From c6804400876067f6124ef1349b1b03814c29f092 Mon Sep 17 00:00:00 2001 From: Shaun Struwig <41984034+Blargian@users.noreply.github.com> Date: Tue, 7 Oct 2025 11:52:46 +0200 Subject: [PATCH 1/2] Redo Zh translation --- docs/cloud/guides/index.md | 23 +- .../current/_clients/go/README.md | 7 +- .../api/_invitations-api-reference.md | 5 +- .../api/_invitations-api-reference.md.hash | 2 +- .../_placeholders/api/_keys-api-reference.md | 3 +- .../api/_keys-api-reference.md.hash | 2 +- .../api/_members-api-reference.md | 5 +- .../api/_members-api-reference.md.hash | 2 +- .../api/_organizations-api-reference.md | 5 +- .../api/_organizations-api-reference.md.hash | 2 +- .../api/_services-api-reference.md | 3 +- .../api/_services-api-reference.md.hash | 2 +- .../current/_placeholders/changelog/_index.md | 3 +- .../_placeholders/changelog/_index.md.hash | 2 +- .../_GCS_authentication_and_bucket.md | 33 +- .../_GCS_authentication_and_bucket.md.hash | 2 +- .../_S3_authentication_and_bucket.md | 71 +- .../_add_remote_ip_access_list_detail.md | 9 +- .../current/_snippets/_add_superset_detail.md | 27 +- .../_snippets/_add_superset_detail.md.hash | 2 +- .../current/_snippets/_aws_regions.md | 15 +- .../current/_snippets/_aws_regions.md.hash | 2 +- .../_clickhouse_mysql_cloud_setup.mdx | 104 +- .../_clickhouse_mysql_cloud_setup.mdx.hash | 2 +- .../_clickhouse_mysql_on_premise_setup.mdx | 31 +- .../current/_snippets/_config-files.md | 7 +- .../_snippets/_gather_your_details_http.mdx | 21 +- .../_snippets/_gather_your_details_native.md | 21 +- .../_gather_your_details_native.md.hash | 2 +- .../current/_snippets/_gcp_regions.md | 15 +- .../current/_snippets/_gcp_regions.md.hash | 2 +- .../current/_snippets/_keeper-config-files.md | 7 +- .../current/_snippets/_launch_sql_console.md | 9 +- .../_snippets/_launch_sql_console.md.hash | 2 +- .../_replication-sharding-terminology.md | 11 +- .../_snippets/_self_managed_only_automated.md | 7 +- .../_self_managed_only_no_roadmap.md | 9 +- .../_self_managed_only_not_applicable.md | 7 +- .../_snippets/_self_managed_only_roadmap.md | 9 +- .../_snippets/_service_actions_menu.md | 9 +- .../_snippets/_service_actions_menu.md.hash | 2 +- .../current/_snippets/_system_table_cloud.md | 7 +- .../current/_snippets/_tabs.md | 23 - .../current/_snippets/_tabs.md.hash | 1 - .../_snippets/_users-and-roles-common.md | 110 +- .../_snippets/_users-and-roles-common.md.hash | 2 +- .../current/about-us/about-faq-index.md | 27 +- .../current/about-us/about-faq-index.md.hash | 2 +- .../current/about-us/adopters.md | 615 +- .../beta-and-experimental-features.md | 161 +- .../beta-and-experimental-features.md.hash | 2 +- .../current/about-us/cloud.md | 48 +- .../current/about-us/cloud.md.hash | 2 +- .../current/about-us/distinctive-features.md | 73 +- .../about-us/distinctive-features.md.hash | 2 +- .../current/about-us/history.md | 56 +- .../current/about-us/history.md.hash | 2 +- .../current/about-us/index.md | 21 +- .../current/about-us/index.md.hash | 2 +- .../current/about-us/intro.mdx | 1 + .../current/about-us/intro.mdx.hash | 2 +- .../current/about-us/support.md | 11 +- .../current/about-us/support.md.hash | 2 +- .../architecture/cluster-deployment.md | 153 - .../architecture/cluster-deployment.md.hash | 1 - .../_snippets/_async_inserts.md | 47 +- .../_snippets/_async_inserts.md.hash | 2 +- .../_snippets/_avoid_mutations.md | 19 +- .../_snippets/_avoid_nullable_columns.md | 13 +- .../_snippets/_avoid_optimize_final.md | 45 +- .../_snippets/_avoid_optimize_final.md.hash | 2 +- .../best-practices/_snippets/_bulk_inserts.md | 15 +- .../_snippets/_table_of_contents.md | 12 + .../_snippets/_table_of_contents.md.hash | 1 + .../current/best-practices/avoid_mutations.md | 7 +- .../best-practices/avoid_mutations.md.hash | 2 +- .../best-practices/avoid_optimize_final.md | 5 + .../avoid_optimize_final.md.hash | 2 +- .../best-practices/choosing_a_primary_key.md | 47 +- .../choosing_a_primary_key.md.hash | 2 +- .../current/best-practices/index.md | 24 +- .../current/best-practices/index.md.hash | 2 +- .../current/best-practices/json_type.md | 61 +- .../current/best-practices/json_type.md.hash | 2 +- .../best-practices/minimize_optimize_joins.md | 63 +- .../minimize_optimize_joins.md.hash | 2 +- .../best-practices/partitioning_keys.mdx | 50 +- .../best-practices/partitioning_keys.mdx.hash | 2 +- .../best-practices/select_data_type.md | 81 +- .../best-practices/select_data_type.md.hash | 2 +- .../selecting_an_insert_strategy.md | 107 +- .../selecting_an_insert_strategy.md.hash | 2 +- .../sizing-and-hardware-recommendations.md | 99 +- ...izing-and-hardware-recommendations.md.hash | 2 +- .../best-practices/use_materialized_views.md | 71 +- .../use_materialized_views.md.hash | 2 +- .../use_materialized_views.translate_override | 5 - .../using_data_skipping_indices.md | 63 +- .../using_data_skipping_indices.md.hash | 2 +- .../current/chdb/api/python.md | 3260 +++++++++ .../current/chdb/api/python.md.hash | 1 + .../current/chdb/getting-started.md | 89 +- .../current/chdb/getting-started.md.hash | 2 +- .../current/chdb/guides/clickhouse-local.md | 37 +- .../chdb/guides/clickhouse-local.md.hash | 2 +- .../current/chdb/guides/index.md | 22 +- .../current/chdb/guides/index.md.hash | 2 +- .../current/chdb/guides/jupysql.md | 77 +- .../current/chdb/guides/jupysql.md.hash | 2 +- .../chdb/guides/query-remote-clickhouse.md | 35 +- .../guides/query-remote-clickhouse.md.hash | 2 +- .../chdb/guides/querying-apache-arrow.md | 31 +- .../chdb/guides/querying-apache-arrow.md.hash | 2 +- .../current/chdb/guides/querying-pandas.md | 41 +- .../chdb/guides/querying-pandas.md.hash | 2 +- .../current/chdb/guides/querying-parquet.md | 39 +- .../chdb/guides/querying-parquet.md.hash | 2 +- .../current/chdb/guides/querying-s3-bucket.md | 47 +- .../chdb/guides/querying-s3-bucket.md.hash | 2 +- .../current/chdb/index.md | 78 +- .../current/chdb/index.md.hash | 2 +- .../current/chdb/install/bun.md | 131 +- .../current/chdb/install/bun.md.hash | 2 +- .../current/chdb/install/c.md | 342 +- .../current/chdb/install/c.md.hash | 2 +- .../current/chdb/install/go.md | 251 +- .../current/chdb/install/go.md.hash | 2 +- .../current/chdb/install/index.md | 19 +- .../current/chdb/install/index.md.hash | 2 +- .../current/chdb/install/nodejs.md | 212 +- .../current/chdb/install/nodejs.md.hash | 2 +- .../current/chdb/install/python.md | 862 ++- .../current/chdb/install/python.md.hash | 2 +- .../current/chdb/install/rust.md | 157 +- .../current/chdb/install/rust.md.hash | 2 +- .../current/chdb/reference/data-formats.md | 176 +- .../chdb/reference/data-formats.md.hash | 2 +- .../current/chdb/reference/index.md | 5 +- .../current/chdb/reference/index.md.hash | 2 +- .../current/chdb/reference/sql-reference.md | 7 +- .../chdb/reference/sql-reference.md.hash | 2 +- .../current/cloud-index.md | 14 - .../current/cloud-index.md.hash | 1 - .../cloud/_snippets/_clickpipes_faq.md | 112 + .../cloud/_snippets/_clickpipes_faq.md.hash | 1 + .../_snippets/_security_table_of_contents.md | 8 + .../_security_table_of_contents.md.hash | 1 + .../current/cloud/bestpractices/index.md | 42 - .../current/cloud/bestpractices/index.md.hash | 1 - .../cloud/bestpractices/multitenancy.md.hash | 1 - .../cloud/bestpractices/usagelimits.md | 31 - .../cloud/bestpractices/usagelimits.md.hash | 1 - .../current/cloud/features/01_cloud_tiers.md | 206 + .../cloud/features/01_cloud_tiers.md.hash | 1 + .../current/cloud/features/02_integrations.md | 68 + .../cloud/features/02_integrations.md.hash | 1 + .../01_sql-console.md} | 141 +- .../01_sql-console.md.hash | 1 + .../02_query-insights.md | 58 + .../02_query-insights.md.hash | 1 + .../03_query-endpoints.md} | 85 +- .../03_query-endpoints.md.hash | 1 + .../03_sql_console_features/04_dashboards.md | 105 + .../04_dashboards.md.hash | 1 + .../03_sql_console_features/_category_.json | 5 + .../03_sql_console_features/hyperdx.md | 30 + .../03_sql_console_features/hyperdx.md.hash | 1 + .../04_infrastructure/_category_.json | 5 + .../04_infrastructure/automatic_scaling.md | 157 + .../automatic_scaling.md.hash | 1 + .../cloud/features/04_infrastructure/byoc.md | 497 ++ .../features/04_infrastructure/byoc.md.hash | 1 + .../replica-aware-routing.md | 49 + .../replica-aware-routing.md.hash | 1 + .../04_infrastructure/shared-catalog.md | 89 + .../04_infrastructure/shared-catalog.md.hash | 1 + .../04_infrastructure/shared-merge-tree.md | 120 + .../shared-merge-tree.md.hash | 1 + .../features/04_infrastructure/warehouses.md | 192 + .../04_infrastructure/warehouses.md.hash | 1 + .../05_admin_features/_category_.json | 5 + .../05_admin_features/api/api-overview.md | 56 + .../api/api-overview.md.hash | 1 + .../features/05_admin_features/api/index.md | 14 + .../05_admin_features/api/index.md.hash | 1 + .../features/05_admin_features/api/openapi.md | 65 + .../05_admin_features/api/openapi.md.hash | 1 + .../05_admin_features/api}/postman.md | 79 +- .../05_admin_features/api/postman.md.hash | 1 + .../features/05_admin_features/upgrades.md | 129 + .../05_admin_features/upgrades.md.hash | 1 + .../01_shared-responsibility-model.md | 108 + .../01_shared-responsibility-model.md.hash | 1 + .../_category_.json | 5 + .../cloud-access-management.md | 148 + .../cloud-access-management.md.hash | 1 + .../cloud-authentication.md | 131 + .../cloud-authentication.md.hash | 1 + .../02_cloud-access-management/index.md | 11 + .../02_cloud-access-management/index.md.hash | 1 + .../01_private-link-overview.md | 18 + .../01_private-link-overview.md.hash | 1 + .../03_connectivity/_category_.json | 6 + .../06_security/03_connectivity/index.md | 15 + .../06_security/03_connectivity/index.md.hash | 1 + .../features/06_security/_category_.json | 5 + .../cloud/features/06_security/cmek.md | 112 + .../cloud/features/06_security/cmek.md.hash | 1 + .../features/07_monitoring/_category_.json | 5 + .../07_monitoring/advanced_dashboard.md | 251 + .../07_monitoring/advanced_dashboard.md.hash | 1 + .../features/07_monitoring/notifications.md | 49 + .../07_monitoring/notifications.md.hash | 1 + .../features/07_monitoring}/prometheus.md | 108 +- .../features/07_monitoring/prometheus.md.hash | 1 + .../08_backups/configurable-backups.md | 49 + .../08_backups/configurable-backups.md.hash | 1 + .../export-backups-to-own-cloud-account.md | 81 +- ...xport-backups-to-own-cloud-account.md.hash | 1 + .../cloud/features/08_backups/index.md | 16 + .../cloud/features/08_backups/index.md.hash | 1 + .../cloud/features/08_backups/overview.md | 187 + .../features/08_backups/overview.md.hash | 1 + .../{support.md => features/09_support.md} | 5 +- .../current/cloud/features/09_support.md.hash | 1 + .../current/cloud/features/_category_.json | 5 + .../cloud/get-started/cloud-quick-start.mdx | 328 - .../get-started/cloud-quick-start.mdx.hash | 1 - .../current/cloud/get-started/index.md | 24 - .../current/cloud/get-started/index.md.hash | 1 - .../cloud/get-started/query-endpoints.md.hash | 1 - .../cloud/get-started/query-insights.md | 57 - .../cloud/get-started/query-insights.md.hash | 1 - .../cloud/get-started/sql-console.md.hash | 1 - .../cloud/guides/SQL_console/_category_.json | 5 + ...figure_org_and_service_role_assignments.md | 84 + ...e_org_and_service_role_assignments.md.hash | 1 + .../configure_sql_console_role_assignments.md | 73 + ...igure_sql_console_role_assignments.md.hash | 1 + .../guides/SQL_console/connection_details.md | 11 + .../SQL_console/connection_details.md.hash | 1 + .../{bestpractices => guides}/_category_.yml | 2 +- .../guides/best_practices/_category_.json | 5 + .../cloud/guides/best_practices/index.md | 34 + .../cloud/guides/best_practices/index.md.hash | 1 + .../best_practices}/multitenancy.md | 99 +- .../best_practices/multitenancy.md.hash | 1 + .../guides/best_practices/usagelimits.md | 33 + .../guides/best_practices/usagelimits.md.hash | 1 + .../cloud/guides/cloud-compatibility.md | 128 + .../cloud/guides/cloud-compatibility.md.hash | 1 + .../cloud/guides/security/_category_.json | 5 + .../cloud_access_management/_category_.json | 5 + .../common-access-management-queries.md | 25 +- .../common-access-management-queries.md.hash | 1 + .../inviting-new-users.md | 9 +- .../inviting-new-users.md.hash | 1 + .../cloud_access_management/saml-sso-setup.md | 369 + .../saml-sso-setup.md.hash | 1 + .../security/connectivity/_category_.json | 5 + .../accessing-s3-data-securely.md | 148 + .../accessing-s3-data-securely.md.hash | 1 + .../connectivity/cloud-endpoints-api.md | 49 + .../connectivity/cloud-endpoints-api.md.hash | 1 + .../private_networking/02_aws-privatelink.md | 386 ++ .../02_aws-privatelink.md.hash | 1 + .../03_gcp-private-service-connect.md | 439 ++ .../03_gcp-private-service-connect.md.hash | 1 + .../04_azure-privatelink.md | 559 ++ .../04_azure-privatelink.md.hash | 1 + .../private_networking/_category_.json | 5 + .../connectivity/setting-ip-filters.md | 110 + .../connectivity/setting-ip-filters.md.hash | 1 + .../cloud/guides/security/data_masking.md | 336 + .../guides/security/data_masking.md.hash | 1 + .../current/cloud/manage/_category_.yml | 6 - .../current/cloud/manage/account-close.md | 52 - .../cloud/manage/account-close.md.hash | 1 - .../current/cloud/manage/api/api-overview.md | 36 - .../cloud/manage/api/api-overview.md.hash | 1 - .../current/cloud/manage/api/index.md | 13 - .../current/cloud/manage/api/index.md.hash | 1 - .../manage/backups/configurable-backups.md | 44 - .../backups/configurable-backups.md.hash | 1 - ...xport-backups-to-own-cloud-account.md.hash | 1 - .../current/cloud/manage/backups/index.md | 15 - .../cloud/manage/backups/index.md.hash | 1 - .../current/cloud/manage/backups/overview.md | 180 - .../cloud/manage/backups/overview.md.hash | 1 - .../current/cloud/manage/billing.md | 573 -- .../current/cloud/manage/billing.md.hash | 1 - .../current/cloud/manage/billing/index.md | 19 - .../cloud/manage/billing/index.md.hash | 1 - .../marketplace/aws-marketplace-committed.md | 98 - .../aws-marketplace-committed.md.hash | 1 - .../marketplace/aws-marketplace-payg.md.hash | 1 - .../azure-marketplace-committed.md.hash | 1 - .../azure-marketplace-payg.md.hash | 1 - .../gcp-marketplace-committed.md.hash | 1 - .../marketplace/gcp-marketplace-payg.md.hash | 1 - .../cloud/manage/billing/marketplace/index.md | 21 - .../manage/billing/marketplace/index.md.hash | 1 - .../manage/billing/marketplace/overview.md | 98 - .../billing/marketplace/overview.md.hash | 1 - .../manage/billing/payment-thresholds.md | 24 - .../manage/billing/payment-thresholds.md.hash | 1 - .../current/cloud/manage/cloud-tiers.md | 208 - .../current/cloud/manage/cloud-tiers.md.hash | 1 - .../current/cloud/manage/dashboards.md | 106 - .../current/cloud/manage/dashboards.md.hash | 1 - .../current/cloud/manage/index.md | 35 - .../current/cloud/manage/index.md.hash | 1 - .../current/cloud/manage/integrations.md | 32 - .../current/cloud/manage/integrations.md.hash | 1 - .../jan2025_faq/_snippets/_clickpipes_faq.md | 142 - .../_snippets/_clickpipes_faq.md.hash | 1 - .../cloud/manage/jan2025_faq/backup.md | 22 - .../cloud/manage/jan2025_faq/backup.md.hash | 1 - .../cloud/manage/jan2025_faq/billing.md | 49 - .../cloud/manage/jan2025_faq/billing.md.hash | 1 - .../cloud/manage/jan2025_faq/dimensions.md | 40 - .../manage/jan2025_faq/dimensions.md.hash | 1 - .../current/cloud/manage/jan2025_faq/index.md | 23 - .../cloud/manage/jan2025_faq/index.md.hash | 1 - .../cloud/manage/jan2025_faq/new_tiers.md | 68 - .../manage/jan2025_faq/new_tiers.md.hash | 1 - .../manage/jan2025_faq/plan_migrations.md | 112 - .../jan2025_faq/plan_migrations.md.hash | 1 - .../cloud/manage/jan2025_faq/scaling.md | 39 - .../cloud/manage/jan2025_faq/scaling.md.hash | 1 - .../cloud/manage/jan2025_faq/summary.md | 97 - .../cloud/manage/jan2025_faq/summary.md.hash | 1 - .../cloud/manage/network-data-transfer.mdx | 32 - .../manage/network-data-transfer.mdx.hash | 1 - .../current/cloud/manage/notifications.md | 48 - .../cloud/manage/notifications.md.hash | 1 - .../current/cloud/manage/openapi.md | 64 - .../current/cloud/manage/openapi.md.hash | 1 - .../current/cloud/manage/postman.md.hash | 1 - .../cloud/manage/replica-aware-routing.md | 44 - .../manage/replica-aware-routing.md.hash | 1 - .../current/cloud/manage/scaling.md | 149 - .../current/cloud/manage/scaling.md.hash | 1 - .../current/cloud/manage/service-uptime.md | 14 - .../cloud/manage/service-uptime.md.hash | 1 - .../current/cloud/manage/settings.md.hash | 1 - .../manage/troubleshooting-billing-issues.md | 21 - .../troubleshooting-billing-issues.md.hash | 1 - .../current/cloud/manage/upgrades.md | 101 - .../current/cloud/manage/upgrades.md.hash | 1 - .../cloud/onboard/01_discover/01_what_is.md | 48 + .../onboard/01_discover/01_what_is.md.hash | 1 + .../01_discover/02_use_cases/00_overview.md | 21 + .../02_use_cases/00_overview.md.hash | 1 + .../02_use_cases/01_real-time-analytics.md | 106 + .../01_real-time-analytics.md.hash | 1 + .../02_use_cases/02_observability.md | 135 + .../02_use_cases/02_observability.md.hash | 1 + .../02_use_cases/03_data_warehousing.md | 78 + .../02_use_cases/03_data_warehousing.md.hash | 1 + .../01_machine_learning.md | 111 + .../01_machine_learning.md.hash | 1 + .../02_agent_facing_analytics.md | 84 + .../02_agent_facing_analytics.md.hash | 1 + .../_category_.json | 5 + .../01_discover/02_use_cases/_category_.json | 5 + .../01_migration_guides/01_overview.md | 40 + .../01_migration_guides/01_overview.md.hash | 1 + .../02_postgres/01_overview.md | 53 + .../02_postgres/01_overview.md.hash | 1 + .../02_postgres/appendix.md | 193 + .../02_postgres/appendix.md.hash | 1 + .../01_migration_guides/02_postgres}/index.md | 11 +- .../02_postgres/index.md.hash | 1 + .../01_migration_guide_part1.md | 190 + .../01_migration_guide_part1.md.hash | 1 + .../02_migration_guide_part2.md} | 34 +- .../02_migration_guide_part2.md.hash | 1 + .../03_migration_guide_part3.md | 270 + .../03_migration_guide_part3.md.hash | 1 + .../migration_guide/_category_.json | 5 + .../03_bigquery/01_overview.md | 482 ++ .../03_bigquery/01_overview.md.hash | 1 + .../02_migrating-to-clickhouse-cloud.md | 533 ++ .../02_migrating-to-clickhouse-cloud.md.hash | 1 + .../03_bigquery/03_loading-data.md | 140 + .../03_bigquery/03_loading-data.md.hash | 1 + .../01_migration_guides/03_bigquery/index.md | 19 + .../03_bigquery/index.md.hash | 1 + .../04_snowflake/01_overview.md | 69 + .../04_snowflake/01_overview.md.hash | 1 + .../04_snowflake/02_migration_guide.md | 115 + .../04_snowflake/02_migration_guide.md.hash | 1 + .../03_sql_translation_reference.md | 66 + .../03_sql_translation_reference.md.hash | 1 + .../04_snowflake/_category_.json | 5 + .../05_elastic/01_overview.md | 15 + .../05_elastic/01_overview.md.hash | 1 + .../05_elastic/_category_.json | 5 + .../06_redshift/01_overview.md | 34 + .../06_redshift/01_overview.md.hash | 1 + .../06_redshift/02_migration_guide.md | 16 + .../06_redshift/02_migration_guide.md.hash | 1 + .../03_sql_translation_reference.md | 67 + .../03_sql_translation_reference.md.hash | 1 + .../06_redshift/_category_.json | 5 + .../01_clickhouse-to-cloud.md} | 86 +- .../01_clickhouse-to-cloud.md.hash | 1 + .../07_OSS_to_Cloud/_category_.json | 5 + .../01_clickhouse-local-etl.md | 146 + .../01_clickhouse-local-etl.md.hash | 1 + .../02_etl-tool-to-clickhouse.md} | 8 +- .../02_etl-tool-to-clickhouse.md.hash | 1 + .../03_object-storage-to-clickhouse.md | 32 + .../03_object-storage-to-clickhouse.md.hash | 1 + .../08_other_methods/_category_.json | 5 + .../01_migration_guides/_category_.json | 5 + .../_monitoring_table_of_contents.md | 3 + .../_monitoring_table_of_contents.md.hash | 1 + .../cloud/onboard/03_tune/resource_tour.md | 49 + .../onboard/03_tune/resource_tour.md.hash | 1 + .../current/cloud/onboard/index.md | 40 + .../current/cloud/onboard/index.md.hash | 1 + .../01_changelog.md} | 219 +- .../01_changelog/02_release_notes/24_02.md} | 12 +- .../01_changelog/02_release_notes/24_05.md} | 13 +- .../01_changelog/02_release_notes/24_06.md} | 10 +- .../01_changelog/02_release_notes/24_08.md} | 9 +- .../01_changelog/02_release_notes/24_10.md} | 11 +- .../01_changelog/02_release_notes/24_12.md} | 8 +- .../01_changelog/02_release_notes/25_04.md} | 16 +- .../01_changelog/02_release_notes/25_06.md | 396 ++ .../02_release_notes/_category_.json | 6 + .../01_changelog/02_release_notes/index.md | 25 + .../reference/01_changelog/_category_.json | 6 + .../cloud/reference/01_changelog/index.md | 11 + .../cloud/reference/02_architecture.md | 55 + .../cloud/reference/02_architecture.md.hash | 1 + .../03_billing/01_billing_overview.md | 386 ++ .../03_billing/01_billing_overview.md.hash | 1 + .../aws-marketplace-committed.md | 105 + .../aws-marketplace-committed.md.hash | 1 + .../02_marketplace}/aws-marketplace-payg.md | 65 +- .../aws-marketplace-payg.md.hash | 1 + .../azure-marketplace-committed.md | 63 +- .../azure-marketplace-committed.md.hash | 1 + .../02_marketplace}/azure-marketplace-payg.md | 63 +- .../azure-marketplace-payg.md.hash | 1 + .../gcp-marketplace-committed.md | 27 +- .../gcp-marketplace-committed.md.hash | 1 + .../02_marketplace}/gcp-marketplace-payg.md | 41 +- .../gcp-marketplace-payg.md.hash | 1 + .../03_billing/02_marketplace/index.md | 22 + .../03_billing/02_marketplace/index.md.hash | 1 + .../migrate-marketplace-payg-committed.md | 88 + ...migrate-marketplace-payg-committed.md.hash | 1 + .../03_billing/02_marketplace/overview.md | 99 + .../02_marketplace/overview.md.hash | 1 + .../03_clickpipes/clickpipes_for_cdc.md | 145 + .../03_clickpipes/clickpipes_for_cdc.md.hash | 1 + ...kpipes_for_streaming_and_object_storage.md | 86 + ...s_for_streaming_and_object_storage.md.hash | 1 + .../03_billing/03_clickpipes/index.md | 19 + .../03_billing/03_clickpipes/index.md.hash | 1 + .../03_billing/04_network-data-transfer.mdx | 40 + .../04_network-data-transfer.mdx.hash | 1 + .../03_billing/05_payment-thresholds.md | 25 + .../03_billing/05_payment-thresholds.md.hash | 1 + .../03_billing/06_billing_compliance.md | 91 + .../03_billing/06_billing_compliance.md.hash | 1 + .../cloud/reference/03_billing/index.md | 20 + .../cloud/reference/03_billing/index.md.hash | 1 + ...ted-regions.md => 05_supported-regions.md} | 53 +- .../reference/05_supported-regions.md.hash | 1 + .../cloud/reference/06_service-uptime.md | 15 + .../cloud/reference/06_service-uptime.md.hash | 1 + .../settings.md => reference/08_settings.md} | 7 +- .../cloud/reference/08_settings.md.hash | 1 + .../reference/09_security/_category_.json | 5 + .../09_security}/audit-logging.md | 22 +- .../09_security/audit-logging.md.hash | 1 + .../privacy_and_compliance/_category_.json | 6 + .../compliance-overview.md | 68 + .../compliance-overview.md.hash | 1 + .../privacy_and_compliance/index.md | 17 + .../privacy_and_compliance/index.md.hash | 1 + .../personal-data-access.md | 63 + .../personal-data-access.md.hash | 1 + .../cloud/reference/10_account-close.md | 53 + .../cloud/reference/10_account-close.md.hash | 1 + .../_snippets/_network_transfer_rates.md | 101 +- .../_snippets/_network_transfer_rates.md.hash | 0 .../current/cloud/reference/architecture.md | 54 - .../cloud/reference/architecture.md.hash | 1 - .../current/cloud/reference/byoc.md | 439 -- .../current/cloud/reference/byoc.md.hash | 1 - .../cloud/reference/changelogs-index.md | 10 - .../cloud/reference/changelogs-index.md.hash | 1 - .../cloud/reference/cloud-compatibility.md | 127 - .../reference/cloud-compatibility.md.hash | 1 - .../current/cloud/reference/index.md | 25 +- .../current/cloud/reference/index.md.hash | 2 +- .../cloud/reference/release-notes-index.md | 18 - .../reference/release-notes-index.md.hash | 1 - .../cloud/reference/shared-merge-tree.md | 121 - .../cloud/reference/shared-merge-tree.md.hash | 1 - .../cloud/reference/supported-regions.md.hash | 1 - .../current/cloud/reference/warehouses.md | 189 - .../cloud/reference/warehouses.md.hash | 1 - .../current/cloud/security/_category_.yml | 6 - .../security/accessing-s3-data-securely.md | 147 - .../accessing-s3-data-securely.md.hash | 1 - .../cloud/security/audit-logging.md.hash | 1 - .../current/cloud/security/aws-privatelink.md | 359 - .../cloud/security/aws-privatelink.md.hash | 1 - .../cloud/security/azure-privatelink.md | 547 -- .../cloud/security/azure-privatelink.md.hash | 1 - .../cloud-access-management.md | 127 - .../cloud-access-management.md.hash | 1 - .../cloud-authentication.md | 127 - .../cloud-authentication.md.hash | 1 - .../security/cloud-access-management/index.md | 13 - .../cloud-access-management/index.md.hash | 1 - .../cloud/security/cloud-endpoints-api.md | 48 - .../security/cloud-endpoints-api.md.hash | 1 - .../current/cloud/security/cmek.md | 111 - .../current/cloud/security/cmek.md.hash | 1 - .../common-access-management-queries.md.hash | 1 - .../cloud/security/compliance-overview.md | 68 - .../security/compliance-overview.md.hash | 1 - .../cloud/security/connectivity-overview.md | 17 - .../security/connectivity-overview.md.hash | 1 - .../security/gcp-private-service-connect.md | 440 -- .../gcp-private-service-connect.md.hash | 1 - .../current/cloud/security/index.md | 23 - .../current/cloud/security/index.md.hash | 1 - .../cloud/security/inviting-new-users.md.hash | 1 - .../cloud/security/personal-data-access.md | 62 - .../security/personal-data-access.md.hash | 1 - .../security/privacy-compliance-overview.md | 16 - .../privacy-compliance-overview.md.hash | 1 - .../cloud/security/private-link-overview.md | 15 - .../security/private-link-overview.md.hash | 1 - .../current/cloud/security/saml-sso-setup.md | 367 - .../cloud/security/saml-sso-setup.md.hash | 1 - .../cloud/security/setting-ip-filters.md | 84 - .../cloud/security/setting-ip-filters.md.hash | 1 - .../security/shared-responsibility-model.md | 109 - .../shared-responsibility-model.md.hash | 1 - .../current/cloud/support.md.hash | 1 - .../current/concepts/glossary.md | 102 +- .../current/concepts/glossary.md.hash | 2 +- .../current/concepts/index.md | 17 +- .../current/concepts/index.md.hash | 2 +- .../current/concepts/olap.md | 27 +- .../current/concepts/olap.md.hash | 2 +- .../concepts/why-clickhouse-is-so-fast.md | 147 - .../why-clickhouse-is-so-fast.md.hash | 1 - .../concepts/why-clickhouse-is-so-fast.mdx | 148 + .../why-clickhouse-is-so-fast.mdx.hash | 1 + .../compression-in-clickhouse.md | 325 +- .../compression-in-clickhouse.md.hash | 2 +- .../data-compression/compression-modes.md | 30 +- .../compression-modes.md.hash | 2 +- .../current/data-modeling/backfilling.md | 188 +- .../current/data-modeling/backfilling.md.hash | 2 +- .../current/data-modeling/denormalization.md | 123 +- .../data-modeling/denormalization.md.hash | 2 +- .../current/data-modeling/index.md | 19 +- .../current/data-modeling/index.md.hash | 2 +- .../current/data-modeling/projections.md | 448 -- .../current/data-modeling/projections.md.hash | 1 - .../projections/1_projections.md | 568 ++ .../projections/1_projections.md.hash | 1 + ...2_materialized-views-versus-projections.md | 75 + ...erialized-views-versus-projections.md.hash | 1 + .../current/data-modeling/schema-design.md | 188 +- .../data-modeling/schema-design.md.hash | 2 +- .../deployment-guides/horizontal-scaling.md | 485 -- .../horizontal-scaling.md.hash | 1 - .../current/deployment-guides/index.md | 15 +- .../current/deployment-guides/index.md.hash | 2 +- .../deployment-guides/parallel-replicas.mdx | 152 +- .../parallel-replicas.mdx.hash | 2 +- .../current/deployment-guides/replicated.md | 564 -- .../deployment-guides/replicated.md.hash | 1 - .../01_1_shard_2_replicas.md | 766 +++ .../01_1_shard_2_replicas.md.hash | 1 + .../02_2_shards_1_replica.md | 773 +++ .../02_2_shards_1_replica.md.hash | 1 + .../03_2_shards_2_replicas.md | 701 ++ .../03_2_shards_2_replicas.md.hash | 1 + .../_snippets/_cloud_tip.mdx | 7 + .../_snippets/_cloud_tip.mdx.hash | 1 + .../_snippets/_config_explanation.mdx | 14 + .../_snippets/_config_explanation.mdx.hash | 1 + .../_snippets/_dedicated_keeper_servers.mdx | 5 + .../_dedicated_keeper_servers.mdx.hash | 1 + .../_snippets/_keeper_config.mdx | 57 + .../_snippets/_keeper_config.mdx.hash | 1 + .../_snippets/_keeper_explanation.mdx | 32 + .../_snippets/_keeper_explanation.mdx.hash | 1 + .../_snippets/_listen_host.mdx | 17 + .../_snippets/_listen_host.mdx.hash | 1 + .../_snippets/_server_parameter_table.mdx | 6 + .../_server_parameter_table.mdx.hash | 1 + .../_snippets/_verify_keeper_using_mntr.mdx | 67 + .../_verify_keeper_using_mntr.mdx.hash | 1 + .../_snippets/_working_example.mdx | 3 + .../_snippets/_working_example.mdx.hash | 1 + .../current/deployment-guides/terminology.md | 23 +- .../deployment-guides/terminology.md.hash | 2 +- .../current/deployment-modes.md | 47 +- .../current/deployment-modes.md.hash | 2 +- .../current/development/architecture.md | 245 +- .../current/development/architecture.md.hash | 2 +- .../current/development/build-cross-arm.md | 13 +- .../development/build-cross-arm.md.hash | 2 +- .../development/build-cross-loongarch.md | 13 +- .../development/build-cross-loongarch.md.hash | 2 +- .../current/development/build-cross-osx.md | 25 +- .../development/build-cross-osx.md.hash | 2 +- .../current/development/build-cross-riscv.md | 7 +- .../development/build-cross-riscv.md.hash | 2 +- .../current/development/build-cross-s390x.md | 43 +- .../development/build-cross-s390x.md.hash | 2 +- .../current/development/build-osx.md | 33 +- .../current/development/build-osx.md.hash | 2 +- .../current/development/build.md | 84 +- .../current/development/build.md.hash | 2 +- .../building_and_benchmarking_deflate_qpl.md | 105 +- ...lding_and_benchmarking_deflate_qpl.md.hash | 2 +- .../development/continuous-integration.md | 141 +- .../continuous-integration.md.hash | 2 +- .../current/development/contrib.md | 36 +- .../current/development/contrib.md.hash | 2 +- .../development/developer-instruction.md | 93 +- .../development/developer-instruction.md.hash | 2 +- .../current/development/index.md | 33 +- .../current/development/index.md.hash | 2 +- .../development/integrating_rust_libraries.md | 26 +- .../integrating_rust_libraries.md.hash | 2 +- .../current/development/style.md | 371 +- .../current/development/style.md.hash | 2 +- .../current/development/tests.md | 370 +- .../current/development/tests.md.hash | 2 +- .../current/dictionary/index.md | 90 +- .../current/dictionary/index.md.hash | 2 +- .../engines/database-engines/atomic.md | 40 +- .../engines/database-engines/atomic.md.hash | 2 +- .../engines/database-engines/backup.md | 19 +- .../engines/database-engines/backup.md.hash | 2 +- .../engines/database-engines/datalake.md | 65 + .../engines/database-engines/datalake.md.hash | 1 + .../current/engines/database-engines/index.md | 21 +- .../engines/database-engines/index.md.hash | 2 +- .../current/engines/database-engines/lazy.md | 9 +- .../engines/database-engines/lazy.md.hash | 2 +- .../materialized-postgresql.md | 95 +- .../materialized-postgresql.md.hash | 2 +- .../current/engines/database-engines/mysql.md | 19 +- .../engines/database-engines/mysql.md.hash | 2 +- .../engines/database-engines/postgresql.md | 27 +- .../database-engines/postgresql.md.hash | 2 +- .../engines/database-engines/replicated.md | 41 +- .../database-engines/replicated.md.hash | 2 +- .../engines/database-engines/sqlite.md | 17 +- .../engines/database-engines/sqlite.md.hash | 2 +- .../current/engines/index.md | 9 +- .../current/engines/index.md.hash | 2 +- .../current/engines/table-engines/index.md | 126 +- .../engines/table-engines/index.md.hash | 2 +- .../integrations/ExternalDistributed.md | 23 +- .../integrations/ExternalDistributed.md.hash | 2 +- .../table-engines/integrations/arrowflight.md | 67 + .../integrations/arrowflight.md.hash | 1 + .../table-engines/integrations/azure-queue.md | 32 +- .../integrations/azure-queue.md.hash | 2 +- .../integrations/azureBlobStorage.md | 77 +- .../integrations/azureBlobStorage.md.hash | 2 +- .../table-engines/integrations/deltalake.md | 11 +- .../integrations/deltalake.md.hash | 2 +- .../integrations/embedded-rocksdb.md | 62 +- .../integrations/embedded-rocksdb.md.hash | 2 +- .../table-engines/integrations/hdfs.md | 188 +- .../table-engines/integrations/hdfs.md.hash | 2 +- .../table-engines/integrations/hive.md | 55 +- .../table-engines/integrations/hive.md.hash | 2 +- .../table-engines/integrations/hudi.md | 15 +- .../table-engines/integrations/hudi.md.hash | 2 +- .../table-engines/integrations/iceberg.md | 106 +- .../integrations/iceberg.md.hash | 2 +- .../table-engines/integrations/index.md | 41 +- .../table-engines/integrations/index.md.hash | 2 +- .../table-engines/integrations/jdbc.md | 23 +- .../table-engines/integrations/jdbc.md.hash | 2 +- .../table-engines/integrations/kafka.md | 157 +- .../table-engines/integrations/kafka.md.hash | 2 +- .../integrations/materialized-postgresql.md | 39 +- .../materialized-postgresql.md.hash | 2 +- .../table-engines/integrations/mongodb.md | 109 +- .../integrations/mongodb.md.hash | 2 +- .../table-engines/integrations/mysql.md | 57 +- .../table-engines/integrations/mysql.md.hash | 2 +- .../table-engines/integrations/nats.md | 80 +- .../table-engines/integrations/nats.md.hash | 2 +- .../table-engines/integrations/odbc.md | 31 +- .../table-engines/integrations/odbc.md.hash | 2 +- .../table-engines/integrations/postgresql.md | 65 +- .../integrations/postgresql.md.hash | 2 +- .../table-engines/integrations/rabbitmq.md | 120 +- .../integrations/rabbitmq.md.hash | 2 +- .../table-engines/integrations/redis.md | 40 +- .../table-engines/integrations/redis.md.hash | 2 +- .../engines/table-engines/integrations/s3.md | 226 +- .../table-engines/integrations/s3.md.hash | 2 +- .../table-engines/integrations/s3queue.md | 167 +- .../integrations/s3queue.md.hash | 2 +- .../table-engines/integrations/sqlite.md | 13 +- .../table-engines/integrations/sqlite.md.hash | 2 +- .../table-engines/integrations/time-series.md | 138 +- .../integrations/time-series.md.hash | 2 +- .../table-engines/integrations/ytsaurus.md | 131 + .../integrations/ytsaurus.md.hash | 1 + .../engines/table-engines/log-family/index.md | 39 +- .../table-engines/log-family/index.md.hash | 2 +- .../engines/table-engines/log-family/log.md | 33 +- .../table-engines/log-family/log.md.hash | 2 +- .../table-engines/log-family/stripelog.md | 21 +- .../log-family/stripelog.md.hash | 2 +- .../table-engines/log-family/tinylog.md | 27 +- .../table-engines/log-family/tinylog.md.hash | 2 +- .../mergetree-family/aggregatingmergetree.md | 57 +- .../aggregatingmergetree.md.hash | 2 +- .../mergetree-family/annindexes.md | 601 +- .../mergetree-family/annindexes.md.hash | 2 +- .../mergetree-family/coalescingmergetree.md | 141 + .../coalescingmergetree.md.hash | 1 + .../mergetree-family/collapsingmergetree.md | 121 +- .../collapsingmergetree.md.hash | 2 +- .../custom-partitioning-key.md | 72 +- .../custom-partitioning-key.md.hash | 2 +- .../mergetree-family/graphitemergetree.md | 80 +- .../graphitemergetree.md.hash | 2 +- .../table-engines/mergetree-family/index.md | 28 +- .../mergetree-family/index.md.hash | 2 +- .../mergetree-family/invertedindexes.md | 459 +- .../mergetree-family/invertedindexes.md.hash | 2 +- .../mergetree-family/mergetree.md | 624 +- .../mergetree-family/mergetree.md.hash | 2 +- .../mergetree-family/replacingmergetree.md | 61 +- .../replacingmergetree.md.hash | 2 +- .../mergetree-family/replication.md | 197 +- .../mergetree-family/replication.md.hash | 2 +- .../mergetree-family/summingmergetree.md | 61 +- .../mergetree-family/summingmergetree.md.hash | 2 +- .../versionedcollapsingmergetree.md | 77 +- .../versionedcollapsingmergetree.md.hash | 2 +- .../engines/table-engines/special/alias.md | 55 + .../table-engines/special/alias.md.hash | 1 + .../engines/table-engines/special/buffer.md | 99 +- .../table-engines/special/buffer.md.hash | 2 +- .../table-engines/special/dictionary.md | 13 +- .../table-engines/special/dictionary.md.hash | 2 +- .../table-engines/special/distributed.md | 203 +- .../table-engines/special/distributed.md.hash | 2 +- .../table-engines/special/executable.md | 83 +- .../table-engines/special/executable.md.hash | 2 +- .../table-engines/special/external-data.md | 33 +- .../special/external-data.md.hash | 2 +- .../engines/table-engines/special/file.md | 57 +- .../table-engines/special/file.md.hash | 2 +- .../engines/table-engines/special/filelog.md | 57 +- .../table-engines/special/filelog.md.hash | 2 +- .../engines/table-engines/special/generate.md | 25 +- .../table-engines/special/generate.md.hash | 2 +- .../engines/table-engines/special/index.md | 31 +- .../table-engines/special/index.md.hash | 2 +- .../engines/table-engines/special/join.md | 71 +- .../table-engines/special/join.md.hash | 2 +- .../table-engines/special/keepermap.md | 43 +- .../table-engines/special/keepermap.md.hash | 2 +- .../engines/table-engines/special/memory.md | 45 +- .../table-engines/special/memory.md.hash | 2 +- .../engines/table-engines/special/merge.md | 71 +- .../table-engines/special/merge.md.hash | 2 +- .../engines/table-engines/special/null.md | 9 +- .../table-engines/special/null.md.hash | 2 +- .../engines/table-engines/special/set.md | 25 +- .../engines/table-engines/special/set.md.hash | 2 +- .../engines/table-engines/special/url.md | 37 +- .../engines/table-engines/special/url.md.hash | 2 +- .../engines/table-engines/special/view.md | 7 +- .../table-engines/special/view.md.hash | 2 +- .../current/faq/general/columnar-database.md | 17 +- .../faq/general/columnar-database.md.hash | 2 +- .../current/faq/general/dbms-naming.md | 13 +- .../current/faq/general/dbms-naming.md.hash | 2 +- .../current/faq/general/index.md | 11 +- .../current/faq/general/index.md.hash | 2 +- .../current/faq/general/mapreduce.md | 11 +- .../current/faq/general/mapreduce.md.hash | 2 +- .../current/faq/general/ne-tormozit.md | 23 +- .../current/faq/general/ne-tormozit.md.hash | 2 +- .../current/faq/general/olap.md | 31 +- .../current/faq/general/olap.md.hash | 2 +- .../faq/general/who-is-using-clickhouse.md | 13 +- .../general/who-is-using-clickhouse.md.hash | 2 +- .../current/faq/index.md | 15 +- .../current/faq/index.md.hash | 2 +- .../current/faq/integration/index.md | 13 +- .../current/faq/integration/index.md.hash | 2 +- .../current/faq/integration/json-import.md | 13 +- .../faq/integration/json-import.md.hash | 2 +- .../current/faq/integration/oracle-odbc.md | 9 +- .../faq/integration/oracle-odbc.md.hash | 2 +- .../current/faq/operations/delete-old-data.md | 34 +- .../faq/operations/delete-old-data.md.hash | 2 +- .../current/faq/operations/index.md | 13 +- .../current/faq/operations/index.md.hash | 2 +- .../operations/multi-region-replication.md | 9 +- .../multi-region-replication.md.hash | 2 +- .../current/faq/operations/production.md | 77 +- .../current/faq/operations/production.md.hash | 2 +- .../faq/operations/separate_storage.md | 9 +- .../faq/operations/separate_storage.md.hash | 2 +- .../current/faq/troubleshooting.md | 25 - .../current/faq/troubleshooting.md.hash | 1 - .../current/faq/use-cases/index.md | 7 +- .../current/faq/use-cases/index.md.hash | 2 +- .../current/faq/use-cases/key-value.md | 17 +- .../current/faq/use-cases/key-value.md.hash | 2 +- .../current/faq/use-cases/time-series.md | 13 +- .../current/faq/use-cases/time-series.md.hash | 2 +- .../example-datasets/amazon-reviews.md | 41 +- .../example-datasets/amazon-reviews.md.hash | 2 +- .../example-datasets/amplab-benchmark.md | 15 +- .../example-datasets/amplab-benchmark.md.hash | 2 +- .../example-datasets/brown-benchmark.md | 19 +- .../example-datasets/brown-benchmark.md.hash | 2 +- .../example-datasets/cell-towers.md | 111 +- .../example-datasets/cell-towers.md.hash | 2 +- .../example-datasets/covid19.md | 39 +- .../example-datasets/covid19.md.hash | 2 +- .../example-datasets/criteo.md | 17 +- .../example-datasets/criteo.md.hash | 2 +- .../example-datasets/dbpedia.md | 315 + .../example-datasets/dbpedia.md.hash | 1 + .../example-datasets/environmental-sensors.md | 35 +- .../environmental-sensors.md.hash | 2 +- .../example-datasets/foursquare-os-places.md | 60 +- .../foursquare-os-places.md.hash | 2 +- .../example-datasets/github-events.md | 7 +- .../example-datasets/github-events.md.hash | 2 +- .../example-datasets/github.md | 674 +- .../example-datasets/github.md.hash | 2 +- .../hacker-news-vector-search.md | 349 + .../hacker-news-vector-search.md.hash | 1 + .../example-datasets/hacker-news.md | 645 ++ .../example-datasets/hacker-news.md.hash | 1 + .../getting-started/example-datasets/laion.md | 170 +- .../example-datasets/laion.md.hash | 2 +- .../example-datasets/laion5b.md | 196 + .../example-datasets/laion5b.md.hash | 1 + .../getting-started/example-datasets/menus.md | 65 +- .../example-datasets/menus.md.hash | 2 +- .../example-datasets/metrica.md | 29 +- .../example-datasets/metrica.md.hash | 2 +- .../getting-started/example-datasets/noaa.md | 115 +- .../example-datasets/noaa.md.hash | 2 +- .../example-datasets/nyc-taxi.md | 79 +- .../example-datasets/nyc-taxi.md.hash | 2 +- .../example-datasets/nypd_complaint_data.md | 135 +- .../nypd_complaint_data.md.hash | 2 +- .../example-datasets/ontime.md | 55 +- .../example-datasets/ontime.md.hash | 2 +- .../example-datasets/opensky.md | 416 -- .../example-datasets/opensky.md.hash | 1 - .../example-datasets/recipes.md | 335 - .../example-datasets/recipes.md.hash | 1 - .../example-datasets/reddit-comments.md | 657 -- .../example-datasets/reddit-comments.md.hash | 1 - .../example-datasets/stackoverflow.md | 57 +- .../example-datasets/stackoverflow.md.hash | 2 +- .../example-datasets/star-schema.md | 49 +- .../example-datasets/star-schema.md.hash | 2 +- .../getting-started/example-datasets/tpcds.md | 23 +- .../example-datasets/tpcds.md.hash | 2 +- .../getting-started/example-datasets/tpch.md | 236 +- .../example-datasets/tpch.md.hash | 2 +- .../example-datasets/tw-weather.md | 45 +- .../example-datasets/tw-weather.md.hash | 2 +- .../example-datasets/uk-price-paid.md | 47 +- .../example-datasets/uk-price-paid.md.hash | 2 +- .../example-datasets/wikistat.md | 21 +- .../example-datasets/wikistat.md.hash | 2 +- .../example-datasets/youtube-dislikes.md | 72 +- .../example-datasets/youtube-dislikes.md.hash | 2 +- .../current/getting-started/index.md | 59 +- .../current/getting-started/index.md.hash | 2 +- .../install/_snippets/_deb_install.md | 37 +- .../install/_snippets/_docker.md | 81 +- .../install/_snippets/_linux_tar_install.md | 27 +- .../_snippets/_linux_tar_install.md.hash | 2 +- .../install/_snippets/_macos.md | 43 +- .../install/_snippets/_macos.md.hash | 2 +- .../install/_snippets/_quick_install.md | 29 +- .../install/_snippets/_quick_install.md.hash | 2 +- .../install/_snippets/_rpm_install.md | 40 +- .../install/_snippets/_windows_install.md | 43 +- .../getting-started/install/advanced.md | 27 +- .../getting-started/install/advanced.md.hash | 2 +- .../getting-started/install/debian_ubuntu.md | 5 +- .../install/debian_ubuntu.md.hash | 2 +- .../current/getting-started/install/docker.md | 3 +- .../getting-started/install/docker.md.hash | 2 +- .../getting-started/install/install.mdx | 10 +- .../getting-started/install/install.mdx.hash | 2 +- .../current/getting-started/install/macos.md | 3 +- .../getting-started/install/macos.md.hash | 2 +- .../getting-started/install/other_linux.md | 3 +- .../install/other_linux.md.hash | 2 +- .../install/quick-install-curl.md | 3 +- .../install/quick-install-curl.md.hash | 2 +- .../current/getting-started/install/redhat.md | 1 + .../getting-started/install/redhat.md.hash | 2 +- .../getting-started/install/windows.md | 5 +- .../getting-started/install/windows.md.hash | 2 +- .../current/getting-started/playground.md | 34 +- .../getting-started/playground.md.hash | 2 +- .../getting-started/quick-start/cloud.mdx | 313 + .../quick-start/cloud.mdx.hash | 1 + .../getting-started/quick-start/index.mdx | 111 + .../quick-start/index.mdx.hash | 1 + .../quick-start/oss.mdx} | 112 +- .../getting-started/quick-start/oss.mdx.hash | 1 + ...ormance_optimizations_table_of_contents.md | 17 + ...ce_optimizations_table_of_contents.md.hash | 1 + .../guides/best-practices/asyncinserts.md | 3 +- .../best-practices/asyncinserts.md.hash | 2 +- .../guides/best-practices/avoidmutations.md | 7 +- .../best-practices/avoidmutations.md.hash | 2 +- .../best-practices/avoidnullablecolumns.md | 3 +- .../avoidnullablecolumns.md.hash | 2 +- .../best-practices/avoidoptimizefinal.md | 7 +- .../best-practices/avoidoptimizefinal.md.hash | 2 +- .../guides/best-practices/bulkinserts.md | 3 +- .../guides/best-practices/bulkinserts.md.hash | 2 +- .../current/guides/best-practices/index.md | 33 +- .../guides/best-practices/index.md.hash | 2 +- .../guides/best-practices/partitioningkey.md | 3 +- .../best-practices/partitioningkey.md.hash | 2 +- .../current/guides/best-practices/prewhere.md | 126 +- .../guides/best-practices/prewhere.md.hash | 2 +- .../best-practices/query-optimization.md | 225 +- .../best-practices/query-optimization.md.hash | 2 +- .../best-practices/query-parallelism.md | 102 +- .../best-practices/query-parallelism.md.hash | 2 +- .../guides/best-practices/skipping-indexes.md | 108 +- .../best-practices/skipping-indexes.md.hash | 2 +- .../best-practices/sparse-primary-indexes.md | 680 +- .../sparse-primary-indexes.md.hash | 2 +- .../current/guides/creating-tables.md | 37 +- .../current/guides/creating-tables.md.hash | 2 +- .../developer/alternative-query-languages.md | 9 +- .../alternative-query-languages.md.hash | 2 +- .../developer/cascading-materialized-views.md | 94 +- .../cascading-materialized-views.md.hash | 2 +- .../developer/debugging-memory-issues.md | 25 +- .../developer/debugging-memory-issues.md.hash | 2 +- .../deduplicating-inserts-on-retries.md | 105 +- .../deduplicating-inserts-on-retries.md.hash | 2 +- .../current/guides/developer/deduplication.md | 103 +- .../guides/developer/deduplication.md.hash | 2 +- .../developer/dynamic-column-selection.md | 197 + .../dynamic-column-selection.md.hash | 1 + .../current/guides/developer/index.md | 19 +- .../current/guides/developer/index.md.hash | 2 +- .../guides/developer/lightweight-delete.md | 3 +- .../developer/lightweight-delete.md.hash | 2 +- .../guides/developer/lightweight-update.md | 93 - .../developer/lightweight-update.md.hash | 1 - .../guides/developer/merge-table-function.md | 216 + .../developer/merge-table-function.md.hash | 1 + .../current/guides/developer/mutations.md | 36 +- .../guides/developer/mutations.md.hash | 2 +- .../guides/developer/on-fly-mutations.md | 95 + .../guides/developer/on-fly-mutations.md.hash | 1 + .../guides/developer/replacing-merge-tree.md | 114 +- .../developer/replacing-merge-tree.md.hash | 2 +- .../developer/time-series-filling-gaps.md | 47 +- .../time-series-filling-gaps.md.hash | 2 +- .../current/guides/developer/ttl.md | 64 +- .../current/guides/developer/ttl.md.hash | 2 +- ...nding-query-execution-with-the-analyzer.md | 54 +- ...-query-execution-with-the-analyzer.md.hash | 2 +- .../aggregate_function_combinators/anyIf.md | 11 +- .../anyIf.md.hash | 2 +- .../argMaxIf.md | 15 +- .../argMaxIf.md.hash | 2 +- .../argMinIf.md | 13 +- .../argMinIf.md.hash | 2 +- .../aggregate_function_combinators/avgIf.md | 11 +- .../avgIf.md.hash | 2 +- .../aggregate_function_combinators/avgMap.md | 11 +- .../avgMap.md.hash | 2 +- .../avgMerge.md | 11 +- .../avgMerge.md.hash | 2 +- .../avgMergeState.md | 25 +- .../avgMergeState.md.hash | 2 +- .../avgResample.md | 25 +- .../avgResample.md.hash | 2 +- .../avgState.md | 19 +- .../avgState.md.hash | 2 +- .../aggregate_function_combinators/countIf.md | 15 +- .../countIf.md.hash | 2 +- .../countResample.md | 11 +- .../countResample.md.hash | 2 +- .../groupArrayDistinct.md | 11 +- .../groupArrayDistinct.md.hash | 2 +- .../groupArrayResample.md | 27 +- .../groupArrayResample.md.hash | 2 +- .../aggregate_function_combinators/maxMap.md | 13 +- .../maxMap.md.hash | 2 +- .../maxSimpleState.md | 13 +- .../maxSimpleState.md.hash | 2 +- .../aggregate_function_combinators/minMap.md | 9 +- .../minMap.md.hash | 2 +- .../minSimpleState.md | 19 +- .../minSimpleState.md.hash | 2 +- .../quantilesTimingArrayIf.md | 21 +- .../quantilesTimingArrayIf.md.hash | 2 +- .../quantilesTimingIf.md | 23 +- .../quantilesTimingIf.md.hash | 2 +- .../sumArray.md | 21 +- .../sumArray.md.hash | 2 +- .../sumForEach.md | 23 +- .../sumForEach.md.hash | 2 +- .../aggregate_function_combinators/sumIf.md | 19 +- .../sumIf.md.hash | 2 +- .../aggregate_function_combinators/sumMap.md | 5 +- .../sumMap.md.hash | 2 +- .../sumSimpleState.md | 11 +- .../sumSimpleState.md.hash | 2 +- .../uniqArray.md | 22 +- .../uniqArray.md.hash | 2 +- .../uniqArrayIf.md | 11 +- .../uniqArrayIf.md.hash | 2 +- .../current/guides/inserting-data.md | 85 +- .../current/guides/inserting-data.md.hash | 2 +- .../current/guides/joining-tables.md | 67 +- .../current/guides/joining-tables.md.hash | 2 +- .../current/guides/manage-and-deploy-index.md | 53 +- .../guides/manage-and-deploy-index.md.hash | 2 +- .../guides/separation-storage-compute.md | 53 +- .../guides/separation-storage-compute.md.hash | 2 +- .../current/guides/sre/configuring-ssl.md | 100 +- .../guides/sre/configuring-ssl.md.hash | 2 +- .../current/guides/sre/index.md | 13 +- .../current/guides/sre/index.md.hash | 2 +- .../current/guides/sre/keeper/index.md | 512 +- .../current/guides/sre/keeper/index.md.hash | 2 +- .../current/guides/sre/network-ports.md | 41 +- .../current/guides/sre/network-ports.md.hash | 2 +- .../current/guides/sre/scaling-clusters.md | 13 +- .../guides/sre/scaling-clusters.md.hash | 2 +- .../sre/user-management/configuring-ldap.md | 66 +- .../user-management/configuring-ldap.md.hash | 2 +- .../guides/sre/user-management/index.md | 156 +- .../guides/sre/user-management/index.md.hash | 2 +- .../sre/user-management/ssl-user-auth.md | 54 +- .../sre/user-management/ssl-user-auth.md.hash | 2 +- .../current/guides/troubleshooting.md | 63 +- .../current/guides/troubleshooting.md.hash | 2 +- .../current/guides/writing-queries.md | 13 +- .../current/guides/writing-queries.md.hash | 2 +- .../current/integrations/cli.mdx | 3 +- .../current/integrations/cli.mdx.hash | 2 +- .../data-ingestion/apache-spark/index.md | 13 +- .../data-ingestion/apache-spark/index.md.hash | 2 +- .../data-ingestion/apache-spark/spark-jdbc.md | 22 +- .../apache-spark/spark-jdbc.md.hash | 2 +- .../apache-spark/spark-native-connector.md | 303 +- .../spark-native-connector.md.hash | 2 +- .../data-ingestion/aws-glue/index.md | 183 +- .../data-ingestion/aws-glue/index.md.hash | 2 +- .../azure-data-factory/index.md | 11 +- .../azure-data-factory/index.md.hash | 2 +- .../azure-data-factory/overview.md | 21 +- .../azure-data-factory/overview.md.hash | 2 +- .../using_azureblobstorage.md | 53 +- .../using_azureblobstorage.md.hash | 2 +- .../using_http_interface.md | 122 +- .../using_http_interface.md.hash | 2 +- .../data-ingestion/azure-synapse/index.md | 31 +- .../azure-synapse/index.md.hash | 2 +- .../clickpipes/aws-privatelink.md | 216 +- .../clickpipes/aws-privatelink.md.hash | 2 +- .../data-ingestion/clickpipes/index.md | 125 +- .../data-ingestion/clickpipes/index.md.hash | 2 +- .../data-ingestion/clickpipes/kafka.md | 390 -- .../data-ingestion/clickpipes/kafka.md.hash | 1 - .../kafka/01_create-kafka-clickpipe.md | 72 + .../kafka/01_create-kafka-clickpipe.md.hash | 1 + .../clickpipes/kafka/02_schema-registries.md | 47 + .../kafka/02_schema-registries.md.hash | 1 + .../clickpipes/kafka/03_reference.md | 103 + .../clickpipes/kafka/03_reference.md.hash | 1 + .../clickpipes/kafka/04_best_practices.md | 151 + .../kafka/04_best_practices.md.hash | 1 + .../data-ingestion/clickpipes/kafka/05_faq.md | 115 + .../clickpipes/kafka/05_faq.md.hash | 1 + .../data-ingestion/clickpipes/kafka/index.md | 17 + .../clickpipes/kafka/index.md.hash | 1 + .../data-ingestion/clickpipes/kinesis.md | 108 +- .../data-ingestion/clickpipes/kinesis.md.hash | 2 +- .../clickpipes/mongodb/add_table.md | 33 + .../clickpipes/mongodb/add_table.md.hash | 1 + .../clickpipes/mongodb/controlling_sync.md | 56 + .../mongodb/controlling_sync.md.hash | 1 + .../clickpipes/mongodb/datatypes.md | 30 + .../clickpipes/mongodb/datatypes.md.hash | 1 + .../data-ingestion/clickpipes/mongodb/faq.md | 66 + .../clickpipes/mongodb/faq.md.hash | 1 + .../clickpipes/mongodb/index.md | 105 + .../clickpipes/mongodb/index.md.hash | 1 + .../clickpipes/mongodb/lifecycle.md | 65 + .../clickpipes/mongodb/lifecycle.md.hash | 1 + .../clickpipes/mongodb/pause_and_resume.md | 47 + .../mongodb/pause_and_resume.md.hash | 1 + .../clickpipes/mongodb/quickstart.md | 371 + .../clickpipes/mongodb/quickstart.md.hash | 1 + .../clickpipes/mongodb/remove_table.md | 27 + .../clickpipes/mongodb/remove_table.md.hash | 1 + .../clickpipes/mongodb/resync.md | 43 + .../clickpipes/mongodb/resync.md.hash | 1 + .../clickpipes/mongodb/source/atlas.md | 59 + .../clickpipes/mongodb/source/atlas.md.hash | 1 + .../clickpipes/mongodb/source/generic.md | 60 + .../clickpipes/mongodb/source/generic.md.hash | 1 + .../clickpipes/mongodb/table_resync.md | 27 + .../clickpipes/mongodb/table_resync.md.hash | 1 + .../clickpipes/mysql/add_table.md | 33 + .../clickpipes/mysql/add_table.md.hash | 1 + .../clickpipes/mysql/controlling_sync.md | 60 + .../clickpipes/mysql/controlling_sync.md.hash | 1 + .../clickpipes/mysql/datatypes.md | 53 +- .../clickpipes/mysql/datatypes.md.hash | 2 +- .../data-ingestion/clickpipes/mysql/faq.md | 46 +- .../clickpipes/mysql/faq.md.hash | 2 +- .../data-ingestion/clickpipes/mysql/index.md | 81 +- .../clickpipes/mysql/index.md.hash | 2 +- .../clickpipes/mysql/lifecycle.md | 65 + .../clickpipes/mysql/lifecycle.md.hash | 1 + .../clickpipes/mysql/parallel_initial_load.md | 51 + .../mysql/parallel_initial_load.md.hash | 1 + .../clickpipes/mysql/pause_and_resume.md | 47 + .../clickpipes/mysql/pause_and_resume.md.hash | 1 + .../clickpipes/mysql/remove_table.md | 27 + .../clickpipes/mysql/remove_table.md.hash | 1 + .../data-ingestion/clickpipes/mysql/resync.md | 47 + .../clickpipes/mysql/resync.md.hash | 1 + .../clickpipes/mysql/schema-changes.md | 16 + .../clickpipes/mysql/schema-changes.md.hash | 1 + .../clickpipes/mysql/source/aurora.md | 103 +- .../clickpipes/mysql/source/aurora.md.hash | 2 +- .../clickpipes/mysql/source/gcp.md | 43 +- .../clickpipes/mysql/source/gcp.md.hash | 2 +- .../clickpipes/mysql/source/generic.md | 141 + .../clickpipes/mysql/source/generic.md.hash | 1 + .../clickpipes/mysql/source/generic_maria.md | 110 + .../mysql/source/generic_maria.md.hash | 1 + .../clickpipes/mysql/source/rds.md | 96 +- .../clickpipes/mysql/source/rds.md.hash | 2 +- .../clickpipes/mysql/source/rds_maria.md | 39 +- .../clickpipes/mysql/source/rds_maria.md.hash | 2 +- .../clickpipes/mysql/table_resync.md | 27 + .../clickpipes/mysql/table_resync.md.hash | 1 + .../clickpipes/object-storage.md | 123 +- .../clickpipes/object-storage.md.hash | 2 +- .../clickpipes/postgres/add_table.md | 21 +- .../clickpipes/postgres/add_table.md.hash | 2 +- .../clickpipes/postgres/controlling_sync.md | 65 + .../postgres/controlling_sync.md.hash | 1 + .../clickpipes/postgres/deduplication.md | 73 +- .../clickpipes/postgres/deduplication.md.hash | 2 +- .../data-ingestion/clickpipes/postgres/faq.md | 314 +- .../clickpipes/postgres/faq.md.hash | 2 +- .../clickpipes/postgres/index.md | 77 +- .../clickpipes/postgres/index.md.hash | 2 +- .../clickpipes/postgres/lifecycle.md | 65 + .../clickpipes/postgres/lifecycle.md.hash | 1 + .../clickpipes/postgres/maintenance.md | 17 +- .../clickpipes/postgres/maintenance.md.hash | 2 +- .../clickpipes/postgres/ordering_keys.md | 29 +- .../clickpipes/postgres/ordering_keys.md.hash | 2 +- .../postgres/parallel_initial_load.md | 48 + .../postgres/parallel_initial_load.md.hash | 1 + .../clickpipes/postgres/pause_and_resume.md | 40 +- .../postgres/pause_and_resume.md.hash | 2 +- .../postgres/postgres_generated_columns.md | 27 +- .../postgres_generated_columns.md.hash | 2 +- .../clickpipes/postgres/remove_table.md | 19 +- .../clickpipes/postgres/remove_table.md.hash | 2 +- .../clickpipes/postgres/resync.md | 47 + .../clickpipes/postgres/resync.md.hash | 1 + .../clickpipes/postgres/scaling.md | 95 + .../clickpipes/postgres/scaling.md.hash | 1 + .../clickpipes/postgres/schema-changes.md | 17 +- .../postgres/schema-changes.md.hash | 2 +- .../clickpipes/postgres/source/aurora.md | 57 +- .../clickpipes/postgres/source/aurora.md.hash | 2 +- .../source/azure-flexible-server-postgres.md | 29 +- .../azure-flexible-server-postgres.md.hash | 2 +- .../postgres/source/crunchy-postgres.md | 19 +- .../postgres/source/crunchy-postgres.md.hash | 2 +- .../clickpipes/postgres/source/generic.md | 33 +- .../postgres/source/generic.md.hash | 2 +- .../postgres/source/google-cloudsql.md | 38 +- .../postgres/source/google-cloudsql.md.hash | 2 +- .../postgres/source/neon-postgres.md | 40 +- .../postgres/source/neon-postgres.md.hash | 2 +- .../clickpipes/postgres/source/planetscale.md | 79 + .../postgres/source/planetscale.md.hash | 1 + .../clickpipes/postgres/source/rds.md | 29 +- .../clickpipes/postgres/source/rds.md.hash | 2 +- .../clickpipes/postgres/source/supabase.md | 40 +- .../postgres/source/supabase.md.hash | 2 +- .../clickpipes/postgres/source/timescale.md | 51 +- .../postgres/source/timescale.md.hash | 2 +- .../clickpipes/postgres/table_resync.md | 14 +- .../clickpipes/postgres/table_resync.md.hash | 2 +- .../clickpipes/postgres/toast.md | 31 +- .../clickpipes/postgres/toast.md.hash | 2 +- .../clickpipes/secure-kinesis.md | 121 +- .../clickpipes/secure-kinesis.md.hash | 2 +- .../data-ingestion/clickpipes/secure-rds.md | 125 + .../clickpipes/secure-rds.md.hash | 1 + .../data-formats/arrow-avro-orc.md | 41 +- .../data-formats/arrow-avro-orc.md.hash | 2 +- .../data-ingestion/data-formats/binary.md | 66 +- .../data-formats/binary.md.hash | 2 +- .../data-ingestion/data-formats/csv-tsv.md | 98 +- .../data-formats/csv-tsv.md.hash | 2 +- .../data-ingestion/data-formats/intro.md | 13 +- .../data-ingestion/data-formats/intro.md.hash | 2 +- .../data-formats/json/exporting.md | 31 +- .../data-formats/json/exporting.md.hash | 2 +- .../data-formats/json/formats.md | 77 +- .../data-formats/json/formats.md.hash | 2 +- .../data-formats/json/inference.md | 95 +- .../data-formats/json/inference.md.hash | 2 +- .../data-ingestion/data-formats/json/intro.md | 13 +- .../data-formats/json/intro.md.hash | 2 +- .../data-formats/json/loading.md | 69 +- .../data-formats/json/loading.md.hash | 2 +- .../data-ingestion/data-formats/json/other.md | 158 +- .../data-formats/json/other.md.hash | 2 +- .../data-formats/json/schema.md | 176 +- .../data-formats/json/schema.md.hash | 2 +- .../data-ingestion/data-formats/parquet.md | 48 +- .../data-formats/parquet.md.hash | 2 +- .../data-ingestion/data-formats/sql.md | 19 +- .../data-ingestion/data-formats/sql.md.hash | 2 +- .../data-formats/templates-regex.md | 43 +- .../data-formats/templates-regex.md.hash | 2 +- .../data-ingestion/data-ingestion-index.md | 32 +- .../data-ingestion-index.md.hash | 2 +- .../data-ingestion/data-sources-index.md | 11 +- .../data-ingestion/data-sources-index.md.hash | 2 +- .../data-ingestion/dbms/dynamodb/index.md | 60 +- .../dbms/dynamodb/index.md.hash | 2 +- .../dbms/jdbc-with-clickhouse.md | 95 +- .../dbms/jdbc-with-clickhouse.md.hash | 2 +- .../dbms/odbc-with-clickhouse.md | 1 + .../dbms/odbc-with-clickhouse.md.hash | 2 +- .../postgresql/connecting-to-postgresql.md | 109 +- .../connecting-to-postgresql.md.hash | 2 +- .../dbms/postgresql/inserting-data.md | 13 +- .../dbms/postgresql/inserting-data.md.hash | 2 +- .../integrations/data-ingestion/emqx/index.md | 189 +- .../data-ingestion/emqx/index.md.hash | 2 +- .../etl-tools/airbyte-and-clickhouse.md | 57 +- .../etl-tools/airbyte-and-clickhouse.md.hash | 2 +- .../data-ingestion/etl-tools/apache-beam.md | 51 +- .../etl-tools/apache-beam.md.hash | 2 +- .../etl-tools/bladepipe-and-clickhouse.md | 122 + .../bladepipe-and-clickhouse.md.hash | 1 + .../dbt/features-and-configurations.md | 503 ++ .../dbt/features-and-configurations.md.hash | 1 + .../data-ingestion/etl-tools/dbt/guides.md | 1053 +++ .../etl-tools/dbt/guides.md.hash | 1 + .../data-ingestion/etl-tools/dbt/index.md | 1113 +-- .../etl-tools/dbt/index.md.hash | 2 +- .../etl-tools/dlt-and-clickhouse.md | 104 +- .../etl-tools/dlt-and-clickhouse.md.hash | 2 +- .../etl-tools/fivetran/index.md | 9 +- .../etl-tools/fivetran/index.md.hash | 2 +- .../etl-tools/nifi-and-clickhouse.md | 119 +- .../etl-tools/nifi-and-clickhouse.md.hash | 2 +- .../etl-tools/vector-to-clickhouse.md | 58 +- .../etl-tools/vector-to-clickhouse.md.hash | 2 +- .../integrations/data-ingestion/gcs/index.md | 147 +- .../data-ingestion/gcs/index.md.hash | 2 +- .../google-dataflow/dataflow.md | 27 +- .../google-dataflow/dataflow.md.hash | 2 +- .../google-dataflow/java-runner.md | 13 +- .../google-dataflow/java-runner.md.hash | 2 +- .../google-dataflow/templates.md | 17 +- .../google-dataflow/templates.md.hash | 2 +- .../templates/bigquery-to-clickhouse.md | 151 +- .../templates/bigquery-to-clickhouse.md.hash | 2 +- .../data-ingestion/insert-local-files.md | 17 +- .../data-ingestion/insert-local-files.md.hash | 2 +- .../kafka/confluent/confluent-cloud.md | 63 + .../kafka/confluent/confluent-cloud.md.hash | 1 + .../kafka/confluent/custom-connector.md | 53 +- .../kafka/confluent/custom-connector.md.hash | 2 +- .../data-ingestion/kafka/confluent/index.md | 8 +- .../kafka/confluent/index.md.hash | 2 +- .../kafka/confluent/kafka-connect-http.md | 124 +- .../confluent/kafka-connect-http.md.hash | 2 +- .../data-ingestion/kafka/index.md | 112 +- .../data-ingestion/kafka/index.md.hash | 2 +- .../kafka/kafka-clickhouse-connect-sink.md | 262 +- .../kafka-clickhouse-connect-sink.md.hash | 2 +- .../kafka/kafka-connect-jdbc.md | 81 +- .../kafka/kafka-connect-jdbc.md.hash | 2 +- .../kafka-table-engine-named-collections.md | 43 +- ...fka-table-engine-named-collections.md.hash | 2 +- .../kafka/kafka-table-engine.md | 163 +- .../kafka/kafka-table-engine.md.hash | 2 +- .../data-ingestion/kafka/kafka-vector.md | 41 +- .../data-ingestion/kafka/kafka-vector.md.hash | 2 +- .../data-ingestion/kafka/msk/index.md | 36 +- .../data-ingestion/kafka/msk/index.md.hash | 2 +- .../redshift/_snippets/_migration_guide.md | 255 + .../_snippets/_migration_guide.md.hash | 1 + .../data-ingestion/redshift/index.md | 265 - .../data-ingestion/redshift/index.md.hash | 1 - .../integrations/data-ingestion/s3-minio.md | 9 +- .../data-ingestion/s3-minio.md.hash | 2 +- .../integrations/data-ingestion/s3/index.md | 305 +- .../data-ingestion/s3/index.md.hash | 2 +- .../data-ingestion/s3/performance.md | 177 +- .../data-ingestion/s3/performance.md.hash | 2 +- .../integrations/data-sources/cassandra.md | 3 +- .../data-sources/cassandra.md.hash | 2 +- .../integrations/data-sources/deltalake.md | 3 +- .../data-sources/deltalake.md.hash | 2 +- .../current/integrations/data-sources/hive.md | 1 + .../integrations/data-sources/hive.md.hash | 2 +- .../current/integrations/data-sources/hudi.md | 1 + .../integrations/data-sources/hudi.md.hash | 2 +- .../integrations/data-sources/iceberg.md | 3 +- .../integrations/data-sources/iceberg.md.hash | 2 +- .../integrations/data-sources/mongodb.md | 1 + .../integrations/data-sources/mongodb.md.hash | 2 +- .../integrations/data-sources/mysql.md | 145 +- .../integrations/data-sources/mysql.md.hash | 2 +- .../current/integrations/data-sources/nats.md | 1 + .../integrations/data-sources/nats.md.hash | 2 +- .../integrations/data-sources/postgres.md | 3 +- .../data-sources/postgres.md.hash | 2 +- .../integrations/data-sources/rabbitmq.md | 1 + .../data-sources/rabbitmq.md.hash | 2 +- .../integrations/data-sources/redis.md | 1 + .../integrations/data-sources/redis.md.hash | 2 +- .../integrations/data-sources/rocksdb.md | 3 +- .../integrations/data-sources/rocksdb.md.hash | 2 +- .../integrations/data-sources/sqlite.md | 1 + .../integrations/data-sources/sqlite.md.hash | 2 +- .../astrato-and-clickhouse.md | 69 +- .../astrato-and-clickhouse.md.hash | 2 +- .../chartbrew-and-clickhouse.md | 71 +- .../chartbrew-and-clickhouse.md.hash | 2 +- .../data-visualization/deepnote.md | 29 +- .../data-visualization/deepnote.md.hash | 2 +- .../draxlr-and-clickhouse.md | 45 +- .../draxlr-and-clickhouse.md.hash | 2 +- .../embeddable-and-clickhouse.md | 38 +- .../embeddable-and-clickhouse.md.hash | 2 +- .../explo-and-clickhouse.md | 61 +- .../explo-and-clickhouse.md.hash | 2 +- .../data-visualization/fabi-and-clickhouse.md | 62 + .../fabi-and-clickhouse.md.hash | 1 + .../data-visualization/grafana/config.md | 124 +- .../data-visualization/grafana/config.md.hash | 2 +- .../data-visualization/grafana/index.md | 49 +- .../data-visualization/grafana/index.md.hash | 2 +- .../grafana/query-builder.md | 204 +- .../grafana/query-builder.md.hash | 2 +- .../hashboard-and-clickhouse.md | 23 +- .../hashboard-and-clickhouse.md.hash | 2 +- .../integrations/data-visualization/index.md | 56 +- .../data-visualization/index.md.hash | 2 +- .../looker-and-clickhouse.md | 31 +- .../looker-and-clickhouse.md.hash | 2 +- .../looker-studio-and-clickhouse.md | 34 +- .../looker-studio-and-clickhouse.md.hash | 2 +- .../luzmo-and-clickhouse.md | 33 +- .../luzmo-and-clickhouse.md.hash | 2 +- .../metabase-and-clickhouse.md | 59 +- .../metabase-and-clickhouse.md.hash | 2 +- .../mitzu-and-clickhouse.md | 103 +- .../mitzu-and-clickhouse.md.hash | 2 +- .../data-visualization/omni-and-clickhouse.md | 19 +- .../omni-and-clickhouse.md.hash | 2 +- .../powerbi-and-clickhouse.md | 146 +- .../powerbi-and-clickhouse.md.hash | 2 +- .../quicksight-and-clickhouse.md | 53 +- .../quicksight-and-clickhouse.md.hash | 2 +- .../rocketbi-and-clickhouse.md | 79 +- .../rocketbi-and-clickhouse.md.hash | 2 +- .../splunk-and-clickhouse.md | 99 +- .../splunk-and-clickhouse.md.hash | 2 +- .../superset-and-clickhouse.md | 69 +- .../superset-and-clickhouse.md.hash | 2 +- .../tableau/tableau-analysis-tips.md | 63 +- .../tableau/tableau-analysis-tips.md.hash | 2 +- .../tableau/tableau-and-clickhouse.md | 138 +- .../tableau/tableau-and-clickhouse.md.hash | 2 +- .../tableau/tableau-connection-tips.md | 40 +- .../tableau/tableau-connection-tips.md.hash | 2 +- .../tableau/tableau-online-and-clickhouse.md | 50 +- .../tableau-online-and-clickhouse.md.hash | 2 +- .../zingdata-and-clickhouse.md | 45 +- .../zingdata-and-clickhouse.md.hash | 2 +- .../current/integrations/index.mdx | 340 +- .../current/integrations/index.mdx.hash | 2 +- .../integrations/language-clients/csharp.md | 228 + .../language-clients/csharp.md.hash | 1 + .../integrations/language-clients/go/index.md | 462 +- .../language-clients/go/index.md.hash | 2 +- .../integrations/language-clients/index.md | 20 +- .../language-clients/index.md.hash | 2 +- .../java/client/_snippets/_v0_7.mdx | 110 +- .../java/client/_snippets/_v0_7.mdx.hash | 2 +- .../java/client/_snippets/_v0_8.mdx | 499 +- .../java/client/_snippets/_v0_8.mdx.hash | 2 +- .../language-clients/java/client/client.mdx | 1 + .../java/client/client.mdx.hash | 2 +- .../language-clients/java/index.md | 159 +- .../language-clients/java/index.md.hash | 2 +- .../java/jdbc/_snippets/_v0_7.mdx | 122 +- .../java/jdbc/_snippets/_v0_7.mdx.hash | 2 +- .../java/jdbc/_snippets/_v0_8.mdx | 76 +- .../java/jdbc/_snippets/_v0_8.mdx.hash | 2 +- .../language-clients/java/jdbc/jdbc.mdx | 3 +- .../language-clients/java/jdbc/jdbc.mdx.hash | 2 +- .../language-clients/java/r2dbc.md | 13 +- .../language-clients/java/r2dbc.md.hash | 2 +- .../integrations/language-clients/js.md | 635 +- .../integrations/language-clients/js.md.hash | 2 +- .../language-clients/moose-olap.md | 153 + .../language-clients/moose-olap.md.hash | 1 + .../language-clients/python/index.md | 822 +-- .../language-clients/python/index.md.hash | 2 +- .../integrations/language-clients/rust.md | 196 +- .../language-clients/rust.md.hash | 2 +- .../integrations/migration/_category_.yml | 8 - .../migration/clickhouse-local-etl.md | 148 - .../migration/clickhouse-local-etl.md.hash | 1 - .../migration/clickhouse-to-cloud.md.hash | 1 - .../migration/etl-tool-to-clickhouse.md.hash | 1 - .../current/integrations/migration/index.md | 25 - .../integrations/migration/index.md.hash | 1 - .../migration/object-storage-to-clickhouse.md | 31 - .../object-storage-to-clickhouse.md.hash | 1 - .../integrations/migration/overview.md | 39 - .../integrations/migration/overview.md.hash | 1 - .../current/integrations/migration/rockset.md | 148 - .../integrations/migration/rockset.md.hash | 1 - .../migration/upload-a-csv-file.md | 39 - .../migration/upload-a-csv-file.md.hash | 1 - .../current/integrations/misc/index.md | 13 +- .../current/integrations/misc/index.md.hash | 2 +- .../current/integrations/prometheus.md.hash | 1 - .../integrations/sql-clients/datagrip.md | 34 +- .../integrations/sql-clients/datagrip.md.hash | 2 +- .../integrations/sql-clients/dbeaver.md | 29 +- .../integrations/sql-clients/dbeaver.md.hash | 2 +- .../integrations/sql-clients/dbvisualizer.md | 31 +- .../sql-clients/dbvisualizer.md.hash | 2 +- .../current/integrations/sql-clients/index.md | 21 +- .../integrations/sql-clients/index.md.hash | 2 +- .../integrations/sql-clients/jupysql.md | 21 +- .../integrations/sql-clients/jupysql.md.hash | 2 +- .../integrations/sql-clients/marimo.md | 29 +- .../integrations/sql-clients/marimo.md.hash | 2 +- .../integrations/sql-clients/qstudio.md | 39 +- .../integrations/sql-clients/qstudio.md.hash | 2 +- .../integrations/sql-clients/sql-console.md | 207 +- .../sql-clients/sql-console.md.hash | 2 +- .../integrations/sql-clients/tablum.md | 26 +- .../integrations/sql-clients/tablum.md.hash | 2 +- .../tools/data-integration/easypanel/index.md | 11 +- .../data-integration/easypanel/index.md.hash | 2 +- .../tools/data-integration/index.md | 13 +- .../tools/data-integration/index.md.hash | 2 +- .../tools/data-integration/retool/index.md | 20 +- .../data-integration/retool/index.md.hash | 2 +- .../tools/data-integration/splunk/index.md | 53 +- .../data-integration/splunk/index.md.hash | 2 +- .../current/integrations/tools/index.md | 9 +- .../current/integrations/tools/index.md.hash | 2 +- .../current/interfaces/arrowflight.md | 84 + .../current/interfaces/arrowflight.md.hash | 1 + .../current/interfaces/cli.md | 580 +- .../current/interfaces/cli.md.hash | 2 +- .../current/interfaces/cpp.md | 7 +- .../current/interfaces/cpp.md.hash | 2 +- .../current/interfaces/formats.md | 269 +- .../current/interfaces/formats.md.hash | 2 +- .../current/interfaces/formats/Arrow/Arrow.md | 46 +- .../interfaces/formats/Arrow/Arrow.md.hash | 2 +- .../interfaces/formats/Arrow/ArrowStream.md | 9 +- .../formats/Arrow/ArrowStream.md.hash | 2 +- .../current/interfaces/formats/Avro/Avro.md | 75 +- .../interfaces/formats/Avro/Avro.md.hash | 2 +- .../interfaces/formats/Avro/AvroConfluent.md | 83 +- .../formats/Avro/AvroConfluent.md.hash | 2 +- .../Avro/_snippets/data-types-matching.md | 12 +- .../current/interfaces/formats/BSONEachRow.md | 175 +- .../interfaces/formats/BSONEachRow.md.hash | 2 +- .../current/interfaces/formats/CSV/CSV.md | 75 +- .../interfaces/formats/CSV/CSV.md.hash | 2 +- .../interfaces/formats/CSV/CSVWithNames.md | 95 +- .../formats/CSV/CSVWithNames.md.hash | 2 +- .../formats/CSV/CSVWithNamesAndTypes.md | 96 +- .../formats/CSV/CSVWithNamesAndTypes.md.hash | 2 +- .../current/interfaces/formats/CapnProto.md | 75 +- .../interfaces/formats/CapnProto.md.hash | 2 +- .../CustomSeparated/CustomSeparated.md | 69 +- .../CustomSeparated/CustomSeparated.md.hash | 2 +- .../CustomSeparatedIgnoreSpaces.md | 31 +- .../CustomSeparatedIgnoreSpaces.md.hash | 2 +- .../CustomSeparatedIgnoreSpacesWithNames.md | 31 +- ...stomSeparatedIgnoreSpacesWithNames.md.hash | 2 +- ...mSeparatedIgnoreSpacesWithNamesAndTypes.md | 29 + ...ratedIgnoreSpacesWithNamesAndTypes.md.hash | 2 +- .../CustomSeparatedWithNames.md | 64 +- .../CustomSeparatedWithNames.md.hash | 2 +- .../CustomSeparatedWithNamesAndTypes.md | 65 +- .../CustomSeparatedWithNamesAndTypes.md.hash | 2 +- .../current/interfaces/formats/DWARF.md | 52 +- .../current/interfaces/formats/DWARF.md.hash | 2 +- .../current/interfaces/formats/Form.md | 11 +- .../current/interfaces/formats/Form.md.hash | 2 +- .../current/interfaces/formats/Hash.md | 67 + .../current/interfaces/formats/Hash.md.hash | 1 + .../current/interfaces/formats/HiveText.md | 1 + .../interfaces/formats/HiveText.md.hash | 2 +- .../current/interfaces/formats/JSON/JSON.md | 41 +- .../interfaces/formats/JSON/JSON.md.hash | 2 +- .../interfaces/formats/JSON/JSONAsObject.md | 10 +- .../formats/JSON/JSONAsObject.md.hash | 2 +- .../interfaces/formats/JSON/JSONAsString.md | 28 +- .../formats/JSON/JSONAsString.md.hash | 2 +- .../interfaces/formats/JSON/JSONColumns.md | 62 +- .../formats/JSON/JSONColumns.md.hash | 2 +- .../formats/JSON/JSONColumnsWithMetadata.md | 12 +- .../JSON/JSONColumnsWithMetadata.md.hash | 2 +- .../interfaces/formats/JSON/JSONCompact.md | 167 +- .../formats/JSON/JSONCompact.md.hash | 2 +- .../formats/JSON/JSONCompactColumns.md | 53 +- .../formats/JSON/JSONCompactColumns.md.hash | 2 +- .../formats/JSON/JSONCompactEachRow.md | 67 +- .../formats/JSON/JSONCompactEachRow.md.hash | 2 +- .../JSON/JSONCompactEachRowWithNames.md | 77 +- .../JSON/JSONCompactEachRowWithNames.md.hash | 2 +- .../JSONCompactEachRowWithNamesAndTypes.md | 84 +- ...SONCompactEachRowWithNamesAndTypes.md.hash | 2 +- .../formats/JSON/JSONCompactStrings.md | 105 +- .../formats/JSON/JSONCompactStrings.md.hash | 2 +- .../formats/JSON/JSONCompactStringsEachRow.md | 67 +- .../JSON/JSONCompactStringsEachRow.md.hash | 2 +- .../JSONCompactStringsEachRowWithNames.md | 73 +- ...JSONCompactStringsEachRowWithNames.md.hash | 2 +- ...NCompactStringsEachRowWithNamesAndTypes.md | 83 +- ...actStringsEachRowWithNamesAndTypes.md.hash | 2 +- .../interfaces/formats/JSON/JSONEachRow.md | 78 +- .../formats/JSON/JSONEachRow.md.hash | 2 +- .../formats/JSON/JSONEachRowWithProgress.md | 3 +- .../JSON/JSONEachRowWithProgress.md.hash | 2 +- .../interfaces/formats/JSON/JSONLines.md | 74 + .../interfaces/formats/JSON/JSONLines.md.hash | 2 +- .../formats/JSON/JSONObjectEachRow.md | 86 +- .../formats/JSON/JSONObjectEachRow.md.hash | 2 +- .../interfaces/formats/JSON/JSONStrings.md | 417 +- .../formats/JSON/JSONStrings.md.hash | 2 +- .../formats/JSON/JSONStringsEachRow.md | 67 +- .../formats/JSON/JSONStringsEachRow.md.hash | 2 +- .../JSON/JSONStringsEachRowWithProgress.md | 7 +- .../JSONStringsEachRowWithProgress.md.hash | 2 +- .../formats/JSON/PrettyJSONEachRow.md | 322 +- .../formats/JSON/PrettyJSONEachRow.md.hash | 2 +- .../formats/JSON/format-settings.md | 55 +- .../formats/JSON/format-settings.md.hash | 2 +- .../formats/LineAsString/LineAsString.md | 11 +- .../formats/LineAsString/LineAsString.md.hash | 2 +- .../LineAsString/LineAsStringWithNames.md | 7 +- .../LineAsStringWithNames.md.hash | 2 +- .../LineAsStringWithNamesAndTypes.md | 7 +- .../LineAsStringWithNamesAndTypes.md.hash | 2 +- .../current/interfaces/formats/Markdown.md | 5 +- .../interfaces/formats/Markdown.md.hash | 2 +- .../current/interfaces/formats/MsgPack.md | 63 +- .../interfaces/formats/MsgPack.md.hash | 2 +- .../current/interfaces/formats/MySQLDump.md | 15 +- .../interfaces/formats/MySQLDump.md.hash | 2 +- .../current/interfaces/formats/MySQLWire.md | 1 + .../interfaces/formats/MySQLWire.md.hash | 2 +- .../current/interfaces/formats/Native.md | 14 +- .../current/interfaces/formats/Native.md.hash | 2 +- .../current/interfaces/formats/Npy.md | 19 +- .../current/interfaces/formats/Npy.md.hash | 2 +- .../current/interfaces/formats/Null.md | 56 +- .../current/interfaces/formats/Null.md.hash | 2 +- .../current/interfaces/formats/ODBCDriver2.md | 1 + .../interfaces/formats/ODBCDriver2.md.hash | 2 +- .../current/interfaces/formats/ORC.md | 72 +- .../current/interfaces/formats/ORC.md.hash | 2 +- .../current/interfaces/formats/One.md | 5 +- .../current/interfaces/formats/One.md.hash | 2 +- .../interfaces/formats/Parquet/Parquet.md | 133 +- .../formats/Parquet/Parquet.md.hash | 2 +- .../formats/Parquet/ParquetMetadata.md | 67 +- .../formats/Parquet/ParquetMetadata.md.hash | 2 +- .../interfaces/formats/PostgreSQLWire.md | 1 + .../interfaces/formats/PostgreSQLWire.md.hash | 2 +- .../interfaces/formats/Pretty/Pretty.md | 29 +- .../interfaces/formats/Pretty/Pretty.md.hash | 2 +- .../formats/Pretty/PrettyCompact.md | 6 +- .../formats/Pretty/PrettyCompact.md.hash | 2 +- .../formats/Pretty/PrettyCompactMonoBlock.md | 5 +- .../Pretty/PrettyCompactMonoBlock.md.hash | 2 +- .../formats/Pretty/PrettyCompactNoEscapes.md | 10 +- .../Pretty/PrettyCompactNoEscapes.md.hash | 2 +- .../Pretty/PrettyCompactNoEscapesMonoBlock.md | 6 +- .../PrettyCompactNoEscapesMonoBlock.md.hash | 2 +- .../formats/Pretty/PrettyMonoBlock.md | 6 +- .../formats/Pretty/PrettyMonoBlock.md.hash | 2 +- .../formats/Pretty/PrettyNoEscapes.md | 15 +- .../formats/Pretty/PrettyNoEscapes.md.hash | 2 +- .../Pretty/PrettyNoEscapesMonoBlock.md | 7 +- .../Pretty/PrettyNoEscapesMonoBlock.md.hash | 2 +- .../interfaces/formats/Pretty/PrettySpace.md | 3 +- .../formats/Pretty/PrettySpace.md.hash | 2 +- .../formats/Pretty/PrettySpaceMonoBlock.md | 6 +- .../Pretty/PrettySpaceMonoBlock.md.hash | 2 +- .../formats/Pretty/PrettySpaceNoEscapes.md | 19 +- .../Pretty/PrettySpaceNoEscapes.md.hash | 2 +- .../Pretty/PrettySpaceNoEscapesMonoBlock.md | 6 +- .../PrettySpaceNoEscapesMonoBlock.md.hash | 2 +- .../common-pretty-format-settings.md | 27 +- .../current/interfaces/formats/Prometheus.md | 19 +- .../interfaces/formats/Prometheus.md.hash | 2 +- .../interfaces/formats/Protobuf/Protobuf.md | 78 +- .../formats/Protobuf/Protobuf.md.hash | 2 +- .../formats/Protobuf/ProtobufList.md | 13 +- .../formats/Protobuf/ProtobufList.md.hash | 2 +- .../formats/Protobuf/ProtobufSingle.md | 5 +- .../formats/Protobuf/ProtobufSingle.md.hash | 2 +- .../current/interfaces/formats/RawBLOB.md | 26 +- .../interfaces/formats/RawBLOB.md.hash | 2 +- .../current/interfaces/formats/Regexp.md | 25 +- .../current/interfaces/formats/Regexp.md.hash | 2 +- .../interfaces/formats/RowBinary/RowBinary.md | 51 +- .../formats/RowBinary/RowBinary.md.hash | 2 +- .../RowBinary/RowBinaryWithDefaults.md | 13 +- .../RowBinary/RowBinaryWithDefaults.md.hash | 2 +- .../formats/RowBinary/RowBinaryWithNames.md | 9 +- .../RowBinary/RowBinaryWithNames.md.hash | 2 +- .../RowBinary/RowBinaryWithNamesAndTypes.md | 27 +- .../RowBinaryWithNamesAndTypes.md.hash | 2 +- .../common-row-binary-format-settings.md | 17 +- .../current/interfaces/formats/SQLInsert.md | 19 +- .../interfaces/formats/SQLInsert.md.hash | 2 +- .../interfaces/formats/TabSeparated/TSKV.md | 88 +- .../formats/TabSeparated/TSKV.md.hash | 2 +- .../formats/TabSeparated/TabSeparated.md | 123 +- .../formats/TabSeparated/TabSeparated.md.hash | 2 +- .../formats/TabSeparated/TabSeparatedRaw.md | 75 +- .../TabSeparated/TabSeparatedRaw.md.hash | 2 +- .../TabSeparated/TabSeparatedRawWithNames.md | 73 +- .../TabSeparatedRawWithNames.md.hash | 2 +- .../TabSeparatedRawWithNamesAndTypes.md | 76 +- .../TabSeparatedRawWithNamesAndTypes.md.hash | 2 +- .../TabSeparated/TabSeparatedWithNames.md | 79 +- .../TabSeparatedWithNames.md.hash | 2 +- .../TabSeparatedWithNamesAndTypes.md | 78 +- .../TabSeparatedWithNamesAndTypes.md.hash | 2 +- .../interfaces/formats/Template/Template.md | 111 +- .../formats/Template/Template.md.hash | 2 +- .../formats/Template/TemplateIgnoreSpaces.md | 13 +- .../Template/TemplateIgnoreSpaces.md.hash | 2 +- .../current/interfaces/formats/Values.md | 25 +- .../current/interfaces/formats/Values.md.hash | 2 +- .../current/interfaces/formats/Vertical.md | 16 +- .../interfaces/formats/Vertical.md.hash | 2 +- .../current/interfaces/formats/XML.md | 15 +- .../current/interfaces/formats/XML.md.hash | 2 +- .../current/interfaces/grpc.md | 26 +- .../current/interfaces/grpc.md.hash | 2 +- .../current/interfaces/http.md | 329 +- .../current/interfaces/http.md.hash | 2 +- .../current/interfaces/images/mysql0.png | Bin 696049 -> 0 bytes .../current/interfaces/images/mysql1.png | Bin 134935 -> 0 bytes .../current/interfaces/images/mysql2.png | Bin 220612 -> 0 bytes .../current/interfaces/images/mysql3.png | Bin 221229 -> 0 bytes .../current/interfaces/jdbc.md | 5 +- .../current/interfaces/jdbc.md.hash | 2 +- .../current/interfaces/mysql.md | 71 +- .../current/interfaces/mysql.md.hash | 2 +- .../native-clients-interfaces-index.md | 19 +- .../native-clients-interfaces-index.md.hash | 2 +- .../current/interfaces/odbc.md | 7 +- .../current/interfaces/odbc.md.hash | 2 +- .../current/interfaces/overview.md | 18 +- .../current/interfaces/overview.md.hash | 2 +- .../current/interfaces/postgresql.md | 27 +- .../current/interfaces/postgresql.md.hash | 2 +- .../current/interfaces/prometheus.md | 62 +- .../current/interfaces/prometheus.md.hash | 2 +- .../current/interfaces/schema-inference.md | 1005 ++- .../interfaces/schema-inference.md.hash | 2 +- .../current/interfaces/ssh.md | 33 +- .../current/interfaces/ssh.md.hash | 2 +- .../current/interfaces/tcp.md | 3 +- .../current/interfaces/tcp.md.hash | 2 +- .../third-party/client-libraries.md | 123 +- .../third-party/client-libraries.md.hash | 2 +- .../current/interfaces/third-party/gui.md | 360 +- .../interfaces/third-party/gui.md.hash | 2 +- .../current/interfaces/third-party/index.md | 7 +- .../interfaces/third-party/index.md.hash | 2 +- .../interfaces/third-party/integrations.md | 277 +- .../third-party/integrations.md.hash | 2 +- .../current/interfaces/third-party/proxy.md | 23 +- .../interfaces/third-party/proxy.md.hash | 2 +- .../current/intro.md | 49 +- .../current/intro.md.hash | 2 +- .../current/introduction-index.md | 13 +- .../current/introduction-index.md.hash | 2 +- .../core-concepts/academic_overview.mdx | 402 +- .../core-concepts/academic_overview.mdx.hash | 2 +- .../managing-data/core-concepts/index.md | 21 +- .../managing-data/core-concepts/index.md.hash | 2 +- .../managing-data/core-concepts/merges.md | 185 - .../core-concepts/merges.md.hash | 1 - .../managing-data/core-concepts/merges.mdx | 185 + .../core-concepts/merges.mdx.hash | 1 + .../managing-data/core-concepts/partitions.md | 319 - .../core-concepts/partitions.md.hash | 1 - .../core-concepts/partitions.mdx | 315 + .../core-concepts/partitions.mdx.hash | 1 + .../managing-data/core-concepts/parts.md | 52 +- .../managing-data/core-concepts/parts.md.hash | 2 +- .../core-concepts/primary-indexes.md.hash | 1 - ...primary-indexes.md => primary-indexes.mdx} | 70 +- .../core-concepts/primary-indexes.mdx.hash | 1 + .../managing-data/core-concepts/shards.md | 119 - .../core-concepts/shards.md.hash | 1 - .../managing-data/core-concepts/shards.mdx | 119 + .../core-concepts/shards.mdx.hash | 1 + .../deleting-data/delete_mutations.md | 17 - .../deleting-data/delete_mutations.md.hash | 1 - .../deleting-data/delete_mutations.mdx | 18 + .../deleting-data/delete_mutations.mdx.hash | 1 + .../managing-data/deleting-data/index.md | 13 +- .../managing-data/deleting-data/index.md.hash | 2 +- .../managing-data/deleting-data/overview.md | 75 - .../deleting-data/overview.md.hash | 1 - .../managing-data/deleting-data/overview.mdx | 76 + .../deleting-data/overview.mdx.hash | 1 + .../managing-data/drop_partition.md.hash | 1 - .../{drop_partition.md => drop_partition.mdx} | 15 +- .../managing-data/drop_partition.mdx.hash | 1 + .../current/managing-data/truncate.md | 5 +- .../current/managing-data/truncate.md.hash | 2 +- .../managing-data/updating-data/index.md | 13 +- .../managing-data/updating-data/index.md.hash | 2 +- .../managing-data/updating-data/overview.md | 126 - .../updating-data/overview.md.hash | 1 - .../managing-data/updating-data/overview.mdx | 137 + .../updating-data/overview.mdx.hash | 1 + .../updating-data/update_mutations.md | 17 - .../updating-data/update_mutations.md.hash | 1 - .../updating-data/update_mutations.mdx | 18 + .../updating-data/update_mutations.mdx.hash | 1 + .../incremental-materialized-view.md | 267 +- .../incremental-materialized-view.md.hash | 2 +- .../current/materialized-view/index.md | 10 +- .../current/materialized-view/index.md.hash | 2 +- .../refreshable-materialized-view.md | 71 +- .../refreshable-materialized-view.md.hash | 2 +- .../bigquery/equivalent-concepts.md | 480 -- .../bigquery/equivalent-concepts.md.hash | 1 - .../current/migrations/bigquery/index.md | 18 - .../current/migrations/bigquery/index.md.hash | 1 - .../migrations/bigquery/loading-data.md | 135 - .../migrations/bigquery/loading-data.md.hash | 1 - .../bigquery/migrating-to-clickhouse-cloud.md | 537 -- .../migrating-to-clickhouse-cloud.md.hash | 1 - .../current/migrations/index.md | 17 - .../current/migrations/index.md.hash | 1 - .../current/migrations/postgres/appendix.md | 192 - .../migrations/postgres/appendix.md.hash | 1 - .../postgres/data-modeling-techniques.md | 262 - .../postgres/data-modeling-techniques.md.hash | 1 - .../current/migrations/postgres/dataset.md | 188 - .../migrations/postgres/dataset.md.hash | 1 - .../current/migrations/postgres/index.md.hash | 1 - .../current/migrations/postgres/overview.md | 48 - .../migrations/postgres/overview.md.hash | 1 - .../postgres/rewriting-queries.md.hash | 1 - .../current/migrations/snowflake.md | 111 - .../current/migrations/snowflake.md.hash | 1 - .../current/native-protocol/basics.md | 15 +- .../current/native-protocol/basics.md.hash | 2 +- .../current/native-protocol/client.md | 154 +- .../current/native-protocol/client.md.hash | 2 +- .../current/native-protocol/columns.md | 34 +- .../current/native-protocol/columns.md.hash | 2 +- .../current/native-protocol/hash.md | 19 +- .../current/native-protocol/hash.md.hash | 2 +- .../current/native-protocol/server.md | 167 +- .../current/native-protocol/server.md.hash | 2 +- .../current/operations/_troubleshooting.md | 65 +- .../operations/_troubleshooting.md.hash | 2 +- .../operations/allocation-profiling-old.md | 224 + .../allocation-profiling-old.md.hash | 1 + .../operations/allocation-profiling.md | 305 +- .../operations/allocation-profiling.md.hash | 2 +- .../current/operations/analyzer.md | 115 +- .../current/operations/analyzer.md.hash | 2 +- .../current/operations/backup.md | 153 +- .../current/operations/backup.md.hash | 2 +- .../current/operations/caches.md | 37 +- .../current/operations/caches.md.hash | 2 +- .../current/operations/cluster-discovery.md | 39 +- .../operations/cluster-discovery.md.hash | 2 +- .../current/operations/configuration-files.md | 168 +- .../operations/configuration-files.md.hash | 2 +- .../external-authenticators/http.md | 47 +- .../external-authenticators/http.md.hash | 2 +- .../external-authenticators/index.md | 15 +- .../external-authenticators/index.md.hash | 2 +- .../external-authenticators/kerberos.md | 55 +- .../external-authenticators/kerberos.md.hash | 2 +- .../external-authenticators/ldap.md | 109 +- .../external-authenticators/ldap.md.hash | 2 +- .../external-authenticators/ssl-x509.md | 9 +- .../external-authenticators/ssl-x509.md.hash | 2 +- .../current/operations/monitoring.md | 41 +- .../current/operations/monitoring.md.hash | 2 +- .../current/operations/named-collections.md | 115 +- .../operations/named-collections.md.hash | 2 +- .../current/operations/opentelemetry.md | 41 +- .../current/operations/opentelemetry.md.hash | 2 +- .../profile-guided-optimization.md | 21 +- .../profile-guided-optimization.md.hash | 2 +- .../sampling-query-profiler.md | 31 +- .../sampling-query-profiler.md.hash | 2 +- .../current/operations/performance-test.md | 7 +- .../operations/performance-test.md.hash | 2 +- .../current/operations/query-cache.md | 106 +- .../current/operations/query-cache.md.hash | 2 +- .../operations/query-condition-cache.md | 73 +- .../operations/query-condition-cache.md.hash | 2 +- .../current/operations/quotas.md | 55 +- .../current/operations/quotas.md.hash | 2 +- .../_server_settings_outside_source.md | 1022 +-- .../_server_settings_outside_source.md.hash | 2 +- .../_snippets/_system-log-parameters.md | 35 +- .../settings.md | 1990 +++--- .../settings.md.hash | 2 +- .../settings/composable-protocols.md | 52 +- .../settings/composable-protocols.md.hash | 2 +- .../settings/constraints-on-settings.md | 45 +- .../settings/constraints-on-settings.md.hash | 2 +- .../current/operations/settings/index.md | 20 + .../current/operations/settings/index.md.hash | 2 +- .../operations/settings/memory-overcommit.md | 35 +- .../settings/memory-overcommit.md.hash | 2 +- .../settings/merge-tree-settings.md | 1075 +-- .../settings/merge-tree-settings.md.hash | 2 +- .../current/operations/settings/overview.md | 27 +- .../operations/settings/overview.md.hash | 2 +- .../settings/permissions-for-queries.md | 51 +- .../settings/permissions-for-queries.md.hash | 2 +- .../operations/settings/query-complexity.md | 145 +- .../settings/query-complexity.md.hash | 2 +- .../operations/settings/server-overload.md | 44 +- .../settings/server-overload.md.hash | 2 +- .../operations/settings/settings-formats.md | 1086 ++- .../settings/settings-formats.md.hash | 2 +- .../operations/settings/settings-profiles.md | 15 +- .../settings/settings-profiles.md.hash | 2 +- .../settings/settings-query-level.md | 33 +- .../settings/settings-query-level.md.hash | 2 +- .../operations/settings/settings-users.md | 60 +- .../settings/settings-users.md.hash | 2 +- .../current/operations/settings/settings.md | 6031 +++++++++-------- .../operations/settings/settings.md.hash | 2 +- .../settings/tcp-connection-limits.md | 34 + .../settings/tcp-connection-limits.md.hash | 1 + .../current/operations/ssl-zookeeper.md | 23 +- .../current/operations/ssl-zookeeper.md.hash | 2 +- .../current/operations/startup-scripts.md | 9 +- .../operations/startup-scripts.md.hash | 2 +- .../current/operations/storing-data.md | 508 +- .../current/operations/storing-data.md.hash | 2 +- .../system-tables/asynchronous_insert_log.md | 37 +- .../asynchronous_insert_log.md.hash | 2 +- .../system-tables/asynchronous_inserts.md | 15 +- .../asynchronous_inserts.md.hash | 2 +- .../system-tables/asynchronous_loader.md | 67 +- .../system-tables/asynchronous_loader.md.hash | 2 +- .../system-tables/asynchronous_metric_log.md | 13 +- .../asynchronous_metric_log.md.hash | 2 +- .../system-tables/asynchronous_metrics.md | 331 +- .../asynchronous_metrics.md.hash | 2 +- .../system-tables/azure_queue_settings.md | 14 +- .../azure_queue_settings.md.hash | 2 +- .../operations/system-tables/backup_log.md | 35 +- .../system-tables/backup_log.md.hash | 2 +- .../system-tables/blob_storage_log.md | 35 +- .../system-tables/blob_storage_log.md.hash | 2 +- .../operations/system-tables/build_options.md | 5 +- .../system-tables/build_options.md.hash | 2 +- .../operations/system-tables/clusters.md | 25 +- .../operations/system-tables/clusters.md.hash | 2 +- .../operations/system-tables/codecs.md | 48 + .../operations/system-tables/codecs.md.hash | 1 + .../operations/system-tables/columns.md | 35 +- .../operations/system-tables/columns.md.hash | 2 +- .../operations/system-tables/contributors.md | 5 +- .../system-tables/contributors.md.hash | 2 +- .../operations/system-tables/crash-log.md | 23 +- .../system-tables/crash-log.md.hash | 2 +- .../operations/system-tables/crash_log.md | 60 + .../system-tables/crash_log.md.hash | 1 + .../operations/system-tables/current-roles.md | 9 +- .../system-tables/current-roles.md.hash | 2 +- .../operations/system-tables/current_roles.md | 17 + .../system-tables/current_roles.md.hash | 1 + .../operations/system-tables/dashboards.md | 9 +- .../system-tables/dashboards.md.hash | 2 +- .../system-tables/data_skipping_indices.md | 11 +- .../data_skipping_indices.md.hash | 2 +- .../system-tables/data_type_families.md | 13 +- .../system-tables/data_type_families.md.hash | 2 +- .../system-tables/database_engines.md | 5 +- .../system-tables/database_engines.md.hash | 2 +- .../system-tables/database_replicas.md | 56 + .../system-tables/database_replicas.md.hash | 1 + .../operations/system-tables/databases.md | 9 +- .../system-tables/databases.md.hash | 2 +- .../system-tables/dead_letter_queue.md | 129 + .../system-tables/dead_letter_queue.md.hash | 1 + .../system-tables/delta_metadata_log.md | 52 + .../system-tables/delta_metadata_log.md.hash | 1 + .../system-tables/detached_parts.md | 9 +- .../system-tables/detached_parts.md.hash | 2 +- .../system-tables/detached_tables.md | 11 +- .../system-tables/detached_tables.md.hash | 2 +- .../operations/system-tables/dictionaries.md | 39 +- .../system-tables/dictionaries.md.hash | 2 +- .../system-tables/dimensional_metrics.md | 57 + .../system-tables/dimensional_metrics.md.hash | 1 + .../current/operations/system-tables/disks.md | 11 +- .../operations/system-tables/disks.md.hash | 2 +- .../system-tables/distributed_ddl_queue.md | 13 +- .../distributed_ddl_queue.md.hash | 2 +- .../system-tables/distribution_queue.md | 25 +- .../system-tables/distribution_queue.md.hash | 2 +- .../operations/system-tables/dns_cache.md | 13 +- .../system-tables/dns_cache.md.hash | 2 +- .../system-tables/dropped_tables.md | 13 +- .../system-tables/dropped_tables.md.hash | 2 +- .../system-tables/dropped_tables_parts.md | 9 +- .../dropped_tables_parts.md.hash | 2 +- .../operations/system-tables/enabled-roles.md | 9 +- .../system-tables/enabled-roles.md.hash | 2 +- .../operations/system-tables/enabled_roles.md | 18 + .../system-tables/enabled_roles.md.hash | 1 + .../operations/system-tables/error_log.md | 21 +- .../system-tables/error_log.md.hash | 2 +- .../operations/system-tables/errors.md | 11 +- .../operations/system-tables/errors.md.hash | 2 +- .../operations/system-tables/events.md | 11 +- .../operations/system-tables/events.md.hash | 2 +- .../operations/system-tables/functions.md | 25 +- .../system-tables/functions.md.hash | 2 +- .../operations/system-tables/grants.md | 19 +- .../operations/system-tables/grants.md.hash | 2 +- .../system-tables/graphite_retentions.md | 21 +- .../system-tables/graphite_retentions.md.hash | 2 +- .../system-tables/histogram_metrics.md | 15 +- .../system-tables/histogram_metrics.md.hash | 2 +- .../system-tables/iceberg_history.md | 15 +- .../system-tables/iceberg_history.md.hash | 2 +- .../system-tables/iceberg_metadata_log.md | 90 + .../iceberg_metadata_log.md.hash | 1 + .../current/operations/system-tables/index.md | 128 +- .../operations/system-tables/index.md.hash | 2 +- .../system-tables/information_schema.md | 215 +- .../system-tables/information_schema.md.hash | 2 +- .../operations/system-tables/jemalloc_bins.md | 17 +- .../system-tables/jemalloc_bins.md.hash | 2 +- .../system-tables/kafka_consumers.md | 39 +- .../system-tables/kafka_consumers.md.hash | 2 +- .../system-tables/latency_buckets.md | 40 - .../system-tables/latency_buckets.md.hash | 1 - .../operations/system-tables/latency_log.md | 57 - .../system-tables/latency_log.md.hash | 1 - .../operations/system-tables/licenses.md | 11 +- .../operations/system-tables/licenses.md.hash | 2 +- .../system-tables/merge_tree_settings.md | 57 +- .../system-tables/merge_tree_settings.md.hash | 2 +- .../operations/system-tables/merges.md | 23 +- .../operations/system-tables/merges.md.hash | 2 +- .../operations/system-tables/metric_log.md | 15 +- .../system-tables/metric_log.md.hash | 2 +- .../operations/system-tables/metrics.md | 393 +- .../operations/system-tables/metrics.md.hash | 2 +- .../current/operations/system-tables/moves.md | 19 +- .../operations/system-tables/moves.md.hash | 2 +- .../operations/system-tables/mutations.md | 61 +- .../system-tables/mutations.md.hash | 2 +- .../operations/system-tables/numbers.md | 9 +- .../operations/system-tables/numbers.md.hash | 2 +- .../operations/system-tables/numbers_mt.md | 5 +- .../system-tables/numbers_mt.md.hash | 2 +- .../current/operations/system-tables/one.md | 9 +- .../operations/system-tables/one.md.hash | 2 +- .../system-tables/opentelemetry_span_log.md | 21 +- .../opentelemetry_span_log.md.hash | 2 +- .../operations/system-tables/overview.md | 73 +- .../operations/system-tables/overview.md.hash | 2 +- .../operations/system-tables/part_log.md | 123 +- .../operations/system-tables/part_log.md.hash | 2 +- .../current/operations/system-tables/parts.md | 97 +- .../operations/system-tables/parts.md.hash | 2 +- .../operations/system-tables/parts_columns.md | 79 +- .../system-tables/parts_columns.md.hash | 2 +- .../operations/system-tables/processes.md | 19 +- .../system-tables/processes.md.hash | 2 +- .../system-tables/processors_profile_log.md | 41 +- .../processors_profile_log.md.hash | 2 +- .../system-tables/projection_parts.md | 82 + .../system-tables/projection_parts.md.hash | 1 + .../system-tables/projection_parts_columns.md | 70 + .../projection_parts_columns.md.hash | 1 + .../operations/system-tables/projections.md | 3 +- .../system-tables/projections.md.hash | 2 +- .../operations/system-tables/query_cache.md | 5 +- .../system-tables/query_cache.md.hash | 2 +- .../system-tables/query_condition_cache.md | 9 +- .../query_condition_cache.md.hash | 2 +- .../operations/system-tables/query_log.md | 157 +- .../system-tables/query_log.md.hash | 2 +- .../system-tables/query_metric_log.md | 15 +- .../system-tables/query_metric_log.md.hash | 2 +- .../system-tables/query_thread_log.md | 75 +- .../system-tables/query_thread_log.md.hash | 2 +- .../system-tables/query_views_log.md | 41 +- .../system-tables/query_views_log.md.hash | 2 +- .../operations/system-tables/quota_limits.md | 17 +- .../system-tables/quota_limits.md.hash | 2 +- .../operations/system-tables/quota_usage.md | 43 +- .../system-tables/quota_usage.md.hash | 2 +- .../operations/system-tables/quotas.md | 33 +- .../operations/system-tables/quotas.md.hash | 2 +- .../operations/system-tables/quotas_usage.md | 33 +- .../system-tables/quotas_usage.md.hash | 2 +- .../operations/system-tables/replicas.md | 63 +- .../operations/system-tables/replicas.md.hash | 2 +- .../system-tables/replicated_fetches.md | 15 +- .../system-tables/replicated_fetches.md.hash | 2 +- .../system-tables/replication_queue.md | 67 +- .../system-tables/replication_queue.md.hash | 2 +- .../operations/system-tables/resources.md | 5 +- .../system-tables/resources.md.hash | 2 +- .../operations/system-tables/role-grants.md | 15 +- .../system-tables/role-grants.md.hash | 2 +- .../operations/system-tables/role_grants.md | 30 + .../system-tables/role_grants.md.hash | 1 + .../current/operations/system-tables/roles.md | 9 +- .../operations/system-tables/roles.md.hash | 2 +- .../operations/system-tables/row_policies.md | 21 +- .../system-tables/row_policies.md.hash | 2 +- .../system-tables/s3_queue_settings.md | 19 +- .../system-tables/s3_queue_settings.md.hash | 2 +- .../operations/system-tables/scheduler.md | 49 +- .../system-tables/scheduler.md.hash | 2 +- .../system-tables/schema_inference_cache.md | 17 +- .../schema_inference_cache.md.hash | 2 +- .../system-tables/server_settings.md | 31 +- .../system-tables/server_settings.md.hash | 2 +- .../operations/system-tables/session_log.md | 47 +- .../system-tables/session_log.md.hash | 2 +- .../operations/system-tables/settings.md | 43 +- .../operations/system-tables/settings.md.hash | 2 +- .../system-tables/settings_changes.md | 9 +- .../system-tables/settings_changes.md.hash | 2 +- .../settings_profile_elements.md | 19 +- .../settings_profile_elements.md.hash | 2 +- .../system-tables/settings_profiles.md | 13 +- .../system-tables/settings_profiles.md.hash | 2 +- .../operations/system-tables/stack_trace.md | 19 +- .../system-tables/stack_trace.md.hash | 2 +- .../system-tables/storage_policies.md | 29 +- .../system-tables/storage_policies.md.hash | 2 +- .../operations/system-tables/symbols.md | 9 +- .../operations/system-tables/symbols.md.hash | 2 +- .../system-tables/system_warnings.md | 11 +- .../system-tables/system_warnings.md.hash | 2 +- .../operations/system-tables/table_engines.md | 28 +- .../system-tables/table_engines.md.hash | 2 +- .../operations/system-tables/tables.md | 41 +- .../operations/system-tables/tables.md.hash | 2 +- .../operations/system-tables/text_log.md | 37 +- .../operations/system-tables/text_log.md.hash | 2 +- .../operations/system-tables/time_zones.md | 1 + .../system-tables/time_zones.md.hash | 2 +- .../operations/system-tables/trace_log.md | 54 +- .../system-tables/trace_log.md.hash | 2 +- .../system-tables/user_processes.md | 9 +- .../system-tables/user_processes.md.hash | 2 +- .../current/operations/system-tables/users.md | 21 +- .../operations/system-tables/users.md.hash | 2 +- .../system-tables/view_refreshes.md | 23 +- .../system-tables/view_refreshes.md.hash | 2 +- .../operations/system-tables/workloads.md | 7 +- .../system-tables/workloads.md.hash | 2 +- .../operations/system-tables/zookeeper.md | 33 +- .../system-tables/zookeeper.md.hash | 2 +- .../system-tables/zookeeper_connection.md | 15 +- .../zookeeper_connection.md.hash | 2 +- .../system-tables/zookeeper_connection_log.md | 60 + .../zookeeper_connection_log.md.hash | 1 + .../operations/system-tables/zookeeper_log.md | 69 +- .../system-tables/zookeeper_log.md.hash | 2 +- .../current/operations/tips.md | 143 +- .../current/operations/tips.md.hash | 2 +- .../current/operations/update.md | 72 +- .../current/operations/update.md.hash | 2 +- .../operations/userspace-page-cache.md | 61 +- .../operations/userspace-page-cache.md.hash | 2 +- .../operations/utilities/backupview.md | 14 +- .../operations/utilities/backupview.md.hash | 2 +- .../utilities/clickhouse-benchmark.md | 71 +- .../utilities/clickhouse-benchmark.md.hash | 2 +- .../utilities/clickhouse-compressor.md | 5 +- .../utilities/clickhouse-compressor.md.hash | 2 +- .../operations/utilities/clickhouse-disks.md | 47 +- .../utilities/clickhouse-disks.md.hash | 2 +- .../operations/utilities/clickhouse-format.md | 24 +- .../utilities/clickhouse-format.md.hash | 2 +- .../utilities/clickhouse-keeper-client.md | 49 +- .../clickhouse-keeper-client.md.hash | 2 +- .../operations/utilities/clickhouse-local.md | 88 +- .../utilities/clickhouse-local.md.hash | 2 +- .../utilities/clickhouse-obfuscator.md | 47 +- .../utilities/clickhouse-obfuscator.md.hash | 2 +- .../current/operations/utilities/index.md | 23 +- .../operations/utilities/index.md.hash | 2 +- .../operations/utilities/odbc-bridge.md | 21 +- .../operations/utilities/odbc-bridge.md.hash | 2 +- .../current/operations/workload-scheduling.md | 236 +- .../operations/workload-scheduling.md.hash | 2 +- .../current/quick-start.mdx.hash | 1 - .../aggregate-functions/combinators.md | 81 +- .../aggregate-functions/combinators.md.hash | 2 +- .../aggregate-functions/grouping_function.md | 33 +- .../grouping_function.md.hash | 2 +- .../aggregate-functions/index.md | 33 +- .../aggregate-functions/index.md.hash | 2 +- .../parametric-functions.md | 218 +- .../parametric-functions.md.hash | 2 +- .../aggregate-functions/reference/aggthrow.md | 9 +- .../reference/aggthrow.md.hash | 2 +- .../reference/analysis_of_variance.md | 15 +- .../reference/analysis_of_variance.md.hash | 2 +- .../aggregate-functions/reference/any.md | 33 +- .../aggregate-functions/reference/any.md.hash | 2 +- .../aggregate-functions/reference/anyheavy.md | 7 +- .../reference/anyheavy.md.hash | 2 +- .../aggregate-functions/reference/anylast.md | 9 +- .../reference/anylast.md.hash | 2 +- .../reference/approxtopk.md | 17 +- .../reference/approxtopk.md.hash | 2 +- .../reference/approxtopsum.md | 17 +- .../reference/approxtopsum.md.hash | 2 +- .../aggregate-functions/reference/argmax.md | 12 +- .../reference/argmax.md.hash | 2 +- .../aggregate-functions/reference/argmin.md | 11 +- .../reference/argmin.md.hash | 2 +- .../reference/arrayconcatagg.md | 32 - .../reference/arrayconcatagg.md.hash | 1 - .../aggregate-functions/reference/avg.md | 7 +- .../aggregate-functions/reference/avg.md.hash | 2 +- .../reference/avgweighted.md | 15 +- .../reference/avgweighted.md.hash | 2 +- .../aggregate-functions/reference/boundrat.md | 7 +- .../reference/boundrat.md.hash | 2 +- .../reference/categoricalinformationvalue.md | 9 +- .../categoricalinformationvalue.md.hash | 2 +- .../reference/contingency.md | 14 +- .../reference/contingency.md.hash | 2 +- .../aggregate-functions/reference/corr.md | 17 +- .../reference/corr.md.hash | 2 +- .../reference/corrmatrix.md | 9 +- .../reference/corrmatrix.md.hash | 2 +- .../reference/corrstable.md | 9 +- .../reference/corrstable.md.hash | 2 +- .../aggregate-functions/reference/count.md | 31 +- .../reference/count.md.hash | 2 +- .../aggregate-functions/reference/covarpop.md | 3 +- .../reference/covarpop.md.hash | 2 +- .../reference/covarpopmatrix.md | 3 +- .../reference/covarpopmatrix.md.hash | 2 +- .../reference/covarpopstable.md | 9 +- .../reference/covarpopstable.md.hash | 2 +- .../reference/covarsamp.md | 11 +- .../reference/covarsamp.md.hash | 2 +- .../reference/covarsampmatrix.md | 1 + .../reference/covarsampmatrix.md.hash | 2 +- .../reference/covarsampstable.md | 5 +- .../reference/covarsampstable.md.hash | 2 +- .../aggregate-functions/reference/cramersv.md | 19 +- .../reference/cramersv.md.hash | 2 +- .../reference/cramersvbiascorrected.md | 11 +- .../reference/cramersvbiascorrected.md.hash | 2 +- .../aggregate-functions/reference/deltasum.md | 9 +- .../reference/deltasum.md.hash | 2 +- .../reference/deltasumtimestamp.md | 17 +- .../reference/deltasumtimestamp.md.hash | 2 +- .../reference/distinctdynamictypes.md | 3 +- .../reference/distinctdynamictypes.md.hash | 2 +- .../reference/distinctjsonpaths.md | 5 +- .../reference/distinctjsonpaths.md.hash | 2 +- .../aggregate-functions/reference/entropy.md | 15 +- .../reference/entropy.md.hash | 2 +- .../reference/estimateCompressionRatio.md | 11 +- .../estimateCompressionRatio.md.hash | 2 +- .../reference/exponentialmovingaverage.md | 23 +- .../exponentialmovingaverage.md.hash | 2 +- .../reference/exponentialtimedecayedavg.md | 9 +- .../exponentialtimedecayedavg.md.hash | 2 +- .../reference/exponentialtimedecayedcount.md | 7 +- .../exponentialtimedecayedcount.md.hash | 2 +- .../reference/exponentialtimedecayedmax.md | 9 +- .../exponentialtimedecayedmax.md.hash | 2 +- .../reference/exponentialtimedecayedsum.md | 7 +- .../exponentialtimedecayedsum.md.hash | 2 +- .../reference/first_value.md | 27 +- .../reference/first_value.md.hash | 2 +- .../reference/flame_graph.md | 17 +- .../reference/flame_graph.md.hash | 2 +- .../reference/grouparray.md | 13 +- .../reference/grouparray.md.hash | 2 +- .../reference/grouparrayarray.md | 9 +- .../reference/grouparrayarray.md.hash | 2 +- .../reference/grouparrayinsertat.md | 19 +- .../reference/grouparrayinsertat.md.hash | 2 +- .../reference/grouparrayintersect.md | 7 +- .../reference/grouparrayintersect.md.hash | 2 +- .../reference/grouparraylast.md | 17 +- .../reference/grouparraylast.md.hash | 2 +- .../reference/grouparraymovingavg.md | 7 +- .../reference/grouparraymovingavg.md.hash | 2 +- .../reference/grouparraymovingsum.md | 9 +- .../reference/grouparraymovingsum.md.hash | 2 +- .../reference/grouparraysample.md | 15 +- .../reference/grouparraysample.md.hash | 2 +- .../reference/grouparraysorted.md | 9 +- .../reference/grouparraysorted.md.hash | 2 +- .../reference/groupbitand.md | 7 +- .../reference/groupbitand.md.hash | 2 +- .../reference/groupbitmap.md | 7 +- .../reference/groupbitmap.md.hash | 2 +- .../reference/groupbitmapand.md | 13 +- .../reference/groupbitmapand.md.hash | 2 +- .../reference/groupbitmapor.md | 11 +- .../reference/groupbitmapor.md.hash | 2 +- .../reference/groupbitmapxor.md | 15 +- .../reference/groupbitmapxor.md.hash | 2 +- .../reference/groupbitor.md | 7 +- .../reference/groupbitor.md.hash | 2 +- .../reference/groupbitxor.md | 5 +- .../reference/groupbitxor.md.hash | 2 +- .../reference/groupconcat.md | 31 +- .../reference/groupconcat.md.hash | 2 +- .../reference/groupuniqarray.md | 5 +- .../reference/groupuniqarray.md.hash | 2 +- .../aggregate-functions/reference/index.md | 142 +- .../reference/index.md.hash | 2 +- .../reference/intervalLengthSum.md | 21 +- .../reference/intervalLengthSum.md.hash | 2 +- .../reference/kolmogorovsmirnovtest.md | 62 +- .../reference/kolmogorovsmirnovtest.md.hash | 2 +- .../aggregate-functions/reference/kurtpop.md | 5 +- .../reference/kurtpop.md.hash | 2 +- .../aggregate-functions/reference/kurtsamp.md | 9 +- .../reference/kurtsamp.md.hash | 2 +- .../reference/largestTriangleThreeBuckets.md | 13 +- .../largestTriangleThreeBuckets.md.hash | 2 +- .../reference/last_value.md | 27 +- .../reference/last_value.md.hash | 2 +- .../reference/mannwhitneyutest.md | 35 +- .../reference/mannwhitneyutest.md.hash | 2 +- .../aggregate-functions/reference/max.md | 7 +- .../aggregate-functions/reference/max.md.hash | 2 +- .../reference/maxintersections.md | 21 +- .../reference/maxintersections.md.hash | 2 +- .../reference/maxintersectionsposition.md | 15 +- .../maxintersectionsposition.md.hash | 2 +- .../aggregate-functions/reference/maxmap.md | 19 +- .../reference/maxmap.md.hash | 2 +- .../reference/meanztest.md | 18 +- .../reference/meanztest.md.hash | 2 +- .../aggregate-functions/reference/median.md | 7 +- .../reference/median.md.hash | 2 +- .../aggregate-functions/reference/min.md | 5 +- .../aggregate-functions/reference/min.md.hash | 2 +- .../aggregate-functions/reference/minmap.md | 15 +- .../reference/minmap.md.hash | 2 +- .../aggregate-functions/reference/quantile.md | 25 +- .../reference/quantile.md.hash | 2 +- .../reference/quantileGK.md | 15 +- .../reference/quantileGK.md.hash | 2 +- .../reference/quantilebfloat16.md | 21 +- .../reference/quantilebfloat16.md.hash | 2 +- .../reference/quantileddsketch.md | 21 +- .../reference/quantileddsketch.md.hash | 2 +- .../reference/quantiledeterministic.md | 19 +- .../reference/quantiledeterministic.md.hash | 2 +- .../reference/quantileexact.md | 87 +- .../reference/quantileexact.md.hash | 2 +- .../reference/quantileexactweighted.md | 27 +- .../reference/quantileexactweighted.md.hash | 2 +- .../quantileexactweightedinterpolated.md | 25 +- .../quantileexactweightedinterpolated.md.hash | 2 +- .../reference/quantileinterpolatedweighted.md | 27 +- .../quantileinterpolatedweighted.md.hash | 2 +- .../reference/quantileprometheushistogram.md | 66 + .../quantileprometheushistogram.md.hash | 1 + .../reference/quantiles.md | 63 +- .../reference/quantiles.md.hash | 2 +- .../reference/quantiletdigest.md | 21 +- .../reference/quantiletdigest.md.hash | 2 +- .../reference/quantiletdigestweighted.md | 27 +- .../reference/quantiletdigestweighted.md.hash | 2 +- .../reference/quantiletiming.md | 29 +- .../reference/quantiletiming.md.hash | 2 +- .../reference/quantiletimingweighted.md | 33 +- .../reference/quantiletimingweighted.md.hash | 2 +- .../aggregate-functions/reference/rankCorr.md | 12 +- .../reference/rankCorr.md.hash | 2 +- .../reference/simplelinearregression.md | 7 +- .../reference/simplelinearregression.md.hash | 2 +- .../reference/singlevalueornull.md | 8 +- .../reference/singlevalueornull.md.hash | 2 +- .../aggregate-functions/reference/skewpop.md | 3 +- .../reference/skewpop.md.hash | 2 +- .../aggregate-functions/reference/skewsamp.md | 9 +- .../reference/skewsamp.md.hash | 2 +- .../aggregate-functions/reference/sparkbar.md | 16 +- .../reference/sparkbar.md.hash | 2 +- .../reference/stddevpop.md | 13 +- .../reference/stddevpop.md.hash | 2 +- .../reference/stddevpopstable.md | 9 +- .../reference/stddevpopstable.md.hash | 2 +- .../reference/stddevsamp.md | 9 +- .../reference/stddevsamp.md.hash | 2 +- .../reference/stddevsampstable.md | 9 +- .../reference/stddevsampstable.md.hash | 2 +- .../reference/stochasticlinearregression.md | 43 +- .../stochasticlinearregression.md.hash | 2 +- .../reference/stochasticlogisticregression.md | 15 +- .../stochasticlogisticregression.md.hash | 2 +- .../reference/studentttest.md | 25 +- .../reference/studentttest.md.hash | 2 +- .../reference/studentttestonesample.md | 80 + .../reference/studentttestonesample.md.hash | 1 + .../aggregate-functions/reference/sum.md | 5 +- .../aggregate-functions/reference/sum.md.hash | 2 +- .../aggregate-functions/reference/sumcount.md | 15 +- .../reference/sumcount.md.hash | 2 +- .../aggregate-functions/reference/sumkahan.md | 17 +- .../reference/sumkahan.md.hash | 2 +- .../aggregate-functions/reference/summap.md | 67 +- .../reference/summap.md.hash | 2 +- .../reference/summapwithoverflow.md | 27 +- .../reference/summapwithoverflow.md.hash | 2 +- .../reference/sumwithoverflow.md | 15 +- .../reference/sumwithoverflow.md.hash | 2 +- .../aggregate-functions/reference/theilsu.md | 13 +- .../reference/theilsu.md.hash | 2 +- .../reference/timeSeriesChangesToGrid.md | 70 + .../reference/timeSeriesChangesToGrid.md.hash | 1 + .../reference/timeSeriesDeltaToGrid.md | 70 + .../reference/timeSeriesDeltaToGrid.md.hash | 1 + .../reference/timeSeriesDerivToGrid.md | 70 + .../reference/timeSeriesDerivToGrid.md.hash | 1 + .../reference/timeSeriesGroupArray.md | 66 + .../reference/timeSeriesGroupArray.md.hash | 1 + .../reference/timeSeriesInstantDeltaToGrid.md | 70 + .../timeSeriesInstantDeltaToGrid.md.hash | 1 + .../reference/timeSeriesInstantRateToGrid.md | 70 + .../timeSeriesInstantRateToGrid.md.hash | 1 + .../reference/timeSeriesLastTwoSamples.md | 159 + .../timeSeriesLastTwoSamples.md.hash | 1 + .../timeSeriesPredictLinearToGrid.md | 73 + .../timeSeriesPredictLinearToGrid.md.hash | 1 + .../reference/timeSeriesRateToGrid.md | 70 + .../reference/timeSeriesRateToGrid.md.hash | 1 + .../timeSeriesResampleToGridWithStaleness.md | 72 + ...eSeriesResampleToGridWithStaleness.md.hash | 1 + .../reference/timeSeriesResetsToGrid.md | 70 + .../reference/timeSeriesResetsToGrid.md.hash | 1 + .../aggregate-functions/reference/topk.md | 19 +- .../reference/topk.md.hash | 2 +- .../reference/topkweighted.md | 13 +- .../reference/topkweighted.md.hash | 2 +- .../aggregate-functions/reference/uniq.md | 9 +- .../reference/uniq.md.hash | 2 +- .../reference/uniqcombined.md | 29 +- .../reference/uniqcombined.md.hash | 2 +- .../reference/uniqcombined64.md | 33 +- .../reference/uniqcombined64.md.hash | 2 +- .../reference/uniqexact.md | 15 +- .../reference/uniqexact.md.hash | 2 +- .../reference/uniqhll12.md | 9 +- .../reference/uniqhll12.md.hash | 2 +- .../reference/uniqthetasketch.md | 13 +- .../reference/uniqthetasketch.md.hash | 2 +- .../aggregate-functions/reference/varpop.md | 13 +- .../reference/varpop.md.hash | 2 +- .../reference/varpopstable.md | 9 +- .../reference/varpopstable.md.hash | 2 +- .../aggregate-functions/reference/varsamp.md | 13 +- .../reference/varsamp.md.hash | 2 +- .../reference/varsampstable.md | 19 +- .../reference/varsampstable.md.hash | 2 +- .../reference/welchttest.md | 15 +- .../reference/welchttest.md.hash | 2 +- .../data-types/aggregatefunction.md | 41 +- .../data-types/aggregatefunction.md.hash | 2 +- .../current/sql-reference/data-types/array.md | 19 +- .../sql-reference/data-types/array.md.hash | 2 +- .../sql-reference/data-types/boolean.md | 5 +- .../sql-reference/data-types/boolean.md.hash | 2 +- .../data-types/data-types-binary-encoding.md | 203 +- .../data-types-binary-encoding.md.hash | 2 +- .../current/sql-reference/data-types/date.md | 17 +- .../sql-reference/data-types/date.md.hash | 2 +- .../sql-reference/data-types/date32.md | 7 +- .../sql-reference/data-types/date32.md.hash | 2 +- .../sql-reference/data-types/datetime.md | 100 +- .../sql-reference/data-types/datetime.md.hash | 2 +- .../sql-reference/data-types/datetime64.md | 35 +- .../data-types/datetime64.md.hash | 2 +- .../sql-reference/data-types/decimal.md | 44 +- .../sql-reference/data-types/decimal.md.hash | 2 +- .../sql-reference/data-types/domains/index.md | 25 +- .../data-types/domains/index.md.hash | 2 +- .../sql-reference/data-types/dynamic.md | 131 +- .../sql-reference/data-types/dynamic.md.hash | 2 +- .../current/sql-reference/data-types/enum.md | 64 +- .../sql-reference/data-types/enum.md.hash | 2 +- .../sql-reference/data-types/fixedstring.md | 97 +- .../data-types/fixedstring.md.hash | 2 +- .../current/sql-reference/data-types/float.md | 32 +- .../sql-reference/data-types/float.md.hash | 2 +- .../current/sql-reference/data-types/geo.md | 25 +- .../sql-reference/data-types/geo.md.hash | 2 +- .../current/sql-reference/data-types/index.md | 11 +- .../sql-reference/data-types/index.md.hash | 2 +- .../sql-reference/data-types/int-uint.md | 33 +- .../sql-reference/data-types/int-uint.md.hash | 2 +- .../current/sql-reference/data-types/ipv4.md | 9 +- .../sql-reference/data-types/ipv4.md.hash | 2 +- .../current/sql-reference/data-types/ipv6.md | 7 +- .../sql-reference/data-types/ipv6.md.hash | 2 +- .../current/sql-reference/data-types/json.md | 21 +- .../sql-reference/data-types/json.md.hash | 2 +- .../data-types/lowcardinality.md | 17 +- .../data-types/lowcardinality.md.hash | 2 +- .../current/sql-reference/data-types/map.md | 22 +- .../sql-reference/data-types/map.md.hash | 2 +- .../nested-data-structures/index.md | 21 +- .../nested-data-structures/index.md.hash | 2 +- .../sql-reference/data-types/newjson.md | 424 +- .../sql-reference/data-types/newjson.md.hash | 2 +- .../sql-reference/data-types/nullable.md | 13 +- .../sql-reference/data-types/nullable.md.hash | 2 +- .../current/sql-reference/data-types/qbit.md | 79 + .../sql-reference/data-types/qbit.md.hash | 1 + .../data-types/simpleaggregatefunction.md | 21 +- .../simpleaggregatefunction.md.hash | 2 +- .../special-data-types/expression.md | 3 +- .../special-data-types/expression.md.hash | 2 +- .../data-types/special-data-types/index.md | 5 +- .../special-data-types/index.md.hash | 2 +- .../data-types/special-data-types/interval.md | 29 +- .../special-data-types/interval.md.hash | 2 +- .../data-types/special-data-types/nothing.md | 9 +- .../special-data-types/nothing.md.hash | 2 +- .../data-types/special-data-types/set.md | 9 +- .../data-types/special-data-types/set.md.hash | 2 +- .../sql-reference/data-types/string.md | 25 +- .../sql-reference/data-types/string.md.hash | 2 +- .../current/sql-reference/data-types/time.md | 103 +- .../sql-reference/data-types/time.md.hash | 2 +- .../sql-reference/data-types/time64.md | 108 +- .../sql-reference/data-types/time64.md.hash | 2 +- .../current/sql-reference/data-types/tuple.md | 25 +- .../sql-reference/data-types/tuple.md.hash | 2 +- .../current/sql-reference/data-types/uuid.md | 25 +- .../sql-reference/data-types/uuid.md.hash | 2 +- .../sql-reference/data-types/variant.md | 73 +- .../sql-reference/data-types/variant.md.hash | 2 +- .../_snippet_dictionary_in_cloud.md | 9 +- .../_snippet_dictionary_in_cloud.md.hash | 2 +- .../sql-reference/dictionaries/index.md | 677 +- .../sql-reference/dictionaries/index.md.hash | 2 +- .../current/sql-reference/distributed-ddl.md | 13 +- .../sql-reference/distributed-ddl.md.hash | 2 +- .../current/sql-reference/formats.mdx | 1 + .../current/sql-reference/formats.mdx.hash | 2 +- .../functions/arithmetic-functions.md | 1017 +-- .../functions/arithmetic-functions.md.hash | 2 +- .../functions/array-functions.md | 2005 ++++-- .../functions/array-functions.md.hash | 2 +- .../sql-reference/functions/array-join.md | 85 +- .../functions/array-join.md.hash | 2 +- .../sql-reference/functions/bit-functions.md | 716 +- .../functions/bit-functions.md.hash | 2 +- .../functions/bitmap-functions.md | 637 +- .../functions/bitmap-functions.md.hash | 2 +- .../functions/comparison-functions.md | 234 +- .../functions/comparison-functions.md.hash | 2 +- .../functions/conditional-functions.md | 589 +- .../functions/conditional-functions.md.hash | 2 +- .../functions/date-time-functions.md | 5717 +++++++++------- .../functions/date-time-functions.md.hash | 2 +- .../functions/distance-functions.md | 573 +- .../functions/distance-functions.md.hash | 2 +- ...unctions.md => embedded-dict-functions.md} | 121 +- .../functions/embedded-dict-functions.md.hash | 1 + .../functions/encoding-functions.md | 1264 ++-- .../functions/encoding-functions.md.hash | 2 +- .../functions/encryption-functions.md | 437 +- .../functions/encryption-functions.md.hash | 2 +- .../functions/ext-dict-functions.md | 147 +- .../functions/ext-dict-functions.md.hash | 2 +- .../current/sql-reference/functions/files.md | 12 +- .../sql-reference/functions/files.md.hash | 2 +- .../functions/financial-functions.md | 268 + .../functions/financial-functions.md.hash | 1 + .../functions/functions-for-nulls.md | 580 +- .../functions/functions-for-nulls.md.hash | 2 +- .../functions/geo/coordinates.md | 63 +- .../functions/geo/coordinates.md.hash | 2 +- .../sql-reference/functions/geo/geohash.md | 39 +- .../functions/geo/geohash.md.hash | 2 +- .../current/sql-reference/functions/geo/h3.md | 296 +- .../sql-reference/functions/geo/h3.md.hash | 2 +- .../sql-reference/functions/geo/index.md | 6 +- .../sql-reference/functions/geo/index.md.hash | 2 +- .../sql-reference/functions/geo/polygon.md | 335 +- .../functions/geo/polygon.md.hash | 2 +- .../current/sql-reference/functions/geo/s2.md | 37 +- .../sql-reference/functions/geo/s2.md.hash | 2 +- .../sql-reference/functions/geo/svg.md | 11 +- .../sql-reference/functions/geo/svg.md.hash | 2 +- .../sql-reference/functions/hash-functions.md | 2827 +++++--- .../functions/hash-functions.md.hash | 2 +- .../sql-reference/functions/in-functions.md | 10 +- .../functions/in-functions.md.hash | 2 +- .../current/sql-reference/functions/index.md | 13 +- .../sql-reference/functions/index.md.hash | 2 +- .../sql-reference/functions/introspection.md | 487 +- .../functions/introspection.md.hash | 2 +- .../functions/ip-address-functions.md | 1113 ++- .../functions/ip-address-functions.md.hash | 2 +- .../sql-reference/functions/json-functions.md | 2088 ++++-- .../functions/json-functions.md.hash | 2 +- .../functions/logical-functions.md | 208 +- .../functions/logical-functions.md.hash | 2 +- .../functions/machine-learning-functions.md | 13 +- .../machine-learning-functions.md.hash | 2 +- .../sql-reference/functions/math-functions.md | 1277 ++-- .../functions/math-functions.md.hash | 2 +- .../sql-reference/functions/nlp-functions.md | 445 +- .../functions/nlp-functions.md.hash | 2 +- .../numeric-indexed-vector-functions.md | 622 ++ .../numeric-indexed-vector-functions.md.hash | 1 + .../functions/other-functions.md | 1012 +-- .../functions/other-functions.md.hash | 2 +- .../sql-reference/functions/overview.md | 40 +- .../sql-reference/functions/overview.md.hash | 2 +- .../functions/random-functions.md | 94 +- .../functions/random-functions.md.hash | 2 +- .../functions/regular-functions-index.md | 93 +- .../functions/regular-functions-index.md.hash | 2 +- .../functions/rounding-functions.md | 122 +- .../functions/rounding-functions.md.hash | 2 +- .../functions/splitting-merging-functions.md | 149 +- .../splitting-merging-functions.md.hash | 2 +- .../functions/string-functions.md | 634 +- .../functions/string-functions.md.hash | 2 +- .../functions/string-replace-functions.md | 72 +- .../string-replace-functions.md.hash | 2 +- .../functions/string-search-functions.md | 683 +- .../functions/string-search-functions.md.hash | 2 +- .../time-series-analysis-functions.md | 175 + .../time-series-analysis-functions.md.hash | 1 + .../functions/time-series-functions.md | 149 +- .../functions/time-series-functions.md.hash | 2 +- .../functions/time-window-functions.md | 56 +- .../functions/time-window-functions.md.hash | 2 +- .../functions/tuple-functions.md | 129 +- .../functions/tuple-functions.md.hash | 2 +- .../functions/tuple-map-functions.md | 274 +- .../functions/tuple-map-functions.md.hash | 2 +- .../functions/type-conversion-functions.md | 2045 +++--- .../type-conversion-functions.md.hash | 2 +- .../current/sql-reference/functions/udf.md | 129 +- .../sql-reference/functions/udf.md.hash | 2 +- .../sql-reference/functions/ulid-functions.md | 30 +- .../functions/ulid-functions.md.hash | 2 +- .../functions/uniqtheta-functions.md | 26 +- .../functions/uniqtheta-functions.md.hash | 2 +- .../sql-reference/functions/url-functions.md | 223 +- .../functions/url-functions.md.hash | 2 +- .../sql-reference/functions/uuid-functions.md | 337 +- .../functions/uuid-functions.md.hash | 2 +- .../functions/ym-dict-functions.md.hash | 1 - .../current/sql-reference/index.md | 3 +- .../current/sql-reference/index.md.hash | 2 +- .../operators/distributed-ddl.md | 3 +- .../operators/distributed-ddl.md.hash | 2 +- .../current/sql-reference/operators/exists.md | 11 +- .../sql-reference/operators/exists.md.hash | 2 +- .../current/sql-reference/operators/in.md | 116 +- .../sql-reference/operators/in.md.hash | 2 +- .../current/sql-reference/operators/index.md | 202 +- .../sql-reference/operators/index.md.hash | 2 +- .../statements/alter/apply-deleted-mask.md | 9 +- .../alter/apply-deleted-mask.md.hash | 2 +- .../sql-reference/statements/alter/column.md | 103 +- .../statements/alter/column.md.hash | 2 +- .../sql-reference/statements/alter/comment.md | 24 +- .../statements/alter/comment.md.hash | 2 +- .../statements/alter/constraint.md | 11 +- .../statements/alter/constraint.md.hash | 2 +- .../statements/alter/database-comment.md | 7 +- .../statements/alter/database-comment.md.hash | 2 +- .../sql-reference/statements/alter/delete.md | 9 +- .../statements/alter/delete.md.hash | 2 +- .../sql-reference/statements/alter/index.md | 79 +- .../statements/alter/index.md.hash | 2 +- .../statements/alter/named-collection.md | 3 +- .../statements/alter/named-collection.md.hash | 2 +- .../statements/alter/order-by.md | 9 +- .../statements/alter/order-by.md.hash | 2 +- .../statements/alter/partition.md | 199 +- .../statements/alter/partition.md.hash | 2 +- .../statements/alter/projection.md | 54 +- .../statements/alter/projection.md.hash | 2 +- .../sql-reference/statements/alter/quota.md | 11 +- .../statements/alter/quota.md.hash | 2 +- .../sql-reference/statements/alter/role.md | 3 +- .../statements/alter/role.md.hash | 2 +- .../statements/alter/row-policy.md | 1 + .../statements/alter/row-policy.md.hash | 2 +- .../statements/alter/sample-by.md | 7 +- .../statements/alter/sample-by.md.hash | 2 +- .../sql-reference/statements/alter/setting.md | 5 +- .../statements/alter/setting.md.hash | 2 +- .../statements/alter/settings-profile.md | 7 +- .../statements/alter/settings-profile.md.hash | 2 +- .../statements/alter/skipping-index.md | 21 +- .../statements/alter/skipping-index.md.hash | 2 +- .../statements/alter/statistics.md | 21 +- .../statements/alter/statistics.md.hash | 2 +- .../sql-reference/statements/alter/ttl.md | 25 +- .../statements/alter/ttl.md.hash | 2 +- .../sql-reference/statements/alter/update.md | 8 +- .../statements/alter/update.md.hash | 2 +- .../sql-reference/statements/alter/user.md | 34 +- .../statements/alter/user.md.hash | 2 +- .../sql-reference/statements/alter/view.md | 17 +- .../statements/alter/view.md.hash | 2 +- .../sql-reference/statements/attach.md | 31 +- .../sql-reference/statements/attach.md.hash | 2 +- .../sql-reference/statements/check-grant.md | 11 +- .../statements/check-grant.md.hash | 2 +- .../sql-reference/statements/check-table.md | 57 +- .../statements/check-table.md.hash | 2 +- .../statements/create/database.md | 31 +- .../statements/create/database.md.hash | 2 +- .../statements/create/dictionary.md | 19 +- .../statements/create/dictionary.md.hash | 2 +- .../statements/create/function.md | 17 +- .../statements/create/function.md.hash | 2 +- .../sql-reference/statements/create/index.md | 1 + .../statements/create/index.md.hash | 2 +- .../statements/create/named-collection.md | 5 +- .../create/named-collection.md.hash | 2 +- .../sql-reference/statements/create/quota.md | 17 +- .../statements/create/quota.md.hash | 2 +- .../sql-reference/statements/create/role.md | 15 +- .../statements/create/role.md.hash | 2 +- .../statements/create/row-policy.md | 39 +- .../statements/create/row-policy.md.hash | 2 +- .../statements/create/settings-profile.md | 7 +- .../create/settings-profile.md.hash | 2 +- .../sql-reference/statements/create/table.md | 220 +- .../statements/create/table.md.hash | 2 +- .../sql-reference/statements/create/user.md | 105 +- .../statements/create/user.md.hash | 2 +- .../sql-reference/statements/create/view.md | 363 +- .../statements/create/view.md.hash | 2 +- .../sql-reference/statements/delete.md | 61 +- .../sql-reference/statements/delete.md.hash | 2 +- .../statements/describe-table.md | 21 +- .../statements/describe-table.md.hash | 2 +- .../sql-reference/statements/detach.md | 23 +- .../sql-reference/statements/detach.md.hash | 2 +- .../current/sql-reference/statements/drop.md | 20 +- .../sql-reference/statements/drop.md.hash | 2 +- .../sql-reference/statements/exchange.md | 6 +- .../sql-reference/statements/exchange.md.hash | 2 +- .../sql-reference/statements/exists.md | 3 +- .../sql-reference/statements/exists.md.hash | 2 +- .../sql-reference/statements/explain.md | 176 +- .../sql-reference/statements/explain.md.hash | 2 +- .../current/sql-reference/statements/grant.md | 839 +-- .../sql-reference/statements/grant.md.hash | 2 +- .../current/sql-reference/statements/index.md | 3 +- .../sql-reference/statements/index.md.hash | 2 +- .../sql-reference/statements/insert-into.md | 81 +- .../statements/insert-into.md.hash | 2 +- .../current/sql-reference/statements/kill.md | 57 +- .../sql-reference/statements/kill.md.hash | 2 +- .../current/sql-reference/statements/move.md | 13 +- .../sql-reference/statements/move.md.hash | 2 +- .../sql-reference/statements/optimize.md | 39 +- .../sql-reference/statements/optimize.md.hash | 2 +- .../sql-reference/statements/parallel_with.md | 13 +- .../statements/parallel_with.md.hash | 2 +- .../sql-reference/statements/rename.md | 13 +- .../sql-reference/statements/rename.md.hash | 2 +- .../sql-reference/statements/revoke.md | 11 +- .../sql-reference/statements/revoke.md.hash | 2 +- .../sql-reference/statements/select/all.md | 9 +- .../statements/select/all.md.hash | 2 +- .../statements/select/apply_modifier.md | 35 + .../statements/select/apply_modifier.md.hash | 1 + .../statements/select/array-join.md | 49 +- .../statements/select/array-join.md.hash | 2 +- .../statements/select/distinct.md | 30 +- .../statements/select/distinct.md.hash | 2 +- .../sql-reference/statements/select/except.md | 78 +- .../statements/select/except.md.hash | 2 +- .../statements/select/except_modifier.md | 34 + .../statements/select/except_modifier.md.hash | 1 + .../sql-reference/statements/select/format.md | 11 +- .../statements/select/format.md.hash | 2 +- .../sql-reference/statements/select/from.md | 37 +- .../statements/select/from.md.hash | 2 +- .../statements/select/group-by.md | 159 +- .../statements/select/group-by.md.hash | 2 +- .../sql-reference/statements/select/having.md | 5 +- .../statements/select/having.md.hash | 2 +- .../sql-reference/statements/select/index.md | 143 +- .../statements/select/index.md.hash | 2 +- .../statements/select/intersect.md | 22 +- .../statements/select/intersect.md.hash | 2 +- .../statements/select/into-outfile.md | 21 +- .../statements/select/into-outfile.md.hash | 2 +- .../sql-reference/statements/select/join.md | 224 +- .../statements/select/join.md.hash | 2 +- .../statements/select/limit-by.md | 14 +- .../statements/select/limit-by.md.hash | 2 +- .../sql-reference/statements/select/limit.md | 17 +- .../statements/select/limit.md.hash | 2 +- .../sql-reference/statements/select/offset.md | 17 +- .../statements/select/offset.md.hash | 2 +- .../statements/select/order-by.md | 109 +- .../statements/select/order-by.md.hash | 2 +- .../statements/select/prewhere.md | 23 +- .../statements/select/prewhere.md.hash | 2 +- .../statements/select/qualify.md | 7 +- .../statements/select/qualify.md.hash | 2 +- .../statements/select/replace_modifier.md | 38 + .../select/replace_modifier.md.hash | 1 + .../sql-reference/statements/select/sample.md | 61 +- .../statements/select/sample.md.hash | 2 +- .../sql-reference/statements/select/union.md | 21 +- .../statements/select/union.md.hash | 2 +- .../sql-reference/statements/select/where.md | 19 +- .../statements/select/where.md.hash | 2 +- .../sql-reference/statements/select/with.md | 150 +- .../statements/select/with.md.hash | 2 +- .../sql-reference/statements/set-role.md | 7 +- .../sql-reference/statements/set-role.md.hash | 2 +- .../current/sql-reference/statements/set.md | 13 +- .../sql-reference/statements/set.md.hash | 2 +- .../current/sql-reference/statements/show.md | 221 +- .../sql-reference/statements/show.md.hash | 2 +- .../sql-reference/statements/system.md | 362 +- .../sql-reference/statements/system.md.hash | 2 +- .../sql-reference/statements/truncate.md | 50 +- .../sql-reference/statements/truncate.md.hash | 2 +- .../sql-reference/statements/undrop.md | 7 +- .../sql-reference/statements/undrop.md.hash | 2 +- .../sql-reference/statements/update.md | 126 + .../sql-reference/statements/update.md.hash | 1 + .../current/sql-reference/statements/use.md | 9 +- .../sql-reference/statements/use.md.hash | 2 +- .../current/sql-reference/statements/watch.md | 5 +- .../sql-reference/statements/watch.md.hash | 2 +- .../current/sql-reference/syntax.md | 328 +- .../current/sql-reference/syntax.md.hash | 2 +- .../table-functions/arrowflight.md | 55 + .../table-functions/arrowflight.md.hash | 1 + .../table-functions/azureBlobStorage.md | 87 +- .../table-functions/azureBlobStorage.md.hash | 2 +- .../azureBlobStorageCluster.md | 37 +- .../azureBlobStorageCluster.md.hash | 2 +- .../sql-reference/table-functions/cluster.md | 33 +- .../table-functions/cluster.md.hash | 2 +- .../table-functions/deltalake.md | 20 +- .../table-functions/deltalake.md.hash | 2 +- .../table-functions/deltalakeCluster.md | 25 +- .../table-functions/deltalakeCluster.md.hash | 2 +- .../table-functions/dictionary.md | 5 +- .../table-functions/dictionary.md.hash | 2 +- .../table-functions/executable.md | 49 +- .../table-functions/executable.md.hash | 2 +- .../sql-reference/table-functions/file.md | 87 +- .../table-functions/file.md.hash | 2 +- .../table-functions/fileCluster.md | 31 +- .../table-functions/fileCluster.md.hash | 2 +- .../sql-reference/table-functions/format.md | 35 +- .../table-functions/format.md.hash | 2 +- .../sql-reference/table-functions/fuzzJSON.md | 39 +- .../table-functions/fuzzJSON.md.hash | 2 +- .../table-functions/fuzzQuery.md | 13 +- .../table-functions/fuzzQuery.md.hash | 2 +- .../sql-reference/table-functions/gcs.md | 81 +- .../sql-reference/table-functions/gcs.md.hash | 2 +- .../sql-reference/table-functions/generate.md | 33 +- .../table-functions/generate.md.hash | 2 +- .../table-functions/generateSeries.md | 10 - .../table-functions/generateSeries.md.hash | 1 - .../table-functions/generate_series.md | 9 +- .../table-functions/generate_series.md.hash | 2 +- .../sql-reference/table-functions/hdfs.md | 51 +- .../table-functions/hdfs.md.hash | 2 +- .../table-functions/hdfsCluster.md | 25 +- .../table-functions/hdfsCluster.md.hash | 2 +- .../sql-reference/table-functions/hudi.md | 35 +- .../table-functions/hudi.md.hash | 2 +- .../table-functions/hudiCluster.md | 31 +- .../table-functions/hudiCluster.md.hash | 2 +- .../sql-reference/table-functions/iceberg.md | 287 +- .../table-functions/iceberg.md.hash | 2 +- .../table-functions/icebergCluster.md | 21 +- .../table-functions/icebergCluster.md.hash | 2 +- .../sql-reference/table-functions/index.md | 67 +- .../table-functions/index.md.hash | 2 +- .../sql-reference/table-functions/input.md | 18 +- .../table-functions/input.md.hash | 2 +- .../sql-reference/table-functions/jdbc.md | 19 +- .../table-functions/jdbc.md.hash | 2 +- .../sql-reference/table-functions/loop.md | 25 +- .../table-functions/loop.md.hash | 2 +- .../sql-reference/table-functions/merge.md | 7 +- .../table-functions/merge.md.hash | 2 +- .../table-functions/mergeTreeIndex.md | 24 +- .../table-functions/mergeTreeIndex.md.hash | 2 +- .../table-functions/mergeTreeProjection.md | 15 +- .../mergeTreeProjection.md.hash | 2 +- .../sql-reference/table-functions/mongodb.md | 35 +- .../table-functions/mongodb.md.hash | 2 +- .../sql-reference/table-functions/mysql.md | 47 +- .../table-functions/mysql.md.hash | 2 +- .../sql-reference/table-functions/null.md | 9 +- .../table-functions/null.md.hash | 2 +- .../sql-reference/table-functions/numbers.md | 15 +- .../table-functions/numbers.md.hash | 2 +- .../sql-reference/table-functions/odbc.md | 29 +- .../table-functions/odbc.md.hash | 2 +- .../table-functions/postgresql.md | 47 +- .../table-functions/postgresql.md.hash | 2 +- .../table-functions/prometheusQuery.md | 45 + .../table-functions/prometheusQuery.md.hash | 1 + .../table-functions/prometheusQueryRange.md | 47 + .../prometheusQueryRange.md.hash | 1 + .../sql-reference/table-functions/redis.md | 31 +- .../table-functions/redis.md.hash | 2 +- .../sql-reference/table-functions/remote.md | 76 +- .../table-functions/remote.md.hash | 2 +- .../sql-reference/table-functions/s3.md | 160 +- .../sql-reference/table-functions/s3.md.hash | 2 +- .../table-functions/s3Cluster.md | 60 +- .../table-functions/s3Cluster.md.hash | 2 +- .../sql-reference/table-functions/sqlite.md | 5 +- .../table-functions/sqlite.md.hash | 2 +- .../table-functions/timeSeriesData.md | 9 +- .../table-functions/timeSeriesData.md.hash | 2 +- .../table-functions/timeSeriesMetrics.md | 7 +- .../table-functions/timeSeriesMetrics.md.hash | 2 +- .../table-functions/timeSeriesSelector.md | 44 + .../timeSeriesSelector.md.hash | 1 + .../table-functions/timeSeriesTags.md | 7 +- .../table-functions/timeSeriesTags.md.hash | 2 +- .../sql-reference/table-functions/url.md | 45 +- .../sql-reference/table-functions/url.md.hash | 2 +- .../table-functions/urlCluster.md | 33 +- .../table-functions/urlCluster.md.hash | 2 +- .../sql-reference/table-functions/values.md | 35 +- .../table-functions/values.md.hash | 2 +- .../sql-reference/table-functions/view.md | 19 +- .../table-functions/view.md.hash | 2 +- .../sql-reference/table-functions/ytsaurus.md | 45 + .../table-functions/ytsaurus.md.hash | 1 + .../sql-reference/table-functions/zeros.md | 13 +- .../table-functions/zeros.md.hash | 2 +- .../current/sql-reference/transactions.md | 105 +- .../sql-reference/transactions.md.hash | 2 +- .../window-functions/dense_rank.md | 11 +- .../window-functions/dense_rank.md.hash | 2 +- .../window-functions/first_value.md | 11 +- .../window-functions/first_value.md.hash | 2 +- .../sql-reference/window-functions/index.md | 108 +- .../window-functions/index.md.hash | 2 +- .../sql-reference/window-functions/lag.md | 80 + .../window-functions/lag.md.hash | 1 + .../window-functions/lagInFrame.md | 21 +- .../window-functions/lagInFrame.md.hash | 2 +- .../window-functions/last_value.md | 17 +- .../window-functions/last_value.md.hash | 2 +- .../sql-reference/window-functions/lead.md | 73 + .../window-functions/lead.md.hash | 1 + .../window-functions/leadInFrame.md | 19 +- .../window-functions/leadInFrame.md.hash | 2 +- .../window-functions/nth_value.md | 11 +- .../window-functions/nth_value.md.hash | 2 +- .../window-functions/percent_rank.md | 16 +- .../window-functions/percent_rank.md.hash | 2 +- .../sql-reference/window-functions/rank.md | 13 +- .../window-functions/rank.md.hash | 2 +- .../window-functions/row_number.md | 9 +- .../window-functions/row_number.md.hash | 2 +- .../current/starter-guides/index.md | 11 +- .../current/starter-guides/index.md.hash | 2 +- .../tips-and-tricks/community-wisdom.md | 42 + .../tips-and-tricks/community-wisdom.md.hash | 1 + .../tips-and-tricks/cost-optimization.md | 94 + .../tips-and-tricks/cost-optimization.md.hash | 1 + .../tips-and-tricks/debugging-insights.md | 175 + .../debugging-insights.md.hash | 1 + .../tips-and-tricks/materialized-views.md | 69 + .../materialized-views.md.hash | 1 + .../performance-optimization.md | 139 + .../performance-optimization.md.hash | 1 + .../tips-and-tricks/success-stories.md | 62 + .../tips-and-tricks/success-stories.md.hash | 1 + .../current/tips-and-tricks/too-many-parts.md | 76 + .../tips-and-tricks/too-many-parts.md.hash | 1 + .../static-files-disk-uploader.md | 31 +- .../static-files-disk-uploader.md.hash | 2 +- .../current/troubleshooting/index.md | 151 + .../current/troubleshooting/index.md.hash | 1 + .../current/tutorial.md | 87 +- .../current/tutorial.md.hash | 2 +- .../current/use-cases/AI_ML/AIChat/index.md | 118 + .../use-cases/AI_ML/AIChat/index.md.hash | 1 + .../use-cases/AI_ML/MCP/01_remote_mcp.md | 99 + .../use-cases/AI_ML/MCP/01_remote_mcp.md.hash | 1 + .../use-cases/AI_ML/MCP/02_claude-desktop.md | 124 + .../AI_ML/MCP/02_claude-desktop.md.hash | 1 + .../use-cases/AI_ML/MCP/03_librechat.md | 227 + .../use-cases/AI_ML/MCP/03_librechat.md.hash | 1 + .../use-cases/AI_ML/MCP/04_anythingllm.md | 127 + .../AI_ML/MCP/04_anythingllm.md.hash | 1 + .../use-cases/AI_ML/MCP/05_open-webui.md | 111 + .../use-cases/AI_ML/MCP/05_open-webui.md.hash | 1 + .../current/use-cases/AI_ML/MCP/06_ollama.md | 226 + .../use-cases/AI_ML/MCP/06_ollama.md.hash | 1 + .../current/use-cases/AI_ML/MCP/07_janai.md | 107 + .../use-cases/AI_ML/MCP/07_janai.md.hash | 1 + .../MCP/ai_agent_libraries/_category_.json | 10 + .../AI_ML/MCP/ai_agent_libraries/agno.md | 142 + .../AI_ML/MCP/ai_agent_libraries/agno.md.hash | 1 + .../AI_ML/MCP/ai_agent_libraries/chainlit.md | 70 + .../MCP/ai_agent_libraries/chainlit.md.hash | 1 + .../MCP/ai_agent_libraries/copilotkit.md | 89 + .../MCP/ai_agent_libraries/copilotkit.md.hash | 1 + .../AI_ML/MCP/ai_agent_libraries/dspy.md | 241 + .../AI_ML/MCP/ai_agent_libraries/dspy.md.hash | 1 + .../AI_ML/MCP/ai_agent_libraries/index.md | 38 + .../MCP/ai_agent_libraries/index.md.hash | 1 + .../AI_ML/MCP/ai_agent_libraries/langchain.md | 192 + .../MCP/ai_agent_libraries/langchain.md.hash | 1 + .../MCP/ai_agent_libraries/llamaindex.md | 161 + .../MCP/ai_agent_libraries/llamaindex.md.hash | 1 + .../MCP/ai_agent_libraries/openai-agents.md | 191 + .../ai_agent_libraries/openai-agents.md.hash | 1 + .../MCP/ai_agent_libraries/pydantic-ai.md | 131 + .../ai_agent_libraries/pydantic-ai.md.hash | 1 + .../AI_ML/MCP/ai_agent_libraries/slackbot.md | 109 + .../MCP/ai_agent_libraries/slackbot.md.hash | 1 + .../AI_ML/MCP/ai_agent_libraries/streamlit.md | 225 + .../MCP/ai_agent_libraries/streamlit.md.hash | 1 + .../current/use-cases/AI_ML/MCP/index.md | 69 + .../current/use-cases/AI_ML/MCP/index.md.hash | 1 + .../AI_ML/ai-powered-sql-generation.md | 193 + .../AI_ML/ai-powered-sql-generation.md.hash | 1 + .../current/use-cases/AI_ML/index.md | 25 + .../current/use-cases/AI_ML/index.md.hash | 1 + .../use-cases/AI_ML/jupyter-notebook.md | 336 + .../use-cases/AI_ML/jupyter-notebook.md.hash | 1 + .../use-cases/data_lake/glue_catalog.md | 23 +- .../use-cases/data_lake/glue_catalog.md.hash | 2 +- .../current/use-cases/data_lake/index.md | 13 +- .../current/use-cases/data_lake/index.md.hash | 2 +- .../use-cases/data_lake/lakekeeper_catalog.md | 370 + .../data_lake/lakekeeper_catalog.md.hash | 1 + .../use-cases/data_lake/nessie_catalog.md | 290 + .../data_lake/nessie_catalog.md.hash | 1 + .../use-cases/data_lake/rest_catalog.md | 232 + .../use-cases/data_lake/rest_catalog.md.hash | 1 + .../use-cases/data_lake/unity_catalog.md | 44 +- .../use-cases/data_lake/unity_catalog.md.hash | 2 +- .../current/use-cases/index.md | 16 +- .../current/use-cases/index.md.hash | 2 +- .../build-your-own/demo-application.md | 5 +- .../build-your-own/demo-application.md.hash | 2 +- .../observability/build-your-own/grafana.md | 86 +- .../build-your-own/grafana.md.hash | 2 +- .../observability/build-your-own/index.md | 15 +- .../build-your-own/index.md.hash | 2 +- .../integrating-opentelemetry.md | 291 +- .../integrating-opentelemetry.md.hash | 2 +- .../build-your-own/introduction.md | 83 +- .../build-your-own/introduction.md.hash | 2 +- .../build-your-own/managing-data.md | 105 +- .../build-your-own/managing-data.md.hash | 2 +- .../build-your-own/schema-design.md | 427 +- .../build-your-own/schema-design.md.hash | 2 +- .../observability/clickstack/alerts.md | 15 +- .../observability/clickstack/alerts.md.hash | 2 +- .../observability/clickstack/architecture.md | 49 +- .../clickstack/architecture.md.hash | 2 +- .../observability/clickstack/config.md | 442 +- .../observability/clickstack/config.md.hash | 2 +- .../observability/clickstack/dashboards.md | 205 + .../clickstack/dashboards.md.hash | 1 + .../deployment/_snippets/_json_support.md | 14 + .../_snippets/_json_support.md.hash | 1 + .../_snippets/otel-cloud-config.yaml | 147 + .../clickstack/deployment/all-in-one.md | 60 +- .../clickstack/deployment/all-in-one.md.hash | 2 +- .../clickstack/deployment/docker-compose.md | 87 +- .../deployment/docker-compose.md.hash | 2 +- .../clickstack/deployment/helm.md | 226 +- .../clickstack/deployment/helm.md.hash | 2 +- .../deployment/hyperdx-clickhouse-cloud.md | 336 + .../hyperdx-clickhouse-cloud.md.hash | 1 + .../clickstack/deployment/hyperdx-only.md | 42 +- .../deployment/hyperdx-only.md.hash | 2 +- .../clickstack/deployment/index.md | 22 +- .../clickstack/deployment/index.md.hash | 2 +- .../clickstack/deployment/local-mode-only.md | 35 +- .../deployment/local-mode-only.md.hash | 2 +- .../observability/clickstack/event_deltas.md | 67 + .../clickstack/event_deltas.md.hash | 1 + .../clickstack/event_patterns.md | 39 + .../clickstack/event_patterns.md.hash | 1 + .../example-datasets/_snippets/_demo.md | 15 + .../example-datasets/_snippets/_demo.md.hash | 1 + .../_snippets/k8s_daemonset.yaml | 100 + .../_snippets/k8s_deployment.yaml | 58 + .../clickstack/example-datasets/index.md | 5 +- .../clickstack/example-datasets/index.md.hash | 2 +- .../clickstack/example-datasets/kubernetes.md | 540 ++ .../example-datasets/kubernetes.md.hash | 1 + .../clickstack/example-datasets/local-data.md | 92 +- .../example-datasets/local-data.md.hash | 2 +- .../example-datasets/remote-demo-data.md | 213 +- .../example-datasets/remote-demo-data.md.hash | 2 +- .../example-datasets/sample-data.md | 77 +- .../example-datasets/sample-data.md.hash | 2 +- .../clickstack/getting-started.md | 93 +- .../clickstack/getting-started.md.hash | 2 +- .../observability/clickstack/index.md | 19 +- .../observability/clickstack/index.md.hash | 2 +- .../clickstack/ingesting-data/collector.md | 286 +- .../ingesting-data/collector.md.hash | 2 +- .../clickstack/ingesting-data/index.md | 17 +- .../clickstack/ingesting-data/index.md.hash | 2 +- .../clickstack/ingesting-data/kubernetes.md | 121 +- .../ingesting-data/kubernetes.md.hash | 2 +- .../ingesting-data/opentelemetry.md | 35 +- .../ingesting-data/opentelemetry.md.hash | 2 +- .../clickstack/ingesting-data/overview.md | 17 +- .../ingesting-data/overview.md.hash | 2 +- .../clickstack/ingesting-data/schemas.md | 65 +- .../clickstack/ingesting-data/schemas.md.hash | 2 +- .../ingesting-data/sdks/aws-lambda.md | 260 + .../ingesting-data/sdks/aws-lambda.md.hash | 1 + .../clickstack/ingesting-data/sdks/browser.md | 64 +- .../ingesting-data/sdks/browser.md.hash | 2 +- .../clickstack/ingesting-data/sdks/deno.md | 11 +- .../ingesting-data/sdks/deno.md.hash | 2 +- .../clickstack/ingesting-data/sdks/elixir.md | 19 +- .../ingesting-data/sdks/elixir.md.hash | 2 +- .../clickstack/ingesting-data/sdks/golang.md | 41 +- .../ingesting-data/sdks/golang.md.hash | 2 +- .../clickstack/ingesting-data/sdks/index.md | 70 +- .../ingesting-data/sdks/index.md.hash | 2 +- .../clickstack/ingesting-data/sdks/java.md | 27 +- .../ingesting-data/sdks/java.md.hash | 2 +- .../clickstack/ingesting-data/sdks/nestjs.md | 35 +- .../ingesting-data/sdks/nestjs.md.hash | 2 +- .../clickstack/ingesting-data/sdks/nextjs.md | 31 +- .../ingesting-data/sdks/nextjs.md.hash | 2 +- .../clickstack/ingesting-data/sdks/nodejs.md | 83 +- .../ingesting-data/sdks/nodejs.md.hash | 2 +- .../clickstack/ingesting-data/sdks/python.md | 43 +- .../ingesting-data/sdks/python.md.hash | 2 +- .../ingesting-data/sdks/react-native.md | 29 +- .../ingesting-data/sdks/react-native.md.hash | 2 +- .../clickstack/ingesting-data/sdks/ruby.md | 25 +- .../ingesting-data/sdks/ruby.md.hash | 2 +- .../clickstack/migration/elastic/concepts.md | 238 + .../migration/elastic/concepts.md.hash | 1 + .../clickstack/migration/elastic/index.md | 23 + .../migration/elastic/index.md.hash | 1 + .../clickstack/migration/elastic/intro.md | 33 + .../migration/elastic/intro.md.hash | 1 + .../migration/elastic/migrating-agents.md | 421 ++ .../elastic/migrating-agents.md.hash | 1 + .../migration/elastic/migrating-data.md | 655 ++ .../migration/elastic/migrating-data.md.hash | 1 + .../migration/elastic/migrating-sdks.md | 54 + .../migration/elastic/migrating-sdks.md.hash | 1 + .../clickstack/migration/elastic/search.md | 71 + .../migration/elastic/search.md.hash | 1 + .../clickstack/migration/elastic/types.md | 75 + .../migration/elastic/types.md.hash | 1 + .../clickstack/migration/index.md | 15 + .../clickstack/migration/index.md.hash | 1 + .../observability/clickstack/overview.md | 77 +- .../observability/clickstack/overview.md.hash | 2 +- .../observability/clickstack/production.md | 133 +- .../clickstack/production.md.hash | 2 +- .../observability/clickstack/search.md | 29 +- .../observability/clickstack/search.md.hash | 2 +- .../use-cases/observability/clickstack/ttl.md | 115 + .../observability/clickstack/ttl.md.hash | 1 + .../observability/demo-application.md.hash | 1 - .../use-cases/observability/grafana.md.hash | 1 - .../current/use-cases/observability/index.md | 52 +- .../use-cases/observability/index.md.hash | 2 +- .../integrating-opentelemetry.md.hash | 1 - .../observability/introduction.md.hash | 1 - .../observability/managing-data.md.hash | 1 - .../observability/schema-design.md.hash | 1 - ...ta-types.md => 01_date-time-data-types.md} | 35 +- .../01_date-time-data-types.md.hash | 1 + ...c-operations.md => 02_basic-operations.md} | 44 +- .../time-series/02_basic-operations.md.hash | 1 + ...-functions.md => 03_analysis-functions.md} | 51 +- .../time-series/03_analysis-functions.md.hash | 1 + ...efficiency.md => 04_storage-efficiency.md} | 36 +- .../time-series/04_storage-efficiency.md.hash | 1 + ...performance.md => 05_query-performance.md} | 45 +- .../time-series/05_query-performance.md.hash | 1 + .../06_materialized-view-rollup.mdx | 255 + .../06_materialized-view-rollup.mdx.hash | 1 + .../time-series/analysis-functions.md.hash | 1 - .../time-series/basic-operations.md.hash | 1 - .../time-series/date-time-data-types.md.hash | 1 - .../current/use-cases/time-series/index.md | 23 +- .../use-cases/time-series/index.md.hash | 2 +- .../time-series/query-performance.md.hash | 1 - .../time-series/storage-efficiency.md.hash | 1 - .../current/whats-new/changelog/2017.md | 1 + .../current/whats-new/changelog/2018.md | 1 + .../current/whats-new/changelog/2019.md | 1 + .../current/whats-new/changelog/2020.md | 53 +- .../current/whats-new/changelog/2021.md | 36 +- .../current/whats-new/changelog/2022.md | 16 +- .../current/whats-new/changelog/2023.md | 13 +- .../current/whats-new/changelog/2024.md | 12 +- .../current/whats-new/changelog/cloud.md | 1 + .../current/whats-new/changelog/index.md | 1883 +++++ .../current/whats-new/roadmap.md | 5 +- .../current/whats-new/security-changelog.md | 7 +- 3211 files changed, 104926 insertions(+), 63714 deletions(-) delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_tabs.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_tabs.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/architecture/cluster-deployment.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/architecture/cluster-deployment.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/best-practices/_snippets/_table_of_contents.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/best-practices/_snippets/_table_of_contents.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/best-practices/use_materialized_views.translate_override create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/chdb/api/python.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/chdb/api/python.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud-index.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud-index.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/_snippets/_clickpipes_faq.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/_snippets/_clickpipes_faq.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/_snippets/_security_table_of_contents.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/_snippets/_security_table_of_contents.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/bestpractices/index.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/bestpractices/index.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/bestpractices/multitenancy.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/bestpractices/usagelimits.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/bestpractices/usagelimits.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/01_cloud_tiers.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/01_cloud_tiers.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/02_integrations.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/02_integrations.md.hash rename i18n/zh/docusaurus-plugin-content-docs/current/cloud/{get-started/sql-console.md => features/03_sql_console_features/01_sql-console.md} (50%) create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/03_sql_console_features/01_sql-console.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/03_sql_console_features/02_query-insights.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/03_sql_console_features/02_query-insights.md.hash rename i18n/zh/docusaurus-plugin-content-docs/current/cloud/{get-started/query-endpoints.md => features/03_sql_console_features/03_query-endpoints.md} (75%) create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/03_sql_console_features/03_query-endpoints.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/03_sql_console_features/04_dashboards.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/03_sql_console_features/04_dashboards.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/03_sql_console_features/_category_.json create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/03_sql_console_features/hyperdx.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/03_sql_console_features/hyperdx.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/04_infrastructure/_category_.json create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/04_infrastructure/automatic_scaling.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/04_infrastructure/automatic_scaling.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/04_infrastructure/byoc.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/04_infrastructure/byoc.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/04_infrastructure/replica-aware-routing.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/04_infrastructure/replica-aware-routing.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/04_infrastructure/shared-catalog.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/04_infrastructure/shared-catalog.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/04_infrastructure/shared-merge-tree.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/04_infrastructure/shared-merge-tree.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/04_infrastructure/warehouses.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/04_infrastructure/warehouses.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/05_admin_features/_category_.json create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/05_admin_features/api/api-overview.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/05_admin_features/api/api-overview.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/05_admin_features/api/index.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/05_admin_features/api/index.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/05_admin_features/api/openapi.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/05_admin_features/api/openapi.md.hash rename i18n/zh/docusaurus-plugin-content-docs/current/cloud/{manage => features/05_admin_features/api}/postman.md (52%) create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/05_admin_features/api/postman.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/05_admin_features/upgrades.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/05_admin_features/upgrades.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/01_shared-responsibility-model.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/01_shared-responsibility-model.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/02_cloud-access-management/_category_.json create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/02_cloud-access-management/cloud-access-management.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/02_cloud-access-management/cloud-access-management.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/02_cloud-access-management/cloud-authentication.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/02_cloud-access-management/cloud-authentication.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/02_cloud-access-management/index.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/02_cloud-access-management/index.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/03_connectivity/01_private-link-overview.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/03_connectivity/01_private-link-overview.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/03_connectivity/_category_.json create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/03_connectivity/index.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/03_connectivity/index.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/_category_.json create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/cmek.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/cmek.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/07_monitoring/_category_.json create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/07_monitoring/advanced_dashboard.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/07_monitoring/advanced_dashboard.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/07_monitoring/notifications.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/07_monitoring/notifications.md.hash rename i18n/zh/docusaurus-plugin-content-docs/current/{integrations => cloud/features/07_monitoring}/prometheus.md (71%) create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/07_monitoring/prometheus.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/08_backups/configurable-backups.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/08_backups/configurable-backups.md.hash rename i18n/zh/docusaurus-plugin-content-docs/current/cloud/{manage/backups => features/08_backups}/export-backups-to-own-cloud-account.md (53%) create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/08_backups/export-backups-to-own-cloud-account.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/08_backups/index.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/08_backups/index.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/08_backups/overview.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/08_backups/overview.md.hash rename i18n/zh/docusaurus-plugin-content-docs/current/cloud/{support.md => features/09_support.md} (68%) create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/09_support.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/_category_.json delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/get-started/cloud-quick-start.mdx delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/get-started/cloud-quick-start.mdx.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/get-started/index.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/get-started/index.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/get-started/query-endpoints.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/get-started/query-insights.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/get-started/query-insights.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/get-started/sql-console.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/SQL_console/_category_.json create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/SQL_console/configure_org_and_service_role_assignments.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/SQL_console/configure_org_and_service_role_assignments.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/SQL_console/configure_sql_console_role_assignments.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/SQL_console/configure_sql_console_role_assignments.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/SQL_console/connection_details.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/SQL_console/connection_details.md.hash rename i18n/zh/docusaurus-plugin-content-docs/current/cloud/{bestpractices => guides}/_category_.yml (83%) create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/best_practices/_category_.json create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/best_practices/index.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/best_practices/index.md.hash rename i18n/zh/docusaurus-plugin-content-docs/current/cloud/{bestpractices => guides/best_practices}/multitenancy.md (74%) create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/best_practices/multitenancy.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/best_practices/usagelimits.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/best_practices/usagelimits.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/cloud-compatibility.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/cloud-compatibility.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/_category_.json create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/cloud_access_management/_category_.json rename i18n/zh/docusaurus-plugin-content-docs/current/cloud/{security => guides/security/cloud_access_management}/common-access-management-queries.md (50%) create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/cloud_access_management/common-access-management-queries.md.hash rename i18n/zh/docusaurus-plugin-content-docs/current/cloud/{security => guides/security/cloud_access_management}/inviting-new-users.md (59%) create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/cloud_access_management/inviting-new-users.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/cloud_access_management/saml-sso-setup.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/cloud_access_management/saml-sso-setup.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/connectivity/_category_.json create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/connectivity/accessing-s3-data-securely.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/connectivity/accessing-s3-data-securely.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/connectivity/cloud-endpoints-api.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/connectivity/cloud-endpoints-api.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/connectivity/private_networking/02_aws-privatelink.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/connectivity/private_networking/02_aws-privatelink.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/connectivity/private_networking/03_gcp-private-service-connect.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/connectivity/private_networking/03_gcp-private-service-connect.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/connectivity/private_networking/04_azure-privatelink.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/connectivity/private_networking/04_azure-privatelink.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/connectivity/private_networking/_category_.json create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/connectivity/setting-ip-filters.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/connectivity/setting-ip-filters.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/data_masking.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/data_masking.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/_category_.yml delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/account-close.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/account-close.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/api/api-overview.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/api/api-overview.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/api/index.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/api/index.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/backups/configurable-backups.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/backups/configurable-backups.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/backups/export-backups-to-own-cloud-account.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/backups/index.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/backups/index.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/backups/overview.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/backups/overview.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/index.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/index.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/marketplace/aws-marketplace-committed.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/marketplace/aws-marketplace-committed.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/marketplace/aws-marketplace-payg.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/marketplace/azure-marketplace-committed.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/marketplace/azure-marketplace-payg.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/marketplace/gcp-marketplace-committed.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/marketplace/gcp-marketplace-payg.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/marketplace/index.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/marketplace/index.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/marketplace/overview.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/marketplace/overview.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/payment-thresholds.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/payment-thresholds.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/cloud-tiers.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/cloud-tiers.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/dashboards.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/dashboards.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/index.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/index.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/integrations.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/integrations.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/_snippets/_clickpipes_faq.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/_snippets/_clickpipes_faq.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/backup.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/backup.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/billing.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/billing.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/dimensions.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/dimensions.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/index.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/index.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/new_tiers.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/new_tiers.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/plan_migrations.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/plan_migrations.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/scaling.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/scaling.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/summary.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/summary.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/network-data-transfer.mdx delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/network-data-transfer.mdx.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/notifications.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/notifications.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/openapi.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/openapi.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/postman.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/replica-aware-routing.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/replica-aware-routing.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/scaling.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/scaling.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/service-uptime.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/service-uptime.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/settings.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/troubleshooting-billing-issues.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/troubleshooting-billing-issues.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/upgrades.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/upgrades.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/01_discover/01_what_is.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/01_discover/01_what_is.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/01_discover/02_use_cases/00_overview.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/01_discover/02_use_cases/00_overview.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/01_discover/02_use_cases/01_real-time-analytics.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/01_discover/02_use_cases/01_real-time-analytics.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/01_discover/02_use_cases/02_observability.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/01_discover/02_use_cases/02_observability.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/01_discover/02_use_cases/03_data_warehousing.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/01_discover/02_use_cases/03_data_warehousing.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/01_discover/02_use_cases/04_machine_learning_and_genAI/01_machine_learning.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/01_discover/02_use_cases/04_machine_learning_and_genAI/01_machine_learning.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/01_discover/02_use_cases/04_machine_learning_and_genAI/02_agent_facing_analytics.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/01_discover/02_use_cases/04_machine_learning_and_genAI/02_agent_facing_analytics.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/01_discover/02_use_cases/04_machine_learning_and_genAI/_category_.json create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/01_discover/02_use_cases/_category_.json create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/01_overview.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/01_overview.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/02_postgres/01_overview.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/02_postgres/01_overview.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/02_postgres/appendix.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/02_postgres/appendix.md.hash rename i18n/zh/docusaurus-plugin-content-docs/current/{migrations/postgres => cloud/onboard/02_migrate/01_migration_guides/02_postgres}/index.md (67%) create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/02_postgres/index.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/02_postgres/migration_guide/01_migration_guide_part1.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/02_postgres/migration_guide/01_migration_guide_part1.md.hash rename i18n/zh/docusaurus-plugin-content-docs/current/{migrations/postgres/rewriting-queries.md => cloud/onboard/02_migrate/01_migration_guides/02_postgres/migration_guide/02_migration_guide_part2.md} (77%) create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/02_postgres/migration_guide/02_migration_guide_part2.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/02_postgres/migration_guide/03_migration_guide_part3.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/02_postgres/migration_guide/03_migration_guide_part3.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/02_postgres/migration_guide/_category_.json create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/03_bigquery/01_overview.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/03_bigquery/01_overview.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/03_bigquery/02_migrating-to-clickhouse-cloud.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/03_bigquery/02_migrating-to-clickhouse-cloud.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/03_bigquery/03_loading-data.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/03_bigquery/03_loading-data.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/03_bigquery/index.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/03_bigquery/index.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/04_snowflake/01_overview.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/04_snowflake/01_overview.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/04_snowflake/02_migration_guide.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/04_snowflake/02_migration_guide.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/04_snowflake/03_sql_translation_reference.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/04_snowflake/03_sql_translation_reference.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/04_snowflake/_category_.json create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/05_elastic/01_overview.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/05_elastic/01_overview.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/05_elastic/_category_.json create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/06_redshift/01_overview.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/06_redshift/01_overview.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/06_redshift/02_migration_guide.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/06_redshift/02_migration_guide.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/06_redshift/03_sql_translation_reference.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/06_redshift/03_sql_translation_reference.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/06_redshift/_category_.json rename i18n/zh/docusaurus-plugin-content-docs/current/{integrations/migration/clickhouse-to-cloud.md => cloud/onboard/02_migrate/01_migration_guides/07_OSS_to_Cloud/01_clickhouse-to-cloud.md} (54%) create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/07_OSS_to_Cloud/01_clickhouse-to-cloud.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/07_OSS_to_Cloud/_category_.json create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/08_other_methods/01_clickhouse-local-etl.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/08_other_methods/01_clickhouse-local-etl.md.hash rename i18n/zh/docusaurus-plugin-content-docs/current/{integrations/migration/etl-tool-to-clickhouse.md => cloud/onboard/02_migrate/01_migration_guides/08_other_methods/02_etl-tool-to-clickhouse.md} (65%) create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/08_other_methods/02_etl-tool-to-clickhouse.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/08_other_methods/03_object-storage-to-clickhouse.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/08_other_methods/03_object-storage-to-clickhouse.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/08_other_methods/_category_.json create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/_category_.json create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/03_tune/_snippets/_monitoring_table_of_contents.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/03_tune/_snippets/_monitoring_table_of_contents.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/03_tune/resource_tour.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/03_tune/resource_tour.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/index.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/index.md.hash rename i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/{changelog.md => 01_changelog/01_changelog.md} (90%) rename i18n/zh/docusaurus-plugin-content-docs/current/cloud/{changelogs/fast-release-24-2.md => reference/01_changelog/02_release_notes/24_02.md} (99%) rename i18n/zh/docusaurus-plugin-content-docs/current/cloud/{changelogs/changelog-24-5.md => reference/01_changelog/02_release_notes/24_05.md} (98%) rename i18n/zh/docusaurus-plugin-content-docs/current/cloud/{changelogs/changelog-24-6.md => reference/01_changelog/02_release_notes/24_06.md} (99%) rename i18n/zh/docusaurus-plugin-content-docs/current/cloud/{changelogs/changelog-24-8.md => reference/01_changelog/02_release_notes/24_08.md} (97%) rename i18n/zh/docusaurus-plugin-content-docs/current/cloud/{changelogs/changelog-24-10.md => reference/01_changelog/02_release_notes/24_10.md} (98%) rename i18n/zh/docusaurus-plugin-content-docs/current/cloud/{changelogs/changelog-24-12.md => reference/01_changelog/02_release_notes/24_12.md} (99%) rename i18n/zh/docusaurus-plugin-content-docs/current/cloud/{changelogs/changelog-25_1-25_4.md => reference/01_changelog/02_release_notes/25_04.md} (99%) create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/01_changelog/02_release_notes/25_06.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/01_changelog/02_release_notes/_category_.json create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/01_changelog/02_release_notes/index.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/01_changelog/_category_.json create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/01_changelog/index.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/02_architecture.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/02_architecture.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/01_billing_overview.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/01_billing_overview.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/aws-marketplace-committed.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/aws-marketplace-committed.md.hash rename i18n/zh/docusaurus-plugin-content-docs/current/cloud/{manage/billing/marketplace => reference/03_billing/02_marketplace}/aws-marketplace-payg.md (50%) create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/aws-marketplace-payg.md.hash rename i18n/zh/docusaurus-plugin-content-docs/current/cloud/{manage/billing/marketplace => reference/03_billing/02_marketplace}/azure-marketplace-committed.md (56%) create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/azure-marketplace-committed.md.hash rename i18n/zh/docusaurus-plugin-content-docs/current/cloud/{manage/billing/marketplace => reference/03_billing/02_marketplace}/azure-marketplace-payg.md (60%) create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/azure-marketplace-payg.md.hash rename i18n/zh/docusaurus-plugin-content-docs/current/cloud/{manage/billing/marketplace => reference/03_billing/02_marketplace}/gcp-marketplace-committed.md (69%) create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/gcp-marketplace-committed.md.hash rename i18n/zh/docusaurus-plugin-content-docs/current/cloud/{manage/billing/marketplace => reference/03_billing/02_marketplace}/gcp-marketplace-payg.md (68%) create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/gcp-marketplace-payg.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/index.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/index.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/migrate-marketplace-payg-committed.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/migrate-marketplace-payg-committed.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/overview.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/overview.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/03_clickpipes/clickpipes_for_cdc.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/03_clickpipes/clickpipes_for_cdc.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/03_clickpipes/clickpipes_for_streaming_and_object_storage.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/03_clickpipes/clickpipes_for_streaming_and_object_storage.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/03_clickpipes/index.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/03_clickpipes/index.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/04_network-data-transfer.mdx create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/04_network-data-transfer.mdx.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/05_payment-thresholds.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/05_payment-thresholds.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/06_billing_compliance.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/06_billing_compliance.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/index.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/index.md.hash rename i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/{supported-regions.md => 05_supported-regions.md} (55%) create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/05_supported-regions.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/06_service-uptime.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/06_service-uptime.md.hash rename i18n/zh/docusaurus-plugin-content-docs/current/cloud/{manage/settings.md => reference/08_settings.md} (50%) create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/08_settings.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/09_security/_category_.json rename i18n/zh/docusaurus-plugin-content-docs/current/cloud/{security => reference/09_security}/audit-logging.md (52%) create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/09_security/audit-logging.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/09_security/privacy_and_compliance/_category_.json create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/09_security/privacy_and_compliance/compliance-overview.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/09_security/privacy_and_compliance/compliance-overview.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/09_security/privacy_and_compliance/index.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/09_security/privacy_and_compliance/index.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/09_security/privacy_and_compliance/personal-data-access.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/09_security/privacy_and_compliance/personal-data-access.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/10_account-close.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/10_account-close.md.hash rename i18n/zh/docusaurus-plugin-content-docs/current/cloud/{manage => reference}/_snippets/_network_transfer_rates.md (61%) rename i18n/zh/docusaurus-plugin-content-docs/current/cloud/{manage => reference}/_snippets/_network_transfer_rates.md.hash (100%) delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/architecture.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/architecture.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/byoc.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/byoc.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/changelogs-index.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/changelogs-index.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/cloud-compatibility.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/cloud-compatibility.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/release-notes-index.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/release-notes-index.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/shared-merge-tree.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/shared-merge-tree.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/supported-regions.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/warehouses.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/warehouses.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/_category_.yml delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/accessing-s3-data-securely.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/accessing-s3-data-securely.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/audit-logging.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/aws-privatelink.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/aws-privatelink.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/azure-privatelink.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/azure-privatelink.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/cloud-access-management/cloud-access-management.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/cloud-access-management/cloud-access-management.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/cloud-access-management/cloud-authentication.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/cloud-access-management/cloud-authentication.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/cloud-access-management/index.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/cloud-access-management/index.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/cloud-endpoints-api.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/cloud-endpoints-api.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/cmek.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/cmek.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/common-access-management-queries.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/compliance-overview.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/compliance-overview.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/connectivity-overview.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/connectivity-overview.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/gcp-private-service-connect.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/gcp-private-service-connect.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/index.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/index.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/inviting-new-users.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/personal-data-access.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/personal-data-access.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/privacy-compliance-overview.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/privacy-compliance-overview.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/private-link-overview.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/private-link-overview.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/saml-sso-setup.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/saml-sso-setup.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/setting-ip-filters.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/setting-ip-filters.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/shared-responsibility-model.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/shared-responsibility-model.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/cloud/support.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/concepts/why-clickhouse-is-so-fast.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/concepts/why-clickhouse-is-so-fast.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/concepts/why-clickhouse-is-so-fast.mdx create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/concepts/why-clickhouse-is-so-fast.mdx.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/data-modeling/projections.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/data-modeling/projections.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/data-modeling/projections/1_projections.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/data-modeling/projections/1_projections.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/data-modeling/projections/2_materialized-views-versus-projections.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/data-modeling/projections/2_materialized-views-versus-projections.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/horizontal-scaling.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/horizontal-scaling.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replicated.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replicated.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/01_1_shard_2_replicas.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/01_1_shard_2_replicas.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/02_2_shards_1_replica.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/02_2_shards_1_replica.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/03_2_shards_2_replicas.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/03_2_shards_2_replicas.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_cloud_tip.mdx create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_cloud_tip.mdx.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_config_explanation.mdx create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_config_explanation.mdx.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_dedicated_keeper_servers.mdx create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_dedicated_keeper_servers.mdx.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_keeper_config.mdx create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_keeper_config.mdx.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_keeper_explanation.mdx create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_keeper_explanation.mdx.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_listen_host.mdx create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_listen_host.mdx.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_server_parameter_table.mdx create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_server_parameter_table.mdx.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_verify_keeper_using_mntr.mdx create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_verify_keeper_using_mntr.mdx.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_working_example.mdx create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_working_example.mdx.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/datalake.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/datalake.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/arrowflight.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/arrowflight.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/ytsaurus.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/ytsaurus.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/coalescingmergetree.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/coalescingmergetree.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/alias.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/alias.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/faq/troubleshooting.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/faq/troubleshooting.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/dbpedia.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/dbpedia.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/hacker-news-vector-search.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/hacker-news-vector-search.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/hacker-news.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/hacker-news.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/laion5b.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/laion5b.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/opensky.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/opensky.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/recipes.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/recipes.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/reddit-comments.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/reddit-comments.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/getting-started/quick-start/cloud.mdx create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/getting-started/quick-start/cloud.mdx.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/getting-started/quick-start/index.mdx create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/getting-started/quick-start/index.mdx.hash rename i18n/zh/docusaurus-plugin-content-docs/current/{quick-start.mdx => getting-started/quick-start/oss.mdx} (55%) create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/getting-started/quick-start/oss.mdx.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/_snippets/_performance_optimizations_table_of_contents.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/_snippets/_performance_optimizations_table_of_contents.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/dynamic-column-selection.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/dynamic-column-selection.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/lightweight-update.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/lightweight-update.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/merge-table-function.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/merge-table-function.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/on-fly-mutations.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/on-fly-mutations.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/kafka.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/kafka.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/kafka/01_create-kafka-clickpipe.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/kafka/01_create-kafka-clickpipe.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/kafka/02_schema-registries.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/kafka/02_schema-registries.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/kafka/03_reference.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/kafka/03_reference.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/kafka/04_best_practices.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/kafka/04_best_practices.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/kafka/05_faq.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/kafka/05_faq.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/kafka/index.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/kafka/index.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/add_table.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/add_table.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/controlling_sync.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/controlling_sync.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/datatypes.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/datatypes.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/faq.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/faq.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/index.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/index.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/lifecycle.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/lifecycle.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/pause_and_resume.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/pause_and_resume.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/quickstart.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/quickstart.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/remove_table.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/remove_table.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/resync.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/resync.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/source/atlas.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/source/atlas.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/source/generic.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/source/generic.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/table_resync.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/table_resync.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/add_table.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/add_table.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/controlling_sync.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/controlling_sync.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/lifecycle.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/lifecycle.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/parallel_initial_load.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/parallel_initial_load.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/pause_and_resume.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/pause_and_resume.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/remove_table.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/remove_table.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/resync.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/resync.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/schema-changes.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/schema-changes.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/source/generic.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/source/generic.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/source/generic_maria.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/source/generic_maria.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/table_resync.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/table_resync.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/controlling_sync.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/controlling_sync.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/lifecycle.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/lifecycle.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/parallel_initial_load.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/parallel_initial_load.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/resync.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/resync.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/scaling.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/scaling.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/planetscale.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/planetscale.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/secure-rds.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/secure-rds.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/etl-tools/bladepipe-and-clickhouse.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/etl-tools/bladepipe-and-clickhouse.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/etl-tools/dbt/features-and-configurations.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/etl-tools/dbt/features-and-configurations.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/etl-tools/dbt/guides.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/etl-tools/dbt/guides.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/kafka/confluent/confluent-cloud.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/kafka/confluent/confluent-cloud.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/redshift/_snippets/_migration_guide.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/redshift/_snippets/_migration_guide.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/redshift/index.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/redshift/index.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-visualization/fabi-and-clickhouse.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-visualization/fabi-and-clickhouse.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/language-clients/csharp.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/language-clients/csharp.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/language-clients/moose-olap.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/language-clients/moose-olap.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/migration/_category_.yml delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/migration/clickhouse-local-etl.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/migration/clickhouse-local-etl.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/migration/clickhouse-to-cloud.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/migration/etl-tool-to-clickhouse.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/migration/index.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/migration/index.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/migration/object-storage-to-clickhouse.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/migration/object-storage-to-clickhouse.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/migration/overview.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/migration/overview.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/migration/rockset.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/migration/rockset.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/migration/upload-a-csv-file.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/migration/upload-a-csv-file.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/integrations/prometheus.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/interfaces/arrowflight.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/interfaces/arrowflight.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/interfaces/formats/Hash.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/interfaces/formats/Hash.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/interfaces/images/mysql0.png delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/interfaces/images/mysql1.png delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/interfaces/images/mysql2.png delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/interfaces/images/mysql3.png delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/merges.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/merges.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/merges.mdx create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/merges.mdx.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/partitions.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/partitions.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/partitions.mdx create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/partitions.mdx.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/primary-indexes.md.hash rename i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/{primary-indexes.md => primary-indexes.mdx} (56%) create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/primary-indexes.mdx.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/shards.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/shards.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/shards.mdx create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/shards.mdx.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/managing-data/deleting-data/delete_mutations.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/managing-data/deleting-data/delete_mutations.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/managing-data/deleting-data/delete_mutations.mdx create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/managing-data/deleting-data/delete_mutations.mdx.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/managing-data/deleting-data/overview.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/managing-data/deleting-data/overview.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/managing-data/deleting-data/overview.mdx create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/managing-data/deleting-data/overview.mdx.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/managing-data/drop_partition.md.hash rename i18n/zh/docusaurus-plugin-content-docs/current/managing-data/{drop_partition.md => drop_partition.mdx} (57%) create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/managing-data/drop_partition.mdx.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/managing-data/updating-data/overview.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/managing-data/updating-data/overview.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/managing-data/updating-data/overview.mdx create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/managing-data/updating-data/overview.mdx.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/managing-data/updating-data/update_mutations.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/managing-data/updating-data/update_mutations.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/managing-data/updating-data/update_mutations.mdx create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/managing-data/updating-data/update_mutations.mdx.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/migrations/bigquery/equivalent-concepts.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/migrations/bigquery/equivalent-concepts.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/migrations/bigquery/index.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/migrations/bigquery/index.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/migrations/bigquery/loading-data.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/migrations/bigquery/loading-data.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/migrations/bigquery/migrating-to-clickhouse-cloud.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/migrations/bigquery/migrating-to-clickhouse-cloud.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/migrations/index.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/migrations/index.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/migrations/postgres/appendix.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/migrations/postgres/appendix.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/migrations/postgres/data-modeling-techniques.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/migrations/postgres/data-modeling-techniques.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/migrations/postgres/dataset.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/migrations/postgres/dataset.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/migrations/postgres/index.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/migrations/postgres/overview.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/migrations/postgres/overview.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/migrations/postgres/rewriting-queries.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/migrations/snowflake.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/migrations/snowflake.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/operations/allocation-profiling-old.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/operations/allocation-profiling-old.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/tcp-connection-limits.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/tcp-connection-limits.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/codecs.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/codecs.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/crash_log.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/crash_log.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/current_roles.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/current_roles.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/database_replicas.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/database_replicas.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/dead_letter_queue.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/dead_letter_queue.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/delta_metadata_log.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/delta_metadata_log.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/dimensional_metrics.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/dimensional_metrics.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/enabled_roles.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/enabled_roles.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/iceberg_metadata_log.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/iceberg_metadata_log.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/latency_buckets.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/latency_buckets.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/latency_log.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/latency_log.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/projection_parts.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/projection_parts.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/projection_parts_columns.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/projection_parts_columns.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/role_grants.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/role_grants.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/zookeeper_connection_log.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/zookeeper_connection_log.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/quick-start.mdx.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/arrayconcatagg.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/arrayconcatagg.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantileprometheushistogram.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantileprometheushistogram.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/studentttestonesample.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/studentttestonesample.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesChangesToGrid.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesChangesToGrid.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesDeltaToGrid.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesDeltaToGrid.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesDerivToGrid.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesDerivToGrid.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesGroupArray.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesGroupArray.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesInstantDeltaToGrid.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesInstantDeltaToGrid.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesInstantRateToGrid.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesInstantRateToGrid.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesLastTwoSamples.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesLastTwoSamples.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesPredictLinearToGrid.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesPredictLinearToGrid.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesRateToGrid.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesRateToGrid.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesResampleToGridWithStaleness.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesResampleToGridWithStaleness.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesResetsToGrid.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesResetsToGrid.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/qbit.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/qbit.md.hash rename i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/{ym-dict-functions.md => embedded-dict-functions.md} (76%) create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/embedded-dict-functions.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/financial-functions.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/financial-functions.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/numeric-indexed-vector-functions.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/numeric-indexed-vector-functions.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/time-series-analysis-functions.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/time-series-analysis-functions.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/ym-dict-functions.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/apply_modifier.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/apply_modifier.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/except_modifier.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/except_modifier.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/replace_modifier.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/replace_modifier.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/update.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/update.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/arrowflight.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/arrowflight.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/generateSeries.md delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/generateSeries.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/prometheusQuery.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/prometheusQuery.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/prometheusQueryRange.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/prometheusQueryRange.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/timeSeriesSelector.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/timeSeriesSelector.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/ytsaurus.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/ytsaurus.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/lag.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/lag.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/lead.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/lead.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/tips-and-tricks/community-wisdom.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/tips-and-tricks/community-wisdom.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/tips-and-tricks/cost-optimization.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/tips-and-tricks/cost-optimization.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/tips-and-tricks/debugging-insights.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/tips-and-tricks/debugging-insights.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/tips-and-tricks/materialized-views.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/tips-and-tricks/materialized-views.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/tips-and-tricks/performance-optimization.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/tips-and-tricks/performance-optimization.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/tips-and-tricks/success-stories.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/tips-and-tricks/success-stories.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/tips-and-tricks/too-many-parts.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/tips-and-tricks/too-many-parts.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/troubleshooting/index.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/troubleshooting/index.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/AIChat/index.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/AIChat/index.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/01_remote_mcp.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/01_remote_mcp.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/02_claude-desktop.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/02_claude-desktop.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/03_librechat.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/03_librechat.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/04_anythingllm.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/04_anythingllm.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/05_open-webui.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/05_open-webui.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/06_ollama.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/06_ollama.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/07_janai.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/07_janai.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/_category_.json create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/agno.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/agno.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/chainlit.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/chainlit.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/copilotkit.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/copilotkit.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/dspy.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/dspy.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/index.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/index.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/langchain.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/langchain.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/llamaindex.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/llamaindex.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/openai-agents.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/openai-agents.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/pydantic-ai.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/pydantic-ai.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/slackbot.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/slackbot.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/streamlit.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/streamlit.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/index.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/index.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/ai-powered-sql-generation.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/ai-powered-sql-generation.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/index.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/index.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/jupyter-notebook.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/jupyter-notebook.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/data_lake/lakekeeper_catalog.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/data_lake/lakekeeper_catalog.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/data_lake/nessie_catalog.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/data_lake/nessie_catalog.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/data_lake/rest_catalog.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/data_lake/rest_catalog.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/dashboards.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/dashboards.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/_snippets/_json_support.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/_snippets/_json_support.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/_snippets/otel-cloud-config.yaml create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/hyperdx-clickhouse-cloud.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/hyperdx-clickhouse-cloud.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/event_deltas.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/event_deltas.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/event_patterns.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/event_patterns.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/example-datasets/_snippets/_demo.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/example-datasets/_snippets/_demo.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/example-datasets/_snippets/k8s_daemonset.yaml create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/example-datasets/_snippets/k8s_deployment.yaml create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/example-datasets/kubernetes.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/example-datasets/kubernetes.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/aws-lambda.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/aws-lambda.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/elastic/concepts.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/elastic/concepts.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/elastic/index.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/elastic/index.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/elastic/intro.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/elastic/intro.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/elastic/migrating-agents.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/elastic/migrating-agents.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/elastic/migrating-data.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/elastic/migrating-data.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/elastic/migrating-sdks.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/elastic/migrating-sdks.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/elastic/search.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/elastic/search.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/elastic/types.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/elastic/types.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/index.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/index.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ttl.md create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ttl.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/demo-application.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/grafana.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/integrating-opentelemetry.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/introduction.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/managing-data.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/schema-design.md.hash rename i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/{date-time-data-types.md => 01_date-time-data-types.md} (69%) create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/01_date-time-data-types.md.hash rename i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/{basic-operations.md => 02_basic-operations.md} (74%) create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/02_basic-operations.md.hash rename i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/{analysis-functions.md => 03_analysis-functions.md} (74%) create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/03_analysis-functions.md.hash rename i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/{storage-efficiency.md => 04_storage-efficiency.md} (57%) create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/04_storage-efficiency.md.hash rename i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/{query-performance.md => 05_query-performance.md} (71%) create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/05_query-performance.md.hash create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/06_materialized-view-rollup.mdx create mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/06_materialized-view-rollup.mdx.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/analysis-functions.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/basic-operations.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/date-time-data-types.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/query-performance.md.hash delete mode 100644 i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/storage-efficiency.md.hash diff --git a/docs/cloud/guides/index.md b/docs/cloud/guides/index.md index 30999e6db89..5ed81a3256e 100644 --- a/docs/cloud/guides/index.md +++ b/docs/cloud/guides/index.md @@ -4,4 +4,25 @@ title: 'Guides' hide_title: true description: 'Table of contents page for the ClickHouse Cloud guides section' doc_type: 'landing-page' ---- \ No newline at end of file +--- + + +| Page | Description | +|-----|-----| +| [Accessing S3 Data Securely](/cloud/security/secure-s3) | This article demonstrates how ClickHouse Cloud customers can leverage role-based access to authenticate with Amazon Simple Storage Service(S3) and access their data securely. | +| [AWS PrivateLink](/manage/security/aws-privatelink) | This document describes how to connect to ClickHouse Cloud using AWS PrivateLink. | +| [Azure Private Link](/cloud/security/azure-privatelink) | How to set up Azure Private Link | +| [Cloud Compatibility](/whats-new/cloud-compatibility) | This guide provides an overview of what to expect functionally and operationally in ClickHouse Cloud. | +| [Cloud IP Addresses](/manage/security/cloud-endpoints-api) | This page documents the Cloud Endpoints API security features within ClickHouse. It details how to secure your ClickHouse deployments by managing access through authentication and authorization mechanisms. | +| [Common Access Management Queries](/cloud/security/common-access-management-queries) | This article shows the basics of defining SQL users and roles and applying those privileges and permissions to databases, tables, rows, and columns. | +| [Configuring organization and service role assignments within the console](/cloud/guides/sql-console/configure-org-service-role-assignments) | Guide showing how to configure org and service role assignments within the console | +| [Configuring SQL console role assignments](/cloud/guides/sql-console/config-sql-console-role-assignments) | Guide showing how to configure SQL console role assignments | +| [Data masking in ClickHouse](/cloud/guides/data-masking) | A guide to data masking in ClickHouse | +| [Gather your connection details](/cloud/guides/sql-console/gather-connection-details) | Gather your connection details | +| [GCP Private Service Connect](/manage/security/gcp-private-service-connect) | This document describes how to connect to ClickHouse Cloud using Google Cloud Platform (GCP) Private Service Connect (PSC), and how to disable access to your ClickHouse Cloud services from addresses other than GCP PSC addresses using ClickHouse Cloud IP access lists. | +| [Inviting new users](/cloud/security/inviting-new-users) | This page describes how administrators can invite new users to their organisation and assign roles to them | +| [Multi tenancy](/cloud/bestpractices/multi-tenancy) | Best practices to implement multi tenancy | +| [SAML SSO Setup](/cloud/security/saml-setup) | How to set up SAML SSO with ClickHouse Cloud | +| [Setting IP Filters](/cloud/security/setting-ip-filters) | This page explains how to set IP filters in ClickHouse Cloud to control access to ClickHouse services. | +| [Usage limits](/cloud/bestpractices/usage-limits) | Describes the recommended usage limits in ClickHouse Cloud | + \ No newline at end of file diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/_clients/go/README.md b/i18n/zh/docusaurus-plugin-content-docs/current/_clients/go/README.md index 3565b950ca3..43b84676b83 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/_clients/go/README.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/_clients/go/README.md @@ -1,6 +1 @@ ---- -null -... ---- - -目录用于复制 Golang 源代码示例 + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/_placeholders/api/_invitations-api-reference.md b/i18n/zh/docusaurus-plugin-content-docs/current/_placeholders/api/_invitations-api-reference.md index 7277c6ef926..9137866e647 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/_placeholders/api/_invitations-api-reference.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/_placeholders/api/_invitations-api-reference.md @@ -1,8 +1,9 @@ --- 'sidebar_label': '邀请' 'title': '邀请' +'doc_type': 'reference' --- -## List all invitations {#list-all-invitations} +## 列出所有邀请 {#list-all-invitations} -此文件是由 `clickhouseapi.js` 在构建过程中生成的。如果内容需要更改,请编辑 `clickhouseapi.js`。 +此文件由 `clickhouseapi.js` 在构建过程中生成。如果需要更改内容,请编辑 `clickhouseapi.js`。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/_placeholders/api/_invitations-api-reference.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/_placeholders/api/_invitations-api-reference.md.hash index 4537140b7bc..7628bcd9227 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/_placeholders/api/_invitations-api-reference.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/_placeholders/api/_invitations-api-reference.md.hash @@ -1 +1 @@ -e0a35465deb99d56 +ae39a53b276a84a9 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/_placeholders/api/_keys-api-reference.md b/i18n/zh/docusaurus-plugin-content-docs/current/_placeholders/api/_keys-api-reference.md index f9a32ab331b..b1421f67ccf 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/_placeholders/api/_keys-api-reference.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/_placeholders/api/_keys-api-reference.md @@ -1,8 +1,9 @@ --- 'sidebar_label': '主键' 'title': '主键' +'doc_type': 'reference' --- ## 获取所有密钥的列表 {#get-list-of-all-keys} -此文件是由 `clickhouseapi.js` 在构建过程中生成的。如果需要更改内容,请编辑 `clickhouseapi.js`。 +此文件由 `clickhouseapi.js` 在构建过程中生成。如果需要更改内容,请编辑 `clickhouseapi.js`。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/_placeholders/api/_keys-api-reference.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/_placeholders/api/_keys-api-reference.md.hash index 3b75d09e7d0..4fc785590cf 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/_placeholders/api/_keys-api-reference.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/_placeholders/api/_keys-api-reference.md.hash @@ -1 +1 @@ -7be3bf52f87fcb23 +a304f0bb1aef8a9d diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/_placeholders/api/_members-api-reference.md b/i18n/zh/docusaurus-plugin-content-docs/current/_placeholders/api/_members-api-reference.md index 183106c44ae..723a7c6a660 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/_placeholders/api/_members-api-reference.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/_placeholders/api/_members-api-reference.md @@ -1,8 +1,9 @@ --- 'sidebar_label': '成员' 'title': '成员' +'doc_type': 'reference' --- -## List organization members {#list-organization-members} +## 列出组织成员 {#list-organization-members} -此文件由 `clickhouseapi.js` 在构建过程中生成。如果内容需要更改,请编辑 `clickhouseapi.js`。 +此文件由 `clickhouseapi.js` 在构建过程中生成。 如果需要更改内容,请编辑 `clickhouseapi.js`。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/_placeholders/api/_members-api-reference.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/_placeholders/api/_members-api-reference.md.hash index 7a27935e4c1..4d23f9e37eb 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/_placeholders/api/_members-api-reference.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/_placeholders/api/_members-api-reference.md.hash @@ -1 +1 @@ -8ba59ed8d689efc4 +620b28a4d887aad4 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/_placeholders/api/_organizations-api-reference.md b/i18n/zh/docusaurus-plugin-content-docs/current/_placeholders/api/_organizations-api-reference.md index 5f6d30d9a15..882e333d7c0 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/_placeholders/api/_organizations-api-reference.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/_placeholders/api/_organizations-api-reference.md @@ -1,8 +1,9 @@ --- 'sidebar_label': '组织' 'title': '组织' +'doc_type': 'reference' --- -## 获取组织详情 {#get-organization-details} +## 获取组织详细信息 {#get-organization-details} -此文件由 `clickhouseapi.js` 在构建过程中生成。如果需要更改内容,请编辑 `clickhouseapi.js`。 +此文件是由 `clickhouseapi.js` 在构建过程中生成的。如果内容需要更改,请编辑 `clickhouseapi.js`。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/_placeholders/api/_organizations-api-reference.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/_placeholders/api/_organizations-api-reference.md.hash index b72529e146b..7d83785eb85 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/_placeholders/api/_organizations-api-reference.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/_placeholders/api/_organizations-api-reference.md.hash @@ -1 +1 @@ -43d9a3a08ee303a2 +8b2e038d00786985 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/_placeholders/api/_services-api-reference.md b/i18n/zh/docusaurus-plugin-content-docs/current/_placeholders/api/_services-api-reference.md index 5f9617e6acb..36379a863db 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/_placeholders/api/_services-api-reference.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/_placeholders/api/_services-api-reference.md @@ -1,8 +1,9 @@ --- 'sidebar_label': '服务' 'title': '服务' +'doc_type': 'landing-page' --- ## 组织服务列表 {#list-of-organization-services} -此文件由 `clickhouseapi.js` 在构建过程中生成。如果需要更改内容,请编辑 `clickhouseapi.js`。 +此文件是在构建过程中由 `clickhouseapi.js` 生成的。 如果需要更改内容,请编辑 `clickhouseapi.js`。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/_placeholders/api/_services-api-reference.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/_placeholders/api/_services-api-reference.md.hash index 4c963b8edd4..bfaf56c800c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/_placeholders/api/_services-api-reference.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/_placeholders/api/_services-api-reference.md.hash @@ -1 +1 @@ -0bf9371323aac313 +0791a0cd491a5639 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/_placeholders/changelog/_index.md b/i18n/zh/docusaurus-plugin-content-docs/current/_placeholders/changelog/_index.md index 3406cf3052e..5055a04937f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/_placeholders/changelog/_index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/_placeholders/changelog/_index.md @@ -1,10 +1,11 @@ --- -'description': '2025 年的更新日志' +'description': '2025 的更新日志' 'note': 'This file is autogenerated by the yarn new-build' 'slug': '/whats-new/changelog/' 'sidebar_position': 2 'sidebar_label': '2025' 'title': '2025 更新日志' +'doc_type': 'changelog' --- diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/_placeholders/changelog/_index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/_placeholders/changelog/_index.md.hash index 0798c1349a8..9b93059cfa6 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/_placeholders/changelog/_index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/_placeholders/changelog/_index.md.hash @@ -1 +1 @@ -cff204a8b011fa88 +942656fa7dd0e1fc diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_GCS_authentication_and_bucket.md b/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_GCS_authentication_and_bucket.md index a0aee9eb127..2c7ca50f3dc 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_GCS_authentication_and_bucket.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_GCS_authentication_and_bucket.md @@ -1,8 +1,3 @@ ---- -null -... ---- - import GCS_bucket_1 from '@site/static/images/integrations/data-ingestion/s3/GCS-bucket-1.png'; import GCS_bucket_2 from '@site/static/images/integrations/data-ingestion/s3/GCS-bucket-2.png'; import GCS_create_service_account_key from '@site/static/images/integrations/data-ingestion/s3/GCS-create-a-service-account-key.png'; @@ -26,32 +21,32 @@ import Image from '@theme/IdealImage'; ### 生成访问密钥 {#generate-an-access-key} -### 创建服务账户 HMAC 密钥和秘密 {#create-a-service-account-hmac-key-and-secret} +### 创建服务账号 HMAC 密钥和秘密 {#create-a-service-account-hmac-key-and-secret} -打开 **Cloud Storage > 设置 > 互操作性**,然后选择一个现有的 **访问密钥**,或者 **为服务账户创建密钥**。 本指南涵盖了为新服务账户创建新密钥的步骤。 +打开 **Cloud Storage > 设置 > 互操作性**,然后选择现有的 **访问密钥**,或者 **为服务账号创建密钥**。本指南涵盖为新服务账号创建新密钥的路径。 -在 GCS 中生成服务账户 HMAC 密钥 +在 GCS 中生成服务账号 HMAC 密钥 -### 添加新服务账户 {#add-a-new-service-account} +### 添加新服务账号 {#add-a-new-service-account} -如果这是一个没有现有服务账户的项目,请 **创建新账户**。 +如果这是一个没有现有服务账号的项目,请 **创建新账号**。 -在 GCS 中添加新服务账户 +在 GCS 中添加新服务账号 -创建服务账户的步骤有三步,第一步给账户一个有意义的名称、ID 和描述。 +创建服务账号有三个步骤。在第一步中,给账号一个有意义的名称、ID 和描述。 -在 GCS 中定义新服务账户的名称和 ID +在 GCS 中定义新服务账号名称和 ID -在互操作性设置对话框中,推荐选择 IAM 角色 **Storage Object Admin**;在第二步中选择该角色。 +在互操作性设置对话框中,推荐 IAM 角色 **存储对象管理员** 角色;在第二步中选择该角色。 -在 GCS 中选择 IAM 角色 Storage Object Admin +在 GCS 中选择 IAM 角色存储对象管理员 -第三步是可选的,在本指南中未使用。 您可以根据政策允许用户拥有这些权限。 +第三步是可选的,本指南中未使用。您可以根据您的策略允许用户具有这些权限。 -为新服务账户配置额外设置的 GCS +在 GCS 中配置新服务账号的附加设置 -服务账户 HMAC 密钥将被显示。 请保存该信息,因为它将在 ClickHouse 配置中使用。 +服务账号 HMAC 密钥将会显示。请保存这些信息,因为它将在 ClickHouse 配置中使用。 -检索到生成的 GCS HMAC 密钥 +检索生成的 GCS HMAC 密钥 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_GCS_authentication_and_bucket.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_GCS_authentication_and_bucket.md.hash index 76487a75a15..5e6cc733867 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_GCS_authentication_and_bucket.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_GCS_authentication_and_bucket.md.hash @@ -1 +1 @@ -e28c24c6b6f89390 +003df1f3c664139d diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_S3_authentication_and_bucket.md b/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_S3_authentication_and_bucket.md index 2376d3b663d..f087df6d69c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_S3_authentication_and_bucket.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_S3_authentication_and_bucket.md @@ -1,8 +1,3 @@ ---- -null -... ---- - import Image from '@theme/IdealImage'; import s3_1 from '@site/static/images/_snippets/s3/s3-1.png'; import s3_2 from '@site/static/images/_snippets/s3/s3-2.png'; @@ -25,44 +20,44 @@ import s3_h from '@site/static/images/_snippets/s3/s3-h.png';
创建 S3 桶和 IAM 用户 -本文演示了如何配置 AWS IAM 用户、创建 S3 桶并配置 ClickHouse 使用该桶作为 S3 磁盘的基本知识。您应该与您的安全团队合作,以确定要使用的权限,并将其视为起点。 +本文演示了如何配置 AWS IAM 用户、创建 S3 桶并配置 ClickHouse 使用该桶作为 S3 磁盘的基础知识。您应与安全团队合作,以确定要使用的权限,并将其视为起点。 ### 创建 AWS IAM 用户 {#create-an-aws-iam-user} 在此过程中,我们将创建一个服务账户用户,而不是登录用户。 -1. 登录到 AWS IAM 管理控制台。 +1. 登录 AWS IAM 管理控制台。 2. 在“用户”中,选择 **添加用户** AWS IAM 管理控制台 - 添加新用户 -3. 输入用户名并将凭证类型设置为 **访问密钥 - 编程访问**,然后选择 **下一步:权限** +3. 输入用户名,并将凭证类型设置为 **访问密钥 - 程序访问**,然后选择 **下一步:权限** -为 IAM 用户设置用户名和访问类型 +设置 IAM 用户的用户名和访问类型 -4. 不要将用户添加到任何组中;选择 **下一步:标签** +4. 不要将用户添加到任何组;选择 **下一步:标签** -跳过对 IAM 用户的组分配 +跳过 IAM 用户的组分配 -5. 除非您需要添加任何标签,否则选择 **下一步:审核** +5. 除非需要添加任何标签,否则选择 **下一步:审核** -跳过对 IAM 用户的标签分配 +跳过 IAM 用户的标签分配 6. 选择 **创建用户** :::note - 提示信息称用户没有权限可以忽略;用户在下一节将获得桶的权限 + 表示用户没有权限的警告可以忽略;将在下一部分中授予用户对桶的权限。 ::: -创建 IAM 用户时不带权限的警告 +创建 IAM 用户时没有权限警告 -7. 用户现在已创建;单击 **显示** 并复制访问密钥和秘密密钥。 +7. 用户现在已创建;点击 **显示** 并复制访问密钥和秘密密钥。 :::note -请将密钥保存在其他地方;这是唯一一次可以使用的秘密访问密钥。 +请将密钥保存到其他地方;这是唯一能获取秘密访问密钥的时间。 ::: -查看和复制 IAM 用户访问密钥 +查看并复制 IAM 用户访问密钥 -8. 单击关闭,然后在用户屏幕中找到该用户。 +8. 点击关闭,然后在用户列表中找到用户。 在用户列表中找到新创建的 IAM 用户 @@ -73,23 +68,23 @@ import s3_h from '@site/static/images/_snippets/s3/s3-h.png'; ### 创建 S3 桶 {#create-an-s3-bucket} 1. 在 S3 桶部分,选择 **创建桶** -开始 S3 桶创建过程 +开始创建 S3 桶的过程 -2. 输入桶名称,保持其他选项为默认值 +2. 输入桶名称,其他选项保持默认 :::note -桶名称在 AWS 中必须是唯一的,而不仅仅是在组织中,否则将发出错误。 +桶名称必须在 AWS 中唯一,而不仅仅是在组织内部,否则将发出错误。 ::: -3. 保持 `阻止所有公共访问` 启用;不需要公共访问。 +3. 保留 `阻止所有公共访问` 启用;不需要公共访问。 -配置公共访问被阻止的 S3 桶设置 +配置 S3 桶设置,阻止公共访问 -4. 选择页面底部的 **创建桶** +4. 在页面底部选择 **创建桶** -最终确定 S3 桶创建过程 +完成 S3 桶的创建 -5. 选择链接,复制 ARN,并保存以供在配置桶的访问策略时使用。 +5. 选择链接,复制 ARN,并保存以便在配置桶的访问策略时使用。 -6. 一旦桶创建完成,在 S3 桶列表中找到新创建的 S3 桶,并选择链接 +6. 创建桶后,在 S3 桶列表中找到新创建的 S3 桶并选择链接 在桶列表中找到新创建的 S3 桶 @@ -97,23 +92,23 @@ import s3_h from '@site/static/images/_snippets/s3/s3-h.png'; 在 S3 桶中创建新文件夹 -8. 输入一个文件夹名称,该名称将作为 ClickHouse S3 磁盘的目标,然后选择 **创建文件夹** +8. 输入一个文件夹名称,作为 ClickHouse S3 磁盘的目标,并选择 **创建文件夹** -设置 ClickHouse S3 磁盘使用的文件夹名称 +为 ClickHouse S3 磁盘使用设置文件夹名称 -9. 该文件夹现在应在桶列表中可见 +9. 该文件夹现在应该在桶列表中可见 -查看新创建的 S3 桶中的文件夹 +查看新创建的文件夹在 S3 桶中的情况 -10. 选择新文件夹的复选框,然后单击 **复制 URL**。保存复制的 URL,以便在下一节的 ClickHouse 存储配置中使用。 +10. 选择新文件夹的复选框并点击 **复制 URL** 保存复制的 URL,以便在下一节的 ClickHouse 存储配置中使用。 -复制用于 ClickHouse 配置的 S3 文件夹 URL +复制 S3 文件夹 URL 用于 ClickHouse 配置 -11. 选择 **权限** 选项卡,然后在 **桶策略** 部分单击 **编辑** 按钮 +11. 选择 **权限** 选项卡,然后在 **桶策略** 部分点击 **编辑** 按钮 访问 S3 桶策略配置 -12. 添加桶策略,如下面示例所示: +12. 添加桶策略,示例如下: ```json { "Version" : "2012-10-17", @@ -147,8 +142,8 @@ import s3_h from '@site/static/images/_snippets/s3/s3-h.png'; ``` :::note -您应该与您的安全团队合作,以确定要使用的权限,并将其视为起点。 -有关策略和设置的更多信息,请参考 AWS 文档: +您应与安全团队合作,以确定要使用的权限,将这些视为起点。 +有关策略和设置的更多信息,请参阅 AWS 文档: https://docs.aws.amazon.com/AmazonS3/latest/userguide/access-policy-language-overview.html ::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_add_remote_ip_access_list_detail.md b/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_add_remote_ip_access_list_detail.md index a3e4fa4951b..825595d456e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_add_remote_ip_access_list_detail.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_add_remote_ip_access_list_detail.md @@ -1,8 +1,3 @@ ---- -null -... ---- - import Image from '@theme/IdealImage'; import ip_allow_list_check_list from '@site/static/images/_snippets/ip-allow-list-check-list.png'; import ip_allow_list_add_current_ip from '@site/static/images/_snippets/ip-allow-list-add-current-ip.png'; @@ -10,12 +5,12 @@ import ip_allow_list_add_current_ip from '@site/static/images/_snippets/ip-allow
管理您的 IP 访问列表 -从您的 ClickHouse Cloud 服务列表中选择您将要使用的服务,并切换到 **设置**。如果 IP 访问列表中不包含需要连接到您的 ClickHouse Cloud 服务的远程系统的 IP 地址或范围,则可以通过 **添加 IP** 来解决此问题: +从您的 ClickHouse Cloud 服务列表中选择您要使用的服务,并切换到 **设置**。如果 IP 访问列表中不包含需要连接到您的 ClickHouse Cloud 服务的远程系统的 IP 地址或范围,您可以通过 **添加 IP 们** 来解决此问题: 检查服务是否允许来自您的 IP 地址的流量在 IP 访问列表中 添加需要连接到您的 ClickHouse Cloud 服务的单个 IP 地址或地址范围。根据需要修改表单,然后 **保存**。 -将您当前的 IP 地址添加到 ClickHouse Cloud 中的 IP 访问列表 +将您的当前 IP 地址添加到 ClickHouse Cloud 的 IP 访问列表中
diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_add_superset_detail.md b/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_add_superset_detail.md index 1f4775736d5..be65cb42fce 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_add_superset_detail.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_add_superset_detail.md @@ -1,26 +1,21 @@ ---- -null -... ---- -
在 Docker 中启动 Apache Superset -Superset 提供了 [使用 Docker Compose 本地安装 Superset](https://superset.apache.org/docs/installation/installing-superset-using-docker-compose/) 的说明。在从 GitHub 上检出 Apache Superset 仓库后,您可以运行最新的开发代码或特定标签。我们推荐使用 2.0.0 版本,因为它是最新的未标记为 `pre-release` 的版本。 +Superset 提供了 [使用 Docker Compose 安装 Superset](https://superset.apache.org/docs/installation/installing-superset-using-docker-compose/) 的说明。在从 GitHub 检出 Apache Superset 仓库后,您可以运行最新的开发代码或特定的标签。我们推荐使用 2.0.0 版本,因为它是最新的未标记为 `pre-release` 的发布版本。 -在运行 `docker compose` 之前,有几个任务需要完成: +在运行 `docker compose` 之前需要完成几个任务: -1. 添加官方 ClickHouse Connect 驱动程序 -2. 获取一个 Mapbox API 密钥并将其添加为环境变量(可选) +1. 添加官方的 ClickHouse Connect 驱动 +2. 获取 Mapbox API 密钥并将其添加为环境变量(可选) 3. 指定要运行的 Superset 版本 :::tip -以下命令需从 GitHub 仓库的顶层目录 `superset` 中运行。 +以下命令需在 GitHub 仓库的顶层目录 `superset` 中运行。 ::: -## 官方 ClickHouse Connect 驱动程序 {#official-clickhouse-connect-driver} +## 官方 ClickHouse Connect 驱动 {#official-clickhouse-connect-driver} -要使 ClickHouse Connect 驱动程序在 Superset 部署中可用,请将其添加到本地需求文件中: +为了在 Superset 部署中使用 ClickHouse Connect 驱动,请将其添加到本地需求文件中: ```bash echo "clickhouse-connect" >> ./docker/requirements-local.txt @@ -28,11 +23,11 @@ echo "clickhouse-connect" >> ./docker/requirements-local.txt ## Mapbox {#mapbox} -这是可选的,您可以在 Superset 中绘制位置数据,而无需 Mapbox API 密钥,但您会看到一条消息,提示您应添加密钥,并且地图的背景图像将缺失(您只会看到数据点,而没有地图背景)。如果您想使用它,Mapbox 提供免费层。 +这是可选的,您可以在 Superset 中绘制位置数据而不需要 Mapbox API 密钥,但您会看到一条消息提示您应该添加一个密钥,并且地图的背景图像将会缺失(您只会看到数据点,而看不到地图背景)。如果您想使用 Mapbox,它提供了免费使用层。 -一些示例可视化指南要求您创建使用位置(例如经度和纬度)数据的可视化。Superset 包含对 Mapbox 地图的支持。要使用 Mapbox 可视化,您需要一个 Mapbox API 密钥。注册 [Mapbox 免费层](https://account.mapbox.com/auth/signup/),并生成一个 API 密钥。 +一些指南中让您创建的示例可视化使用了位置数据,例如经度和纬度数据。Superset 支持 Mapbox 地图。要使用 Mapbox 可视化,您需要一个 Mapbox API 密钥。请注册 [Mapbox 免费使用层](https://account.mapbox.com/auth/signup/),并生成一个 API 密钥。 -将 API 密钥提供给 Superset: +使 API 密钥可用于 Superset: ```bash echo "MAPBOX_API_KEY=pk.SAMPLE-Use-your-key-instead" >> docker/.env-non-dev @@ -40,7 +35,7 @@ echo "MAPBOX_API_KEY=pk.SAMPLE-Use-your-key-instead" >> docker/.env-non-dev ## 部署 Superset 版本 2.0.0 {#deploy-superset-version-200} -要部署 2.0.0 版本,请运行: +要部署 2.0.0 版本,运行: ```bash git checkout 2.0.0 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_add_superset_detail.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_add_superset_detail.md.hash index b65c6c2310b..8e6deb03b51 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_add_superset_detail.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_add_superset_detail.md.hash @@ -1 +1 @@ -ccc68e13430eae91 +38d1ab0953d5112c diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_aws_regions.md b/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_aws_regions.md index adef6473dfe..493589ab3f7 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_aws_regions.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_aws_regions.md @@ -1,13 +1,8 @@ ---- -null -... ---- - -| 区域 | VPC 服务名称 | 可用区 ID | -|--------------|----------------------------------------------------------|------------------------------| -| ap-south-1 | com.amazonaws.vpce.ap-south-1.vpce-svc-0a786406c7ddc3a1b | aps1-az1 aps1-az2 aps1-az3 | -| ap-southeast-1| com.amazonaws.vpce.ap-southeast-1.vpce-svc-0a8b096ec9d2acb01 | apse1-az1 apse1-az2 apse1-az3 | -| ap-southeast-2| com.amazonaws.vpce.ap-southeast-2.vpce-svc-0ca446409b23f0c01 | apse2-az1 apse2-az2 apse2-az3 | +| 区域 | VPC 服务名称 | 可用区 IDs | +|--------------|-------------------------------------------------------------|------------------------------| +| ap-south-1 | com.amazonaws.vpce.ap-south-1.vpce-svc-0a786406c7ddc3a1b | aps1-az1 aps1-az2 aps1-az3 | +| ap-southeast-1| com.amazonaws.vpce.ap-southeast-1.vpce-svc-0a8b096ec9d2acb01| apse1-az1 apse1-az2 apse1-az3| +| ap-southeast-2| com.amazonaws.vpce.ap-southeast-2.vpce-svc-0ca446409b23f0c01| apse2-az1 apse2-az2 apse2-az3| | eu-central-1 | com.amazonaws.vpce.eu-central-1.vpce-svc-0536fc4b80a82b8ed | euc1-az2 euc1-az3 euc1-az1 | | eu-west-1 | com.amazonaws.vpce.eu-west-1.vpce-svc-066b03c9b5f61c6fc | euw1-az2 euw1-az3 euw1-az1 | | us-east-1 c0 | com.amazonaws.vpce.us-east-1.vpce-svc-0a0218fa75c646d81 | use1-az6 use1-az1 use1-az2 | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_aws_regions.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_aws_regions.md.hash index a9b21aa06f6..710ba8a45ac 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_aws_regions.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_aws_regions.md.hash @@ -1 +1 @@ -09158e75c5e2a869 +d9ecc38165e19153 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_clickhouse_mysql_cloud_setup.mdx b/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_clickhouse_mysql_cloud_setup.mdx index 8d755afba8a..96921ac8b67 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_clickhouse_mysql_cloud_setup.mdx +++ b/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_clickhouse_mysql_cloud_setup.mdx @@ -1,87 +1,111 @@ ---- -null -... ---- - import mysql_1 from '@site/static/images/_snippets/mysql1.png'; import mysql_2 from '@site/static/images/_snippets/mysql2.png'; import mysql_3 from '@site/static/images/_snippets/mysql3.png'; import mysql_4 from '@site/static/images/_snippets/mysql4.png'; import mysql_5 from '@site/static/images/_snippets/mysql5.png'; import Image from '@theme/IdealImage'; +import {VerticalStepper} from "@clickhouse/click-ui/bundled"; + + + +#### 选择 `连接您的应用` {#select-connect-your-app} + +在创建您的 ClickHouse Cloud 服务后,在 `连接您的应用` 屏幕上,从下拉菜单中选择 MySQL。 -
-1. 在创建您的 ClickHouse Cloud 服务后,在 `连接您的应用` 屏幕上,从下拉菜单中选择 MySQL。 -
+ClickHouse Cloud 凭据屏幕显示 MySQL 接口选择下拉菜单 -ClickHouse Cloud 凭证屏幕显示 MySQL 界面选择下拉菜单 +#### 启用 MySQL 接口 {#enable-mysql-interface} +切换开关以启用此特定服务的 MySQL 接口。 +这将为该服务暴露端口 `3306`,并提示您输入包含您唯一 MySQL 用户名的 MySQL 连接屏幕。 -2. 切换开关以启用该特定服务的 MySQL 接口。这将为该服务暴露端口 `3306` 并提示您显示包含您独特 MySQL 用户名的 MySQL 连接屏幕。 +ClickHouse Cloud MySQL 接口启用开关和连接详细信息 -ClickHouse Cloud MySQL 接口启用开关和连接详情 -
+另外,为了为现有服务启用 MySQL 接口: -或者,为了为现有服务启用 MySQL 接口: +#### 选择 `连接` {#select-connect} -3. 确保您的服务处于 `运行中` 状态,然后点击您想要启用 MySQL 接口的服务。从左侧菜单中选择 “连接”: +确保您的服务处于 `运行` 状态,然后点击您想启用 MySQL 接口的服务。 +从左侧菜单中选择 "连接": -
-ClickHouse Cloud 服务连接屏幕,突出显示连接选项 -
+ClickHouse Cloud 服务连接屏幕,突出显示连接选项 +#### 选择 `MySQL` {#choose-mysql} -4. 从 `以连接` 下拉菜单中选择 MySQL。 +从 `连接方式` 下拉菜单中选择 `MySQL`。 -
ClickHouse Cloud 连接屏幕显示 MySQL 选项选择 -
-5. 切换开关以启用该特定服务的 MySQL 接口。这将为该服务暴露端口 `3306` 并提示您显示包含您独特 MySQL 用户名的 MySQL 连接屏幕。 +#### 启用 MySQL 接口 {#enable-mysql-interface} -ClickHouse Cloud 连接屏幕,启用 MySQL 接口显示连接详情 +切换开关以启用此特定服务的 MySQL 接口。 +这将为该服务暴露端口 `3306`,并提示您输入包含您唯一 MySQL 用户名的 MySQL 连接屏幕。 -## 在 ClickHouse Cloud 中创建多个 MySQL 用户 {#creating-multiple-mysql-users-in-clickhouse-cloud} +
-默认情况下,有一个内置的 `mysql4` 用户,使用与 `default` 用户相同的密码。`` 部分是您的 ClickHouse Cloud 主机名的第一个段。这种格式是必要的,以便与实现安全连接但不在其 TLS 握手中提供 [SNI 信息](https://www.cloudflare.com/learning/ssl/what-is-sni) 的工具一起使用,这使得在没有用户名中的额外提示的情况下进行内部路由变得不可能(MySQL 控制台客户端就是其中一种工具)。 +ClickHouse Cloud 连接屏幕,MySQL 接口启用,显示连接详细信息 -因此,我们 _强烈建议_ 在创建打算用于 MySQL 接口的新用户时遵循 `mysql4_` 格式,其中 `` 是用于识别您的 Cloud 服务的提示,而 `` 是您选择的任意后缀。 +## 在 ClickHouse Cloud 中创建只读 MySQL 用户 {#creating-multiple-mysql-users-in-clickhouse-cloud} + +ClickHouse Cloud 自动创建一个 `mysql4` 用户,该用户与默认用户共享相同的密码。 +`` 部分对应于您 ClickHouse Cloud 主机名的第一部分。 + +这种用户名格式对于兼容那些建立安全连接但在 TLS 握手中未包含 [SNI (服务器名称指示)](https://www.cloudflare.com/learning/ssl/what-is-sni) 数据的工具是必需的。 +没有 SNI 信息,系统无法执行正确的内部路由,因此嵌入在用户名中的子域提示提供了必要的路由信息。 +MySQL 控制台客户端就是一个需要此信息的工具的例子。 :::tip -对于 ClickHouse Cloud 主机名如 `foobar.us-east1.aws.clickhouse.cloud`,`` 部分等于 `foobar`,而自定义 MySQL 用户名可以是 `mysql4foobar_team1`。 +推荐的最佳实践是创建一个新的只读 MySQL 用户。 +::: + +:::note +对于像 `foobar.us-east1.aws.clickhouse.cloud` 的 ClickHouse Cloud 主机名,`` 部分等于 `foobar`,那么自定义 MySQL 用户名可以是 `mysql4foobar_team1`。 ::: -您可以创建额外的用户以供 MySQL 接口使用,例如,如果您需要应用额外设置。 + + +#### 创建只读设置配置文件 {#create-a-custom-settings-user} -1. 可选 - 创建一个 [设置配置文件](/sql-reference/statements/create/settings-profile),以便应用于您自定义的用户。例如,`my_custom_profile`,其中包含将默认为我们稍后连接时应用的额外设置: +创建一个 [设置配置文件](/sql-reference/statements/create/settings-profile) 以应用于您的只读用户,将 `readonly` 设置为 `1`: ```sql -CREATE SETTINGS PROFILE my_custom_profile SETTINGS prefer_column_name_to_alias=1; +CREATE SETTINGS PROFILE readonly_profile SETTINGS readonly = 1 ``` - `prefer_column_name_to_alias` 仅作为示例,您可以在其中使用其他设置。 -2. 使用以下格式 [创建用户](/sql-reference/statements/create/user):`mysql4_`([见上文](#creating-multiple-mysql-users-in-clickhouse-cloud))。密码必须为双 SHA1 格式。例如: +#### 创建一个新的只读 MySQL 用户 {#create-a-readonly-mysql-user} + +[创建用户](/sql-reference/statements/create/user),使用以下格式命名: ```sql -CREATE USER mysql4foobar_team1 IDENTIFIED WITH double_sha1_password BY 'YourPassword42$'; +mysql4_ ``` - 或者,如果您希望为该用户使用自定义配置文件: +将 `readonly_profile` 应用到新用户,并确保密码采用双重 SHA1 格式。例如: ```sql -CREATE USER mysql4foobar_team1 IDENTIFIED WITH double_sha1_password BY 'YourPassword42$' SETTINGS PROFILE 'my_custom_profile'; +CREATE USER mysql4foobar_readonly +IDENTIFIED WITH double_sha1_password BY 'YourPassword42$' +SETTINGS PROFILE 'readonly_profile'; ``` - 其中 `my_custom_profile` 是您之前创建的配置文件的名称。 -3. [授予](/sql-reference/statements/grant) 新用户与所需表或数据库交互所需的权限。例如,如果您只想授予对 `system.query_log` 的访问权限: +#### 授予新用户访问所需表的权限 {#grant-the-new-user-the-necessary-permissions} + +[授予](/sql-reference/statements/grant) 新用户与所需表或数据库进行交互的必要权限。 +例如,如果您只想授予对 `system.query_log` 的访问权限: ```sql -GRANT SELECT ON system.query_log TO mysql4foobar_team1; +GRANT SELECT ON system.query_log TO mysql4foobar_readonly; ``` -4. 使用创建的用户通过 MySQL 接口连接到您的 ClickHouse Cloud 服务。 +:::note +对于只读用户,确保只授予所需访问表的 `SELECT` 权限。 +::: + +新创建的用户可以使用 MySQL 接口连接到您的 ClickHouse Cloud 服务。 + + -### 在 ClickHouse Cloud 中的多个 MySQL 用户故障排除 {#troubleshooting-multiple-mysql-users-in-clickhouse-cloud} +### 在 ClickHouse Cloud 中故障排除多个 MySQL 用户 {#troubleshooting-multiple-mysql-users-in-clickhouse-cloud} 如果您创建了一个新的 MySQL 用户,并且在通过 MySQL CLI 客户端连接时看到以下错误: @@ -89,4 +113,4 @@ GRANT SELECT ON system.query_log TO mysql4foobar_team1; ERROR 2013 (HY000): Lost connection to MySQL server at 'reading authorization packet', system error: 54 ``` -在这种情况下,确保用户名遵循 `mysql4_` 格式,如上所述([见上文](#creating-multiple-mysql-users-in-clickhouse-cloud))。 +在这种情况下,请确保用户名遵循 `mysql4_` 格式,如上所述 ([上文](#creating-multiple-mysql-users-in-clickhouse-cloud))。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_clickhouse_mysql_cloud_setup.mdx.hash b/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_clickhouse_mysql_cloud_setup.mdx.hash index 4a421a33bbf..890c0fcef8c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_clickhouse_mysql_cloud_setup.mdx.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_clickhouse_mysql_cloud_setup.mdx.hash @@ -1 +1 @@ -8e7d8c4d0d2a0126 +ce5ee4c0fdd94f20 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_clickhouse_mysql_on_premise_setup.mdx b/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_clickhouse_mysql_on_premise_setup.mdx index bb6df5e6a1c..86600d4a90e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_clickhouse_mysql_on_premise_setup.mdx +++ b/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_clickhouse_mysql_on_premise_setup.mdx @@ -1,9 +1,4 @@ ---- -null -... ---- - -请参考 [官方文档](/interfaces/mysql) 了解如何设置启用 MySQL 接口的 ClickHouse 服务器。 +请参阅 [官方文档](/interfaces/mysql) 关于如何设置一个启用 MySQL 接口的 ClickHouse 服务器。 除了在服务器的 `config.xml` 中添加条目 @@ -13,17 +8,17 @@ null ``` -外,还 **要求** 使用 -[Double SHA1 密码加密](/operations/settings/settings-users#user-namepassword) -为将使用 MySQL 接口的用户。 +之外,还必须使用 +[双 SHA1 密码加密](/operations/settings/settings-users#user-namepassword) +为将要使用 MySQL 接口的用户。 -从 shell 中生成使用 Double SHA1 加密的随机密码: +从命令行生成一个使用双 SHA1 加密的随机密码: ```shell PASSWORD=$(base64 < /dev/urandom | head -c16); echo "$PASSWORD"; echo -n "$PASSWORD" | sha1sum | tr -d '-' | xxd -r -p | sha1sum | tr -d '-' ``` -输出应如下所示: +输出应该如下所示: ``` LZOQYnqQN4L/T6L0 @@ -32,7 +27,7 @@ fbc958cc745a82188a51f30de69eebfc67c40ee4 第一行是生成的密码,第二行是我们可以用来配置 ClickHouse 的哈希值。 -以下是使用生成的哈希值的 `mysql_user` 的示例配置: +以下是使用生成的哈希值的 `mysql_user` 示例配置: `/etc/clickhouse-server/users.d/mysql_user.xml` @@ -49,10 +44,9 @@ fbc958cc745a82188a51f30de69eebfc67c40ee4 ``` -将 `password_double_sha1_hex` 条目替换为您自己的生成的 Double SHA1 哈希。 +用您自己生成的双 SHA1 哈希值替换 `password_double_sha1_hex` 条目。 -此外,建议使用 `use_mysql_types_in_show_columns` -在 `SHOW [FULL] COLUMNS` 查询结果中显示原生 MySQL 类型,而不是 ClickHouse 类型,这样可以让 BI 工具在使用 MySQL 连接器时正确地探查数据库模式。 +此外,建议使用 `use_mysql_types_in_show_columns` 来在 `SHOW [FULL] COLUMNS` 查询结果中显示本地 MySQL 类型,而不是 ClickHouse 类型,这样可以让 BI 工具在使用 MySQL 连接器时正确探测数据库架构。 例如: @@ -66,10 +60,9 @@ fbc958cc745a82188a51f30de69eebfc67c40ee4 ``` -或者将其分配给不同的配置文件,而不是默认的配置文件。 +或者将其分配给一个不同的配置文件,而不是默认配置文件。 -如果您有可用的 `mysql` 二进制文件,您可以从命令行测试连接。 -使用上面的示例用户名 (`mysql_user`) 和密码 (`LZOQYnqQN4L/T6L0`),命令行应为: +如果您有 `mysql` 二进制文件可用,您可以从命令行测试连接。使用上面示例中的用户名(`mysql_user`)和密码(`LZOQYnqQN4L/T6L0`),命令行将是: ```bash mysql --protocol tcp -h localhost -u mysql_user -P 9004 --password=LZOQYnqQN4L/T6L0 @@ -89,7 +82,7 @@ mysql> show databases; Read 4 rows, 603.00 B in 0.00156 sec., 2564 rows/sec., 377.48 KiB/sec. ``` -最后,配置 Clickhouse 服务器以监听所需的 IP 地址。 例如,在 `config.xml` 中,取消注释以下内容以监听所有地址: +最后,配置 ClickHouse 服务器以在所需的 IP 地址上监听。例如,在 `config.xml` 中,取消注释以下内容以在所有地址上监听: ```bash :: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_config-files.md b/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_config-files.md index ca63b0a8fbc..cfb8b700b90 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_config-files.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_config-files.md @@ -1,10 +1,5 @@ ---- -null -... ---- - :::important best practices -在配置 ClickHouse 服务器时,通过添加或编辑配置文件,您应该: +在通过添加或编辑配置文件来配置 ClickHouse Server 时,您应当: - 将文件添加到 `/etc/clickhouse-server/config.d/` 目录 - 将文件添加到 `/etc/clickhouse-server/users.d/` 目录 - 保持 `/etc/clickhouse-server/config.xml` 文件不变 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_gather_your_details_http.mdx b/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_gather_your_details_http.mdx index 3447fa4d510..5dc6a2709ad 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_gather_your_details_http.mdx +++ b/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_gather_your_details_http.mdx @@ -1,26 +1,21 @@ ---- -null -... ---- - import cloud_connect_button from '@site/static/images/_snippets/cloud-connect-button.png'; import connection_details_https from '@site/static/images/_snippets/connection-details-https.png'; import Image from '@theme/IdealImage'; 要通过 HTTP(S) 连接到 ClickHouse,您需要以下信息: -- HOST 和 PORT:通常情况下,使用 TLS 时端口为 8443,不使用 TLS 时端口为 8123。 +- **主机**和**端口**:通常,当使用 TLS 时端口为 8443,当不使用 TLS 时端口为 8123。 -- 数据库名称:默认情况下,有一个名为 `default` 的数据库,请使用您要连接的数据库名称。 +- **数据库名称**:开箱即用时,有一个名为 `default` 的数据库,请使用您要连接的数据库名称。 -- 用户名和密码:默认情况下,用户名为 `default`。请使用适合您用例的用户名。 +- **用户名**和**密码**:开箱即用时,用户名为 `default`。请使用适合您用例的用户名。 -您的 ClickHouse Cloud 服务的详细信息可以在 ClickHouse Cloud 控制台中找到。选择您要连接的服务并点击 **Connect**: +您的 ClickHouse Cloud 服务的详细信息可在 ClickHouse Cloud 控制台中获得。 选择您要连接的服务并点击 **连接**: -ClickHouse Cloud service connect button +ClickHouse Cloud 服务连接按钮 -选择 **HTTPS**,并且详细信息可以在一个示例 `curl` 命令中找到。 +选择 **HTTPS**,详细信息可在示例的 `curl` 命令中获得。 -ClickHouse Cloud HTTPS connection details +ClickHouse Cloud HTTPS 连接详细信息 -如果您使用自管理的 ClickHouse,连接详细信息由您的 ClickHouse 管理员设置。 +如果您使用的是自管理的 ClickHouse,连接详细信息由您的 ClickHouse 管理员设置。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_gather_your_details_native.md b/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_gather_your_details_native.md index e68167fcb0a..89acaef61c3 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_gather_your_details_native.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_gather_your_details_native.md @@ -1,26 +1,21 @@ ---- -null -... ---- - import cloud_connect_button from '@site/static/images/_snippets/cloud-connect-button.png'; import connection_details_native from '@site/static/images/_snippets/connection-details-native.png'; import Image from '@theme/IdealImage'; -要通过本地 TCP 连接到 ClickHouse ,您需要以下信息: +要通过原生 TCP 连接到 ClickHouse,您需要以下信息: -- 主机和端口:当使用 TLS 时,端口通常为 9440,当不使用 TLS 时,端口为 9000。 +- 主机(HOST)和端口(PORT):通常,当使用 TLS 时,端口为 9440,当不使用 TLS 时,端口为 9000。 -- 数据库名称:开箱即用有一个名为 `default` 的数据库,请使用您要连接的数据库的名称。 +- 数据库名称(DATABASE NAME):开箱即用有一个名为 `default` 的数据库,使用您要连接的数据库的名称。 -- 用户名和密码:开箱即用的用户名是 `default`。请使用适合您用例的用户名。 +- 用户名(USERNAME)和密码(PASSWORD):开箱即用时,用户名为 `default`。使用适合您用例的用户名。 -有关您的 ClickHouse Cloud 服务的详细信息,请在 ClickHouse Cloud 控制台中查看。 选择您要连接的服务,然后点击 **Connect**: +您 ClickHouse Cloud 服务的详细信息可以在 ClickHouse Cloud 控制台中找到。选择您要连接的服务,然后单击 **Connect**: -ClickHouse Cloud service connect button +ClickHouse Cloud 服务连接按钮 -选择 **Native**,详细信息在示例 `clickhouse-client` 命令中提供。 +选择 **Native**,然后详细信息将在示例 `clickhouse-client` 命令中提供。 -ClickHouse Cloud Native TCP connection details +ClickHouse Cloud 原生 TCP 连接详细信息 如果您使用的是自管理的 ClickHouse,连接详细信息由您的 ClickHouse 管理员设置。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_gather_your_details_native.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_gather_your_details_native.md.hash index da794d24fc8..f7f61ac10fa 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_gather_your_details_native.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_gather_your_details_native.md.hash @@ -1 +1 @@ -069dd5014869e2d8 +09c842d7dd7b745c diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_gcp_regions.md b/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_gcp_regions.md index 8fcbdfbca4e..e92e1c58b98 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_gcp_regions.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_gcp_regions.md @@ -1,11 +1,6 @@ ---- -null -... ---- - -| 区域 | 服务附加信息 | 私有 DNS 域名 | -|--------------|-------------------------------------------------------------|-----------------------------------| +| 区域 | 服务附件 | 私有 DNS 域名 | +|-----------------|------------------------------------------------------------|--------------------------------------| | `asia-southeast1` | `projects/dataplane-production/regions/asia-southeast1/serviceAttachments/production-asia-southeast1-clickhouse-cloud` | `asia-southeast1.p.gcp.clickhouse.cloud` | -| `europe-west4` | `projects/dataplane-production/regions/europe-west4/serviceAttachments/production-europe-west4-clickhouse-cloud` | `europe-west4.p.gcp.clickhouse.cloud` | -| `us-central1` | `projects/dataplane-production/regions/us-central1/serviceAttachments/production-us-central1-clickhouse-cloud` | `us-central1.p.gcp.clickhouse.cloud` | -| `us-east1` | `projects/dataplane-production/regions/us-east1/serviceAttachments/production-us-east1-clickhouse-cloud` | `us-east1.p.gcp.clickhouse.cloud` | +| `europe-west4` | `projects/dataplane-production/regions/europe-west4/serviceAttachments/production-europe-west4-clickhouse-cloud` | `europe-west4.p.gcp.clickhouse.cloud` | +| `us-central1` | `projects/dataplane-production/regions/us-central1/serviceAttachments/production-us-central1-clickhouse-cloud` | `us-central1.p.gcp.clickhouse.cloud` | +| `us-east1` | `projects/dataplane-production/regions/us-east1/serviceAttachments/production-us-east1-clickhouse-cloud` | `us-east1.p.gcp.clickhouse.cloud` | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_gcp_regions.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_gcp_regions.md.hash index 7f08f13748d..69998bd7b8b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_gcp_regions.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_gcp_regions.md.hash @@ -1 +1 @@ -f6c9640aa81292e6 +535bb919042707e7 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_keeper-config-files.md b/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_keeper-config-files.md index acad7f588d4..5313ae088d8 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_keeper-config-files.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_keeper-config-files.md @@ -1,10 +1,5 @@ ---- -null -... ---- - :::important best practices -配置 ClickHouse Keeper 时,通过编辑配置文件,你应该: +在通过编辑配置文件配置 ClickHouse Keeper 时,您应该: - 备份 `/etc/clickhouse-keeper/keeper_config.xml` - 编辑 `/etc/clickhouse-keeper/keeper_config.xml` 文件 ::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_launch_sql_console.md b/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_launch_sql_console.md index e0697c6d4b4..441514e6cf7 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_launch_sql_console.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_launch_sql_console.md @@ -1,14 +1,9 @@ ---- -null -... ---- - import cloud_connect_to_sql_console from '@site/static/images/_snippets/cloud-connect-to-sql-console.png'; import createservice8 from '@site/static/images/_snippets/createservice8.png'; import Image from '@theme/IdealImage'; :::tip SQL 控制台 -如果您需要 SQL 客户端连接,您的 ClickHouse Cloud 服务具有一个相关的基于网络的 SQL 控制台;请展开下面的 **连接到 SQL 控制台** 以获取详细信息。 +如果您需要 SQL 客户端连接,您的 ClickHouse Cloud 服务具有相关的基于网页的 SQL 控制台;展开下面的 **连接到 SQL 控制台** 获取详细信息。 :::
@@ -18,7 +13,7 @@ import Image from '@theme/IdealImage'; 连接到 SQL 控制台 -这将重定向您到 SQL 控制台。 +这将把您重定向到 SQL 控制台。 SQL 控制台 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_launch_sql_console.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_launch_sql_console.md.hash index 98dbf7031b2..8d66a0e608e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_launch_sql_console.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_launch_sql_console.md.hash @@ -1 +1 @@ -0e66060e54cc6a3f +465a1fe1321eba03 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_replication-sharding-terminology.md b/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_replication-sharding-terminology.md index 301e6f3ef2a..b2917dbb288 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_replication-sharding-terminology.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_replication-sharding-terminology.md @@ -1,14 +1,9 @@ ---- -null -... ---- - ## 术语 {#terminology} ### 副本 {#replica} -数据的副本。 ClickHouse 始终至少保留一份您的数据副本,因此最低的 **replicas** 数量为一。这是一个重要的细节,您可能不习惯将数据的原始副本视为副本,但这就是 ClickHouse 代码和文档中使用的术语。添加第二个数据副本可以提供容错能力。 +数据的副本。 ClickHouse 始终至少保留您的数据的一份副本,因此 **副本** 的最小数量为一。这是一个重要的细节,您可能不习惯将数据的原始副本视为副本,但这就是 ClickHouse 代码和文档中使用的术语。 添加第二个数据副本提供了容错能力。 ### 分片 {#shard} -数据的子集。 ClickHouse 始终至少为您的数据保留一个分片,因此如果您不将数据划分到多个服务器上,您的数据将存储在一个分片中。在多个服务器上分片数据可以用于分担负载,如果您超出了单个服务器的容量。目标服务器由 **sharding key** 决定,并在您创建分布式表时定义。分片键可以是随机的或作为 [哈希函数](/sql-reference/functions/hash-functions) 的输出。涉及分片的部署示例将使用 `rand()` 作为分片键,并将提供关于何时以及如何选择不同分片键的进一步信息。 +数据的子集。 ClickHouse 始终至少为您的数据保留一个分片,因此,如果您没有将数据分散到多个服务器上,您的数据将存储在一个分片中。 将数据分片到多个服务器可以在您超出单个服务器的容量时分担负载。 目标服务器由 **分片键** 决定,并在创建分布式表时定义。 分片键可以是随机的或是 [哈希函数](/sql-reference/functions/hash-functions) 的输出。 涉及分片的部署示例将使用 `rand()` 作为分片键,并提供有关何时以及如何选择不同分片键的进一步信息。 ### 分布式协调 {#distributed-coordination} -ClickHouse Keeper 提供了数据复制和分布式 DDL 查询执行的协调系统。 ClickHouse Keeper 与 Apache ZooKeeper 兼容。 +ClickHouse Keeper 提供数据复制和分布式 DDL 查询执行的协调系统。 ClickHouse Keeper 与 Apache ZooKeeper 兼容。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_self_managed_only_automated.md b/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_self_managed_only_automated.md index 1fee55cca8c..e7c4e64e800 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_self_managed_only_automated.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_self_managed_only_automated.md @@ -1,12 +1,7 @@ ---- -null -... ---- - import CloudNotSupportedBadge from '@theme/badges/CloudNotSupportedBadge'; :::note -本页面不适用于 [ClickHouse Cloud](https://clickhouse.com/cloud)。此处记录的过程在 ClickHouse Cloud 服务中是自动化的。 +此页面不适用于 [ClickHouse Cloud](https://clickhouse.com/cloud)。此处文档记录的流程在 ClickHouse Cloud 服务中是自动化的。 ::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_self_managed_only_no_roadmap.md b/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_self_managed_only_no_roadmap.md index badcc9f0fed..2ecdbf2041c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_self_managed_only_no_roadmap.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_self_managed_only_no_roadmap.md @@ -1,13 +1,8 @@ ---- -null -... ---- - import CloudNotSupportedBadge from '@theme/badges/CloudNotSupportedBadge'; :::note -此页面不适用于 [ClickHouse Cloud](https://clickhouse.com/cloud)。本页所述的功能在 ClickHouse Cloud 服务中不可用。 -有关更多信息,请参阅 ClickHouse 的 [Cloud Compatibility](/whats-new/cloud-compatibility) 指南。 +此页面与 [ClickHouse Cloud](https://clickhouse.com/cloud) 不相关。此处文档中记载的功能在 ClickHouse Cloud 服务中不可用。 +有关更多信息,请参阅 ClickHouse [云兼容性](/whats-new/cloud-compatibility) 指南。 ::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_self_managed_only_not_applicable.md b/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_self_managed_only_not_applicable.md index 30a5764b08a..16702d190e4 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_self_managed_only_not_applicable.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_self_managed_only_not_applicable.md @@ -1,12 +1,7 @@ ---- -null -... ---- - import CloudNotSupportedBadge from '@theme/badges/CloudNotSupportedBadge'; :::note -本页面不适用于 [ClickHouse Cloud](https://clickhouse.com/cloud)。此处记录的过程仅在自管理的 ClickHouse 部署中是必要的。 +本页面不适用于 [ClickHouse Cloud](https://clickhouse.com/cloud)。此处记录的流程仅在自管理的 ClickHouse 部署中是必要的。 ::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_self_managed_only_roadmap.md b/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_self_managed_only_roadmap.md index 9793eb1fe5c..085e28503f0 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_self_managed_only_roadmap.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_self_managed_only_roadmap.md @@ -1,13 +1,8 @@ ---- -null -... ---- - import CloudNotSupportedBadge from '@theme/badges/CloudNotSupportedBadge'; :::note -此页面不适用于 [ClickHouse Cloud](https://clickhouse.com/cloud)。文档中描述的功能尚未在 ClickHouse Cloud 服务中提供。 -有关更多信息,请参见 ClickHouse [Cloud Compatibility](/whats-new/cloud-compatibility#roadmap) 指南。 +此页面不适用于 [ClickHouse Cloud](https://clickhouse.com/cloud)。此处文档中的功能尚不可在 ClickHouse Cloud 服务中使用。 +有关更多信息,请参阅 ClickHouse [Cloud Compatibility](/whats-new/cloud-compatibility#roadmap) 指南。 ::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_service_actions_menu.md b/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_service_actions_menu.md index 7645ff3fcb4..c4ffffb7c17 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_service_actions_menu.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_service_actions_menu.md @@ -1,11 +1,6 @@ ---- -null -... ---- - import Image from '@theme/IdealImage'; import cloud_service_action_menu from '@site/static/images/_snippets/cloud-service-actions-menu.png'; -选择你的服务,然后点击 `Data souces` -> `Predefined sample data`。 +选择您的服务,然后选择 `数据源` -> `预定义示例数据`。 -ClickHouse Cloud 服务操作菜单,显示 Data sources 和 Predefined sample data 选项 +ClickHouse Cloud service Actions menu showing Data sources and Predefined sample data options diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_service_actions_menu.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_service_actions_menu.md.hash index b970aee4cff..a6e19e1a109 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_service_actions_menu.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_service_actions_menu.md.hash @@ -1 +1 @@ -0292037de914fe0d +8e177b80a783b7ba diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_system_table_cloud.md b/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_system_table_cloud.md index 2f3983931b8..62cb45825d5 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_system_table_cloud.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_system_table_cloud.md @@ -1,8 +1,3 @@ ---- -null -... ---- - :::note 在 ClickHouse Cloud 中查询 -此系统表中的数据在 ClickHouse Cloud 的每个节点上本地保存。因此,要获取所有数据的完整视图,需要使用 `clusterAllReplicas` 函数。有关详细信息,请参见 [这里](/operations/system-tables/overview#system-tables-in-clickhouse-cloud)。 +此系统表中的数据在 ClickHouse Cloud 中的每个节点上本地保存。因此,要获得所有数据的完整视图,需要使用 `clusterAllReplicas` 函数。有关进一步的详细信息,请参见 [这里](/operations/system-tables/overview#system-tables-in-clickhouse-cloud)。 ::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_tabs.md b/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_tabs.md deleted file mode 100644 index 089cdc1749e..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_tabs.md +++ /dev/null @@ -1,23 +0,0 @@ ---- -'sidebar_label': '选项卡示例' ---- - -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; -import CodeBlock from '@theme/CodeBlock'; - -## 步骤 1. {#step-1} - - - - -云 - - - - -自管理 - - - - diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_tabs.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_tabs.md.hash deleted file mode 100644 index c677ccf99f6..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_tabs.md.hash +++ /dev/null @@ -1 +0,0 @@ -339d948a28eac4fd diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_users-and-roles-common.md b/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_users-and-roles-common.md index f28eb28d818..3bb466a3605 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_users-and-roles-common.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_users-and-roles-common.md @@ -1,13 +1,8 @@ ---- -null -... ---- - ## 测试管理员权限 {#test-admin-privileges} -注销 `default` 用户并以 `clickhouse_admin` 用户身份登录。 +注销当前用户 `default`,并以用户 `clickhouse_admin` 重新登录。 -所有这些都应该成功: +以下所有操作应成功: ```sql SHOW GRANTS FOR clickhouse_admin; @@ -39,52 +34,54 @@ DROP DATABASE db1; ## 非管理员用户 {#non-admin-users} -用户应具备必要的权限,而并非所有用户都是管理员。本文档的其余部分提供了示例场景和所需的角色。 +用户应具备必要的权限,而不必全是管理员用户。本文档的其余部分提供了示例场景和所需的角色。 ### 准备工作 {#preparation} -创建这些表和用户以供示例使用。 +创建以下表和用户以供示例使用。 #### 创建示例数据库、表和行 {#creating-a-sample-database-table-and-rows} -1. 创建一个测试数据库 + + +##### 创建测试数据库 {#create-a-test-database} ```sql CREATE DATABASE db1; ``` -2. 创建一个表 +##### 创建表 {#create-a-table} ```sql CREATE TABLE db1.table1 ( - id UInt64, - column1 String, - column2 String + id UInt64, + column1 String, + column2 String ) ENGINE MergeTree ORDER BY id; ``` -3. 用示例行填充该表 +##### 用示例行填充表 {#populate} ```sql INSERT INTO db1.table1 - (id, column1, column2) + (id, column1, column2) VALUES - (1, 'A', 'abc'), - (2, 'A', 'def'), - (3, 'B', 'abc'), - (4, 'B', 'def'); + (1, 'A', 'abc'), + (2, 'A', 'def'), + (3, 'B', 'abc'), + (4, 'B', 'def'); ``` -4. 验证该表: +##### 验证表 {#verify} -```sql +```sql title="Query" SELECT * FROM db1.table1 ``` -```response +```response title="Response" Query id: 475015cc-6f51-4b20-bda2-3c9c41404e49 ┌─id─┬─column1─┬─column2─┐ @@ -95,28 +92,35 @@ Query id: 475015cc-6f51-4b20-bda2-3c9c41404e49 └────┴─────────┴─────────┘ ``` -5. 创建一个普通用户,用于演示限制对某些列的访问: +##### 创建 `column_user` {#create-a-user-with-restricted-access-to-columns} + +创建一个常规用户,用于演示如何限制对某些列的访问: ```sql CREATE USER column_user IDENTIFIED BY 'password'; ``` -6. 创建一个普通用户,用于演示限制对某些值的行的访问: +##### 创建 `row_user` {#create-a-user-with-restricted-access-to-rows-with-certain-values} + +创建一个常规用户,用于演示如何限制对具有特定值的行的访问: + ```sql CREATE USER row_user IDENTIFIED BY 'password'; ``` + + #### 创建角色 {#creating-roles} 通过这一系列示例: -- 将为不同的权限(如列和行)创建角色 +- 创建不同权限的角色,例如列和行 - 将权限授予角色 -- 用户将被分配到各个角色 +- 将用户分配给每个角色 -角色用于定义特定权限的用户组,而不是单独管理每个用户。 +角色用于定义用户组,以获取特定权限,而不是分别管理每个用户。 -1. 创建一个角色,限制该角色的用户只能在 `db1` 数据库和 `table1` 表中查看 `column1`: +1. 创建一个角色,以限制该角色的用户只能查看数据库 `db1` 中的 `table1` 的 `column1`: ```sql CREATE ROLE column1_users; @@ -134,7 +138,7 @@ GRANT SELECT(id, column1) ON db1.table1 TO column1_users; GRANT column1_users TO column_user; ``` -4. 创建一个角色,限制该角色的用户只能查看选定的行,在本例中,仅包含 `column1` 中值为 `A` 的行 +4. 创建一个角色,以限制该角色的用户只能查看选定的行,在这种情况下,只能查看 `column1` 中包含 `A` 的行 ```sql CREATE ROLE A_rows_users; @@ -146,7 +150,7 @@ CREATE ROLE A_rows_users; GRANT A_rows_users TO row_user; ``` -6. 创建一个策略,仅允许查看 `column1` 的值为 `A` 的行 +6. 创建一项策略,以仅允许查看 `column1` 值为 `A` 的行 ```sql CREATE ROW POLICY A_row_filter ON db1.table1 FOR SELECT USING column1 = 'A' TO A_rows_users; @@ -158,7 +162,7 @@ CREATE ROW POLICY A_row_filter ON db1.table1 FOR SELECT USING column1 = 'A' TO A GRANT SELECT(id, column1, column2) ON db1.table1 TO A_rows_users; ``` -8. 明确授予其他角色仍然能够访问所有行的权限 +8. 授予其他角色的显式权限,以便仍然可以访问所有行 ```sql CREATE ROW POLICY allow_other_users_filter @@ -166,12 +170,12 @@ ON db1.table1 FOR SELECT USING 1 TO clickhouse_admin, column1_users; ``` :::note - 附加策略到表时,系统将应用该策略,仅定义的用户和角色将能够对该表进行操作,所有其他用户将被拒绝任何操作。为了不对其他用户应用限制行策略,必须定义另一策略,以允许其他用户和角色具有常规或其他类型的访问权限。 + 当将策略附加到表时,系统将应用该策略,只有那些被定义的用户和角色才能对该表进行操作,所有其他用户将被拒绝任何操作。为了不对其他用户施加限制性行策略,必须定义另一项策略以允许其他用户和角色进行常规或其他类型的访问。 ::: ## 验证 {#verification} -### 测试带列限制用户的角色权限 {#testing-role-privileges-with-column-restricted-user} +### 使用列限制用户测试角色权限 {#testing-role-privileges-with-column-restricted-user} 1. 使用 `clickhouse_admin` 用户登录 ClickHouse 客户端 @@ -203,7 +207,7 @@ Query id: f5e906ea-10c6-45b0-b649-36334902d31d clickhouse-client --user column_user --password password ``` -4. 测试使用所有列的 `SELECT` +4. 使用所有列测试 `SELECT` ```sql SELECT * @@ -223,10 +227,10 @@ SELECT(id, column1, column2) ON db1.table1. (ACCESS_DENIED) ``` :::note - 访问被拒绝,因为指定了所有列,而用户仅对 `id` 和 `column1` 有访问权限 + 访问被拒绝,因为指定了所有列,而用户仅对 `id` 和 `column1` 有访问权限。 ::: -5. 验证仅指定和允许的列的 `SELECT` 查询: +5. 验证只指定和允许的列的 `SELECT` 查询: ```sql SELECT @@ -246,7 +250,7 @@ Query id: cef9a083-d5ce-42ff-9678-f08dc60d4bb9 └────┴─────────┘ ``` -### 测试带行限制用户的角色权限 {#testing-role-privileges-with-row-restricted-user} +### 使用行限制用户测试角色权限 {#testing-role-privileges-with-row-restricted-user} 1. 使用 `row_user` 登录 ClickHouse 客户端 @@ -271,16 +275,16 @@ Query id: a79a113c-1eca-4c3f-be6e-d034f9a220fb ``` :::note - 验证仅返回上述两行,`column1` 中值为 `B` 的行应被排除。 + 验证仅返回上述两个行,`column1` 中值为 `B` 的行应被排除。 ::: ## 修改用户和角色 {#modifying-users-and-roles} -用户可以被分配多个角色,以获得所需的权限组合。当使用多个角色时,系统将组合这些角色以确定权限,最终效果将是角色权限的累积。 +用户可以被分配多个角色,以满足所需权限的组合。当使用多个角色时,系统将组合这些角色以确定权限,最终效果是角色权限将是累积的。 -例如,如果一个 `role1` 只允许在 `column1` 上进行选择,而 `role2` 允许在 `column1` 和 `column2` 上进行选择,则用户将同时访问这两列。 +例如,如果一个 `role1` 仅允许在 `column1` 上进行选择,而 `role2` 允许在 `column1` 和 `column2` 上进行选择,则用户将同时访问这两列。 -1. 使用管理员帐户,创建新用户以通过行和列的默认角色进行限制 +1. 使用管理员帐户创建新用户,以通过行和列的方式限制,并指定默认角色 ```sql CREATE USER row_and_column_user IDENTIFIED BY 'password' DEFAULT ROLE A_rows_users; @@ -304,7 +308,7 @@ GRANT SELECT(id, column1) ON db1.table1 TO A_rows_users; clickhouse-client --user row_and_column_user --password password; ``` -5. 测试所有列: +5. 使用所有列测试: ```sql SELECT * @@ -323,7 +327,7 @@ To execute this query it's necessary to have grant SELECT(id, column1, column2) ON db1.table1. (ACCESS_DENIED) ``` -6. 测试有限允许的列: +6. 使用有限的允许列进行测试: ```sql SELECT @@ -341,11 +345,11 @@ Query id: 5e30b490-507a-49e9-9778-8159799a6ed0 └────┴─────────┘ ``` -## 排错 {#troubleshooting} +## 故障排除 {#troubleshooting} -有时权限交叉或组合会产生意外结果,以下命令可用于使用管理员帐户缩小问题范围 +有时权限交错或组合会产生意想不到的结果,以下命令可以在使用管理员帐户时用于缩小问题范围 -### 列出用户的授权和角色 {#listing-the-grants-and-roles-for-a-user} +### 列出用户的权限和角色 {#listing-the-grants-and-roles-for-a-user} ```sql SHOW GRANTS FOR row_and_column_user @@ -389,7 +393,7 @@ Query id: f2c636e9-f955-4d79-8e80-af40ea227ebc └────────────────────────────────────────┘ ``` -### 查看策略是如何定义的及当前权限 {#view-how-a-policy-was-defined-and-current-privileges} +### 查看策略的定义和当前权限 {#view-how-a-policy-was-defined-and-current-privileges} ```sql SHOW CREATE ROW POLICY A_row_filter ON db1.table1 @@ -405,11 +409,11 @@ Query id: 0d3b5846-95c7-4e62-9cdd-91d82b14b80b ## 管理角色、策略和用户的示例命令 {#example-commands-to-manage-roles-policies-and-users} -以下命令可用于: +以下命令可以用于: - 删除权限 - 删除策略 -- 取消用户与角色的关联 +- 将用户从角色中撤回 - 删除用户和角色
@@ -429,7 +433,7 @@ REVOKE SELECT(column1, id) ON db1.table1 FROM A_rows_users; DROP ROW POLICY A_row_filter ON db1.table1; ``` -### 取消用户与角色的关联 {#unassign-a-user-from-a-role} +### 从角色中撤回用户 {#unassign-a-user-from-a-role} ```sql REVOKE A_rows_users FROM row_user; @@ -447,6 +451,6 @@ DROP ROLE A_rows_users; DROP USER row_user; ``` -## 摘要 {#summary} +## 总结 {#summary} -本文展示了创建 SQL 用户和角色的基础知识,并提供了设置和修改用户和角色权限的步骤。有关每个内容的更详细信息,请参阅我们的用户指南和参考文档。 +本文介绍了创建 SQL 用户和角色的基础知识,并提供了设置和修改用户和角色权限的步骤。有关每个方面的更详细信息,请参阅我们的用户指南和参考文档。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_users-and-roles-common.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_users-and-roles-common.md.hash index acd90d1753c..ef0bc85c623 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_users-and-roles-common.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_users-and-roles-common.md.hash @@ -1 +1 @@ -a7a06887bcf479a8 +17ff031f9233b05b diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/about-us/about-faq-index.md b/i18n/zh/docusaurus-plugin-content-docs/current/about-us/about-faq-index.md index 76f87af4d45..eb18f133a9b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/about-us/about-faq-index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/about-us/about-faq-index.md @@ -1,19 +1,20 @@ --- 'title': 'FAQ' 'slug': '/about-us/faq' -'description': '登录页面' +'description': '着陆页' +'doc_type': 'landing-page' --- -| 常见问题 | +| FAQ | |-------------------------------------------------------------------------------------------------------------------------------| -| [什么是列式数据库?](/faq/general/columnar-database) | -| [“ClickHouse”是什么意思?](/faq/general/dbms-naming) | -| [将ClickHouse与其他系统集成](/faq/integration) | -| [如何将JSON导入ClickHouse?](/faq/integration/json-import) | -| [如果在通过ODBC使用Oracle时遇到编码问题该怎么办?](/faq/integration/oracle-odbc) | -| [是否可以从ClickHouse表中删除旧记录?](/faq/operations/delete-old-data) | -| [关于操作ClickHouse服务器和集群的问题](/faq/operations) | -| [是否可以使用单独的存储和计算来部署ClickHouse?](/faq/operations/deploy-separate-storage-and-compute) | -| [关于ClickHouse用例的问题](/faq/use-cases) | -| [我可以将ClickHouse用作键值存储吗?](/faq/use-cases/key-value) | -| [我可以将ClickHouse用作时间序列数据库吗?](/faq/use-cases/time-series) | +| [什么是列式数据库?](/faq/general/columnar-database) | +| [“ClickHouse”是什么意思?](/faq/general/dbms-naming) | +| [将ClickHouse与其他系统集成](/faq/integration) | +| [如何将JSON导入ClickHouse?](/faq/integration/json-import) | +| [如果在通过ODBC使用Oracle时遇到编码问题,该怎么办?](/faq/integration/oracle-odbc) | +| [可以从ClickHouse表中删除旧记录吗?](/faq/operations/delete-old-data) | +| [关于操作ClickHouse服务器和集群的问题](/faq/operations) | +| [是否可以使用单独的存储和计算部署ClickHouse?](/faq/operations/deploy-separate-storage-and-compute) | +| [关于ClickHouse使用案例的问题](/faq/use-cases) | +| [我可以将ClickHouse用作键值存储吗?](/faq/use-cases/key-value) | +| [我可以将ClickHouse用作时间序列数据库吗?](/faq/use-cases/time-series) | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/about-us/about-faq-index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/about-us/about-faq-index.md.hash index 4c17d3b30ee..b9674245c00 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/about-us/about-faq-index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/about-us/about-faq-index.md.hash @@ -1 +1 @@ -2720730d1d47f395 +7594b8d2abcb6bd6 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/about-us/adopters.md b/i18n/zh/docusaurus-plugin-content-docs/current/about-us/adopters.md index c871da6f47d..93daa43b8cf 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/about-us/adopters.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/about-us/adopters.md @@ -4,6 +4,7 @@ sidebar_label: 'Adopters' title: 'ClickHouse Adopters' sidebar_position: 60 description: 'A list of companies using ClickHouse and their success stories' +doc_type: 'reference' --- The following list of companies using ClickHouse and their success stories is assembled from public sources, thus might differ from current reality. We'd appreciate it if you share the story of adopting ClickHouse in your company and [add it to the list](https://github.com/ClickHouse/clickhouse-docs/blob/main/docs/about-us/adopters.md), but please make sure you won't have any NDA issues by doing so. Providing updates with publications from other companies is also useful. @@ -15,549 +16,553 @@ The following list of companies using ClickHouse and their success stories is as | [2gis](https://2gis.ru) | Maps | Monitoring | [Talk in Russian, July 2019](https://youtu.be/58sPkXfq6nw) | — | — | | [3xpl](https://3xpl.com/) | Software & Technology | Blockchain Explorer | [Reddit, February 2023](https://www.reddit.com/r/ethereum/comments/1159pdg/new_ethereum_explorer_by_3xpl_no_ads_super_fast/) | — | — | | [5CNetwork](https://www.5cnetwork.com/) | Software | Analytics | [Community Slack](https://clickhouse.com/slack) | — | — | -| [ABTasty](https://www.abtasty.com/) | Web Analytics | Analytics | [Paris Meetup, March 2024](https://www.meetup.com/clickhouse—france—user—group/events/298997115/) | — | — | -| [Arkhn](https://www.arkhn.com) | Healthcare | Data Warehouse | [Paris Meetup, March 2024](https://www.meetup.com/clickhouse—france—user—group/events/298997115/) | — | — | +| [ABTasty](https://www.abtasty.com/) | Web Analytics | Analytics | [Paris Meetup, March 2024](https://www.meetup.com/clickhouse-france-user-group/events/298997115/) | — | — | +| [Arkhn](https://www.arkhn.com) | Healthcare | Data Warehouse | [Paris Meetup, March 2024](https://www.meetup.com/clickhouse-france-user-group/events/298997115/) | — | — | | [ASO.dev](https://aso.dev/) | Software & Technology | App store optimisation | [Twitter, April 2023](https://twitter.com/gorniv/status/1642847791226445828) | — | — | -| [AdGreetz](https://www.adgreetz.com/) | Software & Technology | AdTech & MarTech | [Blog, April 2023](https://clickhouse.com/blog/adgreetz—processes—millions—of—daily—ad—impressions) | — | — | -| [AdGuard](https://adguard.com/) | Anti—Ads | AdGuard DNS | [Official Website, August 2022](https://adguard.com/en/blog/adguard—dns—2—0—goes—open—source.html) | — | 1,000,000 DNS requests per second from over 50 million users | -| [AdScribe](http://www.adscribe.tv/) | Ads | TV Analytics | [A quote from CTO](https://altinity.com/24x7—support/) | — | — | +| [AdGreetz](https://www.adgreetz.com/) | Software & Technology | AdTech & MarTech | [Blog, April 2023](https://clickhouse.com/blog/adgreetz-processes-millions-of-daily-ad-impressions) | — | — | +| [AdGuard](https://adguard.com/) | Anti-Ads | AdGuard DNS | [Official Website, August 2022](https://adguard.com/en/blog/adguard-dns-2-0-goes-open-source.html) | — | 1,000,000 DNS requests per second from over 50 million users | +| [AdScribe](http://www.adscribe.tv/) | Ads | TV Analytics | [A quote from CTO](https://altinity.com/24x7-support/) | — | — | | [Adapty](https://adapty.io/) | Subscription Analytics | Main product | [Twitter, November 2021](https://twitter.com/iwitaly/status/1462698148061659139) | — | — | -| [Adevinta](https://www.adevinta.com/) | Software & Technology | Online Classifieds | [Blog, April 2023](https://clickhouse.com/blog/serving—real—time—analytics—across—marketplaces—at—adevinta) | — | — | -| [Admiral](https://getadmiral.com/) | MarTech | Engagement Management | [Webinar Slides, June 2020](https://altinity.com/presentations/2020/06/16/big—data—in—real—time—how—clickhouse—powers—admirals—visitor—relationships—for—publishers) | — | — | -| [Admixer](https://admixer.com/) | Media & Entertainment | Ad Analytics | [Blog Post](https://clickhouse.com/blog/admixer—aggregates—over—1—billion—unique—users—a—day—using—clickhouse) | — | — | -| [Aggregations.io](https://aggregations.io/) | Real—time analytics | Main product | [Twitter](https://twitter.com/jsneedles/status/1734606200199889282) | — | — | -| [Ahrefs](https://ahrefs.com/) | SEO | Analytics | [Job listing](https://ahrefs.com/jobs/data—scientist—search) | Main cluster is 100k+ CPU cores, 800TB RAM. | 110PB NVME storage, uncompressed data size on main cluster is 1EB. | +| [Adevinta](https://www.adevinta.com/) | Software & Technology | Online Classifieds | [Blog, April 2023](https://clickhouse.com/blog/serving-real-time-analytics-across-marketplaces-at-adevinta) | — | — | +| [Admiral](https://getadmiral.com/) | MarTech | Engagement Management | [Webinar Slides, June 2020](https://altinity.com/presentations/2020/06/16/big-data-in-real-time-how-clickhouse-powers-admirals-visitor-relationships-for-publishers) | — | — | +| [Admixer](https://admixer.com/) | Media & Entertainment | Ad Analytics | [Blog Post](https://clickhouse.com/blog/admixer-aggregates-over-1-billion-unique-users-a-day-using-clickhouse) | — | — | +| [Aggregations.io](https://aggregations.io/) | Real-time analytics | Main product | [Twitter](https://twitter.com/jsneedles/status/1734606200199889282) | — | — | +| [Ahrefs](https://ahrefs.com/) | SEO | Analytics | [Job listing](https://ahrefs.com/jobs/data-scientist-search) | Main cluster is 100k+ CPU cores, 800TB RAM. | 110PB NVME storage, uncompressed data size on main cluster is 1EB. | | [Airfold](https://www.airfold.co/) | API platform | Main Product | [Documentation](https://docs.airfold.co/workspace/pipes) | — | — | -| [Aiven](https://aiven.io/) | Cloud data platform | Managed Service | [Blog post](https://aiven.io/blog/introduction—to—clickhouse) | — | — | -| [Akamai](https://www.akamai.com/) | Software & Technology | CDN | [LinkedIn](https://www.linkedin.com/in/david—piatek—bb27368/) | — | — | +| [Aiven](https://aiven.io/) | Cloud data platform | Managed Service | [Blog post](https://aiven.io/blog/introduction-to-clickhouse) | — | — | +| [Akamai](https://www.akamai.com/) | Software & Technology | CDN | [LinkedIn](https://www.linkedin.com/in/david-piatek-bb27368/) | — | — | | [Akvorado](https://demo.akvorado.net/) | Network Monitoring | Main Product | [Documentation](https://demo.akvorado.net/docs/intro) | — | — | | [Alauda](https://alauda.io) | Software & Technology | Analytics, Logs | [Alauda, November 2024](https://www.alauda.io) | — | — | | [AlgoNode](https://algonode.io/) | Software & Technology | Algorand Hosting | [Twitter, April 2023](https://twitter.com/AlgoNode_io/status/1650594948998213632) | — | — | -| [Alibaba Cloud](https://cn.aliyun.com/) | Cloud | E—MapReduce | [Official Website](https://help.aliyun.com/document_detail/212195.html) | — | — | +| [Alibaba Cloud](https://cn.aliyun.com/) | Cloud | E-MapReduce | [Official Website](https://help.aliyun.com/document_detail/212195.html) | — | — | | [Alibaba Cloud](https://cn.aliyun.com/) | Cloud | Managed Service | [Official Website](https://help.aliyun.com/product/144466.html) | — | — | | [Aloha Browser](https://alohabrowser.com/) | Mobile App | Browser backend | [Slides in Russian, May 2019](https://presentations.clickhouse.com/meetup22/aloha.pdf) | — | — | | [Altinity](https://altinity.com/) | Cloud, SaaS | Main product | [Official Website](https://altinity.com/) | — | — | -| [Amadeus](https://amadeus.com/) | Travel | Analytics | [Press Release, April 2018](https://www.altinity.com/blog/2018/4/5/amadeus—technologies—launches—investment—and—insights—tool—based—on—machine—learning—and—strategy—algorithms) | — | — | -| [AMP](https://useamp.com/) | Software & Technology | e—Commerce Metrics | [Twitter Post, May 2024](https://x.com/pc_barnes/status/1793846059724357832) [Meetup Slides](https://github.com/ClickHouse/clickhouse—presentations/blob/master/2024—meetup—melbourne—2/Talk%20Track%201%20—%20AMP's%20data%20journey%20from%20OSS%20to%20ClickHouse%20Cloud%20—%20Chris%20Lawrence%20.pdf) | — | — | +| [Amadeus](https://amadeus.com/) | Travel | Analytics | [Press Release, April 2018](https://www.altinity.com/blog/2018/4/5/amadeus-technologies-launches-investment-and-insights-tool-based-on-machine-learning-and-strategy-algorithms) | — | — | +| [AMP](https://useamp.com/) | Software & Technology | e-Commerce Metrics | [Twitter Post, May 2024](https://x.com/pc_barnes/status/1793846059724357832) [Meetup Slides](https://github.com/ClickHouse/clickhouse-presentations/blob/master/2024-meetup-melbourne-2/Talk%20Track%201%20-%20AMP's%20data%20journey%20from%20OSS%20to%20ClickHouse%20Cloud%20-%20Chris%20Lawrence%20.pdf) | — | — | | [Android Hub](https://bestforandroid.com/) | Blogging, Analytics, Advertising data | — | [Official Website](https://bestforandroid.com/) | — | — | | [AnswerAI](https://www.answerai.co.uk/) | Software & Technology | AI Customer Support | [Twitter, May 2024](https://twitter.com/TomAnswerAi/status/1791062219678998880) | — | — | | [Anton](https://anton.tools/) | Software & Technology | Blockchain Indexer | [GitHub](https://github.com/tonindexer/anton) | — | — | -| [Antrea](https://antrea.io/) | Software & Technology | Kubernetes Network Security | [Documentation](https://antrea.io/docs/main/docs/network—flow—visibility/) | — | — | -| [ApiRoad](https://apiroad.net/) | API marketplace | Analytics | [Blog post, November 2018, March 2020](https://pixeljets.com/blog/clickhouse—vs—elasticsearch/) | — | — | +| [Antrea](https://antrea.io/) | Software & Technology | Kubernetes Network Security | [Documentation](https://antrea.io/docs/main/docs/network-flow-visibility/) | — | — | +| [ApiRoad](https://apiroad.net/) | API marketplace | Analytics | [Blog post, November 2018, March 2020](https://pixeljets.com/blog/clickhouse-vs-elasticsearch/) | — | — | | [Apitally](https://apitally.io/) | Software & Technology | API Monitoring | [Twitter, March 2024](https://twitter.com/simongurcke/status/1766005582971170926) | — | — | | [Appsflyer](https://www.appsflyer.com) | Mobile analytics | Main product | [Talk in Russian, July 2019](https://www.youtube.com/watch?v=M3wbRlcpBbY) | — | — | -| [Aptabase](https://aptabase.com/) | Analytics | Privacy—first / open—source Firebase Analytics alternative | [GitHub Repository](https://github.com/aptabase/aptabase/tree/main/etc/clickhouse) | — | — | -| [ArenaData](https://arenadata.tech/) | Data Platform | Main product | [Slides in Russian, December 2019](https://github.com/ClickHouse/clickhouse—presentations/blob/master/meetup38/indexes.pdf) | — | — | +| [Aptabase](https://aptabase.com/) | Analytics | Privacy-first / open-source Firebase Analytics alternative | [GitHub Repository](https://github.com/aptabase/aptabase/tree/main/etc/clickhouse) | — | — | +| [ArenaData](https://arenadata.tech/) | Data Platform | Main product | [Slides in Russian, December 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup38/indexes.pdf) | — | — | | [Argedor](https://www.argedor.com/en/clickhouse/) | ClickHouse support | — | [Official website](https://www.argedor.com/en/clickhouse/) | — | — | | [Atani](https://atani.com/en/) | Software & Technology | Crypto Platform | [CTO LinkedIn](https://www.linkedin.com/in/fbadiola/) | — | — | -| [Attentive](https://www.attentive.com/) | Email Marketing | Main product | [Blog Post](https://clickhouse.com/blog/confoundingly—fast—inside—attentives—migration—to—clickhouse) | — | — | -| [Astronomer](https://www.astronomer.io/) | Software & Technology | Observability | [Slide Deck](https://github.com/ClickHouse/clickhouse—presentations/blob/master/2024—meetup—san—francisco/2024.12.09%20Clickhouse%20_%20Powering%20Astro%20Observe%20with%20Clickhouse.pdf) | — | — | +| [Attentive](https://www.attentive.com/) | Email Marketing | Main product | [Blog Post](https://clickhouse.com/blog/confoundingly-fast-inside-attentives-migration-to-clickhouse) | — | — | +| [Astronomer](https://www.astronomer.io/) | Software & Technology | Observability | [Slide Deck](https://github.com/ClickHouse/clickhouse-presentations/blob/master/2024-meetup-san-francisco/2024.12.09%20Clickhouse%20_%20Powering%20Astro%20Observe%20with%20Clickhouse.pdf) | — | — | | [Autoblocks](https://autoblocks.ai) | Software & Technology | LLM Monitoring & Deployment | [Twitter, August 2023](https://twitter.com/nolte_adam/status/1690722237953794048) | — | — | | [Aviso](https://www.aviso.com/) | AI Platform | Reporting | ClickHouse Cloud user | — | — | | [Avito](https://avito.ru/) | Classifieds | Monitoring | [Meetup, April 2020](https://www.youtube.com/watch?v=n1tm4j4W8ZQ) | — | — | -| [Axis Communications](https://www.axis.com/en—ca) | Video surveillance | Main product | [Blog post](https://engineeringat.axis.com/schema—changes—clickhouse/) | — | — | +| [Axis Communications](https://www.axis.com/en-ca) | Video surveillance | Main product | [Blog post](https://engineeringat.axis.com/schema-changes-clickhouse/) | — | — | | [Azura](https://azura.xyz/) | Crypto | Analytics | [Meetup Video](https://youtu.be/S3uroekuYuQ) | — | — | -| [AzurePrice](https://azureprice.net/) | Analytics | Main Product | [Blog, November 2022](https://blog.devgenius.io/how—i—migrate—to—clickhouse—and—speedup—my—backend—7x—and—decrease—cost—by—6x—part—1—2553251a9059) | — | — | -| [AzurGames](https://azurgames.com/) | Gaming | Analytics | [AWS Blog, Aug 2024](https://aws.amazon.com/blogs/gametech/azur—games—migrates—all—game—analytics—data—to—clickhouse—cloud—on—aws/) | — | — | -| [B2Metric](https://b2metric.com/) | Marketing | Analytics | [ProductHunt, July 2023](https://www.producthunt.com/posts/b2metric—decision—intelligence?bc=1) | — | — | +| [AzurePrice](https://azureprice.net/) | Analytics | Main Product | [Blog, November 2022](https://blog.devgenius.io/how-i-migrate-to-clickhouse-and-speedup-my-backend-7x-and-decrease-cost-by-6x-part-1-2553251a9059) | — | — | +| [AzurGames](https://azurgames.com/) | Gaming | Analytics | [AWS Blog, Aug 2024](https://aws.amazon.com/blogs/gametech/azur-games-migrates-all-game-analytics-data-to-clickhouse-cloud-on-aws/) | — | — | +| [B2Metric](https://b2metric.com/) | Marketing | Analytics | [ProductHunt, July 2023](https://www.producthunt.com/posts/b2metric-decision-intelligence?bc=1) | — | — | | [BIGO](https://www.bigo.sg/) | Video | Computing Platform | [Blog Article, August 2020](https://www.programmersought.com/article/44544895251/) | — | — | | [Badoo](https://badoo.com) | Dating | Time series | [Slides in Russian, December 2019](https://presentations.clickhouse.com/meetup38/forecast.pdf) | — | 1.6 mln events/sec (2018) | | [Baidu](https://www.baidu.com/) | Internet services | Data warehousing | [GitHub](https://github.com/ClickHouse/ClickHouse/pull/60361) | — | — | | [Baselime](https://baselime.io/) | Software & Technology | Observability for Serverless | [Official website](https://baselime.io/) | — | — | | [Basic RUM](https://www.basicrum.com/) | Software & Technology | Real User Monitoring | [Official website](https://www.basicrum.com/) | — | — | -| [Beehiiv](https://www.beehiiv.com/) | Marketing | Analytics | [Blog, Aug 2024](https://clickhouse.com/blog/data—hive—the—story—of—beehiivs—journey—from—postgres—to—clickhouse) | — | — | +| [Beehiiv](https://www.beehiiv.com/) | Marketing | Analytics | [Blog, Aug 2024](https://clickhouse.com/blog/data-hive-the-story-of-beehiivs-journey-from-postgres-to-clickhouse) | — | — | | [Beeline](https://beeline.ru/) | Telecom | Data Platform | [Blog post, July 2021](https://habr.com/en/company/beeline/blog/567508/) | — | — | -| [Beekeeper](https://www.beekeeper.io/) | Workforce Enablement | Analytics | [Blog post, April 2024](https://www.meetup.com/clickhouse—switzerland—meetup—group/events/299628922) | — | — | -| [Beetested](https://www.beetested.com/) | Software & Technology | Game Testing | [Case Study, June 2023](https://double.cloud/resources/case—studies/beetested—analyze—millions—of—gamers—emotions—with—doublecloud/) | — | — | -| [Benocs](https://www.benocs.com/) | Network Telemetry and Analytics | Main Product | [Meetup Video, December 2022](https://www.youtube.com/watch?v=48pAVShkeCY&list=PL0Z2YDlm0b3iNDUzpY1S3L_iV4nARda_U&index=12) [Slides, December 2022](https://github.com/ClickHouse/clickhouse—presentations/blob/master/meetup66/Self%20repairing%20processing%20using%20ClickHouse.pdf) [Blog Post, March 2022](https://clickhouse.com/blog/—indexing—for—data—streams—benocs—telco/) [Slides in English, October 2017](https://github.com/ClickHouse/clickhouse—presentations/blob/master/meetup9/lpm.pdf) | — | — | +| [Beekeeper](https://www.beekeeper.io/) | Workforce Enablement | Analytics | [Blog post, April 2024](https://www.meetup.com/clickhouse-switzerland-meetup-group/events/299628922) | — | — | +| [Beetested](https://www.beetested.com/) | Software & Technology | Game Testing | [Case Study, June 2023](https://double.cloud/resources/case-studies/beetested-analyze-millions-of-gamers-emotions-with-doublecloud/) | — | — | +| [Benocs](https://www.benocs.com/) | Network Telemetry and Analytics | Main Product | [Slides, December 2022](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup66/Self%20repairing%20processing%20using%20ClickHouse.pdf) [Blog Post, March 2022](https://clickhouse.com/blog/-indexing-for-data-streams-benocs-telco/) [Slides in English, October 2017](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup9/lpm.pdf) | — | — | | [Bento](https://bento.me/en/home) | Software & Technology | Personal Portfolio | [Twitter, May 2023](https://twitter.com/gubmee/status/1653405962542219264) | — | — | | [Better Stack](https://betterstack.com/) | Cloud, SaaS | Log Management | [Official Website](https://betterstack.com/logtail) | — | — | | [BiliBili](https://www.bilibili.com/) | Video sharing | — | [Blog post, June 2021](https://chowdera.com/2021/06/20210622012241476b.html) | — | — | | [Binom](https://binom.org/) | Analytics | Website analytics | [Twitter, 2023](https://twitter.com/BinomTracker/status/1722948130948206940) | — | — | -| [Bitquery](https://bitquery.io/) | Software & Technology | Blockchain Data Company | [Hacker News, December 2020](https://bitquery.io/blog/blockchain—intelligence—system) | — | — | -| [Bloomberg](https://www.bloomberg.com/) | Finance, Media | Monitoring | [Meetup Video, December 2022](https://www.youtube.com/watch?v=HmJTIrGyVls&list=PL0Z2YDlm0b3iNDUzpY1S3L_iV4nARda_U&index=9) [Slides, December 2022](https://github.com/ClickHouse/clickhouse—presentations/blob/master/meetup67/ClickHouse%20for%20Financial%20Analytics%20—%20Bloomberg.pdf) | — | — | -| [Bloxy](https://bloxy.info) | Blockchain | Analytics | [Slides in Russian, August 2018](https://github.com/ClickHouse/clickhouse—presentations/blob/master/meetup17/4_bloxy.pptx) | — | — | +| [Bitquery](https://bitquery.io/) | Software & Technology | Blockchain Data Company | [Hacker News, December 2020](https://bitquery.io/blog/blockchain-intelligence-system) | — | — | +| [Bloomberg](https://www.bloomberg.com/) | Finance, Media | Monitoring | [Meetup Video, December 2022](https://www.youtube.com/watch?v=HmJTIrGyVls&list=PL0Z2YDlm0b3iNDUzpY1S3L_iV4nARda_U&index=9) [Slides, December 2022](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup67/ClickHouse%20for%20Financial%20Analytics%20-%20Bloomberg.pdf) | — | — | +| [Bloxy](https://bloxy.info) | Blockchain | Analytics | [Slides in Russian, August 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup17/4_bloxy.pptx) | — | — | | [Bonree](https://www.bonree.com/) | Software & Technology | Performance Monitoring & Observability | ClickHouse Meetup in Hangzhou, May 2024 | — | — | | [Bonside](https://www.bonside.com/) | FinTech | — | [Hacker News, July 2023](https://news.ycombinator.com/item?id=36619722) | — | — | -| [BoundaryML](https://www.boundaryml.com/) | Software Development | AI Platform | [Meetup, March 2025](https://youtu.be/DV—zkQUvuPc) | — | — | -| [Botify](https://www.botify.com/) | SaaS | SEO | [Blog Article, September 2022](https://tech.marksblogg.com/billion—taxi—rides—doublecloud—clickhouse.html) | — | — | -| [Braintrust](https://www.usebraintrust.com/) | Software & Technology | Real—time Analytics | [Written Blog from Meetup Video, July 2024](https://clickhouse.com/blog/building—better—ai—products—faster—how—braintrust—uses—clickhouse—for—real—time—data—analysis) | — | — | -| [Braze](https://www.braze.com/) | Software & Technology | Real—time Analytics | [Meetup Video](https://youtu.be/NmEyElaa_xI) | — | — | -| [Buildkite](https://buildkite.com/) | Software & Technology | Real—time analytics | [Wellington meetup, February 2025](https://clickhouse.com/videos/wellington—meetup—buildkite—clickhouse—test—analytics) | — | — | +| [BoundaryML](https://www.boundaryml.com/) | Software Development | AI Platform | [Meetup, March 2025](https://youtu.be/DV-zkQUvuPc) | — | — | +| [Botify](https://www.botify.com/) | SaaS | SEO | [Blog Article, September 2022](https://tech.marksblogg.com/billion-taxi-rides-doublecloud-clickhouse.html) | — | — | +| [Braintrust](https://www.usebraintrust.com/) | Software & Technology | Real-time Analytics | [Written Blog from Meetup Video, July 2024](https://clickhouse.com/blog/building-better-ai-products-faster-how-braintrust-uses-clickhouse-for-real-time-data-analysis) | — | — | +| [Braze](https://www.braze.com/) | Software & Technology | Real-time Analytics | [Meetup Video](https://youtu.be/NmEyElaa_xI) | — | — | +| [Buildkite](https://buildkite.com/) | Software & Technology | Real-time analytics | [Wellington meetup, February 2025](https://clickhouse.com/videos/wellington-meetup-buildkite-clickhouse-test-analytics) | — | — | | [ByConity](https://byconity.github.io/) | Software & Technology | Big Data Analysis Engine | [GitHub](https://github.com/ByConity/ByConity) | — | — | | [Bytedance](https://www.bytedance.com) | Social platforms | — | [The ClickHouse Meetup East, October 2020](https://www.youtube.com/watch?v=ckChUkC3Pns) | — | — | -| [CARTO](https://carto.com/) | Business Intelligence | Geo analytics | [Geospatial processing with ClickHouse](https://carto.com/blog/geospatial—processing—with—clickhouse/) | — | — | -| [CERN](http://public.web.cern.ch/public/) | Research | Experiment | [Press release, April 2012](https://www.yandex.com/company/press_center/press_releases/2012/2012—04—10/) | — | — | -| [CHEQ](https://cheq.ai/) | Software & Technology | GTM Security | [Meetup Video, January 2023](https://www.youtube.com/watch?v=rxIO6w4er3k&list=PL0Z2YDlm0b3iNDUzpY1S3L_iV4nARda_U&index=7) [Slides, January 2023](https://github.com/ClickHouse/clickhouse—presentations/blob/master/meetup68/ClickHouse%20Meetup%20—%20CHEQ.pptx.pdf) | — | — | +| [CARTO](https://carto.com/) | Business Intelligence | Geo analytics | [Geospatial processing with ClickHouse](https://carto.com/blog/geospatial-processing-with-clickhouse/) | — | — | +| [CERN](http://public.web.cern.ch/public/) | Research | Experiment | [Press release, April 2012](https://www.yandex.com/company/press_center/press_releases/2012/2012-04-10/) | — | — | +| [CHEQ](https://cheq.ai/) | Software & Technology | GTM Security | [Meetup Video, January 2023](https://www.youtube.com/watch?v=rxIO6w4er3k&list=PL0Z2YDlm0b3iNDUzpY1S3L_iV4nARda_U&index=7) [Slides, January 2023](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup68/ClickHouse%20Meetup%20-%20CHEQ.pptx.pdf) | — | — | | [Campaign Deputy](https://campaigndeputy.com/) | SaaS | Analytics, Logs | [Twitter, February 2023](https://twitter.com/joshabartley/status/1627669208074014721), [Tweet, July 2023](https://twitter.com/joshabartley/status/1677008728711651331) | — | — | -| [Canopus Networks](https://canopusnetworks.com/) | AI for Telecom | Real—time analytics | [Meetup Presentation](https://github.com/ClickHouse/clickhouse—presentations/blob/master/2024—meetup—sydney/Talk%20Track%201%20—%20Canopus%20Networks.pdf) | — | — | -| [Capgo.app](https://capgo.app/) | App development | Real—time statistics | [Twitter](https://twitter.com/martindonadieu/status/1735728943406219736) | — | — | -| [CardsMobile](https://cardsmobile.ru/) | Finance | Analytics | [VC.ru](https://vc.ru/s/cardsmobile/143449—rukovoditel—gruppy—analiza—dannyh) | — | — | +| [Canopus Networks](https://canopusnetworks.com/) | AI for Telecom | Real-time analytics | [Meetup Presentation](https://github.com/ClickHouse/clickhouse-presentations/blob/master/2024-meetup-sydney/Talk%20Track%201%20-%20Canopus%20Networks.pdf) | — | — | +| [Capgo.app](https://capgo.app/) | App development | Real-time statistics | [Twitter](https://twitter.com/martindonadieu/status/1735728943406219736) | — | — | +| [CardsMobile](https://cardsmobile.ru/) | Finance | Analytics | [VC.ru](https://vc.ru/s/cardsmobile/143449-rukovoditel-gruppy-analiza-dannyh) | — | — | | [Castle](https://castle.io/) | Fraud Detection | Main product | [Community Slack](https://clickhouse.com/slack) | — | — | | [Cato Networks](https://www.catonetworks.com/) | Network Security | Security event analytics | [Full Stack Developers Israel, Jan 2023](https://www.youtube.com/watch?v=Is4TC2gf5EM) | — | 8B (4TB) new events per day | -| [CDN77](https://www.cdn77.com/) | Software & Technology | Content Delivery Network | [GitHub Comment, April 2024](https://github.com/ClickHouse/ClickHouse/issues/61093#issuecomment—2070150654) | — | — | -| [Chainbase](https://chainbase.online/) | Blockchain | Main product | [Documentation](https://docs.chainbase.online/r/data—cloud—studio/data—cloud—api) | — | — | +| [CDN77](https://www.cdn77.com/) | Software & Technology | Content Delivery Network | [GitHub Comment, April 2024](https://github.com/ClickHouse/ClickHouse/issues/61093#issuecomment-2070150654) | — | — | +| [Chainbase](https://chainbase.online/) | Blockchain | Main product | [Documentation](https://docs.chainbase.online/r/data-cloud-studio/data-cloud-api) | — | — | | [ChartMetric](https://chartmetric.com/) | Music Industry | Analytics | [Meetup Video](https://youtu.be/gd1yWbnaalk) | — | — | -| [ChatLayer](https://chatlayer.ai/) | AI virtual assistants | Analytics | [Press Release, December 2021](https://aiven.io/blog/aiven—for—clickhouse—now—generally—available) | — | — | +| [ChatLayer](https://chatlayer.ai/) | AI virtual assistants | Analytics | [Press Release, December 2021](https://aiven.io/blog/aiven-for-clickhouse-now-generally-available) | — | — | | [Checkly](https://www.checklyhq.com/) | Software Development | Analytics | [Twitter, October 2021](https://twitter.com/tim_nolet/status/1445810665743081474?s=20) | — | — | -| [ChelPipe Group](https://chelpipegroup.com/) | Analytics | — | [Blog post, June 2021](https://vc.ru/trade/253172—tyazhelomu—proizvodstvu—user—friendly—sayt—internet—magazin—trub—dlya—chtpz) | — | — | -| [Chroma](https://www.trychroma.com/) | Software & Technology | AI—native embedded database | [GitHub Repository](https://github.com/chroma—core/chroma) [Twitter, February 2023](https://twitter.com/atroyn/status/1625605732644298752) | — | — | -| [CipherStash](https://cipherstash.com/) | Software & Technology | Analytics | [Meetup Presentation](https://github.com/ClickHouse/clickhouse—presentations/blob/master/2024—meetup—sydney/Talk%20Track%203%20—%20CipherStash.pdf) | — | — | -| [Cisco](http://cisco.com/) | Networking | Traffic analysis | [Lightning talk, October 2019](https://youtu.be/—hI1vDR2oPY?t=5057) | — | — | +| [ChelPipe Group](https://chelpipegroup.com/) | Analytics | — | [Blog post, June 2021](https://vc.ru/trade/253172-tyazhelomu-proizvodstvu-user-friendly-sayt-internet-magazin-trub-dlya-chtpz) | — | — | +| [Chroma](https://www.trychroma.com/) | Software & Technology | AI-native embedded database | [GitHub Repository](https://github.com/chroma-core/chroma) [Twitter, February 2023](https://twitter.com/atroyn/status/1625605732644298752) | — | — | +| [CipherStash](https://cipherstash.com/) | Software & Technology | Analytics | [Meetup Presentation](https://github.com/ClickHouse/clickhouse-presentations/blob/master/2024-meetup-sydney/Talk%20Track%203%20-%20CipherStash.pdf) | — | — | +| [Cisco](http://cisco.com/) | Networking | Traffic analysis | [Lightning talk, October 2019](https://youtu.be/-hI1vDR2oPY?t=5057) | — | — | | [Citadel Securities](https://www.citadelsecurities.com/) | Finance | — | [Contribution, March 2019](https://github.com/ClickHouse/ClickHouse/pull/4774) | — | — | -| [Citymobil](https://city—mobil.ru) | Taxi | Analytics | [Blog Post in Russian, March 2020](https://habr.com/en/company/citymobil/blog/490660/) | — | — | +| [Citymobil](https://city-mobil.ru) | Taxi | Analytics | [Blog Post in Russian, March 2020](https://habr.com/en/company/citymobil/blog/490660/) | — | — | | [Clearbit](https://clearbit.com/) | AI | Product usage | ClickHouse Cloud user | — | — | | [ClickFunnels](https://www.clickfunnels.com/) | Website Builder | | ClickHouse Cloud user | — | — | -| [ClickVisual](https://clickvisual.net/) | Software | Logging Platform | [Blog Post, May 2022](https://golangexample.com/a—light—weight—log—visual—analytic—platform—for—clickhouse/) | — | — | +| [ClickVisual](https://clickvisual.net/) | Software | Logging Platform | [Blog Post, May 2022](https://golangexample.com/a-light-weight-log-visual-analytic-platform-for-clickhouse/) | — | — | | [Clog](https://www.hybridlogic.co.uk/) | Software & Technology | Logging | [Blog, February 2023](https://www.hybridlogic.co.uk/2023/02/clog/) | — | — | -| [Cloud Circus, Inc.](https://cloudcircus.jp/) | Software & Technology | Logging | [Tokyo Meetup, January 2025](https://clickhouse.com/videos/tokyo—meetup—cloudcircus—accelerating—cloudfront—log—analysis) | — | — | -| [Cloudflare](https://cloudflare.com) | CDN | Traffic analysis | [Blog post, May 2017](https://blog.cloudflare.com/how—cloudflare—analyzes—1m—dns—queries—per—second/), [Blog post, March 2018](https://blog.cloudflare.com/http—analytics—for—6m—requests—per—second—using—clickhouse/) | 36 servers | — | +| [Cloud Circus, Inc.](https://cloudcircus.jp/) | Software & Technology | Logging | [Tokyo Meetup, January 2025](https://clickhouse.com/videos/tokyo-meetup-cloudcircus-accelerating-cloudfront-log-analysis) | — | — | +| [Cloudflare](https://cloudflare.com) | CDN | Traffic analysis | [Blog post, May 2017](https://blog.cloudflare.com/how-cloudflare-analyzes-1m-dns-queries-per-second/), [Blog post, March 2018](https://blog.cloudflare.com/http-analytics-for-6m-requests-per-second-using-clickhouse/) | 36 servers | — | | [CloudRaft](https://www.cloudraft.io/) | Software & Technology | Consulting Services | [Twitter, May 2024](https://x.com/anjuls/status/1792048331805606156) | — | — | -| [Codegiant](https://codegiant.io/) | Security | Main product | [Blog, December 2023](https://blog.codegiant.io/clickhouse—in—codegiant—observability—ecosystem/) | — | — | -| [Cognitiv](https://cognitiv.ai/) | AdTech | Offline Feature Store | [Blog, Aug 2024](https://clickhouse.com/blog/transforming—ad—tech—how—cognitiv—uses—clickhouse—to—build—better—machine—learning—models) | — | — | -| [Coinhall](https://coinhall.org/) | Web3 | Blockchain Data Platform | [Blog, Aug 2024](https://clickhouse.com/blog/trade—secrets—how—coinhall—uses—clickhouse—to—power—its—blockchain—data—platform) | — | — | -| [Coinpaprika](https://coinpaprika.com/) | Software & Technology | Cryptocurrency Market Data Analysis | [Blog, May 2023](https://clickhouse.com/blog/coinpaprika—aggregates—pricing—data) | — | — | +| [Codegiant](https://codegiant.io/) | Security | Main product | [Blog, December 2023](https://blog.codegiant.io/clickhouse-in-codegiant-observability-ecosystem/) | — | — | +| [Cognitiv](https://cognitiv.ai/) | AdTech | Offline Feature Store | [Blog, Aug 2024](https://clickhouse.com/blog/transforming-ad-tech-how-cognitiv-uses-clickhouse-to-build-better-machine-learning-models) | — | — | +| [Coinhall](https://coinhall.org/) | Web3 | Blockchain Data Platform | [Blog, Aug 2024](https://clickhouse.com/blog/trade-secrets-how-coinhall-uses-clickhouse-to-power-its-blockchain-data-platform) | — | — | +| [Coinpaprika](https://coinpaprika.com/) | Software & Technology | Cryptocurrency Market Data Analysis | [Blog, May 2023](https://clickhouse.com/blog/coinpaprika-aggregates-pricing-data) | — | — | | [Comcast](https://corporate.comcast.com/) | Media | CDN Traffic Analysis | [ApacheCon 2019 Talk](https://www.youtube.com/watch?v=e9TZ6gFDjNg) | — | — | -| [Common Room](https://www.commonroom.io/) | Marketing SaaS | Real—Time Analytics | [Seattle Meetup, March 2024](https://www.youtube.com/watch?v=liTgGiTuhJE) | — | — | -| [Constructor](https://constructor.io/) | E—commerce Search | E—commerce Search | ClickHouse Cloud user | — | — | -| [Constant Contact](https://www.constantcontact.com/) | Marketing Saas | Real—Time Analytics | [Meetup Video](https://youtu.be/6SeEurehp10) | — | — | -| [Contentsquare](https://contentsquare.com) | Web analytics | Main product | [Meetup Video, January 2023](https://www.youtube.com/watch?v=zvuCBAl2T0Q&list=PL0Z2YDlm0b3iNDUzpY1S3L_iV4nARda_U&index=5) [Blog Post, October 2022](https://clickhouse.com/blog/contentsquare—migration—from—elasticsearch—to—clickhouse) [Blog post in French, November 2018](http://souslecapot.net/2018/11/21/patrick—chatain—vp—engineering—chez—contentsquare—penser—davantage—amelioration—continue—que—revolution—constante/) | — | — | +| [Common Room](https://www.commonroom.io/) | Marketing SaaS | Real-Time Analytics | [Seattle Meetup, March 2024](https://www.youtube.com/watch?v=liTgGiTuhJE) | — | — | +| [Constructor](https://constructor.io/) | E-commerce Search | E-commerce Search | ClickHouse Cloud user | — | — | +| [Constant Contact](https://www.constantcontact.com/) | Marketing Saas | Real-Time Analytics | [Meetup Video](https://youtu.be/6SeEurehp10) | — | — | +| [Contentsquare](https://contentsquare.com) | Web analytics | Main product | [Meetup Video, January 2023](https://www.youtube.com/watch?v=zvuCBAl2T0Q&list=PL0Z2YDlm0b3iNDUzpY1S3L_iV4nARda_U&index=5) [Blog Post, October 2022](https://clickhouse.com/blog/contentsquare-migration-from-elasticsearch-to-clickhouse) [Blog post in French, November 2018](http://souslecapot.net/2018/11/21/patrick-chatain-vp-engineering-chez-contentsquare-penser-davantage-amelioration-continue-que-revolution-constante/) | — | — | | [Coroot](https://coroot.com/) | Software & Technology | Observability | [Twitter, July 2023](https://twitter.com/coroot_com/status/1680993372385804288?s=20) | — | — | | [Corsearch](https://corsearch.com/) | Marketing SaaS (Brand Protection) | Main Datastore | [Seattle Meetup, March 2023](https://www.youtube.com/watch?v=BuS8jFL9cvw&list=PL0Z2YDlm0b3iNDUzpY1S3L_iV4nARda_U&index=10) | — | — | -| [Corunet](https://coru.net/) | Analytics | Main product | [Slides in English, April 2019](https://github.com/ClickHouse/clickhouse—presentations/blob/master/meetup21/predictive_models.pdf) | — | — | +| [Corunet](https://coru.net/) | Analytics | Main product | [Slides in English, April 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup21/predictive_models.pdf) | — | — | | [Covalent](https://www.covalenthq.com/) | Financial — Crypto | Blockchain analysis | ClickHouse Cloud user | — | — | -| [CraiditX 氪信](https://www.creditx.com) | Finance AI | Analysis | [Slides in English, November 2019](https://github.com/ClickHouse/clickhouse—presentations/blob/master/meetup33/udf.pptx) | — | — | +| [CraiditX 氪信](https://www.creditx.com) | Finance AI | Analysis | [Slides in English, November 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup33/udf.pptx) | — | — | | [Craigslist](https://sfbay.craigslist.org/) | Classifieds | Rate limiting (Redis replacement) | [SF Meetup, March 2024](https://www.youtube.com/watch?v=wRwqrbUjRe4&list=PL0Z2YDlm0b3iNDUzpY1S3L_iV4nARda_U&index=9) | — | — | | [Crazypanda](https://crazypanda.ru/en/) | Games | | Live session on ClickHouse meetup | — | — | -| [Criteo](https://www.criteo.com/) | Retail | Main product | [Slides in English, October 2018](https://github.com/ClickHouse/clickhouse—presentations/blob/master/meetup18/3_storetail.pptx) | — | — | +| [Criteo](https://www.criteo.com/) | Retail | Main product | [Slides in English, October 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup18/3_storetail.pptx) | — | — | | [Cryptology](https://cryptology.com/) | Digital Assets Trading Platform | — | [Job advertisement, March 2021](https://career.habr.com/companies/cryptology/vacancies) | — | — | | [Culver Max Entertainment/Sony Pictures](https://www.sonypicturesnetworks.com/overview) | Television/Entertainment | Media streaming analytics | ClickHouse Cloud user | — | — | -| [Cumul.io](https://www.cumul.io) | Software & Technology | Customer Analytics | [Blog Post, June 2022](https://clickhouse.com/blog/optimizing—your—customer—facing—analytics—experience—with—cumul—io—and—clickhouse) | — | — | +| [Cumul.io](https://www.cumul.io) | Software & Technology | Customer Analytics | [Blog Post, June 2022](https://clickhouse.com/blog/optimizing-your-customer-facing-analytics-experience-with-cumul-io-and-clickhouse) | — | — | | [DB Pilot](https://www.dbpilot.io/) | Software & Technology | Database GUI | [Twitter, August 2023](https://twitter.com/dennis_hellweg/status/1701349566354686143) | — | — | -| [DENIC](https://www.denic.de/) | Software & Technology | Data Science Analytics | [Blog Post, May 2022](https://clickhouse.com/blog/denic—improves—query—times—by—10x—with—clickhouse) | — | — | +| [DENIC](https://www.denic.de/) | Software & Technology | Data Science Analytics | [Blog Post, May 2022](https://clickhouse.com/blog/denic-improves-query-times-by-10x-with-clickhouse) | — | — | | [DNSMonster](https://dnsmonster.dev/) | Software & Technology | DNS Monitoring | [GitHub Repository](https://github.com/mosajjal/dnsmonster) | — | — | -| [Darwinium](https://www.darwinium.com/) | Software & Technology | Security and Fraud Analytics | [Blog Post, July 2022](https://clickhouse.com/blog/fast—feature—rich—and—mutable—clickhouse—powers—darwiniums—security—and—fraud—analytics—use—cases) | — | — | -| [Dash0](https://www.dash0.com/) | APM Platform | Main product | [Careers page](https://careers.dash0.com/senior—product—engineer—backend/en) | — | — | +| [Darwinium](https://www.darwinium.com/) | Software & Technology | Security and Fraud Analytics | [Blog Post, July 2022](https://clickhouse.com/blog/fast-feature-rich-and-mutable-clickhouse-powers-darwiniums-security-and-fraud-analytics-use-cases) | — | — | +| [Dash0](https://www.dash0.com/) | APM Platform | Main product | [Careers page](https://careers.dash0.com/senior-product-engineer-backend/en) | — | — | | [Dashdive](https://www.dashdive.com/) | Infrastructure management | Analytics | [Hacker News, 2024](https://news.ycombinator.com/item?id=39178753) | — | — | -| [Dassana](https://lake.dassana.io/) | Cloud data platform | Main product | [Blog Post, Jan 2023](https://clickhouse.com/blog/clickhouse—powers—dassanas—security—data—lake) [Direct reference, April 2022](https://news.ycombinator.com/item?id=31111432) | — | — | +| [Dassana](https://lake.dassana.io/) | Cloud data platform | Main product | [Blog Post, Jan 2023](https://clickhouse.com/blog/clickhouse-powers-dassanas-security-data-lake) [Direct reference, April 2022](https://news.ycombinator.com/item?id=31111432) | — | — | | [Datafold](https://www.datafold.com/) | Data Reliability Platform | — | [Job advertisement, April 2022](https://www.datafold.com/careers) | — | — | -| [Dataliance for China Telecom](https://www.chinatelecomglobal.com/) | Telecom | Analytics | [Slides in Chinese, January 2018](https://github.com/ClickHouse/clickhouse—presentations/blob/master/meetup12/telecom.pdf) | — | — | +| [Dataliance for China Telecom](https://www.chinatelecomglobal.com/) | Telecom | Analytics | [Slides in Chinese, January 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup12/telecom.pdf) | — | — | | [DeepFlow](https://deepflow.io) | Software & Technology | Observability | [GitHub](https://github.com/deepflowio/deepflow) | — | — | -| [DeepL](https://www.deepl.com/) | Machine Learning | — | [Blog Post, July 2022](https://clickhouse.com/blog/deepls—journey—with—clickhouse) [Video, October 2021](https://www.youtube.com/watch?v=WIYJiPwxXdM&t=1182s) | — | — | +| [DeepL](https://www.deepl.com/) | Machine Learning | — | [Blog Post, July 2022](https://clickhouse.com/blog/deepls-journey-with-clickhouse) [Video, October 2021](https://www.youtube.com/watch?v=WIYJiPwxXdM&t=1182s) | — | — | | [Deepglint 格灵深瞳](https://www.deepglint.com/) | AI, Computer Vision | OLAP | [Official Website](https://www.deepglint.com/) | — | — | | [Deeplay](https://deeplay.io/eng/) | Gaming Analytics | — | [Job advertisement, 2020](https://career.habr.com/vacancies/1000062568) | — | — | | [Depot](https://depot.dev/) | Software & Technology | CI & Build Acceleration | [Twitter, April 2024](https://twitter.com/jacobwgillespie/status/1778463642150695048) | — | — | -| [Deutsche Bank](https://db.com) | Finance | BI Analytics | [Meetup Video, December 2022](https://www.youtube.com/watch?v=O3GJ6jag3Hc&list=PL0Z2YDlm0b3iNDUzpY1S3L_iV4nARda_U&index=11) [Slides in English, October 2019](https://bigdatadays.ru/wp—content/uploads/2019/10/D2—H3—3_Yakunin—Goihburg.pdf) | — | — | +| [Deutsche Bank](https://db.com) | Finance | BI Analytics | [Meetup Video, December 2022](https://www.youtube.com/watch?v=O3GJ6jag3Hc&list=PL0Z2YDlm0b3iNDUzpY1S3L_iV4nARda_U&index=11) [Slides in English, October 2019](https://bigdatadays.ru/wp-content/uploads/2019/10/D2-H3-3_Yakunin-Goihburg.pdf) | — | — | | [DevHubStack](http://devhubstack.com/) | Software & Technology | Community Management | [Twitter, May 2024](https://twitter.com/thedevhubstack/status/1790655455229771789) | — | — | -| [DeWu Poizon](https://www.dewu.com/) | E—commerce | Real—Time Analytics | [Blog, March 2025](https://clickhouse.com/blog/observing—in—style—how—poizon—rebuilt—its—data—platform—with—clickhouse—enterprise—edition) | — | — | -| [Didi](https://web.didiglobal.com/) | Transportation & Ride Sharing | Observability | [Blog, Apr 2024](https://clickhouse.com/blog/didi—migrates—from—elasticsearch—to—clickHouse—for—a—new—generation—log—storage—system) | 400+ logging, 40 tracing | PBs/day / 40GB/s write throughput, 15M queries/day, 200 QPS peak | +| [DeWu Poizon](https://www.dewu.com/) | E-commerce | Real-Time Analytics | [Blog, March 2025](https://clickhouse.com/blog/observing-in-style-how-poizon-rebuilt-its-data-platform-with-clickhouse-enterprise-edition) | — | — | +| [Didi](https://web.didiglobal.com/) | Transportation & Ride Sharing | Observability | [Blog, Apr 2024](https://clickhouse.com/blog/didi-migrates-from-elasticsearch-to-clickHouse-for-a-new-generation-log-storage-system) | 400+ logging, 40 tracing | PBs/day / 40GB/s write throughput, 15M queries/day, 200 QPS peak | | [DigiCert](https://www.digicert.com) | Network Security | DNS Platform | [Job posting, Aug 2022](https://www.indeed.com/viewjob?t=Senior+Principal+Software+Engineer+Architect&c=DigiCert&l=Lehi,+UT&jk=403c35f96c46cf37&rtk=1g9mnof7qk7dv800) | — | over 35 billion events per day | -| [Disney+](https://www.disneyplus.com/) | Video Streaming | Analytics | [Meetup Video, December 2022](https://www.youtube.com/watch?v=CVVp6N8Xeoc&list=PL0Z2YDlm0b3iNDUzpY1S3L_iV4nARda_U&index=8) [Slides, December 2022](https://github.com/ClickHouse/clickhouse—presentations/blob/master/meetup67/Disney%20plus%20ClickHouse.pdf) | — | 395 TiB | +| [Disney+](https://www.disneyplus.com/) | Video Streaming | Analytics | [Meetup Video, December 2022](https://www.youtube.com/watch?v=CVVp6N8Xeoc&list=PL0Z2YDlm0b3iNDUzpY1S3L_iV4nARda_U&index=8) [Slides, December 2022](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup67/Disney%20plus%20ClickHouse.pdf) | — | 395 TiB | | [Dittofeed](https://dittofeed.com/) | Software & Technology | Open Source Customer Engagement | [Hacker News, June 2023](https://news.ycombinator.com/item?id=36061344) | — | — | -| [Diva—e](https://www.diva—e.com) | Digital consulting | Main Product | [Slides in English, September 2019](https://github.com/ClickHouse/clickhouse—presentations/blob/master/meetup29/ClickHouse—MeetUp—Unusual—Applications—sd—2019—09—17.pdf) | — | — | -| [Dolphin Emulator](https://dolphin—emu.org/) | Games | Analytics | [Twitter, September 2022](https://twitter.com/delroth_/status/1567300096160665601) | — | — | -| [DoorDash](https://www.doordash.com/home) | E—commerce | Monitoring | [Meetup, December 2024](https://github.com/ClickHouse/clickhouse—presentations/blob/master/2024—meetup—san—francisco/Clickhouse%20Meetup%20Slides%20(1).pdf) | — | — | -| [Dopple.io](https://dolphin—emu.org/) | E—commerce | 3D Analytics | [Meetup, September 2024](https://docs.google.com/presentation/d/1_i7H1EIfEttPKtP9CCAB_4Ajs_Li4N6S/edit#slide=id.p4) | — | — | -| [DotSentry](https://forum.polkadot.network/t/dotsentry—ecosystem—wide—monitoring—solution/8210) | Software & Technology | Monitoring for Polkadot Ecosystem | [Forum Post, May 2024](https://forum.polkadot.network/t/dotsentry—ecosystem—wide—monitoring—solution/8210) | — | — | +| [Diva-e](https://www.diva-e.com) | Digital consulting | Main Product | [Slides in English, September 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup29/ClickHouse-MeetUp-Unusual-Applications-sd-2019-09-17.pdf) | — | — | +| [Dolphin Emulator](https://dolphin-emu.org/) | Games | Analytics | [Twitter, September 2022](https://twitter.com/delroth_/status/1567300096160665601) | — | — | +| [DoorDash](https://www.doordash.com/home) | E-commerce | Monitoring | [Meetup, December 2024](https://github.com/ClickHouse/clickhouse-presentations/blob/master/2024-meetup-san-francisco/Clickhouse%20Meetup%20Slides%20(1).pdf) | — | — | +| [Dopple.io](https://dolphin-emu.org/) | E-commerce | 3D Analytics | [Meetup, September 2024](https://docs.google.com/presentation/d/1_i7H1EIfEttPKtP9CCAB_4Ajs_Li4N6S/edit#slide=id.p4) | — | — | +| [DotSentry](https://forum.polkadot.network/t/dotsentry-ecosystem-wide-monitoring-solution/8210) | Software & Technology | Monitoring for Polkadot Ecosystem | [Forum Post, May 2024](https://forum.polkadot.network/t/dotsentry-ecosystem-wide-monitoring-solution/8210) | — | — | | [DrDroid](https://www.drdroid.io/) | Software & Technology | Monitoring | [Slack, August 2023](https://clickhousedb.slack.com/archives/C04N3AU38DV/p1694151014185729) | — | — | | [Duckbill Group](https://www.duckbillgroup.com/) | Software & Technology | — | [Twitter, May 2024](https://twitter.com/mike_julian/status/1789737184192315876) | — | — | -| [eBay](https://www.ebay.com/) | E—commerce | Logs, Metrics and Events | [Official website, Sep 2020](https://tech.ebayinc.com/engineering/ou—online—analytical—processing/) | — | — | +| [eBay](https://www.ebay.com/) | E-commerce | Logs, Metrics and Events | [Official website, Sep 2020](https://tech.ebayinc.com/engineering/ou-online-analytical-processing/) | — | — | | [Ecommpay](https://ecommpay.com/) | Payment Processing | Logs | [Video, Nov 2019](https://www.youtube.com/watch?v=d3GdZTOWGLk) | — | — | -| [Ecwid](https://www.ecwid.com/) | E—commerce SaaS | Metrics, Logging | [Slides in Russian, April 2019](https://nastachku.ru/var/files/1/presentation/backend/2_Backend_6.pdf) | — | — | -| [Effodio](https://www.effodio.com/) | Observability, Root cause analysis | Event storage | [Blog, 2024](https://peng.fyi/post/factorial—growth—of—clickhouse—with—clause/) | — | — | +| [Ecwid](https://www.ecwid.com/) | E-commerce SaaS | Metrics, Logging | [Slides in Russian, April 2019](https://nastachku.ru/var/files/1/presentation/backend/2_Backend_6.pdf) | — | — | +| [Effodio](https://www.effodio.com/) | Observability, Root cause analysis | Event storage | [Blog, 2024](https://peng.fyi/post/factorial-growth-of-clickhouse-with-clause/) | — | — | | [Egg](https://github.com/ducc/egg) | Error Aggregation | Main Product | [GitHub repository](https://github.com/ducc/egg) | — | — | -| [Electrum](https://www.electrum.id/) | Technology | Real—time Analytics | [Meetup Blog, October 2024](https://clickhouse.com/videos/driving—jakarta—electric—motorcycle—transformation—with—clickhouse) | — | — | +| [Electrum](https://www.electrum.id/) | Technology | Real-time Analytics | [Meetup Blog, October 2024](https://clickhouse.com/videos/driving-jakarta-electric-motorcycle-transformation-with-clickhouse) | — | — | | [Engage](https://engage.so/) | Software & Technology | Customer Engagement | [Twitter Post, May 2024](https://x.com/kehers/status/1793935987778724038) | — | — | -| [Embrace](https://embrace.io/) | Observability | Logs | [Blog post, June 2024](https://embrace.io/blog/solving—large—logs—with—clickhouse/) | — | — | -| [Ensemble](https://ensembleanalytics.io/) | Analytics | Analytics | [Official website, Sep 2020](https://ensembleanalytics.io/blog/why—we—went—all—in—clickhouse) | — | — | +| [Embrace](https://embrace.io/) | Observability | Logs | [Blog post, June 2024](https://embrace.io/blog/solving-large-logs-with-clickhouse/) | — | — | +| [Ensemble](https://ensembleanalytics.io/) | Analytics | Analytics | [Official website, Sep 2020](https://ensembleanalytics.io/blog/why-we-went-all-in-clickhouse) | — | — | | [EventBunker.io](https://www.eventbunker.io/) | Serverless Data Processing | — | [Twitter, April 2021](https://twitter.com/Halil_D_/status/1379839133472985091) | — | — | -| [ExitLag](http://www.exitlag.com/) | Software & Technology | Gaming Data Routing | [Blog, June 2023](https://clickhouse.com/blog/boosting—game—performance—exitlag—quest—for—a—better—data—management—system) | — | — | -| [ExitLag](https://www.exitlag.com/) | Software & Technology | Optimized Gaming Experience | [ClickHouse Blog, June 2023](https://clickhouse.com/blog/boosting—game—performance—exitlag—quest—for—a—better—data—management—system) | — | — | -| [Exness](https://www.exness.com/) | Trading | Metrics, Logging | [Talk in Russian, May 2019](https://youtu.be/_rpU—TvSfZ8?t=3215) | — | — | +| [ExitLag](http://www.exitlag.com/) | Software & Technology | Gaming Data Routing | [Blog, June 2023](https://clickhouse.com/blog/boosting-game-performance-exitlag-quest-for-a-better-data-management-system) | — | — | +| [ExitLag](https://www.exitlag.com/) | Software & Technology | Optimized Gaming Experience | [ClickHouse Blog, June 2023](https://clickhouse.com/blog/boosting-game-performance-exitlag-quest-for-a-better-data-management-system) | — | — | +| [Exness](https://www.exness.com/) | Trading | Metrics, Logging | [Talk in Russian, May 2019](https://youtu.be/_rpU-TvSfZ8?t=3215) | — | — | | [Explo](https://www.explo.co/) | Analytics | — | [Meetup Video](https://youtu.be/FZyPvKpFiDk) | — | — | -| [Fastly](https://www.fastly.com/) | Internet Services | Metrics (Graphite replacement) | [Boston Meetup, Dec 2023](https://clickhouse.com/videos/scaling—graphite—with—clickhouse) | — | — | -| [FastNetMon](https://fastnetmon.com/) | DDoS Protection | Main Product | [Official website](https://fastnetmon.com/docs—fnm—advanced/fastnetmon—advanced—traffic—persistency/) | | — | +| [Fastly](https://www.fastly.com/) | Internet Services | Metrics (Graphite replacement) | [Boston Meetup, Dec 2023](https://clickhouse.com/videos/scaling-graphite-with-clickhouse) | — | — | +| [FastNetMon](https://fastnetmon.com/) | DDoS Protection | Main Product | [Official website](https://fastnetmon.com/docs-fnm-advanced/fastnetmon-advanced-traffic-persistency/) | | — | | [Fastnear](https://fastnear.com/) | Infrastructure | Main product | [Twitter, 2024](https://twitter.com/ekuzyakov/status/1762500731154698421) | — | — | | [FeatBit](https://www.featbit.co/) | Software & Technology | Feature Flag Management | [GitHub, August 2023](https://github.com/featbit/featbit) | — | — | | [FinBox](https://finbox.in/) | Software & Technology | Financial Services | [Slack](https://clickhousedb.slack.com/archives/C04N3AU38DV/p1688198501884219) | — | — | -| [Fingerprint](https://fingerprint.com/) | Fraud detection | Fraud detection | [Meetup](https://www.linkedin.com/posts/system29a_clickhouse—meetup—in—berlin—tue—may—16—activity—7063805876570050561—UE—n/) | — | — | -| [Firebolt](https://www.firebolt.io/) | Analytics | Main product | [VLDB 2022 paper](https://www.firebolt.io/content/firebolt—vldb—cdms—2022), [VLDB 2022 slides](https://cdmsworkshop.github.io/2022/Slides/Fri_C2.5_MoshaPasumansky.pdf) | — | — | +| [Fingerprint](https://fingerprint.com/) | Fraud detection | Fraud detection | [Meetup](https://www.linkedin.com/posts/system29a_clickhouse-meetup-in-berlin-tue-may-16-activity-7063805876570050561-UE-n/) | — | — | +| [Firebolt](https://www.firebolt.io/) | Analytics | Main product | [VLDB 2022 paper](https://www.firebolt.io/content/firebolt-vldb-cdms-2022), [VLDB 2022 slides](https://cdmsworkshop.github.io/2022/Slides/Fri_C2.5_MoshaPasumansky.pdf) | — | — | | [Fl0](https://www.fl0.com/) | Cloud | Server management | [Meetup presentation](https://presentations.clickhouse.com/?path=meetup94) | — | — | -| [Flipkart](https://www.flipkart.com/) | e—Commerce | — | [Talk in English, July 2020](https://youtu.be/GMiXCMFDMow?t=239) | — | — | -| [Flipt](https://www.flipt.io/) | Software | Software development management | [Blog, 2024](https://www.flipt.io/blog/analytics—with—clickhouse) | — | — | -| [Flock Safety](https://www.flocksafety.com/) | Crime Surveillance | Real Time Traffic Analytics | [Meetup,December 2024](https://github.com/ClickHouse/clickhouse—presentations/blob/master/2024—meetup—new—york/flock—safety—clickhouse—presentation.pdf) | — | — | -| [FortiSIEM](https://www.fortinet.com/) | Information Security | Supervisor and Worker | [Documentation](https://help.fortinet.com/fsiem/6—6—0/Online—Help/HTML5_Help/clickhouse_config.htm) | — | — | -| [Fortis Games](https://fortisgames.com/) | Game studio | Online data analytics | [Blog post, July 2023](https://thenewstack.io/a—real—time—data—platform—for—player—driven—game—experiences/) | — | — | -| [Foxway](https://www.foxway.com/en/) | Software & Technology | e—Commerce | [ClickHouse Meetup, April 2024](https://twitter.com/ClickHouseDB/status/1782833838886121492) | — | — | +| [Flipkart](https://www.flipkart.com/) | e-Commerce | — | [Talk in English, July 2020](https://youtu.be/GMiXCMFDMow?t=239) | — | — | +| [Flipt](https://www.flipt.io/) | Software | Software development management | [Blog, 2024](https://www.flipt.io/blog/analytics-with-clickhouse) | — | — | +| [Flock Safety](https://www.flocksafety.com/) | Crime Surveillance | Real Time Traffic Analytics | [Meetup,December 2024](https://github.com/ClickHouse/clickhouse-presentations/blob/master/2024-meetup-new-york/flock-safety-clickhouse-presentation.pdf) | — | — | +| [FortiSIEM](https://www.fortinet.com/) | Information Security | Supervisor and Worker | [Documentation](https://help.fortinet.com/fsiem/6-6-0/Online-Help/HTML5_Help/clickhouse_config.htm) | — | — | +| [Fortis Games](https://fortisgames.com/) | Game studio | Online data analytics | [Blog post, July 2023](https://thenewstack.io/a-real-time-data-platform-for-player-driven-game-experiences/) | — | — | +| [Foxway](https://www.foxway.com/en/) | Software & Technology | e-Commerce | [ClickHouse Meetup, April 2024](https://twitter.com/ClickHouseDB/status/1782833838886121492) | — | — | | [Friendly Captcha](https://friendlycaptcha.com) | Bot Protection | — | [Job Posting, Aug 2022](https://news.ycombinator.com/item?id=32311825) | — | — | -| [FunCorp](https://fun.co/rp) | Games | | [Article](https://www.altinity.com/blog/migrating—from—redshift—to—clickhouse) | — | 14 bn records/day as of Jan 2021 | +| [FunCorp](https://fun.co/rp) | Games | | [Article](https://www.altinity.com/blog/migrating-from-redshift-to-clickhouse) | — | 14 bn records/day as of Jan 2021 | | [Futurra Group](https://futurragroup.com/) | Analytics | — | [Article in Russian, December 2021](https://dou.ua/forums/topic/35587/) | — | — | -| [G—Core Labs](https://gcorelabs.com/) | Security | Main product | [Job posting, May 2022](https://careers.gcorelabs.com/jobs/Careers) | — | — | -| [Galaxy—Future](https://www.galaxy—future.com/en/home) | Software & Technology | Metric Monitoring & Measurement | [CudgX GitHub Repository](https://github.com/galaxy—future/cudgx) | — | — | +| [G-Core Labs](https://gcorelabs.com/) | Security | Main product | [Job posting, May 2022](https://careers.gcorelabs.com/jobs/Careers) | — | — | +| [Galaxy-Future](https://www.galaxy-future.com/en/home) | Software & Technology | Metric Monitoring & Measurement | [CudgX GitHub Repository](https://github.com/galaxy-future/cudgx) | — | — | | [Geniee](https://geniee.co.jp) | Ad network | Main product | [Blog post in Japanese, July 2017](https://tech.geniee.co.jp/entry/2017/07/20/160100) | — | — | | [Genotek](https://www.genotek.ru/) | Bioinformatics | Main product | [Video, August 2020](https://youtu.be/v3KyZbz9lEE) | — | — | | [Gigapipe](https://gigapipe.com/) | Managed ClickHouse | Main product | [Official website](https://gigapipe.com/) | — | — | | [Gigasheet](https://gigasheet.co/) | Analytics | Main product | Direct Reference, February 2022 | — | — | -| [GitLab](https://gitlab.com/) | Code and DevOps | APM | [Official website](https://gitlab.com/gitlab—org/incubation—engineering/apm/apm) | — | — | +| [GitLab](https://gitlab.com/) | Code and DevOps | APM | [Official website](https://gitlab.com/gitlab-org/incubation-engineering/apm/apm) | — | — | | [Glaber](https://glaber.io/) | Monitoring | Main product | [Website](https://glaber.io/) | — | — | | [Glenrose Group](https://www.glenrosegroup.com/) | Expense management | — | [Twitter](https://twitter.com/EncodedRose/status/1706145758897180783) | — | — | -| [Gluten](https://github.com/oap—project/gluten) | Software & Technology | Spark performance | [Github, July 2023](https://github.com/oap—project/gluten) | — | — | +| [Gluten](https://github.com/oap-project/gluten) | Software & Technology | Spark performance | [Github, July 2023](https://github.com/oap-project/gluten) | — | — | | [Goldsky](https://goldsky.com/) | Software & Technology | Blockchain data analytics | [Documentation, July 2023](https://docs.goldsky.com/) | — | — | | [Good Job Games](https://goodjobgames.com/) | Games | Event Processing | [Job Posting, Aug 2022](https://news.ycombinator.com/item?id=32313170) | — | — | | [Goodpeople](https://twitter.com/_suzychoi/status/1702113350258180245) | Human Resources | OLAP | [Twitter, 2023](https://twitter.com/_suzychoi/status/1702113350258180245) | — | — | | [Gorgias](https://www.gorgias.com/) | Software & Technology | eCommerce Helpdesk Analytics | [ClickHouse Slack, April 2023](https://clickhousedb.slack.com/archives/C04N3AU38DV/p1682502827729909) | — | — | -| [Grafbase](https://grafbase.com/) | Software & Technology | GraphQL API Management | [Blog, June 2023](https://grafbase.com/blog/how—to—build—your—own—realtime—analytics—dashboards) | — | — | -| [GraphCDN](https://graphcdn.io/) | CDN | Traffic Analytics | [Blog Post in English, August 2021](https://altinity.com/blog/delivering—insight—on—graphql—apis—with—clickhouse—at—graphcdn/) | — | — | +| [Grafbase](https://grafbase.com/) | Software & Technology | GraphQL API Management | [Blog, June 2023](https://grafbase.com/blog/how-to-build-your-own-realtime-analytics-dashboards) | — | — | +| [GraphCDN](https://graphcdn.io/) | CDN | Traffic Analytics | [Blog Post in English, August 2021](https://altinity.com/blog/delivering-insight-on-graphql-apis-with-clickhouse-at-graphcdn/) | — | — | | [GraphJSON](https://www.graphjson.com) | Cloud analytics platform | Main product | [Official Website, November 2021](https://www.graphjson.com/guides/about) | — | — | -| [GraphQL Hive](https://graphql—hive.com/) | Software Development | Traffic analysis | [Source code](https://github.com/kamilkisiela/graphql—hive) | — | — | -| [Groundcover](https://groundcover.com/) | Observability | Kubernetes Observability | [Documentation, July 2023](https://docs.groundcover.com/docs/learn—more/architecture) | — | — | +| [GraphQL Hive](https://graphql-hive.com/) | Software Development | Traffic analysis | [Source code](https://github.com/kamilkisiela/graphql-hive) | — | — | +| [Groundcover](https://groundcover.com/) | Observability | Kubernetes Observability | [Documentation, July 2023](https://docs.groundcover.com/docs/learn-more/architecture) | — | — | | [Grouparoo](https://www.grouparoo.com) | Data Warehouse Integrations | Main product | [Official Website, August 2021](https://www.grouparoo.com/integrations) | — | — | | [Growthbook](https://www.growthbook.io) | Open Source Feature Flagging | Integration | [Meetup Video](https://youtu.be/pVNxXfVB2cE) | — | — | -| [Gumlet](https://www.gumlet.com/) | CDN | Analytics | [Meetup Presentation](https://github.com/ClickHouse/clickhouse—presentations/blob/master/2024—meetup—bangalore—2/Talk%20Track%202%20—%20Gumlet.pdf) | — | — | -| [Harvey](https://www.harvey.ai/) | AI for legal | Network analytics | [San Francisco Meetup, September 2024](https://clickhouse.com/videos/effective—network—threat—detection) | — | — | -| [HUYA](https://www.huya.com/) | Video Streaming | Analytics | [Slides in Chinese, October 2018](https://github.com/ClickHouse/clickhouse—presentations/blob/master/meetup19/7.%20ClickHouse万亿数据分析实践%20李本旺(sundy—li)%20虎牙.pdf) | — | — | -| [Haibo 海博科技](https://www.botech.com.cn/) | Big Data | OLAP | [Personal reference](https://github.com/ClickHouse/clickhouse—docs/pull/279) | — | — | -| [Helicone](https://helicone.ai) | Software & Technology | LLM monitoring | [Meetup, August 2023](https://clickhouse.com/blog/helicones—migration—from—postgres—to—clickhouse—for—advanced—llm—monitoring) | — | — | -| [Hewlett—Packard](https://www.hp.com) | Software & Technology | — | [LinkedIn post, November 2023](https://www.indeed.com/viewjob?t=Machine+Learning+Engineer&c=Hewlett—Packard+CDS+GmbH&l=Houston,+TX&jk=109385f349350746&rtk=1hg3128s9kkf6800) | — | — | -| [Hi—Fi](https://hi.fi/) | Software & Technology | Music Industry Analytics | [Blog Post, January 2023](https://clickhouse.com/blog/hifis—migration—from—bigquery—to—clickhouse) | — | — | +| [Gumlet](https://www.gumlet.com/) | CDN | Analytics | [Meetup Presentation](https://github.com/ClickHouse/clickhouse-presentations/blob/master/2024-meetup-bangalore-2/Talk%20Track%202%20-%20Gumlet.pdf) | — | — | +| [Harvey](https://www.harvey.ai/) | AI for legal | Network analytics | [San Francisco Meetup, September 2024](https://clickhouse.com/videos/effective-network-threat-detection) | — | — | +| [Hasura](https://hasura.io/) | Software & Technology | Data Platform | [Blog, January 2025](https://hasura.io/blog/hasura-ddn-the-most-incredible-api-for-clickhouse) | — | — | +| [HUYA](https://www.huya.com/) | Video Streaming | Analytics | [Slides in Chinese, October 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup19/7.%20ClickHouse万亿数据分析实践%20李本旺(sundy-li)%20虎牙.pdf) | — | — | +| [Haibo 海博科技](https://www.botech.com.cn/) | Big Data | OLAP | [Personal reference](https://github.com/ClickHouse/clickhouse-docs/pull/279) | — | — | +| [Helicone](https://helicone.ai) | Software & Technology | LLM monitoring | [Meetup, August 2023](https://clickhouse.com/blog/helicones-migration-from-postgres-to-clickhouse-for-advanced-llm-monitoring) | — | — | +| [Hewlett-Packard](https://www.hp.com) | Software & Technology | — | [LinkedIn post, November 2023](https://www.indeed.com/viewjob?t=Machine+Learning+Engineer&c=Hewlett-Packard+CDS+GmbH&l=Houston,+TX&jk=109385f349350746&rtk=1hg3128s9kkf6800) | — | — | +| [Hi-Fi](https://hi.fi/) | Software & Technology | Music Industry Analytics | [Blog Post, January 2023](https://clickhouse.com/blog/hifis-migration-from-bigquery-to-clickhouse) | — | — | | [Highlight](https://www.highlight.io/) | Software & Technology | Monitoring | [Hacker News, February 2023](https://news.ycombinator.com/item?id=34897645), [GitHub](https://github.com/highlight/highlight/tree/87f7e3882b88e9019d690847a134231e943890fe/backend/clickhouse) | — | — | -| [HockeyStack](https://hockeystack.com/) | Analytics platform | OLAP | [Blog](https://hockeystack.com/blog/a—new—database/) | — | — | +| [HockeyStack](https://hockeystack.com/) | Analytics platform | OLAP | [Blog](https://hockeystack.com/blog/a-new-database/) | — | — | | [Honeybadger](https://www.honeybadger.io/) | Software | Error tracking | [Mastadon 2024](https://hachyderm.io/@wood/111904268945097226) | — | — | | [Hookdeck](https://hookdeck.com/) | Software & Technology | Webhook | [Twitter, June 2023](https://twitter.com/mkherlakian/status/1666214460824997889) | — | — | | [Hopsteiner](https://www.hopsteiner.com/) | Agriculture | — | [Job post, July 2023](https://www.indeed.com/viewjob?t=Systems+Administrator&c=S+S+STEINER&l=Yakima,+WA&jk=5b9b7336de0577d5&rtk=1h45ruu32j30q800&from=rss) | — | — | | [Horizon](https://horizon.io/) | Software & Technology | Gaming Analytics | [Twitter, July 2023](https://twitter.com/peterk/status/1677099027110805504) | — | — | -| [Huawei](https://www.huaweicloud.com/intl/en—us/) | Software & Technology | Cloud data platform | [Documentation](https://doc.hcs.huawei.com/usermanual/mrs/mrs_01_2344.html) | — | — | +| [Huawei](https://www.huaweicloud.com/intl/en-us/) | Software & Technology | Cloud data platform | [Documentation](https://doc.hcs.huawei.com/usermanual/mrs/mrs_01_2344.html) | — | — | | [Hubalz](https://hubalz.com) | Web analytics | Main product | [Twitter, July 2023](https://twitter.com/Derinilkcan/status/1676197439152312321) | — | — | -| [Huntress](https://www.huntress.com) | Security analytics | Main product | [Blog Post, November 2024](https://clickhouse.com/blog/how—huntress—improved—performance—and—slashed—costs—with—clickHouse) | — | — | +| [Huntress](https://www.huntress.com) | Security analytics | Main product | [Blog Post, November 2024](https://clickhouse.com/blog/how-huntress-improved-performance-and-slashed-costs-with-clickHouse) | — | — | | [Hydrolix](https://www.hydrolix.io/) | Cloud data platform | Main product | [Documentation](https://docs.hydrolix.io/guide/query) | — | — | | [HyperDx](https://www.hyperdx.io/) | Software & Technology | Open Telemetry | [HackerNews, May 2023](https://news.ycombinator.com/item?id=35881942) | — | — | -| [Hystax](https://hystax.com) | Cloud Operations | Observability Analytics | [Blog](https://hystax.com/clickhouse—for—real—time—cost—saving—analytics—how—to—stop—hammering—screws—and—use—an—electric—screwdriver/) | — | — | -| [IBM](https://www.ibm.com) | APM Platform | Ex—Instana | See Instana | — | — | -| [IBM QRadar](https://www.ibm.com) | IBM QRadar Log Insights | Main Product | [IBM Blog](https://www.ibm.com/blog/closing—breach—window—from—data—to—action/) | — | — | -| [ICA](https://www.the—ica.com/) | FinTech | Risk Management | [Blog Post in English, Sep 2020](https://altinity.com/blog/clickhouse—vs—redshift—performance—for—fintech—risk—management?utm_campaign=ClickHouse%20vs%20RedShift&utm_content=143520807&utm_medium=social&utm_source=twitter&hss_channel=tw—3894792263) | — | — | -| [Idealista](https://www.idealista.com) | Real Estate | Analytics | [Blog Post in English, April 2019](https://clickhouse.com/blog/en/clickhouse—meetup—in—madrid—on—april—2—2019) | — | — | -| [Idea Clan](https://ideaclan.com/) | Digital Marketing | Real—Time Analytics | [Gurgaon Meetup talk, March 2025](https://clickhouse.com/videos/gurgaon—meetup—fabfunnel—and—clickhouse—delivering—real—time—marketing—analytics) | — | — | -| [Improvado](https://improvado.io/) | Revenue Operations | Data Stack | [Blog Post, December 2021](https://improvado.io/blog/clickhouse—warehousing—pricing) | — | — | -| [INCREFF](https://www.increff.com/) | Retail Technology | Business Intelligence | [Meetup Presentation](https://github.com/ClickHouse/clickhouse—presentations/blob/master/2024—meetup—bangalore—2/Talk%20Track%203%20—%20Scaling%20BI%20at%20Increff%20with%20Clickhouse.pdf) | — | — | -| [Inigo](https://inigo.io/) | Software & Technology | GraphQL Gateway | [Blog, March 2023](https://inigo.io/blog/materialized_views_and_clickhouse) [Blog, June 2023](https://clickhouse.com/blog/harnessing—the—power—of—materialized—views—and—clickhouse—for—high—performance—analytics—at—inigo) | — | — | +| [Hystax](https://hystax.com) | Cloud Operations | Observability Analytics | [Blog](https://hystax.com/clickhouse-for-real-time-cost-saving-analytics-how-to-stop-hammering-screws-and-use-an-electric-screwdriver/) | — | — | +| [IBM](https://www.ibm.com) | APM Platform | Ex-Instana | See Instana | — | — | +| [IBM QRadar](https://www.ibm.com) | IBM QRadar Log Insights | Main Product | [IBM Blog](https://www.ibm.com/blog/closing-breach-window-from-data-to-action/) | — | — | +| [ICA](https://www.the-ica.com/) | FinTech | Risk Management | [Blog Post in English, Sep 2020](https://altinity.com/blog/clickhouse-vs-redshift-performance-for-fintech-risk-management?utm_campaign=ClickHouse%20vs%20RedShift&utm_content=143520807&utm_medium=social&utm_source=twitter&hss_channel=tw-3894792263) | — | — | +| [Idealista](https://www.idealista.com) | Real Estate | Analytics | [Blog Post in English, April 2019](https://clickhouse.com/blog/en/clickhouse-meetup-in-madrid-on-april-2-2019) | — | — | +| [Idea Clan](https://ideaclan.com/) | Digital Marketing | Real-Time Analytics | [Gurgaon Meetup talk, March 2025](https://clickhouse.com/videos/gurgaon-meetup-fabfunnel-and-clickhouse-delivering-real-time-marketing-analytics) | — | — | +| [Improvado](https://improvado.io/) | Revenue Operations | Data Stack | [Blog Post, December 2021](https://improvado.io/blog/clickhouse-warehousing-pricing) | — | — | +| [INCREFF](https://www.increff.com/) | Retail Technology | Business Intelligence | [Meetup Presentation](https://github.com/ClickHouse/clickhouse-presentations/blob/master/2024-meetup-bangalore-2/Talk%20Track%203%20-%20Scaling%20BI%20at%20Increff%20with%20Clickhouse.pdf) | — | — | +| [Inigo](https://inigo.io/) | Software & Technology | GraphQL Gateway | [Blog, March 2023](https://inigo.io/blog/materialized_views_and_clickhouse) [Blog, June 2023](https://clickhouse.com/blog/harnessing-the-power-of-materialized-views-and-clickhouse-for-high-performance-analytics-at-inigo) | — | — | | [Infobaleen](https://infobaleen.com) | AI markting tool | Analytics | [Official site](https://infobaleen.com) | — | — | -| [Infovista](https://www.infovista.com/) | Networks | Analytics | [Slides in English, October 2019](https://github.com/ClickHouse/clickhouse—presentations/blob/master/meetup30/infovista.pdf) | — | — | -| [Inngest](https://www.inngest.com/) | Software & Technology | Serverless queues and jobs | [TechCrunch, July 2023](https://techcrunch.com/2023/07/12/inngest—helps—developers—build—their—backend—workflows—raises—3m/) | — | — | -| [InnoGames](https://www.innogames.com) | Games | Metrics, Logging | [Slides in Russian, September 2019](https://github.com/ClickHouse/clickhouse—presentations/blob/master/meetup28/graphite_and_clickHouse.pdf) | — | — | -| [Instabug](https://instabug.com/) | APM Platform | Main product | [Blog Post, May 2022](https://clickhouse.com/blog/10x—improved—response—times—cheaper—to—operate—and—30—storage—reduction—why—instabug—chose—clickhouse—for—apm) | — | — | -| [Instacart](https://instacart.com/) | Delivery | Data Engineering and Infrastructure | [Blog Post, May 2022](https://www.instacart.com/company/how—its—made/data—engineering—and—infrastructure—at—instacart—with—engineering—manager—abhi—kalakuntla/) | — | — | +| [Infovista](https://www.infovista.com/) | Networks | Analytics | [Slides in English, October 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup30/infovista.pdf) | — | — | +| [Inngest](https://www.inngest.com/) | Software & Technology | Serverless queues and jobs | [TechCrunch, July 2023](https://techcrunch.com/2023/07/12/inngest-helps-developers-build-their-backend-workflows-raises-3m/) | — | — | +| [InnoGames](https://www.innogames.com) | Games | Metrics, Logging | [Slides in Russian, September 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup28/graphite_and_clickHouse.pdf) | — | — | +| [Instabug](https://instabug.com/) | APM Platform | Main product | [Blog Post, May 2022](https://clickhouse.com/blog/10x-improved-response-times-cheaper-to-operate-and-30-storage-reduction-why-instabug-chose-clickhouse-for-apm) | — | — | +| [Instacart](https://instacart.com/) | Delivery | Data Engineering and Infrastructure | [Blog Post, May 2022](https://www.instacart.com/company/how-its-made/data-engineering-and-infrastructure-at-instacart-with-engineering-manager-abhi-kalakuntla/) | — | — | | [Instana](https://www.instana.com) | APM Platform | Main product | [Twitter post](https://twitter.com/mieldonkers/status/1248884119158882304) | — | — | -| [Integros](https://integros.com) | Platform for video services | Analytics | [Slides in Russian, May 2019](https://github.com/ClickHouse/clickhouse—presentations/blob/master/meetup22/strategies.pdf) | — | — | -| [inwt](https://www.inwt—statistics.com/) | Software & Technology | Data Science | [Blog Post, December 2023](https://www.inwt—statistics.com/blog/business_case_air_pollution_forecast) | — | — | +| [Integros](https://integros.com) | Platform for video services | Analytics | [Slides in Russian, May 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup22/strategies.pdf) | — | — | +| [inwt](https://www.inwt-statistics.com/) | Software & Technology | Data Science | [Blog Post, December 2023](https://www.inwt-statistics.com/blog/business_case_air_pollution_forecast) | — | — | | [Ippon Technologies](https://ippon.tech) | Technology Consulting | — | [Talk in English, July 2020](https://youtu.be/GMiXCMFDMow?t=205) | — | — | | [Ivi](https://www.ivi.ru/) | Online Cinema | Analytics, Monitoring | [Article in Russian, Jan 2018](https://habr.com/en/company/ivi/blog/347408/) | — | — | -| [Jerry](https://getjerry.com/) | Automotive SaaS | Analytics (Migrate from Redshift) | [Blog, May 2024](https://juicefs.com/en/blog/user—stories/read—write—separation) | — | — | -| [Jinshuju 金数据](https://jinshuju.net) | BI Analytics | Main product | [Slides in Chinese, October 2019](https://github.com/ClickHouse/clickhouse—presentations/blob/master/meetup24/3.%20金数据数据架构调整方案Public.pdf) | — | — | -| [Jitsu](https://jitsu.com) | Cloud Software | Data Pipeline | [Documentation](https://jitsu.com/docs/destinations—configuration/clickhouse—destination), [Hacker News post](https://news.ycombinator.com/item?id=29106082) | — | — | -| [JuiceFS](https://juicefs.com/) | Storage | Shopping Cart | [Blog](https://juicefs.com/blog/en/posts/shopee—clickhouse—with—juicefs/) | — | — | -| [Jump Capital](https://jumpcap.com/) | Fintech | Investor | [Chicago meetup, September 2024](https://clickhouse.com/videos/fireside—chat—with—alexey—saurabh) | — | — | -| [Jump Trading](https://www.jumptrading.com/) | Financial | Analytics | [Chicago meetup, September 2024](https://clickhouse.com/videos/clikchouse—demo) | — | — | -| [June](https://www.june.so/) | Product analytics | Main product | [Job post](https://www.ycombinator.com/companies/june/jobs/SHd7fFLYG—founding—engineer) | — | — | -| [Juspay](https://juspay.in/) | Software & Technology | Payments | [Blog, March 2023](https://clickhouse.com/blog/juspay—analyzes—payment—transactions—in—real—time—with—clickhouse) | — | — | -| [KGK Global](https://www.kgk—global.com/en/) | Vehicle monitoring | — | [Press release, June 2021](https://zoom.cnews.ru/news/item/530921) | — | — | +| [Jerry](https://getjerry.com/) | Automotive SaaS | Analytics (Migrate from Redshift) | [Blog, May 2024](https://juicefs.com/en/blog/user-stories/read-write-separation) | — | — | +| [Jinshuju 金数据](https://jinshuju.net) | BI Analytics | Main product | [Slides in Chinese, October 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup24/3.%20金数据数据架构调整方案Public.pdf) | — | — | +| [Jitsu](https://jitsu.com) | Cloud Software | Data Pipeline | [Documentation](https://jitsu.com/docs/destinations-configuration/clickhouse-destination), [Hacker News post](https://news.ycombinator.com/item?id=29106082) | — | — | +| [JuiceFS](https://juicefs.com/) | Storage | Shopping Cart | [Blog](https://juicefs.com/blog/en/posts/shopee-clickhouse-with-juicefs/) | — | — | +| [Jump Capital](https://jumpcap.com/) | Fintech | Investor | [Chicago meetup, September 2024](https://clickhouse.com/videos/fireside-chat-with-alexey-saurabh) | — | — | +| [Jump Trading](https://www.jumptrading.com/) | Financial | Analytics | [Chicago meetup, September 2024](https://clickhouse.com/videos/clikchouse-demo) | — | — | +| [June](https://www.june.so/) | Product analytics | Main product | [Job post](https://www.ycombinator.com/companies/june/jobs/SHd7fFLYG-founding-engineer) | — | — | +| [Juspay](https://juspay.in/) | Software & Technology | Payments | [Blog, March 2023](https://clickhouse.com/blog/juspay-analyzes-payment-transactions-in-real-time-with-clickhouse) | — | — | +| [KGK Global](https://www.kgk-global.com/en/) | Vehicle monitoring | — | [Press release, June 2021](https://zoom.cnews.ru/news/item/530921) | — | — | | [KMK Online](https://www.kmkonline.co.id/) | Digital Services | Streaming analytics | ClickHouse Cloud user | — | — | | [Kaiko](https://www.kaiko.com/) | Digital Assets Data Provider | — | [Job advertisement, April 2022](https://kaiko.talentlyft.com/) | — | — | | [Kakaocorp](https://www.kakaocorp.com/) | Internet company | — | [if(kakao)2020](https://tv.kakao.com/channel/3693125/cliplink/414129353), [if(kakao)2021](https://if.kakao.com/session/24) | — | — | -| [Kami](https://www.kamiapp.com/) | Education, Software & Technology | Real—time Analytics | [Auckland Meetup, CTO talk, February 2025](https://clickhouse.com/videos/auckland—meetup—kami—ingesting—clickstream—data—into—clickhouse), [Auckland Meetup, Head of Data talk, Feburary 2025](https://clickhouse.com/videos/auckland—meetup—kami—evolution—of—kami—data—infrastructure) | — | — | -| [Klaviyo](https://www.klaviyo.com/) | E—Commerce Marketing Automation Platform | — | [Klaviyo Engineering Blog, Jan 2023](https://klaviyo.tech/adaptive—concurrency—control—for—mixed—analytical—workloads—51350439aeec) , [Klaviyo Engineering Blog, July 2023](https://klaviyo.tech/taking—the—first—sip—an—overview—of—klaviyos—segmentation—improvement—project—7db997f36b39), [video](https://youtu.be/8Sk5iO9HGRY) | 128 nodes | — | +| [Kami](https://www.kamiapp.com/) | Education, Software & Technology | Real-time Analytics | [Auckland Meetup, CTO talk, February 2025](https://clickhouse.com/videos/auckland-meetup-kami-ingesting-clickstream-data-into-clickhouse), [Auckland Meetup, Head of Data talk, Feburary 2025](https://clickhouse.com/videos/auckland-meetup-kami-evolution-of-kami-data-infrastructure) | — | — | +| [Klaviyo](https://www.klaviyo.com/) | E-Commerce Marketing Automation Platform | — | [Klaviyo Engineering Blog, Jan 2023](https://klaviyo.tech/adaptive-concurrency-control-for-mixed-analytical-workloads-51350439aeec) , [Klaviyo Engineering Blog, July 2023](https://klaviyo.tech/taking-the-first-sip-an-overview-of-klaviyos-segmentation-improvement-project-7db997f36b39), [video](https://youtu.be/8Sk5iO9HGRY) | 128 nodes | — | | [Knock.app](https://knock.app/) | Software | Notifications management | [Twitter, 2024](https://twitter.com/cjbell_/status/1759989849577181356) | — | — | -| [Kodiak Data](https://www.kodiakdata.com/) | Clouds | Main product | [Slides in Engish, April 2018](https://github.com/ClickHouse/clickhouse—presentations/blob/master/meetup13/kodiak_data.pdf) | — | — | +| [Kodiak Data](https://www.kodiakdata.com/) | Clouds | Main product | [Slides in Engish, April 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup13/kodiak_data.pdf) | — | — | | [Kontur](https://kontur.ru) | Software Development | Metrics | [Talk in Russian, November 2018](https://www.youtube.com/watch?v=U4u4Bd0FtrY) | — | — | | [Kopo Kopo](https://kopokopo.co.ke/) | FinTech | Metrics | ClickHouse Cloud user | — | — | -| [Kuaishou](https://www.kuaishou.com/) | Video | — | [ClickHouse Meetup, October 2018](https://clickhouse.com/blog/en/2018/clickhouse—community—meetup—in—beijing—on—october—28—2018/) | — | — | +| [Kuaishou](https://www.kuaishou.com/) | Video | — | [ClickHouse Meetup, October 2018](https://clickhouse.com/blog/en/2018/clickhouse-community-meetup-in-beijing-on-october-28-2018/) | — | — | | [Kujiale 酷家乐](https://www.kujiale.com/) | VR smart interior design platform. | Use in log monitoring platform. | [Blog, July 2023](https://juejin.cn/post/7251786922615111740/) | Main cluster is 800+ CPU cores, 4000+ GB RAM. | SSD 140+ TB, HDD 280+ TB. | -| [Kyligence](https://kyligence.io/) | Managed Service | Main Product | [Website](https://kyligence.io/all—inclusive—olap/) | — | — | -| [LANCOM Systems](https://www.lancom—systems.com/) | Network Solutions | Traffic analysis | [ClickHouse Operator for Kubernetes](https://www.lancom—systems.com/), [Hacker News post](https://news.ycombinator.com/item?id=29413660) | — | — | -| [Langchain](https://www.langchain.com/) | Software & Technology | LLM Monitoring | [Blog, Apr 2024](https://clickhouse.com/blog/langchain—why—we—choose—clickhouse—to—power—langchain) | — | — | -| [LangDB](https://langdb.ai/) | Software & Technology | AI Gateway | [Singapore Meetup talk, February 2025](https://clickhouse.com/videos/singapore—meetup—langdb—building—intelligent—applications—with—clickhouse) | — | — | +| [Kyligence](https://kyligence.io/) | Managed Service | Main Product | [Website](https://kyligence.io/all-inclusive-olap/) | — | — | +| [LANCOM Systems](https://www.lancom-systems.com/) | Network Solutions | Traffic analysis | [ClickHouse Operator for Kubernetes](https://www.lancom-systems.com/), [Hacker News post](https://news.ycombinator.com/item?id=29413660) | — | — | +| [Langchain](https://www.langchain.com/) | Software & Technology | LLM Monitoring | [Blog, Apr 2024](https://clickhouse.com/blog/langchain-why-we-choose-clickhouse-to-power-langchain) | — | — | +| [LangDB](https://langdb.ai/) | Software & Technology | AI Gateway | [Singapore Meetup talk, February 2025](https://clickhouse.com/videos/singapore-meetup-langdb-building-intelligent-applications-with-clickhouse) | — | — | | [LangFuse](https://langfuse.com/) | Software & Technology | LLM Monitoring | [Meetup, March 2025](https://youtu.be/AnghkoucpN0) | — | — | | [Langtrace AI](https://www.langtrace.ai/) | Software & Technology | LLM Monitoring | [Twitter, May 2024](https://x.com/karthikkalyan90/status/1790483625743716703) | — | — | -| [Lago](https://www.getlago.com/) | Billing automation | — | [GitHub Wiki post](https://github.com/getlago/lago/wiki/How—ClickHouse—saved—our—events—engine—problem) | — | — | +| [Lago](https://www.getlago.com/) | Billing automation | — | [GitHub Wiki post](https://github.com/getlago/lago/wiki/How-ClickHouse-saved-our-events-engine-problem) | — | — | | [Lagon](https://lagon.app/) | Software Development | Serverless Functions | [Twitter, 2023](https://twitter.com/tomlienard/status/1702759256909394010) | — | — | -| [Last9](https://last9.io/) | Software & Technology | Observability | [Mumbai Meetup, February 2025](https://clickhouse.com/videos/the—telemetry—data—platform—breaking—down—operational—silos) , [Bangalore Meetup, February 2025](https://clickhouse.com/videos/less—war—more—room—last9) , [Blog, April 2025](https://clickhouse.com/blog/last9—clickhouse—delivering—seamless—observability—minus—the—chaos) | — | — | +| [Last9](https://last9.io/) | Software & Technology | Observability | [Mumbai Meetup, February 2025](https://clickhouse.com/videos/the-telemetry-data-platform-breaking-down-operational-silos) , [Bangalore Meetup, February 2025](https://clickhouse.com/videos/less-war-more-room-last9) , [Blog, April 2025](https://clickhouse.com/blog/last9-clickhouse-delivering-seamless-observability-minus-the-chaos) | — | — | | [Laudspeaker](https://laudspeaker.com/) | Software & Technology | Open Source Messaging | [GitHub](https://github.com/laudspeaker/laudspeaker) | — | — | -| [Lawrence Berkeley National Laboratory](https://www.lbl.gov) | Research | Traffic analysis | [Slides in English, April 2019](https://www.smitasin.com/presentations/2019—04—17_DOE—NSM.pdf) | 5 servers | 55 TiB | +| [Lawrence Berkeley National Laboratory](https://www.lbl.gov) | Research | Traffic analysis | [Slides in English, April 2019](https://www.smitasin.com/presentations/2019-04-17_DOE-NSM.pdf) | 5 servers | 55 TiB | | [Lever](https://www.lever.co/) | Talent Management | Recruiting | [Hacker News post](https://news.ycombinator.com/item?id=29558544) | — | — | | [LifeStreet](https://lifestreet.com/) | Ad network | Main product | [Blog post in Russian, February 2017](https://habr.com/en/post/322620/) | 75 servers (3 replicas) | 5.27 PiB | -| [LimeChat](https://www.limechat.ai/) | Mobile chat | Whatsapp Commerce | [LinkedIn 2024](https://www.linkedin.com/pulse/scaling—analytics—clickhouse—story—nikhil—gupta—gezcc/) | — | — | -| [LINE Digital Frontier](https://ldfcorp.com/ja) | Gaming | Real—time Analytics | [Tokyo Meetup, January 2025](https://clickhouse.com/videos/tokyo—meetup—line—from—stateles—servers—to—real—time—analytics) | — | — | +| [LimeChat](https://www.limechat.ai/) | Mobile chat | Whatsapp Commerce | [LinkedIn 2024](https://www.linkedin.com/pulse/scaling-analytics-clickhouse-story-nikhil-gupta-gezcc/) | — | — | +| [LINE Digital Frontier](https://ldfcorp.com/ja) | Gaming | Real-time Analytics | [Tokyo Meetup, January 2025](https://clickhouse.com/videos/tokyo-meetup-line-from-stateles-servers-to-real-time-analytics) | — | — | | [LiteLLM](https://github.com/BerriAI/litellm) | Software | API management | [GitHub](https://github.com/BerriAI/litellm/blob/e7b88c2134a013f527304de29358238a5593f91f/cookbook/misc/clickhouse_insert_logs.py#L4) | | — | -| [Little Red Book (Xiaohongshu)](http://www.xiaohongshu.com/) | Social Media | Data warehouse | [Presentation, March 2023](https://github.com/ClickHouse/clickhouse—presentations/blob/master/meetup71/LittleRedBook.pdf) | — | — | +| [Little Red Book (Xiaohongshu)](http://www.xiaohongshu.com/) | Social Media | Data warehouse | [Presentation, March 2023](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup71/LittleRedBook.pdf) | — | — | | [LogfireAI](https://logfire.ai/) | Software & Technology | Monitoring & Observability | [Twitter, March 2024](https://twitter.com/logfire_ai/status/1765947119200841883) | — | — | -| [LogSnag](https://logsnag.com/) | Software & Technology | Realtime Monitoring | [Interview, December 2022](https://founderbeats.com/shayan—on—building—and—growing—logsnag—as—a—solo—founder) | — | — | +| [LogSnag](https://logsnag.com/) | Software & Technology | Realtime Monitoring | [Interview, December 2022](https://founderbeats.com/shayan-on-building-and-growing-logsnag-as-a-solo-founder) | — | — | | [Logtail](https://betterstack.com/logtail) | Cloud, SaaS | Log Management | [Official Website](https://betterstack.com/logtail) | — | — | -| [Loja Integrada](https://lojaintegrada.com.br/) | E—Commerce | — | [Case Study, March 2023](https://double.cloud/resources/case—studies/lojaintegrada—and—pagali—switch—to—doublecloud—to—make—running—clickhouse—easier) | — | — | -| [Longbridge Technology](https://longbridge.com/) | E—Commerce | — | [Blog, March 2025](https://clickhouse.com/blog/longbridge—technology—simplifies—their—architecture—and—achieves—10x—performance—boost—with—clickhouse) | — | — | -| [Lookforsale](https://lookforsale.ru/) | E—Commerce | — | [Job Posting, December 2021](https://telegram.me/javascript_jobs/587318) | — | — | -| [Loopme](https://loopme.com/) | AdTech | Analytics | [Blog, Aug 2024](https://clickhouse.com/blog/measuring—brand—impact—how—loopme—uses—clickhouse—to—deliver—better—brand—advertising—outcomes) | — | — | +| [Loja Integrada](https://lojaintegrada.com.br/) | E-Commerce | — | [Case Study, March 2023](https://double.cloud/resources/case-studies/lojaintegrada-and-pagali-switch-to-doublecloud-to-make-running-clickhouse-easier) | — | — | +| [Longbridge Technology](https://longbridge.com/) | E-Commerce | — | [Blog, March 2025](https://clickhouse.com/blog/longbridge-technology-simplifies-their-architecture-and-achieves-10x-performance-boost-with-clickhouse) | — | — | +| [Lookforsale](https://lookforsale.ru/) | E-Commerce | — | [Job Posting, December 2021](https://telegram.me/javascript_jobs/587318) | — | — | +| [Loopme](https://loopme.com/) | AdTech | Analytics | [Blog, Aug 2024](https://clickhouse.com/blog/measuring-brand-impact-how-loopme-uses-clickhouse-to-deliver-better-brand-advertising-outcomes) | — | — | | [Luabase](https://luabase.com/) | Software | Analytics | [Hacker News, April 2022](https://news.ycombinator.com/item?id=31040190) | — | — | | [Lyft](https://lyft.com) | Rideshare | — | [Twitter, July 2023](https://twitter.com/riteshvaryani/status/1685160430606639104) | — | — | | [MAXILECT](https://maxilect.com/) | Ad Tech, Blockchain, ML, AI | — | [Job advertisement, 2021](https://www.linkedin.com/feed/update/urn:li:activity:6780842017229430784/) | — | — | -| [MGID](https://www.mgid.com/) | Ad network | Web—analytics | [Blog post in Russian, April 2020](http://gs—studio.com/news—about—it/32777————clickhouse———c) | — | — | -| [MUX](https://mux.com/) | Online Video | Video Analytics | [Talk in English, August 2019](https://altinity.com/presentations/2019/8/13/how—clickhouse—became—the—default—analytics—database—for—mux/) | — | — | -| [Mail.ru Cloud Solutions](https://mcs.mail.ru/) | Cloud services | Main product | [Article in Russian](https://mcs.mail.ru/help/db—create/clickhouse#) | — | — | +| [MGID](https://www.mgid.com/) | Ad network | Web-analytics | [Blog post in Russian, April 2020](http://gs-studio.com/news-about-it/32777-—-—clickhouse-—-c) | — | — | +| [MUX](https://mux.com/) | Online Video | Video Analytics | [Talk in English, August 2019](https://altinity.com/presentations/2019/8/13/how-clickhouse-became-the-default-analytics-database-for-mux/) | — | — | +| [Mail.ru Cloud Solutions](https://mcs.mail.ru/) | Cloud services | Main product | [Article in Russian](https://mcs.mail.ru/help/db-create/clickhouse#) | — | — | | [Marfeel](https://www.marfeel.com/) | Mobile SaaS | — | Job offer, Apr 2022 | — | — | | [Marilyn](https://tech.mymarilyn.ru) | Advertising | Statistics | [Talk in Russian, June 2017](https://www.youtube.com/watch?v=iXlIgx2khwc) | — | — | -| [MasMovil](https://www.masmovil.es/) | Telecom | Telecom services | [Blog](https://clickhouse.com/blog/how—grupo—masmovil—monitors—radio—access—networks—with—clickhouse) | — | — | -| [Match Systems](https://matchsystems.com/) | Software & Technology | Blockchain Intelligence & AML | [Job Posting, March 2024](https://telegra—ph.translate.goog/Senior—Database—Administrator—11—28?_x_tr_sl=ru&_x_tr_tl=en&_x_tr_hl=en&_x_tr_pto=wapp) | — | — | -| [Mello](https://mellodesign.ru/) | Marketing | Analytics | [Article, October 2020](https://vc.ru/marketing/166180—razrabotka—tipovogo—otcheta—skvoznoy—analitiki) | 1 server | — | -| [Memfault](https://https://memfault.com/) | Software & Technology | IOT Monitoring | [Job Listing, August 2023](https://www.ycombinator.com/companies/memfault/jobs/zALzwIe—backend—engineer—systems—data) | — | — | -| [cBioPortal](https://www.cbioportal.org/) | Healthcare | Datstore backing portal for cancer genomics | [NYC Meetup, Dec 2023](https://clickhouse.com/videos/fast—answers—in—cancer—research) | — | — | -| [MessageBird](https://www.messagebird.com) | Telecommunications | Statistics | [Slides in English, November 2018](https://github.com/ClickHouse/clickhouse—presentations/blob/master/meetup20/messagebird.pdf) | — | — | -| [Metoda](https://metoda.com/) | Software & Technology | Advertisting | [ClickHouse Meetup, September 2022](https://www.youtube.com/watch?v=uS5uA—aZSlQ&t=1770s) | — | — | -| [MetricFire](https://www.metricfire.com) | Managed Service | Monitoring | [Blog, November 2022](https://www.metricfire.com/blog/using—clickhouse—with—metricfire) | — | — | +| [MasMovil](https://www.masmovil.es/) | Telecom | Telecom services | [Blog](https://clickhouse.com/blog/how-grupo-masmovil-monitors-radio-access-networks-with-clickhouse) | — | — | +| [Match Systems](https://matchsystems.com/) | Software & Technology | Blockchain Intelligence & AML | [Job Posting, March 2024](https://telegra-ph.translate.goog/Senior-Database-Administrator-11-28?_x_tr_sl=ru&_x_tr_tl=en&_x_tr_hl=en&_x_tr_pto=wapp) | — | — | +| [Mello](https://mellodesign.ru/) | Marketing | Analytics | [Article, October 2020](https://vc.ru/marketing/166180-razrabotka-tipovogo-otcheta-skvoznoy-analitiki) | 1 server | — | +| [Memfault](https://https://memfault.com/) | Software & Technology | IOT Monitoring | [Job Listing, August 2023](https://www.ycombinator.com/companies/memfault/jobs/zALzwIe-backend-engineer-systems-data) | — | — | +| [cBioPortal](https://www.cbioportal.org/) | Healthcare | Datstore backing portal for cancer genomics | [NYC Meetup, Dec 2023](https://clickhouse.com/videos/fast-answers-in-cancer-research) | — | — | +| [MessageBird](https://www.messagebird.com) | Telecommunications | Statistics | [Slides in English, November 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup20/messagebird.pdf) | — | — | +| [Metoda](https://metoda.com/) | Software & Technology | Advertisting | [ClickHouse Meetup, September 2022](https://www.youtube.com/watch?v=uS5uA-aZSlQ&t=1770s) | — | — | +| [MetricFire](https://www.metricfire.com) | Managed Service | Monitoring | [Blog, November 2022](https://www.metricfire.com/blog/using-clickhouse-with-metricfire) | — | — | | [Microsoft — Clarity](https://clarity.microsoft.com/) | Web Analytics | Clarity (Main Product) | [Meetup Video, January 2023](https://www.youtube.com/watch?v=rUVZlquVGw0&list=PL0Z2YDlm0b3iNDUzpY1S3L_iV4nARda_U&index=2) [A question on GitHub](https://github.com/ClickHouse/ClickHouse/issues/21556) | — | — | | [Microsoft — Titan](https://www.microsoft.com/) | Software & Technology | Internal Data Analytics (Titan) | [Meetup Video, January 2023](https://www.youtube.com/watch?v=r1ZqjU8ZbNs&list=PL0Z2YDlm0b3iNDUzpY1S3L_iV4nARda_U&index=2) | — | — | | [Middleware](https://middleware.io/) | Software | Cloud management | [SF Meetup, March 2024](https://www.youtube.com/watch?v=xCLMuXJWx80&list=PL0Z2YDlm0b3iNDUzpY1S3L_iV4nARda_U&index=10) | — | — | -| [MindsDB](https://www.mindsdb.com/) | Machine Learning | Main Product | [Official Website](https://www.mindsdb.com/blog/machine—learning—models—as—tables—in—ch) | — | — | -| [Modeo](https://modeo.ai/) | Software & Technology | Data Engineering | [Blog, June 2023](https://clickhouse.com/blog/driving—sustainable—data—management—with—clickhouse—introducing—stash—by—modeo) | — | — | -| [moosejs](https://www.moosejs.com/) | Software & Technology | Open—source developer framework | [Blog Post, May 2024](https://www.fiveonefour.com/blog/product—update—2) | — | — | +| [MindsDB](https://www.mindsdb.com/) | Machine Learning | Main Product | [Official Website](https://www.mindsdb.com/blog/machine-learning-models-as-tables-in-ch) | — | — | +| [Modeo](https://modeo.ai/) | Software & Technology | Data Engineering | [Blog, June 2023](https://clickhouse.com/blog/driving-sustainable-data-management-with-clickhouse-introducing-stash-by-modeo) | — | — | +| [moosejs](https://www.moosejs.com/) | Software & Technology | Open-source developer framework | [Blog Post, May 2024](https://www.fiveonefour.com/blog/product-update-2) | — | — | | [Motodata](https://www.motadata.com/) | Monitoring | Main Product | [Official Website](https://www.motadata.com/docs) | — | — | | [Muse Group](https://mu.se/) | Music Software | Performance Monitoring | [Blog post in Russian, January 2021](https://habr.com/en/post/647079/) | — | — | | [MyScale](https://myscale.com/) | Software & Technology | AI Database | [Docs](https://docs.myscale.com/en/overview/) | — | — | -| [NANO Corp](https://nanocorp.fr/en/) | Software & Technology | NOC as a Service | [Blog Post, July 2022](https://clickhouse.com/blog/from—experimentation—to—production—the—journey—to—supercolumn) | — | — | -| [NGINX](https://nginx.com/) | Application Delivery Network | NGINX Management Suite | [Documentation](https://docs.nginx.com/nginx—management—suite/admin—guides/getting—started/prerequisites/configure—clickhouse/) | — | — | -| [NIC Labs](https://niclabs.cl/) | Network Monitoring | RaTA—DNS | [Blog post, March 2021](https://niclabs.cl/ratadns/2021/03/Clickhouse) | — | — | -| [Nixys](https://nixys.io/) | Software & Technology | DevOps, SRE and DevSecOps | [Blog Post, March 2024](https://habr—com.translate.goog/ru/companies/nixys/articles/801029/?_x_tr_hist=true/ru/companies/nixys/articles/801029/?_x_tr_sl=ru&_x_tr_tl=en&_x_tr_hl=en&_x_tr_pto=wapp&_x_tr_hist=true) | — | — | +| [NANO Corp](https://nanocorp.fr/en/) | Software & Technology | NOC as a Service | [Blog Post, July 2022](https://clickhouse.com/blog/from-experimentation-to-production-the-journey-to-supercolumn) | — | — | +| [NGINX](https://nginx.com/) | Application Delivery Network | NGINX Management Suite | [Documentation](https://docs.nginx.com/nginx-management-suite/admin-guides/getting-started/prerequisites/configure-clickhouse/) | — | — | +| [NIC Labs](https://niclabs.cl/) | Network Monitoring | RaTA-DNS | [Blog post, March 2021](https://niclabs.cl/ratadns/2021/03/Clickhouse) | — | — | +| [Nixys](https://nixys.io/) | Software & Technology | DevOps, SRE and DevSecOps | [Blog Post, March 2024](https://habr-com.translate.goog/ru/companies/nixys/articles/801029/?_x_tr_hist=true/ru/companies/nixys/articles/801029/?_x_tr_sl=ru&_x_tr_tl=en&_x_tr_hl=en&_x_tr_pto=wapp&_x_tr_hist=true) | — | — | | [NLMK](https://nlmk.com/en/) | Steel | Monitoring | [Article in Russian, Jan 2022](https://habr.com/en/company/nlmk/blog/645943/) | — | — | -| [NOC Project](https://getnoc.com/) | Network Monitoring | Analytics | [Official Website](https://getnoc.com/features/big—data/) | Main Product | — | -| [Nansen](https://www.nansen.ai/) | Finance — Crypto | Analytics | [Press release](https://clickhouse.com/blog/clickhouse—cloud—on—google—cloud—platform—gcp—is—generally—available) | — | — | +| [NOC Project](https://getnoc.com/) | Network Monitoring | Analytics | [Official Website](https://getnoc.com/features/big-data/) | Main Product | — | +| [Nansen](https://www.nansen.ai/) | Finance — Crypto | Analytics | [Press release](https://clickhouse.com/blog/clickhouse-cloud-on-google-cloud-platform-gcp-is-generally-available) | — | — | | [Narrative](https://www.trynarrative.com/) | Software & Technology | AI Automation | [Hacker News, May 2024](https://news.ycombinator.com/item?id=40225998) | — | — | | [Nationale Databank Wegverkeers](https://www.ndw.nu/) | Software & Technology | Road Traffic Monitoring | [Presentation at Foss4G, August 2019](https://av.tib.eu/media/43434) | — | — | -| [Nebius](https://nebius.com/il/docs/managed—clickhouse/) | SaaS | Main product | [Official website](https://nebius.com/il/docs/managed—clickhouse/) | — | — | +| [Nebius](https://nebius.com/il/docs/managed-clickhouse/) | SaaS | Main product | [Official website](https://nebius.com/il/docs/managed-clickhouse/) | — | — | | [Neocom](https://www.neocom.ai/) | AI SaaS | Main product | [Job listing](https://news.ycombinator.com/item?id=38497724) | — | — | | [Neocom](https://www.neocom.ai/) | Software & Technology | Sales Platform | [Hacker News, September 2023](https://news.ycombinator.com/item?id=37359122) | — | — | -| [NeonDB](https://neon.tech/) | Cloud | Postgres management | [Blog, 2024](https://double.cloud/resources/case—studies/neon—increases—data—granularity—with—managed—clickhouse/) | — | — | -| [NetMeta](https://github.com/monogon—dev/NetMeta/blob/main/README.md) | Observability | Main Product | [Twitter, December 2022](https://twitter.com/leolukde/status/1605643470239977475) | — | — | +| [NeonDB](https://neon.tech/) | Cloud | Postgres management | [Blog, 2024](https://double.cloud/resources/case-studies/neon-increases-data-granularity-with-managed-clickhouse/) | — | — | +| [NetApp Instaclustr](https://www.instaclustr.com/platform/managed-clickhouse/) | Cloud Storage | Analytics | [Documentation](https://www.instaclustr.com/support/documentation/clickhouse/getting-started-with-clickhouse/creating-a-clickhouse-cluster/) | — | — | +| [NetMeta](https://github.com/monogon-dev/NetMeta/blob/main/README.md) | Observability | Main Product | [Twitter, December 2022](https://twitter.com/leolukde/status/1605643470239977475) | — | — | | [Netflix](https://www.netflix.com/) | Software & Technology | Video Streaming | [Meetup, March 2025](https://youtu.be/64TFG_Qt5r4) | — | — | -| [Netskope](https://www.netskope.com/) | Network Security | — | [Job advertisement, March 2021](https://www.mendeley.com/careers/job/senior—software—developer—backend—developer—1346348) | — | — | -| [Nexpath Networks](https://www.nexpath.net/) | Software & Technology | Network Analysis | [Slides, September 2021](https://opensips.org/events/Summit—2021Distributed/assets/presentations/2021—jon—abrams—big—telco—data—with—clickhouse.pdf) [Video, September 2021](https://www.youtube.com/watch?v=kyu_wDcO0S4&t=3840s) | — | — | +| [Netskope](https://www.netskope.com/) | Network Security | — | [Job advertisement, March 2021](https://www.mendeley.com/careers/job/senior-software-developer-backend-developer-1346348) | — | — | +| [Nexpath Networks](https://www.nexpath.net/) | Software & Technology | Network Analysis | [Slides, September 2021](https://opensips.org/events/Summit-2021Distributed/assets/presentations/2021-jon-abrams-big-telco-data-with-clickhouse.pdf) [Video, September 2021](https://www.youtube.com/watch?v=kyu_wDcO0S4&t=3840s) | — | — | | [NineData](https://www.ninedata.cloud/) | Software & Technology | DMaaS | ClickHouse Meetup in Hangzhou, May 2024 | — | — | -| [Noction](https://www.noction.com) | Network Technology | Main Product | [Official Website](https://www.noction.com/news/irp—3—11—remote—triggered—blackholing—capability) | — | — | +| [Noction](https://www.noction.com) | Network Technology | Main Product | [Official Website](https://www.noction.com/news/irp-3-11-remote-triggered-blackholing-capability) | — | — | | [Notionlytics](https://notionlytics.com/) | Software & Technology | Page analytics for Notion | [Twitter, July 2023](https://twitter.com/MaxPrilutskiy/status/1675428469403004928) | — | — | -| [Ntop](https://www.ntop.org/) | Network Monitoning | Monitoring | [Official website, January 2022](https://www.ntop.org/ntop/historical—traffic—analysis—at—scale—using—clickhouse—with—ntopng/) | — | — | +| [Ntop](https://www.ntop.org/) | Network Monitoning | Monitoring | [Official website, January 2022](https://www.ntop.org/ntop/historical-traffic-analysis-at-scale-using-clickhouse-with-ntopng/) | — | — | | [Nuna Inc.](https://www.nuna.com/) | Health Data Analytics | — | [Talk in English, July 2020](https://youtu.be/GMiXCMFDMow?t=170) | — | — | | [Nuon](https://nuon.co/) | Software & Technology | — | [Meetup video](https://youtu.be/2rHfWt6epIQ) | — | — | -| [Nutanix](https://www.nutanix.com/) | Software & Technology | Main Product | [Slides, March 2024](https://github.com/ClickHouse/clickhouse—presentations/blob/master/2024—meetup—bengaluru/2—Unified_data_platform_with_clickhouse_by_Sachidanad_Gaurav_Nutanix.pdf) | — | — | -| [Nvidia](https://www.nvidia.com/) | Software & Technology | NVIDIA AI Aerial | [Documentation](https://docs.nvidia.com/aerial/archive/aerial—dt/1.0/text/overview.html#clickhouse) | — | — | +| [Nutanix](https://www.nutanix.com/) | Software & Technology | Main Product | [Slides, March 2024](https://github.com/ClickHouse/clickhouse-presentations/blob/master/2024-meetup-bengaluru/2-Unified_data_platform_with_clickhouse_by_Sachidanad_Gaurav_Nutanix.pdf) | — | — | +| [Nvidia](https://www.nvidia.com/) | Software & Technology | NVIDIA AI Aerial | [Documentation](https://docs.nvidia.com/aerial/archive/aerial-dt/1.0/text/overview.html#clickhouse) | — | — | | [Oden](https://oden.io/) | Software & Technology | Manufacturing | | | | | [Oden](https://oden.io/) | Software & Technology | Manufacturing | [Meetup, April 2023](https://www.youtube.com/watch?v=pAKGJDOO6lo) | — | — | | [Odoscope](https://www.odoscope.com/) | Software & Technology | Customer Engagement Platform | [Awards Submission, February 2023](https://ecommercegermanyawards.com/vote/164051) | — | — | | [Ok.ru](https://ok.ru) | Social Network | — | [SmartData conference, October 2021](https://assets.ctfassets.net/oxjq45e8ilak/4JPHkbJenLgZhBGGyyonFP/57472ec6987003ec4078d0941740703b/____________________ClickHouse_______________________.pdf) | 72 servers | 810 TB compressed, 50bn rows/day, 1.5 TB/day | -| [OLX India](https://www.olx.in/) | E—commerce | Log Management | [Gurgaon Meetup talk, March 2025](https://clickhouse.com/videos/gurgaon—meetup—olx—india—optimizing—log—management) | — | — | +| [OLX India](https://www.olx.in/) | E-commerce | Log Management | [Gurgaon Meetup talk, March 2025](https://clickhouse.com/videos/gurgaon-meetup-olx-india-optimizing-log-management) | — | — | | [Omnicomm](https://omnicomm.ru/) | Transportation Monitoring | — | [Facebook post, October 2021](https://www.facebook.com/OmnicommTeam/posts/2824479777774500) | — | — | -| [OneAPM](https://www.oneapm.com/) | Monitoring and Data Analysis | Main product | [Slides in Chinese, October 2018](https://github.com/ClickHouse/clickhouse—presentations/blob/master/meetup19/8.%20clickhouse在OneAPM的应用%20杜龙.pdf) | — | — | +| [OneAPM](https://www.oneapm.com/) | Monitoring and Data Analysis | Main product | [Slides in Chinese, October 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup19/8.%20clickhouse在OneAPM的应用%20杜龙.pdf) | — | — | | [One Fact Foundation](https://www.onefact.org/) | Healthcare | CDN/Web data | [GitHub repository](https://github.com/ClickHouse/ClickHouse/issues/67296) | — | 2PB | | [OneUptime](https://oneuptime.com/) | Observability platform | Analytics | [GitHub repository](https://github.com/OneUptime/oneuptime) | — | — | | [Onepixel.link](https://onepixel.link/) | Software | URL shorterner | [Twitter, 2024](https://twitter.com/championswimmer/status/1759195487134220415) | — | — | -| [Ongage](https://www.ongage.com/) | Marketing | Analytics | [Blog](https://clickhouse.com/blog/ongages—strategic—shift—to—clickhouse—for—real—time—email—marketing) | — | — | +| [Ongage](https://www.ongage.com/) | Marketing | Analytics | [Blog](https://clickhouse.com/blog/ongages-strategic-shift-to-clickhouse-for-real-time-email-marketing) | — | — | | [Ookla](https://www.ookla.com/) | Software & Technology | Network Intelligence | [Presentation at J on the Beach, June 2023](https://www.youtube.com/watch?v=OZ0XpfDM8J0) | — | — | -| [OONI](https://ooni.org/) | Open Observatory of Network Interference (OONI) | Main product | [Blog, May 2023]( https://clickhouse.com/blog/ooni—analyzes—internet—censorship—data—with—clickhouse)[Twitter August 2022](https://twitter.com/OpenObservatory/status/1558014810746265600?s=20&t=hvcDU—LIrgCApP0rZCzuoA) | — | — | +| [OONI](https://ooni.org/) | Open Observatory of Network Interference (OONI) | Main product | [Blog, May 2023]( https://clickhouse.com/blog/ooni-analyzes-internet-censorship-data-with-clickhouse)[Twitter August 2022](https://twitter.com/OpenObservatory/status/1558014810746265600?s=20&t=hvcDU-LIrgCApP0rZCzuoA) | — | — | | [Open Targets](https://www.opentargets.org/) | Genome Research | Genome Search | [Twitter, October 2021](https://twitter.com/OpenTargets/status/1452570865342758913?s=20), [Blog](https://blog.opentargets.org/graphql/) | — | — | | [OpenLIT](https://openlit.io/) | Software & Technology | OTEL Monitoring with AI | [GitHub](https://github.com/openlit/openlit) | — | — | -| [OpenMeter](https://openmeter.io) | Expense Management | Main product | [Offical blog post, 2023](https://openmeter.io/blog/how—openmeter—uses—clickhouse—for—usage—metering#heading—querying—historical—usage) | — | — | -| [OpenReplay](https://openreplay.com/) | Product Analytics | Session Replay | [Docs](https://docs.openreplay.com/en/deployment/openreplay—admin/) | — | — | -| [Opensee](https://opensee.io/) | Financial Analytics | Main product | [Blog Post, February 2022](https://clickhouse.com/blog/opensee—analyzing—terabytes—of—financial—data—a—day—with—clickhouse/) [Blog Post, December 2021](https://opensee.io/news/from—moscow—to—wall—street—the—remarkable—journey—of—clickhouse/) | — | — | +| [OpenMeter](https://openmeter.io) | Expense Management | Main product | [Offical blog post, 2023](https://openmeter.io/blog/how-openmeter-uses-clickhouse-for-usage-metering#heading-querying-historical-usage) | — | — | +| [OpenReplay](https://openreplay.com/) | Product Analytics | Session Replay | [Docs](https://docs.openreplay.com/en/deployment/openreplay-admin/) | — | — | +| [Opensee](https://opensee.io/) | Financial Analytics | Main product | [Blog Post, February 2022](https://clickhouse.com/blog/opensee-analyzing-terabytes-of-financial-data-a-day-with-clickhouse/) [Blog Post, December 2021](https://opensee.io/news/from-moscow-to-wall-street-the-remarkable-journey-of-clickhouse/) | — | — | | [Oppo](https://www.oppo.com/cn/) | Hardware | Consumer Electronics Company | ClickHouse Meetup in Chengdu, April 2024 | — | — | | [OpsVerse](https://opsverse.io/) | Observability | — | [Twitter, 2022](https://twitter.com/OpsVerse/status/1584548242100219904) | — | — | -| [Opstrace](https://opstrace.com/) | Observability | — | [Source code](https://gitlab.com/gitlab—org/opstrace/jaeger—clickhouse/—/blob/main/README.md) | — | — | +| [Opstrace](https://opstrace.com/) | Observability | — | [Source code](https://gitlab.com/gitlab-org/opstrace/jaeger-clickhouse/-/blob/main/README.md) | — | — | +| [Outerbase](https://www.outerbase.com/) | Software & Technology | Database Interface | [Official Website](https://www.outerbase.com/) | — | — | | [Oxide](https://oxide.computer/) | Hardware & Software | Server Control Plane | [GitHub Repository](https://github.com/oxidecomputer/omicron) | — | — | -| [OZON](https://corp.ozon.com/) | E—commerce | — | [Official website](https://job.ozon.ru/vacancy/razrabotchik—clickhouse—ekspluatatsiya—40991870/) | — | — | +| [OZON](https://corp.ozon.com/) | E-commerce | — | [Official website](https://job.ozon.ru/vacancy/razrabotchik-clickhouse-ekspluatatsiya-40991870/) | — | — | | [PITS Globale Datenrettungsdienste](https://www.pitsdatenrettung.de/) | Data Recovery | Analytics | | — | — | -| [PRANA](https://prana—system.com/en/) | Industrial predictive analytics | Main product | [News (russian), Feb 2021](https://habr.com/en/news/t/541392/) | — | — | +| [PRANA](https://prana-system.com/en/) | Industrial predictive analytics | Main product | [News (russian), Feb 2021](https://habr.com/en/news/t/541392/) | — | — | | [Pace](https://www.paceapp.com/) | Marketing & Sales | Internal app | ClickHouse Cloud user | — | — | -| [Panelbear](https://panelbear.com/) | Analytics | Monitoring and Analytics | [Tech Stack, November 2020](https://panelbear.com/blog/tech—stack/) | — | — | +| [Panelbear](https://panelbear.com/) | Analytics | Monitoring and Analytics | [Tech Stack, November 2020](https://panelbear.com/blog/tech-stack/) | — | — | | [Papermark](https://www.papermark.io/) | Software & Technology | Document Sharing & Analytics | [Twitter, September 2023](https://twitter.com/mfts0/status/1698670144367567263) | — | — | -| [Parcel Perform](https://www.parcelperform.com/) | E—commerce | Real—Time Analaytics | [Ho Chi Minh Meetup talk, April 2025](https://clickhouse.com/videos/hochiminh—meetup—parcel—perform—clickhouse—at—a—midsize—company) | — | — | -| [Percent 百分点](https://www.percent.cn/) | Analytics | Main Product | [Slides in Chinese, June 2019](https://github.com/ClickHouse/clickhouse—presentations/blob/master/meetup24/4.%20ClickHouse万亿数据双中心的设计与实践%20.pdf) | — | — | -| [Percona](https://www.percona.com/) | Performance analysis | Percona Monitoring and Management | [Official website, Mar 2020](https://www.percona.com/blog/2020/03/30/advanced—query—analysis—in—percona—monitoring—and—management—with—direct—clickhouse—access/) | — | — | -| [Phare](https://phare.io/) | Uptime Monitoring | Main Product | [Official website, Aug 2023](https://docs.phare.io/changelog/platform/2023#faster—monitoring—statistics) | — | — | +| [Parcel Perform](https://www.parcelperform.com/) | E-commerce | Real-Time Analaytics | [Ho Chi Minh Meetup talk, April 2025](https://clickhouse.com/videos/hochiminh-meetup-parcel-perform-clickhouse-at-a-midsize-company) | — | — | +| [Percent 百分点](https://www.percent.cn/) | Analytics | Main Product | [Slides in Chinese, June 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup24/4.%20ClickHouse万亿数据双中心的设计与实践%20.pdf) | — | — | +| [Percona](https://www.percona.com/) | Performance analysis | Percona Monitoring and Management | [Official website, Mar 2020](https://www.percona.com/blog/2020/03/30/advanced-query-analysis-in-percona-monitoring-and-management-with-direct-clickhouse-access/) | — | — | +| [Phare](https://phare.io/) | Uptime Monitoring | Main Product | [Official website, Aug 2023](https://docs.phare.io/changelog/platform/2023#faster-monitoring-statistics) | — | — | | [PheLiGe](https://phelige.com/about) | Software & Technology | Genetic Studies | [Academic Paper, November 2020](https://academic.oup.com/nar/article/49/D1/D1347/6007654?login=false) | — | — | -| [Physics Wallah](https://www.pw.live/) | Education Technology | Real—Time Analytics | [Gurgaon Meetup talk, March 2025](https://clickhouse.com/videos/gurgaon—meetup—clickhouse—at—physics—wallah) | — | — | -| [PingCAP](https://pingcap.com/) | Analytics | Real—Time Transactional and Analytical Processing | [GitHub, TiFlash/TiDB](https://github.com/pingcap/tiflash) | — | — | +| [Physics Wallah](https://www.pw.live/) | Education Technology | Real-Time Analytics | [Gurgaon Meetup talk, March 2025](https://clickhouse.com/videos/gurgaon-meetup-clickhouse-at-physics-wallah) | — | — | +| [PingCAP](https://pingcap.com/) | Analytics | Real-Time Transactional and Analytical Processing | [GitHub, TiFlash/TiDB](https://github.com/pingcap/tiflash) | — | — | | [Pirsch](https://pirsch.io/) | Software & Technology | Web Analytics | [Hacker News, April 2023](https://news.ycombinator.com/item?id=35692201) | — | — | -| [Piwik PRO](https://piwik.pro/) | Web Analytics | — | [Official website, Dec 2018](https://piwik.pro/blog/piwik—pro—clickhouse—faster—efficient—reports/) | — | — | +| [Piwik PRO](https://piwik.pro/) | Web Analytics | — | [Official website, Dec 2018](https://piwik.pro/blog/piwik-pro-clickhouse-faster-efficient-reports/) | — | — | | [Plane](https://plane.so/) | Software & Technology | Project Management | [Twitter, September 2023](https://twitter.com/vamsi_kurama/status/1699593472704176441) | — | — | -| [Plausible](https://plausible.io/) | Analytics | Main Product | [Blog Post, December 2021](https://clickhouse.com/blog/plausible—analytics—uses—click—house—to—power—their—privacy—friendly—google—analytics—alternative) [Twitter, June 2020](https://twitter.com/PlausibleHQ/status/1273889629087969280) | — | — | +| [Plausible](https://plausible.io/) | Analytics | Main Product | [Blog Post, December 2021](https://clickhouse.com/blog/plausible-analytics-uses-click-house-to-power-their-privacy-friendly-google-analytics-alternative) [Twitter, June 2020](https://twitter.com/PlausibleHQ/status/1273889629087969280) | — | — | | [PoeticMetric](https://www.poeticmetric.com/) | Metrics | Main Product | Community Slack, April 2022 | — | — | +| [PQL](https://pql.dev/) | Software & Technology | SQL Query Tool | [Official Website](https://pql.dev/) | — | — | | [Portkey AI](https://portkey.ai/) | LLMOps | Main Product | [LinkedIn post, August 2023](https://www.linkedin.com/feed/update/urn:li:activity:7094676373826330626/) | — | — | -| [PostHog](https://posthog.com/) | Product Analytics | Main Product | [Release Notes, October 2020](https://posthog.com/blog/the—posthog—array—1—15—0), [Blog, November 2021](https://posthog.com/blog/how—we—turned—clickhouse—into—our—eventmansion) | — | — | +| [PostHog](https://posthog.com/) | Product Analytics | Main Product | [Release Notes, October 2020](https://posthog.com/blog/the-posthog-array-1-15-0), [Blog, November 2021](https://posthog.com/blog/how-we-turned-clickhouse-into-our-eventmansion) | — | — | | [Postmates](https://postmates.com/) | Delivery | — | [Talk in English, July 2020](https://youtu.be/GMiXCMFDMow?t=188) | — | — | -| [Pragma Innovation](http://www.pragma—innovation.fr/) | Telemetry and Big Data Analysis | Main product | [Slides in English, October 2018](https://github.com/ClickHouse/clickhouse—presentations/blob/master/meetup18/4_pragma_innovation.pdf) | — | — | -| [Prefect](https://www.prefect.io/) | Software & Technology | Main Product | [Blog, May 2024](https://clickhouse.com/blog/prefect—event—driven—workflow—orchestration—powered—by—clickhouse) | — | — | -| [Propel](https://www.propeldata.com/) | Analytics | Main product | [Blog, January 2024](https://www.propeldata.com/blog/how—to—store—json—in—clickhouse—the—right—way) | — | — | +| [Pragma Innovation](http://www.pragma-innovation.fr/) | Telemetry and Big Data Analysis | Main product | [Slides in English, October 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup18/4_pragma_innovation.pdf) | — | — | +| [Prefect](https://www.prefect.io/) | Software & Technology | Main Product | [Blog, May 2024](https://clickhouse.com/blog/prefect-event-driven-workflow-orchestration-powered-by-clickhouse) | — | — | +| [Propel](https://www.propeldata.com/) | Analytics | Main product | [Blog, January 2024](https://www.propeldata.com/blog/how-to-store-json-in-clickhouse-the-right-way) | — | — | | [Property Finder](https://www.propertyfinder.com/) | Real Estate | — | ClickHouse Cloud user | — | — | -| [QINGCLOUD](https://www.qingcloud.com/) | Cloud services | Main product | [Slides in Chinese, October 2018](https://github.com/ClickHouse/clickhouse—presentations/blob/master/meetup19/4.%20Cloud%20%2B%20TSDB%20for%20ClickHouse%20张健%20QingCloud.pdf) | — | — | -| [Qrator](https://qrator.net) | DDoS protection | Main product | [Blog Post, March 2019](https://blog.qrator.net/en/clickhouse—ddos—mitigation_37/) | — | — | +| [QINGCLOUD](https://www.qingcloud.com/) | Cloud services | Main product | [Slides in Chinese, October 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup19/4.%20Cloud%20%2B%20TSDB%20for%20ClickHouse%20张健%20QingCloud.pdf) | — | — | +| [Qrator](https://qrator.net) | DDoS protection | Main product | [Blog Post, March 2019](https://blog.qrator.net/en/clickhouse-ddos-mitigation_37/) | — | — | | [Qualified](https://www.qualified.com/) | Sales Pipeline Management | Data and Messaging layers | [Job posting, Nov 2022](https://news.ycombinator.com/item?id=33425109) | — | — | -| [Qube Research & Technologies](https://www.qube—rt.com/) | FinTech | Analysis | ClickHouse Cloud user | — | — | -| [QuickCheck](https://quickcheck.ng/) | FinTech | Analytics | [Blog post, May 2022](https://clickhouse.com/blog/how—quickcheck—uses—clickhouse—to—bring—banking—to—the—unbanked/) | — | — | -| [R—Vision](https://rvision.pro/en/) | Information Security | — | [Article in Russian, December 2021](https://www.anti—malware.ru/reviews/R—Vision—SENSE—15) | — | — | -| [RELEX](https://relexsolutions.com) | Supply Chain Planning | Forecasting | [Meetup Video, December 2022](https://www.youtube.com/watch?v=wyOSMR8l—DI&list=PL0Z2YDlm0b3iNDUzpY1S3L_iV4nARda_U&index=16) [Slides, December 2022](https://presentations.clickhouse.com/meetup65/CRUDy%20OLAP.pdf) | — | — | +| [Qube Research & Technologies](https://www.qube-rt.com/) | FinTech | Analysis | ClickHouse Cloud user | — | — | +| [QuickCheck](https://quickcheck.ng/) | FinTech | Analytics | [Blog post, May 2022](https://clickhouse.com/blog/how-quickcheck-uses-clickhouse-to-bring-banking-to-the-unbanked/) | — | — | +| [R-Vision](https://rvision.pro/en/) | Information Security | — | [Article in Russian, December 2021](https://www.anti-malware.ru/reviews/R-Vision-SENSE-15) | — | — | +| [RELEX](https://relexsolutions.com) | Supply Chain Planning | Forecasting | [Meetup Video, December 2022](https://www.youtube.com/watch?v=wyOSMR8l-DI&list=PL0Z2YDlm0b3iNDUzpY1S3L_iV4nARda_U&index=16) [Slides, December 2022](https://presentations.clickhouse.com/meetup65/CRUDy%20OLAP.pdf) | — | — | | [Raiffeisenbank](https://www.rbinternational.com/) | Banking | Analytics | [Lecture in Russian, December 2020](https://cs.hse.ru/announcements/421965599.html) | — | — | -| [Railway](https://railway.app/) | Software & Technology | PaaS Software Tools | [Changelog, May 2023](https://railway.app/changelog/2023—05—19—horizontal—scaling#logs—are—getting—faster) | — | — | -| [Rambler](https://rambler.ru) | Internet services | Analytics | [Talk in Russian, April 2018](https://medium.com/@ramblertop/разработка—api—clickhouse—для—рамблер—топ—100—f4c7e56f3141) | — | — | -| [Ramp](https://ramp.com/) | Financial Services | Real—Time Analytics, Fraud Detection | [NYC Meetup, March 2024](https://www.youtube.com/watch?v=7BtUgUb4gCs) | — | — | +| [Railway](https://railway.app/) | Software & Technology | PaaS Software Tools | [Changelog, May 2023](https://railway.app/changelog/2023-05-19-horizontal-scaling#logs-are-getting-faster) | — | — | +| [Rambler](https://rambler.ru) | Internet services | Analytics | [Talk in Russian, April 2018](https://medium.com/@ramblertop/разработка-api-clickhouse-для-рамблер-топ-100-f4c7e56f3141) | — | — | +| [Ramp](https://ramp.com/) | Financial Services | Real-Time Analytics, Fraud Detection | [NYC Meetup, March 2024](https://www.youtube.com/watch?v=7BtUgUb4gCs) | — | — | | [Rapid Delivery Analytics](https://rda.team/) | Retail | Analytics | ClickHouse Cloud user | — | — | -| [Real Estate Analytics](https://rea—global.com/) | Software & Technology | Real—time Analytics | [Singapore meetup, February 2025](https://clickhouse.com/videos/singapore—meetup—real—estate—analytics—clickhouse—journey) , [Blog, April 2025](https://clickhouse.com/blog/how—real—estate—analytics—made—its—data—pipeline—50x—faster—with—clickhouse) | — | — | -| [Releem](https://releem.com/) | Databases | MySQL management | [Blog 2024](https://releem.com/blog/whats—new—at—releem—june—2023) | — | — | +| [Real Estate Analytics](https://rea-global.com/) | Software & Technology | Real-time Analytics | [Singapore meetup, February 2025](https://clickhouse.com/videos/singapore-meetup-real-estate-analytics-clickhouse-journey) , [Blog, April 2025](https://clickhouse.com/blog/how-real-estate-analytics-made-its-data-pipeline-50x-faster-with-clickhouse) | — | — | +| [Releem](https://releem.com/) | Databases | MySQL management | [Blog 2024](https://releem.com/blog/whats-new-at-releem-june-2023) | — | — | | [Replica](https://replicahq.com) | Urban Planning | Analytics | [Job advertisement](https://boards.greenhouse.io/replica/jobs/5547732002?gh_jid=5547732002) | — | — | | [Request Metrics](https://requestmetrics.com/) | Software & Technology | Observability | [Hacker News, May 2023](https://news.ycombinator.com/item?id=35982281) | — | — | -| [Rengage](https://rengage.ai/) | Marketing Analytics | Main product | [Bellevue Meetup, August 2024](https://github.com/user—attachments/files/17135804/Rengage.—.clickhouse.1.pptx) | — | — | +| [Rengage](https://rengage.ai/) | Marketing Analytics | Main product | [Bellevue Meetup, August 2024](https://github.com/user-attachments/files/17135804/Rengage.-.clickhouse.1.pptx) | — | — | | [Resmo](https://replicahq.com) | Software & Technology | Cloud Security & Asset Management | | 1 c7g.xlarge node, | | -| [Retell](https://retell.cc/) | Speech synthesis | Analytics | [Blog Article, August 2020](https://vc.ru/services/153732—kak—sozdat—audiostati—na—vashem—sayte—i—zachem—eto—nuzhno) | — | — | +| [Retell](https://retell.cc/) | Speech synthesis | Analytics | [Blog Article, August 2020](https://vc.ru/services/153732-kak-sozdat-audiostati-na-vashem-sayte-i-zachem-eto-nuzhno) | — | — | | [Rivet](https://rivet.gg/) | Software & Technology | Gamer Server Scaling | [HackerNews, August 2023](https://news.ycombinator.com/item?id=37188659) | — | — | -| [Roblox](https://www.roblox.com/) | Gaming | Safety operations | [San Francisco Meetup, September 2024](https://github.com/user—attachments/files/17135964/2024—09—05—ClickHouse—Meetup—Roblox.1.pdf) | — | 100M events per day | -| [Rokt](https://www.rokt.com/) | Software & Technology | eCommerce | [Meetup Video, December 2022](https://www.youtube.com/watch?v=BEP07Edor—0&list=PL0Z2YDlm0b3iNDUzpY1S3L_iV4nARda_U&index=10) [Slides, December 2022](https://github.com/ClickHouse/clickhouse—presentations/blob/master/meetup67/Building%20the%20future%20of%20reporting%20at%20Rokt.pdf) | — | — | +| [Roblox](https://www.roblox.com/) | Gaming | Safety operations | [San Francisco Meetup, September 2024](https://github.com/user-attachments/files/17135964/2024-09-05-ClickHouse-Meetup-Roblox.1.pdf) | — | 100M events per day | +| [Rokt](https://www.rokt.com/) | Software & Technology | eCommerce | [Meetup Video, December 2022](https://www.youtube.com/watch?v=BEP07Edor-0&list=PL0Z2YDlm0b3iNDUzpY1S3L_iV4nARda_U&index=10) [Slides, December 2022](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup67/Building%20the%20future%20of%20reporting%20at%20Rokt.pdf) | — | — | | [Rollbar](https://www.rollbar.com) | Software Development | Main Product | [Official Website](https://www.rollbar.com) | — | — | | [Rspamd](https://rspamd.com/) | Antispam | Analytics | [Official Website](https://rspamd.com/doc/modules/clickhouse.html) | — | — | | [RuSIEM](https://rusiem.com/en) | SIEM | Main Product | [Official Website](https://rusiem.com/en/products/architecture) | — | — | | [RunReveal](https://runreveal.com/) | SIEM | Main Product | [SF Meetup, Nov 2023](https://www.youtube.com/watch?v=rVZ9JnbzHTQ&list=PL0Z2YDlm0b3iNDUzpY1S3L_iV4nARda_U&index=25) | — | — | | [S7 Airlines](https://www.s7.ru) | Airlines | Metrics, Logging | [Talk in Russian, March 2019](https://www.youtube.com/watch?v=nwG68klRpPg&t=15s) | — | — | -| [SEMrush](https://www.semrush.com/) | Marketing | Main product | [Slides in Russian, August 2018](https://github.com/ClickHouse/clickhouse—presentations/blob/master/meetup17/5_semrush.pdf) | — | — | +| [SEMrush](https://www.semrush.com/) | Marketing | Main product | [Slides in Russian, August 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup17/5_semrush.pdf) | — | — | | [SESCO Trading](https://www.sescotrading.com/) | Financial | Analysis | ClickHouse Cloud user | — | — | -| [SGK](http://www.sgk.gov.tr/wps/portal/sgk/tr) | Government Social Security | Analytics | [Slides in English, November 2019](https://github.com/ClickHouse/clickhouse—presentations/blob/master/meetup35/ClickHouse%20Meetup—Ramazan%20POLAT.pdf) | — | — | +| [SGK](http://www.sgk.gov.tr/wps/portal/sgk/tr) | Government Social Security | Analytics | [Slides in English, November 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup35/ClickHouse%20Meetup-Ramazan%20POLAT.pdf) | — | — | | [SMI2](https://smi2.ru/) | News | Analytics | [Blog Post in Russian, November 2017](https://habr.com/ru/company/smi2/blog/314558/) | — | — | -| [SQLPad](https://getsqlpad.com/en/introduction/) | Software & Technology | Web—based SQL editor. | [GitHub, March 2023](https://github.com/sqlpad/sqlpad/blob/master/server/package.json#L43) | — | — | +| [Synclite](https://www.synclite.io/) | Software & Technology | Database Replication | [Official Website](https://www.synclite.io/) | — | — | +| [SQLPad](https://getsqlpad.com/en/introduction/) | Software & Technology | Web-based SQL editor. | [GitHub, March 2023](https://github.com/sqlpad/sqlpad/blob/master/server/package.json#L43) | — | — | | [Santiment](https://www.santiment.net) | Behavioral analytics for the crypto market | Main Product | [Github repo](https://github.com/santiment/sanbase2) | — | — | | [Sber](https://www.sberbank.com/index) | Banking, Fintech, Retail, Cloud, Media | — | [Job advertisement, March 2021](https://career.habr.com/vacancies/1000073536) | 128 servers | >1 PB | | [Scale8](https://scale8.com) | Tag Management and Analytics | Main product | [Source Code](https://github.com/scale8/scale8) | — | — | -| [Scarf](https://about.scarf.sh/) | Open source analytics | Main product | [Meetup, December 2024](https://github.com/ClickHouse/clickhouse—presentations/blob/master/2024—meetup—san—francisco/ClickHouse%20Meet—up%20talk_%20Scarf%20%26%20Clickhouse.pdf) | — | — | -| [Scireum GmbH](https://www.scireum.de/) | e—Commerce | Main product | [Talk in German, February 2020](https://www.youtube.com/watch?v=7QWAn5RbyR4) | — | — | +| [Scarf](https://about.scarf.sh/) | Open source analytics | Main product | [Meetup, December 2024](https://github.com/ClickHouse/clickhouse-presentations/blob/master/2024-meetup-san-francisco/ClickHouse%20Meet-up%20talk_%20Scarf%20%26%20Clickhouse.pdf) | — | — | +| [Scireum GmbH](https://www.scireum.de/) | e-Commerce | Main product | [Talk in German, February 2020](https://www.youtube.com/watch?v=7QWAn5RbyR4) | — | — | | [ScrapingBee](https://www.scrapingbee.com/) | Software & Technology | Web scraping API | [Twitter, January 2024](https://twitter.com/PierreDeWulf/status/1745464855723986989) | — | — | | [ScratchDB](https://scratchdb.com/) | Software & Technology | Serverless Analytics | [GitHub](https://github.com/scratchdata/ScratchDB) | — | — | -| [Segment](https://segment.com/) | Data processing | Main product | [Slides, 2019](https://slides.com/abraithwaite/segment—clickhouse) | 9 * i3en.3xlarge nodes 7.5TB NVME SSDs, 96GB Memory, 12 vCPUs | — | +| [Segment](https://segment.com/) | Data processing | Main product | [Slides, 2019](https://slides.com/abraithwaite/segment-clickhouse) | 9 * i3en.3xlarge nodes 7.5TB NVME SSDs, 96GB Memory, 12 vCPUs | — | | [sembot.io](https://sembot.io/) | Shopping Ads | — | A comment on LinkedIn, 2020 | — | — | -| [Sendinblue](https://www.sendinblue.com/) | Software & Technology | Segmentation | [Blog, February 2023](https://engineering.sendinblue.com/segmentation—to—target—the—right—audience/) | 100 nodes | — | +| [Sendinblue](https://www.sendinblue.com/) | Software & Technology | Segmentation | [Blog, February 2023](https://engineering.sendinblue.com/segmentation-to-target-the-right-audience/) | 100 nodes | — | | [Sentio](https://www.sentio.xyz/) | Software & Technology | Observability | [Twitter, April 2023](https://twitter.com/qiaokan/status/1650736518955438083) | — | — | -| [Sentry](https://sentry.io/) | Software Development | Main product | [Blog Post in English, May 2019](https://blog.sentry.io/2019/05/16/introducing—snuba—sentrys—new—search—infrastructure) | — | — | -| [seo.do](https://seo.do/) | Analytics | Main product | [Slides in English, November 2019](https://github.com/ClickHouse/clickhouse—presentations/blob/master/meetup35/CH%20Presentation—%20Metehan%20Çetinkaya.pdf) | — | — | -| [Serif Health](https://www.serifhealth.com/) | Healthcare | Price transparency platform | [Chicago meetup, Sempteber 2019](https://clickhouse.com/videos/price—transparency—made—easy) | — | — | +| [Sentry](https://sentry.io/) | Software Development | Main product | [Blog Post in English, May 2019](https://blog.sentry.io/2019/05/16/introducing-snuba-sentrys-new-search-infrastructure) | — | — | +| [seo.do](https://seo.do/) | Analytics | Main product | [Slides in English, November 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup35/CH%20Presentation-%20Metehan%20Çetinkaya.pdf) | — | — | +| [Serif Health](https://www.serifhealth.com/) | Healthcare | Price transparency platform | [Chicago meetup, Sempteber 2019](https://clickhouse.com/videos/price-transparency-made-easy) | — | — | | [Serverless](https://www.serverless.com/) | Serverless Apps | Metrics | ClickHouse Cloud user | — | — | -| [ServiceNow](https://www.servicenow.com/) | Managed Services | Qualitative Mobile Analytics | [Meetup Video, January 2023](https://www.youtube.com/watch?v=b4Pmpx3iRK4&list=PL0Z2YDlm0b3iNDUzpY1S3L_iV4nARda_U&index=6) [Slides, January 2023](https://github.com/ClickHouse/clickhouse—presentations/blob/master/meetup68/Appsee%20Remodeling%20—%20ClickHouse.pdf) | — | — | +| [ServiceNow](https://www.servicenow.com/) | Managed Services | Qualitative Mobile Analytics | [Meetup Video, January 2023](https://www.youtube.com/watch?v=b4Pmpx3iRK4&list=PL0Z2YDlm0b3iNDUzpY1S3L_iV4nARda_U&index=6) [Slides, January 2023](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup68/Appsee%20Remodeling%20-%20ClickHouse.pdf) | — | — | | [Sewer AI](https://www.sewerai.com/) | Software & Technology | — | ClickHouse Cloud user | — | — | -| [Shopee](https://www.shopee.com/) | E—Commerce | Distributed Tracing | [Meetup Video, April 2024](https://youtu.be/_BVy—V2wy9s?feature=shared) [Slides, April 2024](https://raw.githubusercontent.com/ClickHouse/clickhouse—presentations/master/2024—meetup—singapore—1/Shopee%20—%20Distributed%20Tracing%20in%20ClickHouse.pdf) [Blog Post, June 2024](https://clickhouse.com/blog/seeing—the—big—picture—shopees—journey—to—distributed—tracing—with—clickhouse) | — | — | -| [SigNoz](https://signoz.io/) | Observability Platform | Main Product | [Source code](https://github.com/SigNoz/signoz) , [Bangalore Meetup, February 2025](https://clickhouse.com/videos/lessons—from—building—a—scalable—observability—backend) | — | — | -| [Sina](http://english.sina.com/index.html) | News | — | [Slides in Chinese, October 2018](https://github.com/ClickHouse/clickhouse—presentations/blob/master/meetup19/6.%20ClickHouse最佳实践%20高鹏_新浪.pdf) | — | — | +| [Shopee](https://www.shopee.com/) | E-Commerce | Distributed Tracing | [Meetup Video, April 2024](https://youtu.be/_BVy-V2wy9s?feature=shared) [Slides, April 2024](https://raw.githubusercontent.com/ClickHouse/clickhouse-presentations/master/2024-meetup-singapore-1/Shopee%20-%20Distributed%20Tracing%20in%20ClickHouse.pdf) [Blog Post, June 2024](https://clickhouse.com/blog/seeing-the-big-picture-shopees-journey-to-distributed-tracing-with-clickhouse) | — | — | +| [SigNoz](https://signoz.io/) | Observability Platform | Main Product | [Source code](https://github.com/SigNoz/signoz) , [Bangalore Meetup, February 2025](https://clickhouse.com/videos/lessons-from-building-a-scalable-observability-backend) | — | — | +| [Sina](http://english.sina.com/index.html) | News | — | [Slides in Chinese, October 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup19/6.%20ClickHouse最佳实践%20高鹏_新浪.pdf) | — | — | | [Sinch](https://www.sinch.com/) | Software & Technology | Customer Communications Cloud | [HackerNews, May 2023](https://news.ycombinator.com/item?id=36042104) | — | — | | [Sipfront](https://www.sipfront.com/) | Software Development | Analytics | [Twitter, October 2021](https://twitter.com/andreasgranig/status/1446404332337913895?s=20) | — | — | | [SiteBehaviour Analytics](https://www.sitebehaviour.com/) | Software | Analytics | [Twitter, 2024](https://twitter.com/developer_jass/status/1763023792970883322) | — | — | -| [Skool](https://www.skool.com/) | Community platform | Behavioral/Experimentation Analytics | [SoCal Meetup, August 2024](https://github.com/user—attachments/files/17081161/ClickHouse.Meetup.pptx) | — | 100m rows/day | -| [slido](https://www.slido.com/) | Software & Technology | Q&A and Polling | [Meetup, April 2023](https://www.linkedin.com/events/datameetup—3—spotlightondataeng7048914766324473856/about/) | — | — | +| [Skool](https://www.skool.com/) | Community platform | Behavioral/Experimentation Analytics | [SoCal Meetup, August 2024](https://github.com/user-attachments/files/17081161/ClickHouse.Meetup.pptx) | — | 100m rows/day | +| [slido](https://www.slido.com/) | Software & Technology | Q&A and Polling | [Meetup, April 2023](https://www.linkedin.com/events/datameetup-3-spotlightondataeng7048914766324473856/about/) | — | — | | [Solarwinds](https://www.solarwinds.com/) | Software & Technology | Main product | [Talk in English, March 2018](https://www.youtube.com/watch?v=w8eTlqGEkkw) | — | — | | [Sonrai Security](https://sonraisecurity.com/) | Cloud Security | — | Slack comments | — | — | -| [Spark New Zealand](https://www.spark.co.nz/) | Telecommunications | Security Operations | [Blog Post, Feb 2020](https://blog.n0p.me/2020/02/2020—02—05—dnsmonster/) | — | — | +| [Spark New Zealand](https://www.spark.co.nz/) | Telecommunications | Security Operations | [Blog Post, Feb 2020](https://blog.n0p.me/2020/02/2020-02-05-dnsmonster/) | — | — | | [Spec](https://www.specprotected.com/) | Software & Technology | Online Fraud Detection | [HackerNews, August 2023](https://news.ycombinator.com/item?id=36965317) | — | — | | [spectate](https://spectate.net/) | Software & Technology | Monitoring & Incident Management | [Twitter, August 2023](https://twitter.com/BjarnBronsveld/status/1700458569861112110) | — | — | | [Splio](https://splio.com/en/) | Software & Technology | Individuation Marketing | [Slack, September 2023](https://clickhousedb.slack.com/archives/C04N3AU38DV/p1693995069023669) | — | — | -| [Splitbee](https://splitbee.io) | Analytics | Main Product | [Blog Post, Mai 2021](https://splitbee.io/blog/new—pricing) | — | — | -| [Splunk](https://www.splunk.com/) | Business Analytics | Main product | [Slides in English, January 2018](https://github.com/ClickHouse/clickhouse—presentations/blob/master/meetup12/splunk.pdf) | — | — | -| [Spotify](https://www.spotify.com) | Music | Experimentation | [Slides, July 2018](https://www.slideshare.net/glebus/using—clickhouse—for—experimentation—104247173) | — | — | +| [Splitbee](https://splitbee.io) | Analytics | Main Product | [Blog Post, Mai 2021](https://splitbee.io/blog/new-pricing) | — | — | +| [Splunk](https://www.splunk.com/) | Business Analytics | Main product | [Slides in English, January 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup12/splunk.pdf) | — | — | +| [Spotify](https://www.spotify.com) | Music | Experimentation | [Slides, July 2018](https://www.slideshare.net/glebus/using-clickhouse-for-experimentation-104247173) | — | — | | [Staffbase](https://staffbase.com/en/) | Software & Technology | Internal Communications | [ClickHouse Slack, April 2023](https://clickhousedb.slack.com/archives/C04N3AU38DV/p1682781081062859) | — | — | | [Staffcop](https://www.staffcop.ru/) | Information Security | Main Product | [Official website, Documentation](https://www.staffcop.ru/sce43) | — | — | -| [Statsig](https://statsig.com/) | Software & Technology | Real—time analytics | [Video](https://clickhouse.com/videos/statsig) | — | — | -| [Streamkap](https://streamkap.com/) | Data Platform | — | [Video](https://clickhouse.com/videos/switching—from—elasticsearch—to—clickhouse) | — | — | -| [Suning](https://www.suning.com/) | E—Commerce | User behaviour analytics | [Blog article](https://www.sohu.com/a/434152235_411876) | — | — | -| [Superology](https://superology.com/) | Software & Technology | Customer Analytics | [Blog Post, June 2022](https://clickhouse.com/blog/collecting—semi—structured—data—from—kafka—topics—using—clickhouse—kafka—engine) | — | — | +| [Statsig](https://statsig.com/) | Software & Technology | Real-time analytics | [Video](https://clickhouse.com/videos/statsig) | — | — | +| [Streamkap](https://streamkap.com/) | Data Platform | — | [Video](https://clickhouse.com/videos/switching-from-elasticsearch-to-clickhouse) | — | — | +| [Suning](https://www.suning.com/) | E-Commerce | User behaviour analytics | [Blog article](https://www.sohu.com/a/434152235_411876) | — | — | +| [Superology](https://superology.com/) | Software & Technology | Customer Analytics | [Blog Post, June 2022](https://clickhouse.com/blog/collecting-semi-structured-data-from-kafka-topics-using-clickhouse-kafka-engine) | — | — | | [Superwall](https://superwall.me/) | Monetization Tooling | Main product | [Word of mouth, Jan 2022](https://github.com/ClickHouse/ClickHouse/pull/33573) | — | — | -| [SwarmFarm Robotics](https://www.swarmfarm.com/) | Agriculture & Technology | Main Product | [Meetup Slides](https://github.com/ClickHouse/clickhouse—presentations/blob/master/2024—meetup—melbourne—2/Talk%20Track%202%20—%20Harvesting%20Big%20Data%20at%20SwarmFarm%20Robotics%20—%20Angus%20Ross.pdf) | — | — | -| [Swetrix](https://swetrix.com) | Analytics | Main Product | [Source code](https://github.com/swetrix/swetrix—api) | — | — | +| [SwarmFarm Robotics](https://www.swarmfarm.com/) | Agriculture & Technology | Main Product | [Meetup Slides](https://github.com/ClickHouse/clickhouse-presentations/blob/master/2024-meetup-melbourne-2/Talk%20Track%202%20-%20Harvesting%20Big%20Data%20at%20SwarmFarm%20Robotics%20-%20Angus%20Ross.pdf) | — | — | +| [Swetrix](https://swetrix.com) | Analytics | Main Product | [Source code](https://github.com/swetrix/swetrix-api) | — | — | | [Swift Navigation](https://www.swiftnav.com/) | Geo Positioning | Data Pipelines | [Job posting, Nov 2022](https://news.ycombinator.com/item?id=33426590) | — | — | -| [Synerise](https://synerise.com/) | ML&AI | Feature Store | [Presentation, April 2020](https://www.slideshare.net/AndrzejMichaowski/feature—store—solving—antipatterns—in—mlsystems—232829863) | — | — | +| [Synerise](https://synerise.com/) | ML&AI | Feature Store | [Presentation, April 2020](https://www.slideshare.net/AndrzejMichaowski/feature-store-solving-antipatterns-in-mlsystems-232829863) | — | — | | [Synpse](https://synpse.net/) | Application Management | Main Product | [Twitter, January 2022](https://twitter.com/KRusenas/status/1483571168363880455) | — | — | -| [Synq](https://www.synq.io) | Software & Technology | Main Product | [Blog Post, July 2023](https://clickhouse.com/blog/building—a—unified—data—platform—with—clickhouse) | — | — | +| [Synq](https://www.synq.io) | Software & Technology | Main Product | [Blog Post, July 2023](https://clickhouse.com/blog/building-a-unified-data-platform-with-clickhouse) | — | — | | [sumsub](https://sumsub.com/) | Software & Technology | Verification platform | [Meetup, July 2022](https://www.youtube.com/watch?v=F74bBGSMwGo) | — | — | -| [Talo Game Services](https://trytalo.com) | Gaming Analytics | Event—based player analytics | [Blog, August 2024](https://trytalo.com/blog/events—clickhouse—migration) | — | — | -| [Tasrie IT Services](https://tasrieit.com) | Software & Technology | Analytics | [Blog, January 2025](https://tasrieit.com/how—tasrie—it—services—uses—clickhouse) | — | — | +| [Talo Game Services](https://trytalo.com) | Gaming Analytics | Event-based player analytics | [Blog, August 2024](https://trytalo.com/blog/events-clickhouse-migration) | — | — | +| [Tasrie IT Services](https://tasrieit.com) | Software & Technology | Analytics | [Blog, January 2025](https://tasrieit.com/how-tasrie-it-services-uses-clickhouse) | — | — | | [TURBOARD](https://www.turboard.com/) | BI Analytics | — | [Official website](https://www.turboard.com/blogs/clickhouse) | — | — | | [TeamApt](https://www.teamapt.com/) | FinTech | Data Processing | [Official Website](https://www.teamapt.com/) | — | — | | [Teamtailor](https://www.teamtailor.com/en/) | Recruitment Software | — | ClickHouse Cloud user | — | — | -| [Tekion](https://tekion.com/) | Automotive Retail | Clickstream Analytics | [Blog Post, June 2024](https://clickhouse.com/blog/tekion—adopts—clickhouse—cloud—to—power—application—performance—and—metrics—monitoring) | — | — | -| [Temporal](https://www.tencentmusic.com/) | Infrastructure software | Observability product | [Bellevue Meetup, August 2024](https://github.com/user—attachments/files/17135746/Temporal.Supercharged.Observability.with.ClickHouse.pdf) | — | — | +| [Tekion](https://tekion.com/) | Automotive Retail | Clickstream Analytics | [Blog Post, June 2024](https://clickhouse.com/blog/tekion-adopts-clickhouse-cloud-to-power-application-performance-and-metrics-monitoring) | — | — | +| [Temporal](https://www.tencentmusic.com/) | Infrastructure software | Observability product | [Bellevue Meetup, August 2024](https://github.com/user-attachments/files/17135746/Temporal.Supercharged.Observability.with.ClickHouse.pdf) | — | — | | [Tencent Music Entertainment (TME)](https://www.tencentmusic.com/) | BigData | Data processing | [Blog in Chinese, June 2020](https://cloud.tencent.com/developer/article/1637840) | — | — | -| [Tencent](https://www.tencent.com) | Big Data | Data processing | [Slides in Chinese, October 2018](https://github.com/ClickHouse/clickhouse—presentations/blob/master/meetup19/5.%20ClickHouse大数据集群应用_李俊飞腾讯网媒事业部.pdf) | — | — | -| [Tencent](https://www.tencent.com) | Messaging | Logging | [Talk in Chinese, November 2019](https://youtu.be/T—iVQRuw—QY?t=5050) | — | — | -| [Teralytics](https://www.teralytics.net/) | Mobility | Analytics | [Tech blog](https://www.teralytics.net/knowledge—hub/visualizing—mobility—data—the—scalability—challenge) | — | — | +| [Tencent](https://www.tencent.com) | Big Data | Data processing | [Slides in Chinese, October 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup19/5.%20ClickHouse大数据集群应用_李俊飞腾讯网媒事业部.pdf) | — | — | +| [Tencent](https://www.tencent.com) | Messaging | Logging | [Talk in Chinese, November 2019](https://youtu.be/T-iVQRuw-QY?t=5050) | — | — | +| [Teralytics](https://www.teralytics.net/) | Mobility | Analytics | [Tech blog](https://www.teralytics.net/knowledge-hub/visualizing-mobility-data-the-scalability-challenge) | — | — | | [Tesla](https://www.tesla.com/) | Electric vehicle and clean energy company | — | [Vacancy description, March 2021](https://news.ycombinator.com/item?id=26306170) | — | — | -| [The Guild](https://the—guild.dev/) | API Platform | Monitoring | [Blog Post, November 2022](https://clickhouse.com/blog/100x—faster—graphql—hive—migration—from—elasticsearch—to—clickhouse) [Blog](https://the—guild.dev/blog/graphql—hive—and—clickhouse) | — | — | +| [The Guild](https://the-guild.dev/) | API Platform | Monitoring | [Blog Post, November 2022](https://clickhouse.com/blog/100x-faster-graphql-hive-migration-from-elasticsearch-to-clickhouse) [Blog](https://the-guild.dev/blog/graphql-hive-and-clickhouse) | — | — | | [Theia](https://theia.so/) | Software & Technology | Threat Intelligence | [Twitter, July 2023](https://twitter.com/jreynoldsdev/status/1680639586999980033) | — | — | | [ThirdWeb](https://thirdweb.com/) | Software & Technology | Blockchain analysis | ClickHouse Cloud user | — | — | -| [Timeflow](https://timeflow.systems) | Software | Analytics | [Blog](https://timeflow.systems/why—we—moved—from—druid—to—clickhouse/ ) | — | — | -| [Timeplus](https://www.timeplus.com/) | Software & Technology | Streaming Analytics | [Meetup, August 2023](https://www.meetup.com/clickhouse—silicon—valley—meetup—group/events/294472987/) | — | — | -| [Tinybird](https://www.tinybird.co/) | Real—time Data Products | Data processing | [Official website](https://www.tinybird.co/) | — | — | +| [Timeflow](https://timeflow.systems) | Software | Analytics | [Blog](https://timeflow.systems/why-we-moved-from-druid-to-clickhouse/ ) | — | — | +| [Timeplus](https://www.timeplus.com/) | Software & Technology | Streaming Analytics | [Meetup, August 2023](https://www.meetup.com/clickhouse-silicon-valley-meetup-group/events/294472987/) | — | — | +| [Tinybird](https://www.tinybird.co/) | Real-time Data Products | Data processing | [Official website](https://www.tinybird.co/) | — | — | | [TrackingPlan](https://www.trackingplan.com/) | Marketing & Sales | Monitoring | ClickHouse Cloud user | — | — | -| [Traffic Stars](https://trafficstars.com/) | AD network | — | [Slides in Russian, May 2018](https://github.com/ClickHouse/clickhouse—presentations/blob/master/meetup15/lightning/ninja.pdf) | 300 servers in Europe/US | 1.8 PiB, 700 000 insert rps (as of 2021) | -| [Trillabit](https://www.trillabit.com/home) | Software & Technology | Business Intelligence | [Blog, January 2023](https://clickhouse.com/blog/trillabit—utilizes—the—power—of—clickhouse—for—fast—scalable—results—within—their—self—service—search—driven—analytics—offering) | — | — | -| [Trip.com](https://trip.com/) | Travel Services | Logging | [Meetup, March 2023](https://github.com/ClickHouse/clickhouse—presentations/blob/master/meetup71/Trip.com.pdf) | — | — | +| [Traffic Stars](https://trafficstars.com/) | AD network | — | [Slides in Russian, May 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup15/lightning/ninja.pdf) | 300 servers in Europe/US | 1.8 PiB, 700 000 insert rps (as of 2021) | +| [Trillabit](https://www.trillabit.com/home) | Software & Technology | Business Intelligence | [Blog, January 2023](https://clickhouse.com/blog/trillabit-utilizes-the-power-of-clickhouse-for-fast-scalable-results-within-their-self-service-search-driven-analytics-offering) | — | — | +| [Trip.com](https://trip.com/) | Travel Services | Logging | [Meetup, March 2023](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup71/Trip.com.pdf) | — | — | | [Turkcell](https://www.turkcell.com.tr/) | Telecom | BI Analytics | [YouTube Video](https://www.youtube.com/watch?v=ckvPBgXl82Q) | 2 nodes | 2TB per day, 100TB in total | -| [Tweeq](https://tweeq.sa/en) | Fintech | Spending Account | [Engineering Blog, May 2024](https://engineering.tweeq.sa/tweeq—data—platform—journey—and—lessons—learned—clickhouse—dbt—dagster—and—superset—fa27a4a61904) | — | — | -| [Twilio](https://www.twilio.com) | Customer engagement | Twilio SendGrid | [Meetup presentation, September 2024](https://github.com/user—attachments/files/17135790/twilio—sendgrid—clickhouse.1.pdf) | — | 10b events/day | -| [Tydo](https://www.tydo.com) | Customer intelligence | Customer Segmentation product | [SoCal meetup, August 2024](https://github.com/user—attachments/files/17081169/Tydo_ClickHouse.Presentation.8_21.pdf) | — | — | +| [Tweeq](https://tweeq.sa/en) | Fintech | Spending Account | [Engineering Blog, May 2024](https://engineering.tweeq.sa/tweeq-data-platform-journey-and-lessons-learned-clickhouse-dbt-dagster-and-superset-fa27a4a61904) | — | — | +| [Twilio](https://www.twilio.com) | Customer engagement | Twilio SendGrid | [Meetup presentation, September 2024](https://github.com/user-attachments/files/17135790/twilio-sendgrid-clickhouse.1.pdf) | — | 10b events/day | +| [Tydo](https://www.tydo.com) | Customer intelligence | Customer Segmentation product | [SoCal meetup, August 2024](https://github.com/user-attachments/files/17081169/Tydo_ClickHouse.Presentation.8_21.pdf) | — | — | | [URLsLab](https://www.urlslab.com/) | Software & Technology | WordPress Plugin | [Twitter, July 2023](https://twitter.com/Yasha_br/status/1680224776302784514) , [Twitter, September 2023](https://twitter.com/Yasha_br/status/1698724654339215812) | — | — | -| [UTMSTAT](https://hello.utmstat.com/) | Analytics | Main product | [Blog post, June 2020](https://vc.ru/tribuna/133956—striming—dannyh—iz—servisa—skvoznoy—analitiki—v—clickhouse) | — | — | +| [UTMSTAT](https://hello.utmstat.com/) | Analytics | Main product | [Blog post, June 2020](https://vc.ru/tribuna/133956-striming-dannyh-iz-servisa-skvoznoy-analitiki-v-clickhouse) | — | — | | [Uber](https://www.uber.com) | Taxi | Logging | [Slides, February 2020](https://presentations.clickhouse.com/meetup40/uber.pdf) | — | — | -| [Uptrace](https://uptrace.dev/) | Software | Tracing Solution | [Official website, March 2021](https://uptrace.dev/open—source/) | — | — | +| [Uptrace](https://uptrace.dev/) | Software | Tracing Solution | [Official website, March 2021](https://uptrace.dev/open-source/) | — | — | | [UseTech](https://usetech.com/) | Software Development | — | [Job Posting, December 2021](https://vk.com/wall136266658_2418) | — | — | | [Usermaven](https://usermaven.com/) | Product Analytics | Main Product | [HackerNews, January 2023](https://news.ycombinator.com/item?id=34404706) | — | — | -| [VKontakte](https://vk.com) | Social Network | Statistics, Logging | [Slides in Russian, August 2018](https://github.com/ClickHouse/clickhouse—presentations/blob/master/meetup17/3_vk.pdf) | — | — | -| [VKontech](https://vkontech.com/) | Distributed Systems | Migrating from MongoDB | [Blog, January 2022](https://vkontech.com/migrating—your—reporting—queries—from—a—general—purpose—db—mongodb—to—a—data—warehouse—clickhouse—performance—overview/) | — | — | -| [VMware](https://www.vmware.com/) | Cloud | VeloCloud, SDN | [Product documentation](https://docs.vmware.com/en/vRealize—Operations—Manager/8.3/com.vmware.vcom.metrics.doc/GUID—A9AD72E1—C948—4CA2—971B—919385AB3CA8.html) | — | — | +| [VKontakte](https://vk.com) | Social Network | Statistics, Logging | [Slides in Russian, August 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup17/3_vk.pdf) | — | — | +| [VKontech](https://vkontech.com/) | Distributed Systems | Migrating from MongoDB | [Blog, January 2022](https://vkontech.com/migrating-your-reporting-queries-from-a-general-purpose-db-mongodb-to-a-data-warehouse-clickhouse-performance-overview/) | — | — | +| [VMware](https://www.vmware.com/) | Cloud | VeloCloud, SDN | [Product documentation](https://docs.vmware.com/en/vRealize-Operations-Manager/8.3/com.vmware.vcom.metrics.doc/GUID-A9AD72E1-C948-4CA2-971B-919385AB3CA8.html) | — | — | | [Valueleaf Services Pvt.Ltd](http://valueleaf.com/) | Software & Technology | Martech platform, Ads platform and Loan aggregator platform | [ClickHouse Slack, April 2023](https://clickhousedb.slack.com/archives/C04N3AU38DV/p1681122299263959) | — | — | -| [Vantage](https://www.vantage.sh/) | Software & Technology | Cloud Cost Management | [Meetup, April 2023](https://www.youtube.com/watch?v=gBgXcHM_ldc) , [ClickHouse Blog, June 2023](https://clickhouse.com/blog/nyc—meetup—report—vantages—journey—from—redshift—and—postgres—to—clickhouse) | — | — | +| [Vantage](https://www.vantage.sh/) | Software & Technology | Cloud Cost Management | [Meetup, April 2023](https://www.youtube.com/watch?v=gBgXcHM_ldc) , [ClickHouse Blog, June 2023](https://clickhouse.com/blog/nyc-meetup-report-vantages-journey-from-redshift-and-postgres-to-clickhouse) | — | — | | [Velvet](https://www.usevelvet.com/) | Database management | Main product | [Job listing](https://news.ycombinator.com/item?id=38492272) | — | — | | [Vercel](https://vercel.com/) | Traffic and Performance Analytics | — | Direct reference, October 2021 | — | — | | [Vexo](https://www.vexo.co/) | App development | Analytics | [Twitter, December 2023](https://twitter.com/FalcoAgustin/status/1737161334213546279) | — | — | | [Vidazoo](https://www.vidazoo.com/) | Advertising | Analytics | ClickHouse Cloud user | — | — | -| [Vimeo](https://vimeo.com/) | Video hosting | Analytics | [Blog post](https://medium.com/vimeo—engineering—blog/clickhouse—is—in—the—house—413862c8ac28) | — | — | +| [Vimeo](https://vimeo.com/) | Video hosting | Analytics | [Blog post](https://medium.com/vimeo-engineering-blog/clickhouse-is-in-the-house-413862c8ac28) | — | — | | [Visiology](https://visiology.com/) | Business intelligence | Analytics | [Company website](https://visiology.com/) | — | — | -| [Voltmetrix](https://voltmetrix.com/) | Database management | Main product | [Blog post](https://voltmetrix.com/blog/voltmetrix—iot—manufacturing—use—case/) | — | — | -| [Voltus](https://www.voltus.co/) | Energy | — | [Blog Post, Aug 2022](https://medium.com/voltus—engineering/migrating—kafka—to—amazon—msk—1f3a7d45b5f2) | — | — | +| [Voltmetrix](https://voltmetrix.com/) | Database management | Main product | [Blog post](https://voltmetrix.com/blog/voltmetrix-iot-manufacturing-use-case/) | — | — | +| [Voltus](https://www.voltus.co/) | Energy | — | [Blog Post, Aug 2022](https://medium.com/voltus-engineering/migrating-kafka-to-amazon-msk-1f3a7d45b5f2) | — | — | | [W3 Analytics](https://w3analytics.hottoshotto.com/) | Blockchain | Dashboards for NFT analytics | [Community Slack, July 2023](https://clickhousedb.slack.com/archives/CU170QE9H/p1689907164648339) | — | — | | [WSPR Live](https://wspr.live/) | Software & Technology | WSPR Spot Data | [Twitter, April 2023](https://twitter.com/HB9VQQ/status/1652723207475015680) | — | — | | [Waitlyst](https://waitlyst.co/) | Software & Technology | AI Customer Journey Management | [Twitter, June 2023](https://twitter.com/aaronkazah/status/1668261900554051585) | — | — | | [Walmart Labs](https://www.walmartlabs.com/) | Internet, Retail | — | [Talk in English, July 2020](https://youtu.be/GMiXCMFDMow?t=144) | — | — | -| [WanShanData](http://wanshandata.com/home) | Software & Technology | Main Product | [Meetup Slides in Chinese](https://github.com/ClickHouse/clickhouse—presentations/blob/master/meetup56/wanshandata.pdf) | — | — | +| [WanShanData](http://wanshandata.com/home) | Software & Technology | Main Product | [Meetup Slides in Chinese](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup56/wanshandata.pdf) | — | — | | [Wargaming](https://wargaming.com/en/) | Games | | [Interview](https://habr.com/en/post/496954/) | — | — | | [WebGazer](https://www.webgazer.io/) | Uptime Monitoring | Main Product | Community Slack, April 2022 | — | — | | [WebScrapingHQ](https://www.webscrapinghq.com/) | Software & Technology | Web scraping API | [X, Novemeber 2024](https://x.com/harsh_maur/status/1862129151806968054) | — | — | -| [Weights & Biases](https://wandb.ai/site) | Software & Technology | LLM Monitoring | [Twitter, April 2024](https://github.com/user—attachments/files/17157064/Lukas.—.Clickhouse.pptx) | — | — | -| [Wildberries](https://www.wildberries.ru/) | E—commerce | | [Official website](https://it.wildberries.ru/) | — | — | -| [Wisebits](https://wisebits.com/) | IT Solutions | Analytics | [Slides in Russian, May 2019](https://github.com/ClickHouse/clickhouse—presentations/blob/master/meetup22/strategies.pdf) | — | — | +| [Weights & Biases](https://wandb.ai/site) | Software & Technology | LLM Monitoring | [Twitter, April 2024](https://github.com/user-attachments/files/17157064/Lukas.-.Clickhouse.pptx) | — | — | +| [Wildberries](https://www.wildberries.ru/) | E-commerce | | [Official website](https://it.wildberries.ru/) | — | — | +| [Wisebits](https://wisebits.com/) | IT Solutions | Analytics | [Slides in Russian, May 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup22/strategies.pdf) | — | — | | [Workato](https://www.workato.com/) | Automation Software | — | [Talk in English, July 2020](https://youtu.be/GMiXCMFDMow?t=334) | — | — | | [Wowza](https://www.wowza.com/) | Video Platform | Streaming Analytics | ClickHouse Cloud user | — | — | | [Wundergraph](https://wundergraph.com/) | Software & Technology | API Platform | [Twitter, February 2023](https://twitter.com/dustindeus/status/1628757807913750531) | — | — | | [Xata](https://xata.io/) | Software & Technology | SaaS observability dashboard | [Twitter, March 2024](https://x.com/tudor_g/status/1770517054971318656) | — | — | -| [Xenoss](https://xenoss.io/) | Martech, Adtech development | — | [Official website](https://xenoss.io/big—data—solution—development) | — | — | -| [Xiaoxin Tech](http://www.xiaoxintech.cn/) | Education | Common purpose | [Slides in English, November 2019](https://github.com/ClickHouse/clickhouse—presentations/blob/master/meetup33/sync—clickhouse—with—mysql—mongodb.pptx) | — | — | -| [Ximalaya](https://www.ximalaya.com/) | Audio sharing | OLAP | [Slides in English, November 2019](https://github.com/ClickHouse/clickhouse—presentations/blob/master/meetup33/ximalaya.pdf) | — | — | +| [Xenoss](https://xenoss.io/) | Martech, Adtech development | — | [Official website](https://xenoss.io/big-data-solution-development) | — | — | +| [Xiaoxin Tech](http://www.xiaoxintech.cn/) | Education | Common purpose | [Slides in English, November 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup33/sync-clickhouse-with-mysql-mongodb.pptx) | — | — | +| [Ximalaya](https://www.ximalaya.com/) | Audio sharing | OLAP | [Slides in English, November 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup33/ximalaya.pdf) | — | — | | [YTsaurus](https://ytsaurus.tech/) | Distributed Storage and Processing | Main product | [Main website](https://ytsaurus.tech/) | — | — | -| [Yandex Cloud](https://cloud.yandex.ru/services/managed—clickhouse) | Public Cloud | Main product | [Talk in Russian, December 2019](https://www.youtube.com/watch?v=pgnak9e_E0o) | — | — | +| [Yandex Cloud](https://cloud.yandex.ru/services/managed-clickhouse) | Public Cloud | Main product | [Talk in Russian, December 2019](https://www.youtube.com/watch?v=pgnak9e_E0o) | — | — | | [Yandex DataLens](https://cloud.yandex.ru/services/datalens) | Business Intelligence | Main product | [Slides in Russian, December 2019](https://presentations.clickhouse.com/meetup38/datalens.pdf) | — | — | -| [Yandex Market](https://market.yandex.ru/) | e—Commerce | Metrics, Logging | [Talk in Russian, January 2019](https://youtu.be/_l1qP0DyBcA?t=478) | — | — | +| [Yandex Market](https://market.yandex.ru/) | e-Commerce | Metrics, Logging | [Talk in Russian, January 2019](https://youtu.be/_l1qP0DyBcA?t=478) | — | — | | [Yandex Metrica](https://metrica.yandex.com) | Web analytics | Main product | [Slides, February 2020](https://presentations.clickhouse.com/meetup40/introduction/#13) | 630 servers in one cluster, 360 servers in another cluster, 1862 servers in one department | 133 PiB / 8.31 PiB / 120 trillion records | -| [Yellowfin](https://www.yellowfinbi.com) | Analytics | Main product | [Integration](https://www.yellowfinbi.com/campaign/yellowfin—9—whats—new#el—30219e0e) | — | — | +| [Yellowfin](https://www.yellowfinbi.com) | Analytics | Main product | [Integration](https://www.yellowfinbi.com/campaign/yellowfin-9-whats-new#el-30219e0e) | — | — | | [Yotascale](https://www.yotascale.com/) | Cloud | Data pipeline | [LinkedIn (Accomplishments)](https://www.linkedin.com/in/adilsaleem/) | — | 2 bn records/day | -| [Your Analytics](https://www.your—analytics.org/) | Product Analytics | Main Product | [Twitter, November 2021](https://twitter.com/mikenikles/status/1459737241165565953) | — | — | +| [Your Analytics](https://www.your-analytics.org/) | Product Analytics | Main Product | [Twitter, November 2021](https://twitter.com/mikenikles/status/1459737241165565953) | — | — | | [Zagrava Trading](https://zagravagames.com/en/) | — | — | [Job offer, May 2021](https://twitter.com/datastackjobs/status/1394707267082063874) | — | — | | [Zappi](https://www.zappi.io/web/) | Software & Technology | Market Research | [Twitter Post, June 2024](https://x.com/HermanLangner/status/1805870318218580004)) | — | — | -| [Zerodha](https://zerodha.tech/) | Stock Broker | Logging | [Blog, March 2023](https://zerodha.tech/blog/logging—at—zerodha/) | — | — | -| [Zing Data](https://getzingdata.com/) | Software & Technology | Business Intelligence | [Blog, May 2023](https://clickhouse.com/blog/querying—clickhouse—on—your—phone—with—zing—data) | — | — | -| [Zipy](https://www.zipy.ai/) | Software & Technology | User session debug | [Blog, April 2023](https://www.zipy.ai/blog/deep—dive—into—clickhouse) | — | — | -| [Zomato](https://www.zomato.com/) | Online food ordering | Logging | [Blog, July 2023](https://www.zomato.com/blog/building—a—cost—effective—logging—platform—using—clickhouse—for—petabyte—scale) | — | — | -| [Zomato](https://www.zomato.com/ncr/golf—course—order—online) | Food & Beverage | Food Delivery | [Blog 2024](https://blog.zomato.com/building—a—cost—effective—logging—platform—using—clickhouse—for—petabyte—scale) | — | — | -| [Zoox](https://zoox.com/) | Software & Technology | Observability | [Job listing](https://www.linkedin.com/jobs/view/senior—software—engineer—observability—at—zoox—4139400247) | — | — | -| [АС "Стрела"](https://magenta—technology.ru/sistema—upravleniya—marshrutami—inkassacii—as—strela/) | Transportation | — | [Job posting, Jan 2022](https://vk.com/topic—111905078_35689124?post=3553) | — | — | +| [Zerodha](https://zerodha.tech/) | Stock Broker | Logging | [Blog, March 2023](https://zerodha.tech/blog/logging-at-zerodha/) | — | — | +| [Zing Data](https://getzingdata.com/) | Software & Technology | Business Intelligence | [Blog, May 2023](https://clickhouse.com/blog/querying-clickhouse-on-your-phone-with-zing-data) | — | — | +| [Zipy](https://www.zipy.ai/) | Software & Technology | User session debug | [Blog, April 2023](https://www.zipy.ai/blog/deep-dive-into-clickhouse) | — | — | +| [Zomato](https://www.zomato.com/) | Online food ordering | Logging | [Blog, July 2023](https://www.zomato.com/blog/building-a-cost-effective-logging-platform-using-clickhouse-for-petabyte-scale) | — | — | +| [Zomato](https://www.zomato.com/ncr/golf-course-order-online) | Food & Beverage | Food Delivery | [Blog 2024](https://blog.zomato.com/building-a-cost-effective-logging-platform-using-clickhouse-for-petabyte-scale) | — | — | +| [Zoox](https://zoox.com/) | Software & Technology | Observability | [Job listing](https://www.linkedin.com/jobs/view/senior-software-engineer-observability-at-zoox-4139400247) | — | — | +| [АС "Стрела"](https://magenta-technology.ru/sistema-upravleniya-marshrutami-inkassacii-as-strela/) | Transportation | — | [Job posting, Jan 2022](https://vk.com/topic-111905078_35689124?post=3553) | — | — | | [ДомКлик](https://domclick.ru/) | Real Estate | — | [Article in Russian, October 2021](https://habr.com/ru/company/domclick/blog/585936/) | — | — | -| [МКБ](https://mkb.ru/) | Bank | Web—system monitoring | [Slides in Russian, September 2019](https://github.com/ClickHouse/clickhouse—presentations/blob/master/meetup28/mkb.pdf) | — | — | +| [МКБ](https://mkb.ru/) | Bank | Web-system monitoring | [Slides in Russian, September 2019](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup28/mkb.pdf) | — | — | | [ООО «МПЗ Богородский»](https://shop.okraina.ru/) | Agriculture | — | [Article in Russian, November 2020](https://cloud.yandex.ru/cases/okraina) | — | — | -| [ЦВТ](https://htc—cs.ru/) | Software Development | Metrics, Logging | [Blog Post, March 2019, in Russian](https://vc.ru/dev/62715—kak—my—stroili—monitoring—na—prometheus—clickhouse—i—elk) | — | — | +| [ЦВТ](https://htc-cs.ru/) | Software Development | Metrics, Logging | [Blog Post, March 2019, in Russian](https://vc.ru/dev/62715-kak-my-stroili-monitoring-na-prometheus-clickhouse-i-elk) | — | — | | [ЦФТ](https://cft.ru/) | Banking, Financial products, Payments | — | [Meetup in Russian, April 2020](https://team.cft.ru/events/162) | — | — | | [Цифровой Рабочий](https://promo.croc.ru/digitalworker) | Industrial IoT, Analytics | — | [Blog post in Russian, March 2021](https://habr.com/en/company/croc/blog/548018/) | — | — | - diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/about-us/beta-and-experimental-features.md b/i18n/zh/docusaurus-plugin-content-docs/current/about-us/beta-and-experimental-features.md index 8eb903fa084..e96c9a335b4 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/about-us/beta-and-experimental-features.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/about-us/beta-and-experimental-features.md @@ -1,47 +1,168 @@ --- 'sidebar_position': 1 -'sidebar_label': '测试版功能和实验' -'title': '测试版和实验功能' -'description': 'ClickHouse 具有 beta 和实验功能。此文档页面讨论定义。' +'sidebar_label': 'Beta 特性和实验' +'title': 'Beta 和实验特性' +'description': 'ClickHouse 具有 beta 和实验特性。此文档页面讨论定义。' 'slug': '/beta-and-experimental-features' +'doc_type': 'reference' --- -因为 ClickHouse 是开源的,它不仅得到了 ClickHouse 员工的许多贡献,还得到了社区的贡献。这些贡献的开发速度往往不同;某些功能可能需要较长的原型开发阶段,或者需要更多时间进行充分的社区反馈和迭代,才能被视为一般可用(GA)。 +因为 ClickHouse 是开源的,它不仅得到了 ClickHouse 员工的众多贡献,也得到了社区的贡献。这些贡献的开发速度往往不同;某些功能可能需要较长的原型制作阶段,或者需要更多的社区反馈和迭代时间,才能被认为是正式可用(GA)。 -由于不确定什么时候功能被分类为一般可用,我们将功能分为两个类别:**Beta** 和 **Experimental**。 +由于不确定何时功能被分为正式可用,我们将功能划分为两个类别:**Beta** 和 **Experimental**。 -**Beta** 功能由 ClickHouse 团队正式支持。**Experimental** 功能是由 ClickHouse 团队或社区驱动的早期原型,且不被正式支持。 +**Beta** 功能由 ClickHouse 团队正式支持。**Experimental** 功能是由 ClickHouse 团队或社区驱动的早期原型,不受官方支持。 下面的部分明确描述了 **Beta** 和 **Experimental** 功能的属性: -## Beta Features {#beta-features} +## Beta features {#beta-features} -- 正在积极开发中,以使其达到一般可用(GA) +- 正在积极开发中,以使其成为正式可用(GA) - 主要已知问题可以在 GitHub 上跟踪 -- 功能可能在未来发生变化 +- 功能未来可能会发生变化 - 可能在 ClickHouse Cloud 中启用 -- ClickHouse 团队支持 beta 功能 +- ClickHouse 团队支持 Beta 功能 -以下功能在 ClickHouse Cloud 中被视为 Beta,并可在 ClickHouse Cloud 服务中使用,即使它们当前处于一个名为 ```allow_experimental_*``` 的 ClickHouse 设置中: +您可以在下面找到被认为是 Beta 的功能,这些功能在 ClickHouse Cloud 中可用,并可在您的 ClickHouse Cloud 服务中使用。 -注意:请确保使用当前版本的 ClickHouse [compatibility](/operations/settings/settings#compatibility) 设置,以便使用最近引入的功能。 +注意:请确保使用当前版本的 ClickHouse [compatibility](/operations/settings/settings#compatibility) 设置,以使用近期引入的功能。 -## Experimental Features {#experimental-features} +## Experimental features {#experimental-features} - 可能永远不会成为 GA -- 可能会被删除 -- 可能引入重大变化 -- 功能可能在未来发生变化 -- 需要故意启用 -- ClickHouse 团队 **不支持** Experimental 功能 -- 可能缺乏重要的功能和文档 +- 可能会被移除 +- 可能引入严重的变化 +- 功能在将来可能会改变 +- 需要明确启用 +- ClickHouse 团队 **不支持** 实验性功能 +- 可能缺乏重要功能和文档 - 在云中无法启用 -请注意:除了上述列为 Beta 的功能外,不允许在 ClickHouse Cloud 中启用其他 Experimental 功能。 +请注意:除了上述列为 Beta 的功能外,不允许在 ClickHouse Cloud 中启用其他实验性功能。 +## Beta settings {#beta-settings} + +| Name | Default | +|------|--------| +| [geotoh3_argument_order](/operations/settings/settings#geotoh3_argument_order) | `lat_lon` | +| [enable_lightweight_update](/operations/settings/settings#enable_lightweight_update) | `1` | +| [allow_experimental_correlated_subqueries](/operations/settings/settings#allow_experimental_correlated_subqueries) | `1` | +| [allow_experimental_parallel_reading_from_replicas](/operations/settings/settings#allow_experimental_parallel_reading_from_replicas) | `0` | +| [parallel_replicas_mode](/operations/settings/settings#parallel_replicas_mode) | `read_tasks` | +| [parallel_replicas_count](/operations/settings/settings#parallel_replicas_count) | `0` | +| [parallel_replica_offset](/operations/settings/settings#parallel_replica_offset) | `0` | +| [parallel_replicas_custom_key](/operations/settings/settings#parallel_replicas_custom_key) | `` | +| [parallel_replicas_custom_key_range_lower](/operations/settings/settings#parallel_replicas_custom_key_range_lower) | `0` | +| [parallel_replicas_custom_key_range_upper](/operations/settings/settings#parallel_replicas_custom_key_range_upper) | `0` | +| [cluster_for_parallel_replicas](/operations/settings/settings#cluster_for_parallel_replicas) | `` | +| [parallel_replicas_allow_in_with_subquery](/operations/settings/settings#parallel_replicas_allow_in_with_subquery) | `1` | +| [parallel_replicas_for_non_replicated_merge_tree](/operations/settings/settings#parallel_replicas_for_non_replicated_merge_tree) | `0` | +| [parallel_replicas_min_number_of_rows_per_replica](/operations/settings/settings#parallel_replicas_min_number_of_rows_per_replica) | `0` | +| [parallel_replicas_prefer_local_join](/operations/settings/settings#parallel_replicas_prefer_local_join) | `1` | +| [parallel_replicas_mark_segment_size](/operations/settings/settings#parallel_replicas_mark_segment_size) | `0` | +| [parallel_replicas_local_plan](/operations/settings/settings#parallel_replicas_local_plan) | `1` | +| [parallel_replicas_index_analysis_only_on_coordinator](/operations/settings/settings#parallel_replicas_index_analysis_only_on_coordinator) | `1` | +| [parallel_replicas_support_projection](/operations/settings/settings#parallel_replicas_support_projection) | `1` | +| [parallel_replicas_only_with_analyzer](/operations/settings/settings#parallel_replicas_only_with_analyzer) | `1` | +| [parallel_replicas_insert_select_local_pipeline](/operations/settings/settings#parallel_replicas_insert_select_local_pipeline) | `1` | +| [parallel_replicas_connect_timeout_ms](/operations/settings/settings#parallel_replicas_connect_timeout_ms) | `300` | +| [allow_experimental_database_iceberg](/operations/settings/settings#allow_experimental_database_iceberg) | `0` | +| [allow_experimental_database_unity_catalog](/operations/settings/settings#allow_experimental_database_unity_catalog) | `0` | +| [allow_experimental_database_glue_catalog](/operations/settings/settings#allow_experimental_database_glue_catalog) | `0` | +| [session_timezone](/operations/settings/settings#session_timezone) | `` | +| [low_priority_query_wait_time_ms](/operations/settings/settings#low_priority_query_wait_time_ms) | `1000` | +| [allow_experimental_delta_kernel_rs](/operations/settings/settings#allow_experimental_delta_kernel_rs) | `1` | + + +## Experimental settings {#experimental-settings} + +| Name | Default | +|------|--------| +| [allow_experimental_replacing_merge_with_cleanup](/operations/settings/merge-tree-settings#allow_experimental_replacing_merge_with_cleanup) | `0` | +| [allow_experimental_reverse_key](/operations/settings/merge-tree-settings#allow_experimental_reverse_key) | `0` | +| [allow_remote_fs_zero_copy_replication](/operations/settings/merge-tree-settings#allow_remote_fs_zero_copy_replication) | `0` | +| [enable_replacing_merge_with_cleanup_for_min_age_to_force_merge](/operations/settings/merge-tree-settings#enable_replacing_merge_with_cleanup_for_min_age_to_force_merge) | `0` | +| [force_read_through_cache_for_merges](/operations/settings/merge-tree-settings#force_read_through_cache_for_merges) | `0` | +| [merge_selector_algorithm](/operations/settings/merge-tree-settings#merge_selector_algorithm) | `Simple` | +| [notify_newest_block_number](/operations/settings/merge-tree-settings#notify_newest_block_number) | `0` | +| [part_moves_between_shards_delay_seconds](/operations/settings/merge-tree-settings#part_moves_between_shards_delay_seconds) | `30` | +| [part_moves_between_shards_enable](/operations/settings/merge-tree-settings#part_moves_between_shards_enable) | `0` | +| [remote_fs_zero_copy_path_compatible_mode](/operations/settings/merge-tree-settings#remote_fs_zero_copy_path_compatible_mode) | `0` | +| [remote_fs_zero_copy_zookeeper_path](/operations/settings/merge-tree-settings#remote_fs_zero_copy_zookeeper_path) | `/clickhouse/zero_copy` | +| [remove_rolled_back_parts_immediately](/operations/settings/merge-tree-settings#remove_rolled_back_parts_immediately) | `1` | +| [shared_merge_tree_enable_coordinated_merges](/operations/settings/merge-tree-settings#shared_merge_tree_enable_coordinated_merges) | `0` | +| [shared_merge_tree_enable_keeper_parts_extra_data](/operations/settings/merge-tree-settings#shared_merge_tree_enable_keeper_parts_extra_data) | `0` | +| [shared_merge_tree_merge_coordinator_election_check_period_ms](/operations/settings/merge-tree-settings#shared_merge_tree_merge_coordinator_election_check_period_ms) | `30000` | +| [shared_merge_tree_merge_coordinator_factor](/operations/settings/merge-tree-settings#shared_merge_tree_merge_coordinator_factor) | `2` | +| [shared_merge_tree_merge_coordinator_fetch_fresh_metadata_period_ms](/operations/settings/merge-tree-settings#shared_merge_tree_merge_coordinator_fetch_fresh_metadata_period_ms) | `10000` | +| [shared_merge_tree_merge_coordinator_max_merge_request_size](/operations/settings/merge-tree-settings#shared_merge_tree_merge_coordinator_max_merge_request_size) | `20` | +| [shared_merge_tree_merge_coordinator_max_period_ms](/operations/settings/merge-tree-settings#shared_merge_tree_merge_coordinator_max_period_ms) | `10000` | +| [shared_merge_tree_merge_coordinator_merges_prepare_count](/operations/settings/merge-tree-settings#shared_merge_tree_merge_coordinator_merges_prepare_count) | `100` | +| [shared_merge_tree_merge_coordinator_min_period_ms](/operations/settings/merge-tree-settings#shared_merge_tree_merge_coordinator_min_period_ms) | `1` | +| [shared_merge_tree_merge_worker_fast_timeout_ms](/operations/settings/merge-tree-settings#shared_merge_tree_merge_worker_fast_timeout_ms) | `100` | +| [shared_merge_tree_merge_worker_regular_timeout_ms](/operations/settings/merge-tree-settings#shared_merge_tree_merge_worker_regular_timeout_ms) | `10000` | +| [shared_merge_tree_virtual_parts_discovery_batch](/operations/settings/merge-tree-settings#shared_merge_tree_virtual_parts_discovery_batch) | `1` | +| [allow_experimental_time_time64_type](/operations/settings/settings#allow_experimental_time_time64_type) | `0` | +| [allow_experimental_kafka_offsets_storage_in_keeper](/operations/settings/settings#allow_experimental_kafka_offsets_storage_in_keeper) | `0` | +| [allow_experimental_delta_lake_writes](/operations/settings/settings#allow_experimental_delta_lake_writes) | `0` | +| [allow_experimental_materialized_postgresql_table](/operations/settings/settings#allow_experimental_materialized_postgresql_table) | `0` | +| [allow_experimental_funnel_functions](/operations/settings/settings#allow_experimental_funnel_functions) | `0` | +| [allow_experimental_nlp_functions](/operations/settings/settings#allow_experimental_nlp_functions) | `0` | +| [allow_experimental_hash_functions](/operations/settings/settings#allow_experimental_hash_functions) | `0` | +| [allow_experimental_object_type](/operations/settings/settings#allow_experimental_object_type) | `0` | +| [allow_experimental_time_series_table](/operations/settings/settings#allow_experimental_time_series_table) | `0` | +| [allow_experimental_codecs](/operations/settings/settings#allow_experimental_codecs) | `0` | +| [throw_on_unsupported_query_inside_transaction](/operations/settings/settings#throw_on_unsupported_query_inside_transaction) | `1` | +| [wait_changes_become_visible_after_commit_mode](/operations/settings/settings#wait_changes_become_visible_after_commit_mode) | `wait_unknown` | +| [implicit_transaction](/operations/settings/settings#implicit_transaction) | `0` | +| [grace_hash_join_initial_buckets](/operations/settings/settings#grace_hash_join_initial_buckets) | `1` | +| [grace_hash_join_max_buckets](/operations/settings/settings#grace_hash_join_max_buckets) | `1024` | +| [join_to_sort_minimum_perkey_rows](/operations/settings/settings#join_to_sort_minimum_perkey_rows) | `40` | +| [join_to_sort_maximum_table_rows](/operations/settings/settings#join_to_sort_maximum_table_rows) | `10000` | +| [allow_experimental_join_right_table_sorting](/operations/settings/settings#allow_experimental_join_right_table_sorting) | `0` | +| [allow_statistics_optimize](/operations/settings/settings#allow_statistics_optimize) | `0` | +| [allow_experimental_statistics](/operations/settings/settings#allow_experimental_statistics) | `0` | +| [allow_experimental_full_text_index](/operations/settings/settings#allow_experimental_full_text_index) | `0` | +| [allow_experimental_live_view](/operations/settings/settings#allow_experimental_live_view) | `0` | +| [live_view_heartbeat_interval](/operations/settings/settings#live_view_heartbeat_interval) | `15` | +| [max_live_view_insert_blocks_before_refresh](/operations/settings/settings#max_live_view_insert_blocks_before_refresh) | `64` | +| [allow_experimental_window_view](/operations/settings/settings#allow_experimental_window_view) | `0` | +| [window_view_clean_interval](/operations/settings/settings#window_view_clean_interval) | `60` | +| [window_view_heartbeat_interval](/operations/settings/settings#window_view_heartbeat_interval) | `15` | +| [wait_for_window_view_fire_signal_timeout](/operations/settings/settings#wait_for_window_view_fire_signal_timeout) | `10` | +| [stop_refreshable_materialized_views_on_startup](/operations/settings/settings#stop_refreshable_materialized_views_on_startup) | `0` | +| [allow_experimental_database_materialized_postgresql](/operations/settings/settings#allow_experimental_database_materialized_postgresql) | `0` | +| [allow_experimental_qbit_type](/operations/settings/settings#allow_experimental_qbit_type) | `0` | +| [allow_experimental_query_deduplication](/operations/settings/settings#allow_experimental_query_deduplication) | `0` | +| [allow_experimental_database_hms_catalog](/operations/settings/settings#allow_experimental_database_hms_catalog) | `0` | +| [allow_experimental_kusto_dialect](/operations/settings/settings#allow_experimental_kusto_dialect) | `0` | +| [allow_experimental_prql_dialect](/operations/settings/settings#allow_experimental_prql_dialect) | `0` | +| [enable_adaptive_memory_spill_scheduler](/operations/settings/settings#enable_adaptive_memory_spill_scheduler) | `0` | +| [allow_experimental_insert_into_iceberg](/operations/settings/settings#allow_experimental_insert_into_iceberg) | `0` | +| [allow_experimental_iceberg_compaction](/operations/settings/settings#allow_experimental_iceberg_compaction) | `0` | +| [write_full_path_in_iceberg_metadata](/operations/settings/settings#write_full_path_in_iceberg_metadata) | `0` | +| [iceberg_metadata_compression_method](/operations/settings/settings#iceberg_metadata_compression_method) | `` | +| [make_distributed_plan](/operations/settings/settings#make_distributed_plan) | `0` | +| [distributed_plan_execute_locally](/operations/settings/settings#distributed_plan_execute_locally) | `0` | +| [distributed_plan_default_shuffle_join_bucket_count](/operations/settings/settings#distributed_plan_default_shuffle_join_bucket_count) | `8` | +| [distributed_plan_default_reader_bucket_count](/operations/settings/settings#distributed_plan_default_reader_bucket_count) | `8` | +| [distributed_plan_force_exchange_kind](/operations/settings/settings#distributed_plan_force_exchange_kind) | `` | +| [distributed_plan_max_rows_to_broadcast](/operations/settings/settings#distributed_plan_max_rows_to_broadcast) | `20000` | +| [allow_experimental_ytsaurus_table_engine](/operations/settings/settings#allow_experimental_ytsaurus_table_engine) | `0` | +| [allow_experimental_ytsaurus_table_function](/operations/settings/settings#allow_experimental_ytsaurus_table_function) | `0` | +| [allow_experimental_ytsaurus_dictionary_source](/operations/settings/settings#allow_experimental_ytsaurus_dictionary_source) | `0` | +| [distributed_plan_force_shuffle_aggregation](/operations/settings/settings#distributed_plan_force_shuffle_aggregation) | `0` | +| [enable_join_runtime_filters](/operations/settings/settings#enable_join_runtime_filters) | `0` | +| [join_runtime_bloom_filter_bytes](/operations/settings/settings#join_runtime_bloom_filter_bytes) | `524288` | +| [join_runtime_bloom_filter_hash_functions](/operations/settings/settings#join_runtime_bloom_filter_hash_functions) | `3` | +| [rewrite_in_to_join](/operations/settings/settings#rewrite_in_to_join) | `0` | +| [allow_experimental_time_series_aggregate_functions](/operations/settings/settings#allow_experimental_time_series_aggregate_functions) | `0` | +| [promql_database](/operations/settings/settings#promql_database) | `` | +| [promql_table](/operations/settings/settings#promql_table) | `` | +| [promql_evaluation_time](/operations/settings/settings#promql_evaluation_time) | `auto` | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/about-us/beta-and-experimental-features.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/about-us/beta-and-experimental-features.md.hash index e4db834c0d2..e1d34aed05a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/about-us/beta-and-experimental-features.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/about-us/beta-and-experimental-features.md.hash @@ -1 +1 @@ -716dee467d69b364 +452f267194bcd6ee diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/about-us/cloud.md b/i18n/zh/docusaurus-plugin-content-docs/current/about-us/cloud.md index d22679025cf..cae1845cd9f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/about-us/cloud.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/about-us/cloud.md @@ -4,28 +4,50 @@ 'sidebar_position': 10 'description': 'ClickHouse Cloud' 'title': 'ClickHouse Cloud' +'doc_type': 'reference' --- # ClickHouse Cloud -ClickHouse Cloud 是由知名开源 OLAP 数据库 ClickHouse 的原始创建者推出的云服务。您可以通过 [开始免费试用](https://console.clickhouse.cloud/signUp) 来体验 ClickHouse Cloud。 +ClickHouse Cloud 是由流行的开源 OLAP 数据库 ClickHouse 的原始开发者创建的云服务。您可以通过 [开始免费试用](https://console.clickhouse.cloud/signUp) 来体验 ClickHouse Cloud。 -### ClickHouse Cloud 的好处: {#clickhouse-cloud-benefits} +## ClickHouse Cloud 的优势 {#clickhouse-cloud-benefits} -使用 ClickHouse Cloud 的一些好处如下所述: +使用 ClickHouse Cloud 的一些优势如下: -- **快速价值实现**: 无需为集群进行规模评估和扩展,立即开始构建。 -- **无缝扩展**: 自动扩展调整适应可变工作负载,因此您无需为峰值使用过量配置。 -- **无服务器操作**: 放松心情,由我们来处理规模、扩展、安全性、可靠性和升级。 -- **透明定价**: 只为您使用的资源付费,提供资源预留和扩展控制。 -- **总拥有成本**: 最佳价格/性能比和较低的管理开销。 -- **广泛的生态系统**: 带上您喜爱的 数据连接器、可视化工具、SQL 和语言客户端。 +- **快速价值实现**:立即开始构建,无需对集群进行大小和扩展计算。 +- **无缝扩展**:自动扩展能够适应可变的工作负载,因此您无需为高峰使用过度配置。 +- **无服务器操作**:放松身心,我们将负责大小、扩展、安全性、可靠性和升级。 +- **透明定价**:仅为您使用的资源付费,提供资源预留和扩展控制。 +- **总拥有成本**:最佳价格/性能比和低管理开销。 +- **广泛的生态系统**:带上您最喜欢的数据连接器、可视化工具、SQL 和语言客户端。 -### ClickHouse Cloud 使用哪个版本的 ClickHouse? {#what-version-of-clickhouse-does-clickhouse-cloud-use} + -我们提供“快速”发布通道,允许用户提前订阅更新,以便在常规发布计划之前获取信息。有关更多详细信息,请参见 ["快速发布通道"](/manage/updates#fast-release-channel-early-upgrades)。 +## ClickHouse Cloud 使用的 ClickHouse 版本是什么? {#what-version-of-clickhouse-does-clickhouse-cloud-use} -如果您依赖于早期版本中的功能,在某些情况下,您可以使用服务的兼容性设置还原到之前的行为。 +Clickhouse Cloud 会持续升级您的服务到更新版本。在开源中发布核心数据库版本后,我们会在云 staging 环境中进行额外验证,通常需要 6-8 周时间,然后再推出到生产环境。发布是按云服务提供商、服务类型和区域分阶段进行的。 + +我们提供“快速”发布频道,以便用户提前订阅更新。有关更多详细信息,请参见 ["快速发布频道"](/manage/updates#fast-release-channel-early-upgrades)。 + +如果您依赖于早期版本中的功能,您在某些情况下可以使用服务的兼容性设置恢复到先前的行为。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/about-us/cloud.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/about-us/cloud.md.hash index 132a2ec0d94..96009b2c59e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/about-us/cloud.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/about-us/cloud.md.hash @@ -1 +1 @@ -64a94b89cb11b49d +bad95b10e6637710 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/about-us/distinctive-features.md b/i18n/zh/docusaurus-plugin-content-docs/current/about-us/distinctive-features.md index 563f0185cb0..e1038522620 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/about-us/distinctive-features.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/about-us/distinctive-features.md @@ -2,101 +2,102 @@ 'slug': '/about-us/distinctive-features' 'sidebar_label': '为什么ClickHouse独特?' 'sidebar_position': 50 -'description': '了解是什么让ClickHouse与其他 DATABASE 管理系统不同。' -'title': 'ClickHouse的独特特征' +'description': '了解是什么使ClickHouse与其他数据库管理系统不同' +'title': 'ClickHouse的独特特点' 'keywords': - 'compression' - 'secondary-indexes' - 'column-oriented' +'doc_type': 'guide' --- -# ClickHouse 的独特特性 +# ClickHouse的独特特性 ## 真正的列式数据库管理系统 {#true-column-oriented-database-management-system} -在真正的列式 DBMS 中,值旁边不会存储额外的数据。这意味着必须支持固定长度的值,以避免将其长度“数字”存储在值旁边。例如,十亿个 UInt8 类型的值在未压缩的情况下应该消耗大约 1 GB 的空间,否则将严重影响 CPU 的使用。即使在未压缩的情况下,紧凑存储数据(不包含任何“垃圾”)至关重要,因为解压速度(CPU 使用)主要取决于未压缩数据的量。 +在真正的列式数据库管理系统中,值旁边不会存储额外的数据。这意味着必须支持恒定长度的值,以避免将它们的长度“数字”存储在值旁边。例如,十亿个UInt8类型的值在未压缩的情况下应该消耗大约1GB,否则会严重影响CPU使用率。即使在未压缩的情况下,也必须紧凑存储数据(没有任何“垃圾”),因为解压缩的速度(CPU使用率)主要取决于未压缩数据的体积。 -这与能够单独存储不同列值的系统形成对比,但由于针对其他场景的优化,无法有效处理分析查询,例如 HBase、Bigtable、Cassandra 和 Hypertable。在这些系统中,你的吞吐量大约是每秒十万个行,而不是每秒数亿行。 +这与能够分别存储不同列值的系统形成对比,这些系统由于优化用于其他场景而无法有效处理分析查询,例如HBase、Bigtable、Cassandra和Hypertable。在这些系统中,您可以获得每秒大约十万行的吞吐量,而不是每秒数亿行。 -最后,ClickHouse 是一个数据库管理系统,而不是单一数据库。它允许在运行时创建表和数据库,加载数据,并运行查询,而无需重新配置和重启服务器。 +最后,ClickHouse是一个数据库管理系统,而不是单一的数据库。它允许在运行时创建表和数据库、加载数据并运行查询,而无需重新配置和重启服务器。 ## 数据压缩 {#data-compression} -一些列式 DBMS 不使用数据压缩。然而,数据压缩在实现卓越性能方面起着关键作用。 +一些列式数据库管理系统不使用数据压缩。然而,数据压缩在实现卓越性能方面发挥着关键作用。 -除了高效的通用压缩编码器,具有不同的磁盘空间和 CPU 消耗的权衡外,ClickHouse 还提供了针对特定类型数据的 [专用编码器](/sql-reference/statements/create/table.md#specialized-codecs),使 ClickHouse 能够与更小众的数据库(例如时间序列数据库)竞争并超越它们。 +除了具有不同磁盘空间与CPU消耗权衡的高效通用压缩编解码器外,ClickHouse还提供[专用编解码器](/sql-reference/statements/create/table.md#specialized-codecs),以处理特定类型的数据,这使得ClickHouse能够与更小众的数据库(如时间序列数据库)竞争并表现优于它们。 ## 数据的磁盘存储 {#disk-storage-of-data} -通过主键物理排序存储数据使得可以根据特定值或值范围以低延迟提取数据,低于几十毫秒。一些列式 DBMS,如 SAP HANA 和 Google PowerDrill,只能在内存中工作。这种方法需要分配比实时分析所需的更大硬件预算。 +通过主键物理排序数据,可以基于特定值或值范围以低延迟(少于几十毫秒)提取数据。一些列式数据库管理系统,如SAP HANA和Google PowerDrill,仅能在RAM中工作。这种方法需要分配比实时分析所需的更大硬件预算。 -ClickHouse 旨在在常规硬盘上工作,这意味着每 GB 数据存储的成本低,但如果有的话,SSD 和额外的 RAM 也会被充分利用。 +ClickHouse旨在在常规硬盘上工作,这意味着每GB数据存储的成本较低,但如有可用SSD和额外RAM,也会充分利用。 -## 多核心的并行处理 {#parallel-processing-on-multiple-cores} +## 多核并行处理 {#parallel-processing-on-multiple-cores} -大型查询自然会并行化,使用当前服务器上可用的所有必要资源。 +大查询自然实现并行化,利用当前服务器上所有可用的资源。 -## 多服务器的分布式处理 {#distributed-processing-on-multiple-servers} +## 多服务器分布式处理 {#distributed-processing-on-multiple-servers} -几乎没有上述提到的列式 DBMS 支持分布式查询处理。 +几乎没有上述提到的列式数据库管理系统支持分布式查询处理。 -在 ClickHouse 中,数据可以位于不同的分片上。每个分片可以是用于容错的一组副本。所有分片都用于并行运行查询,对用户都是透明的。 +在ClickHouse中,数据可以位于不同的分片上。每个分片可以是用于容错的一组副本。所有分片同时用于并行运行查询,对用户是透明的。 -## SQL 支持 {#sql-support} +## SQL支持 {#sql-support} -ClickHouse 支持与 ANSI SQL 标准大致兼容的 [SQL 语言](/sql-reference/)。 +ClickHouse支持基于SQL的[声明性查询语言](/sql-reference/),它大体上与ANSI SQL标准兼容。 -支持的查询包括 [GROUP BY](../sql-reference/statements/select/group-by.md),[ORDER BY](../sql-reference/statements/select/order-by.md),[FROM](../sql-reference/statements/select/from.md) 中的子查询,[JOIN](../sql-reference/statements/select/join.md) 子句,[IN](../sql-reference/operators/in.md) 运算符, [窗口函数](../sql-reference/window-functions/index.md) 以及标量子查询。 +支持的查询包括[GROUP BY](../sql-reference/statements/select/group-by.md)、[ORDER BY](../sql-reference/statements/select/order-by.md)、在[FROM](../sql-reference/statements/select/from.md)中的子查询、[JOIN](../sql-reference/statements/select/join.md)子句、[IN](../sql-reference/operators/in.md)操作符、[窗口函数](../sql-reference/window-functions/index.md)和标量子查询。 -在撰写本文时,不支持相关(依赖)子查询,但未来可能会提供。 +在撰写时,不支持相关(相依)子查询,但未来可能会提供。 ## 向量计算引擎 {#vector-engine} -数据不仅按列存储,还通过向量(列的部分)进行处理,这使得 CPU 效率高。 +数据不仅以列存储,还以向量(列的一部分)进行处理,从而实现高CPU效率。 ## 实时数据插入 {#real-time-data-updates} -ClickHouse 支持具有主键的表。为了快速在主键的范围内执行查询,数据使用合并树按增量排序。因此,数据可以不断添加到表中。新数据被摄入时不会加锁。 +ClickHouse支持具有主键的表。为了快速在主键范围上执行查询,数据使用合并树进行增量排序。因此,可以不断向表中添加数据。新数据被引入时不会加锁。 ## 主索引 {#primary-index} -数据物理按主键排序使得可以根据特定值或值范围以低延迟提取数据,低于几十毫秒。 +通过主键物理排序数据,可以基于特定值或值范围以低延迟(少于几十毫秒)提取数据。 ## 次级索引 {#secondary-indexes} -与其他数据库管理系统不同,ClickHouse 的次级索引并不指向特定行或行范围。相反,它们使数据库能够提前知道某些数据部分中的所有行不会匹配查询过滤条件,因此根本不读取它们,因此称为 [数据跳过索引](../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-data_skipping-indexes)。 +与其他数据库管理系统不同,ClickHouse的次级索引并不指向特定的行或行范围。相反,它们允许数据库提前知道某些数据部分中的所有行都不符合查询过滤条件,因此完全不读取它们,因此它们被称为[数据跳过索引](../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-data_skipping-indexes)。 ## 适合在线查询 {#suitable-for-online-queries} -大多数 OLAP 数据库管理系统并不致力于寻求具有亚秒延迟的在线查询。在替代系统中,十几秒甚至几分钟的报告生成时间常常被视为可接受的。有时甚至需要更多时间,这迫使系统以离线(提前准备或以“稍后再来”响应)来准备报告。 +大多数OLAP数据库管理系统并不追求亚秒延迟的在线查询。在替代系统中,几秒钟甚至几分钟的报告生成时间通常被认为是可以接受的。有时所需的时间甚至更长,这迫使系统提前准备离线报告(或回应“稍后再来”)。 -在 ClickHouse 中,“低延迟”意味着查询可以在没有延迟的情况下处理,而不需要提前准备答案,正是在用户界面页面加载的同一时刻。换句话说,在线的。 +在ClickHouse中,“低延迟”意味着查询可以在没有延迟的情况下处理,而无需试图提前准备答案,正好在用户界面页面加载时——换句话说,*在线*。 ## 支持近似计算 {#support-for-approximated-calculations} -ClickHouse 提供多种方式用以权衡准确性与性能: +ClickHouse提供多种在性能与准确性之间进行权衡的方法: -1. 用于近似计算的聚合函数,计算独特值、均值和分位数的数量。 -2. 基于数据部分 ([SAMPLE](../sql-reference/statements/select/sample.md)) 运行查询并获得近似结果。在这种情况下,比例更少的数据从磁盘中检索。 -3. 对有限数量的随机键运行聚合,而不是对所有键进行聚合。在数据中键分布的特定条件下,这提供了一个相当准确的结果,同时使用更少的资源。 +1. 聚合函数用于近似计算不同值的数量、中位数和分位数。 +2. 基于数据的一部分([SAMPLE](../sql-reference/statements/select/sample.md))运行查询并获取近似结果。在这种情况下,从磁盘检索的数据量相对较少。 +3. 对有限数量的随机键进行聚合,而不是对所有键进行聚合。在数据中键分布的特定条件下,这能提供合理准确的结果,同时使用更少的资源。 ## 自适应连接算法 {#adaptive-join-algorithm} -ClickHouse 自适应地选择如何 [JOIN](../sql-reference/statements/select/join.md) 多个表,优先使用哈希连接算法,并在存在多个大型表时回退到合并连接算法。 +ClickHouse自适应选择如何[JOIN](../sql-reference/statements/select/join.md)多个表,优先使用哈希连接,并在存在多个大表时回退到合并连接。 ## 数据复制和数据完整性支持 {#data-replication-and-data-integrity-support} -ClickHouse 使用异步多主复制。在写入任何可用副本后,所有剩余副本在后台检索其副本。系统在不同副本之间维护相同的数据。大多数故障后的恢复是自动执行的,在复杂情况下为半自动执行。 +ClickHouse使用异步多主复制。在写入任何可用副本后,所有剩余的副本在后台检索各自的副本。该系统在不同副本之间保持相同的数据。大多数故障后的恢复是自动进行的,复杂情况下为半自动进行。 -有关更多信息,请参见 [数据复制](../engines/table-engines/mergetree-family/replication.md) 一节。 +有关更多信息,请参阅[数据复制](../engines/table-engines/mergetree-family/replication.md)部分。 ## 基于角色的访问控制 {#role-based-access-control} -ClickHouse 使用 SQL 查询实现用户账户管理,并允许配置与 ANSI SQL 标准和流行关系数据库管理系统中相似的 [基于角色的访问控制](/guides/sre/user-management/index.md)。 +ClickHouse通过SQL查询实现用户账户管理,并允许进行类似于ANSI SQL标准和流行关系数据库管理系统中可以找到的[基于角色的访问控制配置](/guides/sre/user-management/index.md)。 ## 可视为缺点的特性 {#clickhouse-features-that-can-be-considered-disadvantages} -1. 无完全事务。 -2. 缺乏以高速度和低延迟修改或删除已插入数据的能力。可用批量删除和更新来清洁或修改数据,例如,遵守 [GDPR](https://gdpr-info.eu)。 -3. 稀疏索引使 ClickHouse 在按键检索单行的点查询中效率不高。 +1. 不支持完整的事务。 +2. 缺乏以高速和低延迟修改或删除已插入数据的能力。提供批量删除和更新功能以清理或修改数据,例如,遵守[GDPR](https://gdpr-info.eu)。 +3. 稀疏索引使得ClickHouse在通过键检索单行的点查询时效率较低。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/about-us/distinctive-features.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/about-us/distinctive-features.md.hash index f2c0df97879..a85d4f125cb 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/about-us/distinctive-features.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/about-us/distinctive-features.md.hash @@ -1 +1 @@ -6daaf57c9e664ed7 +30311dc49b5fece2 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/about-us/history.md b/i18n/zh/docusaurus-plugin-content-docs/current/about-us/history.md index 6e0e427f890..04486468542 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/about-us/history.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/about-us/history.md @@ -1,60 +1,58 @@ --- 'slug': '/about-us/history' -'sidebar_label': 'ClickHouse 历史' +'sidebar_label': 'ClickHouse历史' 'sidebar_position': 40 -'description': 'ClickHouse 开发的历史' +'description': 'ClickHouse开发的历史' 'keywords': - 'history' - 'development' - 'Metrica' -'title': 'ClickHouse 历史' +'title': 'ClickHouse历史' +'doc_type': 'reference' --- # ClickHouse 历史 {#clickhouse-history} -ClickHouse 最初是为了支持 [Yandex.Metrica](https://metrica.yandex.com/), [全球第二大网络分析平台](http://w3techs.com/technologies/overview/traffic_analysis/all) 而开发的,并且仍然是其核心组件。随着数据库中记录超过 13 万亿条,且每天超过 200 亿个事件,ClickHouse 允许直接从非聚合数据中动态生成自定义报告。本文简要介绍了 ClickHouse 在其早期开发阶段的目标。 +ClickHouse 最初是为 [Yandex.Metrica](https://metrica.yandex.com/) 开发的, [这是全球第二大网络分析平台](http://w3techs.com/technologies/overview/traffic_analysis/all),并且仍然是其核心组件。数据库中有超过 13 万亿条记录,日均超过 200 亿个事件,ClickHouse 允许直接从未聚合数据中动态生成自定义报告。本文简要介绍了 ClickHouse 在早期开发阶段的目标。 -Yandex.Metrica 根据用户定义的任意细分实时生成自定义报告,基于点击和会话。这经常需要构建复杂的聚合,例如独立用户的数量,而生成报告所需的新数据也实时到达。 +Yandex.Metrica 基于点击和会话实时生成自定义报告,用户可以定义任意的细分。在这样做时,通常需要构建复杂的聚合,例如独立用户的数量,并且构建报告所需的新数据实时到达。 -截至 2014 年 4 月,Yandex.Metrica 每天跟踪约 120 亿个事件(页面浏览和点击)。所有这些事件需要存储,以便生成自定义报告。单个查询可能需要在几百毫秒内扫描数百万行,或在短短几秒钟内扫描数亿行。 +截至 2014 年 4 月,Yandex.Metrica 每日跟踪约 120 亿个事件(页面浏览和点击)。所有这些事件都需要存储,以便构建自定义报告。一个查询可能需要在几百毫秒内扫描数百万行,或在几秒钟内扫描数亿行。 ## 在 Yandex.Metrica 和其他 Yandex 服务中的使用 {#usage-in-yandex-metrica-and-other-yandex-services} -ClickHouse 在 Yandex.Metrica 中具有多重用途。 -其主要任务是使用非聚合数据在线生成报告。它使用一个由 374 台服务器组成的集群,存储超过 20.3 万亿行数据。压缩数据的体积约为 2 PB,不包括重复和副本。未压缩数据的体积(以 TSV 格式)大约为 17 PB。 +ClickHouse 在 Yandex.Metrica 中有多种用途。其主要任务是使用未聚合数据在线生成报告。它使用 374 台服务器的集群,数据库中存储超过 20.3 万亿行。压缩数据的体积约为 2 PB,不包括重复数据和副本。未压缩数据的体积(以 TSV 格式)约为 17 PB。 -ClickHouse 还在以下过程中发挥了关键作用: +ClickHouse 在以下过程中也发挥了关键作用: -- 存储来自 Yandex.Metrica 的会话重放数据。 +- 存储来自 Yandex.Metrica 的会话回放数据。 - 处理中间数据。 -- 使用分析构建全球报告。 -- 执行调试 Yandex.Metrica 引擎的查询。 +- 与 Analytics 一起构建全球报告。 +- 运行查询以调试 Yandex.Metrica 引擎。 - 分析来自 API 和用户界面的日志。 -如今,其他 Yandex 服务和部门中有数十个 ClickHouse 实例:搜索垂直领域、电子商务、广告、商业分析、移动开发、个人服务等。 +如今,其他 Yandex 服务和部门中有多达数十个 ClickHouse 安装:搜索垂直, 电子商务, 广告, 商业分析, 移动开发, 个人服务等。 -## 聚合和非聚合数据 {#aggregated-and-non-aggregated-data} +## 聚合和未聚合数据 {#aggregated-and-non-aggregated-data} -有一种广泛的看法,即为了有效计算统计数据,必须进行数据聚合,因为这会减少数据量。 +有一种广泛的观点认为,为有效计算统计数据,必须聚合数据,因为这可以减少数据量。 -然而,数据聚合伴随着许多限制: +然而,数据聚合存在许多限制: - 必须有预定义的所需报告列表。 -- 用户无法生成自定义报告。 -- 当在大量不同键上聚合时,数据量几乎没有减少,因此聚合没有意义。 -- 对于大量报告,存在过多的聚合变体(组合爆炸)。 -- 当聚合高基数的键(例如 URL)时,数据量减少得不多(不足两倍)。 -- 因此,聚合后的数据量可能会增长而不是减小。 -- 用户并不会查看我们为他们生成的所有报告。大部分计算是无用的。 -- 对于各种聚合,数据的逻辑完整性可能会受到损害。 +- 用户不能制作自定义报告。 +- 当在大量独特键上进行聚合时,数据量几乎不会减少,因此聚合是无用的。 +- 对于大量报告,有太多聚合变体(组合爆炸)。 +- 当聚合高基数键(如 URL)时,数据量不会减少太多(不到两倍)。 +- 因此,聚合后的数据量可能会增长而不是缩小。 +- 用户并不查看我们为他们生成的所有报告。大量的计算都是无用的。 +- 由于不同的聚合方式,数据的逻辑完整性可能会受到损害。 -如果我们不聚合任何内容,而是使用非聚合数据,这可能会减少计算量。 +如果我们不进行任何聚合,而只使用未聚合数据,这可能会减少计算量。 -然而,聚合的话,工作的一部分被转移到离线完成,相对平静。相反,在线计算需要尽可能快地计算,因为用户在等待结果。 +然而,聚合让大量工作离线完成,并相对从容。相比之下,在线计算需要尽快计算,因为用户在等待结果。 -Yandex.Metrica 有一个专门的聚合数据系统,叫做 Metrage,使用它生成大多数报告。 -自 2009 年起,Yandex.Metrica 还使用一个专门的 OLAP 数据库,用于非聚合数据,叫做 OLAPServer,该数据库以前用于报告生成器。 -OLAPServer 在处理非聚合数据时表现良好,但有许多限制,无法如所愿用于所有报告。这些限制包括不支持数据类型(仅限数字),以及无法实时增量更新数据(只能通过每日重写数据来完成)。OLAPServer 不是一个数据库管理系统,而是一个专门的数据库。 +Yandex.Metrica 有一个专门的聚合数据系统,称为 Metrage,用于大多数报告。自 2009 年起,Yandex.Metrica 也使用了一个专门的 OLAP 数据库用于未聚合数据,名为 OLAPServer,之前它用于报告生成器。OLAPServer 对未聚合数据处理良好,但有许多限制,无法如预期那样用于所有报告。这些限制包括对数据类型的支持不足(仅支持数字),以及无法实时增量更新数据(只能通过每天重写数据完成)。OLAPServer 不是一个数据库管理系统,而是一个专门的数据库。 -ClickHouse 的初始目标是消除 OLAPServer 的限制,解决所有报告处理非聚合数据的问题,但随着时间的推移,它已经成长为一个通用数据库管理系统,适合广泛的分析任务。 +ClickHouse 的初衷是消除 OLAPServer 的限制,并解决在所有报告中处理未聚合数据的问题,但随着时间的推移,它已经发展成为一个适用于广泛分析任务的通用数据库管理系统。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/about-us/history.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/about-us/history.md.hash index 2b7686634a4..760419f58db 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/about-us/history.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/about-us/history.md.hash @@ -1 +1 @@ -753e5b10b6147038 +83719b6d8df4958b diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/about-us/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/about-us/index.md index f196e6512f8..bfce238286a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/about-us/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/about-us/index.md @@ -1,19 +1,20 @@ --- 'slug': '/about' 'title': '关于 ClickHouse' -'description': '关于 ClickHouse 的登錄頁面' +'description': '关于 ClickHouse 的着陆页' +'doc_type': 'landing-page' --- # 关于 ClickHouse -在本节文档中,您将找到有关 ClickHouse 的信息。请参阅下面的目录以获取本节文档页面的列表。 +在本节文档中,您将找到有关 ClickHouse 的信息。请参阅下面的目录,以获取本节文档中页面的列表。 -| 页面 | 描述 | -|------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| [什么是 ClickHouse](/about-clickhouse) | 介绍 ClickHouse 的核心特性、架构和用途,为新用户提供简明的概述。 | -| [采用者](/about-us/adopters) | 使用 ClickHouse 的公司的列表及其成功故事,来自公开来源的汇总。 | -| [支持](/about-us/support) | ClickHouse Cloud 支持服务及其使命的介绍。 | -| [测试版特性和实验性功能](/beta-and-experimental-features) | 了解 ClickHouse 如何使用“测试版”和“实验性”标签来区分正式支持的功能和由于社区贡献的不同开发速度而处于早期阶段、不受支持的功能。 | -| [云服务](/about-us/cloud) | 发现 ClickHouse Cloud - 一个完全管理的服务,让用户可以快速启动开源 ClickHouse 数据库,并提供快速价值实现、无缝扩展和无服务器操作等好处。 | -| [ClickHouse 历史](/about-us/history) | 了解更多关于 ClickHouse 的历史。 | +| 页面 | 描述 | +|--------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| [什么是 ClickHouse](/about-clickhouse) | 介绍了 ClickHouse 的核心特性、架构和用法,为新用户提供了简明的概述。 | +| [用户](/about-us/adopters) | 使用 ClickHouse 的公司的列表及其成功故事,收集自公共来源 | +| [支持](/about-us/support) | ClickHouse Cloud 支持服务及其使命的介绍。 | +| [Beta 功能和实验性功能](/beta-and-experimental-features) | 了解 ClickHouse 如何使用“Beta”和“实验性”标签来区分官方支持和早期阶段的不支持功能,因为来自社区贡献的开发速度各不相同。 | +| [云服务](/about-us/cloud) | 发现 ClickHouse Cloud - 一个完全托管的服务,允许用户快速启动开源的 ClickHouse 数据库,并提供快速的价值回报、无缝扩展和无服务器操作等好处。 | +| [ClickHouse 历史](/about-us/history) | 了解更多有关 ClickHouse 的历史。 | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/about-us/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/about-us/index.md.hash index 4f5c81c5947..e07509550fd 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/about-us/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/about-us/index.md.hash @@ -1 +1 @@ -b0fc519f7f2a8240 +ee3bb968df51b0b1 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/about-us/intro.mdx b/i18n/zh/docusaurus-plugin-content-docs/current/about-us/intro.mdx index 8bf21f0c844..79634d1508c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/about-us/intro.mdx +++ b/i18n/zh/docusaurus-plugin-content-docs/current/about-us/intro.mdx @@ -3,6 +3,7 @@ 'sidebar_label': '什么是 ClickHouse?' 'title': '什么是 ClickHouse?' 'description': '页面描述 ClickHouse 是什么' +'doc_type': 'guide' --- import Content from '@site/i18n/zh/docusaurus-plugin-content-docs/current/intro.md'; diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/about-us/intro.mdx.hash b/i18n/zh/docusaurus-plugin-content-docs/current/about-us/intro.mdx.hash index b2069d85ea6..cfc0b0fb0ab 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/about-us/intro.mdx.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/about-us/intro.mdx.hash @@ -1 +1 @@ -0674b032dcd00ad5 +21fde9e44b56b0c0 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/about-us/support.md b/i18n/zh/docusaurus-plugin-content-docs/current/about-us/support.md index fa9b272fd54..99fd844354c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/about-us/support.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/about-us/support.md @@ -4,20 +4,21 @@ 'title': 'ClickHouse Cloud 支持服务' 'sidebar_position': 30 'description': '关于 ClickHouse Cloud 支持服务的信息' +'doc_type': 'reference' --- # ClickHouse Cloud 支持服务 -ClickHouse 为我们的 ClickHouse Cloud 用户和客户提供支持服务。我们的目标是建立一个代表 ClickHouse 产品的支持服务团队——无与伦比的性能、易用性,以及极快的高质量结果。有关详细信息,请访问我们的 [ClickHouse 支持计划](https://clickhouse.com/support/program/) 页面。 +ClickHouse 为我们的 ClickHouse Cloud 用户和客户提供支持服务。我们的目标是建立一个支持服务团队,代表 ClickHouse 产品——无与伦比的性能、易用性,以及非常快速、高质量的结果。有关详细信息,请访问我们的 [ClickHouse 支持计划](https://clickhouse.com/support/program/) 页面。 -[登录 Cloud 控制台](https://console.clickhouse.cloud/support) 并从菜单选项中选择 **帮助 -> 支持** 来打开新的支持案例并查看您提交的案例的状态。 +[登录 Cloud 控制台](https://console.clickhouse.cloud/support),并从菜单选项中选择 **帮助 -> 支持** 来打开新的支持案例并查看您提交的案例状态。 -您还可以订阅我们的 [状态页面](https://status.clickhouse.com),以快速获取有关影响我们平台的任何事件的通知。 +您还可以订阅我们的 [状态页面](https://status.clickhouse.com),以便快速接收到影响我们平台的任何事件的通知。 :::note -请注意,只有订阅客户对支持事件有服务级别协议。如果您当前不是 ClickHouse Cloud 用户——虽然我们会尽力回答您的问题,但我们建议您访问我们的社区资源之一: +请注意,只有订阅客户对支持事件拥有服务水平协议。如果您当前不是 ClickHouse Cloud 用户——虽然我们会尽力回答您的问题,但我们建议您转向我们的社区资源之一: -- [ClickHouse 社区 Slack 渠道](https://clickhouse.com/slack) +- [ClickHouse 社区 Slack 频道](https://clickhouse.com/slack) - [其他社区选项](https://github.com/ClickHouse/ClickHouse/blob/master/README.md#useful-links) ::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/about-us/support.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/about-us/support.md.hash index b21c52b2971..1177a4a7f6a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/about-us/support.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/about-us/support.md.hash @@ -1 +1 @@ -6647ef4883598877 +1d9070fc2e1a55c6 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/architecture/cluster-deployment.md b/i18n/zh/docusaurus-plugin-content-docs/current/architecture/cluster-deployment.md deleted file mode 100644 index fe068159ce6..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/architecture/cluster-deployment.md +++ /dev/null @@ -1,153 +0,0 @@ ---- -'slug': '/architecture/cluster-deployment' -'sidebar_label': '集群部署' -'sidebar_position': 100 -'title': '集群部署' -'description': '通过这个教程,您将学习如何设置一个简单的 ClickHouse 集群。' ---- - -这篇教程假设您已经设置了一个 [本地 ClickHouse 服务器](../getting-started/install/install.mdx) - -通过此教程,您将学习如何设置一个简单的 ClickHouse 集群。虽然它会很小,但具备容错和可扩展性。接下来,我们将使用其中一个示例数据集填充它,并执行一些演示查询。 - -## 集群部署 {#cluster-deployment} - -此 ClickHouse 集群将是一个同构集群。以下是步骤: - -1. 在集群的所有机器上安装 ClickHouse 服务器 -2. 在配置文件中设置集群配置 -3. 在每个实例上创建本地表 -4. 创建一个 [分布式表](../engines/table-engines/special/distributed.md) - -一个 [分布式表](../engines/table-engines/special/distributed.md) 是对 ClickHouse 集群中本地表的"视图"。从分布式表发出的 SELECT 查询使用集群所有分片的资源。您可以为多个集群指定配置,并创建多个分布式表,以提供不同集群的视图。 - -以下是一个包含三个分片的集群示例配置,每个分片有一个副本: - -```xml - - - - - example-perftest01j.clickhouse.com - 9000 - - - - - example-perftest02j.clickhouse.com - 9000 - - - - - example-perftest03j.clickhouse.com - 9000 - - - - -``` - -为了进一步演示,让我们创建一个新的本地表,使用与单节点部署教程中 `hits_v1` 相同的 `CREATE TABLE` 查询,但使用不同的表名: - -```sql -CREATE TABLE tutorial.hits_local (...) ENGINE = MergeTree() ... -``` - -创建一个分布式表提供对集群本地表的视图: - -```sql -CREATE TABLE tutorial.hits_all AS tutorial.hits_local -ENGINE = Distributed(perftest_3shards_1replicas, tutorial, hits_local, rand()); -``` - -一种常见的做法是在集群的所有机器上创建类似的分布式表。这使得可以在集群的任何机器上运行分布式查询。还有另一种选择是为特定的 SELECT 查询创建临时分布式表,使用 [remote](../sql-reference/table-functions/remote.md) 表函数。 - -让我们对分布式表执行 [INSERT SELECT](../sql-reference/statements/insert-into.md),将表数据分散到多个服务器。 - -```sql -INSERT INTO tutorial.hits_all SELECT * FROM tutorial.hits_v1; -``` - -正如您所期待的那样,计算密集型查询在使用 3 台服务器时比使用 1 台服务器快 N 倍。 - -在这种情况下,我们使用一个包含 3 个分片的集群,每个分片包含一个副本。 - -为了在生产环境中提供弹性,我们建议每个分片包含 2-3 个副本,分布在多个可用区或数据中心(或至少机架)之间。请注意,ClickHouse 支持无限数量的副本。 - -以下是一个包含三个副本的单个分片集群的示例配置: - -```xml - - ... - - - - example-perftest01j.clickhouse.com - 9000 - - - example-perftest02j.clickhouse.com - 9000 - - - example-perftest03j.clickhouse.com - 9000 - - - - -``` - -要启用原生复制,需使用 [ZooKeeper](http://zookeeper.apache.org/)。ClickHouse 负责所有副本上的数据一致性,并在故障后自动运行恢复程序。建议将 ZooKeeper 集群部署在独立的服务器上(避免运行其他进程,包括 ClickHouse)。 - -:::note 注意 -ZooKeeper 不是严格要求:在某些简单情况下,您可以通过从应用程序代码中将数据写入所有副本来重复数据。这种方法 **不** 推荐,因为在这种情况下,ClickHouse 将无法保证所有副本上的数据一致性。因此,这将成为您应用程序的责任。 -::: - -ZooKeeper 位置在配置文件中指定: - -```xml - - - zoo01.clickhouse.com - 2181 - - - zoo02.clickhouse.com - 2181 - - - zoo03.clickhouse.com - 2181 - - -``` - -此外,我们需要设置宏以识别每个分片和副本,这些宏在创建表时使用: - -```xml - - 01 - 01 - -``` - -如果在复制表创建时没有副本,则会实例化一个新的第一个副本。如果已经存在活动副本,则新副本将从现有副本克隆数据。您可以选择先创建所有复制表,然后插入数据。另一种选择是在一些副本创建后或在数据插入过程中添加其他副本。 - -```sql -CREATE TABLE tutorial.hits_replica (...) -ENGINE = ReplicatedMergeTree( - '/clickhouse_perftest/tables/{shard}/hits', - '{replica}' -) -... -``` - -在这里我们使用 [ReplicatedMergeTree](../engines/table-engines/mergetree-family/replication.md) 表引擎。在参数中,我们指定包含分片和副本标识符的 ZooKeeper 路径。 - -```sql -INSERT INTO tutorial.hits_replica SELECT * FROM tutorial.hits_local; -``` - -复制在多主模式下操作。数据可以加载到任何副本中,系统会自动与其他实例同步。复制是异步的,因此在某一时刻,并非所有副本都可能包含最近插入的数据。至少应该有一个副本处于活动状态,以允许数据摄取。其他副本将在重新激活后同步数据并修复一致性。请注意,这种方法允许最近插入的数据丢失的可能性较低。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/architecture/cluster-deployment.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/architecture/cluster-deployment.md.hash deleted file mode 100644 index 521afde22d1..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/architecture/cluster-deployment.md.hash +++ /dev/null @@ -1 +0,0 @@ -e77d221d30def930 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/_snippets/_async_inserts.md b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/_snippets/_async_inserts.md index 5319b779812..13c85cd4005 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/_snippets/_async_inserts.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/_snippets/_async_inserts.md @@ -1,68 +1,63 @@ ---- -null -... ---- - import Image from '@theme/IdealImage'; import async_inserts from '@site/static/images/bestpractices/async_inserts.png'; -在 ClickHouse 中,异步插入提供了一种强大的替代方案,当客户端批处理不可行时。尤其是在可观察性工作负载中,数百或数千个代理持续发送数据 — 日志、指标、跟踪 — 通常以小的实时有效载荷进行发送。在这些环境中,客户端缓冲数据增加了复杂性,需要一个集中队列以确保可以发送足够大的批次。 +异步插入在 ClickHouse 中提供了一种强大的替代方案,当客户端批处理不可行时显得尤为重要。这在可观察性工作负载中尤其有价值,其中数百或数千个代理持续发送数据 - 日志、指标、跟踪 - 通常以小的实时有效负载进行。为了在这些环境中客户端缓冲数据,复杂性增加,需要一个集中队列来确保可以发送足够大的批量。 :::note -不推荐以同步模式发送许多小批次,这将导致创建多个部分。这将导致查询性能不佳以及出现 ["too many part"](/knowledgebase/exception-too-many-parts) 错误。 +不推荐以同步模式发送许多小批次,这样会导致创建许多 parts。这将导致查询性能差和 ["too many part"](/knowledgebase/exception-too-many-parts) 错误。 ::: -异步插入通过将传入的数据写入内存中的缓冲区,然后根据可配置的阈值将其刷新到存储,从而将批处理责任从客户端转移到服务器。这种方法显著减少了部分创建的开销,降低了 CPU 的使用,并确保在高并发下的摄取效率。 +异步插入通过将传入数据写入内存缓冲区,然后根据可配置的阈值刷新到存储中,将批处理责任从客户端转移到服务器。这种方法显著降低了部分创建的开销,降低了 CPU 使用率,并确保即使在高并发下,数据摄取也保持高效。 核心行为通过 [`async_insert`](/operations/settings/settings#async_insert) 设置进行控制。 异步插入 -当启用时 (1),插入将被缓冲,并且仅在满足以下任何一个刷新条件后写入磁盘: +启用时 (1),插入被缓冲,只有在满足其中一个刷新条件时才写入磁盘: -(1) 缓冲区达到指定的大小 (async_insert_max_data_size) -(2) 时间阈值经过 (async_insert_busy_timeout_ms) 或 -(3) 累积到达最大插入查询数量 (async_insert_max_query_number)。 +(1) 缓冲区达到指定大小 (async_insert_max_data_size) +(2) 已经过了时间阈值 (async_insert_busy_timeout_ms) 或 +(3) 累积的插入查询达到最大数量 (async_insert_max_query_number)。 -该批处理过程对客户端是不可见的,并帮助 ClickHouse 高效地合并来自多个源的插入流量。然而,在刷新发生之前,数据无法被查询。重要的是,每种插入形状和设置组合有多个缓冲区,并且在集群中,缓冲区是每个节点维护的 - 这允许在多租户环境中进行精细控制。插入机制在其他方面与 [同步插入](/best-practices/selecting-an-insert-strategy#synchronous-inserts-by-default) 描述的相同。 +这个批处理过程对客户端是不可见的,并帮助 ClickHouse 有效地合并来自多个源的插入流量。然而,在发生刷新之前,数据无法被查询。重要的是,对于每个插入形状和设置组合有多个缓冲区,并且在集群中,缓冲区按节点维护 - 这使得在多租户环境中可以进行细粒度控制。插入机制与 [同步插入](/best-practices/selecting-an-insert-strategy#synchronous-inserts-by-default) 描述的相同。 ### 选择返回模式 {#choosing-a-return-mode} 异步插入的行为通过 [`wait_for_async_insert`](/operations/settings/settings#wait_for_async_insert) 设置进一步细化。 -当设置为 1 (默认值) 时,ClickHouse 仅在数据成功刷新到磁盘后才确认插入。这确保了强大的持久性保证,使错误处理变得简单:如果在刷新时出现问题,错误将返回给客户端。此模式推荐用于大多数生产场景,特别是当插入失败需要可靠跟踪时。 +当设置为 1(默认值)时,ClickHouse 只有在数据成功刷新到磁盘后才确认插入。这确保了强大的耐久性保证,并使错误处理变得简单:如果在刷新过程中出现问题,错误将返回给客户端。这个模式推荐用于大多数生产场景,特别是在必须可靠地跟踪插入失败时。 -[基准测试](https://clickhouse.com/blog/asynchronous-data-inserts-in-clickhouse) 显示它在并发上表现良好 - 无论您是在运行 200 还是 500 个客户端 - 这得益于自适应插入和稳定的部分创建行为。 +[基准测试](https://clickhouse.com/blog/asynchronous-data-inserts-in-clickhouse) 显示它在并发时扩展良好 - 无论你是运行 200 还是 500 个客户端 - 这要归功于自适应插入和稳定的部分创建行为。 -设置 `wait_for_async_insert = 0` 启用“无视而过”模式。在这里,服务器在数据被缓冲后立即确认插入,而无需等待数据达到存储。 +将 `wait_for_async_insert = 0` 设置为“ fire-and-forget”模式。在这里,服务器在数据缓冲后立即确认插入,而不等待其到达存储。 -这提供了超低延迟的插入和最大的吞吐量,理想用于高速度、低关键性的数据。然而,这也带来了权衡:无法保证数据被持久化,错误可能仅在刷新时显现,并且很难追踪失败的插入。只有在工作负载可以容忍数据丢失的情况下才使用此模式。 +这提供了超低延迟插入和最大吞吐量,非常适合高速、低重要性数据。然而,这带来了权衡:没有保证数据会被持久化,错误可能仅在刷新期间浮现,并且难以追踪失败的插入。仅在你的工作负载能够容忍数据丢失时使用此模式。 -[基准测试还表明](https://clickhouse.com/blog/asynchronous-data-inserts-in-clickhouse) 当缓冲刷新不频繁时(例如每 30 秒),部分数量显著减少,并且 CPU 使用率降低,但沉默失败的风险仍然存在。 +[基准测试还显示](https://clickhouse.com/blog/asynchronous-data-inserts-in-clickhouse) 当缓冲刷新不频繁(例如每 30 秒一次)时,部分减少和 CPU 使用率降低,但静默失败的风险仍然存在。 -我们强烈建议使用 `async_insert=1,wait_for_async_insert=1`,如果使用异步插入。使用 `wait_for_async_insert=0` 非常冒险,因为您的 INSERT 客户端可能无法意识到是否存在错误,并且可能会导致潜在的过载,如果您的客户端在 ClickHouse 服务器需要减缓写入速度并产生一些回压以确保服务可靠性时继续快速写入。 +我们强烈建议使用 `async_insert=1,wait_for_async_insert=1`,如果使用异步插入。使用 `wait_for_async_insert=0` 风险很大,因为你的 INSERT 客户端可能无法意识到是否存在错误,并且在 ClickHouse 服务器需要减慢写入并产生一定的反压以确保服务的可靠性时,可能会导致潜在的过载。 ### 去重和可靠性 {#deduplication-and-reliability} -默认情况下,ClickHouse 为同步插入执行自动去重,这使得在失败场景中重试是安全的。然而,这在异步插入中是禁用的,除非明确启用(如果您有依赖的物化视图,则不应启用 - [参见问题](https://github.com/ClickHouse/ClickHouse/issues/66003))。 +默认情况下,ClickHouse 对于同步插入执行自动去重,这使得在出现故障场景时重试很安全。然而,对于异步插入,此功能默认是禁用的,除非显式启用(如果你有依赖的物化视图,则不应启用 - [参见问题](https://github.com/ClickHouse/ClickHouse/issues/66003))。 -实际上,如果去重启用并且由于超时或网络中断而重新尝试相同插入,ClickHouse 可以安全地忽略重复。这有助于保持幂等性并避免重复写入数据。仍然值得注意的是,插入验证和模式解析仅在缓冲刷新期间发生 - 因此错误(如类型不匹配)仅在那时浮现。 +实际上,如果去重被开启,并且由于超时或网络中断重试了相同的插入,ClickHouse 可以安全地忽略重复插入。这有助于保持幂等性并避免数据的重复写入。然而,值得注意的是,插入验证和模式解析只在缓冲刷新期间进行 - 所以错误(如类型不匹配)只会在那时显现出来。 ### 启用异步插入 {#enabling-asynchronous-inserts} -可以为特定用户或特定查询启用异步插入: +异步插入可以为特定用户或特定查询启用: -- 在用户级别启用异步插入。此示例使用用户 `default`,如果您创建了不同的用户,请替换该用户名: +- 在用户级别启用异步插入。这个例子使用用户 `default`,如果你创建了不同的用户则替换该用户名: ```sql ALTER USER default SETTINGS async_insert = 1 ``` -- 您可以通过在插入查询中使用 SETTINGS 子句来指定异步插入设置: +- 你可以通过使用插入查询的 SETTINGS 子句来指定异步插入设置: ```sql INSERT INTO YourTable SETTINGS async_insert=1, wait_for_async_insert=1 VALUES (...) ``` -- 在使用 ClickHouse 编程语言客户端时,您还可以将异步插入设置指定为连接参数。 +- 你还可以在使用 ClickHouse 编程语言客户端时将异步插入设置作为连接参数指定。 -作为一个示例,这就是在使用 ClickHouse Java JDBC 驱动程序连接到 ClickHouse Cloud 时,您可以在 JDBC 连接字符串中这样做: + 作为示例,在使用 ClickHouse Java JDBC 驱动程序连接到 ClickHouse Cloud 时,这就是你可以在 JDBC 连接字符串中做到的: ```bash "jdbc:ch://HOST.clickhouse.cloud:8443/?user=default&password=PASSWORD&ssl=true&custom_http_params=async_insert=1,wait_for_async_insert=1" ``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/_snippets/_async_inserts.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/_snippets/_async_inserts.md.hash index 09328f918dd..2533a38d532 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/_snippets/_async_inserts.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/_snippets/_async_inserts.md.hash @@ -1 +1 @@ -6573683eec17fe67 +23db4fb5f65761c3 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/_snippets/_avoid_mutations.md b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/_snippets/_avoid_mutations.md index 400d3277991..32141522f59 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/_snippets/_avoid_mutations.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/_snippets/_avoid_mutations.md @@ -1,18 +1,13 @@ ---- -null -... ---- +在 ClickHouse 中,**变更**指的是修改或删除表中现有数据的操作,通常使用 `ALTER TABLE ... DELETE` 或 `ALTER TABLE ... UPDATE`。虽然这些语句看起来与标准 SQL 操作相似,但从底层来看它们是根本不同的。 -在 ClickHouse 中,**变更** 指的是修改或删除表中现有数据的操作 - 通常使用 `ALTER TABLE ... DELETE` 或 `ALTER TABLE ... UPDATE`。虽然这些语句看起来与标准 SQL 操作相似,但它们在底层是根本不同的。 +与其就地修改行,ClickHouse 中的变更是异步后台进程,会重写受更改影响的整个 [数据部分](/parts)。这种方法是由于 ClickHouse 的列式、不可变存储模型所必需的,但会导致显著的 I/O 和资源使用。 -在 ClickHouse 中,变更不是直接修改行,而是异步后台进程,会重写因更改而受影响的整个 [数据部分](/parts)。这种方法是必要的,因为 ClickHouse 的列式、不可变存储模型,但它可能导致显著的 I/O 和资源使用。 +当发出变更时,ClickHouse 会调度创建新的 **变更部分**,在新部分准备好之前,原始部分保持不变。一旦准备就绪,变更部分将原子性地替换原始部分。然而,由于操作重写了整个部分,即使是微小的更改(例如更新单个行)也可能导致大规模的重写和过多的写入放大。 -当发出变更请求时,ClickHouse 会安排创建新的 **变更部分**,原始部分保持不变,直到新的部分准备好。一旦准备就绪,变更部分将原子性地替换原始部分。然而,由于操作重写整个部分,即使是微小的更改(例如更新单行)也可能导致大规模的重写和过度的写放大。 +对于大型数据集,这会导致磁盘 I/O 的显著上升,并降低整体集群性能。与合并不同,一旦提交,变更无法回滚,即使在服务器重启后也会继续执行,除非显式取消 - 请参见 [`KILL MUTATION`](/sql-reference/statements/kill#kill-mutation)。 -对于大型数据集,这可能会导致磁盘 I/O 的显著激增并降低整体集群性能。与合并不同,变更一旦提交就无法回滚,并且即使在服务器重启后仍会继续执行,除非显式取消 - 请参阅 [`KILL MUTATION`](/sql-reference/statements/kill#kill-mutation)。 +变更是 **完全有序** 的:它们适用于在发出变更之前插入的数据,而较新的数据则不受影响。变更不会阻止插入,但仍可能与其他正在进行的查询重叠。在变更进行期间运行的 SELECT 查询可能会读取变更部分和未变更部分的混合,这可能导致在执行过程中数据视图的不一致。ClickHouse 会按部分并行执行变更,这可能进一步加大内存和 CPU 的使用,特别是在涉及复杂子查询(如 x IN (SELECT ...))时。 -变更是 **完全有序** 的:它们适用于在发出变更之前插入的数据,而新数据则不受影响。变更不会阻止插入,但仍可能与其他正在进行的查询重叠。在变更进行时运行的 SELECT 可能会读取变更和未变更部分的混合,这可能导致执行期间数据视图不一致。ClickHouse 在每个部分并行执行变更,这可能进一步加剧内存和 CPU 使用,特别是在涉及复杂子查询(例如 x IN (SELECT ...))时。 +作为一条规则,**避免频繁或大规模的变更**,尤其是在高容量表上。相反,可以使用其他表引擎,例如 [ReplacingMergeTree](/guides/replacing-merge-tree) 或 [CollapsingMergeTree](/engines/table-engines/mergetree-family/collapsingmergetree),这些引擎旨在在查询时或合并时更有效地处理数据修正。如果变更绝对必要,请使用 system.mutations 表仔细监控它们,并在进程卡住或表现异常时使用 `KILL MUTATION`。误用变更可能导致性能降低、存储频繁波动以及潜在的服务不稳定——因此要谨慎使用并适度应用。 -通常,**避免频繁或大规模的变更**,特别是在高吞吐量的表上。相反,使用其他表引擎,例如 [ReplacingMergeTree](/guides/replacing-merge-tree) 或 [CollapsingMergeTree](/engines/table-engines/mergetree-family/collapsingmergetree),这些引擎被设计用来在查询时或在合并过程中更有效地处理数据更正。如果变更绝对必要,请使用 system.mutations 表仔细监控它们,并在进程卡住或表现不正常时使用 `KILL MUTATION`。滥用变更可能导致性能下降、存储剧烈变动以及潜在的服务不稳定 - 因此请谨慎并适度地应用它们。 - -对于删除数据,用户还可以考虑 [轻量级删除](/guides/developer/lightweight-delete) 或通过 [分区](/best-practices/choosing-a-partitioning-key) 管理数据,这允许有效地 [删除整个部分](/sql-reference/statements/alter/partition#drop-partitionpart)。 +对于删除数据,用户也可以考虑 [轻量级删除](/guides/developer/lightweight-delete) 或通过 [分区](/best-practices/choosing-a-partitioning-key) 管理数据,这允许以 [高效方式删除整个部分](/sql-reference/statements/alter/partition#drop-partitionpart)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/_snippets/_avoid_nullable_columns.md b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/_snippets/_avoid_nullable_columns.md index 80c1a72ddb9..1a174b4b581 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/_snippets/_avoid_nullable_columns.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/_snippets/_avoid_nullable_columns.md @@ -1,11 +1,6 @@ ---- -null -... ---- +[`Nullable` 列](/sql-reference/data-types/nullable/) (例如 `Nullable(String)`) 会创建一个额外的 `UInt8` 类型的列。每当用户处理 `Nullable` 列时,必须处理此附加列。这会导致额外的存储空间占用,并几乎总是对性能产生负面影响。 -[`Nullable` 列](/sql-reference/data-types/nullable/)(例如 `Nullable(String)`)会创建一个额外的 `UInt8` 类型的列。每次用户处理 Nullable 列时,都必须处理这个附加列。这会导致额外的存储空间使用,并几乎总是对性能产生负面影响。 - -为了避免使用 `Nullable` 列,请考虑为该列设置一个默认值。例如,可以使用以下代码替代: +为了避免使用 `Nullable` 列,请考虑为该列设置默认值。例如,代替: ```sql CREATE TABLE default.sample @@ -17,7 +12,7 @@ CREATE TABLE default.sample ENGINE = MergeTree ORDER BY x ``` -use +使用 ```sql CREATE TABLE default.sample2 @@ -30,4 +25,4 @@ ENGINE = MergeTree ORDER BY x ``` -请考虑您的用例,默认值可能并不合适。 +考虑您的用例,默认值可能不合适。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/_snippets/_avoid_optimize_final.md b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/_snippets/_avoid_optimize_final.md index bf57455e0fb..61b3e6b19b8 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/_snippets/_avoid_optimize_final.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/_snippets/_avoid_optimize_final.md @@ -1,48 +1,47 @@ ---- -null -... ---- - import Image from '@theme/IdealImage'; import simple_merges from '@site/static/images/bestpractices/simple_merges.png'; -ClickHouse 表使用 **MergeTree 引擎** 将数据存储为 **不可变的分片**,每次插入数据时都会创建新的分片。 +ClickHouse 表使用 **MergeTree 引擎** 将数据以 **不可变部分** 的形式存储在磁盘上,每次插入数据时都会创建。 -每次插入都会创建一个新的分片,其中包含排序过的、压缩的列文件,以及索引和校验和等元数据。有关分片结构及其形成方式的详细描述,我们推荐查看此 [指南](/parts)。 +每次插入都会生成一个新部分,包含排序、压缩的列文件,以及索引和校验和等元数据。有关部分结构及其形成方式的详细描述,我们推荐此 [指南](/parts)。 -随着时间的推移,后台进程将较小的分片合并为较大的分片,以减少碎片化并提高查询性能。 +随着时间的推移,后台进程将较小的部分合并成更大的部分,以减少碎片化并提高查询性能。 简单合并 -虽然手动触发此合并是很诱人的,如下所示: +尽管手动触发此合并是诱人的,但: ```sql OPTIMIZE TABLE FINAL; ``` -**但在大多数情况下,您应避免此操作**,因为它会触发资源密集型操作,可能会影响集群性能。 +**在大多数情况下,您应该避免使用 `OPTIMIZE FINAL` 操作**,因为它会启动资源密集型操作,这可能会影响集群性能。 + +:::note OPTIMIZE FINAL 与 FINAL +`OPTIMIZE FINAL` 并不等同于 `FINAL`,后者在某些情况下是必要的,以避免结果重复,例如与 `ReplacingMergeTree` 一起使用。一般来说,如果您的查询过滤的列与主键中的列相同,使用 `FINAL` 是可以的。 +::: -## 为什么要避免? {#why-avoid} +## 为什么要避免? {#why-avoid} -### 这是昂贵的 {#its-expensive} +### 代价高昂 {#its-expensive} -执行 `OPTIMIZE FINAL` 将迫使 ClickHouse 将 **所有** 活跃分片合并为 **单个分片**,即使已经发生了大合并。这涉及到: +运行 `OPTIMIZE FINAL` 强制 ClickHouse 将 **所有** 活跃部分合并为 **单个部分**,即使已经发生了大型合并。这涉及: -1. **解压缩** 所有分片 +1. **解压** 所有部分 2. **合并** 数据 -3. **再次压缩** -4. **将** 最终分片写入磁盘或对象存储 +3. **再压缩** +4. **将** 最终部分写入磁盘或对象存储 -这些步骤都是 **CPU 和 I/O 密集型** 的,尤其是当涉及到大型数据集时,可能会给您的系统带来显著的压力。 +这些步骤是 **CPU 和 I/O 密集型的**,可能会对您的系统造成重大压力,尤其是在涉及大型数据集时。 -### 它忽略了安全限制 {#it-ignores-safety-limits} +### 忽略安全限制 {#it-ignores-safety-limits} -通常,ClickHouse 会避免合并大于 ~150 GB 的分片(可以通过 [max_bytes_to_merge_at_max_space_in_pool](/operations/settings/merge-tree-settings#max_bytes_to_merge_at_max_space_in_pool) 配置)。但是 `OPTIMIZE FINAL` **忽略了这个保护**,这意味着: +通常,ClickHouse 避免合并超过 ~150 GB 的部分(可以通过 [max_bytes_to_merge_at_max_space_in_pool](/operations/settings/merge-tree-settings#max_bytes_to_merge_at_max_space_in_pool) 配置)。但 `OPTIMIZE FINAL` **会忽略此保护措施**,这意味着: -* 它可能尝试将 **多个 150 GB 分片** 合并为一个巨大的分片 -* 这可能导致 **长时间的合并**,**内存压力**,甚至 **内存溢出错误** -* 这些大型分片可能会变得难以合并,即进一步尝试合并失败,原因如上所述。在需要为正确的查询时间行为进行合并的情况下,这可能会导致意想不到的后果,例如 [使用 ReplacingMergeTree 进行去重](/guides/developer/deduplication#using-replacingmergetree-for-upserts) 时重复数据的积累,从而增加查询时间性能。 +* 它可能尝试将 **多个 150 GB 部分** 合并成一个巨大的部分 +* 这可能导致 **长时间合并**、**内存压力**,甚至 **内存溢出错误** +* 这些大型部分可能变得难以合并,即尝试进一步合并时因上述原因失败。在需要合并以确保查询时间正常行为的情况下,这可能导致不良后果,例如 [替换合并树中的重复项累积](/guides/developer/deduplication#using-replacingmergetree-for-upserts),增加查询时间性能。 ## 让后台合并来完成工作 {#let-background-merges-do-the-work} -ClickHouse 已经执行智能的后台合并,以优化存储和查询效率。这些合并是增量的,考虑到资源,并尊重配置的阈值。除非您有非常特定的需求(例如,在冻结表或导出之前整理数据),**否则您最好让 ClickHouse 自行管理合并**。 +ClickHouse 已经执行智能的后台合并,以优化存储和查询效率。这些合并是增量的、资源感知的,并且遵循配置的阈值。除非您有非常具体的需求(例如,在冻结表或导出之前完成数据),**否则最好让 ClickHouse 自行管理合并**。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/_snippets/_avoid_optimize_final.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/_snippets/_avoid_optimize_final.md.hash index 28c1a7ccb2b..b16048619c3 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/_snippets/_avoid_optimize_final.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/_snippets/_avoid_optimize_final.md.hash @@ -1 +1 @@ -e39ef18c811b7519 +bf49222073113fa4 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/_snippets/_bulk_inserts.md b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/_snippets/_bulk_inserts.md index 8f53128a821..8631f3cc893 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/_snippets/_bulk_inserts.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/_snippets/_bulk_inserts.md @@ -1,16 +1,11 @@ ---- -null -... ---- +上述机制展示了无论插入大小如何,始终存在的恒定开销,这使得批量大小成为提高摄取吞吐量的最重要优化因素。批量插入减少了总插入时间的开销比例,并提高了处理效率。 -上述机制说明无论插入大小如何,总是存在恒定的开销,使得批量大小成为提升摄取吞吐量的最重要优化因素。批量插入减少了作为总插入时间比例的开销,提高了处理效率。 +我们建议以至少 1,000 行为一个批次插入数据,理想情况下在 10,000 到 100,000 行之间。更少的、更大的插入减少了写入的分区片段数量,最小化了合并负载,降低了整体系统资源使用。 -我们建议以至少1,000行的批量插入数据,理想情况下为10,000到100,000行之间。较少的、大规模的插入减少了写入的分区片段数量,最小化了合并负载,并降低了整体系统资源使用。 +**要使同步插入策略有效,客户端必须进行批量处理。** -**要使同步插入策略有效,需要在客户端进行批量处理。** - -如果您无法在客户端进行数据批量处理,ClickHouse支持异步插入,将批量处理转移到服务器([请参见](/best-practices/selecting-an-insert-strategy#asynchronous-inserts))。 +如果您无法在客户端进行数据批量处理,ClickHouse 支持将批量处理转移到服务器的异步插入([见](/best-practices/selecting-an-insert-strategy#asynchronous-inserts))。 :::tip -无论插入的大小如何,我们建议将插入查询的数量保持在每秒大约一个插入查询。推荐的原因是创建的分区片段在后台合并为更大的分区片段(以优化您的数据以便于读取查询),每秒发送过多的插入查询可能会导致后台合并无法跟上新分区片段的数量。然而,当您使用异步插入时(见异步插入),可以使用更高的每秒插入查询速率。 +无论插入的大小如何,我们建议将插入查询的数量保持在每秒一个插入查询左右。这一建议的原因在于,创建的分区片段在后台合并为更大的分区片段(以优化您的数据以供读取查询),而每秒发送过多的插入查询可能导致后台合并无法跟上新分区片段的数量。但是,当您使用异步插入时,可以使用更高的每秒插入查询速率(见异步插入)。 ::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/_snippets/_table_of_contents.md b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/_snippets/_table_of_contents.md new file mode 100644 index 00000000000..f7fa0037226 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/_snippets/_table_of_contents.md @@ -0,0 +1,12 @@ +| 页面 | 描述 | +|--------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------| +| [选择主键](/best-practices/choosing-a-primary-key) | 如何选择主键以最大化查询性能并最小化存储开销。 | +| [选择数据类型](/best-practices/select-data-types) | 选择最佳数据类型以减少内存使用、改善压缩效果并加快查询速度。 | +| [使用物化视图](/best-practices/use-materialized-views) | 利用物化视图预聚合数据,并显著加快分析查询的速度。 | +| [最小化和优化JOIN](/best-practices/minimize-optimize-joins) | 高效使用ClickHouse的`JOIN`功能的最佳实践。 | +| [选择分区键](/best-practices/choosing-a-partitioning-key) | 选择有效的数据修剪和更快查询执行的分区策略。 | +| [选择插入策略](/best-practices/selecting-an-insert-strategy) | 通过适当的插入模式优化数据摄取吞吐量并减少资源消耗。 | +| [数据跳过索引](/best-practices/use-data-skipping-indices-where-appropriate) | 战略性地应用次级索引以跳过不相关的数据块并加速过滤查询。 | +| [避免变更](/best-practices/avoid-mutations) | 设计架构和工作流程以消除代价高昂的`UPDATE`/`DELETE`操作,从而提升性能。 | +| [避免OPTIMIZE FINAL](/best-practices/avoid-optimize-final) | 理解何时`OPTIMIZE FINAL`会造成比帮助更多的性能瓶颈,从而避免性能问题。 | +| [适当地使用JSON](/best-practices/use-json-where-appropriate) | 在处理ClickHouse中的半结构化JSON数据时,平衡灵活性和性能。 | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/_snippets/_table_of_contents.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/_snippets/_table_of_contents.md.hash new file mode 100644 index 00000000000..aea720ae24d --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/_snippets/_table_of_contents.md.hash @@ -0,0 +1 @@ +80cab0f1d1e0f25a diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/avoid_mutations.md b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/avoid_mutations.md index c9dfcb6f987..d5d7d05ac97 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/avoid_mutations.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/avoid_mutations.md @@ -1,11 +1,12 @@ --- 'slug': '/best-practices/avoid-mutations' 'sidebar_position': 10 -'sidebar_label': '避免修改' -'title': '避免修改' -'description': '页面描述了为什么要在 ClickHouse 中避免修改' +'sidebar_label': '避免变更' +'title': '避免变更' +'description': '页面描述了为什么在 ClickHouse 中要避免变更' 'keywords': - 'mutations' +'doc_type': 'guide' --- import Content from '@site/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/_snippets/_avoid_mutations.md'; diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/avoid_mutations.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/avoid_mutations.md.hash index dcd1734a754..a52f4bdabc5 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/avoid_mutations.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/avoid_mutations.md.hash @@ -1 +1 @@ -9fb155d98bb2f3b0 +7aaf355003bb3b53 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/avoid_optimize_final.md b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/avoid_optimize_final.md index d376157e1a0..b9994423243 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/avoid_optimize_final.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/avoid_optimize_final.md @@ -7,8 +7,13 @@ 'keywords': - 'avoid OPTIMIZE FINAL' - 'background merges' +'hide_title': true +'doc_type': 'guide' --- import Content from '@site/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/_snippets/_avoid_optimize_final.md'; + +# 避免使用 `OPTIMIZE FINAL` + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/avoid_optimize_final.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/avoid_optimize_final.md.hash index aabcaefe259..09563a1e405 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/avoid_optimize_final.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/avoid_optimize_final.md.hash @@ -1 +1 @@ -de4e4d8e3604dd2d +34fdfd71b6277fe1 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/choosing_a_primary_key.md b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/choosing_a_primary_key.md index 393ef145faa..3a9d6dbd876 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/choosing_a_primary_key.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/choosing_a_primary_key.md @@ -7,32 +7,33 @@ 'keywords': - 'primary key' 'show_related_blogs': true +'doc_type': 'guide' --- import Image from '@theme/IdealImage'; import create_primary_key from '@site/static/images/bestpractices/create_primary_key.gif'; import primary_key from '@site/static/images/bestpractices/primary_key.gif'; -> 我们在本页中互换使用“排序键(ordering key)”一词来指代“主键(primary key)”。严格来说,[在 ClickHouse 中它们有所不同](/engines/table-engines/mergetree-family/mergetree#choosing-a-primary-key-that-differs-from-the-sorting-key),但为了本文档的目的,读者可以互换使用这两个术语,其中排序键指的是在表中指定的 `ORDER BY` 列。 +> 我们在此页面上交替使用“ordering key”这个术语来指代“primary key”。严格来说, [这在 ClickHouse 中是不同的](/engines/table-engines/mergetree-family/mergetree#choosing-a-primary-key-that-differs-from-the-sorting-key),但出于本文档的目的,读者可以将它们互换使用,其中 ordering key 指的是在表格 `ORDER BY` 中指定的列。 -注意,ClickHouse 的主键与熟悉 OLTP 数据库(如 Postgres)中类似术语的用户 [非常不同](/migrations/postgresql/data-modeling-techniques#primary-ordering-keys-in-clickhouse)。 +注意,ClickHouse 的主键与那些熟悉类似术语的 OLTP 数据库(例如 Postgres)的人有 [非常不同的工作方式](/migrations/postgresql/data-modeling-techniques#primary-ordering-keys-in-clickhouse)。 -在 ClickHouse 中选择有效的主键对于查询性能和存储效率至关重要。ClickHouse 将数据组织成分片,每个分片包含其自身的稀疏主索引。此索引通过减少扫描的数据量显著加快查询速度。此外,由于主键决定了磁盘上数据的物理顺序,它直接影响压缩效率。优化排序的数据可以更有效地压缩,从而通过减少 I/O 进一步提高性能。 +在 ClickHouse 中选择有效的主键对查询性能和存储效率至关重要。ClickHouse 将数据组织成 parts,每个 part 都包含自己的稀疏主索引。该索引通过减少扫描的数据量显著加快查询速度。此外,由于主键决定了磁盘上数据的物理顺序,这直接影响压缩效率。最佳顺序的数据会更有效地压缩,这进一步通过减少 I/O 来提高性能。 -1. 在选择排序键时,优先考虑在查询过滤器(即 `WHERE` 子句)中频繁使用的列,尤其是那些排除大量行的列。 -2. 与表中其他数据高度相关的列也是有益的,因为连续存储可提高压缩率和 `GROUP BY` 和 `ORDER BY` 操作期间的内存效率。 +1. 在选择 ordering key 时,优先考虑在查询过滤器中(即 `WHERE` 子句)常用的列,尤其是那些排除大量行的列。 +2. 与表中其他数据高度相关的列也很有益,因为连续存储能够提高压缩比和在 `GROUP BY` 和 `ORDER BY` 操作中的内存效率。
-可以应用一些简单的规则来帮助选择排序键。以下规则有时可能会出现冲突,因此请按顺序考虑这些规则。**用户可以通过此过程识别多个键,通常 4-5 个即可**: +一些简单的规则可以帮助选择 ordering key。以下规则有时可能会发生冲突,因此请按照顺序考虑这些规则。 **用户可以从此过程中识别出多个键,通常 4-5 个就足够了**: -:::note 重要 -排序键必须在表创建时定义,无法在之后添加。可以通过称为投影的功能在数据插入之后(或之前)向表中添加额外的排序键。请注意,这会导致数据重复。更多细节 [请参见这里](/sql-reference/statements/alter/projection)。 +:::note Important +ordering keys 必须在表创建时定义,并且无法添加。可以通过称为 projections 的功能在数据插入后(或之前)向表中添加额外的 ordering。请注意这会导致数据重复。更多详细信息请点击 [这里](/sql-reference/statements/alter/projection)。 ::: ## 示例 {#example} -考虑以下 `posts_unordered` 表。该表每行对应 Stack Overflow 的一篇帖子。 +考虑以下 `posts_unordered` 表。每行为一个 Stack Overflow 帖子。 -该表没有主键 - 正如 `ORDER BY tuple()` 所指示的那样。 +该表没有主键 - 由 `ORDER BY tuple()` 表示。 ```sql CREATE TABLE posts_unordered @@ -65,7 +66,7 @@ ENGINE = MergeTree ORDER BY tuple() ``` -假设用户希望计算 2024 年之后提交的问题数量,这代表了他们最常见的访问模式。 +假设用户希望计算在 2024 年之后提交的问题数量,这将代表他们最常见的访问模式。 ```sql SELECT count() @@ -79,9 +80,9 @@ WHERE (CreationDate >= '2024-01-01') AND (PostTypeId = 'Question') 1 row in set. Elapsed: 0.055 sec. Processed 59.82 million rows, 361.34 MB (1.09 billion rows/s., 6.61 GB/s.) ``` -请注意此查询读取的行数和字节数。没有主键,查询必须扫描整个数据集。 +注意该查询读取的行数和字节数。没有主键的情况下,查询必须扫描整个数据集。 -使用 `EXPLAIN indexes=1` 确认由于缺乏索引而导致的完整表扫描。 +使用 `EXPLAIN indexes=1` 确认由于缺乏索引而导致的全表扫描。 ```sql EXPLAIN indexes = 1 @@ -100,7 +101,7 @@ WHERE (CreationDate >= '2024-01-01') AND (PostTypeId = 'Question') 5 rows in set. Elapsed: 0.003 sec. ``` -假设一个名为 `posts_ordered` 的表,包含相同数据,定义的 `ORDER BY` 为 `(PostTypeId, toDate(CreationDate))`,即 +假设定义了一个包含相同数据的表 `posts_ordered`,其 `ORDER BY` 定义为 `(PostTypeId, toDate(CreationDate))` 即 ```sql CREATE TABLE posts_ordered @@ -114,13 +115,13 @@ ENGINE = MergeTree ORDER BY (PostTypeId, toDate(CreationDate)) ``` -`PostTypeId` 的基数为 8,是排序键中第一个条目的逻辑选择。认识到日期粒度过滤可能是足够的(它仍然可以受益于日期时间过滤),因此我们使用 `toDate(CreationDate)` 作为我们的键的第二个组件。这也会产生更小的索引,因为日期可以用 16 位表示,从而加快过滤速度。 +`PostTypeId` 的基数为 8,是我们 ordering key 的逻辑首选项。考虑到日期粒度过滤可能会足够(它仍然会受益于日期时间过滤),我们使用 `toDate(CreationDate)` 作为我们键的第二个组成部分。这也将产生一个较小的索引,因为日期可以用 16 位表示,从而加快过滤速度。 -以下动画展示了如何为 Stack Overflow 帖子表创建一个优化的稀疏主索引。索引不是针对单独的行,而是针对行块: +以下动画展示了如何为 Stack Overflow 帖子表创建优化的稀疏主索引。索引不针对单个行,而是针对行块: -如果在具有此排序键的表上重复相同的查询: +如果在具有此 ordering key 的表上重复相同的查询: ```sql SELECT count() @@ -134,9 +135,9 @@ WHERE (CreationDate >= '2024-01-01') AND (PostTypeId = 'Question') 1 row in set. Elapsed: 0.013 sec. Processed 196.53 thousand rows, 1.77 MB (14.64 million rows/s., 131.78 MB/s.) ``` -此查询现在利用稀疏索引,显著减少了读取的数据量,并将执行时间提高了 4 倍 - 请注意读取的行数和字节的减少。 +此查询现在利用稀疏索引,显著减少了读取的数据量,并将执行时间加快了 4 倍 - 注意行数和字节数的减少。 -使用 `EXPLAIN indexes=1` 可以确认索引的使用。 +可以通过 `EXPLAIN indexes=1` 确认索引的使用。 ```sql EXPLAIN indexes = 1 @@ -163,14 +164,14 @@ WHERE (CreationDate >= '2024-01-01') AND (PostTypeId = 'Question') 13 rows in set. Elapsed: 0.004 sec. ``` -此外,我们可以可视化稀疏索引如何修剪所有不能包含匹配项的行块: +此外,我们可视化了稀疏索引如何修剪掉所有无法包含示例查询匹配的行块: :::note -表中所有列将根据指定排序键的值进行排序,无论它们是否包含在键中。例如,如果将 `CreationDate` 用作键,则所有其他列中的值的顺序将与 `CreationDate` 列中的值的顺序相对应。可以指定多个排序键 - 这将与 `SELECT` 查询中的 `ORDER BY` 子句具有相同的语义进行排序。 +表中的所有列将基于指定 ordering key 的值进行排序,而无论它们是否包含在密钥本身中。例如,如果 `CreationDate` 被用作键,则所有其他列中值的顺序将与 `CreationDate` 列中值的顺序对应。可以指定多个 ordering keys - 这将按与 `SELECT` 查询中的 `ORDER BY` 子句相同的语义进行排序。 ::: -关于选择主键的完整高级指南可以在 [这里](/guides/best-practices/sparse-primary-indexes) 找到。 +有关选择主键的完整高级指南,请点击 [这里](/guides/best-practices/sparse-primary-indexes)。 -有关排序键如何改善压缩并进一步优化存储的更深入见解,请探索有关 [ClickHouse 中的压缩](/data-compression/compression-in-clickhouse) 和 [列压缩编解码器](/data-compression/compression-in-clickhouse#choosing-the-right-column-compression-codec) 的官方指南。 +要深入了解 ordering keys 如何改进压缩并进一步优化存储,请查看有关 [ClickHouse 中的压缩](/data-compression/compression-in-clickhouse) 和 [列压缩编码器](/data-compression/compression-in-clickhouse#choosing-the-right-column-compression-codec) 的官方指南。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/choosing_a_primary_key.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/choosing_a_primary_key.md.hash index 317233d640c..4d4fef6c57f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/choosing_a_primary_key.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/choosing_a_primary_key.md.hash @@ -1 +1 @@ -b101c179758b8313 +fec6baf8388594ce diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/index.md index ab36ed4fbb2..81cdd3afd59 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/index.md @@ -9,28 +9,20 @@ - 'Bulk Inserts' - 'Asynchronous Inserts' - 'Avoid Mutations' -- 'Avoid Nullable Columns' +- 'Avoid nullable Columns' - 'Avoid Optimize Final' - 'Partitioning Key' 'title': '概述' 'hide_title': true -'description': 'ClickHouse 中最佳实践部分的登陆页面' +'description': 'ClickHouse 中最佳实践部分的登录页面' +'doc_type': 'landing-page' --- +import TableOfContents from '@site/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/_snippets/_table_of_contents.md'; -# 在 ClickHouse 中的最佳实践 {#best-practices-in-clickhouse} -本节提供了您希望遵循的最佳实践,以最大限度地发挥 ClickHouse 的性能。 +# Best Practices in ClickHouse {#best-practices-in-clickhouse} -| 页面 | 描述 | -|----------------------------------------------------------------------|--------------------------------------------------------------------------| -| [选择主键](/best-practices/choosing-a-primary-key) | 有关在 ClickHouse 中选择有效主键的指导。 | -| [选择数据类型](/best-practices/select-data-types) | 选择适当数据类型的建议。 | -| [使用物化视图](/best-practices/use-materialized-views) | 何时以及如何利用物化视图。 | -| [最小化和优化 JOIN](/best-practices/minimize-optimize-joins) | 最小化和优化 JOIN 操作的最佳实践。 | -| [选择分区键](/best-practices/choosing-a-partitioning-key) | 如何有效选择和应用分区键。 | -| [选择插入策略](/best-practices/selecting-an-insert-strategy) | 在 ClickHouse 中高效数据插入的策略。 | -| [数据跳过索引](/best-practices/use-data-skipping-indices-where-appropriate) | 何时应用数据跳过索引以提升性能。 | -| [避免变更](/best-practices/avoid-mutations) | 避免变更的原因以及如何在设计中不使用它们。 | -| [避免 OPTIMIZE FINAL](/best-practices/avoid-optimize-final) | 为什么 `OPTIMIZE FINAL` 可能代价高昂以及如何规避它。 | -| [适当使用 JSON](/best-practices/use-json-where-appropriate) | 在 ClickHouse 中使用 JSON 列的注意事项。 | +本节提供了您需要遵循的最佳实践,以充分利用 ClickHouse。 + + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/index.md.hash index 3939d9654b6..33e77cfc023 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/index.md.hash @@ -1 +1 @@ -bd85620bf203cca9 +d31757d44d4fd158 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/json_type.md b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/json_type.md index 3060b70de8f..5cc5d6fc458 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/json_type.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/json_type.md @@ -2,55 +2,56 @@ 'slug': '/best-practices/use-json-where-appropriate' 'sidebar_position': 10 'sidebar_label': '使用 JSON' -'title': '在适当的情况下使用 JSON' +'title': '在适当的地方使用 JSON' 'description': '页面描述何时使用 JSON' 'keywords': - 'JSON' 'show_related_blogs': true +'doc_type': 'reference' --- -ClickHouse 现在提供了一种原生 JSON 列类型,专为半结构化和动态数据设计。需要明确的是,**这是一种列类型,而不是数据格式**——您可以将 JSON 作为字符串插入到 ClickHouse 中,或者通过支持的格式如 [JSONEachRow](/docs/interfaces/formats/JSONEachRow) 插入,但这并不意味着使用 JSON 列类型。用户应仅在数据结构动态时使用 JSON 类型,而不是仅仅因为他们存储 JSON。 +ClickHouse 现在提供了一种原生的 JSON 列类型,旨在处理半结构化和动态数据。重要的是要澄清,这**是一种列类型,而不是一种数据格式**——您可以将 JSON 作为字符串插入到 ClickHouse 中,或通过支持的格式,如 [JSONEachRow](/docs/interfaces/formats/JSONEachRow),但这并不意味着使用 JSON 列类型。用户应仅在数据结构动态时使用 JSON 类型,而不是仅仅因为他们存储 JSON。 ## 何时使用 JSON 类型 {#when-to-use-the-json-type} 当您的数据: -* 具有 **不可预测的键**,可能会随着时间变化。 -* 包含 **多种类型的值** (例如,一个路径有时可能包含字符串,有时包含数字)。 -* 需要模式灵活性,严格的类型定义不可行。 +* 具有 **不可预测的键**,可能会随着时间而变化。 +* 包含 **具有不同类型的值**(例如,路径有时可能包含字符串,有时可能是数字)。 +* 需要模式灵活性,严格类型不可行的情况下。 -如果您的数据结构已知且一致,则很少需要使用 JSON 类型,即使您的数据是 JSON 格式的。具体来说,如果您的数据具有: +如果您的数据结构已知且一致,通常没有必要使用 JSON 类型,即使您的数据是 JSON 格式。具体而言,如果您的数据具有: * **已知键的扁平结构**:使用标准列类型,例如 String。 -* **可预测的嵌套**:对于这些结构,使用 Tuple、Array 或 Nested 类型。 -* **可预测的具有不同类型的结构**:考虑使用 Dynamic 或 Variant 类型。 +* **可预测的嵌套**:使用 Tuple、Array 或 Nested 类型来处理这些结构。 +* **具有不同类型的可预测结构**:可以考虑使用 Dynamic 或 Variant 类型。 -您也可以混合使用方法——例如,对可预测的顶层字段使用静态列,对有效负载的动态部分使用单一 JSON 列。 +您还可以混合使用方法 - 例如,使用静态列来处理可预测的顶级字段,并使用单个 JSON 列来处理有效负载的动态部分。 -## 使用 JSON 的考虑事项和提示 {#considerations-and-tips-for-using-json} +## 使用 JSON 的注意事项和提示 {#considerations-and-tips-for-using-json} -JSON 类型通过将路径扁平化为子列来实现高效的列式存储。但灵活性带来了责任。要有效使用它: +JSON 类型通过将路径扁平化为子列来实现高效的列式存储。但灵活性也带来了责任。要有效使用它: -* 使用 [列定义中的提示](/sql-reference/data-types/newjson) 来 **指定路径类型**,为已知子列指定类型,从而避免不必要的类型推断。 -* 如果不需要值,请 **跳过路径**,使用 [SKIP 和 SKIP REGEXP](/sql-reference/data-types/newjson) 来减少存储和提高性能。 -* **避免将 [`max_dynamic_paths`](/sql-reference/data-types/newjson#reaching-the-limit-of-dynamic-paths-inside-json) 设置得太高**——大值会增加资源消耗并降低效率。一般规则是保持在 10,000 以下。 +* **指定路径类型**,使用 [列定义中的提示](/sql-reference/data-types/newjson) 为已知子列指定类型,以避免不必要的类型推断。 +* **跳过不需要的路径**,使用 [SKIP 和 SKIP REGEXP](/sql-reference/data-types/newjson) 来减少存储并提高性能。 +* **避免将 [`max_dynamic_paths`](/sql-reference/data-types/newjson#reaching-the-limit-of-dynamic-paths-inside-json) 设置得过高** - 大值会增加资源消耗并降低效率。作为经验法则,保持在 10,000 以下。 :::note 类型提示 -类型提示不仅仅是避免不必要类型推断的一种方式——它们完全消除了存储和处理间接性。带有类型提示的 JSON 路径总是像传统列一样存储,避免了在查询时使用 [**判别列**](https://clickhouse.com/blog/a-new-powerful-json-data-type-for-clickhouse#storage-extension-for-dynamically-changing-data) 或动态解析的需要。这意味着,使用明确定义的类型提示,嵌套 JSON 字段获得的性能和效率与从一开始就将它们建模为顶层字段是相同的。因此,对于大多数一致但仍有利于 JSON 灵活性的 数据集,类型提示提供了一种方便的方式来保持性能,无需重新构建您的模式或数据摄取管道。 +类型提示不仅仅是避免不必要的类型推断,还完全消除存储和处理间接性。具有类型提示的 JSON 路径总是像传统列一样存储,避免了在查询时需要 [**区分符列**](https://clickhouse.com/blog/a-new-powerful-json-data-type-for-clickhouse#storage-extension-for-dynamically-changing-data) 或动态解析。这意味着,使用良好定义的类型提示,嵌套的 JSON 字段可以实现与它们从一开始就作为顶级字段建模时相同的性能和效率。因此,对于大部分一致但仍然受益于 JSON 灵活性的数据集,类型提示提供了一种便捷的方式来保持性能,而不需要重构您的模式或摄取管道。 ::: ## 高级功能 {#advanced-features} -* JSON 列 **可以像其他列一样用作主键**。不能为子列指定编解码器。 +* JSON 列 **可以像其他列一样用于主键**。子列不能指定编码。 * 它们支持通过 [`JSONAllPathsWithTypes()` 和 `JSONDynamicPaths()`](/sql-reference/data-types/newjson#introspection-functions) 函数进行自省。 -* 您可以使用 `.^` 语法读取嵌套子对象。 -* 查询语法可能与标准 SQL 不同,可能需要对嵌套字段使用特殊的类型转换或操作符。 +* 您可以使用 `.^` 语法读取嵌套的子对象。 +* 查询语法可能与标准 SQL 不同,可能需要为嵌套字段特别的转换或运算符。 -有关更多指导,请参见 [ClickHouse JSON 文档](/sql-reference/data-types/newjson) 或浏览我们的博客文章 [ClickHouse的新强大JSON数据类型](https://clickhouse.com/blog/a-new-powerful-json-data-type-for-clickhouse)。 +有关更多指导,请参见 [ClickHouse JSON 文档](/sql-reference/data-types/newjson) 或浏览我们的博客文章 [ClickHouse 的新强大 JSON 数据类型](https://clickhouse.com/blog/a-new-powerful-json-data-type-for-clickhouse)。 ## 示例 {#examples} -考虑以下 JSON 示例,表示来自 [Python PyPI 数据集](https://clickpy.clickhouse.com/) 的一行: +考虑以下 JSON 样本,表示来自 [Python PyPI 数据集](https://clickpy.clickhouse.com/) 的一行: ```json { @@ -65,7 +66,7 @@ JSON 类型通过将路径扁平化为子列来实现高效的列式存储。但 } ``` -假设此模式是静态的,类型可以很好地定义。即使数据是 NDJSON 格式(每行一个 JSON),对于这样的模式也不需要使用 JSON 类型。只需用经典类型定义模式。 +假设这个结构是静态的,并且可以明确定义类型。即使数据是 NDJSON 格式(每行一个 JSON),对于这样的结构也不需要使用 JSON 类型。只需使用经典类型定义模式即可。 ```sql CREATE TABLE pypi ( @@ -89,7 +90,7 @@ INSERT INTO pypi FORMAT JSONEachRow {"date":"2022-11-15","country_code":"ES","project":"clickhouse-connect","type":"bdist_wheel","installer":"pip","python_minor":"3.9","system":"Linux","version":"0.3.0"} ``` -考虑包含 250 万篇学术论文的 [arXiv 数据集](https://www.kaggle.com/datasets/Cornell-University/arxiv?resource=download)。该数据集中每一行,都以 NDJSON 形式分发,表示一篇已发布的学术论文。下面是一个示例行: +考虑 [arXiv 数据集](https://www.kaggle.com/datasets/Cornell-University/arxiv?resource=download),其中包含 250 万篇学术论文。该数据集中每一行,按 NDJSON 格式分发,代表一篇已发表的学术论文。以下是一个示例行: ```json { @@ -125,7 +126,7 @@ INSERT INTO pypi FORMAT JSONEachRow } ``` -尽管这里的 JSON 结构复杂且嵌套,但它是可预测的。字段的数量和类型不会变化。虽然我们可以对这个示例使用 JSON 类型,但我们也可以仅使用 [Tuples](/sql-reference/data-types/tuple) 和 [Nested](/sql-reference/data-types/nested-data-structures/nested) 类型显式定义结构: +尽管这里的 JSON 是复杂的,具有嵌套结构,但它是可预测的。字段的数量和类型不会改变。虽然我们可以在这个示例中使用 JSON 类型,但我们也可以简单地使用 [Tuples](/sql-reference/data-types/tuple) 和 [Nested](/sql-reference/data-types/nested-data-structures/nested) 类型明确地定义结构: ```sql CREATE TABLE arxiv @@ -149,14 +150,14 @@ ENGINE = MergeTree ORDER BY update_date ``` -我们再次可以将数据作为 JSON 插入: +我们还可以将数据作为 JSON 插入: ```sql INSERT INTO arxiv FORMAT JSONEachRow {"id":"2101.11408","submitter":"Daniel Lemire","authors":"Daniel Lemire","title":"Number Parsing at a Gigabyte per Second","comments":"Software at https://github.com/fastfloat/fast_float and\n https://github.com/lemire/simple_fastfloat_benchmark/","journal-ref":"Software: Practice and Experience 51 (8), 2021","doi":"10.1002/spe.2984","report-no":null,"categories":"cs.DS cs.MS","license":"http://creativecommons.org/licenses/by/4.0/","abstract":"With disks and networks providing gigabytes per second ....\n","versions":[{"created":"Mon, 11 Jan 2021 20:31:27 GMT","version":"v1"},{"created":"Sat, 30 Jan 2021 23:57:29 GMT","version":"v2"}],"update_date":"2022-11-07","authors_parsed":[["Lemire","Daniel",""]]} ``` -假设添加了另一个名为 `tags` 的列。如果这只是一个字符串列表,我们可以建模为 `Array(String)`,但假设用户可以添加混合类型的任意标签结构(请注意分数是字符串或整数)。我们的修改后的 JSON 文档: +假设添加了另一个名为 `tags` 的列。如果这只是一个字符串列表,我们可以建模为 `Array(String)`,但假设用户可以添加任意标签结构,混合类型(注意 score 是字符串或整数)。我们的修改 JSON 文档: ```sql { @@ -210,7 +211,7 @@ INSERT INTO arxiv FORMAT JSONEachRow } ``` -在这种情况下,我们可以将 arXiv 文档建模为全部 JSON 或仅添加一个 JSON `tags` 列。我们在下面提供两个示例: +在这种情况下,我们可以将 arXiv 文档建模为全部 JSON 或者仅添加一个 JSON `tags` 列。我们在下面提供两种示例: ```sql CREATE TABLE arxiv @@ -222,10 +223,10 @@ ORDER BY doc.update_date ``` :::note -我们在 JSON 定义中为 `update_date` 列提供类型提示,因为我们在排序/主键中使用它。这帮助 ClickHouse 知道此列不会为空,并确保它知道使用哪个 `update_date` 子列(可能会有多个,因此否则会模糊)。 +我们在 JSON 定义中为 `update_date` 列提供了一个类型提示,因为我们在排序/主键中使用它。这有助于 ClickHouse 知道该列不会为空,并确保它知道要使用哪个 `update_date` 子列(对于每种类型可能会有多个,因此否则会产生歧义)。 ::: -我们可以将数据插入该表,并使用 [`JSONAllPathsWithTypes`](/sql-reference/functions/json-functions#jsonallpathswithtypes) 函数和 [`PrettyJSONEachRow`](/interfaces/formats/PrettyJSONEachRow) 输出格式查看随后的推断模式: +我们可以将数据插入此表,并使用 [`JSONAllPathsWithTypes`](/sql-reference/functions/json-functions#JSONAllPathsWithTypes) 函数和 [`PrettyJSONEachRow`](/interfaces/formats/PrettyJSONEachRow) 输出格式查看随后的推断模式: ```sql INSERT INTO arxiv FORMAT JSONAsObject @@ -265,7 +266,7 @@ FORMAT PrettyJSONEachRow 1 row in set. Elapsed: 0.003 sec. ``` -或者,我们可以使用我们早期的模式和一个 JSON `tags` 列进行建模。这通常是优选的,最小化 ClickHouse 所需的推断: +或者,我们可以使用之前的模式和一个 JSON `tags` 列来建模。这通常是更优选的,最小化 ClickHouse 所需的推断: ```sql CREATE TABLE arxiv @@ -295,7 +296,7 @@ INSERT INTO arxiv FORMAT JSONEachRow {"id":"2101.11408","submitter":"Daniel Lemire","authors":"Daniel Lemire","title":"Number Parsing at a Gigabyte per Second","comments":"Software at https://github.com/fastfloat/fast_float and\n https://github.com/lemire/simple_fastfloat_benchmark/","journal-ref":"Software: Practice and Experience 51 (8), 2021","doi":"10.1002/spe.2984","report-no":null,"categories":"cs.DS cs.MS","license":"http://creativecommons.org/licenses/by/4.0/","abstract":"With disks and networks providing gigabytes per second ....\n","versions":[{"created":"Mon, 11 Jan 2021 20:31:27 GMT","version":"v1"},{"created":"Sat, 30 Jan 2021 23:57:29 GMT","version":"v2"}],"update_date":"2022-11-07","authors_parsed":[["Lemire","Daniel",""]],"tags":{"tag_1":{"name":"ClickHouse user","score":"A+","comment":"A good read, applicable to ClickHouse"},"28_03_2025":{"name":"professor X","score":10,"comment":"Didn't learn much","updates":[{"name":"professor X","comment":"Wolverine found more interesting"}]}}} ``` -我们现在可以推断子列 tags 的类型。 +现在我们可以推断子列 tags 的类型。 ```sql SELECT JSONAllPathsWithTypes(tags) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/json_type.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/json_type.md.hash index ffaa884fb5d..a377784ad77 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/json_type.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/json_type.md.hash @@ -1 +1 @@ -dc573e035a8fd4d5 +f1642a900422955f diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/minimize_optimize_joins.md b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/minimize_optimize_joins.md index ffc5a1cee07..37b2042fb42 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/minimize_optimize_joins.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/minimize_optimize_joins.md @@ -3,55 +3,56 @@ 'sidebar_position': 10 'sidebar_label': '最小化和优化 JOINs' 'title': '最小化和优化 JOINs' -'description': '页面描述 JOINs 的最佳实践' +'description': '描述 JOINs 最佳实践的页面' 'keywords': - 'JOIN' - 'Parallel Hash JOIN' 'show_related_blogs': true +'doc_type': 'guide' --- import Image from '@theme/IdealImage'; import joins from '@site/static/images/bestpractices/joins-speed-memory.png'; -ClickHouse 支持多种 JOIN 类型和算法,且 JOIN 性能在近期版本中显著提升。然而,JOIN 本质上比从单个非规范化表查询更昂贵。非规范化将计算工作从查询时间转移到插入或预处理时间,从而在运行时通常会导致显著更低的延迟。对于实时或对延迟敏感的分析查询,**强烈建议非规范化**。 +ClickHouse 支持多种类型的 JOIN 和算法,并且 JOIN 性能在最近的版本中有了显著提升。然而,JOIN 本质上比从单个去规范化的表中查询更为昂贵。去规范化将计算工作从查询时间转移到插入或预处理时间,这通常会在运行时显著降低延迟。对于实时或时延敏感的分析查询,**强烈建议使用去规范化**。 -一般情况下,在以下情况下进行非规范化: +一般来说,当满足以下条件时应去规范化: -- 表变更不频繁或批量刷新是可以接受的。 -- 关系不是多对多或者在基数上不会过高。 -- 只有有限的列子集会被查询,即某些列可以从非规范化中排除。 -- 你有能力将处理从 ClickHouse 转移到上游系统(如 Flink),在这些系统中可以管理实时丰富或扁平化。 +- 表不经常变化,或当批量刷新是可以接受的。 +- 关系不是多对多,或基数不异常高。 +- 只会查询有限子集的列,即某些列可以从去规范化中排除。 +- 您能够将处理转移到上游系统(如 Flink),在这些系统中可以管理实时丰富或扁平化。 -并不是所有数据都需要非规范化 - 应关注频繁被查询的属性。也可以考虑 [物化视图](/best-practices/use-materialized-views) 来逐步计算聚合,而不是复制整个子表。当模式更新较少且延迟至关重要时,非规范化提供了最佳的性能权衡。 +并非所有数据都需要去规范化——重点关注经常查询的属性。还可以考虑 [物化视图](/best-practices/use-materialized-views) 来增量计算聚合,而不是复制整个子表。当模式更新较少且延迟至关重要时,去规范化提供了最佳性能权衡。 -有关在 ClickHouse 中非规范化数据的完整指南,请查看 [这里](/data-modeling/denormalization)。 +有关在 ClickHouse 中去规范化数据的完整指南,请参见 [这里](/data-modeling/denormalization)。 -## 何时需要 JOINs {#when-joins-are-required} +## 何时需要 JOIN {#when-joins-are-required} -当需要 JOINs 时,确保 **至少使用版本 24.12,最好是最新版本**,因为 JOIN 性能在每个新版本中都在持续改进。自 ClickHouse 24.12 起,查询规划器现在会自动将较小的表放置在 JOIN 的右侧,以获得最佳性能 - 这一任务之前需要手动完成。更进一步的增强即将到来,包括更积极的过滤下推和多个 JOIN 的自动重排序。 +当需要 JOIN 时,请确保使用 **至少版本 24.12,最好是最新版本**,因为 JOIN 性能随着每个新版本的发布而不断提高。根据 ClickHouse 24.12,查询规划器现在会自动将较小的表放在 JOIN 的右侧以优化性能——这一任务以前需要手动完成。更多增强功能即将推出,包括更强的过滤推送和多个 JOIN 的自动重排序。 遵循以下最佳实践以提高 JOIN 性能: -* **避免笛卡尔乘积**:如果左侧的某个值与右侧的多个值匹配,则 JOIN 将返回多行 - 即笛卡尔乘积。如果你的用例不需要右侧的所有匹配结果,而只需要任何单个匹配值,可以使用 `ANY` JOINs(例如 `LEFT ANY JOIN`)。它们比常规 JOINs 更快,内存使用更少。 -* **减少 JOIN 表的大小**:JOIN 的运行时和内存消耗与左表和右表的大小成正比。要减少 JOIN 处理的数据量,请在查询的 `WHERE` 或 `JOIN ON` 子句中添加其他过滤条件。ClickHouse 将过滤条件尽可能深地下推到查询计划中,通常是在 JOIN 之前。如果过滤器没有被自动下推(出于某种原因),则重写 JOIN 的一侧为子查询以强制下推。 -* **如合适使用字典进行直接 JOIN**:ClickHouse 中的标准 JOIN 分为两个阶段执行:构建阶段遍历右侧以构建哈希表,后续是探测阶段遍历左侧以通过哈希表查找匹配的 JOIN 伙伴。如果右侧是 [字典](/dictionary) 或其他具有键值特征的表引擎(例如 [EmbeddedRocksDB](/engines/table-engines/integrations/embedded-rocksdb) 或 [Join 表引擎](/engines/table-engines/special/join)),则 ClickHouse 可以使用“直接” JOIN 算法,这样就实际消除了构建哈希表的需要,加快了查询处理。此方法适用于 `INNER` 和 `LEFT OUTER` JOIN,且更适合实时分析工作负载。 -* **利用表排序进行 JOIN**:ClickHouse 中的每个表都根据表的主键列进行排序。可以利用表排序,通过所谓的排序合并 JOIN 算法,如 `full_sorting_merge` 和 `partial_merge`。与基于哈希表的标准 JOIN 算法不同(见下文,`parallel_hash`,`hash`,`grace_hash`),排序合并 JOIN 算法首先排序,然后合并两个表。如果查询通过各自的主键列 JOIN 了两个表,则排序合并具有一种优化,可以省略排序步骤,从而节省处理时间和开销。 -* **避免磁盘溢出 JOIN**:JOIN 的中间状态(例如哈希表)可能会变得过大,以至于无法再适应主内存。在这种情况下,ClickHouse 将默认返回内存不足错误。一些 JOIN 算法(见下文),例如 [`grace_hash`](https://clickhouse.com/blog/clickhouse-fully-supports-joins-hash-joins-part2),[`partial_merge`](https://clickhouse.com/blog/clickhouse-fully-supports-joins-full-sort-partial-merge-part3) 和 [`full_sorting_merge`](https://clickhouse.com/blog/clickhouse-fully-supports-joins-full-sort-partial-merge-part3),能够将中间状态溢出到磁盘并继续查询执行。然而,使用这些 JOIN 算法时仍需谨慎,因为磁盘访问会显著减慢 JOIN 处理。我们反而建议通过其他方式优化 JOIN 查询,以减少中间状态的大小。 -* **在外部 JOIN 中使用默认值作为无匹配标记**:左/右/全外 JOIN 包含来自左/右/两个表的所有值。如果在另一张表中未找到某个值的 JOIN 伙伴,ClickHouse 将用一个特殊标记替换该 JOIN 伙伴。SQL 标准规定数据库使用 NULL 作为这样的标记。在 ClickHouse 中,这需要将结果列包装在 Nullable 中,增加额外的内存和性能开销。作为替代方案,你可以配置设置 `join_use_nulls = 0`,并使用结果列数据类型的默认值作为标记。 +* **避免笛卡尔积**:如果左侧的某个值与右侧的多个值匹配,JOIN 将返回多行——所谓的笛卡尔积。如果您的用例并不需要来自右侧的所有匹配项,而只是任何单个匹配项,则可以使用 `ANY` JOIN(例如,`LEFT ANY JOIN`)。它们比常规 JOIN 更快,占用更少的内存。 +* **减少已 JOIN 表的大小**:JOIN 的运行时间和内存消耗与左侧和右侧表的大小成正比。要减少 JOIN 处理的数据量,请在查询的 `WHERE` 或 `JOIN ON` 子句中添加额外的过滤条件。ClickHouse 会尽可能深地推送过滤条件到查询计划中,通常是在 JOIN 之前。如果过滤条件未自动推送(出于任何原因),可以将 JOIN 的一侧重写为子查询以强制推送。 +* **适当时通过字典使用直接 JOIN**:ClickHouse 中的标准 JOIN 分为两个阶段执行:构建阶段迭代右侧以构建哈希表,随后是探测阶段迭代左侧通过哈希表查找匹配的 JOIN 伙伴。如果右侧是一个 [字典](/dictionary) 或其他具有键值特征的表引擎(例如 [EmbeddedRocksDB](/engines/table-engines/integrations/embedded-rocksdb) 或 [Join 表引擎](/engines/table-engines/special/join)),则 ClickHouse 可以使用“直接” JOIN 算法,有效地消除了构建哈希表的需要,从而加速查询处理。这适用于 `INNER` 和 `LEFT OUTER` JOIN,并且是实时分析工作负载的首选。 +* **利用表排序进行 JOIN**:ClickHouse 中的每个表都是按照表的主键列排序的。可以利用所谓的排序合并 JOIN 算法(如 `full_sorting_merge` 和 `partial_merge`)利用表的排序。与基于哈希表的标准 JOIN 算法(见下文 `parallel_hash`,`hash`,`grace_hash`)不同,排序合并 JOIN 算法首先对两个表进行排序,然后进行合并。如果查询通过各自的主键列对两个表进行 JOIN,则排序合并具有省略排序步骤的优化,从而节省处理时间和开销。 +* **避免磁盘溢出 JOIN**:JOIN 的中间状态(例如,哈希表)可能会变得非常大,以至于无法再装入主内存。在这种情况下,ClickHouse 将默认返回内存不足错误。一些 JOIN 算法(见下文),例如 [`grace_hash`](https://clickhouse.com/blog/clickhouse-fully-supports-joins-hash-joins-part2),[`partial_merge`](https://clickhouse.com/blog/clickhouse-fully-supports-joins-full-sort-partial-merge-part3) 和 [`full_sorting_merge`](https://clickhouse.com/blog/clickhouse-fully-supports-joins-full-sort-partial-merge-part3),能够将中间状态溢出到磁盘,并继续执行查询。然而,应该谨慎使用这些JOIN算法,因为磁盘访问可能显著减慢 JOIN 处理。我们建议以其他方式优化 JOIN 查询,以减少中间状态的大小。 +* **将默认值作为外部 JOIN 中的无匹配标记**:左/右/全外部 JOIN 包含左/右/两个表的所有值。如果在另一个表中找不到某个值的 JOIN 伙伴,ClickHouse 将用一个特殊标记替换此 JOIN 伙伴。SQL 标准要求数据库使用 NULL 作为此类标记。在 ClickHouse 中,这需要将结果列包装在 Nullable 中,从而产生额外的内存和性能开销。作为替代,您可以配置设置 `join_use_nulls = 0`,并使用结果列数据类型的默认值作为标记。 -:::note 注意谨慎使用字典 -在 ClickHouse 中使用字典进行 JOIN 时,重要的是要理解字典设计上不允许重复键。在数据加载期间,任何重复的键都会被默默去重 - 仅保留给定键的最后加载值。这一行为使得字典非常适合一对一或多对一关系,其中只需要最新或权威的值。然而,使用字典处理一对多或多对多关系(例如将角色与演员关联,演员可能有多个角色)将导致静默数据丢失,因为所有与之匹配的行中除了一个外的行都将被丢弃。因此,字典不适用于需要在多个匹配中保持完整关系的场景。 +:::note 谨慎使用字典 +在 ClickHouse 中使用字典进行 JOIN 时,了解字典的设计是不允许重复键的,在数据加载过程中,任何重复的键都会被静默去重——仅保留给定键的最后加载值。这种行为使得字典非常适合一对一或多对一的关系,其中只需要最新或权威的值。然而,将字典用于一对多或多对多关系(例如,将角色链接到演员,其中一个演员可以有多个角色)会导致静默数据丢失,因为匹配的行中只保留一行。因此,字典不适合需要跨多个匹配保持完整关系保真度的场景。 ::: -## 选择正确的 JOIN 算法 {#choosing-the-right-join-algorithm} +## 选择合适的 JOIN 算法 {#choosing-the-right-join-algorithm} -ClickHouse 支持几种在速度和内存之间进行权衡的 JOIN 算法: +ClickHouse 支持几种 JOIN 算法,速度和内存之间进行权衡: -* **并行哈希 JOIN(默认):** 适合适合内存的小到中等右侧表。 -* **直接 JOIN:** Ideal when using dictionaries (or other table engines with key-value characteristics) with `INNER` or `LEFT ANY JOIN` - 这是进行点查找的最快方法,因为它消除了构建哈希表的需要。 -* **全排序合并 JOIN:** 当两个表均按连接键排序时高效。 -* **部分合并 JOIN:** 内存占用最小,但速度较慢 - 最适合在内存有限的情况下连接大表。 -* **Grace 哈希 JOIN:** 灵活且可调节内存,适合大型数据集,具有可调整的性能特性。 +* **并行哈希 JOIN(默认):** 针对适合内存中的小到中型右侧表快速。 +* **直接 JOIN:** 使用字典(或其他具有键值特征的表引擎)时理想——这是最佳的针对点查找的方法,因为它消除了构建哈希表的需要。 +* **全排序合并 JOIN:** 当两个表都按 JOIN 键排序时有效。 +* **部分合并 JOIN:** 最小化内存,但较慢——最佳用于连接大表但内存有限的情况。 +* **Grace 哈希 JOIN:** 灵活且可调节内存,适用于具有可调性能特征的大数据集。 @@ -59,12 +60,12 @@ ClickHouse 支持几种在速度和内存之间进行权衡的 JOIN 算法: 每种算法对 JOIN 类型的支持各不相同。每种算法支持的 JOIN 类型的完整列表可以在 [这里](/guides/joining-tables#choosing-a-join-algorithm) 找到。 ::: -你可以通过设置 `join_algorithm = 'auto'`(默认值)让 ClickHouse 自动选择最佳算法,或根据你的工作负载明确控制。如果你需要选择 JOIN 算法以优化性能或内存开销,我们推荐 [此指南](/guides/joining-tables#choosing-a-join-algorithm)。 +您可以通过设置 `join_algorithm = 'auto'`(默认)来让 ClickHouse 选择最佳算法,或者根据工作负载明确控制。如果您需要选择一个 JOIN 算法以优化性能或内存开销,建议参考 [本指南](/guides/joining-tables#choosing-a-join-algorithm)。 为了获得最佳性能: -* 在高性能工作负载中将 JOIN 限制在最低限度。 -* 避免每个查询中包含超过 3-4 个 JOIN。 -* 在真实数据上基准测试不同算法 - 性能根据 JOIN 键的分布和数据大小而变化。 +* 在高性能工作负载中过少使用 JOIN。 +* 每个查询避免超过 3-4 个 JOIN。 +* 在实际数据上对不同算法进行基准测试——性能会根据 JOIN 键分布和数据大小变化。 -有关 JOIN 优化策略、JOIN 算法及其调优的更多信息,请参阅 [ClickHouse 文档](/guides/joining-tables) 和这 [博客系列](https://clickhouse.com/blog/clickhouse-fully-supports-joins-part1)。 +有关 JOIN 优化策略、JOIN 算法以及如何调整它们的更多信息,请参考 [ClickHouse 文档](/guides/joining-tables) 和这篇 [博客系列](https://clickhouse.com/blog/clickhouse-fully-supports-joins-part1)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/minimize_optimize_joins.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/minimize_optimize_joins.md.hash index 22a075534b4..40af612f536 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/minimize_optimize_joins.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/minimize_optimize_joins.md.hash @@ -1 +1 @@ -098c2760185c09c5 +3236a9b4bc878c8b diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/partitioning_keys.mdx b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/partitioning_keys.mdx index afde22eb5d8..e5a99261c63 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/partitioning_keys.mdx +++ b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/partitioning_keys.mdx @@ -6,64 +6,64 @@ 'description': '页面描述如何选择分区键' 'keywords': - 'partitioning key' +'doc_type': 'reference' --- import Image from '@theme/IdealImage'; import partitions from '@site/static/images/bestpractices/partitions.png'; import merges_with_partitions from '@site/static/images/bestpractices/merges_with_partitions.png'; -:::note 数据管理技术 -分区主要是一种数据管理技术,而不是查询优化工具,尽管它可以在特定工作负载中提升性能,但不应作为加速查询的第一机制;分区键必须谨慎选择,清楚其影响,仅在符合数据生命周期需求或良好理解的访问模式时应用。 +:::note A data management technique +分区主要是一种数据管理技术,而不是查询优化工具,虽然它可以在特定工作负载中提高性能,但不应首先用来加速查询;分区键必须小心选择,并明确其影响,只有在与数据生命周期需求或成熟的访问模式一致时才应用。 ::: -在 ClickHouse 中,分区将数据按照指定的键组织成逻辑段。这是在创建表时使用 `PARTITION BY` 子句定义的,通常用于按时间间隔、类别或其他业务相关维度对行进行分组。每个分区表达式的唯一值在磁盘上形成自己的物理分区,ClickHouse 为这些值中的每一个存储数据于单独的部分。分区改善了数据管理,简化了保留策略,并能帮助处理某些查询模式。 +在 ClickHouse 中,分区根据指定的键将数据组织成逻辑段。这在创建表时使用 `PARTITION BY` 子句定义,通常用于按时间区间、类别或其他与业务相关的维度对行进行分组。分区表达式的每个唯一值在磁盘上形成自己的物理分区,ClickHouse 为这些值中的每个存储独立的部分。分区提高了数据管理,简化了保留策略,并有助于某些查询模式。 -例如,考虑以下带有分区键 `toStartOfMonth(date)` 的英国价格支付数据集表。 +例如,考虑以下带有分区键 `toStartOfMonth(date)` 的英国支付价格数据集表。 ```sql CREATE TABLE uk.uk_price_paid_simple_partitioned ( - date Date, - town LowCardinality(String), - street LowCardinality(String), - price UInt32 + date Date, + town LowCardinality(String), + street LowCardinality(String), + price UInt32 ) ENGINE = MergeTree ORDER BY (town, street) PARTITION BY toStartOfMonth(date) ``` -每当一组行插入到表中时,ClickHouse 不会创建一个单一的数据部分来包含所有插入的行(如 [这里](/parts) 所述),而是为每个插入行中的唯一分区键值创建一个新数据部分: +每当一组行插入表时,ClickHouse 创建每个唯一分区键值的新数据部分,而不是创建一个(至少一)包含所有插入行的单一数据部分(如[这里所述](/parts))。 - + +ClickHouse 服务器首先通过其分区键值 `toStartOfMonth(date)` 将示例插入中的 4 行拆分成行。然后,对于每个识别的分区,按照[通常的步骤](/parts)处理这些行(① 排序,② 划分到列,③ 压缩,④ 写入磁盘)。 -ClickHouse 服务器首先根据其分区键值 `toStartOfMonth(date)` 将上面示例插入中由 4 行组成的行分割开。然后,对于每个识别的分区,这些行像[往常一样](/parts) 处理,执行几个顺序步骤(① 排序,② 划分列,③ 压缩,④ 写入磁盘)。 +有关分区的更详细解释,我们推荐[本指南](/partitions)。 -要获取关于分区的更详细解释,我们推荐[本指南](/partitions)。 +启用分区后,ClickHouse 只在分区内[合并](/merges)数据部分,而不跨分区进行合并。我们为上述示例表绘制了这一点: -启用分区后,ClickHouse 仅在分区内[合并](/merges) 数据部分,而不是跨分区。我们为上面的示例表进行概述: + - +## 应用分区 {#applications-of-partitioning} -## 分区的应用 {#applications-of-partitioning} +分区是管理 ClickHouse 中大数据集的强大工具,尤其在可观察性和分析用例中。它通过允许与时间或业务逻辑对齐的整个分区在单个元数据操作中被删除、移动或归档,使高效的数据生命周期操作成为可能。这比逐行删除或复制操作显著更快,占用更少资源。分区还与 ClickHouse 特性如 TTL 和分层存储无缝集成,使得在没有自定义编排的情况下实现保留策略或冷热存储策略成为可能。例如,最近的数据可以保留在快速的 SSD 存储中,而较旧的分区则自动转移到更便宜的对象存储中。 -分区是管理 ClickHouse 中大数据集的强大工具,尤其在可观察性和分析用例中。它通过允许与时间或业务逻辑对齐的整个分区一次性删除、移动或归档,来实现有效的数据生命周期操作。这比逐行删除或复制操作要快得多且资源消耗更少。分区还与 ClickHouse 功能如 TTL 和分层存储无缝集成,使得在无需自定义协调的情况下实施保留策略或热/冷存储策略成为可能。例如,可以将最近的数据保留在快速的 SSD 储存上,而将较老的分区自动转移到更便宜的对象存储中。 +虽然分区可以提高某些工作负载的查询性能,但也可能对响应时间产生负面影响。 -虽然分区可以提升某些工作负载的查询性能,但也可能对响应时间产生负面影响。 +如果分区键不在主键中,而你又以此进行过滤,用户可能会在使用分区时看到查询性能的提高。 示例请参见[这里](/partitions#query-optimization)。 -如果分区键不在主键中并您按其过滤,则用户可能会看到分区提升查询性能。有关示例,请参见[此处](/partitions#query-optimization)。 +相反,如果查询需要跨分区查询,性能可能会受到负面影响,因为总的部分数量较高。因此,在考虑将分区作为查询优化技术之前,用户应理解其访问模式。 -相反,如果查询需要跨分区查询,性能可能会由于总部分数的增加而受到负面影响。因此,用户在考虑将分区作为查询优化技术之前,应该了解其访问模式。 - -总之,用户应将分区主要视为一种数据管理技术。有关管理数据的示例,请查看来自可观察性用例指南的 ["管理数据"](/observability/managing-data) 和来自核心概念 - 表分区的 ["表分区的用途是什么?"](/partitions#data-management)。 +总之,用户应主要将分区视为一种数据管理技术。有关管理数据的示例,请参见可观察性用例指南中的["管理数据"](/observability/managing-data)和核心概念 - 表分区中的["表分区的用途是什么?"](/partitions#data-management)。 ## 选择低基数分区键 {#choose-a-low-cardinality-partitioning-key} -重要的是,过多的部分将对查询性能产生负面影响。如果部分数量超过指定的总限制(在[总数](/operations/settings/merge-tree-settings#max_parts_in_total)或[每个分区](/operations/settings/merge-tree-settings#parts_to_throw_insert)),ClickHouse 将因此对插入作出响应,提示[“部分太多”](/knowledgebase/exception-too-many-parts) 错误。 +重要的是,较高的部分数量会对查询性能产生负面影响。因此,如果部分数量超过指定限制,则 ClickHouse 会对插入做出[“部分太多”](/knowledgebase/exception-too-many-parts)的响应,无论是在[总数](/operations/settings/merge-tree-settings#max_parts_in_total)或[每个分区](/operations/settings/merge-tree-settings#parts_to_throw_insert)中。 -选择正确的 **基数** 对于分区键至关重要。高基数的分区键——即不同分区值的数量较大——可能会导致数据部分的激增。由于 ClickHouse 不会合并跨分区的部分,过多的分区将导致未合并的部分过多,最终触发“部分太多”错误。[合并是必要的](/merges) ,以减少存储碎片并优化查询速度,但对于高基数的分区,该合并潜力会丧失。 +为分区键选择正确的**基数**至关重要。高基数的分区键 - 具有大量不同分区值 - 可能会导致数据部分的急剧增加。由于 ClickHouse 不会跨分区合并部分,因此过多的分区会导致过多未合并的部分,最终触发“部分太多”错误。[合并是必要的](/merges),用于减少存储碎片并优化查询速度,但使用高基数分区时,这个合并潜力将会丧失。 -相反,**低基数分区键**——具有 100 到 1,000 个不同值——通常是最优的。它能够有效地进行部分合并,保持元数据开销低,并避免在存储中创建过多对象。此外,ClickHouse 自动在分区列上建立 MinMax 索引,这可以显著加快对这些列进行过滤的查询。例如,当表按 `toStartOfMonth(date)` 进行分区时,按月过滤可使引擎完全跳过无关的分区及其部分。 +相比之下,**低基数的分区键**——具有少于 100 - 1,000 个不同值——通常是最佳选择。它允许高效的部分合并,保持元数据开销低,并避免在存储中创建过多对象。此外,ClickHouse 会自动在分区列上构建 MinMax 索引,这可以显著加速对这些列进行过滤的查询。例如,当表按 `toStartOfMonth(date)` 分区时,按月份过滤可以让引擎完全跳过无关的分区及其部分。 -虽然分区可以在某些查询模式中提升性能,但它主要是一种数据管理特性。在许多情况下,由于数据碎片化增加和扫描更多部分,在所有分区间查询可能比使用非分区表更慢。明智地使用分区,并始终确保所选键是低基数并符合您的数据生命周期政策(例如,通过 TTL 进行保留)。如果您不确定分区是否必要,您可以先从不使用分区开始,根据观察到的访问模式再进行优化。 +虽然分区可以提高某些查询模式的性能,但它主要是一项数据管理功能。在许多情况下,跨所有分区查询可能会比使用未分区表更慢,这归因于数据碎片增加和扫描的部分增多。要明智地使用分区,并始终确保所选择的键是低基数并符合你的数据生命周期政策(例如,通过 TTL 进行保留)。如果你不确定分区是否必要,可以先从不使用它开始,随后根据观察到的访问模式进行优化。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/partitioning_keys.mdx.hash b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/partitioning_keys.mdx.hash index b5eaefad89a..7943128fbbe 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/partitioning_keys.mdx.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/partitioning_keys.mdx.hash @@ -1 +1 @@ -cba7fafe19055f4a +ac5ed4f2477880ee diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/select_data_type.md b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/select_data_type.md index 614eb08ff42..237fa860fc3 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/select_data_type.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/select_data_type.md @@ -6,34 +6,35 @@ 'description': '页面描述如何在 ClickHouse 中选择数据类型' 'keywords': - 'data types' +'doc_type': 'reference' --- import NullableColumns from '@site/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/_snippets/_avoid_nullable_columns.md'; -ClickHouse 查询性能的核心原因之一是其高效的数据压缩。磁盘上的数据减少通过最小化 I/O 开销,从而导致更快的查询和插入。ClickHouse 的列式架构自然地将相似数据相邻排列,使压缩算法和编解码器能够显著减小数据大小。为了最大化这些压缩收益,精心选择适当的数据类型至关重要。 +ClickHouse 查询性能的核心原因之一是其高效的数据压缩。磁盘上的数据更少通过最小化 I/O 开销提高查询和插入的速度。ClickHouse 的列式架构自然将相似的数据相邻排列,使得压缩算法和编解码器能够显著减少数据大小。为了最大化这些压缩效益,仔细选择适当的数据类型至关重要。 -ClickHouse 中的压缩效率主要依赖于三个因素:排序键、数据类型和编解码器,这些都通过表模式定义。选择最佳数据类型可以立即改善存储和查询性能。 +在 ClickHouse 中,压缩效率主要依赖于三个因素:排序键、数据类型和编解码器,所有这些都通过表模式定义。选择最佳的数据类型可以在存储和查询性能上实现立即改进。 -一些简单的指导原则可以显著增强模式: +一些简单的指南可以显著增强模式: -* **使用严格类型:** 始终为列选择正确的数据类型。数值和日期字段应使用适当的数值和日期类型,而不是通用的字符串类型。这确保了过滤和聚合的正确语义。 +* **使用严格类型:** 始终为列选择正确的数据类型。数值和日期字段应使用适当的数值和日期类型,而不是通用的字符串类型。这确保了过滤和聚合的语义正确。 -* **避免 Nullable 列:** Nullable 列通过维护单独的列来跟踪空值,引入额外开销。只有在明确需要区分空状态和 null 状态时才使用 Nullable。否则,通常默认值或零等效值即可满足需求。有关为什么除非必要应避免此类型的更多信息,请参见 [避免 Nullable 列](/best-practices/select-data-types#avoid-nullable-columns)。 +* **避免可空列:** 可空列通过维护单独的列来跟踪空值,从而引入额外的开销。仅在明确需要区分空状态和null状态时使用 Nullable。否则,默认值或零等效值通常足够。有关为什么应避免此类型的更多信息,请参见 [Avoid nullable Columns](/best-practices/select-data-types#avoid-nullable-columns)。 -* **最小化数值精度:** 选择最小位宽的数值类型,该类型仍能适应预期的数据范围。例如,如果不需要负值,并且范围在 0–65535 之间,则优先考虑 [UInt16 而不是 Int32](/sql-reference/data-types/int-uint)。 +* **最小化数值精度:** 选择具有最小位宽的数值类型,但仍能满足预期的数据范围。例如,如果不需要负值,并且范围符合 0–65535,优先选择 [UInt16 over Int32](/sql-reference/data-types/int-uint)。 -* **优化日期和时间精度:** 选择最粗粒度的日期或日期时间类型,以满足查询要求。对仅包含日期的字段使用 Date 或 Date32,除非需要毫秒或更细的精度,建议使用 DateTime 而不是 DateTime64。 +* **优化日期和时间精度:** 选择满足查询要求的最粗粒度的日期或 datetime 类型。对于仅包含日期的字段使用 Date 或 Date32,除非需要毫秒或更细的精度,否则优先选择 DateTime 而不是 DateTime64。 -* **利用 LowCardinality 和专用类型:** 对于具有少于约 10,000 个唯一值的列,使用 LowCardinality 类型可以通过字典编码显著减少存储。同样,FixedString 仅在列值为严格固定长度的字符串(例如,国家或货币代码)时使用,对于有有限可能值集的列,建议使用 Enum 类型,以便实现高效存储和内置数据验证。 +* **利用 LowCardinality 和专用类型:** 对于具有约 10,000 个唯一值以下的列,使用 LowCardinality 类型通过字典编码显著减少存储。同样,只有当列值为严格固定长度字符串(例如国家或货币代码)时才使用 FixedString,并且对于具有有限可能值集的列优先使用 Enum 类型,以实现高效存储和内置数据验证。 -* **用于数据验证的 Enum:** Enum 类型可用于有效编码枚举类型。根据所需存储的唯一值数量,Enums 可以是 8 位或 16 位。如果您需要插入时的相关验证(未声明的值将被拒绝)或希望执行利用 Enum 值自然顺序的查询,请考虑使用此类型,例如,设想一个包含用户反馈的列 Enum(':(' = 1, ':|' = 2, ':)' = 3)。 +* **用于数据验证的枚举:** Enum 类型可以有效编码枚举类型。根据需要存储的唯一值的数量,枚举可以是 8 位或 16 位。如果您需要在插入时进行关联验证(未声明的值将被拒绝)或希望执行利用枚举值的自然排序的查询,例如构想一个包含用户反馈的列 Enum(':(' = 1, ':|' = 2, ':)' = 3),请考虑使用它。 ## 示例 {#example} -ClickHouse 提供内置工具来简化类型优化。例如,模式推断可以自动识别初始类型。考虑公开可用的 Parquet 格式的 Stack Overflow 数据集。通过 [`DESCRIBE`](/sql-reference/statements/describe-table) 命令运行简单的模式推断提供了初始的未优化模式。 +ClickHouse 提供内置工具以简化类型优化。例如,模式推断可以自动识别初始类型。考虑 Stack Overflow 数据集,公开以 Parquet 格式提供。通过 [`DESCRIBE`](/sql-reference/statements/describe-table) 命令运行简单的模式推断可以提供初始的未优化模式。 :::note -默认情况下,ClickHouse 将这些映射为等效的 Nullable 类型。这是首选,因为该模式仅基于样本行。 +默认情况下,ClickHouse 将这些映射为等效的 Nullable 类型。这是首选,因为该模式仅基于行的一个样本。 ::: ```sql @@ -69,40 +70,40 @@ SETTINGS describe_compact_output = 1 ``` :::note -请注意,我们使用 glob 模式 *.parquet 读取 stackoverflow/parquet/posts 文件夹中的所有文件。 +请注意,我们在此处使用通配符 *.parquet 来读取 stackoverflow/parquet/posts 文件夹中的所有文件。 ::: -通过将我们的早期简单规则应用于我们的帖子表,我们可以识别每列的最佳类型: - -| 列名 | 是否数值 | 最小值, 最大值 | 唯一值 | 空值 | 注释 | 优化后的类型 | -|------------------------|------------|------------------------------------------------------------------------|----------------|--------|----------------------------------------------------------------------------------------------|------------------------------------------| -| `PostTypeId` | 是 | 1, 8 | 8 | 否 | | `Enum('Question' = 1, 'Answer' = 2, 'Wiki' = 3, 'TagWikiExcerpt' = 4, 'TagWiki' = 5, 'ModeratorNomination' = 6, 'WikiPlaceholder' = 7, 'PrivilegeWiki' = 8)` | -| `AcceptedAnswerId` | 是 | 0, 78285170 | 12282094 | 是 | 用于将 Null 与 0 值区分 | UInt32 | -| `CreationDate` | 否 | 2008-07-31 21:42:52.667000000, 2024-03-31 23:59:17.697000000 | - | 否 | 不需要毫秒粒度,使用 DateTime | DateTime | -| `Score` | 是 | -217, 34970 | 3236 | 否 | | Int32 | -| `ViewCount` | 是 | 2, 13962748 | 170867 | 否 | | UInt32 | -| `Body` | 否 | - | - | 否 | | String | -| `OwnerUserId` | 是 | -1, 4056915 | 6256237 | 是 | | Int32 | -| `OwnerDisplayName` | 否 | - | 181251 | 是 | 考虑 Null 为空字符串 | String | -| `LastEditorUserId` | 是 | -1, 9999993 | 1104694 | 是 | 0 是未使用值,可以用于 Nulls | Int32 | -| `LastEditorDisplayName` | 否 | - | 70952 | 是 | 考虑 Null 为一个空字符串。测试 LowCardinality 无Benefit | String | -| `LastEditDate` | 否 | 2008-08-01 13:24:35.051000000, 2024-04-06 21:01:22.697000000 | - | 否 | 不需要毫秒粒度,使用 DateTime | DateTime | -| `LastActivityDate` | 否 | 2008-08-01 12:19:17.417000000, 2024-04-06 21:01:22.697000000 | - | 否 | 不需要毫秒粒度,使用 DateTime | DateTime | -| `Title` | 否 | - | - | 否 | 考虑 Null 为一个空字符串 | String | -| `Tags` | 否 | - | - | 否 | 考虑 Null 为一个空字符串 | String | -| `AnswerCount` | 是 | 0, 518 | 216 | 否 | 考虑 Null 和 0 相同 | UInt16 | -| `CommentCount` | 是 | 0, 135 | 100 | 否 | 考虑 Null 和 0 相同 | UInt8 | -| `FavoriteCount` | 是 | 0, 225 | 6 | 是 | 考虑 Null 和 0 相同 | UInt8 | -| `ContentLicense` | 否 | - | 3 | 否 | LowCardinality 性能优于 FixedString | LowCardinality(String) | -| `ParentId` | 否 | - | 20696028 | 是 | 考虑 Null 为一个空字符串 | String | -| `CommunityOwnedDate` | 否 | 2008-08-12 04:59:35.017000000, 2024-04-01 05:36:41.380000000 | - | 是 | 考虑默认 1970-01-01 对于 Nulls。毫秒粒度不需要,使用 DateTime | DateTime | -| `ClosedDate` | 否 | 2008-09-04 20:56:44, 2024-04-06 18:49:25.393000000 | - | 是 | 考虑默认 1970-01-01 对于 Nulls。毫秒粒度不需要,使用 DateTime | DateTime | +通过应用我们早期的简单规则到我们的 posts 表中,我们可以为每一列确定最佳类型: + +| 列 | 是否数字 | 最小值, 最大值 | 唯一值 | Nulls | 注释 | 优化类型 | +|---------------------|----------|-----------------------------------------------------------------------|----------|-------|-------------------------------------------------------------------------------------------|------------------------------------| +| `PostTypeId` | 是 | 1, 8 | 8 | 否 | | `Enum('Question' = 1, 'Answer' = 2, 'Wiki' = 3, 'TagWikiExcerpt' = 4, 'TagWiki' = 5, 'ModeratorNomination' = 6, 'WikiPlaceholder' = 7, 'PrivilegeWiki' = 8)` | +| `AcceptedAnswerId` | 是 | 0, 78285170 | 12282094 | 是 | 用 0 值区分 Null | UInt32 | +| `CreationDate` | 否 | 2008-07-31 21:42:52.667000000, 2024-03-31 23:59:17.697000000 | - | 否 | 不需要毫秒粒度,使用 DateTime | DateTime | +| `Score` | 是 | -217, 34970 | 3236 | 否 | | Int32 | +| `ViewCount` | 是 | 2, 13962748 | 170867 | 否 | | UInt32 | +| `Body` | 否 | - | - | 否 | | String | +| `OwnerUserId` | 是 | -1, 4056915 | 6256237 | 是 | | Int32 | +| `OwnerDisplayName` | 否 | - | 181251 | 是 | 认为 Null 为空字符串 | String | +| `LastEditorUserId` | 是 | -1, 9999993 | 1104694 | 是 | 0 是未使用的值,可以用作 Nulls | Int32 | +| `LastEditorDisplayName` | 否 | - | 70952 | 是 | 认为 Null 为一个空字符串。测试 LowCardinality 没有收益 | String | +| `LastEditDate` | 否 | 2008-08-01 13:24:35.051000000, 2024-04-06 21:01:22.697000000 | - | 否 | 不需要毫秒粒度,使用 DateTime | DateTime | +| `LastActivityDate` | 否 | 2008-08-01 12:19:17.417000000, 2024-04-06 21:01:22.697000000 | - | 否 | 不需要毫秒粒度,使用 DateTime | DateTime | +| `Title` | 否 | - | - | 否 | 认为 Null 为一个空字符串 | String | +| `Tags` | 否 | - | - | 否 | 认为 Null 为一个空字符串 | String | +| `AnswerCount` | 是 | 0, 518 | 216 | 否 | 认为 Null 和 0 为同一 | UInt16 | +| `CommentCount` | 是 | 0, 135 | 100 | 否 | 认为 Null 和 0 为同一 | UInt8 | +| `FavoriteCount` | 是 | 0, 225 | 6 | 是 | 认为 Null 和 0 为同一 | UInt8 | +| `ContentLicense` | 否 | - | 3 | 否 | LowCardinality 性能优于 FixedString | LowCardinality(String) | +| `ParentId` | 否 | - | 20696028 | 是 | 认为 Null 为一个空字符串 | String | +| `CommunityOwnedDate`| 否 | 2008-08-12 04:59:35.017000000, 2024-04-01 05:36:41.380000000 | - | 是 | 考虑将 Null 的默认值设置为 1970-01-01。不需要毫秒粒度,使用 DateTime | DateTime | +| `ClosedDate` | 否 | 2008-09-04 20:56:44, 2024-04-06 18:49:25.393000000 | - | 是 | 考虑将 Null 的默认值设置为 1970-01-01。不需要毫秒粒度,使用 DateTime | DateTime | :::note tip -为列识别类型依赖于理解其数值范围和唯一值数量。要找到所有列的范围和不同值的数量,用户可以使用简单的查询 `SELECT * APPLY min, * APPLY max, * APPLY uniq FROM table FORMAT Vertical`。我们建议在数据的较小子集上执行此操作,因为这可能会很昂贵。 +为列识别类型依赖于理解其数值范围和唯一值数量。要查找所有列的范围和不同值的数量,用户可以使用简单查询 `SELECT * APPLY min, * APPLY max, * APPLY uniq FROM table FORMAT Vertical`。我们建议在较小的数据子集上执行此操作,因为这可能会很昂贵。 ::: -这将产生以下优化后的模式(有关类型): +这导致以下优化后的模式(就类型而言): ```sql CREATE TABLE posts @@ -135,6 +136,6 @@ ENGINE = MergeTree ORDER BY tuple() ``` -## 避免 Nullable 列 {#avoid-nullable-columns} +## 避免可空列 {#avoid-nullable-columns} diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/select_data_type.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/select_data_type.md.hash index d1c44e66e6c..5147d52fdcc 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/select_data_type.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/select_data_type.md.hash @@ -1 +1 @@ -e4b40aba99d4585d +47429107d9356c57 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/selecting_an_insert_strategy.md b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/selecting_an_insert_strategy.md index 3502a56db71..1a0f57c2d1f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/selecting_an_insert_strategy.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/selecting_an_insert_strategy.md @@ -10,6 +10,7 @@ - 'compression' - 'batch inserts' 'show_related_blogs': true +'doc_type': 'guide' --- import Image from '@theme/IdealImage'; @@ -18,18 +19,18 @@ import async_inserts from '@site/static/images/bestpractices/async_inserts.png'; import AsyncInserts from '@site/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/_snippets/_async_inserts.md'; import BulkInserts from '@site/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/_snippets/_bulk_inserts.md'; -高效的数据摄取构成了高性能 ClickHouse 部署的基础。选择正确的插入策略可以显著影响吞吐量、成本和可靠性。本节概述了最佳实践、权衡和配置选项,以帮助您为工作负载做出正确的决策。 +高效的数据摄取是高性能 ClickHouse 部署的基础。选择正确的插入策略可以显著影响吞吐量、成本和可靠性。本节概述了最佳实践、权衡和配置选项,以帮助您为工作负载做出正确的决策。 :::note -以下假设您通过客户端将数据推送到 ClickHouse。如果您是通过内置表函数(如 [s3](/sql-reference/table-functions/s3) 和 [gcs](/sql-reference/table-functions/gcs))将数据拉入 ClickHouse,我们推荐您查看我们的指南 ["优化 S3 插入和读取性能"](/integrations/s3/performance)。 +以下内容假设您是通过客户端将数据推送到 ClickHouse。如果您是通过例如使用内置表函数 [s3](/sql-reference/table-functions/s3) 和 [gcs](/sql-reference/table-functions/gcs) 将数据拉入 ClickHouse,我们建议您查看我们的指南 [“优化 S3 插入和读取性能”](/integrations/s3/performance)。 ::: ## 默认的同步插入 {#synchronous-inserts-by-default} -默认情况下,对 ClickHouse 的插入是同步的。每个插入查询会立即在磁盘上创建一个存储部分,包括元数据和索引。 +默认情况下,插入到 ClickHouse 是同步的。每个插入查询立即在磁盘上创建一个存储部分,包括元数据和索引。 -:::note 如果可以在客户端进行批处理,请使用同步插入 -如果不能,请参见下面的 [异步插入](#asynchronous-inserts)。 +:::note 如果可以在客户端对数据进行批处理,请使用同步插入 +如果不能,请查看下面的 [异步插入](#asynchronous-inserts)。 ::: 我们简要回顾 ClickHouse 的 MergeTree 插入机制: @@ -38,115 +39,115 @@ import BulkInserts from '@site/i18n/zh/docusaurus-plugin-content-docs/current/be #### 客户端步骤 {#client-side-steps} -为了实现最佳性能,数据必须 ① [批处理](https://clickhouse.com/blog/asynchronous-data-inserts-in-clickhouse#data-needs-to-be-batched-for-optimal-performance),批量大小是 **第一个决定**。 +为了获得最佳性能,数据必须 ①[批处理](https://clickhouse.com/blog/asynchronous-data-inserts-in-clickhouse#data-needs-to-be-batched-for-optimal-performance),使批处理大小成为 **第一项决定**。 -ClickHouse 会根据表的主键列按[顺序](/guides/best-practices/sparse-primary-indexes#data-is-stored-on-disk-ordered-by-primary-key-columns) 存储插入的数据。 **第二个决定** 是在传输到服务器之前是否 ② 对数据进行预排序。如果批量数据按主键列预排序到达,ClickHouse 可以 [跳过](https://github.com/ClickHouse/ClickHouse/blob/94ce8e95404e991521a5608cd9d636ff7269743d/src/Storages/MergeTree/MergeTreeDataWriter.cpp#L595) ⑨ 排序步骤,从而加快摄取速度。 +ClickHouse 按照表的主键列(列)在磁盘上存储插入的数据,[有序](/guides/best-practices/sparse-primary-indexes#data-is-stored-on-disk-ordered-by-primary-key-columns)。**第二项决策**是是否在传输到服务器之前 ②对数据进行预排序。如果一个批次按照主键列预排序到达,ClickHouse 可以[跳过](https://github.com/ClickHouse/ClickHouse/blob/94ce8e95404e991521a5608cd9d636ff7269743d/src/Storages/MergeTree/MergeTreeDataWriter.cpp#L595) ⑨ 排序步骤,从而加快摄取速度。 -如果要摄取的数据没有预定义格式, **关键决策** 是选择格式。ClickHouse 支持以 [70 多种格式](https://interfaces/formats) 插入数据。然而,当使用 ClickHouse 命令行客户端或编程语言客户端时,通常会自动处理此选择。如有需要,此自动选择也可以显式覆盖。 +如果要摄取的数据没有预定义格式,**关键决策**是选择一种格式。ClickHouse 支持以 [超过 70 种格式](/interfaces/formats) 插入数据。但是,当使用 ClickHouse 命令行客户端或编程语言客户端时,这个选择通常是自动处理的。如果需要,也可以显式覆盖该自动选择。 -下一个 **主要决策** 是 ④ 是否在传输到 ClickHouse 服务器之前压缩数据。压缩可以减少传输大小并提高网络效率,从而加快数据传输并降低带宽使用,尤其是对于大型数据集。 +下一个 **主要决定**是 ④ 是否在传输到 ClickHouse 服务器之前压缩数据。压缩可以减少传输大小,提高网络效率,从而加快数据传输速度并降低带宽使用,尤其是对于大数据集。 -数据会 ⑤ 传输到 ClickHouse 网络接口——可以是 [native](/interfaces/tcp) 或 [HTTP](/interfaces/http) 接口(稍后我们将对此进行[比较](https://clickhouse.com/blog/clickhouse-input-format-matchup-which-is-fastest-most-efficient#clickhouse-client-defaults))。 +数据 ⑤ 被传输到 ClickHouse 网络接口——可以是 [本机](/interfaces/tcp) 或 [HTTP](/interfaces/http) 接口(我们会在本文后面对此进行 [比较](https://clickhouse.com/blog/clickhouse-input-format-matchup-which-is-fastest-most-efficient#clickhouse-client-defaults))。 -#### 服务器步骤 {#server-side-steps} +#### 服务器端步骤 {#server-side-steps} -在 ⑥ 接收数据后,如果使用了压缩,ClickHouse 会 ⑦ 解压缩数据,然后 ⑧ 从原始发送格式解析数据。 +在 ⑥ 接收到数据后,如果使用了压缩,ClickHouse 将 ⑦ 解压缩数据,然后 ⑧ 从最初发送的格式中解析数据。 -使用该格式化数据的值和目标表的 [DDL](/sql-reference/statements/create/table) 语句,ClickHouse ⑨ 构建一个内存中的 [块](/development/architecture#block),以 MergeTree 格式 ⑩ [按主键列排序](/parts#what-are-table-parts-in-clickhouse),如果它们尚未预排序,⑪ 创建一个 [稀疏主索引](/guides/best-practices/sparse-primary-indexes),⑫ 应用 [按列压缩](/parts#what-are-table-parts-in-clickhouse),并将数据 ⑬ 作为新的 ⑭ [数据部分](/parts) 写入磁盘。 +利用格式化数据的值和目标表的 [DDL](/sql-reference/statements/create/table) 语句,ClickHouse ⑨ 在内存中构建以 MergeTree 格式的 [块](/development/architecture#block),如果行尚未预排序,则 ⑩ [按主键列排序](/parts#what-are-table-parts-in-clickhouse),⑪ 创建 [稀疏主索引](/guides/best-practices/sparse-primary-indexes),⑫ 应用 [每列压缩](/parts#what-are-table-parts-in-clickhouse),并 ⑬ 将数据作为新的 ⑭ [数据部分](/parts) 写入磁盘。 -### 如果是同步插入则采用批量插入 {#batch-inserts-if-synchronous} +### 如果同步则批量插入 {#batch-inserts-if-synchronous} ### 确保幂等重试 {#ensure-idempotent-retries} -同步插入也是 **幂等的**。在使用 MergeTree 引擎时,ClickHouse 默认会去重插入。这可以防止模糊的失败情况,例如: +同步插入也是 **幂等的**。使用 MergeTree 引擎时,ClickHouse 默认会去重插入。这能保护您免受歧义失败情况的影响,例如: -* 插入成功但由于网络中断客户端从未收到确认。 +* 插入成功,但客户端因网络中断而未收到确认。 * 插入在服务器端失败并超时。 -在这两种情况下,安全地 **重试插入** 是可以的——只要批量内容和顺序保持不变。因此,客户端的一致重试至关重要,不能修改或重新排序数据。 +在这两种情况下,安全的 **重试插入** 是安全的——只要批处理的内容和顺序保持不变。因此,客户端的一致重试至关重要,不能修改或重新排序数据。 ### 选择正确的插入目标 {#choose-the-right-insert-target} -对于分片集群,您有两种选择: +对于分片集群,您有两个选择: -* 直接插入到 **MergeTree** 或 **ReplicatedMergeTree** 表中。这是最有效的选项,当客户端可以在分片之间进行负载均衡时。启用 `internal_replication = true` 后,ClickHouse 透明地处理复制。 -* 插入到 [分布式表](/engines/table-engines/special/distributed) 中。这允许客户端将数据发送到任何节点,并让 ClickHouse 转发到正确的分片。这比较简单,但由于额外的转发步骤,性能略差。仍然建议启用 `internal_replication = true`。 +* 直接插入到 **MergeTree** 或 **ReplicatedMergeTree** 表中。当客户端可以在分片之间执行负载均衡时,这是最有效的选项。在 `internal_replication = true` 的情况下,ClickHouse 透明地处理复制。 +* 插入到 [分布式表](/engines/table-engines/special/distributed)。这允许客户端将数据发送到任何节点,并让 ClickHouse 将其转发到正确的分片。这更简单,但由于额外的转发步骤,性能略低。仍然建议使用 `internal_replication = true`。 -**在 ClickHouse Cloud 中,所有节点都对同一个分片进行读写。插入会自动在节点之间进行平衡。用户只需将插入发送到暴露的端点。** +**在 ClickHouse Cloud 中,所有节点都读取和写入同一个分片。插入会自动在节点之间平衡。用户只需将插入发送到公开终端即可。** ### 选择正确的格式 {#choose-the-right-format} -选择正确的输入格式对于 ClickHouse 中高效的数据摄取至关重要。支持70多种格式时,选择最有效的选项可以显著影响插入速度、CPU 和内存使用率以及整体系统效率。 +选择正确的输入格式对于 ClickHouse 的高效数据摄取至关重要。支持超过 70 种格式时,选择性能最好的选项可以显著影响插入速度、CPU 和内存使用,以及整个系统的效率。 -虽然灵活性对数据工程和基于文件的导入是有用的,**应用程序应优先考虑以性能为导向的格式**: +虽然灵活性对数据工程和基于文件的导入很有用,但 **应用应该优先考虑面向性能的格式**: -* **Native 格式**(推荐):最高效。列式,服务器端需要最小解析。Go 和 Python 客户端默认使用。 -* **RowBinary**:高效的行格式,理想情况下在客户端难以进行列式转换。用于 Java 客户端。 -* **JSONEachRow**:易于使用但解析成本高。适合于低数据量的用例或快速集成。 +* **本机格式**(推荐):效率最高。列式,服务器端所需的解析最小。在 Go 和 Python 客户端中默认使用。 +* **RowBinary**:高效的行式格式,适合在客户端进行列式转换困难时使用。在 Java 客户端中使用。 +* **JSONEachRow**:使用简单但解析开销较大。适用于低容量用例或快速集成。 ### 使用压缩 {#use-compression} -压缩在减少网络开销、加快插入速度和降低 ClickHouse 存储成本方面起着关键作用。有效使用时,它增强了摄取性能,而无需更改数据格式或架构。 +压缩在减少网络开销、加快插入速度和降低 ClickHouse 的存储成本中发挥着关键作用。有效使用它可以提升摄取性能,而无需更改数据格式或架构。 -压缩插入数据会减少通过网络发送的有效负载大小,最小化带宽使用并加速传输。 +压缩插入数据可以减小通过网络发送的负载大小,最小化带宽使用,加快传输速度。 -对于插入,压缩在与 Native 格式一起使用时尤其有效,后者已经与 ClickHouse 的内部列式存储模型匹配。在这种设置中,服务器可以高效解压缩并直接存储数据,几乎无需转化。 +对于插入操作,当与本机格式一起使用时,压缩尤其有效,因为这种格式已经与 ClickHouse 的内部列式存储模型匹配。在这种设置中,服务器可以有效地解压缩并直接存储数据,而无需进行大量转化。 -#### 在速度上使用 LZ4,在压缩率上使用 ZSTD {#use-lz4-for-speed-zstd-for-compression-ratio} +#### 使用 LZ4 提升速度,使用 ZSTD 提升压缩比 {#use-lz4-for-speed-zstd-for-compression-ratio} -ClickHouse 在数据传输过程中支持多种压缩编解码器。两个常见的选项是: +ClickHouse 在数据传输期间支持几种压缩编解码器。其中两个常见选项是: -* **LZ4**:快速且轻量。它显著减少数据大小,同时 CPU 开销最小,非常适合高吞吐量插入,是大多数 ClickHouse 客户端的默认选项。 -* **ZSTD**:更高的压缩比,但 CPU 消耗更多。在网络传输成本较高时(例如在跨区域或云提供商场景中)很有用,尽管它会稍微增加客户端计算和服务器端解压缩时间。 +* **LZ4**:快速且轻量。它在 CPU 开销最小的情况下显著降低数据大小,适合高吞吐量的插入,是大多数 ClickHouse 客户端中的默认选项。 +* **ZSTD**:更高的压缩比但 CPU 开销更多。当网络传输成本较高(例如跨区域或云提供商场景)时非常有用,尽管它略微增加客户端计算和服务器端解压缩时间。 -最佳实践:使用 LZ4,除非带宽受限或产生数据外发费用——那时考虑使用 ZSTD。 +最佳实践:使用 LZ4,除非您有带宽限制或产生数据出站成本 - 然后考虑 ZSTD。 :::note -在 [FastFormats 基准](https://clickhouse.com/blog/clickhouse-input-format-matchup-which-is-fastest-most-efficient) 的测试中,LZ4 压缩的 Native 插入将数据大小减少了超过 50%,将 5.6 GiB 数据集的摄取时间从 150 秒缩短至 131 秒。切换到 ZSTD 将相同数据集压缩至 1.69 GiB,但略微增加了服务器端处理时间。 +在 [FastFormats 基准](https://clickhouse.com/blog/clickhouse-input-format-matchup-which-is-fastest-most-efficient) 的测试中,LZ4 压缩的本机插入将数据大小减少了超过 50%,将 5.6 GiB 数据集的摄取时间从 150 秒减少到 131 秒。切换到 ZSTD 将同一数据集压缩到 1.69 GiB,但略微增加了服务器端处理时间。 ::: #### 压缩减少资源使用 {#compression-reduces-resource-usage} -压缩不仅减少了网络流量——它还提高了服务器的 CPU 和内存效率。通过压缩数据,ClickHouse 接收的字节更少,并花费更少的时间解析大量输入。在多个并发客户端(例如可观察性场景)摄取时,这种好处尤为重要。 +压缩不仅减少了网络流量,还提高了服务器的 CPU 和内存效率。通过压缩数据,ClickHouse 接收到更少的字节,并花费更少的时间解析大型输入。当从多个并发客户端摄取时,这一好处尤其重要,比如在可观测性场景中。 -对于 LZ4,压缩对 CPU 和内存的影响温和,而对于 ZSTD 的影响适中。即使在负载下,由于数据量减少,服务器端效率也会提高。 +对于 LZ4,压缩对 CPU 和内存的影响是适度的;对于 ZSTD,则是中等的。即使在负载下,由于减少了数据量,服务器端的效率也会提高。 -**将压缩与批处理和高效输入格式(如 Native)结合使用,能获得最佳的摄取性能。** +**将压缩与批处理和高效输入格式(如本机格式)结合使用可获得最佳摄取性能。** -当使用本机接口(例如 [clickhouse-client](/interfaces/cli))时,默认启用 LZ4 压缩。您可以通过设置选项切换到 ZSTD。 +在使用本机接口(例如 [clickhouse-client](/interfaces/cli))时,LZ4 压缩默认为启用状态。您可以通过设置选择切换到 ZSTD。 -在 [HTTP 接口](/interfaces/http) 中,使用 Content-Encoding 头应用压缩(例如 Content-Encoding: lz4)。整个有效负载必须在发送前进行压缩。 +对于 [HTTP 接口](/interfaces/http),使用 Content-Encoding 头来应用压缩(例如 Content-Encoding: lz4)。整个负载必须在发送之前完成压缩。 -### 如果低成本则进行预排序 {#pre-sort-if-low-cost} +### 如果低成本,则进行预排序 {#pre-sort-if-low-cost} -在插入之前按主键对数据进行预排序可以改善 ClickHouse 的摄取效率,特别是对于大批量数据。 +在插入之前按主键对数据进行预排序可以提高 ClickHouse 的摄取效率,特别是对于大批量数据。 -当数据预排序到达时,ClickHouse 可以在创建分区时跳过或简化内部排序步骤,从而减少 CPU 使用率并加快插入过程。预排序还提高了压缩效率,因为类似的值会聚集在一起——使得像 LZ4 或 ZSTD 这样的编码器能够实现更好的压缩比。在与大批量插入和压缩结合使用时,这种好处尤其明显,因为它减少了处理开销和传输的数据量。 +当数据以预排序方式到达时,ClickHouse 可以跳过或简化在创建部分期间的内部排序步骤,从而降低 CPU 使用并加快插入过程。预排序还提高了压缩效率,因为相似值会组合在一起 - 使得像 LZ4 或 ZSTD 这样的编解码器能够实现更好的压缩比。这在与大批量插入和压缩结合使用时尤为有益,因为它减少了处理开销和传输数据量。 -**也就是说,预排序是可选的优化——不是必需的。** ClickHouse 可以高效地使用并行处理对数据进行排序,在许多情况下,服务器端排序比客户端预排序的速度更快或更方便。 +**也就是说,预排序是一种可选的优化——不是强制要求。** ClickHouse 使用并行处理高效地对数据进行排序,在许多情况下,服务器端排序的速度可能更快或更方便,而不是在客户端进行预排序。 -**我们建议仅在数据几乎已排序或客户端资源(CPU、内存)充足且未充分利用时进行预排序。** 在延迟敏感或高吞吐量的用例中,例如可观察性,在数据无序到达或来自许多代理的情况下,通常最好跳过预排序,依赖 ClickHouse 的内置性能。 +**我们建议仅在数据已经几乎有序或客户端资源(CPU、内存)充分且未被利用时进行预排序。** 在那些对延迟敏感或高吞吐量的用例中,例如可观测性,数据随着顺序或来自许多代理到达,通常最好跳过预排序,依赖 ClickHouse 的内置性能。 ## 异步插入 {#asynchronous-inserts} -## 选择一个接口 - HTTP 或 Native {#choose-an-interface} +## 选择接口 - HTTP 或本机 {#choose-an-interface} -### Native {#choose-an-interface-native} +### 本机 {#choose-an-interface-native} -ClickHouse 提供了两种主要的数据摄取接口:**native 接口**和 **HTTP 接口**,两者在性能和灵活性之间存在权衡。native 接口由 [clickhouse-client](/interfaces/cli) 和选定语言的客户端(如 Go 和 C++)使用,专为性能而构建。它始终以 ClickHouse 高效的 Native 格式传输数据,支持使用 LZ4 或 ZSTD 进行块级压缩,并通过将解析和格式转换等工作卸载到客户端来最小化服务器端处理。 +ClickHouse 提供两种主要的数据摄取接口:**本机接口**和**HTTP 接口** - 每种接口在性能和灵活性之间都有取舍。本机接口用于 [clickhouse-client](/interfaces/cli) 和一些语言客户端(如 Go 和 C++),是为性能量身定制的。它始终以 ClickHouse 高效的本机格式传输数据,支持以 LZ4 或 ZSTD 进行块级压缩,并通过将解析和格式转换等工作委派给客户端来最小化服务器端的处理。 -它甚至使得可以在客户端计算 MATERIALIZED 和 DEFAULT 列的值,从而使服务器能够完全跳过这些步骤。这使得 native 接口非常适合高吞吐量的插入场景,其中效率至关重要。 +它甚至允许在客户端计算 MATERIALIZED 和 DEFAULT 列的值,使服务器能够完全跳过这些步骤。这使得本机接口非常适合对效率要求极高的高吞吐量摄取场景。 ### HTTP {#choose-an-interface-http} -与许多传统数据库不同,ClickHouse 还支持 HTTP 接口。**这相比之下,优先考虑兼容性和灵活性。** 它允许数据以 [任意支持的格式](/integrations/data-formats) 发送——包括 JSON、CSV、Parquet 等,并在大多数 ClickHouse 客户端中广泛支持,包括 Python、Java、JavaScript 和 Rust。 +与许多传统数据库不同,ClickHouse 还支持 HTTP 接口。**相反,它优先考虑兼容性和灵活性。** 它允许以 [任何支持的格式](/integrations/data-formats) 发送数据——包括 JSON、CSV、Parquet 等,并在大多数 ClickHouse 客户端(包括 Python、Java、JavaScript 和 Rust)中广泛支持。 -这通常比 ClickHouse 的 native 协议更可取,因为它允许与负载均衡器轻松切换流量。我们预计使用 native 协议时,插入性能会有小差异,后者的开销更低。 +这通常比 ClickHouse 的本机协议更可取,因为它允许通过负载均衡器轻松切换流量。我们预计使用本机协议时的插入性能会有小幅差异,其开销较小。 -然而,它缺乏 native 协议的深度集成,并且无法执行客户端优化,如计算物化值或自动转换为 Native 格式。虽然 HTTP 插入仍然可以使用标准 HTTP 头进行压缩(例如 `Content-Encoding: lz4`),但压缩应用于整个有效负载,而不是单个数据块。该接口通常在协议简单性、负载均衡或广泛格式兼容性比原始性能更重要的环境中受到青睐。 +但是,它缺乏本机协议的更深层次集成,无法进行客户端优化,如计算物化值或自动转换为本机格式。虽然 HTTP 插入仍然可以使用标准 HTTP 头压缩(例如 `Content-Encoding: lz4`),但压缩是应用于整个负载,而不是单独数据块。这种接口通常在协议简化、负载均衡或广泛格式兼容性比原始性能更重要的环境中更受欢迎。 -有关这些接口的更详细描述,请参见 [此处](/interfaces/overview)。 +有关这些接口的更详细描述,请见 [这里](/interfaces/overview)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/selecting_an_insert_strategy.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/selecting_an_insert_strategy.md.hash index e0d32071d00..86de49f48ee 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/selecting_an_insert_strategy.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/selecting_an_insert_strategy.md.hash @@ -1 +1 @@ -30369c9bf541880a +4fff1d2730133d95 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/sizing-and-hardware-recommendations.md b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/sizing-and-hardware-recommendations.md index 1636af1c481..df91d2467a0 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/sizing-and-hardware-recommendations.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/sizing-and-hardware-recommendations.md @@ -1,17 +1,18 @@ --- 'slug': '/guides/sizing-and-hardware-recommendations' -'sidebar_label': '硬件和尺寸推荐' +'sidebar_label': '大小和硬件推荐' 'sidebar_position': 4 -'title': '硬件和尺寸推荐' -'description': '本指南讨论了我们关于硬件、计算、内存和磁盘配置的一般建议,适用于开源用户。' +'title': '大小和硬件推荐' +'description': '本指南讨论了我们关于硬件、计算、内存和磁盘配置的普遍建议,适用于开源用户。' +'doc_type': 'guide' --- -# 硬件和配置建议 +# 尺寸和硬件建议 -本指南讨论了我们针对开源用户在硬件、计算、内存和磁盘配置方面的一般建议。如果您希望简化设置,我们建议使用 [ClickHouse Cloud](https://clickhouse.com/cloud),因为它可以自动扩展和适应您的工作负载,同时最大程度地降低与基础设施管理相关的成本。 +本指南讨论了我们关于开源用户的硬件、计算、内存和磁盘配置的总体建议。如果您想简化您的设置,我们推荐使用 [ClickHouse Cloud](https://clickhouse.com/cloud),因为它会自动缩放并适应您的工作负载,同时降低与基础设施管理相关的成本。 -您的 ClickHouse 集群配置高度依赖于您应用程序的用例和工作负载模式。在规划架构时,您必须考虑以下因素: +您的 ClickHouse 集群的配置高度依赖于您应用程序的用例和工作负载模式。在规划您的架构时,您必须考虑以下因素: - 并发性(每秒请求数) - 吞吐量(每秒处理的行数) @@ -22,84 +23,84 @@ ## 磁盘 {#disk} -您应该使用的磁盘类型取决于数据量、延迟或吞吐量的要求。 +您应与 ClickHouse 一起使用的磁盘类型取决于数据量、延迟或吞吐量要求。 ### 性能优化 {#optimizing-for-performance} -为了最大化性能,我们建议直接连接 [AWS 的预配置 IOPS SSD 卷](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/provisioned-iops.html) 或您云服务提供商的等效产品,以优化 IO。 +为了最大化性能,我们建议直接连接 [AWS 提供的预置 IOPS SSD 卷](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/provisioned-iops.html) 或您云提供商的等效产品,以优化 IO。 -### 存储成本优化 {#optimizing-for-storage-costs} +### 降低存储成本 {#optimizing-for-storage-costs} 为了降低成本,您可以使用 [通用 SSD EBS 卷](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/general-purpose.html)。 -您还可以在 [热/温/冷架构](/guides/developer/ttl#implementing-a-hotwarmcold-architecture) 中使用 SSD 和 HDD 实施分层存储。或者,使用 [AWS S3](https://aws.amazon.com/s3/) 进行存储也可以分离计算和存储。请查看我们的指南,了解如何将开源 ClickHouse 与计算和存储分离一起使用 [这里](/guides/separation-storage-compute)。在 ClickHouse Cloud 中,计算和存储的分离是默认可用的。 +您还可以在 [热/温/冷架构](/guides/developer/ttl#implementing-a-hotwarmcold-architecture) 中使用 SSD 和 HDD 实现分层存储。或者,也可以使用 [AWS S3](https://aws.amazon.com/s3/) 来分离计算和存储。请参阅我们的指南 [使用开源 ClickHouse 实现计算与存储的分离]( /guides/separation-storage-compute)。在 ClickHouse Cloud 中,计算与存储的分离是默认可用的。 ## CPU {#cpu} -### 我应该使用哪种 CPU? {#which-cpu-should-i-use} +### 我应使用哪种 CPU? {#which-cpu-should-i-use} -您应该使用的 CPU 类型取决于您的使用模式。然而,通常来说,具有许多频繁并发查询、处理更多数据,或使用计算密集型 UDF 的应用程序将需要更多的 CPU 核心。 +您应使用的 CPU 类型取决于您的使用模式。然而,通常情况下,具有许多频繁并发查询、处理更多数据或使用计算密集型 UDF 的应用程序将需要更多的 CPU 核心。 **低延迟或面向客户的应用程序** -对于如面向客户的工作负载在 10 毫秒范围内的延迟要求,我们建议使用 AWS 的 EC2 [i3 系列](https://aws.amazon.com/ec2/instance-types/i3/) 或 [i4i 系列](https://aws.amazon.com/ec2/instance-types/i4i/) 或您云服务提供商的等效产品,这些都是 IO 优化的。 +对于要求在几十毫秒的延迟,如面向客户的工作负载,我们建议使用 AWS 的 EC2 [i3 系列](https://aws.amazon.com/ec2/instance-types/i3/) 或 [i4i 系列](https://aws.amazon.com/ec2/instance-types/i4i/) 或您云提供商的相应产品,这些产品经过 IO 优化。 **高并发应用程序** -对于需要优化并发的工作负载(每秒 100+ 查询),我们建议使用 AWS 的 [计算优化 C 系列](https://aws.amazon.com/ec2/instance-types/#Compute_Optimized) 或您云服务提供商的等效产品。 +对于需要优化并发性(每秒 100 次以上查询)的工作负载,我们建议使用 AWS 的 [计算优化 C 系列](https://aws.amazon.com/ec2/instance-types/#Compute_Optimized) 或您云提供商的相应产品。 -**数据仓库使用案例** +**数据仓库用例** -对于数据仓库工作负载和临时分析查询,我们建议使用 AWS 的 [R 型系列](https://aws.amazon.com/ec2/instance-types/#Memory_Optimized) 或您云服务提供商的等效产品,因为它们是内存优化的。 +对于数据仓库工作负载和临时分析查询,我们建议使用 AWS 的 [R 类型系列](https://aws.amazon.com/ec2/instance-types/#Memory_Optimized) 或您云提供商的相应产品,因为它们是内存优化的。 --- -### CPU 使用率应该是多少? {#what-should-cpu-utilization-be} +### CPU 利用率应该是多少? {#what-should-cpu-utilization-be} -ClickHouse 没有标准的 CPU 使用率目标。使用 [iostat](https://linux.die.net/man/1/iostat) 等工具来测量平均 CPU 使用率,并 accordingly 调整服务器的大小以管理意外的流量高峰。然而,对于分析或数据仓库用例的临时查询,您应该将目标定在 10-20% 的 CPU 使用率。 +ClickHouse 没有标准的 CPU 利用率目标。使用工具如 [iostat](https://linux.die.net/man/1/iostat) 来测量平均 CPU 使用率,并根据需要调整服务器的大小以应对意外的流量激增。然而,对于具有临时查询的分析或数据仓库用例,您应目标设定在 10-20% 的 CPU 利用率。 -### 我应该使用多少个 CPU 核心? {#how-many-cpu-cores-should-i-use} +### 我应该使用多少 CPU 核心? {#how-many-cpu-cores-should-i-use} -您应该使用的 CPU 数量取决于您的工作负载。不过,通常我们建议根据您的 CPU 类型使用以下内存与 CPU 核心的比率: +您应使用的 CPU 数量取决于您的工作负载。然而,我们通常根据 CPU 类型建议以下内存与 CPU 核心的比率: -- **[M型](https://aws.amazon.com/ec2/instance-types/)(通用用例):** 4:1 内存与 CPU 核心比率 -- **[R型](https://aws.amazon.com/ec2/instance-types/#Memory_Optimized)(数据仓库用例):** 8:1 内存与 CPU 核心比率 -- **[C型](https://aws.amazon.com/ec2/instance-types/#Compute_Optimized)(计算优化用例):** 2:1 内存与 CPU 核心比率 +- **[M 类型](https://aws.amazon.com/ec2/instance-types/)(通用用途):** 4:1 内存与 CPU 核心比率 +- **[R 类型](https://aws.amazon.com/ec2/instance-types/#Memory_Optimized)(数据仓库用例):** 8:1 内存与 CPU 核心比率 +- **[C 类型](https://aws.amazon.com/ec2/instance-types/#Compute_Optimized)(计算优化用例):** 2:1 内存与 CPU 核心比率 -例如,当使用 M 型 CPU 时,我们建议每 25 个 CPU 核心配置 100GB 的内存。要确定适合您应用程序的内存量,需分析您的内存使用情况。您可以阅读 [此指南以调试内存问题](/guides/developer/debugging-memory-issues) 或使用 [内置可观察性仪表板](/operations/monitoring) 来监控 ClickHouse。 +例如,使用 M 型 CPU 时,我们建议每 25 个 CPU 核心配置 100GB 内存。要确定适合您应用程序的内存量,需要对您的内存使用情况进行分析。您可以阅读 [关于调试内存问题的指南](/guides/developer/debugging-memory-issues) 或使用 [内置的可观察性仪表盘](/operations/monitoring) 来监控 ClickHouse。 ## 内存 {#memory} -与 CPU 的选择一样,您选择的内存与存储比率和内存与 CPU 比率也取决于您的用例。 +与您的 CPU 选择一样,存储比、内存与 CPU 比率的选择取决于您的用例。 -所需的 RAM 总量通常取决于: +所需的 RAM 量通常取决于: - 查询的复杂性。 - 在查询中处理的数据量。 -不过,通常而言,内存越多,查询运行得越快。 -如果您的用例对价格敏感,较少的内存也可以使用,因为可以启用设置([`max_bytes_before_external_group_by`](/operations/settings/settings#max_bytes_before_external_group_by) 和 [`max_bytes_before_external_sort`](/operations/settings/settings#max_bytes_before_external_sort))以允许将数据溢出到磁盘,但请注意,这可能显著影响查询性能。 +然而,通常情况下,内存越多,查询运行的速度会越快。 +如果您的用例对价格敏感,较低的内存量也可以使用,因为可以启用设置 ([`max_bytes_before_external_group_by`](/operations/settings/settings#max_bytes_before_external_group_by) 和 [`max_bytes_before_external_sort`](/operations/settings/settings#max_bytes_before_external_sort)) 允许将数据溢出到磁盘,但请注意这可能会大幅影响查询性能。 -### 内存与存储比率应该是多少? {#what-should-the-memory-to-storage-ratio-be} +### 内存与存储的比率应该是多少? {#what-should-the-memory-to-storage-ratio-be} -对于低数据量,可以接受 1:1 的内存与存储比率,但总内存不应低于 8GB。 +对于低数据量,1:1 的内存与存储比率是可以接受的,但总内存不应低于 8GB。 -对于具有长数据保留期或高数据量的用例,我们建议使用 1:100 至 1:130 的内存与存储比率。例如,如果您存储 10TB 的数据,则每个副本应分配 100GB 的 RAM。 +对于长期保留数据或高数据量的用例,我们建议内存与存储比率为 1:100 到 1:130。例如,如果您存储 10TB 的数据,则每个副本需要 100GB 的 RAM。 -对于如面向客户的工作负载等频繁访问的用例,我们建议使用更多内存,以 1:30 至 1:50 的内存与存储比率。 +对于频繁访问的用例,如面向客户的工作负载,我们建议使用更多内存,内存与存储比率为 1:30 到 1:50。 ## 副本 {#replicas} -我们建议每个分片至少有三个副本(或两个副本与 [Amazon EBS](https://aws.amazon.com/ebs/))。此外,我们建议在添加额外副本之前,先对所有副本进行垂直扩展(水平扩展)。 +我们建议每个分片至少有三个副本(或者与 [Amazon EBS](https://aws.amazon.com/ebs/) 一起使用两个副本)。此外,我们建议在添加额外副本(横向扩展)之前对所有副本进行垂直扩展。 -ClickHouse 不会自动分片,重新分片您的数据集将需要大量计算资源。因此,我们通常建议使用可用的最大服务器,以防止将来需要重新分片您的数据。 +ClickHouse 并不会自动进行分片,重新分片您的数据集将需要大量计算资源。因此,我们通常建议使用可用的最大服务器,以防将来需要重新分片数据。 -考虑使用 [ClickHouse Cloud](https://clickhouse.com/cloud),它可以自动扩展,并允许您轻松控制副本数量,以适应您的用例。 +考虑使用 [ClickHouse Cloud](https://clickhouse.com/cloud),它会自动扩展,并允许您轻松控制副本的数量以满足您的用例。 -## 大工作负载的示例配置 {#example-configurations-for-large-workloads} +## 大型工作负载的示例配置 {#example-configurations-for-large-workloads} -ClickHouse 的配置在很大程度上取决于您特定应用程序的要求。如果您希望我们帮助优化您的架构以降低成本和提高性能,请 [联系销售](https://clickhouse.com/company/contact?loc=docs-sizing-and-hardware-recommendations)。 +ClickHouse 配置高度依赖于您的特定应用程序需求。如果您希望我们帮助优化您的架构以降低成本和提高性能,请 [联系销售](https://clickhouse.com/company/contact?loc=docs-sizing-and-hardware-recommendations)。 -为了提供指导(非建议),以下是生产环境中 ClickHouse 用户的示例配置: +为了提供指导(而非建议),以下是一些在生产环境中使用 ClickHouse 用户的示例配置: ### 财富 500 强 B2B SaaS {#fortune-500-b2b-saas} @@ -112,11 +113,11 @@ ClickHouse 的配置在很大程度上取决于您特定应用程序的要求。
- + - + @@ -154,16 +155,16 @@ ClickHouse 的配置在很大程度上取决于您特定应用程序的要求。 - + - +
30TB
总存储(压缩)总存储(压缩后) 540TB
数据保留数据保留期 18 个月
256GB
RAM 与 vCPU 比率RAM 和 vCPU 比 4:1
RAM 与磁盘比率RAM 与磁盘比 1:50
-### 财富 500 强电信运营商的日志用例 {#fortune-500-telecom-operator-for-a-logging-use-case} +### 财富 500 强电信运营商的日志用例配置 {#fortune-500-telecom-operator-for-a-logging-use-case} @@ -174,11 +175,11 @@ ClickHouse 的配置在很大程度上取决于您特定应用程序的要求。 - + - + @@ -212,18 +213,18 @@ ClickHouse 的配置在很大程度上取决于您特定应用程序的要求。 - + - +
4860TB
总存储(压缩)总存储(压缩后) 608TB
数据保留数据保留期 30 天
256GB
RAM 与 vCPU 比率RAM 和 vCPU 比 6:1
RAM 与磁盘比率RAM 与磁盘比 1:60
-## 扩展阅读 {#further-reading} +## 深入阅读 {#further-reading} -以下是使用开源 ClickHouse 的公司发表的架构相关的博客文章: +以下是使用开源 ClickHouse 的公司在架构方面发表的博客文章: - [Cloudflare](https://blog.cloudflare.com/http-analytics-for-6m-requests-per-second-using-clickhouse/?utm_source=linkedin&utm_medium=social&utm_campaign=blog) - [eBay](https://innovation.ebayinc.com/tech/engineering/ou-online-analytical-processing/) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/sizing-and-hardware-recommendations.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/sizing-and-hardware-recommendations.md.hash index 05dd1f593e3..5fd1a1649a5 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/sizing-and-hardware-recommendations.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/sizing-and-hardware-recommendations.md.hash @@ -1 +1 @@ -31948f0993eea545 +cf74c49ab8a57ef3 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/use_materialized_views.md b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/use_materialized_views.md index 0b1663b58cf..7958f4057e2 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/use_materialized_views.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/use_materialized_views.md @@ -8,76 +8,77 @@ - 'materialized views' - 'medallion architecture' 'show_related_blogs': true +'doc_type': 'guide' --- import Image from '@theme/IdealImage'; import incremental_materialized_view from '@site/static/images/bestpractices/incremental_materialized_view.gif'; import refreshable_materialized_view from '@site/static/images/bestpractices/refreshable_materialized_view.gif'; -ClickHouse 支持两种类型的物化视图:[**增量**](/materialized-view/incremental-materialized-view) 和 [**刷新**](/materialized-view/refreshable-materialized-view)。虽然这两者都是通过预计算和存储结果来加速查询,但它们在底层查询的执行方式、何时执行、适合的工作负载以及数据新鲜度管理方面存在显著差异。 +ClickHouse 支持两种类型的物化视图:[**增量**](/materialized-view/incremental-materialized-view) 和 [**可刷新**](/materialized-view/refreshable-materialized-view)。虽然这两种视图都旨在通过预计算和存储结果来加速查询,但它们在执行底层查询的方式、适用的工作负载和数据新鲜度处理方面存在显著差异。 -**用户应该考虑针对特定的查询模式使用物化视图,这些模式需要加速,前提是已经执行了有关类型的最佳实践 [regarding type](/best-practices/select-data-types) 和 [主键优化](/best-practices/choosing-a-primary-key)。** +**用户应该考虑在特定的查询模式下使用物化视图,以加速查询,前提是已遵循之前的最佳实践 [关于数据类型](/best-practices/select-data-types) 和 [主键优化](/best-practices/choosing-a-primary-key)。** -**增量物化视图** 实时更新。当新数据插入到源表时,ClickHouse 会自动将物化视图的查询应用于新的数据块,并将结果写入到单独的目标表中。随着时间的推移,ClickHouse 将这些部分结果合并以生成一个完整的、最新的视图。这种方法非常高效,因为它将计算成本转移到插入时,仅处理新数据。因此,对目标表的 `SELECT` 查询执行快速且轻量。增量视图支持所有聚合函数,并且可以很好地扩展——甚至达到PB级别的数据——因为每个查询操作于正在插入的数据集的一个小而近期的子集上。 +**增量物化视图** 实时更新。当新的数据插入源表时,ClickHouse 会自动将物化视图的查询应用于新数据块,并将结果写入单独的目标表。随着时间的推移,ClickHouse 会合并这些部分结果,以生成完整的、最新的视图。这种方法非常高效,因为它将计算成本转移到插入时间,并且只处理新数据。因此,针对目标表的 `SELECT` 查询速度快且轻量。增量视图支持所有聚合函数,并且能够很好地扩展——甚至达到 PB 级别的数据——因为每个查询都在被插入的数据集的小而新的子集上运行。 物化视图 -**刷新物化视图**,相对而言,按计划更新。这些视图定期重新执行它们的完整查询,并在目标表中覆盖结果。这类似于传统 OLTP 数据库(如 Postgres)中的物化视图。 +**可刷新物化视图** 相反,按计划更新。这些视图定期重新执行完整查询,并覆盖目标表中的结果。这类似于传统 OLTP 数据库(如 Postgres)中的物化视图。 可刷新物化视图图示 -在增量和刷新物化视图之间的选择在很大程度上取决于查询的性质、数据变更的频率,以及是否必须在每次插入时反映更新,或者是否可以接受定期刷新。理解这些权衡对于在 ClickHouse 中设计高效、可扩展的物化视图至关重要。 +在增量和可刷新物化视图之间的选择在很大程度上取决于查询的性质、数据变化的频率以及对视图的更新是否需要在每次插入时反映每一行,或者是否可以接受定期刷新。理解这些权衡对于设计高性能、可扩展的 ClickHouse 物化视图至关重要。 ## 何时使用增量物化视图 {#when-to-use-incremental-materialized-views} -增量物化视图通常是首选,因为它们在源表接收新数据时会自动实时更新。它们支持所有聚合函数,特别适用于对单个表的聚合。通过在插入时增量计算结果,查询运行在显著较小的数据子集上,使这些视图能够轻松扩展到PB级别级别的数据。在大多数情况下,它们对整体集群性能不会产生显著影响。 +增量物化视图通常被优先考虑,因为它们在源表接收到新数据时自动实时更新。它们支持所有聚合函数,并且特别适用于对单个表的聚合操作。通过在插入时以增量方式计算结果,查询将针对显著较小的数据子集运行,从而使这些视图能够毫不费力地扩展到 PB 级别的数据。在大多数情况下,它们对整体集群性能不会产生显着影响。 -使用增量物化视图的情况: +当你需要增量物化视图时: -- 您需要每次插入时更新的实时查询结果。 -- 您需要频繁聚合或过滤大量数据。 -- 您的查询涉及对单个表的简单转换或聚合。 +- 你需要实时查询结果,每次插入时都会更新。 +- 你频繁聚合或过滤大量数据。 +- 你的查询涉及对单个表的简单转换或聚合。 -有关增量物化视图的示例,请参见 [此处](/materialized-view/incremental-materialized-view)。 +有关增量物化视图的示例,请见 [这里](/materialized-view/incremental-materialized-view)。 -## 何时使用刷新物化视图 {#when-to-use-refreshable-materialized-views} +## 何时使用可刷新物化视图 {#when-to-use-refreshable-materialized-views} -刷新物化视图按周期性执行其查询,而不是增量执行,存储查询结果集以便快速检索。 +可刷新物化视图定期执行其查询,而不是增量执行,将查询结果集存储以便快速检索。 -它们在查询性能至关重要(例如,亚毫秒延迟)且可以接受稍微过时的结果时最有用。由于查询会被完全重新运行,刷新视图最适合于相对快速计算或可以在不频繁的间隔(例如每小时)计算的查询,例如缓存“前 N”结果或查找表。 +当查询性能至关重要(例如,亚毫秒延迟)并且稍微过时的结果可以接受时,它们最有用。由于查询会完整重新运行,可刷新视图最适合那些计算相对较快的查询,或者这些查询可以在不频繁的间隔(例如每小时)内计算,比如缓存“前 N”结果或查找表。 -执行频率应仔细调整,以避免对系统造成过大负载。极为复杂且消耗大量资源的查询应谨慎安排——这些会通过影响缓存并消耗 CPU 和内存而导致整体集群性能下降。查询的运行时间应相对较快,以避免超负荷集群。例如,如果查询本身需要至少 10 秒钟才能计算,则不应每 10 秒更新一次视图。 +执行频率应谨慎调整,以避免对系统造成过大负载。极其复杂、资源消耗较大的查询应谨慎调度——这些查询可能会通过影响缓存和消耗 CPU 和内存来导致整体集群性能下降。相较于刷新间隔,查询的运行速度应该相对较快,以避免对集群的过载。例如,不要安排每 10 秒更新一次视图,假如查询本身至少需要 10 秒才能计算。 -## 摘要 {#summary} +## 总结 {#summary} -总结一下,使用刷新物化视图的情况: +总之,当你需要可刷新物化视图时: -- 您需要立即可用的缓存查询结果,并且小的延迟在新鲜度上是可以接受的。 -- 您需要查询结果集的前 N。 -- 结果集的大小不会随着时间的推移而无限增长。这将导致目标视图的性能下降。 -- 您正在执行复杂的连接或涉及多个表的非规范化操作,需要在任何源表更改时进行更新。 -- 您正在构建批处理工作流、非规范化任务或创建类似于 DBT DAG 的视图依赖关系。 +- 你需要快速获取缓存的查询结果,并且可以接受新鲜度的轻微延迟。 +- 你需要查询结果集的前 N 个结果。 +- 结果集的大小不应随着时间的推移而无限增长。这会导致目标视图的性能下降。 +- 你正在执行涉及多个表的复杂连接或非规范化,需要在任一源表更改时进行更新。 +- 你正在构建批处理工作流、非规范化任务,或创建类似于 DBT DAG 的视图依赖关系。 -有关刷新物化视图的示例,请参见 [此处](/materialized-view/refreshable-materialized-view)。 +有关可刷新物化视图的示例,请见 [这里](/materialized-view/refreshable-materialized-view)。 ### APPEND 与 REPLACE 模式 {#append-vs-replace-mode} -刷新物化视图支持两种模式来写入目标表数据:`APPEND` 和 `REPLACE`。这些模式定义了在刷新视图时,如何写入视图查询的结果。 +可刷新物化视图支持两种将数据写入目标表的模式:`APPEND` 和 `REPLACE`。这两种模式定义了视图在刷新时查询结果的写入方式。 -`REPLACE` 是默认行为。每次刷新视图时,目标表的先前内容会完全被最新的查询结果覆盖。这适合于视图应始终反映最新状态的用例,例如缓存结果集。 +`REPLACE` 是默认行为。每次刷新视图时,目标表的先前内容将被最新的查询结果完全覆盖。这适用于视图应始终反映最新状态的用例,例如缓存结果集。 -相对而言,`APPEND` 允许将新行添加到目标表的末尾,而不是替换其内容。这使得其他用例,例如捕获定期快照成为可能。当每次刷新代表一个特定的时间点或需要历史结果积累时,`APPEND` 特别有用。 +相反,`APPEND` 允许向目标表的末尾添加新行,而不是替换其内容。这使得额外的用例成为可能,例如捕获定期快照。当每次刷新表示一个特定的时间点或需要历史结果累计时,`APPEND` 特别有用。 -选择 `APPEND` 模式的情况: +选择 `APPEND` 模式时: -- 您希望保留过去刷新记录。 -- 您正在构建定期快照或报告。 -- 您需要随时间逐步收集刷新结果。 +- 你想保留过去刷新的历史。 +- 你正在构建定期快照或报告。 +- 你需要随着时间的推移逐步收集刷新的结果。 -选择 `REPLACE` 模式的情况: +选择 `REPLACE` 模式时: -- 您只需要最新的结果。 -- 应完全丢弃过时的数据。 -- 该视图代表当前状态或查找。 +- 你只需要最新的结果。 +- 过时的数据应完全丢弃。 +- 视图代表当前状态或查找。 -用户可以在构建 [Medallion 架构](https://clickhouse.com/blog/building-a-medallion-architecture-for-bluesky-json-data-with-clickhouse) 时找到 `APPEND` 功能的应用实例。 +如果构建 [Medallion 架构](https://clickhouse.com/blog/building-a-medallion-architecture-for-bluesky-json-data-with-clickhouse) 的话,用户可以找到 `APPEND` 功能的应用示例。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/use_materialized_views.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/use_materialized_views.md.hash index 23b054b6886..97e6713d993 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/use_materialized_views.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/use_materialized_views.md.hash @@ -1 +1 @@ -3fc3702f96ba39f6 +d9bb7feda0960a0f diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/use_materialized_views.translate_override b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/use_materialized_views.translate_override deleted file mode 100644 index 21cc63824cd..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/use_materialized_views.translate_override +++ /dev/null @@ -1,5 +0,0 @@ -{ - "chinese": { - "even to petabytes of data": "甚至达到PB级别的数据", - } -} diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/using_data_skipping_indices.md b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/using_data_skipping_indices.md index 608ad62c594..f7635f244e6 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/using_data_skipping_indices.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/using_data_skipping_indices.md @@ -3,56 +3,57 @@ 'sidebar_position': 10 'sidebar_label': '数据跳过索引' 'title': '在适当的地方使用数据跳过索引' -'description': '页面描述如何以及何时使用数据跳过索引' +'description': '页面描述如何及何时使用数据跳过索引' 'keywords': - 'data skipping index' - 'skip index' 'show_related_blogs': true +'doc_type': 'guide' --- import Image from '@theme/IdealImage'; import building_skipping_indices from '@site/static/images/bestpractices/building_skipping_indices.gif'; import using_skipping_indices from '@site/static/images/bestpractices/using_skipping_indices.gif'; -数据跳过索引应该在遵循既往最佳实践的情况下考虑,即优化了类型,选择了良好的主键并利用了物化视图。 +数据跳过索引应该在遵循之前最佳实践的情况下考虑,即:类型已优化,选择了良好的主键,并充分利用了物化视图。 -如果在充分理解其工作原理的前提下谨慎使用,这类索引可以加速查询性能。 +这类索引可用于加速查询性能,但需要谨慎使用,并了解其工作原理。 -ClickHouse 提供了一种强大的机制,称为 **数据跳过索引**,可以显著减少查询执行时扫描的数据量——尤其是在主键对特定过滤条件没有帮助的情况下。与依赖于基于行的传统数据库的二级索引(如 B 树)不同,ClickHouse 是一个列式存储,不以支持此类结构的方式存储行位置。相反,它使用跳过索引,这帮助它避免读取那些在保证不匹配查询过滤条件的情况下的块数据。 +ClickHouse 提供了一种强大的机制,称为 **数据跳过索引**,可以显著减少查询执行期间扫描的数据量——特别是当主键对于特定的过滤条件不太有效时。与依赖基于行的二级索引(如 B-tree)的传统数据库不同,ClickHouse 是列式存储,并且不以支持这些结构的方式存储行位置。相反,它使用跳过索引,帮助避免读取那些确保不匹配查询过滤条件的数据块。 -跳过索引通过存储有关数据块的元数据——例如最小/最大值、值集合或布隆过滤器表示——并在查询执行期间使用这些元数据来确定哪些数据块可以完全跳过。它们仅适用于 [MergeTree 家族](/engines/table-engines/mergetree-family/mergetree) 的表引擎,并通过一个表达式、一个索引类型、一个名称和定义每个索引块大小的粒度来进行定义。这些索引与表数据一起存储,并在查询过滤器与索引表达式匹配时进行咨询。 +跳过索引通过存储有关数据块的元数据(例如最小/最大值、值集或布隆过滤器表示)来工作,并在查询执行期间利用这些元数据来确定可以完全跳过哪些数据块。它们仅适用于 [MergeTree 家族](/engines/table-engines/mergetree-family/mergetree) 的表引擎,并通过表达式、索引类型、名称以及定义每个索引块大小的粒度来定义。这些索引与表数据一起存储,并在查询过滤条件与索引表达式匹配时进行查阅。 -有几种类型的数据跳过索引,适用于不同类型的查询和数据分布: +有几种类型的数据跳过索引,每种索引适合不同类型的查询和数据分布: -* **minmax**:跟踪每个块的一个表达式的最小值和最大值。理想用于对于松散排序的数据的范围查询。 -* **set(N)**:跟踪每个块中最大为 N 的值集合。有效用于低基数列的块。 -* **bloom_filter**:以概率方式确定值是否存在于某个块中,允许快速近似过滤集合的成员资格。有效于优化在“干草堆中的针”场景中查找,其中需要正匹配。 -* **tokenbf_v1 / ngrambf_v1**:专为在字符串中搜索令牌或字符序列而设计的特殊布隆过滤器变种——对日志数据或文本搜索用例特别有用。 +* **minmax**:跟踪每个数据块表达式的最小值和最大值。非常适合用于松散排序数据的范围查询。 +* **set(N)**:跟踪每个数据块中最多指定大小 N 的值集。对低基数的列有效。 +* **bloom_filter**:概率性地确定一个值是否存在于数据块中,允许对集合成员资格进行快速近似过滤。有效优化寻找“针在干草堆中”的查询,其中需要正匹配。 +* **tokenbf_v1 / ngrambf_v1**:专门的布隆过滤器变体,旨在搜索字符串中的标记或字符序列——特别适用于日志数据或文本搜索用例。 -虽然强大,跳过索引必须谨慎使用。当它们消除了大量数据块时才能提供益处,如果查询或数据结构不匹配,则可能引入开销。如果块中存在一个匹配值,则必须读取整个块。 +尽管功能强大,跳过索引必须谨慎使用。它们仅在消除大量数据块的情况下提供好处,如果查询或数据结构不一致,还可能引入开销。如果数据块中存在一个匹配的值,则仍需读取整个数据块。 -**有效的跳过索引使用通常依赖于被索引列与表的主键之间强热点相关性,或者以一种将相似值分组的方式插入数据。** +**有效的跳过索引使用通常依赖于索引列与表主键之间的强相关性,或以一种将相似值聚集在一起的方式插入数据。** -通常,在确保有适当的主键设计和类型优化后,最好应用数据跳过索引。它们特别适用于: +一般来说,在确保适当的主键设计和类型优化后,数据跳过索引的应用效果最佳。它们特别适用于: -* 整体基数高但块内基数低的列。 -* 对于搜索至关重要的稀有值(例如错误代码、特定 ID)。 -* 在非主键列上发生过滤的情况下,且具有局部分布。 +* 总体基数高但每个块内基数低的列。 +* 对搜索至关重要的稀有值(例如错误代码、特定 ID)。 +* 在具有本地分布的非主键列上发生过滤的情况。 始终: -1. 在真实数据上用现实查询测试跳过索引。尝试不同的索引类型和粒度值。 -2. 使用像 send_logs_level='trace' 这样的工具评估其影响,并使用 `EXPLAIN indexes=1` 以查看索引的有效性。 -3. 始终评估索引的大小以及如何受到粒度的影响。通常降低粒度的大小会改善性能,从而导致更多的粒度被过滤并需要被扫描。然而,随着索引大小随较低粒度增加,性能也可能恶化。测量不同粒度数据点的性能和索引大小。这在布隆过滤器索引上尤其相关。 +1. 在真实数据上使用真实查询测试跳过索引。尝试不同的索引类型和粒度值。 +2. 使用工具(如 send_logs_level='trace' 和 `EXPLAIN indexes=1`)评估它们的影响,以查看索引效果。 +3. 始终评估索引的大小以及其如何受到粒度的影响。降低粒度大小通常会改善性能,但会导致更多的块被过滤和需要扫描。然而,随着索引大小的增加,性能也可能会下降。测量各种粒度数据点的性能和索引大小。这对布隆过滤器索引尤其重要。

-**当适当使用时,跳过索引能够大幅提升性能—当盲目使用时,它们可能增加不必要的成本。** +**当适当使用时,跳过索引可以显著提升性能——盲目使用则可能增加不必要的成本。** -有关数据跳过索引的更详细指南请见 [这里](/sql-reference/statements/alter/skipping-index)。 +有关数据跳过索引的更详细指南,请参见 [这里](/sql-reference/statements/alter/skipping-index)。 ## 示例 {#example} -考虑以下优化过的表。此表包含每个帖子的 Stack Overflow 数据。 +考虑以下优化后的表。这包含每个帖子一行的 Stack Overflow 数据。 ```sql CREATE TABLE stackoverflow.posts @@ -85,7 +86,7 @@ PARTITION BY toYear(CreationDate) ORDER BY (PostTypeId, toDate(CreationDate)) ``` -该表针对按帖子类型和日期过滤和聚合的查询进行了优化。假设我们希望统计 2009 年后发布的超过 10,000,000 次浏览的帖子数量。 +该表针对按帖子类型和日期过滤和聚合的查询进行了优化。假设我们希望统计2009年后发布的访问量超过10,000,000的帖子数量。 ```sql SELECT count() @@ -99,7 +100,7 @@ WHERE (CreationDate > '2009-01-01') AND (ViewCount > 10000000) 1 row in set. Elapsed: 0.720 sec. Processed 59.55 million rows, 230.23 MB (82.66 million rows/s., 319.56 MB/s.) ``` -此查询能够使用主索引排除一些行(和粒度)。然而,大多数行依旧需要阅读,如上面的响应和接下来的 `EXPLAIN indexes=1` 所示: +此查询能够利用主索引排除一些行(和块)。然而,大多数行仍需根据上述响应和随后 `EXPLAIN indexes=1` 的结果进行读取: ```sql EXPLAIN indexes = 1 @@ -139,13 +140,13 @@ LIMIT 1 25 rows in set. Elapsed: 0.070 sec. ``` -简单分析表明,`ViewCount` 与 `CreationDate`(主键)是相关的,正如人们所期望的那样——帖子存在越久,被查看的时间就越多。 +简单分析显示 `ViewCount` 与 `CreationDate`(主键)之间存在相关性——帖子存在的时间越长,被查看的时间就越多。 ```sql -SELECT toDate(CreationDate) as day, avg(ViewCount) as view_count FROM stackoverflow.posts WHERE day > '2009-01-01' GROUP BY day +SELECT toDate(CreationDate) AS day, avg(ViewCount) AS view_count FROM stackoverflow.posts WHERE day > '2009-01-01' GROUP BY day ``` -因此,为数据跳过索引做出逻辑选择。考虑到数字类型,min_max 索引是有意义的。我们使用以下 `ALTER TABLE` 命令添加索引——首先添加它,然后“物化”它。 +因此,这是选择数据跳过索引的合逻辑选择。考虑到数值类型,使用 min_max 索引是合理的。我们通过以下 `ALTER TABLE` 命令添加索引——首先添加,它,然后“物化”它。 ```sql ALTER TABLE stackoverflow.posts @@ -154,7 +155,7 @@ ALTER TABLE stackoverflow.posts ALTER TABLE stackoverflow.posts MATERIALIZE INDEX view_count_idx; ``` -此索引也可以在初始表创建期间添加。定义为 DDL 一部分的模式,带有 min max 索引: +该索引也可以在初始表创建期间添加。在 DDL 中定义 min max 索引的模式: ```sql CREATE TABLE stackoverflow.posts @@ -188,11 +189,11 @@ PARTITION BY toYear(CreationDate) ORDER BY (PostTypeId, toDate(CreationDate)) ``` -以下动画说明了我们的 minmax 跳过索引是如何为示例表构建的,跟踪表中每个行块(粒度)的最小和最大 `ViewCount` 值: +以下动画展示了为示例表构建我们的 minmax 跳过索引的过程,跟踪表中每个数据块(粒度)中的最小和最大 `ViewCount` 值: Building skipping indices -重复我们之前的查询显示了显著的性能改善。注意所有减少的被扫描行数: +重复我们之前的查询显示出显著的性能提升。请注意扫描的行数减少: ```sql SELECT count() @@ -249,6 +250,6 @@ WHERE (CreationDate > '2009-01-01') AND (ViewCount > 10000000) 29 rows in set. Elapsed: 0.211 sec. ``` -我们还展示了一个动画,展示 minmax 跳过索引如何修剪不能包含示例查询中 `ViewCount` > 10,000,000 条件匹配的所有行块: +我们还展示了一个动画,说明 minmax 跳过索引如何修剪所有不可能包含符合 `ViewCount` > 10,000,000 谓词的行块: Using skipping indices diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/using_data_skipping_indices.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/using_data_skipping_indices.md.hash index 84cfa99f485..b57a7792061 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/using_data_skipping_indices.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/using_data_skipping_indices.md.hash @@ -1 +1 @@ -b927b730adc95e8e +d28dbcbcd9e5e1eb diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/api/python.md b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/api/python.md new file mode 100644 index 00000000000..8b94f052b75 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/api/python.md @@ -0,0 +1,3260 @@ +--- +'title': 'chDB Python API 参考' +'sidebar_label': 'Python API' +'slug': '/chdb/api/python' +'description': '完整的 chDB Python API 参考' +'keywords': +- 'chdb' +- 'embedded' +- 'clickhouse-lite' +- 'python' +- 'api' +- 'reference' +'doc_type': 'reference' +--- + + +# Python API Reference +## Core Query Functions {#core-query-functions} +### `chdb.query` {#chdb-query} + +使用 chDB 引擎执行 SQL 查询。 + +这是主要的查询函数,它使用嵌入式 ClickHouse 引擎执行 SQL 语句。支持多种输出格式,并且可以与内存或基于文件的数据库一起使用。 + +**语法** + +```python +chdb.query(sql, output_format='CSV', path='', udf_path='') +``` + +**参数** + +| 参数 | 类型 | 默认值 | 描述 | +|------------------|-------|---------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `sql` | str | *必填* | 要执行的 SQL 查询字符串 | +| `output_format` | str | `"CSV"` | 结果的输出格式。支持的格式:
• `"CSV"` - 逗号分隔值
• `"JSON"` - JSON 格式
• `"Arrow"` - Apache Arrow 格式
• `"Parquet"` - Parquet 格式
• `"DataFrame"` - Pandas DataFrame
• `"ArrowTable"` - PyArrow 表
• `"Debug"` - 启用详细日志记录 | +| `path` | str | `""` | 数据库文件路径。默认为内存数据库。
可以是文件路径或 `":memory:"` 表示内存数据库 | +| `udf_path` | str | `""` | 用户定义函数目录的路径 | + +**返回值** + +以指定格式返回查询结果: + +| 返回类型 | 条件 | +|-----------------------|------------------------------------------------------| +| `str` | 对于文本格式,如 CSV、JSON | +| `pd.DataFrame` | 当 `output_format` 为 `"DataFrame"` 或 `"dataframe"` 时 | +| `pa.Table` | 当 `output_format` 为 `"ArrowTable"` 或 `"arrowtable"` 时 | +| chdb 结果对象 | 对于其他格式 | + +**抛出异常** + +| 异常 | 条件 | +|-----------------|---------------------------------------------------------------| +| `ChdbError` | 如果 SQL 查询执行失败 | +| `ImportError` | 如果缺少 DataFrame/Arrow 格式所需的依赖项 | + +**示例** + +```pycon +>>> # Basic CSV query +>>> result = chdb.query("SELECT 1, 'hello'") +>>> print(result) +"1,hello" +``` + +```pycon +>>> # Query with DataFrame output +>>> df = chdb.query("SELECT 1 as id, 'hello' as msg", "DataFrame") +>>> print(df) + id msg +0 1 hello +``` + +```pycon +>>> # Query with file-based database +>>> result = chdb.query("CREATE TABLE test (id INT)", path="mydb.chdb") +``` + +```pycon +>>> # Query with UDF +>>> result = chdb.query("SELECT my_udf('test')", udf_path="/path/to/udfs") +``` + +--- +### `chdb.sql` {#chdb_sql} + +使用 chDB 引擎执行 SQL 查询。 + +这是主要的查询函数,它使用嵌入式 ClickHouse 引擎执行 SQL 语句。支持多种输出格式,并且可以与内存或基于文件的数据库一起使用。 + +**语法** + +```python +chdb.sql(sql, output_format='CSV', path='', udf_path='') +``` + +**参数** + +| 参数 | 类型 | 默认值 | 描述 | +|------------------|-------|---------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `sql` | str | *必填* | 要执行的 SQL 查询字符串 | +| `output_format` | str | `"CSV"` | 结果的输出格式。支持的格式:
• `"CSV"` - 逗号分隔值
• `"JSON"` - JSON 格式
• `"Arrow"` - Apache Arrow 格式
• `"Parquet"` - Parquet 格式
• `"DataFrame"` - Pandas DataFrame
• `"ArrowTable"` - PyArrow 表
• `"Debug"` - 启用详细日志记录 | +| `path` | str | `""` | 数据库文件路径。默认为内存数据库。
可以是文件路径或 `":memory:"` 表示内存数据库 | +| `udf_path` | str | `""` | 用户定义函数目录的路径 | + +**返回值** + +以指定格式返回查询结果: + +| 返回类型 | 条件 | +|-----------------------|------------------------------------------------------| +| `str` | 对于文本格式,如 CSV、JSON | +| `pd.DataFrame` | 当 `output_format` 为 `"DataFrame"` 或 `"dataframe"` 时 | +| `pa.Table` | 当 `output_format` 为 `"ArrowTable"` 或 `"arrowtable"` 时 | +| chdb 结果对象 | 对于其他格式 | + +**抛出异常** + +| 异常 | 条件 | +|----------------------|---------------------------------------------------------------| +| [`ChdbError`](#chdberror) | 如果 SQL 查询执行失败 | +| `ImportError` | 如果缺少 DataFrame/Arrow 格式所需的依赖项 | + +**示例** + +```pycon +>>> # Basic CSV query +>>> result = chdb.query("SELECT 1, 'hello'") +>>> print(result) +"1,hello" +``` + +```pycon +>>> # Query with DataFrame output +>>> df = chdb.query("SELECT 1 as id, 'hello' as msg", "DataFrame") +>>> print(df) + id msg +0 1 hello +``` + +```pycon +>>> # Query with file-based database +>>> result = chdb.query("CREATE TABLE test (id INT)", path="mydb.chdb") +``` + +```pycon +>>> # Query with UDF +>>> result = chdb.query("SELECT my_udf('test')", udf_path="/path/to/udfs") +``` + +--- +### `chdb.to_arrowTable` {#chdb-state-sqlitelike-to_arrowtable} + +将查询结果转换为 PyArrow 表。 + +将 chDB 查询结果转换为 PyArrow 表,以便高效的列式数据处理。如果结果为空,则返回一个空表。 + +**语法** + +```python +chdb.to_arrowTable(res) +``` + +**参数** + +| 参数 | 描述 | +|-----------|------------------------------------------------| +| `res` | 包含二进制 Arrow 数据的 chDB 查询结果对象 | + +**返回值** + +| 返回类型 | 描述 | +|------------|---------------------------------------| +| `pa.Table` | 包含查询结果的 PyArrow 表 | + +**抛出异常** + +| 错误类型 | 描述 | +|--------------|---------------------------------| +| `ImportError` | 如果未安装 pyarrow 或 pandas | + +**示例** + +```pycon +>>> result = chdb.query("SELECT 1 as id, 'hello' as msg", "Arrow") +>>> table = chdb.to_arrowTable(result) +>>> print(table.to_pandas()) + id msg +0 1 hello +``` + +--- +### `chdb.to_df` {#chdb_to_df} + +将查询结果转换为 Pandas DataFrame。 + +通过首先转换为 PyArrow 表,然后使用多线程转换为 Pandas,以获得更好的性能,将 chDB 查询结果转换为 Pandas DataFrame。 + +**语法** + +```python +chdb.to_df(r) +``` + +**参数** + +| 参数 | 描述 | +|-----------|------------------------------------------------| +| `r` | 包含二进制 Arrow 数据的 chDB 查询结果对象 | + +**返回值** + +| 返回类型 | 描述 | +|--------------------|-----------------------------------| +| `pd.DataFrame` | 包含查询结果的 Pandas DataFrame | + +**抛出异常** + +| 异常 | 条件 | +|------------------|-----------------------------------| +| `ImportError` | 如果未安装 pyarrow 或 pandas | + +**示例** + +```pycon +>>> result = chdb.query("SELECT 1 as id, 'hello' as msg", "Arrow") +>>> df = chdb.to_df(result) +>>> print(df) + id msg +0 1 hello +``` +## Connection and Session Management {#connection-session-management} + +以下会话函数可用: +### `chdb.connect` {#chdb-connect} + +创建一个与 chDB 后台服务器的连接。 + +此函数与 chDB (ClickHouse) 数据库引擎建立 [连接](#chdb-state-sqlitelike-connection)。每个进程仅允许一个打开的连接。多次使用相同连接字符串调用将返回相同的连接对象。 + +```python +chdb.connect(connection_string: str = ':memory:') → Connection +``` + +**参数:** + +| 参数 | 类型 | 默认值 | 描述 | +|-----------------------|-------|----------------|-----------------------------------------| +| `connection_string` | str | `":memory:"` | 数据库连接字符串。见下文格式。 | + +**基本格式** + +| 格式 | 描述 | +|---------------------------|----------------------------| +| `":memory:"` | 内存数据库(默认) | +| `"test.db"` | 相对路径数据库文件 | +| `"file:test.db"` | 与相对路径相同 | +| `"/path/to/test.db"` | 绝对路径数据库文件 | +| `"file:/path/to/test.db"` | 与绝对路径相同 | + +**带查询参数的格式** + +| 格式 | 描述 | +|--------------------------------------------------|-----------------------------| +| `"file:test.db?param1=value1¶m2=value2"` | 带参数的相对路径 | +| `"file::memory:?verbose&log-level=test"` | 带参数的内存数据库 | +| `"///path/to/test.db?param1=value1¶m2=value2"` | 带参数的绝对路径 | + +**查询参数处理** + +查询参数作为启动参数传递给 ClickHouse 引擎。特殊参数处理: + +| 特殊参数 | 变为 | 描述 | +|-------------------|-------------------|-------------------------| +| `mode=ro` | `--readonly=1` | 只读模式 | +| `verbose` | (标志) | 启用详细日志记录 | +| `log-level=test` | (设置) | 设置日志级别 | + +有关完整的参数列表,请参见 `clickhouse local --help --verbose` + +**返回值** + +| 返回类型 | 描述 | +|-------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `Connection` | 支持的数据库连接对象:
• 使用 `Connection.cursor()` 创建游标
• 使用 `Connection.query()` 直接查询
• 使用 `Connection.send_query()` 流式查询
• 支持自动清理的上下文管理器协议 | + +**抛出异常** + +| 异常 | 条件 | +|---------------|-----------------------------| +| `RuntimeError` | 如果连接到数据库失败 | + +:::warning +每个进程只支持一个连接。 +创建新连接将关闭任何现有的连接。 +::: + +**示例** + +```pycon +>>> # In-memory database +>>> conn = connect() +>>> conn = connect(":memory:") +>>> +>>> # File-based database +>>> conn = connect("my_data.db") +>>> conn = connect("/path/to/data.db") +>>> +>>> # With parameters +>>> conn = connect("data.db?mode=ro") # Read-only mode +>>> conn = connect(":memory:?verbose&log-level=debug") # Debug logging +>>> +>>> # Using context manager for automatic cleanup +>>> with connect("data.db") as conn: +... result = conn.query("SELECT 1") +... print(result) +>>> # Connection automatically closed +``` + +**另见** +- [`Connection`](#chdb-state-sqlitelike-connection) - 数据库连接类 +- [`Cursor`](#chdb-state-sqlitelike-cursor) - 用于 DB-API 2.0 操作的数据库游标 +## Exception Handling {#chdb-exceptions} +### **class** `chdb.ChdbError` {#chdb_chdbError} + +基类:`Exception` + +chDB 相关错误的基异常类。 + +当 chDB 查询执行失败或遇到错误时,会引发此异常。它继承自标准 Python Exception 类,并提供来自底层 ClickHouse 引擎的错误信息。 + +--- +### **class** `chdb.session.Session` {#chdb_session_session} + +基类:`object` + +会话将保持查询状态。 +如果路径为 None,它将创建一个临时目录并将其用作数据库路径,并在会话关闭时删除临时目录。 +您还可以传入路径以在该路径创建一个数据库,以存放数据。 + +您也可以使用连接字符串传递路径和其他参数。 + +```python +class chdb.session.Session(path=None) +``` + +**示例** + +| 连接字符串 | 描述 | +|----------------------------------------------|-------------------------------| +| `":memory:"` | 内存数据库 | +| `"test.db"` | 相对路径 | +| `"file:test.db"` | 与上述相同 | +| `"/path/to/test.db"` | 绝对路径 | +| `"file:/path/to/test.db"` | 与上述相同 | +| `"file:test.db?param1=value1¶m2=value2"` | 带查询参数的相对路径 | +| `"file::memory:?verbose&log-level=test"` | 带查询参数的内存数据库 | +| `"///path/to/test.db?param1=value1¶m2=value2"` | 带查询参数的绝对路径 | + +:::note 连接字符串参数处理 +包含查询参数的连接字符串如 "[file:test.db?param1=value1¶m2=value2](file:test.db?param1=value1¶m2=value2)" +“param1=value1”将作为启动参数传递给 ClickHouse 引擎。 + +有关更多详细信息,请参见 `clickhouse local --help --verbose` + +一些特殊参数处理: +- “mode=ro”会变为“--readonly=1”用于 clickhouse(只读模式) +::: + +:::warning 重要 +- 任何时候只能有一个会话。如果您想创建新会话,您需要关闭现有会话。 +- 创建新会话将关闭现有会话。 +::: + +--- +#### `cleanup` {#cleanup} + +带有异常处理的清理会话资源。 + +此方法尝试关闭会话,同时抑制清理过程中可能发生的任何异常。在错误处理场景中或当您需要确保无论会话状态如何都进行清理时,这尤其有用。 + +**语法** + +```python +cleanup() +``` + +:::note +此方法永远不会引发异常,所以在 finally 块或析构函数中调用是安全的。 +::: + +**示例** + +```pycon +>>> session = Session("test.db") +>>> try: +... session.query("INVALID SQL") +... finally: +... session.cleanup() # Safe cleanup regardless of errors +``` + +**另见** +- [`close()`](#chdb-session-session-close) - 用于显式会话关闭并进行错误传播 + +--- +#### `close` {#close} + +关闭会话并清理资源。 + +此方法关闭底层连接并重置全局会话状态。调用此方法后,会话变为无效,不能用于进一步的查询。 + +**语法** + +```python +close() +``` + +:::note +当会话作为上下文管理器使用或当会话对象被销毁时,自动调用此方法。 +::: + +:::warning 重要 +在调用 `close()` 后,任何尝试使用会话的行为都将导致错误。 +::: + +**示例** + +```pycon +>>> session = Session("test.db") +>>> session.query("SELECT 1") +>>> session.close() # Explicitly close the session +``` + +--- +#### `query` {#chdb-session-session-query} + +执行 SQL 查询并返回结果。 + +此方法针对会话的数据库执行 SQL 查询,并以指定格式返回结果。该方法支持多种输出格式,并在查询之间保持会话状态。 + +**语法** + +```python +query(sql, fmt='CSV', udf_path='') +``` + +**参数** + +| 参数 | 类型 | 默认值 | 描述 | +|-----------|-------|---------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `sql` | str | *必填* | 要执行的 SQL 查询字符串 | +| `fmt` | str | `"CSV"` | 结果的输出格式。可用格式:
• `"CSV"` - 逗号分隔值
• `"JSON"` - JSON 格式
• `"TabSeparated"` - 制表符分隔值
• `"Pretty"` - 美化显示的表格格式
• `"JSONCompact"` - 紧凑的 JSON 格式
• `"Arrow"` - Apache Arrow 格式
• `"Parquet"` - Parquet 格式 | +| `udf_path`| str | `""` | 用户定义函数的路径。如果未指定,则使用会话初始化的 UDF 路径 | + +**返回值** + +以指定格式返回查询结果。 +确切的返回类型取决于格式参数: +- 字符串格式(CSV,JSON 等)返回 str +- 二进制格式(Arrow,Parquet)返回 bytes + +**抛出异常** + +| 异常 | 条件 | +|---------------|--------------------------------| +| `RuntimeError` | 如果会话被关闭或无效 | +| `ValueError` | 如果 SQL 查询格式不正确 | + +:::note +“不支持调试”格式,将自动转换为“CSV”并发出警告。 +对于调试,请使用连接字符串参数。 +::: + +:::warning 警告 +此方法同步执行查询并将所有结果加载到内存中。对于大型结果集,请考虑使用 [`send_query()`](#chdb-session-session-send_query) 进行流式结果。 +::: + +**示例** + +```pycon +>>> session = Session("test.db") +>>> +>>> # Basic query with default CSV format +>>> result = session.query("SELECT 1 as number") +>>> print(result) +number +1 +``` + +```pycon +>>> # Query with JSON format +>>> result = session.query("SELECT 1 as number", fmt="JSON") +>>> print(result) +{"number": "1"} +``` + +```pycon +>>> # Complex query with table creation +>>> session.query("CREATE TABLE test (id INT, name String)") +>>> session.query("INSERT INTO test VALUES (1, 'Alice'), (2, 'Bob')") +>>> result = session.query("SELECT * FROM test ORDER BY id") +>>> print(result) +id,name +1,Alice +2,Bob +``` + +**另见** +- [`send_query()`](#chdb-session-session-send_query) - 用于流式查询执行 +- [`sql`](#chdb-session-session-sql) - 此方法的别名 + +--- +#### `send_query` {#chdb-session-session-send_query} + +执行 SQL 查询并返回流式结果迭代器。 + +此方法针对会话的数据库执行 SQL 查询,并返回一个流式结果对象,允许您在不一次性将所有结果加载到内存中的情况下迭代结果。这对于大型结果集特别有用。 + +**语法** + +```python +send_query(sql, fmt='CSV') → StreamingResult +``` + +**参数** + +| 参数 | 类型 | 默认值 | 描述 | +|-----------|-------|---------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `sql` | str | *必填* | 要执行的 SQL 查询字符串 | +| `fmt` | str | `"CSV"` | 结果的输出格式。可用格式:
• `"CSV"` - 逗号分隔值
• `"JSON"` - JSON 格式
• `"TabSeparated"` - 制表符分隔值
• `"JSONCompact"` - 紧凑的 JSON 格式
• `"Arrow"` - Apache Arrow 格式
• `"Parquet"` - Parquet 格式 | + +**返回值** + +| 返回类型 | 描述 | +|-----------------|-----------------------------------------------------------------------------------------------------------------------------------------| +| `StreamingResult` | 一个流式结果迭代器,可逐步产生查询结果。迭代器可以在 for 循环中使用或转换为其他数据结构 | + +**抛出异常** + +| 异常 | 条件 | +|---------------|--------------------------------| +| `RuntimeError` | 如果会话被关闭或无效 | +| `ValueError` | 如果 SQL 查询格式不正确 | + +:::note +“不支持调试”格式,将自动转换为“CSV”并发出警告。对于调试,请使用连接字符串参数。 +::: + +:::warning +返回的 StreamingResult 对象应及时消耗或适当存储,因为它保持与数据库的连接。 +::: + +**示例** + +```pycon +>>> session = Session("test.db") +>>> session.query("CREATE TABLE big_table (id INT, data String)") +>>> +>>> # Insert large dataset +>>> for i in range(1000): +... session.query(f"INSERT INTO big_table VALUES ({i}, 'data_{i}')") +>>> +>>> # Stream results to avoid memory issues +>>> streaming_result = session.send_query("SELECT * FROM big_table ORDER BY id") +>>> for chunk in streaming_result: +... print(f"Processing chunk: {len(chunk)} bytes") +... # Process chunk without loading entire result set +``` + +```pycon +>>> # Using with context manager +>>> with session.send_query("SELECT COUNT(*) FROM big_table") as stream: +... for result in stream: +... print(f"Count result: {result}") +``` + +**另见** +- [`query()`](#chdb-session-session-query) - 用于非流式查询执行 +- `chdb.state.sqlitelike.StreamingResult` - 流式结果迭代器 + +--- +#### `sql` {#chdb-session-session-sql} + +执行 SQL 查询并返回结果。 + +此方法针对会话的数据库执行 SQL 查询,并以指定格式返回结果。该方法支持多种输出格式,并在查询之间保持会话状态。 + +**语法** + +```python +sql(sql, fmt='CSV', udf_path='') +``` + +**参数** + +| 参数 | 类型 | 默认值 | 描述 | +|-----------|-------|---------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `sql` | str | *必填* | 要执行的 SQL 查询字符串 | +| `fmt` | str | `"CSV"` | 结果的输出格式。可用格式:
• `"CSV"` - 逗号分隔值
• `"JSON"` - JSON 格式
• `"TabSeparated"` - 制表符分隔值
• `"Pretty"` - 美化显示的表格格式
• `"JSONCompact"` - 紧凑的 JSON 格式
• `"Arrow"` - Apache Arrow 格式
• `"Parquet"` - Parquet 格式 | +| `udf_path`| str | `""` | 用户定义函数的路径。如果未指定,则使用会话初始化的 UDF 路径 | + +**返回值** + +以指定格式返回查询结果。 +确切的返回类型取决于格式参数: +- 字符串格式(CSV,JSON 等)返回 str +- 二进制格式(Arrow,Parquet)返回 bytes + +**抛出异常:** + +| 异常 | 条件 | +|---------------|--------------------------------| +| `RuntimeError` | 如果会话被关闭或无效 | +| `ValueError` | 如果 SQL 查询格式不正确 | + +:::note +“不支持调试”格式,将自动转换为“CSV”并发出警告。对于调试,请使用连接字符串参数。 +::: + +:::warning 警告 +此方法同步执行查询并将所有结果加载到内存中。 +对于大型结果集,请考虑使用 [`send_query()`](#chdb-session-session-send_query) 进行流式结果。 +::: + +**示例** + +```pycon +>>> session = Session("test.db") +>>> +>>> # Basic query with default CSV format +>>> result = session.query("SELECT 1 as number") +>>> print(result) +number +1 +``` + +```pycon +>>> # Query with JSON format +>>> result = session.query("SELECT 1 as number", fmt="JSON") +>>> print(result) +{"number": "1"} +``` + +```pycon +>>> # Complex query with table creation +>>> session.query("CREATE TABLE test (id INT, name String)") +>>> session.query("INSERT INTO test VALUES (1, 'Alice'), (2, 'Bob')") +>>> result = session.query("SELECT * FROM test ORDER BY id") +>>> print(result) +id,name +1,Alice +2,Bob +``` + +**另见** +- [`send_query()`](#chdb-session-session-send_query) - 用于流式查询执行 +- [`sql`](#chdb-session-session-sql) - 此方法的别名 +## State Management {#chdb-state-management} +### `chdb.state.connect` {#chdb_state_connect} + +创建与 chDB 后台服务器的 [连接](#chdb-state-sqlitelike-connection)。 + +此函数与 chDB (ClickHouse) 数据库引擎建立连接。 +每个进程仅允许一个打开的连接。多次使用相同连接字符串调用将返回相同的连接对象。 + +**语法** + +```python +chdb.state.connect(connection_string: str = ':memory:') → Connection +``` + +**参数** + +| 参数 | 类型 | 默认值 | 描述 | +|-------------------------------|-------|---------------|-----------------------------------------| +| `connection_string(str, optional)` | str | `":memory:"` | 数据库连接字符串。见下文格式。 | + +**基本格式** + +支持的连接字符串格式: + +| 格式 | 描述 | +|---------------------------|----------------------------| +| `":memory:"` | 内存数据库(默认) | +| `"test.db"` | 相对路径数据库文件 | +| `"file:test.db"` | 与相对路径相同 | +| `"/path/to/test.db"` | 绝对路径数据库文件 | +| `"file:/path/to/test.db"` | 与绝对路径相同 | + +**带查询参数的格式** + +| 格式 | 描述 | +|--------------------------------------------------|-----------------------------| +| `"file:test.db?param1=value1¶m2=value2"` | 带参数的相对路径 | +| `"file::memory:?verbose&log-level=test"` | 带参数的内存数据库 | +| `"///path/to/test.db?param1=value1¶m2=value2"` | 带参数的绝对路径 | + +**查询参数处理** + +查询参数作为启动参数传递给 ClickHouse 引擎。特殊参数处理: + +| 特殊参数 | 变为 | 描述 | +|-------------------|-------------------|-------------------------| +| `mode=ro` | `--readonly=1` | 只读模式 | +| `verbose` | (标志) | 启用详细日志记录 | +| `log-level=test` | (设置) | 设置日志级别 | + +有关完整的参数列表,请参见 `clickhouse local --help --verbose` + +**返回值** + +| 返回类型 | 描述 | +|-------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `Connection` | 支持的数据库连接对象:
• 使用 `Connection.cursor()` 创建游标
• 使用 `Connection.query()` 直接查询
• 使用 `Connection.send_query()` 流式查询
• 支持自动清理的上下文管理器协议 | + +**抛出异常** + +| 异常 | 条件 | +|---------------|-----------------------------| +| `RuntimeError` | 如果连接到数据库失败 | + +:::warning 警告 +每个进程只支持一个连接。 +创建新连接将关闭任何现有的连接。 +::: + +**示例** + +```pycon +>>> # In-memory database +>>> conn = connect() +>>> conn = connect(":memory:") +>>> +>>> # File-based database +>>> conn = connect("my_data.db") +>>> conn = connect("/path/to/data.db") +>>> +>>> # With parameters +>>> conn = connect("data.db?mode=ro") # Read-only mode +>>> conn = connect(":memory:?verbose&log-level=debug") # Debug logging +>>> +>>> # Using context manager for automatic cleanup +>>> with connect("data.db") as conn: +... result = conn.query("SELECT 1") +... print(result) +>>> # Connection automatically closed +``` + +**另见** +- `Connection` - 数据库连接类 +- `Cursor` - 用于 DB-API 2.0 操作的数据库游标 +### **class** `chdb.state.sqlitelike.Connection` {#chdb-state-sqlitelike-connection} + +基类:`object` + +**语法** + +```python +class chdb.state.sqlitelike.Connection(connection_string: str) +``` + +--- +#### `close` {#chdb-session-session-close} + +关闭连接并清理资源。 + +此方法关闭数据库连接并清理任何相关资源,包括活动游标。调用此方法后,连接变为无效,不能用于进一步的操作。 + +**语法** + +```python +close() → None +``` + +:::note +此方法是幂等的 - 多次调用是安全的。 +::: + +:::warning 警告 +任何正在进行的流式查询将在连接关闭时被取消。在关闭之前,请确保处理所有重要数据。 +::: + +**示例** + +```pycon +>>> conn = connect("test.db") +>>> # Use connection for queries +>>> conn.query("CREATE TABLE test (id INT)") +>>> # Close when done +>>> conn.close() +``` + +```pycon +>>> # Using with context manager (automatic cleanup) +>>> with connect("test.db") as conn: +... conn.query("SELECT 1") +... # Connection automatically closed +``` + +--- +#### `cursor` {#chdb-state-sqlitelike-connection-cursor} + +创建一个 [Cursor](#chdb-state-sqlitelike-cursor) 对象以执行查询。 + +此方法创建一个数据库游标,提供标准的 +DB-API 2.0 接口来执行查询和提取结果。 +游标允许对查询执行和结果检索进行精细控制。 + +**语法** + +```python +cursor() → Cursor +``` + +**返回** + +| 返回类型 | 描述 | +|------------|---------------------------------------| +| `Cursor` | 用于数据库操作的游标对象 | + +:::note +创建新游标将替换与此连接相关的任何现有游标。每个连接仅支持一个游标。 +::: + +**示例** + +```pycon +>>> conn = connect(":memory:") +>>> cursor = conn.cursor() +>>> cursor.execute("CREATE TABLE test (id INT, name String)") +>>> cursor.execute("INSERT INTO test VALUES (1, 'Alice')") +>>> cursor.execute("SELECT * FROM test") +>>> rows = cursor.fetchall() +>>> print(rows) +((1, 'Alice'),) +``` + +**另请参见** +- [`Cursor`](#chdb-state-sqlitelike-cursor) - 数据库游标实现 + +--- +#### `query` {#chdb-state-sqlitelike-connection-query} + +执行 SQL 查询并返回完整结果。 + +此方法同步执行 SQL 查询并返回完整 +结果集。它支持各种输出格式并自动应用 +格式特定的后处理。 + +**语法** + +```python +query(query: str, format: str = 'CSV') → Any +``` + +**参数:** + +| 参数 | 类型 | 默认值 | 描述 | +|------------|--------|--------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `query` | str | *必需* | 要执行的 SQL 查询字符串 | +| `format` | str | `"CSV"` | 结果的输出格式。支持的格式:
• `"CSV"` - 逗号分隔值(字符串)
• `"JSON"` - JSON 格式(字符串)
• `"Arrow"` - Apache Arrow 格式(字节)
• `"Dataframe"` - Pandas DataFrame(需要 pandas)
• `"Arrowtable"` - PyArrow 表(需要 pyarrow) | + +**返回** + +| 返回类型 | 描述 | +|------------------------|--------------------------------------| +| `str` | 对于字符串格式(CSV,JSON) | +| `bytes` | 对于 Arrow 格式 | +| `pandas.DataFrame` | 对于数据框格式 | +| `pyarrow.Table` | 对于箭头表格式 | + +**引发** + +| 异常 | 条件 | +|----------------|--------------------------------------------------| +| `RuntimeError` | 如果查询执行失败 | +| `ImportError` | 如果所需的格式包未安装 | + +:::warning 警告 +此方法将整个结果集加载到内存中。对于大型结果,请考虑使用 [`send_query()`](#chdb-state-sqlitelike-connection-send_query) 进行流式处理。 +::: + +**示例** + +```pycon +>>> conn = connect(":memory:") +>>> +>>> # Basic CSV query +>>> result = conn.query("SELECT 1 as num, 'hello' as text") +>>> print(result) +num,text +1,hello +``` + +```pycon +>>> # DataFrame format +>>> df = conn.query("SELECT number FROM numbers(5)", "dataframe") +>>> print(df) + number +0 0 +1 1 +2 2 +3 3 +4 4 +``` + +**另请参见** +- [`send_query()`](#chdb-state-sqlitelike-connection-send_query) - 用于流式查询执行 + +--- +#### `send_query` {#chdb-state-sqlitelike-connection-send_query} + +执行 SQL 查询并返回流式结果迭代器。 + +此方法执行 SQL 查询并返回一个 StreamingResult 对象 +,允许您迭代结果而不一次性加载所有内容。 +这对于处理大型结果集非常理想。 + +**语法** + +```python +send_query(query: str, format: str = 'CSV') → StreamingResult +``` + +**参数** + +| 参数 | 类型 | 默认值 | 描述 | +|------------|--------|--------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `query` | str | *必需* | 要执行的 SQL 查询字符串 | +| `format` | str | `"CSV"` | 结果的输出格式。支持的格式:
• `"CSV"` - 逗号分隔值
• `"JSON"` - JSON 格式
• `"Arrow"` - Apache Arrow 格式(启用 record_batch() 方法)
• `"dataframe"` - Pandas DataFrame 片段
• `"arrowtable"` - PyArrow 表片段 | + +**返回** + +| 返回类型 | 描述 | +|----------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `StreamingResult` | 一个流式迭代器,用于查询结果,支持:
• 迭代器协议(for 循环)
• 上下文管理器协议(with 语句)
• 使用 fetch() 方法手动提取
• PyArrow RecordBatch 流式(仅限 Arrow 格式) | + +**引发** + +| 异常 | 条件 | +|----------------|--------------------------------------------------| +| `RuntimeError` | 如果查询执行失败 | +| `ImportError` | 如果所需的格式包未安装 | + +:::note +仅 “Arrow” 格式支持返回的 StreamingResult 上的 `record_batch()` 方法。 +::: + +**示例** + +```pycon +>>> conn = connect(":memory:") +>>> +>>> # Basic streaming +>>> stream = conn.send_query("SELECT number FROM numbers(1000)") +>>> for chunk in stream: +... print(f"Processing chunk: {len(chunk)} bytes") +``` + +```pycon +>>> # Using context manager for cleanup +>>> with conn.send_query("SELECT * FROM large_table") as stream: +... chunk = stream.fetch() +... while chunk: +... process_data(chunk) +... chunk = stream.fetch() +``` + +```pycon +>>> # Arrow format with RecordBatch streaming +>>> stream = conn.send_query("SELECT * FROM data", "Arrow") +>>> reader = stream.record_batch(rows_per_batch=10000) +>>> for batch in reader: +... print(f"Batch shape: {batch.num_rows} x {batch.num_columns}") +``` + +**另请参见** +- [`query()`](#chdb-state-sqlitelike-connection-query) - 用于非流式查询执行 +- `StreamingResult` - 流式结果迭代器 + +--- +### **class** `chdb.state.sqlitelike.Cursor` {#chdb-state-sqlitelike-cursor} + +基于:`object` + +```python +class chdb.state.sqlitelike.Cursor(connection) +``` + +--- +#### `close` {#cursor-close-none} + +关闭游标并清理资源。 + +此方法关闭游标并清理任何相关资源。 +调用此方法后,游标变得无效,无法用于进一步操作。 + +**语法** + +```python +close() → None +``` + +:::note +此方法是幂等的 - 多次调用是安全的。 +连接关闭时,游标也会自动关闭。 +::: + +**示例** + +```pycon +>>> cursor = conn.cursor() +>>> cursor.execute("SELECT 1") +>>> result = cursor.fetchone() +>>> cursor.close() # Cleanup cursor resources +``` + +--- +#### `column_names` {#chdb-state-sqlitelike-cursor-column_names} + +从最后执行的查询中返回列名列表。 + +此方法返回最近执行的 SELECT 查询中的列名。名称的返回顺序与它们在结果集中的出现顺序相同。 + +**语法** + +```python +column_names() → list +``` + +**返回** + +| 返回类型 | 描述 | +|----------|------------------------------------------------------------------------------------------| +| `list` | 列名字符串的列表,如果没有执行查询或查询未返回列,则返回空列表 | + +**示例** + +```pycon +>>> cursor = conn.cursor() +>>> cursor.execute("SELECT id, name, email FROM users LIMIT 1") +>>> print(cursor.column_names()) +['id', 'name', 'email'] +``` + +**另请参见** +- [`column_types()`](#chdb-state-sqlitelike-cursor-column_types) - 获取列类型信息 +- [`description`](#chdb-state-sqlitelike-cursor-description) - DB-API 2.0 列描述 + +--- +#### `column_types` {#chdb-state-sqlitelike-cursor-column_types} + +返回最后执行的查询中的列类型列表。 + +此方法返回最近执行的 SELECT 查询中的 ClickHouse 列类型名称。类型的返回顺序与它们在结果集中的出现顺序相同。 + +**语法** + +```python +column_types() → list +``` + +**返回** + +| 返回类型 | 描述 | +|----------|------------------------------------------------------------------------------| +| `list` | ClickHouse 类型名称字符串的列表,如果没有执行查询或查询未返回列,则返回空列表 | + +**示例** + +```pycon +>>> cursor = conn.cursor() +>>> cursor.execute("SELECT toInt32(1), toString('hello')") +>>> print(cursor.column_types()) +['Int32', 'String'] +``` + +**另请参见** +- [`column_names()`](#chdb-state-sqlitelike-cursor-column_names) - 获取列名信息 +- [`description`](#chdb-state-sqlitelike-cursor-description) - DB-API 2.0 列描述 + +--- +#### `commit` {#commit} + +提交任何待处理的事务。 + +此方法提交任何待处理的数据库事务。在 ClickHouse 中, +大多数操作是自动提交的,但此方法用于 +DB-API 2.0 兼容性。 + +:::note +ClickHouse 通常自动提交操作,因此通常不需要显式提交。 +此方法的提供是为了与标准 DB-API 2.0 工作流兼容。 +::: + +**语法** + +```python +commit() → None +``` + +**示例** + +```pycon +>>> cursor = conn.cursor() +>>> cursor.execute("INSERT INTO test VALUES (1, 'data')") +>>> cursor.commit() +``` + +--- +#### `property description : list` {#chdb-state-sqlitelike-cursor-description} + +根据 DB-API 2.0 规范返回列描述。 + +此属性返回描述最后执行的 SELECT 查询中每列的 7 项元组列表。每个元组包含: +(name, type_code, display_size, internal_size, precision, scale, null_ok) + +目前,仅提供名称和类型代码,其他字段设置为 None。 + +**返回** + +| 返回类型 | 描述 | +|----------|-------------------------------------------------------------------------------------| +| `list` | 描述每一列的 7 元组列表,如果没有执行 SELECT 查询,则返回空列表 | + +:::note +这遵循 DB-API 2.0 关于 cursor.description 的规范。 +在此实现中,只有前两个元素(名称和类型代码)包含有意义的数据。 +::: + +**示例** + +```pycon +>>> cursor = conn.cursor() +>>> cursor.execute("SELECT id, name FROM users LIMIT 1") +>>> for desc in cursor.description: +... print(f"Column: {desc[0]}, Type: {desc[1]}") +Column: id, Type: Int32 +Column: name, Type: String +``` + +**另请参见** +- [`column_names()`](#chdb-state-sqlitelike-cursor-column_names) - 仅获取列名 +- [`column_types()`](#chdb-state-sqlitelike-cursor-column_types) - 仅获取列类型 + +--- +#### `execute` {#execute} + +执行 SQL 查询并准备结果以供提取。 + +此方法执行 SQL 查询并准备结果以供使用 +提取方法检索。它处理结果数据的解析和 +ClickHouse 数据类型的自动类型转换。 + +**语法** + +```python +execute(query: str) → None +``` + +**参数:** + +| 参数 | 类型 | 描述 | +|------------|--------|---------------------------------| +| `query` | str | 要执行的 SQL 查询字符串 | + +**引发** + +| 异常 | 条件 | +|------------|----------------------------| +| `Exception` | 如果查询执行失败或结果解析失败 | + +:::note +此方法遵循 DB-API 2.0 规范,适用于 `cursor.execute()`。 +执行后,使用 `fetchone()`、`fetchmany()` 或 `fetchall()` 来 +检索结果。 +::: + +:::note +该方法会自动将 ClickHouse 数据类型转换为适当的 +Python 类型: + +- Int/UInt 类型 → int +- Float 类型 → float +- String/FixedString → str +- DateTime → datetime.datetime +- Date → datetime.date +- Bool → bool +::: + +**示例** + +```pycon +>>> cursor = conn.cursor() +>>> +>>> # Execute DDL +>>> cursor.execute("CREATE TABLE test (id INT, name String)") +>>> +>>> # Execute DML +>>> cursor.execute("INSERT INTO test VALUES (1, 'Alice')") +>>> +>>> # Execute SELECT and fetch results +>>> cursor.execute("SELECT * FROM test") +>>> rows = cursor.fetchall() +>>> print(rows) +((1, 'Alice'),) +``` + +**另请参见** +- [`fetchone()`](#chdb-state-sqlitelike-cursor-fetchone) - 获取单行 +- [`fetchmany()`](#chdb-state-sqlitelike-cursor-fetchmany) - 获取多行 +- [`fetchall()`](#chdb-state-sqlitelike-cursor-fetchall) - 获取所有剩余行 + +--- +#### `fetchall` {#chdb-state-sqlitelike-cursor-fetchall} + +从查询结果中获取所有剩余行。 + +此方法检索当前查询结果集中的所有剩余行,从当前游标位置开始。 +它返回一个行元组的元组,并应用适当的 Python 类型转换。 + +**语法** + +```python +fetchall() → tuple +``` + +**返回:** + +| 返回类型 | 描述 | +|----------|------------------------------------| +| `tuple` | 包含结果集所有剩余行元组的元组。如果没有行可用,则返回空元组 | + +:::warning 警告 +此方法一次性加载所有剩余行到内存中。对于大型结果集,请考虑使用 [`fetchmany()`](#chdb-state-sqlitelike-cursor-fetchmany) 来批量处理结果。 +::: + +**示例** + +```pycon +>>> cursor = conn.cursor() +>>> cursor.execute("SELECT id, name FROM users") +>>> all_users = cursor.fetchall() +>>> for user_id, user_name in all_users: +... print(f"User {user_id}: {user_name}") +``` + +**另请参见** +- [`fetchone()`](#chdb-state-sqlitelike-cursor-fetchone) - 获取单行 +- [`fetchmany()`](#chdb-state-sqlitelike-cursor-fetchmany) - 批量获取多行 + +--- +#### `fetchmany` {#chdb-state-sqlitelike-cursor-fetchmany} + +从查询结果中获取多行。 + +此方法从当前查询结果集中检索多达 'size' 行。它返回一个行元组的元组,每一行包含适当的 Python 类型转换的列值。 + +**语法** + +```python +fetchmany(size: int = 1) → tuple +``` + +**参数** + +| 参数 | 类型 | 默认值 | 描述 | +|------------|--------|--------|-----------------------------| +| `size` | int | `1` | 要获取的最大行数 | + +**返回** + +| 返回类型 | 描述 | +|----------|-----------------------------------------------------------------------------------| +| `tuple` | 包含多达 'size' 行元组的元组。如果结果集耗尽,可能包含更少的行 | + +:::note +此方法遵循 DB-API 2.0 规范。如果结果集耗尽,它会返回少于 'size' 的行。 +::: + +**示例** + +```pycon +>>> cursor = conn.cursor() +>>> cursor.execute("SELECT * FROM large_table") +>>> +>>> # Process results in batches +>>> while True: +... batch = cursor.fetchmany(100) # Fetch 100 rows at a time +... if not batch: +... break +... process_batch(batch) +``` + +**另请参见** +- [`fetchone()`](#chdb-state-sqlitelike-cursor-fetchone) - 获取单行 +- [`fetchall()`](#chdb-state-sqlitelike-cursor-fetchall) - 获取所有剩余行 + +--- +#### `fetchone` {#chdb-state-sqlitelike-cursor-fetchone} + +从查询结果中获取下一行。 + +此方法从当前查询结果集中检索下一个可用行。它返回一个元组,包含适当的 Python 类型转换的列值。 + +**语法** + +```python +fetchone() → tuple | None +``` + +**返回:** + +| 返回类型 | 描述 | +|----------------|-------------------------------------------------------------------------------| +| `Optional[tuple]` | 下一行作为列值的元组,如果没有更多行可用,则返回 None | + +:::note +此方法遵循 DB-API 2.0 规范。列值根据 +ClickHouse 列类型自动转换为适当的 Python 类型。 +::: + +**示例** + +```pycon +>>> cursor = conn.cursor() +>>> cursor.execute("SELECT id, name FROM users") +>>> row = cursor.fetchone() +>>> while row is not None: +... user_id, user_name = row +... print(f"User {user_id}: {user_name}") +... row = cursor.fetchone() +``` + +**另请参见** +- [`fetchmany()`](#chdb-state-sqlitelike-cursor-fetchmany) - 获取多行 +- [`fetchall()`](#chdb-state-sqlitelike-cursor-fetchall) - 获取所有剩余行 + +--- +### `chdb.state.sqlitelike` {#state-sqlitelike-to_arrowtable} + +将查询结果转换为 PyArrow 表。 + +此函数将 chdb 查询结果转换为 PyArrow 表格式, +提供高效的列式数据访问和与其他数据处理库的互操作性。 + +**语法** + +```python +chdb.state.sqlitelike.to_arrowTable(res) +``` + +**参数:** + +| 参数 | 类型 | 描述 | +|------------|--------|----------------------------------------------------| +| `res` | - | 从 chdb 查询结果对象,包含 Arrow 格式数据 | + +**返回** + +| 返回类型 | 描述 | +|-------------------|----------------------------------------| +| `pyarrow.Table` | 包含查询结果的 PyArrow 表 | + +**引发** + +| 异常 | 条件 | +|---------------|---------------------------------------------| +| `ImportError` | 如果未安装 pyarrow 或 pandas 包 | + +:::note +此函数需要同时安装 pyarrow 和 pandas。 +使用以下命令安装:`pip install pyarrow pandas` +::: + +:::warning 警告 +空结果返回一个没有模式的空 PyArrow 表。 +::: + +**示例** + +```pycon +>>> import chdb +>>> result = chdb.query("SELECT 1 as num, 'hello' as text", "Arrow") +>>> table = to_arrowTable(result) +>>> print(table.schema) +num: int64 +text: string +>>> print(table.to_pandas()) + num text +0 1 hello +``` + +--- +### `chdb.state.sqlitelike.to_df` {#state-sqlitelike-to_df} + +将查询结果转换为 Pandas DataFrame。 + +此函数通过先转换为 PyArrow 表,然后再转换为 DataFrame,将 chdb 查询结果转换为 Pandas DataFrame 格式。这样提供了使用 Pandas API 进行便捷数据分析的能力。 + +**语法** + +```python +chdb.state.sqlitelike.to_df(r) +``` + +**参数:** + +| 参数 | 类型 | 描述 | +|------------|--------|----------------------------------------------------| +| `r` | - | 从 chdb 查询结果对象,包含 Arrow 格式数据 | + +**返回:** + +| 返回类型 | 描述 | +|--------------------|---------------------------------------------------------------------------------| +| `pandas.DataFrame` | 包含查询结果的 DataFrame,具有适当的列名和数据类型 | + +**引发** + +| 异常 | 条件 | +|---------------|-------------------------------------------| +| `ImportError` | 如果未安装 pyarrow 或 pandas 包 | + +:::note +此函数使用多线程将 Arrow 转换为 Pandas,以提高大型数据集的性能。 +::: + +**另请参见** +- [`to_arrowTable()`](#chdb-state-sqlitelike-to_arrowtable) - 用于 PyArrow 表格式转换 + +**示例** + +```pycon +>>> import chdb +>>> result = chdb.query("SELECT 1 as num, 'hello' as text", "Arrow") +>>> df = to_df(result) +>>> print(df) + num text +0 1 hello +>>> print(df.dtypes) +num int64 +text object +dtype: object +``` +## DataFrame 集成 {#dataframe-integration} +### **class** `chdb.dataframe.Table` {#chdb-dataframe-table} + +基于: + +```python +class chdb.dataframe.Table(*args: Any, **kwargs: Any) +``` +## 数据库 API (DBAPI) 2.0 接口 {#database-api-interface} + +chDB 提供与数据库连接的 Python DB-API 2.0 兼容接口,允许您将 chDB 与期望标准数据库接口的工具和框架一起使用。 + +chDB DB-API 2.0 接口包括: + +- **连接**:数据库连接管理与连接字符串 +- **游标**:查询执行和结果检索 +- **类型系统**:与 DB-API 2.0 兼容的类型常量和转换器 +- **错误处理**:标准数据库异常层次结构 +- **线程安全**:级别 1 线程安全(线程可以共享模块但不能共享连接) + +--- +### 核心功能 {#core-functions} + +数据库 API (DBAPI) 2.0 接口实现以下核心功能: +#### `chdb.dbapi.connect` {#dbapi-connect} + +初始化新的数据库连接。 + +**语法** + +```python +chdb.dbapi.connect(*args, **kwargs) +``` + +**参数** + +| 参数 | 类型 | 默认值 | 描述 | +|------------|--------|---------|-----------------------------------------------| +| `path` | str | `None` | 数据库文件路径。对于内存数据库为 None | + +**引发** + +| 异常 | 条件 | +|----------------------------------|-----------------------------------| +| [`err.Error`](#chdb-dbapi-err-error) | 如果无法建立连接 | + +--- +#### `chdb.dbapi.get_client_info()` {#dbapi-get-client-info} + +获取客户端版本信息。 + +返回 chDB 客户端版本的字符串,以兼容 MySQLdb。 + +**语法** + +```python +chdb.dbapi.get_client_info() +``` + +**返回** + +| 返回类型 | 描述 | +|------------|------------------------------------------------| +| `str` | 版本字符串,格式为 'major.minor.patch' | + +--- +### 类型构造器 {#type-constructors} +#### `chdb.dbapi.Binary(x)` {#dbapi-binary} + +将 x 作为二进制类型返回。 + +此函数将输入转换为字节类型,以用于数据库字段,符合 DB-API 2.0 规范。 + +**语法** + +```python +chdb.dbapi.Binary(x) +``` + +**参数** + +| 参数 | 类型 | 描述 | +|------------|--------|--------------------------------------------| +| `x` | - | 要转换为二进制的输入数据 | + +**返回** + +| 返回类型 | 描述 | +|------------|------------------------------| +| `bytes` | 转换为字节的输入 | + +--- +### 连接类 {#connection-class} +#### **class** `chdb.dbapi.connections.Connection(path=None)` {#chdb-dbapi-connections-connection} + +基于:`object` + +与 chDB 数据库的 DB-API 2.0 兼容连接。 + +此类提供与 chDB 数据库连接和交互的标准 DB-API 接口。它支持内存和基于文件的数据库。 + +连接管理底层的 chDB 引擎,提供执行查询、管理事务(对于 ClickHouse 为无操作)和创建游标的方法。 + +```python +class chdb.dbapi.connections.Connection(path=None) +``` + +**参数** + +| 参数 | 类型 | 默认值 | 描述 | +|------------|--------|----------|-------------------------------------------------------------------------------------------------| +| `path` | str | `None` | 数据库文件路径。如果为 None,则使用内存数据库。可以是类似 'database.db' 的文件路径或 ':memory:' | + +**变量** + +| 变量 | 类型 | 描述 | +|------------|--------|-----------------------------------------------| +| `encoding` | str | 查询的字符编码,默认为 'utf8' | +| `open` | bool | 如果连接处于打开状态则为 True,若已关闭则为 False | + +**示例** + +```pycon +>>> # In-memory database +>>> conn = Connection() +>>> cursor = conn.cursor() +>>> cursor.execute("SELECT 1") +>>> result = cursor.fetchall() +>>> conn.close() +``` + +```pycon +>>> # File-based database +>>> conn = Connection('mydata.db') +>>> with conn.cursor() as cur: +... cur.execute("CREATE TABLE users (id INT, name STRING)") +... cur.execute("INSERT INTO users VALUES (1, 'Alice')") +>>> conn.close() +``` + +```pycon +>>> # Context manager usage +>>> with Connection() as cur: +... cur.execute("SELECT version()") +... version = cur.fetchone() +``` + +:::note +ClickHouse 不支持传统事务,因此 commit() 和 rollback() +操作为无操作,但为了兼容 DB-API 提供。 +::: + +--- +#### `close` {#dbapi-connection-close} + +关闭数据库连接。 + +关闭底层的 chDB 连接并将此连接标记为已关闭。 +对此连接的后续操作将引发错误。 + +**语法** + +```python +close() +``` + +**引发** + +| 异常 | 条件 | +|-------------------------------- |-----------------------------------| +| [`err.Error`](#chdb-dbapi-err-error) | 如果连接已关闭 | + +--- +#### `commit` {#dbapi-commit} + +提交当前事务。 + +**语法** + +```python +commit() +``` + +:::note +这对于 chDB/ClickHouse 是无操作的,因为它不支持传统事务。 为了兼容 DB-API 2.0 提供。 +::: + +--- +#### `cursor` {#dbapi-cursor} + +创建一个新的游标以执行查询。 + +**语法** + +```python +cursor(cursor=None) +``` + +**参数** + +| 参数 | 类型 | 描述 | +|------------|--------|-----------------------------------------| +| `cursor` | - | 被忽略,提供兼容性 | + +**返回** + +| 返回类型 | 描述 | +|------------|---------------------------------------| +| `Cursor` | 此连接的新游标对象 | + +**引发** + +| 异常 | 条件 | +|----------------------------------|---------------------------------------| +| [`err.Error`](#chdb-dbapi-err-error) | 如果连接已关闭 | + +**示例** + +```pycon +>>> conn = Connection() +>>> cur = conn.cursor() +>>> cur.execute("SELECT 1") +>>> result = cur.fetchone() +``` + +--- +#### `escape` {#escape} + +转义值以安全地包括在 SQL 查询中。 + +**语法** + +```python +escape(obj, mapping=None) +``` + +**参数** + +| 参数 | 类型 | 描述 | +|------------|--------|------------------------------------------| +| `obj` | - | 要转义的值(字符串,字节,数字等) | +| `mapping` | - | 可选字符映射以进行转义 | + +**返回** + +| 返回类型 | 描述 | +|------------|---------------------------------------------------------| +| - | 输入的转义版本,适合于 SQL 查询 | + +**示例** + +```pycon +>>> conn = Connection() +>>> safe_value = conn.escape("O'Reilly") +>>> query = f"SELECT * FROM users WHERE name = {safe_value}" +``` + +--- +#### `escape_string` {#escape-string} + +对字符串值进行转义以用于 SQL 查询。 + +**语法** + +```python +escape_string(s) +``` + +**参数** + +| 参数 | 类型 | 描述 | +|------------|--------|-----------------------------| +| `s` | str | 要转义的字符串 | + +**返回** + +| 返回类型 | 描述 | +|------------|---------------------------------------| +| `str` | 安全的转义字符串以包括在 SQL 中 | + +--- +#### `property open` {#property-open} + +检查连接是否打开。 + +**返回** + +| 返回类型 | 描述 | +|------------|------------------------------------------| +| `bool` | 如果连接是打开的,则为 True,关闭时为 False | + +--- +#### `query` {#dbapi-query} + +直接执行 SQL 查询并返回原始结果。 + +此方法绕过游标接口,直接执行查询。 +对于标准的 DB-API 使用,建议使用 cursor() 方法。 + +**语法** + +```python +query(sql, fmt='CSV') +``` + +**参数:** + +| 参数 | 类型 | 默认值 | 描述 | +|---------------|--------------|--------------|---------------------------------------------------------------------------| +| `sql` | str 或 bytes | *必需* | 要执行的 SQL 查询 | +| `fmt` | str | `"CSV"` | 输出格式。支持的格式包括 "CSV"、"JSON"、"Arrow"、"Parquet" 等等 | + +**返回** + +| 返回类型 | 描述 | +|------------|-----------------------------------| +| - | 以指定格式返回的查询结果 | + +**引发** + +| 异常 | 条件 | +|--------------------------------------------------|-------------------------------------| +| [`err.InterfaceError`](#chdb-dbapi-err-interfaceerror) | 如果连接已关闭或查询失败 | + +**示例** + +```pycon +>>> conn = Connection() +>>> result = conn.query("SELECT 1, 'hello'", "CSV") +>>> print(result) +"1,hello\n" +``` + +--- +#### `property resp` {#property-resp} + +获取最后查询响应。 + +**返回** + +| 返回类型 | 描述 | +|------------|------------------------------------------| +| - | 来自最后一次 query() 调用的原始响应 | + +:::note +每次直接调用 query() 时,此属性都会更新。 +它不反映通过游标执行的查询。 +::: + +--- +#### `rollback` {#rollback} + +回滚当前事务。 + +**语法** + +```python +rollback() +``` + +:::note +这对于 chDB/ClickHouse 是无操作的,因为它不支持传统事务。 为了兼容 DB-API 2.0 提供。 +::: + +--- +### 游标类 {#cursor-class} +#### **class** `chdb.dbapi.cursors.Cursor` {#chdb-dbapi-cursors-cursor} + +基于:`object` + +用于执行查询和获取结果的 DB-API 2.0 游标。 + +游标提供执行 SQL 语句、管理查询结果和在结果集间导航的方法。它支持参数绑定、批量操作,并遵循 DB-API 2.0 规范。 + +请勿直接创建 Cursor 实例。请使用 `Connection.cursor()` 代替。 + +```python +class chdb.dbapi.cursors.Cursor(connection) +``` + +| 变量 | 类型 | 描述 | +|-----------------|--------|-----------------------------------------------| +| `description` | tuple | 最近查询结果的列元数据 | +| `rowcount` | int | 最近查询影响的行数(如果未知则为 -1) | +| `arraysize` | int | 默认一次获取行数(默认为 1) | +| `lastrowid` | - | 最近插入行的 ID(如果适用) | +| `max_stmt_length` | int | executemany() 的最大语句大小(默认为 1024000) | + +**示例** + +```pycon +>>> conn = Connection() +>>> cur = conn.cursor() +>>> cur.execute("SELECT 1 as id, 'test' as name") +>>> result = cur.fetchone() +>>> print(result) # (1, 'test') +>>> cur.close() +``` + +:::note +请参见 [DB-API 2.0 Cursor 对象](https://www.python.org/dev/peps/pep-0249/#cursor-objects) 获取完整的规范细节。 +::: + +--- +#### `callproc` {#callproc} + +执行存储过程(占位实现)。 + +**语法** + +```python +callproc(procname, args=()) +``` + +**参数** + +| 参数 | 类型 | 描述 | +|--------------|----------|---------------------------------------------| +| `procname` | str | 要执行的存储过程名称 | +| `args` | sequence | 传递给过程的参数 | + +**返回** + +| 返回类型 | 描述 | +|-------------|------------------------------------------| +| `sequence` | 原始的 args 参数(未修改) | + +:::note +chDB/ClickHouse 不支持传统意义上的存储过程。 +此方法用于 DB-API 2.0 兼容性,但不执行任何实际操作。请使用 execute() 执行所有 SQL 操作。 +::: + +:::warning 兼容性 +这是一个占位实现。传统存储过程的特性,如 OUT/INOUT 参数、多结果集和服务器变量,未被底层 ClickHouse 引擎支持。 +::: + +--- +#### `close` {#dbapi-cursor-close} + +关闭游标并释放相关资源。 + +关闭后,游标变得不可用,任何操作都会引发异常。 +关闭游标会耗尽所有剩余数据,并释放底层游标。 + +**语法** + +```python +close() +``` + + +#### `execute` {#dbapi-execute} + +执行带有可选参数绑定的 SQL 查询。 + +此方法执行单个 SQL 语句,并可选地进行参数替换。 +它支持多种参数占位符样式,以提高灵活性。 + +**语法** + +```python +execute(query, args=None) +``` + +**参数** + +| 参数 | 类型 | 默认值 | 描述 | +|-------------|-------------------|-------------|-------------------------------------| +| `query` | str | *必填* | 要执行的 SQL 查询 | +| `args` | tuple/list/dict | `None` | 要绑定到占位符的参数 | + +**返回** + +| 返回类型 | 描述 | +|-------------|----------------------------------------| +| `int` | 受影响的行数(-1 如果未知) | + +**参数样式** + +| 样式 | 示例 | +|----------------------|----------------------------------------------------| +| 问号样式 | `"SELECT * FROM users WHERE id = ?"` | +| 命名样式 | `"SELECT * FROM users WHERE name = %(name)s"` | +| 格式样式 | `"SELECT * FROM users WHERE age = %s"`(遗留) | + +**示例** + +```pycon +>>> # Question mark parameters +>>> cur.execute("SELECT * FROM users WHERE id = ? AND age > ?", (123, 18)) +>>> +>>> # Named parameters +>>> cur.execute("SELECT * FROM users WHERE name = %(name)s", {'name': 'Alice'}) +>>> +>>> # No parameters +>>> cur.execute("SELECT COUNT(*) FROM users") +``` + +**引发异常** + +| 异常 | 条件 | +|-------------------------------------------------------|-------------------------------------------| +| [`ProgrammingError`](#chdb-dbapi-err-programmingerror) | 如果游标已关闭或查询格式不正确 | +| [`InterfaceError`](#chdb-dbapi-err-interfaceerror) | 如果在执行过程中发生数据库错误 | + +--- +#### `executemany(query, args)` {#chdb-dbapi-cursors-cursor-executemany} + +使用不同参数集多次执行查询。 + +此方法高效地多次执行相同的 SQL 查询,并使用不同的参数值。它特别适合用于批量 INSERT 操作。 + +**语法** + +```python +executemany(query, args) +``` + +**参数** + +| 参数 | 类型 | 描述 | +|-------------|-----------|----------------------------------------------| +| `query` | str | 要多次执行的 SQL 查询 | +| `args` | sequence | 每次执行的参数元组/字典/列表序列 | + +**返回** + +| 返回类型 | 描述 | +|-------------|--------------------------------------------------| +| `int` | 所有执行中受影响的行的总数 | + +**示例** + +```pycon +>>> # Bulk insert with question mark parameters +>>> users_data = [(1, 'Alice'), (2, 'Bob'), (3, 'Charlie')] +>>> cur.executemany("INSERT INTO users VALUES (?, ?)", users_data) +>>> +>>> # Bulk insert with named parameters +>>> users_data = [ +... {'id': 1, 'name': 'Alice'}, +... {'id': 2, 'name': 'Bob'} +... ] +>>> cur.executemany( +... "INSERT INTO users VALUES (%(id)s, %(name)s)", +... users_data +... ) +``` + +:::note +此方法通过优化查询执行过程来提高多行 INSERT 和 UPDATE 操作的性能。 +::: + +--- +#### `fetchall()` {#dbapi-fetchall} + +从查询结果中获取所有剩余行。 + +**语法** + +```python +fetchall() +``` + +**返回** + +| 返回类型 | 描述 | +|-------------|------------------------------------------| +| `list` | 表示所有剩余行的元组列表 | + +**引发异常** + +| 异常 | 条件 | +|-------------------------------------------------------|--------------------------------------------| +| [`ProgrammingError`](#chdb-dbapi-err-programmingerror) | 如果没有先调用 `execute()` | + +:::warning 警告 +此方法对于大型结果集可能会消耗大量内存。 +考虑在处理大数据集时使用 `fetchmany()`。 +::: + +**示例** + +```pycon +>>> cursor.execute("SELECT id, name FROM users") +>>> all_rows = cursor.fetchall() +>>> print(len(all_rows)) # Number of total rows +``` + +--- +#### `fetchmany` {#dbapi-fetchmany} + +从查询结果中获取多个行。 + +**语法** + +```python +fetchmany(size=1) +``` + +**参数** + +| 参数 | 类型 | 默认值 | 描述 | +|-------------|-------|---------|----------------------------------| +| `size` | int | `1` | 要获取的行数。如果未指定,则使用 cursor.arraysize | + +**返回** + +| 返回类型 | 描述 | +|-------------|---------------------------------------| +| `list` | 表示获取行的元组列表 | + +**引发异常** + +| 异常 | 条件 | +|-------------------------------------------------------|--------------------------------------------| +| [`ProgrammingError`](#chdb-dbapi-err-programmingerror) | 如果没有先调用 `execute()` | + +**示例** + +```pycon +>>> cursor.execute("SELECT id, name FROM users") +>>> rows = cursor.fetchmany(3) +>>> print(rows) # [(1, 'Alice'), (2, 'Bob'), (3, 'Charlie')] +``` + +--- +#### `fetchone` {#dbapi-fetchone} + +从查询结果中获取下一行。 + +**语法** + +```python +fetchone() +``` + +**返回** + +| 返回类型 | 描述 | +|--------------------------|--------------------------------------------------------------| +| `tuple or None` | 下一行作为元组,如果没有更多行,则返回 None | + +**引发异常** + +| 异常 | 条件 | +|-------------------------------------------------------|--------------------------------------------| +| [`ProgrammingError`](#chdb-dbapi-err-programmingerror) | 如果没有先调用 `execute()` | + +**示例** + +```pycon +>>> cursor.execute("SELECT id, name FROM users LIMIT 3") +>>> row = cursor.fetchone() +>>> print(row) # (1, 'Alice') +>>> row = cursor.fetchone() +>>> print(row) # (2, 'Bob') +``` + +--- +#### `max_stmt_length = 1024000` {#max-stmt-length} + +[`executemany()`](#chdb-dbapi-cursors-cursor-executemany) 生成的最大语句大小。 + +默认值为 1024000。 + +--- +#### `mogrify` {#mogrify} + +返回将发送到数据库的确切查询字符串。 + +此方法显示参数替换后的最终 SQL 查询,适合用于调试和日志记录。 + +**语法** + +```python +mogrify(query, args=None) +``` + +**参数** + +| 参数 | 类型 | 默认值 | 描述 | +|-------------|-------------------|-------------|-------------------------------------| +| `query` | str | *必填* | 带参数占位符的 SQL 查询 | +| `args` | tuple/list/dict | `None` | 要替换的参数 | + +**返回** + +| 返回类型 | 描述 | +|-------------|-----------------------------------------------| +| `str` | 带参数替换的最终 SQL 查询字符串 | + +**示例** + +```pycon +>>> cur.mogrify("SELECT * FROM users WHERE id = ?", (123,)) +"SELECT * FROM users WHERE id = 123" +``` + +:::note +此方法遵循 Psycopg 使用的 DB-API 2.0 扩展。 +::: + +--- +#### `nextset` {#nextset} + +移动到下一个结果集(不支持)。 + +**语法** + +```python +nextset() +``` + +**返回** + +| 返回类型 | 描述 | +|-------------|----------------------------------------------| +| `None` | 始终返回 None,因为不支持多个结果集 | + +:::note +chDB/ClickHouse 不支持来自单个查询的多个结果集。 +此方法是为了遵循 DB-API 2.0 规范,但始终返回 None。 +::: + +--- +#### `setinputsizes` {#setinputsizes} + +为参数设置输入大小(无操作实现)。 + +**语法** + +```python +setinputsizes(*args) +``` + +**参数** + +| 参数 | 类型 | 描述 | +|-------------|-------|----------------------------------------| +| `*args` | - | 参数大小规格(被忽略) | + +:::note +此方法没有任何功能,但根据 DB-API 2.0 规范是必需的。 +chDB 自动处理参数大小。 +::: + +--- +#### `setoutputsizes` {#setoutputsizes} + +设置输出列大小(无操作实现)。 + +**语法** + +```python +setoutputsizes(*args) +``` + +**参数** + +| 参数 | 类型 | 描述 | +|-------------|-------|-------------------------------------| +| `*args` | - | 列大小规格(被忽略) | + +:::note +此方法没有任何功能,但根据 DB-API 2.0 规范是必需的。 +chDB 自动处理输出大小。 +::: + +--- +### 错误类 {#error-classes} + +用于 chdb 数据库操作的异常类。 + +该模块提供了一个完整的异常类层次结构,用于处理 chdb 中与数据库相关的错误,遵循 Python 数据库 API 规范 v2.0。 + +异常层次结构如下: + +```default +StandardError +├── Warning +└── Error + ├── InterfaceError + └── DatabaseError + ├── DataError + ├── OperationalError + ├── IntegrityError + ├── InternalError + ├── ProgrammingError + └── NotSupportedError +``` + +每个异常类表示特定类别的数据库错误: + +| 异常 | 描述 | +|-------------------|-----------------------------------------------------| +| `Warning` | 数据库操作期间的非致命警告 | +| `InterfaceError` | 数据库接口本身的问题 | +| `DatabaseError` | 所有与数据库相关的错误的基类 | +| `DataError` | 数据处理中的问题(无效值、类型错误) | +| `OperationalError`| 数据库操作问题(连接性、资源) | +| `IntegrityError` | 约束违反(外键、唯一性) | +| `InternalError` | 数据库内部错误和损坏 | +| `ProgrammingError` | SQL 语法错误和 API 滥用 | +| `NotSupportedError`| 不支持的功能或操作 | + +:::note +这些异常类符合 Python DB API 2.0 规范,并为不同数据库操作提供一致的错误处理。 +::: + +**另见** +- [Python 数据库 API 规范 v2.0](https://peps.python.org/pep-0249/) +- `chdb.dbapi.connections` - 数据库连接管理 +- `chdb.dbapi.cursors` - 数据库游标操作 + +**示例** + +```pycon +>>> try: +... cursor.execute("SELECT * FROM nonexistent_table") +... except ProgrammingError as e: +... print(f"SQL Error: {e}") +... +SQL Error: Table 'nonexistent_table' doesn't exist +``` + +```pycon +>>> try: +... cursor.execute("INSERT INTO users (id) VALUES (1), (1)") +... except IntegrityError as e: +... print(f"Constraint violation: {e}") +... +Constraint violation: Duplicate entry '1' for key 'PRIMARY' +``` + +--- +#### **exception** `chdb.dbapi.err.DataError` {#chdb-dbapi-err-dataerror} + +基于:[`DatabaseError`](#chdb-dbapi-err-databaseerror) + +因处理数据的问题而引发的异常。 + +当数据库操作因处理数据的问题而失败时,会引发此异常,例如: + +- 零除法操作 +- 数值超出范围 +- 无效的日期/时间值 +- 字符串截断错误 +- 类型转换失败 +- 列类型的数据格式无效 + +**引发** + +| 异常 | 条件 | +|-------------------------------|-------------------------------------------------| +| [`DataError`](#chdb-dbapi-err-dataerror) | 当数据验证或处理失败时 | + +**示例** + +```pycon +>>> # Division by zero in SQL +>>> cursor.execute("SELECT 1/0") +DataError: Division by zero +``` + +```pycon +>>> # Invalid date format +>>> cursor.execute("INSERT INTO table VALUES ('invalid-date')") +DataError: Invalid date format +``` + +--- +#### **exception** `chdb.dbapi.err.DatabaseError` {#chdb-dbapi-err-databaseerror} + +基于:[`Error`](#chdb-dbapi-err-error) + +与数据库相关的错误引发的异常。 + +这是所有与数据库相关的错误的基类。它包括所有在数据库操作期间发生的错误,这些错误与数据库本身有关,而不是接口。 + +常见场景包括: + +- SQL 执行错误 +- 数据库连接问题 +- 交易相关问题 +- 数据库特定的约束违规 + +:::note +这作为更具体的数据库错误类型(如 [`DataError`](#chdb-dbapi-err-dataerror),[`OperationalError`](#chdb-dbapi-err-operationalerror) 等)的父类。 +::: + +--- +#### **exception** `chdb.dbapi.err.Error` {#chdb-dbapi-err-error} + +基于:[`StandardError`](#chdb-dbapi-err-standarderror) + +所有其他错误异常的基类(非 Warning)。 + +这是 chdb 中所有错误异常的基类,不包括警告。 +它作为所有阻止操作成功完成的数据库错误条件的父类。 + +:::note +此异常层次结构遵循 Python DB API 2.0 规范。 +::: + +**另见** +- [`Warning`](#chdb_dbapi_err_warning) - 适用于不会阻止操作完成的重要非致命警告 +#### **exception** `chdb.dbapi.err.IntegrityError` {#chdb-dbapi-err-integrityerror} + +基于:[`DatabaseError`](#chdb-dbapi-err-databaseerror) + +影响数据库关系完整性的异常。 + +当数据库操作违反完整性约束时,会引发此异常,包括: + +- 外键约束违反 +- 主键或唯一约束违反(重复键) +- 检查约束违反 +- NOT NULL 约束违反 +- 参照完整性违反 + +**引发** + +| 异常 | 条件 | +|-----------------------------------------------------|-------------------------------------------------| +| [`IntegrityError`](#chdb-dbapi-err-integrityerror) | 当数据库完整性约束被违反时 | + +**示例** + +```pycon +>>> # Duplicate primary key +>>> cursor.execute("INSERT INTO users (id, name) VALUES (1, 'John')") +>>> cursor.execute("INSERT INTO users (id, name) VALUES (1, 'Jane')") +IntegrityError: Duplicate entry '1' for key 'PRIMARY' +``` + +```pycon +>>> # Foreign key violation +>>> cursor.execute("INSERT INTO orders (user_id) VALUES (999)") +IntegrityError: Cannot add or update a child row: foreign key constraint fails +``` + +--- +#### **exception** `chdb.dbapi.err.InterfaceError` {#chdb-dbapi-err-interfaceerror} + +基于:[`Error`](#chdb-dbapi-err-error) + +与数据库接口相关的错误引发的异常,而不是与数据库本身有关的错误。 + +当数据库接口实现中出现问题时,便会引发此异常,例如: + +- 无效的连接参数 +- API 滥用(在已关闭连接上调用方法) +- 接口级协议错误 +- 模块导入或初始化失败 + +**引发** + +| 异常 | 条件 | +|-----------------------------------------------------|-----------------------------------------------------------------------| +| [`InterfaceError`](#chdb-dbapi-err-interfaceerror) | 当数据库接口遇到与数据库操作无关的错误时 | + +:::note +这些错误通常是编程错误或配置问题,可以通过修复客户端代码或配置来解决。 +::: + +--- +#### **exception** `chdb.dbapi.err.InternalError` {#chdb-dbapi-err-internalerror} + +基于:[`DatabaseError`](#chdb-dbapi-err-databaseerror) + +当数据库遇到内部错误时引发的异常。 + +当数据库系统遇到应用程序未导致的内部错误时,会引发此异常,例如: + +- 无效的游标状态(游标不再有效) +- 事务状态不一致(事务不同步) +- 数据库损坏问题 +- 内部数据结构损坏 +- 系统级数据库错误 + +**引发** + +| 异常 | 条件 | +|----------------------------------|-------------------------------------------| +| [`InternalError`](#chdb-dbapi-err-internalerror) | 当数据库遇到内部不一致时 | + +:::warning 警告 +内部错误可能表明需要数据库管理员关注的严重数据库问题。这些错误通常无法通过应用程序级重试逻辑恢复。 +::: + +:::note +这些错误通常超出了应用程序的控制范围,可能需要数据库重启或修复操作。 +::: + +--- +#### **exception** `chdb.dbapi.err.NotSupportedError` {#chdb-dbapi-err-notsupportederror} + +基于:[`DatabaseError`](#chdb-dbapi-err-databaseerror) + +当不支持某个方法或数据库 API 时引发的异常。 + +当应用程序尝试使用当前数据库配置或版本不支持的数据库功能或 API 方法时,会引发此异常,例如: + +- 在没有事务支持的连接上请求 `rollback()` +- 使用当前数据库版本不支持的高级 SQL 功能 +- 调用当前驱动程序未实现的方法 +- 尝试使用被禁用的数据库功能 + +**引发** + +| 异常 | 条件 | +|-----------------------------------------------------|----------------------------------------------| +| [`NotSupportedError`](#chdb_dbapi_err_notsupportederror) | 当访问不支持的数据库功能时 | + +**示例** + +```pycon +>>> # Transaction rollback on non-transactional connection +>>> connection.rollback() +NotSupportedError: Transactions are not supported +``` + +```pycon +>>> # Using unsupported SQL syntax +>>> cursor.execute("SELECT * FROM table WITH (NOLOCK)") +NotSupportedError: WITH clause not supported in this database version +``` + +:::note +检查数据库文档和驱动程序功能,以避免这些错误。在可能的情况下考虑优雅降级。 +::: + +--- +#### **exception** `chdb.dbapi.err.OperationalError` {#chdb-dbapi-err-operationalerror} + +基于:[`DatabaseError`](#chdb_dbapi_err_databaseerror) + +与数据库操作相关的错误引发的异常。 + +当数据库操作期间发生错误且不一定在程序员的控制之内时,会引发此异常,包括: + +- 意外与数据库断开连接 +- 找不到或无法访问数据库服务器 +- 事务处理失败 +- 处理过程中的内存分配错误 +- 磁盘空间或资源耗尽 +- 数据库服务器内部错误 +- 身份验证或授权失败 + +**引发** + +| 异常 | 条件 | +|----------------------------------------------------|--------------------------------------------------| +| [`OperationalError`](#chdb-dbapi-err-operationalerror) | 当因操作问题导致数据库操作失败时 | + +:::note +这些错误通常是暂时性的,可能通过重试操作或解决系统级问题来解决。 +::: + +:::warning 警告 +有些操作错误可能表示需要管理干预的严重系统问题。 +::: + +--- +#### **exception** `chdb.dbapi.err.ProgrammingError` {#chdb-dbapi-err-programmingerror} + +基于:[`DatabaseError`](#chdb-dbapi-err-databaseerror) + +数据库操作中的编程错误引发的异常。 + +当应用程序在使用数据库时出现编程错误时,会引发此异常,包括: + +- 表或列不存在 +- 创建时表或索引已存在 +- 语句中的 SQL 语法错误 +- 在准备语句中指定的参数数量错误 +- 无效的 SQL 操作(例如,非现有对象的 DROP 操作) +- 数据库 API 方法使用不当 + +**引发** + +| 异常 | 条件 | +|----------------------------------------------------|--------------------------------------------| +| [`ProgrammingError`](#chdb_dbapi_err_programmingerror) | 当 SQL 语句或 API 使用中存在错误时 | + +**示例** + +```pycon +>>> # Table not found +>>> cursor.execute("SELECT * FROM nonexistent_table") +ProgrammingError: Table 'nonexistent_table' doesn't exist +``` + +```pycon +>>> # SQL syntax error +>>> cursor.execute("SELCT * FROM users") +ProgrammingError: You have an error in your SQL syntax +``` + +```pycon +>>> # Wrong parameter count +>>> cursor.execute("INSERT INTO users (name, age) VALUES (%s)", ('John',)) +ProgrammingError: Column count doesn't match value count +``` + +--- +#### **exception** `chdb.dbapi.err.StandardError` {#chdb-dbapi-err-standarderror} + +基于:`Exception` + +与 chdb 操作相关的异常。 + +这是所有 chdb 相关异常的基类。它继承自 Python 内置的 Exception 类,并作为数据库操作异常层次结构的根。 + +:::note +此异常类遵循 Python DB API 2.0 规范,用于数据库异常处理。 +::: + +--- +#### **exception** `chdb.dbapi.err.Warning` {#chdb-dbapi-err-warning} + +基于:[`StandardError`](#chdb-dbapi-err-standarderror) + +因重要警告而引发的异常,例如插入时的数据截断等。 + +当数据库操作完成但存在重要警告时引发此异常,这些警告应引起应用程序的注意。 +常见场景包括: + +- 插入时数据截断 +- 数值转换中的精度损失 +- 字符集转换警告 + +:::note +这遵循 Python DB API 2.0 规范的警告异常。 +::: + +--- +### 模块常量 {#module-constants} +#### `chdb.dbapi.apilevel = '2.0'` {#apilevel} + +```python +str(object=’’) -> str +str(bytes_or_buffer[, encoding[, errors]]) -> str +``` + +使用给定对象创建一个新字符串对象。如果指定了编码或错误,则该对象必须暴露一个数据缓冲区,该缓冲区将使用给定的编码和错误处理解码。否则,返回 `object.__str__()` 的结果(如果定义了)或 `repr(object)`。 + +- 编码默认为 ‘utf-8’。 +- 错误默认为 ‘strict’。 + +--- +#### `chdb.dbapi.threadsafety = 1` {#threadsafety} + +```python +int([x]) -> integer +int(x, base=10) -> integer +``` + +将数字或字符串转换为整数,如果未给出参数,则返回 0。如果 x 是数字,则返回 x.__int__()。对于浮点数,这将向零截断。 + +如果 x 不是数字或给出了基数,则 x 必须是表示给定基数下的整数字面量的字符串、字节或字节数组实例。字面量可以用 ‘+’ 或 ‘-’ 前缀,并用空格包围。基数默认为 10。有效基数为 0 和 2-36。基数 0 意味着根据字符串解释基数作为整数字面量。 + +```python +>>> int(‘0b100’, base=0) +4 +``` + +--- +#### `chdb.dbapi.paramstyle = 'format'` {#paramstyle} + +```python +str(object=’’) -> str +str(bytes_or_buffer[, encoding[, errors]]) -> str +``` + +使用给定对象创建一个新字符串对象。如果编码或错误被指定,则该对象必须暴露一个数据缓冲区,该缓冲区将使用给定的编码和错误处理解码。否则,返回对象.__str__() 的结果(如果定义了)或 repr(object)。编码默认为 ‘utf-8’。错误默认为 ‘strict’。 + +--- +### 类型常量 {#type-constants} +#### `chdb.dbapi.STRING = frozenset({247, 253, 254})` {#string-type} + +用于 DB-API 2.0 类型比较的扩展 frozenset。 + +此类扩展了 frozenset,以支持 DB-API 2.0 类型比较语义。它允许灵活的类型检查,其中单个项可以使用等号和不等号运算符与集合进行比较。 + +这用于像 STRING、BINARY、NUMBER 等的类型常量,以启用像 “field_type == STRING” 的比较,其中 field_type 是单个类型值。 + +**示例** + +```pycon +>>> string_types = DBAPISet([FIELD_TYPE.STRING, FIELD_TYPE.VAR_STRING]) +>>> FIELD_TYPE.STRING == string_types # Returns True +>>> FIELD_TYPE.INT != string_types # Returns True +>>> FIELD_TYPE.BLOB in string_types # Returns False +``` + +--- +#### `chdb.dbapi.BINARY = frozenset({249, 250, 251, 252})` {#binary-type} + +用于 DB-API 2.0 类型比较的扩展 frozenset。 + +此类扩展了 frozenset,以支持 DB-API 2.0 类型比较语义。它允许灵活的类型检查,其中单个项可以使用等号和不等号运算符与集合进行比较。 + +这用于像 STRING、BINARY、NUMBER 等的类型常量,以启用像 “field_type == STRING” 的比较,其中 field_type 是单个类型值。 + +**示例** + +```pycon +>>> string_types = DBAPISet([FIELD_TYPE.STRING, FIELD_TYPE.VAR_STRING]) +>>> FIELD_TYPE.STRING == string_types # Returns True +>>> FIELD_TYPE.INT != string_types # Returns True +>>> FIELD_TYPE.BLOB in string_types # Returns False +``` + +--- +#### `chdb.dbapi.NUMBER = frozenset({0, 1, 3, 4, 5, 8, 9, 13})` {#number-type} + +用于 DB-API 2.0 类型比较的扩展 frozenset。 + +此类扩展了 frozenset,以支持 DB-API 2.0 类型比较语义。它允许灵活的类型检查,其中单个项可以使用等号和不等号运算符与集合进行比较。 + +这用于像 STRING、BINARY、NUMBER 等的类型常量,以启用像 “field_type == STRING” 的比较,其中 field_type 是单个类型值。 + +**示例** + +```pycon +>>> string_types = DBAPISet([FIELD_TYPE.STRING, FIELD_TYPE.VAR_STRING]) +>>> FIELD_TYPE.STRING == string_types # Returns True +>>> FIELD_TYPE.INT != string_types # Returns True +>>> FIELD_TYPE.BLOB in string_types # Returns False +``` + +--- +#### `chdb.dbapi.DATE = frozenset({10, 14})` {#date-type} + +用于 DB-API 2.0 类型比较的扩展 frozenset。 + +此类扩展了 frozenset,以支持 DB-API 2.0 类型比较语义。它允许灵活的类型检查,其中单个项可以使用等号和不等号运算符与集合进行比较。 + +这用于像 STRING、BINARY、NUMBER 等的类型常量,以启用像 “field_type == STRING” 的比较,其中 field_type 是单个类型值。 + +**示例** + +```pycon +>>> string_types = DBAPISet([FIELD_TYPE.STRING, FIELD_TYPE.VAR_STRING]) +>>> FIELD_TYPE.STRING == string_types # Returns True +>>> FIELD_TYPE.INT != string_types # Returns True +>>> FIELD_TYPE.BLOB in string_types # Returns False +``` + +--- +#### `chdb.dbapi.TIME = frozenset({11})` {#time-type} + +用于 DB-API 2.0 类型比较的扩展 frozenset。 + +此类扩展了 frozenset,以支持 DB-API 2.0 类型比较语义。它允许灵活的类型检查,其中单个项可以使用等号和不等号运算符与集合进行比较。 + +这用于像 STRING、BINARY、NUMBER 等的类型常量,以启用像 “field_type == STRING” 的比较,其中 field_type 是单个类型值。 + +**示例** + +```pycon +>>> string_types = DBAPISet([FIELD_TYPE.STRING, FIELD_TYPE.VAR_STRING]) +>>> FIELD_TYPE.STRING == string_types # Returns True +>>> FIELD_TYPE.INT != string_types # Returns True +>>> FIELD_TYPE.BLOB in string_types # Returns False +``` + +--- +#### `chdb.dbapi.TIMESTAMP = frozenset({7, 12})` {#timestamp-type} + +用于 DB-API 2.0 类型比较的扩展 frozenset。 + +此类扩展了 frozenset,以支持 DB-API 2.0 类型比较语义。它允许灵活的类型检查,其中单个项可以使用等号和不等号运算符与集合进行比较。 + +这用于像 STRING、BINARY、NUMBER 等的类型常量,以启用像 “field_type == STRING” 的比较,其中 field_type 是单个类型值。 + +**示例** + +```pycon +>>> string_types = DBAPISet([FIELD_TYPE.STRING, FIELD_TYPE.VAR_STRING]) +>>> FIELD_TYPE.STRING == string_types # Returns True +>>> FIELD_TYPE.INT != string_types # Returns True +>>> FIELD_TYPE.BLOB in string_types # Returns False +``` +#### `chdb.dbapi.DATETIME = frozenset({7, 12})` {#datetime-type} + +用于 DB-API 2.0 类型比较的扩展 frozenset。 + +此类扩展了 frozenset,以支持 DB-API 2.0 类型比较语义。它允许灵活的类型检查,其中单个项可以使用等号和不等号运算符与集合进行比较。 + +这用于像 STRING、BINARY、NUMBER 等的类型常量,以启用像 “field_type == STRING” 的比较,其中 field_type 是单个类型值。 + +**示例** + +```pycon +>>> string_types = DBAPISet([FIELD_TYPE.STRING, FIELD_TYPE.VAR_STRING]) +>>> FIELD_TYPE.STRING == string_types # Returns True +>>> FIELD_TYPE.INT != string_types # Returns True +>>> FIELD_TYPE.BLOB in string_types # Returns False +``` + +--- +#### `chdb.dbapi.ROWID = frozenset({})` {#rowid-type} + +用于 DB-API 2.0 类型比较的扩展 frozenset。 + +此类扩展了 frozenset,以支持 DB-API 2.0 类型比较语义。它允许灵活的类型检查,其中单个项可以使用等号和不等号运算符与集合进行比较。 + +这用于像 STRING、BINARY、NUMBER 等的类型常量,以启用像 “field_type == STRING” 的比较,其中 field_type 是单个类型值。 + +**示例** + +```pycon +>>> string_types = DBAPISet([FIELD_TYPE.STRING, FIELD_TYPE.VAR_STRING]) +>>> FIELD_TYPE.STRING == string_types # Returns True +>>> FIELD_TYPE.INT != string_types # Returns True +>>> FIELD_TYPE.BLOB in string_types # Returns False +``` + +**使用示例** + +基本查询示例: + +```python +import chdb.dbapi as dbapi + +print("chdb driver version: {0}".format(dbapi.get_client_info())) + + +# Create connection and cursor +conn = dbapi.connect() +cur = conn.cursor() + + +# Execute query +cur.execute('SELECT version()') +print("description:", cur.description) +print("data:", cur.fetchone()) + + +# Clean up +cur.close() +conn.close() +``` + +处理数据: + +```python +import chdb.dbapi as dbapi + +conn = dbapi.connect() +cur = conn.cursor() + + +# Create table +cur.execute(""" + CREATE TABLE employees ( + id UInt32, + name String, + department String, + salary Decimal(10,2) + ) ENGINE = Memory +""") + + +# Insert data +cur.execute(""" + INSERT INTO employees VALUES + (1, 'Alice', 'Engineering', 75000.00), + (2, 'Bob', 'Marketing', 65000.00), + (3, 'Charlie', 'Engineering', 80000.00) +""") + + +# Query data +cur.execute("SELECT * FROM employees WHERE department = 'Engineering'") + + +# Fetch results +print("Column names:", [desc[0] for desc in cur.description]) +for row in cur.fetchall(): + print(row) + +conn.close() +``` + +连接管理: + +```python +import chdb.dbapi as dbapi + + +# In-memory database (default) +conn1 = dbapi.connect() + + +# Persistent database file +conn2 = dbapi.connect("./my_database.chdb") + + +# Connection with parameters +conn3 = dbapi.connect("./my_database.chdb?log-level=debug&verbose") + + +# Read-only connection +conn4 = dbapi.connect("./my_database.chdb?mode=ro") + + +# Automatic connection cleanup +with dbapi.connect("test.chdb") as conn: + cur = conn.cursor() + cur.execute("SELECT count() FROM numbers(1000)") + result = cur.fetchone() + print(f"Count: {result[0]}") + cur.close() +``` + +**最佳实践** + +1. **连接管理**:完成后始终关闭连接和游标 +2. **上下文管理器**:使用 `with` 语句进行自动清理 +3. **批量处理**:对于大结果集使用 `fetchmany()` +4. **错误处理**:将数据库操作包装在 try-except 块中 +5. **参数绑定**:尽可能使用参数化查询 +6. **内存管理**:避免对非常大的数据集使用 `fetchall()` + +:::note +- chDB 的 DB-API 2.0 接口与大多数 Python 数据库工具兼容 +- 该接口提供 1 级线程安全(线程可以共享模块,但不能共享连接) +- 连接字符串支持与 chDB 会话相同的参数 +- 支持所有标准的 DB-API 2.0 异常 +::: + +:::warning 警告 +- 始终关闭游标和连接以避免资源泄漏 +- 大结果集应按批处理 +- 参数绑定语法遵循格式样式:`%s` +::: +## 用户定义函数 (UDF) {#user-defined-functions} + +用于 chDB 的用户定义函数模块。 + +此模块提供了在 chDB 中创建和管理用户定义函数 (UDF) 的功能。 +它允许您通过编写自定义 Python 函数来扩展 chDB 的能力,这些函数可以从 SQL 查询中调用。 +### `chdb.udf.chdb_udf` {#chdb-udf} + +用于 chDB Python UDF(用户定义函数)的装饰器。 + +**语法** + +```python +chdb.udf.chdb_udf(return_type='String') +``` + +**参数** + +| 参数 | 类型 | 默认值 | 描述 | +|---------------|-------|---------------|---------------------------------------------------------| +| `return_type` | str | `"String"` | 函数的返回类型。应该是 ClickHouse 数据类型之一 | + +**注意事项** + +1. 函数应无状态。仅支持 UDF,不支持 UDAF。 +2. 默认返回类型为字符串。返回类型应为 ClickHouse 数据类型之一。 +3. 函数应接受字符串类型的参数。所有参数均为字符串。 +4. 该函数将对每行输入调用。 +5. 函数应为纯 Python 函数。在函数中导入所有使用的模块。 +6. 使用的 Python 解释器与运行脚本时使用的相同。 + +**示例** + +```python +@chdb_udf() +def sum_udf(lhs, rhs): + return int(lhs) + int(rhs) + +@chdb_udf() +def func_use_json(arg): + import json + # ... use json module +``` + +--- +### `chdb.udf.generate_udf` {#generate-udf} + +生成用户定义函数 (UDF) 的配置和可执行脚本文件。 + +此函数创建 chDB 中用户定义函数 (UDF) 所需的文件: +1. 处理输入数据的 Python 可执行脚本 +2. 将 UDF 注册到 ClickHouse 的 XML 配置文件 + +**语法** + +```python +chdb.udf.generate_udf(func_name, args, return_type, udf_body) +``` + +**参数** + +| 参数 | 类型 | 描述 | +|---------------|-------|-----------------------------------------| +| `func_name` | str | UDF 函数的名称 | +| `args` | list | 函数的参数名称列表 | +| `return_type` | str | 函数的 ClickHouse 返回类型 | +| `udf_body` | str | UDF 函数的 Python 源代码主体 | + +:::note +此函数通常由 @chdb_udf 装饰器调用,用户不应直接调用。 +::: + +--- +## 工具 {#utilities} + +与 chDB 一起使用的实用函数和帮助程序。 + +此模块包含用于与 chDB 配合使用的各种实用函数,包括数据类型推断、数据转换帮助程序和调试工具。 + +--- +### `chdb.utils.convert_to_columnar` {#convert-to-columnar} + +将字典列表转换为列式格式。 + +此函数接受字典列表,并将其转换为一个字典,其中每个键对应于一列,每个值是该列值的列表。 +字典中缺失的值表示为 None。 + +**语法** + +```python +chdb.utils.convert_to_columnar(items: List[Dict[str, Any]]) → Dict[str, List[Any]] +``` + +**参数** + +| 参数 | 类型 | 描述 | +|-------------|------------------------|-------------------------------| +| `items` | `List[Dict[str, Any]]` | 要转换的字典列表 | + +**返回** + +| 返回类型 | 描述 | +|---------------------|--------------------------------------------------------------------------| +| `Dict[str, List[Any]]` | 一个字典,键作为列名,值作为列值的列表 | + +**示例** + +```pycon +>>> items = [ +... {"name": "Alice", "age": 30, "city": "New York"}, +... {"name": "Bob", "age": 25}, +... {"name": "Charlie", "city": "San Francisco"} +... ] +>>> convert_to_columnar(items) +{ + 'name': ['Alice', 'Bob', 'Charlie'], + 'age': [30, 25, None], + 'city': ['New York', None, 'San Francisco'] +} +``` + +--- +### `chdb.utils.flatten_dict` {#flatten-dict} + +扁平化嵌套字典。 + +此函数接受一个嵌套字典并将其扁平化,使用分隔符连接嵌套密钥。字典列表序列化为 JSON 字符串。 + +**语法** + +```python +chdb.utils.flatten_dict(d: Dict[str, Any], parent_key: str = '', sep: str = '_') → Dict[str, Any] +``` + +**参数** + +| 参数 | 类型 | 默认 | 描述 | +|--------------|--------------------|------------|-----------------------------------------------------| +| `d` | `Dict[str, Any]` | *必需* | 要扁平化的字典 | +| `parent_key` | str | `""` | 预先附加到每个键的基本键 | +| `sep` | str | `"_"` | 用于连接密钥之间的分隔符 | + +**返回** + +| 返回类型 | 描述 | +|---------------|-------------------------------| +| `Dict[str, Any]` | 一个扁平化字典 | + +**示例** + +```pycon +>>> nested_dict = { +... "a": 1, +... "b": { +... "c": 2, +... "d": { +... "e": 3 +... } +... }, +... "f": [4, 5, {"g": 6}], +... "h": [{"i": 7}, {"j": 8}] +... } +>>> flatten_dict(nested_dict) +{ + 'a': 1, + 'b_c': 2, + 'b_d_e': 3, + 'f_0': 4, + 'f_1': 5, + 'f_2_g': 6, + 'h': '[{"i": 7}, {"j": 8}]' +} +``` + +--- +### `chdb.utils.infer_data_type` {#infer-data-type} + +推断值列表的最合适数据类型。 + +此函数检查值列表并确定可以表示列表中所有值的最适合的数据类型。它考虑整数、无符号整数、十进制和浮点类型,如果值不能由任何数字类型表示或所有值为 None,则默认为“string”。 + +**语法** + +```python +chdb.utils.infer_data_type(values: List[Any]) → str +``` + +**参数** + +| 参数 | 类型 | 描述 | +|-------------|-------------------|---------------------------------------------| +| `values` | `List[Any]` | 要分析的值列表。值可以是任何类型 | + +**返回** + +| 返回类型 | 描述 | +|------------|----------------------------------------------------------------------------------------------------------------------------------------------------| +| `str` | 一个表示推断数据类型的字符串。可能的返回值为:”int8”、 “int16”、 “int32”、 “int64”、 “int128”、 “int256”、 “uint8”、 “uint16”、 “uint32”、 “uint64”、 “uint128”、 “uint256”、 “decimal128”、 “decimal256”、 “float32”、 “float64” 或 “string”。 | + +:::note +- 如果列表中的所有值都是 None,函数返回“string”。 +- 如果列表中的任何值是字符串,函数将立即返回“string”。 +- 函数假定数值可以根据其范围和精度表示为整数、十进制或浮点数。 +::: + +--- +### `chdb.utils.infer_data_types` {#infer-data-types} + +推断列式数据结构中每列的数据类型。 + +此函数分析每列中的值并根据数据的示例推断每列的最适合数据类型。 + +**语法** + +```python +chdb.utils.infer_data_types`(column_data: Dict[str, List[Any]], n_rows: int = 10000) → List[tuple] +``` + +**参数** + +| 参数 | 类型 | 默认 | 描述 | +|---------------|-------------------------|-----------|---------------------------------------------------------------------| +| `column_data` | `Dict[str, List[Any]]` | *必需* | 一个字典,其中键是列名,值是列值的列表 | +| `n_rows` | int | `10000` | 用于类型推断的样本行数 | + +**返回** + +| 返回类型 | 描述 | +|-------------|----------------------------------------------------------------------| +| `List[tuple]` | 一个元组列表,每个元组包含一个列名及其推断数据类型 | + +## 抽象基类 {#abstract-base-classes} +### **class** `chdb.rwabc.PyReader`(data: Any)` {#pyreader} + +基类: `ABC` + +```python +class chdb.rwabc.PyReader(data: Any) +``` + +--- +#### **abstractmethod** `read` {#read} + +从给定列读取指定数量的行并返回对象列表,每个对象是列值的序列。 + +```python +abstractmethod (col_names: List[str], count: int) → List[Any] +``` + +**参数** + +| 参数 | 类型 | 描述 | +|------------|-----------------|----------------------------| +| `col_names` | `List[str]` | 要读取的列名列表 | +| `count` | int | 最大读取行数 | + +**返回** + +| 返回类型 | 描述 | +|------------|--------------------------------| +| `List[Any]` | 按列返回的序列列表 | +### **class** `chdb.rwabc.PyWriter` {#pywriter} + +基类: `ABC` + +```python +class chdb.rwabc.PyWriter(col_names: List[str], types: List[type], data: Any) +``` + +--- +#### **abstractmethod** finalize {#finalize} + +组装并返回来自区块的最终数据。必须由子类实现。 + +```python +abstractmethod finalize() → bytes +``` + +**返回** + +| 返回类型 | 描述 | +|------------|---------------------------| +| `bytes` | 最终序列化的数据 | + +--- +#### **abstractmethod** `write` {#write} + +将数据列保存到区块中。必须由子类实现。 + +```python +abstractmethod write(col_names: List[str], columns: List[List[Any]]) → None +``` + +**参数** + +| 参数 | 类型 | 描述 | +|------------|---------------------|---------------------------------------------------------| +| `col_names` | `List[str]` | 正在写入的列名列表 | +| `columns` | `List[List[Any]]` | 列数据列表,每列由一个列表表示 | + +## 异常处理 {#exception-handling} +### **class** `chdb.ChdbError` {#chdberror} + +基类: `Exception` + +chDB 相关错误的基本异常类。 + +当 chDB 查询执行失败或遇到错误时,引发此异常。它继承自标准 Python Exception 类,并提供来自底层 ClickHouse 引擎的错误信息。 + +异常消息通常包含来自 ClickHouse 的详细错误信息,包括语法错误、类型不匹配、缺少表/列及其他查询执行问题。 + +**变量** + +| 变量 | 类型 | 描述 | +|------------|-------|--------------------------------------------| +| `args` | - | 包含错误消息及其他附加参数的元组 | + +**示例** + +```pycon +>>> try: +... result = chdb.query("SELECT * FROM non_existent_table") +... except chdb.ChdbError as e: +... print(f"Query failed: {e}") +Query failed: Table 'non_existent_table' doesn't exist +``` + +```pycon +>>> try: +... result = chdb.query("SELECT invalid_syntax FROM") +... except chdb.ChdbError as e: +... print(f"Syntax error: {e}") +Syntax error: Syntax error near 'FROM' +``` + +:::note +当底层 ClickHouse 引擎报告错误时,此异常由 chdb.query() 和相关函数自动引发。 +您应在处理可能失败的查询时捕获此异常,以在您的应用程序中提供适当的错误处理。 +::: +## 版本信息 {#version-information} +### `chdb.chdb_version = ('3', '6', '0')` {#chdb-version} + +内置不可变序列。 + +如果未给出参数,构造函数返回一个空元组。 +如果指定了可迭代对象,则元组从可迭代对象的项初始化。 + +如果参数是一个元组,则返回值是相同的对象。 + +--- +### `chdb.engine_version = '25.5.2.1'` {#engine-version} + +```python +str(object=’’) -> str +str(bytes_or_buffer[, encoding[, errors]]) -> str +``` + +从给定对象创建一个新的字符串对象。如果指定了编码或错误,则对象必须暴露一个数据缓冲区,该缓冲区将使用给定的编码和错误处理程序进行解码。否则,返回对象.__str__()(如果定义)或 repr(object)的结果。 + +- 编码默认为 ‘utf-8’。 +- 错误默认为 ‘strict’。 + +--- +### `chdb.__version__ = '3.6.0'` {#version} + +```python +str(object=’’) -> str +str(bytes_or_buffer[, encoding[, errors]]) -> str +``` + +从给定对象创建一个新的字符串对象。如果指定了编码或错误,则对象必须暴露一个数据缓冲区,该缓冲区将使用给定的编码和错误处理程序进行解码。否则,返回对象.__str__()(如果定义)或 repr(object)的结果。 + +- 编码默认为 ‘utf-8’。 +- 错误默认为 ‘strict’。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/api/python.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/api/python.md.hash new file mode 100644 index 00000000000..b830ffbafe7 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/api/python.md.hash @@ -0,0 +1 @@ +0fe561058e605fd4 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/getting-started.md b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/getting-started.md index f82b98c4399..d4d425cd8c1 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/getting-started.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/getting-started.md @@ -1,62 +1,63 @@ --- -'title': '使用 chDB 开始' +'title': '开始使用 chDB' 'sidebar_label': '开始使用' 'slug': '/chdb/getting-started' -'description': 'chDB 是一个由 ClickHouse 支持的内置 SQL OLAP 引擎' +'description': 'chDB 是一个由 ClickHouse 驱动的内嵌 SQL OLAP 引擎' 'keywords': - 'chdb' - 'embedded' - 'clickhouse-lite' - 'in-process' - 'in process' +'doc_type': 'guide' --- -# Getting started with chDB +# 开始使用 chDB -在本指南中,我们将使用 chDB 的 Python 变体进行快速入门。 -我们将首先查询存储在 S3 上的 JSON 文件,然后根据该 JSON 文件在 chDB 中创建一个表,并对数据进行一些查询。 -我们还将看到如何让查询以不同格式返回数据,包括 Apache Arrow 和 Pandas,最后,我们将学习如何查询 Pandas DataFrames。 +在本指南中,我们将使用 chDB 的 Python 版本进行操作。 +我们将从查询存储在 S3 上的 JSON 文件开始,然后根据该 JSON 文件在 chDB 中创建一个表,并对数据进行一些查询。 +我们还将看到如何使查询以不同格式返回数据,包括 Apache Arrow 和 Pandas,最后我们将学习如何查询 Pandas DataFrames。 -## Setup {#setup} +## 设置 {#setup} -让我们首先创建一个虚拟环境: +首先,让我们创建一个虚拟环境: ```bash python -m venv .venv source .venv/bin/activate ``` -现在我们将安装 chDB。 -确保您有版本 2.0.3 或更高版本: +接下来,我们将安装 chDB。 +确保您安装的版本是 2.0.3 或更高: ```bash pip install "chdb>=2.0.2" ``` -接下来,我们将安装 [ipython](https://ipython.org/): +现在我们将安装 [ipython](https://ipython.org/): ```bash pip install ipython ``` -我们将使用 `ipython` 来运行本指南中的命令,您可以通过运行以下命令启动: +我们将使用 `ipython` 来运行本指南中的命令,您可以通过运行以下命令来启动它: ```bash ipython ``` -我们还将使用 Pandas 和 Apache Arrow,因此让我们也安装这些库: +在本指南中,我们还将使用 Pandas 和 Apache Arrow,因此让我们也安装这些库: ```bash pip install pandas pyarrow ``` -## Querying a JSON file in S3 {#querying-a-json-file-in-s3} +## 查询 S3 中的 JSON 文件 {#querying-a-json-file-in-s3} 现在让我们看看如何查询存储在 S3 存储桶中的 JSON 文件。 -[YouTube dislikes dataset](/getting-started/example-datasets/youtube-dislikes) 包含超过 40 亿行 YouTube 视频的“喜欢”数据,数据截至 2021 年。 -我们将使用该数据集中其中一个 JSON 文件。 +[YouTube 不喜欢数据集](/getting-started/example-datasets/youtube-dislikes) 包含了截至 2021 年的超过 40 亿行不喜欢 YouTube 视频的数据。 +我们将使用该数据集中的一个 JSON 文件。 导入 chdb: @@ -64,7 +65,7 @@ pip install pandas pyarrow import chdb ``` -我们可以写以下查询来描述其中一个 JSON 文件的结构: +我们可以写以下查询以描述其中一个 JSON 文件的结构: ```python chdb.query( @@ -128,9 +129,9 @@ chdb.query( 336432 ``` -此文件包含略超过 300,000 条记录。 +该文件包含略多于 300,000 条记录。 -chdb 目前尚不支持传入查询参数,但我们可以提取路径并通过 f-String 传入。 +chdb 目前还不支持传入查询参数,但我们可以提取路径并通过 f-String 传入。 ```python path = 's3://clickhouse-public-datasets/youtube/original/files/youtubedislikes_20211127161229_18654868.1637897329_vid.json.zst' @@ -146,13 +147,13 @@ chdb.query( ``` :::warning -这样做对于在程序中定义的变量是可以的,但不要对用户提供的输入这样做,否则您的查询将面临 SQL 注入的风险。 +这样做对于程序中定义的变量是可以的,但不要对用户提供的输入这样做,否则您的查询将面临 SQL 注入风险。 ::: -## Configuring the output format {#configuring-the-output-format} +## 配置输出格式 {#configuring-the-output-format} -默认输出格式为 `CSV`,但我们可以通过 `output_format` 参数进行更改。 -chDB 支持 ClickHouse 数据格式,以及 [它自己的一些格式](/chdb/reference/data-formats.md),包括 `DataFrame`,其返回 Pandas DataFrame: +默认输出格式是 `CSV`,但我们可以通过 `output_format` 参数更改它。 +chDB 支持 ClickHouse 数据格式,以及 [一些自己的格式](/chdb/reference/data-formats.md),包括 `DataFrame`,返回 Pandas DataFrame: ```python result = chdb.query( @@ -175,7 +176,7 @@ print(result) 1 True 35307 ``` -或者如果我们想要返回 Apache Arrow 表: +或者如果我们想获取一个 Apache Arrow 表: ```python result = chdb.query( @@ -201,10 +202,10 @@ is_live_content: [[false,true]] count(): [[315746,20686]] ``` -## Creating a table from JSON file {#creating-a-table-from-json-file} +## 从 JSON 文件创建表 {#creating-a-table-from-json-file} 接下来,让我们看看如何在 chDB 中创建一个表。 -我们需要使用不同的 API 来做到这一点,所以让我们首先导入它: +我们需要使用不同的 API 来实现,因此让我们先导入它: ```python from chdb import session as chs @@ -212,7 +213,7 @@ from chdb import session as chs 接下来,我们将初始化一个会话。 如果我们希望会话持久化到磁盘,则需要提供一个目录名称。 -如果我们留空,则数据库将在内存中,且在我们终止 Python 进程时将丢失。 +如果留空,数据库将在内存中,并在我们终止 Python 进程后丢失。 ```python sess = chs.Session("gettingStarted.chdb") @@ -224,8 +225,8 @@ sess = chs.Session("gettingStarted.chdb") sess.query("CREATE DATABASE IF NOT EXISTS youtube") ``` -现在我们可以根据 JSON 文件的架构使用 `CREATE...EMPTY AS` 技术创建一个 `dislikes` 表。 -我们将使用 [`schema_inference_make_columns_nullable`](/operations/settings/formats/#schema_inference_make_columns_nullable) 设置,以免所有列类型都变为 `Nullable`。 +现在我们可以基于 JSON 文件中的模式使用 `CREATE...EMPTY AS` 技术创建一个 `dislikes` 表。 +我们将使用 [`schema_inference_make_columns_nullable`](/operations/settings/formats/#schema_inference_make_columns_nullable) 设置,以便列类型不会全部设为 `Nullable`。 ```python sess.query(f""" @@ -239,7 +240,7 @@ sess.query(f""" ) ``` -然后我们可以使用 `DESCRIBE` 子句检查架构: +然后我们可以使用 `DESCRIBE` 子句来检查架构: ```python sess.query(f""" @@ -292,8 +293,8 @@ sess.query(f""" ) ``` -我们也可以使用 `CREATE...AS` 技术一步完成这两个步骤。 -让我们使用该技术创建一个不同的表: +我们也可以将这两个步骤合并为一个,通过 `CREATE...AS` 技术进行。 +让我们使用该技术创建另一个表: ```python sess.query(f""" @@ -307,7 +308,7 @@ sess.query(f""" ) ``` -## Querying a table {#querying-a-table} +## 查询表 {#querying-a-table} 最后,让我们查询该表: @@ -338,16 +339,16 @@ df 9 RC Cars OFF Road 31952962 101503 49489 ``` -假设我们随后向 DataFrame 添加一个额外的列,以计算喜欢和不喜欢的比例。 +假设我们然后向 DataFrame 中添加一个额外的列来计算喜欢与不喜欢的比率。 我们可以写以下代码: ```python df["likeDislikeRatio"] = df["likeCount"] / df["dislikeCount"] ``` -## Querying a Pandas DataFrame {#querying-a-pandas-dataframe} +## 查询 Pandas DataFrame {#querying-a-pandas-dataframe} -然后我们可以从 chDB 查询该 DataFrame: +然后,我们可以从 chDB 查询该 DataFrame: ```python chdb.query( @@ -373,14 +374,14 @@ chdb.query( 9 RC Cars OFF Road 2.051021 ``` -您还可以在 [Querying Pandas developer guide](guides/querying-pandas.md) 中阅读有关查询 Pandas DataFrames 的更多信息。 +您还可以在 [查询 Pandas 开发者指南](guides/querying-pandas.md) 中阅读更多关于查询 Pandas DataFrames 的内容。 -## Next steps {#next-steps} +## 下一步 {#next-steps} -希望本指南已经为您提供了 chDB 的良好概述。 -要了解有关如何使用它的更多信息,请参见以下开发者指南: +希望本指南能够为您提供 chDB 的良好概述。 +要了解更多有关如何使用它的信息,请参阅以下开发者指南: -* [Querying Pandas DataFrames](guides/querying-pandas.md) -* [Querying Apache Arrow](guides/querying-apache-arrow.md) -* [Using chDB in JupySQL](guides/jupysql.md) -* [Using chDB with an existing clickhouse-local database](guides/clickhouse-local.md) +* [查询 Pandas DataFrames](guides/querying-pandas.md) +* [查询 Apache Arrow](guides/querying-apache-arrow.md) +* [在 JupySQL 中使用 chDB](guides/jupysql.md) +* [使用现有的 clickhouse-local 数据库的 chDB](guides/clickhouse-local.md) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/getting-started.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/getting-started.md.hash index 6c65b46e479..e21dcce1db5 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/getting-started.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/getting-started.md.hash @@ -1 +1 @@ -0b7a488f98a713a2 +b95df43787d70a89 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/guides/clickhouse-local.md b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/guides/clickhouse-local.md index 935cfa53a40..de97b72a218 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/guides/clickhouse-local.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/guides/clickhouse-local.md @@ -1,40 +1,41 @@ --- -'title': '使用 clickhouse-local 数据库' -'sidebar_label': '使用 clickhouse-local 数据库' +'title': '使用 clickhouse-local DATABASE' +'sidebar_label': '使用 clickhouse-local DATABASE' 'slug': '/chdb/guides/clickhouse-local' -'description': '学习如何与 chDB 一起使用 clickhouse-local 数据库' +'description': '学习如何使用 clickhouse-local DATABASE 与 chDB' 'keywords': - 'chdb' - 'clickhouse-local' +'doc_type': 'guide' --- -[clickhouse-local](/operations/utilities/clickhouse-local) 是一个带有嵌入版本 ClickHouse 的 CLI。 -它赋予用户使用 ClickHouse 的能力,而无需安装服务器。 +[clickhouse-local](/operations/utilities/clickhouse-local) 是一个嵌入了 ClickHouse 的命令行工具。 +它使用户能够使用 ClickHouse 而无需安装服务器。 在本指南中,我们将学习如何从 chDB 使用 clickhouse-local 数据库。 ## Setup {#setup} -让我们首先创建一个虚拟环境: +首先创建一个虚拟环境: ```bash python -m venv .venv source .venv/bin/activate ``` -现在我们将安装 chDB。 -确保您拥有 2.0.2 或更高版本: +现在我们将安装 chDB。 +确保你安装的版本是 2.0.2 或更高版本: ```bash pip install "chdb>=2.0.2" ``` -现在我们要安装 [ipython](https://ipython.org/): +现在我们将安装 [ipython](https://ipython.org/): ```bash pip install ipython ``` -我们将使用 `ipython` 来运行本指南中的其余命令,您可以通过运行以下命令启动它: +我们将使用 `ipython` 来运行本指南中的命令,你可以通过运行以下命令启动它: ```bash ipython @@ -42,14 +43,14 @@ ipython ## Installing clickhouse-local {#installing-clickhouse-local} -下载和安装 clickhouse-local 的过程与 [下载和安装 ClickHouse](/install) 相同。 -我们可以通过运行以下命令来完成这一步: +下载和安装 clickhouse-local 的过程与 [下载和安装 ClickHouse](/install) 相同。 +我们可以通过运行以下命令来实现: ```bash curl https://clickhouse.com/ | sh ``` -为了通过将数据持久化到目录中来启动 clickhouse-local,我们需要传入 `--path`: +要启动 clickhouse-local 并将数据持久化到某个目录中,我们需要传递一个 `--path` 参数: ```bash ./clickhouse -m --path demo.chdb @@ -57,7 +58,7 @@ curl https://clickhouse.com/ | sh ## Ingesting data into clickhouse-local {#ingesting-data-into-clickhouse-local} -默认数据库仅在内存中存储数据,因此我们需要创建一个命名数据库,以确保我们所摄取的任何数据都持久保存在磁盘上。 +默认数据库仅存储内存中的数据,因此我们需要创建一个命名数据库,以确保我们输入的任何数据都持久化到磁盘。 ```sql CREATE DATABASE foo; @@ -72,7 +73,7 @@ SELECT rand() AS number FROM numbers(10_000_000); ``` -让我们写一个查询来查看我们得到了哪些数据: +让我们写一个查询来查看我们有哪些数据: ```sql SELECT quantilesExact(0, 0.5, 0.75, 0.99)(number) AS quants @@ -83,8 +84,8 @@ FROM foo.randomNumbers └───────────────────────────────────────┘ ``` -完成后,确保您从 CLI 中 `exit;`,因为只有一个进程可以在这个目录上保持锁定。 -如果不这样做,当我们尝试从 chDB 连接到数据库时,将会出现以下错误: +完成后,请确保从 CLI 中 `exit;`,因为只有一个进程可以锁定该目录。 +如果我们不这样做,当尝试从 chDB 连接到数据库时会出现以下错误: ```text ChdbError: Code: 76. DB::Exception: Cannot lock file demo.chdb/status. Another server instance in same directory is already running. (CANNOT_OPEN_FILE) @@ -117,7 +118,7 @@ Row 1: quants: [0,9976599,2147776478,4209286886] ``` -我们还可以从 chDB 向这个数据库插入数据: +我们也可以从 chDB 向这个数据库插入数据: ```python sess.query(""" diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/guides/clickhouse-local.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/guides/clickhouse-local.md.hash index c97fc9bc1c0..72ed8351d28 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/guides/clickhouse-local.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/guides/clickhouse-local.md.hash @@ -1 +1 @@ -70254ba9c82343dc +622c08a0671e11d6 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/guides/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/guides/index.md index 15d9a733868..513467d26b9 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/guides/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/guides/index.md @@ -1,25 +1,29 @@ --- 'title': 'chDB 指南' 'slug': '/chdb/guides' -'description': 'chDB 指南的索引页' +'description': 'chDB 指南的索引页面' 'keywords': - 'chdb' - 'guides' +'doc_type': 'landing-page' --- -查看下面的 chDB 开发者指南: +请查看我们下面的 chDB 开发者指南: + | 页面 | 描述 | |-----|-----| +| [如何查询远程 ClickHouse 服务器](/chdb/guides/query-remote-clickhouse) | 本指南将学习如何从 chDB 查询远程 ClickHouse 服务器。 | +| [如何使用 chDB 查询 Apache Arrow](/chdb/guides/apache-arrow) | 本指南将学习如何使用 chDB 查询 Apache Arrow 表 | +| [如何查询 S3 存储桶中的数据](/chdb/guides/querying-s3) | 学习如何使用 chDB 查询 S3 存储桶中的数据。 | +| [如何使用 chDB 查询 Pandas DataFrames](/chdb/guides/pandas) | 学习如何使用 chDB 查询 Pandas DataFrames | | [如何查询 Parquet 文件](/chdb/guides/querying-parquet) | 学习如何使用 chDB 查询 Parquet 文件。 | -| [如何查询 S3 桶中的数据](/chdb/guides/querying-s3) | 学习如何使用 chDB 查询 S3 桶中的数据。 | -| [使用 clickhouse-local 数据库](/chdb/guides/clickhouse-local) | 学习如何使用 chDB 操作 clickhouse-local 数据库。 | -| [如何使用 chDB 查询 Pandas DataFrames](/chdb/guides/pandas) | 学习如何使用 chDB 查询 Pandas DataFrames。 | | [JupySQL 和 chDB](/chdb/guides/jupysql) | 如何为 Bun 安装 chDB | -| [如何查询远程 ClickHouse 服务器](/chdb/guides/query-remote-clickhouse) | 在本指南中,我们将学习如何从 chDB 查询远程 ClickHouse 服务器。 | -| [如何使用 chDB 查询 Apache Arrow](/chdb/guides/apache-arrow) | 在本指南中,我们将学习如何使用 chDB 查询 Apache Arrow 表。 | +| [使用 clickhouse-local 数据库](/chdb/guides/clickhouse-local) | 学习如何使用 chDB 使用 clickhouse-local 数据库 | + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/guides/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/guides/index.md.hash index b507cde2646..105b639f490 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/guides/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/guides/index.md.hash @@ -1 +1 @@ -e27c68e90d9b656a +ffc7fe8c836f634c diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/guides/jupysql.md b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/guides/jupysql.md index f4c26c69e99..c14c8696b97 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/guides/jupysql.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/guides/jupysql.md @@ -6,51 +6,54 @@ 'keywords': - 'chdb' - 'JupySQL' +'doc_type': 'guide' --- import Image from '@theme/IdealImage'; import PlayersPerRank from '@site/static/images/chdb/guides/players_per_rank.png'; -[JupySQL](https://jupysql.ploomber.io/en/latest/quick-start.html) 是一个 Python 库,允许你在 Jupyter 笔记本和 IPython shell 中运行 SQL。在本指南中,我们将学习如何使用 chDB 和 JupySQL 查询数据。 +[JupySQL](https://jupysql.ploomber.io/en/latest/quick-start.html) 是一个 Python 库,允许您在 Jupyter notebooks 和 IPython shell 中运行 SQL。 +在本指南中,我们将学习如何使用 chDB 和 JupySQL 查询数据。

-## 安装 {#setup} +## 设置 {#setup} -让我们先创建一个虚拟环境: +让我们首先创建一个虚拟环境: ```bash python -m venv .venv source .venv/bin/activate ``` -然后,我们将安装 JupySQL、IPython 和 Jupyter Lab: +接下来,我们将安装 JupySQL、IPython 和 Jupyter Lab: ```bash pip install jupysql ipython jupyterlab ``` -我们可以在 IPython 中使用 JupySQL,可以通过运行以下命令启动: +我们可以在 IPython 中使用 JupySQL,通过运行以下命令启动: ```bash ipython ``` -或者在 Jupyter Lab 中,通过运行: +或者在 Jupyter Lab 中,运行: ```bash jupyter lab ``` :::note -如果你使用的是 Jupyter Lab,你需要先创建一个笔记本,然后才能继续后面的指南。 +如果您使用 Jupyter Lab,您需要先创建一个笔记本,然后再按照其余指南进行操作。 ::: ## 下载数据集 {#downloading-a-dataset} -我们将使用 [Jeff Sackmann 的 tennis_atp](https://github.com/JeffSackmann/tennis_atp) 数据集,该数据集包含关于球员及其排名随时间变化的元数据。让我们开始下载排名文件: +我们将使用 [Jeff Sackmann的 tennis_atp](https://github.com/JeffSackmann/tennis_atp) 数据集,其中包含有关选手及其排名的元数据。 +让我们首先下载排名文件: ```python from urllib.request import urlretrieve @@ -74,7 +77,8 @@ for file in files: from chdb import dbapi ``` -我们将创建一个 chDB 连接。任何我们持久化的数据将保存到 `atp.chdb` 目录: +然后我们将创建一个 chDB 连接。 +我们持久化的任何数据将保存到 `atp.chdb` 目录中: ```python conn = dbapi.connect(path="atp.chdb") @@ -87,15 +91,16 @@ conn = dbapi.connect(path="atp.chdb") %sql conn --alias chdb ``` -接下来,我们将显示显示限制,以便查询结果不会被截断: +接下来,我们将显示显示限制,以便查询的结果不会被截断: ```python %config SqlMagic.displaylimit = None ``` -## 查询 CSV 文件中的数据 {#querying-data-in-csv-files} +## 在 CSV 文件中查询数据 {#querying-data-in-csv-files} -我们下载了一堆以 `atp_rankings` 为前缀的文件。让我们使用 `DESCRIBE` 子句来了解模式: +我们下载了一批以 `atp_rankings` 为前缀的文件。 +让我们使用 `DESCRIBE` 子句了解模式: ```python %%sql @@ -115,7 +120,7 @@ SETTINGS describe_compact_output=1, +--------------+-------+ ``` -我们还可以直接对这些文件编写 `SELECT` 查询,以查看数据的样子: +我们还可以直接对这些文件写一个 `SELECT` 查询,以查看数据的样子: ```python %sql SELECT * FROM file('atp_rankings*.csv') LIMIT 1 @@ -129,7 +134,8 @@ SETTINGS describe_compact_output=1, +--------------+------+--------+--------+ ``` -数据格式有点奇怪。让我们清理一下这些数据,并使用 `REPLACE` 子句返回清理后的 `ranking_date`: +数据的格式有点奇怪。 +让我们清理一下日期,并使用 `REPLACE` 子句返回清理后的 `ranking_date`: ```python %%sql @@ -160,7 +166,8 @@ SETTINGS schema_inference_make_columns_nullable=0 ## 将 CSV 文件导入 chDB {#importing-csv-files-into-chdb} -现在我们将把这些 CSV 文件中的数据存储在一个表中。默认数据库不会将数据持久化到磁盘,因此我们需要先创建另一个数据库: +现在我们将把这些 CSV 文件中的数据存储到一个表中。 +默认数据库不会将数据持久化到磁盘,因此我们需要先创建另一个数据库: ```python %sql CREATE DATABASE atp @@ -203,9 +210,10 @@ SETTINGS schema_inference_make_columns_nullable=0 +--------------+------+--------+--------+ ``` -看起来不错 - 输出,如预期的,跟直接查询 CSV 文件时相同。 +看起来不错——输出与直接查询 CSV 文件时预期的结果相同。 -我们将对球员元数据执行相同的过程。这次数据都在一个 CSV 文件中,所以让我们下载该文件: +我们将对选手的元数据执行相同的过程。 +这次数据全部在一个单一的 CSV 文件中,因此让我们下载那个文件: ```python _ = urlretrieve( @@ -214,9 +222,10 @@ _ = urlretrieve( ) ``` -然后根据 CSV 文件的内容创建一个名为 `players` 的表。我们还将清理 `dob` 字段,以使其成为 `Date32` 类型。 +然后根据 CSV 文件的内容创建一个名为 `players` 的表。 +我们还将清理 `dob` 字段,使其成为 `Date32` 类型。 -> 在 ClickHouse 中,`Date` 类型仅支持从 1970 年开始的日期。由于 `dob` 列包含 1970 年之前的日期,因此我们将使用 `Date32` 类型。 +> 在 ClickHouse 中,`Date` 类型仅支持1970年以后的日期。由于 `dob` 列包含1970年之前的日期,因此我们将使用 `Date32` 类型。 ```python %%sql @@ -259,9 +268,11 @@ SETTINGS schema_inference_make_columns_nullable=0 ## 查询 chDB {#querying-chdb} -数据摄取完成,现在是有趣的部分 - 查询数据! +数据摄取完成,现在是有趣的部分——查询数据! -网球选手根据他们在比赛中的表现获得积分。每位球员在 52 周的滚动期间获得积分。我们将编写一个查询,找出每位球员累积的最大积分以及他们当时的排名: +网球选手根据他们在比赛中的表现获得积分。 +每位选手在 52 周内的积分累计。 +我们将编写一个查询,以找到每位选手的最高积分及其当时的排名: ```python %%sql @@ -293,11 +304,12 @@ LIMIT 10 +------------+-----------+-----------+------+------------+ ``` -有趣的是,这个列表中的一些球员在积分总数上没有达到第一名,但依然累积了很多积分。 +有趣的是,这个列表中的一些选手在积分总数上未能成为第一。 ## 保存查询 {#saving-queries} -我们可以使用 `--save` 参数在与 `%%sql` 魔法相同的行上保存查询。`--no-execute` 参数意味着将跳过查询执行。 +我们可以使用 `--save` 参数在与 `%%sql` 魔法相同的行上保存查询。 +`--no-execute` 参数意味着将跳过查询执行。 ```python %%sql --save best_points --no-execute @@ -311,7 +323,8 @@ GROUP BY ALL ORDER BY maxPoints DESC ``` -当我们运行一个保存的查询时,它将在执行之前被转换为公共表表达式 (CTE)。在下面的查询中,我们计算了球员在排名第一时获得的最大积分: +当我们运行保存的查询时,它将在执行之前被转换为公共表表达式 (CTE)。 +在以下查询中,我们计算当选手排名第一时所获得的最高积分: ```python %sql select * FROM best_points WHERE rank=1 @@ -340,13 +353,15 @@ ORDER BY maxPoints DESC ## 使用参数查询 {#querying-with-parameters} -我们还可以在查询中使用参数。参数只是普通变量: +我们也可以在查询中使用参数。 +参数只是普通变量: ```python rank = 10 ``` -然后我们可以在查询中使用 `{{variable}}` 语法。以下查询找出在首次进入前 10 名以及最后一次在前 10 名之间天数最少的球员: +然后我们可以在查询中使用 `{{variable}}` 语法。 +以下查询找到这些选手,他们首次进入前 10 名和最后一次进入前 10 名之间的天数最少: ```python %%sql @@ -382,9 +397,11 @@ LIMIT 10 ## 绘制直方图 {#plotting-histograms} -JupySQL 还具有有限的图表功能。我们可以创建箱线图或直方图。 +JupySQL 也具有有限的图表功能。 +我们可以创建箱线图或直方图。 -我们将创建一个直方图,但首先让我们编写(并保存)一个计算每个球员在前 100 名中取得的排名的查询。我们将能够利用此查询创建一个计算获得每项排名的球员数量的直方图: +我们将创建一个直方图,但首先让我们编写 (并保存) 一个查询,该查询计算每位选手在前 100 名中所达到的排名。 +我们将能够利用此查询创建一个直方图,以计算每个排名上有多少选手: ```python %%sql --save players_per_rank --no-execute @@ -393,7 +410,7 @@ FROM atp.rankings WHERE rank <= 100 ``` -然后,我们可以通过运行以下命令来创建直方图: +然后我们可以通过运行以下命令创建直方图: ```python from sql.ggplot import ggplot, geom_histogram, aes @@ -407,4 +424,4 @@ plot = ( ) ``` -ATP 数据集中球员排名的直方图 +ATP 数据集中选手排名的直方图 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/guides/jupysql.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/guides/jupysql.md.hash index 5f97fe001e0..59f4f3c3f26 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/guides/jupysql.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/guides/jupysql.md.hash @@ -1 +1 @@ -a6d7a009fd2b2644 +b1a7781811cdb9e9 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/guides/query-remote-clickhouse.md b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/guides/query-remote-clickhouse.md index d54d87a802b..b69ab74690c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/guides/query-remote-clickhouse.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/guides/query-remote-clickhouse.md @@ -6,13 +6,14 @@ 'keywords': - 'chdb' - 'clickhouse' +'doc_type': 'guide' --- 在本指南中,我们将学习如何从 chDB 查询远程 ClickHouse 服务器。 ## 设置 {#setup} -让我们首先创建一个虚拟环境: +让我们先创建一个虚拟环境: ```bash python -m venv .venv @@ -20,33 +21,33 @@ source .venv/bin/activate ``` 现在我们将安装 chDB。 -确保您拥有版本 2.0.2 或更高版本: +确保您的版本为 2.0.2 或更高: ```bash pip install "chdb>=2.0.2" ``` -现在我们将安装 pandas 和 ipython: +接下来,我们将安装 pandas 和 ipython: ```bash pip install pandas ipython ``` -我们将使用 `ipython` 来运行本指南其余部分中的命令,您可以通过运行以下命令启动它: +我们将使用 `ipython` 来运行指南中的命令,您可以通过运行以下命令来启动它: ```bash ipython ``` -您也可以在 Python 脚本中或在您喜欢的笔记本中使用这些代码。 +您也可以在 Python 脚本或您喜欢的笔记本中使用这些代码。 ## ClickPy 简介 {#an-intro-to-clickpy} 我们将要查询的远程 ClickHouse 服务器是 [ClickPy](https://clickpy.clickhouse.com)。 -ClickPy 记录了所有 PyPI 包的下载情况,并让您通过 UI 探索包的统计信息。 -底层数据库可以使用 `play` 用户进行查询。 +ClickPy 跟踪所有 PyPI 包的下载,并通过用户界面让您探索包的统计信息。 +底层数据库可以通过 `play` 用户进行查询。 -您可以通过 [它的 GitHub 仓库](https://github.com/ClickHouse/clickpy) 了解更多关于 ClickPy 的信息。 +您可以在 [其 GitHub 仓库](https://github.com/ClickHouse/clickpy) 中了解更多关于 ClickPy 的信息。 ## 查询 ClickPy ClickHouse 服务 {#querying-the-clickpy-clickhouse-service} @@ -56,11 +57,11 @@ ClickPy 记录了所有 PyPI 包的下载情况,并让您通过 UI 探索包 import chdb ``` -我们将使用 `remoteSecure` 函数查询 ClickPy。 +我们将使用 `remoteSecure` 函数来查询 ClickPy。 此函数至少需要主机名、表名和用户名。 -我们可以编写以下查询,以返回 [`openai` 包](https://clickpy.clickhouse.com/dashboard/openai) 每日的下载数量,并将其作为 Pandas DataFrame 返回: - +我们可以写以下查询,以返回 [`openai` 包](https://clickpy.clickhouse.com/dashboard/openai) 每天的下载次数,结果为 Pandas DataFrame: + ```python query = """ SELECT @@ -94,7 +95,7 @@ openai_df.sort_values(by=["x"], ascending=False).head(n=10) 2383 2024-09-23 1777554 ``` -现在让我们做同样的事情来返回 [`scikit-learn`](https://clickpy.clickhouse.com/dashboard/scikit-learn) 的下载量: +现在我们来做同样的事情,以返回 [`scikit-learn`](https://clickpy.clickhouse.com/dashboard/scikit-learn) 的下载次数: ```python query = """ @@ -131,7 +132,7 @@ sklearn_df.sort_values(by=["x"], ascending=False).head(n=10) ## 合并 Pandas DataFrames {#merging-pandas-dataframes} -我们现在有两个 DataFrame,可以根据日期(这是 `x` 列)像这样将它们合并在一起: +我们现在有两个 DataFrame,我们可以根据日期(即 `x` 列)将它们合并在一起,如下所示: ```python df = openai_df.merge( @@ -151,7 +152,7 @@ df.head(n=5) 4 2018-03-02 5 23842 ``` -然后我们可以像这样计算 Open AI 下载与 `scikit-learn` 下载的比例: +然后,我们可以计算 Open AI 下载与 `scikit-learn` 下载的比例,如下所示: ```python df['ratio'] = df['y_openai'] / df['y_sklearn'] @@ -169,8 +170,8 @@ df.head(n=5) ## 查询 Pandas DataFrames {#querying-pandas-dataframes} -接下来,假设我们想找出比率最好和最差的日期。 -我们可以回到 chDB 并计算这些值: +接下来,假设我们想要找到下载比例最高和最低的日期。 +我们可以返回到 chDB 并计算这些值: ```python chdb.query(""" @@ -187,4 +188,4 @@ FROM Python(df) 0 0.693855 2024-09-19 0.000003 2020-02-09 ``` -如果您想了解更多关于查询 Pandas DataFrames 的信息,请参阅 [Pandas DataFrames 开发者指南](querying-pandas.md)。 +如果您想了解更多关于查询 Pandas DataFrames 的信息,请参见 [Pandas DataFrames 开发者指南](querying-pandas.md)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/guides/query-remote-clickhouse.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/guides/query-remote-clickhouse.md.hash index 1fe1e5218e9..37f9cc9afb9 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/guides/query-remote-clickhouse.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/guides/query-remote-clickhouse.md.hash @@ -1 +1 @@ -ab345efcc1f61943 +c63bc1c67e93d664 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/guides/querying-apache-arrow.md b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/guides/querying-apache-arrow.md index 9e6f371bbca..adcf33b79e1 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/guides/querying-apache-arrow.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/guides/querying-apache-arrow.md @@ -6,22 +6,23 @@ 'keywords': - 'chdb' - 'Apache Arrow' +'doc_type': 'guide' --- -[Apache Arrow](https://arrow.apache.org/) 是一种标准化的列式内存格式,已在数据社区中获得了广泛的认可。 +[Apache Arrow](https://arrow.apache.org/) 是一种标准化的列式内存格式,在数据社区中获得了广泛的关注。 在本指南中,我们将学习如何使用 `Python` 表函数查询 Apache Arrow。 ## 设置 {#setup} -首先,让我们创建一个虚拟环境: +首先,我们创建一个虚拟环境: ```bash python -m venv .venv source .venv/bin/activate ``` -现在我们将安装 chDB。 -确保您安装的版本为 2.0.2 或更高: +现在我们将安装 chDB。 +确保您有 2.0.2 或更高版本: ```bash pip install "chdb>=2.0.2" @@ -33,17 +34,17 @@ pip install "chdb>=2.0.2" pip install pyarrow pandas ipython ``` -我们将使用 `ipython` 来运行本指南中的命令,您可以通过运行以下命令来启动它: +我们将使用 `ipython` 在指南的其余部分中运行命令,您可以通过运行以下命令启动它: ```bash ipython ``` -您还可以在 Python 脚本或您喜欢的笔记本中使用代码。 +您也可以在 Python 脚本或您喜欢的笔记本中使用这些代码。 ## 从文件创建 Apache Arrow 表 {#creating-an-apache-arrow-table-from-a-file} -首先,我们下载 [Ookla 数据集](https://github.com/teamookla/ookla-open-data) 的一个 Parquet 文件,使用 [AWS CLI 工具](https://aws.amazon.com/cli/): +首先,让我们下载 [Ookla 数据集](https://github.com/teamookla/ookla-open-data) 的一个 Parquet 文件,使用 [AWS CLI 工具](https://aws.amazon.com/cli/): ```bash aws s3 cp \ @@ -51,8 +52,8 @@ aws s3 cp \ s3://ookla-open-data/parquet/performance/type=mobile/year=2023/quarter=2/2023-04-01_performance_mobile_tiles.parquet . ``` -:::note -如果您想下载更多文件,请使用 `aws s3 ls` 获取所有文件的列表,然后更新上面的命令。 +:::note +如果您想下载更多文件,请使用 `aws s3 ls` 获取所有文件的列表,然后更新上述命令。 ::: 接下来,我们将从 `pyarrow` 包中导入 Parquet 模块: @@ -67,7 +68,7 @@ import pyarrow.parquet as pq arrow_table = pq.read_table("./2023-04-01_performance_mobile_tiles.parquet") ``` -模式如下所示: +架构如下所示: ```python arrow_table.schema @@ -87,7 +88,7 @@ tests: int64 devices: int64 ``` -我们可以通过调用 `shape` 属性来获取行数和列数: +我们可以通过调用 `shape` 属性来获取行和列的计数: ```python arrow_table.shape @@ -99,14 +100,14 @@ arrow_table.shape ## 查询 Apache Arrow {#querying-apache-arrow} -现在让我们从 chDB 查询 Arrow 表。 -首先,让我们导入 chDB: +现在让我们从 chDB 查询 Arrow 表。 +首先,导入 chDB: ```python import chdb ``` -然后我们可以描述该表: +然后我们可以描述表: ```python chdb.query(""" @@ -141,7 +142,7 @@ chdb.query("SELECT count() FROM Python(arrow_table)", "DataFrame") 0 3864546 ``` -现在,让我们做一些更有趣的事情。 +现在,让我们做一些更有趣的事情。 以下查询排除了 `quadkey` 和 `tile.*` 列,然后计算所有剩余列的平均值和最大值: ```python diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/guides/querying-apache-arrow.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/guides/querying-apache-arrow.md.hash index c567d915e37..6f20f6722fb 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/guides/querying-apache-arrow.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/guides/querying-apache-arrow.md.hash @@ -1 +1 @@ -55698e72afc0928a +371b57d604cd4014 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/guides/querying-pandas.md b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/guides/querying-pandas.md index c83c51185d5..850f4c7dcf8 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/guides/querying-pandas.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/guides/querying-pandas.md @@ -7,15 +7,16 @@ - 'chDB' - 'Pandas' 'show_related_blogs': true +'doc_type': 'guide' --- -[Pandas](https://pandas.pydata.org/) 是一个流行的 Python 数据处理和分析库。 -在 chDB 的 2 版本中,我们提高了查询 Pandas DataFrames 的性能,并引入了 `Python` 表函数。 +[Pandas](https://pandas.pydata.org/) 是一个流行的用于数据操作和分析的 Python 库。 +在 chDB 的 2 版本中,我们改进了查询 Pandas DataFrames 的性能,并引入了 `Python` 表函数。 在本指南中,我们将学习如何使用 `Python` 表函数查询 Pandas。 ## 设置 {#setup} -让我们首先创建一个虚拟环境: +首先,让我们创建一个虚拟环境: ```bash python -m venv .venv @@ -23,29 +24,29 @@ source .venv/bin/activate ``` 现在我们将安装 chDB。 -确保您使用的是 2.0.2 或更高版本: +确保你拥有 2.0.2 版本或更高版本: ```bash pip install "chdb>=2.0.2" ``` -接下来,我们将安装 Pandas 和其他几个库: +接下来,我们将安装 Pandas 和其他一些库: ```bash pip install pandas requests ipython ``` -我们将使用 `ipython` 在本指南的其余部分运行命令,您可以通过运行以下命令启动: +我们将使用 `ipython` 执行本指南中剩余的命令,可以通过运行以下命令启动: ```bash ipython ``` -您也可以在 Python 脚本或您喜欢的笔记本中使用该代码。 +你也可以在 Python 脚本或你喜欢的笔记本中使用这些代码。 ## 从 URL 创建 Pandas DataFrame {#creating-a-pandas-dataframe-from-a-url} -我们将从 [StatsBomb GitHub 仓库](https://github.com/statsbomb/open-data/tree/master?tab=readme-ov-file) 查询一些数据。 +我们将从 [StatsBomb GitHub 代码库](https://github.com/statsbomb/open-data/tree/master?tab=readme-ov-file) 查询一些数据。 首先,让我们导入 requests 和 pandas: ```python @@ -53,7 +54,7 @@ import requests import pandas as pd ``` -然后,我们将加载一个比赛的 JSON 文件到 DataFrame 中: +然后,我们将其中一场比赛的 JSON 文件加载到 DataFrame 中: ```python response = requests.get( @@ -62,7 +63,7 @@ response = requests.get( matches_df = pd.json_normalize(response.json(), sep='_') ``` -让我们看看我们将处理的数据: +让我们看看我们将要处理的数据: ```python matches_df.iloc[0] @@ -114,7 +115,7 @@ referee_country_name Brazi Name: 0, dtype: object ``` -接下来,我们将加载一个事件的 JSON 文件,并向该 DataFrame 添加一个名为 `match_id` 的列: +接下来,我们将加载一个事件 JSON 文件,并向该 DataFrame 添加一个名为 `match_id` 的列: ```python response = requests.get( @@ -124,7 +125,7 @@ events_df = pd.json_normalize(response.json(), sep='_') events_df["match_id"] = 3943077 ``` -然后,让我们看看第一行的数据: +再一次,让我们看看第一行的数据: ```python with pd.option_context("display.max_rows", None): @@ -165,14 +166,14 @@ Name: 0, dtype: object import chdb ``` -我们可以通过使用 `Python` 表函数查询 Pandas DataFrames: +我们可以使用 `Python` 表函数查询 Pandas DataFrames: ```sql SELECT * FROM Python() ``` -因此,如果我们想列出 `matches_df` 中的列,可以写如下: +所以,如果我们想列出 `matches_df` 中的列,我们可以编写如下内容: ```python chdb.query(""" @@ -282,8 +283,8 @@ LIMIT 10 ## 联接 Pandas DataFrames {#joining-pandas-dataframes} -我们还可以在查询中将 DataFrames 连接在一起。 -例如,为了获取比赛的概况,我们可以写出以下查询: +我们还可以在查询中连接 DataFrames。 +例如,要获取比赛概览,我们可以编写如下查询: ```python chdb.query(""" @@ -311,10 +312,10 @@ away_shots 19 Name: 0, dtype: object ``` -## 从 DataFrame 填充表 {#populating-a-table-from-a-dataframe} +## 从 DataFrame 填充表格 {#populating-a-table-from-a-dataframe} 我们还可以从 DataFrames 创建并填充 ClickHouse 表。 -如果我们想在 chDB 中创建一个表,需要使用有状态会话 API。 +如果我们想在 chDB 中创建一个表,我们需要使用有状态会话 API。 让我们导入会话模块: @@ -344,7 +345,7 @@ FROM Python(events_df) """) ``` -然后我们可以运行查询,返回最顶端的传球接受者: +然后我们可以运行查询,以返回接球最多的球员: ```python sess.query(""" @@ -373,7 +374,7 @@ LIMIT 10 ## 联接 Pandas DataFrame 和表 {#joining-a-pandas-dataframe-and-table} -最后,我们还可以更新我们的联接查询,将 `matches_df` DataFrame 与 `statsbomb.events` 表联接: +最后,我们还可以更新我们的联接查询,将 `matches_df` DataFrame 与 `statsbomb.events` 表连接: ```python sess.query(""" diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/guides/querying-pandas.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/guides/querying-pandas.md.hash index a7037f9dccf..1449879ae97 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/guides/querying-pandas.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/guides/querying-pandas.md.hash @@ -1 +1 @@ -039a64c3db1b11f5 +5b126d990139b54f diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/guides/querying-parquet.md b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/guides/querying-parquet.md index 1de4109a66b..3dc41ad5789 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/guides/querying-parquet.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/guides/querying-parquet.md @@ -6,9 +6,10 @@ 'keywords': - 'chdb' - 'parquet' +'doc_type': 'guide' --- -许多世界上的数据存储在 Amazon S3 桶中。 +很多世界数据存储在 Amazon S3 存储桶中。 在本指南中,我们将学习如何使用 chDB 查询这些数据。 ## 设置 {#setup} @@ -20,37 +21,37 @@ python -m venv .venv source .venv/bin/activate ``` -现在我们将安装 chDB。 -确保您拥有版本 2.0.2 或更高版本: +现在我们将安装 chDB。 +确保您拥有 2.0.2 版本或更高版本: ```bash pip install "chdb>=2.0.2" ``` -接下来,我们要安装 IPython: +接下来,我们将安装 IPython: ```bash pip install ipython ``` -我们将使用 `ipython` 来运行本指南中的命令,您可以通过运行以下命令来启动它: +我们将使用 `ipython` 来运行本指南其余部分中的命令,您可以通过运行以下命令来启动它: ```bash ipython ``` -您也可以在 Python 脚本或您最喜欢的笔记本中使用这些代码。 +您也可以在 Python 脚本或您喜欢的笔记本中使用这些代码。 -## 探索 Parquet 元数据 {#exploring-parquet-metadata} +## 查看 Parquet 元数据 {#exploring-parquet-metadata} -我们将探索来自 [Amazon reviews](/getting-started/example-datasets/amazon-reviews) 数据集的 Parquet 文件。 +我们将探索来自 [Amazon reviews](/getting-started/example-datasets/amazon-reviews) 数据集的 Parquet 文件。 但首先,让我们安装 `chDB`: ```python import chdb ``` -在查询 Parquet 文件时,我们可以使用 [`ParquetMetadata`](/interfaces/formats/ParquetMetadata) 输入格式,使其返回 Parquet 元数据而不是文件内容。 +在查询 Parquet 文件时,我们可以使用 [`ParquetMetadata`](/interfaces/formats/ParquetMetadata) 输入格式,使其返回 Parquet 元数据,而不是文件内容。 让我们使用 `DESCRIBE` 子句查看使用此格式时返回的字段: ```python @@ -77,8 +78,8 @@ columns Array(Tuple(name String, path String, max_definition_level UInt64, max_r row_groups Array(Tuple(num_columns UInt64, num_rows UInt64, total_uncompressed_size UInt64, total_compressed_size UInt64, columns Array(Tuple(name String, path String, total_compressed_size UInt64, total_uncompressed_size UInt64, have_statistics Bool, statistics Tuple(num_values Nullable(UInt64), null_count Nullable(UInt64), distinct_count Nullable(UInt64), min Nullable(String), max Nullable(String)))))) ``` -现在我们来看看该文件的元数据。 -`columns` 和 `row_groups` 都包含许多属性的元组数组,因此我们暂时将其排除。 +现在我们来看看这个文件的元数据。 +`columns` 和 `row_groups` 都包含许多属性的元组数组,因此我们暂时将其排除在外。 ```python query = """ @@ -104,11 +105,11 @@ total_uncompressed_size: 14615827169 total_compressed_size: 9272262304 ``` -从此输出中,我们了解到该 Parquet 文件有超过 4000 万行,分为 42 个行组,每行有 15 列数据。 -行组是将数据水平逻辑分区为行。 -每个行组都有相关的元数据,查询工具可以利用这些元数据高效地查询文件。 +从这个输出中,我们了解到这个 Parquet 文件有超过 4000 万行,分为 42 个行组,每行有 15 列数据。 +行组是将数据按行逻辑水平分区的方式。 +每个行组都有相关的元数据,查询工具可以利用这些元数据有效地查询文件。 -让我们看看其中一个行组: +让我们来看看其中一个行组: ```python query = """ @@ -153,8 +154,8 @@ chdb.query(query, 'DataFrame') ## 查询 Parquet 文件 {#querying-parquet-files} -接下来,让我们查询文件的内容。 -我们可以通过调整上述查询以移除 `ParquetMetadata`,然后计算所有评论中最受欢迎的 `star_rating`: +接下来,让我们查询文件的内容。 +我们可以通过调整上面的查询来删除 `ParquetMetadata`,然后,例如,计算所有评论中最受欢迎的 `star_rating`: ```python query = """ @@ -178,5 +179,5 @@ chdb.query(query, 'DataFrame') 4 5 27078664 27.08 million ``` -有趣的是,五星评价的数量超过了所有其他评级的总和! -看起来人们喜欢 Amazon 上的产品,或者如果他们不喜欢,那么他们根本就不提交评级。 +有趣的是,5 星评论的数量比其他所有评分加起来还多! +看起来人们喜欢亚马逊的产品,或者如果不喜欢,他们就不会提交评分。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/guides/querying-parquet.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/guides/querying-parquet.md.hash index 513b356b2e0..e3d700213db 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/guides/querying-parquet.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/guides/querying-parquet.md.hash @@ -1 +1 @@ -988a838efd05b5ea +53d1d5a8e309aeda diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/guides/querying-s3-bucket.md b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/guides/querying-s3-bucket.md index a948f1fe98a..272adf55466 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/guides/querying-s3-bucket.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/guides/querying-s3-bucket.md @@ -1,19 +1,20 @@ --- -'title': '如何在 S3 bucket 中查询数据' +'title': '如何在 S3 存储桶中查询数据' 'sidebar_label': '在 S3 中查询数据' 'slug': '/chdb/guides/querying-s3' -'description': '了解如何使用 chDB 查询 S3 bucket 中的数据。' +'description': '学习如何使用 chDB 在 S3 存储桶中查询数据。' 'keywords': - 'chdb' - 's3' +'doc_type': 'guide' --- -世界上很多数据存储在 Amazon S3 存储桶中。 +很多世界上的数据存储在 Amazon S3 桶中。 在本指南中,我们将学习如何使用 chDB 查询这些数据。 ## 设置 {#setup} -我们首先创建一个虚拟环境: +首先让我们创建一个虚拟环境: ```bash python -m venv .venv @@ -21,36 +22,36 @@ source .venv/bin/activate ``` 现在我们将安装 chDB。 -确保您有版本 2.0.2 或更高版本: +确保你有版本 2.0.2 或更高版本: ```bash pip install "chdb>=2.0.2" ``` -接下来我们要安装 IPython: +现在我们要安装 IPython: ```bash pip install ipython ``` -我们将使用 `ipython` 来运行本指南余下部分的命令,您可以通过运行以下命令启动它: +我们将使用 `ipython` 运行本指南其余部分中的命令,你可以通过运行以下命令来启动它: ```bash ipython ``` -您也可以在 Python 脚本或您喜欢的笔记本中使用这些代码。 +你也可以在 Python 脚本或你喜欢的笔记本中使用这些代码。 -## 列出 S3 存储桶中的文件 {#listing-files-in-an-s3-bucket} +## 列出 S3 桶中的文件 {#listing-files-in-an-s3-bucket} -让我们开始列出 [包含亚马逊评论的 S3 存储桶](/getting-started/example-datasets/amazon-reviews) 中的所有文件。 -为此,我们可以使用 [`s3` 表函数](/sql-reference/table-functions/s3),并传入文件的路径或文件集的通配符。 +让我们首先列出 [一个包含亚马逊评论的 S3 桶](/getting-started/example-datasets/amazon-reviews) 中的所有文件。 +为此,我们可以使用 [`s3` 表函数](/sql-reference/table-functions/s3) 并传入文件的路径或一组文件的通配符。 :::tip -如果您仅传入存储桶名称,将会抛出异常。 +如果你仅传入桶名称,它将抛出异常。 ::: -我们还将使用 [`One`](/interfaces/formats#data-format-one) 输入格式,这样文件就不会被解析,而是每个文件返回一行,我们可以通过 `_file` 虚拟列访问文件,通过 `_path` 虚拟列访问路径。 +我们还将使用 [`One`](/interfaces/formats#data-format-one) 输入格式,这样文件不会被解析,而是每个文件返回一行,我们可以通过 `_file` 虚拟列访问文件,通过 `_path` 虚拟列访问路径。 ```python import chdb @@ -77,12 +78,12 @@ SETTINGS output_format_pretty_row_numbers=0 └─────────────────────────────────────┴───────────────────────────────────────────────────────────────────────────┘ ``` -这个存储桶只包含 Parquet 文件。 +这个桶仅包含 Parquet 文件。 -## 查询 S3 存储桶中的文件 {#querying-files-in-an-s3-bucket} +## 查询 S3 桶中的文件 {#querying-files-in-an-s3-bucket} 接下来,让我们学习如何查询这些文件。 -如果我们想计算每个文件中的行数,可以运行以下查询: +如果我们想统计每个文件中的行数,可以运行以下查询: ```python chdb.query(""" @@ -109,7 +110,7 @@ SETTINGS output_format_pretty_row_numbers=0 └─────────────────────────────────────┴──────────┴─────────────────┘ ``` -我们也可以传入 S3 存储桶的 HTTP URI,并获得相同的结果: +我们也可以传入 S3 桶的 HTTP URI,并获得相同的结果: ```python chdb.query(""" @@ -123,7 +124,7 @@ SETTINGS output_format_pretty_row_numbers=0 """, 'PrettyCompact') ``` -让我们使用 `DESCRIBE` 子句查看这些 Parquet 文件的模式: +让我们使用 `DESCRIBE` 子句查看这些 Parquet 文件的架构: ```python chdb.query(""" @@ -152,7 +153,7 @@ SETTINGS describe_compact_output=1 └───────────────────┴──────────────────┘ ``` -现在让我们根据评论数量计算顶级产品类别,并计算平均星级评分: +现在让我们计算基于评论数量的 top 产品类别,以及计算平均星级评分: ```python chdb.query(""" @@ -178,9 +179,9 @@ LIMIT 10 └──────────────────┴──────────┴──────┘ ``` -## 查询私有 S3 存储桶中的文件 {#querying-files-in-a-private-s3-bucket} +## 查询私有 S3 桶中的文件 {#querying-files-in-a-private-s3-bucket} -如果我们在私有 S3 存储桶中查询文件,则需要传入访问密钥和密钥。 +如果我们要查询私有 S3 桶中的文件,我们需要传入访问密钥和秘密。 我们可以将这些凭证传递给 `s3` 表函数: ```python @@ -193,7 +194,7 @@ LIMIT 10 ``` :::note -此查询将无法工作,因为这是一个公共存储桶! +这个查询将不起作用,因为这是一个公共桶! ::: -另一种方法是使用 [命名集合](/operations/named-collections),但该方法尚未被 chDB 支持。 +另一种方法是使用 [命名集合](/operations/named-collections),但这种方法尚不支持 chDB。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/guides/querying-s3-bucket.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/guides/querying-s3-bucket.md.hash index fcf4da4e5b5..7a2e86141db 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/guides/querying-s3-bucket.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/guides/querying-s3-bucket.md.hash @@ -1 +1 @@ -22a180324f488326 +bdb51de1a2f456ea diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/index.md index b336e5e6480..8b90a722a47 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/index.md @@ -2,67 +2,81 @@ 'title': 'chDB' 'sidebar_label': '概述' 'slug': '/chdb' -'description': 'chDB 是一个由 ClickHouse 驱动的内联 SQL OLAP 引擎' +'description': 'chDB 是一个由 ClickHouse 提供支持的进程内 SQL OLAP 引擎' 'keywords': - 'chdb' - 'embedded' - 'clickhouse-lite' - 'in-process' - 'in process' +'doc_type': 'guide' --- +import Image from '@theme/IdealImage'; +import dfBench from '@site/static/images/chdb/df_bench.png'; + # chDB -chDB 是一个快速的内嵌 SQL OLAP 引擎,由 [ClickHouse](https://github.com/clickhouse/clickhouse) 提供支持。当您希望在编程语言中使用 ClickHouse 的强大功能,而无需连接到 ClickHouse 服务器时,可以使用它。 +chDB是一个快速的内嵌SQL OLAP引擎,由[ClickHouse](https://github.com/clickhouse/clickhouse)提供支持。您可以在需要利用ClickHouse的强大功能但无需连接到ClickHouse服务器的编程语言中使用它。 + +## 关键特性 {#key-features} + +- **内嵌SQL OLAP引擎** - 由ClickHouse提供支持,无需安装ClickHouse服务器 +- **多种数据格式** - 输入与输出支持Parquet、CSV、JSON、Arrow、ORC以及[70多种格式](/interfaces/formats) +- **最小化数据复制** - 从C++到Python,使用[python memoryview](https://docs.python.org/3/c-api/memoryview.html) +- **丰富的Python生态系统集成** - 原生支持Pandas、Arrow、DB API 2.0,完美契合现有的数据科学工作流 +- **零依赖** - 无需外部数据库的安装 -## chDB 支持哪些语言? {#what-languages-are-supported-by-chdb} +## chDB支持哪些语言? {#what-languages-are-supported-by-chdb} -chDB 拥有以下语言绑定: +chDB具有以下语言绑定: -* [Python](install/python.md) +* [Python](install/python.md) - [API参考](api/python.md) * [Go](install/go.md) * [Rust](install/rust.md) * [NodeJS](install/nodejs.md) * [Bun](install/bun.md) - -## 支持哪些输入和输出格式? {#what-input-and-output-formats-are-supported} - -chDB 支持 Parquet、CSV、JSON、Apache Arrow、ORC 和 [60 种以上格式](/interfaces/formats)。 +* [C和C++](install/c.md) ## 我该如何开始? {#how-do-i-get-started} -* 如果您使用的是 [Go](install/go.md)、[Rust](install/rust.md)、[NodeJS](install/nodejs.md) 或 [Bun](install/bun.md),请查看相应的语言页面。 -* 如果您使用 Python,请参阅 [入门开发者指南](getting-started.md)。还有一些指南展示了如何执行常见任务,例如: - * [JupySQL](guides/jupysql.md) - * [查询 Pandas](guides/querying-pandas.md) - * [查询 Apache Arrow](guides/querying-apache-arrow.md) - * [查询 S3 中的数据](guides/querying-s3-bucket.md) - * [查询 Parquet 文件](guides/querying-parquet.md) - * [查询远程 ClickHouse](guides/query-remote-clickhouse.md) - * [使用 clickhouse-local 数据库](guides/clickhouse-local.md) - - - -## 入门视频 {#an-introductory-video} - -您可以收听 chDB 项目的简要介绍,由 ClickHouse 的原始创建者 Alexey Milovidov 提供: +您可以收听chDB项目的简要介绍,由ClickHouse的原始创始人Alexey Milovidov提供:
-## 关于 chDB {#about-chdb} +## 性能基准 {#performance-benchmarks} + +chDB在不同场景下提供卓越的性能: + +- **[嵌入引擎的ClickBench](https://benchmark.clickhouse.com/#eyJzeXN0ZW0iOnsiQXRoZW5hIChwYXJ0aXRpb25lZCkiOnRydWUsIkF0aGVuYSAoc2luZ2xlKSI6dHJ1ZSwiQXVyb3JhIGZvciBNeVNRTCI6dHJ1ZSwiQXVyb3JhIGZvciBQb3N0Z3JlU1FMIjp0cnVlLCJCeXRlSG91c2UiOnRydWUsImNoREIiOnRydWUsIkNpdHVzIjp0cnVlLCJjbGlja2hvdXNlLWxvY2FsIChwYXJ0aXRpb25lZCkiOnRydWUsImNsaWNraG91c2UtbG9jYWwgKHNpbmdsZSkiOnRydWUsIkNsaWNrSG91c2UiOnRydWUsIkNsaWNrSG91c2UgKHR1bmVkKSI6dHJ1ZSwiQ2xpdGhvdXNlIHpzdGQiOnRydWUsIkNsaWNrSG91c2UgQ2xvdWQiOnRydWUsIkNsaWNrSG91c2UgKHdlYikiOnRydWUsIkNyYXRlREIiOnRydWUsIkRhdGFiZW5kIjp0cnVlLCJEYXRhRnVzaW9uIChzaW5nbGUpIjp0cnVlLCJBcGFjaGUgRG9yaXMiOnRydWUsIkRydWlkIjp0cnVlLCJEdWNrREIgKFBhcnF1ZXQpIjp0cnVlLCJEdWNrREIiOnRydWUsIkVsYXN0aWNzZWFyY2giOnRydWUsIkVsYXN0aWNzZWFyY2ggKHR1bmVkKSI6ZmFsc2UsIkdyZWVucGx1bSI6dHJ1ZSwiSGVhdnlBSSI6dHJ1ZSwiSHlkcmEiOnRydWUsIkluZm9icmlnaHQiOnRydWUsIktpbmV0aWNhIjp0cnVlLCJNYXJpYURCIENvbHVtblN0b3JlIjp0cnVlLCJNYXJpYURCIjpmYWxzZSwiTW9uZXREQiI6dHJ1ZSwiTW9uZ29EQiI6dHJ1ZSwiTXlTUUwgKE15SVNBTSkiOnRydWUsIk15U1FMIjp0cnVlLCJQaW5vdCI6dHJ1ZSwiUG9zdGdyZVNRTCI6dHJ1ZSwiUG9zdGdyZVNRTCAodHVuZWQpIjpmYWxzZSwiUXVlc3REQiAocGFydGl0aW9uZWQpIjp0cnVlLCJRdWVzdERCIjp0cnVlLCJSZWRzaGlmdCI6dHJ1ZSwiU2VsZWN0REIiOnRydWUsIlNpbmdsZVN0b3JlIjp0cnVlLCJTbm93Zmxha2UiOnRydWUsIlNRTGl0ZSI6dHJ1ZSwiU3RhclJvY2tzIjp0cnVlLCJUaW1lc2NhbGVEQiAoY29tcHJlc3Npb24pIjp0cnVlLCJUaW1lc2NhbGVEQiI6dHJ1ZX0sInR5cGUiOnsic3RhdGVsZXNzIjpmYWxzZSwibWFuYWdlZCI6ZmFsc2UsIkphdmEiOmZhbHNlLCJjb2x1bW4tb3JpZW50ZWQiOmZhbHNlLCJDKysiOmZhbHNlLCJNeVNRTCBjb21wYXRpYmxlIjpmYWxzZSwicm93LW9yaWVudGVkIjpmYWxzZSwiQyI6ZmFsc2UsIlBvc3RncmVTUUwgY29tcGF0aWJsZSI6ZmFsc2UsIkNsaWNrSG91c2UgZGVyaXZhdGl2ZSI6ZmFsc2UsImVtYmVkZGVkIjp0cnVlLCJzZXJ2ZXJsZXNzIjpmYWxzZSwiUnVzdCI6ZmFsc2UsInNlYXJjaCI6ZmFsc2UsImRvY3VtZW50IjpmYWxzZSwidGltZS1zZXJpZXMiOmZhbHNlfSwibWFjaGluZSI6eyJzZXJ2ZXJsZXNzIjp0cnVlLCIxNmFjdSI6dHJ1ZSwiTCI6dHJ1ZSwiTSI6dHJ1ZSwiUyI6dHJ1ZSwiWFMiOnRydWUsImM2YS5tZXRhbCwgNTAwZ2IgZ3AyIjp0cnVlLCJjNmEuNHhsYXJnZSwgNTAwZ2IgZ3AyIjp0cnVlLCJjNS40eGxhcmdlLCA1MDBnYiBncDIiOnRydWUsIjE2IHRocmVhZHMiOnRydWUsIjIwIHRocmVhZHMiOnRydWUsIjI0IHRocmVhZHMiOnRydWUsIjI4IHRocmVhZHMiOnRydWUsIjMwIHRocmVhZHMiOnRydWUsIjQ4IHRocmVhZHMiOnRydWUsIjYwIHRocmVhZHMiOnRydWUsIm01ZC4yNHhsYXJnZSI6dHJ1ZSwiYzVuLjR4bGFyZ2UsIDIwMGdiIGdwMiI6dHJ1ZSwiYzZhLjR4bGFyZ2UsIDE1MDBnYiBncDIiOnRydWUsImRjMi44eGxhcmdlIjp0cnVlLCJyYTMuMTZ4bGFyZ2UiOnRydWUsInJhMy40eGxhcmdlIjp0cnVlLCJyYTMueGxwbHVzIjp0cnVlLCJTMjQiOnRydWUsIlMyIjp0cnVlLCIyWEwiOnRydWUsIjNYTCI6dHJ1ZSwiNFhMIjp0cnVlLCJYTCI6dHJ1ZX0sImNsdXN0ZXJfc2l6ZSI6eyIxIjp0cnVlLCIyIjp0cnVlLCI0Ijp0cnVlLCI4Ijp0cnVlLCIxNiI6dHJ1ZSwiMzIiOnRydWUsIjY0Ijp0cnVlLCIxMjgiOnRydWUsInNlcnZlcmxlc3MiOnRydWUsInVuZGVmaW5lZCI6dHJ1ZX0sIm1ldHJpYyI6ImhvdCIsInF1ZXJpZXMiOlt0cnVlLHRydWUsdHJ1ZSx0cnVlLHRydWUsdHJ1ZSx0cnVlLHRydWUsdHJ1ZSx0cnVlLHRydWUsdHJ1ZSx0cnVlLHRydWUsdHJ1ZSx0cnVlLHRydWUsdHJ1ZSx0cnVlLHRydWUsdHJ1ZSx0cnVlLHRydWUsdHJ1ZSx0cnVlLHRydWUsdHJ1ZSx0cnVlLHRydWUsdHJ1ZSx0cnVlLHRydWUsdHJ1ZSx0cnVlXX0=)** - 综合性能比较 +- **[DataFrame处理性能](https://colab.research.google.com/drive/1FogLujJ_-ds7RGurDrUnK-U0IW8a8Qd0)** - 与其他DataFrame库的比较分析 +- **[DataFrame基准测试](https://benchmark.clickhouse.com/#eyJzeXN0ZW0iOnsiQWxsb3lEQiI6dHJ1ZSwiQWxsb3lEQiAodHVuZWQpIjp0cnVlLCJBdGhlbmEgKHBhcnRpdGlvbmVkKSI6dHJ1ZSwiQXRoZW5hIChzaW5nbGUpIjp0cnVlLCJBdXJvcmEgZm9yIE15U1FMIjp0cnVlLCJBdXJvcmEgZm9yIFBvc3RncmVTUUwiOnRydWUsIkJ5Q29uaXR5Ijp0cnVlLCJCeXRlSG91c2UiOnRydWUsImNoREIgKERhdGFGcmFtZSkiOnRydWUsImNoREIgKFBhcnF1ZXQsIHBhcnRpdGlvbmVkKSI6dHJ1ZSwiY2hEQiI6dHJ1ZSwiQ2l0dXMiOnRydWUsIkNsaWNrSG91c2UgQ2xvdWQgKGF3cykiOnRydWUsIkNsaWNrSG91c2UgQ2xvdWQgKGF6dXJlKSI6dHJ1ZSwiQ2xpY2tIb3VzZSBDbG91ZCAoZ2NwKSI6dHJ1ZSwiQ2xpY2tIb3VzZSAoZGF0YSBsYWtlLCBwYXJ0aXRpb25lZCkiOnRydWUsIkNsaWNrSG91c2UgKGRhdGEgbGFrZSwgc2luZ2xlKSI6dHJ1ZSwiQ2xpY2tIb3VzZSAoUGFycXVldCwgcGFydGl0aW9uZWQpIjp0cnVlLCJDbGlja0hvdXNlIChQYXJxdWV0LCBzaW5nbGUpIjp0cnVlLCJDbGlja0hvdXNlICh3ZWIpIjp0cnVlLCJDbGlja0hvdXNlIjp0cnVlLCJDbGlja0hvdXNlICh0dW5lZCkiOnRydWUsIkNsaWNrSG91c2UgKHR1bmVkLCBtZW1vcnkpIjp0cnVlLCJDbG91ZGJlcnJ5Ijp0cnVlLCJDcmF0ZURCIjp0cnVlLCJDcnVuY2h5IEJyaWRnZSBmb3IgQW5hbHl0aWNzIChQYXJxdWV0KSI6dHJ1ZSwiRGF0YWJlbmQiOnRydWUsIkRhdGFGdXNpb24gKFBhcnF1ZXQsIHBhcnRpdGlvbmVkKSI6dHJ1ZSwiRGF0YUZ1c2lvbiAoUGFycXVldCwgc2luZ2xlKSI6dHJ1ZSwiQXBhY2hlIERvcmlzIjp0cnVlLCJEcnVpZCI6dHJ1ZSwiRHVja0RCIChEYXRhRnJhbWUpIjp0cnVlLCJEdWNrREIgKFBhcnF1ZXQsIHBhcnRpdGlvbmVkKSI6dHJ1ZSwiRHVja0RCIjp0cnVlLCJFbGFzdGljc2VhcmNoIjp0cnVlLCJFbGFzdGljc2VhcmNoICh0dW5lZCkiOmZhbHNlLCJHbGFyZURCIjp0cnVlLCJHcmVlbnBsdW0iOnRydWUsIkhlYXZ5QUkiOnRydWUsIkh5ZHJhIjp0cnVlLCJJbmZvYnJpZ2h0Ijp0cnVlLCJLaW5ldGljYSI6dHJ1ZSwiTWFyaWFEQiBDb2x1bW5TdG9yZSI6dHJ1ZSwiTWFyaWFEQiI6ZmFsc2UsIk1vbmV0REIiOnRydWUsIk1vbmdvREIiOnRydWUsIk1vdGhlcmR1Y2siOnRydWUsIk15U1FMIChNeUlTQU0pIjp0cnVlLCJNeVNRTCI6dHJ1ZSwiT3hsYSI6dHJ1ZSwiUGFuZGFzIChEYXRhRnJhbWUpIjp0cnVlLCJQYXJhZGVEQiAoUGFycXVldCwgcGFydGl0aW9uZWQpIjp0cnVlLCJQYXJhZGVEQiAoUGFycXVldCwgc2luZ2xlKSI6dHJ1ZSwiUGlub3QiOnRydWUsIlBvbGFycyAoRGF0YUZyYW1lKSI6dHJ1ZSwiUG9zdGdyZVNRTCAodHVuZWQpIjpmYWxzZSwiUG9zdGdyZVNRTCI6dHJ1ZSwiUXVlc3REQiAocGFydGl0aW9uZWQpIjp0cnVlLCJRdWVzdERCIjp0cnVlLCJSZWRzaGlmdCI6dHJ1ZSwiU2luZ2xlU3RvcmUiOnRydWUsIlNub3dmbGFrZSI6dHJ1ZSwiU1FMaXRlIjp0cnVlLCJTdGFyUm9ja3MiOnRydWUsIlRhYmxlc3BhY2UiOnRydWUsIlRlbWJvIE9MQVAgKGNvbHVtbmFyKSI6dHJ1ZSwiVGltZXNjYWxlREIgKGNvbXByZXNzaW9uKSI6dHJ1ZSwiVGltZXNjYWxlREIiOnRydWUsIlVtYnJhIjp0cnVlfSwidHlwZSI6eyJDIjpmYWxzZSwiY29sdW1uLW9yaWVudGVkIjpmYWxzZSwiUG9zdGdyZVNRTCBjb21wYXRpYmxlIjpmYWxzZSwibWFuYWdlZCI6ZmFsc2UsImdjcCI6ZmFsc2UsInN0YXRlbGVzcyI6ZmFsc2UsIkphdmEiOmZhbHNlLCJDKysiOmZhbHNlLCJNeVNRTCBjb21wYXRpYmxlIjpmYWxzZSwicm93LW9yaWVudGVkIjpmYWxzZSwiQ2xpY2tIb3VzZSBkZXJpdmF0aXZlIjpmYWxzZSwiZW1iZWRkZWQiOmZhbHNlLCJzZXJ2ZXJsZXNzIjpmYWxzZSwiZGF0YWZyYW1lIjp0cnVlLCJhd3MiOmZhbHNlLCJhenVyZSI6ZmFsc2UsImFuYWx5dGljYWwiOmZhbHNlLCJSdXN0IjpmYWxzZSwic2VhcmNoIjpmYWxzZSwiZG9jdW1lbnQiOmZhbHNlLCJzb21ld2hhdCBQb3N0Z3JlU1FMIGNvbXBhdGlibGUiOmZhbHNlLCJ0aW1lLXNlcmllcyI6ZmFsc2V9LCJtYWNoaW5lIjp7IjE2IHZDUFUgMTI4R0IiOnRydWUsIjggdkNQVSA2NEdCIjp0cnVlLCJzZXJ2ZXJsZXNzIjp0cnVlLCIxNmFjdSI6dHJ1ZSwiYzZhLjR4bGFyZ2UsIDUwMGdiIGdwMiI6dHJ1ZSwiTCI6dHJ1ZSwiTSI6dHJ1ZSwiUyI6dHJ1ZSwiWFMiOnRydWUsImM2YS5tZXRhbCwgNTAwZ2IgZ3AyIjp0cnVlLCIxOTJHQiI6dHJ1ZSwiMjRHQiI6dHJ1ZSwiMzYwR0IiOnRydWUsIjQ4R0IiOnRydWUsIjcyMEdCIjp0cnVlLCI5NkdCIjp0cnVlLCJkZXYiOnRydWUsIjcwOEdCIjp0cnVlLCJjNW4uNHhsYXJnZSwgNTAwZ2IgZ3AyIjp0cnVlLCJBbmFseXRpY3MtMjU2R0IgKDY0IHZDb3JlcywgMjU2IEdCKSI6dHJ1ZSwiYzUuNHhsYXJnZSwgNTAwZ2IgZ3AyIjp0cnVlLCJjNmEuNHhsYXJnZSwgMTUwMGdiIGdwMiI6dHJ1ZSwiY2xvdWQiOnRydWUsImRjMi44eGxhcmdlIjp0cnVlLCJyYTMuMTZ4bGFyZ2UiOnRydWUsInJhMy40eGxhcmdlIjp0cnVlLCJyYTMueGxwbHVzIjp0cnVlLCJTMiI6dHJ1ZSwiUzI0Ijp0cnVlLCIyWEwiOnRydWUsIjNYTCI6dHJ1ZSwiNFhMIjp0cnVlLCJYTCI6dHJ1ZSwiTDEgLSAxNkNQVSAzMkdCIjp0cnVlLCJjNmEuNHhsYXJnZSwgNTAwZ2IgZ3AzIjp0cnVlfSwiY2x1c3Rlcl9zaXplIjp7IjEiOnRydWUsIjIiOnRydWUsIjQiOnRydWUsIjgiOnRydWUsIjE2Ijp0cnVlLCIzMiI6dHJ1ZSwiNjQiOnRydWUsIjEyOCI6dHJ1ZSwic2VydmVybGVzcyI6dHJ1ZX0sIm1ldHJpYyI6ImhvdCIsInF1ZXJpZXMiOlt0cnVlLHRydWUsdHJ1ZSx0cnVlLHRydWUsdHJ1ZSx0cnVlLHRydWUsdHJ1ZSx0cnVlLHRydWUsdHJ1ZSx0cnVlLHRydWUsdHJ1ZSx0cnVlLHRydWUsdHJ1ZSx0cnVlLHRydWUsdHJ1ZSx0cnVlLHRydWUsdHJ1ZSx0cnVlLHRydWUsdHJ1ZSx0cnVlLHRydWUsdHJ1ZSx0cnVlLHRydWUsdHJ1ZSx0cnVlLHRydWUsdHJ1ZSx0cnVlXX0=)** + +DataFrame基准测试结果 -- 在 [Auxten's blog](https://clickhouse.com/blog/chdb-embedded-clickhouse-rocket-engine-on-a-bicycle) 上阅读 chDB 项目诞生的完整故事 -- 在 [官方 ClickHouse 博客](https://clickhouse.com/blog/welcome-chdb-to-clickhouse) 上阅读关于 chDB 及其使用案例的内容 -- 使用 [codapi 示例](https://antonz.org/trying-chdb/) 在浏览器中发现 chDB +## 关于chDB {#about-chdb} +- 阅读关于chDB项目出生的完整故事在[博客](https://clickhouse.com/blog/chdb-embedded-clickhouse-rocket-engine-on-a-bicycle) +- 查看关于chDB及其使用案例的[博客](https://clickhouse.com/blog/welcome-chdb-to-clickhouse) +- 参加[chDB按需课程](https://learn.clickhouse.com/user_catalog_class/show/1901178) +- 使用[codapi示例](https://antonz.org/trying-chdb/)在您的浏览器中发现chDB +- 更多示例请参见(https://github.com/chdb-io/chdb/tree/main/examples) -## 它使用什么许可证? {#what-license-does-it-use} +## 许可证 {#license} -chDB 根据 Apache 许可证第 2.0 版提供。 +chDB根据Apache许可证2.0版提供。有关更多信息,请参见[许可证](https://github.com/chdb-io/chdb/blob/main/LICENSE.txt)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/index.md.hash index 0a5f5e3777b..1b14879e101 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/index.md.hash @@ -1 +1 @@ -3b039ff406752922 +1b23a7330fc61f1e diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/install/bun.md b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/install/bun.md index de6cef1ffe7..cab6644bdb2 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/install/bun.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/install/bun.md @@ -1,59 +1,134 @@ --- -'title': '为 Bun 安装 chDB' +'title': 'chDB for Bun' 'sidebar_label': 'Bun' 'slug': '/chdb/install/bun' -'description': '如何为 Bun 安装 chDB' +'description': '如何安装和使用 chDB 与 Bun 运行时' 'keywords': - 'chdb' -- 'embedded' -- 'clickhouse-lite' - 'bun' -- 'install' +- 'javascript' +- 'typescript' +- 'embedded' +- 'clickhouse' +- 'sql' +- 'olap' +'doc_type': 'guide' --- -# Installing chDB for Bun +# chDB for Bun + +chDB-bun 提供实验性的 FFI (Foreign Function Interface) 绑定,允许您在 Bun 应用中直接运行 ClickHouse 查询,而无需任何外部依赖。 + +## 安装 {#installation} + +### 步骤 1: 安装系统依赖 {#install-system-dependencies} -## Requirements {#requirements} +首先,安装所需的系统依赖: -安装 [libchdb](https://github.com/chdb-io/chdb): +#### 安装 libchdb {#install-libchdb} ```bash curl -sL https://lib.chdb.io | bash ``` -## Install {#install} +#### 安装构建工具 {#install-build-tools} -请参见: [chdb-bun](https://github.com/chdb-io/chdb-bun) +您需要在系统上安装 `gcc` 或 `clang`: -## GitHub repository {#github-repository} +### 步骤 2: 安装 chDB-bun {#install-chdb-bun} -您可以在 [chdb-io/chdb-bun](https://github.com/chdb-io/chdb-bun) 找到该项目的 GitHub 仓库。 +```bash + +# Install from the GitHub repository +bun add github:chdb-io/chdb-bun + + +# Or clone and build locally +git clone https://github.com/chdb-io/chdb-bun.git +cd chdb-bun +bun install +bun run build +``` -## Usage {#usage} +## 用法 {#usage} -### Query(query, *format) (ephemeral) {#queryquery-format-ephemeral} +chDB-bun 支持两种查询模式:用于一次性操作的临时查询和用于维护数据库状态的持久会话。 -```javascript +### 临时查询 {#ephemeral-queries} + +对于简单的、一次性查询,且不需要持久状态: + +```typescript import { query } from 'chdb-bun'; -// Query (ephemeral) -var result = query("SELECT version()", "CSV"); -console.log(result); // 23.10.1.1 +// Basic query +const result = query("SELECT version()", "CSV"); +console.log(result); // "23.10.1.1" + +// Query with different output formats +const jsonResult = query("SELECT 1 as id, 'Hello' as message", "JSON"); +console.log(jsonResult); + +// Query with calculations +const mathResult = query("SELECT 2 + 2 as sum, pi() as pi_value", "Pretty"); +console.log(mathResult); + +// Query system information +const systemInfo = query("SELECT * FROM system.functions LIMIT 5", "CSV"); +console.log(systemInfo); ``` -### Session.Query(query, *format) {#sessionqueryquery-format} +### 持久会话 {#persistent-sessions} -```javascript -import { Session } from 'chdb-bun'; -const sess = new Session('./chdb-bun-tmp'); +对于需要在查询之间维护状态的复杂操作: -// Query Session (persistent) -sess.query("CREATE FUNCTION IF NOT EXISTS hello AS () -> 'Hello chDB'", "CSV"); -var result = sess.query("SELECT hello()", "CSV"); -console.log(result); +```typescript +import { Session } from 'chdb-bun'; -// Before cleanup, you can find the database files in `./chdb-bun-tmp` +// Create a session with persistent storage +const sess = new Session('./chdb-bun-tmp'); -sess.cleanup(); // cleanup session, this will delete the database +try { + // Create a database and table + sess.query(` + CREATE DATABASE IF NOT EXISTS mydb; + CREATE TABLE IF NOT EXISTS mydb.users ( + id UInt32, + name String, + email String + ) ENGINE = MergeTree() ORDER BY id + `, "CSV"); + + // Insert data + sess.query(` + INSERT INTO mydb.users VALUES + (1, 'Alice', 'alice@example.com'), + (2, 'Bob', 'bob@example.com'), + (3, 'Charlie', 'charlie@example.com') + `, "CSV"); + + // Query the data + const users = sess.query("SELECT * FROM mydb.users ORDER BY id", "JSON"); + console.log("Users:", users); + + // Create and use custom functions + sess.query("CREATE FUNCTION IF NOT EXISTS hello AS () -> 'Hello chDB'", "CSV"); + const greeting = sess.query("SELECT hello() as message", "Pretty"); + console.log(greeting); + + // Aggregate queries + const stats = sess.query(` + SELECT + COUNT(*) as total_users, + MAX(id) as max_id, + MIN(id) as min_id + FROM mydb.users + `, "JSON"); + console.log("Statistics:", stats); + +} finally { + // Always cleanup the session to free resources + sess.cleanup(); // This deletes the database files +} ``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/install/bun.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/install/bun.md.hash index 01682d0fb36..10a66b6464d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/install/bun.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/install/bun.md.hash @@ -1 +1 @@ -38ae1ccc991c9c80 +dc8ea61c3f6531fd diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/install/c.md b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/install/c.md index eb147340b04..593014a02cd 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/install/c.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/install/c.md @@ -1,50 +1,342 @@ --- -'title': '安装 chDB 适用于 C 和 C++' +'title': 'chDB for C 和 C++' 'sidebar_label': 'C 和 C++' 'slug': '/chdb/install/c' -'description': '如何安装 chDB 适用于 C 和 C++' +'description': '如何安装和使用 chDB 与 C 和 C++' 'keywords': - 'chdb' +- 'c' +- 'cpp' - 'embedded' -- 'clickhouse-lite' -- 'install' +- 'clickhouse' +- 'sql' +- 'olap' +- 'api' +'doc_type': 'guide' --- -# Installing chDB for C and C++ +# chDB for C and C++ -## Requirements {#requirements} +chDB 提供了一个原生的 C/C++ API,可以将 ClickHouse 功能直接嵌入到您的应用程序中。该 API 支持简单查询以及持久连接和流式查询结果等高级功能。 -安装 [libchdb](https://github.com/chdb-io/chdb): +## Installation {#installation} + +### Step 1: Install libchdb {#install-libchdb} + +在您的系统上安装 chDB 库: ```bash curl -sL https://lib.chdb.io | bash ``` +### Step 2: Include headers {#include-headers} + +在您的项目中包含 chDB 头文件: + +```c +#include +``` + +### Step 3: Link library {#link-library} + +编译并链接您的应用程序与 chDB: + +```bash + +# C compilation +gcc -o myapp myapp.c -lchdb + + +# C++ compilation +g++ -o myapp myapp.cpp -lchdb +``` + +## C Examples {#c-examples} + +### Basic connection and queries {#basic-connection-queries} + +```c +#include +#include + +int main() { + // Create connection arguments + char* args[] = {"chdb", "--path", "/tmp/chdb-data"}; + int argc = 3; + + // Connect to chDB + chdb_connection* conn = chdb_connect(argc, args); + if (!conn) { + printf("Failed to connect to chDB\n"); + return 1; + } + + // Execute a query + chdb_result* result = chdb_query(*conn, "SELECT version()", "CSV"); + if (!result) { + printf("Query execution failed\n"); + chdb_close_conn(conn); + return 1; + } + + // Check for errors + const char* error = chdb_result_error(result); + if (error) { + printf("Query error: %s\n", error); + } else { + // Get result data + char* data = chdb_result_buffer(result); + size_t length = chdb_result_length(result); + double elapsed = chdb_result_elapsed(result); + uint64_t rows = chdb_result_rows_read(result); + + printf("Result: %.*s\n", (int)length, data); + printf("Elapsed: %.3f seconds\n", elapsed); + printf("Rows: %llu\n", rows); + } + + // Cleanup + chdb_destroy_query_result(result); + chdb_close_conn(conn); + return 0; +} +``` + +### Streaming queries {#streaming-queries} + +```c +#include +#include + +int main() { + char* args[] = {"chdb", "--path", "/tmp/chdb-stream"}; + chdb_connection* conn = chdb_connect(3, args); + + if (!conn) { + printf("Failed to connect\n"); + return 1; + } + + // Start streaming query + chdb_result* stream_result = chdb_stream_query(*conn, + "SELECT number FROM system.numbers LIMIT 1000000", "CSV"); + + if (!stream_result) { + printf("Failed to start streaming query\n"); + chdb_close_conn(conn); + return 1; + } + + uint64_t total_rows = 0; + + // Process chunks + while (true) { + chdb_result* chunk = chdb_stream_fetch_result(*conn, stream_result); + if (!chunk) break; + + // Check if we have data in this chunk + size_t chunk_length = chdb_result_length(chunk); + if (chunk_length == 0) { + chdb_destroy_query_result(chunk); + break; // End of stream + } + + uint64_t chunk_rows = chdb_result_rows_read(chunk); + total_rows += chunk_rows; + + printf("Processed chunk: %llu rows, %zu bytes\n", chunk_rows, chunk_length); + + // Process the chunk data here + // char* data = chdb_result_buffer(chunk); + + chdb_destroy_query_result(chunk); -## Usage {#usage} + // Progress reporting + if (total_rows % 100000 == 0) { + printf("Progress: %llu rows processed\n", total_rows); + } + } -按照 [libchdb](https://github.com/chdb-io/chdb/blob/main/bindings.md) 的说明开始使用。 + printf("Streaming complete. Total rows: %llu\n", total_rows); -`chdb.h` + // Cleanup streaming query + chdb_destroy_query_result(stream_result); + chdb_close_conn(conn); + return 0; +} +``` + +### Working with different data formats {#data-formats} ```c -#pragma once -#include -#include - -extern "C" { -struct local_result -{ - char * buf; - size_t len; - void * _vec; // std::vector *, for freeing - double elapsed; - uint64_t rows_read; - uint64_t bytes_read; +#include +#include + +int main() { + char* args[] = {"chdb"}; + chdb_connection* conn = chdb_connect(1, args); + + const char* query = "SELECT number, toString(number) as str FROM system.numbers LIMIT 3"; + + // CSV format + chdb_result* csv_result = chdb_query(*conn, query, "CSV"); + printf("CSV Result:\n%.*s\n\n", + (int)chdb_result_length(csv_result), + chdb_result_buffer(csv_result)); + chdb_destroy_query_result(csv_result); + + // JSON format + chdb_result* json_result = chdb_query(*conn, query, "JSON"); + printf("JSON Result:\n%.*s\n\n", + (int)chdb_result_length(json_result), + chdb_result_buffer(json_result)); + chdb_destroy_query_result(json_result); + + // Pretty format + chdb_result* pretty_result = chdb_query(*conn, query, "Pretty"); + printf("Pretty Result:\n%.*s\n\n", + (int)chdb_result_length(pretty_result), + chdb_result_buffer(pretty_result)); + chdb_destroy_query_result(pretty_result); + + chdb_close_conn(conn); + return 0; +} +``` + +## C++ example {#cpp-example} + +```cpp +#include +#include +#include +#include + +class ChDBConnection { +private: + chdb_connection* conn; + +public: + ChDBConnection(const std::vector& args) { + // Convert string vector to char* array + std::vector argv; + for (const auto& arg : args) { + argv.push_back(const_cast(arg.c_str())); + } + + conn = chdb_connect(argv.size(), argv.data()); + if (!conn) { + throw std::runtime_error("Failed to connect to chDB"); + } + } + + ~ChDBConnection() { + if (conn) { + chdb_close_conn(conn); + } + } + + std::string query(const std::string& sql, const std::string& format = "CSV") { + chdb_result* result = chdb_query(*conn, sql.c_str(), format.c_str()); + if (!result) { + throw std::runtime_error("Query execution failed"); + } + + const char* error = chdb_result_error(result); + if (error) { + std::string error_msg(error); + chdb_destroy_query_result(result); + throw std::runtime_error("Query error: " + error_msg); + } + + std::string data(chdb_result_buffer(result), chdb_result_length(result)); + + // Get query statistics + std::cout << "Query statistics:\n"; + std::cout << " Elapsed: " << chdb_result_elapsed(result) << " seconds\n"; + std::cout << " Rows read: " << chdb_result_rows_read(result) << "\n"; + std::cout << " Bytes read: " << chdb_result_bytes_read(result) << "\n"; + + chdb_destroy_query_result(result); + return data; + } }; -local_result * query_stable(int argc, char ** argv); -void free_result(local_result * result); +int main() { + try { + // Create connection + ChDBConnection db({{"chdb", "--path", "/tmp/chdb-cpp"}}); + + // Create and populate table + db.query("CREATE TABLE test (id UInt32, value String) ENGINE = MergeTree() ORDER BY id"); + db.query("INSERT INTO test VALUES (1, 'hello'), (2, 'world'), (3, 'chdb')"); + + // Query with different formats + std::cout << "CSV Results:\n" << db.query("SELECT * FROM test", "CSV") << "\n"; + std::cout << "JSON Results:\n" << db.query("SELECT * FROM test", "JSON") << "\n"; + + // Aggregation query + std::cout << "Count: " << db.query("SELECT COUNT(*) FROM test") << "\n"; + + } catch (const std::exception& e) { + std::cerr << "Error: " << e.what() << std::endl; + return 1; + } + + return 0; +} +``` + +## Error handling best practices {#error-handling} + +```c +#include +#include + +int safe_query_example() { + chdb_connection* conn = NULL; + chdb_result* result = NULL; + int return_code = 0; + + // Create connection + char* args[] = {"chdb"}; + conn = chdb_connect(1, args); + if (!conn) { + printf("Failed to create connection\n"); + return 1; + } + + // Execute query + result = chdb_query(*conn, "SELECT invalid_syntax", "CSV"); + if (!result) { + printf("Query execution failed\n"); + return_code = 1; + goto cleanup; + } + + // Check for query errors + const char* error = chdb_result_error(result); + if (error) { + printf("Query error: %s\n", error); + return_code = 1; + goto cleanup; + } + + // Process successful result + printf("Result: %.*s\n", + (int)chdb_result_length(result), + chdb_result_buffer(result)); + +cleanup: + if (result) chdb_destroy_query_result(result); + if (conn) chdb_close_conn(conn); + return return_code; } ``` + +## GitHub repository {#github-repository} + +- **Main Repository**: [chdb-io/chdb](https://github.com/chdb-io/chdb) +- **Issues and Support**: 在 [GitHub repository](https://github.com/chdb-io/chdb/issues) 上报告问题 +- **C API Documentation**: [Bindings Documentation](https://github.com/chdb-io/chdb/blob/main/bindings.md) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/install/c.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/install/c.md.hash index b22edc99a88..24388c065ce 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/install/c.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/install/c.md.hash @@ -1 +1 @@ -66d7e1632baf1f01 +410ac9448a262702 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/install/go.md b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/install/go.md index 732d94d74b6..12fdfc40be1 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/install/go.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/install/go.md @@ -1,36 +1,259 @@ --- -'title': '为 Go 安装 chDB' +'title': 'chDB for Go' 'sidebar_label': 'Go' 'slug': '/chdb/install/go' -'description': '如何为 Go 安装 chDB' +'description': '如何安装和使用 chDB 与 Go' 'keywords': - 'chdb' -- 'embedded' -- 'clickhouse-lite' - 'go' -- 'install' +- 'golang' +- 'embedded' +- 'clickhouse' +- 'sql' +- 'olap' +'doc_type': 'guide' --- -# Installing chDB for Go +# chDB for Go + +chDB-go 提供了 chDB 的 Go 绑定,使您能够在 Go 应用程序中直接运行 ClickHouse 查询,且无需任何外部依赖。 + +## Installation {#installation} -## Requirements {#requirements} +### Step 1: Install libchdb {#install-libchdb} -安装 [libchdb](https://github.com/chdb-io/chdb): +首先,安装 chDB 库: ```bash curl -sL https://lib.chdb.io | bash ``` -## Install {#install} +### Step 2: Install chdb-go {#install-chdb-go} -查看: [chdb-go](https://github.com/chdb-io/chdb-go) +安装 Go 包: -## GitHub repository {#github-repository} +```bash +go install github.com/chdb-io/chdb-go@latest +``` -您可以在 [chdb-io/chdb-go](https://github.com/chdb-io/chdb-go) 找到该项目的 GitHub 仓库。 +或者将其添加到您的 `go.mod` 中: + +```bash +go get github.com/chdb-io/chdb-go +``` ## Usage {#usage} -- API 文档: [High Level API](https://github.com/chdb-io/chdb-go/blob/main/chdb.md) -- 低级 API 文档: [Low Level API](https://github.com/chdb-io/chdb-go/blob/main/lowApi.md) +### Command line interface {#cli} + +chDB-go 包含一个 CLI,用于快速查询: + +```bash + +# Simple query +./chdb-go "SELECT 123" + + +# Interactive mode +./chdb-go + + +# Interactive mode with persistent storage +./chdb-go --path /tmp/chdb +``` + +### Go Library - quick start {#quick-start} + +#### Stateless queries {#stateless-queries} + +用于简单的一次性查询: + +```go +package main + +import ( + "fmt" + "github.com/chdb-io/chdb-go" +) + +func main() { + // Execute a simple query + result, err := chdb.Query("SELECT version()", "CSV") + if err != nil { + panic(err) + } + fmt.Println(result) +} +``` + +#### Stateful queries with session {#stateful-queries} + +用于具有持久状态的复杂查询: + +```go +package main + +import ( + "fmt" + "github.com/chdb-io/chdb-go" +) + +func main() { + // Create a session with persistent storage + session, err := chdb.NewSession("/tmp/chdb-data") + if err != nil { + panic(err) + } + defer session.Cleanup() + + // Create database and table + _, err = session.Query(` + CREATE DATABASE IF NOT EXISTS testdb; + CREATE TABLE IF NOT EXISTS testdb.test_table ( + id UInt32, + name String + ) ENGINE = MergeTree() ORDER BY id + `, "") + + if err != nil { + panic(err) + } + + // Insert data + _, err = session.Query(` + INSERT INTO testdb.test_table VALUES + (1, 'Alice'), (2, 'Bob'), (3, 'Charlie') + `, "") + + if err != nil { + panic(err) + } + + // Query data + result, err := session.Query("SELECT * FROM testdb.test_table ORDER BY id", "Pretty") + if err != nil { + panic(err) + } + + fmt.Println(result) +} +``` + +#### SQL driver interface {#sql-driver} + +chDB-go 实现了 Go 的 `database/sql` 接口: + +```go +package main + +import ( + "database/sql" + "fmt" + _ "github.com/chdb-io/chdb-go/driver" +) + +func main() { + // Open database connection + db, err := sql.Open("chdb", "") + if err != nil { + panic(err) + } + defer db.Close() + + // Query with standard database/sql interface + rows, err := db.Query("SELECT COUNT(*) FROM url('https://datasets.clickhouse.com/hits/hits.parquet')") + if err != nil { + panic(err) + } + defer rows.Close() + + for rows.Next() { + var count int + err := rows.Scan(&count) + if err != nil { + panic(err) + } + fmt.Printf("Count: %d\n", count) + } +} +``` + +#### Query streaming for large datasets {#query-streaming} + +用于处理不适合放入内存的大型数据集,请使用流式查询: + +```go +package main + +import ( + "fmt" + "log" + "github.com/chdb-io/chdb-go/chdb" +) + +func main() { + // Create a session for streaming queries + session, err := chdb.NewSession("/tmp/chdb-stream") + if err != nil { + log.Fatal(err) + } + defer session.Cleanup() + + // Execute a streaming query for large dataset + streamResult, err := session.QueryStreaming( + "SELECT number, number * 2 as double FROM system.numbers LIMIT 1000000", + "CSV", + ) + if err != nil { + log.Fatal(err) + } + defer streamResult.Free() + + rowCount := 0 + + // Process data in chunks + for { + chunk := streamResult.GetNext() + if chunk == nil { + // No more data + break + } + + // Check for streaming errors + if err := streamResult.Error(); err != nil { + log.Printf("Streaming error: %v", err) + break + } + + rowsRead := chunk.RowsRead() + // You can process the chunk data here + // For example, write to file, send over network, etc. + fmt.Printf("Processed chunk with %d rows\n", rowsRead) + rowCount += int(rowsRead) + if rowCount%100000 == 0 { + fmt.Printf("Processed %d rows so far...\n", rowCount) + } + } + + fmt.Printf("Total rows processed: %d\n", rowCount) +} +``` + +**流式查询的好处:** +- **内存高效** - 在不将所有数据加载到内存中的情况下处理大型数据集 +- **实时处理** - 在第一个数据块到达后立即开始处理数据 +- **取消支持** - 可以使用 `Cancel()` 取消长时间运行的查询 +- **错误处理** - 使用 `Error()` 检查流式处理期间的错误 + +## API documentation {#api-documentation} + +chDB-go 提供了高层次和低层次的 API: + +- **[高层次 API 文档](https://github.com/chdb-io/chdb-go/blob/main/chdb.md)** - 推荐用于大多数用例 +- **[低层次 API 文档](https://github.com/chdb-io/chdb-go/blob/main/lowApi.md)** - 用于需要精细控制的高级用例 + +## System requirements {#requirements} + +- Go 1.21 或更高版本 +- 兼容 Linux, macOS diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/install/go.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/install/go.md.hash index 34b334f21a6..6878366f00f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/install/go.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/install/go.md.hash @@ -1 +1 @@ -b2b885728e769679 +f5bd98c8d05c68ae diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/install/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/install/index.md index dca9d31a4cb..7d15eb1fab0 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/install/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/install/index.md @@ -10,15 +10,16 @@ - 'Bun' - 'C' - 'C++' +'doc_type': 'landing-page' --- -关于如何设置 chDB 的说明如下,适用于以下语言和运行时: +如何设置 chDB 的说明如下,适用于以下语言和运行时: -| 语言 | -|---------------------------------------| -| [Python](/chdb/install/python) | -| [NodeJS](/chdb/install/nodejs) | -| [Go](/chdb/install/go) | -| [Rust](/chdb/install/rust) | -| [Bun](/chdb/install/bun) | -| [C and C++](/chdb/install/c) | +| 语言 | API 参考 | +|----------------------------------------|-------------------------------------| +| [Python](/chdb/install/python) | [Python API](/chdb/api/python) | +| [NodeJS](/chdb/install/nodejs) | | +| [Go](/chdb/install/go) | | +| [Rust](/chdb/install/rust) | | +| [Bun](/chdb/install/bun) | | +| [C 和 C++](/chdb/install/c) | | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/install/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/install/index.md.hash index e253c9f8431..8bfb01f5b9b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/install/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/install/index.md.hash @@ -1 +1 @@ -76e84f59d6a713d8 +04c84539c1f70e3c diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/install/nodejs.md b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/install/nodejs.md index 9b04edad8ca..3e0df60b836 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/install/nodejs.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/install/nodejs.md @@ -1,71 +1,201 @@ --- -'title': '为 NodeJS 安装 chDB' -'sidebar_label': 'NodeJS' +'title': 'chDB for Node.js' +'sidebar_label': 'Node.js' 'slug': '/chdb/install/nodejs' -'description': '如何为 NodeJS 安装 chDB' +'description': '如何安装和使用 chDB 与 Node.js' 'keywords': - 'chdb' +- 'nodejs' +- 'javascript' - 'embedded' -- 'clickhouse-lite' -- 'NodeJS' -- 'install' +- 'clickhouse' +- 'sql' +- 'olap' +'doc_type': 'guide' --- -# 安装 chDB 用于 NodeJS +# chDB for Node.js -## 需求 {#requirements} +chDB-node 提供了 Node.js 的 chDB 绑定,使您能够直接在 Node.js 应用程序中运行 ClickHouse 查询,无需外部依赖。 -安装 [libchdb](https://github.com/chdb-io/chdb): +## Installation {#installation} ```bash -curl -sL https://lib.chdb.io | bash +npm install chdb ``` -## 安装 {#install} +## Usage {#usage} -```bash -npm i chdb -``` +chDB-node 支持两种查询模式:用于简单操作的独立查询和用于维护数据库状态的会话查询。 -## GitHub 仓库 {#github-repository} +### Standalone queries {#standalone-queries} -您可以在 [chdb-io/chdb-node](https://github.com/chdb-io/chdb-node) 找到该项目的 GitHub 仓库。 +对于不需要持久状态的简单一次性查询: -## 使用 {#usage} +```javascript +const { query } = require("chdb"); -您可以通过导入和使用 chdb-node 模块,在 NodeJS 应用程序中利用 chdb 的强大功能: +// Basic query +const result = query("SELECT version()", "CSV"); +console.log("ClickHouse version:", result); -```javascript -const { query, Session } = require("chdb"); +// Query with multiple columns +const multiResult = query("SELECT 'Hello' as greeting, 'chDB' as engine, 42 as answer", "CSV"); +console.log("Multi-column result:", multiResult); -var ret; +// Mathematical operations +const mathResult = query("SELECT 2 + 2 as sum, pi() as pi_value", "JSON"); +console.log("Math result:", mathResult); -// Test standalone query -ret = query("SELECT version(), 'Hello chDB', chdb()", "CSV"); -console.log("Standalone Query Result:", ret); +// System information +const systemInfo = query("SELECT * FROM system.functions LIMIT 5", "Pretty"); +console.log("System functions:", systemInfo); +``` -// Test session query -// Create a new session instance -const session = new Session("./chdb-node-tmp"); -ret = session.query("SELECT 123", "CSV") -console.log("Session Query Result:", ret); -ret = session.query("CREATE DATABASE IF NOT EXISTS testdb;" + - "CREATE TABLE IF NOT EXISTS testdb.testtable (id UInt32) ENGINE = MergeTree() ORDER BY id;"); +### Session-Based queries {#session-based-queries} -session.query("USE testdb; INSERT INTO testtable VALUES (1), (2), (3);") +```javascript +const { Session } = require("chdb"); + +// Create a session with persistent storage +const session = new Session("./chdb-node-data"); + +try { + // Create database and table + session.query(` + CREATE DATABASE IF NOT EXISTS myapp; + CREATE TABLE IF NOT EXISTS myapp.users ( + id UInt32, + name String, + email String, + created_at DateTime DEFAULT now() + ) ENGINE = MergeTree() ORDER BY id + `); + + // Insert sample data + session.query(` + INSERT INTO myapp.users (id, name, email) VALUES + (1, 'Alice', 'alice@example.com'), + (2, 'Bob', 'bob@example.com'), + (3, 'Charlie', 'charlie@example.com') + `); + + // Query the data with different formats + const csvResult = session.query("SELECT * FROM myapp.users ORDER BY id", "CSV"); + console.log("CSV Result:", csvResult); + + const jsonResult = session.query("SELECT * FROM myapp.users ORDER BY id", "JSON"); + console.log("JSON Result:", jsonResult); + + // Aggregate queries + const stats = session.query(` + SELECT + COUNT(*) as total_users, + MAX(id) as max_id, + MIN(created_at) as earliest_signup + FROM myapp.users + `, "Pretty"); + console.log("User Statistics:", stats); + +} finally { + // Always cleanup the session + session.cleanup(); // This deletes the database files +} +``` -ret = session.query("SELECT * FROM testtable;") -console.log("Session Query Result:", ret); +### Processing external data {#processing-external-data} -// Clean up the session -session.cleanup(); +```javascript +const { Session } = require("chdb"); + +const session = new Session("./data-processing"); + +try { + // Process CSV data from URL + const result = session.query(` + SELECT + COUNT(*) as total_records, + COUNT(DISTINCT "UserID") as unique_users + FROM url('https://datasets.clickhouse.com/hits/hits.csv', 'CSV') + LIMIT 1000 + `, "JSON"); + + console.log("External data analysis:", result); + + // Create table from external data + session.query(` + CREATE TABLE web_analytics AS + SELECT * FROM url('https://datasets.clickhouse.com/hits/hits.csv', 'CSV') + LIMIT 10000 + `); + + // Analyze the imported data + const analysis = session.query(` + SELECT + toDate("EventTime") as date, + COUNT(*) as events, + COUNT(DISTINCT "UserID") as unique_users + FROM web_analytics + GROUP BY date + ORDER BY date + LIMIT 10 + `, "Pretty"); + + console.log("Daily analytics:", analysis); + +} finally { + session.cleanup(); +} ``` -## 从源代码构建 {#build-from-source} +## Error handling {#error-handling} -```bash -npm run libchdb -npm install -npm run test +在使用 chDB 时始终适当地处理错误: + +```javascript +const { query, Session } = require("chdb"); + +// Error handling for standalone queries +function safeQuery(sql, format = "CSV") { + try { + const result = query(sql, format); + return { success: true, data: result }; + } catch (error) { + console.error("Query error:", error.message); + return { success: false, error: error.message }; + } +} + +// Example usage +const result = safeQuery("SELECT invalid_syntax"); +if (result.success) { + console.log("Query result:", result.data); +} else { + console.log("Query failed:", result.error); +} + +// Error handling for sessions +function safeSessionQuery() { + const session = new Session("./error-test"); + + try { + // This will throw an error due to invalid syntax + const result = session.query("CREATE TABLE invalid syntax", "CSV"); + console.log("Unexpected success:", result); + } catch (error) { + console.error("Session query error:", error.message); + } finally { + // Always cleanup, even if an error occurred + session.cleanup(); + } +} + +safeSessionQuery(); ``` + +## GitHub repository {#github-repository} + +- **GitHub Repository**: [chdb-io/chdb-node](https://github.com/chdb-io/chdb-node) +- **Issues and Support**: 在 [GitHub repository](https://github.com/chdb-io/chdb-node/issues) 上报告问题 +- **NPM Package**: [chdb on npm](https://www.npmjs.com/package/chdb) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/install/nodejs.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/install/nodejs.md.hash index fe9fd326416..9865fc0349a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/install/nodejs.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/install/nodejs.md.hash @@ -1 +1 @@ -63a51001fc4d0ca5 +7b69f28e40cc310d diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/install/python.md b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/install/python.md index a59d11056e3..ac6afdd6943 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/install/python.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/install/python.md @@ -9,14 +9,13 @@ - 'clickhouse-lite' - 'python' - 'install' +'doc_type': 'guide' --- - -# 安装 chDB for Python - ## 要求 {#requirements} -在 macOS 和 Linux (x86_64 和 ARM64) 上,Python 3.8+ +- Python 3.8+ +- 支持的平台:macOS 和 Linux (x86_64 和 ARM64) ## 安装 {#install} @@ -26,242 +25,813 @@ pip install chdb ## 使用 {#usage} -CLI 示例: +### 命令行界面 {#command-line-interface} -```python -python3 -m chdb [SQL] [OutputFormat] -``` +直接从命令行运行 SQL 查询: -```python +```bash + +# Basic query python3 -m chdb "SELECT 1, 'abc'" Pretty + + +# Query with formatting +python3 -m chdb "SELECT version()" JSON ``` -Python 文件示例: +### 基本的 Python 用法 {#basic-python-usage} ```python import chdb -res = chdb.query("SELECT 1, 'abc'", "CSV") -print(res, end="") + +# Simple query +result = chdb.query("SELECT 1 as id, 'Hello World' as message", "CSV") +print(result) + + +# Get query statistics +print(f"Rows read: {result.rows_read()}") +print(f"Bytes read: {result.bytes_read()}") +print(f"Execution time: {result.elapsed()} seconds") ``` -查询可以使用任何 [支持的格式](/interfaces/formats) 返回数据,以及 `Dataframe` 和 `Debug`。 +### 基于连接的 API (推荐) {#connection-based-api} -## GitHub 仓库 {#github-repository} +为了更好的资源管理和性能: -您可以在 [chdb-io/chdb](https://github.com/chdb-io/chdb) 查找该项目的 GitHub 仓库。 +```python +import chdb -## 数据输入 {#data-input} -以下方法可用于访问磁盘和内存中的数据格式: +# Create connection (in-memory by default) +conn = chdb.connect(":memory:") -### 对文件的查询 (Parquet, CSV, JSON, Arrow, ORC 及 60+ 格式) {#query-on-file-parquet-csv-json-arrow-orc-and-60} +# Or use file-based: conn = chdb.connect("mydata.db") -您可以执行 SQL 并返回所需格式的数据。 -```python -import chdb -res = chdb.query('select version()', 'Pretty'); print(res) +# Create cursor for query execution +cur = conn.cursor() + + +# Execute queries +cur.execute("SELECT number, toString(number) as str FROM system.numbers LIMIT 3") + + +# Fetch results in different ways +print(cur.fetchone()) # Single row: (0, '0') +print(cur.fetchmany(2)) # Multiple rows: ((1, '1'), (2, '2')) + + +# Get metadata +print(cur.column_names()) # ['number', 'str'] +print(cur.column_types()) # ['UInt64', 'String'] + + +# Use cursor as iterator +for row in cur: + print(row) + + +# Always close resources +cur.close() +conn.close() ``` -**处理 Parquet 或 CSV** +## 数据输入方法 {#data-input} + +### 基于文件的数据源 {#file-based-data-sources} + +chDB 支持超过 70 种数据格式进行直接文件查询: ```python +import chdb + +# Prepare your data + +# ... + -# See more data type format in tests/format_output.py -res = chdb.query('select * from file("data.parquet", Parquet)', 'JSON'); print(res) -res = chdb.query('select * from file("data.csv", CSV)', 'CSV'); print(res) -print(f"SQL read {res.rows_read()} rows, {res.bytes_read()} bytes, elapsed {res.elapsed()} seconds") +# Query Parquet files +result = chdb.query(""" + SELECT customer_id, sum(amount) as total + FROM file('sales.parquet', Parquet) + GROUP BY customer_id + ORDER BY total DESC + LIMIT 10 +""", 'JSONEachRow') + + +# Query CSV with headers +result = chdb.query(""" + SELECT * FROM file('data.csv', CSVWithNames) + WHERE column1 > 100 +""", 'DataFrame') + + +# Multiple file formats +result = chdb.query(""" + SELECT * FROM file('logs*.jsonl', JSONEachRow) + WHERE timestamp > '2024-01-01' +""", 'Pretty') ``` -**Pandas DataFrame 输出** +### 输出格式示例 {#output-format-examples} + ```python -# See more in https://clickhouse.com/docs/interfaces/formats -chdb.query('select * from file("data.parquet", Parquet)', 'Dataframe') +# DataFrame for analysis +df = chdb.query('SELECT * FROM system.numbers LIMIT 5', 'DataFrame') +print(type(df)) # + + +# Arrow Table for interoperability +arrow_table = chdb.query('SELECT * FROM system.numbers LIMIT 5', 'ArrowTable') +print(type(arrow_table)) # + + +# JSON for APIs +json_result = chdb.query('SELECT version()', 'JSON') +print(json_result) + + +# Pretty format for debugging +pretty_result = chdb.query('SELECT * FROM system.numbers LIMIT 3', 'Pretty') +print(pretty_result) ``` -### 对表的查询 (Pandas DataFrame, Parquet 文件/字节, Arrow 字节) {#query-on-table-pandas-dataframe-parquet-filebytes-arrow-bytes} +### DataFrame 操作 {#dataframe-operations} -**对 Pandas DataFrame 的查询** +#### 传统 DataFrame API {#legacy-dataframe-api} ```python import chdb.dataframe as cdf import pandas as pd -# Join 2 DataFrames + +# Join multiple DataFrames df1 = pd.DataFrame({'a': [1, 2, 3], 'b': ["one", "two", "three"]}) df2 = pd.DataFrame({'c': [1, 2, 3], 'd': ["①", "②", "③"]}) -ret_tbl = cdf.query(sql="select * from __tbl1__ t1 join __tbl2__ t2 on t1.a = t2.c", - tbl1=df1, tbl2=df2) -print(ret_tbl) -# Query on the DataFrame Table -print(ret_tbl.query('select b, sum(a) from __table__ group by b')) +result_df = cdf.query( + sql="SELECT * FROM __tbl1__ t1 JOIN __tbl2__ t2 ON t1.a = t2.c", + tbl1=df1, + tbl2=df2 +) +print(result_df) + + +# Query the result DataFrame +summary = result_df.query('SELECT b, sum(a) FROM __table__ GROUP BY b') +print(summary) ``` -### 使用有状态会话的查询 {#query-with-stateful-session} +#### Python 表引擎 (推荐) {#python-table-engine-recommended} + +```python +import chdb +import pandas as pd +import pyarrow as pa + -会话将保持查询的状态。所有 DDL 和 DML 状态将保存在一个目录中。目录路径可以作为参数传入。如果没有传入,将创建一个临时目录。 +# Query Pandas DataFrame directly +df = pd.DataFrame({ + "customer_id": [1, 2, 3, 1, 2], + "product": ["A", "B", "A", "C", "A"], + "amount": [100, 200, 150, 300, 250], + "metadata": [ + {'category': 'electronics', 'priority': 'high'}, + {'category': 'books', 'priority': 'low'}, + {'category': 'electronics', 'priority': 'medium'}, + {'category': 'clothing', 'priority': 'high'}, + {'category': 'books', 'priority': 'low'} + ] +}) + + +# Direct DataFrame querying with JSON support +result = chdb.query(""" + SELECT + customer_id, + sum(amount) as total_spent, + toString(metadata.category) as category + FROM Python(df) + WHERE toString(metadata.priority) = 'high' + GROUP BY customer_id, toString(metadata.category) + ORDER BY total_spent DESC +""").show() + + +# Query Arrow Table +arrow_table = pa.table({ + "id": [1, 2, 3, 4], + "name": ["Alice", "Bob", "Charlie", "David"], + "score": [98, 89, 86, 95] +}) + +chdb.query(""" + SELECT name, score + FROM Python(arrow_table) + ORDER BY score DESC +""").show() +``` -如果未指定路径,临时目录将在会话对象被删除时删除。否则,路径将被保留。 +### 有状态会话 {#stateful-sessions} -请注意,默认数据库是 `_local`,默认引擎是 `Memory`,这意味着所有数据都将存储在内存中。如果您想将数据存储在磁盘上,则应创建另一个数据库。 +会话在多次操作中保持查询状态,能够支持复杂的工作流: ```python -from chdb import session as chs - -## Create DB, Table, View in temp session, auto cleanup when session is deleted. -sess = chs.Session() -sess.query("CREATE DATABASE IF NOT EXISTS db_xxx ENGINE = Atomic") -sess.query("CREATE TABLE IF NOT EXISTS db_xxx.log_table_xxx (x String, y Int) ENGINE = Log;") -sess.query("INSERT INTO db_xxx.log_table_xxx VALUES ('a', 1), ('b', 3), ('c', 2), ('d', 5);") -sess.query( - "CREATE VIEW db_xxx.view_xxx AS SELECT * FROM db_xxx.log_table_xxx LIMIT 4;" +from chdb import session + + +# Temporary session (auto-cleanup) +sess = session.Session() + + +# Or persistent session with specific path + +# sess = session.Session("/path/to/data") + + +# Create database and tables +sess.query("CREATE DATABASE IF NOT EXISTS analytics ENGINE = Atomic") +sess.query("USE analytics") + +sess.query(""" + CREATE TABLE sales ( + id UInt64, + product String, + amount Decimal(10,2), + sale_date Date + ) ENGINE = MergeTree() + ORDER BY (sale_date, id) +""") + + +# Insert data +sess.query(""" + INSERT INTO sales VALUES + (1, 'Laptop', 999.99, '2024-01-15'), + (2, 'Mouse', 29.99, '2024-01-16'), + (3, 'Keyboard', 79.99, '2024-01-17') +""") + + +# Create materialized views +sess.query(""" + CREATE MATERIALIZED VIEW daily_sales AS + SELECT + sale_date, + count() as orders, + sum(amount) as revenue + FROM sales + GROUP BY sale_date +""") + + +# Query the view +result = sess.query("SELECT * FROM daily_sales ORDER BY sale_date", "Pretty") +print(result) + + +# Session automatically manages resources +sess.close() # Optional - auto-closed when object is deleted +``` + +### 先进的会话特性 {#advanced-session-features} + +```python + +# Session with custom settings +sess = session.Session( + path="/tmp/analytics_db", ) -print("Select from view:\n") -print(sess.query("SELECT * FROM db_xxx.view_xxx", "Pretty")) + + +# Query performance optimization +result = sess.query(""" + SELECT product, sum(amount) as total + FROM sales + GROUP BY product + ORDER BY total DESC + SETTINGS max_threads = 4 +""", "JSON") ``` -另请参见: [test_stateful.py](https://github.com/chdb-io/chdb/blob/main/tests/test_stateful.py)。 +另见:[test_stateful.py](https://github.com/chdb-io/chdb/blob/main/tests/test_stateful.py)。 + +### Python DB-API 2.0 接口 {#python-db-api-20} -### 使用 Python DB-API 2.0 的查询 {#query-with-python-db-api-20} +标准数据库接口,以兼容现有的 Python 应用: ```python import chdb.dbapi as dbapi -print("chdb driver version: {0}".format(dbapi.get_client_info())) - -conn1 = dbapi.connect() -cur1 = conn1.cursor() -cur1.execute('select version()') -print("description: ", cur1.description) -print("data: ", cur1.fetchone()) -cur1.close() -conn1.close() + + +# Check driver information +print(f"chDB driver version: {dbapi.get_client_info()}") + + +# Create connection +conn = dbapi.connect() +cursor = conn.cursor() + + +# Execute queries with parameters +cursor.execute(""" + SELECT number, number * ? as doubled + FROM system.numbers + LIMIT ? +""", (2, 5)) + + +# Get metadata +print("Column descriptions:", cursor.description) +print("Row count:", cursor.rowcount) + + +# Fetch results +print("First row:", cursor.fetchone()) +print("Next 2 rows:", cursor.fetchmany(2)) + + +# Fetch remaining rows +for row in cursor.fetchall(): + print("Row:", row) + + +# Batch operations +data = [(1, 'Alice'), (2, 'Bob'), (3, 'Charlie')] +cursor.execute(""" + CREATE TABLE temp_users ( + id UInt64, + name String + ) ENGINE = MergeTree() + ORDER BY (id) +""") +cursor.executemany( + "INSERT INTO temp_users (id, name) VALUES (?, ?)", + data +) ``` -### 使用 UDF (用户定义函数) 的查询 {#query-with-udf-user-defined-functions} +### 用户定义函数 (UDF) {#user-defined-functions} + +用自定义 Python 函数扩展 SQL: + +#### 基本 UDF 用法 {#basic-udf-usage} ```python from chdb.udf import chdb_udf from chdb import query + +# Simple mathematical function @chdb_udf() -def sum_udf(lhs, rhs): - return int(lhs) + int(rhs) +def add_numbers(a, b): + return int(a) + int(b) -print(query("select sum_udf(12,22)")) + +# String processing function +@chdb_udf() +def reverse_string(text): + return text[::-1] + + +# JSON processing function +@chdb_udf() +def extract_json_field(json_str, field): + import json + try: + data = json.loads(json_str) + return str(data.get(field, '')) + except: + return '' + + +# Use UDFs in queries +result = query(""" + SELECT + add_numbers('10', '20') as sum_result, + reverse_string('hello') as reversed, + extract_json_field('{"name": "John", "age": 30}', 'name') as name +""") +print(result) ``` -关于 chDB Python UDF (用户定义函数) 装饰器的一些说明。 -1. 该函数应为无状态的。仅支持 UDF,不支持 UDAF(用户定义聚合函数)。 -2. 默认返回类型为字符串。如果您想更改返回类型,可以将返回类型作为参数传入。返回类型应为 [以下类型之一](/sql-reference/data-types)。 -3. 该函数应接受类型为字符串的参数。由于输入为制表符分隔的所有参数都是字符串。 -4. 该函数将在每一行输入时被调用。例如: +#### 带有自定义返回类型的高级 UDF {#advanced-udf-custom-return-types} + ```python -def sum_udf(lhs, rhs): - return int(lhs) + int(rhs) - -for line in sys.stdin: - args = line.strip().split('\t') - lhs = args[0] - rhs = args[1] - print(sum_udf(lhs, rhs)) - sys.stdout.flush() + +# UDF with specific return type +@chdb_udf(return_type="Float64") +def calculate_bmi(height_str, weight_str): + height = float(height_str) / 100 # Convert cm to meters + weight = float(weight_str) + return weight / (height * height) + + +# UDF for data validation +@chdb_udf(return_type="UInt8") +def is_valid_email(email): + import re + pattern = r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$' + return 1 if re.match(pattern, email) else 0 + + +# Use in complex queries +result = query(""" + SELECT + name, + calculate_bmi(height, weight) as bmi, + is_valid_email(email) as has_valid_email + FROM ( + SELECT + 'John' as name, '180' as height, '75' as weight, 'john@example.com' as email + UNION ALL + SELECT + 'Jane' as name, '165' as height, '60' as weight, 'invalid-email' as email + ) +""", "Pretty") +print(result) ``` -5. 该函数应是一个纯 Python 函数。您应该导入所有在 **函数内部** 使用的 Python 模块。 + +#### UDF 最佳实践 {#udf-best-practices} + +1. **无状态函数**:UDF 应该是没有副作用的纯函数 +2. **函数内部导入**:所有必要的模块必须在 UDF 内部导入 +3. **字符串输入/输出**:所有 UDF 参数都是字符串(TabSeparated 格式) +4. **错误处理**:包括 try-catch 块以确保 UDF 的健壮性 +5. **性能**:UDF 对每一行都调用,因此需优化性能 + ```python -def func_use_json(arg): + +# Well-structured UDF with error handling +@chdb_udf(return_type="String") +def safe_json_extract(json_str, path): import json - ... + try: + data = json.loads(json_str) + keys = path.split('.') + result = data + for key in keys: + if isinstance(result, dict) and key in result: + result = result[key] + else: + return 'null' + return str(result) + except Exception as e: + return f'error: {str(e)}' + + +# Use with complex nested JSON +query(""" + SELECT safe_json_extract( + '{"user": {"profile": {"name": "Alice", "age": 25}}}', + 'user.profile.name' + ) as extracted_name +""") ``` -6. 使用的 Python 解释器与运行脚本所使用的相同。您可以通过 `sys.executable` 获取它。 -另请参见: [test_udf.py](https://github.com/chdb-io/chdb/blob/main/tests/test_udf.py)。 +### 流式查询处理 {#streaming-queries} + +以恒定的内存使用处理大数据集: + +```python +from chdb import session + +sess = session.Session() + + +# Setup large dataset +sess.query(""" + CREATE TABLE large_data ENGINE = Memory() AS + SELECT number as id, toString(number) as data + FROM numbers(1000000) +""") + + +# Example 1: Basic streaming with context manager +total_rows = 0 +with sess.send_query("SELECT * FROM large_data", "CSV") as stream: + for chunk in stream: + chunk_rows = len(chunk.data().split('\n')) - 1 + total_rows += chunk_rows + print(f"Processed chunk: {chunk_rows} rows") + + # Early termination if needed + if total_rows > 100000: + break + +print(f"Total rows processed: {total_rows}") + + +# Example 2: Manual iteration with explicit cleanup +stream = sess.send_query("SELECT * FROM large_data WHERE id % 100 = 0", "JSONEachRow") +processed_count = 0 + +while True: + chunk = stream.fetch() + if chunk is None: + break + + # Process chunk data + lines = chunk.data().strip().split('\n') + for line in lines: + if line: # Skip empty lines + processed_count += 1 + + print(f"Processed {processed_count} records so far...") + +stream.close() # Important: explicit cleanup + + +# Example 3: Arrow integration for external libraries +import pyarrow as pa +from deltalake import write_deltalake + + +# Stream results in Arrow format +stream = sess.send_query("SELECT * FROM large_data LIMIT 100000", "Arrow") + + +# Create RecordBatchReader with custom batch size +batch_reader = stream.record_batch(rows_per_batch=10000) + + +# Export to Delta Lake +write_deltalake( + table_or_uri="./my_delta_table", + data=batch_reader, + mode="overwrite" +) + +stream.close() +sess.close() +``` ### Python 表引擎 {#python-table-engine} -### 对 Pandas DataFrame 的查询 {#query-on-pandas-dataframe} +#### 查询 Pandas DataFrames {#query-pandas-dataframes} ```python import chdb import pandas as pd -df = pd.DataFrame( - { - "a": [1, 2, 3, 4, 5, 6], - "b": ["tom", "jerry", "auxten", "tom", "jerry", "auxten"], - } -) -chdb.query("SELECT b, sum(a) FROM Python(df) GROUP BY b ORDER BY b").show() + +# Complex DataFrame with nested data +df = pd.DataFrame({ + "customer_id": [1, 2, 3, 4, 5, 6], + "customer_name": ["Alice", "Bob", "Charlie", "Alice", "Bob", "David"], + "orders": [ + {"order_id": 101, "amount": 250.50, "items": ["laptop", "mouse"]}, + {"order_id": 102, "amount": 89.99, "items": ["book"]}, + {"order_id": 103, "amount": 1299.99, "items": ["phone", "case", "charger"]}, + {"order_id": 104, "amount": 45.50, "items": ["pen", "paper"]}, + {"order_id": 105, "amount": 199.99, "items": ["headphones"]}, + {"order_id": 106, "amount": 15.99, "items": ["cable"]} + ] +}) + + +# Advanced querying with JSON operations +result = chdb.query(""" + SELECT + customer_name, + count() as order_count, + sum(toFloat64(orders.amount)) as total_spent, + arrayStringConcat( + arrayDistinct( + arrayFlatten( + groupArray(orders.items) + ) + ), + ', ' + ) as all_items + FROM Python(df) + GROUP BY customer_name + HAVING total_spent > 100 + ORDER BY total_spent DESC +""").show() + + +# Window functions on DataFrames +window_result = chdb.query(""" + SELECT + customer_name, + toFloat64(orders.amount) as amount, + sum(toFloat64(orders.amount)) OVER ( + PARTITION BY customer_name + ORDER BY toInt32(orders.order_id) + ) as running_total + FROM Python(df) + ORDER BY customer_name, toInt32(orders.order_id) +""", "Pretty") +print(window_result) ``` -### 对 Arrow 表的查询 {#query-on-arrow-table} +#### 使用 PyReader 的自定义数据源 {#custom-data-sources-pyreader} + +为专业数据源实现自定义数据读取器: ```python import chdb -import pyarrow as pa -arrow_table = pa.table( - { - "a": [1, 2, 3, 4, 5, 6], - "b": ["tom", "jerry", "auxten", "tom", "jerry", "auxten"], - } -) +from typing import List, Tuple, Any +import json + +class DatabaseReader(chdb.PyReader): + """Custom reader for database-like data sources""" -chdb.query( - "SELECT b, sum(a) FROM Python(arrow_table) GROUP BY b ORDER BY b", "debug" -).show() + def __init__(self, connection_string: str): + # Simulate database connection + self.data = self._load_data(connection_string) + self.cursor = 0 + self.batch_size = 1000 + super().__init__(self.data) + + def _load_data(self, conn_str): + # Simulate loading from database + return { + "id": list(range(1, 10001)), + "name": [f"user_{i}" for i in range(1, 10001)], + "score": [i * 10 + (i % 7) for i in range(1, 10001)], + "metadata": [ + json.dumps({"level": i % 5, "active": i % 3 == 0}) + for i in range(1, 10001) + ] + } + + def get_schema(self) -> List[Tuple[str, str]]: + """Define table schema with explicit types""" + return [ + ("id", "UInt64"), + ("name", "String"), + ("score", "Int64"), + ("metadata", "String") # JSON stored as string + ] + + def read(self, col_names: List[str], count: int) -> List[List[Any]]: + """Read data in batches""" + if self.cursor >= len(self.data["id"]): + return [] # No more data + + end_pos = min(self.cursor + min(count, self.batch_size), len(self.data["id"])) + + # Return data for requested columns + result = [] + for col in col_names: + if col in self.data: + result.append(self.data[col][self.cursor:end_pos]) + else: + # Handle missing columns + result.append([None] * (end_pos - self.cursor)) + + self.cursor = end_pos + return result + +### JSON Type Inference and Handling {#json-type-inference-handling} + +chDB automatically handles complex nested data structures: + +```python +import pandas as pd +import chdb + + +# DataFrame with mixed JSON objects +df_with_json = pd.DataFrame({ + "user_id": [1, 2, 3, 4], + "profile": [ + {"name": "Alice", "age": 25, "preferences": ["music", "travel"]}, + {"name": "Bob", "age": 30, "location": {"city": "NYC", "country": "US"}}, + {"name": "Charlie", "skills": ["python", "sql", "ml"], "experience": 5}, + {"score": 95, "rank": "gold", "achievements": [{"title": "Expert", "date": "2024-01-01"}]} + ] +}) + + +# Control JSON inference with settings +result = chdb.query(""" + SELECT + user_id, + profile.name as name, + profile.age as age, + length(profile.preferences) as pref_count, + profile.location.city as city + FROM Python(df_with_json) + SETTINGS pandas_analyze_sample = 1000 -- Analyze all rows for JSON detection +""", "Pretty") +print(result) + + +# Advanced JSON operations +complex_json = chdb.query(""" + SELECT + user_id, + JSONLength(toString(profile)) as json_fields, + JSONType(toString(profile), 'preferences') as pref_type, + if( + JSONHas(toString(profile), 'achievements'), + JSONExtractString(toString(profile), 'achievements[0].title'), + 'None' + ) as first_achievement + FROM Python(df_with_json) +""", "JSONEachRow") +print(complex_json) ``` -### 对 chdb.PyReader 类实例的查询 {#query-on-chdbpyreader-class-instance} +## 性能和优化 {#performance-optimization} + +### 基准测试 {#benchmarks} -1. 您必须继承 chdb.PyReader 类并实现 `read` 方法。 -2. `read` 方法应: - 1. 返回一个列表的列表,第一维是列,第二维是行,列的顺序应与 `read` 的第一个参数 `col_names` 相同。 - 1. 在没有更多数据可读时返回空列表。 - 1. 是有状态的,游标应在 `read` 方法中更新。 -3. 可选的 `get_schema` 方法可以实现以返回表的模式。原型为 `def get_schema(self) -> List[Tuple[str, str]]:`,返回值是一个元组列表,每个元组包含列名和列类型。列类型应为 [以下类型之一](/sql-reference/data-types)。 +chDB 一直优于其他嵌入式引擎: +- **DataFrame 操作**:比传统 DataFrame 库的分析查询快 2-5 倍 +- **Parquet 处理**:与领先的列式引擎竞争 +- **内存效率**:比其他选项的内存占用更低 -
+[更多基准测试结果详情](https://github.com/chdb-io/chdb?tab=readme-ov-file#benchmark) + +### 性能提示 {#performance-tips} ```python import chdb -class myReader(chdb.PyReader): - def __init__(self, data): - self.data = data - self.cursor = 0 - super().__init__(data) - - def read(self, col_names, count): - print("Python func read", col_names, count, self.cursor) - if self.cursor >= len(self.data["a"]): - return [] - block = [self.data[col] for col in col_names] - self.cursor += len(block[0]) - return block - -reader = myReader( - { - "a": [1, 2, 3, 4, 5, 6], - "b": ["tom", "jerry", "auxten", "tom", "jerry", "auxten"], - } -) -chdb.query( - "SELECT b, sum(a) FROM Python(reader) GROUP BY b ORDER BY b" -).show() -``` +# 1. Use appropriate output formats +df_result = chdb.query("SELECT * FROM large_table", "DataFrame") # For analysis +arrow_result = chdb.query("SELECT * FROM large_table", "Arrow") # For interop +native_result = chdb.query("SELECT * FROM large_table", "Native") # For chDB-to-chDB + + +# 2. Optimize queries with settings +fast_result = chdb.query(""" + SELECT customer_id, sum(amount) + FROM sales + GROUP BY customer_id + SETTINGS + max_threads = 8, + max_memory_usage = '4G', + use_uncompressed_cache = 1 +""", "DataFrame") + + +# 3. Leverage streaming for large datasets +from chdb import session + +sess = session.Session() + + +# Setup large dataset +sess.query(""" + CREATE TABLE large_sales ENGINE = Memory() AS + SELECT + number as sale_id, + number % 1000 as customer_id, + rand() % 1000 as amount + FROM numbers(10000000) +""") -另请参见: [test_query_py.py](https://github.com/chdb-io/chdb/blob/main/tests/test_query_py.py)。 -## 限制 {#limitations} +# Stream processing with constant memory usage +total_amount = 0 +processed_rows = 0 -1. 支持的列类型:`pandas.Series`, `pyarrow.array`,`chdb.PyReader` -1. 支持的数据类型:Int, UInt, Float, String, Date, DateTime, Decimal -1. Python 对象类型将转化为字符串 -1. Pandas DataFrame 的性能最佳,Arrow 表优于 PyReader +with sess.send_query("SELECT customer_id, sum(amount) as total FROM large_sales GROUP BY customer_id", "JSONEachRow") as stream: + for chunk in stream: + lines = chunk.data().strip().split('\n') + for line in lines: + if line: # Skip empty lines + import json + row = json.loads(line) + total_amount += row['total'] + processed_rows += 1 -
+ print(f"Processed {processed_rows} customer records, running total: {total_amount}") + + # Early termination for demo + if processed_rows > 1000: + break + +print(f"Final result: {processed_rows} customers processed, total amount: {total_amount}") + + +# Stream to external systems (e.g., Delta Lake) +stream = sess.send_query("SELECT * FROM large_sales LIMIT 1000000", "Arrow") +batch_reader = stream.record_batch(rows_per_batch=50000) + + +# Process in batches +for batch in batch_reader: + print(f"Processing batch with {batch.num_rows} rows...") + # Transform or export each batch + # df_batch = batch.to_pandas() + # process_batch(df_batch) + +stream.close() +sess.close() +``` + +## GitHub 仓库 {#github-repository} -更多示例,请参见 [examples](https://github.com/chdb-io/chdb/tree/main/examples) 和 [tests](https://github.com/chdb-io/chdb/tree/main/tests)。 +- **主仓库**:[chdb-io/chdb](https://github.com/chdb-io/chdb) +- **问题和支持**:在 [GitHub 仓库](https://github.com/chdb-io/chdb/issues) 上报告问题 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/install/python.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/install/python.md.hash index aca9c2fa810..a994ddbeaec 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/install/python.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/install/python.md.hash @@ -1 +1 @@ -ecb29b9291e6fa5c +a7d9de3caef570e5 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/install/rust.md b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/install/rust.md index 7486086f1d3..f449e492b53 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/install/rust.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/install/rust.md @@ -1,28 +1,169 @@ --- -'title': '为 Rust 安装 chDB' +'title': '安装 chDB 以用于 Rust' 'sidebar_label': 'Rust' 'slug': '/chdb/install/rust' -'description': '如何为 Rust 安装 chDB' +'description': '如何安装和使用 chDB Rust 绑定' 'keywords': - 'chdb' - 'embedded' - 'clickhouse-lite' -- 'bun' +- 'rust' - 'install' +- 'ffi' +- 'bindings' +'doc_type': 'guide' --- -## 要求 {#requirements} -安装 [libchdb](https://github.com/chdb-io/chdb): +# chDB for Rust {#chdb-for-rust} + +chDB-rust 提供实验性的 FFI(外部函数接口)绑定,用于 chDB,使您能够在 Rust 应用程序中直接运行 ClickHouse 查询,而无需任何外部依赖。 + +## Installation {#installation} + +### Install libchdb {#install-libchdb} + +安装 chDB 库: ```bash curl -sL https://lib.chdb.io | bash ``` -## 用法 {#usage} +## Usage {#usage} + +chDB Rust 提供无状态和有状态查询执行模式。 + +### Stateless usage {#stateless-usage} + +对于没有持久状态的简单查询: + +```rust +use chdb_rust::{execute, arg::Arg, format::OutputFormat}; + +fn main() -> Result<(), Box> { + // Execute a simple query + let result = execute( + "SELECT version()", + Some(&[Arg::OutputFormat(OutputFormat::JSONEachRow)]) + )?; + println!("ClickHouse version: {}", result.data_utf8()?); + + // Query with CSV file + let result = execute( + "SELECT * FROM file('data.csv', 'CSV')", + Some(&[Arg::OutputFormat(OutputFormat::JSONEachRow)]) + )?; + println!("CSV data: {}", result.data_utf8()?); + + Ok(()) +} +``` + +### Stateful usage (Sessions) {#stateful-usage-sessions} + +对于需要持久状态的查询,如数据库和表: + +```rust +use chdb_rust::{ + session::SessionBuilder, + arg::Arg, + format::OutputFormat, + log_level::LogLevel +}; +use tempdir::TempDir; + +fn main() -> Result<(), Box> { + // Create a temporary directory for database storage + let tmp = TempDir::new("chdb-rust")?; + + // Build session with configuration + let session = SessionBuilder::new() + .with_data_path(tmp.path()) + .with_arg(Arg::LogLevel(LogLevel::Debug)) + .with_auto_cleanup(true) // Cleanup on drop + .build()?; + + // Create database and table + session.execute( + "CREATE DATABASE demo; USE demo", + Some(&[Arg::MultiQuery]) + )?; + + session.execute( + "CREATE TABLE logs (id UInt64, msg String) ENGINE = MergeTree() ORDER BY id", + None, + )?; + + // Insert data + session.execute( + "INSERT INTO logs (id, msg) VALUES (1, 'Hello'), (2, 'World')", + None, + )?; + + // Query data + let result = session.execute( + "SELECT * FROM logs ORDER BY id", + Some(&[Arg::OutputFormat(OutputFormat::JSONEachRow)]), + )?; + + println!("Query results:\n{}", result.data_utf8()?); + + // Get query statistics + println!("Rows read: {}", result.rows_read()); + println!("Bytes read: {}", result.bytes_read()); + println!("Query time: {:?}", result.elapsed()); + + Ok(()) +} +``` + +## Building and testing {#building-testing} + +### Build the project {#build-the-project} + +```bash +cargo build +``` + +### Run tests {#run-tests} + +```bash +cargo test +``` + +### Development dependencies {#development-dependencies} -此绑定仍在进行中。请按照 [chdb-rust](https://github.com/chdb-io/chdb-rust) 中的说明开始。 +该项目包括以下开发依赖: +- `bindgen` (v0.70.1) - 从 C 头文件生成 FFI 绑定 +- `tempdir` (v0.3.7) - 在测试中处理临时目录 +- `thiserror` (v1) - 错误处理工具 + +## Error handling {#error-handling} + +chDB Rust 通过 `Error` 枚举提供全面的错误处理: + +```rust +use chdb_rust::{execute, error::Error}; + +match execute("SELECT 1", None) { + Ok(result) => { + println!("Success: {}", result.data_utf8()?); + }, + Err(Error::QueryError(msg)) => { + eprintln!("Query failed: {}", msg); + }, + Err(Error::NoResult) => { + eprintln!("No result returned"); + }, + Err(Error::NonUtf8Sequence(e)) => { + eprintln!("Invalid UTF-8: {}", e); + }, + Err(e) => { + eprintln!("Other error: {}", e); + } +} +``` -## GitHub 仓库 {#github-repository} +## GitHub repository {#github-repository} 您可以在 [chdb-io/chdb-rust](https://github.com/chdb-io/chdb-rust) 找到该项目的 GitHub 仓库。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/install/rust.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/install/rust.md.hash index 78064df2556..0e82181b79c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/install/rust.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/install/rust.md.hash @@ -1 +1 @@ -5e56761c0e898d17 +a90aab846dc359bd diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/reference/data-formats.md b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/reference/data-formats.md index 899876be534..2a8423fce4a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/reference/data-formats.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/reference/data-formats.md @@ -6,97 +6,105 @@ 'keywords': - 'chdb' - 'data formats' +'doc_type': 'reference' --- 当涉及到数据格式时,chDB 与 ClickHouse 具有 100% 的功能兼容性。 -输入格式用于解析提供给 `INSERT` 和 `SELECT` 的数据,这些数据来自文件支持的表,例如 `File`、`URL` 或 `S3`。 -输出格式用于整理 `SELECT` 的结果,并将 `INSERT` 语句写入到文件支持的表中。 -除了 ClickHouse 支持的数据格式,chDB 还支持: +输入格式用于解析提供给 `INSERT` 和 `SELECT` 的数据,这些数据来自于文件支持的表,例如 `File`、`URL` 或 `S3`。 +输出格式用于安排 `SELECT` 的结果,并将数据执行 `INSERT` 到文件支持的表中。 +除了 ClickHouse 支持的数据格式外,chDB 还支持: -- `ArrowTable` 作为输出格式,其类型为 Python `pyarrow.Table` -- `DataFrame` 作为输入和输出格式,其类型为 Python `pandas.DataFrame`。有关示例,请参见 [`test_joindf.py`](https://github.com/chdb-io/chdb/blob/main/tests/test_joindf.py) -- `Debug` 作为输出(作为 `CSV` 的别名),但启用了来自 ClickHouse 的调试详细输出。 +- `ArrowTable` 作为输出格式,类型为 Python `pyarrow.Table` +- `DataFrame` 作为输入和输出格式,类型为 Python `pandas.DataFrame`。有关示例,请参见 [`test_joindf.py`](https://github.com/chdb-io/chdb/blob/main/tests/test_joindf.py) +- `Debug` 作为输出(作为 `CSV` 的别名),但启用 ClickHouse 的调试详细输出。 ClickHouse 支持的数据格式包括: -| 格式 | 输入 | 输出 | -|-------------------------------|-------|--------| -| TabSeparated | ✔ | ✔ | -| TabSeparatedRaw | ✔ | ✔ | -| TabSeparatedWithNames | ✔ | ✔ | -| TabSeparatedWithNamesAndTypes | ✔ | ✔ | -| TabSeparatedRawWithNames | ✔ | ✔ | -| TabSeparatedRawWithNamesAndTypes| ✔ | ✔ | -| Template | ✔ | ✔ | -| TemplateIgnoreSpaces | ✔ | ✗ | -| CSV | ✔ | ✔ | -| CSVWithNames | ✔ | ✔ | -| CSVWithNamesAndTypes | ✔ | ✔ | -| CustomSeparated | ✔ | ✔ | -| CustomSeparatedWithNames | ✔ | ✔ | -| CustomSeparatedWithNamesAndTypes| ✔ | ✔ | -| SQLInsert | ✗ | ✔ | -| Values | ✔ | ✔ | -| Vertical | ✗ | ✔ | -| JSON | ✔ | ✔ | -| JSONAsString | ✔ | ✗ | -| JSONStrings | ✔ | ✔ | -| JSONColumns | ✔ | ✔ | -| JSONColumnsWithMetadata | ✔ | ✔ | -| JSONCompact | ✔ | ✔ | -| JSONCompactStrings | ✗ | ✔ | -| JSONCompactColumns | ✔ | ✔ | -| JSONEachRow | ✔ | ✔ | -| PrettyJSONEachRow | ✗ | ✔ | -| JSONEachRowWithProgress | ✗ | ✔ | -| JSONStringsEachRow | ✔ | ✔ | -| JSONStringsEachRowWithProgress | ✗ | ✔ | -| JSONCompactEachRow | ✔ | ✔ | -| JSONCompactEachRowWithNames | ✔ | ✔ | -| JSONCompactEachRowWithNamesAndTypes | ✔ | ✔ | -| JSONCompactStringsEachRow | ✔ | ✔ | -| JSONCompactStringsEachRowWithNames | ✔ | ✔ | +| 格式 | 输入 | 输出 | +|---------------------------------|-------|-------| +| TabSeparated | ✔ | ✔ | +| TabSeparatedRaw | ✔ | ✔ | +| TabSeparatedWithNames | ✔ | ✔ | +| TabSeparatedWithNamesAndTypes | ✔ | ✔ | +| TabSeparatedRawWithNames | ✔ | ✔ | +| TabSeparatedRawWithNamesAndTypes| ✔ | ✔ | +| Template | ✔ | ✔ | +| TemplateIgnoreSpaces | ✔ | ✗ | +| CSV | ✔ | ✔ | +| CSVWithNames | ✔ | ✔ | +| CSVWithNamesAndTypes | ✔ | ✔ | +| CustomSeparated | ✔ | ✔ | +| CustomSeparatedWithNames | ✔ | ✔ | +| CustomSeparatedWithNamesAndTypes| ✔ | ✔ | +| SQLInsert | ✗ | ✔ | +| Values | ✔ | ✔ | +| Vertical | ✗ | ✔ | +| JSON | ✔ | ✔ | +| JSONAsString | ✔ | ✗ | +| JSONAsObject | ✔ | ✗ | +| JSONStrings | ✔ | ✔ | +| JSONColumns | ✔ | ✔ | +| JSONColumnsWithMetadata | ✔ | ✔ | +| JSONCompact | ✔ | ✔ | +| JSONCompactStrings | ✗ | ✔ | +| JSONCompactColumns | ✔ | ✔ | +| JSONEachRow | ✔ | ✔ | +| PrettyJSONEachRow | ✗ | ✔ | +| JSONEachRowWithProgress | ✗ | ✔ | +| JSONStringsEachRow | ✔ | ✔ | +| JSONStringsEachRowWithProgress | ✗ | ✔ | +| JSONCompactEachRow | ✔ | ✔ | +| JSONCompactEachRowWithNames | ✔ | ✔ | +| JSONCompactEachRowWithNamesAndTypes | ✔ | ✔ | +| JSONCompactEachRowWithProgress | ✗ | ✔ | +| JSONCompactStringsEachRow | ✔ | ✔ | +| JSONCompactStringsEachRowWithNames | ✔ | ✔ | | JSONCompactStringsEachRowWithNamesAndTypes | ✔ | ✔ | -| JSONObjectEachRow | ✔ | ✔ | -| BSONEachRow | ✔ | ✔ | -| TSKV | ✔ | ✔ | -| Pretty | ✗ | ✔ | -| PrettyNoEscapes | ✗ | ✔ | -| PrettyMonoBlock | ✗ | ✔ | -| PrettyNoEscapesMonoBlock | ✗ | ✔ | -| PrettyCompact | ✗ | ✔ | -| PrettyCompactNoEscapes | ✗ | ✔ | -| PrettyCompactMonoBlock | ✗ | ✔ | -| PrettyCompactNoEscapesMonoBlock| ✗ | ✔ | -| PrettySpace | ✗ | ✔ | -| PrettySpaceNoEscapes | ✗ | ✔ | -| PrettySpaceMonoBlock | ✗ | ✔ | -| PrettySpaceNoEscapesMonoBlock | ✗ | ✔ | -| Prometheus | ✗ | ✔ | -| Protobuf | ✔ | ✔ | -| ProtobufSingle | ✔ | ✔ | -| Avro | ✔ | ✔ | -| AvroConfluent | ✔ | ✗ | -| Parquet | ✔ | ✔ | -| ParquetMetadata | ✔ | ✗ | -| Arrow | ✔ | ✔ | -| ArrowStream | ✔ | ✔ | -| ORC | ✔ | ✔ | -| One | ✔ | ✗ | -| RowBinary | ✔ | ✔ | -| RowBinaryWithNames | ✔ | ✔ | -| RowBinaryWithNamesAndTypes | ✔ | ✔ | -| RowBinaryWithDefaults | ✔ | ✔ | -| Native | ✔ | ✔ | -| Null | ✗ | ✔ | -| XML | ✗ | ✔ | -| CapnProto | ✔ | ✔ | -| LineAsString | ✔ | ✔ | -| Regexp | ✔ | ✗ | -| RawBLOB | ✔ | ✔ | -| MsgPack | ✔ | ✔ | -| MySQLDump | ✔ | ✗ | -| Markdown | ✗ | ✔ | +| JSONCompactStringsEachRowWithProgress | ✗ | ✔ | +| JSONObjectEachRow | ✔ | ✔ | +| BSONEachRow | ✔ | ✔ | +| TSKV | ✔ | ✔ | +| Pretty | ✗ | ✔ | +| PrettyNoEscapes | ✗ | ✔ | +| PrettyMonoBlock | ✗ | ✔ | +| PrettyNoEscapesMonoBlock | ✗ | ✔ | +| PrettyCompact | ✗ | ✔ | +| PrettyCompactNoEscapes | ✗ | ✔ | +| PrettyCompactMonoBlock | ✗ | ✔ | +| PrettyCompactNoEscapesMonoBlock | ✗ | ✔ | +| PrettySpace | ✗ | ✔ | +| PrettySpaceNoEscapes | ✗ | ✔ | +| PrettySpaceMonoBlock | ✗ | ✔ | +| PrettySpaceNoEscapesMonoBlock | ✗ | ✔ | +| Prometheus | ✗ | ✔ | +| Protobuf | ✔ | ✔ | +| ProtobufSingle | ✔ | ✔ | +| ProtobufList | ✔ | ✔ | +| Avro | ✔ | ✔ | +| AvroConfluent | ✔ | ✗ | +| Parquet | ✔ | ✔ | +| ParquetMetadata | ✔ | ✗ | +| Arrow | ✔ | ✔ | +| ArrowStream | ✔ | ✔ | +| ORC | ✔ | ✔ | +| One | ✔ | ✗ | +| Npy | ✔ | ✔ | +| RowBinary | ✔ | ✔ | +| RowBinaryWithNames | ✔ | ✔ | +| RowBinaryWithNamesAndTypes | ✔ | ✔ | +| RowBinaryWithDefaults | ✔ | ✗ | +| Native | ✔ | ✔ | +| Null | ✗ | ✔ | +| XML | ✗ | ✔ | +| CapnProto | ✔ | ✔ | +| LineAsString | ✔ | ✔ | +| Regexp | ✔ | ✗ | +| RawBLOB | ✔ | ✔ | +| MsgPack | ✔ | ✔ | +| MySQLDump | ✔ | ✗ | +| DWARF | ✔ | ✗ | +| Markdown | ✗ | ✔ | +| Form | ✔ | ✗ | -有关更多信息和示例,请参见 [ClickHouse 输入和输出数据格式](/interfaces/formats)。 +如需进一步信息和示例,请参见 [ClickHouse 输入和输出数据格式](/interfaces/formats)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/reference/data-formats.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/reference/data-formats.md.hash index 8cecc50002d..8827822075f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/reference/data-formats.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/reference/data-formats.md.hash @@ -1 +1 @@ -c012a1bdc7473677 +b7c920ba6e75ebd7 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/reference/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/reference/index.md index 9ee67a4e9c6..d93942f0bfa 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/reference/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/reference/index.md @@ -5,9 +5,10 @@ 'keywords': - 'chdb' - 'data formats' +'doc_type': 'reference' --- -| 参考页面 | +| 参考页面 | |----------------------| | [数据格式](/chdb/reference/data-formats) | -| [SQL 参考](/chdb/reference/sql-reference) | +| [SQL参考](/chdb/reference/sql-reference) | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/reference/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/reference/index.md.hash index 1ad71c93bc8..8b0ed5d16b0 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/reference/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/reference/index.md.hash @@ -1 +1 @@ -4079d1f7568f6f2b +e1ecb4a270740e58 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/reference/sql-reference.md b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/reference/sql-reference.md index 9b33c66e5b4..3b3552ed849 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/reference/sql-reference.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/reference/sql-reference.md @@ -6,19 +6,20 @@ 'keywords': - 'chdb' - 'sql reference' +'doc_type': 'reference' --- chdb 支持与 ClickHouse 相同的 SQL 语法、语句、引擎和函数: -| 主题 | +| 主题 | |----------------------------| | [SQL 语法](/sql-reference/syntax) | | [语句](/sql-reference/statements) | | [表引擎](/engines/table-engines) | | [数据库引擎](/engines/database-engines) | -| [常规函数](/sql-reference/functions) | +| [普通函数](/sql-reference/functions) | | [聚合函数](/sql-reference/aggregate-functions) | | [表函数](/sql-reference/table-functions) | | [窗口函数](/sql-reference/window-functions) | -有关更多信息和示例,请参见 [ClickHouse SQL 参考](/sql-reference). +有关更多信息和示例,请参见 [ClickHouse SQL 参考](/sql-reference)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/reference/sql-reference.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/reference/sql-reference.md.hash index 379625e2b43..6a8fccd6354 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/chdb/reference/sql-reference.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/chdb/reference/sql-reference.md.hash @@ -1 +1 @@ -ede8d67f012db877 +962533c1f5ddf338 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud-index.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud-index.md deleted file mode 100644 index c34752e1810..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud-index.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -'slug': '/cloud/overview' -'keywords': -- 'AWS' -- 'Cloud' -- 'serverless' -'title': '概述' -'hide_title': true -'description': 'Cloud 的概述页面' ---- - -import Content from '@site/i18n/zh/docusaurus-plugin-content-docs/current/about-us/cloud.md'; - - diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud-index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud-index.md.hash deleted file mode 100644 index 5d558480400..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud-index.md.hash +++ /dev/null @@ -1 +0,0 @@ -c9b65a8f4acfae0f diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/_snippets/_clickpipes_faq.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/_snippets/_clickpipes_faq.md new file mode 100644 index 00000000000..213352f2d64 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/_snippets/_clickpipes_faq.md @@ -0,0 +1,112 @@ +import Image from '@theme/IdealImage'; +import clickpipesPricingFaq1 from '@site/static/images/cloud/manage/jan2025_faq/external_clickpipes_pricing_faq_1.png'; +import clickpipesPricingFaq2 from '@site/static/images/cloud/manage/jan2025_faq/external_clickpipes_pricing_faq_2.png'; +import clickpipesPricingFaq3 from '@site/static/images/cloud/manage/jan2025_faq/external_clickpipes_pricing_faq_3.png'; + +
+ +什么是 ClickPipes 副本? + +ClickPipes 通过专用基础设施从远程数据源摄取数据,这些基础设施独立于 ClickHouse Cloud 服务运行和扩展。 +因此,它使用专用计算副本。 +下面的图表展示了简化的架构。 + +对于流式 ClickPipes,ClickPipes 副本访问远程数据源(例如:Kafka 代理),拉取数据,处理并将其摄取到目标 ClickHouse 服务中。 + +ClickPipes 副本 - 流式 ClickPipes + +在对象存储 ClickPipes 的情况下, +ClickPipes 副本协调数据加载任务 +(识别要复制的文件,维护状态,并移动分区), +而数据则直接从 ClickHouse 服务拉取。 + +ClickPipes 副本 - 对象存储 ClickPipes + +
+ +
+ +副本的默认数量及其大小是多少? + +每个 ClickPipe 默认有 1 个副本,配备 2 GiB 的 RAM 和 0.5 vCPU。 +这对应于 **0.25** ClickHouse 计算单位(1 单位 = 8 GiB RAM,2 vCPUs)。 + +
+ +
+ +ClickPipes 副本可以扩展吗? + +是的,流式 ClickPipes 可以横向和纵向扩展。 +横向扩展增加更多副本以提高吞吐量,而纵向扩展则增加分配给每个副本的资源(CPU 和 RAM),以处理更密集的工作负载。 +这可以在 ClickPipe 创建期间配置,或者在 **设置** -> **高级设置** -> **扩展** 下的任何其他时候配置。 + +
+ +
+ +我需要多少个 ClickPipes 副本? + +这取决于工作负载的吞吐量和延迟要求。 +我们建议从 1 个副本的默认值开始,测量延迟,并根据需要添加副本。 +请记住,对于 Kafka ClickPipes,您还必须相应地扩展 Kafka 代理的分区。 +扩展控件在每个流式 ClickPipe 的“设置”中可用。 + +ClickPipes 副本 - 我需要多少个 ClickPipes 副本? + +
+ +
+ +ClickPipes 的定价结构是什么样的? + +它由两个维度组成: +- **计算**:每个单位每小时的价格 + 计算代表运行 ClickPipes 副本 pod 的成本,无论它们是否正在积极摄取数据。 + 它适用于所有 ClickPipes 类型。 +- **摄取的数据**:每 GB 定价 + 摄取的数据费率适用于所有流式 ClickPipes + (Kafka、Confluent、Amazon MSK、Amazon Kinesis、Redpanda、WarpStream、Azure Event Hubs),用于通过副本 pod 传输的数据。 + 摄取的数据大小(GB)根据从源收到的字节数收费(无压缩或压缩)。 + +
+ +
+ +ClickPipes 的公开价格是什么? + +- 计算:每单位每小时 \$0.20(每副本每小时 \$0.05) +- 摄取数据:每 GB \$0.04 + +
+ +
+ +在一个示例中看起来如何? + +例如,使用 Kafka 连接器以单个副本(0.25 计算单位)在 24 小时内摄取 1 TB 数据的成本为: + +$$ +(0.25 \times 0.20 \times 24) + (0.04 \times 1000) = \$41.2 +$$ +
+ +对于对象存储连接器(S3 和 GCS), +只会产生 ClickPipes 计算成本,因为 ClickPipes pod 并未处理数据 +而仅仅是协调由底层的 ClickHouse 服务操作的传输: + +$$ +0.25 \times 0.20 \times 24 = \$1.2 +$$ + +
+ +
+ +ClickPipes 定价与市场相比如何? + +ClickPipes 定价的理念是 +覆盖平台的运营成本,同时提供一种简单可靠的方式将数据移动到 ClickHouse Cloud。 +从这个角度来看,我们的市场分析表明我们的定价具有竞争力。 + +
diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/_snippets/_clickpipes_faq.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/_snippets/_clickpipes_faq.md.hash new file mode 100644 index 00000000000..680d3b0de74 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/_snippets/_clickpipes_faq.md.hash @@ -0,0 +1 @@ +19eddd9169b059eb diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/_snippets/_security_table_of_contents.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/_snippets/_security_table_of_contents.md new file mode 100644 index 00000000000..a86a916dd32 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/_snippets/_security_table_of_contents.md @@ -0,0 +1,8 @@ +| 页面 | 描述 | +|---------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------| +| [共享责任模型](/cloud/security/shared-responsibility-model) | 了解 ClickHouse Cloud 和您的组织在不同服务类型之间如何划分安全责任。 | +| [云访问管理](/cloud/security/cloud-access-management) | 管理用户访问,包括身份验证、单点登录(SSO)、基于角色的权限和团队邀请。 | +| [连接性](/cloud/security/connectivity) | 配置安全网络访问,包括 IP 允许列表、私有网络、S3 数据访问和云 IP 地址管理。 | +| [增强加密](/cloud/security/cmek) | 了解默认的 AES 256 加密以及如何启用透明数据加密(TDE)以提供额外的静态数据保护。 | +| [审核日志记录](/cloud/security/audit-logging) | 设置并使用审核日志记录,以跟踪和监控您在 ClickHouse Cloud 环境中的活动。 | +| [隐私和合规性](/cloud/security/privacy-compliance-overview) | 审查安全认证、合规标准,并了解如何管理您的个人信息和数据权利。 | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/_snippets/_security_table_of_contents.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/_snippets/_security_table_of_contents.md.hash new file mode 100644 index 00000000000..b81e45e251e --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/_snippets/_security_table_of_contents.md.hash @@ -0,0 +1 @@ +5d9a7ef8c49befa0 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/bestpractices/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/bestpractices/index.md deleted file mode 100644 index ee5e49a9a77..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/bestpractices/index.md +++ /dev/null @@ -1,42 +0,0 @@ ---- -'slug': '/cloud/bestpractices' -'keywords': -- 'Cloud' -- 'Best Practices' -- 'Bulk Inserts' -- 'Asynchronous Inserts' -- 'Avoid Mutations' -- 'Avoid Nullable Columns' -- 'Avoid Optimize Final' -- 'Low Cardinality Partitioning Key' -- 'Multi Tenancy' -- 'Usage Limits' -'title': '概述' -'hide_title': true -'description': 'ClickHouse Cloud 中最佳实践部分的登录页面' ---- - - -# Best Practices in ClickHouse Cloud {#best-practices-in-clickhouse-cloud} - -本节提供您希望遵循的最佳实践,以充分利用 ClickHouse Cloud。 - -| 页面 | 描述 | -|----------------------------------------------------------|----------------------------------------------------------------------------| -| [使用限制](/cloud/bestpractices/usage-limits)| 探索 ClickHouse 的限制。 | -| [多租户](/cloud/bestpractices/multi-tenancy)| 了解实施多租户的不同策略。 | - -这些是适用于所有 ClickHouse 部署的标准最佳实践的补充。 - -| 页面 | 描述 | -|----------------------------------------------------------------------|--------------------------------------------------------------------------| -| [选择主键](/best-practices/choosing-a-primary-key) | 关于在 ClickHouse 中选择有效主键的指导。 | -| [选择数据类型](/best-practices/select-data-types) | 选择合适数据类型的建议。 | -| [使用物化视图](/best-practices/use-materialized-views) | 何时以及如何受益于物化视图。 | -| [最小化和优化 JOIN](/best-practices/minimize-optimize-joins)| 最小化和优化 JOIN 操作的最佳实践。 | -| [选择分区键](/best-practices/choosing-a-partitioning-key) | 如何有效选择和应用分区键。 | -| [选择插入策略](/best-practices/selecting-an-insert-strategy) | 在 ClickHouse 中高效数据插入的策略。 | -| [数据跳过索引](/best-practices/use-data-skipping-indices-where-appropriate) | 何时应用数据跳过索引以提高性能。 | -| [避免变更](/best-practices/avoid-mutations) | 避免变更的理由及如何在设计中不使用它们。 | -| [避免 OPTIMIZE FINAL](/best-practices/avoid-optimize-final) | 为什么 `OPTIMIZE FINAL` 可能代价高昂以及如何规避它。 | -| [适当使用 JSON](/best-practices/use-json-where-appropriate) | 在 ClickHouse 中使用 JSON 列的考虑事项。 | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/bestpractices/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/bestpractices/index.md.hash deleted file mode 100644 index 1ae056246fd..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/bestpractices/index.md.hash +++ /dev/null @@ -1 +0,0 @@ -8c4d3e48a9af0c2f diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/bestpractices/multitenancy.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/bestpractices/multitenancy.md.hash deleted file mode 100644 index bf23ea018cd..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/bestpractices/multitenancy.md.hash +++ /dev/null @@ -1 +0,0 @@ -2815dfa7d00cce3f diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/bestpractices/usagelimits.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/bestpractices/usagelimits.md deleted file mode 100644 index 06fe8e9c6a7..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/bestpractices/usagelimits.md +++ /dev/null @@ -1,31 +0,0 @@ ---- -'slug': '/cloud/bestpractices/usage-limits' -'sidebar_label': '使用限制' -'title': '使用限制' -'description': '描述 ClickHouse Cloud 中推荐的使用限制' ---- - -虽然 ClickHouse 以其速度和可靠性而闻名,但在某些操作参数下才能实现最佳性能。例如,数据库、表或分片过多可能会对性能产生负面影响。为避免这种情况,Clickhouse Cloud 为几类项目设置了护栏。您可以在下面找到这些护栏的详细信息。 - -:::tip -如果您遇到了这些护栏,很可能是您以不优化的方式实现了您的用例。请联系我们的支持团队,我们将乐意帮助您优化用例,以避免超出护栏,或共同寻找如何以受控的方式提高护栏。 -::: - -| 维度 | 限制 | -|--------------|-------| -|**数据库** | 1000 | -|**表** | 5000 | -|**列** | ∼1000(首选宽格式而非紧凑格式)| -|**分区** | 50k | -|**分区片段** | 100k 整个实例范围内 | -|**分区片段大小**| 150gb | -|**每个组织的服务**| 20(软限制)| -|**每个仓库的服务**| 5(软限制)| -|**低基数** | 10k 或更少 | -|**表中的主键**| 4-5 个,能够有效过滤数据 | -|**查询并发性**| 1000 | -|**批量导入** | 任何大于 1M 的数据都将由系统分割为 1M 行块 | - -:::note -对于单副本服务,数据库的最大数量限制为 100,表的最大数量限制为 500。此外,基础层服务的存储限制为 1 TB。 -::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/bestpractices/usagelimits.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/bestpractices/usagelimits.md.hash deleted file mode 100644 index a06bfa084e9..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/bestpractices/usagelimits.md.hash +++ /dev/null @@ -1 +0,0 @@ -b8f70f140fe904c7 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/01_cloud_tiers.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/01_cloud_tiers.md new file mode 100644 index 00000000000..a9b8846575e --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/01_cloud_tiers.md @@ -0,0 +1,206 @@ +--- +'sidebar_label': 'ClickHouse Cloud 层级' +'slug': '/cloud/manage/cloud-tiers' +'title': 'ClickHouse Cloud 层级' +'description': 'ClickHouse Cloud 中可用的云层级' +'doc_type': 'reference' +--- + + +# ClickHouse Cloud 级别 + +在 ClickHouse Cloud 中有几个可用的级别。 +级别在任何组织级别上分配。因此,组织内的服务属于同一级别。 +本页面讨论哪些级别适合您的特定用例。 + +**云级别摘要:** + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
[基本](#basic)[扩展 (推荐)](#scale)[企业](#enterprise)
**服务特性**
服务数量✓ 无限✓ 无限✓ 无限
存储✓ 最大 1 TB / 服务✓ 无限✓ 无限
内存✓ 8-12 GiB 总内存✓ 可配置✓ 可配置
可用性✓ 1 区域✓ 2+ 区域✓ 2+ 区域
备份✓ 每 24 小时 1 次备份,保留 1 天✓ 可配置✓ 可配置
垂直扩展✓ 自动扩展✓ 标准配置自动,定制配置手动
水平扩展✓ 手动扩展✓ 手动扩展
ClickPipes
提前升级
计算-计算分离
导出备份到您自己的云账户
定期升级
自定义硬件配置
**安全性**
SAML/SSO
MFA
SOC 2 类型 II
ISO 27001
私有网络
S3 角色基础访问
透明数据加密 (CMEK for TDE)
HIPAA
+ +## 基本 {#basic} + +- 成本效益高的选项,支持单副本部署。 +- 适用于数据量较小、没有严格可靠性保证的部门用例。 + +:::note +基本级别的服务旨在保持固定大小,不允许自动和手动缩放。 +您可以升级到扩展或企业级别以扩展其服务。 +::: + +## 扩展 {#scale} + +专为需要增强服务水平协议(2+ 副本部署)、可扩展性和高级安全性的工作负载设计。 + +- 提供对以下功能的支持: + - [私有网络支持](/cloud/security/private-link-overview). + - [计算-计算分离](../reference/warehouses#what-is-compute-compute-separation). + - [灵活扩展](/manage/scaling) 选项(向上/向下,内置/扩展)。 + - [可配置的备份](/cloud/manage/backups/configurable-backups) + +## 企业 {#enterprise} + +适用于大规模、关键任务的部署,具有严格的安全性和合规性需求。 + +- 包括扩展中的所有内容,**加上** +- 灵活的扩展:标准配置(`1:4 vCPU:内存比例`),以及 `HighMemory (1:8 比例)` 和 `HighCPU (1:2 比例)` 自定义配置。 +- 提供最高水平的性能和可靠性保证。 +- 支持企业级安全: + - 单点登录 (SSO) + - 增强加密:对于 AWS 和 GCP 服务,服务默认由我们的密钥加密,并可以旋转到它们的密钥以启用客户管理加密密钥(CMEK)。 +- 允许定期升级:您可以选择升级的星期几/时间窗口,涵盖数据库和云发布。 +- 提供 [HIPAA](/cloud/security/compliance-overview#hipaa-since-2024) 和 PCI 合规性。 +- 导出备份到用户的账户。 + +:::note +三个级别中的单副本服务旨在保持固定大小 (`8 GiB`, `12 GiB`) +::: + +## 升级到不同级别 {#upgrading-to-a-different-tier} + +您可以随时从基本级别升级到扩展级别或从扩展级别升级到企业级别。 降级级别将需要禁用高级功能。 + +--- + +如果您对服务类型有任何问题,请查看 [定价页面](https://clickhouse.com/pricing) 或联系 support@clickhouse.com。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/01_cloud_tiers.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/01_cloud_tiers.md.hash new file mode 100644 index 00000000000..afc18aa1d93 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/01_cloud_tiers.md.hash @@ -0,0 +1 @@ +5aa26f01486026d2 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/02_integrations.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/02_integrations.md new file mode 100644 index 00000000000..15ddf0d01f0 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/02_integrations.md @@ -0,0 +1,68 @@ +--- +'sidebar_label': '集成' +'slug': '/manage/integrations' +'title': '集成' +'description': 'ClickHouse 的集成' +'doc_type': 'landing-page' +--- + +import Kafkasvg from '@site/static/images/integrations/logos/kafka.svg'; +import Confluentsvg from '@site/static/images/integrations/logos/confluent.svg'; +import Msksvg from '@site/static/images/integrations/logos/msk.svg'; +import Azureeventhubssvg from '@site/static/images/integrations/logos/azure_event_hubs.svg'; +import Warpstreamsvg from '@site/static/images/integrations/logos/warpstream.svg'; +import S3svg from '@site/static/images/integrations/logos/amazon_s3_logo.svg'; +import AmazonKinesis from '@site/static/images/integrations/logos/amazon_kinesis_logo.svg'; +import Gcssvg from '@site/static/images/integrations/logos/gcs.svg'; +import DOsvg from '@site/static/images/integrations/logos/digitalocean.svg'; +import ABSsvg from '@site/static/images/integrations/logos/azureblobstorage.svg'; +import Postgressvg from '@site/static/images/integrations/logos/postgresql.svg'; +import Mysqlsvg from '@site/static/images/integrations/logos/mysql.svg'; +import Mongodbsvg from '@site/static/images/integrations/logos/mongodb.svg'; +import redpanda_logo from '@site/static/images/integrations/logos/logo_redpanda.png'; +import clickpipes_stack from '@site/static/images/integrations/data-ingestion/clickpipes/clickpipes_stack.png'; +import cp_custom_role from '@site/static/images/integrations/data-ingestion/clickpipes/cp_custom_role.png'; +import Image from '@theme/IdealImage'; + +ClickHouse Cloud 使您能够连接您喜爱的工具和服务。 + +## ClickHouse Cloud 的托管集成管道 {#clickpipes} + +ClickPipes 是一个托管集成平台,使从多种来源摄取数据变得像点击几下按钮一样简单。 +ClickPipes 的强大和可扩展架构专为最苛刻的工作负载而设计,确保了性能和可靠性的一致性。 +ClickPipes 可用于长期流式传输需求或一次性数据加载作业。 + +| 名称 | 徽标 | 类型 | 状态 | 描述 | +|----------------------------------------------------|--------------------------------------------------------------------------------------------------|------------|------------------|------------------------------------------------------------------------------------------------------| +| [Apache Kafka](/integrations/clickpipes/kafka) | | 流式 | 稳定 | 配置 ClickPipes 并开始从 Apache Kafka 向 ClickHouse Cloud 摄取流式数据。 | +| Confluent Cloud | | 流式 | 稳定 | 通过我们的直接集成,释放 Confluent 和 ClickHouse Cloud 的结合力量。 | +| Redpanda | Redpanda logo | 流式 | 稳定 | 配置 ClickPipes 并开始从 Redpanda 向 ClickHouse Cloud 摄取流式数据。 | +| AWS MSK | | 流式 | 稳定 | 配置 ClickPipes 并开始从 AWS MSK 向 ClickHouse Cloud 摄取流式数据。 | +| Azure Event Hubs | | 流式 | 稳定 | 配置 ClickPipes 并开始从 Azure Event Hubs 向 ClickHouse Cloud 摄取流式数据。 | +| WarpStream | | 流式 | 稳定 | 配置 ClickPipes 并开始从 WarpStream 向 ClickHouse Cloud 摄取流式数据。 | +| Amazon S3 | | 对象存储 | 稳定 | 配置 ClickPipes 从对象存储中摄取大量数据。 | +| Google Cloud Storage | | 对象存储 | 稳定 | 配置 ClickPipes 从对象存储中摄取大量数据。 | +| DigitalOcean Spaces | | 对象存储 | 稳定 | 配置 ClickPipes 从对象存储中摄取大量数据。 +| Azure Blob Storage | | 对象存储 | 私有测试 | 配置 ClickPipes 从对象存储中摄取大量数据。 +| [Amazon Kinesis](/integrations/clickpipes/kinesis) | | 流式 | 稳定 | 配置 ClickPipes 并开始从 Amazon Kinesis 向 ClickHouse Cloud 摄取流式数据。 | +| [Postgres](/integrations/clickpipes/postgres) | | DBMS | 稳定 | 配置 ClickPipes 并开始从 Postgres 向 ClickHouse Cloud 摄取数据。 | +| [MySQL](/integrations/clickpipes/mysql) | | DBMS | 私有测试 | 配置 ClickPipes 并开始从 MySQL 向 ClickHouse Cloud 摄取数据。 | +| [MongoDB](/integrations/clickpipes/mongodb) | | DBMS | 私有预览 | 配置 ClickPipes 并开始从 MongoDB 向 ClickHouse Cloud 摄取数据。 | + +## 语言客户端集成 {#language-client-integrations} + +ClickHouse 提供多种语言客户端集成,每个集成的文档链接如下。 + +| 页面 | 描述 | +|-------------------------------------------------------------------------|----------------------------------------------------------------------------------| +| [C++](/interfaces/cpp) | C++ 客户端库和用户服务器异步框架 | +| [C#](/integrations/csharp) | 学习如何将您的 C# 项目连接到 ClickHouse。 | +| [Go](/integrations/go) | 学习如何将您的 Go 项目连接到 ClickHouse。 | +| [JavaScript](/integrations/javascript) | 学习如何使用官方 JS 客户端将您的 JS 项目连接到 ClickHouse。 | +| [Java](/integrations/java) | 了解多个 Java 和 ClickHouse 的集成。 | +| [Python](/integrations/python) | 学习如何将您的 Python 项目连接到 ClickHouse。 | +| [Rust](/integrations/rust) | 学习如何将您的 Rust 项目连接到 ClickHouse。 | +| [第三方客户端](/interfaces/third-party/client-libraries) | 了解来自第三方开发者的客户端库。 | + +除了 ClickPipes 和语言客户端外,ClickHouse 还支持其他众多集成,涵盖核心集成、合作伙伴集成和社区集成。 +完整的列表请参见文档的 ["集成"](/integrations) 部分。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/02_integrations.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/02_integrations.md.hash new file mode 100644 index 00000000000..d43838bf9af --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/02_integrations.md.hash @@ -0,0 +1 @@ +97f0756ab0077471 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/get-started/sql-console.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/03_sql_console_features/01_sql-console.md similarity index 50% rename from i18n/zh/docusaurus-plugin-content-docs/current/cloud/get-started/sql-console.md rename to i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/03_sql_console_features/01_sql-console.md index b5f5c7e57d3..92dede203ad 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/get-started/sql-console.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/03_sql_console_features/01_sql-console.md @@ -1,13 +1,14 @@ --- 'sidebar_title': 'SQL Console' 'slug': '/cloud/get-started/sql-console' -'description': '通过 SQL 控制台运行查询并创建可视化。' +'description': '运行查询并使用 SQL 控制台创建可视化.' 'keywords': - 'sql console' - 'sql client' - 'cloud console' - 'console' 'title': 'SQL 控制台' +'doc_type': 'guide' --- import Image from '@theme/IdealImage'; @@ -49,33 +50,33 @@ import adjust_axis_scale from '@site/static/images/cloud/sqlconsole/adjust-axis- # SQL 控制台 -SQL 控制台是探索和查询您在 ClickHouse Cloud 中的数据库的最快和最简单的方法。您可以使用 SQL 控制台来: +SQL 控制台是在 ClickHouse Cloud 中探索和查询数据库的最快、最简单的方法。您可以使用 SQL 控制台来: - 连接到您的 ClickHouse Cloud 服务 - 查看、过滤和排序表数据 -- 仅需几次点击即可执行查询和可视化结果数据 -- 与团队成员共享查询并更有效地协作。 +- 执行查询并在几次点击中可视化结果数据 +- 与团队成员共享查询,更有效地协作。 ### 探索表 {#exploring-tables} ### 查看表列表和架构信息 {#viewing-table-list-and-schema-info} -您 ClickHouse 实例中包含的表的概述可以在左侧边栏区域找到。使用左侧栏顶部的数据库选择器查看特定数据库中的表。 +在左侧边栏区域可以找到您 ClickHouse 实例中包含的表的概述。使用左栏顶部的数据库选择器查看特定数据库中的表。 表列表和架构 -可以展开列表中的表以查看列和类型。 +表列表中的表也可以展开以查看列和类型。 查看列 ### 探索表数据 {#exploring-table-data} -在列表中单击一个表以在新标签页中打开它。在表视图中,可以轻松查看、选择和复制数据。请注意,在复制粘贴到 Microsoft Excel 和 Google Sheets 等电子表格应用程序时,结构和格式会被保留。您可以使用页脚中的导航翻页查看表数据(按 30 行递增分页)。 +在列表中单击一个表以在新选项卡中打开它。在表视图中,可以轻松查看、选择和复制数据。注意,复制粘贴到电子表格应用程序(如 Microsoft Excel 和 Google Sheets)时结构和格式保持不变。您可以使用页脚中的导航在表数据的页面之间翻转(按 30 行递增分页)。 abc ### 检查单元格数据 {#inspecting-cell-data} -可以使用单元格检查器工具查看单个单元格中包含的大量数据。要打开它,右键单击一个单元格并选择“检查单元格”。可以通过单击检查器内容右上角的复制图标来复制单元格检查器的内容。 +单元格检查工具可用于查看包含在单个单元格中的大量数据。要打开它,右键单击单元格并选择“检查单元格”。通过单击检查器内容右上角的复制图标可以复制单元格检查器的内容。 检查单元格内容 @@ -83,37 +84,37 @@ SQL 控制台是探索和查询您在 ClickHouse Cloud 中的数据库的最快 ### 排序表 {#sorting-a-table} -要在 SQL 控制台中对表进行排序,请打开表并在工具栏中选择“排序”按钮。此按钮将打开一个菜单,允许您配置排序。您可以选择一个要排序的列并配置排序的顺序(升序或降序)。选择“应用”或按 Enter 键以对表进行排序。 +要在 SQL 控制台中对表进行排序,打开表并选择工具栏中的“排序”按钮。此按钮将打开一个菜单,允许您配置排序。您可以选择要排序的列并配置排序的顺序(升序或降序)。选择“应用”或按 Enter 来对表进行排序。 -按列降序排序 +在一列上降序排序 -SQL 控制台还允许您向表添加多个排序。再次单击“排序”按钮以添加另一个排序。 +SQL 控制台还允许您对表添加多个排序。再次单击“排序”按钮以添加另一个排序。 :::note -排序按它们在排序面板中的出现顺序(从上到下)应用。要删除排序,只需单击排序旁边的“x”按钮。 +排序是按照它们在排序面板中出现的顺序(从上到下)应用的。要移除排序,只需单击排序旁边的“x”按钮。 ::: ### 过滤表 {#filtering-a-table} -要在 SQL 控制台中过滤表,请打开表并选择“过滤”按钮。与排序一样,此按钮将打开一个菜单,允许您配置过滤器。您可以选择要过滤的列并选择必要的条件。SQL 控制台智能地显示与列中包含的数据类型相对应的过滤选项。 +要在 SQL 控制台中过滤表,打开表并选择“过滤”按钮。与排序一样,此按钮将打开一个菜单,允许您配置过滤器。您可以选择要过滤的列并选择必要的标准。SQL 控制台智能地显示与列中包含的数据类型相对应的过滤选项。 -在无线电列中过滤等于 GSM +过滤无线列等于 GSM -当您对过滤器感到满意时,可以选择“应用”来过滤数据。您还可以添加其他过滤器,如下所示。 +当您对过滤器感到满意时,可以选择“应用”以过滤数据。您还可以添加其他过滤器,如下所示。 -添加大于 2000 的过滤器 +在范围大于 2000 上添加过滤器 -与排序功能类似,单击过滤器旁边的“x”按钮以将其删除。 +与排序功能类似,单击过滤器旁边的“x”按钮以移除它。 ### 同时过滤和排序 {#filtering-and-sorting-together} SQL 控制台允许您同时过滤和排序表。为此,使用上述步骤添加所有所需的过滤器和排序,然后单击“应用”按钮。 -添加大于 2000 的过滤器 +在范围大于 2000 上添加过滤器 ### 从过滤器和排序创建查询 {#creating-a-query-from-filters-and-sorts} -SQL 控制台可以通过单击将您的排序和过滤直接转换为查询。只需从工具栏中选择“创建查询”按钮,并选择您想要的排序和过滤参数。单击“创建查询”后,将打开一个新的查询选项卡,预填充与您表视图中包含的数据相对应的 SQL 命令。 +SQL 控制台可以一键将您的排序和过滤器直接转换为查询。只需选择工具栏中的“创建查询”按钮,附上您选择的排序和过滤参数。单击“创建查询”后,将打开一个新的查询选项卡,其中预填充了与您表视图中包含的数据对应的 SQL 命令。 从排序和过滤器创建查询 @@ -127,9 +128,9 @@ SQL 控制台可以通过单击将您的排序和过滤直接转换为查询。 ### 创建查询 {#creating-a-query} -在 SQL 控制台中创建新查询有两种方法。 +在 SQL 控制台中有两种方法可以创建新查询。 -- 点击选项卡栏中的“+”按钮 +- 单击标签栏中的“+”按钮 - 从左侧边栏查询列表中选择“新查询”按钮 创建查询 @@ -139,40 +140,40 @@ SQL 控制台可以通过单击将您的排序和过滤直接转换为查询。 要运行查询,请在 SQL 编辑器中输入您的 SQL 命令,并单击“运行”按钮或使用快捷键 `cmd / ctrl + enter`。要顺序编写和运行多个命令,请确保在每个命令后添加分号。 查询执行选项 -默认情况下,单击运行按钮将运行 SQL 编辑器中包含的所有命令。SQL 控制台支持另外两种查询执行选项: +默认情况下,单击运行按钮将运行 SQL 编辑器中包含的所有命令。SQL 控制台支持两种其他查询执行选项: - 运行选定的命令 - 在光标处运行命令 -要运行选定的命令,请高亮选择所需的命令或命令序列,然后单击“运行”按钮(或使用 `cmd / ctrl + enter` 快捷键)。当有选择存在时,您还可以从 SQL 编辑器上下文菜单(通过在编辑器内任意位置右键单击打开)中选择“运行选定”。 +要运行选定的命令,突出显示所需的命令或命令序列,然后单击“运行”按钮(或使用 `cmd / ctrl + enter` 快捷键)。在有选定项时,您也可以在 SQL 编辑器上下文菜单中选择“运行选择的”。 运行选定的查询 -在当前位置运行光标处的命令有两种方式: +运行当前光标位置的命令可以通过两种方式实现: -- 从扩展运行选项菜单中选择“在光标处运行”(或使用相应的 `cmd / ctrl + shift + enter` 键盘快捷键)。 +- 从扩展运行选项菜单中选择“在光标处” (或使用相应的 `cmd / ctrl + shift + enter` 键盘快捷键) 在光标处运行 - - 从 SQL 编辑器上下文菜单中选择“在光标处运行”。 +- 从 SQL 编辑器上下文菜单选择“在光标处运行” 在光标处运行 :::note -光标位置上的命令在执行时将闪烁黄色。 +光标位置的命令在执行时会闪烁黄色。 ::: ### 取消查询 {#canceling-a-query} -在查询运行时,“运行”按钮将被“取消”按钮替换。只需单击此按钮或按 `Esc` 来取消查询。注意:已返回的任何结果将在取消后持续存在。 +在查询运行时,查询编辑器工具栏中的“运行”按钮将替换为“取消”按钮。只需单击该按钮或按 `Esc` 来取消查询。注意:已经返回的任何结果在取消后将继续存在。 取消查询 ### 保存查询 {#saving-a-query} -保存查询使您能够更轻松地找到它们并与您的团队成员共享。SQL 控制台还允许您将查询组织到文件夹中。 +保存查询可以让您更轻松地找到它们并与您的团队成员共享。SQL 控制台还允许您将查询组织到文件夹中。 -要保存查询,只需单击工具栏中“运行”按钮旁边的“保存”按钮。输入所需的名称并单击“保存查询”。 +要保存查询,只需单击工具栏中紧邻“运行”按钮的“保存”按钮。输入所需名称并单击“保存查询”。 :::note 使用快捷键 `cmd / ctrl` + s 也将保存当前查询选项卡中的任何工作。 @@ -180,124 +181,124 @@ SQL 控制台可以通过单击将您的排序和过滤直接转换为查询。 保存查询 -或者,您可以通过单击工具栏中的“无标题查询”,调整名称并按 Enter 键同时命名和保存查询: +或者,您也可以通过单击工具栏中的“无标题查询”,调整名称并按回车键来同时命名和保存查询: 重命名查询 ### 查询共享 {#query-sharing} -SQL 控制台允许您轻松与团队成员共享查询。SQL 控制台支持四个访问级别,可以在全局和每个用户的基础上进行调整: +SQL 控制台允许您轻松与团队成员共享查询。SQL 控制台支持四个访问级别,可以在全局和按用户基础上进行调整: - 拥有者(可以调整共享选项) -- 写入访问 +- 写访问 - 只读访问 - 无访问 -保存查询后,单击工具栏中的“共享”按钮。将出现一个共享选项的 modal: +保存查询后,单击工具栏中的“共享”按钮。将出现一个共享选项的模态框: 共享查询 -要调整对所有有服务访问权限的组织成员的查询访问权限,只需调整顶部行中的访问级别选择器: +要为所有访问服务的组织成员调整查询访问权限,只需在顶部行中调整访问级别选择器: -编辑访问 +编辑访问权限 -应用上述设置后,所有有权访问 SQL 控制台的团队成员都可以查看(和执行)该查询。 +应用上述内容后,该查询现在可以由所有访问 SQL 控制台的团队成员查看(和执行)。 -要调整特定成员的查询访问权限,从“添加团队成员”选择器中选择所需的团队成员: +要为特定成员调整查询访问权限,从“添加团队成员”选择器中选择所需的团队成员: 添加团队成员 -选择团队成员后,将出现一个新的行项,带有访问级别选择器: +选择团队成员后,应出现一行新项目及其访问级别选择器: 编辑团队成员访问权限 ### 访问共享查询 {#accessing-shared-queries} -如果查询已与您共享,它将在 SQL 控制台左侧边栏的“查询”选项卡中显示: +如果有查询与您共享,它将在 SQL 控制台左侧边栏的“查询”选项卡中显示: 访问查询 -### 链接到查询(固定链接) {#linking-to-a-query-permalinks} +### 链接到查询 (永久链接) {#linking-to-a-query-permalinks} -已保存的查询也有固定链接,这意味着您可以发送和接收指向共享查询的链接并直接打开它们。 +保存的查询也具有永久链接,这意味着您可以发送和接收共享查询的链接并直接打开它们。 -查询中可能存在的任何参数的值会自动添加到已保存查询 URL 作为查询参数。例如,如果查询包含 `{start_date: Date}` 和 `{end_date: Date}` 参数,则该固定链接可能看起来像:`https://console.clickhouse.cloud/services/:serviceId/console/query/:queryId?param_start_date=2015-01-01¶m_end_date=2016-01-01`。 +查询中可能存在的任何参数的值会自动添加到保存的查询 URL 作为查询参数。例如,如果查询包含 `{start_date: Date}` 和 `{end_date: Date}` 参数,则永久链接可能看起来像:`https://console.clickhouse.cloud/services/:serviceId/console/query/:queryId?param_start_date=2015-01-01¶m_end_date=2016-01-01`。 ## 高级查询功能 {#advanced-querying-features} ### 搜索查询结果 {#searching-query-results} -在查询执行后,您可以使用结果窗格中的搜索输入快速搜索返回的结果集。该功能有助于预览附加的 `WHERE` 子句结果,或者仅仅检查特定数据是否包含在结果集中。在搜索输入中输入一个值后,结果窗格将更新并返回包含与输入值匹配的条目。 在这个例子中,我们将查看 `hackernews` 表中所有包含 `ClickHouse` 的 `breakfast` 评论(不区分大小写): +查询执行后,您可以使用结果面板中的搜索输入框快速搜索返回的结果集。此功能有助于预览额外的 `WHERE` 子句的结果,或者仅仅检查特定数据是否包含在结果集中。在搜索输入框中输入值后,结果面板将更新并返回包含与输入值匹配的条目。以下示例中,我们将搜索 `hackernews` 表中所有包含 `ClickHouse` 的 `breakfast` 评论(不区分大小写): -搜索黑客新闻数据 +搜索 Hacker News 数据 -注意:匹配输入值的任何字段都将被返回。例如,以上截图中的第三条记录在 `by` 字段中不匹配 ‘breakfast’,但在 `text` 字段中匹配: +注意:任何与输入值匹配的字段都将被返回。例如,上述屏幕截图中的第三条记录在 `by` 字段中不匹配“breakfast”,但是 `text` 字段中的确有: -主体中的匹配 +主体中的匹配项 ### 调整分页设置 {#adjusting-pagination-settings} -默认情况下,查询结果窗格将在单个页面上显示每个结果记录。对于较大的结果集,分页结果以便于查看可能更为合适。这可以通过结果窗格右下角的分页选择器来完成: +默认情况下,查询结果面板将在单个页面上显示每个结果记录。对于较大的结果集,可能更希望分页结果以便于查看。这可以通过结果面板右下角的分页选择器来完成: 分页选项 -选择页面大小将立即将分页应用于结果集,并在结果窗格页脚中间出现导航选项。 +选择页面大小将立即将分页应用于结果集,并在结果面板页脚中间显示导航选项。 分页导航 ### 导出查询结果数据 {#exporting-query-result-data} -查询结果集可以直接从 SQL 控制台轻松导出为 CSV 格式。为此,请打开结果窗格工具栏右侧的 `•••` 菜单并选择“下载为 CSV”。 +查询结果集可以轻松地从 SQL 控制台导出为 CSV 格式。要做到这一点,打开结果面板工具栏右侧的 `•••` 菜单,选择“下载为 CSV”。 下载为 CSV ## 可视化查询数据 {#visualizing-query-data} -某些数据可以更轻松地通过图表形式解释。您可以直接从 SQL 控制台仅需几次点击即可快速创建来自查询结果数据的可视化。例如,我们将使用一个计算 NYC 出租车周统计的查询: +某些数据以图表形式呈现时更容易解释。您可以直接从 SQL 控制台快速创建查询结果数据的可视化,仅需几次点击。例如,我们将使用一个计算纽约市出租车行程每周统计数据的查询: ```sql -select - toStartOfWeek(pickup_datetime) as week, - sum(total_amount) as fare_total, - sum(trip_distance) as distance_total, - count(*) as trip_total -from +SELECT + toStartOfWeek(pickup_datetime) AS week, + sum(total_amount) AS fare_total, + sum(trip_distance) AS distance_total, + count(*) AS trip_total +FROM nyc_taxi -group by +GROUP BY 1 -order by - 1 asc +ORDER BY + 1 ASC ``` 表格查询结果 -没有可视化,这些结果很难解释。让我们将它们转变为图表。 +没有可视化时,这些结果很难解释。让我们将它们转化为图表。 ### 创建图表 {#creating-charts} -要开始构建可视化,请从查询结果窗格工具栏中选择“图表”选项。图表配置面板将出现: +要开始构建可视化,选择查询结果面板工具栏中的“图表”选项。将出现一个图表配置面板: 从查询切换到图表 -我们将首先创建一个简单的条形图,以 `week` 为标准跟踪 `trip_total`。要实现这一点,我们将 `week` 字段拖到 x 轴,将 `trip_total` 字段拖到 y 轴: +我们将开始创建一个简单的柱状图,跟踪 `trip_total` 按 `week`。为此,我们将 `week` 字段拖动到 x 轴,将 `trip_total` 字段拖动到 y 轴: -按周的旅程总计 +按周计算的行程总额 -大多数图表类型支持多个字段在数值轴上。为了演示,我们将 `fare_total` 字段拖到 y 轴上: +大多数图表类型支持在数值轴上使用多个字段。为了演示,我们将 `fare_total` 字段拖到 y 轴: 柱状图 ### 自定义图表 {#customizing-charts} -SQL 控制台支持十种图表类型,可以从图表配置面板中的图表类型选择器中选择。例如,我们可以轻松将之前的图表类型从条形图更改为区域图: +SQL 控制台支持十种图表类型,可以从图表配置面板中的图表类型选择器中选择。例如,我们可以轻松将之前的图表类型从柱状图更改为区域图: 从柱状图更改为区域图 -图表标题与提供数据的查询名称匹配。更新查询的名称将导致图表标题也更新: +图表标题匹配提供数据的查询名称。更新查询的名称将导致图表标题也更新: 更新查询名称 -在图表配置面板的“高级”部分,还可以调整更多高级图表特性。首先,我们将调整以下设置: +在图表配置面板的“高级”部分中,还可以调整许多更高级的图表特性。首先,我们将调整以下设置: - 副标题 - 轴标题 @@ -307,6 +308,6 @@ SQL 控制台支持十种图表类型,可以从图表配置面板中的图表 更新副标题等 -在某些情况下,可能需要独立调整每个字段的轴刻度。这也可以在图表配置面板的“高级”部分完成,通过为轴范围指定最小值和最大值。例如,上面的图表看起来不错,但为了展示 `trip_total` 和 `fare_total` 字段之间的相关性,轴范围需要进行一些调整: +在某些情况下,可能需要分别调整每个字段的轴缩放。这也可以在图表配置面板的“高级”部分中通过指定轴范围的最小值和最大值来完成。作为示例,上述图表看起来不错,但为了演示 `trip_total` 和 `fare_total` 字段之间的相关性,轴范围需要进行一些调整: -调整轴刻度 +调整轴缩放 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/03_sql_console_features/01_sql-console.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/03_sql_console_features/01_sql-console.md.hash new file mode 100644 index 00000000000..cd20a0abc42 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/03_sql_console_features/01_sql-console.md.hash @@ -0,0 +1 @@ +34449e42ae4dd274 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/03_sql_console_features/02_query-insights.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/03_sql_console_features/02_query-insights.md new file mode 100644 index 00000000000..19ea713fcef --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/03_sql_console_features/02_query-insights.md @@ -0,0 +1,58 @@ +--- +'sidebar_title': 'Query Insights' +'slug': '/cloud/get-started/query-insights' +'description': '可视化 system.query_log 数据,以简化查询调试和性能优化' +'keywords': +- 'query insights' +- 'query log' +- 'query log ui' +- 'system.query_log insights' +'title': '查询洞察' +'doc_type': 'guide' +--- + +import Image from '@theme/IdealImage'; +import insights_overview from '@site/static/images/cloud/sqlconsole/insights_overview.png'; +import insights_latency from '@site/static/images/cloud/sqlconsole/insights_latency.png'; +import insights_recent from '@site/static/images/cloud/sqlconsole/insights_recent.png'; +import insights_drilldown from '@site/static/images/cloud/sqlconsole/insights_drilldown.png'; +import insights_query_info from '@site/static/images/cloud/sqlconsole/insights_query_info.png'; + + +# 查询洞察 + +**查询洞察**功能通过各种可视化和表格简化了 ClickHouse 内置查询日志的使用。ClickHouse 的 `system.query_log` 表是查询优化、调试和监控整体集群健康状况和性能的重要信息来源。 + +## 查询概述 {#query-overview} + +选择服务后,左侧边栏中的 **监控** 导航项将展开以显示新的 **查询洞察** 子项。单击此选项将打开新的查询洞察页面: + +查询洞察 UI 概览 + +## 顶级指标 {#top-level-metrics} + +顶部的统计框代表所选时间段内的一些基本顶级查询指标。在其下方,我们展示了三个时间序列图表,显示按查询种类(select, insert, other)划分的查询量、延迟和错误率,时间窗口是所选的。延迟图表可以进一步调整以显示 p50、p90 和 p99 延迟: + +查询洞察 UI 延迟图表 + +## 最近查询 {#recent-queries} + +在顶级指标下方,一个表格显示了所选时间窗口内的查询日志条目(按规范化查询哈希和用户分组): + +查询洞察 UI 最近查询表 + +最近的查询可以按任何可用字段进行过滤和排序。该表还可以配置以显示或隐藏额外字段,例如表、p90 和 p99 延迟。 + +## 查询详细信息 {#query-drill-down} + +从最近查询表中选择一个查询将打开一个侧边栏,其中包含特定于所选查询的指标和信息: + +查询洞察 UI 查询详细信息 + +从侧边栏中可以看到,特定查询在过去 24 小时内已运行超过 3000 次。**查询信息**选项卡中的所有指标都是汇总指标,但我们还可以通过选择 **查询历史** 选项卡查看单次运行的指标: + +查询洞察 UI 查询信息 + +
+ +在此面板中,可以展开每次查询运行的 `设置` 和 `性能事件` 项以显示其他信息。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/03_sql_console_features/02_query-insights.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/03_sql_console_features/02_query-insights.md.hash new file mode 100644 index 00000000000..bf731d4ab83 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/03_sql_console_features/02_query-insights.md.hash @@ -0,0 +1 @@ +3d50aa7c75663c38 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/get-started/query-endpoints.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/03_sql_console_features/03_query-endpoints.md similarity index 75% rename from i18n/zh/docusaurus-plugin-content-docs/current/cloud/get-started/query-endpoints.md rename to i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/03_sql_console_features/03_query-endpoints.md index 0d63a45a2ba..eb05fa66b69 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/get-started/query-endpoints.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/03_sql_console_features/03_query-endpoints.md @@ -1,13 +1,14 @@ --- 'sidebar_title': 'Query API Endpoints' 'slug': '/cloud/get-started/query-endpoints' -'description': '轻松从您保存的查询中生成 REST API 端点' +'description': '轻松从您保存的查询生成 REST API 端点' 'keywords': - 'api' - 'query api endpoints' - 'query endpoints' - 'query rest api' 'title': '查询 API 端点' +'doc_type': 'guide' --- import Image from '@theme/IdealImage'; @@ -21,80 +22,80 @@ import endpoints_monitoring from '@site/static/images/cloud/sqlconsole/endpoints # 查询 API 端点 -**查询 API 端点** 功能允许您直接从 ClickHouse Cloud 控制台中的任何保存的 SQL 查询创建 API 端点。您可以通过 HTTP 访问 API 端点,以执行您的保存查询,而无需通过本地驱动程序连接到您的 ClickHouse Cloud 服务。 +**查询 API 端点** 功能允许您直接从 ClickHouse Cloud 控制台中的任何已保存 SQL 查询创建 API 端点。您可以通过 HTTP 访问 API 端点,以执行已保存的查询,而无需通过原生驱动程序连接到 ClickHouse Cloud 服务。 ## 快速入门指南 {#quick-start-guide} 在继续之前,请确保您拥有 API 密钥和管理员控制台角色。您可以按照本指南 [创建 API 密钥](/cloud/manage/openapi)。 -### 创建保存的查询 {#creating-a-saved-query} +### 创建已保存的查询 {#creating-a-saved-query} -如果您已经有了保存的查询,可以跳过此步骤。 +如果您已经有已保存的查询,可以跳过此步骤。 -打开一个新的查询选项卡。为了演示目的,我们将使用 [youtube 数据集](/getting-started/example-datasets/youtube-dislikes),该数据集包含大约 45 亿条记录。作为示例查询,我们将根据用户输入的 `year` 参数返回按每个视频的平均观看次数排名前 10 的上传者: +打开一个新的查询标签。为了演示,我们将使用 [youtube 数据集](/getting-started/example-datasets/youtube-dislikes),该数据集包含大约 45 亿条记录。作为示例查询,我们将根据用户输入的 `year` 参数返回按平均每个视频观看次数排列的前 10 个上传者: ```sql -with sum(view_count) as view_sum, - round(view_sum / num_uploads, 2) as per_upload -select +WITH sum(view_count) AS view_sum, + round(view_sum / num_uploads, 2) AS per_upload +SELECT uploader, - count() as num_uploads, - formatReadableQuantity(view_sum) as total_views, - formatReadableQuantity(per_upload) as views_per_video -from + count() AS num_uploads, + formatReadableQuantity(view_sum) AS total_views, + formatReadableQuantity(per_upload) AS views_per_video +FROM youtube -where +WHERE toYear(upload_date) = {year: UInt16} group by uploader order by per_upload desc limit 10 ``` -请注意,这个查询包含一个参数(`year`)。 SQL 控制台查询编辑器会自动检测 ClickHouse 查询参数表达式,并为每个参数提供输入。我们快速运行此查询,以确保它正常工作: +请注意,此查询包含一个参数(`year`)。SQL 控制台查询编辑器会自动检测 ClickHouse 查询参数表达式,并为每个参数提供一个输入。让我们快速运行此查询,以确保它有效: 测试示例查询 -接下来,我们将保存查询: +下一步,我们将保存查询: 保存示例查询 -有关保存查询的更多文档,请参见 [这里](/cloud/get-started/sql-console#saving-a-query)。 +有关已保存查询的更多文档可在 [此处](/cloud/get-started/sql-console#saving-a-query) 找到。 ### 配置查询 API 端点 {#configuring-the-query-api-endpoint} -可以通过点击 **分享** 按钮并选择 `API 端点` 从查询视图直接配置查询 API 端点。系统会提示您指定可以访问该端点的 API 密钥: +查询 API 端点可以直接从查询视图配置,方法是点击 **Share** 按钮并选择 `API Endpoint`。系统会提示您指定哪些 API 密钥可以访问该端点: 配置查询端点 -选择 API 密钥后,查询 API 端点将自动配置。示例 `curl` 命令将显示,您可以用它发送测试请求: +选择 API 密钥后,查询 API 端点将自动配置。将显示一个示例 `curl` 命令,您可以用来发送测试请求: 端点 curl 命令 ### 查询 API 参数 {#query-api-parameters} -查询中的查询参数可以使用语法 `{parameter_name: type}` 指定。这些参数将被自动检测,示例请求有效负载将包含一个 `queryVariables` 对象,通过该对象您可以传递这些参数。 +查询中的查询参数可以使用语法 `{parameter_name: type}` 指定。这些参数将被自动检测,示例请求有效载荷将包含一个 `queryVariables` 对象,通过该对象您可以传递这些参数。 ### 测试和监控 {#testing-and-monitoring} -创建查询 API 端点后,您可以使用 `curl` 或任何其他 HTTP 客户端测试其是否正常工作: +创建查询 API 端点后,您可以使用 `curl` 或任何其他 HTTP 客户端测试其是否有效: 端点 curl 测试 -在您发送第一个请求后,**分享** 按钮右侧应立即出现一个新按钮。单击它将打开一个弹出窗口,包含有关查询的监控数据: +发送完第一个请求后,**Share** 按钮右侧应立即出现一个新按钮。点击它将打开一个包含有关查询的监控数据的浮动窗口: 端点监控 -## 实现详情 {#implementation-details} +## 实现细节 {#implementation-details} ### 描述 {#description} -此路由在指定的查询端点上运行查询。它支持不同的版本、格式和查询变量。响应可以是流式的(_仅限版本 2_)或作为单个有效负载返回。 +此路由在指定的查询端点上运行查询。它支持不同的版本、格式和查询变量。响应可以是流式的(_仅限版本 2_)或作为单个有效载荷返回。 ### 身份验证 {#authentication} - **必需**:是 -- **方法**:通过 OpenAPI 密钥/密钥的基本身份验证 -- **权限**:对查询端点的适当权限。 +- **方法**:通过 OpenAPI 密钥/秘密的基本身份验证 +- **权限**:查询端点的适当权限。 ### URL 参数 {#url-parameters} @@ -109,18 +110,18 @@ limit 10 #### V2 {#v2} - `format`(可选):响应的格式。支持 ClickHouse 支持的所有格式。 -- `param_:name` 查询变量,用于查询中。 `name` 应与查询中的变量名称匹配。这应该仅在请求主体是数据流时使用。 -- `:clickhouse_setting` 任何支持的 [ClickHouse 设置](/operations/settings/settings) 可以作为查询参数传递。 +- `param_:name` 查询变量,用于查询。`name` 应与查询中的变量名称匹配。这个仅在请求的主体为流时使用。 +- `:clickhouse_setting` 任何受支持的 [ClickHouse 设置](/operations/settings/settings) 可以作为查询参数传递。 ### 头部 {#headers} -- `x-clickhouse-endpoint-version`(可选):查询端点的版本。支持的版本为 `1` 和 `2`。如果未提供,默认版本为该端点最后保存的版本。 -- `x-clickhouse-endpoint-upgrade`(可选):设置此头部以升级端点版本。此操作与 `x-clickhouse-endpoint-version` 头部配合使用。 +- `x-clickhouse-endpoint-version`(可选):查询端点的版本。支持的版本为 `1` 和 `2`。如果未提供,则默认版本为为该端点最后保存的版本。 +- `x-clickhouse-endpoint-upgrade`(可选):设置此头部以升级端点版本。此工作与 `x-clickhouse-endpoint-version` 头部一起使用。 ### 请求主体 {#request-body} -- `queryVariables`(可选):包含用于查询的变量的对象。 -- `format`(可选):响应的格式。如果查询 API 端点为版本 2,任何 ClickHouse 支持的格式都是可能的。v1 的支持格式为: +- `queryVariables`(可选):一个包含用于查询的变量的对象。 +- `format`(可选):响应的格式。如果查询 API 端点是版本 2,则可以使用任何 ClickHouse 支持的格式。v1 支持的格式包括: - TabSeparated - TabSeparatedWithNames - TabSeparatedWithNamesAndTypes @@ -134,18 +135,18 @@ limit 10 - **200 OK**:查询成功执行。 - **400 Bad Request**:请求格式错误。 -- **401 Unauthorized**:请求未进行身份验证或权限不足。 +- **401 Unauthorized**:请求未经身份验证或权限不足。 - **404 Not Found**:未找到指定的查询端点。 ### 错误处理 {#error-handling} - 确保请求包含有效的身份验证凭据。 -- 验证 `queryEndpointId` 和 `queryVariables` 确保它们是正确的。 -- 优雅地处理任何服务器错误,返回适当的错误消息。 +- 验证 `queryEndpointId` 和 `queryVariables` 以确保它们正确。 +- 优雅地处理服务器错误,返回适当的错误信息。 ### 升级端点版本 {#upgrading-the-endpoint-version} -要将端点版本从 `v1` 升级到 `v2`,请在请求中包含 `x-clickhouse-endpoint-upgrade` 头部并将其设置为 `1`。这将触发升级过程,并允许您使用 `v2` 中可用的功能和改进。 +要将端点版本从 `v1` 升级到 `v2`,请在请求中包含 `x-clickhouse-endpoint-upgrade` 头,并将其设置为 `1`。这将触发升级过程,并允许您使用 `v2` 中可用的功能和改进。 ## 示例 {#examples} @@ -154,7 +155,7 @@ limit 10 **查询 API 端点 SQL:** ```sql -SELECT database, name as num_tables FROM system.tables limit 3; +SELECT database, name AS num_tables FROM system.tables LIMIT 3; ``` #### 版本 1 {#version-1} @@ -251,7 +252,7 @@ fetch( {"database":"INFORMATION_SCHEMA","num_tables":"REFERENTIAL_CONSTRAINTS"} ``` -### 请求中带有查询变量和版本 2 的 JSONCompactEachRow 格式 {#request-with-query-variables-and-version-2-on-jsoncompacteachrow-format} +### 带有查询变量和版本 2 的 JSONCompactEachRow 格式请求 {#request-with-query-variables-and-version-2-on-jsoncompacteachrow-format} **查询 API 端点 SQL:** @@ -302,7 +303,7 @@ fetch( ["query_views_log", "system"] ``` -### 请求中带有数组的查询变量,该变量向表中插入数据 {#request-with-array-in-the-query-variables-that-inserts-data-into-a-table} +### 请求带有数组的查询变量以将数据插入表 {#request-with-array-in-the-query-variables-that-inserts-data-into-a-table} **表 SQL:** @@ -365,12 +366,12 @@ fetch( OK ``` -### 请求时将 ClickHouse 设置 max_threads 设置为 8 {#request-with-clickhouse-settings-max_threads-set-to-8} +### 请求并将 ClickHouse 设置 max_threads 设置为 8 {#request-with-clickhouse-settings-max_threads-set-to-8} **查询 API 端点 SQL:** ```sql -SELECT * from system.tables; +SELECT * FROM system.tables; ``` **cURL:** @@ -406,7 +407,7 @@ fetch( **查询 API 端点 SQL:** ```sql -SELECT name, database from system.tables; +SELECT name, database FROM system.tables; ``` **Typescript:** @@ -471,7 +472,7 @@ fetchAndLogChunks(endpointUrl, openApiKeyId, openApiKeySecret).catch((err) => > Stream ended. ``` -### 从文件向表中插入流 {#insert-a-stream-from-a-file-into-a-table} +### 从文件插入流到表 {#insert-a-stream-from-a-file-into-a-table} 创建一个文件 ./samples/my_first_table_2024-07-11.csv,内容如下: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/03_sql_console_features/03_query-endpoints.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/03_sql_console_features/03_query-endpoints.md.hash new file mode 100644 index 00000000000..f5b8f94c6b0 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/03_sql_console_features/03_query-endpoints.md.hash @@ -0,0 +1 @@ +045c79c3a42865be diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/03_sql_console_features/04_dashboards.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/03_sql_console_features/04_dashboards.md new file mode 100644 index 00000000000..829a71ef2e5 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/03_sql_console_features/04_dashboards.md @@ -0,0 +1,105 @@ +--- +'sidebar_label': '仪表板' +'slug': '/cloud/manage/dashboards' +'title': '仪表板' +'description': 'SQL 控制台的仪表板功能允许您收集和分享来自保存的 查询 的可视化数据。' +'doc_type': 'guide' +--- + +import BetaBadge from '@theme/badges/BetaBadge'; +import Image from '@theme/IdealImage'; +import dashboards_2 from '@site/static/images/cloud/dashboards/2_dashboards.png'; +import dashboards_3 from '@site/static/images/cloud/dashboards/3_dashboards.png'; +import dashboards_4 from '@site/static/images/cloud/dashboards/4_dashboards.png'; +import dashboards_5 from '@site/static/images/cloud/dashboards/5_dashboards.png'; +import dashboards_6 from '@site/static/images/cloud/dashboards/6_dashboards.png'; +import dashboards_7 from '@site/static/images/cloud/dashboards/7_dashboards.png'; +import dashboards_8 from '@site/static/images/cloud/dashboards/8_dashboards.png'; +import dashboards_9 from '@site/static/images/cloud/dashboards/9_dashboards.png'; +import dashboards_10 from '@site/static/images/cloud/dashboards/10_dashboards.png'; +import dashboards_11 from '@site/static/images/cloud/dashboards/11_dashboards.png'; + + +# 仪表板 + +SQL 控制台的仪表板功能允许您收集和共享来自已保存查询的可视化。首先,通过保存和可视化查询,向仪表板添加查询可视化,并使用查询参数使仪表板具有互动性来开始。 + +## 核心概念 {#core-concepts} + +### 查询共享 {#query-sharing} + +为了与同事共享您的仪表板,请确保共享基础的已保存查询。为了查看可视化,用户至少必须具有对基础已保存查询的只读访问权限。 + +### 互动性 {#interactivity} + +使用 [查询参数](/sql-reference/syntax#defining-and-using-query-parameters) 使您的仪表板具有互动性。例如,您可以在 `WHERE` 子句中添加查询参数以作为过滤器。 + +您可以通过选择可视化设置中的“过滤器”类型,在 **Global** 过滤器侧边栏中切换查询参数输入。您还可以通过将其链接到仪表板上的另一个对象(如表)来切换查询参数输入。请参阅以下快速入门指南的“[配置过滤器](/cloud/manage/dashboards#configure-a-filter)”部分。 + +## 快速入门 {#quick-start} + +让我们创建一个仪表板,以使用 [query\_log](/operations/system-tables/query_log) 系统表监控我们的 ClickHouse 服务。 + +## 快速入门 {#quick-start-1} + +### 创建已保存查询 {#create-a-saved-query} + +如果您已经有要可视化的已保存查询,可以跳过此步骤。 + +打开一个新的查询选项卡。让我们编写一个查询,以统计 ClickHouse 系统表中按天的查询量: + +创建已保存查询 + +我们可以以表格格式查看查询结果,或开始从图表视图构建可视化。在下一步中,我们将查询保存为 `queries over time`: + +保存查询 + +有关已保存查询的更多文档,请参阅 [Saving a Query section](/cloud/get-started/sql-console#saving-a-query)。 + +我们可以创建并保存另一个查询 `query count by query kind`,以统计按查询种类分类的查询数量。以下是 SQL 控制台中数据的条形图可视化。 + +查询结果的条形图可视化 + +现在有了两个查询,让我们创建一个仪表板来可视化并收集这些查询。 + +### 创建仪表板 {#create-a-dashboard} + +导航到仪表板面板,点击“新仪表板”。在给定名称后,您将成功创建第一个仪表板! + +创建新仪表板 + +### 添加可视化 {#add-a-visualization} + +有两个已保存的查询,`queries over time` 和 `query count by query kind`。让我们将第一个可视化为折线图。为您的可视化提供标题和副标题,并选择要可视化的查询。接下来,选择“折线”图表类型,并分配一个 x 轴和一个 y 轴。 + +添加可视化 + +在这里,还可以进行其他样式更改——例如数字格式、图例布局和坐标轴标签。 + +接下来,让我们将第二个查询可视化为表格,并将其放置在折线图下方。 + +将查询结果可视化为表格 + +您通过可视化两个已保存的查询创建了第一个仪表板! + +### 配置过滤器 {#configure-a-filter} + +让我们通过在查询种类上添加过滤器使仪表板具有互动性,这样您可以仅显示与插入查询相关的趋势。我们将利用 [查询参数](/sql-reference/syntax#defining-and-using-query-parameters) 来完成这项工作。 + +点击折线图旁边的三个点,点击查询旁的铅笔按钮以打开行内查询编辑器。在这里,我们可以直接从仪表板编辑基础的已保存查询。 + +编辑基础查询 + +现在,当按下黄色的运行查询按钮时,您将看到之前过滤仅针对插入查询的相同查询。点击保存按钮以更新查询。当您返回到图表设置时,您将能够过滤折线图。 + +现在,使用顶部功能区中的 Global Filters,您可以通过更改输入来切换过滤器。 + +调整全局过滤器 + +假设您想将折线图的过滤器链接到表格。您可以通过返回可视化设置,将 query_kind 查询参数的值源更改为表格,并选择 query_kind 列作为要链接的字段来实现。 + +更改查询参数 + +现在,您可以直接从按种类查询的表中控制折线图的过滤器,以使您的仪表板具有互动性。 + +控制折线图上的过滤器 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/03_sql_console_features/04_dashboards.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/03_sql_console_features/04_dashboards.md.hash new file mode 100644 index 00000000000..83f416a9fa0 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/03_sql_console_features/04_dashboards.md.hash @@ -0,0 +1 @@ +83f396087cedafb6 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/03_sql_console_features/_category_.json b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/03_sql_console_features/_category_.json new file mode 100644 index 00000000000..07e636bd5ed --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/03_sql_console_features/_category_.json @@ -0,0 +1,5 @@ +{ + "label": "SQL console", + "collapsible": true, + "collapsed": true, +} \ No newline at end of file diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/03_sql_console_features/hyperdx.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/03_sql_console_features/hyperdx.md new file mode 100644 index 00000000000..db4faf795f5 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/03_sql_console_features/hyperdx.md @@ -0,0 +1,30 @@ +--- +'sidebar_label': 'HyperDX' +'slug': '/cloud/manage/hyperdx' +'title': 'HyperDX' +'description': '提供 HyperDX,这是一个用于 ClickStack 的用户界面 - 一个基于 ClickHouse 和 OpenTelemetry + (OTel) 的生产级可观察性平台,将日志、跟踪、指标和会话统一在一个高性能可扩展的解决方案中。' +'doc_type': 'guide' +--- + +import PrivatePreviewBadge from '@theme/badges/PrivatePreviewBadge'; +import Image from '@theme/IdealImage'; +import hyperdx_cloud from '@site/static/images/use-cases/observability/hyperdx_cloud.png'; + + + +HyperDX 是 [**ClickStack**](/use-cases/observability/clickstack) 的用户界面 - 一款基于 ClickHouse 和 OpenTelemetry (OTel) 构建的生产级可观察性平台,将日志、追踪、指标和会话统一在一个高性能解决方案中。ClickStack 旨在监控和调试复杂系统,使开发人员和 SRE 能够在不切换工具或手动使用时间戳或关联 ID 拼接数据的情况下,进行端到端的问题追踪。 + +HyperDX 是一个专门构建的前端,用于探索和可视化可观察性数据,支持 Lucene 风格和 SQL 查询、交互式仪表板、警报、追踪探索等功能——所有这些都是针对 ClickHouse 作为后端进行了优化。 + +ClickHouse Cloud 中的 HyperDX 允许用户享受更便捷的 ClickStack 体验——无须管理基础设施,无需配置单独的身份验证。HyperDX 可以一键启动并连接到您的数据——完全整合到 ClickHouse Cloud 身份验证系统中,实现无缝、安全地访问您的可观察性洞见。 + +## 部署 {#main-concepts} + +ClickHouse Cloud 中的 HyperDX 目前处于私人预览阶段,必须在组织级别启用。一旦启用,用户将在选择任何服务时,在左侧主导航菜单中找到 HyperDX。 + +ClickHouse Cloud HyperDX + +要开始使用 ClickHouse Cloud 中的 HyperDX,我们建议您参考我们的专用 [入门指南](/use-cases/observability/clickstack/deployment/hyperdx-clickhouse-cloud)。 + +有关 ClickStack 的更多详细信息,请参见 [完整文档](/use-cases/observability/clickstack)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/03_sql_console_features/hyperdx.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/03_sql_console_features/hyperdx.md.hash new file mode 100644 index 00000000000..203c1752946 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/03_sql_console_features/hyperdx.md.hash @@ -0,0 +1 @@ +a7d48abbb45ec3a0 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/04_infrastructure/_category_.json b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/04_infrastructure/_category_.json new file mode 100644 index 00000000000..41f211b5456 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/04_infrastructure/_category_.json @@ -0,0 +1,5 @@ +{ + "label": "Infrastructure", + "collapsible": true, + "collapsed": true, +} \ No newline at end of file diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/04_infrastructure/automatic_scaling.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/04_infrastructure/automatic_scaling.md new file mode 100644 index 00000000000..bc529255521 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/04_infrastructure/automatic_scaling.md @@ -0,0 +1,157 @@ +--- +'sidebar_position': 1 +'sidebar_label': '自动伸缩' +'slug': '/manage/scaling' +'description': '在 ClickHouse Cloud 中配置自动伸缩' +'keywords': +- 'autoscaling' +- 'auto scaling' +- 'scaling' +- 'horizontal' +- 'vertical' +- 'bursts' +'title': '自动伸缩' +'doc_type': 'guide' +--- + +import Image from '@theme/IdealImage'; +import auto_scaling from '@site/static/images/cloud/manage/AutoScaling.png'; +import scaling_patch_request from '@site/static/images/cloud/manage/scaling-patch-request.png'; +import scaling_patch_response from '@site/static/images/cloud/manage/scaling-patch-response.png'; +import scaling_configure from '@site/static/images/cloud/manage/scaling-configure.png'; +import scaling_memory_allocation from '@site/static/images/cloud/manage/scaling-memory-allocation.png'; +import ScalePlanFeatureBadge from '@theme/badges/ScalePlanFeatureBadge' + + +# 自动扩展 + +扩展是根据客户需求调整可用资源的能力。Scale 和 Enterprise (具有标准 1:4 配置文件) 级别的服务可以通过调用 API 进行水平扩展,或者通过在 UI 上更改设置来调整系统资源。这些服务还可以 **自动垂直扩展** 以满足应用程序需求。 + + + +:::note +Scale 和 Enterprise 级别支持单副本和多副本服务,而 Basic 级别仅支持单副本服务。单副本服务的大小是固定的,不允许进行垂直或水平扩展。用户可以升级到 Scale 或 Enterprise 级别以扩展他们的服务。 +::: + +## ClickHouse Cloud 中的扩展工作原理 {#how-scaling-works-in-clickhouse-cloud} + +目前,ClickHouse Cloud 支持对 Scale 级服务进行垂直自动扩展和手动水平扩展。 + +对于 Enterprise 级服务,扩展工作如下: + +- **水平扩展**:手动水平扩展将在企业级的所有标准和自定义配置文件中可用。 +- **垂直扩展**: + - 标准配置文件 (1:4) 将支持垂直自动扩展。 + - 自定义配置文件 (`highMemory` 和 `highCPU`) 不支持垂直自动扩展或手动垂直扩展。但是,可以通过联系支持团队对这些服务进行垂直扩展。 + +:::note +ClickHouse Cloud 中的扩展采用我们称之为 “Make Before Break” (MBB) 的方法。在删除旧副本之前,先添加一个或多个新大小的副本,以防止扩展操作期间的容量损失。通过消除移除现有副本和添加新副本之间的间隙,MBB 创建了一个更加无缝和较少干扰的扩展过程。这在扩展场景中特别有利,因为高资源利用率触发了对额外容量的需求,因为提前删除副本只会加剧资源限制。作为此方法的一部分,我们会等待最长一个小时,以让任何现有查询在旧副本上完成,然后再将其删除。这平衡了现有查询完成的需求,同时确保旧副本不会停留太久。 + +请注意,作为此变化的一部分: +1. 历史系统表数据将在扩展事件中保留最多 30 天。此外,2024 年 12 月 19 日之前的 AWS 或 GCP 服务上的任何系统表数据,以及 2025 年 1 月 14 日之前的 Azure 服务上的数据将不会在迁移到新组织级别时保留。 +2. 对于使用 TDE (Transparent Data Encryption) 的服务,系统表数据在 MBB 操作后当前不会维护。我们正在努力消除这一限制。 +::: + +### 垂直自动扩展 {#vertical-auto-scaling} + + + +Scale 和 Enterprise 服务支持基于 CPU 和内存使用情况的自动扩展。我们会不断监控服务在回溯窗口 (过去 30 小时) 期间的历史使用情况以做出扩展决策。如果使用率超过或低于某些阈值,我们会相应地扩展服务以满足需求。 + +基于 CPU 的自动扩展在 CPU 使用率超过 50-75% 的上限阈值时启动(实际阈值取决于集群的大小)。此时,分配给集群的 CPU 配额会加倍。如果 CPU 使用率降到上限阈值的一半以下(例如,对于 50% 的上限阈值,降到 25%),则 CPU 配额减半。 + +基于内存的自动扩展会将集群扩展到最大内存使用量的 125%,如果遇到 OOM (内存不足) 错误,则最多可扩展到 150%。 + +***CPU*** 和 ***内存*** 推荐中选择 **较大者**,分配给服务的 CPU 和内存将按步进大小 `1` CPU 和 `4 GiB` 内存进行扩展。 + +### 配置垂直自动扩展 {#configuring-vertical-auto-scaling} + +ClickHouse Cloud Scale 或 Enterprise 服务的扩展可以由具有 **Admin** 角色的组织成员进行调整。要配置垂直自动扩展,请转到服务的 **设置** 选项卡,并按如下所示调整最小和最大内存及 CPU 设置。 + +:::note +单副本服务在所有级别都不能进行扩展。 +::: + +Scaling settings page + +将副本的 **最大内存** 设置为高于 **最小内存** 的值。服务将在这些范围内根据需要进行扩展。这些设置在服务初始创建过程中也可用。每个副本将分配相同的内存和 CPU 资源。 + +您还可以选择将这些值设置为相同,从而“固定”服务到特定配置。这样做会立即强制扩展到您选择的期望大小。 + +需要注意的是,这将禁用集群上的任何自动扩展,并且您的服务将在超出这些设置的 CPU 或内存使用量增加时不受保护。 + +:::note +对于 Enterprise 级服务,标准 1:4 配置文件将支持垂直自动扩展。 +自定义配置文件在推出时将不支持垂直自动扩展或手动垂直扩展。 +但是,可以通过联系支持来对这些服务进行垂直扩展。 +::: + +## 手动水平扩展 {#manual-horizontal-scaling} + + + +您可以使用 ClickHouse Cloud [公共 API](https://clickhouse.com/docs/cloud/manage/api/swagger#/paths/~1v1~1organizations~1:organizationId~1services~1:serviceId~1scaling/patch) 通过更新服务的扩展设置,或在云控制台中调整副本数量来扩展您的服务。 + +**Scale** 和 **Enterprise** 级别也支持单副本服务。服务扩展后,可以缩减到最低单副本。请注意,单副本服务的可用性降低,不推荐用于生产使用。 + +:::note +服务可以水平扩展到最多 20 个副本。如果您需要额外的副本,请联系支持团队。 +::: + +### 通过 API 进行水平扩展 {#horizontal-scaling-via-api} + +要进行水平扩展,发送一个 `PATCH` 请求通过 API 调整副本数量。下图展示了一个将 `3` 副本集群扩展到 `6` 个副本的 API 调用和相应的响应。 + +Scaling PATCH request + +*`PATCH` 请求以更新 `numReplicas`* + +Scaling PATCH response + +*来自 `PATCH` 请求的响应* + +如果在一个扩展请求正在进行时发出新的扩展请求或多个请求,扩展服务将忽略中间状态,并最终收敛到最终的副本计数。 + +### 通过 UI 进行水平扩展 {#horizontal-scaling-via-ui} + +要通过 UI 对服务进行水平扩展,您可以在 **设置** 页面上调整服务的副本数量。 + +Scaling configuration settings + +*来自 ClickHouse Cloud 控制台的服务扩展设置* + +扩展服务后,云控制台中的指标仪表板应显示服务的正确分配。下图显示集群总内存扩展到 `96 GiB`,这意味着 `6` 个副本,每个副本分配 `16 GiB` 内存。 + +Scaling memory allocation + +## 自动闲置 {#automatic-idling} +在 **设置** 页面中,您还可以选择是否在服务不活动时允许自动闲置,如上图所示(即当服务未执行任何用户提交的查询时)。 自动闲置减少了您的服务成本,因为在服务暂停时不会对计算资源进行计费。 + +:::note +在某些特殊情况下,例如当服务具有大量分片时,服务将不会自动闲置。 + +服务可能会进入一种闲置状态,在这种状态下,它暂停 [可刷新的物化视图](/materialized-view/refreshable-materialized-view) 的刷新、从 [S3Queue](/engines/table-engines/integrations/s3queue) 的消费和新合并的调度。现有的合并操作将在服务过渡到闲置状态之前完成。为了确保可刷新的物化视图和 S3Queue 消费的连续操作,请禁用闲置状态功能。 +::: + +:::danger 何时不使用自动闲置 +仅当您的用例能承受响应查询的延迟时,才使用自动闲置,因为当服务暂停时,连接到服务的连接将超时。自动闲置非常适合不常使用且可以容忍延迟的服务。不建议用于频繁使用并驱动面向客户功能的服务。 +::: + +## 处理工作负载激增 {#handling-bursty-workloads} + +如果您预期即将出现工作负载激增,您可以使用 [ClickHouse Cloud API](/cloud/manage/api/api-overview) 预先扩展您的服务以应对激增,并在需求减退后缩减服务。 + +要了解每个副本当前的 CPU 核心和内存使用情况,您可以运行以下查询: + +```sql +SELECT * +FROM clusterAllReplicas('default', view( + SELECT + hostname() AS server, + anyIf(value, metric = 'CGroupMaxCPU') AS cpu_cores, + formatReadableSize(anyIf(value, metric = 'CGroupMemoryTotal')) AS memory + FROM system.asynchronous_metrics +)) +ORDER BY server ASC +SETTINGS skip_unavailable_shards = 1 +``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/04_infrastructure/automatic_scaling.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/04_infrastructure/automatic_scaling.md.hash new file mode 100644 index 00000000000..66fb2822570 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/04_infrastructure/automatic_scaling.md.hash @@ -0,0 +1 @@ +1346675e3b9ed266 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/04_infrastructure/byoc.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/04_infrastructure/byoc.md new file mode 100644 index 00000000000..b8cbd68df36 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/04_infrastructure/byoc.md @@ -0,0 +1,497 @@ +--- +'title': 'AWS 的 BYOC (Bring Your Own Cloud)' +'slug': '/cloud/reference/byoc' +'sidebar_label': 'BYOC (Bring Your Own Cloud)' +'keywords': +- 'BYOC' +- 'cloud' +- 'bring your own cloud' +'description': '在您自己的云基础设施上部署 ClickHouse' +'doc_type': 'reference' +--- + +import Image from '@theme/IdealImage'; +import byoc1 from '@site/static/images/cloud/reference/byoc-1.png'; +import byoc4 from '@site/static/images/cloud/reference/byoc-4.png'; +import byoc3 from '@site/static/images/cloud/reference/byoc-3.png'; +import byoc_vpcpeering from '@site/static/images/cloud/reference/byoc-vpcpeering-1.png'; +import byoc_vpcpeering2 from '@site/static/images/cloud/reference/byoc-vpcpeering-2.png'; +import byoc_vpcpeering3 from '@site/static/images/cloud/reference/byoc-vpcpeering-3.png'; +import byoc_vpcpeering4 from '@site/static/images/cloud/reference/byoc-vpcpeering-4.png'; +import byoc_plb from '@site/static/images/cloud/reference/byoc-plb.png'; +import byoc_security from '@site/static/images/cloud/reference/byoc-securitygroup.png'; +import byoc_inbound from '@site/static/images/cloud/reference/byoc-inbound-rule.png'; +import byoc_subnet_1 from '@site/static/images/cloud/reference/byoc-subnet-1.png'; +import byoc_subnet_2 from '@site/static/images/cloud/reference/byoc-subnet-2.png'; +import byoc_s3_endpoint from '@site/static/images/cloud/reference/byoc-s3-endpoint.png' + +## 概述 {#overview} + +BYOC (自带云) 允许您在自己的云基础设施上部署 ClickHouse Cloud。如果您有特定要求或限制,无法使用 ClickHouse Cloud 托管服务,这将非常有用。 + +**如果您希望获得访问权限,请 [联系我们](https://clickhouse.com/cloud/bring-your-own-cloud)。** 有关更多信息,请参阅我们的 [服务条款](https://clickhouse.com/legal/agreements/terms-of-service)。 + +目前,BYOC 仅支持 AWS。您可以在 [这里](https://clickhouse.com/cloud/bring-your-own-cloud) 加入 GCP 和 Azure 的等待名单。 + +:::note +BYOC 专为大规模部署设计,并要求客户签署保留合同。 +::: + +## 术语表 {#glossary} + +- **ClickHouse VPC:** 由 ClickHouse Cloud 拥有的 VPC。 +- **客户 BYOC VPC:** 由客户的云账户拥有的 VPC,由 ClickHouse Cloud 提供和管理,专用于 ClickHouse Cloud BYOC 部署。 +- **客户 VPC:** 其他由客户云账户拥有的 VPC,用于需要连接到客户 BYOC VPC 的应用程序。 + +## 架构 {#architecture} + +指标和日志存储在客户的 BYOC VPC 内。日志目前存储在本地 EBS 中。在未来的更新中,日志将存储在 LogHouse 中,这是一个 ClickHouse 服务,位于客户的 BYOC VPC 中。指标通过存储在客户 BYOC VPC 中的 Prometheus 和 Thanos 堆栈实现。 + +
+ +BYOC Architecture + +
+ +## 上线流程 {#onboarding-process} + +客户可以通过联系 [我们](https://clickhouse.com/cloud/bring-your-own-cloud) 来启动上线流程。客户需要有一个专用的 AWS 账户并了解他们将使用的区域。目前,我们仅允许用户在我们支持的 ClickHouse Cloud 区域内启动 BYOC 服务。 + +### 准备 AWS 账户 {#prepare-an-aws-account} + +我们建议客户准备一个专用的 AWS 账户,以托管 ClickHouse BYOC 部署,以确保更好的隔离。然而,使用共享账户和现有 VPC 也是可以的。有关详细信息,请参阅下面的 *设置 BYOC 基础设施*。 + +拥有此账户和初始组织管理员电子邮件后,您可以联系 ClickHouse 支持。 + +### 初始化 BYOC 设置 {#initialize-byoc-setup} + +初始 BYOC 设置可以使用 CloudFormation 模板或 Terraform 模块进行。两种方法都创建相同的 IAM 角色,使来自 ClickHouse Cloud 的 BYOC 控制器能够管理您的基础设施。请注意,运行 ClickHouse 所需的 S3、VPC 和计算资源不包括在此初始设置中。 + +#### CloudFormation 模板 {#cloudformation-template} + +[BYOC CloudFormation 模板](https://s3.us-east-2.amazonaws.com/clickhouse-public-resources.clickhouse.cloud/cf-templates/byoc.yaml) + +#### Terraform 模块 {#terraform-module} + +[BYOC Terraform 模块](https://s3.us-east-2.amazonaws.com/clickhouse-public-resources.clickhouse.cloud/tf/byoc.tar.gz) + +```hcl +module "clickhouse_onboarding" { + source = "https://s3.us-east-2.amazonaws.com/clickhouse-public-resources.clickhouse.cloud/tf/byoc.tar.gz" + byoc_env = "production" +} +``` + + + +### 设置 BYOC 基础设施 {#setup-byoc-infrastructure} + +创建 CloudFormation 栈后,系统会提示您从云控制台设置基础设施,包括 S3、VPC 和 EKS 集群。在此阶段必须确定某些配置,因为之后无法更改。具体包括: + +- **您要使用的区域**,您可以选择我们为 ClickHouse Cloud 提供的任何 [公共区域](/cloud/reference/supported-regions)。 +- **BYOC 的 VPC CIDR 范围**:默认情况下,我们使用 `10.0.0.0/16` 作为 BYOC VPC CIDR 范围。如果您打算与另一个账户进行 VPC 对等互联,请确保 CIDR 范围不重叠。为 BYOC 分配适当的 CIDR 范围,最小大小为 `/22` 以容纳必需的工作负载。 +- **BYOC VPC 的可用区**:如果您打算使用 VPC 对等互联,源账户和 BYOC 账户之间的可用区对齐可以帮助降低跨 AZ 流量费用。在 AWS 中,可用区后缀(`a, b, c`)可能表示不同账户中的不同物理区域 ID。有关详细信息,请参阅 [AWS 指南](https://docs.aws.amazon.com/prescriptive-guidance/latest/patterns/use-consistent-availability-zones-in-vpcs-across-different-aws-accounts.html)。 + +#### 客户管理的 VPC {#customer-managed-vpc} +默认情况下,ClickHouse Cloud 将为您的 BYOC 部署提供一个专用 VPC,以确保更好的隔离。然而,您也可以在您的账户中使用现有 VPC。这需要特定配置,并且必须通过 ClickHouse 支持协调。 + +**配置您的现有 VPC** +1. 为 ClickHouse Cloud 使用的至少 3 个不同可用区分配 3 个私有子网。 +2. 确保每个子网的最小 CIDR 范围为 `/23`(例如,10.0.0.0/23),以为 ClickHouse 部署提供足够的 IP 地址。 +3. 在每个子网上添加标签 `kubernetes.io/role/internal-elb=1` 以启用正确的负载均衡器配置。 + +
+ +BYOC VPC Subnet + +
+ +
+ +BYOC VPC Subnet Tags + +
+ +4. 配置 S3 网关端点 +如果您的 VPC 尚未配置 S3 网关端点,则需要创建一个,以实现 VPC 和 Amazon S3 之间的安全私密通信。此端点允许您的 ClickHouse 服务访问 S3,而无需经过公共互联网。请参考下面的屏幕截图,了解示例配置。 + +
+ +BYOC S3 Endpint + +
+ +**联系 ClickHouse 支持** +创建支持票据,提供以下信息: + +* 您的 AWS 账户 ID +* 您希望部署服务的 AWS 区域 +* 您的 VPC ID +* 您为 ClickHouse 分配的私有子网 ID +* 这些子网所在的可用区 + +### 可选:设置 VPC 对等互联 {#optional-setup-vpc-peering} + +要为 ClickHouse BYOC 创建或删除 VPC 对等互联,请按照以下步骤操作: + +#### 第 1 步:为 ClickHouse BYOC 启用私有负载均衡器 {#step-1-enable-private-load-balancer-for-clickhouse-byoc} +联系 ClickHouse 支持以启用私有负载均衡器。 + +#### 第 2 步:创建对等连接 {#step-2-create-a-peering-connection} +1. 导航到 ClickHouse BYOC 账户中的 VPC 控制台。 +2. 选择 Peering Connections。 +3. 点击 Create Peering Connection。 +4. 将 VPC Requester 设置为 ClickHouse VPC ID。 +5. 将 VPC Accepter 设置为目标 VPC ID。(如适用,请选择其他账户) +6. 点击 Create Peering Connection。 + +
+ +BYOC Create Peering Connection + +
+ +#### 第 3 步:接受对等连接请求 {#step-3-accept-the-peering-connection-request} +转到对等账户,在 (VPC -> Peering connections -> Actions -> Accept request) 页面,客户可以批准此 VPC 对等请求。 + +
+ +BYOC Accept Peering Connection + +
+ +#### 第 4 步:将目标添加到 ClickHouse VPC 路由表 {#step-4-add-destination-to-clickhouse-vpc-route-tables} +在 ClickHouse BYOC 账户中, +1. 在 VPC 控制台中选择 Route Tables。 +2. 搜索 ClickHouse VPC ID。编辑附加到私有子网的每个路由表。 +3. 点击 Routes 标签下的 Edit 按钮。 +4. 点击 Add another route。 +5. 输入目标 VPC 的 CIDR 范围作为 Destination。 +6. 选择 “Peering Connection” 和对等连接的 ID 作为 Target。 + +
+ +BYOC Add route table + +
+ +#### 第 5 步:将目标添加到目标 VPC 路由表 {#step-5-add-destination-to-the-target-vpc-route-tables} +在对等 AWS 账户中, +1. 在 VPC 控制台中选择 Route Tables。 +2. 搜索目标 VPC ID。 +3. 点击 Routes 标签下的 Edit 按钮。 +4. 点击 Add another route。 +5. 输入 ClickHouse VPC 的 CIDR 范围作为 Destination。 +6. 选择 “Peering Connection” 和对等连接的 ID 作为 Target。 + +
+ +BYOC Add route table + +
+ +#### 第 6 步:编辑安全组以允许对等 VPC 访问 {#step-6-edit-security-group-to-allow-peered-vpc-access} +在 ClickHouse BYOC 账户中,您需要更新安全组设置以允许来自对等 VPC 的流量。请联系 ClickHouse 支持请求添加包括对等 VPC 的 CIDR 范围的入站规则。 + +--- +现在 ClickHouse 服务应该可以从对等 VPC 访问。 + +为了私密访问 ClickHouse,为用户的对等 VPC 提供了私有负载均衡器和端点。私有端点遵循公共端点格式,并带有 `-private` 后缀。例如: +- **公共端点**: `h5ju65kv87.mhp0y4dmph.us-west-2.aws.byoc.clickhouse.cloud` +- **私有端点**: `h5ju65kv87-private.mhp0y4dmph.us-west-2.aws.byoc.clickhouse.cloud` + +可选,在验证对等互联正常后,您可以请求移除 ClickHouse BYOC 的公共负载均衡器。 + +## 升级流程 {#upgrade-process} + +我们定期升级软件,包括 ClickHouse 数据库版本升级、ClickHouse Operator、EKS 和其他组件。 + +尽管我们旨在实现无缝升级(例如,滚动升级和重启),但某些升级(如 ClickHouse 版本变化和 EKS 节点升级)可能会影响服务。客户可以指定维护窗口(例如,每周二凌晨 1:00 PDT),确保此类升级仅在计划时间内进行。 + +:::note +维护窗口不适用于安全性和漏洞修复。这些作为周期外升级处理,并及时沟通以协调合适的时间,尽量减少运营影响。 +::: + +## CloudFormation IAM 角色 {#cloudformation-iam-roles} + +### 启动 IAM 角色 {#bootstrap-iam-role} + +启动 IAM 角色具有以下权限: + +- **EC2 和 VPC 操作**:设置 VPC 和 EKS 集群所需。 +- **S3 操作(例如,`s3:CreateBucket`)**:创建 ClickHouse BYOC 存储桶所需。 +- **`route53:*` 权限**:外部 DNS 配置 Route 53 中的记录所需。 +- **IAM 操作(例如,`iam:CreatePolicy`)**:控制器创建其他角色所需(详细信息请参阅下一节)。 +- **EKS 操作**:仅限于名称以 `clickhouse-cloud` 前缀开头的资源。 + +### 控制器创建的其他 IAM 角色 {#additional-iam-roles-created-by-the-controller} + +除了通过 CloudFormation 创建的 `ClickHouseManagementRole`,控制器还将创建若干其他角色。 + +这些角色由运行在客户 EKS 集群中的应用程序承担: +- **状态导出角色** + - ClickHouse 组件,向 ClickHouse Cloud 报告服务健康信息。 + - 需要写入 ClickHouse Cloud 拥有的 SQS 队列的权限。 +- **负载均衡器控制器** + - 标准 AWS 负载均衡器控制器。 + - EBS CSI 控制器用于管理 ClickHouse 服务的卷。 +- **外部 DNS** + - 将 DNS 配置传播到 Route 53。 +- **证书管理器** + - 为 BYOC 服务域名提供 TLS 证书。 +- **集群自动缩放器** + - 根据需要调整节点组大小。 + +**K8s-control-plane** 和 **k8s-worker** 角色旨在由 AWS EKS 服务承担。 + +最后,**`data-plane-mgmt`** 允许 ClickHouse Cloud 控制平面组件协调必需的自定义资源,如 `ClickHouseCluster` 和 Istio 虚拟服务/网关。 + +## 网络边界 {#network-boundaries} + +本节涵盖进出客户 BYOC VPC 的不同网络流量: + +- **入站**:进入客户 BYOC VPC 的流量。 +- **出站**:源自客户 BYOC VPC 并发送到外部目的地的流量。 +- **公共**:可从公共互联网访问的网络端点。 +- **私有**:仅通过私有连接(例如 VPC 对等、VPC 私有链接或 Tailscale)访问的网络端点。 + +**Istio ingress 部署在 AWS NLB 后面,以接收 ClickHouse 客户端流量。** + +*入站、公共(可以是私有)* + +Istio ingress 网关终止 TLS。由 CertManager 使用 Let's Encrypt 提供的证书存储为 EKS 集群内的秘密。Istio 和 ClickHouse 之间的流量由 AWS [加密](https://docs.aws.amazon.com/whitepapers/latest/logical-separation/encrypting-data-at-rest-and--in-transit.html#:~:text=All%20network%20traffic%20between%20AWS,supported%20Amazon%20EC2%20instance%20types),因为他们位于同一个 VPC 中。 + +默认情况下,入口是公开访问的,并带有 IP 允许列表过滤。客户可以配置 VPC 对等以使其成为私有,并禁用公共连接。我们强烈建议设置 [IP 过滤器](/cloud/security/setting-ip-filters) 以限制访问。 + +### 访问故障排除 {#troubleshooting-access} + +*入站、公共(可以是私有)* + +ClickHouse Cloud 工程师需要通过 Tailscale 进行故障排除访问。他们以适时证书为基础的身份验证来授权 BYOC 部署。 + +### 计费抓取器 {#billing-scraper} + +*出站、私有* + +计费抓取器从 ClickHouse 收集计费数据并将其发送到 ClickHouse Cloud 拥有的 S3 存储桶。 + +它作为 ClickHouse 服务器容器的侧车运行,定期抓取 CPU 和内存指标。同一区域内的请求通过 VPC 网关服务端点进行路由。 + +### 警报 {#alerts} + +*出站、公共* + +当客户的 ClickHouse 集群不健康时,AlertManager 被配置为向 ClickHouse Cloud 发送警报。 + +指标和日志存储在客户的 BYOC VPC 内。日志目前存储在本地 EBS 中。在未来的更新中,它们将被存储在 LogHouse 中,这是位于 BYOC VPC 内的 ClickHouse 服务。指标使用 Prometheus 和 Thanos 堆栈,本地存储在 BYOC VPC 中。 + +### 服务状态 {#service-state} + +*出站* + +状态导出器将 ClickHouse 服务状态信息发送到 ClickHouse Cloud 拥有的 SQS。 + +## 功能 {#features} + +### 支持的功能 {#supported-features} + +- **SharedMergeTree**:ClickHouse Cloud 和 BYOC 使用相同的二进制文件和配置。因此,ClickHouse 核心中的所有功能在 BYOC 中都得到支持,例如 SharedMergeTree。 +- **管理服务状态的控制台访问**: + - 支持启动、停止和终止等操作。 + - 查看服务和状态。 +- **备份和恢复。** +- **手动垂直和水平扩展。** +- **空闲。** +- **仓库**:计算-计算分离。 +- **通过 Tailscale 实现零信任网络。** +- **监控**: + - 云控制台包括内置健康仪表板以监控服务健康。 + - Prometheus 抓取,用于与 Prometheus、Grafana 和 Datadog 进行集中监控。有关设置说明,请参见 [Prometheus 文档](/integrations/prometheus)。 +- **VPC 对等。** +- **集成**:完整列表请见 [此页面](/integrations)。 +- **安全 S3。** +- **[AWS PrivateLink](https://aws.amazon.com/privatelink/)。** + +### 计划功能(当前不支持) {#planned-features-currently-unsupported} + +- [AWS KMS](https://aws.amazon.com/kms/) 也称为 CMEK(客户管理的加密密钥) +- ClickPipes 进行摄取 +- 自动缩放 +- MySQL 接口 + +## 常见问题 {#faq} + +### 计算 {#compute} + +#### 我可以在这个单一的 EKS 集群中创建多个服务吗? {#can-i-create-multiple-services-in-this-single-eks-cluster} + +可以。每个 AWS 账户和区域组合所需的基础设施只需要准备一次。 + +### 您支持哪个地区的 BYOC? {#which-regions-do-you-support-for-byoc} + +BYOC 支持与 ClickHouse Cloud 相同的一组 [区域](/cloud/reference/supported-regions#aws-regions)。 + +#### 会有一些资源开销吗?运行 ClickHouse 实例以外的服务需要什么资源? {#will-there-be-some-resource-overhead-what-are-the-resources-needed-to-run-services-other-than-clickhouse-instances} + +除了 ClickHouse 实例(ClickHouse 服务器和 ClickHouse Keeper)外,我们还运行 `clickhouse-operator`、`aws-cluster-autoscaler`、Istio 等服务以及我们的监控堆栈。 + +目前我们在专用节点组中有 3 个 m5.xlarge 节点(每个 AZ 一个)来运行这些工作负载。 + +### 网络和安全 {#network-and-security} + +#### 完成设置后,我们能否撤销在安装期间设置的权限? {#can-we-revoke-permissions-set-up-during-installation-after-setup-is-complete} + +目前不可能。 + +#### 您是否考虑了一些未来的安全控制措施,以便 ClickHouse 工程师可以访问客户基础设施进行故障排除? {#have-you-considered-some-future-security-controls-for-clickhouse-engineers-to-access-customer-infra-for-troubleshooting} + +是的。实施客户控制机制,让客户批准工程师对集群的访问已经在我们的路线图上。目前,工程师必须通过内部升级流程来获得及时访问集群的权限。这是由我们的安全团队记录和审核的。 + +#### 创建的 VPC IP 范围的大小是多少? {#what-is-the-size-of-the-vpc-ip-range-created} + +默认情况下,我们对 BYOC VPC 使用 `10.0.0.0/16`。我们建议至少保留 /22 进行潜在的未来扩展,但如果您希望限制大小,如果您可能仅限于 30 个服务器 pods,可以使用 /23。 + +#### 我可以决定维护频率吗? {#can-i-decide-maintenance-frequency} + +请联系支持以安排维护窗口。请期待至少每周更新计划。 + +## 可观察性 {#observability} + +### 内置监控工具 {#built-in-monitoring-tools} +ClickHouse BYOC 提供几种方法以适应不同的用例。 + +#### 可观察性仪表板 {#observability-dashboard} + +ClickHouse Cloud 包含一个先进的可观察性仪表板,显示内存使用情况、查询速率和 I/O 等指标。您可以在 ClickHouse Cloud 网页控制台的 **监控** 部分访问。 + +
+ +Observability dashboard + +
+ +#### 高级仪表板 {#advanced-dashboard} + +您可以使用来自系统表的指标,如 `system.metrics`、`system.events` 和 `system.asynchronous_metrics` 等,自定义仪表板以详细监控服务器性能和资源利用率。 + +
+ +Advanced dashboard + +
+ +#### 访问 BYOC Prometheus 堆栈 {#prometheus-access} +ClickHouse BYOC 在您的 Kubernetes 集群上部署了 Prometheus 堆栈。您可以从中访问和抓取指标,并将其与您自己的监控堆栈集成。 + +联系 ClickHouse 支持以启用私有负载均衡器并请求 URL。请注意,该 URL 仅通过私有网络访问,并不支持身份验证。 + +**示例 URL** +```bash +https://prometheus-internal...aws.clickhouse-byoc.com/query +``` + +#### Prometheus 集成 {#prometheus-integration} + +**弃用:** 请改用上述部分中的 Prometheus 堆栈集成。除了 ClickHouse 服务器指标外,它还提供更多指标,包括 K8S 指标和其他服务的指标。 + +ClickHouse Cloud 提供一个 Prometheus 端点,您可以用来抓取监控指标。这允许与 Grafana 和 Datadog 等工具集成以实现可视化。 + +**通过 HTTPS 端点 /metrics_all 的示例请求** + +```bash +curl --user : https://i6ro4qarho.mhp0y4dmph.us-west-2.aws.byoc.clickhouse.cloud:8443/metrics_all +``` + +**示例响应** + +```bash + +# HELP ClickHouse_CustomMetric_StorageSystemTablesS3DiskBytes The amount of bytes stored on disk `s3disk` in system database + +# TYPE ClickHouse_CustomMetric_StorageSystemTablesS3DiskBytes gauge +ClickHouse_CustomMetric_StorageSystemTablesS3DiskBytes{hostname="c-jet-ax-16-server-43d5baj-0"} 62660929 + +# HELP ClickHouse_CustomMetric_NumberOfBrokenDetachedParts The number of broken detached parts + +# TYPE ClickHouse_CustomMetric_NumberOfBrokenDetachedParts gauge +ClickHouse_CustomMetric_NumberOfBrokenDetachedParts{hostname="c-jet-ax-16-server-43d5baj-0"} 0 + +# HELP ClickHouse_CustomMetric_LostPartCount The age of the oldest mutation (in seconds) + +# TYPE ClickHouse_CustomMetric_LostPartCount gauge +ClickHouse_CustomMetric_LostPartCount{hostname="c-jet-ax-16-server-43d5baj-0"} 0 + +# HELP ClickHouse_CustomMetric_NumberOfWarnings The number of warnings issued by the server. It usually indicates about possible misconfiguration + +# TYPE ClickHouse_CustomMetric_NumberOfWarnings gauge +ClickHouse_CustomMetric_NumberOfWarnings{hostname="c-jet-ax-16-server-43d5baj-0"} 2 + +# HELP ClickHouseErrorMetric_FILE_DOESNT_EXIST FILE_DOESNT_EXIST + +# TYPE ClickHouseErrorMetric_FILE_DOESNT_EXIST counter +ClickHouseErrorMetric_FILE_DOESNT_EXIST{hostname="c-jet-ax-16-server-43d5baj-0",table="system.errors"} 1 + +# HELP ClickHouseErrorMetric_UNKNOWN_ACCESS_TYPE UNKNOWN_ACCESS_TYPE + +# TYPE ClickHouseErrorMetric_UNKNOWN_ACCESS_TYPE counter +ClickHouseErrorMetric_UNKNOWN_ACCESS_TYPE{hostname="c-jet-ax-16-server-43d5baj-0",table="system.errors"} 8 + +# HELP ClickHouse_CustomMetric_TotalNumberOfErrors The total number of errors on server since the last restart + +# TYPE ClickHouse_CustomMetric_TotalNumberOfErrors gauge +ClickHouse_CustomMetric_TotalNumberOfErrors{hostname="c-jet-ax-16-server-43d5baj-0"} 9 +``` + +**身份验证** + +可以使用 ClickHouse 用户名和密码对身份进行验证。我们建议创建具有最低权限的专用用户以抓取指标。至少需要在所有副本的 `system.custom_metrics` 表上具有 `READ` 权限。例如: + +```sql +GRANT REMOTE ON *.* TO scrapping_user; +GRANT SELECT ON system._custom_metrics_dictionary_custom_metrics_tables TO scrapping_user; +GRANT SELECT ON system._custom_metrics_dictionary_database_replicated_recovery_time TO scrapping_user; +GRANT SELECT ON system._custom_metrics_dictionary_failed_mutations TO scrapping_user; +GRANT SELECT ON system._custom_metrics_dictionary_group TO scrapping_user; +GRANT SELECT ON system._custom_metrics_dictionary_shared_catalog_recovery_time TO scrapping_user; +GRANT SELECT ON system._custom_metrics_dictionary_table_read_only_duration_seconds TO scrapping_user; +GRANT SELECT ON system._custom_metrics_view_error_metrics TO scrapping_user; +GRANT SELECT ON system._custom_metrics_view_histograms TO scrapping_user; +GRANT SELECT ON system._custom_metrics_view_metrics_and_events TO scrapping_user; +GRANT SELECT(description, metric, value) ON system.asynchronous_metrics TO scrapping_user; +GRANT SELECT ON system.custom_metrics TO scrapping_user; +GRANT SELECT(name, value) ON system.errors TO scrapping_user; +GRANT SELECT(description, event, value) ON system.events TO scrapping_user; +GRANT SELECT(description, labels, metric, value) ON system.histogram_metrics TO scrapping_user; +GRANT SELECT(description, metric, value) ON system.metrics TO scrapping_user; +``` + +**配置 Prometheus** + +下面是示例配置。`targets` 端点与访问 ClickHouse 服务使用的端点相同。 + +```bash +global: + scrape_interval: 15s + +scrape_configs: + - job_name: "prometheus" + static_configs: + - targets: ["localhost:9090"] + - job_name: "clickhouse" + static_configs: + - targets: ["..aws.byoc.clickhouse.cloud:8443"] + scheme: https + metrics_path: "/metrics_all" + basic_auth: + username: + password: + honor_labels: true +``` + +请参见 [这篇博客文章](https://clickhouse.com/blog/clickhouse-cloud-now-supports-prometheus-monitoring) 和 [ClickHouse 的 Prometheus 设置文档](/integrations/prometheus)。 + +### 正常运行时间 SLA {#uptime-sla} + +#### ClickHouse 为 BYOC 提供正常运行时间 SLA 吗? {#uptime-sla-for-byoc} + +不提供,因为数据平面托管在客户的云环境中,服务可用性取决于 ClickHouse 无法控制的资源。因此,ClickHouse 不为 BYOC 部署提供正式的正常运行时间 SLA。如果您有其他问题,请联系 support@clickhouse.com。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/04_infrastructure/byoc.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/04_infrastructure/byoc.md.hash new file mode 100644 index 00000000000..7a2ff32e922 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/04_infrastructure/byoc.md.hash @@ -0,0 +1 @@ +782d3c45a3d9bf3d diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/04_infrastructure/replica-aware-routing.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/04_infrastructure/replica-aware-routing.md new file mode 100644 index 00000000000..8b8d3720273 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/04_infrastructure/replica-aware-routing.md @@ -0,0 +1,49 @@ +--- +'title': '副本感知路由' +'slug': '/manage/replica-aware-routing' +'description': '如何使用副本感知路由来增加缓存重用' +'keywords': +- 'cloud' +- 'sticky endpoints' +- 'sticky' +- 'endpoints' +- 'sticky routing' +- 'routing' +- 'replica aware routing' +'doc_type': 'guide' +--- + +import PrivatePreviewBadge from '@theme/badges/PrivatePreviewBadge'; + + +# 副本感知路由 + + + +副本感知路由(也称为粘性会话、粘性路由或会话亲和性)利用了 [Envoy 代理的环哈希负载均衡](https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/upstream/load_balancing/load_balancers#ring-hash)。副本感知路由的主要目的是增加缓存重用的机会。它并不保证隔离。 + +在为服务启用副本感知路由时,我们允许在服务主机名上方使用通配符子域名。对于主机名为 `abcxyz123.us-west-2.aws.clickhouse.cloud` 的服务,您可以使用任何匹配 `*.sticky.abcxyz123.us-west-2.aws.clickhouse.cloud` 的主机名来访问该服务: + +|示例主机名| +|---| +|`aaa.sticky.abcxyz123.us-west-2.aws.clickhouse.cloud`| +|`000.sticky.abcxyz123.us-west-2.aws.clickhouse.cloud`| +|`clickhouse-is-the-best.sticky.abcxyz123.us-west-2.aws.clickhouse.cloud`| + +当 Envoy 接收到与此模式匹配的主机名时,它将基于主机名计算路由哈希,并根据计算出的哈希查找相应的 ClickHouse 服务器。假设服务没有进行任何操作变化(例如,服务器重启、扩展或缩减),Envoy 将始终选择相同的 ClickHouse 服务器进行连接。 + +请注意,原始主机名仍将使用 `LEAST_CONNECTION` 负载均衡,这是默认路由算法。 + +## 副本感知路由的限制 {#limitations-of-replica-aware-routing} + +### 副本感知路由并不保证隔离 {#replica-aware-routing-does-not-guarantee-isolation} + +对服务的任何干扰,例如服务器 pod 重启(由于版本升级、崩溃、垂直扩展等原因)、服务器扩展/缩减,将导致路由哈希环的中断。这将导致具有相同主机名的连接落在不同的服务器 pod 上。 + +### 副本感知路由无法在私有链接上开箱即用 {#replica-aware-routing-does-not-work-out-of-the-box-with-private-link} + +客户需要手动添加 DNS 记录,以使新主机名模式的名称解析正常工作。如果客户使用不当,这可能会导致服务器负载不平衡。 + +## 配置副本感知路由 {#configuring-replica-aware-routing} + +要启用副本感知路由,请联系 [我们的支持团队](https://clickhouse.com/support/program)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/04_infrastructure/replica-aware-routing.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/04_infrastructure/replica-aware-routing.md.hash new file mode 100644 index 00000000000..90c364b4fc2 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/04_infrastructure/replica-aware-routing.md.hash @@ -0,0 +1 @@ +9551a04cb628a267 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/04_infrastructure/shared-catalog.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/04_infrastructure/shared-catalog.md new file mode 100644 index 00000000000..57be3700fb2 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/04_infrastructure/shared-catalog.md @@ -0,0 +1,89 @@ +--- +'slug': '/cloud/reference/shared-catalog' +'sidebar_label': '共享目录' +'title': '共享目录和共享数据库引擎' +'keywords': +- 'SharedCatalog' +- 'SharedDatabaseEngine' +'description': '描述ClickHouse Cloud中的共享目录组件和共享数据库引擎' +'doc_type': 'reference' +--- + + +# 共享目录和共享数据库引擎 {#shared-catalog-and-shared-database-engine} + +**仅在 ClickHouse Cloud(和第一方合作伙伴云服务)中可用** + +共享目录是一个云原生组件,负责在 ClickHouse Cloud 中跨副本复制使用无状态引擎的数据库和表的元数据和 DDL 操作。它为这些对象提供一致和集中化的状态管理,确保在动态或部分离线环境中元数据的一致性。 + +共享目录**不复制表本身**,而是通过复制 DDL 查询和元数据,确保所有副本对数据库和表定义的视图一致。 + +它支持以下数据库引擎的复制: + +- Shared +- PostgreSQL +- MySQL +- DataLakeCatalog + +## 架构和元数据存储 {#architecture-and-metadata-storage} + +所有共享目录中的元数据和 DDL 查询历史都集中存储在 ZooKeeper 中。没有任何内容被保存在本地磁盘上。此架构确保: + +- 所有副本之间的状态一致 +- 计算节点的无状态性 +- 快速、可靠的副本引导 + +## 共享数据库引擎 {#shared-database-engine} + +**共享数据库引擎**与共享目录协同工作,以管理其表使用**无状态表引擎**(如 `SharedMergeTree`)的数据库。这些表引擎不会将持久状态写入磁盘,并且与动态计算环境兼容。 + +共享数据库引擎在 Replicated 数据库引擎的基础上构建并改善其行为,同时提供额外的保证和操作优势。 + +### 主要优势 {#key-benefits} + +- **原子性 CREATE TABLE ... AS SELECT** + 表创建和数据插入是原子执行的——整个操作要么完成,要么表根本不创建。 + +- **在数据库之间重命名表** + 使得在数据库之间原子移动表成为可能: +```sql +RENAME TABLE db1.table TO db2.table; +``` + +- **通过 UNDROP TABLE 自动恢复表** + 被删除的表会在默认的 8 小时内保留,并可以恢复: +```sql +UNDROP TABLE my_table; +``` + 保留窗口可通过服务器设置进行配置。 + +- **改善的计算-计算分离** + 不同于 Replicated 数据库引擎,它要求所有副本在线以处理 DROP 查询,共享目录执行集中元数据删除。这允许在有些副本离线时操作仍然成功。 + +- **自动元数据复制** + 共享目录确保数据库定义在启动时自动复制到所有服务器。操作员无需手动配置或同步新实例上的元数据。 + +- **集中、版本化的元数据状态** + 共享目录在 ZooKeeper 中存储唯一的真相源。当副本启动时,它获取最新状态并应用差异以达到一致性。在查询执行期间,系统可以等待其他副本达到至少所需版本的元数据以确保正确性。 + +## 在 ClickHouse Cloud 中的使用 {#usage-in-clickhouse-cloud} + +对于最终用户,使用共享目录和共享数据库引擎无需额外配置。数据库创建与往常一样: + +```sql +CREATE DATABASE my_database; +``` + +ClickHouse Cloud 自动将共享数据库引擎分配给数据库。在该数据库中使用无状态引擎创建的任何表将自动受益于共享目录的复制和协调能力。 + +## 摘要 {#summary} + +共享目录和共享数据库引擎提供: + +- 对无状态引擎的可靠和自动元数据复制 +- 无本地元数据持久性的无状态计算 +- 复杂 DDL 的原子操作 +- 改进的对弹性、短暂或部分离线计算环境的支持 +- ClickHouse Cloud 用户无缝使用 + +这些功能使得共享目录成为在 ClickHouse Cloud 中可扩展、云原生元数据管理的基础。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/04_infrastructure/shared-catalog.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/04_infrastructure/shared-catalog.md.hash new file mode 100644 index 00000000000..f035897b866 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/04_infrastructure/shared-catalog.md.hash @@ -0,0 +1 @@ +58ba761da11f4435 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/04_infrastructure/shared-merge-tree.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/04_infrastructure/shared-merge-tree.md new file mode 100644 index 00000000000..e99057d4f07 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/04_infrastructure/shared-merge-tree.md @@ -0,0 +1,120 @@ +--- +'slug': '/cloud/reference/shared-merge-tree' +'sidebar_label': 'SharedMergeTree' +'title': 'SharedMergeTree' +'keywords': +- 'SharedMergeTree' +'description': '描述 SharedMergeTree 表引擎' +'doc_type': 'reference' +--- + +import shared_merge_tree from '@site/static/images/cloud/reference/shared-merge-tree-1.png'; +import shared_merge_tree_2 from '@site/static/images/cloud/reference/shared-merge-tree-2.png'; +import Image from '@theme/IdealImage'; + + +# SharedMergeTree 表引擎 + +SharedMergeTree 表引擎系列是 ReplicatedMergeTree 引擎的云原生替代方案,旨在优化在共享存储(例如 Amazon S3、Google Cloud Storage、MinIO、Azure Blob Storage)上的工作。每种特定的 MergeTree 引擎类型都有一个 SharedMergeTree 的类比,例如,ReplacingSharedMergeTree 替代 ReplacingReplicatedMergeTree。 + +SharedMergeTree 表引擎系列支持 ClickHouse Cloud。对于最终用户来说,没有任何改动需要,您可以直接使用 SharedMergeTree 引擎系列来替代基于 ReplicatedMergeTree 的引擎。它提供以下额外好处: + +- 更高的插入吞吐量 +- 改进的后台合并吞吐量 +- 改进的变更吞吐量 +- 更快的扩展和缩放操作 +- 对查询提供更轻量级的强一致性 + +SharedMergeTree 带来的一个显著改进是,与 ReplicatedMergeTree 相比,它提供了更深入的计算和存储分离。您可以在下面看到 ReplicatedMergeTree 如何分离计算和存储: + +ReplicatedMergeTree Diagram + +如您所见,尽管存储在 ReplicatedMergeTree 中的数据位于对象存储中,元数据仍然保留在每一个 clickhouse-server 上。这意味着对于每个复制操作,元数据也需要在所有副本上复制。 + +ReplicatedMergeTree Diagram with Metadata + +与 ReplicatedMergeTree 不同,SharedMergeTree 不要求副本之间进行通信。相反,所有通信都通过共享存储和 clickhouse-keeper 进行。SharedMergeTree 实现了异步无领导复制,并使用 clickhouse-keeper 进行协调和元数据存储。这意味着随着服务的扩展和缩减,元数据不需要被复制。这导致更快的复制、变更、合并和扩展操作。SharedMergeTree 允许每个表有数百个副本,从而实现无需分片的动态扩展。ClickHouse Cloud 中使用分布式查询执行方法来利用更多计算资源执行查询。 + +## 内省 {#introspection} + +大多数用于 ReplicatedMergeTree 内省的系统表在 SharedMergeTree 中存在,除了 `system.replication_queue` 和 `system.replicated_fetches`,因为没有发生数据和元数据的复制。然而,SharedMergeTree 有这两个表的相应替代品。 + +**system.virtual_parts** + +该表作为 SharedMergeTree 的 `system.replication_queue` 替代品。它存储有关最新的当前分区集的信息,以及正在进行中的未来分区信息,如合并、变更和删除的分区。 + +**system.shared_merge_tree_fetches** + +该表是 SharedMergeTree 的 `system.replicated_fetches` 替代品。它包含有关当前正在进行的主键和校验和获取操作的信息。 + +## 启用 SharedMergeTree {#enabling-sharedmergetree} + +`SharedMergeTree` 默认启用。 + +对于支持 SharedMergeTree 表引擎的服务,您不需要手动启用任何东西。您可以像以前一样创建表,它将自动使用与您在 CREATE TABLE 查询中指定的引擎相对应的基于 SharedMergeTree 的表引擎。 + +```sql +CREATE TABLE my_table( + key UInt64, + value String +) +ENGINE = MergeTree +ORDER BY key +``` + +这将使用 SharedMergeTree 表引擎创建表 `my_table`。 + +您不需要指定 `ENGINE=MergeTree`,因为在 ClickHouse Cloud 中 `default_table_engine=MergeTree`。以下查询与上述查询相同。 + +```sql +CREATE TABLE my_table( + key UInt64, + value String +) +ORDER BY key +``` + +如果您使用 Replacing、Collapsing、Aggregating、Summing、VersionedCollapsing 或 Graphite MergeTree 表,它将自动转换为相应的基于 SharedMergeTree 的表引擎。 + +```sql +CREATE TABLE myFirstReplacingMT +( + `key` Int64, + `someCol` String, + `eventTime` DateTime +) +ENGINE = ReplacingMergeTree +ORDER BY key; +``` + +对于给定的表,您可以通过 `SHOW CREATE TABLE` 检查使用的表引擎与 `CREATE TABLE` 语句: +```sql +SHOW CREATE TABLE myFirstReplacingMT; +``` + +```sql +CREATE TABLE default.myFirstReplacingMT +( `key` Int64, `someCol` String, `eventTime` DateTime ) +ENGINE = SharedReplacingMergeTree('/clickhouse/tables/{uuid}/{shard}', '{replica}') +ORDER BY key +``` + +## 设置 {#settings} + +一些设置行为显著变化: + +- `insert_quorum` -- 所有对 SharedMergeTree 的插入都是法定插入(写入共享存储),因此在使用 SharedMergeTree 表引擎时不需要此设置。 +- `insert_quorum_parallel` -- 所有对 SharedMergeTree 的插入都是法定插入(写入共享存储),因此在使用 SharedMergeTree 表引擎时不需要此设置。 +- `select_sequential_consistency` -- 不需要法定插入,会对 `SELECT` 查询触发额外负载到 clickhouse-keeper。 + +## 一致性 {#consistency} + +SharedMergeTree 提供比 ReplicatedMergeTree 更好的轻量级一致性。当插入 SharedMergeTree 时,您不需要提供诸如 `insert_quorum` 或 `insert_quorum_parallel` 的设置。插入是法定插入,这意味着元数据将存储在 ClickHouse-Keeper 中,并且元数据复制到至少法定数量的 ClickHouse-keeper。您集群中的每个副本将异步从 ClickHouse-Keeper 获取新信息。 + +大多数情况下,您不应使用 `select_sequential_consistency` 或 `SYSTEM SYNC REPLICA LIGHTWEIGHT`。异步复制应覆盖大多数场景,并且延迟非常低。在极少数需要防止过时读取的情况下,请按照优先级遵循以下建议: + +1. 如果您在同一会话或同一节点中执行读取和写入查询,则不需要使用 `select_sequential_consistency`,因为您的副本将已经拥有最新的元数据。 + +2. 如果您对一个副本进行写入,而从另一个副本进行读取,则可以使用 `SYSTEM SYNC REPLICA LIGHTWEIGHT` 强制副本从 ClickHouse-Keeper 获取元数据。 + +3. 将 `select_sequential_consistency` 作为查询的一部分使用设置。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/04_infrastructure/shared-merge-tree.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/04_infrastructure/shared-merge-tree.md.hash new file mode 100644 index 00000000000..bc2ed8309d2 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/04_infrastructure/shared-merge-tree.md.hash @@ -0,0 +1 @@ +6dd53191a13fa8e2 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/04_infrastructure/warehouses.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/04_infrastructure/warehouses.md new file mode 100644 index 00000000000..eba4ec60f9d --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/04_infrastructure/warehouses.md @@ -0,0 +1,192 @@ +--- +'title': '仓库' +'slug': '/cloud/reference/warehouses' +'keywords': +- 'compute separation' +- 'cloud' +- 'architecture' +- 'compute-compute' +- 'warehouse' +- 'warehouses' +- 'hydra' +'description': 'ClickHouse Cloud 中的计算-计算分离' +'doc_type': 'reference' +--- + +import compute_1 from '@site/static/images/cloud/reference/compute-compute-1.png'; +import compute_2 from '@site/static/images/cloud/reference/compute-compute-2.png'; +import compute_3 from '@site/static/images/cloud/reference/compute-compute-3.png'; +import compute_4 from '@site/static/images/cloud/reference/compute-compute-4.png'; +import compute_5 from '@site/static/images/cloud/reference/compute-compute-5.png'; +import compute_7 from '@site/static/images/cloud/reference/compute-compute-7.png'; +import compute_8 from '@site/static/images/cloud/reference/compute-compute-8.png'; +import Image from '@theme/IdealImage'; + + +# 仓库 + +## 什么是计算-计算分离? {#what-is-compute-compute-separation} + +计算-计算分离适用于 Scale 和 Enterprise 级别。 + +每个 ClickHouse Cloud 服务包括: +- 需要一组两个或更多的 ClickHouse 节点(或副本),但子服务可以是单个副本。 +- 一个端点(或通过 ClickHouse Cloud UI 控制台创建的多个端点),这是您用于连接服务的服务 URL(例如,`https://dv2fzne24g.us-east-1.aws.clickhouse.cloud:8443`)。 +- 一个对象存储文件夹,服务在其中存储所有数据和部分元数据: + +:::note +子服务可以进行垂直扩展,而不像单个父服务。 +::: + +当前在 ClickHouse Cloud 中的服务 + +
+ +_Fig. 1 - 当前在 ClickHouse Cloud 中的服务_ + +计算-计算分离允许用户创建多个计算节点组,每个组具有自己的端点,它们使用相同的对象存储文件夹,因此,使用相同的表、视图等。 + +每个计算节点组都有自己的端点,因此您可以选择用于工作负载的副本集。您的某些工作负载可能只需使用一个小型副本,其他工作负载可能需要完全的高可用性(HA)和数百 GB 的内存。计算-计算分离还允许您将读操作与写操作分开,从而避免相互干扰: + +ClickHouse Cloud 中的计算分离 + +
+ +_Fig. 2 - ClickHouse Cloud 中的计算分离_ + +可以创建共享与现有服务相同数据的额外服务,或创建一个全新的设置,多个服务共享相同数据。 + +## 什么是仓库? {#what-is-a-warehouse} + +在 ClickHouse Cloud 中,_仓库_ 是一组共享相同数据的服务。 +每个仓库都有一个主要服务(这个服务是首先创建的)和一个或多个次要服务。例如,在下图中,您可以看到一个名为 "DWH Prod" 的仓库,其中有两个服务: + +- 主要服务 `DWH Prod` +- 次要服务 `DWH Prod Subservice` + +具有主要和次要服务的仓库示例 + +
+ +_Fig. 3 - 仓库示例_ + +仓库中的所有服务共享相同的: + +- 区域(例如,us-east1) +- 云服务提供商(AWS、GCP 或 Azure) +- ClickHouse 数据库版本 + +您可以根据它们所属的仓库对服务进行排序。 + +## 访问控制 {#access-controls} + +### 数据库凭据 {#database-credentials} + +因为所有仓库中的服务共享相同的表集,所以它们也共享对其他服务的访问控制。这意味着在服务 1 中创建的所有数据库用户也能够以相同的权限(表、视图等的授予)使用服务 2,反之亦然。用户将通过每个服务使用不同的端点,但使用相同的用户名和密码。换句话说,_用户在使用相同存储的服务之间是共享的:_ + +用户访问共享相同数据的服务 + +
+ +_Fig. 4 - 用户 Alice 在服务 1 中创建,但她可以使用相同的凭据访问所有共享相同数据的服务_ + +### 网络访问控制 {#network-access-control} + +限制特定服务被其他应用程序或临时用户使用通常是很有用的。这可以通过使用网络限制来完成,类似于目前为常规服务配置的方式(在 ClickHouse Cloud 控制台中的特定服务的服务选项卡中导航到**设置**)。 + +您可以对每个服务单独应用 IP 过滤设置,这意味着您可以控制哪个应用程序可以访问哪个服务。这允许您限制用户使用特定服务: + +网络访问控制设置 + +
+ +_Fig. 5 - Alice 被网络设置限制访问服务 2_ + +### 只读与读写 {#read-vs-read-write} + +有时限制特定服务的写访问并仅允许仓库中一部分服务进行写入是很有用的。这可以在创建第二个和第 N 个服务时完成(第一个服务应始终是读写的): + +仓库中的读写服务和只读服务 + +
+ +_Fig. 6 - 仓库中的读写服务和只读服务_ + +:::note +1. 当前只读服务允许用户管理操作(创建、删除等)。这一行为未来可能会改变。 +2. 目前,可刷新的物化视图在仓库中的所有服务上执行,包括只读服务。然而,这一行为将在未来改变,它们将仅在读写服务上执行。 +::: + +## 扩展 {#scaling} + +仓库中的每个服务可以根据您的工作负载进行调整,包括: +- 节点数量(副本)。主要服务(仓库中首先创建的服务)应具有 2 个或更多节点。每个次要服务可以有 1 个或更多节点。 +- 节点(副本)的大小 +- 服务是否应自动扩展 +- 服务在不活动时是否应闲置(不能应用于组中的第一个服务 - 请查看**限制**部分) + +## 行为变化 {#changes-in-behavior} +一旦某个服务启用了计算-计算(至少创建了一个次要服务),则调用 `clusterAllReplicas()` 函数时使用的 `default` 集群名称将仅利用从其调用的服务中的副本。这意味着,如果有两个连接到同一数据集的服务,并且从服务 1 调用 `clusterAllReplicas(default, system, processes)`,则仅会显示在服务 1 上运行的进程。如果需要,您仍然可以调用 `clusterAllReplicas('all_groups.default', system, processes)` 例如来访问所有副本。 + +## 限制 {#limitations} + +1. **主要服务应始终处于运行状态,并且不应闲置(此限制将在 GA 后的一段时间内被移除)。** 在私有预览和 GA 后的一段时间内,主要服务(通常是您希望通过添加其他服务来扩展的现有服务)将始终保持运行,并且将禁用闲置设置。如果存在至少一个次要服务,您将无法停止或闲置主要服务。一旦所有次要服务被移除,您可以再次停止或闲置原始服务。 + +2. **有时工作负载无法隔离。** 尽管目标是为您提供选项,以将数据库工作负载相互隔离,但可能会出现某些边界情况,其中一个服务中的工作负载会影响共享相同数据的另一个服务。这些情况比较少见,通常与 OLTP 类型的工作负载有关。 + +3. **所有读写服务都在进行后台合并操作。** 当将数据插入 ClickHouse 时,数据库首先将数据插入某些暂存分区,然后在后台执行合并。这些合并可能会消耗内存和 CPU 资源。当两个读写服务共享相同的存储时,它们都在执行后台操作。这意味着可能会出现这样的情况:服务 1 中的 `INSERT` 查询,但合并操作由服务 2 完成。请注意,只读服务不执行后台合并,因此它们不会在此操作上消耗资源。 + +4. **所有读写服务都在执行 S3Queue 表引擎插入操作。** 当在 RW 服务上创建 S3Queue 表时,仓库中的所有其他 RW 服务可能会从 S3 读取数据并将数据写入数据库。 + +5. **在一个读写服务中的插入可能会阻止另一个读写服务闲置(如果启用了闲置)。** 结果,第二个服务为第一个服务执行后台合并操作。这些后台操作可能会阻止第二个服务在闲置时进入睡眠状态。一旦后台操作完成,服务将闲置。只读服务不受影响,将毫不延迟地闲置。 + +6. **CREATE/RENAME/DROP DATABASE 查询默认可能会被闲置/停止的服务阻止。** 这些查询可能会挂起。要绕过此限制,您可以在会话或查询级别运行数据库管理查询时设置 `settings distributed_ddl_task_timeout=0`。例如: + +```sql +CREATE DATABASE db_test_ddl_single_query_setting +SETTINGS distributed_ddl_task_timeout=0 +``` + +6. **在非常少见的情况下,长时间闲置或停止的次要服务(天数)而未被唤醒/启动可能会导致同一仓库中的其他服务性能下降。** 这个问题将在不久的将来解决,并与后台运行的突变有关。如果您认为您遇到此问题,请联系 ClickHouse [支持](https://clickhouse.com/support/program)。 + +7. **目前每个仓库有 5 个服务的软限制。** 如果您需要在单个仓库中使用超过 5 个服务,请联系支持团队。 + +## 定价 {#pricing} + +仓库中所有服务的计算价格都是相同的(主要和次要)。存储仅收取一次费用 - 包括在第一个(原始)服务中。 + +请参考 [定价](https://clickhouse.com/pricing) 页面上的定价计算器,它将帮助您根据工作负载大小和级别选择来估算成本。 + +## 备份 {#backups} + +- 由于单个仓库中的所有服务共享相同的存储,因此备份仅在主要(初始)服务上进行。通过这种方式,仓库中所有服务的数据都得到了备份。 +- 如果您从仓库的主要服务恢复备份,它将恢复到一个完全新的服务,与现有仓库没有连接。然后您可以在恢复完成后立即向新服务添加更多服务。 + +## 使用仓库 {#using-warehouses} + +### 创建仓库 {#creating-a-warehouse} + +要创建一个仓库,需要创建一个与现有服务共享数据的第二个服务。可以通过单击任何现有服务上的加号来完成: + +在仓库中创建新服务 + +
+ +_Fig. 7 - 单击加号以在仓库中创建新服务_ + +在服务创建屏幕中,原始服务将作为新服务的数据源在下拉列表中被选中。一旦创建,这两个服务将形成一个仓库。 + +### 重命名仓库 {#renaming-a-warehouse} + +有两种方式可以重命名仓库: + +- 您可以在服务页面的右上角选择“按仓库排序”,然后点击仓库名称旁边的铅笔图标 +- 您可以单击任何服务上的仓库名称,并在此处重命名仓库 + +### 删除仓库 {#deleting-a-warehouse} + +删除仓库意味着删除所有计算服务及其数据(表、视图、用户等)。此操作无法撤销。 +您只能通过删除第一个创建的服务来删除仓库。为此: + +1. 删除您首次创建的服务之外创建的所有服务; +2. 删除第一个服务(警告:在此步骤中,将删除所有仓库的数据)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/04_infrastructure/warehouses.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/04_infrastructure/warehouses.md.hash new file mode 100644 index 00000000000..4c03f6aede1 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/04_infrastructure/warehouses.md.hash @@ -0,0 +1 @@ +109e0133c89fd61d diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/05_admin_features/_category_.json b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/05_admin_features/_category_.json new file mode 100644 index 00000000000..72016fcfba5 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/05_admin_features/_category_.json @@ -0,0 +1,5 @@ +{ + "label": "Admin", + "collapsible": true, + "collapsed": true, +} \ No newline at end of file diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/05_admin_features/api/api-overview.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/05_admin_features/api/api-overview.md new file mode 100644 index 00000000000..c7140ee94de --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/05_admin_features/api/api-overview.md @@ -0,0 +1,56 @@ +--- +'sidebar_label': '概述' +'sidebar_position': 1 +'title': 'ClickHouse Cloud API' +'slug': '/cloud/manage/api/api-overview' +'description': '了解 ClickHouse Cloud API' +'doc_type': 'reference' +--- + + +# ClickHouse Cloud API + +## 概述 {#overview} + +ClickHouse Cloud API 是一个 REST API,旨在帮助开发人员轻松管理 ClickHouse Cloud 上的组织和服务。通过我们的 Cloud API,您可以创建和管理服务,配置 API 密钥,增减组织成员等。 + +[了解如何创建您的第一个 API 密钥并开始使用 ClickHouse Cloud API。](/cloud/manage/openapi) + +## Swagger (OpenAPI) 端点和 UI {#swagger-openapi-endpoint-and-ui} + +ClickHouse Cloud API 基于开源的 [OpenAPI 规范](https://www.openapis.org/) 构建,以实现可预测的客户端消费。如果您需要以编程方式获取 ClickHouse Cloud API 文档,我们提供基于 JSON 的 Swagger 端点,网址为 https://api.clickhouse.cloud/v1。您还可以通过 [Swagger UI](https://clickhouse.com/docs/cloud/manage/api/swagger) 找到 API 文档。 + +:::note +如果您的组织已迁移至 [新定价计划](https://clickhouse.com/pricing?plan=scale&provider=aws®ion=us-east-1&hours=8&storageCompressed=false),并且您使用 OpenAPI,您将需要在服务创建的 `POST` 请求中删除 `tier` 字段。 + +`tier` 字段已从服务对象中移除,因为我们不再有服务层次。 +这将影响 `POST`、`GET` 和 `PATCH` 服务请求返回的对象。因此,任何使用这些 API 的代码可能需要调整以处理这些更改。 +::: + +## 限速 {#rate-limits} + +每个组织的开发人员限制为 100 个 API 密钥。每个 API 密钥在 10 秒窗口内的请求限制为 10 次。如果您希望增加组织的 API 密钥数量或每 10 秒窗口内的请求数量,请联系 support@clickhouse.com + +## Terraform 提供程序 {#terraform-provider} + +官方 ClickHouse Terraform Provider 允许您使用 [基础设施即代码](https://www.redhat.com/en/topics/automation/what-is-infrastructure-as-code-iac) 创建可预测的、版本控制的配置,从而使部署过程更加不易出错。 + +您可以在 [Terraform 注册表](https://registry.terraform.io/providers/ClickHouse/clickhouse/latest/docs) 中查看 Terraform 提供程序文档。 + +如果您想为 ClickHouse Terraform Provider 贡献代码,可以在 [GitHub 仓库](https://github.com/ClickHouse/terraform-provider-clickhouse) 中查看源代码。 + +:::note +如果您的组织已迁移至 [新定价计划](https://clickhouse.com/pricing?plan=scale&provider=aws®ion=us-east-1&hours=8&storageCompressed=false),您将需要使用我们的 [ClickHouse Terraform provider](https://registry.terraform.io/providers/ClickHouse/clickhouse/latest/docs) 版本 2.0.0 或以上。此升级是为了处理 `tier` 属性的更改,因为在定价迁移后,不再接受 `tier` 字段,且应移除对此字段的引用。 + +您现在还可以将 `num_replicas` 字段指定为服务资源的属性。 +::: + +## Terraform 和 OpenAPI 新定价:副本设置说明 {#terraform-and-openapi-new-pricing---replica-settings-explained} + +每个服务的副本数在 Scale 和 Enterprise 层次默认为 3,而在 Basic 层次默认为 1。 +对于 Scale 和 Enterprise 层次,可以通过在服务创建请求中传递 `numReplicas` 字段来进行调整。 +`numReplicas` 字段的值必须在仓库中的第一个服务中介于 2 到 20 之间。在现有仓库中创建的服务的副本数可以低至 1。 + +## 支持 {#support} + +我们建议您首先访问 [我们的 Slack 频道](https://clickhouse.com/slack) 以获得快速支持。如果您希望获得更多帮助或有关我们 API 及其功能的更多信息,请访问 ClickHouse 支持 https://console.clickhouse.cloud/support diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/05_admin_features/api/api-overview.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/05_admin_features/api/api-overview.md.hash new file mode 100644 index 00000000000..23e0fa565ba --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/05_admin_features/api/api-overview.md.hash @@ -0,0 +1 @@ +67e22cb71b2fa877 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/05_admin_features/api/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/05_admin_features/api/index.md new file mode 100644 index 00000000000..1a6275621f4 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/05_admin_features/api/index.md @@ -0,0 +1,14 @@ +--- +'title': 'Cloud API' +'slug': '/cloud/manage/cloud-api' +'description': 'Cloud API 部分的登录页面' +'doc_type': 'landing-page' +--- + +这个部分包含Cloud API的参考文档,包含以下页面: + +| 页面 | 描述 | +|--------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------| +| [概述](/cloud/manage/api/api-overview) | 提供速率限制、Terraform Provider、Swagger (OpenAPI) 端点和用户界面的概述,以及可用的支持。 | +| [管理 API 密钥](/cloud/manage/openapi) | 了解更多关于Cloud的API,利用OpenAPI允许您以编程方式管理您的帐户和服务的各个方面。 | +| [API 参考](https://clickhouse.com/docs/cloud/manage/api/swagger) | OpenAPI (swagger) 参考页面。 | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/05_admin_features/api/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/05_admin_features/api/index.md.hash new file mode 100644 index 00000000000..7829d87fec9 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/05_admin_features/api/index.md.hash @@ -0,0 +1 @@ +359feb2f2a970dda diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/05_admin_features/api/openapi.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/05_admin_features/api/openapi.md new file mode 100644 index 00000000000..c9cb11f02b5 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/05_admin_features/api/openapi.md @@ -0,0 +1,65 @@ +--- +'sidebar_label': '管理 API 密钥' +'slug': '/cloud/manage/openapi' +'title': '管理 API 密钥' +'description': 'ClickHouse Cloud 提供了一个利用 OpenAPI 的 API,使您能够以编程方式管理您的帐户和服务的各个方面。' +'doc_type': 'guide' +--- + +import image_01 from '@site/static/images/cloud/manage/openapi1.png'; +import image_02 from '@site/static/images/cloud/manage/openapi2.png'; +import image_03 from '@site/static/images/cloud/manage/openapi3.png'; +import image_04 from '@site/static/images/cloud/manage/openapi4.png'; +import image_05 from '@site/static/images/cloud/manage/openapi5.png'; +import Image from '@theme/IdealImage'; + + +# 管理 API 密钥 + +ClickHouse Cloud 提供了一个利用 OpenAPI 的 API,允许您以编程方式管理您的帐户和服务的各个方面。 + +:::note +本文档涵盖 ClickHouse Cloud API。有关数据库 API 端点,请参见 [Cloud Endpoints API](/cloud/get-started/query-endpoints)。 +::: + +1. 您可以使用左侧菜单中的 **API Keys** 标签来创建和管理您的 API 密钥。 + + API Keys tab + +2. **API Keys** 页面最初会显示创建您的第一个 API 密钥的提示,如下所示。在创建第一个密钥后,您可以使用出现在右上角的 `New API Key` 按钮创建新密钥。 + + API Keys page + +3. 要创建 API 密钥,请指定密钥名称、密钥权限和过期时间,然后点击 `Generate API Key`。 +
+:::note +权限与 ClickHouse Cloud 的 [预定义角色](/cloud/security/cloud-access-management/overview#console-users-and-roles) 对齐。开发者角色对分配的服务具有只读权限,而管理员角色则具有完全的读写权限。 +::: + + Create API key form + +4. 下一屏幕将显示您的密钥 ID 和密钥密钥。复制这些值并将它们放在一个安全的地方,例如保险库。离开此屏幕后,值将不再显示。 + + API key details + +5. ClickHouse Cloud API 使用 [HTTP Basic Authentication](https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication) 来验证您的 API 密钥的有效性。以下是如何使用 API 密钥通过 `curl` 向 ClickHouse Cloud API 发送请求的示例: + +```bash +$ KEY_ID=mykeyid +$ KEY_SECRET=mykeysecret + +$ curl --user $KEY_ID:$KEY_SECRET https://api.clickhouse.cloud/v1/organizations +``` + +6. 返回 **API Keys** 页面,您将看到密钥名称、密钥 ID 的最后四个字符、权限、状态、过期日期和创建者。您可以从此屏幕编辑密钥名称、权限和过期时间。密钥也可以从此屏幕禁用或删除。 +
+:::note +删除 API 密钥是一个永久性操作。任何使用该密钥的服务将立即失去对 ClickHouse Cloud 的访问权限。 +::: + + API Keys management page + +## 端点 {#endpoints} + +有关端点的详细信息,请参阅 [API reference](https://clickhouse.com/docs/cloud/manage/api/swagger)。 +使用您的 API Key 和 API Secret,以及基础 URL `https://api.clickhouse.cloud/v1`。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/05_admin_features/api/openapi.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/05_admin_features/api/openapi.md.hash new file mode 100644 index 00000000000..68a7570a70b --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/05_admin_features/api/openapi.md.hash @@ -0,0 +1 @@ +acad857167b2edf0 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/postman.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/05_admin_features/api/postman.md similarity index 52% rename from i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/postman.md rename to i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/05_admin_features/api/postman.md index 0e00dd54ea1..59fa34b7c38 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/postman.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/05_admin_features/api/postman.md @@ -1,8 +1,9 @@ --- 'slug': '/cloud/manage/postman' -'sidebar_label': '使用 Postman 进行程序化 API 访问' -'title': '使用 Postman 进行程序化 API 访问' +'sidebar_label': '使用 Postman 进行编程 API 访问' +'title': '使用 Postman 进行编程 API 访问' 'description': '本指南将帮助您使用 Postman 测试 ClickHouse Cloud API' +'doc_type': 'guide' --- import Image from '@theme/IdealImage'; @@ -24,21 +25,24 @@ import postman15 from '@site/static/images/cloud/manage/postman/postman15.png'; import postman16 from '@site/static/images/cloud/manage/postman/postman16.png'; import postman17 from '@site/static/images/cloud/manage/postman/postman17.png'; -这个指南将帮助您使用 [Postman](https://www.postman.com/product/what-is-postman/) 测试 ClickHouse Cloud API。 -Postman 应用程序可以在网络浏览器中使用,也可以下载到桌面。 +本指南将帮助您使用 [Postman](https://www.postman.com/product/what-is-postman/) 测试 ClickHouse Cloud API。 +Postman 应用程序可在 Web 浏览器中使用,也可以下载到桌面。 -### 创建一个帐户 {#create-an-account} -* 免费帐户可以在 [https://www.postman.com](https://www.postman.com) 获取。 +### 创建账户 {#create-an-account} + +* 免费账户可在 [https://www.postman.com](https://www.postman.com) 上注册。 Postman site -### 创建一个工作区 {#create-a-workspace} -* 命名您的工作区并设置可见性级别。 +### 创建工作区 {#create-a-workspace} + +* 为您的工作区命名并设置可见性级别。 Create workspace -### 创建一个集合 {#create-a-collection} -* 在左上角菜单的 "Explore" 下点击 "Import": +### 创建集合 {#create-a-collection} + +* 在左上角菜单的“探索”下点击“导入”: Explore > Import @@ -46,72 +50,79 @@ Postman 应用程序可以在网络浏览器中使用,也可以下载到桌面 API URL entry -* 输入 API 地址:“https://api.clickhouse.cloud/v1”并按 'Enter': +* 输入 API 地址: "https://api.clickhouse.cloud/v1" 并按 'Enter' : Import -* 点击 "Import" 按钮选择 "Postman Collection": +* 点击“导入”按钮选择“Postman 集合”: Collection > Import ### 与 ClickHouse Cloud API 规范交互 {#interface-with-the-clickhouse-cloud-api-spec} -* 现在将在 "Collections"(左导航)中出现 "ClickHouse Cloud 的 API 规范"。 +* “ClickHouse Cloud 的 API 规范”现在将在“集合”(左侧导航)中显示。 Import your API -* 点击 "ClickHouse Cloud 的 API 规范"。在中间面板中选择 'Authorization' 选项卡: +* 点击“ClickHouse Cloud 的 API 规范。” 在中间窗格中选择“授权”选项卡: Import complete ### 设置授权 {#set-authorization} -* 切换下拉菜单选择 "Basic Auth": +* 切换下拉菜单选择“基本认证”: Basic auth -* 输入您在设置 ClickHouse Cloud API 密钥时收到的用户名和密码: +* 输入在设置 ClickHouse Cloud API 密钥时收到的用户名和密码: credentials ### 启用变量 {#enable-variables} -* [变量](https://learning.postman.com/docs/sending-requests/variables/) 允许在 Postman 中存储和重用值,从而简化 API 测试过程。 + +* [变量](https://learning.postman.com/docs/sending-requests/variables/) 使您能够在 Postman 中存储和重用值,从而使 API 测试更轻松。 + #### 设置组织 ID 和服务 ID {#set-the-organization-id-and-service-id} -* 在 "Collection" 中,点击中间面板的 "Variable" 选项卡(基本 URL 将由之前的 API 导入进行设置): -* 在 `baseURL` 下面点击打开的字段 "Add new value",并替换为您的组织 ID 和服务 ID: + +* 在“集合”中,点击中间窗格的“变量”选项卡(Base URL 将由早期的 API 导入设置): +* 在 `baseURL` 下面,点击开放字段“添加新值”,并替换为您的组织 ID 和服务 ID: Organization ID and Service ID ## 测试 ClickHouse Cloud API 功能 {#test-the-clickhouse-cloud-api-functionalities} -### 测试 "获取可用组织的列表" {#test-get-list-of-available-organizations} -* 在 "OpenAPI spec for ClickHouse Cloud" 下,展开文件夹 > V1 > organizations -* 点击 "GET list of available organizations" 并按右侧的蓝色 "Send" 按钮: + +### 测试 “获取可用组织列表” {#test-get-list-of-available-organizations} + +* 在“ClickHouse Cloud 的 OpenAPI 规范”下,展开文件夹 > V1 > organizations +* 点击“获取可用组织列表”并按右侧的蓝色“发送”按钮: Test retrieval of organizations -* 返回的结果应提供您的组织详细信息,并且 "status" 应为 200。(如果您收到 "status" 400 且没有组织信息,则表示您的配置不正确)。 +* 返回的结果应提供您的组织详细信息,并且“status”: 200。(如果您收到“status” 400,且没有组织信息,则说明您的配置不正确)。 Status -### 测试 "获取组织详细信息" {#test-get-organizational-details} -* 在 `organizationid` 文件夹下,导航至 "GET organizational details": -* 在中间框架菜单的 Params 下,需要一个 `organizationid`。 +### 测试 “获取组织详情” {#test-get-organizational-details} + +* 在 `organizationid` 文件夹下,导航到“获取组织详情”: +* 在中间框架菜单的 Params 下需要一个 `organizationid`。 Test retrieval of organization details -* 将该值编辑为大括号中的 `orgid` `{{orgid}}`(由于您之前设置了此值,将会出现一个菜单,该菜单将显示该值): +* 用大括号 `{{orgid}}` 编辑此值(设置此值后,菜单将显示该值): Submit test -* 按下 "Save" 按钮后,在屏幕右上角按蓝色 "Send" 按钮。 +* 按“保存”按钮后,按右上角的蓝色“发送”按钮。 Return value -* 返回的结果应提供您的组织详细信息,并且 "status" 应为 200。(如果您收到 "status" 400 且没有组织信息,则表示您的配置不正确)。 +* 返回的结果应提供您的组织详细信息,并且“status”: 200。(如果您收到“status” 400,且没有组织信息,则说明您的配置不正确)。 + +### 测试 “获取服务详情” {#test-get-service-details} -### 测试 "获取服务详细信息" {#test-get-service-details} -* 点击 "GET service details" -* 将 `organizationid` 和 `serviceid` 的值编辑为 `{{orgid}}` 和 `{{serviceid}}`,分别。 -* 按 "Save",然后按右侧的蓝色 "Send" 按钮。 +* 点击“获取服务详情” +* 用 `{{orgid}}` 和 `{{serviceid}}` 分别编辑 `organizationid` 和 `serviceid` 的值。 +* 按“保存”,然后在右侧按蓝色“发送”按钮。 List of services -* 返回的结果应提供您的服务及其详细信息的列表,并且 "status" 应为 200。(如果您收到 "status" 400 且没有服务信息,则表示您的配置不正确)。 +* 返回的结果应提供您的服务及其详细信息的列表,并且“status”: 200。(如果您收到“status” 400,且没有服务信息,则说明您的配置不正确)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/05_admin_features/api/postman.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/05_admin_features/api/postman.md.hash new file mode 100644 index 00000000000..55d92814707 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/05_admin_features/api/postman.md.hash @@ -0,0 +1 @@ +6e35452b6089b777 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/05_admin_features/upgrades.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/05_admin_features/upgrades.md new file mode 100644 index 00000000000..d5159e35562 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/05_admin_features/upgrades.md @@ -0,0 +1,129 @@ +--- +'sidebar_label': '升级' +'slug': '/manage/updates' +'title': '升级' +'description': '使用 ClickHouse Cloud,您无需担心修补和升级。我们定期推出包括修复、新功能和性能改进的升级。' +'doc_type': 'guide' +--- + +import Image from '@theme/IdealImage'; +import EnterprisePlanFeatureBadge from '@theme/badges/EnterprisePlanFeatureBadge' +import ScalePlanFeatureBadge from '@theme/badges/ScalePlanFeatureBadge' +import fast_release from '@site/static/images/cloud/manage/fast_release.png'; +import enroll_fast_release from '@site/static/images/cloud/manage/enroll_fast_release.png'; +import scheduled_upgrades from '@site/static/images/cloud/manage/scheduled_upgrades.png'; +import scheduled_upgrade_window from '@site/static/images/cloud/manage/scheduled_upgrade_window.png'; + + +# 升级 + +使用 ClickHouse Cloud,您无需担心打补丁和升级。我们定期推出升级,包括修复、新功能和性能改进。有关 ClickHouse 中新内容的完整列表,请参阅我们的 [Cloud changelog](/whats-new/cloud)。 + +:::note +我们引入了一种新的升级机制,一个我们称之为“先行后断”(或 MBB)的概念。在这种新方法中,我们在升级操作过程中添加更新的副本,然后再删除旧的副本。这使得升级更加无缝,对运行中的工作负载的干扰更小。 + +作为此更改的一部分,历史系统表数据将在升级事件中保留最长可达 30 天。此外,AWS 或 GCP 上服务的任何系统表数据如果早于 2024 年 12 月 19 日,Azure 上服务的如果早于 2025 年 1 月 14 日,将不作为迁移到新组织层的一部分而保留。 +::: + +## 版本兼容性 {#version-compatibility} + +当您创建服务时,[`compatibility`](/operations/settings/settings#compatibility) 设置将被设置为在您的服务首次配置时 ClickHouse Cloud 提供的最新版本。 + +`compatibility` 设置允许您使用先前版本的设置的默认值。当您的服务升级到新版本时,指定的 `compatibility` 设置的版本不会改变。这意味着在您首次创建服务时存在的设置的默认值不会更改(除非您已经覆盖了这些默认值,在这种情况下,它们将在升级后继续保持)。 + +您无法管理服务级默认的 `compatibility` 设置。如果您希望更改服务默认的 `compatibility` 设置的版本,必须 [联系支持](https://clickhouse.com/support/program)。但是,您可以使用标准 ClickHouse 设置机制(例如在会话中使用 `SET compatibility = '22.3'` 或在查询中使用 `SETTINGS compatibility = '22.3'`)在用户、角色、配置文件、查询或会话级别覆盖 `compatibility` 设置。 + +## 维护模式 {#maintenance-mode} + +有时,我们可能需要更新您的服务,这可能需要我们禁用某些功能,例如缩放或闲置。在少数情况下,我们可能需要对出现问题的服务采取措施,并将其恢复到健康状态。在维护期间,您将在服务页面上看到一条显示为 _“正在维护”_ 的横幅。在此期间,您仍然可以使用该服务进行查询。 + +在服务维护期间,您不会被收取费用。 _维护模式_ 是一种少见的情况,不应与常规服务升级混淆。 + +## 发布频道(升级计划) {#release-channels-upgrade-schedule} + +用户可以通过订阅特定发布频道来指定其 ClickHouse Cloud 服务的升级计划。共有三个发布频道,用户可以使用 **计划升级** 特性配置升级的星期几和时间。 + +这三个发布频道是: +- [**快速发布频道**](#fast-release-channel-early-upgrades),用于提前访问升级。 +- [**常规发布频道**](#regular-release-channel),为默认频道,在此频道上的升级在快速发布频道升级两周后开始。如果您的 Scale 和 Enterprise 级服务没有设置发布频道,则默认情况下在常规发布频道上。 +- [**缓慢发布频道**](#slow-release-channel-deferred-upgrades),用于延迟发布。此频道上的升级在常规发布频道升级两周后进行。 + +:::note +基本级服务将自动加入快速发布频道。 +::: + +### 快速发布频道(提前升级) {#fast-release-channel-early-upgrades} + + + +除了常规的升级计划外,如果您希望您的服务在常规发布计划之前接收更新,我们提供 **快速发布** 频道。 + +具体来说,服务将: + +- 接收最新的 ClickHouse 版本 +- 随着新版本的测试,更频繁地进行升级 + +您可以在 Cloud 控制台中修改服务的发布计划,如下所示: + +
+ 选择计划 +
+
+ +
+ 选择计划 +
+
+ +此 **快速发布** 频道适合在非关键环境中测试新功能。 **不推荐用于具有严格正常运行时间和可靠性要求的生产工作负载。** + +### 常规发布频道 {#regular-release-channel} + +对于所有没有配置发布频道或升级计划的 Scale 和 Enterprise 级服务,将作为常规频道发布的一部分进行升级。这推荐用于生产环境。 + +常规发布频道的升级通常在 **快速发布频道** 后的两周内进行。 + +:::note +基本级服务将在快速发布频道之后不久升级。 +::: + +### 缓慢发布频道(延迟升级) {#slow-release-channel-deferred-upgrades} + + + +如果您希望您的服务在常规发布计划后接收升级,我们提供 **缓慢发布** 频道。 + +具体来说,服务将: + +- 在快速和常规发布频道的推出完成后升级 +- 在常规发布后约 2 周接收 ClickHouse 发布 +- 适用于希望在生产升级之前有额外时间在非生产环境中测试 ClickHouse 发布的客户。非生产环境可以在快速或常规发布频道中进行测试和验证。 + +:::note +您可以随时更改发布频道。但是在某些情况下,变更仅适用于未来的发布。 +- 移动到更快的频道将立即升级您的服务。例如,从缓慢到常规,从常规到快速 +- 移动到更慢的频道不会降级您的服务,并保持在当前版本,直到该频道中有更新版本可用。例如,从常规到缓慢,从快速到常规或缓慢 +::: + +## 计划升级 {#scheduled-upgrades} + + + +用户可以为企业级服务配置升级窗口。 + +选择您希望指定升级计划的服务,然后从左侧菜单中选择 `设置`。向下滚动至 `计划升级`。 + +
+ 计划升级 +
+
+ +选择此选项将允许用户选择每周的某一天/时间窗口进行数据库和云升级。 + +
+ 计划升级窗口 +
+
+:::note +虽然计划的升级遵循定义的计划,但对于关键安全补丁和漏洞修复适用例外。在发现紧急安全问题的情况下,升级可能会在计划窗口外进行。需要时,客户将会被通知此类例外情况。 +::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/05_admin_features/upgrades.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/05_admin_features/upgrades.md.hash new file mode 100644 index 00000000000..19ca96079d6 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/05_admin_features/upgrades.md.hash @@ -0,0 +1 @@ +d2f74cbef4251f75 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/01_shared-responsibility-model.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/01_shared-responsibility-model.md new file mode 100644 index 00000000000..eddae8f253e --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/01_shared-responsibility-model.md @@ -0,0 +1,108 @@ +--- +'sidebar_label': '共享责任模型' +'slug': '/cloud/security/shared-responsibility-model' +'title': '共享责任模型' +'description': '了解更多关于ClickHouse Cloud的安全模型' +'doc_type': 'reference' +--- + +## 服务类型 {#service-types} + +ClickHouse Cloud 提供三种服务类型:基础型、可扩展型和企业型。有关更多信息,请查看我们的 [服务类型](/cloud/manage/cloud-tiers) 页面。 + +## 云架构 {#cloud-architecture} + +云架构由控制平面和数据平面组成。控制平面负责组织创建、控制平面内的用户管理、服务管理、API 密钥管理和计费。数据平面运行编排和管理工具,并托管客户服务。有关更多信息,请查看我们的 [ClickHouse Cloud 架构](/cloud/reference/architecture) 图示。 + +## BYOC 架构 {#byoc-architecture} + +自带您的云 (BYOC) 使客户能够在自己的云账户中运行数据平面。有关更多信息,请查看我们的 [(BYOC) 自带云](/cloud/reference/byoc) 页面。 + +## ClickHouse Cloud 共享责任模型 {#clickhouse-cloud-shared-responsibility-model} +下表通常说明了 ClickHouse 的责任,并展示了 ClickHouse Cloud 和 ClickHouse BYOC 的客户各自应承担的责任。有关我们的 PCI 共享责任模型的更多信息,请下载我们 [信任中心](https://trust.clickhouse.com) 提供的概述副本。 + +| 控制 | ClickHouse | 云客户 | BYOC 客户 | +|-------------------------------------------------------------------------|--------------------|---------------------|---------------------| +| 保持环境之间的隔离 | :white_check_mark: | | :white_check_mark: | +| 管理网络设置 | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| 安全管理对 ClickHouse 系统的访问 | :white_check_mark: | | | +| 在控制平面和数据库中安全管理组织用户 | | :white_check_mark: | :white_check_mark: | +| 用户管理和审计 | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| 加密传输中的数据和静态数据 | :white_check_mark: | | | +| 安全处理客户管理的加密密钥 | | :white_check_mark: | :white_check_mark: | +| 提供冗余基础设施 | :white_check_mark: | | :white_check_mark: | +| 备份数据 | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| 验证备份恢复能力 | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| 实施数据保留设置 | | :white_check_mark: | :white_check_mark: | +| 安全配置管理 | :white_check_mark: | | :white_check_mark: | +| 软件和基础设施漏洞修复 | :white_check_mark: | | | +| 执行渗透测试 | :white_check_mark: | | | +| 威胁检测和响应 | :white_check_mark: | | :white_check_mark: | +| 安全事件响应 | :white_check_mark: | | :white_check_mark: | + +## ClickHouse Cloud 可配置安全功能 {#clickhouse-cloud-configurable-security-features} + +
+ 网络连接 + + | 设置 | 状态 | 云 | 服务级别 | + |------------------------------------------------------------------------------------------------------|-----------|----------------------|----------------------| + | [IP 过滤器](/cloud/security/setting-ip-filters) 限制对服务的连接 | 可用 | AWS, GCP, Azure | 所有 | + | [私有链接](/cloud/security/private-link-overview) 安全地连接到服务 | 可用 | AWS, GCP, Azure | 可扩展型或企业型 | + +
+
+ 访问管理 + + | 设置 | 状态 | 云 | 服务级别 | + |------------------------------------------------------------------------------------------------------|-----------|----------------------|-----------------------| + | [标准基于角色的访问](/cloud/security/cloud-access-management) 在控制平面 | 可用 | AWS, GCP, Azure | 所有 | + | [多因素认证 (MFA)](/cloud/security/cloud-authentication#multi-factor-authentication) 可用 | 可用 | AWS, GCP, Azure | 所有 | + | [SAML 单点登录](/cloud/security/saml-setup) 到控制平面可用 | 预览 | AWS, GCP, Azure | 企业型 | + | 在数据库中细粒度的 [基于角色的访问控制](/cloud/security/cloud-access-management/overview#database-permissions) | 可用 | AWS, GCP, Azure | 所有 | + +
+
+ 数据安全 + + | 设置 | 状态 | 云 | 服务级别 | + |------------------------------------------------------------------------------------------------------|-----------|----------------------|-----------------------| + | [云提供商和区域](/cloud/reference/supported-regions) 选择 | 可用 | AWS, GCP, Azure | 所有 | + | 有限的 [免费每日备份](/cloud/manage/backups/overview#default-backup-policy) | 可用 | AWS, GCP, Azure | 所有 | + | [自定义备份配置](/cloud/manage/backups/overview#configurable-backups) 可用 | 可用 | GCP, AWS, Azure | 可扩展型或企业型 | + | [客户管理的加密密钥 (CMEK)](/cloud/security/cmek) 实现透明
数据加密 可用 | 可用 | AWS, GCP | 企业型 | + | [字段级加密](/sql-reference/functions/encryption-functions) 具有手动密钥管理以实现细粒度加密 | 可用 | GCP, AWS, Azure | 所有 | + +
+
+ 数据保留 + + | 设置 | 状态 | 云 | 服务级别 | + |------------------------------------------------------------------------------------------------------|-----------|----------------------|-----------------------| + | [生存时间 (TTL)](/sql-reference/statements/alter/ttl) 设置以管理数据保留 | 可用 | AWS, GCP, Azure | 所有 | + | [ALTER TABLE DELETE](/sql-reference/statements/alter/delete) 用于大量删除操作 | 可用 | AWS, GCP, Azure | 所有 | + | [轻量级 DELETE](/sql-reference/statements/delete) 用于精确删除活动 | 可用 | AWS, GCP, Azure | 所有 | + +
+
+ 审计和日志记录 + + | 设置 | 状态 | 云 | 服务级别 | + |------------------------------------------------------------------------------------------------------|-----------|----------------------|-----------------------| + | [审计日志](/cloud/security/audit-logging) 记录控制平面活动 | 可用 | AWS, GCP, Azure | 所有 | + | [会话日志](/operations/system-tables/session_log) 记录数据库活动 | 可用 | AWS, GCP, Azure | 所有 | + | [查询日志](/operations/system-tables/query_log) 记录数据库活动 | 可用 | AWS, GCP, Azure | 所有 | + +
+ +## ClickHouse Cloud 合规性 {#clickhouse-cloud-compliance} + + | 框架 | 状态 | 云 | 服务级别 | + |------------------------------------------------------------------------------------------------------|-----------|----------------------|-----------------------| + | ISO 27001 合规性 | 可用 | AWS, GCP, Azure | 所有 | + | SOC 2 类型 II 合规性 | 可用 | AWS, GCP, Azure | 所有 | + | GDPR 和 CCPA 合规性 | 可用 | AWS, GCP, Azure | 所有 | + | HIPAA 合规性 | 可用 | AWS, GCP | 企业型 | + | PCI 合规性 | 可用 | AWS | 企业型 | + + 有关支持的合规性框架的更多信息,请查看我们的 [安全与合规性](/cloud/security/compliance-overview) 页面。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/01_shared-responsibility-model.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/01_shared-responsibility-model.md.hash new file mode 100644 index 00000000000..f4500203721 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/01_shared-responsibility-model.md.hash @@ -0,0 +1 @@ +3706d61ee85fa4d5 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/02_cloud-access-management/_category_.json b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/02_cloud-access-management/_category_.json new file mode 100644 index 00000000000..784ea5ce006 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/02_cloud-access-management/_category_.json @@ -0,0 +1,5 @@ +{ + "label": "Cloud access management", + "collapsible": true, + "collapsed": true, +} \ No newline at end of file diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/02_cloud-access-management/cloud-access-management.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/02_cloud-access-management/cloud-access-management.md new file mode 100644 index 00000000000..a62b301e828 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/02_cloud-access-management/cloud-access-management.md @@ -0,0 +1,148 @@ +--- +'sidebar_label': '概览' +'slug': '/cloud/security/cloud-access-management/overview' +'title': '云访问管理' +'description': '描述了 ClickHouse 云中访问控制是如何工作的,包括角色类型的信息' +'doc_type': 'guide' +--- + +import Image from '@theme/IdealImage'; +import user_grant_permissions_options from '@site/static/images/cloud/security/cloud-access-management/user_grant_permissions_options.png'; + + +# 在 ClickHouse Cloud 中的访问控制 {#access-control-in-clickhouse-cloud} + +ClickHouse Cloud 控制对控制台本身及其内部可用功能的访问。 +**控制台用户** 是这种访问的基础,所有权限、角色和访问控制通过这些用户分配和管理。 +当 [与控制台用户关联的数据库级权限](/cloud/security/common-access-management-queries#modifying-users-and-roles) 存在时,它们将管理通过 SQL 控制台查询时的数据访问。 + +## 控制台用户和角色 {#console-users-and-roles} + +在控制台 > 用户和角色页面中 [配置组织和服务角色分配](/cloud/guides/sql-console/configure-org-service-role-assignments)。 +在每个服务的设置页面中 [配置 SQL 控制台角色分配](/cloud/guides/sql-console/config-sql-console-role-assignments)。 + +用户必须被分配一个组织级角色,并可以选择性地被分配一个或多个服务角色。可以选择性地为用户配置服务角色,以便他们在服务设置页面访问 SQL 控制台。 +- 被分配组织管理员角色的用户默认会获得服务管理员权限。 +- 通过 SAML 集成添加到组织的用户会自动被分配会员角色,以最小权限访问,且在配置之前无法访问任何服务。 +- 服务管理员默认被分配 SQL 控制台管理员角色。可以在服务设置页面中移除 SQL 控制台权限。 + +| 上下文 | 角色 | 描述 | +|:--------------|:-------------------------|:-----------------------------------------------| +| 组织 | 管理员 | 执行组织的所有管理活动并控制所有设置。默认分配给组织中的第一个用户。 | +| 组织 | 开发者 | 查看访问所有内容,但不能访问服务,有权生成只读 API 密钥。 | +| 组织 | 账单 | 查看使用情况和发票,并管理付款方式。 | +| 组织 | 会员 | 仅能登录,具有管理个人资料设置的能力。默认分配给 SAML SSO 用户。 | +| 服务 | 服务管理员 | 管理服务设置。 | +| 服务 | 服务只读 | 查看服务和设置。 | +| SQL 控制台 | SQL 控制台管理员 | 对服务中的数据库具有相当于默认数据库角色的管理访问权限。 | +| SQL 控制台 | SQL 控制台只读 | 对服务中的数据库具有只读访问权限 | +| SQL 控制台 | 自定义 | 使用 SQL [`GRANT`](/sql-reference/statements/grant) 语句进行配置;通过以用户命名角色来将角色分配给 SQL 控制台用户 | + +要为 SQL 控制台用户创建自定义角色并授予它一个通用角色,请运行以下命令。电子邮件地址必须与控制台中用户的电子邮件地址匹配。 + + + +#### 创建 `database_developer` 并授予权限 {#create-database_developer-and-grant-permissions} + +创建 `database_developer` 角色并授予 `SHOW`、`CREATE`、`ALTER` 和 `DELETE` 权限。 + +```sql +CREATE ROLE OR REPLACE database_developer; +GRANT SHOW ON * TO database_developer; +GRANT CREATE ON * TO database_developer; +GRANT ALTER ON * TO database_developer; +GRANT DELETE ON * TO database_developer; +``` + +#### 创建 SQL 控制台用户角色 {#create-sql-console-user-role} + +为 SQL 控制台用户 my.user@domain.com 创建一个角色并将其分配为 database_developer 角色。 + +```sql +CREATE ROLE OR REPLACE `sql-console-role:my.user@domain.com`; +GRANT database_developer TO `sql-console-role:my.user@domain.com`; +``` + + + +### SQL 控制台无密码身份验证 {#sql-console-passwordless-authentication} +为每个会话创建 SQL 控制台用户,并使用自动轮换的 X.509 证书进行身份验证。当会话终止时,用户将被移除。在生成审计的访问列表时,请导航到控制台中服务的设置选项卡,并记录 SQL 控制台访问和存在于数据库中的数据库用户。如果配置了自定义角色,则用户的访问权限将列在以用户的用户名结尾的角色中。 + +## 数据库权限 {#database-permissions} +在服务和数据库中使用 SQL [GRANT](/sql-reference/statements/grant) 语句配置以下内容。 + +| 角色 | 描述 | +|:----------------------|:---------------------------------------------------------------------------| +| 默认 | 对服务的全面管理访问 | +| 自定义 | 使用 SQL [`GRANT`](/sql-reference/statements/grant) 语句进行配置 | + +- 数据库角色是加法的。这意味着如果用户是两个角色的成员,则用户具有这两个角色中授予的最大访问权限。添加角色不会失去访问权限。 +- 数据库角色可以被授予其他角色,从而形成层次结构。角色继承其成员角色的所有权限。 +- 数据库角色在每个服务中是唯一的,并且可以在同一服务中的多个数据库之间应用。 + +下图示例展示了用户可以以不同方式被授予权限。 + +An illustration showing the different ways a user could be granted permissions + +### 初始设置 {#initial-settings} +数据库具有一个名为 `default` 的账户,自动添加并在服务创建时授予 default_role。在创建服务时,由创建服务的用户提供分配给 `default` 账户的自动生成的随机密码。初始设置后不再显示该密码,但任何具有服务管理员权限的用户可以在控制台中随时更改。此账户或控制台中具有服务管理员权限的账户可以在任何时候设置额外的数据库用户和角色。 + +:::note +要在控制台中更改分配给 `default` 账户的密码,请转到左侧的服务菜单,访问服务,转到设置选项卡,然后点击重置密码按钮。 +::: + +我们建议创建一个与某个人关联的新用户账户,并授予该用户 default_role。这样可以确保用户所执行的活动与其用户 ID 相关联,同时保留 `default` 账户用于应急活动。 + +```sql +CREATE USER userID IDENTIFIED WITH sha256_hash by 'hashed_password'; +GRANT default_role to userID; +``` + +用户可以使用 SHA256 哈希生成器或 Python 中的 `hashlib` 等代码函数,将具有适当复杂度的 12 个以上字符的密码转换为 SHA256 字符串,以提供给系统管理员作为密码。这确保了管理员不会看到或处理明文密码。 + +### 与 SQL 控制台用户的数据库访问列表 {#database-access-listings-with-sql-console-users} +可以使用以下过程生成您组织中 SQL 控制台和数据库的完整访问列表。 + + + +#### 获取所有数据库授予的列表 {#get-a-list-of-all-database-grants} + +运行以下查询以获取数据库中所有授予的列表。 + +```sql +SELECT grants.user_name, +grants.role_name, +users.name AS role_member, +grants.access_type, +grants.database, +grants.table +FROM system.grants LEFT OUTER JOIN system.role_grants ON grants.role_name = role_grants.granted_role_name +LEFT OUTER JOIN system.users ON role_grants.user_name = users.name + +UNION ALL + +SELECT grants.user_name, +grants.role_name, +role_grants.role_name AS role_member, +grants.access_type, +grants.database, +grants.table +FROM system.role_grants LEFT OUTER JOIN system.grants ON role_grants.granted_role_name = grants.role_name +WHERE role_grants.user_name is null; +``` + +#### 将授予列表与访问 SQL 控制台的控制台用户关联 {#associate-grant-list-to-console-users-with-access-to-sql-console} + +将此列表与可以访问 SQL 控制台的控制台用户关联。 + +a. 转到控制台。 + +b. 选择相关服务。 + +c. 在左侧选择设置。 + +d. 滚动到 SQL 控制台访问部分。 + +e. 单击有关访问数据库的用户数量的链接 `There are # users with access to this service.` 以查看用户列表。 + + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/02_cloud-access-management/cloud-access-management.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/02_cloud-access-management/cloud-access-management.md.hash new file mode 100644 index 00000000000..7596b2dfe7a --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/02_cloud-access-management/cloud-access-management.md.hash @@ -0,0 +1 @@ +d49fae470c413969 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/02_cloud-access-management/cloud-authentication.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/02_cloud-access-management/cloud-authentication.md new file mode 100644 index 00000000000..5680ab1a0bd --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/02_cloud-access-management/cloud-authentication.md @@ -0,0 +1,131 @@ +--- +'sidebar_label': '云身份验证' +'slug': '/cloud/security/cloud-authentication' +'title': '云身份验证' +'description': '本指南解释了一些配置身份验证的良好实践。' +'doc_type': 'guide' +--- + +import ScalePlanFeatureBadge from '@theme/badges/ScalePlanFeatureBadge' +import EnterprisePlanFeatureBadge from '@theme/badges/EnterprisePlanFeatureBadge' + + +# Cloud 认证 + +ClickHouse Cloud 提供多种身份验证方式。 本指南解释配置身份验证的一些良好实践。 选择身份验证方法时,请始终与您的安全团队进行确认。 + +## 密码设置 {#password-settings} + +我们控制台和服务(数据库)的最低密码设置目前符合 [NIST 800-63B](https://pages.nist.gov/800-63-3/sp800-63b.html#sec4) 身份验证器保障级别 1: +- 至少 12 个字符 +- 包含以下 4 项中的 3 项: + - 1 个大写字母 + - 1 个小写字母 + - 1 个数字 + - 1 个特殊字符 + +## 电子邮件和密码 {#email--password} + +ClickHouse Cloud 允许您使用电子邮件地址和密码进行身份验证。 使用此方法时,保护您的 ClickHouse 帐户的最佳方法是使用强密码。 有许多在线资源可以帮助您想出一个可以记住的密码。 或者,您可以使用随机密码生成器并将密码存储在密码管理器中以提高安全性。 + +## 使用 Google 或 Microsoft 社交身份验证的单点登录 {#sso-using-google-or-microsoft-social-authentication} + +如果您的公司使用 Google Workspace 或 Microsoft 365,您可以利用您当前的单点登录设置在 ClickHouse Cloud 中进行身份验证。 要执行此操作,只需使用您的公司电子邮件地址注册,并邀请其他用户使用他们的公司电子邮件。 结果是您的用户必须使用公司的登录流程进行登录,无论是通过您的身份提供者,还是直接通过 Google 或 Microsoft 身份验证,然后才能登录 ClickHouse Cloud。 + +## 多因素身份验证 {#multi-factor-authentication} + +使用电子邮件 + 密码或社交身份验证的用户可以通过多因素身份验证 (MFA) 进一步保护他们的账户。 设置 MFA 的步骤如下: +1. 登录到 [console.clickhouse.cloud](https://console.clickhouse.cloud/) +2. 点击位于 ClickHouse 徽标旁边的左上角您的首字母 +3. 选择个人资料 +4. 在左侧选择安全性 +5. 点击身份验证器应用块中的设置 +6. 使用 Authy、1Password 或 Google Authenticator 等身份验证器应用扫描二维码 +7. 输入代码以确认 +8. 在下一个屏幕上,复制恢复代码并将其存储在安全的地方 +9. 勾选 `I have safely recorded this code` 旁边的框 +10. 点击继续 + +## 帐户恢复 {#account-recovery} + +
+ 获取恢复代码 + + 如果您之前注册了 MFA,但没有创建或丢失恢复代码,请按照以下步骤获取新的恢复代码: + 1. 转到 https://console.clickhouse.cloud + 2. 使用您的凭证和 MFA 登录 + 3. 在左上角转到您的个人资料 + 4. 点击左侧的安全性 + 5. 点击您身份验证器应用旁边的垃圾桶 + 6. 点击移除身份验证器应用 + 7. 输入您的代码,然后点击继续 + 8. 点击身份验证器应用部分中的设置 + 9. 扫描二维码并输入新代码 + 10. 复制您的恢复代码并将其存储在安全的地方 + 11. 勾选 `I have safely recorded this code` 旁边的框 + 12. 点击继续 + +
+
+ 忘记密码 + + 如果您忘记了密码,请按照以下步骤进行自助恢复: + 1. 转到 https://console.clickhouse.cloud + 2. 输入您的电子邮件地址并点击继续 + 3. 点击忘记密码? + 4. 点击发送密码重置链接 + 5. 检查您的电子邮件并点击电子邮件中的重置密码 + 6. 输入您的新密码,确认密码并点击更新密码 + 7. 点击返回登录 + 8. 使用新密码正常登录 + +
+
+ 丢失 MFA 设备或令牌 + + 如果您丢失了 MFA 设备或删除了令牌,请按照以下步骤恢复并创建新令牌: + 1. 转到 https://console.clickhouse.cloud + 2. 输入您的凭证并点击继续 + 3. 在多因素身份验证屏幕上点击取消 + 4. 点击恢复代码 + 5. 输入代码并按继续 + 6. 复制新恢复代码并将其存放在安全的地方 + 7. 勾选 `I have safely recorded this code` 旁边的框并点击继续 + 8. 登录后,转到左上角的个人资料 + 9. 点击左上角的安全性 + 10. 点击身份验证器应用旁边的垃圾桶图标以移除旧身份验证器 + 11. 点击移除身份验证器应用 + 12. 当提示您进行多因素身份验证时,点击取消 + 13. 点击恢复代码 + 14. 输入您的恢复代码(这是在第 7 步中生成的新代码)并点击继续 + 15. 复制新恢复代码并将其存放在安全的地方 - 这是在移除过程中如果离开屏幕时的后备措施 + 16. 勾选 `I have safely recorded this code` 旁边的框并点击继续 + 17. 按照以上步骤设置一个新的 MFA 因素 + +
+
+ 丢失 MFA 和恢复代码 + + 如果您丢失了 MFA 设备和恢复代码,或者您丢失了 MFA 设备且从未获得恢复代码,请按照以下步骤请求重置: + + **提交工单**:如果您所在的组织还有其他管理用户,即使您尝试访问的是单用户组织,也请让被分配为管理员角色的组织成员登录组织并代表您提交工单以重置您的 MFA。 一旦我们验证请求经过身份验证,我们会重置您的 MFA 并通知管理员。 按照正常方式登录,无需 MFA,并转到您的个人资料设置以注册新的因素(如有必要)。 + + **通过电子邮件重置**:如果您是该组织中的唯一用户,请使用与您的帐户关联的电子邮件地址通过电子邮件提交支持案例 (support@clickhouse.com)。 一旦我们验证请求来自正确的电子邮件,我们将重置您的 MFA 和密码。 访问您的电子邮件以获取密码重置链接。 设置新密码,然后转到您的个人资料设置以注册新的因素(如有必要)。 + +
+ +## SAML 单点登录 {#saml-sso} + + + +ClickHouse Cloud 还支持安全声明标记语言 (SAML) 单点登录 (SSO)。 有关更多信息,请参见 [SAML SSO 设置](/cloud/security/saml-setup)。 + +## 数据库用户 ID 和密码 {#database-user-id--password} + +在 [创建用户帐户](/sql-reference/statements/create/user.md) 时,请使用 SHA256_hash 方法来确保密码安全。 + +**提示**:由于没有管理权限的用户无法设置自己的密码,请要求用户使用生成器,例如 [这个](https://tools.keycdn.com/sha256-online-generator),在将密码提供给管理员设置帐户之前将其哈希化。 密码应遵循上述 [要求](#password-settings)。 + +```sql +CREATE USER userName IDENTIFIED WITH sha256_hash BY 'hash'; +``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/02_cloud-access-management/cloud-authentication.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/02_cloud-access-management/cloud-authentication.md.hash new file mode 100644 index 00000000000..39492fe7d16 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/02_cloud-access-management/cloud-authentication.md.hash @@ -0,0 +1 @@ +29f81c12b794df95 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/02_cloud-access-management/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/02_cloud-access-management/index.md new file mode 100644 index 00000000000..037025c3bf7 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/02_cloud-access-management/index.md @@ -0,0 +1,11 @@ +--- +'slug': '/cloud/security/cloud-access-management' +'title': '云访问管理' +'description': '云访问管理 TABLE OF CONTENTS' +'doc_type': 'landing-page' +--- + +| 页面 | 描述 | +|----------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------| +| [概述](/cloud/security/cloud-access-management/overview) | ClickHouse Cloud 中访问控制的概述 | +| [云认证](/cloud/security/cloud-authentication) | 一份探索配置认证一些良好实践的指南 | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/02_cloud-access-management/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/02_cloud-access-management/index.md.hash new file mode 100644 index 00000000000..977038cb9ec --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/02_cloud-access-management/index.md.hash @@ -0,0 +1 @@ +24366921c422748f diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/03_connectivity/01_private-link-overview.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/03_connectivity/01_private-link-overview.md new file mode 100644 index 00000000000..9d9cd4505bf --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/03_connectivity/01_private-link-overview.md @@ -0,0 +1,18 @@ +--- +'sidebar_label': '私有链接概述' +'slug': '/cloud/security/private-link-overview' +'title': '私有链接概述' +'description': '私有链接的登陆页面' +'doc_type': 'landing-page' +--- + + +# 私有链接概述 + +ClickHouse Cloud 提供将您的服务连接到云虚拟网络的能力。 + +请参考以下指南以获取您提供商的设置步骤: + +- [AWS 私有链接](/manage/security/aws-privatelink) +- [GCP 私有服务连接](/manage/security/gcp-private-service-connect) +- [Azure 私有链接](/cloud/security/azure-privatelink) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/03_connectivity/01_private-link-overview.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/03_connectivity/01_private-link-overview.md.hash new file mode 100644 index 00000000000..78c5687ca52 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/03_connectivity/01_private-link-overview.md.hash @@ -0,0 +1 @@ +291d5fb6e2b62e1a diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/03_connectivity/_category_.json b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/03_connectivity/_category_.json new file mode 100644 index 00000000000..f825cb0a36a --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/03_connectivity/_category_.json @@ -0,0 +1,6 @@ +{ + "label": "Connectivity", + "collapsible": true, + "collapsed": true, + "link": { "type": "doc", "id": "cloud/features/security/connectivity/index" } +} \ No newline at end of file diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/03_connectivity/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/03_connectivity/index.md new file mode 100644 index 00000000000..f240a2fc87e --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/03_connectivity/index.md @@ -0,0 +1,15 @@ +--- +'slug': '/cloud/security/connectivity' +'title': '连接性概述' +'description': '连接性的登录页面' +'doc_type': 'landing-page' +--- + + +# 连接性 + +本节讨论连接性,并包含以下页面: + +| 页面 | 描述 | +|---------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------| +| [私有网络](/cloud/security/private-link-overview) | 关于如何将您的服务连接到云虚拟网络的信息。 | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/03_connectivity/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/03_connectivity/index.md.hash new file mode 100644 index 00000000000..8b2fa5e0609 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/03_connectivity/index.md.hash @@ -0,0 +1 @@ +051189d93695625d diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/_category_.json b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/_category_.json new file mode 100644 index 00000000000..aed26fa7f7a --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/_category_.json @@ -0,0 +1,5 @@ +{ + "label": "Security", + "collapsible": true, + "collapsed": true, +} \ No newline at end of file diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/cmek.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/cmek.md new file mode 100644 index 00000000000..4f12bf84eea --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/cmek.md @@ -0,0 +1,112 @@ +--- +'sidebar_label': '增强加密' +'slug': '/cloud/security/cmek' +'title': '客户管理加密密钥 (CMEK)' +'description': '了解更多关于客户管理加密密钥的信息' +'doc_type': 'guide' +--- + +import Image from '@theme/IdealImage'; +import EnterprisePlanFeatureBadge from '@theme/badges/EnterprisePlanFeatureBadge' +import cmek_performance from '@site/static/images/_snippets/cmek-performance.png'; + + +# ClickHouse增强加密 + + + +静态数据默认使用云服务提供商管理的AES 256密钥进行加密。客户可以启用透明数据加密(TDE)来为服务数据提供额外的保护层,或提供自己的密钥以实现客户管理加密密钥(CMEK)。 + +增强加密当前可在AWS和GCP服务中使用。Azure即将推出。 + +## 透明数据加密(TDE) {#transparent-data-encryption-tde} + +在创建服务时必须启用TDE。现有服务在创建后无法进行加密。一旦启用TDE,就无法禁用。服务中的所有数据将保持加密状态。如果您想在启用TDE后禁用它,必须创建新服务并将数据迁移到新服务中。 + +1. 选择 `创建新服务` +2. 命名服务 +3. 从下拉菜单中选择AWS或GCP作为云服务提供商和所需的区域 +4. 点击企业功能的下拉菜单并切换启用透明数据加密(TDE) +5. 点击创建服务 + +## 客户管理加密密钥(CMEK) {#customer-managed-encryption-keys-cmek} + +:::warning +删除用于加密ClickHouse Cloud服务的KMS密钥将导致您的ClickHouse服务停止,并且其数据将不可恢复,包括现有备份。为了防止在旋转密钥时意外数据丢失,您可能希望在删除之前保留旧的KMS密钥一段时间。 +::: + +一旦服务使用TDE加密,客户可以更新密钥以启用CMEK。更新TDE设置后,服务将自动重启。在此过程中,旧的KMS密钥将解密数据加密密钥(DEK),新的KMS密钥将重新加密DEK。这确保服务在重启后将使用新的KMS密钥进行后续的加密操作。此过程可能需要几分钟。 + +
+ 使用AWS KMS启用CMEK + +1. 在ClickHouse Cloud中,选择加密服务 +2. 点击左侧的设置 +3. 在屏幕底部,展开网络安全信息 +4. 复制加密角色ID(AWS)或加密服务账号(GCP) - 您将在将来的步骤中需要此信息 +5. [为AWS创建KMS密钥](https://docs.aws.amazon.com/kms/latest/developerguide/create-keys.html) +6. 点击该密钥 +7. 按如下方式更新AWS密钥策略: + +```json +{ + "Sid": "Allow ClickHouse Access", + "Effect": "Allow", + "Principal": { + "AWS": [ "Encryption role ID " ] + }, + "Action": [ + "kms:Encrypt", + "kms:Decrypt", + "kms:ReEncrypt*", + "kms:DescribeKey" + ], + "Resource": "*" +} +``` + +10. 保存密钥策略 +11. 复制密钥ARN +12. 返回ClickHouse Cloud并将密钥ARN粘贴到服务设置的透明数据加密部分 +13. 保存更改 + +
+ +
+ 使用GCP KMS启用CMEK + +1. 在ClickHouse Cloud中,选择加密服务 +2. 点击左侧的设置 +3. 在屏幕底部,展开网络安全信息 +4. 复制加密服务账号(GCP) - 您将在将来的步骤中需要此信息 +5. [为GCP创建KMS密钥](https://cloud.google.com/kms/docs/create-key) +6. 点击该密钥 +7. 向在步骤4中复制的GCP加密服务账号授予以下权限。 + - Cloud KMS CryptoKey Encrypter/Decrypter + - Cloud KMS Viewer +10. 保存密钥权限 +11. 复制密钥资源路径 +12. 返回ClickHouse Cloud并将密钥资源路径粘贴到服务设置的透明数据加密部分 +13. 保存更改 + +
+ +## 密钥轮换 {#key-rotation} + +一旦您设置了CMEK,通过上述程序旋转密钥,创建新的KMS密钥并授予权限。返回服务设置以粘贴新的ARN(AWS)或密钥资源路径(GCP),并保存设置。服务将重启以应用新密钥。 + +## 备份和恢复 {#backup-and-restore} + +备份使用与关联服务相同的密钥进行加密。当您恢复加密备份时,会创建一个加密实例,使用与原始实例相同的KMS密钥。如有需要,您可以在恢复后旋转KMS密钥;有关更多详细信息,请参见 [密钥轮换](#key-rotation)。 + +## KMS密钥轮询器 {#kms-key-poller} + +使用CMEK时,每10分钟会检查提供的KMS密钥的有效性。如果对KMS密钥的访问无效,ClickHouse服务将停止。要恢复服务,请按照本指南中的步骤恢复对KMS密钥的访问,然后重启服务。 + +## 性能 {#performance} + +如本页所述,我们使用ClickHouse内置的[数据加密虚拟文件系统功能](/operations/storing-data#encrypted-virtual-file-system)来加密和保护您的数据。 + +此功能所使用的算法为`AES_256_CTR`,预计根据工作负载性能损失为5-15%: + +CMEK 性能损失 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/cmek.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/cmek.md.hash new file mode 100644 index 00000000000..b7ec5a2078e --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/06_security/cmek.md.hash @@ -0,0 +1 @@ +1fd4f943d6a8ca36 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/07_monitoring/_category_.json b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/07_monitoring/_category_.json new file mode 100644 index 00000000000..ef0bd973e2c --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/07_monitoring/_category_.json @@ -0,0 +1,5 @@ +{ + "label": "Monitoring", + "collapsible": true, + "collapsed": true, +} \ No newline at end of file diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/07_monitoring/advanced_dashboard.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/07_monitoring/advanced_dashboard.md new file mode 100644 index 00000000000..f06d4762d82 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/07_monitoring/advanced_dashboard.md @@ -0,0 +1,251 @@ +--- +'description': 'ClickHouse Cloud 中的高级仪表板' +'keywords': +- 'monitoring' +- 'observability' +- 'advanced dashboard' +- 'dashboard' +- 'observability dashboard' +'sidebar_label': '高级仪表板' +'sidebar_position': 45 +'slug': '/cloud/manage/monitor/advanced-dashboard' +'title': 'ClickHouse Cloud 中的高级仪表板' +'doc_type': 'guide' +--- + +import AdvancedDashboard from '@site/static/images/cloud/manage/monitoring/advanced_dashboard.png'; +import NativeAdvancedDashboard from '@site/static/images/cloud/manage/monitoring/native_advanced_dashboard.png'; +import EditVisualization from '@site/static/images/cloud/manage/monitoring/edit_visualization.png'; +import InsertedRowsSec from '@site/static/images/cloud/manage/monitoring/inserted_rows_max_parts_for_partition.png'; +import ResourceIntensiveQuery from '@site/static/images/cloud/manage/monitoring/resource_intensive_query.png'; +import SelectedRowsPerSecond from '@site/static/images/cloud/manage/monitoring/selected_rows_sec.png'; +import Image from '@theme/IdealImage'; + +在生产环境中监控数据库系统对于理解部署健康至关重要,以便您能够预防或解决故障。 + +高级仪表板是一个轻量级工具,旨在为您提供深入的 ClickHouse 系统及其环境的洞察,帮助您预先识别性能瓶颈、系统故障和效率低下的问题。 + +高级仪表板在 ClickHouse OSS(开源软件)和 Cloud 中均可用。本文将向您展示如何在 Cloud 中使用高级仪表板。 + +## 访问高级仪表板 {#accessing-the-advanced-dashboard} + +可以通过导航到以下位置访问高级仪表板: + +* 左侧面板 + * `Monitoring` → `Advanced dashboard` + +Advanced dashboard + +## 访问本地高级仪表板 {#accessing-the-native-advanced-dashboard} + +可以通过导航到以下位置访问本地高级仪表板: + +* 左侧面板 + * `Monitoring` → `Advanced dashboard` + * 点击 `You can still access the native advanced dashboard.` + +这将在新标签页中打开本地高级仪表板。您需要进行身份验证才能访问该仪表板。 + +Advanced dashboard + +每个可视化都有一个与之关联的 SQL 查询来填充它。您可以通过单击铅笔图标来编辑此查询。 + +Advanced dashboard + +## 开箱即用的可视化 {#out-of-box-visualizations} + +高级仪表板中的默认图表旨在提供对 ClickHouse 系统的实时可见性。以下是每个图表的描述列表。它们分为三个类别,以帮助您导航。 + +### ClickHouse 特定 {#clickhouse-specific} + +这些指标旨在监控 ClickHouse 实例的健康和性能。 + +| 指标 | 描述 | +|-----------------------------|--------------------------------------------------------------------------------------------| +| 每秒查询数 | 跟踪正在处理的查询速率 | +| 每秒选定行数 | 指示被查询读取的行数 | +| 每秒插入行数 | 测量数据摄取速率 | +| MergeTree 中的总分片数 | 显示 MergeTree 表中活动分片的数量,帮助识别未批量插入 | +| 分区的最大分片数 | 突出显示任何分区中的最大分片数 | +| 当前运行的查询 | 显示当前正在执行的查询数量 | +| 每秒选定字节数 | 指示被查询读取的数据量 | + +### 系统健康特定 {#system-health-specific} + +监控底层系统与观察 ClickHouse 自身一样重要。 + +| 指标 | 描述 | +|-----------------------------|---------------------------------------------------------------------| +| IO 等待 | 跟踪 I/O 等待时间 | +| CPU 等待 | 测量由 CPU 资源争用引起的延迟 | +| 从磁盘读取 | 跟踪从磁盘或块设备读取的字节数 | +| 从文件系统读取 | 跟踪从文件系统(包括页缓存)读取的字节数 | +| 内存(跟踪,字节) | 显示 ClickHouse 跟踪的进程的内存使用情况 | +| 负载平均值(15分钟) | 报告系统的当前负载平均值 | +| 操作系统 CPU 使用率(用户空间) | CPU 使用率运行用户空间代码 | +| 操作系统 CPU 使用率(内核) | CPU 使用率运行内核代码 | + +## ClickHouse Cloud 特定 {#clickhouse-cloud-specific} + +ClickHouse Cloud 使用对象存储(S3 类型)存储数据。监控此接口可以帮助检测问题。 + +| 指标 | 描述 | +|-------------------------------|----------------------------------------------------------| +| S3 读取等待 | 测量对 S3 的读取请求延迟 | +| 每秒 S3 读取错误数 | 跟踪读取错误的速率 | +| 从 S3 读取(字节/秒) | 跟踪从 S3 存储读取数据的速率 | +| 每秒磁盘 S3 写入请求 | 监控写入 S3 存储操作的频率 | +| 每秒磁盘 S3 读取请求 | 监控读取 S3 存储操作的频率 | +| 页面缓存命中率 | 页面缓存的命中率 | +| 文件系统缓存命中率 | 文件系统缓存的命中率 | +| 文件系统缓存大小 | 当前文件系统缓存大小 | +| 网络发送字节/秒 | 跟踪当前入站网络流量的速度 | +| 网络接收字节/秒 | 跟踪当前出站网络流量的速度 | +| 同时网络连接数 | 跟踪当前同时的网络连接数 | + +## 使用高级仪表板识别问题 {#identifying-issues-with-the-advanced-dashboard} + +实时查看 ClickHouse 服务的健康状态极大地帮助您在问题影响业务之前缓解这些问题或帮助解决它们。以下是一些可以通过高级仪表板发现的问题。 + +### 未批量插入 {#unbatched-inserts} + +如 [最佳实践文档](/best-practices/selecting-an-insert-strategy#batch-inserts-if-synchronous) 中所述,建议始终在可能的情况下同步批量插入数据到 ClickHouse。 + +合理批量大小的批量插入减少了摄取过程中创建的分片数量,从而在磁盘上实现更高效的写入操作和更少的合并操作。 + +发现非最优插入的关键指标是 **每秒插入行数** 和 **分区的最大分片数**。 + +Unbatched inserts + +上面的示例显示了 **每秒插入行数** 和 **分区的最大分片数** 在 13 时到 14 时之间的两个峰值。这表明我们以合理速度摄取数据。 + +然后我们看到在 16 时,**分区的最大分片数** 另一个大峰值,但 **每秒插入行数速度** 非常慢。创建了很多分片,但产生的数据显示,这些分片的大小非最优。 + +### 资源密集型查询 {#resource-intensive-query} + +运行消耗大量资源的 SQL 查询(如 CPU 或内存)是常见现象。然而,监控这些查询并了解它们对部署整体性能的影响非常重要。 + +没有查询吞吐量的变化而资源消耗出现突然变化可能表明正在执行更昂贵的查询。根据您运行的查询类型,这可能是可以预期的,但通过高级仪表板发现它们是好的。 + +下面是 CPU 使用率峰值的示例,而每秒执行的查询数量没有显著变化。 + +Resource intensive query + +### 不良主键设计 {#bad-primary-key-design} + +使用高级仪表板可以发现的另一个问题是不良的主键设计。如在 ["ClickHouse 中主索引的实用介绍"](/guides/best-practices/sparse-primary-indexes#a-table-with-a-primary-key) 中所述,选择最适合您用例的主键将大大提高性能,减少 ClickHouse 执行查询所需读取的行数。 + +要跟踪主键潜在改进的指标之一是 **每秒选定行数**。选定行数突然峰值可能表明整体查询吞吐量的一般增长,以及执行查询时选择了大量行的查询。 + +Resource intensive query + +通过时间戳作为筛选条件,您可以在 `system.query_log` 表中找到在峰值时执行的查询。 + +例如,运行一个查询,显示在某一天上午 11 时到中午 11 时之间执行的所有查询,以了解哪些查询读取了过多的行: + +```sql title="Query" +SELECT + type, + event_time, + query_duration_ms, + query, + read_rows, + tables +FROM system.query_log +WHERE has(databases, 'default') AND (event_time >= '2024-12-23 11:20:00') AND (event_time <= '2024-12-23 11:30:00') AND (type = 'QueryFinish') +ORDER BY query_duration_ms DESC +LIMIT 5 +FORMAT VERTICAL +``` + +```response title="Response" +Row 1: +────── +type: QueryFinish +event_time: 2024-12-23 11:22:55 +query_duration_ms: 37407 +query: SELECT + toStartOfMonth(review_date) AS month, + any(product_title), + avg(star_rating) AS avg_stars +FROM amazon_reviews_no_pk +WHERE + product_category = 'Home' +GROUP BY + month, + product_id +ORDER BY + month DESC, + product_id ASC +LIMIT 20 +read_rows: 150957260 +tables: ['default.amazon_reviews_no_pk'] + +Row 2: +────── +type: QueryFinish +event_time: 2024-12-23 11:26:50 +query_duration_ms: 7325 +query: SELECT + toStartOfMonth(review_date) AS month, + any(product_title), + avg(star_rating) AS avg_stars +FROM amazon_reviews_no_pk +WHERE + product_category = 'Home' +GROUP BY + month, + product_id +ORDER BY + month DESC, + product_id ASC +LIMIT 20 +read_rows: 150957260 +tables: ['default.amazon_reviews_no_pk'] + +Row 3: +────── +type: QueryFinish +event_time: 2024-12-23 11:24:10 +query_duration_ms: 3270 +query: SELECT + toStartOfMonth(review_date) AS month, + any(product_title), + avg(star_rating) AS avg_stars +FROM amazon_reviews_pk +WHERE + product_category = 'Home' +GROUP BY + month, + product_id +ORDER BY + month DESC, + product_id ASC +LIMIT 20 +read_rows: 6242304 +tables: ['default.amazon_reviews_pk'] + +Row 4: +────── +type: QueryFinish +event_time: 2024-12-23 11:28:10 +query_duration_ms: 2786 +query: SELECT + toStartOfMonth(review_date) AS month, + any(product_title), + avg(star_rating) AS avg_stars +FROM amazon_reviews_pk +WHERE + product_category = 'Home' +GROUP BY + month, + product_id +ORDER BY + month DESC, + product_id ASC +LIMIT 20 +read_rows: 6242304 +tables: ['default.amazon_reviews_pk'] +``` + +在这个示例中,我们可以看到同一查询在两个表 `amazon_reviews_no_pk` 和 `amazon_reviews_pk` 上执行。可以得出结论:某人在为 `amazon_reviews` 表测试主键选项。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/07_monitoring/advanced_dashboard.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/07_monitoring/advanced_dashboard.md.hash new file mode 100644 index 00000000000..0f5b6b64119 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/07_monitoring/advanced_dashboard.md.hash @@ -0,0 +1 @@ +dfb96b596618b898 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/07_monitoring/notifications.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/07_monitoring/notifications.md new file mode 100644 index 00000000000..5b7e23c9f93 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/07_monitoring/notifications.md @@ -0,0 +1,49 @@ +--- +'title': '通知' +'slug': '/cloud/notifications' +'description': '您在 ClickHouse Cloud 服务的通知' +'keywords': +- 'cloud' +- 'notifications' +'doc_type': 'guide' +--- + +import Image from '@theme/IdealImage'; +import notifications_1 from '@site/static/images/cloud/manage/notifications-1.png'; +import notifications_2 from '@site/static/images/cloud/manage/notifications-2.png'; +import notifications_3 from '@site/static/images/cloud/manage/notifications-3.png'; +import notifications_4 from '@site/static/images/cloud/manage/notifications-4.png'; + +ClickHouse Cloud 发送与您的服务或组织相关的重要事件通知。理解通知的发送和配置有几个概念需要牢记: + +1. **通知类别**:指通知的组,例如账单通知、服务相关通知等。在每个类别内,有多个通知可以配置传递方式。 +2. **通知严重性**:通知严重性可以是 `info`、`warning` 或 `critical`,这取决于通知的重要性。这是不可配置的。 +3. **通知渠道**:渠道指接收通知的方式,例如 UI、电子邮件、Slack 等。大多数通知可配置此项。 + +## 接收通知 {#receiving-notifications} + +通知可以通过各种渠道接收。目前,ClickHouse Cloud 支持通过电子邮件、ClickHouse Cloud UI 和 Slack 接收通知。您可以点击左上角菜单中的铃铛图标查看当前通知,这将打开一个弹出窗口。点击弹出窗口底部的 **查看所有** 按钮将带您访问显示所有通知活动日志的页面。 + +ClickHouse Cloud notifications flyout + +ClickHouse Cloud notifications activity log + +## 自定义通知 {#customizing-notifications} + +对于每个通知,您可以自定义接收通知的方式。您可以通过通知弹出窗口或通知活动日志的第二个选项卡访问设置界面。 + +Cloud 用户可以自定义通过 Cloud UI 发送的通知,这些自定义反映在每个用户身上。Cloud 用户还可以自定义发送到自己电子邮件的通知,但只有具备管理员权限的用户才能自定义发送到自定义电子邮件地址的通知和发送到 Slack 渠道的通知。 + +要为特定通知配置传递方式,请点击铅笔图标以修改通知传递渠道。 + +ClickHouse Cloud notifications settings screen + +ClickHouse Cloud notification delivery settings + +:::note +某些 **必需** 通知,例如 **支付失败**,是不可配置的。 +::: + +## 支持的通知 {#supported-notifications} + +目前,我们发送与账单相关的通知(支付失败、使用超出确认阈值等),以及与扩展事件相关的通知(扩展完成、扩展被阻止等)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/07_monitoring/notifications.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/07_monitoring/notifications.md.hash new file mode 100644 index 00000000000..d4783d49767 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/07_monitoring/notifications.md.hash @@ -0,0 +1 @@ +3feda35b0ebb1b39 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/prometheus.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/07_monitoring/prometheus.md similarity index 71% rename from i18n/zh/docusaurus-plugin-content-docs/current/integrations/prometheus.md rename to i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/07_monitoring/prometheus.md index 3d848d765bf..b443741149a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/prometheus.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/07_monitoring/prometheus.md @@ -9,6 +9,7 @@ - 'monitoring' - 'metrics' - 'exporter' +'doc_type': 'reference' --- import prometheus_grafana_metrics_endpoint from '@site/static/images/integrations/prometheus-grafana-metrics-endpoint.png'; @@ -22,31 +23,30 @@ import Image from '@theme/IdealImage'; # Prometheus 集成 -该功能支持将 [Prometheus](https://prometheus.io/) 集成到 ClickHouse Cloud 服务中进行监控。通过 [ClickHouse Cloud API](/cloud/manage/api/api-overview) 端点公开对 Prometheus 指标的访问,允许用户安全地连接并将指标导出到他们的 Prometheus 指标收集器。这些指标可以与仪表盘集成,例如 Grafana、Datadog 进行可视化。 +该功能支持将 [Prometheus](https://prometheus.io/) 集成到 ClickHouse Cloud 服务中,以监控服务。通过 [ClickHouse Cloud API](/cloud/manage/api/api-overview) 端点公开访问 Prometheus 指标,允许用户安全连接并将指标导出到他们的 Prometheus 指标收集器。这些指标可以与仪表盘结合使用,例如 Grafana、Datadog 进行可视化。 要开始,请 [生成一个 API 密钥](/cloud/manage/openapi)。 -## 用于检索 ClickHouse Cloud 指标的 Prometheus 端点 API {#prometheus-endpoint-api-to-retrieve-clickhouse-cloud-metrics} +## Prometheus 端点 API 以检索 ClickHouse Cloud 指标 {#prometheus-endpoint-api-to-retrieve-clickhouse-cloud-metrics} ### API 参考 {#api-reference} -| 方法 | 路径 | 描述 | -| ------ | ------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------- | -| GET | `https://api.clickhouse.cloud/v1/organizations/:organizationId/services/:serviceId/prometheus?filtered_metrics=[true \| false]` | 返回特定服务的指标 | -| GET | `https://api.clickhouse.cloud/v1/organizations/:organizationId/prometheus?filtered_metrics=[true \| false]` | 返回组织中所有服务的指标 | +| 方法 | 路径 | 描述 | +| ------ | ------------------------------------------------------------------------------------------------------------------- | -------------------------------------- | +| GET | `https://api.clickhouse.cloud/v1/organizations/:organizationId/services/:serviceId/prometheus?filtered_metrics=[true \| false]` | 返回特定服务的指标 | +| GET | `https://api.clickhouse.cloud/v1/organizations/:organizationId/prometheus?filtered_metrics=[true \| false]` | 返回组织中所有服务的指标 | **请求参数** | 名称 | 位置 | 类型 | -| ---------------- | ------------------ |------------------ | -| Organization ID | 端点地址 | uuid | -| Service ID | 端点地址 | uuid(可选) | -| filtered_metrics | 查询参数 | boolean(可选) | +| ---------------- | ------------------ | ------------------ | +| 组织 ID | 端点地址 | uuid | +| 服务 ID | 端点地址 | uuid(可选) | +| filtered_metrics | 查询参数 | boolean(可选) | +### 认证 {#authentication} -### 身份验证 {#authentication} - -使用您的 ClickHouse Cloud API 密钥进行基本身份验证: +使用您的 ClickHouse Cloud API 密钥进行基本认证: ```bash Username: @@ -158,41 +158,41 @@ ClickPipes_FetchedEvents_Total{clickhouse_org="11dfa1ec-767d-43cb-bfad-618ce2aaf ### 指标标签 {#metric-labels} -所有指标都有以下标签: +所有指标具有以下标签: -| 标签 | 描述 | -|------|------| -| clickhouse_org | 组织 ID | -| clickhouse_service | 服务 ID | -| clickhouse_service_name | 服务名称 | +| 标签 | 描述 | +|------------------------|------------------| +| clickhouse_org | 组织 ID | +| clickhouse_service | 服务 ID | +| clickhouse_service_name | 服务名称 | 对于 ClickPipes,指标还将具有以下标签: -| 标签 | 描述 | -|------|------| -| clickpipe_id | ClickPipe ID | -| clickpipe_name | ClickPipe 名称 | -| clickpipe_source | ClickPipe 源类型 | +| 标签 | 描述 | +|------------------------|------------------| +| clickpipe_id | ClickPipe ID | +| clickpipe_name | ClickPipe 名称 | +| clickpipe_source | ClickPipe 源类型 | ### 信息指标 {#information-metrics} -ClickHouse Cloud 提供了一个特殊的指标 `ClickHouse_ServiceInfo`,这是一个 `gauge`,其值始终为 `1`。此指标包含所有 **指标标签** 以及以下标签: +ClickHouse Cloud 提供一个特殊指标 `ClickHouse_ServiceInfo`,它是一个 `gauge` 且始终具有值 `1`。此指标包含所有 **指标标签** 以及以下标签: -| 标签 | 描述 | -|------|------| -| clickhouse_cluster_status | 服务的状态。可能为以下之一:[`awaking` \| `running` \| `degraded` \| `idle` \| `stopped`] | -| clickhouse_version | 服务运行的 ClickHouse 服务器版本 | -| scrape | 指示最后一次抓取的状态。可能为 `full` 或 `partial` | -| full | 表示在最后一次指标抓取期间没有错误 | -| partial | 表示在最后一次指标抓取期间发生了一些错误,仅返回了 `ClickHouse_ServiceInfo` 指标。 | +| 标签 | 描述 | +|-------------------------------|-----------------------------------------| +| clickhouse_cluster_status | 服务的状态。可能是以下之一:[ `awaking` \| `running` \| `degraded` \| `idle` \| `stopped`] | +| clickhouse_version | 服务运行的 ClickHouse 服务器版本 | +| scrape | 表示上次抓取的状态。可能是 `full` 或 `partial` | +| full | 表示上次抓取指标时没有错误 | +| partial | 表示上次抓取指标时发生了一些错误,并且只返回了 `ClickHouse_ServiceInfo` 指标。 | -请求以检索指标的操作不会重新激活处于 `idle` 状态的服务。如果服务处于 `idle` 状态,仅将返回 `ClickHouse_ServiceInfo` 指标。 +请求以检索指标不会恢复处于空闲状态的服务。如果服务处于 `idle` 状态,则只会返回 `ClickHouse_ServiceInfo` 指标。 对于 ClickPipes,还有一个类似的 `ClickPipes_Info` 指标 `gauge`,除了 **指标标签** 之外,还包含以下标签: -| 标签 | 描述 | -|------|------| -| clickpipe_state | 管道的当前状态 | +| 标签 | 描述 | +|---------------------------|-------------------------------------------| +| clickpipe_state | 管道的当前状态 | ### 配置 Prometheus {#configuring-prometheus} @@ -219,23 +219,23 @@ scrape_configs: honor_labels: true ``` -请注意,`honor_labels` 配置参数需要设置为 `true`,以便实例标签能够正确填充。此外,上述示例中的 `filtered_metrics` 设置为 `true`,但应该根据用户的喜好进行配置。 +请注意,`honor_labels` 配置参数需要设置为 `true`,以便实例标签能够正确填充。此外,上述示例中的 `filtered_metrics` 设置为 `true`,但应根据用户的喜好进行配置。 ## 与 Grafana 集成 {#integrating-with-grafana} -用户有两种主要方式与 Grafana 集成: +用户有两种主要方法与 Grafana 集成: -- **指标端点** – 此方法的优点是不需要任何额外的组件或基础架构。此提供仅限于 Grafana Cloud,只需 ClickHouse Cloud Prometheus 端点 URL 和凭据。 -- **Grafana Alloy** - Grafana Alloy 是 OpenTelemetry (OTel) Collector 的一种中立于供应商的分发版,替代了 Grafana Agent。这可以用作抓取器,可以在您的基础设施中部署,并与任何 Prometheus 端点兼容。 +- **指标端点** – 这种方法的优点是不需要任何额外的组件或基础设施。这种方式仅限于 Grafana Cloud,仅需 ClickHouse Cloud Prometheus 端点 URL 和凭证。 +- **Grafana Alloy** - Grafana Alloy 是 OpenTelemetry (OTel) Collector 的中立供应商分发,替代了 Grafana Agent。这可以用作抓取器,部署在您自己的基础设施中,并与任何 Prometheus 端点兼容。 -我们在下面提供有关使用这些选项的说明,重点讨论与 ClickHouse Cloud Prometheus 端点相关的细节。 +我们在下面提供了关于使用这些选项的说明,重点是与 ClickHouse Cloud Prometheus 端点特定的细节。 ### 使用指标端点的 Grafana Cloud {#grafana-cloud-with-metrics-endpoint} -- 登录到您的 Grafana Cloud 帐户 -- 通过选择 **Metrics Endpoint** 添加新的连接 -- 配置抓取 URL,指向 Prometheus 端点,并使用基本认证配置 API 密钥/秘密来连接 -- 测试连接以确保可以连接 +- 登录到您的 Grafana Cloud 账户 +- 通过选择 **指标端点** 添加新连接 +- 配置抓取 URL 以指向 Prometheus 端点,并使用基本身份验证与 API 密钥/密钥配置您的连接 +- 测试连接以确保您能够连接 配置 Grafana 指标端点 @@ -243,23 +243,23 @@ scrape_configs: 配置完成后,您应该在下拉菜单中看到可以选择以配置仪表盘的指标: -Grafana 指标资源管理器下拉菜单 +Grafana 指标探索器下拉菜单
-Grafana 指标资源管理器图表 +Grafana 指标探索器图表 ### 使用 Alloy 的 Grafana Cloud {#grafana-cloud-with-alloy} -如果您使用的是 Grafana Cloud,可以通过在 Grafana 中导航到 Alloy 菜单并按照屏幕上的说明来安装 Alloy: +如果您使用的是 Grafana Cloud,可以通过导航到 Grafana 中的 Alloy 菜单并按照屏幕上的说明进行安装 Alloy: Grafana Alloy
-这应该将 Alloy 配置为一个带有 `prometheus.remote_write` 组件的设置,以将数据发送到带有身份验证令牌的 Grafana Cloud 端点。用户只需修改 Alloy 配置(在 Linux 上位于 `/etc/alloy/config.alloy`)以包含 ClickHouse Cloud Prometheus 端点的抓取器。 +这应该将 Alloy 配置为具有 `prometheus.remote_write` 组件,用于将数据发送到具有身份验证令牌的 Grafana Cloud 端点。用户只需修改 Alloy 配置(在 Linux 中位于 `/etc/alloy/config.alloy`),以添加用于 ClickHouse Cloud Prometheus 端点的抓取器。 -以下是包含 `prometheus.scrape` 组件的 Alloy 示例配置,用于从 ClickHouse Cloud 端点抓取指标,以及自动配置的 `prometheus.remote_write` 组件。请注意,`basic_auth` 配置组件包含我们的 Cloud API 密钥 ID 和秘密,分别作为用户名和密码。 +以下展示了 Alloy 的示例配置,具有用于从 ClickHouse Cloud 端点抓取指标的 `prometheus.scrape` 组件,以及自动配置的 `prometheus.remote_write` 组件。请注意,`basic_auth` 配置组件包含我们的 Cloud API 密钥 ID 和秘密,分别作为用户名和密码。 ```yaml prometheus.scrape "clickhouse_cloud" { @@ -295,7 +295,7 @@ prometheus.remote_write "metrics_service" { ### 使用 Alloy 的自管理 Grafana {#grafana-self-managed-with-alloy} -自管理的 Grafana 用户可以在 [这里](https://grafana.com/docs/alloy/latest/get-started/install/) 找到安装 Alloy 代理的说明。我们假设用户已配置 Alloy 将 Prometheus 指标发送到他们所需的目的地。下面的 `prometheus.scrape` 组件使 Alloy 从 ClickHouse Cloud 端点抓取。我们假设 `prometheus.remote_write` 接收抓取的指标。如未存在,请调整 `forward_to` 键以指向目标位置。 +使用自管理 Grafana 的用户可以[在这里](https://grafana.com/docs/alloy/latest/get-started/install/)找到安装 Alloy 代理的说明。我们假设用户已配置 Alloy 以将 Prometheus 指标发送到他们希望的目标。以下的 `prometheus.scrape` 组件使 Alloy 从 ClickHouse Cloud 端点抓取指标。我们假设 `prometheus.remote_write` 接收抓取的指标。如果该目标不存在,请调整 `forward_to` 键,以指向目标位置。 ```yaml prometheus.scrape "clickhouse_cloud" { @@ -317,9 +317,9 @@ prometheus.scrape "clickhouse_cloud" { } ``` -配置完成后,您应该在您的指标资源管理器中看到与 ClickHouse 相关的指标: +配置完成后,您应该在您的指标探索器中看到与 ClickHouse 相关的指标: -Grafana 指标资源管理器 +Grafana 指标探索器
@@ -327,7 +327,7 @@ prometheus.scrape "clickhouse_cloud" { ## 与 Datadog 集成 {#integrating-with-datadog} -您可以使用 Datadog [Agent](https://docs.datadoghq.com/agent/?tab=Linux) 和 [OpenMetrics 集成](https://docs.datadoghq.com/integrations/openmetrics/) 从 ClickHouse Cloud 端点收集指标。以下是该代理和集成的简单示例配置。请注意,您可能希望仅选择您最关心的那些指标。以下的广泛示例将导出成千上万个指标实例组合,Datadog 会将其视为自定义指标。 +您可以使用 Datadog [Agent](https://docs.datadoghq.com/agent/?tab=Linux) 和 [OpenMetrics 集成](https://docs.datadoghq.com/integrations/openmetrics/) 从 ClickHouse Cloud 端点收集指标。以下是此代理和集成的简单示例配置。请注意,您可能只想选择您最关心的那些指标。以下的笼统示例将导出成千上万的指标实例组合,Datadog 将其视为自定义指标。 ```yaml init_config: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/07_monitoring/prometheus.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/07_monitoring/prometheus.md.hash new file mode 100644 index 00000000000..c9a70d06a2b --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/07_monitoring/prometheus.md.hash @@ -0,0 +1 @@ +d180f2abdbbc6853 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/08_backups/configurable-backups.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/08_backups/configurable-backups.md new file mode 100644 index 00000000000..98f0467c078 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/08_backups/configurable-backups.md @@ -0,0 +1,49 @@ +--- +'sidebar_label': '可配置的备份' +'slug': '/cloud/manage/backups/configurable-backups' +'description': '可配置的备份' +'title': '可配置的备份' +'keywords': +- 'backups' +- 'cloud backups' +- 'restore' +'doc_type': 'guide' +--- + +import backup_settings from '@site/static/images/cloud/manage/backup-settings.png'; +import backup_configuration_form from '@site/static/images/cloud/manage/backup-configuration-form.png'; +import CloudNotSupportedBadge from '@theme/badges/CloudNotSupportedBadge'; +import ScalePlanFeatureBadge from '@theme/badges/ScalePlanFeatureBadge'; +import Image from '@theme/IdealImage'; + + + +ClickHouse Cloud 允许您为 **Scale** 和 **Enterprise** 等级服务配置备份计划。备份可以根据您的业务需求沿以下维度进行配置。 + +- **保留期**: 每个备份将保留的天数。保留期可以指定为最低 1 天,最高 30 天,中间有多个值可选。 +- **频率**: 频率允许您指定后续备份之间的时间间隔。例如,“每 12 小时一次”的频率意味着备份将相隔 12 小时。频率范围从“每 6 小时一次”到“每 48 小时一次”,按以下小时增量:`6`, `8`, `12`, `16`, `20`, `24`, `36`, `48`。 +- **开始时间**: 您希望每天安排备份的开始时间。指定开始时间意味着备份的“频率”将默认设置为每 24 小时一次。ClickHouse Cloud 将在指定开始时间的一小时内开始备份。 + +:::note +自定义计划将覆盖 ClickHouse Cloud 对您所提供服务的默认备份策略。 +::: + +:::note +在一些罕见的情况下,备份调度程序不会尊重为备份指定的 **开始时间**。具体来说,如果在当前计划备份时间的 < 24 小时 内触发了成功的备份,就会发生这种情况。这可能是由于我们为备份设置的重试机制。在这种情况下,调度程序将跳过当天的备份,并将在次日的计划时间重试备份。 +::: + +要配置服务的备份计划,请转到控制台中的 **设置** 选项卡,然后单击 **更改备份配置**。 + +配置备份设置 + +这将在右侧打开一个选项卡,您可以在其中选择保留期、频率和开始时间的值。您需要保存所选设置以使其生效。 + +选择备份保留期和频率 + +:::note +开始时间和频率是相互排斥的。开始时间优先。 +::: + +:::note +更改备份计划可能会导致每月存储费用增加,因为某些备份可能不包含在服务的默认备份中。请参见下面的 ["理解备份成本"](./overview.md/#understanding-backup-cost) 部分。 +::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/08_backups/configurable-backups.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/08_backups/configurable-backups.md.hash new file mode 100644 index 00000000000..3fab24d5374 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/08_backups/configurable-backups.md.hash @@ -0,0 +1 @@ +ea9e8c0bcb74ebf2 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/backups/export-backups-to-own-cloud-account.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/08_backups/export-backups-to-own-cloud-account.md similarity index 53% rename from i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/backups/export-backups-to-own-cloud-account.md rename to i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/08_backups/export-backups-to-own-cloud-account.md index f265ce3ce6d..0278f34ccd0 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/backups/export-backups-to-own-cloud-account.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/08_backups/export-backups-to-own-cloud-account.md @@ -1,44 +1,49 @@ --- -'sidebar_label': '导出备份到您自己的云帐户' +'sidebar_label': '将备份导出到您自己的云帐户' 'slug': '/cloud/manage/backups/export-backups-to-own-cloud-account' -'title': '导出备份到您自己的云帐户' +'title': '将备份导出到您自己的云帐户' 'description': '描述如何将备份导出到您自己的 Cloud 帐户' +'doc_type': 'guide' --- import EnterprisePlanFeatureBadge from '@theme/badges/EnterprisePlanFeatureBadge' -ClickHouse Cloud 支持将备份存储到您自己的云服务提供商(CSP)账户(AWS S3、Google Cloud Storage 或 Azure Blob Storage)中。 -有关 ClickHouse Cloud 备份工作原理的详细信息,包括“完整”备份与“增量”备份的区别,请参见 [backups](overview.md) 文档。 +ClickHouse Cloud 支持将备份导出到您自己的云服务提供商 (CSP) 账户(AWS S3、Google Cloud Storage 或 Azure Blob Storage)。 +有关 ClickHouse Cloud 备份的工作原理的详细信息,包括“完整”与“增量”备份,请参阅 [backups](overview.md) 文档。 -在这里,我们展示如何将完整和增量备份存储到 AWS、GCP、Azure 对象存储的示例,以及如何从备份中恢复。 +在这里,我们展示如何将完整和增量备份导出到 AWS、GCP、Azure 对象存储的示例,以及如何从备份中恢复。 :::note -用户应注意,任何将备份导出到相同云提供商的不同区域,或导出到另一个云提供商(同一区域或不同区域)的用法将产生 [data transfer](../network-data-transfer.mdx) 费用。 +用户应注意,任何将备份导出到同一云提供商的不同区域的使用,将产生 [data transfer](/cloud/manage/network-data-transfer) 费用。目前我们不支持跨云备份。 ::: -## Requirements {#requirements} +## 要求 {#requirements} -您需要以下详细信息才能将备份导出到您自己的 CSP 存储桶或从中恢复。 +您需要以下详细信息,以将备份导出/恢复到您自己的 CSP 存储桶中。 ### AWS {#aws} -1. AWS S3 终端节点,格式如下: +1. AWS S3 端点,格式如下: ```text s3://.s3.amazonaws.com/ ``` - 例如: + 例如: ```text s3://testchbackups.s3.amazonaws.com/backups/ ``` - 其中: - - `testchbackups` 是导出备份的 S3 存储桶名称。 - - `backups` 是可选的子目录。 + 其中: + - `testchbackups` 是要导出备份的 S3 存储桶的名称。 + - `backups` 是可选的子目录。 -2. AWS 访问密钥和秘密。 +2. AWS 访问密钥和密钥。也支持基于角色的 AWS 身份验证,可以替代 AWS 访问密钥和密钥使用。 + +:::note +要使用基于角色的身份验证,请遵循安全 s3 [setup](https://clickhouse.com/docs/cloud/security/secure-s3)。另外,您需要在 IAM 策略中添加 `s3:PutObject` 和 `s3:DeleteObject` 权限,如 [here.](https://clickhouse.com/docs/cloud/security/secure-s3#option-2-manually-create-iam-role) 所述。 +::: ### Azure {#azure} @@ -48,36 +53,36 @@ s3://testchbackups.s3.amazonaws.com/backups/ ### Google Cloud Storage (GCS) {#google-cloud-storage-gcs} -1. GCS 终端节点,格式如下: +1. GCS 端点,格式如下: ```text https://storage.googleapis.com// ``` -2. 访问 HMAC 密钥和 HMAC 秘密。 +2. 访问 HMAC 密钥和 HMAC 密钥。
-# Backup / Restore +# 备份 / 恢复 -## Backup / Restore to AWS S3 Bucket {#backup--restore-to-aws-s3-bucket} +## 备份 / 恢复到 AWS S3 存储桶 {#backup--restore-to-aws-s3-bucket} -### Take a DB Backup {#take-a-db-backup} +### 进行 DB 备份 {#take-a-db-backup} -**Full Backup** +**完整备份** ```sql BACKUP DATABASE test_backups TO S3('https://testchbackups.s3.amazonaws.com/backups/', '', '') ``` -其中 `uuid` 是唯一标识符,用于区分一组备份。 +其中 `uuid` 是用于区分一组备份的唯一标识符。 :::note 您需要为此子目录中的每个新备份使用不同的 UUID,否则会出现 `BACKUP_ALREADY_EXISTS` 错误。 -例如,如果您每天进行备份,则每天需要使用新的 UUID。 +例如,如果每天进行备份,则需要每天使用新的 UUID。 ::: -**Incremental Backup** +**增量备份** ```sql BACKUP DATABASE test_backups @@ -85,7 +90,7 @@ TO S3('https://testchbackups.s3.amazonaws.com/backups/', '', '', '', '') ``` -### Restore from a backup {#restore-from-a-backup} +### 从备份恢复 {#restore-from-a-backup} ```sql RESTORE DATABASE test_backups @@ -93,22 +98,22 @@ AS test_backups_restored FROM S3('https://testchbackups.s3.amazonaws.com/backups/', '', '') ``` -请参见:[Configuring BACKUP/RESTORE to use an S3 Endpoint](/operations/backup#configuring-backuprestore-to-use-an-s3-endpoint)以获取更多详细信息。 +请参见:[Configuring BACKUP/RESTORE to use an S3 Endpoint](/operations/backup#configuring-backuprestore-to-use-an-s3-endpoint) 以获得更多详细信息。 -## Backup / Restore to Azure Blob Storage {#backup--restore-to-azure-blob-storage} +## 备份 / 恢复到 Azure Blob 存储 {#backup--restore-to-azure-blob-storage} -### Take a DB Backup {#take-a-db-backup-1} +### 进行 DB 备份 {#take-a-db-backup-1} -**Full Backup** +**完整备份** ```sql BACKUP DATABASE test_backups TO AzureBlobStorage('', '', '/'); ``` -其中 `uuid` 是唯一标识符,用于区分一组备份。 +其中 `uuid` 是用于区分一组备份的唯一标识符。 -**Incremental Backup** +**增量备份** ```sql BACKUP DATABASE test_backups @@ -116,7 +121,7 @@ TO AzureBlobStorage('', '', '', '/') ``` -### Restore from a backup {#restore-from-a-backup-1} +### 从备份恢复 {#restore-from-a-backup-1} ```sql RESTORE DATABASE test_backups @@ -124,21 +129,21 @@ AS test_backups_restored_azure FROM AzureBlobStorage('', '', '/') ``` -请参见:[Configuring BACKUP/RESTORE to use an S3 Endpoint](/operations/backup#configuring-backuprestore-to-use-an-azureblobstorage-endpoint)以获取更多详细信息。 +请参见:[Configuring BACKUP/RESTORE to use an S3 Endpoint](/operations/backup#configuring-backuprestore-to-use-an-azureblobstorage-endpoint) 以获得更多详细信息。 -## Backup / Restore to Google Cloud Storage (GCS) {#backup--restore-to-google-cloud-storage-gcs} +## 备份 / 恢复到 Google Cloud Storage (GCS) {#backup--restore-to-google-cloud-storage-gcs} -### Take a DB Backup {#take-a-db-backup-2} +### 进行 DB 备份 {#take-a-db-backup-2} -**Full Backup** +**完整备份** ```sql BACKUP DATABASE test_backups TO S3('https://storage.googleapis.com//', ', ) ``` -其中 `uuid` 是唯一标识符,用于区分一组备份。 +其中 `uuid` 是用于区分一组备份的唯一标识符。 -**Incremental Backup** +**增量备份** ```sql BACKUP DATABASE test_backups @@ -146,7 +151,7 @@ TO S3('https://storage.googleapis.com/test_gcs_backups//my_incremental', ' SETTINGS base_backup = S3('https://storage.googleapis.com/test_gcs_backups/', 'key', 'secret') ``` -### Restore from a backup {#restore-from-a-backup-2} +### 从备份恢复 {#restore-from-a-backup-2} ```sql RESTORE DATABASE test_backups diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/08_backups/export-backups-to-own-cloud-account.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/08_backups/export-backups-to-own-cloud-account.md.hash new file mode 100644 index 00000000000..b0b4b08b14e --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/08_backups/export-backups-to-own-cloud-account.md.hash @@ -0,0 +1 @@ +ce7b81935f8f4181 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/08_backups/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/08_backups/index.md new file mode 100644 index 00000000000..b904e6b1d18 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/08_backups/index.md @@ -0,0 +1,16 @@ +--- +'slug': '/cloud/manage/backups' +'title': '备份' +'description': '备份的目录页面。' +'keywords': +- 'backups' +- 'configurable backups' +- 'export backups to own cloud' +'doc_type': 'landing-page' +--- + +| 页面 | 描述 | +|--------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------| +| [概述](./overview.md) | 备份的概述页面。 | +| [可配置备份](./configurable-backups.md) | 了解如何按比例和企业级用户可以根据特定业务需求自定义其备份计划。 | +| [将备份导出到您自己的云账户](./export-backups-to-own-cloud-account.md) | 了解企业级功能,使您能够将备份导出到您自己的云账户。 | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/08_backups/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/08_backups/index.md.hash new file mode 100644 index 00000000000..99ab4beb87f --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/08_backups/index.md.hash @@ -0,0 +1 @@ +df62220f4f4fe757 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/08_backups/overview.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/08_backups/overview.md new file mode 100644 index 00000000000..b6a6359f51c --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/08_backups/overview.md @@ -0,0 +1,187 @@ +--- +'sidebar_label': '概述' +'sidebar_position': 0 +'slug': '/cloud/manage/backups/overview' +'title': '概述' +'keywords': +- 'backups' +- 'cloud backups' +- 'restore' +'description': '提供 ClickHouse Cloud 中备份的概述' +'doc_type': 'guide' +--- + +import CloudNotSupportedBadge from '@theme/badges/CloudNotSupportedBadge'; +import ScalePlanFeatureBadge from '@theme/badges/ScalePlanFeatureBadge'; +import Image from '@theme/IdealImage'; +import backup_chain from '@site/static/images/cloud/manage/backup-chain.png'; +import backup_status_list from '@site/static/images/cloud/manage/backup-status-list.png'; +import backup_usage from '@site/static/images/cloud/manage/backup-usage.png'; +import backup_restore from '@site/static/images/cloud/manage/backup-restore.png'; +import backup_service_provisioning from '@site/static/images/cloud/manage/backup-service-provisioning.png'; + + +# 备份 + +数据库备份提供了一种安全保障,确保在数据因任何不可预见的原因丢失时,服务可以从最后一次成功备份恢复到之前的状态。这可以最小化停机时间,并防止业务关键数据被永久丢失。本指南涵盖了在 ClickHouse Cloud 中备份的工作原理、您可以为服务配置备份的选项,以及如何从备份中恢复。 + +## ClickHouse Cloud 中备份的工作原理 {#how-backups-work-in-clickhouse-cloud} + +ClickHouse Cloud 备份是由“全量”备份和“增量”备份组合而成的备份链。链条从全量备份开始,然后在接下来的几个调度时间段内进行增量备份,以创建一系列备份。一旦备份链达到一定长度,将开始新的链条。整个备份链可以用于在需要时将数据恢复到新的服务中。一旦特定链中所有备份都超过了为服务设置的保留时间(有关保留的更多信息见下文),该链将被丢弃。 + +在下面的截图中,实线方框表示全量备份,虚线方框表示增量备份。方框周围的实线矩形表示保留期和用户可见的备份,这些备份可用于备份恢复。在下面的场景中,每24小时进行一次备份,并保留2天。 + +在第1天,进行全量备份以启动备份链。在第2天,进行增量备份,现在我们有一个全量备份和一个增量备份可供恢复。在第7天,我们在链中有一个全量备份和六个增量备份,其中最新的两个增量备份对用户可见。在第8天,我们进行新的全量备份,在第9天,当我们在新链中有两个备份时,前一个链被丢弃。 + +在 ClickHouse Cloud 中的备份链示例 + +*ClickHouse Cloud 中的备份场景示例* + +## 默认备份策略 {#default-backup-policy} + +在基础、高级和企业级别中,备份是按使用量计费,与存储分开计费。所有服务默认每天备份一次,并且可以在 Cloud 控制台的设置选项卡中进行更多配置,从高级套餐开始。每个备份将至少保留24小时。 + +## 备份状态列表 {#backup-status-list} + +您的服务将根据设定的调度进行备份,无论是默认的每日调度还是您选定的 [自定义调度](./configurable-backups.md)。所有可用的备份可以在服务的**备份**选项卡中查看。从这里,您可以查看备份的状态、持续时间以及备份的大小。您还可以使用**操作**列恢复特定备份。 + +ClickHouse Cloud 中的备份状态列表 + +## 理解备份成本 {#understanding-backup-cost} + +根据默认政策,ClickHouse Cloud 每天强制备份一次,保留24小时。选择需要保留更多数据的调度,或导致备份更频繁的调度可能会产生额外的存储费用。 + +要了解备份成本,您可以从使用情况屏幕查看每个服务的备份成本(如下所示)。一旦您根据自定义调度运行了一些天的备份,您就可以大致了解成本并推断出备份的每月成本。 + +ClickHouse Cloud 中的备份使用情况图表 + +估算备份的总成本需要您设定一个调度。我们还在更新我们的 [定价计算器](https://clickhouse.com/pricing),以便您在设定调度之前获得每月成本估算。您需要提供以下输入以估算成本: +- 全量和增量备份的大小 +- 希望的频率 +- 希望的保留期 +- 云提供商和区域 + +:::note +请注意,备份的估算成本将随着服务中数据大小的增长而变化。 +::: + +## 恢复备份 {#restore-a-backup} + +备份将恢复到新的 ClickHouse Cloud 服务中,而不是恢复到备份来源的现有服务中。 + +点击**恢复**备份图标后,您可以指定将要创建的新服务的服务名称,然后恢复该备份: + +在 ClickHouse Cloud 中恢复备份 + +新服务将在服务列表中显示为 `Provisioning`,直到它准备就绪: + +正在进行服务配置 + +## 使用恢复后的服务 {#working-with-your-restored-service} + +在备份恢复后,您将拥有两个相似的服务:需要恢复的**原始服务**和从原始备份恢复的新**恢复服务**。 + +备份恢复完成后,您应该执行以下操作之一: +- 使用新的恢复服务并删除原始服务。 +- 将数据从新的恢复服务迁移回原始服务并删除新的恢复服务。 + +### 使用 **新恢复的服务** {#use-the-new-restored-service} + +要使用新服务,请执行以下步骤: + +1. 验证新服务是否具有您用例所需的 IP 访问列表条目。 +1. 验证新服务是否包含您所需的数据。 +1. 删除原始服务。 + +### 从 **新恢复的服务** 迁移数据回到 **原始服务** {#migrate-data-from-the-newly-restored-service-back-to-the-original-service} + +假设您出于某种原因无法使用新恢复的服务,例如仍有用户或应用程序连接到现有服务。您可以决定将新恢复的数据迁移到原始服务中。迁移可以通过以下步骤完成: + +**允许远程访问新恢复的服务** + +新服务应从具有与原始服务相同的 IP 允许列表的备份中恢复。这是必要的,因为连接将不允许访问其他 ClickHouse Cloud 服务,除非您允许了来自 **Anywhere** 的访问。暂时修改允许列表,并允许来自 **Anywhere** 的访问。有关详细信息,请参见 [IP 访问列表](/cloud/security/setting-ip-filters) 文档。 + +**在新恢复的 ClickHouse 服务上(托管恢复数据的系统)** + +:::note +您需要重置新服务的密码以便访问。您可以从服务列表的 **设置** 选项卡中进行此操作。 +::: + +添加一个只读用户,可以读取源表(在此示例中为 `db.table`): + +```sql +CREATE USER exporter +IDENTIFIED WITH SHA256_PASSWORD BY 'password-here' +SETTINGS readonly = 1; +``` + +```sql +GRANT SELECT ON db.table TO exporter; +``` + +复制表定义: + +```sql +SELECT create_table_query +FROM system.tables +WHERE database = 'db' AND table = 'table' +``` + +**在目标 ClickHouse Cloud 系统上(损坏表的系统):** + +创建目标数据库: +```sql +CREATE DATABASE db +``` + +使用源的 `CREATE TABLE` 语句创建目标: + +:::tip +在运行 `CREATE` 语句时,将 `ENGINE` 更改为 `ReplicatedMergeTree`,不带任何参数。ClickHouse Cloud 始终复制表并提供正确的参数。 +::: + +```sql +CREATE TABLE db.table ... +ENGINE = ReplicatedMergeTree +ORDER BY ... +``` + +使用 `remoteSecure` 函数将数据从新恢复的 ClickHouse Cloud 服务提取到您的原始服务中: + +```sql +INSERT INTO db.table +SELECT * +FROM remoteSecure('source-hostname', db, table, 'exporter', 'password-here') +``` + +成功将数据插入原始服务后,请确保验证服务中的数据。数据验证后,您也应删除新服务。 + +## 未删除或未丢弃表 {#undeleting-or-undropping-tables} + + + +在 ClickHouse Cloud 中不支持 `UNDROP` 命令。如果您意外 `DROP` 了一个表,最好的做法是从最后的备份中恢复并重新创建该表。 + +为了防止用户不小心丢弃表,您可以使用 [`GRANT` 语句](/sql-reference/statements/grant) 撤销特定用户或角色对 [`DROP TABLE` 命令](/sql-reference/statements/drop#drop-table) 的权限。 + +:::note +请注意,默认情况下,在 ClickHouse Cloud 中无法删除超过`1TB`大小的表。 +如果您希望删除超过此阈值的表,可以使用设置 `max_table_size_to_drop` 来实现: + +```sql +DROP TABLE IF EXISTS table_to_drop +SYNC SETTINGS max_table_size_to_drop=2000000000000 -- increases the limit to 2TB +``` +::: + +:::note +遗留计划:对于使用遗留计划的客户,默认的每日备份保留24小时,已包含在存储成本中。 +::: + +## 可配置的备份 {#configurable-backups} + +如果您希望设置不同于默认备份调度的备份计划,请查看 [可配置的备份](./configurable-backups.md)。 + +## 将备份导出到您的云帐户 {#export-backups-to-your-own-cloud-account} + +有关希望将备份导出到自己云帐户的用户,请参见 [这里](./export-backups-to-own-cloud-account.md)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/08_backups/overview.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/08_backups/overview.md.hash new file mode 100644 index 00000000000..5096e74c278 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/08_backups/overview.md.hash @@ -0,0 +1 @@ +97a660e4d50f00a0 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/support.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/09_support.md similarity index 68% rename from i18n/zh/docusaurus-plugin-content-docs/current/cloud/support.md rename to i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/09_support.md index 56b729fa751..8a26eee16fa 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/support.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/09_support.md @@ -1,9 +1,10 @@ --- 'sidebar_label': '云支持' -'title': '云支持' +'title': '支持' 'slug': '/cloud/support' -'description': '了解云支持' +'description': '了解关于云支持的信息' 'hide_title': true +'doc_type': 'guide' --- import Content from '@site/i18n/zh/docusaurus-plugin-content-docs/current/about-us/support.md'; diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/09_support.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/09_support.md.hash new file mode 100644 index 00000000000..bec4ac57f1d --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/09_support.md.hash @@ -0,0 +1 @@ +a2b7ade2dc463cc3 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/_category_.json b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/_category_.json new file mode 100644 index 00000000000..383c8150644 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/features/_category_.json @@ -0,0 +1,5 @@ +{ + "label": "Features", + "collapsible": true, + "collapsed": true, +} \ No newline at end of file diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/get-started/cloud-quick-start.mdx b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/get-started/cloud-quick-start.mdx deleted file mode 100644 index 693212ad3a6..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/get-started/cloud-quick-start.mdx +++ /dev/null @@ -1,328 +0,0 @@ ---- -'sidebar_position': 1 -'slug': '/cloud/get-started/cloud-quick-start' -'sidebar_label': 'Cloud 快速入门' -'keywords': -- 'clickhouse' -- 'install' -- 'getting started' -- 'quick start' -'pagination_next': 'cloud/get-started/sql-console' -'title': 'ClickHouse Cloud 快速入门' -'description': 'ClickHouse Cloud 的快速入门指南' ---- - -import Image from '@theme/IdealImage'; -import signup_page from '@site/static/images/_snippets/signup_page.png'; -import select_plan from '@site/static/images/_snippets/select_plan.png'; -import createservice1 from '@site/static/images/_snippets/createservice1.png'; -import scaling_limits from '@site/static/images/_snippets/scaling_limits.png'; -import createservice8 from '@site/static/images/_snippets/createservice8.png'; -import show_databases from '@site/static/images/_snippets/show_databases.png'; -import service_connect from '@site/static/images/_snippets/service_connect.png'; -import data_sources from '@site/static/images/_snippets/data_sources.png'; -import select_data_source from '@site/static/images/_snippets/select_data_source.png'; -import client_details from '@site/static/images/_snippets/client_details.png'; -import new_rows_from_csv from '@site/static/images/_snippets/new_rows_from_csv.png'; -import SQLConsoleDetail from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_launch_sql_console.md'; - - -# ClickHouse Cloud 快速入门 - -使用 ClickHouse 最快和最简单的方法是创建一个新的 -服务在 [ClickHouse Cloud](https://console.clickhouse.cloud)。 - - - -## 创建一个 ClickHouse 服务 {#1-create-a-clickhouse-service} - -要在 [ClickHouse Cloud](https://console.clickhouse.cloud) 中创建一个免费的 ClickHouse 服务,您只需通过完成以下步骤进行注册: - - - 在 [注册页面](https://console.clickhouse.cloud/signUp) 上创建一个账户 - - 您可以选择使用电子邮件或通过 Google SSO、Microsoft SSO、AWS Marketplace、Google Cloud 或 Microsoft Azure 进行注册 - - 如果您选择使用电子邮件和密码注册,请记得在接下来的 24 小时内通过您电子邮件中收到的链接验证您的电子邮件地址 - - 使用您刚刚创建的用户名和密码登录 - -选择计划 -
- -登录后,ClickHouse Cloud 会启动入职向导,引导您创建新的 ClickHouse 服务。您将最初被要求 [选择一个计划](/cloud/manage/cloud-tiers): - -选择计划 -
- -:::tip -我们建议大多数工作负载使用 Scale 级别。 -有关级别的更多详细信息,请参见 [这里](/cloud/manage/cloud-tiers) -::: - -选择一个计划需要您选择希望部署第一个服务的区域。 -可用的确切选项将取决于所选的级别。 -在以下步骤中,我们假设用户选择了推荐的 Scale 级别。 - -选择您想要部署服务的区域,并给您的新服务命名: - -新 ClickHouse 服务 -
- -默认情况下,Scale 级别将创建每个具有 4 个 VCPU 和 16 GiB RAM 的 3 个副本。Scale 级别将默认启用 [垂直自动扩展](/manage/scaling#vertical-auto-scaling)。 - -用户可以根据需要自定义服务资源,指定副本的最小和最大大小以实现扩展。当准备就绪时,选择 `创建服务`。 - -扩展限制 -
- -恭喜!您的 ClickHouse Cloud 服务已启动并已完成入职。继续阅读以获取有关如何开始数据摄取和查询的详细信息。 - -## 连接到 ClickHouse {#2-connect-to-clickhouse} -有两种方法可以连接到 ClickHouse: - - 使用我们的基于web的 SQL 控制台进行连接 - - 使用您的应用程序进行连接 -
-### 使用 SQL 控制台进行连接 {#connect-using-sql-console} - -为了快速入门,ClickHouse 提供了一个基于web的 SQL 控制台,您将在完成入职后被重定向到该控制台。 - -SQL 控制台 - -创建一个查询标签并输入一个简单查询以验证您的连接是否正常: - -```sql -SHOW databases -``` - -您应该在列表中看到 4 个数据库,此外还有您可能添加的任何其他数据库。 - -SQL 控制台 -
- -就这样 - 您已经准备好开始使用您的新 ClickHouse 服务! - -### 使用您的应用程序进行连接 {#connect-with-your-app} - -从导航菜单中按连接按钮。将打开一个模态窗口,提供您服务的凭据,并为您提供如何使用您的接口或语言客户端连接的说明。 - -服务连接 -
- -如果您无法看到您的语言客户端,您可能想查看我们的 [集成列表](/integrations)。 - -## 添加数据 {#3-add-data} - -ClickHouse 在有数据时表现更好!有多种方法可以添加数据,其中大多数可以在数据源页面上找到,该页面可以通过导航菜单访问。 - -数据源 -
- -您可以使用以下方法上传数据: - - 设置 ClickPipe以开始从 S3、Postgres、Kafka、GCS 等数据源摄取数据 - - 使用 SQL 控制台 - - 使用 ClickHouse 客户端 - - 上传文件 - 支持格式包括 JSON、CSV 和 TSV - - 从文件 URL 上传数据 - -### ClickPipes {#clickpipes} - -[ClickPipes](http://clickhouse.com/docs/integrations/clickpipes) 是一个管理集成平台,使从多种来源摄取数据变得简单,只需单击几个按钮。ClickPipes 的强大和可扩展架构确保了一致的性能和可靠性,非常适合最要求的工作负载。ClickPipes 可用于长期流式传输需求或一次性数据加载作业。 - -选择数据源 -
- -### 使用 SQL 控制台添加数据 {#add-data-using-the-sql-console} - -像大多数数据库管理系统一样,ClickHouse 将表 logically group 成 **数据库**。使用 [`CREATE DATABASE`](../../sql-reference/statements/create/database.md) 命令在 ClickHouse 中创建一个新数据库: - -```sql -CREATE DATABASE IF NOT EXISTS helloworld -``` - -运行以下命令在 `helloworld` 数据库中创建一个名为 `my_first_table` 的表: - -```sql -CREATE TABLE helloworld.my_first_table -( - user_id UInt32, - message String, - timestamp DateTime, - metric Float32 -) -ENGINE = MergeTree() -PRIMARY KEY (user_id, timestamp) -``` - -在上述示例中,`my_first_table` 是一个 [`MergeTree`](../../engines/table-engines/mergetree-family/mergetree.md) 表,具有四个列: - - - `user_id`: 一个 32 位无符号整数 ([UInt32](../../sql-reference/data-types/int-uint.md)) - - `message`: 一个 [String](../../sql-reference/data-types/string.md) 数据类型,替代了其他数据库系统中的 `VARCHAR`、`BLOB`、`CLOB` 等类型 - - `timestamp`: 一个 [DateTime](../../sql-reference/data-types/datetime.md) 值,表示某个时刻 - - `metric`: 一个 32 位浮点数 ([Float32](../../sql-reference/data-types/float.md)) - -:::note 表引擎 -表引擎确立了: - - 数据的存储方式和位置 - - 支持哪些查询 - - 数据是否被复制 -
-有许多表引擎可供选择,但对于单节点 ClickHouse 服务器上的简单表,[`MergeTree`](/engines/table-engines/mergetree-family/mergetree.md) 是您可能的选择。 -::: - -#### 主键简介 {#a-brief-intro-to-primary-keys} - -在您继续之前,重要的是要了解 ClickHouse 中主键的工作方式(主键的实现可能会让您感到意外!): - - - ClickHouse 中的主键在表中的每一行并 **_不唯一_** - -ClickHouse 表的主键决定了数据写入磁盘时的排序方式。每 8,192 行或 10MB 数据(称为 **索引粒度**)会在主键索引文件中创建一个条目。这个粒度概念 创建了一个 **稀疏索引**,可以很容易地放入内存,粒度代表在 `SELECT` 查询期间处理的最少列数据条带。 - -可以使用 `PRIMARY KEY` 参数定义主键。如果您定义一个没有指定 `PRIMARY KEY` 的表,则键成为 `ORDER BY` 子句中指定的元组。如果您同时指定了 `PRIMARY KEY` 和 `ORDER BY`,则主键必须是排序顺序的一个子集。 - -主键也是排序键,它是一个 `(user_id, timestamp)` 的元组。因此,存储在每个 列文件中的数据将按 `user_id`,然后按 `timestamp` 排序。 - -有关核心 ClickHouse 概念的深度探讨,请参阅 ["核心概念"](../../managing-data/core-concepts/index.md)。 - -#### 向您的表中插入数据 {#insert-data-into-your-table} - -您可以使用熟悉的 [`INSERT INTO TABLE`](../../sql-reference/statements/insert-into.md) 命令与 ClickHouse,但重要的是要理解每次插入一个 [`MergeTree`](/engines/table-engines/mergetree-family/mergetree.md) 表时都会在存储中创建一个 **部分**。 - -:::tip ClickHouse 最佳实践 -每批插入大量行 - 一次数万行或数百万行。不要担心 - ClickHouse 可以轻松处理这种体量 - 而且它将通过向您的服务发送更少的写请求来 [为您节省资金](/best-practices/selecting-an-insert-strategy#batch-inserts-if-synchronous)。 -::: - -
- -即使是一个简单的示例,让我们一次插入多于一行: - -```sql -INSERT INTO helloworld.my_first_table (user_id, message, timestamp, metric) VALUES - (101, 'Hello, ClickHouse!', now(), -1.0 ), - (102, 'Insert a lot of rows per batch', yesterday(), 1.41421 ), - (102, 'Sort your data based on your commonly-used queries', today(), 2.718 ), - (101, 'Granules are the smallest chunks of data read', now() + 5, 3.14159 ) -``` - -:::note -注意 `timestamp` 列通过各种 [**Date**](../../sql-reference/data-types/date.md) 和 [**DateTime**](../../sql-reference/data-types/datetime.md) 函数填充。ClickHouse 拥有数百个实用函数,您可以在 [**函数**部分](/sql-reference/functions/) 中查看。 -::: - -让我们验证一下是否成功: - -```sql -SELECT * FROM helloworld.my_first_table -``` - -### 使用 ClickHouse 客户端添加数据 {#add-data-using-the-clickhouse-client} - -您还可以使用名为 [**clickhouse client**](/interfaces/cli) 的命令行工具连接到您的 ClickHouse Cloud 服务。单击左侧菜单中的 `连接` 以访问这些详细信息。从对话框中选择 `Native`。 - -clickhouse client 连接详细信息 -
- -1. 安装 [ClickHouse](/interfaces/cli)。 - -2. 运行命令,替换您的主机名、用户名和密码: - -```bash -./clickhouse client --host HOSTNAME.REGION.CSP.clickhouse.cloud \ ---secure --port 9440 \ ---user default \ ---password -``` -如果您看到微笑表情符号提示,您就可以运行查询了! -```response -:) -``` - -3. 尝试运行以下查询: - -
- -```sql -SELECT * -FROM helloworld.my_first_table -ORDER BY timestamp -``` - -注意响应以漂亮的表格格式返回: - -```response -┌─user_id─┬─message────────────────────────────────────────────┬───────────timestamp─┬──metric─┐ -│ 102 │ Insert a lot of rows per batch │ 2022-03-21 00:00:00 │ 1.41421 │ -│ 102 │ Sort your data based on your commonly-used queries │ 2022-03-22 00:00:00 │ 2.718 │ -│ 101 │ Hello, ClickHouse! │ 2022-03-22 14:04:09 │ -1 │ -│ 101 │ Granules are the smallest chunks of data read │ 2022-03-22 14:04:14 │ 3.14159 │ -└─────────┴────────────────────────────────────────────────────┴─────────────────────┴─────────┘ - -4 rows in set. Elapsed: 0.008 sec. -``` - -4. 添加一个 [`FORMAT`](../../sql-reference/statements/select/format.md) 子句来指定 [ClickHouse 支持的多种输出格式之一](/interfaces/formats/): - -
- -```sql -SELECT * -FROM helloworld.my_first_table -ORDER BY timestamp -FORMAT TabSeparated -``` -在上述查询中,输出作为制表符分隔返回: -```response -Query id: 3604df1c-acfd-4117-9c56-f86c69721121 - -102 Insert a lot of rows per batch 2022-03-21 00:00:00 1.41421 -102 Sort your data based on your commonly-used queries 2022-03-22 00:00:00 2.718 -101 Hello, ClickHouse! 2022-03-22 14:04:09 -1 -101 Granules are the smallest chunks of data read 2022-03-22 14:04:14 3.14159 - -4 rows in set. Elapsed: 0.005 sec. -``` - -5. 要退出 `clickhouse client`,输入 **exit** 命令: - -
- -```bash -exit -``` - -### 上传文件 {#upload-a-file} - -开始使用数据库时一项常见任务是插入您已经存在于文件中的一些数据。我们有一些在线示例数据,可以插入,表示点击流数据 - 包括用户 ID、访问的 URL 和事件的时间戳。 - -假设我们在名为 `data.csv` 的 CSV 文件中有以下文本: - -```bash title="data.csv" -102,This is data in a file,2022-02-22 10:43:28,123.45 -101,It is comma-separated,2022-02-23 00:00:00,456.78 -103,Use FORMAT to specify the format,2022-02-21 10:43:30,678.90 -``` - -1. 以下命令将数据插入到 `my_first_table`: - -
- -```bash -./clickhouse client --host HOSTNAME.REGION.CSP.clickhouse.cloud \ ---secure --port 9440 \ ---user default \ ---password \ ---query='INSERT INTO helloworld.my_first_table FORMAT CSV' < data.csv -``` - -2. 如果从 SQL 控制台查询,现在注意新行出现在表中: - -
- -来自 CSV 文件的新行 -
- -
- -## 接下来怎么做? {#whats-next} - -- [教程](/tutorial.md) 指导您向表插入 200 万行并编写一些分析查询 -- 我们有一个 [示例数据集列表](/getting-started/index.md),里面有如何插入它们的说明 -- 查看我们关于 [ClickHouse 入门的 25 分钟视频](https://clickhouse.com/company/events/getting-started-with-clickhouse/) -- 如果您的数据来自外部来源,可以查看我们的 [集成指南集合](/integrations/index.mdx),帮助您连接消息队列、数据库、管道等 -- 如果您使用 UI/BI 可视化工具,请查看 [连接 UI 到 ClickHouse 的用户指南](/integrations/data-visualization) -- 关于 [主键](/guides/best-practices/sparse-primary-indexes.md) 的用户指南是您需要知道的关于主键及其定义的所有内容 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/get-started/cloud-quick-start.mdx.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/get-started/cloud-quick-start.mdx.hash deleted file mode 100644 index 920a1a2fa37..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/get-started/cloud-quick-start.mdx.hash +++ /dev/null @@ -1 +0,0 @@ -334f9f4b187c4ae0 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/get-started/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/get-started/index.md deleted file mode 100644 index d49d3ebaaa6..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/get-started/index.md +++ /dev/null @@ -1,24 +0,0 @@ ---- -'slug': '/cloud/get-started' -'title': '开始使用' -'description': '开始使用 目录' -'keywords': -- 'Cloud Quick Start' -- 'SQL Console' -- 'Query Insights' -- 'Query API Endpoints' -- 'Dashboards' -- 'Cloud Support' ---- - -欢迎来到 ClickHouse Cloud!浏览以下页面以了解 ClickHouse Cloud 提供的内容。 - -| 页面 | 描述 | -|--------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------| -| [概述](/cloud/overview) | 使用 ClickHouse Cloud 的好处概述,以及它使用的 ClickHouse 版本。 | -| [Cloud 快速入门](/cloud/get-started/cloud-quick-start) | 快速入门指南,帮助您快速启动和运行 Cloud。 | -| [SQL 控制台](/cloud/get-started/sql-console) | 了解 Cloud 中可用的交互式 SQL 控制台 | -| [查询洞察](/cloud/get-started/query-insights) | 了解 Cloud 的查询洞察功能如何通过各种可视化和表格使 ClickHouse 内置查询日志更易于使用。 | -| [查询端点](/cloud/get-started/query-endpoints) | 了解查询 API 端点功能,该功能允许您直接从 ClickHouse Cloud 控制台中任何保存的 SQL 查询创建 API 端点。 | -| [仪表板](/cloud/manage/dashboards) | 了解 SQL 控制台的仪表板功能如何允许您收集和共享来自保存查询的可视化内容。 | -| [Cloud 支持](/cloud/support) | 了解更多关于 ClickHouse Cloud 用户和客户的支持服务。 | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/get-started/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/get-started/index.md.hash deleted file mode 100644 index 68858b04518..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/get-started/index.md.hash +++ /dev/null @@ -1 +0,0 @@ -b8fcec8e00383a0d diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/get-started/query-endpoints.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/get-started/query-endpoints.md.hash deleted file mode 100644 index 0a346951535..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/get-started/query-endpoints.md.hash +++ /dev/null @@ -1 +0,0 @@ -2efed77deefef909 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/get-started/query-insights.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/get-started/query-insights.md deleted file mode 100644 index a173316c09e..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/get-started/query-insights.md +++ /dev/null @@ -1,57 +0,0 @@ ---- -'sidebar_title': 'Query Insights' -'slug': '/cloud/get-started/query-insights' -'description': '可视化 system.query_log 数据,以简化查询调试和性能优化' -'keywords': -- 'query insights' -- 'query log' -- 'query log ui' -- 'system.query_log insights' -'title': '查询洞察' ---- - -import Image from '@theme/IdealImage'; -import insights_overview from '@site/static/images/cloud/sqlconsole/insights_overview.png'; -import insights_latency from '@site/static/images/cloud/sqlconsole/insights_latency.png'; -import insights_recent from '@site/static/images/cloud/sqlconsole/insights_recent.png'; -import insights_drilldown from '@site/static/images/cloud/sqlconsole/insights_drilldown.png'; -import insights_query_info from '@site/static/images/cloud/sqlconsole/insights_query_info.png'; - - -# 查询洞察 - -**查询洞察**功能通过各种可视化和表格使 ClickHouse 内置的查询日志更易于使用。 ClickHouse 的 `system.query_log` 表是查询优化、调试和监控整体集群健康状况及性能的重要信息来源。 - -## 查询概览 {#query-overview} - -选择服务后,左侧边栏中的 **监控** 导航项应展开以显示新的 **查询洞察** 子项。点击此选项会打开新的查询洞察页面: - -查询洞察 UI 概览 - -## 顶层指标 {#top-level-metrics} - -顶部的统计框代表在所选时间段内的一些基本顶层查询指标。在其下方,我们展示了三种时间序列图表,分别代表查询量、延迟和按查询类型(选择、插入、其他)细分的错误率,展示所选的时间窗口内的数据。延迟图表还可以进一步调整,以显示 p50、p90 和 p99 延迟: - -查询洞察 UI 延迟图表 - -## 最近查询 {#recent-queries} - -在顶层指标下方,表格显示所选时间窗口内的查询日志条目(按标准化查询哈希和用户分组): - -查询洞察 UI 最近查询表格 - -最近查询可以按任何可用字段进行过滤和排序。该表也可以配置以显示或隐藏其他字段,如表格、p90 和 p99 延迟。 - -## 查询深入分析 {#query-drill-down} - -从最近查询表中选择一个查询将打开一个飞出窗口,其中包含与所选查询特定的指标和信息: - -查询洞察 UI 查询深入分析 - -从飞出窗口中可以看到,该查询在过去 24 小时内已运行超过 3000 次。**查询信息**标签中的所有指标都是聚合指标,但我们还可以通过选择 **查询历史** 标签来查看单次运行的指标: - -查询洞察 UI 查询信息 - -
- -在此窗格中,每次查询运行的 `设置` 和 `配置事件` 项目可以展开以显示额外信息。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/get-started/query-insights.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/get-started/query-insights.md.hash deleted file mode 100644 index 043bd89863a..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/get-started/query-insights.md.hash +++ /dev/null @@ -1 +0,0 @@ -270a16c45145d311 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/get-started/sql-console.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/get-started/sql-console.md.hash deleted file mode 100644 index 0a47d757191..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/get-started/sql-console.md.hash +++ /dev/null @@ -1 +0,0 @@ -09476a9e1e6791b8 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/SQL_console/_category_.json b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/SQL_console/_category_.json new file mode 100644 index 00000000000..07e636bd5ed --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/SQL_console/_category_.json @@ -0,0 +1,5 @@ +{ + "label": "SQL console", + "collapsible": true, + "collapsed": true, +} \ No newline at end of file diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/SQL_console/configure_org_and_service_role_assignments.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/SQL_console/configure_org_and_service_role_assignments.md new file mode 100644 index 00000000000..879192de995 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/SQL_console/configure_org_and_service_role_assignments.md @@ -0,0 +1,84 @@ +--- +'slug': '/cloud/guides/sql-console/configure-org-service-role-assignments' +'sidebar_label': '配置组织和服务角色分配' +'title': '在控制台中配置组织和服务角色分配' +'description': '指南显示如何在控制台中配置 org 和服务角色分配' +'doc_type': 'guide' +--- + +import Image from '@theme/IdealImage'; +import step_1 from '@site/static/images/cloud/guides/sql_console/org_level_access/1_org_settings.png' +import step_2 from '@site/static/images/cloud/guides/sql_console/org_level_access/2_org_settings.png' +import step_3 from '@site/static/images/cloud/guides/sql_console/org_level_access/3_org_settings.png' +import step_4 from '@site/static/images/cloud/guides/sql_console/org_level_access/4_org_settings.png' +import step_5 from '@site/static/images/cloud/guides/sql_console/org_level_access/5_org_settings.png' +import step_6 from '@site/static/images/cloud/guides/sql_console/org_level_access/6_org_settings.png' +import step_7 from '@site/static/images/cloud/guides/sql_console/org_level_access/7_org_settings.png' + + +# 配置控制台中的组织和服务角色分配 + +> 本指南向您展示如何在组织和服务级别配置角色分配。 + + + +## 访问组织设置 {#access-service-settings} + +从服务页面中,选择您组织的名称: + + + +从弹出菜单中选择 `Users and roles` 菜单项。 + + + +## 调整每个用户的访问权限 {#access-per-user} + +选择您希望修改访问权限的用户所在行末尾的菜单项: + + + +选择 `edit`: + + + +页面右侧将显示一个选项卡: + + + +选择下拉菜单项以调整控制台的访问权限和用户可以从 ClickHouse 控制台访问的功能。 +这管理组织的高层次访问和管理设置: + +| 角色 | 描述 | +|-------------|-------------------------------------------------------------------------------| +| `Admin` | 执行组织的所有管理活动,控制所有设置。 | +| `Developer` | 查看除服务外的所有内容,创建具有相同或较低访问权限的 API 密钥。 | +| `Member` | 仅登录,能够管理个人资料设置。 | +| `Billing` | 查看使用情况和发票,并管理付款方式。 | + +选择下拉菜单项以调整所选用户的服务角色访问范围。 +这定义了特定服务的安全和操作设置: + +| 访问范围 | +|---------------------| +| `All services` | +| `Specific services` | +| `No services` | + +当选择 `Specific services` 时,您可以按服务控制用户的角色: + + + +您可以选择以下角色: + +| 角色 | 描述 | +|-------------|-------------------------------------------------------------------| +| `Admin` | 对配置和安全拥有完全控制。可以删除服务。 | +| `Read-only` | 可以查看服务数据和安全设置。无法修改任何内容。 | +| `No access` | 不知道该服务存在。 | + +通过选项卡底部的 `Save changes` 按钮保存您的更改: + + + + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/SQL_console/configure_org_and_service_role_assignments.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/SQL_console/configure_org_and_service_role_assignments.md.hash new file mode 100644 index 00000000000..34139e6d81e --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/SQL_console/configure_org_and_service_role_assignments.md.hash @@ -0,0 +1 @@ +466296969926c23b diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/SQL_console/configure_sql_console_role_assignments.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/SQL_console/configure_sql_console_role_assignments.md new file mode 100644 index 00000000000..007f3a9f3b1 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/SQL_console/configure_sql_console_role_assignments.md @@ -0,0 +1,73 @@ +--- +'slug': '/cloud/guides/sql-console/config-sql-console-role-assignments' +'sidebar_label': '配置 SQL 控制台角色分配' +'title': '配置 SQL 控制台角色分配' +'description': '指南,介绍如何配置 SQL 控制台角色分配' +'doc_type': 'guide' +--- + +import Image from '@theme/IdealImage'; +import step_1 from '@site/static/images/cloud/guides/sql_console/service_level_access/1_service_settings.png' +import step_2 from '@site/static/images/cloud/guides/sql_console/service_level_access/2_service_settings.png' +import step_3 from '@site/static/images/cloud/guides/sql_console/service_level_access/3_service_settings.png' +import step_4 from '@site/static/images/cloud/guides/sql_console/service_level_access/4_service_settings.png' +import step_5 from '@site/static/images/cloud/guides/sql_console/service_level_access/5_service_settings.png' +import step_6 from '@site/static/images/cloud/guides/sql_console/service_level_access/6_service_settings.png' +import step_7 from '@site/static/images/cloud/guides/sql_console/service_level_access/7_service_settings.png' + + +# 配置 SQL 控制台角色分配 + +> 本指南向您展示如何配置 SQL 控制台角色分配,这决定了控制台范围内的访问权限以及用户可以在云控制台中访问的功能。 + + + +## 访问服务设置 {#access-service-settings} + +在服务页面,点击您想要调整 SQL 控制台访问设置的服务右上角的菜单。 + + + +从弹出菜单中选择 `settings`。 + + + +## 调整 SQL 控制台访问 {#adjust-sql-console-access} + +在“安全”部分,找到“SQL 控制台访问”区域: + + + +选择服务管理员的下拉菜单以更改服务管理员角色的访问控制设置: + + + +您可以从以下角色中选择: + +| 角色 | +|---------------| +| `无访问` | +| `只读` | +| `完全访问` | + +选择服务只读的下拉菜单以更改服务只读角色的访问控制设置: + + + +您可以从以下角色中选择: + +| 角色 | +|---------------| +| `无访问` | +| `只读` | +| `完全访问` | + +通过选择用户计数,可以查看该服务的用户概览: + + + +页面右侧将打开一个标签,显示用户总数及其角色: + + + + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/SQL_console/configure_sql_console_role_assignments.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/SQL_console/configure_sql_console_role_assignments.md.hash new file mode 100644 index 00000000000..6d47bcccb95 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/SQL_console/configure_sql_console_role_assignments.md.hash @@ -0,0 +1 @@ +75253896be4e27f3 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/SQL_console/connection_details.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/SQL_console/connection_details.md new file mode 100644 index 00000000000..e515c3da320 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/SQL_console/connection_details.md @@ -0,0 +1,11 @@ +--- +'slug': '/cloud/guides/sql-console/gather-connection-details' +'sidebar_label': '收集您的连接详细信息' +'title': '收集您的连接详细信息' +'description': '收集您的连接详细信息' +'doc_type': 'guide' +--- + +import ConnectionDetails from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_gather_your_details_http.mdx'; + + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/SQL_console/connection_details.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/SQL_console/connection_details.md.hash new file mode 100644 index 00000000000..5eb07ce90ad --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/SQL_console/connection_details.md.hash @@ -0,0 +1 @@ +332ee9c6aeda9d1a diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/bestpractices/_category_.yml b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/_category_.yml similarity index 83% rename from i18n/zh/docusaurus-plugin-content-docs/current/cloud/bestpractices/_category_.yml rename to i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/_category_.yml index 1648e8a79cb..747e5fb1796 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/bestpractices/_category_.yml +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/_category_.yml @@ -1,4 +1,4 @@ -label: 'Best Practices' +label: 'Guides' collapsible: true collapsed: true link: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/best_practices/_category_.json b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/best_practices/_category_.json new file mode 100644 index 00000000000..21f95c55bca --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/best_practices/_category_.json @@ -0,0 +1,5 @@ +{ + "label": "Best practices", + "collapsible": true, + "collapsed": true, +} \ No newline at end of file diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/best_practices/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/best_practices/index.md new file mode 100644 index 00000000000..546b74d9c0f --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/best_practices/index.md @@ -0,0 +1,34 @@ +--- +'slug': '/cloud/bestpractices' +'keywords': +- 'Cloud' +- 'Best Practices' +- 'Bulk Inserts' +- 'Asynchronous Inserts' +- 'Avoid Mutations' +- 'Avoid Nullable Columns' +- 'Avoid Optimize Final' +- 'Low Cardinality Partitioning Key' +- 'Multi Tenancy' +- 'Usage Limits' +'title': '概述' +'hide_title': true +'description': 'ClickHouse Cloud 中最佳实践部分的着陆页' +'doc_type': 'landing-page' +--- + +import TableOfContents from '@site/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/_snippets/_table_of_contents.md'; + + +# Best Practices in ClickHouse Cloud {#best-practices-in-clickhouse-cloud} + +本节提供了您希望遵循的最佳实践,以充分利用 ClickHouse Cloud。 + +| 页面 | 描述 | +|----------------------------------------------------------|-------------------------------------------------------------------------| +| [Usage Limits](/cloud/bestpractices/usage-limits)| 探索 ClickHouse 的限制。 | +| [Multi tenancy](/cloud/bestpractices/multi-tenancy)| 了解实现多租户的不同策略。 | + +这些是适用于所有 ClickHouse 部署的标准最佳实践的补充。 + + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/best_practices/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/best_practices/index.md.hash new file mode 100644 index 00000000000..4ec8ab64bff --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/best_practices/index.md.hash @@ -0,0 +1 @@ +fe26d9e5b9800239 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/bestpractices/multitenancy.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/best_practices/multitenancy.md similarity index 74% rename from i18n/zh/docusaurus-plugin-content-docs/current/cloud/bestpractices/multitenancy.md rename to i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/best_practices/multitenancy.md index 9dcaf17df18..93a70057b35 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/bestpractices/multitenancy.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/best_practices/multitenancy.md @@ -1,33 +1,34 @@ --- 'slug': '/cloud/bestpractices/multi-tenancy' -'sidebar_label': '实现多租户' +'sidebar_label': '多租户' 'title': '多租户' 'description': '实施多租户的最佳实践' +'doc_type': 'guide' --- -在SaaS数据分析平台上,多个租户(如组织、客户或业务部门)共享相同的数据库基础设施,同时保持其数据的逻辑隔离,这种做法是很常见的。这允许不同的用户在同一平台上安全地访问他们自己的数据。 +在SaaS数据分析平台上,多个租户(例如组织、客户或业务部门)共享相同的数据库基础设施,同时保持其数据的逻辑分离是很常见的。这使得不同的用户可以在同一平台上安全地访问自己的数据。 根据需求,有不同的方法来实现多租户。以下是如何在ClickHouse Cloud中实现它们的指南。 ## 共享表 {#shared-table} -在这种方法中,所有租户的数据存储在一个共享表中,使用一个字段(或一组字段)来识别每个租户的数据。为了最大化性能,这个字段应包含在 [主键](/sql-reference/statements/create/table#primary-key) 中。为了确保用户只能访问属于各自租户的数据,我们使用 [基于角色的访问控制](/operations/access-rights),通过 [行策略](/operations/access-rights#row-policy-management) 实现。 +在这种方法中,所有租户的数据存储在一个共享表中,使用一个字段(或一组字段)来标识每个租户的数据。为了最大化性能,这个字段应该包含在[主键](/sql-reference/statements/create/table#primary-key)中。为了确保用户只能访问各自租户的数据,我们使用[基于角色的访问控制](/operations/access-rights),通过[行策略](/operations/access-rights#row-policy-management)来实现。 -> **我们推荐这种方法,因为这是最简单的管理方式,特别是当所有租户共享相同的数据结构且数据量适中(< TBs)时。** +> **我们推荐这种方法,因为这是最简单的管理方式,特别是当所有租户共享相同的数据架构且数据量适中(< TBs)时。** -通过将所有租户数据合并到一个表中,存储效率通过优化的数据压缩和减少的元数据开销得以提高。此外,由于所有数据都在中央管理,模式更新也变得更简单。 +通过将所有租户的数据合并到一个表中,存储效率得到了改善,优化的数据压缩和减少的元数据开销。此外,模式更新得到了简化,因为所有数据都集中管理。 -这种方法特别适合处理大量租户(可能达到数百万)。 +这种方法特别有效,适用于处理大量租户(可能达到数百万)。 -然而,如果租户具有不同的数据模式或预计会随着时间的推移而有所不同,则替代方法可能更为合适。 +然而,如果租户具有不同的数据模式或预计会随着时间的推移而差异,替代的方法可能更合适。 -在租户之间的数据量存在显著差距的情况下,较小的租户可能会遭遇不必要的查询性能影响。请注意,这个问题在很大程度上通过在主键中包含租户字段得以缓解。 +在租户之间的数据量存在显著差距的情况下,较小的租户可能会经历不必要的查询性能影响。请注意,这个问题在很大程度上通过将租户字段包含在主键中得以缓解。 ### 示例 {#shared-table-example} 这是一个共享表多租户模型实现的示例。 -首先,让我们创建一个共享表,并将字段 `tenant_id` 包含在主键中。 +首先,让我们创建一个共享表,其中包含在主键中的字段`tenant_id`。 ```sql --- Create table events. Using tenant_id as part of the primary key @@ -43,7 +44,7 @@ CREATE TABLE events ORDER BY (tenant_id, timestamp) ``` -让我们插入假数据。 +让我们插入虚假数据。 ```sql -- Insert some dummy rows @@ -61,7 +62,7 @@ VALUES (2, '5c150ceb-b869-4ebb-843d-ab42d3cb5410', 'user_login', '2025-03-19 09:00:00', 2004, '{"device": "mobile", "location": "SF"}'), ``` -然后创建两个用户 `user_1` 和 `user_2`。 +然后让我们创建两个用户`user_1`和`user_2`。 ```sql -- Create users @@ -69,7 +70,7 @@ CREATE USER user_1 IDENTIFIED BY '' CREATE USER user_2 IDENTIFIED BY '' ``` -我们 [创建行策略](/sql-reference/statements/create/row-policy),限制 `user_1` 和 `user_2` 仅能访问各自租户的数据。 +我们[创建行策略](/sql-reference/statements/create/row-policy),限制`user_1`和`user_2`仅访问各自租户的数据。 ```sql -- Create row policies @@ -77,7 +78,7 @@ CREATE ROW POLICY user_filter_1 ON default.events USING tenant_id=1 TO user_1 CREATE ROW POLICY user_filter_2 ON default.events USING tenant_id=2 TO user_2 ``` -然后通过一个公共角色对共享表使用 [`GRANT SELECT`](/sql-reference/statements/grant#usage) 权限。 +然后使用一个公共角色对共享表进行[`GRANT SELECT`](/sql-reference/statements/grant#usage)权限。 ```sql -- Create role @@ -89,7 +90,7 @@ GRANT user_role TO user_1 GRANT user_role TO user_2 ``` -现在,你可以以 `user_1` 身份连接,并运行一个简单的选择。仅返回第一个租户的行。 +现在您可以以`user_1`的身份连接并运行简单的选择。只返回第一个租户的行。 ```sql -- Logged as user_1 @@ -105,21 +106,21 @@ FROM events └───────────┴──────────────────────────────────────┴─────────────┴─────────────────────┴─────────┴─────────────────────────────────────────┘ ``` -## 单独表 {#separate-tables} +## 独立表 {#separate-tables} -在这种方法中,每个租户的数据存储在同一数据库中的一个单独表中,消除了识别租户的特定字段的需要。用户访问通过 [GRANT 语句](/sql-reference/statements/grant) 强制执行,确保每个用户只能访问包含其租户数据的表。 +在这种方法中,每个租户的数据存储在同一数据库中的独立表中,无需特定字段来识别租户。用户访问使用[GRANT语句](/sql-reference/statements/grant) enforced,确保每个用户只能访问包含其租户数据的表。 -> **当租户具有不同的数据模式时,使用单独表是一个不错的选择。** +> **当租户具有不同的数据模式时,使用独立表是一个不错的选择。** -对于涉及少量租户且数据集非常大的场景,当查询性能至关重要时,这种方法可能优于共享表模型。由于无需过滤其他租户的数据,因此查询可以更加高效。此外,主键可以进一步优化,因为不需要在主键中包含额外字段(例如租户ID)。 +对于涉及少量具有非常大数据集的租户的场景,如果查询性能至关重要,这种方法可能会优于共享表模型。由于无需过滤其他租户的数据,查询可以更高效。此外,主键可以进一步优化,因为主键中不需要包含额外字段(如租户 ID)。 -请注意,这种方法无法扩展到数千个租户。请参见 [使用限制](/cloud/bestpractices/usage-limits)。 +请注意,此方法对于1000个以上的租户不具备扩展性。请参见[使用限制](/cloud/bestpractices/usage-limits)。 ### 示例 {#separate-tables-example} -这是一个单独表多租户模型实现的示例。 +这是一个独立表多租户模型实现的示例。 -首先,让我们创建两个表,一个用于 `tenant_1` 的事件,另一个用于 `tenant_2` 的事件。 +首先,让我们为`tenant_1`创建一个事件表,并为`tenant_2`创建一个事件表。 ```sql -- Create table for tenant 1 @@ -145,7 +146,7 @@ CREATE TABLE events_tenant_2 ORDER BY (timestamp, user_id) -- Primary key can focus on other attributes ``` -让我们插入假数据。 +让我们插入虚假数据。 ```sql INSERT INTO events_tenant_1 (id, type, timestamp, user_id, data) @@ -165,7 +166,7 @@ VALUES ('5c150ceb-b869-4ebb-843d-ab42d3cb5410', 'user_login', '2025-03-19 09:00:00', 2004, '{"device": "mobile", "location": "SF"}') ``` -然后让我们创建两个用户 `user_1` 和 `user_2`。 +然后我们创建两个用户`user_1`和`user_2`。 ```sql -- Create users @@ -173,7 +174,7 @@ CREATE USER user_1 IDENTIFIED BY '' CREATE USER user_2 IDENTIFIED BY '' ``` -然后对相应表 `GRANT SELECT` 权限。 +然后对相应表授予`GRANT SELECT`权限。 ```sql -- Grant read only to events table. @@ -181,7 +182,7 @@ GRANT SELECT ON default.events_tenant_1 TO user_1 GRANT SELECT ON default.events_tenant_2 TO user_2 ``` -现在你可以以 `user_1` 身份连接,并从与该用户对应的表中运行一个简单的选择。仅返回第一个租户的行。 +现在您可以以`user_1`的身份连接并从该用户对应的表中运行简单选择。只返回第一个租户的行。 ```sql -- Logged as user_1 @@ -197,21 +198,21 @@ FROM default.events_tenant_1 └──────────────────────────────────────┴─────────────┴─────────────────────┴─────────┴─────────────────────────────────────────┘ ``` -## 单独数据库 {#separate-databases} +## 独立数据库 {#separate-databases} -每个租户的数据存储在同一ClickHouse服务中的一个单独数据库中。 +每个租户的数据存储在同一ClickHouse服务中的独立数据库中。 -> **这种方法对于每个租户需要大量表和可能的物化视图,并且具有不同数据模式的情况很有用。然而,如果租户数量较多,管理起来可能会变得具有挑战性。** +> **当每个租户需要大量表和可能的物化视图,并且具有不同的数据架构时,这种方法非常有用。然而,如果租户数量较大,管理起来可能会变得具有挑战性。** -实施类似于单独表的方法,但不是在表级别授予权限,而是在数据库级别授予权限。 +该实现与独立表方法相似,但不是在表级别授予权限,而是在数据库级别授予权限。 -请注意,这种方法无法扩展到数千个租户。请参见 [使用限制](/cloud/bestpractices/usage-limits)。 +请注意,此方法对于1000个以上的租户不具备扩展性。请参见[使用限制](/cloud/bestpractices/usage-limits)。 ### 示例 {#separate-databases-example} -这是一个单独数据库多租户模型实现的示例。 +这是一个独立数据库多租户模型实现的示例。 -首先,让我们为 `tenant_1` 创建一个数据库,为 `tenant_2` 创建另一个数据库。 +首先,我们创建两个数据库,一个用于`tenant_1`,一个用于`tenant_2`。 ```sql -- Create database for tenant_1 @@ -245,7 +246,7 @@ CREATE TABLE tenant_2.events ORDER BY (timestamp, user_id); ``` -让我们插入假数据。 +让我们插入虚假数据。 ```sql INSERT INTO tenant_1.events (id, type, timestamp, user_id, data) @@ -265,7 +266,7 @@ VALUES ('5c150ceb-b869-4ebb-843d-ab42d3cb5410', 'user_login', '2025-03-19 09:00:00', 2004, '{"device": "mobile", "location": "SF"}') ``` -然后让我们创建两个用户 `user_1` 和 `user_2`。 +然后我们创建两个用户`user_1`和`user_2`。 ```sql -- Create users @@ -273,7 +274,7 @@ CREATE USER user_1 IDENTIFIED BY '' CREATE USER user_2 IDENTIFIED BY '' ``` -然后对相应表 `GRANT SELECT` 权限。 +然后对相应表授予`GRANT SELECT`权限。 ```sql -- Grant read only to events table. @@ -281,7 +282,7 @@ GRANT SELECT ON tenant_1.events TO user_1 GRANT SELECT ON tenant_2.events TO user_2 ``` -现在你可以以 `user_1` 身份连接,并在适当数据库的事件表上运行一个简单的选择。仅返回第一个租户的行。 +现在您可以以`user_1`的身份连接并在相应数据库的事件表上运行简单选择。只返回第一个租户的行。 ```sql -- Logged as user_1 @@ -299,27 +300,27 @@ FROM tenant_1.events ## 计算-计算分离 {#compute-compute-separation} -上述三种方法也可以通过使用 [Warehouses](/cloud/reference/warehouses#what-is-a-warehouse) 进一步隔离。数据通过公共对象存储共享,但每个租户可以拥有自己的计算服务,thanks to [计算-计算分离](/cloud/reference/warehouses#what-is-compute-compute-separation),使用不同的CPU/内存比率。 +上述三种方法还可以通过使用[仓库](/cloud/reference/warehouses#what-is-a-warehouse)进一步隔离。数据通过公共对象存储共享,但每个租户可以拥有自己的计算服务,借助[计算-计算分离](/cloud/reference/warehouses#what-is-compute-compute-separation)使用不同的CPU/内存比率。 -用户管理与之前描述的方法相似,因为仓库中的所有服务 [共享访问控制](/cloud/reference/warehouses#database-credentials)。 +用户管理与之前描述的方法类似,因为仓库中的所有服务[共享访问控制](/cloud/reference/warehouses#database-credentials)。 -请注意,仓库中子服务的数量限制为少数。参见 [仓库限制](/cloud/reference/warehouses#limitations)。 +请注意,仓库中子服务的数量有限制。请见[仓库限制](/cloud/reference/warehouses#limitations)。 -## 单独云服务 {#separate-service} +## 独立云服务 {#separate-service} 最激进的方法是为每个租户使用不同的ClickHouse服务。 -> **这种不太常见的方法将是一个解决方案,如果租户的数据需要存储在不同的区域——出于法律、安全或接近性原因。** +> **这种不太常见的方法是指在法律、安全或接近性的原因下,租户数据需要存储在不同地区的解决方案。** -必须在每个服务上创建用户帐户,用户可以访问各自租户的数据。 +必须在每个服务上创建一个用户帐户,以便用户可以访问各自租户的数据。 -这种方法的管理更加复杂,并且每个服务都有额外的负担,因为它们每个都需要自己的基础设施来运行。可以通过 [ClickHouse Cloud API](/cloud/manage/api/api-overview) 管理服务,同时也可以通过 [官方Terraform提供程序](https://registry.terraform.io/providers/ClickHouse/clickhouse/latest/docs) 进行编排。 +这种方法更难以管理,并且带来每个服务的额外开销,因为它们各自需要自己的基础设施来运行。可以通过[ClickHouse Cloud API](/cloud/manage/api/api-overview)管理服务,使用[官方Terraform提供程序](https://registry.terraform.io/providers/ClickHouse/clickhouse/latest/docs)也可以进行编排。 ### 示例 {#separate-service-example} -这是一个单独服务多租户模型实现的示例。请注意,示例展示了在一个ClickHouse服务上创建表和用户,所有服务上都必须复制相同的操作。 +这是一个独立服务多租户模型实现的示例。请注意,示例显示在一个ClickHouse服务上创建表和用户,必须在所有服务上进行复制。 -首先,让我们创建表 `events` +首先,我们创建表`events`。 ```sql -- Create table for tenant_1 @@ -334,7 +335,7 @@ CREATE TABLE events ORDER BY (timestamp, user_id); ``` -让我们插入假数据。 +让我们插入虚假数据。 ```sql INSERT INTO events (id, type, timestamp, user_id, data) @@ -346,21 +347,21 @@ VALUES ('975fb0c8-55bd-4df4-843b-34f5cfeed0a9', 'user_login', '2025-03-19 08:50:00', 1004, '{"device": "desktop", "location": "LA"}') ``` -然后让我们创建两个用户 `user_1` +然后我们创建两个用户`user_1`。 ```sql -- Create users CREATE USER user_1 IDENTIFIED BY '' ``` -然后对相应表 `GRANT SELECT` 权限。 +然后对相应表授予`GRANT SELECT`权限。 ```sql -- Grant read only to events table. GRANT SELECT ON events TO user_1 ``` -现在你可以在租户1的服务上以 `user_1` 身份连接并运行一个简单的选择。仅返回第一个租户的行。 +现在您可以以`user_1`的身份在租户1的服务上连接并运行简单选择。只返回第一个租户的行。 ```sql -- Logged as user_1 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/best_practices/multitenancy.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/best_practices/multitenancy.md.hash new file mode 100644 index 00000000000..e447784b833 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/best_practices/multitenancy.md.hash @@ -0,0 +1 @@ +39f5febb0f1275c5 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/best_practices/usagelimits.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/best_practices/usagelimits.md new file mode 100644 index 00000000000..8cba88a8bdd --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/best_practices/usagelimits.md @@ -0,0 +1,33 @@ +--- +'slug': '/cloud/bestpractices/usage-limits' +'sidebar_label': '服务限制' +'title': '使用限制' +'description': '描述了 ClickHouse Cloud 中推荐的使用限制' +'doc_type': 'reference' +--- + +虽然 ClickHouse 以其速度和可靠性而闻名,但在特定的操作参数内才能实现最佳性能。例如,拥有过多的表、数据库或分片可能会对性能产生负面影响。为了防止这种情况,ClickHouse Cloud 在多个操作维度上强制实施限制。以下是这些保护措施的详细信息。 + +:::tip +如果您遇到了这些保护措施中的一个,可能是您以未优化的方式实现了您的用例。请联系我们的支持团队,我们将乐意帮助您完善用例,以避免超过这些保护措施,或者一起探讨如何以受控制的方式增加这些限制。 +::: + +| 维度 | 限制 | +|-------------------------------|------------------------------------------------------------| +| **数据库** | 1000 | +| **表** | 5000 | +| **列** | ∼1000(宽格式优于紧凑格式) | +| **分区** | 50k | +| **分区片段** | 100k 在整个实例中 | +| **分区片段大小** | 150gb | +| **每个组织的服务** | 20(软限制) | +| **每个数据仓库的服务** | 5(软限制) | +| **每个服务的副本** | 20(软限制) | +| **低基数** | 10k 或更少 | +| **每个表的主键** | 4-5 个足够过滤数据的主键 | +| **查询并发** | 1000(每个副本) | +| **批量导入** | 大于 1M 的任何数据将由系统按 1M 行块进行拆分 | + +:::note +对于单副本服务,数据库的最大数量限制为 100,表的最大数量限制为 500。此外,基础层服务的存储限制为 1 TB。 +::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/best_practices/usagelimits.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/best_practices/usagelimits.md.hash new file mode 100644 index 00000000000..1a7907ea3a3 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/best_practices/usagelimits.md.hash @@ -0,0 +1 @@ +667b451d1374b9d2 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/cloud-compatibility.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/cloud-compatibility.md new file mode 100644 index 00000000000..0c3fa0bf82c --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/cloud-compatibility.md @@ -0,0 +1,128 @@ +--- +'slug': '/whats-new/cloud-compatibility' +'sidebar_label': '云兼容性' +'title': '云兼容性' +'description': '本指南提供了在 ClickHouse Cloud 中功能和操作方面的期望概述。' +'doc_type': 'guide' +--- + + +# ClickHouse Cloud 兼容性指南 + +本指南概述了在 ClickHouse Cloud 中的功能与操作预期。虽然 ClickHouse Cloud 基于开源的 ClickHouse 发行版,但在架构和实现上可能存在一些差异。您可能会发现这篇关于 [我们如何从零构建 ClickHouse Cloud](https://clickhouse.com/blog/building-clickhouse-cloud-from-scratch-in-a-year) 的博客有趣且相关。 + +## ClickHouse Cloud 架构 {#clickhouse-cloud-architecture} +ClickHouse Cloud 显著简化了操作开销,并降低了大规模运行 ClickHouse 的成本。您无需提前确定部署规模,设置高可用性的复制,手动对数据进行分片,工作负载增加时扩展服务器,或在不使用时缩减服务器规模——我们为您处理这一切。 + +这些好处是 ClickHouse Cloud 基础架构选择的结果: +- 计算和存储相互分离,因此可以沿独立维度进行自动扩展,这样您就不必在静态实例配置中过度配置存储或计算。 +- 基于对象存储的分层存储和多级缓存提供了几乎无限的扩展能力和良好的性价比,因此您无需提前确定存储分区的规模,也不必担心高昂的存储成本。 +- 默认启用高可用性并透明管理复制,因此您可以专注于构建应用程序或分析数据。 +- 默认启用可变连续工作负载的自动扩展,因此您无需提前确定服务规模,工作负载增加时扩展服务器,或在活动减少时手动缩减服务器。 +- 默认启用间歇性工作负载的无缝休眠。我们会在一段时间的非活动后自动暂停计算资源,并在到达新查询时透明地重新启动它,因此您无需为闲置资源支付费用。 +- 高级扩展控制提供了设置自动扩展上限以控制额外成本的能力,或设置自动扩展下限来为具有特定性能要求的应用预留计算资源。 + +## 功能 {#capabilities} +ClickHouse Cloud 提供了一组经过精心策划的功能,基于 ClickHouse 的开源版本。下表描述了目前在 ClickHouse Cloud 中禁用的一些功能。 + +### DDL 语法 {#ddl-syntax} +大多数情况下,ClickHouse Cloud 的 DDL 语法应与自管理安装中可用的语法相匹配。几个显著的例外: +- 不支持 `CREATE AS SELECT`。作为一种变通方法,我们建议使用 `CREATE ... EMPTY ... AS SELECT`,然后插入到该表中(有关示例,请参见[这篇博客](https://clickhouse.com/blog/getting-data-into-clickhouse-part-1))。 +- 一些实验性语法可能被禁用,例如 `ALTER TABLE ... MODIFY QUERY` 语句。 +- 一些自省功能可能出于安全原因被禁用,例如 `addressToLine` SQL 函数。 +- 请勿在 ClickHouse Cloud 中使用 `ON CLUSTER` 参数——这些是多余的。虽然这些多数是无操作函数,但如果您试图使用 [宏](/operations/server-configuration-parameters/settings#macros),还是会导致错误。宏通常在 ClickHouse Cloud 中不起作用且不必要。 + +### 数据库和表引擎 {#database-and-table-engines} + +ClickHouse Cloud 默认提供高可用、复制的服务。因此,所有数据库和表引擎都是“复制的”。您无需指定“复制”——例如,`ReplicatedMergeTree` 和 `MergeTree` 在 ClickHouse Cloud 中是相同的。 + +**支持的表引擎** + +- ReplicatedMergeTree(默认,当未指定时) +- ReplicatedSummingMergeTree +- ReplicatedAggregatingMergeTree +- ReplicatedReplacingMergeTree +- ReplicatedCollapsingMergeTree +- ReplicatedVersionedCollapsingMergeTree +- MergeTree(转换为 ReplicatedMergeTree) +- SummingMergeTree(转换为 ReplicatedSummingMergeTree) +- AggregatingMergeTree(转换为 ReplicatedAggregatingMergeTree) +- ReplacingMergeTree(转换为 ReplicatedReplacingMergeTree) +- CollapsingMergeTree(转换为 ReplicatedCollapsingMergeTree) +- VersionedCollapsingMergeTree(转换为 ReplicatedVersionedCollapsingMergeTree) +- URL +- View +- MaterializedView +- GenerateRandom +- Null +- Buffer +- Memory +- Deltalake +- Hudi +- MySQL +- MongoDB +- NATS +- RabbitMQ +- PostgreSQL +- S3 + +### 接口 {#interfaces} +ClickHouse Cloud 支持 HTTPS、本地接口和 [MySQL 线协议](/interfaces/mysql)。对更多接口的支持,比如 Postgres,正在开发中。 + +### 字典 {#dictionaries} +字典是在 ClickHouse 中加速查找的流行方式。ClickHouse Cloud 当前支持来自 PostgreSQL、MySQL、远程和本地 ClickHouse 服务器、Redis、MongoDB 和 HTTP 源的字典。 + +### 联邦查询 {#federated-queries} +我们支持用于跨集群通信和与外部自管理 ClickHouse 集群通信的联邦 ClickHouse 查询。ClickHouse Cloud 当前支持使用以下集成引擎的联邦查询: +- Deltalake +- Hudi +- MySQL +- MongoDB +- NATS +- RabbitMQ +- PostgreSQL +- S3 + +某些外部数据库和表引擎的联邦查询,如 SQLite、ODBC、JDBC、Redis、HDFS 和 Hive 目前尚不支持。 + +### 用户定义函数 {#user-defined-functions} + +用户定义函数是 ClickHouse 的一项新功能。ClickHouse Cloud 当前仅支持 SQL UDFs。 + +### 实验性功能 {#experimental-features} + +为确保服务部署的稳定性,ClickHouse Cloud 服务中禁用了实验性功能。 + +### Kafka {#kafka} + +[Kafka 表引擎](/integrations/data-ingestion/kafka/index.md)在 ClickHouse Cloud 中未普遍可用。相反,我们建议依赖将 Kafka 连接组件与 ClickHouse 服务分离的架构,以实现职责分离。我们推荐使用 [ClickPipes](https://clickhouse.com/cloud/clickpipes) 从 Kafka 流中提取数据。或者,请考虑 [Kafka 用户指南](/integrations/data-ingestion/kafka/index.md) 中列出的基于推送的替代方案。 + +### 命名集合 {#named-collections} + +[命名集合](/operations/named-collections) 当前在 ClickHouse Cloud 中不受支持。 + +## 操作默认值和注意事项 {#operational-defaults-and-considerations} +以下是 ClickHouse Cloud 服务的默认设置。在某些情况下,这些设置是固定的,以确保服务的正确操作,而在其他情况下,它们可以进行调整。 + +### 操作限制 {#operational-limits} + +#### `max_parts_in_total: 10,000` {#max_parts_in_total-10000} +MergeTree 表的 `max_parts_in_total` 设置的默认值已降低从 100,000 至 10,000。更改的原因是我们观察到大量数据部分可能导致云中服务的启动时间变慢。大量部分通常表示选择了过于细粒度的分区键,通常是意外造成的,应当避免。更改默认值将允许更早地检测到这些情况。 + +#### `max_concurrent_queries: 1,000` {#max_concurrent_queries-1000} +将此每服务器设置从默认的 `100` 增加到 `1000`,以允许更多并发。 +这将导致提供的服务层级可处理 `number of replicas * 1,000` 的并发查询。 +对于限于单一副本的基础层服务,支持 `1000` 个并发查询;而对于规模和企业层,支持 `1000+` 个并发查询,具体取决于配置的副本数量。 + +#### `max_table_size_to_drop: 1,000,000,000,000` {#max_table_size_to_drop-1000000000000} +将此设置从 50GB 提高,以允许删除大小达到 1TB 的表/分区。 + +### 系统设置 {#system-settings} +ClickHouse Cloud 针对可变工作负载进行了调整,因此目前大多数系统设置不可配置。我们不预期大多数用户需要调整系统设置,但如果您有关于高级系统调整的问题,请联系 ClickHouse Cloud 支持。 + +### 高级安全管理 {#advanced-security-administration} +在创建 ClickHouse 服务时,我们会创建一个默认数据库,以及一个对此数据库具有广泛权限的默认用户。此初始用户可以创建其他用户并分配其对该数据库的权限。在此之外,使用 Kerberos、LDAP 或 SSL X.509 证书认证启用数据库中的以下安全功能目前不受支持。 + +## 路线图 {#roadmap} + +我们正在 Cloud 中引入可执行 UDFs 的支持,并评估许多其他功能的需求。如果您有反馈并希望请求特定功能,请 [在此提交](https://console.clickhouse.cloud/support)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/cloud-compatibility.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/cloud-compatibility.md.hash new file mode 100644 index 00000000000..9cc5d69228f --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/cloud-compatibility.md.hash @@ -0,0 +1 @@ +9c2ba565c0b4d55c diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/_category_.json b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/_category_.json new file mode 100644 index 00000000000..aed26fa7f7a --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/_category_.json @@ -0,0 +1,5 @@ +{ + "label": "Security", + "collapsible": true, + "collapsed": true, +} \ No newline at end of file diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/cloud_access_management/_category_.json b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/cloud_access_management/_category_.json new file mode 100644 index 00000000000..abfdcebed27 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/cloud_access_management/_category_.json @@ -0,0 +1,5 @@ +{ + "label": "Cloud Access Management", + "collapsible": true, + "collapsed": true, +} \ No newline at end of file diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/common-access-management-queries.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/cloud_access_management/common-access-management-queries.md similarity index 50% rename from i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/common-access-management-queries.md rename to i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/cloud_access_management/common-access-management-queries.md index ade35e3fc78..d2e96f12685 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/common-access-management-queries.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/cloud_access_management/common-access-management-queries.md @@ -1,8 +1,9 @@ --- -'sidebar_label': '通用访问管理查询' -'title': '通用访问管理查询' +'sidebar_label': '常见访问管理查询' +'title': '常见访问管理查询' 'slug': '/cloud/security/common-access-management-queries' -'description': '本文展示了定义 SQL 用户和角色的基础知识,并将这些权限和权限应用于数据库、表、行和列。' +'description': '本文展示了定义 SQL 用户和角色的基础知识,以及将这些权限应用于 DATABASE、TABLE、行和列的方式。' +'doc_type': 'guide' --- import CommonUserRolesContent from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_users-and-roles-common.md'; @@ -11,16 +12,16 @@ import CommonUserRolesContent from '@site/i18n/zh/docusaurus-plugin-content-docs # 常见访问管理查询 :::tip 自管理 -如果您正在使用自管理的 ClickHouse,请参阅 [SQL 用户和角色](/guides/sre/user-management/index.md)。 +如果您正在使用自管理的 ClickHouse,请查看 [SQL 用户和角色](/guides/sre/user-management/index.md)。 ::: -本文介绍了定义 SQL 用户和角色的基础知识,以及将这些权限和权限应用于数据库、表、行和列的方法。 +本文展示了定义 SQL 用户和角色的基础知识,以及如何将这些特权和权限应用于数据库、表、行和列。 ## 管理员用户 {#admin-user} -ClickHouse Cloud 服务有一个管理员用户 `default`,在服务创建时自动生成。密码在服务创建时提供,具有 **Admin** 角色的 ClickHouse Cloud 用户可以重置该密码。 +ClickHouse Cloud 服务有一个管理员用户 `default`,在服务创建时生成。密码在服务创建时提供,具有 **Admin** 角色的 ClickHouse Cloud 用户可以重置密码。 -当您为 ClickHouse Cloud 服务添加其他 SQL 用户时,他们需要一个 SQL 用户名和密码。如果您希望他们具有管理级别的权限,则将新用户分配角色 `default_role`。例如,添加用户 `clickhouse_admin`: +当您为 ClickHouse Cloud 服务添加其他 SQL 用户时,他们将需要一个 SQL 用户名和密码。 如果您希望他们具有管理级别的权限,请将新用户分配为角色 `default_role`。例如,添加用户 `clickhouse_admin`: ```sql CREATE USER IF NOT EXISTS clickhouse_admin @@ -32,27 +33,27 @@ GRANT default_role TO clickhouse_admin; ``` :::note -使用 SQL 控制台时,您的 SQL 语句不会以 `default` 用户身份运行。相反,语句将以名为 `sql-console:${cloud_login_email}` 的用户身份运行,其中 `cloud_login_email` 是当前运行查询的用户的电子邮件。 +在使用 SQL 控制台时,您的 SQL 语句不会作为 `default` 用户运行。相反,语句将作为名为 `sql-console:${cloud_login_email}` 的用户运行,其中 `cloud_login_email` 是当前运行查询的用户的电子邮件。 这些自动生成的 SQL 控制台用户具有 `default` 角色。 ::: ## 无密码认证 {#passwordless-authentication} -SQL 控制台有两个可用角色:`sql_console_admin`,其权限与 `default_role` 相同,以及 `sql_console_read_only`,其为只读权限。 +SQL 控制台有两个可用角色:`sql_console_admin`,其权限与 `default_role` 相同,以及 `sql_console_read_only`,具有只读权限。 -管理员用户默认分配 `sql_console_admin` 角色,因此对他们没有变化。然而,`sql_console_read_only` 角色允许非管理员用户被授予任何实例的只读或完全访问权限。管理员需要配置此访问权限。可以使用 `GRANT` 或 `REVOKE` 命令来调整角色,以更好地满足特定实例的需求,并且对这些角色所做的任何修改将被持久化。 +管理员用户默认分配了 `sql_console_admin` 角色,因此他们的权限没有变化。然而,`sql_console_read_only` 角色允许非管理员用户被授予只读或完全访问实例的权限。管理员需要配置此访问权限。可以使用 `GRANT` 或 `REVOKE` 命令调整角色,以更好地满足实例特定的需求,对这些角色所做的任何修改将会被持久化。 ### 细粒度访问控制 {#granular-access-control} -此访问控制功能还可以手动配置以实现用户级别的细粒度控制。在将新的 `sql_console_*` 角色分配给用户之前,应创建与命名空间 `sql-console-role:` 匹配的 SQL 控制台用户特定数据库角色。例如: +这种访问控制功能还可以手动配置,以实现用户级别的细粒度控制。在将新的 `sql_console_*` 角色分配给用户之前,应为与命名空间 `sql-console-role:` 匹配的 SQL 控制台用户特定数据库角色创建。例如: ```sql CREATE ROLE OR REPLACE sql-console-role:; GRANT TO sql-console-role:; ``` -当检测到匹配角色时,它将分配给用户,而不是使用模板角色。这引入了更复杂的访问控制配置,例如创建角色 `sql_console_sa_role` 和 `sql_console_pm_role` 并将其授予特定用户。例如: +当检测到匹配的角色时,它将被分配给用户,而不是模板角色。这引入了更复杂的访问控制配置,例如创建角色 `sql_console_sa_role` 和 `sql_console_pm_role`,并将它们授予特定用户。例如: ```sql CREATE ROLE OR REPLACE sql_console_sa_role; diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/cloud_access_management/common-access-management-queries.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/cloud_access_management/common-access-management-queries.md.hash new file mode 100644 index 00000000000..8955a6056e5 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/cloud_access_management/common-access-management-queries.md.hash @@ -0,0 +1 @@ +b5a3dbbb2d6de6d2 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/inviting-new-users.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/cloud_access_management/inviting-new-users.md similarity index 59% rename from i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/inviting-new-users.md rename to i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/cloud_access_management/inviting-new-users.md index ab21150c505..3249bef51e7 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/inviting-new-users.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/cloud_access_management/inviting-new-users.md @@ -2,17 +2,18 @@ 'sidebar_label': '邀请新用户' 'slug': '/cloud/security/inviting-new-users' 'title': '邀请新用户' -'description': '本页面描述了管理员如何邀请新用户加入他们的组织并分配角色给他们' +'description': '本页面描述了管理员如何邀请新用户加入他们的组织并为他们分配角色' +'doc_type': 'guide' --- import Image from '@theme/IdealImage'; import users_and_roles from '@site/static/images/cloud/security/users_and_roles.png'; import invite_user from '@site/static/images/cloud/security/invite-user.png'; -管理员可以邀请其他人加入组织,并为其分配 `Developer`、`Admin` 或 `Billing Admin` 角色。 +管理员可以邀请其他人加入组织,并为他们分配 `Developer`、`Admin` 或 `Billing Admin` 角色。 :::note -管理员和开发者与数据库用户不同。要创建数据库用户和角色,请使用 SQL 控制台。要了解更多信息,请查看我们关于 [Users and Roles](/cloud/security/cloud-access-management) 的文档。 +管理员和开发者与数据库用户是不同的。要创建数据库用户和角色,请使用 SQL 控制台。要了解更多信息,请访问我们关于 [用户和角色](/cloud/security/cloud-access-management) 的文档。 ::: 要邀请用户,请选择组织并点击 `Users and roles`: @@ -27,4 +28,4 @@ import invite_user from '@site/static/images/cloud/security/invite-user.png';
-点击 `Send invites`。用户将收到一封电子邮件,可以通过该邮件加入组织。 +点击 `Send invites`。用户将收到一封电子邮件,通过该邮件可以加入组织。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/cloud_access_management/inviting-new-users.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/cloud_access_management/inviting-new-users.md.hash new file mode 100644 index 00000000000..84485d88519 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/cloud_access_management/inviting-new-users.md.hash @@ -0,0 +1 @@ +13e5f1ea17c1335b diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/cloud_access_management/saml-sso-setup.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/cloud_access_management/saml-sso-setup.md new file mode 100644 index 00000000000..75f2fca9c23 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/cloud_access_management/saml-sso-setup.md @@ -0,0 +1,369 @@ +--- +'sidebar_label': 'SAML SSO 设置' +'slug': '/cloud/security/saml-setup' +'title': 'SAML SSO 设置' +'description': '如何在 ClickHouse Cloud 中设置 SAML SSO' +'doc_type': 'guide' +--- + +import Image from '@theme/IdealImage'; +import samlOrgId from '@site/static/images/cloud/security/saml-org-id.png'; +import samlOktaSetup from '@site/static/images/cloud/security/saml-okta-setup.png'; +import samlGoogleApp from '@site/static/images/cloud/security/saml-google-app.png'; +import samlAzureApp from '@site/static/images/cloud/security/saml-azure-app.png'; +import samlAzureClaims from '@site/static/images/cloud/security/saml-azure-claims.png'; +import EnterprisePlanFeatureBadge from '@theme/badges/EnterprisePlanFeatureBadge' + + +# SAML SSO 设置 + + + +ClickHouse Cloud 支持通过安全声明标记语言(SAML)进行单点登录(SSO)。这使您能够通过身份提供者(IdP)安全地登录到您的 ClickHouse Cloud 组织。 + +我们目前支持服务提供商发起的 SSO、多组织使用单独连接和及时配置。我们尚不支持跨域身份管理(SCIM)或属性映射系统。 + +## 开始之前 {#before-you-begin} + +您将需要在 IdP 中的管理员权限以及在 ClickHouse Cloud 组织中的 **Admin** 角色。在您的 IdP 中设置连接后,请按照下面程序中的信息与我们联系以完成该过程。 + +我们建议您在设置 SAML 连接的同时,为您的组织设置 **直接链接** 以简化登录过程。每个 IdP 的处理方式不同。请继续阅读以了解如何为您的 IdP 执行此操作。 + +## 如何配置您的 IdP {#how-to-configure-your-idp} + +### 步骤 {#steps} + +
+ 获取您的组织 ID + + 所有设置都需要您的组织 ID。要获取您的组织 ID: + + 1. 登录到您的 [ClickHouse Cloud](https://console.clickhouse.cloud) 组织。 + + 组织 ID + + 3. 在左下角,单击 **组织** 下的组织名称。 + + 4. 在弹出菜单中,选择 **组织详细信息**。 + + 5. 记录您的 **组织 ID** 以供后用。 + +
+ +
+ 配置您的 SAML 集成 + + ClickHouse 使用服务提供商发起的 SAML 连接。这意味着您可以通过 https://console.clickhouse.cloud 或通过直接链接登录。我们目前不支持身份提供者发起的连接。基本的 SAML 配置包括以下内容: + +- SSO URL 或 ACS URL: `https://auth.clickhouse.cloud/login/callback?connection={organizationid}` + +- Audience URI 或 Entity ID: `urn:auth0:ch-production:{organizationid}` + +- 应用程序用户名: `email` + +- 属性映射: `email = user.email` + +- 访问您组织的直接链接: `https://console.clickhouse.cloud/?connection={organizationid}` + + 有关特定的配置步骤,请参阅您特定的身份提供者。 + +
+ +
+ 获取您的连接信息 + + 获取您的身份提供者 SSO URL 和 x.509 证书。有关如何检索此信息,请参阅您特定的身份提供者。 + +
+ +
+ 提交支持案例 + + 1. 返回 ClickHouse Cloud 控制台。 + + 2. 在左侧选择 **帮助**,然后选择支持子菜单。 + + 3. 点击 **新案例**。 + + 4. 输入主题“SAML SSO 设置”。 + + 5. 在描述中粘贴从上面说明中收集的任何链接,并将证书附加到票据中。 + + 6. 请告知我们该连接应允许哪些域名(例如,domain.com,domain.ai等)。 + + 7. 创建一个新的案例。 + + 8. 我们将在 ClickHouse Cloud 中完成设置,并在可以测试时通知您。 + +
+ +
+ 完成设置 + + 1. 在您的身份提供者中分配用户访问权限。 + + 2. 通过 https://console.clickhouse.cloud 或您在“配置您的 SAML 集成”部分中配置的直接链接登录 ClickHouse。用户初始分配为“Member”角色,可以登录组织并更新个人设置。 + + 3. 从 ClickHouse 组织注销。 + + 4. 使用原始身份验证方法登录,以将 Admin 角色分配给您的新 SSO 帐户。 +- 对于电子邮件 + 密码帐户,请使用 `https://console.clickhouse.cloud/?with=email`。 +- 对于社交登录,请单击适当的按钮 (**用 Google 登录** 或 **用 Microsoft 登录**) + +:::note +`email` 在 `?with=email` 中是字面参数值,而不是占位符 +::: + + 5. 使用原始身份验证方法注销,并通过 https://console.clickhouse.cloud 或通过您在“配置您的 SAML 集成”部分中配置的直接链接重新登录。 + + 6. 删除任何非 SAML 用户,以强制实施组织的 SAML。以后,用户通过您的身份提供者分配。 + +
+ +### 配置 Okta SAML {#configure-okta-saml} + +您将为每个 ClickHouse 组织在 Okta 中配置两个应用集成:一个 SAML 应用和一个用于存放直接链接的书签。 + +
+ 1. 创建一个组以管理访问 + + 1. 以 **管理员** 身份登录到您的 Okta 实例。 + + 2. 在左侧选择 **组**。 + + 3. 点击 **添加组**。 + + 4. 输入组的名称和描述。该组将用于在 SAML 应用和其相关书签应用之间保持用户的一致性。 + + 5. 点击 **保存**。 + + 6. 点击您创建的组名称。 + + 7. 点击 **分配人员**,以分配希望访问此 ClickHouse 组织的用户。 + +
+ +
+ 2. 创建书签应用以使用户无缝登录 + + 1. 在左侧选择 **应用程序**,然后选择 **应用程序** 子标题。 + + 2. 点击 **浏览应用程序目录**。 + + 3. 搜索并选择 **书签应用**。 + + 4. 点击 **添加集成**。 + + 5. 选择应用的标签。 + + 6. 将 URL 输入为 `https://console.clickhouse.cloud/?connection={organizationid}` + + 7. 转到 **分配** 选项卡并添加您上面创建的组。 + +
+ +
+ 3. 创建 SAML 应用以使连接可用 + + 1. 在左侧选择 **应用程序**,然后选择 **应用程序** 子标题。 + + 2. 点击 **创建应用集成**。 + + 3. 选择 SAML 2.0 并点击下一步。 + + 4. 为您的应用输入名称,并勾选 **不向用户显示应用图标** 旁边的框,然后点击 **下一步**。 + + 5. 使用以下值填充 SAML 设置屏幕。 + + | 字段 | 值 | + |--------------------------------|-------| + | 单点登录 URL | `https://auth.clickhouse.cloud/login/callback?connection={organizationid}` | + | Audience URI (SP 实体 ID) | `urn:auth0:ch-production:{organizationid}` | + | 默认 RelayState | 留空 | + | Name ID 格式 | 未指定 | + | 应用程序用户名 | 电子邮件 | + | 更新应用程序用户名为 | 创建并更新 | + + 7. 输入以下属性声明。 + + | 名称 | 名称格式 | 值 | + |---------|---------------|------------| + | email | 基本 | user.email | + + 9. 点击 **下一步**。 + + 10. 在反馈屏幕上输入所请求的信息并点击 **完成**。 + + 11. 转到 **分配** 选项卡并添加您上面创建的组。 + + 12. 在新应用的 **单点登录** 选项卡上,点击 **查看 SAML 设置说明** 按钮。 + + Okta SAML 设置说明 + + 13. 收集这三个项目,并前往上面的提交支持案例以完成该过程。 + - 身份提供者单点登录 URL + - 身份提供者发行者 + - X.509 证书 + +
+ +### 配置 Google SAML {#configure-google-saml} + +您将为每个组织在 Google 中配置一个 SAML 应用,并必须向用户提供直接链接 (`https://console.clickhouse.cloud/?connection={organizationId}`) 以供书签使用,如果使用多组织 SSO。 + +
+ 创建 Google Web 应用 + + 1. 转到您的 Google 管理控制台 (admin.google.com)。 + + Google SAML 应用 + + 2. 点击 **应用**,然后选择左侧的 **Web 和移动应用**。 + + 3. 点击顶部菜单中的 **添加应用**,然后选择 **添加自定义 SAML 应用**。 + + 4. 输入应用的名称并点击 **继续**。 + + 5. 收集这两个项目并前往上面的提交支持案例以提交信息给我们。注意:如果您在复制此数据之前完成设置,请点击应用主页上的 **下载元数据** 以获取 X.509 证书。 + - SSO URL + - X.509 证书 + + 7. 在下面输入 ACS URL 和 Entity ID。 + + | 字段 | 值 | + |-----------|-------| + | ACS URL | `https://auth.clickhouse.cloud/login/callback?connection={organizationid}` | + | Entity ID | `urn:auth0:ch-production:{organizationid}` | + + 8. 勾选 **已签名响应** 复选框。 + + 9. 选择 **EMAIL** 作为 Name ID 格式,并将 Name ID 留为 **基本信息 > 主电子邮件**。 + + 10. 点击 **继续**。 + + 11. 输入以下属性映射: + + | 字段 | 值 | + |-------------------|---------------| + | 基本信息 | 主电子邮件 | + | 应用属性 | email | + + 13. 点击 **完成**。 + + 14. 为了使应用可用,单击 **OFF** 为每个人,然后将设置更改为 **ON** 为每个人。访问权限也可以通过选择屏幕左侧的选项,以限制为组或组织单位。 + +
+ +### 配置 Azure (Microsoft) SAML {#configure-azure-microsoft-saml} + +Azure (Microsoft) SAML 也可称为 Azure Active Directory (AD) 或 Microsoft Entra。 + +
+ 创建 Azure 企业应用 + + 您将为每个组织设置一个应用集成,使用单独的登录 URL。 + + 1. 登录到 Microsoft Entra 管理中心。 + + 2. 导航到左侧的 **应用程序 > 企业** 应用程序。 + + 3. 点击顶部菜单中的 **新建应用**。 + + 4. 点击顶部菜单中的 **创建您自己的应用**。 + + 5. 输入名称并选择 **集成您在画廊中找不到的其他应用程序(非画廊)**,然后点击 **创建**。 + + Azure 非画廊应用 + + 6. 点击左侧的 **用户和组** 并分配用户。 + + 7. 点击左侧的 **单点登录**。 + + 8. 点击 **SAML**。 + + 9. 使用以下设置填充基本 SAML 配置屏幕。 + + | 字段 | 值 | + |---------------------------|-------| + | 标识符(实体 ID) | `urn:auth0:ch-production:{organizationid}` | + | 回复 URL(断言消费者服务 URL) | `https://auth.clickhouse.cloud/login/callback?connection={organizationid}` | + | 登录 URL | `https://console.clickhouse.cloud/?connection={organizationid}` | + | Relay State | 留空 | + | 注销 URL | 留空 | + + 11. 在属性和声明下添加 (A) 或更新 (U) 以下内容: + + | 声明名称 | 格式 | 源属性 | + |--------------------------------------|---------------|------------------| + | (U) 唯一用户标识符(Name ID) | 电子邮件地址 | user.mail | + | (A) email | 基本 | user.mail | + | (U) /identity/claims/name | 被省略 | user.mail | + + 属性和声明 + + 12. 收集这两个项目并前往上面的提交支持案例以完成该过程: + - 登录 URL + - 证书(Base64) + +
+ +### 配置 Duo SAML {#configure-duo-saml} + +
+ 为 Duo 创建通用 SAML 服务提供商 + + 1. 按照 [Duo 单点登录通用 SAML 服务提供商的说明](https://duo.com/docs/sso-generic) 的说明进行操作。 + + 2. 使用以下 Bridge 属性映射: + + | Bridge 属性 | ClickHouse 属性 | + |:-------------------|:-----------------------| + | 电子邮件地址 | 电子邮件 | + + 3. 使用以下值更新您在 Duo 中的云应用: + + | 字段 | 值 | + |:----------|:-------------------------------------------| + | 实体 ID | `urn:auth0:ch-production:{organizationid}` | + | 断言消费者服务 (ACS) URL | `https://auth.clickhouse.cloud/login/callback?connection={organizationid}` | + | 服务提供商登录 URL | `https://console.clickhouse.cloud/?connection={organizationid}` | + + 4. 收集这两个项目并前往上面的提交支持案例以完成该过程: + - 单点登录 URL + - 证书 + +
+ +## 它是如何工作的 {#how-it-works} + +### 服务提供商发起的 SSO {#service-provider-initiated-sso} + +我们仅利用服务提供商发起的 SSO。这意味着用户需要访问 `https://console.clickhouse.cloud` 并输入他们的电子邮件地址以便重定向到 IdP 进行身份验证。通过您的 IdP 已经身份验证的用户可以使用直接链接自动登录到您的组织,而无需在登录页面输入他们的电子邮件地址。 + +### 分配用户角色 {#assigning-user-roles} + +用户在他们被分配到您的 IdP 应用程序并首次登录后,将出现在您的 ClickHouse Cloud 控制台中。至少应在您的组织中为一名 SSO 用户分配 Admin 角色,使用 SSO 登录的其他用户将以 ["Member"](/cloud/security/cloud-access-management/overview#console-users-and-roles) 角色创建,这意味着他们默认不能访问任何服务,并应由管理员更新他们的访问权限和角色。 + +使用社交登录或 `https://console.clickhouse.cloud/?with=email` 使用原始身份验证方法登录以更新您的 SSO 角色。 + +### 移除非 SSO 用户 {#removing-non-sso-users} + +一旦您设置了 SSO 用户并为至少一个用户分配了 Admin 角色,管理员可以删除使用其他方法(例如社交身份验证或用户 ID + 密码)的用户。设置 SSO 后,Google 身份验证将继续有效。用户 ID + 密码用户将基于其电子邮件域被自动重定向到 SSO,除非用户使用 `https://console.clickhouse.cloud/?with=email`。 + +### 管理用户 {#managing-users} + +ClickHouse Cloud 目前实现了 SAML 进行 SSO。我们尚未实现 SCIM 来管理用户。这意味着 SSO 用户必须在您的 IdP 中被分配到应用程序才能访问您的 ClickHouse Cloud 组织。用户必须首次登录 ClickHouse Cloud 才能出现在组织的 **用户** 区域中。当用户在您的 IdP 中被删除时,他们将无法再使用 SSO 登录 ClickHouse Cloud。然而,SSO 用户仍然会在您的组织中显示,直到管理员手动删除该用户。 + +### 多组织 SSO {#multi-org-sso} + +ClickHouse Cloud 支持多组织 SSO,为每个组织提供单独的连接。使用直接链接 (`https://console.clickhouse.cloud/?connection={organizationid}`) 登录到各自的组织。在登录另一个组织之前,请确保注销一个组织。 + +## 其他信息 {#additional-information} + +安全是我们在身份验证方面的首要任务。因此,我们在实现 SSO 时做出了一些需要您知晓的决定。 + +- **我们只处理服务提供商发起的身份验证流程。** 用户必须导航到 `https://console.clickhouse.cloud` 并输入电子邮件地址,以便被重定向到您的身份提供者。提供了添加书签应用或快捷方式的说明,以方便您的用户,无需记住 URL。 + +- **所有通过 IdP 分配给您应用的用户必须具有相同的电子邮件域。** 如果您有希望访问 ClickHouse 帐户的供应商、承包商或顾问,他们必须具有与您的员工相同域名的电子邮件地址(例如 user@domain.com)。 + +- **我们不会自动链接 SSO 和非 SSO 帐户。** 即使用户使用相同的电子邮件地址,您也可能在 ClickHouse 用户列表中看到用户的多个帐户。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/cloud_access_management/saml-sso-setup.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/cloud_access_management/saml-sso-setup.md.hash new file mode 100644 index 00000000000..768c065a36f --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/cloud_access_management/saml-sso-setup.md.hash @@ -0,0 +1 @@ +bf785a1a409cc44a diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/connectivity/_category_.json b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/connectivity/_category_.json new file mode 100644 index 00000000000..6e137e0592d --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/connectivity/_category_.json @@ -0,0 +1,5 @@ +{ + "label": "Connectivity", + "collapsible": true, + "collapsed": true, +} \ No newline at end of file diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/connectivity/accessing-s3-data-securely.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/connectivity/accessing-s3-data-securely.md new file mode 100644 index 00000000000..d470a690a95 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/connectivity/accessing-s3-data-securely.md @@ -0,0 +1,148 @@ +--- +'slug': '/cloud/security/secure-s3' +'sidebar_label': '安全地访问 S3 数据' +'title': '安全地访问 S3 数据' +'description': '本文演示了 ClickHouse Cloud 客户如何利用基于角色的访问来与 Amazon Simple Storage Service(S3) + 进行身份验证并安全地访问他们的数据。' +'doc_type': 'guide' +--- + +import Image from '@theme/IdealImage'; +import secure_s3 from '@site/static/images/cloud/security/secures3.jpg'; +import s3_info from '@site/static/images/cloud/security/secures3_arn.png'; +import s3_output from '@site/static/images/cloud/security/secures3_output.jpg'; + +这篇文章演示了 ClickHouse Cloud 客户如何利用基于角色的访问,安全地通过 Amazon 简单存储服务(S3)进行身份验证并访问他们的数据。 + +## 介绍 {#introduction} + +在深入安全 S3 访问的设置之前,了解其工作原理是重要的。以下是 ClickHouse 服务如何通过假设客户 AWS 账户中的角色访问私有 S3 存储桶的概述。 + +与 ClickHouse 一起使用安全 S3 访问的概述 + +这种方法允许客户在一个地方管理对他们 S3 存储桶的所有访问(即假设角色的 IAM 策略),而无需逐个查看所有存储桶策略来添加或移除访问权限。 + +## 设置 {#setup} + +### 获取 ClickHouse 服务 IAM 角色 ARN {#obtaining-the-clickhouse-service-iam-role-arn} + +1 - 登录到您的 ClickHouse cloud 账户。 + +2 - 选择您想要创建集成的 ClickHouse 服务。 + +3 - 选择 **设置** 选项卡。 + +4 - 向下滚动到页面底部的 **网络安全信息** 部分。 + +5 - 复制如下所示的服务的 **服务角色 ID (IAM)** 值。 + +获取 ClickHouse 服务 IAM 角色 ARN + +### 设置 IAM 假设角色 {#setting-up-iam-assume-role} + +#### 选项 1:使用 CloudFormation 堆栈部署 {#option-1-deploying-with-cloudformation-stack} + +1 - 使用具有创建和管理 IAM 角色权限的 IAM 用户登录到您的 AWS 账户。 + +2 - 访问 [此网址](https://us-west-2.console.aws.amazon.com/cloudformation/home?region=us-west-2#/stacks/quickcreate?templateURL=https://s3.us-east-2.amazonaws.com/clickhouse-public-resources.clickhouse.cloud/cf-templates/secure-s3.yaml&stackName=ClickHouseSecureS3) 来填充 CloudFormation 堆栈。 + +3 - 输入(或粘贴)属于 ClickHouse 服务的 **IAM 角色**。 + +4 - 配置 CloudFormation 堆栈。以下是有关这些参数的额外信息。 + +| 参数 | 默认值 | 描述 | +| :--- | :----: | :---- | +| RoleName | ClickHouseAccess-001 | ClickHouse Cloud 用于访问您的 S3 存储桶的新角色名称 | +| Role Session Name | * | 角色会话名称可作为共享密钥,进一步保护您的存储桶。 | +| ClickHouse Instance Roles| | 可以使用此安全 S3 集成的 ClickHouse 服务 IAM 角色的逗号分隔列表。 | +| Bucket Access | Read | 设置提供的存储桶的访问级别。 | +| Bucket Names | | 此角色将有权访问的 **存储桶名称** 的逗号分隔列表。 | + +*注意*:请勿输入完整的存储桶 ARN,仅需输入存储桶名称。 + +5 - 选中 **我确认 AWS CloudFormation 可能会创建具有自定义名称的 IAM 资源。** 复选框。 + +6 - 点击右下角的 **创建堆栈** 按钮。 + +7 - 确保 CloudFormation 堆栈完成且没有错误。 + +8 - 选择 CloudFormation 堆栈的 **输出**。 + +9 - 复制该集成的 **RoleArn** 值。该值是访问您的 S3 存储桶所需的。 + +显示 IAM 角色 ARN 的 CloudFormation 堆栈输出 + +#### 选项 2:手动创建 IAM 角色 {#option-2-manually-create-iam-role} + +1 - 使用具有创建和管理 IAM 角色权限的 IAM 用户登录到您的 AWS 账户。 + +2 - 浏览到 IAM 服务控制台。 + +3 - 使用以下 IAM 和信任策略创建新 IAM 角色。 + +信任策略(请将 `{ClickHouse_IAM_ARN}` 替换为属于您 ClickHouse 实例的 IAM 角色 ARN): + +```json +{ + "Version": "2012-10-17", + "Statement": [ + { + "Effect": "Allow", + "Principal": { + "AWS": "{ClickHouse_IAM_ARN}" + }, + "Action": "sts:AssumeRole" + } + ] +} +``` + +IAM 策略(请将 `{BUCKET_NAME}` 替换为您的存储桶名称): + +```json +{ + "Version": "2012-10-17", + "Statement": [ + { + "Action": [ + "s3:GetBucketLocation", + "s3:ListBucket" + ], + "Resource": [ + "arn:aws:s3:::{BUCKET_NAME}" + ], + "Effect": "Allow" + }, + { + "Action": [ + "s3:Get*", + "s3:List*" + ], + "Resource": [ + "arn:aws:s3:::{BUCKET_NAME}/*" + ], + "Effect": "Allow" + } + ] +} +``` + +4 - 创建后复制新 **IAM 角色 Arn**。该值是访问您的 S3 存储桶所需的。 + +## 使用 ClickHouseAccess 角色访问您的 S3 存储桶 {#access-your-s3-bucket-with-the-clickhouseaccess-role} + +ClickHouse Cloud 具有一项新功能,允许您将 `extra_credentials` 作为 S3 表函数的一部分来指定。以下是如何使用从上面复制的新创建角色运行查询的示例。 + +```sql +DESCRIBE TABLE s3('https://s3.amazonaws.com/BUCKETNAME/BUCKETOBJECT.csv','CSVWithNames',extra_credentials(role_arn = 'arn:aws:iam::111111111111:role/ClickHouseAccessRole-001')) +``` + +以下是一个示例查询,它使用 `role_session_name` 作为共享密钥从存储桶中查询数据。如果 `role_session_name` 不正确,此操作将失败。 + +```sql +DESCRIBE TABLE s3('https://s3.amazonaws.com/BUCKETNAME/BUCKETOBJECT.csv','CSVWithNames',extra_credentials(role_arn = 'arn:aws:iam::111111111111:role/ClickHouseAccessRole-001', role_session_name = 'secret-role-name')) +``` + +:::note +我们建议您的源 S3 存储在与您的 ClickHouse Cloud 服务相同的区域,以减少数据传输成本。有关更多信息,请参阅 [S3 定价]( https://aws.amazon.com/s3/pricing/) +::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/connectivity/accessing-s3-data-securely.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/connectivity/accessing-s3-data-securely.md.hash new file mode 100644 index 00000000000..782528fd955 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/connectivity/accessing-s3-data-securely.md.hash @@ -0,0 +1 @@ +d66e015b960ddac2 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/connectivity/cloud-endpoints-api.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/connectivity/cloud-endpoints-api.md new file mode 100644 index 00000000000..a78f2408da5 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/connectivity/cloud-endpoints-api.md @@ -0,0 +1,49 @@ +--- +'slug': '/manage/security/cloud-endpoints-api' +'sidebar_label': '云 IP 地址' +'title': '云 IP 地址' +'description': '本页面记录了 ClickHouse 中 Cloud Endpoints API 的安全功能。它详细说明了如何通过身份验证和授权机制来管理访问,从而保护您的 + ClickHouse 部署。' +'doc_type': 'reference' +--- + +import Image from '@theme/IdealImage'; +import aws_rds_mysql from '@site/static/images/_snippets/aws-rds-mysql.png'; +import gcp_authorized_network from '@site/static/images/_snippets/gcp-authorized-network.png'; + +## 静态 IP API {#static-ips-api} + +如果您需要获取静态 IP 的列表,可以使用以下 ClickHouse Cloud API 端点:[`https://api.clickhouse.cloud/static-ips.json`](https://api.clickhouse.cloud/static-ips.json)。该 API 提供了 ClickHouse Cloud 服务的端点,例如每个区域和云的 ingress/egress IP 和 S3 端点。 + +如果您使用 MySQL 或 PostgreSQL 引擎等集成,您可能需要授权 ClickHouse Cloud 访问您的实例。您可以使用此 API 检索公共 IP,并在 GCP 的 `firewalls` 或 `Authorized networks` 中配置它们,或者在 Azure、AWS 或任何其他您正在使用的基础设施出口管理系统中的 `Security Groups` 中进行配置。 + +例如,要允许来自在区域 `ap-south-1` 上托管的 AWS 的 ClickHouse Cloud 服务的访问,您可以添加该区域的 `egress_ips` 地址: + +```bash +❯ curl -s https://api.clickhouse.cloud/static-ips.json | jq '.' +{ + "aws": [ + { + "egress_ips": [ + "3.110.39.68", + "15.206.7.77", + "3.6.83.17" + ], + "ingress_ips": [ + "15.206.78.111", + "3.6.185.108", + "43.204.6.248" + ], + "region": "ap-south-1", + "s3_endpoints": "vpce-0a975c9130d07276d" + }, +... +``` + +例如,在 `us-east-2` 中运行的 AWS RDS 实例需要连接到 ClickHouse cloud 服务,应具有以下入站安全组规则: + +AWS 安全组规则 + +对于同一在 `us-east-2` 中运行的 ClickHouse Cloud 服务,但这次连接到 GCP 中的 MySQL,`Authorized networks` 应如下所示: + +GCP 授权网络 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/connectivity/cloud-endpoints-api.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/connectivity/cloud-endpoints-api.md.hash new file mode 100644 index 00000000000..ee8e8ffafe9 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/connectivity/cloud-endpoints-api.md.hash @@ -0,0 +1 @@ +85b0289694c32868 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/connectivity/private_networking/02_aws-privatelink.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/connectivity/private_networking/02_aws-privatelink.md new file mode 100644 index 00000000000..909c7ee0384 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/connectivity/private_networking/02_aws-privatelink.md @@ -0,0 +1,386 @@ +--- +'title': 'AWS PrivateLink' +'description': '本文档描述了如何使用 AWS PrivateLink 连接到 ClickHouse Cloud。' +'slug': '/manage/security/aws-privatelink' +'doc_type': 'guide' +--- + +import Image from '@theme/IdealImage'; +import ScalePlanFeatureBadge from '@theme/badges/ScalePlanFeatureBadge'; +import aws_private_link_pecreate from '@site/static/images/cloud/security/aws-privatelink-pe-create.png'; +import aws_private_link_endpoint_settings from '@site/static/images/cloud/security/aws-privatelink-endpoint-settings.png'; +import aws_private_link_select_vpc from '@site/static/images/cloud/security/aws-privatelink-select-vpc-and-subnets.png'; +import aws_private_link_vpc_endpoint_id from '@site/static/images/cloud/security/aws-privatelink-vpc-endpoint-id.png'; +import aws_private_link_endpoints_menu from '@site/static/images/cloud/security/aws-privatelink-endpoints-menu.png'; +import aws_private_link_modify_dnsname from '@site/static/images/cloud/security/aws-privatelink-modify-dns-name.png'; +import pe_remove_private_endpoint from '@site/static/images/cloud/security/pe-remove-private-endpoint.png'; +import aws_private_link_pe_filters from '@site/static/images/cloud/security/aws-privatelink-pe-filters.png'; +import aws_private_link_ped_nsname from '@site/static/images/cloud/security/aws-privatelink-pe-dns-name.png'; + + +# AWS PrivateLink + + + +您可以使用 [AWS PrivateLink](https://aws.amazon.com/privatelink/) 在 VPC、AWS 服务、您本地系统和 ClickHouse Cloud 之间建立安全连接,而无需将流量暴露于公共互联网。本文档概述了使用 AWS PrivateLink 连接到 ClickHouse Cloud 的步骤。 + +要仅通过 AWS PrivateLink 地址限制对 ClickHouse Cloud 服务的访问,请遵循 ClickHouse Cloud 提供的 [IP 访问列表](/cloud/security/setting-ip-filters) 中的说明。 + +:::note +ClickHouse Cloud 支持来自以下地区的 [跨区域 PrivateLink](https://aws.amazon.com/about-aws/whats-new/2024/11/aws-privatelink-across-region-connectivity/): +- sa-east-1 +- il-central-1 +- me-central-1 +- me-south-1 +- eu-central-2 +- eu-north-1 +- eu-south-2 +- eu-west-3 +- eu-south-1 +- eu-west-2 +- eu-west-1 +- eu-central-1 +- ca-west-1 +- ca-central-1 +- ap-northeast-1 +- ap-southeast-2 +- ap-southeast-1 +- ap-northeast-2 +- ap-northeast-3 +- ap-south-1 +- ap-southeast-4 +- ap-southeast-3 +- ap-south-2 +- ap-east-1 +- af-south-1 +- us-west-2 +- us-west-1 +- us-east-2 +- us-east-1 +定价考虑:AWS 将对跨区域数据传输向用户收取费用,具体定价请参见 [此处](https://aws.amazon.com/privatelink/pricing/)。 +::: + +**请完成以下步骤以启用 AWS PrivateLink**: +1. 获取终端节点 "服务名称"。 +1. 创建 AWS 终端节点。 +1. 将 "终端节点 ID" 添加到 ClickHouse Cloud 组织。 +1. 将 "终端节点 ID" 添加到 ClickHouse 服务允许列表。 + +找到 Terraform 示例 [此处](https://github.com/ClickHouse/terraform-provider-clickhouse/tree/main/examples/)。 + +## 重要考虑事项 {#considerations} +ClickHouse 尝试将您的服务分组,以重用 AWS 区域内相同的已发布 [服务终端节点](https://docs.aws.amazon.com/vpc/latest/privatelink/privatelink-share-your-services.html#endpoint-service-overview)。但是,特别是在您将服务分散到多个 ClickHouse 组织时,这种分组并不能得到保证。 +如果您已经为 ClickHouse 组织中的其他服务配置了 PrivateLink,您通常可以跳过大部分步骤,直接进入最后一步:将 ClickHouse 的 "终端节点 ID" 添加到 ClickHouse 服务允许列表。 + +## 此过程的先决条件 {#prerequisites} + +在开始之前,您需要: + +1. 您的 AWS 账户。 +1. 具有必要权限的 [ClickHouse API 密钥](/cloud/manage/openapi),以创建和管理 ClickHouse 侧的私有终端节点。 + +## 步骤 {#steps} + +按照以下步骤通过 AWS PrivateLink 连接您的 ClickHouse Cloud 服务。 + +### 获取终端节点 "服务名称" {#obtain-endpoint-service-info} + +#### 选项 1:ClickHouse Cloud 控制台 {#option-1-clickhouse-cloud-console} + +在 ClickHouse Cloud 控制台中,打开您想通过 PrivateLink 连接的服务,然后导航到 **设置** 菜单。 + +Private Endpoints + +记下 `服务名称` 和 `DNS 名称`,然后 [继续下一步](#create-aws-endpoint)。 + +#### 选项 2:API {#option-2-api} + +首先,在运行任何命令之前,设置以下环境变量: + +```shell +REGION= +PROVIDER=aws +KEY_ID= +KEY_SECRET= +ORG_ID= +SERVICE_NAME= +``` + +通过区域、提供商和服务名称过滤来获取您的 ClickHouse `INSTANCE_ID`: + +```shell +INSTANCE_ID=$(curl --silent --user "${KEY_ID:?}:${KEY_SECRET:?}" \ +"https://api.clickhouse.cloud/v1/organizations/${ORG_ID:?}/services" | \ +jq ".result[] | select (.region==\"${REGION:?}\" and .provider==\"${PROVIDER:?}\" and .name==\"${SERVICE_NAME:?}\") | .id " -r) +``` + +获取您 PrivateLink 配置的 `endpointServiceId` 和 `privateDnsHostname`: + +```bash +curl --silent --user "${KEY_ID:?}:${KEY_SECRET:?}" \ +"https://api.clickhouse.cloud/v1/organizations/${ORG_ID:?}/services/${INSTANCE_ID:?}/privateEndpointConfig" | \ +jq .result +``` + +此命令应返回类似于以下内容: + +```result +{ + "endpointServiceId": "com.amazonaws.vpce.us-west-2.vpce-svc-xxxxxxxxxxxxxxxxx", + "privateDnsHostname": "xxxxxxxxxx.us-west-2.vpce.aws.clickhouse.cloud" +} +``` + +记下 `endpointServiceId` 和 `privateDnsHostname` [继续下一步](#create-aws-endpoint)。 + +### 创建 AWS 终端节点 {#create-aws-endpoint} + +:::important +本节涵盖通过 AWS PrivateLink 配置 ClickHouse 的 ClickHouse 特定细节。AWS 特定步骤提供作为参考,以指导您查看相关内容,但可能会随时间而变化,恕不另行通知。请根据您的特定用例考虑 AWS 配置。 + +请注意,ClickHouse 不负责配置所需的 AWS VPC 终端节点、安全组规则或 DNS 记录。 + +如果您在设置 PrivateLink 时启用了 "私有 DNS 名称",并且在通过 PrivateLink 配置新服务时遇到困难,请联系 ClickHouse 支持。有关 AWS 配置任务的任何其他问题,请直接联系 AWS 支持。 +::: + +#### 选项 1:AWS 控制台 {#option-1-aws-console} + +打开 AWS 控制台,转到 **VPC** → **终端节点** → **创建终端节点**。 + +选择 **使用 NLB 和 GWLB 的终端服务**,并在 **服务名称** 字段中使用您从 [获取终端节点 "服务名称"](#obtain-endpoint-service-info) 步骤中获得的 `服务名称`控制台 或 `endpointServiceId`API。点击 **验证服务**: + +AWS PrivateLink Endpoint Settings + +如果您想通过 PrivateLink 建立跨区域连接,请启用 "跨区域终端" 复选框并指定服务区域。服务区域是 ClickHouse 实例运行的地方。 + +如果您收到 "服务名称无法验证。" 错误,请联系客户支持,申请将新区域添加到支持的区域列表。 + +接下来,选择您的 VPC 和子网: + +Select VPC and subnets + +作为可选步骤,分配安全组/标签: + +:::note +请确保在安全组中允许端口 `443`、`8443`、`9440`、`3306`。 +::: + +创建 VPC 终端节点后,记下 `终端节点 ID` 值;您将在即将到来的步骤中需要它。 + +VPC Endpoint ID + +#### 选项 2:AWS CloudFormation {#option-2-aws-cloudformation} + +接下来,您需要使用您从 [获取终端节点 "服务名称"](#obtain-endpoint-service-info) 步骤中获得的 `服务名称`控制台 或 `endpointServiceId`API 创建 VPC 终端节点。 +确保使用正确的子网 ID、安全组和 VPC ID。 + +```response +Resources: + ClickHouseInterfaceEndpoint: + Type: 'AWS::EC2::VPCEndpoint' + Properties: + VpcEndpointType: Interface + PrivateDnsEnabled: false + ServiceName: + VpcId: vpc-vpc_id + SubnetIds: + - subnet-subnet_id1 + - subnet-subnet_id2 + - subnet-subnet_id3 + SecurityGroupIds: + - sg-security_group_id1 + - sg-security_group_id2 + - sg-security_group_id3 +``` + +创建 VPC 终端节点后,记下 `终端节点 ID` 值;您将在即将到来的步骤中需要它。 + +#### 选项 3:Terraform {#option-3-terraform} + +下面的 `service_name` 是您从 [获取终端节点 "服务名称"](#obtain-endpoint-service-info) 步骤中获得的 `服务名称`控制台 或 `endpointServiceId`API + +```json +resource "aws_vpc_endpoint" "this" { + vpc_id = var.vpc_id + service_name = "" + vpc_endpoint_type = "Interface" + security_group_ids = [ + Var.security_group_id1,var.security_group_id2, var.security_group_id3, + ] + subnet_ids = [var.subnet_id1,var.subnet_id2,var.subnet_id3] + private_dns_enabled = false + service_region = "(Optional) If specified, the VPC endpoint will connect to the service in the provided region. Define it for multi-regional PrivateLink connections." +} +``` + +创建 VPC 终端节点后,记下 `终端节点 ID` 值;您将在即将到来的步骤中需要它。 + +#### 为终端节点设置私有 DNS 名称 {#set-private-dns-name-for-endpoint} + +:::note +配置 DNS 的方法有多种。请根据您的特定用例设置 DNS。 +::: + +您需要将从 [获取终端节点 "服务名称"](#obtain-endpoint-service-info) 步骤中获取的 "DNS 名称" 指向 AWS 终端节点网络接口。这确保您的 VPC/网络中的服务/组件能够正确解析它。 + +### 将 "终端节点 ID" 添加到 ClickHouse 服务允许列表 {#add-endpoint-id-to-services-allow-list} + +#### 选项 1:ClickHouse Cloud 控制台 {#option-1-clickhouse-cloud-console-2} + +要添加,请导航到 ClickHouse Cloud 控制台,打开您想通过 PrivateLink 连接的服务,然后导航到 **设置**。点击 **设置私有终端** 打开私有终端设置。输入从 [创建 AWS 终端节点](#create-aws-endpoint) 步骤中获得的 `终端节点 ID`。点击 "创建终端”。 + +:::note +如果您希望从现有 PrivateLink 连接允许访问,请使用现有终端下拉菜单。 +::: + +Private Endpoints Filter + +要删除请导航到 ClickHouse Cloud 控制台,找到服务,然后导航到该服务的 **设置**,找到您希望删除的终端。将其从终端列表中移除。 + +#### 选项 2:API {#option-2-api-2} + +您需要为每个通过 PrivateLink 应该可用的实例添加终端节点 ID 到允许列表中。 + +使用从 [创建 AWS 终端节点](#create-aws-endpoint) 步骤中获得的数据设置 `ENDPOINT_ID` 环境变量。 + +在运行任何命令之前,设置以下环境变量: + +```bash +REGION= +PROVIDER=aws +KEY_ID= +KEY_SECRET= +ORG_ID= +SERVICE_NAME= +``` + +要将终端节点 ID 添加到允许列表中: + +```bash +cat <API 或 `DNS 名称`控制台。 + +#### 获取私有 DNS 主机名 {#getting-private-dns-hostname} + +##### 选项 1:ClickHouse Cloud 控制台 {#option-1-clickhouse-cloud-console-3} + +在 ClickHouse Cloud 控制台中,导航到 **设置**。点击 **设置私有终端** 按钮。在弹出的窗口中,复制 **DNS 名称**。 + +Private Endpoint DNS Name + +##### 选项 2:API {#option-2-api-3} + +在运行任何命令之前,设置以下环境变量: + +```bash +KEY_ID= +KEY_SECRET= +ORG_ID= +INSTANCE_ID= +``` + +您可以从 [步骤](#option-2-api) 中检索 `INSTANCE_ID`。 + +```bash +curl --silent --user "${KEY_ID:?}:${KEY_SECRET:?}" \ +"https://api.clickhouse.cloud/v1/organizations/${ORG_ID:?}/services/${INSTANCE_ID:?}/privateEndpointConfig" | \ +jq .result +``` + +这应该输出类似于: + +```result +{ + "endpointServiceId": "com.amazonaws.vpce.us-west-2.vpce-svc-xxxxxxxxxxxxxxxxx", + "privateDnsHostname": "xxxxxxxxxx.us-west-2.vpce.aws.clickhouse.cloud" +} +``` + +在这个例子中,通过 `privateDnsHostname` 主机名的连接将路由到 PrivateLink,但通过 `endpointServiceId` 主机名的连接将通过互联网路由。 + +## 故障排除 {#troubleshooting} + +### 同一区域的多个 PrivateLinks {#multiple-privatelinks-in-one-region} + +在大多数情况下,您只需要为每个 VPC 创建一个终端服务。该终端可以将请求从 VPC 路由到多个 ClickHouse Cloud 服务。 +请参见 [此处](#considerations) + +### 连接到私有终端超时 {#connection-to-private-endpoint-timed-out} + +- 请将安全组附加到 VPC 终端。 +- 请验证附加到终端的安全组的 `入站` 规则,并允许 ClickHouse 端口。 +- 请验证用于连接测试的 VM 附加的安全组的 `出站` 规则,并允许连接到 ClickHouse 端口。 + +### 私有主机名:未找到主机地址 {#private-hostname-not-found-address-of-host} + +- 请检查您的 DNS 配置 + +### 连接被对等方重置 {#connection-reset-by-peer} + +- 很可能是未将终端 ID 添加到服务允许列表中,请访问 [步骤](#add-endpoint-id-to-services-allow-list) + +### 检查终端过滤器 {#checking-endpoint-filters} + +在运行任何命令之前,设置以下环境变量: + +```bash +KEY_ID= +KEY_SECRET= +ORG_ID= +INSTANCE_ID= +``` + +您可以从 [步骤](#option-2-api) 中检索 `INSTANCE_ID`。 + +```shell +curl --silent --user "${KEY_ID:?}:${KEY_SECRET:?}" \ +-X GET -H "Content-Type: application/json" \ +"https://api.clickhouse.cloud/v1/organizations/${ORG_ID:?}/services/${INSTANCE_ID:?}" | \ +jq .result.privateEndpointIds +``` + +### 连接到远程数据库 {#connecting-to-a-remote-database} + +假设您尝试在 ClickHouse Cloud 中使用 [MySQL](/sql-reference/table-functions/mysql) 或 [PostgreSQL](/sql-reference/table-functions/postgresql) 表函数,并连接到托管在 Amazon Web Services (AWS) VPC 中的数据库。无法使用 AWS PrivateLink 安全地启用此连接。PrivateLink 是单向的单向连接。它允许您的内部网络或 Amazon VPC 安全连接到 ClickHouse Cloud,但不允许 ClickHouse Cloud 连接到您的内部网络。 + +根据 [AWS PrivateLink 文档](https://docs.aws.amazon.com/whitepapers/latest/building-scalable-secure-multi-vpc-network-infrastructure/aws-privatelink.html): + +> 当您设置客户端/服务器想要允许一个或多个消费者 VPC 单向访问服务提供商 VPC 中的特定服务或一组实例时,使用 AWS PrivateLink。只有消费者 VPC 中的客户端可以发起与服务提供商 VPC 中的服务的连接。 + +为此,请配置您的 AWS 安全组以允许 ClickHouse Cloud 与您的内部/私有数据库服务之间的连接。检查 [ClickHouse Cloud 区域的默认出站 IP 地址](/manage/security/cloud-endpoints-api),以及 [可用的静态 IP 地址](https://api.clickhouse.cloud/static-ips.json)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/connectivity/private_networking/02_aws-privatelink.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/connectivity/private_networking/02_aws-privatelink.md.hash new file mode 100644 index 00000000000..26986cd7f75 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/connectivity/private_networking/02_aws-privatelink.md.hash @@ -0,0 +1 @@ +b2f35526b955fef1 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/connectivity/private_networking/03_gcp-private-service-connect.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/connectivity/private_networking/03_gcp-private-service-connect.md new file mode 100644 index 00000000000..56d60ebdaf2 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/connectivity/private_networking/03_gcp-private-service-connect.md @@ -0,0 +1,439 @@ +--- +'title': 'GCP Private Service Connect' +'description': '本文件描述了如何使用 Google Cloud Platform (GCP) Private Service Connect (PSC) + 连接到 ClickHouse Cloud,以及如何通过 ClickHouse Cloud IP 访问列表禁用来自除 GCP PSC 地址以外的地址对您 ClickHouse + Cloud 服务的访问。' +'sidebar_label': 'GCP Private Service Connect' +'slug': '/manage/security/gcp-private-service-connect' +'doc_type': 'guide' +--- + +import Image from '@theme/IdealImage'; +import ScalePlanFeatureBadge from '@theme/badges/ScalePlanFeatureBadge'; +import gcp_psc_overview from '@site/static/images/cloud/security/gcp-psc-overview.png'; +import gcp_privatelink_pe_create from '@site/static/images/cloud/security/gcp-privatelink-pe-create.png'; +import gcp_psc_open from '@site/static/images/cloud/security/gcp-psc-open.png'; +import gcp_psc_enable_global_access from '@site/static/images/cloud/security/gcp-psc-enable-global-access.png'; +import gcp_psc_copy_connection_id from '@site/static/images/cloud/security/gcp-psc-copy-connection-id.png'; +import gcp_psc_create_zone from '@site/static/images/cloud/security/gcp-psc-create-zone.png'; +import gcp_psc_zone_type from '@site/static/images/cloud/security/gcp-psc-zone-type.png'; +import gcp_psc_dns_record from '@site/static/images/cloud/security/gcp-psc-dns-record.png'; +import gcp_pe_remove_private_endpoint from '@site/static/images/cloud/security/gcp-pe-remove-private-endpoint.png'; +import gcp_privatelink_pe_filters from '@site/static/images/cloud/security/gcp-privatelink-pe-filters.png'; +import gcp_privatelink_pe_dns from '@site/static/images/cloud/security/gcp-privatelink-pe-dns.png'; + + +# Private Service Connect {#private-service-connect} + + + +Private Service Connect (PSC) 是一个 Google Cloud 网络功能,允许消费者在其虚拟私有云(VPC)网络内私密访问托管服务。 同样,它允许托管服务提供者在自己的独立 VPC 网络中托管这些服务,并为其消费者提供私密连接。 + +服务提供者通过创建 Private Service Connect 服务将其应用程序发布给消费者。 服务消费者通过这些 Private Service Connect 类型之一直接访问这些 Private Service Connect 服务。 + +Private Service Connect 概述 + +:::important +默认情况下,即使 PSC 连接已获得批准并建立,ClickHouse 服务也无法通过 Private Service 连接访问;您需要通过完成以下 [步骤](#add-endpoint-id-to-services-allow-list) 显式地将 PSC ID 添加到实例级别的允许列表中。 +::: + +**使用 Private Service Connect 全球访问的重要注意事项**: +1. 使用全球访问的区域必须属于同一 VPC。 +1. 必须在 PSC 级别显式启用全球访问(请参阅下面的截图)。 +1. 确保您的防火墙设置不会阻止来自其他区域的 PSC 访问。 +1. 请注意,您可能会产生 GCP 跨区域数据传输费用。 + +不支持跨区域连接。生产者和消费者区域必须相同。 但是,您可以通过在 Private Service Connect (PSC) 级别启用 [全球访问](https://cloud.google.com/vpc/docs/about-accessing-vpc-hosted-services-endpoints#global-access) 从 VPC 内的其他区域进行连接。 + +**请完成以下步骤以启用 GCP PSC**: +1. 获取用于 Private Service Connect 的 GCP 服务附件。 +1. 创建服务端点。 +1. 将 "Endpoint ID" 添加到 ClickHouse Cloud 服务。 +1. 将 "Endpoint ID" 添加到 ClickHouse 服务允许列表中。 + +## 注意事项 {#attention} +ClickHouse 尝试将您的服务分组,以便在 GCP 区域内重用相同的已发布 [PSC 端点](https://cloud.google.com/vpc/docs/private-service-connect)。 不过,这种分组并不是保证的,尤其是在您在多个 ClickHouse 组织中分散服务的情况下。 +如果您已经为 ClickHouse 组织中的其他服务配置了 PSC,您通常可以跳过大部分步骤,因为可以直接进行最后一步:[将 "Endpoint ID" 添加到 ClickHouse 服务允许列表](#add-endpoint-id-to-services-allow-list)。 + +可以在 [这里](https://github.com/ClickHouse/terraform-provider-clickhouse/tree/main/examples/) 找到 Terraform 示例。 + +## 开始之前 {#before-you-get-started} + +:::note +下面提供了代码示例,以展示如何在 ClickHouse Cloud 服务中设置 Private Service Connect。 在我们下面的示例中,我们将使用: +- GCP 区域:`us-central1` +- GCP 项目(客户 GCP 项目):`my-gcp-project` +- 客户 GCP 项目中的 GCP 私有 IP 地址:`10.128.0.2` +- 客户 GCP 项目中的 GCP VPC:`default` +::: + +您需要检索有关 ClickHouse Cloud 服务的信息。您可以通过 ClickHouse Cloud 控制台或 ClickHouse API 进行此操作。如果您打算使用 ClickHouse API,请在继续之前设置以下环境变量: + +```shell +REGION= +PROVIDER=gcp +KEY_ID= +KEY_SECRET= +ORG_ID= +SERVICE_NAME= +``` + +您可以 [创建新的 ClickHouse Cloud API 密钥](/cloud/manage/openapi) 或使用现有的密钥。 + +通过按区域、提供者和服务名称过滤来获取 ClickHouse `INSTANCE_ID`: + +```shell +INSTANCE_ID=$(curl --silent --user "${KEY_ID:?}:${KEY_SECRET:?}" \ +"https://api.clickhouse.cloud/v1/organizations/${ORG_ID:?}/services" | \ +jq ".result[] | select (.region==\"${REGION:?}\" and .provider==\"${PROVIDER:?}\" and .name==\"${SERVICE_NAME:?}\") | .id " -r) +``` + +:::note +- 您可以从 ClickHouse 控制台(组织 -> 组织详细信息)中获取您的组织 ID。 +- 您可以 [创建一个新密钥](/cloud/manage/openapi) 或使用现有的密钥。 +::: + +## 获取 GCP 服务附件和 Private Service Connect 的 DNS 名称 {#obtain-gcp-service-attachment-and-dns-name-for-private-service-connect} + +### 选项 1:ClickHouse Cloud 控制台 {#option-1-clickhouse-cloud-console} + +在 ClickHouse Cloud 控制台中,打开您希望通过 Private Service Connect 连接的服务,然后打开 **设置** 菜单。 点击 **设置私有端点** 按钮。记下 **服务名称**( `endpointServiceId`)和 **DNS 名称**(`privateDnsHostname`)。您将在接下来的步骤中使用它们。 + +私有端点 + +### 选项 2:API {#option-2-api} + +:::note +您需要在该区域中部署至少一个实例才能执行此步骤。 +::: + +获取用于 Private Service Connect 的 GCP 服务附件和 DNS 名称: + +```bash +curl --silent --user "${KEY_ID:?}:${KEY_SECRET:?}" "https://api.clickhouse.cloud/v1/organizations/${ORG_ID:?}/services/${INSTANCE_ID:?}/privateEndpointConfig" | jq .result +{ + "endpointServiceId": "projects/.../regions/us-central1/serviceAttachments/production-us-central1-clickhouse-cloud", + "privateDnsHostname": "xxxxxxxxxx.us-central1.p.gcp.clickhouse.cloud" +} +``` + +记下 `endpointServiceId` 和 `privateDnsHostname`。您将在接下来的步骤中使用它们。 + +## 创建服务端点 {#create-service-endpoint} + +:::important +本节涵盖通过 GCP PSC(Private Service Connect)配置 ClickHouse 的特定细节。提供有关 GCP 的具体步骤作为参考,以指导您查找相关信息,但这些步骤可能会随时更改,恕不另行通知。请根据您的具体用例考虑 GCP 配置。 + +请注意,ClickHouse 不负责配置所需的 GCP PSC 端点、DNS 记录。 + +有关 GCP 配置任务的任何问题,请直接联系 GCP 支持。 +::: + +在本节中,我们将创建服务端点。 + +### 添加私有服务连接 {#adding-a-private-service-connection} + +首先,我们将创建一个私有服务连接。 + +#### 选项 1:使用 Google Cloud 控制台 {#option-1-using-google-cloud-console} + +在 Google Cloud 控制台中,导航到 **网络服务 -> 私有服务连接**。 + +在 Google Cloud 控制台中打开私有服务连接 + +通过单击 **连接端点** 按钮打开私有服务连接创建对话框。 + +- **目标**:选择 **已发布服务** +- **目标服务**:选择 [获取 GCP 服务附件和 Private Service Connect 的 DNS 名称](#obtain-gcp-service-attachment-and-dns-name-for-private-service-connect) 步骤中的 `endpointServiceId`API 或 `服务名称`控制台。 +- **端点名称**:设置 PSC **端点名称**。 +- **网络/子网络/IP 地址**:选择要用于连接的网络。您需要创建一个 IP 地址或使用现有的来作为 Private Service Connect 端点。在我们的示例中,我们预先创建了一个名为 **your-ip-address** 的地址,并分配了 IP 地址 `10.128.0.2`。 +- 为了使端点可从任何区域访问,您可以勾选 **启用全球访问** 复选框。 + +启用 Private Service Connect 的全球访问 + +要创建 PSC 端点,请使用 **添加端点** 按钮。 + +**状态** 列将在连接获得批准后从 **待处理** 更改为 **已接受**。 + +复制 PSC 连接 ID + +复制 ***PSC 连接 ID***,我们将在接下来的步骤中将其用作 ***端点 ID***。 + +#### 选项 2:使用 Terraform {#option-2-using-terraform} + +```json +provider "google" { + project = "my-gcp-project" + region = "us-central1" +} + +variable "region" { + type = string + default = "us-central1" +} + +variable "subnetwork" { + type = string + default = "https://www.googleapis.com/compute/v1/projects/my-gcp-project/regions/us-central1/subnetworks/default" +} + +variable "network" { + type = string + default = "https://www.googleapis.com/compute/v1/projects/my-gcp-project/global/networks/default" +} + +resource "google_compute_address" "psc_endpoint_ip" { + address = "10.128.0.2" + address_type = "INTERNAL" + name = "your-ip-address" + purpose = "GCE_ENDPOINT" + region = var.region + subnetwork = var.subnetwork +} + +resource "google_compute_forwarding_rule" "clickhouse_cloud_psc" { + ip_address = google_compute_address.psc_endpoint_ip.self_link + name = "ch-cloud-${var.region}" + network = var.network + region = var.region + load_balancing_scheme = "" + # service attachment + target = "https://www.googleapis.com/compute/v1/$TARGET" # See below in notes +} + +output "psc_connection_id" { + value = google_compute_forwarding_rule.clickhouse_cloud_psc.psc_connection_id + description = "Add GCP PSC Connection ID to allow list on instance level." +} +``` + +:::note +使用 [获取 GCP 服务附件和 Private Service Connect 的 DNS 名称](#obtain-gcp-service-attachment-and-dns-name-for-private-service-connect) 步骤中的 `endpointServiceId`API 或 `服务名称`控制台。 +::: + +## 设置端点的私有 DNS 名称 {#set-private-dns-name-for-endpoint} + +:::note +配置 DNS 有多种方法。请根据您的具体用例设置 DNS。 +::: + +您需要将从 [获取 GCP 服务附件和 Private Service Connect 的 DNS 名称](#obtain-gcp-service-attachment-and-dns-name-for-private-service-connect) 步骤中获取的 "DNS 名称" 指向 GCP 私有服务连接端点的 IP 地址。这确保您 VPC/网络内的服务/组件可以正确解析它。 + +## 将端点 ID 添加到 ClickHouse Cloud 组织 {#add-endpoint-id-to-clickhouse-cloud-organization} + +### 选项 1:ClickHouse Cloud 控制台 {#option-1-clickhouse-cloud-console-1} + +要将端点添加到您的组织,请继续到 [将 "Endpoint ID" 添加到 ClickHouse 服务允许列表](#add-endpoint-id-to-services-allow-list) 步骤。使用 ClickHouse Cloud 控制台将 `PSC 连接 ID` 添加到服务允许列表会自动将其添加到组织中。 + +要删除一个端点,请打开 **组织详细信息 -> 私有端点**,并单击删除按钮以删除该端点。 + +从 ClickHouse Cloud 移除私有端点 + +### 选项 2:API {#option-2-api-1} + +在运行任何命令之前,请设置这些环境变量: + +将 **Endpoint ID** 替换为 [添加私有服务连接](#adding-a-private-service-connection) 步骤中的值。 + +要添加端点,请运行: + +```bash +cat < + +### 选项 2:API {#option-2-api-2} + +在运行任何命令之前,请设置这些环境变量: + +将 **ENDPOINT_ID** 替换为 [添加私有服务连接](#adding-a-private-service-connection) 步骤中的 **Endpoint ID** 的值。 + +对每个应该通过 Private Service Connect 可用的服务执行此操作。 + +要添加: + +```bash +cat < + +#### 选项 2:API {#option-2-api-3} + +```bash +curl --silent --user "${KEY_ID:?}:${KEY_SECRET:?}" "https://api.clickhouse.cloud/v1/organizations/${ORG_ID:?}/services/${INSTANCE_ID:?}/privateEndpointConfig" | jq .result +``` + +```response +{ + ... + "privateDnsHostname": "xxxxxxx..p.gcp.clickhouse.cloud" +} +``` + +在此示例中,连接到 `xxxxxxx.yy-xxxxN.p.gcp.clickhouse.cloud` 主机名将被路由到 Private Service Connect。与此同时,`xxxxxxx.yy-xxxxN.gcp.clickhouse.cloud` 将通过互联网路由。 + +## 故障排除 {#troubleshooting} + +### 测试 DNS 设置 {#test-dns-setup} + +DNS_NAME - 使用 [获取 GCP 服务附件和 Private Service Connect 的 DNS 名称](#obtain-gcp-service-attachment-and-dns-name-for-private-service-connect) 步骤中的 `privateDnsHostname` + +```bash +nslookup $DNS_NAME +``` + +```response +Non-authoritative answer: +... +Address: 10.128.0.2 +``` + +### 连接被对等方重置 {#connection-reset-by-peer} + +- 很可能,端点 ID 未添加到服务允许列表。请重新访问 [_将端点 ID 添加到服务允许列表_ 步骤](#add-endpoint-id-to-services-allow-list)。 + +### 测试连接性 {#test-connectivity} + +如果您在使用 PSC 链接时遇到问题,请使用 `openssl` 检查您的连接性。确保 Private Service Connect 端点状态为 `已接受`: + +OpenSSL 应能够连接(请参见输出中的 CONNECTED)。`errno=104` 是预期的。 + +DNS_NAME - 使用 [获取 GCP 服务附件和 Private Service Connect 的 DNS 名称](#obtain-gcp-service-attachment-and-dns-name-for-private-service-connect) 步骤中的 `privateDnsHostname` + +```bash +openssl s_client -connect ${DNS_NAME}:9440 +``` + +```response + +# highlight-next-line +CONNECTED(00000003) +write:errno=104 +--- +no peer certificate available +--- +No client certificate CA names sent +--- +SSL handshake has read 0 bytes and written 335 bytes +Verification: OK +--- +New, (NONE), Cipher is (NONE) +Secure Renegotiation IS NOT supported +Compression: NONE +Expansion: NONE +No ALPN negotiated +Early data was not sent +Verify return code: 0 (ok) +``` + +### 检查端点过滤器 {#checking-endpoint-filters} + +#### REST API {#rest-api} + +```bash +curl --silent --user "${KEY_ID:?}:${KEY_SECRET:?}" -X GET -H "Content-Type: application/json" "https://api.clickhouse.cloud/v1/organizations/${ORG_ID:?}/services/${INSTANCE_ID:?}" | jq .result.privateEndpointIds +[ + "102600141743718403" +] +``` + +### 连接到远程数据库 {#connecting-to-a-remote-database} + +假设您正在尝试在 ClickHouse Cloud 中使用 [MySQL](/sql-reference/table-functions/mysql) 或 [PostgreSQL](/sql-reference/table-functions/postgresql) 表函数并连接到您托管在 GCP 的数据库。 GCP PSC 不能用于安全地启用此连接。 PSC 是单向的单向连接。它允许您的内部网络或 GCP VPC 安全连接到 ClickHouse Cloud,但不允许 ClickHouse Cloud 连接到您的内部网络。 + +根据 [GCP Private Service Connect 文档](https://cloud.google.com/vpc/docs/private-service-connect): + +> 面向服务的设计:生产者服务通过负载均衡器发布,向消费者 VPC 网络暴露单个 IP 地址。访问生产者服务的消费者流量是单向且只能访问服务 IP 地址,而不能访问整个对等 VPC 网络。 + +为此,请配置您的 GCP VPC 防火墙规则,以允许 ClickHouse Cloud 连接到您的内部/私有数据库服务。请检查 [ClickHouse Cloud 区域的默认出站 IP 地址](/manage/security/cloud-endpoints-api),以及 [可用的静态 IP 地址](https://api.clickhouse.cloud/static-ips.json)。 + +## 更多信息 {#more-information} + +有关更详细的信息,请访问 [cloud.google.com/vpc/docs/configure-private-service-connect-services](https://cloud.google.com/vpc/docs/configure-private-service-connect-services)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/connectivity/private_networking/03_gcp-private-service-connect.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/connectivity/private_networking/03_gcp-private-service-connect.md.hash new file mode 100644 index 00000000000..7c895ba795e --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/connectivity/private_networking/03_gcp-private-service-connect.md.hash @@ -0,0 +1 @@ +53025c9fffcf1dd7 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/connectivity/private_networking/04_azure-privatelink.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/connectivity/private_networking/04_azure-privatelink.md new file mode 100644 index 00000000000..5c4cff2f2b8 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/connectivity/private_networking/04_azure-privatelink.md @@ -0,0 +1,559 @@ +--- +'title': 'Azure Private Link' +'sidebar_label': 'Azure Private Link' +'slug': '/cloud/security/azure-privatelink' +'description': '如何设置 Azure Private Link' +'keywords': +- 'azure' +- 'private link' +- 'privatelink' +'doc_type': 'guide' +--- + +import Image from '@theme/IdealImage'; +import ScalePlanFeatureBadge from '@theme/badges/ScalePlanFeatureBadge'; +import azure_pe from '@site/static/images/cloud/security/azure-pe.png'; +import azure_privatelink_pe_create from '@site/static/images/cloud/security/azure-privatelink-pe-create.png'; +import azure_private_link_center from '@site/static/images/cloud/security/azure-private-link-center.png'; +import azure_pe_create_basic from '@site/static/images/cloud/security/azure-pe-create-basic.png'; +import azure_pe_resource from '@site/static/images/cloud/security/azure-pe-resource.png'; +import azure_pe_create_vnet from '@site/static/images/cloud/security/azure-pe-create-vnet.png'; +import azure_pe_create_dns from '@site/static/images/cloud/security/azure-pe-create-dns.png'; +import azure_pe_create_tags from '@site/static/images/cloud/security/azure-pe-create-tags.png'; +import azure_pe_create_review from '@site/static/images/cloud/security/azure-pe-create-review.png'; +import azure_pe_ip from '@site/static/images/cloud/security/azure-pe-ip.png'; +import azure_pe_view from '@site/static/images/cloud/security/azure-pe-view.png'; +import azure_pe_resource_id from '@site/static/images/cloud/security/azure-pe-resource-id.png'; +import azure_pe_resource_guid from '@site/static/images/cloud/security/azure-pe-resource-guid.png'; +import azure_pl_dns_wildcard from '@site/static/images/cloud/security/azure-pl-dns-wildcard.png'; +import azure_pe_remove_private_endpoint from '@site/static/images/cloud/security/azure-pe-remove-private-endpoint.png'; +import azure_privatelink_pe_filter from '@site/static/images/cloud/security/azure-privatelink-pe-filter.png'; +import azure_privatelink_pe_dns from '@site/static/images/cloud/security/azure-privatelink-pe-dns.png'; + + +# Azure Private Link + + + +本指南显示如何使用 Azure Private Link 在 Azure(包括客户自有和 Microsoft 合作伙伴服务)与 ClickHouse Cloud 之间通过虚拟网络提供私有连接。Azure Private Link 简化了网络架构,并通过消除对公共互联网的数据暴露来保护 Azure 中端点之间的连接。 + +Overview of PrivateLink + +Azure 支持通过 Private Link 进行跨区域连接。这使您能够在不同区域的虚拟网络(VNet)之间建立连接,前提是您在这些区域部署了 ClickHouse 服务。 + +:::note +跨区域流量可能会产生额外费用。请查看最新的 Azure 文档。 +::: + +**请完成以下步骤以启用 Azure Private Link:** + +1. 获取用于 Private Link 的 Azure 连接别名 +1. 在 Azure 中创建一个 Private Endpoint +1. 将 Private Endpoint 资源 ID 添加到您的 ClickHouse Cloud 组织中 +1. 将 Private Endpoint 资源 ID 添加到您的服务允许列表中 +1. 使用 Private Link 访问您的 ClickHouse Cloud 服务 + +:::note +ClickHouse Cloud Azure PrivateLink 已从使用 resourceGUID 切换为 Resource ID 过滤器。您仍然可以使用 resourceGUID,因为它是向后兼容的,但我们建议切换到 Resource ID 过滤器。要迁移,只需使用 Resource ID 创建一个新端点,将其附加到服务,并移除旧的基于 resourceGUID 的端点。 +::: + +## 注意 {#attention} +ClickHouse 尝试将您的服务分组以便重用同一发布的 [Private Link 服务](https://learn.microsoft.com/en-us/azure/private-link/private-link-service-overview) 在 Azure 区域中。然而,这种分组并不是保证的,特别是如果您将服务分散到多个 ClickHouse 组织中。 +如果您已经为 ClickHouse 组织中的其他服务配置了 Private Link,则通常可以跳过大多数步骤,因为该分组的存在,并直接进入最后一步:[将 Private Endpoint 资源 ID 添加到您的服务允许列表](#add-private-endpoint-id-to-services-allow-list)。 + +在 ClickHouse [Terraform Provider 仓库](https://github.com/ClickHouse/terraform-provider-clickhouse/tree/main/examples/)中找到 Terraform 示例。 + +## 获取用于 Private Link 的 Azure 连接别名 {#obtain-azure-connection-alias-for-private-link} + +### 选项 1:ClickHouse Cloud 控制台 {#option-1-clickhouse-cloud-console} + +在 ClickHouse Cloud 控制台中,打开您希望通过 PrivateLink 连接的服务,然后打开 **设置** 菜单。点击 **设置私有端点** 按钮。记录下 `服务名称` 和 `DNS 名称`,它们将用于设置 Private Link。 + +Private Endpoints + +记录下 `服务名称` 和 `DNS 名称`,它们将在下一步中使用。 + +### 选项 2:API {#option-2-api} + +在开始之前,您需要一个 ClickHouse Cloud API 密钥。您可以 [创建一个新密钥](/cloud/manage/openapi) 或使用现有密钥。 + +一旦您拥有 API 密钥,在运行任何命令之前设置以下环境变量: + +```bash +REGION= +PROVIDER=azure +KEY_ID= +KEY_SECRET= +ORG_ID= +SERVICE_NAME= +``` + +通过过滤区域、提供者和服务名称获取 ClickHouse 的 `INSTANCE_ID`: + +```shell +INSTANCE_ID=$(curl --silent --user "${KEY_ID:?}:${KEY_SECRET:?}" \ +"https://api.clickhouse.cloud/v1/organizations/${ORG_ID:?}/services" | \ +jq ".result[] | select (.region==\"${REGION:?}\" and .provider==\"${PROVIDER:?}\" and .name==\"${SERVICE_NAME:?}\") | .id " -r) +``` + +获取您的 Azure 连接别名和用于 Private Link 的私有 DNS 主机名: + +```bash +curl --silent --user "${KEY_ID:?}:${KEY_SECRET:?}" "https://api.clickhouse.cloud/v1/organizations/${ORG_ID:?}/services/${INSTANCE_ID:?}/privateEndpointConfig" | jq .result +{ + "endpointServiceId": "production-westus3-0-0.xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.westus3.azure.privatelinkservice", + "privateDnsHostname": "xxxxxxxxxx.westus3.privatelink.azure.clickhouse.cloud" +} +``` + +记录下 `endpointServiceId`。您将在下一步中使用它。 + +## 在 Azure 中创建私有端点 {#create-private-endpoint-in-azure} + +:::important +本节涵盖了通过 Azure Private Link 配置 ClickHouse 的特定细节。提供了 Azure 特定的步骤作为参考,以引导您了解应该查看的内容,但这些步骤可能会随着时间的推移而变化,因此请根据您的具体使用案例考虑 Azure 配置。 + +请注意,ClickHouse 对配置所需的 Azure 私有端点和 DNS 记录不负任何责任。 + +有关 Azure 配置任务的任何问题,请直接联系 Azure 支持。 +::: + +在本节中,我们将创建一个 Azure 中的 Private Endpoint。您可以使用 Azure Portal 或 Terraform。 + +### 选项 1:使用 Azure Portal 创建 Azure 中的私有端点 {#option-1-using-azure-portal-to-create-a-private-endpoint-in-azure} + +在 Azure Portal 中,打开 **私有链接中心 → 私有端点**。 + +Open Azure Private Center + +通过点击 **创建** 按钮打开私有端点创建对话框。 + +Open Azure Private Center + +--- + +在以下屏幕中,指定以下选项: + +- **订阅** / **资源组**:请选择用于私有端点的 Azure 订阅和资源组。 +- **名称**:为 **私有端点** 设置一个名称。 +- **区域**:选择将通过 Private Link 连接到 ClickHouse Cloud 的已部署 VNet 的区域。 + +完成上述步骤后,点击 **下一步:资源** 按钮。 + +Create Private Endpoint Basic + +--- + +选择 **通过资源 ID 或别名连接到 Azure 资源** 选项。 + +对于 **资源 ID 或别名**,使用您在 [获取用于 Private Link 的 Azure 连接别名](#obtain-azure-connection-alias-for-private-link) 步骤中获得的 `endpointServiceId`。 + +点击 **下一步:虚拟网络** 按钮。 + +Private Endpoint Resource Selection + +--- + +- **虚拟网络**:选择您希望使用 Private Link 连接到 ClickHouse Cloud 的 VNet +- **子网**:选择将在其上创建私有端点的子网 + +可选: + +- **应用安全组**:您可以将 ASG 附加到私有端点,并在网络安全组中使用,以过滤进出私有端点的网络流量。 + +点击 **下一步:DNS** 按钮。 + +Private Endpoint Virtual Network Selection + +点击 **下一步:标签** 按钮。 + +--- + +Private Endpoint DNS Configuration + +可选地,您可以为您的私有端点附加标签。 + +点击 **下一步:审核 + 创建** 按钮。 + +--- + +Private Endpoint Tags + +最后,点击 **创建** 按钮。 + +Private Endpoint Review + +创建的私有端点的 **连接状态** 将处于 **待定** 状态。一旦您将此私有端点添加到服务允许列表中,它将更改为 **已批准** 状态。 + +打开与私有端点关联的网络接口,复制 **私有 IPv4 地址**(在本例中为 10.0.0.4),您将在下一步中需要此信息。 + +Private Endpoint IP Address + +### 选项 2:使用 Terraform 创建 Azure 中的私有端点 {#option-2-using-terraform-to-create-a-private-endpoint-in-azure} + +使用下面的模板使用 Terraform 创建私有端点: + +```json +resource "azurerm_private_endpoint" "example_clickhouse_cloud" { + name = var.pe_name + location = var.pe_location + resource_group_name = var.pe_resource_group_name + subnet_id = var.pe_subnet_id + + private_service_connection { + name = "test-pl" + private_connection_resource_alias = "" + is_manual_connection = true + } +} +``` + +### 获取私有端点资源 ID {#obtaining-private-endpoint-resourceid} + +为了使用 Private Link,您需要将私有端点连接资源 ID 添加到您的服务允许列表中。 + +私有端点资源 ID 在 Azure Portal 中公开。打开在上一步中创建的私有端点并点击 **JSON 视图**: + +Private Endpoint View + +在属性下找到 `id` 字段并复制该值: + +**首选方法:使用资源 ID** +Private Endpoint Resource ID + +**遗留方法:使用 resourceGUID** +您仍然可以使用 resourceGUID 以保持向后兼容。从 `resourceGuid` 字段中找到并复制该值: + +Private Endpoint Resource GUID + +## 设置 Private Link 的 DNS {#setting-up-dns-for-private-link} + +您需要创建一个私有 DNS 区域 (`${location_code}.privatelink.azure.clickhouse.cloud`) 并将其附加到您的 VNet,以通过 Private Link 访问资源。 + +### 创建私有 DNS 区域 {#create-private-dns-zone} + +**选项 1:使用 Azure 门户** + +请按照此指南 [使用 Azure 门户创建 Azure 私有 DNS 区域](https://learn.microsoft.com/en-us/azure/dns/private-dns-getstarted-portal)。 + +**选项 2:使用 Terraform** + +使用以下 Terraform 模板创建私有 DNS 区域: + +```json +resource "azurerm_private_dns_zone" "clickhouse_cloud_private_link_zone" { + name = "${var.location}.privatelink.azure.clickhouse.cloud" + resource_group_name = var.resource_group_name +} +``` + +### 创建通配符 DNS 记录 {#create-a-wildcard-dns-record} + +创建通配符记录并指向您的私有端点: + +**选项 1:使用 Azure 门户** + +1. 打开 `MyAzureResourceGroup` 资源组并选择 `${region_code}.privatelink.azure.clickhouse.cloud` 私有区域。 +2. 选择 + 记录集。 +3. 在名称中输入 `*`。 +4. 在 IP 地址中输入您看到的私有端点的 IP 地址。 +5. 选择 **确定**。 + +Private Link DNS Wildcard Setup + +**选项 2:使用 Terraform** + +使用以下 Terraform 模板创建通配符 DNS 记录: + +```json +resource "azurerm_private_dns_a_record" "example" { + name = "*" + zone_name = var.zone_name + resource_group_name = var.resource_group_name + ttl = 300 + records = ["10.0.0.4"] +} +``` + +### 创建虚拟网络链接 {#create-a-virtual-network-link} + +要将私有 DNS 区域链接到虚拟网络,您需要创建一个虚拟网络链接。 + +**选项 1:使用 Azure 门户** + +请按照此指南 [将虚拟网络链接到您的私有 DNS 区域](https://learn.microsoft.com/en-us/azure/dns/private-dns-getstarted-portal#link-the-virtual-network)。 + +**选项 2:使用 Terraform** + +:::note +有多种配置 DNS 的方法。请根据您的具体使用案例设置 DNS。 +::: + +您需要将从 [获取用于 Private Link 的 Azure 连接别名](#obtain-azure-connection-alias-for-private-link) 步骤中获取的 "DNS 名称",指向私有端点的 IP 地址。这确保了您的 VPC/网络中的服务/组件能够正确解析它。 + +### 验证 DNS 设置 {#verify-dns-setup} + +`xxxxxxxxxx.westus3.privatelink.azure.clickhouse.cloud` 域应指向私有端点 IP。(在本例中为 10.0.0.4)。 + +```bash +nslookup xxxxxxxxxx.westus3.privatelink.azure.clickhouse.cloud. +Server: 127.0.0.53 +Address: 127.0.0.53#53 + +Non-authoritative answer: +Name: xxxxxxxxxx.westus3.privatelink.azure.clickhouse.cloud +Address: 10.0.0.4 +``` + +## 将私有端点资源 ID 添加到您的 ClickHouse Cloud 组织 {#add-the-private-endpoint-id-to-your-clickhouse-cloud-organization} + +### 选项 1:ClickHouse Cloud 控制台 {#option-1-clickhouse-cloud-console-1} + +要将端点添加到组织,请转到 [将私人端点资源 ID 添加到您的服务允许列表](#add-private-endpoint-id-to-services-allow-list) 步骤。使用 ClickHouse Cloud 控制台将私有端点资源 ID 添加到服务允许列表中,自动将其添加到组织中。 + +要删除端点,打开 **组织详情 -> 私有端点**,然后点击删除按钮以移除端点。 + +Remove Private Endpoint + +### 选项 2:API {#option-2-api-1} + +在运行任何命令之前设置以下环境变量: + +```bash +PROVIDER=azure +KEY_ID= +KEY_SECRET= +ORG_ID= +ENDPOINT_ID= +REGION= +``` + +使用 [获取私有端点资源 ID](#obtaining-private-endpoint-resourceid) 步骤中的数据设置 `ENDPOINT_ID` 环境变量。 + +运行以下命令以添加私有端点: + +```bash +cat < + +### 选项 2:API {#option-2-api-2} + +在运行任何命令之前设置以下环境变量: + +```bash +PROVIDER=azure +KEY_ID= +KEY_SECRET= +ORG_ID= +ENDPOINT_ID= +INSTANCE_ID= +``` + +对每个应该通过 Private Link 可用的服务执行此操作。 + +运行以下命令以将私有端点添加到服务允许列表: + +```bash +cat <API 或 `DNS 名称`控制台。 + +### 获取私有 DNS 主机名 {#obtaining-the-private-dns-hostname} + +#### 选项 1:ClickHouse Cloud 控制台 {#option-1-clickhouse-cloud-console-3} + +在 ClickHouse Cloud 控制台中,导航至 **设置**。点击 **设置私有端点** 按钮。在打开的侧边栏中,复制 **DNS 名称**。 + +Private Endpoint DNS Name + +#### 选项 2:API {#option-2-api-3} + +在运行任何命令之前设置以下环境变量: + +```bash +KEY_ID= +KEY_SECRET= +ORG_ID= +INSTANCE_ID= +``` + +运行以下命令: + +```bash +curl --silent --user "${KEY_ID:?}:${KEY_SECRET:?}" "https://api.clickhouse.cloud/v1/organizations/${ORG_ID:?}/services/${INSTANCE_ID:?}/privateEndpointConfig" | jq .result +``` + +您应该会收到类似于以下的响应: + +```response +{ + ... + "privateDnsHostname": "xxxxxxx..privatelink.azure.clickhouse.cloud" +} +``` + +在此示例中,连接到 `xxxxxxx.region_code.privatelink.azure.clickhouse.cloud` 主机名将路由到 Private Link。与此同时,`xxxxxxx.region_code.azure.clickhouse.cloud` 将通过互联网路由。 + +使用 `privateDnsHostname` 通过 Private Link 连接到您的 ClickHouse Cloud 服务。 + +## 疑难排解 {#troubleshooting} + +### 测试 DNS 设置 {#test-dns-setup} + +运行以下命令: + +```bash +nslookup +``` +其中 "dns 名称" 是来自 [获取用于 Private Link 的 Azure 连接别名](#obtain-azure-connection-alias-for-private-link) 的 `privateDnsHostname`API 或 `DNS 名称`控制台 + +您应该会收到以下响应: + +```response +Non-authoritative answer: +Name: +Address: 10.0.0.4 +``` + +### 连接被对等方重置 {#connection-reset-by-peer} + +很可能,私有端点资源 ID 未被添加到服务允许列表中。重新访问 [_将私有端点资源 ID 添加到您的服务允许列表_ 步骤](#add-private-endpoint-id-to-services-allow-list)。 + +### 私有端点处于待定状态 {#private-endpoint-is-in-pending-state} + +很可能,私有端点资源 ID 未被添加到服务允许列表中。重新访问 [_将私有端点资源 ID 添加到您的服务允许列表_ 步骤](#add-private-endpoint-id-to-services-allow-list)。 + +### 测试连接 {#test-connectivity} + +如果您在使用 Private Link 进行连接时遇到问题,请使用 `openssl` 检查您的连接情况。确保 Private Link 端点状态为 `Accepted`。 + +OpenSSL 应能够连接(在输出中看到 CONNECTED)。`errno=104` 是预期的。 + +```bash +openssl s_client -connect abcd.westus3.privatelink.azure.clickhouse.cloud:9440 +``` + +```response + +# highlight-next-line +CONNECTED(00000003) +write:errno=104 +--- +no peer certificate available +--- +No client certificate CA names sent +--- +SSL handshake has read 0 bytes and written 335 bytes +Verification: OK +--- +New, (NONE), Cipher is (NONE) +Secure Renegotiation IS NOT supported +Compression: NONE +Expansion: NONE +No ALPN negotiated +Early data was not sent +Verify return code: 0 (ok) +``` + +### 检查私有端点过滤器 {#checking-private-endpoint-filters} + +在运行任何命令之前设置以下环境变量: + +```bash +KEY_ID= +KEY_SECRET= +ORG_ID= +INSTANCE_ID= +``` + +运行以下命令检查私有端点过滤器: + +```bash +curl --silent --user "${KEY_ID:?}:${KEY_SECRET:?}" -X GET -H "Content-Type: application/json" "https://api.clickhouse.cloud/v1/organizations/${ORG_ID:?}/services/${INSTANCE_ID:?}" | jq .result.privateEndpointIds +``` + +## 更多信息 {#more-information} + +有关 Azure Private Link 的更多信息,请访问 [azure.microsoft.com/en-us/products/private-link](https://azure.microsoft.com/en-us/products/private-link)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/connectivity/private_networking/04_azure-privatelink.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/connectivity/private_networking/04_azure-privatelink.md.hash new file mode 100644 index 00000000000..5e77a21a1ee --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/connectivity/private_networking/04_azure-privatelink.md.hash @@ -0,0 +1 @@ +f1dd5d7e5a2fc7b7 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/connectivity/private_networking/_category_.json b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/connectivity/private_networking/_category_.json new file mode 100644 index 00000000000..1b1476fa879 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/connectivity/private_networking/_category_.json @@ -0,0 +1,5 @@ +{ + "label": "Private networking", + "collapsible": true, + "collapsed": true, +} \ No newline at end of file diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/connectivity/setting-ip-filters.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/connectivity/setting-ip-filters.md new file mode 100644 index 00000000000..de714e54f22 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/connectivity/setting-ip-filters.md @@ -0,0 +1,110 @@ +--- +'sidebar_label': '设置 IP 过滤器' +'slug': '/cloud/security/setting-ip-filters' +'title': '设置 IP 过滤器' +'description': '本页解释如何在 ClickHouse Cloud 中设置 IP 过滤器以控制对 ClickHouse 服务的访问。' +'doc_type': 'guide' +--- + +import Image from '@theme/IdealImage'; +import ip_filtering_after_provisioning from '@site/static/images/cloud/security/ip-filtering-after-provisioning.png'; +import ip_filter_add_single_ip from '@site/static/images/cloud/security/ip-filter-add-single-ip.png'; + +## 设置 IP 过滤器 {#setting-ip-filters} + +IP 访问列表通过指定哪些源地址被允许连接来过滤对 ClickHouse 服务或 API 密钥的流量。这些列表可以针对每个服务和每个 API 密钥进行配置。可以在服务或 API 密钥创建时配置列表,或之后进行配置。 + +:::important +如果您跳过为 ClickHouse Cloud 服务创建 IP 访问列表,则该服务将不允许任何流量。如果 ClickHouse 服务的 IP 访问列表设置为 `Allow from anywhere`,您的服务可能会定期被寻找公共 IP 的网络爬虫和扫描仪从闲置状态移动到活动状态,这可能会导致意外的费用。 +::: + +## 准备工作 {#prepare} + +在开始之前,收集应该添加到访问列表的 IP 地址或范围。考虑到远程工作者、值班地点、VPN 等。IP 访问列表用户界面接受单个地址和 CIDR 表示法。 + +无类别域间路由 (CIDR) 表示法允许您指定小于传统 A 类、B 类或 C 类 (8、6 或 24) 子网掩码大小的 IP 地址范围。如果您需要, [ARIN](https://account.arin.net/public/cidrCalculator) 和其他几个组织提供 CIDR 计算器,如果您想了解有关 CIDR 表示法的更多信息,请参见 [无类别域间路由 (CIDR)](https://www.rfc-editor.org/rfc/rfc4632.html) RFC。 + +## 创建或修改 IP 访问列表 {#create-or-modify-an-ip-access-list} + +:::note 仅适用于 PrivateLink 之外的连接 +IP 访问列表仅适用于来自公共互联网的连接,位于 [PrivateLink](/cloud/security/private-link-overview) 之外。 +如果您只想要来自 PrivateLink 的流量,请在 IP 允许列表中设置 `DenyAll`。 +::: + +
+ ClickHouse 服务的 IP 访问列表 + + 当您创建一个 ClickHouse 服务时,IP 允许列表的默认设置是“来自任何地方的允许”。 + + 从您的 ClickHouse Cloud 服务列表中选择服务,然后选择 **设置**。在 **安全性** 部分,您将找到 IP 访问列表。单击添加 IP 按钮。 + + 一个侧边栏将出现,供您配置选项: + +- 允许来自任何地方的传入流量到该服务 +- 允许来自特定位置的访问到该服务 +- 拒绝对该服务的所有访问 + +
+
+ API 密钥的 IP 访问列表 + + 当您创建一个 API 密钥时,IP 允许列表的默认设置是“来自任何地方的允许”。 + + 从 API 密钥列表中,单击 **操作** 列下 API 密钥旁边的三个点,然后选择 **编辑**。在屏幕底部,您将找到 IP 访问列表和配置选项: + +- 允许来自任何地方的传入流量到该服务 +- 允许来自特定位置的访问到该服务 +- 拒绝对该服务的所有访问 + +
+ +此屏幕截图显示了一个访问列表,该列表允许来自一系列 IP 地址的流量,描述为“NY 办公室范围”: + +ClickHouse Cloud 中的现有访问列表 + +### 可执行的操作 {#possible-actions} + +1. 添加额外条目,您可以使用 **+ 添加新 IP** + + 这个示例添加了一个单独的 IP 地址,并描述为 `伦敦服务器`: + +在 ClickHouse Cloud 中向访问列表添加单个 IP + +2. 删除现有条目 + + 单击交叉 (x) 可以删除条目。 + +3. 编辑现有条目 + + 直接修改该条目。 + +4. 切换以允许来自 **任何地方** 的访问 + + 这不推荐,但被允许。我们建议您将构建在 ClickHouse 之上的应用程序公开,并限制对后端 ClickHouse Cloud 服务的访问。 + +要应用您所做的更改,您必须单击 **保存**。 + +## 验证 {#verification} + +创建过滤器后,请确认可以从范围内连接到服务,并确认来自允许范围外的连接被拒绝。您可以使用简单的 `curl` 命令进行验证: +```bash title="Attempt rejected from outside the allow list" +curl https://.clickhouse.cloud:8443 +``` +```response +curl: (35) error:02FFF036:system library:func(4095):Connection reset by peer +``` +或 +```response +curl: (35) LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to HOSTNAME.clickhouse.cloud:8443 +``` + +```bash title="Attempt permitted from inside the allow list" +curl https://.clickhouse.cloud:8443 +``` +```response +Ok. +``` + +## 限制 {#limitations} + +- 当前,IP 访问列表仅支持 IPv4 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/connectivity/setting-ip-filters.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/connectivity/setting-ip-filters.md.hash new file mode 100644 index 00000000000..9824a371969 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/connectivity/setting-ip-filters.md.hash @@ -0,0 +1 @@ +b269a31a744b0bf2 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/data_masking.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/data_masking.md new file mode 100644 index 00000000000..2624a4ccbeb --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/data_masking.md @@ -0,0 +1,336 @@ +--- +'slug': '/cloud/guides/data-masking' +'sidebar_label': '数据掩码' +'title': '在 ClickHouse 中的数据掩码' +'description': '关于在 ClickHouse 中进行数据掩码的指南' +'keywords': +- 'data masking' +'doc_type': 'guide' +--- + + +# ClickHouse中的数据掩码 + +数据掩码是一种数据保护技术,在这种技术中,原始数据会被替换为符合其格式和结构的版本,同时移除任何个人可识别信息(PII)或敏感信息。 + +本指南展示了如何在ClickHouse中掩码数据。 + +## 使用字符串替换函数 {#using-string-functions} + +对于基本的数据掩码使用案例,`replace`函数系列提供了一种便捷的数据掩码方法: + +| 函数 | 描述 | +|------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------| +| [`replaceOne`](/sql-reference/functions/string-replace-functions#replaceone) | 用提供的替换字符串替换干草堆字符串中模式的第一个出现。 | +| [`replaceAll`](/sql-reference/functions/string-replace-functions#replaceall) | 用提供的替换字符串替换干草堆字符串中模式的所有出现。 | +| [`replaceRegexpOne`](/sql-reference/functions/string-replace-functions#replaceregexpone) | 用提供的替换字符串替换干草堆中与正则表达式模式(采用re2语法)匹配的子字符串的第一个出现。 | +| [`replaceRegexpAll`](/sql-reference/functions/string-replace-functions#replaceregexpall) | 用提供的替换字符串替换干草堆中与正则表达式模式(采用re2语法)匹配的所有子字符串的出现。 | + +例如,您可以使用`replaceOne`函数将名称“John Smith”替换为占位符`[CUSTOMER_NAME]`: + +```sql title="Query" +SELECT replaceOne( + 'Customer John Smith called about his account', + 'John Smith', + '[CUSTOMER_NAME]' +) AS anonymized_text; +``` + +```response title="Response" +┌─anonymized_text───────────────────────────────────┐ +│ Customer [CUSTOMER_NAME] called about his account │ +└───────────────────────────────────────────────────┘ +``` + +更一般地,您可以使用`replaceRegexpOne`来替换任何客户名称: + +```sql title="Query" +SELECT + replaceRegexpAll( + 'Customer John Smith called. Later, Mary Johnson and Bob Wilson also called.', + '\\b[A-Z][a-z]+ [A-Z][a-z]+\\b', + '[CUSTOMER_NAME]' + ) AS anonymized_text; +``` + +```response title="Response" +┌─anonymized_text───────────────────────────────────────────────────────────────────────┐ +│ [CUSTOMER_NAME] Smith called. Later, [CUSTOMER_NAME] and [CUSTOMER_NAME] also called. │ +└───────────────────────────────────────────────────────────────────────────────────────┘ +``` + +或者,您可以使用`replaceRegexpAll`函数掩码社会安全号码,仅保留最后4位数字。 + +```sql title="Query" +SELECT replaceRegexpAll( + 'SSN: 123-45-6789', + '(\d{3})-(\d{2})-(\d{4})', + 'XXX-XX-\3' +) AS masked_ssn; +``` + +在上面的查询中,` \3 `用于将第三个捕获组替换到结果字符串中,产生: + +```response title="Response" +┌─masked_ssn───────┐ +│ SSN: XXX-XX-6789 │ +└──────────────────┘ +``` + +## 创建掩码 `VIEW` {#masked-views} + +可以结合上述字符串函数使用 [`VIEW`](/sql-reference/statements/create/view) 对包含敏感数据的列应用转换,在数据呈现给用户之前。 +通过这种方式,原始数据保持不变,查询视图的用户仅看到掩码数据。 + +为了演示,假设我们有一个存储客户订单记录的表。 +我们希望确保一组员工可以查看信息,但我们不希望他们看到客户的完整信息。 + +运行下面的查询以创建一个示例表`orders`并插入一些虚构的客户订单记录: + +```sql +CREATE TABLE orders ( + user_id UInt32, + name String, + email String, + phone String, + total_amount Decimal(10,2), + order_date Date, + shipping_address String +) +ENGINE = MergeTree() +ORDER BY user_id; + +INSERT INTO orders VALUES + (1001, 'John Smith', 'john.smith@gmail.com', '555-123-4567', 299.99, '2024-01-15', '123 Main St, New York, NY 10001'), + (1002, 'Sarah Johnson', 'sarah.johnson@outlook.com', '555-987-6543', 149.50, '2024-01-16', '456 Oak Ave, Los Angeles, CA 90210'), + (1003, 'Michael Brown', 'mbrown@company.com', '555-456-7890', 599.00, '2024-01-17', '789 Pine Rd, Chicago, IL 60601'), + (1004, 'Emily Rogers', 'emily.rogers@yahoo.com', '555-321-0987', 89.99, '2024-01-18', '321 Elm St, Houston, TX 77001'), + (1005, 'David Wilson', 'dwilson@email.net', '555-654-3210', 449.75, '2024-01-19', '654 Cedar Blvd, Phoenix, AZ 85001'); +``` + +创建一个名为`masked_orders`的视图: + +```sql +CREATE VIEW masked_orders AS +SELECT + user_id, + replaceRegexpOne(name, '^([A-Za-z]+)\\s+(.*)$', '\\1 ****') AS name, + replaceRegexpOne(email, '^(.{0})[^@]*(@.*)$', '\\1****\\2') AS email, + replaceRegexpOne(phone, '^(\\d{3})-(\\d{3})-(\\d{4})$', '\\1-***-\\3') AS phone, + total_amount, + order_date, + replaceRegexpOne(shipping_address, '^[^,]+,\\s*(.*)$', '*** \\1') AS shipping_address +FROM orders; +``` + +在上面的视图创建查询的`SELECT`子句中,我们使用`replaceRegexpOne`定义了对`name`、`email`、`phone`和`shipping_address`字段的转换,这些字段包含我们希望部分掩码的敏感信息。 + +从视图中选择数据: + +```sql title="Query" +SELECT * FROM masked_orders +``` + +```response title="Response" +┌─user_id─┬─name─────────┬─email──────────────┬─phone────────┬─total_amount─┬─order_date─┬─shipping_address──────────┐ +│ 1001 │ John **** │ jo****@gmail.com │ 555-***-4567 │ 299.99 │ 2024-01-15 │ *** New York, NY 10001 │ +│ 1002 │ Sarah **** │ sa****@outlook.com │ 555-***-6543 │ 149.5 │ 2024-01-16 │ *** Los Angeles, CA 90210 │ +│ 1003 │ Michael **** │ mb****@company.com │ 555-***-7890 │ 599 │ 2024-01-17 │ *** Chicago, IL 60601 │ +│ 1004 │ Emily **** │ em****@yahoo.com │ 555-***-0987 │ 89.99 │ 2024-01-18 │ *** Houston, TX 77001 │ +│ 1005 │ David **** │ dw****@email.net │ 555-***-3210 │ 449.75 │ 2024-01-19 │ *** Phoenix, AZ 85001 │ +└─────────┴──────────────┴────────────────────┴──────────────┴──────────────┴────────────┴───────────────────────────┘ +``` + +请注意,从视图返回的数据是部分掩码的,模糊了敏感信息。 +您还可以创建多个视图,根据查看者对信息的特权访问级别实现不同程度的模糊处理。 + +为了确保用户只能访问返回掩码数据的视图,而无法访问原始未掩码数据的表,您应使用 [基于角色的访问控制](/cloud/security/cloud-access-management/overview) 来确保特定角色仅对视图的选择有授权。 + +首先创建角色: + +```sql +CREATE ROLE masked_orders_viewer; +``` + +接着将`SELECT`权限授予视图: + +```sql +GRANT SELECT ON masked_orders TO masked_orders_viewer; +``` + +由于ClickHouse角色是累加的,您必须确保那些只应查看掩码视图的用户没有通过任何角色对基础表具有`SELECT`权限。 + +因此,您应该明确撤销基础表访问以确保安全: + +```sql +REVOKE SELECT ON orders FROM masked_orders_viewer; +``` + +最后,将角色分配给适当的用户: + +```sql +GRANT masked_orders_viewer TO your_user; +``` + +这确保拥有`masked_orders_viewer`角色的用户仅能看到视图中的掩码数据,而无法查看表中的原始未掩码数据。 + +## 使用 `MATERIALIZED` 列和列级访问限制 {#materialized-ephemeral-column-restrictions} + +在您不想创建单独视图的情况下,您可以将掩码数据版本与原始数据一起存储。 +为此,您可以使用 [物化列](/sql-reference/statements/create/table#materialized)。 +此类列的值在插入行时会根据指定的物化表达式自动计算,我们可以用它们创建掩码数据的新列。 + +以之前的示例为例,我们现在将使用`MATERIALIZED`创建掩码列,而不是为掩码数据创建单独的`VIEW`: + +```sql +DROP TABLE IF EXISTS orders; +CREATE TABLE orders ( + user_id UInt32, + name String, + name_masked String MATERIALIZED replaceRegexpOne(name, '^([A-Za-z]+)\\s+(.*)$', '\\1 ****'), + email String, + email_masked String MATERIALIZED replaceRegexpOne(email, '^(.{0})[^@]*(@.*)$', '\\1****\\2'), + phone String, + phone_masked String MATERIALIZED replaceRegexpOne(phone, '^(\\d{3})-(\\d{3})-(\\d{4})$', '\\1-***-\\3'), + total_amount Decimal(10,2), + order_date Date, + shipping_address String, + shipping_address_masked String MATERIALIZED replaceRegexpOne(shipping_address, '^[^,]+,\\s*(.*)$', '*** \\1') +) +ENGINE = MergeTree() +ORDER BY user_id; + +INSERT INTO orders VALUES + (1001, 'John Smith', 'john.smith@gmail.com', '555-123-4567', 299.99, '2024-01-15', '123 Main St, New York, NY 10001'), + (1002, 'Sarah Johnson', 'sarah.johnson@outlook.com', '555-987-6543', 149.50, '2024-01-16', '456 Oak Ave, Los Angeles, CA 90210'), + (1003, 'Michael Brown', 'mbrown@company.com', '555-456-7890', 599.00, '2024-01-17', '789 Pine Rd, Chicago, IL 60601'), + (1004, 'Emily Rogers', 'emily.rogers@yahoo.com', '555-321-0987', 89.99, '2024-01-18', '321 Elm St, Houston, TX 77001'), + (1005, 'David Wilson', 'dwilson@email.net', '555-654-3210', 449.75, '2024-01-19', '654 Cedar Blvd, Phoenix, AZ 85001'); +``` + +如果您现在运行以下选择查询,您将看到在插入时,掩码数据“物化”并与原始未掩码数据一起存储。 +需要明确选择掩码列,因为ClickHouse默认不会在`SELECT *`查询中自动包含物化列。 + +```sql title="Query" +SELECT + *, + name_masked, + email_masked, + phone_masked, + shipping_address_masked +FROM orders +ORDER BY user_id ASC +``` + +```response title="Response" + ┌─user_id─┬─name──────────┬─email─────────────────────┬─phone────────┬─total_amount─┬─order_date─┬─shipping_address───────────────────┬─name_masked──┬─email_masked───────┬─phone_masked─┬─shipping_address_masked────┐ +1. │ 1001 │ John Smith │ john.smith@gmail.com │ 555-123-4567 │ 299.99 │ 2024-01-15 │ 123 Main St, New York, NY 10001 │ John **** │ jo****@gmail.com │ 555-***-4567 │ **** New York, NY 10001 │ +2. │ 1002 │ Sarah Johnson │ sarah.johnson@outlook.com │ 555-987-6543 │ 149.5 │ 2024-01-16 │ 456 Oak Ave, Los Angeles, CA 90210 │ Sarah **** │ sa****@outlook.com │ 555-***-6543 │ **** Los Angeles, CA 90210 │ +3. │ 1003 │ Michael Brown │ mbrown@company.com │ 555-456-7890 │ 599 │ 2024-01-17 │ 789 Pine Rd, Chicago, IL 60601 │ Michael **** │ mb****@company.com │ 555-***-7890 │ **** Chicago, IL 60601 │ +4. │ 1004 │ Emily Rogers │ emily.rogers@yahoo.com │ 555-321-0987 │ 89.99 │ 2024-01-18 │ 321 Elm St, Houston, TX 77001 │ Emily **** │ em****@yahoo.com │ 555-***-0987 │ **** Houston, TX 77001 │ +5. │ 1005 │ David Wilson │ dwilson@email.net │ 555-654-3210 │ 449.75 │ 2024-01-19 │ 654 Cedar Blvd, Phoenix, AZ 85001 │ David **** │ dw****@email.net │ 555-***-3210 │ **** Phoenix, AZ 85001 │ + └─────────┴───────────────┴───────────────────────────┴──────────────┴──────────────┴────────────┴────────────────────────────────────┴──────────────┴────────────────────┴──────────────┴────────────────────────────┘ +``` + +为了确保用户只能访问包含掩码数据的列,您可以再次使用 [基于角色的访问控制](/cloud/security/cloud-access-management/overview) 来确保特定角色仅对`orders`中的掩码列有选择授权。 + +重新创建我们之前创建的角色: + +```sql +DROP ROLE IF EXISTS masked_order_viewer; +CREATE ROLE masked_order_viewer; +``` + +接下来,将`SELECT`权限授予`orders`表: + +```sql +GRANT SELECT ON orders TO masked_data_reader; +``` + +撤销对任何敏感列的访问: + +```sql +REVOKE SELECT(name) ON orders FROM masked_data_reader; +REVOKE SELECT(email) ON orders FROM masked_data_reader; +REVOKE SELECT(phone) ON orders FROM masked_data_reader; +REVOKE SELECT(shipping_address) ON orders FROM masked_data_reader; +``` + +最后,将角色分配给适当的用户: + +```sql +GRANT masked_orders_viewer TO your_user; +``` + +在您希望在`orders`表中仅存储掩码数据的情况下,您可以将敏感的未掩码列标记为 [`EPHEMERAL`](/sql-reference/statements/create/table#ephemeral),这将确保这种类型的列不会存储在表中。 + +```sql +DROP TABLE IF EXISTS orders; +CREATE TABLE orders ( + user_id UInt32, + name String EPHEMERAL, + name_masked String MATERIALIZED replaceRegexpOne(name, '^([A-Za-z]+)\\s+(.*)$', '\\1 ****'), + email String EPHEMERAL, + email_masked String MATERIALIZED replaceRegexpOne(email, '^(.{2})[^@]*(@.*)$', '\\1****\\2'), + phone String EPHEMERAL, + phone_masked String MATERIALIZED replaceRegexpOne(phone, '^(\\d{3})-(\\d{3})-(\\d{4})$', '\\1-***-\\3'), + total_amount Decimal(10,2), + order_date Date, + shipping_address String EPHEMERAL, + shipping_address_masked String MATERIALIZED replaceRegexpOne(shipping_address, '^([^,]+),\\s*(.*)$', '*** \\2') +) +ENGINE = MergeTree() +ORDER BY user_id; + +INSERT INTO orders (user_id, name, email, phone, total_amount, order_date, shipping_address) VALUES + (1001, 'John Smith', 'john.smith@gmail.com', '555-123-4567', 299.99, '2024-01-15', '123 Main St, New York, NY 10001'), + (1002, 'Sarah Johnson', 'sarah.johnson@outlook.com', '555-987-6543', 149.50, '2024-01-16', '456 Oak Ave, Los Angeles, CA 90210'), + (1003, 'Michael Brown', 'mbrown@company.com', '555-456-7890', 599.00, '2024-01-17', '789 Pine Rd, Chicago, IL 60601'), + (1004, 'Emily Rogers', 'emily.rogers@yahoo.com', '555-321-0987', 89.99, '2024-01-18', '321 Elm St, Houston, TX 77001'), + (1005, 'David Wilson', 'dwilson@email.net', '555-654-3210', 449.75, '2024-01-19', '654 Cedar Blvd, Phoenix, AZ 85001'); +``` + +如果我们运行与之前相同的查询,您将看到仅将物化的掩码数据插入到表中: + +```sql title="Query" +SELECT + *, + name_masked, + email_masked, + phone_masked, + shipping_address_masked +FROM orders +ORDER BY user_id ASC +``` + +```response title="Response" + ┌─user_id─┬─total_amount─┬─order_date─┬─name_masked──┬─email_masked───────┬─phone_masked─┬─shipping_address_masked───┐ +1. │ 1001 │ 299.99 │ 2024-01-15 │ John **** │ jo****@gmail.com │ 555-***-4567 │ *** New York, NY 10001 │ +2. │ 1002 │ 149.5 │ 2024-01-16 │ Sarah **** │ sa****@outlook.com │ 555-***-6543 │ *** Los Angeles, CA 90210 │ +3. │ 1003 │ 599 │ 2024-01-17 │ Michael **** │ mb****@company.com │ 555-***-7890 │ *** Chicago, IL 60601 │ +4. │ 1004 │ 89.99 │ 2024-01-18 │ Emily **** │ em****@yahoo.com │ 555-***-0987 │ *** Houston, TX 77001 │ +5. │ 1005 │ 449.75 │ 2024-01-19 │ David **** │ dw****@email.net │ 555-***-3210 │ *** Phoenix, AZ 85001 │ + └─────────┴──────────────┴────────────┴──────────────┴────────────────────┴──────────────┴───────────────────────────┘ +``` + +## 使用日志数据的查询掩码规则 {#use-query-masking-rules} + +希望特别掩码日志数据的ClickHouse OSS用户可以使用 [查询掩码规则](/operations/server-configuration-parameters/settings#query_masking_rules)(日志掩码)来掩码数据。 + +为此,您可以在服务器配置中定义基于正则表达式的掩码规则。 +这些规则会在查询和所有日志消息被存储到服务器日志或系统表(如`system.query_log`、`system.text_log`和`system.processes`)之前应用。 + +这有助于防止敏感数据泄漏到仅在**日志**中。 +请注意,它不会掩码查询结果中的数据。 + +例如,要掩码社会安全号码,您可以将以下规则添加到您的 [服务器配置](/operations/configuration-files) 中: + +```yaml + + + hide SSN + (^|\D)\d{3}-\d{2}-\d{4}($|\D) + 000-00-0000 + + +``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/data_masking.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/data_masking.md.hash new file mode 100644 index 00000000000..8fef285c009 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/guides/security/data_masking.md.hash @@ -0,0 +1 @@ +fcd25e5b7680512f diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/_category_.yml b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/_category_.yml deleted file mode 100644 index 59089856c86..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/_category_.yml +++ /dev/null @@ -1,6 +0,0 @@ -label: 'Manage Cloud' -collapsible: true -collapsed: true -link: - type: generated-index - title: Manage ClickHouse Cloud diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/account-close.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/account-close.md deleted file mode 100644 index 26c0c414dae..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/account-close.md +++ /dev/null @@ -1,52 +0,0 @@ ---- -'sidebar_label': '删除账户' -'slug': '/cloud/manage/close_account' -'title': '账户关闭与删除' -'description': '我们知道有时会有必要关闭账户的情况。此指南将帮助您完成该过程。' ---- - -## 账户关闭与删除 {#account-close--deletion} -我们的目标是帮助您在项目中取得成功。如果您有未在本网站上解答的问题或需要帮助评估独特的用例,请通过 [support@clickhouse.com](mailto:support@clickhouse.com) 与我们联系。 - -我们知道有时会出现需要关闭账户的情况。本指南将帮助您完成该过程。 - -## 关闭与删除 {#close-vs-delete} -客户可以重新登录已关闭的账户以查看使用情况、账单和账户级活动日志。这使您可以轻松访问有助于多种目的的详细信息,从记录用例到在年底下载发票以用于税务目的。您还将继续接收产品更新,以便知道您可能一直在等待的功能现在是否可用。此外,已关闭的账户可以随时重新开放以开始新的服务。 - -请求个人数据删除的客户应注意,这是一项不可逆的过程。账户及相关信息将不再可用。您将不会收到产品更新,并且可能无法重新开放账户。这不会影响任何新闻通讯订阅。 - -新闻通讯订阅者可以随时通过使用新闻通讯电子邮件底部的取消订阅链接取消订阅,而无需关闭其账户或删除其信息。 - -## 关闭准备 {#preparing-for-closure} - -在请求关闭账户之前,请采取以下步骤以准备账户。 -1. 导出您需要保留的任何服务数据。 -2. 停止并删除您的服务。这将防止您账户上产生额外费用。 -3. 删除除了请求关闭的管理员以外的所有用户。这将帮助您确保在流程完成期间不会创建新的服务。 -4. 查看控制面板中的“使用情况”和“账单”标签,以验证所有费用已支付。我们无法关闭有未付款余额的账户。 - -## 请求关闭账户 {#request-account-closure} - -我们必须对关闭和删除请求进行身份验证。为确保您的请求能够快速处理,请遵循以下步骤。 -1. 登录到您的 clickhouse.cloud 账户。 -2. 完成“关闭准备”部分中的任何剩余步骤。 -3. 点击帮助按钮(屏幕右上角的问号)。 -4. 在“支持”下点击“创建 case”。 -5. 在“创建新 case”屏幕中,输入以下内容: - -```text -Priority: Severity 3 -Subject: Please close my ClickHouse account -Description: We would appreciate it if you would share a brief note about why you are cancelling. -``` - -6. 点击“创建新 case” -7. 我们将关闭您的账户并发送确认电子邮件,以便让您知道何时完成。 - - -## 请求个人数据删除 {#request-personal-data-deletion} -请注意,只有账户管理员可以请求从 ClickHouse 删除个人数据。如果您不是账户管理员,请联系您的 ClickHouse 账户管理员请求从账户中删除。 - -要请求数据删除,请按照上面的“请求关闭账户”中的步骤进行。当输入案例信息时,将主题更改为“请关闭我的 ClickHouse 账户并删除我的个人数据。” - -我们将在 30 天内完成个人数据删除请求。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/account-close.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/account-close.md.hash deleted file mode 100644 index 01d80fe7fe7..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/account-close.md.hash +++ /dev/null @@ -1 +0,0 @@ -94aa9906dcb7b95a diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/api/api-overview.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/api/api-overview.md deleted file mode 100644 index 20192c3a6f3..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/api/api-overview.md +++ /dev/null @@ -1,36 +0,0 @@ ---- -'sidebar_label': '概述' -'sidebar_position': 1 -'title': 'ClickHouse Cloud API' -'slug': '/cloud/manage/api/api-overview' -'description': '了解 ClickHouse Cloud API' ---- - - -# ClickHouse Cloud API - -## 概述 {#overview} - -ClickHouse Cloud API 是一个 REST API,旨在帮助开发者轻松管理 ClickHouse Cloud 上的组织和服务。使用我们的 Cloud API,您可以创建和管理服务、配置 API 密钥、添加或移除您组织中的成员等等。 - -[了解如何创建您的第一个 API 密钥并开始使用 ClickHouse Cloud API.](/cloud/manage/openapi.md) - -## Swagger (OpenAPI) 端点和 UI {#swagger-openapi-endpoint-and-ui} - -ClickHouse Cloud API 基于开源的 [OpenAPI 规范](https://www.openapis.org/) 构建,以便于可预测的客户端消费。如果您需要以编程方式访问 ClickHouse Cloud API 文档,我们提供一个基于 JSON 的 Swagger 端点,网址为 https://api.clickhouse.cloud/v1。您还可以通过 [Swagger UI](https://clickhouse.com/docs/cloud/manage/api/swagger) 查找 API 文档。 - -## 速率限制 {#rate-limits} - -每个组织的开发者最多可以拥有 100 个 API 密钥。每个 API 密钥在 10 秒内最多可以发起 10 次请求。如果您希望增加组织的 API 密钥数量或每 10 秒内的请求次数,请联系 support@clickhouse.com。 - -## Terraform 提供者 {#terraform-provider} - -官方的 ClickHouse Terraform 提供者允许您使用 [基础设施即代码](https://www.redhat.com/en/topics/automation/what-is-infrastructure-as-code-iac) 来创建可预测的、版本控制的配置,从而使部署的错误率大大降低。 - -您可以在 [Terraform 注册表](https://registry.terraform.io/providers/ClickHouse/clickhouse/latest/docs) 中查看 Terraform 提供者文档。 - -如果您想为 ClickHouse Terraform 提供者做贡献,可以在 [GitHub 存储库](https://github.com/ClickHouse/terraform-provider-clickhouse) 中查看源代码。 - -## 支持 {#support} - -我们建议您首先访问 [我们的 Slack 频道](https://clickhouse.com/slack) 获取快速支持。如果您需要额外的帮助或有关我们 API 及其功能的更多信息,请联系 ClickHouse 支持,网址为 https://console.clickhouse.cloud/support diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/api/api-overview.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/api/api-overview.md.hash deleted file mode 100644 index 21c0488c9ae..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/api/api-overview.md.hash +++ /dev/null @@ -1 +0,0 @@ -70ca4744c2f48cb5 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/api/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/api/index.md deleted file mode 100644 index 217c5e243a3..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/api/index.md +++ /dev/null @@ -1,13 +0,0 @@ ---- -'title': 'Cloud API' -'slug': '/cloud/manage/cloud-api' -'description': 'Cloud API 章节的着陆页' ---- - -这个部分包含有关 Cloud API 的参考文档,包含以下页面: - -| 页面 | 描述 | -|--------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------| -| [概述](/cloud/manage/api/api-overview) | 提供速率限制、Terraform 提供程序、Swagger (OpenAPI) 端点和用户界面及可用支持的概述。 | -| [管理 API 密钥](/cloud/manage/openapi) | 了解更多关于 Cloud 的 API,利用 OpenAPI 让您能够以编程方式管理您的账户及服务的各个方面。 | -| [API 参考](https://clickhouse.com/docs/cloud/manage/api/swagger) | OpenAPI (swagger) 参考页面。 | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/api/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/api/index.md.hash deleted file mode 100644 index dea3784a5bb..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/api/index.md.hash +++ /dev/null @@ -1 +0,0 @@ -ad4a986b80f1932a diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/backups/configurable-backups.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/backups/configurable-backups.md deleted file mode 100644 index ec565bb65da..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/backups/configurable-backups.md +++ /dev/null @@ -1,44 +0,0 @@ ---- -'sidebar_label': '可配置备份' -'slug': '/cloud/manage/backups/configurable-backups' -'description': '可配置备份' -'title': '可配置备份' -'keywords': -- 'backups' -- 'cloud backups' -- 'restore' ---- - -import backup_settings from '@site/static/images/cloud/manage/backup-settings.png'; -import backup_configuration_form from '@site/static/images/cloud/manage/backup-configuration-form.png'; -import CloudNotSupportedBadge from '@theme/badges/CloudNotSupportedBadge'; -import ScalePlanFeatureBadge from '@theme/badges/ScalePlanFeatureBadge'; -import Image from '@theme/IdealImage'; - - - -ClickHouse Cloud 允许您为 **Scale** 和 **Enterprise** 级别的服务配置备份的时间表。备份可以根据您的业务需求沿以下维度进行配置。 - -- **保留**:每个备份将保留的天数。保留期可以指定为最短 1 天,最长可达 30 天,并可以在之间选择多个值。 -- **频率**:频率允许您指定后续备份之间的时间间隔。例如,“每 12 小时一次”的频率意味着备份将相隔 12 小时。频率范围从“每 6 小时一次”到“每 48 小时一次”,具体的小时增量为:`6`、`8`、`12`、`16`、`20`、`24`、`36`、`48`。 -- **开始时间**:您希望每天安排备份的开始时间。指定开始时间意味着备份的“频率”将默认为每 24 小时一次。 ClickHouse Cloud 会在指定开始时间的一个小时内开始备份。 - -:::note -自定义时间表将覆盖您所给定服务在 ClickHouse Cloud 中的默认备份策略。 -::: - -要为某项服务配置备份时间表,请转到控制台中的 **设置** 选项卡,然后点击 **更改备份配置**。 - -配置备份设置 - -这将在右侧打开一个选项卡,您可以选择保留、频率和开始时间的值。您需要保存所选设置以使其生效。 - -选择备份保留和频率 - -:::note -开始时间和频率是互斥的。开始时间优先。 -::: - -:::note -更改备份时间表可能会导致更高的存储每月费用,因为某些备份可能不在服务的默认备份中覆盖。请参阅下面的 ["理解备份成本"](./overview.md/#understanding-backup-cost) 部分。 -::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/backups/configurable-backups.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/backups/configurable-backups.md.hash deleted file mode 100644 index 131e0593d43..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/backups/configurable-backups.md.hash +++ /dev/null @@ -1 +0,0 @@ -ded388302fa94ada diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/backups/export-backups-to-own-cloud-account.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/backups/export-backups-to-own-cloud-account.md.hash deleted file mode 100644 index fa7af426da1..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/backups/export-backups-to-own-cloud-account.md.hash +++ /dev/null @@ -1 +0,0 @@ -a74c503da7bdc353 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/backups/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/backups/index.md deleted file mode 100644 index fa93ca44a35..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/backups/index.md +++ /dev/null @@ -1,15 +0,0 @@ ---- -'slug': '/cloud/manage/backups' -'title': '备份' -'description': '备份的目录页面.' -'keywords': -- 'backups' -- 'configurable backups' -- 'export backups to own cloud' ---- - -| 页面 | 描述 | -|--------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------| -| [概述](./overview.md) | 备份的概述页面。 | -| [可配置备份](./configurable-backups.md) | 了解如何在规模和企业级用户可以根据其特定的业务需求自定义备份计划。 | -| [将备份导出到自己的云帐户](./export-backups-to-own-cloud-account.md) | 了解企业级功能,该功能使您能够将备份导出到自己的云帐户。 | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/backups/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/backups/index.md.hash deleted file mode 100644 index d747e535481..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/backups/index.md.hash +++ /dev/null @@ -1 +0,0 @@ -da87a14f6088acac diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/backups/overview.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/backups/overview.md deleted file mode 100644 index dbd4f33bea5..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/backups/overview.md +++ /dev/null @@ -1,180 +0,0 @@ ---- -'sidebar_label': '概述' -'sidebar_position': 0 -'slug': '/cloud/manage/backups/overview' -'title': '概述' -'keywords': -- 'backups' -- 'cloud backups' -- 'restore' -'description': '提供有关 ClickHouse Cloud 中备份的概述' ---- - -import CloudNotSupportedBadge from '@theme/badges/CloudNotSupportedBadge'; -import ScalePlanFeatureBadge from '@theme/badges/ScalePlanFeatureBadge'; -import Image from '@theme/IdealImage'; -import backup_chain from '@site/static/images/cloud/manage/backup-chain.png'; -import backup_status_list from '@site/static/images/cloud/manage/backup-status-list.png'; -import backup_usage from '@site/static/images/cloud/manage/backup-usage.png'; -import backup_restore from '@site/static/images/cloud/manage/backup-restore.png'; -import backup_service_provisioning from '@site/static/images/cloud/manage/backup-service-provisioning.png'; - - -# 备份 - -数据库备份通过确保在任何不可预见的原因导致数据丢失时,可以从最后一次成功的备份中将服务恢复到之前的状态,从而提供了一个安全网。这将最小化停机时间,并防止业务关键数据永久丢失。本指南涵盖了备份在 ClickHouse Cloud 中的工作原理,您可以为您的服务配置备份的选项,以及如何从备份中恢复。 - -## 备份在 ClickHouse Cloud 中的工作原理 {#how-backups-work-in-clickhouse-cloud} - -ClickHouse Cloud 备份是“全量”和“增量”备份的组合,构成了备份链。备份链以全量备份开始,然后在接下来的几个计划时间段内进行增量备份,以创建一系列备份。一旦备份链达到一定长度,将启动新链。在需要时,整个备份链可以用于将数据恢复到新服务。一旦特定链中包含的所有备份超过服务设置的保留时间框架(更多关于保留的内容见下文),该链将被丢弃。 - -在下面的截图中,实线方块表示全量备份,虚线方块表示增量备份。包围方块的实线矩形表示保留期以及最终用户可以用于备份恢复的备份。在下面的场景中,备份每24小时进行一次,并保留2天。 - -在第1天,进行全量备份以启动备份链。在第2天,进行增量备份,现在可以从全量和增量备份中进行恢复。到第7天,我们在链中有一个全量备份和六个增量备份,其中最近的两个增量备份对用户可见。在第8天,我们进行新的全量备份,在第9天,当我们在新链中有两个备份时,前一个链将被丢弃。 - -ClickHouse Cloud中的备份链示例 - -*ClickHouse Cloud中的备份场景示例* - -## 默认备份策略 {#default-backup-policy} - -在 Basic、Scale 和 Enterprise 级别,备份是计量并与存储分开计费的。所有服务默认设置为一个备份,并可以通过 Cloud Console 的设置选项卡配置更多备份,从 Scale 级别开始。 - -## 备份状态列表 {#backup-status-list} - -您的服务将根据设定的计划备份,无论是默认的每日计划还是您选择的[自定义计划](./configurable-backups.md)。所有可用的备份可以从服务的 **Backups** 选项卡中查看。从这里,您可以看到备份的状态、持续时间以及备份的大小。您还可以使用 **Actions** 列恢复特定的备份。 - -ClickHouse Cloud中的备份状态列表 - -## 理解备份成本 {#understanding-backup-cost} - -根据默认策略,ClickHouse Cloud 每天要求进行一次备份,并保持 24 小时的保留。选择需要保留更多数据的计划,或导致更频繁备份的计划可能会产生额外的备份存储费用。 - -要了解备份成本,您可以从使用屏幕查看每项服务的备份成本(如下所示)。一旦您在几天内运行了定制计划的备份,您就可以对成本有一个大致的了解,并推算出每月的备份成本。 - -ClickHouse Cloud中的备份使用图表 - -估算备份的总成本需要您设置一个计划。我们也在更新我们的[定价计算器](https://clickhouse.com/pricing),以便您在设置计划之前获得月度成本估算。您需要提供以下输入才能估算成本: -- 全量和增量备份的大小 -- 所需频率 -- 所需保留期 -- 云提供商和区域 - -:::note -请记住,随着服务中数据的增长,备份的估计成本将会变化。 -::: - -## 从备份中恢复 {#restore-a-backup} - -备份是恢复到新的 ClickHouse Cloud 服务,而不是恢复到源服务中。 - -单击 **Restore** 备份图标后,您可以指定将要创建的新服务的服务名称,然后恢复此备份: - -在 ClickHouse Cloud 中恢复备份 - -新服务在就绪之前将在服务列表中显示为 `Provisioning`: - -正在进行服务配置 - -## 使用恢复的服务 {#working-with-your-restored-service} - -备份恢复后,您现在将有两个类似的服务:需要恢复的 **原始服务** 和从原始服务的备份中恢复的新 **恢复服务**。 - -备份恢复完成后,您可以执行以下操作之一: -- 使用新恢复的服务并删除原始服务。 -- 将数据从新恢复的服务迁移回原始服务,并删除新恢复的服务。 - -### 使用 **新恢复的服务** {#use-the-new-restored-service} - -要使用新服务,请执行以下步骤: - -1. 验证新服务是否具有您的用例所需的 IP 访问列表条目。 -1. 验证新服务是否包含您所需的数据。 -1. 删除原始服务。 - -### 从 **新恢复的服务** 迁移数据回 **原始服务** {#migrate-data-from-the-newly-restored-service-back-to-the-original-service} - -假设您由于某种原因无法使用新恢复的服务,例如,如果您仍有用户或应用程序连接到现有服务。您可以决定将新恢复的数据迁移到原始服务。通过以下步骤可以完成迁移: - -**允许对新恢复服务的远程访问** - -新服务应从与原始服务相同的 IP 允许列表的备份中恢复。这是必要的,因为如果您没有允许 **Anywhere** 的访问,则不允许连接到其他 ClickHouse Cloud 服务。修改允许列表并暂时允许来自 **Anywhere** 的访问。有关详细信息,请参见[IP 访问列表](/cloud/security/setting-ip-filters)文档。 - -**在新恢复的 ClickHouse 服务上(承载恢复数据的系统):** - -:::note -您需要重置新服务的密码才能访问它。您可以通过服务列表中的 **Settings** 选项卡进行此操作。 -::: - -添加一个只读用户,可以读取源表(在此示例中为 `db.table`): - -```sql -CREATE USER exporter -IDENTIFIED WITH SHA256_PASSWORD BY 'password-here' -SETTINGS readonly = 1; -``` - -```sql -GRANT SELECT ON db.table TO exporter; -``` - -复制表定义: - -```sql -SELECT create_table_query -FROM system.tables -WHERE database = 'db' AND table = 'table' -``` - -**在目标 ClickHouse Cloud 系统上(原来存在损坏表的系统):** - -创建目标数据库: -```sql -CREATE DATABASE db -``` - -使用源的 `CREATE TABLE` 语句创建目标: - -:::tip -在执行 `CREATE` 语句时,将 `ENGINE` 更改为 `ReplicatedMergeTree`,而不带任何参数。 ClickHouse Cloud 始终为表复制并提供正确的参数。 -::: - -```sql -CREATE TABLE db.table ... -ENGINE = ReplicatedMergeTree -ORDER BY ... -``` - -使用 `remoteSecure` 函数将数据从新恢复的 ClickHouse Cloud 服务拉入您的原始服务: - -```sql -INSERT INTO db.table -SELECT * -FROM remoteSecure('source-hostname', db, table, 'exporter', 'password-here') -``` - -在成功将数据插入原始服务后,请务必验证服务中的数据。验证数据后,还应删除新服务。 - -## 无法删除或撤销删除表 {#undeleting-or-undropping-tables} - - - -`UNDROP` 命令在 ClickHouse Cloud 中不受支持。如果您意外 `DROP` 表,最佳做法是恢复您的最后一次备份,并从备份中重新创建表。 - -为了防止用户意外删除表,您可以使用[`GRANT` 语句](/sql-reference/statements/grant)撤销特定用户或角色的[`DROP TABLE`命令](/sql-reference/statements/drop#drop-table)的权限。 - -:::note -为了防止数据意外删除,请注意,默认情况下,在 ClickHouse Cloud 中不允许删除大于 `1TB` 的表。如果您希望删除超过此阈值的表,可以使用设置 `max_table_size_to_drop` 来执行: -```sql -DROP TABLE IF EXISTS table_to_drop -SYNC SETTINGS max_table_size_to_drop=2097152 -- increases the limit to 2TB -``` -::: - -## 可配置的备份 {#configurable-backups} - -如果您希望设置不同于默认备份计划的备份计划,请查看[可配置的备份](./configurable-backups.md)。 - -## 将备份导出到您自己的云账户 {#export-backups-to-your-own-cloud-account} - -有关想要将备份导出到自己云账户的用户,请参见[这里](./export-backups-to-own-cloud-account.md)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/backups/overview.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/backups/overview.md.hash deleted file mode 100644 index dfe9a56f620..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/backups/overview.md.hash +++ /dev/null @@ -1 +0,0 @@ -a85f0c762c56a7c5 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing.md deleted file mode 100644 index 978aed993be..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing.md +++ /dev/null @@ -1,573 +0,0 @@ ---- -'sidebar_label': '概述' -'slug': '/cloud/manage/billing/overview' -'title': '定价' -'description': 'ClickHouse Cloud 定价的概述页面' ---- - -import ClickPipesFAQ from './jan2025_faq/_snippets/_clickpipes_faq.md' - -有关定价信息,请参阅 [ClickHouse Cloud 定价](https://clickhouse.com/pricing#pricing-calculator) 页面。 -ClickHouse Cloud 根据计算、存储、[数据传输](/cloud/manage/network-data-transfer)(互联网的出口和跨区域)、和 [ClickPipes](/integrations/clickpipes) 的使用情况进行计费。 -要了解哪些因素可能影响您的账单以及您可以管理支出的方式,请继续阅读。 - -## 亚马逊网络服务 (AWS) 示例 {#amazon-web-services-aws-example} - -:::note -- 价格反映了 AWS us-east-1 的定价。 -- 适用的数据传输和 ClickPipes 收费请 [点击这里](jan2025_faq/dimensions.md)。 -::: - -### 基本:每月起价 $66.52 {#basic-from-6652-per-month} - -最佳适用:用于小型数据量的部门用例,无需严格的可靠性保证。 - -**基本服务** -- 1 个副本 x 8 GiB RAM, 2 vCPU -- 500 GB 的压缩数据 -- 500 GB 的数据备份 -- 10 GB 的公共互联网出口数据传输 -- 5 GB 的跨区域数据传输 - -本示例的定价细分: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
活跃 6 小时/天活跃 12 小时/天活跃 24 小时/天
计算\$39.91\$79.83\$159.66
存储\$25.30\$25.30\$25.30
公共互联网出口数据传输\$1.15\$1.15\$1.15
跨区域数据传输\$0.16\$0.16\$0.16
总计\$66.52\$106.44\$186.27
- -### 扩展(常开、自动扩展):每月起价 $499.38 {#scale-always-on-auto-scaling-from-49938-per-month} - -最佳适用:需要增强的服务级别协议 (SLA)(2 个以上副本服务)、可扩展性和高级安全性的工作负载。 - -**扩展服务** -- 活跃工作负载 ~100% 时间 -- 自动扩展可防止账单失控的最大可配置限制 -- 100 GB 的公共互联网出口数据传输 -- 10 GB 的跨区域数据传输 - -本示例的定价细分: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
示例 1示例 2示例 3
计算2 个副本 x 8 GiB RAM, 2 vCPU

\$436.95
2 个副本 x 16 GiB RAM, 4 vCPU

\$873.89
3 个副本 x 16 GiB RAM, 4 vCPU

\$1,310.84
存储1 TB 的数据 + 1 个备份

\$50.60
2 TB 的数据 + 1 个备份

\$101.20
3 TB 的数据 + 1 个备份

\$151.80
公共互联网出口数据传输\$11.52\$11.52\$11.52
跨区域数据传输\$0.31\$0.31\$0.31
总计\$499.38\$986.92\$1,474.47
- -### 企业:起始价格多样 {#enterprise-starting-prices-vary} - -最佳适用:大型、关键任务的部署,具有严格的安全和合规需求 - -**企业服务** -- 活跃工作负载 ~100% 时间 -- 1 TB 的公共互联网出口数据传输 -- 500 GB 的跨区域数据传输 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
示例 1示例 2示例 3
计算2 个副本 x 32 GiB RAM, 8 vCPU

\$2,285.60
2 个副本 x 64 GiB RAM, 16 vCPU

\$4,571.19
2 x 120 GiB RAM, 30 vCPU

\$8,570.99
存储5 TB + 1 个备份

\$253.00
10 TB + 1 个备份

\$506.00
20 TB + 1 个备份

\$1,012.00
公共互联网出口数据传输\$115.20\$115.20\$115.20
跨区域数据传输\$15.60\$15.60\$15.60
总计\$2,669.40\$5,207.99\$9,713.79
- -## 常见问题 {#faqs} - -### 计算是如何计量的? {#how-is-compute-metered} - -ClickHouse Cloud 按分钟计量计算,每 8G RAM 递增。 -计算成本将根据服务层、区域和云服务提供商的不同而有所变化。 - -### 磁盘上的存储是如何计算的? {#how-is-storage-on-disk-calculated} - -ClickHouse Cloud 使用云对象存储,且按存储在 ClickHouse 表中的数据压缩大小进行计量。 -存储成本在各个服务层之间是相同的,不同区域和云服务提供商之间可能有所变化。 - -### 备份计入总存储吗? {#do-backups-count-toward-total-storage} - -存储和备份计入存储成本,并分别计费。 -所有服务默认有一个备份,保留一天。 -需要额外备份的用户可以通过在 Cloud Console 的设置选项卡下配置额外的 [备份](backups/overview.md) 来实现。 - -### 如何估算压缩? {#how-do-i-estimate-compression} - -压缩可能因数据集而异。 -它的变化程度取决于数据本身的可压缩性(高低基数字段的数量), -以及用户如何设置模式(例如使用可选编解码器或不使用编解码器)。 -对于常见类型的分析数据,压缩比率可能在 10 倍左右,但也可以显著低于或高于这个比例。 -请参阅 [优化文档](/optimize/asynchronous-inserts) 以获取建议,并查看此 [Uber 博客](https://www.uber.com/blog/logging/) 的详细日志用例示例。 -确切知道唯一的方法是将您的数据集导入 ClickHouse,并比较数据集的大小与存储在 ClickHouse 中的大小。 - -您可以使用以下查询: - -```sql title="Estimating compression" -SELECT formatReadableSize(total_bytes) -FROM system.tables -WHERE name = -``` - -### 如果我有自管理部署,ClickHouse 提供哪些工具来估算在云中运行服务的成本? {#what-tools-does-clickhouse-offer-to-estimate-the-cost-of-running-a-service-in-the-cloud-if-i-have-a-self-managed-deployment} - -ClickHouse 查询日志捕获 [关键指标](/operations/system-tables/query_log),可用于估算在 ClickHouse Cloud 中运行工作负载的成本。 -有关从自管理迁移到 ClickHouse Cloud 的详细信息,请参阅 [迁移文档](/cloud/migration/clickhouse-to-cloud),并联系 [ClickHouse Cloud 支持](https://console.clickhouse.cloud/support) 以获取进一步的问题。 - -### ClickHouse Cloud 提供哪些计费选项? {#what-billing-options-are-available-for-clickhouse-cloud} - -ClickHouse Cloud 支持以下计费选项: - -- 自助月度计费(以美元计,通过信用卡支付)。 -- 直接销售的年度/多年计费(通过预付的 "ClickHouse 额度",以美元计,还有其他支付选项)。 -- 通过 AWS、GCP 和 Azure 市场(可以按使用付费(PAYG)或通过市场与 ClickHouse Cloud 签订合同)。 - -### 计费周期是多久? {#how-long-is-the-billing-cycle} - -计费按照每月计费周期进行,开始日期被跟踪为 ClickHouse Cloud 组织创建的日期。 - -### ClickHouse Cloud 提供哪些控制以管理 Scale 和 Enterprise 服务的成本? {#what-controls-does-clickhouse-cloud-offer-to-manage-costs-for-scale-and-enterprise-services} - -- 试用和年度承诺客户在消费达到某些阈值(`50%`、`75%` 和 `90%`)时会自动收到电子邮件通知。这使得用户能够主动管理其使用情况。 -- ClickHouse Cloud 允许用户通过 [高级 scaling 控制](/manage/scaling) 来设定计算的最大自动扩展限制,这对分析工作负载是一个重要的成本因素。 -- [高级 scaling 控制](/manage/scaling) 允许您设置内存限制,以及在不活动期间控制暂停/闲置行为的选项。 - -### ClickHouse Cloud 提供哪些控制以管理 Basic 服务的成本? {#what-controls-does-clickhouse-cloud-offer-to-manage-costs-for-basic-services} - -- [高级 scaling 控制](/manage/scaling) 允许您控制在不活动期间的暂停/闲置行为。对于 Basic 服务,不支持调整内存分配。 -- 请注意,默认设置在一段不活动时间后会暂停服务。 - -### 如果我有多个服务,我是按服务获取发票还是获取合并发票? {#if-i-have-multiple-services-do-i-get-an-invoice-per-service-or-a-consolidated-invoice} - -在给定的计费周期内,为所有服务生成合并发票。 - -### 如果我在试用期和信用额度过期之前添加信用卡并升级,会收取费用吗? {#if-i-add-my-credit-card-and-upgrade-before-my-trial-period-and-credits-expire-will-i-be-charged} - -当用户在 30 天的试用期结束之前将试用转换为付费,但仍有剩余额度时, -我们在初始 30 天的试用期中继续使用试用额度,然后收取信用卡费用。 - -### 如何跟踪我的支出? {#how-can-i-keep-track-of-my-spending} - -ClickHouse Cloud 控制台提供使用情况显示,详细说明每项服务的使用情况。这个细分按使用维度进行组织,帮助您了解与每个计量单位相关的成本。 - -### 如何访问我在 ClickHouse Cloud 服务的市场订阅发票? {#how-do-i-access-my-invoice-for-my-marketplace-subscription-to-the-clickhouse-cloud-service} - -所有市场订阅均由市场进行计费和开具发票。您可以直接通过相应的云提供商市场查看发票。 - -### 使用声明上的日期与我的市场发票不匹配的原因是什么? {#why-do-the-dates-on-the-usage-statements-not-match-my-marketplace-invoice} - -AWS 市场的计费遵循日历月周期。 -例如,对于 2024 年 12 月 1 日到 2025 年 1 月 1 日之间的使用,将在 2025 年 1 月 3 日至 1 月 5 日之间生成发票。 - -ClickHouse Cloud 的使用声明遵循不同的计费周期,其中使用情况从注册之日起开始按 30 天计量和报告。 - -如果这些日期不同,使用和发票日期将不相同。由于使用声明按天跟踪给定服务的使用情况,用户可以依赖声明查看成本分解。 - -### 预付费信用的使用是否有限制? {#are-there-any-restrictions-around-the-usage-of-prepaid-credits} - -ClickHouse Cloud 预付费信用(无论是直接通过 ClickHouse 还是通过云提供商的市场) -只能在合同条款中使用。 -这意味着它们可以在接受日期或未来日期使用,而不能用于任何先前的周期。 -任何未被预付费信用覆盖的超额费用必须通过信用卡支付或通过市场的每月计费来支付。 - -### 通过云提供商市场支付与直接向 ClickHouse 支付,ClickHouse Cloud 定价是否存在差异? {#is-there-a-difference-in-clickhouse-cloud-pricing-whether-paying-through-the-cloud-provider-marketplace-or-directly-to-clickhouse} - -市场计费与直接与 ClickHouse 注册之间的定价没有差异。 -在任何情况下,您对 ClickHouse Cloud 的使用都以 ClickHouse Cloud 信用 (CHCs) 为单位进行跟踪, -这种计量方式相同并据此计费。 - -### 计算-计算分离的计费方式是什么? {#how-is-compute-compute-separation-billed} - -在创建新服务时,您可以选择此新服务是否应与现有服务共享相同的数据。 -如果是,那么这两个服务现在形成一个 [仓库](../reference/warehouses.md)。 -一个仓库的数据存储在其中,多个计算服务访问这些数据。 - -由于数据只存储一次,因此您只需支付一份数据的费用,尽管多个服务正在访问它。 -您按正常方式支付计算费用——对于计算-计算分离/仓库没有额外费用。 -通过在此部署中利用共享存储,用户在存储和备份上都受益于成本节省。 - -在某些情况下,计算-计算分离可以为您节省大量的 ClickHouse 信用。 -以下设置是一个很好的示例: - -1. 您有 ETL 作业全天候运行并向服务中提取数据。这些 ETL 作业不需要大量内存,因此可以在小实例上运行,例如 32 GiB 的 RAM。 - -2. 同一团队中的数据科学家有偶发报告需求,表示他们需要运行一个需要大量内存的查询——236 GiB,但不需要高可用性,如果第一次运行失败可以等待并重新运行查询。 - -在这个示例中,作为数据库的管理员,您可以执行以下操作: - -1. 创建一个具有两个副本的较小服务,各 16 GiB——这将满足 ETL 作业并提供高可用性。 - -2. 对于数据科学家,您可以在同一仓库中创建第二个服务,仅使用一个副本和 236 GiB。您可以为此服务启用闲置功能,因此在数据科学家不使用时无需为其服务付费。 - -此示例在 **扩展层** 的每月成本估算: -- 父服务全天候活跃:2 个副本 x 16 GiB 4 vCPU 每个副本 -- 子服务:1 个副本 x 236 GiB 59 vCPU 每个副本 -- 3 TB 的压缩数据 + 1 个备份 -- 100 GB 的公共互联网出口数据传输 -- 50 GB 的跨区域数据传输 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
子服务
每天活跃 1 小时
子服务
每天活跃 2 小时
子服务
每天活跃 4 小时
计算\$1,142.43\$1,410.97\$1,948.05
存储\$151.80\$151.80\$151.80
公共互联网出口数据传输\$11.52\$11.52\$11.52
跨区域数据传输\$1.56\$1.56\$1.56
总计\$1,307.31\$1,575.85\$2,112.93
- -如果没有仓库,您必须支付数据工程师为其查询所需的内存量。 -然而,将两个服务结合在一个仓库内并将其中一个闲置,帮助您节省金钱。 - -## ClickPipes 定价 {#clickpipes-pricing} - -### ClickPipes 用于 Postgres CDC {#clickpipes-for-postgres-cdc} - -本节概述了我们在 ClickPipes 中针对 Postgres 变更数据捕获 (CDC) 的定价模型。在设计此模型时,我们的目标是保持定价高度竞争,同时忠于我们的核心愿景: - -> 让客户无缝且负担得起地将数据从 Postgres 移动到 ClickHouse 进行实时分析。 - -该连接器比外部 ETL 工具以及其他数据库平台中类似功能的成本效益高出 **5 倍**。$^*$ - -:::note -针对使用 Postgres CDC ClickPipes 的所有客户(包括现有和新客户), -计费将于 **2025年9月1日** 开始计量。到那时为止,使用是免费的。 -客户在 5 月 29 日(GA公告)开始享有 3 个月的窗口期,如果需要,可以审核和优化他们的费用,尽管我们预期大多数客户不需要进行任何更改。 -::: - -$^*$ _例如,外部 ETL 工具 Airbyte 提供类似的 CDC 能力,收费为 $10/GB(不包括信用)——超过 ClickPipes 中 Postgres CDC 移动 1TB 数据的费用的 20 倍以上。_ - -#### 定价维度 {#pricing-dimensions} - -定价主要包括两个维度: - -1. **摄取的数据**:来自 Postgres 的原始未压缩字节,摄取到 ClickHouse 中。 -2. **计算**:每项服务预配置的计算单元,管理多个 Postgres CDC ClickPipes,与 ClickHouse Cloud 服务使用的计算单元分开。该额外计算专门用于 Postgres CDC ClickPipes。计算按服务级别计费,而不是按单个管道计费。每个计算单元包括 2 vCPU 和 8 GB 的 RAM。 - -#### 摄取数据 {#ingested-data} - -Postgres CDC 连接器分为两个主要阶段: - -- **初始加载/重新同步**:这会捕获 Postgres 表的完整快照,并在管道首次创建或重新同步时发生。 -- **持续复制 (CDC)**:数据从 Postgres 到 ClickHouse 的更改的持续复制——如插入、更新、删除和架构更改。 - -在大多数用例中,持续复制占 ClickPipe 生命周期的 90% 以上。由于初始加载涉及一次性传输大量数据,我们为此阶段提供较低的费率。 - -| 阶段 | 成本 | -|---------------------------------------|--------------| -| **初始加载/重新同步** | $0.10 每 GB | -| **持续复制 (CDC)** | $0.20 每 GB | - -#### 计算 {#compute} - -该维度涵盖每项服务专门用于 Postgres ClickPipes 的计算单元。计算在服务内的所有 Postgres 管道中共享。**在创建第一个 Postgres 管道时会分配计算单元,当没有 Postgres CDC 管道时将撤销分配**。分配的计算量取决于您组织的服务层次: - -| 层级 | 成本 | -|--------------------------------|-------------------------------------------| -| **基本层** | 每项服务 0.5 计算单元 — 每小时 $0.10 | -| **扩展或企业层** | 每项服务 1 计算单元 — 每小时 $0.20 | - -#### 示例 {#example} - -假设您的服务处于扩展层,并具有以下设置: - -- 2 个 Postgres ClickPipes 正在运行持续复制 -- 每个管道每月摄取 500 GB 的数据更改 (CDC) -- 当第一个管道开始工作时,服务将为 Postgres CDC 提供 **1 个计算单元**。 - -##### 每月成本细分 {#cost-breakdown} - -**摄取数据 (CDC)**: - -$$ 2 \text{ 个管道} \times 500 \text{ GB} = 1,000 \text{ GB 每月} $$ - -$$ 1,000 \text{ GB} \times \$0.20/\text{GB} = \$200 $$ - -**计算**: - -$$1 \text{ 计算单元} \times \$0.20/\text{hr} \times 730 \text{ 小时(大约一个月)} = \$146$$ - -:::note -计算在两个管道之间共享 -::: - -**每月总成本**: - -$$\$200 \text{ (摄取)} + \$146 \text{ (计算)} = \$346$$ - -### ClickPipes 用于流和对象存储 {#clickpipes-for-streaming-object-storage} - -本节概述了 ClickPipes 用于流和对象存储的定价模型。 - -#### ClickPipes 定价结构是什么样的? {#what-does-the-clickpipes-pricing-structure-look-like} - -它由两个维度组成: - -- **计算**:每个单位的每小时价格 -计算表示运行 ClickPipes 副本 pod 的成本,无论它们是否实际摄取数据。 -这适用于所有 ClickPipes 类型。 -- **摄取数据**:按 GB 定价 -摄取数据的费率适用于所有流媒体 ClickPipes(Kafka、Confluent、Amazon MSK、Amazon Kinesis、Redpanda、WarpStream、Azure 事件中心)通过副本 pod 传输的数据。摄取的数据大小 (GB) 费用根据来自 source 的字节(未压缩或压缩)进行收费。 - -#### ClickPipes 副本是什么? {#what-are-clickpipes-replicas} - -ClickPipes 通过专用基础设施从远程数据源摄取数据,该基础设施独立于 ClickHouse Cloud 服务运行和扩展。 -因此,它使用专用的计算副本。 - -#### 副本的默认数量及其大小是多少? {#what-is-the-default-number-of-replicas-and-their-size} - -每个 ClickPipe 默认提供 1 个副本,配备 2 GiB 的 RAM 和 0.5 vCPU。 -这相当于 **0.25** ClickHouse 计算单元(1 单元 = 8 GiB RAM,2 vCPUs)。 - -#### ClickPipes 的公共价格是什么? {#what-are-the-clickpipes-public-prices} - -- 计算:每单位每小时 \$0.20(每个副本每小时 \$0.05) -- 摄取数据:每 GB \$0.04 - -#### 在示例中具体表现如何? {#how-does-it-look-in-an-illustrative-example} - -以下示例假设单个副本,除非明确提及。 - - - - - - - - - - - - - - - - - - - - - - -
100 GB 24小时1 TB 24小时10 TB 24小时
流式 ClickPipe(0.25 x 0.20 x 24) + (0.04 x 100) = \$5.20(0.25 x 0.20 x 24) + (0.04 x 1000) = \$41.20使用 4 个副本:

(0.25 x 0.20 x 24 x 4) + (0.04 x 10000) = \$404.80
对象存储 ClickPipe $^*$(0.25 x 0.20 x 24) = \$1.20(0.25 x 0.20 x 24) = \$1.20(0.25 x 0.20 x 24) = \$1.20
- -$^1$ _仅 ClickPipes 计算用于编排, -有效的数据传输由基础 ClickHouse 服务承担_ - -## ClickPipes 定价常见问题 {#clickpipes-pricing-faq} - -以下是有关 CDC ClickPipes 和流式及基于对象存储 ClickPipes 的常见问题。 - -### Postgres CDC ClickPipes 的常见问题 {#faq-postgres-cdc-clickpipe} - -
- -摄取的数据是根据压缩后还是未压缩大小来计量的? - -摄取的数据是按 _未压缩数据_ 计量的,即来自 Postgres 的原始数据—— -无论是在初始加载时还是在 CDC(通过复制槽)。Postgres 默认在传输过程中不会压缩数据, -而 ClickPipe 处理的是原始未压缩字节。 - -
- -
- -Postgres CDC 定价何时开始出现在我的账单上? - -Postgres CDC ClickPipes 的定价从 **2025年9月1日** 开始出现在所有客户的每月账单上—— -包括现有和新客户。在此之前,使用是免费的。客户从 **5 月 29 日**(GA公告日期) -开始享有 **3 个月** 的窗口期,以审查和优化他们的使用情况,尽管我们预期大多数不需要进行任何更改。 - -
- -
- -如果我暂停管道,会收费吗? - -在管道暂停期间不会产生数据摄取费用,因为没有数据被移动。 -但是,仍然会产生计算费用——根据您组织的层级而定,为 0.5 或 1 个计算单元。 -这是一项固定的服务级费用,适用于该服务内的所有管道。 - -
- -
- -我如何估算我的定价? - -ClickPipes 的概述页面提供初始加载/重新同步和 CDC 数据量的指标。 -您可以利用这些指标以及 ClickPipes 定价来估算您的 Postgres CDC 成本。 - -
- -
- -我可以为我的服务中的 Postgres CDC 扩大分配的计算吗? - -默认情况下,计算扩展不可由用户配置。 -提供的资源经过优化,以最佳方式处理大多数客户的工作负载。如果您的用例需要更多或更少的计算,请提交支持票以便我们可以评估您的请求。 - -
- -
- -定价粒度是什么? - -- **计算**:按小时计费。部分小时按下一个小时四舍五入。 -- **摄取数据**:按未压缩数据的千兆字节 (GB) 计量和计费。 - -
- -
- -我可以使用我的 ClickHouse Cloud 额度用于通过 ClickPipes 的 Postgres CDC 吗? - -可以。 ClickPipes 定价是统一的 ClickHouse Cloud 定价的一部分。您拥有的任何平台信用将自动应用于 ClickPipes 使用。 - -
- -
- -我在现有的每月 ClickHouse Cloud 支出中应该预计 Postgres CDC ClickPipes 产生多少额外费用? - -费用根据您的用例、数据量和组织层级而异。 -也就是说,大多数现有客户在试用期后,将看到相较于其现有每月 ClickHouse Cloud 支出 **0-15%** 的增加。 -实际费用可能随工作负载的不同而有所变化——一些工作负载涉及大量数据量但处理较少, -而其他工作负载则需要更多处理但数据量较少。 - -
- -### 流式和对象存储 ClickPipes 的常见问题 {#faq-streaming-and-object-storage} - - diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing.md.hash deleted file mode 100644 index bfb2f210ae8..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing.md.hash +++ /dev/null @@ -1 +0,0 @@ -d2c01b33fddfe95f diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/index.md deleted file mode 100644 index c0b500ce507..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/index.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -'slug': '/cloud/manage/billing' -'title': '账单' -'description': '账单的内容页面。' -'keywords': -- 'billing' -- 'payment thresholds' -- 'trouble shooting' -- 'marketplace' ---- - -该文档的这一部分涵盖了与计费相关的主题,并包含以下页面: - -| 页面 | 描述 | -|---------------------------------------|----------------------------------------------------------------------| -| [概述](/cloud/marketplace/marketplace-billing) | 市场计费的概述和常见问题页面。 | -| [支付阈值](/cloud/billing/payment-thresholds) | 了解支付阈值的工作原理以及如何调整它们。 | -| [解决计费问题](/manage/troubleshooting-billing-issues) | 疑难解答常见的计费问题。 | -| [市场](/cloud/manage/) | 进一步与市场相关主题的登陆页面。 | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/index.md.hash deleted file mode 100644 index f5f25464bb5..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/index.md.hash +++ /dev/null @@ -1 +0,0 @@ -fbab6a1653f93ac7 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/marketplace/aws-marketplace-committed.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/marketplace/aws-marketplace-committed.md deleted file mode 100644 index 0125da1b09d..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/marketplace/aws-marketplace-committed.md +++ /dev/null @@ -1,98 +0,0 @@ ---- -'slug': '/cloud/billing/marketplace/aws-marketplace-committed-contract' -'title': 'AWS Marketplace 承诺合同' -'description': '通过 AWS Marketplace 订阅 ClickHouse Cloud(承诺合同)' -'keywords': -- 'aws' -- 'amazon' -- 'marketplace' -- 'billing' -- 'committed' -- 'committed contract' ---- - -import Image from '@theme/IdealImage'; -import aws_marketplace_committed_1 from '@site/static/images/cloud/manage/billing/marketplace/aws-marketplace-committed-1.png'; -import aws_marketplace_payg_6 from '@site/static/images/cloud/manage/billing/marketplace/aws-marketplace-payg-6.png'; -import aws_marketplace_payg_7 from '@site/static/images/cloud/manage/billing/marketplace/aws-marketplace-payg-7.png'; -import aws_marketplace_payg_8 from '@site/static/images/cloud/manage/billing/marketplace/aws-marketplace-payg-8.png'; -import aws_marketplace_payg_9 from '@site/static/images/cloud/manage/billing/marketplace/aws-marketplace-payg-9.png'; -import aws_marketplace_payg_10 from '@site/static/images/cloud/manage/billing/marketplace/aws-marketplace-payg-10.png'; -import aws_marketplace_payg_11 from '@site/static/images/cloud/manage/billing/marketplace/aws-marketplace-payg-11.png'; -import aws_marketplace_payg_12 from '@site/static/images/cloud/manage/billing/marketplace/aws-marketplace-payg-12.png'; - -开始使用 [AWS Marketplace](https://aws.amazon.com/marketplace) 上的 ClickHouse Cloud 中的承诺合同。承诺合同,也称为私人优惠,允许客户承诺在一段时间内在 ClickHouse Cloud 上支出一定金额。 - -## 先决条件 {#prerequisites} - -- 具有特定合同条款的 ClickHouse 私人优惠。 - -## 注册步骤 {#steps-to-sign-up} - -1. 您应该收到一封电子邮件,其中包含一个链接,以查看和接受您的私人优惠。 - -
- -AWS Marketplace private offer email - -
- -2. 点击电子邮件中的 **Review Offer** 链接。这应该会将您带到包含私人优惠详情的 AWS Marketplace 页面。在接受私人优惠时,在合同选项下拉列表中选择 1 作为单位数量。 - -3. 完成 AWS 门户上的订阅步骤,然后点击 **Set up your account**。此时重定向到 ClickHouse Cloud 是非常重要的,并且需要注册新帐户或使用现有帐户登录。如果未完成此步骤,我们将无法将您的 AWS Marketplace 订阅与 ClickHouse Cloud 关联。 - -4. 一旦您重定向到 ClickHouse Cloud,您可以使用现有帐户登录或注册新帐户。此步骤非常重要,以便我们能够将您的 ClickHouse Cloud 组织绑定到 AWS Marketplace 账单。 - -
- -ClickHouse Cloud sign in page - -
- -如果您是新用户,请在页面底部点击 **Register**。系统会提示您创建新用户并验证电子邮件。在验证您的电子邮件后,您可以离开 ClickHouse Cloud 登录页面,并在 [https://console.clickhouse.cloud](https://console.clickhouse.cloud) 使用新用户名登录。 - -
- -ClickHouse Cloud sign up page - -
- -请注意,如果您是新用户,您还需要提供一些关于您业务的基本信息。请参见下面的截图。 - -
- -ClickHouse Cloud sign up info form - -
- -
- -ClickHouse Cloud sign up info form 2 - -
- -如果您是现有的 ClickHouse Cloud 用户,只需使用您的凭据登录即可。 - -5. 成功登录后,将创建一个新的 ClickHouse Cloud 组织。该组织将与您的 AWS 账单帐户连接,所有使用情况将通过您的 AWS 账户进行计费。 - -6. 登录后,您可以确认您的计费确实与 AWS Marketplace 绑定,并开始设置您的 ClickHouse Cloud 资源。 - -
- -ClickHouse Cloud view AWS Marketplace billing - -
- -ClickHouse Cloud new services page - -
- -6. 您应该会收到一封确认注册的电子邮件: - -
- -AWS Marketplace confirmation email - -
- -如果您遇到任何问题,请随时联系 [我们的支持团队](https://clickhouse.com/support/program)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/marketplace/aws-marketplace-committed.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/marketplace/aws-marketplace-committed.md.hash deleted file mode 100644 index 03465181c10..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/marketplace/aws-marketplace-committed.md.hash +++ /dev/null @@ -1 +0,0 @@ -75faa9566e51f2b8 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/marketplace/aws-marketplace-payg.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/marketplace/aws-marketplace-payg.md.hash deleted file mode 100644 index 7d890aba13d..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/marketplace/aws-marketplace-payg.md.hash +++ /dev/null @@ -1 +0,0 @@ -772895e4efa284cf diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/marketplace/azure-marketplace-committed.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/marketplace/azure-marketplace-committed.md.hash deleted file mode 100644 index 75de449c4cd..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/marketplace/azure-marketplace-committed.md.hash +++ /dev/null @@ -1 +0,0 @@ -1911c3fe90af480b diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/marketplace/azure-marketplace-payg.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/marketplace/azure-marketplace-payg.md.hash deleted file mode 100644 index 230cd13426f..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/marketplace/azure-marketplace-payg.md.hash +++ /dev/null @@ -1 +0,0 @@ -54eeaae68b329348 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/marketplace/gcp-marketplace-committed.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/marketplace/gcp-marketplace-committed.md.hash deleted file mode 100644 index c265642e980..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/marketplace/gcp-marketplace-committed.md.hash +++ /dev/null @@ -1 +0,0 @@ -cd061fff5e155c0a diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/marketplace/gcp-marketplace-payg.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/marketplace/gcp-marketplace-payg.md.hash deleted file mode 100644 index 86ac0d2d692..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/marketplace/gcp-marketplace-payg.md.hash +++ /dev/null @@ -1 +0,0 @@ -5a4b47d7cbaa8a2e diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/marketplace/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/marketplace/index.md deleted file mode 100644 index c1bf909bf1c..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/marketplace/index.md +++ /dev/null @@ -1,21 +0,0 @@ ---- -'slug': '/cloud/manage/marketplace/' -'title': '市场交易' -'description': '市场交易 目录页面' -'keywords': -- 'Marketplace Billing' -- 'AWS' -- 'GCP' ---- - -这部分详细介绍了与市场相关的计费主题。 - -| 页面 | 描述 | -|---------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| [市场计费](/cloud/marketplace/marketplace-billing) | 关于市场计费的常见问题解答。 | -| [AWS 市场 PAYG](/cloud/billing/marketplace/aws-marketplace-payg) | 通过 PAYG(按需付费)公共报价在 AWS 市场上开始使用 ClickHouse Cloud。 | -| [AWS 市场承诺合同](/cloud/billing/marketplace/aws-marketplace-committed-contract) | 通过承诺合同在 AWS 市场上开始使用 ClickHouse Cloud。承诺合同,也称为私有报价,允许客户承诺在一段时间内在 ClickHouse Cloud 上支出一定金额。 | -| [GCP 市场 PAYG](/cloud/billing/marketplace/gcp-marketplace-payg) | 通过 PAYG(按需付费)公共报价在 GCP 市场上开始使用 ClickHouse Cloud。 | -| [GCP 市场承诺合同](/cloud/billing/marketplace/gcp-marketplace-committed-contract) | 通过承诺合同在 GCP 市场上开始使用 ClickHouse Cloud。承诺合同,也称为私有报价,允许客户承诺在一段时间内在 ClickHouse Cloud 上支出一定金额。 | -| [Azure 市场 PAYG](/cloud/billing/marketplace/azure-marketplace-payg) | 通过 PAYG(按需付费)公共报价在 Azure 市场上开始使用 ClickHouse Cloud。 | -| [Azure 市场承诺合同](/cloud/billing/marketplace/azure-marketplace-committed-contract) | 通过承诺合同在 Azure 市场上开始使用 ClickHouse Cloud。承诺合同,也称为私有报价,允许客户承诺在一段时间内在 ClickHouse Cloud 上支出一定金额。 | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/marketplace/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/marketplace/index.md.hash deleted file mode 100644 index 8f65372a8b0..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/marketplace/index.md.hash +++ /dev/null @@ -1 +0,0 @@ -dd80e7eb1ab38733 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/marketplace/overview.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/marketplace/overview.md deleted file mode 100644 index d0eff0a6c23..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/marketplace/overview.md +++ /dev/null @@ -1,98 +0,0 @@ ---- -'slug': '/cloud/marketplace/marketplace-billing' -'title': '市场计费' -'description': '通过 AWS、GCP 和 Azure 市场订阅 ClickHouse Cloud。' -'keywords': -- 'aws' -- 'azure' -- 'gcp' -- 'google cloud' -- 'marketplace' -- 'billing' ---- - -import Image from '@theme/IdealImage'; -import marketplace_signup_and_org_linking from '@site/static/images/cloud/manage/billing/marketplace/marketplace_signup_and_org_linking.png' - -您可以通过 AWS、GCP 和 Azure 市场订阅 ClickHouse Cloud。这使您可以通过现有的云服务提供商账单支付 ClickHouse Cloud。 - -您可以选择按需支付(PAYG)或通过市场与 ClickHouse Cloud 签订合同。账单将由云服务提供商处理,您将收到一份有关所有云服务的单一发票。 - -- [AWS 市场 PAYG](/cloud/billing/marketplace/aws-marketplace-payg) -- [AWS 市场承诺合同](/cloud/billing/marketplace/aws-marketplace-committed-contract) -- [GCP 市场 PAYG](/cloud/billing/marketplace/gcp-marketplace-payg) -- [GCP 市场承诺合同](/cloud/billing/marketplace/gcp-marketplace-committed-contract) -- [Azure 市场 PAYG](/cloud/billing/marketplace/azure-marketplace-payg) -- [Azure 市场承诺合同](/cloud/billing/marketplace/azure-marketplace-committed-contract) - -## 常见问题 {#faqs} - -### 我如何验证我的组织是否已连接到市场账单?​ {#how-can-i-verify-that-my-organization-is-connected-to-marketplace-billing} - -在 ClickHouse Cloud 控制台中,导航到 **账单**。在 **付款详情** 部分,您应该能看到市场名称和链接。 - -### 我是现有的 ClickHouse Cloud 用户。当我通过 AWS / GCP / Azure 市场订阅 ClickHouse Cloud 时会发生什么?​ {#i-am-an-existing-clickhouse-cloud-user-what-happens-when-i-subscribe-to-clickhouse-cloud-via-aws--gcp--azure-marketplace} - -从云服务提供商市场注册 ClickHouse Cloud 是一个两步过程: -1. 您首先在云服务提供商的市场门户中“订阅” ClickHouse Cloud。完成订阅后,您点击“立即支付”或“在提供商处管理”(具体取决于市场)。这将重定向您到 ClickHouse Cloud。 -2. 在 ClickHouse Cloud 上,您可以注册一个新帐户或使用现有帐户登录。无论哪种方式,都会为您创建一个新的 ClickHouse Cloud 组织,它与您的市场账单相关联。 - -注意:您之前任何 ClickHouse Cloud 注册的现有服务和组织将保持不变,并且它们不会与市场账单连接。ClickHouse Cloud 允许您使用同一帐户管理多个组织,每个组织都有不同的账单。 - -您可以通过 点击 House Cloud 控制台左下角的菜单在组织之间切换。 - -### 我是现有的 ClickHouse Cloud 用户。如果我希望我的现有服务通过市场收费,我该怎么办?​ {#i-am-an-existing-clickhouse-cloud-user-what-should-i-do-if-i-want-my-existing-services-to-be-billed-via-marketplace} - -您需要通过云服务提供商市场订阅 ClickHouse Cloud。完成市场上的订阅后,重定向到 ClickHouse Cloud,您将有选择将现有的 ClickHouse Cloud 组织链接到市场账单的选项。从那时起,您的现有资源将通过市场收费。 - -Marketplace signup and org linking - -您可以从组织的账单页面确认账单确实已链接到市场。如果您遇到任何问题,请联系 [ClickHouse Cloud 支持](https://clickhouse.com/support/program)。 - -:::note -您之前任何 ClickHouse Cloud 注册的现有服务和组织将保持不变,并且不会与市场账单连接。 -::: - -### 我作为市场用户订阅了 ClickHouse Cloud。我如何取消订阅?​ {#i-subscribed-to-clickhouse-cloud-as-a-marketplace-user-how-can-i-unsubscribe} - -请注意,您可以简单地停止使用 ClickHouse Cloud 并删除所有现有的 ClickHouse Cloud 服务。尽管订阅仍然有效,但您将不再支付任何费用,因为 ClickHouse Cloud 没有任何经常性费用。 - -如果您想取消订阅,请导航到云服务提供商控制台并取消订阅续订。一旦订阅结束,所有现有服务将停止,您将被提示添加信用卡。如果没有添加信用卡,在两周后,所有现有服务将被删除。 - -### 我作为市场用户订阅了 ClickHouse Cloud,然后取消了订阅。现在我想再次订阅,流程是什么?​ {#i-subscribed-to-clickhouse-cloud-as-a-marketplace-user-and-then-unsubscribed-now-i-want-to-subscribe-back-what-is-the-process} - -在这种情况下,请像往常一样订阅 ClickHouse Cloud(参见通过市场订阅 ClickHouse Cloud 的部分)。 - -- 对于 AWS 市场,将创建一个新的 ClickHouse Cloud 组织并与市场连接。 -- 对于 GCP 市场,您的旧组织将重新激活。 - -如果您在重新激活市场组织时遇到任何问题,请联系 [ClickHouse Cloud 支持](https://clickhouse.com/support/program)。 - -### 我如何访问我的 ClickHouse Cloud 服务的市场订阅发票?​ {#how-do-i-access-my-invoice-for-my-marketplace-subscription-to-the-clickhouse-cloud-service} - -- [AWS 账单控制台](https://us-east-1.console.aws.amazon.com/billing/home) -- [GCP 市场订单](https://console.cloud.google.com/marketplace/orders)(选择您用于订阅的账单帐户) - -### 为什么使用情况报表上的日期与我的市场发票不匹配?​ {#why-do-the-dates-on-the-usage-statements-not-match-my-marketplace-invoice} - -市场账单遵循日历月周期。例如,对于 12 月 1 日至 1 月 1 日之间的使用情况,将在 1 月 3 日至 1 月 5 日之间生成发票。 - -ClickHouse Cloud 使用情况报表遵循不同的账单周期,在注册日起的 30 天内对使用情况进行计量和报告。 - -如果这些日期不相同,则使用情况和发票日期会有所不同。由于使用情况报表按天跟踪某项服务的使用情况,用户可以依赖这些报表查看费用的详细细分。 - -### 我可以在哪里找到一般的账单信息​? {#where-can-i-find-general-billing-information} - -请参阅 [账单概述页面](/cloud/manage/billing)。 - -### 通过云服务提供商市场支付和直接向 ClickHouse 支付的 ClickHouse Cloud 价格有什么区别吗? {#is-there-a-difference-in-clickhouse-cloud-pricing-whether-paying-through-the-cloud-provider-marketplace-or-directly-to-clickhouse} - -市场账单和直接与 ClickHouse 注册之间的价格没有区别。在这两种情况下,您对 ClickHouse Cloud 的使用情况都是以 ClickHouse Cloud 积分(CHC)进行跟踪的,这些积分的计量方式是相同的,并相应地计费。 - -### 我可以设置多个 ClickHouse 组织,以便将账单发送到单个云市场账单帐户或子帐户(AWS、GCP 或 Azure)吗? {#multiple-organizations-to-bill-to-single-cloud-marketplace-account} - -单个 ClickHouse 组织只能配置为将账单发送到单个云市场账单帐户或子帐户。 - -### 如果我的 ClickHouse 组织是通过云市场承诺支出协议收费,当我的信用耗尽时,是否会自动转换为 PAYG 账单? {#automatically-move-to-PAYG-when-running-out-of-credit} - -如果您的市场承诺支出合同处于活动状态并且您的信用耗尽,我们将自动将您的组织转换为 PAYG 账单。然而,当您现有的合同到期时,您将需要将新的市场合同链接到您的组织,或者将您的组织移至通过信用卡直接收费。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/marketplace/overview.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/marketplace/overview.md.hash deleted file mode 100644 index d796d9d41a3..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/marketplace/overview.md.hash +++ /dev/null @@ -1 +0,0 @@ -00f0892aa3b90de5 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/payment-thresholds.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/payment-thresholds.md deleted file mode 100644 index 73d64f3e4f4..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/payment-thresholds.md +++ /dev/null @@ -1,24 +0,0 @@ ---- -'sidebar_label': '支付阈值' -'slug': '/cloud/billing/payment-thresholds' -'title': '支付阈值' -'description': '支付阈值和 ClickHouse Cloud 的自动发票。' -'keywords': -- 'billing' -- 'payment thresholds' -- 'automatic invoicing' -- 'invoice' ---- - - -# 支付阈值 - -当您在 ClickHouse Cloud 的账单周期内应付金额达到 10,000 美元或等值金额时,您的支付方式将自动被扣费。未成功的扣费将导致您的服务在宽限期后被暂停或终止。 - -:::note -此支付阈值不适用于与 ClickHouse 签订了承诺支出合同或其他协商合同协议的客户。 -::: - -如果您的组织达到支付阈值的 90%,并且预计将在账单周期中期超出支付阈值,关联的账单电子邮件将收到邮件通知。当您超过支付阈值时,您也将收到邮件通知和发票。 - -这些支付阈值可以根据客户的请求或 ClickHouse 财务团队的要求调整至低于 10,000 美元。如果您有任何问题,请联系 support@clickhouse.com 获取更多详细信息。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/payment-thresholds.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/payment-thresholds.md.hash deleted file mode 100644 index f579328e279..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/payment-thresholds.md.hash +++ /dev/null @@ -1 +0,0 @@ -f38b52780b999ee1 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/cloud-tiers.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/cloud-tiers.md deleted file mode 100644 index 37891628d77..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/cloud-tiers.md +++ /dev/null @@ -1,208 +0,0 @@ ---- -'sidebar_label': 'ClickHouse Cloud 层级' -'slug': '/cloud/manage/cloud-tiers' -'title': 'ClickHouse Cloud 层级' -'description': '在 ClickHouse Cloud 可用的云层级' ---- - - -# ClickHouse Cloud Tiers - -ClickHouse Cloud 提供多个层级。 -层级可以在任何组织级别分配,因此组织内部的服务属于同一个层级。 -此页面讨论哪些层级适合您的特定用例。 - -**云层级摘要:** - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
[基础](#basic)[规模(推荐)](#scale)[企业](#enterprise)
**服务特性**
服务数量✓ 无限✓ 无限✓ 无限
存储✓ 每个服务最多 1 TB✓ 无限✓ 无限
内存✓ 总内存 8-12 GiB✓ 可配置✓ 可配置
可用性✓ 1 个区域✓ 2+ 个区域✓ 2+ 个区域
备份✓ 每 24 小时 1 次备份,保留 1 天✓ 可配置✓ 可配置
垂直扩展✓ 自动扩展✓ 标准配置下自动扩展,自定义配置下手动扩展
水平扩展✓ 手动扩展✓ 手动扩展
ClickPipes
提前升级
计算与计算分离
导出备份到您自己的云账户
定期升级
自定义硬件配置
**安全性**
SAML/SSO
MFA
SOC 2 Type II
ISO 27001
私有网络
S3 基于角色的访问
透明数据加密(CMEK for TDE)
HIPAA
- -## 基础 {#basic} - -- 成本效益高的选项,支持单副本部署。 -- 适合数据量较小且没有严格可靠性保证的部门用例。 - -:::note -基础层级的服务旨在固定大小,不允许自动和手动扩展。 -用户可以升级到规模或企业层级以扩展其服务。 -::: - -## 规模 {#scale} - -旨在满足需要增强服务级别协议(2+ 副本部署)、可扩展性和高级安全性的工作负载。 - -- 支持以下功能: - - [私有网络支持](../security/private-link-overview.md)。 - - [计算与计算分离](../reference/warehouses#what-is-compute-compute-separation)。 - - [灵活扩展](../manage/scaling.md)选项(向上/向下、向内/向外扩展)。 - -## 企业 {#enterprise} - -满足具有严格安全和合规需求的大规模关键任务部署。 - -- 包含规模的一切,**此外** -- 灵活扩展:标准配置(`1:4 vCPU:内存比例`),以及 `高内存(1:8 比例)` 和 `高 CPU(1:2 比例)` 自定义配置。 -- 提供最高级别的性能和可靠性保证。 -- 支持企业级安全: - - 单点登录(SSO) - - 增强加密:针对 AWS 和 GCP 服务。服务默认由我们的密钥加密,并可以旋转到他们的密钥以启用客户管理加密密钥(CMEK)。 -- 允许定期升级:用户可以选择升级的周几/时间窗口,包括数据库和云版本。 -- 提供 [HIPAA](../security/compliance-overview.md/#hipaa-since-2024) 合规性。 -- 将备份导出到用户的账户。 - -:::note -所有三个层级的单副本服务旨在具有固定大小(`8 GiB`,`12 GiB`)。 -::: - -## 升级到不同层级 {#upgrading-to-a-different-tier} - -您可以随时从基础升级到规模或从规模升级到企业。 - -:::note -不可能降级层级。 -::: - ---- - -如果您对服务类型有任何问题,请查看 [定价页面](https://clickhouse.com/pricing) 或联系 support@clickhouse.com。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/cloud-tiers.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/cloud-tiers.md.hash deleted file mode 100644 index 2ab9e9daa0e..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/cloud-tiers.md.hash +++ /dev/null @@ -1 +0,0 @@ -3fe46184738b67bf diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/dashboards.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/dashboards.md deleted file mode 100644 index 5efbed5f624..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/dashboards.md +++ /dev/null @@ -1,106 +0,0 @@ ---- -'sidebar_label': '仪表板' -'slug': '/cloud/manage/dashboards' -'title': '仪表板' -'description': 'SQL 控制台的仪表板功能允许您从保存的查询中收集和共享可视化。' ---- - -import BetaBadge from '@theme/badges/BetaBadge'; -import Image from '@theme/IdealImage'; -import dashboards_2 from '@site/static/images/cloud/dashboards/2_dashboards.png'; -import dashboards_3 from '@site/static/images/cloud/dashboards/3_dashboards.png'; -import dashboards_4 from '@site/static/images/cloud/dashboards/4_dashboards.png'; -import dashboards_5 from '@site/static/images/cloud/dashboards/5_dashboards.png'; -import dashboards_6 from '@site/static/images/cloud/dashboards/6_dashboards.png'; -import dashboards_7 from '@site/static/images/cloud/dashboards/7_dashboards.png'; -import dashboards_8 from '@site/static/images/cloud/dashboards/8_dashboards.png'; -import dashboards_9 from '@site/static/images/cloud/dashboards/9_dashboards.png'; -import dashboards_10 from '@site/static/images/cloud/dashboards/10_dashboards.png'; -import dashboards_11 from '@site/static/images/cloud/dashboards/11_dashboards.png'; - - -# Dashboards - - - -SQL 控制台的仪表板功能允许您收集和共享来自保存查询的可视化效果。通过保存和可视化查询、将查询可视化添加到仪表板,并使用查询参数使仪表板具有交互性来开始使用。 - -## Core Concepts {#core-concepts} - -### Query Sharing {#query-sharing} - -为了与同事共享您的仪表板,请务必共享底层的保存查询。为了查看可视化,用户至少必须具有对底层保存查询的只读访问权限。 - -### Interactivity {#interactivity} - -使用 [query parameters](/sql-reference/syntax#defining-and-using-query-parameters) 使您的仪表板具有交互性。例如,您可以在 `WHERE` 子句中添加一个查询参数作为过滤器。 - -您可以通过在可视化设置中选择“过滤器”类型,利用 **Global** 过滤器侧边栏切换查询参数输入。您还可以通过链接到仪表板上的另一个对象(比如一个表)来切换查询参数输入。请参见下面快速入门指南的 “[configure a filter](/cloud/manage/dashboards#configure-a-filter)” 部分。 - -## Quick Start {#quick-start} - -让我们创建一个仪表板来监控我们的 ClickHouse 服务,使用 [query_log](/operations/system-tables/query_log) 系统表。 - -## Quick Start {#quick-start-1} - -### Create a saved query {#create-a-saved-query} - -如果您已经有保存的查询可视化,可以跳过此步骤。 - -打开一个新的查询标签页。我们来写一个查询,以计算在服务中按天的查询量,使用 ClickHouse 系统表: - -Create a saved query - -我们可以以表格格式查看查询结果,或开始从图表视图构建可视化。在下一步中,我们将查询保存为 `queries over time`: - -Save query - -有关保存查询的更多文档,请参见 [Saving a Query section](/cloud/get-started/sql-console#saving-a-query)。 - -我们可以创建并保存另一个查询 `query count by query kind`,以计算按查询类型的查询数量。以下是 SQL 控制台中数据的条形图可视化。 - -A bar chart visualization of a query's results - -现在有了两个查询,让我们创建一个仪表板来可视化和收集这些查询。 - -### Create a dashboard {#create-a-dashboard} - -导航到仪表板面板,并点击“新仪表板”。在您分配名称后,您将成功创建您的第一个仪表板! - -Create a new dashboard - -### Add a visualization {#add-a-visualization} - -有两个保存的查询,`queries over time` 和 `query count by query kind`。让我们将第一个可视化为折线图。给您的可视化设置一个标题和副标题,并选择要可视化的查询。接下来,选择“折线”图表类型,并指定 x 轴和 y 轴。 - -Add a visualization - -在这里,还可以进行其他样式更改,例如数字格式、图例布局和轴标签。 - -接下来,让我们将第二个查询可视化为表格,并将其放置在折线图下方。 - -Visualize query results as a table - -通过可视化两个保存的查询,您已经创建了您的第一个仪表板! - -### Configure a filter {#configure-a-filter} - -让我们通过在查询类型上添加一个过滤器来使这个仪表板具有交互性,这样您就可以仅显示与插入查询相关的趋势。我们将使用 [query parameters](/sql-reference/syntax#defining-and-using-query-parameters) 来完成此任务。 - -单击折线图旁边的三个点,然后单击查询旁边的铅笔按钮以打开内联查询编辑器。在这里,我们可以直接从仪表板编辑底层的保存查询。 - -Edit the underlying query - -现在,当按下黄色的运行查询按钮时,您将看到之前仅针对插入查询过滤的相同查询。单击保存按钮以更新查询。当您返回到图表设置时,您将能够过滤折线图。 - -现在,通过顶部功能区上的 Global Filters,您可以通过更改输入来切换该过滤器。 - -Adjust global filters - -假设您想将折线图的过滤器链接到表。您可以通过返回可视化设置,将 `query_kind` 查询参数的值源更改为表,并选择 `query_kind` 列作为链接字段来做到这一点。 - -Changing query parameter - -现在,您可以直接从按查询类型的表中控制折线图上的过滤器,以使您的仪表板具有交互性。 - -Control the filter on the line chart diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/dashboards.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/dashboards.md.hash deleted file mode 100644 index fc81eb3daa0..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/dashboards.md.hash +++ /dev/null @@ -1 +0,0 @@ -91878617913c19ed diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/index.md deleted file mode 100644 index e03407630f9..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/index.md +++ /dev/null @@ -1,35 +0,0 @@ ---- -'slug': '/cloud/manage' -'keywords': -- 'AWS' -- 'Cloud' -- 'serverless' -- 'management' -'title': '概述' -'hide_title': true -'description': '管理云的概述页面' ---- - - -# 管理云 - -在本节文档中,您将找到关于管理 ClickHouse 云的所有信息。本节包含以下页面: - -| 页面 | 描述 | -|-----------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------| -| [ClickHouse Cloud 级别](/cloud/manage/cloud-tiers) | 描述不同的云级别、它们的特性以及选择合适级别时需要考虑的因素。 | -| [集成](/manage/integrations) | 涵盖 ClickHouse Cloud 的内置集成、自定义集成以及不支持的集成。 | -| [备份](/cloud/manage/backups) | 描述了 ClickHouse Cloud 中备份的工作原理,您可以配置备份的选项以及如何从备份中恢复。 | -| [监控](/integrations/prometheus) | 如何将 Prometheus 集成作为监控 ClickHouse 云的方式。 | -| [计费](/cloud/manage/billing/overview) | 解释了 ClickHouse Cloud 的定价模型,包括影响您服务成本的因素。 | -| [配置设置](/manage/settings) | 描述如何为 ClickHouse Cloud 配置设置。 | -| [副本感知路由](/manage/replica-aware-routing) | 解释了 ClickHouse Cloud 中的副本感知路由是什么,它的限制,以及如何配置它。 | -| [自动扩展](/manage/scaling) | 解释了 ClickHouse Cloud 服务如何根据您的资源需求手动或自动扩展。 | -| [服务正常运行时间和 SLA](/cloud/manage/service-uptime) | 有关生产实例提供的服务正常运行时间和服务级别协议的信息。 | -| [通知](/cloud/notifications) | 显示如何接收 ClickHouse Cloud 通知以及如何自定义这些通知。 | -| [升级](/manage/updates) | 有关 ClickHouse Cloud 中如何进行升级的信息。 | -| [删除账户](/cloud/manage/close_account) | 有关在必要时如何关闭或删除您的账户的信息。 | -| [使用 Postman 的编程 API 访问](/cloud/manage/postman) | 指导您使用 Postman 测试 ClickHouse API。 | -| [故障排除](/faq/troubleshooting) | 常见问题及其故障排除方法的集合。 | -| [数据传输](./network-data-transfer.mdx) | 了解 ClickHouse Cloud 如何计量数据传输的进出流量。 | -| [2025年1月变更常见问题](./jan2025_faq/index.md) | 了解 2025 年 1 月引入的云变更。 | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/index.md.hash deleted file mode 100644 index 45d161f70e8..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/index.md.hash +++ /dev/null @@ -1 +0,0 @@ -abc77200856ec1c0 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/integrations.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/integrations.md deleted file mode 100644 index 37c9ba60fe1..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/integrations.md +++ /dev/null @@ -1,32 +0,0 @@ ---- -'sidebar_label': '集成' -'slug': '/manage/integrations' -'title': '集成' -'description': 'ClickHouse 的集成' ---- - -要查看 ClickHouse 的完整集成列表,请参见 [此页面](/integrations)。 - -## ClickHouse Cloud 的专有集成 {#proprietary-integrations-for-clickhouse-cloud} - -除了 ClickHouse 可用的几十个集成外,还有一些仅适用于 ClickHouse Cloud 的专有集成: - -### ClickPipes {#clickpipes} - -[ClickPipes](/integrations/clickpipes) 是一个托管的集成平台,通过一个简单的基于网络的用户界面将数据导入 ClickHouse Cloud。它目前支持 Apache Kafka、S3、GCS 和 Amazon Kinesis,更多集成即将推出。 - -### ClickHouse Cloud 的 Looker Studio {#looker-studio-for-clickhouse-cloud} - -[Looker Studio](https://lookerstudio.google.com/) 是 Google 提供的一种流行商业智能工具。Looker Studio 目前不提供 ClickHouse 连接器,而是依赖 MySQL 连接协议连接到 ClickHouse。 - -通过启用 [MySQL 接口](/interfaces/mysql),Looker Studio 可以连接到 ClickHouse Cloud。有关将 Looker Studio 连接到 ClickHouse Cloud 的详细信息,请参见 [此页面](/interfaces/mysql#enabling-the-mysql-interface-on-clickhouse-cloud)。 - -### MySQL 接口 {#mysql-interface} - -一些应用程序目前不支持 ClickHouse 连接协议。要将 ClickHouse Cloud 与这些应用程序一起使用,您可以通过 Cloud Console 启用 MySQL 连接协议。有关如何通过 Cloud Console 启用 MySQL 连接协议的详细信息,请参见 [此页面](/interfaces/mysql#enabling-the-mysql-interface-on-clickhouse-cloud)。 - -## 不支持的集成 {#unsupported-integrations} - -以下集成功能目前不适用于 ClickHouse Cloud,因为它们是实验性功能。如果需要在您的应用程序中支持这些功能,请联系 support@clickhouse.com。 - -- [MaterializedPostgreSQL](/engines/table-engines/integrations/materialized-postgresql) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/integrations.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/integrations.md.hash deleted file mode 100644 index d57de49d713..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/integrations.md.hash +++ /dev/null @@ -1 +0,0 @@ -edb5a54525d091ab diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/_snippets/_clickpipes_faq.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/_snippets/_clickpipes_faq.md deleted file mode 100644 index 93b827ec0c2..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/_snippets/_clickpipes_faq.md +++ /dev/null @@ -1,142 +0,0 @@ ---- -null -... ---- - -import Image from '@theme/IdealImage'; -import clickpipesPricingFaq1 from '@site/static/images/cloud/manage/jan2025_faq/external_clickpipes_pricing_faq_1.png'; -import clickpipesPricingFaq2 from '@site/static/images/cloud/manage/jan2025_faq/external_clickpipes_pricing_faq_2.png'; -import clickpipesPricingFaq3 from '@site/static/images/cloud/manage/jan2025_faq/external_clickpipes_pricing_faq_3.png'; - -
- -为什么我们现在为 ClickPipes 引入定价模型? - -我们决定最初将 ClickPipes 免费推出,目的是收集反馈、完善功能并确保其满足用户需求。 -随着 GA 平台的发展,它在处理数万亿行数据方面经受住了时间的考验。引入定价模型使我们能够继续改善服务,维护基础设施,并提供专门的支持和新的连接器。 - -
- -
- -什么是 ClickPipes 副本? - -ClickPipes 通过专用基础设施从远程数据源中摄取数据,这些基础设施独立于 ClickHouse Cloud 服务运行和扩展。 -因此,它使用专用的计算副本。 -下面的图示显示了一个简化的架构。 - -对于流式 ClickPipes,ClickPipes 副本访问远程数据源(例如 Kafka 代理), -拉取数据,处理并摄取到目标 ClickHouse 服务中。 - -ClickPipes 副本 - 流式 ClickPipes - -在对象存储 ClickPipes 的情况下, -ClickPipes 副本协调数据加载任务 -(识别要复制的文件、维护状态和移动分区), -同时数据是直接从 ClickHouse 服务中拉取的。 - -ClickPipes 副本 - 对象存储 ClickPipes - -
- -
- -副本的默认数量和大小是多少? - -每个 ClickPipe 默认包含 1 个副本,配备 2 GiB 内存和 0.5 vCPU。 -这相当于 **0.25** ClickHouse 计算单元(1 单元 = 8 GiB RAM, 2 vCPUs)。 - -
- -
- -ClickPipes 副本可以扩展吗? - -流式 ClickPipes 可以通过添加更多副本来横向扩展,每个副本的基本单元为 **0.25** ClickHouse 计算单元。 -对于特定用例,垂直扩展也是按需提供(为每个副本增加更多 CPU 和 RAM)。 - -
- -
- -我需要多少 ClickPipes 副本? - -这取决于工作负载的吞吐量和延迟要求。 -我们建议从 1 个副本的默认值开始,测量您的延迟,并在需要时添加副本。 -请记住,对于 Kafka ClickPipes,您还需要相应地扩展 Kafka 代理分区。 -扩展控制在每个流式 ClickPipe 的“设置”中可用。 - -ClickPipes 副本 - 我需要多少 ClickPipes 副本? - -
- -
- -ClickPipes 的定价结构是什么样的? - -它由两个维度组成: -- **计算**: 每单位每小时的价格 - 计算代表运行 ClickPipes 副本 Pod 的成本,无论它们是否积极摄取数据。 - 这适用于所有类型的 ClickPipes。 -- **摄取的数据**: 按 GB 计费 - 对于所有流式 ClickPipes(Kafka, Confluent, Amazon MSK, Amazon Kinesis, Redpanda, WarpStream, Azure Event Hubs),摄取的数据费率适用于通过副本 Pod 传输的数据。 - 摄取的数据大小(GB)是基于从源接收的字节数(未压缩或压缩)进行收费。 - -
- -
- -ClickPipes 的公开价格是什么? - -- 计算: 每单位每小时 \$0.20 (每个副本每小时 \$0.05) -- 摄取的数据: 每 GB \$0.04 - -
- -
- -在一个示例中它看起来怎么样? - -例如,使用 Kafka 连接器通过单个副本(0.25 计算单元)摄取 1 TB 数据,持续 24 小时的费用为: - -$$ -(0.25 \times 0.20 \times 24) + (0.04 \times 1000) = \$41.2 -$$ -
- -对于对象存储连接器(S3 和 GCS), -只产生 ClickPipes 的计算成本,因为 ClickPipes Pod 不处理数据 -而只是协调由基础 ClickHouse 服务操作的传输: - -$$ -0.25 \times 0,20 \times 24 = \$1.2 -$$ - -
- -
- -新的定价模型何时生效? - -新的定价模型将在 2025 年 1 月 27 日之后创建的所有组织中生效。 - -
- -
- -当前用户会发生什么? - -现有用户将有一个 **60 天的宽限期**,在此期间 ClickPipes 服务将继续免费提供。 -现有用户的 ClickPipes 计费将于 **2025 年 3 月 24 日** 自动开始。 - -
- -
- -ClickPipes 的定价与市场相比如何? - -ClickPipes 定价背后的理念是 -覆盖平台的运营成本,同时提供一种简单可靠的方式将数据迁移到 ClickHouse Cloud。 -从这个角度来看,我们的市场分析显示,我们的定位具有竞争力。 - -
diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/_snippets/_clickpipes_faq.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/_snippets/_clickpipes_faq.md.hash deleted file mode 100644 index b05f051ebed..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/_snippets/_clickpipes_faq.md.hash +++ /dev/null @@ -1 +0,0 @@ -70d83bd07e578519 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/backup.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/backup.md deleted file mode 100644 index 8e212ff742a..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/backup.md +++ /dev/null @@ -1,22 +0,0 @@ ---- -'title': '备份策略' -'slug': '/cloud/manage/jan-2025-faq/backup' -'keywords': -- 'new tiers' -- 'plans' -- 'pricing' -- 'backups' -'description': '新层中的备份策略' ---- - -## 什么是备份策略? {#what-is-the-backup-policy} -在基本、规模和企业级别,备份是计量的,并且与存储分开收费。 -所有服务默认为每天进行一次备份,并可以在云控制台的设置选项卡中配置更多备份,从规模级别开始。每个备份至少保留24小时。 - -## 用户设置的当前配置与默认备份分开的情况会如何? {#what-happens-to-current-configurations-that-users-have-set-up-separate-from-default-backups} - -客户特定的备份配置将会保留。用户可以根据需要在新的层次中更改这些配置。 - -## 各个层次的备份收费是否不同? {#are-backups-charged-differently-across-tiers} - -所有层次的备份费用是相同的。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/backup.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/backup.md.hash deleted file mode 100644 index 34cab564c01..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/backup.md.hash +++ /dev/null @@ -1 +0,0 @@ -f8155d394fd70e53 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/billing.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/billing.md deleted file mode 100644 index 3dbdf9bf2f9..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/billing.md +++ /dev/null @@ -1,49 +0,0 @@ ---- -'title': '计费' -'slug': '/cloud/manage/jan-2025-faq/billing' -'keywords': -- 'new pricing' -- 'billing' -'description': '新定价层的计费详情' ---- - -## Billing {#billing} - -### Are there any changes to how usage is metered and charged? {#are-there-any-changes-to-how-usage-is-metered-and-charged} - -计算和存储的每个维度单位成本发生了变化,并且现在有两个额外的维度来计算数据传输和 ClickPipes 使用情况。 - -一些显著的变化: - -- 每 TB 存储价格将降低,存储成本将不再包括备份(我们将单独收费,并且只要求进行一次备份)。存储成本在不同级别之间相同,并根据地区和云服务提供商有所不同。 -- 计算成本将根据级别、地区和云服务提供商有所不同。 -- 数据传输的新定价维度仅适用于跨区域和公共互联网的数据出口。 -- ClickPipes 使用的新定价维度。 - -### What happens to users with existing committed spend contracts? {#what-happens-to-users-with-existing-committed-spend-contracts} - -拥有有效的承诺消费合同的用户在合同到期之前不会受到计算和存储新每个维度单位成本价格的影响。然而,数据传输和 ClickPipes 的新定价维度将从 2025 年 3 月 24 日开始适用。大多数客户不会看到这些新维度导致的每月账单显著增加。 - -### Can users on a committed spend agreement with ClickHouse continue to launch services on the old plan? {#can-users-on-a-committed-spend-agreement-with-clickhouse-continue-to-launch-services-on-the-old-plan} - -是的,用户将在合同的结束日期之前能够继续启动开发和生产服务,续订将反映新的定价计划。 - -如果您需要修改合同或对这些变化如何在未来影响您有任何疑问,请联系支持团队或您的销售代表。 - -### What happens if users exhaust their credits before the end of the contract and go to PAYG? {#what-happens-if-users-exhaust-their-credits-before-the-end-of-the-contract-and-go-to-payg} - -如果承诺消费合同在续订日期之前用尽了信用额度,我们将按当前费率收费,直到续订(根据当前政策)。 - -### What happens to users on the monthly PAYG? {#what-happens-to-users-on-the-monthly-payg} - -使用每月 PAYG 计划的用户将继续按旧定价计划收费,以用于开发和生产服务。他们有直到 2025 年 7 月 23 日的时间自行迁移到新计划,否则将于该日迁移到 Scale 配置,并根据新计划收费。 - -### Where can I reference legacy plans? {#where-can-i-reference-legacy-plans} - -可以在 [这里](https://clickhouse.com/pricing?legacy=true) 查阅旧计划。 - -## Marketplaces {#marketplaces} - -### Are there changes to how users are charged via the CSP marketplaces? {#are-there-changes-to-how-users-are-charged-via-the-csp-marketplaces} - -通过 CSP 市场注册 ClickHouse Cloud 的用户以 CHCs(ClickHouse Cloud Credits)的形式产生使用费用。此行为没有改变。然而,信用使用的基础组成将与此处概述的定价和包装变化保持一致,并包括任何数据传输使用和 ClickPipes 的费用,一旦这些服务上线。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/billing.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/billing.md.hash deleted file mode 100644 index 700d3b03de4..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/billing.md.hash +++ /dev/null @@ -1 +0,0 @@ -8a24b55dce023917 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/dimensions.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/dimensions.md deleted file mode 100644 index 5e8f1fdbd14..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/dimensions.md +++ /dev/null @@ -1,40 +0,0 @@ ---- -'title': '新定价维度' -'slug': '/cloud/manage/jan-2025-faq/pricing-dimensions' -'keywords': -- 'new pricing' -- 'dimensions' -'description': '用于数据传输和 ClickPipes 的定价维度' ---- - -import Image from '@theme/IdealImage'; -import clickpipesPricingFaq1 from '@site/static/images/cloud/manage/jan2025_faq/external_clickpipes_pricing_faq_1.png'; -import clickpipesPricingFaq2 from '@site/static/images/cloud/manage/jan2025_faq/external_clickpipes_pricing_faq_2.png'; -import clickpipesPricingFaq3 from '@site/static/images/cloud/manage/jan2025_faq/external_clickpipes_pricing_faq_3.png'; -import NetworkPricing from '@site/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/_snippets/_network_transfer_rates.md'; -import ClickPipesFAQ from './_snippets/_clickpipes_faq.md' - -以下维度已被添加到新的 ClickHouse Cloud 定价中。 - -:::note -自 2025 年 3 月 24 日起,数据传输和 ClickPipes 定价不适用于遗留计划,即开发、生产和专用计划。 -::: - -## 数据传输定价 {#data-transfer-pricing} - -### 用户如何为数据传输收费,组织层级和地区会有所不同吗? {#how-are-users-charged-for-data-transfer-and-will-this-vary-across-organization-tiers-and-regions} - -- 用户在两个维度上为数据传输付费——公共互联网出口和跨区域出口。区域内的数据传输或私人链接/私人服务连接的使用和数据传输不收取费用。然而,如果我们看到影响我们适当收费能力的使用模式,我们保留实施额外数据传输定价维度的权利。 -- 数据传输定价因云服务提供商 (CSP) 和地区而异。 -- 数据传输定价在组织层级之间 **不** 变化。 -- 公共出口定价仅基于来源地区。跨区域(或跨区域)定价取决于来源地区和目的地区。 - - - -### 随着使用量的增加,数据传输定价会分层吗? {#will-data-transfer-pricing-be-tiered-as-usage-increases} - -数据传输价格随着使用量的增加 **不会** 分层。定价因地区和云服务提供商而异。 - -## ClickPipes 定价常见问题 {#clickpipes-pricing-faq} - - diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/dimensions.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/dimensions.md.hash deleted file mode 100644 index baa96610a2e..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/dimensions.md.hash +++ /dev/null @@ -1 +0,0 @@ -0d2d2d1c0fc03c0b diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/index.md deleted file mode 100644 index 314a7c894ed..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/index.md +++ /dev/null @@ -1,23 +0,0 @@ ---- -'title': '2025年1月更改常见问题解答' -'slug': '/cloud/manage/jan-2025-faq' -'description': '新定价常见问题解答索引页' -'keywords': -- 'new pricing' -- 'faq' ---- - - -| 页面 | 描述 | -|-----|-----| -| [概述](/docs/cloud/manage/jan-2025-faq/summary) | 新的 ClickHouse Cloud 级别概述 | -| [新级别描述](/docs/cloud/manage/jan-2025-faq/new-tiers) | 新级别和功能的描述 | -| [计费](/docs/cloud/manage/jan-2025-faq/billing) | 新定价级别的计费细节 | -| [新定价维度](/docs/cloud/manage/jan-2025-faq/pricing-dimensions) | 数据传输和 ClickPipes 的定价维度 | -| [扩展](/docs/cloud/manage/jan-2025-faq/scaling) | 新定价级别中的扩展行为 | -| [备份策略](/docs/cloud/manage/jan-2025-faq/backup) | 新级别中的备份策略 | -| [迁移到新计划](/docs/cloud/manage/jan-2025-faq/plan-migrations) | 迁移到新计划、级别、定价,如何决定和估算成本 | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/index.md.hash deleted file mode 100644 index 11508e8b69f..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/index.md.hash +++ /dev/null @@ -1 +0,0 @@ -a0fba25160bcb7f0 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/new_tiers.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/new_tiers.md deleted file mode 100644 index cfcd3b2ad05..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/new_tiers.md +++ /dev/null @@ -1,68 +0,0 @@ ---- -'title': '新层次的描述' -'slug': '/cloud/manage/jan-2025-faq/new-tiers' -'keywords': -- 'new tiers' -- 'features' -- 'pricing' -- 'description' -'description': '新层次和功能的描述' ---- - -## 关键变更摘要 {#summary-of-key-changes} - -### 关于特性与层级映射的预期关键变更是什么? {#what-key-changes-to-expect-with-regard-to-features-to-tier-mapping} - -- **Private Link/Private Service Connect:** 现在所有服务类型在 Scale 和 Enterprise 层级中均支持私有连接(包括单副本服务)。这意味着您可以为您的生产(大规模)和开发(小规模)环境设置 Private Link。 -- **备份:** 所有服务默认提供一次备份,额外备份将单独收费。用户可以利用可配置的备份控制来管理额外的备份。这意味着备份需求较少的服务无需支付更高的打包价格。请查看备份 FAQ 获取更多详情。 -- **增强加密:** 此功能在 Enterprise 层级的服务中可用,包括单副本服务,适用于 AWS 和 GCP。服务默认由我们的密钥加密,并可以轮换到其密钥以启用客户管理加密密钥(CMEK)。 -- **单点登录 (SSO):** 此功能在 Enterprise 层级中提供,并需要支持工单为某个组织启用。拥有多个组织的用户应确保其所有组织都在 Enterprise 层级,以便为每个组织使用 SSO。 - -## 基础层级 {#basic-tier} - -### 基础层级需要考虑哪些事项? {#what-are-the-considerations-for-the-basic-tier} - -基础层级旨在用于小型工作负载 - 用户希望部署一个不需要高可用性或用于原型的小型分析应用。此层级不适合需要规模、可靠性(灾难恢复/高可用)和数据持久性的工作负载。该层级支持固定大小为 1x8GiB 或 1x12GiB 的单副本服务。有关更多信息,请参考文档和 [支持政策](https://clickhouse.com/support/program)。 - -### 基础层级的用户可以访问 Private Link 和 Private Service Connect 吗? {#can-users-on-the-basic-tier-access-private-link-and-private-service-connect} - -不可以,用户需要升级到 Scale 或 Enterprise 才能访问此功能。 - -### 基础层级和 Scale 层级的用户可以为组织设置 SSO 吗? {#can-users-on-the-basic-and-scale-tiers-set-up-sso-for-the-organization} - -不可以,用户需要升级到 Enterprise 层级才能访问此功能。 - -### 用户可以在所有层级启动单副本服务吗? {#can-users-launch-single-replica-services-in-all-tiers} - -可以,单副本服务在所有三个层级中均受支持。用户可以扩展,但不允许缩减为单副本。 - -### 用户可以在基础层级上向上/向下扩展并添加更多副本吗? {#can-users-scale-updown-and-add-more-replicas-on-the-basic-tier} - -不可以,此层级的服务旨在支持小型和固定大小的工作负载(单副本 `1x8GiB` 或 `1x12GiB`)。如果用户需要向上/向下扩展或添加副本,将被提示升级到 Scale 或 Enterprise 层级。 - -## Scale 层级 {#scale-tier} - -### 新计划(基础/Scale/Enterprise)中哪些层级支持计算-计算分离? {#which-tiers-on-the-new-plans-basicscaleenterprise-support-compute-compute-separation} - -只有 Scale 和 Enterprise 层级支持计算-计算分离。请注意,此功能需要至少运行 2+ 副本的父服务。 - -### 现有计划(生产/开发)的用户可以访问计算-计算分离吗? {#can-users-on-the-legacy-plans-productiondevelopment-access-compute-compute-separation} - -现有的开发和生产服务不支持计算-计算分离,除非用户已经参与了私有预览和测试版。如果您有其他问题,请联系 [支持](https://clickhouse.com/support/program)。 - -## Enterprise 层级 {#enterprise-tier} - -### Enterprise 层级支持哪些不同的硬件配置? {#what-different-hardware-profiles-are-supported-for-the-enterprise-tier} - -Enterprise 层级将支持标准配置(1:4 vCPU:内存比),以及 `highMem (1:8 比)` 和 `highCPU (1:2 比)` **自定义配置,** 为用户提供更多选择,以便选择最适合的配置。Enterprise 层级将使用与基础和 Scale 层级一起部署的共享计算资源。 - -### Enterprise 层级独家提供哪些功能? {#what-are-the-features-exclusively-offered-on-the-enterprise-tier} - -- **自定义配置:** 实例类型选择的选项,标准配置(1:4 vCPU:内存比)和 `highMem (1:8 比)` 和 `highCPU (1:2 比)` 自定义配置。 -- **企业级安全:** - - **单点登录 (SSO)** - - **增强加密:** 适用于 AWS 和 GCP 服务。服务默认由我们的密钥加密,并可以轮换到其密钥以启用客户管理加密密钥(CMEK)。 -- **计划升级:** 用户可以选择进行升级的星期几/时间窗口,涉及数据库和云产品的发布。 -- **HIPAA 合规:** 客户必须通过法律部门签署业务伙伴协议 (BAA),在我们为他们启用符合 HIPAA 的区域之前。 -- **私人区域:** 此功能无法自助开启,需要用户通过 Sales sales@clickhouse.com 路由请求。 -- **导出备份** 到客户的云账户。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/new_tiers.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/new_tiers.md.hash deleted file mode 100644 index 4ccbcbd2ee7..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/new_tiers.md.hash +++ /dev/null @@ -1 +0,0 @@ -23817a9d9793c6b3 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/plan_migrations.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/plan_migrations.md deleted file mode 100644 index 6c9d66d5082..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/plan_migrations.md +++ /dev/null @@ -1,112 +0,0 @@ ---- -'title': '迁移到新计划' -'slug': '/cloud/manage/jan-2025-faq/plan-migrations' -'keywords': -- 'migration' -- 'new tiers' -- 'pricing' -- 'cost' -- 'estimation' -'description': '迁移到新计划、层级、定价,如何决定和估算成本' ---- - -## 选择新计划 {#choosing-new-plans} - -### 新组织可以在旧的(遗留)计划上启动服务吗? {#can-new-organizations-launch-services-on-the-old-legacy-plan} - -不,创建的新组织在公告后将无法访问旧计划。 - -### 用户可以自行迁移到新的定价计划吗? {#can-users-migrate-to-the-new-pricing-plan-self-serve} - -是的,以下是关于自行迁移的指导: - -| 当前计划 | 新计划 | 自行迁移 | -|------------|-------------------------|----------------------------------------------------------------------------------------------------------------| -| Development | Basic | 如果组织中的所有服务支持 Development 则支持 | -| Development | Scale (2 replicas+) | :white_check_mark: | -| Development | Enterprise (2 replicas+) | :white_check_mark: | -| Production | Scale (3 replicas+) | :white_check_mark: | -| Production | Enterprise (3 replicas+) | :white_check_mark: | -| Dedicated | 联系 [support](https://clickhouse.com/support/program) | - -### 在试用运行 Development 和 Production 服务期间,用户的体验将是什么样的? {#what-will-the-experience-be-for-users-in-trial-running-development-and-production-services} - -用户可以在试用期间升级,并继续使用试用积分评估新的服务层级及其支持的功能。但是,如果他们选择继续使用相同的 Development 和 Production 服务,他们可以这样做并升级到 PAYG。仍需在 2025 年 7 月 23 日之前迁移。 - -### 用户可以升级他们的层级吗,即 Basic → Scale, Scale → Enterprise 等? {#can-users-upgrade-their-tiers-ie-basic--scale-scale--enterprise-etc} - -是的,用户可以自行升级,定价将在升级后反映所选层级。 - -### 用户可以从较高的成本层级移动到较低的成本层级吗,例如 Enterprise → Scale, Scale → Basic, Enterprise → Basic 自行服务? {#can-users-move-from-a-higher-to-a-lower-cost-tier-eg-enterprise--scale-scale--basic-enterprise--basic-self-serve} - -不,我们不允许降级层级。 - -### 只有组织中的 Development 服务的用户可以迁移到 Basic 层级吗? {#can-users-with-only-development-services-in-the-organization-migrate-to-the-basic-tier} - -是的,这是被允许的。用户将根据他们过去的使用情况获得推荐,并可以选择 Basic `1x8GiB` 或 `1x12GiB`。 - -### 在同一组织中有 Development 和 Production 服务的用户可以迁移到 Basic 层级吗? {#can-users-with-a-development-and-production-service-in-the-same-organization-move-to-the-basic-tier} - -不,如果用户在同一组织中同时拥有 Development 和 Production 服务,他们只能自行迁移到 Scale 或 Enterprise 层级。如果他们想迁移到 Basic,必须删除所有现有的 Production 服务。 - -### 新层级在扩展行为方面有任何变化吗? {#are-there-any-changes-related-to-the-scaling-behavior-with-the-new-tiers} - -我们引入了一种新的垂直扩展机制用于计算副本,我们称之为“先建后拆”(Make Before Break, MBB)。这种方法在移除旧副本之前添加一个或多个新大小的副本,防止在扩展操作期间任何容量损失。通过消除移除现有副本和添加新副本之间的间隙,MBB 使得扩展过程更加无缝且不具破坏性。它在规模扩展场景中特别有益,因为高资源利用率会触发对额外容量的需求,提早移除副本只会加剧资源限制。 - -请注意,作为此更改的一部分,历史系统表数据将在最多 30 天内保留,以支持扩展事件。此外,对于 AWS 或 GCP 上的服务,12 月 19 日 2024 年之前的任何系统表数据,将不会在迁移到新组织层级时保留,而对于 Azure 上的服务,这一日期为 2025 年 1 月 14 日。 - -## 估算成本 {#estimating-costs} - -### 用户在迁移过程中如何获得指导,以了解最适合他们需求的层级? {#how-will-users-be-guided-during-migration-understanding-what-tier-best-fits-their-needs} - -如果您有服务,控制台将根据历史使用情况提示您每个服务的推荐选项。新用户可以详细查看列出的能力和功能,并决定最适合他们需求的层级。 - -### 用户如何在新定价中估算“仓库”的大小和成本? {#how-do-users-size-and-estimate-the-cost-of-warehouses-in-the-new-pricing} - -请参考 [定价](https://clickhouse.com/pricing) 页上的定价计算器,它将帮助根据您的工作负载大小和层级选择估算成本。 - - -## 进行迁移 {#undertaking-the-migration} - -### 进行迁移的服务版本先决条件是什么? {#what-are-service-version-pre-requisites-to-undertaking-the-migration} - -您的服务必须在 24.8 版本或更高版本,并已迁移到 SharedMergeTree。 - -### 当前的 Development 和 Production 服务的用户迁移体验是什么?用户是否需要计划服务不可用的维护窗口? {#what-is-the-migration-experience-for-users-of-the-current-development-and-production-services-do-users-need-to-plan-for-a-maintenance-window-where-the-service-is-unavailable} - -Development 和 Production 服务迁移到新定价层级可能会触发服务器重启。要迁移 Dedicated 服务,请联系 [support](https://clickhouse.com/support/program)。 - -### 用户在迁移后应采取哪些其他行动? {#what-other-actions-should-a-user-take-after-the-migration} - -API 访问模式将有所不同。 - -使用我们 OpenAPI 创建新服务的用户将需要在服务创建的 `POST` 请求中删除 `tier` 字段。 - -由于我们不再有服务层级,因此 `tier` 字段已从服务对象中删除。 -这将影响由 `POST`、`GET` 和 `PATCH` 服务请求返回的对象。因此,任何使用这些 API 的代码可能需要调整以处理这些更改。 - -每个服务默认创建的副本数量对于 Scale 和 Enterprise 层级默认为 3,而 Basic 层级默认为 1。 -对于 Scale 和 Enterprise 层级,您可以通过在服务创建请求中传递 `numReplicas` 字段来进行调整。 -`numReplicas` 字段的值必须在 2 到 20 之间,适用于仓库中的第一个服务。创建在现有仓库中的服务可以将副本数低至 1。 - -### 如果使用现有的 Terraform 提供者进行自动化,用户应进行哪些更改? {#what-changes-should-the-users-make-if-using-the-existing-terraform-provider-for-automation} - -一旦组织迁移到新计划之一,用户将被要求使用我们 Terraform 提供者版本 2.0.0 或更高版本。 - -新的 Terraform 提供者是因为 `tier` 属性在服务中的变更所必需的。 - -迁移后,不再接受 `tier` 字段,应删除对其的引用。 - -用户还可以将 `num_replicas` 字段作为服务资源的属性进行指定。 - -每个服务默认创建的副本数量对于 Scale 和 Enterprise 层级默认为 3,而 Basic 层级默认为 1。 -对于 Scale 和 Enterprise 层级,您可以通过在服务创建请求中传递 `numReplicas` 字段来进行调整。 -`num_replicas` 字段的值必须在 2 到 20 之间,适用于仓库中的第一个服务。创建在现有仓库中的服务可以将副本数低至 1。 - -### 用户需要对数据库访问进行任何更改吗? {#will-users-have-to-make-any-changes-to-the-database-access} - -不,数据库用户名/密码的工作方式与以前相同。 - -### 用户需要重新配置私有网络功能吗? {#will-users-have-to-reconfigure-private-networking-features} - -不,用户在将其 Production 服务迁移到 Scale 或 Enterprise 后,可以使用现有的私有网络(Private Link、PSC 等)配置。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/plan_migrations.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/plan_migrations.md.hash deleted file mode 100644 index 3c46b8ad14c..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/plan_migrations.md.hash +++ /dev/null @@ -1 +0,0 @@ -0a040aac8ced5f00 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/scaling.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/scaling.md deleted file mode 100644 index 7d6f2a3ad94..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/scaling.md +++ /dev/null @@ -1,39 +0,0 @@ ---- -'title': '扩展' -'slug': '/cloud/manage/jan-2025-faq/scaling' -'keywords': -- 'new pricing' -- 'faq' -- 'scaling' -'description': '在新定价层中的扩展行为' ---- - -ClickHouse Cloud 允许向两个方向扩展 - 垂直(增加副本大小)和水平(增加更多副本)。 - -## 每个级别可用的扩展选项是什么? {#what-scaling-options-will-be-available-for-each-tier} - -每个级别的扩展行为如下: - -* **基本**:基本级别仅支持单个副本服务。这些服务的大小是固定的,不允许进行垂直或水平扩展。用户可以升级到 Scale 或 Enterprise 级别以扩展他们的服务。 -* **Scale**:Scale 级别支持单个和多个副本服务。多个副本服务允许扩展。 - * 服务可在扩展到多个副本设置后,垂直扩展到 CSP/区域支持的最大副本大小;仅 2 个以上副本可以进行垂直扩展。 - * 将提供手动水平扩展。 -* **Enterprise**:Enterprise 级别支持单个和多个副本服务,并允许多个副本服务进行扩展。 - * 服务可以垂直扩展到 CSP/区域支持的最大副本大小。 - * 标准配置(1:4 CPU 与内存比)将支持垂直自动扩展。 - * 自定义配置(`highMemory` 和 `highCPU`)可以通过支持工单进行垂直扩展。 - * 将提供手动水平扩展。 - -:::note -服务可以水平扩展到最多 20 个副本。如果您需要额外的副本,请联系支持团队。 -::: - -## 用户可以在服务中进行扩展吗? {#can-users-scale-in-their-service} - -扩展将限制为 2 个以上副本。一旦扩展,用户将不允许缩减到单个副本,因为这可能导致不稳定和潜在的数据丢失。 - -## 新级别的扩展行为是否有任何变化? {#are-there-any-changes-related-to-the-scaling-behavior-with-the-new-tiers} - -我们引入了一种新的垂直扩展机制,称为“Make Before Break”(MBB)。这种方法是在移除旧副本之前添加一个或多个新大小的副本,从而防止在扩展操作期间容量的损失。通过消除移除现有副本和添加新副本之间的间隔,MBB 创建了一个更无缝、更少干扰的扩展过程。这在向上扩展的场景中特别有利,在这种情况下,高资源利用率触发了对额外容量的需求,因为过早移除副本只会加剧资源限制。 - -请注意,作为此更改的一部分,历史系统表数据将在扩展事件中保留最多 30 天。此外,对于 AWS 或 GCP 上的服务,2024 年 12 月 19 日之前的任何系统表数据将不会作为迁移到新组织级别的部分而被保留,对于 Azure 上的服务,2025 年 1 月 14 日之前的任何系统表数据将不被保留。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/scaling.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/scaling.md.hash deleted file mode 100644 index e6030df36b1..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/scaling.md.hash +++ /dev/null @@ -1 +0,0 @@ -f9d028e52cee5294 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/summary.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/summary.md deleted file mode 100644 index 94b7013506a..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/summary.md +++ /dev/null @@ -1,97 +0,0 @@ ---- -'title': '总结' -'slug': '/cloud/manage/jan-2025-faq/summary' -'keywords': -- 'new tiers' -- 'packaging' -- 'pricing faq' -- 'summary' -'description': '新 ClickHouse Cloud 级别的总结' ---- - -以下常见问题解答总结了有关ClickHouse Cloud于2025年1月引入的新层级的常见问题。 - -## ClickHouse Cloud层级有哪些变化? {#what-has-changed-with-clickhouse-cloud-tiers} - -在ClickHouse,我们致力于调整我们的产品,以满足客户不断变化的需求。自两年前正式推出以来,ClickHouse Cloud经历了显著的演变,我们获得了宝贵的见解,了解客户如何利用我们的云服务。 - -我们正在引入新功能,以优化ClickHouse Cloud服务在工作负载方面的规模和成本效率。这些功能包括计算-计算分离、高性能机器类型和单副本服务。我们还在自动扩展和托管升级方面进行改进,使其以更无缝和响应迅速的方式执行。 - -我们正在新增一个企业级别,以满足最具挑战性的客户和工作负载的需求,重点关注行业特定的安全和合规功能,对基础硬件和升级有更多控制,以及先进的灾难恢复功能。 - -您可以在这个[博客](https://clickhouse.com/blog/evolution-of-clickhouse-cloud-new-features-superior-performance-tailored-offerings)中阅读这些以及其他功能变化。 - -## 需要采取什么措施? {#what-action-is-required} - -为了支持这些变化,我们正在重组当前层级,以更准确匹配我们的不断发展的客户基础对我们产品的使用,您需要采取行动来选择新计划。 - -选择的详细信息和时间表如下。 - -## 层级有什么变化? {#how-are-tiers-changing} - -我们正在从一个将付费层级仅按“服务类型”组织的模型转变,该模型根据容量和特性区分(即开发、生产和专用层级)到一个按功能可用性组织的付费层级。这些新层级称为基础、规模和企业,下面将详细描述。 - -这一变化带来了几个关键好处: - -* **一致的功能访问**:某一层级中的功能将在该层级的所有服务规模中可用,并且在其上所有层级中均可用。例如,私有网络以前仅对生产服务类型可用,现在从规模层级开始,所有服务都可以访问,因此您可以根据需要为开发和生产工作负载部署此功能。 - -* **组织级功能**:我们现在可以在适当的计划下提供在组织级别建立的功能,确保客户在合适的服务级别获得所需工具。例如,SSO(单一登录)和CMEK(客户管理加密密钥)的访问权限将仅在企业层级可用。 - -* **优化的支持计划**:新的包装结构还允许我们将支持响应时间与付费层级对齐,更有效地满足我们多样化客户基础的需求。例如,我们现在为企业层级客户提供指定支持工程师。 - -以下是新层级的概述,描述它们如何与使用案例相关,并列出关键功能。 - -**基础:ClickHouse的初步体验** - -* 基础层级旨在为数据量较小和工作负载要求较低的组织提供预算友好的选项。它允许您运行单副本部署,具备最多12GB内存和少于1TB存储,非常适合不需要可靠性保证的小规模用例。 - -**规模:增强的服务等级协议和可扩展性** - -* 规模层级适用于需要增强服务等级协议、更大可扩展性和高级安全措施的工作负载。 -* 它提供无限计算和存储,伴随任何复制因子,访问计算-计算分离,以及自动垂直和水平扩展。 -* 关键功能包括: - * 对私有网络、自定义备份控制、多因素身份验证等的支持 - * 优化资源使用的计算-计算分离 - * 灵活的扩展选项(包括垂直和水平)以满足变化的需求 - -**企业:关键任务部署** - -* 企业级别是运行大规模、关键任务的ClickHouse部署的最佳选择。 -* 它最适合对安全和合规性需求严格的组织,要求最高水平的性能和可靠性。 -* 关键功能包括: - * 行业特定的合规认证,如HIPAA - * 自助访问SSO(单一登录)和CMEK(客户管理加密密钥) - * 定期升级以确保最小干扰 - * 支持自定义配置,包括高内存、高CPU选项和私有区域 - -新层级的详细介绍可在我们的[官网](https://clickhouse.com/pricing)上找到。 - -## 定价将如何变化? {#how-is-pricing-changing} - -除了发展我们的付费层级外,我们还对整体定价结构和价格点进行了以下调整: - -* **存储**:存储每TB的价格将降低,且存储费用中将不再包含备份。 -* **备份**:备份将单独收费,仅为一个备份为强制性。 -* **计算**:计算成本将增加,视层级和地区而异。这一增加可能会因为计算-计算分离和单副本服务的引入而得到平衡,这些服务允许您通过根据不同工作负载类型部署和合理配置服务来优化计算使用。 -* **数据传输**:我们将对数据出带进行收费,特别是针对互联网和跨地区的数据传输。根据我们的分析,大多数客户不会因为这个新维度而看到其月账单有实质性增加。 -* **ClickPipes**:我们的托管摄取服务在介绍期内是免费的,现在将根据计算和摄取的数据收取费用。根据我们的分析,大多数客户不会因为这个新维度而看到其月账单有实质性增加。 - -## 这些变化何时生效? {#when-will-these-changes-take-effect} - -尽管对于新客户,这些变化会立即生效,但现有客户将拥有6个月到一年的时间来过渡到新计划。 - -生效日期的详细分解如下: - -* **新客户**:对于ClickHouse Cloud的新客户,新计划将于**2025年1月27日**生效。 -* **现有的按需付费客户**:按需付费(PAYG)客户将有6个月的时间,直到**2025年7月23日**,以迁移到新计划。 -* **现有的承诺消费客户**:拥有承诺消费协议的客户可以在当前合同结束时重新协商条款。 -* **数据传输和ClickPipes的新使用维度**将于**2025年3月24日**,在此次公告后8周内同时对PAYG和承诺消费客户生效。 - -## 您应该采取什么行动? {#what-actions-should-you-take} - -如果您是**按需付费(PAYG)客户**,可以通过ClickHouse Cloud控制台中提供的自助选项迁移到新计划。 - -如果您是**承诺消费客户**,请联系您的客户代表讨论您的自定义迁移计划和时间表。 - -**需要帮助吗?** -我们在这次过渡中为您提供支持。如果您有任何问题或需要个性化帮助,请联系您的客户代表或联系我们的支持团队。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/summary.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/summary.md.hash deleted file mode 100644 index b30fad644e2..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/jan2025_faq/summary.md.hash +++ /dev/null @@ -1 +0,0 @@ -9858329a1bd62d03 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/network-data-transfer.mdx b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/network-data-transfer.mdx deleted file mode 100644 index e1f0e102cbd..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/network-data-transfer.mdx +++ /dev/null @@ -1,32 +0,0 @@ ---- -'sidebar_label': '数据传输' -'slug': '/cloud/manage/network-data-transfer' -'title': '数据传输' -'description': '了解更多关于 ClickHouse Cloud 如何计量传入和传出的数据' ---- - -import NetworkPricing from '@site/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/_snippets/_network_transfer_rates.md'; - -ClickHouse Cloud 计量传输的入站和出站数据。这包括任何进出 ClickHouse Cloud 的数据,以及任何区域内和跨区域的数据传输。此使用情况在服务级别进行跟踪。根据此使用情况,客户将产生数据传输费用,这些费用随后将被添加到他们的月账单中。 - -ClickHouse Cloud 收取以下费用: -- 从 ClickHouse Cloud 到公共互联网的数据出站,包括到其他云服务提供商的其他区域。 -- 向同一云服务提供商的另一个区域进行数据出站。 - -对于区域内的数据传输或 Private Link/Private Service Connect 使用和数据传输没有费用。然而,如果我们观察到影响我们适当收费能力的使用模式,我们保留实施额外数据传输定价维度的权利。 - -数据传输费用因云服务提供商(CSP)和区域而异。公共互联网出站定价仅基于起源区域。区域间(或跨区域)定价取决于起源和目标区域。 - -**最小化数据传输成本的最佳实践** - -在进出 Clickhouse Cloud 数据时,有一些模式需要记住,以最小化数据传输成本。 -1. 在从 Clickhouse Cloud 进出数据时,尽量使用压缩,以最小化传输的数据量及相关费用。 -2. 请注意,当使用原生协议进行 INSERT 操作且包含非内联值时(例如 INSERT INTO [TABLE] FROM INFILE [FILE] FORMAT NATIVE),ClickHouse 客户端会从服务器提取元数据以打包数据。如果元数据大于 INSERT 负载,从服务器的角度来看,您可能会发现出站数据奇怪地多于入站数据。如果这不可接受,请考虑使用 VALUES 语法内联数据或使用 HTTP 协议。 - -下表展示了不同云服务提供商和区域中公共互联网或跨区域的数据传输费用如何变化。 - -:::note -ClickHouse Cloud 以等级(Tier 1 到 Tier 4)计量区域间使用情况,具体取决于起源和目标区域。下表展示了每种区域间数据传输的组合所对应的等级。在 ClickHouse Cloud 的账单使用屏幕中,您将看到按等级细分的数据传输使用情况。 -::: - - diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/network-data-transfer.mdx.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/network-data-transfer.mdx.hash deleted file mode 100644 index 741af24988b..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/network-data-transfer.mdx.hash +++ /dev/null @@ -1 +0,0 @@ -3af7c4d1ff2933e5 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/notifications.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/notifications.md deleted file mode 100644 index d1715618416..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/notifications.md +++ /dev/null @@ -1,48 +0,0 @@ ---- -'title': '通知' -'slug': '/cloud/notifications' -'description': '您 ClickHouse Cloud 服务的通知' -'keywords': -- 'cloud' -- 'notifications' ---- - -import Image from '@theme/IdealImage'; -import notifications_1 from '@site/static/images/cloud/manage/notifications-1.png'; -import notifications_2 from '@site/static/images/cloud/manage/notifications-2.png'; -import notifications_3 from '@site/static/images/cloud/manage/notifications-3.png'; -import notifications_4 from '@site/static/images/cloud/manage/notifications-4.png'; - -ClickHouse Cloud 发送有关与您的服务或组织相关的关键事件的通知。为了理解通知的发送和配置,有几个概念需要牢记: - -1. **通知类别**:指通知的分组,例如账单通知、服务相关通知等。在每个类别中,有多个通知可以配置交付模式。 -2. **通知严重性**:通知严重性可以是 `info`、`warning` 或 `critical`,具体取决于通知的重要性。这是不可配置的。 -3. **通知渠道**:渠道是指接收通知的方式,例如 UI、电子邮件、Slack 等。这对于大多数通知是可配置的。 - -## 接收通知 {#receiving-notifications} - -通知可以通过各种渠道接收。目前,ClickHouse Cloud 支持通过电子邮件、ClickHouse Cloud UI 和 Slack 接收通知。您可以点击左上角菜单中的铃铛图标查看当前通知,这将打开一个侧边栏。点击侧边栏底部的 **查看全部** 按钮将带您进入显示所有通知活动日志的页面。 - -ClickHouse Cloud notifications flyout - -ClickHouse Cloud notifications activity log - -## 自定义通知 {#customizing-notifications} - -对于每个通知,您可以自定义如何接收该通知。您可以通过通知侧边栏或通知活动日志的第二个选项卡访问设置屏幕。 - -云用户可以自定义通过 Cloud UI 发送的通知,这些自定义对每个单独用户都有反映。云用户还可以自定义发送到自己电子邮件的通知,但只有具有管理员权限的用户才能自定义发送到自定义电子邮件和发送到 Slack 渠道的通知。 - -要配置特定通知的交付,请点击铅笔图标以修改通知交付渠道。 - -ClickHouse Cloud notifications settings screen - -ClickHouse Cloud notification delivery settings - -:::note -某些 **必需** 通知,例如 **支付失败** 是不可配置的。 -::: - -## 支持的通知 {#supported-notifications} - -目前,我们发送与账单(支付失败、使用超过特定阈值等)相关的通知以及与扩展事件(扩展完成、扩展被阻止等)相关的通知。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/notifications.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/notifications.md.hash deleted file mode 100644 index 524fa5a156e..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/notifications.md.hash +++ /dev/null @@ -1 +0,0 @@ -b2da1b2f0129acd4 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/openapi.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/openapi.md deleted file mode 100644 index ea7987e4428..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/openapi.md +++ /dev/null @@ -1,64 +0,0 @@ ---- -'sidebar_label': '管理 API 密钥' -'slug': '/cloud/manage/openapi' -'title': '管理 API 密钥' -'description': 'ClickHouse Cloud 提供一个利用 OpenAPI 的 API,允许您以编程方式管理您的帐户和服务的各个方面。' ---- - -import image_01 from '@site/static/images/cloud/manage/openapi1.png'; -import image_02 from '@site/static/images/cloud/manage/openapi2.png'; -import image_03 from '@site/static/images/cloud/manage/openapi3.png'; -import image_04 from '@site/static/images/cloud/manage/openapi4.png'; -import image_05 from '@site/static/images/cloud/manage/openapi5.png'; -import Image from '@theme/IdealImage'; - - -# 管理 API 密钥 - -ClickHouse Cloud 提供了一个利用 OpenAPI 的 API,使您可以以编程方式管理您的账户和服务的各个方面。 - -:::note -本文档涵盖了 ClickHouse Cloud API。有关数据库 API 端点的信息,请参见 [Cloud Endpoints API](/cloud/get-started/query-endpoints.md) -::: - -1. 您可以使用左侧菜单中的 **API 密钥** 选项卡来创建和管理您的 API 密钥。 - - API Keys tab - -2. **API 密钥** 页面最初会显示创建您的第一个 API 密钥的提示,如下所示。在您创建第一个密钥后,您可以使用右上角出现的 `New API Key` 按钮创建新密钥。 - - API Keys page - -3. 要创建 API 密钥,请指定密钥名称、权限和过期时间,然后点击 `Generate API Key`。 -
-:::note -权限与 ClickHouse Cloud 的 [预定义角色](/cloud/security/cloud-access-management/overview#console-users-and-roles) 对齐。开发者角色对分配的服务具有只读权限,而管理员角色具有完全的读写权限。 -::: - - Create API key form - -4. 下一个屏幕将显示您的密钥 ID 和密钥秘密。复制这些值并安全地保存,例如保存在保险箱中。离开此屏幕后,这些值将不会再显示。 - - API key details - -5. ClickHouse Cloud API 使用 [HTTP Basic Authentication](https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication) 来验证您的 API 密钥的有效性。以下是一个使用您的 API 密钥通过 `curl` 向 ClickHouse Cloud API 发送请求的示例: - -```bash -$ KEY_ID=mykeyid -$ KEY_SECRET=mykeysecret - -$ curl --user $KEY_ID:$KEY_SECRET https://api.clickhouse.cloud/v1/organizations -``` - -6. 返回到 **API 密钥** 页面,您将看到密钥名称、密钥 ID 的最后四个字符、权限、状态、过期日期和创建者。您可以从此屏幕编辑密钥名称、权限和过期时间。密钥也可以在此屏幕上被禁用或删除。 -
-:::note -删除 API 密钥是一个永久性操作。任何使用该密钥的服务将立即失去访问 ClickHouse Cloud 的权限。 -::: - - API Keys management page - -## 端点 {#endpoints} - -有关端点的详细信息,请参阅 [API reference](https://clickhouse.com/docs/cloud/manage/api/swagger)。 -使用您的 API 密钥和 API 秘密与基本 URL `https://api.clickhouse.cloud/v1`。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/openapi.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/openapi.md.hash deleted file mode 100644 index 38f906e2b88..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/openapi.md.hash +++ /dev/null @@ -1 +0,0 @@ -ce3e9dc8fd39764b diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/postman.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/postman.md.hash deleted file mode 100644 index 2d3a25ae06d..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/postman.md.hash +++ /dev/null @@ -1 +0,0 @@ -ba64d5e36ffe7fc6 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/replica-aware-routing.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/replica-aware-routing.md deleted file mode 100644 index d0f462c5d7b..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/replica-aware-routing.md +++ /dev/null @@ -1,44 +0,0 @@ ---- -'title': '副本感知路由' -'slug': '/manage/replica-aware-routing' -'description': '如何使用副本感知路由来增加缓存重用' -'keywords': -- 'cloud' -- 'sticky endpoints' -- 'sticky' -- 'endpoints' -- 'sticky routing' -- 'routing' -- 'replica aware routing' ---- - - -# 副本感知路由(私有预览) - -副本感知路由(也称为粘性会话、粘性路由或会话亲和性)利用了 [Envoy 代理的环哈希负载均衡](https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/upstream/load_balancing/load_balancers#ring-hash)。副本感知路由的主要目的是增加缓存重用的机会。它并不保证隔离。 - -当为服务启用副本感知路由时,我们允许在服务主机名的基础上使用通配符子域名。对于主机名为 `abcxyz123.us-west-2.aws.clickhouse.cloud` 的服务,您可以使用任何匹配 `*.sticky.abcxyz123.us-west-2.aws.clickhouse.cloud` 的主机名来访问该服务: - -|示例主机名| -|---| -|`aaa.sticky.abcxyz123.us-west-2.aws.clickhouse.cloud`| -|`000.sticky.abcxyz123.us-west-2.aws.clickhouse.cloud`| -|`clickhouse-is-the-best.sticky.abcxyz123.us-west-2.aws.clickhouse.cloud`| - -当 Envoy 收到与此模式匹配的主机名时,它将基于主机名计算路由哈希,并根据计算出的哈希在哈希环上找到相应的 ClickHouse 服务器。假设服务没有正在进行的更改(例如,服务器重启、扩展或缩减),Envoy 将始终选择相同的 ClickHouse 服务器进行连接。 - -请注意,原始主机名仍将使用 `LEAST_CONNECTION` 负载均衡,这是默认的路由算法。 - -## 副本感知路由的局限性 {#limitations-of-replica-aware-routing} - -### 副本感知路由不保证隔离 {#replica-aware-routing-does-not-guarantee-isolation} - -服务的任何中断,例如服务器 Pod 重启(由于版本升级、崩溃、垂直扩展等原因)、服务器扩展/缩减,都将导致路由哈希环的中断。这将导致相同主机名的连接落在不同的服务器 Pod 上。 - -### 副本感知路由与私有链接无法开箱即用 {#replica-aware-routing-does-not-work-out-of-the-box-with-private-link} - -客户需要手动添加 DNS 条目,以使新主机名模式的名称解析正常工作。如果客户错误使用,可能会导致服务器负载不平衡。 - -## 配置副本感知路由 {#configuring-replica-aware-routing} - -要启用副本感知路由,请联系 [我们的支持团队](https://clickhouse.com/support)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/replica-aware-routing.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/replica-aware-routing.md.hash deleted file mode 100644 index d5f3da22468..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/replica-aware-routing.md.hash +++ /dev/null @@ -1 +0,0 @@ -7281c75a23ca0bfe diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/scaling.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/scaling.md deleted file mode 100644 index 5132280213f..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/scaling.md +++ /dev/null @@ -1,149 +0,0 @@ ---- -'sidebar_position': 1 -'sidebar_label': '自动伸缩' -'slug': '/manage/scaling' -'description': '在 ClickHouse Cloud 中配置自动伸缩' -'keywords': -- 'autoscaling' -- 'auto scaling' -- 'scaling' -- 'horizontal' -- 'vertical' -- 'bursts' -'title': '自动伸缩' ---- - -import Image from '@theme/IdealImage'; -import auto_scaling from '@site/static/images/cloud/manage/AutoScaling.png'; -import scaling_patch_request from '@site/static/images/cloud/manage/scaling-patch-request.png'; -import scaling_patch_response from '@site/static/images/cloud/manage/scaling-patch-response.png'; -import scaling_configure from '@site/static/images/cloud/manage/scaling-configure.png'; -import scaling_memory_allocation from '@site/static/images/cloud/manage/scaling-memory-allocation.png'; -import ScalePlanFeatureBadge from '@theme/badges/ScalePlanFeatureBadge' - - -# 自动扩展 - -扩展是根据客户需求调整可用资源的能力。Scale 和 Enterprise(标准 1:4 配置)层服务可以通过编程调用 API 或在 UI 上更改设置以横向扩展系统资源。或者,这些服务可以**垂直自动扩展**以满足应用程序需求。 - - - -## ClickHouse Cloud 中的扩展工作原理 {#how-scaling-works-in-clickhouse-cloud} - -目前,ClickHouse Cloud 支持垂直自动扩展和手动横向扩展 Scale 层服务。 - -对于 Enterprise 层服务,扩展如下工作: - -- **横向扩展**:在企业层,所有标准和自定义配置都可以手动横向扩展。 -- **垂直扩展**: - - 标准配置(1:4)将支持垂直自动扩展。 - - 自定义配置在启动时将不支持垂直自动扩展或手动垂直扩展。但是,可以通过联系支持团队进行垂直扩展。 - -:::note -我们正在为计算副本引入一种新的垂直扩展机制,我们称之为“Make Before Break”(MBB)。这种方法在移除旧副本之前增加一个或多个新的副本,以防止在扩展操作期间出现任何容量损失。通过消除移除现有副本与添加新副本之间的差距,MBB 创建了一个更无缝且干扰更小的扩展过程。它在向上扩展的场景中特别有利,因为高资源利用率触发了对额外容量的需求,因为过早移除副本只会加剧资源限制。 - -请注意,作为此更改的一部分,历史系统表数据将在最多 30 天内保留,以便于扩展事件。此外,对于 AWS 或 GCP 上的服务,任何早于 2024 年 12 月 19 日的系统表数据和对于 Azure 上的服务,任何早于 2025 年 1 月 14 日的系统表数据将不会在迁移到新的组织层时保留。 -::: - -### 垂直自动扩展 {#vertical-auto-scaling} - - - -Scale 和 Enterprise 服务支持基于 CPU 和内存使用情况的自动扩展。我们持续监控服务在过去 30 小时内的历史使用情况,以做出扩展决策。如果使用量超过或低于某些阈值,我们会相应地扩展服务以匹配需求。 - -基于 CPU 的自动扩展在 CPU 使用量超过 50-75% 的上限阈值时启动(实际阈值取决于集群的大小)。此时,集群的 CPU 分配将加倍。如果 CPU 使用量降到上限阈值的一半以下(例如,在 50% 的上限阈值情况下降到 25%),CPU 分配将减半。 - -基于内存的自动扩展将集群扩展到最大内存使用量的 125%,如果出现 OOM(内存不足)错误,则扩展到 150%。 - -选择**更大**的 CPU 或内存建议,并以 `1` CPU 和 `4 GiB` 内存的步幅进行扩展。 - -### 配置垂直自动扩展 {#configuring-vertical-auto-scaling} - -具有 **Admin** 角色的组织成员可以调整 ClickHouse Cloud Scale 或 Enterprise 服务的扩展配置。要配置垂直自动扩展,请转到服务的 **设置** 选项卡,并根据下图调整最小和最大内存以及 CPU 设置。 - -:::note -单副本服务不能在所有层进行扩展。 -::: - -Scaling settings page - -将副本的 **最大内存** 设置为高于 **最小内存** 的值。服务将在这些范围内按需扩展。这些设置在初始服务创建流程中也可以使用。您服务中的每个副本将分配相同的内存和 CPU 资源。 - -您还可以选择将这些值设置为相同,基本上将服务“固定”到特定配置。这样会立即强制扩展到您选择的所需大小。 - -需要注意的是,这将禁用集群上的任何自动扩展,您的服务将不会受到超过这些设置的 CPU 或内存使用增加的保护。 - -:::note -对于 Enterprise 层服务,标准 1:4 配置将支持垂直自动扩展。 -自定义配置在启动时将不支持垂直自动扩展或手动垂直扩展。 -但是,可以通过联系支持进行垂直扩展。 -::: - -## 手动横向扩展 {#manual-horizontal-scaling} - - - -您可以使用 ClickHouse Cloud [公共 API](https://clickhouse.com/docs/cloud/manage/api/swagger#/paths/~1v1~1organizations~1:organizationId~1services~1:serviceId~1scaling/patch) 通过更新服务的扩展设置或从云控制台调整副本数量来扩展服务。 - -**Scale** 和 **Enterprise** 层确实支持单副本服务。然而,在这些层中,起始有多个副本的服务,或扩展到多个副本的服务只能缩减到至少 `2` 个副本。 - -:::note -服务可以横向扩展到最多 20 个副本。如果您需要额外的副本,请联系支持团队。 -::: - -### 通过 API 进行横向扩展 {#horizontal-scaling-via-api} - -要横向扩展集群,请通过 API 发送 `PATCH` 请求以调整副本数量。以下截图显示了将 `3` 个副本的集群扩展到 `6` 个副本的 API 调用及其对应的响应。 - -Scaling PATCH request - -*`PATCH` 请求以更新 `numReplicas`* - -Scaling PATCH response - -*`PATCH` 请求的响应* - -如果您在一个请求正在进行时发出新的扩展请求或连续发出多个请求,扩展服务将忽略中间状态,并收敛到最终的副本计数。 - -### 通过 UI 进行横向扩展 {#horizontal-scaling-via-ui} - -要通过 UI 横向扩展服务,可以在 **设置** 页面上调整服务的副本数量。 - -Scaling configuration settings - -*来自 ClickHouse Cloud 控制台的服务扩展设置* - -服务扩展后,云控制台中的指标仪表板应显示服务的正确分配情况。下图显示集群扩展到总内存为 `96 GiB`,这是 `6` 个副本,每个副本的内存分配为 `16 GiB`。 - -Scaling memory allocation - -## 自动闲置 {#automatic-idling} -在 **设置** 页面上,您还可以选择在服务处于非活动状态时是否允许自动闲置,如上图所示(即当服务没有执行任何用户提交的查询时)。自动闲置减少了服务的成本,因为在服务暂停时您不会为计算资源付费。 - -:::note -在某些特殊情况下,例如当服务具有大量部分时,服务将无法自动闲置。 - -服务可能会进入一种闲置状态,此时暂停对 [可刷新物化视图](/materialized-view/refreshable-materialized-view) 的刷新,消耗 [S3Queue](/engines/table-engines/integrations/s3queue) 的数据,以及调度新的合并。现有的合并操作将在服务转换到闲置状态之前完成。为了确保可刷新物化视图和 S3Queue 消耗的连续操作,请禁用闲置状态功能。 -::: - -:::danger 何时不使用自动闲置 -仅在您的用例能够在响应查询前处理延迟的情况下使用自动闲置,因为当服务暂停时,连接到服务的请求将超时。自动闲置非常适合不频繁使用的服务,并且可以容忍延迟。对于经常使用并驱动面向客户的功能的服务,不推荐使用。 -::: - -## 处理突发工作负载 {#handling-bursty-workloads} -如果您预期即将发生工作负载高峰,您可以使用 [ClickHouse Cloud API](/cloud/manage/api/api-overview) 预先扩展服务以应对高峰,并在需求减退后缩减服务。 - -要了解每个副本当前的 CPU 核心和内存使用情况,您可以运行以下查询: - -```sql -SELECT * -FROM clusterAllReplicas('default', view( - SELECT - hostname() AS server, - anyIf(value, metric = 'CGroupMaxCPU') AS cpu_cores, - formatReadableSize(anyIf(value, metric = 'CGroupMemoryTotal')) AS memory - FROM system.asynchronous_metrics -)) -ORDER BY server ASC -SETTINGS skip_unavailable_shards = 1 -``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/scaling.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/scaling.md.hash deleted file mode 100644 index a1d85821baa..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/scaling.md.hash +++ /dev/null @@ -1 +0,0 @@ -eba9287973ae49fc diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/service-uptime.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/service-uptime.md deleted file mode 100644 index a087d61f3fa..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/service-uptime.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -'sidebar_label': '服务正常运行时间和服务级别协议(SLA)' -'slug': '/cloud/manage/service-uptime' -'title': '服务正常运行时间' -'description': '用户现在可以在状态页面上查看区域正常运行时间并订阅服务中断的警报。' ---- - -## Uptime Alerts {#uptime-alerts} - -用户现在可以在 [状态页面](https://status.clickhouse.com/) 查看区域运行时间,并订阅服务中断的警报。 - -## SLA {#sla} - -我们还为部分承诺消费合同提供服务水平协议(SLA)。请通过 [sales@clickhouse.com](mailto:sales@clickhouse.com) 联系我们以了解更多关于我们SLA政策的信息。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/service-uptime.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/service-uptime.md.hash deleted file mode 100644 index a541b95f316..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/service-uptime.md.hash +++ /dev/null @@ -1 +0,0 @@ -df9f75d445319ad4 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/settings.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/settings.md.hash deleted file mode 100644 index 4228941c7ef..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/settings.md.hash +++ /dev/null @@ -1 +0,0 @@ -62696f3f9aa6bcf4 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/troubleshooting-billing-issues.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/troubleshooting-billing-issues.md deleted file mode 100644 index 61cecdb68af..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/troubleshooting-billing-issues.md +++ /dev/null @@ -1,21 +0,0 @@ ---- -'sidebar_label': '故障排除账单问题' -'slug': '/manage/troubleshooting-billing-issues' -'title': '故障排除账单问题' -'description': '用于常见账单问题的故障排除文章' ---- - -import Image from '@theme/IdealImage'; - -# 故障排除账单问题 - -## 修复无效的支付信息 {#fixing-non-working-payment-details} - -使用 ClickHouse Cloud 需要一张有效的信用卡。在试用期结束后的 30 天内或在您最后一次成功付款后,您的服务将继续运行。然而,如果我们无法收费有效的信用卡,您的组织的云控制台功能将受到限制。 - -**如果在试用期结束后的 30 天内或您最后一次成功付款后未添加有效的信用卡,您的数据将被删除。** - -如果您在支付信息方面遇到问题或无法添加信用卡,请联系 [我们的支持团队](https://clickhouse.com/support/program)。 - -
- diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/troubleshooting-billing-issues.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/troubleshooting-billing-issues.md.hash deleted file mode 100644 index ab1077a2104..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/troubleshooting-billing-issues.md.hash +++ /dev/null @@ -1 +0,0 @@ -ffff537954b3cd1d diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/upgrades.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/upgrades.md deleted file mode 100644 index b33bf91c571..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/upgrades.md +++ /dev/null @@ -1,101 +0,0 @@ ---- -'sidebar_label': '升级' -'slug': '/manage/updates' -'title': '升级' -'description': '使用 ClickHouse Cloud,您无需担心补丁和升级。我们会定期推出包含修复、新功能和性能改进的升级。' ---- - -import Image from '@theme/IdealImage'; -import EnterprisePlanFeatureBadge from '@theme/badges/EnterprisePlanFeatureBadge' -import ScalePlanFeatureBadge from '@theme/badges/ScalePlanFeatureBadge' -import fast_release from '@site/static/images/cloud/manage/fast_release.png'; -import enroll_fast_release from '@site/static/images/cloud/manage/enroll_fast_release.png'; -import scheduled_upgrades from '@site/static/images/cloud/manage/scheduled_upgrades.png'; -import scheduled_upgrade_window from '@site/static/images/cloud/manage/scheduled_upgrade_window.png'; - - -# 升级 - -使用 ClickHouse Cloud,您无需担心修补和升级。我们会定期推出包含修复、新功能和性能改进的升级。有关 ClickHouse 的完整新特性列表,请参阅我们的 [Cloud changelog](/cloud/reference/changelog.md)。 - -:::note -我们正在引入一种新的升级机制,一个我们称之为“先升级后替换”(或 MBB)的概念。在此新方法中,我们在移除旧副本之前,会添加更新后的副本。这会导致更平滑的升级,并减少对正在运行的工作负载的干扰。 - -作为这一变化的一部分,历史系统表数据将在升级事件中保留最多 30 天。此外,任何 2024 年 12 月 19 日之前的系统表数据(对于 AWS 或 GCP 上的服务),以及任何 2025 年 1 月 14 日之前的系统表数据(对于 Azure 上的服务)将不会在迁移到新组织层时保留。 -::: - -## 版本兼容性 {#version-compatibility} - -创建服务时,[`compatibility`](/operations/settings/settings#compatibility) 设置会被设置为您的服务首次配置时 ClickHouse Cloud 提供的最新 ClickHouse 版本。 - -`compatibility` 设置允许您使用先前版本的设置默认值。当您的服务升级到新版本时,`compatibility` 设置中指定的版本不会改变。这意味着您首次创建服务时存在的设置默认值不会改变(除非您已经覆盖了这些默认值,在这种情况下,它们将在升级后保留)。 - -您无法管理服务的 `compatibility` 设置。如果您希望更改 `compatibility` 设置中的版本,必须 [联系支持](https://clickhouse.com/support/program)。 - -## 维护模式 {#maintenance-mode} - -有时,我们需要更新您的服务,这可能需要禁用某些功能,例如扩展或闲置。在少数情况下,我们可能需要对遇到问题的服务采取措施,使其恢复到健康状态。在此类维护期间,您将在服务页面上看到一条消息 _“维护进行中”_。在此期间,您仍然可以使用该服务进行查询。 - -在服务处于维护状态时,您将不会被收取费用。_维护模式_ 是一种罕见的情况,不应与常规服务升级混淆。 - -## 发布渠道(升级计划) {#release-channels-upgrade-schedule} - -您可以通过订阅特定的发布渠道来指定 ClickHouse Cloud 服务的升级计划。 - -### 快速发布渠道(提前升级) {#fast-release-channel-early-upgrades} - - - -除了常规升级计划外,如果您希望您的服务比常规发布计划更早接收更新,我们还提供 **快速发布** 渠道。 - -具体而言,服务将会: - -- 接收最新的 ClickHouse 版本 -- 在测试新版本时更频繁地进行升级 - -您可以如下面所示在云控制台中修改服务的发布计划: - -
- 选择计划 -
-
- -
- 选择计划 -
-
- -此 **快速发布** 渠道适合在非关键环境中测试新功能。**不推荐在具有严格正常运行时间和可靠性要求的生产工作负载中使用。** - -### 常规发布渠道 {#regular-release-channel} - -对于所有没有配置发布渠道或升级计划的 Scale 和 Enterprise 级别服务,升级将作为常规渠道发布的一部分进行。这在生产环境中是推荐的做法。 - -常规发布渠道的升级通常在 **快速发布渠道** 之后的两周内进行。 - -:::note -基本层的服务在快速发布渠道之后不久也会进行升级。 -::: - -## 计划升级 {#scheduled-upgrades} - - - -用户可以为 Enterprise 级别服务配置升级窗口。 - -选择您希望指定升级计划的服务,然后在左侧菜单中选择 `Settings`。滚动到 `Scheduled upgrades`。 - -
- 计划升级 -
-
- -选择此选项将允许用户选择数据库和云升级的星期几/时间窗口。 - -
- 计划升级窗口 -
-
-:::note -虽然计划的升级遵循定义的时间表,但对于关键安全补丁和漏洞修复的例外情况适用。如果发现紧急安全问题,升级可能会在计划窗口之外进行。客户将根据需要被通知这些例外情况。 -::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/upgrades.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/upgrades.md.hash deleted file mode 100644 index 43b560d2dca..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/upgrades.md.hash +++ /dev/null @@ -1 +0,0 @@ -67cae2c42246e669 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/01_discover/01_what_is.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/01_discover/01_what_is.md new file mode 100644 index 00000000000..11268f4ab22 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/01_discover/01_what_is.md @@ -0,0 +1,48 @@ +--- +'slug': '/cloud/overview' +'title': '介绍' +'description': '了解 ClickHouse Cloud 是什么,它相对于开源的优势,以及这个完全自管理分析平台的关键功能' +'keywords': +- 'clickhouse cloud' +- 'what is clickhouse cloud' +- 'clickhouse cloud overview' +- 'clickhouse cloud features' +'hide_title': true +'doc_type': 'guide' +--- + +## What is ClickHouse Cloud? {#what-is-clickhouse-cloud} + +ClickHouse Cloud 是一个由 ClickHouse 的原始创建者创建的完全托管的云服务,ClickHouse 是最快速和最受欢迎的开源列式在线分析处理数据库。 + +有了 Cloud,基础设施、维护、扩展和运营都由我们为您处理,因此您可以专注于最重要的事情,即更快地为您的组织和客户创造价值。 + +## Benefits of ClickHouse Cloud {#benefits-of-clickhouse-cloud} + +ClickHouse Cloud 提供了相较于开源版本的几个主要优势: + +- **快速创造价值**:立即开始构建,无需为您的集群进行调整和扩展。 +- **无缝扩展**:自动扩展适应可变负载,因此您无需过度配置以应对峰值使用。 +- **无服务器操作**:放轻松,让我们为您处理尺寸、扩展、安全、可靠性和升级。 +- **透明定价**:仅为您使用的内容付费,附带资源预留和扩展控制。 +- **总拥有成本**:最佳的价格/性能比和低行政开销。 +- **广泛的生态系统**:带上您最喜欢的数据连接器、可视化工具、SQL 和语言客户端。 + +## OSS vs ClickHouse Cloud comparison {#oss-vs-clickhouse-cloud} + +| Feature | Benefits | OSS ClickHouse | ClickHouse Cloud | +|--------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------|-------------------| +| **Deployment modes** | ClickHouse 提供了灵活性,可以选择自我管理的开源版本或在云中部署。使用 ClickHouse local 为本地文件提供服务,而 chDB 可以将 ClickHouse 直接嵌入到您的应用程序中。 | ✅ | ✅ | +| **Storage** | 作为一个开源和云托管的产品,ClickHouse 可以在共享磁盘和无共享架构中部署。 | ✅ | ✅ | +| **Monitoring and alerting** | 监控和警报您服务的状态对于确保最佳性能和主动检测潜在问题至关重要。 | ✅ | ✅ | +| **ClickPipes** | ClickPipes 是 ClickHouse 的托管摄取管道,允许您无缝连接外部数据源,如数据库、API 和流媒体服务到 ClickHouse Cloud,消除了管理管道、自定义作业或 ETL 过程的需求。它支持各种规模的工作负载。 | ❌ | ✅ | +| **Pre-built integrations** | ClickHouse 提供了预构建的集成,将 ClickHouse 连接到流行工具和服务,例如数据湖、SQL 和语言客户端、可视化库等。 | ❌ | ✅ | +| **SQL console** | SQL 控制台提供了一种快速、直观的方式来连接、探索和查询 ClickHouse 数据库,具有流畅的标题、查询界面、数据导入工具、可视化、协作功能以及 GenAI 驱动的 SQL 支持。 | ❌ | ✅ | +| **Compliance** | ClickHouse Cloud 合规性包括 CCPA、EU-US DPF、GDPR、HIPAA、ISO 27001、ISO 27001 SoA、PCI DSS 和 SOC2。ClickHouse Cloud 的安全性、可用性、处理完整性和保密性流程均经过独立审计。详情请访问: trust.clickhouse.com。 | ❌ | ✅ | +| **Enterprise-grade security** | 支持高级安全功能,如单点登录 (SSO)、多因素身份验证、基于角色的访问控制 (RBAC)、支持 Private Link 和 Private Service Connect 的私有和安全连接、IP 过滤、客户管理的加密密钥 (CMEK) 等。 | ❌ | ✅ | +| **Scaling and optimization** | 根据工作负载无缝扩展或收缩,支持水平和垂直扩展。凭借自动备份、复制和高可用性,ClickHouse 提供给用户最佳的资源分配。 | ❌ | ✅ | +| **Support services** | 我们一流的支持服务和开源社区资源为您选择的任何部署模式提供支持。 | ❌ | ✅ | +| **Database upgrades** | 定期的数据库升级对于建立强大的安全态势和访问最新功能及性能改进至关重要。 | ❌ | ✅ | +| **Backups** | 备份和恢复功能确保数据的持久性,并支持在发生停机或其他中断时的优雅恢复。 | ❌ | ✅ | +| **Compute-compute separation** | 用户可以独立扩展计算资源,因此团队和工作负载可以共享相同的存储,并保持专用的计算资源。这确保了一个工作负载的性能不会干扰另一个,提高了灵活性、性能和成本效率。 | ❌ | ✅ | +| **Managed services** | 通过云托管服务,团队可以专注于业务成果,加快上市时间,而无需担心 ClickHouse 的尺寸、设置和维护的操作开销。 | ❌ | ✅ | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/01_discover/01_what_is.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/01_discover/01_what_is.md.hash new file mode 100644 index 00000000000..eeb5e2a146f --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/01_discover/01_what_is.md.hash @@ -0,0 +1 @@ +a795b6c26b82a94a diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/01_discover/02_use_cases/00_overview.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/01_discover/02_use_cases/00_overview.md new file mode 100644 index 00000000000..5af36fab0da --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/01_discover/02_use_cases/00_overview.md @@ -0,0 +1,21 @@ +--- +'slug': '/cloud/get-started/cloud/use-cases/overview' +'title': '在 ClickHouse Cloud 上构建' +'description': '探索 ClickHouse Cloud 的使用案例,包括实时分析、可观察性、数据湖与仓库,以及机器学习应用' +'keywords': +- 'use cases' +- 'Cloud' +'sidebar_label': '概述' +'doc_type': 'landing-page' +--- + +ClickHouse Cloud 适合用作 **主数据存储** 和 **分析层**。 + +ClickHouse 的列式架构、向量化处理和云原生设计使其特别适合需要速度和规模的分析工作负载。广泛而言,ClickHouse Cloud 最常见的用例包括: + +| 用例 | 描述 | +|------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| [实时分析](/cloud/get-started/cloud/use-cases/real-time-analytics) | ClickHouse Cloud 在实时分析方面表现卓越,通过其列式存储架构和向量化执行引擎,能够在数十亿行数据上提供亚秒级查询响应。该平台处理数百万事件每秒的高吞吐量数据摄取,同时允许对原始数据进行直接查询,无需预聚合。物化视图提供实时聚合和预计算结果,而用于分位数和计数的近似函数则提供即时洞察,非常适合交互式仪表板和实时决策。 | +| [可观察性](/cloud/get-started/cloud/use-cases/observability) | ClickHouse Cloud 非常适合可观察性工作负载,具备针对时间序列数据优化的专用引擎和功能,能够轻松摄取和查询 TB 级别的日志、指标和追踪数据。通过 ClickStack,ClickHouse 的综合可观察性解决方案,组织可以通过在单个平台中统一所有可观察性数据来打破传统的日志、指标和追踪三大孤岛,实现关联分析,消除管理独立系统的复杂性。这种统一的方法使其非常适合企业级应用性能监控、基础设施监控和安全事件分析,ClickStack 提供了完整可观察性工作流所需的工具和集成,而无需数据孤岛。 | +| [数据仓库](/cloud/get-started/cloud/use-cases/data_lake_and_warehouse) | ClickHouse 的数据仓库生态连接性允许用户只需几次点击即可设置,并轻松将数据导入 ClickHouse。凭借对历史数据分析、数据湖、查询联合和 JSON 作为原生数据类型的卓越支持,它使用户能够以成本效益高的方式规模化存储数据。 | +| [机器学习和人工智能](/cloud/get-started/cloud/use-cases/AI_ML) | ClickHouse Cloud 可以用于 ML 价值链的各个环节,从探索、准备到训练、测试和推理。工具如 Clickhouse-local、Clickhouse-server 和 chdb 可用于数据探索、发现和转换,而 ClickHouse 可用作特征存储、向量存储或 MLOps 可观察性存储。此外,它通过内置工具启用代理分析,如完全托管的远程 MCP 服务器、查询的内联文本补全、AI 驱动的图表配置以及产品中的 Ask AI。 | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/01_discover/02_use_cases/00_overview.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/01_discover/02_use_cases/00_overview.md.hash new file mode 100644 index 00000000000..5c2ef3fe4b5 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/01_discover/02_use_cases/00_overview.md.hash @@ -0,0 +1 @@ +9787e3f67000a150 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/01_discover/02_use_cases/01_real-time-analytics.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/01_discover/02_use_cases/01_real-time-analytics.md new file mode 100644 index 00000000000..5b541121cfe --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/01_discover/02_use_cases/01_real-time-analytics.md @@ -0,0 +1,106 @@ +--- +'slug': '/cloud/get-started/cloud/use-cases/real-time-analytics' +'title': '实时分析' +'description': '学习如何使用 ClickHouse Cloud 构建实时分析应用程序,以获得即时洞察和数据驱动的决策' +'keywords': +- 'use cases' +- 'real-time analytics' +'sidebar_label': '实时分析' +'doc_type': 'guide' +--- + +import Image from '@theme/IdealImage'; +import rta_0 from '@site/static/images/cloud/onboard/discover/use_cases/0_rta.png'; +import rta_1 from '@site/static/images/cloud/onboard/discover/use_cases/1_rta.png'; +import rta_2 from '@site/static/images/cloud/onboard/discover/use_cases/2_rta.png'; +import rta_3 from '@site/static/images/cloud/onboard/discover/use_cases/3_rta.png'; + + + +## 什么是实时分析? {#what-is-real-time-analytics} + +实时分析指的是数据处理,它在数据生成后立刻向最终用户和客户提供洞察。它与传统或批处理分析不同,后者将数据以批次的方式收集并处理,通常在数据生成后很长一段时间才进行处理。 + +实时分析系统建立在事件流之上,该事件流由一系列按时间顺序排列的事件组成。事件是已经发生的事情。它可以是电子商务网站上将项目添加到购物车的动作,来自物联网 (IoT) 传感器的读数输出,或者足球比赛中的进球。 + +下面是来自一个虚构的物联网传感器的事件示例: + +```json +{ + "deviceId": "sensor-001", + "timestamp": "2023-10-05T14:30:00Z", + "eventType": "temperatureAlert", + "data": { + "temperature": 28.5, + "unit": "Celsius", + "thresholdExceeded": true + } +} +``` + +组织可以通过聚合和分析这样的事件来发现关于客户的洞察。这在传统上是通过批处理分析完成的,接下来的部分我们将比较批处理分析和实时分析。 + +## 实时分析与批处理分析 {#real-time-analytics-vs-batch-analytics} + +下面的图表展示了从单个事件的角度来看,典型的批处理分析系统的样子: + +批处理分析图 + +可以看到,从事件发生到我们处理并获得一些洞察之间有很大的间隔。传统上,这是唯一的数据分析方式,我们需要创建人工时间边界以批量处理数据。例如,我们可能在一天结束时处理所有收集到的数据。这对于许多用例有效,但对于其他一些用例来说,这种方式并不理想,因为我们在处理陈旧的数据,并且这无法让我们对数据做出足够迅速的反应。 + +相比之下,在实时分析系统中,我们会在事件发生后立即做出反应,如下图所示: + +实时分析图 + +现在,我们几乎可以在事件生成后立即派生出洞察。但这为什么有用呢? + +## 实时分析的好处 {#benefits-of-real-time-analytics} + +在今天这个快速变化的世界中,组织依赖实时分析来保持敏捷,并对不断变化的环境做出响应。一个实时分析系统可以在许多方面为企业带来好处。 + +### 更好的决策 {#better-decision-making} + +通过实时分析获得可操作的洞察,可以改善决策过程。当业务运营者能够看到正在发生的事件时,更容易做出及时干预。 + +例如,如果我们对应用程序进行更改并希望知道这些更改是否对用户体验产生了负面影响,我们希望尽快知道这一点,以便在必要时撤回更改。如果采用不够实时的方法,我们可能需要等到第二天才能进行分析,这样的话就会有很多不满的用户。 + +### 新产品和收入来源 {#new-products-and-revenue-streams} + +实时分析可以帮助企业生成新的收入来源。组织可以开发新的以数据为中心的产品和服务,使用户能够获得分析查询功能。这些产品往往足够吸引用户支付使用费用。 + +此外,现有应用程序可以变得更具粘性,提高用户参与度和留存率。这将导致更多的应用使用,从而为组织创造更多的收入。 + +### 改善客户体验 {#improved-customer-experience} + +借助实时分析,企业可以获得关于客户行为、偏好和需求的即时洞察。这使企业能提供及时的帮助,个性化互动,并创造更具吸引力的体验,让客户不断回访。 + +## 实时分析的用例 {#real-time-analytics-use-cases} + +实时分析的实际价值在于我们考虑其实际应用时会变得明显。我们来看一些用例。 + +### 欺诈检测 {#fraud-detection} + +欺诈检测是指识别欺诈模式,从虚假账户到支付欺诈。我们希望尽快发现这种欺诈,标记可疑活动,阻止交易并在必要时禁用账户。 + +这个用例跨越多个行业:医疗保健、数字银行、金融服务、零售等。 + +[Instacart](https://www.instacart.com/) 是北美领先的在线杂货公司,拥有数百万的活跃客户和购物者。它使用 ClickHouse 作为其欺诈检测平台 Yoda 的一部分。除了上述描述的欺诈一般类型外,它还试图检测客户与购物者之间的勾结。 + +实时分析的欺诈检测 + +他们识别出 ClickHouse 的以下特性使其能够实现实时欺诈检测: + +> ClickHouse 支持基于 LSM 树的 MergeTree 家族引擎。 +> 这些引擎经过优化,适合实时摄取大量数据,适合大量写入操作。 + +> ClickHouse专门为分析查询设计并优化。这完美契合了应用程序的需求,即持续分析数据以寻找可能表明欺诈的模式。 + +### 对时间敏感的决策 {#ftime-sensitive-decision-making} + +对时间敏感的决策是指用户或组织需要快速做出知情选择的情况,基于可用的最新信息。实时分析使用户能够在动态环境中做出明智的选择,无论他们是对市场波动作出反应的交易员,还是做出购买决定的消费者,亦或是适应实时操作变化的专业人士。 + +Coinhall 通过蜡烛图提供实时的价格变动洞察,显示每个交易周期的开盘价、最高价、最低价和收盘价。他们需要能够快速运行这些类型的查询,并支持大量并发用户。 + +实时分析的时间敏感决策 + +> 在性能方面,ClickHouse 是明显的赢家,以 20 毫秒执行蜡烛图查询,而其他数据库需要 400 毫秒或更多。其最新价格查询在 8 毫秒内完成,超越了下一个最佳性能 (SingleStore) 的 45 毫秒。最后,它在 50 毫秒内处理 ASOF JOIN 查询,而 Snowflake 则需要 20 分钟,Rockset 超时。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/01_discover/02_use_cases/01_real-time-analytics.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/01_discover/02_use_cases/01_real-time-analytics.md.hash new file mode 100644 index 00000000000..1e01afd3e47 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/01_discover/02_use_cases/01_real-time-analytics.md.hash @@ -0,0 +1 @@ +d86d2ee05c33e1b2 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/01_discover/02_use_cases/02_observability.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/01_discover/02_use_cases/02_observability.md new file mode 100644 index 00000000000..ecf68e268ae --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/01_discover/02_use_cases/02_observability.md @@ -0,0 +1,135 @@ +--- +'slug': '/cloud/get-started/cloud/use-cases/observability' +'title': '可观察性' +'description': '使用 ClickHouse Cloud 进行可观察性、监控、日志记录和在分布式应用中的系统性能分析' +'keywords': +- 'use cases' +- 'observability' +'sidebar_label': '可观察性' +'doc_type': 'guide' +--- + + + +现代软件系统非常复杂。微服务、云基础设施和分布式系统使得理解我们的应用程序内部发生了什么变得越来越困难。当出现问题时,团队需要快速知道问题在哪里,以及为什么会发生。 + +这就是可观察性发挥作用的地方。它已经从简单的系统监控演变为全面了解系统行为的方法。然而,实施有效的可观察性并不是简单的任务——这需要理解技术概念和组织挑战。 + +## 什么是可观察性? {#what-is-observability} + +可观察性是通过检查系统的输出,了解其内部状态。在软件系统中,这意味着通过系统生成的数据,理解您的应用程序和基础设施内部发生了什么。 + +这一领域已经发生了显著变化,可以通过两代不同的可观察性方法来理解。 + +第一代,通常称为可观察性 1.0,是围绕传统的“三个支柱”方法(指标、日志和追踪)构建的。这种方法需要多个工具和数据存储来处理不同类型的遥测数据。它往往迫使工程师预先定义他们想要测量的内容,使得维护多个系统的成本高昂且复杂。 + +现代可观察性或可观察性 2.0,采取了根本不同的方法。它基于为我们系统中的每个工作单元(例如,HTTP 请求和响应)收集广泛的结构化事件。这种方法捕获高基数数据,例如用户 ID、请求 ID、Git 提交哈希、实例 ID、Kubernetes pod 名称、特定路由参数和供应商交易 ID。一个经验法则是,如果它可以帮助我们理解系统的行为,就添加一段元数据。 + +这种丰富的数据收集使得动态切分和处理数据成为可能,而无需预先定义指标。团队可以从基础数据中导出指标、追踪和其他可视化,使得他们能够回答关于系统行为的复杂问题,这些问题在首次添加仪表化时并未预见。 + +然而,实现现代可观察性功能存在挑战。组织需要可靠的方法来收集、处理和导出这种丰富的遥测数据,跨越不同的系统和技术。虽然现代方法已经超越了传统的界限,但理解可观察性的基本构建块仍然至关重要。 + +## 可观察性的三个支柱 {#three-pillars-of-observability} + +为了更好地理解可观察性如何演变及其在实践中的工作方式,让我们探讨可观察性的三个支柱——日志、指标和追踪。 + +虽然现代可观察性已不再将这些视作独立的关注点,但它们仍然是理解系统行为不同方面的基本概念。 + +1. **日志** - 系统内发生的离散事件的基于文本的记录。这些提供了关于特定事件、错误和状态变化的详细上下文。 +2. **指标** - 随时间收集的数值测量。这些包括计数器、仪表和直方图,帮助跟踪系统性能、资源使用和业务 KPI。 +3. **追踪** - 跟踪请求在分布式系统中流动旅程的记录。这些有助于理解服务之间的关系并识别性能瓶颈。 + +这些支柱使团队能够监控、排除故障和优化他们的系统。然而,真正的力量来自于理解如何有效地收集、分析和关联三者之间的数据,以获得有意义的关于系统行为的见解。 + +## 可观察性的好处 {#the-benefits-of-observability} + +虽然可观察性的技术方面——日志、指标和追踪——已得到很好的理解,但考虑到业务好处同样重要。 + +在他们的书籍 ["Observability Engineering"](https://clickhouse.com/engineering-resources/observability#:~:text=Observability%20Engineering) (O'Reilly, 2022)中,Charity Majors、Liz Fong-Jones 和 George Miranda 结合行业研究和案例反馈,识别出组织可以期望从实施适当的可观察性实践中获得的四个关键业务好处。让我们一一探讨这些好处: + +### 更高的增量收入 {#higher-incremental-revenue} + +作者指出,帮助团队提高正常运行时间和性能的可观察性工具,可以通过改善代码质量来实现增量收入的增加。这体现在几个方面: + +1. 改善客户体验:快速的问题解决和防止服务降级,导致更高的客户满意度和保留率。 +2. 增加系统可靠性:更好的正常运行时间意味着更多成功的交易和更少的商业机会损失。 +3. 提高性能:识别和优化性能瓶颈的能力有助于维持响应迅速的服务,保持客户的参与度。 +4. 竞争优势:能够通过全面监控和快速解决问题来维持高服务质量的组织往往会在竞争中获得优势。 + +### 加快事件响应带来的成本节省 {#cost-savings-from-faster-incident-response} + +可观察性最直接的好处之一是通过更快检测和解决问题来降低劳动力成本。这体现在: + +* 减少平均检测时间 (MTTD) 和平均解决时间 (MTTR) +* 改善查询响应时间,允许更快的调查 +* 更快识别性能瓶颈 +* 减少值班时间 +* 减少因不必要的回滚而浪费的资源 + +我们在实践中看到了这一点——[trip.com 用 ClickHouse 建立了他们的可观察性系统](trip.com built their observability system with ClickHouse),实现了比他们之前的解决方案快 4-30 倍的查询速度,90% 的查询在 300 毫秒以内完成,从而实现了快速问题调查。 + +### 避免事件导致的成本节省 {#cost-savings-from-incidents-avoided} + +可观察性不仅帮助更快解决问题——它还帮助完全防止这些问题。作者强调,团队可以通过以下方式防止关键问题: + +* 在潜在问题变得关键之前识别它们 +* 分析模式以防止重复问题 +* 理解不同条件下的系统行为 +* 主动解决性能瓶颈 +* 基于数据做出关于系统改进的决策 + +ClickHouse 的[自有可观察性平台 LogHouse](https://clickhouse.com/blog/building-a-logging-platform-with-clickhouse-and-saving-millions-over-datadog) 证实了这一点。它使我们的核心工程师能够搜索所有集群的历史模式,帮助防止重复问题。 + +### 降低员工流失导致的成本节省 {#cost-savings-from-decreased-employee-churn} + +最被忽视的好处之一是对团队满意度和留任率的影响。作者指出,可观察性会导致: + +* 通过更好的工具改善工作满意度 +* 由于较少未解决的问题而减少开发人员的倦怠 +* 通过更好的信号与噪声比降低告警疲劳 +* 由于更好的事件管理降低值班压力 +* 团队对系统可靠性更有信心 + +我们在实践中看到了这一点——当[Fastly 迁移到 ClickHouse](https://clickhouse.com/videos/scaling-graphite-with-clickhouse)时,他们的工程师惊讶于查询性能的提升,指出: + +> “我简直不敢相信。我实际上不得不回头几次,只是为了确保我正确地查询... 这是回来得太快了。 这没道理。” + +正如作者所强调的,虽然这些好处的具体衡量标准可能因工具和实施而异,但可以期待这些基本改进会出现在采用强大可观察性实践的组织中。关键是有效选择和实施合适的工具,以最大化这些好处。 + +实现这些好处需要克服几个重大障碍。即使是了解可观察性价值的组织,往往也会发现实施带来了意想不到的复杂性和挑战,必须小心应对。 + +## 实施可观察性的挑战 {#challenges-in-implementing-observability} + +在组织中实施可观察性是迈向深入了解系统性能和可靠性的变革性步骤。然而,这一旅程并非没有挑战。随着组织努力发挥可观察性的全部潜力,他们会遇到各种障碍,这些障碍可能阻碍进展。让我们逐一看一下这些障碍。 + +### 数据量和可扩展性 {#data-volume-and-scalability} + +实施可观察性的主要障碍之一是管理现代系统生成的庞大遥测数据的体量和可扩展性。随着组织的发展,他们需要监控的数据也在增加,这就需要能够高效处理大规模数据摄取和实时分析的解决方案。 + +### 与现有系统集成 {#integration-with-existing-systems} + +与现有系统的集成是另一个重要的挑战。许多组织在异构环境中运营,拥有多样化的技术,这使得可观察性工具必须能够无缝集成到当前基础设施中。开放标准在促进这种集成方面至关重要,确保互操作性并降低在不同技术栈之间部署可观察性解决方案的复杂性。 + +### 技能差距 {#skill-gaps} + +技能差距也可能阻碍可观察性的成功实施。向先进的可观察解决方案转型通常需要对数据分析和特定工具的专业知识。团队可能需要投资于培训或招聘以弥补这些差距,充分利用他们的可观察性平台的能力。 + +### 成本管理 {#cost-management} + +成本管理至关重要,因为可观察性解决方案可能会变得昂贵,尤其是在规模较大的情况下。组织必须在这些工具的成本和它们提供的价值之间取得平衡,寻找相较于传统方法具有显著节省的成本效益解决方案。 + +### 数据保留和存储 {#data-retention-and-storage} + +数据保留和存储管理带来了额外的挑战。决定保留可观察性数据多长时间而不影响性能或洞察力需要仔细规划和高效的存储解决方案,这些解决方案能够在减少存储要求的同时保持数据的可访问性。 + +### 标准化和供应商锁定 {#standardization-and-vendor-lock-in} + +确保标准化并避免供应商锁定对于在可观察性解决方案中保持灵活性和适应性至关重要。通过遵循开放标准,组织可以防止被特定供应商束缚,并确保他们的可观察性堆栈能够随其需求而发展。 + +### 安全性和合规性 {#security-and-compliance} + +安全性和合规性考虑在处理可观察性系统中的敏感数据时仍然至关重要。组织必须确保其可观察性解决方案符合相关法规,并有效保护敏感信息。 + +这些挑战强调了在实施可观察性解决方案时,进行战略规划和明智决策的重要性,以有效满足组织需求。 + +为了解决这些挑战,组织需要制定一个结构良好的方法来实施可观察性。标准的可观察性管道已经发展成提供有效收集、处理和分析遥测数据的框架。这一演变的一些最早和最具影响力的例子来自 Twitter 在 2013 年的经验。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/01_discover/02_use_cases/02_observability.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/01_discover/02_use_cases/02_observability.md.hash new file mode 100644 index 00000000000..0a2e90d8731 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/01_discover/02_use_cases/02_observability.md.hash @@ -0,0 +1 @@ +0545e7c42e499bab diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/01_discover/02_use_cases/03_data_warehousing.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/01_discover/02_use_cases/03_data_warehousing.md new file mode 100644 index 00000000000..1f9d287e0ce --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/01_discover/02_use_cases/03_data_warehousing.md @@ -0,0 +1,78 @@ +--- +'slug': '/cloud/get-started/cloud/use-cases/data_lake_and_warehouse' +'title': '数据湖房' +'description': '使用 ClickHouse Cloud 建立现代数据仓库架构,结合数据湖的灵活性和数据库性能' +'keywords': +- 'use cases' +- 'data lake and warehouse' +'sidebar_label': '数据仓库' +'doc_type': 'guide' +--- + +import Image from '@theme/IdealImage'; +import datalakehouse_01 from '@site/static/images/cloud/onboard/discover/use_cases/datalakehouse_01.png'; + + + +数据湖屋是一种融合架构,将数据库原理应用于数据湖基础设施,同时保持云存储系统的灵活性和规模。 + +湖屋不仅是拆解数据库,而是将类似数据库的功能构建在一个根本不同的基础之上(云对象存储),专注于在统一平台上支持传统分析和现代AI/ML工作负载。 + +## 数据湖屋的组成部分是什么? {#components-of-the-data-lakehouse} + +现代数据湖屋架构代表了数据仓库与数据湖技术的融合,结合了两种方法的最佳方面。这种架构包含多个不同但相互关联的层,提供一个灵活、稳健的数据存储、管理和分析平台。 + +理解这些组件对于希望实施或优化其数据湖屋策略的组织至关重要。这种分层方法允许组件替换和各层独立演变,提供了架构灵活性和未来证明能力。 + +让我们探索典型数据湖屋架构的核心构建块,以及它们如何相互作用以创建一个统一的数据管理平台。 + +数据湖屋的组成部分 + +| 组件 | 描述 | +|---------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| **数据源** | 湖屋数据源包括操作数据库、流媒体平台、物联网设备、应用程序日志和外部提供商。 | +| **查询引擎** | 处理存储在对象存储中的分析查询,利用表格式层提供的元数据和优化。支持 SQL 以及其他查询语言,以有效地分析大量数据。 | +| **元数据目录** | [数据目录](https://clickhouse.com/engineering-resources/data-catalog) 充当元数据的中央存储库,存储和管理表定义和模式、分区信息以及访问控制策略。实现对湖屋的数据信息发现、数据血缘跟踪和治理。 | +| **表格式层** | [表格式层](https://clickhouse.com/engineering-resources/open-table-formats) 管理数据文件的逻辑组织,将其归类到表中,提供数据库类功能,如 ACID 事务、模式实施与演变、时间旅行功能,以及数据跳过和聚类等性能优化。 | +| **对象存储** | 此层为所有数据文件和元数据提供可扩展、耐用且具有成本效益的存储。它处理以开放格式持续保留数据的物理持久性,支持多个工具和系统的直接访问。 | +| **客户端应用程序** | 连接到湖屋以查询数据、可视化洞见或构建数据产品的各种工具和应用程序。这些可以包括商业智能工具、数据科学笔记本、自定义应用程序,以及 ETL/ELT 工具。 | + +## 数据湖屋的好处是什么? {#benefits-of-the-data-lakehouse} + +与传统数据仓库和数据湖相比,数据湖屋架构提供了几项显著优势: + +### 与传统数据仓库相比 {#compared-to-traditional-data-warehouses} + +| # | 好处 | 描述 | +|---|------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| 1 | **成本效率** | 湖屋利用廉价的对象存储而非专有存储格式,相比于对其集成存储收取高价的数据仓库,显著降低了存储成本。 | +| 2 | **组件灵活性和互换性** | 湖屋架构允许组织替换不同的组件。传统系统在需求变化或技术进步时需要全面替换,而湖屋通过更换单个组件(如查询引擎或表格式)实现增量演变。这种灵活性减少了供应商锁定,使组织能够在不进行破坏性迁移的情况下适应变化的需求。 | +| 3 | **开放格式支持** | 湖屋以开放文件格式(如 Parquet)存储数据,允许各种工具直接访问,而无需担心供应商锁定,不同于限制进入其生态系统的专有数据仓库格式。 | +| 4 | **AI/ML 集成** | 湖屋为机器学习框架和 Python/R 库提供直接访问数据,而数据仓库通常需要在使用数据进行高级分析之前提取数据。 | +| 5 | **独立扩展** | 湖屋将存储与计算分离,使每个部分能够根据实际需要独立扩展,而许多数据仓库则需要一起扩展。 | + +### 与数据湖相比 {#compared-to-data-lakes} + +| # | 好处 | 描述 | +|---|-------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| 1 | **查询性能** | 湖屋实现了索引、统计信息和数据布局优化,使 SQL 查询速度可与数据仓库相媲美,克服了原始数据湖的性能缺陷。 | +| 2 | **数据一致性** | 通过 ACID 事务支持,湖屋在并发操作中确保一致性,解决了传统数据湖的主要限制,后者可能因文件冲突导致数据损坏。 | +| 3 | **模式管理** | 湖屋实施模式验证并跟踪模式演变,防止 "数据沼泽" 问题,通常在数据湖中出现,导致数据因模式不一致而无法使用。 | +| 4 | **治理能力** | 湖屋提供行/列级的细粒度访问控制和审计功能,解决了基本数据湖中安全控制有限的问题。 | +| 5 | **BI 工具支持** | 湖屋提供 SQL 接口和优化,使其与标准商业智能工具兼容,不同于原始数据湖,在可视化之前需要额外的处理层。 | + +## ClickHouse 在数据湖屋架构中适合什么位置? {#where-does-clickhouse-fit-in-the-data-lakehouse-architecture} + +ClickHouse 是现代数据湖屋生态系统内一款强大的分析查询引擎。它为组织提供了一种高性能的选项,以大规模分析数据。由于其卓越的查询速度和效率,ClickHouse 是一个极具吸引力的选择。 + +在湖屋架构中,ClickHouse 充当专门的处理层,能够灵活地与底层数据进行交互。它可以直接查询存储在云对象存储系统(如 S3、Azure Blob Storage 或 Google Cloud Storage)中的 Parquet 文件,利用其优化的列式处理能力,即使在大规模数据集上也能快速交付结果。此直接查询能力使组织能够分析其湖泊数据,而无需复杂的数据搬运或转换过程。 + +ClickHouse 可以与 Apache Iceberg、Delta Lake 或 Apache Hudi 等开放表格式进行集成,以满足更复杂的数据管理需求。这种集成使 ClickHouse 能够利用这些格式的高级功能,同时仍然提供其所知的卓越查询性能。组织可以直接集成这些表格式,也可以通过元数据目录(如 AWS Glue、Unity 或其他目录服务)进行连接。 + +通过将 ClickHouse 作为查询引擎纳入其湖屋架构,组织能够对其数据湖执行快速的分析查询,同时保持湖屋方法定义下的灵活性和开放性。此组合提供了专门的分析数据库的性能特征,而不牺牲湖屋模型的核心优势,包括组件互换性、开放格式和统一数据管理。 + +## 混合架构:两全其美 {#hybrid-architecture-the-best-of-both-worlds} + +虽然 ClickHouse 在查询湖屋组件方面表现出色,但其高度优化的存储引擎提供了额外的优势。对于需要超低延迟查询的用例—例如实时仪表板、操作分析或互动用户体验—组织可以选择将性能关键数据直接存储在 ClickHouse 的本地格式中。这种混合方法提供了两全其美的效果:ClickHouse 专用存储提供的无与伦比的查询速度,适用于时间敏感的分析,同时在需要时也具备查询更广泛数据湖屋的灵活性。 + +这种双重能力使组织能够实施分层数据策略,其中经常访问的热数据存储在 ClickHouse 的优化存储中,以实现亚秒级的查询响应,同时维护对湖屋中完整数据历史的无缝访问。团队可以根据性能需求而不是技术限制做出架构决策,利用 ClickHouse 作为关键工作负载的快速分析数据库,以及作为更广泛数据生态系统的灵活查询引擎。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/01_discover/02_use_cases/03_data_warehousing.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/01_discover/02_use_cases/03_data_warehousing.md.hash new file mode 100644 index 00000000000..60a268b4c7f --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/01_discover/02_use_cases/03_data_warehousing.md.hash @@ -0,0 +1 @@ +326929633bfc2fa0 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/01_discover/02_use_cases/04_machine_learning_and_genAI/01_machine_learning.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/01_discover/02_use_cases/04_machine_learning_and_genAI/01_machine_learning.md new file mode 100644 index 00000000000..0b11326a74f --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/01_discover/02_use_cases/04_machine_learning_and_genAI/01_machine_learning.md @@ -0,0 +1,111 @@ +--- +'slug': '/cloud/get-started/cloud/use-cases/AI_ML' +'title': '机器学习' +'description': '了解 ClickHouse 如何在机器学习管道中驱动机器学习应用程序。' +'keywords': +- 'use cases' +- 'Machine Learning' +- 'Generative AI' +'sidebar_label': '机器学习' +'doc_type': 'guide' +--- + +import machine_learning_data_layer from '@site/static/images/cloud/onboard/discover/use_cases/ml_data_layer.png' +import online_feature_store from '@site/static/images/cloud/onboard/discover/use_cases/ml_data_layer.png' +import Image from '@theme/IdealImage'; + +## 机器学习数据层 {#machine-learning-data-layer} + +你可能听说过这样一个传闻:机器学习从业者80%的时间都花在数据清理上。无论这个神话是否真实,数据在机器学习问题中始终是核心,从开始到结束。无论你是在构建RAG管道、微调、训练自己的模型,还是评估模型性能,数据都是每个问题的根源。 + +管理数据可能很棘手,作为副产品,这个领域经历了一系列旨在通过解决机器学习数据问题特定切片来提高生产力的工具的激增。通常,这种情况表现为围绕更通用解决方案的抽象层,它具有指导性界面,从表面上看,可以更容易地应用于当前的特定子问题。实际上,这减少了通用解决方案中存在的灵活性,偏向于特定任务的易用性和简洁性。 + + + +这种方法有几个缺点。与支持应用代码结合的通用解决方案相比,专业工具、产品和服务的层叠套件存在更大的架构复杂性和数据成本的风险。你很容易发现自己拥有一长串工具和服务,每个工具只用于一个单一步骤。 + +这些风险通常有两个常见维度: + +1. **学习、维护和切换成本** + +机器学习架构可能会因为各种工具和组件的杂乱而变得难以学习和管理,产生更多的故障点和成本增长。 + +2. **数据重复和传输成本** + +在机器学习管道中使用多个离散但重叠的数据系统,可能会引入不必要且通常成本高昂的数据传输开销。 + +一个很好的说明这个权衡的是向量数据库。向量数据库旨在针对非常特定的机器学习任务,存储和搜索向量。虽然在某些架构中这可能是正确的选择,但在其他架构中,向量数据库可能是技术栈中不必要的新添加,因为这是又一个需要集成、管理以及传输数据的系统。大多数现代通用数据库都内置了向量支持(或通过插件实现),并且有更广泛的交叉能力。换句话说,在那些架构中,可能根本没有必要额外再添加一个专门处理向量的数据库。关键在于这些向量特定便利功能(例如内置嵌入模型)是否是任务关键的,并且值得付出成本。 + +### 数据探索 {#data-exploration} + +在定义机器学习问题、目标和成功标准之后,一个常见的第一步是探索将用于模型训练和评估的相关数据。 + +在此步骤中,数据被分析以理解其特征、分布和关系。这种评估和理解的过程是一个迭代的过程,通常导致在数据集上执行一系列临时查询,而查询的响应速度是至关重要的(以及其他因素,如成本效率和准确性)。随着公司存储越来越多的数据以利用于机器学习,检查现有数据的问题变得更加困难。 + +这是因为,传统数据系统的分析和评估查询在规模上通常变得乏味或 prohibitively 缓慢。一些大型厂商为了降低查询时间,会显著提高成本,并通过按查询收费或按扫描字节数收费来阻止临时评估。工程师可能会为了妥协这些限制而选择将数据子集下载到本地机器。 + +而ClickHouse是一个实时数据仓库,因此用户可以享受业内领先的分析计算查询速度。此外,ClickHouse从一开始就提供高性能,并且不会将关键的查询加速功能锁定在更高的定价等级。ClickHouse还可以直接从对象存储或数据湖查询数据,支持Iceberg、Delta Lake和Hudi等常见格式。这意味着无论你的数据存放在哪里,ClickHouse都可以作为你的机器学习工作负载的统一访问和计算层。 + +ClickHouse还拥有一整套可扩展至PB级数据的预构建统计和聚合函数,使编写和维护执行复杂计算的简单SQL变得容易。通过支持最细粒度的精确数据类型和编码,用户不需要担心减少数据的粒度。 + +尽管用户可以直接在ClickHouse中转换数据或在插入前使用SQL查询进行转换,但ClickHouse还可以在编程环境(如Python)中使用,通过[chDB](/chdb)。这允许嵌入式ClickHouse作为Python模块暴露,并用于在笔记本中转换和操作大型数据帧。因此,数据工程师可以在客户端执行转化工作,结果可以作为特征表材料化在集中式的ClickHouse实例中。 + +### 数据准备和特征提取 {#data-preparation-and-feature-extraction} + +接下来,数据被准备:清理、转换,并用于提取模型将用来训练和评估的特征。这个组件有时被称为特征生成或提取管道,是机器学习数据层的另一部分,通常会引入新工具。MLOps领域的公司如Neptune和Hopsworks提供了用于协调这些管道的不同数据转换产品的示例。然而,由于它们与所操作的数据库是独立工具,因此它们可能会脆弱,并可能导致需要手动修正的中断。 + +相比之下,通过[物化视图](/materialized-views),在ClickHouse中轻松完成数据转换。当新的数据插入ClickHouse源表时,它们会自动触发,用于在数据到达时轻松提取、转换和修改数据 - eliminating 不需要自己构建和监控定制管道。当这些转换需要对可能不适合内存的完整数据集进行聚合时,利用ClickHouse可以确保你无需尝试调整这一步骤以便与本地机器上的数据帧一起工作。对于那些在本地评估更方便的数据集,[ClickHouse local](/operations/utilities/clickhouse-local)是一个很好的替代选择,与[chDB](/chdb)一起,使用户能够使用标准的Python数据库(如Pandas)来利用ClickHouse。 + +### 训练和评估 {#training-and-evaluation} + +此时,特征将被划分为训练、验证和测试集。这些数据集被版本化,并随后在相应的阶段中使用。 + +在这一阶段,管道中常常会引入另一个专业工具到机器学习数据层 - 特征库。特征库通常是围绕数据库的抽象层,提供特定于管理模型训练、推断和评估的数据的便利功能。这些便利功能的例子包括版本控制、访问管理和自动将特征定义翻译为SQL语句。 + +在特征库中,ClickHouse可以作为: + +**数据源** - ClickHouse可以以70多种不同文件格式查询或摄取数据,包括数据湖格式如Iceberg和Delta Lake,使其成为理想的长期存储或查询数据的选择。通过使用对象存储分离存储和计算,ClickHouse Cloud还允许数据无限期存储 - 计算可缩减或完全停用,以最小化成本。灵活的编码,与列式存储和磁盘数据排序相结合,最大化压缩率,从而最小化所需的存储。用户可以轻松地将ClickHouse与数据湖结合,使用内置函数在对象存储中就地查询数据。 + +**转换引擎** - SQL提供了一种自然声明数据转换的方式。当扩展ClickHouse的分析和统计函数时,这些转换变得简洁和优化。不仅可以应用于ClickHouse表,在ClickHouse作为数据存储的情况下,表函数还允许对存储在Parquet等格式中的数据、磁盘或对象存储上的数据,甚至其他数据存储(如Postgres和MySQL)写SQL查询。一个完全并行化的查询执行引擎,结合列式存储格式,使ClickHouse能够在几秒钟内对PB级的数据进行聚合 - 与内存数据帧的转换不同,用户不会受限于内存。此外,物化视图允许在插入时对数据进行转换,从而将计算重载从查询时间转移到数据加载时间。这些视图可以利用同一系列适合数据分析和汇总的分析和统计函数。如果ClickHouse现有的分析功能不足或需要集成自定义库,用户还可以利用用户定义函数(UDF)。 + +#### 离线特征库 {#offline-feature-store} + +离线特征库用于模型训练。这通常意味着特征本身通过批处理数据转换管道生成(如上节所述),通常对这些特征的可用性没有严格的延迟要求。 + +通过能够从多个源读取数据并通过SQL查询应用转换,这些查询的结果也可以通过 `INSERT INTO SELECT` 语句持久化到ClickHouse中。由于转换通常按实体ID分组并返回多列作为结果,ClickHouse的模式推断可以自动检测这些结果所需的类型,并生成适当的表模式来存储它们。用于生成随机数和统计抽样的函数允许数据以每秒数百万行的速度高效迭代和扩展,以供模型训练管道使用。 + +通常,特征表示为带有时间戳的表,指示特定时间点上某个实体和特征的值。如前所述,训练管道通常需要在特定时间点和组中的特征状态。ClickHouse的稀疏索引允许快速过滤数据以满足时间点查询和特征选择过滤器。虽然其他技术如Spark、Redshift和BigQuery依赖于缓慢的状态窗口方法来识别特定时间点的特征状态,ClickHouse支持ASOF(截至当前时间)左连接查询和argMax函数。除了简化语法外,这种方法在大数据集上具有高性能,利用了排序和合并算法。这使得特征组能够快速构建,从而减少训练前的数据准备时间。 + +#### 在线特征库 {#online-feature-store} + +在线特征库用于存储用于推断的最新特征版本,并实时应用。这意味着这些特征需要以最小的延迟计算,因为它们是实时机器学习服务的一部分。 + + + +作为一个实时分析数据库,ClickHouse可以以低延迟服务高度并发的查询工作负载。虽然这需要数据通常是非规范化的,但这与训练和推断时使用的特征组的存储相符合。重要的是,ClickHouse能够在承受高写入工作负载的同时提供这种查询性能,得益于其日志结构合并树。这些特性是在线存储中保持特征更新所必需的。由于特征在离线存储中已经可用,因此可以轻松地将其材料化到同一ClickHouse集群或不同实例的新表中,通过现有能力,比如 `remoteSecure`。通过Kafka的集成,无论是通过其仅一次的Kafka Connect提供,还是通过[ClickPipes](/integrations/clickpipes/kafka)在ClickHouse Cloud中,都使从流数据源消费流数据变得简单可靠。 + +许多现代系统需要同时使用离线和在线存储,容易导致得出结论,这里需要两个专业的特征库。然而,这会增加同步这两个存储的复杂性,当然还包括在它们之间重复数据的成本。 + +像ClickHouse这样的实时数据仓库是一个可以同时支持离线和在线特征管理的单一系统。ClickHouse高效处理流数据和历史数据,并具备在实时推断和离线训练中提供所需的无限扩展、性能和并发性。 + +在考虑在此阶段使用特征库产品与直接利用实时数据仓库之间的权衡时,值得强调的是,可以通过设计表或模式等传统数据库范式实现版本控制等便利功能。其他功能,例如将特征定义转换为SQL语句,可能作为应用或业务逻辑的一部分提供更大的灵活性,而不是存在于一个有指导性的抽象层中。 + +### 推断 {#inference} + +模型推断是运行训练好的模型以获取输出的过程。当推断被数据库操作触发时 - 例如插入新记录或查询记录 - 推断步骤可以通过定制的作业或应用代码来管理。 + +另一方面,它也可以在数据层本身管理。ClickHouse的[用户定义函数 (UDFs)](/sql-reference/functions/udf),使用户能够在插入或查询时间直接从ClickHouse调用模型。这提供了将输入数据传递给模型、接收输出并自动将这些结果与摄取的数据一起存储的能力 - 所有这一切都无需启动其他进程或作业。这还提供了一个单一的接口,SQL,通过它来管理这一步骤。 + +### 向量存储 {#vector-store} + +向量存储是一种特定类型的数据库,优化用于存储和检索向量,通常是数据的一部分(如文本或图像)的嵌入,这些嵌入以数值形式捕捉其潜在含义。向量是当今生成性AI浪潮的核心,并在无数应用中使用。 + +向量数据库中的主要操作是“相似度搜索”,以根据数学度量找到“最接近”的向量。向量数据库受欢迎的原因在于它们采用特定策略,使这种检查 - 向量比较 - 尽可能快速。通常,这些技术意味着它们近似向量比较,而不是将输入向量与每一个存储的向量进行比较。 + +这一新工具类的问题在于,许多通用数据库,包括ClickHouse,内置了向量支持,并且通常也内置了这些近似方法的实现。特别是,ClickHouse旨在高性能的大规模分析 - 使你能够非常有效地执行不近似的向量比较。这意味着你可以获得精确的结果,而不必依赖于近似,同时不牺牲速度。 + +### 可观察性 {#observability} + +一旦你的机器学习应用上线,它将生成数据,包括日志和追踪数据,这些数据提供了对模型行为、性能和潜在改进领域的宝贵洞察。 + +基于SQL的可观察性是ClickHouse的另一个关键用例,在这里,ClickHouse被发现在成本效益上比替代方案高出10到100倍。事实上,许多可观察性产品本身都是在ClickHouse的支持下构建的。凭借业内最佳的摄取速率和压缩比,ClickHouse为任何规模的机器学习可观察性提供了成本效率和惊人的速度。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/01_discover/02_use_cases/04_machine_learning_and_genAI/01_machine_learning.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/01_discover/02_use_cases/04_machine_learning_and_genAI/01_machine_learning.md.hash new file mode 100644 index 00000000000..3001d9e7702 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/01_discover/02_use_cases/04_machine_learning_and_genAI/01_machine_learning.md.hash @@ -0,0 +1 @@ +63f8a5c1d6f48d6e diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/01_discover/02_use_cases/04_machine_learning_and_genAI/02_agent_facing_analytics.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/01_discover/02_use_cases/04_machine_learning_and_genAI/02_agent_facing_analytics.md new file mode 100644 index 00000000000..2c3c8abec58 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/01_discover/02_use_cases/04_machine_learning_and_genAI/02_agent_facing_analytics.md @@ -0,0 +1,84 @@ +--- +'slug': '/cloud/get-started/cloud/use-cases/AI_ML/agent_facing_analytics' +'title': '面向代理的分析' +'description': '使用 ClickHouse Cloud 构建面向代理的分析系统,以便为需要实时数据访问的 AI 代理和自主系统提供支持' +'keywords': +- 'use cases' +- 'Machine Learning' +- 'Generative AI' +- 'agent facing analytics' +- 'agents' +'sidebar_label': '面向代理的分析' +'doc_type': 'guide' +--- + +import Image from '@theme/IdealImage'; +import ml_ai_05 from '@site/static/images/cloud/onboard/discover/use_cases/ml_ai_05.png'; +import ml_ai_06 from '@site/static/images/cloud/onboard/discover/use_cases/ml_ai_06.png'; +import ml_ai_07 from '@site/static/images/cloud/onboard/discover/use_cases/ml_ai_07.png'; +import ml_ai_08 from '@site/static/images/cloud/onboard/discover/use_cases/ml_ai_08.png'; +import ml_ai_09 from '@site/static/images/cloud/onboard/discover/use_cases/ml_ai_09.png'; + +## 面向代理的分析概念 {#agent-facing-analytics} + +### 什么是“代理”? {#agents} + +可以将AI代理视为数字助手,它们已经超越了简单的任务执行(或函数调用):它们可以理解上下文,做出决定,并采取有意义的行动以实现特定目标。它们在一个“感知-思考-行动”的循环中运行(参见ReAct代理),处理各种输入(文本、媒体、数据),分析情况,然后利用这些信息做一些有用的事情。最重要的是,根据应用领域,它们理论上可以在不同的自主级别下运行,可能需要或不需要人工监督。 + +这里的变革者是大型语言模型(LLMs)的出现。虽然我们已经对AI代理有了一段时间的认识,但像GPT系列这样的LLMs大大提升了它们的“理解”和沟通能力。就好像它们突然变得更加流利于“人类”的语言,即能够理解请求并用从模型培训中提取的相关上下文信息作出回应。 + +### AI代理的超能力:“工具” {#tools} + +这些代理在对“工具”的访问中闪耀光芒。工具通过赋予AI代理执行任务的能力来增强它们。它们不仅仅是对话接口,能够完成各种任务,无论是进行数字运算、搜索信息,还是管理客户沟通。可以把这看作是有一个人能够描述如何解决问题与有一个人能够实际解决问题之间的区别。 + +例如,ChatGPT现在默认配备了搜索工具。这种与搜索提供者的集成使得模型在对话中能够从网络中提取最新信息。这意味着它可以对回答进行事实核查,访问最近的事件和数据,并提供最新的信息,而无需仅依赖于其训练数据。 + +配备工具的代理 + +工具还可以简化检索增强生成(RAG)管道的实施。不再仅仅依赖AI模型在训练期间学习的内容,RAG允许模型在形成响应之前提取相关信息。以下是一个例子:使用AI助手帮助客户支持(例如Salesforce AgentForce,ServiceNow AI Agents)。没有RAG,它只会利用其一般训练来回答问题。但是有了RAG,当客户询问最新的产品特性时,系统会在撰写响应之前检索最新的文档、发布说明和历史支持票据。这意味着答案现在基于AI模型可用的最新信息。 + +### 推理模型 {#reasoning-models} + +AI领域的另一个发展,或许是最有趣的,便是推理模型的出现。像OpenAI的o1、Anthropic的Claude或DeepSeek-R1这样的系统采取更为系统的方法,在响应提示之前引入“思考”步骤。推理模型不是立即生成答案,而是使用诸如思维链(Chain-of-Thought,CoT)等提示技术,从多个角度分析问题,将其分解为步骤,并利用可用工具在需要时收集上下文信息。 + +这标志着向更强大的系统的转变,这些系统通过推理与实用工具的结合能够处理更复杂的任务。这个领域最新的例子之一是OpenAI的深度研究,该代理能够自主进行复杂的多步骤在线研究任务。它处理和综合来自各种来源的信息,包括文本、图像和PDF,在五到三十分钟内生成综合报告,而这一任务传统上需要人类几个小时。 + +推理模型 + +## AI代理的实时分析 {#real-time-analytics-for-ai-agents} + +让我们以一个具备实时分析数据库访问的代理AI助手为例,该数据库包含公司的CRM数据。当用户询问最新的(实时)销售趋势时,AI助手查询连接的数据源。它迭代分析数据,以识别有意义的模式和趋势,例如环比增长、季节性变化或新兴产品类别。最后,它生成一条自然语言响应,解释关键发现,通常附有支持性可视化。当主要接口以聊天为基础时,性能尤为重要,因为这些迭代探索会触发一系列查询,能够扫描大量数据以提取相关见解。 + +某些属性使得实时数据库特别适合这种工作负载。例如,实时分析数据库旨在处理近实时数据,使它们能够在新数据到达时几乎立即处理和提供见解。这对AI代理至关重要,因为它们可能需要最新的信息来做出(或协助做出)及时和相关的决策。 + +核心分析能力也很重要。实时分析数据库在执行复杂的聚合和模式检测方面表现出色。与主要专注于原始数据存储或检索的操作数据库不同,这些系统经过优化,旨在分析海量信息。这使它们特别适合需要发现趋势、检测异常和得出可操作见解的AI代理。 + +实时分析数据库还需要提供快速性能,以支持交互式查询,这对于基于聊天的交互和高频率的探索工作负载至关重要。即使在大量数据和高并发查询下,它们也能确保一致的性能,从而实现响应式对话和更流畅的用户体验。 + +最后,实时分析数据库通常作为终极“数据汇聚点”,有效地将有价值的特定领域数据整合在一个位置。通过将不同来源和格式的必要数据在同一位置协同放置,这些数据库确保AI代理能够访问领域信息的统一视图,而不受操作系统的影响。 + +经典实时分析 + +代理实时分析 + +这些属性已经使得实时数据库在大规模支持AI数据检索用例中发挥重要作用(例如OpenAI收购Rockset)。它们还使得AI代理能够提供快速的数据驱动响应,同时卸载繁重的计算工作。 + +这使得实时分析数据库在获取见解方面定位为AI代理的首选“上下文提供者”。 + +## AI代理作为新兴用户角色 {#ai-agents-as-an-emerging-user-persona} + +将利用实时分析数据库的AI代理视为新用户类别,一种有用的思考方式,可以用产品经理的说法来描述:用户角色。 + +代理作为新兴用户角色 + +从数据库的角度来看,我们可以预期一个潜在数量不受限制的AI代理,正在同时为用户运行大量查询,或自主进行调查,优化迭代研究和见解,并执行任务。 + +多年来,实时数据库有时间适应人类交互用户,无论是直接连接到系统还是通过中间件应用层。经典用户角色的例子包括数据库管理员、商业分析师、数据科学家或构建应用程序的开发者。行业逐步学习了他们的使用模式和需求,并自然地提供了接口、操作员、用户界面、格式、客户端和性能,以满足他们的各种用例。 + +现在的问题是,我们是否准备好适应AI代理的工作负载?我们需要重新思考或从头创建哪些特定功能,以适应这些使用模式? + +ClickHouse正在迅速通过一系列旨在提供功能齐全的AI体验的特性,为这些问题提供答案。 + +## ClickHouse.ai {#clickhouse-ai} + +有关即将在ClickHouse Cloud中推出的功能的更多信息,请参见 [ClickHouse.ai](https://clickhouse.com/clickhouse-ai/)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/01_discover/02_use_cases/04_machine_learning_and_genAI/02_agent_facing_analytics.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/01_discover/02_use_cases/04_machine_learning_and_genAI/02_agent_facing_analytics.md.hash new file mode 100644 index 00000000000..48cabb5da93 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/01_discover/02_use_cases/04_machine_learning_and_genAI/02_agent_facing_analytics.md.hash @@ -0,0 +1 @@ +53cfcf13072fa00a diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/01_discover/02_use_cases/04_machine_learning_and_genAI/_category_.json b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/01_discover/02_use_cases/04_machine_learning_and_genAI/_category_.json new file mode 100644 index 00000000000..01f4f00d897 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/01_discover/02_use_cases/04_machine_learning_and_genAI/_category_.json @@ -0,0 +1,5 @@ +{ + "label": "ML/AI", + "collapsible": true, + "collapsed": true, +} \ No newline at end of file diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/01_discover/02_use_cases/_category_.json b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/01_discover/02_use_cases/_category_.json new file mode 100644 index 00000000000..70c6591bd01 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/01_discover/02_use_cases/_category_.json @@ -0,0 +1,5 @@ +{ + "label": "Use cases", + "collapsible": true, + "collapsed": true, +} \ No newline at end of file diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/01_overview.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/01_overview.md new file mode 100644 index 00000000000..084c5206bdb --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/01_overview.md @@ -0,0 +1,40 @@ +--- +'sidebar_label': '概述' +'sidebar_position': 1 +'slug': '/integrations/migration/overview' +'keywords': +- 'clickhouse' +- 'migrate' +- 'migration' +- 'migrating' +- 'data' +'title': '将数据迁移到 ClickHouse' +'description': '页面描述了可用于将数据迁移到 ClickHouse 的选项' +'doc_type': 'guide' +--- + + +# 将数据迁移到 ClickHouse + +
+ +
+ +
+ +根据您数据当前所在的位置,有几种将数据迁移到 ClickHouse Cloud 的选项: + +- [自管理到云](/cloud/migration/clickhouse-to-cloud):使用 `remoteSecure` 函数传输数据 +- [其他 DBMS](/cloud/migration/clickhouse-local):使用 [clickhouse-local] ETL 工具和适合您当前 DBMS 的 ClickHouse 表函数 +- [任何地方!](/cloud/migration/etl-tool-to-clickhouse):使用与各种不同数据源连接的众多流行 ETL/ELT 工具之一 +- [对象存储](/integrations/migration/object-storage-to-clickhouse):轻松将数据从 S3 插入 ClickHouse + +在示例 [从 Redshift 迁移](/migrations/redshift/migration-guide) 中,我们展示了三种将数据迁移到 ClickHouse 的不同方法。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/01_overview.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/01_overview.md.hash new file mode 100644 index 00000000000..4fa2f290455 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/01_overview.md.hash @@ -0,0 +1 @@ +3ad809f002420893 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/02_postgres/01_overview.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/02_postgres/01_overview.md new file mode 100644 index 00000000000..74ceb0821c8 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/02_postgres/01_overview.md @@ -0,0 +1,53 @@ +--- +'slug': '/migrations/postgresql/overview' +'title': '比较 PostgreSQL 和 ClickHouse' +'description': '从 PostgreSQL 迁移到 ClickHouse 的指南' +'keywords': +- 'postgres' +- 'postgresql' +- 'migrate' +- 'migration' +'sidebar_label': '概述' +'doc_type': 'guide' +--- + + +# 比较 ClickHouse 和 PostgreSQL + +## 为什么使用 ClickHouse 而不是 Postgres? {#why-use-clickhouse-over-postgres} + +TLDR:因为 ClickHouse 是为快速分析而设计的,特别是 `GROUP BY` 查询,作为一个 OLAP 数据库,而 Postgres 是一个为事务工作负载设计的 OLTP 数据库。 + +OLTP,或在线事务处理数据库,是为管理事务信息而设计的。这些数据库的主要目标,Postgres 是经典的例子,是确保工程师能够将一批更新提交到数据库,并能确保该批更新——整体上——要么成功,要么失败。这些类型的事务保证与 ACID 属性是 OLTP 数据库的主要焦点,也是 Postgres 的巨大优势。考虑到这些要求,OLTP 数据库在用于大数据集的分析查询时通常会遇到性能限制。 + +OLAP,或在线分析处理数据库,旨在满足这些需求——管理分析工作负载。这些数据库的主要目标是确保工程师能够有效地查询和聚合庞大的数据集。像 ClickHouse 这样的实时 OLAP 系统允许在数据实时摄取时进行这种分析。 + +有关 ClickHouse 和 PostgreSQL 更深入比较,请参见 [这里](/migrations/postgresql/appendix#postgres-vs-clickhouse-equivalent-and-different-concepts)。 + +要查看 ClickHouse 和 Postgres 在分析查询上的潜在性能差异,请查看 [在 ClickHouse 中重写 PostgreSQL 查询](/migrations/postgresql/rewriting-queries)。 + +## 迁移策略 {#migration-strategies} + +从 PostgreSQL 迁移到 ClickHouse 的正确策略取决于您的用例、基础架构和数据要求。一般而言,对于大多数现代用例,实时变更数据捕获 (CDC) 是最佳方法,而手动批量加载后跟定期更新适合于更简单的场景或一次性迁移。 + +以下部分描述了两种主要的迁移策略:**实时 CDC** 和 **手动批量加载 + 定期更新**。 + +### 实时复制 (CDC) {#real-time-replication-cdc} + +变更数据捕获 (CDC) 是保持两个数据库之间同步表的过程。它是从 PostgreSQL 迁移的最有效的方法,但由于它处理近乎实时的 PostgreSQL 到 ClickHouse 的插入、更新和删除,因此更复杂。它非常适合实时分析非常重要的用例。 + +实时变更数据捕获 (CDC) 可以通过 [ClickPipes](/integrations/clickpipes/postgres/deduplication) 在 ClickHouse 中实现,如果您正在使用 ClickHouse Cloud,或者如果您运行的是本地 ClickHouse,可以使用 [PeerDB](https://github.com/PeerDB-io/peerdb)。这些解决方案处理实时数据同步的复杂性,包括初始加载,通过捕获来自 PostgreSQL 的插入、更新和删除并在 ClickHouse 中复制它们。这种方法确保 ClickHouse 中的数据始终是最新和准确的,而无需手动干预。 + +### 手动批量加载 + 定期更新 {#manual-bulk-load-periodic-updates} + +在某些情况下,像手动批量加载后跟定期更新这样的更简单的方法可能就足够了。此策略非常适合一次性迁移或不要求实时复制的情况。它涉及通过直接 SQL `INSERT` 命令或导出和导入 CSV 文件将数据从 PostgreSQL 批量加载到 ClickHouse。初始迁移后,您可以通过定期同步来自 PostgreSQL 的更改周期性地更新 ClickHouse 中的数据。 + +批量加载过程简单灵活,但缺乏实时更新的缺点。一旦初始数据在 ClickHouse 中,更新不会立即反映,因此您必须安排定期更新以同步来自 PostgreSQL 的更改。这种方法适用于对时间不太敏感的用例,但它引入了数据在 PostgreSQL 中更改和这些更改出现在 ClickHouse 中之间的延迟。 + +### 选择哪个策略? {#which-strategy-to-choose} + +对于大多数需要在 ClickHouse 中保持最新数据的应用程序,建议采用通过 ClickPipes 实现的实时 CDC 方法。它提供了连续的数据同步,设置和维护最小。另一方面,手动批量加载加上定期更新,适合于更简单的一次性迁移或实时更新不太关键的工作负载。 + +--- + +**[在这里开始 PostgreSQL 迁移指南](/migrations/postgresql/dataset)。** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/02_postgres/01_overview.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/02_postgres/01_overview.md.hash new file mode 100644 index 00000000000..26c7709144f --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/02_postgres/01_overview.md.hash @@ -0,0 +1 @@ +17ba928115dd3651 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/02_postgres/appendix.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/02_postgres/appendix.md new file mode 100644 index 00000000000..08029ce3ba0 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/02_postgres/appendix.md @@ -0,0 +1,193 @@ +--- +'slug': '/migrations/postgresql/appendix' +'title': '附录' +'keywords': +- 'postgres' +- 'postgresql' +- 'data types' +- 'types' +'description': '与从 PostgreSQL 迁移相关的附加信息' +'doc_type': 'reference' +--- + +import postgresReplicas from '@site/static/images/integrations/data-ingestion/dbms/postgres-replicas.png'; +import Image from '@theme/IdealImage'; + +## Postgres 与 ClickHouse:等价与不同概念 {#postgres-vs-clickhouse-equivalent-and-different-concepts} + +来自 OLTP 系统的用户,如果习惯于 ACID 事务,则应注意 ClickHouse 刻意妥协,以在提供性能的同时不完全实现这些功能。如果理解得当,ClickHouse 语义可以提供较高的耐久性保证和高写入吞吐量。我们在下面突出了一些关键概念,用户在从 Postgres 转向 ClickHouse 之前应熟悉。 + +### 分片与副本 {#shards-vs-replicas} + +分片和复制是用于在存储和/或计算成为性能瓶颈时,通过多个 Postgres 实例进行扩展的两种策略。在 Postgres 中,分片涉及将一个大型数据库拆分为更小的可管理部分,分布在多个节点上。然而,Postgres 本身不支持分片。相反,分片可以通过如 [Citus](https://www.citusdata.com/) 的扩展来实现,其中 Postgres 成为一种能够水平扩展的分布式数据库。这种方法使 Postgres 能够通过将负载分配到几台机器上来处理更高的事务率和更大的数据集。分片可以基于行或模式,以提供灵活性,支持诸如事务或分析等工作负载类型。分片在数据管理和查询执行方面可能会引入显著复杂性,因为它需要在多个机器之间进行协调和一致性保证。 + +与分片不同,副本是额外的 Postgres 实例,包含来自主节点的所有或部分数据。副本用于各种原因,包括增强读取性能和高可用性(HA)场景。物理复制是 Postgres 的一项原生特性,涉及将整个数据库或显著部分复制到另一服务器,包括所有数据库、表和索引。这涉及通过 TCP/IP 从主节点流式传输 WAL 段。相比之下,逻辑复制是一种更高层次的抽象,它基于 `INSERT`、`UPDATE` 和 `DELETE` 操作流式传递更改。尽管物理复制可能产生相同的结果,但它为特定表和操作的目标以及数据转换和支持不同版本的 Postgres 等提供了更大的灵活性。 + +**相对而言,ClickHouse 的分片和副本是与数据分布和冗余相关的两个关键概念**。ClickHouse 的副本可以被视为类似于 Postgres 的副本,尽管复制是最终一致的,而没有主节点的概念。与 Postgres 不同,分片在 ClickHouse 中是本地支持的。 + +分片是表数据的一部分。您始终至少拥有一个分片。将数据分片到多个服务器可以在您超出单个服务器的容量时分担负载,所有分片均用于并行运行查询。用户可以手动在不同服务器上为表创建分片,并直接向它们插入数据。或者,可以使用分布式表,并通过分片键定义数据的路由到哪个分片。分片键可以是随机的,也可以是哈希函数的输出。重要的是,一个分片可以由多个副本组成。 + +副本是数据的副本。ClickHouse 总是至少具有一份数据的副本,因此副本的最小数量为一个。添加数据的第二个副本可提供容错能力,并可能为处理更多查询提供额外的计算([并行副本](https://clickhouse.com/blog/clickhouse-release-23-03#parallel-replicas-for-utilizing-the-full-power-of-your-replicas-nikita-mikhailov) 还可以用于为单个查询分配计算,从而降低延迟)。副本是通过 [ReplicatedMergeTree 表引擎](/engines/table-engines/mergetree-family/replication) 实现的,该引擎使 ClickHouse 能够在不同服务器之间保持数据的多个副本同步。复制是物理的:只有压缩的部分在节点之间传输,而不是查询。 + +总之,副本是提供冗余和可靠性(以及潜在的分布式处理)的数据副本,而分片是允许分布式处理和负载均衡的数据子集。 + +> ClickHouse Cloud 使用 S3 后备的单一数据副本,并具有多个计算副本。每个副本节点都可以访问数据,并具有本地 SSD 缓存。这仅依赖于通过 ClickHouse Keeper 进行元数据复制。 + +## 最终一致性 {#eventual-consistency} + +ClickHouse 使用 ClickHouse Keeper(C++ ZooKeeper 实现,ZooKeeper 也可以使用)来管理其内部复制机制,主要关注元数据存储和确保最终一致性。Keeper 用于为分布式环境中的每次插入分配唯一的顺序编号。这对维护操作之间的顺序和一致性至关重要。该框架还处理后续操作,如合并和变更,确保这些操作的工作在保证它们在所有副本中执行的相同顺序的同时进行分配。除了元数据之外,Keeper 作为复制的综合控制中心,跟踪存储数据部分的校验和,并充当副本之间的分布式通知系统。 + +ClickHouse 中的复制过程 (1) 当数据插入到任何副本时开始。此数据以原始插入的形式 (2) 与其校验和一起写入磁盘。一旦写入,副本 (3) 尝试通过分配唯一的块编号并记录新部分的细节,在 Keeper 中注册此新数据部分。其他副本在 (4) 检测到复制日志中的新条目时,将 (5) 通过内部 HTTP 协议下载相应的数据部分,并根据 ZooKeeper 中列出的校验和进行验证。该方法确保所有副本最终持有一致且最新的数据,尽管处理速度不同或可能存在延迟。此外,系统能够并发处理多个操作,从而优化数据管理流程,并允许系统扩展和对硬件差异保持稳健性。 + +Eventual consistency + +请注意,ClickHouse Cloud 使用 [针对云优化的复制机制](https://clickhouse.com/blog/clickhouse-cloud-boosts-performance-with-sharedmergetree-and-lightweight-updates),以适应其存储和计算架构的分离。通过将数据存储在共享对象存储中,数据会自动对所有计算节点可用,而无需在节点之间物理复制数据。相反,Keeper 仅用于在计算节点之间共享元数据(数据在对象存储中的位置)。 + +PostgreSQL 采用了一种与 ClickHouse 不同的复制策略,主要使用流式复制,这涉及到一个主副本模型,其中数据不断从主节点流式传输到一个或多个副本节点。这种类型的复制确保了近乎实时的一致性,并且是同步或异步的,允许管理员控制可用性和一致性之间的平衡。与 ClickHouse 不同,PostgreSQL 依赖于 WAL(Write-Ahead Logging)与逻辑复制和解码,以在节点之间流式传递数据对象和更改。这种 PostgreSQL 方法更为直接,但在高度分布的环境中,可能无法提供与 ClickHouse 通过其复杂的 Keeper 用于分布式操作协调和最终一致性所实现的相同级别的扩展性和容错性。 + +## 用户影响 {#user-implications} + +在 ClickHouse 中,存在“脏读”的可能性——用户可以向一个副本写入数据,然后从另一个副本读取可能未复制的数据,这源于其通过 Keeper 管理的最终一致性复制模型。该模型强调在分布式系统中的性能和可扩展性,允许副本独立操作并异步同步。因此,新的插入数据可能不会立即在所有副本中可见,这取决于复制延迟以及更改在系统中传播所需的时间。 + +相反,PostgreSQL 的流式复制模型通常可以通过采用同步复制选项来防止脏读,在这种情况下,主节点等待至少一个副本确认收到数据后再提交事务。这确保一旦事务被提交,就有保证数据在另一个副本中可用。在主节点故障的情况下,副本将确保查询看到已提交的数据,从而维持更严格的一致性级别。 + +## 建议 {#recommendations} + +新用户在使用 ClickHouse 时应意识到这些差异,这些差异会在复制环境中表现出来。通常,在分析数十亿甚至数万亿个数据点时,最终一致性是足够的——在这种情况下,指标通常更稳定,或者由于新数据以高速度持续插入,估算足够。 + +如果需要,可以通过多种选项增加读取的一致性。两个示例都需要增加复杂性或开销——从而降低查询性能,并使 ClickHouse 扩展变得更加困难。 **我们建议这些方法仅在绝对必要时使用。** + +## 一致路由 {#consistent-routing} + +为克服最终一致性的某些限制,用户可以确保客户端路由到相同的副本。这在多个用户查询 ClickHouse 时特别有用,并且结果应该在请求之间是确定性的。在结果可能有所不同的情况下,确保查询相同的副本可以确保视图的一致性。 + +这可以通过几种方法实现,具体取决于您的架构以及是否使用 ClickHouse OSS 或 ClickHouse Cloud。 + +## ClickHouse Cloud {#clickhouse-cloud} + +ClickHouse Cloud 使用 S3 后备的单一数据副本,并具有多个计算副本。数据对每个副本节点可用,且每个副本都有本地 SSD 缓存。为了确保一致的结果,用户只需确保一致路由到相同的节点。 + +ClickHouse Cloud 服务的节点通信通过代理进行。HTTP 和原生协议连接将在保持打开的期间内路由到同一节点。在大多数客户端的 HTTP 1.1 连接中,这取决于 Keep-Alive 窗口。大多数客户端(例如 Node Js)可以对此进行配置。这还要求在服务器端进行配置,该配置通常高于客户端,并在 ClickHouse Cloud 中设置为 10 秒。 + +为了确保在连接之间的一致路由,例如,如果使用连接池或连接过期,用户可以确保使用相同的连接(原生更容易)或请求暴露粘性端点。这为集群中的每个节点提供了一组端点,从而允许客户端确保查询的确定性路由。 + +> 联系支持以访问粘性端点。 + +## ClickHouse OSS {#clickhouse-oss} + +在 OSS 中实现这一行为取决于您的分片和副本拓扑,以及您是否使用 [分布式表](/engines/table-engines/special/distributed) 进行查询。 + +当只有一个分片和副本(当 ClickHouse 垂直扩展时常见)时,用户在客户端层选择节点并直接查询副本,确保这是被确定性选择的。 + +虽然没有分布式表的多分片和副本拓扑是可能的,但这种高级部署通常具有自己的路由基础设施。因此,我们假设具有多个分片的部署使用了分布式表(分布式表可以与单分片部署一起使用,但通常没有必要)。 + +在这种情况下,用户应该根据属性(例如 `session_id` 或 `user_id`)确保一致节点路由。设置 [`prefer_localhost_replica=0`](/operations/settings/settings#prefer_localhost_replica),[`load_balancing=in_order`](/operations/settings/settings#load_balancing) 应 [在查询中设置](/operations/settings/query-level)。这将确保优先选择任何分片的本地副本,否则优先选择配置中列出的副本——前提是它们的错误数量相同——如果错误更多,则将随机选择以进行故障转移。[`load_balancing=nearest_hostname`](/operations/settings/settings#load_balancing) 也可以作为这种确定性分片选择的替代方案。 + +> 创建分布式表时,用户将指定一个集群。此集群定义在 config.xml 中指定,将列出分片(及其副本)- 从而允许用户控制它们从每个节点使用的顺序。通过使用这一点,用户可以确保选择是确定性的。 + +## 顺序一致性 {#sequential-consistency} + +在某些特殊情况下,用户可能需要顺序一致性。 + +数据库中的顺序一致性是指对数据库的操作似乎以某种顺序执行,并且这一顺序在与数据库交互的所有程序中保持一致。这意味着每个操作在被调用和完成之间似乎都能瞬间生效,并且所有操作都有一个共同商定的顺序。 + +从用户的角度来看,这通常表现为在 ClickHouse 中写入数据时,并在读取数据时,保证返回最新插入的行。 +这可以通过几种方式实现(按优先顺序): + +1. **读/写同一节点** - 如果您使用原生协议,或通过 HTTP 进行写入/读取的 [会话](/interfaces/http#default-database),则应连接到同一副本:在这种情况下,您直接从写入的节点读取,则您的读取将始终是一致的。 +2. **手动同步副本** - 如果您向一个副本写入并从另一个副本读取,则可以在读取之前使用命令 `SYSTEM SYNC REPLICA LIGHTWEIGHT`。 +3. **启用顺序一致性** - 通过查询设置 [`select_sequential_consistency = 1`](/operations/settings/settings#select_sequential_consistency)。在 OSS 中,还必须指定设置 `insert_quorum = 'auto'`。 + +
+ +有关启用这些设置的进一步细节,请参见 [此处](/cloud/reference/shared-merge-tree#consistency)。 + +> 使用顺序一致性将对 ClickHouse Keeper 施加更多负载。结果可能意味着插入和读取变得更慢。ClickHouse Cloud 中作为主要表引擎使用的 SharedMergeTree,其顺序一致性 [开销更小且更具可扩展性](/cloud/reference/shared-merge-tree#consistency)。OSS 用户在使用此方法时应谨慎,并测量 Keeper 的负载。 + +## 事务 (ACID) 支持 {#transactional-acid-support} + +迁移自 PostgreSQL 的用户可能习惯于其对 ACID(原子性、一致性、隔离性、持久性)属性的强大支持,使其成为事务数据库的可靠选择。PostgreSQL 中的原子性确保每个事务被视为一个单一单元,完全成功或完全回滚,从而防止部分更新。通过强制执行约束、触发器和规则来维护一致性,确保所有数据库事务导致有效状态。PostgreSQL 支持从已提交读到可序列化的隔离级别,允许对并发事务所做更改的可见性进行精细控制。最后,通过预写日志(WAL)实现持久性,确保一旦事务被提交,即使在系统故障的情况下也保持不变。 + +这些属性是充当真实来源的 OLTP 数据库的共同特征。 + +虽然强大,但这具有固有的限制,并使 PB 规模变得具有挑战性。ClickHouse 在这些属性上进行了妥协,以提供快速的分析查询,同时保持高写入吞吐量。 + +ClickHouse 在 [有限配置下提供 ACID 属性](/guides/developer/transactional) - 最简单的情况是使用一个分区的非复制的 MergeTree 表引擎。用户不应期望在这些情况之外具备这些属性,并确保这些不是需求。 + +## 压缩 {#compression} + +ClickHouse 的列式存储意味着与 Postgres 相比,压缩通常会显著更好。以下是在比较两个数据库中所有 Stack Overflow 表的存储需求时的示例: + +```sql title="Query (Postgres)" +SELECT + schemaname, + tablename, + pg_total_relation_size(schemaname || '.' || tablename) AS total_size_bytes, + pg_total_relation_size(schemaname || '.' || tablename) / (1024 * 1024 * 1024) AS total_size_gb +FROM + pg_tables s +WHERE + schemaname = 'public'; +``` + +```sql title="Query (ClickHouse)" +SELECT + `table`, + formatReadableSize(sum(data_compressed_bytes)) AS compressed_size +FROM system.parts +WHERE (database = 'stackoverflow') AND active +GROUP BY `table` +``` + +```response title="Response" +┌─table───────┬─compressed_size─┐ +│ posts │ 25.17 GiB │ +│ users │ 846.57 MiB │ +│ badges │ 513.13 MiB │ +│ comments │ 7.11 GiB │ +│ votes │ 1.28 GiB │ +│ posthistory │ 40.44 GiB │ +│ postlinks │ 79.22 MiB │ +└─────────────┴─────────────────┘ +``` + +有关优化和测量压缩的更多详细信息可以在 [此处](/data-compression/compression-in-clickhouse) 找到。 + +## 数据类型映射 {#data-type-mappings} + +以下表显示了 Postgres 的等效 ClickHouse 数据类型。 + +| Postgres 数据类型 | ClickHouse 类型 | +| --- | --- | +| `DATE` | [Date](/sql-reference/data-types/date) | +| `TIMESTAMP` | [DateTime](/sql-reference/data-types/datetime) | +| `REAL` | [Float32](/sql-reference/data-types/float) | +| `DOUBLE` | [Float64](/sql-reference/data-types/float) | +| `DECIMAL, NUMERIC` | [Decimal](/sql-reference/data-types/decimal) | +| `SMALLINT` | [Int16](/sql-reference/data-types/int-uint) | +| `INTEGER` | [Int32](/sql-reference/data-types/int-uint) | +| `BIGINT` | [Int64](/sql-reference/data-types/int-uint) | +| `SERIAL` | [UInt32](/sql-reference/data-types/int-uint) | +| `BIGSERIAL` | [UInt64](/sql-reference/data-types/int-uint) | +| `TEXT, CHAR, BPCHAR` | [String](/sql-reference/data-types/string) | +| `INTEGER` | Nullable([Int32](/sql-reference/data-types/int-uint)) | +| `ARRAY` | [Array](/sql-reference/data-types/array) | +| `FLOAT4` | [Float32](/sql-reference/data-types/float) | +| `BOOLEAN` | [Bool](/sql-reference/data-types/boolean) | +| `VARCHAR` | [String](/sql-reference/data-types/string) | +| `BIT` | [String](/sql-reference/data-types/string) | +| `BIT VARYING` | [String](/sql-reference/data-types/string) | +| `BYTEA` | [String](/sql-reference/data-types/string) | +| `NUMERIC` | [Decimal](/sql-reference/data-types/decimal) | +| `GEOGRAPHY` | [Point](/sql-reference/data-types/geo#point), [Ring](/sql-reference/data-types/geo#ring), [Polygon](/sql-reference/data-types/geo#polygon), [MultiPolygon](/sql-reference/data-types/geo#multipolygon) | +| `GEOMETRY` | [Point](/sql-reference/data-types/geo#point), [Ring](/sql-reference/data-types/geo#ring), [Polygon](/sql-reference/data-types/geo#polygon), [MultiPolygon](/sql-reference/data-types/geo#multipolygon) | +| `INET` | [IPv4](/sql-reference/data-types/ipv4), [IPv6](/sql-reference/data-types/ipv6) | +| `MACADDR` | [String](/sql-reference/data-types/string) | +| `CIDR` | [String](/sql-reference/data-types/string) | +| `HSTORE` | [Map(K, V)](/sql-reference/data-types/map), [Map](/sql-reference/data-types/map)(K,[Variant](/sql-reference/data-types/variant)) | +| `UUID` | [UUID](/sql-reference/data-types/uuid) | +| `ARRAY` | [ARRAY(T)](/sql-reference/data-types/array) | +| `JSON*` | [String](/sql-reference/data-types/string), [Variant](/sql-reference/data-types/variant), [Nested](/sql-reference/data-types/nested-data-structures/nested#nestedname1-type1-name2-type2-), [Tuple](/sql-reference/data-types/tuple) | +| `JSONB` | [String](/sql-reference/data-types/string) | + +*\* ClickHouse 对 JSON 的生产支持正在开发中。目前用户可以将 JSON 映射为 String,并使用 [JSON 函数](/sql-reference/functions/json-functions),或直接将 JSON 映射为 [元组](/sql-reference/data-types/tuple)和 [嵌套](/sql-reference/data-types/nested-data-structures/nested),如果结构是可预测的。有关 JSON 的更多信息,请参见 [此处](/integrations/data-formats/json/overview).* diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/02_postgres/appendix.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/02_postgres/appendix.md.hash new file mode 100644 index 00000000000..c0af48a01e8 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/02_postgres/appendix.md.hash @@ -0,0 +1 @@ +ee779bba05f7a33a diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/migrations/postgres/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/02_postgres/index.md similarity index 67% rename from i18n/zh/docusaurus-plugin-content-docs/current/migrations/postgres/index.md rename to i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/02_postgres/index.md index 72974c2dd01..3e2e9fa34f3 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/migrations/postgres/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/02_postgres/index.md @@ -3,14 +3,15 @@ 'pagination_prev': null 'pagination_next': null 'title': 'PostgreSQL' -'description': 'PostgreSQL 迁移部分的首页' +'description': 'PostgreSQL 迁移部分的登录页面' +'doc_type': 'landing-page' --- | 页面 | 描述 | |----------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| [概述](./overview.md) | 本节的介绍页面 | -| [连接到 PostgreSQL](/integrations/postgresql/connecting-to-postgresql) | 本页涵盖将 PostgreSQL 与 ClickHouse 集成的以下选项:ClickPipes、PeerDB、PostgreSQL 表引擎、MaterializedPostgreSQL 数据库引擎。 | -| [迁移数据](/migrations/postgresql/dataset) | 从 PostgreSQL 迁移到 ClickHouse 的指南第一部分。通过实际示例,演示如何使用实时复制 (CDC) 方法高效地执行迁移。所涵盖的许多概念同样适用于从 PostgreSQL 到 ClickHouse 的手动批量数据传输。 | -| [重写 PostgreSQL 查询](/migrations/postgresql/rewriting-queries)| 从 PostgreSQL 迁移到 ClickHouse 的指南第二部分。通过实际示例,演示如何使用实时复制 (CDC) 方法高效地执行迁移。所涵盖的许多概念同样适用于从 PostgreSQL 到 ClickHouse 的手动批量数据传输。| +| [概述](/migrations/postgresql/overview) | 本节的介绍页面 | +| [连接 PostgreSQL](/integrations/postgresql/connecting-to-postgresql) | 本页面涵盖将 PostgreSQL 与 ClickHouse 集成的以下选项:ClickPipes、PeerDB、PostgreSQL 表引擎、MaterializedPostgreSQL 数据库引擎。 | +| [迁移数据](/migrations/postgresql/dataset) | 从 PostgreSQL 迁移到 ClickHouse 的指南第一部分。通过实际示例,演示如何使用实时复制 (CDC) 方法有效执行迁移。所涵盖的许多概念也适用于从 PostgreSQL 到 ClickHouse 的手动批量数据传输。 | +| [重写 PostgreSQL 查询](/migrations/postgresql/rewriting-queries)| 从 PostgreSQL 迁移到 ClickHouse 的指南第二部分。通过实际示例,演示如何使用实时复制 (CDC) 方法有效执行迁移。所涵盖的许多概念也适用于从 PostgreSQL 到 ClickHouse 的手动批量数据传输。| | [数据建模技术](/migrations/postgresql/data-modeling-techniques)| 从 PostgreSQL 迁移到 ClickHouse 的指南第三部分。通过实际示例,演示在从 PostgreSQL 迁移时如何在 ClickHouse 中建模数据。| | [附录](/migrations/postgresql/appendix)| 迁移 PostgreSQL 相关的附加信息| diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/02_postgres/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/02_postgres/index.md.hash new file mode 100644 index 00000000000..cbdffb563ed --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/02_postgres/index.md.hash @@ -0,0 +1 @@ +b76005a88913c21b diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/02_postgres/migration_guide/01_migration_guide_part1.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/02_postgres/migration_guide/01_migration_guide_part1.md new file mode 100644 index 00000000000..ba6e0b81772 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/02_postgres/migration_guide/01_migration_guide_part1.md @@ -0,0 +1,190 @@ +--- +'slug': '/migrations/postgresql/dataset' +'title': '迁移数据' +'description': '示例数据集从 PostgreSQL 迁移至 ClickHouse' +'keywords': +- 'Postgres' +'show_related_blogs': true +'sidebar_label': '第 1 部分' +'doc_type': 'guide' +--- + +import postgres_stackoverflow_schema from '@site/static/images/migrations/postgres-stackoverflow-schema.png'; +import Image from '@theme/IdealImage'; + +> 这是关于从 PostgreSQL 迁移到 ClickHouse 的指南的 **第一部分**。通过一个实际示例,它演示了如何高效地使用实时复制 (CDC) 方法进行迁移。所涵盖的许多概念同样适用于从 PostgreSQL 到 ClickHouse 的手动批量数据传输。 + +## 数据集 {#dataset} + +作为展示从 Postgres 到 ClickHouse 典型迁移的示例数据集,我们使用 Stack Overflow 数据集,该数据集的详细信息记录在 [这里](/getting-started/example-datasets/stackoverflow)。它包含了从 2008 年到 2024 年 4 月在 Stack Overflow 上发生的每个 `post`、`vote`、`user`、`comment` 和 `badge`。 PostgreSQL 的此数据的模式如下所示: + +PostgreSQL Stack Overflow schema + +*在 PostgreSQL 中创建表的 DDL 命令可在 [这里](https://pastila.nl/?001c0102/eef2d1e4c82aab78c4670346acb74d83#TeGvJWX9WTA1V/5dVVZQjg==) 获取。* + +这个模式虽然不一定是最优的,但利用了一些流行的 PostgreSQL 特性,包括主键、外键、分区和索引。 + +我们将把这些概念迁移到它们在 ClickHouse 中的等效项。 + +对于那些希望将此数据集填充到 PostgreSQL 实例中以测试迁移步骤的用户,我们提供了以 `pg_dump` 格式下载的数据以及 DDL,而后续数据加载命令如下所示: + +```bash + +# users +wget https://datasets-documentation.s3.eu-west-3.amazonaws.com/stackoverflow/pdump/2024/users.sql.gz +gzip -d users.sql.gz +psql < users.sql + + +# posts +wget https://datasets-documentation.s3.eu-west-3.amazonaws.com/stackoverflow/pdump/2024/posts.sql.gz +gzip -d posts.sql.gz +psql < posts.sql + + +# posthistory +wget https://datasets-documentation.s3.eu-west-3.amazonaws.com/stackoverflow/pdump/2024/posthistory.sql.gz +gzip -d posthistory.sql.gz +psql < posthistory.sql + + +# comments +wget https://datasets-documentation.s3.eu-west-3.amazonaws.com/stackoverflow/pdump/2024/comments.sql.gz +gzip -d comments.sql.gz +psql < comments.sql + + +# votes +wget https://datasets-documentation.s3.eu-west-3.amazonaws.com/stackoverflow/pdump/2024/votes.sql.gz +gzip -d votes.sql.gz +psql < votes.sql + + +# badges +wget https://datasets-documentation.s3.eu-west-3.amazonaws.com/stackoverflow/pdump/2024/badges.sql.gz +gzip -d badges.sql.gz +psql < badges.sql + + +# postlinks +wget https://datasets-documentation.s3.eu-west-3.amazonaws.com/stackoverflow/pdump/2024/postlinks.sql.gz +gzip -d postlinks.sql.gz +psql < postlinks.sql +``` + +对于 ClickHouse 来说,这个数据集虽然较小,但对于 Postgres 来说却相当庞大。上述内容代表了覆盖 2024 年前三个月的一个子集。 + +> 虽然我们的示例结果使用完整数据集来显示 Postgres 和 ClickHouse 之间的性能差异,但下面记录的所有步骤在功能上与较小的子集是相同的。希望将完整数据集加载到 Postgres 中的用户可见 [这里](https://pastila.nl/?00d47a08/1c5224c0b61beb480539f15ac375619d#XNj5vX3a7ZjkdiX7In8wqA==)。由于上述模式施加的外键约束,PostgreSQL 的完整数据集仅包含满足引用完整性的行。如果需要,可以直接将没有这种约束的 [Parquet 版本](/getting-started/example-datasets/stackoverflow) 轻松加载到 ClickHouse 中。 + +## 迁移数据 {#migrating-data} + +### 实时复制 (CDC) {#real-time-replication-or-cdc} + +请参见此 [指南](/integrations/clickpipes/postgres) 以设置 PostgreSQL 的 ClickPipes。该指南涵盖许多不同类型的源 Postgres 实例。 + +使用 ClickPipes 或 PeerDB 的 CDC 方法,PostgreSQL 数据库中的每个表都将自动复制到 ClickHouse。 + +为了在近实时中处理更新和删除,ClickPipes 将 Postgres 表映射到 ClickHouse,使用专门设计用于处理 ClickHouse 中的更新和删除的 [ReplacingMergeTree](/engines/table-engines/mergetree-family/replacingmergetree) 引擎。有关数据如何通过 ClickPipes 复制到 ClickHouse 的更多信息,请查看 [这里](/integrations/clickpipes/postgres/deduplication#how-does-data-get-replicated)。重要的是要注意,使用 CDC 进行复制时,在复制更新或删除操作时,ClickHouse 会创建重复的行。请查看 [使用 FINAL](https://clickhouse.com/docs/sql-reference/statements/select/from#final-modifier) 修饰符处理这些内容的 [技术](/integrations/clickpipes/postgres/deduplication#deduplicate-using-final-keyword) 。 + +让我们看看如何使用 ClickPipes 在 ClickHouse 中创建表 `users`。 + +```sql +CREATE TABLE users +( + `id` Int32, + `reputation` String, + `creationdate` DateTime64(6), + `displayname` String, + `lastaccessdate` DateTime64(6), + `aboutme` String, + `views` Int32, + `upvotes` Int32, + `downvotes` Int32, + `websiteurl` String, + `location` String, + `accountid` Int32, + `_peerdb_synced_at` DateTime64(9) DEFAULT now64(), + `_peerdb_is_deleted` Int8, + `_peerdb_version` Int64 +) +ENGINE = ReplacingMergeTree(_peerdb_version) +PRIMARY KEY id +ORDER BY id; +``` + +一旦设置完成,ClickPipes 将开始将所有数据从 PostgreSQL 迁移到 ClickHouse。根据网络和部署的大小,这对于 Stack Overflow 数据集只需几分钟的时间。 + +### 手动批量加载与定期更新 {#initial-bulk-load-with-periodic-updates} + +使用手动方法,可以通过以下方式实现数据集的初始批量加载: + +- **表函数** - 使用 ClickHouse 中的 [Postgres 表函数](/sql-reference/table-functions/postgresql) 从 Postgres `SELECT` 数据并 `INSERT` 到 ClickHouse 表中。适用于导入几百 GB 的数据集的批量加载。 +- **导出** - 导出到中间格式,如 CSV 或 SQL 脚本文件。这些文件可以从客户端通过 `INSERT FROM INFILE` 子句加载到 ClickHouse 中,或者使用对象存储及其相关函数,如 s3、gcs。 + +在从 PostgreSQL 手动加载数据时,您需要先在 ClickHouse 中创建表。请参阅此 [数据建模文档](/data-modeling/schema-design#establish-initial-schema),它使用 Stack Overflow 数据集来优化 ClickHouse 中的表模式。 + +PostgreSQL 与 ClickHouse 之间的数据类型可能不同。为了确定每个表列的等效类型,我们可以使用 `DESCRIBE` 命令和 [Postgres 表函数](/sql-reference/table-functions/postgresql)。以下命令描述 PostgreSQL 中的 `posts` 表,请根据您的环境进行修改: + +```sql title="Query" +DESCRIBE TABLE postgresql(':', 'postgres', 'posts', '', '') +SETTINGS describe_compact_output = 1 +``` + +有关 PostgreSQL 和 ClickHouse 之间数据类型映射的概述,请参阅 [附录文档](/migrations/postgresql/appendix#data-type-mappings)。 + +优化此模式的数据类型的步骤与从其他来源(例如 S3 上的 Parquet)加载数据时的步骤相同。在此 [使用 Parquet 的备用指南](/data-modeling/schema-design) 中描述的过程,将产生以下模式: + +```sql title="Query" +CREATE TABLE stackoverflow.posts +( + `Id` Int32, + `PostTypeId` Enum('Question' = 1, 'Answer' = 2, 'Wiki' = 3, 'TagWikiExcerpt' = 4, 'TagWiki' = 5, 'ModeratorNomination' = 6, 'WikiPlaceholder' = 7, 'PrivilegeWiki' = 8), + `AcceptedAnswerId` UInt32, + `CreationDate` DateTime, + `Score` Int32, + `ViewCount` UInt32, + `Body` String, + `OwnerUserId` Int32, + `OwnerDisplayName` String, + `LastEditorUserId` Int32, + `LastEditorDisplayName` String, + `LastEditDate` DateTime, + `LastActivityDate` DateTime, + `Title` String, + `Tags` String, + `AnswerCount` UInt16, + `CommentCount` UInt8, + `FavoriteCount` UInt8, + `ContentLicense`LowCardinality(String), + `ParentId` String, + `CommunityOwnedDate` DateTime, + `ClosedDate` DateTime +) +ENGINE = MergeTree +ORDER BY tuple() +COMMENT 'Optimized types' +``` + +我们可以用简单的 `INSERT INTO SELECT` 填充它,从 PostgreSQL 读取数据并插入到 ClickHouse: + +```sql title="Query" +INSERT INTO stackoverflow.posts SELECT * FROM postgresql(':', 'postgres', 'posts', '', '') +0 rows in set. Elapsed: 146.471 sec. Processed 59.82 million rows, 83.82 GB (408.40 thousand rows/s., 572.25 MB/s.) +``` + +增量加载也可以调度。如果 Postgres 表仅接收插入并且存在递增的 id 或时间戳,用户可以使用上述表函数方法加载增量,即可以在 `SELECT` 中应用 `WHERE` 子句。这种方法也可以用于支持更新,如果这些更新确保会修改相同的列。然而,支持删除则需要完全重新加载,随着表的增长,这可能会很难实现。 + +我们通过使用 `CreationDate`(我们假设如果行被更新,则此字段也会更新)来展示初始加载和增量加载。 + +```sql +-- initial load +INSERT INTO stackoverflow.posts SELECT * FROM postgresql('', 'postgres', 'posts', 'postgres', '', 'postgres', 'posts', 'postgres', ' ( SELECT (max(CreationDate) FROM stackoverflow.posts) +``` + +> ClickHouse 将下推简单的 `WHERE` 子句,例如 `=`、`!=`、`>`、`>=`、`<`、`<=` 和 IN 到 PostgreSQL 服务器。因此,通过确保在用于识别更改集的列上存在索引,可以使增量加载更高效。 + +> 使用查询复制时检测 UPDATE 操作的一种可能方法是使用 [`XMIN` 系统列](https://www.postgresql.org/docs/9.1/ddl-system-columns.html)(事务 ID)作为水印 - 此列的变化意味着更改,因此可以应用到目标表。使用此方法的用户应意识到 `XMIN` 值可能会环绕,并且比较需要完全扫描表,使跟踪更改变得更加复杂。 + +[点击这里查看第二部分](/migrations/postgresql/rewriting-queries) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/02_postgres/migration_guide/01_migration_guide_part1.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/02_postgres/migration_guide/01_migration_guide_part1.md.hash new file mode 100644 index 00000000000..69273c46952 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/02_postgres/migration_guide/01_migration_guide_part1.md.hash @@ -0,0 +1 @@ +348ac3e0c6cae337 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/migrations/postgres/rewriting-queries.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/02_postgres/migration_guide/02_migration_guide_part2.md similarity index 77% rename from i18n/zh/docusaurus-plugin-content-docs/current/migrations/postgres/rewriting-queries.md rename to i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/02_postgres/migration_guide/02_migration_guide_part2.md index 03bc5ba4e23..5090138fb01 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/migrations/postgres/rewriting-queries.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/02_postgres/migration_guide/02_migration_guide_part2.md @@ -5,30 +5,32 @@ - 'postgres' - 'postgresql' - 'rewriting queries' -'description': '从 PostgreSQL 迁移到 ClickHouse 的指南第二部分' +'description': '关于从 PostgreSQL 迁移到 ClickHouse 的指南的第 2 部分' +'sidebar_label': '第 2 部分' +'doc_type': 'guide' --- -> 这是关于从 PostgreSQL 迁移到 ClickHouse 的指南的 **第二部分**。通过一个实际的例子,它演示了如何高效地进行实时复制(CDC)方式的迁移。许多涵盖的概念同样适用于从 PostgreSQL 到 ClickHouse 的手动批量数据传输。 +> 这是将 PostgreSQL 迁移到 ClickHouse 的指南的 **第二部分**。通过一个实际的示例,它演示了如何使用实时复制 (CDC) 方法高效地完成迁移。许多涵盖的概念也适用于从 PostgreSQL 到 ClickHouse 的手动批量数据传输。 -您 PostgreSQL 设置中的大多数 SQL 查询应在 ClickHouse 中无需修改地运行,并且执行速度可能更快。 +您的 PostgreSQL 设置中的大多数 SQL 查询在 ClickHouse 中应该可以无修改地运行,并且执行速度更快。 -## 使用 CDC 的去重 {#deduplication-cdc} +## 使用 CDC 进行去重 {#deduplication-cdc} -在使用实时复制和 CDC 时,请记住,更新和删除可能会导致重复行。为了管理这一点,您可以使用涉及视图和可刷新的物化视图的技术。 +在使用 CDC 进行实时复制时,请注意,更新和删除可能导致重复行。为了解决这个问题,您可以使用涉及视图和可刷新的物化视图的技术。 -请参阅本[指南](/integrations/clickpipes/postgres/deduplication#query-like-with-postgres),了解如何在使用实时复制和 CDC 迁移时以最小的摩擦将您的应用程序从 PostgreSQL 迁移到 ClickHouse。 +请参考本 [指南](/integrations/clickpipes/postgres/deduplication#query-like-with-postgres),了解如何在使用实时复制和 CDC 进行迁移时,将您的应用程序从 PostgreSQL 迁移到 ClickHouse,降低摩擦。 ## 在 ClickHouse 中优化查询 {#optimize-queries-in-clickhouse} -虽然可以在最小查询重写的情况下进行迁移,建议利用 ClickHouse 的特性以显著简化查询并进一步提高查询性能。 +虽然可以在最小查询重写的情况下进行迁移,但建议利用 ClickHouse 的特性显著简化查询并进一步改善查询性能。 -这里的例子涵盖了常见的查询模式,并展示了如何使用 ClickHouse 对其进行优化。它们使用了完整的[Stack Overflow 数据集](/getting-started/example-datasets/stackoverflow)(截至 2024 年 4 月)与 PostgreSQL 和 ClickHouse 中的等效资源(8 核心,32GiB 内存)。 +这里的示例涵盖了常见的查询模式,并展示了如何在 ClickHouse 中优化它们。它们使用完整的 [Stack Overflow 数据集](/getting-started/example-datasets/stackoverflow)(截至 2024 年 4 月)在 PostgreSQL 和 ClickHouse 中的等效资源(8 核心,32GiB 内存)。 -> 为了简单起见,下面的查询省略了去重数据的技术。 +> 为了简单起见,下面的查询省略了使用数据去重的技术。 -> 此处的计数会略有不同,因为 PostgreSQL 数据仅包含满足外键参照完整性的行。ClickHouse 不施加此类约束,因此具有完整的数据集,例如包括匿名用户。 +> 此处的计数会略有不同,因为 PostgreSQL 数据仅包含满足外键引用完整性的行。ClickHouse 不强加这样的约束,因此拥有完整的数据集,例如,包括匿名用户。 -用户(提问超过 10 个)中获得最多浏览量的: +用户(提问超过 10 个)中获得最多浏览量的用户: ```sql -- ClickHouse @@ -73,7 +75,7 @@ LIMIT 5; Time: 107620.508 ms (01:47.621) ``` -哪些 `tags` 获得了最多的 `views`: +哪些 `tags` 收到的 `views` 最多: ```sql --ClickHouse @@ -131,7 +133,7 @@ Time: 112508.083 ms (01:52.508) **聚合函数** -用户在可能的情况下应利用 ClickHouse 聚合函数。下面我们展示了使用[argMax](/sql-reference/aggregate-functions/reference/argmax)函数来计算每年查看次数最多的问题。 +在可能的情况下,用户应利用 ClickHouse 的聚合函数。下面我们展示了使用 [argMax](/sql-reference/aggregate-functions/reference/argmax) 函数来计算每年最受欢迎的问题。 ```sql --ClickHouse @@ -173,7 +175,7 @@ MaxViewCount: 66975 Peak memory usage: 554.31 MiB. ``` -这比对应的 PostgreSQL 查询显著简单(且更快): +这比等效的 PostgreSQL 查询显著更简单(且更快): ```sql --Postgres @@ -209,7 +211,7 @@ Time: 125822.015 ms (02:05.822) **条件和数组** -条件和数组函数使查询显著简化。以下查询计算了从 2022 年到 2023 年增幅最大的标签(出现超过 10000 次)。请注意,由于条件、数组函数的存在以及在 HAVING 和 SELECT 子句中重用别名的能力,下面的 ClickHouse 查询非常简洁。 +条件和数组函数使查询简单得多。以下查询计算了 2022 年到 2023 年之间出现超过 10000 次的标签,其百分比增长最大。请注意,以下的 ClickHouse 查询因条件、数组函数以及在 HAVING 和 SELECT 子句中重用别名的能力而变得简明扼要。 ```sql --ClickHouse @@ -272,4 +274,4 @@ LIMIT 5; Time: 116750.131 ms (01:56.750) ``` -[点击这里查看第三部分](./data-modeling-techniques.md) +[单击这里访问第三部分](/migrations/postgresql/data-modeling-techniques) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/02_postgres/migration_guide/02_migration_guide_part2.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/02_postgres/migration_guide/02_migration_guide_part2.md.hash new file mode 100644 index 00000000000..218600402ee --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/02_postgres/migration_guide/02_migration_guide_part2.md.hash @@ -0,0 +1 @@ +cf2918e4831a135d diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/02_postgres/migration_guide/03_migration_guide_part3.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/02_postgres/migration_guide/03_migration_guide_part3.md new file mode 100644 index 00000000000..840b256f5d5 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/02_postgres/migration_guide/03_migration_guide_part3.md @@ -0,0 +1,270 @@ +--- +'slug': '/migrations/postgresql/data-modeling-techniques' +'title': '数据建模技术' +'description': '关于从 PostgreSQL 迁移到 ClickHouse 的指南第 3 部分' +'keywords': +- 'postgres' +- 'postgresql' +'show_related_blogs': true +'sidebar_label': '第 3 部分' +'doc_type': 'guide' +--- + +import postgres_b_tree from '@site/static/images/migrations/postgres-b-tree.png'; +import postgres_sparse_index from '@site/static/images/migrations/postgres-sparse-index.png'; +import postgres_partitions from '@site/static/images/migrations/postgres-partitions.png'; +import postgres_projections from '@site/static/images/migrations/postgres-projections.png'; +import Image from '@theme/IdealImage'; + +> 这是关于从 PostgreSQL 迁移到 ClickHouse 的指南的 **第 3 部分**。通过一个实际的例子,它演示了如果从 PostgreSQL 迁移,如何在 ClickHouse 中建模数据。 + +我们建议从 Postgres 迁移的用户阅读 [ClickHouse 中建模数据的指南](/data-modeling/schema-design)。本指南使用相同的 Stack Overflow 数据集,并探索了多种利用 ClickHouse 特性的不同方法。 + +## ClickHouse 中的主键(排序键) {#primary-ordering-keys-in-clickhouse} + +来自 OLTP 数据库的用户通常会寻找 ClickHouse 中的等效概念。在注意到 ClickHouse 支持 `PRIMARY KEY` 语法时,用户可能会倾向于使用与其源 OLTP 数据库相同的键来定义表模式。这并不合适。 + +### ClickHouse 主键有何不同? {#how-are-clickhouse-primary-keys-different} + +为了理解为什么在 ClickHouse 中使用 OLTP 主键不合适,用户应该了解 ClickHouse 索引的基础知识。我们以 Postgres 作为比较的例子,但这些一般概念适用于其他 OLTP 数据库。 + +- Postgres 主键根据定义,每行都是唯一的。使用 [B-树结构](/guides/best-practices/sparse-primary-indexes#an-index-design-for-massive-data-scales) 允许通过该键高效查找单行。虽然 ClickHouse 可以优化单行值的查找,但分析工作负载通常需要读取少量列但处理许多行。过滤器更常需要识别 **一部分行**,以便进行聚合处理。 +- 内存和磁盘效率在 ClickHouse 通常使用的规模中至关重要。数据以称为部分的块写入 ClickHouse 表,同时应用后台合并部分的规则。在 ClickHouse 中,每个部分都有自己独立的主索引。当部分被合并时,合并部分的主索引也会合并。与 Postgres 不同,这些索引不是为每行构建的。相反,一个部分的主索引为每组行有一个索引条目——该技术称为 **稀疏索引**。 +- **稀疏索引** 是可能的,因为 ClickHouse 将部分的行根据指定的键有序存储在磁盘上。与直接定位单行不同(如基于 B-树的索引),稀疏主索引允许它通过索引条目上的二分查找快速识别可能匹配查询的行组。定位到的潜在匹配行组随后会并行流入 ClickHouse 引擎以查找匹配项。此索引设计允许主索引变小(它完全适合主内存),同时仍显著加快查询执行时间,特别是在数据分析用例中典型的范围查询时。 + +要获取更多细节,我们推荐查看该 [深入指南](/guides/best-practices/sparse-primary-indexes)。 + +PostgreSQL B-Tree Index + +PostgreSQL Sparse Index + +在 ClickHouse 中选择的键不仅会确定索引,还会确定数据在磁盘上的写入顺序。因此,它可以显著影响压缩级别,这反过来又会影响查询性能。导致大多数列值以连续顺序写入的排序键,将允许所选的压缩算法(和编解码器)更有效地压缩数据。 + +> 表中的所有列都会根据指定排序键的值进行排序,无论它们是否包含在键中。例如,如果 `CreationDate` 被用作键,则其他所有列中值的顺序将与 `CreationDate` 列中的值的顺序相对应。可以指定多个排序键——这将以与 `SELECT` 查询中的 `ORDER BY` 子句相同的语义进行排序。 + +### 选择排序键 {#choosing-an-ordering-key} + +有关选择排序键的考虑因素和步骤,以帖子表为例,请参见 [此处](/data-modeling/schema-design#choosing-an-ordering-key)。 + +使用带有 CDC 的实时复制时,还需考虑其他约束,请参阅该 [文档](/integrations/clickpipes/postgres/ordering_keys),了解如何使用 CDC 自定义排序键的技术。 + +## 分区 {#partitions} + +Postgres 用户会熟悉表分区的概念,通过将表划分为更小、更易管理的部分来增强大型数据库的性能和可管理性。这种分区可以通过在指定列(例如,日期)上定义范围、定义列表或通过键的哈希来实现。这使得管理员可以根据特定标准(如日期范围或地理位置)组织数据。分区有助于通过启用更快的数据访问(通过分区裁剪)和更有效的索引来提高查询性能。它还通过允许对单个分区而不是整个表进行操作,帮助维护任务,例如备份和数据清理。此外,分区可以通过在多个分区之间分配负载显著提高 PostgreSQL 数据库的可扩展性。 + +在 ClickHouse 中,分区在表最初通过 `PARTITION BY` 子句定义时指定。该子句可以包含任何列的 SQL 表达式,其结果将定义一行发送到哪个分区。 + +PostgreSQL partitions to ClickHouse partitions + +数据部分在磁盘上与每个分区逻辑关联,并可以单独查询。在下面的例子中,我们使用表达式 `toYear(CreationDate)` 按年对 `posts` 表进行分区。当行插入到 ClickHouse 时,将针对每行评估此表达式,并在存在分区时路由到结果分区(如果该行是某一年的第一行,则该分区将被创建)。 + +```sql + CREATE TABLE posts +( + `Id` Int32 CODEC(Delta(4), ZSTD(1)), + `PostTypeId` Enum8('Question' = 1, 'Answer' = 2, 'Wiki' = 3, 'TagWikiExcerpt' = 4, 'TagWiki' = 5, 'ModeratorNomination' = 6, 'WikiPlaceholder' = 7, 'PrivilegeWiki' = 8), + `AcceptedAnswerId` UInt32, + `CreationDate` DateTime64(3, 'UTC'), +... + `ClosedDate` DateTime64(3, 'UTC') +) +ENGINE = MergeTree +ORDER BY (PostTypeId, toDate(CreationDate), CreationDate) +PARTITION BY toYear(CreationDate) +``` + +有关分区的完整描述,请参见 ["表分区"](/partitions)。 + +### 分区的应用 {#applications-of-partitions} + +ClickHouse 中的分区与 Postgres 中的应用相似,但有一些细微差别。更具体地说: + +- **数据管理** - 在 ClickHouse 中,用户应主要将分区视为数据管理特性,而不是查询优化技术。通过根据键逻辑分离数据,可以独立操作每个分区,例如删除。这使得用户能够高效地在 [存储层](/integrations/s3#storage-tiers) 之间移动分区,进而移动子集,或者 [过期数据/有效地从集群中删除](/sql-reference/statements/alter/partition)。例如,在下面的案例中,我们删除 2008 年的帖子。 + +```sql +SELECT DISTINCT partition +FROM system.parts +WHERE `table` = 'posts' + +┌─partition─┐ +│ 2008 │ +│ 2009 │ +│ 2010 │ +│ 2011 │ +│ 2012 │ +│ 2013 │ +│ 2014 │ +│ 2015 │ +│ 2016 │ +│ 2017 │ +│ 2018 │ +│ 2019 │ +│ 2020 │ +│ 2021 │ +│ 2022 │ +│ 2023 │ +│ 2024 │ +└───────────┘ + +17 rows in set. Elapsed: 0.002 sec. + +ALTER TABLE posts +(DROP PARTITION '2008') + +Ok. + +0 rows in set. Elapsed: 0.103 sec. +``` + +- **查询优化** - 尽管分区可以帮助提升查询性能,但这在很大程度上依赖于访问模式。如果查询仅针对少数分区(理想情况下是一个),性能可能会有所提升。这通常只有在分区键不在主键中,且你按照该键进行过滤时才有效。然而,需要覆盖多个分区的查询可能性能较差,这可能是因为由于分区产生更多部分。针对单一区域的目标的好处在分区键已在主键中占据前面位置时甚至更不明显。如果每个分区中的值是唯一的,分区还可以用来 [优化 GROUP BY 查询](/engines/table-engines/mergetree-family/custom-partitioning-key#group-by-optimisation-using-partition-key)。但通常,用户应确保主键经过优化,并且仅在访问模式访问具体可预测的子集(例如,按天分区,大部分查询在最后一天)时考虑分区作为查询优化技术。 + +### 对于分区的建议 {#recommendations-for-partitions} + +用户应将分区视为一种数据管理技术。当处理时间序列数据时,尤其是需要从集群中过期数据时是理想的,例如,可以 [简便地删除](https://www.baidu.com) 最古老的分区(/sql-reference/statements/alter/partition#drop-partitionpart)。 + +**重要**:确保你的分区键表达式不会导致高基数集,即应避免创建超过 100 个分区。例如,不要通过客户端标识符或名称等高基数字段对数据进行分区。相反,使用客户端标识符或名称作为 `ORDER BY` 表达式中的首列。 + +> 内部上, ClickHouse [为插入的数据创建部分](/guides/best-practices/sparse-primary-indexes#clickhouse-index-design)。随着更多数据的插入,部分数量增加。为了防止过多的部分导致查询性能下降(需要读取更多文件),部分在后台异步进程中被合并。如果部分的数量超过预配置的限制,则 ClickHouse 在插入时会抛出异常—作为“部分太多”的错误。在正常操作下不会发生这种情况,仅在 ClickHouse 配置错误或使用不当时(例如,大量小插入)才会发生。 + +> 由于部分是在每个分区中独立创建的,增加分区的数量会导致部分数增加,即是分区数量的倍数。因此,高基数的分区键可能引发此错误,需予以避免。 + +## 物化视图与投影 {#materialized-views-vs-projections} + +Postgres 允许在单个表上创建多个索引,以优化各种访问模式。这种灵活性使管理员和开发人员能够根据特定的查询和操作需求调整数据库性能。 ClickHouse 的投影概念虽然与此并不完全相同,但允许用户为表指定多个 `ORDER BY` 子句。 + +在 ClickHouse [数据建模文档](/data-modeling/schema-design) 中,我们探讨了如何在 ClickHouse 中使用物化视图来预计算聚合、转换行,并针对不同的访问模式优化查询。 + +对于最后一个例子,我们提供了 [一个示例](/materialized-view/incremental-materialized-view#lookup-table),其中物化视图将行发送到目标表,并具有与原始接收插入的表不同的排序键。 + +例如,考虑以下查询: + +```sql +SELECT avg(Score) +FROM comments +WHERE UserId = 8592047 + + ┌──────────avg(Score)─┐ +1. │ 0.18181818181818182 │ + └─────────────────────┘ + +1 row in set. Elapsed: 0.040 sec. Processed 90.38 million rows, 361.59 MB (2.25 billion rows/s., 9.01 GB/s.) +Peak memory usage: 201.93 MiB. +``` + +该查询要求扫描所有 9000 万行(虽然速度很快),因为 `UserId` 不是排序键。之前,我们通过一个作为 `PostId` 查找的物化视图解决了这个问题。相同的问题可以通过 [投影](/data-modeling/projections) 来解决。下面的命令为 `ORDER BY user_id` 添加了一个投影。 + +```sql +ALTER TABLE comments ADD PROJECTION comments_user_id ( +SELECT * ORDER BY UserId +) + +ALTER TABLE comments MATERIALIZE PROJECTION comments_user_id +``` + +请注意,我们必须先创建该投影,然后对其进行物化。该后续命令将导致数据在磁盘上以两种不同的顺序存储两次。投影也可以在创建数据时定义,如下所示,并在数据插入时自动维护。 + +```sql +CREATE TABLE comments +( + `Id` UInt32, + `PostId` UInt32, + `Score` UInt16, + `Text` String, + `CreationDate` DateTime64(3, 'UTC'), + `UserId` Int32, + `UserDisplayName` LowCardinality(String), + PROJECTION comments_user_id + ( + SELECT * + ORDER BY UserId + ) +) +ENGINE = MergeTree +ORDER BY PostId +``` + +如果通过 `ALTER` 创建投影,则在发出 `MATERIALIZE PROJECTION` 命令时,创建是异步的。用户可以使用以下查询确认该操作的进度,等待 `is_done=1`。 + +```sql +SELECT + parts_to_do, + is_done, + latest_fail_reason +FROM system.mutations +WHERE (`table` = 'comments') AND (command LIKE '%MATERIALIZE%') + + ┌─parts_to_do─┬─is_done─┬─latest_fail_reason─┐ +1. │ 1 │ 0 │ │ + └─────────────┴─────────┴────────────────────┘ + +1 row in set. Elapsed: 0.003 sec. +``` + +如果我们重复上述查询,我们可以看到性能显著提高,虽然增加了存储成本。 + +```sql +SELECT avg(Score) +FROM comments +WHERE UserId = 8592047 + + ┌──────────avg(Score)─┐ +1. │ 0.18181818181818182 │ + └─────────────────────┘ + +1 row in set. Elapsed: 0.008 sec. Processed 16.36 thousand rows, 98.17 KB (2.15 million rows/s., 12.92 MB/s.) +Peak memory usage: 4.06 MiB. +``` + +通过 `EXPLAIN` 命令,我们还确认使用了投影来处理此查询: + +```sql +EXPLAIN indexes = 1 +SELECT avg(Score) +FROM comments +WHERE UserId = 8592047 + + ┌─explain─────────────────────────────────────────────┐ + 1. │ Expression ((Projection + Before ORDER BY)) │ + 2. │ Aggregating │ + 3. │ Filter │ + 4. │ ReadFromMergeTree (comments_user_id) │ + 5. │ Indexes: │ + 6. │ PrimaryKey │ + 7. │ Keys: │ + 8. │ UserId │ + 9. │ Condition: (UserId in [8592047, 8592047]) │ +10. │ Parts: 2/2 │ +11. │ Granules: 2/11360 │ + └─────────────────────────────────────────────────────┘ + +11 rows in set. Elapsed: 0.004 sec. +``` + +### 何时使用投影 {#when-to-use-projections} + +对于新用户而言,投影是一项吸引人的特性,因为随着数据的插入,它们会自动维护。此外,查询可以仅发送到单个表,并根据可能的情况利用投影来加快响应时间。 + +PostgreSQL projections in ClickHouse + +与物化视图不同,后者用户必须根据过滤条件选择适当的优化目标表或重写查询。这对用户应用程序施加了更大的强调,并增加了客户端的复杂性。 + +尽管有这些优势,投影也有一些 [固有的限制](/data-modeling/projections#when-to-use-projections),用户应注意,因此应谨慎部署。 + +我们建议在以下情况下使用投影: + +- 需要对数据进行全面重新排序。虽然投影中的表达式理论上可以使用 `GROUP BY`,但物化视图更有效地维护聚合。查询优化器也更可能利用使用简单重新排序的投影,即 `SELECT * ORDER BY x`。用户可以在该表达式中选择一部分列,以减小存储占用。 +- 用户对相关的存储占用增加和双重写入数据的开销感到满意。测试对插入速度的影响,并 [评估存储开销](/data-compression/compression-in-clickhouse)。 + +:::note +自 25.5 版以来, ClickHouse 在投影中支持虚拟列 `_part_offset` ,这开启了一种更节省空间的投影存储方式。 + +有关更多细节,请参见 ["投影"](/data-modeling/projections) +::: + +## 反规范化 {#denormalization} + +由于 Postgres 是关系数据库,因此其数据模型通常高度 [规范化](https://en.wikipedia.org/wiki/Database_normalization),通常涉及数百个表。在 ClickHouse 中,反规范化有时可以提高 JOIN 性能。 + +你可以参考该 [指南](/data-modeling/denormalization),展示在 ClickHouse 中反规范化 Stack Overflow 数据集的好处。 + +这结束了我们为从 Postgres 迁移到 ClickHouse 的用户准备的基本指南。我们建议从 Postgres 迁移的用户阅读 [ClickHouse 中建模数据的指南](/data-modeling/schema-design),以了解更多关于 ClickHouse 高级特性的内容。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/02_postgres/migration_guide/03_migration_guide_part3.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/02_postgres/migration_guide/03_migration_guide_part3.md.hash new file mode 100644 index 00000000000..3c565131b82 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/02_postgres/migration_guide/03_migration_guide_part3.md.hash @@ -0,0 +1 @@ +d80cc736b9d77113 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/02_postgres/migration_guide/_category_.json b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/02_postgres/migration_guide/_category_.json new file mode 100644 index 00000000000..ad514aeb890 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/02_postgres/migration_guide/_category_.json @@ -0,0 +1,5 @@ +{ + "label": "Migration guide", + "collapsible": true, + "collapsed": true, +} \ No newline at end of file diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/03_bigquery/01_overview.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/03_bigquery/01_overview.md new file mode 100644 index 00000000000..721fb274cba --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/03_bigquery/01_overview.md @@ -0,0 +1,482 @@ +--- +'title': 'BigQuery vs ClickHouse Cloud' +'slug': '/migrations/bigquery/biquery-vs-clickhouse-cloud' +'description': 'BigQuery 如何与 ClickHouse Cloud 不同' +'keywords': +- 'BigQuery' +'show_related_blogs': true +'sidebar_label': '概述' +'doc_type': 'guide' +--- + +import bigquery_1 from '@site/static/images/migrations/bigquery-1.png'; +import Image from '@theme/IdealImage'; + + +# 比较 ClickHouse Cloud 和 BigQuery + +## 资源组织 {#resource-organization} + +ClickHouse Cloud 中资源的组织方式类似于 [BigQuery 的资源层次结构](https://cloud.google.com/bigquery/docs/resource-hierarchy)。我们根据下面的图示描述具体的差异,展示 ClickHouse Cloud 的资源层次结构: + +资源组织 + +### 组织 {#organizations} + +与 BigQuery 相似,组织是 ClickHouse Cloud 资源层次结构中的根节点。在您的 ClickHouse Cloud 账户中设置的第一个用户会自动分配到由该用户拥有的组织中。该用户可以邀请其他用户加入该组织。 + +### BigQuery 项目与 ClickHouse Cloud 服务 {#bigquery-projects-vs-clickhouse-cloud-services} + +在组织内部,您可以创建大致相当于 BigQuery 项目的服务,因为在 ClickHouse Cloud 中存储的数据与服务相关联。ClickHouse Cloud 中有 [几种服务类型可用](/cloud/manage/cloud-tiers)。每个 ClickHouse Cloud 服务在特定区域中部署,包括: + +1. 一组计算节点(当前,开发层服务为 2 个节点,生产层服务为 3 个节点)。对于这些节点,ClickHouse Cloud [支持垂直和水平扩展](/manage/scaling#how-scaling-works-in-clickhouse-cloud),支持手动和自动扩展。 +2. 一个对象存储文件夹,用于服务存储所有数据。 +3. 一个端点(或通过 ClickHouse Cloud UI 控制台创建的多个端点) - 您用来连接服务的服务 URL(例如,`https://dv2fzne24g.us-east-1.aws.clickhouse.cloud:8443`) + +### BigQuery 数据集与 ClickHouse Cloud 数据库 {#bigquery-datasets-vs-clickhouse-cloud-databases} + +ClickHouse 将表逻辑上分组到数据库中。与 BigQuery 数据集类似,ClickHouse 数据库是逻辑容器,用于组织和控制对表数据的访问。 + +### BigQuery 文件夹 {#bigquery-folders} + +ClickHouse Cloud 当前没有与 BigQuery 文件夹相对应的概念。 + +### BigQuery 插槽保留和配额 {#bigquery-slot-reservations-and-quotas} + +与 BigQuery 插槽保留类似,您可以在 ClickHouse Cloud 中 [配置垂直和水平自动扩展](/manage/scaling#configuring-vertical-auto-scaling)。对于垂直自动扩展,您可以设置服务的计算节点的内存和 CPU 核心的最小和最大大小。然后,服务将在这些范围内根据需要进行扩展。这些设置在初始服务创建流程中也可用。服务中的每个计算节点具有相同的大小。您可以通过 [水平扩展](/manage/scaling#manual-horizontal-scaling) 更改服务中的计算节点数量。 + +此外,类似于 BigQuery 配额,ClickHouse Cloud 提供并发控制、内存使用限制和 I/O 调度,允许用户将查询隔离到工作负载类别中。通过为特定工作负载类限制共享资源(CPU 核心、DRAM、磁盘和网络 I/O),确保这些查询不会影响其他关键业务查询。在并发查询数量较高的情况下,并发控制可防止线程过度分配。 + +ClickHouse 在服务器、用户和查询级别跟踪内存分配的字节大小,允许灵活的内存使用限制。内存过度分配使查询能够使用超出保证内存的额外空闲内存,同时确保其他查询的内存限制。此外,聚合、排序和连接子句的内存使用也可以被限制,当超过内存限制时,允许回退到外部算法。 + +最后,I/O 调度允许用户根据最大带宽、在途请求和策略限制工作负载类的本地和远程磁盘访问。 + +### 权限 {#permissions} + +ClickHouse Cloud [控制用户访问](/cloud/security/cloud-access-management) 有两个地方,通过 [云控制台](/cloud/get-started/sql-console) 和通过数据库。控制台访问是通过 [clickhouse.cloud](https://console.clickhouse.cloud) 用户界面进行管理的。数据库访问是通过数据库用户账户和角色进行管理的。此外,可以在数据库中授予控制台用户角色,使其能够通过我们的 [SQL 控制台](/integrations/sql-clients/sql-console) 与数据库交互。 + +## 数据类型 {#data-types} + +ClickHouse 在数值方面提供了更细粒度的精度。例如,BigQuery 提供的数值类型 [`INT64`,`NUMERIC`,`BIGNUMERIC` 和 `FLOAT64`](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#numeric_types)。与此相比,ClickHouse 为小数、浮点数和整数提供了多种精度类型。利用这些数据类型,ClickHouse 用户可以优化存储和内存开销,从而实现更快的查询和较低的资源消耗。以下是 BigQuery 类型与对应的 ClickHouse 类型的映射: + +| BigQuery | ClickHouse | +|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| [ARRAY](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#array_type) | [Array(t)](/sql-reference/data-types/array) | +| [NUMERIC](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#decimal_types) | [Decimal(P, S),Decimal32(S),Decimal64(S),Decimal128(S)](/sql-reference/data-types/decimal) | +| [BIG NUMERIC](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#decimal_types) | [Decimal256(S)](/sql-reference/data-types/decimal) | +| [BOOL](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#boolean_type) | [Bool](/sql-reference/data-types/boolean) | +| [BYTES](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#bytes_type) | [FixedString](/sql-reference/data-types/fixedstring) | +| [DATE](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#date_type) | [Date32](/sql-reference/data-types/date32) (范围更小) | +| [DATETIME](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#datetime_type) | [DateTime](/sql-reference/data-types/datetime),[DateTime64](/sql-reference/data-types/datetime64) (范围更小,精度更高) | +| [FLOAT64](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#floating_point_types) | [Float64](/sql-reference/data-types/float) | +| [GEOGRAPHY](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#geography_type) | [Geo 数据类型](/sql-reference/data-types/float) | +| [INT64](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#integer_types) | [UInt8,UInt16,UInt32,UInt64,UInt128,UInt256,Int8,Int16,Int32,Int64,Int128,Int256](/sql-reference/data-types/int-uint) | +| [INTERVAL](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#integer_types) | 不适用 - [作为表达式支持](/sql-reference/data-types/special-data-types/interval#usage-remarks) 或 [通过函数支持](/sql-reference/functions/date-time-functions#addYears) | +| [JSON](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#json_type) | [JSON](/integrations/data-formats/json/inference) | +| [STRING](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#string_type) | [String (bytes)](/sql-reference/data-types/string) | +| [STRUCT](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#constructing_a_struct) | [Tuple](/sql-reference/data-types/tuple),[Nested](/sql-reference/data-types/nested-data-structures/nested) | +| [TIME](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#time_type) | [DateTime64](/sql-reference/data-types/datetime64) | +| [TIMESTAMP](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#timestamp_type) | [DateTime64](/sql-reference/data-types/datetime64) | + +在 ClickHouse 类型的多个选项中,请考虑数据的实际范围并选择最低要求。此外,考虑利用 [适当的编解码器](https://clickhouse.com/blog/optimize-clickhouse-codecs-compression-schema) 进行进一步的压缩。 + +## 查询加速技术 {#query-acceleration-techniques} + +### 主键和外键及主索引 {#primary-and-foreign-keys-and-primary-index} + +在 BigQuery 中,表可以具有 [主键和外键约束](https://cloud.google.com/bigquery/docs/information-schema-table-constraints)。通常,主键和外键用于关系型数据库以确保数据完整性。主键值通常对每一行都是唯一的,并且不能为 `NULL`。在一行中的每个外键值必须存在于主键表的主键列中或者为 `NULL`。在 BigQuery 中,这些约束不会被强制执行,但查询优化器可能使用此信息来更好地优化查询。 + +在 ClickHouse 中,表也可以有主键。与 BigQuery 相同,ClickHouse 并不强制执行表的主键列值的唯一性。不像 BigQuery,表的数据在磁盘上根据主键列 [有序存储](/guides/best-practices/sparse-primary-indexes#optimal-compression-ratio-of-data-files)。查询优化器利用这种排序顺序来防止重新排序,尽量减少连接的内存使用,并启用限值子句的短路。与 BigQuery 不同,ClickHouse 自动根据主键列值创建 [(稀疏)主索引](/guides/best-practices/sparse-primary-indexes#an-index-design-for-massive-data-scales)。该索引用于加速所有包含对主键列的过滤条件的查询。目前,ClickHouse 不支持外键约束。 + +## 辅助索引(仅在 ClickHouse 可用) {#secondary-indexes-only-available-in-clickhouse} + +除了根据表的主键列值创建的主索引外,ClickHouse 还允许您在主键以外的列上创建辅助索引。ClickHouse 提供几种类型的辅助索引,每种索引都适用于不同类型的查询: + +- **布隆过滤器索引**: + - 用于加速具有相等条件的查询(例如,=,IN)。 + - 使用概率数据结构来确定值是否存在于数据块中。 +- **令牌布隆过滤器索引**: + - 类似于布隆过滤器索引,但用于标记字符串并适合全文搜索查询。 +- **最小-最大索引**: + - 为每个数据部分维护列的最小和最大值。 + - 有助于跳过读取不在指定范围内的数据部分。 + +## 搜索索引 {#search-indexes} + +类似于 BigQuery 中的 [搜索索引](https://cloud.google.com/bigquery/docs/search-index),可以为 ClickHouse 表的字符串值列创建 [全文索引](/engines/table-engines/mergetree-family/invertedindexes)。 + +## 向量索引 {#vector-indexes} + +BigQuery 最近推出了 [向量索引](https://cloud.google.com/bigquery/docs/vector-index) 作为预发布功能。同样,ClickHouse 也对加速 [向量搜索用例的索引](https://engines/table-engines/mergetree-family/annindexes) 提供实验性支持。 + +## 分区 {#partitioning} + +与 BigQuery 相似,ClickHouse 使用表分区来提升大型表的性能和可管理性,通过将表分成称为分区的小块,使其更易于管理。我们在 [此处](/engines/table-engines/mergetree-family/custom-partitioning-key) 详细描述 ClickHouse 分区。 + +## 聚类 {#clustering} + +通过聚类,BigQuery 根据指定几列的值自动对表数据进行排序,并将其放置在最佳大小的块中。聚类提高了查询性能,使 BigQuery 更好地估算运行查询的成本。使用聚类列,查询还消除了对不必要数据的扫描。 + +在 ClickHouse 中,数据会根据表的主键列 [自动聚类到磁盘上](/guides/best-practices/sparse-primary-indexes#optimal-compression-ratio-of-data-files),并在逻辑上以块组织,这些块可以通过利用主索引数据结构快速定位或修剪。 + +## 物化视图 {#materialized-views} + +无论是 BigQuery 还是 ClickHouse,都支持物化视图 – 基于对基础表的转换查询结果的预计算结果,以提高性能和效率。 + +## 查询物化视图 {#querying-materialized-views} + +BigQuery 物化视图可以直接查询或由优化器使用以处理对基础表的查询。如果对基础表的更改可能使物化视图失效,则数据将直接从基础表读取。如果对基础表的更改不会使物化视图失效,则其余数据将从物化视图中读取,仅更改部分将从基础表中读取。 + +在 ClickHouse 中,物化视图只能直接查询。然而,与 BigQuery (其中物化视图会在对基础表进行更改后在 5 分钟内自动刷新,但不会频繁于 [每 30 分钟](https://cloud.google.com/bigquery/docs/materialized-views-manage#refresh))相比,物化视图始终与基础表保持同步。 + +**更新物化视图** + +BigQuery 定期通过对基础表运行视图的转换查询来完全刷新物化视图。在刷新之间,BigQuery 将物化视图的数据与新基础表数据结合,以提供一致的查询结果,同时仍然使用物化视图。 + +在 ClickHouse 中,物化视图是增量更新的。这种增量更新机制提供了高可扩展性和低计算成本:增量更新的物化视图专为基础表包含数十亿或数万亿行的场景而设计。ClickHouse 不是反复查询不断增长的基础表以刷新物化视图,而是简单计算新插入的基础表行(仅)的部分结果。这个部分结果会在后台与之前计算的部分结果增量合并。这与反复从整个基础表刷新物化视图相比,大大降低了计算成本。 + +## 事务 {#transactions} + +与 ClickHouse 相比,BigQuery 支持在单个查询中或在使用会话时跨多个查询进行多语句事务。多语句事务允许您对一个或多个表执行更改操作,如插入或删除行,并以原子方式提交或回滚更改。多语句事务在 [ClickHouse 的 2024 年路线图](https://github.com/ClickHouse/ClickHouse/issues/58392) 中。 + +## 聚合函数 {#aggregate-functions} + +与 BigQuery 相比,ClickHouse 提供了显著更多的内置聚合函数: + +- BigQuery 提供 [18 个聚合函数](https://cloud.google.com/bigquery/docs/reference/standard-sql/aggregate_functions),和 [4 个近似聚合函数](https://cloud.google.com/bigquery/docs/reference/standard-sql/approximate_aggregate_functions)。 +- ClickHouse 具有超过 [150 个预构建的聚合函数](/sql-reference/aggregate-functions/reference),以及强大的 [聚合组合器](/sql-reference/aggregate-functions/combinators),用于 [扩展](https://www.youtube.com/watch?v=7ApwD0cfAFI) 预构建聚合函数的行为。例如,您可以通过调用具有 [-Array 后缀](/sql-reference/aggregate-functions/combinators#-array) 的函数将超过 150 个预构建的聚合函数应用于数组,而不是表行。使用 [-Map 后缀](/sql-reference/aggregate-functions/combinators#-map),您可以将任何聚合函数应用于映射。使用 [-ForEach 后缀](/sql-reference/aggregate-functions/combinators#-foreach),您可以将任何聚合函数应用于嵌套数组。 + +## 数据源和文件格式 {#data-sources-and-file-formats} + +与 BigQuery 相比,ClickHouse 支持显著更多的文件格式和数据源: + +- ClickHouse 原生支持从几乎所有数据源加载 90 多种文件格式的数据 +- BigQuery 支持 5 种文件格式和 19 种数据源 + +## SQL 语言特性 {#sql-language-features} + +ClickHouse 提供标准的 SQL 及许多扩展和改进,使其在分析任务中更加友好。例如,ClickHouse SQL [支持 lambda 函数](/sql-reference/functions/overview#arrow-operator-and-lambda) 和高阶函数,因此在应用转换时无需对数组进行展开。与 BigQuery 等其他系统相比,这是一个很大的优势。 + +## 数组 {#arrays} + +与 BigQuery 的 8 个数组函数相比,ClickHouse 具有超过 80 个 [内置数组函数](/sql-reference/functions/array-functions),可优雅且简单地建模和解决各种问题。 + +ClickHouse 中的典型设计模式是使用 [`groupArray`](/sql-reference/aggregate-functions/reference/grouparray) 聚合函数(暂时)将表的特定行值转换为数组。然后可以通过数组函数方便地处理该数组,结果可以通过 [`arrayJoin`](/sql-reference/functions/array-join) 聚合函数转换回单独的表行。 + +由于 ClickHouse SQL 支持 [高阶 lambda 函数](/sql-reference/functions/overview#arrow-operator-and-lambda),许多高级数组操作可以通过简单调用其中一个内置的高阶数组函数来实现,而不必将数组暂时转换回表,这在 BigQuery 中经常是 [必需的](https://cloud.google.com/bigquery/docs/arrays),例如用于 [过滤](https://cloud.google.com/bigquery/docs/arrays#filtering_arrays) 或 [压缩](https://cloud.google.com/bigquery/docs/arrays#zipping_arrays) 数组。在 ClickHouse 中,这些操作只是对高阶函数 [`arrayFilter`](/sql-reference/functions/array-functions#arrayFilter) 和 [`arrayZip`](/sql-reference/functions/array-functions#arrayZip) 的简单函数调用。 + +以下是 BigQuery 到 ClickHouse 的数组操作映射: + +| BigQuery | ClickHouse | +|----------|------------| +| [ARRAY_CONCAT](https://cloud.google.com/bigquery/docs/reference/standard-sql/array_functions#array_concat) | [arrayConcat](/sql-reference/functions/array-functions#arrayConcat) | +| [ARRAY_LENGTH](https://cloud.google.com/bigquery/docs/reference/standard-sql/array_functions#array_length) | [length](/sql-reference/functions/array-functions#length) | +| [ARRAY_REVERSE](https://cloud.google.com/bigquery/docs/reference/standard-sql/array_functions#array_reverse) | [arrayReverse](/sql-reference/functions/array-functions#arrayReverse) | +| [ARRAY_TO_STRING](https://cloud.google.com/bigquery/docs/reference/standard-sql/array_functions#array_to_string) | [arrayStringConcat](/sql-reference/functions/splitting-merging-functions#arraystringconcat) | +| [GENERATE_ARRAY](https://cloud.google.com/bigquery/docs/reference/standard-sql/array_functions#generate_array) | [range](/sql-reference/functions/array-functions#range) | + +**创建一个包含子查询中每行一个元素的数组** + +_BigQuery_ + +[ARRAY 函数](https://cloud.google.com/bigquery/docs/reference/standard-sql/array_functions#array) + +```sql +SELECT ARRAY + (SELECT 1 UNION ALL + SELECT 2 UNION ALL + SELECT 3) AS new_array; + +/*-----------* + | new_array | + +-----------+ + | [1, 2, 3] | + *-----------*/ +``` + +_ClickHouse_ + +[groupArray](/sql-reference/aggregate-functions/reference/grouparray) 聚合函数 + +```sql +SELECT groupArray(*) AS new_array +FROM +( + SELECT 1 + UNION ALL + SELECT 2 + UNION ALL + SELECT 3 +) + ┌─new_array─┐ +1. │ [1,2,3] │ + └───────────┘ +``` + +**将数组转换为一组行** + +_BigQuery_ + +[`UNNEST`](https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax#unnest_operator) 操作符 + +```sql +SELECT * +FROM UNNEST(['foo', 'bar', 'baz', 'qux', 'corge', 'garply', 'waldo', 'fred']) + AS element +WITH OFFSET AS offset +ORDER BY offset; + +/*----------+--------* + | element | offset | + +----------+--------+ + | foo | 0 | + | bar | 1 | + | baz | 2 | + | qux | 3 | + | corge | 4 | + | garply | 5 | + | waldo | 6 | + | fred | 7 | + *----------+--------*/ +``` + +_ClickHouse_ + +[ARRAY JOIN](/sql-reference/statements/select/array-join) 子句 + +```sql +WITH ['foo', 'bar', 'baz', 'qux', 'corge', 'garply', 'waldo', 'fred'] AS values +SELECT element, num-1 AS offset +FROM (SELECT values AS element) AS subquery +ARRAY JOIN element, arrayEnumerate(element) AS num; + +/*----------+--------* + | element | offset | + +----------+--------+ + | foo | 0 | + | bar | 1 | + | baz | 2 | + | qux | 3 | + | corge | 4 | + | garply | 5 | + | waldo | 6 | + | fred | 7 | + *----------+--------*/ +``` + +**返回日期数组** + +_BigQuery_ + +[GENERATE_DATE_ARRAY](https://cloud.google.com/bigquery/docs/reference/standard-sql/array_functions#generate_date_array) 函数 + +```sql +SELECT GENERATE_DATE_ARRAY('2016-10-05', '2016-10-08') AS example; + +/*--------------------------------------------------* + | example | + +--------------------------------------------------+ + | [2016-10-05, 2016-10-06, 2016-10-07, 2016-10-08] | + *--------------------------------------------------*/ +``` + +[range](/sql-reference/functions/array-functions#range) + [arrayMap](/sql-reference/functions/array-functions#arrayMap) 函数 + +_ClickHouse_ + +```sql +SELECT arrayMap(x -> (toDate('2016-10-05') + x), range(toUInt32((toDate('2016-10-08') - toDate('2016-10-05')) + 1))) AS example + + ┌─example───────────────────────────────────────────────┐ +1. │ ['2016-10-05','2016-10-06','2016-10-07','2016-10-08'] │ + └───────────────────────────────────────────────────────┘ +``` + +**返回时间戳数组** + +_BigQuery_ + +[GENERATE_TIMESTAMP_ARRAY](https://cloud.google.com/bigquery/docs/reference/standard-sql/array_functions#generate_timestamp_array) 函数 + +```sql +SELECT GENERATE_TIMESTAMP_ARRAY('2016-10-05 00:00:00', '2016-10-07 00:00:00', + INTERVAL 1 DAY) AS timestamp_array; + +/*--------------------------------------------------------------------------* + | timestamp_array | + +--------------------------------------------------------------------------+ + | [2016-10-05 00:00:00+00, 2016-10-06 00:00:00+00, 2016-10-07 00:00:00+00] | + *--------------------------------------------------------------------------*/ +``` + +_ClickHouse_ + +[range](/sql-reference/functions/array-functions#range) + [arrayMap](/sql-reference/functions/array-functions#arrayMap) 函数 + +```sql +SELECT arrayMap(x -> (toDateTime('2016-10-05 00:00:00') + toIntervalDay(x)), range(dateDiff('day', toDateTime('2016-10-05 00:00:00'), toDateTime('2016-10-07 00:00:00')) + 1)) AS timestamp_array + +Query id: b324c11f-655b-479f-9337-f4d34fd02190 + + ┌─timestamp_array─────────────────────────────────────────────────────┐ +1. │ ['2016-10-05 00:00:00','2016-10-06 00:00:00','2016-10-07 00:00:00'] │ + └─────────────────────────────────────────────────────────────────────┘ +``` + +**过滤数组** + +_BigQuery_ + +需要通过 [`UNNEST`](https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax#unnest_operator) 操作符将数组暂时转换回表 + +```sql +WITH Sequences AS + (SELECT [0, 1, 1, 2, 3, 5] AS some_numbers + UNION ALL SELECT [2, 4, 8, 16, 32] AS some_numbers + UNION ALL SELECT [5, 10] AS some_numbers) +SELECT + ARRAY(SELECT x * 2 + FROM UNNEST(some_numbers) AS x + WHERE x < 5) AS doubled_less_than_five +FROM Sequences; + +/*------------------------* + | doubled_less_than_five | + +------------------------+ + | [0, 2, 2, 4, 6] | + | [4, 8] | + | [] | + *------------------------*/ +``` + +_ClickHouse_ + +[arrayFilter](/sql-reference/functions/array-functions#arrayFilter) 函数 + +```sql +WITH Sequences AS + ( + SELECT [0, 1, 1, 2, 3, 5] AS some_numbers + UNION ALL + SELECT [2, 4, 8, 16, 32] AS some_numbers + UNION ALL + SELECT [5, 10] AS some_numbers + ) +SELECT arrayMap(x -> (x * 2), arrayFilter(x -> (x < 5), some_numbers)) AS doubled_less_than_five +FROM Sequences; + ┌─doubled_less_than_five─┐ +1. │ [0,2,2,4,6] │ + └────────────────────────┘ + ┌─doubled_less_than_five─┐ +2. │ [] │ + └────────────────────────┘ + ┌─doubled_less_than_five─┐ +3. │ [4,8] │ + └────────────────────────┘ +``` + +**压缩数组** + +_BigQuery_ + +需要通过 [`UNNEST`](https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax#unnest_operator) 操作符将数组暂时转换回表 + +```sql +WITH + Combinations AS ( + SELECT + ['a', 'b'] AS letters, + [1, 2, 3] AS numbers + ) +SELECT + ARRAY( + SELECT AS STRUCT + letters[SAFE_OFFSET(index)] AS letter, + numbers[SAFE_OFFSET(index)] AS number + FROM Combinations + CROSS JOIN + UNNEST( + GENERATE_ARRAY( + 0, + LEAST(ARRAY_LENGTH(letters), ARRAY_LENGTH(numbers)) - 1)) AS index + ORDER BY index + ); + +/*------------------------------* + | pairs | + +------------------------------+ + | [{ letter: "a", number: 1 }, | + | { letter: "b", number: 2 }] | + *------------------------------*/ +``` + +_ClickHouse_ + +[arrayZip](/sql-reference/functions/array-functions#arrayZip) 函数 + +```sql +WITH Combinations AS + ( + SELECT + ['a', 'b'] AS letters, + [1, 2, 3] AS numbers + ) +SELECT arrayZip(letters, arrayResize(numbers, length(letters))) AS pairs +FROM Combinations; + ┌─pairs─────────────┐ +1. │ [('a',1),('b',2)] │ + └───────────────────┘ +``` + +**聚合数组** + +_BigQuery_ + +需要通过 [`UNNEST`](https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax#unnest_operator) 操作符将数组转换回表 + +```sql +WITH Sequences AS + (SELECT [0, 1, 1, 2, 3, 5] AS some_numbers + UNION ALL SELECT [2, 4, 8, 16, 32] AS some_numbers + UNION ALL SELECT [5, 10] AS some_numbers) +SELECT some_numbers, + (SELECT SUM(x) + FROM UNNEST(s.some_numbers) AS x) AS sums +FROM Sequences AS s; + +/*--------------------+------* + | some_numbers | sums | + +--------------------+------+ + | [0, 1, 1, 2, 3, 5] | 12 | + | [2, 4, 8, 16, 32] | 62 | + | [5, 10] | 15 | + *--------------------+------*/ +``` + +_ClickHouse_ + +[arraySum](/sql-reference/functions/array-functions#arraySum)、[arrayAvg](/sql-reference/functions/array-functions#arrayAvg) 等函数,或任何超过 90 个现有聚合函数名称作为 [arrayReduce](/sql-reference/functions/array-functions#arrayReduce) 函数的参数 + +```sql +WITH Sequences AS + ( + SELECT [0, 1, 1, 2, 3, 5] AS some_numbers + UNION ALL + SELECT [2, 4, 8, 16, 32] AS some_numbers + UNION ALL + SELECT [5, 10] AS some_numbers + ) +SELECT + some_numbers, + arraySum(some_numbers) AS sums +FROM Sequences; + ┌─some_numbers──┬─sums─┐ +1. │ [0,1,1,2,3,5] │ 12 │ + └───────────────┴──────┘ + ┌─some_numbers──┬─sums─┐ +2. │ [2,4,8,16,32] │ 62 │ + └───────────────┴──────┘ + ┌─some_numbers─┬─sums─┐ +3. │ [5,10] │ 15 │ + └──────────────┴──────┘ +``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/03_bigquery/01_overview.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/03_bigquery/01_overview.md.hash new file mode 100644 index 00000000000..374a436f9da --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/03_bigquery/01_overview.md.hash @@ -0,0 +1 @@ +18ae7424166a08ea diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/03_bigquery/02_migrating-to-clickhouse-cloud.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/03_bigquery/02_migrating-to-clickhouse-cloud.md new file mode 100644 index 00000000000..545fdc5c903 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/03_bigquery/02_migrating-to-clickhouse-cloud.md @@ -0,0 +1,533 @@ +--- +'title': '从 BigQuery 迁移到 ClickHouse Cloud' +'slug': '/migrations/bigquery/migrating-to-clickhouse-cloud' +'description': '如何将您的数据从 BigQuery 迁移到 ClickHouse Cloud' +'keywords': +- 'BigQuery' +'show_related_blogs': true +'sidebar_label': '迁移指南' +'doc_type': 'guide' +--- + +import bigquery_2 from '@site/static/images/migrations/bigquery-2.png'; +import bigquery_3 from '@site/static/images/migrations/bigquery-3.png'; +import bigquery_4 from '@site/static/images/migrations/bigquery-4.png'; +import bigquery_5 from '@site/static/images/migrations/bigquery-5.png'; +import bigquery_6 from '@site/static/images/migrations/bigquery-6.png'; +import bigquery_7 from '@site/static/images/migrations/bigquery-7.png'; +import bigquery_8 from '@site/static/images/migrations/bigquery-8.png'; +import bigquery_9 from '@site/static/images/migrations/bigquery-9.png'; +import bigquery_10 from '@site/static/images/migrations/bigquery-10.png'; +import bigquery_11 from '@site/static/images/migrations/bigquery-11.png'; +import bigquery_12 from '@site/static/images/migrations/bigquery-12.png'; +import Image from '@theme/IdealImage'; + +## 为什么选择 ClickHouse Cloud 而不是 BigQuery? {#why-use-clickhouse-cloud-over-bigquery} + +简而言之:因为 ClickHouse 在现代数据分析方面比 BigQuery 更快、更便宜、更强大: + +ClickHouse vs BigQuery + +## 从 BigQuery 加载数据到 ClickHouse Cloud {#loading-data-from-bigquery-to-clickhouse-cloud} + +### 数据集 {#dataset} + +作为从 BigQuery 迁移到 ClickHouse Cloud 的典型示例数据集,我们使用 Stack Overflow 数据集,该数据集的详细信息记录在 [这里](/getting-started/example-datasets/stackoverflow)。这包含了从 2008 年到 2024 年 4 月在 Stack Overflow 上发生的每个 `post`、`vote`、`user`、`comment` 和 `badge`。此数据的 BigQuery 架构如下所示: + +Schema + +对于希望将此数据集填充到 BigQuery 实例中以测试迁移步骤的用户,我们在 GCS 存储桶中提供了这些表的 Parquet 格式数据,并且用于在 BigQuery 中创建和加载表的 DDL 命令可以在 [这里](https://pastila.nl/?003fd86b/2b93b1a2302cfee5ef79fd374e73f431#hVPC52YDsUfXg2eTLrBdbA==) 获取。 + +### 迁移数据 {#migrating-data} + +在 BigQuery 和 ClickHouse Cloud 之间迁移数据主要分为两种工作负载类型: + +- **初始批量加载与定期更新** - 必须迁移初始数据集,并在设定的间隔(例如每日)进行定期更新。这里的更新通过重新发送已更改的行来处理,这些行通过可以用于比较的列(例如日期)进行识别。删除操作通过完整的定期数据集重新加载来处理。 +- **实时复制或 CDC** - 必须迁移初始数据集。对该数据集的更改必须在 ClickHouse 中近实时反映,只有几秒钟的延迟是可以接受的。这实际上是一种 [变更数据捕获 (CDC) 过程](https://en.wikipedia.org/wiki/Change_data_capture),其中 BigQuery 中的表必须与 ClickHouse 中的等效表同步,即在 BigQuery 表中插入、更新和删除的操作必须应用到 ClickHouse 中的相应表。 + +#### 通过 Google Cloud Storage (GCS) 批量加载 {#bulk-loading-via-google-cloud-storage-gcs} + +BigQuery 支持将数据导出到 Google 的对象存储 (GCS)。对于我们的示例数据集: + +1. 将 7 个表导出到 GCS。相关的命令可在 [这里](https://pastila.nl/?014e1ae9/cb9b07d89e9bb2c56954102fd0c37abd#0Pzj52uPYeu1jG35nmMqRQ==) 获取。 + +2. 将数据导入到 ClickHouse Cloud。为此,我们可以使用 [gcs 表函数](/sql-reference/table-functions/gcs)。DDL 和导入查询可以在 [这里](https://pastila.nl/?00531abf/f055a61cc96b1ba1383d618721059976#Wf4Tn43D3VCU5Hx7tbf1Qw==) 获取。请注意,由于 ClickHouse Cloud 实例由多个计算节点组成,因此我们使用的是 [s3Cluster 表函数](/sql-reference/table-functions/s3Cluster),而不是 `gcs` 表函数。这个函数也可以与 gcs 储存桶配合使用,并且 [利用 ClickHouse Cloud 服务的所有节点](https://clickhouse.com/blog/supercharge-your-clickhouse-data-loads-part1#parallel-servers) 进行并行数据加载。 + +Bulk loading + +这种方法有许多优点: + +- BigQuery 导出功能支持导出数据子集的过滤器。 +- BigQuery 支持导出 [Parquet、Avro、JSON 和 CSV](https://cloud.google.com/bigquery/docs/exporting-data) 格式和几种 [压缩类型](https://cloud.google.com/bigquery/docs/exporting-data),所有这些都是 ClickHouse 支持的。 +- GCS 支持 [对象生命周期管理](https://cloud.google.com/storage/docs/lifecycle),允许在指定时间后删除已经导出并导入到 ClickHouse 的数据。 +- [Google 允许每天将高达 50TB 的数据免费导出到 GCS](https://cloud.google.com/bigquery/quotas#export_jobs)。用户只需支付 GCS 存储费用。 +- 导出会自动生成多个文件,每个文件的表数据最大为 1GB。这对 ClickHouse 很有利,因为它允许并行化导入。 + +在尝试以下示例之前,我们建议用户查看 [导出所需的权限](https://cloud.google.com/bigquery/docs/exporting-data#required_permissions) 和 [本地性建议](https://cloud.google.com/bigquery/docs/exporting-data#data-locations),以最大化导出和导入性能。 + +### 通过计划查询进行实时复制或 CDC {#real-time-replication-or-cdc-via-scheduled-queries} + +变更数据捕获 (CDC) 是确保两个数据库之间的表保持同步的过程。如果需要近实时处理更新和删除,这将复杂得多。一种方法是简单地使用 BigQuery 的 [计划查询功能](https://cloud.google.com/bigquery/docs/scheduling-queries) 定期安排导出。只要您能接受数据插入 ClickHouse 时的延迟,这种方法易于实现和维护。一个示例可以在 [这篇博客文章](https://clickhouse.com/blog/clickhouse-bigquery-migrating-data-for-realtime-queries#using-scheduled-queries) 中找到。 + +## 设计模式 {#designing-schemas} + +Stack Overflow 数据集包含多个相关表。我们建议首先重点迁移主表。这可能不一定是最大的表,而是期望收到最多分析查询的表。这将使您熟悉主要的 ClickHouse 概念。此表可能需要重新建模,因为在添加其他表以充分利用 ClickHouse 特性并获得最佳性能时,可能会涉及到额外的建模过程。我们将在我们的 [数据建模文档](/data-modeling/schema-design#next-data-modeling-techniques) 中探讨这个建模过程。 + +遵循这一原则,我们首先关注主 `posts` 表。其 BigQuery 架构如下所示: + +```sql +CREATE TABLE stackoverflow.posts ( + id INTEGER, + posttypeid INTEGER, + acceptedanswerid STRING, + creationdate TIMESTAMP, + score INTEGER, + viewcount INTEGER, + body STRING, + owneruserid INTEGER, + ownerdisplayname STRING, + lasteditoruserid STRING, + lasteditordisplayname STRING, + lasteditdate TIMESTAMP, + lastactivitydate TIMESTAMP, + title STRING, + tags STRING, + answercount INTEGER, + commentcount INTEGER, + favoritecount INTEGER, + conentlicense STRING, + parentid STRING, + communityowneddate TIMESTAMP, + closeddate TIMESTAMP +); +``` + +### 优化类型 {#optimizing-types} + +根据 [这里描述的过程](/data-modeling/schema-design),我们得到了以下架构: + +```sql +CREATE TABLE stackoverflow.posts +( + `Id` Int32, + `PostTypeId` Enum('Question' = 1, 'Answer' = 2, 'Wiki' = 3, 'TagWikiExcerpt' = 4, 'TagWiki' = 5, 'ModeratorNomination' = 6, 'WikiPlaceholder' = 7, 'PrivilegeWiki' = 8), + `AcceptedAnswerId` UInt32, + `CreationDate` DateTime, + `Score` Int32, + `ViewCount` UInt32, + `Body` String, + `OwnerUserId` Int32, + `OwnerDisplayName` String, + `LastEditorUserId` Int32, + `LastEditorDisplayName` String, + `LastEditDate` DateTime, + `LastActivityDate` DateTime, + `Title` String, + `Tags` String, + `AnswerCount` UInt16, + `CommentCount` UInt8, + `FavoriteCount` UInt8, + `ContentLicense`LowCardinality(String), + `ParentId` String, + `CommunityOwnedDate` DateTime, + `ClosedDate` DateTime +) +ENGINE = MergeTree +ORDER BY tuple() +COMMENT 'Optimized types' +``` + +我们可以通过简单的 [`INSERT INTO SELECT`](/sql-reference/statements/insert-into) 将数据填充到该表中,从 gcs 中读取导出的数据,并使用 [`gcs` 表函数](/sql-reference/table-functions/gcs)。请注意,在 ClickHouse Cloud 上,您还可以使用与 gcs 兼容的 [`s3Cluster` 表函数](/sql-reference/table-functions/s3Cluster) 在多个节点上并行加载: + +```sql +INSERT INTO stackoverflow.posts SELECT * FROM gcs( 'gs://clickhouse-public-datasets/stackoverflow/parquet/posts/*.parquet', NOSIGN); +``` + +在我们的新架构中不会保留任何 null 值。上述插入隐式地将这些值转换为各自类型的默认值 - 整数为 0,字符串为空值。ClickHouse 还会自动将任何数字转换为目标精度。 + +## ClickHouse 的主键有何不同? {#how-are-clickhouse-primary-keys-different} + +如 [此处所述](/migrations/bigquery),与 BigQuery 类似,ClickHouse 不对表的主键列值强制执行唯一性。 + +与 BigQuery 中的聚类类似,ClickHouse 表的数据按主键列的顺序存储在磁盘上。查询优化器利用这种排序顺序来防止重新排序,最小化连接的内存使用,并为限制子句启用短路处理。 +与 BigQuery 相比,ClickHouse 自动创建基于主键列值的 [(稀疏)主索引](/guides/best-practices/sparse-primary-indexes)。这个索引用于加速所有包含对主键列过滤的查询。具体而言: + +- 内存和磁盘效率对 ClickHouse 通常使用的规模至关重要。数据以称为 parts 的块写入 ClickHouse 表,合并规则在后台应用。每个 part 都有自己主索引,当部分合并时,合并后的主索引也会合并。要注意,这些索引并不是为每一行构建的。相反,part 的主索引每组行有一个索引条目 - 这种技术称为稀疏索引。 +- 稀疏索引成为可能是因为 ClickHouse 将 part 的行按指定键的顺序存储在磁盘上。与直接定位单行(如基于 B-Tree 的索引)不同,稀疏主索引用于快速(通过二进制搜索索引条目)识别可能与查询匹配的行组。定位到的可能匹配的行组随后被并行流入 ClickHouse 引擎以查找匹配项。该索引设计使得主索引可以较小(完全适合主存储器),同时仍显著加快查询执行时间,尤其是典型于数据分析用例的范围查询。有关更多详细信息,我们建议阅读 [这篇深入的指南](/guides/best-practices/sparse-primary-indexes)。 + +ClickHouse Primary keys + +在 ClickHouse 中选择的主键不仅将决定索引,还将决定数据在磁盘上的写入顺序。因此,这可能会大幅影响压缩水平,而这又会影响查询性能。导致大多数列的值以连续顺序写入的排序键将允许所选择的压缩算法(和编码)更有效地压缩数据。 + +> 表中的所有列将根据指定的排序键值排序,无论它们是否包含在键中。例如,如果将 `CreationDate` 用作键,则所有其他列中的值的顺序将与 `CreationDate` 列中的值的顺序相对应。可以指定多个排序键,排序方式与 `SELECT` 查询中的 `ORDER BY` 子句具有相同的语义。 + +### 选择排序键 {#choosing-an-ordering-key} + +有关选择排序键的考虑和步骤,使用帖子表作为示例,请参见 [此处](/data-modeling/schema-design#choosing-an-ordering-key)。 + +## 数据建模技术 {#data-modeling-techniques} + +我们建议从 BigQuery 迁移的用户阅读 [ClickHouse 中建模数据的指南](/data-modeling/schema-design)。该指南使用相同的 Stack Overflow 数据集,并探讨使用 ClickHouse 特性的多种方法。 + +### 分区 {#partitions} + +BigQuery 用户将熟悉通过将表划分为称为分区的小块来增强大型数据库性能和可管理性的表分区概念。这种分区可以通过对指定列(例如日期)进行范围划分、定义列表或根据某个键进行哈希来实现。这使得管理员能够根据特定标准(例如日期范围或地理位置)组织数据。 + +分区通过启用更快的数据访问(通过分区裁剪)和更有效的索引来帮助改善查询性能。它还通过允许在单个分区上进行操作(而不是整个表)来帮助维护任务,如备份和数据清除。此外,分区可以通过将负载分散到多个分区来显著提高 BigQuery 数据库的可扩展性。 + +在 ClickHouse 中,分区在通过 [`PARTITION BY`](/engines/table-engines/mergetree-family/custom-partitioning-key) 子句初始定义表时指定。该子句可以包含针对任何列的 SQL 表达式,其结果将定义一个行被发送到哪个分区。 + +Partitions + +数据部分在磁盘上与每个分区逻辑上关联,并可以单独查询。下面的示例中,我们通过使用表达式 [`toYear(CreationDate)`](/sql-reference/functions/date-time-functions#toYear) 按年份对 posts 表进行分区。当行被插入到 ClickHouse 中时,将对每行评估该表达式 - 然后将行路由到该分区中的新数据部分。 + +```sql +CREATE TABLE posts +( + `Id` Int32 CODEC(Delta(4), ZSTD(1)), + `PostTypeId` Enum8('Question' = 1, 'Answer' = 2, 'Wiki' = 3, 'TagWikiExcerpt' = 4, 'TagWiki' = 5, 'ModeratorNomination' = 6, 'WikiPlaceholder' = 7, 'PrivilegeWiki' = 8), + `AcceptedAnswerId` UInt32, + `CreationDate` DateTime64(3, 'UTC'), +... + `ClosedDate` DateTime64(3, 'UTC') +) +ENGINE = MergeTree +ORDER BY (PostTypeId, toDate(CreationDate), CreationDate) +PARTITION BY toYear(CreationDate) +``` + +#### 应用 {#applications} + +在 ClickHouse 中的分区与在 BigQuery 中有类似的应用,但有一些微妙的差异。更具体地说: + +- **数据管理** - 在 ClickHouse 中,用户应主要考虑将分区视为数据管理特性,而非查询优化技术。通过基于某个键在逻辑上分隔数据,每个分区可以独立操作,例如删除。这允许用户高效地在存储层之间移动分区,从而在时间上或 [过期数据/高效删除集群](https://sql-reference/statements/alter/partition) 中进行操作。例如,下面我们删除 2008 年的帖子: + +```sql +SELECT DISTINCT partition +FROM system.parts +WHERE `table` = 'posts' + +┌─partition─┐ +│ 2008 │ +│ 2009 │ +│ 2010 │ +│ 2011 │ +│ 2012 │ +│ 2013 │ +│ 2014 │ +│ 2015 │ +│ 2016 │ +│ 2017 │ +│ 2018 │ +│ 2019 │ +│ 2020 │ +│ 2021 │ +│ 2022 │ +│ 2023 │ +│ 2024 │ +└───────────┘ + +17 rows in set. Elapsed: 0.002 sec. + +ALTER TABLE posts +(DROP PARTITION '2008') + +Ok. + +0 rows in set. Elapsed: 0.103 sec. +``` + +- **查询优化** - 虽然分区可以帮助查询性能,但这在很大程度上依赖于访问模式。如果查询仅针对少数几个分区(理想情况下为一个),则性能可能会提高。仅在分区键不在主键中时并且您以其为过滤条件时,这通常才有用。然而,需要覆盖多个分区的查询可能会比不使用分区的情况表现更差(因为分区的结果可能产生更多的部分)。如果分区键已经是主键中的早期条目,则对单个分区的目标的好处也会微乎其微。分区还可以用于 [优化 `GROUP BY` 查询](/engines/table-engines/mergetree-family/custom-partitioning-key#group-by-optimisation-using-partition-key),如果每个分区中的值是唯一的。然而,通常情况下,用户应确保主键是经过优化的,仅在访问模式访问特定可预测子集的极少数情况中考虑分区作为查询优化技术,例如按天分区,而大多数查询在最后一天进行。 + +#### 建议 {#recommendations} + +用户应将分区视为数据管理技术。当需要从集群中过期数据时,它是理想的,尤其是在处理时间序列数据时,例如:最旧的分区可以 [直接删除](/sql-reference/statements/alter/partition#drop-partitionpart)。 + +重要提示:确保您的分区键表达式不会导致高基数集,即应避免创建超过 100 个分区。例如,不要根据客户端标识符或名称等高基数列来分区数据。相反,将客户端标识符或名称作为 `ORDER BY` 表达式中的第一列。 + +> 内部,ClickHouse [为插入数据创建部分](/guides/best-practices/sparse-primary-indexes#clickhouse-index-design)。随着数据的不断插入,部分的数量会增加。为了防止过高数量的部分导致查询性能下降(因为需要读取更多文件),部分会在后台异步处理的过程中进行合并。如果部分的数量超过 [预配置限制](/operations/settings/merge-tree-settings#parts_to_throw_insert),则 ClickHouse 将在插入时抛出异常,提示为 ["太多部分" 错误](/knowledgebase/exception-too-many-parts)。在正常操作下,这种情况不应发生,只有在 ClickHouse 配置错误或使用不当(例如,多个小插入)时才会发生。由于部分是在每个分区中独立创建的,增加分区的数量会导致部分数量增加,即是分区数量的乘数。因此,高基数的分区键可能导致此错误,应该避免。 + +## 物化视图与投影 {#materialized-views-vs-projections} + +ClickHouse 的投影概念允许用户为表指定多个 `ORDER BY` 子句。 + +在 [ClickHouse 数据建模](/data-modeling/schema-design) 中,我们探讨了如何使用物化视图在 ClickHouse 中进行预计算聚合、转换行,并为不同的访问模式优化查询。对于后者,我们 [提供了示例](/materialized-view/incremental-materialized-view#lookup-table),其中物化视图将行发送到具有不同排序键的目标表,而不是接收插入的原始表。 + +例如,考虑以下查询: + +```sql +SELECT avg(Score) +FROM comments +WHERE UserId = 8592047 + + ┌──────────avg(Score)─┐ + │ 0.18181818181818182 │ + └─────────────────────┘ +--highlight-next-line +1 row in set. Elapsed: 0.040 sec. Processed 90.38 million rows, 361.59 MB (2.25 billion rows/s., 9.01 GB/s.) +Peak memory usage: 201.93 MiB. +``` + +此查询需要扫描所有 9000 万行(尽管很快),因为 `UserId` 不是排序键。以前我们通过使用物化视图作为 `PostId` 的查找来解决这个问题。同样的问题可以使用投影解决。以下命令添加具有 `ORDER BY user_id` 的投影。 + +```sql +ALTER TABLE comments ADD PROJECTION comments_user_id ( +SELECT * ORDER BY UserId +) + +ALTER TABLE comments MATERIALIZE PROJECTION comments_user_id +``` + +请注意,我们必须先创建投影,然后将其物化。这个后续命令会导致数据在磁盘上以两种不同的排序存储两次。还可以在创建数据时定义投影,如下所示,并在数据插入时自动维护。 + +```sql +CREATE TABLE comments +( + `Id` UInt32, + `PostId` UInt32, + `Score` UInt16, + `Text` String, + `CreationDate` DateTime64(3, 'UTC'), + `UserId` Int32, + `UserDisplayName` LowCardinality(String), + --highlight-begin + PROJECTION comments_user_id + ( + SELECT * + ORDER BY UserId + ) + --highlight-end +) +ENGINE = MergeTree +ORDER BY PostId +``` + +如果通过 `ALTER` 命令创建投影,则在发出 `MATERIALIZE PROJECTION` 命令时,创建是异步的。用户可以通过以下查询确认此操作的进度,等待 `is_done=1`。 + +```sql +SELECT + parts_to_do, + is_done, + latest_fail_reason +FROM system.mutations +WHERE (`table` = 'comments') AND (command LIKE '%MATERIALIZE%') + + ┌─parts_to_do─┬─is_done─┬─latest_fail_reason─┐ +1. │ 1 │ 0 │ │ + └─────────────┴─────────┴────────────────────┘ + +1 row in set. Elapsed: 0.003 sec. +``` + +如果我们重复上述查询,可以看到性能明显提高,代价是额外的存储空间。 + +```sql +SELECT avg(Score) +FROM comments +WHERE UserId = 8592047 + + ┌──────────avg(Score)─┐ +1. │ 0.18181818181818182 │ + └─────────────────────┘ +--highlight-next-line +1 row in set. Elapsed: 0.008 sec. Processed 16.36 thousand rows, 98.17 KB (2.15 million rows/s., 12.92 MB/s.) +Peak memory usage: 4.06 MiB. +``` + +使用 [`EXPLAIN` 命令](/sql-reference/statements/explain),我们也确认了该投影被用于服务该查询: + +```sql +EXPLAIN indexes = 1 +SELECT avg(Score) +FROM comments +WHERE UserId = 8592047 + + ┌─explain─────────────────────────────────────────────┐ + 1. │ Expression ((Projection + Before ORDER BY)) │ + 2. │ Aggregating │ + 3. │ Filter │ + 4. │ ReadFromMergeTree (comments_user_id) │ + 5. │ Indexes: │ + 6. │ PrimaryKey │ + 7. │ Keys: │ + 8. │ UserId │ + 9. │ Condition: (UserId in [8592047, 8592047]) │ +10. │ Parts: 2/2 │ +11. │ Granules: 2/11360 │ + └─────────────────────────────────────────────────────┘ + +11 rows in set. Elapsed: 0.004 sec. +``` + +### 何时使用投影 {#when-to-use-projections} + +投影对新用户是一个有吸引力的特性,因为它们会随着数据的插入自动维护。此外,查询可以只发送到单个表,投影会在可能的情况下得到利用,从而加快响应时间。 + +Projections + +这与物化视图形成对比,后者用户必须选择适当的优化目标表或重写查询,具体取决于过滤器。这增加了用户应用的复杂性,从而增加了客户端的复杂性。 + +尽管有这些优点,投影也带有一些固有的限制,用户应该意识到,因此应谨慎部署。有关更多详细信息,请参见 ["物化视图与投影"](/managing-data/materialized-views-versus-projections)。 + +我们建议在以下情况下使用投影: + +- 需要对数据进行完全重新排序。虽然投影中的表达式理论上可以使用 `GROUP BY`,但物化视图对于维护聚合更有效。查询优化器也更可能利用那些使用简单重新排序的投影,即 `SELECT * ORDER BY x`。用户可以在此表达式中选择一组列,以减少存储占用。 +- 用户能接受附加的存储占用和双写数据的开销。测试插入速度的影响并 [评估存储开销](/data-compression/compression-in-clickhouse)。 + +## 在 ClickHouse 中重写 BigQuery 查询 {#rewriting-bigquery-queries-in-clickhouse} + +以下提供了比较 BigQuery 和 ClickHouse 的示例查询。此列表旨在演示如何利用 ClickHouse 的特点显著简化查询。这些示例涉及完整的 Stack Overflow 数据集(截至 2024 年 4 月)。 + +**(问题超过 10 条的)用户获得的最多阅读量:** + +_BigQuery_ + +Rewriting BigQuery queries + +_ClickHouse_ + +```sql +SELECT + OwnerDisplayName, + sum(ViewCount) AS total_views +FROM stackoverflow.posts +WHERE (PostTypeId = 'Question') AND (OwnerDisplayName != '') +GROUP BY OwnerDisplayName +HAVING count() > 10 +ORDER BY total_views DESC +LIMIT 5 + + ┌─OwnerDisplayName─┬─total_views─┐ +1. │ Joan Venge │ 25520387 │ +2. │ Ray Vega │ 21576470 │ +3. │ anon │ 19814224 │ +4. │ Tim │ 19028260 │ +5. │ John │ 17638812 │ + └──────────────────┴─────────────┘ + +5 rows in set. Elapsed: 0.076 sec. Processed 24.35 million rows, 140.21 MB (320.82 million rows/s., 1.85 GB/s.) +Peak memory usage: 323.37 MiB. +``` + +**哪些标签获得的最多阅读量:** + +_BigQuery_ + +
+ +BigQuery 1 + +_ClickHouse_ + +```sql +-- ClickHouse +SELECT + arrayJoin(arrayFilter(t -> (t != ''), splitByChar('|', Tags))) AS tags, + sum(ViewCount) AS views +FROM stackoverflow.posts +GROUP BY tags +ORDER BY views DESC +LIMIT 5 + + ┌─tags───────┬──────views─┐ +1. │ javascript │ 8190916894 │ +2. │ python │ 8175132834 │ +3. │ java │ 7258379211 │ +4. │ c# │ 5476932513 │ +5. │ android │ 4258320338 │ + └────────────┴────────────┘ + +5 rows in set. Elapsed: 0.318 sec. Processed 59.82 million rows, 1.45 GB (188.01 million rows/s., 4.54 GB/s.) +Peak memory usage: 567.41 MiB. +``` + +## 聚合函数 {#aggregate-functions} + +在可能的情况下,用户应利用 ClickHouse 的聚合函数。下面,我们展示了如何使用 [`argMax` 函数](/sql-reference/aggregate-functions/reference/argmax) 计算每年的最受欢迎问题。 + +_BigQuery_ + +Aggregate functions 1 + +Aggregate functions 2 + +_ClickHouse_ + +```sql +-- ClickHouse +SELECT + toYear(CreationDate) AS Year, + argMax(Title, ViewCount) AS MostViewedQuestionTitle, + max(ViewCount) AS MaxViewCount +FROM stackoverflow.posts +WHERE PostTypeId = 'Question' +GROUP BY Year +ORDER BY Year ASC +FORMAT Vertical + +Row 1: +────── +Year: 2008 +MostViewedQuestionTitle: How to find the index for a given item in a list? +MaxViewCount: 6316987 + +Row 2: +────── +Year: 2009 +MostViewedQuestionTitle: How do I undo the most recent local commits in Git? +MaxViewCount: 13962748 + +... + +Row 16: +─────── +Year: 2023 +MostViewedQuestionTitle: How do I solve "error: externally-managed-environment" every time I use pip 3? +MaxViewCount: 506822 + +Row 17: +─────── +Year: 2024 +MostViewedQuestionTitle: Warning "Third-party cookie will be blocked. Learn more in the Issues tab" +MaxViewCount: 66975 + +17 rows in set. Elapsed: 0.225 sec. Processed 24.35 million rows, 1.86 GB (107.99 million rows/s., 8.26 GB/s.) +Peak memory usage: 377.26 MiB. +``` + +## 条件和数组 {#conditionals-and-arrays} + +条件和数组函数使查询变得更加简单。以下查询计算了 2022 年到 2023 年间发生的标签(出现超过 10000 次)的最大百分比增长。请注意,由于条件、数组函数以及在 `HAVING` 和 `SELECT` 子句中重用别名的能力,以下 ClickHouse 查询简洁明了。 + +_BigQuery_ + +Conditionals and Arrays + +_ClickHouse_ + +```sql +SELECT + arrayJoin(arrayFilter(t -> (t != ''), splitByChar('|', Tags))) AS tag, + countIf(toYear(CreationDate) = 2023) AS count_2023, + countIf(toYear(CreationDate) = 2022) AS count_2022, + ((count_2023 - count_2022) / count_2022) * 100 AS percent_change +FROM stackoverflow.posts +WHERE toYear(CreationDate) IN (2022, 2023) +GROUP BY tag +HAVING (count_2022 > 10000) AND (count_2023 > 10000) +ORDER BY percent_change DESC +LIMIT 5 + +┌─tag─────────┬─count_2023─┬─count_2022─┬──────percent_change─┐ +│ next.js │ 13788 │ 10520 │ 31.06463878326996 │ +│ spring-boot │ 16573 │ 17721 │ -6.478189718413183 │ +│ .net │ 11458 │ 12968 │ -11.644046884639112 │ +│ azure │ 11996 │ 14049 │ -14.613139725247349 │ +│ docker │ 13885 │ 16877 │ -17.72826924216389 │ +└─────────────┴────────────┴────────────┴─────────────────────┘ + +5 rows in set. Elapsed: 0.096 sec. Processed 5.08 million rows, 155.73 MB (53.10 million rows/s., 1.63 GB/s.) +Peak memory usage: 410.37 MiB. +``` + +这就是我们为从 BigQuery 迁移到 ClickHouse 的用户提供的基本指南。我们建议从 BigQuery 迁移的用户阅读 [ClickHouse 中建模数据的指南](/data-modeling/schema-design),以了解更多高级 ClickHouse 功能。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/03_bigquery/02_migrating-to-clickhouse-cloud.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/03_bigquery/02_migrating-to-clickhouse-cloud.md.hash new file mode 100644 index 00000000000..97f2cb2d25f --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/03_bigquery/02_migrating-to-clickhouse-cloud.md.hash @@ -0,0 +1 @@ +70fc47f9883ee418 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/03_bigquery/03_loading-data.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/03_bigquery/03_loading-data.md new file mode 100644 index 00000000000..1eab3c49dca --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/03_bigquery/03_loading-data.md @@ -0,0 +1,140 @@ +--- +'sidebar_label': '加载数据' +'title': '从 BigQuery 加载数据到 ClickHouse' +'slug': '/migrations/bigquery/loading-data' +'description': '如何从 BigQuery 加载数据到 ClickHouse' +'keywords': +- 'migrate' +- 'migration' +- 'migrating' +- 'data' +- 'etl' +- 'elt' +- 'BigQuery' +'doc_type': 'guide' +--- + +_本指南兼容 ClickHouse Cloud 以及自管理的 ClickHouse v23.5+。_ + +本指南展示了如何将数据从 [BigQuery](https://cloud.google.com/bigquery) 迁移到 ClickHouse。 + +我们首先将一个表导出到 [Google 的对象存储 (GCS)](https://cloud.google.com/storage),然后将该数据导入到 [ClickHouse Cloud](https://clickhouse.com/cloud)。这些步骤需要为您希望从 BigQuery 导出到 ClickHouse 的每个表重复。 + +## 将数据导出到 ClickHouse 需要多长时间? {#how-long-will-exporting-data-to-clickhouse-take} + +从 BigQuery 导出数据到 ClickHouse 的时间取决于您的数据集大小。作为比较,使用本指南从 BigQuery 导出 [4TB 的公开以太坊数据集](https://cloud.google.com/blog/products/data-analytics/ethereum-bigquery-public-dataset-smart-contract-analytics) 到 ClickHouse 大约需要一个小时。 + +| 表 | 行数 | 导出文件数 | 数据大小 | BigQuery 导出 | 槽时间 | ClickHouse 导入 | +| ------------------------------------------------------------------------------------------------- | ------------- | -------------- | --------- | --------------- | --------------- | ----------------- | +| [blocks](https://github.com/ClickHouse/examples/blob/main/ethereum/schemas/blocks.md) | 16,569,489 | 73 | 14.53GB | 23秒 | 37分钟 | 15.4秒 | +| [transactions](https://github.com/ClickHouse/examples/blob/main/ethereum/schemas/transactions.md) | 1,864,514,414 | 5169 | 957GB | 1分钟 38秒 | 1天 8小时 | 18分钟 5秒 | +| [traces](https://github.com/ClickHouse/examples/blob/main/ethereum/schemas/traces.md) | 6,325,819,306 | 17,985 | 2.896TB | 5分钟 46秒 | 5天 19小时 | 34分钟 55秒 | +| [contracts](https://github.com/ClickHouse/examples/blob/main/ethereum/schemas/contracts.md) | 57,225,837 | 350 | 45.35GB | 16秒 | 1小时 51分钟 | 39.4秒 | +| 总计 | 82.6亿 | 23,577 | 3.982TB | 8分钟 3秒 | \> 6天 5小时 | 53分钟 45秒 | + + + +## 将表数据导出到 GCS {#1-export-table-data-to-gcs} + +在此步骤中,我们利用 [BigQuery SQL 工作区](https://cloud.google.com/bigquery/docs/bigquery-web-ui) 执行我们的 SQL 命令。下面,我们使用 [`EXPORT DATA`](https://cloud.google.com/bigquery/docs/reference/standard-sql/other-statements) 语句将 BigQuery 表 `mytable` 导出到 GCS 存储桶。 + +```sql +DECLARE export_path STRING; +DECLARE n INT64; +DECLARE i INT64; +SET i = 0; + +-- We recommend setting n to correspond to x billion rows. So 5 billion rows, n = 5 +SET n = 100; + +WHILE i < n DO + SET export_path = CONCAT('gs://mybucket/mytable/', i,'-*.parquet'); + EXPORT DATA + OPTIONS ( + uri = export_path, + format = 'PARQUET', + overwrite = true + ) + AS ( + SELECT * FROM mytable WHERE export_id = i + ); + SET i = i + 1; +END WHILE; +``` + +在上述查询中,我们将 BigQuery 表导出为 [Parquet 数据格式](https://parquet.apache.org/)。我们在 `uri` 参数中具有 `*` 字符。这确保如果导出的数据超过 1GB,输出将分片为多个文件,并且具有递增的数字后缀。 + +这种方法有多个优点: + +- Google 允许每天最多将 50TB 数据免费导出到 GCS。用户仅需为 GCS 存储付费。 +- 导出会自动生成多个文件,限制每个文件最大为 1GB 的表数据。这对 ClickHouse 有好处,因为它允许导入并行化。 +- Parquet 作为一种列式格式,提供了更好的交换格式,因为它本质上是压缩的,BigQuery 导出和 ClickHouse 查询的速度更快。 + +## 从 GCS 导入数据到 ClickHouse {#2-importing-data-into-clickhouse-from-gcs} + +一旦导出完成,我们可以将这些数据导入到 ClickHouse 表中。您可以使用 [ClickHouse SQL 控制台](/integrations/sql-clients/sql-console) 或 [`clickhouse-client`](/interfaces/cli) 执行以下命令。 + +您必须先在 ClickHouse 中 [创建表](/sql-reference/statements/create/table): + +```sql +-- If your BigQuery table contains a column of type STRUCT, you must enable this setting +-- to map that column to a ClickHouse column of type Nested +SET input_format_parquet_import_nested = 1; + +CREATE TABLE default.mytable +( + `timestamp` DateTime64(6), + `some_text` String +) +ENGINE = MergeTree +ORDER BY (timestamp); +``` + +创建表之后,如果您的集群中有多个 ClickHouse 副本,请启用设置 `parallel_distributed_insert_select` 来加速我们的导出。如果您只有一个 ClickHouse 节点,则可以跳过此步骤: + +```sql +SET parallel_distributed_insert_select = 1; +``` + +最后,我们可以使用 [`INSERT INTO SELECT` 命令](/sql-reference/statements/insert-into#inserting-the-results-of-select) 将 GCS 中的数据插入到 ClickHouse 表中,该命令基于 `SELECT` 查询的结果将数据插入表中。 + +为了检索要 `INSERT` 的数据,我们可以使用 [s3Cluster 函数](/sql-reference/table-functions/s3Cluster) 从我们的 GCS 存储桶中检索数据,因为 GCS 与 [Amazon S3](https://aws.amazon.com/s3/) 兼容。如果您只有一个 ClickHouse 节点,也可以使用 [s3 表函数](/sql-reference/table-functions/s3) 而不是 `s3Cluster` 函数。 + +```sql +INSERT INTO mytable +SELECT + timestamp, + ifNull(some_text, '') AS some_text +FROM s3Cluster( + 'default', + 'https://storage.googleapis.com/mybucket/mytable/*.parquet.gz', + '', + '' +); +``` + +上述查询中使用的 `ACCESS_ID` 和 `SECRET` 是与您的 GCS 存储桶关联的 [HMAC 密钥](https://cloud.google.com/storage/docs/authentication/hmackeys)。 + +:::note 使用 `ifNull` 导出 nullable 列 +在上述查询中,我们使用 [`ifNull` 函数](/sql-reference/functions/functions-for-nulls#ifNull) 在 `some_text` 列中插入数据到我们的 ClickHouse 表中,设置默认值。您也可以在 ClickHouse 中将列设置为 [`Nullable`](/sql-reference/data-types/nullable),但不建议这样做,因为可能会对性能产生负面影响。 + +另外,您可以 `SET input_format_null_as_default=1`,任何缺失或 NULL 值将被替换为其各自列的默认值(如果已指定这些默认值)。 +::: + +## 测试数据导出是否成功 {#3-testing-successful-data-export} + +要测试您的数据是否正确插入,只需在您的新表上运行 `SELECT` 查询: + +```sql +SELECT * FROM mytable LIMIT 10; +``` + +要导出更多的 BigQuery 表,只需为每个附加表重复上述步骤。 + + + +## 进一步阅读和支持 {#further-reading-and-support} + +除了本指南外,我们还推荐阅读我们的博客文章,展示 [如何使用 ClickHouse 加速 BigQuery 以及如何处理增量导入](https://clickhouse.com/blog/clickhouse-bigquery-migrating-data-for-realtime-queries)。 + +如果您在从 BigQuery 到 ClickHouse 传输数据时遇到问题,请随时通过 support@clickhouse.com 联系我们。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/03_bigquery/03_loading-data.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/03_bigquery/03_loading-data.md.hash new file mode 100644 index 00000000000..b2c2ecc2b44 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/03_bigquery/03_loading-data.md.hash @@ -0,0 +1 @@ +c630731ca2f98fc5 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/03_bigquery/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/03_bigquery/index.md new file mode 100644 index 00000000000..21eb151737f --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/03_bigquery/index.md @@ -0,0 +1,19 @@ +--- +'slug': '/migrations/bigquery' +'title': 'BigQuery' +'pagination_prev': null +'pagination_next': null +'description': 'BigQuery 迁移部分的着陆页' +'keywords': +- 'BigQuery' +- 'migration' +'doc_type': 'landing-page' +--- + +在本节文档中,了解 BigQuery 和 ClickHouse Cloud 之间的相似之处和不同之处,以及您可能想要迁移的原因和方法。 + +| 页面 | 描述 | +|-----------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------| +| [BigQuery vs ClickHouse Cloud](/migrations/bigquery/biquery-vs-clickhouse-cloud) | ClickHouse Cloud 中资源的组织方式与 BigQuery 的资源层次结构相似。我们在本文中描述了具体的不同之处。 | +| [从 BigQuery 迁移到 ClickHouse Cloud](/migrations/bigquery/migrating-to-clickhouse-cloud) | 了解您可能想要从 BigQuery 迁移到 ClickHouse Cloud 的原因。 | +| [加载数据](/migrations/bigquery/loading-data) | 一份指南,向您展示如何将数据从 BigQuery 迁移到 ClickHouse。 | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/03_bigquery/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/03_bigquery/index.md.hash new file mode 100644 index 00000000000..7b991a2e15b --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/03_bigquery/index.md.hash @@ -0,0 +1 @@ +c987d529f1791379 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/04_snowflake/01_overview.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/04_snowflake/01_overview.md new file mode 100644 index 00000000000..0928b05d27d --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/04_snowflake/01_overview.md @@ -0,0 +1,69 @@ +--- +'sidebar_label': '概述' +'slug': '/migrations/snowflake-overview' +'description': '从 Snowflake 迁移到 ClickHouse' +'keywords': +- 'Snowflake' +'title': '从 Snowflake 迁移到 ClickHouse' +'show_related_blogs': true +'doc_type': 'guide' +--- + +import snowflake_architecture from '@site/static/images/cloud/onboard/discover/use_cases/snowflake_architecture.png'; +import cloud_architecture from '@site/static/images/cloud/onboard/discover/use_cases/cloud_architecture.png'; +import Image from '@theme/IdealImage'; + + +# Snowflake 到 ClickHouse 的迁移 + +> 本文档提供了从 Snowflake 迁移数据到 ClickHouse 的介绍。 + +Snowflake 是一个以云数据仓库为主的产品,主要专注于将传统的本地数据仓库工作负载迁移到云端。它经过良好优化,能够在大规模环境中执行长时间运行的报告。随着数据集迁移到云端,数据拥有者开始思考如何从这些数据中提取更多价值,包括利用这些数据集来支撑内部和外部用例的实时应用。当这种情况发生时,他们通常意识到需要一个优化以处理实时分析的数据库,如 ClickHouse。 + +## 比较 {#comparison} + +在本节中,我们将比较 ClickHouse 和 Snowflake 的主要特性。 + +### 相似点 {#similarities} + +Snowflake 是一个基于云的数据仓库平台,提供一种可扩展和高效的解决方案,用于存储、处理和分析大量数据。与 ClickHouse 一样,Snowflake 不是建立在现有技术之上,而是依赖于其自己的 SQL 查询引擎和定制架构。 + +Snowflake 的架构被描述为共享存储(shared-disk)架构和无共享架构(shared-nothing architecture)的混合体。共享存储架构是指数据可以通过对象存储(如 S3)从所有计算节点访问。无共享架构指的是每个计算节点在本地存储整个数据集的一部分以响应查询。理论上,这提供了两种模型的最佳性能:共享磁盘架构的简单性和无共享架构的可扩展性。 + +该设计在根本上依赖于对象存储作为主要存储介质,这在并发访问下几乎无限扩展,同时提供高韧性和可扩展的吞吐量保证。 + +下面的图像来源于 [docs.snowflake.com](https://docs.snowflake.com/en/user-guide/intro-key-concepts),展示了这种架构: + +Snowflake architecture + +相反,作为一个开源和云托管的产品,ClickHouse 可以在共享磁盘和无共享架构中进行部署。后者通常适用于自管理的部署。尽管允许 CPU 和内存易于扩展,但无共享配置引入了经典的数据管理挑战以及数据复制的开销,特别是在成员变化期间。 + +因此,ClickHouse Cloud 采用了与 Snowflake 概念上类似的共享存储架构。数据在对象存储(单一副本)中仅存储一次,例如 S3 或 GCS,提供几乎无限的存储,并具备强大的冗余保证。每个节点可以访问这一单一数据副本以及其本地 SSD 用于缓存。节点可以进行扩展,以根据需要提供额外的 CPU 和内存资源。与 Snowflake 类似,S3 的可扩展性特性通过确保在集群中添加额外节点时不会影响当前节点的 I/O 吞吐量,解决了共享磁盘架构的经典限制(磁盘 I/O 和网络瓶颈)。 + +ClickHouse Cloud architecture + +### 不同点 {#differences} + +除了底层存储格式和查询引擎,这些架构在几个微妙的方面有所不同: + +* Snowflake 中的计算资源通过 [仓库](https://docs.snowflake.com/en/user-guide/warehouses) 的概念提供。这些仓库由多个节点组成,每个节点具有固定大小。虽然 Snowflake 并未公布其仓库的具体架构,但 [通常理解](https://select.dev/posts/snowflake-warehouse-sizing) 为每个节点由 8 个 vCPU、16GiB 和 200GB 的本地存储(用于缓存)组成。节点的数量取决于 T 恤尺码,例如超小型有一个节点,小型有两个, 中型有四个,大型有八个,等等。这些仓库与数据是独立的,可以用于查询位于对象存储上的任何数据库。当处于空闲状态且未承受查询负载时,仓库会暂停 - 一旦收到查询则恢复。虽然存储成本始终反映在账单中,但仓库仅在活跃时收取费用。 + +* ClickHouse Cloud 采用类似的原则,使用带有本地缓存存储的节点。用户不是按 T 恤尺码进行部署,而是根据计算总量和可用 RAM 部署服务。这反过来在查询负载的基础上透明地进行自动扩展(在定义的限制内) - 通过增加(或减少)每个节点的资源进行垂直扩展,或通过增加/减少节点总数进行水平扩展。ClickHouse Cloud 节点目前具有 1:1 的 CPU 与内存比例,而 Snowflake 的比例为 1。虽然可以实现更松散的耦合,但服务目前与数据耦合,不像 Snowflake 的仓库那样。节点在空闲时也会暂停,并在受到查询时恢复。用户如有必要,也可以手动调整服务大小。 + +* ClickHouse Cloud 的查询缓存目前是特定于节点的,而 Snowflake 的查询缓存是以独立于仓库的服务层提供的。根据基准测试,ClickHouse Cloud 的节点缓存性能优于 Snowflake 的。 + +* Snowflake 和 ClickHouse Cloud 在扩展以增加查询并发性方面采取了不同的方法。Snowflake 通过一个称为 [多集群仓库](https://docs.snowflake.com/en/user-guide/warehouses-multicluster#benefits-of-multi-cluster-warehouses) 的功能来处理这个问题。该功能允许用户为仓库添加集群。虽然这不会改善查询延迟,但确实提供了额外的并行ization,并允许更高的查询并发性。ClickHouse 通过增加服务的内存和 CPU 进行垂直或水平扩展来实现这一点。我们在这篇博客中没有探讨这些服务在扩展到更高并发性方面的能力,而是集中于延迟,但承认这项工作应当进行,以便进行全面比较。然而,我们预计 ClickHouse 在任何并发测试中表现良好,而 Snowflake 在 [仓库默认情况下限制每个仓库的最大并发查询数为 8](https://docs.snowflake.com/en/sql-reference/parameters#max-concurrency-level)。相比之下,ClickHouse Cloud 允许每个节点执行多达 1000 个查询。 + +* Snowflake 在数据集上切换计算大小的能力,加上仓库的快速恢复时间,使其在临时查询方面提供了出色的体验。对于数据仓库和数据湖用例,这提供了比其他系统更大的优势。 + +### 实时分析 {#real-time-analytics} + +根据公开的 [基准](https://benchmark.clickhouse.com/#system=+%E2%98%81w|%EF%B8%8Fr|C%20c|nfe&type=-&machine=-ca2|gl|6ax|6ale|3al&cluster_size=-&opensource=-&tuned=+n&metric=hot&queries=-) 数据,ClickHouse 在以下领域的实时分析应用中优于 Snowflake: + +* **查询延迟**:即使在对表应用聚类以优化性能时,Snowflake 查询的查询延迟也更高。在我们的测试中,Snowflake 需要超过两倍的计算资源才能在对 Snowflake 聚类键或 ClickHouse 主键应用过滤器的查询中达到等效的 ClickHouse 性能。虽然 Snowflake 的 [持久查询缓存](https://docs.snowflake.com/en/user-guide/querying-persisted-results) 缓解了部分延迟挑战,但在过滤标准更加多样化的情况下效果不佳。这一查询缓存的有效性还会受到基础数据变化的影响,当表发生变化时,缓存条目会失效。尽管在我们应用的基准测试中并非如此,但实际部署需要插入新的、最近的数据。请注意,ClickHouse 的查询缓存是特定于节点的,并且不是 [事务一致的](https://clickhouse.com/blog/introduction-to-the-clickhouse-query-cache-and-design),因此对于实时分析 [更为合适](https://clickhouse.com/blog/introduction-to-the-clickhouse-query-cache-and-design)。用户还可以对其使用进行细粒度控制,可以在 [每个查询的基础上](https://operations/settings/settings#use_query_cache) 控制其使用、[精确大小](https://operations/settings/settings#query_cache_max_size_in_bytes)、是否 [缓存查询](https://operations/settings/settings#enable_writes_to_query_cache)(限制持续时间或需要的执行次数)以及是否仅 [被动使用](https://clickhouse.com/blog/introduction-to-the-clickhouse-query-cache-and-design#using-logs-and-settings)。 + +* **更低的成本**:Snowflake 仓库可以配置为在查询不活跃时暂停。一旦暂停,将不会产生费用。实际上,这一非活动检查 [仅能降低到 60 秒](https://docs.snowflake.com/en/sql-reference/sql/alter-warehouse)。仓库在收到查询后会自动恢复,通常在几秒钟内完成。由于 Snowflake 只在仓库使用时对资源收取费用,这一行为非常适合于经常闲置的工作负载,例如临时查询。 + + 然而,许多实时分析工作负载需要持续的实时数据摄取和频繁的查询,这并不受益于闲置(如面向客户的仪表板)。这意味着仓库通常必须保持完全活跃并产生费用。这消除了闲置的成本效益以及可能与 Snowflake 能够更快恢复响应状态相关的任何性能优势。这种活跃状态的要求,加上 ClickHouse Cloud 在活跃状态下每秒的更低成本,导致 ClickHouse Cloud 在这类工作负载中提供显著更低的总成本。 + +* **特征的可预测定价:** 在实时分析用例中,实现最高级别的性能所需的特征,例如物化视图和聚类(相当于 ClickHouse 的 ORDER BY),在 Snowflake 中会产生额外费用,要求不仅采用更高的等级,这导致每个信用的成本增加 1.5 倍,还有不可预测的后台费用。例如,物化视图会产生后台维护成本,聚类也是如此,这在使用之前是难以预测的。相比之下,这些特征在 ClickHouse Cloud 中没有额外成本,除了在插入时额外的 CPU 和内存使用,通常在插入工作负载较高的情况下才会显著。我们在基准测试中观察到,这些差异,加上更低的查询延迟和更高的压缩率,使得 ClickHouse 的成本显著降低。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/04_snowflake/01_overview.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/04_snowflake/01_overview.md.hash new file mode 100644 index 00000000000..a0ef83b0f3e --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/04_snowflake/01_overview.md.hash @@ -0,0 +1 @@ +5397c3fe4e88cb9d diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/04_snowflake/02_migration_guide.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/04_snowflake/02_migration_guide.md new file mode 100644 index 00000000000..a8b17ef6d47 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/04_snowflake/02_migration_guide.md @@ -0,0 +1,115 @@ +--- +'sidebar_label': '迁移指南' +'slug': '/migrations/snowflake' +'description': '从 Snowflake 迁移到 ClickHouse' +'keywords': +- 'Snowflake' +'title': '从 Snowflake 迁移到 ClickHouse' +'show_related_blogs': false +'doc_type': 'guide' +--- + +import migrate_snowflake_clickhouse from '@site/static/images/migrations/migrate_snowflake_clickhouse.png'; +import Image from '@theme/IdealImage'; + + +# 从 Snowflake 迁移到 ClickHouse + +> 本指南将向您展示如何将数据从 Snowflake 迁移到 ClickHouse。 + +在 Snowflake 和 ClickHouse 之间迁移数据需要使用对象存储,如 S3,作为传输的中间存储。迁移过程还依赖于使用 Snowflake 的 `COPY INTO` 命令和 ClickHouse 的 `INSERT INTO SELECT`。 + + + +## 从 Snowflake 导出数据 {#1-exporting-data-from-snowflake} + +从 Snowflake 迁移到 ClickHouse + +从 Snowflake 导出数据需要使用外部阶段,如上图所示。 + +假设我们想要导出一个具有以下模式的 Snowflake 表: + +```sql +CREATE TABLE MYDATASET ( + timestamp TIMESTAMP, + some_text varchar, + some_file OBJECT, + complex_data VARIANT, +) DATA_RETENTION_TIME_IN_DAYS = 0; +``` + +要将此表的数据转移到 ClickHouse 数据库中,我们首先需要将这些数据复制到外部阶段。在复制数据时,我们建议使用 Parquet 作为中间格式,因为它允许共享类型信息、保留精度、压缩效果良好,并原生支持分析中常见的嵌套结构。 + +在下面的示例中,我们在 Snowflake 中创建一个命名文件格式来表示 Parquet 和所需的文件选项。然后,我们指定哪个存储桶将包含我们复制的数据集。最后,我们将数据集复制到存储桶中。 + +```sql +CREATE FILE FORMAT my_parquet_format TYPE = parquet; + +-- Create the external stage that specifies the S3 bucket to copy into +CREATE OR REPLACE STAGE external_stage +URL='s3://mybucket/mydataset' +CREDENTIALS=(AWS_KEY_ID='' AWS_SECRET_KEY='') +FILE_FORMAT = my_parquet_format; + +-- Apply "mydataset" prefix to all files and specify a max file size of 150mb +-- The `header=true` parameter is required to get column names +COPY INTO @external_stage/mydataset from mydataset max_file_size=157286400 header=true; +``` + +对于大约 5TB 的数据集,最大文件大小为 150MB,并使用位于 AWS `us-east-1` 区域的 2X-Large Snowflake 仓库,复制数据到 S3 存储桶大约需要 30 分钟。 + +## 导入到 ClickHouse {#2-importing-to-clickhouse} + +一旦数据被暂存到中间对象存储中,可以使用 ClickHouse 函数,例如 [s3 表函数](/sql-reference/table-functions/s3),将数据插入到表中,如下所示。 + +这个示例使用 AWS S3 的 [s3 表函数](/sql-reference/table-functions/s3),但是 [gcs 表函数](/sql-reference/table-functions/gcs) 可用于 Google Cloud Storage,而 [azureBlobStorage 表函数](/sql-reference/table-functions/azureBlobStorage) 可用于 Azure Blob Storage。 + +假设以下表的目标模式: + +```sql +CREATE TABLE default.mydataset +( + `timestamp` DateTime64(6), + `some_text` String, + `some_file` Tuple(filename String, version String), + `complex_data` Tuple(name String, description String), +) +ENGINE = MergeTree +ORDER BY (timestamp) +``` + +然后,我们可以使用 `INSERT INTO SELECT` 命令将 S3 中的数据插入到 ClickHouse 表中: + +```sql +INSERT INTO mydataset +SELECT + timestamp, + some_text, + JSONExtract( + ifNull(some_file, '{}'), + 'Tuple(filename String, version String)' + ) AS some_file, + JSONExtract( + ifNull(complex_data, '{}'), + 'Tuple(filename String, description String)' + ) AS complex_data, +FROM s3('https://mybucket.s3.amazonaws.com/mydataset/mydataset*.parquet') +SETTINGS input_format_null_as_default = 1, -- Ensure columns are inserted as default if values are null +input_format_parquet_case_insensitive_column_matching = 1 -- Column matching between source data and target table should be case insensitive +``` + +:::note 嵌套列结构的注意事项 +原始 Snowflake 表模式中的 `VARIANT` 和 `OBJECT` 列默认将作为 JSON 字符串输出,迫使我们在插入到 ClickHouse 时对这些进行转换。 + +诸如 `some_file` 这样的嵌套结构在复制时由 Snowflake 转换为 JSON 字符串。导入这些数据时,我们需要在 ClickHouse 插入时将这些结构转换为 Tuples,使用 [JSONExtract 函数](/sql-reference/functions/json-functions#JSONExtract),如上所示。 +::: + +## 测试成功的数据导出 {#3-testing-successful-data-export} + +要测试您的数据是否已正确插入,只需在新表上运行 `SELECT` 查询: + +```sql +SELECT * FROM mydataset LIMIT 10; +``` + + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/04_snowflake/02_migration_guide.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/04_snowflake/02_migration_guide.md.hash new file mode 100644 index 00000000000..5fe730f20d5 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/04_snowflake/02_migration_guide.md.hash @@ -0,0 +1 @@ +638bcf587ac97514 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/04_snowflake/03_sql_translation_reference.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/04_snowflake/03_sql_translation_reference.md new file mode 100644 index 00000000000..84830ebd758 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/04_snowflake/03_sql_translation_reference.md @@ -0,0 +1,66 @@ +--- +'sidebar_label': 'SQL 翻译参考' +'slug': '/migrations/snowflake-translation-reference' +'description': 'SQL 翻译参考' +'keywords': +- 'Snowflake' +'title': '从 Snowflake 迁移到 ClickHouse' +'show_related_blogs': true +'doc_type': 'guide' +--- + + +# Snowflake SQL 转换指南 + +## 数据类型 {#data-types} + +### 数值类型 {#numerics} + +在 ClickHouse 和 Snowflake 之间移动数据的用户会立即注意到, +ClickHouse 提供了更细粒度的数字声明精度。例如, +Snowflake 提供数字类型 Number。这个类型要求用户指定精度(总位数)和小数位数(小数点右侧的位数),总共最多为 38。整数声明与 Number 同义,仅定义固定的精度和小数位数,而且范围相同。这种便利性得益于在 Snowflake 中修改精度(对于整数小数位数为 0)并不会影响磁盘上的数据大小 - 在微分区级别写入时会使用最小所需的字节来满足数值范围。然而,小数位数确实会影响存储空间,并通过压缩进行抵消。`Float64` 类型提供更大的值范围,但精度有所下降。 + +将其与 ClickHouse 对比,后者提供多种有符号和无符号的浮点和整数精度。借助这些,ClickHouse 用户可以明确整数所需的精度以优化存储和内存开销。Decimal 类型,相当于 Snowflake 的 Number 类型,也提供两倍的精度和76位小数。除了类似的 `Float64` 值,ClickHouse 还提供 `Float32`,用于当精度不那么关键而压缩至关重要的情况。 + +### 字符串类型 {#strings} + +ClickHouse 和 Snowflake 在字符串数据存储方面采取了对比鲜明的方法。Snowflake 中的 `VARCHAR` 存储 UTF-8 编码的 Unicode 字符,允许用户指定最大长度。此长度对存储或性能没有影响,始终使用最小字节数来存储字符串,而只是提供有用的约束供下游工具使用。其他类型如 `Text` 和 `NChar` 只是此类型的别名。相反,ClickHouse 将所有 [字符串数据作为原始字节](/sql-reference/data-types/string) 存储,使用 `String` 类型(不需要指定长度),编码的任务推给用户,并提供 [查询时函数](/sql-reference/functions/string-functions#lengthutf8) 来处理不同的编码。我们建议读者参考 ["不透明数据参数"](https://utf8everywhere.org/#cookie) 来了解背后的动机。因此,ClickHouse 的 `String` 类型在实现上更可比于 Snowflake 的 Binary 类型。 [Snowflake](https://docs.snowflake.com/en/sql-reference/collation) 和 [ClickHouse](/sql-reference/statements/select/order-by#collation-support) 均支持“排序”,允许用户覆盖字符串的排序和比较方式。 + +### 半结构化类型 {#semi-structured-data} + +Snowflake 支持半结构化数据的 `VARIANT`、`OBJECT` 和 `ARRAY` 类型。 + +ClickHouse 提供相应的 [`Variant`](/sql-reference/data-types/variant)、`Object`(现已弃用,替代为原生 `JSON` 类型)和 [`Array`](/sql-reference/data-types/array) 类型。此外,ClickHouse 还具有 [`JSON`](/sql-reference/data-types/newjson) 类型,该类型取代了现已弃用的 `Object('json')` 类型,并在 [与其他本地 JSON 类型的比较中](https://jsonbench.com/) 特别高效和节省存储。 + +ClickHouse 还支持命名的 [`Tuple`](/sql-reference/data-types/tuple) 和通过 [`Nested`](/sql-reference/data-types/nested-data-structures/nested) 类型的元组数组,允许用户明确映射嵌套结构。这允许在整个层次结构中应用编解码器和类型优化,与 Snowflake 不同,后者要求用户使用 `OBJECT`、`VARIANT` 和 `ARRAY` 类型用于外部对象,并且不允许 [明确的内部类型](https://docs.snowflake.com/en/sql-reference/data-types-semistructured#characteristics-of-an-object)。这种内部类型也简化了 ClickHouse 中嵌套数字的查询,因为无需转换,可以在索引定义中使用。 + +在 ClickHouse 中,编解码器和优化类型也可以应用于子结构。这带来了一个附加好处,即与扁平化数据相比,嵌套结构的压缩效果依然出色。相比之下,由于无法对子结构应用特定类型,Snowflake 建议 [扁平化数据以获得最佳压缩效果](https://docs.snowflake.com/en/user-guide/semistructured-considerations#storing-semi-structured-data-in-a-variant-column-vs-flattening-the-nested-structure)。Snowflake 还对这些数据类型 [施加大小限制](https://docs.snowflake.com/en/user-guide/semistructured-considerations#data-size-limitations)。 + +### 类型参考 {#type-reference} + +| Snowflake | ClickHouse | 注意 | +|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| [`NUMBER`](https://docs.snowflake.com/en/sql-reference/data-types-numeric) | [`Decimal`](/sql-reference/data-types/decimal) | ClickHouse 支持的精度和小数位数是 Snowflake 的两倍 - 76 位与 38 位。 | +| [`FLOAT`, `FLOAT4`, `FLOAT8`](https://docs.snowflake.com/en/sql-reference/data-types-numeric#data-types-for-floating-point-numbers) | [`Float32`, `Float64`](/sql-reference/data-types/float) | Snowflake 中的所有浮点数都是 64 位。 | +| [`VARCHAR`](https://docs.snowflake.com/en/sql-reference/data-types-text#varchar) | [`String`](/sql-reference/data-types/string) | | +| [`BINARY`](https://docs.snowflake.com/en/sql-reference/data-types-text#binary) | [`String`](/sql-reference/data-types/string) | | +| [`BOOLEAN`](https://docs.snowflake.com/en/sql-reference/data-types-logical) | [`Bool`](/sql-reference/data-types/boolean) | | +| [`DATE`](https://docs.snowflake.com/en/sql-reference/data-types-datetime#date) | [`Date`](/sql-reference/data-types/date), [`Date32`](/sql-reference/data-types/date32) | 在 Snowflake 中的 `DATE` 提供比 ClickHouse 更广泛的日期范围,例如 `Date32` 的最小值为 `1900-01-01`,而 `Date` 为 `1970-01-01`。ClickHouse 的 `Date` 提供更具成本效益(两字节)的存储。 | +| [`TIME(N)`](https://docs.snowflake.com/en/sql-reference/data-types-datetime#time) | 没有直接等价类型,但可以表示为 [`DateTime`](/sql-reference/data-types/datetime) 和 [`DateTime64(N)`](/sql-reference/data-types/datetime64). | `DateTime64` 使用相同的精度概念。 | +| [`TIMESTAMP`](https://docs.snowflake.com/en/sql-reference/data-types-datetime#timestamp) - [`TIMESTAMP_LTZ`](https://docs.snowflake.com/en/sql-reference/data-types-datetime#timestamp-ltz-timestamp-ntz-timestamp-tz), [`TIMESTAMP_NTZ`](https://docs.snowflake.com/en/sql-reference/data-types-datetime#timestamp-ltz-timestamp-ntz-timestamp-tz), [`TIMESTAMP_TZ`](https://docs.snowflake.com/en/sql-reference/data-types-datetime#timestamp-ltz-timestamp-ntz-timestamp-tz) | [`DateTime`](/sql-reference/data-types/datetime) 和 [`DateTime64`](/sql-reference/data-types/datetime64) | `DateTime` 和 `DateTime64` 可以选择性为列定义 TZ 参数。如果不存在,将使用服务器的时区。此外,客户端还可以使用 `--use_client_time_zone` 参数。 | +| [`VARIANT`](https://docs.snowflake.com/en/sql-reference/data-types-semistructured#variant) | [`JSON`, `Tuple`, `Nested`](/interfaces/formats) | `JSON` 类型在 ClickHouse 中是实验性的。该类型在插入时推断列类型。`Tuple`、`Nested` 和 `Array` 也可用于构建显式类型结构作为替代方案。 | +| [`OBJECT`](https://docs.snowflake.com/en/sql-reference/data-types-semistructured#object) | [`Tuple`, `Map`, `JSON`](/interfaces/formats) | `OBJECT` 和 `Map` 类似于 ClickHouse 中的 `JSON` 类型,其中键为 `String`。ClickHouse 要求值保持一致并具有强类型,而 Snowflake 使用 `VARIANT`。这意味着不同键的值可以是不同的类型。如果 ClickHouse 中需要此功能,请使用 `Tuple` 显式定义层次结构,或依赖于 `JSON` 类型。 | +| [`ARRAY`](https://docs.snowflake.com/en/sql-reference/data-types-semistructured#array) | [`Array`](/sql-reference/data-types/array), [`Nested`](/sql-reference/data-types/nested-data-structures/nested) | Snowflake 中的 `ARRAY` 使用 `VARIANT` 作为元素 - 一种超类型。相比之下,这些在 ClickHouse 中是强类型的。 | +| [`GEOGRAPHY`](https://docs.snowflake.com/en/sql-reference/data-types-geospatial#geography-data-type) | [`Point`, `Ring`, `Polygon`, `MultiPolygon`](/sql-reference/data-types/geo) | Snowflake 使用坐标系统(WGS 84),而 ClickHouse 在查询时应用。 | +| [`GEOMETRY`](https://docs.snowflake.com/en/sql-reference/data-types-geospatial#geometry-data-type) | [`Point`, `Ring`, `Polygon`, `MultiPolygon`](/sql-reference/data-types/geo) | | | + +| ClickHouse 类型 | 描述 | +|-------------------|-----------------------------------------------------------------------------------------------------| +| `IPv4` 和 `IPv6` | IP 特定类型,可能比 Snowflake 更有效率地存储。 | +| `FixedString` | 允许使用固定长度的字节,这对哈希很有用。 | +| `LowCardinality` | 允许任何类型进行字典编码。当基数预期小于 100k 时非常有用。 | +| `Enum` | 允许以 8 位或 16 位范围有效编码命名值。 | +| `UUID` | 用于高效存储 UUID。 | +| `Array(Float32)` | 向量可以表示为 Float32 数组,并支持距离函数。 | + +最后,ClickHouse 提供了存储聚合函数 [中间状态](/sql-reference/data-types/aggregatefunction) 的独特能力。该状态是实现特定的,但允许存储聚合结果并随后查询(带有相应的合并函数)。通常,此功能通过物化视图使用,如下面所示,通过存储对插入数据的查询增量结果来提高特定查询的性能,并以最小的存储成本实现(更多细节请参见这里)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/04_snowflake/03_sql_translation_reference.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/04_snowflake/03_sql_translation_reference.md.hash new file mode 100644 index 00000000000..fe290d749bb --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/04_snowflake/03_sql_translation_reference.md.hash @@ -0,0 +1 @@ +2337099cf76294c8 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/04_snowflake/_category_.json b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/04_snowflake/_category_.json new file mode 100644 index 00000000000..50b05cb45a0 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/04_snowflake/_category_.json @@ -0,0 +1,5 @@ +{ + "label": "Snowflake", + "collapsible": true, + "collapsed": true, +} \ No newline at end of file diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/05_elastic/01_overview.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/05_elastic/01_overview.md new file mode 100644 index 00000000000..6f4d1a1737e --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/05_elastic/01_overview.md @@ -0,0 +1,15 @@ +--- +'sidebar_label': '概览' +'slug': '/migrations/elastic-overview' +'description': '从 Snowflake 到 ClickHouse 的迁移' +'keywords': +- 'Snowflake' +'title': '从 Snowflake 迁移到 ClickHouse' +'show_related_blogs': true +'doc_type': 'landing-page' +--- + + +# Elasticsearch 到 ClickHouse 迁移 + +有关可观察性用例,请参阅 [Elasticsearch 到 ClickStack](/use-cases/observability/clickstack/migration/elastic) 迁移文档。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/05_elastic/01_overview.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/05_elastic/01_overview.md.hash new file mode 100644 index 00000000000..6290c6ca69c --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/05_elastic/01_overview.md.hash @@ -0,0 +1 @@ +eb7f41486298aa1d diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/05_elastic/_category_.json b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/05_elastic/_category_.json new file mode 100644 index 00000000000..4f49621cf3d --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/05_elastic/_category_.json @@ -0,0 +1,5 @@ +{ + "label": "Elasticsearch", + "collapsible": true, + "collapsed": true +} \ No newline at end of file diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/06_redshift/01_overview.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/06_redshift/01_overview.md new file mode 100644 index 00000000000..83543e33a20 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/06_redshift/01_overview.md @@ -0,0 +1,34 @@ +--- +'sidebar_label': '概述' +'slug': '/migrations/redshift-overview' +'description': '从 Amazon Redshift 迁移到 ClickHouse' +'keywords': +- 'Redshift' +'title': '比较 ClickHouse Cloud 和 Amazon Redshift' +'doc_type': 'guide' +--- + + +# Amazon Redshift 到 ClickHouse 的迁移 + +> 本文档介绍了将数据从 Amazon Redshift 迁移到 ClickHouse 的相关内容。 + +## 介绍 {#introduction} + +Amazon Redshift 是一个云数据仓库,提供对结构化和半结构化数据的报告和分析功能。它旨在使用类似于 ClickHouse 的列式数据库原则来处理大数据集上的分析工作负载。作为 AWS 产品的一部分,它通常是 AWS 用户在处理其分析数据需求时的默认解决方案。 + +尽管由于与 Amazon 生态系统的紧密集成而吸引了现有的 AWS 用户,但采用 Redshift 以支持实时分析应用的用户发现他们需要一个更优化的解决方案。因此,他们越来越倾向于选择 ClickHouse,以利用更优越的查询性能和数据压缩,作为替代方案或与现有的 Redshift 工作负载并行部署的“加速层”。 + +## ClickHouse vs Redshift {#clickhouse-vs-redshift} + +对于在 AWS 生态系统中深度投入的用户来说,Redshift 在面对数据仓库需求时是一个自然选择。Redshift 与 ClickHouse 在这一重要方面有所不同——它优化其引擎以处理需要复杂报告和分析查询的数据仓库工作负载。在所有部署模式中,以下两个限制使得使用 Redshift 处理实时分析工作负载变得困难: +* Redshift [为每个查询执行计划编译代码](https://docs.aws.amazon.com/redshift/latest/dg/c-query-performance.html),这为首次查询执行增加了显著的开销。当查询模式可预测且编译的执行计划可以存储在查询缓存中时,这种开销是合理的。然而,这在面对可变查询的交互式应用时引入了挑战。即便 Redshift 能够利用这个代码编译缓存,ClickHouse 在大多数查询上仍然更快。请参见 ["ClickBench"](https://benchmark.clickhouse.com/#system=+%E2%98%81w|%EF%B8%8Fr|C%20c|Rf&type=-&machine=-ca2|gl|6ax|6ale|3al&cluster_size=-&opensource=-&tuned=+n&metric=hot&queries=-)。 +* Redshift [将并发限制在 50 个队列中](https://docs.aws.amazon.com/redshift/latest/dg/c_workload_mngmt_classification.html),这(虽然对于商业智能足够)使得它不适合高度并发的分析应用。 + +相反,虽然 ClickHouse 也可以用于复杂的分析查询,但它优化了实时分析工作负载,无论是为应用提供动力还是充当数据仓库加速层。因此,Redshift 用户通常会出于以下原因使用 ClickHouse 替代或增强 Redshift: + +| 优势 | 描述 | +|-----------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| **更低的查询延迟** | ClickHouse 实现了更低的查询延迟,包括在高并发和流式插入下对于不同查询模式的支持。即使在查询未命中缓存的情况下(这是交互式用户分析中不可避免的),ClickHouse 仍然可以快速处理它。 | +| **更高的并发查询限制** | ClickHouse 对并发查询的限制要高得多,这对实时应用体验至关重要。在 ClickHouse 中,无论是自管理还是云端,您可以根据每个服务所需的并发进行计算资源的扩展。ClickHouse 中允许的查询并发级别是可配置的,ClickHouse Cloud 的默认值为 1000。 | +| **卓越的数据压缩** | ClickHouse 提供卓越的数据压缩,允许用户减少总存储(从而降低成本)或在相同成本下持久化更多数据,并从其数据中获取更多实时洞察。请参见下面的“ClickHouse vs Redshift 存储效率”。 | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/06_redshift/01_overview.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/06_redshift/01_overview.md.hash new file mode 100644 index 00000000000..f06a417fbbc --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/06_redshift/01_overview.md.hash @@ -0,0 +1 @@ +73480e41528acef2 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/06_redshift/02_migration_guide.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/06_redshift/02_migration_guide.md new file mode 100644 index 00000000000..8a375761ccf --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/06_redshift/02_migration_guide.md @@ -0,0 +1,16 @@ +--- +'sidebar_label': '迁移指南' +'slug': '/migrations/redshift/migration-guide' +'description': '从 Amazon Redshift 迁移到 ClickHouse' +'keywords': +- 'Redshift' +'title': 'Amazon Redshift 到 ClickHouse 迁移指南' +'doc_type': 'guide' +--- + +import MigrationGuide from '@site/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/redshift/_snippets/_migration_guide.md' + + +# Amazon Redshift 到 ClickHouse 迁移指南 + + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/06_redshift/02_migration_guide.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/06_redshift/02_migration_guide.md.hash new file mode 100644 index 00000000000..8a9af16ecea --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/06_redshift/02_migration_guide.md.hash @@ -0,0 +1 @@ +153863f77d31518f diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/06_redshift/03_sql_translation_reference.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/06_redshift/03_sql_translation_reference.md new file mode 100644 index 00000000000..9b0043cfa3a --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/06_redshift/03_sql_translation_reference.md @@ -0,0 +1,67 @@ +--- +'sidebar_label': 'SQL 翻译参考' +'slug': '/migrations/redshift/sql-translation-reference' +'description': 'Amazon Redshift 到 ClickHouse 的 SQL 翻译参考' +'keywords': +- 'Redshift' +'title': 'Amazon Redshift SQL 翻译指南' +'doc_type': 'reference' +--- + + +# Amazon Redshift SQL 翻译指南 + +## 数据类型 {#data-types} + +在 ClickHouse 和 Redshift 之间移动数据的用户会立即注意到,ClickHouse 提供了更广泛的类型范围,并且限制更少。虽然 Redshift 要求用户指定可能的字符串长度,即使是可变的,ClickHouse 通过以字节形式存储字符串来消除这种限制和负担。因此,ClickHouse 的 String 类型没有限制或长度规范要求。 + +此外,用户可以利用数组、元组和枚举——这些在 Redshift 中不存在作为一流公民(尽管可以用 `SUPER` 模拟数组/结构)并且是用户的常见挫折。ClickHouse 还允许在查询时或甚至在表中持久化聚合状态。这将使数据能够进行预聚合,通常使用物化视图,并且可以显著提高常见查询的性能。 + +下面我们将每个 Redshift 类型映射到相应的 ClickHouse 类型: + +| Redshift | ClickHouse | +|------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| [`SMALLINT`](https://docs.aws.amazon.com/redshift/latest/dg/r_Numeric_types201.html#r_Numeric_types201-integer-types) | [`Int8`](/sql-reference/data-types/int-uint) * | +| [`INTEGER`](https://docs.aws.amazon.com/redshift/latest/dg/r_Numeric_types201.html#r_Numeric_types201-integer-types) | [`Int32`](/sql-reference/data-types/int-uint) * | +| [`BIGINT`](https://docs.aws.amazon.com/redshift/latest/dg/r_Numeric_types201.html#r_Numeric_types201-integer-types) | [`Int64`](/sql-reference/data-types/int-uint) * | +| [`DECIMAL`](https://docs.aws.amazon.com/redshift/latest/dg/r_Numeric_types201.html#r_Numeric_types201-decimal-or-numeric-type) | [`UInt128`, `UInt256`, `Int128`, `Int256`](/sql-reference/data-types/int-uint), [`Decimal(P, S)`, `Decimal32(S)`, `Decimal64(S)`, `Decimal128(S)`, `Decimal256(S)`](/sql-reference/data-types/decimal) - (支持高精度和范围) | +| [`REAL`](https://docs.aws.amazon.com/redshift/latest/dg/r_Numeric_types201.html#r_Numeric_types201-floating-point-types) | [`Float32`](/sql-reference/data-types/float) | +| [`DOUBLE PRECISION`](https://docs.aws.amazon.com/redshift/latest/dg/r_Numeric_types201.html#r_Numeric_types201-floating-point-types) | [`Float64`](/sql-reference/data-types/float) | +| [`BOOLEAN`](https://docs.aws.amazon.com/redshift/latest/dg/r_Boolean_type.html) | [`Bool`](/sql-reference/data-types/boolean) | +| [`CHAR`](https://docs.aws.amazon.com/redshift/latest/dg/r_Character_types.html#r_Character_types-char-or-character) | [`String`](/sql-reference/data-types/string), [`FixedString`](/sql-reference/data-types/fixedstring) | +| [`VARCHAR`](https://docs.aws.amazon.com/redshift/latest/dg/r_Character_types.html#r_Character_types-varchar-or-character-varying) ** | [`String`](/sql-reference/data-types/string) | +| [`DATE`](https://docs.aws.amazon.com/redshift/latest/dg/r_Datetime_types.html#r_Datetime_types-date) | [`Date32`](/sql-reference/data-types/date32) | +| [`TIMESTAMP`](https://docs.aws.amazon.com/redshift/latest/dg/r_Datetime_types.html#r_Datetime_types-timestamp) | [`DateTime`](/sql-reference/data-types/datetime), [`DateTime64`](/sql-reference/data-types/datetime64) | +| [`TIMESTAMPTZ`](https://docs.aws.amazon.com/redshift/latest/dg/r_Datetime_types.html#r_Datetime_types-timestamptz) | [`DateTime`](/sql-reference/data-types/datetime), [`DateTime64`](/sql-reference/data-types/datetime64) | +| [`GEOMETRY`](https://docs.aws.amazon.com/redshift/latest/dg/geospatial-overview.html) | [地理数据类型](/sql-reference/data-types/geo) | +| [`GEOGRAPHY`](https://docs.aws.amazon.com/redshift/latest/dg/geospatial-overview.html) | [地理数据类型](/sql-reference/data-types/geo) (发展较少,例如没有坐标系统 - 可以通过 [函数](/sql-reference/functions/geo/) 模拟) | +| [`HLLSKETCH`](https://docs.aws.amazon.com/redshift/latest/dg/r_HLLSKTECH_type.html) | [`AggregateFunction(uniqHLL12, X)`](/sql-reference/data-types/aggregatefunction) | +| [`SUPER`](https://docs.aws.amazon.com/redshift/latest/dg/r_SUPER_type.html) | [`Tuple`](/sql-reference/data-types/tuple), [`Nested`](/sql-reference/data-types/nested-data-structures/nested), [`Array`](/sql-reference/data-types/array), [`JSON`](/sql-reference/data-types/newjson), [`Map`](/sql-reference/data-types/map) | +| [`TIME`](https://docs.aws.amazon.com/redshift/latest/dg/r_Datetime_types.html#r_Datetime_types-time) | [`DateTime`](/sql-reference/data-types/datetime), [`DateTime64`](/sql-reference/data-types/datetime64) | +| [`TIMETZ`](https://docs.aws.amazon.com/redshift/latest/dg/r_Datetime_types.html#r_Datetime_types-timetz) | [`DateTime`](/sql-reference/data-types/datetime), [`DateTime64`](/sql-reference/data-types/datetime64) | +| [`VARBYTE`](https://docs.aws.amazon.com/redshift/latest/dg/r_VARBYTE_type.html) ** | [`String`](/sql-reference/data-types/string) 结合 [`Bit`](/sql-reference/functions/bit-functions) 和 [Encoding](/sql-reference/functions/encoding-functions/#hex) 函数 | + +* ClickHouse 还支持具有扩展范围的无符号整数,即 `UInt8`, `UInt32`, `UInt32` 和 `UInt64`
+** ClickHouse 的 String 类型默认没有长度限制,但可以通过使用 约束 来限制特定长度。 + +## DDL 语法 {#compression} + +### 排序键 {#sorting-keys} + +ClickHouse 和 Redshift 都有“排序键”的概念,它定义了数据在存储时如何排序。Redshift 使用 `SORTKEY` 子句定义排序键: + +```sql +CREATE TABLE some_table(...) SORTKEY (column1, column2) +``` + +相对而言,ClickHouse 使用 `ORDER BY` 子句来指定排序顺序: + +```sql +CREATE TABLE some_table(...) ENGINE = MergeTree ORDER BY (column1, column2) +``` + +在大多数情况下,您可以在 ClickHouse 中使用与 Redshift 相同的排序键列和顺序,假设您使用的是默认的 `COMPOUND` 类型。当数据添加到 Redshift 时,您应该运行 `VACUUM` 和 `ANALYZE` 命令来重新排序新添加的数据并更新查询计划器的统计信息——否则,未排序的空间会增加。ClickHouse 不需要此类过程。 + +Redshift 支持一些方便的排序键功能。第一个是自动排序键(使用 `SORTKEY AUTO`)。虽然这可能适合入门,但显式排序键确保最佳性能和存储效率。第二个是 `INTERLEAVED` 排序键,它对排序键中的一组列赋予相等的权重,从而在查询使用一个或多个备用排序列时提高性能。ClickHouse 支持显式的 [投影](/data-modeling/projections),可以通过略微不同的设置实现相同的效果。 + +用户应注意,“主键”概念在 ClickHouse 和 Redshift 中代表不同的事物。在 Redshift 中,主键类似于传统的关系数据库管理系统中的概念,旨在实施约束。然而,它们在 Redshift 中并不严格执行,而是作为查询计划器和节点之间数据分布的提示。在 ClickHouse 中,主键表示用于构建稀疏主索引的列,该索引用于确保数据在磁盘上排序,从而最大化压缩,同时避免主索引的污染和浪费内存。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/06_redshift/03_sql_translation_reference.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/06_redshift/03_sql_translation_reference.md.hash new file mode 100644 index 00000000000..52e67e43b0c --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/06_redshift/03_sql_translation_reference.md.hash @@ -0,0 +1 @@ +14638af86d960d76 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/06_redshift/_category_.json b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/06_redshift/_category_.json new file mode 100644 index 00000000000..95419dcb41c --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/06_redshift/_category_.json @@ -0,0 +1,5 @@ +{ + "label": "Redshift", + "collapsible": true, + "collapsed": true, +} \ No newline at end of file diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/migration/clickhouse-to-cloud.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/07_OSS_to_Cloud/01_clickhouse-to-cloud.md similarity index 54% rename from i18n/zh/docusaurus-plugin-content-docs/current/integrations/migration/clickhouse-to-cloud.md rename to i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/07_OSS_to_Cloud/01_clickhouse-to-cloud.md index 586a4ac0064..5102b0fd4d0 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/migration/clickhouse-to-cloud.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/07_OSS_to_Cloud/01_clickhouse-to-cloud.md @@ -1,9 +1,9 @@ --- -'sidebar_position': 10 -'sidebar_label': 'ClickHouse 到 ClickHouse Cloud' +'sidebar_label': 'ClickHouse OSS' 'slug': '/cloud/migration/clickhouse-to-cloud' 'title': '在自管理 ClickHouse 和 ClickHouse Cloud 之间迁移' 'description': '页面描述如何在自管理 ClickHouse 和 ClickHouse Cloud 之间迁移' +'doc_type': 'guide' --- import Image from '@theme/IdealImage'; @@ -16,40 +16,38 @@ import self_managed_05 from '@site/static/images/integrations/migration/self-man import self_managed_06 from '@site/static/images/integrations/migration/self-managed-06.png'; -# 从自管理的 ClickHouse 迁移到 ClickHouse Cloud +# 从自管理 ClickHouse 迁移到 ClickHouse Cloud 迁移自管理的 ClickHouse -本指南将展示如何从自管理的 ClickHouse 服务器迁移到 ClickHouse Cloud,以及如何在 ClickHouse Cloud 服务之间迁移。 [`remoteSecure`](../../sql-reference/table-functions/remote.md) 函数在 `SELECT` 和 `INSERT` 查询中使用,以允许访问远程 ClickHouse 服务器,这使得迁移表变得简单,只需编写一个嵌入 `SELECT` 的 `INSERT INTO` 查询。 +本指南将展示如何从自管理的 ClickHouse 服务器迁移到 ClickHouse Cloud,以及如何在 ClickHouse Cloud 服务之间进行迁移。 `[`remoteSecure`](/sql-reference/table-functions/remote)` 函数用于 `SELECT` 和 `INSERT` 查询中,以允许访问远程 ClickHouse 服务器,使表的迁移变得简单,只需编写带有嵌入式 `SELECT` 的 `INSERT INTO` 查询。 ## 从自管理的 ClickHouse 迁移到 ClickHouse Cloud {#migrating-from-self-managed-clickhouse-to-clickhouse-cloud} 迁移自管理的 ClickHouse :::note -无论源表是否经过分片和/或复制,在 ClickHouse Cloud 上,您只需创建一个目标表(您可以省略此表的 Engine 参数,它将自动为 ReplicatedMergeTree 表), -ClickHouse Cloud 将自动处理纵向和横向扩展。您无需考虑如何复制和分片表。 +无论源表是否分片和/或复制,在 ClickHouse Cloud 上,您只需创建一个目标表(可以省略此表的 Engine 参数,它将自动成为 ReplicatedMergeTree 表),ClickHouse Cloud 将自动处理垂直和水平扩展。您无需考虑如何复制和分片表。 ::: -在这个例子中,自管理的 ClickHouse 服务器是 *源*,ClickHouse Cloud 服务是 *目标*。 +在此示例中,自管理的 ClickHouse 服务器是 *源*,ClickHouse Cloud 服务是 *目标*。 ### 概述 {#overview} -整个过程是: +该过程为: 1. 向源服务添加只读用户 1. 在目标服务上复制源表结构 -1. 从源拉取数据到目标,或根据源的网络可用性将数据从源推送到目标 -1. 从目标的 IP 访问列表中移除源服务器(如适用) -1. 从源服务中删除只读用户 - +1. 根据源的网络可用性,从源提取数据到目标,或将数据从源推送到目标 +1. 从目标的 IP 访问列表中移除源服务器(如果适用) +1. 从源服务中移除只读用户 ### 从一个系统迁移表到另一个系统: {#migration-of-tables-from-one-system-to-another} -此示例将一个表从自管理的 ClickHouse 服务器迁移到 ClickHouse Cloud。 +该示例将一个表从自管理的 ClickHouse 服务器迁移到 ClickHouse Cloud。 ### 在源 ClickHouse 系统上(当前托管数据的系统) {#on-the-source-clickhouse-system-the-system-that-currently-hosts-the-data} -- 添加一个可以读取源表(本例中为 `db.table`)的只读用户 +- 添加一个可以读取源表的只读用户(在此示例中为 `db.table`) ```sql CREATE USER exporter IDENTIFIED WITH SHA256_PASSWORD BY 'password-here' @@ -62,9 +60,9 @@ GRANT SELECT ON db.table TO exporter; - 复制表定义 ```sql -select create_table_query -from system.tables -where database = 'db' and table = 'table' +SELECT create_table_query +FROM system.tables +WHERE database = 'db' AND table = 'table' ``` ### 在目标 ClickHouse Cloud 系统上: {#on-the-destination-clickhouse-cloud-system} @@ -74,18 +72,17 @@ where database = 'db' and table = 'table' CREATE DATABASE db ``` -- 使用源的 CREATE TABLE 语句创建目标表。 +- 使用源的 CREATE TABLE 语句创建目标。 :::tip -运行 CREATE 语句时,将 ENGINE 更改为不带任何参数的 ReplicatedMergeTree。ClickHouse Cloud 始终复制表并提供正确的参数。请保留 `ORDER BY`、`PRIMARY KEY`、`PARTITION BY`、`SAMPLE BY`、`TTL` 和 `SETTINGS` 子句。 +在运行 CREATE 语句时,将 ENGINE 更改为 ReplicatedMergeTree,且不带任何参数。ClickHouse Cloud 始终复制表并提供正确的参数。但请保留 `ORDER BY`,`PRIMARY KEY`,`PARTITION BY`,`SAMPLE BY`,`TTL` 和 `SETTINGS` 子句。 ::: ```sql CREATE TABLE db.table ... ``` - -- 使用 `remoteSecure` 函数从自管理的源拉取数据 +- 使用 `remoteSecure` 函数从自管理源提取数据 迁移自管理的 ClickHouse @@ -95,7 +92,7 @@ remoteSecure('source-hostname', db, table, 'exporter', 'password-here') ``` :::note -如果源系统无法从外部网络访问,您可以推送数据而不是拉取数据,因为 `remoteSecure` 函数适用于选择和插入。 查看下一个选项。 +如果源系统从外部网络不可用,您可以使用推送而不是提取数据,因为 `remoteSecure` 函数适用于选择和插入。请参阅下一个选项。 ::: - 使用 `remoteSecure` 函数将数据推送到 ClickHouse Cloud 服务 @@ -103,7 +100,7 @@ remoteSecure('source-hostname', db, table, 'exporter', 'password-here') 迁移自管理的 ClickHouse :::tip 将远程系统添加到您的 ClickHouse Cloud 服务 IP 访问列表 -为了让 `remoteSecure` 函数连接到您的 ClickHouse Cloud 服务,远程系统的 IP 地址需要在 IP 访问列表中被允许。有关更多信息,请展开此提示下的 **管理您的 IP 访问列表**。 +为了使 `remoteSecure` 函数能够连接到您的 ClickHouse Cloud 服务,远程系统的 IP 地址需要在 IP 访问列表中被允许。有关更多信息,请展开此提示下方的 **管理您的 IP 访问列表**。 ::: @@ -114,33 +111,30 @@ remoteSecure('HOSTNAME.clickhouse.cloud:9440', 'db.table', 'default', 'PASS') SELECT * FROM db.table ``` - - ## 在 ClickHouse Cloud 服务之间迁移 {#migrating-between-clickhouse-cloud-services} 迁移自管理的 ClickHouse -在 ClickHouse Cloud 服务之间迁移数据的一些示例用途: -- 从恢复的备份迁移数据 +以下是将数据在 ClickHouse Cloud 服务之间迁移的一些示例用法: +- 从恢复的备份中迁移数据 - 从开发服务复制数据到暂存服务(或从暂存到生产) -在这个例子中,有两个 ClickHouse Cloud 服务,将分别称为 *源* 和 *目标*。数据将从源拉取到目标。尽管您可以选择推送数据,但示例中展示的是拉取,因为它使用了只读用户。 +在此示例中,有两个 ClickHouse Cloud 服务,它们将分别被称为 *源* 和 *目标*。数据将从源提取到目标。虽然您可以选择推送,但这里以提取为例,因为它使用了只读用户。 迁移自管理的 ClickHouse -迁移过程包含以下几个步骤: +迁移有几个步骤: 1. 确定一个 ClickHouse Cloud 服务作为 *源*,另一个作为 *目标* 1. 向源服务添加只读用户 1. 在目标服务上复制源表结构 -1. 临时允许源服务的 IP 访问 +1. 暂时允许对源服务的 IP 访问 1. 从源复制数据到目标 -1. 在目标上重新建立 IP 访问列表 -1. 从源服务中删除只读用户 - +1. 重新建立目标上的 IP 访问列表 +1. 从源服务中移除只读用户 #### 向源服务添加只读用户 {#add-a-read-only-user-to-the-source-service} -- 添加一个可以读取源表(本例中为 `db.table`)的只读用户 +- 添加一个可以读取源表的只读用户(在此示例中为 `db.table`) ```sql CREATE USER exporter IDENTIFIED WITH SHA256_PASSWORD BY 'password-here' @@ -160,37 +154,35 @@ where database = 'db' and table = 'table' #### 在目标服务上复制表结构 {#duplicate-the-table-structure-on-the-destination-service} -如果目标中尚不存在数据库,则创建该数据库: +在目标创建数据库(如果尚未存在): - 创建目标数据库: ```sql CREATE DATABASE db ``` - - - 使用源的 CREATE TABLE 语句创建目标。 - 在目标上使用源中的 `select create_table_query...` 输出创建表: + 在目标使用源的 `select create_table_query...` 输出创建表: ```sql CREATE TABLE db.table ... ``` -#### 允许源服务的远程访问 {#allow-remote-access-to-the-source-service} +#### 允许远程访问源服务 {#allow-remote-access-to-the-source-service} -为了从源向目标拉取数据,源服务必须允许连接。临时禁用源服务上的 "IP 访问列表" 功能。 +为了从源提取数据到目标,源服务必须允许连接。暂时禁用源服务上的“IP 访问列表”功能。 :::tip -如果您将继续使用源 ClickHouse Cloud 服务,则在切换到允许从任何地方访问之前,将现有的 IP 访问列表导出到 JSON 文件;这将允许您在数据迁移完成后导入访问列表。 +如果您将继续使用源 ClickHouse Cloud 服务,则在切换到允许来自任何地方的访问之前,请将现有的 IP 访问列表导出为 JSON 文件;这将允许您在数据迁移后导入访问列表。 ::: -修改允许列表,临时允许 **任何地方** 的访问。有关详细信息,请参见 [IP 访问列表](/cloud/security/setting-ip-filters) 文档。 +修改允许列表并暂时允许来自 **任何地方** 的访问。有关详细信息,请参见 [IP Access List](/cloud/security/setting-ip-filters) 文档。 #### 从源复制数据到目标 {#copy-the-data-from-source-to-destination} -- 使用 `remoteSecure` 函数从源 ClickHouse Cloud 服务拉取数据 - 连接到目标。在目标 ClickHouse Cloud 服务上运行此命令: +- 使用 `remoteSecure` 函数从源 ClickHouse Cloud 服务提取数据 + 连接到目标。在目标的 ClickHouse Cloud 服务上运行此命令: ```sql INSERT INTO db.table SELECT * FROM @@ -199,11 +191,11 @@ remoteSecure('source-hostname', db, table, 'exporter', 'password-here') - 验证目标服务中的数据 -#### 在源上重新建立 IP 访问列表 {#re-establish-the-ip-access-list-on-the-source} +#### 重新建立源上的 IP 访问列表 {#re-establish-the-ip-access-list-on-the-source} -如果您之前导出了访问列表,则可以通过 **共享** 重新导入它,否则重新添加您的条目到访问列表中。 +如果您之前导出了访问列表,则可以使用 **Share** 重新导入,如果没有,则重新添加您的条目到访问列表中。 -#### 删除只读 `exporter` 用户 {#remove-the-read-only-exporter-user} +#### 移除只读 `exporter` 用户 {#remove-the-read-only-exporter-user} ```sql DROP USER exporter diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/07_OSS_to_Cloud/01_clickhouse-to-cloud.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/07_OSS_to_Cloud/01_clickhouse-to-cloud.md.hash new file mode 100644 index 00000000000..7dbe0fc708e --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/07_OSS_to_Cloud/01_clickhouse-to-cloud.md.hash @@ -0,0 +1 @@ +c2c2735fd11e325d diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/07_OSS_to_Cloud/_category_.json b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/07_OSS_to_Cloud/_category_.json new file mode 100644 index 00000000000..9720f826193 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/07_OSS_to_Cloud/_category_.json @@ -0,0 +1,5 @@ +{ + "label": "OSS to Cloud", + "collapsible": true, + "collapsed": true, +} \ No newline at end of file diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/08_other_methods/01_clickhouse-local-etl.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/08_other_methods/01_clickhouse-local-etl.md new file mode 100644 index 00000000000..63dc08978da --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/08_other_methods/01_clickhouse-local-etl.md @@ -0,0 +1,146 @@ +--- +'sidebar_label': '使用 clickhouse-local' +'keywords': +- 'clickhouse' +- 'migrate' +- 'migration' +- 'migrating' +- 'data' +- 'etl' +- 'elt' +- 'clickhouse-local' +- 'clickhouse-client' +'slug': '/cloud/migration/clickhouse-local' +'title': '迁移到 ClickHouse 使用 clickhouse-local' +'description': '指南展示如何使用 clickhouse-local 迁移到 ClickHouse' +'doc_type': 'guide' +--- + +import Image from '@theme/IdealImage'; +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import CodeBlock from '@theme/CodeBlock'; +import AddARemoteSystem from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_add_remote_ip_access_list_detail.md'; +import ch_local_01 from '@site/static/images/integrations/migration/ch-local-01.png'; +import ch_local_02 from '@site/static/images/integrations/migration/ch-local-02.png'; +import ch_local_03 from '@site/static/images/integrations/migration/ch-local-03.png'; +import ch_local_04 from '@site/static/images/integrations/migration/ch-local-04.png'; + + +# 使用 clickhouse-local 迁移到 ClickHouse + +迁移自管理的 ClickHouse + +您可以使用 ClickHouse,更具体地说是 [`clickhouse-local`](/operations/utilities/clickhouse-local.md) 作为 ETL 工具,将数据从您当前的数据库系统迁移到 ClickHouse Cloud,只要您的当前数据库系统有 ClickHouse 提供的 [集成引擎](/engines/table-engines/#integration-engines) 或 [表函数](/sql-reference/table-functions/),或者有供应商提供的 JDBC 驱动程序或 ODBC 驱动程序可用。 + +我们有时将这种迁移方法称为“支点”方法,因为它使用一个中间支点或跳跃,将数据从源数据库迁移到目标数据库。例如,如果由于安全要求,仅允许从私有或内部网络进行外部连接,则可能需要这种方法,因此您需要使用 clickhouse-local 从源数据库拉取数据,然后将数据推送到目标 ClickHouse 数据库,而 clickhouse-local 充当支点。 + +ClickHouse 为 [MySQL](/engines/table-engines/integrations/mysql/)、[PostgreSQL](/engines/table-engines/integrations/postgresql)、[MongoDB](/engines/table-engines/integrations/mongodb) 和 [SQLite](/engines/table-engines/integrations/sqlite) 提供集成引擎和表函数(动态创建集成引擎)。对于所有其他流行的数据库系统,供应商提供了 JDBC 驱动程序或 ODBC 驱动程序。 + +## 什么是 clickhouse-local? {#what-is-clickhouse-local} + +迁移自管理的 ClickHouse + +通常,ClickHouse 以集群的形式运行,其中多个 ClickHouse 数据库引擎的实例在不同的服务器上分布式运行。 + +在单台服务器上,ClickHouse 数据库引擎作为 `clickhouse-server` 程序的一部分运行。数据库访问(路径、用户、安全性等)通过服务器配置文件进行配置。 + +`clickhouse-local` 工具使您能够以命令行实用程序的方式,隔离使用 ClickHouse 数据库引擎,进行快速 SQL 数据处理,而无需配置和启动 ClickHouse 服务器。 + +## 安装 clickhouse-local {#installing-clickhouse-local} + +您需要一个用于 `clickhouse-local` 的主机,该主机可以访问当前的源数据库系统和您的 ClickHouse Cloud 目标服务。 + +在该主机上,下载适合您的计算机操作系统的 `clickhouse-local` 的适当版本: + + + + +1. 下载 `clickhouse-local` 的最简单方法是运行以下命令: +```bash +curl https://clickhouse.com/ | sh +``` + +1. 运行 `clickhouse-local`(它将仅打印其版本): +```bash +./clickhouse-local +``` + + + + +1. 下载 `clickhouse-local` 的最简单方法是运行以下命令: +```bash +curl https://clickhouse.com/ | sh +``` + +1. 运行 `clickhouse-local`(它将仅打印其版本): +```bash +./clickhouse local +``` + + + + +:::info 重要 +本指南中的示例使用 Linux 命令运行 `clickhouse-local` (`./clickhouse-local`)。 +要在 Mac 上运行 `clickhouse-local`,请使用 `./clickhouse local`。 +::: + +:::tip 将远程系统添加到您的 ClickHouse Cloud 服务 IP 访问列表 +为了使 `remoteSecure` 函数能够连接到您的 ClickHouse Cloud 服务,远程系统的 IP 地址必须被 IP 访问列表允许。有关更多信息,请展开此提示下的 **管理您的 IP 访问列表**。 +::: + + + +## 示例 1: 使用集成引擎将 MySQL 迁移到 ClickHouse Cloud {#example-1-migrating-from-mysql-to-clickhouse-cloud-with-an-integration-engine} + +我们将使用 [集成表引擎](/engines/table-engines/integrations/mysql/) (通过 [mysql 表函数](/sql-reference/table-functions/mysql/) 动态创建)从源 MySQL 数据库读取数据,并将使用 [remoteSecure 表函数](/sql-reference/table-functions/remote/) 将数据写入 ClickHouse cloud 服务的目标表中。 + +迁移自管理的 ClickHouse + +### 在目标 ClickHouse Cloud 服务上: {#on-the-destination-clickhouse-cloud-service} + +#### 创建目标数据库: {#create-the-destination-database} + +```sql +CREATE DATABASE db +``` + +#### 创建一个与 MySQL 表模式相等的目标表: {#create-a-destination-table-that-has-a-schema-equivalent-to-the-mysql-table} + +```sql +CREATE TABLE db.table ... +``` + +:::note +ClickHouse Cloud 的目标表模式与源 MySQL 表的模式必须对齐(列名和顺序必须相同,列数据类型必须兼容)。 +::: + +### 在 clickhouse-local 主机上: {#on-the-clickhouse-local-host-machine} + +#### 使用迁移查询运行 clickhouse-local: {#run-clickhouse-local-with-the-migration-query} + +```sql + ./clickhouse-local --query " +INSERT INTO FUNCTION +remoteSecure('HOSTNAME.clickhouse.cloud:9440', 'db.table', 'default', 'PASS') +SELECT * FROM mysql('host:port', 'database', 'table', 'user', 'password');" +``` + +:::note +在 `clickhouse-local` 主机上没有存储任何数据。相反,数据是从源 MySQL 表读取的,然后立即写入 ClickHouse Cloud 服务上的目标表。 +::: + +## 示例 2: 使用 JDBC 桥将 MySQL 迁移到 ClickHouse Cloud {#example-2-migrating-from-mysql-to-clickhouse-cloud-with-the-jdbc-bridge} + +我们将使用 [JDBC 集成表引擎](/engines/table-engines/integrations/jdbc.md) (通过 [jdbc 表函数](/sql-reference/table-functions/jdbc.md) 动态创建),结合 [ClickHouse JDBC 桥](https://github.com/ClickHouse/clickhouse-jdbc-bridge) 和 MySQL JDBC 驱动程序,从源 MySQL 数据库读取数据,并将使用 [remoteSecure 表函数](/sql-reference/table-functions/remote.md) 将数据写入 ClickHouse cloud 服务的目标表中。 + +迁移自管理的 ClickHouse + +### 在目标 ClickHouse Cloud 服务上: {#on-the-destination-clickhouse-cloud-service-1} + +#### 创建目标数据库: {#create-the-destination-database-1} +```sql +CREATE DATABASE db +``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/08_other_methods/01_clickhouse-local-etl.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/08_other_methods/01_clickhouse-local-etl.md.hash new file mode 100644 index 00000000000..feb5e6b61b9 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/08_other_methods/01_clickhouse-local-etl.md.hash @@ -0,0 +1 @@ +dadfc60a8ad286f5 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/migration/etl-tool-to-clickhouse.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/08_other_methods/02_etl-tool-to-clickhouse.md similarity index 65% rename from i18n/zh/docusaurus-plugin-content-docs/current/integrations/migration/etl-tool-to-clickhouse.md rename to i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/08_other_methods/02_etl-tool-to-clickhouse.md index 455936d8798..ef06c476f1f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/migration/etl-tool-to-clickhouse.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/08_other_methods/02_etl-tool-to-clickhouse.md @@ -1,6 +1,5 @@ --- 'sidebar_label': '使用第三方 ETL 工具' -'sidebar_position': 20 'keywords': - 'clickhouse' - 'migrate' @@ -13,7 +12,8 @@ - 'clickhouse-client' 'slug': '/cloud/migration/etl-tool-to-clickhouse' 'title': '使用第三方 ETL 工具' -'description': '页面描述如何将第三方 ETL 工具与 ClickHouse 一起使用' +'description': '本页描述如何在 ClickHouse 中使用第三方 ETL 工具' +'doc_type': 'guide' --- import Image from '@theme/IdealImage'; @@ -24,10 +24,10 @@ import third_party_01 from '@site/static/images/integrations/migration/third-par 迁移自管理的 ClickHouse -将数据从外部数据源移动到 ClickHouse 的一个不错选择是使用众多流行的 ETL 和 ELT 工具之一。我们有文档涵盖以下内容: +将数据从外部数据源移入 ClickHouse 的一个好选择是使用许多流行的 ETL 和 ELT 工具之一。我们有文档涵盖以下内容: - [Airbyte](/integrations/data-ingestion/etl-tools/airbyte-and-clickhouse.md) - [dbt](/integrations/data-ingestion/etl-tools/dbt/index.md) - [Vector](/integrations/data-ingestion/etl-tools/vector-to-clickhouse.md) -但是还有许多其他与 ClickHouse 集成的 ETL/ELT 工具,因此请查看您喜欢的工具的文档以获取详细信息。 +但还有许多其他与 ClickHouse 集成的 ETL/ELT 工具,因此请查看您喜爱的工具的文档以获取详细信息。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/08_other_methods/02_etl-tool-to-clickhouse.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/08_other_methods/02_etl-tool-to-clickhouse.md.hash new file mode 100644 index 00000000000..233197e383f --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/08_other_methods/02_etl-tool-to-clickhouse.md.hash @@ -0,0 +1 @@ +e7e4cf07d4f7e459 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/08_other_methods/03_object-storage-to-clickhouse.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/08_other_methods/03_object-storage-to-clickhouse.md new file mode 100644 index 00000000000..2cde87b8951 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/08_other_methods/03_object-storage-to-clickhouse.md @@ -0,0 +1,32 @@ +--- +'title': '使用对象存储' +'description': '将数据从对象存储移动到 ClickHouse Cloud' +'keywords': +- 'object storage' +- 's3' +- 'azure blob' +- 'gcs' +- 'migration' +'slug': '/integrations/migration/object-storage-to-clickhouse' +'doc_type': 'guide' +--- + +import Image from '@theme/IdealImage'; +import object_storage_01 from '@site/static/images/integrations/migration/object-storage-01.png'; + + +# 将数据从云对象存储移动到 ClickHouse Cloud + +迁移自管理的 ClickHouse + +如果您使用云对象存储作为数据湖并希望将这些数据导入 ClickHouse Cloud,或者如果您当前的数据库系统能够直接将数据卸载到云对象存储中,那么您可以使用以下表函数将存储在云对象存储中的数据迁移到 ClickHouse Cloud 表中: + +- [s3](/sql-reference/table-functions/s3.md) 或 [s3Cluster](/sql-reference/table-functions/s3Cluster.md) +- [gcs](/sql-reference/table-functions/gcs) +- [azureBlobStorage](/sql-reference/table-functions/azureBlobStorage) + +如果您当前的数据库系统无法直接将数据卸载到云对象存储中,您可以使用 [第三方 ETL/ELT 工具](/cloud/migration/etl-tool-to-clickhouse) 或 [clickhouse-local](/cloud/migration/clickhouse-local) 来将数据从您当前的数据库系统移动到云对象存储,以便在第二步中将这些数据迁移到 ClickHouse Cloud 表中。 + +尽管这是一个两步过程(将数据卸载到云对象存储,然后加载到 ClickHouse),但它的优势在于由于 [强大的 ClickHouse Cloud](https://clickhouse.com/blog/getting-data-into-clickhouse-part-3-s3) 对来自云对象存储的高并发读取的支持,可以扩展到 PB 级别。同时,您可以利用复杂和压缩的格式,例如 [Parquet](/interfaces/formats/#data-format-parquet)。 + +有一篇 [博客文章](https://clickhouse.com/blog/getting-data-into-clickhouse-part-3-s3) 通过具体代码示例展示了如何使用 S3 将数据导入 ClickHouse Cloud。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/08_other_methods/03_object-storage-to-clickhouse.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/08_other_methods/03_object-storage-to-clickhouse.md.hash new file mode 100644 index 00000000000..25ba1f9400b --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/08_other_methods/03_object-storage-to-clickhouse.md.hash @@ -0,0 +1 @@ +c95b3324aab9b6fb diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/08_other_methods/_category_.json b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/08_other_methods/_category_.json new file mode 100644 index 00000000000..61c592ce8a0 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/08_other_methods/_category_.json @@ -0,0 +1,5 @@ +{ + "label": "Other...", + "collapsible": true, + "collapsed": true, +} \ No newline at end of file diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/_category_.json b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/_category_.json new file mode 100644 index 00000000000..aca0c529bce --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/02_migrate/01_migration_guides/_category_.json @@ -0,0 +1,5 @@ +{ + "label": "Migration guides", + "collapsible": true, + "collapsed": true, +} \ No newline at end of file diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/03_tune/_snippets/_monitoring_table_of_contents.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/03_tune/_snippets/_monitoring_table_of_contents.md new file mode 100644 index 00000000000..e5d813d8226 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/03_tune/_snippets/_monitoring_table_of_contents.md @@ -0,0 +1,3 @@ +| Page | Description | +|------|-------------| +| | | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/03_tune/_snippets/_monitoring_table_of_contents.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/03_tune/_snippets/_monitoring_table_of_contents.md.hash new file mode 100644 index 00000000000..e852b72ed46 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/03_tune/_snippets/_monitoring_table_of_contents.md.hash @@ -0,0 +1 @@ +b95b12523c2327fa diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/03_tune/resource_tour.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/03_tune/resource_tour.md new file mode 100644 index 00000000000..827442fca40 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/03_tune/resource_tour.md @@ -0,0 +1,49 @@ +--- +'slug': '/cloud/get-started/cloud/resource-tour' +'title': '资源巡回' +'description': '关于 ClickHouse Cloud 文档资源的概述,包括查询优化、扩展策略、监控和最佳实践' +'keywords': +- 'clickhouse cloud' +'hide_title': true +'doc_type': 'guide' +--- + +import TableOfContentsBestPractices from '@site/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/_snippets/_table_of_contents.md'; +import TableOfContentsOptimizationAndPerformance from '@site/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/_snippets/_performance_optimizations_table_of_contents.md'; +import TableOfContentsSecurity from '@site/i18n/zh/docusaurus-plugin-content-docs/current/cloud/_snippets/_security_table_of_contents.md'; + + +# 资源导览 + +本文旨在为您提供概述,以了解在文档中可用的资源,学习如何最大化利用您的 ClickHouse Cloud 部署。根据以下主题探索资源: + +- [查询优化技术和性能调优](#query-optimization) +- [监控](#monitoring) +- [安全最佳实践和合规功能](#security) +- [成本优化和计费](#cost-optimization) + +在深入具体主题之前,我们建议您先查看我们的通用 ClickHouse 最佳实践指南,其中涵盖了使用 ClickHouse 时应遵循的通用最佳实践: + + + +## 查询优化技术和性能调优 {#query-optimization} + + + +## 监控 {#monitoring} + +| 页面 | 描述 | +|-------------------------------------------------------------------|---------------------------------------------------------------------------| +| [高级仪表板](/cloud/manage/monitor/advanced-dashboard) | 使用内置的高级仪表板监控服务状态和性能 | +| [Prometheus 集成](/integrations/prometheus) | 使用 Prometheus 监控云服务 | + +## 安全 {#security} + + + +## 成本优化和计费 {#cost-optimization} + +| 页面 | 描述 | +|-------------------------------------------------------|-----------------------------------------------------------------------------------------------------| +| [数据传输](/cloud/manage/network-data-transfer) | 理解 ClickHouse Cloud 如何计量传入和传出的数据传输 | +| [通知](/cloud/notifications) | 为您的 ClickHouse Cloud 服务设置通知。例如,当信用使用量超过一个阈值时 | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/03_tune/resource_tour.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/03_tune/resource_tour.md.hash new file mode 100644 index 00000000000..725282f98ab --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/03_tune/resource_tour.md.hash @@ -0,0 +1 @@ +1a10abd292336aea diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/index.md new file mode 100644 index 00000000000..5da21d34d46 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/index.md @@ -0,0 +1,40 @@ +--- +'slug': '/cloud/get-started' +'title': '开始使用 ClickHouse Cloud' +'description': '完整指南,让您了解如何开始使用 ClickHouse Cloud - 从发现功能到部署和优化' +'hide_title': true +'doc_type': 'guide' +--- + + +# 开始使用 ClickHouse Cloud + +新手使用 ClickHouse Cloud,不知道从哪里开始?在本节文档中,我们将引导您快速入门。我们将此入门部分安排为三个子部分,以帮助您在探索 ClickHouse Cloud 的每一个步骤中获得指导。 + + + +## 发现 ClickHouse Cloud {#discover-clickhouse-cloud} + +- [了解](/cloud/overview) ClickHouse Cloud 是什么,以及它与开源版本的不同 +- [发现](/cloud/get-started/cloud/use-cases/overview) ClickHouse Cloud 的主要用例 + +## 设置 ClickHouse Cloud {#get-set-up-with-clickhouse-cloud} + +现在您知道了 ClickHouse Cloud 是什么,我们将引导您完成将数据导入 ClickHouse Cloud 的过程,展示可用的主要功能,并指出一些您应该了解的通用最佳实践。 + +主题包括: + +- [来自各种平台的迁移指南](/integrations/migration/overview) + +## 调整您的 ClickHouse Cloud 部署 {#evaluate-clickhouse-cloud} + +现在您的数据已在 ClickHouse Cloud 中,我们将引导您了解一些更高级的主题,以帮助您充分利用 ClickHouse Cloud 的体验,并探索该平台提供的内容。 + +主题包括: + +- [查询性能和优化](/cloud/get-started/cloud/resource-tour#query-optimization) +- [监控](/cloud/get-started/cloud/resource-tour#monitoring) +- [安全考虑](/cloud/get-started/cloud/resource-tour#security) +- [故障排除提示](/troubleshooting) + + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/index.md.hash new file mode 100644 index 00000000000..a4bf5bd209d --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/onboard/index.md.hash @@ -0,0 +1 @@ +938eb877f02bd5f5 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/changelog.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/01_changelog/01_changelog.md similarity index 90% rename from i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/changelog.md rename to i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/01_changelog/01_changelog.md index 0d0e7992055..d46b36e6524 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/changelog.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/01_changelog/01_changelog.md @@ -3,6 +3,7 @@ slug: /whats-new/cloud sidebar_label: 'Cloud Changelog' title: 'Cloud Changelog' description: 'ClickHouse Cloud changelog providing descriptions of what is new in each ClickHouse Cloud release' +doc_type: 'changelog' --- import Image from '@theme/IdealImage'; @@ -27,8 +28,112 @@ import kafka_config from '@site/static/images/cloud/reference/june-13-kafka-conf import fast_releases from '@site/static/images/cloud/reference/june-13-fast-releases.png'; import share_queries from '@site/static/images/cloud/reference/may-30-share-queries.png'; import query_endpoints from '@site/static/images/cloud/reference/may-17-query-endpoints.png'; +import dashboards from '@site/static/images/cloud/reference/may-30-dashboards.png'; -In addition to this ClickHouse Cloud changelog, please see the [Cloud Compatibility](/cloud/reference/cloud-compatibility.md) page. +In addition to this ClickHouse Cloud changelog, please see the [Cloud Compatibility](/whats-new/cloud-compatibility) page. + +## August 29, 2025 {#august-29-2025} + +- [ClickHouse Cloud Azure Private Link](/cloud/security/azure-privatelink) has switched from using Resource GUID to Resource ID filters for resource identification. You can still use the legacy Resource GUID, which is backward compatible, but we recommend switching to Resource ID filters. For migration details see the [docs](/cloud/security/azure-privatelink#obtaining-private-endpoint-resourceid) for Azure Private Link. + +## August 22, 2025 {#august-22-2025} + +- **ClickHouse Connector for AWS Glue** + You can now use the official [ClickHouse Connector for AWS Glue](/integrations/glue) that is available from the [AWS Marketplace](https://aws.amazon.com/marketplace/pp/prodview-eqvmuopqzdg7s). Utilizes AWS Glue’s Apache + Spark-based serverless engine for extracting, transforming and loading data integration between ClickHouse and other data sources. Get + started by following along with the announcement [blogpost](http://clickhouse.com/blog/clickhouse-connector-aws-glue) for how to create tables, write and read data between ClickHouse and Spark. +- **Change to the minimum number of replicas in a service** + Services which have been scaled up can now be [scaled back down](/manage/scaling) to use a single replica (previously the minimum was 2 replicas). Note: single replica services have reduced availability and are not recommended for production usage. +- ClickHouse Cloud will begin to send notifications related to service scaling and service version upgrades, by default for administrator roles. Users can adjust their notification preferences in their notification settings. + +## August 13, 2025 {#august-13-2025} + +- **ClickPipes for MongoDB CDC now in Private Preview** + You can now use ClickPipes to replicate data from MongoDB into ClickHouse Cloud in a few clicks, enabling + real-time analytics without the need for external ETL tools. The connector supports continuous + replication as well as one-time migrations, and is compatible with MongoDB Atlas and self-hosted MongoDB + deployments. Read the [blogpost](https://clickhouse.com/blog/mongodb-cdc-clickhouse-preview) for an overview of the MongoDB CDC connector and [sign up for early access here](https://clickhouse.com/cloud/clickpipes/mongodb-cdc-connector)! + +## August 8, 2025 {#august-08-2025} + +- **Notifications**: Users will now receive a UI notification when their service starts upgrading to a new ClickHouse version. Additional Email and Slack notifications can be added via the notification center. +- **ClickPipes**: Azure Blob Storage (ABS) ClickPipes support was added to the ClickHouse Terraform provider. See the provider documentation for an example of how to programmatically create an ABS ClickPipe. + - [Bug fix] Object storage ClickPipes writing to a destination table using the Null engine now report "Total records" and "Data ingested" metrics in the UI. + - [Bug fix] The “Time period” selector for metrics in the UI defaulted to “24 hours” regardless of the selected time period. This has now been fixed, and the UI correctly updates the charts for the selected time period. +- **Cross-region private link (AWS)** is now Generally Available. Please refer to the [documentation](/manage/security/aws-privatelink) for the list of supported regions. + +## July 31, 2025 {#july-31-2025} + +**Vertical scaling for ClickPipes now available** + +[Vertical scaling is now available for streaming ClickPipes](https://clickhouse.com/blog/clickpipes-flexible-scaling-monitoring). +This feature allows you to control the size of each replica, in addition to the +number of replicas (horizontal scaling). The details page for each ClickPipe now +also includes per-replica CPU and memory utilization, which helps you better +understand your workloads and plan re-sizing operations with confidence. + +## July 24, 2025 {#july-24-2025} + +**ClickPipes for MySQL CDC now in public beta** + +The MySQL CDC connector in ClickPipes is now widely available in public beta. With just a few clicks, +you can start replicating your MySQL (or MariaDB) data directly into ClickHouse Cloud in real-time, +with no external dependencies. Read the [blogpost](https://clickhouse.com/blog/mysql-cdc-connector-clickpipes-beta) +for an overview of the connector and follow the [quickstart](https://clickhouse.com/docs/integrations/clickpipes/mysql) +to get up and running. + +## July 11, 2025 {#june-11-2025} + +- New services now store database and table metadata in a central **SharedCatalog**, + a new model for coordination and object lifecycles which enables: + - **Cloud-scale DDL**, even under high concurrency + - **Resilient deletion and new DDL operations** + - **Fast spin-up and wake-ups** as stateless nodes now launch with no disk dependencies + - **Stateless compute across both native and open formats**, including Iceberg and Delta Lake + + Read more about SharedCatalog in our [blog](https://clickhouse.com/blog/clickhouse-cloud-stateless-compute) + +- We now support the ability to launch HIPAA compliant services in GCP `europe-west4` + +## June 27, 2025 {#june-27-2025} + +- We now officially support a Terraform provider for managing database privileges + which is also compatible with self-managed deployments. Please refer to the + [blog](https://clickhouse.com/blog/new-terraform-provider-manage-clickhouse-database-users-roles-and-privileges-with-code) + and our [docs](https://registry.terraform.io/providers/ClickHouse/clickhousedbops/latest/docs) + for more information. +- Enterprise tier services can now enlist in the [slow release channel](/manage/updates/#slow-release-channel-deferred-upgrades) to defer + upgrades by two weeks after the regular release to permit additional time for + testing. + +## June 13, 2025 {#june-13-2025} + +- We're excited to announce that ClickHouse Cloud Dashboards are now generally available. Dashboards allow users to visualize queries on dashboards, interact with data via filters and query parameters, and manage sharing. +- API key IP filters: we are introducing an additional layer of protection for your interactions with ClickHouse Cloud. When generating an API key, you may setup an IP allow list to limit where the API key may be used. Please refer to the [documentation](https://clickhouse.com/docs/cloud/security/setting-ip-filters) for details. + +## May 30, 2025 {#may-30-2025} + +- We're excited to announce general availability of **ClickPipes for Postgres CDC** + in ClickHouse Cloud. With just a few clicks, you can now replicate your Postgres + databases and unlock blazing-fast, real-time analytics. The connector delivers + faster data synchronization, latency as low as a few seconds, automatic schema changes, + fully secure connectivity, and more. Refer to the + [blog](https://clickhouse.com/blog/postgres-cdc-connector-clickpipes-ga) for + more information. To get started, refer to the instructions [here](https://clickhouse.com/docs/integrations/clickpipes/postgres). + +- Introduced new improvements to the SQL console dashboards: + - Sharing: You can share your dashboard with your team members. Four levels of access are supported, that can be adjusted both globally and on a per-user basis: + - _Write access_: Add/edit visualizations, refresh settings, interact with dashboards via filters. + - _Owner_: Share a dashboard, delete a dashboard, and all other permissions of a user with "write access". + - _Read-only access_: View and interact with dashboard via filters + - _No access_: Cannot view a dashboard + - For existing dashboards that have already been created, Organization Administrators can assign existing dashboards to themselves as owners. + - You can now add a table or chart from the SQL console to a dashboard from the query view. + +Dashboards improvements + +- We are enlisting preview participants for [Distributed cache](https://clickhouse.com/cloud/distributed-cache-waitlist) + for AWS and GCP. Read more in the [blog](https://clickhouse.com/blog/building-a-distributed-cache-for-s3). ## May 16, 2025 {#may-16-2025} @@ -38,7 +143,7 @@ In addition to this ClickHouse Cloud changelog, please see the [Cloud Compatibil * Memory & CPU: Graphs for `CGroupMemoryTotal` (Allocated Memory), `CGroupMaxCPU` (allocated CPU), `MemoryResident` (memory used), and `ProfileEvent_OSCPUVirtualTimeMicroseconds` (CPU used) * Data Transfer: Graphs showing data ingress and egress from ClickHouse Cloud. Learn more [here](/cloud/manage/network-data-transfer). -- We’re excited to announce the launch of our new ClickHouse Cloud Prometheus/Grafana mix-in, +- We're excited to announce the launch of our new ClickHouse Cloud Prometheus/Grafana mix-in, built to simplify monitoring for your ClickHouse Cloud services. This mix-in uses our Prometheus-compatible API endpoint to seamlessly integrate ClickHouse metrics into your existing Prometheus and Grafana setup. It includes @@ -79,7 +184,7 @@ In addition to this ClickHouse Cloud changelog, please see the [Cloud Compatibil ## April 4, 2025 {#april-4-2025} - Slack notifications for ClickHouse Cloud: ClickHouse Cloud now supports Slack notifications for billing, scaling, and ClickPipes events, in addition to in-console and email notifications. These notifications are sent via the ClickHouse Cloud Slack application. Organization admins can configure these notifications via the notification center by specifying slack channels to which notifications should be sent. -- Users running Production and Development services will now see ClickPipes and data transfer usage price on their bills. Please refer to the [announcement](/cloud/manage/jan-2025-faq/pricing-dimensions) from January 2025 for more details. +- Users running Production and Development services will now see ClickPipes and data transfer usage price on their bills. ## March 21, 2025 {#march-21-2025} @@ -101,7 +206,7 @@ In addition to this ClickHouse Cloud changelog, please see the [Cloud Compatibil ## February 21, 2025 {#february-21-2025} -### ClickHouse Bring Your Own Cloud (BYOC) for AWS is now generally available! {#clickhouse-byoc-for-aws-ga} +### ClickHouse Bring Your Own Cloud (BYOC) for AWS is now generally available {#clickhouse-byoc-for-aws-ga} In this deployment model, data plane components (compute, storage, backups, logs, metrics) run in the Customer VPC, while the control plane (web access, APIs, and billing) @@ -150,7 +255,6 @@ in use. - If your service is already above these limits, we will permit a 10% increase. Please contact [support](https://clickhouse.com/support/program) if you have any questions. - ## January 27, 2025 {#january-27-2025} ### Changes to ClickHouse Cloud tiers {#changes-to-clickhouse-cloud-tiers} @@ -163,7 +267,7 @@ We are adding a **new Enterprise tier** to serve the needs of the most demanding To support these changes, we are restructuring our current **Development** and **Production** tiers to more closely match how our evolving customer base is using our offerings. We are introducing the **Basic** tier, oriented toward users that are testing out new ideas and projects, and the **Scale** tier, matching users working with production workloads and data at scale. -You can read about these and other functional changes in this [blog](https://clickhouse.com/blog/evolution-of-clickhouse-cloud-new-features-superior-performance-tailored-offerings). Existing customers will need to take action to select a [new plan](https://clickhouse.com/pricing). Customer-facing communication was sent via email to organization administrators, and the following [FAQ](/cloud/manage/jan-2025-faq/summary) covers the key changes and timelines. +You can read about these and other functional changes in this [blog](https://clickhouse.com/blog/evolution-of-clickhouse-cloud-new-features-superior-performance-tailored-offerings). Existing customers will need to take action to select a [new plan](https://clickhouse.com/pricing). Customer-facing communication was sent via email to organization administrators. ### Warehouses: Compute-compute separation (GA) {#warehouses-compute-compute-separation-ga} @@ -191,7 +295,7 @@ Safe managed upgrades deliver significant value to our users by allowing them to ### HIPAA support {#hipaa-support} -We now support HIPAA in compliant regions, including AWS `us-east-1`, `us-west-2` and GCP `us-central1`, `us-east1`. Customers wishing to onboard must sign a Business Associate Agreement (BAA) and deploy to the compliant version of the region. For more information on HIPAA, please refer to the [documentation](/cloud/security/security-and-compliance). +We now support HIPAA in compliant regions, including AWS `us-east-1`, `us-west-2` and GCP `us-central1`, `us-east1`. Customers wishing to onboard must sign a Business Associate Agreement (BAA) and deploy to the compliant version of the region. For more information on HIPAA, please refer to the [documentation](/cloud/security/compliance-overview). ### Scheduled upgrades {#scheduled-upgrades} @@ -225,7 +329,6 @@ We've added several enhancements for the Prometheus integration: The filtered metrics feature is now available for all users. You can find more details [here](/integrations/prometheus). - ## December 20, 2024 {#december-20-2024} ### Marketplace subscription organization attachment {#marketplace-subscription-organization-attachment} @@ -244,15 +347,15 @@ Org Admins can now add more email addresses to a specific notification as additi ## December 6, 2024 {#december-6-2024} -### BYOC (Beta) {#byoc-beta} +### BYOC (beta) {#byoc-beta} Bring Your Own Cloud for AWS is now available in Beta. This deployment model allows you to deploy and run ClickHouse Cloud in your own AWS account. We support deployments in 11+ AWS regions, with more coming soon. Please [contact support](https://clickhouse.com/support/program) for access. Note that this deployment is reserved for large-scale deployments. -### Postgres Change-Data-Capture (CDC) Connector in ClickPipes {#postgres-change-data-capture-cdc-connector-in-clickpipes} +### Postgres Change Data Capture (CDC) connector in ClickPipes {#postgres-change-data-capture-cdc-connector-in-clickpipes} This turnkey integration enables customers to replicate their Postgres databases to ClickHouse Cloud in just a few clicks and leverage ClickHouse for blazing-fast analytics. You can use this connector for both continuous replication and one-time migrations from Postgres. -### Dashboards (Beta) {#dashboards-beta} +### Dashboards (beta) {#dashboards-beta} This week, we're excited to announce the Beta launch of Dashboards in ClickHouse Cloud. With Dashboards, users can turn saved queries into visualizations, organize visualizations onto dashboards, and interact with dashboards using query parameters. To get started, follow the [dashboards documentation](/cloud/manage/dashboards). @@ -278,15 +381,15 @@ To get started, follow the [Query API Endpoints documentation](/cloud/get-starte We are launching Beta for our native JSON support in ClickHouse Cloud. To get started, please get in touch with support[ to enable your cloud service](/cloud/support). -### Vector search using vector similarity indexes (Early Access) {#vector-search-using-vector-similarity-indexes-early-access} +### Vector search using vector similarity indexes (early access) {#vector-search-using-vector-similarity-indexes-early-access} -We are announcing vector similarity indexes for approximate vector search in early access! +We are announcing vector similarity indexes for approximate vector search in early access. ClickHouse already offers robust support for vector-based use cases, with a wide range of [distance functions]https://clickhouse.com/blog/reinvent-2024-product-announcements#vector-search-using-vector-similarity-indexes-early-access) and the ability to perform linear scans. In addition, more recently, we added an experimental[ approximate vector search](/engines/table-engines/mergetree-family/annindexes) approach powered by the [usearch](https://github.com/unum-cloud/usearch) library and the Hierarchical Navigable Small Worlds (HNSW) approximate nearest neighbor search algorithm. To get started, [please sign up for the early access waitlist](https://clickhouse.com/cloud/vector-search-index-waitlist). -### ClickHouse-Connect (Python) and ClickHouse-Kafka-Connect Users {#clickhouse-connect-python-and-clickhouse-kafka-connect-users} +### ClickHouse-connect (Python) and ClickHouse Kafka Connect users {#clickhouse-connect-python-and-clickhouse-kafka-connect-users} Notification emails went out to customers who had experienced issues where the clients could encounter a `MEMORY_LIMIT_EXCEEDED` exception. @@ -302,7 +405,7 @@ You can now grant uni-directional access to a specific data source like AWS MSK. ### ClickPipes now supports IAM for AWS MSK {#clickpipes-now-supports-iam-for-aws-msk} -You can now use IAM authentication to connect to an MSK broker with AWS MSK ClickPipes. To get started, review our [documentation](/integrations/clickpipes/kafka#iam). +You can now use IAM authentication to connect to an MSK broker with AWS MSK ClickPipes. To get started, review our [documentation](/integrations/clickpipes/kafka/best-practices/#iam). ### Maximum replica size for new services on AWS {#maximum-replica-size-for-new-services-on-aws} @@ -312,7 +415,7 @@ From now on, any new services created on AWS will allow a maximum available repl ### Built-in advanced observability dashboard for ClickHouse Cloud {#built-in-advanced-observability-dashboard-for-clickhouse-cloud} -Previously, the advanced observability dashboard that allows you to monitor ClickHouse server metrics and hardware resource utilization was only available in open-source ClickHouse. We are happy to announce that this feature is now available in the ClickHouse Cloud console! +Previously, the advanced observability dashboard that allows you to monitor ClickHouse server metrics and hardware resource utilization was only available in open-source ClickHouse. We are happy to announce that this feature is now available in the ClickHouse Cloud console. This dashboard allows you to view queries based on the [system.dashboards](/operations/system-tables/dashboards) table in an all-in-one UI. Visit **Monitoring > Service Health** page to start using the advanced observability dashboard today. @@ -320,11 +423,11 @@ This dashboard allows you to view queries based on the [system.dashboards](/oper ### AI-powered SQL autocomplete {#ai-powered-sql-autocomplete} -We've improved autocomplete significantly, allowing you to get in-line SQL completions as you write your queries with the new AI Copilot! This feature can be enabled by toggling the **"Enable Inline Code Completion"** setting for any ClickHouse Cloud service. +We've improved autocomplete significantly, allowing you to get in-line SQL completions as you write your queries with the new AI Copilot. This feature can be enabled by toggling the **"Enable Inline Code Completion"** setting for any ClickHouse Cloud service. Animation showing the AI Copilot providing SQL autocompletion suggestions as a user types -### New "Billing" role {#new-billing-role} +### New "billing" role {#new-billing-role} You can now assign users in your organization to a new **Billing** role that allows them to view and manage billing information without giving them the ability to configure or manage services. Simply invite a new user or edit an existing user's role to assign the **Billing** role. @@ -350,7 +453,7 @@ Customers looking for increased security for protected health information (PHI) Services are available in GCP `us-central-1` to customers with the **Dedicated** service type and require a Business Associate Agreement (BAA). Contact [sales](mailto:sales@clickhouse.com) or [support](https://clickhouse.com/support/program) to request access to this feature or join the wait list for additional GCP, AWS, and Azure regions. -### Compute-Compute separation is now in Private Preview for GCP and Azure {#compute-compute-separation-is-now-in-private-preview-for-gcp-and-azure} +### Compute-compute separation is now in private preview for GCP and Azure {#compute-compute-separation-is-now-in-private-preview-for-gcp-and-azure} We recently announced the Private Preview for Compute-Compute Separation for AWS. We're happy to announce that it is now available for GCP and Azure. @@ -360,9 +463,9 @@ Compute-compute separation allows you to designate specific services as read-wri Customers using multi-factor authentication can now obtain recovery codes that can be used in the event of a lost phone or accidentally deleted token. Customers enrolling in MFA for the first time will be provided the code on set up. Customers with existing MFA can obtain a recovery code by removing their existing MFA token and adding a new one. -### ClickPipes update: custom certificates, latency insights, and more! {#clickpipes-update-custom-certificates-latency-insights-and-more} +### ClickPipes update: custom certificates, latency insights, and more. {#clickpipes-update-custom-certificates-latency-insights-and-more} -We're excited to share the latest updates for ClickPipes, the easiest way to ingest data into your ClickHouse service! These new features are designed to enhance your control over data ingestion and provide greater visibility into performance metrics. +We're excited to share the latest updates for ClickPipes, the easiest way to ingest data into your ClickHouse service. These new features are designed to enhance your control over data ingestion and provide greater visibility into performance metrics. *Custom Authentication Certificates for Kafka* @@ -382,13 +485,13 @@ High throughput can demand extra resources to meet your data volume and latency *Raw Message Ingestion for Kafka and Kinesis* -It is now possible to ingest an entire Kafka or Kinesis message without parsing it. ClickPipes now offers support for a `_raw_message` [virtual column](/integrations/clickpipes/kafka#kafka-virtual-columns), allowing users to map the full message into a single String column. This gives you the flexibility to work with raw data as needed. +It is now possible to ingest an entire Kafka or Kinesis message without parsing it. ClickPipes now offers support for a `_raw_message` [virtual column](/integrations/clickpipes/kafka/reference/#kafka-virtual-columns), allowing users to map the full message into a single String column. This gives you the flexibility to work with raw data as needed. ## August 29, 2024 {#august-29-2024} ### New Terraform provider version - v1.0.0 {#new-terraform-provider-version---v100} -Terraform allows you to control your ClickHouse Cloud services programmatically, then store your configuration as code. Our Terraform provider has almost 200,000 downloads and is now officially v1.0.0! This new version includes improvements such as better retry logic and a new resource to attach private endpoints to your ClickHouse Cloud service. You can download the [Terraform provider here](https://registry.terraform.io/providers/ClickHouse/clickhouse/latest) and view the [full changelog here](https://github.com/ClickHouse/terraform-provider-clickhouse/releases/tag/v1.0.0). +Terraform allows you to control your ClickHouse Cloud services programmatically, then store your configuration as code. Our Terraform provider has almost 200,000 downloads and is now officially v1.0.0. This new version includes improvements such as better retry logic and a new resource to attach private endpoints to your ClickHouse Cloud service. You can download the [Terraform provider here](https://registry.terraform.io/providers/ClickHouse/clickhouse/latest) and view the [full changelog here](https://github.com/ClickHouse/terraform-provider-clickhouse/releases/tag/v1.0.0). ### 2024 SOC 2 Type II report and updated ISO 27001 certificate {#2024-soc-2-type-ii-report-and-updated-iso-27001-certificate} @@ -418,7 +521,7 @@ ClickPipes is the easiest way to ingest data into ClickHouse Cloud. We're happy In our last cloud changelog, we announced the Private Preview for exporting [Prometheus](https://prometheus.io/) metrics from ClickHouse Cloud. This feature allows you to use the [ClickHouse Cloud API](/cloud/manage/api/api-overview) to get your metrics into tools like [Grafana](https://grafana.com/) and [Datadog](https://www.datadoghq.com/) for visualization. We're happy to announce that this feature is now **Generally Available**. Please see [our docs](/integrations/prometheus) to learn more about this feature. -### Table Inspector in Cloud Console {#table-inspector-in-cloud-console} +### Table inspector in Cloud console {#table-inspector-in-cloud-console} ClickHouse has commands like [`DESCRIBE`](/sql-reference/statements/describe-table) that allow you to introspect your table to examine schema. These commands output to the console, but they are often not convenient to use as you need to combine several queries to retrieve all pertinent data about your tables and columns. @@ -434,11 +537,11 @@ Our [Java Client](https://github.com/ClickHouse/clickhouse-java) is one of the m For the last couple of years, we've been working on a new analyzer for query analysis and optimization. This analyzer improves query performance and will allow us to make further optimizations, including faster and more efficient `JOIN`s. Previously, it was required that new users enable this feature using the setting `allow_experimental_analyzer`. This improved analyzer is now available on new ClickHouse Cloud services by default. -Stay tuned for more improvements to the analyzer as we have many more optimizations planned! +Stay tuned for more improvements to the analyzer as we have many more optimizations planned. ## June 28, 2024 {#june-28-2024} -### ClickHouse Cloud for Microsoft Azure is now Generally Available! {#clickhouse-cloud-for-microsoft-azure-is-now-generally-available} +### ClickHouse Cloud for Microsoft Azure is now generally available {#clickhouse-cloud-for-microsoft-azure-is-now-generally-available} We first announced Microsoft Azure support in Beta [this past May](https://clickhouse.com/blog/clickhouse-cloud-is-now-on-azure-in-public-beta). In this latest cloud release, we're happy to announce that our Azure support is transitioning from Beta to Generally Available. ClickHouse Cloud is now available on all the three major cloud platforms: AWS, Google Cloud Platform, and now Microsoft Azure. @@ -451,7 +554,7 @@ If you'd like any specific region to be supported, please [contact us](https://c ### Query log insights {#query-log-insights} -Our new Query Insights UI in the Cloud Console makes ClickHouse's built-in query log a lot easier to use. ClickHouse's `system.query_log` table is a key source of information for query optimization, debugging, and monitoring overall cluster health and performance. There's just one caveat: with 70+ fields and multiple records per query, interpreting the query log represents a steep learning curve. This initial version of query insights provides a blueprint for future work to simplify query debugging and optimization patterns. We'd love to hear your feedback as we continue to iterate on this feature, so please reach out—your input will be greatly appreciated! +Our new Query Insights UI in the Cloud console makes ClickHouse's built-in query log a lot easier to use. ClickHouse's `system.query_log` table is a key source of information for query optimization, debugging, and monitoring overall cluster health and performance. There's just one caveat: with 70+ fields and multiple records per query, interpreting the query log represents a steep learning curve. This initial version of query insights provides a blueprint for future work to simplify query debugging and optimization patterns. We'd love to hear your feedback as we continue to iterate on this feature, so please reach out—your input will be greatly appreciated. ClickHouse Cloud Query Insights UI showing query performance metrics and analysis @@ -461,7 +564,7 @@ Perhaps one of our most requested features: you can now export [Prometheus](http Grafana dashboard showing Prometheus metrics from ClickHouse Cloud -### Other features: {#other-features} +### Other features {#other-features} - [Configurable backups](/cloud/manage/backups/configurable-backups) to configure custom backup policies like frequency, retention, and schedule are now Generally Available. ## June 13, 2024 {#june-13-2024} @@ -481,7 +584,7 @@ The following options are available: ### Enroll services to the Fast release channel {#enroll-services-to-the-fast-release-channel} -The Fast release channel allows your services to receive updates ahead of the release schedule. Previously, this feature required assistance from the support team to enable. Now, you can use the ClickHouse Cloud console to enable this feature for your services directly. Simply navigate to **Settings**, and click **Enroll in fast releases**. Your service will now receive updates as soon as they are available! +The Fast release channel allows your services to receive updates ahead of the release schedule. Previously, this feature required assistance from the support team to enable. Now, you can use the ClickHouse Cloud console to enable this feature for your services directly. Simply navigate to **Settings**, and click **Enroll in fast releases**. Your service will now receive updates as soon as they are available. ClickHouse Cloud settings page showing the option to enroll in fast releases @@ -503,13 +606,13 @@ We're happy to announce that you can now easily share queries via the ClickHouse ### ClickHouse Cloud for Microsoft Azure is now in beta {#clickhouse-cloud-for-microsoft-azure-is-now-in-beta} -We've finally launched the ability to create ClickHouse Cloud services on Microsoft Azure! We already have many customers using ClickHouse Cloud on Azure in production as part of our Private Preview program. Now, anyone can create their own service on Azure. All of your favorite ClickHouse features that are supported on AWS and GCP will also work on Azure. +We've finally launched the ability to create ClickHouse Cloud services on Microsoft Azure. We already have many customers using ClickHouse Cloud on Azure in production as part of our Private Preview program. Now, anyone can create their own service on Azure. All of your favorite ClickHouse features that are supported on AWS and GCP will also work on Azure. We expect to have ClickHouse Cloud for Azure ready for General Availability in the next few weeks. [Read this blog post](https://clickhouse.com/blog/clickhouse-cloud-is-now-on-azure-in-public-beta) to learn more, or create your new service using Azure via the ClickHouse Cloud console. Note: **Development** services for Azure are not supported at this time. -### Set up Private Link via the Cloud Console {#set-up-private-link-via-the-cloud-console} +### Set up Private Link via the Cloud console {#set-up-private-link-via-the-cloud-console} Our Private Link feature allows you to connect your ClickHouse Cloud services with internal services in your cloud provider account without having to direct traffic to the public internet, saving costs and enhancing security. Previously, this was difficult to set up and required using the ClickHouse Cloud API. @@ -519,15 +622,15 @@ You can now configure private endpoints in just a few clicks directly from the C ## May 17, 2024 {#may-17-2024} -### Ingest data from Amazon Kinesis using ClickPipes (Beta) {#ingest-data-from-amazon-kinesis-using-clickpipes-beta} +### Ingest data from Amazon Kinesis using ClickPipes (beta) {#ingest-data-from-amazon-kinesis-using-clickpipes-beta} -ClickPipes is an exclusive service provided by ClickHouse Cloud to ingest data without code. Amazon Kinesis is AWS's fully managed streaming service to ingest and store data streams for processing. We are thrilled to launch the ClickPipes beta for Amazon Kinesis, one of our most requested integrations. We're looking to add more integrations to ClickPipes, so please let us know which data source you'd like us to support! Read more about this feature [here](https://clickhouse.com/blog/clickpipes-amazon-kinesis). +ClickPipes is an exclusive service provided by ClickHouse Cloud to ingest data without code. Amazon Kinesis is AWS's fully managed streaming service to ingest and store data streams for processing. We are thrilled to launch the ClickPipes beta for Amazon Kinesis, one of our most requested integrations. We're looking to add more integrations to ClickPipes, so please let us know which data source you'd like us to support. Read more about this feature [here](https://clickhouse.com/blog/clickpipes-amazon-kinesis). You can try the new Amazon Kinesis integration for ClickPipes in the cloud console: ClickPipes interface showing Amazon Kinesis integration configuration options -### Configurable Backups (Private Preview) {#configurable-backups-private-preview} +### Configurable backups (private preview) {#configurable-backups-private-preview} Backups are important for every database (no matter how reliable), and we've taken backups very seriously since day 1 of ClickHouse Cloud. This week, we launched Configurable Backups, which allows for much more flexibility for your service's backups. You can now control start time, retention, and frequency. This feature is available for **Production** and **Dedicated** services and is not available for **Development** services. As this feature is in private preview, please contact support@clickhouse.com to enable this for your service. Read more about configurable backups [here](https://clickhouse.com/blog/configurable-backups-in-clickhouse-cloud). @@ -588,10 +691,9 @@ Other changes: - Java client: Fixed bug with incorrect error code parsing - Python client: Fixed parameters binding for numeric types, fixed bugs with number list in query binding, added SQLAlchemy Point support. - ## April 4, 2024 {#april-4-2024} -### Introducing the new ClickHouse Cloud Console {#introducing-the-new-clickhouse-cloud-console} +### Introducing the new ClickHouse Cloud console {#introducing-the-new-clickhouse-cloud-console} This release introduces a private preview for the new cloud console. @@ -601,7 +703,7 @@ Thousands of ClickHouse Cloud users execute billions of queries on our SQL conso Select customers will receive a preview of our new cloud console experience – a unified and immersive way to explore and manage your data in ClickHouse. Please reach out to us at support@clickhouse.com if you'd like priority access. -Animation showing the new ClickHouse Cloud Console interface with integrated SQL editor and management features +Animation showing the new ClickHouse Cloud console interface with integrated SQL editor and management features ## March 28, 2024 {#march-28-2024} @@ -635,10 +737,10 @@ This release introduces support for Microsoft Azure, Horizontal Scaling via API, ## March 14, 2024 {#march-14-2024} -This release makes available in early access the new Cloud Console experience, ClickPipes for bulk loading from S3 and GCS, and support for Avro format in ClickPipes for Kafka. It also upgrades the ClickHouse database version to 24.1, bringing support for new functions as well as performance and resource usage optimizations. +This release makes available in early access the new Cloud console experience, ClickPipes for bulk loading from S3 and GCS, and support for Avro format in ClickPipes for Kafka. It also upgrades the ClickHouse database version to 24.1, bringing support for new functions as well as performance and resource usage optimizations. ### Console changes {#console-changes-2} -- New Cloud Console experience is available in early access (please contact support if you're interested in participating). +- New Cloud console experience is available in early access (please contact support if you're interested in participating). - ClickPipes for bulk loading from S3 and GCS are available in early access (please contact support if you're interested in participating). - Support for Avro format in ClickPipes for Kafka is available in early access (please contact support if you're interested in participating). @@ -688,12 +790,12 @@ This release upgrades the core database version, adds ability to set up private ### Integrations changes {#integrations-changes-4} * Kafka Connect - * Support async_insert for exactly once (disabled by default) + * Support async_insert for exactly once (disabled by default) * Golang client - * Fixed DateTime binding - * Improved batch insert performance + * Fixed DateTime binding + * Improved batch insert performance * Java client - * Fixed request compression problem + * Fixed request compression problem ### Settings changes {#settings-changes} * `use_mysql_types_in_show_columns` is no longer required. It will be automatically enabled when you connect through the MySQL interface. @@ -724,7 +826,6 @@ This release brings availability of ClickPipes for Azure Event Hub, dramatically * Metabase * Added support for a connection to multiple databases - ## January 18, 2024 {#january-18-2024} This release brings a new region in AWS (London / eu-west-2), adds ClickPipes support for Redpanda, Upstash, and Warpstream, and improves reliability of the [is_deleted](/engines/table-engines/mergetree-family/replacingmergetree#is_deleted) core database capability. @@ -750,7 +851,6 @@ This release brings a new region in AWS (London / eu-west-2), adds ClickPipes su ### Reliability changes {#reliability-changes} - User-facing backward incompatible change: Previously, two features ([is_deleted](/engines/table-engines/mergetree-family/replacingmergetree#is_deleted) and ``OPTIMIZE CLEANUP``) under certain conditions could lead to corruption of the data in ClickHouse. To protect the integrity of the data of our users, while keeping the core of the functionality, we adjusted how this feature works. Specifically, the MergeTree setting ``clean_deleted_rows`` is now deprecated and has no effect anymore. The ``CLEANUP`` keyword is not allowed by default (to use it you will need to enable ``allow_experimental_replacing_merge_with_cleanup``). If you decide to use ``CLEANUP``, you need to make sure that it is always used together with ``FINAL``, and you must guarantee that no rows with older versions will be inserted after you run ``OPTIMIZE FINAL CLEANUP``. - ## December 18, 2023 {#december-18-2023} This release brings a new region in GCP (us-east1), ability to self-service secure endpoint connections, support for additional integrations including DBT 1.7, and numerous bug fixes and security enhancements. @@ -780,7 +880,6 @@ This release brings a new region in GCP (us-east1), ability to self-service secu - CVE-2023-48704 (CVSS 7.0) - a heap buffer overflow vulnerability affecting the native interface running by default on port 9000/tcp - CVE 2023-48298 (CVSS 5.9) - an integer underflow vulnerability in the FPC compressions codec - ## November 22, 2023 {#november-22-2023} This release upgrades the core database version, improves login and authentication flow, and adds proxy support to Kafka Connect Sink. @@ -856,7 +955,7 @@ This release brings general availability of ClickPipes for Kafka, Confluent Clou ### Console changes {#console-changes-11} - Added a self-service workflow to secure [access to Amazon S3 via IAM roles](/cloud/security/secure-s3) -- Introduced AI-assisted query suggestions in private preview (please [contact ClickHouse Cloud support](https://console.clickhouse.cloud/support) to try it out!) +- Introduced AI-assisted query suggestions in private preview (please [contact ClickHouse Cloud support](https://console.clickhouse.cloud/support) to try it out.) ### Integrations changes {#integrations-changes-11} - Announced general availability of ClickPipes - a turnkey data ingestion service - for Kafka, Confluent Cloud, and Amazon MSK (see the [release blog](https://clickhouse.com/blog/clickpipes-is-generally-available)) @@ -994,9 +1093,21 @@ This release brings the public release of the ClickHouse Cloud Programmatic API ## May 11, 2023 {#may-11-2023} -This release brings the ~~public beta~~ (now GA, see June 20th entry above) of ClickHouse Cloud on GCP (see [blog](https://clickhouse.com/blog/clickhouse-cloud-on-gcp-available-in-public-beta) for details), extends administrators rights to grant terminate query permissions, and adds more visibility into the status of MFA users in the Cloud console. +This release brings the public beta of ClickHouse Cloud on GCP +(see [blog](https://clickhouse.com/blog/clickhouse-cloud-on-gcp-available-in-public-beta) +for details), extends administrators' rights to grant terminate query permissions, +and adds more visibility into the status of MFA users in the Cloud console. + +:::note Update +ClickHouse Cloud on GCP is now GA, see the entry for June twenty above. +::: + +### ClickHouse Cloud on GCP is now available in public beta {#clickhouse-cloud-on-gcp-is-now-available-in-public-beta-now-ga-see-june-20th-entry-above} + +:::note +ClickHouse Cloud on GCP is now GA, see the [June 20th](#june-20-2023) entry above. +::: -### ClickHouse Cloud on GCP ~~(Public Beta)~~ (now GA, see June 20th entry above) {#clickhouse-cloud-on-gcp-public-beta-now-ga-see-june-20th-entry-above} - Launches a fully-managed separated storage and compute ClickHouse offering, running on top of Google Compute and Google Cloud Storage - Available in Iowa (us-central1), Netherlands (europe-west4), and Singapore (asia-southeast1) regions - Supports both Development and Production services in all three initial regions @@ -1079,7 +1190,6 @@ This release brings an API for retrieving cloud endpoints, an advanced scaling c ### Bug fixes {#bug-fixes-1} * Fixed behavior where running `INSERT INTO ... SELECT ...` from the SQL console incorrectly applied the same row limit as select queries - ## March 23, 2023 {#march-23-2023} This release brings database password complexity rules, significant speedup in restoring large backups, and support for displaying traces in Grafana Trace View. @@ -1113,7 +1223,6 @@ This release brings database password complexity rules, significant speedup in r - Fixed a bug resulting in slow initial provisioning and startup times for new services - Fixed a bug that resulted in slower query performance due to cache misconfiguration - ## March 9, 2023 {#march-9-2023} This release improves observability dashboards, optimizes time to create large backups, and adds the configuration necessary to drop large tables and partitions. @@ -1199,7 +1308,6 @@ This release brings an officially supported Metabase integration, a major Java c - Fixed a bug where SQL console CSV export was truncated - Fixed a bug resulting in intermittent sample data upload failures - ## January 12, 2023 {#january-12-2023} This release updates the ClickHouse version to 22.12, enables dictionaries for many new sources, and improves query performance. @@ -1253,7 +1361,7 @@ This release introduces seamless logins for administrators to SQL console, impro ### Integrations changes {#integrations-changes-26} - The [Metabase plugin](/integrations/data-visualization/metabase-and-clickhouse.md) got a long-awaited v0.9.1 major update. Now it is compatible with the latest Metabase version and has been thoroughly tested against ClickHouse Cloud. -## December 6, 2022 - General Availability {#december-6-2022---general-availability} +## December 6, 2022 - General availability {#december-6-2022---general-availability} ClickHouse Cloud is now production-ready with SOC2 Type II compliance, uptime SLAs for production workloads, and public status page. This release includes major new capabilities like AWS Marketplace integration, SQL console - a data exploration workbench for ClickHouse users, and ClickHouse Academy - self-paced learning in ClickHouse Cloud. Learn more in this [blog](https://clickhouse.com/blog/clickhouse-cloud-generally-available). @@ -1335,7 +1443,7 @@ This release enables dictionaries from local ClickHouse table and HTTP sources, ### General changes {#general-changes-5} - Added support for [dictionaries](/sql-reference/dictionaries/index.md) from local ClickHouse table and HTTP sources -- Introduced support for the Mumbai [region](/cloud/reference/supported-regions.md) +- Introduced support for the Mumbai [region](/cloud/reference/supported-regions) ### Console changes {#console-changes-30} @@ -1379,7 +1487,6 @@ This release removes read & write units from pricing (see the [pricing page](htt - Added functions for Morton curve encoding, Java integer hashing, and random number generation. - See the [detailed 22.10 changelog](/whats-new/cloud#clickhouse-2210-version-upgrade) for the complete list of changes. - ## October 25, 2022 {#october-25-2022} This release significantly lowers compute consumption for small workloads, lowers compute pricing (see [pricing](https://clickhouse.com/pricing) page for details), improves stability through better defaults, and enhances the Billing and Usage views in the ClickHouse Cloud console. @@ -1404,4 +1511,4 @@ This release significantly lowers compute consumption for small workloads, lower ClickHouse Cloud began its public Beta on October 4th, 2022. Learn more in this [blog](https://clickhouse.com/blog/clickhouse-cloud-public-beta). -The ClickHouse Cloud version is based on ClickHouse core v22.10. For a list of compatible features, refer to the [Cloud Compatibility](/cloud/reference/cloud-compatibility.md) guide. +The ClickHouse Cloud version is based on ClickHouse core v22.10. For a list of compatible features, refer to the [Cloud Compatibility](/whats-new/cloud-compatibility) guide. diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/changelogs/fast-release-24-2.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/01_changelog/02_release_notes/24_02.md similarity index 99% rename from i18n/zh/docusaurus-plugin-content-docs/current/cloud/changelogs/fast-release-24-2.md rename to i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/01_changelog/02_release_notes/24_02.md index 714f8a8f575..0600119bc76 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/changelogs/fast-release-24-2.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/01_changelog/02_release_notes/24_02.md @@ -3,12 +3,14 @@ slug: /whats-new/changelog/24.2-fast-release title: 'v24.2 Changelog' description: 'Fast release changelog for v24.2' keywords: ['changelog'] -sidebar_label: 'v24.2' +sidebar_label: '24.2' +sidebar_position: 8 +doc_type: 'changelog' --- ### ClickHouse release tag: 24.2.2.15987 {#clickhouse-release-tag-242215987} -#### Backward Incompatible Change {#backward-incompatible-change} +#### Backward incompatible change {#backward-incompatible-change} * Validate suspicious/experimental types in nested types. Previously we didn't validate such types (except JSON) in nested types like Array/Tuple/Map. [#59385](https://github.com/ClickHouse/ClickHouse/pull/59385) ([Kruglov Pavel](https://github.com/Avogar)). * The sort clause `ORDER BY ALL` (introduced with v23.12) is replaced by `ORDER BY *`. The previous syntax was too error-prone for tables with a column `all`. [#59450](https://github.com/ClickHouse/ClickHouse/pull/59450) ([Robert Schulze](https://github.com/rschu1ze)). * Add sanity check for number of threads and block sizes. [#60138](https://github.com/ClickHouse/ClickHouse/pull/60138) ([Raúl Marín](https://github.com/Algunenano)). @@ -20,9 +22,9 @@ sidebar_label: 'v24.2' * ClickHouse allows arbitrary binary data in the String data type, which is typically UTF-8. Parquet/ORC/Arrow Strings only support UTF-8. That's why you can choose which Arrow's data type to use for the ClickHouse String data type - String or Binary. This is controlled by the settings, `output_format_parquet_string_as_string`, `output_format_orc_string_as_string`, `output_format_arrow_string_as_string`. While Binary would be more correct and compatible, using String by default will correspond to user expectations in most cases. Parquet/ORC/Arrow supports many compression methods, including lz4 and zstd. ClickHouse supports each and every compression method. Some inferior tools lack support for the faster `lz4` compression method, that's why we set `zstd` by default. This is controlled by the settings `output_format_parquet_compression_method`, `output_format_orc_compression_method`, and `output_format_arrow_compression_method`. We changed the default to `zstd` for Parquet and ORC, but not Arrow (it is emphasized for low-level usages). [#61817](https://github.com/ClickHouse/ClickHouse/pull/61817) ([Alexey Milovidov](https://github.com/alexey-milovidov)). * Fix for the materialized view security issue, which allowed a user to insert into a table without required grants for that. Fix validates that the user has permission to insert not only into a materialized view but also into all underlying tables. This means that some queries, which worked before, now can fail with Not enough privileges. To address this problem, the release introduces a new feature of SQL security for views [https://clickhouse.com/docs/sql-reference/statements/create/view#sql_security](/sql-reference/statements/create/view#sql_security). [#54901](https://github.com/ClickHouse/ClickHouse/pull/54901) ([pufit](https://github.com/pufit)) -#### New Feature {#new-feature} +#### New feature {#new-feature} * Topk/topkweighed support mode, which return count of values and it's error. [#54508](https://github.com/ClickHouse/ClickHouse/pull/54508) ([UnamedRus](https://github.com/UnamedRus)). -* Added new syntax which allows to specify definer user in View/Materialized View. This allows to execute selects/inserts from views without explicit grants for underlying tables. [#54901](https://github.com/ClickHouse/ClickHouse/pull/54901) ([pufit](https://github.com/pufit)). +* Added new syntax which allows to specify definer user in view/materialized view. This allows to execute selects/inserts from views without explicit grants for underlying tables. [#54901](https://github.com/ClickHouse/ClickHouse/pull/54901) ([pufit](https://github.com/pufit)). * Implemented automatic conversion of merge tree tables of different kinds to replicated engine. Create empty `convert_to_replicated` file in table's data directory (`/clickhouse/store/xxx/xxxyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy/`) and that table will be converted automatically on next server start. [#57798](https://github.com/ClickHouse/ClickHouse/pull/57798) ([Kirill](https://github.com/kirillgarbar)). * Added table function `mergeTreeIndex`. It represents the contents of index and marks files of `MergeTree` tables. It can be used for introspection. Syntax: `mergeTreeIndex(database, table, [with_marks = true])` where `database.table` is an existing table with `MergeTree` engine. [#58140](https://github.com/ClickHouse/ClickHouse/pull/58140) ([Anton Popov](https://github.com/CurtizJ)). * Try to detect file format automatically during schema inference if it's unknown in `file/s3/hdfs/url/azureBlobStorage` engines. Closes [#50576](https://github.com/ClickHouse/ClickHouse/issues/50576). [#59092](https://github.com/ClickHouse/ClickHouse/pull/59092) ([Kruglov Pavel](https://github.com/Avogar)). @@ -37,7 +39,7 @@ sidebar_label: 'v24.2' * Added function `toMillisecond` which returns the millisecond component for values of type`DateTime` or `DateTime64`. [#60281](https://github.com/ClickHouse/ClickHouse/pull/60281) ([Shaun Struwig](https://github.com/Blargian)). * Support single-argument version for the merge table function, as `merge(['db_name', ] 'tables_regexp')`. [#60372](https://github.com/ClickHouse/ClickHouse/pull/60372) ([豪肥肥](https://github.com/HowePa)). * Make all format names case insensitive, like Tsv, or TSV, or tsv, or even rowbinary. [#60420](https://github.com/ClickHouse/ClickHouse/pull/60420) ([豪肥肥](https://github.com/HowePa)). -* Added new syntax which allows to specify definer user in View/Materialized View. This allows to execute selects/inserts from views without explicit grants for underlying tables. [#60439](https://github.com/ClickHouse/ClickHouse/pull/60439) ([pufit](https://github.com/pufit)). +* Added new syntax which allows to specify definer user in view/materialized view. This allows to execute selects/inserts from views without explicit grants for underlying tables. [#60439](https://github.com/ClickHouse/ClickHouse/pull/60439) ([pufit](https://github.com/pufit)). * Add four properties to the `StorageMemory` (memory-engine) `min_bytes_to_keep, max_bytes_to_keep, min_rows_to_keep` and `max_rows_to_keep` - Add tests to reflect new changes - Update `memory.md` documentation - Add table `context` property to `MemorySink` to enable access to table parameter bounds. [#60612](https://github.com/ClickHouse/ClickHouse/pull/60612) ([Jake Bamrah](https://github.com/JakeBamrah)). * Added function `toMillisecond` which returns the millisecond component for values of type`DateTime` or `DateTime64`. [#60649](https://github.com/ClickHouse/ClickHouse/pull/60649) ([Robert Schulze](https://github.com/rschu1ze)). * Separate limits on number of waiting and executing queries. Added new server setting `max_waiting_queries` that limits the number of queries waiting due to `async_load_databases`. Existing limits on number of executing queries no longer count waiting queries. [#61053](https://github.com/ClickHouse/ClickHouse/pull/61053) ([Sergei Trifonov](https://github.com/serxa)). diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/changelogs/changelog-24-5.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/01_changelog/02_release_notes/24_05.md similarity index 98% rename from i18n/zh/docusaurus-plugin-content-docs/current/cloud/changelogs/changelog-24-5.md rename to i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/01_changelog/02_release_notes/24_05.md index 256c6e4c3be..ad97ed2b6ac 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/changelogs/changelog-24-5.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/01_changelog/02_release_notes/24_05.md @@ -3,14 +3,16 @@ slug: /changelogs/24.5 title: 'v24.5 Changelog for Cloud' description: 'Fast release changelog for v24.5' keywords: ['changelog', 'cloud'] -sidebar_label: 'v24.5' +sidebar_label: '24.5' +sidebar_position: 7 +doc_type: 'changelog' --- -# v24.5 Changelog for Cloud +# V24.5 changelog for Cloud Relevant changes for ClickHouse Cloud services based on the v24.5 release. -## Breaking Changes {#breaking-changes} +## Breaking changes {#breaking-changes} * Change the column name from duration_ms to duration_microseconds in the system.zookeeper table to reflect the reality that the duration is in the microsecond resolution. [#60774](https://github.com/ClickHouse/ClickHouse/pull/60774) (Duc Canh Le). @@ -20,8 +22,7 @@ Relevant changes for ClickHouse Cloud services based on the v24.5 release. * Usage of functions neighbor, runningAccumulate, runningDifferenceStartingWithFirstValue, runningDifference deprecated (because it is error-prone). Proper window functions should be used instead. To enable them back, set allow_deprecated_error_prone_window_functions=1. [#63132](https://github.com/ClickHouse/ClickHouse/pull/63132) (Nikita Taranov). - -## Backward Incompatible Changes {#backward-incompatible-changes} +## Backward incompatible changes {#backward-incompatible-changes} * In the new ClickHouse version, the functions geoDistance, greatCircleDistance, and greatCircleAngle will use 64-bit double precision floating point data type for internal calculations and return type if all the arguments are Float64. This closes #58476. In previous versions, the function always used Float32. You can switch to the old behavior by setting geo_distance_returns_float64_on_float64_arguments to false or setting compatibility to 24.2 or earlier. [#61848](https://github.com/ClickHouse/ClickHouse/pull/61848) (Alexey Milovidov). @@ -29,7 +30,7 @@ Relevant changes for ClickHouse Cloud services based on the v24.5 release. * Fix crash in largestTriangleThreeBuckets. This changes the behaviour of this function and makes it to ignore NaNs in the series provided. Thus the resultset might differ from previous versions. [#62646](https://github.com/ClickHouse/ClickHouse/pull/62646) (Raúl Marín). -## New Features {#new-features} +## New features {#new-features} * The new analyzer is enabled by default on new services. diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/changelogs/changelog-24-6.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/01_changelog/02_release_notes/24_06.md similarity index 99% rename from i18n/zh/docusaurus-plugin-content-docs/current/cloud/changelogs/changelog-24-6.md rename to i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/01_changelog/02_release_notes/24_06.md index 3dc8d747ea5..1436edd5227 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/changelogs/changelog-24-6.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/01_changelog/02_release_notes/24_06.md @@ -3,18 +3,20 @@ slug: /changelogs/24.6 title: 'v24.6 Changelog for Cloud' description: 'Fast release changelog for v24.6' keywords: ['changelog', 'cloud'] -sidebar_label: 'v24.6' +sidebar_label: '24.6' +sidebar_position: 6 +doc_type: 'changelog' --- -# v24.6 Changelog for Cloud +# V24.6 changelog for Cloud Relevant changes for ClickHouse Cloud services based on the v24.6 release. -## Backward Incompatible Change {#backward-incompatible-change} +## Backward incompatible change {#backward-incompatible-change} * Rework parallel processing in `Ordered` mode of storage `S3Queue`. This PR is backward incompatible for Ordered mode if you used settings `s3queue_processing_threads_num` or `s3queue_total_shards_num`. Setting `s3queue_total_shards_num` is deleted, previously it was allowed to use only under `s3queue_allow_experimental_sharded_mode`, which is now deprecated. A new setting is added - `s3queue_buckets`. [#64349](https://github.com/ClickHouse/ClickHouse/pull/64349) ([Kseniia Sumarokova](https://github.com/kssenii)). * New functions `snowflakeIDToDateTime`, `snowflakeIDToDateTime64`, `dateTimeToSnowflakeID`, and `dateTime64ToSnowflakeID` were added. Unlike the existing functions `snowflakeToDateTime`, `snowflakeToDateTime64`, `dateTimeToSnowflake`, and `dateTime64ToSnowflake`, the new functions are compatible with function `generateSnowflakeID`, i.e. they accept the snowflake IDs generated by `generateSnowflakeID` and produce snowflake IDs of the same type as `generateSnowflakeID` (i.e. `UInt64`). Furthermore, the new functions default to the UNIX epoch (aka. 1970-01-01), just like `generateSnowflakeID`. If necessary, a different epoch, e.g. Twitter's/X's epoch 2010-11-04 aka. 1288834974657 msec since UNIX epoch, can be passed. The old conversion functions are deprecated and will be removed after a transition period: to use them regardless, enable setting `allow_deprecated_snowflake_conversion_functions`. [#64948](https://github.com/ClickHouse/ClickHouse/pull/64948) ([Robert Schulze](https://github.com/rschu1ze)). -## New Feature {#new-feature} +## New feature {#new-feature} * Support empty tuples. [#55061](https://github.com/ClickHouse/ClickHouse/pull/55061) ([Amos Bird](https://github.com/amosbird)). * Add Hilbert Curve encode and decode functions. [#60156](https://github.com/ClickHouse/ClickHouse/pull/60156) ([Artem Mustafin](https://github.com/Artemmm91)). diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/changelogs/changelog-24-8.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/01_changelog/02_release_notes/24_08.md similarity index 97% rename from i18n/zh/docusaurus-plugin-content-docs/current/cloud/changelogs/changelog-24-8.md rename to i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/01_changelog/02_release_notes/24_08.md index 29cabc28e51..5567fdccb05 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/changelogs/changelog-24-8.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/01_changelog/02_release_notes/24_08.md @@ -3,12 +3,14 @@ slug: /changelogs/24.8 title: 'v24.8 Changelog for Cloud' description: 'Fast release changelog for v24.8' keywords: ['changelog', 'cloud'] -sidebar_label: 'v24.8' +sidebar_label: '24.8' +sidebar_position: 5 +doc_type: 'changelog' --- Relevant changes for ClickHouse Cloud services based on the v24.8 release. -## Backward Incompatible Change {#backward-incompatible-change} +## Backward incompatible change {#backward-incompatible-change} - Change binary serialization of Variant data type: add compact mode to avoid writing the same discriminator multiple times for granules with single variant or with only NULL values. Add MergeTree setting use_compact_variant_discriminators_serialization that is enabled by default. Note that Variant type is still experimental and backward-incompatible change in serialization should not impact you unless you have been working with support to get this feature enabled earlier. [#62774](https://github.com/ClickHouse/ClickHouse/pull/62774) (Kruglov Pavel). @@ -28,8 +30,7 @@ Relevant changes for ClickHouse Cloud services based on the v24.8 release. - Fix REPLACE modifier formatting (forbid omitting brackets). [#67774](https://github.com/ClickHouse/ClickHouse/pull/67774) (Azat Khuzhin). - -## New Feature {#new-feature} +## New feature {#new-feature} - Extend function tuple to construct named tuples in query. Introduce function tupleNames to extract names from tuples. [#54881](https://github.com/ClickHouse/ClickHouse/pull/54881) (Amos Bird). diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/changelogs/changelog-24-10.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/01_changelog/02_release_notes/24_10.md similarity index 98% rename from i18n/zh/docusaurus-plugin-content-docs/current/cloud/changelogs/changelog-24-10.md rename to i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/01_changelog/02_release_notes/24_10.md index e75eec40655..097e6fa5f91 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/changelogs/changelog-24-10.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/01_changelog/02_release_notes/24_10.md @@ -3,12 +3,14 @@ slug: /changelogs/24.10 title: 'v24.10 Changelog for Cloud' description: 'Fast release changelog for v24.10' keywords: ['changelog', 'cloud'] -sidebar_label: 'v24.10' +sidebar_label: '24.10' +sidebar_position: 4 +doc_type: 'changelog' --- Relevant changes for ClickHouse Cloud services based on the v24.10 release. -## Backward Incompatible Change {#backward-incompatible-change} +## Backward incompatible change {#backward-incompatible-change} - Allow to write `SETTINGS` before `FORMAT` in a chain of queries with `UNION` when subqueries are inside parentheses. This closes [#39712](https://github.com/ClickHouse/ClickHouse/issues/39712). Change the behavior when a query has the SETTINGS clause specified twice in a sequence. The closest SETTINGS clause will have a preference for the corresponding subquery. In the previous versions, the outermost SETTINGS clause could take a preference over the inner one. [#60197](https://github.com/ClickHouse/ClickHouse/pull/60197)[#68614](https://github.com/ClickHouse/ClickHouse/pull/68614) ([Alexey Milovidov](https://github.com/alexey-milovidov)). - Reimplement Dynamic type. Now when the limit of dynamic data types is reached new types are not cast to String but stored in a special data structure in binary format with binary encoded data type. Now any type ever inserted into Dynamic column can be read from it as subcolumn. [#68132](https://github.com/ClickHouse/ClickHouse/pull/68132) ([Pavel Kruglov](https://github.com/Avogar)). - Expressions like `a[b].c` are supported for named tuples, as well as named subscripts from arbitrary expressions, e.g., `expr().name`. This is useful for processing JSON. This closes [#54965](https://github.com/ClickHouse/ClickHouse/issues/54965). In previous versions, an expression of form `expr().name` was parsed as `tupleElement(expr(), name)`, and the query analyzer was searching for a column `name` rather than for the corresponding tuple element; while in the new version, it is changed to `tupleElement(expr(), 'name')`. In most cases, the previous version was not working, but it is possible to imagine a very unusual scenario when this change could lead to incompatibility: if you stored names of tuple elements in a column or an alias, that was named differently than the tuple element's name: `SELECT 'b' AS a, CAST([tuple(123)] AS 'Array(Tuple(b UInt8))') AS t, t[1].a`. It is very unlikely that you used such queries, but we still have to mark this change as potentially backward incompatible. [#68435](https://github.com/ClickHouse/ClickHouse/pull/68435) ([Alexey Milovidov](https://github.com/alexey-milovidov)). @@ -16,8 +18,7 @@ Relevant changes for ClickHouse Cloud services based on the v24.10 release. - Reordering of filter conditions from `[PRE]WHERE` clause is now allowed by default. It could be disabled by setting `allow_reorder_prewhere_conditions` to `false`. [#70657](https://github.com/ClickHouse/ClickHouse/pull/70657) ([Nikita Taranov](https://github.com/nickitat)). - Fix `optimize_functions_to_subcolumns` optimization (previously could lead to `Invalid column type for ColumnUnique::insertRangeFrom. Expected String, got LowCardinality(String)` error), by preserving `LowCardinality` type in `mapKeys`/`mapValues`. [#70716](https://github.com/ClickHouse/ClickHouse/pull/70716) ([Azat Khuzhin](https://github.com/azat)). - -## New Feature {#new-feature} +## New feature {#new-feature} - Refreshable materialized views are production ready. [#70550](https://github.com/ClickHouse/ClickHouse/pull/70550) ([Michael Kolupaev](https://github.com/al13n321)). Refreshable materialized views are now supported in Replicated databases. [#60669](https://github.com/ClickHouse/ClickHouse/pull/60669) ([Michael Kolupaev](https://github.com/al13n321)). - Function `toStartOfInterval()` now has a new overload which emulates TimescaleDB's `time_bucket()` function, respectively PostgreSQL's `date_bin()` function. ([#55619](https://github.com/ClickHouse/ClickHouse/issues/55619)). It allows to align date or timestamp values to multiples of a given interval from an *arbitrary* origin (instead of 0000-01-01 00:00:00.000 as *fixed* origin). For example, `SELECT toStartOfInterval(toDateTime('2023-01-01 14:45:00'), INTERVAL 1 MINUTE, toDateTime('2023-01-01 14:35:30'));` returns `2023-01-01 14:44:30` which is a multiple of 1 minute intervals, starting from origin `2023-01-01 14:35:30`. [#56738](https://github.com/ClickHouse/ClickHouse/pull/56738) ([Yarik Briukhovetskyi](https://github.com/yariks5s)). - MongoDB integration refactored: migration to new driver mongocxx from deprecated Poco::MongoDB, remove support for deprecated old protocol, support for connection by URI, support for all MongoDB types, support for WHERE and ORDER BY statements on MongoDB side, restriction for expression unsupported by MongoDB. [#63279](https://github.com/ClickHouse/ClickHouse/pull/63279) ([Kirill Nikiforov](https://github.com/allmazz)). @@ -50,5 +51,3 @@ Relevant changes for ClickHouse Cloud services based on the v24.10 release. - Allow to read/write JSON type as binary string in RowBinary format under settings `input_format_binary_read_json_as_string/output_format_binary_write_json_as_string`. [#70288](https://github.com/ClickHouse/ClickHouse/pull/70288) ([Pavel Kruglov](https://github.com/Avogar)). - Allow to serialize/deserialize JSON column as single String column in Native format. For output use setting `output_format_native_write_json_as_string`. For input, use serialization version `1` before the column data. [#70312](https://github.com/ClickHouse/ClickHouse/pull/70312) ([Pavel Kruglov](https://github.com/Avogar)). - Supports standard CTE, `with insert`, as previously only supports `insert ... with ...`. [#70593](https://github.com/ClickHouse/ClickHouse/pull/70593) ([Shichao Jin](https://github.com/jsc0218)). - - diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/changelogs/changelog-24-12.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/01_changelog/02_release_notes/24_12.md similarity index 99% rename from i18n/zh/docusaurus-plugin-content-docs/current/cloud/changelogs/changelog-24-12.md rename to i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/01_changelog/02_release_notes/24_12.md index feb1b2fe93a..239257061ea 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/changelogs/changelog-24-12.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/01_changelog/02_release_notes/24_12.md @@ -3,12 +3,14 @@ slug: /changelogs/24.12 title: 'v24.12 Changelog for Cloud' description: 'Fast release changelog for v24.12' keywords: ['changelog', 'cloud'] -sidebar_label: 'v24.12' +sidebar_label: '24.12' +sidebar_position: 3 +doc_type: 'changelog' --- Relevant changes for ClickHouse Cloud services based on the v24.12 release. -## Backward Incompatible Changes {#backward-incompatible-changes} +## Backward incompatible changes {#backward-incompatible-changes} - Functions `greatest` and `least` now ignore NULL input values, whereas they previously returned NULL if one of the arguments was NULL. For example, `SELECT greatest(1, 2, NULL)` now returns 2. This makes the behavior compatible with PostgreSQL. [#65519](https://github.com/ClickHouse/ClickHouse/pull/65519) ([kevinyhzou](https://github.com/KevinyhZou)). - Don't allow Variant/Dynamic types in ORDER BY/GROUP BY/PARTITION BY/PRIMARY KEY by default because it may lead to unexpected results. [#69731](https://github.com/ClickHouse/ClickHouse/pull/69731) ([Pavel Kruglov](https://github.com/Avogar)). @@ -23,7 +25,7 @@ Relevant changes for ClickHouse Cloud services based on the v24.12 release. - Remove support for `Enum` as well as `UInt128` and `UInt256` arguments in `deltaSumTimestamp`. Remove support for `Int8`, `UInt8`, `Int16`, and `UInt16` of the second ("timestamp") argument of `deltaSumTimestamp`. [#71790](https://github.com/ClickHouse/ClickHouse/pull/71790) ([Alexey Milovidov](https://github.com/alexey-milovidov)). - Added source query validation when ClickHouse is used as a source for a dictionary. [#72548](https://github.com/ClickHouse/ClickHouse/pull/72548) ([Alexey Katsman](https://github.com/alexkats)). -## New Features {#new-features} +## New features {#new-features} - Implement SYSTEM LOAD PRIMARY KEY command to load primary indexes for all parts of a specified table or for all tables if no table is specified. This will be useful for benchmarks and to prevent extra latency during query execution. [#66252](https://github.com/ClickHouse/ClickHouse/pull/66252) ([ZAWA_ll](https://github.com/Zawa-ll)). - Added statement `SYSTEM LOAD PRIMARY KEY` for loading the primary indexes of all parts in a specified table or for all tables if no table is specified. This can be useful for benchmarking and to prevent extra latency during query execution. [#67733](https://github.com/ClickHouse/ClickHouse/pull/67733) ([ZAWA_ll](https://github.com/Zawa-ll)). diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/changelogs/changelog-25_1-25_4.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/01_changelog/02_release_notes/25_04.md similarity index 99% rename from i18n/zh/docusaurus-plugin-content-docs/current/cloud/changelogs/changelog-25_1-25_4.md rename to i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/01_changelog/02_release_notes/25_04.md index 038dd45e061..248509a5425 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/changelogs/changelog-25_1-25_4.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/01_changelog/02_release_notes/25_04.md @@ -1,12 +1,14 @@ --- slug: /changelogs/25.4 title: 'v25.4 Changelog for Cloud' -description: 'Changelog for v25.4' +description: 'Fast release changelog for v25.4' keywords: ['changelog', 'cloud'] -sidebar_label: 'v25.4' +sidebar_label: '25.4' +sidebar_position: 2 +doc_type: 'changelog' --- -## Backward Incompatible Changes {#backward-incompatible-changes} +## Backward incompatible changes {#backward-incompatible-changes} * Parquet output format converts Date and DateTime columns to date/time types supported by Parquet, instead of writing them as raw numbers. DateTime becomes DateTime64(3) (was: UInt32); setting `output_format_parquet_datetime_as_uint32` brings back the old behavior. Date becomes Date32 (was: UInt16). [#70950](https://github.com/ClickHouse/ClickHouse/pull/70950) ([Michael Kolupaev](https://github.com/al13n321)). * Don't allow comparable types (like JSON/Object/AggregateFunction) in ORDER BY and comparison functions `less/greater/equal/etc` by default. [#73276](https://github.com/ClickHouse/ClickHouse/pull/73276) ([Pavel Kruglov](https://github.com/Avogar)). @@ -25,7 +27,7 @@ sidebar_label: 'v25.4' * The legacy MongoDB integration has been removed. Server setting `use_legacy_mongodb_integration` became obsolete and now does nothing. [#77895](https://github.com/ClickHouse/ClickHouse/pull/77895) ([Robert Schulze](https://github.com/rschu1ze)). * Enhance SummingMergeTree validation to skip aggregation for columns used in partition or sort keys. [#78022](https://github.com/ClickHouse/ClickHouse/pull/78022) ([Pervakov Grigorii](https://github.com/GrigoryPervakov)). -## New Features {#new-features} +## New features {#new-features} * Added an in-memory cache for deserialized skipping index granules. This should make repeated queries that use skipping indexes faster. The size of the new cache is controlled by server settings `skipping_index_cache_size` and `skipping_index_cache_max_entries`. The original motivation for the cache were vector similarity indexes which became a lot faster now. [#70102](https://github.com/ClickHouse/ClickHouse/pull/70102) ([Robert Schulze](https://github.com/rschu1ze)). * A new implementation of the Userspace Page Cache, which allows caching data in the in-process memory instead of relying on the OS page cache. It is useful when the data is stored on a remote virtual filesystem without backing with the local filesystem cache. [#70509](https://github.com/ClickHouse/ClickHouse/pull/70509) ([Michael Kolupaev](https://github.com/al13n321)). @@ -274,7 +276,7 @@ sidebar_label: 'v25.4' * Don't fail silently if user executing `SYSTEM DROP REPLICA` doesn't have enough permissions. [#75377](https://github.com/ClickHouse/ClickHouse/pull/75377) ([Bharat Nallan](https://github.com/bharatnc)). * Add a ProfileEvent about the number of times any of system logs has failed to flush. [#75466](https://github.com/ClickHouse/ClickHouse/pull/75466) ([Alexey Milovidov](https://github.com/alexey-milovidov)). * Add check and logging for decrypting and decompressing. [#75471](https://github.com/ClickHouse/ClickHouse/pull/75471) ([Vitaly Baranov](https://github.com/vitlibar)). -* Added support for the micro sign (U+00B5) in the `parseTimeDelta` function. Now both the micro sign (U+00B5) and the Greek letter mu (U+03BC) are recognized as valid representations for microseconds, aligning ClickHouse's behavior with Go’s implementation ([see time.go](https://github.com/golang/go/blob/ad7b46ee4ac1cee5095d64b01e8cf7fcda8bee5e/src/time/time.go#L983C19-L983C20) and [time/format.go](https://github.com/golang/go/blob/ad7b46ee4ac1cee5095d64b01e8cf7fcda8bee5e/src/time/format.go#L1608-L1609)). [#75472](https://github.com/ClickHouse/ClickHouse/pull/75472) ([Vitaly Orlov](https://github.com/orloffv)). +* Added support for the micro sign (U+00B5) in the `parseTimeDelta` function. Now both the micro sign (U+00B5) and the Greek letter mu (U+03BC) are recognized as valid representations for microseconds, aligning ClickHouse's behavior with Go's implementation ([see time.go](https://github.com/golang/go/blob/ad7b46ee4ac1cee5095d64b01e8cf7fcda8bee5e/src/time/time.go#L983C19-L983C20) and [time/format.go](https://github.com/golang/go/blob/ad7b46ee4ac1cee5095d64b01e8cf7fcda8bee5e/src/time/format.go#L1608-L1609)). [#75472](https://github.com/ClickHouse/ClickHouse/pull/75472) ([Vitaly Orlov](https://github.com/orloffv)). * Replace server setting (`send_settings_to_client`) with client setting (`apply_settings_from_server`) that controls whether client-side code (e.g. parsing INSERT data and formatting query output) should use settings from server's `users.xml` and user profile. Otherwise only settings from client command line, session, and the query are used. Note that this only applies to native client (not e.g. HTTP), and doesn't apply to most of query processing (which happens on the server). [#75478](https://github.com/ClickHouse/ClickHouse/pull/75478) ([Michael Kolupaev](https://github.com/al13n321)). * Keeper improvement: disable digest calculation when committing to in-memory storage for better performance. It can be enabled with `keeper_server.digest_enabled_on_commit` config. Digest is still calculated when preprocessing requests. [#75490](https://github.com/ClickHouse/ClickHouse/pull/75490) ([Antonio Andelic](https://github.com/antonio2368)). * Push down filter expression from JOIN ON when possible. [#75536](https://github.com/ClickHouse/ClickHouse/pull/75536) ([Vladimir Cherkasov](https://github.com/vdimir)). @@ -611,7 +613,7 @@ sidebar_label: 'v25.4' * Fix crash in REFRESHABLE MV in case of ALTER after incorrect shutdown. [#78858](https://github.com/ClickHouse/ClickHouse/pull/78858) ([Azat Khuzhin](https://github.com/azat)). * Fix parsing of bad DateTime values in CSV format. [#78919](https://github.com/ClickHouse/ClickHouse/pull/78919) ([Pavel Kruglov](https://github.com/Avogar)). -## Build/Testing/Packaging Improvement {#build-testing-packaging-improvement} +## Build/testing/packaging improvement {#build-testing-packaging-improvement} * The internal dependency LLVM is bumped from 16 to 18. [#66053](https://github.com/ClickHouse/ClickHouse/pull/66053) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)). * Restore deleted nats integration tests and fix errors. - fixed some race conditions in nats engine - fixed data loss when streaming data to nats in case of connection loss - fixed freeze of receiving the last chunk of data when streaming from nats ended - nats_max_reconnect is deprecated and has no effect, reconnect is performed permanently with nats_reconnect_wait timeout. [#69772](https://github.com/ClickHouse/ClickHouse/pull/69772) ([Dmitry Novikov](https://github.com/dmitry-sles-novikov)). @@ -621,7 +623,7 @@ sidebar_label: 'v25.4' * The universal installation script will propose installation even on macOS. [#74339](https://github.com/ClickHouse/ClickHouse/pull/74339) ([Alexey Milovidov](https://github.com/alexey-milovidov)). * Fix build when kerberos is not enabled. [#74771](https://github.com/ClickHouse/ClickHouse/pull/74771) ([flynn](https://github.com/ucasfl)). * Update to embedded LLVM 19. [#75148](https://github.com/ClickHouse/ClickHouse/pull/75148) ([Konstantin Bogdanov](https://github.com/thevar1able)). -* *Potentially breaking*: Improvement to set even more restrictive defaults. The current defaults are already secure. The user has to specify an option to publish ports explicitly. But when the `default` user doesn’t have a password set by `CLICKHOUSE_PASSWORD` and/or a username changed by `CLICKHOUSE_USER` environment variables, it should be available only from the local system as an additional level of protection. [#75259](https://github.com/ClickHouse/ClickHouse/pull/75259) ([Mikhail f. Shiryaev](https://github.com/Felixoid)). +* *Potentially breaking*: Improvement to set even more restrictive defaults. The current defaults are already secure. The user has to specify an option to publish ports explicitly. But when the `default` user doesn't have a password set by `CLICKHOUSE_PASSWORD` and/or a username changed by `CLICKHOUSE_USER` environment variables, it should be available only from the local system as an additional level of protection. [#75259](https://github.com/ClickHouse/ClickHouse/pull/75259) ([Mikhail f. Shiryaev](https://github.com/Felixoid)). * Integration tests have a 1-hour timeout for single batch of parallel tests running. When this timeout is reached `pytest` is killed without some logs. Internal pytest timeout is set to 55 minutes to print results from a session and not trigger external timeout signal. Closes [#75532](https://github.com/ClickHouse/ClickHouse/issues/75532). [#75533](https://github.com/ClickHouse/ClickHouse/pull/75533) ([Ilya Yatsishin](https://github.com/qoega)). * Make all clickhouse-server related actions a function, and execute them only when launching the default binary in `entrypoint.sh`. A long-postponed improvement was suggested in [#50724](https://github.com/ClickHouse/ClickHouse/issues/50724). Added switch `--users` to `clickhouse-extract-from-config` to get values from the `users.xml`. [#75643](https://github.com/ClickHouse/ClickHouse/pull/75643) ([Mikhail f. Shiryaev](https://github.com/Felixoid)). * For stress tests if server did not exit while we collected stacktraces via gdb additional wait time is added to make `Possible deadlock on shutdown (see gdb.log)` detection less noisy. It will only add delay for cases when test did not finish successfully. [#75668](https://github.com/ClickHouse/ClickHouse/pull/75668) ([Ilya Yatsishin](https://github.com/qoega)). diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/01_changelog/02_release_notes/25_06.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/01_changelog/02_release_notes/25_06.md new file mode 100644 index 00000000000..5f8735fc4a2 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/01_changelog/02_release_notes/25_06.md @@ -0,0 +1,396 @@ +--- +slug: /changelogs/25.6 +title: 'v25.6 Changelog for Cloud' +description: 'Fast release changelog for v25.6' +keywords: ['changelog', 'cloud'] +sidebar_label: '25.6' +sidebar_position: 1 +doc_type: 'changelog' +--- + +## Backward incompatible change {#backward-incompatible-change} + +* Function `geoToH3()` now accepts the input in the order (lat, lon,res) (which is the standard order for geometric functions). Users who wish to retain the legacy result order (lon, lat,res) can set setting `geotoh3_lon_lat_input_order = true`. [#78852](https://github.com/ClickHouse/ClickHouse/pull/78852) ([Pratima Patel](https://github.com/pratimapatel2008)). +* Indexes of type `full_text` were renamed to `gin`. This follows the more familiar terminology of PostgreSQL and other databases. Existing indexes of type `full_text` remain loadable but they will throw an exception (suggesting `gin` indexes instead) when one tries to use them in searches. [#79024](https://github.com/ClickHouse/ClickHouse/pull/79024) ([Robert Schulze](https://github.com/rschu1ze)). +* Add a filesystem cache setting `allow_dynamic_cache_resize`, by default `false`, to allow dynamic resize of filesystem cache. Why: in certain environments (ClickHouse Cloud) all the scaling events happen through the restart of the process and we would love this feature to be explicitly disabled to have more control over the behavior + as a safety measure. This PR is marked as backward incompatible, because in older versions dynamic cache resize worked by default without special setting. [#79148](https://github.com/ClickHouse/ClickHouse/pull/79148) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Removed support for legacy index types `annoy` and `usearch`. Both have been stubs for a long time, i.e. every attempt to use the legacy indexes returned an error anyways. If you still have `annoy` and `usearch` indexes, please drop them. [#79802](https://github.com/ClickHouse/ClickHouse/pull/79802) ([Robert Schulze](https://github.com/rschu1ze)). +#* Remove `format_alter_commands_with_parentheses` server setting. The setting was introduced and disabled by default in 24.2. It was enabled by default in 25.2. As there are no LTS versions that don't support the new format, we can remove the setting. [#79970](https://github.com/ClickHouse/ClickHouse/pull/79970) ([János Benjamin Antal](https://github.com/antaljanosbenjamin)). +#* Minor: Force backup_threads and restore_threads server settings to be non zero. [#80224](https://github.com/ClickHouse/ClickHouse/pull/80224) ([Raúl Marín](https://github.com/Algunenano)). +* Fix bitNot() for String to return a zero-terminated string. [#80791](https://github.com/ClickHouse/ClickHouse/pull/80791) ([Azat Khuzhin](https://github.com/azat)). + +## New feature {#new-feature} + +* Add a new option to MergeTree `SETTINGS` which specifies a default compression codec in case the `CREATE` query does not explicitly define one for the given columns. This closes [#42005](https://github.com/ClickHouse/ClickHouse/issues/42005). [#66394](https://github.com/ClickHouse/ClickHouse/pull/66394) ([gvoelfin](https://github.com/gvoelfin)). +* Follow up for https://github.com/ClickHouse/ClickHouse/pull/71943. This PR implements `Time`/`Time64` data types. Implements new data types: Time (HHH:MM:SS) and Time64 (HHH:MM:SS.``), some basic cast functions and functions to interact with other data types. Also, changed the existing function's name `toTime` to `toTimeWithFixedDate` because the function `toTime` is required for the cast function. [#75735](https://github.com/ClickHouse/ClickHouse/pull/75735) ([Yarik Briukhovetskyi](https://github.com/yariks5s)). +* Support correlated subqueries as an argument of `EXISTS` expression in the `WHERE` clause. Closes [#72459](https://github.com/ClickHouse/ClickHouse/issues/72459). [#76078](https://github.com/ClickHouse/ClickHouse/pull/76078) ([Dmitry Novik](https://github.com/novikd)). +* Allow writing to Merge table engines. [#77484](https://github.com/ClickHouse/ClickHouse/pull/77484) ([Anton Ivashkin](https://github.com/ianton-ru)). +* Distributed `INSERT SELECT` for replicated MergeTree tables now efficiently uses parallel replicas to parallelize `INSERT`s by selecting different data on different nodes and inserting them independently. [#78041](https://github.com/ClickHouse/ClickHouse/pull/78041) ([Igor Nikonov](https://github.com/devcrafter)). +* Add `mapContainsValuesLike`/`mapContainsValues`/`mapExtractValuesLike` functions to filter on map values and their support in bloomfilter based indexes. [#78171](https://github.com/ClickHouse/ClickHouse/pull/78171) ([UnamedRus](https://github.com/UnamedRus)). +* Add `system.iceberg_history` table. [#78244](https://github.com/ClickHouse/ClickHouse/pull/78244) ([Smita Kulkarni](https://github.com/SmitaRKulkarni)). +* Added query slot scheduling for workloads, see https://clickhouse.com/docs/operations/workload-scheduling#query_scheduling for details. [#78415](https://github.com/ClickHouse/ClickHouse/pull/78415) ([Sergei Trifonov](https://github.com/serxa)). +* Add `getServerSetting` and `getMergeTreeSetting` function. Closes https://github.com/clickhouse/clickhouse/issues/78318. [#78439](https://github.com/ClickHouse/ClickHouse/pull/78439) ([NamNguyenHoai](https://github.com/NamHoaiNguyen)). +* Support disallowed values under settings constraints. [#78499](https://github.com/ClickHouse/ClickHouse/pull/78499) ([Bharat Nallan](https://github.com/bharatnc)). +* Add new `iceberg_enable_version_hint` setting to leverage `version-hint.text` file. [#78594](https://github.com/ClickHouse/ClickHouse/pull/78594) ([Arnaud Briche](https://github.com/arnaudbriche)). +* Gives the possibility to truncate specific tables from a database, filtered with the `LIKE` keyword. [#78597](https://github.com/ClickHouse/ClickHouse/pull/78597) ([Yarik Briukhovetskyi](https://github.com/yariks5s)). +* `clickhouse-local` (and its shorthand alias, `ch`) now use an implicit `FROM table` when there is input data for processing. This closes [#65023](https://github.com/ClickHouse/ClickHouse/issues/65023). Also enabled format inference in clickhouse-local if `--input-format` is not specified and it processes a regular file. [#79085](https://github.com/ClickHouse/ClickHouse/pull/79085) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Add [`icebergHash`](https://iceberg.apache.org/spec/#appendix-b-32-bit-hash-requirements) and [`icebergBucketTransform`](https://iceberg.apache.org/spec/#bucket-transform-details) functions. Support data files pruning in `Iceberg` tables partitioned with [`bucket transfom`](https://iceberg.apache.org/spec/#partitioning). [#79262](https://github.com/ClickHouse/ClickHouse/pull/79262) ([Daniil Ivanik](https://github.com/divanik)). +* Add a support for Coalescing Merge Tree. This closes [#78869](https://github.com/ClickHouse/ClickHouse/issues/78869). [#79344](https://github.com/ClickHouse/ClickHouse/pull/79344) ([Konstantin Vedernikov](https://github.com/scanhex12)). +* Add `stringBytesUniq` and `stringBytesEntropy` functions to search for possibly random or encrypted data. [#79350](https://github.com/ClickHouse/ClickHouse/pull/79350) ([Sachin Kumar Singh](https://github.com/sachinkumarsingh092)). +* Support `_part_starting_offset` virtual column in MergeTree-family tables. This column represents the cumulative row count of all preceding parts, calculated at query time based on the current part list. The cumulative values are retained throughout query execution and remain effective even after part pruning. Related internal logic has been refactored to support this behavior. [#79417](https://github.com/ClickHouse/ClickHouse/pull/79417) ([Amos Bird](https://github.com/amosbird)). +* Added a setting `enable_shared_storage_snapshot_in_query` to enable sharing the same storage snapshot across all subqueries in a single query. This ensures consistent reads from the same table, even when the table is referenced multiple times within a query. [#79471](https://github.com/ClickHouse/ClickHouse/pull/79471) ([Amos Bird](https://github.com/amosbird)). +* Support writing CH JSON columns to Parquet and reading Parquet JSON columns directly as CH JSON columns. [#79649](https://github.com/ClickHouse/ClickHouse/pull/79649) ([Nihal Z. Miaji](https://github.com/nihalzp)). +* Bundle [`chdig`](https://github.com/azat/chdig/) - TUI interface for ClickHouse (top like) as part of ClickHouse. [#79666](https://github.com/ClickHouse/ClickHouse/pull/79666) ([Azat Khuzhin](https://github.com/azat)). +* Add `MultiPolygon` support for `pointInPolygon`. [#79773](https://github.com/ClickHouse/ClickHouse/pull/79773) ([Nihal Z. Miaji](https://github.com/nihalzp)). +* Support geo parquet. This closes [#75317](https://github.com/ClickHouse/ClickHouse/issues/75317). [#79777](https://github.com/ClickHouse/ClickHouse/pull/79777) ([Konstantin Vedernikov](https://github.com/scanhex12)). +* Add support for querying local filesystem-mounted delta tables via `deltaLakeLocal` table function. [#79781](https://github.com/ClickHouse/ClickHouse/pull/79781) ([roykim98](https://github.com/roykim98)). +* Added base32 encode/decode functionality. [#79809](https://github.com/ClickHouse/ClickHouse/pull/79809) ([Joanna Hulboj](https://github.com/jh0x)). +* Clickhouse vector search now supports both pre-filtering and post-filtering and provides related settings for finer control. (issue [#78161](https://github.com/ClickHouse/ClickHouse/issues/78161)). [#79854](https://github.com/ClickHouse/ClickHouse/pull/79854) ([Shankar Iyer](https://github.com/shankar-iyer)). +* Support functions to read WKB format. This partially closes [#43941](https://github.com/ClickHouse/ClickHouse/issues/43941). [#80139](https://github.com/ClickHouse/ClickHouse/pull/80139) ([Konstantin Vedernikov](https://github.com/scanhex12)). +* Add new setting `cast_string_to_date_time_mode` that allows to choose DateTime parsing mode during cast from String. [#80210](https://github.com/ClickHouse/ClickHouse/pull/80210) ([Pavel Kruglov](https://github.com/Avogar)). +* Added `Bech32` and `Bech32m` encoding and decoding functions (issue [#40381](https://github.com/ClickHouse/ClickHouse/issues/40381)). [#80239](https://github.com/ClickHouse/ClickHouse/pull/80239) ([George Larionov](https://github.com/glarik)). +* Support `disk` setting for Atomic and Ordinary DB engines, specifying the disk to store table metadata files. [#80546](https://github.com/ClickHouse/ClickHouse/pull/80546) ([Tuan Pham Anh](https://github.com/tuanpach)). +* Support functions to unpack and compare merge tree parts. [#80573](https://github.com/ClickHouse/ClickHouse/pull/80573) ([Mikhail Artemenko](https://github.com/Michicosun)). +* `timeSeries*` helper functions to speed up some scenarios when working with time series data: - re-sample the data to the time grid with specified start timestamp, end timestamp and step - calculate PromQL-like `delta`, `rate`, `idelta` and `irate`. [#80590](https://github.com/ClickHouse/ClickHouse/pull/80590) ([Alexander Gololobov](https://github.com/davenger)). +* Allow filtering of parts selected for querying by the disk they reside on. [#80650](https://github.com/ClickHouse/ClickHouse/pull/80650) ([tanner-bruce](https://github.com/tanner-bruce)). +* Add a landing page with the list of embedded web tools. It will open when requested by a browser-like user agent. [#81129](https://github.com/ClickHouse/ClickHouse/pull/81129) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Allow for filtering `NULL` values in `arrayFirst`, `arrayFirstIndex`, `arrayLast` & `arrayLastIndex`. Fixes [#81113](https://github.com/ClickHouse/ClickHouse/issues/81113). [#81197](https://github.com/ClickHouse/ClickHouse/pull/81197) ([Lennard Eijsackers](https://github.com/Blokje5)). + +## Experimental feature {#experimental-feature} + +* Hive metastore catalog for iceberg datalake. [#77677](https://github.com/ClickHouse/ClickHouse/pull/77677) ([Konstantin Vedernikov](https://github.com/scanhex12)). +* The explicit parameters are supported via key-value pairs. Currently, supported parameters are a mandatory `tokenizer` and two optional `max_rows_per_postings_list` and `ngram_size`. [#80262](https://github.com/ClickHouse/ClickHouse/pull/80262) ([Elmi Ahmadov](https://github.com/ahmadov)). +* Experimental indexes of type `gin` were renamed to `text`. Existing indexes of type `gin` remain loadable but they will throw an exception (suggesting `text` indexes instead) when one tries to use them in searches. [#80855](https://github.com/ClickHouse/ClickHouse/pull/80855) ([Robert Schulze](https://github.com/rschu1ze)). + +## Performance improvement {#performance-improvement} + +* Speed up secondary indices by evaluating their expressions on multiple granules at once. [#64109](https://github.com/ClickHouse/ClickHouse/pull/64109) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Introduced threshold (regulated by setting `parallel_hash_join_threshold`) to fall back to the `hash` algorithm when the size of the right table is below the threshold. [#76185](https://github.com/ClickHouse/ClickHouse/pull/76185) ([Nikita Taranov](https://github.com/nickitat)). +* The existing implementation of `Pipe::resize` creates a single `Resize` or `StrictResize` node by inserting it into the pipeline topology, which then acts as a central hub connecting all input streams (upstream nodes) to a unified set of output streams (downstream nodes). This design leads to contention for the` ExecutingGraph::Node::status_mutex` during pipeline graph execution, especially in high-core-count environments. When pipelines scale to tens or hundreds of streams, this contention results in:. [#77562](https://github.com/ClickHouse/ClickHouse/pull/77562) ([Zhiguo Zhou](https://github.com/ZhiguoZh)). +* Improve performance of `S3Queue`/`AzureQueue` by allowing `INSERT`s data in parallel (can be enabled with `parallel_inserts=true` queue setting). Previously `S3Queue`/`AzureQueue` can only do the first part of the pipeline in parallel (downloading, parsing), INSERT was single-threaded. And `INSERT`s are almost always the bottleneck. Now it will scale almost linear with `processing_threads_num`. [#77671](https://github.com/ClickHouse/ClickHouse/pull/77671) ([Azat Khuzhin](https://github.com/azat)). +* Change the compact part format to save marks for each substream to be able to read individual sub-columns. The old compact format is still supported for reads and can be enabled for writes using MergeTree setting `write_marks_for_substreams_in_compact_parts`. It's disabled by default for safer upgrades as it changes the compact parts storage. It will be enabled by default in one of the next releases. [#77940](https://github.com/ClickHouse/ClickHouse/pull/77940) ([Pavel Kruglov](https://github.com/Avogar)). +* Introduced new setting`use_skip_indexes_in_final_exact_mode`. If a query on a `ReplacingMergeTree` table has the `FINAL` clause, reading only table ranges based on skip indexes may produce incorrect result. This setting can ensure that correct results are returned by scanning newer parts that have overlap with primary key ranges returned by the skip index. Set to 0 to disable, 1 to enable. [#78350](https://github.com/ClickHouse/ClickHouse/pull/78350) ([Shankar Iyer](https://github.com/shankar-iyer)). +* Now we use the number of replicas to determine the task size for reading with parallel replicas enabled. This provides better work distribution between replicas when the amount of data to read is not very large. [#78695](https://github.com/ClickHouse/ClickHouse/pull/78695) ([Nikita Taranov](https://github.com/nickitat)). +* Allow parallel merging of `uniqExact` states during the final stage of distributed aggregation. [#78703](https://github.com/ClickHouse/ClickHouse/pull/78703) ([Nikita Taranov](https://github.com/nickitat)). +* Fix possible performance degradation of the parallel merging of `uniqExact` states for aggregation with key. [#78724](https://github.com/ClickHouse/ClickHouse/pull/78724) ([Nikita Taranov](https://github.com/nickitat)). +#* Replace `DELETE FROM ... WHERE 1` queries to `TRUNCATE`. (Reverted). [#78739](https://github.com/ClickHouse/ClickHouse/pull/78739) ([Konstantin Vedernikov](https://github.com/scanhex12)). +* Reduce the number of List Blobs API calls to Azure storage. [#78860](https://github.com/ClickHouse/ClickHouse/pull/78860) ([Julia Kartseva](https://github.com/jkartseva)). +* Merge equality conditions from filter query plan step into `JOIN` condition if possible to allow using them as hash table keys. [#78877](https://github.com/ClickHouse/ClickHouse/pull/78877) ([Dmitry Novik](https://github.com/novikd)). +* Improve performance of hive path parsing by using `extractKeyValuePairs` instead of regex. [#79067](https://github.com/ClickHouse/ClickHouse/pull/79067) ([Arthur Passos](https://github.com/arthurpassos)). +* Fix performance of the distributed `INSERT SELECT` with parallel replicas. [#79441](https://github.com/ClickHouse/ClickHouse/pull/79441) ([Azat Khuzhin](https://github.com/azat)). +* Allow moving conditions with sub-columns to `PREWHERE`. [#79489](https://github.com/ClickHouse/ClickHouse/pull/79489) ([Pavel Kruglov](https://github.com/Avogar)). +* Performance improvements to all bloom filter types. [#79800](https://github.com/ClickHouse/ClickHouse/pull/79800) ([Delyan Kratunov](https://github.com/dkratunov)). +* Prevent `LogSeriesLimiter` from doing cleanup on every construction, avoiding lock contention and performance regressions in high-concurrency scenarios. [#79864](https://github.com/ClickHouse/ClickHouse/pull/79864) ([filimonov](https://github.com/filimonov)). +* Enable `compile_expressions` (JIT compiler for fragments of ordinary expressions) by default. This closes [#51264](https://github.com/ClickHouse/ClickHouse/issues/51264) and [#56386](https://github.com/ClickHouse/ClickHouse/issues/56386) and [#66486](https://github.com/ClickHouse/ClickHouse/issues/66486). [#79907](https://github.com/ClickHouse/ClickHouse/pull/79907) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Speedup queries with trivial count optimization. [#79945](https://github.com/ClickHouse/ClickHouse/pull/79945) ([Raúl Marín](https://github.com/Algunenano)). +* Introduced a happy path in `UniqExactSet::merge` when one of the sets is empty. Also, now if the LHS set is two-level and the RHS is single-level, we won't do the conversion to two-level for the RHS. [#79971](https://github.com/ClickHouse/ClickHouse/pull/79971) ([Nikita Taranov](https://github.com/nickitat)). +* Add `__attribute__((always_inline))` to `convertDecimalsImpl`. [#79999](https://github.com/ClickHouse/ClickHouse/pull/79999) ([Konstantin Bogdanov](https://github.com/thevar1able)). +* Set `input_format_parquet_bloom_filter_push_down` to true by default. Also, fix a mistake in the settings changes history. [#80058](https://github.com/ClickHouse/ClickHouse/pull/80058) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +#* Make logging asynchronous by default. You can disable this by setting `false` under ``. [#80125](https://github.com/ClickHouse/ClickHouse/pull/80125) ([Raúl Marín](https://github.com/Algunenano)). +* Improve memory reuse efficiency and reduce page faults when using the two-level hash tables. [#80245](https://github.com/ClickHouse/ClickHouse/pull/80245) ([Jiebin Sun](https://github.com/jiebinn)). +* Avoid unnecessary update and reduce lock contention in QueryConditionCache. [#80247](https://github.com/ClickHouse/ClickHouse/pull/80247) ([Jiebin Sun](https://github.com/jiebinn)). +* Small optimization of `concatenateBlocks`, which could be good for parallel Hash join. [#80328](https://github.com/ClickHouse/ClickHouse/pull/80328) ([李扬](https://github.com/taiyang-li)). +* When selecting mark ranges from the primary key range, binary search cannot be used if the primary key is wrapped with functions. This PR improves this limitation: binary search can still be applied when the primary key is wrapped with an always monotonic function chain, or when the RPN contains an element that is always true. This PR closes [#45536](https://github.com/ClickHouse/ClickHouse/issues/45536). [#80597](https://github.com/ClickHouse/ClickHouse/pull/80597) ([zoomxi](https://github.com/zoomxi)). +* Improve the shutdown speed of Kafka engine (remove an extra 3 seconds delay in case of multiple Kafka tables). [#80796](https://github.com/ClickHouse/ClickHouse/pull/80796) ([Azat Khuzhin](https://github.com/azat)). +* Reduce memory usage of async inserts and improve the performance of insert queries. [#80972](https://github.com/ClickHouse/ClickHouse/pull/80972) ([Raúl Marín](https://github.com/Algunenano)). +* Don't profile processors if the log table is disabled. [#81256](https://github.com/ClickHouse/ClickHouse/pull/81256) ([Raúl Marín](https://github.com/Algunenano)). +* Speed up `toFixedString` when the source is exactly what's requested. [#81257](https://github.com/ClickHouse/ClickHouse/pull/81257) ([Raúl Marín](https://github.com/Algunenano)). +* Don't process quota values if the user is not limited. [#81549](https://github.com/ClickHouse/ClickHouse/pull/81549) ([Raúl Marín](https://github.com/Algunenano)). +* Make ProcfsMetricsProvider thread_local to keep files open between tasks. [#81576](https://github.com/ClickHouse/ClickHouse/pull/81576) ([Raúl Marín](https://github.com/Algunenano)). +* Fixed performance regression in memory tracking. [#81694](https://github.com/ClickHouse/ClickHouse/pull/81694) ([Michael Kolupaev](https://github.com/al13n321)). + +## Improvement {#improvement} + +#* `clickhouse-local` will retain its databases after restart if you specify the `--path` command line argument. This closes [#50647](https://github.com/ClickHouse/ClickHouse/issues/50647). This closes [#49947](https://github.com/ClickHouse/ClickHouse/issues/49947). [#71722](https://github.com/ClickHouse/ClickHouse/pull/71722) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* `EXPLAIN SYNTAX` now uses a new analyzer. It returns an abstract syntax tree (AST) built from the query tree. Added option `query_tree_passes` to control the number of passes to be executed before converting the query tree to the AST. [#74536](https://github.com/ClickHouse/ClickHouse/pull/74536) ([Vladimir Cherkasov](https://github.com/vdimir)). +#* Use SLRU cache policy in filesystem cache by default. [#75072](https://github.com/ClickHouse/ClickHouse/pull/75072) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Refactored the logic of pushing to views. [#77309](https://github.com/ClickHouse/ClickHouse/pull/77309) ([Sema Checherinda](https://github.com/CheSema)). +* Object storage cluster table functions (e.g. `s3Cluster`) will now assign files to replicas for reading based on consistent hash to improve cache locality. [#77326](https://github.com/ClickHouse/ClickHouse/pull/77326) ([Andrej Hoos](https://github.com/adikus)). +* Refresh S3 credentials after error `AuthenticationRequired`. [#77353](https://github.com/ClickHouse/ClickHouse/pull/77353) ([Vitaly Baranov](https://github.com/vitlibar)). +* Embed proxy configuration in some HTTP buffers with the help of builders. [#77693](https://github.com/ClickHouse/ClickHouse/pull/77693) ([Arthur Passos](https://github.com/arthurpassos)). +* Added dictionary metrics to `system.asynchronous_metrics` - `DictionaryMaxUpdateDelay` - The maximum delay(in seconds) of dictionary update. - `DictionaryTotalFailedUpdates` - Number of errors since last successful loading in all dictionaries. [#78175](https://github.com/ClickHouse/ClickHouse/pull/78175) ([Vlad](https://github.com/codeworse)). +* Add functions `divideOrNull`,`moduloOrNull`, `intDivOrNull`,`positiveModuloOrNull` to return NULL when right argument is zero. [#78276](https://github.com/ClickHouse/ClickHouse/pull/78276) ([kevinyhzou](https://github.com/KevinyhZou)). +* Extend the `isIPAddressInRange` function to String, IPv4, IPv6, Nullable(String) Nullable(IPv4) and Nullable(IPv6) data types. [#78364](https://github.com/ClickHouse/ClickHouse/pull/78364) ([YjyJeff](https://github.com/YjyJeff)). +* Change PostgreSQL engine connection pooler settings dynamically. [#78414](https://github.com/ClickHouse/ClickHouse/pull/78414) ([Samay Sharma](https://github.com/samay-sharma)). +* Allow to specify `_part_offset` in a normal projection. This is the first step to build a projection index. It can be used with [#58224](https://github.com/ClickHouse/ClickHouse/issues/58224) and can help improve https://github.com/ClickHouse/ClickHouse/pull/63207. [#78429](https://github.com/ClickHouse/ClickHouse/pull/78429) ([Amos Bird](https://github.com/amosbird)). +* Improve the sharding key optimization on distributed queries. [#78452](https://github.com/ClickHouse/ClickHouse/pull/78452) ([fhw12345](https://github.com/fhw12345)). +* Add new columns(`create_query` and `source`) for `system.named_collections`. Closes [#78179](https://github.com/ClickHouse/ClickHouse/issues/78179). [#78582](https://github.com/ClickHouse/ClickHouse/pull/78582) ([MikhailBurdukov](https://github.com/MikhailBurdukov)). +* Added field `condition` to system table `system.query_condition_cache`. It stores the plaintext condition whose hash is used as a key in the query condition cache. [#78671](https://github.com/ClickHouse/ClickHouse/pull/78671) ([Robert Schulze](https://github.com/rschu1ze)). +* Implement Kafka re-balance like logic for StorageKafka2 using ClickHouse Keeper. For each replica we support two types of partition locks: permanent locks and temporary locks. The replica tries to hold permanent locks as long as possible, at any given time there are no more than `all_topic_partitions / active_replicas_count` (here `all_topic_partitions` is the number of all partitions, `active_replicas_count` is the number of active replicas) permanent locks on the replica, if there are more, then the replica releases some partitions. Some partitions are temporarily held by the replica. The maximum number of temporary locks on a replica changes dynamically to give other replicas a chance to take some partitions into permanent locks. When updating temporary locks, the replica releases them all and tries to take some others again. [#78726](https://github.com/ClickHouse/ClickHouse/pull/78726) ([Daria Fomina](https://github.com/sinfillo)). +* Add table settings for SASL configuration and credentials to the `Kafka` table engine. This allows configuring SASL-based authentication to Kafka and Kafka-compatible systems directly in the `CREATE TABLE` statement rather than having to use configuration files or named collections. [#78810](https://github.com/ClickHouse/ClickHouse/pull/78810) ([Christoph Wurm](https://github.com/cwurm)). +* Add a warning about databases that were potentially created to save broken tables. [#78841](https://github.com/ClickHouse/ClickHouse/pull/78841) ([János Benjamin Antal](https://github.com/antaljanosbenjamin)). +* Vector similarity indexes can now be created on top of `BFloat16` columns. [#78850](https://github.com/ClickHouse/ClickHouse/pull/78850) ([Robert Schulze](https://github.com/rschu1ze)). +* Support unix timestamps with a fractional part in best-effort DateTime64 parsing. [#78908](https://github.com/ClickHouse/ClickHouse/pull/78908) ([Pavel Kruglov](https://github.com/Avogar)). +* In storage DeltaLake delta-kernel implementation fix for columnMappingMode.name, add tests for schema evolution. [#78921](https://github.com/ClickHouse/ClickHouse/pull/78921) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Improve insert into Variant column in Values format by better conversion of values. [#78923](https://github.com/ClickHouse/ClickHouse/pull/78923) ([Pavel Kruglov](https://github.com/Avogar)). +* Add `_time` virtual column in `S3Queue` engine. [#78926](https://github.com/ClickHouse/ClickHouse/pull/78926) ([Anton Ivashkin](https://github.com/ianton-ru)). +* The `tokens` function was extended to accept an additional "tokenizer" argument plus further tokenizer-specific arguments. [#79001](https://github.com/ClickHouse/ClickHouse/pull/79001) ([Elmi Ahmadov](https://github.com/ahmadov)). +* The `SHOW CLUSTER` statement now expands macros (if any) in its argument. [#79006](https://github.com/ClickHouse/ClickHouse/pull/79006) ([arf42](https://github.com/arf42)). +* Hash functions now support `NULL`s inside arrays, tuples, and maps. (issues [#48365](https://github.com/ClickHouse/ClickHouse/issues/48365) and [#48623](https://github.com/ClickHouse/ClickHouse/issues/48623)). [#79008](https://github.com/ClickHouse/ClickHouse/pull/79008) ([Michael Kolupaev](https://github.com/al13n321)). +* Support for a refresh in read-only MergeTree tables. [#79033](https://github.com/ClickHouse/ClickHouse/pull/79033) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +#* Update cctz to 2025a. [#79043](https://github.com/ClickHouse/ClickHouse/pull/79043) ([Raúl Marín](https://github.com/Algunenano)). +* Make settings controlling connection drop on overloaded CPU hot-reloadable. [#79052](https://github.com/ClickHouse/ClickHouse/pull/79052) ([Alexey Katsman](https://github.com/alexkats)). +* It's better for usability. [#79066](https://github.com/ClickHouse/ClickHouse/pull/79066) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Enable the query condition cache by default. [#79080](https://github.com/ClickHouse/ClickHouse/pull/79080) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +#* Make tabs undo-able in the Web UI. This closes [#71284](https://github.com/ClickHouse/ClickHouse/issues/71284). [#79084](https://github.com/ClickHouse/ClickHouse/pull/79084) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Remove settings during `recoverLostReplica` the same as was done in https://github.com/ClickHouse/ClickHouse/pull/78637. [#79113](https://github.com/ClickHouse/ClickHouse/pull/79113) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)). +* Add ProfileEvents ParquetReadRowGroups and ParquetPrunedRowGroups to profile parquet index prune. [#79180](https://github.com/ClickHouse/ClickHouse/pull/79180) ([flynn](https://github.com/ucasfl)). +* Add container prefix to data paths reported in system.tables for plain disks in Azure blob storage, making reporting consistent with S3 and GCP. [#79241](https://github.com/ClickHouse/ClickHouse/pull/79241) ([Julia Kartseva](https://github.com/jkartseva)). +* Support altering a database on cluster. [#79242](https://github.com/ClickHouse/ClickHouse/pull/79242) ([Tuan Pham Anh](https://github.com/tuanpach)). +* Explicitly skip missed runs of statistics collection for QueryMetricLog, otherwise the log will take a long time to catch up with the current time. [#79257](https://github.com/ClickHouse/ClickHouse/pull/79257) ([Mikhail Artemenko](https://github.com/Michicosun)). +* Added an ability to apply lightweight deletes on the fly (with settings `lightweight_deletes_sync = 0`, `apply_mutations_on_fly = 1`. [#79281](https://github.com/ClickHouse/ClickHouse/pull/79281) ([Anton Popov](https://github.com/CurtizJ)). +* Optimized `ALTER ... DELETE` mutations for parts in which all rows should be deleted. Now, in such cases an empty part is created instead of original without executing a mutation. [#79307](https://github.com/ClickHouse/ClickHouse/pull/79307) ([Anton Popov](https://github.com/CurtizJ)). +* Some small optimizations to `CHColumnToArrowColumn`. [#79308](https://github.com/ClickHouse/ClickHouse/pull/79308) ([Bharat Nallan](https://github.com/bharatnc)). +* The setting `allow_archive_path_syntax` was marked as experimental by mistake. Add a test to prevent having experimental settings enabled by default. [#79320](https://github.com/ClickHouse/ClickHouse/pull/79320) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Made page cache settings adjustable on a per-query level. This is needed for faster experimentation and for the possibility of fine-tuning for high-throughput and low-latency queries. [#79337](https://github.com/ClickHouse/ClickHouse/pull/79337) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Do not print number tips in pretty formats for numbers that look like most of the 64-bit hashes. This closes [#79334](https://github.com/ClickHouse/ClickHouse/issues/79334). [#79338](https://github.com/ClickHouse/ClickHouse/pull/79338) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* If data in the pretty format is displayed in the terminal, and a subsequent block has the same column widths, it can continue from the previous block, glue it to the previous block by moving the cursor up. This closes [#79333](https://github.com/ClickHouse/ClickHouse/issues/79333). The feature is controlled by the new setting, `output_format_pretty_glue_chunks`. [#79339](https://github.com/ClickHouse/ClickHouse/pull/79339) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Colors of graphs on the advanced dashboards will be calculated from the hash of the corresponding query. This makes it easier to remember and locate a graph while scrolling the dashboard. [#79341](https://github.com/ClickHouse/ClickHouse/pull/79341) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Add asynchronous metric, `FilesystemCacheCapacity` - total capacity in the `cache` virtual filesystem. This is useful for global infrastructure monitoring. [#79348](https://github.com/ClickHouse/ClickHouse/pull/79348) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Optimize access to system.parts (read columns/indexes size only when requested). [#79352](https://github.com/ClickHouse/ClickHouse/pull/79352) ([Azat Khuzhin](https://github.com/azat)). +* Select important fields for query `'SHOW CLUSTER '` instead of all fields. [#79368](https://github.com/ClickHouse/ClickHouse/pull/79368) ([Tuan Pham Anh](https://github.com/tuanpach)). +* Allow to specify storage settings for `DatabaseCatalog`. [#79407](https://github.com/ClickHouse/ClickHouse/pull/79407) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Support local storage in delta kernel. [#79416](https://github.com/ClickHouse/ClickHouse/pull/79416) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Add a query level setting to enable delta-kernel-rs: `allow_experimental_delta_kernel_rs`. [#79418](https://github.com/ClickHouse/ClickHouse/pull/79418) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Fix possible endless loop when listing blobs from Azure/S3 blob storage. [#79425](https://github.com/ClickHouse/ClickHouse/pull/79425) ([Alexander Gololobov](https://github.com/davenger)). +* Now, ClickHouse also accepts query parameters as `param-` (dash) along with `param_` (underscore). This closes [#63093](https://github.com/ClickHouse/ClickHouse/issues/63093). [#79429](https://github.com/ClickHouse/ClickHouse/pull/79429) ([Engel Danila](https://github.com/aaaengel)). +#* Add filesystem cache setting `max_size_ratio_to_total_space`. [#79460](https://github.com/ClickHouse/ClickHouse/pull/79460) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Detailed warning msg for bandwidth discount when copying data from local to remote S3 with checksum enabled. [#79464](https://github.com/ClickHouse/ClickHouse/pull/79464) ([VicoWu](https://github.com/VicoWu)). +* For `clickhouse-benchmark` reconfigure `reconnect` option to take 0, 1 or N as values for reconnecting accordingly. [#79465](https://github.com/ClickHouse/ClickHouse/pull/79465) ([Sachin Kumar Singh](https://github.com/sachinkumarsingh092)). +* Add setting `input_format_max_block_size_bytes` to limit blocks created in input formats in bytes. It can help to avoid high memory usage during data import when rows contains large values. [#79495](https://github.com/ClickHouse/ClickHouse/pull/79495) ([Pavel Kruglov](https://github.com/Avogar)). +* Enhance sparseGrams speed and memory usage. [#79517](https://github.com/ClickHouse/ClickHouse/pull/79517) ([Konstantin Vedernikov](https://github.com/scanhex12)). +* Avoid extra copying of the block during insertion into Compact part when possible. [#79536](https://github.com/ClickHouse/ClickHouse/pull/79536) ([Pavel Kruglov](https://github.com/Avogar)). +* Enable `DeltaLake` storage delta-kernel implementation by default. [#79541](https://github.com/ClickHouse/ClickHouse/pull/79541) ([Kseniia Sumarokova](https://github.com/kssenii)). +* If reading from an URL involves multiple redirects, setting `enable_url_encoding` is correctly applied across all redirects in the chain. [#79563](https://github.com/ClickHouse/ClickHouse/pull/79563) ([Shankar Iyer](https://github.com/shankar-iyer)). +* Allow `ALTER TABLE ... MOVE|REPLACE PARTITION` for tables on different plain_rewritable disks. [#79566](https://github.com/ClickHouse/ClickHouse/pull/79566) ([Julia Kartseva](https://github.com/jkartseva)). +* Support scalar correlated subqueries in the `WHERE` clause. Closes [#6697](https://github.com/ClickHouse/ClickHouse/issues/6697). [#79600](https://github.com/ClickHouse/ClickHouse/pull/79600) ([Dmitry Novik](https://github.com/novikd)). +* Previously when `input_format_parquet_max_block_size = 0` ClickHouse would stuck. Now this behaviour is fixed. This closes [#79394](https://github.com/ClickHouse/ClickHouse/issues/79394). [#79601](https://github.com/ClickHouse/ClickHouse/pull/79601) ([abashkeev](https://github.com/abashkeev)). +* Add `throw_on_error` setting for startup_scripts: when `throw_on_error` is true, the server will not start unless all queries complete successfully. By default, `throw_on_error` is false, preserving the previous behavior. [#79732](https://github.com/ClickHouse/ClickHouse/pull/79732) ([Aleksandr Musorin](https://github.com/AVMusorin)). +* The vector similarity index is now also used if the reference vector is of type `Array(BFloat16)`. [#79745](https://github.com/ClickHouse/ClickHouse/pull/79745) ([Shankar Iyer](https://github.com/shankar-iyer)). +* Add `last_error_message`, `last_error_trace` and `query_id` to the `system.error_log` table. Related ticket [#75816](https://github.com/ClickHouse/ClickHouse/issues/75816). [#79836](https://github.com/ClickHouse/ClickHouse/pull/79836) ([Andrei Tinikov](https://github.com/Dolso)). +#* Enable sending crash reports by default. This can be turned off in the server's configuration file. [#79838](https://github.com/ClickHouse/ClickHouse/pull/79838) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* System table `system.functions` now shows in which ClickHouse version functions were first introduced. [#79839](https://github.com/ClickHouse/ClickHouse/pull/79839) ([Robert Schulze](https://github.com/rschu1ze)). +* Added `access_control_improvements.enable_user_name_access_type` setting. This setting allows enabling/disabling of precise grants for users/roles, introduced in https://github.com/ClickHouse/ClickHouse/pull/72246. You may want to turn this setting off in case you have a cluster with the replicas older than 25.1. [#79842](https://github.com/ClickHouse/ClickHouse/pull/79842) ([pufit](https://github.com/pufit)). +* Proper implementation of `ASTSelectWithUnionQuery::clone()` method now takes into account `is_normalized` field as well. This might help with [#77569](https://github.com/ClickHouse/ClickHouse/issues/77569). [#79909](https://github.com/ClickHouse/ClickHouse/pull/79909) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)). +* Support correlated subqueries in the projection list in simple cases. [#79925](https://github.com/ClickHouse/ClickHouse/pull/79925) ([Dmitry Novik](https://github.com/novikd)). +* Fix the inconsistent formatting of certain queries with the `EXCEPT` operator. If the left-hand side of the EXCEPT operator ends with `*`, the formatted query loses parentheses and is then parsed as a `*` with the `EXCEPT` modifier. These queries are found by the fuzzer and are unlikely to be found in practice. This closes [#79950](https://github.com/ClickHouse/ClickHouse/issues/79950). [#79952](https://github.com/ClickHouse/ClickHouse/pull/79952) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Allow to add `http_response_headers` in `http_handlers` of any kind. [#79975](https://github.com/ClickHouse/ClickHouse/pull/79975) ([Andrey Zvonov](https://github.com/zvonand)). +* Small improvement in JSON type parsing by using cache of variants deserialization order. [#79984](https://github.com/ClickHouse/ClickHouse/pull/79984) ([Pavel Kruglov](https://github.com/Avogar)). +* Allow moving `GLOBAL [NOT] IN` predicate to `PREWHERE` clause if applicable. [#79996](https://github.com/ClickHouse/ClickHouse/pull/79996) ([Eduard Karacharov](https://github.com/korowa)). +* Add setting `s3_slow_all_threads_after_network_error`. [#80035](https://github.com/ClickHouse/ClickHouse/pull/80035) ([Vitaly Baranov](https://github.com/vitlibar)). +* The logging level about the selected parts to merge was wrong (Information). Closes [#80061](https://github.com/ClickHouse/ClickHouse/issues/80061). [#80062](https://github.com/ClickHouse/ClickHouse/pull/80062) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Function reverse support Tuple data type. Closes [#80053](https://github.com/ClickHouse/ClickHouse/issues/80053). [#80083](https://github.com/ClickHouse/ClickHouse/pull/80083) ([flynn](https://github.com/ucasfl)). +* Setting `enble_url_encoding` default value is now set to `False`. [#80088](https://github.com/ClickHouse/ClickHouse/pull/80088) ([Shankar Iyer](https://github.com/shankar-iyer)). +* This tiny patch resolves [#75817](https://github.com/ClickHouse/ClickHouse/issues/75817): allows get `auxiliary_zookeepers` data from `system.zookeeper` table. [#80146](https://github.com/ClickHouse/ClickHouse/pull/80146) ([Nikolay Govorov](https://github.com/mrdimidium)). +* Vector search using the vector similarity index is now beta (previously experimental). [#80164](https://github.com/ClickHouse/ClickHouse/pull/80164) ([Robert Schulze](https://github.com/rschu1ze)). +* Add asynchronous metrics about the server's TCP sockets. This improves the observability. Closes [#80187](https://github.com/ClickHouse/ClickHouse/issues/80187). [#80188](https://github.com/ClickHouse/ClickHouse/pull/80188) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Function `tokens` now supports `string` as a tokenizer. [#80195](https://github.com/ClickHouse/ClickHouse/pull/80195) ([Robert Schulze](https://github.com/rschu1ze)). +* Parallel replicas: avoid waiting for slow unused replicas if all read tasks have been assigned to other replicas. [#80199](https://github.com/ClickHouse/ClickHouse/pull/80199) ([Igor Nikonov](https://github.com/devcrafter)). +* Support `anylast_respect_nulls` and `any_respect_nulls` in `simpleAggregateFunction`. [#80219](https://github.com/ClickHouse/ClickHouse/pull/80219) ([Diskein](https://github.com/Diskein)). +* Remove unnecessary call `adjustCreateQueryForBackup()` for replicated databases. [#80282](https://github.com/ClickHouse/ClickHouse/pull/80282) ([Vitaly Baranov](https://github.com/vitlibar)). +#* Allow extra options (that go after `--` like `-- --config.value='abc'`) in `clickhouse-local` without the equality sign. Closes [#80292](https://github.com/ClickHouse/ClickHouse/issues/80292). [#80293](https://github.com/ClickHouse/ClickHouse/pull/80293) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Highlight metacharacters in `SHOW ... LIKE` queries. This closes [#80275](https://github.com/ClickHouse/ClickHouse/issues/80275). [#80297](https://github.com/ClickHouse/ClickHouse/pull/80297) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +#* Make SQL UDF persistent in `clickhouse-local`. The previously created function will be loaded at startup. This closes [#80085](https://github.com/ClickHouse/ClickHouse/issues/80085). [#80300](https://github.com/ClickHouse/ClickHouse/pull/80300) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Support comparison between `Time`/`Time64`. [#80327](https://github.com/ClickHouse/ClickHouse/pull/80327) ([Yarik Briukhovetskyi](https://github.com/yariks5s)). +* Fix description in explain plan for a preliminary distinct step. [#80330](https://github.com/ClickHouse/ClickHouse/pull/80330) ([UnamedRus](https://github.com/UnamedRus)). +* Allow use of named collections in ODBC/JDBC. [#80334](https://github.com/ClickHouse/ClickHouse/pull/80334) ([Andrey Zvonov](https://github.com/zvonand)). +* Enable multiple-projection filtering support, allowing to use more than one projection for part-level filtering. This addresses [#55525](https://github.com/ClickHouse/ClickHouse/issues/55525). This is the second step to implement projection index, following [#78429](https://github.com/ClickHouse/ClickHouse/issues/78429). [#80343](https://github.com/ClickHouse/ClickHouse/pull/80343) ([Amos Bird](https://github.com/amosbird)). +* Metrics for the number of readonly and broken disks. Indicator logs when DiskLocalCheckThread is started. [#80391](https://github.com/ClickHouse/ClickHouse/pull/80391) ([VicoWu](https://github.com/VicoWu)). +* Implement support for `s3_plain_rewritable` storage with projections. In previous versions, metadata objects in S3 referencing projections would not get updated when moved. Closes [#70258](https://github.com/ClickHouse/ClickHouse/issues/70258). [#80393](https://github.com/ClickHouse/ClickHouse/pull/80393) ([Sav](https://github.com/sberss)). +* Parallel replicas uses separate connection timeout, see `parallel_replicas_connect_timeout_ms` setting. Before `connect_timeout_with_failover_ms`/`connect_timeout_with_failover_secure_ms` settings were used as connection timeout values for parallel replicas queries (1 second by default). [#80421](https://github.com/ClickHouse/ClickHouse/pull/80421) ([Igor Nikonov](https://github.com/devcrafter)). +* The `SYSTEM UNFREEZE` command will not try to look up parts in readonly and write-once disks. This closes [#80430](https://github.com/ClickHouse/ClickHouse/issues/80430). [#80432](https://github.com/ClickHouse/ClickHouse/pull/80432) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Changed log level of a merged parts message from INFO to TRACE. [#80476](https://github.com/ClickHouse/ClickHouse/pull/80476) ([Hans Krutzer](https://github.com/hkrutzer)). +* Implement flattened serialization for Dynamic and JSON in Native format that allows to serialize/deserialize Dynamic and JSON data without special structures like shared variant for Dynamic and shared data for JSON. This serialization can be enabled by setting `output_format_native_use_flattened_dynamic_and_json_serialization`. This serialization can be used for easier support for Dynamic and JSON in TCP protocol in clients in different languages. [#80499](https://github.com/ClickHouse/ClickHouse/pull/80499) ([Pavel Kruglov](https://github.com/Avogar)). +* Changes the default behavior of partition pruning for Iceberg table. [#80583](https://github.com/ClickHouse/ClickHouse/pull/80583) ([Melvyn Peignon](https://github.com/melvynator)). +* Add two new ProfileEvents for index search algorithm observability: `IndexBinarySearchAlgorithm` and `IndexGenericExclusionSearchAlgorithm`. [#80679](https://github.com/ClickHouse/ClickHouse/pull/80679) ([Pablo Marcos](https://github.com/pamarcos)). +* Do not complain about unsupported `MADV_POPULATE_WRITE` for older kernels in logs (to avoid logs polluting). [#80704](https://github.com/ClickHouse/ClickHouse/pull/80704) ([Robert Schulze](https://github.com/rschu1ze)). +* Added support for Date32, DateTime64 in TTL. [#80710](https://github.com/ClickHouse/ClickHouse/pull/80710) ([Andrey Zvonov](https://github.com/zvonand)). +* Adjust compatibility values for `max_merge_delayed_streams_for_parallel_write`. [#80760](https://github.com/ClickHouse/ClickHouse/pull/80760) ([Azat Khuzhin](https://github.com/azat)). +* Fix a crash: if an exception is thrown in an attempt to remove a temporary file (they are used for spilling temporary data on disk) in the destructor, the program can terminate. [#80776](https://github.com/ClickHouse/ClickHouse/pull/80776) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Add `IF EXISTS` modifier to `SYSTEM SYNC REPLICA`. [#80810](https://github.com/ClickHouse/ClickHouse/pull/80810) ([Raúl Marín](https://github.com/Algunenano)). +* Extend the exception message about "Having zero bytes, but read range is not finished...", add finished_download_time column to system.filesystem_cache'. [#80849](https://github.com/ClickHouse/ClickHouse/pull/80849) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Previously, `packed` storage was not supported for the full-text index, because the segment id was updated on-fly by reading and writing (`.gin_sid`) file on disk. In case of packed storage, reading a value from the uncommited file is not supported and this led to an issue. [#80852](https://github.com/ClickHouse/ClickHouse/pull/80852) ([Elmi Ahmadov](https://github.com/ahmadov)). +* Add a search algorithm section to `EXPLAIN` output when using it with `indexes = 1`. It shows either "binary search" or "generic exclusion search". [#80881](https://github.com/ClickHouse/ClickHouse/pull/80881) ([Pablo Marcos](https://github.com/pamarcos)). +* At the beginning of 2024, `prefer_column_name_to_alias` was hardcoded to True for MySQL handler because the new analyzer was not enabled by default. Now, it has been unhardcoded. [#80916](https://github.com/ClickHouse/ClickHouse/pull/80916) ([Yarik Briukhovetskyi](https://github.com/yariks5s)). +* Now `system.iceberg_history` shows history for catalogs databases like glue or iceberg rest. Also renamed `table_name` and `database_name` columns to `table` and `database` in `system.iceberg_history` for consistency. [#80975](https://github.com/ClickHouse/ClickHouse/pull/80975) ([alesapin](https://github.com/alesapin)). +* Allow read-only mode for the `merge` table function, so the `CREATE TEMPORARY TABLE` grant is not required for using it. [#80981](https://github.com/ClickHouse/ClickHouse/pull/80981) ([Miсhael Stetsyuk](https://github.com/mstetsyuk)). +* Better introspection of in-memory caches (expose information about caches in `system.metrics` over incomplete `system.asynchronouse_metrics`). Add in-memory caches size (in bytes) into `dashboard.html`. `VectorSimilarityIndexCacheSize`/`IcebergMetadataFilesCacheSize` has been renamed to `VectorSimilarityIndexCacheBytes`/`IcebergMetadataFilesCacheBytes`. [#81023](https://github.com/ClickHouse/ClickHouse/pull/81023) ([Azat Khuzhin](https://github.com/azat)). +* Ignore databases with engines that can't contain RocksDB tables while reading from system.rocksdb. [#81083](https://github.com/ClickHouse/ClickHouse/pull/81083) ([Pervakov Grigorii](https://github.com/GrigoryPervakov)). +* Allow `filesystem_caches` and `named_collections` in the `clickhouse-local` configuration file. [#81105](https://github.com/ClickHouse/ClickHouse/pull/81105) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Fix highlighting of `PARTITION BY` in `INSERT` queries. In previous versions, `PARTITION BY` was not highlighted as a keyword. [#81106](https://github.com/ClickHouse/ClickHouse/pull/81106) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +#* Two mini improvements in Web UI: correctly handle queries without output, such as `CREATE`, `INSERT` (until recently, these queries resulted in an infinite spinner); - when double clicking on a table, scroll to the top. [#81131](https://github.com/ClickHouse/ClickHouse/pull/81131) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +#* Update `c-ares` to `v1.34.5`. [#81159](https://github.com/ClickHouse/ClickHouse/pull/81159) ([Konstantin Bogdanov](https://github.com/thevar1able)). +#* Upgrade curl to 8.14 to address CVE-2025-5025 and CVE-2025-4947. [#81171](https://github.com/ClickHouse/ClickHouse/pull/81171) ([larryluogit](https://github.com/larryluogit)). +#* Upgrade libarchive to 3.7.9 to address: CVE-2024-20696 CVE-2025-25724 CVE-2024-48958 CVE-2024-57970 CVE-2025-1632 CVE-2024-48957 CVE-2024-48615. [#81174](https://github.com/ClickHouse/ClickHouse/pull/81174) ([larryluogit](https://github.com/larryluogit)). +#* Upgrade libxml2 to 2.14.3. [#81187](https://github.com/ClickHouse/ClickHouse/pull/81187) ([larryluogit](https://github.com/larryluogit)). +* `MemoryResidentWithoutPageCache` provides the amount of physical memory used by the server process, excluding userspace page cache, in bytes. This provides a more accurate view of actual memory usage when userspace page cache is utilized. When userspace page cache is disabled, this value equals MemoryResident. [#81233](https://github.com/ClickHouse/ClickHouse/pull/81233) ([Jayme Bird](https://github.com/jaymebrd)). +* Mark manually logged exceptions in client, local server, keeper client and disks app as logged, so that they are not logged twice. [#81271](https://github.com/ClickHouse/ClickHouse/pull/81271) ([Miсhael Stetsyuk](https://github.com/mstetsyuk)). +* Setting `use_skip_indexes_if_final` and `use_skip_indexes_if_final_exact_mode` now default to `True`. Queries with `FINAL` clause will now use skip indexes (if applicable) to shortlist granules and also read any additional granules corresponding to matching primary key ranges. Users needing earlier behaviour of approximate/imprecise results can set `use_skip_indexes_if_final_exact_mode` to FALSE after careful evaluation. [#81331](https://github.com/ClickHouse/ClickHouse/pull/81331) ([Shankar Iyer](https://github.com/shankar-iyer)). +#* When you have multiple queries in the web UI, it will run the one under the cursor. Continuation of [#80977](https://github.com/ClickHouse/ClickHouse/issues/80977). [#81354](https://github.com/ClickHouse/ClickHouse/pull/81354) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* This PR addresses issues with the implementation of `is_strict` in the monotonicity checks for conversion functions. Currently, some conversion functions, such as toFloat64(UInt32) and toDate(UInt8), incorrectly return is_strict as false when they should return true. [#81359](https://github.com/ClickHouse/ClickHouse/pull/81359) ([zoomxi](https://github.com/zoomxi)). +#* In filesystem with journal `mkdir` is written to the journal of filesystem which is persisted to disk. In case of slow disk this can take long time. Definitely make sense to move out from reserve lock scope. [#81371](https://github.com/ClickHouse/ClickHouse/pull/81371) ([Kseniia Sumarokova](https://github.com/kssenii)). +* When checking if a `KeyCondition` matches a continuous range, if the key is wrapped with a non-strict function chain, a `Constraint::POINT` may needs to be converted to a`Constraint::RANGE`. For example: `toDate(event_time) = '2025-06-03'` implies a range for `event_time`: ['2025-06-03 00:00:00', '2025-06-04 00:00:00'). This PR fixes this behavior. [#81400](https://github.com/ClickHouse/ClickHouse/pull/81400) ([zoomxi](https://github.com/zoomxi)). +#* Use `postgres` 16.9. [#81437](https://github.com/ClickHouse/ClickHouse/pull/81437) ([Konstantin Bogdanov](https://github.com/thevar1able)). +#* Use `openssl` 3.2.4. [#81438](https://github.com/ClickHouse/ClickHouse/pull/81438) ([Konstantin Bogdanov](https://github.com/thevar1able)). +#* Use `abseil-cpp` 2025-01-27. [#81440](https://github.com/ClickHouse/ClickHouse/pull/81440) ([Konstantin Bogdanov](https://github.com/thevar1able)). +#* Use `mongo-c-driver` 1.30.4. [#81449](https://github.com/ClickHouse/ClickHouse/pull/81449) ([Konstantin Bogdanov](https://github.com/thevar1able)). +#* Use `krb5` 1.21.3-final. [#81453](https://github.com/ClickHouse/ClickHouse/pull/81453) ([Konstantin Bogdanov](https://github.com/thevar1able)). +#* Use `orc` 2.1.2. [#81455](https://github.com/ClickHouse/ClickHouse/pull/81455) ([Konstantin Bogdanov](https://github.com/thevar1able)). +#* Add support for the `--database` argument in `clickhouse-local`. You can switch to a previously created database. This closes [#44115](https://github.com/ClickHouse/ClickHouse/issues/44115). [#81465](https://github.com/ClickHouse/ClickHouse/pull/81465) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +#* `clickhouse`/`ch` aliases will invoke `clickhouse-client` instead of `clickhouse-local` if `--host` or `--port` are specified. Continuation of [#79422](https://github.com/ClickHouse/ClickHouse/issues/79422). Closes [#65252](https://github.com/ClickHouse/ClickHouse/issues/65252). [#81509](https://github.com/ClickHouse/ClickHouse/pull/81509) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Now that we have the keeper response time distribution data, we can tune the histogram buckets. [#81516](https://github.com/ClickHouse/ClickHouse/pull/81516) ([Miсhael Stetsyuk](https://github.com/mstetsyuk)). +* Postpone reading of Iceberg manifest files until the first reading of a query. [#81619](https://github.com/ClickHouse/ClickHouse/pull/81619) ([Daniil Ivanik](https://github.com/divanik)). +#* Use `grpc` 1.73.0. [#81629](https://github.com/ClickHouse/ClickHouse/pull/81629) ([Konstantin Bogdanov](https://github.com/thevar1able)). +#* Use `delta-kernel-rs` v0.12.1. [#81707](https://github.com/ClickHouse/ClickHouse/pull/81707) ([Konstantin Bogdanov](https://github.com/thevar1able)). +* Add profile event `PageCacheReadBytes`. [#81742](https://github.com/ClickHouse/ClickHouse/pull/81742) ([Kseniia Sumarokova](https://github.com/kssenii)). + +## Bug fix (user-visible misbehavior in an official stable release) {#bug-fix-user-visible-misbehavior-in-an-official-stable-release} + +* Fix parameterized view with `SELECT EXCEPT` query. Closes [#49447](https://github.com/ClickHouse/ClickHouse/issues/49447). [#57380](https://github.com/ClickHouse/ClickHouse/pull/57380) ([Nikolay Degterinsky](https://github.com/evillique)). +* Analyzer: fix column projection name after column type promotion in join. Closes [#63345](https://github.com/ClickHouse/ClickHouse/issues/63345). [#63519](https://github.com/ClickHouse/ClickHouse/pull/63519) ([Dmitry Novik](https://github.com/novikd)). +* A materialized view can start too late, e.g. after the Kafka table that streams to it. [#72123](https://github.com/ClickHouse/ClickHouse/pull/72123) ([Ilya Golshtein](https://github.com/ilejn)). +* Fixed a logical error in cases of column name clashes when analyzer_compatibility_join_using_top_level_identifier is enabled. [#75676](https://github.com/ClickHouse/ClickHouse/pull/75676) ([Vladimir Cherkasov](https://github.com/vdimir)). +* Fixed rare crashes while reading from `MergeTree` table after multiple asynchronous (with `alter_sync = 0`) `RENAME COLUMN` and `ADD COLUMN` queries. [#76346](https://github.com/ClickHouse/ClickHouse/pull/76346) ([Anton Popov](https://github.com/CurtizJ)). +* Fix `SELECT` query rewriting during `VIEW` creation with enabled analyzer. closes [#75956](https://github.com/ClickHouse/ClickHouse/issues/75956). [#76356](https://github.com/ClickHouse/ClickHouse/pull/76356) ([Dmitry Novik](https://github.com/novikd)). +* Fix CTE usage in pushed-down predicates when `allow_push_predicate_ast_for_distributed_subqueries` is enabled. Fixes [#75647](https://github.com/ClickHouse/ClickHouse/issues/75647). Fixes [#79672](https://github.com/ClickHouse/ClickHouse/issues/79672). [#77316](https://github.com/ClickHouse/ClickHouse/pull/77316) ([Dmitry Novik](https://github.com/novikd)). +* Fix applying `async_insert` from server (via `apply_settings_from_server`) (previously leads to `Unknown packet 11 from server` errors on the client). [#77578](https://github.com/ClickHouse/ClickHouse/pull/77578) ([Azat Khuzhin](https://github.com/azat)). +* Fixed refreshable materialized view in replicated databases not working on newly added replicas. [#77774](https://github.com/ClickHouse/ClickHouse/pull/77774) ([Michael Kolupaev](https://github.com/al13n321)). +* Fixed refreshable materialized views breaking backups. [#77893](https://github.com/ClickHouse/ClickHouse/pull/77893) ([Michael Kolupaev](https://github.com/al13n321)). +* Fix old firing logical error for `transform`. [#78247](https://github.com/ClickHouse/ClickHouse/pull/78247) ([Yarik Briukhovetskyi](https://github.com/yariks5s)). +* Fixes an issue where `SYSTEM SYNC REPLICA LIGHTWEIGHT 'foo'` would report success even when the specified replica didn't exist. The command now properly validates that the replica exists in Keeper before attempting synchronization. [#78405](https://github.com/ClickHouse/ClickHouse/pull/78405) ([Jayme Bird](https://github.com/jaymebrd)). +* Fix some cases where secondary index was not applied with analyzer. Fixes [#65607](https://github.com/ClickHouse/ClickHouse/issues/65607) , fixes [#69373](https://github.com/ClickHouse/ClickHouse/issues/69373). [#78485](https://github.com/ClickHouse/ClickHouse/pull/78485) ([Nikolai Kochetov](https://github.com/KochetovNicolai)). +* Fix dumping profile events (`NetworkSendElapsedMicroseconds`/`NetworkSendBytes`) for HTTP protocol with compression enabled (the error should not be more then the buffer size, usually around 1MiB). [#78516](https://github.com/ClickHouse/ClickHouse/pull/78516) ([Azat Khuzhin](https://github.com/azat)). +#* ```sql CREATE TABLE t0 ( key Int32, value Int32 ) ENGINE=MergeTree() PRIMARY KEY key PARTITION BY key % 2;. [#78593](https://github.com/ClickHouse/ClickHouse/pull/78593) ([Vlad](https://github.com/codeworse)). +* Fix analyzer producing `LOGICAL_ERROR` when `JOIN ... USING` involves `ALIAS` column - should produce an appropriate error. [#78618](https://github.com/ClickHouse/ClickHouse/pull/78618) ([Yakov Olkhovskiy](https://github.com/yakov-olkhovskiy)). +* Fix analyzer: `CREATE VIEW ... ON CLUSTER` fails if SELECT contains positional arguments. [#78663](https://github.com/ClickHouse/ClickHouse/pull/78663) ([Yakov Olkhovskiy](https://github.com/yakov-olkhovskiy)). +* Fix `Block structure mismatch` error in case of `INSERT SELECT` into table a function with schema inference if `SELECT` has scalar subqueries. [#78677](https://github.com/ClickHouse/ClickHouse/pull/78677) ([Pervakov Grigorii](https://github.com/GrigoryPervakov)). +* Fix analyzer: with `prefer_global_in_and_join=1` for Distributed table in SELECT query `in` function should be replaced by `globalIn`. [#78749](https://github.com/ClickHouse/ClickHouse/pull/78749) ([Yakov Olkhovskiy](https://github.com/yakov-olkhovskiy)). +* Fixed several types of `SELECT` queries that read from tables with `MongoDB` engine or `mongodb` table function: queries with implicit conversion of const value in `WHERE` clause (e.g. `WHERE datetime = '2025-03-10 00:00:00'`) ; queries with `LIMIT` and `GROUP BY`. Previously, they could return the wrong result. [#78777](https://github.com/ClickHouse/ClickHouse/pull/78777) ([Anton Popov](https://github.com/CurtizJ)). +* Fix conversion between different JSON types. Now it's performed by simple cast through convertion to/from String. It's less effective but 100% accurate. [#78807](https://github.com/ClickHouse/ClickHouse/pull/78807) ([Pavel Kruglov](https://github.com/Avogar)). +* Fix logical error during convertion of Dynamic type to Interval. [#78813](https://github.com/ClickHouse/ClickHouse/pull/78813) ([Pavel Kruglov](https://github.com/Avogar)). +* Fix column rollback on JSON parsing error. [#78836](https://github.com/ClickHouse/ClickHouse/pull/78836) ([Pavel Kruglov](https://github.com/Avogar)). +* Fix 'bad cast' error when join using constant alias column. [#78848](https://github.com/ClickHouse/ClickHouse/pull/78848) ([Vladimir Cherkasov](https://github.com/vdimir)). +* Don't allow `PREWHERE` in materialized views on columns with different types in view and target table. [#78889](https://github.com/ClickHouse/ClickHouse/pull/78889) ([Pavel Kruglov](https://github.com/Avogar)). +* Fix logical error during parsing of bad binary data of Variant column. [#78982](https://github.com/ClickHouse/ClickHouse/pull/78982) ([Pavel Kruglov](https://github.com/Avogar)). +* Throw an exception when the parquet batch size is set to 0. Previously when `output_format_parquet_batch_size = 0` ClickHouse would hang. Now this behavior is fixed. [#78991](https://github.com/ClickHouse/ClickHouse/pull/78991) ([daryawessely](https://github.com/daryawessely)). +* Fix deserialization of variant discriminators with basic format in compact parts. It was introduced in https://github.com/ClickHouse/ClickHouse/pull/55518. [#79000](https://github.com/ClickHouse/ClickHouse/pull/79000) ([Pavel Kruglov](https://github.com/Avogar)). +* Dictionaries of type `complex_key_ssd_cache` now reject zero or negative `block_size` and `write_buffer_size` parameters (issue [#78314](https://github.com/ClickHouse/ClickHouse/issues/78314)). [#79028](https://github.com/ClickHouse/ClickHouse/pull/79028) ([Elmi Ahmadov](https://github.com/ahmadov)). +* Avoid using Field for non-aggregated columns in SummingMergeTree. It could lead to unexpected errors with Dynamic/Variant types used in SummingMergeTree. [#79051](https://github.com/ClickHouse/ClickHouse/pull/79051) ([Pavel Kruglov](https://github.com/Avogar)). +* Fix read from materialized view with distributed destination table and different header in analyzer. [#79059](https://github.com/ClickHouse/ClickHouse/pull/79059) ([Pavel Kruglov](https://github.com/Avogar)). +* Fix crash for a very specific situation when the `currentDatabase` function was used in `CONSTRAINT` sections for `ON CLUSTER` queries Closes [#78100](https://github.com/ClickHouse/ClickHouse/issues/78100). [#79070](https://github.com/ClickHouse/ClickHouse/pull/79070) ([pufit](https://github.com/pufit)). +* Fixes a bug where `arrayUnion()` returned extra (incorrect) values on tables that had batch inserts. Fixes [#75057](https://github.com/ClickHouse/ClickHouse/issues/75057). [#79079](https://github.com/ClickHouse/ClickHouse/pull/79079) ([Peter Nguyen](https://github.com/petern48)). +#* Fix segfault in `OpenSSLInitializer`. Closes [#79092](https://github.com/ClickHouse/ClickHouse/issues/79092). [#79097](https://github.com/ClickHouse/ClickHouse/pull/79097) ([Konstantin Bogdanov](https://github.com/thevar1able)). +* Fix passing of external roles in inter-server queries. [#79099](https://github.com/ClickHouse/ClickHouse/pull/79099) ([Andrey Zvonov](https://github.com/zvonand)). +* Always set prefix for S3 ListObject. [#79114](https://github.com/ClickHouse/ClickHouse/pull/79114) ([Azat Khuzhin](https://github.com/azat)). +* Fixes a bug where `arrayUnion()` returned extra (incorrect) values on tables that had batch inserts. Fixes [#79157](https://github.com/ClickHouse/ClickHouse/issues/79157). [#79158](https://github.com/ClickHouse/ClickHouse/pull/79158) ([Peter Nguyen](https://github.com/petern48)). +* Fix logical error after filter pushdown. [#79164](https://github.com/ClickHouse/ClickHouse/pull/79164) ([Pervakov Grigorii](https://github.com/GrigoryPervakov)). +* Try to use IColumn instead of Field in SingleValueDataGeneric. It fixes the incorrect return values for some aggregate functions like `argMax` for types `Dynamic/Variant/JSON`. [#79166](https://github.com/ClickHouse/ClickHouse/pull/79166) ([Pavel Kruglov](https://github.com/Avogar)). +* Fix DeltaLake table engine with delta-kernel implementation being used with http based endpoints, fix NOSIGN. Closes [#78124](https://github.com/ClickHouse/ClickHouse/issues/78124). [#79203](https://github.com/ClickHouse/ClickHouse/pull/79203) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Keeper fix: Avoid triggering watches on failed multi requests. [#79247](https://github.com/ClickHouse/ClickHouse/pull/79247) ([Antonio Andelic](https://github.com/antonio2368)). +* Forbid Dynamic and JSON types in IN. With current implementation of `IN` it can lead to incorrect results. Proper support of this types in `IN` is complicated and can be done in future. [#79282](https://github.com/ClickHouse/ClickHouse/pull/79282) ([Pavel Kruglov](https://github.com/Avogar)). +* Fix check for duplicate paths in JSON type parsing. [#79317](https://github.com/ClickHouse/ClickHouse/pull/79317) ([Pavel Kruglov](https://github.com/Avogar)). +* Fix SecureStreamSocket connection issues. [#79383](https://github.com/ClickHouse/ClickHouse/pull/79383) ([Konstantin Bogdanov](https://github.com/thevar1able)). +* Fix loading of plain_rewritable disks containing data. [#79439](https://github.com/ClickHouse/ClickHouse/pull/79439) ([Julia Kartseva](https://github.com/jkartseva)). +* Fix crash in dynamic subcolumns discovery in Wide parts in MergeTree. [#79466](https://github.com/ClickHouse/ClickHouse/pull/79466) ([Pavel Kruglov](https://github.com/Avogar)). +* Verify the table name's length only for initial create queries. Do not verify this for secondary creates to avoid backward compatibility issues. [#79488](https://github.com/ClickHouse/ClickHouse/pull/79488) ([Miсhael Stetsyuk](https://github.com/mstetsyuk)). +* Fixed error `Block structure mismatch` in several cases with tables with sparse columns. [#79491](https://github.com/ClickHouse/ClickHouse/pull/79491) ([Anton Popov](https://github.com/CurtizJ)). +* Fixes two cases of `Logical Error: Can't set alias of * of Asterisk on alias`. [#79505](https://github.com/ClickHouse/ClickHouse/pull/79505) ([Raúl Marín](https://github.com/Algunenano)). +* Fix applying use_native_copy and allow_azure_native_copy setting for azure blob storage and updated to use native copy only when credentials match resolves [#78964](https://github.com/ClickHouse/ClickHouse/issues/78964). [#79561](https://github.com/ClickHouse/ClickHouse/pull/79561) ([Smita Kulkarni](https://github.com/SmitaRKulkarni)). +* Fix using incorrect paths when renaming an Atomic database. [#79569](https://github.com/ClickHouse/ClickHouse/pull/79569) ([Tuan Pham Anh](https://github.com/tuanpach)). +* Fix order by JSON column with other columns. [#79591](https://github.com/ClickHouse/ClickHouse/pull/79591) ([Pavel Kruglov](https://github.com/Avogar)). +* Fix result duplication when reading from remote with both `use_hedged_requests` and `allow_experimental_parallel_reading_from_replicas` disabled. [#79599](https://github.com/ClickHouse/ClickHouse/pull/79599) ([Eduard Karacharov](https://github.com/korowa)). +* Fix crash in delta-kernel implementation when using unity catalog. [#79677](https://github.com/ClickHouse/ClickHouse/pull/79677) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Resolve macros for autodiscovery clusters. [#79696](https://github.com/ClickHouse/ClickHouse/pull/79696) ([Anton Ivashkin](https://github.com/ianton-ru)). +* Fix logical errors about a column's unknown origin scope produced while checking if this column is correlated. Fixes [#78183](https://github.com/ClickHouse/ClickHouse/issues/78183). Fixes [#79451](https://github.com/ClickHouse/ClickHouse/issues/79451). [#79727](https://github.com/ClickHouse/ClickHouse/pull/79727) ([Dmitry Novik](https://github.com/novikd)). +* Fix wrong results for grouping sets with ColumnConst and Analyzer. [#79743](https://github.com/ClickHouse/ClickHouse/pull/79743) ([Andrey Zvonov](https://github.com/zvonand)). +* Fix local shard result duplication when reading from distributed table with local replica being stale. [#79761](https://github.com/ClickHouse/ClickHouse/pull/79761) ([Eduard Karacharov](https://github.com/korowa)). +* Handle incorrectly configured `page_cache_limits` suitably. [#79805](https://github.com/ClickHouse/ClickHouse/pull/79805) ([Bharat Nallan](https://github.com/bharatnc)). +* Fixes the result of SQL function `formatDateTime` if a variable-size formatter (e.g. `%W` aka. weekday `Monday` `Tuesday`, etc.) is followed by a compound formatter (a formatter that prints multiple components at once, e.g. `%D` aka. the American date `05/04/25`). [#79835](https://github.com/ClickHouse/ClickHouse/pull/79835) ([Robert Schulze](https://github.com/rschu1ze)). +* IcebergS3 supports count optimization, but IcebergS3Cluster does not. As a result, the count() result returned in cluster mode may be a multiple of the number of replicas. [#79844](https://github.com/ClickHouse/ClickHouse/pull/79844) ([wxybear](https://github.com/wxybear)). +* Fix the sorting order of the NaNs with a negative sign bit. [#79847](https://github.com/ClickHouse/ClickHouse/pull/79847) ([Pervakov Grigorii](https://github.com/GrigoryPervakov)). +* Now `GROUP BY ALL` doesn't take into account the `GROUPING` part. [#79915](https://github.com/ClickHouse/ClickHouse/pull/79915) ([Yarik Briukhovetskyi](https://github.com/yariks5s)). +* Fixes `AMBIGUOUS_COLUMN_NAME` error with lazy materialization when no columns are used for query execution until projection. Example, SELECT * FROM t ORDER BY rand() LIMIT 5. [#79926](https://github.com/ClickHouse/ClickHouse/pull/79926) ([Igor Nikonov](https://github.com/devcrafter)). +* Fixed incorrect state merging for `TopK` / `TopKWeighted` functions that would cause excessive error values even when capacity was not exhausted. [#79939](https://github.com/ClickHouse/ClickHouse/pull/79939) ([Joel Höner](https://github.com/athre0z)). +* Hide password for query `CREATE DATABASE datalake ENGINE = DataLakeCatalog(\'http://catalog:8181\', \'admin\', \'password\')`. [#79941](https://github.com/ClickHouse/ClickHouse/pull/79941) ([Han Fei](https://github.com/hanfei1991)). +* Allow specifying an alias in `JOIN USING`. Specify this alias in case the column was renamed (e.g., because of `ARRAY JOIN). Fixes [#73707](https://github.com/ClickHouse/ClickHouse/issues/73707). [#79942](https://github.com/ClickHouse/ClickHouse/pull/79942) ([Nikolai Kochetov](https://github.com/KochetovNicolai)). +* Respect `readonly` setting in `azure_blob_storage` object storage. [#79954](https://github.com/ClickHouse/ClickHouse/pull/79954) ([Julia Kartseva](https://github.com/jkartseva)). +* Fixed incorrect query results and out-of-memory crashes when using `match(column, '^…')` with backslash-escaped characters. [#79969](https://github.com/ClickHouse/ClickHouse/pull/79969) ([filimonov](https://github.com/filimonov)). +* Disabling hive partitioning for datalakes Partially addresses https://github.com/issues/assigned?issue=ClickHouse%7CClickHouse%7C79937. [#80005](https://github.com/ClickHouse/ClickHouse/pull/80005) ([Daniil Ivanik](https://github.com/divanik)). +* Skip indexes with lambda expressions could not be applied. Fix the case when high-level functions in the index definition exactly match the one in the query. [#80025](https://github.com/ClickHouse/ClickHouse/pull/80025) ([Nikolai Kochetov](https://github.com/KochetovNicolai)). +* Allow materialized views with UNIONs to work correctly on new replicas. [#80037](https://github.com/ClickHouse/ClickHouse/pull/80037) ([Samay Sharma](https://github.com/samay-sharma)). +* Fix metadata version during attach part on the replica executing ATTACH_PART command from replication log. [#80038](https://github.com/ClickHouse/ClickHouse/pull/80038) ([Aleksei Filatov](https://github.com/aalexfvk)). +* Format specifier `%e` in SQL function `parseDateTime` now recognizes single-digit days (e.g. `3`), whereas it previously required space padding (e.g. ` 3`). This makes its behavior compatible with MySQL. To retain the previous behaviour, set setting `parsedatetime_e_requires_space_padding = 1`. (issue [#78243](https://github.com/ClickHouse/ClickHouse/issues/78243)). [#80057](https://github.com/ClickHouse/ClickHouse/pull/80057) ([Robert Schulze](https://github.com/rschu1ze)). +* Executable User Defined Functions (eUDF) names are not added to the `used_functions` column of the `system.query_log` table, unlike other functions. This PR implements the addition of the eUDF name if the eUDF was used in the request. [#80073](https://github.com/ClickHouse/ClickHouse/pull/80073) ([Kyamran](https://github.com/nibblerenush)). +#* Fix warnings `Cannot find 'kernel' in '[...]/memory.stat'` in ClickHouse's log (issue [#77410](https://github.com/ClickHouse/ClickHouse/issues/77410)). [#80129](https://github.com/ClickHouse/ClickHouse/pull/80129) ([Robert Schulze](https://github.com/rschu1ze)). +* Fix logical error in Arrow format with LowCardinality(FixedString). [#80156](https://github.com/ClickHouse/ClickHouse/pull/80156) ([Pavel Kruglov](https://github.com/Avogar)). +* Fix reading subcolumns from Merge engine. [#80158](https://github.com/ClickHouse/ClickHouse/pull/80158) ([Pavel Kruglov](https://github.com/Avogar)). +* Fix a bug about the comparison between numeric types in `KeyCondition`. [#80207](https://github.com/ClickHouse/ClickHouse/pull/80207) ([Yarik Briukhovetskyi](https://github.com/yariks5s)). +* Fix AMBIGUOUS_COLUMN_NAME when lazy materialization applied to table with projections. [#80251](https://github.com/ClickHouse/ClickHouse/pull/80251) ([Igor Nikonov](https://github.com/devcrafter)). +* Fix incorrect count optimization for string prefix filters like LIKE 'ab_c%' when using implicit projections. This fixes [#80250](https://github.com/ClickHouse/ClickHouse/issues/80250). [#80261](https://github.com/ClickHouse/ClickHouse/pull/80261) ([Amos Bird](https://github.com/amosbird)). +* Fix improper serialization of nested numeric fields as strings in MongoDB documents. Remove maximum depth limit for documents from MongoDB. [#80289](https://github.com/ClickHouse/ClickHouse/pull/80289) ([Kirill Nikiforov](https://github.com/allmazz)). +* Perform less strict metadata checks for RMT in the Replicated database. Closes [#80296](https://github.com/ClickHouse/ClickHouse/issues/80296). [#80298](https://github.com/ClickHouse/ClickHouse/pull/80298) ([Nikolay Degterinsky](https://github.com/evillique)). +* Fix text representation of DateTime and DateTime64 for PostgreSQL storage. [#80301](https://github.com/ClickHouse/ClickHouse/pull/80301) ([Yakov Olkhovskiy](https://github.com/yakov-olkhovskiy)). +* Allow `DateTime` with timezone in `StripeLog` tables. This closes [#44120](https://github.com/ClickHouse/ClickHouse/issues/44120). [#80304](https://github.com/ClickHouse/ClickHouse/pull/80304) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Disable filter-push-down for the predicate with a non-deterministic function in case the query plan step changes the number of rows. Fixes [#40273](https://github.com/ClickHouse/ClickHouse/issues/40273). [#80329](https://github.com/ClickHouse/ClickHouse/pull/80329) ([Nikolai Kochetov](https://github.com/KochetovNicolai)). +* Fix possible logical errors and crashes in projections with subcolumns. [#80333](https://github.com/ClickHouse/ClickHouse/pull/80333) ([Pavel Kruglov](https://github.com/Avogar)). +* Fix `NOT_FOUND_COLUMN_IN_BLOCK` error caused by filter-push-down optimization of the logical JOIN sep in case `ON` expression is not a trivial equality. Fixes [#79647](https://github.com/ClickHouse/ClickHouse/issues/79647) Fixes [#77848](https://github.com/ClickHouse/ClickHouse/issues/77848). [#80360](https://github.com/ClickHouse/ClickHouse/pull/80360) ([Nikolai Kochetov](https://github.com/KochetovNicolai)). +* Fix incorrect results when reading reverse-ordered keys in partitioned tables. This fixes [#79987](https://github.com/ClickHouse/ClickHouse/issues/79987). [#80448](https://github.com/ClickHouse/ClickHouse/pull/80448) ([Amos Bird](https://github.com/amosbird)). +* Fixed wrong sorting in tables with a nullable key and enabled optimize_read_in_order. [#80515](https://github.com/ClickHouse/ClickHouse/pull/80515) ([Pervakov Grigorii](https://github.com/GrigoryPervakov)). +* Fixed refreshable materialized view DROP getting stuck if the view was paused using SYSTEM STOP REPLICATED VIEW. [#80543](https://github.com/ClickHouse/ClickHouse/pull/80543) ([Michael Kolupaev](https://github.com/al13n321)). +* Fix 'Cannot find column' with constant tuple in distributed query. [#80596](https://github.com/ClickHouse/ClickHouse/pull/80596) ([Yakov Olkhovskiy](https://github.com/yakov-olkhovskiy)). +* Fix `shardNum` function in Distributed tables with `join_use_nulls`. [#80612](https://github.com/ClickHouse/ClickHouse/pull/80612) ([János Benjamin Antal](https://github.com/antaljanosbenjamin)). +* Fix incorrect results during reading column that exists in subset of tables in Merge engine. [#80643](https://github.com/ClickHouse/ClickHouse/pull/80643) ([Pavel Kruglov](https://github.com/Avogar)). +* The timestamp in the iceberg_history table should now be correct. [#80711](https://github.com/ClickHouse/ClickHouse/pull/80711) ([Melvyn Peignon](https://github.com/melvynator)). +* Fix handling of enum globs of a single element in object storage table functions. [#80716](https://github.com/ClickHouse/ClickHouse/pull/80716) ([Konstantin Bogdanov](https://github.com/thevar1able)). +* Fix wrong result types of comparison functions with Tuple(Dynamic) and String that led to logical error. [#80728](https://github.com/ClickHouse/ClickHouse/pull/80728) ([Pavel Kruglov](https://github.com/Avogar)). +* Add missing support data type `timestamp_ntz` for unity catalog. Fixes [#79535](https://github.com/ClickHouse/ClickHouse/issues/79535), Fixes [#79875](https://github.com/ClickHouse/ClickHouse/issues/79875). [#80740](https://github.com/ClickHouse/ClickHouse/pull/80740) ([alesapin](https://github.com/alesapin)). +* Fix `THERE_IS_NO_COLUMN` error for distributed queries with `IN cte`. Fixes [#75032](https://github.com/ClickHouse/ClickHouse/issues/75032). [#80757](https://github.com/ClickHouse/ClickHouse/pull/80757) ([Nikolai Kochetov](https://github.com/KochetovNicolai)). +* Fix excessive number of files (leads to excessive memory usage) for external `ORDER BY`. [#80777](https://github.com/ClickHouse/ClickHouse/pull/80777) ([Azat Khuzhin](https://github.com/azat)). +#* This PR might close [#80742](https://github.com/ClickHouse/ClickHouse/issues/80742). [#80783](https://github.com/ClickHouse/ClickHouse/pull/80783) ([zoomxi](https://github.com/zoomxi)). +#* Fix crash in Kafka due to get_member_id() was creating std::string from NULL (it was likely an issue only in case of connection to broker had been failed). [#80793](https://github.com/ClickHouse/ClickHouse/pull/80793) ([Azat Khuzhin](https://github.com/azat)). +* Properly await consumers before shutting down Kafka engine (active consumers after shutdown can trigger various debug assertions and also may read data from brokers in background after table has been dropped/detached). [#80795](https://github.com/ClickHouse/ClickHouse/pull/80795) ([Azat Khuzhin](https://github.com/azat)). +* Fix `NOT_FOUND_COLUMN_IN_BLOCK`, which is caused by `predicate-push-down` optimization. Fixes [#80443](https://github.com/ClickHouse/ClickHouse/issues/80443). [#80834](https://github.com/ClickHouse/ClickHouse/pull/80834) ([Nikolai Kochetov](https://github.com/KochetovNicolai)). +* Fix logical error when resolving star (*) matcher in table function in `JOIN` with `USING`. [#80894](https://github.com/ClickHouse/ClickHouse/pull/80894) ([Vladimir Cherkasov](https://github.com/vdimir)). +* Fix memory accounting for Iceberg metadata files cache. [#80904](https://github.com/ClickHouse/ClickHouse/pull/80904) ([Azat Khuzhin](https://github.com/azat)). +* Fix wrong partitioning with nullable partition key. [#80913](https://github.com/ClickHouse/ClickHouse/pull/80913) ([Pervakov Grigorii](https://github.com/GrigoryPervakov)). +* Fix `Table does not exist` error for distributed queries with pushed-down predicate (`allow_push_predicate_ast_for_distributed_subqueries=1`) when the source table does not exist on the initialtor. Fixes [#77281](https://github.com/ClickHouse/ClickHouse/issues/77281). [#80915](https://github.com/ClickHouse/ClickHouse/pull/80915) ([Nikolai Kochetov](https://github.com/KochetovNicolai)). +* Fix the logical error in the nested functions with named windows. [#80926](https://github.com/ClickHouse/ClickHouse/pull/80926) ([Pervakov Grigorii](https://github.com/GrigoryPervakov)). +* Fix extremes for nullable and floating-point columns. [#80970](https://github.com/ClickHouse/ClickHouse/pull/80970) ([Pervakov Grigorii](https://github.com/GrigoryPervakov)). +* Fix possible crash while querying from system.tables (likely the case under memory pressure). [#80976](https://github.com/ClickHouse/ClickHouse/pull/80976) ([Azat Khuzhin](https://github.com/azat)). +* Fix atomic rename with truncate for files which compression is inferred from their file extension. [#80979](https://github.com/ClickHouse/ClickHouse/pull/80979) ([Pablo Marcos](https://github.com/pamarcos)). +#* Fix ErrorCodes::getName. [#81032](https://github.com/ClickHouse/ClickHouse/pull/81032) ([RinChanNOW](https://github.com/RinChanNOWWW)). +* Fix bug when user cannot list tables in Unity Catalog without permissions for all of them. Now all tables are listed properly, attempt to read from restricted table will throw an exception. [#81044](https://github.com/ClickHouse/ClickHouse/pull/81044) ([alesapin](https://github.com/alesapin)). +* Now ClickHouse will ignore errors and unexpected responses from data lake catalogs in `SHOW TABLES` query. Fixes [#79725](https://github.com/ClickHouse/ClickHouse/issues/79725). [#81046](https://github.com/ClickHouse/ClickHouse/pull/81046) ([alesapin](https://github.com/alesapin)). +* Fix parsing of `DateTime64` from integers in `JSONExtract` and `JSON` type parsing. [#81050](https://github.com/ClickHouse/ClickHouse/pull/81050) ([Pavel Kruglov](https://github.com/Avogar)). +* Reflect `date_time_input_format` setting in schema inference cache. [#81052](https://github.com/ClickHouse/ClickHouse/pull/81052) ([Pavel Kruglov](https://github.com/Avogar)). +* Fix crash on `INSERT` if table was DROPed after query started but before columns sent. [#81053](https://github.com/ClickHouse/ClickHouse/pull/81053) ([Azat Khuzhin](https://github.com/azat)). +* Fix use-of-uninitialized-value in quantileDeterministic. [#81062](https://github.com/ClickHouse/ClickHouse/pull/81062) ([Azat Khuzhin](https://github.com/azat)). +* Fix hardlinks count management for metadatastoragefromdisk disk transactions. add tests. [#81066](https://github.com/ClickHouse/ClickHouse/pull/81066) ([Sema Checherinda](https://github.com/CheSema)). +* User Defined Functions (UDF) names are not added to the `system.query_log` table, unlike other functions. This PR implements the addition of the UDF name to one of the two columns `used_executable_user_defined_functions` or `used_sql_user_defined_functions` if the UDF was used in the request. [#81101](https://github.com/ClickHouse/ClickHouse/pull/81101) ([Kyamran](https://github.com/nibblerenush)). +* Fixed `Too large size ... passed to allocator` errors or possible crashes on inserts via http protocol with text formats (`JSON`, `Values`, ...) and omitted `Enum` fields. [#81145](https://github.com/ClickHouse/ClickHouse/pull/81145) ([Anton Popov](https://github.com/CurtizJ)). +* Fix LOGICAL_ERROR in case of Sparse column in INSERT block pushed to non-MT MV. [#81161](https://github.com/ClickHouse/ClickHouse/pull/81161) ([Azat Khuzhin](https://github.com/azat)). +* Fix `Unknown table expression identifier` for `distributed_product_mode_local=local` with cross-replication. [#81162](https://github.com/ClickHouse/ClickHouse/pull/81162) ([Nikolai Kochetov](https://github.com/KochetovNicolai)). +* Fixed incorrectly caching number of rows in parquet files after filtering. [#81184](https://github.com/ClickHouse/ClickHouse/pull/81184) ([Michael Kolupaev](https://github.com/al13n321)). +* Fix fs cache `max_size_to_total_space` setting when used with relative cache path. [#81237](https://github.com/ClickHouse/ClickHouse/pull/81237) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Fixed clickhouse-local crashing when outputting const tuples or maps in Parquet format. [#81249](https://github.com/ClickHouse/ClickHouse/pull/81249) ([Michael Kolupaev](https://github.com/al13n321)). +* Verify array offsets received over network. [#81269](https://github.com/ClickHouse/ClickHouse/pull/81269) ([Azat Khuzhin](https://github.com/azat)). +* Fix some corner case in query that joins empty tables and uses window functions. The bug leads to exploding number of parallel streams which leads to OOMs. [#81299](https://github.com/ClickHouse/ClickHouse/pull/81299) ([Alexander Gololobov](https://github.com/davenger)). +* Fixes for datalake Cluster functions (`deltaLakeCluster`, `icebergCluster`, etc): (1) fix potential segfault in `DataLakeConfiguration` when using `Cluster` function with old analyzer; (2) remove duplicating data lake metadata updates (extra object storage requests); (3) fix redundant listing in object storage when format is not explicitly specified (which was already done for non-cluster data lake engines). [#81300](https://github.com/ClickHouse/ClickHouse/pull/81300) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Make `force_restore_data` flag recover lost keeper metadata. [#81324](https://github.com/ClickHouse/ClickHouse/pull/81324) ([Raúl Marín](https://github.com/Algunenano)). +* Fix region error in delta-kernel. Fixes [#79914](https://github.com/ClickHouse/ClickHouse/issues/79914). [#81353](https://github.com/ClickHouse/ClickHouse/pull/81353) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Disable incorrect JIT for divideOrNull. [#81370](https://github.com/ClickHouse/ClickHouse/pull/81370) ([Raúl Marín](https://github.com/Algunenano)). +* Fix insert error when MergeTree table has a long partition column name. [#81390](https://github.com/ClickHouse/ClickHouse/pull/81390) ([hy123q](https://github.com/haoyangqian)). +* Don't store content of several manifest files in memory. [#81470](https://github.com/ClickHouse/ClickHouse/pull/81470) ([Daniil Ivanik](https://github.com/divanik)). +* Fix possible crash during shutting down background pools (`background_.*pool_size`). [#81473](https://github.com/ClickHouse/ClickHouse/pull/81473) ([Azat Khuzhin](https://github.com/azat)). +* Fix out-of-bounds read in the `Npy` format happening when writing to a table with the `URL` engine. This closes [#81356](https://github.com/ClickHouse/ClickHouse/issues/81356). [#81502](https://github.com/ClickHouse/ClickHouse/pull/81502) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* There is a chance that Web UI displays `NaN%` (typical JavaScript problems). [#81507](https://github.com/ClickHouse/ClickHouse/pull/81507) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Fix `DatabaseReplicated` for `database_replicated_enforce_synchronous_settings=1`. [#81564](https://github.com/ClickHouse/ClickHouse/pull/81564) ([Azat Khuzhin](https://github.com/azat)). +* Fix sorting order for LowCardinality(Nullable(...)) types. [#81583](https://github.com/ClickHouse/ClickHouse/pull/81583) ([Pervakov Grigorii](https://github.com/GrigoryPervakov)). +* Server should not preserve a HTTP connection if the request has not been fully read from the socket. [#81595](https://github.com/ClickHouse/ClickHouse/pull/81595) ([Sema Checherinda](https://github.com/CheSema)). +* Make scalar correlated subqueries return a nullable result of the projection expression. Fix the case when a correlated subquery produces an empty result set. [#81632](https://github.com/ClickHouse/ClickHouse/pull/81632) ([Dmitry Novik](https://github.com/novikd)). +* Fix `Unexpected relative path for a deduplicated part` during `ATTACH` to `ReplicatedMergeTree`. [#81647](https://github.com/ClickHouse/ClickHouse/pull/81647) ([Azat Khuzhin](https://github.com/azat)). +* Query settings `use_iceberg_partition_pruning` will not take effect for iceberg storage, because it uses global context rather than query context. it's not critical because its default value is true. this pr can fix it. [#81673](https://github.com/ClickHouse/ClickHouse/pull/81673) ([Han Fei](https://github.com/hanfei1991)). +* Add validation for merge tree setting `merge_max_block_size` to ensure that it's non zero. [#81693](https://github.com/ClickHouse/ClickHouse/pull/81693) ([Bharat Nallan](https://github.com/bharatnc)). +* Fix issues with `clickhouse-local` involving stuck `DROP VIEW ` queries. [#81705](https://github.com/ClickHouse/ClickHouse/pull/81705) ([Bharat Nallan](https://github.com/bharatnc)). +* Fix StorageRedis join in some cases. [#81736](https://github.com/ClickHouse/ClickHouse/pull/81736) ([Pervakov Grigorii](https://github.com/GrigoryPervakov)). +* Fix crash in `ConcurrentHashJoin` with empty `USING ()` and old analyzer enabled. [#81754](https://github.com/ClickHouse/ClickHouse/pull/81754) ([Nikita Taranov](https://github.com/nickitat)). +* Keeper fix: block commits of new logs if there is invalid entry in the logs. Previously, if the leader applied some logs incorrectly, it would continue to commit new logs, even though the follower would detect digest mismatch and abort. [#81780](https://github.com/ClickHouse/ClickHouse/pull/81780) ([Antonio Andelic](https://github.com/antonio2368)). \ No newline at end of file diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/01_changelog/02_release_notes/_category_.json b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/01_changelog/02_release_notes/_category_.json new file mode 100644 index 00000000000..4eeae460788 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/01_changelog/02_release_notes/_category_.json @@ -0,0 +1,6 @@ +{ + "label": "Release notes", + "collapsible": true, + "collapsed": true, + "link": { "type": "doc", "id": "cloud/reference/changelog/release_notes/index" } +} \ No newline at end of file diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/01_changelog/02_release_notes/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/01_changelog/02_release_notes/index.md new file mode 100644 index 00000000000..b147678fe10 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/01_changelog/02_release_notes/index.md @@ -0,0 +1,25 @@ +--- +slug: /cloud/reference/changelogs/release-notes +title: 'Cloud Release Notes' +description: 'Landing page for Cloud release notes' +doc_type: 'changelog' +--- + + + + +| Page | Description | +|-----|-----| +| [v25.6 Changelog for Cloud](/changelogs/25.6) | Fast release changelog for v25.6 | +| [v25.4 Changelog for Cloud](/changelogs/25.4) | Fast release changelog for v25.4 | +| [v24.12 Changelog for Cloud](/changelogs/24.12) | Fast release changelog for v24.12 | +| [v24.10 Changelog for Cloud](/changelogs/24.10) | Fast release changelog for v24.10 | +| [v24.8 Changelog for Cloud](/changelogs/24.8) | Fast release changelog for v24.8 | +| [v24.6 Changelog for Cloud](/changelogs/24.6) | Fast release changelog for v24.6 | +| [v24.5 Changelog for Cloud](/changelogs/24.5) | Fast release changelog for v24.5 | +| [v24.2 Changelog](/whats-new/changelog/24.2-fast-release) | Fast release changelog for v24.2 | +| [Cloud Changelog](/whats-new/cloud) | ClickHouse Cloud changelog providing descriptions of what is new in each ClickHouse Cloud release | + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/01_changelog/_category_.json b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/01_changelog/_category_.json new file mode 100644 index 00000000000..60a9e95ee7e --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/01_changelog/_category_.json @@ -0,0 +1,6 @@ +{ + "label": "Change logs", + "collapsible": true, + "collapsed": true, + "link": { "type": "doc", "id": "cloud/reference/changelog/index" } +} \ No newline at end of file diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/01_changelog/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/01_changelog/index.md new file mode 100644 index 00000000000..179a4235988 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/01_changelog/index.md @@ -0,0 +1,11 @@ +--- +slug: /cloud/reference/changelogs +title: 'Changelogs' +description: 'Landing page for Cloud changelogs' +doc_type: 'landing-page' +--- + +| Page | Description | +|---------------------------------------------------------------|-------------------------------------------------| +| [Cloud Changelog](/whats-new/cloud) | Changelog for ClickHouse Cloud | +| [Release Notes](/cloud/reference/changelogs/release-notes) | Release notes for all ClickHouse Cloud releases | \ No newline at end of file diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/02_architecture.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/02_architecture.md new file mode 100644 index 00000000000..613ce34876e --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/02_architecture.md @@ -0,0 +1,55 @@ +--- +'sidebar_label': '架构' +'slug': '/cloud/reference/architecture' +'title': 'ClickHouse Cloud 架构' +'description': '本页面描述了 ClickHouse Cloud 的架构' +'doc_type': 'reference' +--- + +import Architecture from '@site/static/images/cloud/reference/architecture.svg'; + + +# ClickHouse Cloud 架构 + + + +## 由对象存储支持的存储 {#storage-backed-by-object-store} +- 几乎无限的存储 +- 无需手动共享数据 +- 存储数据的成本显著降低,特别是对于访问频率较低的数据 + +## 计算 {#compute} +- 自动扩展和闲置:无需前期预估规模,也无需为峰值使用过度配置 +- 自动闲置和恢复:在无人使用时无需保持闲置计算实例运行 +- 默认安全和高可用性 + +## 管理 {#administration} +- 设置、监控、备份和计费由系统为您完成。 +- 成本控制默认启用,您可以通过云控制台进行调整。 + +## 服务隔离 {#service-isolation} + +### 网络隔离 {#network-isolation} + +所有服务在网络层面上是隔离的。 + +### 计算隔离 {#compute-isolation} + +所有服务在各自的 Kubernetes 空间中以独立的 Pod 部署,并具有网络级隔离。 + +### 存储隔离 {#storage-isolation} + +所有服务使用共享桶(AWS、GCP)或存储容器(Azure)的独立子路径。 + +对于 AWS,存储访问通过 AWS IAM 控制,每个 IAM 角色对每个服务都是唯一的。对于企业服务,可以启用 [CMEK](/cloud/security/cmek) 以提供静态数据的高级隔离。当前 CMEK 仅支持 AWS 服务。 + +对于 GCP 和 Azure,服务具有对象存储隔离(所有服务都有自己的存储桶或存储容器)。 + +## 计算-计算分离 {#compute-compute-separation} +[计算-计算分离](/cloud/reference/warehouses) 允许用户创建多个计算节点组,每个组都有自己的服务 URL,且都使用相同的共享对象存储。这使得对不同用例的计算隔离成为可能,例如读取与写入的情况,它们共享相同的数据。这还通过允许计算组根据需要独立扩展,从而实现更高效的资源利用。 + +## 并发限制 {#concurrency-limits} + +您在 ClickHouse Cloud 服务中的每秒查询数(QPS)没有限制。然而,每个副本的并发查询数量有限制为 1000。QPS 最终取决于您的平均查询执行时间和服务中的副本数量。 + +与自管理的 ClickHouse 实例或其他数据库/数据仓库相比,ClickHouse Cloud 的一个主要好处是您可以通过 [添加更多副本(水平扩展)](/manage/scaling#manual-horizontal-scaling) 来轻松增加并发。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/02_architecture.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/02_architecture.md.hash new file mode 100644 index 00000000000..8a7caeb3304 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/02_architecture.md.hash @@ -0,0 +1 @@ +2e8c7a6d84da5c9d diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/01_billing_overview.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/01_billing_overview.md new file mode 100644 index 00000000000..488c68cf966 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/01_billing_overview.md @@ -0,0 +1,386 @@ +--- +'sidebar_label': '概述' +'slug': '/cloud/manage/billing/overview' +'title': '定价' +'description': 'ClickHouse Cloud 定价的概述页面' +'doc_type': 'reference' +--- + +根据使用情况获取定价信息,请查看 [ClickHouse Cloud Pricing](https://clickhouse.com/pricing#pricing-calculator) 页面。 +ClickHouse Cloud 以计算、存储、[数据传输](/cloud/manage/network-data-transfer)(互联网和跨区域的出口)以及 [ClickPipes](/integrations/clickpipes) 的使用情况进行计费。 +要了解哪些因素可能会影响您的账单,以及如何管理您的支出,请继续阅读。 + +## 亚马逊网络服务 (AWS) 示例 {#amazon-web-services-aws-example} + +:::note +- 价格反映 AWS us-east-1 的定价。 +- 在 [这里](/cloud/manage/network-data-transfer) 查看适用的数据传输和 ClickPipes 收费。 +::: + +### 基本:每月从 $66.52 起 {#basic-from-6652-per-month} + +最佳选择:适用于没有严格可靠性保证的小型数据量的部门用例。 + +**基本层服务** +- 1 个副本 x 8 GiB RAM,2 vCPU +- 500 GB 的压缩数据 +- 500 GB 的数据备份 +- 10 GB 的公共互联网出口数据传输 +- 5 GB 的跨区域数据传输 + +此示例的定价细分: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
每天活跃 6 小时每天活跃 12 小时每天活跃 24 小时
计算\$39.91\$79.83\$159.66
存储\$25.30\$25.30\$25.30
公共互联网出口数据传输\$1.15\$1.15\$1.15
跨区域数据传输\$0.16\$0.16\$0.16
总计\$66.52\$106.44\$186.27
+ +### 扩展(始终在线,自适应扩展):每月从 $499.38 起 {#scale-always-on-auto-scaling-from-49938-per-month} + +最佳选择:需要增强的服务级别协议(2 个以上副本服务)、可扩展性和高级安全性的工作负载。 + +**扩展层服务** +- 活跃工作负载 ~100% 时间 +- 自适应扩展最大配置以防止账单失控 +- 100 GB 的公共互联网出口数据传输 +- 10 GB 的跨区域数据传输 + +此示例的定价细分: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
示例 1示例 2示例 3
计算2 个副本 x 8 GiB RAM,2 vCPU

\$436.95
2 个副本 x 16 GiB RAM,4 vCPU

\$873.89
3 个副本 x 16 GiB RAM,4 vCPU

\$1,310.84
存储1 TB 数据 + 1 备份

\$50.60
2 TB 数据 + 1 备份

\$101.20
3 TB 数据 + 1 备份

\$151.80
公共互联网出口数据传输\$11.52\$11.52\$11.52
跨区域数据传输\$0.31\$0.31\$0.31
总计\$499.38\$986.92\$1,474.47
+ +### 企业:起始价格各异 {#enterprise-starting-prices-vary} + +最佳选择:大规模、关键任务部署,具有严格的安全和合规需求。 + +**企业层服务** +- 活跃工作负载 ~100% 时间 +- 1 TB 的公共互联网出口数据传输 +- 500 GB 的跨区域数据传输 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
示例 1示例 2示例 3
计算2 个副本 x 32 GiB RAM,8 vCPU

\$2,285.60
2 个副本 x 64 GiB RAM,16 vCPU

\$4,571.19
2 x 120 GiB RAM,30 vCPU

\$8,570.99
存储5 TB + 1 备份

\$253.00
10 TB + 1 备份

\$506.00
20 TB + 1 备份

\$1,012.00
公共互联网出口数据传输\$115.20\$115.20\$115.20
跨区域数据传输\$15.60\$15.60\$15.60
总计\$2,669.40\$5,207.99\$9,713.79
+ +## 常见问题 {#faqs} + +### 什么是 ClickHouse Credit (CHC)? {#what-is-chc} + +ClickHouse Credit 是一个信贷单位,用于客户在 ClickHouse Cloud 的使用,等于一(1)美元,将根据 ClickHouse 当时的已发布价格表进行结算。 + +### 我在哪里可以找到旧版定价? {#find-legacy-pricing} + +旧版定价信息可以在 [这里](https://clickhouse.com/pricing?legacy=true) 找到。 + +:::note +如果您是通过 Stripe 进行计费,您会在您的 Stripe 发票上看到 1 CHC 等于 \$0.01 USD。这是为了使计费在 Stripe 上准确,因为其限制无法以小数计费我们的标准 SKU 1 CHC = \$1 USD。 +::: + +### 计算如何计量? {#how-is-compute-metered} + +ClickHouse Cloud 根据每分钟和 8G RAM 增量计算计算。 +计算成本将根据层、区域和云服务提供商而有所不同。 + +### 磁盘存储是如何计算的? {#how-is-storage-on-disk-calculated} + +ClickHouse Cloud 使用云对象存储,使用基于存储在 ClickHouse 表中数据的压缩大小进行计量。 +存储成本在各层之间相同,并根据区域和云服务提供商而有所不同。 + +### 备份算入总存储吗? {#do-backups-count-toward-total-storage} + +存储和备份计入存储成本,并分别计费。 +所有服务默认会保留一天的备份。 +需要额外备份的用户可以通过在 Cloud 控制台的设置标签下配置额外的 [备份](/cloud/manage/backups/overview) 来实现。 + +### 我如何估计压缩率? {#how-do-i-estimate-compression} + +压缩率因数据集而异。 +变化程度取决于数据本身的可压缩性(高基数与低基数字段的数量), +以及用户如何设置模式(例如,是否使用可选编解码器)。 +对于常见类型的分析数据,压缩率可达到 10 倍,但也可能低于或高于此。 +有关指导,请参见 [优化文档](/optimize/asynchronous-inserts) 和这篇 [Uber 博客](https://www.uber.com/blog/logging/) 的详细日志用例示例。 +确切了解的唯一实际方法是将数据集摄取到 ClickHouse 中并将数据集的大小与存储在 ClickHouse 中的大小进行比较。 + +您可以使用以下查询: + +```sql title="Estimating compression" +SELECT formatReadableSize(total_bytes) +FROM system.tables +WHERE name = +``` + +### 如果我有自管理部署,ClickHouse 提供哪些工具来估算在云中运行服务的成本? {#what-tools-does-clickhouse-offer-to-estimate-the-cost-of-running-a-service-in-the-cloud-if-i-have-a-self-managed-deployment} + +ClickHouse 查询日志捕获了 [关键指标](/operations/system-tables/query_log),可用于估算在 ClickHouse Cloud 中运行工作负载的成本。 +有关从自管理迁移到 ClickHouse Cloud 的详细信息,请参阅 [迁移文档](/cloud/migration/clickhouse-to-cloud),如有进一步问题,请联系 [ClickHouse Cloud 支持](https://console.clickhouse.cloud/support)。 + +### ClickHouse Cloud 提供哪些计费选项? {#what-billing-options-are-available-for-clickhouse-cloud} + +ClickHouse Cloud 支持以下计费选项: + +- 自助服务每月(以美元,通过信用卡)。 +- 直接销售每年/多年的(通过预付的 “ClickHouse Credits”,以美元,附加付款选项)。 +- 通过 AWS、GCP 和 Azure 市场(支付即用(PAYG)或与 ClickHouse Cloud 通过市场签订合同)。 + +:::note +ClickHouse Cloud 的 PAYG 信贷以 \$0.01 单位开具发票,使我们能够根据客户的使用情况对部分 ClickHouse 信贷进行收费。这与预留支出 ClickHouse 信贷不同,预留支出是以整 \$1 单位提前购买的。 +::: + +### 计费周期多长? {#how-long-is-the-billing-cycle} + +计费遵循每月账单周期,起始日期被记录为创建 ClickHouse Cloud 组织的日期。 + +### 如果我有一个活跃的 PAYG 市场订阅,然后签署了一份承诺合同,我的承诺信用是否会被优先消费? {#committed-credits-consumed-first-with-active-payg-subscription} + +是的。 使用以下付款方式按以下顺序消费: +- 承诺(预付)信用 +- 市场订阅(PAYG) +- 信用卡 + +### ClickHouse Cloud 提供哪些控制措施来管理扩展和企业服务的成本? {#what-controls-does-clickhouse-cloud-offer-to-manage-costs-for-scale-and-enterprise-services} + +- 试用和年度承诺客户在其消费达到特定阈值时会通过电子邮件自动收到通知:`50%`、`75%` 和 `90%`。这使用户能够主动管理其使用情况。 +- ClickHouse Cloud 允许用户通过 [高级扩展控制](/manage/scaling) 设置计算的最大自适应扩展限制,这是分析工作负载的一个重大成本因素。 +- [高级扩展控制](/manage/scaling) 允许您设置内存限制,并可以控制在不活动期间暂停/空闲的行为。 + +### ClickHouse Cloud 提供哪些控制措施来管理基本服务的成本? {#what-controls-does-clickhouse-cloud-offer-to-manage-costs-for-basic-services} + +- [高级扩展控制](/manage/scaling) 让您控制在不活动期间暂停/空闲的行为。 对于基本服务,不支持调整内存分配。 +- 请注意,默认设置在一段时间不活动后会暂停服务。 + +### 如果我有多个服务,我会收到每个服务的发票还是合并的发票? {#if-i-have-multiple-services-do-i-get-an-invoice-per-service-or-a-consolidated-invoice} + +对于给定组织的账单周期,会生成所有服务的合并发票。 + +### 如果我在试用期和信用到期之前添加信用卡并升级,我会被收费吗? {#if-i-add-my-credit-card-and-upgrade-before-my-trial-period-and-credits-expire-will-i-be-charged} + +当用户在 30 天试用期结束之前从试用转为付费,但还有来自试用信用额度的剩余信用时, +在初始 30 天试用期间,我们会继续使用试用信用进行消耗,然后再向信用卡收费。 + +### 我该如何跟踪我的支出? {#how-can-i-keep-track-of-my-spending} + +ClickHouse Cloud 控制台提供了一个用法显示,详细列出了每项服务的使用情况。 这种细分按使用维度组织,帮助您了解与每个计量单位相关的成本。 + +### 我如何访问我在 ClickHouse Cloud 服务上的订阅发票? {#how-do-i-access-my-invoice-for-my-subscription-to-the-clickhouse-cloud-service} + +对于使用信用卡的直接订阅: + +要查看您的发票,请在 ClickHouse Cloud UI 的左侧导航栏中选择您的组织,然后转到计费。 所有的发票将列在发票部分。 + +对于通过云市场的订阅: + +所有市场订阅均由市场进行计费和开具发票。 您可以通过相应的云服务提供商市场直接查看您的发票。 + +### 为什么用法报表上的日期与我的市场发票不匹配? {#why-do-the-dates-on-the-usage-statements-not-match-my-marketplace-invoice} + +AWS Marketplace 计费遵循日历月周期。 +例如,对于 2024 年 12 月 1 日至 2025 年 1 月 1 日之间的使用, +发票将在 2025 年 1 月 3 日至 1 月 5 日之间生成。 + +ClickHouse Cloud 使用报表遵循不同的计费周期,在注册日起的 30 天内进行计量 +和报告。 + +如果这些日期不相同,则用法和发票日期将不同。 由于使用报表按天跟踪特定服务的使用情况,用户可以依赖报表查看费用明细。 + +### 有关预付信用的使用是否存在任何限制? {#are-there-any-restrictions-around-the-usage-of-prepaid-credits} + +ClickHouse Cloud 的预付信用(无论是直接通过 ClickHouse,还是通过云服务提供商的市场) +只能在合同条款内使用。 +这意味着它们可以在接受日期或未来日期使用,而不能用于任何之前的期间。 +任何超出预付信用的费用都必须通过信用卡支付或通过市场的每月账单覆盖。 + +### 通过云服务提供商市场或直接向 ClickHouse 付款是否存在 ClickHouse Cloud 定价的差异? {#is-there-a-difference-in-clickhouse-cloud-pricing-whether-paying-through-the-cloud-provider-marketplace-or-directly-to-clickhouse} + +市场计费和直接注册 ClickHouse 的定价之间没有差异。 +在这两种情况下,您对 ClickHouse Cloud 的使用情况均以 ClickHouse Cloud Credits (CHCs) 进行跟踪, +并以相同的方式进行计量并相应计费。 + +### 计算-计算分离是如何计费的? {#how-is-compute-compute-separation-billed} + +创建新服务时,您可以选择新服务是否与现有服务共享数据。 +如果是,这两个服务现在构成一个 [仓库](/cloud/reference/warehouses)。 +仓库中存储了数据,并且多个计算服务可以访问这些数据。 + +由于数据只存储一次,您只需为一份数据支付费用,尽管多个服务正在访问它。 +您支付计算费用就像往常一样 — 计算-计算分离/仓库没有额外费用。 +通过利用此部署中的共享存储,用户在存储和备份方面可以节省费用。 + +在某些情况下,计算-计算分离可以为您节省大量的 ClickHouse Credits。 +一个好的例子是以下设置: + +1. 您有 24/7 运行的 ETL 作业,并将数据摄取到服务中。 这些 ETL 作业不需要大量内存,因此可以在小实例上运行,例如 32 GiB RAM。 + +2. 同一个团队的一位数据科学家有临时报告需求,表示他们需要运行一个查询,这需要大量内存 - 236 GiB,但不需要高可用性,并且如果第一次运行失败,可以等待并重新运行查询。 + +在这个例子中,您作为数据库管理员可以进行以下操作: + +1. 创建一个具有两个副本(每个 16 GiB)的较小服务 - 这将满足 ETL 作业并提供高可用性。 + +2. 对于数据科学家,您可以在同一仓库中创建一个副本为 236 GiB 的第二个服务。 您可以为该服务启用空闲功能,这样在数据科学家不使用的时候就不需要为该服务付费。 + +此示例的 **扩展层** 费用估算(每月): +- 父服务全天候在线:2 个副本 x 16 GiB 4 vCPU 每个副本 +- 子服务:1 个副本 x 236 GiB 59 vCPU 每个副本 +- 3 TB 压缩数据 + 1 备份 +- 100 GB 公共互联网出口数据传输 +- 50 GB 跨区域数据传输 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
子服务
每天活跃 1 小时
子服务
每天活跃 2 小时
子服务
每天活跃 4 小时
计算\$1,142.43\$1,410.97\$1,948.05
存储\$151.80\$151.80\$151.80
公共互联网出口数据传输\$11.52\$11.52\$11.52
跨区域数据传输\$1.56\$1.56\$1.56
总计\$1,307.31\$1,575.85\$2,112.93
+ +如果没有仓库,您将不得不为数据工程师在其查询中所需的内存付费。 +然而,将两个服务组合在一个仓库中并使其中一个闲置,能够帮助您节省资金。 + +## ClickPipes 定价 {#clickpipes-pricing} + +有关 ClickPipes 计费的信息,请参见专门的 [“ClickPipes 计费”部分](/cloud/reference/billing/clickpipes)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/01_billing_overview.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/01_billing_overview.md.hash new file mode 100644 index 00000000000..f0e36d35e66 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/01_billing_overview.md.hash @@ -0,0 +1 @@ +903c56d6f2be9974 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/aws-marketplace-committed.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/aws-marketplace-committed.md new file mode 100644 index 00000000000..0b27f7bcab1 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/aws-marketplace-committed.md @@ -0,0 +1,105 @@ +--- +'slug': '/cloud/billing/marketplace/aws-marketplace-committed-contract' +'title': 'AWS Marketplace 承诺合同' +'description': '通过 AWS Marketplace (Committed Contract) 订阅 ClickHouse Cloud' +'keywords': +- 'aws' +- 'amazon' +- 'marketplace' +- 'billing' +- 'committed' +- 'committed contract' +'doc_type': 'guide' +--- + +import Image from '@theme/IdealImage'; +import aws_marketplace_committed_1 from '@site/static/images/cloud/manage/billing/marketplace/aws-marketplace-committed-1.png'; +import aws_marketplace_payg_6 from '@site/static/images/cloud/manage/billing/marketplace/aws-marketplace-payg-6.png'; +import aws_marketplace_payg_7 from '@site/static/images/cloud/manage/billing/marketplace/aws-marketplace-payg-7.png'; +import aws_marketplace_payg_8 from '@site/static/images/cloud/manage/billing/marketplace/aws-marketplace-payg-8.png'; +import aws_marketplace_payg_9 from '@site/static/images/cloud/manage/billing/marketplace/aws-marketplace-payg-9.png'; +import aws_marketplace_payg_10 from '@site/static/images/cloud/manage/billing/marketplace/aws-marketplace-payg-10.png'; +import aws_marketplace_payg_11 from '@site/static/images/cloud/manage/billing/marketplace/aws-marketplace-payg-11.png'; +import aws_marketplace_payg_12 from '@site/static/images/cloud/manage/billing/marketplace/aws-marketplace-payg-12.png'; + +开始通过承诺合同在 [AWS Marketplace](https://aws.amazon.com/marketplace) 上使用 ClickHouse Cloud。承诺合同,也称为私有报价,允许客户承诺在一段时间内在 ClickHouse Cloud 上花费一定金额。 + +## 先决条件 {#prerequisites} + +- 根据具体合同条款从 ClickHouse 获得的私有报价。 +- 要将 ClickHouse 组织连接到您的承诺支出报价,您必须是该组织的管理员。 + +[在 AWS 中查看和接受您承诺合同所需的权限](https://docs.aws.amazon.com/marketplace/latest/buyerguide/private-offers-page.html#private-offers-page-permissions): +- 如果您使用 AWS 托管策略,则需要具有以下权限: `AWSMarketplaceRead-only`, `AWSMarketplaceManageSubscriptions` 或 `AWSMarketplaceFullAccess`。 +- 如果您不使用 AWS 托管策略,则需具备以下权限: IAM 操作 `aws-marketplace:ListPrivateListings` 和 `aws-marketplace:ViewSubscriptions`。 + +## 注册步骤 {#steps-to-sign-up} + +1. 您应该已经收到了一封电子邮件,里面有一个链接用于查看和接受您的私有报价。 + +
+ +AWS Marketplace 私有报价邮件 + +
+ +2. 点击邮件中的 **Review Offer** 链接。这将带您到 AWS Marketplace 页面,并显示私有报价的详细信息。在接受私有报价时,选择合同选项下拉框中的单位数量为 1。 + +3. 完成在 AWS 门户上的订阅步骤并点击 **Set up your account**。 +此时将您重定向到 ClickHouse Cloud 非常重要,您可以注册一个新帐户或使用现有帐户登录。未完成此步骤,我们将无法将您的 AWS Marketplace 订阅与 ClickHouse Cloud 关联。 + +4. 一旦您重定向到 ClickHouse Cloud,您可以使用现有帐户登录或注册新帐户。此步骤非常重要,以便我们可以将您的 ClickHouse Cloud 组织与 AWS Marketplace 计费绑定。 + +
+ +ClickHouse Cloud 登录页面 + +
+ +如果您是新的 ClickHouse Cloud 用户,请点击页面底部的 **Register**。您将被提示创建新用户并验证电子邮件。在验证您的电子邮件后,您可以离开 ClickHouse Cloud 登录页面,并使用新用户名登录到 [https://console.clickhouse.cloud](https://console.clickhouse.cloud)。 + +
+ +ClickHouse Cloud 注册页面 + +
+ +请注意,如果您是新用户,您还需要提供一些有关您业务的基本信息。请参见以下截图。 + +
+ +ClickHouse Cloud 注册信息表单 + +
+ +
+ +ClickHouse Cloud 注册信息表单 2 + +
+ +如果您是现有的 ClickHouse Cloud 用户,只需使用您的凭据登录即可。 + +5. 成功登录后,将创建一个新的 ClickHouse Cloud 组织。该组织将与您的 AWS 计费帐户连接,所有使用将通过您的 AWS 帐户计费。 + +6. 一旦您登录,您可以确认您的计费确实与 AWS Marketplace 相关联,并开始设置您的 ClickHouse Cloud 资源。 + +
+ +ClickHouse Cloud 查看 AWS Marketplace 计费 + +
+ +ClickHouse Cloud 新服务页面 + +
+ +6. 您应该会收到一封确认注册的电子邮件: + +
+ +AWS Marketplace 确认电子邮件 + +
+ +如果您遇到任何问题,请随时联系 [我们的支持团队](https://clickhouse.com/support/program)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/aws-marketplace-committed.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/aws-marketplace-committed.md.hash new file mode 100644 index 00000000000..eb943629d99 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/aws-marketplace-committed.md.hash @@ -0,0 +1 @@ +9214f1fbd4a01b8a diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/marketplace/aws-marketplace-payg.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/aws-marketplace-payg.md similarity index 50% rename from i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/marketplace/aws-marketplace-payg.md rename to i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/aws-marketplace-payg.md index 7efe3040420..5ac6ffac4c4 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/marketplace/aws-marketplace-payg.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/aws-marketplace-payg.md @@ -1,12 +1,13 @@ --- 'slug': '/cloud/billing/marketplace/aws-marketplace-payg' 'title': 'AWS Marketplace PAYG' -'description': '通过 AWS Marketplace (PAYG) 订阅 ClickHouse Cloud.' +'description': '通过 AWS Marketplace (PAYG) 订阅 ClickHouse Cloud。' 'keywords': - 'aws' - 'marketplace' - 'billing' - 'PAYG' +'doc_type': 'guide' --- import aws_marketplace_payg_1 from '@site/static/images/cloud/manage/billing/marketplace/aws-marketplace-payg-1.png'; @@ -23,109 +24,109 @@ import aws_marketplace_payg_11 from '@site/static/images/cloud/manage/billing/ma import aws_marketplace_payg_12 from '@site/static/images/cloud/manage/billing/marketplace/aws-marketplace-payg-12.png'; import Image from '@theme/IdealImage'; -开始通过[AWS Marketplace](https://aws.amazon.com/marketplace)的PAYG(按需付费)公共报价设置ClickHouse Cloud。 +开始在 [AWS Marketplace](https://aws.amazon.com/marketplace) 上通过 PAYG(按需付费)公共报价使用 ClickHouse Cloud。 ## 前提条件 {#prerequisites} -- 一个由您的账单管理员启用购买权限的AWS账户。 -- 要进行购买,您必须使用此账户登录AWS Marketplace。 +- 一个由您的计费管理员启用购买权限的 AWS 账户。 +- 要进行购买,您必须使用此账户登录到 AWS Marketplace。 ## 注册步骤 {#steps-to-sign-up} -1. 前往[AWS Marketplace](https://aws.amazon.com/marketplace)并搜索ClickHouse Cloud。 +1. 前往 [AWS Marketplace](https://aws.amazon.com/marketplace) 并搜索 ClickHouse Cloud。
-AWS Marketplace首页 +AWS Marketplace 首页
-2. 点击[列表](https://aws.amazon.com/marketplace/pp/prodview-jettukeanwrfc),然后点击**查看购买选项**。 +2. 点击 [列表](https://aws.amazon.com/marketplace/pp/prodview-jettukeanwrfc),然后点击 **查看购买选项**。
-AWS Marketplace中搜索ClickHouse +AWS Marketplace 搜索 ClickHouse
3. 在下一个屏幕上,配置合同: -- **合同期限** - PAYG合同按月进行。 +- **合同期限** - PAYG 合同按月运行。 - **续订设置** - 您可以选择合同是否自动续订。 -请注意,如果您未启用自动续订,您的组织将在账单周期结束时自动进入宽限期,然后被停用。 +请注意,我们强烈建议将您的订阅设置为每月自动续订。但是,如果您未启用自动续订,您的组织将在计费周期结束时自动进入宽限期,然后停用。 -- **合同选项** - 您可以在此文本框中输入任何数字(或仅输入1)。这不会影响您支付的价格,因为这些单位的公共报价价格为$0。通常在接受ClickHouse Cloud的私人报价时使用这些单位。 +- **合同选项** - 您可以在此文本框中输入任何数字(或仅输入 1)。这不会影响您支付的价格,因为该公共报价的单位价格为 $0。这些单位通常在接受来自 ClickHouse Cloud 的私人报价时使用。 - **采购订单** - 这是可选的,您可以忽略此项。
-AWS Marketplace配置合同 +AWS Marketplace 配置合同
-填写完上述信息后,点击**创建合同**。您可以确认显示的合同价格为零美元,这基本上意味着您无需支付任何费用,仅需根据使用情况收取费用。 +填写完上述信息后,点击 **创建合同**。您可以确认显示的合同价格为零美元,这意味着您无需支付任何费用,并将根据使用情况产生费用。
-AWS Marketplace确认合同 +AWS Marketplace 确认合同
-4. 一旦您点击**创建合同**,您将看到一个确认和支付的模态框(0美元到期)。 +4. 一旦您点击 **创建合同**,将会出现一个模态框以确认并付款($0 应付)。 -5. 一旦您点击**立即付款**,您将看到确认您现在已订阅ClickHouse Cloud的AWS Marketplace报价。 +5. 一旦您点击 **立即付款**,您将看到确认您现在已订阅 ClickHouse Cloud 的 AWS Marketplace 提供。
-AWS Marketplace支付确认 +AWS Marketplace 支付确认
-6. 请注意,此时设置尚未完成。您需要通过点击**设置您的账户**并在ClickHouse Cloud上注册来继续。 +6. 请注意,此时设置尚未完成。您需要通过点击 **设置您的账户** 并在 ClickHouse Cloud 上注册来进行重定向。 -7. 一旦您重定向到ClickHouse Cloud,您可以选择使用现有账户登录,或注册新账户。这一步非常重要,以便我们可以将您的ClickHouse Cloud组织与AWS Marketplace账单绑定。 +7. 一旦您重定向到 ClickHouse Cloud,您可以选择使用现有账户登录或注册新账户。此步骤非常重要,以便我们能够将您的 ClickHouse Cloud 组织绑定到 AWS Marketplace 计费。
-ClickHouse Cloud登录页面 +ClickHouse Cloud 登录页面
-如果您是新用户,请在页面底部点击**注册**。系统将提示您创建新用户并验证电子邮件。验证邮件后,您可以离开ClickHouse Cloud登录页面,并使用新用户名登录到[https://console.clickhouse.cloud](https://console.clickhouse.cloud)。 +如果您是新用户,请点击页面底部的 **注册**。您将被提示创建新的用户并验证电子邮件。验证完电子邮件后,您可以离开 ClickHouse Cloud 登录页面,并使用新用户名在 [https://console.clickhouse.cloud](https://console.clickhouse.cloud) 登录。
-ClickHouse Cloud注册页面 +ClickHouse Cloud 注册页面
-请注意,如果您是新用户,您还需要提供有关您业务的一些基本信息。请查看下面的截图。 +请注意,如果您是新用户,您还需要提供一些关于您业务的基本信息。请参见下面的屏幕截图。
-ClickHouse Cloud注册信息表单 +ClickHouse Cloud 注册信息表单

-ClickHouse Cloud注册信息表单2 +ClickHouse Cloud 注册信息表单 2
-如果您是现有的ClickHouse Cloud用户,请使用您的凭据直接登录。 +如果您是现有的 ClickHouse Cloud 用户,请使用您的凭据登录。 -8. 成功登录后,将会创建一个新的ClickHouse Cloud组织。该组织将与您的AWS账单账户连接,所有使用情况将通过您的AWS账户计费。 +8. 登录成功后,将创建一个新的 ClickHouse Cloud 组织。该组织将与您的 AWS 计费账户相关联,所有使用将通过您的 AWS 账户计费。 -9. 登录后,您可以确认您的账单确实与AWS Marketplace绑定,并开始设置您的ClickHouse Cloud资源。 +9. 一旦您登录,您可以确认您的计费确实与 AWS Marketplace 绑定,并开始设置您的 ClickHouse Cloud 资源。
-ClickHouse Cloud查看AWS Marketplace账单 +ClickHouse Cloud 查看 AWS Marketplace 计费
-ClickHouse Cloud新服务页面 +ClickHouse Cloud 新服务页面
@@ -133,8 +134,8 @@ import Image from '@theme/IdealImage';
-AWS Marketplace确认邮件 +AWS Marketplace 确认电子邮件
-如果您遇到任何问题,请随时联系[我们的支持团队](https://clickhouse.com/support/program)。 +如果您遇到任何问题,请随时联系 [我们的支持团队](https://clickhouse.com/support/program)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/aws-marketplace-payg.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/aws-marketplace-payg.md.hash new file mode 100644 index 00000000000..721b00a891d --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/aws-marketplace-payg.md.hash @@ -0,0 +1 @@ +8170aa9a42e5d114 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/marketplace/azure-marketplace-committed.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/azure-marketplace-committed.md similarity index 56% rename from i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/marketplace/azure-marketplace-committed.md rename to i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/azure-marketplace-committed.md index 1b9fb479cf7..a677f743da8 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/marketplace/azure-marketplace-committed.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/azure-marketplace-committed.md @@ -1,7 +1,7 @@ --- 'slug': '/cloud/billing/marketplace/azure-marketplace-committed-contract' -'title': 'Azure Marketplace 认可的合同' -'description': '通过 Azure Marketplace 订阅 ClickHouse Cloud (认可的合同)' +'title': 'Azure Marketplace 承诺合同' +'description': '通过 Azure Marketplace 订阅 ClickHouse Cloud(承诺合同)' 'keywords': - 'Microsoft' - 'Azure' @@ -9,6 +9,7 @@ - 'billing' - 'committed' - 'committed contract' +'doc_type': 'guide' --- import Image from '@theme/IdealImage'; @@ -26,117 +27,117 @@ import aws_marketplace_payg_9 from '@site/static/images/cloud/manage/billing/mar import azure_marketplace_payg_11 from '@site/static/images/cloud/manage/billing/marketplace/azure-marketplace-payg-11.png'; import azure_marketplace_payg_12 from '@site/static/images/cloud/manage/billing/marketplace/azure-marketplace-payg-12.png'; -开始在 [Azure Marketplace](https://azuremarketplace.microsoft.com/en-us/marketplace/apps) 上通过承诺合同使用 ClickHouse Cloud。承诺合同,也称为私有报价,允许客户承诺在一段时间内在 ClickHouse Cloud 上花费一定金额。 +通过在 [Azure Marketplace](https://azuremarketplace.microsoft.com/en-us/marketplace/apps) 上的承诺合同开始使用 ClickHouse Cloud。承诺合同,也称为私有报价,允许客户承诺在一段时间内在 ClickHouse Cloud 上花费一定金额。 ## 先决条件 {#prerequisites} -- 来自 ClickHouse 的私有报价,基于特定的合同条款。 +- 基于特定合同条款的 ClickHouse 私有报价。 ## 注册步骤 {#steps-to-sign-up} -1. 您应该收到一封包含查看和接受您私有报价的链接的电子邮件。 +1. 您应该已经收到一封包含审阅和接受私有报价链接的电子邮件。
-Azure Marketplace 私有报价电子邮件 +Azure Marketplace private offer email
-2. 点击电子邮件中的 **Review Private Offer** 链接。这将把您带到包含私有报价详情的 GCP Marketplace 页面。 +2. 点击电子邮件中的 **审阅私有报价** 链接。这将带您到包含私有报价详细信息的 GCP Marketplace 页面。
-Azure Marketplace 私有报价详情 +Azure Marketplace private offer details
-3. 一旦您接受报价,您将进入 **Private Offer Management** 页面。Azure 可能需要一些时间来准备购买报价。 +3. 一旦您接受此报价,您将进入 **私有报价管理** 界面。Azure 可能需要一些时间来准备购买该报价。
-Azure Marketplace 私有报价管理页面 +Azure Marketplace Private Offer Management page
-Azure Marketplace 私有报价管理页面加载中 +Azure Marketplace Private Offer Management page loading
-4. 等待几分钟后,刷新页面。报价应该准备完成 **Purchase**。 +4. 等待几分钟后,刷新页面。该报价应该可以进行 **购买**。
-Azure Marketplace 私有报价管理页面可购买 +Azure Marketplace Private Offer Management page purchase enabled
-5. 点击 **Purchase** - 您将看到一个弹出窗口。完成以下内容: +5. 点击 **购买** - 您将看到一个弹出窗口。完成以下内容:
- 订阅和资源组 - 为 SaaS 订阅提供一个名称 -- 选择您有私有报价的计费计划。只有创建私有报价时的期限(例如,1 年)才会有金额,而其他计费期限选项将为 $0。 -- 选择是否希望进行循环计费。如果未选择循环计费,合同将在计费期结束时结束,资源将被设置为退役。 -- 点击 **Review + subscribe**。 +- 选择您拥有私有报价的计费计划。只有创建私有报价的条款(例如,1 年)才会有金额,其他计费条款选项将为 $0 的金额。 +- 选择是否需要定期计费。如果不选择定期计费,合同将在计费周期结束时终止,资源将被设置为退役。 +- 点击 **审阅 + 订阅**。
-Azure Marketplace 订阅表单 +Azure Marketplace subscription form
-6. 在下一个屏幕上,检查所有详细信息并点击 **Subscribe**。 +6. 在下一屏幕上,审查所有详细信息并点击 **订阅**。
-Azure Marketplace 订阅确认 +Azure Marketplace subscription confirmation
-7. 在下一个屏幕上,您将看到 **Your SaaS subscription in progress**。 +7. 在下一屏幕上,您将看到 **您的 SaaS 订阅正在进行中**。
-Azure Marketplace 订阅提交页面 +Azure Marketplace subscription submitting page
-8. 一旦准备好,您可以点击 **Configure account now**。请注意,这是将 Azure 订阅绑定到您帐户的 ClickHouse Cloud 组织的关键步骤。如果没有此步骤,您的 Marketplace 订阅将不会完成。 +8. 一旦准备就绪,您可以点击 **立即配置账户**。请注意,这是一个关键步骤,将 Azure 订阅绑定到 ClickHouse Cloud 组织。没有此步骤,您的 Marketplace 订阅将不完整。
-Azure Marketplace 立即配置帐户按钮 +Azure Marketplace configure account now button
-9. 您将被重定向到 ClickHouse Cloud 注册或登录页面。您可以使用新帐户注册或使用现有帐户登录。一旦您登录,将创建一个新的组织,准备通过 Azure Marketplace 进行使用和计费。 +9. 您将被重定向到 ClickHouse Cloud 注册或登录页面。您可以选择使用新账户注册或使用现有账户登录。登录后,将创建一个新组织,准备通过 Azure Marketplace 使用和计费。 -10. 在继续之前,您需要回答几个问题 - 地址和公司详情。 +10. 您需要回答一些问题 - 地址和公司详细信息 - 然后才能继续。
-ClickHouse Cloud 注册信息表单 +ClickHouse Cloud sign up info form
-ClickHouse Cloud 注册信息表单 2 +ClickHouse Cloud sign up info form 2
-11. 一旦您点击 **Complete sign up**,您将被带到 ClickHouse Cloud 组织中,在那里您可以查看计费屏幕,以确保您通过 Azure Marketplace 付费并可以创建服务。 +11. 一旦您点击 **完成注册**,您将被带到 ClickHouse Cloud 中的组织,在那里您可以查看计费屏幕以确保通过 Azure Marketplace 进行计费,并可以创建服务。

-ClickHouse Cloud 注册信息表单 +ClickHouse Cloud sign up info form

-ClickHouse Cloud 注册信息表单 +ClickHouse Cloud sign up info form
diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/azure-marketplace-committed.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/azure-marketplace-committed.md.hash new file mode 100644 index 00000000000..2d89ea96c5b --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/azure-marketplace-committed.md.hash @@ -0,0 +1 @@ +96b37b6b1b0d3b28 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/marketplace/azure-marketplace-payg.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/azure-marketplace-payg.md similarity index 60% rename from i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/marketplace/azure-marketplace-payg.md rename to i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/azure-marketplace-payg.md index cde8798ffa1..9fa1d72db7c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/marketplace/azure-marketplace-payg.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/azure-marketplace-payg.md @@ -7,6 +7,7 @@ - 'marketplace' - 'billing' - 'PAYG' +'doc_type': 'guide' --- import Image from '@theme/IdealImage'; @@ -25,18 +26,18 @@ import aws_marketplace_payg_9 from '@site/static/images/cloud/manage/billing/mar import azure_marketplace_payg_11 from '@site/static/images/cloud/manage/billing/marketplace/azure-marketplace-payg-11.png'; import azure_marketplace_payg_12 from '@site/static/images/cloud/manage/billing/marketplace/azure-marketplace-payg-12.png'; -开始在 [Azure Marketplace](https://azuremarketplace.microsoft.com/en-us/marketplace/apps) 上通过 PAYG(按需付费)公共报价使用 ClickHouse Cloud。 +开始使用 ClickHouse Cloud,通过 [Azure Marketplace](https://azuremarketplace.microsoft.com/en-us/marketplace/apps) 的 PAYG(按需付费)公共报价。 -## 先决条件 {#prerequisites} +## 前提条件 {#prerequisites} -- 由您的账单管理员启用购买权限的 Azure 项目。 -- 要在 Azure Marketplace 上订阅 ClickHouse Cloud,您必须使用具有购买权限的帐户登录并选择适当的项目。 +- 一个由您的账单管理员启用购买权限的 Azure 项目。 +- 要在 Azure Marketplace 订阅 ClickHouse Cloud,您必须使用具有购买权限的帐户登录,并选择适当的项目。 -1. 访问 [Azure Marketplace](https://azuremarketplace.microsoft.com/en-us/marketplace/apps) 并搜索 ClickHouse Cloud。确保您已登录,以便可以在市场上购买产品。 +1. 前往 [Azure Marketplace](https://azuremarketplace.microsoft.com/en-us/marketplace/apps),搜索 ClickHouse Cloud。确保您已登录,以便您可以在市场上购买产品。
-ClickHouse Cloud 注册信息表单 +ClickHouse Cloud sign up info form
@@ -44,15 +45,15 @@ import azure_marketplace_payg_12 from '@site/static/images/cloud/manage/billing/
-ClickHouse Cloud 注册信息表单 +ClickHouse Cloud sign up info form
-3. 在下一个屏幕上,您需要提供姓名、电子邮件和位置信息。 +3. 在下一个屏幕上,您需要提供名称、电子邮件和位置信息。
-ClickHouse Cloud 注册信息表单 +ClickHouse Cloud sign up info form
@@ -60,7 +61,7 @@ import azure_marketplace_payg_12 from '@site/static/images/cloud/manage/billing/
-ClickHouse Cloud 注册信息表单 +ClickHouse Cloud sign up info form
@@ -68,84 +69,84 @@ import azure_marketplace_payg_12 from '@site/static/images/cloud/manage/billing/
-ClickHouse Cloud 注册信息表单 +ClickHouse Cloud sign up info form
-6. 您还需要为订阅提供一个名称,并从可用选项中选择计费条款。您可以选择将 **循环计费** 设置为开启或关闭。如果您将其设置为“关闭”,您的合同将在计费期结束后终止,您的资源将被退役。 +6. 您还需要为订阅提供一个名称,并从可用选项中选择计费条款。您可以选择将 **定期计费** 设置为开启或关闭。如果您将其设置为 "关闭",则您的合同将在计费周期结束后结束,您的资源将被停用。
-ClickHouse Cloud 注册信息表单 +ClickHouse Cloud sign up info form
-7. 点击 **“查看 + 订阅”**。 +7. 点击 **"审核 + 订阅"**。 -8. 在下一个屏幕上,确认一切看起来正确,然后点击 **订阅**。 +8. 在下一个屏幕上,确认一切无误后,点击 **订阅**。
-ClickHouse Cloud 注册信息表单 +ClickHouse Cloud sign up info form
-9. 请注意,此时您已经订阅了 ClickHouse Cloud 的 Azure 订阅,但尚未在 ClickHouse Cloud 上设置您的帐户。接下来的步骤是必要且关键的,以便 ClickHouse Cloud 能够绑定到您的 Azure 订阅,以便通过 Azure 市场正确进行计费。 +9. 注意,此时您已经订阅了 ClickHouse Cloud 的 Azure 订阅,但还没有在 ClickHouse Cloud 上设置您的帐户。接下来的步骤是必要且关键的,以便 ClickHouse Cloud 能够绑定到您的 Azure 订阅,从而通过 Azure 市场正确进行计费。
-ClickHouse Cloud 注册信息表单 +ClickHouse Cloud sign up info form
-10. 一旦 Azure 设置完成,**现在配置帐户** 按钮将变为活跃状态。 +10. 一旦 Azure 设置完成,**立即配置帐户** 按钮应变为可用。
-ClickHouse Cloud 注册信息表单 +ClickHouse Cloud sign up info form
-11. 点击 **现在配置帐户**。 +11. 点击 **立即配置帐户**。
-您将收到一封电子邮件,内容如下,内含有关配置您的帐户的详细信息: +您将收到类似于以下内容的电子邮件,邮件中包含配置您帐户的详细信息:
-ClickHouse Cloud 注册信息表单 +ClickHouse Cloud sign up info form
-12. 您将被重定向到 ClickHouse Cloud 注册或登录页面。您可以使用新帐户注册或使用现有帐户登录。一旦登录,将创建一个新组织,可以通过 Azure Marketplace 进行使用和计费。 +12. 您将被重定向到 ClickHouse Cloud 注册或登录页面。一旦您重定向到 ClickHouse Cloud,您可以使用现有帐户登录,或注册新帐户。此步骤非常重要,以便我们可以将您的 ClickHouse Cloud 组织与 Azure Marketplace 计费绑定。 -13. 在继续之前,您需要回答几个问题 - 地址和公司信息。 +13. 注意,如果您是新用户,您还需要提供一些关于您业务的基本信息。请查看下面的截图。
-ClickHouse Cloud 注册信息表单 +ClickHouse Cloud sign up info form
-ClickHouse Cloud 注册信息表单 2 +ClickHouse Cloud sign up info form 2
-14. 一旦您点击 **完成注册**,您将被带到 ClickHouse Cloud 内的组织,您可以查看计费屏幕,以确保通过 Azure Marketplace 进行计费并创建服务。 +一旦您点击 **完成注册**,您将进入 ClickHouse Cloud 内的您的组织,在那里您可以查看计费屏幕,以确保您通过 Azure Marketplace 进行计费并可以创建服务。

-ClickHouse Cloud 注册信息表单 +ClickHouse Cloud sign up info form

-ClickHouse Cloud 注册信息表单 +ClickHouse Cloud sign up info form
-15. 如果您遇到任何问题,请随时联系 [我们的支持团队](https://clickhouse.com/support/program)。 +14. 如果您遇到任何问题,请随时联系 [我们的支持团队](https://clickhouse.com/support/program)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/azure-marketplace-payg.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/azure-marketplace-payg.md.hash new file mode 100644 index 00000000000..0a9b5e469f8 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/azure-marketplace-payg.md.hash @@ -0,0 +1 @@ +bafa258cd860ffb6 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/marketplace/gcp-marketplace-committed.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/gcp-marketplace-committed.md similarity index 69% rename from i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/marketplace/gcp-marketplace-committed.md rename to i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/gcp-marketplace-committed.md index 2424a25ceb5..5874f0ba85c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/marketplace/gcp-marketplace-committed.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/gcp-marketplace-committed.md @@ -1,7 +1,7 @@ --- 'slug': '/cloud/billing/marketplace/gcp-marketplace-committed-contract' 'title': 'GCP Marketplace 承诺合同' -'description': '通过 GCP Marketplace 订阅 ClickHouse Cloud (承诺合同)' +'description': '通过 GCP Marketplace 订阅 ClickHouse Cloud(承诺合同)' 'keywords': - 'gcp' - 'google' @@ -9,6 +9,7 @@ - 'billing' - 'committed' - 'committed contract' +'doc_type': 'guide' --- import Image from '@theme/IdealImage'; @@ -27,15 +28,15 @@ import gcp_marketplace_payg_5 from '@site/static/images/cloud/manage/billing/mar import aws_marketplace_payg_11 from '@site/static/images/cloud/manage/billing/marketplace/aws-marketplace-payg-11.png'; import gcp_marketplace_payg_6 from '@site/static/images/cloud/manage/billing/marketplace/gcp-marketplace-payg-6.png'; -开始使用 [GCP Marketplace](https://console.cloud.google.com/marketplace) 上的 ClickHouse Cloud 通过承诺合同。承诺合同,也称为私有报价,允许客户承诺在一段时间内在 ClickHouse Cloud 上花费一定金额。 +通过签订承诺合同在 [GCP Marketplace](https://console.cloud.google.com/marketplace) 上开始使用 ClickHouse Cloud。承诺合同,也称为私有报价,允许客户在一段时间内承诺在 ClickHouse Cloud 上支出一定金额。 -## 先决条件 {#prerequisites} +## 前提条件 {#prerequisites} -- 根据特定合同条款来自 ClickHouse 的私有报价。 +- 根据特定合同条款 从 ClickHouse 获得的私有报价。 ## 注册步骤 {#steps-to-sign-up} -1. 您应该已收到一封电子邮件,里面有一个链接以查看和接受您的私有报价。 +1. 您应该已经收到一封电子邮件,里面包含审核和接受您的私有报价的链接。
@@ -43,7 +44,7 @@ import gcp_marketplace_payg_6 from '@site/static/images/cloud/manage/billing/mar
-2. 点击电子邮件中的 **Review Offer** 链接。这应该会带您到带有私有报价详情的 GCP Marketplace 页面。 +2. 点击电子邮件中的 **Review Offer** 链接。这将带您到包含私有报价详细信息的 GCP Marketplace 页面。
@@ -79,7 +80,7 @@ import gcp_marketplace_payg_6 from '@site/static/images/cloud/manage/billing/mar
-此时,重要的是跳转到 ClickHouse Cloud 并注册或登录。如果不完成此步骤,我们将无法将您的 GCP Marketplace 订阅与 ClickHouse Cloud 关联。 +在这一点上重定向到 ClickHouse Cloud 并注册或登录是至关重要的。未完成此步骤,我们将无法将您的 GCP Marketplace 订阅与 ClickHouse Cloud 连接。
@@ -87,7 +88,7 @@ import gcp_marketplace_payg_6 from '@site/static/images/cloud/manage/billing/mar
-6. 一旦您跳转到 ClickHouse Cloud,您可以使用现有账户登录,或使用新账户注册。 +6. 一旦您重定向到 ClickHouse Cloud,您可以使用现有帐户登录,也可以注册新帐户。
@@ -95,7 +96,7 @@ import gcp_marketplace_payg_6 from '@site/static/images/cloud/manage/billing/mar
-如果您是新用户,请点击页面底部的 **Register**。您将被提示创建新用户并验证电子邮件。验证电子邮件后,您可以离开 ClickHouse Cloud 登录页面,并使用新用户名登录 [https://console.clickhouse.cloud](https://console.clickhouse.cloud)。 +如果您是新的 ClickHouse Cloud 用户,请在页面底部点击 **Register**。系统会提示您创建新用户并验证电子邮件。验证您的电子邮件后,您可以离开 ClickHouse Cloud 登录页面,并使用新用户名登录 [https://console.clickhouse.cloud](https://console.clickhouse.cloud)。
@@ -103,7 +104,7 @@ import gcp_marketplace_payg_6 from '@site/static/images/cloud/manage/billing/mar
-注意,如果您是新用户,您还需要提供一些关于您企业的基本信息。请参见以下截图。 +请注意,如果您是新用户,您还需要提供一些有关您业务的基本信息。请参见下面的屏幕截图。
@@ -115,11 +116,11 @@ import gcp_marketplace_payg_6 from '@site/static/images/cloud/manage/billing/mar
-如果您是现有的 ClickHouse Cloud 用户,只需使用您的凭据登录即可。 +如果您是现有的 ClickHouse Cloud 用户,只需使用您的凭据登录。 -7. 登录成功后,将会创建一个新的 ClickHouse Cloud 组织。此组织将与您的 GCP 账单账户连接,所有使用将通过您的 GCP 账户收费。 +7. 成功登录后,将创建一个新的 ClickHouse Cloud 组织。该组织将与您的 GCP 计费帐户连接,所有使用情况将通过您的 GCP 帐户计费。 -8. 登录后,您可以确认您的账单确实与 GCP Marketplace 关联,并开始设置您的 ClickHouse Cloud 资源。 +8. 登录后,您可以确认您的计费确实与 GCP Marketplace 相关,并开始设置您的 ClickHouse Cloud 资源。
diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/gcp-marketplace-committed.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/gcp-marketplace-committed.md.hash new file mode 100644 index 00000000000..6c13a076a03 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/gcp-marketplace-committed.md.hash @@ -0,0 +1 @@ +8584e3b68535dab6 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/marketplace/gcp-marketplace-payg.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/gcp-marketplace-payg.md similarity index 68% rename from i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/marketplace/gcp-marketplace-payg.md rename to i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/gcp-marketplace-payg.md index 162d2d9b073..ca97d60371e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/billing/marketplace/gcp-marketplace-payg.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/gcp-marketplace-payg.md @@ -1,12 +1,13 @@ --- 'slug': '/cloud/billing/marketplace/gcp-marketplace-payg' -'title': 'GCP 市场 PAYG' -'description': '通过 GCP 市场 (PAYG) 订阅 ClickHouse Cloud。' +'title': 'GCP Marketplace PAYG' +'description': '通过 GCP Marketplace (PAYG) 订阅 ClickHouse Cloud。' 'keywords': - 'gcp' - 'marketplace' - 'billing' - 'PAYG' +'doc_type': 'guide' --- import gcp_marketplace_payg_1 from '@site/static/images/cloud/manage/billing/marketplace/gcp-marketplace-payg-1.png'; @@ -22,29 +23,29 @@ import aws_marketplace_payg_11 from '@site/static/images/cloud/manage/billing/ma import gcp_marketplace_payg_6 from '@site/static/images/cloud/manage/billing/marketplace/gcp-marketplace-payg-6.png'; import Image from '@theme/IdealImage'; -开始通过 PAYG(按需付费)公共报价在 [GCP Marketplace](https://console.cloud.google.com/marketplace) 上使用 ClickHouse Cloud。 +通过 PAYG(按需付费)公共报价在 [GCP Marketplace](https://console.cloud.google.com/marketplace) 上开始使用 ClickHouse Cloud。 ## 前提条件 {#prerequisites} -- 一个由您的计费管理员启用采购权限的 GCP 项目。 -- 要在 GCP Marketplace 上订阅 ClickHouse Cloud,您必须使用具有采购权限的帐户登录并选择相应的项目。 +- 一个由您的计费管理员启用购买权限的 GCP 项目。 +- 要在 GCP Marketplace 上订阅 ClickHouse Cloud,您必须登录具有购买权限的账户并选择适当的项目。 ## 注册步骤 {#steps-to-sign-up} -1. 前往 [GCP Marketplace](https://cloud.google.com/marketplace) 并搜索 ClickHouse Cloud。确保您选择了正确的项目。 +1. 前往 [GCP Marketplace](https://cloud.google.com/marketplace) 并搜索 ClickHouse Cloud。确保选择正确的项目。 -GCP Marketplace 首页 +GCP Marketplace 主页 -2. 点击 [列表](https://console.cloud.google.com/marketplace/product/clickhouse-public/clickhouse-cloud),然后点击 **Subscribe**。 +2. 点击 [列表](https://console.cloud.google.com/marketplace/product/clickhouse-public/clickhouse-cloud),然后点击 **订阅**。 GCP Marketplace 中的 ClickHouse Cloud 3. 在下一个屏幕上,配置订阅: -- 计划默认设置为 "ClickHouse Cloud" +- 计划默认为 "ClickHouse Cloud" - 订阅时间框架为 "每月" - 选择适当的计费账户 -- 接受条款并点击 **Subscribe** +- 接受条款,然后点击 **订阅**
@@ -52,17 +53,17 @@ import Image from '@theme/IdealImage';
-4. 一旦您点击 **Subscribe**,您将看到一个模态窗口 **Sign up with ClickHouse**。 +4. 一旦您点击 **订阅**,您将看到模态窗口 **使用 ClickHouse 注册**。
-GCP Marketplace 注册模态窗口 +GCP Marketplace 注册模态
-5. 请注意,此时设置尚未完成。您需要通过点击 **Set up your account** 并在 ClickHouse Cloud 上注册来进行重定向。 +5. 请注意,此时设置尚未完成。您需要通过点击 **设置您的账户** 并在 ClickHouse Cloud 上注册来重定向到 ClickHouse Cloud。 -6. 一旦您重定向到 ClickHouse Cloud,您可以使用现有帐户登录,或使用新帐户注册。此步骤非常重要,这样我们才能将您的 ClickHouse Cloud 组织与 GCP Marketplace 计费绑定。 +6. 一旦您重定向到 ClickHouse Cloud,您可以使用现有账户登录,或用新账户注册。此步骤非常重要,以便我们可以将您的 ClickHouse Cloud 组织绑定到 GCP Marketplace 计费。
@@ -70,7 +71,7 @@ import Image from '@theme/IdealImage';
-如果您是 ClickHouse Cloud 新用户,请在页面底部点击 **Register**。系统会提示您创建新用户并验证电子邮件。验证您的电子邮件后,您可以离开 ClickHouse Cloud 登录页面,并使用新用户名登录 [https://console.clickhouse.cloud](https://console.clickhouse.cloud)。 +如果您是新用户,请在页面底部点击 **注册**。系统会提示您创建一个新用户并验证电子邮件。验证电子邮件后,您可以离开 ClickHouse Cloud 登录页面并使用新用户名登录 [https://console.clickhouse.cloud](https://console.clickhouse.cloud)。
@@ -78,7 +79,7 @@ import Image from '@theme/IdealImage';
-请注意,如果您是新用户,您还需要提供一些有关您的业务的基本信息。请参见下面的屏幕截图。 +请注意,如果您是新用户,您还需要提供一些有关您业务的基本信息。请参见下面的屏幕截图。
@@ -90,11 +91,11 @@ import Image from '@theme/IdealImage';
-如果您是现有 ClickHouse Cloud 用户,只需使用您的凭据登录。 +如果您是现有的 ClickHouse Cloud 用户,只需使用您的凭据登录。 -7. 成功登录后,将创建一个新的 ClickHouse Cloud 组织。该组织将与您的 GCP 计费账户连接,所有使用将通过您的 GCP 账户计费。 +7. 成功登录后,将创建一个新的 ClickHouse Cloud 组织。该组织将与您的 GCP 计费账户连接,所有使用将通过您的 GCP 账户进行计费。 -8. 登录后,您可以确认您的计费确实与 GCP Marketplace 相关联,并开始设置您的 ClickHouse Cloud 资源。 +8. 登录后,您可以确认您的计费确实与 GCP Marketplace 绑定,并开始设置您的 ClickHouse Cloud 资源。
@@ -111,7 +112,7 @@ import Image from '@theme/IdealImage';

-GCP Marketplace 确认电子邮件 +GCP Marketplace 确认邮件
diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/gcp-marketplace-payg.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/gcp-marketplace-payg.md.hash new file mode 100644 index 00000000000..d8df07fa811 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/gcp-marketplace-payg.md.hash @@ -0,0 +1 @@ +c040806d07d5de0c diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/index.md new file mode 100644 index 00000000000..ea7abf45af4 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/index.md @@ -0,0 +1,22 @@ +--- +'slug': '/cloud/manage/marketplace/' +'title': '市场' +'description': '市场 TABLE OF CONTENTS 页面' +'keywords': +- 'Marketplace Billing' +- 'AWS' +- 'GCP' +'doc_type': 'landing-page' +--- + +这一部分详细介绍了与市场相关的计费主题。 + +| 页面 | 描述 | +|---------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| [市场计费](/cloud/marketplace/marketplace-billing) | 关于市场计费的常见问题。 | +| [AWS Marketplace PAYG](/cloud/billing/marketplace/aws-marketplace-payg) | 通过PAYG(按需付款)公共报价在AWS Marketplace上开始使用ClickHouse Cloud。 | +| [AWS Marketplace承诺合同](/cloud/billing/marketplace/aws-marketplace-committed-contract) | 通过承诺合同在AWS Marketplace上开始使用ClickHouse Cloud。承诺合同,也称为私人报价,允许客户承诺在一定时间内在ClickHouse Cloud上支出一定金额。 | +| [GCP Marketplace PAYG](/cloud/billing/marketplace/gcp-marketplace-payg) | 通过PAYG(按需付款)公共报价在GCP Marketplace上开始使用ClickHouse Cloud。 | +| [GCP Marketplace承诺合同](/cloud/billing/marketplace/gcp-marketplace-committed-contract) | 通过承诺合同在GCP Marketplace上开始使用ClickHouse Cloud。承诺合同,也称为私人报价,允许客户承诺在一定时间内在ClickHouse Cloud上支出一定金额。 | +| [Azure Marketplace PAYG](/cloud/billing/marketplace/azure-marketplace-payg) | 通过PAYG(按需付款)公共报价在Azure Marketplace上开始使用ClickHouse Cloud。 | +| [Azure Marketplace承诺合同](/cloud/billing/marketplace/azure-marketplace-committed-contract) | 通过承诺合同在Azure Marketplace上开始使用ClickHouse Cloud。承诺合同,也称为私人报价,允许客户承诺在一定时间内在ClickHouse Cloud上支出一定金额。 | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/index.md.hash new file mode 100644 index 00000000000..cfcc8dba60a --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/index.md.hash @@ -0,0 +1 @@ +cb725e616ac3b655 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/migrate-marketplace-payg-committed.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/migrate-marketplace-payg-committed.md new file mode 100644 index 00000000000..4f9dcb9b09f --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/migrate-marketplace-payg-committed.md @@ -0,0 +1,88 @@ +--- +'slug': '/cloud/billing/marketplace/migrate' +'title': '将计费从按需付费 (PAYG) 迁移到云市场中的承诺支出合同' +'description': '从按需付费迁移到承诺支出合同。' +'keywords': +- 'marketplace' +- 'billing' +- 'PAYG' +- 'pay-as-you-go' +- 'committed spend contract' +'doc_type': 'guide' +--- + + +# 将账单从按需支付 (PAYG) 迁移到云市场中的承诺支出合同 {#migrate-payg-to-committed} + +如果您的 ClickHouse 组织当前通过活跃的云市场按需支付 (PAYG) 订阅(或订单)进行计费,并且您希望通过同一云市场迁移到通过承诺支出合同进行计费,请接受您的新报价,然后根据您的云服务提供商遵循以下步骤。 + +## 重要说明 {#important-notes} + +请注意,取消您的市场 PAYG 订阅不会删除您的 ClickHouse Cloud 账户 - 仅删除通过市场的计费关系。一旦取消,我们的系统将停止通过市场对 ClickHouse Cloud 服务的计费。(注意:此过程不是立即的,可能需要几分钟才能完成)。 + +在您的市场订阅取消后,如果您的 ClickHouse 组织有保存的信用卡,我们将在您的计费周期结束时收费 - 除非在此之前连接了新的市场订阅。 + +如果在取消后没有配置信用卡,您将有 14 天的时间为您的组织添加有效的信用卡或新的云市场订阅。如果在该期间内未配置付款方式,您的服务将被暂停,并且您的组织将被视为不符合 [计费合规性](/manage/clickhouse-cloud-billing-compliance)。 + +任何在订阅取消后产生的使用费用将按照顺序计入下一个配置的有效付款方式 - 预付信用卡、市场订阅或信用卡。 + +如有任何问题或需要帮助配置您的组织到新的市场订阅,请联系 ClickHouse [支持](https://clickhouse.com/support/program) 寻求帮助。 + +## AWS Marketplace {#aws-marketplace} + +如果您希望使用相同的 AWS 账户 ID 将您的 PAYG 订阅迁移到承诺支出合同,则我们推荐的方法是 [联系销售](https://clickhouse.com/company/contact) 进行此变更。这样做意味着不需要额外的步骤,并且不会对您的 ClickHouse 组织或服务造成干扰。 + +如果您希望使用不同的 AWS 账户 ID 将您的 ClickHouse 组织从 PAYG 订阅迁移到承诺支出合同,请按照以下步骤进行: + +### 取消 AWS PAYG 订阅的步骤 {#cancel-aws-payg} + +1. **前往 [AWS Marketplace](https://us-east-1.console.aws.amazon.com/marketplace)** +2. **点击“管理订阅”按钮** +3. **导航到“您的订阅”:** + - 点击“管理订阅” +4. **在列表中找到 ClickHouse Cloud:** + - 在“您的订阅”下查找并点击 ClickHouse Cloud +5. **取消订阅:** + - 在“协议”下点击 ClickHouse Cloud 列表旁边的“操作”下拉菜单或按钮 + - 选择“取消订阅” + +> **注意:** 如需帮助取消您的订阅(例如,如果取消订阅按钮不可用),请联系 [AWS 支持](https://support.console.aws.amazon.com/support/home#/)。 + +接下来,请遵循这些 [步骤](/cloud/billing/marketplace/aws-marketplace-committed-contract) 将您的 ClickHouse 组织配置为您接受的新 AWS 承诺支出合同。 + +## GCP Marketplace {#gcp-marketplace} + +### 取消 GCP PAYG 订单的步骤 {#cancel-gcp-payg} + +1. **前往您的 [Google Cloud Marketplace 控制台](https://console.cloud.google.com/marketplace):** + - 确保您已登录到正确的 GCP 账户并选择了适当的项目 +2. **找到您的 ClickHouse 订单:** + - 在左侧菜单中,点击“您的订单” + - 在活动订单列表中找到正确的 ClickHouse 订单 +3. **取消订单:** + - 找到您订单右侧的三个点菜单,并按照说明取消 ClickHouse 订单 + +> **注意:** 如需帮助取消此订单,请联系 [GCP 支持](https://cloud.google.com/support/docs/get-billing-support)。 + +接下来,请遵循这些 [步骤](/cloud/billing/marketplace/gcp-marketplace-committed-contract) 将您的 ClickHouse 组织配置为您的新 GCP 承诺支出合同。 + +## Azure Marketplace {#azure-marketplace} + +### 取消 Azure PAYG 订阅的步骤 {#cancel-azure-payg} + +1. **前往 [Microsoft Azure 门户](http://portal.azure.com)** +2. **导航到“订阅”** +3. **找到您要取消的活动 ClickHouse 订阅** +4. **取消订阅:** + - 点击 ClickHouse Cloud 订阅以打开订阅详情 + - 选择“取消订阅”按钮 + +> **注意:** 如需帮助取消此订单,请在您的 Azure 门户中打开支持票。 + +接下来,请遵循这些 [步骤](/cloud/billing/marketplace/azure-marketplace-committed-contract) 将您的 ClickHouse 组织配置为您新的 Azure 承诺支出合同。 + +## 连接到承诺支出合同的要求 {#linking-requirements} + +> **注意:** 为了将您的组织连接到市场承诺支出合同: +> - 跟随步骤的用户必须是您要连接订阅的 ClickHouse 组织的管理员用户 +> - 组织中的所有未付款发票必须已支付(如有任何问题,请联系 ClickHouse [支持](https://clickhouse.com/support/program))。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/migrate-marketplace-payg-committed.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/migrate-marketplace-payg-committed.md.hash new file mode 100644 index 00000000000..8006ab17214 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/migrate-marketplace-payg-committed.md.hash @@ -0,0 +1 @@ +a42ef907c5a6f902 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/overview.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/overview.md new file mode 100644 index 00000000000..a024d5e9e4d --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/overview.md @@ -0,0 +1,99 @@ +--- +'slug': '/cloud/marketplace/marketplace-billing' +'title': '市场账单' +'description': '通过 AWS、GCP 和 Azure 市场订阅 ClickHouse Cloud。' +'keywords': +- 'aws' +- 'azure' +- 'gcp' +- 'google cloud' +- 'marketplace' +- 'billing' +'doc_type': 'guide' +--- + +import Image from '@theme/IdealImage'; +import marketplace_signup_and_org_linking from '@site/static/images/cloud/manage/billing/marketplace/marketplace_signup_and_org_linking.png' + +您可以通过 AWS、GCP 和 Azure 市场订阅 ClickHouse Cloud。这使您可以通过现有的云服务提供商账单为 ClickHouse Cloud 付款。 + +您可以选择按需支付(PAYG)或通过市场与 ClickHouse Cloud 签订合同。账单将由云服务提供商处理,您将获得所有云服务的单一发票。 + +- [AWS Marketplace 按需支付](/cloud/billing/marketplace/aws-marketplace-payg) +- [AWS Marketplace 合同签订](/cloud/billing/marketplace/aws-marketplace-committed-contract) +- [GCP Marketplace 按需支付](/cloud/billing/marketplace/gcp-marketplace-payg) +- [GCP Marketplace 合同签订](/cloud/billing/marketplace/gcp-marketplace-committed-contract) +- [Azure Marketplace 按需支付](/cloud/billing/marketplace/azure-marketplace-payg) +- [Azure Marketplace 合同签订](/cloud/billing/marketplace/azure-marketplace-committed-contract) + +## 常见问题 {#faqs} + +### 我如何验证我的组织是否已连接到市场账单?​ {#how-can-i-verify-that-my-organization-is-connected-to-marketplace-billing} + +在 ClickHouse Cloud 控制台中,导航到 **账单**。您应该在 **支付详情** 部分看到市场的名称和链接。 + +### 我是现有的 ClickHouse Cloud 用户。如果我通过 AWS / GCP / Azure 市场订阅 ClickHouse Cloud,会发生什么?​ {#i-am-an-existing-clickhouse-cloud-user-what-happens-when-i-subscribe-to-clickhouse-cloud-via-aws--gcp--azure-marketplace} + +从云服务提供商市场注册 ClickHouse Cloud 是一个两步过程: +1. 您首先在云服务提供商的市场门户中“订阅” ClickHouse Cloud。完成订阅后,您点击“立即支付”或“在提供商上管理”(具体取决于市场)。这会将您重定向到 ClickHouse Cloud。 +2. 在 ClickHouse Cloud 上,您可以注册新账户或使用现有账户登录。不管哪种方式,都会为您创建一个新的 ClickHouse Cloud 组织,该组织与您的市场账单相联系。 + +注意:您之前 ClickHouse Cloud 注册的现有服务和组织将保持存在,但它们不会与市场账单连接。ClickHouse Cloud 允许您使用同一账户管理多个组织,每个组织具有不同的账单。 + +您可以通过 ClickHouse Cloud 控制台左下角的菜单在组织之间切换。 + +### 我是现有的 ClickHouse Cloud 用户。如果我希望现有服务通过市场计费,我该怎么做?​ {#i-am-an-existing-clickhouse-cloud-user-what-should-i-do-if-i-want-my-existing-services-to-be-billed-via-marketplace} + +您需要通过云服务提供商市场订阅 ClickHouse Cloud。完成市场的订阅后,重定向到 ClickHouse Cloud,您将有机会将现有的 ClickHouse Cloud 组织链接到市场账单。从那时起,您的现有资源将通过市场进行计费。 + +市场注册和组织链接 + +您可以通过组织的账单页面确认计费现在确实已链接到市场。如果遇到任何问题,请联系 [ClickHouse Cloud 支持](https://clickhouse.com/support/program)。 + +:::note +您之前 ClickHouse Cloud 注册的现有服务和组织将保持存在,并且不会与市场账单连接。 +::: + +### 我作为市场用户订阅了 ClickHouse Cloud。如何取消订阅?​ {#i-subscribed-to-clickhouse-cloud-as-a-marketplace-user-how-can-i-unsubscribe} + +请注意,您可以简单地停止使用 ClickHouse Cloud,并删除所有现有 ClickHouse Cloud 服务。尽管订阅仍然有效,但您将不会支付任何费用,因为 ClickHouse Cloud 没有任何定期费用。 + +如果要取消订阅,请导航到云服务提供商控制台并在那里取消订阅续订。一旦订阅结束,所有现有服务将停止,并且您将被提示添加信用卡。如果没有添加卡,两个星期后所有现有服务将被删除。 + +### 我作为市场用户订阅了 ClickHouse Cloud,然后取消了订阅。现在我想重新订阅,流程是什么?​ {#i-subscribed-to-clickhouse-cloud-as-a-marketplace-user-and-then-unsubscribed-now-i-want-to-subscribe-back-what-is-the-process} + +在这种情况下,请像往常一样订阅 ClickHouse Cloud(请参阅通过市场订阅 ClickHouse Cloud 的部分)。 + +- 对于 AWS 市场,将创建一个新的 ClickHouse Cloud 组织并连接到市场。 +- 对于 GCP 市场,您的旧组织将被重新激活。 + +如果您在重新激活市场组织时遇到任何问题,请联系 [ClickHouse Cloud 支持](https://clickhouse.com/support/program)。 + +### 我如何访问我对 ClickHouse Cloud 服务的市场订阅的发票?​ {#how-do-i-access-my-invoice-for-my-marketplace-subscription-to-the-clickhouse-cloud-service} + +- [AWS 账单控制台](https://us-east-1.console.aws.amazon.com/billing/home) +- [GCP 市场订单](https://console.cloud.google.com/marketplace/orders)(选择您用于订阅的账单账户) + +### 使用状态报表上的日期为何与我的市场发票不符?​ {#why-do-the-dates-on-the-usage-statements-not-match-my-marketplace-invoice} + +市场账单遵循日历月周期。例如,对于 12 月 1 日至 1 月 1 日之间的使用,将于 1 月 3 日至 1 月 5 日之间生成发票。 + +ClickHouse Cloud 使用报表遵循不同的计费周期,其中使用情况是从注册之日起的 30 天内计量和报告的。 + +如果这些日期不相同,使用和发票日期会有所不同。由于使用状态按天跟踪特定服务的使用,用户可以依赖状态查看费用明细。 + +### 我在哪里可以找到一般账单信息?​ {#where-can-i-find-general-billing-information} + +请参阅 [账单概述页面](/cloud/manage/billing)。 + +### 通过云服务提供商市场付款和直接向 ClickHouse 付款在 ClickHouse Cloud 定价上有什么区别吗? {#is-there-a-difference-in-clickhouse-cloud-pricing-whether-paying-through-the-cloud-provider-marketplace-or-directly-to-clickhouse} + +市场账单和直接与 ClickHouse 注册之间的定价没有区别。在这两种情况下,您对 ClickHouse Cloud 的使用以 ClickHouse Cloud 积分(CHCs)跟踪,使用方式和计费方式相同。 + +### 我可以设置多个 ClickHouse 组织以计费到单个云市场账单账户或子账户(AWS、GCP 或 Azure)吗? {#multiple-organizations-to-bill-to-single-cloud-marketplace-account} + +单个 ClickHouse 组织只能配置为计费到单个云市场账单账户或子账户。 + +### 如果我的 ClickHouse 组织通过云市场的承诺支出协议计费,当我用尽积分时,我会自动转到按需支付计费吗? {#automatically-move-to-PAYG-when-running-out-of-credit} + +如果您的市场承诺支出合同有效且您用尽了积分,我们将自动将您的组织转到按需支付计费。但是,当您现有的合同到期时,您将需要将新的市场合同链接到您的组织,或通过信用卡将您的组织转到直接计费。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/overview.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/overview.md.hash new file mode 100644 index 00000000000..90a70f79a97 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/02_marketplace/overview.md.hash @@ -0,0 +1 @@ +4c6110e02b52f2cf diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/03_clickpipes/clickpipes_for_cdc.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/03_clickpipes/clickpipes_for_cdc.md new file mode 100644 index 00000000000..ebcba1ea056 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/03_clickpipes/clickpipes_for_cdc.md @@ -0,0 +1,145 @@ +--- +'sidebar_label': 'PostgreSQL CDC' +'slug': '/cloud/reference/billing/clickpipes/postgres-cdc' +'title': 'ClickPipes for PostgreSQL CDC' +'description': 'PostgreSQL CDC ClickPipes 的计费概述' +'doc_type': 'reference' +--- + + +# ClickPipes for PostgreSQL CDC {#clickpipes-for-postgresql-cdc} + +本节概述了 ClickPipes 中 Postgres 数据变更捕获 (CDC) 连接器的定价模型。在设计此模型时,目标是在保持价格高度竞争的同时,忠实于我们的核心愿景: + +> 使客户能够无缝且实惠地将数据从 Postgres 移动到 ClickHouse 以进行实时分析。 + +该连接器的成本优于外部 ETL 工具和其他数据库平台中类似功能的 **5 倍以上**。 + +:::note +从 **2025 年 9 月 1 日** 起,所有使用 Postgres CDC ClickPipes 的客户(包括现有客户和新客户)开始按月计费。 +::: + +## 定价维度 {#pricing-dimensions} + +定价主要包括两个维度: + +1. **已摄取数据**:来自 Postgres 的原始未压缩字节,已摄取到 ClickHouse 中。 +2. **计算**:每个服务管理多个 Postgres CDC ClickPipes 的计算单元,与 ClickHouse Cloud 服务使用的计算单元是分开的。这部分额外的计算专门用于 Postgres CDC ClickPipes。计算是按服务层级计费,而不是按单个管道计费。每个计算单元包括 2 个 vCPU 和 8 GB 的 RAM。 + +### 已摄取数据 {#ingested-data} + +Postgres CDC 连接器主要分为两个阶段: + +- **初始加载 / 重新同步**:这会捕获 Postgres 表的完整快照,并在第一次创建或重新同步管道时发生。 +- **持续复制 (CDC)**:从 Postgres 到 ClickHouse 的变更的持续复制,例如插入、更新、删除和模式更改。 + +在大多数用例中,持续复制占 ClickPipe 生命周期的 90% 以上。由于初始加载涉及一次性传输大量数据,因此我们对该阶段提供了较低的费率。 + +| 阶段 | 费用 | +|----------------------------------|--------------| +| **初始加载 / 重新同步** | 每 GB $0.10 | +| **持续复制 (CDC)** | 每 GB $0.20 | + +### 计算 {#compute} + +该维度覆盖了专用于 Postgres ClickPipes 的每个服务所配置的计算单元。计算在同一服务中所有 Postgres 管道之间共享。**当第一个 Postgres 管道创建时会配置计算,在没有 Postgres CDC 管道时会释放计算。** 配置的计算量取决于您组织的层级: + +| 层级 | 费用 | +|------------------------------|-----------------------------------------------| +| **基本层** | 每服务 0.5 计算单元 - 每小时 $0.10 | +| **规模或企业层** | 每服务 1 计算单元 - 每小时 $0.20 | + +### 示例 {#example} + +假设您的服务处于规模层,并且有以下设置: + +- 2 个 Postgres ClickPipes 正在进行持续复制 +- 每个管道每月摄取 500 GB 的数据变化 (CDC) +- 当第一个管道启动时,服务根据规模层为 Postgres CDC 配置了 **1 个计算单元** + +#### 每月费用明细 {#cost-breakdown} + +**已摄取数据 (CDC)**: + +$$ 2 \text{ pipes} \times 500 \text{ GB} = 1,000 \text{ GB per month} $$ + +$$ 1,000 \text{ GB} \times \$0.20/\text{GB} = \$200 $$ + +**计算**: + +$$1 \text{ compute unit} \times \$0.20/\text{hr} \times 730 \text{ hours (approximate month)} = \$146$$ + +:::note +计算在两个管道之间共享 +::: + +**每月总费用**: + +$$\$200 \text{ (ingest)} + \$146 \text{ (compute)} = \$346$$ + +## Postgres CDC ClickPipes 常见问题解答 {#faq-postgres-cdc-clickpipe} + +
+ +定价中测量的已摄取数据是基于压缩大小还是未压缩大小? + +已摄取数据是指来自 Postgres 的 _未压缩数据_ — 无论是在初始加载和 CDC(通过复制槽)。Postgres 默认在传输过程中不压缩数据,ClickPipe 处理的是原始未压缩字节。 + +
+ +
+ +Postgres CDC 的定价何时开始出现在我的账单上? + +Postgres CDC ClickPipes 的定价从 **2025 年 9 月 1 日** 开始出现在所有客户(现有客户和新客户)的月账单上。 + +
+ +
+ +如果我暂停我的管道,会被收费吗? + +在管道暂停期间不收取数据摄取费用,因为没有数据被移动。但是,依然会收取计算费用 — 0.5 或 1 个计算单元 — 具体取决于您组织的层级。这是一个固定的服务层级费用,适用于该服务内的所有管道。 + +
+ +
+ +我如何估算我的定价? + +ClickPipes 中的概述页面提供了初始加载/重新同步和 CDC 数据量的指标。您可以结合这些指标和 ClickPipes 定价来估算您的 Postgres CDC 成本。 + +
+ +
+ +我可以为我的服务扩展分配给 Postgres CDC 的计算吗? + +默认情况下,计算扩展无法由用户配置。配置的资源经过优化以最佳处理大多数客户工作负载。如果您的用例需要更多或更少的计算,请提交支持票以便我们评估您的请求。 + +
+ +
+ +定价粒度是什么? + +- **计算**:按小时计费。部分小时将四舍五入到下一个小时。 +- **已摄取数据**:根据未压缩数据的千兆字节 (GB) 进行测量和计费。 + +
+ +
+ +我可以为通过 ClickPipes 的 Postgres CDC 使用我的 ClickHouse Cloud 额度吗? + +可以。ClickPipes 定价是统一 ClickHouse Cloud 定价的一部分。您拥有的任何平台额度将自动适用于 ClickPipes 的使用。 + +
+ +
+ +我可以预期在现有的 ClickHouse Cloud 月支出中, Postgres CDC ClickPipes 会增加多少额外成本? + +成本因您的用例、数据量和组织层级而异。也就是说,大多数现有客户在试用后相较于现有的 ClickHouse Cloud 月支出看到的增加为 **0–15%**。实际成本可能因工作负载而异—一些工作负载涉及大量数据而处理较少,而其他工作负载要求更多处理但数据较少。 + +
diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/03_clickpipes/clickpipes_for_cdc.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/03_clickpipes/clickpipes_for_cdc.md.hash new file mode 100644 index 00000000000..a941a4fcd16 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/03_clickpipes/clickpipes_for_cdc.md.hash @@ -0,0 +1 @@ +407023e5d67679c6 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/03_clickpipes/clickpipes_for_streaming_and_object_storage.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/03_clickpipes/clickpipes_for_streaming_and_object_storage.md new file mode 100644 index 00000000000..085edccb473 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/03_clickpipes/clickpipes_for_streaming_and_object_storage.md @@ -0,0 +1,86 @@ +--- +'sidebar_label': '流式和对象存储' +'slug': '/cloud/reference/billing/clickpipes/streaming-and-object-storage' +'title': 'ClickPipes 用于流式和对象存储' +'description': '流式和对象存储 ClickPipes 计费概述' +'doc_type': 'reference' +--- + +import ClickPipesFAQ from '../../../_snippets/_clickpipes_faq.md' + + +# ClickPipes 用于流式传输和对象存储 {#clickpipes-for-streaming-object-storage} + +本节概述了 ClickPipes 用于流式传输和对象存储的定价模型。 + +## ClickPipes 定价结构是什么样的? {#what-does-the-clickpipes-pricing-structure-look-like} + +它由两个维度组成: + +- **计算**:每单位每小时的价格。 + 计算代表了运行 ClickPipes 副本 Pod 的成本,无论它们是否积极接收数据。 + 它适用于所有 ClickPipes 类型。 +- **接收的数据**:按每 GB 的价格。 + 接收的数据费率适用于所有流式 ClickPipes + (Kafka, Confluent, Amazon MSK, Amazon Kinesis, Redpanda, WarpStream, Azure Event Hubs), + 适用于通过副本 Pod 传输的数据。接收的数据大小(GB)是基于从源接收的字节(未压缩或压缩)收费。 + +## 什么是 ClickPipes 副本? {#what-are-clickpipes-replicas} + +ClickPipes 通过独立的基础设施从远程数据源接收数据, +该基础设施独立于 ClickHouse Cloud 服务运行和扩展。 +因此,它使用专用的计算副本。 + +## 默认副本的数量和大小是多少? {#what-is-the-default-number-of-replicas-and-their-size} + +每个 ClickPipe 默认提供 1 个副本,配备 512 MiB 的 RAM 和 0.125 vCPU (XS)。 +这相当于 **0.0625** ClickHouse 计算单位(1 单位 = 8 GiB RAM, 2 vCPUs)。 + +## ClickPipes 的公开价格是什么? {#what-are-the-clickpipes-public-prices} + +- 计算:每单位每小时 \$0.20(默认副本大小下每副本每小时 \$0.0125) +- 接收的数据:每 GB \$0.04 + +计算维度的价格取决于 ClickPipe 中副本的 **数量** 和 **大小**。默认副本大小可以通过垂直扩展进行调整,且每个副本大小的定价如下: + +| 副本大小 | 计算单位 | RAM | vCPU | 每小时价格 | +|-------------------------|-----------|---------|--------|--------------| +| 超小型 (XS) (默认) | 0.0625 | 512 MiB | 0.125 | \$0.0125 | +| 小型 (S) | 0.125 | 1 GiB | 0.25 | \$0.025 | +| 中型 (M) | 0.25 | 2 GiB | 0.5 | \$0.05 | +| 大型 (L) | 0.5 | 4 GiB | 1.0 | \$0.10 | +| 特大 (XL) | 1.0 | 8 GiB | 2.0 | \$0.20 | + +## 在一个示例中如何体现? {#how-does-it-look-in-an-illustrative-example} + +以下示例假设有一个 M 大小的单一副本,除非明确提及。 + + + + + + + + + + + + + + + + + + + + + + +
100 GB 在 24 小时内1 TB 在 24 小时内10 TB 在 24 小时内
流式 ClickPipe(0.25 x 0.20 x 24) + (0.04 x 100) = \$5.20(0.25 x 0.20 x 24) + (0.04 x 1000) = \$41.20使用 4 个副本:

(0.25 x 0.20 x 24 x 4) + (0.04 x 10000) = \$404.80
对象存储 ClickPipe $^*$(0.25 x 0.20 x 24) = \$1.20(0.25 x 0.20 x 24) = \$1.20(0.25 x 0.20 x 24) = \$1.20
+ +$^1$ _仅 ClickPipes 的计算用于编排, +有效的数据传输由底层 Clickhouse 服务承担_ + +## 流式传输和对象存储 ClickPipes 的常见问题解答 {#faq-streaming-and-object-storage} + + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/03_clickpipes/clickpipes_for_streaming_and_object_storage.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/03_clickpipes/clickpipes_for_streaming_and_object_storage.md.hash new file mode 100644 index 00000000000..55d8de6bf33 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/03_clickpipes/clickpipes_for_streaming_and_object_storage.md.hash @@ -0,0 +1 @@ +c2d99d1ec34dd403 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/03_clickpipes/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/03_clickpipes/index.md new file mode 100644 index 00000000000..2b9e9775b5a --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/03_clickpipes/index.md @@ -0,0 +1,19 @@ +--- +'slug': '/cloud/reference/billing/clickpipes' +'title': 'ClickPipes' +'description': 'ClickPipes 计费' +'keywords': +- 'ClickPipes Billing' +'doc_type': 'reference' +--- + +:::note +在达到一般可用性 (GA) 之前,MySQL 和 MongoDB CDC 的 ClickPipes 使用是免费的。客户将在 GA 启动之前收到通知,以审查和优化他们的 ClickPipes 使用。 +::: + +[ClickPipes](/integrations/clickpipes) 的计费基于 **计算使用** 和 **摄取数据**。有关每个类别的定价模型的更多信息,请参阅专门的计费页面: + +| 页面 | 描述 | +|-------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| [ClickPipes for Postgres CDC](/cloud/reference/billing/clickpipes/postgres-cdc) | PostgreSQL CDC ClickPipes 的定价。 | +| [ClickPipes for streaming and object storage](/cloud/reference/billing/clickpipes/streaming-and-object-storage) | 流式和对象存储 ClickPipes 的定价。 | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/03_clickpipes/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/03_clickpipes/index.md.hash new file mode 100644 index 00000000000..1d7a55b7bdd --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/03_clickpipes/index.md.hash @@ -0,0 +1 @@ +5facb108629b3cf7 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/04_network-data-transfer.mdx b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/04_network-data-transfer.mdx new file mode 100644 index 00000000000..0bb74d53f29 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/04_network-data-transfer.mdx @@ -0,0 +1,40 @@ +--- +'sidebar_label': '数据传输' +'slug': '/cloud/manage/network-data-transfer' +'title': '数据传输' +'description': '了解 ClickHouse Cloud 如何计量传入和传出的数据' +'doc_type': 'guide' +--- + +import NetworkPricing from '@site/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/_snippets/_network_transfer_rates.md'; + +ClickHouse Cloud 监测传入和传出的数据。 +这包括进入和离开 ClickHouse Cloud 的所有数据,以及任何区域内和跨区域的数据传输。该使用情况在服务级别进行跟踪。根据这个使用情况,客户会产生数据传输费用,然后将这些费用添加到每月账单中。 + +ClickHouse Cloud 对以下内容收费: +- 从 ClickHouse Cloud 到公共互联网的数据传出,包括到其他云服务提供商的其他区域。 +- 向同一云服务提供商的另一个区域的数据传出。 + +区域内的数据传输或私有链接/私有服务连接的使用和数据传输不收费。然而,如果我们发现影响我们合理收费能力的使用模式,我们保留实施额外数据传输定价维度的权利。 + +注意:私有链接/私有服务连接的使用会产生云服务提供商(CSP)费用。请参考 CSP 的定价页面以获取最新信息。 + +数据传输费用因云服务提供商(CSP)和区域而异。 +公共互联网传出的定价仅基于源区域。 +跨区域(或区域间)定价取决于源区域和目标区域。 + +**最佳实践以最小化数据传输成本** + +在传入和传出数据时,有一些模式需要牢记,以最小化数据传输成本。 + +1. 在从 ClickHouse Cloud 传入或传出数据时,尽可能使用压缩,以减少传输的数据量及相关成本。 + +2. 请注意,当使用非内联值通过原生协议进行 INSERT(例如 `INSERT INTO [TABLE] FROM INFILE [FILE] FORMAT NATIVE`)时,ClickHouse 客户端会从服务器提取元数据以打包数据。如果元数据的大小大于 `INSERT` 有效负载,您可能会违反直觉地看到从服务器的传出数据比传入数据更多。如果这是不可接受的,考虑使用 `VALUES` 语法进行内联数据或使用 HTTP 协议。 + +下表显示了不同云服务提供商和区域的公共互联网或跨区域的传出数据传输费用的变化情况。 + +:::note +ClickHouse Cloud 在区域间使用情况方面按层级进行监测,从第 1 层到第 4 层,根据源区域和目标区域。下表显示每个区域间数据传输组合的层级。在 ClickHouse Cloud 的计费使用屏幕中,您将看到按层级划分的数据传输使用情况。 +::: + + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/04_network-data-transfer.mdx.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/04_network-data-transfer.mdx.hash new file mode 100644 index 00000000000..6d23c14fe2f --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/04_network-data-transfer.mdx.hash @@ -0,0 +1 @@ +b0d85817fdba1778 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/05_payment-thresholds.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/05_payment-thresholds.md new file mode 100644 index 00000000000..5e3c9ee4792 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/05_payment-thresholds.md @@ -0,0 +1,25 @@ +--- +'sidebar_label': 'Payment Thresholds' +'slug': '/cloud/billing/payment-thresholds' +'title': '支付阈值' +'description': '支付阈值和自动开票用于 ClickHouse Cloud.' +'keywords': +- 'billing' +- 'payment thresholds' +- 'automatic invoicing' +- 'invoice' +'doc_type': 'guide' +--- + + +# 付款阈值 + +当您在 ClickHouse Cloud 的账单周期内应付金额达到 10,000 美元或等值金额时,您的付款方式将会自动扣款。扣款失败将导致在宽限期后暂停或终止您的服务。 + +:::note +此付款阈值不适用于与 ClickHouse 签订了承诺消费合同或其他谈判合同的客户。 +::: + +如果您的组织达到付款阈值的 90%,并且预计在周期中会超过付款阈值,关联该组织的账单电子邮件将收到通知邮件。当您超过付款阈值时,您也将收到通知邮件和发票。 + +这些付款阈值可以根据客户的请求或 ClickHouse 财务团队的决定调整至低于 10,000 美元。如果您有任何问题,请联系 support@clickhouse.com 获取更多详情。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/05_payment-thresholds.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/05_payment-thresholds.md.hash new file mode 100644 index 00000000000..92c1a298e49 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/05_payment-thresholds.md.hash @@ -0,0 +1 @@ +31b260c47b98ecc0 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/06_billing_compliance.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/06_billing_compliance.md new file mode 100644 index 00000000000..769589db70d --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/06_billing_compliance.md @@ -0,0 +1,91 @@ +--- +'sidebar_label': 'ClickHouse Cloud 计费合规性' +'slug': '/manage/clickhouse-cloud-billing-compliance' +'title': 'ClickHouse Cloud 计费合规性' +'description': '页面描述 ClickHouse Cloud 计费合规性' +'keywords': +- 'billing compliance' +- 'pay-as-you-go' +'doc_type': 'guide' +--- + +import billing_compliance from '@site/static/images/cloud/manage/billing_compliance.png'; +import Image from '@theme/IdealImage'; + + +# ClickHouse Cloud 账单合规性 + +## 账单合规性 {#billing-compliance} + +您使用 ClickHouse Cloud 需要您的组织配置有效的账单付款方式。在您的 30 天试用期结束或您的试用积分耗尽(以先发生者为准)后,您有以下账单选项以继续使用 ClickHouse Cloud: + +| 账单选项 | 描述 | +|------------------------------------------------------|---------------------------------------------------------------------------------------| +| [直接按需支付](#direct-payg) | 为您的组织添加有效信用卡以进行按需支付 | +| [市场按需支付](#cloud-marketplace-payg) | 通过支持的云市场供应商设置按需支付订阅 | +| [承诺支出合同](#committed-spend-contract) | 直接或通过支持的云市场签署承诺支出合同 | + +如果您的试用期结束且您的组织未配置任何账单选项,您的所有服务将被停止。 如果在两周后仍未配置账单方法,您的所有数据将被删除。 + +ClickHouse 按组织级别对服务收费。如果我们无法使用您当前的账单方法处理付款,您必须将其更新为上述三种选项之一以避免服务中断。有关根据您选择的账单方法的付款合规性的更多详细信息,请参见下文。 + +### 使用信用卡进行按需支付 {#direct-payg} + +您可以使用信用卡按月支付 ClickHouse Cloud 的使用费用。 要添加信用卡,请按照这些 [说明](#add-credit-card)。 + +ClickHouse 的每月账单周期自选择组织层级(基本版、扩展版或企业版)并在组织内创建首个服务之日起开始。 + +文件中的信用卡通常会在您的每月账单周期结束时被收费,但如果计费周期内到期金额达到 10,000 美元(有关付款阈值的更多信息,请参见 [这里](/cloud/billing/payment-thresholds))。 + +文件中的信用卡必须有效且未过期,并且有足够的可用信用额度来支付您的账单总额。如果由于任何原因我们无法收费全额到期款项,将立即适用以下未付款账单限制: + +* 您只能扩展到每个副本 120 GiB +* 如果服务已停止,您将无法启动服务 +* 您将无法启动或创建新服务 + +我们将在最多 30 天内尝试使用组织配置的账单方法处理付款。如果在 14 天后付款不成功,则组织内的所有服务将被停止。如果在此 30 天期限结束时仍未收到付款,并且我们未授予延长,则将删除与您的组织相关的所有数据和服务。 + +### 云市场按需支付账单 {#cloud-marketplace-payg} + +按需支付账单也可以通过我们支持的云市场(AWS、GCP 或 Azure)为组织收费。 要注册市场按需支付账单,请按照这些 [说明](#marketplace-payg)。 + +与直接按需支付类似,通过市场按需支付的 ClickHouse 每月账单周期从选择组织层级(基本版、扩展版或企业版)并在组织内创建首个服务之日起开始。 + +然而,由于市场的要求,我们会按小时记录您按需使用的费用。 请注意,您将根据与该市场的协议条款开具发票 - 通常是在日历月的账单周期上。 + +例如,如果您在 1 月 18 日创建了第一个组织服务,那么您在 ClickHouse Cloud 的首次账单使用周期将从 1 月 18 日持续到 2 月 17 日的结束。然而,您可能会在 2 月初收到来自云市场的首张发票。 + +但是,如果您的 PAYG 市场订阅被取消或未能自动续订,账单将退回到组织的文件信用卡上(如果有)。 若要添加信用卡,请 [联系支持](/about-us/support) 获取帮助。如果未提供有效的信用卡,将适用上述针对 [直接按需支付](#direct-payg) 的未付账单限制 - 这包括服务暂停和最终的数据删除。 + +### 承诺合同计费 {#committed-spend-contract} + +您可以通过承诺合同为您的组织购买积分,方法如下: + +1. 联系销售直接购买积分,包括 ACH 或电汇等付款选项。付款条款将在适用的订单表中列出。 +2. 联系销售通过我们支持的云市场之一购买积分(AWS、GCP 或 Azure)上的订阅。费用将在接受私人报价后报告给适用的云市场,并随后根据报价条款进行处理,但您将根据与该市场的协议条款开具发票。要通过市场付款,请按照这些 [说明](#marketplace-payg)。 + +应用于组织的积分(例如,通过承诺合同或退款)在订单表或接受的私人报价中指定的期限内供您使用。 +积分自授予积分之日开始消耗,具体的账单周期根据选择的第一个组织层级(基本版、扩展版或企业版)日期来决定。 + +如果一个组织 **不** 在云市场的承诺合同中且积分用完或积分过期,组织将自动切换到按需支付(PAYG)账单。在这种情况下,我们将尝试使用组织的文件信用卡对付款进行处理(如果有)。 + +如果一个组织 **在** 云市场的承诺合同中且积分用完,则其也将自动切换到通过同一市场支付的 PAYG 账单,用于剩余的订阅。 然而,如果订阅未续订并过期,我们将尝试使用组织的文件信用卡进行付款处理(如果有)。 + +在这两种情况下,如果我们无法对配置的信用卡收费,将适用上述针对 [按需支付(PAYG)](#direct-payg) 账单的未付款限制——这包括服务暂停。 但是,对于承诺合同客户,我们将在启动数据删除之前与您联系有关任何未付款的发票。 数据不会在任何时间段后自动删除。 + +如果您希望在现有积分到期或耗尽之前添加额外积分,请 [联系我们](https://clickhouse.com/company/contact)。 + +### 如何使用信用卡付款 {#add-credit-card} + +请前往 ClickHouse Cloud UI 的账单部分,点击“添加信用卡”按钮(如下图所示)完成设置。如果您有任何问题,请 [联系支持](/about-us/support) 获取帮助。 + +如何添加信用卡 + +## 如何通过市场付款 {#marketplace-payg} + +如果您想通过我们支持的任何市场(AWS、GCP 或 Azure)付款,您可以按照 [这些步骤](/cloud/marketplace/marketplace-billing) 获取帮助。 对于与云市场账单相关的任何问题,请直接联系云服务提供商。 + +解决市场账单问题的有用链接: +* [AWS 账单常见问题](https://aws.amazon.com/aws-cost-management/aws-billing/faqs/) +* [GCP 账单常见问题](https://cloud.google.com/compute/docs/billing-questions) +* [Azure 账单常见问题](https://learn.microsoft.com/en-us/azure/cost-management-billing/cost-management-billing-faq) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/06_billing_compliance.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/06_billing_compliance.md.hash new file mode 100644 index 00000000000..769b998bf05 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/06_billing_compliance.md.hash @@ -0,0 +1 @@ +da73e3abb8bca843 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/index.md new file mode 100644 index 00000000000..74d73450fa1 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/index.md @@ -0,0 +1,20 @@ +--- +'slug': '/cloud/manage/billing' +'title': '账单' +'description': '账单的目录页。' +'keywords': +- 'billing' +- 'payment thresholds' +- 'trouble shooting' +- 'marketplace' +'doc_type': 'landing-page' +--- + +该文档的这一部分涵盖与计费相关的主题,并包含以下页面: + +| 页面 | 描述 | +|---------------------------------------|------------------------------------------------------------------| +| [概述](/cloud/marketplace/marketplace-billing) | 市场计费的概述和常见问题页面。 | +| [付款阈值](/cloud/billing/payment-thresholds) | 了解付款阈值的工作原理以及如何调整它们。 | +| [排查计费问题](/manage/clickhouse-cloud-billing-compliance) | 排查常见的计费问题。 | +| [市场](/cloud/manage/marketplace/) | 进一步市场相关主题的着陆页。 | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/index.md.hash new file mode 100644 index 00000000000..ef273ec4e58 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/03_billing/index.md.hash @@ -0,0 +1 @@ +f406ebed6a29f9ab diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/supported-regions.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/05_supported-regions.md similarity index 55% rename from i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/supported-regions.md rename to i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/05_supported-regions.md index a614bd46130..b1b474a170a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/supported-regions.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/05_supported-regions.md @@ -8,8 +8,9 @@ - 'azure' - 'cloud' - 'regions' -'description': 'ClickHouse Cloud 的支持区域' +'description': '支持 ClickHouse Cloud 的区域' 'slug': '/cloud/reference/supported-regions' +'doc_type': 'reference' --- import EnterprisePlanFeatureBadge from '@theme/badges/EnterprisePlanFeatureBadge' @@ -28,16 +29,16 @@ import EnterprisePlanFeatureBadge from '@theme/badges/EnterprisePlanFeatureBadge - eu-west-2 (伦敦) - me-central-1 (阿联酋) - us-east-1 (北弗吉尼亚) -- us-east-2 (俄亥俄) -- us-west-2 (俄勒冈) +- us-east-2 (俄亥俄州) +- us-west-2 (俄勒冈州) -**考虑中:** +**私有区域:** - ca-central-1 (加拿大) - af-south-1 (南非) - eu-north-1 (斯德哥尔摩) -- sa-east-1 (南美) +- sa-east-1 (南美洲) - ap-northeast-2 (韩国,首尔) - + ## Google Cloud 区域 {#google-cloud-regions} - asia-southeast1 (新加坡) @@ -45,9 +46,9 @@ import EnterprisePlanFeatureBadge from '@theme/badges/EnterprisePlanFeatureBadge - us-central1 (爱荷华) - us-east1 (南卡罗来纳) -**考虑中:** +**私有区域:** -- us-west1 (俄勒冈) +- us-west1 (俄勒冈州) - australia-southeast1 (悉尼) - asia-northeast1 (东京) - europe-west3 (法兰克福) @@ -56,42 +57,44 @@ import EnterprisePlanFeatureBadge from '@theme/badges/EnterprisePlanFeatureBadge ## Azure 区域 {#azure-regions} -- 美国西部 3 (亚利桑那) -- 美国东部 2 (弗吉尼亚) +- 西美国 3 (亚利桑那州) +- 东美国 2 (弗吉尼亚州) - 德国西部中心 (法兰克福) -**考虑中:** +**私有区域:** + +- 日本东部 -日本东部 :::note -需要部署到当前未列出的区域?[提交请求](https://clickhouse.com/pricing?modal=open)。 +需要部署到当前未列出的区域吗?[提交请求](https://clickhouse.com/pricing?modal=open)。 ::: ## 私有区域 {#private-regions} -我们为企业级服务提供私有区域。请[联系我们](https://clickhouse.com/company/contact)以提交私有区域请求。 +我们为我们的企业级服务提供私有区域。请[联系我们](https://clickhouse.com/company/contact)以请求私有区域。 私有区域的关键考虑事项: - 服务不会自动扩展。 -- 服务无法停止或闲置。 -- 可以通过支持票启用手动扩展(纵向和横向)。 -- 如果某项服务需要使用 CMEK 配置,客户必须在服务启动时提供 AWS KMS 密钥。 -- 要启动新的和额外的服务,需通过支持票进行请求。 +- 服务不能停止或闲置。 +- 可以通过支持票启用手动扩展(包括垂直和水平)。 +- 如果服务需要与 CMEK 配置,则客户必须在服务启动时提供 AWS KMS 密钥。 +- 对于新服务和额外服务的启动,请通过支持票提出请求。 -关于 HIPAA 合规性可能有额外要求(包括签署 BAA)。请注意,HIPAA 目前仅可用于企业级服务。 +可能还适用于 HIPAA 合规性(包括签署 BAA)。请注意,HIPAA 目前仅适用于企业级服务。 ## HIPAA 合规区域 {#hipaa-compliant-regions} -客户必须签署商业伙伴协议 (BAA) 并通过销售或支持请求入驻,以便在 HIPAA 合规区域设置服务。支持 HIPAA 合规性的区域包括: +客户必须签署商业合作协议(BAA),并通过销售或支持请求入驻,以在 HIPAA 合规区域设置服务。支持 HIPAA 合规性区域如下: - AWS eu-central-1 (法兰克福) - AWS eu-west-2 (伦敦) - AWS us-east-1 (北弗吉尼亚) -- AWS us-east-2 (俄亥俄) -- AWS us-west-2 (俄勒冈) +- AWS us-east-2 (俄亥俄州) +- AWS us-west-2 (俄勒冈州) +- GCP europe-west4 (荷兰) - GCP us-central1 (爱荷华) - GCP us-east1 (南卡罗来纳) @@ -99,9 +102,9 @@ import EnterprisePlanFeatureBadge from '@theme/badges/EnterprisePlanFeatureBadge -客户必须通过销售或支持请求入驻,以便在 PCI 合规区域设置服务。支持 PCI 合规性的区域包括: +客户必须通过销售或支持请求入驻,以在 PCI 合规区域设置服务。支持 PCI 合规性的区域如下: - AWS eu-central-1 (法兰克福) - AWS eu-west-2 (伦敦) - AWS us-east-1 (北弗吉尼亚) -- AWS us-east-2 (俄亥俄) -- AWS us-west-2 (俄勒冈) +- AWS us-east-2 (俄亥俄州) +- AWS us-west-2 (俄勒冈州) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/05_supported-regions.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/05_supported-regions.md.hash new file mode 100644 index 00000000000..49a19547a7c --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/05_supported-regions.md.hash @@ -0,0 +1 @@ +845fcc489bddcfb3 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/06_service-uptime.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/06_service-uptime.md new file mode 100644 index 00000000000..6cfe1232bad --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/06_service-uptime.md @@ -0,0 +1,15 @@ +--- +'sidebar_label': '服务正常运行时间和SLA' +'slug': '/cloud/manage/service-uptime' +'title': '服务正常运行时间' +'description': '用户现在可以在状态页面上查看区域正常运行时间,并订阅服务中断的警报。' +'doc_type': 'reference' +--- + +## Uptime alerts {#uptime-alerts} + +用户现在可以在 [status page](https://status.clickhouse.com/) 上查看区域正常运行时间,并订阅服务中断的警报。 + +## SLA {#sla} + +我们还为特定的承诺支出合同提供服务级别协议。请通过 [sales@clickhouse.com](mailto:sales@clickhouse.com) 联系我们以了解更多关于我们的 SLA 政策的信息。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/06_service-uptime.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/06_service-uptime.md.hash new file mode 100644 index 00000000000..bf193792714 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/06_service-uptime.md.hash @@ -0,0 +1 @@ +41614db63d69cb5d diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/settings.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/08_settings.md similarity index 50% rename from i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/settings.md rename to i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/08_settings.md index dd97706b82f..29e78217473 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/settings.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/08_settings.md @@ -3,6 +3,7 @@ 'slug': '/manage/settings' 'title': '配置设置' 'description': '如何为特定用户或角色配置您的 ClickHouse Cloud 服务的设置' +'doc_type': 'guide' --- import Image from '@theme/IdealImage'; @@ -11,10 +12,10 @@ import cloud_settings_sidebar from '@site/static/images/cloud/manage/cloud-setti # 配置设置 -要为特定的 [用户](/operations/access-rights#user-account-management) 或 [角色](/operations/access-rights#role-management) 指定 ClickHouse Cloud 服务的设置,您必须使用 [基于 SQL 的设置轮廓](/operations/access-rights#settings-profiles-management)。应用设置轮廓可确保您配置的设置保持有效,即使当您的服务停止、闲置或升级时。要了解有关设置轮廓的更多信息,请参见 [此页面](/operations/settings/settings-profiles.md)。 +要为特定的 [用户](/operations/access-rights#user-account-management) 或 [角色](/operations/access-rights#role-management) 指定 ClickHouse Cloud 服务的设置,您必须使用 [基于 SQL 的设置配置文件](/operations/access-rights#settings-profiles-management)。应用设置配置文件可确保您配置的设置在服务停止、空闲和升级时依然有效。要了解有关设置配置文件的更多信息,请参阅 [此页面](/operations/settings/settings-profiles.md)。 -请注意,当前不支持基于 XML 的设置轮廓和 [配置文件](/operations/configuration-files.md) 用于 ClickHouse Cloud。 +请注意,基于 XML 的设置配置文件和 [配置文件](/operations/configuration-files.md) 当前不支持 ClickHouse Cloud。 -要了解您可以为 ClickHouse Cloud 服务指定的设置,您可以在 [我们的文档](/operations/settings) 中查看按类别列出的所有可能设置。 +要了解您可以为 ClickHouse Cloud 服务指定的设置,请在 [我们的文档](/operations/settings) 中查看按类别列出的所有可能设置。 Cloud settings sidebar diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/08_settings.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/08_settings.md.hash new file mode 100644 index 00000000000..d5ccbc91d0a --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/08_settings.md.hash @@ -0,0 +1 @@ +aed3476964ed957f diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/09_security/_category_.json b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/09_security/_category_.json new file mode 100644 index 00000000000..aed26fa7f7a --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/09_security/_category_.json @@ -0,0 +1,5 @@ +{ + "label": "Security", + "collapsible": true, + "collapsed": true, +} \ No newline at end of file diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/audit-logging.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/09_security/audit-logging.md similarity index 52% rename from i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/audit-logging.md rename to i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/09_security/audit-logging.md index 613505675a3..821e0d16872 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/audit-logging.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/09_security/audit-logging.md @@ -1,9 +1,9 @@ --- -'sidebar_label': 'Audit Logging' +'sidebar_label': '审计日志' 'slug': '/cloud/security/audit-logging' 'title': '审计日志' -'description': '本页面描述了 ClickHouse Cloud 中的审计日志。它解释了如何访问和解释审计日志,这些日志记录了对 ClickHouse - Cloud 组织所做的更改。' +'description': '此页面描述了ClickHouse Cloud中的审计日志。它解释了如何访问和解读审计日志,这些日志记录了对ClickHouse Cloud组织所做的更改。' +'doc_type': 'reference' --- import Image from '@theme/IdealImage'; @@ -17,9 +17,9 @@ import activity_log_3 from '@site/static/images/cloud/security/activity_log3.png
-在左侧菜单中选择 **Audit** 标签,以查看对您的 ClickHouse Cloud 组织所做的更改 - 包括谁做的更改及其发生的时间。 +在左侧菜单中选择 **Audit** 选项卡,以查看对您的 ClickHouse Cloud 组织所做的更改,包括更改的执行者及其发生的时间。 -**Activity** 页面显示包含关于您组织的事件列表的表格。默认情况下,此列表按时间倒序排列(最新事件在顶部)。通过点击列标题更改表格的排序。表格中的每个项目包含以下字段: +**Activity** 页面显示一个包含关于您组织的事件日志的表格。默认情况下,此列表按逆时间顺序排序(最新事件在顶部)。通过点击列标题可以更改表格的顺序。表格的每个条目包含以下字段: - **Activity:** 描述事件的文本片段 - **User:** 发起事件的用户 @@ -30,7 +30,7 @@ import activity_log_3 from '@site/static/images/cloud/security/activity_log3.png
-您可以使用提供的搜索栏根据某些标准(例如服务名称或 IP 地址)隔离事件。您还可以将此信息导出为 CSV 格式,以便在外部工具中分发或分析。 +您可以使用提供的搜索栏根据某些标准(如服务名称或 IP 地址)来隔离事件。您还可以将此信息导出为 CSV 格式,以便在外部工具中进行分发或分析。
ClickHouse Cloud Activity CSV export @@ -38,7 +38,7 @@ import activity_log_3 from '@site/static/images/cloud/security/activity_log3.png ## 记录的事件列表 {#list-of-events-logged} -为组织捕获的不同类型事件被分为 3 类:**Service**、**Organization** 和 **User**。记录的事件列表包含: +为组织捕获的不同类型事件分为三个类别:**Service**、**Organization** 和 **User**。记录的事件列表包括: ### Service {#service} @@ -46,9 +46,9 @@ import activity_log_3 from '@site/static/images/cloud/security/activity_log3.png - 删除服务 - 停止服务 - 启动服务 -- 更改服务名称 -- 更改服务 IP 访问列表 -- 重置服务密码 +- 服务名称更改 +- 服务 IP 访问列表更改 +- 服务密码重置 ### Organization {#organization} @@ -67,4 +67,4 @@ import activity_log_3 from '@site/static/images/cloud/security/activity_log3.png ## 审计事件的 API {#api-for-audit-events} -用户可以使用 ClickHouse Cloud API `activity` 端点获取审计事件的导出。更多详细信息请参考 [API reference](https://clickhouse.com/docs/cloud/manage/api/swagger)。 +用户可以使用 ClickHouse Cloud API 的 `activity` 端点获取审计事件的导出。详细信息请参阅 [API reference](https://clickhouse.com/docs/cloud/manage/api/swagger)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/09_security/audit-logging.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/09_security/audit-logging.md.hash new file mode 100644 index 00000000000..83f363c34aa --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/09_security/audit-logging.md.hash @@ -0,0 +1 @@ +13600d3d66f63760 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/09_security/privacy_and_compliance/_category_.json b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/09_security/privacy_and_compliance/_category_.json new file mode 100644 index 00000000000..99beeb3e924 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/09_security/privacy_and_compliance/_category_.json @@ -0,0 +1,6 @@ +{ + "label": "Privacy and compliance", + "collapsible": true, + "collapsed": true, + "link": { "type": "doc", "id": "cloud/reference/security/privacy_and_compliance/index" } +} \ No newline at end of file diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/09_security/privacy_and_compliance/compliance-overview.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/09_security/privacy_and_compliance/compliance-overview.md new file mode 100644 index 00000000000..e5dfc16b2c0 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/09_security/privacy_and_compliance/compliance-overview.md @@ -0,0 +1,68 @@ +--- +'title': '安全与合规报告' +'slug': '/cloud/security/compliance-overview' +'description': '关于 ClickHouse Cloud 安全与合规认证的概述,包括 SOC 2、ISO 27001、美国 DPF 和 HIPAA' +'doc_type': 'guide' +--- + +import BetaBadge from '@theme/badges/BetaBadge'; +import EnterprisePlanFeatureBadge from '@theme/badges/EnterprisePlanFeatureBadge'; + + +# 安全和合规报告 +ClickHouse Cloud 评估我们的客户的安全和合规需求,并在不断扩展该计划,以满足其他报告的请求。有关更多信息或下载报告,请访问我们的 [信任中心](https://trust.clickhouse.com)。 + +### SOC 2 Type II(自2022年起) {#soc-2-type-ii-since-2022} + +系统和组织控制(SOC)2是一份专注于安全性、可用性、机密性、处理完整性和隐私标准的报告,这些标准包含在信任服务标准(TSC)中,并适用于组织的系统,旨在向依赖方(我们的客户)提供有关这些控制的保证。ClickHouse 与独立的外部审计师合作,至少每年进行一次审计,以解决我们系统的安全性、可用性和处理完整性,以及我们系统处理的数据的机密性和隐私。该报告涉及我们的 ClickHouse Cloud 和自带云(BYOC)服务。 + +### ISO 27001(自2023年起) {#iso-27001-since-2023} + +国际标准组织(ISO)27001是信息安全的国际标准。它要求公司实施信息安全管理系统(ISMS),该系统包括管理风险、创建和传达政策、实施安全控制以及监控以确保组件保持相关和有效的流程。ClickHouse 进行内部审计,并与独立的外部审计师合作,在证书发放后的两年内进行审计和中期检查。 + +### 美国数据隐私框架(自2024年起) {#us-dpf-since-2024} + +美国数据隐私框架的制定旨在为美国组织提供可靠的机制,从欧洲联盟/欧洲经济区、英国和瑞士将个人数据传输到美国,这些机制符合欧盟、英国和瑞士法律(https://dataprivacyframework.gov/Program-Overview)。ClickHouse 自我认证该框架,并在 [数据隐私框架列表](https://dataprivacyframework.gov/list) 上列出。 + +### HIPAA(自2024年起) {#hipaa-since-2024} + + + +希望在符合 HIPAA 的区域部署服务以加载电子受保护健康信息(ePHI)的客户,可以访问控制台中的 **组织** 页面请求启用该功能。一名销售人员将联系您以获取签署的商业伙伴协议(BAA),以完成设置。部署到符合 HIPAA 区域的客户应查看我们的 [共享责任模型](/cloud/security/shared-responsibility-model),并为其用例选择和实施适当的控制。 + +《1996年健康保险流通与问责法案》(HIPAA)是一项基于美国的隐私法,专注于受保护健康信息(PHI)的管理。HIPAA 有多个要求,包括 [安全规则](https://www.hhs.gov/hipaa/for-professionals/security/index.html),该规则专注于保护电子个人健康信息(ePHI)。ClickHouse 已实施行政、物理和技术保障措施,以确保存储在指定服务中的 ePHI 的机密性、完整性和安全性。这些活动已被纳入我们的 SOC 2 Type II 报告中,可在我们的 [信任中心](https://trust.clickhouse.com) 下载。 + +### PCI 服务提供商(自2025年起) {#pci-service-provider-since-2025} + + + +希望在符合 PCI 的区域部署服务以加载持卡人数据的客户,可以访问控制台中的 **组织** 页面以启用该功能。一旦启用,客户在部署新服务时可以选择 "PCI 合规" 区域类型。部署到符合 PCI 区域的客户应查看我们在 [信任中心](https://trust.clickhouse.com) 提供的 PCI 责任概述,并为其用例选择和实施适当的控制。 + +[支付卡行业数据安全标准(PCI DSS)](https://www.pcisecuritystandards.org/standards/pci-dss/) 是由 PCI 安全标准委员会制定的一套规则,旨在保护信用卡支付数据。ClickHouse 已通过合格的安全评估员(QSA)进行外部审计,结果是根据存储信用卡数据相关的 PCI 标准通过了合规报告(ROC)。要下载我们的一份合规证明(AOC)副本和 PCI 责任概述,请访问我们的 [信任中心](https://trust.clickhouse.com)。 + + +# 隐私合规 + +除了上述项目,ClickHouse 还维护内部合规程序,以应对一般数据保护条例(GDPR)、加州消费者隐私法(CCPA)以及其他相关隐私框架。有关 ClickHouse 收集的个人数据、如何使用、如何保护以及其他隐私相关信息的详细信息,可以在以下位置找到。 + +### 法律文件 {#legal-documents} + +- [隐私政策](https://clickhouse.com/legal/privacy-policy) +- [Cookie 政策](https://clickhouse.com/legal/cookie-policy) +- [数据隐私框架通知](https://clickhouse.com/legal/data-privacy-framework) +- [数据处理附录(DPA)](https://clickhouse.com/legal/agreements/data-processing-addendum) + +### 处理位置 {#processing-locations} + +- [子处理器和附属机构](https://clickhouse.com/legal/agreements/subprocessors) +- [数据处理位置](https://trust.clickhouse.com) + +### 其他程序 {#additional-procedures} + +- [个人数据访问](/cloud/security/personal-data-access) +- [删除账户](/cloud/manage/close_account) + + +# 支付合规 + +ClickHouse 提供一种安全的信用卡支付方式,符合 [PCI SAQ A v4.0](https://www.pcisecuritystandards.org/document_library/)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/09_security/privacy_and_compliance/compliance-overview.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/09_security/privacy_and_compliance/compliance-overview.md.hash new file mode 100644 index 00000000000..0d43b04b94d --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/09_security/privacy_and_compliance/compliance-overview.md.hash @@ -0,0 +1 @@ +075c0c19f4ed40f2 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/09_security/privacy_and_compliance/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/09_security/privacy_and_compliance/index.md new file mode 100644 index 00000000000..23a62e687c7 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/09_security/privacy_and_compliance/index.md @@ -0,0 +1,17 @@ +--- +'sidebar_label': '隐私与合规概述' +'slug': '/cloud/security/privacy-compliance-overview' +'title': '隐私与合规' +'description': '隐私与合规的登陆页面' +'doc_type': 'landing-page' +--- + + +# 隐私和合规性 + +本节包含以下页面: + +| 页面 | 描述 | +|----------------------------------------------------------------------------|------------------------------------------------------| +| [安全性和合规性](/cloud/security/compliance-overview) | ClickHouse Cloud 的安全报告和隐私合规性。 | +| [个人数据访问](/cloud/security/personal-data-access) | 如何访问您的个人数据的信息。 | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/09_security/privacy_and_compliance/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/09_security/privacy_and_compliance/index.md.hash new file mode 100644 index 00000000000..0265c126d54 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/09_security/privacy_and_compliance/index.md.hash @@ -0,0 +1 @@ +418c3e736262b0d5 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/09_security/privacy_and_compliance/personal-data-access.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/09_security/privacy_and_compliance/personal-data-access.md new file mode 100644 index 00000000000..0f02a139654 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/09_security/privacy_and_compliance/personal-data-access.md @@ -0,0 +1,63 @@ +--- +'sidebar_label': '个人数据访问' +'slug': '/cloud/security/personal-data-access' +'title': '个人数据访问' +'description': '作为注册用户,ClickHouse 允许您查看和管理您的个人账户数据,包括联系信息。' +'doc_type': 'reference' +--- + +import Image from '@theme/IdealImage'; +import support_case_form from '@site/static/images/cloud/security/support-case-form.png'; + +## Intro {#intro} + +作为注册用户,ClickHouse 允许您查看和管理个人账户数据,包括联系信息。根据您的角色,这可能还包括访问您组织中其他用户的联系信息、API 密钥详细信息和其他相关信息。您可以通过 ClickHouse 控制台以自助的方式直接管理这些详细信息。 + +**什么是数据主体访问请求 (DSAR)** + +根据您所在的位置,适用法律可能还会赋予您对 ClickHouse 持有的个人数据的额外权利(数据主体权利),具体如下所述 ClickHouse 隐私政策。 行使数据主体权利的过程被称为数据主体访问请求 (DSAR)。 + +**个人数据的范围** + +请查看 ClickHouse 的隐私政策,了解 ClickHouse 收集的个人数据及其用途。 + +## 自助服务 {#self-service} + +默认情况下,ClickHouse 使用户能够直接从 ClickHouse 控制台查看其个人数据。 + +以下是 ClickHouse 在账户设置和服务使用过程中收集的数据摘要,以及在 ClickHouse 控制台中可以查看特定个人数据的位置。 + +| 位置/网址 | 描述 | 个人数据 | +|-----------------------|----------------|-----------------------------------------| +| https://auth.clickhouse.cloud/u/signup/ | 账户注册 | email, password | +| https://console.clickhouse.cloud/profile | 一般用户个人资料详细信息 | name, email | +| https://console.clickhouse.cloud/organizations/OrgID/members | 组织中的用户列表 | name, email | +| https://console.clickhouse.cloud/organizations/OrgID/keys | API 密钥列表及创建者 | email | +| https://console.clickhouse.cloud/organizations/OrgID/audit | 活动日志,列出个别用户的操作 | email | +| https://console.clickhouse.cloud/organizations/OrgID/billing | 账单信息和发票 | billing address, email | +| https://console.clickhouse.cloud/support | 与 ClickHouse 支持的互动 | name, email | + +注意:带有 `OrgID` 的网址需要更新,以反映您特定账户的 `OrgID`。 + +### 当前客户 {#current-customers} + +如果您在我们这里有账户,而自助服务选项未解决您的个人数据问题,您可以根据隐私政策提交数据主体访问请求。为此,登录您的 ClickHouse 账户并打开一个 [支持案例](https://console.clickhouse.cloud/support)。 这有助于我们验证您的身份并简化处理请求的过程。 + +请确保在您的支持案例中包含以下详细信息: + +| 字段 | 请求中要包含的文本 | +|-----------|-----------------------------------| +| 主题 | 数据主体访问请求 (DSAR) | +| 描述 | 您希望 ClickHouse 查找、收集和/或提供的信息的详细描述。 | + +ClickHouse Cloud 中的支持案例表单 + +### 没有账户的个人 {#individuals-without-an-account} + +如果您没有与我们建立账户,且上述自助服务选项未解决您的个人数据问题,并希望根据隐私政策提出数据主体访问请求,您可以通过电子邮件向 [privacy@clickhouse.com](mailto:privacy@clickhouse.com) 提交这些请求。 + +## 身份验证 {#identity-verification} + +如果您通过电子邮件提交数据主体访问请求,我们可能会向您请求特定信息,以帮助我们确认您的身份并处理您的请求。适用法律可能要求或允许我们拒绝您的请求。如果我们拒绝您的请求,我们会告知您原因,但受法律限制。 + +有关更多信息,请查看 [ClickHouse 隐私政策](https://clickhouse.com/legal/privacy-policy) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/09_security/privacy_and_compliance/personal-data-access.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/09_security/privacy_and_compliance/personal-data-access.md.hash new file mode 100644 index 00000000000..e41fca4b809 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/09_security/privacy_and_compliance/personal-data-access.md.hash @@ -0,0 +1 @@ +d815f2493b8ba3a5 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/10_account-close.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/10_account-close.md new file mode 100644 index 00000000000..f7f70c98689 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/10_account-close.md @@ -0,0 +1,53 @@ +--- +'sidebar_label': '帐户关闭' +'slug': '/cloud/manage/close_account' +'title': '帐户关闭和删除' +'description': '我们知道有时会出现一些情况需要关闭帐户。这个指南将帮助您完成这一过程。' +'doc_type': 'guide' +--- + +## 账户关闭与删除 {#account-close--deletion} + +我们的目标是帮助您在项目中取得成功。如果您在本网站上没有找到答案或需要帮助评估独特的用例,请通过 [support@clickhouse.com](mailto:support@clickhouse.com) 联系我们。 + +我们知道,有时会出现需要关闭账户的情况。本指南将帮助您完成这一过程。 + +## 关闭与删除账户 {#close-vs-delete} +客户可以重新登录已关闭的账户,以查看使用情况、账单和账户级活动日志。这使您能够轻松访问对多种目的有用的详细信息,从记录用例到在年底下载发票以用于税务目的。您还将继续收到产品更新,以便了解您可能期待的功能是否现在可用。此外,已关闭的账户可以随时重新开启以开始新服务。 + +请求个人数据删除的客户应了解这是一个不可逆的过程。账户及相关信息将不再可用。您将不会收到产品更新,并且可能无法重新开启该账户。这不会影响任何新闻通讯订阅。 + +新闻通讯订阅者可以随时通过使用新闻通讯电子邮件底部的取消订阅链接来取消订阅,而无需关闭其账户或删除其信息。 + +## 准备关闭账户 {#preparing-for-closure} + +在请求关闭账户之前,请采取以下步骤为账户做好准备。 +1. 导出您需要保留的任何服务数据。 +2. 停止并删除您的服务。这将防止您的账户产生额外费用。 +3. 移除除请求关闭的管理员之外的所有用户。这将帮助您确保在过程完成期间不会创建新服务。 +4. 查看控制面板中的“使用情况”和“账单”标签,以验证所有费用已支付。我们无法关闭余额未支付的账户。 + +## 请求账户关闭 {#request-account-closure} + +我们需要对关闭和删除请求进行验证。为确保能够快速处理您的请求,请遵循以下步骤。 +1. 登录您的 clickhouse.cloud 账户。 +2. 完成上述“准备关闭账户”部分中的任何剩余步骤。 +3. 点击帮助按钮(屏幕右上角的问号)。 +4. 在“支持”下,点击“创建案例”。 +5. 在“创建新案例”页面中,输入以下内容: + +```text +Priority: Severity 3 +Subject: Please close my ClickHouse account +Description: We would appreciate it if you would share a brief note about why you are cancelling. +``` + +5. 点击“创建新案例” +6. 我们将关闭您的账户,并发送确认电子邮件以通知您何时完成。 + +## 请求删除您的个人数据 {#request-personal-data-deletion} +请注意,只有账户管理员可以请求从 ClickHouse 删除个人数据。如果您不是账户管理员,请联系您的 ClickHouse 账户管理员以请求从账户中删除。 + +要请求数据删除,请遵循上述“请求账户关闭”的步骤。在输入案例信息时,将主题更改为“请关闭我的 ClickHouse 账户并删除我的个人数据。” + +我们将在 30 天内完成个人数据删除请求。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/10_account-close.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/10_account-close.md.hash new file mode 100644 index 00000000000..ac764927aee --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/10_account-close.md.hash @@ -0,0 +1 @@ +f3a2f955417fd56a diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/_snippets/_network_transfer_rates.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/_snippets/_network_transfer_rates.md similarity index 61% rename from i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/_snippets/_network_transfer_rates.md rename to i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/_snippets/_network_transfer_rates.md index 744bda13d22..57e098cbda8 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/_snippets/_network_transfer_rates.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/_snippets/_network_transfer_rates.md @@ -1,20 +1,15 @@ ---- -null -... ---- - -下表显示了不同云服务提供商和区域在公共互联网或跨区域的数据传输费用(出口)的差异。 +以下表格显示了不同云提供商和地区的出站公共互联网或跨区域数据传输费用的变化。 **AWS** - - - + + + - + @@ -91,24 +86,24 @@ null
云服务提供商区域公共互联网出口云提供商地区公共互联网出站 同一区域跨区域
(所有Tier 1)
跨区域
(所有 Tier 1)
-$^*$数据传输费用以每GB传输的数据计算 +$^*$数据传输费用以每 GB 传输的数据为单位。 **GCP** - - - - + + + + - - + + @@ -117,62 +112,62 @@ $^*$数据传输费用以每GB传输的数据计算 - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + +
云服务提供商源区域公共互联网出口目标区域云提供商起源地区公共互联网出站目的地区
同一区域 北美 欧洲亚洲、澳大利亚中东、南美、非洲亚洲,澳大利亚中东,南美,非洲
`us-central1` `$0.1140` `$0.0000``$0.0360`(Tier 1)`$0.0720`(Tier 2)`$0.1200`(Tier 3)`$0.1620`(Tier 4)`$0.0360` (Tier 1)`$0.0720` (Tier 2)`$0.1200` (Tier 3)`$0.1620` (Tier 4)
`GCP` `us-east1` `$0.1140` `$0.0000``$0.0360`(Tier 1)`$0.0720`(Tier 2)`$0.1200`(Tier 3)`$0.1620`(Tier 4)`$0.0360` (Tier 1)`$0.0720` (Tier 2)`$0.1200` (Tier 3)`$0.1620` (Tier 4)
`GCP` `europe-west4` `$0.1140` `$0.0000``$0.0720`(Tier 2)`$0.0360`(Tier 1)`$0.1200`(Tier 3)`$0.1620`(Tier 4)`$0.0720` (Tier 2)`$0.0360` (Tier 1)`$0.1200` (Tier 3)`$0.1620` (Tier 4)
`GCP` `asia-southeast1` `$0.1440` `$0.0000``$0.1200`(Tier 3)`$0.1200`(Tier 3)`$0.1200`(Tier 3)`$0.1620`(Tier 4)`$0.1200` (Tier 3)`$0.1200` (Tier 3)`$0.1200` (Tier 3)`$0.1620` (Tier 4)
-$^*$数据传输费用以每GB传输的数据计算 +$^*$数据传输费用以每 GB 传输的数据为单位。 **Azure** - - - - + + + + - - + + @@ -181,32 +176,32 @@ $^*$数据传输费用以每GB传输的数据计算 - - - - + + + + - - - - + + + + - - - - + + + +
云服务提供商源区域公共互联网出口目标区域云提供商起源地区公共互联网出站目的地区
同一区域 北美 欧洲亚洲、澳大利亚中东、南美、非洲亚洲,澳大利亚中东,南美,非洲
`eastus2` `$0.1020` `$0.0000``$0.0300`(Tier 1)`$0.0660`(Tier 2)`$0.0660`(Tier 2)`$0.0660`(Tier 2)`$0.0300` (Tier 1)`$0.0660` (Tier 2)`$0.0660` (Tier 2)`$0.0660` (Tier 2)
`Azure` `westus3` `$0.1020` `$0.0000``$0.0300`(Tier 1)`$0.0660`(Tier 2)`$0.0660`(Tier 2)`$0.0660`(Tier 2)`$0.0300` (Tier 1)`$0.0660` (Tier 2)`$0.0660` (Tier 2)`$0.0660` (Tier 2)
`Azure` `germanywestcentral` `$0.1020` `$0.0000``$0.0660`(Tier 2)`$0.0300`(Tier 1)`$0.0660`(Tier 2)`$0.0660`(Tier 2)`$0.0660` (Tier 2)`$0.0300` (Tier 1)`$0.0660` (Tier 2)`$0.0660` (Tier 2)
-$^*$数据传输费用以每GB传输的数据计算 +$^*$数据传输费用以每 GB 传输的数据为单位。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/_snippets/_network_transfer_rates.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/_snippets/_network_transfer_rates.md.hash similarity index 100% rename from i18n/zh/docusaurus-plugin-content-docs/current/cloud/manage/_snippets/_network_transfer_rates.md.hash rename to i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/_snippets/_network_transfer_rates.md.hash diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/architecture.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/architecture.md deleted file mode 100644 index 92d2ae1b9a4..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/architecture.md +++ /dev/null @@ -1,54 +0,0 @@ ---- -'sidebar_label': '架构' -'slug': '/cloud/reference/architecture' -'title': 'ClickHouse Cloud 架构' -'description': '本页面描述了 ClickHouse Cloud 的架构' ---- - -import Architecture from '@site/static/images/cloud/reference/architecture.svg'; - - -# ClickHouse Cloud 架构 - - - -## 由对象存储支持的存储 {#storage-backed-by-object-store} -- 几乎无限的存储 -- 无需手动共享数据 -- 存储数据的成本显著降低,尤其是对不常访问的数据 - -## 计算 {#compute} -- 自动扩展和闲置:无需提前规划规模,也无需为峰值使用过度配置 -- 自动闲置和恢复:在无人使用时无需持续运行未使用的计算资源 -- 默认安全和高可用性 - -## 管理 {#administration} -- 设置、监控、备份和计费均由系统为您执行。 -- 默认启用成本控制,您可以通过云控制台进行调整。 - -## 服务隔离 {#service-isolation} - -### 网络隔离 {#network-isolation} - -所有服务在网络层面上都是隔离的。 - -### 计算隔离 {#compute-isolation} - -所有服务部署在各自的Kubernetes空间中的独立Pod中,并具有网络级隔离。 - -### 存储隔离 {#storage-isolation} - -所有服务使用共享存储桶(AWS、GCP)或存储容器(Azure)中的独立子路径。 - -对于AWS,通过AWS IAM控制存储访问,并且每个IAM角色在每个服务中都是唯一的。对于企业服务,可以启用[CMEK](/cloud/security/cmek)以提供静态数据的高级隔离。目前CMEK仅支持AWS服务。 - -对于GCP和Azure,服务具有对象存储隔离(所有服务都有自己的存储桶或存储容器)。 - -## 计算-计算分离 {#compute-compute-separation} -[计算-计算分离](/cloud/reference/warehouses) 允许用户创建多个计算节点组,每个组都有自己的服务URL,所有组使用相同的共享对象存储。这允许对不同用例的计算进行隔离,例如从写入中读取,它们共享相同的数据。还通过允许根据需要独立扩展计算组,提高资源利用效率。 - -## 并发限制 {#concurrency-limits} - -在您的 ClickHouse Cloud 服务中,查询每秒(QPS)的数量没有限制。但是,每个副本的并发查询限制为 1000。QPS 最终取决于您的平均查询执行时间和服务中副本的数量。 - -与自管理的 ClickHouse 实例或其他数据库/数据仓库相比,ClickHouse Cloud 的一个主要优点是您可以通过[添加更多副本(横向扩展)](/manage/scaling#manual-horizontal-scaling)轻松增加并发性。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/architecture.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/architecture.md.hash deleted file mode 100644 index 238530d300c..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/architecture.md.hash +++ /dev/null @@ -1 +0,0 @@ -4864ed1266505adc diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/byoc.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/byoc.md deleted file mode 100644 index d517f1666aa..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/byoc.md +++ /dev/null @@ -1,439 +0,0 @@ ---- -'title': 'AWS的BYOC (自带云服务)' -'slug': '/cloud/reference/byoc' -'sidebar_label': 'BYOC (自带云服务)' -'keywords': -- 'BYOC' -- 'cloud' -- 'bring your own cloud' -'description': '在您自己的云基础设施上部署 ClickHouse' ---- - -import Image from '@theme/IdealImage'; -import byoc1 from '@site/static/images/cloud/reference/byoc-1.png'; -import byoc4 from '@site/static/images/cloud/reference/byoc-4.png'; -import byoc3 from '@site/static/images/cloud/reference/byoc-3.png'; -import byoc_vpcpeering from '@site/static/images/cloud/reference/byoc-vpcpeering-1.png'; -import byoc_vpcpeering2 from '@site/static/images/cloud/reference/byoc-vpcpeering-2.png'; -import byoc_vpcpeering3 from '@site/static/images/cloud/reference/byoc-vpcpeering-3.png'; -import byoc_vpcpeering4 from '@site/static/images/cloud/reference/byoc-vpcpeering-4.png'; -import byoc_plb from '@site/static/images/cloud/reference/byoc-plb.png'; -import byoc_security from '@site/static/images/cloud/reference/byoc-securitygroup.png'; -import byoc_inbound from '@site/static/images/cloud/reference/byoc-inbound-rule.png'; -import byoc_subnet_1 from '@site/static/images/cloud/reference/byoc-subnet-1.png'; -import byoc_subnet_2 from '@site/static/images/cloud/reference/byoc-subnet-2.png'; - -## 概述 {#overview} - -BYOC (自带云) 允许您在自己的云基础设施上部署 ClickHouse Cloud。如果您有特定的需求或约束,导致无法使用 ClickHouse Cloud 托管服务,这将非常有用。 - -**如果您希望获取访问权限,请 [联系我们](https://clickhouse.com/cloud/bring-your-own-cloud)。** 有关更多信息,请参阅我们的 [服务条款](https://clickhouse.com/legal/agreements/terms-of-service)。 - -目前,BYOC 仅支持 AWS。您可以在这里加入 GCP 和 Azure 的候补名单 [here](https://clickhouse.com/cloud/bring-your-own-cloud)。 - -:::note -BYOC 专为大规模部署而设计,需要客户签署承诺合同。 -::: - -## 术语表 {#glossary} - -- **ClickHouse VPC:** ClickHouse Cloud 所拥有的 VPC。 -- **客户 BYOC VPC:** 由客户云账户拥有并由 ClickHouse Cloud 提供和管理的 VPC,专用于 ClickHouse Cloud BYOC 部署。 -- **客户 VPC:** 其他由客户云账户拥有的 VPC,用于需要连接到客户 BYOC VPC 的应用程序。 - -## 架构 {#architecture} - -指标和日志存储在客户的 BYOC VPC 中。日志目前在本地存储于 EBS。在未来的更新中,日志将存储在 LogHouse 中,这是客户 BYOC VPC 内的 ClickHouse 服务。指标通过存储在客户 BYOC VPC 中的 Prometheus 和 Thanos 堆栈实现。 - -
- -BYOC 架构 - -
- -## 上线流程 {#onboarding-process} - -客户可以通过与 [我们](https://clickhouse.com/cloud/bring-your-own-cloud) 联系来启动上线流程。客户需要有一个专用的 AWS 账户,并知道他们将使用的区域。目前,我们仅允许用户在支持 ClickHouse Cloud 的区域内启动 BYOC 服务。 - -### 准备 AWS 账户 {#prepare-an-aws-account} - -建议客户为托管 ClickHouse BYOC 部署准备一个专用的 AWS 账户,以确保更好的隔离。但是,也可以使用共享账户和现有 VPC。请参见下面的 *设置 BYOC 基础设施* 了解详细信息。 - -使用此账户和初始组织管理员电子邮件,您可以联系 ClickHouse 支持。 - -### 应用 CloudFormation 模板 {#apply-cloudformation-template} - -BYOC 设置通过一个 [CloudFormation 堆栈](https://s3.us-east-2.amazonaws.com/clickhouse-public-resources.clickhouse.cloud/cf-templates/byoc.yaml) 初始化,该堆栈仅创建一个角色,允许 ClickHouse Cloud 的 BYOC 控制器管理基础设施。S3、VPC 和用于运行 ClickHouse 的计算资源不包括在此堆栈中。 - - - -### 设置 BYOC 基础设施 {#setup-byoc-infrastructure} - -创建 CloudFormation 堆栈后,系统会提示您设置基础设施,包括 S3、VPC 和 EKS 集群。某些配置必须在此阶段确定,因为之后无法更改。具体而言: - -- **您想使用的区域**,您可以选择我们的 ClickHouse Cloud 可用的任何 [公共区域](/cloud/reference/supported-regions)。 -- **BYOC 的 VPC CIDR 范围**:默认情况下,我们为 BYOC VPC CIDR 范围使用 `10.0.0.0/16`。如果您计划与另一个账户进行 VPC 对等连接,请确保 CIDR 范围不重叠。为 BYOC 分配适当的 CIDR 范围,最小大小为 `/22` 以容纳必要的工作负载。 -- **BYOC VPC 的可用区**:如果您计划使用 VPC 对等连接,则在源账户和 BYOC 账户之间对齐可用区可以帮助减少跨 AZ 流量费用。在 AWS 中,可用区后缀 (`a, b, c`) 可能表示不同的物理区 ID。有关详细信息,请参见 [AWS 指南](https://docs.aws.amazon.com/prescriptive-guidance/latest/patterns/use-consistent-availability-zones-in-vpcs-across-different-aws-accounts.html)。 - -#### 客户管理的 VPC {#customer-managed-vpc} -默认情况下,ClickHouse Cloud 会为您的 BYOC 部署配置一个专用 VPC,以确保更好的隔离。但是,您也可以使用您账户中的现有 VPC。这需要特定配置,并且必须通过 ClickHouse 支持进行协调。 - -**配置您现有的 VPC** -1. 在 3 个不同可用区中分配至少 3 个私有子网以供 ClickHouse Cloud 使用。 -2. 确保每个子网的 CIDR 范围至少为 `/23`(例如,10.0.0.0/23),以提供足够的 IP 地址用于 ClickHouse 部署。 -3. 为每个子网添加标签 `kubernetes.io/role/internal-elb=1` 以启用适当的负载均衡器配置。 - -
- -BYOC VPC 子网 - -
- -
- -BYOC VPC 子网标签 - -
- -**联系 ClickHouse 支持** -创建一个支持工单,其中包含以下信息: - -* 您的 AWS 账户 ID -* 您希望部署服务的 AWS 区域 -* 您的 VPC ID -* 您为 ClickHouse 分配的私有子网 ID -* 这些子网所在的可用区 - - -### 可选:设置 VPC 对等连接 {#optional-setup-vpc-peering} - -要为 ClickHouse BYOC 创建或删除 VPC 对等连接,请按以下步骤操作: - -#### 第一步 启用 ClickHouse BYOC 的私有负载均衡器 {#step-1-enable-private-load-balancer-for-clickhouse-byoc} -联系 ClickHouse 支持以启用私有负载均衡器。 - -#### 第二步 创建对等连接 {#step-2-create-a-peering-connection} -1. 转到 ClickHouse BYOC 账户中的 VPC 仪表板。 -2. 选择对等连接。 -3. 点击创建对等连接。 -4. 将 VPC 请求者设置为 ClickHouse VPC ID。 -5. 将 VPC 接受者设置为目标 VPC ID。(如有适用,选择另一个账户) -6. 点击创建对等连接。 - -
- -BYOC 创建对等连接 - -
- -#### 第三步 接受对等连接请求 {#step-3-accept-the-peering-connection-request} -转到对等账户,在(VPC -> 对等连接 -> 操作 -> 接受请求)页面,客户可以批准此 VPC 对等连接请求。 - -
- -BYOC 接受对等连接 - -
- -#### 第四步 将目标添加到 ClickHouse VPC 路由表 {#step-4-add-destination-to-clickhouse-vpc-route-tables} -在 ClickHouse BYOC 账户中, -1. 在 VPC 仪表板中选择路由表。 -2. 搜索 ClickHouse VPC ID。编辑附加到私有子网的每个路由表。 -3. 点击路由选项卡下的编辑按钮。 -4. 点击添加另一条路由。 -5. 输入目标 VPC 的 CIDR 范围作为目的地。 -6. 选择“对等连接”和对等连接的 ID 作为目标。 - -
- -BYOC 添加路由表 - -
- -#### 第五步 将目标添加到目标 VPC 路由表 {#step-5-add-destination-to-the-target-vpc-route-tables} -在对等 AWS 账户中, -1. 在 VPC 仪表板中选择路由表。 -2. 搜索目标 VPC ID。 -3. 点击路由选项卡下的编辑按钮。 -4. 点击添加另一条路由。 -5. 输入 ClickHouse VPC 的 CIDR 范围作为目的地。 -6. 选择“对等连接”和对等连接的 ID 作为目标。 - -
- -BYOC 添加路由表 - -
- -#### 第六步 编辑安全组以允许对等 VPC 访问 {#step-6-edit-security-group-to-allow-peered-vpc-access} -在 ClickHouse BYOC 账户中,您需要更新安全组设置以允许来自对等 VPC 的流量。请联系 ClickHouse 支持以请求添加入站规则,包括您对等 VPC 的 CIDR 范围。 - ---- -现在 ClickHouse 服务应该可以从对等 VPC 访问。 - -要私密访问 ClickHouse,将为用户的对等 VPC 提供私有负载均衡器和终端。私有终端遵循公共终端格式,带有 `-private` 后缀。例如: -- **公共终端**: `h5ju65kv87.mhp0y4dmph.us-west-2.aws.byoc.clickhouse.cloud` -- **私有终端**: `h5ju65kv87-private.mhp0y4dmph.us-west-2.aws.byoc.clickhouse.cloud` - -可选地,在验证对等连接正常工作后,您可以请求移除 ClickHouse BYOC 的公共负载均衡器。 - -## 升级流程 {#upgrade-process} - -我们定期升级软件,包括 ClickHouse 数据库版本升级、ClickHouse Operator、EKS 和其他组件。 - -虽然我们的目标是实现无缝升级(例如,滚动升级和重启),但某些升级,如 ClickHouse 版本变更和 EKS 节点升级,可能会影响服务。客户可以指定维护窗口(例如,每周二凌晨 1:00 PDT),确保此类升级仅在计划时间内进行。 - -:::note -维护窗口不适用于安全和漏洞修复。这些处理为非周期性升级,并及时沟通以协调合适的时间,最大限度地减少操作影响。 -::: - -## CloudFormation IAM 角色 {#cloudformation-iam-roles} - -### 引导 IAM 角色 {#bootstrap-iam-role} - -引导 IAM 角色拥有以下权限: - -- **EC2 和 VPC 操作**:用于设置 VPC 和 EKS 集群。 -- **S3 操作(例如,`s3:CreateBucket`)**:需要创建 ClickHouse BYOC 存储桶。 -- **`route53:*` 权限**:用于外部 DNS 在 Route 53 中配置记录。 -- **IAM 操作(例如,`iam:CreatePolicy`)**:需要控制器创建额外角色(详见下一节)。 -- **EKS 操作**:限于名称以 `clickhouse-cloud` 前缀开头的资源。 - -### 由控制器创建的其他 IAM 角色 {#additional-iam-roles-created-by-the-controller} - -除了通过 CloudFormation 创建的 `ClickHouseManagementRole` 之外,控制器还将创建几个其他角色。 - -这些角色由在客户 EKS 集群内运行的应用程序承担: -- **状态导出器角色** - - ClickHouse 组件,向 ClickHouse Cloud 报告服务健康信息。 - - 需要写入 ClickHouse Cloud 拥有的 SQS 队列的权限。 -- **负载均衡器控制器** - - 标准 AWS 负载均衡器控制器。 - - EBS CSI 控制器,用于管理 ClickHouse 服务的卷。 -- **外部 DNS** - - 将 DNS 配置传播到 Route 53。 -- **证书管理器** - - 为 BYOC 服务域提供 TLS 证书。 -- **集群自动缩放器** - - 根据需要调整节点组大小。 - -**K8s-control-plane** 和 **k8s-worker** 角色旨在由 AWS EKS 服务承担。 - -最后,**`data-plane-mgmt`** 允许 ClickHouse Cloud 控制平面组件调和必要的自定义资源,如 `ClickHouseCluster` 和 Istio 虚拟服务/网关。 - -## 网络边界 {#network-boundaries} - -本节涵盖客户端 BYOC VPC 的不同网络流量: - -- **入站**:进入客户 BYOC VPC 的流量。 -- **出站**:来自客户 BYOC VPC 并发送到外部目标的流量。 -- **公共**:可以从公共互联网访问的网络端点。 -- **私有**:只能通过私有连接访问的网络端点,例如 VPC 对等连接、VPC 私有链接或 Tailscale。 - -**Istio 入口在 AWS NLB 后面部署,以接受 ClickHouse 客户端流量。** - -*入站,公有(可以是私有)* - -Istio 入口网关终止 TLS。证书由 CertManager 使用 Let's Encrypt 提供,存储在 EKS 集群中的秘密中。由于它们位于同一 VPC 中,Istio 和 ClickHouse 之间的流量经过 [AWS 加密](https://docs.aws.amazon.com/whitepapers/latest/logical-separation/encrypting-data-at-rest-and--in-transit.html#:~:text=All%20network%20traffic%20between%20AWS,supported%20Amazon%20EC2%20instance%20types)。 - -默认情况下,入口是公开可访问的,并具有 IP 允许名单过滤。客户可以配置 VPC 对等连接以使其变为私有并禁用公共连接。我们强烈建议设置 [IP 过滤器](/cloud/security/setting-ip-filters) 以限制访问。 - -### 故障排除访问 {#troubleshooting-access} - -*入站,公有(可以是私有)* - -ClickHouse Cloud 工程师需要通过 Tailscale 进行故障排除访问。它们通过及时的基于证书的身份验证为 BYOC 部署提供服务。 - -### 计费抓取器 {#billing-scraper} - -*出站,私有* - -计费抓取器从 ClickHouse 收集计费数据,并将其发送到 ClickHouse Cloud 拥有的 S3 存储桶。 - -它作为 ClickHouse 服务器容器的附加容器运行,周期性地抓取 CPU 和内存指标。在同一区域内的请求通过 VPC 网关服务端点路由。 - -### 警报 {#alerts} - -*出站,公有* - -AlertManager 被配置为在客户的 ClickHouse 集群处于不健康状态时向 ClickHouse Cloud 发送警报。 - -指标和日志存储在客户的 BYOC VPC 中。日志目前在本地存储于 EBS。在未来的更新中,它们将存储在 LogHouse 中,这是 BYOC VPC 内的 ClickHouse 服务。指标使用存储在 BYOC VPC 中的 Prometheus 和 Thanos 堆栈。 - -### 服务状态 {#service-state} - -*出站* - -状态导出器将 ClickHouse 服务状态信息发送到 ClickHouse Cloud 拥有的 SQS。 - -## 特性 {#features} - -### 支持的特性 {#supported-features} - -- **SharedMergeTree**: ClickHouse Cloud 和 BYOC 使用相同的二进制和配置。因此,ClickHouse 核心的所有功能在 BYOC 中都得到支持,例如 SharedMergeTree。 -- **管理服务状态的控制台访问**: - - 支持启动、停止和终止等操作。 - - 查看服务和状态。 -- **备份和恢复。** -- **手动垂直和水平缩放。** -- **空闲。** -- **仓库**:计算-计算分离 -- **通过 Tailscale 的零信任网络。** -- **监控**: - - Cloud 控制台包含用于监控服务健康的内置健康仪表板。 - - Prometheus 抓取,以便与 Prometheus、Grafana 和 Datadog 进行集中监控。有关设置说明,请参见 [Prometheus 文档](/integrations/prometheus)。 -- **VPC 对等连接。** -- **集成**:完整列表请参见 [此页面](/integrations)。 -- **安全的 S3。** -- **[AWS PrivateLink](https://aws.amazon.com/privatelink/)。** - -### 计划中的特性(目前不支持) {#planned-features-currently-unsupported} - -- [AWS KMS](https://aws.amazon.com/kms/) 即 CMEK(客户管理加密密钥) -- ClickPipes 用于摄取 -- 自动缩放 -- MySQL 接口 - -## 常见问题解答 {#faq} - -### 计算 {#compute} - -#### 我可以在这个单一 EKS 集群中创建多个服务吗? {#can-i-create-multiple-services-in-this-single-eks-cluster} - -可以。基础设施只需为每个 AWS 账户和区域组合配置一次。 - -### 您支持哪些区域的 BYOC? {#which-regions-do-you-support-for-byoc} - -BYOC 支持与 ClickHouse Cloud 相同的一组 [区域](/cloud/reference/supported-regions#aws-regions)。 - -#### 会有一些资源开销吗?运行 ClickHouse 实例之外的服务需要哪些资源? {#will-there-be-some-resource-overhead-what-are-the-resources-needed-to-run-services-other-than-clickhouse-instances} - -除了 ClickHouse 实例(ClickHouse 服务器和 ClickHouse Keeper)外,我们还运行 `clickhouse-operator`、`aws-cluster-autoscaler`、Istio 等服务,以及我们的监控堆栈。 - -目前我们在专用节点组中有 3 个 m5.xlarge 节点(每个 AZ 一个)以运行这些工作负载。 - -### 网络和安全 {#network-and-security} - -#### 在安装后可以撤销设置期间设置的权限吗? {#can-we-revoke-permissions-set-up-during-installation-after-setup-is-complete} - -目前无法实现。 - -#### 您是否考虑过未来的安全控制,以便 ClickHouse 工程师访问客户基础设施进行故障排除? {#have-you-considered-some-future-security-controls-for-clickhouse-engineers-to-access-customer-infra-for-troubleshooting} - -是的。实施客户控制机制,允许客户批准工程师访问集群在我们的路线图上。当时,工程师必须通过我们的内部升级流程,以获取对集群的及时访问。这由我们的安全团队记录和审核。 - -#### 创建的 VPC IP 范围的大小是多少? {#what-is-the-size-of-the-vpc-ip-range-created} - -默认情况下,我们为 BYOC VPC 使用 `10.0.0.0/16`。我们建议保留至少 /22 供未来潜在扩展,但如果您希望限制大小,如果预计将限制到 30 个服务器 pod,可以使用 /23。 - -#### 我可以决定维护频率吗? {#can-i-decide-maintenance-frequency} - -联系支持以安排维护窗口。请预计每周至少一次的更新计划。 - -## 可观测性 {#observability} - -### 内置监控工具 {#built-in-monitoring-tools} - -#### 可观测性仪表板 {#observability-dashboard} - -ClickHouse Cloud 包含一个高级可观测性仪表板,显示内存使用情况、查询率和 I/O 等指标。可以在 ClickHouse Cloud 网络控制台界面的 **监控** 部分访问。 - -
- -可观测性仪表板 - -
- -#### 高级仪表板 {#advanced-dashboard} - -您可以使用 `system.metrics`、`system.events` 和 `system.asynchronous_metrics` 等系统表中的指标自定义仪表板,以详细监控服务器性能和资源利用。 - -
- -高级仪表板 - -
- -#### Prometheus 集成 {#prometheus-integration} - -ClickHouse Cloud 提供了一个 Prometheus 端点,您可以用来抓取监控指标。这允许与 Grafana 和 Datadog 等工具进行可视化集成。 - -**通过 https 端点 /metrics_all 的示例请求** - -```bash -curl --user : https://i6ro4qarho.mhp0y4dmph.us-west-2.aws.byoc.clickhouse.cloud:8443/metrics_all -``` - -**示例响应** - -```bash - -# HELP ClickHouse_CustomMetric_StorageSystemTablesS3DiskBytes The amount of bytes stored on disk `s3disk` in system database - -# TYPE ClickHouse_CustomMetric_StorageSystemTablesS3DiskBytes gauge -ClickHouse_CustomMetric_StorageSystemTablesS3DiskBytes{hostname="c-jet-ax-16-server-43d5baj-0"} 62660929 - -# HELP ClickHouse_CustomMetric_NumberOfBrokenDetachedParts The number of broken detached parts - -# TYPE ClickHouse_CustomMetric_NumberOfBrokenDetachedParts gauge -ClickHouse_CustomMetric_NumberOfBrokenDetachedParts{hostname="c-jet-ax-16-server-43d5baj-0"} 0 - -# HELP ClickHouse_CustomMetric_LostPartCount The age of the oldest mutation (in seconds) - -# TYPE ClickHouse_CustomMetric_LostPartCount gauge -ClickHouse_CustomMetric_LostPartCount{hostname="c-jet-ax-16-server-43d5baj-0"} 0 - -# HELP ClickHouse_CustomMetric_NumberOfWarnings The number of warnings issued by the server. It usually indicates about possible misconfiguration - -# TYPE ClickHouse_CustomMetric_NumberOfWarnings gauge -ClickHouse_CustomMetric_NumberOfWarnings{hostname="c-jet-ax-16-server-43d5baj-0"} 2 - -# HELP ClickHouseErrorMetric_FILE_DOESNT_EXIST FILE_DOESNT_EXIST - -# TYPE ClickHouseErrorMetric_FILE_DOESNT_EXIST counter -ClickHouseErrorMetric_FILE_DOESNT_EXIST{hostname="c-jet-ax-16-server-43d5baj-0",table="system.errors"} 1 - -# HELP ClickHouseErrorMetric_UNKNOWN_ACCESS_TYPE UNKNOWN_ACCESS_TYPE - -# TYPE ClickHouseErrorMetric_UNKNOWN_ACCESS_TYPE counter -ClickHouseErrorMetric_UNKNOWN_ACCESS_TYPE{hostname="c-jet-ax-16-server-43d5baj-0",table="system.errors"} 8 - -# HELP ClickHouse_CustomMetric_TotalNumberOfErrors The total number of errors on server since the last restart - -# TYPE ClickHouse_CustomMetric_TotalNumberOfErrors gauge -ClickHouse_CustomMetric_TotalNumberOfErrors{hostname="c-jet-ax-16-server-43d5baj-0"} 9 -``` - -**身份验证** - -可以使用 ClickHouse 用户名和密码对进行身份验证。我们建议创建一个具有最小权限的专用用户来抓取监控指标。至少,`system.custom_metrics` 表上的 `READ` 权限是必须的,在副本之间。例如: - -```sql -GRANT REMOTE ON *.* TO scraping_user -GRANT SELECT ON system.custom_metrics TO scraping_user -``` - -**配置 Prometheus** - -下面显示了一个示例配置。 `targets` 端点与访问 ClickHouse 服务使用的相同。 - -```bash -global: - scrape_interval: 15s - -scrape_configs: - - job_name: "prometheus" - static_configs: - - targets: ["localhost:9090"] - - job_name: "clickhouse" - static_configs: - - targets: ["..aws.byoc.clickhouse.cloud:8443"] - scheme: https - metrics_path: "/metrics_all" - basic_auth: - username: - password: - honor_labels: true -``` - -有关更多详细信息,请参见 [这篇博客文章](https://clickhouse.com/blog/clickhouse-cloud-now-supports-prometheus-monitoring) 和 [ClickHouse 的 Prometheus 设置文档](/integrations/prometheus)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/byoc.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/byoc.md.hash deleted file mode 100644 index ff263edb3eb..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/byoc.md.hash +++ /dev/null @@ -1 +0,0 @@ -91101d1b6a54878f diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/changelogs-index.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/changelogs-index.md deleted file mode 100644 index 78c7e1191eb..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/changelogs-index.md +++ /dev/null @@ -1,10 +0,0 @@ ---- -'slug': '/cloud/reference/changelogs' -'title': '变更日志' -'description': '云变更日志的登录页面' ---- - -| 页面 | 描述 | -|---------------------------------------------------------------|-------------------------------------------------| -| [Cloud Changelog](/whats-new/cloud) | ClickHouse Cloud 的更新日志 | -| [Release Notes](/cloud/reference/changelogs/release-notes) | 所有 ClickHouse Cloud 发布的发布说明 | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/changelogs-index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/changelogs-index.md.hash deleted file mode 100644 index ac31602d21c..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/changelogs-index.md.hash +++ /dev/null @@ -1 +0,0 @@ -fb5b3251b669307d diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/cloud-compatibility.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/cloud-compatibility.md deleted file mode 100644 index 410bde5d8bf..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/cloud-compatibility.md +++ /dev/null @@ -1,127 +0,0 @@ ---- -'slug': '/whats-new/cloud-compatibility' -'sidebar_label': '云兼容性' -'title': '云兼容性' -'description': '本指南提供了在 ClickHouse Cloud 中功能和操作方面的概述。' ---- - - -# ClickHouse Cloud — 兼容性指南 - -本指南提供了在 ClickHouse Cloud 中功能和操作上的预期概述。尽管 ClickHouse Cloud 基于开源的 ClickHouse 分发版本,但在架构和实现上可能会有一些差异。您可能会觉得这篇关于 [如何从头构建 ClickHouse Cloud 的博客](https://clickhouse.com/blog/building-clickhouse-cloud-from-scratch-in-a-year) 读起来有趣且相关。 - -## ClickHouse Cloud 架构 {#clickhouse-cloud-architecture} -ClickHouse Cloud 显著简化了操作开销,并降低了大规模运行 ClickHouse 的成本。您无需提前调整部署规模、设置高可用性的复制、手动分片数据、在工作负载增加时扩展服务器,或在不使用时缩减服务器——我们为您处理这些。 - -这些好处来自于 ClickHouse Cloud 背后的架构选择: -- 计算和存储是分开的,因此可以沿不同维度自动扩展,因此您无需在静态实例配置中过度配置存储或计算。 -- 在对象存储上建立的分层存储和多级缓存提供了几乎无限的扩展和良好的价格/性能比,因此您无需提前调整存储分区并担心高存储成本。 -- 默认情况下启用高可用性,复制管理透明,因此您可以专注于构建应用或分析数据。 -- 对于可变的连续工作负载,默认启用了自动扩展,因此您无需提前调整服务规模,在工作负载增加时扩展服务器,或在活动减少时手动缩减服务器。 -- 默认启用无缝休眠以处理间歇性工作负载。我们会在长时间不活动后自动暂停计算资源,并在新查询到达时透明地重新启动,因此您无需为闲置资源支付费用。 -- 高级扩展控制提供了设置自动扩展最大值的能力,以便进行额外的成本控制,或设置自动扩展最小值,以便为具有特殊性能要求的应用保留计算资源。 - -## 功能 {#capabilities} -ClickHouse Cloud 提供对开源 ClickHouse 分发版本中经过筛选的一组功能的访问。下面的表描述了目前在 ClickHouse Cloud 中禁用的一些特性。 - -### DDL 语法 {#ddl-syntax} -在大多数情况下,ClickHouse Cloud 的 DDL 语法应与自管理安装中可用的语法相匹配。有一些显著的例外: - - 不支持 `CREATE AS SELECT`,作为解决方法,我们建议使用 `CREATE ... EMPTY ... AS SELECT`,然后将数据插入该表中(请参阅 [这篇博客](https://clickhouse.com/blog/getting-data-into-clickhouse-part-1) 的示例)。 - - 一些实验性语法可能被禁用,例如 `ALTER TABLE ... MODIFY QUERY` 语句。 - - 一些用于反向工程的功能可能因安全原因被禁用,例如 `addressToLine` SQL 函数。 - - 不要在 ClickHouse Cloud 中使用 `ON CLUSTER` 参数 —— 这些是没有必要的。尽管这些大多数是无操作的函数,但如果您尝试使用 [宏](/operations/server-configuration-parameters/settings#macros),仍然可能会导致错误。宏通常不在 ClickHouse Cloud 中工作且没有必要。 - -### 数据库与表引擎 {#database-and-table-engines} - -ClickHouse Cloud 默认提供高可用和复制的服务。因此,所有数据库和表引擎都是“复制的”。您无需指定“复制”——例如,`ReplicatedMergeTree` 和 `MergeTree` 在 ClickHouse Cloud 中是相同的。 - -**支持的表引擎** - - - ReplicatedMergeTree(默认情况下,未指定时) - - ReplicatedSummingMergeTree - - ReplicatedAggregatingMergeTree - - ReplicatedReplacingMergeTree - - ReplicatedCollapsingMergeTree - - ReplicatedVersionedCollapsingMergeTree - - MergeTree(转换为 ReplicatedMergeTree) - - SummingMergeTree(转换为 ReplicatedSummingMergeTree) - - AggregatingMergeTree(转换为 ReplicatedAggregatingMergeTree) - - ReplacingMergeTree(转换为 ReplicatedReplacingMergeTree) - - CollapsingMergeTree(转换为 ReplicatedCollapsingMergeTree) - - VersionedCollapsingMergeTree(转换为 ReplicatedVersionedCollapsingMergeTree) - - URL - - View - - MaterializedView - - GenerateRandom - - Null - - Buffer - - Memory - - Deltalake - - Hudi - - MySQL - - MongoDB - - NATS - - RabbitMQ - - PostgreSQL - - S3 - -### 接口 {#interfaces} -ClickHouse Cloud 支持 HTTPS、本地接口和 [MySQL 传输协议](/interfaces/mysql)。对于 Postgres 等更多接口的支持即将推出。 - -### 字典 {#dictionaries} -字典是在 ClickHouse 中加速查找的流行方式。ClickHouse Cloud 目前支持来自 PostgreSQL、MySQL、远程和本地 ClickHouse 服务器、Redis、MongoDB 和 HTTP 源的字典。 - -### 联邦查询 {#federated-queries} -我们支持在云中的跨集群通信和与外部自管理 ClickHouse 集群之间的联邦 ClickHouse 查询。ClickHouse Cloud 目前支持使用以下集成引擎进行联邦查询: - - Deltalake - - Hudi - - MySQL - - MongoDB - - NATS - - RabbitMQ - - PostgreSQL - - S3 - -尚不支持与某些外部数据库和表引擎的联邦查询,例如 SQLite、ODBC、JDBC、Redis、HDFS 和 Hive。 - -### 用户定义函数 {#user-defined-functions} - -用户定义函数是 ClickHouse 的一项新功能。ClickHouse Cloud 目前仅支持 SQL 用户定义函数(UDFs)。 - -### 实验性功能 {#experimental-features} - -为了确保服务部署的稳定性,ClickHouse Cloud 服务中禁用实验性功能。 - -### Kafka {#kafka} - -[Kafka 表引擎](/integrations/data-ingestion/kafka/index.md)在 ClickHouse Cloud 中不可用。相反,我们建议依赖将 Kafka 连接组件与 ClickHouse 服务解耦的架构,以实现关注分离。我们推荐使用 [ClickPipes](https://clickhouse.com/cloud/clickpipes) 从 Kafka 流中拉取数据。或者,考虑 [Kafka 用户指南](/integrations/data-ingestion/kafka/index.md) 中列出的基于推送的替代方案。 - -### 命名集合 {#named-collections} - -[命名集合](/operations/named-collections)目前在 ClickHouse Cloud 中不受支持。 - -## 操作默认值和考虑事项 {#operational-defaults-and-considerations} -以下是 ClickHouse Cloud 服务的默认设置。在某些情况下,这些设置是固定的,以确保服务的正确运行,而在其他情况下,它们可以进行调整。 - -### 操作限制 {#operational-limits} - -#### `max_parts_in_total: 10,000` {#max_parts_in_total-10000} -MergeTree 表的 `max_parts_in_total` 设置的默认值已从 100,000 降低到 10,000。此更改的原因是,我们观察到大量数据片段可能会导致云中服务启动时间缓慢。大量的片段通常表示选择了过于细粒度的分区键,这通常是意外造成的,应该避免。默认值的更改将允许更早地检测这些情况。 - -#### `max_concurrent_queries: 1,000` {#max_concurrent_queries-1000} -将此每个服务器设置从默认的 `100` 增加到 `1000` 以允许更多的并发。 -这将导致为所提供层服务的并发查询数为 `副本数 * 1,000`。 -对于限于单个副本的基础服务,支持 `1000` 个并发查询,对于规模和企业版,支持 `1000+`,具体取决于配置的副本数量。 - -#### `max_table_size_to_drop: 1,000,000,000,000` {#max_table_size_to_drop-1000000000000} -将此设置从 50GB 提高,以允许删除高达 1TB 的表/分区。 - -### 系统设置 {#system-settings} -ClickHouse Cloud 针对可变工作负载进行了调整,因此大多数系统设置目前不可配置。我们不预计大多数用户需要调整系统设置,但如果您对高级系统调整有任何疑问,请联系 ClickHouse Cloud 支持。 - -### 高级安全管理 {#advanced-security-administration} -在创建 ClickHouse 服务时,我们创建了一个默认数据库,以及具有广泛权限的默认用户。此初始用户可以创建其他用户并为其分配对该数据库的权限。除此之外,当前不支持在数据库内使用 Kerberos、LDAP 或 SSL X.509 证书身份验证启用以下安全功能的能力。 - -## 路线图 {#roadmap} - -我们正在 Cloud 中引入对可执行用户定义函数(UDFs)的支持,并评估对许多其他功能的需求。如果您有反馈并希望请求特定功能,请 [在这里提交](https://console.clickhouse.cloud/support)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/cloud-compatibility.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/cloud-compatibility.md.hash deleted file mode 100644 index c8103269eef..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/cloud-compatibility.md.hash +++ /dev/null @@ -1 +0,0 @@ -7de3b31c157c42a9 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/index.md index ce297e2e012..4312ab0176e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/index.md @@ -5,27 +5,28 @@ - 'reference' - 'architecture' - 'SharedMergeTree' -- 'Compute-Compute Separation' +- 'Compute-compute Separation' - 'Bring Your Own Cloud' - 'Changelogs' - 'Supported Cloud Regions' - 'Cloud Compatibility' 'title': '概述' 'hide_title': true -'description': '云参考部分的登录页面' +'description': '云参考部分的登录页' +'doc_type': 'landing-page' --- -# Cloud Reference +# Cloud reference 本节作为 ClickHouse Cloud 的一些更技术细节的参考指南,包含以下页面: -| 页面 | 描述 | -|-----------------------------------|-----------------------------------------------------------------------------------------------------------| -| [Architecture](/cloud/reference/architecture) | 讨论 ClickHouse Cloud 的架构,包括存储、计算、管理和安全性。 | -| [SharedMergeTree](/cloud/reference/shared-merge-tree) | 解释 SharedMergeTree,这是一种云原生替代 ReplicatedMergeTree 及其类似物的解决方案。 | -| [Warehouses](/cloud/reference/warehouses) | 解释 ClickHouse Cloud 中的仓库及计算-计算分离的概念。 | -| [BYOC (Bring Your Own Cloud)](/cloud/reference/byoc)| 解释 ClickHouse Cloud 提供的自带云(BYOC)服务。 | -| [Changelogs](/cloud/reference/changelogs) | 云变更日志和版本说明。 | -| [Cloud Compatibility](/whats-new/cloud-compatibility) | 指导您在 ClickHouse Cloud 中功能和操作方面应期待的内容。 | -| [Supported Cloud Regions](/cloud/reference/supported-regions) | 支持 AWS、Google 和 Azure 的云区域列表。 | +| 页面 | 描述 | +|-----------------------------------|--------------------------------------------------------------------------------------------------------| +| [Architecture](/cloud/reference/architecture) | 讨论 ClickHouse Cloud 的架构,包括存储、计算、管理和安全性。 | +| [SharedMergeTree](/cloud/reference/shared-merge-tree) | 解释 SharedMergeTree,这是 ReplicatedMergeTree 及类似产品的云原生替代品。 | +| [Warehouses](/cloud/reference/warehouses) | 解释在 ClickHouse Cloud 中 Warehouses 和计算-计算分离的概念。 | +| [BYOC (Bring Your Own Cloud)](/cloud/reference/byoc)| 解释 ClickHouse Cloud 提供的 Bring Your Own Cloud (BYOC) 服务。 | +| [Changelogs](/cloud/reference/changelogs) | 云变更日志和发布说明。 | +| [Cloud Compatibility](/whats-new/cloud-compatibility) | 指导在 ClickHouse Cloud 中期望的功能和操作性。 | +| [Supported Cloud Regions](/cloud/reference/supported-regions) | 支持的云区域列表,包括 AWS、Google 和 Azure。 | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/index.md.hash index 9db623ba8ef..455b4e49092 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/index.md.hash @@ -1 +1 @@ -45ff30305843593b +c41b711c36ec743f diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/release-notes-index.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/release-notes-index.md deleted file mode 100644 index 4106349a977..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/release-notes-index.md +++ /dev/null @@ -1,18 +0,0 @@ ---- -'slug': '/cloud/reference/changelogs/release-notes' -'title': '云发布说明' -'description': 'Cloud 发布说明的登陆页面' ---- - - - -| 页面 | 描述 | -|-----|-----| -| [v24.5 Cloud 更新日志](/changelogs/24.5) | v24.5 的快速发布更新日志 | -| [v24.10 Cloud 更新日志](/changelogs/24.10) | v24.10 的快速发布更新日志 | -| [v24.8 Cloud 更新日志](/changelogs/24.8) | v24.8 的快速发布更新日志 | -| [v24.12 Cloud 更新日志](/changelogs/24.12) | v24.12 的快速发布更新日志 | -| [v24.6 Cloud 更新日志](/changelogs/24.6) | v24.6 的快速发布更新日志 | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/release-notes-index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/release-notes-index.md.hash deleted file mode 100644 index 746a708914b..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/release-notes-index.md.hash +++ /dev/null @@ -1 +0,0 @@ -e78f3769709d1b41 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/shared-merge-tree.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/shared-merge-tree.md deleted file mode 100644 index 76fb8e7e970..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/shared-merge-tree.md +++ /dev/null @@ -1,121 +0,0 @@ ---- -'slug': '/cloud/reference/shared-merge-tree' -'sidebar_label': 'SharedMergeTree' -'title': 'SharedMergeTree' -'keywords': -- 'SharedMergeTree' -'description': '描述 SharedMergeTree 表引擎' ---- - -import shared_merge_tree from '@site/static/images/cloud/reference/shared-merge-tree-1.png'; -import shared_merge_tree_2 from '@site/static/images/cloud/reference/shared-merge-tree-2.png'; -import Image from '@theme/IdealImage'; - - -# SharedMergeTree 表引擎 - -* ** 仅在 ClickHouse Cloud(和第一方合作伙伴云服务)中提供 ** - -SharedMergeTree 表引擎家族是 ReplicatedMergeTree 引擎的云原生替代品,经过优化以在共享存储(例如 Amazon S3、Google Cloud Storage、MinIO、Azure Blob Storage)上工作。每种特定的 MergeTree 引擎类型都有一个 SharedMergeTree 的对应类型,即 ReplacingSharedMergeTree 替代 ReplacingReplicatedMergeTree。 - -SharedMergeTree 表引擎家族支撑 ClickHouse Cloud。对于最终用户,使用 SharedMergeTree 引擎家族代替基于 ReplicatedMergeTree 的引擎无须进行任何更改。它提供以下额外好处: - -- 更高的插入吞吐量 -- 背景合并的吞吐量提升 -- 突变的吞吐量提升 -- 更快的扩展和缩减操作 -- 对选择查询的更轻量级强一致性 - -SharedMergeTree 带来的一个显著改进是,与 ReplicatedMergeTree 相比,它提供了更深的计算和存储分离。您可以在下面看到 ReplicatedMergeTree 如何分离计算和存储: - -ReplicatedMergeTree Diagram - -正如您所看到的,尽管存储在 ReplicatedMergeTree 中的数据在对象存储中,元数据仍驻留在每个 clickhouse-servers 上。这意味着对于每个复制操作,元数据也需要在所有副本上进行复制。 - -ReplicatedMergeTree Diagram with Metadata - -与 ReplicatedMergeTree 不同,SharedMergeTree 不需要副本之间进行通信。相反,所有通信通过共享存储和 clickhouse-keeper 进行。SharedMergeTree 实现了异步无领导复制,并使用 clickhouse-keeper 进行协调和元数据存储。这意味着随着服务的扩展和缩减,元数据无需被复制。这导致更快的复制、突变、合并和扩展操作。SharedMergeTree 允许每个表有数百个副本,使其能够在没有分片的情况下动态扩展。ClickHouse Cloud 使用分布式查询执行方法来利用更多的计算资源进行查询。 - -## 内省 {#introspection} - -大多数用于 ReplicatedMergeTree 的系统表在 SharedMergeTree 中都存在,除了 `system.replication_queue` 和 `system.replicated_fetches` 因为没有数据和元数据的复制发生。然而,SharedMergeTree 具有这两个表的相应替代项。 - -**system.virtual_parts** - -该表作为 SharedMergeTree 的 `system.replication_queue` 的替代。它存储有关最新一组当前部分的信息,以及正在进行中的未来部分,例如合并、突变和删除的分区。 - -**system.shared_merge_tree_fetches** - -该表是 SharedMergeTree 的 `system.replicated_fetches` 的替代。它包含有关主键和校验和当前进行中的提取到内存的信息。 - -## 启用 SharedMergeTree {#enabling-sharedmergetree} - -`SharedMergeTree` 默认启用。 - -对于支持 SharedMergeTree 表引擎的服务,您无需手动启用任何东西。您可以按照以前的方式创建表,它会自动使用与您在 CREATE TABLE 查询中指定的引擎相对应的基于 SharedMergeTree 的表引擎。 - -```sql -CREATE TABLE my_table( - key UInt64, - value String -) -ENGINE = MergeTree -ORDER BY key -``` - -这将使用 SharedMergeTree 表引擎创建表 `my_table`。 - -在 ClickHouse Cloud 中,您不需要指定 `ENGINE=MergeTree`,因为 `default_table_engine=MergeTree`。以下查询与上述查询是相同的。 - -```sql -CREATE TABLE my_table( - key UInt64, - value String -) -ORDER BY key -``` - -如果您使用 Replacing、Collapsing、Aggregating、Summing、VersionedCollapsing 或 Graphite MergeTree 表,它将自动转换为相应的基于 SharedMergeTree 的表引擎。 - -```sql -CREATE TABLE myFirstReplacingMT -( - `key` Int64, - `someCol` String, - `eventTime` DateTime -) -ENGINE = ReplacingMergeTree -ORDER BY key; -``` - -对于给定的表,您可以使用 `SHOW CREATE TABLE` 检查使用的表引擎: -```sql -SHOW CREATE TABLE myFirstReplacingMT; -``` - -```sql -CREATE TABLE default.myFirstReplacingMT -( `key` Int64, `someCol` String, `eventTime` DateTime ) -ENGINE = SharedReplacingMergeTree('/clickhouse/tables/{uuid}/{shard}', '{replica}') -ORDER BY key -``` - -## 设置 {#settings} - -某些设置的行为发生了显著变化: - -- `insert_quorum` - 所有对 SharedMergeTree 的插入都是法定插入(写入共享存储),因此在使用 SharedMergeTree 表引擎时不需要此设置。 -- `insert_quorum_parallel` - 所有对 SharedMergeTree 的插入都是法定插入(写入共享存储),因此在使用 SharedMergeTree 表引擎时不需要此设置。 -- `select_sequential_consistency` - 不需要法定插入,将在 `SELECT` 查询时触发对 clickhouse-keeper 的额外负载。 - -## 一致性 {#consistency} - -SharedMergeTree 提供比 ReplicatedMergeTree 更好的轻量级一致性。插入 SharedMergeTree 时,您无需提供诸如 `insert_quorum` 或 `insert_quorum_parallel` 的设置。插入就是法定插入,这意味着元数据将存储在 ClickHouse-Keeper 中,且元数据会复制到至少法定数量的 ClickHouse-Keeper。集群中的每个副本将异步从 ClickHouse-Keeper 获取新信息。 - -大多数情况下,您不应使用 `select_sequential_consistency` 或 `SYSTEM SYNC REPLICA LIGHTWEIGHT`。异步复制应该涵盖大多数场景,并且延迟非常低。在极少数情况下,如果您确实需要防止过时的读取,请按以下优先顺序遵循这些建议: - -1. 如果您在同一会话或同一节点中执行读取和写入查询,则不需要使用 `select_sequential_consistency`,因为您的副本将已经拥有最新的元数据。 - -2. 如果您在一个副本中写入并在另一个副本中读取,您可以使用 `SYSTEM SYNC REPLICA LIGHTWEIGHT` 来强制副本从 ClickHouse-Keeper 获取元数据。 - -3. 将 `select_sequential_consistency` 用作查询的一部分。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/shared-merge-tree.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/shared-merge-tree.md.hash deleted file mode 100644 index 70bc48cb3f6..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/shared-merge-tree.md.hash +++ /dev/null @@ -1 +0,0 @@ -ea6bc4485d010335 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/supported-regions.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/supported-regions.md.hash deleted file mode 100644 index 4abb0067808..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/supported-regions.md.hash +++ /dev/null @@ -1 +0,0 @@ -f2d355a55a35b571 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/warehouses.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/warehouses.md deleted file mode 100644 index 98ddcc284a5..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/warehouses.md +++ /dev/null @@ -1,189 +0,0 @@ ---- -'title': '仓库' -'slug': '/cloud/reference/warehouses' -'keywords': -- 'compute separation' -- 'cloud' -- 'architecture' -- 'compute-compute' -- 'warehouse' -- 'warehouses' -- 'hydra' -'description': 'ClickHouse Cloud中的计算-计算分离' ---- - -import compute_1 from '@site/static/images/cloud/reference/compute-compute-1.png'; -import compute_2 from '@site/static/images/cloud/reference/compute-compute-2.png'; -import compute_3 from '@site/static/images/cloud/reference/compute-compute-3.png'; -import compute_4 from '@site/static/images/cloud/reference/compute-compute-4.png'; -import compute_5 from '@site/static/images/cloud/reference/compute-compute-5.png'; -import compute_7 from '@site/static/images/cloud/reference/compute-compute-7.png'; -import compute_8 from '@site/static/images/cloud/reference/compute-compute-8.png'; -import Image from '@theme/IdealImage'; - - -# 仓库 - -## 计算-计算分离是什么? {#what-is-compute-compute-separation} - -计算-计算分离适用于 Scale 和 Enterprise 级别。 - -每个 ClickHouse Cloud 服务包括: -- 需要一组两个或更多 ClickHouse 节点(或副本),但子服务可以是单个副本。 -- 一个端点(或通过 ClickHouse Cloud UI 控制台创建的多个端点),这是连接到服务的服务 URL(例如,`https://dv2fzne24g.us-east-1.aws.clickhouse.cloud:8443`)。 -- 一个对象存储文件夹,服务在其中存储所有数据和部分元数据: - -:::note -子单服务可以垂直扩展,不同于单父服务。 -::: - -当前在 ClickHouse Cloud 的服务 - -
- -_Fig. 1 - 当前在 ClickHouse Cloud 的服务_ - -计算-计算分离允许用户创建多个计算节点组,每个节点组都有自己的端点,使用相同的对象存储文件夹,因此拥有相同的表、视图等。 - -每个计算节点组将有其自己的端点,因此您可以选择用于工作负载的副本集。您的某些工作负载可能只需要一个小型副本,而其他工作负载可能需要完整的高可用性(HA)和数百GB的内存。计算-计算分离还允许您将读操作与写操作分开,以便它们不会相互干扰: - -ClickHouse Cloud 中的计算分离 - -
- -_Fig. 2 - ClickHouse Cloud 中的计算分离_ - -可以创建额外的服务,与现有服务共享相同的数据,或者创建一个完全新的设置,其中多个服务共享相同的数据。 - -## 什么是仓库? {#what-is-a-warehouse} - -在 ClickHouse Cloud 中,一个 _仓库_ 是一组共享相同数据的服务。 -每个仓库都有一个主服务(这个服务是第一个创建的)和一个或多个副服务。例如,在下面的截图中,您可以看到名为 "DWH Prod" 的仓库,其中有两个服务: - -- 主服务 `DWH Prod` -- 副服务 `DWH Prod Subservice` - -带有主服务和副服务的仓库示例 - -
- -_Fig. 3 - 仓库示例_ - -仓库中的所有服务共享相同的: - -- 区域(例如,us-east1) -- 云服务提供商(AWS、GCP 或 Azure) -- ClickHouse 数据库版本 - -您可以按它们所属的仓库对服务进行排序。 - -## 访问控制 {#access-controls} - -### 数据库凭据 {#database-credentials} - -因为仓库中的所有服务共享相同的表集合,所以它们也共享对其他服务的访问控制。这意味着在服务 1 中创建的所有数据库用户也可以使用服务 2,享有相同的权限(对表、视图等的授权),反之亦然。用户将为每个服务使用不同的端点,但将使用相同的用户名和密码。换句话说,_用户在与相同存储工作时是在服务间共享的:_ - -共享相同数据的服务之间的用户访问 - -
- -_Fig. 4 - 用户 Alice 在服务 1 中创建,但她可以使用相同的凭据访问所有共享相同数据的服务_ - -### 网络访问控制 {#network-access-control} - -通常,限制特定服务被其他应用程序或临时用户使用是非常有用的。可以通过使用网络限制来完成这一点,类似于当前为常规服务配置的方式(在 ClickHouse Cloud 控制台中特定服务的 **设置** 中导航)。 - -您可以单独对每个服务应用 IP 过滤设置,这意味着您可以控制哪个应用程序可以访问哪个服务。这允许您限制用户使用特定服务: - -网络访问控制设置 - -
- -_Fig. 5 - Alice 因网络设置被限制访问服务 2_ - -### 只读与可读写 {#read-vs-read-write} - -有时,限制特定服务的写入访问并仅允许一个仓库中的某些服务写入是很有用的。这可以在创建第二个及后续服务时完成(第一个服务应始终是可读可写的): - -仓库中的可读写和只读服务 - -
- -_Fig. 6 - 仓库中的可读写和只读服务_ - -:::note -1. 当前,只读服务允许用户管理操作(创建、删除等)。这种行为可能会在未来发生变化。 -2. 目前,可刷新的物化视图在仓库中的所有服务上执行,包括只读服务。然而,将来这种行为将会改变,它们将仅在 RW 服务上执行。 -::: - - -## 扩展 {#scaling} - -仓库中的每个服务可以根据您的工作负载进行调整: -- 节点数(副本)。主服务(在仓库中首先创建的服务)应具有两个或更多节点。每个副服务可以有一个或多个节点。 -- 节点(副本)的大小 -- 服务是否应自动扩展 -- 服务是否应在不活动时闲置(不能应用于组中的第一个服务 - 请参见 **限制** 部分) - -## 行为变化 {#changes-in-behavior} -一旦为服务启用计算-计算(至少创建了一个副服务),则对 `default` 集群名称的 `clusterAllReplicas()` 函数调用将仅利用调用该函数的服务中的副本。这意味着,如果有两个服务连接到同一个数据集,并且从服务 1 调用 `clusterAllReplicas(default, system, processes)`,则仅会显示在服务 1 上运行的进程。如果需要,您仍然可以调用 `clusterAllReplicas('all_groups.default', system, processes)` 例如以访问所有副本。 - -## 限制 {#limitations} - -1. **主服务应始终处于运行状态,且不能闲置(限制将在 GA 之后的某个时间移除)。** 在私有预览期间以及 GA 后的一段时间,主服务(通常是您希望通过添加其他服务进行扩展的现有服务)将始终处于运行状态,并禁用闲置设置。如果至少存在一个副服务,您将无法停止或闲置主服务。一旦所有副服务被移除,您可以再次停止或闲置原始服务。 - -2. **有时候工作负载无法隔离。** 尽管目标是为您提供将数据库工作负载彼此隔离的选项,但在某些极端情况下,一个服务中的工作负载可能会影响共享相同数据的另一个服务。这种情况非常少见,大多数与 OLTP 类似的工作负载有关。 - -3. **所有可读写服务都在执行后台合并操作。** 当将数据插入 ClickHouse 时,数据库首先将数据插入某些暂存分区,然后在后台执行合并。这些合并可能消耗内存和 CPU 资源。当两个可读写服务共享相同的存储时,它们都在执行后台操作。这意味着可能出现 Service 1 中有一个 `INSERT` 查询,但合并操作由 Service 2 完成的情况。请注意,只有只读服务不会执行后台合并,因此不会在此操作上消耗其资源。 - -4. **一个可读写服务中的插入可能会阻止另一个可读写服务闲置(如果已启用闲置)。** 由于前一点,第二个服务为第一个服务执行后台合并操作。这些后台操作可能会阻止第二个服务在闲置时进入休眠状态。一旦后台操作完成,服务将被闲置。只读服务不受影响,并将毫不延迟地闲置。 - -5. **CREATE/RENAME/DROP DATABASE 查询可能默认会被闲置/停止的服务阻塞。** 这些查询可能会挂起。为绕过此问题,您可以以会话或每个查询级别运行数据库管理查询,方法是设置 `settings distributed_ddl_task_timeout=0`。例如: - -```sql -create database db_test_ddl_single_query_setting -settings distributed_ddl_task_timeout=0 -``` - -6. **在极少数情况下,闲置或停止超过一段时间(天)的副服务可能会导致同一仓库中其他服务的性能下降。** 此问题将很快得到解决,与后台执行的变更有关。如果您认为您正在经历此问题,请联系 ClickHouse [支持](https://clickhouse.com/support/program)。 - -7. **目前,每个仓库的服务数的软限制为 5 个。** 如果您需要在单个仓库中使用超过 5 个服务,请联系支持团队。 - - -## 定价 {#pricing} - -计算价格在仓库中的所有服务(主服务和副服务)中都是相同的。存储仅按一次计费 - 它包含在第一个(原始)服务中。 - -## 备份 {#backups} - -- 由于单个仓库中的所有服务共享相同的存储,因此备份仅在主(初始)服务上进行。通过这种方式,可以备份仓库中所有服务的数据。 -- 如果您从仓库的主服务恢复备份,它将被恢复到一个完全新的服务,而不是连接到现有仓库。您可以在恢复完成后立即向新服务添加更多服务。 - -## 使用仓库 {#using-warehouses} - -### 创建仓库 {#creating-a-warehouse} - -要创建一个仓库,您需要创建一个第二个服务,该服务将与现有服务共享数据。这可以通过单击任何现有服务上的加号来完成: - -在仓库中创建新服务 - -
- -_Fig. 7 - 单击加号以在仓库中创建新服务_ - -在服务创建屏幕上,会在下拉菜单中选择原始服务作为新服务数据的来源。一旦创建,这两个服务将形成一个仓库。 - -### 重命名仓库 {#renaming-a-warehouse} - -有两种方法可以重命名仓库: - -- 您可以在服务页面右上角选择 "按仓库排序",然后单击仓库名称旁的铅笔图标 -- 您可以单击任何服务上的仓库名称,并在那条重命名仓库 - -### 删除仓库 {#deleting-a-warehouse} - -删除仓库意味着删除所有计算服务和数据(表、视图、用户等)。此操作无法撤消。 -您只能通过删除第一个创建的服务来删除仓库。为此: - -1. 删除所有在第一个创建服务后创建的额外服务; -2. 删除第一个服务(警告:在此步骤中将删除所有仓库的数据)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/warehouses.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/warehouses.md.hash deleted file mode 100644 index ecb25c1c895..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/reference/warehouses.md.hash +++ /dev/null @@ -1 +0,0 @@ -d6ad26bda3aae394 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/_category_.yml b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/_category_.yml deleted file mode 100644 index b7253753fd5..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/_category_.yml +++ /dev/null @@ -1,6 +0,0 @@ -label: 'Cloud Security' -collapsible: true -collapsed: true -link: - type: generated-index - title: Cloud Security diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/accessing-s3-data-securely.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/accessing-s3-data-securely.md deleted file mode 100644 index 9e75338c456..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/accessing-s3-data-securely.md +++ /dev/null @@ -1,147 +0,0 @@ ---- -'slug': '/cloud/security/secure-s3' -'sidebar_label': '安全访问 S3 数据' -'title': '安全访问 S3 数据' -'description': '本文演示了 ClickHouse Cloud 客户如何利用基于角色的访问来与 Amazon Simple Storage Service - (S3) 进行身份验证,并安全地访问他们的数据。' ---- - -import Image from '@theme/IdealImage'; -import secure_s3 from '@site/static/images/cloud/security/secures3.jpg'; -import s3_info from '@site/static/images/cloud/security/secures3_arn.png'; -import s3_output from '@site/static/images/cloud/security/secures3_output.jpg'; - -This article demonstrates how ClickHouse Cloud customers can leverage role-based access to authenticate with Amazon Simple Storage Service(S3) and access their data securely. - -## Introduction {#introduction} - -在深入了解安全 S3 访问设置之前,了解其工作原理是非常重要的。以下是 ClickHouse 服务如何通过在客户的 AWS 账户中假设角色来访问私有 S3 桶的概述。 - -Overview of Secure S3 Access with ClickHouse - -这种方法允许客户在一个地方(假设角色的 IAM 策略)管理对其 S3 桶的所有访问,而无需遍历其所有桶策略来添加或删除访问权限。 - -## Setup {#setup} - -### Obtaining the ClickHouse service IAM role Arn {#obtaining-the-clickhouse-service-iam-role-arn} - -1 - 登录到您的 ClickHouse 云账户。 - -2 - 选择您要创建集成的 ClickHouse 服务。 - -3 - 选择 **设置** 选项卡。 - -4 - 向下滚动到页面底部的 **网络安全信息** 部分。 - -5 - 复制该服务的 **服务角色 ID (IAM)** 值,如下所示。 - -Obtaining ClickHouse service IAM Role ARN - -### Setting up IAM assume role {#setting-up-iam-assume-role} - -#### Option 1: Deploying with CloudFormation stack {#option-1-deploying-with-cloudformation-stack} - -1 - 使用具有创建和管理 IAM 角色权限的 IAM 用户登录到您的 AWS 账户。 - -2 - 访问 [this url](https://us-west-2.console.aws.amazon.com/cloudformation/home?region=us-west-2#/stacks/quickcreate?templateURL=https://s3.us-east-2.amazonaws.com/clickhouse-public-resources.clickhouse.cloud/cf-templates/secure-s3.yaml&stackName=ClickHouseSecureS3) 来填充 CloudFormation 堆栈。 - -3 - 输入(或粘贴)属于 ClickHouse 服务的 **IAM 角色**。 - -4 - 配置 CloudFormation 堆栈。以下是关于这些参数的额外信息。 - -| 参数 | 默认值 | 描述 | -| :--- | :----: | :---- | -| RoleName | ClickHouseAccess-001 | ClickHouse Cloud 将用于访问您的 S3 桶的新角色的名称 | -| Role Session Name | * | 角色会话名称可以用作共享密钥以进一步保护您的桶。 | -| ClickHouse Instance Roles | | 可使用此安全 S3 集成的 ClickHouse 服务 IAM 角色的逗号分隔列表。 | -| Bucket Access | Read | 设置提供桶的访问级别。 | -| Bucket Names | | 此角色将有权访问的 **桶名称** 的逗号分隔列表。 | - -*注意*: 请勿填写完整的桶 Arn,而只需填写桶名称。 - -5 - 选择 **我承认 AWS CloudFormation 可能会创建带有自定义名称的 IAM 资源。** 复选框。 - -6 - 点击右下角的 **创建堆栈** 按钮。 - -7 - 确保 CloudFormation 堆栈完成且没有错误。 - -8 - 选择 CloudFormation 堆栈的 **输出**。 - -9 - 复制该集成的 **RoleArn** 值。这是访问您的 S3 桶所需的。 - -CloudFormation stack output showing IAM Role ARN - -#### Option 2: Manually create IAM role. {#option-2-manually-create-iam-role} - -1 - 使用具有创建和管理 IAM 角色权限的 IAM 用户登录到您的 AWS 账户。 - -2 - 浏览到 IAM 服务控制台。 - -3 - 创建一个新的 IAM 角色,使用以下 IAM 和信任策略。 - -信任策略(请将 `{ClickHouse_IAM_ARN}` 替换为属于您的 ClickHouse 实例的 IAM 角色 Arn): - -```json -{ - "Version": "2012-10-17", - "Statement": [ - { - "Effect": "Allow", - "Principal": { - "AWS": "{ClickHouse_IAM_ARN}" - }, - "Action": "sts:AssumeRole" - } - ] -} -``` - -IAM 策略(请将 `{BUCKET_NAME}` 替换为您的桶名称): - -```json -{ - "Version": "2012-10-17", - "Statement": [ - { - "Action": [ - "s3:GetBucketLocation", - "s3:ListBucket" - ], - "Resource": [ - "arn:aws:s3:::{BUCKET_NAME}" - ], - "Effect": "Allow" - }, - { - "Action": [ - "s3:Get*", - "s3:List*" - ], - "Resource": [ - "arn:aws:s3:::{BUCKET_NAME}/*" - ], - "Effect": "Allow" - } - ] -} -``` - -4 - 创建后复制新的 **IAM 角色 Arn**。这是访问您的 S3 桶所需的。 - -## Access your S3 bucket with the ClickHouseAccess Role {#access-your-s3-bucket-with-the-clickhouseaccess-role} - -ClickHouse Cloud 具有一个新功能,允许您在 S3 表函数中指定 `extra_credentials`。以下是如何使用从上面复制的新角色运行查询的示例。 - -```sql -DESCRIBE TABLE s3('https://s3.amazonaws.com/BUCKETNAME/BUCKETOBJECT.csv','CSVWithNames',extra_credentials(role_arn = 'arn:aws:iam::111111111111:role/ClickHouseAccessRole-001')) -``` - -下面是一个示例查询,它使用 `role_session_name` 作为共享密钥从桶中查询数据。如果 `role_session_name` 不正确,此操作将失败。 - -```sql -DESCRIBE TABLE s3('https://s3.amazonaws.com/BUCKETNAME/BUCKETOBJECT.csv','CSVWithNames',extra_credentials(role_arn = 'arn:aws:iam::111111111111:role/ClickHouseAccessRole-001', role_session_name = 'secret-role-name')) -``` - -:::note -我们建议您的源 S3 位于与您 ClickHouse 云服务相同的区域,以减少数据传输成本。有关更多信息,请参考 [S3 pricing]( https://aws.amazon.com/s3/pricing/) -::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/accessing-s3-data-securely.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/accessing-s3-data-securely.md.hash deleted file mode 100644 index ce2a099cc8e..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/accessing-s3-data-securely.md.hash +++ /dev/null @@ -1 +0,0 @@ -785df0b271a0a024 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/audit-logging.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/audit-logging.md.hash deleted file mode 100644 index 686be939f79..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/audit-logging.md.hash +++ /dev/null @@ -1 +0,0 @@ -85a890844d282bbf diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/aws-privatelink.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/aws-privatelink.md deleted file mode 100644 index 05d7ceffc7b..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/aws-privatelink.md +++ /dev/null @@ -1,359 +0,0 @@ ---- -'title': 'AWS PrivateLink' -'description': '本文档描述了如何使用 AWS PrivateLink 连接到 ClickHouse Cloud。' -'slug': '/manage/security/aws-privatelink' ---- - -import Image from '@theme/IdealImage'; -import ScalePlanFeatureBadge from '@theme/badges/ScalePlanFeatureBadge'; -import aws_private_link_pecreate from '@site/static/images/cloud/security/aws-privatelink-pe-create.png'; -import aws_private_link_endpoint_settings from '@site/static/images/cloud/security/aws-privatelink-endpoint-settings.png'; -import aws_private_link_select_vpc from '@site/static/images/cloud/security/aws-privatelink-select-vpc-and-subnets.png'; -import aws_private_link_vpc_endpoint_id from '@site/static/images/cloud/security/aws-privatelink-vpc-endpoint-id.png'; -import aws_private_link_endpoints_menu from '@site/static/images/cloud/security/aws-privatelink-endpoints-menu.png'; -import aws_private_link_modify_dnsname from '@site/static/images/cloud/security/aws-privatelink-modify-dns-name.png'; -import pe_remove_private_endpoint from '@site/static/images/cloud/security/pe-remove-private-endpoint.png'; -import aws_private_link_pe_filters from '@site/static/images/cloud/security/aws-privatelink-pe-filters.png'; -import aws_private_link_ped_nsname from '@site/static/images/cloud/security/aws-privatelink-pe-dns-name.png'; - - -# AWS PrivateLink - - - -您可以使用 [AWS PrivateLink](https://aws.amazon.com/privatelink/) 在 VPC、AWS 服务、您的本地系统和 ClickHouse Cloud 之间建立安全连接,而无需将流量暴露于公共互联网。本文档概述了使用 AWS PrivateLink 连接到 ClickHouse Cloud 的步骤。 - -要仅通过 AWS PrivateLink 地址限制对 ClickHouse Cloud 服务的访问,请按照 ClickHouse Cloud [IP 访问列表](/cloud/security/setting-ip-filters) 中提供的说明操作。 - -:::note -ClickHouse Cloud 目前支持 [跨区域 PrivateLink](https://aws.amazon.com/about-aws/whats-new/2024/11/aws-privatelink-across-region-connectivity/) 的测试版。 -::: - - -**请完成以下操作以启用 AWS PrivateLink**: -1. 获取端点“服务名称”。 -1. 创建 AWS 端点。 -1. 将“端点 ID”添加到 ClickHouse Cloud 组织。 -1. 将“端点 ID”添加到 ClickHouse 服务允许列表。 - - -可以在 [这里](https://github.com/ClickHouse/terraform-provider-clickhouse/tree/main/examples/) 找到 Terraform 示例。 - - -## 注意 {#attention} -ClickHouse 尝试将您的服务分组,以在 AWS 区域内重用相同的发布 [服务端点](https://docs.aws.amazon.com/vpc/latest/privatelink/privatelink-share-your-services.html#endpoint-service-overview)。但是,这种分组并不总是保证,特别是当您将服务分散到多个 ClickHouse 组织时。 -如果您已经为 ClickHouse 组织中的其他服务配置了 PrivateLink,通常可以跳过大部分步骤,因为可以直接进入最后一步:[将 ClickHouse“端点 ID”添加到 ClickHouse 服务允许列表](#add-endpoint-id-to-services-allow-list)。 - - -## 前提条件 {#prerequisites} - -在开始之前,您需要: - -1. 您的 AWS 账户。 -1. 具有必要权限以在 ClickHouse 端创建和管理私有端点的 [ClickHouse API 密钥](/cloud/manage/openapi)。 - -## 步骤 {#steps} - -按照以下步骤通过 AWS PrivateLink 连接您的 ClickHouse Cloud 服务。 - -### 获取端点“服务名称” {#obtain-endpoint-service-info} - -#### 选项 1:ClickHouse Cloud 控制台 {#option-1-clickhouse-cloud-console} - -在 ClickHouse Cloud 控制台中,打开您想要通过 PrivateLink 连接的服务,然后导航到 **设置** 菜单。 - -私有端点 - -记下 `服务名称` 和 `DNS 名称`,然后 [移动到下一步](#create-aws-endpoint)。 - -#### 选项 2:API {#option-2-api} - -首先,在运行任何命令之前设置以下环境变量: - -```shell -REGION= -PROVIDER=aws -KEY_ID= -KEY_SECRET= -ORG_ID= -SERVICE_NAME= -``` - -通过按区域、提供者和服务名称进行过滤,获取您的 ClickHouse `INSTANCE_ID`: - -```shell -INSTANCE_ID=$(curl --silent --user "${KEY_ID:?}:${KEY_SECRET:?}" \ -"https://api.clickhouse.cloud/v1/organizations/${ORG_ID:?}/services" | \ -jq ".result[] | select (.region==\"${REGION:?}\" and .provider==\"${PROVIDER:?}\" and .name==\"${SERVICE_NAME:?}\") | .id " -r) -``` - -获取您的 PrivateLink 配置的 `endpointServiceId` 和 `privateDnsHostname`: - -```bash -curl --silent --user "${KEY_ID:?}:${KEY_SECRET:?}" \ -"https://api.clickhouse.cloud/v1/organizations/${ORG_ID:?}/services/${INSTANCE_ID:?}/privateEndpointConfig" | \ -jq .result -``` - -此命令应该返回类似于以下内容: - -```result -{ - "endpointServiceId": "com.amazonaws.vpce.us-west-2.vpce-svc-xxxxxxxxxxxxxxxxx", - "privateDnsHostname": "xxxxxxxxxx.us-west-2.vpce.aws.clickhouse.cloud" -} -``` - -记下 `endpointServiceId` 和 `privateDnsHostname`, [移动到下一步](#create-aws-endpoint)。 - -### 创建 AWS 端点 {#create-aws-endpoint} - -:::important -本节介绍通过 AWS PrivateLink 配置 ClickHouse 的特定细节。提供了 AWS 特定步骤以供参考,但这些步骤可能会随着时间而变化,且 AWS 云提供商不会发出通知。请根据您的具体用例考虑 AWS 配置。 - -请注意,ClickHouse 并不负责配置所需的 AWS VPC 端点、安全组规则或 DNS 记录。 - -如果您在设置 PrivateLink 时以前启用了“私有 DNS 名称”,并且在通过 PrivateLink 配置新服务时遇到困难,请联系 ClickHouse 支持。有关 AWS 配置任务的其他问题,请直接联系 AWS 支持。 -::: - -#### 选项 1:AWS 控制台 {#option-1-aws-console} - -打开 AWS 控制台并转到 **VPC** → **端点** → **创建端点**。 - -选择 **使用 NLB 和 GWLB 的端点服务**,并在 **服务名称** 字段中使用您从 [获取端点“服务名称” ](#obtain-endpoint-service-info) 步骤中获得的 `服务名称`console 或 `endpointServiceId`API。单击 **验证服务**: - -AWS PrivateLink 端点设置 - -如果您想通过 PrivateLink 建立跨区域连接,请启用“跨区域端点”复选框,并指定服务区域。服务区域是 ClickHouse 实例运行的地方。 - -如果出现“无法验证服务名称。”错误,请联系客户支持请求将新区域添加到支持区域列表中。 - -接下来,选择您的 VPC 和子网: - -选择 VPC 和子网 - -作为可选步骤,分配安全组/标签: - -:::note -确保安全组中开放 `443`、`8443`、`9440`、`3306` 端口。 -::: - -创建 VPC 端点后,请记下 `端点 ID` 值;您将在后续步骤中需要它。 - -VPC 端点 ID - -#### 选项 2:AWS CloudFormation {#option-2-aws-cloudformation} - -接下来,您需要使用您从 [获取端点“服务名称” ](#obtain-endpoint-service-info) 步骤中获得的 `服务名称`console 或 `endpointServiceId`API 创建一个 VPC 端点。 -确保使用正确的子网 ID、安全组和 VPC ID。 - -```response -Resources: - ClickHouseInterfaceEndpoint: - Type: 'AWS::EC2::VPCEndpoint' - Properties: - VpcEndpointType: Interface - PrivateDnsEnabled: false - ServiceName: - VpcId: vpc-vpc_id - SubnetIds: - - subnet-subnet_id1 - - subnet-subnet_id2 - - subnet-subnet_id3 - SecurityGroupIds: - - sg-security_group_id1 - - sg-security_group_id2 - - sg-security_group_id3 -``` - -创建 VPC 端点后,请记下 `端点 ID` 值;您将在后续步骤中需要它。 - -#### 选项 3:Terraform {#option-3-terraform} - -以下的 `service_name` 是您从 [获取端点“服务名称” ](#obtain-endpoint-service-info) 步骤中获得的 `服务名称`console 或 `endpointServiceId`API。 - -```json -resource "aws_vpc_endpoint" "this" { - vpc_id = var.vpc_id - service_name = "" - vpc_endpoint_type = "Interface" - security_group_ids = [ - Var.security_group_id1,var.security_group_id2, var.security_group_id3, - ] - subnet_ids = [var.subnet_id1,var.subnet_id2,var.subnet_id3] - private_dns_enabled = false - service_region = "(Optional) If specified, the VPC endpoint will connect to the service in the provided region. Define it for multi-regional PrivateLink connections." -} -``` - -创建 VPC 端点后,请记下 `端点 ID` 值;您将在后续步骤中需要它。 - -#### 为端点设置私有 DNS 名称 {#set-private-dns-name-for-endpoint} - -:::note -有多种配置 DNS 的方法。请根据您的具体用例设置 DNS。 -::: - -您需要将从 [获取端点“服务名称” ](#obtain-endpoint-service-info) 步骤中获取的“DNS 名称”指向 AWS 端点网络接口。这确保您 VPC/网络内的服务/组件可以正确解析它。 - -### 将“端点 ID”添加到 ClickHouse 服务允许列表 {#add-endpoint-id-to-services-allow-list} - -#### 选项 1:ClickHouse Cloud 控制台 {#option-1-clickhouse-cloud-console-2} - -要添加,请导航到 ClickHouse Cloud 控制台,打开您希望通过 PrivateLink 连接的服务,然后导航到 **设置**。单击 **设置私有端点** 以打开私有端点设置。输入从 [创建 AWS 端点](#create-aws-endpoint) 步骤中获得的 `端点 ID`。点击“创建端点”。 - -:::note -如果您想允许来自现有 PrivateLink 连接的访问,请使用现有端点下拉菜单。 -::: - -私有端点过滤器 - -要删除,请导航到 ClickHouse Cloud 控制台,找到该服务,然后导航到服务的 **设置**,找到您想要删除的端点。从端点列表中将其删除。 - -#### 选项 2:API {#option-2-api-2} - -您需要将端点 ID 添加到应使用 PrivateLink 访问的每个实例的允许列表中。 - -使用来自 [创建 AWS 端点](#create-aws-endpoint) 步骤的数据设置 `ENDPOINT_ID` 环境变量。 - -在运行任何命令之前设置以下环境变量: - -```bash -REGION= -PROVIDER=aws -KEY_ID= -KEY_SECRET= -ORG_ID= -SERVICE_NAME= -``` - -要将端点 ID 添加到允许列表: - -```bash -cat <API 或 `DNS 名称`console。 - -#### 获取私有 DNS 主机名 {#getting-private-dns-hostname} - -##### 选项 1:ClickHouse Cloud 控制台 {#option-1-clickhouse-cloud-console-3} - -在 ClickHouse Cloud 控制台中,导航到 **设置**。单击 **设置私有端点** 按钮。在打开的飞出菜单中,复制 **DNS 名称**。 - -私有端点 DNS 名称 - -##### 选项 2:API {#option-2-api-3} - -在运行任何命令之前设置以下环境变量: - -```bash -KEY_ID= -KEY_SECRET= -ORG_ID= -INSTANCE_ID= -``` - -您可以从 [步骤](#option-2-api) 中检索 `INSTANCE_ID`。 - -```bash -curl --silent --user "${KEY_ID:?}:${KEY_SECRET:?}" \ -"https://api.clickhouse.cloud/v1/organizations/${ORG_ID:?}/services/${INSTANCE_ID:?}/privateEndpointConfig" | \ -jq .result -``` - -这应该输出类似于: - -```result -{ - "endpointServiceId": "com.amazonaws.vpce.us-west-2.vpce-svc-xxxxxxxxxxxxxxxxx", - "privateDnsHostname": "xxxxxxxxxx.us-west-2.vpce.aws.clickhouse.cloud" -} -``` - -在此示例中,通过 `privateDnsHostname` 主机名连接将路由到 PrivateLink,但通过 `endpointServiceId` 主机名的连接将通过互联网路由。 - -## 故障排除 {#troubleshooting} - -### 一个区域内的多个 PrivateLinks {#multiple-privatelinks-in-one-region} - -在大多数情况下,您只需为每个 VPC 创建一个单一的端点服务。此端点可以将请求从 VPC 路由到多个 ClickHouse Cloud 服务。 -请参见 [这里](#attention) - -### 连接到私有端点超时 {#connection-to-private-endpoint-timed-out} - -- 请将安全组附加到 VPC 端点。 -- 请验证附加到端点的安全组上的 `inbound` 规则,并允许 ClickHouse 端口。 -- 请验证用于连通性测试的 VM 上附加的安全组的 `outbound` 规则,并允许对 ClickHouse 端口的连接。 - -### 私有主机名:未找到主机地址 {#private-hostname-not-found-address-of-host} - -- 请检查您的 DNS 配置。 - -### 连接被对等方重置 {#connection-reset-by-peer} - -- 端点 ID 可能未添加到服务允许列表中,请访问 [步骤](#add-endpoint-id-to-services-allow-list)。 - -### 检查端点过滤器 {#checking-endpoint-filters} - -在运行任何命令之前设置以下环境变量: - -```bash -KEY_ID= -KEY_SECRET= -ORG_ID= -INSTANCE_ID= -``` - -您可以从 [步骤](#option-2-api) 中检索 `INSTANCE_ID`。 - -```shell -curl --silent --user "${KEY_ID:?}:${KEY_SECRET:?}" \ --X GET -H "Content-Type: application/json" \ -"https://api.clickhouse.cloud/v1/organizations/${ORG_ID:?}/services/${INSTANCE_ID:?}" | \ -jq .result.privateEndpointIds -``` - -### 连接到远程数据库 {#connecting-to-a-remote-database} - -假设您正在尝试在 ClickHouse Cloud 中使用 [MySQL](../../sql-reference/table-functions/mysql.md) 或 [PostgreSQL](../../sql-reference/table-functions/postgresql.md) 表函数并连接到托管在 Amazon Web Services (AWS) VPC 中的数据库。不能使用 AWS PrivateLink 安全地启用此连接。PrivateLink 是单向的、单向连接。它允许您的内部网络或 Amazon VPC 安全连接到 ClickHouse Cloud,但不允许 ClickHouse Cloud 连接到您的内部网络。 - -根据 [AWS PrivateLink 文档](https://docs.aws.amazon.com/whitepapers/latest/building-scalable-secure-multi-vpc-network-infrastructure/aws-privatelink.html): - -> 当您有一个客户端/服务器设置时,想让一个或多个消费者 VPC 对服务提供者 VPC 中的特定服务或一组实例具有单向访问权限时,使用 AWS PrivateLink。只有消费者 VPC 中的客户端可以发起与服务提供者 VPC 中的服务的连接。 - -为此,配置您的 AWS 安全组以允许 ClickHouse Cloud 连接到您内部/私有数据库服务。查看 [ClickHouse Cloud 区域的默认出站 IP 地址](/manage/security/cloud-endpoints-api),以及 [可用的静态 IP 地址](https://api.clickhouse.cloud/static-ips.json)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/aws-privatelink.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/aws-privatelink.md.hash deleted file mode 100644 index 70fd5cb9d95..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/aws-privatelink.md.hash +++ /dev/null @@ -1 +0,0 @@ -c0f7615c2e970831 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/azure-privatelink.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/azure-privatelink.md deleted file mode 100644 index 184870905f0..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/azure-privatelink.md +++ /dev/null @@ -1,547 +0,0 @@ ---- -'title': 'Azure Private Link' -'sidebar_label': 'Azure Private Link' -'slug': '/cloud/security/azure-privatelink' -'description': '如何设置 Azure Private Link' -'keywords': -- 'azure' -- 'private link' -- 'privatelink' ---- - -import Image from '@theme/IdealImage'; -import ScalePlanFeatureBadge from '@theme/badges/ScalePlanFeatureBadge'; -import azure_pe from '@site/static/images/cloud/security/azure-pe.png'; -import azure_privatelink_pe_create from '@site/static/images/cloud/security/azure-privatelink-pe-create.png'; -import azure_private_link_center from '@site/static/images/cloud/security/azure-private-link-center.png'; -import azure_pe_create_basic from '@site/static/images/cloud/security/azure-pe-create-basic.png'; -import azure_pe_resource from '@site/static/images/cloud/security/azure-pe-resource.png'; -import azure_pe_create_vnet from '@site/static/images/cloud/security/azure-pe-create-vnet.png'; -import azure_pe_create_dns from '@site/static/images/cloud/security/azure-pe-create-dns.png'; -import azure_pe_create_tags from '@site/static/images/cloud/security/azure-pe-create-tags.png'; -import azure_pe_create_review from '@site/static/images/cloud/security/azure-pe-create-review.png'; -import azure_pe_ip from '@site/static/images/cloud/security/azure-pe-ip.png'; -import azure_pe_view from '@site/static/images/cloud/security/azure-pe-view.png'; -import azure_pe_resource_guid from '@site/static/images/cloud/security/azure-pe-resource-guid.png'; -import azure_pl_dns_wildcard from '@site/static/images/cloud/security/azure-pl-dns-wildcard.png'; -import azure_pe_remove_private_endpoint from '@site/static/images/cloud/security/azure-pe-remove-private-endpoint.png'; -import azure_privatelink_pe_filter from '@site/static/images/cloud/security/azure-privatelink-pe-filter.png'; -import azure_privatelink_pe_dns from '@site/static/images/cloud/security/azure-privatelink-pe-dns.png'; - - -# Azure Private Link - - - -本指南展示了如何使用 Azure Private Link,通过虚拟网络提供与 Azure(包括客户拥有的和微软合作伙伴服务)和 ClickHouse Cloud 之间的私有连接。Azure Private Link 简化了网络架构,确保 Azure 中端点之间的连接安全,消除了数据暴露于公共互联网的风险。 - -PrivateLink 概述 - -与 AWS 和 GCP 不同,Azure 支持通过 Private Link 的跨区域连接。这使您能够在不同区域的虚拟网络之间建立连接,这些区域中部署了 ClickHouse 服务。 - -:::note -跨区域流量可能会产生额外费用。请查看最新的 Azure 文档。 -::: - -**请按照以下步骤启用 Azure Private Link:** - -1. 获取 Private Link 的 Azure 连接别名 -1. 在 Azure 中创建一个 Private Endpoint -1. 将 Private Endpoint GUID 添加到您的 ClickHouse Cloud 组织中 -1. 将 Private Endpoint GUID 添加到您的服务允许列表中 -1. 使用 Private Link 访问您的 ClickHouse Cloud 服务 - - -## 注意事项 {#attention} -ClickHouse 尝试将您的服务分组,以便重用同一区域内已发布的 [Private Link 服务](https://learn.microsoft.com/en-us/azure/private-link/private-link-service-overview)。然而,这种分组并不能得到保证,尤其是在您将服务分布在多个 ClickHouse 组织的情况下。如果您已经为 ClickHouse 组织中的其他服务配置了 Private Link,通常可以跳过大部分步骤,直接进入最后一步:[将 Private Endpoint GUID 添加到您的服务允许列表](#add-private-endpoint-guid-to-services-allow-list)。 - -在 ClickHouse [Terraform Provider 仓库](https://github.com/ClickHouse/terraform-provider-clickhouse/tree/main/examples/) 中找到 Terraform 示例。 - -## 获取 Private Link 的 Azure 连接别名 {#obtain-azure-connection-alias-for-private-link} - -### 选项 1:ClickHouse Cloud 控制台 {#option-1-clickhouse-cloud-console} - -在 ClickHouse Cloud 控制台中,打开您希望通过 PrivateLink 连接的服务,然后打开 **设置** 菜单。点击 **设置私有端点** 按钮。记下将用于设置 Private Link 的 `服务名称` 和 `DNS 名称`。 - -Private Endpoints - -记下 `服务名称` 和 `DNS 名称`,下一步将需要这些信息。 - -### 选项 2:API {#option-2-api} - -在开始之前,您需要一个 ClickHouse Cloud API 密钥。您可以 [创建新密钥](/cloud/manage/openapi) 或使用现有密钥。 - -一旦您有了 API 密钥,在运行任何命令之前设置以下环境变量: - -```bash -REGION= -PROVIDER=azure -KEY_ID= -KEY_SECRET= -ORG_ID= -SERVICE_NAME= -``` - -通过按区域、提供者和服务名称过滤获取 ClickHouse 的 `INSTANCE_ID`: - -```shell -INSTANCE_ID=$(curl --silent --user "${KEY_ID:?}:${KEY_SECRET:?}" \ -"https://api.clickhouse.cloud/v1/organizations/${ORG_ID:?}/services" | \ -jq ".result[] | select (.region==\"${REGION:?}\" and .provider==\"${PROVIDER:?}\" and .name==\"${SERVICE_NAME:?}\") | .id " -r) -``` - -获取您的 Azure 连接别名和 Private DNS 主机名: - -```bash -curl --silent --user "${KEY_ID:?}:${KEY_SECRET:?}" "https://api.clickhouse.cloud/v1/organizations/${ORG_ID:?}/services/${INSTANCE_ID:?}/privateEndpointConfig" | jq .result -{ - "endpointServiceId": "production-westus3-0-0.xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.westus3.azure.privatelinkservice", - "privateDnsHostname": "xxxxxxxxxx.westus3.privatelink.azure.clickhouse.cloud" -} -``` - -记下 `endpointServiceId`。您将在下一步中使用它。 - -## 在 Azure 中创建 Private Endpoint {#create-private-endpoint-in-azure} - -:::important -本节涵盖了通过 Azure Private Link 配置 ClickHouse 的 ClickHouse 特定详细信息。提供了 Azure 特定步骤作为参考,以指导您寻找信息,但这些步骤可能会随时更改,且未得到 Azure 云提供商的通知。请根据您的具体用例考虑 Azure 配置。 - -请注意,ClickHouse 不负责配置所需的 Azure 私有端点、DNS 记录。 - -对于与 Azure 配置任务相关的任何问题,请直接联系 Azure 支持。 -::: - -在本节中,我们将在 Azure 中创建一个 Private Endpoint。您可以使用 Azure 门户或 Terraform。 - -### 选项 1:使用 Azure 门户在 Azure 中创建 Private Endpoint {#option-1-using-azure-portal-to-create-a-private-endpoint-in-azure} - -在 Azure 门户中,打开 **Private Link Center → Private Endpoints**。 - -打开 Azure 私有中心 - -通过点击 **创建** 按钮打开 Private Endpoint 创建对话框。 - -打开 Azure 私有中心 - ---- - -在下一个屏幕中,指定以下选项: - -- **订阅** / **资源组**:请为 Private Endpoint 选择 Azure 订阅和资源组。 -- **名称**:为 **Private Endpoint** 设置一个名称。 -- **区域**:选择将通过 Private Link 连接到 ClickHouse Cloud 的已部署 VNet 的区域。 - -在完成以上步骤后,点击 **下一步:资源** 按钮。 - -创建 Private Endpoint 基础 - ---- - -选择选项 **通过资源 ID 或别名连接到 Azure 资源**。 - -对于 **资源 ID 或别名**,使用您从 [获取 Private Link 的 Azure 连接别名](#obtain-azure-connection-alias-for-private-link) 步骤中获取的 `endpointServiceId`。 - -点击 **下一步:虚拟网络** 按钮。 - -私有端点资源选择 - ---- - -- **虚拟网络**:选择您要使用 Private Link 连接到 ClickHouse Cloud 的 VNet -- **子网**:选择将创建 Private Endpoint 的子网 - -可选: - -- **应用程序安全组**:您可以将 ASG 附加到 Private Endpoint,并在网络安全组中使用它,以过滤到/从 Private Endpoint 的网络流量。 - -点击 **下一步:DNS** 按钮。 - -私有端点虚拟网络选择 - -点击 **下一步:标签** 按钮。 - ---- - -私有端点 DNS 配置 - -可选地,您可以为您的 Private Endpoint 附加标签。 - -点击 **下一步:审查 + 创建** 按钮。 - ---- - -私有端点标签 - -最后,点击 **创建** 按钮。 - -私有端点审查 - -所创建的 Private Endpoint 的 **连接状态** 将处于 **待处理** 状态。一旦您将此 Private Endpoint 添加到服务允许列表中,它将变为 **已批准** 状态。 - -打开与 Private Endpoint 关联的网络接口并复制 **私有 IPv4 地址**(本示例中为 10.0.0.4),您将在下一步中需要该信息。 - -私有端点 IP 地址 - -### 选项 2:使用 Terraform 在 Azure 中创建 Private Endpoint {#option-2-using-terraform-to-create-a-private-endpoint-in-azure} - -使用以下模板通过 Terraform 创建 Private Endpoint: - -```json -resource "azurerm_private_endpoint" "example_clickhouse_cloud" { - name = var.pe_name - location = var.pe_location - resource_group_name = var.pe_resource_group_name - subnet_id = var.pe_subnet_id - - private_service_connection { - name = "test-pl" - private_connection_resource_alias = "" - is_manual_connection = true - } -} -``` - -### 获取 Private Endpoint `resourceGuid` {#obtaining-private-endpoint-resourceguid} - -为了使用 Private Link,您需要将 Private Endpoint 连接 GUID 添加到您的服务允许列表中。 - -Private Endpoint 资源 GUID 仅在 Azure 门户中公开。打开在前一步创建的 Private Endpoint,然后点击 **JSON 视图**: - -私有端点视图 - -在属性下,找到 `resourceGuid` 字段并复制这个值: - -私有端点资源 GUID - -## 为 Private Link 设置 DNS {#setting-up-dns-for-private-link} - -您需要创建一个私有 DNS 区域 (`${location_code}.privatelink.azure.clickhouse.cloud`) 并将其附加到您的 VNet,以便通过 Private Link 访问资源。 - -### 创建私有 DNS 区域 {#create-private-dns-zone} - -**选项 1:使用 Azure 门户** - -请遵循以下指南 [使用 Azure 门户创建 Azure 私有 DNS 区域](https://learn.microsoft.com/en-us/azure/dns/private-dns-getstarted-portal)。 - -**选项 2:使用 Terraform** - -使用以下 Terraform 模板创建一个私有 DNS 区域: - -```json -resource "azurerm_private_dns_zone" "clickhouse_cloud_private_link_zone" { - name = "${var.location}.privatelink.azure.clickhouse.cloud" - resource_group_name = var.resource_group_name -} -``` - -### 创建通配符 DNS 记录 {#create-a-wildcard-dns-record} - -创建一个通配符记录,指向您的 Private Endpoint: - -**选项 1:使用 Azure 门户** - -1. 打开 `MyAzureResourceGroup` 资源组并选择 `${region_code}.privatelink.azure.clickhouse.cloud` 私有区域。 -2. 选择 + 记录集。 -3. 对于名称,输入 `*`。 -4. 对于 IP 地址,输入您为 Private Endpoint 看到的 IP 地址。 -5. 选择 **确定**。 - -私有链接 DNS 通配符设置 - -**选项 2:使用 Terraform** - -使用以下 Terraform 模板创建一个通配符 DNS 记录: - -```json -resource "azurerm_private_dns_a_record" "example" { - name = "*" - zone_name = var.zone_name - resource_group_name = var.resource_group_name - ttl = 300 - records = ["10.0.0.4"] -} -``` - -### 创建虚拟网络链接 {#create-a-virtual-network-link} - -要将私有 DNS 区域链接到虚拟网络,您需要创建一个虚拟网络链接。 - -**选项 1:使用 Azure 门户** - -请遵循以下指南 [将虚拟网络链接到您的私有 DNS 区域](https://learn.microsoft.com/en-us/azure/dns/private-dns-getstarted-portal#link-the-virtual-network)。 - -**选项 2:使用 Terraform** - -:::note -配置 DNS 的方法有多种。请根据您的具体用例设置 DNS。 -::: - -您需要将从 [获取 Private Link 的 Azure 连接别名](#obtain-azure-connection-alias-for-private-link) 步骤中获取的 "DNS 名称",指向 Private Endpoint 的 IP 地址。这确保了您的 VPC/网络中的服务/组件能够正确解析。 - -### 验证 DNS 设置 {#verify-dns-setup} - -`xxxxxxxxxx.westus3.privatelink.azure.clickhouse.cloud` 域应指向 Private Endpoint IP。(本示例中为 10.0.0.4)。 - -```bash -nslookup xxxxxxxxxx.westus3.privatelink.azure.clickhouse.cloud. -Server: 127.0.0.53 -Address: 127.0.0.53#53 - -Non-authoritative answer: -Name: xxxxxxxxxx.westus3.privatelink.azure.clickhouse.cloud -Address: 10.0.0.4 -``` - -## 将 Private Endpoint GUID 添加到您的 ClickHouse Cloud 组织 {#add-the-private-endpoint-guid-to-your-clickhouse-cloud-organization} - -### 选项 1:ClickHouse Cloud 控制台 {#option-1-clickhouse-cloud-console-1} - -要将端点添加到组织,请继续进行 [将 Private Endpoint GUID 添加到您的服务允许列表](#add-private-endpoint-guid-to-services-allow-list) 步骤。通过 ClickHouse Cloud 控制台将 `Private Endpoint GUID` 添加到服务允许列表中,会自动将其添加到组织。 - -要删除端点,打开 **组织详情 -> 私有端点**,然后点击删除按钮以移除该端点。 - -删除私有端点 - -### 选项 2:API {#option-2-api-1} - -在运行任何命令之前设置以下环境变量: - -```bash -PROVIDER=azure -KEY_ID= -KEY_SECRET= -ORG_ID= -ENDPOINT_ID= -REGION= -``` - -根据 [获取 Private Endpoint `resourceGuid`](#obtaining-private-endpoint-resourceguid) 步骤中的数据设置 `ENDPOINT_ID` 环境变量。 - -运行以下命令以添加 Private Endpoint: - -```bash -cat < - -### 选项 2:API {#option-2-api-2} - -在运行任何命令之前,设置以下环境变量: - -```bash -PROVIDER=azure -KEY_ID= -KEY_SECRET= -ORG_ID= -ENDPOINT_ID= -INSTANCE_ID= -``` - -对每个应通过 Private Link 可用的服务执行此操作。 - -运行以下命令以将 Private Endpoint 添加到服务允许列表: - -```bash -cat <API 或 `DNS 名称`控制台。 - -### 获取私有 DNS 主机名 {#obtaining-the-private-dns-hostname} - -#### 选项 1:ClickHouse Cloud 控制台 {#option-1-clickhouse-cloud-console-3} - -在 ClickHouse Cloud 控制台中,导航到 **设置**。点击 **设置私有端点** 按钮。在打开的飞出窗口中,复制 **DNS 名称**。 - -私有端点 DNS 名称 - -#### 选项 2:API {#option-2-api-3} - -在运行任何命令之前,设置以下环境变量: - -```bash -KEY_ID= -KEY_SECRET= -ORG_ID= -INSTANCE_ID= -``` - -运行以下命令: - -```bash -curl --silent --user "${KEY_ID:?}:${KEY_SECRET:?}" "https://api.clickhouse.cloud/v1/organizations/${ORG_ID:?}/services/${INSTANCE_ID:?}/privateEndpointConfig" | jq .result -``` - -您应收到类似以下的响应: - -```response -{ - ... - "privateDnsHostname": "xxxxxxx..privatelink.azure.clickhouse.cloud" -} -``` - -在此示例中,连接到 `xxxxxxx.region_code.privatelink.azure.clickhouse.cloud` 主机名将路由到 Private Link。同时,`xxxxxxx.region_code.azure.clickhouse.cloud` 将通过互联网路由。 - -使用 `privateDnsHostname` 通过 Private Link 连接到您的 ClickHouse Cloud 服务。 - -## 故障排除 {#troubleshooting} - -### 测试 DNS 设置 {#test-dns-setup} - -运行以下命令: - -```bash -nslookup -``` -其中 "dns name" 是从 [获取 Private Link 的 Azure 连接别名](#obtain-azure-connection-alias-for-private-link) 获取的 `privateDnsHostname`API 或 `DNS 名称`控制台 。 - -您应收到以下响应: - -```response -Non-authoritative answer: -Name: -Address: 10.0.0.4 -``` - -### 连接被同伴重置 {#connection-reset-by-peer} - -最有可能的情况是,Private Endpoint GUID 并未添加到服务允许列表中。请重新访问 [_将 Private Endpoint GUID 添加到服务允许列表_ 步骤](#add-private-endpoint-guid-to-services-allow-list)。 - -### 私有端点处于待处理状态 {#private-endpoint-is-in-pending-state} - -最有可能的情况是,Private Endpoint GUID 并未添加到服务允许列表中。请重新访问 [_将 Private Endpoint GUID 添加到服务允许列表_ 步骤](#add-private-endpoint-guid-to-services-allow-list)。 - -### 测试连接性 {#test-connectivity} - -如果您在使用 Private Link 连接时遇到问题,请使用 `openssl` 检查您的连接性。确保 Private Link 端点状态为 `Accepted`。 - -OpenSSL 应能够连接(在输出中查看 CONNECTED)。预期 `errno=104`。 - -```bash -openssl s_client -connect abcd.westus3.privatelink.azure.clickhouse.cloud.cloud:9440 -``` - -```response - -# highlight-next-line -CONNECTED(00000003) -write:errno=104 ---- -no peer certificate available ---- -No client certificate CA names sent ---- -SSL handshake has read 0 bytes and written 335 bytes -Verification: OK ---- -New, (NONE), Cipher is (NONE) -Secure Renegotiation IS NOT supported -Compression: NONE -Expansion: NONE -No ALPN negotiated -Early data was not sent -Verify return code: 0 (ok) -``` - -### 检查私有端点过滤器 {#checking-private-endpoint-filters} - -在运行任何命令之前设置以下环境变量: - -```bash -KEY_ID= -KEY_SECRET= -ORG_ID= -INSTANCE_ID= -``` - -运行以下命令检查私有端点过滤器: - -```bash -curl --silent --user "${KEY_ID:?}:${KEY_SECRET:?}" -X GET -H "Content-Type: application/json" "https://api.clickhouse.cloud/v1/organizations/${ORG_ID:?}/services/${INSTANCE_ID:?}" | jq .result.privateEndpointIds -``` - -## 更多信息 {#more-information} - -有关 Azure Private Link 的更多信息,请访问 [azure.microsoft.com/en-us/products/private-link](https://azure.microsoft.com/en-us/products/private-link)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/azure-privatelink.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/azure-privatelink.md.hash deleted file mode 100644 index 5ffe9af3ec8..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/azure-privatelink.md.hash +++ /dev/null @@ -1 +0,0 @@ -48bc465c726d7a9e diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/cloud-access-management/cloud-access-management.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/cloud-access-management/cloud-access-management.md deleted file mode 100644 index d93485dedf4..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/cloud-access-management/cloud-access-management.md +++ /dev/null @@ -1,127 +0,0 @@ ---- -'sidebar_label': '概述' -'slug': '/cloud/security/cloud-access-management/overview' -'title': '云访问管理' -'description': '描述了 ClickHouse 云中访问控制如何工作,包括角色类型的信息' ---- - -import Image from '@theme/IdealImage'; -import user_grant_permissions_options from '@site/static/images/cloud/security/cloud-access-management/user_grant_permissions_options.png'; - - -# Access control in ClickHouse Cloud {#access-control-in-clickhouse-cloud} -ClickHouse 在两个地方控制用户访问: 通过控制台和通过数据库。控制台访问通过 clickhouse.cloud 用户界面管理。数据库访问通过数据库用户账户和角色管理。此外,可以在数据库中授予控制台用户角色,使控制台用户能够通过我们的 SQL 控制台与数据库交互。 - -## Console users and roles {#console-users-and-roles} -在控制台 > 用户和角色页面中配置组织和服务角色分配。在每个服务的设置页面中配置 SQL 控制台角色分配。 - -用户必须被分配一个组织级别的角色,并可以选择性地为一个或多个服务分配服务角色。可以选择性地为用户在服务设置页面中配置服务角色以访问 SQL 控制台。 -- 被分配为组织管理员角色的用户默认获得服务管理员角色。 -- 通过 SAML 集成添加到组织的用户会自动分配为成员角色。 -- 服务管理员默认被分配为 SQL 控制台管理员角色。SQL 控制台权限可以在服务设置页面中移除。 - -| Context | Role | Description | -|:-------------|:-----------------------|:-------------------------------------------------| -| Organization | Admin | 执行组织的所有管理活动并控制所有设置。默认分配给组织中的第一个用户。 | -| Organization | Developer | 查看对除了服务以外的所有内容的访问权限,有能力生成只读 API 密钥。 | -| Organization | Billing | 查看使用情况和发票,并管理付款方式。 | -| Organization | Member | 仅能登录,能够管理个人档案设置。默认分配给 SAML SSO 用户。 | -| Service | Service Admin | 管理服务设置。 | -| Service | Service Read Only | 查看服务和设置。 | -| SQL console | SQL console admin | 对服务中的数据库具有管理员访问权限,等同于默认数据库角色。 | -| SQL console | SQL console read only | 对服务中的数据库具有只读访问权限。 | -| SQL console | Custom | 使用 SQL [`GRANT`](/sql-reference/statements/grant) 语句进行配置;通过为用户命名角色为用户的 SQL 控制台用户分配角色。 | - -要为 SQL 控制台用户创建自定义角色并授予一般角色,请运行以下命令。电子邮件地址必须与控制台中用户的电子邮件地址匹配。 - -1. 创建 database_developer 角色并授予 `SHOW`、`CREATE`、`ALTER` 和 `DELETE` 权限。 - -```sql -CREATE ROLE OR REPLACE database_developer; -GRANT SHOW ON * TO database_developer; -GRANT CREATE ON * TO database_developer; -GRANT ALTER ON * TO database_developer; -GRANT DELETE ON * TO database_developer; -``` - -2. 为 SQL 控制台用户 my.user@domain.com 创建一个角色并将其分配给 database_developer 角色。 - -```sql -CREATE ROLE OR REPLACE `sql-console-role:my.user@domain.com`; -GRANT database_developer TO `sql-console-role:my.user@domain.com`; -``` - -### SQL console passwordless authentication {#sql-console-passwordless-authentication} -SQL 控制台用户在每个会话中创建,并使用自动轮换的 X.509 证书进行身份验证。用户在会话结束时被移除。在生成审计的访问列表时,请导航到控制台服务的设置选项卡,并注意 SQL 控制台访问以及数据库中存在的数据库用户。如果配置了自定义角色,用户的访问将在以用户用户名结尾的角色中列出。 - -## Database permissions {#database-permissions} -使用 SQL [GRANT](/sql-reference/statements/grant) 语句在服务和数据库中配置以下内容。 - -| Role | Description | -|:----------------------|:------------------------------------------------------------------------------| -| Default | 对服务具有完全的管理访问权限 | -| Custom | 使用 SQL [`GRANT`](/sql-reference/statements/grant) 语句进行配置 | - - -- 数据库角色是累加的。这意味着如果用户是两个角色的成员,该用户将获得两个角色授予的最大访问权限。添加角色不会失去访问权限。 -- 数据库角色可以授予其他角色,形成层次结构。角色会继承其成员角色的所有权限。 -- 数据库角色在每个服务中是唯一的,并且可以在同一服务中的多个数据库中应用。 - -下图显示了授予用户权限的不同方式。 - -An illustration showing the different ways a user could be granted permissions - -### Initial settings {#initial-settings} -数据库中有一个名为 `default` 的账户,该账户在服务创建时自动添加并授予 default_role。创建服务的用户会看到为 `default` 账户分配的自动生成的随机密码。初始设置后不会显示密码,但任何具有服务管理员权限的用户都可以在控制台中稍后更改此密码。该账户或在控制台中具有服务管理员权限的账户可以随时设置其他数据库用户和角色。 - -:::note -要在控制台中更改分配给 `default` 账户的密码,请转到左侧的服务菜单,访问服务,进入设置选项卡并单击重置密码按钮。 -::: - -我们建议创建一个与个人关联的新用户账户,并将 default_role 授予该用户。这是为了将用户执行的活动标识到其用户 ID,并且保留 `default` 账户用于紧急操作。 - -```sql -CREATE USER userID IDENTIFIED WITH sha256_hash by 'hashed_password'; -GRANT default_role to userID; -``` - -用户可以使用 SHA256 哈希生成器或 Python 中的 `hashlib` 等代码函数,将具有适当复杂度的 12 个以上字符的密码转换为 SHA256 字符串,以提供给系统管理员作为密码。这可确保管理员不会看到或处理明文密码。 - -### Database access listings with SQL console users {#database-access-listings-with-sql-console-users} -可以使用以下过程生成组织中 SQL 控制台和数据库的完整访问列表。 - -1. 运行以下查询以获取数据库中所有授权的列表。 - -```sql -SELECT grants.user_name, - grants.role_name, - users.name AS role_member, - grants.access_type, - grants.database, - grants.table -FROM system.grants LEFT OUTER JOIN system.role_grants ON grants.role_name = role_grants.granted_role_name - LEFT OUTER JOIN system.users ON role_grants.user_name = users.name - -UNION ALL - -SELECT grants.user_name, - grants.role_name, - role_grants.role_name AS role_member, - grants.access_type, - grants.database, - grants.table -FROM system.role_grants LEFT OUTER JOIN system.grants ON role_grants.granted_role_name = grants.role_name -WHERE role_grants.user_name is null; -``` - -2. 将此列表与访问 SQL 控制台的控制台用户关联。 - - a. 转到控制台。 - - b. 选择相关服务。 - - c. 在左侧选择设置。 - - d. 滚动到 SQL 控制台访问部分。 - - e. 单击具有访问数据库的用户数量的链接 `There are # users with access to this service.` 以查看用户列表。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/cloud-access-management/cloud-access-management.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/cloud-access-management/cloud-access-management.md.hash deleted file mode 100644 index c9af84de708..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/cloud-access-management/cloud-access-management.md.hash +++ /dev/null @@ -1 +0,0 @@ -af348ab62ae71a97 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/cloud-access-management/cloud-authentication.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/cloud-access-management/cloud-authentication.md deleted file mode 100644 index 146e50b0af2..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/cloud-access-management/cloud-authentication.md +++ /dev/null @@ -1,127 +0,0 @@ ---- -'sidebar_label': '云认证' -'slug': '/cloud/security/cloud-authentication' -'title': '云认证' -'description': '本指南讲解了一些配置认证的良好实践。' ---- - -import ScalePlanFeatureBadge from '@theme/badges/ScalePlanFeatureBadge' -import EnterprisePlanFeatureBadge from '@theme/badges/EnterprisePlanFeatureBadge' - - -# Cloud Authentication - -ClickHouse Cloud 提供了多种身份验证方式。本指南解释了一些配置身份验证的良好实践。在选择身份验证方法时,请始终与您的安全团队进行确认。 - -## Password Settings {#password-settings} - -我们控制台和服务(数据库)的最低密码设置目前符合 [NIST 800-63B](https://pages.nist.gov/800-63-3/sp800-63b.html#sec4) 认证机构保障级别 1: -- 最少 12 个字符 -- 包含以下 4 项中的 3 项: - - 1 个大写字母 - - 1 个小写字母 - - 1 个数字 - - 1 个特殊字符 - -## Email + Password {#email--password} - -ClickHouse Cloud 允许您使用电子邮件地址和密码进行身份验证。使用此方法时,保护您的 ClickHouse 账户的最佳方式是使用强密码。有许多在线资源可以帮助您想出一个您可以记住的密码。或者,您可以使用随机密码生成器,并将密码存储在密码管理器中以提高安全性。 - -## SSO Using Google or Microsoft Social Authentication {#sso-using-google-or-microsoft-social-authentication} - -如果您的公司使用 Google Workspace 或 Microsoft 365,您可以在 ClickHouse Cloud 中利用当前的单点登录设置。为此,只需使用您的公司电子邮件地址注册,并使用其他用户的公司电子邮件邀请他们。效果是您的用户必须通过您的身份提供者或直接通过 Google 或 Microsoft 身份验证使用您公司的登录流程进行登录,才能在 ClickHouse Cloud 中进行身份验证。 - -## Multi-Factor Authentication {#multi-factor-authentication} - -使用电子邮件 + 密码或社交身份验证的用户可以进一步通过多因素身份验证 (MFA) 来保护其账户。要设置 MFA: -1. 登录到 console.clickhouse.cloud -2. 单击左上角 ClickHouse 标志旁边的您的首字母 -3. 选择个人资料 -4. 在左侧选择安全性 -5. 单击身份验证应用程序区域中的设置 -6. 使用 Authy、1Password 或 Google Authenticator 等身份验证应用程序扫描二维码 -7. 输入代码以确认 -8. 在下一个屏幕上,复制恢复代码并将其存储在安全的地方 -9. 选中 `我已经安全记录了此代码` 旁边的框 -10. 单击继续 - -## Account recovery {#account-recovery} - -
- 获取恢复代码 - - 如果您之前注册了 MFA,但没有创建或丢失了恢复代码,请按照以下步骤获取新的恢复代码: - 1. 访问 https://console.clickhouse.cloud - 2. 使用您的凭证和 MFA 登录 - 3. 在左上角转到您的个人资料 - 4. 单击左侧的安全性 - 5. 单击您的身份验证应用程序旁边的垃圾桶 - 6. 单击移除身份验证应用程序 - 7. 输入您的代码,然后单击继续 - 8. 单击身份验证应用程序部分中的设置 - 9. 扫描二维码并输入新代码 - 10. 复制您的恢复代码并将其存储在安全的地方 - 11. 选中 `我已经安全记录了此代码` 旁边的框 - 12. 单击继续 - -
-
- 忘记密码 - - 如果您忘记了密码,请按照以下步骤进行自助恢复: - 1. 访问 https://console.clickhouse.cloud - 2. 输入您的电子邮件地址并单击继续 - 3. 单击忘记密码? - 4. 单击发送密码重置链接 - 5. 检查您的电子邮件并单击电子邮件中的重置密码 - 6. 输入您的新密码,确认密码并单击更新密码 - 7. 单击返回以登录 - 8. 使用您的新密码正常登录 - -
-
- 丢失 MFA 设备或令牌 - - 如果您丢失了 MFA 设备或删除了令牌,请按照以下步骤恢复并创建新的令牌: - 1. 访问 https://console.clickhouse.cloud - 2. 输入您的凭证并单击继续 - 3. 在多因素身份验证屏幕上单击取消 - 4. 单击恢复代码 - 5. 输入代码并按继续 - 6. 复制新的恢复代码并将其存储在安全的地方 - 7. 选中 `我已经安全记录了此代码` 旁边的框并单击继续 - 8. 登录后,在左上角转到您的个人资料 - 9. 点击左上角的安全性 - 10. 单击身份验证应用程序旁边的垃圾桶图标以去除您的旧身份验证器 - 11. 单击移除身份验证应用程序 - 12. 当提示您进行多因素身份验证时,单击取消 - 13. 单击恢复代码 - 14. 输入您的恢复代码(这是在步骤 7 中生成的新代码)并单击继续 - 15. 复制新的恢复代码并将其存储在安全的地方 - 这是在移除过程中离开屏幕时的备用方案 - 16. 选中 `我已经安全记录了此代码` 旁边的框并单击继续 - 17. 按照上述过程设置新的 MFA 因素 - -
-
- 丢失 MFA 和恢复代码 - - 如果您丢失了您的 MFA 设备和恢复代码,或者您丢失了 MFA 设备且从未获得恢复代码,请按照以下步骤请求重置: - - **提交工单**:如果您所在的组织有其他管理用户,即使您尝试访问单用户组织,也请请求分配了管理员角色的组织成员登录组织并代表您提交支持工单以重置您的 MFA。一旦我们验证请求是经过身份验证的,我们将重置您的 MFA,并通知管理员。如果您希望,可以像往常一样登录而不需要 MFA,然后转到个人资料设置以注册新因素。 - - **通过电子邮件重置**:如果您是组织中唯一的用户,请通过与您的帐户关联的电子邮件地址向支持团队提交支持案例(support@clickhouse.com)。一旦我们验证请求来自正确的电子邮件,我们将重置您的 MFA 和密码。访问您的电子邮件以访问密码重置链接。设置新密码,然后转到个人资料设置以注册新因素,如果您希望。 - -
- -## SAML SSO {#saml-sso} - - - -ClickHouse Cloud 还支持安全断言标记语言 (SAML) 单点登录 (SSO)。有关更多信息,请参阅 [SAML SSO 设置](/cloud/security/saml-setup)。 - -## Database User ID + Password {#database-user-id--password} - -在 [创建用户账户](/sql-reference/statements/create/user.md) 时使用 SHA256_hash 方法来保护密码。 - -**提示**:由于没有管理权限的用户无法设置自己的密码,请要求用户使用生成器对其密码进行哈希处理 -例如 [这个](https://tools.keycdn.com/sha256-online-generator),然后再提供给管理员以设置账户。密码应遵循上述的 [要求](#password-settings)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/cloud-access-management/cloud-authentication.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/cloud-access-management/cloud-authentication.md.hash deleted file mode 100644 index ee1185d2e2c..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/cloud-access-management/cloud-authentication.md.hash +++ /dev/null @@ -1 +0,0 @@ -cb8fb09406f41a08 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/cloud-access-management/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/cloud-access-management/index.md deleted file mode 100644 index def295bea81..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/cloud-access-management/index.md +++ /dev/null @@ -1,13 +0,0 @@ ---- -'slug': '/cloud/security/cloud-access-management' -'title': '云访问管理' -'description': '云访问管理 目录' ---- - -| 页面 | 描述 | -|---------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------| -| [概述](/cloud/security/cloud-access-management/overview) | ClickHouse Cloud 中访问控制的概述 | -| [云身份验证](/cloud/security/cloud-authentication) | 探索配置您身份验证的一些最佳实践的指南 | -| [SAML SSO 设置](/cloud/security/saml-setup) | 如何设置 SAML SSO 的指南。 | -| [常见访问管理查询](/cloud/security/common-access-management-queries) | 介绍定义 SQL 用户和角色的基础知识,并将这些权限应用于数据库、表、行和列的文章。 | -| [邀请新用户](/cloud/security/inviting-new-users) | 邀请新用户加入您的组织以及如何分配角色的操作指南。 | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/cloud-access-management/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/cloud-access-management/index.md.hash deleted file mode 100644 index 05d6705ec16..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/cloud-access-management/index.md.hash +++ /dev/null @@ -1 +0,0 @@ -bb9f8cca5bf83136 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/cloud-endpoints-api.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/cloud-endpoints-api.md deleted file mode 100644 index 0209942ef3e..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/cloud-endpoints-api.md +++ /dev/null @@ -1,48 +0,0 @@ ---- -'slug': '/manage/security/cloud-endpoints-api' -'sidebar_label': '云 IP 地址' -'title': '云 IP 地址' -'description': '此页面记录了 ClickHouse 中 Cloud Endpoints API 的安全特性。它详细说明了如何通过身份验证和授权机制管理访问来保护你的 - ClickHouse 部署。' ---- - -import Image from '@theme/IdealImage'; -import aws_rds_mysql from '@site/static/images/_snippets/aws-rds-mysql.png'; -import gcp_authorized_network from '@site/static/images/_snippets/gcp-authorized-network.png'; - -## Static IPs API {#static-ips-api} - -如果您需要获取静态 IP 列表,可以使用以下 ClickHouse Cloud API 端点:[`https://api.clickhouse.cloud/static-ips.json`](https://api.clickhouse.cloud/static-ips.json)。该 API 提供 ClickHouse Cloud 服务的端点,例如每个区域和云的入口/出口 IP 和 S3 端点。 - -如果您使用像 MySQL 或 PostgreSQL 引擎的集成,您可能需要授权 ClickHouse Cloud 访问您的实例。您可以使用该 API 检索公共 IP 并在 GCP 的 `firewalls` 或 `Authorized networks` 中进行配置,或者在 Azure、AWS 或您使用的任何其他基础设施出口管理系统的 `Security Groups` 中进行配置。 - -例如,要允许在区域 `ap-south-1` 上托管的 ClickHouse Cloud 服务访问,您可以添加该区域的 `egress_ips` 地址: - -```bash -❯ curl -s https://api.clickhouse.cloud/static-ips.json | jq '.' -{ - "aws": [ - { - "egress_ips": [ - "3.110.39.68", - "15.206.7.77", - "3.6.83.17" - ], - "ingress_ips": [ - "15.206.78.111", - "3.6.185.108", - "43.204.6.248" - ], - "region": "ap-south-1", - "s3_endpoints": "vpce-0a975c9130d07276d" - }, -... -``` - -例如,在 `us-east-2` 中运行的 AWS RDS 实例,如果需要连接到 ClickHouse Cloud 服务,则应具有以下入站安全组规则: - -AWS Security group rules - -对于同一 ClickHouse Cloud 服务,在 `us-east-2` 中运行,但这次连接到 GCP 中的 MySQL,`Authorized networks` 应如下所示: - -GCP Authorized networks diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/cloud-endpoints-api.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/cloud-endpoints-api.md.hash deleted file mode 100644 index a079c2a88cc..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/cloud-endpoints-api.md.hash +++ /dev/null @@ -1 +0,0 @@ -1b65274993bbabb5 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/cmek.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/cmek.md deleted file mode 100644 index cca11b1ac99..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/cmek.md +++ /dev/null @@ -1,111 +0,0 @@ ---- -'sidebar_label': '增强加密' -'slug': '/cloud/security/cmek' -'title': '客户管理的加密密钥 (CMEK)' -'description': '了解更多关于客户管理的加密密钥的内容' ---- - -import Image from '@theme/IdealImage'; -import EnterprisePlanFeatureBadge from '@theme/badges/EnterprisePlanFeatureBadge' -import cmek_performance from '@site/static/images/_snippets/cmek-performance.png'; - - -# ClickHouse 增强加密 - - - -静态数据默认使用云服务提供商管理的 AES 256 密钥进行加密。客户可以启用透明数据加密 (TDE) 来为服务数据提供额外的保护层,或提供自己的密钥以实现客户管理的加密密钥 (CMEK)。 - -当前增强加密在 AWS 和 GCP 服务中可用。Azure 将很快推出。 - -## 透明数据加密 (TDE) {#transparent-data-encryption-tde} - -在创建服务时必须启用 TDE。现有服务在创建后无法进行加密。 - -1. 选择 `创建新服务` -2. 命名服务 -3. 从下拉菜单中选择 AWS 或 GCP 作为云提供商及所需区域 -4. 点击企业功能下拉菜单,切换启用透明数据加密 (TDE) -5. 点击创建服务 - -## 客户管理的加密密钥 (CMEK) {#customer-managed-encryption-keys-cmek} - -:::warning -删除用于加密 ClickHouse Cloud 服务的 KMS 密钥会导致您的 ClickHouse 服务停止,数据将无法恢复,现有备份也将丢失。为了防止轮换密钥时意外数据丢失,您可能希望在删除之前保留旧的 KMS 密钥一段时间。 -::: - -一旦服务使用 TDE 加密,客户可以更新密钥以启用 CMEK。更新 TDE 设置后,服务将自动重启。在此过程中,旧的 KMS 密钥将解密数据加密密钥 (DEK),新的 KMS 密钥将重新加密 DEK。这确保了服务在重启后将使用新的 KMS 密钥进行加密操作。此过程可能需要几分钟。 - -
- 使用 AWS KMS 启用 CMEK - -1. 在 ClickHouse Cloud 中,选择加密的服务 -2. 点击左侧的设置 -3. 在屏幕底部,展开网络安全信息 -4. 复制加密角色 ID (AWS) 或加密服务账号 (GCP) - 您将在后续步骤中需要该信息 -5. [为 AWS 创建一个 KMS 密钥](https://docs.aws.amazon.com/kms/latest/developerguide/create-keys.html) -6. 点击密钥 -7. 按如下方式更新 AWS 密钥策略: - -```json -{ - "Sid": "Allow ClickHouse Access", - "Effect": "Allow", - "Principal": { - "AWS": "{ Encryption role ID }" - }, - "Action": [ - "kms:Encrypt", - "kms:Decrypt", - "kms:ReEncrypt*", - "kms:DescribeKey" - ], - "Resource": "*" -} -``` - -10. 保存密钥策略 -11. 复制密钥 ARN -12. 返回 ClickHouse Cloud,将密钥 ARN 粘贴到服务设置的透明数据加密部分 -13. 保存更改 - -
- -
- 使用 GCP KMS 启用 CMEK - -1. 在 ClickHouse Cloud 中,选择加密的服务 -2. 点击左侧的设置 -3. 在屏幕底部,展开网络安全信息 -4. 复制加密服务账号 (GCP) - 您将在后续步骤中需要该信息 -5. [为 GCP 创建一个 KMS 密钥](https://cloud.google.com/kms/docs/create-key) -6. 点击密钥 -7. 授予上述第 4 步中复制的 GCP 加密服务账号以下权限: - - Cloud KMS CryptoKey Encrypter/Decrypter - - Cloud KMS Viewer -10. 保存密钥权限 -11. 复制密钥资源路径 -12. 返回 ClickHouse Cloud,将密钥资源路径粘贴到服务设置的透明数据加密部分 -13. 保存更改 - -
- -## 密钥轮换 {#key-rotation} - -一旦您设置了 CMEK,请按照上述创建新 KMS 密钥和授予权限的步骤轮换密钥。返回服务设置,将新的 ARN (AWS) 或密钥资源路径 (GCP) 粘贴并保存设置。服务将重启以应用新密钥。 - -## 备份和恢复 {#backup-and-restore} - -备份使用与相关服务相同的密钥进行加密。当您恢复加密备份时,会创建一个加密实例,该实例使用与原始实例相同的 KMS 密钥。如果需要,您可以在恢复后轮换 KMS 密钥;有关详细信息,请参见 [密钥轮换](#key-rotation)。 - -## KMS 密钥轮询器 {#kms-key-poller} - -使用 CMEK 时,将每 10 分钟检查一次所提供的 KMS 密钥的有效性。如果 KMS 密钥的访问权限无效,ClickHouse 服务将停止。要恢复服务,请按照本指南中的步骤恢复对 KMS 密钥的访问,然后重启服务。 - -## 性能 {#performance} - -如本页所述,我们使用 ClickHouse 内置的 [数据加密虚拟文件系统功能](/operations/storing-data#encrypted-virtual-file-system) 来加密和保护您的数据。 - -此功能使用的算法是 `AES_256_CTR`,预计根据工作负载性能损失为 5-15%: - -CMEK 性能损失 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/cmek.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/cmek.md.hash deleted file mode 100644 index a6d7ee1cfb4..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/cmek.md.hash +++ /dev/null @@ -1 +0,0 @@ -c4d8c9c41fecc037 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/common-access-management-queries.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/common-access-management-queries.md.hash deleted file mode 100644 index a7a80db6770..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/common-access-management-queries.md.hash +++ /dev/null @@ -1 +0,0 @@ -a49d2805bf32958f diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/compliance-overview.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/compliance-overview.md deleted file mode 100644 index 7e01329736a..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/compliance-overview.md +++ /dev/null @@ -1,68 +0,0 @@ ---- -'sidebar_label': '安全与合规' -'slug': '/cloud/security/security-and-compliance' -'title': '安全与合规' -'description': '本页面描述了 ClickHouse Cloud 实施的安全与合规措施,以保护客户数据。' ---- - -import BetaBadge from '@theme/badges/BetaBadge'; -import EnterprisePlanFeatureBadge from '@theme/badges/EnterprisePlanFeatureBadge'; - - -# 安全与合规报告 -ClickHouse Cloud 评估我们客户的安全和合规需求,并不断扩大该计划以满足额外报告的请求。有关更多信息或下载报告,请访问我们的 [信任中心](https://trust.clickhouse.com)。 - -### SOC 2 Type II (自 2022 年起) {#soc-2-type-ii-since-2022} - -系统和组织控制 (SOC) 2 是一份报告,专注于信任服务标准 (TSC) 中包含的安全性、可用性、机密性、处理完整性和隐私标准,适用于组织的系统,旨在向依赖方(我们的客户)提供对这些控制的保证。ClickHouse 与独立的外部审计师合作,每年至少进行一次审核,审查我们系统的安全性、可用性和处理完整性,以及我们系统处理的数据的机密性和隐私。该报告涵盖了我们的 ClickHouse Cloud 和自带云 (BYOC) 产品。 - -### ISO 27001 (自 2023 年起) {#iso-27001-since-2023} - -国际标准化组织 (ISO) 27001 是信息安全的国际标准。它要求公司实施信息安全管理系统 (ISMS),包括管理风险、制定和传达政策、实施安全控制以及监控以确保组件保持相关性和有效性的流程。ClickHouse 进行内部审计,并与独立的外部审计师合作,在证书发布后的 2 年间进行审计和临时检查。 - -### U.S. DPF (自 2024 年起) {#us-dpf-since-2024} - -美国数据隐私框架旨在为美国组织提供将个人数据从欧盟/欧洲经济区、英国和瑞士传输到美国的可靠机制,符合欧盟、英国和瑞士的法律 (https://dataprivacyframework.gov/Program-Overview)。ClickHouse 已自我认证该框架,并已列入 [数据隐私框架列表](https://dataprivacyframework.gov/list)。 - -### HIPAA (自 2024 年起) {#hipaa-since-2024} - - - -客户必须完成商业伙伴协议 (BAA),并联系销售或支持团队以在 HIPAA 合规区域启动服务,以加载电子健康信息 (ePHI)。此外,客户应查看我们的 [共享责任模型](/cloud/security/shared-responsibility-model),为其使用案例选择并实施适当的控制措施。 - -《健康保险可移植性与责任法案》 (HIPAA) 于 1996 年在美国实施,是一项专注于受保护健康信息 (PHI) 管理的隐私法。HIPAA 有几项要求,包括 [安全规则](https://www.hhs.gov/hipaa/for-professionals/security/index.html),其重点是保护电子个人健康信息 (ePHI)。ClickHouse 已实施行政、物理和技术保障措施,以确保存储于指定服务中的 ePHI 的机密性、完整性和安全性。这些活动已纳入我们的 SOC 2 Type II 报告中,您可以在我们的 [信任中心](https://trust.clickhouse.com) 下载。 - -### PCI 服务提供商 (自 2025 年起) {#pci-service-provider-since-2025} - - - -客户必须联系销售或支持团队,启动服务到 PCI 合规区域以加载持卡人数据。此外,客户应查看我们在 [信任中心](https://trust.clickhouse.com) 提供的 PCI 责任概述,为其使用案例选择并实施适当的控制措施。 - -[支付卡行业数据安全标准 (PCI DSS)](https://www.pcisecuritystandards.org/standards/pci-dss/) 是由 PCI 安全标准委员会制定的一套规则,旨在保护信用卡支付数据。ClickHouse 已接受合格安全评估师 (QSA) 的外部审核,获得关于存储信用卡数据的 PCI 标准的合格合规报告 (ROC)。要下载我们的合规性证明 (AOC) 和 PCI 责任概述的副本,请访问我们的 [信任中心](https://trust.clickhouse.com)。 - - -# 隐私合规性 - -除了上述项目,ClickHouse 还维持内部合规程序,以满足通用数据保护条例 (GDPR)、加州消费者隐私法 (CCPA) 和其他相关隐私框架。关于 ClickHouse 收集的个人数据、如何使用、如何保护以及其他隐私相关信息的详细信息,请参阅以下位置。 - -### 法律文件 {#legal-documents} - -- [隐私政策](https://clickhouse.com/legal/privacy-policy) -- [Cookie 政策](https://clickhouse.com/legal/cookie-policy) -- [数据隐私框架通知](https://clickhouse.com/legal/data-privacy-framework) -- [数据处理附录 (DPA)](https://clickhouse.com/legal/agreements/data-processing-addendum) - -### 处理位置 {#processing-locations} - -- [子处理器和附属机构](https://clickhouse.com/legal/agreements/subprocessors) -- [数据处理位置](https://trust.clickhouse.com) - -### 其他程序 {#additional-procedures} - -- [个人数据访问](/cloud/security/personal-data-access) -- [删除账户](/cloud/manage/close_account) - - -# 支付合规性 - -ClickHouse 提供符合 [PCI SAQ A v4.0](https://www.pcisecuritystandards.org/document_library/) 的安全信用卡支付方式。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/compliance-overview.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/compliance-overview.md.hash deleted file mode 100644 index 2fe0b1771eb..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/compliance-overview.md.hash +++ /dev/null @@ -1 +0,0 @@ -2f1c1834318da8e3 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/connectivity-overview.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/connectivity-overview.md deleted file mode 100644 index d4236599805..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/connectivity-overview.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -'slug': '/cloud/security/connectivity' -'title': '连接概览' -'description': '连接性入口页面' ---- - - -# 连接性 - -本节讨论连接性,并包含以下页面: - -| 页面 | 描述 | -|----------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------| -| [设置 IP 过滤器](/cloud/security/setting-ip-filters) | 指导如何使用 IP 访问列表控制对您 ClickHouse 服务的流量。 | -| [私有网络](/cloud/security/private-link-overview) | 有关如何将您的服务连接到云虚拟网络的信息。 | -| [安全访问 S3 数据](/cloud/security/secure-s3) | 指导如何利用基于角色的访问来验证 Amazon Simple Storage Service(S3) 并安全访问数据。 | -| [云 IP 地址](/manage/security/cloud-endpoints-api) | 列出 ClickHouse Cloud 中每个支持的云和区域的静态 IP 和 S3 端点的表格。 | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/connectivity-overview.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/connectivity-overview.md.hash deleted file mode 100644 index f0068e03c8d..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/connectivity-overview.md.hash +++ /dev/null @@ -1 +0,0 @@ -efdffdc0bdc1ee4f diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/gcp-private-service-connect.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/gcp-private-service-connect.md deleted file mode 100644 index a9724329ba1..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/gcp-private-service-connect.md +++ /dev/null @@ -1,440 +0,0 @@ ---- -'title': 'GCP Private Service Connect' -'description': '本文档描述了如何使用 Google Cloud Platform (GCP) Private Service Connect (PSC) - 连接到 ClickHouse Cloud,以及如何使用 ClickHouse Cloud IP 访问列表禁用来自 GCP PSC 地址以外的地址对您的 ClickHouse - Cloud 服务的访问。' -'sidebar_label': 'GCP Private Service Connect' -'slug': '/manage/security/gcp-private-service-connect' ---- - -import Image from '@theme/IdealImage'; -import ScalePlanFeatureBadge from '@theme/badges/ScalePlanFeatureBadge'; -import gcp_psc_overview from '@site/static/images/cloud/security/gcp-psc-overview.png'; -import gcp_privatelink_pe_create from '@site/static/images/cloud/security/gcp-privatelink-pe-create.png'; -import gcp_psc_open from '@site/static/images/cloud/security/gcp-psc-open.png'; -import gcp_psc_enable_global_access from '@site/static/images/cloud/security/gcp-psc-enable-global-access.png'; -import gcp_psc_copy_connection_id from '@site/static/images/cloud/security/gcp-psc-copy-connection-id.png'; -import gcp_psc_create_zone from '@site/static/images/cloud/security/gcp-psc-create-zone.png'; -import gcp_psc_zone_type from '@site/static/images/cloud/security/gcp-psc-zone-type.png'; -import gcp_psc_dns_record from '@site/static/images/cloud/security/gcp-psc-dns-record.png'; -import gcp_pe_remove_private_endpoint from '@site/static/images/cloud/security/gcp-pe-remove-private-endpoint.png'; -import gcp_privatelink_pe_filters from '@site/static/images/cloud/security/gcp-privatelink-pe-filters.png'; -import gcp_privatelink_pe_dns from '@site/static/images/cloud/security/gcp-privatelink-pe-dns.png'; - - -# 私有服务连接 {#private-service-connect} - - - -私有服务连接(PSC)是Google Cloud的网络功能,允许消费者在其虚拟私有云(VPC)网络内私密访问托管服务。类似地,它允许托管服务提供商在自己独立的VPC网络中托管这些服务,并为其消费者提供私密连接。 - -服务提供商通过创建私有服务连接服务,将其应用发布给消费者。服务消费者通过以下任一类型的私有服务连接直接访问这些私有服务连接服务。 - -Overview of Private Service Connect - -:::important -默认情况下,即使PSC连接已批准并建立,ClickHouse服务也不可通过私有服务连接访问;您需要通过完成下面的[步骤](#add-endpoint-id-to-services-allow-list),明确将PSC ID添加到实例级别的允许列表中。 -::: - - -**使用私有服务连接全局访问的重要考虑事项**: -1. 利用全局访问的区域必须属于同一VPC。 -1. 必须在PSC级别明确启用全局访问(请参阅下面的截图)。 -1. 确保您的防火墙设置不会阻止来自其他区域的PSC访问。 -1. 请注意,您可能会产生GCP跨区域数据传输费用。 - -不支持跨区域连接。生产者和消费者区域必须相同。然而,您可以通过在私有服务连接(PSC)级别启用[全球访问](https://cloud.google.com/vpc/docs/about-accessing-vpc-hosted-services-endpoints#global-access)从您VPC内的其他地区进行连接。 - -**请完成以下步骤以启用GCP PSC**: -1. 获取私有服务连接的GCP服务附加。 -1. 创建服务端点。 -1. 将“端点ID”添加到ClickHouse Cloud服务中。 -1. 将“端点ID”添加到ClickHouse服务允许列表中。 - - -## 注意事项 {#attention} -ClickHouse尝试将您的服务分组,以便在GCP区域内重用相同的发布[PSC端点](https://cloud.google.com/vpc/docs/private-service-connect)。然而,尤其是在您将服务分布在多个ClickHouse组织之间时,这种分组不能得到保证。 -如果您已经为ClickHouse组织中的其他服务配置了PSC,通常可以跳过大部分步骤,因为分组的原因,直接进行最后一步:[添加“端点ID”到ClickHouse服务允许列表](#add-endpoint-id-to-services-allow-list)。 - -在[这里](https://github.com/ClickHouse/terraform-provider-clickhouse/tree/main/examples/)找到Terraform示例。 - -## 在开始之前 {#before-you-get-started} - -:::note -下面提供了代码示例,以演示如何在ClickHouse Cloud服务中设置私有服务连接。在下面的示例中,我们将使用: - - GCP区域:`us-central1` - - GCP项目(客户GCP项目):`my-gcp-project` - - 客户GCP项目中的GCP私有IP地址:`10.128.0.2` - - 客户GCP项目中的GCP VPC:`default` -::: - -您需要检索有关您的ClickHouse Cloud服务的信息。您可以通过ClickHouse Cloud控制台或ClickHouse API来完成。如果您打算使用ClickHouse API,请在继续之前设置以下环境变量: - -```shell -REGION= -PROVIDER=gcp -KEY_ID= -KEY_SECRET= -ORG_ID= -SERVICE_NAME= -``` - -您可以[创建一个新的ClickHouse Cloud API密钥](/cloud/manage/openapi)或使用现有的密钥。 - -通过按区域、提供商和服务名称过滤以获取您的ClickHouse `INSTANCE_ID`: - -```shell -INSTANCE_ID=$(curl --silent --user "${KEY_ID:?}:${KEY_SECRET:?}" \ -"https://api.clickhouse.cloud/v1/organizations/${ORG_ID:?}/services" | \ -jq ".result[] | select (.region==\"${REGION:?}\" and .provider==\"${PROVIDER:?}\" and .name==\"${SERVICE_NAME:?}\") | .id " -r) -``` - -:::note - - 您可以从ClickHouse控制台(组织 -> 组织详情)中获取您的组织ID。 - - 您可以[创建一个新的密钥](/cloud/manage/openapi)或使用现有的密钥。 -::: - -## 获取GCP服务附加和私有服务连接的DNS名称 {#obtain-gcp-service-attachment-and-dns-name-for-private-service-connect} - -### 选项 1:ClickHouse Cloud控制台 {#option-1-clickhouse-cloud-console} - -在ClickHouse Cloud控制台中,打开您希望通过私有服务连接连接的服务,然后打开**设置**菜单。点击**设置私有端点**按钮。记下**服务名称**(`endpointServiceId`)和**DNS名称**(`privateDnsHostname`)。您将在接下来的步骤中使用它们。 - -Private Endpoints - -### 选项 2:API {#option-2-api} - -:::note -您需要在区域中至少部署一个实例才能执行此步骤。 -::: - -获取GCP服务附加和私有服务连接的DNS名称: - -```bash -curl --silent --user "${KEY_ID:?}:${KEY_SECRET:?}" "https://api.clickhouse.cloud/v1/organizations/${ORG_ID:?}/services/${INSTANCE_ID:?}/privateEndpointConfig" | jq .result -{ - "endpointServiceId": "projects/.../regions/us-central1/serviceAttachments/production-us-central1-clickhouse-cloud", - "privateDnsHostname": "xxxxxxxxxx.us-central1.p.gcp.clickhouse.cloud" -} -``` - -记下`endpointServiceId`和`privateDnsHostname`。您将在接下来的步骤中使用它们。 - -## 创建服务端点 {#create-service-endpoint} - -:::important -本节涵盖通过GCP PSC(私有服务连接)配置ClickHouse的ClickHouse特定详细信息。GCP特定步骤仅作为参考,以指导您查看相关内容,但它们可能会随时间而变化,无需GCP云提供商通知。请根据您的特定用例考虑GCP配置。 - -请注意,ClickHouse不负责配置所需的GCP PSC端点、DNS记录。 - -有关GCP配置任务的任何问题,请直接联系GCP支持。 -::: - -在本节中,我们将创建一个服务端点。 - -### 添加私有服务连接 {#adding-a-private-service-connection} - -首先,我们将创建私有服务连接。 - -#### 选项 1:使用Google Cloud控制台 {#option-1-using-google-cloud-console} - -在Google Cloud控制台中,导航到**网络服务 -> 私有服务连接**。 - -Open Private Service Connect in Google Cloud Console - -通过点击**连接端点**按钮打开私有服务连接创建对话框。 - -- **目标**:使用**已发布的服务** -- **目标服务**:使用来自[获取GCP服务附加和私有服务连接的DNS名称](#obtain-gcp-service-attachment-and-dns-name-for-private-service-connect)步骤的`endpointServiceId`API或`服务名称`控制台。 -- **端点名称**:为PSC **端点名称**设置一个名称。 -- **网络/子网络/IP地址**:选择您希望用于连接的网络。您需要创建一个IP地址或使用现有的IP地址作为私有服务连接端点。在我们的示例中,我们预先创建了名称为**your-ip-address**的地址,并分配了IP地址`10.128.0.2` -- 为了使端点在任何区域可用,您可以启用**启用全局访问**复选框。 - -Enable Global Access for Private Service Connect - -要创建PSC端点,请使用**添加端点**按钮。 - -**状态**列将在连接获得批准后从**待处理**变为**已接受**。 - -Copy PSC Connection ID - -复制***PSC连接ID***,我们将在接下来的步骤中将其用作***端点ID***。 - -#### 选项 2:使用Terraform {#option-2-using-terraform} - -```json -provider "google" { - project = "my-gcp-project" - region = "us-central1" -} - -variable "region" { - type = string - default = "us-central1" -} - -variable "subnetwork" { - type = string - default = "https://www.googleapis.com/compute/v1/projects/my-gcp-project/regions/us-central1/subnetworks/default" -} - -variable "network" { - type = string - default = "https://www.googleapis.com/compute/v1/projects/my-gcp-project/global/networks/default" -} - -resource "google_compute_address" "psc_endpoint_ip" { - address = "10.128.0.2" - address_type = "INTERNAL" - name = "your-ip-address" - purpose = "GCE_ENDPOINT" - region = var.region - subnetwork = var.subnetwork -} - -resource "google_compute_forwarding_rule" "clickhouse_cloud_psc" { - ip_address = google_compute_address.psc_endpoint_ip.self_link - name = "ch-cloud-${var.region}" - network = var.network - region = var.region - load_balancing_scheme = "" - # service attachment - target = "https://www.googleapis.com/compute/v1/$TARGET" # See below in notes -} - -output "psc_connection_id" { - value = google_compute_forwarding_rule.clickhouse_cloud_psc.psc_connection_id - description = "Add GCP PSC Connection ID to allow list on instance level." -} -``` - -:::note -使用来自[获取GCP服务附加和私有服务连接的DNS名称](#obtain-gcp-service-attachment-and-dns-name-for-private-service-connect)步骤的`endpointServiceId`API或`服务名称`控制台。 -::: - -## 设置端点的私有DNS名称 {#setting-up-dns} - -:::note -有多种方式来配置DNS。请根据您的特定用例设置DNS。 -::: - -您需要将“DNS名称”,即来自[获取GCP服务附加和私有服务连接的DNS名称](#obtain-gcp-service-attachment-and-dns-name-for-private-service-connect)步骤中的名称,指向GCP私有服务连接端点IP地址。这确保服务/组件可以在您的VPC/网络内正确解析它。 - -## 将端点ID添加到ClickHouse Cloud组织 {#add-endpoint-id-to-clickhouse-cloud-organization} - -### 选项 1:ClickHouse Cloud控制台 {#option-1-clickhouse-cloud-console-1} - -要将端点添加到您的组织,请继续到[添加“端点ID”到ClickHouse服务允许列表](#add-endpoint-id-to-services-allow-list)步骤。在ClickHouse Cloud控制台中使用`PSC连接ID`将其添加到服务允许列表中,自动将其添加到组织中。 - -要删除端点,请打开**组织详情 -> 私有端点**,然后单击删除按钮以移除该端点。 - -Remove Private Endpoint from ClickHouse Cloud - -### 选项 2:API {#option-2-api-1} - -在运行任何命令之前,请设置以下环境变量: - -用来自[添加一个私有服务连接](#adding-a-private-service-connection)步骤的“端点ID”替换下面的`ENDPOINT_ID`。 - -要添加端点,请运行: - -```bash -cat < - -### 选项 2:API {#option-2-api-2} - -在运行任何命令之前,请设置以下环境变量: - -用来自[添加一个私有服务连接](#adding-a-private-service-connection)步骤的“端点ID”替换下面的**ENDPOINT_ID**。 - -对每个应通过私有服务连接提供的服务执行此操作。 - -要添加: - -```bash -cat < - -#### 选项 2:API {#option-2-api-3} - -```bash -curl --silent --user "${KEY_ID:?}:${KEY_SECRET:?}" "https://api.clickhouse.cloud/v1/organizations/${ORG_ID:?}/services/${INSTANCE_ID:?}/privateEndpointConfig" | jq .result -``` - -```response -{ - ... - "privateDnsHostname": "xxxxxxx..p.gcp.clickhouse.cloud" -} -``` - -在此示例中,连接到`xxxxxxx.yy-xxxxN.p.gcp.clickhouse.cloud`主机名将路由到私有服务连接。同时,`xxxxxxx.yy-xxxxN.gcp.clickhouse.cloud`将通过互联网路由。 - -## 疑难解答 {#troubleshooting} - -### 测试DNS设置 {#test-dns-setup} - -DNS_NAME - 使用来自[获取GCP服务附加和私有服务连接的DNS名称](#obtain-gcp-service-attachment-and-dns-name-for-private-service-connect)步骤中的`privateDnsHostname` - -```bash -nslookup $DNS_NAME -``` - -```response -Non-authoritative answer: -... -Address: 10.128.0.2 -``` - -### 连接被对等方重置 {#connection-reset-by-peer} - -- 很可能,未将端点ID添加到服务允许列表。请重新访问[_添加端点ID到服务允许列表_步骤](#add-endpoint-id-to-services-allow-list)。 - -### 测试连接性 {#test-connectivity} - -如果您在使用PSC链接时遇到连接问题,请使用`openssl`检查您的连接性。确保私有服务连接端点的状态为`已接受`: - -OpenSSL应该能够连接(请参见输出中的CONNECTED)。`errno=104`是预期的。 - -DNS_NAME - 使用来自[获取GCP服务附加和私有服务连接的DNS名称](#obtain-gcp-service-attachment-and-dns-name-for-private-service-connect)步骤中的`privateDnsHostname` - -```bash -openssl s_client -connect ${DNS_NAME}:9440 -``` - -```response - -# highlight-next-line -CONNECTED(00000003) -write:errno=104 ---- -no peer certificate available ---- -No client certificate CA names sent ---- -SSL handshake has read 0 bytes and written 335 bytes -Verification: OK ---- -New, (NONE), Cipher is (NONE) -Secure Renegotiation IS NOT supported -Compression: NONE -Expansion: NONE -No ALPN negotiated -Early data was not sent -Verify return code: 0 (ok) -``` - -### 检查端点过滤器 {#checking-endpoint-filters} - -#### REST API {#rest-api} - -```bash -curl --silent --user "${KEY_ID:?}:${KEY_SECRET:?}" -X GET -H "Content-Type: application/json" "https://api.clickhouse.cloud/v1/organizations/${ORG_ID:?}/services/${INSTANCE_ID:?}" | jq .result.privateEndpointIds -[ - "102600141743718403" -] -``` - -### 连接到远程数据库 {#connecting-to-a-remote-database} - -假设您尝试在ClickHouse Cloud中使用[MySQL](../../sql-reference/table-functions/mysql.md)或[PostgreSQL](../../sql-reference/table-functions/postgresql.md)表函数,并连接到您在GCP中托管的数据库。GCP PSC无法用来安全地启用此连接。PSC是一种单向的单向连接。它允许您的内部网络或GCP VPC安全地连接到ClickHouse Cloud,但它不允许ClickHouse Cloud连接到您的内部网络。 - -根据[GCP私有服务连接文档](https://cloud.google.com/vpc/docs/private-service-connect): - -> 面向服务的设计:生产者服务通过负载均衡器发布,向消费者VPC网络公开单个IP地址。访问生产者服务的消费者流量是单向的,只能访问服务IP地址,而无法访问整个对等的VPC网络。 - -为此,请配置您的GCP VPC防火墙规则,以允许ClickHouse Cloud与您的内部/私有数据库服务建立连接。查看[ClickHouse Cloud区域的默认出口IP地址](/manage/security/cloud-endpoints-api),以及[可用的静态IP地址](https://api.clickhouse.cloud/static-ips.json)。 - -## 更多信息 {#more-information} - -有关更详细的信息,请访问[cloud.google.com/vpc/docs/configure-private-service-connect-services](https://cloud.google.com/vpc/docs/configure-private-service-connect-services)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/gcp-private-service-connect.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/gcp-private-service-connect.md.hash deleted file mode 100644 index 71a0d65a738..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/gcp-private-service-connect.md.hash +++ /dev/null @@ -1 +0,0 @@ -c16f6c4dd9f07121 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/index.md deleted file mode 100644 index f5b4dbe65cb..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/index.md +++ /dev/null @@ -1,23 +0,0 @@ ---- -'slug': '/cloud/security' -'keywords': -- 'Cloud' -- 'Security' -'title': '概述' -'hide_title': true -'description': 'ClickHouse Cloud 安全的着陆页' ---- - - -# ClickHouse Cloud 安全性 - -本节深入探讨 ClickHouse Cloud 的安全性,并包含以下页面: - -| 页面 | 描述 | -|---------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| [共享责任模型](shared-responsibility-model.md) | 有关为每种服务类型提供的安全功能的信息。 | -| [云访问管理](cloud-access-management/index.md) | 有关访问控制、身份验证、单点登录设置、常见访问管理查询以及如何邀请新用户的信息。 | -| [连接性](connectivity-overview.md) | 有关设置 IP 过滤器、私有网络、S3 数据的安全访问和云 IP 地址的信息。 | -| [增强加密](cmek.md) | 静态数据默认使用云提供商管理的 AES 256 密钥加密。客户可以启用透明数据加密 (TDE),为服务数据提供额外的保护层。 | -| [审计日志](audit-logging.md) | ClickHouse Cloud 中审计日志的指南。 | -| [隐私和合规性](privacy-compliance-overview.md) | 有关 ClickHouse Cloud 的安全性和合规性的信息,以及如何查看和更正您的个人信息的指南。 | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/index.md.hash deleted file mode 100644 index b9becabec14..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/index.md.hash +++ /dev/null @@ -1 +0,0 @@ -84e755e836339115 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/inviting-new-users.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/inviting-new-users.md.hash deleted file mode 100644 index eded3f75b59..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/inviting-new-users.md.hash +++ /dev/null @@ -1 +0,0 @@ -8dc4c0cc007d0d81 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/personal-data-access.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/personal-data-access.md deleted file mode 100644 index 7535c385d21..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/personal-data-access.md +++ /dev/null @@ -1,62 +0,0 @@ ---- -'sidebar_label': '个人数据访问' -'slug': '/cloud/security/personal-data-access' -'title': '个人数据访问' -'description': '作为注册用户,ClickHouse 允许您查看和管理您的个人账户数据,包括联系信息。' ---- - -import Image from '@theme/IdealImage'; -import support_case_form from '@site/static/images/cloud/security/support-case-form.png'; - -## 介绍 {#intro} - -作为注册用户,ClickHouse 允许您查看和管理您的个人账户数据,包括联系信息。根据您的角色,这可能还包括访问您所在组织中其他用户的联系信息、API 密钥详细信息以及其他相关信息。您可以通过 ClickHouse 控制台自助管理这些详细信息。 - -**什么是数据主体访问请求 (DSAR)** - -根据您所在的位置,适用的法律可能还会为您提供有关 ClickHouse 持有的个人数据的额外权利(数据主体权利),具体情况请参阅 ClickHouse 隐私政策。 行使数据主体权利的过程称为数据主体访问请求(DSAR)。 - -**个人数据的范围** - -请查看 ClickHouse 的隐私政策以获取 ClickHouse 收集的个人数据的详细信息以及这些数据可能如何使用。 - -## 自助服务 {#self-service} - -默认情况下,ClickHouse 使用户能够直接通过 ClickHouse 控制台查看他们的个人数据。 - -以下是 ClickHouse 在账户设置和服务使用过程中收集的数据摘要,以及在 ClickHouse 控制台中可以查看特定个人数据的信息。 - -| 位置/网址 | 描述 | 个人数据 | -|-------------|----------------|-----------------------------------------| -| https://auth.clickhouse.cloud/u/signup/ | 账户注册 | email, password | -| https://console.clickhouse.cloud/profile | 一般用户配置文件详细信息 | name, email | -| https://console.clickhouse.cloud/organizations/OrgID/members | 组织中的用户列表 | name, email | -| https://console.clickhouse.cloud/organizations/OrgID/keys | API 密钥及其创建者列表 | email | -| https://console.clickhouse.cloud/organizations/OrgID/audit | 活动日志,列出各个用户的操作 | email | -| https://console.clickhouse.cloud/organizations/OrgID/billing | 账单信息和发票 | billing address, email | -| https://console.clickhouse.cloud/support | 与 ClickHouse 支持的互动 | name, email | - -注意:包含 `OrgID` 的网址需要更新,以反映您特定账户的 `OrgID`。 - -### 当前客户 {#current-customers} - -如果您与我们有账户,并且自助选项未解决您的个人数据问题,您可以根据隐私政策提交数据主体访问请求。为此,请登录您的 ClickHouse 账户并打开一个 [支持案例](https://console.clickhouse.cloud/support)。这有助于我们验证您的身份并简化处理您的请求的过程。 - -请确保在您的支持案例中包含以下详细信息: - -| 字段 | 请求中包含的文本 | -|-------------|---------------------------------------------------| -| 主题 | 数据主体访问请求 (DSAR) | -| 描述 | 详细描述您希望 ClickHouse 查找、收集和/或提供的信息。 | - -ClickHouse Cloud 中的支持案例表单 - -### 没有账户的个人 {#individuals-without-an-account} - -如果您与我们没有账户,并且上述自助选项未解决您的个人数据问题,您希望根据隐私政策提交数据主体访问请求,您可以通过电子邮件将这些请求提交至 [privacy@clickhouse.com](mailto:privacy@clickhouse.com)。 - -## 身份验证 {#identity-verification} - -如果您通过电子邮件提交数据主体访问请求,我们可能会要求您提供特定信息,以帮助我们确认您的身份并处理您的请求。适用法律可能要求或允许我们拒绝您的请求。如果我们拒绝您的请求,我们将告知您原因,但需遵守法律限制。 - -欲了解更多信息,请查看 [ClickHouse 隐私政策](https://clickhouse.com/legal/privacy-policy) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/personal-data-access.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/personal-data-access.md.hash deleted file mode 100644 index 004c8f5bb87..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/personal-data-access.md.hash +++ /dev/null @@ -1 +0,0 @@ -fc97d80d792ad2a1 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/privacy-compliance-overview.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/privacy-compliance-overview.md deleted file mode 100644 index 5115231fe71..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/privacy-compliance-overview.md +++ /dev/null @@ -1,16 +0,0 @@ ---- -'sidebar_label': '隐私与合规概述' -'slug': '/cloud/security/privacy-compliance-overview' -'title': '隐私与合规' -'description': '隐私与合规的着陆页' ---- - - -# 隐私和合规性 - -本节包含以下页面: - -| 页面 | 描述 | -|---------------------------------------------------------------------------|------------------------------------------------------------| -| [安全与合规性](/cloud/security/security-and-compliance) | ClickHouse Cloud 的安全报告和隐私合规性。 | -| [个人数据访问](/cloud/security/personal-data-access) | 获取访问您的个人数据的信息。 | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/privacy-compliance-overview.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/privacy-compliance-overview.md.hash deleted file mode 100644 index d66fd77e892..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/privacy-compliance-overview.md.hash +++ /dev/null @@ -1 +0,0 @@ -47c45bc0076326e7 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/private-link-overview.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/private-link-overview.md deleted file mode 100644 index fbe19da5d62..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/private-link-overview.md +++ /dev/null @@ -1,15 +0,0 @@ ---- -'sidebar_label': 'Private Link 概述' -'slug': '/cloud/security/private-link-overview' -'title': 'Private Link 概述' -'description': 'Private Link 的登录页面' ---- - - -# Private Link 概述 - -ClickHouse Cloud 提供将您的服务连接到您的云虚拟网络的能力。请参阅以下针对您的提供商的指南: - -- [AWS Private Link](/cloud/security/aws-privatelink.md) -- [GCP Private Service Connect](/cloud/security/gcp-private-service-connect.md) -- [Azure Private Link](/cloud/security/azure-privatelink.md) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/private-link-overview.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/private-link-overview.md.hash deleted file mode 100644 index 1440462f318..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/private-link-overview.md.hash +++ /dev/null @@ -1 +0,0 @@ -b28f6e0020816ae5 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/saml-sso-setup.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/saml-sso-setup.md deleted file mode 100644 index 812d75f78e5..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/saml-sso-setup.md +++ /dev/null @@ -1,367 +0,0 @@ ---- -'sidebar_label': 'SAML SSO 设置' -'slug': '/cloud/security/saml-setup' -'title': 'SAML SSO 设置' -'description': '如何使用 ClickHouse Cloud 设置 SAML SSO' ---- - -import Image from '@theme/IdealImage'; -import samlOrgId from '@site/static/images/cloud/security/saml-org-id.png'; -import samlOktaSetup from '@site/static/images/cloud/security/saml-okta-setup.png'; -import samlGoogleApp from '@site/static/images/cloud/security/saml-google-app.png'; -import samlAzureApp from '@site/static/images/cloud/security/saml-azure-app.png'; -import samlAzureClaims from '@site/static/images/cloud/security/saml-azure-claims.png'; -import EnterprisePlanFeatureBadge from '@theme/badges/EnterprisePlanFeatureBadge' - - - -# SAML SSO 设置 - - - -ClickHouse Cloud 支持通过安全断言标记语言 (SAML) 的单点登录 (SSO)。这使您能够通过与您的身份提供者 (IdP) 进行身份验证,安全地登录到您的 ClickHouse Cloud 组织。 - -我们目前支持服务提供者启动的 SSO、多组织使用独立连接以及即时配置。我们尚不支持跨域身份管理系统 (SCIM) 或属性映射。 - -## 开始之前 {#before-you-begin} - -您需要在您的 IdP 中具有管理员权限,并在您的 ClickHouse Cloud 组织中具有 **Admin** 角色。在您的 IdP 中设置好连接后,请使用下述程序中请求的信息与我们联系以完成该过程。 - -我们建议除了 SAML 连接之外,还设置一个 **直接链接到您的组织** 以简化登录过程。每个 IdP 处理此事的方式不同。继续了解如何为您的 IdP 执行此操作。 - -## 如何配置您的 IdP {#how-to-configure-your-idp} - -### 步骤 {#steps} - -
- 获取您的组织 ID - - 所有设置都需要您的组织 ID。要获取您的组织 ID: - - 1. 登录到您的 [ClickHouse Cloud](https://console.clickhouse.cloud) 组织。 - - Organization ID - - 3. 在左下角,点击 **Organization** 下的组织名称。 - - 4. 在弹出菜单中,选择 **Organization details**。 - - 5. 记下您的 **Organization ID** 以供后续使用。 - -
- -
- 配置您的 SAML 集成 - - ClickHouse 使用服务提供者发起的 SAML 连接。这意味着您可以通过 `https://console.clickhouse.cloud` 或通过直接链接登录。我们目前不支持身份提供者发起的连接。基本的 SAML 配置包括以下内容: - - - SSO URL 或 ACS URL: `https://auth.clickhouse.cloud/login/callback?connection={organizationid}` - - - Audience URI 或 Entity ID: `urn:auth0:ch-production:{organizationid}` - - - 应用程序用户名: `email` - - - 属性映射: `email = user.email` - - - 访问您组织的直接链接: `https://console.clickhouse.cloud/?connection={organizationid}` - - - 有关具体配置步骤,请参阅您特定的身份提供商下方的信息。 - -
- -
- 获取您的连接信息 - - 获取您的身份提供者 SSO URL 和 x.509 证书。请参阅您特定的身份提供商下方以获取有关如何检索此信息的说明。 - -
- - -
- 提交支持案例 - - 1. 返回 ClickHouse Cloud 控制台。 - - 2. 在左侧选择 **Help**,然后选择支持子菜单。 - - 3. 点击 **New case**。 - - 4. 输入主题 "SAML SSO Setup"。 - - 5. 在描述中粘贴从上述说明中收集的任何链接,并将证书附加到票据中。 - - 6. 请告知我们哪些域应被允许用于此连接(例如 domain.com, domain.ai, 等)。 - - 7. 创建一个新案例。 - - 8. 我们将在 ClickHouse Cloud 内完成设置,并在准备好测试时通知您。 - -
- -
- 完成设置 - - 1. 在您的身份提供者中分配用户访问权限。 - - 2. 通过 `https://console.clickhouse.cloud` 或者您在 "Configure your SAML integration" 中配置的直接链接登录 ClickHouse。用户最初被分配为 ‘Member’ 角色,可以登录到组织并更新个人设置。 - - 3. 登出 ClickHouse 组织。 - - 4. 使用您的原始身份验证方法登录以将 Admin 角色分配给您的新 SSO 帐户。 - - 对于邮箱 + 密码帐户,请使用 `https://console.clickhouse.cloud/?with=email`。 - - 对于社交登录,请点击相应的按钮 (**Continue with Google** 或 **Continue with Microsoft**) - - 5. 使用您的原始身份验证方法登出,并通过 `https://console.clickhouse.cloud` 或您在 "Configure your SAML integration" 中配置的直接链接重新登录。 - - 6. 删除任何非 SAML 用户以强制执行组织的 SAML。以后的用户将通过您的身份提供者分配。 - -
- -### 配置 Okta SAML {#configure-okta-saml} - -您将在 Okta 中为每个 ClickHouse 组织配置两个应用集成:一个 SAML 应用和一个用于存放您直接链接的书签。 - -
- 1. 创建一个组以管理访问权限 - - 1. 作为 **Administrator** 登录到您的 Okta 实例。 - - 2. 在左侧选择 **Groups**。 - - 3. 点击 **Add group**。 - - 4. 输入组的名称和描述。此组将用于保持 SAML 应用与其相关书签应用之间的用户一致性。 - - 5. 点击 **Save**。 - - 6. 点击您创建的组的名称。 - - 7. 点击 **Assign people** 为希望访问此 ClickHouse 组织的用户分配权限。 - -
- -
- 2. 创建一个书签应用以使用户无缝登录 - - 1. 在左侧选择 **Applications**,然后选择 **Applications** 子标题。 - - 2. 点击 **Browse App Catalog**。 - - 3. 搜索并选择 **Bookmark App**。 - - 4. 点击 **Add integration**。 - - 5. 为应用选择一个标签。 - - 6. 输入 URL 为 `https://console.clickhouse.cloud/?connection={organizationid}` - - 7. 转到 **Assignments** 标签,将您上述创建的组添加进去。 - -
- -
- 3. 创建一个 SAML 应用以启用连接 - - 1. 在左侧选择 **Applications**,然后选择 **Applications** 子标题。 - - 2. 点击 **Create App Integration**。 - - 3. 选择 SAML 2.0 并点击 Next。 - - 4. 输入您的应用程序名称,并勾选 **Do not display application icon to users** 旁边的框,然后点击 **Next**。 - - 5. 使用以下值填充 SAML 设置屏幕。 - - | 字段 | 值 | - |--------------------------------|-------| - | 单点登录 URL | `https://auth.clickhouse.cloud/login/callback?connection={organizationid}` | - | Audience URI (SP Entity ID) | `urn:auth0:ch-production:{organizationid}` | - | 默认 RelayState | 留空 | - | Name ID 格式 | 未指定 | - | 应用程序用户名 | Email | - | 更新应用程序用户名的 | 创建和更新 | - - 7. 输入以下属性声明。 - - | 名称 | 名称格式 | 值 | - |---------|---------------|------------| - | email | Basic | user.email | - - 9. 点击 **Next**。 - - 10. 在反馈屏幕上输入所请求的信息,然后点击 **Finish**。 - - 11. 转到 **Assignments** 标签,将您上述创建的组添加进去。 - - 12. 在新应用的 **Sign On** 标签下,点击 **View SAML setup instructions** 按钮。 - - Okta SAML Setup Instructions - - 13. 收集这三项,并前往提交支持案例以完成此过程。 - - 身份提供者单点登录 URL - - 身份提供者发行者 - - X.509 证书 - -
- - -### 配置 Google SAML {#configure-google-saml} - -您将为每个组织在 Google 中配置一个 SAML 应用,并且必须提供给用户直接链接(`https://console.clickhouse.cloud/?connection={organizationId}`)以便于书签,如果使用多组织 SSO。 - -
- 创建一个 Google Web 应用 - - 1. 前往您的 Google 管理控制台 (admin.google.com)。 - - Google SAML App - - 2. 点击左侧的 **Apps**,然后选择 **Web and mobile apps**。 - - 3. 点击顶部菜单中的 **Add app**,然后选择 **Add custom SAML app**。 - - 4. 输入应用的名称并点击 **Continue**。 - - 5. 收集这两项内容,并前往提交支持案例以将信息提交给我们。注意:如果在复制此数据之前完成设置,请点击应用主页上的 **DOWNLOAD METADATA** 以获取 X.509 证书。 - - SSO URL - - X.509 证书 - - 7. 输入以下 ACS URL 和实体 ID。 - - | 字段 | 值 | - |-----------|-------| - | ACS URL | `https://auth.clickhouse.cloud/login/callback?connection={organizationid}` | - | 实体 ID | `urn:auth0:ch-production:{organizationid}` | - - 8. 选中 **Signed response** 复选框。 - - 9. 选择 **EMAIL** 作为 Name ID 格式,并将 Name ID 留空为 **Basic Information > Primary email.** - - 10. 点击 **Continue**。 - - 11. 输入以下属性映射: - - | 字段 | 值 | - |-------------------|---------------| - | 基本信息 | 主邮箱 | - | 应用属性 | email | - - 13. 点击 **Finish**。 - - 14. 要启用应用,请对所有人点击 **OFF**,然后将设置更改为 **ON**。通过选择屏幕左侧的选项,也可以限制对组或组织单位的访问。 - -
- -### 配置 Azure (Microsoft) SAML {#configure-azure-microsoft-saml} - -Azure (Microsoft) SAML 也可以称为 Azure Active Directory (AD) 或 Microsoft Entra。 - -
- 创建一个 Azure 企业应用 - - 您将为每个组织设置一个具有单独登录 URL 的应用集成。 - - 1. 登录到 Microsoft Entra 管理中心。 - - 2. 在左侧导航到 **Applications > Enterprise** 应用。 - - 3. 点击顶部菜单中的 **New application**。 - - 4. 点击顶部菜单中的 **Create your own application**。 - - 5. 输入名称并选择 **Integrate any other application you don't find in the gallery (Non-gallery)**,然后点击 **Create**。 - - Azure Non-Gallery App - - 6. 点击左侧的 **Users and groups** 并分配用户。 - - 7. 点击左侧的 **Single sign-on**。 - - 8. 点击 **SAML**。 - - 9. 使用以下设置填充基本 SAML 配置屏幕。 - - | 字段 | 值 | - |---------------------------|-------| - | 标识符 (实体 ID) | `urn:auth0:ch-production:{organizationid}` | - | 回复 URL (断言消费者服务 URL) | `https://auth.clickhouse.cloud/login/callback?connection={organizationid}` | - | 登录 URL | `https://console.clickhouse.cloud/?connection={organizationid}` | - | Relay State | 空白 | - | 登出 URL | 空白 | - - 11. 在 Attributes & Claims 下添加 (A) 或更新 (U) 以下内容: - - | 声明名称 | 格式 | 来源属性 | - |--------------------------------------|---------------|------------------| - | (U) 唯一用户标识符 (Name ID) | 邮件地址 | user.mail | - | (A) email | Basic | user.mail | - | (U) /identity/claims/name | 省略 | user.mail | - - Attributes and Claims - - 12. 收集这两项,并前往提交支持案例以完成此过程: - - 登录 URL - - 证书 (Base64) - -
- -### 配置 Duo SAML {#configure-duo-saml} - -
- 创建一个 Duo 的通用 SAML 服务提供者 - - 1. 遵循 [Duo Single Sign-On for Generic SAML Service Providers](https://duo.com/docs/sso-generic) 的说明。 - - 2. 使用以下桥接属性映射: - - | 桥接属性 | ClickHouse 属性 | - |:-------------------|:-----------------------| - | 邮件地址 | email | - - 3. 使用以下值更新 Duo 中的 Cloud 应用程序: - - | 字段 | 值 | - |:----------|:-------------------------------------------| - | 实体 ID | `urn:auth0:ch-production:{organizationid}` | - | 断言消费者服务 (ACS) URL | `https://auth.clickhouse.cloud/login/callback?connection={organizationid}` | - | 服务提供者登录 URL | `https://console.clickhouse.cloud/?connection={organizationid}` | - - 4. 收集这两项,并前往提交支持案例以完成此过程: - - 单点登录 URL - - 证书 - -
- - -## 工作原理 {#how-it-works} - -### 服务提供者发起的 SSO {#service-provider-initiated-sso} - -我们仅使用服务提供者发起的 SSO。这意味着用户需要访问 `https://console.clickhouse.cloud` 并输入他们的电子邮件地址,以被重定向到 IdP 进行身份验证。已经通过您的 IdP 进行身份验证的用户可以使用直接链接,自动登录到您的组织,而无需在登录页面输入他们的电子邮件地址。 - -### 分配用户角色 {#assigning-user-roles} - -用户将会在分配到您的 IdP 应用并第一次登录后出现在您的 ClickHouse Cloud 控制台中。至少应该将一个 SSO 用户分配为您组织中的 Admin 角色。使用社交登录或 `https://console.clickhouse.cloud/?with=email` 按照您原始的身份验证方法登录以更新您的 SSO 角色。 - -### 移除非 SSO 用户 {#removing-non-sso-users} - -一旦您设置了 SSO 用户并将至少一个用户分配为 Admin 角色,管理员可以移除使用其他方法 (例如社交身份验证或用户 ID + 密码) 的用户。在设置 SSO 之后,Google 身份验证仍将有效。使用用户 ID + 密码的用户将根据他们的电子邮件域自动重定向到 SSO,除非用户使用 `https://console.clickhouse.cloud/?with=email`。 - -### 管理用户 {#managing-users} - -ClickHouse Cloud 目前为 SSO 实现了 SAML。我们尚未实施 SCIM 来管理用户。这意味着 SSO 用户必须在您的 IdP 中被分配到应用程序才能访问您的 ClickHouse Cloud 组织。用户必须在 ClickHouse Cloud 中登录一次,才能在组织的 **Users** 区域中显示。当在您的 IdP 中移除用户时,他们将无法通过 SSO 登录 ClickHouse Cloud。然而,该 SSO 用户在您的组织中仍将显示,直到管理员手动移除该用户。 - -### 多组织 SSO {#multi-org-sso} - -ClickHouse Cloud 通过为每个组织提供单独的连接,支持多组织 SSO。使用直接链接 (`https://console.clickhouse.cloud/?connection={organizationid}`) 登录到各自的组织。确保在登录到另一个组织之前退出当前组织。 - -## 其他信息 {#additional-information} - -安全性是我们在身份验证方面的首要任务。因此,在实施 SSO 时,我们做出了一些决策,您需要了解这些决策。 - -- **我们只处理服务提供者发起的身份验证流程。** 用户必须访问 `https://console.clickhouse.cloud` 并输入电子邮件地址以重定向到您的身份提供者。提供了添加书签应用程序或快捷方式的说明,以便于您的用户,无需记住 URL。 - -- **通过您的 IdP 分配给您的应用的所有用户必须拥有相同的电子邮件域。** 如果您有供应商、承包商或顾问希望访问您的 ClickHouse 帐户,他们的电子邮件地址必须与您员工的域相同(例如 user@domain.com)。 - -- **我们不会自动链接 SSO 和非 SSO 帐户。** 即使它们使用相同的电子邮件地址,您可能会在 ClickHouse 用户列表中看到用户的多个帐户。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/saml-sso-setup.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/saml-sso-setup.md.hash deleted file mode 100644 index 3fd822612d4..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/saml-sso-setup.md.hash +++ /dev/null @@ -1 +0,0 @@ -1ecb081c60dbbb1e diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/setting-ip-filters.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/setting-ip-filters.md deleted file mode 100644 index f3066987da9..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/setting-ip-filters.md +++ /dev/null @@ -1,84 +0,0 @@ ---- -'sidebar_label': '设置 IP 过滤器' -'slug': '/cloud/security/setting-ip-filters' -'title': '设置 IP 过滤器' -'description': '此页面解释了如何在 ClickHouse Cloud 中设置 IP 过滤器,以控制对 ClickHouse 服务的访问。' ---- - -import Image from '@theme/IdealImage'; -import ip_filtering_after_provisioning from '@site/static/images/cloud/security/ip-filtering-after-provisioning.png'; -import ip_filter_add_single_ip from '@site/static/images/cloud/security/ip-filter-add-single-ip.png'; - -## 设置 IP 过滤器 {#setting-ip-filters} - -IP 访问列表通过指定哪些源地址被允许连接到您的 ClickHouse 服务来过滤流量。每个服务的列表都是可配置的。列表可以在服务部署期间或之后进行配置。如果您在配置过程中未设置 IP 访问列表,或如果您想对初始列表进行更改,则可以通过选择服务,然后选择 **Security** 选项卡来进行更改。 - -:::important -如果您跳过了 ClickHouse Cloud 服务的 IP 访问列表的创建,则该服务将不允许任何流量。 -::: - -## 准备 {#prepare} -在开始之前,请收集应添加到访问列表中的 IP 地址或范围。请考虑到远程工作者、值班位置、VPN 等。IP 访问列表用户界面接受单个地址和 CIDR 符号表示法。 - -无类域间路由(CIDR)符号表示法,允许您指定小于传统 A 类、B 类或 C 类(8、6 或 24)子网掩码大小的 IP 地址范围。如果您需要,[ARIN](https://account.arin.net/public/cidrCalculator) 和其他几个组织提供 CIDR 计算器。如果您想了解更多有关 CIDR 符号表示法的信息,请参见 [无类域间路由(CIDR)](https://www.rfc-editor.org/rfc/rfc4632.html) RFC。 - -## 创建或修改 IP 访问列表 {#create-or-modify-an-ip-access-list} - -从您的 ClickHouse Cloud 服务列表中选择服务,然后选择 **Settings**。在 **Security** 部分,您将找到 IP 访问列表。单击超链接,其文本为:*You can connect to this service from* **(anywhere | x specific locations)** - -将出现一个侧边栏,供您配置选项: - -- 允许来自任何地方到该服务的流量 -- 允许从特定位置访问该服务 -- 拒绝对该服务的所有访问 - -此屏幕截图显示了一个访问列表,它允许来自一系列 IP 地址的流量,该范围被描述为“NY Office range”: - -Existing access list in ClickHouse Cloud - -### 可能的操作 {#possible-actions} - -1. 要添加额外条目,您可以使用 **+ Add new IP** - - 此示例添加了一个单一的 IP 地址,并带有 `London server` 的描述: - -Adding a single IP to the access list in ClickHouse Cloud - -2. 删除现有条目 - - 单击叉号 (x) 可以删除一个条目 - -3. 编辑现有条目 - - 直接修改条目 - -4. 切换到允许来自 **Anywhere** 的访问 - - 这并不推荐,但它是允许的。我们建议您将基于 ClickHouse 构建的应用程序公开,并限制对后端 ClickHouse Cloud 服务的访问。 - -要应用您所做的更改,您必须单击 **Save**。 - -## 验证 {#verification} - -一旦创建了过滤器,请确认在范围内的连通性,并确认来自允许范围之外的连接被拒绝。可以使用简单的 `curl` 命令来验证: -```bash title="Attempt rejected from outside the allow list" -curl https://.clickhouse.cloud:8443 -``` -```response -curl: (35) error:02FFF036:system library:func(4095):Connection reset by peer -``` -或 -```response -curl: (35) LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to HOSTNAME.clickhouse.cloud:8443 -``` - -```bash title="Attempt permitted from inside the allow list" -curl https://.clickhouse.cloud:8443 -``` -```response -Ok. -``` - -## 限制 {#limitations} - -- 目前,IP 访问列表仅支持 IPv4 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/setting-ip-filters.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/setting-ip-filters.md.hash deleted file mode 100644 index 37b2eebc271..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/setting-ip-filters.md.hash +++ /dev/null @@ -1 +0,0 @@ -040bfba2cae20130 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/shared-responsibility-model.md b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/shared-responsibility-model.md deleted file mode 100644 index 9c23d84a875..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/shared-responsibility-model.md +++ /dev/null @@ -1,109 +0,0 @@ ---- -'sidebar_label': '共享责任模型' -'slug': '/cloud/security/shared-responsibility-model' -'title': '安全共享责任模型' -'description': '了解有关ClickHouse Cloud的安全模型的更多信息' ---- - -## 服务类型 {#service-types} - -ClickHouse Cloud 提供三种服务类型:Basic、Scale 和 Enterprise。欲了解更多信息,请查看我们的 [服务类型](/cloud/manage/cloud-tiers) 页面。 - -## 云架构 {#cloud-architecture} - -云架构由控制平面和数据平面组成。控制平面负责组织创建、控制平面内用户管理、服务管理、API 密钥管理和账单。数据平面运行编排和管理的工具,并存放客户服务。欲了解更多信息,请查看我们的 [ClickHouse Cloud 架构](/cloud/reference/architecture) 图。 - -## BYOC 架构 {#byoc-architecture} - -自带云 (BYOC) 使客户能够在自己的云账户中运行数据平面。欲了解更多信息,请查看我们的 [(BYOC) 自带云](/cloud/reference/byoc) 页面。 - -## ClickHouse Cloud 共享责任模型 {#clickhouse-cloud-shared-responsibility-model} -下面的模型大致说明了 ClickHouse 的责任,并显示了 ClickHouse Cloud 和 ClickHouse BYOC 客户需要承担的责任。有关我们的 PCI 共享责任模型的更多信息,请下载我们 [信任中心](https://trust.clickhouse.com) 中提供的概述副本。 - -| 控制 | ClickHouse | 云客户 | BYOC 客户 | -|-----------------------------------------------------------------------|-------------------|---------------------|---------------------| -| 维护环境隔离 | :white_check_mark: | | :white_check_mark: | -| 管理网络设置 | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| 安全地管理对 ClickHouse 系统的访问 | :white_check_mark: | | | -| 安全地管理控制平面和数据库中的组织用户 | | :white_check_mark: | :white_check_mark: | -| 用户管理和审计 | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| 加密数据在传输和静止状态下 | :white_check_mark: | | | -| 安全地处理客户管理的加密密钥 | | :white_check_mark: | :white_check_mark: | -| 提供冗余基础设施 | :white_check_mark: | | :white_check_mark: | -| 备份数据 | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| 验证备份恢复能力 | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| 实施数据保留设置 | | :white_check_mark: | :white_check_mark: | -| 安全配置管理 | :white_check_mark: | | :white_check_mark: | -| 软件和基础设施漏洞修复 | :white_check_mark: | | | -| 执行渗透测试 | :white_check_mark: | | | -| 威胁检测与响应 | :white_check_mark: | | :white_check_mark: | -| 安全事件响应 | :white_check_mark: | | :white_check_mark: | - -## ClickHouse Cloud 可配置的安全功能 {#clickhouse-cloud-configurable-security-features} - -
- 网络连接 - - | 设置 | 状态 | 云 | 服务级别 | - |------------------------------------------------------------------------------------------------------|-----------|---------------------|---------------------| - | [IP 过滤器](/cloud/security/setting-ip-filters) 限制对服务的连接 | 可用 | AWS, GCP, Azure | 所有 | - | [私有链接](/cloud/security/private-link-overview) 安全连接到服务 | 可用 | AWS, GCP, Azure | Scale 或 Enterprise | - -
-
- 访问管理 - - - | 设置 | 状态 | 云 | 服务级别 | - |------------------------------------------------------------------------------------------------------|-----------|---------------------|---------------------| - | [标准基于角色的访问](/cloud/security/cloud-access-management) 在控制平面 | 可用 | AWS, GCP, Azure | 所有 | - | [多因素认证 (MFA)](/cloud/security/cloud-authentication#multi-factor-authentication) 可用 | 可用 | AWS, GCP, Azure | 所有 | - | [SAML 单点登录](/cloud/security/saml-setup) 可用于控制平面 | 预览 | AWS, GCP, Azure | Enterprise | - | 数据库中的细粒度 [基于角色的访问控制](/cloud/security/cloud-access-management/overview#database-permissions) | 可用 | AWS, GCP, Azure | 所有 | - -
-
- 数据安全 - - | 设置 | 状态 | 云 | 服务级别 | - |------------------------------------------------------------------------------------------------------|-----------|---------------------|---------------------| - | [云提供商和地区](/cloud/reference/supported-regions) 选择 | 可用 | AWS, GCP, Azure | 所有 | - | 有限的 [每日免费备份](/cloud/manage/backups/overview#default-backup-policy) | 可用 | AWS, GCP, Azure | 所有 | - | [自定义备份配置](/cloud/manage/backups/overview#configurable-backups) 可用 | 可用 | GCP, AWS, Azure | Scale 或 Enterprise | - | [客户管理的加密密钥 (CMEK)](/cloud/security/cmek) 透明
数据加密可用 | 可用 | AWS, GCP | Enterprise | - | [字段级加密](/sql-reference/functions/encryption-functions) 带有手动密钥管理的细粒度加密 | 可用 | GCP, AWS, Azure | 所有 | - - -
-
- 数据保留 - - | 设置 | 状态 | 云 | 服务级别 | - |------------------------------------------------------------------------------------------------------|-----------|---------------------|---------------------| - | [生存时间 (TTL)](/sql-reference/statements/alter/ttl) 设置管理保留 | 可用 | AWS, GCP, Azure | 所有 | - | [ALTER TABLE DELETE](/sql-reference/statements/alter/delete) 进行大量删除操作 | 可用 | AWS, GCP, Azure | 所有 | - | [轻量级 DELETE](/sql-reference/statements/delete) 用于有计划的删除活动 | 可用 | AWS, GCP, Azure | 所有 | - -
-
- 审计与日志记录 - - | 设置 | 状态 | 云 | 服务级别 | - |------------------------------------------------------------------------------------------------------|-----------|---------------------|---------------------| - | [审计日志](/cloud/security/audit-logging) 控制平面活动 | 可用 | AWS, GCP, Azure | 所有 | - | [会话日志](/operations/system-tables/session_log) 数据库活动 | 可用 | AWS, GCP, Azure | 所有 | - | [查询日志](/operations/system-tables/query_log) 数据库活动 | 可用 | AWS, GCP, Azure | 所有 | - -
- -## ClickHouse Cloud 合规性 {#clickhouse-cloud-compliance} - - | 框架 | 状态 | 云 | 服务级别 | - |------------------------------------------------------------------------------------------------------|-----------|---------------------|---------------------| - | ISO 27001 合规性 | 可用 | AWS, GCP, Azure | 所有 | - | SOC 2 类型 II 合规性 | 可用 | AWS, GCP, Azure | 所有 | - | GDPR 和 CCPA 合规性 | 可用 | AWS, GCP, Azure | 所有 | - | HIPAA 合规性 | 可用 | AWS, GCP | Enterprise | - | PCI 合规性 | 可用 | AWS | Enterprise | - - 关于支持的合规框架的更多信息,请查看我们的 [安全与合规](/cloud/security/security-and-compliance) 页面。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/shared-responsibility-model.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/shared-responsibility-model.md.hash deleted file mode 100644 index ed391022165..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/security/shared-responsibility-model.md.hash +++ /dev/null @@ -1 +0,0 @@ -e5dce4c2f9cd4b61 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/support.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/cloud/support.md.hash deleted file mode 100644 index 2f250785b47..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/cloud/support.md.hash +++ /dev/null @@ -1 +0,0 @@ -92402ef81da4e7c5 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/concepts/glossary.md b/i18n/zh/docusaurus-plugin-content-docs/current/concepts/glossary.md index 75d4ba45fbf..644867085f3 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/concepts/glossary.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/concepts/glossary.md @@ -1,37 +1,113 @@ --- -'sidebar_label': '词汇表' -'description': '此页面包含有关 ClickHouse 的常用词汇和短语的列表,以及它们的定义。' -'title': '词汇表' +'sidebar_label': '术语表' +'description': '此页面包含关于 ClickHouse 的常用词汇和短语及其定义的列表。' +'title': '术语表' 'slug': '/concepts/glossary' +'doc_type': 'reference' --- -# 术语表 + + + +# 词汇表 ## 原子性 {#atomicity} -原子性确保事务(系列数据库操作)被视为一个单独的、不可分割的单位。这意味着交易中的所有操作要么全部发生,要么都不发生。一个原子交易的例子是将资金从一个银行账户转移到另一个账户。如果转账的任一步骤失败,交易失败,资金将保留在第一个账户中。原子性确保没有资金丢失或创建。 +原子性确保一个事务(数据库操作系列)被视为一个单独且不可分割的单元。这意味着事务内的所有操作要么全部执行,要么都不执行。原子事务的一个例子是将资金从一个银行账户转移到另一个账户。如果转账的任何一步失败,则事务失败,资金仍停留在第一个账户中。原子性确保没有资金丢失或产生。 + +## 块 {#block} + +块是组织数据处理和存储的逻辑单元。每个块包含列式数据,这些数据一起处理以提高查询执行的性能。通过以块的形式处理数据,ClickHouse有效利用CPU核心,最小化缓存未命中,并促进矢量化执行。ClickHouse使用多种压缩算法,如LZ4、ZSTD和Delta,以压缩块中的数据。 ## 集群 {#cluster} -一组协同工作以存储和处理数据的节点(服务器)。 +一组节点(服务器),共同存储和处理数据。 -## 客户管理的加密密钥 {#cmek} +## 客户自管理加密密钥 {#cmek} -客户管理的加密密钥(CMEK)允许客户使用其密钥管理服务(KMS)密钥来加密ClickHouse磁盘数据密钥,并保护其静态数据。 +客户自管理加密密钥(CMEK)允许客户使用其密钥管理服务(KMS)密钥来加密ClickHouse磁盘数据密钥并保护其静态数据。 ## 字典 {#dictionary} -字典是键值对的映射,对于各种类型的参考列表非常有用。它是一个强大的特性,允许在查询中高效使用字典,这通常比使用 `JOIN` 参考表更高效。 +字典是键值对的映射,对于各种类型的参考列表非常有用。这是一个强大的功能,允许在查询中有效使用字典,这通常比使用带有参考表的 `JOIN` 更高效。 + +## 分布式表 {#distributed-table} + +ClickHouse中的分布式表是一种特殊类型的表,它不存储数据本身,而是为集群中多个服务器的分布式查询处理提供统一视图。 + +## 粒度 {#granule} + +粒度是未压缩块中的一批行。在读取数据时,ClickHouse访问粒度,而不是单个行,这使得在分析负载中实现更快的数据处理。默认情况下,一个粒度包含8192行。主索引每个粒度包含一个条目。 + +## 增量物化视图 {#incremental-materialized-view} + +在ClickHouse中,是一种在插入时处理和聚合数据的物化视图。当新数据插入到源表中时,物化视图只对新插入的块执行预定义的SQL聚合查询,并将聚合结果写入目标表。 + +## 轻量级更新 {#lightweight-update} + +在ClickHouse中,轻量级更新是一种实验性功能,允许您使用标准SQL UPDATE语法更新表中的行,但不是重写整个列或数据部分(如传统突变),而是创建仅包含更新列和行的“补丁部分”。这些更新通过补丁应用在SELECT查询中立即可见,但物理数据仅在随后的合并期间更新。 + +## 物化视图 {#materialized-view} + +在ClickHouse中,物化视图是一种机制,会在数据插入源表时自动运行查询,并将转换或聚合的结果存储在单独的目标表中,以加快查询速度。 + +## MergeTree {#mergetree} + +在ClickHouse中,MergeTree是一种旨在支持高数据摄取率和大量数据的表引擎。它是ClickHouse的核心存储引擎,提供列式存储、自定义分区、稀疏主索引以及背景数据合并等功能。 + +## 突变 {#mutation} + +在ClickHouse中,突变是指修改或删除表中现有数据的操作,通常使用命令如ALTER TABLE ... UPDATE或ALTER TABLE ... DELETE。突变实现为异步后台处理进程,这些进程重写受到更改影响的整个数据部分,而不是就地修改行。 + +## 即时突变 {#on-the-fly-mutation} -## 分区片段 {#parts} +在ClickHouse中,即时突变是一种机制,允许在提交突变后,更新或删除在随后的SELECT查询中立即可见,而无需等待后台突变进程完成。 -存储表数据部分的磁盘上的物理文件。这不同于分区,后者是使用分区键创建的表数据的逻辑划分。 +## 部件 {#parts} + +磁盘上的物理文件,存储表数据的一部分。这与分区不同,后者是使用分区键创建的表数据的逻辑划分。 + +## 分区键 {#partitioning-key} + +在ClickHouse中,分区键是在创建表时在PARTITION BY子句中定义的SQL表达式。它决定了数据在磁盘上如何逻辑分组为分区。每个唯一的分区键值形成其自己的物理分区,从而允许高效的数据管理操作,如删除、移动或归档整个分区。 + +## 主键 {#primary-key} + +在ClickHouse中,主键确定数据在磁盘上的存储顺序,并用于构造加速查询过滤的稀疏索引。与传统数据库不同,ClickHouse中的主键不强制唯一性——多行可以具有相同的主键值。 + +## 投影 {#projection} + +在ClickHouse中,投影是一个隐藏的、自动维护的表,以不同的顺序存储数据或进行预计算聚合,以加快查询速度,特别是那些过滤不在主主键中的列的查询。 + +## 可刷新的物化视图 {#refreshable-materialized-view} + +可刷新的物化视图是一种物化视图,定期在完整数据集上重新执行其查询,并将结果存储在目标表中。与增量物化视图不同,可刷新的物化视图按计划更新,可以支持复杂查询,包括JOIN和UNION,无限制。 ## 副本 {#replica} -存储在ClickHouse数据库中的数据的副本。您可以拥有任何数量的相同数据的副本,以实现冗余和可靠性。副本与ReplicatedMergeTree表引擎一起使用,使ClickHouse能够在不同的服务器之间保持多个数据副本的同步。 +存储在ClickHouse数据库中的数据副本。您可以拥有相同数据的任意数量的副本,以实现冗余和可靠性。副本与ReplicatedMergeTree表引擎一起使用,使ClickHouse能够在不同服务器之间保持多份数据的同步。 ## 分片 {#shard} -数据的一个子集。ClickHouse始终至少为您的数据提供一个分片。如果您不将数据分割到多个服务器上,您的数据将存储在一个分片中。将数据分片到多个服务器上可以在超过单个服务器的容量时分担负载。 +数据的一个子集。ClickHouse始终为您的数据至少有一个分片。如果您没有在多个服务器之间拆分数据,则数据将存储在一个分片中。在多个服务器之间分片数据可以用来分配负载,如果您超出了单个服务器的容量。 + +## 跳过索引 {#skipping-index} + +跳过索引用于在多个连续粒度级别存储少量元数据,这使得ClickHouse能够避免扫描不相关的行。跳过索引为投影提供了一种轻量级替代方案。 + +## 排序键 {#sorting-key} + +在ClickHouse中,排序键定义了磁盘上行的物理顺序。如果您不指定主键,ClickHouse将使用排序键作为主键。如果您同时指定了两者,则主键必须是排序键的前缀。 + +## 稀疏索引 {#sparse-index} + +一种索引类型,其中主索引包含一组行的一个条目,而不是单个行。与行组对应的条目称为标记。使用稀疏索引,ClickHouse首先识别可能与查询匹配的行组,然后单独处理它们以找到匹配的结果。因此,主索引足够小,可以加载到内存中。 + +## 表引擎 {#table-engine} + +ClickHouse中的表引擎确定数据的写入、存储和访问方式。MergeTree是最常见的表引擎,允许快速插入大量数据,这些数据会在后台进行处理。 + +## 生存时间 (TTL) {#ttl} + +生存时间(TTL)是ClickHouse的一项功能,允许在特定时间段后自动移动、删除或合并列或行。这使您可以更有效地管理存储,因为您可以删除、移动或归档不再需要频繁访问的数据。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/concepts/glossary.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/concepts/glossary.md.hash index ed775b1fd6b..f17378cb19e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/concepts/glossary.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/concepts/glossary.md.hash @@ -1 +1 @@ -da2b7d0613356ba7 +d149bc9b7bd5a69a diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/concepts/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/concepts/index.md index 1b98f336db2..d538428570e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/concepts/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/concepts/index.md @@ -8,14 +8,15 @@ - 'concepts' - 'OLAP' - 'fast' +'doc_type': 'landing-page' --- -在本节文档中,我们将深入探讨使 ClickHouse 如此快速和高效的概念。 +在本节文档中,我们将深入探讨使 ClickHouse 快速高效的概念。 -| 页面 | 描述 | -|------------------------------------------------------------------|--------------------------------------------------------------------------------------| -| [为什么 ClickHouse 如此快速?](./why-clickhouse-is-so-fast.md) | 了解是什么让 ClickHouse 如此快速。 | -| [什么是 OLAP?](./olap.md) | 了解什么是在线分析处理(Online Analytical Processing)。 | -| [为什么 ClickHouse 独特?](../about-us/distinctive-features.md) | 了解是什么让 ClickHouse 独特。 | -| [词汇表](./glossary.md) | 本页面包含您在文档中常遇到的术语的词汇表。 | -| [常见问题](../faq/index.md) | 收集了我们关于 ClickHouse 最常见的一些问题。 | +| 页面 | 描述 | +|------------------------------------------------------------------|----------------------------------------------------------------------------------------| +| [为什么 ClickHouse 如此快速?](./why-clickhouse-is-so-fast.mdx) | 了解是什么让 ClickHouse 如此快速。 | +| [什么是 OLAP?](./olap.md) | 了解什么是在线分析处理(Online Analytical Processing)。 | +| [为什么 ClickHouse 独特?](../about-us/distinctive-features.md) | 了解是什么让 ClickHouse 独一无二。 | +| [术语表](./glossary.md) | 此页面包含您在文档中常见的术语的术语表。 | +| [常见问题解答](../faq/index.md) | 对我们关于 ClickHouse 的最常见问题的汇编。 | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/concepts/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/concepts/index.md.hash index 16f99b8153b..813f81d06fb 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/concepts/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/concepts/index.md.hash @@ -1 +1 @@ -3c3ef25bd1898a9a +e7e9dd0b8988db2b diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/concepts/olap.md b/i18n/zh/docusaurus-plugin-content-docs/current/concepts/olap.md index 0702f209b87..515485b673e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/concepts/olap.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/concepts/olap.md @@ -6,36 +6,37 @@ 'slug': '/concepts/olap' 'keywords': - 'OLAP' +'doc_type': 'reference' --- # 什么是OLAP? -[OLAP](https://en.wikipedia.org/wiki/Online_analytical_processing) 代表联机分析处理(Online Analytical Processing)。这是一个广泛的术语,可以从技术和商业两个方面进行理解。在最高层次,你可以反向阅读这些词: +[OLAP](https://en.wikipedia.org/wiki/Online_analytical_processing) 是在线分析处理 (Online Analytical Processing) 的缩写。它是一个广泛的术语,可以从技术和商业两个角度来看待。在最高层面上,你可以将这些词反向阅读: -**处理** 一些源数据被处理… +**处理** — 一些源数据被处理… -**分析** …以生成一些分析报告和见解… +**分析** — …以生成一些分析报告和见解… -**在线** …实时进行。 +**在线** — …实时进行。 ## 从商业角度看OLAP {#olap-from-the-business-perspective} -近年来,商业人士开始意识到数据的价值。盲目做决定的公司往往无法跟上竞争对手的步伐。成功公司的数据驱动方法迫使它们收集所有可能对商业决策有用的数据,并对其施加了对及时分析这些数据机制的需求。这就是OLAP数据库管理系统(DBMS)发挥作用的地方。 +近年来,商业人士开始意识到数据的价值。那些盲目做决策的公司往往无法跟上竞争的步伐。成功公司的数据驱动方法迫使他们收集所有可能对商业决策有用的数据,并要求他们具备及时分析这些数据的机制。这正是OLAP数据库管理系统 (DBMS) 介入的地方。 -从商业角度看,OLAP允许公司持续规划、分析和报告运营活动,从而最大化效率、降低开支,并最终征服市场份额。这可以在内部系统中完成,也可以外包给SaaS提供商,如Web/移动分析服务、CRM服务等。OLAP是许多BI应用(商业智能)背后的技术。 +从商业的角度来看,OLAP允许公司持续规划、分析和报告运营活动,从而最大化效率、降低开支,最终征服市场份额。这可以在内部系统中完成,也可以外包给像网页/移动分析服务、CRM服务等SaaS提供商。OLAP是许多BI(商业智能)应用程序背后的技术。 -ClickHouse是一个OLAP数据库管理系统,常用作分析特定领域数据的SaaS解决方案的后端。然而,一些企业仍然不愿意与第三方提供商分享其数据,因此内部数据仓库方案也是可行的。 +ClickHouse是一种OLAP数据库管理系统,通常被用作分析特定领域数据的SaaS解决方案的后台。然而,一些企业仍然不愿意与第三方提供商共享数据,因此内部数据仓库的场景也是可行的。 ## 从技术角度看OLAP {#olap-from-the-technical-perspective} -所有数据库管理系统可以分为两类:OLAP(联机 **分析** 处理)和OLTP(联机 **事务** 处理)。前者专注于构建报告,每个报告基于大量历史数据,但频率较低。后者通常处理持续的事务流,不断修改当前的数据状态。 +所有数据库管理系统可以分为两组:OLAP(在线**分析**处理)和OLTP(在线**事务**处理)。前者专注于构建每个基于大量历史数据的报告,但执行频率较低。后者通常处理源源不断的事务,不断修改数据的当前状态。 -在实践中,OLAP和OLTP并不被视为二元分类,而是更像一个光谱。大多数实际系统通常专注于其中一种,但如果还需要相反类型的工作负载,则提供了一些解决方案或变通方法。这种情况通常迫使企业运营多个集成的存储系统。这可能不是大问题,但拥有更多系统会增加维护成本,因此近年来的趋势是向HTAP(**混合事务/分析处理**)发展,即单一数据库管理系统能够同样良好地处理这两种类型的工作负载。 +在实践中,OLAP和OLTP并不被视为二元类别,而更像是一个光谱。大多数真实系统通常专注于其中之一,但如果需要相反类型的工作负载,它们也提供一些解决方案或变通办法。这种情况常常迫使企业运行多个集成的存储系统。这可能没有太大的问题,但拥有更多系统会增加维护成本,因此近年来的趋势是HTAP(**混合事务/分析处理**),即单一数据库管理系统能够同样良好地处理两种类型的工作负载。 -即使一个DBMS最初作为纯OLAP或纯OLTP开始,它也被迫朝HTAP方向发展以跟上竞争。ClickHouse也不例外。最初,它被设计为一个 [尽可能快速的OLAP系统](/concepts/why-clickhouse-is-so-fast),但仍然没有全面的事务支持,但已经添加了一些功能,如一致的读/写和更新/删除数据的变更。 +即使一个DBMS最初作为纯OLAP或纯OLTP起步,它也被迫朝HTAP方向发展以跟上竞争。ClickHouse也不例外。最初,它被设计为一个[尽可能快速的OLAP系统](/concepts/why-clickhouse-is-so-fast),尽管它仍然没有完整的事务支持,但已经添加了一些功能,例如一致的读/写和用于更新/删除数据的变更。 -OLAP和OLTP系统之间的根本权衡仍然存在: +OLAP和OLTP系统之间的基本权衡仍然是: -- 要有效构建分析报告,能够单独读取列是至关重要的,因此大多数OLAP数据库是 [列式](https://clickhouse.com/engineering-resources/what-is-columnar-database) 的, -- 而单独存储列则会增加对行的操作成本,如追加或就地修改,成比例地与列数(如果系统试图收集所有事件细节以防万一,这个数字可能会很大)相关。因此,大多数OLTP系统按行存储数据。 +- 要高效地构建分析报告,能够单独读取列至关重要,因此大多数OLAP数据库是[列式](https://clickhouse.com/engineering-resources/what-is-columnar-database)的; +- 而将列单独存储会增加对行的操作成本,如追加或就地修改,这与列的数量成正比(如果系统尝试收集所有事件的详细信息以防万一,这个数量可能会非常庞大)。因此,大多数OLTP系统按行存储数据。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/concepts/olap.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/concepts/olap.md.hash index ef45981cf91..f835867da4c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/concepts/olap.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/concepts/olap.md.hash @@ -1 +1 @@ -39ada86b2814b5ea +6528f1d8769f82c9 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/concepts/why-clickhouse-is-so-fast.md b/i18n/zh/docusaurus-plugin-content-docs/current/concepts/why-clickhouse-is-so-fast.md deleted file mode 100644 index 2a3caa8cb1e..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/concepts/why-clickhouse-is-so-fast.md +++ /dev/null @@ -1,147 +0,0 @@ ---- -'sidebar_position': 1 -'sidebar_label': '为什么 ClickHouse 如此快速?' -'description': '它被设计为快速。查询执行性能一直是开发过程中的首要任务,但其他重要特性如用户友好性、可扩展性和安全性也得到了考虑,以便 ClickHouse - 能够成为一个真正的生产系统。' -'title': '为什么 ClickHouse 如此快速?' -'slug': '/concepts/why-clickhouse-is-so-fast' -'keywords': -- 'Architecture' -- 'VLDB' -- 'Performance' -'show_related_blogs': true ---- - - -# 为什么 ClickHouse 这么快? {#why-clickhouse-is-so-fast} - -除了 [数据方向](/intro#row-oriented-vs-column-oriented-storage) 之外,还有许多其他因素影响数据库的性能。接下来,我们将详细解释为什么 ClickHouse 这么快,尤其是与其他列式数据库相比。 - -从架构的角度来看,数据库至少由一个存储层和一个查询处理层组成。存储层负责保存、加载和维护表数据,而查询处理层执行用户查询。与其他数据库相比,ClickHouse 在这两个层面上提供了创新,使得插入和查询的速度极快。 - -## 存储层:并发插入彼此隔离 {#storage-layer-concurrent-inserts-are-isolated} - - - -在 ClickHouse 中,每个表由多个“表部分”组成。每当用户向表中插入数据(INSERT 语句)时,就会创建一个 [部分](/parts)。查询始终是针对查询开始时存在的所有表部分执行的。 - -为了避免过多的部分积累,ClickHouse 在后台运行 [合并](/merges) 操作,持续将多个较小的部分合并成一个更大的部分。 - -这种方法有几个优点:所有数据处理可以 [卸载到后台部分合并](/concepts/why-clickhouse-is-so-fast#storage-layer-merge-time-computation),保持数据写入轻量且高效。单个插入是“本地”的,因为它们不需要更新全局的,即每个表的数据结构。因此,多个并发插入无需相互同步或与现有表数据同步,因此插入可以几乎以磁盘 I/O 的速度进行。 - -在 VLDB 论文的整体性能优化部分。 - -🤿 深入了解这一点,请参见我们 VLDB 2024 论文的 [On-Disk Format](/docs/academic_overview#3-1-on-disk-format) 部分,网页版。 - -## 存储层:并发插入和选择是隔离的 {#storage-layer-concurrent-inserts-and-selects-are-isolated} - - - -插入与 SELECT 查询完全隔离,合并插入的数据部分发生在后台,而不会影响并发查询。 - -🤿 深入了解这一点,请参见我们 VLDB 2024 论文的 [Storage Layer](/docs/academic_overview#3-storage-layer) 部分,网页版。 - -## 存储层:合并时间计算 {#storage-layer-merge-time-computation} - - - -与其他数据库不同,ClickHouse 通过在 [合并](/merges) 背景过程中执行所有额外的数据转换,从而保持数据写入轻量且高效。这些转换的示例包括: - -- **替换合并** ,保留输入部分中行的最新版本并丢弃所有其他版本。替换合并可以被视为合并时的清理操作。 - -- **聚合合并** ,将输入部分中的中间聚合状态合并为新的聚合状态。虽然这看起来难以理解,但实际上只实现了增量聚合。 - -- **TTL(生存时间)合并** ,根据某些基于时间的规则压缩、移动或删除行。 - -这些转换的目的是将工作(计算)从用户查询运行时转移到合并时间。这一点重要,原因有二: - -一方面,如果用户查询能够利用“转化”数据,例如预聚合数据,可能会显著加快用户查询,有时加速高达 1000 倍或更多。 - -另一方面,合并的大部分运行时间消耗在加载输入部分和保存输出部分上。在合并期间转换数据的额外工作通常不会对合并的运行时间产生太大影响。所有这些魔法都是完全透明的,不会影响查询的结果(除了它们的性能)。 - -🤿 深入了解这一点,请参见我们 VLDB 2024 论文的 [Merge-time Data Transformation](/docs/academic_overview#3-3-merge-time-data-transformation) 部分,网页版。 - -## 存储层:数据修剪 {#storage-layer-data-pruning} - - - -在实践中,许多查询是重复的,即在定期间隔内以不变或仅轻微修改(例如不同的参数值)运行。一次又一次运行相同或相似的查询允许添加索引或以某种方式重新组织数据,使得频繁查询可以更快地访问。这种方法也称为“数据修剪”,而 ClickHouse 提供三种技术来实现这一点: - -1. [主键索引](/guides/best-practices/sparse-primary-indexes#clickhouse-index-design) 定义表数据的排序顺序。精心选择的主键允许使用快速的二进制搜索评估过滤器(如上述查询中的 WHERE 子句),而不是进行全列扫描。在更技术上,扫描的运行时间随着数据大小的增加而变为对数而不是线性。 - -2. [表投影](/sql-reference/statements/alter/projection) 作为表的替代内部版本,存储相同的数据但按不同的主键排序。当存在多个频繁的过滤条件时,投影可能会很有用。 - -3. [跳过索引](/optimize/skipping-indexes) 将附加的数据统计信息嵌入到列中,例如最小和最大列值、唯一值集合等。跳过索引与主键和表投影是正交的,具体速度会因列中数据分布而异,它们可以大大加速过滤条件的评估。 - -这三种技术都旨在尽可能跳过全列读取期间的行,因为读取数据的最快方法是不读取它。 - -🤿 深入了解这一点,请参见我们 VLDB 2024 论文的 [Data Pruning](/docs/academic_overview#3-2-data-pruning) 部分,网页版。 - -## 存储层:数据压缩 {#storage-layer-data-compression} - - - -除此之外,ClickHouse 的存储层还额外(可选地)使用不同的编解码器压缩原始表数据。 - -列存储特别适合这种压缩,因为相同类型和数据分布的值位于一起。 - -用户可以 [指定](https://clickhouse.com/blog/optimize-clickhouse-codecs-compression-schema) 列使用各种通用压缩算法(如 ZSTD)或专用编解码器进行压缩,例如用于浮点值的 Gorilla 和 FPC,或用于整数值的 Delta 和 GCD,甚至 AES 作为加密编解码器。 - -数据压缩不仅减少了数据库表的存储大小,而且在许多情况下,查询性能也得到了提升,因为本地磁盘和网络 I/O 通常受到低吞吐量的限制。 - -🤿 深入了解这一点,请参见我们 VLDB 2024 论文的 [On-Disk Format](/docs/academic_overview#3-1-on-disk-format) 部分,网页版。 - -## 尖端查询处理层 {#state-of-the-art-query-processing-layer} - - - -最后,ClickHouse 使用矢量化查询处理层,尽可能并行化查询执行,以最大限度地利用所有资源,实现最大速度和效率。 - -“矢量化”意味着查询计划操作符以批处理的方式传递中间结果行,而不是单行。这导致了 CPU 缓存的更好利用,并允许操作符应用 SIMD 指令一次处理多个值。实际上,许多操作符有多个版本——每个 SIMD 指令集世代一个。ClickHouse 会根据运行的硬件能力自动选择最新、最快的版本。 - -现代系统具有数十个 CPU 核心。为了充分利用所有核心,ClickHouse 将查询计划展开为多个通道,通常每个核心一个。每个通道处理表数据的一个不重叠范围。这样,数据库的性能随着可用核心的数量“垂直”扩展。 - -如果单个节点变得太小,无法容纳表数据,可以添加更多节点以形成集群。表可以被拆分(“分片”)并分布到各个节点。ClickHouse 将在所有存储表数据的节点上运行查询,从而与可用节点的数量“横向”扩展。 - -🤿 深入了解这一点,请参见我们 VLDB 2024 论文的 [Query Processing Layer](/academic_overview#4-query-processing-layer) 部分,网页版。 - -## 细致入微的关注细节 {#meticulous-attention-to-detail} - - - -> **“ClickHouse 是一个怪异的系统 - 你们有 20 个哈希表的版本。你们有这些令人惊叹的东西,而大多数系统只有一个哈希表... ClickHouse 之所以具有这种惊人的性能,是因为它有这么多专业化的组件。”** [Andy Pavlo, 卡内基梅隆大学数据库教授](https://www.youtube.com/watch?v=Vy2t_wZx4Is&t=3579s) - -ClickHouse 的不同之处在于其对低级优化的细致入微关注。构建一个仅能正常工作的数据库是一回事,但设计一个能在多种查询类型、数据结构、分布和索引配置下提供速度的数据库则是 “[怪异系统](https://youtu.be/Vy2t_wZx4Is?si=K7MyzsBBxgmGcuGU&t=3579)” 艺术的闪光点。 - -**哈希表。** 以哈希表为例。哈希表是连接和聚合使用的中心数据结构。作为程序员,需要考虑这些设计决策: - -* 选择哈希函数, -* 碰撞解决方案:[开放地址法](https://en.wikipedia.org/wiki/Open_addressing) 或 [链式法](https://en.wikipedia.org/wiki/Hash_table#Separate_chaining), -* 内存布局:一个数组用于键和值还是分开的数组? -* 填充因子:何时以及如何调整大小?在调整大小时如何移动值? -* 删除:哈希表是否允许驱逐条目? - -由第三方库提供的标准哈希表在功能上可以工作,但速度并不快。优异的性能需要细致的基准测试和实验。 - -[ClickHouse 中的哈希表实现](https://clickhouse.com/blog/hash-tables-in-clickhouse-and-zero-cost-abstractions) 根据查询和数据的具体情况选择 **30 多个预编译哈希表变体** 中的一个。 - -**算法。** 算法也同样如此。例如,在排序时,您可能要考虑: - -* 要排序的内容:数字、元组、字符串或结构? -* 数据是否在 RAM 中? -* 排序是否需要稳定? -* 所有数据都必须排序还是部分排序就可以? - -依赖数据特征的算法通常比它们的通用对应算法表现更佳。如果事先不知道数据特征,系统可以尝试各种实现,并在运行时选择效果最佳的实现。有关示例,请参见 [关于 ClickHouse 中 LZ4 解压缩实现的文章](https://habr.com/en/company/yandex/blog/457612/)。 - -🤿 深入了解这一点,请参见我们 VLDB 2024 论文的 [Holistic Performance Optimization](/academic_overview#4-4-holistic-performance-optimization) 部分,网页版。 - -## VLDB 2024 论文 {#vldb-2024-paper} - -在 2024 年 8 月,我们的第一篇研究论文被 VLDB 会议接受并发表。 VLDB 是一个关于超大规模数据库的国际会议,被广泛认为是数据管理领域的领先会议之一。在数百份投稿中,VLDB 通常具有约 20% 的录用率。 - -您可以阅读这篇 [论文 PDF](https://www.vldb.org/pvldb/vol17/p3731-schulze.pdf) 或我们的 [网页版](/docs/academic_overview),其中简要描述了 ClickHouse 的一些最有趣的架构和系统设计组件,使其如此快速。 - -我们的首席技术官、ClickHouse 的创建者 Alexey Milovidov 现场演示了论文(幻灯片 [在这里](https://raw.githubusercontent.com/ClickHouse/clickhouse-presentations/master/2024-vldb/VLDB_2024_presentation.pdf)),随后进行了问答(很快就没有时间了!)。您可以在这里观看录制的演示: - - diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/concepts/why-clickhouse-is-so-fast.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/concepts/why-clickhouse-is-so-fast.md.hash deleted file mode 100644 index 7fc273e93a3..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/concepts/why-clickhouse-is-so-fast.md.hash +++ /dev/null @@ -1 +0,0 @@ -c69594f38d458a12 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/concepts/why-clickhouse-is-so-fast.mdx b/i18n/zh/docusaurus-plugin-content-docs/current/concepts/why-clickhouse-is-so-fast.mdx new file mode 100644 index 00000000000..5e6972189bf --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/concepts/why-clickhouse-is-so-fast.mdx @@ -0,0 +1,148 @@ +--- +'sidebar_position': 1 +'sidebar_label': '为什么 ClickHouse 这么快?' +'description': '它的设计旨在快速。查询执行性能在开发过程中始终是首要任务,但其他重要特性,如用户友好性、可扩展性和安全性,也被考虑在内,以便 ClickHouse + 能够成为一个真正的生产系统。' +'title': '为什么 ClickHouse 这么快?' +'slug': '/concepts/why-clickhouse-is-so-fast' +'keywords': +- 'Architecture' +- 'VLDB' +- 'Performance' +'show_related_blogs': true +'doc_type': 'guide' +--- + + +# 为什么 ClickHouse 这么快? {#why-clickhouse-is-so-fast} + +除了[数据方向](/intro#row-oriented-vs-column-oriented-storage),还有许多其他因素影响数据库的性能。接下来我们将更详细地解释是什么让 ClickHouse 如此快速,特别是与其他列式数据库相比。 + +从架构的角度来看,数据库至少由存储层和查询处理层组成。存储层负责保存、加载和维护表数据,而查询处理层执行用户查询。与其他数据库相比,ClickHouse 在这两个层面提供了创新,使得插入和 Select 查询非常快速。 + +## 存储层:并发插入相互隔离 {#storage-layer-concurrent-inserts-are-isolated} + + + +在 ClickHouse 中,每个表由多个“表片段”组成。用户插入数据时(INSERT 语句),就会创建一个[片段](/parts)。查询始终在查询开始时存在的所有表片段上执行。 + +为了避免太多片段的积累,ClickHouse 在后台运行[合并](/merges)操作,持续将多个较小的片段合并为一个较大的片段。 + +这种方法有几个优点:所有数据处理可以[卸载到后台片段合并](/concepts/why-clickhouse-is-so-fast#storage-layer-merge-time-computation),保持数据写入轻量且高效。单个插入在某种意义上是“本地的”,因为它们不需要更新全局的、即每个表的数据结构。因此,多次同时插入无需彼此同步或与现有表数据同步,因此插入几乎可以以磁盘 I/O 的速度执行。 + +关于 VLDB 论文的整体性能优化部分。 + +🤿 深入了解 [磁盘格式](/docs/academic_overview#3-1-on-disk-format) 部分,具体请参见我们 VLDB 2024 论文的网络版本。 + +## 存储层:并发插入和选择相互隔离 {#storage-layer-concurrent-inserts-and-selects-are-isolated} + + + +插入完全与 SELECT 查询隔离,插入的数据片段的合并在后台进行,而不影响并发查询。 + +🤿 深入了解 [存储层](/docs/academic_overview#3-storage-layer) 部分,具体请参见我们 VLDB 2024 论文的网络版本。 + +## 存储层:合并时间计算 {#storage-layer-merge-time-computation} + + + +与其他数据库不同,ClickHouse 通过在[合并](/merges)后台过程中执行所有附加数据转换,保持数据写入轻量和高效。这些转换的例子包括: + +- **替换合并**,仅保留输入部分中行的最新版本,丢弃所有其他行版本。替换合并可视为合并时清理操作。 + +- **聚合合并**,将输入部分中的中间聚合状态组合成新的聚合状态。尽管这看似难以理解,实际上仅仅是实现递增聚合。 + +- **生存时间 (TTL) 合并**,根据某些基于时间的规则压缩、移动或删除行。 + +这些转换的重点是在用户查询运行时将计算工作转移到合并时间。这一点重要的原因有两个: + +一方面,如果用户查询能够利用“转化过”的数据,例如预聚合的数据,查询运行时间可能会显著加快,有时甚至加快 1000 倍或更多。 + +另一方面,大多数合并的运行时间被加载输入片段和保存输出片段所消耗。在合并过程中转换数据的额外工作通常不会对合并的运行时间产生太大影响。所有这些魔法都是完全透明的,不影响查询结果(除了性能)。 + +🤿 深入了解 [合并时间数据转换](/docs/academic_overview#3-3-merge-time-data-transformation) 部分,具体请参见我们 VLDB 2024 论文的网络版本。 + +## 存储层:数据修剪 {#storage-layer-data-pruning} + + + +在实践中,许多查询是重复的,即在周期性间隔内以不变或仅轻微修改的方式运行(例如,参数值不同)。一次又一次地运行相同或相似的查询允许添加索引或以某种方式重新组织数据,以便频繁查询能够更快地访问。这种方法也被称为“数据修剪”,ClickHouse 提供了三种技术来实现这一点: + +1. [主键索引](/guides/best-practices/sparse-primary-indexes#clickhouse-index-design),定义表数据的排序顺序。一个良好选择的主键可以利用快速的二分搜索评估过滤器(如上述查询中的 WHERE 子句),而不需要全列扫描。从更技术的角度看,扫描的运行时间变为相对于数据大小的对数而不是线性。 + +2. [表投影](/sql-reference/statements/alter/projection),作为表的替代内部版本,存储相同的数据但按不同的主键排序。当频繁有多个过滤条件时,投影非常有用。 + +3. [跳过索引](/optimize/skipping-indexes),将额外的数据统计信息嵌入到列中,例如最小和最大列值、唯一值集合等。跳过索引与主键和表投影是正交的,根据列中的数据分布,它们可以大大加快过滤器的评估速度。 + +这三种技术的目标是在全列读取中尽可能跳过尽量多的行,因为读取数据的最快方式是根本不读取它。 + +🤿 深入了解 [数据修剪](/docs/academic_overview#3-2-data-pruning) 部分,具体请参见我们 VLDB 2024 论文的网络版本。 + +## 存储层:数据压缩 {#storage-layer-data-compression} + + + +除此之外,ClickHouse 的存储层还(可选地)使用不同的编解码器压缩原始表数据。 + +列存储特别适合此类压缩,因为相同类型和数据分布的值集中在一起。 + +用户可以[指定](https://clickhouse.com/blog/optimize-clickhouse-codecs-compression-schema),将列使用各种通用压缩算法(如 ZSTD)或专门的编解码器进行压缩,例如 Gorill 和 FPC 用于浮点值,Delta 和 GCD 用于整数值,甚至 AES 作为加密编解码器。 + +数据压缩不仅减少了数据库表的存储大小,而且在许多情况下,它还改善了查询性能,因为本地磁盘和网络 I/O 通常受到低吞吐量的限制。 + +🤿 深入了解 [磁盘格式](/docs/academic_overview#3-1-on-disk-format) 部分,具体请参见我们 VLDB 2024 论文的网络版本。 + +## 最先进的查询处理层 {#state-of-the-art-query-processing-layer} + + + +最后,ClickHouse 使用向量化查询处理层,尽可能地并行化查询执行,以利用所有资源以获得最大的速度和效率。 + +“向量化”的意思是查询计划运算符以批量的方式传递中间结果行,而不是逐行传递。这不仅导致更好的 CPU 缓存利用率,还允许运算符使用 SIMD 指令同时处理多个值。事实上,许多运算符都有多个版本-每个 SIMD 指令集生成一个。ClickHouse 将根据其运行的硬件能力自动选择最近且最快的版本。 + +现代系统有数十个 CPU 核心。为了利用所有核心,ClickHouse 将查询计划展开为多个处理通道,通常为每个核心一个。每个通道处理表数据的一个不重叠范围。这样,数据库的性能随着可用核心数量的增加而“垂直”扩展。 + +如果单个节点变得太小而无法容纳表数据,可以添加更多节点组成集群。可以将表“分片”并分布在节点之间。ClickHouse 将在所有存储表数据的节点上运行查询,从而随着可用节点数的增加实现“水平”扩展。 + +🤿 深入了解 [查询处理层](/academic_overview#4-query-processing-layer) 部分,具体请参见我们 VLDB 2024 论文的网络版本。 + +## 对细节的严谨关注 {#meticulous-attention-to-detail} + + + +> **“ClickHouse 是一个怪异的系统——你们有 20 个版本的哈希表。你们有这些令人惊叹的东西,而大多数系统只会有一个哈希表……ClickHouse 之所以具有如此出色的性能,是因为它有所有这些专门的组件。”** [Andy Pavlo, 卡内基梅隆大学数据库教授](https://www.youtube.com/watch?v=Vy2t_wZx4Is&t=3579s) + +ClickHouse 的[与众不同](https://www.youtube.com/watch?v=CAS2otEoerM)之处在于对底层优化的严谨关注。构建一个简单可用的数据库是一回事,但工程设计以在各种查询类型、数据结构、分布和索引配置中提供速度,正是“[怪异系统](https://youtu.be/Vy2t_wZx4Is?si=K7MyzsBBxgmGcuGU&t=3579)”艺术的体现。 + +**哈希表。** 以哈希表为例。哈希表是连接和聚合使用的中心数据结构。作为程序员,必须考虑这些设计决策: + +* 选择什么哈希函数, +* 碰撞解决: [开放寻址](https://en.wikipedia.org/wiki/Open_addressing) 还是 [链式法](https://en.wikipedia.org/wiki/Hash_table#Separate_chaining)? +* 内存布局:为键和值使用一个数组还是分开数组? +* 填充因子:何时以及如何调整大小?调整大小时如何移动值? +* 删除:哈希表是否允许驱逐条目? + +由第三方库提供的标准哈希表在功能上是可行的,但速度并不快。出色的性能需要仔细的基准测试和实验。 + +ClickHouse 中的[哈希表实现](https://clickhouse.com/blog/hash-tables-in-clickhouse-and-zero-cost-abstractions)根据查询和数据的具体情况选择 **30 多种预编译哈希表变体** 中的一种。 + +**算法。** 对于算法也是如此。例如,在排序时,你可能会考虑: + +* 将要排序的是什么:数字、元组、字符串还是结构? +* 数据是否在 RAM 中? +* 排序是否需要稳定性? +* 是否需要对所有数据进行排序,还是部分排序足够? + +依赖于数据特征的算法通常比通用算法表现更佳。如果数据特征事先未知,系统可以尝试多种实现并选择在运行时效果最好的。例如,参见[关于 ClickHouse 中 LZ4 解压缩实现的文章](https://habr.com/en/company/yandex/blog/457612/)。 + +🤿 深入了解 [整体性能优化](/academic_overview#4-4-holistic-performance-optimization) 部分,具体请参见我们 VLDB 2024 论文的网络版本。 + +## VLDB 2024 论文 {#vldb-2024-paper} + +在 2024 年 8 月,我们的第一篇研究论文被 VLDB 录用并发表。VLDB 是一个关于超大规模数据库的国际会议,被广泛认为是数据管理领域的领先会议之一。在数百份投稿中,VLDB 通常的录用率为 ~20%。 + +您可以阅读 [论文的 PDF](https://www.vldb.org/pvldb/vol17/p3731-schulze.pdf) 或我们[网络版本](/docs/academic_overview),它简要描述了 ClickHouse 最有趣的架构和系统设计组件,哪些使其如此快速。 + +我们的首席技术官和 ClickHouse 创始人 Alexey Milovidov 介绍了该论文(幻灯片 [在这里](https://raw.githubusercontent.com/ClickHouse/clickhouse-presentations/master/2024-vldb/VLDB_2024_presentation.pdf)),随后进行了问答(很快就超时了!)。您可以在这里观看录制的演示: + + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/concepts/why-clickhouse-is-so-fast.mdx.hash b/i18n/zh/docusaurus-plugin-content-docs/current/concepts/why-clickhouse-is-so-fast.mdx.hash new file mode 100644 index 00000000000..f1fac288fca --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/concepts/why-clickhouse-is-so-fast.mdx.hash @@ -0,0 +1 @@ +5af4ad3225f4dd8a diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/data-compression/compression-in-clickhouse.md b/i18n/zh/docusaurus-plugin-content-docs/current/data-compression/compression-in-clickhouse.md index 302d05eecaa..f80259c6947 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/data-compression/compression-in-clickhouse.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/data-compression/compression-in-clickhouse.md @@ -1,34 +1,35 @@ --- 'slug': '/data-compression/compression-in-clickhouse' -'title': 'ClickHouse中的压缩' -'description': '选择ClickHouse压缩算法' +'title': 'ClickHouse 中的压缩' +'description': '选择 ClickHouse 压缩算法' 'keywords': - 'compression' - 'codec' - 'encoding' +'doc_type': 'reference' --- -One of the secrets to ClickHouse query performance is compression. +ClickHouse 查询性能的秘密之一是压缩。 -Less data on disk means less I/O and faster queries and inserts. The overhead of any compression algorithm with respect to CPU is in most cases outweighed by the reduction in IO. Improving the compression of the data should therefore be the first focus when working on ensuring ClickHouse queries are fast. +磁盘上的数据越少,I/O 就越少,查询和插入的速度也就越快。与 CPU 相关的任何压缩算法的开销在大多数情况下被 I/O 的减少所抵消。因此,改进数据的压缩应是确保 ClickHouse 查询快速的首要任务。 -> For why ClickHouse compresses data so well, we recommended [this article](https://clickhouse.com/blog/optimize-clickhouse-codecs-compression-schema). In summary, as a column-oriented database, values will be written in column order. If these values are sorted, the same values will be adjacent to each other. Compression algorithms exploit contiguous patterns of data. On top of this, ClickHouse has codecs and granular data types which allow users to tune the compression techniques further. +> 关于为什么 ClickHouse 可以如此有效地压缩数据,我们推荐 [这篇文章](https://clickhouse.com/blog/optimize-clickhouse-codecs-compression-schema)。总之,作为一种列式数据库,值将按列顺序写入。如果这些值经过排序,相同的值将彼此相邻。压缩算法利用连续的数据模式。在此基础上,ClickHouse 具有编解码器和细粒度数据类型,使用户能够进一步调整压缩技术。 -Compression in ClickHouse will be impacted by 3 principal factors: -- The ordering key -- The data types -- Which codecs are used +ClickHouse 中的压缩将受到 3 个主要因素的影响: +- 排序键 +- 数据类型 +- 使用的编解码器 -All of these are configured through the schema. +所有这些都通过架构进行配置。 -## Choose the right data type to optimize compression {#choose-the-right-data-type-to-optimize-compression} +## 选择正确的数据类型以优化压缩 {#choose-the-right-data-type-to-optimize-compression} -Let's use the Stack Overflow dataset as an example. Let's compare compression statistics for the following schemas for the `posts` table: +我们以 Stack Overflow 数据集为例。我们将比较 `posts` 表的以下架构的压缩统计数据: -- `posts` - A non type optimized schema with no ordering key. -- `posts_v3` - A type optimized schema with the appropriate type and bit size for each column with ordering key `(PostTypeId, toDate(CreationDate), CommentCount)`. +- `posts` - 无类型优化架构,没有排序键。 +- `posts_v3` - 针对每列选择适当类型和位大小的类型优化架构,排序键为 `(PostTypeId, toDate(CreationDate), CommentCount)`。 -Using the following queries, we can measure the current compressed and uncompressed size of each column. Let's examine the size of the initial optimized schema `posts` with no ordering key. +使用以下查询,我们可以测量每一列当前的压缩和未压缩大小。让我们检查初始优化架构 `posts`(没有排序键)的大小。 ```sql SELECT name, @@ -65,227 +66,77 @@ GROUP BY name └───────────────────────┴─────────────────┴───────────────────┴────────────┘ ``` -We show both a compressed and uncompressed size here. Both are important. The compressed size equates to what we will need to read off disk - something we want to minimize for query performance (and storage cost). This data will need to be decompressed prior to reading. The size of this uncompressed size will be dependent on the data type used in this case. Minimizing this size will reduce memory overhead of queries and the amount of data which has to be processed by the query, improving utilization of caches and ultimately query times. - -> The above query relies on the table `columns` in the system database. This database is managed by ClickHouse and is a treasure trove of useful information, from query performance metrics to background cluster logs. We recommend ["System Tables and a Window into the Internals of ClickHouse"](https://clickhouse.com/blog/clickhouse-debugging-issues-with-system-tables) and accompanying articles[[1]](https://clickhouse.com/blog/monitoring-troubleshooting-insert-queries-clickhouse)[[2]](https://clickhouse.com/blog/monitoring-troubleshooting-select-queries-clickhouse) for the curious reader. - -To summarize the total size of the table, we can simplify the above query: - -```sql -SELECT formatReadableSize(sum(data_compressed_bytes)) AS compressed_size, - formatReadableSize(sum(data_uncompressed_bytes)) AS uncompressed_size, - round(sum(data_uncompressed_bytes) / sum(data_compressed_bytes), 2) AS ratio -FROM system.columns -WHERE table = 'posts' - -┌─compressed_size─┬─uncompressed_size─┬─ratio─┐ -│ 50.16 GiB │ 143.47 GiB │ 2.86 │ -└─────────────────┴───────────────────┴───────┘ -``` - -Repeating this query for the `posts_v3`, the table with an optimized type and ordering key, we can see a significant reduction in uncompressed and compressed sizes. - -```sql -SELECT - formatReadableSize(sum(data_compressed_bytes)) AS compressed_size, - formatReadableSize(sum(data_uncompressed_bytes)) AS uncompressed_size, - round(sum(data_uncompressed_bytes) / sum(data_compressed_bytes), 2) AS ratio -FROM system.columns -WHERE `table` = 'posts_v3' - -┌─compressed_size─┬─uncompressed_size─┬─ratio─┐ -│ 25.15 GiB │ 68.87 GiB │ 2.74 │ -└─────────────────┴───────────────────┴───────┘ -``` - -The full column breakdown shows considerable savings for the `Body`, `Title`, `Tags` and `CreationDate` columns achieved by ordering the data prior to compression and using the appropriate types. - -```sql -SELECT - name, - formatReadableSize(sum(data_compressed_bytes)) AS compressed_size, - formatReadableSize(sum(data_uncompressed_bytes)) AS uncompressed_size, - round(sum(data_uncompressed_bytes) / sum(data_compressed_bytes), 2) AS ratio -FROM system.columns -WHERE `table` = 'posts_v3' -GROUP BY name - -┌─name──────────────────┬─compressed_size─┬─uncompressed_size─┬───ratio─┐ -│ Body │ 23.10 GiB │ 63.63 GiB │ 2.75 │ -│ Title │ 614.65 MiB │ 1.28 GiB │ 2.14 │ -│ Score │ 40.28 MiB │ 227.38 MiB │ 5.65 │ -│ Tags │ 234.05 MiB │ 688.49 MiB │ 2.94 │ -│ ParentId │ 107.78 MiB │ 321.33 MiB │ 2.98 │ -│ Id │ 159.70 MiB │ 227.38 MiB │ 1.42 │ -│ AcceptedAnswerId │ 40.34 MiB │ 227.38 MiB │ 5.64 │ -│ ClosedDate │ 5.93 MiB │ 9.49 MiB │ 1.6 │ -│ LastActivityDate │ 246.55 MiB │ 454.76 MiB │ 1.84 │ -│ CommentCount │ 635.78 KiB │ 56.84 MiB │ 91.55 │ -│ OwnerUserId │ 183.86 MiB │ 227.38 MiB │ 1.24 │ -│ AnswerCount │ 9.67 MiB │ 113.69 MiB │ 11.76 │ -│ FavoriteCount │ 19.77 KiB │ 147.32 KiB │ 7.45 │ -│ ViewCount │ 45.04 MiB │ 227.38 MiB │ 5.05 │ -│ LastEditorUserId │ 86.25 MiB │ 227.38 MiB │ 2.64 │ -│ ContentLicense │ 2.17 MiB │ 57.10 MiB │ 26.37 │ -│ OwnerDisplayName │ 5.95 MiB │ 16.19 MiB │ 2.72 │ -│ PostTypeId │ 39.49 KiB │ 56.84 MiB │ 1474.01 │ -│ CreationDate │ 181.23 MiB │ 454.76 MiB │ 2.51 │ -│ LastEditDate │ 134.07 MiB │ 454.76 MiB │ 3.39 │ -│ LastEditorDisplayName │ 2.15 MiB │ 6.25 MiB │ 2.91 │ -│ CommunityOwnedDate │ 824.60 KiB │ 1.34 MiB │ 1.66 │ -└───────────────────────┴─────────────────┴───────────────────┴─────────┘ -``` - -## Choosing the right column compression codec {#choosing-the-right-column-compression-codec} - -With column compression codecs, we can change the algorithm (and its settings) used to encode and compress each column. - -Encodings and compression work slightly differently with the same objective: to reduce our data size. Encodings apply a mapping to our data, transforming the values based on a function by exploiting properties of the data type. Conversely, compression uses a generic algorithm to compress data at a byte level. - -Typically, encodings are applied first before compression is used. Since different encodings and compression algorithms are effective on different value distributions, we must understand our data. +
+ +有关紧凑与宽分片的说明 -ClickHouse supports a large number of codecs and compression algorithms. The following are some recommendations in order of importance: +如果您看到的 `compressed_size` 或 `uncompressed_size` 值等于 `0`,这可能是因为片段的类型是 `compact` 而不是 `wide`(请参阅 [`system.parts`](/operations/system-tables/parts) 中 `part_type` 的描述)。部分格式由设置 [`min_bytes_for_wide_part`](/operations/settings/merge-tree-settings#min_bytes_for_wide_part) 和 [`min_rows_for_wide_part`](/operations/settings/merge-tree-settings#min_rows_for_wide_part) 控制,这意味着如果插入的数据导致一个部分没有超过上述设置的值,该部分将是紧凑的,而不是宽的,并且您将无法看到 `compressed_size` 或 `uncompressed_size` 的值。 -Recommendation | Reasoning ---- | --- -**`ZSTD` all the way** | `ZSTD` compression offers the best rates of compression. `ZSTD(1)` should be the default for most common types. Higher rates of compression can be tried by modifying the numeric value. We rarely see sufficient benefits on values higher than 3 for the increased cost of compression (slower insertion). -**`Delta` for date and integer sequences** | `Delta`-based codecs work well whenever you have monotonic sequences or small deltas in consecutive values. More specifically, the Delta codec works well, provided the derivatives yield small numbers. If not, `DoubleDelta` is worth trying (this typically adds little if the first-level derivative from `Delta` is already very small). Sequences where the monotonic increment is uniform, will compress even better e.g. DateTime fields. -**`Delta` improves `ZSTD`** | `ZSTD` is an effective codec on delta data - conversely, delta encoding can improve `ZSTD` compression. In the presence of `ZSTD`, other codecs rarely offer further improvement. -**`LZ4` over `ZSTD` if possible** | if you get comparable compression between `LZ4` and `ZSTD`, favor the former since it offers faster decompression and needs less CPU. However, `ZSTD` will outperform `LZ4` by a significant margin in most cases. Some of these codecs may work faster in combination with `LZ4` while providing similar compression compared to `ZSTD` without a codec. This will be data specific, however, and requires testing. -**`T64` for sparse or small ranges** | `T64` can be effective on sparse data or when the range in a block is small. Avoid `T64` for random numbers. -**`Gorilla` and `T64` for unknown patterns?** | If the data has an unknown pattern, it may be worth trying `Gorilla` and `T64`. -**`Gorilla` for gauge data** | `Gorilla` can be effective on floating point data, specifically that which represents gauge readings, i.e. random spikes. +为了演示: -See [here](/sql-reference/statements/create/table#column_compression_codec) for further options. - -Below we specify the `Delta` codec for the `Id`, `ViewCount` and `AnswerCount`, hypothesizing these will be linearly correlated with the ordering key and thus should benefit from Delta encoding. - -```sql -CREATE TABLE posts_v4 -( - `Id` Int32 CODEC(Delta, ZSTD), - `PostTypeId` Enum('Question' = 1, 'Answer' = 2, 'Wiki' = 3, 'TagWikiExcerpt' = 4, 'TagWiki' = 5, 'ModeratorNomination' = 6, 'WikiPlaceholder' = 7, 'PrivilegeWiki' = 8), - `AcceptedAnswerId` UInt32, - `CreationDate` DateTime64(3, 'UTC'), - `Score` Int32, - `ViewCount` UInt32 CODEC(Delta, ZSTD), - `Body` String, - `OwnerUserId` Int32, - `OwnerDisplayName` String, - `LastEditorUserId` Int32, - `LastEditorDisplayName` String, - `LastEditDate` DateTime64(3, 'UTC'), - `LastActivityDate` DateTime64(3, 'UTC'), - `Title` String, - `Tags` String, - `AnswerCount` UInt16 CODEC(Delta, ZSTD), - `CommentCount` UInt8, - `FavoriteCount` UInt8, - `ContentLicense` LowCardinality(String), - `ParentId` String, - `CommunityOwnedDate` DateTime64(3, 'UTC'), - `ClosedDate` DateTime64(3, 'UTC') +```sql title="Query" +-- Create a table with compact parts +CREATE TABLE compact ( + number UInt32 ) -ENGINE = MergeTree -ORDER BY (PostTypeId, toDate(CreationDate), CommentCount) -``` +ENGINE = MergeTree() +ORDER BY number +AS SELECT * FROM numbers(100000); -- Not big enough to exceed default of min_bytes_for_wide_part = 10485760 -The compression improvements for these columns is shown below: +-- Check the type of the parts +SELECT table, name, part_type from system.parts where table = 'compact'; -```sql -SELECT - `table`, - name, - formatReadableSize(sum(data_compressed_bytes)) AS compressed_size, - formatReadableSize(sum(data_uncompressed_bytes)) AS uncompressed_size, - round(sum(data_uncompressed_bytes) / sum(data_compressed_bytes), 2) AS ratio +-- Get the compressed and uncompressed column sizes for the compact table +SELECT name, + formatReadableSize(sum(data_compressed_bytes)) AS compressed_size, + formatReadableSize(sum(data_uncompressed_bytes)) AS uncompressed_size, + round(sum(data_uncompressed_bytes) / sum(data_compressed_bytes), 2) AS ratio FROM system.columns -WHERE (name IN ('Id', 'ViewCount', 'AnswerCount')) AND (`table` IN ('posts_v3', 'posts_v4')) -GROUP BY - `table`, - name -ORDER BY - name ASC, - `table` ASC - -┌─table────┬─name────────┬─compressed_size─┬─uncompressed_size─┬─ratio─┐ -│ posts_v3 │ AnswerCount │ 9.67 MiB │ 113.69 MiB │ 11.76 │ -│ posts_v4 │ AnswerCount │ 10.39 MiB │ 111.31 MiB │ 10.71 │ -│ posts_v3 │ Id │ 159.70 MiB │ 227.38 MiB │ 1.42 │ -│ posts_v4 │ Id │ 64.91 MiB │ 222.63 MiB │ 3.43 │ -│ posts_v3 │ ViewCount │ 45.04 MiB │ 227.38 MiB │ 5.05 │ -│ posts_v4 │ ViewCount │ 52.72 MiB │ 222.63 MiB │ 4.22 │ -└──────────┴─────────────┴─────────────────┴───────────────────┴───────┘ - -6 rows in set. Elapsed: 0.008 sec -``` +WHERE table = 'compact' +GROUP BY name; -### Compression in ClickHouse Cloud {#compression-in-clickhouse-cloud} - -In ClickHouse Cloud, we utilize the `ZSTD` compression algorithm (with a default value of 1) by default. While compression speeds can vary for this algorithm, depending on the compression level (higher = slower), it has the advantage of being consistently fast on decompression (around 20% variance) and also benefiting from the ability to be parallelized. Our historical tests also suggest that this algorithm is often sufficiently effective and can even outperform `LZ4` combined with a codec. It is effective on most data types and information distributions, and is thus a sensible general-purpose default and why our initial earlier compression is already excellent even without optimization. - ---- - -ClickHouse查询性能的秘密之一是压缩。 - -磁盘上的数据越少,I/O就越少,查询和插入就越快。在大多数情况下,任何压缩算法对CPU的开销都被I/O的减少所抵消。因此,改进数据的压缩应该是确保ClickHouse查询快速的首要任务。 - -> 关于ClickHouse为何能够如此有效地压缩数据,我们推荐[这篇文章](https://clickhouse.com/blog/optimize-clickhouse-codecs-compression-schema)。总之,作为一个列式数据库,值将按列顺序写入。如果这些值是排序的,相同的值将相互相邻。压缩算法利用相邻的数据模式。除此之外,ClickHouse还具有编解码器和细粒度的数据类型,允许用户进一步调整压缩技术。 - -ClickHouse中的压缩将受到3个主要因素的影响: -- 排序键 -- 数据类型 -- 使用的编码器 - -所有这些都通过模式进行配置。 - -## 选择正确的数据类型以优化压缩 {#choose-the-right-data-type-to-optimize-compression} - -让我们使用Stack Overflow数据集作为示例。我们来比较`posts`表以下模式的压缩统计信息: - -- `posts` - 一种没有排序键的非类型优化模式。 -- `posts_v3` - 一种类型优化模式,针对每一列使用适当的类型和比特大小,排序键为`(PostTypeId, toDate(CreationDate), CommentCount)`。 +-- Create a table with wide parts +CREATE TABLE wide ( + number UInt32 +) +ENGINE = MergeTree() +ORDER BY number +SETTINGS min_bytes_for_wide_part=0 +AS SELECT * FROM numbers(100000); -使用以下查询,我们可以测量每列当前压缩和未压缩的大小。让我们检查初始优化模式`posts`(没有排序键)的大小。 +-- Check the type of the parts +SELECT table, name, part_type from system.parts where table = 'wide'; -```sql +-- Get the compressed and uncompressed sizes for the wide table SELECT name, formatReadableSize(sum(data_compressed_bytes)) AS compressed_size, formatReadableSize(sum(data_uncompressed_bytes)) AS uncompressed_size, round(sum(data_uncompressed_bytes) / sum(data_compressed_bytes), 2) AS ratio FROM system.columns -WHERE table = 'posts' -GROUP BY name +WHERE table = 'wide' +GROUP BY name; +``` -┌─name──────────────────┬─compressed_size─┬─uncompressed_size─┬───ratio────┐ -│ Body │ 46.14 GiB │ 127.31 GiB │ 2.76 │ -│ Title │ 1.20 GiB │ 2.63 GiB │ 2.19 │ -│ Score │ 84.77 MiB │ 736.45 MiB │ 8.69 │ -│ Tags │ 475.56 MiB │ 1.40 GiB │ 3.02 │ -│ ParentId │ 210.91 MiB │ 696.20 MiB │ 3.3 │ -│ Id │ 111.17 MiB │ 736.45 MiB │ 6.62 │ -│ AcceptedAnswerId │ 81.55 MiB │ 736.45 MiB │ 9.03 │ -│ ClosedDate │ 13.99 MiB │ 517.82 MiB │ 37.02 │ -│ LastActivityDate │ 489.84 MiB │ 964.64 MiB │ 1.97 │ -│ CommentCount │ 37.62 MiB │ 565.30 MiB │ 15.03 │ -│ OwnerUserId │ 368.98 MiB │ 736.45 MiB │ 2 │ -│ AnswerCount │ 21.82 MiB │ 622.35 MiB │ 28.53 │ -│ FavoriteCount │ 280.95 KiB │ 508.40 MiB │ 1853.02 │ -│ ViewCount │ 95.77 MiB │ 736.45 MiB │ 7.69 │ -│ LastEditorUserId │ 179.47 MiB │ 736.45 MiB │ 4.1 │ -│ ContentLicense │ 5.45 MiB │ 847.92 MiB │ 155.5 │ -│ OwnerDisplayName │ 14.30 MiB │ 142.58 MiB │ 9.97 │ -│ PostTypeId │ 20.93 MiB │ 565.30 MiB │ 27 │ -│ CreationDate │ 314.17 MiB │ 964.64 MiB │ 3.07 │ -│ LastEditDate │ 346.32 MiB │ 964.64 MiB │ 2.79 │ -│ LastEditorDisplayName │ 5.46 MiB │ 124.25 MiB │ 22.75 │ -│ CommunityOwnedDate │ 2.21 MiB │ 509.60 MiB │ 230.94 │ -└───────────────────────┴─────────────────┴───────────────────┴────────────┘ +```response title="Response" + ┌─table───┬─name──────┬─part_type─┐ +1. │ compact │ all_1_1_0 │ Compact │ + └─────────┴───────────┴───────────┘ + ┌─name───┬─compressed_size─┬─uncompressed_size─┬─ratio─┐ +1. │ number │ 0.00 B │ 0.00 B │ nan │ + └────────┴─────────────────┴───────────────────┴───────┘ + ┌─table─┬─name──────┬─part_type─┐ +1. │ wide │ all_1_1_0 │ Wide │ + └───────┴───────────┴───────────┘ + ┌─name───┬─compressed_size─┬─uncompressed_size─┬─ratio─┐ +1. │ number │ 392.31 KiB │ 390.63 KiB │ 1 │ + └────────┴─────────────────┴───────────────────┴───────┘ ``` -我们在这里显示了压缩和未压缩的大小。两者都很重要。压缩的大小等于我们需要从磁盘读取的内容——这是我们希望尽量减少以提高查询性能(和存储成本)的内容。此数据需要在读取之前进行解压缩。未压缩的大小将取决于这种情况下使用的数据类型。最小化这个大小将减少查询的内存开销和查询必须处理的数据量,从而提高缓存的利用率,最终改善查询时间。 +
+ +我们在这里展示了压缩和未压缩的大小。两者都很重要。压缩大小表示我们需要从磁盘读取的内容 - 我们希望尽量减少这一点以提高查询性能(和存储成本)。这部分数据在读取之前需要解压。这个未压缩大小的大小将取决于使用的数据类型。最小化这个大小将减少查询的内存开销,以及必须由查询处理的数据量,从而提高缓存的利用率,最终改善查询时间。 -> 上述查询依赖于系统数据库中的`columns`表。该数据库由ClickHouse管理,是关于查询性能指标到后台群集日志的宝贵信息来源。我们推荐["系统表和ClickHouse内部的窗口"](https://clickhouse.com/blog/clickhouse-debugging-issues-with-system-tables)和相关的文章[[1]](https://clickhouse.com/blog/monitoring-troubleshooting-insert-queries-clickhouse)[[2]](https://clickhouse.com/blog/monitoring-troubleshooting-select-queries-clickhouse)供感兴趣的读者参考。 +> 上述查询依赖于系统数据库中的 `columns` 表。这个数据库由 ClickHouse 管理,是有用信息的宝库,从查询性能指标到后台集群日志。我们推荐给好奇的读者 ["系统表和 ClickHouse 内部的窗口"](https://clickhouse.com/blog/clickhouse-debugging-issues-with-system-tables) 和附随的文章[[1]](https://clickhouse.com/blog/monitoring-troubleshooting-insert-queries-clickhouse)[[2]](https://clickhouse.com/blog/monitoring-troubleshooting-select-queries-clickhouse)。 为了总结表的总大小,我们可以简化上述查询: @@ -301,7 +152,7 @@ WHERE table = 'posts' └─────────────────┴───────────────────┴───────┘ ``` -对`posts_v3`重复此查询,该表具有优化类型和排序键,我们可以看到未压缩和压缩大小的显著减少。 +针对 `posts_v3` 的重复查询,此表具有优化的数据类型和排序键,我们可以看到未压缩和压缩大小显著减少。 ```sql SELECT @@ -316,7 +167,7 @@ WHERE `table` = 'posts_v3' └─────────────────┴───────────────────┴───────┘ ``` -完整的列细分显示通过在压缩之前对数据进行排序并使用适当类型`Body`、`Title`、`Tags`和`CreationDate`列所取得的显著节省。 +完整的列细分显示通过在压缩之前对数据进行排序并使用适当的类型,`Body`、`Title`、`Tags` 和 `CreationDate` 列获得了可观的节省。 ```sql SELECT @@ -354,29 +205,29 @@ GROUP BY name └───────────────────────┴─────────────────┴───────────────────┴─────────┘ ``` -## 选择正确的列压缩编码器 {#choosing-the-right-column-compression-codec} +## 选择正确的列压缩编解码器 {#choosing-the-right-column-compression-codec} -使用列压缩编码器,我们可以更改用于编码和压缩每一列的算法(及其设置)。 +使用列压缩编解码器,我们可以更改用于编码和压缩每列的算法(及其设置)。 -编码和压缩的工作原理略有不同,但目的相同:减少我们的数据大小。编码对我们的数据应用映射,通过利用数据类型的属性,根据函数转换值。相反,压缩使用通用算法在字节级别上压缩数据。 +编码和压缩的工作原理略有不同,但目标都是减少我们的数据大小。编码对数据应用映射,利用数据类型的属性根据函数转变值。相反,压缩使用通用算法在字节级别压缩数据。 -通常,编码被首先应用,然后才使用压缩。由于不同的编码和压缩算法在不同的值分布中效果不同,我们必须理解我们的数据。 +通常,编码先应用,然后再使用压缩。由于不同的编码和压缩算法对不同值分布的有效性不同,因此我们必须了解我们的数据。 -ClickHouse支持大量的编码器和压缩算法。以下是一些重要性排序的推荐: +ClickHouse 支持大量编解码器和压缩算法。以下是一些按重要性排序的推荐: -推荐 | 理由 ---- | --- -**`ZSTD` 全面使用** | `ZSTD` 压缩提供了最佳的压缩率。`ZSTD(1)` 应该是大多数常用类型的默认值。通过修改数字值,可以尝试更高的压缩率。我们很少在压缩成本增加(插入速度较慢)的情况下看到高于3的值有足够的益处。 -**`Delta` 用于日期和整数序列** | 每当您拥有单调序列或连续值中的小增量时,基于`Delta` 的编码器效果很好。更具体地说,Delta编码器效果很好,只要其导数产生小数字。如果不是,则值得尝试`DoubleDelta`(如果来自`Delta`的第一阶导数已经很小,这通常增加不多)。在单调增量均匀的序列中,例如DateTime字段,将获得更好的压缩效果。 -**`Delta` 改善 `ZSTD`** | `ZSTD` 是在增量数据上的有效编码器 - 反之,增量编码可以改善 `ZSTD` 压缩。在存在 `ZSTD` 的情况下,其他编码器很少提供进一步改进。 -**如果可能,使用 `LZ4` 超过 `ZSTD`** | 如果`LZ4`和`ZSTD`之间的压缩相当,请优先使用前者,因为其解压速度更快且CPU占用更少。但是,在大多数情况下,`ZSTD`将显著超越`LZ4`。这些编码器中的一些可能在与`LZ4`结合使用时速度更快,同时提供与没有编码器的`ZSTD`相似的压缩。然而,这将是特定于数据的,需要测试。 -**`T64` 适用于稀疏或小范围数据** | `T64` 可以在稀疏数据上或当一个块中的范围较小的情况下发挥有效作用。避免在随机数字中使用 `T64`。 -**对于未知模式使用 `Gorilla` 和 `T64` ?** | 如果数据具有未知模式,尝试 `Gorilla` 和 `T64` 可能是值得的。 -**`Gorilla` 适用于衡量数据** | `Gorilla` 在浮点数据上可能有效,特别是那些代表测量读数,即随机峰值的数据。 +推荐 | 理由 +--- | --- +**`ZSTD` 一路支持** | `ZSTD` 压缩提供最佳的压缩率。`ZSTD(1)` 应是大多数常见类型的默认值。可以通过修改数字值尝试更高的压缩率。对于压缩增益,我们很少看到超过 3 的值在增加压缩成本(插入速度较慢)时有足够的获益。 +**日期和整数序列使用 `Delta`** | 当您拥有单调序列或连续值的小增量时,基于 `Delta` 的编解码器效果很好。更具体地说,Delta 编解码器在其导数生成小数字时效果良好。如果没有,值得尝试 `DoubleDelta`(如果 `Delta` 的一级导数已经非常小,这通常不会增加太多)。单调增量均匀的序列将得到更好的压缩,例如 DateTime 字段。 +**`Delta` 改善 `ZSTD`** | `ZSTD` 是 Delta 数据上有效的编解码器 - 相反,delta 编码可以改善 `ZSTD` 压缩。在存在 `ZSTD` 的情况下,其他编解码器很少提供进一步的改善。 +**如果可能,优先使用 `LZ4` 而不是 `ZSTD`** | 如果您在 `LZ4` 和 `ZSTD` 之间获得可比的压缩,优先选择前者,因为它提供更快的解压缩并需要更少的 CPU。但是,在大多数情况下,`ZSTD` 将显著超越 `LZ4`。其中一些编解码器可能与 `LZ4` 组合使用时运行更快,同时在没有编解码器的情况下提供与 `ZSTD` 相似的压缩。但这将是特定于数据的,并需要测试。 +**对稀疏或小范围数据使用 `T64`** | `T64` 在稀疏数据或块中的范围较小时可能非常有效。避免在随机数上使用 `T64`。 +**不确定模式使用 `Gorilla` 和 `T64`?** | 如果数据具有不确定模式,尝试使用 `Gorilla` 和 `T64` 可能是值得的。 +**对测量数据使用 `Gorilla`** | `Gorilla` 对浮点数据是有效的,特别是代表测量读数的数据,即随机峰值。 -有关更多选项,请参见[这里](/sql-reference/statements/create/table#column_compression_codec)。 +有关更多选项,请参见 [此处](/sql-reference/statements/create/table#column_compression_codec)。 -下面我们为`Id`、`ViewCount`和`AnswerCount`指定`Delta`编码器,假设它们将与排序键线性相关,因此应该受益于Delta编码。 +下面我们为 `Id`、`ViewCount` 和 `AnswerCount` 指定 `Delta` 编解码器,假设这些会与排序键线性相关,从而应从 Delta 编码中受益。 ```sql CREATE TABLE posts_v4 @@ -438,6 +289,6 @@ ORDER BY 6 rows in set. Elapsed: 0.008 sec ``` -### ClickHouse Cloud中的压缩 {#compression-in-clickhouse-cloud} +### ClickHouse Cloud 中的压缩 {#compression-in-clickhouse-cloud} -在ClickHouse Cloud中,我们默认使用`ZSTD`压缩算法(默认值为1)。虽然这种算法的压缩速度可能因压缩级别(更高=更慢)而不同,但它具有解压速度一致快速(波动约20%)的优势,并且还受益于能够并行化。我们的历史测试也表明,这种算法通常足够有效,甚至可以超过与编码器结合的`LZ4`。它对大多数数据类型和信息分布有效,因此是一个明智的通用默认值,这也是我们最初的压缩即使没有优化也已经出色的原因。 +在 ClickHouse Cloud 中,我们默认使用 `ZSTD` 压缩算法(默认值为 1)。虽然压缩速度可能会因压缩级别而异(更高 = 更慢),但它的优点在于解压缩速度始终较快(约 20% 的波动)且具有并行化的能力。我们的历史测试还表明,这种算法通常效果足够好,甚至可以优于与编解码器结合使用的 `LZ4`。它对大多数数据类型和信息分布有效,因此是一个合理的通用默认选项,这也是我们早期压缩在没有优化的情况下已经非常出色的原因。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/data-compression/compression-in-clickhouse.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/data-compression/compression-in-clickhouse.md.hash index 0996551b337..8bd72432f09 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/data-compression/compression-in-clickhouse.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/data-compression/compression-in-clickhouse.md.hash @@ -1 +1 @@ -040d4b2d7ff26e4b +58e660f8e691fde0 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/data-compression/compression-modes.md b/i18n/zh/docusaurus-plugin-content-docs/current/data-compression/compression-modes.md index e23cced1723..8f60d2dadb7 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/data-compression/compression-modes.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/data-compression/compression-modes.md @@ -2,12 +2,13 @@ 'slug': '/data-compression/compression-modes' 'sidebar_position': 6 'title': '压缩模式' -'description': 'ClickHouse 列 压缩模式' +'description': 'ClickHouse 列压缩模式' 'keywords': - 'compression' - 'codec' - 'encoding' - 'modes' +'doc_type': 'reference' --- import CompressionBlock from '@site/static/images/data-compression/ch_compression_block.png'; @@ -16,22 +17,22 @@ import Image from '@theme/IdealImage'; # 压缩模式 -ClickHouse 协议支持 **数据块** 的压缩和校验和。 -如果不确定选择哪个模式,请使用 `LZ4`。 +ClickHouse 协议支持带有校验和的 **数据块** 压缩。 +如果不确定选择哪种模式,请使用 `LZ4`。 :::tip -了解更多关于可用的 [列压缩编解码器](/sql-reference/statements/create/table#column_compression_codec),并在创建表时或之后进行指定。 +了解更多关于 [列压缩编解码器](/sql-reference/statements/create/table#column_compression_codec) 的信息,并在创建表时或之后指定它们。 ::: ## 模式 {#modes} | value | name | description | |--------|--------------------|------------------------------------------| -| `0x02` | [None](#none-mode) | 无压缩,只有校验和 | -| `0x82` | LZ4 | 极其快速,压缩效果良好 | -| `0x90` | ZSTD | Zstandard,速度相当快,压缩效果最好 | +| `0x02` | [None](#none-mode) | 无压缩,仅校验和 | +| `0x82` | LZ4 | 极快,良好的压缩效果 | +| `0x90` | ZSTD | Zstandard,速度较快,压缩效果最佳 | -LZ4 和 ZSTD 的作者相同,但各自有不同的权衡。 +LZ4 和 ZSTD 由同一作者创建,但各有不同的权衡。 来自 [Facebook 基准测试](https://facebook.github.io/zstd/#benchmarks): | name | ratio | encoding | decoding | @@ -43,20 +44,19 @@ LZ4 和 ZSTD 的作者相同,但各自有不同的权衡。 | field | type | description | |-----------------|---------|--------------------------------------------------| -| checksum | uint128 | [哈希](../native-protocol/hash.md) (header + compressed data) | -| raw_size | uint32 | 不含头的原始大小 | -| data_size | uint32 | 解压缩数据的大小 | +| checksum | uint128 | [哈希](../native-protocol/hash.md) 值为 (header + 压缩数据) | +| raw_size | uint32 | 不带头信息的原始大小 | +| data_size | uint32 | 未压缩的数据大小 | | mode | byte | 压缩模式 | | compressed_data | binary | 压缩数据块 | -图示 ClickHouse 压缩块结构 +Diagram illustrating ClickHouse compression block structure -头部为 (raw_size + data_size + mode),原始大小由 len(header + compressed_data) 组成。 +头信息为 (raw_size + data_size + mode),原始大小由 len(header + compressed_data) 组成。 校验和为 `hash(header + compressed_data)`,使用 [ClickHouse CityHash](../native-protocol/hash.md)。 ## 无模式 {#none-mode} 如果使用 *None* 模式,`compressed_data` 等于原始数据。 -无压缩模式有助于通过校验和确保额外的数据完整性,因为 -哈希的开销微不足道。 +无压缩模式有助于通过校验和确保额外的数据完整性,因为哈希开销微不足道。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/data-compression/compression-modes.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/data-compression/compression-modes.md.hash index a716bb8c6cc..a0011e95b52 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/data-compression/compression-modes.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/data-compression/compression-modes.md.hash @@ -1 +1 @@ -80d6f3c06d227b7d +fc096799a0689d03 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/data-modeling/backfilling.md b/i18n/zh/docusaurus-plugin-content-docs/current/data-modeling/backfilling.md index 1c9f4d0ae50..eb34582e576 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/data-modeling/backfilling.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/data-modeling/backfilling.md @@ -1,12 +1,13 @@ --- 'slug': '/data-modeling/backfilling' -'title': '补齐数据' -'description': '如何在 ClickHouse 中使用补齐大型数据集' +'title': '填充数据' +'description': '如何在 ClickHouse 中使用填充大量数据集' 'keywords': - 'materialized views' - 'backfilling' - 'inserting data' - 'resilient data load' +'doc_type': 'guide' --- import nullTableMV from '@site/static/images/data-modeling/null_table_mv.png'; @@ -15,17 +16,17 @@ import Image from '@theme/IdealImage'; # 回填数据 -无论是刚刚接触 ClickHouse 还是负责现有部署的用户,都不可避免地需要回填带有历史数据的表。在某些情况下,这相对简单,但在需要填充物化视图时可能会变得更加复杂。本指南记录了一些用户可以应用于自身用例的处理流程。 +无论是首次接触 ClickHouse 还是负责现有部署,用户通常需要用历史数据回填表。在某些情况下,这相对简单,但当需要填充物化视图时,可能会变得更加复杂。本指南记录了一些用户可以应用于其用例的回填过程。 :::note -本指南假设用户已熟悉 [增量物化视图](/materialized-view/incremental-materialized-view) 和 [使用表函数进行数据加载,比如 s3 和 gcs](/integrations/s3) 的概念。我们还建议用户阅读我们关于 [优化对象存储插入性能](/integrations/s3/performance) 的指南,其中的建议可以适用于本指南中的插入操作。 +本指南假设用户已熟悉[增量物化视图](/materialized-view/incremental-materialized-view)和[使用 s3 和 gcs 等表函数加载数据](/integrations/s3)的概念。我们还建议用户阅读我们的指南,[优化对象存储的插入性能](/integrations/s3/performance),其中的建议可以应用于本指南中的插入操作。 ::: ## 示例数据集 {#example-dataset} -在本指南中,我们使用 PyPI 数据集。此数据集中每一行代表使用 `pip` 等工具下载的 Python 包。 +在本指南中,我们使用 PyPI 数据集。该数据集中的每一行表示使用 `pip` 等工具下载的 Python 包。 -例如,子集涵盖了一天的内容 - `2024-12-17`,并在 `https://datasets-documentation.s3.eu-west-3.amazonaws.com/pypi/2024-12-17/` 上公开可用。用户可以通过以下查询: +例如,子集覆盖了单天 - `2024-12-17`,并可以在 `https://datasets-documentation.s3.eu-west-3.amazonaws.com/pypi/2024-12-17/` 上公开获取。用户可以执行以下查询: ```sql SELECT count() @@ -39,9 +40,9 @@ FROM s3('https://datasets-documentation.s3.eu-west-3.amazonaws.com/pypi/2024-12- Peak memory usage: 239.50 MiB. ``` -此存储桶的完整数据集包含超过 320 GB 的 parquet 文件。在下面的示例中,我们故意使用 glob 模式来定位子集。 +该存储桶的完整数据集包含超过 320 GB 的 parquet 文件。在以下示例中,我们有意使用 glob 模式来定位子集。 -我们假设用户正在消费此日期之后的数据流,例如来自 Kafka 或对象存储。此数据的模式如下所示: +我们假设用户正在使用 Kafka 或对象存储消费此数据流,以获取此日期之后的数据。此数据的模式如下所示: ```sql DESCRIBE TABLE s3('https://datasets-documentation.s3.eu-west-3.amazonaws.com/pypi/2024-12-17/*.parquet') @@ -69,25 +70,25 @@ SETTINGS describe_compact_output = 1 ``` :::note -完整的 PyPI 数据集包含超过 1 万亿行,用户可以在我们的公共演示环境 [clickpy.clickhouse.com](https://clickpy.clickhouse.com) 中访问。有关此数据集的更多详细信息,包括演示如何利用物化视图来提高性能以及数据如何每天填充,请参见 [这里](https://github.com/ClickHouse/clickpy)。 +完整的 PyPI 数据集包含超过 1 万亿行,已在我们的公共演示环境 [clickpy.clickhouse.com](https://clickpy.clickhouse.com) 中提供。如需有关此数据集的详细信息,包括演示如何利用物化视图来提高性能以及数据如何每天填充,请参阅[这里](https://github.com/ClickHouse/clickpy)。 ::: ## 回填场景 {#backfilling-scenarios} -通常,当从某一时间点消费数据流时,需要进行回填。此数据被插入到带有 [增量物化视图](/materialized-view/incremental-materialized-view) 的 ClickHouse 表中,随着数据块的插入而触发。这些视图可能在插入之前对数据进行转换或计算汇总,并将结果发送到目标表,以便在下游应用中稍后使用。 +当从某个时间点消费数据流时,通常需要进行回填。此数据被插入到具有[增量物化视图](/materialized-view/incremental-materialized-view)的 ClickHouse 表中,并在插入块时触发。这些视图可能在插入之前对数据进行转换,或计算聚合并将结果发送到目标表,以便在后续应用程序中使用。 我们将尝试涵盖以下场景: -1. **使用现有数据摄取回填数据** - 新数据正在加载,且历史数据需要回填。此历史数据已被识别。 -2. **向现有表添加物化视图** - 需要向其历史数据已被填充且数据已在流入的设置中添加新的物化视图。 +1. **使用现有数据摄取回填数据** - 新数据正在加载,并且需要回填已识别的历史数据。 +2. **向现有表添加物化视图** - 需要向已填充历史数据且数据正在流动的设置中添加新的物化视图。 -我们假设数据将从对象存储回填。在所有情况下,我们旨在避免数据插入的暂停。 +我们假设数据将从对象存储中回填。在所有情况下,我们旨在避免数据插入暂停。 -我们建议从对象存储回填历史数据。数据应该尽可能导出为 Parquet 格式,以实现最佳读取性能和压缩(减少网络传输)。通常,约 150MB 的文件大小最为理想,但 ClickHouse 支持超过 [70 种文件格式](/interfaces/formats),并能够处理各种大小的文件。 +我们建议从对象存储回填历史数据。数据应尽可能导出为 Parquet,以优化读取性能和压缩(减少网络传输)。通常,约 150MB 的文件大小是首选,但 ClickHouse 支持超过[70 种文件格式](/interfaces/formats),并能够处理所有大小的文件。 -## 使用重复表和视图 {#using-duplicate-tables-and-views} +## 使用副本表和视图 {#using-duplicate-tables-and-views} -在所有场景下,我们依赖“重复表和视图”的概念。这些表和视图表示用于实时流数据的副本,允许在隔离的情况下执行回填,如果发生故障则有简单的恢复手段。例如,我们有以下主要的 `pypi` 表和物化视图,计算每个 Python 项目的下载次数: +对于所有场景,我们依赖于“副本表和视图”的概念。这些表和视图代表了实时流数据使用的副本,允许在隔离的情况下执行回填,并提供简单的恢复机制,以防出现故障。例如,我们有以下主要 `pypi` 表和物化视图,该视图计算每个 Python 项目的下载次数: ```sql CREATE TABLE pypi @@ -120,7 +121,7 @@ FROM pypi GROUP BY project ``` -我们用数据的子集填充主要表和关联视图: +我们使用数据的一个子集填充主表和关联视图: ```sql INSERT INTO pypi SELECT * @@ -140,7 +141,6 @@ SELECT count() FROM pypi SELECT sum(count) FROM pypi_downloads - ┌─sum(count)─┐ │ 20612750 │ -- 20.61 million └────────────┘ @@ -149,11 +149,11 @@ FROM pypi_downloads Peak memory usage: 682.38 KiB. ``` -假设我们希望加载另一个子集 `{101..200}`。虽然我们可以直接插入到 `pypi` 中,但可以通过创建重复表在隔离状态下完成回填。 +假设我们希望加载另一个子集 `{101..200}`。虽然我们可以直接插入到 `pypi`,但我们可以通过创建副本表在隔离的情况下进行此回填。 -如果回填失败,我们没有影响到主要表,只需 [截断](/managing-data/truncate) 重复表并重新执行。 +如果回填失败,我们不会影响我们的主表,只需[截断](/managing-data/truncate)副本表并重复操作即可。 -要创建这些视图的新副本,我们可以使用 `CREATE TABLE AS` 子句,后加后缀 `_v2`: +要创建这些视图的新副本,我们可以使用 `CREATE TABLE AS` 子句并添加后缀 `_v2`: ```sql CREATE TABLE pypi_v2 AS pypi @@ -168,7 +168,7 @@ FROM pypi_v2 GROUP BY project ``` -我们用大约相同大小的第二个子集填充这一表,并确认成功加载。 +我们使用大约相同大小的第二个子集填充此副本,并确认加载成功。 ```sql INSERT INTO pypi_v2 SELECT * @@ -197,9 +197,9 @@ FROM pypi_downloads_v2 Peak memory usage: 688.77 KiB. ``` -如果在第二次加载期间的任何时刻经历了失败,我们可以简单地 [截断](/managing-data/truncate) `pypi_v2` 和 `pypi_downloads_v2`,然后重复数据加载。 +如果在第二次加载的任何点出现故障,我们可以简单地[截断](/managing-data/truncate)我们的 `pypi_v2` 和 `pypi_downloads_v2` 并重复数据加载。 -完成数据加载后,我们可以使用 [`ALTER TABLE MOVE PARTITION`](/sql-reference/statements/alter/partition#move-partition-to-table) 子句将数据从重复表移动到主要表。 +数据加载完成后,我们可以使用[`ALTER TABLE MOVE PARTITION`](/sql-reference/statements/alter/partition#move-partition-to-table) 子句将数据从副本表移动到主表。 ```sql ALTER TABLE pypi_v2 MOVE PARTITION () TO pypi @@ -212,10 +212,10 @@ ALTER TABLE pypi_downloads_v2 MOVE PARTITION () TO pypi_downloads ``` :::note 分区名称 -上述的 `MOVE PARTITION` 调用使用了分区名称 `()`。这表示此表的单一分区(未分区)。对于分区表,用户需要调用多个 `MOVE PARTITION` 调用 - 每个分区一个分区。当前分区的名称可以通过 [`system.parts`](/operations/system-tables/parts) 表确定,例如 `SELECT DISTINCT partition FROM system.parts WHERE (table = 'pypi_v2')`。 +上述 `MOVE PARTITION` 调用使用了分区名称 `()`。这表示该表的单个分区(没有分区)。对于已分区的表,用户需要执行多个 `MOVE PARTITION` 调用 - 每个分区一个。当前分区的名称可以从[`system.parts`](/operations/system-tables/parts) 表中获得,例如 `SELECT DISTINCT partition FROM system.parts WHERE (table = 'pypi_v2')`。 ::: -我们现在可以确认 `pypi` 和 `pypi_downloads` 包含完整的数据。`pypi_downloads_v2` 和 `pypi_v2` 可以安全删除。 +我们现在可以确认 `pypi` 和 `pypi_downloads` 包含完整数据。可以安全删除 `pypi_downloads_v2` 和 `pypi_v2`。 ```sql SELECT count() @@ -240,13 +240,13 @@ SELECT count() FROM pypi_v2 ``` -重要的是,`MOVE PARTITION` 操作是轻量级的(利用硬链接)和原子性的,即它要么成功,要么失败,没有中间状态。 +重要的是,`MOVE PARTITION` 操作既轻量(利用硬链接)又是原子性的,即它要么失败,要么成功,没有中间状态。 -我们在下面的回填场景中大量利用这一过程。 +我们在下面的回填场景中大量利用此过程。 -请注意,该过程要求用户选择每次插入操作的大小。 +请注意,这一过程要求用户选择每次插入操作的大小。 -较大的插入,即更多的行,将意味着需要更少的 `MOVE PARTITION` 操作。然而,这必须与因插入失败(例如由于网络中断)而恢复的成本相平衡。用户可以通过批量处理文件来降低风险。这可以通过范围查询,例如 `WHERE timestamp BETWEEN 2024-12-17 09:00:00 AND 2024-12-17 10:00:00` 或者 glob 模式来完成。例如, +更大的插入,即更多行,将意味着需要更少的 `MOVE PARTITION` 操作。然而,这必须与插入失败(例如,因网络中断)时的恢复成本进行权衡。用户还可以通过批量处理文件来降低风险。这可以通过范围查询进行,例如 `WHERE timestamp BETWEEN 2024-12-17 09:00:00 AND 2024-12-17 10:00:00` 或 glob 模式。例如, ```sql INSERT INTO pypi_v2 SELECT * @@ -259,22 +259,22 @@ FROM s3('https://datasets-documentation.s3.eu-west-3.amazonaws.com/pypi/2024-12- ``` :::note -ClickPipes 在从对象存储加载数据时使用此方法,自动创建目标表及其物化视图的副本,避免用户执行上述步骤的需要。通过使用多个工作线程,每个线程处理不同子集(通过 glob 模式)及其自己的重复表,数据可以快速加载,并确保正确一次性语义。对此感兴趣的用户可以在 [这篇博客](https://clickhouse.com/blog/supercharge-your-clickhouse-data-loads-part3) 中找到更多详细信息。 +ClickPipes 在从对象存储加载数据时使用此方法,自动创建目标表及其物化视图的副本,避免用户执行上述步骤的需要。通过使用多个工作线程,分别处理不同的子集(通过 glob 模式)并具有自己的副本表,数据可以快速加载,并确保准确一次的语义。有兴趣的人可以在[这篇博客](https://clickhouse.com/blog/supercharge-your-clickhouse-data-loads-part3)中找到更多详细信息。 ::: -## 场景 1: 使用现有数据摄取回填数据 {#scenario-1-backfilling-data-with-existing-data-ingestion} +## 场景 1:使用现有数据摄取回填数据 {#scenario-1-backfilling-data-with-existing-data-ingestion} -在此场景中,我们假设要回填的数据不在一个孤立的存储桶中,因此需要过滤。数据已经在插入,并且可以识别出某个时间戳或单调递增的列,从而需要回填历史数据。 +在此场景中,我们假设要回填的数据不在一个孤立的存储桶中,因此需要进行筛选。数据已经在插入中,可以识别出一个时间戳或单调递增的列,从该列需要回填历史数据。 -这个过程遵循以下步骤: +该过程遵循以下步骤: -1. 确定检查点 - 识别需要恢复的时间戳或列值。 -2. 创建主要表和物化视图目标表的重复副本。 -3. 创建指向在步骤 (2) 中创建的目标表的任何物化视图的副本。 -4. 插入到在步骤 (2) 中创建的重复主要表中。 -5. 将所有分区从重复表移动到它们的原始版本中。删除重复表。 +1. 确定检查点 - 一个时间戳或列值,从中需恢复历史数据。 +2. 为主表和物化视图的目标表创建副本。 +3. 创建指向步骤(2)中创建的目标表的任何物化视图的副本。 +4. 向步骤(2)中创建的副本主表插入数据。 +5. 将所有分区从副本表移动到其原始版本。删除副本表。 -例如,在我们的 PyPI 数据中,假设我们已经加载了数据。我们可以识别出最小时间戳,因此我们的“检查点”。 +例如,在我们的 PyPI 数据中,假设我们已经加载了数据。我们可以识别最小的时间戳,从而确定我们的“检查点”。 ```sql SELECT min(timestamp) @@ -288,7 +288,7 @@ FROM pypi Peak memory usage: 227.84 MiB. ``` -从上述内容,我们知道我们需要加载在 `2024-12-17 09:00:00` 之前的数据。使用我们之前的过程,我们创建重复表和视图,并使用时间戳上的过滤加载子集。 +从上面,我们知道我们需要加载在 `2024-12-17 09:00:00` 之前的数据。使用我们之前的过程,我们创建副本表和视图,并使用时间戳进行过滤来加载该子集。 ```sql CREATE TABLE pypi_v2 AS pypi @@ -307,7 +307,7 @@ WHERE timestamp < '2024-12-17 09:00:00' 0 rows in set. Elapsed: 500.152 sec. Processed 2.74 billion rows, 364.40 GB (5.47 million rows/s., 728.59 MB/s.) ``` :::note -在 Parquet 中对时间戳列进行过滤可以非常高效。ClickHouse 只会读取时间戳列以识别出要加载的完整数据范围,从而最大限度地减少网络流量。ClickHouse 查询引擎还可以利用 Parquet 索引,如最小-最大。 +在 Parquet 中按时间戳列进行筛选可以非常高效。ClickHouse 将仅读取时间戳列以识别要加载的完整数据范围,从而最小化网络流量。ClickHouse 查询引擎也可以利用 Parquet 索引,例如最小-最大索引。 ::: 一旦此插入完成,我们可以移动相关的分区。 @@ -318,32 +318,32 @@ ALTER TABLE pypi_v2 MOVE PARTITION () TO pypi ALTER TABLE pypi_downloads_v2 MOVE PARTITION () TO pypi_downloads ``` -如果历史数据在一个孤立的存储桶中,则不需要上述时间过滤。如果没有时间或单调列,请隔离您的历史数据。 +如果历史数据是在一个孤立的存储桶中,则不需要上述时间筛选。如果没有时间或单调列,请将历史数据隔离。 -:::note 只需在 ClickHouse Cloud 中使用 ClickPipes -ClickHouse Cloud 用户应在数据可以孤立到自己的存储桶中(且不需要过滤)时使用 ClickPipes 来恢复历史备份。通过并行加载多个工作线程,从而减少加载时间,ClickPipes 自动化了上述过程 - 为主表和物化视图创建重复表。 +:::note 请在 ClickHouse Cloud 中使用 ClickPipes +ClickHouse Cloud 用户应在历史备份的数据可以隔离在其自己的存储桶中(且不需要过滤)时,使用 ClickPipes 来恢复历史备份。除了通过多个工作程序并行化加载,从而减少加载时间外,ClickPipes 自动化了上述过程 - 为主表和物化视图创建副本。 ::: -## 场景 2: 向现有表添加物化视图 {#scenario-2-adding-materialized-views-to-existing-tables} +## 场景 2:向现有表添加物化视图 {#scenario-2-adding-materialized-views-to-existing-tables} -在需要向已填充大量数据以及正在插入数据的设置中添加新物化视图并不罕见。这里可使用时间戳或单调递增的列来识别流中的某个点,这有助于避免数据插入的暂停。在下面的示例中,我们假设这两种情况,倾向于选择避免暂停的插入方法。 +向已经填充了大量数据且数据正在插入的设置中添加新的物化视图并不少见。时间戳或单调递增列的存在,可以用来识别流中的某个点,这在这里非常有用,避免数据插入暂停。在下面的示例中,我们假设两种情况,优先考虑避免插入过程中的暂停的方法。 :::note 避免使用 POPULATE -我们不建议使用 [`POPULATE`](/sql-reference/statements/create/view#materialized-view) 命令来回填物化视图,除非是暂停插入的小数据集。此操作符可能会错过插入到其源表的行,物化视图是在 populate hash 完成后创建的。此外,此 populate 将对所有数据运行,且在大数据集上容易受到中断或内存限制的影响。 +我们不建议使用[`POPULATE`](/sql-reference/statements/create/view#materialized-view)命令对物化视图进行回填,除非数据集较小并且 ingest 暂停。该操作符可能会错过插入到其源表中的行,并且物化视图的创建在 populate 哈希完成之后。此外,此 populate 会针对所有数据执行,并且在大型数据集上容易受到中断或内存限制的影响。 ::: ### 可用时间戳或单调递增列 {#timestamp-or-monotonically-increasing-column-available} -在这种情况下,我们建议新的物化视图包含一个过滤器,将行限制为未来任意数据的值。然后可以使用来自主表的历史数据从此日期回填物化视图。回填方法依赖于数据大小和相关查询的复杂性。 +在这种情况下,我们建议新的物化视图包含一个过滤器,将行限制为大于未来的任意数据。此后,这个物化视图可以使用来自主表的历史数据从该日期进行回填。回填方法取决于数据大小和相关查询的复杂性。 -我们最简单的方法包括以下步骤: +我们最简单的方法涉及以下步骤: -1. 创建我们的物化视图,并加上一个仅考虑任意近期时间之后的行的过滤器。 -2. 运行一个 `INSERT INTO SELECT` 查询,该查询向物化视图的目标表插入数据,读取源表与视图的聚合查询。 +1. 创建我们的物化视图,过滤器只考虑大于近未来任意时间的行。 +2. 运行一个 `INSERT INTO SELECT` 查询,将数据插入到物化视图的目标表,从源表读取带有视图聚合查询的数据。 -这可以进一步增强以在步骤 (2) 中针对数据子集,和/或使用物化视图的重复目标表(在插入完成后将分区附加到原始表)以便于故障后的恢复。 +这可以进一步增强,以便在步骤(2)中针对数据的子集进行处理和/或使用物化视图的副本目标表(在插入完成后将分区附加到原始表)以便于故障后恢复。 -考虑以下物化视图,它计算每小时最受欢迎的项目。 +考虑以下物化视图,计算每小时最受欢迎的项目。 ```sql CREATE TABLE pypi_downloads_per_day @@ -355,7 +355,6 @@ CREATE TABLE pypi_downloads_per_day ENGINE = SummingMergeTree ORDER BY (project, hour) - CREATE MATERIALIZED VIEW pypi_downloads_per_day_mv TO pypi_downloads_per_day AS SELECT toStartOfHour(timestamp) as hour, @@ -367,20 +366,20 @@ GROUP BY project ``` -虽然我们可以添加目标表,但在添加物化视图之前,我们修改其 `SELECT` 子句,以包含一个仅考虑任意未来时间后行的过滤器 - 在这种情况下我们假设 `2024-12-17 09:00:00` 是几分钟后的时间。 +虽然我们可以添加目标表,但在添加物化视图之前,我们修改其 `SELECT` 子句以包含一个过滤器,仅考虑大于近未来的任意时间的行 - 在这种情况下,我们假设 `2024-12-17 09:00:00` 是几分钟之后的时间。 ```sql CREATE MATERIALIZED VIEW pypi_downloads_per_day_mv TO pypi_downloads_per_day AS SELECT - toStartOfHour(timestamp) as hour, + toStartOfHour(timestamp) AS hour, project, count() AS count FROM pypi WHERE timestamp >= '2024-12-17 09:00:00' GROUP BY hour, project ``` -一旦添加了此视图,我们就可以在此数据之前回填物化视图的所有数据。 +一旦这个视图被添加,我们可以为物化视图回填在此数据之前的所有数据。 -完成此操作最简单的方法是简单地在主表上运行物化视图的查询,并加上过滤以忽略最近添加的数据,通过 `INSERT INTO SELECT` 将结果插入到我们视图的目标表。例如,对于上面的视图: +执行此操作最简单的方法是直接在主表上运行物化视图查询,使用过滤器忽略最近添加的数据,并通过 `INSERT INTO SELECT` 将结果插入到视图的目标表中。例如,对于上述视图: ```sql INSERT INTO pypi_downloads_per_day SELECT @@ -400,29 +399,29 @@ Peak memory usage: 543.71 MiB. ``` :::note -在上述示例中,我们的目标表是 [SummingMergeTree](/engines/table-engines/mergetree-family/summingmergetree)。在这种情况下,我们可以直接使用原始聚合查询。对于更复杂的用例,这些用例利用 [AggregatingMergeTree](/engines/table-engines/mergetree-family/aggregatingmergetree),用户将使用 `-State` 函数进行汇总。对此的示例可以在 [这里](/integrations/s3/performance#be-aware-of-merges) 找到。 +在上面的示例中,我们的目标表是一个[SummingMergeTree](/engines/table-engines/mergetree-family/summingmergetree)。在这种情况下,我们可以简单地使用原始聚合查询。对于利用[AggregatingMergeTree](/engines/table-engines/mergetree-family/aggregatingmergetree)的更复杂用例,用户将使用 `-State` 函数来处理聚合。相关示例可以在[此处]( /integrations/s3/performance#be-aware-of-merges)找到。 ::: -在我们的案例中,这是相对轻量级的聚合,完成时间少于 3 秒,使用内存少于 600MiB。对于更复杂或运行时间较长的聚合,用户可以通过使用早期的重复表方法来增强此过程,即创建一个影子目标表,例如 `pypi_downloads_per_day_v2`,将数据插入这个表,并将其生成的分区附加到 `pypi_downloads_per_day`。 +在我们的案例中,这是一个相对轻量的聚合,完成时间小于 3 秒,并且使用的内存少于 600MiB。对于更复杂或运行时间更长的聚合,用户可以使用早期的副本表方法使得此过程更加完善,即创建一个影子目标表,例如 `pypi_downloads_per_day_v2`,将数据插入到该表,然后将其结果分区附加到 `pypi_downloads_per_day`。 -物化视图的查询往往可以更复杂(这并不少见,否则用户就不会使用视图了!)并消耗资源。在更少见的情况下,查询所需的资源超出了服务器的承载能力。这凸显了 ClickHouse 物化视图的一大优势 - 它们是增量的,不会一次性处理整个数据集! +物化视图的查询通常会更复杂(否则用户不会使用视图!)并且消耗资源。在更少见的情况下,查询所需的资源超出了服务器的限制。这突显了 ClickHouse 物化视图的优势 - 它们是增量的,不会一次性处理整个数据集! -在这种情况下,用户有几种选择: +在这种情况下,用户有几个选项: -1. 修改查询以回填范围,例如 `WHERE timestamp BETWEEN 2024-12-17 08:00:00 AND 2024-12-17 09:00:00`,`WHERE timestamp BETWEEN 2024-12-17 07:00:00 AND 2024-12-17 08:00:00` 等。 -2. 使用 [Null 表引擎](/engines/table-engines/special/null) 来填充物化视图。这模拟了物化视图的典型增量填充,在数据块(可配置大小)上执行查询。 +1. 修改查询以按范围回填,例如 `WHERE timestamp BETWEEN 2024-12-17 08:00:00 AND 2024-12-17 09:00:00`,`WHERE timestamp BETWEEN 2024-12-17 07:00:00 AND 2024-12-17 08:00:00` 等。 +2. 使用[Null 表引擎](/engines/table-engines/special/null)填充物化视图。这复制了物化视图的典型增量填充,在指定大小的数据块上执行其查询。 -(1)代表了最简单的方法,通常就足够了。为了简洁起见,我们不提供示例。 +(1)代表最简单的方法,通常是足够的。为了简洁,我们不提供示例。 -我们下面进一步探讨(2)。 +我们在下面进一步探讨(2)。 #### 使用 Null 表引擎填充物化视图 {#using-a-null-table-engine-for-filling-materialized-views} -[Null 表引擎](/engines/table-engines/special/null) 提供了一种不持久化数据的存储引擎(想象它是表引擎世界的 `/dev/null`)。尽管这似乎矛盾,但物化视图仍会在插入到此表引擎的数据上执行。这允许在不持久化原始数据的情况下构建物化视图,避免了输入输出及相关存储。 +[Null 表引擎](/engines/table-engines/special/null)提供了一种不持久化数据的存储引擎(将其视为表引擎世界中的 `/dev/null`)。虽然这看起来矛盾,但物化视图仍将在插入到此表引擎中的数据上执行。这允许在不持久化原始数据的情况下构建物化视图 - 避免了 I/O 和相关存储。 -重要的是,任何附着到表引擎的物化视图仍然会在其插入的数据块上执行 - 将结果发送到目标表。这些块的大小是可配置的。虽然较大的块可能在效率上更高(处理更快),但它们消耗的资源(主要是内存)也更多。使用此表引擎意味着我们可以逐步增量构建物化视图,即一次一个块,避免将整个聚合保持在内存中。 +重要的是,任何附加到表引擎的物化视图在插入时仍会针对块的数据执行 - 将其结果发送到目标表。这些块的大小是可配置的。虽然较大的块可能更有效(并且处理速度更快),但它们会消耗更多资源(主要是内存)。使用此表引擎意味着我们可以逐块增量构建物化视图,避免需要将整个聚合保留在内存中。 -ClickHouse 中的去规范化 +ClickHouse 中的去标准化
@@ -447,13 +446,13 @@ GROUP BY project ``` -在此,我们创建一个 Null 表 `pypi_v2`,以接收将用于构建物化视图的行。请注意,我们将模式限制为仅包括所需的列。我们的物化视图对插入到此表的数据(一次一个块)执行聚合,将结果发送到我们的目标表 `pypi_downloads_per_day`。 +在这里,我们创建了一个 Null 表 `pypi_v2`,以接收将用于构建物化视图的行。请注意,我们将模式限制为仅需的列。我们的物化视图在插入到此表的行上进行聚合(逐块),并将结果发送到我们的目标表 `pypi_downloads_per_day`。 :::note -我们在此使用 `pypi_downloads_per_day` 作为目标表。为了增加弹性,用户可以创建重复表 `pypi_downloads_per_day_v2`,并将其用作视图的目标表,如前面示例中所示。在插入完成后,`pypi_downloads_per_day_v2` 中的分区可以反过来移动到 `pypi_downloads_per_day`。这将允许在由于内存问题或服务器中断而导致插入失败的情况下进行恢复,即我们只需截断 `pypi_downloads_per_day_v2`,调整设置,然后重试。 +我们在这里使用 `pypi_downloads_per_day` 作为我们的目标表。为了增加鲁棒性,用户可以创建一个副本表 `pypi_downloads_per_day_v2`,并将其用作视图的目标表,如前面的示例所示。在插入完成后,`pypi_downloads_per_day_v2` 中的分区可以再移动到 `pypi_downloads_per_day`。这样可以在因内存问题或服务器中断导致插入失败的情况下进行恢复,即我们只需截断 `pypi_downloads_per_day_v2`,调整设置,然后重试。 ::: -要填充这个物化视图,我们只需将相关数据从 `pypi.` 插入到 `pypi_v2` 中进行回填。 +要填充此物化视图,我们只需将相关数据从 `pypi` 插入到 `pypi_v2`。 ```sql INSERT INTO pypi_v2 SELECT timestamp, project FROM pypi WHERE timestamp < '2024-12-17 09:00:00' @@ -462,20 +461,20 @@ INSERT INTO pypi_v2 SELECT timestamp, project FROM pypi WHERE timestamp < '2024- Peak memory usage: 639.47 MiB. ``` -请注意,我们的内存使用为 `639.47 MiB`。 +注意这里我们的内存使用为 `639.47 MiB`。 -##### 调整性能和资源 {#tuning-performance--resources} +##### 调整性能与资源 {#tuning-performance--resources} -几个因素将决定上述场景中的性能和资源使用情况。在尝试调整之前,我们建议读者了解在 [优化 S3 插入和读取性能指南](/integrations/s3/performance) 的 [使用线程进行读取](/integrations/s3/performance#using-threads-for-reads) 部分详细记录的插入机制。简而言之: +几个因素将决定上述场景中的性能和资源使用。在尝试进行调整之前,我们建议读者了解[优化 S3 插入和读取性能指南](/integrations/s3/performance)中详细记录的插入机制。总结如下: -- **读取并行性** - 用于读取的线程数。通过 [`max_threads`](/operations/settings/settings#max_threads) 控制。在 ClickHouse Cloud 中,这取决于实例大小,默认为 vCPUs 的数量。增加该值可能会提高读取性能,但会增加内存使用。 -- **插入并行性** - 用于插入的线程数。通过 [`max_insert_threads`](/operations/settings/settings#max_insert_threads) 控制。在 ClickHouse Cloud 中,这由实例大小(在 2 到 4 之间)确定,在 OSS 中设置为 1。增加该值可能会提高性能,但会增加内存使用。 -- **插入块大小** - 数据在一个循环中被处理,在此过程中数据被拉取、解析并形成内存中的插入块,基于 [分区键](/engines/table-engines/mergetree-family/custom-partitioning-key)。这些块会被排序、优化、压缩,并作为新的 [数据部分](/parts) 写入存储。插入块的大小由设置 [`min_insert_block_size_rows`](/operations/settings/settings#min_insert_block_size_rows) 和 [`min_insert_block_size_bytes`](/operations/settings/settings#min_insert_block_size_bytes)(未压缩)控制,影响内存使用和磁盘 I/O。较大的块使用更多内存,但创建更少的部分,从而减少 I/O 和后台合并。这些设置表示最小阈值(达到第一个的触发刷新)。 -- **物化视图块大小** - 除了上述主插入机制,在插入到物化视图之前,块也会被压缩以提高处理效率。这些块的大小由设置 [`min_insert_block_size_bytes_for_materialized_views`](/operations/settings/settings#min_insert_block_size_bytes_for_materialized_views) 和 [`min_insert_block_size_rows_for_materialized_views`](/operations/settings/settings#min_insert_block_size_rows_for_materialized_views) 决定。较大的块会以较大的内存使用换取更高效的处理。默认情况下,这些设置会恢复到源表设置 [`min_insert_block_size_rows`](/operations/settings/settings#min_insert_block_size_rows) 和 [`min_insert_block_size_bytes`](/operations/settings/settings#min_insert_block_size_bytes) 的值。 +- **读取并行性** - 用于读取的线程数量。通过[`max_threads`](/operations/settings/settings#max_threads) 控制。在 ClickHouse Cloud 中,此值由实例大小决定,默认为 vCPUs 的数量。增加该值可能会提高读取性能,但会以更大的内存使用为代价。 +- **插入并行性** - 用于插入的线程数量。通过[`max_insert_threads`](/operations/settings/settings#max_insert_threads) 控制。在 ClickHouse Cloud 中,此值由实例大小(介于 2 和 4 之间)决定,在 OSS 中设为 1。增加该值可能会提高性能,但会以更大的内存使用为代价。 +- **插入块大小** - 数据以循环方式处理,其中数据被拉取、解析,并根据[分区键](/engines/table-engines/mergetree-family/custom-partitioning-key)形成内存中的插入块。这些块会被排序、优化、压缩并作为新的[data parts](/parts) 写入存储。插入块的大小,通过设置[`min_insert_block_size_rows`](/operations/settings/settings#min_insert_block_size_rows)和[`min_insert_block_size_bytes`](/operations/settings/settings#min_insert_block_size_bytes)(未压缩)控制,影响内存使用和磁盘 I/O。较大的块使用更多内存,但创建的部分更少,从而减少 I/O 和后台合并。这些设置表示最小阈值(无论哪个先达到触发刷新)。 +- **物化视图块大小** - 除了主插入的上述机制,在插入物化视图之前,块也会被压缩以实现更高效的处理。这些块的大小由设置[`min_insert_block_size_bytes_for_materialized_views`](/operations/settings/settings#min_insert_block_size_bytes_for_materialized_views) 和 [`min_insert_block_size_rows_for_materialized_views`](/operations/settings/settings#min_insert_block_size_rows_for_materialized_views) 决定。较大的块在资源使用上会更高效。默认情况下,这些设置将回退到源表设置[`min_insert_block_size_rows`](/operations/settings/settings#min_insert_block_size_rows) 和 [`min_insert_block_size_bytes`](/operations/settings/settings#min_insert_block_size_bytes) 的值。 -为了提高性能,用户可以遵循在 [优化 S3 插入和读取性能指南](/integrations/s3/performance) 的 [调整线程和插入块大小](/integrations/s3/performance#tuning-threads-and-block-size-for-inserts) 部分中概述的准则。在大多数情况下,不需要同时修改 `min_insert_block_size_bytes_for_materialized_views` 和 `min_insert_block_size_rows_for_materialized_views` 来提高性能。如果必须修改,则使用与 `min_insert_block_size_rows` 和 `min_insert_block_size_bytes` 讨论的相同最佳实践。 +为了提高性能,用户可以遵循在[优化 S3 插入和读取性能指南](/integrations/s3/performance#tuning-threads-and-block-size-for-inserts)中列出的指导原则。在大多数情况下,不需要修改 `min_insert_block_size_bytes_for_materialized_views` 和 `min_insert_block_size_rows_for_materialized_views` 也可提升性能。如果要修改,使用与 `min_insert_block_size_rows` 和 `min_insert_block_size_bytes` 讨论的最佳实践相同。 -为了最小化内存使用,用户可能希望尝试调整这些设置。这将不可避免地降低性能。使用之前的查询,我们在下面展示示例。 +为了最小化内存使用,用户可能希望尝试这些设置,这无疑会降低性能。使用之前的查询,我们在下面展示了一些示例。 将 `max_insert_threads` 降低到 1 可以减少我们的内存开销。 @@ -492,7 +491,7 @@ SETTINGS max_insert_threads = 1 Peak memory usage: 506.78 MiB. ``` -我们可以通过将 `max_threads` 设置降低到 1,进一步减少内存。 +我们可以通过将 `max_threads` 设置降低到 1 进一步降低内存。 ```sql INSERT INTO pypi_v2 @@ -507,7 +506,7 @@ Ok. Peak memory usage: 272.53 MiB. ``` -最后,我们可以通过将 `min_insert_block_size_rows` 设置为 0(禁用它作为块大小的决定因素)和将 `min_insert_block_size_bytes` 设置为 10485760(10MiB),进一步减少内存使用。 +最后,我们可以通过将 `min_insert_block_size_rows` 设置为 0(禁用其作为块大小的决定因素)和 `min_insert_block_size_bytes` 设置为 10485760(10MiB)来进一步降低内存使用。 ```sql INSERT INTO pypi_v2 @@ -522,20 +521,20 @@ SETTINGS max_insert_threads = 1, max_threads = 1, min_insert_block_size_rows = 0 Peak memory usage: 218.64 MiB. ``` -最后,请注意,降低块大小会产生更多部分并造成更大的合并压力。如 [这里](https://integrations/s3/performance#be-aware-of-merges) 讨论的,这些设置应谨慎修改。 +最后,请注意,降低块大小会产生更多部分,并造成更大的合并压力。如前所述[这里](/integrations/s3/performance#be-aware-of-merges),这些设置应谨慎更改。 ### 没有时间戳或单调递增列 {#no-timestamp-or-monotonically-increasing-column} -上述过程依赖于用户拥有时间戳或单调递增的列。在某些情况下,这些信息根本不可用。在这种情况下,我们建议采用以下过程,该过程利用了之前概述的许多步骤,但需要用户暂停插入。 +上述过程依赖于用户有时间戳或单调递增列。在某些情况下,这根本不可用。在这种情况下,我们建议采用以下过程,利用之前概述的许多步骤,但需要用户暂停插入。 -1. 暂停主表的插入。 -2. 使用 `CREATE AS` 语法创建主目标表的重复表。 -3. 使用 [`ALTER TABLE ATTACH`](/sql-reference/statements/alter/partition#attach-partitionpart) 将原始目标表的分区附加到重复表中。**注意:** 此附加操作与之前使用的移动操作不同。虽然依赖于硬链接,但保留了原始表中的数据。 +1. 暂停对主表的插入。 +2. 使用 `CREATE AS` 语法创建主目标表的副本。 +3. 使用[`ALTER TABLE ATTACH`](/sql-reference/statements/alter/partition#attach-partitionpart) 将原目标表的分区附加到副本。**注意:** 此附加操作与之前使用的移动不同。虽然依赖于硬链接,但保留了原表中的数据。 4. 创建新的物化视图。 -5. 重新启动插入。**注意:** 插入只会更新目标表,而不会更新重复表,后者仅引用原始数据。 -6. 回填物化视图,使用上述针对时间戳的数据使用的相同流程,以重复表作为源。 +5. 重启插入。**注意:** 插入仅会更新目标表,而不会更新副本,该副本将仅引用原始数据。 +6. 回填物化视图,应用上述时间戳数据使用的相同过程,使用副本表作为源。 -考虑使用 PyPI 和我们之前的新物化视图 `pypi_downloads_per_day` 的以下示例(我们假设不能使用时间戳): +考虑使用 PyPI 及我们先前的新物化视图 `pypi_downloads_per_day` 的以下示例(我们假设无法使用时间戳): ```sql SELECT count() FROM pypi @@ -575,7 +574,6 @@ CREATE TABLE pypi_downloads_per_day ENGINE = SummingMergeTree ORDER BY (project, hour) - CREATE MATERIALIZED VIEW pypi_downloads_per_day_mv TO pypi_downloads_per_day AS SELECT toStartOfHour(timestamp) as hour, @@ -623,6 +621,6 @@ GROUP BY DROP TABLE pypi_v2; ``` -在倒数第二个步骤中,我们使用简单的 `INSERT INTO SELECT` 方法回填 `pypi_downloads_per_day`,如 [之前](#timestamp-or-monotonically-increasing-column-available) 所述。这也可以使用上述文档中的 Null 表方法增强,并可选择使用重复表以增加弹性。 +在倒数第二步中,我们使用之前描述的简单 `INSERT INTO SELECT` 方法回填 `pypi_downloads_per_day`。此外,还可以使用上面描述的 Null 表方法进行增强,选择性地使用副本表以增强鲁棒性。 -尽管此操作确实需要暂停插入,但中间操作通常可以快速完成 - 最小化任何数据中断。 +虽然此操作确实需要暂停插入,但中间操作通常可以快速完成 - 从而最小化任何数据中断。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/data-modeling/backfilling.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/data-modeling/backfilling.md.hash index 38fe08d3514..9e42d88ae50 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/data-modeling/backfilling.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/data-modeling/backfilling.md.hash @@ -1 +1 @@ -2948e8a5e5955808 +c2c821e1ba38bd0a diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/data-modeling/denormalization.md b/i18n/zh/docusaurus-plugin-content-docs/current/data-modeling/denormalization.md index 5580364e745..e52af542eab 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/data-modeling/denormalization.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/data-modeling/denormalization.md @@ -1,11 +1,12 @@ --- 'slug': '/data-modeling/denormalization' -'title': '去规范化数据' -'description': '如何使用去规范化来提高 Query 性能' +'title': '反规范化数据' +'description': '如何利用反规范化来提高查询性能' 'keywords': - 'data denormalization' - 'denormalize' - 'query optimization' +'doc_type': 'guide' --- import denormalizationDiagram from '@site/static/images/data-modeling/denormalization-diagram.png'; @@ -13,63 +14,63 @@ import denormalizationSchema from '@site/static/images/data-modeling/denormaliza import Image from '@theme/IdealImage'; -# 数据非规范化 +# 非规范化数据 -数据非规范化是 ClickHouse 中的一种技术,利用扁平化表格帮助最小化查询延迟,从而避免连接操作。 +数据非规范化是 ClickHouse 中的一种技术,通过使用扁平化的表格来尽量减少查询延迟,从而避免连接操作。 ## 比较规范化与非规范化模式 {#comparing-normalized-vs-denormalized-schemas} -数据非规范化涉及故意逆转规范化过程,以优化数据库在特定查询模式下的性能。在规范化数据库中,数据分为多个相关表,以最小化冗余并确保数据完整性。非规范化通过合并表格、复制数据和将计算字段合并到一个或更少的表中重新引入冗余 - 有效地将任何连接操作从查询时间移至插入时间。 +非规范化数据涉及故意逆转规范化过程,以针对特定查询模式优化数据库性能。在规范化数据库中,数据被拆分为多个相关表,以最小化冗余并确保数据完整性。非规范化通过组合表、重复数据和将计算字段合并到单一表或较少的表中重新引入冗余——有效地将任何连接从查询时间移至插入时间。 -此过程减少了在查询时对复杂连接的需求,并且可以显著加快读取操作,使其非常适合具有重读需求和复杂查询的应用程序。然而,这可能会增加写入操作和维护的复杂性,因为对复制数据的任何更改必须在所有实例之间传播以保持一致性。 +该过程减少了查询时对复杂连接的需求,并能够显著加快读取操作,非常适合具有重读要求和复杂查询的应用程序。然而,它可能会增加写操作和维护的复杂性,因为对重复数据的任何更改必须在所有实例中传播以保持一致性。 ClickHouse中的非规范化
-一种被 NoSQL 解决方案推广的常见技术是在没有 `JOIN` 支持的情况下进行数据非规范化,有效地将所有统计信息或相关行存储在父行的列和嵌套对象中。例如,在一个博客的示例模式中,我们可以将所有 `Comments` 存储为其各自帖子的对象数组。 +一种流行的技术是,在没有 `JOIN` 支持的情况下进行数据非规范化,有效地将所有统计信息或相关行存储为列和嵌套对象,作为父行的一部分。例如,在一个博客的示例模式中,我们可以将所有 `Comments` 作为对象的 `Array` 存储在各自的帖子上。 ## 何时使用非规范化 {#when-to-use-denormalization} -一般来说,我们推荐在以下情况下进行非规范化: +一般而言,我们建议在以下情况下进行非规范化: -- 非规范化那些变化不频繁的表,或者可以容忍数据在分析查询前延迟可用的情况,即数据可以在一个批次中完全重新加载。 -- 避免对多对多关系进行非规范化。如果一个源行发生变化,可能会导致需要更新多个行。 -- 避免对高基数关系进行非规范化。如果表中的每一行在另一个表中有数千个相关条目,则需要将其表示为一个 `Array` - 要么是原始类型,要么是元组。一般来说,不推荐有超过1000个元组的数组。 -- 与其将所有列作为嵌套对象进行非规范化,可以考虑仅使用物化视图对统计数据进行非规范化(见下文)。 +- 非规范化不经常变化的表,或在等待数据可用于分析查询时可以容忍延迟的情况,即数据可以在批处理中完全重新加载。 +- 避免非规范化多对多关系。这可能会导致在单个源行更改时需要更新许多行。 +- 避免非规范化高基数关系。如果表中的每一行在另一张表中都有成千上万的相关条目,这些条目需要用 `Array` 表示——可以是原始类型或元组。通常,不建议使用超过 1000 个元组的数组。 +- 与其将所有列作为嵌套对象非规范化,不如考虑使用物化视图非规范化仅一个统计信息(见下文)。 -并非所有的信息都需要非规范化 - 只需经常访问的关键信息即可。 +并非所有信息都需要非规范化——只需非规范化需要频繁访问的关键信息。 -非规范化的工作可以在 ClickHouse 或上游处理,例如使用 Apache Flink。 +非规范化的工作可以在 ClickHouse 中或上游处理,例如使用 Apache Flink。 -## 避免对频繁更新的数据进行非规范化 {#avoid-denormalization-on-frequently-updated-data} +## 避免在频繁更新的数据上进行非规范化 {#avoid-denormalization-on-frequently-updated-data} -对于 ClickHouse,非规范化是用户可以用来优化查询性能的几种选项之一,但应谨慎使用。如果数据更新频繁并需要接近实时更新,则应避免使用此方法。如果主表大多是仅追加的,或者可以定期批量重新加载(例如每天),则可以使用。 +对于 ClickHouse,非规范化是用户可以用来优化查询性能的几种选项之一,但应该谨慎使用。如果数据频繁更新并且需要近实时更新,则应该避免这种方法。如果主表主要是仅追加的,或可以定期作为批量重新加载,例如每日,那么可以使用这种方法。 -作为一种方法,它面临一个主要的挑战 - 写入性能和更新数据。更具体地说,非规范化有效地将数据连接的责任从查询时间转移到摄取时间。虽然这可以显著提高查询性能,但它使摄取过程变得复杂,这意味着如果用于组成它的任何行发生更改,数据管道需要在 ClickHouse 中重新插入一行。这可能意味着一个源行的更改可能需要在 ClickHouse 中更新许多行。在复杂的模式中,当行是由复杂的连接组成时,连接中的嵌套组件中的单一行更改可能意味着需要更新数百万行。 +这种方法面临一个主要挑战——写入性能和数据更新。更具体地说,非规范化事实上将数据连接的责任从查询时间转移到了摄取时间。虽然这可以显著提高查询性能,但它使摄取变得复杂,并且意味着如果任何用于组成该行的行发生变化,数据管道需要重新将该行插入 ClickHouse。这意味着,源行的一个变化可能意味着 ClickHouse 中需要更新许多行。在复杂的模式中,当行是从复杂的连接组合而成时,连接中的一个嵌套组件的单个行更改可能意味着需要更新数百万行。 -实时实现这一点通常是不切实际的,并且由于以下两个挑战而需要大量工程: +在实时实现这一点通常是不切实际的,并且由于两个挑战需要大量的工程: -1. 当表行发生更改时,触发正确的连接语句。理想情况下,这不应导致连接的所有对象都被更新,而仅为受到影响的对象。有效地修改连接以过滤到正确的行,并在高吞吐量下实现这一点,需要外部工具或工程。 -2. ClickHouse 中的行更新需要小心管理,使其复杂性增加。 +1. 当表行发生变化时,触发正确的连接语句。这理想情况下不应导致连接的所有对象都被更新,而应该仅仅更新那些受影响的对象。有效地修改连接以过滤到正确的行,并在高吞吐量下实现这一点,需要外部工具或工程。 +2. 在 ClickHouse 中更新行需要精心管理,引入了额外的复杂性。
-因此,批量更新过程更为常见,其中所有的非规范化对象会定期重新加载。 +因此,批更新过程更为常见,在此过程中,所有的非规范化对象都定期重新加载。 ## 非规范化的实际案例 {#practical-cases-for-denormalization} -让我们考虑一些实际示例,在这些示例中,非规范化可能是合适的,而其他情况下则更希望采用替代方法。 +让我们考虑几个可能使非规范化有意义的实际示例,以及其他一些更可取的替代方法。 -考虑一个已经用统计信息(如 `AnswerCount` 和 `CommentCount`)进行了非规范化的 `Posts` 表 - 源数据以这种形式提供。实际上,我们可能希望规范化这些信息,因为它很可能会频繁变化。许多这些列也可以通过其他表访问,例如可以通过 `PostId` 列和 `Comments` 表获取帖子的评论。为了方便示例,我们假设帖子是通过批处理过程重新加载的。 +考虑一个已经包含统计信息,例如 `AnswerCount` 和 `CommentCount` 的 `Posts` 表——源数据以这种形式提供。实际上,我们可能反而想要规范化这些信息,因为它们可能会频繁更改。这些列中的许多也可以通过其他表获得,例如,一个帖子的评论可以通过 `PostId` 列和 `Comments` 表获得。为了示例的目的,我们假设帖子是在批处理过程中重新加载的。 -我们还只考虑将其他表非规范化到 `Posts` 上,因为我们认为这是我们分析的主表。朝相反方向非规范化对于某些查询此时也是合适的,应用上述相同的考虑。 +我们还只考虑将其他表非规范化到 `Posts`,因为我们视其为分析的主表。非规范化到其他方向针对某些查询也是合适的,以上述相同的考虑适用。 -*对于以下每个示例,假设存在一个需要在连接中使用两个表的查询。* +*在以下每个示例中,假设存在一个需要两个表进行连接的查询。* ### 帖子和投票 {#posts-and-votes} -帖子投票被表示为单独的表。优化的模式如下所示,以及加载数据的插入命令: +帖子的投票作为单独的表表示。优化的模式如下所示,以及加载数据的插入命令: ```sql CREATE TABLE votes @@ -89,9 +90,9 @@ INSERT INTO votes SELECT * FROM s3('https://datasets-documentation.s3.eu-west-3. 0 rows in set. Elapsed: 26.272 sec. Processed 238.98 million rows, 2.13 GB (9.10 million rows/s., 80.97 MB/s.) ``` -乍一看,这些可能是非规范化在帖子表上的候选对象。这种方法有几个挑战。 +乍一看,这些可能是帖子表的非规范化候选者。然而,这种方法面临一些挑战。 -投票经常被添加到帖子中。虽然这可能会随着时间的推移而在每个帖子上减少,但以下查询显示我们在 30k 帖子上每小时有大约 40k 次投票。 +投票经常添加到帖子上。虽然这可能随着时间的推移而减少,但以下查询显示我们在 3 万篇帖子上每小时大约有 4 万次投票。 ```sql SELECT round(avg(c)) AS avg_votes_per_hr, round(avg(posts)) AS avg_posts_per_hr @@ -110,9 +111,9 @@ FROM └──────────────────┴──────────────────┘ ``` -如果可以容忍延迟,可以通过批量处理来解决此问题,但这仍要求我们处理更新,除非我们定期重新加载所有帖子(这不太可能是可取的)。 +如果可以容忍延迟,这可以通过批处理解决,但这仍然需要我们处理更新,除非我们定期重新加载所有帖子(这不太可能是理想选择)。 -更麻烦的是,有些帖子有极高数量的投票: +更麻烦的是,一些帖子有极高的投票数: ```sql SELECT PostId, concat('https://stackoverflow.com/questions/', PostId) AS url, count() AS c @@ -130,7 +131,7 @@ LIMIT 5 └──────────┴──────────────────────────────────────────────┴───────┘ ``` -这里的主要观察是,对于大多数分析,聚合的每个帖子的投票统计信息就足够了 - 我们不需要对所有投票信息进行非规范化。例如,当前的 `Score` 列表示这样的统计信息,即总上票数减去下票数。理想情况下,我们希望能够在查询时通过简单查找来检索这些统计信息(见 [字典](/dictionary))。 +主要观察是,对于大多数分析而言,聚合的投票统计信息对每个帖子的足够——我们没有必要非规范化所有投票信息。例如,当前的 `Score` 列表示这样的统计信息,即总的赞成票减去反对票。理想情况下,我们只需在查询时通过简单查找获取这些统计信息(见 [字典](/dictionary))。 ### 用户和徽章 {#users-and-badges} @@ -139,7 +140,7 @@ LIMIT 5 用户和徽章模式

-我们首先使用以下命令插入数据: +我们首先通过以下命令插入数据:

```sql @@ -184,7 +185,7 @@ INSERT INTO badges SELECT * FROM s3('https://datasets-documentation.s3.eu-west-3 0 rows in set. Elapsed: 18.126 sec. Processed 51.29 million rows, 797.05 MB (2.83 million rows/s., 43.97 MB/s.) ``` -虽然用户可能会频繁获得徽章,但这不太可能是我们需要每天更新的数据集。徽章和用户之间的关系是一对多关系。也许我们可以简单地将徽章作为元组列表非规范化到用户上?虽然可行,但快速检查每个用户的最大徽章数量表明这并不理想: +虽然用户可能频繁获得徽章,但这不太可能是我们需要每天更新的数据集。徽章和用户之间是一对多的关系。也许我们可以简单地将徽章作为元组列表非规范化到用户?虽然可行,但快速检查每位用户的徽章数量表明这并不理想: ```sql SELECT UserId, count() AS c FROM badges GROUP BY UserId ORDER BY c DESC LIMIT 5 @@ -198,13 +199,13 @@ SELECT UserId, count() AS c FROM badges GROUP BY UserId ORDER BY c DESC LIMIT 5 └────────┴───────┘ ``` -将 19k 对象非规范化到单行上可能不现实。这个关系最好保持为单独的表或者添加统计信息。 +将 19,000 个对象非规范化到单一行可能并不现实。这种关系最好保留为单独的表,或增加统计信息。 -> 我们可能希望将徽章的统计信息非规范化到用户上,例如徽章的数量。当在插入时使用字典处理该数据集时,我们考虑了这样的示例。 +> 我们可能希望将徽章的统计信息非规范化到用户,例如徽章数量。我们在插入此数据集时考虑使用字典的此类示例。 -### 帖子和帖子链接 {#posts-and-postlinks} +### 帖子和链接 {#posts-and-postlinks} -`PostLinks` 连接用户认为相关或重复的 `Posts`。以下查询显示模式和加载命令: +`PostLinks` 连接 `Posts`,用户认为它们是相关或重复的。以下查询显示模式和加载命令: ```sql CREATE TABLE postlinks @@ -223,7 +224,7 @@ INSERT INTO postlinks SELECT * FROM s3('https://datasets-documentation.s3.eu-wes 0 rows in set. Elapsed: 4.726 sec. Processed 6.55 million rows, 129.70 MB (1.39 million rows/s., 27.44 MB/s.) ``` -我们可以确认,没有帖子具有过多链接而阻止非规范化: +我们可以确认没有帖子有过多的链接,这阻碍了非规范化: ```sql SELECT PostId, count() AS c @@ -240,7 +241,7 @@ ORDER BY c DESC LIMIT 5 └──────────┴─────┘ ``` -同样,这些链接并不是频繁发生的事件: +同样,这些链接不是过于频繁发生的事件: ```sql SELECT @@ -261,11 +262,11 @@ FROM └──────────────────┴──────────────────┘ ``` -我们将其用作下面的非规范化示例。 +我们将此用作下面的非规范化示例。 ### 简单统计示例 {#simple-statistic-example} -在大多数情况下,非规范化需要将单个列或统计信息添加到父行。例如,我们可能仅希望用重复帖子数量丰富我们的帖子,我们只需添加一列。 +在大多数情况下,非规范化需要在父行上添加单个列或统计信息。例如,我们可能只是希望通过重复的帖子数量来丰富我们的帖子,只需添加一列。 ```sql CREATE TABLE posts_with_duplicate_count @@ -277,7 +278,7 @@ CREATE TABLE posts_with_duplicate_count ORDER BY (PostTypeId, toDate(CreationDate), CommentCount) ``` -为了填充此表,我们利用 `INSERT INTO SELECT` 将我们的重复统计与帖子连接。 +要填充该表,我们利用 `INSERT INTO SELECT` 将我们的重复统计信息与帖子连接。 ```sql INSERT INTO posts_with_duplicate_count SELECT @@ -292,18 +293,18 @@ LEFT JOIN ) AS postlinks ON posts.Id = postlinks.PostId ``` -### 利用复杂类型处理一对多关系 {#exploiting-complex-types-for-one-to-many-relationships} +### 利用复杂类型进行一对多关系 {#exploiting-complex-types-for-one-to-many-relationships} -为了执行非规范化,我们通常需要利用复杂类型。如果正在非规范化一对一关系,且列数较少,用户可以像上面那样简单地将这些作为原始类型的行添加。然而,对于较大的对象来说,这通常并不理想,并且对于一对多关系也是不可能的。 +为了执行非规范化,我们常常需要利用复杂类型。如果是低列数的一对一关系进行非规范化,用户可以简单地将这些行添加为其原始类型,如上所示。然而,对于较大的对象,这通常是不理想的,并且对于一对多关系则不可行。 在复杂对象或一对多关系的情况下,用户可以使用: -- 命名元组 - 这允许将相关结构表示为一组列。 -- Array(Tuple) 或 Nested - 一个命名元组的数组,也称为嵌套,其中每个条目表示一个对象。适用于一对多关系。 +- 命名元组 - 这些允许相关结构作为一组列表示。 +- Array(Tuple) 或 Nested - 一组命名元组的数组,也称为嵌套,每个条目表示一个对象。适用于一对多关系。 -作为示例,我们如下演示将 `PostLinks` 非规范化到 `Posts`。 +作为示例,我们在下面演示将 `PostLinks` 非规范化到 `Posts`。 -每个帖子可以包含多个指向其他帖子的链接,如之前 `PostLinks` 模式所示。作为嵌套类型,我们可以将这些链接和重复的帖子表示如下: +每个帖子可以包含指向其他帖子的多个链接,如先前的 `PostLinks` 模式所示。作为嵌套类型,我们可以如下表示这些链接和重复的帖子: ```sql SET flatten_nested=0 @@ -317,9 +318,9 @@ CREATE TABLE posts_with_links ORDER BY (PostTypeId, toDate(CreationDate), CommentCount) ``` -> 注意使用设置 `flatten_nested=0`。我们建议禁用嵌套数据的扁平化。 +> 请注意 `flatten_nested=0` 的设置。我们建议禁用嵌套数据的扁平化。 -我们可以使用 `INSERT INTO SELECT` 结合 `OUTER JOIN` 查询来执行此非规范化: +我们可以使用 `INSERT INTO SELECT` 和 `OUTER JOIN` 查询执行此非规范化: ```sql INSERT INTO posts_with_links @@ -340,11 +341,11 @@ LEFT JOIN ( Peak memory usage: 6.98 GiB. ``` -> 注意时间。我们已经在大约 2 分钟内非规范化了 66m 行。正如我们稍后看到的,这是我们可以安排的操作。 +> 请注意这里的时间。我们在大约 2 分钟内成功地非规范化了 6600 万行。如我们稍后将看到的,这是一个可以调度的操作。 -请注意,使用 `groupArray` 函数将 `PostLinks` 合并为每个 `PostId` 的数组,然后进行连接。该数组会过滤成两个子列表:`LinkedPosts` 和 `DuplicatePosts`,也排除外部连接的任何空结果。 +请注意使用 `groupArray` 函数将 `PostLinks` 合并为每个 `PostId` 的数组,随后进行连接。该数组然后被过滤为两个子列表:`LinkedPosts` 和 `DuplicatePosts`,同时也排除了来自外部连接的任何空结果。 -我们可以选择一些行以查看我们的新非规范化结构: +我们可以选择一些行,以查看我们新的非规范化结构: ```sql SELECT LinkedPosts, DuplicatePosts @@ -359,19 +360,19 @@ LinkedPosts: [('2017-04-11 11:53:09.583',3404508),('2017-04-11 11:49:07.680', DuplicatePosts: [('2017-04-11 12:18:37.260',3922739),('2017-04-11 12:18:37.260',33058004)] ``` -## 组织和调度非规范化 {#orchestrating-and-scheduling-denormalization} +## 协调和调度非规范化 {#orchestrating-and-scheduling-denormalization} ### 批处理 {#batch} -利用非规范化需要一个转换过程,可以在其中执行和组织。 +利用非规范化需要一个转换过程,在此过程中可以执行和协调它。 -我们已经展示了如何在 ClickHouse 中通过 `INSERT INTO SELECT` 执行此转换,一旦数据被加载。这适用于定期的批处理转换。 +我们在上面演示了如何在数据通过 `INSERT INTO SELECT` 加载后,使用 ClickHouse 执行此转换。这适用 于定期批量转换。 -假设可以接受定期批量加载过程,用户有几种在 ClickHouse 中组织此操作的选项: +用户在 ClickHouse 中协调此操作有几种选择,假设定期批处理加载过程是可接受的: -- **[可刷新的物化视图](/materialized-view/refreshable-materialized-view)** - 可刷新的物化视图可用于定期调度查询,并将结果发送到目标表中。在查询执行时,该视图确保目标表被原子性地更新。这为 ClickHouse 提供了一种本地调度此工作的方式。 -- **外部工具** - 使用工具例如 [dbt](https://www.getdbt.com/) 和 [Airflow](https://airflow.apache.org/) 定期调度转换。用于 dbt 的 [ClickHouse 集成](/integrations/dbt) 确保以原子方式执行此操作,并创建目标表的新版本,然后与接收查询的版本原子性交换(通过 [EXCHANGE](/sql-reference/statements/exchange) 命令)。 +- **[可刷新的物化视图](/materialized-view/refreshable-materialized-view)** - 可刷新的物化视图可用于定期调度查询,并将结果发送到目标表。在查询执行时,该视图确保目标表被原子性更新。这提供了 ClickHouse 原生调度此工作的方式。 +- **外部工具** - 利用 [dbt](https://www.getdbt.com/) 和 [Airflow](https://airflow.apache.org/) 等工具定期调度转换。 [ClickHouse与dbt的集成](/integrations/dbt) 确保此操作是原子性的,创建新版本的目标表,然后与接收查询的版本原子交换(通过 [EXCHANGE](/sql-reference/statements/exchange) 命令)。 -### 流处理 {#streaming} +### 流式处理 {#streaming} -用户可能还希望在 ClickHouse 之外进行此操作,在插入之前,使用流处理技术,例如 [Apache Flink](https://flink.apache.org/)。或者,可以使用增量的 [物化视图](/guides/developer/cascading-materialized-views) 在数据插入时执行此过程。 +用户可能还希望在 ClickHouse 之外进行此操作,插入前使用流式技术,例如 [Apache Flink](https://flink.apache.org/)。或者,还可以使用增量 [物化视图](/guides/developer/cascading-materialized-views) 在数据插入时执行此过程。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/data-modeling/denormalization.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/data-modeling/denormalization.md.hash index 40f92e8c310..72434d2bc2f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/data-modeling/denormalization.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/data-modeling/denormalization.md.hash @@ -1 +1 @@ -a4794c14228d845a +788705f1ba8d2f76 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/data-modeling/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/data-modeling/index.md index 1e89de96df5..eabb20cd0df 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/data-modeling/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/data-modeling/index.md @@ -9,18 +9,19 @@ - 'materialized view' - 'data compression' - 'denormalizing data' +'doc_type': 'landing-page' --- -# 数据建模 +# 数据建模 -本节关于 ClickHouse 中的数据建模,包含以下主题: +本节内容有关 ClickHouse 中的数据建模,包含以下主题: | 页面 | 描述 | -|-----------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| [模式设计](/data-modeling/schema-design) | 讨论 ClickHouse 的模式设计以实现最佳性能,考虑到查询、数据更新、延迟和数据量等因素。 | -| [字典](/dictionary) | 解释如何定义和使用字典以提高查询性能和丰富数据。 | -| [物化视图](/materialized-views) | 关于 ClickHouse 中物化视图和可刷新的物化视图的信息。 | -| [投影](/data-modeling/projections) | 关于 ClickHouse 中投影的信息。 | -| [数据压缩](/data-compression/compression-in-clickhouse) | 讨论 ClickHouse 中各种压缩模式,以及如何通过选择适合特定数据类型和工作负载的压缩方法来优化数据存储和查询性能。 | -| [非规范化数据](/data-modeling/denormalization) | 讨论 ClickHouse 中使用的非规范化方法,该方法旨在通过将相关数据存储在单个表中来提高查询性能。 | +|-----------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| [模式设计](/data-modeling/schema-design) | 讨论了 ClickHouse 的模式设计,以实现最佳性能,考虑查询、数据更新、延迟和数据量等因素。 | +| [字典](/dictionary) | 说明如何定义和使用字典以提高查询性能并丰富数据。 | +| [物化视图](/materialized-views) | 关于 ClickHouse 中的物化视图和可刷新的物化视图的信息。 | +| [投影](/data-modeling/projections) | 关于 ClickHouse 中投影的信息。 | +| [数据压缩](/data-compression/compression-in-clickhouse) | 讨论了 ClickHouse 中的各种压缩模式,以及如何通过选择适合特定数据类型和工作负载的压缩方法来优化数据存储和查询性能。 | +| [数据非规范化](/data-modeling/denormalization) | 讨论了 ClickHouse 中使用的非规范化方法,旨在通过将相关数据存储在单个表中来提高查询性能。 | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/data-modeling/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/data-modeling/index.md.hash index 557418b4a08..391c60e2a2d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/data-modeling/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/data-modeling/index.md.hash @@ -1 +1 @@ -ad46a332f2389db4 +a9d2cb36d4fbe724 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/data-modeling/projections.md b/i18n/zh/docusaurus-plugin-content-docs/current/data-modeling/projections.md deleted file mode 100644 index c4a36379c39..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/data-modeling/projections.md +++ /dev/null @@ -1,448 +0,0 @@ ---- -'slug': '/data-modeling/projections' -'title': '投影' -'description': '页面描述了什么是投影,它们如何用于提高查询性能,以及它们与物化视图的区别。' -'keywords': -- 'projection' -- 'projections' -- 'query optimization' ---- - -import projections_1 from '@site/static/images/data-modeling/projections_1.png'; -import projections_2 from '@site/static/images/data-modeling/projections_2.png'; -import Image from '@theme/IdealImage'; - - -# Projections - -## Introduction {#introduction} - -ClickHouse 提供了多种机制来加速对大量数据的分析查询,以满足实时场景的需求。其中一种加速查询的机制是通过使用 _Projections_。Projections 通过按感兴趣的属性重新排序数据来帮助优化查询。这可以是: - -1. 完整的重新排序 -2. 原始表的不同顺序子集 -3. 预计算的聚合(类似于物化视图),但订单与聚合对齐。 - -## How do Projections work? {#how-do-projections-work} - -实际上,Projection 可以被视为原始表的额外隐藏表。投影可以具有与原始表不同的行顺序,因此具有不同的主键索引,并且可以自动增量地预计算聚合值。因此,使用 Projections 为加速查询执行提供了两个“调节旋钮”: - -- **正确使用主键索引** -- **预计算聚合** - -不同程度上,Projections 类似于 [Materialized Views](/materialized-views),后者也允许您在插入时拥有多种行顺序和预计算聚合。Projections 会自动更新并与原始表保持同步,不同于需要显式更新的物化视图。当查询目标是原始表时,ClickHouse 会自动抽样主键并选择一个可以生成相同正确结果但要求读取的数据量最少的表,如下图所示: - -Projections in ClickHouse - -## When to use Projections? {#when-to-use-projections} - -Projections 是新用户一个非常吸引人的特性,因为它们在数据插入时会自动维护。此外,查询仅需发送到单个表,在可能的情况下利用 projections 来加速响应时间。 - -这与物化视图形成对比,后者用户需要根据过滤条件选择适当的优化目标表或重写他们的查询。这对用户应用程序的依赖性更大,并增加了客户端的复杂性。 - -尽管这些优点,projections 也有一些固有的限制,用户应该注意,因此应该谨慎使用。 - -- Projections 不允许为源表和(隐藏)目标表使用不同的 TTL,物化视图允许不同的 TTL。 -- Projections 目前不支持 `optimize_read_in_order` 用于(隐藏)目标表。 -- 对于带有 projections 的表,不支持轻量级更新和删除。 -- 物化视图可以链接:一个物化视图的目标表可以是另一个物化视图的源表,等等。这在 projections 中不可行。 -- Projections 不支持连接,但物化视图支持。 -- Projections 不支持过滤器(`WHERE` 子句),而物化视图支持。 - -我们建议在以下情况下使用 projections: - -- 需要对数据进行完整的重新排序。尽管投影中的表达式在理论上可以使用 `GROUP BY`,物化视图在维护聚合方面更为有效。查询优化器也更有可能利用使用简单重新排序的 projections,即 `SELECT * ORDER BY x`。用户可以在此表达式中选择一部分列以减少存储占用。 -- 用户能接受与之相关的存储占用增加和两次写入数据的开销。测试插入速度的影响并 [评估存储开销](/data-compression/compression-in-clickhouse)。 - -## Examples {#examples} - -### Filtering on columns which aren't in the primary key {#filtering-without-using-primary-keys} - -在此示例中,我们将向您展示如何向表中添加一个投影。我们还将查看如何使用投影加速过滤在表的主键中不存在的列的查询。 - -在此示例中,我们将使用位于 [sql.clickhouse.com](https://sql.clickhouse.com/) 的纽约出租车数据集,该数据集按 `pickup_datetime` 排序。 - -让我们写一个简单的查询以查找乘客给司机小费超过 200 美元的所有行程 ID: - -```sql runnable -SELECT - tip_amount, - trip_id, - dateDiff('minutes', pickup_datetime, dropoff_datetime) AS trip_duration_min -FROM nyc_taxi.trips WHERE tip_amount > 200 AND trip_duration_min > 0 -ORDER BY tip_amount, trip_id ASC -``` - -请注意,由于我们在 `ORDER BY` 中没有包含 `tip_amount` 进行过滤,ClickHouse 不得不进行全表扫描。让我们加速这个查询。 - -为了保留原始表和结果,我们将创建一个新表并使用 `INSERT INTO SELECT` 复制数据: - -```sql -CREATE TABLE nyc_taxi.trips_with_projection AS nyc_taxi.trips; -INSERT INTO nyc_taxi.trips_with_projection SELECT * FROM nyc_taxi.trips; -``` - -要添加投影,我们使用 `ALTER TABLE` 语句与 `ADD PROJECTION` 语句: - -```sql -ALTER TABLE nyc_taxi.trips_with_projection -ADD PROJECTION prj_tip_amount -( - SELECT * - ORDER BY tip_amount, dateDiff('minutes', pickup_datetime, dropoff_datetime) -) -``` - -添加投影后,有必要使用 `MATERIALIZE PROJECTION` 语句,以便数据按照上述指定查询的物理顺序重新写入: - -```sql -ALTER TABLE nyc.trips_with_projection MATERIALIZE PROJECTION prj_tip_amount -``` - -现在我们已经添加了投影,让我们再次运行查询: - -```sql runnable -SELECT - tip_amount, - trip_id, - dateDiff('minutes', pickup_datetime, dropoff_datetime) AS trip_duration_min -FROM nyc_taxi.trips_with_projection WHERE tip_amount > 200 AND trip_duration_min > 0 -ORDER BY tip_amount, trip_id ASC -``` - -请注意,我们能够大幅减少查询时间,并且需要扫描的行数更少。 - -我们可以通过查询 `system.query_log` 表来确认我们的查询确实使用了我们制作的投影: - -```sql -SELECT query, projections -FROM system.query_log -WHERE query_id='' -``` - -```response -┌─query─────────────────────────────────────────────────────────────────────────┬─projections──────────────────────┐ -│ SELECT ↴│ ['default.trips.prj_tip_amount'] │ -│↳ tip_amount, ↴│ │ -│↳ trip_id, ↴│ │ -│↳ dateDiff('minutes', pickup_datetime, dropoff_datetime) AS trip_duration_min↴│ │ -│↳FROM trips WHERE tip_amount > 200 AND trip_duration_min > 0 │ │ -└───────────────────────────────────────────────────────────────────────────────┴──────────────────────────────────┘ -``` - -### Using projections to speed up UK price paid queries {#using-projections-to-speed-up-UK-price-paid} - -为了演示如何使用 projections 来加速查询性能,让我们看一个使用真实数据集的示例。在此示例中,我们将使用我们的 [UK Property Price Paid](https://clickhouse.com/docs/getting-started/example-datasets/uk-price-paid) 教程中的表,包含 3003 万行。这个数据集也可在我们的 [sql.clickhouse.com](https://sql.clickhouse.com/?query_id=6IDMHK3OMR1C97J6M9EUQS) 环境中获得。 - -如果您想查看该表是如何创建和插入数据的,您可以参考 ["The UK property prices dataset"](/getting-started/example-datasets/uk-price-paid) 页面。 - -我们可以在此数据集上运行两个简单的查询。第一个列出伦敦县中支付价格最高的县,而第二个计算这些县的平均价格: - -```sql runnable -SELECT - county, - price -FROM uk.uk_price_paid -WHERE town = 'LONDON' -ORDER BY price DESC -LIMIT 3 -``` - -```sql runnable -SELECT - county, - avg(price) -FROM uk.uk_price_paid -GROUP BY county -ORDER BY avg(price) DESC -LIMIT 3 -``` - -请注意,尽管非常快,但由于在创建表时 `town` 和 `price` 都未包含在我们的 `ORDER BY` 语句中,这两个查询都发生了对 3003 万行的全表扫描: - -```sql -CREATE TABLE uk.uk_price_paid -( - ... -) -ENGINE = MergeTree ---highlight-next-line -ORDER BY (postcode1, postcode2, addr1, addr2); -``` - -让我们看看是否可以使用 projections 加速此查询。 - -为了保留原始表和结果,我们将创建一个新表并使用 `INSERT INTO SELECT` 复制数据: - -```sql -CREATE TABLE uk.uk_price_paid_with_projections AS uk_price_paid; -INSERT INTO uk.uk_price_paid_with_projections SELECT * FROM uk.uk_price_paid; -``` - -我们创建并填充投影 `prj_oby_town_price`,它生成一个按城镇和价格排序的额外(隐藏)表,以优化列出特定城镇中支付最高价格的县的查询: - -```sql -ALTER TABLE uk.uk_price_paid_with_projections - (ADD PROJECTION prj_obj_town_price - ( - SELECT * - ORDER BY - town, - price - )) -``` - -```sql -ALTER TABLE uk.uk_price_paid_with_projections - (MATERIALIZE PROJECTION prj_obj_town_price) -SETTINGS mutations_sync = 1 -``` - -[`mutations_sync`](/operations/settings/settings#mutations_sync) 设置用于强制同步执行。 - -我们创建并填充投影 `prj_gby_county`——一个额外的(隐藏)表,它以增量方式预计算所有现有 130 个英国县的 avg(price) 聚合值: - -```sql -ALTER TABLE uk.uk_price_paid_with_projections - (ADD PROJECTION prj_gby_county - ( - SELECT - county, - avg(price) - GROUP BY county - )) -``` -```sql -ALTER TABLE uk.uk_price_paid_with_projections - (MATERIALIZE PROJECTION prj_gby_county) -SETTINGS mutations_sync = 1 -``` - -:::note -如果在像上面的 `prj_gby_county` 投影中使用了 `GROUP BY` 子句,则(隐藏)表的底层存储引擎会变为 `AggregatingMergeTree`,所有聚合函数会转换为 `AggregateFunction`。这确保了正确的增量数据聚合。 -::: - -下图是主表 `uk_price_paid_with_projections` 及其两个投影的可视化: - -Visualization of the main table uk_price_paid_with_projections and its two projections - -如果我们现在再次运行列出伦敦县中支付最高价格的三个查询,我们会看到查询性能的提高: - -```sql runnable -SELECT - county, - price -FROM uk.uk_price_paid_with_projections -WHERE town = 'LONDON' -ORDER BY price DESC -LIMIT 3 -``` - -同样,对于列出三个位于英国的价格支付最高的县的查询: - -```sql runnable -SELECT - county, - avg(price) -FROM uk.uk_price_paid_with_projections -GROUP BY county -ORDER BY avg(price) DESC -LIMIT 3 -``` - -请注意,这两个查询都指向原始表,并且在创建这两个投影之前,两个查询都导致进行了全表扫描(3003 万行完全从磁盘流式传输)。 - -同时,请注意,列出伦敦县中支付最高价格的查询正在流式传输 217 万行。当我们直接使用优化此查询的第二个表时,仅有 81920 行从磁盘流式传输。 - -这种差异的原因是,目前不支持上述提到的 `optimize_read_in_order` 优化用于 projections。 - -我们检查 `system.query_log` 表,看到 ClickHouse 自动使用了上述两个查询的两个投影(见下方的 projections 列): - -```sql -SELECT - tables, - query, - query_duration_ms::String || ' ms' AS query_duration, - formatReadableQuantity(read_rows) AS read_rows, - projections -FROM clusterAllReplicas(default, system.query_log) -WHERE (type = 'QueryFinish') AND (tables = ['default.uk_price_paid_with_projections']) -ORDER BY initial_query_start_time DESC - LIMIT 2 -FORMAT Vertical -``` - -```response -Row 1: -────── -tables: ['uk.uk_price_paid_with_projections'] -query: SELECT - county, - avg(price) -FROM uk_price_paid_with_projections -GROUP BY county -ORDER BY avg(price) DESC -LIMIT 3 -query_duration: 5 ms -read_rows: 132.00 -projections: ['uk.uk_price_paid_with_projections.prj_gby_county'] - -Row 2: -────── -tables: ['uk.uk_price_paid_with_projections'] -query: SELECT - county, - price -FROM uk_price_paid_with_projections -WHERE town = 'LONDON' -ORDER BY price DESC -LIMIT 3 -SETTINGS log_queries=1 -query_duration: 11 ms -read_rows: 2.29 million -projections: ['uk.uk_price_paid_with_projections.prj_obj_town_price'] - -2 rows in set. Elapsed: 0.006 sec. -``` - -### Further examples {#further-examples} - -以下示例使用相同的英国价格数据集,比较使用和不使用投影的查询。 - -为了保留原始表(及其性能),我们再次使用 `CREATE AS` 和 `INSERT INTO SELECT` 创建表的副本。 - -```sql -CREATE TABLE uk.uk_price_paid_with_projections_v2 AS uk.uk_price_paid; -INSERT INTO uk.uk_price_paid_with_projections_v2 SELECT * FROM uk.uk_price_paid; -``` - -#### Build a Projection {#build-projection} - -让我们创建一个按 `toYear(date)`、`district` 和 `town` 维度进行聚合的投影: - -```sql -ALTER TABLE uk.uk_price_paid_with_projections_v2 - ADD PROJECTION projection_by_year_district_town - ( - SELECT - toYear(date), - district, - town, - avg(price), - sum(price), - count() - GROUP BY - toYear(date), - district, - town - ) -``` - -为现有数据填充投影。(在未物化的情况下,投影将仅为新插入的数据创建): - -```sql -ALTER TABLE uk.uk_price_paid_with_projections_v2 - MATERIALIZE PROJECTION projection_by_year_district_town -SETTINGS mutations_sync = 1 -``` - -以下查询比较使用和不使用投影的性能。要禁用投影使用,我们使用设置 [`optimize_use_projections`](/operations/settings/settings#optimize_use_projections),该设置默认启用。 - -#### Query 1. Average price per year {#average-price-projections} - -```sql runnable -SELECT - toYear(date) AS year, - round(avg(price)) AS price, - bar(price, 0, 1000000, 80) -FROM uk.uk_price_paid_with_projections_v2 -GROUP BY year -ORDER BY year ASC -SETTINGS optimize_use_projections=0 -``` - -```sql runnable -SELECT - toYear(date) AS year, - round(avg(price)) AS price, - bar(price, 0, 1000000, 80) -FROM uk.uk_price_paid_with_projections_v2 -GROUP BY year -ORDER BY year ASC - -``` -结果应该是相同的,但后者示例的性能更佳! - - -#### Query 2. Average price per year in London {#average-price-london-projections} - -```sql runnable -SELECT - toYear(date) AS year, - round(avg(price)) AS price, - bar(price, 0, 2000000, 100) -FROM uk.uk_price_paid_with_projections_v2 -WHERE town = 'LONDON' -GROUP BY year -ORDER BY year ASC -SETTINGS optimize_use_projections=0 -``` - - -```sql runnable -SELECT - toYear(date) AS year, - round(avg(price)) AS price, - bar(price, 0, 2000000, 100) -FROM uk.uk_price_paid_with_projections_v2 -WHERE town = 'LONDON' -GROUP BY year -ORDER BY year ASC -``` - -#### Query 3. The most expensive neighborhoods {#most-expensive-neighborhoods-projections} - -条件 (date >= '2020-01-01') 需要修改,以便与投影维度匹配 (`toYear(date) >= 2020`): - -```sql runnable -SELECT - town, - district, - count() AS c, - round(avg(price)) AS price, - bar(price, 0, 5000000, 100) -FROM uk.uk_price_paid_with_projections_v2 -WHERE toYear(date) >= 2020 -GROUP BY - town, - district -HAVING c >= 100 -ORDER BY price DESC -LIMIT 100 -SETTINGS optimize_use_projections=0 -``` - -```sql runnable -SELECT - town, - district, - count() AS c, - round(avg(price)) AS price, - bar(price, 0, 5000000, 100) -FROM uk.uk_price_paid_with_projections_v2 -WHERE toYear(date) >= 2020 -GROUP BY - town, - district -HAVING c >= 100 -ORDER BY price DESC -LIMIT 100 -``` - -同样,结果是相同的,但注意第二个查询的查询性能有所改善。 - - -## Related content {#related-content} -- [A Practical Introduction to Primary Indexes in ClickHouse](/guides/best-practices/sparse-primary-indexes#option-3-projections) -- [Materialized Views](/docs/materialized-views) -- [ALTER PROJECTION](/sql-reference/statements/alter/projection) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/data-modeling/projections.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/data-modeling/projections.md.hash deleted file mode 100644 index beaa1eb0e6f..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/data-modeling/projections.md.hash +++ /dev/null @@ -1 +0,0 @@ -fc1ba9ffdc610418 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/data-modeling/projections/1_projections.md b/i18n/zh/docusaurus-plugin-content-docs/current/data-modeling/projections/1_projections.md new file mode 100644 index 00000000000..2c0b6880c6a --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/data-modeling/projections/1_projections.md @@ -0,0 +1,568 @@ +--- +'slug': '/data-modeling/projections' +'title': '投影' +'description': '页面描述投影是什么,它们如何用于提高查询性能,以及它们与物化视图的不同。' +'keywords': +- 'projection' +- 'projections' +- 'query optimization' +'sidebar_order': 1 +'doc_type': 'guide' +--- + +import projections_1 from '@site/static/images/data-modeling/projections_1.png'; +import projections_2 from '@site/static/images/data-modeling/projections_2.png'; +import Image from '@theme/IdealImage'; + + +# Projections + +## Introduction {#introduction} + +ClickHouse 提供了多种加速实时场景下大规模数据分析查询的机制。其中一种加速查询的机制是通过使用 _Projections_。Projections 通过按相关属性重排数据来帮助优化查询。这可以是: + +1. 完全重排 +2. 原始表的一个子集,但顺序不同 +3. 预计算聚合(类似于物化视图),但与聚合对齐的排序。 + +
+ + +## How do Projections work? {#how-do-projections-work} + +实际上,Projection 可以被视为原始表的一个附加的、隐藏的表。Projection 可以具有不同于原始表的行顺序,因此可以有不同的主索引,并且它可以自动和增量地预计算聚合值。因此,使用 Projections 提供了两个加速查询执行的“调节旋钮”: + +- **正确使用主索引** +- **预计算聚合** + +Projections 在某种程度上类似于 [Materialized Views](/materialized-views),它们也允许您在插入时维护多个行顺序和预计算聚合。Projections 是自动更新并与原始表保持同步的,这与物化视图不同,后者是显式更新的。当查询针对原始表时,ClickHouse 会自动抽样主键并选择一个可以生成相同正确结果的表,但读取所需的数据最少,如下图所示: + +Projections in ClickHouse + +### Smarter storage with `_part_offset` {#smarter_storage_with_part_offset} + +自 25.5 版本以来,ClickHouse 在 Projections 中支持虚拟列 `_part_offset`,这提供了一种新的定义 Projection 的方法。 + +现在定义 Projection 有两种方式: + +- **存储完整列(原始行为)**:Projection 包含完整数据并可以直接读取,当过滤条件与 Projection 的排序顺序匹配时,性能更快。 + +- **只存储排序键 + `_part_offset`**:Projection 的工作方式类似于索引。ClickHouse 使用 Projection 的主索引来定位匹配行,但从基础表中读取实际数据。这在插入时会减少存储开销,但在查询时会略微增加 I/O。 + +上述方法也可以混合使用,在 Projection 中存储某些列,并通过 `_part_offset` 间接存储其他列。 + +## When to use Projections? {#when-to-use-projections} + +Projections 对新用户来说是一个吸引人的特性,因为它们在数据插入时会自动维护。此外,查询可以仅发送到一个表,在可能的情况下利用 Projections 来加速响应时间。 + +这与物化视图形成对比,后者要求用户选择适当的优化目标表或根据过滤器重写查询。这使得用户应用程序的复杂性提高,并增加了客户端的复杂度。 + +尽管有这些优势,Projections 也有一些固有的限制,用户应该意识到,因此应谨慎使用。 + +- Projections 不允许对源表和(隐藏的)目标表使用不同的 TTL,而物化视图允许不同的 TTL。 +- 对于包含 Projections 的表,不支持轻量级更新和删除。 +- 物化视图可以链式使用:一个物化视图的目标表可以成为另一个物化视图的源表,等等。这在 Projections 中是不可能的。 +- Projections 不支持连接,但物化视图支持。 +- Projections 不支持过滤(`WHERE` 子句),但物化视图支持。 + +我们推荐在以下情况下使用 Projections: + +- 需要对数据进行完全重排。虽然 Projection 中的表达式理论上可以使用 `GROUP BY`,但物化视图在维护聚合方面更有效。查询优化器更有可能利用使用简单重排的 Projections,即 `SELECT * ORDER BY x`。用户可以选择此表达式中的子集列以减少存储占用。 +- 用户能够接受潜在的存储占用和重写数据两次的开销。测试插入速度的影响并 [评估存储开销](/data-compression/compression-in-clickhouse)。 + +## Examples {#examples} + +### Filtering on columns which aren't in the primary key {#filtering-without-using-primary-keys} + +在本例中,我们将向您展示如何向表中添加一个 Projection。我们还将看一下 Projection 如何用于加速过滤在表的主键中不存在的列的查询。 + +在此示例中,我们将使用可在 [sql.clickhouse.com](https://sql.clickhouse.com/) 上找到的纽约出租车数据集,该数据集按 `pickup_datetime` 排序。 + +让我们写一个简单的查询,以查找所有小费大于 $200 的行程 ID: + +```sql runnable +SELECT + tip_amount, + trip_id, + dateDiff('minutes', pickup_datetime, dropoff_datetime) AS trip_duration_min +FROM nyc_taxi.trips WHERE tip_amount > 200 AND trip_duration_min > 0 +ORDER BY tip_amount, trip_id ASC +``` + +请注意,由于我们过滤的是不在 `ORDER BY` 中的 `tip_amount`,ClickHouse 必须进行完整表扫描。让我们加速这个查询。 + +为了保留原始表和结果,我们将创建一个新表并使用 `INSERT INTO SELECT` 复制数据: + +```sql +CREATE TABLE nyc_taxi.trips_with_projection AS nyc_taxi.trips; +INSERT INTO nyc_taxi.trips_with_projection SELECT * FROM nyc_taxi.trips; +``` + +要添加一个 Projection,我们使用 `ALTER TABLE` 语句和 `ADD PROJECTION` 语句: + +```sql +ALTER TABLE nyc_taxi.trips_with_projection +ADD PROJECTION prj_tip_amount +( + SELECT * + ORDER BY tip_amount, dateDiff('minutes', pickup_datetime, dropoff_datetime) +) +``` + +在添加 Projection 后,有必要使用 `MATERIALIZE PROJECTION` 语句,以便使其中的数据按物理顺序排列并根据上述指定的查询重写: + +```sql +ALTER TABLE nyc.trips_with_projection MATERIALIZE PROJECTION prj_tip_amount +``` + +添加了 Projection 后,让我们再次运行查询: + +```sql runnable +SELECT + tip_amount, + trip_id, + dateDiff('minutes', pickup_datetime, dropoff_datetime) AS trip_duration_min +FROM nyc_taxi.trips_with_projection WHERE tip_amount > 200 AND trip_duration_min > 0 +ORDER BY tip_amount, trip_id ASC +``` + +请注意,我们确实能够显著减少查询时间,并且需要扫描更少的行。 + +我们可以通过查询 `system.query_log` 表来确认上述查询确实使用了我们创建的 Projection: + +```sql +SELECT query, projections +FROM system.query_log +WHERE query_id='' +``` + +```response +┌─query─────────────────────────────────────────────────────────────────────────┬─projections──────────────────────┐ +│ SELECT ↴│ ['default.trips.prj_tip_amount'] │ +│↳ tip_amount, ↴│ │ +│↳ trip_id, ↴│ │ +│↳ dateDiff('minutes', pickup_datetime, dropoff_datetime) AS trip_duration_min↴│ │ +│↳FROM trips WHERE tip_amount > 200 AND trip_duration_min > 0 │ │ +└───────────────────────────────────────────────────────────────────────────────┴──────────────────────────────────┘ +``` + +### Using projections to speed up UK price paid queries {#using-projections-to-speed-up-UK-price-paid} + +为了演示如何使用 Projections 加速查询性能,让我们看看一个使用真实数据集的示例。在此示例中,我们将使用来自我们 [UK Property Price Paid](https://clickhouse.com/docs/getting-started/example-datasets/uk-price-paid) 教程的表,该表包含 3003 万行。该数据集也可在我们的 [sql.clickhouse.com](https://sql.clickhouse.com/?query_id=6IDMHK3OMR1C97J6M9EUQS) 环境中找到。 + +如果您想查看如何创建表和插入数据,您可以参考 [“英国房价数据集”](/getting-started/example-datasets/uk-price-paid) 页面。 + +我们可以在此数据集上运行两个简单查询。第一个列出伦敦中支付价格最高的县,第二个计算各县的平均价格: + +```sql runnable +SELECT + county, + price +FROM uk.uk_price_paid +WHERE town = 'LONDON' +ORDER BY price DESC +LIMIT 3 +``` + +```sql runnable +SELECT + county, + avg(price) +FROM uk.uk_price_paid +GROUP BY county +ORDER BY avg(price) DESC +LIMIT 3 +``` + +请注意,尽管这两个查询非常快速,但由于在创建表时 `town` 和 `price` 不在我们的 `ORDER BY` 语句中,因此进行了完整表扫描(所有 3003 万行均从磁盘流式传输)。 + +```sql +CREATE TABLE uk.uk_price_paid +( + ... +) +ENGINE = MergeTree +--highlight-next-line +ORDER BY (postcode1, postcode2, addr1, addr2); +``` + +让我们看看是否可以使用 Projections 加速这个查询。 + +为了保留原始表和结果,我们将创建一个新表并使用 `INSERT INTO SELECT` 复制数据: + +```sql +CREATE TABLE uk.uk_price_paid_with_projections AS uk_price_paid; +INSERT INTO uk.uk_price_paid_with_projections SELECT * FROM uk.uk_price_paid; +``` + +我们创建并填充 Projection `prj_oby_town_price`,它生成一个附加的(隐藏的)表,主索引按城市和价格排序,以优化列出特定城市支付最高价格的县的查询: + +```sql +ALTER TABLE uk.uk_price_paid_with_projections + (ADD PROJECTION prj_obj_town_price + ( + SELECT * + ORDER BY + town, + price + )) +``` + +```sql +ALTER TABLE uk.uk_price_paid_with_projections + (MATERIALIZE PROJECTION prj_obj_town_price) +SETTINGS mutations_sync = 1 +``` + +[`mutations_sync`](/operations/settings/settings#mutations_sync) 设置用于强制同步执行。 + +我们创建并填充 Projection `prj_gby_county` – 一个附加的(隐藏的)表,它增量地预计算所有现有 130 个英国县的 avg(price) 聚合值: + +```sql +ALTER TABLE uk.uk_price_paid_with_projections + (ADD PROJECTION prj_gby_county + ( + SELECT + county, + avg(price) + GROUP BY county + )) +``` +```sql +ALTER TABLE uk.uk_price_paid_with_projections + (MATERIALIZE PROJECTION prj_gby_county) +SETTINGS mutations_sync = 1 +``` + +:::note +如果在 Projection 中使用了 `GROUP BY` 子句,例如在 `prj_gby_county` Projection 中,那么该(隐藏)表的底层存储引擎变为 `AggregatingMergeTree`,所有聚合函数被转换为 `AggregateFunction`。这确保了适当的增量数据聚合。 +::: + +下图是主要表 `uk_price_paid_with_projections` 及其两个 Projections 的可视化: + +Visualization of the main table uk_price_paid_with_projections and its two projections + +如果我们现在再次运行列出伦敦中支付最高价格的三县的查询,我们会看到查询性能有所改善: + +```sql runnable +SELECT + county, + price +FROM uk.uk_price_paid_with_projections +WHERE town = 'LONDON' +ORDER BY price DESC +LIMIT 3 +``` + +同样,对于列出支付平均价格最高的英国县的查询: + +```sql runnable +SELECT + county, + avg(price) +FROM uk.uk_price_paid_with_projections +GROUP BY county +ORDER BY avg(price) DESC +LIMIT 3 +``` + +请注意,这两个查询都针对原始表,并且在我们创建这两个 Projections 之前,这两个查询都导致了完整表扫描(所有 3003 万行均从磁盘流式传输)。 + +还要注意,列出伦敦中支付最高价格的三县的查询流式传输了 217 万行。当我们直接使用一个针对该查询优化的第二个表时,仅从磁盘流式传输了 81920 行。 + +差异的原因在于,目前,前面提到的 `optimize_read_in_order` 优化不支持 Projections。 + +我们检查 `system.query_log` 表,以查看 ClickHouse 自动对上述两个查询使用了两个 Projections(请参见下面的 Projections 列): + +```sql +SELECT + tables, + query, + query_duration_ms::String || ' ms' AS query_duration, + formatReadableQuantity(read_rows) AS read_rows, + projections +FROM clusterAllReplicas(default, system.query_log) +WHERE (type = 'QueryFinish') AND (tables = ['default.uk_price_paid_with_projections']) +ORDER BY initial_query_start_time DESC + LIMIT 2 +FORMAT Vertical +``` + +```response +Row 1: +────── +tables: ['uk.uk_price_paid_with_projections'] +query: SELECT + county, + avg(price) +FROM uk_price_paid_with_projections +GROUP BY county +ORDER BY avg(price) DESC +LIMIT 3 +query_duration: 5 ms +read_rows: 132.00 +projections: ['uk.uk_price_paid_with_projections.prj_gby_county'] + +Row 2: +────── +tables: ['uk.uk_price_paid_with_projections'] +query: SELECT + county, + price +FROM uk_price_paid_with_projections +WHERE town = 'LONDON' +ORDER BY price DESC +LIMIT 3 +SETTINGS log_queries=1 +query_duration: 11 ms +read_rows: 2.29 million +projections: ['uk.uk_price_paid_with_projections.prj_obj_town_price'] + +2 rows in set. Elapsed: 0.006 sec. +``` + +### Further examples {#further-examples} + +以下示例使用相同的英国价格数据集,比较使用和不使用 Projections 的查询。 + +为了保留我们的原始表(和性能),我们再次使用 `CREATE AS` 和 `INSERT INTO SELECT` 创建表的副本。 + +```sql +CREATE TABLE uk.uk_price_paid_with_projections_v2 AS uk.uk_price_paid; +INSERT INTO uk.uk_price_paid_with_projections_v2 SELECT * FROM uk.uk_price_paid; +``` + +#### Build a Projection {#build-projection} + +让我们按维度 `toYear(date)`、`district` 和 `town` 创建一个聚合 Projection: + +```sql +ALTER TABLE uk.uk_price_paid_with_projections_v2 + ADD PROJECTION projection_by_year_district_town + ( + SELECT + toYear(date), + district, + town, + avg(price), + sum(price), + count() + GROUP BY + toYear(date), + district, + town + ) +``` + +为现有数据填充 Projection。(如果不物化,Projection 将仅为新插入的数据创建): + +```sql +ALTER TABLE uk.uk_price_paid_with_projections_v2 + MATERIALIZE PROJECTION projection_by_year_district_town +SETTINGS mutations_sync = 1 +``` + +以下查询对比了使用和不使用 Projections 的性能。要禁用 Projection 使用,我们使用设置 [`optimize_use_projections`](/operations/settings/settings#optimize_use_projections),该设置默认为启用。 + +#### Query 1. Average price per year {#average-price-projections} + +```sql runnable +SELECT + toYear(date) AS year, + round(avg(price)) AS price, + bar(price, 0, 1000000, 80) +FROM uk.uk_price_paid_with_projections_v2 +GROUP BY year +ORDER BY year ASC +SETTINGS optimize_use_projections=0 +``` + +```sql runnable +SELECT + toYear(date) AS year, + round(avg(price)) AS price, + bar(price, 0, 1000000, 80) +FROM uk.uk_price_paid_with_projections_v2 +GROUP BY year +ORDER BY year ASC + +``` +结果应该是一样的,但后者示例的性能更好! + +#### Query 2. Average price per year in London {#average-price-london-projections} + +```sql runnable +SELECT + toYear(date) AS year, + round(avg(price)) AS price, + bar(price, 0, 2000000, 100) +FROM uk.uk_price_paid_with_projections_v2 +WHERE town = 'LONDON' +GROUP BY year +ORDER BY year ASC +SETTINGS optimize_use_projections=0 +``` + +```sql runnable +SELECT + toYear(date) AS year, + round(avg(price)) AS price, + bar(price, 0, 2000000, 100) +FROM uk.uk_price_paid_with_projections_v2 +WHERE town = 'LONDON' +GROUP BY year +ORDER BY year ASC +``` + +#### Query 3. The most expensive neighborhoods {#most-expensive-neighborhoods-projections} + +条件 (date >= '2020-01-01') 需要进行修改,以匹配 Projection 维度(`toYear(date) >= 2020`): + +```sql runnable +SELECT + town, + district, + count() AS c, + round(avg(price)) AS price, + bar(price, 0, 5000000, 100) +FROM uk.uk_price_paid_with_projections_v2 +WHERE toYear(date) >= 2020 +GROUP BY + town, + district +HAVING c >= 100 +ORDER BY price DESC +LIMIT 100 +SETTINGS optimize_use_projections=0 +``` + +```sql runnable +SELECT + town, + district, + count() AS c, + round(avg(price)) AS price, + bar(price, 0, 5000000, 100) +FROM uk.uk_price_paid_with_projections_v2 +WHERE toYear(date) >= 2020 +GROUP BY + town, + district +HAVING c >= 100 +ORDER BY price DESC +LIMIT 100 +``` + +同样,结果是一样的,但注意第二个查询的查询性能有所改善。 + +### Combining projections in one query {#combining-projections} + +自 25.6 版本起,基于前一个版本中引入的 `_part_offset` 支持,ClickHouse 现在可以使用多个 Projections 来加速具有多个过滤器的单个查询。 + +重要的是,ClickHouse 仍然只从一个 Projection(或基础表)读取数据,但可以使用其他 Projections 的主索引在读取之前修剪不必要的部分。这对于过滤多个列的查询特别有用,每个列可能匹配不同的 Projection。 + +> 目前,这一机制仅修剪整个部分。粒度级别的修剪尚不支持。 + +为了演示这一点,我们定义表(使用 `_part_offset` 列的 Projections)并插入五个示例行以匹配上面的图示。 + +```sql +CREATE TABLE page_views +( + id UInt64, + event_date Date, + user_id UInt32, + url String, + region String, + PROJECTION region_proj + ( + SELECT _part_offset ORDER BY region + ), + PROJECTION user_id_proj + ( + SELECT _part_offset ORDER BY user_id + ) +) +ENGINE = MergeTree +ORDER BY (event_date, id) +SETTINGS + index_granularity = 1, -- one row per granule + max_bytes_to_merge_at_max_space_in_pool = 1; -- disable merge +``` + +然后我们将数据插入表中: + +```sql +INSERT INTO page_views VALUES ( +1, '2025-07-01', 101, 'https://example.com/page1', 'europe'); +INSERT INTO page_views VALUES ( +2, '2025-07-01', 102, 'https://example.com/page2', 'us_west'); +INSERT INTO page_views VALUES ( +3, '2025-07-02', 106, 'https://example.com/page3', 'us_west'); +INSERT INTO page_views VALUES ( +4, '2025-07-02', 107, 'https://example.com/page4', 'us_west'); +INSERT INTO page_views VALUES ( +5, '2025-07-03', 104, 'https://example.com/page5', 'asia'); +``` + +:::note +注意:该表使用自定义设置进行说明,例如单行粒度和禁用分片合并,这些在生产使用中不推荐。 +::: + +这设置将产生: +- 五个单独的部分(每个插入行一个) +- 每行一个主索引条目(在基础表和每个 Projection 中) +- 每个部分包含恰好一行 + +有了这个设置,我们运行一个同时针对 `region` 和 `user_id` 过滤的查询。由于基础表的主索引是从 `event_date` 和 `id` 构建的,因此在这里没有用处,ClickHouse 因此使用: + +- `region_proj` 按区域修剪部分 +- `user_id_proj` 进一步按 `user_id` 修剪 + +这种行为可使用 `EXPLAIN projections = 1` 可见,它显示了 ClickHouse 如何选择和应用 Projections。 + +```sql +EXPLAIN projections=1 +SELECT * FROM page_views WHERE region = 'us_west' AND user_id = 107; +``` + +```response + ┌─explain────────────────────────────────────────────────────────────────────────────────┐ + 1. │ Expression ((Project names + Projection)) │ + 2. │ Expression │ + 3. │ ReadFromMergeTree (default.page_views) │ + 4. │ Projections: │ + 5. │ Name: region_proj │ + 6. │ Description: Projection has been analyzed and is used for part-level filtering │ + 7. │ Condition: (region in ['us_west', 'us_west']) │ + 8. │ Search Algorithm: binary search │ + 9. │ Parts: 3 │ +10. │ Marks: 3 │ +11. │ Ranges: 3 │ +12. │ Rows: 3 │ +13. │ Filtered Parts: 2 │ +14. │ Name: user_id_proj │ +15. │ Description: Projection has been analyzed and is used for part-level filtering │ +16. │ Condition: (user_id in [107, 107]) │ +17. │ Search Algorithm: binary search │ +18. │ Parts: 1 │ +19. │ Marks: 1 │ +20. │ Ranges: 1 │ +21. │ Rows: 1 │ +22. │ Filtered Parts: 2 │ + └────────────────────────────────────────────────────────────────────────────────────────┘ +``` + +`EXPLAIN` 输出(如上所示)揭示了逻辑查询计划,从上到下: + +| 行号 | 描述 | +|------|------------------------------------------------------------------------------------------------| +| 3 | 计划从 `page_views` 基础表读取 | +| 5-13 | 使用 `region_proj` 识别 3 个区域为 'us_west' 的部分,修剪 5 个部分中的 2 个 | +| 14-22| 使用 `user_id_proj` 识别 1 个部分,其中 `user_id = 107`,进一步修剪 3 个剩余部分中的 2 个 | + +最后,从基础表中只读取 **5 个部分中的 1 个**。通过结合多个 Projections 的索引分析,ClickHouse 显著减少了扫描的数据量,提高了性能,同时保持低存储开销。 + +## Related content {#related-content} +- [ClickHouse 中主索引的实际介绍](/guides/best-practices/sparse-primary-indexes#option-3-projections) +- [物化视图](/docs/materialized-views) +- [ALTER PROJECTION](/sql-reference/statements/alter/projection) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/data-modeling/projections/1_projections.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/data-modeling/projections/1_projections.md.hash new file mode 100644 index 00000000000..66ed75b3a84 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/data-modeling/projections/1_projections.md.hash @@ -0,0 +1 @@ +69e0bdb1e54cc95e diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/data-modeling/projections/2_materialized-views-versus-projections.md b/i18n/zh/docusaurus-plugin-content-docs/current/data-modeling/projections/2_materialized-views-versus-projections.md new file mode 100644 index 00000000000..9ba907c78df --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/data-modeling/projections/2_materialized-views-versus-projections.md @@ -0,0 +1,75 @@ +--- +'slug': '/managing-data/materialized-views-versus-projections' +'sidebar_label': '物化视图与投影' +'title': '物化视图与投影' +'hide_title': false +'description': '本文比较了 ClickHouse 中的物化视图和投影,包括它们的使用案例、性能和限制。' +'doc_type': 'reference' +--- + +> 用户常常会问他们何时应该使用物化视图而不是投影。本文将探讨两者之间的主要区别,以及为什么在某些情况下您可能更倾向于选择其中一个。 + +## 主要区别总结 {#key-differences} + +下表总结了物化视图和投影在各个考虑方面的主要区别。 + +| 方面 | 物化视图 | 投影 | +|----------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| 数据存储和位置 | 将结果存储在一个**独立的、明确的目标表**中,作为对源表插入的触发器。 | 投影创建优化的数据布局,这些布局物理上**与主表数据存储在一起**,对用户而言是不可见的。 | +| 更新机制 | 在源表的`INSERT`上**同步**操作(对于增量物化视图)。注意:它们还可以使用可刷新的物化视图进行**计划**。 | 在向主表插入时**异步**更新。 | +| 查询交互 | 使用物化视图时需要直接查询**目标表**,这意味着用户在编写查询时需要注意物化视图的存在。 | 投影由 ClickHouse 的查询优化器**自动选择**,在透明性方面,用户不需要修改其查询以利用具有投影的表。从版本 25.6 开始,也可以按多个投影进行过滤。 | +| 处理`UPDATE` / `DELETE` | **不会自动响应**源表上的`UPDATE`或`DELETE`操作,因为物化视图对源表没有了解,仅充当插入触发器。这样可能导致源表和目标表之间的数据过时,并需要解决方法或定期完全刷新。(通过可刷新的物化视图)。 | 默认情况下,与`DELETED`行**不兼容**(尤其是轻量级删除)。`lightweight_mutation_projection_mode`(v24.7+)可以启用兼容性。 | +| `JOIN` 支持 | 是的。可刷新的物化视图可用于复杂的非规范化。增量物化视图仅在最左侧表插入时触发。 | 否。在投影定义中不支持`JOIN`操作以过滤物化数据。 | +| 定义中的 `WHERE` 子句 | 是的。可以包括 `WHERE` 子句以在物化之前过滤数据。 | 否。在投影定义中不支持 `WHERE` 子句以过滤物化到投影本身的数据。 | +| 链接能力 | 是的,一个物化视图的目标表可以是另一个物化视图的源,支持多阶段管道。 | 否。投影不能链式使用。 | +| 适用的表引擎 | 可与各种源表引擎一起使用,但目标表通常属于 `MergeTree` 家族。 | **仅适用于** `MergeTree` 家族的表引擎。 | +| 故障处理 | 数据插入过程中的故障意味着目标表中的数据丢失,从而导致潜在的不一致性。 | 故障在后台**静默处理**。查询可以无缝混合物化部分和非物化部分。 | +| 操作开销 | 需要明确的目标表创建,并且通常需要手动填充。管理`UPDATE`/`DELETE`的一致性增加了复杂性。 | 投影是自动维护并保持同步的,通常具有较低的操作负担。 | +| `FINAL` 查询兼容性 | 通常兼容,但通常需要在目标表上使用 `GROUP BY`。 | **不支持** `FINAL` 查询。 | +| 延迟物化 | 是的。 | 在使用物化特性时监控投影兼容性问题。您可能需要设置 `query_plan_optimize_lazy_materialization = false` | +| 并行副本 | 是的。 | 否。 | +| [`optimize_read_in_order`](/operations/settings/settings#optimize_read_in_order) | 是的。 | 是的。 | +| 轻量级更新和删除 | 是的。 | 否。 | + +## 比较物化视图和投影 {#choose-between} + +### 何时选择物化视图 {#choosing-materialized-views} + +您应该考虑使用物化视图的情况: + +- 处理**实时 ETL 和多阶段数据管道**:您需要执行复杂的变换、聚合,或在数据到达时进行路由,可能通过链式视图跨多个阶段。 +- 您需要**复杂的非规范化**:您需要将来自多个源(表、子查询或字典)的数据预先连接到一个单一的、针对查询优化的表中,尤其是在可以接受使用可刷新的物化视图进行定期完全刷新的情况下。 +- 您希望**明确的模式控制**:您需要一个独立、独特的目标表,其具有自己的模式和引擎,供预计算结果使用,为数据建模提供更大的灵活性。 +- 您希望在摄取时**进行过滤**:您需要在数据物化之前过滤数据,从而减少写入目标表的数据量。 + +### 何时避免物化视图 {#avoid-materialized-views} + +您应该考虑避免使用物化视图的情况: + +- **源数据频繁更新或删除**:如果没有额外的策略来处理源表和目标表之间的一致性,增量物化视图可能会变得过时和不一致。 +- **简单和自动优化更可取**:如果您希望避免管理单独的目标表。 + +### 何时选择投影 {#choosing-projections} + +您应该考虑使用投影的情况: + +- **针对单一表优化查询**:您的主要目标是通过提供替代排序顺序,加速对单个基础表的查询,优化不属于主键的列上的过滤,或为单个表预计算聚合。 +- 您希望**查询透明性**:您希望查询针对原始表而不进行修改,依赖 ClickHouse 为给定查询选择最佳数据布局。 + +### 何时避免投影 {#avoid-projections} + +您应该考虑避免使用投影的情况: + +- **需要复杂的数据转换或多阶段 ETL**:投影在其定义中不支持`JOIN`操作,无法更改以建立多步骤管道,并且无法处理某些 SQL 特性,如窗口函数或复杂的 `CASE` 语句。因此,它们不适合复杂的数据转换。 +- **需要明确过滤物化数据**:投影在其定义中不支持`WHERE` 子句以过滤进入投影本身的数据。 +- **使用非 MergeTree 表引擎**:投影仅适用于使用 `MergeTree` 家族引擎的表。 +- `FINAL` 查询是必需的:投影不支持 `FINAL` 查询,这在某些情况下用于去重。 +- 您需要 [并行副本](/deployment-guides/parallel-replicas),因为投影不支持并行副本。 + +## 总结 {#summary} + +物化视图和投影都是您优化查询和变换数据的强大工具,一般来说,我们建议不要将它们视为非此即彼的选择。相反,它们可以以互补的方式使用,以便充分利用您的查询。因此,在 ClickHouse 中选择物化视图和投影真正取决于您的特定用例和访问模式。 + +作为一般的经验法则,当您需要将来自一个或多个源表的数据聚合到目标表中或在大规模上执行复杂的变换时,您应该考虑使用物化视图。物化视图非常适合将昂贵的聚合工作从查询时间转移到插入时间。它们非常适合每日或每月汇总、实时仪表盘或数据摘要。 + +另一方面,当您需要优化针对的数据过滤的列,而这些列不属于表的主键时,您应该使用投影,因为主键决定了数据在磁盘上的物理顺序。特别是在无法更改表的主键时,或者当您的访问模式比主键能够容纳的范围更广泛时,投影非常有用。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/data-modeling/projections/2_materialized-views-versus-projections.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/data-modeling/projections/2_materialized-views-versus-projections.md.hash new file mode 100644 index 00000000000..a3500803163 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/data-modeling/projections/2_materialized-views-versus-projections.md.hash @@ -0,0 +1 @@ +2f2cdda2389ac0ea diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/data-modeling/schema-design.md b/i18n/zh/docusaurus-plugin-content-docs/current/data-modeling/schema-design.md index 6356166aa4f..bd48eccfb86 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/data-modeling/schema-design.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/data-modeling/schema-design.md @@ -1,40 +1,41 @@ --- 'slug': '/data-modeling/schema-design' -'title': '架构设计' -'description': '优化 ClickHouse 架构以提高查询性能' +'title': '模式设计' +'description': '优化 ClickHouse 模式以提高查询性能' 'keywords': - 'schema' - 'schema design' - 'query optimization' +'doc_type': 'guide' --- import stackOverflowSchema from '@site/static/images/data-modeling/stackoverflow-schema.png'; import schemaDesignIndices from '@site/static/images/data-modeling/schema-design-indices.png'; import Image from '@theme/IdealImage'; -理解有效的模式设计是优化 ClickHouse 性能的关键,包括常常涉及权衡的选择,最佳方法取决于所服务的查询以及数据更新频率、延迟要求和数据量等因素。 本指南提供了模式设计最佳实践和数据建模技术的概述,以优化 ClickHouse 性能。 +理解有效的模式设计是优化 ClickHouse 性能的关键,这涉及到的选择通常会牵涉到权衡,最优的方法取决于所服务的查询以及数据更新频率、延迟要求和数据量等因素。本指南提供了模式设计最佳实践和数据建模技术的概述,以优化 ClickHouse 性能。 ## Stack Overflow 数据集 {#stack-overflow-dataset} -在本指南中的示例中,我们使用了 Stack Overflow 数据集的一个子集。该数据集包含了从 2008 到 2024 年 4 月,在 Stack Overflow 上发生的所有帖子、投票、用户、评论和徽章。这些数据以 Parquet 格式存储,使用以下模式在 S3 桶 `s3://datasets-documentation/stackoverflow/parquet/` 中提供: +在本指南的示例中,我们使用 Stack Overflow 数据集的一个子集。此数据集包含了自 2008 年至 2024 年 4 月在 Stack Overflow 上发生的每一条帖子、投票、用户、评论和徽章。此数据以 Parquet 格式提供,存储在 S3 存储桶 `s3://datasets-documentation/stackoverflow/parquet/` 下,使用以下模式: -> 指示的主键和关系并未通过约束强制执行(Parquet 是文件而非表格式),仅表示数据之间的关系和其独特的键。 +> 所示的主键和关系并未通过约束来强制执行(Parquet 是文件而非表格式),仅表示数据之间的关系及其具有的唯一键。 Stack Overflow Schema
-Stack Overflow 数据集包含多个相关表。在任何数据建模任务中,我们建议用户首先关注加载其主表。这个表不一定是最大的表,而是您期望收到最多分析查询的那个表。这将使您熟悉主要的 ClickHouse 概念和类型,这尤其重要,如果您来自以 OLTP 为主的背景。随着更多表的添加,该表可能需要重新建模以充分利用 ClickHouse 的特性并获得最佳性能。 +Stack Overflow 数据集包含一些相关的表。在任何数据建模任务中,我们建议用户首先关注加载他们的主表。此表不一定是最大的表,而是您期望接收大多数分析查询的表。这将使您熟悉主要的 ClickHouse 概念和类型,尤其是在来自主要 OLTP 背景的情况下。这张表可能需要重建,以便在添加其他表时充分利用 ClickHouse 特性,实现最佳性能。 -上述模式故意没有为本指南的目的而最优。 +上述模式故意不符合最佳模式,以便于本指南的目的。 ## 建立初始模式 {#establish-initial-schema} -由于 `posts` 表将是大多数分析查询的目标,因此我们专注于为该表建立模式。该数据可以在公共 S3 桶 `s3://datasets-documentation/stackoverflow/parquet/posts/*.parquet` 中找到,每年一个文件。 +由于 `posts` 表将是大多数分析查询的目标,我们重点建立该表的模式。此数据可在公共 S3 存储桶 `s3://datasets-documentation/stackoverflow/parquet/posts/*.parquet` 中获取,每年一个文件。 -> 从 S3 加载 Parquet 格式的数据是加载数据到 ClickHouse 最常见和首选的方式。ClickHouse 针对处理 Parquet 进行了优化,可能每秒从 S3 读取和插入数千万行。 +> 从 S3 加载 Parquet 格式的数据是将数据加载到 ClickHouse 的最常见和首选方式。ClickHouse 针对处理 Parquet 进行了优化,理论上每秒可以从 S3 读取和插入数千万行。 -ClickHouse 提供了一种模式推断能力,可以自动识别数据集的类型。这对于所有数据格式(包括 Parquet)均支持。我们可以利用此功能通过 s3 表函数和 [`DESCRIBE`](/sql-reference/statements/describe-table) 命令识别数据的 ClickHouse 类型。请注意,我们在下面使用了通配符模式 `*.parquet` 来读取 `stackoverflow/parquet/posts` 文件夹中的所有文件。 +ClickHouse 提供了模式推断能力,可以自动识别数据集的类型。这对所有数据格式(包括 Parquet)都受到支持。我们可以利用此功能,通过 s3 表函数和 [`DESCRIBE`](/sql-reference/statements/describe-table) 命令识别数据的 ClickHouse 类型。请注意,我们使用 glob 模式 `*.parquet` 来读取 `stackoverflow/parquet/posts` 文件夹中的所有文件。 ```sql DESCRIBE TABLE s3('https://datasets-documentation.s3.eu-west-3.amazonaws.com/stackoverflow/parquet/posts/*.parquet') @@ -66,9 +67,9 @@ SETTINGS describe_compact_output = 1 └───────────────────────┴────────────────────────────────┘ ``` -> [s3 表函数](/sql-reference/table-functions/s3) 允许在 ClickHouse 中实时查询 S3 中的数据。此函数与 ClickHouse 支持的所有文件格式兼容。 +> [s3 表函数](/sql-reference/table-functions/s3) 允许从 ClickHouse 直接查询 S3 中的数据。此函数与 ClickHouse 支持的所有文件格式兼容。 -这为我们提供了一个初始的非优化模式。默认情况下,ClickHouse 将这些映射为等效的 Nullable 类型。我们可以使用简单的 `CREATE EMPTY AS SELECT` 命令创建一个 ClickHouse 表。 +这为我们提供了一个初步的、未优化的模式。默认情况下,ClickHouse 将这些映射为等效的 Nullable 类型。我们可以使用简单的 `CREATE EMPTY AS SELECT` 命令来创建一个 ClickHouse 表。 ```sql CREATE TABLE posts @@ -77,12 +78,12 @@ ORDER BY () EMPTY AS SELECT * FROM s3('https://datasets-documentation.s3.eu-west-3.amazonaws.com/stackoverflow/parquet/posts/*.parquet') ``` -有几点重要事项: +几个重要的要点: -我们的 `posts` 表在运行此命令后为空。没有数据被加载。 -我们已指定 MergeTree 作为我们的表引擎。MergeTree 是您可能使用的最常见 ClickHouse 表引擎。这是 ClickHouse 工具箱中的多功能工具,能够处理 PB 的数据,服务于大多数分析用例。对于需要支持高效更新的用例,存在其他表引擎。 +我们的 posts 表在运行此命令后是空的。没有数据被加载。 +我们指定了 MergeTree 作为我们的表引擎。MergeTree 是您可能使用的最常见的 ClickHouse 表引擎。它是 ClickHouse 盒子中的多功能工具,能够处理 PB 的数据,并服务于大多数分析用例。其他表引擎存在于例如需要支持高效更新的 CDC 用例中。 -子句 `ORDER BY ()` 意味着我们没有索引,更具体地说就是数据没有顺序。稍后会详细讲述。现在,只需知道所有查询将需要线性扫描。 +子句 `ORDER BY ()` 表示我们没有索引,更具体地说,我们的数据没有顺序。稍后会详细介绍。在此之前,请了解所有查询都将需要线性扫描。 要确认表已创建: @@ -118,7 +119,7 @@ ENGINE = MergeTree('/clickhouse/tables/{uuid}/{shard}', '{replica}') ORDER BY tuple() ``` -定义好我们的初始模式后,我们可以使用 `INSERT INTO SELECT` 填充数据,通过 s3 表函数读取数据。以下命令在一个 8 核 ClickHouse Cloud 实例上,大约 2 分钟内加载 `posts` 数据。 +定义了初始模式后,我们可以使用 `INSERT INTO SELECT` 来填充数据,通过 s3 表函数读取数据。以下代码在 8 核的 ClickHouse Cloud 实例上大约花费 2 分钟加载了 `posts` 数据。 ```sql INSERT INTO posts SELECT * FROM s3('https://datasets-documentation.s3.eu-west-3.amazonaws.com/stackoverflow/parquet/posts/*.parquet') @@ -126,59 +127,59 @@ INSERT INTO posts SELECT * FROM s3('https://datasets-documentation.s3.eu-west-3. 0 rows in set. Elapsed: 148.140 sec. Processed 59.82 million rows, 38.07 GB (403.80 thousand rows/s., 257.00 MB/s.) ``` -> 上述查询加载了 6000 万行。虽然对于 ClickHouse 而言数量不大,但网络连接较慢的用户可能希望加载部分数据。通过简单地通过通配符模式指定他们希望加载的年份,可以实现此功能,例如 `https://datasets-documentation.s3.eu-west-3.amazonaws.com/stackoverflow/parquet/posts/2008.parquet` 或 `https://datasets-documentation.s3.eu-west-3.amazonaws.com/stackoverflow/parquet/posts/{2008, 2009}.parquet`。有关如何使用通配符模式来目标特定文件子集,请参见 [此处](/sql-reference/table-functions/file#globs-in-path)。 +> 上述查询加载了 6000 万行。尽管对于 ClickHouse 来说数量较小,但较慢的互联网连接用户可能希望加载数据的子集。这可以通过简单指定他们希望加载的年份的 glob 模式来实现,例如 `https://datasets-documentation.s3.eu-west-3.amazonaws.com/stackoverflow/parquet/posts/2008.parquet` 或 `https://datasets-documentation.s3.eu-west-3.amazonaws.com/stackoverflow/parquet/posts/{2008, 2009}.parquet`。请参见 [这里](/sql-reference/table-functions/file#globs-in-path) 了解如何使用 glob 模式来定位文件子集。 ## 优化类型 {#optimizing-types} ClickHouse 查询性能的秘密之一是压缩。 -磁盘上的数据越少,I/O 就越少,因此查询和插入速度更快。任何压缩算法的 CPU 开销在大多数情况下都将被 I/O 的减少所抵消。因此,改善数据的压缩应该是确保 ClickHouse 查询快速的首要任务。 - -> 关于 ClickHouse 为何如此有效地压缩数据,我们推荐 [这篇文章](https://clickhouse.com/blog/optimize-clickhouse-codecs-compression-schema)。简而言之,作为一个列式数据库,值将按列顺序写入。 如果这些值是排过序的,相同的值将相邻。压缩算法利用数据的连续模式。除此之外,ClickHouse 具有编解码器和细粒度数据类型,允许用户进一步调整压缩技术。 - -ClickHouse 中的压缩会受到 3 个主要因素的影响:排序键、数据类型以及使用的任何编解码器。所有这些都可以通过模式配置。 - -通过简单的类型优化过程可以获得最大初始压缩和查询性能的提升。可以应用一些简单的规则来优化模式: - -- **使用严格类型** - 我们的初始模式中许多列使用字符串,但它们显然是数值型。使用正确的类型将确保在过滤和聚合时获得期望的语义。日期类型也是如此,已经在 Parquet 文件中正确提供。 -- **避免 Nullable 列** - 默认情况下,上述列被假定为 Null。Nullable 类型允许查询确定空值与 Null 值之间的区别。这会创建一个额外的 UInt8 类型的列。每当用户处理可空列时,必须处理此额外的列。这会导致额外的存储空间使用,并几乎总是对查询性能产生负面影响。仅在类型的默认空值与 Null 值之间存在差异时才使用 Nullable。例如,`ViewCount` 列中的空值使用 0 表示对于大多数查询将是足够的且不会影响结果。如果需要将空值视为不同的值,通常可以使用过滤器从查询中排除空值。 -- **使用最小精度的数值类型** - ClickHouse 拥有一系列针对不同数值范围和精度设计的数值类型。始终旨在最小化表示列所使用的位数。除了具有不同大小的整数(例如 Int16),ClickHouse 还提供无符号变体,其最小值为 0。这可能允许在列中使用更少的位数,例如,UInt16 的最大值为 65535,是 Int16 的两倍。如果可能,优先使用这些类型而不是较大的有符号变体。 -- **最小精度的日期类型** - ClickHouse 支持多种日期和日期时间类型。可以使用 Date 和 Date32 来存储纯日期,后者支持更大的日期范围,但需要更多的位数。DateTime 和 DateTime64 支持日期时间。DateTime 限制为秒粒度,使用 32 位。DateTime64,如其名所示,使用 64 位,但支持高达纳秒粒度的时间。与往常一样,选择适合查询的颗粒度较粗的版本,尽量减少所需的位数。 -- **使用 LowCardinality** - 具有较少唯一值的数字、字符串、日期或日期时间列可以使用 LowCardinality 类型进行编码。此字典编码值,减少磁盘上的大小。考虑将该列用于唯一值少于 10k 的列。 -- **固定字符串用于特殊情况** - 长度固定的字符串可以使用 FixedString 类型进行编码,例如语言和货币代码。当数据的长度恰好为 N 字节时,这种方式是有效的。在所有其他情况下,这可能会降低效率,优先使用 LowCardinality。 -- **使用枚举进行数据验证** - 枚举类型可以用于有效地编码枚举类型。枚举可以是 8 位或 16 位,具体取决于它们需要存储的唯一值的数量。如果您需要在插入时进行相关验证(未声明的值将被拒绝)或希望执行利用枚举值自然顺序的查询,请考虑使用此选项,例如想象一下一个反馈列包含用户响应 `Enum(':(' = 1, ':|' = 2, ':)' = 3)`。 - -> 提示:要查找所有列的范围和独特值的数量,用户可以使用简单的查询 `SELECT * APPLY min, * APPLY max, * APPLY uniq FROM table FORMAT Vertical`。我们建议在较小的数据子集上进行此操作,因为这可能会非常耗费资源。该查询要求数字至少被定义为数字,以获得准确的结果,即不能是字符串。 - -通过将这些简单规则应用于我们的 `posts` 表,我们可以为每一列确定最佳类型: - -| 列名 | 是否为数值 | 最小值,最大值 | 唯一值 | Nulls | 注释 | 优化类型 | -|-------------------------|------------|------------------------------------------------------------------------|---------|-------|-------------------------------------------------------------------------------------------|-------------------------------------| -| `PostTypeId` | 是 | 1, 8 | 8 | 否 | | `Enum('Question' = 1, 'Answer' = 2, 'Wiki' = 3, 'TagWikiExcerpt' = 4, 'TagWiki' = 5, 'ModeratorNomination' = 6, 'WikiPlaceholder' = 7, 'PrivilegeWiki' = 8)` | -| `AcceptedAnswerId` | 是 | 0, 78285170 | 12282094 | 是 | 用 0 值区分 Null | UInt32 | -| `CreationDate` | 否 | 2008-07-31 21:42:52.667000000, 2024-03-31 23:59:17.697000000 | - | 否 | 毫秒粒度不需要,使用 DateTime | DateTime | -| `Score` | 是 | -217, 34970 | 3236 | 否 | | Int32 | -| `ViewCount` | 是 | 2, 13962748 | 170867 | 否 | | UInt32 | -| `Body` | 否 | - | - | 否 | | String | -| `OwnerUserId` | 是 | -1, 4056915 | 6256237 | 是 | | Int32 | -| `OwnerDisplayName` | 否 | - | 181251 | 是 | 将 Null 看作空字符串 | String | -| `LastEditorUserId` | 是 | -1, 9999993 | 1104694 | 是 | 0 是未使用的值可用作 Null | Int32 | -| `LastEditorDisplayName` | 否 | - | 70952 | 是 | 将 Null 看作空字符串。测试了 LowCardinality,但没有收益 | String | -| `LastEditDate` | 否 | 2008-08-01 13:24:35.051000000, 2024-04-06 21:01:22.697000000 | - | 否 | 毫秒粒度不需要,使用 DateTime | DateTime | -| `LastActivityDate` | 否 | 2008-08-01 12:19:17.417000000, 2024-04-06 21:01:22.697000000 | - | 否 | 毫秒粒度不需要,使用 DateTime | DateTime | -| `Title` | 否 | - | - | 否 | 将 Null 看作空字符串 | String | -| `Tags` | 否 | - | - | 否 | 将 Null 看作空字符串 | String | -| `AnswerCount` | 是 | 0, 518 | 216 | 否 | 将 Null 和 0 视为相同 | UInt16 | -| `CommentCount` | 是 | 0, 135 | 100 | 否 | 将 Null 和 0 视为相同 | UInt8 | -| `FavoriteCount` | 是 | 0, 225 | 6 | 是 | 将 Null 和 0 视为相同 | UInt8 | -| `ContentLicense` | 否 | - | 3 | 否 | LowCardinality 超过了 FixedString | LowCardinality(String) | -| `ParentId` | 否 | - | 20696028 | 是 | 将 Null 看作空字符串 | String | -| `CommunityOwnedDate` | 否 | 2008-08-12 04:59:35.017000000, 2024-04-01 05:36:41.380000000 | - | 是 | 将默认值 1970-01-01 用于 Null。毫秒粒度不需要,使用 DateTime | DateTime | -| `ClosedDate` | 否 | 2008-09-04 20:56:44, 2024-04-06 18:49:25.393000000 | - | 是 | 将默认值 1970-01-01 用于 Null。毫秒粒度不需要,使用 DateTime | DateTime | +磁盘上的数据减少意味着更少的 I/O,从而实现更快的查询和插入。任何压缩算法的 CPU 开销在大多数情况下将被 I/O 的减少所抵消。因此,改善数据的压缩应当是确保 ClickHouse 查询快速的首要关注点。 + +> 关于 ClickHouse 为何能如此高效地压缩数据,我们建议查看 [这篇文章](https://clickhouse.com/blog/optimize-clickhouse-codecs-compression-schema)。总之,作为一个列式数据库,值将按列顺序写入。如果这些值是已排序的,相同的值将相邻存放。压缩算法利用连续的数据模式。除此之外,ClickHouse 还具有编解码器和细粒度数据类型,允许用户进一步调整压缩技术。 + +ClickHouse 中的压缩将受到 3 个主要因素的影响:排序键、数据类型和所使用的任何编解码器。所有这些都通过模式进行配置。 + +通过简单的类型优化过程可以获得压缩和查询性能的最大初步改善。可以应用一些简单的规则来优化模式: + +- **使用严格类型** - 我们的初始模式使用了许多明显是数字类型的列使用了 Strings。使用正确的类型将确保在过滤和聚合时获得预期的语义。日期类型也是如此,在 Parquet 文件中已正确提供。 +- **避免 Nullable 列** - 默认情况下,上述列被假定为 Null。Nullable 类型允许查询区分空值和 Null 值。这会创建一个额外的 UInt8 类型列。每当用户处理 Nullable 列时,就必须处理这个附加的列。这会导致额外的存储空间使用,并几乎总会对查询性能产生负面影响。仅在类型的默认空值与 Null 之间存在差异时使用 Nullable。例如,`ViewCount` 列的空值使用 0 可能已足够,并不会影响结果。如果空值应被视为不同,则通常也可以通过过滤器从查询中排除。 +- **数字类型使用最小精度** - ClickHouse 提供了一些针对不同数字范围和精度设计的数字类型。始终旨在最小化表示列所需的位数。除了不同大小的整数(例如、Int16),ClickHouse 还提供无符号变体,其最小值为 0。这些可允许在列中使用更少的位,例如,UInt16 的最大值为 65535,是 Int16 的两倍。如果可能,请优先使用这些类型而不是较大的有符号变体。 +- **日期类型使用最小精度** - ClickHouse 支持多种日期和日期时间类型。Date 和 Date32 可用于存储纯日期,后者支持更大的日期范围但使用更多位。DateTime 和 DateTime64 提供了对于日期和时间的支持。DateTime 的粒度限制在秒,并使用 32 位。正如其名,DateTime64 使用 64 位,但支持高达纳秒的粒度。如以往选择查询中可接受的更粗版本,最小化所需的位数。 +- **使用 LowCardinality** - 具有较少唯一值的数字、字符串、日期或日期时间列可以使用 LowCardinality 类型编码。此字典编码值,减少磁盘上的大小。考虑对此类列应用此技术,尤其是其唯一值少于 10k 的列。 +- **特殊情况下使用 FixedString** - 长度固定的字符串可以使用 FixedString 类型进行编码,例如语言和货币代码。这在数据长度正好为 N 字节时是高效的。在所有其他情况下,可能会降低效率,而 LowCardinality 是优选。 +- **使用 Enums 进行数据验证** - Enum 类型可用于高效编码枚举类型。Enums 可以是 8 位或 16 位,具体取决于其要求存储的唯一值数量。如果您需要在插入时进行关联验证(未声明的值将被拒绝)或者希望执行利用 Enum 值的自然顺序的查询,例如想象一个包含用户响应的反馈列 `Enum(':(' = 1, ':|' = 2, ':)' = 3)`,请考虑使用此类型。 + +> 提示:要查找所有列的范围和唯一值数量,用户可以使用简单查询 `SELECT * APPLY min, * APPLY max, * APPLY uniq FROM table FORMAT Vertical`。我们建议在数据的较小子集上执行此操作,因为这可能是昂贵的。此查询要求数字至少定义为如此,以获得准确结果,即不得为字符串。 + +通过将这些简单规则应用于我们的 posts 表,我们可以为每一列识别出最佳类型: + +| 列 | 是数字 | 最小值, 最大值 | 唯一值 | Nulls | 评论 | 优化类型 | +|---------------------|--------|-----------------------------------------------------------------------|-----------|-------|--------------------------------------------------------------------------------------------|-----------------------------------------------------------------| +| `PostTypeId` | 是 | 1, 8 | 8 | 否 | | `Enum('Question' = 1, 'Answer' = 2, 'Wiki' = 3, 'TagWikiExcerpt' = 4, 'TagWiki' = 5, 'ModeratorNomination' = 6, 'WikiPlaceholder' = 7, 'PrivilegeWiki' = 8)` | +| `AcceptedAnswerId` | 是 | 0, 78285170 | 12282094 | 是 | 利用 0 值区分 Null | UInt32 | +| `CreationDate` | 否 | 2008-07-31 21:42:52.667000000, 2024-03-31 23:59:17.697000000 | - | 否 | 毫秒粒度不是必需的,使用 DateTime | DateTime | +| `Score` | 是 | -217, 34970 | 3236 | 否 | | Int32 | +| `ViewCount` | 是 | 2, 13962748 | 170867 | 否 | | UInt32 | +| `Body` | 否 | - | - | 否 | | String | +| `OwnerUserId` | 是 | -1, 4056915 | 6256237 | 是 | | Int32 | +| `OwnerDisplayName` | 否 | - | 181251 | 是 | 考虑 Null 为空字符串 | String | +| `LastEditorUserId` | 是 | -1, 9999993 | 1104694 | 是 | 0 是一个未使用的值可以用于 Null | Int32 | +| `LastEditorDisplayName`| 否 | - | 70952 | 是 | 考虑 Null 为空字符串。测试 LowCardinality 并无益 | String | +| `LastEditDate` | 否 | 2008-08-01 13:24:35.051000000, 2024-04-06 21:01:22.697000000 | - | 否 | 毫秒粒度不是必需的,使用 DateTime | DateTime | +| `LastActivityDate` | 否 | 2008-08-01 12:19:17.417000000, 2024-04-06 21:01:22.697000000 | - | 否 | 毫秒粒度不是必需的,使用 DateTime | DateTime | +| `Title` | 否 | - | - | 否 | 考虑 Null 为空字符串 | String | +| `Tags` | 否 | - | - | 否 | 考虑 Null 为空字符串 | String | +| `AnswerCount` | 是 | 0, 518 | 216 | 否 | 考虑 Null 和 0 为相同 | UInt16 | +| `CommentCount` | 是 | 0, 135 | 100 | 否 | 考虑 Null 和 0 为相同 | UInt8 | +| `FavoriteCount` | 是 | 0, 225 | 6 | 是 | 考虑 Null 和 0 为相同 | UInt8 | +| `ContentLicense` | 否 | - | 3 | 否 | LowCardinality 优于 FixedString | LowCardinality(String) | +| `ParentId` | 否 | - | 20696028 | 是 | 考虑 Null 为空字符串 | String | +| `CommunityOwnedDate` | 否 | 2008-08-12 04:59:35.017000000, 2024-04-01 05:36:41.380000000 | - | 是 | 考虑 Null 的默认值为 1970-01-01。毫秒粒度不是必需的,使用 DateTime | DateTime | +| `ClosedDate` | 否 | 2008-09-04 20:56:44, 2024-04-06 18:49:25.393000000 | - | 是 | 考虑 Null 的默认值为 1970-01-01。毫秒粒度不是必需的,使用 DateTime | DateTime |
-上述内容为我们提供了以下模式: +以上给我们提供了以下模式: ```sql CREATE TABLE posts_v2 @@ -211,7 +212,7 @@ ORDER BY tuple() COMMENT 'Optimized types' ``` -我们可以通过简单的 `INSERT INTO SELECT` 将数据从之前的表读取并插入到这个表中: +我们可以使用简单的 `INSERT INTO SELECT` 来填充它,从我们之前的表中读取数据并插入到此表中: ```sql INSERT INTO posts_v2 SELECT * FROM posts @@ -219,36 +220,36 @@ INSERT INTO posts_v2 SELECT * FROM posts 0 rows in set. Elapsed: 146.471 sec. Processed 59.82 million rows, 83.82 GB (408.40 thousand rows/s., 572.25 MB/s.) ``` -在我们的新模式中,我们不保留任何空值。上述插入将这些隐式转换为其各自类型的默认值 - 整数为 0,字符串为空值。ClickHouse 还会自动将任何数值转换为其目标精度。 -ClickHouse 中的主键(排序键) +在我们的新模式中,我们不保留任何 Null。上述插入将这些隐式转换为其相应类型的默认值 - 整数为 0,字符串为空值。ClickHouse 还会自动将任何数值转换为其目标精度。 +ClickHouse 中的主(排序)键 来自 OLTP 数据库的用户通常会寻找 ClickHouse 中的等效概念。 ## 选择排序键 {#choosing-an-ordering-key} -在 ClickHouse 通常使用的规模下,内存和磁盘效率至关重要。数据以称为分片的块写入 ClickHouse 表中,并应用规则来在后台合并这些分片。在 ClickHouse 中,每个分片都有自己的主索引。当分片合并时,合并后的分片的主索引也会合并。分片的主索引每组行有一个索引条目 - 这种技术称为稀疏索引。 +在 ClickHouse 通常使用的规模下,内存和磁盘效率至关重要。数据是按块写入 ClickHouse 表中,称为 parts,同时应用合并部分的规则。在 ClickHouse 中,每个 part 具有自己的主索引。当部分合并时,合并部分的主索引也被合并。部分的主索引每组行只具有一个索引条目 - 这种技术称为稀疏索引。 Sparse Indexing in ClickHouse -在 ClickHouse 中选择的键将不仅决定索引,还决定数据写入磁盘的顺序。因此,它可能会显著影响压缩水平,而这又会影响查询性能。导致大多数列的值以连续顺序写入的排序键将允许所选的压缩算法(和编解码器)更有效地压缩数据。 +在 ClickHouse 中选择的键将决定不仅是索引,而且是数据在磁盘上写入的顺序。因此,它可以显著影响压缩级别,从而影响查询性能。一个使大多数列的值按连续顺序写入的排序键将允许所选压缩算法(和编解码器)更有效地压缩数据。 -> 表中的所有列将根据指定的排序键的值排序,无论它们是否包含在键中。例如,如果将 `CreationDate` 用作键,则其他列中的所有值的顺序将与 `CreationDate` 列中的值的顺序相对应。可以指定多个排序键 - 这将以相同的语义对数据进行排序,就像 `SELECT` 查询中的 `ORDER BY` 子句一样。 +> 表中的所有列都将根据指定排序键的值进行排序,无论它们是否包含在键本身中。例如,若使用 `CreationDate` 作为键,则所有其他列中的值顺序将与 `CreationDate` 列中的值顺序相对应。可以指定多个排序键 - 这将与 `SELECT` 查询中的 `ORDER BY` 子句具有相同的语义。 -可以应用一些简单规则来帮助选择排序键。以下规则有时可能会冲突,所以请依次考虑。用户可以从这个过程识别出多个键,通常 4-5 个就足够了: +可以应用一些简单的规则来帮助选择排序键。以下内容有时可能会相互冲突,因此请按顺序考虑这些。用户可以从该过程识别多个键,通常 4-5 个足够: -- 选择与您的常见过滤条件对齐的列。如果某列在 `WHERE` 子句中使用频繁,将其优先包括在键中,而不是那些使用较少的列。 -- 优先选择可以在过滤时帮助排除大量总行的列,从而减少需要读取的数据量。 -- 优先选择可能与表中的其他列高度相关的列。这将有助于确保这些值也存储在连续的位置,从而改善压缩效果。 -- 在排序键中的列进行 `GROUP BY` 和 `ORDER BY` 操作可以更有效地使用内存。 +- 选择与常用过滤器对齐的列。如果某列在 `WHERE` 子句中使用频繁,优先考虑将其包含在关键字中,而不是那些使用较少的列。 +- 优先考虑在过滤时可以帮助排除大量总行数的列,从而减少需要读取的数据量。 +- 优先考虑与表中其他列高度相关的列。这将有助于确保这些值也是连续存储,从而改善压缩。 +- 对于排序键中的列,`GROUP BY` 和 `ORDER BY` 操作可以更高效地使用内存。 -在确定排序键的列子集时,请按照特定顺序声明列。这一顺序可以显著影响查询中对二级键列过滤的效率,以及表的数据文件的压缩比。一般来说,最好按基数的升序对键进行排序。这应该与排序键中较后列的过滤效率较低这一事实保持平衡。平衡这些行为,并考虑您的访问模式(最重要的是测试不同的变体)。 +在识别排序键的列子集时,请按特定顺序声明这些列。此顺序可能显著影响过滤的效率及表的数据文件的压缩比。通常,最好按基数的升序排列键。需要平衡的因素是,过滤在排序键后出现的列的效率将低于过滤在元组中较早出现的列。平衡这些行为并考虑您的访问模式(最重要的是测试变体)。 ### 示例 {#example} -将上述指南应用于我们的 `posts` 表,假设我们的用户希望执行按日期和帖子类型过滤的分析,例如: +将上述指导方针应用于我们的 `posts` 表,假设我们的用户希望进行按日期和帖子类型过滤的分析,例如: -“最近 3 个月哪个问题的评论最多”。 +“在过去 3 个月内哪个问题的评论最多”。 -使用我们之前的 `posts_v2` 表(类型已优化但没有排序键)的问题查询: +使用我们早前的 `posts_v2` 表,该表具有优化类型但没有排序键的查询如下: ```sql SELECT @@ -270,11 +271,11 @@ LIMIT 3 Peak memory usage: 429.38 MiB. ``` -> 即便扫描了所有 6000 万行,此查询也非常快速 - ClickHouse 就是快 :) 您必须相信我们,排序键在 TB 和 PB 规模上是值得的! +> 尽管对 6000 万行进行了线性扫描,查询速度依然很快——ClickHouse 的速度就是快 :) 你必须相信我们,在 TB 和 PB 级别中,排序键是值得的! -让我们选择 `PostTypeId` 和 `CreationDate` 作为我们的排序键。 +我们选择列 `PostTypeId` 和 `CreationDate` 作为我们的排序键。 -也许在我们的案例中,我们期望用户始终按 `PostTypeId` 进行过滤。该值的基数为 8,并且代表了我们排序键的第一个条目的逻辑选择。鉴于日期粒度过滤可能是足够的(它仍然会使 DateTime 过滤受益),因此我们使用 `toDate(CreationDate)` 作为我们键的第二个组成部分。这也将生成更小的索引,因为日期可以使用 16 位表示,从而加速过滤。我们的最终键条目是 `CommentCount`,以协助查找评论最多的帖子(最终排序)。 +也许在我们的案例中,我们期待用户始终按 `PostTypeId` 进行过滤。它的基数为 8,代表了我们排序键中第一个条目的逻辑选择。认识到日期粒度过滤可能已足够(其仍将受益于日期时间过滤),因此我们将 `toDate(CreationDate)` 作为键的第二个组件。这也将产生较小的索引,因为日期可以用 16 表示,快速过滤。我们最终的键条目是 `CommentCount`,以帮助查找评论最多的帖子(最终排序)。 ```sql CREATE TABLE posts_v3 @@ -313,7 +314,6 @@ INSERT INTO posts_v3 SELECT * FROM posts_v2 0 rows in set. Elapsed: 158.074 sec. Processed 59.82 million rows, 76.21 GB (378.42 thousand rows/s., 482.14 MB/s.) Peak memory usage: 6.41 GiB. - Our previous query improves the query response time by over 3x: SELECT @@ -328,25 +328,25 @@ LIMIT 3 10 rows in set. Elapsed: 0.020 sec. Processed 290.09 thousand rows, 21.03 MB (14.65 million rows/s., 1.06 GB/s.) ``` -对于对通过使用特定类型和适当排序键实现的压缩改进感兴趣的用户,请参见 [ClickHouse 中的压缩](/data-compression/compression-in-clickhouse)。如果用户需要进一步提高压缩,我们还推荐查看 [选择正确的列压缩编解码器](/data-compression/compression-in-clickhouse#choosing-the-right-column-compression-codec)。 +对于对使用特定类型和适当排序键所取得的压缩改进感兴趣的用户,请参见 [ClickHouse 中的压缩](/data-compression/compression-in-clickhouse)。如果用户需要进一步改进压缩,我们也建议查看 [选择正确的列压缩编解码器](/data-compression/compression-in-clickhouse#choosing-the-right-column-compression-codec)。 -## 接下来: 数据建模技术 {#next-data-modeling-techniques} +## 下一步:数据建模技术 {#next-data-modeling-techniques} -到目前为止,我们仅迁移了单个表。虽然这使我们能够介绍一些核心 ClickHouse 概念,但大多数模式不幸并非如此简单。 +到目前为止,我们迁移了仅一个表。虽然这使我们能够介绍某些核心 ClickHouse 概念,但大多数模式不幸并不是如此简单。 -在下面列出的其他指南中,我们将探索多种技术,以重构我们更广泛的模式,以便进行最佳 ClickHouse 查询。在此过程中,我们旨在保持 `Posts` 作为我们大多数分析查询的中心表。尽管其他表仍可以独立查询,但我们假设大多数分析希望在 `posts` 的上下文中进行。 +在下面列出的其他指南中,我们将探讨一些技术,以重新构建我们更广泛的模式,实现最佳的 ClickHouse 查询。在这个过程中,我们的目标是使 `Posts` 继续作为大多数分析查询的核心表。尽管其他表仍然可以独立查询,但我们假设大多数分析希望在 `posts` 的上下文中进行。 -> 在本节中,我们使用优化版本的其他表。虽然我们提供了这些表的模式,但为简洁起见,我们省略了所做的决策。这些基于前面描述的规则,我们留给读者推断这些决策。 +> 在本节中,我们使用其他表的优化变体。虽然我们提供了这些的模式,但出于简洁性,我们省略了做出的决策。这些都是基于先前描述的规则,我们将推测决策留给读者。 -以下方法都旨在最小化使用 JOIN 的需要,以优化读取和提高查询性能。虽然 ClickHouse 完全支持 JOIN,但我们建议在 JOIN 查询中尽量少用(2 到 3 个表的 JOIN 查询是可以的),以实现最佳性能。 +以下方法都旨在最小化使用 JOIN 的需求,以优化读取并改善查询性能。虽然 ClickHouse 完全支持 JOIN,但我们建议适度使用(JOIN 查询中 2 到 3 个表是可以的),以实现最佳性能。 -> ClickHouse 没有外键的概念。这并不禁止 JOIN,但意味着参考完整性由用户在应用程序级别进行管理。在 ClickHouse 这样的 OLAP 系统中,数据完整性通常在应用程序级别或数据摄取过程中管理,而不是通过数据库自身强制执行,因为这样会产生显著的开销。这种方法允许更大的灵活性和更快的数据插入。这与 ClickHouse 对速度和大数据集的读取和插入查询的可扩展性重点一致。 +> ClickHouse 没有外键的概念。这并不禁止进行连接,但意味着引用完整性由用户在应用程序级别管理。在像 ClickHouse 这样的 OLAP 系统中,数据完整性通常在应用程序级别或数据摄取过程中进行管理,而不是由数据库本身强制执行,因为这样会产生显著的开销。这种方法允许更大的灵活性和更快的数据插入。这与 ClickHouse 专注于性能和可扩展性的读取和插入查询相关,尤其对于非常大的数据集。 -为了最小化在查询时使用 JOIN,用户有几种工具/方法: +为了在查询时最小化 JOIN 的使用,用户有几种工具/方法: -- [**数据去规范化**](/data-modeling/denormalization) - 通过合并表并使用复杂类型处理非 1:1 关系来去规范化数据。这通常涉及将任何 JOIN 从查询时间移到插入时间。 -- [**字典**](/dictionary) - ClickHouse 特有的功能,用于处理直接的 JOIN 和键值查找。 -- [**增量物化视图**](/materialized-view/incremental-materialized-view) - ClickHouse 的一种功能,将计算的成本从查询时间转移到插入时间,允许逐步计算聚合值。 -- [**可刷新的物化视图**](/materialized-view/refreshable-materialized-view) - 类似于其他数据库产品中使用的物化视图,此功能允许周期性计算查询的结果并缓存结果。 +- [**数据反规范化**](/data-modeling/denormalization) - 通过合并表并为非 1:1 关系使用复杂类型来反规范化数据。这通常涉及将在查询时连接的任何部分移到插入时。 +- [**字典**](/dictionary) - ClickHouse 特有的处理直接连接和键值查找的功能。 +- [**增量物化视图**](/materialized-view/incremental-materialized-view) - ClickHouse 的一项功能,可以将计算的成本从查询时间转移到插入时间,包括增量计算聚合值的能力。 +- [**可刷新的物化视图**](/materialized-view/refreshable-materialized-view) - 类似于其他数据库产品使用的物化视图,这允许定期计算查询的结果并缓存结果。 -我们将在每个指南中探讨这些方法,突出何时适用,并提供示例说明如何将其应用于解决 Stack Overflow 数据集的问题。 +我们将在每个指南中探讨这些方法,突出何时每种方法是合适的,并示例如何将其应用于解决 Stack Overflow 数据集的问题。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/data-modeling/schema-design.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/data-modeling/schema-design.md.hash index f5a7d94b3d5..9a951fcfb05 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/data-modeling/schema-design.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/data-modeling/schema-design.md.hash @@ -1 +1 @@ -7e8fc072dbf0c319 +94f6ffeefab1a4a2 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/horizontal-scaling.md b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/horizontal-scaling.md deleted file mode 100644 index c43ee857ba2..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/horizontal-scaling.md +++ /dev/null @@ -1,485 +0,0 @@ ---- -'slug': '/architecture/horizontal-scaling' -'sidebar_label': '扩展' -'sidebar_position': 10 -'title': '扩展' -'description': '页面描述旨在提供可扩展性的示例架构' ---- - -import Image from '@theme/IdealImage'; -import ReplicationShardingTerminology from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_replication-sharding-terminology.md'; -import ConfigFileNote from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_config-files.md'; -import scalingOut1 from '@site/static/images/deployment-guides/scaling-out-1.png'; - -## 描述 {#description} -此示例架构设计用于提供可扩展性。它包括三个节点:两个结合了 ClickHouse 和协调功能(ClickHouse Keeper)的服务器,以及一个仅有 ClickHouse Keeper 的第三个服务器,以完成三者的法定人数。在该示例中,我们将创建一个数据库、表和一个分布式表,以查询两个节点上的数据。 - -## 级别:基础 {#level-basic} - - - -## 环境 {#environment} -### 架构图 {#architecture-diagram} - -2 个分片和 1 个副本的架构图 - -|节点|描述| -|----|-----------| -|`chnode1`|数据 + ClickHouse Keeper| -|`chnode2`|数据 + ClickHouse Keeper| -|`chnode3`|用于 ClickHouse Keeper 的法定人数| - -:::note -在生产环境中,我们强烈建议 ClickHouse Keeper 运行在专用主机上。此基本配置在 ClickHouse 服务器进程内运行 Keeper 功能。有关独立部署 ClickHouse Keeper 的说明,请参见 [安装文档](/getting-started/install/install.mdx)。 -::: - -## 安装 {#install} - -按照 [您的归档类型的说明](/getting-started/install/install.mdx) 在三台服务器上安装 ClickHouse(.deb、.rpm、.tar.gz 等)。对于此示例,您将依次在所有三台机器上遵循 ClickHouse 服务器和客户端的安装说明。 - -## 编辑配置文件 {#editing-configuration-files} - - - -## chnode1 配置 {#chnode1-configuration} - -对于 `chnode1`,有五个配置文件。您可以选择将这些文件合并为一个文件,但为了文档的清晰性,可以单独查看它们。当您浏览配置文件时,您会发现 `chnode1` 和 `chnode2` 的大部分配置是相同的;差异将被强调。 - -### 网络和日志配置 {#network-and-logging-configuration} - -这些值可以根据您的需要进行自定义。此示例配置为您提供一个在 1000M 时滚动的调试日志三次。ClickHouse 将在端口 8123 和 9000 上监听 IPv4 网络,并将使用端口 9009 进行服务器之间的通信。 - -```xml title="network-and-logging.xml on chnode1" - - - debug - /var/log/clickhouse-server/clickhouse-server.log - /var/log/clickhouse-server/clickhouse-server.err.log - 1000M - 3 - - clickhouse - 0.0.0.0 - 8123 - 9000 - 9009 - -``` - -### ClickHouse Keeper 配置 {#clickhouse-keeper-configuration} - -ClickHouse Keeper 为数据复制和分布式 DDL 查询执行提供协调系统。ClickHouse Keeper 与 Apache ZooKeeper 兼容。此配置在端口 9181 上启用 ClickHouse Keeper。突出显示的行指定此 Keeper 实例的 `server_id` 为 1。这是三个服务器中 `enable-keeper.xml` 文件的唯一差异。`chnode2` 的 `server_id` 将设置为 `2`,而 `chnode3` 的 `server_id` 将设置为 `3`。所有三台服务器上的 raft 配置部分是相同的,下面高亢显示 `server_id` 与 raft 配置中的 `server` 实例之间的关系。 - -:::note -如果由于任何原因替换或重建了 Keeper 节点,请不要重复使用现有的 `server_id`。例如,若 `server_id` 为 `2` 的 Keeper 节点被重建,请将其 `server_id` 设置为 `4` 或更高。 -::: - -```xml title="enable-keeper.xml on chnode1" - - - 9181 - # highlight-next-line - 1 - /var/lib/clickhouse/coordination/log - /var/lib/clickhouse/coordination/snapshots - - - 10000 - 30000 - trace - - - - # highlight-start - - 1 - chnode1 - 9234 - - # highlight-end - - 2 - chnode2 - 9234 - - - 3 - chnode3 - 9234 - - - - -``` - -### 宏配置 {#macros-configuration} - -宏 `shard` 和 `replica` 减少了分布式 DDL 的复杂性。配置的值会自动替换到您的 DDL 查询中,从而简化您的 DDL。此配置的宏指定了每个节点的分片和副本编号。 -在这个 2 个分片 1 个副本的示例中,副本宏在 `chnode1` 和 `chnode2` 上为 `replica_1`,因为只有一个副本。分片宏在 `chnode1` 上为 `1`,在 `chnode2` 上为 `2`。 - -```xml title="macros.xml on chnode1" - - - # highlight-next-line - 1 - replica_1 - - -``` - -### 复制和分片配置 {#replication-and-sharding-configuration} - -从顶部开始: -- XML 的 `remote_servers` 部分指定环境中的每个集群。属性 `replace=true` 将默认 ClickHouse 配置中的示例 `remote_servers` 替换为此文件中指定的 `remote_servers` 配置。没有此属性,此文件中的远程服务器将被附加到默认中的示例列表。 -- 在此示例中,有一个名为 `cluster_2S_1R` 的集群。 -- 创建了一个名为 `cluster_2S_1R` 的集群的密钥,值为 `mysecretphrase`。该密钥在环境中的所有远程服务器之间共享,以确保正确的服务器连接在一起。 -- 集群 `cluster_2S_1R` 有两个分片,并且每个分片有一个副本。查看本文档开头的架构图,并将其与下面 XML 中的两个 `shard` 定义进行比较。在每个分片定义中都有一个副本。该副本是该特定分片的。为此副本指定了主机和端口。配置中第一个分片的副本存储在 `chnode1` 上,第二个分片的副本存储在 `chnode2` 上。 -- 分片的内部复制设置为 true。每个分片可以在配置文件中定义 `internal_replication` 参数。如果将此参数设置为 true,则写入操作将选择第一个健康的副本并将数据写入其上。 - -```xml title="remote-servers.xml on chnode1" - - - - mysecretphrase - - true - - chnode1 - 9000 - - - - true - - chnode2 - 9000 - - - - - -``` - -### 配置使用 Keeper {#configuring-the-use-of-keeper} - -在上面的几个文件中配置了 ClickHouse Keeper。此配置文件 `use-keeper.xml` 正在配置 ClickHouse 服务器使用 ClickHouse Keeper 进行复制和分布式 DDL 的协调。此文件指定 ClickHouse 服务器应在节点 `chnode1` - 3 上使用端口 9181 上的 Keeper,该文件在 `chnode1` 和 `chnode2` 上是相同的。 - -```xml title="use-keeper.xml on chnode1" - - - - chnode1 - 9181 - - - chnode2 - 9181 - - - chnode3 - 9181 - - - -``` - -## chnode2 配置 {#chnode2-configuration} - -由于 `chnode1` 和 `chnode2` 的配置非常相似,这里将仅指出差异。 - -### 网络和日志配置 {#network-and-logging-configuration-1} - -```xml title="network-and-logging.xml on chnode2" - - - debug - /var/log/clickhouse-server/clickhouse-server.log - /var/log/clickhouse-server/clickhouse-server.err.log - 1000M - 3 - - clickhouse - 0.0.0.0 - 8123 - 9000 - 9009 - -``` - -### ClickHouse Keeper 配置 {#clickhouse-keeper-configuration-1} - -此文件包含 `chnode1` 和 `chnode2` 之间的两个差异之一。在 Keeper 配置中,`server_id` 设置为 `2`。 - -```xml title="enable-keeper.xml on chnode2" - - - 9181 - # highlight-next-line - 2 - /var/lib/clickhouse/coordination/log - /var/lib/clickhouse/coordination/snapshots - - - 10000 - 30000 - trace - - - - - 1 - chnode1 - 9234 - - # highlight-start - - 2 - chnode2 - 9234 - - # highlight-end - - 3 - chnode3 - 9234 - - - - -``` - -### 宏配置 {#macros-configuration-1} - -宏配置是 `chnode1` 和 `chnode2` 之间的差异之一。在此节点上,`shard` 设置为 `2`。 - -```xml title="macros.xml on chnode2" - - - # highlight-next-line - 2 - replica_1 - - -``` - -### 复制和分片配置 {#replication-and-sharding-configuration-1} - -```xml title="remote-servers.xml on chnode2" - - - - mysecretphrase - - true - - chnode1 - 9000 - - - - true - - chnode2 - 9000 - - - - - -``` - -### 配置使用 Keeper {#configuring-the-use-of-keeper-1} - -```xml title="use-keeper.xml on chnode2" - - - - chnode1 - 9181 - - - chnode2 - 9181 - - - chnode3 - 9181 - - - -``` - -## chnode3 配置 {#chnode3-configuration} - -由于 `chnode3` 不存储数据,仅用于 ClickHouse Keeper 提供法定人数的第三个节点,`chnode3` 只有两个配置文件,一个用于配置网络和日志,另一个用于配置 ClickHouse Keeper。 - -### 网络和日志配置 {#network-and-logging-configuration-2} - -```xml title="network-and-logging.xml on chnode3" - - - debug - /var/log/clickhouse-server/clickhouse-server.log - /var/log/clickhouse-server/clickhouse-server.err.log - 1000M - 3 - - clickhouse - 0.0.0.0 - 8123 - 9000 - 9009 - -``` - -### ClickHouse Keeper 配置 {#clickhouse-keeper-configuration-2} - -```xml title="enable-keeper.xml on chnode3" - - - 9181 - # highlight-next-line - 3 - /var/lib/clickhouse/coordination/log - /var/lib/clickhouse/coordination/snapshots - - - 10000 - 30000 - trace - - - - - 1 - chnode1 - 9234 - - - 2 - chnode2 - 9234 - - # highlight-start - - 3 - chnode3 - 9234 - - # highlight-end - - - -``` - -## 测试 {#testing} - -1. 连接到 `chnode1` 并验证上述配置的集群 `cluster_2S_1R` 是否存在 - -```sql title="Query" -SHOW CLUSTERS -``` - -```response title="Response" -┌─cluster───────┐ -│ cluster_2S_1R │ -└───────────────┘ -``` - -2. 在集群上创建一个数据库 - -```sql title="Query" -CREATE DATABASE db1 ON CLUSTER cluster_2S_1R -``` - -```response title="Response" -┌─host────┬─port─┬─status─┬─error─┬─num_hosts_remaining─┬─num_hosts_active─┐ -│ chnode2 │ 9000 │ 0 │ │ 1 │ 0 │ -│ chnode1 │ 9000 │ 0 │ │ 0 │ 0 │ -└─────────┴──────┴────────┴───────┴─────────────────────┴──────────────────┘ -``` - -3. 在集群上创建一个使用 MergeTree 表引擎的表。 -:::note -我们无需在表引擎上指定参数,因为这些参数将根据我们的宏自动定义。 -::: - -```sql title="Query" -CREATE TABLE db1.table1 ON CLUSTER cluster_2S_1R -( - `id` UInt64, - `column1` String -) -ENGINE = MergeTree -ORDER BY id -``` -```response title="Response" -┌─host────┬─port─┬─status─┬─error─┬─num_hosts_remaining─┬─num_hosts_active─┐ -│ chnode1 │ 9000 │ 0 │ │ 1 │ 0 │ -│ chnode2 │ 9000 │ 0 │ │ 0 │ 0 │ -└─────────┴──────┴────────┴───────┴─────────────────────┴──────────────────┘ -``` - -4. 连接到 `chnode1` 并插入一行 - -```sql title="Query" -INSERT INTO db1.table1 (id, column1) VALUES (1, 'abc'); -``` - -5. 连接到 `chnode2` 并插入一行 - -```sql title="Query" -INSERT INTO db1.table1 (id, column1) VALUES (2, 'def'); -``` - -6. 连接到 `chnode1` 或 `chnode2` 其中一个节点,您将只看到在该节点上插入的表中的行。 -例如,在 `chnode2` 上 - -```sql title="Query" -SELECT * FROM db1.table1; -``` - -```response title="Response" -┌─id─┬─column1─┐ -│ 2 │ def │ -└────┴─────────┘ -``` - -7. 创建一个分布式表以查询两个节点上的两个分片。 -(在此示例中,`rand()` 函数设置为分片键,以便随机分配每个插入) - -```sql title="Query" -CREATE TABLE db1.table1_dist ON CLUSTER cluster_2S_1R -( - `id` UInt64, - `column1` String -) -ENGINE = Distributed('cluster_2S_1R', 'db1', 'table1', rand()) -``` - -```response title="Response" -┌─host────┬─port─┬─status─┬─error─┬─num_hosts_remaining─┬─num_hosts_active─┐ -│ chnode2 │ 9000 │ 0 │ │ 1 │ 0 │ -│ chnode1 │ 9000 │ 0 │ │ 0 │ 0 │ -└─────────┴──────┴────────┴───────┴─────────────────────┴──────────────────┘ -``` - -8. 连接到 `chnode1` 或 `chnode2`,并查询分布式表以查看两个行。 - -```sql title="Query" -SELECT * FROM db1.table1_dist; -``` - -```reponse title="Response" -┌─id─┬─column1─┐ -│ 2 │ def │ -└────┴─────────┘ -┌─id─┬─column1─┐ -│ 1 │ abc │ -└────┴─────────┘ -``` - -## 详细信息: {#more-information-about} - -- [分布式表引擎](/engines/table-engines/special/distributed.md) -- [ClickHouse Keeper](/guides/sre/keeper/index.md) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/horizontal-scaling.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/horizontal-scaling.md.hash deleted file mode 100644 index 8fd82edd48e..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/horizontal-scaling.md.hash +++ /dev/null @@ -1 +0,0 @@ -c221f17aa0002fdd diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/index.md index 85c2aef9624..d29896e180a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/index.md @@ -1,17 +1,18 @@ --- 'slug': '/deployment-guides/index' 'title': '部署指南概述' -'description': '部署和扩展部分的登陆页面' +'description': '部署和扩展部分的登录页面' +'doc_type': 'landing-page' --- -# 部署与扩展 +# 部署和扩展 本节涵盖以下主题: -| 主题 | +| 主题 | |------------------------------------------------------------------| -| [介绍](/architecture/introduction) | -| [水平扩展](/architecture/horizontal-scaling) | -| [故障容错的复制](/architecture/replication) | -| [集群部署](/architecture/cluster-deployment) | +| [介绍](/architecture/introduction) | +| [横向扩展](/architecture/horizontal-scaling) | +| [容错的复制](/architecture/replication) | +| [集群部署](/architecture/cluster-deployment) | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/index.md.hash index 77ba247dae4..6b5b933b862 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/index.md.hash @@ -1 +1 @@ -aed0a6e41b60b100 +adb447969a6c4949 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/parallel-replicas.mdx b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/parallel-replicas.mdx index 65d734dd981..c023f855b0c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/parallel-replicas.mdx +++ b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/parallel-replicas.mdx @@ -3,7 +3,8 @@ 'title': '并行副本' 'keywords': - 'parallel replica' -'description': '在本指南中,我们将首先讨论 ClickHouse 如何通过分布式表将查询分配到多个分片,然后讨论查询如何利用多个副本进行执行。' +'description': '在本指南中,我们将首先讨论 ClickHouse 如何通过分布式表在多个分片之间分配查询,然后查询如何利用多个副本进行执行。' +'doc_type': 'reference' --- import Image from '@theme/IdealImage'; @@ -22,164 +23,164 @@ import image_9 from '@site/static/images/deployment-guides/parallel-replicas-9.p ## 介绍 {#introduction} -ClickHouse 可以极快地处理查询,但这些查询是如何在多个服务器之间分发和并行执行的呢? +ClickHouse 可以非常快速地处理查询,但这些查询是如何在多个服务器之间分配和并行化的呢? -> 在本指南中,我们将首先讨论 ClickHouse 如何通过分布式表将查询分发到多个分片,然后再讨论查询如何利用多个副本来执行。 +> 在本指南中,我们将首先讨论 ClickHouse 如何通过分布式表将查询分配到多个分片上,然后讨论查询如何利用多个副本来执行。 ## 分片架构 {#sharded-architecture} -在无共享架构中,集群通常会被拆分成多个分片,每个分片包含总体数据的一个子集。一个分布式表位于这些分片之上,提供对完整数据的统一视图。 +在无共享架构中,集群通常被拆分为多个分片,每个分片包含整体数据的一个子集。一个分布式表位于这些分片之上,为完整数据提供统一视图。 -读取可以发送到本地表。查询的执行将仅在指定的分片上进行,或者可以发送到分布式表,在这种情况下,每个分片将执行给定的查询。查询分布式表的服务器将汇总数据并响应客户端: +读取请求可以发送到本地表。查询执行将仅在指定的分片上发生,或者可以将其发送到分布式表,在这种情况下,每个分片将执行给定的查询。发出查询的服务器将聚合数据并响应客户端: -分片架构 +sharded architecture -上图可视化了客户端查询分布式表时发生的情况: +上图可视化了客户查询分布式表时发生的情况:
  1. - select 查询被发送到一个节点上的分布式表(可以通过轮询策略或在负载均衡器路由到特定服务器后进行)。这个节点现在将充当协调者。 + 选择查询通过负载均衡器以任意方式发送到节点上的分布式表(通过轮询策略或在被指向特定服务器后)。该节点将充当协调者。
  2. - 节点将根据分布式表指定的信息定位需要执行查询的每个分片,并将查询发送到每个分片。 + 节点将通过分布式表指定的信息找到需要执行查询的每个分片,并将查询发送到每个分片。
  3. - 每个分片在本地读取、过滤和聚合数据,然后将可合并的状态发送回协调者。 + 每个分片本地读取、过滤和聚合数据,然后将可合并的状态发送回协调者。
  4. 协调节点合并数据,然后将响应发送回客户端。
-当我们加入副本时,过程相似,唯一的区别是每个分片只有一个副本会执行查询。这意味着将能够并行处理更多查询。 +当我们将副本引入混合时,过程相似,唯一的区别是每个分片仅有一个副本会执行查询。这意味着可以并行处理更多查询。 ## 非分片架构 {#non-sharded-architecture} -ClickHouse Cloud 具有与上述架构非常不同的架构。(有关更多详细信息,请参见 ["ClickHouse Cloud 架构"](https://clickhouse.com/docs/cloud/reference/architecture))。由于计算和存储的分离,以及几乎无限的存储量,分片的重要性降低。 +ClickHouse Cloud 具有与上述不同的架构。(有关更多细节,请参见 ["ClickHouse Cloud Architecture"](https://clickhouse.com/docs/cloud/reference/architecture))。通过计算与存储的分离,以及几乎无限的存储,分片的需求变得不那么重要。 -下图展示了 ClickHouse Cloud 的架构: +下图展示了 ClickHouse Cloud 架构: -非分片架构 +non sharded architecture -该架构使我们能够几乎瞬时地添加和移除副本,确保了非常高的集群可扩展性。ClickHouse Keeper 集群(右侧显示)确保我们对于元数据拥有单一的可信源。副本可以从 ClickHouse Keeper 集群获取元数据,并且所有副本维护相同的数据。数据本身存储在对象存储中,SSD 缓存允许我们加速查询。 +这种架构使我们能够几乎瞬时地添加和移除副本,从而确保非常高的集群可扩展性。ClickHouse Keeper 集群(如右所示)确保我们拥有元数据的单一真实性来源。副本可以从 ClickHouse Keeper 集群获取元数据,并且所有副本维护相同的数据。数据本身存储在对象存储中,SSD 缓存使查询速度得以提升。 -但是,我们现在如何在多个服务器之间分发查询执行呢?在分片架构中,由于每个分片实际上可以在数据的子集上执行查询,这一点相当明显。没有分片时,它是如何工作的呢? +但我们如何在多个服务器之间分配查询执行呢?在分片架构中很明显,因为每个分片实际上可以在数据的子集上执行查询。当没有分片时,这会如何工作呢? ## 引入并行副本 {#introducing-parallel-replicas} -为了通过多个服务器并行化查询执行,我们首先需要能够将我们的一个服务器指定为协调者。协调者负责创建需要执行的任务列表,确保所有任务都被执行、聚合并将结果返回给客户端。就像大多数分布式系统一样,这将是接收初始查询的节点的角色。我们还需要定义工作单元。在分片架构中,工作单元是分片,即数据的子集。在并行副本中,我们将使用称为 [granules](/docs/guides/best-practices/sparse-primary-indexes#data-is-organized-into-granules-for-parallel-data-processing) 的小部分表作为工作单元。 +为了通过多个服务器并行化查询执行,我们首先需要能够将我们的一个服务器指定为协调者。协调者负责创建需要执行的任务列表,确保所有任务都被执行、聚合并将结果返回给客户端。与大多数分布式系统一样,这将是接收初始查询的节点的角色。我们还需要定义工作单元。在分片架构中,工作单元是分片,即数据的子集。使用并行副本时,我们将使用表的一个小部分,称为 [granules](/docs/guides/best-practices/sparse-primary-indexes#data-is-organized-into-granules-for-parallel-data-processing),作为工作单元。 -现在,让我们借助下图看看它在实践中的工作原理: +现在,让我们看看实际操作中的工作流程,借助下图: -并行副本 +Parallel replicas 使用并行副本时:
  1. - 客户端的查询在经过负载均衡器后发送到一个节点。这个节点成为此查询的协调者。 + 客户端的查询在经过负载均衡器后发送到一个节点。该节点成为此查询的协调者。
  2. - 节点分析每个部分的索引,并选择合适的部分和 granules 进行处理。 + 节点分析每个部分的索引,并选择正确的部分和 granules 进行处理。
  3. - 协调者将工作负载分解为一组可以分配给不同副本的 granules。 + 协调者将工作负载拆分为可以分配给不同副本的一组 granules。
  4. - 每组 granules 由相应的副本处理,完成后将可合并状态发送到协调者。 + 每组 granules 由相应的副本处理,完成时将可合并的状态发送给协调者。
  5. 最后,协调者合并来自副本的所有结果,然后将响应返回给客户端。
-以上步骤概述了并行副本在理论上的工作方式。然而,在实践中,有许多因素可能会阻止这种逻辑完美运行: +上述步骤概述了并行副本在理论上的工作原理。然而,在实际中,有许多因素可能会阻止这种逻辑完美运行:
  1. 一些副本可能不可用。
  2. - 在 ClickHouse 中,复制是异步的,某些副本在某些时刻可能没有相同的部分。 + ClickHouse 中的复制是异步的,一些副本在某些时间点可能没有相同的部分。
  3. 需要以某种方式处理副本之间的尾延迟。
  4. - 基于每个副本的活动,文件系统缓存在副本之间有所不同,这意味着随机任务分配可能由于缓存局部性导致性能不佳。 + 文件系统缓存因每个副本的活动而异,这意味着随机的任务分配可能导致由于缓存局部性而性能不佳。
-我们将在接下来的章节中探讨如何克服这些因素。 +我们将在接下来的部分中探讨如何克服这些因素。 ### 公告 {#announcements} -为了解决上述列表中的 (1) 和 (2) 问题,我们引入了公告的概念。让我们使用下图可视化它的工作原理: +为了解决上述列表中的(1)和(2),我们引入了公告的概念。让我们通过下图来可视化它的工作原理: -公告 +Announcements
  1. 客户端的查询在经过负载均衡器后发送到一个节点。该节点成为此查询的协调者。
  2. - 协调节点向集群中的所有副本发送请求以获取公告。副本可能对某个表的当前部分集有稍微不同的视图。因此,我们需要收集这些信息以避免不正确的调度决策。 + 协调节点向集群中的所有副本发送请求以获取公告。副本可能对表的当前部分集有稍微不同的视图。因此,我们需要收集这些信息,以避免不正确的调度决策。
  3. - 协调节点然后使用公告来定义可以分配给不同副本的一组 granules。在这里,例如,我们可以看到没有来自部件 3 的 granules 被分配给副本 2,因为此副本在其公告中没有提供该部分。另外,请注意没有任务被分配给副本 3,因为该副本未提供公告。 + 协调节点然后使用公告来定义可以分配给不同副本的一组 granules。在这里,例如,我们可以看到由于副本 2 在其公告中没有提供这个部分,因此没有来自部分 3 的 granules 被分配给副本 2。同时注意,由于副本没有提供公告,没有任务被分配给副本 3。
  4. - 每个副本在其 granules 子集上处理完查询后,将可合并的状态发送回协调者,协调者合并结果并将响应发送给客户端。 + 每个副本处理完其 granules 子集的查询后,将可合并的状态发送回协调者,协调者合并结果,响应发送给客户端。
### 动态协调 {#dynamic-coordination} -为了解决尾延迟的问题,我们添加了动态协调。这意味着并非所有的 granules 都在一个请求中发送给一个副本,而每个副本能够向协调者请求新的任务(待处理的 granules 集)。协调者将根据接收到的公告向副本提供 granules 集。 +为了解决尾延迟的问题,我们添加了动态协调。这意味着所有 granules 不会在一次请求中发送给副本,而是每个副本将能够向协调者请求新的任务(要处理的一组 granules)。协调者将根据接收到的公告为副本提供一组 granules。 -假设我们处于所有副本都已发送公告的阶段。 +假设我们处于处理过程的阶段,此时所有副本都已发送包含所有部分的公告。 -下图可视化了动态协调的工作原理: +下图可视化了动态协调的工作方式: -动态协调 - 第 1 部分 +Dynamic Coordination - part 1
  1. - 副本通知协调者节点它们能够处理任务,它们还可以指定可以处理的工作量。 + 副本向协调节点表明它们能够处理任务,同时它们还可以指定自己能够处理多少工作。
  2. 协调者将任务分配给副本。
-动态协调 - 第 2 部分 +Dynamic Coordination - part 2
  1. - 副本 1 和 2 能够非常快速地完成它们的任务。它们将向协调者请求另一个任务。 + 副本 1 和 2 能够非常快地完成其任务。它们将向协调节点请求另一个任务。
  2. - 协调者向副本 1 和 2 分配新任务。 + 协调者将新任务分配给副本 1 和 2。
-动态协调 - 第 3 部分 +Dynamic Coordination - part 3
  1. - 所有副本现在都已完成它们的任务处理。它们请求更多任务。 + 所有副本现在都完成了对其任务的处理。它们请求更多任务。
  2. - 协调者使用公告检查待处理的任务,但没有剩余任务。 + 协调者根据公告检查剩余需要处理的任务,但没有剩余任务。
  3. - 协调者告诉副本一切都已处理。它现在将合并所有可合并状态并响应查询。 + 协调者告诉副本一切都已处理。它将合并所有可合并的状态并对查询做出响应。
### 管理缓存局部性 {#managing-cache-locality} -最后一个潜在问题是如何处理缓存局部性。如果查询被多次执行,我们如何确保相同的任务路由到相同的副本?在前面的示例中,我们有以下任务分配: +最后一个可能存在的问题是我们如何处理缓存局部性。如果查询多次执行,我们如何确保相同的任务路由到相同的副本?在前面的例子中,我们有以下任务分配: @@ -192,19 +193,19 @@ ClickHouse Cloud 具有与上述架构非常不同的架构。(有关更多详 - + - + - + @@ -212,43 +213,44 @@ ClickHouse Cloud 具有与上述架构非常不同的架构。(有关更多详
部件 1部分 1 g1, g6, g7 g2, g4, g5 g3
部件 2部分 2 g1 g2, g4, g5 g3
部件 3部分 3 g1, g6 g2, g4, g5 g3
-为了确保相同的任务被分配给相同的副本并可以利用缓存,发生了两件事。计算部件 + granules 集合(任务)的哈希。应用任务分配的副本数量的模运算。 +为了确保相同的任务被分配给相同的副本并能够受益于缓存,会发生两件事。部分 + granules 集合(即一个任务)的哈希会被计算。然后应用一个模数来决定任务分配的副本数量。 -纸面上这听起来不错,但在现实中,某个副本的突然负载或网络劣化,如果始终使用同一副本执行某些任务,可能会导致尾延迟。如果 `max_parallel_replicas` 小于副本的数量,则随机选择副本进行查询执行。 +在纸面上,这听起来不错,但在实际中,如果某个副本突然负载过重,或网络出现降级,则可能导致尾延迟,因为相同的副本持续用于执行某些任务。如果 `max_parallel_replicas` 小于副本的数量,则会随机选择副本进行查询执行。 ### 任务窃取 {#task-stealing} -如果某个副本处理任务的速度慢于其他副本,其他副本将尝试“窃取”原则上属于该副本的任务,以减少尾延迟。 +如果某个副本处理任务的速度比其他副本慢,其他副本将尝试通过哈希“窃取”原则上属于该副本的任务,以减少尾延迟。 ### 限制 {#limitations} -此功能有已知的限制,主要限制记录在本节中。 +此功能已知有一些限制,其中主要限制在本节中进行了文档说明。 :::note -如果您发现一个不属于下面给出的限制的问题,并且怀疑并行副本是原因,请在 GitHub 上使用标签 `comp-parallel-replicas` 提交问题。 +如果您发现一个问题,并不属于下面列出的限制,并怀疑并行副本可能是原因,请在 GitHub 上打开一个问题,使用标签 `comp-parallel-replicas`。 ::: -| 限制 | 描述 | -|----------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| 复杂查询 | 当前并行副本对简单查询工作得相当不错。复杂层次如 CTEs、子查询、JOIN、非扁平查询等可能会对查询性能产生负面影响。 | -| 小查询 | 如果您正在执行一个不处理大量行的查询,在多个副本上执行可能不会提高性能,因为副本之间协调的网络时间可能导致查询执行中的额外周期。您可以通过使用设置 [`parallel_replicas_min_number_of_rows_per_replica`](/docs/operations/settings/settings#parallel_replicas_min_number_of_rows_per_replica) 来限制这些问题。 | -| 使用 FINAL 时并行副本被禁用 | | -| 高基数数据和复杂聚合 | 高基数聚合需要发送大量数据,可能会显著减慢查询速度。 | -| 与新分析器的兼容性 | 在特定场景下,新分析器可能显著减慢或加速查询执行。 | +| 限制 | 描述 | +|-----------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| 复杂查询 | 当前并行副本对于简单查询功能良好。CTE、子查询、JOIN、非平铺查询等复杂性层将对查询性能产生负面影响。 | +| 小查询 | 如果您执行的查询处理的行数不多,在多个副本上执行可能不会提高性能,因为副本之间的协调网络时间可能导致查询执行中额外的周期。通过使用设置 [`parallel_replicas_min_number_of_rows_per_replica`](/docs/operations/settings/settings#parallel_replicas_min_number_of_rows_per_replica) 可以减少这些问题的影响。 | +| FINAL 时禁用并行副本 | | +| 投影与并行副本不一起使用 | | +| 高基数数据和复杂聚合 | 高基数聚合需要发送大量数据,会显著减慢查询速度。 | +| 与新分析器的兼容性 | 在特定情况下,新的分析器可能会显著减慢或加快查询执行。 | ## 与并行副本相关的设置 {#settings-related-to-parallel-replicas} -| 设置 | 描述 | -|----------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `enable_parallel_replicas` | `0`: 禁用
`1`: 启用
`2`: 强制使用并行副本,如果未使用则抛出异常。 | -| `cluster_for_parallel_replicas` | 用于并行复制的集群名称;如果您使用的是 ClickHouse Cloud,请使用 `default`。 | -| `max_parallel_replicas` | 用于查询在多个副本上执行的最大副本数,指定的数量若低于集群中的副本数,节点将随机选择。此值也可以过度承诺以适应水平扩展。 | -| `parallel_replicas_min_number_of_rows_per_replica` | 帮助根据需要处理的行数限制使用的副本数,使用的副本数由:
`estimated rows to read` / `min_number_of_rows_per_replica` 定义。 | -| `allow_experimental_analyzer` | `0`: 使用旧分析器
`1`: 使用新分析器。

并行副本的行为可能会根据使用的分析器而变化。 | +| 设置 | 描述 | +|------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `enable_parallel_replicas` | `0`: 禁用
`1`: 启用
`2`: 强制使用并行副本,如果不使用将抛出异常。 | +| `cluster_for_parallel_replicas` | 用于并行复制的集群名称;如果您使用 ClickHouse Cloud,请使用 `default`。 | +| `max_parallel_replicas` | 用于在多个副本上执行查询的最大副本数,如果指定的数量低于集群中的副本数,则将随机选择节点。该值也可以被超分配以考虑水平扩展。 | +| `parallel_replicas_min_number_of_rows_per_replica` | 帮助限制基于需要处理的行数的副本数,使用的副本数由以下公式定义:
`estimated rows to read` / `min_number_of_rows_per_replica`。 | +| `allow_experimental_analyzer` | `0`: 使用旧分析器
`1`: 使用新分析器。

并行副本的行为可能会根据使用的分析器而有所不同。 | -## 调查并行副本的问题 {#investigating-issues-with-parallel-replicas} +## 调查并行副本问题 {#investigating-issues-with-parallel-replicas} -您可以检查 [`system.query_log`](/docs/operations/system-tables/query_log) 表中每个查询所使用的设置。您还可以查看 [`system.events`](/docs/operations/system-tables/events) 表,以查看服务器上发生的所有事件,并可以使用 [`clusterAllReplicas`](/docs/sql-reference/table-functions/cluster) 表函数查看所有副本上的表(如果您是云用户,请使用 `default`)。 +您可以通过 [`system.query_log`](/docs/operations/system-tables/query_log) 表检查每个查询使用的设置。您还可以查看 [`system.events`](/docs/operations/system-tables/events) 表,以查看在服务器上发生的所有事件,您可以使用 [`clusterAllReplicas`](/docs/sql-reference/table-functions/cluster) 表函数查看所有副本上的表(如果您是云用户,请使用 `default`)。 ```sql title="Query" SELECT @@ -307,7 +309,7 @@ WHERE event ILIKE '%ParallelReplicas%' ```
-[`system.text_log`](/docs/operations/system-tables/text_log) 表还包含使用并行副本执行查询的信息: +[`system.text_log`](/docs/operations/system-tables/text_log) 表还包含有关使用并行副本执行查询的信息: ```sql title="Query" SELECT message @@ -380,7 +382,7 @@ Received from 3 replica ```
-最后,您还可以使用 `EXPLAIN PIPELINE`。它突出显示 ClickHouse 将如何执行查询以及将使用哪些资源来执行查询。让我们以以下查询为例: +最后,您还可以使用 `EXPLAIN PIPELINE`。这将突出显示 ClickHouse 将如何执行查询以及用于执行查询的资源。以以下查询为例: ```sql SELECT count(), uniq(pageId) , min(timestamp), max(timestamp) @@ -389,7 +391,7 @@ WHERE type='type3' GROUP BY toYear(timestamp) LIMIT 10 ``` -让我们查看没有并行副本的查询管道: +让我们来看一下没有并行副本的查询管道: ```sql title="EXPLAIN PIPELINE (without parallel replica)" EXPLAIN PIPELINE graph = 1, compact = 0 @@ -402,9 +404,9 @@ SETTINGS allow_experimental_parallel_reading_from_replicas=0 FORMAT TSV; ``` -EXPLAIN 不使用 parallel_replica +EXPLAIN without parallel replica -现在使用并行副本: +现在有并行副本: ```sql title="EXPLAIN PIPELINE (with parallel replica)" EXPLAIN PIPELINE graph = 1, compact = 0 @@ -417,4 +419,4 @@ SETTINGS allow_experimental_parallel_reading_from_replicas=2 FORMAT TSV; ``` -EXPLAIN 使用 parallel_replica +EXPLAIN with parallel replica diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/parallel-replicas.mdx.hash b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/parallel-replicas.mdx.hash index 23c726836f9..d246a52e876 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/parallel-replicas.mdx.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/parallel-replicas.mdx.hash @@ -1 +1 @@ -6364ec63eca1d1bd +606fe16a52d7b34d diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replicated.md b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replicated.md deleted file mode 100644 index ef6df9521c9..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replicated.md +++ /dev/null @@ -1,564 +0,0 @@ ---- -'slug': '/architecture/replication' -'sidebar_label': '用于容错的复制' -'sidebar_position': 10 -'title': '用于容错的复制' -'description': '页面描述了一个配置有五台服务器的示例架构。两台用于托管数据副本,其余用于协调数据的复制' ---- - -import Image from '@theme/IdealImage'; -import ReplicationShardingTerminology from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_replication-sharding-terminology.md'; -import ConfigFileNote from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_config-files.md'; -import KeeperConfigFileNote from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_keeper-config-files.md'; -import ReplicationArchitecture from '@site/static/images/deployment-guides/architecture_1s_2r_3_nodes.png'; - -## 描述 {#description} -在此架构中,配置了五台服务器。两台用于托管数据的副本。其余的三台服务器用于协调数据的复制。在这个例子中,我们将创建一个数据库和一个将在两个数据节点之间复制的表,使用的是 ReplicatedMergeTree 表引擎。 - -## 级别:基础 {#level-basic} - - - -## 环境 {#environment} -### 架构图 {#architecture-diagram} - -包含 ReplicatedMergeTree 的 1 个分片和 2 个副本的架构图 - -|节点|描述| -|----|-----------| -|clickhouse-01|数据| -|clickhouse-02|数据| -|clickhouse-keeper-01|分布式协调| -|clickhouse-keeper-02|分布式协调| -|clickhouse-keeper-03|分布式协调| - -:::note -在生产环境中,我们强烈建议为 ClickHouse Keeper 使用 *专用* 主机。在测试环境中,将 ClickHouse Server 和 ClickHouse Keeper 组合在同一服务器上运行是可以接受的。另一个基本示例,[横向扩展](/deployment-guides/horizontal-scaling.md),就是使用这种方法。在这个示例中,我们展示了将 Keeper 与 ClickHouse Server 分开的推荐方法。Keeper 服务器可以较小,通常每台 Keeper 服务器 4GB RAM 就足够,直到你的 ClickHouse Servers 变得非常大。 -::: - -## 安装 {#install} - -在两台服务器 `clickhouse-01` 和 `clickhouse-02` 上安装 ClickHouse 服务器和客户端,遵循 [你的归档类型的安装说明](/getting-started/install/install.mdx) (.deb, .rpm, .tar.gz 等)。 - -在三台服务器 `clickhouse-keeper-01`、`clickhouse-keeper-02` 和 `clickhouse-keeper-03` 上安装 ClickHouse Keeper,遵循 [你的归档类型的安装说明](/getting-started/install/install.mdx) (.deb, .rpm, .tar.gz 等)。 - -## 编辑配置文件 {#editing-configuration-files} - - - -## clickhouse-01 配置 {#clickhouse-01-configuration} - -对于 clickhouse-01,有五个配置文件。您可以选择将这些文件合并为一个文件,但为了文档的清晰性,单独查看它们可能更简单。当您阅读配置文件时,您会发现 clickhouse-01 和 clickhouse-02 之间的大部分配置是相同的;不同之处将被突出显示。 - -### 网络和日志配置 {#network-and-logging-configuration} - -这些值可以根据您的需要自定义。该示例配置为您提供: -- 一个将在 1000M 处滚动三次的调试日志 -- 当您使用 `clickhouse-client` 连接时显示的名称是 `cluster_1S_2R node 1` -- ClickHouse 将在 IPV4 网络上侦听 8123 和 9000 端口。 - -```xml title="/etc/clickhouse-server/config.d/network-and-logging.xml on clickhouse-01" - - - debug - /var/log/clickhouse-server/clickhouse-server.log - /var/log/clickhouse-server/clickhouse-server.err.log - 1000M - 3 - - cluster_1S_2R node 1 - 0.0.0.0 - 8123 - 9000 - -``` - -### 宏配置 {#macros-configuration} - -宏 `shard` 和 `replica` 减少了分布式 DDL 的复杂性。配置的值会自动替换您的 DDL 查询,从而简化您的 DDL。此配置的宏指定了每个节点的分片和副本编号。 -在这个 1 个分片 2 个副本的示例中,clickhouse-01 上的副本宏是 `replica_1`,clickhouse-02 上的副本宏是 `replica_2`。分片宏在 clickhouse-01 和 clickhouse-02 上都是 `1`,因为只有一个分片。 - -```xml title="/etc/clickhouse-server/config.d/macros.xml on clickhouse-01" - - - 01 - - 01 - cluster_1S_2R - - -``` - -### 复制和分片配置 {#replication-and-sharding-configuration} - -从顶部开始: -- XML 的 remote_servers 部分指定环境中的每个集群。属性 `replace=true` 用指定在此文件中的 remote_server 配置替换默认 ClickHouse 配置中的示例 remote_servers。没有此属性,此文件中的远程服务器将附加到默认样本的列表中。 -- 在此示例中,有一个名为 `cluster_1S_2R` 的集群。 -- 为集群 `cluster_1S_2R` 创建一个名为 `mysecretphrase` 的秘密。该秘密在环境中的所有远程服务器之间共享,以确保正确的服务器连接在一起。 -- 集群 `cluster_1S_2R` 有一个分片和两个副本。看看本文档开头的架构图,并将其与下面 XML 的 `shard` 定义进行对比。分片定义包含两个副本。每个副本的主机和端口被指定。一个副本存储在 `clickhouse-01` 上,另一个副本存储在 `clickhouse-02` 上。 -- 此分片的内部复制设置为 true。每个分片可以在配置文件中定义 internal_replication 参数。如果此参数设置为 true,则写操作选择第一个健康的副本并将数据写入它。 - -```xml title="/etc/clickhouse-server/config.d/remote-servers.xml on clickhouse-01" - - - - mysecretphrase - - true - - clickhouse-01 - 9000 - - - clickhouse-02 - 9000 - - - - - -``` - -### 配置使用 Keeper {#configuring-the-use-of-keeper} - -此配置文件 `use-keeper.xml` 正在配置 ClickHouse Server 使用 ClickHouse Keeper 进行复制和分布式 DDL 的协调。此文件指定 ClickHouse Server 应在点击 `clickhouse-keeper-01` - 03 节点上的 9181 端口使用 Keeper,该文件在 `clickhouse-01` 和 `clickhouse-02` 上是相同的。 - -```xml title="/etc/clickhouse-server/config.d/use-keeper.xml on clickhouse-01" - - - - - clickhouse-keeper-01 - 9181 - - - clickhouse-keeper-02 - 9181 - - - clickhouse-keeper-03 - 9181 - - - -``` - -## clickhouse-02 配置 {#clickhouse-02-configuration} - -由于 clickhouse-01 和 clickhouse-02 的配置非常相似,这里只会指出不同之处。 - -### 网络和日志配置 {#network-and-logging-configuration-1} - -此文件在 clickhouse-01 和 clickhouse-02 上是相同的,唯一的例外是 `display_name`。 - -```xml title="/etc/clickhouse-server/config.d/network-and-logging.xml on clickhouse-02" - - - debug - /var/log/clickhouse-server/clickhouse-server.log - /var/log/clickhouse-server/clickhouse-server.err.log - 1000M - 3 - - - cluster_1S_2R node 2 - 0.0.0.0 - 8123 - 9000 - -``` - -### 宏配置 {#macros-configuration-1} - -宏配置在 clickhouse-01 和 clickhouse-02 之间是不同的。此节点上的 `replica` 设置为 `02`。 - -```xml title="/etc/clickhouse-server/config.d/macros.xml on clickhouse-02" - - - 01 - - 02 - cluster_1S_2R - - -``` - -### 复制和分片配置 {#replication-and-sharding-configuration-1} - -此文件在 clickhouse-01 和 clickhouse-02 上是相同的。 - -```xml title="/etc/clickhouse-server/config.d/remote-servers.xml on clickhouse-02" - - - - mysecretphrase - - true - - clickhouse-01 - 9000 - - - clickhouse-02 - 9000 - - - - - -``` - -### 配置使用 Keeper {#configuring-the-use-of-keeper-1} - -此文件在 clickhouse-01 和 clickhouse-02 上是相同的。 - -```xml title="/etc/clickhouse-server/config.d/use-keeper.xml on clickhouse-02" - - - - - clickhouse-keeper-01 - 9181 - - - clickhouse-keeper-02 - 9181 - - - clickhouse-keeper-03 - 9181 - - - -``` - -## clickhouse-keeper-01 配置 {#clickhouse-keeper-01-configuration} - - - -ClickHouse Keeper 提供了数据复制和分布式 DDL 查询执行的协调系统。ClickHouse Keeper 与 Apache ZooKeeper 兼容。此配置启用 ClickHouse Keeper,端口为 9181。突出显示的行指定该 Keeper 实例的 server_id 为 1。这是 `enable-keeper.xml` 文件在三台服务器之间的唯一差异。 `clickhouse-keeper-02` 的 `server_id` 设置为 `2`,而 `clickhouse-keeper-03` 的 `server_id` 设置为 `3`。raft 配置部分在三个服务器上是相同的,下面突出显示以展示 `server_id` 与 raft 配置中的 `server` 实例之间的关系。 - -:::note -如果由于任何原因替换或重建 Keeper 节点,请不要重用现有的 `server_id`。例如,如果 `server_id` 为 `2` 的 Keeper 节点被重建,请给它分配 `4` 或更高的 server_id。 -::: - -```xml title="/etc/clickhouse-keeper/keeper_config.xml on clickhouse-keeper-01" - - - trace - /var/log/clickhouse-keeper/clickhouse-keeper.log - /var/log/clickhouse-keeper/clickhouse-keeper.err.log - 1000M - 3 - - 0.0.0.0 - - 9181 - - 1 - /var/lib/clickhouse/coordination/log - /var/lib/clickhouse/coordination/snapshots - - 10000 - 30000 - trace - - - - - 1 - clickhouse-keeper-01 - 9234 - - - - 2 - clickhouse-keeper-02 - 9234 - - - 3 - clickhouse-keeper-03 - 9234 - - - - -``` - -## clickhouse-keeper-02 配置 {#clickhouse-keeper-02-configuration} - -`clickhouse-keeper-01` 和 `clickhouse-keeper-02` 之间只有一行差异。此节点上的 `server_id` 设置为 `2`。 - -```xml title="/etc/clickhouse-keeper/keeper_config.xml on clickhouse-keeper-02" - - - trace - /var/log/clickhouse-keeper/clickhouse-keeper.log - /var/log/clickhouse-keeper/clickhouse-keeper.err.log - 1000M - 3 - - 0.0.0.0 - - 9181 - - 2 - /var/lib/clickhouse/coordination/log - /var/lib/clickhouse/coordination/snapshots - - 10000 - 30000 - trace - - - - 1 - clickhouse-keeper-01 - 9234 - - - - 2 - clickhouse-keeper-02 - 9234 - - - - 3 - clickhouse-keeper-03 - 9234 - - - - -``` - -## clickhouse-keeper-03 配置 {#clickhouse-keeper-03-configuration} - -`clickhouse-keeper-01` 和 `clickhouse-keeper-03` 之间只有一行差异。此节点上的 `server_id` 设置为 `3`。 - -```xml title="/etc/clickhouse-keeper/keeper_config.xml on clickhouse-keeper-03" - - - trace - /var/log/clickhouse-keeper/clickhouse-keeper.log - /var/log/clickhouse-keeper/clickhouse-keeper.err.log - 1000M - 3 - - 0.0.0.0 - - 9181 - - 3 - /var/lib/clickhouse/coordination/log - /var/lib/clickhouse/coordination/snapshots - - 10000 - 30000 - trace - - - - 1 - clickhouse-keeper-01 - 9234 - - - 2 - clickhouse-keeper-02 - 9234 - - - - 3 - clickhouse-keeper-03 - 9234 - - - - - -``` - -## 测试 {#testing} - -为了获得对 ReplicatedMergeTree 和 ClickHouse Keeper 的经验,您可以运行以下命令,您将会: -- 在上述配置的集群上创建一个数据库 -- 使用 ReplicatedMergeTree 表引擎在数据库上创建一个表 -- 在一个节点上插入数据并在另一个节点上查询 -- 停止一个 ClickHouse 服务器节点 -- 在运行的节点上插入更多数据 -- 重启已停止的节点 -- 验证当查询已重启的节点时数据是否可用 - -### 验证 ClickHouse Keeper 是否正在运行 {#verify-that-clickhouse-keeper-is-running} - -`mntr` 命令用于验证 ClickHouse Keeper 是否正在运行,并获取关于三个 Keeper 节点关系的状态信息。在本示例中使用的配置中,有三个节点协同工作。节点将选举出一个领导者,其余节点将成为跟随者。`mntr` 命令提供与性能相关的信息,以及特定节点是否为跟随者或领导者的信息。 - -:::tip -您可能需要安装 `netcat` 以便向 Keeper 发送 `mntr` 命令。请查看 [nmap.org](https://nmap.org/ncat/) 页面以获取下载信息。 -::: - -```bash title="run from a shell on clickhouse-keeper-01, clickhouse-keeper-02, and clickhouse-keeper-03" -echo mntr | nc localhost 9181 -``` -```response title="response from a follower" -zk_version v23.3.1.2823-testing-46e85357ce2da2a99f56ee83a079e892d7ec3726 -zk_avg_latency 0 -zk_max_latency 0 -zk_min_latency 0 -zk_packets_received 0 -zk_packets_sent 0 -zk_num_alive_connections 0 -zk_outstanding_requests 0 - -# highlight-next-line -zk_server_state follower -zk_znode_count 6 -zk_watch_count 0 -zk_ephemerals_count 0 -zk_approximate_data_size 1271 -zk_key_arena_size 4096 -zk_latest_snapshot_size 0 -zk_open_file_descriptor_count 46 -zk_max_file_descriptor_count 18446744073709551615 -``` - -```response title="response from a leader" -zk_version v23.3.1.2823-testing-46e85357ce2da2a99f56ee83a079e892d7ec3726 -zk_avg_latency 0 -zk_max_latency 0 -zk_min_latency 0 -zk_packets_received 0 -zk_packets_sent 0 -zk_num_alive_connections 0 -zk_outstanding_requests 0 - -# highlight-next-line -zk_server_state leader -zk_znode_count 6 -zk_watch_count 0 -zk_ephemerals_count 0 -zk_approximate_data_size 1271 -zk_key_arena_size 4096 -zk_latest_snapshot_size 0 -zk_open_file_descriptor_count 48 -zk_max_file_descriptor_count 18446744073709551615 - -# highlight-start -zk_followers 2 -zk_synced_followers 2 - -# highlight-end -``` - -### 验证 ClickHouse 集群功能 {#verify-clickhouse-cluster-functionality} - -在一个终端中使用 `clickhouse client` 连接到节点 `clickhouse-01`,在另一个终端中使用 `clickhouse client` 连接到节点 `clickhouse-02`。 - -1. 在上述配置的集群上创建一个数据库 - -```sql title="run on either node clickhouse-01 or clickhouse-02" -CREATE DATABASE db1 ON CLUSTER cluster_1S_2R -``` -```response -┌─host──────────┬─port─┬─status─┬─error─┬─num_hosts_remaining─┬─num_hosts_active─┐ -│ clickhouse-02 │ 9000 │ 0 │ │ 1 │ 0 │ -│ clickhouse-01 │ 9000 │ 0 │ │ 0 │ 0 │ -└───────────────┴──────┴────────┴───────┴─────────────────────┴──────────────────┘ -``` - -2. 使用 ReplicatedMergeTree 表引擎在数据库上创建一个表 -```sql title="run on either node clickhouse-01 or clickhouse-02" -CREATE TABLE db1.table1 ON CLUSTER cluster_1S_2R -( - `id` UInt64, - `column1` String -) -ENGINE = ReplicatedMergeTree -ORDER BY id -``` -```response -┌─host──────────┬─port─┬─status─┬─error─┬─num_hosts_remaining─┬─num_hosts_active─┐ -│ clickhouse-02 │ 9000 │ 0 │ │ 1 │ 0 │ -│ clickhouse-01 │ 9000 │ 0 │ │ 0 │ 0 │ -└───────────────┴──────┴────────┴───────┴─────────────────────┴──────────────────┘ -``` -3. 在一个节点上插入数据并在另一个节点上查询 -```sql title="run on node clickhouse-01" -INSERT INTO db1.table1 (id, column1) VALUES (1, 'abc'); -``` - -4. 在节点 `clickhouse-02` 上查询表 -```sql title="run on node clickhouse-02" -SELECT * -FROM db1.table1 -``` -```response -┌─id─┬─column1─┐ -│ 1 │ abc │ -└────┴─────────┘ -``` - -5. 在另一个节点上插入数据,并在节点 `clickhouse-01` 上查询 -```sql title="run on node clickhouse-02" -INSERT INTO db1.table1 (id, column1) VALUES (2, 'def'); -``` - -```sql title="run on node clickhouse-01" -SELECT * -FROM db1.table1 -``` -```response -┌─id─┬─column1─┐ -│ 1 │ abc │ -└────┴─────────┘ -┌─id─┬─column1─┐ -│ 2 │ def │ -└────┴─────────┘ -``` - -6. 停止一个 ClickHouse 服务器节点 -通过运行与用于启动节点的操作系统命令类似的命令来停止一个 ClickHouse 服务器节点。如果您使用了 `systemctl start` 启动节点,则使用 `systemctl stop` 停止它。 - -7. 在运行的节点上插入更多数据 -```sql title="run on the running node" -INSERT INTO db1.table1 (id, column1) VALUES (3, 'ghi'); -``` - -选择数据: -```sql title="run on the running node" -SELECT * -FROM db1.table1 -``` -```response -┌─id─┬─column1─┐ -│ 1 │ abc │ -└────┴─────────┘ -┌─id─┬─column1─┐ -│ 2 │ def │ -└────┴─────────┘ -┌─id─┬─column1─┐ -│ 3 │ ghi │ -└────┴─────────┘ -``` - -8. 重启已停止的节点并从那里选择数据 - -```sql title="run on the restarted node" -SELECT * -FROM db1.table1 -``` -```response -┌─id─┬─column1─┐ -│ 1 │ abc │ -└────┴─────────┘ -┌─id─┬─column1─┐ -│ 2 │ def │ -└────┴─────────┘ -┌─id─┬─column1─┐ -│ 3 │ ghi │ -└────┴─────────┘ -``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replicated.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replicated.md.hash deleted file mode 100644 index 6bc5667c5f9..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replicated.md.hash +++ /dev/null @@ -1 +0,0 @@ -9ff877351882fea7 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/01_1_shard_2_replicas.md b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/01_1_shard_2_replicas.md new file mode 100644 index 00000000000..0b6127fd5f1 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/01_1_shard_2_replicas.md @@ -0,0 +1,766 @@ +--- +'slug': '/architecture/replication' +'sidebar_label': 'Replication' +'sidebar_position': 10 +'title': '复制数据' +'description': '页面描述一个具有五台服务器配置的示例架构。其中两台用于托管数据副本,其余用于协调数据的复制' +'doc_type': 'guide' +--- + +import Image from '@theme/IdealImage'; +import ReplicationShardingTerminology from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_replication-sharding-terminology.md'; +import ReplicationArchitecture from '@site/static/images/deployment-guides/replication-sharding-examples/replication.png'; +import ConfigFileNote from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_config-files.md'; +import KeeperConfigFileNote from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_keeper-config-files.md'; +import ConfigExplanation from '@site/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_config_explanation.mdx'; +import ListenHost from '@site/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_listen_host.mdx'; +import ServerParameterTable from '@site/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_server_parameter_table.mdx'; +import KeeperConfig from '@site/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_keeper_config.mdx'; +import KeeperConfigExplanation from '@site/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_keeper_explanation.mdx'; +import VerifyKeeperStatus from '@site/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_verify_keeper_using_mntr.mdx'; +import DedicatedKeeperServers from '@site/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_dedicated_keeper_servers.mdx'; +import ExampleFiles from '@site/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_working_example.mdx'; +import CloudTip from '@site/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_cloud_tip.mdx'; + +> 在这个示例中,您将学习如何设置一个简单的 ClickHouse 集群来复制数据。这里配置了五台服务器,其中两台用于托管数据副本,而另外三台服务器用于协调数据的复制。 + +您将要设置的集群架构如下所示: + +Architecture diagram for 1 shard and 2 replicas with ReplicatedMergeTree + + + +## 前提条件 {#pre-requisites} + +- 您之前已经设置过一个 [本地 ClickHouse 服务器](/install) +- 您熟悉 ClickHouse 的基本配置概念,例如 [配置文件](/operations/configuration-files) +- 您的机器上已安装 Docker + + + +## 设置目录结构和测试环境 {#set-up} + + + +在本教程中,您将使用 [Docker compose](https://docs.docker.com/compose/) 来设置 ClickHouse 集群。此设置可以修改以适用于单独的本地机器、虚拟机或云实例。 + +运行以下命令以设置此示例的目录结构: + +```bash +mkdir cluster_1S_2R +cd cluster_1S_2R + + +# Create clickhouse-keeper directories +for i in {01..03}; do + mkdir -p fs/volumes/clickhouse-keeper-${i}/etc/clickhouse-keeper +done + + +# Create clickhouse-server directories +for i in {01..02}; do + mkdir -p fs/volumes/clickhouse-${i}/etc/clickhouse-server +done +``` + +将以下 `docker-compose.yml` 文件添加到 `cluster_1S_2R` 目录中: + +```yaml title="docker-compose.yml" +version: '3.8' +services: + clickhouse-01: + image: "clickhouse/clickhouse-server:latest" + user: "101:101" + container_name: clickhouse-01 + hostname: clickhouse-01 + volumes: + - ${PWD}/fs/volumes/clickhouse-01/etc/clickhouse-server/config.d/config.xml:/etc/clickhouse-server/config.d/config.xml + - ${PWD}/fs/volumes/clickhouse-01/etc/clickhouse-server/users.d/users.xml:/etc/clickhouse-server/users.d/users.xml + ports: + - "127.0.0.1:8123:8123" + - "127.0.0.1:9000:9000" + depends_on: + - clickhouse-keeper-01 + - clickhouse-keeper-02 + - clickhouse-keeper-03 + clickhouse-02: + image: "clickhouse/clickhouse-server:latest" + user: "101:101" + container_name: clickhouse-02 + hostname: clickhouse-02 + volumes: + - ${PWD}/fs/volumes/clickhouse-02/etc/clickhouse-server/config.d/config.xml:/etc/clickhouse-server/config.d/config.xml + - ${PWD}/fs/volumes/clickhouse-02/etc/clickhouse-server/users.d/users.xml:/etc/clickhouse-server/users.d/users.xml + ports: + - "127.0.0.1:8124:8123" + - "127.0.0.1:9001:9000" + depends_on: + - clickhouse-keeper-01 + - clickhouse-keeper-02 + - clickhouse-keeper-03 + clickhouse-keeper-01: + image: "clickhouse/clickhouse-keeper:latest-alpine" + user: "101:101" + container_name: clickhouse-keeper-01 + hostname: clickhouse-keeper-01 + volumes: + - ${PWD}/fs/volumes/clickhouse-keeper-01/etc/clickhouse-keeper/keeper_config.xml:/etc/clickhouse-keeper/keeper_config.xml + ports: + - "127.0.0.1:9181:9181" + clickhouse-keeper-02: + image: "clickhouse/clickhouse-keeper:latest-alpine" + user: "101:101" + container_name: clickhouse-keeper-02 + hostname: clickhouse-keeper-02 + volumes: + - ${PWD}/fs/volumes/clickhouse-keeper-02/etc/clickhouse-keeper/keeper_config.xml:/etc/clickhouse-keeper/keeper_config.xml + ports: + - "127.0.0.1:9182:9181" + clickhouse-keeper-03: + image: "clickhouse/clickhouse-keeper:latest-alpine" + user: "101:101" + container_name: clickhouse-keeper-03 + hostname: clickhouse-keeper-03 + volumes: + - ${PWD}/fs/volumes/clickhouse-keeper-03/etc/clickhouse-keeper/keeper_config.xml:/etc/clickhouse-keeper/keeper_config.xml + ports: + - "127.0.0.1:9183:9181" +``` + +创建以下子目录和文件: + +```bash +for i in {01..02}; do + mkdir -p fs/volumes/clickhouse-${i}/etc/clickhouse-server/config.d + mkdir -p fs/volumes/clickhouse-${i}/etc/clickhouse-server/users.d + touch fs/volumes/clickhouse-${i}/etc/clickhouse-server/config.d/config.xml + touch fs/volumes/clickhouse-${i}/etc/clickhouse-server/users.d/users.xml +done +``` + + + +## 配置 ClickHouse 节点 {#configure-clickhouse-servers} + +### 服务器设置 {#server-setup} + +现在修改每个空的配置文件 `config.xml`,这些文件位于 `fs/volumes/clickhouse-{}/etc/clickhouse-server/config.d`。下面突出显示的行需要根据每个节点进行更改: + +```xml + + + debug + /var/log/clickhouse-server/clickhouse-server.log + /var/log/clickhouse-server/clickhouse-server.err.log + 1000M + 3 + + + cluster_1S_2R node 1 + 0.0.0.0 + 8123 + 9000 + + + users.xml + + + /var/lib/clickhouse/access/ + + + + /clickhouse/task_queue/ddl + + + + + true + + clickhouse-01 + 9000 + + + clickhouse-02 + 9000 + + + + + + + clickhouse-keeper-01 + 9181 + + + clickhouse-keeper-02 + 9181 + + + clickhouse-keeper-03 + 9181 + + + + + 01 + 01 + cluster_1S_2R + + + +``` + +| 目录 | 文件 | +|----------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `fs/volumes/clickhouse-01/etc/clickhouse-server/config.d` | [`config.xml`](https://github.com/ClickHouse/examples/blob/main/docker-compose-recipes/recipes/cluster_1S_2R/fs/volumes/clickhouse-01/etc/clickhouse-server/config.d/config.xml) | +| `fs/volumes/clickhouse-02/etc/clickhouse-server/config.d` | [`config.xml`](https://github.com/ClickHouse/examples/blob/main/docker-compose-recipes/recipes/cluster_1S_2R/fs/volumes/clickhouse-02/etc/clickhouse-server/config.d/config.xml) | + +上述配置文件的每个部分将在下面更详细地解释。 + +#### 网络和日志记录 {#networking} + + + +日志记录在 `` 块中定义。此示例配置为您提供一个调试日志,日志会在 1000M 时轮换三次: + +```xml + + debug + /var/log/clickhouse-server/clickhouse-server.log + /var/log/clickhouse-server/clickhouse-server.err.log + 1000M + 3 + +``` + +有关日志配置的更多信息,请参见默认 ClickHouse [配置文件](https://github.com/ClickHouse/ClickHouse/blob/master/programs/server/config.xml) 中包含的注释。 + +#### 集群配置 {#cluster-configuration} + +集群的配置在 `` 块中设置。这里定义了集群名称 `cluster_1S_2R`。 + +`` 块定义了集群的布局,使用 `` 和 `` 设置,并作为分布式 DDL 查询的模板,这些查询使用 `ON CLUSTER` 子句在集群中执行。默认情况下,允许分布式 DDL 查询,但也可以通过设置 `allow_distributed_ddl_queries` 来关闭。 + +`internal_replication` 设置为 true,以便数据仅写入其中一个副本。 + +```xml + + + + + + + true + + clickhouse-01 + 9000 + + + clickhouse-02 + 9000 + + + + +``` + + + +#### Keeper 配置 {#keeper-config-explanation} + +`` 部分告诉 ClickHouse ClickHouse Keeper(或 ZooKeeper)在哪里运行。由于我们使用的是 ClickHouse Keeper 集群,因此需要为每个集群 `` 指定其主机名和端口号,使用 `` 和 `` 标签。 + +ClickHouse Keeper 的设置将在下一个步骤的教程中解释。 + +```xml + + + clickhouse-keeper-01 + 9181 + + + clickhouse-keeper-02 + 9181 + + + clickhouse-keeper-03 + 9181 + + +``` + +:::note +虽然可以在与 ClickHouse Server 相同的服务器上运行 ClickHouse Keeper,但在生产环境中我们强烈建议 ClickHouse Keeper 在专用主机上运行。 +::: + +#### 宏配置 {#macros-config-explanation} + +此外,`` 部分用于定义复制表的参数替换。这些替换在 `system.macros` 中列出,允许在查询中使用替换,例如 `{shard}` 和 `{replica}`。 + +```xml + + 01 + 01 + cluster_1S_2R + +``` + +:::note +这些将根据集群的布局分别定义。 +::: + +### 用户配置 {#user-config} + +现在修改每个空的配置文件 `users.xml`,位于 `fs/volumes/clickhouse-{}/etc/clickhouse-server/users.d`,内容如下: + +```xml title="/users.d/users.xml" + + + + + 10000000000 + 0 + in_order + 1 + + + + + 1 + default + + ::/0 + + default + 1 + 1 + 1 + 1 + + + + + + 3600 + 0 + 0 + 0 + 0 + 0 + + + + +``` + +| 目录 | 文件 | +|-----------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `fs/volumes/clickhouse-01/etc/clickhouse-server/users.d` | [`users.xml`](https://github.com/ClickHouse/examples/blob/main/docker-compose-recipes/recipes/cluster_1S_2R/fs/volumes/clickhouse-01/etc/clickhouse-server/users.d/users.xml) | +| `fs/volumes/clickhouse-02/etc/clickhouse-server/users.d` | [`users.xml`](https://github.com/ClickHouse/examples/blob/main/docker-compose-recipes/recipes/cluster_1S_2R/fs/volumes/clickhouse-02/etc/clickhouse-server/users.d/users.xml) | + +在本示例中,默认用户未设置密码以简化配置。在实际操作中,不建议这样做。 + +:::note +在本示例中,集群中所有节点的 `users.xml` 文件是相同的。 +::: + +## 配置 ClickHouse Keeper {#configure-clickhouse-keeper-nodes} + +### Keeper 设置 {#configuration-explanation} + + + +| 目录 | 文件 | +|------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `fs/volumes/clickhouse-keeper-01/etc/clickhouse-server/config.d` | [`keeper_config.xml`](https://github.com/ClickHouse/examples/blob/main/docker-compose-recipes/recipes/cluster_1S_2R/fs/volumes/clickhouse-keeper-01/etc/clickhouse-keeper/keeper_config.xml) | +| `fs/volumes/clickhouse-keeper-02/etc/clickhouse-server/config.d` | [`keeper_config.xml`](https://github.com/ClickHouse/examples/blob/main/docker-compose-recipes/recipes/cluster_1S_2R/fs/volumes/clickhouse-keeper-02/etc/clickhouse-keeper/keeper_config.xml) | +| `fs/volumes/clickhouse-keeper-03/etc/clickhouse-server/config.d` | [`keeper_config.xml`](https://github.com/ClickHouse/examples/blob/main/docker-compose-recipes/recipes/cluster_1S_2R/fs/volumes/clickhouse-keeper-03/etc/clickhouse-keeper/keeper_config.xml) | + + + + + +## 测试设置 {#test-the-setup} + +确保 Docker 在您的机器上运行。 +使用 `docker-compose up` 命令从 `cluster_1S_2R` 目录的根目录启动集群: + +```bash +docker-compose up -d +``` + +您应该看到 Docker 开始拉取 ClickHouse 和 Keeper 镜像,然后启动容器: + +```bash +[+] Running 6/6 + ✔ Network cluster_1s_2r_default Created + ✔ Container clickhouse-keeper-03 Started + ✔ Container clickhouse-keeper-02 Started + ✔ Container clickhouse-keeper-01 Started + ✔ Container clickhouse-01 Started + ✔ Container clickhouse-02 Started +``` + +要验证集群是否正在运行,请连接到 `clickhouse-01` 或 `clickhouse-02` 并运行以下查询。连接到第一个节点的命令如下所示: + +```bash + +# Connect to any node +docker exec -it clickhouse-01 clickhouse-client +``` + +如果成功,您将看到 ClickHouse 客户端提示: + +```response +cluster_1S_2R node 1 :) +``` + +运行以下查询以检查哪些主机定义了哪些集群拓扑: + +```sql title="Query" +SELECT + cluster, + shard_num, + replica_num, + host_name, + port +FROM system.clusters; +``` + +```response title="Response" + ┌─cluster───────┬─shard_num─┬─replica_num─┬─host_name─────┬─port─┐ +1. │ cluster_1S_2R │ 1 │ 1 │ clickhouse-01 │ 9000 │ +2. │ cluster_1S_2R │ 1 │ 2 │ clickhouse-02 │ 9000 │ +3. │ default │ 1 │ 1 │ localhost │ 9000 │ + └───────────────┴───────────┴─────────────┴───────────────┴──────┘ +``` + +运行以下查询以检查 ClickHouse Keeper 集群的状态: + +```sql title="Query" +SELECT * +FROM system.zookeeper +WHERE path IN ('/', '/clickhouse') +``` + +```response title="Response" + ┌─name───────┬─value─┬─path────────┐ +1. │ sessions │ │ /clickhouse │ +2. │ task_queue │ │ /clickhouse │ +3. │ keeper │ │ / │ +4. │ clickhouse │ │ / │ + └────────────┴───────┴─────────────┘ +``` + + + +这样,您已经成功设置了一个单分片和两个副本的 ClickHouse 集群。在下一步中,您将创建一个集群中的表。 + +## 创建数据库 {#creating-a-database} + +现在,您已经验证集群正确设置并正在运行,您将重新创建一个与 [UK property prices](/getting-started/example-datasets/uk-price-paid) 示例数据集教程中使用的表相同的表。它包含了自 1995 年以来在英格兰和威尔士房地产的支付价格约 3000 万行数据。 + +通过在不同的终端选项卡或窗口中运行以下每个命令,连接到每个主机的客户端: + +```bash +docker exec -it clickhouse-01 clickhouse-client +docker exec -it clickhouse-02 clickhouse-client +``` + +您可以从每个主机的 clickhouse-client 运行以下查询以确认除了默认数据库外尚未创建任何其他数据库: + +```sql title="Query" +SHOW DATABASES; +``` + +```response title="Response" + ┌─name───────────────┐ +1. │ INFORMATION_SCHEMA │ +2. │ default │ +3. │ information_schema │ +4. │ system │ + └────────────────────┘ +``` + +从 `clickhouse-01` 客户端运行以下 **分布式** DDL 查询,使用 `ON CLUSTER` 子句创建一个名为 `uk` 的新数据库: + +```sql +CREATE DATABASE IF NOT EXISTS uk +-- highlight-next-line +ON CLUSTER cluster_1S_2R; +``` + +您可以再次从每个主机的客户端运行相同的查询,以确认尽管只在 `clickhouse-01` 上运行查询,但数据库已在集群中创建: + +```sql +SHOW DATABASES; +``` + +```response + ┌─name───────────────┐ +1. │ INFORMATION_SCHEMA │ +2. │ default │ +3. │ information_schema │ +4. │ system │ +#highlight-next-line +5. │ uk │ + └────────────────────┘ +``` + +## 在集群上创建表 {#creating-a-table} + +现在数据库已经创建,请在集群上创建一个表。 +在任何主机客户端中运行以下查询: + +```sql +CREATE TABLE IF NOT EXISTS uk.uk_price_paid_local +--highlight-next-line +ON CLUSTER cluster_1S_2R +( + price UInt32, + date Date, + postcode1 LowCardinality(String), + postcode2 LowCardinality(String), + type Enum8('terraced' = 1, 'semi-detached' = 2, 'detached' = 3, 'flat' = 4, 'other' = 0), + is_new UInt8, + duration Enum8('freehold' = 1, 'leasehold' = 2, 'unknown' = 0), + addr1 String, + addr2 String, + street LowCardinality(String), + locality LowCardinality(String), + town LowCardinality(String), + district LowCardinality(String), + county LowCardinality(String) +) +--highlight-next-line +ENGINE = ReplicatedMergeTree +ORDER BY (postcode1, postcode2, addr1, addr2); +``` + +请注意,这与 [UK property prices](/getting-started/example-datasets/uk-price-paid) 示例数据集教程中的原始 `CREATE` 语句中使用的查询是相同的,只是添加了 `ON CLUSTER` 子句并使用了 `ReplicatedMergeTree` 引擎。 + +`ON CLUSTER` 子句旨在用于分布式执行 DDL(数据定义语言)查询,例如 `CREATE`、`DROP`、`ALTER` 和 `RENAME`,以确保这些模式更改在集群中的所有节点上应用。 + +[`ReplicatedMergeTree`](https://clickhouse.com/docs/engines/table-engines/mergetree-family/replication#converting-from-mergetree-to-replicatedmergetree) 引擎的工作方式与普通的 `MergeTree` 表引擎相同,但它还会复制数据。 + +您可以从 `clickhouse-01` 或 `clickhouse-02` 客户端运行以下查询,以确认该表已在集群中创建: + +```sql title="Query" +SHOW TABLES IN uk; +``` + +```response title="Response" + ┌─name────────────────┐ +1. │ uk_price_paid. │ + └─────────────────────┘ +``` + +## 插入数据 {#inserting-data} + +由于数据集很大,完全摄取数据需要几分钟,因此我们将只插入一小部分数据开始。 + +从 `clickhouse-01` 插入数据集中的一小部分数据,使用以下查询: + +```sql +INSERT INTO uk.uk_price_paid_local +SELECT + toUInt32(price_string) AS price, + parseDateTimeBestEffortUS(time) AS date, + splitByChar(' ', postcode)[1] AS postcode1, + splitByChar(' ', postcode)[2] AS postcode2, + transform(a, ['T', 'S', 'D', 'F', 'O'], ['terraced', 'semi-detached', 'detached', 'flat', 'other']) AS type, + b = 'Y' AS is_new, + transform(c, ['F', 'L', 'U'], ['freehold', 'leasehold', 'unknown']) AS duration, + addr1, + addr2, + street, + locality, + town, + district, + county +FROM url( + 'http://prod1.publicdata.landregistry.gov.uk.s3-website-eu-west-1.amazonaws.com/pp-complete.csv', + 'CSV', + 'uuid_string String, + price_string String, + time String, + postcode String, + a String, + b String, + c String, + addr1 String, + addr2 String, + street String, + locality String, + town String, + district String, + county String, + d String, + e String' +) LIMIT 10000 +SETTINGS max_http_get_redirects=10; +``` + +请注意,数据在每个主机上完全复制: + +```sql +-- clickhouse-01 +SELECT count(*) +FROM uk.uk_price_paid_local + +-- ┌─count()─┐ +-- 1.│ 10000 │ +-- └─────────┘ + +-- clickhouse-02 +SELECT count(*) +FROM uk.uk_price_paid_local + +-- ┌─count()─┐ +-- 1.│ 10000 │ +-- └─────────┘ +``` + +为了演示当某个主机失败时会发生什么,从任一主机创建一个简单的测试数据库和测试表: + +```sql +CREATE DATABASE IF NOT EXISTS test ON CLUSTER cluster_1S_2R; +CREATE TABLE test.test_table ON CLUSTER cluster_1S_2R +( + `id` UInt64, + `name` String +) +ENGINE = ReplicatedMergeTree +ORDER BY id; +``` + +与 `uk_price_paid` 表一样,我们可以从任一主机插入数据: + +```sql +INSERT INTO test.test_table (id, name) VALUES (1, 'Clicky McClickface'); +``` + +但是如果某个主机宕机,会发生什么呢?要模拟这一点,请运行以下命令停止 `clickhouse-01`: + +```bash +docker stop clickhouse-01 +``` + +通过运行以下命令检查主机是否宕机: + +```bash +docker-compose ps +``` + +```response title="Response" +NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS +clickhouse-02 clickhouse/clickhouse-server:latest "/entrypoint.sh" clickhouse-02 X minutes ago Up X minutes 127.0.0.1:8124->8123/tcp, 127.0.0.1:9001->9000/tcp +clickhouse-keeper-01 clickhouse/clickhouse-keeper:latest-alpine "/entrypoint.sh" clickhouse-keeper-01 X minutes ago Up X minutes 127.0.0.1:9181->9181/tcp +clickhouse-keeper-02 clickhouse/clickhouse-keeper:latest-alpine "/entrypoint.sh" clickhouse-keeper-02 X minutes ago Up X minutes 127.0.0.1:9182->9181/tcp +clickhouse-keeper-03 clickhouse/clickhouse-keeper:latest-alpine "/entrypoint.sh" clickhouse-keeper-03 X minutes ago Up X minutes 127.0.0.1:9183->9181/tcp +``` + +在 `clickhouse-01` 现在宕机的情况下,向测试表插入另一行数据并查询该表: + +```sql +INSERT INTO test.test_table (id, name) VALUES (2, 'Alexey Milovidov'); +SELECT * FROM test.test_table; +``` + +```response title="Response" + ┌─id─┬─name───────────────┐ +1. │ 1 │ Clicky McClickface │ +2. │ 2 │ Alexey Milovidov │ + └────┴────────────────────┘ +``` + +现在使用以下命令重启 `clickhouse-01` (您可以再次运行 `docker-compose ps` 以确认): + +```sql +docker start clickhouse-01 +``` + +在运行 `docker exec -it clickhouse-01 clickhouse-client` 后,从 `clickhouse-01` 查询测试表: + +```sql title="Query" +SELECT * FROM test.test_table +``` + +```response title="Response" + ┌─id─┬─name───────────────┐ +1. │ 1 │ Clicky McClickface │ +2. │ 2 │ Alexey Milovidov │ + └────┴────────────────────┘ +``` + +如果您希望摄取完整的 UK property price 数据集进行实验,您可以运行以下查询: + +```sql +TRUNCATE TABLE uk.uk_price_paid_local ON CLUSTER cluster_1S_2R; +INSERT INTO uk.uk_price_paid_local +SELECT + toUInt32(price_string) AS price, + parseDateTimeBestEffortUS(time) AS date, + splitByChar(' ', postcode)[1] AS postcode1, + splitByChar(' ', postcode)[2] AS postcode2, + transform(a, ['T', 'S', 'D', 'F', 'O'], ['terraced', 'semi-detached', 'detached', 'flat', 'other']) AS type, + b = 'Y' AS is_new, + transform(c, ['F', 'L', 'U'], ['freehold', 'leasehold', 'unknown']) AS duration, + addr1, + addr2, + street, + locality, + town, + district, + county +FROM url( + 'http://prod1.publicdata.landregistry.gov.uk.s3-website-eu-west-1.amazonaws.com/pp-complete.csv', + 'CSV', + 'uuid_string String, + price_string String, + time String, + postcode String, + a String, + b String, + c String, + addr1 String, + addr2 String, + street String, + locality String, + town String, + district String, + county String, + d String, + e String' + ) SETTINGS max_http_get_redirects=10; +``` + +从 `clickhouse-02` 或 `clickhouse-01` 查询该表: + +```sql title="Query" +SELECT count(*) FROM uk.uk_price_paid_local; +``` + +```response title="Response" + ┌──count()─┐ +1. │ 30212555 │ -- 30.21 million + └──────────┘ +``` + + + +## 结论 {#conclusion} + +这种集群拓扑的优势在于有两个副本时,您的数据存在于两个独立的主机上。如果一台主机发生故障,另一副本将继续提供数据而不会丢失。这消除了存储级别的单点故障。 + +当一台主机宕机时,剩下的副本仍然能够: +- 在没有中断的情况下处理读取查询 +- 接受新的写入(根据您的一致性设置) +- 为应用程序保持服务的可用性 + +当故障的主机重新上线时,它能够: +- 自动从健康副本同步缺少的数据 +- 无需人工干预恢复正常操作 +- 快速恢复完全冗余 + +在下一个示例中,我们将看看如何设置一个具有两个分片但只有一个副本的集群。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/01_1_shard_2_replicas.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/01_1_shard_2_replicas.md.hash new file mode 100644 index 00000000000..5762319a4b3 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/01_1_shard_2_replicas.md.hash @@ -0,0 +1 @@ +635d5a89559cabe3 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/02_2_shards_1_replica.md b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/02_2_shards_1_replica.md new file mode 100644 index 00000000000..7b2be29d6bf --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/02_2_shards_1_replica.md @@ -0,0 +1,773 @@ +--- +'slug': '/architecture/horizontal-scaling' +'sidebar_label': '扩展性' +'sidebar_position': 10 +'title': '扩展性' +'description': '页面描述一个旨在提供可扩展性的示例架构' +'doc_type': 'guide' +--- + +import Image from '@theme/IdealImage'; +import ReplicationShardingTerminology from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_replication-sharding-terminology.md'; +import ShardingArchitecture from '@site/static/images/deployment-guides/replication-sharding-examples/sharding.png'; +import ConfigFileNote from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_config-files.md'; +import KeeperConfigFileNote from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_keeper-config-files.md'; +import ConfigExplanation from '@site/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_config_explanation.mdx'; +import ListenHost from '@site/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_listen_host.mdx'; +import ServerParameterTable from '@site/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_server_parameter_table.mdx'; +import KeeperConfig from '@site/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_keeper_config.mdx'; +import KeeperConfigExplanation from '@site/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_keeper_explanation.mdx'; +import VerifyKeeperStatus from '@site/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_verify_keeper_using_mntr.mdx'; +import DedicatedKeeperServers from '@site/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_dedicated_keeper_servers.mdx'; +import ExampleFiles from '@site/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_working_example.mdx'; +import CloudTip from '@site/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_cloud_tip.mdx'; + +> 在这个示例中,您将学习如何设置一个简单的 ClickHouse 集群以进行扩展。配置了五台服务器。其中两台用于对数据进行分片,另外三台服务器用于协调。 + +您将要设置的集群的架构如下所示: + +2个分片和1个副本的架构图 + + + +## 前提条件 {#pre-requisites} + +- 您之前已经设置了一个 [本地 ClickHouse 服务器](/install) +- 您熟悉 ClickHouse 的基本配置概念,例如 [配置文件](/operations/configuration-files) +- 您的机器上已安装 docker + + + +## 设置目录结构和测试环境 {#set-up} + + + +在本教程中,您将使用 [Docker compose](https://docs.docker.com/compose/) 来设置 ClickHouse 集群。此设置也可以修改为适用于单独的本地机器、虚拟机或云实例。 + +运行以下命令以设置此示例的目录结构: + +```bash +mkdir cluster_2S_1R +cd cluster_2S_1R + + +# Create clickhouse-keeper directories +for i in {01..03}; do + mkdir -p fs/volumes/clickhouse-keeper-${i}/etc/clickhouse-keeper +done + + +# Create clickhouse-server directories +for i in {01..02}; do + mkdir -p fs/volumes/clickhouse-${i}/etc/clickhouse-server +done +``` + +将以下 `docker-compose.yml` 文件添加到 `clickhouse-cluster` 目录: + +```yaml title="docker-compose.yml" +version: '3.8' +services: + clickhouse-01: + image: "clickhouse/clickhouse-server:latest" + user: "101:101" + container_name: clickhouse-01 + hostname: clickhouse-01 + networks: + cluster_2S_1R: + ipv4_address: 192.168.7.1 + volumes: + - ${PWD}/fs/volumes/clickhouse-01/etc/clickhouse-server/config.d/config.xml:/etc/clickhouse-server/config.d/config.xml + - ${PWD}/fs/volumes/clickhouse-01/etc/clickhouse-server/users.d/users.xml:/etc/clickhouse-server/users.d/users.xml + ports: + - "127.0.0.1:8123:8123" + - "127.0.0.1:9000:9000" + depends_on: + - clickhouse-keeper-01 + - clickhouse-keeper-02 + - clickhouse-keeper-03 + clickhouse-02: + image: "clickhouse/clickhouse-server:latest" + user: "101:101" + container_name: clickhouse-02 + hostname: clickhouse-02 + networks: + cluster_2S_1R: + ipv4_address: 192.168.7.2 + volumes: + - ${PWD}/fs/volumes/clickhouse-02/etc/clickhouse-server/config.d/config.xml:/etc/clickhouse-server/config.d/config.xml + - ${PWD}/fs/volumes/clickhouse-02/etc/clickhouse-server/users.d/users.xml:/etc/clickhouse-server/users.d/users.xml + ports: + - "127.0.0.1:8124:8123" + - "127.0.0.1:9001:9000" + depends_on: + - clickhouse-keeper-01 + - clickhouse-keeper-02 + - clickhouse-keeper-03 + clickhouse-keeper-01: + image: "clickhouse/clickhouse-keeper:latest-alpine" + user: "101:101" + container_name: clickhouse-keeper-01 + hostname: clickhouse-keeper-01 + networks: + cluster_2S_1R: + ipv4_address: 192.168.7.5 + volumes: + - ${PWD}/fs/volumes/clickhouse-keeper-01/etc/clickhouse-keeper/keeper_config.xml:/etc/clickhouse-keeper/keeper_config.xml + ports: + - "127.0.0.1:9181:9181" + clickhouse-keeper-02: + image: "clickhouse/clickhouse-keeper:latest-alpine" + user: "101:101" + container_name: clickhouse-keeper-02 + hostname: clickhouse-keeper-02 + networks: + cluster_2S_1R: + ipv4_address: 192.168.7.6 + volumes: + - ${PWD}/fs/volumes/clickhouse-keeper-02/etc/clickhouse-keeper/keeper_config.xml:/etc/clickhouse-keeper/keeper_config.xml + ports: + - "127.0.0.1:9182:9181" + clickhouse-keeper-03: + image: "clickhouse/clickhouse-keeper:latest-alpine" + user: "101:101" + container_name: clickhouse-keeper-03 + hostname: clickhouse-keeper-03 + networks: + cluster_2S_1R: + ipv4_address: 192.168.7.7 + volumes: + - ${PWD}/fs/volumes/clickhouse-keeper-03/etc/clickhouse-keeper/keeper_config.xml:/etc/clickhouse-keeper/keeper_config.xml + ports: + - "127.0.0.1:9183:9181" +networks: + cluster_2S_1R: + driver: bridge + ipam: + config: + - subnet: 192.168.7.0/24 + gateway: 192.168.7.254 +``` + +创建以下子目录和文件: + +```bash +for i in {01..02}; do + mkdir -p fs/volumes/clickhouse-${i}/etc/clickhouse-server/config.d + mkdir -p fs/volumes/clickhouse-${i}/etc/clickhouse-server/users.d + touch fs/volumes/clickhouse-${i}/etc/clickhouse-server/config.d/config.xml + touch fs/volumes/clickhouse-${i}/etc/clickhouse-server/users.d/users.xml +done +``` + + + +## 配置 ClickHouse 节点 {#configure-clickhouse-servers} + +### 服务器设置 {#server-setup} + +现在修改位于 `fs/volumes/clickhouse-{}/etc/clickhouse-server/config.d` 的每个空配置文件 `config.xml`。下面突出显示的行需要更改为特定于每个节点的内容: + +```xml + + + debug + /var/log/clickhouse-server/clickhouse-server.log + /var/log/clickhouse-server/clickhouse-server.err.log + 1000M + 3 + + + cluster_2S_1R node 1 + 0.0.0.0 + 8123 + 9000 + + + users.xml + + + /var/lib/clickhouse/access/ + + + + /clickhouse/task_queue/ddl + + + + + + clickhouse-01 + 9000 + + + + + clickhouse-02 + 9000 + + + + + + + clickhouse-keeper-01 + 9181 + + + clickhouse-keeper-02 + 9181 + + + clickhouse-keeper-03 + 9181 + + + + + 01 + 01 + + + +``` + +| 目录 | 文件 | +|--------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `fs/volumes/clickhouse-01/etc/clickhouse-server/config.d` | [`config.xml`](https://github.com/ClickHouse/examples/blob/main/docker-compose-recipes/recipes/cluster_2S_1R/fs/volumes/clickhouse-01/etc/clickhouse-server/config.d/config.xml) | +| `fs/volumes/clickhouse-02/etc/clickhouse-server/config.d` | [`config.xml`](https://github.com/ClickHouse/examples/blob/main/docker-compose-recipes/recipes/cluster_2S_1R/fs/volumes/clickhouse-02/etc/clickhouse-server/config.d/config.xml) | + +上面配置文件的每个部分将在下面详细解释。 + +#### 网络和日志 {#networking} + + + +日志在 `` 块中定义。此示例配置为您提供一个调试日志,该日志将在 1000M 处翻转三次: + +```xml + + debug + /var/log/clickhouse-server/clickhouse-server.log + /var/log/clickhouse-server/clickhouse-server.err.log + 1000M + 3 + +``` + +有关日志配置的更多信息,请参阅默认 ClickHouse [配置文件](https://github.com/ClickHouse/ClickHouse/blob/master/programs/server/config.xml) 中包含的注释。 + +#### 集群配置 {#cluster-configuration} + +集群的配置在 `` 块中设置。这里定义了集群名称 `cluster_2S_1R`。 + +`` 块定义了集群的布局,使用 `` 和 `` 设置,并充当分布式 DDL 查询的模板,分布式 DDL 查询是指在集群中执行的查询,使用 `ON CLUSTER` 子句。默认情况下,允许分布式 DDL 查询,但可通过设置 `allow_distributed_ddl_queries` 关闭。 + +`internal_replication` 设置为 true,以便数据仅写入一个副本。 + +```xml + + + + + clickhouse-01 + 9000 + + + + + clickhouse-02 + 9000 + + + + +``` + + + +#### Keeper 配置 {#keeper-config-explanation} + +`` 部分告知 ClickHouse ClickHouse Keeper(或 ZooKeeper)在哪里运行。由于我们使用的是 ClickHouse Keeper 集群,因此每个集群的 `` 需要指定其主机名和端口号,使用 `` 和 `` 标签分别指定。 + +ClickHouse Keeper 的设置将在本教程的下一步中解释。 + +```xml + + + clickhouse-keeper-01 + 9181 + + + clickhouse-keeper-02 + 9181 + + + clickhouse-keeper-03 + 9181 + + +``` + +:::note +尽管可以在与 ClickHouse Server 相同的服务器上运行 ClickHouse Keeper,但在生产环境中,我们强烈建议将 ClickHouse Keeper 运行在专用主机上。 +::: + +#### 宏配置 {#macros-config-explanation} + +此外,`` 部分用于定义参数替换以用于复制表。这些列在 `system.macros` 中,并允许在查询中使用替换,如 `{shard}` 和 `{replica}`。 + +```xml + + 01 + 01 + +``` + +:::note +这些将在集群布局上唯一定义。 +::: + +### 用户配置 {#user-config} + +现在修改位于 `fs/volumes/clickhouse-{}/etc/clickhouse-server/users.d` 的每个空配置文件 `users.xml`,内容如下: + +```xml title="/users.d/users.xml" + + + + + 10000000000 + 0 + in_order + 1 + + + + + 1 + default + + ::/0 + + default + 1 + 1 + 1 + 1 + + + + + + 3600 + 0 + 0 + 0 + 0 + 0 + + + + +``` + +| 目录 | 文件 | +|-------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `fs/volumes/clickhouse-01/etc/clickhouse-server/users.d` | [`users.xml`](https://github.com/ClickHouse/examples/blob/main/docker-compose-recipes/recipes/cluster_2S_1R/fs/volumes/clickhouse-01/etc/clickhouse-server/users.d/users.xml) | +| `fs/volumes/clickhouse-02/etc/clickhouse-server/users.d` | [`users.xml`](https://github.com/ClickHouse/examples/blob/main/docker-compose-recipes/recipes/cluster_2S_1R/fs/volumes/clickhouse-02/etc/clickhouse-server/users.d/users.xml) | + +在这个示例中,出于简便考虑,默认用户未配置密码。实际上,这不建议。 + +:::note +在这个示例中,每个 `users.xml` 文件在集群的所有节点上都是相同的。 +::: + +## 配置 ClickHouse Keeper {#configure-clickhouse-keeper-nodes} + +### Keeper 设置 {#configuration-explanation} + + + +| 目录 | 文件 | +|--------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `fs/volumes/clickhouse-keeper-01/etc/clickhouse-server/config.d` | [`keeper_config.xml`](https://github.com/ClickHouse/examples/blob/main/docker-compose-recipes/recipes/cluster_2S_1R/fs/volumes/clickhouse-keeper-01/etc/clickhouse-keeper/keeper_config.xml) | +| `fs/volumes/clickhouse-keeper-02/etc/clickhouse-server/config.d` | [`keeper_config.xml`](https://github.com/ClickHouse/examples/blob/main/docker-compose-recipes/recipes/cluster_2S_1R/fs/volumes/clickhouse-keeper-02/etc/clickhouse-keeper/keeper_config.xml) | +| `fs/volumes/clickhouse-keeper-03/etc/clickhouse-server/config.d` | [`keeper_config.xml`](https://github.com/ClickHouse/examples/blob/main/docker-compose-recipes/recipes/cluster_2S_1R/fs/volumes/clickhouse-keeper-03/etc/clickhouse-keeper/keeper_config.xml) | + + + + + +## 测试设置 {#test-the-setup} + +确保您的机器上正在运行 docker。 +使用 `docker-compose up` 命令从 `cluster_2S_1R` 目录的根目录启动集群: + +```bash +docker-compose up -d +``` + +您应该会看到 docker 开始拉取 ClickHouse 和 Keeper 的镜像,然后启动容器: + +```bash +[+] Running 6/6 + ✔ Network cluster_2s_1r_default Created + ✔ Container clickhouse-keeper-03 Started + ✔ Container clickhouse-keeper-02 Started + ✔ Container clickhouse-keeper-01 Started + ✔ Container clickhouse-01 Started + ✔ Container clickhouse-02 Started +``` + +要验证集群是否正在运行,请连接到 `clickhouse-01` 或 `clickhouse-02`,并运行以下查询。连接到第一个节点的命令如下所示: + +```bash + +# Connect to any node +docker exec -it clickhouse-01 clickhouse-client +``` + +如果成功,您将看到 ClickHouse 客户端提示: + +```response +cluster_2S_1R node 1 :) +``` + +运行以下查询以检查为哪些主机定义的集群拓扑: + +```sql title="Query" +SELECT + cluster, + shard_num, + replica_num, + host_name, + port +FROM system.clusters; +``` + +```response title="Response" + ┌─cluster───────┬─shard_num─┬─replica_num─┬─host_name─────┬─port─┐ +1. │ cluster_2S_1R │ 1 │ 1 │ clickhouse-01 │ 9000 │ +2. │ cluster_2S_1R │ 2 │ 1 │ clickhouse-02 │ 9000 │ +3. │ default │ 1 │ 1 │ localhost │ 9000 │ + └───────────────┴───────────┴─────────────┴───────────────┴──────┘ +``` + +运行以下查询以检查 ClickHouse Keeper 集群的状态: + +```sql title="Query" +SELECT * +FROM system.zookeeper +WHERE path IN ('/', '/clickhouse') +``` + +```response title="Response" + ┌─name───────┬─value─┬─path────────┐ +1. │ task_queue │ │ /clickhouse │ +2. │ sessions │ │ /clickhouse │ +3. │ clickhouse │ │ / │ +4. │ keeper │ │ / │ + └────────────┴───────┴─────────────┘ +``` + + + +这样,您就成功设置了一个单分片和两个副本的 ClickHouse 集群。在下一步中,您将创建一个集群中的表。 + +## 创建数据库 {#creating-a-database} + +现在您已经验证了集群正确设置并正在运行,您将重新创建与 [英国房产价格](/getting-started/example-datasets/uk-price-paid) 示例数据集教程中使用的表相同的表。它包含自 1995 年以来在英格兰和威尔士支付的大约 3000 万行房地产价格数据。 + +通过在单独的终端选项卡或窗口中运行以下命令,连接到每个主机的客户端: + +```bash +docker exec -it clickhouse-01 clickhouse-client +docker exec -it clickhouse-02 clickhouse-client +``` + +您可以从每个主机的 clickhouse-client 运行以下查询,以确认除了默认数据库外,没有数据库被创建: + +```sql title="Query" +SHOW DATABASES; +``` + +```response title="Response" + ┌─name───────────────┐ +1. │ INFORMATION_SCHEMA │ +2. │ default │ +3. │ information_schema │ +4. │ system │ + └────────────────────┘ +``` + +从 `clickhouse-01` 客户端运行以下 **分布式** DDL 查询,以使用 `ON CLUSTER` 子句创建名为 `uk` 的新数据库: + +```sql +CREATE DATABASE IF NOT EXISTS uk +-- highlight-next-line +ON CLUSTER cluster_2S_1R; +``` + +您可以再次从每个主机的客户端运行与之前相同的查询,以确认尽管只在 `clickhouse-01` 上运行该查询,数据库仍然已跨集群创建: + +```sql +SHOW DATABASES; +``` + +```response + ┌─name───────────────┐ +1. │ INFORMATION_SCHEMA │ +2. │ default │ +3. │ information_schema │ +4. │ system │ +#highlight-next-line +5. │ uk │ + └────────────────────┘ +``` + +## 在集群上创建表 {#creating-a-table} + +现在已创建数据库,您将创建一个分布式表。分布式表是可以访问位于不同主机上的分片的表,使用 `Distributed` 表引擎定义。分布式表充当集群中所有分片的接口。 + +从任何主机客户端运行以下查询: + +```sql +CREATE TABLE IF NOT EXISTS uk.uk_price_paid_local +--highlight-next-line +ON CLUSTER cluster_2S_1R +( + price UInt32, + date Date, + postcode1 LowCardinality(String), + postcode2 LowCardinality(String), + type Enum8('terraced' = 1, 'semi-detached' = 2, 'detached' = 3, 'flat' = 4, 'other' = 0), + is_new UInt8, + duration Enum8('freehold' = 1, 'leasehold' = 2, 'unknown' = 0), + addr1 String, + addr2 String, + street LowCardinality(String), + locality LowCardinality(String), + town LowCardinality(String), + district LowCardinality(String), + county LowCardinality(String) +) +ENGINE = MergeTree +ORDER BY (postcode1, postcode2, addr1, addr2); +``` + +请注意,它与 [英国房产价格](/getting-started/example-datasets/uk-price-paid) 示例数据集教程中的原始 `CREATE` 语句中使用的查询相同,唯一不同的是 `ON CLUSTER` 子句。 + +`ON CLUSTER` 子句旨在用于 DDL(数据定义语言)查询的分布式执行,例如 `CREATE`、`DROP`、`ALTER` 和 `RENAME`,确保这些模式更改应用于集群中的所有节点。 + +您可以从每个主机的客户端运行以下查询,以确认表已跨集群创建: + +```sql title="Query" +SHOW TABLES IN uk; +``` + +```response title="Response" + ┌─name────────────────┐ +1. │ uk_price_paid_local │ + └─────────────────────┘ +``` + +## 向分布式表插入数据 {#inserting-data} + +在插入英国房价数据之前,让我们快速进行实验,看看从任何主机向普通表插入数据时会发生什么。 + +从任何主机运行以下查询创建测试数据库和表: + +```sql +CREATE DATABASE IF NOT EXISTS test ON CLUSTER cluster_2S_1R; +CREATE TABLE test.test_table ON CLUSTER cluster_2S_1R +( + `id` UInt64, + `name` String +) +ENGINE = ReplicatedMergeTree +ORDER BY id; +``` + +现在从 `clickhouse-01` 运行以下 `INSERT` 查询: + +```sql +INSERT INTO test.test_table (id, name) VALUES (1, 'Clicky McClickface'); +``` + +切换到 `clickhouse-02` 并运行以下 `INSERT` 查询: + +```sql title="Query" +INSERT INTO test.test_table (id, name) VALUES (1, 'Alexey Milovidov'); +``` + +现在从 `clickhouse-01` 或 `clickhouse-02` 运行以下查询: + +```sql +-- from clickhouse-01 +SELECT * FROM test.test_table; +-- ┌─id─┬─name───────────────┐ +-- 1.│ 1 │ Clicky McClickface │ +-- └────┴────────────────────┘ + +--from clickhouse-02 +SELECT * FROM test.test_table; +-- ┌─id─┬─name───────────────┐ +-- 1.│ 1 │ Alexey Milovidov │ +-- └────┴────────────────────┘ +``` + +您会注意到,仅返回插入到特定主机表中的行,而不是两个行。 + +要从两个分片读取数据,我们需要一个接口,该接口可以处理跨所有分片的查询,在我们对其运行选择查询时结合来自两个分片的数据,并在我们运行插入查询时处理向不同分片插入数据。 + +在 ClickHouse 中,该接口称为分布式表,我们使用 [`Distributed`](/engines/table-engines/special/distributed) 表引擎创建它。让我们看看它是如何工作的。 + +使用以下查询创建一个分布式表: + +```sql +CREATE TABLE test.test_table_dist ON CLUSTER cluster_2S_1R AS test.test_table +ENGINE = Distributed('cluster_2S_1R', 'test', 'test_table', rand()) +``` + +在这个示例中,选择 `rand()` 函数作为分片键,以便插入随机分布在各个分片上。 + +现在从任何主机查询分布式表,您将返回在两个主机上插入的两个行: + +```sql + ┌─id─┬─name───────────────┐ +1. │ 1 │ Alexey Milovidov │ +2. │ 1 │ Clicky McClickface │ + └────┴────────────────────┘ +``` + +让我们为我们的英国房产价格数据做同样的事情。从任意主机客户端运行以下查询,使用之前创建的现有表创建分布式表,使用 `ON CLUSTER`: + +```sql +CREATE TABLE IF NOT EXISTS uk.uk_price_paid_distributed +ON CLUSTER cluster_2S_1R +ENGINE = Distributed('cluster_2S_1R', 'uk', 'uk_price_paid_local', rand()); +``` + +现在连接到任一主机并插入数据: + +```sql +INSERT INTO uk.uk_price_paid_distributed +SELECT + toUInt32(price_string) AS price, + parseDateTimeBestEffortUS(time) AS date, + splitByChar(' ', postcode)[1] AS postcode1, + splitByChar(' ', postcode)[2] AS postcode2, + transform(a, ['T', 'S', 'D', 'F', 'O'], ['terraced', 'semi-detached', 'detached', 'flat', 'other']) AS type, + b = 'Y' AS is_new, + transform(c, ['F', 'L', 'U'], ['freehold', 'leasehold', 'unknown']) AS duration, + addr1, + addr2, + street, + locality, + town, + district, + county +FROM url( + 'http://prod1.publicdata.landregistry.gov.uk.s3-website-eu-west-1.amazonaws.com/pp-complete.csv', + 'CSV', + 'uuid_string String, + price_string String, + time String, + postcode String, + a String, + b String, + c String, + addr1 String, + addr2 String, + street String, + locality String, + town String, + district String, + county String, + d String, + e String' +) SETTINGS max_http_get_redirects=10; +``` + +数据插入后,您可以使用分布式表检查行数: + +```sql title="Query" +SELECT count(*) +FROM uk.uk_price_paid_distributed +``` + +```response title="Response" + ┌──count()─┐ +1. │ 30212555 │ -- 30.21 million + └──────────┘ +``` + +如果您在任一主机上运行以下查询,您将看到数据已在分片间大致均匀分配(请记住,插入的分片选择是通过 `rand()` 设置的,因此结果可能会有所不同): + +```sql +-- from clickhouse-01 +SELECT count(*) +FROM uk.uk_price_paid_local +-- ┌──count()─┐ +-- 1. │ 15107353 │ -- 15.11 million +-- └──────────┘ + +--from clickhouse-02 +SELECT count(*) +FROM uk.uk_price_paid_local +-- ┌──count()─┐ +-- 1. │ 15105202 │ -- 15.11 million +-- └──────────┘ +``` + +如果其中一台主机出现故障会发生什么?让我们通过关闭 `clickhouse-01` 来模拟这一点: + +```bash +docker stop clickhouse-01 +``` + +通过运行以下查询检查主机是否关闭: + +```bash +docker-compose ps +``` + +```response title="Response" +NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS +clickhouse-02 clickhouse/clickhouse-server:latest "/entrypoint.sh" clickhouse-02 X minutes ago Up X minutes 127.0.0.1:8124->8123/tcp, 127.0.0.1:9001->9000/tcp +clickhouse-keeper-01 clickhouse/clickhouse-keeper:latest-alpine "/entrypoint.sh" clickhouse-keeper-01 X minutes ago Up X minutes 127.0.0.1:9181->9181/tcp +clickhouse-keeper-02 clickhouse/clickhouse-keeper:latest-alpine "/entrypoint.sh" clickhouse-keeper-02 X minutes ago Up X minutes 127.0.0.1:9182->9181/tcp +clickhouse-keeper-03 clickhouse/clickhouse-keeper:latest-alpine "/entrypoint.sh" clickhouse-keeper-03 X minutes ago Up X minutes 127.0.0.1:9183->9181/tcp +``` + +现在从 `clickhouse-02` 运行我们之前在分布式表上运行的相同选择查询: + +```sql +SELECT count(*) +FROM uk.uk_price_paid_distributed +``` + +```response title="Response" +Received exception from server (version 25.5.2): +Code: 279. DB::Exception: Received from localhost:9000. DB::Exception: All connection tries failed. Log: + +Code: 32. DB::Exception: Attempt to read after eof. (ATTEMPT_TO_READ_AFTER_EOF) (version 25.5.2.47 (official build)) +Code: 209. DB::NetException: Timeout: connect timed out: 192.168.7.1:9000 (clickhouse-01:9000, 192.168.7.1, local address: 192.168.7.2:37484, connection timeout 1000 ms). (SOCKET_TIMEOUT) (version 25.5.2.47 (official build)) +#highlight-next-line +Code: 198. DB::NetException: Not found address of host: clickhouse-01: (clickhouse-01:9000, 192.168.7.1, local address: 192.168.7.2:37484). (DNS_ERROR) (version 25.5.2.47 (official build)) + +: While executing Remote. (ALL_CONNECTION_TRIES_FAILED) +``` + +不幸的是,我们的集群不具备容错能力。如果其中一台主机出现故障,集群将被视为不健康,并且查询失败,相比之下,我们在 [先前示例](/architecture/replication) 中看到的复制表,我们能够在其中一台主机出现故障时插入数据。 + + + +## 结论 {#conclusion} + +这种集群拓扑的优势在于数据分布在不同的主机上,并且每个节点消耗的存储量减半。更重要的是,查询跨两个分片处理,这在内存利用率方面更有效,并减少每个主机的 I/O。 + +这种集群拓扑的主要缺点是,当然,失去其中一台主机使我们无法提供查询服务。 + +在 [下一个示例](/architecture/cluster-deployment) 中,我们将看看如何设置一个具有两个分片和两个副本的集群,以提供可扩展性和故障容错能力。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/02_2_shards_1_replica.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/02_2_shards_1_replica.md.hash new file mode 100644 index 00000000000..213b733d70c --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/02_2_shards_1_replica.md.hash @@ -0,0 +1 @@ +9db5a69df7276295 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/03_2_shards_2_replicas.md b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/03_2_shards_2_replicas.md new file mode 100644 index 00000000000..ae651c6b883 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/03_2_shards_2_replicas.md @@ -0,0 +1,701 @@ +--- +'slug': '/architecture/cluster-deployment' +'sidebar_label': '复制 + 扩展' +'sidebar_position': 100 +'title': '复制 + 扩展' +'description': '通过这个教程,您将学习如何设置一个简单的 ClickHouse 集群。' +'doc_type': 'guide' +--- + +import Image from '@theme/IdealImage'; +import SharedReplicatedArchitecture from '@site/static/images/deployment-guides/replication-sharding-examples/both.png'; +import ConfigExplanation from '@site/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_config_explanation.mdx'; +import ListenHost from '@site/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_listen_host.mdx'; +import KeeperConfig from '@site/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_keeper_config.mdx'; +import KeeperConfigExplanation from '@site/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_keeper_explanation.mdx'; +import VerifyKeeperStatus from '@site/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_verify_keeper_using_mntr.mdx'; +import DedicatedKeeperServers from '@site/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_dedicated_keeper_servers.mdx'; +import ExampleFiles from '@site/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_working_example.mdx'; +import CloudTip from '@site/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_cloud_tip.mdx'; + +> 在这个例子中,您将学习如何设置一个简单的 ClickHouse 集群,该集群既具有复制功能又具备扩展性。它由两个分片和两个副本组成,并使用 3 节点的 ClickHouse Keeper 集群来管理协调及保持集群中的法定人数。 +> +> 您将要设置的集群架构如下所示: + +2分片和1副本的架构图 + + + +## 前提条件 {#prerequisites} + +- 您之前已设置过一个 [本地 ClickHouse 服务器](/install) +- 您熟悉 ClickHouse 的基本配置概念,例如 [配置文件](/operations/configuration-files) +- 您的机器上已安装 docker + + + +## 设置目录结构和测试环境 {#set-up} + + + +在本教程中,您将使用 [Docker compose](https://docs.docker.com/compose/) 来设置 ClickHouse 集群。该设置可以修改为适应独立的本地机器、虚拟机或云实例。 + +运行以下命令以设置本示例的目录结构: + +```bash +mkdir cluster_2S_2R +cd cluster_2S_2R + + +# Create clickhouse-keeper directories +for i in {01..03}; do + mkdir -p fs/volumes/clickhouse-keeper-${i}/etc/clickhouse-keeper +done + + +# Create clickhouse-server directories +for i in {01..04}; do + mkdir -p fs/volumes/clickhouse-${i}/etc/clickhouse-server +done +``` + +将以下 `docker-compose.yml` 文件添加到 `clickhouse-cluster` 目录中: + +```yaml title="docker-compose.yml" +version: '3.8' +services: + clickhouse-01: + image: "clickhouse/clickhouse-server:latest" + user: "101:101" + container_name: clickhouse-01 + hostname: clickhouse-01 + volumes: + - ${PWD}/fs/volumes/clickhouse-01/etc/clickhouse-server/config.d/config.xml:/etc/clickhouse-server/config.d/config.xml + - ${PWD}/fs/volumes/clickhouse-01/etc/clickhouse-server/users.d/users.xml:/etc/clickhouse-server/users.d/users.xml + ports: + - "127.0.0.1:8123:8123" + - "127.0.0.1:9000:9000" + depends_on: + - clickhouse-keeper-01 + - clickhouse-keeper-02 + - clickhouse-keeper-03 + clickhouse-02: + image: "clickhouse/clickhouse-server:latest" + user: "101:101" + container_name: clickhouse-02 + hostname: clickhouse-02 + volumes: + - ${PWD}/fs/volumes/clickhouse-02/etc/clickhouse-server/config.d/config.xml:/etc/clickhouse-server/config.d/config.xml + - ${PWD}/fs/volumes/clickhouse-02/etc/clickhouse-server/users.d/users.xml:/etc/clickhouse-server/users.d/users.xml + ports: + - "127.0.0.1:8124:8123" + - "127.0.0.1:9001:9000" + depends_on: + - clickhouse-keeper-01 + - clickhouse-keeper-02 + - clickhouse-keeper-03 + clickhouse-03: + image: "clickhouse/clickhouse-server:latest" + user: "101:101" + container_name: clickhouse-03 + hostname: clickhouse-03 + volumes: + - ${PWD}/fs/volumes/clickhouse-03/etc/clickhouse-server/config.d/config.xml:/etc/clickhouse-server/config.d/config.xml + - ${PWD}/fs/volumes/clickhouse-03/etc/clickhouse-server/users.d/users.xml:/etc/clickhouse-server/users.d/users.xml + ports: + - "127.0.0.1:8125:8123" + - "127.0.0.1:9002:9000" + depends_on: + - clickhouse-keeper-01 + - clickhouse-keeper-02 + - clickhouse-keeper-03 + clickhouse-04: + image: "clickhouse/clickhouse-server:latest" + user: "101:101" + container_name: clickhouse-04 + hostname: clickhouse-04 + volumes: + - ${PWD}/fs/volumes/clickhouse-04/etc/clickhouse-server/config.d/config.xml:/etc/clickhouse-server/config.d/config.xml + - ${PWD}/fs/volumes/clickhouse-04/etc/clickhouse-server/users.d/users.xml:/etc/clickhouse-server/users.d/users.xml + ports: + - "127.0.0.1:8126:8123" + - "127.0.0.1:9003:9000" + depends_on: + - clickhouse-keeper-01 + - clickhouse-keeper-02 + - clickhouse-keeper-03 + clickhouse-keeper-01: + image: "clickhouse/clickhouse-keeper:latest-alpine" + user: "101:101" + container_name: clickhouse-keeper-01 + hostname: clickhouse-keeper-01 + volumes: + - ${PWD}/fs/volumes/clickhouse-keeper-01/etc/clickhouse-keeper/keeper_config.xml:/etc/clickhouse-keeper/keeper_config.xml + ports: + - "127.0.0.1:9181:9181" + clickhouse-keeper-02: + image: "clickhouse/clickhouse-keeper:latest-alpine" + user: "101:101" + container_name: clickhouse-keeper-02 + hostname: clickhouse-keeper-02 + volumes: + - ${PWD}/fs/volumes/clickhouse-keeper-02/etc/clickhouse-keeper/keeper_config.xml:/etc/clickhouse-keeper/keeper_config.xml + ports: + - "127.0.0.1:9182:9181" + clickhouse-keeper-03: + image: "clickhouse/clickhouse-keeper:latest-alpine" + user: "101:101" + container_name: clickhouse-keeper-03 + hostname: clickhouse-keeper-03 + volumes: + - ${PWD}/fs/volumes/clickhouse-keeper-03/etc/clickhouse-keeper/keeper_config.xml:/etc/clickhouse-keeper/keeper_config.xml + ports: + - "127.0.0.1:9183:9181" +``` + +创建以下子目录和文件: + +```bash +for i in {01..04}; do + mkdir -p fs/volumes/clickhouse-${i}/etc/clickhouse-server/config.d + mkdir -p fs/volumes/clickhouse-${i}/etc/clickhouse-server/users.d + touch fs/volumes/clickhouse-${i}/etc/clickhouse-server/config.d/config.xml + touch fs/volumes/clickhouse-${i}/etc/clickhouse-server/users.d/users.xml +done +``` + + + +## 配置 ClickHouse 节点 {#configure-clickhouse-servers} + +### 服务器设置 {#server-setup} + +现在修改位于 `fs/volumes/clickhouse-{}/etc/clickhouse-server/config.d` 的每个空配置文件 `config.xml`。下面突出显示的行需要根据每个节点进行更改: + +```xml + + + debug + /var/log/clickhouse-server/clickhouse-server.log + /var/log/clickhouse-server/clickhouse-server.err.log + 1000M + 3 + + + cluster_2S_2R node 1 + 0.0.0.0 + 8123 + 9000 + + + users.xml + + + /var/lib/clickhouse/access/ + + + + /clickhouse/task_queue/ddl + + + + + true + + clickhouse-01 + 9000 + + + clickhouse-03 + 9000 + + + + true + + clickhouse-02 + 9000 + + + clickhouse-04 + 9000 + + + + + + + clickhouse-keeper-01 + 9181 + + + clickhouse-keeper-02 + 9181 + + + clickhouse-keeper-03 + 9181 + + + + + 01 + 01 + + + +``` + +| 目录 | 文件 | +|------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `fs/volumes/clickhouse-01/etc/clickhouse-server/config.d` | [`config.xml`](https://github.com/ClickHouse/examples/blob/main/docker-compose-recipes/recipes/cluster_2S_2R/fs/volumes/clickhouse-01/etc/clickhouse-server/config.d/config.xml) | +| `fs/volumes/clickhouse-02/etc/clickhouse-server/config.d` | [`config.xml`](https://github.com/ClickHouse/examples/blob/main/docker-compose-recipes/recipes/cluster_2S_2R/fs/volumes/clickhouse-02/etc/clickhouse-server/config.d/config.xml) | +| `fs/volumes/clickhouse-03/etc/clickhouse-server/config.d` | [`config.xml`](https://github.com/ClickHouse/examples/blob/main/docker-compose-recipes/recipes/cluster_2S_2R/fs/volumes/clickhouse-03/etc/clickhouse-server/config.d/config.xml) | +| `fs/volumes/clickhouse-04/etc/clickhouse-server/config.d` | [`config.xml`](https://github.com/ClickHouse/examples/blob/main/docker-compose-recipes/recipes/cluster_2S_2R/fs/volumes/clickhouse-04/etc/clickhouse-server/config.d/config.xml) | + +上述配置文件的每个部分将在下面详细解释。 + +#### 网络与日志记录 {#networking} + + + +日志配置在 `` 块中定义。此示例配置提供了一个调试日志,日志将在 1000M 时滚动三次: + +```xml + + debug + /var/log/clickhouse-server/clickhouse-server.log + /var/log/clickhouse-server/clickhouse-server.err.log + 1000M + 3 + +``` + +有关日志配置的更多信息,参见默认 ClickHouse [配置文件](https://github.com/ClickHouse/ClickHouse/blob/master/programs/server/config.xml) 中包含的注释。 + +#### 集群配置 {#cluster-config} + +集群的配置在 `` 块中设置。在这里,集群名称 `cluster_2S_2R` 被定义。 + +`` 块定义了集群的布局,使用 `` 和 `` 设置,并作为分布式 DDL 查询的模板,这些查询在集群内使用 `ON CLUSTER` 子句执行。默认情况下,允许分布式 DDL 查询,但也可以通过设置 `allow_distributed_ddl_queries` 关闭。 + +`internal_replication` 设置为 true,以便数据仅写入一个副本。 + +```xml + + + + + + + true + + clickhouse-01 + 9000 + + + clickhouse-03 + 9000 + + + + true + + clickhouse-02 + 9000 + + + clickhouse-04 + 9000 + + + + +``` + +`` 部分定义了集群的布局,并充当分布式 DDL 查询的模板,这些查询在集群内使用 `ON CLUSTER` 子句执行。 + +#### Keeper 配置 {#keeper-config-explanation} + +`` 部分告知 ClickHouse 点击 House Keeper(或 ZooKeeper)在哪里运行。由于我们使用的是 ClickHouse Keeper 集群,因此集群的每个 `` 都需要指定其主机名和端口号,分别使用 `` 和 `` 标签。 + +ClickHouse Keeper 的设置将在本教程的下一步中进行解释。 + +```xml + + + clickhouse-keeper-01 + 9181 + + + clickhouse-keeper-02 + 9181 + + + clickhouse-keeper-03 + 9181 + + +``` + +:::note +尽管可以在同一服务器上运行 ClickHouse Keeper 和 ClickHouse Server,但在生产环境中,我们强烈建议 ClickHouse Keeper 运行在专用主机上。 +::: + +#### 宏配置 {#macros-config-explanation} + +此外,`` 部分用于定义复制表的参数替代。这些在 `system.macros` 中列出,并允许在查询中使用诸如 `{shard}` 和 `{replica}` 的替代。 + +```xml + + 01 + 01 + +``` + +### 用户配置 {#cluster-configuration} + +现在修改位于 `fs/volumes/clickhouse-{}/etc/clickhouse-server/users.d` 的每个空配置文件 `users.xml`,内容如下: + +```xml title="/users.d/users.xml" + + + + + 10000000000 + 0 + in_order + 1 + + + + + 1 + default + + ::/0 + + default + 1 + 1 + 1 + 1 + + + + + + 3600 + 0 + 0 + 0 + 0 + 0 + + + + +``` + +在本示例中,默认用户配置为无密码以简化操作。在实际应用中,这种做法是不被推荐的。 + +:::note +在此示例中,每个 `users.xml` 文件在集群中的所有节点上都是相同的。 +::: + +## 配置 ClickHouse Keeper {#configure-clickhouse-keeper-nodes} + +接下来,您将配置 ClickHouse Keeper,用于协调。 + +### Keeper 设置 {#configuration-explanation} + + + +| 目录 | 文件 | +|---------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `fs/volumes/clickhouse-keeper-01/etc/clickhouse-server/config.d` | [`keeper_config.xml`](https://github.com/ClickHouse/examples/blob/main/docker-compose-recipes/recipes/cluster_2S_2R/fs/volumes/clickhouse-keeper-01/etc/clickhouse-keeper/keeper_config.xml) | +| `fs/volumes/clickhouse-keeper-02/etc/clickhouse-server/config.d` | [`keeper_config.xml`](https://github.com/ClickHouse/examples/blob/main/docker-compose-recipes/recipes/cluster_2S_2R/fs/volumes/clickhouse-keeper-02/etc/clickhouse-keeper/keeper_config.xml) | +| `fs/volumes/clickhouse-keeper-03/etc/clickhouse-server/config.d` | [`keeper_config.xml`](https://github.com/ClickHouse/examples/blob/main/docker-compose-recipes/recipes/cluster_2S_2R/fs/volumes/clickhouse-keeper-03/etc/clickhouse-keeper/keeper_config.xml) | + + + + + +## 测试设置 {#test-the-setup} + +确保您的机器上正在运行 docker。使用 `docker-compose up` 命令从 `cluster_2S_2R` 目录的根目录启动集群: + +```bash +docker-compose up -d +``` + +您应该会看到 docker 开始拉取 ClickHouse 和 Keeper 镜像,并随后启动容器: + +```bash +[+] Running 8/8 + ✔ Network cluster_2s_2r_default Created + ✔ Container clickhouse-keeper-03 Started + ✔ Container clickhouse-keeper-02 Started + ✔ Container clickhouse-keeper-01 Started + ✔ Container clickhouse-01 Started + ✔ Container clickhouse-02 Started + ✔ Container clickhouse-04 Started + ✔ Container clickhouse-03 Started +``` + +要验证集群是否正在运行,请连接到任意一个节点并运行以下查询。连接到第一个节点的命令如下所示: + +```bash + +# Connect to any node +docker exec -it clickhouse-01 clickhouse-client +``` + +如果成功,您将看到 ClickHouse 客户端提示: + +```response +cluster_2S_2R node 1 :) +``` + +运行以下查询以检查定义了哪些集群拓扑以及对应的主机: + +```sql title="Query" +SELECT + cluster, + shard_num, + replica_num, + host_name, + port +FROM system.clusters; +``` + +```response title="Response" + ┌─cluster───────┬─shard_num─┬─replica_num─┬─host_name─────┬─port─┐ +1. │ cluster_2S_2R │ 1 │ 1 │ clickhouse-01 │ 9000 │ +2. │ cluster_2S_2R │ 1 │ 2 │ clickhouse-03 │ 9000 │ +3. │ cluster_2S_2R │ 2 │ 1 │ clickhouse-02 │ 9000 │ +4. │ cluster_2S_2R │ 2 │ 2 │ clickhouse-04 │ 9000 │ +5. │ default │ 1 │ 1 │ localhost │ 9000 │ + └───────────────┴───────────┴─────────────┴───────────────┴──────┘ +``` + +运行以下查询以检查 ClickHouse Keeper 集群的状态: + +```sql title="Query" +SELECT * +FROM system.zookeeper +WHERE path IN ('/', '/clickhouse') +``` + +```response title="Response" + ┌─name───────┬─value─┬─path────────┐ +1. │ task_queue │ │ /clickhouse │ +2. │ sessions │ │ /clickhouse │ +3. │ keeper │ │ / │ +4. │ clickhouse │ │ / │ + └────────────┴───────┴─────────────┘ +``` + + + +通过这些步骤,您成功设置了一个具有两个分片和两个副本的 ClickHouse 集群。在下一步中,您将创建一个集群中的表。 + +## 创建数据库 {#creating-a-database} + +现在您已经验证集群正确设置并正在运行,您将重新创建与 [英国房地产价格](/getting-started/example-datasets/uk-price-paid) 示例数据集教程中使用的表相同的表。它由大约 3000 万行自 1995 年以来在英格兰和威尔士支付的房地产价格组成。 + +通过分别在不同的终端标签或窗口中运行以下每个命令,连接到每个主机的客户端: + +```bash +docker exec -it clickhouse-01 clickhouse-client +docker exec -it clickhouse-02 clickhouse-client +docker exec -it clickhouse-03 clickhouse-client +docker exec -it clickhouse-04 clickhouse-client +``` + +您可以从每个主机的 clickhouse-client 运行如下查询,以确认除了默认的数据库外,尚未创建任何数据库: + +```sql title="Query" +SHOW DATABASES; +``` + +```response title="Response" + ┌─name───────────────┐ +1. │ INFORMATION_SCHEMA │ +2. │ default │ +3. │ information_schema │ +4. │ system │ + └────────────────────┘ +``` + +从 `clickhouse-01` 客户端运行以下 **分布式** DDL 查询,使用 `ON CLUSTER` 子句创建一个名为 `uk` 的新数据库: + +```sql +CREATE DATABASE IF NOT EXISTS uk +-- highlight-next-line +ON CLUSTER cluster_2S_2R; +``` + +您可以再次从每个主机的客户端运行相同的查询,以确认尽管只从 `clickhouse-01` 运行查询,但数据库已经跨集群创建: + +```sql +SHOW DATABASES; +``` + +```response + ┌─name───────────────┐ +1. │ INFORMATION_SCHEMA │ +2. │ default │ +3. │ information_schema │ +4. │ system │ +#highlight-next-line +5. │ uk │ + └────────────────────┘ +``` + +## 在集群上创建分布式表 {#creating-a-table} + +数据库创建完成后,接下来您将创建一个分布式表。分布式表是可以访问位于不同主机的分片的表,使用 `Distributed` 表引擎进行定义。分布式表充当集群中所有分片的接口。 + +从任一主机客户端运行以下查询: + +```sql +CREATE TABLE IF NOT EXISTS uk.uk_price_paid_local +--highlight-next-line +ON CLUSTER cluster_2S_2R +( + price UInt32, + date Date, + postcode1 LowCardinality(String), + postcode2 LowCardinality(String), + type Enum8('terraced' = 1, 'semi-detached' = 2, 'detached' = 3, 'flat' = 4, 'other' = 0), + is_new UInt8, + duration Enum8('freehold' = 1, 'leasehold' = 2, 'unknown' = 0), + addr1 String, + addr2 String, + street LowCardinality(String), + locality LowCardinality(String), + town LowCardinality(String), + district LowCardinality(String), + county LowCardinality(String) +) +--highlight-next-line +ENGINE = ReplicatedMergeTree('/clickhouse/tables/{database}/{table}/{shard}', '{replica}') +ORDER BY (postcode1, postcode2, addr1, addr2); +``` + +请注意,它与原始 `CREATE` 语句中使用的查询完全相同,正如 [英国房地产价格](/getting-started/example-datasets/uk-price-paid) 示例数据集教程中所示,只是增加了 `ON CLUSTER` 子句和使用了 `ReplicatedMergeTree` 引擎。 + +`ON CLUSTER` 子句旨在用于分布式执行 DDL(数据定义语言)查询,例如 `CREATE`、`DROP`、`ALTER` 和 `RENAME`,确保这些模式更改会在集群中的所有节点上应用。 + +[`ReplicatedMergeTree`](https://clickhouse.com/docs/engines/table-engines/mergetree-family/replication#converting-from-mergetree-to-replicatedmergetree) 引擎的工作方式与普通的 `MergeTree` 表引擎相同,但它还会复制数据。它需要指定两个参数: + +- `zoo_path`:表的元数据在 Keeper/ZooKeeper 中的路径。 +- `replica_name`:表的副本名称。 + +
+ +`zoo_path` 参数可以设置为您选择的任何内容,尽管建议按照以下约定使用前缀 + +```text +/clickhouse/tables/{shard}/{database}/{table} +``` + +其中: +- `{database}` 和 `{table}` 将被自动替换。 +- `{shard}` 和 `{replica}` 是在之前的 `config.xml` 文件中定义的宏 [定义](#macros-config-explanation)。 + +您可以从每个主机客户端运行下面的查询,以确认表已在集群中创建: + +```sql title="Query" +SHOW TABLES IN uk; +``` + +```response title="Response" + ┌─name────────────────┐ +1. │ uk_price_paid_local │ + └─────────────────────┘ +``` + +## 向分布式表插入数据 {#inserting-data-using-distributed} + +要向分布式表插入数据,不能使用 `ON CLUSTER`,因为它不适用于 DML(数据操作语言)查询,例如 `INSERT`、`UPDATE` 和 `DELETE`。要插入数据,必须使用 [`Distributed`](/engines/table-engines/special/distributed) 表引擎。 + +从任何主机客户端运行以下查询,以使用之前创建的表创建分布式表,且使用 `ON CLUSTER` 和 `ReplicatedMergeTree` 的方式: + +```sql +CREATE TABLE IF NOT EXISTS uk.uk_price_paid_distributed +ON CLUSTER cluster_2S_2R +ENGINE = Distributed('cluster_2S_2R', 'uk', 'uk_price_paid_local', rand()); +``` + +在每个主机上,您现在将看到 `uk` 数据库中的以下表: + +```sql + ┌─name──────────────────────┐ +1. │ uk_price_paid_distributed │ +2. │ uk_price_paid_local │ + └───────────────────────────┘ +``` + +数据可以使用以下查询从任何主机客户端插入到 `uk_price_paid_distributed` 表中: + +```sql +INSERT INTO uk.uk_price_paid_distributed +SELECT + toUInt32(price_string) AS price, + parseDateTimeBestEffortUS(time) AS date, + splitByChar(' ', postcode)[1] AS postcode1, + splitByChar(' ', postcode)[2] AS postcode2, + transform(a, ['T', 'S', 'D', 'F', 'O'], ['terraced', 'semi-detached', 'detached', 'flat', 'other']) AS type, + b = 'Y' AS is_new, + transform(c, ['F', 'L', 'U'], ['freehold', 'leasehold', 'unknown']) AS duration, + addr1, + addr2, + street, + locality, + town, + district, + county +FROM url( + 'http://prod1.publicdata.landregistry.gov.uk.s3-website-eu-west-1.amazonaws.com/pp-complete.csv', + 'CSV', + 'uuid_string String, + price_string String, + time String, + postcode String, + a String, + b String, + c String, + addr1 String, + addr2 String, + street String, + locality String, + town String, + district String, + county String, + d String, + e String' +) SETTINGS max_http_get_redirects=10; +``` + +运行以下查询以确认插入的数据已均匀分布在我们集群的节点之间: + +```sql +SELECT count(*) +FROM uk.uk_price_paid_distributed; + +SELECT count(*) FROM uk.uk_price_paid_local; +``` + +```response + ┌──count()─┐ +1. │ 30212555 │ -- 30.21 million + └──────────┘ + + ┌──count()─┐ +1. │ 15105983 │ -- 15.11 million + └──────────┘ +``` + +
diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/03_2_shards_2_replicas.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/03_2_shards_2_replicas.md.hash new file mode 100644 index 00000000000..2bbe3b7a1ca --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/03_2_shards_2_replicas.md.hash @@ -0,0 +1 @@ +ed81937bf3db82d8 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_cloud_tip.mdx b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_cloud_tip.mdx new file mode 100644 index 00000000000..35459f34425 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_cloud_tip.mdx @@ -0,0 +1,7 @@ +:::tip ClickHouse Cloud 简化管理 +[ClickHouse Cloud](/cloud/overview) +消除了与管理分片和副本相关的操作负担。该平台自动处理高可用性、复制和扩展决策。 +计算和存储是独立的,并根据需求进行扩展,无需手动配置或持续维护。 + +[了解更多](/manage/scaling) +::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_cloud_tip.mdx.hash b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_cloud_tip.mdx.hash new file mode 100644 index 00000000000..1232e360c99 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_cloud_tip.mdx.hash @@ -0,0 +1 @@ +cdc766401c597c75 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_config_explanation.mdx b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_config_explanation.mdx new file mode 100644 index 00000000000..90cf2b08c95 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_config_explanation.mdx @@ -0,0 +1,14 @@ +- `config.d` 目录包含 ClickHouse 服务器配置文件 `config.xml`,在其中定义了每个 ClickHouse 节点的自定义配置。该配置与每个 ClickHouse 安装中自带的默认 `config.xml` ClickHouse 配置文件相结合。 +- `users.d` 目录包含用户配置文件 `users.xml`,在其中定义了用户的自定义配置。该配置与每个 ClickHouse 安装中自带的默认 ClickHouse `users.xml` 配置文件相结合。 + +:::tip 自定义配置目录 +在编写自己的配置时,最好使用 `config.d` 和 `users.d` 目录,而不是直接修改 `/etc/clickhouse-server/config.xml` 和 `etc/clickhouse-server/users.xml` 中的默认配置。 + +这一行 + +```xml + +``` + +确保了在 `config.d` 和 `users.d` 目录中定义的配置部分覆盖默认 `config.xml` 和 `users.xml` 文件中定义的默认配置部分。 +::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_config_explanation.mdx.hash b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_config_explanation.mdx.hash new file mode 100644 index 00000000000..77c0cf9a957 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_config_explanation.mdx.hash @@ -0,0 +1 @@ +2fd7898ae64e38f4 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_dedicated_keeper_servers.mdx b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_dedicated_keeper_servers.mdx new file mode 100644 index 00000000000..51fdb3193cf --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_dedicated_keeper_servers.mdx @@ -0,0 +1,5 @@ +:::note +尽管可以在同一服务器上运行 ClickHouse Server 和 ClickHouse Keeper 的组合,但我们强烈建议在生产环境中为 ClickHouse Keeper 使用 *专用* 主机,这也是我们将在本示例中演示的方法。 + +Keeper 服务器可以更小,每个 Keeper 服务器一般需要 4GB 内存,直到您的 ClickHouse 服务器变得庞大。 +::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_dedicated_keeper_servers.mdx.hash b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_dedicated_keeper_servers.mdx.hash new file mode 100644 index 00000000000..c47b8aedbf2 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_dedicated_keeper_servers.mdx.hash @@ -0,0 +1 @@ +9be182b2037abc8c diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_keeper_config.mdx b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_keeper_config.mdx new file mode 100644 index 00000000000..99037e669d9 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_keeper_config.mdx @@ -0,0 +1,57 @@ +为了使复制工作,必须设置和配置 ClickHouse Keeper 集群。 ClickHouse Keeper 提供数据复制的协调系统,作为 Zookeeper 的替代方案,Zookeeper 也可以使用。然而,推荐使用 ClickHouse Keeper,因为它提供更好的保障和可靠性,并且比 ZooKeeper 使用更少的资源。为了高可用性并保持法定人数,建议运行至少三个 ClickHouse Keeper 节点。 + +:::note +ClickHouse Keeper 可以与 ClickHouse 在集群的任何节点上运行,尽管建议在专用节点上运行,这样可以独立于数据库集群扩展和管理 ClickHouse Keeper 集群。 +::: + +使用以下命令从示例文件夹的根目录为每个 ClickHouse Keeper 节点创建 `keeper_config.xml` 文件: + +```bash +for i in {01..03}; do + touch fs/volumes/clickhouse-keeper-${i}/etc/clickhouse-keeper/keeper_config.xml +done +``` + +修改在每个节点目录 `fs/volumes/clickhouse-keeper-{}/etc/clickhouse-keeper` 中创建的空配置文件。下面突出显示的行需要根据每个节点进行更改: + +```xml title="/config.d/config.xml" + + + information + /var/log/clickhouse-keeper/clickhouse-keeper.log + /var/log/clickhouse-keeper/clickhouse-keeper.err.log + 1000M + 3 + + 0.0.0.0 + + 9181 + + 1 + /var/lib/clickhouse/coordination/log + /var/lib/clickhouse/coordination/snapshots + + 10000 + 30000 + information + + + + 1 + clickhouse-keeper-01 + 9234 + + + 2 + clickhouse-keeper-02 + 9234 + + + 3 + clickhouse-keeper-03 + 9234 + + + + +``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_keeper_config.mdx.hash b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_keeper_config.mdx.hash new file mode 100644 index 00000000000..5028b2475e2 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_keeper_config.mdx.hash @@ -0,0 +1 @@ +929b29a0b433b166 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_keeper_explanation.mdx b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_keeper_explanation.mdx new file mode 100644 index 00000000000..0b9bc752dcd --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_keeper_explanation.mdx @@ -0,0 +1,32 @@ +每个配置文件将包含以下唯一配置(如下所示)。 +用于 ClickHouse Keeper 节点的 `server_id` 应在集群中唯一,并且与 `` 部分中定义的服务器 `` 匹配。 +`tcp_port` 是 ClickHouse Keeper 的 _客户端_ 使用的端口。 + +```xml +9181 +{id} +``` + +以下部分用于配置参与 [raft 共识算法](https://en.wikipedia.org/wiki/Raft_(algorithm)) 的服务器: + +```xml + + + 1 + clickhouse-keeper-01 + + + 9234 + + + 2 + clickhouse-keeper-02 + 9234 + + + 3 + clickhouse-keeper-03 + 9234 + + +``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_keeper_explanation.mdx.hash b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_keeper_explanation.mdx.hash new file mode 100644 index 00000000000..61728596e8c --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_keeper_explanation.mdx.hash @@ -0,0 +1 @@ +beab695596574d47 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_listen_host.mdx b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_listen_host.mdx new file mode 100644 index 00000000000..31675804d5c --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_listen_host.mdx @@ -0,0 +1,17 @@ +外部通信通过激活 listen host 设置来启用网络接口。这确保 ClickHouse 服务器主机可以被其他主机访问: + +```xml +0.0.0.0 +``` + +HTTP API 的端口设置为 `8123`: + +```xml +8123 +``` + +用于 clickhouse-client 与其他本地 ClickHouse 工具以及 clickhouse-server 与其他 clickhouse-servers 之间通过 ClickHouse 本地协议进行交互的 TCP 端口设置为 `9000`: + +```xml +9000 +``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_listen_host.mdx.hash b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_listen_host.mdx.hash new file mode 100644 index 00000000000..250edb979ee --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_listen_host.mdx.hash @@ -0,0 +1 @@ +770167eec0c0cc9d diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_server_parameter_table.mdx b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_server_parameter_table.mdx new file mode 100644 index 00000000000..92a0ac696be --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_server_parameter_table.mdx @@ -0,0 +1,6 @@ +对于每个服务器,指定以下参数: + +| 参数 | 描述 | 默认值 | +|---------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------| +| `host` | 远程服务器的地址。您可以使用域名或 IPv4 或 IPv6 地址。如果您指定域名,服务器在启动时会发出 DNS 请求,并将结果存储在服务器运行期间。如果 DNS 请求失败,服务器将无法启动。如果您更改 DNS 记录,则需要重新启动服务器。 | - | +| `port` | 用于消息传递活动的 TCP 端口(配置中的 `tcp_port`,通常设置为 9000)。不要与 `http_port` 混淆。 | - | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_server_parameter_table.mdx.hash b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_server_parameter_table.mdx.hash new file mode 100644 index 00000000000..1c4e6ba6021 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_server_parameter_table.mdx.hash @@ -0,0 +1 @@ +a3e320e842195437 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_verify_keeper_using_mntr.mdx b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_verify_keeper_using_mntr.mdx new file mode 100644 index 00000000000..74d6dde8c6b --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_verify_keeper_using_mntr.mdx @@ -0,0 +1,67 @@ +`mntr` 命令通常用于验证 ClickHouse Keeper 是否正在运行,并获取有关三个 Keeper 节点关系的状态信息。在本示例中使用的配置中,有三个节点协同工作。节点将选举出一个领导者,其余的节点将作为跟随者。 + +`mntr` 命令提供与性能相关的信息,以及某个特定节点是跟随者还是领导者。 + +:::tip +您可能需要安装 `netcat` 以便将 `mntr` 命令发送到 Keeper。请参见 [nmap.org](https://nmap.org/ncat/) 页面以获取下载信息。 +::: + +在 `clickhouse-keeper-01`、`clickhouse-keeper-02` 和 `clickhouse-keeper-03` 上从 shell 运行以下命令,以检查每个 Keeper 节点的状态。`clickhouse-keeper-01` 的命令如下所示: + +```bash +docker exec -it clickhouse-keeper-01 /bin/sh -c 'echo mntr | nc 127.0.0.1 9181' +``` + +下面的响应显示了来自跟随者节点的示例响应: + +```response title="Response" +zk_version v23.3.1.2823-testing-46e85357ce2da2a99f56ee83a079e892d7ec3726 +zk_avg_latency 0 +zk_max_latency 0 +zk_min_latency 0 +zk_packets_received 0 +zk_packets_sent 0 +zk_num_alive_connections 0 +zk_outstanding_requests 0 + +# highlight-next-line +zk_server_state follower +zk_znode_count 6 +zk_watch_count 0 +zk_ephemerals_count 0 +zk_approximate_data_size 1271 +zk_key_arena_size 4096 +zk_latest_snapshot_size 0 +zk_open_file_descriptor_count 46 +zk_max_file_descriptor_count 18446744073709551615 +``` + +下面的响应显示了来自领导者节点的示例响应: + +```response title="Response" +zk_version v23.3.1.2823-testing-46e85357ce2da2a99f56ee83a079e892d7ec3726 +zk_avg_latency 0 +zk_max_latency 0 +zk_min_latency 0 +zk_packets_received 0 +zk_packets_sent 0 +zk_num_alive_connections 0 +zk_outstanding_requests 0 + +# highlight-next-line +zk_server_state leader +zk_znode_count 6 +zk_watch_count 0 +zk_ephemerals_count 0 +zk_approximate_data_size 1271 +zk_key_arena_size 4096 +zk_latest_snapshot_size 0 +zk_open_file_descriptor_count 48 +zk_max_file_descriptor_count 18446744073709551615 + +# highlight-start +zk_followers 2 +zk_synced_followers 2 + +# highlight-end +``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_verify_keeper_using_mntr.mdx.hash b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_verify_keeper_using_mntr.mdx.hash new file mode 100644 index 00000000000..5a079f1f926 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_verify_keeper_using_mntr.mdx.hash @@ -0,0 +1 @@ +ab3011bd8978f500 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_working_example.mdx b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_working_example.mdx new file mode 100644 index 00000000000..dea9ae77bb6 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_working_example.mdx @@ -0,0 +1,3 @@ +:::tip 示例文件 +以下步骤将指导您从头开始设置集群。如果您希望跳过这些步骤并直接运行集群,可以从 [examples repository](https://github.com/ClickHouse/examples/tree/main/docker-compose-recipes) 获取示例文件。 +::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_working_example.mdx.hash b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_working_example.mdx.hash new file mode 100644 index 00000000000..26f10a16454 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/replication-sharding-examples/_snippets/_working_example.mdx.hash @@ -0,0 +1 @@ +34c8702243cbe6c6 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/terminology.md b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/terminology.md index acd2cf8c90c..61f856d8b4f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/terminology.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/terminology.md @@ -3,22 +3,17 @@ 'sidebar_label': '介绍' 'title': '介绍' 'sidebar_position': 1 -'description': '此页面包含基于 ClickHouse Support and Services 组织向 ClickHouse 用户提供的建议的部署示例' +'description': '此页面包含基于 ClickHouse 支持和服务组织为 ClickHouse 用户提供的建议的部署示例' +'doc_type': 'guide' --- import ReplicationShardingTerminology from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_replication-sharding-terminology.md'; -这些部署示例基于 ClickHouse 支持和服务组织向 ClickHouse 用户提供的建议。 这些都是有效的示例,我们建议您尝试它们,然后根据您的需求进行调整。 您可能会在这里找到完全符合您要求的示例。 或者,如果您有一个需求是数据复制三次而不是两次,您应该能够按照这里呈现的模式添加另一个副本。 +该部分中的部署示例是基于 ClickHouse 支持和服务组织对 ClickHouse 用户提供的建议。这些是有效的示例,我们推荐您尝试这些示例并根据您的需求进行调整。您可能会在这里找到一个完全符合您要求的示例。 - - -## 示例 {#examples} - -### 基本 {#basic} +我们在 [example repo](https://github.com/ClickHouse/examples/tree/main/docker-compose-recipes/recipes) 中提供了多种不同拓扑的“配方”,如果本节中的示例不完全符合您的需求,建议您查看这些配方。 -- [**横向扩展**](/deployment-guides/horizontal-scaling.md) 示例展示了如何在两个节点之间分片数据,并使用分布式表。 这将导致在两个 ClickHouse 节点上存储数据。 这两个 ClickHouse 节点还运行 ClickHouse Keeper 提供分布式同步。 第三个节点独立运行 ClickHouse Keeper 以完成 ClickHouse Keeper 的法定人数。 - -- [**故障容错的复制**](/deployment-guides/replicated.md) 示例展示了如何在两个节点之间复制数据,并使用 ReplicatedMergeTree 表。 这将导致在两个 ClickHouse 节点上存储数据。 除了这两个 ClickHouse 服务器节点外,还有三个独立的 ClickHouse Keeper 节点来管理复制。 +
- -### 中级 {#intermediate} - -- 敬请期待 - -### 高级 {#advanced} - -- 敬请期待 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/terminology.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/terminology.md.hash index c813bde4b34..db9ccda6e89 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/terminology.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-guides/terminology.md.hash @@ -1 +1 @@ -32998f267bc5d198 +09807d32f05833a0 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/deployment-modes.md b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-modes.md index e0d7ea6041b..39eaed7bcbd 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/deployment-modes.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-modes.md @@ -1,12 +1,13 @@ --- 'slug': '/deployment-modes' 'sidebar_label': '部署模式' -'description': 'ClickHouse 提供四种部署选项,所有选项都使用相同强大的 DATABASE 引擎,只是为满足您的特定需求而以不同方式打包。' +'description': 'ClickHouse 提供四种部署选项,所有选项均使用相同强大的 DATABASE 引擎,只是以不同的方式打包,以满足您的特定需求。' 'title': '部署模式' 'keywords': - 'Deployment Modes' - 'chDB' 'show_related_blogs': true +'doc_type': 'guide' --- import chServer from '@site/static/images/deployment-modes/ch-server.png'; @@ -15,64 +16,64 @@ import chLocal from '@site/static/images/deployment-modes/ch-local.png'; import chDB from '@site/static/images/deployment-modes/chdb.png'; import Image from '@theme/IdealImage'; -ClickHouse 是一个多功能的数据库系统,可以根据您的需求以多种不同方式部署。在其核心,所有部署选项 **都使用相同强大的 ClickHouse 数据库引擎** —— 不同之处在于您如何与其互动以及它运行的位置。 +ClickHouse 是一个灵活的数据库系统,根据您的需求可以以多种方式部署。在其核心,所有部署选项 **使用相同强大的 ClickHouse 数据库引擎** – 不同之处在于您如何与其交互以及它运行的位置。 -无论您是在生产中运行大规模分析,进行本地数据分析,还是构建应用程序,都有针对您用例设计的部署选项。底层引擎的一致性意味着您可以在所有部署模式中获得相同的高性能和 SQL 兼容性。 -本指南探讨了部署和使用 ClickHouse 的四种主要方式: +无论您是在生产中运行大规模分析、进行本地数据分析,还是构建应用程序,都有一个针对您用例的部署选项。底层引擎的一致性意味着您在所有部署模式中都能获得相同的高性能和 SQL 兼容性。 +本指南探讨了使用 ClickHouse 的四种主要部署方式: -* ClickHouse Server 用于传统的客户端/服务器部署 -* ClickHouse Cloud 用于完全托管的数据库操作 +* ClickHouse Server 适用于传统的客户端/服务器部署 +* ClickHouse Cloud 适用于完全托管的数据库操作 * clickhouse-local 用于命令行数据处理 -* chDB 用于在应用程序中直接嵌入 ClickHouse +* chDB 适用于直接在应用程序中嵌入 ClickHouse 每种部署模式都有其自身的优势和理想用例,我们将在下面详细探讨。 - + ## ClickHouse Server {#clickhouse-server} -ClickHouse Server 代表传统的客户端/服务器架构,非常适合生产部署。这种部署模式提供了完整的 OLAP 数据库功能,具有 ClickHouse 所以以闻名的高吞吐量和低延迟查询。 +ClickHouse Server 代表传统的客户端/服务器架构,适用于生产部署。此部署模式提供完整的 OLAP 数据库功能,具备 ClickHouse 所以闻名的高吞吐量和低延迟查询。 ClickHouse Server
-在部署灵活性方面,ClickHouse Server 可以在您的本地机器上安装以进行开发或测试,部署到主要云提供商如 AWS、GCP 或 Azure 进行云操作,或在您自己的本地硬件上设置。对于大规模操作,它可以配置为分布式集群,以处理增加的负载并提供高可用性。 +在部署灵活性方面,ClickHouse Server 可以安装在您的本地计算机上以进行开发或测试,或者部署到 AWS、GCP 或 Azure 等主要云服务提供商的云环境,或在您自己的本地硬件上设置。对于大规模操作,它可以配置为分布式集群,以处理增加的负载并提供高可用性。 -这种部署模式是需要可靠性、性能和全面功能访问的生产环境的首选。 +这种部署模式是生产环境的首选,可靠性、性能和完整功能访问至关重要。 ## ClickHouse Cloud {#clickhouse-cloud} -[ClickHouse Cloud](/cloud/overview) 是 ClickHouse 的完全托管版本,消除了运行自己部署的操作开销。尽管它维护了 ClickHouse Server 的所有核心功能,但它通过额外的功能增强了开发和操作的体验。 +[ClickHouse Cloud](/cloud/overview) 是 ClickHouse 的一个完全托管版本,消除了运行自己部署的操作开销。虽然它保持了 ClickHouse Server 的所有核心功能,但通过旨在简化开发和运营的额外功能增强了用户体验。 ClickHouse Cloud -ClickHouse Cloud 的一个主要优势是其集成工具。[ClickPipes](/cloud/get-started/cloud-quick-start#clickpipes) 提供了一个强大的数据摄取框架,使您能够轻松连接并从各种源流数据,而无需管理复杂的 ETL 流水线。该平台还提供了专用的 [查询 API](/cloud/get-started/query-endpoints),大大简化了构建应用程序的过程。 +ClickHouse Cloud 的一个主要优势是其集成工具。[ClickPipes](/getting-started/quick-start/cloud/#clickpipes) 提供了一个强大的数据摄取框架,允许您轻松连接并从各种来源流式传输数据,而无需管理复杂的 ETL 流水线。该平台还提供专用的 [查询 API](/cloud/get-started/query-endpoints),让构建应用程序变得更加轻松。 -ClickHouse Cloud 中的 SQL 控制台包括强大的 [仪表盘](/cloud/manage/dashboards) 功能,让您可以将查询转化为交互式可视化。您可以创建和共享由保存的查询构建的仪表盘,能够通过查询参数添加交互元素。这些仪表盘可以通过全局过滤器动态生成,让用户通过可自定义的视图探索数据——尽管需要指出的是,用户需要至少读取访问权限才能查看可视化的底层保存查询。 +ClickHouse Cloud 中的 SQL 控制台包括一个强大的 [仪表板](/cloud/manage/dashboards) 功能,让您可以将查询转化为交互式可视化。您可以创建并共享由保存的查询构建的仪表板,并通过查询参数添加交互元素。这些仪表板可以通过全局过滤器动态生成,允许用户通过可定制的视图探索数据 – 不过需要注意的是,用户至少需要对基础的保存查询有读取访问权限才能查看可视化。 -对于监控和优化,ClickHouse Cloud 包含内置图表和 [查询洞察](/cloud/get-started/query-insights)。这些工具提供了深度的集群性能可见性,帮助您理解查询模式、资源利用率和潜在的优化机会。这种可观察性的水平对需要维持高性能分析操作而不分配资源进行基础设施管理的团队特别有价值。 +为了监控和优化,ClickHouse Cloud 包括内置图表和 [查询洞察](/cloud/get-started/query-insights)。这些工具提供了对您的集群性能的深刻可见性,帮助您理解查询模式、资源利用率和潜在的优化机会。这种可观察性对需要维持高性能分析操作的团队尤其重要,而无需分配资源用于基础设施管理。 -该服务的托管特性意味着您无需担心更新、备份、扩展或安全补丁——这些都由系统自动处理。这使得它成为希望集中精力于数据和应用程序而不是数据库管理的组织的理想选择。 +该服务的托管性质意味着您无需担心更新、备份、扩展或安全补丁 – 这些都将自动处理。这使其成为希望专注于数据和应用程序而非数据库管理的组织的理想选择。 ## clickhouse-local {#clickhouse-local} -[clickhouse-local](/operations/utilities/clickhouse-local) 是一个强大的命令行工具,提供了 ClickHouse 的完整功能,打包为一个独立的可执行文件。它本质上与 ClickHouse Server 是相同的数据库,但以一种方式打包,使您可以直接从命令行利用 ClickHouse 的所有能力,而无需运行服务器实例。 +[clickhouse-local](/operations/utilities/clickhouse-local) 是一个强大的命令行工具,提供 ClickHouse 的完整功能,作为一个独立的可执行文件。它本质上是与 ClickHouse Server 相同的数据库,但以一种让您可以直接从命令行利用 ClickHouse 的所有功能而无需运行服务器实例的方式打包。 clickHouse-local -该工具在临时数据分析方面表现出色,特别是在处理本地文件或存储在云存储服务中的数据时。您可以使用 ClickHouse 的 SQL 方言直接查询各种格式(CSV、JSON、Parquet 等)的文件,是快速数据探索或单次分析任务的绝佳选择。 +该工具在临时数据分析中表现出色,特别是在处理本地文件或存储在云存储服务中的数据时。您可以使用 ClickHouse 的 SQL 方言直接查询各种格式的文件(CSV、JSON、Parquet 等),使其成为快速数据探索或一次性分析任务的极佳选择。 -由于 clickhouse-local 包含了 ClickHouse 的所有功能,您可以用它进行数据转换、格式转换或任何您通常用 ClickHouse Server 完成的数据库操作。虽然主要用于临时操作,但在需要时它也可以使用与 ClickHouse Server 相同的存储引擎持久化数据。 +由于 clickhouse-local 包含 ClickHouse 的所有功能,您可以用于数据转换、格式转换或您通常使用 ClickHouse Server 进行的任何其他数据库操作。虽然主要用于临时操作,但在需要时也可以使用与 ClickHouse Server 相同的存储引擎持久化数据。 -远程表函数的组合与对本地文件系统的访问使得 clickhouse-local 在需要在 ClickHouse Server 和本地计算机上的文件之间连接数据的场景中特别有用。这在处理您不想上传到服务器的敏感或临时本地数据时尤为有价值。 +通过远程表函数和对本地文件系统的访问,使得 clickhouse-local 在需要将数据连接到 ClickHouse Server 和本地计算机上的文件之间的场景中特别有用。这在处理敏感或临时本地数据时特别有价值,因为您不想将其上传到服务器。 ## chDB {#chdb} -[chDB](/chdb) 是 ClickHouse 嵌入的进程内数据库引擎,Python 是主要实现语言,此外还支持 Go、Rust、NodeJS 和 Bun。这种部署选项将 ClickHouse 强大的 OLAP 功能直接带入应用程序的进程中,消除了单独安装数据库的需要。 +[chDB](/chdb) 是将 ClickHouse 嵌入为进程内数据库引擎,主要实现为 Python,此外还可用于 Go、Rust、NodeJS 和 Bun。此部署选项将 ClickHouse 强大的 OLAP 功能直接带入您的应用程序进程中,消除了单独安装数据库的需要。 chDB - Embedded ClickHouse -chDB 与您应用程序的生态系统无缝集成。例如,在 Python 中,它已优化为有效地与常见数据科学工具如 Pandas 和 Arrow 一起工作,通过 Python memoryview 最小化数据复制开销。这使得它在希望在现有工作流程中利用 ClickHouse 查询性能的数据科学家和分析师中尤为有价值。 +chDB 与您的应用程序生态系统无缝集成。例如,在 Python 中,它优化了与常用的数据科学工具如 Pandas 和 Arrow 的高效工作,最小化数据复制开销通过 Python memoryview。这对希望在现有工作流中利用 ClickHouse 查询性能的数据科学家和分析师特别有价值。 -chDB 还可以连接使用 clickhouse-local 创建的数据库,为您处理数据提供灵活性。这意味着您可以在本地开发、在 Python 中进行数据探索以及更永久的存储解决方案之间无缝过渡,而无需更改数据访问模式。 +chDB 还可以连接使用 clickhouse-local 创建的数据库,为您处理数据提供灵活性。这意味着您可以在本地开发、Python 中的数据探索和更持久的存储解决方案之间无缝过渡,而无需更改数据访问模式。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/deployment-modes.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-modes.md.hash index 01ebef3fd97..08ee86ad8b7 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/deployment-modes.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/deployment-modes.md.hash @@ -1 +1 @@ -9c458e8e9c073ee0 +b8c93ee6366e8b32 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/development/architecture.md b/i18n/zh/docusaurus-plugin-content-docs/current/development/architecture.md index 81ae95709bf..fd1daaa506c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/development/architecture.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/development/architecture.md @@ -1,219 +1,221 @@ --- -'description': '对 ClickHouse 架构及其列式设计的全面概述' +'description': '关于 ClickHouse 架构及其列式设计的综合概述' 'sidebar_label': '架构概述' 'sidebar_position': 50 'slug': '/development/architecture' 'title': '架构概述' +'doc_type': 'reference' --- + # 架构概述 -ClickHouse 是一个真正的列式数据库管理系统。数据以列的形式存储,并在执行数组(列的向量或块)时进行处理。只要可能,操作会在数组上调度,而不是在单个值上执行。这种方法被称为“向量化查询执行”,有助于降低实际数据处理的成本。 +ClickHouse 是一个真正的列式 DBMS。数据按列存储,并在执行数组(向量或列的块)时进行处理。只要可能,就会在数组上调度操作,而不是单个值上。这被称为“向量化查询执行”,它有助于降低实际数据处理的成本。 -这个想法并不新颖。它可以追溯到 `APL`(一种编程语言,1957)及其后裔:`A +`(APL方言)、`J`(1990)、`K`(1993)和 `Q`(Kx Systems的编程语言,2003)。数组编程在科学数据处理中被广泛使用。在关系数据库中,这个想法也不是新鲜事物。例如,它在 `VectorWise` 系统(也称为 Actian Corporation 的 Actian Vector 分析数据库)中得到了应用。 +这个想法并不新颖。它可以追溯到 `APL`(一种编程语言,1957 年)及其后代:`A +`(APL 方言)、`J`(1990 年)、`K`(1993 年)和 `Q`(Kx Systems 的编程语言,2003 年)。数组编程在科学数据处理中被使用。这个想法在关系数据库中也并不是新鲜事物。例如,它在 `VectorWise` 系统(也称为 Actian Corporation 的 Actian Vector 分析数据库)中被使用。 -加速查询处理有两种不同的方式:向量化查询执行和运行时代码生成。后者消除了所有间接调用和动态调度。这两种方法并没有严格的优劣之分。当它合并许多操作时,运行时代码生成可能更好,从而充分利用 CPU 执行单元和流水线。向量化查询执行可能不太实用,因为它涉及必须写入缓存并重新读取的临时向量。如果临时数据无法装入 L2 缓存,这会成为一个问题。但向量化查询执行更容易利用 CPU 的 SIMD 能力。我们的朋友写的一篇 [研究论文](http://15721.courses.cs.cmu.edu/spring2016/papers/p5-sompolski.pdf) 显示,将两种方法结合使用更为有效。ClickHouse 使用向量化查询执行,并且对运行时代码生成有有限的初步支持。 +加速查询处理有两种不同的方法:向量化查询执行和运行时代码生成。后者消除了所有间接性和动态调度。这两种方法没有哪种严格地优于另一种。当它融合多种操作并充分利用 CPU 执行单元和管道时,运行时代码生成可能会更好。向量化查询执行可能不太实际,因为它涉及到必须写入缓存并读取的临时向量。如果临时数据无法适配 L2 缓存,这就成了一个问题。但向量化查询执行更容易利用 CPU 的 SIMD 能力。我们朋友写的一篇 [研究论文](http://15721.courses.cs.cmu.edu/spring2016/papers/p5-sompolski.pdf) 表明,结合这两种方法是更好的选择。ClickHouse 使用向量化查询执行,并对运行时代码生成有有限的初始支持。 ## 列 {#columns} -`IColumn` 接口用于表示内存中的列(实际上是列的块)。该接口提供了实现各种关系操作符的辅助方法。几乎所有操作都是不可变的:它们不会修改原始列,而是创建一个新的修改后的列。例如,`IColumn :: filter` 方法接受一个筛选字节掩码。它用于 `WHERE` 和 `HAVING` 关系操作符。其他示例包括:`IColumn :: permute` 方法以支持 `ORDER BY`,`IColumn :: cut` 方法以支持 `LIMIT`。 +`IColumn` 接口用于表示内存中的列(实际上是列的块)。此接口提供辅助方法用于实现各种关系运算符。几乎所有操作都是不可变的:它们不修改原始列,而是创建一个新的修改过的列。例如,`IColumn :: filter` 方法接受一个筛选字节掩码。它用于 `WHERE` 和 `HAVING` 关系运算符。其他示例:`IColumn :: permute` 方法支持 `ORDER BY`,`IColumn :: cut` 方法支持 `LIMIT`。 -各种 `IColumn` 实现(如 `ColumnUInt8`、`ColumnString` 等)负责列的内存布局。内存布局通常是一个连续数组。对于整数类型的列,它只是一个连续数组,如 `std :: vector`。对于 `String` 和 `Array` 列,它是两个向量:一个是所有数组元素,彼此连续存放,另一个是每个数组起始位置的偏移量。还有 `ColumnConst`,它在内存中只存储一个值,但看起来像一列。 +各种 `IColumn` 的实现(`ColumnUInt8`、`ColumnString` 等)负责列的内存布局。内存布局通常是一个连续的数组。对于整数类型的列,它只是一个连续的数组,如 `std :: vector`。对于 `String` 和 `Array` 列,它们是两个向量:一个是所有数组元素,连续存放,另一个是每个数组开始位置的偏移。还有 `ColumnConst`,它在内存中仅存储一个值,但看起来像列。 ## 字段 {#field} -然而,也可以对单个值进行操作。为了表示一个单独的值,使用 `Field`。`Field` 只是 `UInt64`、`Int64`、`Float64`、`String` 和 `Array` 的一种区分联合。`IColumn` 具有 `operator []` 方法,用于获取第 n 个值作为 `Field`,以及 `insert` 方法,用于将 `Field` 追加到列的末尾。这些方法效率不是很高,因为它们需要处理表示单个值的临时 `Field` 对象。还有其他更高效的方法,如 `insertFrom`、`insertRangeFrom` 等。 +然而,也可以处理单个值。为了表示一个单独的值,使用 `Field`。`Field` 只是 `UInt64`、`Int64`、`Float64`、`String` 和 `Array` 的一个带标签的联合体。`IColumn` 具有 `operator []` 方法,可以获取第 n 个值作为 `Field`,并且 `insert` 方法将 `Field` 附加到列的末尾。这些方法不是非常高效,因为它们涉及到处理表示单个值的临时 `Field` 对象。有更高效的方法,例如 `insertFrom`、`insertRangeFrom` 等。 -`Field` 对于表的特定数据类型没有足够的信息。例如,`UInt8`、`UInt16`、`UInt32` 和 `UInt64` 都在 `Field` 中表示为 `UInt64`。 +`Field` 对表的具体数据类型没有足够的信息。例如,`UInt8`、`UInt16`、`UInt32` 和 `UInt64` 在 `Field` 中都是以 `UInt64` 表示。 -## 漏洞抽象 {#leaky-abstractions} +## 漏斗抽象 {#leaky-abstractions} -`IColumn` 具有用于常见关系数据变换的方法,但它们并不能满足所有需求。例如,`ColumnUInt64` 没有可计算两个列的和的方法,而 `ColumnString` 没有进行子串搜索的方法。这些无数例程在 `IColumn` 之外实现。 +`IColumn` 具有用于常见关系数据转换的方法,但它们并不能满足所有需求。例如,`ColumnUInt64` 没有计算两个列之和的方法,而 `ColumnString` 没有运行子串搜索的方法。这些无数的例程都是在 `IColumn` 之外实现的。 -可以以通用但效率不高的方式使用 `IColumn` 方法提取 `Field` 值,或者以专门的方式使用特定 `IColumn` 实现内部内存布局的知识来实现各种列上的功能。这通过将函数强制转换为特定 `IColumn` 类型并直接处理内部表示来实现。例如,`ColumnUInt64` 具有 `getData` 方法,返回对内部数组的引用,然后一个单独的例程直接读取或填充该数组。我们有“漏洞抽象”,以允许各种例程的高效专门化。 +可以使用 `IColumn` 方法提取 `Field` 值,以通用但不高效的方式实现列上的各种函数,或者使用对特定 `IColumn` 实现内部内存布局的知识以专业的方式实现它。通过将函数强制转换为特定的 `IColumn` 类型,并直接处理内部表示来实现。例如,`ColumnUInt64` 有 `getData` 方法,它返回对内部数组的引用,然后一个单独的例程直接读取或填充该数组。我们有“漏斗抽象”,以便允许各种例程的高效特化。 ## 数据类型 {#data_types} -`IDataType` 负责序列化和反序列化:以二进制或文本形式读取和写入列块或单个值。`IDataType` 直接对应于表中的数据类型。例如,有 `DataTypeUInt32`、`DataTypeDateTime`、`DataTypeString` 等。 +`IDataType` 负责序列化和反序列化:用于以二进制或文本形式读取和写入列块或单个值。`IDataType` 与表中的数据类型直接对应。例如,有 `DataTypeUInt32`、`DataTypeDateTime`、`DataTypeString` 等。 -`IDataType` 和 `IColumn` 之间只有松散的联系。不同的数据类型可以通过相同的 `IColumn` 实现存储在内存中。例如,`DataTypeUInt32` 和 `DataTypeDateTime` 都可以由 `ColumnUInt32` 或 `ColumnConstUInt32` 表示。此外,同一种数据类型可以由不同的 `IColumn` 实现表示。例如,`DataTypeUInt8` 可以由 `ColumnUInt8` 或 `ColumnConstUInt8` 表示。 +`IDataType` 和 `IColumn` 之间的关系相对较弱。不同的数据类型可以由相同的 `IColumn` 实现表示。例如,`DataTypeUInt32` 和 `DataTypeDateTime` 都由 `ColumnUInt32` 或 `ColumnConstUInt32` 表示。此外,相同的数据类型可以由不同的 `IColumn` 实现表示。例如,`DataTypeUInt8` 可以由 `ColumnUInt8` 或 `ColumnConstUInt8` 表示。 -`IDataType` 仅存储元数据。例如,`DataTypeUInt8` 不存储任何内容(除了虚拟指针 `vptr`),而 `DataTypeFixedString` 仅存储 `N`(固定大小字符串的大小)。 +`IDataType` 仅存储元数据。例如,`DataTypeUInt8` 完全不存储任何内容(除了虚拟指针 `vptr`),而 `DataTypeFixedString` 仅存储 `N`(固定大小字符串的大小)。 -`IDataType` 具有用于各种数据格式的辅助方法。示例包括用于序列化可能引用的值、为 JSON 序列化值以及以 XML 格式序列化值的方法。数据格式没有直接对应关系。例如,不同的数据格式 `Pretty` 和 `TabSeparated` 可以使用来自 `IDataType` 接口的相同 `serializeTextEscaped` 辅助方法。 +`IDataType` 有多种数据格式的辅助方法。例如,序列化带有可能引用的值的方法、为 JSON 序列化值的方法以及作为 XML 格式的一部分序列化值的方法。与数据格式没有直接对应。例如,不同的数据格式 `Pretty` 和 `TabSeparated` 可以使用 `IDataType` 接口中的相同 `serializeTextEscaped` 辅助方法。 ## 块 {#block} -`Block` 是一个容器,表示内存中表的子集(块)。它只是一组三元组:`(IColumn, IDataType, 列名)`。在查询执行过程中,数据通过 `Block` 进行处理。如果我们有一个 `Block`,则我们拥有数据(在 `IColumn` 对象中)、关于其类型的信息(在 `IDataType` 中,告知我们如何处理该列),并且我们有列名。它可以是来自表的原始列名,也可以是为获取计算的临时结果而分配的某个人工名称。 +`Block` 是表示内存中表的子集(块)的容器。它仅仅是一组三元组:(IColumn, IDataType, 列名)。在查询执行期间,数据通过 `Block` 进行处理。如果我们有一个 `Block`,则我们有数据(在 `IColumn` 对象中),我们有其类型的信息(在 `IDataType` 中),该信息告诉我们如何处理该列,并且我们有列名。列名可以是表的原始列名,也可以是为获取计算临时结果而分配的某些人工名称。 -当我们在块中的列上计算某个函数时,我们将其结果添加到块中,而不触碰函数参数的列,因为操作是不可变的。稍后,可以从块中删除不必要的列,但无法修改它。这样有助于消除公共子表达式。 +当我们在块中的列上计算某个函数时,我们将另一个列与其结果添加到该块中,我们不接触函数参数的列,因为操作是不可变的。之后,可以从块中删除不需要的列,但不能修改它。这样做方便消除公共子表达式。 -每处理一块数据都会创建块。请注意,对于相同类型的计算,列名和类型在不同块之间保持相同,只有列数据发生变化。最好将块数据与块头分离,因为小块大小在复制 shared_ptr 和列名时会产生高开销。 +块是为每个处理过的数据块创建的。请注意,对于相同类型的计算,列名和类型在不同块中保持相同,只有列数据发生变化。将块数据与块头分开是更好的,因为小块大小对复制 shared_ptr 和列名的临时字符串产生较大的开销。 ## 处理器 {#processors} -请参阅 [https://github.com/ClickHouse/ClickHouse/blob/master/src/Processors/IProcessor.h](https://github.com/ClickHouse/ClickHouse/blob/master/src/Processors/IProcessor.h) 中的描述。 +请参见 [https://github.com/ClickHouse/ClickHouse/blob/master/src/Processors/IProcessor.h](https://github.com/ClickHouse/ClickHouse/blob/master/src/Processors/IProcessor.h) 中的描述。 ## 格式 {#formats} -数据格式是通过处理器实现的。 +数据格式通过处理器实现。 -## 输入/输出 {#io} +## I/O {#io} -对于面向字节的输入/输出,有 `ReadBuffer` 和 `WriteBuffer` 抽象类。它们代替 C++ `iostream` 使用。不要担心:每个成熟的 C++ 项目都出于良好的理由使用其他东西而不是 `iostream`。 +对于字节导向的输入/输出,有 `ReadBuffer` 和 `WriteBuffer` 抽象类。它们被用来替代 C++ 的 `iostream`。不要担心:每个成熟的 C++ 项目出于良好的理由使用其他东西,而不是 `iostream`。 -`ReadBuffer` 和 `WriteBuffer` 只是一个连续的缓冲区以及指向该缓冲区中位置的光标。实现可以拥有或不拥有缓冲区的内存。对于 `ReadBuffer`,有一个虚拟方法用于填充以下数据,而对于 `WriteBuffer`,则用于将缓冲区刷新到某处。这些虚拟方法很少被调用。 +`ReadBuffer` 和 `WriteBuffer` 只是一个连续的缓冲区和一个指向该缓冲区中位置的游标。实现可以拥有或不拥有缓冲区的内存。有一个虚拟方法用于用以下数据填充缓冲区(对于 `ReadBuffer`),或者将缓冲区刷新到某处(对于 `WriteBuffer`)。这些虚拟方法很少被调用。 -`ReadBuffer`/`WriteBuffer` 的实现用于处理文件和文件描述符及网络套接字,用于实现压缩(`CompressedWriteBuffer` 使用另一个 WriteBuffer 初始化,并在将数据写入之前执行压缩),以及其他用途——例如,`ConcatReadBuffer`、`LimitReadBuffer` 和 `HashingWriteBuffer` 的名称都是自解释的。 +`ReadBuffer`/`WriteBuffer` 的实现用于处理文件和文件描述符以及网络套接字,用于实现压缩(`CompressedWriteBuffer` 初始化时接收另一个 WriteBuffer,并在将数据写入其中之前执行压缩),以及其他用途——名称 `ConcatReadBuffer`、`LimitReadBuffer` 和 `HashingWriteBuffer` 自说明了。 -读/写缓冲区只处理字节。从 `ReadHelpers` 和 `WriteHelpers` 头文件中有函数可以帮助格式化输入/输出。例如,有辅助函数将数字写入十进制格式。 +Read/WriteBuffers 仅处理字节。`ReadHelpers` 和 `WriteHelpers` 头文件中有用于帮助格式化输入/输出的函数。例如,有写入十进制格式数字的辅助函数。 -让我们检查一下,当您想将结果集以 `JSON` 格式写入 stdout 时会发生什么。 -您已经准备好从提取 `QueryPipeline` 中获取结果集。 -首先,您创建一个 `WriteBufferFromFileDescriptor(STDOUT_FILENO)`,将字节写入 stdout。 -接下来,您将查询管道的结果连接到 `JSONRowOutputFormat`,该格式使用该 `WriteBuffer` 初始化,以将行以 `JSON` 格式写入 stdout。 -这可以通过 `complete` 方法完成,该方法将提取的 `QueryPipeline` 转换为已完成的 `QueryPipeline`。 -在内部,`JSONRowOutputFormat` 将写入各种 JSON 分隔符,并调用 `IDataType::serializeTextJSON` 方法,参数为 `IColumn` 的引用和行号。因此,`IDataType::serializeTextJSON` 将调用 `WriteHelpers.h` 中的方法:例如,数值类型的 `writeText` 和 `DataTypeString` 的 `writeJSONString`。 +让我们检查一下当您想要以 `JSON` 格式将结果集合写入 stdout 时发生的事情。 +您已经准备好从拉取 `QueryPipeline` 中获取结果集。 +首先,您创建一个 `WriteBufferFromFileDescriptor(STDOUT_FILENO)`,以将字节写入 stdout。 +接下来,您将来自查询管道的结果连接到 `JSONRowOutputFormat`,它使用该 `WriteBuffer` 初始化,以将行以 `JSON` 格式写入 stdout。 +这可以通过 `complete` 方法完成,该方法将拉取的 `QueryPipeline` 转换为已完成的 `QueryPipeline`。 +内部,`JSONRowOutputFormat` 将写入各种 JSON 分隔符,并调用 `IDataType::serializeTextJSON` 方法,传入 `IColumn` 的引用和行号作为参数。因此,`IDataType::serializeTextJSON` 将调用 `WriteHelpers.h` 中的方法:例如,对数值类型使用 `writeText`,对 `DataTypeString` 使用 `writeJSONString`。 ## 表 {#tables} -`IStorage` 接口表示表。这种接口的不同实现是不同的表引擎。示例有 `StorageMergeTree`、`StorageMemory` 等。这些类的实例仅仅是表。 +`IStorage` 接口表示表。该接口的不同实现是不同的表引擎。例如,`StorageMergeTree`、`StorageMemory` 等。这些类的实例只是表。 -`IStorage` 的关键方法是 `read` 和 `write`,以及其他方法如 `alter`、`rename` 和 `drop`。`read` 方法接受以下参数:要从表中读取的列集合、需要考虑的 `AST` 查询和所需的流数量。它返回一个 `Pipe`。 +在 `IStorage` 中的关键方法是 `read` 和 `write`,以及其他方法,如 `alter`、`rename` 和 `drop`。`read` 方法接受以下参数:从表中读取的列集、要考虑的 `AST` 查询以及所需的流数量。它返回一个 `Pipe`。 -在大多数情况下,读取方法仅负责从表中读取指定列,而不负责任何后续的数据处理。所有后续的数据处理都由管道的另一部分处理,超出了 `IStorage` 的责任。 +在大多数情况下,`read` 方法仅负责从表中读取指定列,而不进行任何进一步的数据处理。 +所有后续的数据处理由管道的另一个部分处理,超出了 `IStorage` 的责任。 -但也有显著的例外: +但有一些显著的例外: -- `AST` 查询被传递给 `read` 方法,表引擎可以使用它来推导索引的使用情况,并从表中读取更少的数据。 -- 有时,表引擎可以将数据处理到特定阶段。例如,`StorageDistributed` 可以向远程服务器发送查询,要求它们处理数据到可以合并不同远程服务器数据的阶段,并返回预处理的数据。查询解释器随后完成数据处理。 +- `AST` 查询被传递给 `read` 方法,表引擎可以使用它来推导索引使用情况,并从表中读取更少的数据。 +- 有时,表引擎可以将数据处理到特定阶段。例如,`StorageDistributed` 可以将查询发送到远程服务器,要求它们处理数据到一个阶段,在这个阶段,来自不同远程服务器的数据可以合并,然后返回预处理的数据。查询解释器随后完成数据处理。 -表的 `read` 方法可以返回由多个 `Processors` 组成的 `Pipe`。这些 `Processors` 可以并行地从表中读取数据。然后,您可以将这些处理器与各种其他转换(如表达式计算或过滤)连接,这些转换可以独立计算。 -然后,在其上创建 `QueryPipeline`,并通过 `PipelineExecutor` 执行它。 +表的 `read` 方法可以返回一个由多个 `Processors` 组成的 `Pipe`。这些 `Processors` 可以并行读取表。 +然后,您可以将这些处理器与各种其他转换(如表达式评估或过滤)连接,这些转换可以独立计算。 +然后,在它们的顶部创建一个 `QueryPipeline`,并通过 `PipelineExecutor` 执行它。 -还有 `TableFunction`。这些是返回临时 `IStorage` 对象以便在查询的 `FROM` 子句中使用的函数。 +还有 `TableFunction`。这些是返回临时 `IStorage` 对象的函数,用于查询的 `FROM` 子句。 -想要快速了解如何实现您的表引擎,可以看看一些简单的实例,如 `StorageMemory` 或 `StorageTinyLog`。 +要快速了解如何实现您的表引擎,可以查看一些简单的,例如 `StorageMemory` 或 `StorageTinyLog`。 -> 作为 `read` 方法的结果,`IStorage` 返回 `QueryProcessingStage`——有关查询的哪些部分已经在存储中计算的信息。 +> 作为 `read` 方法的结果,`IStorage` 返回 `QueryProcessingStage` ——有关查询的哪些部分已经在存储中计算的信息。 ## 解析器 {#parsers} -一个手写的递归下降解析器用于解析查询。例如,`ParserSelectQuery` 只是递归调用底层解析器以解析查询的各个部分。解析器创建 `AST`。`AST` 由节点表示,节点是 `IAST` 的实例。 +手写的递归下降解析器解析查询。例如,`ParserSelectQuery` 只是递归地调用查询的不同部分的基础解析器。解析器创建一个 `AST`。`AST` 由节点表示,这些节点是 `IAST` 的实例。 -> 由于历史原因,未使用解析器生成器。 +> 出于历史原因,不使用解析器生成器。 ## 解释器 {#interpreters} -解释器负责从 AST 创建查询执行管道。有简单的解释器,如 `InterpreterExistsQuery` 和 `InterpreterDropQuery`,以及更复杂的 `InterpreterSelectQuery`。 +解释器负责从 AST 创建查询执行管道。有简单的解释器,例如 `InterpreterExistsQuery` 和 `InterpreterDropQuery`,以及更复杂的 `InterpreterSelectQuery`。 -查询执行管道是可以消耗和生成块(具有特定类型的列集合)的处理器的组合。 -处理器通过端口进行通信,可以拥有多个输入端口和多个输出端口。 -更详细的说明可以在 [src/Processors/IProcessor.h](https://github.com/ClickHouse/ClickHouse/blob/master/src/Processors/IProcessor.h) 中找到。 +查询执行管道是能够接受和生成块(具有特定类型的列集)的处理器的组合。 +一个处理器通过端口进行通信,并且可以有多个输入端口和多个输出端口。 +更详细的描述可以在 [src/Processors/IProcessor.h](https://github.com/ClickHouse/ClickHouse/blob/master/src/Processors/IProcessor.h) 中找到。 -例如,解释 `SELECT` 查询的结果是一个“提取型” `QueryPipeline`,它具有一个特殊的输出端口来读取结果集。 -解释 `INSERT` 查询的结果是一个“推送型” `QueryPipeline`,具有一个输入端口以写入插入数据。 -而解释 `INSERT SELECT` 查询的结果是一个“完成型” `QueryPipeline`,没有输入或输出,但同时将数据从 `SELECT` 复制到 `INSERT`。 +例如,解析 `SELECT` 查询的结果是一个“拉取型” `QueryPipeline`,它有一个特殊的输出端口,从中读取结果集。 +`INSERT` 查询的结果是一个“推送型” `QueryPipeline`,它有一个输入端口用于写入插入数据。 +而解析 `INSERT SELECT` 查询的结果是一个“完成型” `QueryPipeline`,它没有输入或输出,但能够同时将数据从 `SELECT` 复制到 `INSERT`。 -`InterpreterSelectQuery` 使用 `ExpressionAnalyzer` 和 `ExpressionActions` 机制进行查询分析和转换。在这里,执行大部分基于规则的查询优化。`ExpressionAnalyzer` 非常混乱,需要重写:各种查询转换和优化应提取到单独的类中,以便实现查询的模块化转换。 +`InterpreterSelectQuery` 使用 `ExpressionAnalyzer` 和 `ExpressionActions` 机制进行查询分析和转换。这是查询的绝大多数基于规则的优化都会进行的地方。`ExpressionAnalyzer` 目前非常混乱,需要重写:各种查询转换和优化应该提取到独立的类中,以便实现模块化查询的转换。 -为了解决解释器中存在的问题,开发了一种新版本的 `InterpreterSelectQueryAnalyzer`。这是 `InterpreterSelectQuery` 的新版本,它不使用 `ExpressionAnalyzer`,并在 `AST` 和 `QueryPipeline` 之间引入名为 `QueryTree` 的额外抽象层。它已完全准备好在生产中使用,但以防万一,可以通过将 `enable_analyzer` 设置为 `false` 来关闭。 +为了解决解释器中存在的问题,开发了新的 `InterpreterSelectQueryAnalyzer`。这是 `InterpreterSelectQuery` 的新版本,它不使用 `ExpressionAnalyzer`,并在 `AST` 和 `QueryPipeline` 之间引入了一层额外的抽象层,称为 `QueryTree`。它已经完全准备好在生产中使用,但为了安全起见,可以通过将 `enable_analyzer` 设置为 `false` 来关闭它。 ## 函数 {#functions} -存在普通函数和聚合函数。有关聚合函数的信息,请参见下一节。 +有普通函数和聚合函数。有关聚合函数,请参阅下一部分。 -普通函数不改变行数——它们的工作就像在处理每一行时是独立的。实际上,函数不是针对单个行调用的,而是对数据块进行的,以实现向量化查询执行。 +普通函数不会改变行数——它们的工作方式就像是独立处理每一行。实际上,函数并不是针对单独的行调用,而是针对数据的 `Block` 调用,以实现向量化查询执行。 -还有一些杂项函数,如 [blockSize](/sql-reference/functions/other-functions#blockSize)、[rowNumberInBlock](/sql-reference/functions/other-functions#rowNumberInBlock) 和 [runningAccumulate](/sql-reference/functions/other-functions#runningaccumulate),它们利用块处理并破坏了行的独立性。 +还有一些杂项函数,例如 [blockSize](/sql-reference/functions/other-functions#blockSize)、[rowNumberInBlock](/sql-reference/functions/other-functions#rowNumberInBlock) 和 [runningAccumulate](/sql-reference/functions/other-functions#runningaccumulate),利用块处理并违反行的独立性。 -ClickHouse 具有强类型,因此没有隐式类型转换。如果函数不支持特定的类型组合,它会抛出异常。但函数可以针对多种不同的类型组合工作(重载)。例如,`plus` 函数(用于实现 `+` 运算符)对任何数字类型组合有效:`UInt8` + `Float32`、`UInt16` + `Int8` 等等。此外,一些可变参数函数可以接受任意数量的参数,例如 `concat` 函数。 +ClickHouse 有强类型,因此没有隐式类型转换。如果函数不支持特定类型的组合,它将引发异常。但函数可以针对许多不同类型的组合(重载)工作。例如,`plus` 函数(用于实现 `+` 运算符)可以对任何组合的数值类型工作:`UInt8` + `Float32`、`UInt16` + `Int8`,等等。同时,一些可变参数函数可以接受任意数量的参数,例如 `concat` 函数。 -实现函数可能稍显不便,因为函数明确调度支持的数据类型和支持的 `IColumns`。例如,`plus` 函数通过对每种数字类型组合及常量或非常量的左右参数实例化 C++ 模板生成代码。 +实现函数可能会略显不便,因为函数会显式地调度受支持的数据类型和受支持的 `IColumns`。例如,`plus` 函数会通过实例化 C++ 模板为每种数值类型组合生成代码,包括恒定或非常量的左/右参数。 -这是实现运行时代码生成以避免模板代码膨胀的绝佳场所。此外,这使得添加融合函数(如融合乘法加法)或在一个循环迭代中进行多次比较成为可能。 +这是实现运行时代码生成以避免模板代码膨胀的绝佳场所。此外,它使得可以添加如融合乘法加或在一次循环迭代中进行多重比较等融合函数。 -由于向量化查询执行,函数不是短路的。例如,如果您写 `WHERE f(x) AND g(y)`,即使 `f(x)` 为零(除了 `f(x)` 为零常量表达式时),也会计算两侧。但是,如果 `f(x)` 条件的选择性很高,并且 `f(x)` 的计算远比 `g(y)` 便宜,则最好实现多遍计算。首先计算 `f(x)`,然后根据结果过滤列,然后仅对较小的、过滤后的数据块计算 `g(y)`。 +由于向量化查询执行,函数不会短路。例如,如果您写 `WHERE f(x) AND g(y)`,即使对于 `f(x)` 为零的行,两个条件都会被计算(除非 `f(x)` 是零常量表达式)。但如果 `f(x)` 条件的选择性很高,而计算 `f(x)` 的成本远低于计算 `g(y)` 的成本,那么最好实现多次计算。首先计算 `f(x)`,然后根据结果筛选列,最后仅针对较小的、经过筛选的数据块计算 `g(y)`。 ## 聚合函数 {#aggregate-functions} -聚合函数是有状态的函数。它们将传递的值累积到某个状态中,并允许您从该状态中获取结果。它们由 `IAggregateFunction` 接口管理。状态可以相当简单(`AggregateFunctionCount` 的状态只是一个单一的 `UInt64` 值),或相当复杂(`AggregateFunctionUniqCombined` 的状态是线性数组、哈希表和 `HyperLogLog` 概率数据结构的组合)。 +聚合函数是有状态的函数。它们将传递的值累积到某种状态中,并允许您从该状态中获取结果。它们由 `IAggregateFunction` 接口管理。状态可以相当简单(`AggregateFunctionCount` 的状态只是一个 `UInt64` 值),也可以相当复杂(`AggregateFunctionUniqCombined` 的状态是一个线性数组、哈希表和 `HyperLogLog` 概率数据结构的组合)。 -状态在内存池 `Arena` 中分配,以处理在执行高基数 `GROUP BY` 查询时的多个状态。状态可以具有非平凡的构造函数和析构函数:例如,复杂的聚合状态可以自行分配额外的内存。创建和销毁状态以及正确传递其所有权和销毁顺序时需要一些注意。 +状态在 `Arena`(内存池)中分配,以处理在执行高基数 `GROUP BY` 查询时的多个状态。状态可以具有非平凡的构造函数和析构函数:例如,复杂的聚合状态可以自我分配额外的内存。创建和销毁状态时需要一些注意,以及正确传递它们的所有权和销毁顺序。 -聚合状态可以进行序列化和反序列化,以便在分布式查询执行期间通过网络传递或在内存不足时写入磁盘。它们甚至可以存储在一个表中,使用 `DataTypeAggregateFunction` 以允许数据的增量聚合。 +聚合状态可以序列化和反序列化,以便在分布式查询执行期间通过网络传递,或者在 RAM 不足的情况下将其写入磁盘。它们甚至可以存储在具有 `DataTypeAggregateFunction` 的表中,以允许数据的增量聚合。 -> 聚合函数状态的序列化数据格式目前没有版本控制。如果聚合状态仅暂时存储,这没有问题。但我们有 `AggregatingMergeTree` 表引擎用于增量聚合,人们已经在生产中使用它。这就是为什么未来在更改任何聚合函数的序列化格式时需要确保向后兼容的原因。 +> 目前聚合函数状态的序列化数据格式未版本化。如果聚合状态仅暂时存储,这没有问题。但我们有 `AggregatingMergeTree` 表引擎用于增量聚合,人们已经在生产中使用它。这就是未来更改任何聚合函数序列化格式时需要向后兼容的原因。 ## 服务器 {#server} 服务器实现了几种不同的接口: -- 一个用于任何外部客户端的 HTTP 接口。 -- 一个用于原生 ClickHouse 客户端和分布式查询执行期间跨服务器通信的 TCP 接口。 +- 针对任何外部客户端的 HTTP 接口。 +- 针对本地 ClickHouse 客户端和在分布式查询执行期间跨服务器通信的 TCP 接口。 - 用于复制的数据传输接口。 -在内部,它只是一个原始的多线程服务器,没有协程或纤维。由于服务器并不是为了处理大量简单查询而设计的,而是为了处理相对较低数量的复杂查询,因此每个查询可以处理大量的数据进行分析。 +在内部,它只是一个原始的多线程服务器,没有协程或纤程。由于服务器并不是为了处理高频率的简单查询而设计的,而是为了处理相对低频的复杂查询,因此每个查询都可以处理大量用于分析的数据。 -服务器使用必要的环境初始化 `Context` 类以进行查询执行:可用数据库、用户和访问权限、设置、集群、进程列表、查询日志等的列表。解释器使用该环境。 +服务器用查询执行所需的环境初始化 `Context` 类:可用数据库、用户及访问权限、设置、集群、进程列表、查询日志等列表。解释器使用这个环境。 -我们为服务器的 TCP 协议维护完全的向后和向前兼容性:旧客户端可以与新服务器通信,新的客户端可以与旧服务器通信。但我们不想永远维护它,并且在大约一年后,我们将停止支持旧版本。 +我们为服务器 TCP 协议维护完整的向前和向后兼容性:旧客户端可以与新服务器通信,新客户端可以与旧服务器通信。但是,我们不想永远维护它,并且在大约一年后将删除对旧版本的支持。 :::note -对于大多数外部应用程序,我们建议使用 HTTP 接口,因为它简单且易于使用。TCP 协议与内部数据结构联系更紧密:它使用内部格式来传递数据块,并使用自定义格式来压缩数据。我们还没有为该协议发布 C 库,因为它需要链接大部分 ClickHouse 代码库,这并不现实。 +对于大多数外部应用,我们建议使用 HTTP 接口,因为它简单且易于使用。TCP 协议与内部数据结构更紧密关联:它使用内部格式传递数据块,并使用自定义框架处理压缩数据。我们没有发布该协议的 C 库,因为它需要链接 ClickHouse 大部分代码库,这并不实际。 ::: ## 配置 {#configuration} -ClickHouse Server 基于 POCO C++ 库,并使用 `Poco::Util::AbstractConfiguration` 表示其配置。配置由 `Poco::Util::ServerApplication` 类持有,该类继承自 `DaemonBase` 类,而后者又继承自实现 clickhouse-server 的 `DB::Server` 类。因此,可以通过 `ServerApplication::config()` 方法访问配置。 +ClickHouse 服务器基于 POCO C++ 库,并使用 `Poco::Util::AbstractConfiguration` 来表示其配置。配置由 `Poco::Util::ServerApplication` 类持有,该类继承自 `DaemonBase` 类,而后者又由实现 clickhouse-server 的 `DB::Server` 类继承。因此,可以通过 `ServerApplication::config()` 方法访问配置。 -配置从多个文件(以 XML 或 YAML 格式)读取,并由 `ConfigProcessor` 类合并为单个 `AbstractConfiguration`。配置在服务器启动时加载。如果其中一个配置文件被更新、删除或添加,则可以稍后重新加载。`ConfigReloader` 类负责定期监控这些更改和重新加载程序。`SYSTEM RELOAD CONFIG` 查询也会触发配置重新加载。 +配置从多个文件(XML 或 YAML 格式)读取,并由 `ConfigProcessor` 类合并为单个 `AbstractConfiguration`。配置在服务器启动时加载,如果其中一个配置文件被更新、删除或添加,可以稍后重新加载。`ConfigReloader` 类负责定期监视这些更改以及重新加载过程。`SYSTEM RELOAD CONFIG` 查询也会触发配置的重新加载。 -对于除了 `Server` 以外的查询和子系统,可以使用 `Context::getConfigRef()` 方法访问配置。每个能够在不重新启动服务器的情况下重新加载其配置的子系统应在 `Server::main()` 方法中的重新加载回调中注册自己。请注意,如果新配置有错误,大多数子系统将忽略新配置,记录警告消息,并继续使用先前加载的配置。由于 `AbstractConfiguration` 的特性,无法传递对特定部分的引用,因此通常使用 `String config_prefix`。 +对于查询和其他子系统,`Server` 配置可以通过 `Context::getConfigRef()` 方法访问。每个能够在不重启服务器的情况下重新加载其配置的子系统应该在 `Server::main()` 方法中注册自身的重新加载回调。请注意,如果较新的配置存在错误,大多数子系统将忽略新配置,记录警告信息并继续使用之前加载的配置。由于 `AbstractConfiguration` 的性质,无法传递对特定部分的引用,因此通常使用 `String config_prefix`。 ## 线程和作业 {#threads-and-jobs} -为了执行查询和进行辅助活动,ClickHouse 从线程池中分配线程以避免频繁创建和销毁线程。根据作业的目的和结构,有几个线程池被选中: - - * 服务器池用于处理传入的客户端会话。 - * 全局线程池用于通用作业、后台活动和独立线程。 - * IO 线程池用于主要在某些 IO 上被阻塞且不是 CPU 密集型的作业。 - * 背景池用于定期任务。 - * 可抢先执行的任务池,这些任务可以被分为多个步骤。 +为了执行查询和进行附加活动,ClickHouse 从线程池中分配线程,以避免频繁的线程创建和销毁。根据作业的目的和结构,有几个线程池可供选择: +* 服务器池用于传入的客户端会话。 +* 全局线程池用于一般目的作业、后台活动和独立线程。 +* I/O 线程池用于大部分被阻塞在某些 I/O 上且不是 CPU 密集型的作业。 +* 背景池用于定期任务。 +* 预抢占任务的池,这些任务可以拆分成步骤。 -服务器池是 `Server::main()` 方法中定义的 `Poco::ThreadPool` 类实例。它最多可以拥有 `max_connection` 个线程。每个线程专注于一个单独的活动连接。 +服务器池是 `Poco::ThreadPool` 类实例,在 `Server::main()` 方法中定义。它最多可以拥有 `max_connection` 个线程。每个线程专注于一个活跃的连接。 -全局线程池是 `GlobalThreadPool` 单例类。要从中分配线程,使用 `ThreadFromGlobalPool`。它具有与 `std::thread` 相似的接口,但从全局池中提取线程并执行所有必要的初始化。它使用以下设置进行配置: +全局线程池是 `GlobalThreadPool` 单例类。要从中分配线程,请使用 `ThreadFromGlobalPool`。它的接口类似于 `std::thread`,但从全局池中获取线程并进行所有必要的初始化。它配置了以下设置: +* `max_thread_pool_size` - 池中线程数的限制。 +* `max_thread_pool_free_size` - 等待新作业的空闲线程数的限制。 +* `thread_pool_queue_size` - 已调度作业数的限制。 - * `max_thread_pool_size` - 池中线程数量限制。 - * `max_thread_pool_free_size` - 等待新作业的空闲线程数限制。 - * `thread_pool_queue_size` - 已调度作业数量限制。 +全局池是通用的,下面描述的所有池都是在此基础上实现的。这可以被视为池的层次结构。任何特定的池都从全局池中获取其线程,使用 `ThreadPool` 类。因此,任何特定池的主要目的是对同时作业数量施加限制并进行作业调度。如果调度的作业数量超过池中的线程数,`ThreadPool` 将按优先级将作业积累在队列中。每个作业都有一个整数优先级。默认优先级为零。所有优先级值较高的作业在任何优先级值较低的作业之前启动。但在已执行的作业之间没有区别,因此优先级仅在池过载时才重要。 -全局池是通用的,下面描述的所有池都是在其上实现的。这可以被视为池的层次结构。任何专门的池都从全局池中获取其线程,使用 `ThreadPool` 类。因此,任何专门的池的主要目的都是对同时作业的数量施加限制并进行作业调度。如果调度的作业数量超过池中的线程数量,`ThreadPool` 将优先级队列中的作业进行累积。每个作业都有一个整数优先级。默认优先级为零。所有优先级值更高的作业在任何低优先级作业之前启动。但正在执行的作业之间没有区别,因此优先级仅在池过载时才重要。 +I/O 线程池被实现为一个普通的 `ThreadPool`,可以通过 `IOThreadPool::get()` 方法访问。它的配置方式与全局池相同,使用 `max_io_thread_pool_size`、`max_io_thread_pool_free_size` 和 `io_thread_pool_queue_size` 设置。I/O 线程池的主要目的在于避免由于 I/O 作业而耗尽全局池,这可能会阻止查询完全利用 CPU。备份到 S3 进行大量 I/O 操作,为了避免对交互式查询造成影响,专门配置了一个 `BackupsIOThreadPool`,使用 `max_backups_io_thread_pool_size`、`max_backups_io_thread_pool_free_size` 和 `backups_io_thread_pool_queue_size` 设置。 -IO 线程池作为简单的 `ThreadPool` 实现,可通过 `IOThreadPool::get()` 方法访问。它的配置与全局池相同,使用 `max_io_thread_pool_size`、`max_io_thread_pool_free_size` 和 `io_thread_pool_queue_size` 设置。IO 线程池的主要目的是避免通过 IO 作业耗尽全局池,这会导致查询无法充分利用 CPU。备份到 S3 会执行大量 IO 操作,为避免对交互式查询造成影响,有一个单独的 `BackupsIOThreadPool`,它使用 `max_backups_io_thread_pool_size`、`max_backups_io_thread_pool_free_size` 和 `backups_io_thread_pool_queue_size` 设置进行配置。 +对于定期任务执行,存在 `BackgroundSchedulePool` 类。您可以使用 `BackgroundSchedulePool::TaskHolder` 对象注册任务,而池确保没有任务同时运行两次。它还允许您将任务的执行推迟到未来的特定时刻或暂时停用任务。全局 `Context` 提供了几个不同目的的此类实例。对于一般目的的任务,使用 `Context::getSchedulePool()`。 -对于周期任务执行,存在 `BackgroundSchedulePool` 类。您可以使用 `BackgroundSchedulePool::TaskHolder` 对象注册任务,池确保不会同时为同一任务运行两个作业。它还允许您将任务执行推迟到将来的特定时刻或临时停用任务。全局 `Context` 提供了此类多个实例以用于不同目的。对于通用任务,使用 `Context::getSchedulePool()`。 +还有专门用于预抢占任务的线程池。这种 `IExecutableTask` 任务可以拆分为有序的作业序列,称为步骤。为了以允许短任务优先于长任务的方式调度这些任务,使用 `MergeTreeBackgroundExecutor`。顾名思义,它用于后台与 MergeTree 相关的操作,例如合并、突变、获取和移动。使用 `Context::getCommonExecutor()` 和其他类似方法可以获取池实例。 -还有专门的线程池用于可抢先执行的任务。这样的 `IExecutableTask` 任务可以被分为有序的作业序列,称为步骤。为了以允许短任务优先于长任务的方式调度这些任务,使用 `MergeTreeBackgroundExecutor`。顾名思义,它用于与背景 MergeTree 相关的操作,如合并、变异、提取和移动。池实例可以通过 `Context::getCommonExecutor()` 和其他类似方法获得。 +无论使用哪个池来完成作业,开始时都会为该作业创建 `ThreadStatus` 实例。它封装了所有每线程的信息:线程 id、查询 id、性能计数器、资源消耗和许多其他有用的数据。作业可以通过 `CurrentThread::get()` 调用通过线程本地指针访问,因此我们不需要将其传递给每个函数。 -无论用于作业的池是什么,启动时都会为此作业创建 `ThreadStatus` 实例。它封装了所有每线程信息:线程 ID、查询 ID、性能计数器、资源消耗以及其他许多有用数据。作业可以通过 `CurrentThread::get()` 调用通过线程本地指针访问它,因此我们不需要将其传递给每个函数。 - -如果线程与查询执行相关,则附加到 `ThreadStatus` 的最重要的信息是查询上下文 `ContextPtr`。每个查询在服务器池中都有其主线程。主线程通过持有 `ThreadStatus::QueryScope query_scope(query_context)` 对象进行附加。主线程还创建一个线程组,由 `ThreadGroupStatus` 对象表示。在此查询执行期间分配的每个附加线程都通过 `CurrentThread::attachTo(thread_group)` 调用附加到其线程组。线程组用于聚合事件计数器和跟踪所有专用于单个任务的线程的内存消耗(有关更多信息,请参见 `MemoryTracker` 和 `ProfileEvents::Counters` 类)。 +如果线程与查询执行相关联,那么附加到 `ThreadStatus` 的最重要的内容是查询上下文 `ContextPtr`。每个查询在服务器池中都有其主线程。主线程通过持有 `ThreadStatus::QueryScope query_scope(query_context)` 对象进行关联。主线程还创建一个表示为 `ThreadGroupStatus` 对象的线程组。在此查询执行过程中分配的每个额外线程都通过 `CurrentThread::attachTo(thread_group)` 调用附加到其线程组。线程组用于聚合事件计数器并追踪所有专用于单个任务的线程的内存消耗(有关更多信息,请参阅 `MemoryTracker` 和 `ProfileEvents::Counters` 类)。 ## 并发控制 {#concurrency-control} -可以并行化的查询使用 `max_threads` 设置来限制自己。该设置的默认值经过选择,以便单个查询能够以最佳方式利用所有 CPU 核心。但如果有多个并发查询,并且每个查询都使用默认的 `max_threads` 设置值呢?那么查询将共享 CPU 资源。操作系统将通过不断地切换线程来确保公平,这会引入一定的性能惩罚。`ConcurrencyControl` 有助于处理这一惩罚,避免分配过多的线程。配置设置 `concurrent_threads_soft_limit_num` 用于限制在施加某种 CPU 压力之前可以分配多少个并发线程。 +可以并行化的查询使用 `max_threads` 设置来限制自身。此设置的默认值选择方式使得单个查询能够最好地利用所有 CPU 核心。但是,如果存在多个并发查询,而每个查询都使用默认的 `max_threads` 设置值怎么办?那么查询将共享 CPU 资源。操作系统将确保公平性,通过不断切换线程,这会引入一些性能惩罚。`ConcurrencyControl` 有助于处理这种惩罚,避免分配大量线程。配置设置 `concurrent_threads_soft_limit_num` 用于限制在施加某种 CPU 压力之前,可以分配多少并发线程。 -引入了 CPU `slot` 的概念。槽是一个并发的单位:要运行线程,查询必须事先获取槽并在线程停止时释放它。槽的数量在服务器中是全局限制的。如果总需求超出总槽数量,则会有多个并发查询竞争 CPU 槽。`ConcurrencyControl` 负责通过公平地进行 CPU 槽调度来解决这一竞争。 +引入了 CPU `slot` 的概念。插槽是并发的单位:要运行线程,查询必须提前获取一个插槽并在线程停止时释放它。插槽的数量在服务器中是全局限制的。多个并发查询如果整体需求超过插槽总数,则相互竞争 CPU 插槽。`ConcurrencyControl` 负责通过以公平的方式进行 CPU 插槽调度来解决这种竞争。 -每个槽都可以被视为一个独立的状态机,具有以下状态: - * `free`:槽可供任何查询分配。 - * `granted`:槽被特定查询 `allocated`,但尚未被任何线程获取。 - * `acquired`:槽被特定查询 `allocated` 并被线程获取。 +每个插槽可以视为具有以下状态的独立状态机: +* `free`:插槽可供任何查询分配。 +* `granted`:插槽被特定查询“分配”,但尚未被任何线程获取。 +* `acquired`:插槽被特定查询“分配”并被某线程获取。 -注意,`allocated` 槽可以处于两种不同的状态:`granted` 和 `acquired`。前者是一个过渡状态,实际上应该是短暂的(从槽被分配到查询之时开始,到该查询的任何线程运行扩展程序的时刻为止)。 +请注意,`allocated` 插槽可以处于两种不同的状态:`granted` 和 `acquired`。前者是一个过渡状态,实际上应该是短暂的(从插槽分配给查询的瞬间到该查询的任何线程运行扩展程序的时刻)。 ```mermaid stateDiagram-v2 @@ -229,47 +231,48 @@ stateDiagram-v2 allocated --> free: release ``` -`ConcurrencyControl` 的 API 由以下函数组成: -1. 为查询创建资源分配:`auto slots = ConcurrencyControl::instance().allocate(1, max_threads);`。它将分配至少1个,最多 `max_threads` 个槽。注意,第一个槽会立即授予,但其余槽可能稍后才会授予。因此,限制是软限制,因为每个查询将至少获得一个线程。 -2. 对于每个线程,必须从分配中获取槽:`while (auto slot = slots->tryAcquire()) spawnThread([slot = std::move(slot)] { ... });`。 -3. 更新槽的总数:`ConcurrencyControl::setMaxConcurrency(concurrent_threads_soft_limit_num)`。可在运行时完成,无需重新启动服务器。 +`ConcurrencyControl` 的 API 包含以下功能: +1. 为查询创建资源分配:`auto slots = ConcurrencyControl::instance().allocate(1, max_threads);`。它将至少分配 1 而至多 `max_threads` 插槽。请注意,第一个插槽立即获得批准,但其余插槽可能稍后获得批准。因此限制是软性限制,因为每个查询将至少获得一个线程。 +2. 对于每个线程,必须从分配中获取一个插槽:`while (auto slot = slots->tryAcquire()) spawnThread([slot = std::move(slot)] { ... });`。 +3. 更新插槽的总数量:`ConcurrencyControl::setMaxConcurrency(concurrent_threads_soft_limit_num)`。可以在运行时进行,无需重新启动服务器。 -该 API 允许查询以至少一个线程启动(在存在 CPU 压力的情况下),并随后扩展到 `max_threads`。 +此 API 允许查询至少以一个线程开始(在 CPU 压力存在时),然后再扩展到 `max_threads`。 ## 分布式查询执行 {#distributed-query-execution} -集群设置中的服务器大多数是独立的。您可以在集群中的一台或所有服务器上创建一个 `Distributed` 表。`Distributed` 表本身不存储数据——它只提供对多个节点上所有本地表的“视图”。当您从一个 `Distributed` 表中选择数据时,它将重写该查询,根据负载平衡设置选择远程节点,并将查询发送给它们。`Distributed` 表请求远程服务器处理查询,直到不同服务器的中间结果可以合并为止。然后,它接收中间结果并将其合并。分布式表尝试将尽可能多的工作分配给远程服务器,并且不会通过网络发送过多的中间数据。 +集群设置中的服务器大多是独立的。您可以在集群中的一个或所有服务器上创建一个 `Distributed` 表。`Distributed` 表本身不存储数据——它仅提供对集群多个节点上所有本地表的“视图”。当您从 `Distributed` 表中 SELECT 时,它会重写该查询,根据负载均衡设置选择远程节点,并将查询发送给它们。`Distributed` 表请求远程服务器处理查询,直到中间结果来自不同服务器可以合并的阶段。然后它接收中间结果并将其合并。分布式表尽力将尽可能多的工作分配给远程服务器,并且不会在网络上发送过多的中间数据。 + +当您在 IN 或 JOIN 子句中有子查询,并且每个子查询都使用 `Distributed` 表时,事情变得更复杂。我们有不同的策略来执行这些查询。 -当您在 IN 或 JOIN 子句中有子查询,而每个子查询都使用 `Distributed` 表时,情况变得更加复杂。我们对这些查询的执行有不同的策略。 +分布式查询执行没有全局查询计划。每个节点都有其本地查询计划,负责其部分工作。我们只有简单的单遍分布式查询执行:我们将查询发送给远程节点,然后合并结果。但对于具有高基数 `GROUP BY` 或大量 JOIN 的临时数据的复杂查询,这不可行。在这种情况下,我们需要在服务器之间“洗牌”数据,这需要额外的协调。ClickHouse 不支持这种类型的查询执行,我们需要对此进行改进。 -分布式查询执行没有全局查询计划。每个节点都有自己的本地查询计划,处理其工作的部分。我们仅有简单的一次性分布式查询执行:我们向远程节点发送查询,然后合并结果。但对于具有高基数的 `GROUP BY` 或大的临时数据量的 JOIN 的复杂查询,这并不可行。在这种情况下,我们需要在服务器之间“重新洗牌”数据,这需要额外的协调。ClickHouse 不支持这种查询执行,我们需要对此进行改进。 -## Merge Tree {#merge-tree} +## Merge tree {#merge-tree} -`MergeTree` 是一系列支持主键索引的存储引擎。主键可以是任意列或表达式的元组。`MergeTree` 表中的数据存储在“部分”中。每个部分按照主键顺序存储数据,因此数据按主键元组的字典序排列。所有表列存储在这些部分的单独 `column.bin` 文件中。这些文件由压缩块组成。每个块通常包含从 64 KB 到 1 MB 的未压缩数据,具体取决于平均值大小。块由按照顺序连续放置的列值组成。每列的列值顺序相同(主键定义了顺序),因此当您在多个列中迭代时,您将获得对应行的值。 +`MergeTree` 是一类支持通过主键索引的存储引擎。主键可以是任意的列或表达式的元组。`MergeTree` 表中的数据存储在 "parts" 中。每个部分按主键顺序存储数据,因此数据按主键元组的字典序排列。所有表列都存储在这些部分中的单独 `column.bin` 文件中。这些文件由压缩块组成。每个块通常为 64 KB 到 1 MB 的未压缩数据,具体取决于平均值的大小。这些块由紧密排列的列值组成。每列的列值按相同的顺序排列(主键定义了顺序),因此当你按多个列迭代时,可以获得对应行的值。 -主键本身是“稀疏的”。它并不指向每一行,而仅指向某些数据范围。一个单独的 `primary.idx` 文件记录每第 N 行的主键值,其中 N 被称为 `index_granularity`(通常,N = 8192)。此外,对于每列,我们还提供包含“标记”的 `column.mrk` 文件,这些标记是数据文件中每第 N 行的偏移量。每个标记是一个对:文件中压缩块起始位置的偏移量,以及在解压块中到数据起始位置的偏移量。通常,压缩块由标记对齐,并且在解压块中的偏移量为零。`primary.idx` 的数据始终驻留在内存中,而 `column.mrk` 文件的数据则被缓存。 +主键本身是 "稀疏" 的。它并不指向每一行,而仅指向一些数据范围。一个单独的 `primary.idx` 文件存储每 N 行的主键值,其中 N 被称为 `index_granularity`(通常为 N = 8192)。另外,对于每一列,我们有 `column.mrk` 文件,其中存储了 "marks",这些是数据文件中每 N 行的偏移量。每个标记都是一对:文件中压缩块开始的偏移位置,以及解压缩块中数据开始的偏移位置。通常,压缩块根据标记对齐,而解压缩块中的偏移为零。`primary.idx` 的数据始终驻留在内存中,`column.mrk` 文件的数据则被缓存。 -当我们打算从 `MergeTree` 的某个部分读取数据时,我们查看 `primary.idx` 数据并定位可能包含请求数据的范围,然后查看 `column.mrk` 数据并计算从何处开始读取这些范围。由于稀疏性,可能会读取多余的数据。ClickHouse 不适合高负载的简单点查询,因为每个键必须读取整个范围的 `index_granularity` 行,并且每列的整个压缩块必须被解压。我们之所以使索引稀疏,是因为我们必须能够在单个服务器上维护数万亿行,没有明显的内存消耗。此外,由于主键是稀疏的,它不是唯一的:在 INSERT 时无法检查表中键的存在。您可以在表中有许多具有相同键的行。 +当我们想从 `MergeTree` 的某个部分读取数据时,我们查看 `primary.idx` 数据并定位可能包含请求数据的范围,然后查看 `column.mrk` 数据并计算从哪些范围开始读取的偏移量。由于稀疏性,可能会读取额外的数据。ClickHouse 并不适合高负载的简单点查询,因为每个键都必须读取整个 `index_granularity` 行的范围,并且每列的整个压缩块必须解压缩。我们使索引稀疏是因为必须能够在单台服务器上维护数万亿行,而不会对索引产生显著的内存消耗。此外,由于主键是稀疏的,它并不唯一:在 INSERT 时无法检查表中键的存在。表中可以有多行相同的键。 -当您将一批数据 `INSERT` 到 `MergeTree` 中时,这批数据会按照主键顺序排序并形成一个新部分。后台线程会定期选择某些部分并将它们合并成一个排序部分,以保持部分数量相对较低。这就是它被称为 `MergeTree` 的原因。当然,合并会导致“写放大”。所有部分都是不可变的:它们只创建和删除,而不修改。当执行 SELECT 时,它会保留表的快照(一个部分集合)。合并后,我们也会保留旧部分一段时间,以便在故障后更容易进行恢复,因此如果我们发现某个合并部分可能损坏,我们可以用其源部分替换它。 +当你 `INSERT` 一堆数据到 `MergeTree` 中时,这一堆数据会按主键顺序排序并形成一个新的部分。后台线程会定期选择一些部分并将它们合并成一个已排序的部分,以保持部分的数量相对较低。这就是它被称为 `MergeTree` 的原因。当然,合并会导致 "写放大"。所有部分都是不可变的:它们只会被创建和删除,而不会被修改。当执行 SELECT 时,它持有该表的快照(部分集合)。在合并后,我们还会保留旧部分一段时间,以便在故障后更容易恢复,因此如果我们发现某个合并的部分可能损坏,我们可以用其源部分替换它。 -`MergeTree` 不是 LSM 树,因为它不包含 MEMTABLE 和 LOG:插入的数据直接写入文件系统。这种行为使 MergeTree 更加适合批量插入数据。因此,频繁插入少量行并不理想。例如,每秒几行是可以的,但每秒进行一千次则不适用于 MergeTree。然而,对于小的插入,有一种异步插入模式可以克服这一限制。我们这样做是为了简单起见,因为我们在应用程序中已经批量插入数据。 +`MergeTree` 不是 LSM 树,因为它不包含 MEMTABLE 和 LOG:插入的数据直接写入文件系统。这种行为使 MergeTree 更适合批量插入数据。因此,频繁插入少量行并不适合 MergeTree。例如,每秒插入几行是可以的,但每秒插入一千次对 MergeTree 来说并不理想。然而,对于小插入,有一种异步插入模式来克服这个限制。我们这样做是为了简单起见,而且因为我们的应用程序中已经在批量插入数据。 -有些 MergeTree 引擎在后台合并期间进行额外工作。例如 `CollapsingMergeTree` 和 `AggregatingMergeTree`。这可以被视为对更新的特殊支持。请记住,这些并不是真正的更新,因为用户通常无法控制后台合并执行的时间,而 `MergeTree` 表中的数据几乎总是存储在不止一个部分中,而不是完全合并的形式。 +有些 MergeTree 引擎在后台合并时会执行额外的工作。例如 `CollapsingMergeTree` 和 `AggregatingMergeTree`。这可以视为对更新的特殊支持。请记住,这并不是真正的更新,因为用户通常无法控制后台合并执行的时间,而 `MergeTree` 表中的数据几乎总是存储在多个部分中,而不是完全合并的形式。 ## Replication {#replication} -在 ClickHouse 中,复制可以针对每个表进行配置。您可以在同一服务器上拥有一些复制表和一些非复制表。您也可以以不同方式复制表,例如,一个表具有双重复制而另一个表具有三重复制。 +ClickHouse 中的复制可以按表配置。你可以在同一服务器上有一些复制表和一些非复制表。你还可以以不同的方式复制表,例如,一个表具有两因素复制,另一个表具有三因素复制。 -复制在 `ReplicatedMergeTree` 存储引擎中实现。`ZooKeeper` 中的路径作为存储引擎的参数指定。所有在 `ZooKeeper` 中具有相同路径的表彼此成为副本:它们同步其数据并保持一致性。副本可以动态添加和删除,只需创建或删除一个表。 +复制是在 `ReplicatedMergeTree` 存储引擎中实现的。在 `ZooKeeper` 中的路径作为存储引擎的参数指定。所有在 `ZooKeeper` 中具有相同路径的表都会成为彼此的副本:它们同步其数据并保持一致性。副本可以通过创建或删除表动态添加或删除。 -复制使用异步多主方案。您可以将数据插入到与 `ZooKeeper` 具有会话的任何副本中,数据会异步复制到所有其他副本。由于 ClickHouse 不支持 UPDATE,复制是无冲突的。由于默认情况下没有插入的多数确认,因此如果一个节点失败,刚插入的数据可能会丢失。可以使用 `insert_quorum` 设置启用插入的多数。 +复制使用异步多主方案。你可以将数据插入任何与 `ZooKeeper` 建立会话的副本中,并且数据会异步复制到所有其他副本。由于 ClickHouse 不支持 UPDATE,因此复制是无冲突的。由于默认情况下没有插入的法定确认,刚插入的数据可能在一个节点失败时丢失。插入法定可以使用 `insert_quorum` 设置启用。 -复制的元数据存储在 ZooKeeper 中。有一个复制日志列出要执行的操作。操作包括:获取部分;合并部分;删除分区,等等。每个副本将复制复制日志到其队列,然后执行队列中的操作。例如,在插入时,会在日志中创建“获取部分”操作,所有副本将下载该部分。合并在副本之间协调,以获得字节相同的结果。所有副本以相同方式合并所有部分。一个领导者首先发起新的合并,并将“合并部分”操作写入日志。多个副本(或全部)可以同时作为领导者。可以使用 `merge_tree` 设置 `replicated_can_become_leader` 来阻止副本成为领导者。领导者负责调度后台合并。 +复制的元数据存储在 ZooKeeper 中。有一个复制日志列出了要执行的操作。操作包括:获取部分;合并部分;丢弃分区等等。每个副本将复制复制日志到其队列中,然后执行队列中的操作。例如,在插入时,日志中会创建 "获取部分" 操作,然后每个副本下载该部分。合并在副本之间协调,以获得字节相同的结果。所有副本的所有部分以相同的方式合并。一个领导者首先发起新的合并,并将 "合并部分" 操作写入日志。多个副本(或所有副本)可以同时成为领导者。可以使用 `merge_tree` 设置 `replicated_can_become_leader` 来防止副本成为领导者。领导者负责安排后台合并。 -复制是物理的:仅压缩部分在节点之间传输,而不是查询。合并在每个副本上独立处理,以降低网络成本,避免网络放大。仅在存在显著复制延迟的情况下,才通过网络发送大型合并部分。 +复制是物理的:节点之间只传输压缩部分,而不是查询。合并通常在每个副本上独立处理,以降低网络成本,避免网络放大。只有在显著的复制滞后情况下,大的合并部分才会通过网络发送。 -此外,每个副本在 ZooKeeper 中存储其状态,作为部分及其校验和的集合。当本地文件系统上的状态与 ZooKeeper 中的参考状态发生偏差时,该副本通过从其他副本下载缺失和损坏的部分来恢复其一致性。当本地文件系统中存在意外或损坏的数据时,ClickHouse 不会删除它,而是将其移动到单独的目录中并忘记它。 +此外,每个副本在 ZooKeeper 中存储其状态作为部分的集合及其校验和。当本地文件系统上的状态与 ZooKeeper 中的参考状态不一致时,副本通过从其他副本下载缺失和损坏的部分来恢复其一致性。当本地文件系统中存在意外或损坏的数据时,ClickHouse 不会删除它,而是将其移动到单独的目录并忘记它。 :::note -ClickHouse 集群由独立的分片组成,每个分片由副本组成。集群是 **非弹性的**,因此在添加新分片后,数据不会在分片之间自动重新平衡。相反,集群负载被假定为不均匀。这种实现让您拥有更多的控制权,适合相对较小的集群,如几十个节点。但对于我们在生产中使用的数百个节点的集群,这种方法就成了一个显著的缺点。我们应该实现一个跨越集群的表引擎,具有动态复制区域,可以在各个集群之间自动拆分和平衡。 +ClickHouse 集群由独立的分片组成,每个分片由副本组成。集群是 **非弹性的**,因此在添加新分片后,数据不会在分片之间自动重新平衡。相反,集群负载应该调整为不均匀。这种实现让你拥有更多的控制权,并且对于相对较小的集群(如数十个节点)是可以接受的。但对于我们在生产中使用的数百个节点的集群,这种方法就变成了一个显著的缺点。我们应该实现一种跨集群的表引擎,具有动态复制区域,能够在集群之间自动拆分和均衡。 ::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/development/architecture.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/development/architecture.md.hash index 7b047e0d491..e853a1af127 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/development/architecture.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/development/architecture.md.hash @@ -1 +1 @@ -72393d0a2cdfc8f0 +a67fe373b09536e0 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/development/build-cross-arm.md b/i18n/zh/docusaurus-plugin-content-docs/current/development/build-cross-arm.md index 124a24832f1..6cdcf1963d3 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/development/build-cross-arm.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/development/build-cross-arm.md @@ -1,14 +1,15 @@ --- -'description': '为AARCH64架构从源代码构建ClickHouse的指南' -'sidebar_label': '在Linux上为AARCH64构建' +'description': '为 AARCH64 架构从源代码构建 ClickHouse 的指南' +'sidebar_label': '在 Linux 上为 AARCH64 构建' 'sidebar_position': 25 'slug': '/development/build-cross-arm' -'title': '如何在Linux上为AARCH64构建ClickHouse' +'title': '如何在 Linux 上为 AARCH64 构建 ClickHouse' +'doc_type': 'guide' --- -# 如何在 Linux 上为 AARCH64 构建 ClickHouse +# 如何在Linux上为AARCH64构建ClickHouse -在 Aarch64 机器上构建 ClickHouse 不需要特殊步骤。 +在Aarch64机器上构建ClickHouse不需要特别的步骤。 -要在 x86 Linux 机器上交叉编译 ClickHouse 为 AArch64,请将以下标志传递给 `cmake`: `-DCMAKE_TOOLCHAIN_FILE=cmake/linux/toolchain-aarch64.cmake` +要在x86 Linux机器上为AArch64进行交叉编译ClickHouse,请将以下标志传递给 `cmake`: `-DCMAKE_TOOLCHAIN_FILE=cmake/linux/toolchain-aarch64.cmake` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/development/build-cross-arm.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/development/build-cross-arm.md.hash index 8e6547343e2..e1a12f88ae4 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/development/build-cross-arm.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/development/build-cross-arm.md.hash @@ -1 +1 @@ -ca9e49d837a59d57 +cc21151245d59a5b diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/development/build-cross-loongarch.md b/i18n/zh/docusaurus-plugin-content-docs/current/development/build-cross-loongarch.md index ba847c21dc2..bd436a0c171 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/development/build-cross-loongarch.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/development/build-cross-loongarch.md @@ -1,15 +1,16 @@ --- -'description': '为 LoongArch64 架构从源代码构建 ClickHouse 的指南' -'sidebar_label': '在 Linux 上为 LoongArch64 构建' +'description': '为LoongArch64架构构建ClickHouse源代码的指南' +'sidebar_label': '在Linux上为LoongArch64构建' 'sidebar_position': 35 'slug': '/development/build-cross-loongarch' -'title': '在 Linux 上为 LoongArch64 构建' +'title': '在Linux上为LoongArch64构建' +'doc_type': 'guide' --- -# 在 LoongArch64 上构建 +# 在 LoongArch64 上构建 Linux -ClickHouse 对 LoongArch64 提供实验性支持 +ClickHouse 对 LoongArch64 提供了实验支持 ## 构建 ClickHouse {#build-clickhouse} @@ -22,4 +23,4 @@ CC=clang-19 CXX=clang++-19 cmake . -Bbuild-loongarch64 -G Ninja -DCMAKE_TOOLCHAI ninja -C build-loongarch64 ``` -生成的二进制文件仅在具有 LoongArch64 CPU 架构的 Linux 上运行。 +生成的二进制文件仅在使用 LoongArch64 CPU 架构的 Linux 上运行。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/development/build-cross-loongarch.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/development/build-cross-loongarch.md.hash index 500bcb15d0e..72baeb39367 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/development/build-cross-loongarch.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/development/build-cross-loongarch.md.hash @@ -1 +1 @@ -210904acfc2ffdf4 +b7514c6c229e156c diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/development/build-cross-osx.md b/i18n/zh/docusaurus-plugin-content-docs/current/development/build-cross-osx.md index 0d894e2d542..b58a5d45b6b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/development/build-cross-osx.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/development/build-cross-osx.md @@ -1,27 +1,28 @@ --- -'description': '在 Linux 环境中为 macOS 系统交叉编译 ClickHouse 的指南' -'sidebar_label': '在 Linux 上构建 macOS' +'description': '在 Linux 系统上为 macOS 系统交叉编译 ClickHouse 的指南' +'sidebar_label': '在 Linux 上为 macOS 创建' 'sidebar_position': 20 'slug': '/development/build-cross-osx' -'title': '在 Linux 上构建 macOS' +'title': '在 Linux 上为 macOS 创建' +'doc_type': 'guide' --- # 如何在 Linux 上为 macOS 构建 ClickHouse -这是针对您拥有一台 Linux 机器并希望使用它来构建将在 OS X 上运行的 `clickhouse` 二进制文件的情况。 -主要用例是在 Linux 机器上运行的持续集成检查。 -如果您想直接在 macOS 上构建 ClickHouse,请按照 [原生构建说明](../development/build-osx.md) 进行操作。 +这是为了在你拥有一台 Linux 机器并希望使用它来构建将在 OS X 上运行的 `clickhouse` 二进制文件的情况。 +主要的使用场景是运行在 Linux 机器上的持续集成检查。 +如果你想直接在 macOS 上构建 ClickHouse,请查看 [本地构建说明](../development/build-osx.md)。 -针对 macOS 的交叉构建基于 [构建说明](../development/build.md),请先遵循它们。 +针对 macOS 的交叉构建是基于 [构建说明](../development/build.md),请首先遵循这些说明。 -以下部分提供了为 `x86_64` macOS 构建 ClickHouse 的详细步骤。 -如果您的目标是 ARM 架构,只需将所有 `x86_64` 的出现替换为 `aarch64`。 -例如,在整个步骤中,将 `x86_64-apple-darwin` 替换为 `aarch64-apple-darwin`。 +以下部分提供了针对 `x86_64` macOS 构建 ClickHouse 的步骤。 +如果你的目标是 ARM 架构,只需将所有 `x86_64` 的出现替换为 `aarch64`。 +例如,步骤中将 `x86_64-apple-darwin` 替换为 `aarch64-apple-darwin`。 ## 安装交叉编译工具集 {#install-cross-compilation-toolset} -让我们记住我们安装 `cctools` 的路径为 `${CCTOOLS}` +让我们记住安装 `cctools` 的路径为 `${CCTOOLS}` ```bash mkdir ~/cctools @@ -59,4 +60,4 @@ CC=clang-19 CXX=clang++-19 cmake -DCMAKE_AR:FILEPATH=${CCTOOLS}/bin/x86_64-apple ninja ``` -生成的二进制文件将具有 Mach-O 可执行格式,并且无法在 Linux 上运行。 +生成的二进制文件将具有 Mach-O 可执行格式,无法在 Linux 上运行。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/development/build-cross-osx.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/development/build-cross-osx.md.hash index 2a59109b7f7..521e3d40559 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/development/build-cross-osx.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/development/build-cross-osx.md.hash @@ -1 +1 @@ -9104e2ea4f4c202b +d82c8432d36ad182 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/development/build-cross-riscv.md b/i18n/zh/docusaurus-plugin-content-docs/current/development/build-cross-riscv.md index 852d8b9b1c7..8b76344b38a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/development/build-cross-riscv.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/development/build-cross-riscv.md @@ -1,15 +1,16 @@ --- -'description': '用于为RISC-V 64架构从源代码构建ClickHouse的指南' +'description': '针对RISC-V 64架构从源代码构建ClickHouse的指南' 'sidebar_label': '在Linux上为RISC-V 64构建' 'sidebar_position': 30 'slug': '/development/build-cross-riscv' 'title': '如何在Linux上为RISC-V 64构建ClickHouse' +'doc_type': 'guide' --- # 如何在 Linux 上为 RISC-V 64 构建 ClickHouse -ClickHouse 对 RISC-V 提供实验性支持。并非所有功能都可以启用。 +ClickHouse 对 RISC-V 提供了实验性的支持。并非所有功能都可启用。 ## 构建 ClickHouse {#build-clickhouse} @@ -22,4 +23,4 @@ CC=clang-19 CXX=clang++-19 cmake . -Bbuild-riscv64 -G Ninja -DCMAKE_TOOLCHAIN_FI ninja -C build-riscv64 ``` -生成的二进制文件仅能在具有 RISC-V 64 CPU 架构的 Linux 上运行。 +生成的二进制文件仅在具有 RISC-V 64 CPU 架构的 Linux 上运行。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/development/build-cross-riscv.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/development/build-cross-riscv.md.hash index 59b08362f76..23ce56a2dc3 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/development/build-cross-riscv.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/development/build-cross-riscv.md.hash @@ -1 +1 @@ -4e0197713651bc5c +6189f6223eca964a diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/development/build-cross-s390x.md b/i18n/zh/docusaurus-plugin-content-docs/current/development/build-cross-s390x.md index 64aa0ce0584..613f4c67485 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/development/build-cross-s390x.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/development/build-cross-s390x.md @@ -1,39 +1,40 @@ --- -'description': '为 s390x 架构构建 ClickHouse 的源代码指南' +'description': '为 s390x 架构从源代码构建 ClickHouse 的指南' 'sidebar_label': '在 Linux 上为 s390x (zLinux) 构建' 'sidebar_position': 30 'slug': '/development/build-cross-s390x' 'title': '在 Linux 上为 s390x (zLinux) 构建' +'doc_type': 'guide' --- -# 在s390x (zLinux)上构建 +# 在 s390x (zLinux) 上构建 -ClickHouse对s390x有实验支持。 +ClickHouse 对 s390x 提供实验性支持。 -## 为s390x构建ClickHouse {#building-clickhouse-for-s390x} +## 为 s390x 构建 ClickHouse {#building-clickhouse-for-s390x} -s390x有两个与OpenSSL相关的构建选项: -- 默认情况下,OpenSSL在s390x上作为共享库构建。这与其他所有平台不同,在其他平台上,OpenSSL是作为静态库构建的。 -- 要无论如何将OpenSSL构建为静态库,请将 `-DENABLE_OPENSSL_DYNAMIC=0` 传递给CMake。 +s390x 有两个与 OpenSSL 相关的构建选项: +- 默认情况下,OpenSSL 在 s390x 上作为共享库构建。这与其他所有平台不同,其他平台上的 OpenSSL 是作为静态库构建。 +- 无论如何,要将 OpenSSL 构建为静态库,请将 `-DENABLE_OPENSSL_DYNAMIC=0` 传递给 CMake。 -这些说明假设主机机器是x86_64,并且拥有根据[构建说明](../development/build.md)本地构建所需的所有工具。它还假设主机是Ubuntu 22.04,但以下说明应该也适用于Ubuntu 20.04。 +这些说明假设主机机器是 x86_64,且具备根据 [构建说明](../development/build.md) 本地构建所需的所有工具。它还假设主机是 Ubuntu 22.04,但以下说明在 Ubuntu 20.04 上也应适用。 -除了安装用于本地构建的工具外,还需要安装以下附加软件包: +除了安装用于本地构建的工具外,还需要安装以下额外软件包: ```bash apt-get install binutils-s390x-linux-gnu libc6-dev-s390x-cross gcc-s390x-linux-gnu binfmt-support qemu-user-static ``` -如果您希望交叉编译rust代码,请安装s390x的rust交叉编译目标: +如果您希望交叉编译 Rust 代码,请安装 s390x 的 Rust 交叉编译目标: ```bash rustup target add s390x-unknown-linux-gnu ``` -s390x构建使用mold链接器,从https://github.com/rui314/mold/releases/download/v2.0.0/mold-2.0.0-x86_64-linux.tar.gz下载并将其放入您的 `$PATH` 中。 +s390x 的构建使用 mold 链接器,请从 https://github.com/rui314/mold/releases/download/v2.0.0/mold-2.0.0-x86_64-linux.tar.gz 下载并将其放入 `$PATH` 中。 -要为s390x构建: +要为 s390x 构建: ```bash cmake -DCMAKE_TOOLCHAIN_FILE=cmake/linux/toolchain-s390x.cmake .. @@ -42,7 +43,7 @@ ninja ## 运行 {#running} -构建完成后,可以使用以下命令运行可执行文件,例如: +构建完成后,可以运行二进制文件,例如: ```bash qemu-s390x-static -L /usr/s390x-linux-gnu ./clickhouse @@ -50,19 +51,19 @@ qemu-s390x-static -L /usr/s390x-linux-gnu ./clickhouse ## 调试 {#debugging} -安装LLDB: +安装 LLDB: ```bash apt-get install lldb-15 ``` -要调试s390x可执行文件,使用QEMU以调试模式运行clickhouse: +要调试 s390x 可执行文件,请使用调试模式运行 clickhouse,并通过 QEMU: ```bash qemu-s390x-static -g 31338 -L /usr/s390x-linux-gnu ./clickhouse ``` -在另一个shell中运行LLDB并附加,替换 `` 和 `` 为与您的环境对应的值。 +在另一个 shell 中运行 LLDB 并附加,替换 `` 和 `` 为您环境中的相应值。 ```bash lldb-15 @@ -95,10 +96,10 @@ Process 1 stopped ## Visual Studio Code 集成 {#visual-studio-code-integration} -- [CodeLLDB](https://github.com/vadimcn/vscode-lldb) 扩展是可视调试所必需的。 +- [CodeLLDB](https://github.com/vadimcn/vscode-lldb) 扩展是进行视觉调试的必要条件。 - [Command Variable](https://github.com/rioj7/command-variable) 扩展可以帮助动态启动,如果使用 [CMake Variants](https://github.com/microsoft/vscode-cmake-tools/blob/main/docs/variants.md)。 -- 确保将后端设置为您的LLVM安装,例如 `"lldb.library": "/usr/lib/x86_64-linux-gnu/liblldb-15.so"` -- 启动前,请确保以调试模式运行clickhouse可执行文件。(也可以创建一个 `preLaunchTask` 来自动化此过程) +- 确保将后端设置为您的 LLVM 安装,例如 `"lldb.library": "/usr/lib/x86_64-linux-gnu/liblldb-15.so"` +- 在启动之前,请确保以调试模式运行 clickhouse 可执行文件(也可以创建一个 `preLaunchTask` 来自动执行此操作)。 ### 示例配置 {#example-configurations} #### cmake-variants.yaml {#cmake-variantsyaml} @@ -155,7 +156,7 @@ toolchain: ``` #### settings.json {#settingsjson} -这也会将不同的构建放在`build`文件夹的不同子文件夹下。 +这也会将不同的构建放在 `build` 文件夹的不同子文件夹中。 ```json { "cmake.buildDirectory": "${workspaceFolder}/build/${buildKitVendor}-${buildKitVersion}-${variant:toolchain}-${variant:buildType}", @@ -172,7 +173,7 @@ qemu-s390x-static -g 2159 -L /usr/s390x-linux-gnu $2 $3 $4 ``` #### tasks.json {#tasksjson} -定义一个任务,以在 `tmp` 文件夹下以 `server` 模式运行编译的可执行文件,该文件夹与二进制文件相邻,配置来自 `programs/server/config.xml` 。 +定义了一个任务,在 `tmp` 文件夹中以 `server` 模式运行编译后的可执行文件,该文件夹位于二进制文件旁边,配置来自 `programs/server/config.xml` 下。 ```json { "version": "2.0.0", diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/development/build-cross-s390x.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/development/build-cross-s390x.md.hash index 59ec36b1198..4533b840a21 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/development/build-cross-s390x.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/development/build-cross-s390x.md.hash @@ -1 +1 @@ -6b95d83e208e0143 +9e03c0e6c98b767d diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/development/build-osx.md b/i18n/zh/docusaurus-plugin-content-docs/current/development/build-osx.md index 60729e564fc..ba30ea3e902 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/development/build-osx.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/development/build-osx.md @@ -4,40 +4,45 @@ 'sidebar_position': 15 'slug': '/development/build-osx' 'title': '在 macOS 上构建 macOS' +'keywords': +- 'MacOS' +- 'Mac' +- 'build' +'doc_type': 'guide' --- # 如何在 macOS 上构建 ClickHouse -:::info 您不需要自己构建 ClickHouse! -您可以按照[快速开始](https://clickhouse.com/#quick-start)中描述的方法安装预构建的 ClickHouse。 +:::info 您无需自己构建 ClickHouse! +您可以按照 [快速入门](https://clickhouse.com/#quick-start) 中的说明安装预构建的 ClickHouse。 ::: -ClickHouse 可以在 macOS x86_64 (Intel) 和 arm64 (Apple Silicon) 上使用 macOS 10.15 (Catalina) 或更高版本进行编译。 +ClickHouse 可以在 macOS x86_64(Intel)和 arm64(Apple Silicon)上编译,要求 macOS 10.15(Catalina)或更高版本。 -作为编译器,仅支持来自 Homebrew 的 Clang。 +作为编译器,仅支持来自 homebrew 的 Clang。 ## 安装先决条件 {#install-prerequisites} -首先,请参阅通用的 [先决条件文档](developer-instruction.md)。 +首先,查看通用的 [先决条件文档](developer-instruction.md)。 -接下来,安装 [Homebrew](https://brew.sh/) 并运行: +接下来,安装 [Homebrew](https://brew.sh/) 并运行 然后运行: ```bash brew update -brew install ccache cmake ninja libtool gettext llvm binutils grep findutils nasm bash +brew install ccache cmake ninja libtool gettext llvm lld binutils grep findutils nasm bash rust rustup ``` :::note -Apple 默认使用大小写不敏感的文件系统。虽然这通常不会影响编译(尤其是 scratch makes 将正常工作),但它可能会混淆文件操作,如 `git mv`。 -对于在 macOS 上进行严重开发,确保源代码存储在大小写敏感的磁盘卷上,例如,请参见 [这些说明](https://brianboyko.medium.com/a-case-sensitive-src-folder-for-mac-programmers-176cc82a3830)。 +Apple 默认使用区分大小写的文件系统。虽然这通常不会影响编译(特别是 scratch makes 会正常工作),但可能会使文件操作如 `git mv` 感到困惑。 +对于在 macOS 上的严肃开发,请确保源代码存储在支持区分大小写的磁盘卷中,例如,请参阅 [这些说明](https://brianboyko.medium.com/a-case-sensitive-src-folder-for-mac-programmers-176cc82a3830)。 ::: ## 构建 ClickHouse {#build-clickhouse} -要构建,必须使用 Homebrew 的 Clang 编译器: +要构建,请使用 Homebrew 的 Clang 编译器: ```bash cd ClickHouse @@ -50,7 +55,7 @@ cmake --build build ``` :::note -如果在链接过程中遇到 `ld: archive member '/' not a mach-o file in ...` 错误,您可能需要通过设置标志 `-DCMAKE_AR=/opt/homebrew/opt/llvm/bin/llvm-ar` 来使用 llvm-ar。 +如果在链接期间遇到 `ld: archive member '/' not a mach-o file in ...` 错误,您可能需要通过设置标志 `-DCMAKE_AR=/opt/homebrew/opt/llvm/bin/llvm-ar` 来使用 llvm-ar。 ::: ## 注意事项 {#caveats} @@ -61,7 +66,7 @@ cmake --build build 您需要使用 sudo。 ::: -要做到这一点,创建 `/Library/LaunchDaemons/limit.maxfiles.plist` 文件,内容如下: +为此,创建 `/Library/LaunchDaemons/limit.maxfiles.plist` 文件,并包含以下内容: ```xml @@ -87,7 +92,7 @@ cmake --build build ``` -给文件正确的权限: +赋予文件正确的权限: ```bash sudo chown root:wheel /Library/LaunchDaemons/limit.maxfiles.plist @@ -105,4 +110,4 @@ plutil /Library/LaunchDaemons/limit.maxfiles.plist sudo launchctl load -w /Library/LaunchDaemons/limit.maxfiles.plist ``` -要检查是否工作,请使用 `ulimit -n` 或 `launchctl limit maxfiles` 命令。 +要检查其是否正常工作,请使用 `ulimit -n` 或 `launchctl limit maxfiles` 命令。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/development/build-osx.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/development/build-osx.md.hash index 08e085719cf..95b2e357dca 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/development/build-osx.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/development/build-osx.md.hash @@ -1 +1 @@ -35755c83b489c03e +af51a4626f544acf diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/development/build.md b/i18n/zh/docusaurus-plugin-content-docs/current/development/build.md index 9219285f313..6bd64f4f002 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/development/build.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/development/build.md @@ -4,29 +4,30 @@ 'sidebar_position': 10 'slug': '/development/build' 'title': '如何在Linux上构建ClickHouse' +'doc_type': 'guide' --- # 如何在 Linux 上构建 ClickHouse :::info 您不必自己构建 ClickHouse! -您可以按照 [快速入门](https://clickhouse.com/#quick-start) 中的说明安装预构建的 ClickHouse。 +您可以按照 [快速开始](https://clickhouse.com/#quick-start) 的说明安装预构建的 ClickHouse。 ::: ClickHouse 可以在以下平台上构建: - x86_64 - AArch64 -- PowerPC 64 LE (实验性) -- s390/x (实验性) -- RISC-V 64 (实验性) +- PowerPC 64 LE(实验性) +- s390/x(实验性) +- RISC-V 64(实验性) -## 先决条件 {#assumptions} +## 假设 {#assumptions} -以下教程基于 Ubuntu Linux,但也应该适用于任何其他 Linux 发行版,只需进行适当修改即可。 -推荐用于开发的最小 Ubuntu 版本为 24.04 LTS。 +以下教程基于 Ubuntu Linux,但它也应该适用于其他任何 Linux 发行版,只需进行适当的更改。 +建议的最低 Ubuntu 版本为 24.04 LTS。 -该教程假设您已经在本地检出了 ClickHouse 仓库及其所有子模块。 +本教程假定您已本地检出 ClickHouse 仓库及所有子模块。 ## 安装先决条件 {#install-prerequisites} @@ -34,7 +35,7 @@ ClickHouse 可以在以下平台上构建: ClickHouse 使用 CMake 和 Ninja 进行构建。 -您可以选择性地安装 ccache,以便在构建时重用已编译的对象文件。 +您可以选择性地安装 ccache,以便构建能够重用已编译的目标文件。 ```bash sudo apt-get update @@ -43,68 +44,72 @@ sudo apt-get install git cmake ccache python3 ninja-build nasm yasm gawk lsb-rel ## 安装 Clang 编译器 {#install-the-clang-compiler} -要在 Ubuntu/Debian 上安装 Clang,请使用来自 [这里](https://apt.llvm.org/) 的 LLVM 自动安装脚本。 +要在 Ubuntu/Debian 上安装 Clang,请使用 LLVM 的自动安装脚本,地址可以从 [这里](https://apt.llvm.org/) 获取。 ```bash sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" ``` -对于其他 Linux 发行版,请检查是否可以安装任何 LLVM 的 [预构建软件包](https://releases.llvm.org/download.html)。 +对于其他 Linux 发行版,请查看是否可以安装 LLVM 的 [预构建包](https://releases.llvm.org/download.html)。 -截至 2025 年 3 月,必须使用 Clang 19 或更高版本。 -GCC 或其他编译器不受支持。 +截至 2025 年 3 月,要求使用 Clang 19 或更高版本。 +不支持 GCC 或其他编译器。 ## 安装 Rust 编译器(可选) {#install-the-rust-compiler-optional} :::note Rust 是 ClickHouse 的可选依赖项。 -如果未安装 Rust,则某些 ClickHouse 功能将从编译中省略。 +如果未安装 Rust,则某些 ClickHouse 的功能将不会被编译。 ::: -首先,请按照官方 [Rust 文档](https://www.rust-lang.org/tools/install) 中的步骤安装 `rustup`。 +首先,请遵循官方 [Rust 文档](https://www.rust-lang.org/tools/install) 中的步骤安装 `rustup`。 -与 C++ 依赖项一样,ClickHouse 使用 vendoring 来精确控制已安装的内容并避免依赖第三方服务(如 `crates.io` 注册表)。 +与 C++ 依赖项一样,ClickHouse 使用 vendoring 来精确控制安装内容,并避免依赖第三方服务(如 `crates.io` 注册表)。 -尽管在发布模式下,任何现代的 rustup 工具链版本都应与这些依赖项一起工作,但如果您计划启用 sanitizer,则必须使用与 CI 中使用的相同 `std` 的版本(对于该版本我们供应 crates): +虽然在发布模式下,任何现代的 rustup 工具链版本应该可以与这些依赖项配合使用,但如果您计划启用 sanitizers,必须使用与 CI 中使用的相同 `std` 完全匹配的版本(我们为此 vendoring 了这些 crates): ```bash -rustup toolchain install nightly-2024-12-01 -rustup default nightly-2024-12-01 +rustup toolchain install nightly-2025-07-07 +rustup default nightly-2025-07-07 rustup component add rust-src ``` ## 构建 ClickHouse {#build-clickhouse} -我们建议在 `ClickHouse` 内创建一个单独的目录 `build`,其中包含所有构建产物: +我们建议在 `ClickHouse` 目录中创建一个单独的目录 `build`,其中包含所有构建工件: ```sh mkdir build cd build ``` -您可以为不同的构建类型(例如 `build_release`、`build_debug` 等)设置几个不同的目录。 +您可以有多个不同的目录(例如 `build_release`、`build_debug` 等)用于不同的构建类型。 -可选:如果安装了多个编译器版本,您可以选择性地指定要使用的确切编译器。 +可选:如果您安装了多个编译器版本,可以选择性地指定要使用的确切编译器。 ```sh export CC=clang-19 export CXX=clang++-19 ``` -出于开发目的,建议使用调试构建。 -与发布构建相比,调试构建具有较低的编译器优化级别(`-O`),提供更好的调试体验。 -此外,类型为 `LOGICAL_ERROR` 的内部异常立即崩溃,而不是优雅失败。 +出于开发目的,推荐使用调试构建。 +与发布构建相比,它们具有较低的编译器优化水平(`-O`),提供更好的调试体验。 +此外,类型为 `LOGICAL_ERROR` 的内部异常会立即崩溃,而不是优雅失败。 ```sh cmake -D CMAKE_BUILD_TYPE=Debug .. ``` +:::note +如果您希望使用 gdb 等调试器,请在上述命令中添加 `-D DEBUG_O_LEVEL="0"` 来移除所有编译器优化,这可能会影响 gdb 查看/访问变量的能力。 +::: + 运行 ninja 进行构建: ```sh -ninja clickhouse-server clickhouse-client +ninja clickhouse ``` -如果您希望构建所有二进制文件(实用程序和测试),请无需参数运行 ninja: +如果您希望构建所有二进制文件(实用程序和测试),可以不带参数运行 ninja: ```sh ninja @@ -117,7 +122,7 @@ ninja -j 1 clickhouse-server clickhouse-client ``` :::tip -CMake 为上述命令提供了快捷方式: +CMake 提供了上述命令的快捷方式: ```sh cmake -S . -B build # configure build, run from repository top-level directory @@ -127,12 +132,12 @@ cmake --build build # compile ## 运行 ClickHouse 可执行文件 {#running-the-clickhouse-executable} -构建成功完成后,您会在 `ClickHouse//programs/` 中找到可执行文件: +构建成功完成后,您可以在 `ClickHouse//programs/` 中找到可执行文件: ClickHouse 服务器尝试在当前目录中查找配置文件 `config.xml`。 -您可以选择通过 `-C` 在命令行中指定配置文件。 +您还可以通过 `-C` 在命令行中指定配置文件。 -要使用 `clickhouse-client` 连接到 ClickHouse 服务器,请打开另一个终端,导航到 `ClickHouse/build/programs/`,然后运行 `./clickhouse client`。 +要使用 `clickhouse-client` 连接到 ClickHouse 服务器,请打开另一个终端,导航到 `ClickHouse/build/programs/` 并运行 `./clickhouse client`。 如果您在 macOS 或 FreeBSD 上收到 `Connection refused` 消息,请尝试指定主机地址 127.0.0.1: @@ -150,7 +155,7 @@ clickhouse client --host 127.0.0.1 cmake -DENABLE_LIBRARIES=OFF ``` -如果出现问题,您将独自承担后果... +如果出现问题,您就要自己解决了…… Rust 需要互联网连接。要禁用 Rust 支持: @@ -161,7 +166,7 @@ cmake -DENABLE_RUST=OFF ### 运行 ClickHouse 可执行文件 {#running-the-clickhouse-executable-1} 您可以用编译后的 ClickHouse 二进制文件替换系统中安装的生产版本 ClickHouse 二进制文件。 -为此,请按照官方网站的说明在您的机器上安装 ClickHouse。 +要做到这一点,请遵循官方站点上的说明在您的机器上安装 ClickHouse。 接下来,运行: ```bash @@ -170,9 +175,9 @@ sudo cp ClickHouse/build/programs/clickhouse /usr/bin/ sudo service clickhouse-server start ``` -请注意,`clickhouse-client`、`clickhouse-server` 和其他文件都是指向常用的 `clickhouse` 二进制文件的符号链接。 +请注意,`clickhouse-client`、`clickhouse-server` 等是通用共享的 `clickhouse` 二进制文件的符号链接。 -您还可以使用系统上安装的 ClickHouse 软件包中的配置文件运行自定义构建的 ClickHouse 二进制文件: +您还可以使用系统中安装的 ClickHouse 包的配置文件运行您自定义构建的 ClickHouse 二进制文件: ```bash sudo service clickhouse-server stop @@ -204,16 +209,15 @@ cmake --build build ### 在 docker 中构建 {#building-in-docker} -您可以使用以下命令在类似 CI 的环境中本地运行任何构建: +您可以使用以下命令在与 CI 相似的环境中本地运行任何构建: ```bash python -m ci.praktika "BUILD_JOB_NAME" ``` -其中 BUILD_JOB_NAME 是 CI 报告中显示的作业名称,例如,“Build (arm_release)”、“Build (amd_debug)” +其中 BUILD_JOB_NAME 是 CI 报告中显示的作业名称,例如 "Build (arm_release)"、"Build (amd_debug)" -该命令会拉取所需依赖项的适当 Docker 镜像 `clickhouse/binary-builder`, -并在其中运行构建脚本: `./ci/jobs/build_clickhouse.py` +此命令会拉取适当的 Docker 镜像 `clickhouse/binary-builder`,该镜像包含所有所需的依赖项,并在其中运行构建脚本:`./ci/jobs/build_clickhouse.py` 构建输出将放置在 `./ci/tmp/` 中。 -它可以在 AMD 和 ARM 架构上运行,并且不需要除 Docker 之外的其他依赖项。 +它适用于 AMD 和 ARM 架构,并且除了 Docker 之外,不需要其他额外的依赖项。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/development/build.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/development/build.md.hash index 687306ef9f9..94c6a752fc5 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/development/build.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/development/build.md.hash @@ -1 +1 @@ -43d59cd762a519fc +330f6774553ad5ed diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/development/building_and_benchmarking_deflate_qpl.md b/i18n/zh/docusaurus-plugin-content-docs/current/development/building_and_benchmarking_deflate_qpl.md index 41015c3ccaf..1ea217091af 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/development/building_and_benchmarking_deflate_qpl.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/development/building_and_benchmarking_deflate_qpl.md @@ -1,34 +1,35 @@ --- -'description': '如何构建 Clickhouse 并使用 DEFLATE_QPL 编解码器进行基准测试' +'description': '如何构建 Clickhouse 并使用 DEFLATE_QPL 编解码器运行基准测试' 'sidebar_label': '构建和基准测试 DEFLATE_QPL' 'sidebar_position': 73 'slug': '/development/building_and_benchmarking_deflate_qpl' -'title': '使用 DEFLATE_QPL 构建 Clickhouse' +'title': '构建 Clickhouse 与 DEFLATE_QPL' +'doc_type': 'guide' --- # 使用 DEFLATE_QPL 构建 Clickhouse -- 确保您的主机满足 QPL 所需的 [先决条件](https://intel.github.io/qpl/documentation/get_started_docs/installation.html#prerequisites) -- 在 cmake 构建过程中,默认启用 deflate_qpl。如果您意外更改了该设置,请仔细检查构建标志: ENABLE_QPL=1 +- 确保你的主机满足 QPL 所需的 [先决条件](https://intel.github.io/qpl/documentation/get_started_docs/installation.html#prerequisites) +- 在 cmake 构建期间,deflate_qpl 默认启用。如果你不小心更改了它,请仔细检查构建标志: ENABLE_QPL=1 -- 有关通用要求,请参阅 Clickhouse 通用的 [构建说明](/development/build.md) +- 有关通用要求,请参考 Clickhouse 通用 [构建说明](/development/build.md) # 使用 DEFLATE_QPL 运行基准测试 ## 文件列表 {#files-list} -`benchmark_sample` 文件夹下的 [qpl-cmake](https://github.com/ClickHouse/ClickHouse/tree/master/contrib/qpl-cmake) 提供了使用 python 脚本运行基准测试的示例: +文件夹 `benchmark_sample` 在 [qpl-cmake](https://github.com/ClickHouse/ClickHouse/tree/master/contrib/qpl-cmake) 下提供了使用 python 脚本运行基准测试的示例: `client_scripts` 包含用于运行典型基准测试的 python 脚本,例如: -- `client_stressing_test.py`:用于查询压力测试的 python 脚本,支持 [1~4] 个服务器实例。 -- `queries_ssb.sql`:列出了所有 [星型模式基准测试](/getting-started/example-datasets/star-schema/) 的查询文件。 -- `allin1_ssb.sh`:该 shell 脚本自动执行所有基准测试工作流程。 +- `client_stressing_test.py`:用于 [1~4] 个服务器实例的查询压力测试的 python 脚本。 +- `queries_ssb.sql`:文件列出了与 [星型模式基准测试](/getting-started/example-datasets/star-schema/) 相关的所有查询。 +- `allin1_ssb.sh`:此 shell 脚本自动执行所有基准测试工作流程。 `database_files` 表示它将根据 lz4/deflate/zstd 编解码器存储数据库文件。 -## 自动运行星型模式基准测试 {#run-benchmark-automatically-for-star-schema} +## 自动运行星型模式基准测试: {#run-benchmark-automatically-for-star-schema} ```bash $ cd ./benchmark_sample/client_scripts @@ -37,24 +38,24 @@ $ sh run_ssb.sh 完成后,请检查此文件夹中的所有结果:`./output/` -如果您遇到故障,请按照以下部分手动运行基准测试。 +如果遇到故障,请手动运行基准测试,如下所述。 ## 定义 {#definition} -[CLICKHOUSE_EXE] 表示 Clickhouse 可执行程序的路径。 +[CLICKHOUSE_EXE] 表示 ClickHouse 可执行程序的路径。 ## 环境 {#environment} -- CPU: Sapphire Rapid -- 操作系统要求请参阅 [QPL 的系统要求](https://intel.github.io/qpl/documentation/get_started_docs/installation.html#system-requirements) -- IAA 设置请参阅 [加速器配置](https://intel.github.io/qpl/documentation/get_started_docs/installation.html#accelerator-configuration) +- CPU:Sapphire Rapid +- 操作系统要求参见 [QPL 系统要求](https://intel.github.io/qpl/documentation/get_started_docs/installation.html#system-requirements) +- IAA 设置参见 [加速器配置](https://intel.github.io/qpl/documentation/get_started_docs/installation.html#accelerator-configuration) - 安装 python 模块: ```bash pip3 install clickhouse_driver numpy ``` -[IAA 自检] +[IAA 的自检] ```bash $ accel-config list | grep -P 'iax|state' @@ -67,7 +68,7 @@ $ accel-config list | grep -P 'iax|state' "state":"enabled", ``` -如果没有输出,说明 IAA 尚未准备好工作。请再次检查 IAA 设置。 +如果未看到任何输出,则表示 IAA 尚未准备好工作。请再次检查 IAA 设置。 ## 生成原始数据 {#generate-raw-data} @@ -79,7 +80,7 @@ $ mkdir rawdata_dir && cd rawdata_dir 使用 [`dbgen`](/getting-started/example-datasets/star-schema) 生成 1 亿行数据,参数为: -s 20 -文件 `*.tbl` 预期将输出到 `./benchmark_sample/rawdata_dir/ssb-dbgen` 下: +预期输出的文件为位于 `./benchmark_sample/rawdata_dir/ssb-dbgen` 下的 `*.tbl` 文件: ## 数据库设置 {#database-setup} @@ -91,12 +92,12 @@ $ [CLICKHOUSE_EXE] server -C config_lz4.xml >&/dev/null& $ [CLICKHOUSE_EXE] client ``` -在控制台中,您应该看到消息 `Connected to ClickHouse server`,这表示客户端成功与服务器建立连接。 +在控制台中你应该看到消息 `Connected to ClickHouse server`,这表示客户端与服务器成功建立了连接。 -完成 [星型模式基准测试](/getting-started/example-datasets/star-schema) 中提到的以下三步: +完成 [星型模式基准测试](/getting-started/example-datasets/star-schema) 中提到的以下三个步骤: - 在 ClickHouse 中创建表 - 插入数据。此处应使用 `./benchmark_sample/rawdata_dir/ssb-dbgen/*.tbl` 作为输入数据。 -- 将“星型模式”转换为非规范化的“扁平模式” +- 将“星型模式”转换为去规范化的“扁平模式” 使用 IAA Deflate 编解码器设置数据库 @@ -105,7 +106,7 @@ $ cd ./database_dir/deflate $ [CLICKHOUSE_EXE] server -C config_deflate.xml >&/dev/null& $ [CLICKHOUSE_EXE] client ``` -完成与上面 LZ4 相同的三步 +完成与上述 lz4 相同的三步 使用 ZSTD 编解码器设置数据库 @@ -114,32 +115,32 @@ $ cd ./database_dir/zstd $ [CLICKHOUSE_EXE] server -C config_zstd.xml >&/dev/null& $ [CLICKHOUSE_EXE] client ``` -完成与上面 LZ4 相同的三步 +完成与上述 lz4 相同的三步 [self-check] -对于每个编解码器(lz4/zstd/deflate),请执行以下查询以确保数据库成功创建: +对于每个编解码器 (lz4/zstd/deflate),请执行以下查询以确保数据库已成功创建: ```sql -select count() from lineorder_flat +SELECT count() FROM lineorder_flat ``` -您应该看到以下输出: +你应该看到以下输出: ```sql ┌───count()─┐ │ 119994608 │ └───────────┘ ``` -[IAA Deflate 编解码器自检] +[IAA Deflate 编解码器的自检] -在您首次从客户端执行插入或查询时,Clickhouse 服务器控制台应该打印出以下日志: +第一次执行客户端的插入或查询时,预计 ClickHouse 服务器控制台将打印此日志: ```text Hardware-assisted DeflateQpl codec is ready! ``` -如果您从未找到此日志,而看到其他日志如下所示: +如果你未发现此日志,而是看到如下日志: ```text Initialization of hardware-assisted DeflateQpl codec failed ``` -这意味着 IAA 设备尚未准备好,您需要再次检查 IAA 设置。 +这意味着 IAA 设备未准备好,需要再次检查 IAA 设置。 -## 单实例基准测试 {#benchmark-with-single-instance} +## 使用单实例进行基准测试 {#benchmark-with-single-instance} - 在开始基准测试之前,请禁用 C6 并将 CPU 频率调节器设置为 `performance` @@ -148,12 +149,12 @@ $ cpupower idle-set -d 3 $ cpupower frequency-set -g performance ``` -- 为了消除内存绑定对跨插槽的影响,我们使用 `numactl` 将服务器绑定到一个插槽,将客户端绑定到另一个插槽。 -- 单实例意味着单个服务器连接到单个客户端 +- 为了消除在跨插槽时内存绑定的影响,我们使用 `numactl` 将服务器绑定到一个插槽,将客户端绑定到另一个插槽。 +- 单实例意味着单个服务器与单个客户端连接 现在分别为 LZ4/Deflate/ZSTD 运行基准测试: -LZ4: +LZ4: ```bash $ cd ./database_dir/lz4 @@ -162,7 +163,7 @@ $ cd ./client_scripts $ numactl -m 1 -N 1 python3 client_stressing_test.py queries_ssb.sql 1 > lz4.log ``` -IAA deflate: +IAA deflate: ```bash $ cd ./database_dir/deflate @@ -171,7 +172,7 @@ $ cd ./client_scripts $ numactl -m 1 -N 1 python3 client_stressing_test.py queries_ssb.sql 1 > deflate.log ``` -ZSTD: +ZSTD: ```bash $ cd ./database_dir/zstd @@ -180,7 +181,7 @@ $ cd ./client_scripts $ numactl -m 1 -N 1 python3 client_stressing_test.py queries_ssb.sql 1 > zstd.log ``` -现在应该如预期输出三个日志: +现在应输出三条预期的日志: ```text lz4.log deflate.log @@ -191,18 +192,18 @@ zstd.log 我们关注 QPS,请搜索关键字: `QPS_Final` 并收集统计数据 -## 多实例基准测试 {#benchmark-with-multi-instances} +## 使用多实例进行基准测试 {#benchmark-with-multi-instances} -- 为了减少内存绑定对过多线程的影响,我们建议使用多实例运行基准测试。 -- 多实例意味着多个(2 或 4)服务器连接到各自的客户端。 +- 为了减少过多线程对内存绑定的影响,建议使用多实例运行基准测试。 +- 多实例意味着多个(2 或 4)服务器与相应客户端连接。 - 一个插槽的核心需要均匀分配并分别分配给服务器。 - 对于多实例,必须为每个编解码器创建新文件夹,并按照与单实例类似的步骤插入数据集。 有两个不同之处: -- 对于客户端,在创建表和插入数据时,您需要使用分配的端口启动 Clickhouse。 -- 对于服务器端,您需要使用特定的 xml 配置文件启动 Clickhouse,其中端口已经分配。所有为多实例提供的自定义 xml 配置文件都在 ./server_config 下。 +- 对于客户端,需要在创建表和插入数据时使用分配的端口启动 ClickHouse。 +- 对于服务器,需要使用特定的 xml 配置文件启动 ClickHouse,端口已分配。所有用于多实例的自定义 xml 配置文件均已提供在 ./server_config 下。 -在此,我们假设每个插槽有 60 个核心,以两个实例为例。 +在此假设每个插槽有 60 个核心,以 2 个实例为例。 启动第一个实例的服务器 LZ4: @@ -251,7 +252,7 @@ $ cp ../../server_config/config_deflate_s2.xml ./ $ numactl -C 30-59,150-179 [CLICKHOUSE_EXE] server -C config_deflate_s2.xml >&/dev/null& ``` -为第二个实例创建表和插入数据 +为第二个实例创建表并插入数据 创建表: @@ -265,8 +266,8 @@ $ [CLICKHOUSE_EXE] client -m --port=9001 $ [CLICKHOUSE_EXE] client --query "INSERT INTO [TBL_FILE_NAME] FORMAT CSV" < [TBL_FILE_NAME].tbl --port=9001 ``` -- [TBL_FILE_NAME] 表示名称为正则表达式:*. tbl 的文件,位于 `./benchmark_sample/rawdata_dir/ssb-dbgen` 下。 -- `--port=9001` 代表分配给服务器实例的端口,这也在 config_lz4_s2.xml/config_zstd_s2.xml/config_deflate_s2.xml 中定义。对于更多实例,您需要将其替换为 9002/9003,分别表示 s3/s4 实例。如果您没有分配它,默认为 9000 端口,该端口已被第一个实例使用。 +- [TBL_FILE_NAME] 表示在 `./benchmark_sample/rawdata_dir/ssb-dbgen` 下以正则表达式命名的文件:*. tbl。 +- `--port=9001` 代表为服务器实例分配的端口,该端口在 config_lz4_s2.xml/config_zstd_s2.xml/config_deflate_s2.xml 中定义。对于更多实例,需要将其替换为值:9002/9003,分别代表 s3/s4 实例。如果未分配,默认端口为 9000,已由第一个实例使用。 使用 2 个实例进行基准测试 @@ -303,9 +304,9 @@ $ cd ./client_scripts $ numactl -m 1 -N 1 python3 client_stressing_test.py queries_ssb.sql 2 > deflate_2insts.log ``` -这里最后一个参数: `2` 表示 client_stressing_test.py 的实例数量。对于更多实例,您需要将其替换为 3 或 4。该脚本支持最多 4 个实例。 +这里最后一个参数: `2` 表示 client_stressing_test.py 的实例数量。对于更多实例,你需要将其替换为值:3 或 4。此脚本支持最多 4 个实例。 -现在应该如预期输出三个日志: +现在应输出三条预期日志: ```text lz4_2insts.log @@ -316,15 +317,15 @@ zstd_2insts.log 我们关注 QPS,请搜索关键字: `QPS_Final` 并收集统计数据 -4 个实例的基准测试设置与上面的 2 个实例类似。 -我们建议使用 2 个实例的基准测试数据作为最终报告进行审查。 +4 个实例的基准测试设置与上述 2 个实例的设置类似。 +我们建议使用 2 个实例的基准测试数据作为最终报告以供审核。 ## 提示 {#tips} -每次在启动新的 Clickhouse 服务器之前,请确保没有后台 Clickhouse 进程在运行,请检查并终止旧的进程: +每次启动新的 ClickHouse 服务器之前,请确保没有后台 ClickHouse 进程在运行,请检查并终止旧进程: ```bash $ ps -aux| grep clickhouse $ kill -9 [PID] ``` -通过比较 ./client_scripts/queries_ssb.sql 中的查询列表与官方 [星型模式基准测试](/getting-started/example-datasets/star-schema),您会发现有 3 个查询未包含: Q1.2/Q1.3/Q3.4。这是因为这些查询的 CPU 利用率 % 非常低 < 10% ,这意味着无法展示性能差异。 +通过比较 ./client_scripts/queries_ssb.sql 中的查询列表与官方 [星型模式基准测试](/getting-started/example-datasets/star-schema),你会发现 3 个查询未包含: Q1.2/Q1.3/Q3.4 。这是因为这些查询的 CPU 利用率百分比非常低 < 10%,这意味着无法展示性能差异。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/development/building_and_benchmarking_deflate_qpl.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/development/building_and_benchmarking_deflate_qpl.md.hash index e678a7a153f..0bb50c3f01d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/development/building_and_benchmarking_deflate_qpl.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/development/building_and_benchmarking_deflate_qpl.md.hash @@ -1 +1 @@ -12f4a25741923514 +a2a3ced4cd61bc8f diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/development/continuous-integration.md b/i18n/zh/docusaurus-plugin-content-docs/current/development/continuous-integration.md index 5f9f5e10d3e..518c5127c76 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/development/continuous-integration.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/development/continuous-integration.md @@ -4,14 +4,15 @@ 'sidebar_position': 55 'slug': '/development/continuous-integration' 'title': '持续集成 (CI)' +'doc_type': 'reference' --- -# 持续集成 (CI) +# 持续集成(CI) -当您提交拉取请求时,ClickHouse [持续集成 (CI) 系统](tests.md#test-automation)将对您的代码运行一些自动检查。这在一个仓库维护者(ClickHouse团队的某个成员)审核了您的代码并将 `can be tested` 标签添加到您的拉取请求后发生。检查结果在GitHub拉取请求页面上列出,详细信息请参见 [GitHub 检查文档](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/about-status-checks)。如果某个检查失败,您可能需要修复它。本页面概述了您可能会遇到的检查以及您可以采取的修复措施。 +当您提交拉取请求时,ClickHouse [持续集成(CI)系统](tests.md#test-automation) 会对您的代码运行一些自动检查。这发生在存储库维护者(来自 ClickHouse 团队的某人)筛选您的代码并将 `can be tested` 标签添加到您的拉取请求后。检查结果会在 GitHub 拉取请求页面上列出,如 [GitHub 检查文档](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/about-status-checks) 中所述。如果某个检查失败,您可能需要修复它。此页面提供您可能遇到的检查概述,以及您可以采取的修复措施。 -如果检查失败似乎与您的更改无关,这可能是某种暂时性失败或基础设施问题。向拉取请求推送一个空提交以重新启动CI检查: +如果看起来检查失败与您的更改无关,可能是某种瞬时故障或基础设施问题。向拉取请求推送一个空提交以重新启动 CI 检查: ```shell git reset @@ -19,36 +20,36 @@ git commit --allow-empty git push ``` -如果您不确定该做什么,请向维护者寻求帮助。 +如果您不确定该怎么做,可以询问维护者寻求帮助。 -## 与 Master 合并 {#merge-with-master} +## 与主干合并 {#merge-with-master} -验证 PR 是否可以合并到 master。如果不能,检查将失败并显示消息 `Cannot fetch mergecommit`。要修复此检查,请按照 [GitHub 文档](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/resolving-a-merge-conflict-on-github) 中的说明解决冲突,或使用 git 将 `master` 分支合并到您的拉取请求分支。 +验证 PR 是否可以合并到主干。如果不能,它将显示 `Cannot fetch mergecommit` 的消息。要修复此检查,请按照 [GitHub 文档](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/resolving-a-merge-conflict-on-github) 中的说明解决冲突,或使用 git 将 `master` 分支合并到您的拉取请求分支。 ## 文档检查 {#docs-check} -尝试构建 ClickHouse 文档网站。如果您更改了文档中的内容,它可能会失败。最可能的原因是文档中的某些交叉链接错误。查看检查报告,寻找 `ERROR` 和 `WARNING` 消息。 +尝试构建 ClickHouse 文档网站。如果您更改了文档中的某些内容,可能会失败。最可能的原因是文档中的某些交叉链接错误。前往检查报告,查看 `ERROR` 和 `WARNING` 消息。 ## 描述检查 {#description-check} -检查您的拉取请求描述是否符合模板 [PULL_REQUEST_TEMPLATE.md](https://github.com/ClickHouse/ClickHouse/blob/master/.github/PULL_REQUEST_TEMPLATE.md)。您必须为更改指定一个变更日志类别(例如 Bug 修复),并撰写用户可读的消息以描述 [CHANGELOG.md](../whats-new/changelog/index.md) 中的变更。 +检查您的拉取请求的描述是否符合模板 [PULL_REQUEST_TEMPLATE.md](https://github.com/ClickHouse/ClickHouse/blob/master/.github/PULL_REQUEST_TEMPLATE.md)。您必须为您的更改指定一个变更日志类别(例如,Bug 修复),并为 [CHANGELOG.md](../whats-new/changelog/index.md) 编写可读性强的描述消息。 ## 推送到 DockerHub {#push-to-dockerhub} -构建用于构建和测试的docker镜像,然后将其推送到DockerHub。 +构建用于构建和测试的 Docker 镜像,然后将其推送到 DockerHub。 ## 标记检查 {#marker-check} -此检查表示CI系统开始处理拉取请求。当其状态为 'pending' 时,这意味着并非所有检查均已开始。所有检查均已启动后,它会将状态更改为 'success'。 +此检查表示 CI 系统已开始处理拉取请求。当它处于“待处理”状态时,表示尚未开始所有检查。在所有检查开始后,状态将更改为“成功”。 -## 风格检查 {#style-check} +## 格式检查 {#style-check} -对代码库执行各种风格检查。 +对代码库执行各种格式检查。 -风格检查作业中的基本检查: +格式检查作业中的基本检查: ##### cpp {#cpp} -使用 [`ci/jobs/scripts/check_style/check_cpp.sh`](https://github.com/ClickHouse/ClickHouse/blob/master/ci/jobs/scripts/check_style/check_cpp.sh) 脚本(也可以在本地运行)执行基于正则表达式的简单代码风格检查。如果失败,根据 [代码风格指南](style.md) 修复风格问题。 +使用 [`ci/jobs/scripts/check_style/check_cpp.sh`](https://github.com/ClickHouse/ClickHouse/blob/master/ci/jobs/scripts/check_style/check_cpp.sh) 脚本(也可以在本地运行)执行简单的基于正则表达式的代码风格检查。如果失败,请根据 [代码风格指南](style.md) 修复格式问题。 ##### codespell, aspell {#codespell} 检查语法错误和拼写错误。 @@ -56,92 +57,118 @@ git push ##### mypy {#mypy} 对 Python 代码执行静态类型检查。 -### 在本地运行风格检查作业 {#running-style-check-locally} +### 在本地运行格式检查作业 {#running-style-check-locally} -整个 _风格检查_ 作业可以在Docker容器中通过以下命令本地运行: +整个 _Style Check_ 作业可以在 Docker 容器中本地运行,命令为: ```sh python -m ci.praktika run "Style check" ``` -要运行特定检查(例如,_cpp_ 检查): +要运行特定检查(例如,_cpp_ 检查): ```sh python -m ci.praktika run "Style check" --test cpp ``` -这些命令拉取 `clickhouse/style-test` Docker 镜像并在容器化环境中运行作业。除了 Python 3 和 Docker 外,没有其他依赖项。 +这些命令拉取 `clickhouse/style-test` Docker 镜像,并在容器化环境中运行该作业。除了 Python 3 和 Docker 以外,不需要其他依赖项。 ## 快速测试 {#fast-test} -通常这是针对PR运行的第一个检查。它构建 ClickHouse 并运行大多数 [无状态功能测试](tests.md#functional-tests),而省略一些。如果它失败,进一步的检查将不会启动,直到修复它。查看报告以查看哪些测试失败,然后按照 [这里](../development/tests#running-a-test-locally) 中的描述在本地重现故障。 +通常,这是为 PR 运行的第一个检查。它构建 ClickHouse 并运行大部分 [无状态功能测试](tests.md#functional-tests),省略一些。如果失败,则在修复之前不会启动进一步的检查。查看报告以了解哪些测试失败,然后根据 [这里](../development/tests#running-a-test-locally) 的说明在本地重现故障。 -#### 在本地运行快速测试: {#running-fast-test-locally} +#### 在本地运行快速测试: {#running-fast-test-locally} ```sh python -m ci.praktika run "Fast test" [--test some_test_name] ``` -这些命令拉取 `clickhouse/fast-test` Docker 镜像并在容器化环境中运行作业。除了 Python 3 和 Docker 外,没有其他依赖项。 +这些命令拉取 `clickhouse/fast-test` Docker 镜像,并在容器化环境中运行该作业。除了 Python 3 和 Docker 以外,不需要其他依赖项。 ## 构建检查 {#build-check} -以各种配置构建 ClickHouse 以供进一步步骤使用。您必须修复失败的构建。构建日志通常具有足够的信息以修复错误,但您可能需要在本地重现故障。可以在构建日志中找到 `cmake` 选项,grep 查找 `cmake`。使用这些选项并遵循 [通用构建流程](../development/build.md)。 +在各种配置中构建 ClickHouse,以用于后续步骤。 -### 报告详情 {#report-details} +### 在本地运行构建 {#running-builds-locally} -- **编译器**: `clang-19`,可选包括目标平台名称 -- **构建类型**: `Debug` 或 `RelWithDebInfo` (cmake)。 -- **检查器**: `none`(无检查器)、`address`(ASan)、`memory`(MSan)、`undefined`(UBSan)或 `thread`(TSan)。 -- **状态**: `success` 或 `fail` -- **构建日志**: 指向构建和文件复制日志的链接,构建失败时有用。 -- **构建时间**。 -- **工件**: 构建结果文件(其中 `XXX` 是服务器版本,例如 `20.8.1.4344`)。 - - `clickhouse-client_XXX_amd64.deb` - - `clickhouse-common-static-dbg_XXX[+asan, +msan, +ubsan, +tsan]_amd64.deb` - - `clickhouse-common-staticXXX_amd64.deb` - - `clickhouse-server_XXX_amd64.deb` - - `clickhouse`: 主要构建的二进制文件。 - - `clickhouse-odbc-bridge` - - `unit_tests_dbms`: 包含ClickHouse单元测试的 GoogleTest 二进制文件。 - - `performance.tar.zst`: 用于性能测试的特殊包。 +构建可以在 CI 类似环境中本地运行,命令为: -## 特殊构建检查 {#special-build-check} -使用 `clang-tidy` 进行静态分析和代码风格检查。报告类似于 [构建检查](#build-check)。修复构建日志中发现的错误。 +```bash +python -m ci.praktika run "" +``` -#### 在本地运行 clang-tidy: {#running-clang-tidy-locally} +除了 Python 3 和 Docker 以外,不需要其他依赖项。 -这里有一个便利的 `packager` 脚本在docker中运行clang-tidy构建 -```sh -mkdir build_tidy -./docker/packager/packager --output-dir=./build_tidy --package-type=binary --compiler=clang-19 --debug-build --clang-tidy +#### 可用构建作业 {#available-build-jobs} + +构建作业名称与 CI 报告中显示的名称完全相同: + +**AMD64 构建:** +- `Build (amd_debug)` - 带符号的调试构建 +- `Build (amd_release)` - 优化的发布构建 +- `Build (amd_asan)` - 地址检测工具构建 +- `Build (amd_tsan)` - 线程检测工具构建 +- `Build (amd_msan)` - 内存检测工具构建 +- `Build (amd_ubsan)` - 未定义行为检测工具构建 +- `Build (amd_binary)` - 不带 Thin LTO 的快速发布构建 +- `Build (amd_compat)` - 旧系统的兼容构建 +- `Build (amd_musl)` - 采用 musl libc 的构建 +- `Build (amd_darwin)` - macOS 构建 +- `Build (amd_freebsd)` - FreeBSD 构建 + +**ARM64 构建:** +- `Build (arm_release)` - ARM64 优化发布构建 +- `Build (arm_asan)` - ARM64 地址检测工具构建 +- `Build (arm_coverage)` - 带覆盖工具的 ARM64 构建 +- `Build (arm_binary)` - 不带 Thin LTO 的 ARM64 快速发布构建 +- `Build (arm_darwin)` - macOS ARM64 构建 +- `Build (arm_v80compat)` - ARMv8.0 兼容构建 + +**其他架构:** +- `Build (ppc64le)` - PowerPC 64位小端 +- `Build (riscv64)` - RISC-V 64位 +- `Build (s390x)` - IBM System/390 64位 +- `Build (loongarch64)` - LoongArch 64位 + +如果作业成功,构建结果将保存在 `/ci/tmp/build` 目录中。 + +**注意:** 对于不在“其他架构”类别中的构建(使用交叉编译),您的本地机器架构必须与所请求的 `BUILD_JOB_NAME` 构建类型匹配,以生成所请求的构建。 + +#### 示例 {#example-run-local} + +要运行本地调试构建: + +```bash +python -m ci.praktika run "Build (amd_debug)" ``` +如果上述方法对您无效,请使用构建日志中的 cmake 选项,并遵循 [一般构建过程](../development/build.md)。 ## 无状态功能测试 {#functional-stateless-tests} -对以各种配置构建的 ClickHouse 二进制文件运行 [无状态功能测试](tests.md#functional-tests) -- 发布、调试、带检查器等。查看报告以查看哪些测试失败,然后按照 [这里](../development/tests#functional-tests) 中的描述在本地重现故障。请注意,您必须使用正确的构建配置进行重现 -- 在 AddressSanitizer 下测试可能会失败,但在 Debug 下通过。下载 [CI 构建检查页面](/install/advanced) 中的二进制文件,或在本地构建它。 - -## 有状态功能测试 {#functional-stateful-tests} -运行 [有状态功能测试](tests.md#functional-tests)。像处理无状态功能测试一样对待它们。不同之处在于它们需要来自 [clickstream 数据集](../getting-started/example-datasets/metrica.md) 的 `hits` 和 `visits` 表才能运行。 +为在各种配置中构建的 ClickHouse 二进制文件运行 [无状态功能测试](tests.md#functional-tests) -- 发布、调试、带有检测工具等。查看报告以了解哪些测试失败,然后根据 [这里](../development/tests#functional-tests) 的说明在本地重现故障。请注意,您必须使用正确的构建配置进行重现 -- 一个测试可能在 AddressSanitizer 下失败,但在 Debug 下通过。请从 [CI 构建检查页面](/install/advanced) 下载二进制文件,或在本地构建它。 ## 集成测试 {#integration-tests} + 运行 [集成测试](tests.md#integration-tests)。 -## 错误修复验证检查 {#bugfix-validate-check} +## Bug 修复验证检查 {#bugfix-validate-check} -检查是新测试(功能或集成)还是某些失败的已更改测试,使用与主分支上构建的二进制文件。此检查在拉取请求具有 "pr-bugfix" 标签时触发。 +检查是否有新的测试(功能或集成)或有一些更改过的测试在使用 master 分支构建的二进制文件时失败。此检查在拉取请求带有 "pr-bugfix" 标签时触发。 ## 压力测试 {#stress-test} + 从多个客户端并发运行无状态功能测试,以检测与并发相关的错误。如果失败: -* 首先修复所有其他测试失败; -* 查看报告查找服务器日志,并检查可能导致错误的原因。 + * 首先修复所有其他测试失败; + * 查看报告以查找服务器日志并检查可能的错误原因。 ## 兼容性检查 {#compatibility-check} -检查 `clickhouse` 二进制文件是否在旧 libc 版本的发行版上运行。如果失败,请向维护者寻求帮助。 +检查 `clickhouse` 二进制文件是否在旧 libc 版本的分发版上运行。如果失败,请询问维护者寻求帮助。 -## AST Fuzzer {#ast-fuzzer} -运行随机生成的查询以捕捉程序错误。如果失败,请向维护者寻求帮助。 +## AST 模糊测试 {#ast-fuzzer} + +运行随机生成的查询以捕捉程序错误。如果失败,请询问维护者寻求帮助。 ## 性能测试 {#performance-tests} -测量查询性能的变化。这是耗时最长的检查,运行时间略低于6小时。性能测试报告的详细信息请参见 [此处](https://github.com/ClickHouse/ClickHouse/tree/master/docker/test/performance-comparison#how-to-read-the-report)。 + +测量查询性能的变化。这是最长的检查,运行时间略少于 6 小时。性能测试报告的详细描述见 [这里](https://github.com/ClickHouse/ClickHouse/tree/master/docker/test/performance-comparison#how-to-read-the-report)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/development/continuous-integration.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/development/continuous-integration.md.hash index 2761f34ff09..09a02356c8d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/development/continuous-integration.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/development/continuous-integration.md.hash @@ -1 +1 @@ -fab57c31f3e619e8 +bdbc5476392c3548 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/development/contrib.md b/i18n/zh/docusaurus-plugin-content-docs/current/development/contrib.md index 7df0eae9c22..052d73e4c79 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/development/contrib.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/development/contrib.md @@ -1,51 +1,41 @@ --- -'description': '页面描述 ClickHouse 第三方使用以及如何添加和维护第三方库。' +'description': '页面描述 ClickHouse 第三方使用及如何添加和维护第三方库。' 'sidebar_label': '第三方库' 'sidebar_position': 60 'slug': '/development/contrib' 'title': '第三方库' +'doc_type': 'reference' --- # 第三方库 -ClickHouse 利用第三方库来实现不同的功能,例如,连接到其他数据库,在加载/保存数据时对数据进行解码/编码,或实现某些特殊的 SQL 函数。 -为了使 ClickHouse 独立于目标系统中可用的库,每个第三方库都作为 Git 子模块导入到 ClickHouse 的源代码树中,并与 ClickHouse 一起编译和链接。 -可以通过以下查询获取第三方库及其许可证的列表: +ClickHouse 利用第三方库来完成不同的任务,例如连接到其他数据库、在从磁盘加载/保存数据时进行解码/编码,或实现某些特定的 SQL 函数。为了独立于目标系统中可用的库,每个第三方库作为 Git 子模块导入到 ClickHouse 的源代码树中,并与 ClickHouse 编译和链接。可以通过以下查询获取第三方库及其许可证的列表: ```sql SELECT library_name, license_type, license_path FROM system.licenses ORDER BY library_name COLLATE 'en'; ``` -请注意,列出的库是位于 ClickHouse 存储库的 `contrib/` 目录中的库。 -根据构建选项,某些库可能未被编译,因此它们的功能在运行时可能不可用。 +请注意,列出的库位于 ClickHouse 仓库的 `contrib/` 目录中。根据构建选项,某些库可能未被编译,因此,它们的功能可能在运行时不可用。 [示例](https://sql.clickhouse.com?query_id=478GCPU7LRTSZJBNY3EJT3) ## 添加和维护第三方库 {#adding-and-maintaining-third-party-libraries} -每个第三方库必须位于 ClickHouse 存储库的 `contrib/` 目录下的专用目录中。 -请避免将外部代码的副本直接放入库目录中。 -相反,创建一个 Git 子模块从外部上游存储库中获取第三方代码。 +每个第三方库必须位于 ClickHouse 仓库 `contrib/` 目录下的专用目录中。避免将外部代码的副本放入库目录中。相反,创建一个 Git 子模块以从外部上游仓库中拉取第三方代码。 -ClickHouse 使用的所有子模块都在 `.gitmodule` 文件中列出。 -- 如果库可以按原样使用(默认情况),则可以直接引用上游存储库。 -- 如果库需要打补丁,请在 [ClickHouse GitHub 组织](https://github.com/ClickHouse) 中创建上游存储库的分叉。 +ClickHouse 使用的所有子模块都列在 `.gitmodule` 文件中。 +- 如果库可以直接使用(默认情况),您可以直接引用上游仓库。 +- 如果库需要打补丁,请在 [ClickHouse GitHub 组织](https://github.com/ClickHouse) 中创建上游仓库的分支。 -在后一个情况下,我们旨在尽可能将自定义补丁与上游提交隔离。 -为此,从要集成的分支或标签创建一个以 `ClickHouse/` 为前缀的分支,例如 `ClickHouse/2024_2`(对于分支 `2024_2`)或 `ClickHouse/release/vX.Y.Z`(对于标签 `release/vX.Y.Z`)。 -请避免跟踪上游开发分支 `master` / `main` / `dev`(即,在分叉库中以 `ClickHouse/master` / `ClickHouse/main` / `ClickHouse/dev` 为前缀的分支)。 -这样的分支是移动目标,这使得适当版本控制变得更加困难。 -“前缀分支”确保从上游存储库到分叉的拉取不会影响自定义的 `ClickHouse/` 分支。 -`contrib/` 中的子模块必须只跟踪分叉的第三方库的 `ClickHouse/` 分支。 +在后者的情况下,我们的目标是尽可能将自定义补丁与上游提交隔离开。为此,从您想要集成的分支或标签创建一个以 `ClickHouse/` 为前缀的分支,例如 `ClickHouse/2024_2`(针对分支 `2024_2`)或 `ClickHouse/release/vX.Y.Z`(针对标签 `release/vX.Y.Z`)。避免跟随上游开发分支 `master`/ `main` / `dev`(即,分支前缀为 `ClickHouse/master` / `ClickHouse/main` / `ClickHouse/dev`)。这样的分支是流动目标,这使得适当的版本控制变得更加困难。“前缀分支”确保从上游仓库到分叉的提取不会影响自定义的 `ClickHouse/` 分支。`contrib/` 中的子模块只能跟踪分叉的第三方库的 `ClickHouse/` 分支。 补丁仅适用于外部库的 `ClickHouse/` 分支。 有两种方法可以做到这一点: -- 如果您想在分叉库的 `ClickHouse/` 前缀分支上进行新修复,例如一个清理器修复。在这种情况下,将修复推送为一个以 `ClickHouse/` 为前缀的分支,例如 `ClickHouse/fix-sanitizer-disaster`。然后从新分支创建一个 PR,目标为自定义跟踪分支,例如 `ClickHouse/2024_2 <-- ClickHouse/fix-sanitizer-disaster`,并合并 PR。 -- 如果您更新了子模块并需要重新应用早期的补丁。在这种情况下,重新创建旧 PR 是多余的。相反,只需将旧提交 cherry-pick 到新的 `ClickHouse/` 分支(对应于新版本)。如果 PR 具有多个提交,可以自由地将其合并。在最佳情况下,我们已经将自定义补丁贡献回上游,从而在新版本中可以省略补丁。 +- 如果您希望在分叉的仓库中针对 `ClickHouse/` 前缀分支进行新的修复,例如一个清理器修复。在这种情况下,将修复作为带有 `ClickHouse/` 前缀的分支推送,例如 `ClickHouse/fix-sanitizer-disaster`。然后从新分支创建一个 PR 针对自定义跟踪分支,例如 `ClickHouse/2024_2 <-- ClickHouse/fix-sanitizer-disaster` 并合并 PR。 +- 如果您更新了子模块并需要重新应用早期补丁。在这种情况下,重新创建旧 PR 是多余的。相反,只需将较旧的提交挑选到新的 `ClickHouse/` 分支中(对应新的版本)。对于曾经有多个提交的 PR,您可以随意合并提交。在最佳情况下,我们已经将自定义补丁贡献回上游,可以在新版本中省略补丁。 -一旦子模块更新,便在 ClickHouse 中提高子模块的版本以指向分叉中的新哈希。 +一旦子模块更新,提升 ClickHouse 中的子模块以指向分叉中的新哈希。 -创建第三方库的补丁时,请考虑官方存储库,并考虑将补丁反馈到上游存储库。 -这确保其他人也能从补丁中受益,并且不会给 ClickHouse 团队带来维护负担。 +根据官方仓库创建第三方库的补丁,并考虑将补丁贡献回上游仓库。这样可以确保其他人也可以受益于该补丁,同时不会给 ClickHouse 团队带来维护负担。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/development/contrib.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/development/contrib.md.hash index fe4f72b3a72..5c30f867271 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/development/contrib.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/development/contrib.md.hash @@ -1 +1 @@ -2eafd19d10897906 +f6fa87108f9d7d69 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/development/developer-instruction.md b/i18n/zh/docusaurus-plugin-content-docs/current/development/developer-instruction.md index c434c9d08a1..9620adf8f4a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/development/developer-instruction.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/development/developer-instruction.md @@ -3,59 +3,54 @@ 'sidebar_label': '先决条件' 'sidebar_position': 5 'slug': '/development/developer-instruction' -'title': '开发人员先决条件' +'title': '开发者先决条件' +'doc_type': 'guide' --- # 先决条件 -ClickHouse 可以在 Linux、FreeBSD 和 macOS 上构建。 -如果你使用 Windows,你仍然可以在运行 Linux 的虚拟机中构建 ClickHouse,例如 使用 [VirtualBox](https://www.virtualbox.org/) 的 Ubuntu。 +ClickHouse 可以在 Linux、FreeBSD 和 macOS 上构建。如果你使用 Windows,仍然可以在虚拟机中运行 Linux 来构建 ClickHouse,例如使用 [VirtualBox](https://www.virtualbox.org/) 及 Ubuntu。 ## 在 GitHub 上创建一个仓库 {#create-a-repository-on-github} -要开始为 ClickHouse 开发,你需要一个 [GitHub](https://www.github.com/) 账户。 -请在本地生成一个 SSH 密钥(如果你还没有的话),并将公钥上传到 GitHub,因为这对于贡献补丁是一个前提。 +要开始为 ClickHouse 开发,你需要一个 [GitHub](https://www.github.com/) 账户。请同时在本地生成一个 SSH 密钥(如果你还没有的话),并将公钥上传到 GitHub,因为这是贡献补丁的先决条件。 -接下来,在你的个人账户中通过点击右上角的“fork”按钮来分叉 [ClickHouse 仓库](https://github.com/ClickHouse/ClickHouse/)。 +接下来,通过点击右上角的“fork”按钮,在你的个人账户中复制 [ClickHouse 仓库](https://github.com/ClickHouse/ClickHouse/)。 -要提交更改,例如修复问题或添加功能,首先将更改提交到你分叉的一个分支中,然后创建一个与主仓库的“Pull Request”。 +要贡献更改,例如,修复一个问题或添加一个功能,首先把你的更改提交到你 fork 的一个分支中,然后创建一个“拉取请求”(Pull Request),将更改提交给主仓库。 -要使用 Git 仓库,请安装 Git。例如,在 Ubuntu 中运行: +关于 Git 仓库的工作,请安装 Git。例如,在 Ubuntu 中运行: ```sh sudo apt update sudo apt install git ``` -你可以在 [这里](https://education.github.com/git-cheat-sheet-education.pdf) 找到 Git 速查表。 -详细的 Git 手册在 [这里](https://git-scm.com/book/en/v2)。 +可以在 [这里](https://education.github.com/git-cheat-sheet-education.pdf) 找到 Git 速查手册。详细的 Git 手册可以在 [这里](https://git-scm.com/book/en/v2)。 ## 将仓库克隆到你的开发机器 {#clone-the-repository-to-your-development-machine} -首先,将源文件下载到你的工作机器,也就是克隆仓库: +首先,将源文件下载到你的工作机器,即克隆仓库: ```sh git clone git@github.com:your_github_username/ClickHouse.git # replace the placeholder with your GitHub user name cd ClickHouse ``` -此命令创建一个名为 `ClickHouse/` 的目录,其中包含源代码、测试和其他文件。 -你可以在 URL 后指定一个自定义目录用于检出,但重要的是此路径不能包含空格,因为这可能会在后续构建中出错。 +此命令会创建一个名为 `ClickHouse/` 的目录,其中包含源代码、测试和其他文件。你可以在 URL 后指定一个自定义目录进行检出,但重要的是这个路径不能包含空格,因为这可能会在之后的构建中造成问题。 -ClickHouse 的 Git 仓库使用子模块来引入第三方库。 -默认情况下,子模块不会被检出。 -你可以选择 +ClickHouse 的 Git 仓库使用子模块来拉取第三方库。子模块默认情况下不会被检出。你可以选择: -- 运行 `git clone`,并带上 `--recurse-submodules` 选项, +- 使用 `--recurse-submodules` 选项运行 `git clone`, -- 如果 `git clone` 在没有 `--recurse-submodules` 的情况下运行,运行 `git submodule update --init --jobs ` 来显式检出所有子模块。 (`` 可以设置为,例如 `12`,以并行下载。) +- 如果 `git clone` 是在没有 `--recurse-submodules` 的情况下运行的,请运行 `git submodule update --init --jobs ` 来显式检出所有子模块。(`` 可以设置为例如 `12` 以并行下载。) -- 如果 `git clone` 在没有 `--recurse-submodules` 的情况下运行,并且你希望使用 [稀疏](https://github.blog/2020-01-17-bring-your-monorepo-down-to-size-with-sparse-checkout/) 和 [浅层](https://github.blog/2020-12-21-get-up-to-speed-with-partial-clone-and-shallow-clone/) 子模块检出,以省略不需要的文件和历史记录以节省空间(大约 5 GB 而不是大约 15 GB),运行 `./contrib/update-submodules.sh`。此替代方案由 CI 使用,但不建议用于本地开发,因为它使得使用子模块变得更不方便且更慢。 +- 如果 `git clone` 是在没有 `--recurse-submodules` 的情况下运行的,并且你想使用 [稀疏](https://github.blog/2020-01-17-bring-your-monorepo-down-to-size-with-sparse-checkout/) 和 [浅层](https://github.blog/2020-12-21-get-up-to-speed-with-partial-clone-and-shallow-clone/) 子模块检出以省略不需要的文件和历史记录从而节省空间(大约 5 GB 而不是大约 15 GB),请运行 `./contrib/update-submodules.sh`。这个替代方法被 CI 使用,但不推荐用于本地开发,因为它会使处理子模块变得不方便且较慢。 -要检查 Git 子模块的状态,运行 `git submodule status`。 +要检查 Git 子模块的状态,请运行 `git submodule status`。 -如果你收到以下错误信息 +如果你收到以下错误信息: ```bash Permission denied (publickey). @@ -65,9 +60,7 @@ Please make sure you have the correct access rights and the repository exists. ``` -则表示缺少用于连接到 GitHub 的 SSH 密钥。 -这些密钥通常位于 `~/.ssh`。 -为了让 SSH 密钥被接受,你需要在 GitHub 的设置中上传它们。 +表示连接到 GitHub 的 SSH 密钥丢失。这些密钥通常位于 `~/.ssh`。为了使 SSH 密钥被接受,你需要在 GitHub 的设置中上传它们。 你也可以通过 HTTPS 克隆仓库: @@ -75,10 +68,9 @@ and the repository exists. git clone https://github.com/ClickHouse/ClickHouse.git ``` -然而,这样你将无法向服务器发送你的更改。 -你仍然可以暂时使用它,稍后添加 SSH 密钥,并使用 `git remote` 命令替换仓库的远程地址。 +但是,这样将无法将你的更改推送到服务器。你仍然可以暂时使用它,稍后再添加 SSH 密钥,使用 `git remote` 命令替换仓库的远程地址。 -你也可以将原始 ClickHouse 仓库地址添加到你的本地仓库,以从那里拉取更新: +你还可以将原始的 ClickHouse 仓库地址添加到你的本地仓库中,以从那里拉取更新: ```sh git remote add upstream git@github.com:ClickHouse/ClickHouse.git @@ -87,58 +79,44 @@ git remote add upstream git@github.com:ClickHouse/ClickHouse.git 成功运行此命令后,你将能够通过运行 `git pull upstream master` 从主 ClickHouse 仓库拉取更新。 :::tip -请勿直接使用 `git push`,你可能会推送到错误的远程和/或错误的分支。 -最好明确指定远程和分支名称,例如 `git push origin my_branch_name`。 +请不要直接使用 `git push`,你可能会推送到错误的远程和/或错误的分支。最好明确指定远程和分支名称,例如 `git push origin my_branch_name`。 ::: ## 编写代码 {#writing-code} -以下是一些在为 ClickHouse 编写代码时可能有用的快速链接: +在这里你可以找到一些在为 ClickHouse 编写代码时可能有用的快速链接: - [ClickHouse 架构](/development/architecture/)。 - [代码风格指南](/development/style/)。 - [第三方库](/development/contrib#adding-and-maintaining-third-party-libraries) - [编写测试](/development/tests/) -- [开放问题](https://github.com/ClickHouse/ClickHouse/issues?q=is%3Aopen+is%3Aissue+label%3A%22easy+task%22) +- [打开的问题](https://github.com/ClickHouse/ClickHouse/issues?q=is%3Aopen+is%3Aissue+label%3A%22easy+task%22) ### IDE {#ide} -[Visual Studio Code](https://code.visualstudio.com/) 和 [Neovim](https://neovim.io/) 是过去开发 ClickHouse 时非常适用的两个选项。如果你在使用 VS Code,我们建议使用 [clangd 扩展](https://marketplace.visualstudio.com/items?itemName=llvm-vs-code-extensions.vscode-clangd) 来替代 IntelliSense,因为它性能更佳。 +[Visual Studio Code](https://code.visualstudio.com/) 和 [Neovim](https://neovim.io/) 是过去在开发 ClickHouse 时效果良好的两个选项。如果你使用 VS Code,我们推荐使用 [clangd 扩展](https://marketplace.visualstudio.com/items?itemName=llvm-vs-code-extensions.vscode-clangd) 来替代 IntelliSense,因为它的性能更优。 -[CLion](https://www.jetbrains.com/clion/) 是另一个很好的替代品。然而,在像 ClickHouse 这样的大型项目上可能会比较慢。使用 CLion 时需要注意几件事: +[CLion](https://www.jetbrains.com/clion/) 是另一个不错的替代品。然而,在像 ClickHouse 这样的大型项目上可能会比较慢。使用 CLion 时需要注意一些事项: -- CLion 会自行创建一个 `build` 路径,并自动选择 `debug` 作为构建类型 -- 它使用的 CMake 版本是在 CLion 中定义的,而不是你安装的版本 +- CLion 会自动创建一个 `build` 路径,默认选择 `debug` 作为构建类型 +- 它使用 CLion 中定义的版本的 CMake,而不是你安装的版本 - CLion 将使用 `make` 来运行构建任务,而不是 `ninja`(这是正常行为) -你还可以使用其他 IDE,例如 [Sublime Text](https://www.sublimetext.com/)、[Qt Creator](https://www.qt.io/product/development-tools) 或 [Kate](https://kate-editor.org/)。 +你还可以使用其他 IDE,如 [Sublime Text](https://www.sublimetext.com/)、[Qt Creator](https://www.qt.io/product/development-tools) 或 [Kate](https://kate-editor.org/)。 -## 创建 Pull Request {#create-a-pull-request} +## 创建拉取请求 {#create-a-pull-request} -在 GitHub 的 UI 中导航到你的分叉仓库。 -如果你在一个分支中进行开发,你需要选择该分支。 -界面上将会有一个“Pull request”按钮。 -本质上,这意味着“创建一个请求以接受我的更改到主仓库”。 +在 GitHub 的 UI 中导航到你的 fork 仓库。如果你在一个分支中进行开发,你需要选择那个分支。屏幕上会有一个“拉取请求”按钮。从本质上讲,这意味着“创建一个请求以接受我的更改到主仓库中”。 -即使工作尚未完成,也可以创建一个 Pull Request。 -在这种情况下,请在标题的开头加上“WIP”(进行中的工作),待后续修改。 -这对于协作审核和讨论更改以及运行所有可用测试来说非常有用。 -重要的是你要提供一个对你所做更改的简要描述,以后用于生成发布变更日志。 +即使工作尚未完成,也可以创建拉取请求。在这种情况下,请在标题的开头加上“WIP”(进行中的工作),稍后可以更改。这对于协作审查和更改讨论以及运行所有可用测试非常有用。重要的是要提供对你更改的简要描述,后来将用于生成发布的变更日志。 -一旦 ClickHouse 员工为你的 PR 添加了“可以测试”的标签,测试将立即开始。 -一些初步检查(例如代码风格)的结果将在几分钟内返回。 -构建检查结果将在半小时内返回。 -主要的测试结果将在一小时内报告。 +测试将在 ClickHouse 员工将你的 PR 标记为“可以测试”后开始。一些初步检查(如代码风格)的结果将在几分钟内反馈。构建检查结果将在半小时内到达。主要测试集将在一小时内报告结果。 -系统将会为你的 Pull Request 单独准备 ClickHouse 二进制构建。 -要检索这些构建,单击在检查列表中“构建”条目旁的“详细信息”链接。 -在那里你将找到构建的 ClickHouse .deb 包的直接链接,你可以在生产服务器上进行部署(如果你不怕的话)。 +系统将为你的拉取请求单独准备 ClickHouse 二进制构建。要获取这些构建,请单击检查列表中的“构建”条目旁的“详细信息”链接。在那里你将找到构建的 ClickHouse .deb 包的直接链接,你可以在你的生产服务器上部署这些包(如果你不害怕的话)。 ## 编写文档 {#write-documentation} -每个添加新功能的 Pull Request 必须附带适当的文档。 -如果你想预览文档的更改,README.md 文件中提供了如何在本地构建文档页面的说明 [这里](https://github.com/ClickHouse/clickhouse-docs)。 -在 ClickHouse 中添加新功能时,可以使用以下模板作为指南: +每个添加新功能的拉取请求都必须附带适当的文档。如果你想预览文档更改,可以在 [这里](https://github.com/ClickHouse/clickhouse-docs) 的 README.md 文件中找到如何在本地构建文档页面的说明。当向 ClickHouse 添加新函数时,可以使用下面的模板作为指南: ```markdown @@ -185,10 +163,7 @@ Response: ## 使用测试数据 {#using-test-data} -开发 ClickHouse 通常需要加载真实的 数据集。 -这对性能测试尤其重要。 -我们准备了一套经过匿名化处理的网页分析数据。 -它额外需要大约 3GB 的可用磁盘空间。 +开发 ClickHouse 通常需要加载真实的数据集。这对于性能测试尤为重要。我们有一套特别准备的匿名网络分析数据集。它另外需要大约 3GB 的可用磁盘空间。 ```sh sudo apt install wget xz-utils diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/development/developer-instruction.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/development/developer-instruction.md.hash index d110e0ea572..ddc55da10a0 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/development/developer-instruction.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/development/developer-instruction.md.hash @@ -1 +1 @@ -1e4a13cc81c6cf75 +8569ad87629adc21 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/development/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/development/index.md index 23dbbef3107..a56f4e0c262 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/development/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/development/index.md @@ -1,14 +1,37 @@ --- -'description': '开发与贡献的索引页' +'description': '开发与贡献的索引页面' 'slug': '/development/' 'title': '开发与贡献' +'doc_type': 'landing-page' --- -在文档的这一部分,您将找到以下页面: +在本节文档中,您将找到以下页面: - + If you've spotted an error or wish to improve the descriptions, please edit + the files themselves directly. +--> + + +| 页面 | 描述 | +|-----|-----| +| [开发者先决条件](/development/developer-instruction) | ClickHouse 开发的先决条件和设置说明 | +| [如何在 Linux 上构建 ClickHouse](/development/build) | 在 Linux 系统上从源代码构建 ClickHouse 的逐步指南 | +| [在 macOS 上构建 ClickHouse](/development/build-osx) | 从源代码在 macOS 系统上构建 ClickHouse 的指南 | +| [在 Linux 上为 macOS 构建 ClickHouse](/development/build-cross-osx) | 从 Linux 为 macOS 系统进行交叉编译 ClickHouse 的指南 | +| [如何为 AARCH64 在 Linux 上构建 ClickHouse](/development/build-cross-arm) | 为 AARCH64 架构从源代码构建 ClickHouse 的指南 | +| [如何为 RISC-V 64 在 Linux 上构建 ClickHouse](/development/build-cross-riscv) | 为 RISC-V 64 架构从源代码构建 ClickHouse 的指南 | +| [在 Linux 上为 s390x (zLinux) 构建 ClickHouse](/development/build-cross-s390x) | 为 s390x 架构从源代码构建 ClickHouse 的指南 | +| [在 Linux 上为 LoongArch64 构建 ClickHouse](/development/build-cross-loongarch) | 为 LoongArch64 架构从源代码构建 ClickHouse 的指南 | +| [测试 ClickHouse](/development/tests) | 测试 ClickHouse 和运行测试套件的指南 | +| [架构概述](/development/architecture) | ClickHouse 架构及其列式设计的全面概述 | +| [持续集成 (CI)](/development/continuous-integration) | ClickHouse 持续集成系统的概述 | +| [第三方库](/development/contrib) | 描述 ClickHouse 第三方使用及如何添加和维护第三方库的页面。 | +| [C++ 风格指南](/development/style) | ClickHouse C++ 开发的编码风格指南 | +| [使用 DEFLATE_QPL 构建 Clickhouse](/development/building_and_benchmarking_deflate_qpl) | 如何构建 Clickhouse 并使用 DEFLATE_QPL 编解码器运行基准测试 | +| [集成 Rust 库](/development/integrating_rust_libraries) | 将 Rust 库集成到 ClickHouse 的指南 | + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/development/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/development/index.md.hash index 801a7b158e6..8b2736185b8 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/development/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/development/index.md.hash @@ -1 +1 @@ -ec8484da48265e6d +3f53f983d14cd3f1 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/development/integrating_rust_libraries.md b/i18n/zh/docusaurus-plugin-content-docs/current/development/integrating_rust_libraries.md index f481bf8253c..25cf5409873 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/development/integrating_rust_libraries.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/development/integrating_rust_libraries.md @@ -1,18 +1,19 @@ --- 'description': '将 Rust 库集成到 ClickHouse 的指南' -'sidebar_label': 'Rust 库' +'sidebar_label': 'Rust Libraries' 'slug': '/development/integrating_rust_libraries' 'title': '集成 Rust 库' +'doc_type': 'guide' --- # Rust 库 -Rust 库集成将基于 BLAKE3 哈希函数的集成进行描述。 +Rust 库的集成将基于 BLAKE3 哈希函数的集成进行描述。 -集成的第一步是将库添加到 /rust 文件夹。为此,您需要创建一个空的 Rust 项目,并在 Cargo.toml 中包含所需的库。还需要通过在 Cargo.toml 中添加 `crate-type = ["staticlib"]` 来将新库的编译配置为静态。 +集成的第一步是将库添加到 /rust 文件夹中。为此,您需要创建一个空的 Rust 项目并在 Cargo.toml 中包含所需的库。此外,还需要通过在 Cargo.toml 中添加 `crate-type = ["staticlib"]` 来配置新的库编译为静态库。 -接下来,您需要使用 Corrosion 库将库链接到 CMake。第一步是在 /rust 文件夹内的 CMakeLists.txt 中添加库文件夹。之后,您应该将 CMakeLists.txt 文件添加到库目录。在其中,您需要调用 Corrosion 导入函数。这些行用于导入 BLAKE3: +接下来,您需要使用 Corrosion 库将库链接到 CMake。第一步是在 /rust 文件夹内的 CMakeLists.txt 中添加库文件夹。之后,您应该在库目录中添加 CMakeLists.txt 文件。在其中,您需要调用 Corrosion 导入函数。这些行用于导入 BLAKE3: ```CMake corrosion_import_crate(MANIFEST_PATH Cargo.toml NO_STD) @@ -21,9 +22,9 @@ target_include_directories(_ch_rust_blake3 INTERFACE include) add_library(ch_rust::blake3 ALIAS _ch_rust_blake3) ``` -因此,我们将使用 Corrosion 创建一个正确的 CMake 目标,然后用一个更方便的名称重命名它。请注意,名称 `_ch_rust_blake3` 来自 Cargo.toml,其中被用作项目名称(`name = "_ch_rust_blake3"`)。 +因此,我们将使用 Corrosion 创建一个正确的 CMake 目标,然后使用一个更便利的名称重命名它。请注意,名称 `_ch_rust_blake3` 来自 Cargo.toml,其中它被用作项目名称(`name = "_ch_rust_blake3"`)。 -由于 Rust 数据类型与 C/C++ 数据类型不兼容,我们将使用我们的空库项目创建用于转换从 C/C++ 接收到的数据的 shim 方法,调用库方法,以及输出数据的逆转换。例如,针对 BLAKE3 编写了这个方法: +由于 Rust 数据类型与 C/C++ 数据类型不兼容,我们将使用我们的空库项目为从 C/C++ 接收的数据创建适配方法,调用库方法,并为输出数据进行反向转换。例如,针对 BLAKE3 编写了这个方法: ```rust #[no_mangle] @@ -53,11 +54,11 @@ pub unsafe extern "C" fn blake3_apply_shim( } ``` -该方法获取 C 兼容的字符串、其大小和输出字符串指针作为输入。然后,它将 C 兼容的输入转换为实际库方法使用的类型并调用它们。之后,它应将库方法的输出转换回 C 兼容类型。在该特定情况下,库支持通过方法 fill() 直接写入指针,因此不需要转换。这里的主要建议是创建尽可能少的方法,这样您在每次方法调用时需要进行更少的转换,并且不会产生太多开销。 +该方法以 C 兼容的字符串、其大小和输出字符串指针作为输入。然后,它将 C 兼容的输入转换为实际库方法所使用的类型并调用它们。在此之后,它应该将库方法的输出转换回 C 兼容类型。在这种特定情况下,库支持通过 fill() 方法直接写入指针,因此不需要转换。这里的主要建议是创建尽量少的方法,这样您在每次调用方法时需要进行的转换就会更少,不会产生过多的开销。 -值得注意的是,`#[no_mangle]` 属性和 `extern "C"` 对于所有此类方法都是强制性的。没有它们,将无法进行正确的 C/C++ 兼容编译。此外,它们对于集成的下一步也是必要的。 +值得注意的是,`#[no_mangle]` 属性和 `extern "C"` 对所有此类方法都是强制性的。没有它们,将无法执行正确的 C/C++ 兼容编译。此外,它们是集成的下一步所必需的。 -在编写 shim 方法的代码后,我们需要为库准备头文件。这可以手动完成,或者可以使用 cbindgen 库进行自动生成。如果使用 cbindgen,您需要编写一个 build.rs 构建脚本并将 cbindgen 作为构建依赖项。 +在编写完适配方法的代码后,我们需要为库准备头文件。这可以手动完成,或者您可以使用 cbindgen 库自动生成。在使用 cbindgen 的情况下,您需要编写一个 build.rs 构建脚本,并将 cbindgen 作为构建依赖项包含。 一个可以自动生成头文件的构建脚本示例: @@ -77,8 +78,9 @@ match cbindgen::generate(&crate_dir) { } ``` -此外,您应该对每个 C 兼容的属性使用属性 #[no_mangle] 和 `extern "C"`。没有这些,库可能会错误编译,并且 cbindgen 将无法启动头文件的自动生成。 +此外,您应该对每个 C 兼容的属性使用属性 #[no_mangle] 和 `extern "C"`。没有它,库可能会错误编译,cbindgen 将无法启动头文件的自动生成。 -在完成所有这些步骤后,您可以在一个小项目中测试您的库,以发现与兼容性或头文件生成相关的所有问题。如果在头文件生成过程中出现任何问题,您可以尝试使用 cbindgen.toml 文件进行配置(您可以在这里找到模板:[https://github.com/eqrion/cbindgen/blob/master/template.toml](https://github.com/eqrion/cbindgen/blob/master/template.toml))。 +完成所有这些步骤后,您可以在一个小项目中测试您的库,以查找与兼容性或头文件生成相关的所有问题。如果在头文件生成过程中出现任何问题,您可以尝试使用 cbindgen.toml 文件进行配置(您可以在这里找到模板:[https://github.com/eqrion/cbindgen/blob/master/template.toml](https://github.com/eqrion/cbindgen/blob/master/template.toml))。 -值得注意的是,在集成 BLAKE3 时出现的问题:MemorySanitizer 可能会导致误报,因为它无法判断 Rust 中的一些变量是否已初始化。通过为某些变量编写更明确的定义方法解决了这个问题,尽管这种实现方法较慢,并且仅用于修复 MemorySanitizer 构建。 +值得注意的是在集成 BLAKE3 时遇到的问题: +MemorySanitizer 可能会引发误报,因为它无法判断某些 Rust 中的变量是否已初始化。通过为某些变量编写更明确定义的方法解决了这个问题,尽管此方法的实现较慢,仅用于修复 MemorySanitizer 构建。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/development/integrating_rust_libraries.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/development/integrating_rust_libraries.md.hash index 8ba87948795..08e1e589d38 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/development/integrating_rust_libraries.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/development/integrating_rust_libraries.md.hash @@ -1 +1 @@ -41e87956ccbc1a66 +4602ecb1020e9a12 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/development/style.md b/i18n/zh/docusaurus-plugin-content-docs/current/development/style.md index 180e6e1a51f..884b572a9ca 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/development/style.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/development/style.md @@ -1,28 +1,29 @@ --- -'description': 'ClickHouse C++ 开发的编码风格指南' +'description': 'ClickHouse C++ 开发的编码风格准则' 'sidebar_label': 'C++ 风格指南' 'sidebar_position': 70 'slug': '/development/style' -'title': 'C++ 编程风格指南' +'title': 'C++ 风格指南' +'doc_type': 'guide' --- -# C++ 代码风格指南 +# C++ 风格指南 ## 一般建议 {#general-recommendations} 以下是建议,而非要求。 -如果您正在编辑代码,遵循现有代码的格式是合理的。 -代码风格对于一致性非常重要。一致性使得阅读代码更加容易,也使得搜索代码变得更简单。 -许多规则并没有逻辑上的理由,它们是由既定的实践所决定的。 +如果您正在编辑代码,遵循现有代码的格式是有意义的。 +代码风格是为了保持一致性。一致性使得阅读代码变得更容易,也使得代码搜索变得更简单。 +许多规则并没有逻辑理由;它们是由既定惯例所决定的。 -## 格式 {#formatting} +## 格式化 {#formatting} -**1.** 大部分格式由 `clang-format` 自动完成。 +**1.** 大部分格式化由 `clang-format` 自动执行。 -**2.** 缩进为4个空格。配置您的开发环境,使得一个制表符添加四个空格。 +**2.** 缩进为 4 个空格。配置您的开发环境,使制表符增加四个空格。 -**3.** 开始和结束的大括号必须单独占一行。 +**3.** 开始和结束的花括号必须在单独的一行上。 ```cpp inline void readBoolText(bool & x, ReadBuffer & buf) @@ -33,14 +34,14 @@ inline void readBoolText(bool & x, ReadBuffer & buf) } ``` -**4.** 如果整个函数体是一个单一的 `statement`,可以放在同一行。大括号周围要留出空格(除了行末的空格)。 +**4.** 如果整个函数体是单个 `statement`,则可以放在一行。花括号周围要加空格(除了行尾的空格)。 ```cpp inline size_t mask() const { return buf_size() - 1; } inline size_t place(HashValue x) const { return x & mask(); } ``` -**5.** 对于函数,不要在括号周围加空格。 +**5.** 对于函数,括号周围不加空格。 ```cpp void reinsert(const Value & x) @@ -50,13 +51,13 @@ void reinsert(const Value & x) memcpy(&buf[place_value], &x, sizeof(x)); ``` -**6.** 在 `if`、`for`、`while` 和其他表达式中,打开括号前要插入空格(与函数调用不同)。 +**6.** 在 `if`、`for`、`while` 和其他表达式中,在开括号前插入空格(与函数调用相反)。 ```cpp for (size_t i = 0; i < rows; i += storage.index_granularity) ``` -**7.** 在二进制运算符(`+`、`-`、`*`、`/`、`%` 等)及三元运算符 `?:` 周围添加空格。 +**7.** 在二元运算符(`+`、`-`、`*`、`/`、`%`,...)和三元运算符 `?:` 周围加空格。 ```cpp UInt16 year = (s[0] - '0') * 1000 + (s[1] - '0') * 100 + (s[2] - '0') * 10 + (s[3] - '0'); @@ -64,7 +65,7 @@ UInt8 month = (s[5] - '0') * 10 + (s[6] - '0'); UInt8 day = (s[8] - '0') * 10 + (s[9] - '0'); ``` -**8.** 如果输入了换行,将运算符换到新的一行,并在前面增加缩进。 +**8.** 如果输入了换行,操作符放在新的一行,并在其前面增加缩进。 ```cpp if (elapsed_ns) @@ -73,7 +74,7 @@ if (elapsed_ns) << bytes_read_on_server * 1000.0 / elapsed_ns << " MB/s.) "; ``` -**9.** 如果需要,您可以在一行内对齐使用空格。 +**9.** 如果需要,可以在一行内使用空格对齐。 ```cpp dst.ClickLogID = click.LogID; @@ -83,15 +84,15 @@ dst.ClickGoodEvent = click.GoodEvent; **10.** 不要在运算符 `.` 和 `->` 周围使用空格。 -如有必要,运算符可以换到下一行。在这种情况下,前面的缩进应增加。 +如有必要,运算符可以换到下一行。在这种情况下,前面的缩进要增加。 -**11.** 不要使用空格将一元运算符(`--`、`++`、`*`、`&` 等)与其参数分隔开。 +**11.** 不要用空格将一元运算符(`--`、`++`、`*`、`&`,...)与参数分开。 -**12.** 在逗号后加空格,但逗号前不加。对于 `for` 表达式中的分号同样适用。 +**12.** 在逗号后加空格,但在逗号前不加。对于 `for` 表达式中的分号也是同理。 -**13.** 不要使用空格将 `[]` 运算符分隔开。 +**13.** 不要使用空格分隔 `[]` 运算符。 -**14.** 在 `template <...>` 表达式中,`template` 和 `<` 之间要留空格;`<` 之后和 `>` 之前不留空格。 +**14.** 在 `template <...>` 表达式中,在 `template` 和 `<` 之间使用空格;在 `<` 之后或 `>` 之前不加空格。 ```cpp template @@ -99,7 +100,7 @@ struct AggregatedStatElement {} ``` -**15.** 在类和结构体中,使用 `public`、`private` 和 `protected` 与 `class/struct` 保持在同一级别,其余代码则缩进。 +**15.** 在类和结构中,`public`、`private` 和 `protected` 应与 `class/struct` 在同一水平,并缩进其余代码。 ```cpp template @@ -112,11 +113,11 @@ public: } ``` -**16.** 如果整个文件使用相同的 `namespace`,且没有其他重要内容,则不必在 `namespace` 内进行缩进。 +**16.** 如果整个文件使用同一个 `namespace`,并且没有其他重要内容,则在 `namespace` 内部不必缩进。 -**17.** 如果 `if`、`for`、`while` 或其他表达式的块只包含一个 `statement`,则括号是可选的。将 `statement` 放在单独的一行中。这条规则也适用于嵌套的 `if`、`for`、`while` 等。 +**17.** 如果 `if`、`for`、`while` 或其他表达式的块仅由一个 `statement` 构成,花括号是可选的。将 `statement` 放在单独的一行上。这条规则同样适用于嵌套的 `if`、`for`、`while`,... -但如果内部的 `statement` 包含大括号或 `else`,则外部块应使用大括号。 +但如果内部的 `statement` 包含花括号或 `else`,外部块应该用花括号书写。 ```cpp /// Finish write. @@ -126,7 +127,7 @@ for (auto & stream : streams) **18.** 行尾不应有空格。 -**19.** 源文件采用 UTF-8 编码。 +**19.** 源文件使用 UTF-8 编码。 **20.** 字符串字面量中可以使用非 ASCII 字符。 @@ -134,13 +135,13 @@ for (auto & stream : streams) << ", " << (timer.elapsed() / chunks_stats.hits) << " μsec/hit."; ``` -**21.** 不要在同一行中写多个表达式。 +**21.** 不要在单行内写多个表达式。 -**22.** 在函数内部对代码部分进行分组,并用不超过一行的空行进行分隔。 +**22.** 在函数内部对代码段进行分组,并用最多一行空行分隔它们。 -**23.** 使用一到两行空行分隔函数、类等。 +**23.** 用一到两个空行分隔函数、类等。 -**24.** `A const`(与值有关的)必须写在类型名之前。 +**24.** `A const`(与值相关)必须在类型名称之前书写。 ```cpp //correct @@ -150,7 +151,7 @@ const std::string & s char const * pos ``` -**25.** 声明指针或引用时,`*` 和 `&` 符号应在两侧用空格分隔。 +**25.** 声明指针或引用时,`*` 和 `&` 符号应在两边都加空格。 ```cpp //correct @@ -160,11 +161,11 @@ const char* pos const char *pos ``` -**26.** 在使用模板类型时,使用 `using` 关键字为它们命名(除了最简单的情况)。 +**26.** 使用模板类型时,用 `using` 关键字进行别名(除了最简单的情况)。 -换句话说,模板参数仅在 `using` 中指定,且不在代码中重复。 +换句话说,模板参数仅在 `using` 中指定,而不会在代码中重复。 -`using` 可以在函数内部局部声明。 +`using` 可以在局部声明,例如在函数内部。 ```cpp //correct @@ -190,17 +191,17 @@ std::cerr << (int)c <<; std::endl; std::cerr << static_cast(c) << std::endl; ``` -**29.** 在类和结构体中,按可见性范围分别分组成员和函数。 +**29.** 在类和结构中,按每个可见性范围分别分组成员和函数。 -**30.** 对于小型类和结构体,不必将方法声明与实现分开。 +**30.** 对于小型类和结构,无需将方法声明与实现分开。 -对于任何类或结构体中的小型方法也同样适用。 +同样,任何类或结构中的小型方法也是如此。 -对于模板类和结构体,不要将方法声明与实现分开(因为否则它们必须在同一个翻译单元中定义)。 +对于模板类和结构,不要将方法声明与实现分开(因为否则它们必须在同一个翻译单元中定义)。 -**31.** 每行可在140个字符处换行,而不是80个字符。 +**31.** 可以将行换行至 140 个字符,而不是 80。 -**32.** 如果不需要后缀递增/递减运算符,请始终使用前缀运算符。 +**32.** 如果不需要后缀,始终使用前缀自增/自减运算符。 ```cpp for (Names::const_iterator it = column_names.begin(); it != column_names.end(); ++it) @@ -208,9 +209,9 @@ for (Names::const_iterator it = column_names.begin(); it != column_names.end(); ## 注释 {#comments} -**1.** 确保为所有非平凡的代码部分添加注释。 +**1.** 确保为所有非平凡代码部分添加注释。 -这非常重要。写注释可能会帮助您意识到某部分代码是不必要的,或者设计得不正确。 +这非常重要。写注释可能会帮助您意识到代码是不必要的,或是设计不正确的。 ```cpp /** Part of piece of memory, that can be used. @@ -220,9 +221,9 @@ for (Names::const_iterator it = column_names.begin(); it != column_names.end(); */ ``` -**2.** 注释可以根据需要详细。 +**2.** 注释可以详细到必要的程度。 -**3.** 将注释放在其描述的代码之前。在少数情况下,注释可以在代码后,位于同一行。 +**3.** 在描述它们的代码之前放置注释。在少数情况下,注释可以在代码后面,位于同一行。 ```cpp /** Parses and executes the query. @@ -236,11 +237,11 @@ void executeQuery( ) ``` -**4.** 注释应仅使用英语撰写。 +**4.** 注释应仅用英语书写。 -**5.** 如果您正在编写库,请在主要头文件中包含详细注释以进行解释。 +**5.** 如果您正在编写库,请在主头文件中包含详细注释进行说明。 -**6.** 不要添加没有额外信息的注释。特别是,不要留下像这这样的空注释: +**6.** 不要添加不提供附加信息的注释。特别是,不要留空注释,如下: ```cpp /* @@ -263,29 +264,29 @@ void executeQuery( */ ``` -示例借鉴自资源 http://home.tamk.fi/~jaalto/course/coding-style/doc/unmaintainable-code/. +该示例摘自资源 http://home.tamk.fi/~jaalto/course/coding-style/doc/unmaintainable-code/. -**7.** 不要在每个文件的开头写垃圾注释(作者、创建日期等)。 +**7.** 不要在每个文件的开头写垃圾注释(作者、创建日期……)。 -**8.** 单行注释以三个斜杠开头:`///`,多行注释以 `/**` 开头。这些注释被视为“文档注释”。 +**8.** 单行注释以三个斜杠开始: `///`,多行注释以 `/**` 开始。这些注释被视为“文档”。 -注意:您可以使用 Doxygen 从这些注释生成文档。但是通常不使用 Doxygen,因为在 IDE 中导航代码更方便。 +注意:您可以使用 Doxygen 从这些注释生成文档。但 Doxygen 通常不被使用,因为在 IDE 中导航代码更为方便。 -**9.** 多行注释不得在开头和结尾有空行(关闭多行注释的行除外)。 +**9.** 多行注释开头和结尾不得有空行(闭合多行注释的那一行除外)。 -**10.** 用于注释掉代码的注释,使用基本注释,而不是“文档”注释。 +**10.** 对于注释掉的代码,使用基本注释,而不是“文档”注释。 -**11.** 提交之前删除注释掉的代码部分。 +**11.** 在提交之前删除被注释掉的代码部分。 -**12.** 不要在注释或代码中使用粗俗语言。 +**12.** 注释或代码中不得有亵渎。 -**13.** 不要使用大写字母,也不要使用太多标点符号。 +**13.** 不要使用大写字母。不要使用过多的标点符号。 ```cpp /// WHAT THE FAIL??? ``` -**14.** 不要使用注释来做分隔符。 +**14.** 不要使用注释来作为分隔符。 ```cpp ///****************************************************** @@ -297,7 +298,7 @@ void executeQuery( /// Why did you do this stuff? ``` -**16.** 不必在块结束时写下描述其内容的注释。 +**16.** 没必要在块结束时写一个注释描述它的内容。 ```cpp /// for @@ -305,51 +306,51 @@ void executeQuery( ## 命名 {#names} -**1.** 在变量和类成员的命名上使用小写字母和下划线。 +**1.** 在变量和类成员的名称中使用小写字母和下划线。 ```cpp size_t max_block_size; ``` -**2.** 对于函数(方法)的命名,使用 camelCase 并以小写字母开头。 +**2.** 在函数(方法)名称中使用 camelCase,开头为小写字母。 ```cpp std::string getName() const override { return "Memory"; } ``` -**3.** 对于类(结构体)的命名,使用 CamelCase 并以大写字母开头。接口不使用 I 之外的前缀。 +**3.** 在类(结构)的名称中使用 CamelCase,开头为大写字母。对于接口,不使用 I 之外的前缀。 ```cpp class StorageMemory : public IStorage ``` -**4.** `using` 的命名方式与类相同。 +**4.** `using` 的命名与类相同。 -**5.** 模板类型参数的命名:在简单的情况下,使用 `T`;`T`、`U`;`T1`、`T2`。 +**5.** 模板类型参数的名称:在简单情况下,使用 `T`;`T`、`U`;`T1`、`T2`。 -对于更复杂的情况,可以遵循类名的命名规则,或者添加前缀 `T`。 +对于更复杂的情况,可以遵循类名称的规则,或添加前缀 `T`。 ```cpp template struct AggregatedStatElement ``` -**6.** 模板常量参数的命名:要么遵循变量名的命名规则,要么在简单情况下使用 `N`。 +**6.** 模板常量参数的名称:遵循变量名称的规则,或在简单情况下使用 `N`。 ```cpp template struct ExtractDomain ``` -**7.** 对于抽象类(接口),可以添加 `I` 前缀。 +**7.** 对于抽象类(接口),您可以添加 `I` 前缀。 ```cpp class IProcessor ``` -**8.** 如果您在局部使用变量,可以使用简短名称。 +**8.** 如果您在本地使用变量,可以使用短名称。 -在其他情况下,使用能够描述其意义的名称。 +在所有其他情况下,请使用描述其含义的名称。 ```cpp bool info_successfully_loaded = false; @@ -361,18 +362,18 @@ bool info_successfully_loaded = false; #define MAX_SRC_TABLE_NAMES_TO_STORE 1000 ``` -**10.** 文件名应与其内容使用相同的风格。 +**10.** 文件名应使用与其内容相同的风格。 -如果文件只包含一个类,则文件命名应与类同名(CamelCase)。 +如果一个文件包含单个类,则将文件命名为该类的同名(CamelCase)。 -如果文件只包含一个函数,则文件命名应与函数相同(camelCase)。 +如果文件包含单个函数,则将文件命名为该函数的同名(camelCase)。 -**11.** 如果名称包含缩写,则: +**11.** 如果名称中包含缩写,则: - 对于变量名称,缩写应使用小写字母 `mysql_connection`(而不是 `mySQL_connection`)。 -- 对于类和函数的名称,保持缩写中的大写字母 `MySQLConnection`(而不是 `MySqlConnection`)。 +- 对于类和函数名称,保留缩写中的大写字母 `MySQLConnection`(而不是 `MySqlConnection`)。 -**12.** 仅用于初始化类成员的构造函数参数的命名应与类成员的命名相同,但在末尾加下划线。 +**12.** 用于初始化类成员的构造函数参数应与类成员同名,但后面加下划线。 ```cpp FileQueueProcessor( @@ -387,15 +388,15 @@ FileQueueProcessor( } ``` -如果参数在构造函数体中未使用,可以省略下划线后缀。 +如果参数未在构造函数体中使用,可以省略下划线后缀。 -**13.** 局部变量和类成员的名称之间不需要区别(不需要前缀)。 +**13.** 局部变量和类成员的名称没有区别(不要求前缀)。 ```cpp timer (not m_timer) ``` -**14.** 对于 `enum` 中的常量,使用大写字母开头的 CamelCase。全大写也是可以的。如果 `enum` 不是局部的,使用 `enum class`。 +**14.** 对于 `enum` 中的常量,使用 CamelCase 首字母大写,也可以使用全大写字母。如果 `enum` 不是局部的,使用 `enum class`。 ```cpp enum class CompressionMethod @@ -405,49 +406,49 @@ enum class CompressionMethod }; ``` -**15.** 所有名称必须使用英语。禁止翻译希伯来词。 +**15.** 所有名称必须使用英语。不得转写希伯来语单词。 not T_PAAMAYIM_NEKUDOTAYIM -**16.** 缩写在众所周知的情况下是可以接受的(当您能轻松在维基百科或搜索引擎中找到缩写的意思时)。 +**16.** 缩写是可以接受的,只要它们是众所周知的(例如,您可以轻松找到缩写的含义,查看维基百科或搜索引擎)。 `AST`、`SQL`。 - 不是 `NVDH`(一些随机字母) + 不是 `NVDH`(随意字母) -不完整的单词在常用情况下是可以接受的。 +不完整的单词是可以接受的,只要简写是常用的。 -如果完整名称在注释中有所提及,您也可以使用缩写。 +如果完整名称在注释中与其相邻,也可以使用缩写。 -**17.** 含有 C++ 源代码的文件必须具有 `.cpp` 扩展名。头文件必须具有 `.h` 扩展名。 +**17.** C++ 源代码的文件名必须具有 `.cpp` 扩展名。头文件必须具有 `.h` 扩展名。 ## 如何编写代码 {#how-to-write-code} **1.** 内存管理。 -手动内存释放(`delete`)只能在库代码中使用。 +手动内存释放(`delete`)仅可在库代码中使用。 在库代码中,`delete` 操作符只能在析构函数中使用。 -在应用程序代码中,内存必须由拥有该内存的对象释放。 +在应用程序代码中,必须由拥有对象的对象释放内存。 示例: -- 最简单的方法是将对象放置在栈上,或者使其成为另一个类的成员。 -- 对于大量的小对象,使用容器。 -- 对于在堆中居住的小型对象的自动释放,使用 `shared_ptr/unique_ptr`。 +- 最简单的方法是将对象放在栈上,或使其成为另一个类的成员。 +- 对于大量小对象,请使用容器。 +- 对于位于堆中的少量对象的自动释放,使用 `shared_ptr/unique_ptr`。 **2.** 资源管理。 -使用 `RAII`,见上文。 +使用 `RAII`,详见上文。 **3.** 错误处理。 -使用异常。在大多数情况下,您只需要抛出异常,而不需要捕获它(由于 `RAII`)。 +使用异常。在大多数情况下,您只需抛出异常,而无需捕获它(因为 `RAII`)。 -在离线数据处理应用中,不捕获异常通常是可以接受的。 +在离线数据处理应用程序中,通常可以不捕获异常。 -在处理用户请求的服务器中,通常只需在连接处理程序的顶层捕获异常即可。 +在处理用户请求的服务器中,通常只需在连接处理程序的顶部捕获异常。 在线程函数中,您应该捕获并保存所有异常,以便在 `join` 后在主线程中重新抛出它们。 @@ -465,14 +466,14 @@ if (exception) exception->rethrow(); ``` -切勿在未处理的情况下隐藏异常。切勿盲目将所有异常记录在日志中。 +切勿在没有处理的情况下隐藏异常。切勿盲目将所有异常记录。 ```cpp //Not correct catch (...) {} ``` -如果需要忽略某些异常,只对特定异常如此,并重新抛出其余异常。 +如果需要忽略某些异常,仅对特定异常进行处理,并重新抛出其余异常。 ```cpp catch (const DB::Exception & e) @@ -484,33 +485,33 @@ catch (const DB::Exception & e) } ``` -在使用具有响应码或 `errno` 函数时,始终检查结果并在出现错误的情况下抛出异常。 +使用带有响应代码或 `errno` 的函数时,始终检查结果,并在出错时抛出异常。 ```cpp if (0 != close(fd)) throw ErrnoException(ErrorCodes::CANNOT_CLOSE_FILE, "Cannot close file {}", file_name); ``` -您可以使用 assert 来检查代码中的不变性。 +您可以使用 assert 检查代码中不变量的有效性。 **4.** 异常类型。 -在应用程序代码中不需要使用复杂的异常层次结构。异常文本应对系统管理员可理解。 +在应用程序代码中没有必要使用复杂的异常层次结构。异常文本应为系统管理员可理解。 **5.** 从析构函数抛出异常。 -这并不推荐,但允许。 +这不推荐,但可以。 使用以下选项: -- 创建一个函数(`done()` 或 `finalize()`),在异常可能发生之前完成所有工作。如果该函数已被调用,之后的析构函数中不应有异常。 -- 过于复杂的任务(例如在网络上发送消息)可以放在一个单独的方法中,使用该类的用户必须在销毁之前调用。 -- 如果析构函数中发生异常,最好记录而不是隐藏它(如果日志系统可用)。 -- 在简单应用中,可以依赖于 `std::terminate`(对于 C++11 中默认的 `noexcept` 的情况)来处理异常。 +- 创建一个函数(`done()` 或 `finalize()`),提前处理可能导致异常的所有工作。如果该函数已被调用,则析构函数中不应有异常。 +- 太复杂的任务(如通过网络发送消息)可以放在单独的方法中,类的用户必须在析构前调用此方法。 +- 如果析构函数中发生异常,最好记录它,而不是隐藏(如果记录器可用)。 +- 在简单应用中,可以依靠 `std::terminate` (在 C++11中默认为 `noexcept`)来处理异常。 **6.** 匿名代码块。 -您可以在单个函数内部创建一个单独的代码块,以使某些变量成为局部的,这样当退出此块时,析构函数将被调用。 +您可以在单个函数内部创建一个单独的代码块,以使某些变量局部,从而在退出块时调用析构函数。 ```cpp Block block = data.in->read(); @@ -528,25 +529,25 @@ ready_any.set(); 在离线数据处理程序中: -- 尽量在单个 CPU 核心上获得尽可能好的性能。在必要时再对代码进行并行化。 +- 尽量在单个 CPU 核心上获得最佳性能。如果需要,您可以随后对代码进行并行化。 -在服务器应用中: +在服务器应用程序中: -- 使用线程池处理请求。目前尚未出现需要用户空间上下文切换的任务。 +- 使用线程池处理请求。目前尚未有需要用户空间上下文切换的任务。 不使用 fork 进行并行化。 -**8.** 线程同步。 +**8.** 同步线程。 -通常可以让不同的线程使用不同的内存单元(更好的是:不同的缓存行),并且不使用任何线程同步(除了 `joinAll`)。 +通常,可以让不同的线程使用不同的内存单元(甚至更好:不同的缓存行),而不使用任何线程同步(除了 `joinAll`)。 如果需要同步,在大多数情况下,使用 `lock_guard` 下的互斥量就足够了。 -在其他情况下使用系统同步原语。不要使用忙等待。 +在其他情况下,使用系统同步原语。不要使用忙等待。 -仅在最简单的情况下使用原子操作。 +原子操作应仅在最简单的情况下使用。 -除非这是您的主要专业领域,否则不要尝试实现无锁数据结构。 +除非这是您的主要专长领域,否则不要尝试实现无锁数据结构。 **9.** 指针与引用。 @@ -556,33 +557,33 @@ ready_any.set(); 使用常量引用、指向常量的指针、`const_iterator` 和 `const` 方法。 -将 `const` 视为默认,只有在必要时使用非 `const`。 +将 `const` 视为默认,并仅在必要时使用非 `const`。 在按值传递变量时,使用 `const` 通常没有意义。 -**11.** 无符号。 +**11.** unsigned。 -必要时使用 `unsigned`。 +如果必要,使用 `unsigned`。 -**12.** 数值类型。 +**12.** 数字类型。 使用 `UInt8`、`UInt16`、`UInt32`、`UInt64`、`Int8`、`Int16`、`Int32` 和 `Int64`,以及 `size_t`、`ssize_t` 和 `ptrdiff_t`。 -不要使用这些类型数字:`signed/unsigned long`、`long long`、`short`、`signed/unsigned char`、`char`。 +不要为以下数字使用这些类型:`signed/unsigned long`、`long long`、`short`、`signed/unsigned char`、`char`。 **13.** 传递参数。 -对于将被移动的复杂值按值传递,并使用 std::move;如果您想在循环中更新值则按引用传递。 +如果要移动复杂值,则按值传递,并使用 std::move;如果要在循环中更新值,则按引用传递。 -如果一个函数获取了在堆上创建对象的所有权,请使参数类型为 `shared_ptr` 或 `unique_ptr`。 +如果一个函数捕获了堆内对象的所有权,令参数类型为 `shared_ptr` 或 `unique_ptr`。 **14.** 返回值。 -在大多数情况下,使用 `return`。不要写 `return std::move(res)`。 +在大多数情况下,仅使用 `return`。不要写 `return std::move(res)`。 -如果函数在堆上分配对象并返回它,使用 `shared_ptr` 或 `unique_ptr`。 +如果函数在堆上分配对象并返回它,请使用 `shared_ptr` 或 `unique_ptr`。 -在少数情况下(在循环中更新值),您可能需要通过参数返回值。在这种情况下,参数应为引用。 +在少数情况下(在循环中更新值),您可能需要通过参数返回值。在这种情况下,参数应该是引用。 ```cpp using AggregateFunctionPtr = std::shared_ptr; @@ -598,23 +599,23 @@ public: **15.** `namespace`。 -不需要为应用程序代码使用单独的 `namespace`。 +应用程序代码中不需要使用单独的 `namespace`。 -小型库也不需要这样。 +小型库也不需要这个。 对于中型到大型库,将所有内容放在一个 `namespace` 中。 -在库的 `.h` 文件中,您可以使用 `namespace detail` 隐藏不需要在应用程序代码中的实现细节。 +在库的 `.h` 文件中,您可以使用 `namespace detail` 来隐藏应用程序代码中不需要的实现细节。 -在 `.cpp` 文件中,您可以使用 `static` 或匿名 `namespace` 隐藏符号。 +在 `.cpp` 文件中,您可以使用 `static` 或匿名 `namespace` 来隐藏符号。 -此外,`namespace` 可用于 `enum` 以防止相应的名称掉入外部 `namespace`(但最好使用 `enum class`)。 +此外,`namespace` 可用于 `enum`,以防止相应名称落入外部 `namespace`(但最好使用 `enum class`)。 **16.** 延迟初始化。 如果初始化需要参数,则通常不应编写默认构造函数。 -如果将来需要延迟初始化,您可以添加一个默认构造函数,该构造函数将创建一个无效对象。或者,对于少量对象,可以使用 `shared_ptr/unique_ptr`。 +如果稍后需要延迟初始化,可以添加一个默认构造函数来创建一个无效对象。或者,对于少量对象,可以使用 `shared_ptr/unique_ptr`。 ```cpp Loader(DB::Connection * connection_, const std::string & query, size_t max_block_size_); @@ -625,51 +626,51 @@ Loader() {} **17.** 虚函数。 -如果类不打算用于多态使用,则不需要使函数为虚函数。这同样适用于析构函数。 +如果类不打算用于多态使用,则不需要将函数设为虚。析构函数也适用此规则。 **18.** 编码。 -在任何地方都使用 UTF-8。使用 `std::string` 和 `char *`。不要使用 `std::wstring` 和 `wchar_t`。 +到处使用 UTF-8。使用 `std::string` 和 `char *`。不要使用 `std::wstring` 和 `wchar_t`。 **19.** 日志记录。 -参见代码中的示例。 +请查看代码中的示例。 -在提交之前,删除所有无意义和调试日志,以及任何其他类型的调试输出。 +在提交之前,删除所有无意义的调试日志以及任何其他类型的调试输出。 -在循环中记录应尽量避免,即使在 Trace 等级。 +尽量避免在循环中记录,即使是在 Trace 级别。 -日志必须在任何记录级别下都能被阅读。 +在任何日志级别下,日志内容必须可读。 日志应主要用于应用程序代码。 -日志消息必须用英语撰写。 +日志消息必须用英语书写。 -日志应尽可能对系统管理员可理解。 +日志应尽可能便于系统管理员理解。 -不要在日志中使用粗俗语言。 +日志中不得有亵渎。 -在日志中使用UTF-8编码。在少数情况下,您可以在日志中使用非ASCII字符。 +在日志中使用 UTF-8 编码。在少数情况下,您可以在日志中使用非 ASCII 字符。 **20.** 输入输出。 -不要在对应用程序性能至关重要的内部循环中使用 `iostreams`(绝不使用 `stringstream`)。 +在对应用性能至关重要的内部循环中,不要使用 `iostreams`(并且绝不要使用 `stringstream`)。 -使用 `DB/IO` 库。 +改用 `DB/IO` 库。 **21.** 日期和时间。 -参见 `DateLUT` 库。 +请参阅 `DateLUT` 库。 -**22.** 包含。 +**22.** include。 -始终使用 `#pragma once`,而不是包含保护。 +始终使用 `#pragma once` 而不是包含保护。 -**23.** 使用。 +**23.** using。 -不使用 `using namespace`。您可以使用 `using` 进行特定的内容。但是使其在类或函数内部局部。 +不使用 `using namespace`。您可以使用 `using` 和特定内容。但将其限定在类或函数内部。 -**24.** 除非必要,否则不使用 `trailing return type`。 +**24.** 除非必要,否则不要对函数使用 `trailing return type`。 ```cpp auto f() -> void @@ -686,13 +687,13 @@ std::string s{"Hello"}; auto s = std::string{"Hello"}; ``` -**26.** 对于虚函数,在基类中写 `virtual`,而在派生类中用 `override` 代替 `virtual`。 +**26.** 对于虚函数,在基类中书写 `virtual`,而在派生类中书写 `override` 代替 `virtual`。 -## C++ 的未使用功能 {#unused-features-of-c} +## C++ 的未使用特性 {#unused-features-of-c} **1.** 不使用虚继承。 -**2.** 在现代 C++ 中具有便利语法糖的构造,例如: +**2.** 在现代 C++ 中具有方便语法糖的构造,例如: ```cpp // Traditional way without syntactic sugar @@ -739,103 +740,103 @@ auto func(const E & e) // auto return type (C++14) **1.** 我们为特定平台编写代码。 -但在其他条件相同的情况下,优先使用跨平台或可移植的代码。 +但在其他条件相等的情况下,优先选择跨平台或便携式代码。 -**2.** 语言:C++20(见可用 [C++20 特性](https://en.cppreference.com/w/cpp/compiler_support#C.2B.2B20_features) 的列表)。 +**2.** 语言:C++20(见可用的 [C++20 功能](https://en.cppreference.com/w/cpp/compiler_support#C.2B.2B20_features))。 -**3.** 编译器:`clang`。截至撰写时(2025年3月),代码使用 `clang` 版本 >= 19 进行编译。 +**3.** 编译器: `clang`。在撰写本文时(2025年3月),代码使用 clang 版本 >= 19 编译。 使用标准库(`libc++`)。 **4.** 操作系统:Linux Ubuntu,不低于 Precise。 -**5.** 代码为 x86_64 CPU 架构编写。 +**5.** 代码针对 x86_64 CPU 架构编写。 -CPU 指令集是我们服务器中最低支持的集。目前是 SSE 4.2。 +CPU 指令集是我们服务器之间的最低支持集。目前为 SSE 4.2。 -**6.** 使用 `-Wall -Wextra -Werror -Weverything` 编译标志,但有一些例外。 +**6.** 使用 `-Wall -Wextra -Werror -Weverything` 编译标志,少数例外。 -**7.** 除了那些难以静态链接的库外,所有库都使用静态链接(见 `ldd` 命令的输出)。 +**7.** 除了难以静态连接的库外,使用与所有库的静态链接(见 `ldd` 命令的输出)。 -**8.** 在发布设置下开发和调试代码。 +**8.** 代码在发布设置下开发和调试。 ## 工具 {#tools} -**1.** KDevelop 是一个不错的 IDE。 +**1.** KDevelop 是一个很好的 IDE。 **2.** 调试时,使用 `gdb`、`valgrind`(`memcheck`)、`strace`、`-fsanitize=...` 或 `tcmalloc_minimal_debug`。 **3.** 进行性能分析时,使用 `Linux Perf`、`valgrind`(`callgrind`)或 `strace -cf`。 -**4.** 源代码使用 Git。 +**4.** 源代码在 Git 中。 **5.** 汇编使用 `CMake`。 -**6.** 程序通过 `deb` 包发布。 +**6.** 通过 `deb` 包发布程序。 -**7.** 提交到主分支的更改不能破坏构建。 +**7.** 不得破坏主分支的构建。 -虽然仅选择的修订版被认为是可工作的。 +尽管只有选定的修订被视为可工作。 -**8.** 尽可能频繁地进行提交,即使代码只是部分准备好。 +**8.** 尽可能频繁地进行提交,即使代码只部分完成。 -为此使用分支。 +为此目的使用分支。 -如果您在 `master` 分支中的代码尚未可构建,请在 `push` 之前将其排除在构建之外。您需要在几天内完成它或将其删除。 +如果主分支中的代码尚不可构建,请在 `push` 前将其从构建中排除。您需要在几天内完成或删除它。 -**9.** 对于非平凡的更改,使用分支并在服务器上发布。 +**9.** 对于非平凡的更改,使用分支并在服务器上发布它们。 -**10.** 从存储库中删除未使用的代码。 +**10.** 从代码库中删除未使用的代码。 ## 库 {#libraries} **1.** 使用 C++20 标准库(允许实验性扩展),以及 `boost` 和 `Poco` 框架。 -**2.** 不允许使用操作系统包中的库。也不允许使用预安装的库。所有库应以源代码形式放在 `contrib` 目录中并与 ClickHouse 一起构建。有关详细信息,请参见 [添加和维护第三方库的指南](/development/contrib#adding-and-maintaining-third-party-libraries)。 +**2.** 不允许使用操作系统包中的库。也不允许使用预安装库。所有库应以源代码形式放置在 `contrib` 目录中,并与 ClickHouse 一起构建。有关详细信息,请参见 [添加和维护第三方库的指导方针](/development/contrib#adding-and-maintaining-third-party-libraries)。 **3.** 总是优先考虑已经在使用中的库。 ## 一般建议 {#general-recommendations-1} -**1.** 写尽可能少的代码。 +**1.** 尽量编写最少的代码。 **2.** 尝试最简单的解决方案。 -**3.** 在知道它将如何工作以及内部循环将如何运行之前,请勿编写代码。 +**3.** 在您清楚它的工作方式及内部循环将如何工作之前,不要编写代码。 -**4.** 在最简单的情况下,使用 `using` 而不是类或结构体。 +**4.** 在最简单的情况下,使用 `using` 代替类或结构。 -**5.** 如果可能,不要编写复制构造函数、赋值运算符、析构函数(除非是虚构造函数,如果类至少包含一个虚拟函数)、移动构造函数或移动赋值运算符。换句话说,编译器生成的函数必须正常工作。您可以使用 `default`。 +**5.** 如果可能,不要编写复制构造函数、赋值运算符、析构函数(除非是虚函数,如果类至少包含一个虚函数)、移动构造函数或移动赋值运算符。换句话说,编译器生成的函数必须正常工作。您可以使用 `default`。 -**6.** 鼓励代码简化。在可能的情况下减少代码的大小。 +**6.** 鼓励代码简化。尽可能减少代码的大小。 -## 其他建议 {#additional-recommendations} +## 附加建议 {#additional-recommendations} -**1.** 明确指定 `std::` 进行 `stddef.h` 中的类型 +**1.** 明确指定 `std::` 的 `stddef.h` 中的类型 -并不推荐。换句话说,我们建议写 `size_t` 而不是 `std::size_t`,因为这样更短。 +是不推荐的。换句话说,我们建议写 `size_t` 而不是 `std::size_t`,因为它更短。 -可以选择添加 `std::`。 +添加 `std::` 是可以接受的。 -**2.** 明确指定 `std::` 进行标准 C 库中的函数 +**2.** 明确指定 `std::` 的标准 C 库中的函数 -并不推荐。换句话说,写 `memcpy` 而不是 `std::memcpy`。 +是不推荐的。换句话说,写 `memcpy` 而不是 `std::memcpy`。 -原因是存在类似的非标准函数,例如 `memmem`。我们确实偶尔会使用这些函数。这些函数不在 `namespace std` 中。 +原因在于有类似的非标准函数,例如 `memmem`。我们偶尔会使用这些函数。这些函数不存在于 `namespace std` 中。 -如果您在任何地方写 `std::memcpy` 而不是 `memcpy`,那么没有 `std::` 的 `memmem` 看起来会很奇怪。 +如果您在任何地方写 `std::memcpy` 而不是 `memcpy`,那么没有 `std::` 的 `memmem` 会显得奇怪。 -尽管如此,如果您更喜欢使用 `std::`,仍然可以。 +不过,如果您更喜欢,可以仍然使用 `std::`。 -**3.** 当相同的函数可用于标准 C++ 库时,使用 C 的函数。 +**3.** 在标准 C++ 库中的相同函数可用时使用 C 的函数。 -如果更有效,这是可以接受的。 +如果更高效,可以接受。 -例如,对于复制大段内存,使用 `memcpy` 而不是 `std::copy`。 +例如,使用 `memcpy` 来替代 `std::copy` 来复制大量内存。 **4.** 多行函数参数。 -以下任何包装样式都是允许的: +以下任何一种包装样式都是允许的: ```cpp function( diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/development/style.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/development/style.md.hash index 9e14df51dcd..80d5eb7c9ad 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/development/style.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/development/style.md.hash @@ -1 +1 @@ -fb3b0b8dca031287 +f9ef4baf7bd3bfc7 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/development/tests.md b/i18n/zh/docusaurus-plugin-content-docs/current/development/tests.md index d627ffcc773..0a85f95de45 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/development/tests.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/development/tests.md @@ -1,9 +1,10 @@ --- -'description': '测试 ClickHouse 和运行测试套件的指南' +'description': '关于测试 ClickHouse 和运行测试套件的指南' 'sidebar_label': '测试' 'sidebar_position': 40 'slug': '/development/tests' 'title': '测试 ClickHouse' +'doc_type': 'guide' --- @@ -11,51 +12,41 @@ ## 功能测试 {#functional-tests} -功能测试是最简单和方便使用的。 -大多数 ClickHouse 功能可以通过功能测试进行测试,对于任何可以以此方式进行测试的 ClickHouse 代码更改,它们都是强制使用的。 +功能测试是最简单且使用方便的测试方式。大部分 ClickHouse 功能都可以通过功能测试进行验证,并且对于任何可以通过这种方式测试的 ClickHouse 代码更改,功能测试是强制要求的。 -每个功能测试向运行中的 ClickHouse 服务器发送一个或多个查询,并将结果与引用进行比较。 +每个功能测试会向运行中的 ClickHouse 服务器发送一个或多个查询,并将结果与参考结果进行比较。 -测试位于 `queries` 目录。 -有两个子目录:`stateless` 和 `stateful`。 -- 无状态测试在没有任何预加载测试数据的情况下运行查询 - 它们通常在测试本身内动态创建小的合成数据集。 -- 有状态测试需要从 ClickHouse 预加载测试数据,并且它对公众可用。请参见 [状态测试在持续集成中的使用](continuous-integration.md#functional-stateful-tests)。 +测试位于 `./tests/queries` 目录下。 每个测试可以是两种类型之一:`.sql` 和 `.sh`。 -- `.sql` 测试是简单的 SQL 脚本,通过 `clickhouse-client` 管道传输。 -- `.sh` 测试是单独运行的脚本。 +- `.sql` 测试是一个简单的 SQL 脚本,通过 `clickhouse-client` 进行处理。 +- `.sh` 测试是一个独立运行的脚本。 -一般来说,SQL 测试优于 `.sh` 测试。 -只有在必须测试一些无法通过纯 SQL 实现的功能时,才应使用 `.sh` 测试,例如将一些输入数据传递到 `clickhouse-client` 或测试 `clickhouse-local`。 +通常情况下,SQL 测试优先于 `.sh` 测试。只有在必须测试一些无法通过纯 SQL 实现的功能时,才应使用 `.sh` 测试,比如将一些输入数据传递给 `clickhouse-client` 或测试 `clickhouse-local`。 :::note -测试数据类型 `DateTime` 和 `DateTime64` 时常见的错误是假设服务器使用特定时区(例如“UTC”)。实际上并非如此,CI 测试运行中的时区是故意随机化的。最简单的解决方法是明确为测试值指定时区,例如 `toDateTime64(val, 3, 'Europe/Amsterdam')`。 +在测试数据类型 `DateTime` 和 `DateTime64` 时,常见的错误是认为服务器使用特定的时区(例如 “UTC”)。实际上并非如此,CI 测试运行中的时区是故意随机化的。解决此问题的最简单方法是明确为测试值指定时区,例如 `toDateTime64(val, 3, 'Europe/Amsterdam')`。 ::: -### 在本地运行测试 {#running-a-test-locally} +### 本地运行测试 {#running-a-test-locally} -在本地启动 ClickHouse 服务器,监听默认端口(9000)。 -例如,要运行测试 `01428_hash_set_nan_key`,请切换到存储库文件夹并运行以下命令: +在本地启动 ClickHouse 服务器,监听默认端口(9000)。例如,要运行测试 `01428_hash_set_nan_key`,请切换到代码库文件夹并运行以下命令: ```sh PATH=:$PATH tests/clickhouse-test 01428_hash_set_nan_key ``` -测试结果(`stderr` 和 `stdout`)写入到文件 `01428_hash_set_nan_key.[stderr|stdout]` 中,这些文件位于测试本身旁边(对于 `queries/0_stateless/foo.sql`,输出将位于 `queries/0_stateless/foo.stdout` 中)。 +测试结果(`stderr` 和 `stdout`)将写入文件 `01428_hash_set_nan_key.[stderr|stdout]`,这些文件位于测试本身所在的同一目录(例如,对于 `queries/0_stateless/foo.sql`,输出将位于 `queries/0_stateless/foo.stdout`)。 -请参见 `tests/clickhouse-test --help` 了解 `clickhouse-test` 的所有选项。 -您可以运行所有测试,或者通过提供测试名称的过滤器来运行部分测试:`./clickhouse-test substring`。 -还有选项可以并行运行测试或随机顺序运行。 +请查看 `tests/clickhouse-test --help` 了解 `clickhouse-test` 的所有选项。您可以运行所有测试或通过提供测试名称过滤器来运行测试的子集:`./clickhouse-test substring`。此外,还可以选择以并行或随机顺序运行测试。 ### 添加新测试 {#adding-a-new-test} -要添加新测试,首先在 `queries/0_stateless` 目录中创建一个 `.sql` 或 `.sh` 文件。 -然后使用 `clickhouse-client < 12345_test.sql > 12345_test.reference` 或 `./12345_test.sh > ./12345_test.reference` 生成相应的 `.reference` 文件。 +要添加新测试,首先在 `queries/0_stateless` 目录中创建一个 `.sql` 或 `.sh` 文件。然后使用 `clickhouse-client < 12345_test.sql > 12345_test.reference` 或 `./12345_test.sh > ./12345_test.reference` 生成相应的 `.reference` 文件。 -测试仅应在自动创建的数据库 `test` 中创建、删除、查询表等。 -可以使用临时表。 +测试应该仅创建、删除、选择等数据库 `test` 中的表,该数据库会自动创建。可以使用临时表。 -要在本地设置与 CI 相同的环境,请安装测试配置(它们将使用 Zookeeper 虚拟实现并调整某些设置) +要在本地设置与 CI 相同的环境,安装测试配置(它们将使用 Zookeeper 模拟实现并调整一些设置) ```sh cd /tests/config @@ -63,19 +54,19 @@ sudo ./install.sh ``` :::note -测试应 -- 最小化:仅创建所需的最少表、列和复杂性, -- 快速:不超过几秒(更好:亚秒级), -- 正确且确定性:仅在被测试功能未正常工作时才失败, +测试应该 +- 最小化:仅创建最少需要的表、列和复杂性, +- 快速:不超过几秒(最好是毫秒级), +- 正确且确定性:仅在被测试的功能不工作时才失败, - 隔离/无状态:不依赖于环境和时间 -- 详尽:覆盖边界情况,比如零、空值、空集、异常(负测试,使用语法 `-- { serverError xyz }` 和 `-- { clientError xyz }` 来实现), -- 在测试结束时清理表(以防有残留), -- 确保其他测试不测试相同内容(即先使用 grep 检查)。 +- 全面:覆盖边界案例,如零、空值、空集合、异常(负面测试,使用语法 `-- { serverError xyz }` 和 `-- { clientError xyz }`), +- 在测试结束时清理表(防止出现剩余部分), +- 确保其他测试不测试相同的内容(即先进行 grep)。 ::: ### 限制测试运行 {#restricting-test-runs} -测试可以具有零个或多个 _tags_,指定测试在 CI 中运行的上下文限制。 +测试可以有零个或多个 _tags_,用于指定测试在 CI 中运行的限制上下文。 对于 `.sql` 测试,标签放在第一行作为 SQL 注释: @@ -87,7 +78,7 @@ sudo ./install.sh SELECT 1 ``` -对于 `.sh` 测试,标签作为注释放在第二行: +对于 `.sh` 测试,标签作为第二行的注释书写: ```bash #!/usr/bin/env bash @@ -101,22 +92,23 @@ SELECT 1 可用标签列表: -|标签名称 | 功能 | 用法示例 | +| 标签名称 | 作用 | 使用示例 | |---|---|---| -| `disabled`| 测试未运行 || -| `long` | 测试的执行时间从1分钟延长到10分钟 || +| `disabled`| 测试不运行 || +| `long` | 测试的执行时间从 1 分钟延长到 10 分钟 || | `deadlock` | 测试在循环中长时间运行 || -| `race` | 与 `deadlock` 相同。优先选择 `deadlock` || -| `shard` | 服务器需监听 `127.0.0.*` || -| `distributed` | 与 `shard` 相同。优先选择 `shard` || -| `global` | 与 `shard` 相同。优先选择 `shard` || -| `zookeeper` | 测试需运行 Zookeeper 或 ClickHouse Keeper | 测试使用 `ReplicatedMergeTree` | -| `replica` | 与 `zookeeper` 相同。优先选择 `zookeeper` || -| `no-fasttest`| 测试不在 [快速测试](continuous-integration.md#fast-test) 下运行 | 测试使用的 `MySQL` 表引擎在快速测试中被禁用 | -| `no-[asan, tsan, msan, ubsan]` | 禁用在具有 [sanitizers](#sanitizers) 的构建中测试 | 测试在 QEMU 下运行,QEMU 不兼容 sanitizers | +| `race` | 与 `deadlock` 相同。优先使用 `deadlock` || +| `shard` | 服务器需要监听 `127.0.0.*` || +| `distributed` | 与 `shard` 相同。优先使用 `shard` || +| `global` | 与 `shard` 相同。优先使用 `shard` || +| `zookeeper` | 测试需要 Zookeeper 或 ClickHouse Keeper 运行 | 测试使用 `ReplicatedMergeTree` | +| `replica` | 与 `zookeeper` 相同。优先使用 `zookeeper` || +| `no-fasttest`| 测试在 [快速测试](continuous-integration.md#fast-test) 下不运行 | 测试使用禁用的 `MySQL` 表引擎 | +| `fasttest-only`| 测试仅在 [快速测试](continuous-integration.md#fast-test) 下运行 || +| `no-[asan, tsan, msan, ubsan]` | 禁用在带有 [sanitizers](#sanitizers) 的构建中的测试 | 测试在不支持 sanitizers 的 QEMU 下运行 | | `no-replicated-database` ||| | `no-ordinary-database` ||| -| `no-parallel` | 禁止与此测试并行运行其他测试 | 测试从 `system` 表中读取,可能会破坏不变性 | +| `no-parallel` | 禁止与此测试并行运行其他测试 | 测试从 `system` 表读取,可能破坏不变性 | | `no-parallel-replicas` ||| | `no-debug` ||| | `no-stress` ||| @@ -129,14 +121,13 @@ SELECT 1 | `no-cpu-ppc64le` ||| | `no-s3-storage` ||| -除了以上设置外,您还可以使用 `system.build_options` 中的 `USE_*` 标志来定义 ClickHouse 特定功能的使用。 -例如,如果您的测试使用 MySQL 表,则应添加标签 `use-mysql`。 +除了上述设置外,您可以使用 `system.build_options` 中的 `USE_*` 标志来定义特定 ClickHouse 功能的使用。例如,如果您的测试使用 MySQL 表,则应添加标签 `use-mysql`。 ### 为随机设置指定限制 {#specifying-limits-for-random-settings} -测试可以指定随机测试运行中允许的设置的最小值和最大值。 +测试可以为在测试运行期间可以随机化的设置指定最小和最大允许值。 -对于 `.sh` 测试,限制作为注释写在标签旁边的行上,或者如果未指定标签,则写在第二行: +对于 `.sh` 测试,限制作为注释写在标签旁边的行中,或者如果没有标签则写在第二行: ```bash #!/usr/bin/env bash @@ -146,7 +137,7 @@ SELECT 1 # Random settings limits: max_block_size=(1000, 10000); index_granularity=(100, None) ``` -对于 `.sql` 测试,标签紧邻标签的行中作为 SQL 注释,或在第一行中: +对于 `.sql` 测试,标签放在标签旁边的 SQL 注释中,或者放在第一行: ```sql -- Tags: no-fasttest @@ -154,72 +145,55 @@ SELECT 1 SELECT 1 ``` -如果您只需要指定一个限制,可以对另一个限制使用 `None`。 +如果您只需要指定一个限制,可以使用 `None` 作为另一个限制。 ### 选择测试名称 {#choosing-the-test-name} -测试名称以五位数字前缀开头,后跟描述性名称,例如 `00422_hash_function_constexpr.sql`。 -要选择前缀,请找到目录中已存在的最大前缀,并将其递增1。 +测试的名称以五位数字前缀开头,后跟描述性名称,如 `00422_hash_function_constexpr.sql`。要选择前缀,请查找目录中已存在的最大前缀,然后加 1。 ```sh ls tests/queries/0_stateless/[0-9]*.reference | tail -n 1 ``` -与此同时,可能会添加其他具有相同数字前缀的测试,但这没有问题,并不会导致任何问题,您不必在以后更改它。 +同时,可能会有其他测试使用相同的数字前缀,但这没关系,并不会导致任何问题,您不必在以后的时间里更改它。 ### 检查必须发生的错误 {#checking-for-an-error-that-must-occur} -有时您想测试不正确的查询是否会发生服务器错误。我们在 SQL 测试中支持特殊注释,形式如下: +有时您希望测试错误查询会导致服务器错误。我们在 SQL 测试中支持这种特殊注释,形式如下: ```sql -select x; -- { serverError 49 } +SELECT x; -- { serverError 49 } ``` -该测试确保服务器返回代码为49的关于未知列 `x` 的错误。 -如果没有错误,或者错误不同,测试将失败。 -如果您想确保在客户端发生错误,请使用 `clientError` 注释。 +此测试确保服务器返回代码为 49 的未知列 `x` 的错误。如果没有错误或错误不同,测试将失败。如果您想确保在客户端发生错误,请使用 `clientError` 注释。 -请勿检查错误消息的特定措辞,因为这可能会在未来发生改变,从而不必要地导致测试失败。 -只检查错误代码。 -如果现有错误代码不够精确以满足您的需求,请考虑添加一个新代码。 +不要检查错误消息的具体措辞,因为将来可能会更改,测试将徒然失败。仅检查错误代码。如果现有错误代码不够精确,可以考虑添加一个新代码。 ### 测试分布式查询 {#testing-a-distributed-query} -如果您希望在功能测试中使用分布式查询,可以利用 `remote` 表函数,使用 `127.0.0.{1..2}` 地址供服务器查询自身;或者可以在服务器配置文件中使用预定义的测试集群,如 `test_shard_localhost`。 -记得在测试名称中添加 `shard` 或 `distributed`,以便在 CI 中以正确的配置运行,其中服务器配置为支持分布式查询。 +如果您想在功能测试中使用分布式查询,可以利用 `remote` 表函数,使用 `127.0.0.{1..2}` 地址让服务器自查询;或者您可以在服务器配置文件中使用预定义的测试集群,如 `test_shard_localhost`。请记得在测试名称中添加 `shard` 或 `distributed` 字样,以便在 CI 中以正确的配置运行,其中服务器被配置为支持分布式查询。 ### 处理临时文件 {#working-with-temporary-files} -有时在 Shell 测试中,您可能需要动态创建一个文件以进行处理。 -请记住,一些 CI 检查会并行运行测试,因此如果您在脚本中创建或删除一个没有唯一名称的临时文件,这可能会导致某些 CI 检查(例如 Flaky)失败。 -为了解决这个问题,您应该使用环境变量 `$CLICKHOUSE_TEST_UNIQUE_NAME` 来为运行中的测试提供唯一的临时文件名。 -这样,您可以确保您在设置期间创建或在清理期间删除的文件是该测试唯一使用的文件,而不是其他并行运行的测试中的文件。 +有时在 shell 测试中,您可能需要动态创建一个文件进行处理。请注意,某些 CI 检查会并行运行测试,因此如果您在脚本中创建或删除临时文件而没有唯一名称,可能会导致某些 CI 检查(例如不稳定性检测)失败。为了解决此问题,您应该使用环境变量 `$CLICKHOUSE_TEST_UNIQUE_NAME` 为临时文件指定一个唯一的名称,以便运行的测试所创建或删除的文件是该测试专用的,并不是某个并行运行的其他测试所使用的。 ## 已知错误 {#known-bugs} -如果我们知道一些可以通过功能测试轻松重现的错误,我们会将准备好的功能测试放在 `tests/queries/bugs` 目录中。 -这些测试将在修复错误后移动到 `tests/queries/0_stateless`。 +如果我们知道一些可以通过功能测试轻松重现的错误,我们会将准备好的功能测试放在 `tests/queries/bugs` 目录下。这些测试将在错误修复后移至 `tests/queries/0_stateless`。 ## 集成测试 {#integration-tests} -集成测试允许在集群配置中测试 ClickHouse 以及 ClickHouse 与其他服务器(如 MySQL、Postgres、MongoDB)的交互。 -它们可用于模拟网络分裂、数据包丢失等。 -这些测试在 Docker 下运行,并创建多个带有不同软件的容器。 +集成测试允许在集群配置中测试 ClickHouse 及其与 MySQL、Postgres、MongoDB 等其他服务器的互动。它们对于模拟网络故障、丢包等情况非常有用。这些测试在 Docker 下运行,并创建多个不同软件的容器。 -请查看 `tests/integration/README.md` 了解如何运行这些测试。 +请参见 `tests/integration/README.md` 了解如何运行这些测试。 -请注意,ClickHouse 与第三方驱动程序的集成未经过测试。 -此外,我们目前没有与我们的 JDBC 和 ODBC 驱动程序的集成测试。 +请注意,ClickHouse 与第三方驱动程序的集成未经过测试。此外,我们目前没有与 JDBC 和 ODBC 驱动程序的集成测试。 ## 单元测试 {#unit-tests} -单元测试在您想要测试的不是整个 ClickHouse 而是单个独立库或类时非常有用。 -您可以使用 `ENABLE_TESTS` CMake 选项启用或禁用测试的构建。 -单元测试(以及其他测试程序)位于代码的 `tests` 子目录中。 -要运行单元测试,请键入 `ninja test`。 -一些测试使用 `gtest`,但有些只是返回非零退出代码以指示测试失败的程序。 +单元测试在您希望测试单个独立库或类时很有用。您可以使用 `ENABLE_TESTS` CMake 选项启用或禁用测试的构建。单元测试(和其他测试程序)位于代码中的 `tests` 子目录。要运行单元测试,请输入 `ninja test`。一些测试使用 `gtest`,但有些只是返回测试失败时非零退出码的程序。 -如果代码已由功能测试覆盖,则不必进行单元测试(功能测试通常更简单易用)。 +如果代码已经通过功能测试覆盖(而功能测试通常更易于使用),则没有必要进行单元测试。 您可以通过直接调用可执行文件来运行单独的 gtest 检查,例如: @@ -229,52 +203,35 @@ $ ./src/unit_tests_dbms --gtest_filter=LocalAddress* ## 性能测试 {#performance-tests} -性能测试可测量和比较 ClickHouse 某个独立部分在合成查询中的性能。 -性能测试位于 `tests/performance/`。 -每个测试由一个包含测试用例描述的 `.xml` 文件表示。 -测试使用 `docker/test/performance-comparison` 工具运行。请参见自述文件以获取调用方法。 +性能测试可以测量和比较 ClickHouse 某个隔离部分在合成查询中的性能。性能测试位于 `tests/performance/`。每个测试由一个 `.xml` 文件表示,其中包含测试用例的描述。测试通过 `docker/test/performance-comparison` 工具运行。有关调用的更多信息,请参阅自述文件。 -每个测试在循环中运行一个或多个查询(可能带有参数组合)。 +每个测试循环运行一个或多个查询(可能是参数组合)。 -如果您希望在某个场景中改善 ClickHouse 的性能,并且如果改善可以在简单查询上观察到,强烈建议您编写性能测试。 -此外,当您添加或修改相对独立且不太晦涩的 SQL 函数时,也建议编写性能测试。 -在测试过程中使用 `perf top` 或其他 `perf` 工具总是有意义的。 +如果您想改善 ClickHouse 在某些场景下的性能,并且如果改进可以在简单查询中观察到,强烈建议编写性能测试。此外,当您添加或修改相对独立且不太晦涩的 SQL 函数时,也建议编写性能测试。在测试期间使用 `perf top` 或其他 `perf` 工具总是有意义的。 ## 测试工具和脚本 {#test-tools-and-scripts} -在 `tests` 目录中的某些程序不是准备好的测试,而是测试工具。 -例如,对于 `Lexer` 有一个工具 `src/Parsers/tests/lexer`,它只对标准输入进行分词,并将彩色结果写入标准输出。 -您可以将这些工具用作代码示例以及探索和手动测试之用。 +在 `tests` 目录中的一些程序不是预备测试,而是测试工具。例如,对于 `Lexer`,有一个工具 `src/Parsers/tests/lexer`,仅对标准输入进行标记化,并将着色结果写入标准输出。您可以使用这些工具作为代码示例以及进行探索和手动测试。 ## 杂项测试 {#miscellaneous-tests} -在 `tests/external_models` 中有机器学习模型的测试。 -这些测试没有更新,必须转移到集成测试中。 +在 `tests/external_models` 中有机器学习模型的测试。这些测试不会被更新,必须迁移到集成测试中。 -有一个单独的测试用于法定插入。 -该测试在单独的服务器上运行 ClickHouse 集群,并模拟各种故障情况:网络分裂、数据包丢失(在 ClickHouse 节点之间、ClickHouse 和 ZooKeeper 之间、ClickHouse 服务器与客户端之间等)、`kill -9`、`kill -STOP` 和 `kill -CONT`,类似于 [Jepsen](https://aphyr.com/tags/Jepsen)。然后测试检查所有确认的插入是否已写入,而所有被拒绝的插入未写入。 +还有一个单独的测试用于法定插入。该测试在单独的服务器上运行 ClickHouse 集群,并模拟各种故障案例:网络拆分、丢包(在 ClickHouse 节点之间、ClickHouse 和 ZooKeeper 之间、ClickHouse 服务器和客户端之间等),`kill -9`、`kill -STOP` 和 `kill -CONT`,如 [Jepsen](https://aphyr.com/tags/Jepsen) 所示。然后测试检查所有已确认的插入是否已写入,所有被拒绝的插入是否未写入。 -法定测试是 ClickHouse 开源之前由一个单独团队编写的。 -这个团队现在不再与 ClickHouse 相关。 -测试意外地用 Java 编写。 -因此,法定测试必须重写并移至集成测试。 +法定测试是由独立团队在 ClickHouse 开源之前编写的。这个团队不再与 ClickHouse 一起工作。该测试意外地采用 Java 编写。因此,法定测试必须重写并迁移到集成测试中。 ## 手动测试 {#manual-testing} -在您开发新功能时,合理地手动测试它。 -您可以按照以下步骤进行操作: +当您开发新功能时,手动测试也是合理的。您可以通过以下步骤进行手动测试: -构建 ClickHouse。从终端运行 ClickHouse:切换目录到 `programs/clickhouse-server` 并通过 `./clickhouse-server` 运行。它将默认使用当前目录的配置(`config.xml`、`users.xml` 和 `config.d` 和 `users.d` 目录中的文件)。要连接到 ClickHouse 服务器,运行 `programs/clickhouse-client/clickhouse-client`。 +构建 ClickHouse。从终端运行 ClickHouse:将目录更改为 `programs/clickhouse-server`,并使用 `./clickhouse-server` 运行它。默认情况下,它将使用当前目录中的配置(`config.xml`、`users.xml` 和 `config.d` 和 `users.d` 目录中的文件)。要连接到 ClickHouse 服务器,请运行 `programs/clickhouse-client/clickhouse-client`。 -请注意,所有 ClickHouse 工具(服务器、客户端等)都是指向名为 `clickhouse` 的单个二进制文件的符号链接。 -您可以在 `programs/clickhouse` 中找到该二进制文件。 -所有工具也可通过 `clickhouse tool` 代替 `clickhouse-tool` 调用。 +请注意,所有 ClickHouse 工具(服务器、客户端等)都是指向名为 `clickhouse` 的单个二进制文件的符号链接。您可以在 `programs/clickhouse` 中找到该二进制文件。所有工具也可以以 `clickhouse tool` 的方式调用,而不是 `clickhouse-tool`。 -或者您可以安装 ClickHouse 软件包:可以是 ClickHouse 存储库中的稳定版本,或您可以使用 `./release` 在 ClickHouse 源代码根目录中为自己构建软件包。 -然后使用 `sudo clickhouse start` 启动服务器(或 stop 停止服务器)。 -查看 `/etc/clickhouse-server/clickhouse-server.log` 中的日志。 +或者,您可以安装 ClickHouse 包:从 ClickHouse 仓库安装稳定版本,或者您可以在 ClickHouse 源代码根目录中使用 `./release` 为自己构建包。然后使用 `sudo clickhouse start` 启动服务器(或使用 `stop` 停止服务器)。查看 `/etc/clickhouse-server/clickhouse-server.log` 中的日志。 -当 ClickHouse 已经在您的系统上安装时,您可以构建新的 `clickhouse` 二进制文件并替换现有的二进制文件: +当 ClickHouse 已经安装在您的系统上时,您可以构建一个新的 `clickhouse` 二进制文件并替换现有的二进制文件: ```bash $ sudo clickhouse stop @@ -282,7 +239,7 @@ $ sudo cp ./clickhouse /usr/bin/ $ sudo clickhouse start ``` -您也可以停止系统 ClickHouse 服务器,并使用相同的配置但将日志记录到终端的方式运行您自己的实例: +您还可以停止系统的 clickhouse-server,并使用相同的配置运行您自己的服务器,但将日志输出到终端: ```bash $ sudo clickhouse stop @@ -295,211 +252,162 @@ $ sudo -u clickhouse /usr/bin/clickhouse server --config-file /etc/clickhouse-se $ sudo -u clickhouse gdb --args /usr/bin/clickhouse server --config-file /etc/clickhouse-server/config.xml ``` -如果系统 ClickHouse 服务器已经在运行,并且您不想停止它,您可以在 `config.xml` 中更改端口号(或在 `config.d` 目录中的文件中覆盖它们),提供合适的数据路径并运行它。 +如果系统的 clickhouse-server 已经在运行,并且您不想停止它,可以在 `config.xml` 中更改端口号(或在 `config.d` 目录中的文件中覆盖),提供适当的数据路径,然后运行它。 -`clickhouse` 二进制文件几乎没有依赖项,可以跨多个 Linux 发行版工作。 -要快速且简便地在服务器上测试您的更改,您只需将新构建的 `clickhouse` 二进制文件 `scp` 到服务器,然后像上面的示例一样运行它。 +`clickhouse` 二进制文件几乎没有依赖关系,并且可以在广泛的 Linux 发行版上运行。要在服务器上快速测试您的更改,您可以简单地将新构建的 `clickhouse` 二进制文件通过 `scp` 传送到服务器,然后像上面的示例一样运行它。 ## 构建测试 {#build-tests} -构建测试允许检查构建在各种替代配置和一些外部系统上的可用性。 -这些测试也是自动化的。 +构建测试允许检查构建在各种替代配置和某些外部系统上是否未损坏。这些测试也是自动化的。 示例: -- 为 Darwin x86_64 (macOS)交叉编译 -- 为 FreeBSD x86_64 交叉编译 -- 为 Linux AArch64 交叉编译 -- 在 Ubuntu 上使用系统软件包中的库构建(不推荐) -- 使用共享链接库构建(不推荐) +- 为 Darwin x86_64(macOS)进行交叉编译 +- 为 FreeBSD x86_64 进行交叉编译 +- 为 Linux AArch64 进行交叉编译 +- 在包含来自系统包的库的 Ubuntu 上构建(不推荐) +- 使用共享链接构建库(不推荐) -例如,使用系统软件包的构建是不好的做法,因为我们无法保证系统将具有什么确切版本的包。 -但这对于 Debian 维护者确实是非常需要的。 -因此,我们至少必须支持这个构建变体。 -另一个例子:共享链接是一种常见问题的来源,但一些爱好者需要它。 +例如,使用系统包进行构建是一种不良做法,因为我们无法保证系统将具有的确切版本的包。但这确实是 Debian 维护者需要的。出于这个原因,我们至少必须支持这种构建变体。另一个例子:共享链接是一个常见的麻烦来源,但某些爱好者需要它。 -尽管我们无法在所有构建变体中运行所有测试,但我们希望至少检查各种构建变体是否正常。 -为此,我们使用构建测试。 +尽管我们不能在所有构建变体上运行所有测试,但我们至少想检查各种构建变体是否未损坏。为此,我们使用构建测试。 -我们还测试没有单元过长而无法编译或需要过多 RAM。 +我们还测试没有翻译单元太长而无法编译或需要太多 RAM 的情况。 我们还测试没有过大的堆栈帧。 -## 测试协议兼容性 {#testing-for-protocol-compatibility} +## 协议兼容性测试 {#testing-for-protocol-compatibility} -当我们扩展 ClickHouse 网络协议时,我们手动测试旧的 `clickhouse-client` 是否能与新的 `clickhouse-server` 一起工作,以及新的 `clickhouse-client` 是否能与旧的 `clickhouse-server` 一起工作(简单地从相应包运行二进制文件)。 +当我们扩展 ClickHouse 网络协议时,我们手动测试旧版 clickhouse-client 是否与新版 clickhouse-server 兼容,以及新版 clickhouse-client 是否与旧版 clickhouse-server 兼容(通过运行相应包中的二进制文件简单测试)。 -我们还使用集成测试自动测试一些案例: -- 旧版本的 ClickHouse 写入的数据是否可以被新版本成功读取; -- 不同 ClickHouse 版本的集群中,分布式查询是否正常工作。 +我们还通过集成测试自动测试某些案例: +- 旧版本的 ClickHouse 写入的数据能否被新版本成功读取; +- 在具有不同 ClickHouse 版本的集群中,分布式查询是否有效。 ## 来自编译器的帮助 {#help-from-the-compiler} -主要的 ClickHouse 代码(位于 `src` 目录)使用 `-Wall -Wextra -Werror` 进行编译,并启用了某些其他警告。 -尽管这些选项未针对第三方库启用。 +主要的 ClickHouse 代码(位于 `src` 目录中)通过 `-Wall -Wextra -Werror` 编译,并打开了一些额外的警告。尽管这些选项未对第三方库启用。 -Clang 具有更有用的警告 - 您可以通过 `-Weverything` 查找它们并选择某些默认构建。 +Clang 具有更有用的警告 - 您可以使用 `-Weverything` 查找并选择一些默认构建。 -我们始终使用 clang 来构建 ClickHouse,用于开发和生产。 -您可以在自己的机器上以调试模式构建(以节省您的笔记本电池),但请注意,编译器能够通过更好的控制流和过程间分析生成更多警告,使用 `-O3`。 -在调试模式下使用 clang 构建时,使用调试版本的 `libc++`,这允许在运行时捕获更多错误。 +我们始终使用 clang 来构建 ClickHouse,无论是用于开发还是生产。您可以在自己的机器上使用调试模式进行构建(以节省笔记本电脑的电池),但请注意,编译器能够通过 `-O3` 生成更多警告,因为更好的控制流和过程间分析。使用调试模式构建时,使用调试版本的 `libc++`,这有助于在运行时捕获更多错误。 ## Sanitizers {#sanitizers} :::note -如果进程(ClickHouse 服务器或客户端)在本地启动时崩溃,您可能需要禁用地址空间布局随机化:`sudo sysctl kernel.randomize_va_space=0` +如果在本地运行时进程(ClickHouse 服务器或客户端)在启动时崩溃,您可能需要禁用地址空间布局随机化:`sudo sysctl kernel.randomize_va_space=0` ::: -### 地址清理器 {#address-sanitizer} +### 地址清理程序 {#address-sanitizer} -我们在每次提交时在 ASan 下运行功能、集成、压力和单元测试。 +我们在每个提交的基础上,在 ASan 下运行功能、集成、压力和单元测试。 -### 线程清理器 {#thread-sanitizer} +### 线程清理程序 {#thread-sanitizer} -我们在每次提交时在 TSan 下运行功能、集成、压力和单元测试。 +我们在每个提交的基础上,在 TSan 下运行功能、集成、压力和单元测试。 -### 内存清理器 {#memory-sanitizer} +### 内存清理程序 {#memory-sanitizer} -我们在每次提交时在 MSan 下运行功能、集成、压力和单元测试。 +我们在每个提交的基础上,在 MSan 下运行功能、集成、压力和单元测试。 -### 未定义行为清理器 {#undefined-behaviour-sanitizer} +### 未定义行为清理程序 {#undefined-behaviour-sanitizer} -我们在每次提交时在 UBSan 下运行功能、集成、压力和单元测试。 -一些第三方库的代码未针对 UB 进行清理。 +我们在每个提交的基础上,在 UBSan 下运行功能、集成、压力和单元测试。一些第三方库的代码没有针对未定义行为进行清理。 -### Valgrind(内存检查) {#valgrind-memcheck} +### Valgrind(内存检测) {#valgrind-memcheck} -我们曾经在 Valgrind 下运行功能测试,但现在不再这样做。 -它会花费几个小时的时间。 -目前,`re2` 库中有一个已知的误报,请参见 [这篇文章](https://research.swtch.com/sparse)。 +我们过去会在 Valgrind 下过夜运行功能测试,但现在不再这样做。这需要多个小时。目前在 `re2` 库中有一个已知的假阳性,请参阅 [这篇文章](https://research.swtch.com/sparse)。 ## 模糊测试 {#fuzzing} -ClickHouse 的模糊测试实现既使用 [libFuzzer](https://llvm.org/docs/LibFuzzer.html) 也使用随机 SQL 查询。 -所有模糊测试都应在带有清理器(地址和未定义)的情况下执行。 +ClickHouse 的模糊测试是通过 [libFuzzer](https://llvm.org/docs/LibFuzzer.html) 和随机 SQL 查询实现的。所有模糊测试都应在带有清理程序(地址和未定义)的情况下进行。 -LibFuzzer 用于库代码的独立模糊测试。 -模糊测试器作为测试代码的一部分实现,并具有 "_fuzzer" 名称后缀。 -模糊测试器示例可以在 `src/Parsers/fuzzers/lexer_fuzzer.cpp` 中找到。 -LibFuzzer 特定配置、字典和语料库存储在 `tests/fuzz` 中。我们鼓励您为每个处理用户输入的功能编写模糊测试。 +LibFuzzer 用于隔离库代码的模糊测试。模糊程序作为测试代码的一部分实现并带有 "_fuzzer" 名称后缀。模糊测试示例可以在 `src/Parsers/fuzzers/lexer_fuzzer.cpp` 中找到。特定于 LibFuzzer 的配置、字典和语料库存储在 `tests/fuzz` 中。我们鼓励您为每个处理用户输入的功能编写模糊测试。 -模糊测试器默认情况下并不构建。 -要构建模糊测试器,必须设置 `-DENABLE_FUZZING=1` 和 `-DENABLE_TESTS=1` 选项。 -我们建议在构建模糊测试器时禁用 Jemalloc。 -将 ClickHouse 模糊测试集成到 Google OSS-Fuzz 使用的配置可以在 `docker/fuzz` 中找到。 +模糊测试程序默认不构建。要构建模糊测试程序,必须设置 `-DENABLE_FUZZING=1` 和 `-DENABLE_TESTS=1` 选项。我们建议在构建模糊测试程序时禁用 Jemalloc。集成 ClickHouse 模糊测试到 Google OSS-Fuzz 所使用的配置可以在 `docker/fuzz` 中找到。 -我们还使用简单的模糊测试生成随机 SQL 查询,并检查服务器不会因执行它们而崩溃。 -您可以在 `00746_sql_fuzzy.pl` 中找到它。 -该测试应持续运行(过夜及更长时间)。 +我们还使用简单的模糊测试生成随机 SQL 查询,并检查服务器在执行这些查询时不会崩溃。您可以在 `00746_sql_fuzzy.pl` 中找到它。此测试应持续运行(过夜及更长时间)。 -我们还使用复杂的基于 AST 的查询模糊测试器,能够找到大量边界情况。 -它在查询 AST 中进行随机排列和替换。 -在处理它们时,它会记住来自先前测试的 AST 节点,以便为后续测试提供模糊处理,同时以随机顺序处理它们。 -您可以在 [这篇博客文章](https://clickhouse.com/blog/fuzzing-click-house) 中了解更多关于此模糊测试器的信息。 +我们还使用复杂的基于 AST 的查询模糊测试器,能够找到大量边界案例。它在查询 AST中进行随机排列和替换。它将以前测试中的 AST 节点存储下来,以便在处理后续测试时用于模糊测试,同时以随机顺序处理它们。您可以在 [这篇博客文章](https://clickhouse.com/blog/fuzzing-click-house) 中了解更多关于此模糊测试器的信息。 ## 压力测试 {#stress-test} -压力测试是另一种模糊测试。 -它并行以随机顺序运行所有功能测试,使用单一服务器。 -测试结果不被检查。 +压力测试是另一种模糊测试。它在单个服务器上以随机顺序并行运行所有功能测试。测试结果不会被检查。 -检查内容: -- 服务器不崩溃,没有调试或清理器陷阱触发; +已检查: +- 服务器不会崩溃,不会触发调试或清理程序陷阱; - 没有死锁; -- 数据库结构一致; -- 测试结束后,服务器可以成功停止并再次启动,没有异常。 +- 数据库结构是一致的; +- 服务器在测试后能够成功停止并重新启动而没有异常。 -有五种变体(Debug、ASan、TSan、MSan、UBSan)。 +有五种变体(调试、ASan、TSan、MSan、UBSan)。 -## 线程模糊测试 {#thread-fuzzer} +## 线程模糊测试器 {#thread-fuzzer} -线程模糊测试(请勿与线程清理器混淆)是一种允许随机化线程执行顺序的模糊测试。 -这有助于发现更多特殊情况。 +线程模糊测试器(请不要与线程清理器混淆)是另一种模糊测试,允许随机化线程的执行顺序。这有助于找到更多特殊案例。 ## 安全审计 {#security-audit} -我们的安全团队对 ClickHouse 从安全角度的能力进行了基本概述。 +我们的安全团队对 ClickHouse 功能进行了基本的安全审计。 ## 静态分析器 {#static-analyzers} -我们在每次提交时运行 `clang-tidy`。 -`clang-static-analyzer` 检查也已启用。 -`clang-tidy` 也用于某些样式检查。 +我们在每个提交的基础上运行 `clang-tidy`。还启用了 `clang-static-analyzer` 检查。`clang-tidy` 还用于一些风格检查。 -我们评估了 `clang-tidy`、`Coverity`、`cppcheck`、`PVS-Studio`、`tscancode`、`CodeQL`。 -您可以在 `tests/instructions/` 目录中找到使用说明。 +我们评估过 `clang-tidy`、`Coverity`、`cppcheck`、`PVS-Studio`、`tscancode`、`CodeQL`。您可以在 `tests/instructions/` 目录中找到使用说明。 -如果您使用 `CLion` 作为 IDE,您可以开箱即用地利用一些 `clang-tidy` 检查。 +如果您使用 `CLion` 作为 IDE,您可以直接利用一些 `clang-tidy` 检查。 -我们还使用 `shellcheck` 对 Shell 脚本进行静态分析。 +我们还使用 `shellcheck` 对 shell 脚本进行静态分析。 -## 加固 {#hardening} +## 强化 {#hardening} -在调试构建中,我们使用自定义分配器来进行用户级分配的 ASLR。 +在调试构建中,我们使用自定义分配器,对用户级别的内存分配进行 ASLR。 我们还手动保护预期在分配后为只读的内存区域。 -在调试构建中,我们还涉及 `libc` 的定制,以确保不会调用任何“有害”(过时、不安全、非线程安全)函数。 +在调试构建中,我们还涉及 libc 的定制,以确保不调用“有害”的(过时、不安全、不线程安全的)函数。 -调试断言被广泛使用。 +在调试构建中大量使用调试断言。 -在调试构建中,如果抛出带有“逻辑错误”代码(表明存在错误)的异常,则程序会过早终止。 -这允许在发布构建中使用异常,但在调试构建中则将其视为断言。 +在调试构建中,如果抛出包含“逻辑错误”代码的异常(表示存在错误),程序将提前终止。这允许在发布构建中使用异常,但在调试构建中将其视为断言。 -调试版本的 jemalloc 用于调试构建。 -调试版本的 libc++ 用于调试构建。 +为调试构建使用调试版本的 jemalloc。为调试构建使用调试版本的 libc++。 ## 运行时完整性检查 {#runtime-integrity-checks} -存储在磁盘上的数据具有校验和。 -MergeTree 表的数据通过三种方式同时进行校验和计算*(压缩的数据块、未压缩的数据块,以及跨块的总校验和)。 -在客户端和服务器之间,或服务器之间通过网络传输的数据,也会进行校验和检查。 -复制确保副本上的数据位相同。 +存储在磁盘上的数据是进行校验和检测的。MergeTree 表中的数据以三种方式进行校验和检测*(压缩数据块、未压缩数据块、块之间的总校验和)。通过网络在客户端与服务器之间或服务器之间传输的数据也是进行校验和检测的。复制确保副本上的数据是逐位相同的。 -需要防止有缺陷的硬件(存储介质上的位腐烂、服务器内存中的位翻转、网络控制器内存中的位翻转、网络交换机内存中的位翻转、客户端内存中的位翻转、数据线上的位翻转)。 -请注意,位翻转是常见的,并且可能会发生,即便是在使用 ECC RAM 和存在 TCP 校验和的情况下(如果您管理数千个每天处理数PB数据的服务器)。 -[请查看视频(俄语)](https://www.youtube.com/watch?v=ooBAQIe0KlQ)。 +这需要保护故障硬件(存储介质上的位腐烂、服务器 RAM 中的位翻转、网络控制器中的位翻转、网络交换机中的位翻转、客户端中的位翻转、数据传输线上的位翻转)。请注意,即使对于 ECC RAM 和存在 TCP 校验和的情况下,位翻转也是常见的,很可能发生(如果您成功地运行数千个服务器,每天处理 PB 的数据)。 +[观看视频(俄文)](https://www.youtube.com/watch?v=ooBAQIe0KlQ)。 -ClickHouse 提供诊断工具,帮助运维工程师找到有缺陷的硬件。 +ClickHouse 提供了诊断工具,这将帮助运维工程师找到故障硬件。 -\* 并且这并不慢。 +\*并且并不慢。 ## 代码风格 {#code-style} -代码风格规则在 [这里](style.md) 描述。 +代码风格规则在 [这里](style.md) 进行描述。 要检查一些常见的风格违规,您可以使用 `utils/check-style` 脚本。 -要强制您的代码遵循正确的风格,您可以使用 `clang-format`。 -文件 `.clang-format` 位于源代码根目录。 -它大致对应于我们实际的代码风格。 -但不推荐对现有文件应用 `clang-format`,因为这会导致格式变得更糟。 -您可以使用 `clang-format-diff` 工具,可以在 clang 源代码库中找到。 +要强制代码采用适当的风格,您可以使用 `clang-format`。文件 `.clang-format` 位于源代码根目录。它主要对应于我们实际的代码风格。但不推荐将 `clang-format` 应用于现有文件,因为这会使格式变得更差。您可以使用 `clang-format-diff` 工具,该工具可以在 clang 源代码仓库中找到。 -或者,您可以尝试使用 `uncrustify` 工具来重新格式化您的代码。 -配置在源代码根目录的 `uncrustify.cfg` 中。 -它的测试不如 `clang-format` 完善。 +或者,您可以尝试 `uncrustify` 工具来重新格式化您的代码。配置位于源代码根目录的 `uncrustify.cfg` 中。它的测试程度不如 `clang-format`。 -`CLion` 有自己的代码格式化程序,需要根据我们的代码风格进行调整。 +`CLion` 有自己的代码格式化工具,但必须为我们的代码风格进行调整。 -我们还使用 `codespell` 找到代码中的拼写错误。 -这也是自动化的。 +我们还使用 `codespell` 查找代码中的拼写错误。这也是自动化的。 -## 测试覆盖 {#test-coverage} +## 测试覆盖率 {#test-coverage} -我们也跟踪测试覆盖率,但仅针对功能测试,并且仅针对 clickhouse-server。 -这在每日基础上进行。 +我们还跟踪测试覆盖率,但仅针对功能测试以及仅针对 clickhouse-server。它是每日进行的。 ## 测试的测试 {#tests-for-tests} -有自动检查脆弱测试的机制。 -它运行所有新测试100次(对于功能测试)或10次(对于集成测试)。 -如果至少有一次测试失败,它被认为是脆弱的。 +有自动化检查不稳定测试的功能。它对所有新测试运行 100 次(对于功能测试)或 10 次(对于集成测试)。如果至少有一次测试失败,则视为不稳定测试。 ## 测试自动化 {#test-automation} -我们使用 [GitHub Actions](https://github.com/features/actions) 运行测试。 +我们通过 [GitHub Actions](https://github.com/features/actions) 运行测试。 -构建作业和测试在每次提交时在沙箱中运行。 -生成的包和测试结果被发布在 GitHub 上,可以通过直接链接下载。 -工件储存几个月。 -当您在 GitHub 上提交拉取请求时,我们将其标记为“可以测试”,我们的 CI 系统将为您构建 ClickHouse 包(发布版、调试版、带地址清理器的版本等)。 +构建任务和测试在每个提交的基础上在 Sandbox 中运行。生成的包和测试结果发布在 GitHub 上,可以通过直接链接下载。工件将存储几个月。 当您在 GitHub 上发送拉取请求时,我们将其标记为“可以测试”,我们的 CI 系统将为您构建 ClickHouse 包(发布版、调试版、带地址清理程序等)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/development/tests.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/development/tests.md.hash index c1f2b78eb0d..542d5cf4481 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/development/tests.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/development/tests.md.hash @@ -1 +1 @@ -a781c03d60105b25 +ef933ca4daa970ab diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/dictionary/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/dictionary/index.md index d9d7d7e9e34..5d75be7f719 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/dictionary/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/dictionary/index.md @@ -4,7 +4,8 @@ 'keywords': - 'dictionary' - 'dictionaries' -'description': '字典提供了一个键值表示的数据,便于快速查找。' +'description': '字典提供数据的键值表示,以便快速查找。' +'doc_type': 'reference' --- import dictionaryUseCases from '@site/static/images/dictionary/dictionary-use-cases.png'; @@ -14,32 +15,32 @@ import Image from '@theme/IdealImage'; # 字典 -ClickHouse 中的字典提供了一种来自各种 [内部和外部来源](/sql-reference/dictionaries#dictionary-sources) 的内存 [键值](https://en.wikipedia.org/wiki/Key%E2%80%93value_database) 表示,优化超低延迟查找查询。 +ClickHouse中的字典提供了来自各种 [内部和外部源](/sql-reference/dictionaries#dictionary-sources) 的数据的内存 [键值](https://en.wikipedia.org/wiki/Key%E2%80%93value_database) 表示,优化了超低延迟查找查询。 字典的用途包括: -- 提高查询性能,特别是在与 `JOIN` 一起使用时 -- 在不中断摄取过程的情况下动态丰富摄取的数据 +- 提高查询性能,尤其是在与 `JOIN` 一起使用时 +- 在不中断数据摄取过程的情况下动态丰富摄取的数据 -ClickHouse 中字典的用例 +ClickHouse中字典的使用案例 -## 使用字典加速 JOIN {#speeding-up-joins-using-a-dictionary} +## 使用字典加速连接 {#speeding-up-joins-using-a-dictionary} 字典可以用来加速特定类型的 `JOIN`:[`LEFT ANY` 类型](/sql-reference/statements/select/join#supported-types-of-join),其中连接键需要匹配底层键值存储的键属性。 -使用字典与 LEFT ANY JOIN +使用字典与LEFT ANY JOIN -如果是这种情况,ClickHouse 可以利用字典执行 [直接连接](https://clickhouse.com/blog/clickhouse-fully-supports-joins-direct-join-part4#direct-join)。这是 ClickHouse 的最快连接算法,当右侧表的 [表引擎](/engines/table-engines) 支持低延迟键值请求时适用。ClickHouse 具有三个提供此功能的表引擎:[Join](/engines/table-engines/special/join)(基本上是一个预计算的哈希表)、[EmbeddedRocksDB](/engines/table-engines/integrations/embedded-rocksdb) 和 [Dictionary](/engines/table-engines/special/dictionary)。我们将描述基于字典的方法,但所有三个引擎的机制是相同的。 +如果是这种情况,ClickHouse可以利用字典执行 [直接连接](https://clickhouse.com/blog/clickhouse-fully-supports-joins-direct-join-part4#direct-join)。这是ClickHouse最快的连接算法,适用于右侧表的底层 [表引擎](/engines/table-engines) 支持低延迟键值请求。ClickHouse有三个提供此功能的表引擎:[Join](/engines/table-engines/special/join)(实际上是预计算的哈希表)、[EmbeddedRocksDB](/engines/table-engines/integrations/embedded-rocksdb) 和 [Dictionary](/engines/table-engines/special/dictionary)。我们将描述基于字典的方法,但这三种引擎的机制是相同的。 -直接连接算法要求右表由字典支持,使得待连接的数据在内存中以低延迟的键值数据结构的形式存在。 +直接连接算法要求右侧表由字典支持,以便待连接的数据以低延迟键值数据结构的形式存在于内存中。 ### 示例 {#example} -使用 Stack Overflow 数据集,我们来回答这个问题: -*Hacker News 上有关 SQL 的最具争议的帖子是什么?* +使用Stack Overflow数据集,我们来回答这个问题: +*关于SQL的争议帖子是什么?* -我们将争议定义为帖子有相似的支持和反对票数。我们计算这个绝对差值,接近 0 的值意味着更大的争议。我们假设帖子必须至少有 10 个支持和反对票 - 没有人投票的帖子并不是很有争议。 +我们将定义争议为当帖子有相似数量的赞成票和反对票时。我们计算这个绝对差值,值越接近0表示争议越大。我们假设帖子必须至少有10个赞成票和反对票——没有人投票的帖子并不是很有争议。 -在数据标准化之后,这个查询目前需要使用 `posts` 和 `votes` 表的 `JOIN`: +在我们的数据规范化之后,这个查询目前需要使用 `posts` 和 `votes` 表的 `JOIN`: ```sql WITH PostIds AS @@ -82,13 +83,13 @@ Controversial_ratio: 0 Peak memory usage: 3.18 GiB. ``` -> **在 `JOIN` 的右侧使用较小的数据集**:这个查询看起来可能比必要的要冗长,因为 `PostId` 的过滤发生在外部和子查询中。这是一种性能优化,确保查询响应时间快速。为了最佳性能,请始终确保 `JOIN` 的右侧是较小的集合,并尽可能小。有关优化 JOIN 性能和了解可用算法的提示,我们推荐 [这一系列博文](https://clickhouse.com/blog/clickhouse-fully-supports-joins-part1)。 +>**在 `JOIN` 的右侧使用较小的数据集**:这个查询可能看起来比实际所需的冗长,因为在外层和子查询中都对 `PostId` 进行过滤。这是一种性能优化,确保查询响应时间快速。为了获得最佳性能,始终确保 `JOIN` 的右侧是较小的集合,并尽可能小。有关优化 `JOIN` 性能和理解可用算法的提示,我们建议 [这系列博客文章](https://clickhouse.com/blog/clickhouse-fully-supports-joins-part1)。 -虽然这个查询很快,但它依赖于我们仔细编写 `JOIN` 来实现良好的性能。理想情况下,我们可以在查看 `UpVote` 和 `DownVote` 计数之前,仅过滤出包含 “SQL” 的帖子。 +尽管这个查询很快,但它依赖于我们仔细编写 `JOIN` 来实现良好的性能。理想情况下,我们会在查看子集的 `UpVote` 和 `DownVote` 计数之前,仅过滤包含“SQL”的帖子,以便计算我们的指标。 #### 应用字典 {#applying-a-dictionary} -为了演示这些概念,我们使用字典来存储我们的投票数据。由于字典通常保存在内存中([ssd_cache](/sql-reference/dictionaries#ssd_cache) 是例外),用户应意识到数据的大小。确认我们的 `votes` 表的大小: +为了展示这些概念,我们使用字典来处理我们的投票数据。由于字典通常存储在内存中([ssd_cache](/sql-reference/dictionaries#ssd_cache) 是例外),用户应注意数据的大小。确认我们的 `votes` 表的大小: ```sql SELECT table, @@ -104,11 +105,11 @@ GROUP BY table └─────────────────┴─────────────────┴───────────────────┴───────┘ ``` -数据将以未压缩的形式存储在我们的字典中,因此如果我们要在字典中存储所有列,内存至少需要 4GB(实际上我们不会存储所有列)。字典将在我们的集群中进行复制,因此每个节点需要保留这种内存量。 +数据将在我们的字典中未压缩存储,因此如果我们要在字典中存储所有列(我们不会),则需要至少4GB的内存。字典将在我们的集群中复制,因此此内存量需要按 *节点* 保留。 -> 在下面的示例中,我们的字典数据来自 ClickHouse 表。虽然这代表了字典的最常见来源,但支持 [多种来源](/sql-reference/dictionaries#dictionary-sources),包括文件、http 和数据库,包括 [Postgres](/sql-reference/dictionaries#postgresql)。正如我们所示,字典可以自动刷新,提供一种确保频繁更改的小数据集可用于直接连接的理想方法。 +> 在下面的示例中,我们的字典数据源来自一个ClickHouse表。虽然这代表了字典中最常见的数据源,但支持包括文件、http和数据库(如 [Postgres](/sql-reference/dictionaries#postgresql))在内的 [许多来源](/sql-reference/dictionaries#dictionary-sources)。正如我们将展示的,字典可以自动刷新,提供了一种理想的方式来确保频繁更改的小数据集可用于直接连接。 -我们的字典需要一个主键,以便执行查找。这在概念上与事务性数据库的主键是相同的,并且应该是唯一的。我们上述查询需要在连接键上查找 - `PostId`。字典应相应地填充来自我们 `votes` 表的每个 `PostId` 的支持和反对票总数。以下是获取此字典数据的查询: +我们的字典需要一个主键,用于进行查找。这在概念上与事务性数据库的主键相同,并且应该是唯一的。我们上述的查询需要在连接键上进行查找 - `PostId`。字典应填充自 `votes` 表的每个 `PostId` 的总赞成票和反对票。以下是获取此字典数据的查询: ```sql SELECT PostId, @@ -118,7 +119,7 @@ FROM votes GROUP BY PostId ``` -要创建我们的字典需要以下 DDL - 注意我们上述查询的使用: +创建我们的字典需要以下DDL - 请注意使用我们上述的查询: ```sql CREATE DICTIONARY votes_dict @@ -135,9 +136,9 @@ LAYOUT(HASHED()) 0 rows in set. Elapsed: 36.063 sec. ``` -> 在自管理的 OSS 中,上述命令需要在所有节点上执行。在 ClickHouse Cloud 中,字典将自动复制到所有节点。上述操作在具有 64GB RAM 的 ClickHouse Cloud 节点上执行,耗时 36 秒进行加载。 +> 在自管理的OSS中,上述命令需要在所有节点上执行。在ClickHouse Cloud中,字典将自动复制到所有节点。上述命令在具有64GB RAM的ClickHouse Cloud节点上执行,花费了36秒来加载。 -要确认我们的字典消耗的内存: +确认我们的字典所消耗的内存: ```sql SELECT formatReadableSize(bytes_allocated) AS size @@ -149,7 +150,7 @@ WHERE name = 'votes_dict' └──────────┘ ``` -现在,可以使用简单的 `dictGet` 函数检索特定 `PostId` 的支持和反对票。以下是我们检索 `11227902` 帖子的值: +检索特定 `PostId` 的赞成票和反对票现在可以通过一个简单的 `dictGet` 函数来实现。以下是我们为帖子 `11227902` 检索的值: ```sql SELECT dictGet('votes_dict', ('UpVotes', 'DownVotes'), '11227902') AS votes @@ -158,7 +159,6 @@ SELECT dictGet('votes_dict', ('UpVotes', 'DownVotes'), '11227902') AS votes │ (34999,32) │ └────────────┘ - Exploiting this in our earlier query, we can remove the JOIN: WITH PostIds AS @@ -180,11 +180,11 @@ LIMIT 3 Peak memory usage: 552.26 MiB. ``` -这个查询不仅简单得多,而且还快了两倍以上!我们可以进一步优化,只将超过 10 个支持和反对票的帖子加载到字典中,并只存储预计算的争议值。 +这个查询不仅更简单,而且还快了两倍以上!这可以通过仅将赞成票和反对票均超过10的帖子加载到字典中并仅存储预计算的争议值来进一步优化。 -## 查询时间丰富 {#query-time-enrichment} +## 查询时丰富 {#query-time-enrichment} -字典可以用于查询时查找值。这些值可以在结果中返回或用于聚合。假设我们创建一个字典,用于将用户 ID 映射到他们的位置: +字典可以在查询时查找值。这些值可以在结果中返回或用于聚合。假设我们创建一个字典,将用户ID映射到他们的位置: ```sql CREATE DICTIONARY users_dict @@ -210,10 +210,8 @@ WHERE Title ILIKE '%clickhouse%' LIMIT 5 FORMAT PrettyCompactMonoBlock - - ┌───────Id─┬─Title─────────────────────────────────────────────────────────┬─Location──────────────┐ -│ 52296928 │ Comparision between two Strings in ClickHouse │ Spain │ +│ 52296928 │ Comparison between two Strings in ClickHouse │ Spain │ │ 52345137 │ How to use a file to migrate data from mysql to a clickhouse? │ 中国江苏省Nanjing Shi │ │ 61452077 │ How to change PARTITION in clickhouse │ Guangzhou, 广东省中国 │ │ 55608325 │ Clickhouse select last record without max() on all table │ Moscow, Russia │ @@ -224,7 +222,7 @@ FORMAT PrettyCompactMonoBlock Peak memory usage: 249.32 MiB. ``` -与我们上述的连接示例类似,我们可以使用同一个字典有效确定大多数帖子来自何处: +与我们上述的连接示例类似,我们可以使用相同的字典高效地确定大多数帖子来自哪里: ```sql SELECT @@ -248,13 +246,13 @@ LIMIT 5 Peak memory usage: 248.84 MiB. ``` -## 索引时间丰富 {#index-time-enrichment} +## 索引时丰富 {#index-time-enrichment} -在上面的示例中,我们在查询时间使用字典来移除连接。字典也可以在插入时用于丰富行。这通常适用于补充值没有变化且来自外部源,可以用于填充字典的情况。在这种情况下,在插入时丰富行可以避免查询时间查找字典。 +在上述示例中,我们在查询时使用字典来消除连接。字典还可以在插入时丰富行。这通常适用于如果丰富值不会改变并且存在于可用于填充字典的外部源中。在这种情况下,在插入时丰富行可以避免查询时查找字典。 -假设 Stack Overflow 中用户的 `Location` 永远不会改变(实际上他们会改变) - 特别是 `users` 表中的 `Location` 列。假设我们希望按位置对帖子表进行分析查询。此表包含一个 `UserId`。 +假设Stack Overflow中用户的 `Location` 从未改变(实际上是会改变的)——具体来说是 `users` 表的 `Location` 列。假设我们希望按位置对帖子表进行分析查询。它包含一个 `UserId`。 -字典提供从用户 ID 到位置的映射,后面支撑着 `users` 表: +字典提供了从用户ID到位置的映射,由 `users` 表支持: ```sql CREATE DICTIONARY users_dict @@ -268,9 +266,9 @@ LIFETIME(MIN 600 MAX 900) LAYOUT(HASHED()) ``` -> 我们省略 `Id < 0` 的用户,使我们能够使用 `Hashed` 字典类型。具有 `Id < 0` 的用户是系统用户。 +> 我们省略 `Id < 0` 的用户,从而允许使用 `Hashed` 字典类型。 `Id < 0` 的用户是系统用户。 -为了在帖子表的插入时间利用该字典,我们需要修改架构: +为了在帖子表的插入时利用该字典,我们需要修改模式: ```sql CREATE TABLE posts_with_location @@ -284,11 +282,11 @@ ENGINE = MergeTree ORDER BY (PostTypeId, toDate(CreationDate), CommentCount) ``` -在上述示例中,`Location` 被声明为 `MATERIALIZED` 列。这意味着该值可以作为 `INSERT` 查询的一部分提供,并将始终被计算。 +在上述示例中,`Location` 被声明为 `MATERIALIZED` 列。这意味着该值可以作为 `INSERT` 查询的一部分提供,并且将始终计算。 -> ClickHouse 还支持 [`DEFAULT` 列](/sql-reference/statements/create/table#default_values)(如果未提供,可以插入或计算_value)。 +> ClickHouse还支持 [`DEFAULT` 列](/sql-reference/statements/create/table#default_values)(如果未提供,则可以插入或计算值)。 -要填充表,我们可以使用通常的 `INSERT INTO SELECT` 从 S3: +我们可以使用通常的 `INSERT INTO SELECT` 从S3填充表: ```sql INSERT INTO posts_with_location SELECT Id, PostTypeId::UInt8, AcceptedAnswerId, CreationDate, Score, ViewCount, Body, OwnerUserId, OwnerDisplayName, LastEditorUserId, LastEditorDisplayName, LastEditDate, LastActivityDate, Title, Tags, AnswerCount, CommentCount, FavoriteCount, ContentLicense, ParentId, CommunityOwnedDate, ClosedDate FROM s3('https://datasets-documentation.s3.eu-west-3.amazonaws.com/stackoverflow/parquet/posts/*.parquet') @@ -296,7 +294,7 @@ INSERT INTO posts_with_location SELECT Id, PostTypeId::UInt8, AcceptedAnswerId, 0 rows in set. Elapsed: 36.830 sec. Processed 238.98 million rows, 2.64 GB (6.49 million rows/s., 71.79 MB/s.) ``` -我们现在可以获得来自大多数帖子的位置名称: +我们现在可以获取大多数帖子来源的地点名称: ```sql SELECT Location, count() AS c @@ -321,20 +319,20 @@ Peak memory usage: 666.82 MiB. ### 选择字典 `LAYOUT` {#choosing-the-dictionary-layout} -`LAYOUT` 子句控制字典的内部数据结构。有多种选项,文档记录 [在这里](/sql-reference/dictionaries#ways-to-store-dictionaries-in-memory)。选择正确布局的一些提示可以在 [这里](https://clickhouse.com/blog/faster-queries-dictionaries-clickhouse#choosing-a-layout) 找到。 +`LAYOUT` 子句控制字典的内部数据结构。存在多种选项,并在 [这里](/sql-reference/dictionaries#ways-to-store-dictionaries-in-memory) 进行了文档记录。有关选择正确布局的一些提示可以在 [这里](https://clickhouse.com/blog/faster-queries-dictionaries-clickhouse#choosing-a-layout) 找到。 ### 刷新字典 {#refreshing-dictionaries} -我们为字典指定了一个 `LIFETIME` 值为 `MIN 600 MAX 900`。LIFETIME 是字典的更新间隔,此处的值使字典在 600 到 900 秒之间的随机间隔周期性重新加载。这个随机间隔是必要的,以便在大量服务器上更新时分散字典源的负载。在更新过程中,可以继续查询字典的旧版本,只有初始加载会阻塞查询。请注意,设置 `(LIFETIME(0))` 会阻止字典更新。 +我们为字典指定了 `LIFETIME` 为 `MIN 600 MAX 900`。LIFETIME 是字典的更新间隔,这里的值导致在600至900秒之间的随机间隔进行周期性重新加载。这个随机间隔是必要的,以便在对大量服务器进行更新时分配字典源的负载。在更新期间,可以查询旧版本的字典,只有初始加载会阻塞查询。请注意,设置 `(LIFETIME(0))` 会阻止字典更新。 可以使用 `SYSTEM RELOAD DICTIONARY` 命令强制重新加载字典。 -对于 ClickHouse 和 Postgres 等数据库源,可以设置一个查询,该查询仅在字典确实发生更改时更新字典(查询的响应决定这一点),而不是在定期间隔内。进一步的细节可以在 [这里](/sql-reference/dictionaries#refreshing-dictionary-data-using-lifetime)找到。 +对于ClickHouse和Postgres等数据库来源,您可以设置一个查询,仅在字典真的发生变化时更新(查询的响应决定这一点),而不是在周期性间隔。有关进一步的细节,可以在 [这里](/sql-reference/dictionaries#refreshing-dictionary-data-using-lifetime) 找到。 ### 其他字典类型 {#other-dictionary-types} -ClickHouse 还支持 [分层](/sql-reference/dictionaries#hierarchical-dictionaries)、[多边形](/sql-reference/dictionaries#polygon-dictionaries) 和 [正则表达式](/sql-reference/dictionaries#regexp-tree-dictionary) 字典。 +ClickHouse还支持 [层次](/sql-reference/dictionaries#hierarchical-dictionaries)、[多边形](/sql-reference/dictionaries#polygon-dictionaries) 和 [正则表达式](/sql-reference/dictionaries#regexp-tree-dictionary) 字典。 -### 进一步阅读 {#more-reading} +### 更多阅读 {#more-reading} - [使用字典加速查询](https://clickhouse.com/blog/faster-queries-dictionaries-clickhouse) - [字典的高级配置](/sql-reference/dictionaries) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/dictionary/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/dictionary/index.md.hash index a5676f6741b..4d85b5bfea8 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/dictionary/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/dictionary/index.md.hash @@ -1 +1 @@ -d09e32ee182ee986 +a48e5f19ffb34d17 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/atomic.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/atomic.md index c4a7651bb96..c9630195aac 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/atomic.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/atomic.md @@ -5,24 +5,25 @@ 'sidebar_position': 10 'slug': '/engines/database-engines/atomic' 'title': '原子' +'doc_type': 'reference' --- -# Atomic +# 原子引擎 -`Atomic` 引擎支持非阻塞的 [`DROP TABLE`](#drop-detach-table) 和 [`RENAME TABLE`](#rename-table) 查询,并且支持原子性 [`EXCHANGE TABLES`](#exchange-tables) 查询。 `Atomic` 数据库引擎是默认使用的引擎。 +`Atomic` 引擎支持非阻塞的 [`DROP TABLE`](#drop-detach-table) 和 [`RENAME TABLE`](#rename-table) 查询,以及原子性的 [`EXCHANGE TABLES`](#exchange-tables) 查询。`Atomic` 数据库引擎是开源 ClickHouse 的默认引擎。 :::note -在 ClickHouse Cloud 中,默认使用的是 `Replicated` 数据库引擎。 +在 ClickHouse Cloud 中,默认使用 [`Shared` 数据库引擎](/cloud/reference/shared-catalog#shared-database-engine),也支持上述操作。 ::: ## 创建数据库 {#creating-a-database} ```sql -CREATE DATABASE test [ENGINE = Atomic]; +CREATE DATABASE test [ENGINE = Atomic] [SETTINGS disk=...]; ``` -## 具体事项和推荐 {#specifics-and-recommendations} +## 特性和建议 {#specifics-and-recommendations} ### 表 UUID {#table-uuid} @@ -34,7 +35,7 @@ CREATE DATABASE test [ENGINE = Atomic]; 其中 `xxxyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy` 是表的 UUID。 -默认情况下,UUID 是自动生成的。然而,用户可以在创建表时显式指定 UUID,但这并不推荐。 +默认情况下,UUID 是自动生成的。然而,用户在创建表时可以显式指定 UUID,但不推荐这样做。 例如: @@ -43,35 +44,44 @@ CREATE TABLE name UUID '28f1c61c-2970-457a-bffe-454156ddcfef' (n UInt64) ENGINE ``` :::note -您可以使用 [show_table_uuid_in_table_create_query_if_not_nil](../../operations/settings/settings.md#show_table_uuid_in_table_create_query_if_not_nil) 设置,通过 `SHOW CREATE` 查询显示 UUID。 +您可以使用 [show_table_uuid_in_table_create_query_if_not_nil](../../operations/settings/settings.md#show_table_uuid_in_table_create_query_if_not_nil) 设置,在 `SHOW CREATE` 查询中显示 UUID。 ::: ### RENAME TABLE {#rename-table} -[`RENAME`](../../sql-reference/statements/rename.md) 查询不会修改 UUID 或移动表数据。这些查询立即执行,不会等待其他使用该表的查询完成。 +[`RENAME`](../../sql-reference/statements/rename.md) 查询不会修改 UUID 或移动表数据。这些查询会立即执行,并且不会等待其他使用该表的查询完成。 ### DROP/DETACH TABLE {#drop-detach-table} -使用 `DROP TABLE` 时,不会删除任何数据。 `Atomic` 引擎仅通过将元数据移动到 `/clickhouse_path/metadata_dropped/` 来标记表为已删除,并通知后台线程。在最终删除表数据之前的延迟由 [`database_atomic_delay_before_drop_table_sec`](../../operations/server-configuration-parameters/settings.md#database_atomic_delay_before_drop_table_sec) 设置指定。 -您可以使用 `SYNC` 修饰符指定同步模式。使用 [`database_atomic_wait_for_drop_and_detach_synchronously`](../../operations/settings/settings.md#database_atomic_wait_for_drop_and_detach_synchronously) 设置来实现这一点。在这种情况下,`DROP` 会等待使用该表的正在运行的 `SELECT`、`INSERT` 和其他查询完成。表在未被使用时将被删除。 +使用 `DROP TABLE` 时,不会移除任何数据。`Atomic` 引擎只是通过将表的元数据移动到 `/clickhouse_path/metadata_dropped/` 来将表标记为已删除,并通知后台线程。在最终删除表数据之前的延迟由 [`database_atomic_delay_before_drop_table_sec`](../../operations/server-configuration-parameters/settings.md#database_atomic_delay_before_drop_table_sec) 设置指定。 +您可以使用 `SYNC` 修饰符指定同步模式。使用 [`database_atomic_wait_for_drop_and_detach_synchronously`](../../operations/settings/settings.md#database_atomic_wait_for_drop_and_detach_synchronously) 设置来实现。在这种情况下,`DROP` 等待正在运行的 `SELECT`、`INSERT` 和其他使用该表的查询完成。当表不再使用时,将被删除。 ### EXCHANGE TABLES/DICTIONARIES {#exchange-tables} -[`EXCHANGE`](../../sql-reference/statements/exchange.md) 查询以原子方式交换表或字典。例如,您可以替换以下非原子操作: +[`EXCHANGE`](../../sql-reference/statements/exchange.md) 查询原子性地交换表或字典。例如,您可以使用以下原子操作替代此非原子操作: ```sql title="Non-atomic" RENAME TABLE new_table TO tmp, old_table TO new_table, tmp TO old_table; ``` -您可以使用原子操作: +您可以使用一个原子操作: ```sql title="Atomic" EXCHANGE TABLES new_table AND old_table; ``` -### ReplicatedMergeTree 在 Atomic 数据库中 {#replicatedmergetree-in-atomic-database} +### 原子数据库中的 ReplicatedMergeTree {#replicatedmergetree-in-atomic-database} -对于 [`ReplicatedMergeTree`](/engines/table-engines/mergetree-family/replication) 表,建议不要为 ZooKeeper 中的路径和副本名称指定引擎参数。在这种情况下,将使用配置参数 [`default_replica_path`](../../operations/server-configuration-parameters/settings.md#default_replica_path) 和 [`default_replica_name`](../../operations/server-configuration-parameters/settings.md#default_replica_name)。如果您想显式指定引擎参数,建议使用 `{uuid}` 宏。这确保在 ZooKeeper 中为每个表自动生成唯一的路径。 +对于 [`ReplicatedMergeTree`](/engines/table-engines/mergetree-family/replication) 表,建议不要为 ZooKeeper 中的路径和副本名称指定引擎参数。在这种情况下,将使用配置参数 [`default_replica_path`](../../operations/server-configuration-parameters/settings.md#default_replica_path) 和 [`default_replica_name`](../../operations/server-configuration-parameters/settings.md#default_replica_name)。如果您想显式指定引擎参数,建议使用 `{uuid}` 宏。这确保为每个表在 ZooKeeper 中自动生成唯一的路径。 -## 另见 {#see-also} +### 元数据磁盘 {#metadata-disk} +当在 `SETTINGS` 中指定 `disk` 时,该磁盘用于存储表的元数据文件。 +例如: + +```sql +CREATE TABLE db (n UInt64) ENGINE = Atomic SETTINGS disk=disk(type='local', path='/var/lib/clickhouse-disks/db_disk'); +``` +如果未指定,将默认使用 `database_disk.disk` 中定义的磁盘。 + +## 另请参见 {#see-also} - [system.databases](../../operations/system-tables/databases.md) 系统表 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/atomic.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/atomic.md.hash index 84eda628352..b7005d80755 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/atomic.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/atomic.md.hash @@ -1 +1 @@ -62bf021f2ce93332 +58e472c998dfa0b3 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/backup.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/backup.md index a1e8d6127c0..b07ecc157ac 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/backup.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/backup.md @@ -1,17 +1,18 @@ --- -'description': '允许以只读模式立即从备份中附加表/数据库。' +'description': '允许以只读模式即时从备份中附加表/数据库。' 'sidebar_label': '备份' 'sidebar_position': 60 'slug': '/engines/database-engines/backup' 'title': '备份' +'doc_type': 'reference' --- # 备份 -数据库备份允许即时以只读模式附加来自 [备份](../../operations/backup) 的表/数据库。 +数据库备份允许立即以只读模式从 [备份](../../operations/backup) 附加表/数据库。 -数据库备份可以使用增量备份和非增量备份。 +数据库备份适用于增量备份和非增量备份。 ## 创建数据库 {#creating-a-database} @@ -20,7 +21,7 @@ CREATE DATABASE backup_database ENGINE = Backup('database_name_inside_backup', 'backup_destination') ``` -备份目标可以是任何有效的备份 [目标](../../operations/backup#configure-a-backup-destination),如 `Disk`,`S3`,`File`。 +备份目标可以是任何有效的备份 [目标](../../operations/backup#configure-a-backup-destination),例如 `Disk`、`S3`、`File`。 使用 `Disk` 备份目标,从备份创建数据库的查询如下所示: @@ -31,12 +32,12 @@ ENGINE = Backup('database_name_inside_backup', Disk('disk_name', 'backup_name')) **引擎参数** -- `database_name_inside_backup` — 备份中的数据库名称。 +- `database_name_inside_backup` — 备份内数据库的名称。 - `backup_destination` — 备份目标。 ## 使用示例 {#usage-example} -让我们用 `Disk` 备份目标做一个示例。首先,在 `storage.xml` 中设置备份磁盘: +让我们用一个 `Disk` 备份目标来做一个示例。首先在 `storage.xml` 中设置备份磁盘: ```xml @@ -53,7 +54,7 @@ ENGINE = Backup('database_name_inside_backup', Disk('disk_name', 'backup_name')) ``` -使用示例。让我们创建测试数据库、表,插入一些数据,然后创建一个备份: +使用示例。我们先创建测试数据库、表,插入一些数据,然后创建一个备份: ```sql CREATE DATABASE test_database; @@ -70,7 +71,7 @@ INSERT INTO test_database.test_table_3 VALUES (0, 'test_database.test_table_3'); BACKUP DATABASE test_database TO Disk('backups', 'test_database_backup'); ``` -所以现在我们有了 `test_database_backup` 备份,让我们创建数据库 Backup: +现在我们有了 `test_database_backup` 备份,让我们创建数据库 Backup: ```sql CREATE DATABASE test_database_backup ENGINE = Backup('test_database', Disk('backups', 'test_database_backup')); @@ -98,7 +99,7 @@ SELECT id, value FROM test_database_backup.test_table_3; └────┴────────────────────────────┘ ``` -我们也可以像使用任何普通数据库一样处理这个数据库 Backup。例如查询其中的表: +也可以将这个数据库 Backup 作为任何普通数据库进行操作。例如查询其中的表: ```sql SELECT database, name FROM system.tables WHERE database = 'test_database_backup': diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/backup.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/backup.md.hash index d1a0b48ba10..27a844a1cbe 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/backup.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/backup.md.hash @@ -1 +1 @@ -e12e92b1b21d23aa +e15ca4fde0601d4d diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/datalake.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/datalake.md new file mode 100644 index 00000000000..abbf3158011 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/datalake.md @@ -0,0 +1,65 @@ +--- +'description': 'DataLakeCatalog 数据库引擎使您能够将 ClickHouse 连接到外部数据目录并查询开放表格式数据' +'sidebar_label': 'DataLakeCatalog' +'slug': '/engines/database-engines/datalakecatalog' +'title': 'DataLakeCatalog' +'doc_type': 'reference' +--- + + +# DataLakeCatalog + +`DataLakeCatalog` 数据库引擎使您能够将 ClickHouse 连接到外部数据目录,并查询开放表格式数据,无需数据重复。这将 ClickHouse 转变为一个强大的查询引擎,可以与您现有的数据湖基础设施无缝协作。 + +## Supported catalogs {#supported-catalogs} + +`DataLakeCatalog` 引擎支持以下数据目录: + +- **AWS Glue Catalog** - 用于 AWS 环境中的 Iceberg 表 +- **Databricks Unity Catalog** - 用于 Delta Lake 和 Iceberg 表 +- **Hive Metastore** - 传统 Hadoop 生态系统目录 +- **REST Catalogs** - 支持 Iceberg REST 规范的任何目录 + +## Creating a database {#creating-a-database} + +您需要启用以下相关设置以使用 `DataLakeCatalog` 引擎: + +```sql +SET allow_experimental_database_iceberg = 1; +SET allow_experimental_database_unity_catalog = 1; +SET allow_experimental_database_glue_catalog = 1; +SET allow_experimental_database_hms_catalog = 1; +``` + +使用以下语法可以创建带有 `DataLakeCatalog` 引擎的数据库: + +```sql +CREATE DATABASE database_name +ENGINE = DataLakeCatalog(catalog_endpoint[, user, password]) +SETTINGS +catalog_type, +[...] +``` + +支持以下设置: + +| Setting | Description | +|-------------------------|---------------------------------------------------------------------------| +| `catalog_type` | 目录类型: `glue`, `unity` (Delta), `rest` (Iceberg), `hive` | +| `warehouse` | 要在目录中使用的仓库/数据库名称。 | +| `catalog_credential` | 用于目录的身份验证凭据(例如,API 密钥或令牌) | +| `auth_header` | 用于与目录服务进行身份验证的自定义 HTTP 头 | +| `auth_scope` | 用于身份验证的 OAuth2 范围(如果使用 OAuth) | +| `storage_endpoint` | 用于底层存储的端点 URL | +| `oauth_server_uri` | 用于身份验证的 OAuth2 授权服务器的 URI | +| `vended_credentials` | 布尔值,指示是否使用供应商凭据(特定于 AWS) | +| `aws_access_key_id` | 用于 S3/Glue 访问的 AWS 访问密钥 ID(如果不使用供应商凭据) | +| `aws_secret_access_key` | 用于 S3/Glue 访问的 AWS 秘密访问密钥(如果不使用供应商凭据) | +| `region` | 服务的 AWS 区域(例如,`us-east-1`) | + +## Examples {#examples} + +请参见以下页面以获取使用 `DataLakeCatalog` 引擎的示例: + +* [Unity Catalog](/use-cases/data-lake/unity-catalog) +* [Glue Catalog](/use-cases/data-lake/glue-catalog) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/datalake.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/datalake.md.hash new file mode 100644 index 00000000000..75d056a485c --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/datalake.md.hash @@ -0,0 +1 @@ +9084846e45797f61 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/index.md index 4a3fc5a2320..5b5d36292fa 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/index.md @@ -1,18 +1,19 @@ --- -'description': 'Documentation for DATABASE Engines' +'description': 'Documentation for Database Engines' 'slug': '/engines/database-engines/' 'toc_folder_title': 'Database Engines' 'toc_priority': 27 'toc_title': 'Introduction' 'title': '数据库引擎' +'doc_type': 'landing-page' --- # 数据库引擎 -数据库引擎允许您操作表。默认情况下,ClickHouse 使用 [Atomic](../../engines/database-engines/atomic.md) 数据库引擎,提供可配置的 [表引擎](../../engines/table-engines/index.md) 和 [SQL 方言](../../sql-reference/syntax.md)。 +数据库引擎允许您处理表。默认情况下,ClickHouse使用[Atomic](../../engines/database-engines/atomic.md)数据库引擎,它提供可配置的[表引擎](../../engines/table-engines/index.md)和[SQL 方言](../../sql-reference/syntax.md)。 -以下是可用数据库引擎的完整列表。请按照链接获取更多详细信息: +以下是可用数据库引擎的完整列表。点击链接以获取更多详细信息: + + +| 页面 | 描述 | +|-----|-----| +| [Atomic](/engines/database-engines/atomic) | `Atomic`引擎支持非阻塞的 `DROP TABLE` 和 `RENAME TABLE` 查询,以及原子 `EXCHANGE TABLES` 查询。默认情况下使用`Atomic`数据库引擎。 | +| [Lazy](/engines/database-engines/lazy) | 仅在最后访问后 `expiration_time_in_seconds` 秒内将表保留在内存中。只能与日志类型的表一起使用。 | +| [Replicated](/engines/database-engines/replicated) | 此引擎基于Atomic引擎。它支持通过DDL日志进行元数据的复制,该日志被写入ZooKeeper并在给定数据库的所有副本上执行。 | +| [PostgreSQL](/engines/database-engines/postgresql) | 允许连接到远程PostgreSQL服务器上的数据库。 | +| [MySQL](/engines/database-engines/mysql) | 允许连接到远程MySQL服务器上的数据库,并执行 `INSERT` 和 `SELECT` 查询以在ClickHouse和MySQL之间交换数据。 | +| [SQLite](/engines/database-engines/sqlite) | 允许连接到SQLite数据库,并执行 `INSERT` 和 `SELECT` 查询以在ClickHouse和SQLite之间交换数据。 | +| [MaterializedPostgreSQL](/engines/database-engines/materialized-postgresql) | 创建一个具有来自PostgreSQL数据库表的ClickHouse数据库。 | +| [Backup](/engines/database-engines/backup) | 允许以只读模式即时附加来自备份的表/数据库。 | +| [DataLakeCatalog](/engines/database-engines/datalakecatalog) | DataLakeCatalog数据库引擎使您能够将ClickHouse连接到外部数据目录并查询开放表格式数据。 | + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/index.md.hash index a6dcf844704..59f5573975d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/index.md.hash @@ -1 +1 @@ -1c3321ab17ed0408 +af468039e7a4fb88 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/lazy.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/lazy.md index 2f8a574f23f..596a5b4768b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/lazy.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/lazy.md @@ -1,17 +1,18 @@ --- -'description': '仅在上次访问后 `expiration_time_in_seconds` 秒内将表保留在 RAM 中。只能与 Log 类型表一起使用。' +'description': '在最后访问后只将表保留在RAM中`expiration_time_in_seconds`秒。只能与Log类型表一起使用。' 'sidebar_label': '懒惰' 'sidebar_position': 20 'slug': '/engines/database-engines/lazy' 'title': '懒惰' +'doc_type': 'reference' --- -# Lazy +# 懒惰 -在最后一次访问后,保持表只在 RAM 中存在 `expiration_time_in_seconds` 秒。仅可与 \*Log 表一起使用。 +在上次访问后,仅在 RAM 中保留表 `expiration_time_in_seconds` 秒。只能与 \*Log 表一起使用。 -它被优化用于存储许多较小的 \*Log 表,这些表之间的访问时间间隔较长。 +它是为存储许多小型 \*Log 表而优化的,这些表之间的访问时间间隔较长。 ## 创建数据库 {#creating-a-database} diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/lazy.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/lazy.md.hash index bf76f33ce05..9d98dacf1f9 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/lazy.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/lazy.md.hash @@ -1 +1 @@ -6c45af00f6fe753f +8407c71d54017923 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/materialized-postgresql.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/materialized-postgresql.md index d2aadf72481..81316526db9 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/materialized-postgresql.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/materialized-postgresql.md @@ -1,9 +1,10 @@ --- 'description': '创建一个 ClickHouse 数据库,包含来自 PostgreSQL 数据库的表。' -'sidebar_label': 'MaterializedPostgreSQL' +'sidebar_label': '物化PostgreSQL' 'sidebar_position': 60 'slug': '/engines/database-engines/materialized-postgresql' -'title': 'MaterializedPostgreSQL' +'title': '物化PostgreSQL' +'doc_type': 'reference' --- import ExperimentalBadge from '@theme/badges/ExperimentalBadge'; @@ -16,15 +17,15 @@ import CloudNotSupportedBadge from '@theme/badges/CloudNotSupportedBadge'; :::note -推荐 ClickHouse Cloud 用户使用 [ClickPipes](/integrations/clickpipes) 进行 PostgreSQL 到 ClickHouse 的复制。这原生支持高性能的变更数据捕获 (CDC) 用于 PostgreSQL。 +建议使用 ClickHouse Cloud 用户使用 [ClickPipes](/integrations/clickpipes) 将 PostgreSQL 复制到 ClickHouse。这本地支持高性能的变更数据捕获 (CDC) 用于 PostgreSQL。 ::: -创建一个 ClickHouse 数据库,其中包含来自 PostgreSQL 数据库的表。首先,使用引擎 `MaterializedPostgreSQL` 的数据库创建 PostgreSQL 数据库的快照并加载所需的表。所需的表可以包括指定数据库的任何架构中的任意表子集。快照后的数据库引擎获取 LSN,并在执行初始表转储后,开始从 WAL 拉取更新。数据库创建后,新增添加到 PostgreSQL 数据库的表不会自动添加到复制中。它们必须通过 `ATTACH TABLE db.table` 查询手动添加。 +创建包含来自 PostgreSQL 数据库的表的 ClickHouse 数据库。首先,使用引擎 `MaterializedPostgreSQL` 创建 PostgreSQL 数据库的快照并加载所需的表。所需的表可以包括来自指定数据库的任何架构的任意子集的表。除了快照,数据库引擎获取 LSN,并且一旦执行了初始的表转储后 - 它开始从 WAL 中提取更新。创建数据库后,新添加到 PostgreSQL 数据库的表不会自动添加到复制中。它们必须通过 `ATTACH TABLE db.table` 查询手动添加。 -复制是通过 PostgreSQL 逻辑复制协议实现的,该协议不允许复制 DDL,但允许了解是否发生了影响复制的更改(列类型更改、添加/删除列)。此类更改会被检测到,相应的表将停止接收更新。在这种情况下,您应该使用 `ATTACH`/ `DETACH PERMANENTLY` 查询完全重新加载表。如果 DDL 不会破坏复制(例如,更改列名),则表仍会接收更新(插入是按位置进行的)。 +复制是通过 PostgreSQL 逻辑复制协议实现的,该协议不允许复制 DDL,但允许知道是否发生了复制破坏性更改(列类型更改、添加/删除列)。这些更改会被检测到,相应的表将停止接收更新。在这种情况下,您应使用 `ATTACH` / `DETACH PERMANENTLY` 查询来完全重新加载表。如果 DDL 不会破坏复制(例如,重命名列),则表仍将接收更新(插入是按位置进行的)。 :::note -该数据库引擎是实验性的。要使用它,请在您的配置文件中将 `allow_experimental_database_materialized_postgresql` 设置为 1,或者使用 `SET` 命令: +此数据库引擎是实验性的。要使用它,请在配置文件中将 `allow_experimental_database_materialized_postgresql` 设置为 1,或通过使用 `SET` 命令: ```sql SET allow_experimental_database_materialized_postgresql=1 ``` @@ -40,7 +41,7 @@ ENGINE = MaterializedPostgreSQL('host:port', 'database', 'user', 'password') [SE **引擎参数** - `host:port` — PostgreSQL 服务器端点。 -- `database` — PostgreSQL 数据库名。 +- `database` — PostgreSQL 数据库名称。 - `user` — PostgreSQL 用户。 - `password` — 用户密码。 @@ -61,30 +62,30 @@ SELECT * FROM postgresql_db.postgres_table; ## 动态添加新表到复制 {#dynamically-adding-table-to-replication} -创建 `MaterializedPostgreSQL` 数据库后,它不会自动检测相应 PostgreSQL 数据库中的新表。可以手动添加这些表: +在创建 `MaterializedPostgreSQL` 数据库后,它不会自动检测到相应 PostgreSQL 数据库中的新表。这些表可以手动添加: ```sql ATTACH TABLE postgres_database.new_table; ``` :::warning -在 22.1 版本之前,添加表到复制时会留下一个未删除的临时复制槽(命名为 `{db_name}_ch_replication_slot_tmp`)。如果在 22.1 之前的 ClickHouse 版本中附加表,请确保手动删除它 (`SELECT pg_drop_replication_slot('{db_name}_ch_replication_slot_tmp')`)。否则磁盘使用将会增加。此问题在 22.1 中已修复。 +在 22.1 之前的版本中,将表添加到复制会留下一个未删除的临时复制槽(命名为 `{db_name}_ch_replication_slot_tmp`)。如果在 ClickHouse 版本 22.1 之前附加表,请确保手动删除它 (`SELECT pg_drop_replication_slot('{db_name}_ch_replication_slot_tmp')`)。否则磁盘使用量将增加。此问题在 22.1 中已修复。 ::: ## 动态移除复制中的表 {#dynamically-removing-table-from-replication} -可以从复制中移除特定表: +可以从复制中移除特定的表: ```sql DETACH TABLE postgres_database.table_to_remove PERMANENTLY; ``` -## PostgreSQL 架构 {#schema} +## PostgreSQL 结构 {#schema} -PostgreSQL [schema](https://www.postgresql.org/docs/9.1/ddl-schemas.html) 可以通过三种方式配置(从版本 21.12 开始)。 +PostgreSQL [schema](https://www.postgresql.org/docs/9.1/ddl-schemas.html) 可以以 3 种方式进行配置(自版本 21.12 起)。 -1. 一个架构用于一个 `MaterializedPostgreSQL` 数据库引擎。需要使用设置 `materialized_postgresql_schema`。 -通过表名访问表: +1. 一个 schema 对应一个 `MaterializedPostgreSQL` 数据库引擎。需要使用设置 `materialized_postgresql_schema`。 +表仅通过表名访问: ```sql CREATE DATABASE postgres_database @@ -94,8 +95,8 @@ SETTINGS materialized_postgresql_schema = 'postgres_schema'; SELECT * FROM postgres_database.table1; ``` -2. 任何数量的架构为一个 `MaterializedPostgreSQL` 数据库引擎指定一组表。需要使用设置 `materialized_postgresql_tables_list`。每个表都与其架构一同写入。 -通过架构名和表名同时访问表: +2. 一个 `MaterializedPostgreSQL` 数据库引擎可以使用指定表集的任意数量的 schema。需要使用设置 `materialized_postgresql_tables_list`。每个表都与其 schema 一起写入。 +表同时通过 schema 名称和表名访问: ```sql CREATE DATABASE database1 @@ -107,12 +108,12 @@ SELECT * FROM database1.`schema1.table1`; SELECT * FROM database1.`schema2.table2`; ``` -但在这种情况下,`materialized_postgresql_tables_list` 中的所有表必须附带其架构名。 +但在这种情况下,`materialized_postgresql_tables_list` 中的所有表必须使用其 schema 名称进行书写。 需要 `materialized_postgresql_tables_list_with_schema = 1`。 -注意:在这种情况下,表名中不允许有点。 +警告:对于这种情况,表名中的点是不允许的。 -3. 任何数量的架构为一个 `MaterializedPostgreSQL` 数据库引擎指定完整的表集。需要使用设置 `materialized_postgresql_schema_list`。 +3. 一个 `MaterializedPostgreSQL` 数据库引擎有任意数量的 schema,且具有完整的表集。需要使用设置 `materialized_postgresql_schema_list`。 ```sql CREATE DATABASE database1 @@ -124,13 +125,13 @@ SELECT * FROM database1.`schema1.table2`; SELECT * FROM database1.`schema2.table2`; ``` -注意:在这种情况下,表名中不允许有点。 +警告:对于这种情况,表名中的点是不允许的。 -## 需求 {#requirements} +## 要求 {#requirements} -1. PostgreSQL 配置文件中的 [wal_level](https://www.postgresql.org/docs/current/runtime-config-wal.html) 设置必须为 `logical`,`max_replication_slots` 参数至少必须为 `2`。 +1. 在 PostgreSQL 配置文件中,`[wal_level](https://www.postgresql.org/docs/current/runtime-config-wal.html)` 设置必须具有值 `logical`,并且 `max_replication_slots` 参数必须至少为 `2`。 -2. 每个复制的表必须具有以下之一 [replica identity](https://www.postgresql.org/docs/10/sql-altertable.html#SQL-CREATETABLE-REPLICA-IDENTITY): +2. 每个被复制的表必须具有以下之一的 [replica identity](https://www.postgresql.org/docs/10/sql-altertable.html#SQL-CREATETABLE-REPLICA-IDENTITY): - 主键(默认) @@ -142,9 +143,9 @@ postgres# CREATE unique INDEX postgres_table_index on postgres_table(a, c, e); postgres# ALTER TABLE postgres_table REPLICA IDENTITY USING INDEX postgres_table_index; ``` -主键始终首先被检查。如果不存在,则检查作为复制标识索引定义的索引。 -如果使用索引作为复制标识,则该表中只能有一个这样的索引。 -您可以使用以下命令检查特定表使用了何种类型: +主键总是首先检查。如果不存在,则检查定义为副本身份索引的索引。 +如果索引用作副本身份,则表中必须仅有一个这样的索引。 +您可以使用以下命令检查特定表使用的类型: ```bash postgres# SELECT CASE relreplident @@ -165,27 +166,27 @@ WHERE oid = 'postgres_table'::regclass; ### `materialized_postgresql_tables_list` {#materialized-postgresql-tables-list} - 设置要通过 [MaterializedPostgreSQL](../../engines/database-engines/materialized-postgresql.md) 数据库引擎复制的 PostgreSQL 数据库表的以逗号分隔的列表。 + 设置一个逗号分隔的 PostgreSQL 数据库表列表,将通过 [MaterializedPostgreSQL](../../engines/database-engines/materialized-postgresql.md) 数据库引擎进行复制。 - 每个表可以在括号中有一组复制的列。如果省略列子集,则将复制该表的所有列。 + 每个表可以在括号中有被复制列的子集。如果省略列子集,则将复制表的所有列。 ```sql materialized_postgresql_tables_list = 'table1(co1, col2),table2,table3(co3, col5, col7) ``` - 默认值:空列表 — 意味着整个 PostgreSQL 数据库将被复制。 + 默认值:空列表——表示将复制整个 PostgreSQL 数据库。 ### `materialized_postgresql_schema` {#materialized-postgresql-schema} - 默认值:空字符串。(使用默认架构) + 默认值:空字符串。(使用默认 schema) ### `materialized_postgresql_schema_list` {#materialized-postgresql-schema-list} - 默认值:空列表。(使用默认架构) + 默认值:空列表。(使用默认 schema) ### `materialized_postgresql_max_block_size` {#materialized-postgresql-max-block-size} - 设置在将数据刷新到 PostgreSQL 数据库表之前,在内存中收集的行数。 + 设置在将数据刷新到 PostgreSQL 数据库表之前在内存中收集的行数。 可能的值: @@ -199,7 +200,7 @@ materialized_postgresql_tables_list = 'table1(co1, col2),table2,table3(co3, col5 ### `materialized_postgresql_snapshot` {#materialized-postgresql-snapshot} - 识别快照的文本字符串,将执行 [PostgreSQL 表的初始转储](../../engines/database-engines/materialized-postgresql.md)。必须与 `materialized_postgresql_replication_slot` 一起使用。 + 识别快照的文本字符串,从中将执行 [初始的 PostgreSQL 表转储](../../engines/database-engines/materialized-postgresql.md)。必须与 `materialized_postgresql_replication_slot` 一起使用。 ```sql CREATE DATABASE database1 @@ -209,7 +210,7 @@ SETTINGS materialized_postgresql_tables_list = 'table1,table2,table3'; SELECT * FROM database1.table1; ``` - 如果需要,可以使用 DDL 查询更改这些设置。但无法更改设置 `materialized_postgresql_tables_list`。要更新此设置中的表列表,请使用 `ATTACH TABLE` 查询。 + 如果需要,可以使用 DDL 查询更改设置。但是不可能更改设置 `materialized_postgresql_tables_list`。要更新此设置中表的列表,请使用 `ATTACH TABLE` 查询。 ```sql ALTER DATABASE postgres_database MODIFY SETTING materialized_postgresql_max_block_size = ; @@ -217,18 +218,18 @@ ALTER DATABASE postgres_database MODIFY SETTING materialized_postgresql_max_bloc ### `materialized_postgresql_use_unique_replication_consumer_identifier` {#materialized_postgresql_use_unique_replication_consumer_identifier} -使用唯一的复制消费者标识符进行复制。默认值: `0`。 -如果设置为 `1`,则允许设置多个 `MaterializedPostgreSQL` 表指向同一 `PostgreSQL` 表。 +为复制使用唯一的复制消费者标识符。默认值:`0`。 +如果设置为 `1`,允许设置多个 `MaterializedPostgreSQL` 表指向同一个 `PostgreSQL` 表。 -## 注意事项 {#notes} +## 注释 {#notes} ### 逻辑复制槽的故障转移 {#logical-replication-slot-failover} -存在于主服务器上的逻辑复制槽在备用副本中不可用。 -因此,如果发生故障转移,新主机(旧物理备用)将不了解旧主机上存在的任何槽。这将导致来自 PostgreSQL 的复制中断。 -解决方案是您自己管理复制槽并定义一个永久复制槽(一些信息可以在 [这里](https://patroni.readthedocs.io/en/latest/SETTINGS.html) 找到)。您需要通过 `materialized_postgresql_replication_slot` 设置传递槽名称,并且必须使用 `EXPORT SNAPSHOT` 选项进行导出。快照标识符需要通过 `materialized_postgresql_snapshot` 设置传递。 +存在于主服务器上的逻辑复制槽在备用副本上不可用。 +因此,如果发生故障转移,新主(旧的物理备用)将无法意识到在旧主上存在的任何槽。这将导致 PostgreSQL 复制中断。 +解决此问题的方法是您自己管理复制槽,并定义一个永久的复制槽(一些信息可以在 [这里](https://patroni.readthedocs.io/en/latest/SETTINGS.html) 找到)。您需要通过 `materialized_postgresql_replication_slot` 设置传递槽名称,并且必须通过 `EXPORT SNAPSHOT` 选项进行导出。快照标识符需要通过 `materialized_postgresql_snapshot` 设置传递。 -请注意,如果实际上没有必要,或者对原因没有充分理解,则仅在真正需要时使用此功能。否则,最好让表引擎创建和管理自己的复制槽。 +请注意,这仅在实际需要时使用。如果没有真正的需求或完全理解理由,则最好允许表引擎创建和管理自己的复制槽。 **示例(来自 [@bchrobot](https://github.com/bchrobot))** @@ -259,7 +260,7 @@ BEGIN; SELECT pg_export_snapshot(); ``` -3. 在 ClickHouse 创建数据库: +3. 在 ClickHouse 中创建数据库: ```sql CREATE DATABASE demodb @@ -270,7 +271,7 @@ SETTINGS materialized_postgresql_tables_list = 'table1,table2,table3'; ``` -4. 一旦确认到 ClickHouse 数据库的复制结束 PostgreSQL 事务。验证在故障转移后复制是否继续: +4. 一旦复制到 ClickHouse 数据库得到确认,结束 PostgreSQL 事务。验证在故障转移后复制是否继续: ```bash kubectl exec acid-demo-cluster-0 -c postgres -- su postgres -c 'patronictl failover --candidate acid-demo-cluster-1 --force' @@ -278,13 +279,13 @@ kubectl exec acid-demo-cluster-0 -c postgres -- su postgres -c 'patronictl failo ### 所需权限 {#required-permissions} -1. [CREATE PUBLICATION](https://postgrespro.ru/docs/postgresql/14/sql-createpublication) -- 创建查询特权。 +1. [CREATE PUBLICATION](https://postgrespro.ru/docs/postgresql/14/sql-createpublication) -- 创建查询权限。 -2. [CREATE_REPLICATION_SLOT](https://postgrespro.ru/docs/postgrespro/10/protocol-replication#PROTOCOL-REPLICATION-CREATE-SLOT) -- 复制特权。 +2. [CREATE_REPLICATION_SLOT](https://postgrespro.ru/docs/postgrespro/10/protocol-replication#PROTOCOL-REPLICATION-CREATE-SLOT) -- 复制权限。 -3. [pg_drop_replication_slot](https://postgrespro.ru/docs/postgrespro/9.5/functions-admin#functions-replication) -- 复制特权或超级用户权限。 +3. [pg_drop_replication_slot](https://postgrespro.ru/docs/postgrespro/9.5/functions-admin#functions-replication) -- 复制权限或超级用户。 -4. [DROP PUBLICATION](https://postgrespro.ru/docs/postgresql/10/sql-droppublication) -- 发布的所有者(`username` 在 MaterializedPostgreSQL 引擎本身中)。 +4. [DROP PUBLICATION](https://postgrespro.ru/docs/postgresql/10/sql-droppublication) -- 发表的所有者(`MaterializedPostgreSQL` 引擎本身中的 `username`)。 可以避免执行 `2` 和 `3` 命令并拥有这些权限。使用设置 `materialized_postgresql_replication_slot` 和 `materialized_postgresql_snapshot`。但需谨慎。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/materialized-postgresql.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/materialized-postgresql.md.hash index 28ae14024ab..b6c8997a25c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/materialized-postgresql.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/materialized-postgresql.md.hash @@ -1 +1 @@ -245fae8b7eb0a841 +a9fa743c5de5cced diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/mysql.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/mysql.md index acd1d061b0b..cf9cbb560b9 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/mysql.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/mysql.md @@ -1,10 +1,11 @@ --- -'description': '允许连接到远程 MySQL 服务器上的数据库,并执行 `INSERT` 和 `SELECT` 查询,以在 ClickHouse 和 - MySQL 之间交换数据。' +'description': '允许连接到远程 MySQL 服务器上的数据库,并执行 `INSERT` 和 `SELECT` 查询以在 ClickHouse 和 MySQL + 之间交换数据。' 'sidebar_label': 'MySQL' 'sidebar_position': 50 'slug': '/engines/database-engines/mysql' 'title': 'MySQL' +'doc_type': 'reference' --- import CloudNotSupportedBadge from '@theme/badges/CloudNotSupportedBadge'; @@ -14,9 +15,9 @@ import CloudNotSupportedBadge from '@theme/badges/CloudNotSupportedBadge'; -允许连接到远程 MySQL 服务器上的数据库,并执行 `INSERT` 和 `SELECT` 查询,以在 ClickHouse 和 MySQL 之间交换数据。 +允许连接到远程 MySQL 服务器上的数据库,并执行 `INSERT` 和 `SELECT` 查询以在 ClickHouse 和 MySQL 之间交换数据。 -`MySQL` 数据库引擎将查询转化为 MySQL 服务器的格式,因此您可以执行 `SHOW TABLES` 或 `SHOW CREATE TABLE` 等操作。 +`MySQL` 数据库引擎将查询翻译为 MySQL 服务器,因此您可以执行如 `SHOW TABLES` 或 `SHOW CREATE TABLE` 的操作。 您不能执行以下查询: @@ -56,20 +57,20 @@ ENGINE = MySQL('host:port', ['database' | database], 'user', 'password') | DATETIME, TIMESTAMP | [DateTime](../../sql-reference/data-types/datetime.md) | | BINARY | [FixedString](../../sql-reference/data-types/fixedstring.md) | -所有其他 MySQL 数据类型都会转换为 [String](../../sql-reference/data-types/string.md)。 +其他所有 MySQL 数据类型都将转换为 [String](../../sql-reference/data-types/string.md)。 支持 [Nullable](../../sql-reference/data-types/nullable.md)。 ## 全局变量支持 {#global-variables-support} -为了更好的兼容性,您可以使用 MySQL 风格来引用全局变量,如 `@@identifier`。 +为了更好的兼容性,您可以使用 MySQL 风格来处理全局变量,格式为 `@@identifier`。 -支持以下变量: +支持的变量有: - `version` - `max_allowed_packet` :::note -目前这些变量是占位符,并不对应任何内容。 +到目前为止,这些变量是存根,不对应任何内容。 ::: 示例: @@ -104,7 +105,7 @@ mysql> select * from mysql_table; 1 row in set (0,00 sec) ``` -在 ClickHouse 中的数据库,与 MySQL 服务器交换数据: +ClickHouse 中的数据库,与 MySQL 服务器交换数据: ```sql CREATE DATABASE mysql_db ENGINE = MySQL('localhost:3306', 'test', 'my_user', 'user_password') SETTINGS read_write_timeout=10000, connect_timeout=100; diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/mysql.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/mysql.md.hash index a449cfa297e..6e748c79956 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/mysql.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/mysql.md.hash @@ -1 +1 @@ -a7a9d3e9fd442db3 +462a8b8d9b7dccc1 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/postgresql.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/postgresql.md index 9958d09002c..04eb9a345d7 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/postgresql.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/postgresql.md @@ -4,16 +4,17 @@ 'sidebar_position': 40 'slug': '/engines/database-engines/postgresql' 'title': 'PostgreSQL' +'doc_type': 'guide' --- # PostgreSQL -允许连接到远程 [PostgreSQL](https://www.postgresql.org) 服务器上的数据库。支持读写操作(`SELECT` 和 `INSERT` 查询)以在ClickHouse和PostgreSQL之间交换数据。 +允许连接到远程 [PostgreSQL](https://www.postgresql.org) 服务器上的数据库。支持读写操作(`SELECT` 和 `INSERT` 查询),以在 ClickHouse 和 PostgreSQL 之间交换数据。 -通过 `SHOW TABLES` 和 `DESCRIBE TABLE` 查询提供对远程PostgreSQL的表列表和表结构的实时访问。 +通过 `SHOW TABLES` 和 `DESCRIBE TABLE` 查询,实时访问远程 PostgreSQL 的表列表和表结构。 -支持表结构修改(`ALTER TABLE ... ADD|DROP COLUMN`)。如果 `use_table_cache` 参数(参见下面的引擎参数)设置为 `1`,则表结构会被缓存,不会检查是否被修改,但可以通过 `DETACH` 和 `ATTACH` 查询进行更新。 +支持表结构修改(`ALTER TABLE ... ADD|DROP COLUMN`)。如果将 `use_table_cache` 参数(请参阅下面的引擎参数)设置为 `1`,则表结构将被缓存,不会检查是否被修改,但可以通过 `DETACH` 和 `ATTACH` 查询进行更新。 ## 创建数据库 {#creating-a-database} @@ -24,11 +25,11 @@ ENGINE = PostgreSQL('host:port', 'database', 'user', 'password'[, `schema`, `use **引擎参数** -- `host:port` — PostgreSQL服务器地址。 +- `host:port` — PostgreSQL 服务器地址。 - `database` — 远程数据库名称。 -- `user` — PostgreSQL用户。 +- `user` — PostgreSQL 用户。 - `password` — 用户密码。 -- `schema` — PostgreSQL架构。 +- `schema` — PostgreSQL 模式。 - `use_table_cache` — 定义数据库表结构是否被缓存。可选。默认值:`0`。 ## 数据类型支持 {#data_types-support} @@ -51,7 +52,7 @@ ENGINE = PostgreSQL('host:port', 'database', 'user', 'password'[, `schema`, `use ## 使用示例 {#examples-of-use} -在ClickHouse中创建数据库,与PostgreSQL服务器交换数据: +在 ClickHouse 中的数据库,与 PostgreSQL 服务器交换数据: ```sql CREATE DATABASE test_database @@ -80,7 +81,7 @@ SHOW TABLES FROM test_database; └────────────┘ ``` -从PostgreSQL表中读取数据: +从 PostgreSQL 表中读取数据: ```sql SELECT * FROM test_database.test_table; @@ -92,7 +93,7 @@ SELECT * FROM test_database.test_table; └────┴───────┘ ``` -向PostgreSQL表中写入数据: +向 PostgreSQL 表中写入数据: ```sql INSERT INTO test_database.test_table VALUES (3,4); @@ -106,13 +107,13 @@ SELECT * FROM test_database.test_table; └────────┴───────┘ ``` -考虑到PostgreSQL中的表结构已被修改: +假设 PostgreSQL 中的表结构已被修改: ```sql postgre> ALTER TABLE test_table ADD COLUMN data Text ``` -由于在创建数据库时 `use_table_cache` 参数设置为 `1`,ClickHouse中的表结构被缓存,因此未被修改: +由于在创建数据库时 `use_table_cache` 参数被设置为 `1`,因此 ClickHouse 中的表结构被缓存,因此没有被修改: ```sql DESCRIBE TABLE test_database.test_table; @@ -141,5 +142,5 @@ DESCRIBE TABLE test_database.test_table; ## 相关内容 {#related-content} -- 博客: [ClickHouse和PostgreSQL - 数据天堂中的完美搭配 - 第1部分](https://clickhouse.com/blog/migrating-data-between-clickhouse-postgres) -- 博客: [ClickHouse和PostgreSQL - 数据天堂中的完美搭配 - 第2部分](https://clickhouse.com/blog/migrating-data-between-clickhouse-postgres-part-2) +- 博客: [ClickHouse 和 PostgreSQL - 数据天堂的完美结合 - 第 1 部分](https://clickhouse.com/blog/migrating-data-between-clickhouse-postgres) +- 博客: [ClickHouse 和 PostgreSQL - 数据天堂的完美结合 - 第 2 部分](https://clickhouse.com/blog/migrating-data-between-clickhouse-postgres-part-2) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/postgresql.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/postgresql.md.hash index dacdf615b77..3f50bda0ad5 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/postgresql.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/postgresql.md.hash @@ -1 +1 @@ -9d4bddf80bc66c1e +026b9d3febc63ab8 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/replicated.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/replicated.md index 28ca4d29fb5..d4192c1fff8 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/replicated.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/replicated.md @@ -1,17 +1,18 @@ --- -'description': '该引擎基于Atomic引擎。它通过将DDL日志写入ZooKeeper并在给定DATABASE的所有副本上执行来支持元数据的复制。' +'description': '该引擎基于 Atomic 引擎。它支持通过将 DDL 日志写入 ZooKeeper 并在给定的 DATABASE 的所有副本上执行来复制元数据。' 'sidebar_label': '副本' 'sidebar_position': 30 'slug': '/engines/database-engines/replicated' 'title': '副本' +'doc_type': 'reference' --- -# 复制的 +# 复制 -该引擎基于 [Atomic](../../engines/database-engines/atomic.md) 引擎。它支持通过将 DDL 日志写入 ZooKeeper 并在给定数据库的所有副本上执行来复制元数据。 +该引擎基于 [Atomic](../../engines/database-engines/atomic.md) 引擎。它通过将 DDL 日志写入 ZooKeeper,并在给定数据库的所有副本上执行,支持元数据的复制。 -一个 ClickHouse 服务器可以同时运行和更新多个复制的数据库,但同一个复制数据库不能有多个副本。 +一个 ClickHouse 服务器可以同时运行和更新多个复制数据库。但是,不能有同一个复制数据库的多个副本。 ## 创建数据库 {#creating-a-database} ```sql @@ -20,31 +21,31 @@ CREATE DATABASE testdb ENGINE = Replicated('zoo_path', 'shard_name', 'replica_na **引擎参数** -- `zoo_path` — ZooKeeper 路径。相同的 ZooKeeper 路径对应于相同的数据库。 -- `shard_name` — 分片名称。数据库副本通过 `shard_name` 被分组为分片。 -- `replica_name` — 副本名称。相同分片的所有副本名称必须不同。 +- `zoo_path` — ZooKeeper 路径。同一个 ZooKeeper 路径对应同一个数据库。 +- `shard_name` — 分片名称。数据库副本通过 `shard_name` 分组为分片。 +- `replica_name` — 副本名称。对同一分片的所有副本,副本名称必须不同。 -对于 [ReplicatedMergeTree](/engines/table-engines/mergetree-family/replication) 表,如果未提供参数,则使用默认参数:`/clickhouse/tables/{uuid}/{shard}` 和 `{replica}`。这些参数可以在服务器设置 [default_replica_path](../../operations/server-configuration-parameters/settings.md#default_replica_path) 和 [default_replica_name](../../operations/server-configuration-parameters/settings.md#default_replica_name) 中更改。宏 `{uuid}` 被展开为表的 uuid,`{shard}` 和 `{replica}` 被展开为来自服务器配置的值,而不是来自数据库引擎参数。但将来,可以使用复制数据库的 `shard_name` 和 `replica_name`。 +对于 [ReplicatedMergeTree](/engines/table-engines/mergetree-family/replication) 表,如果未提供参数,则使用默认参数:`/clickhouse/tables/{uuid}/{shard}` 和 `{replica}`。这些可以在服务器设置中的 [default_replica_path](../../operations/server-configuration-parameters/settings.md#default_replica_path) 和 [default_replica_name](../../operations/server-configuration-parameters/settings.md#default_replica_name) 中更改。宏 `{uuid}` 被展开为表的 uuid,`{shard}` 和 `{replica}` 被展开为来自服务器配置的值,而不是来自数据库引擎参数。但是将来,将能够使用 Replicated 数据库的 `shard_name` 和 `replica_name`。 -## 具体事项和建议 {#specifics-and-recommendations} +## 特性和建议 {#specifics-and-recommendations} -带有 `Replicated` 数据库的 DDL 查询的工作方式与 [ON CLUSTER](../../sql-reference/distributed-ddl.md) 查询类似,但有一些细微差别。 +`Replicated` 数据库的 DDL 查询工作方式与 [ON CLUSTER](../../sql-reference/distributed-ddl.md) 查询类似,但有一些细微的差别。 -首先,DDL 请求尝试在发起者(最初从用户处接收请求的主机)上执行。如果请求无法满足,用户会立即收到错误,其他主机不会尝试执行该请求。如果请求在发起者上成功完成,则所有其他主机将自动重试,直到它们完成它。发起者将尝试等待查询在其他主机上完成(不超过 [distributed_ddl_task_timeout](../../operations/settings/settings.md#distributed_ddl_task_timeout)),并将返回一张显示每个主机上查询执行状态的表。 +首先,DDL 请求尝试在发起者(最初从用户接收请求的主机)上执行。如果请求未被满足,用户会立即收到错误,其他主机不会尝试满足该请求。如果请求在发起者上成功完成,则所有其他主机会自动重试,直到它们完成该请求。发起者会尝试等待查询在其他主机上完成(最长不超过 [distributed_ddl_task_timeout](../../operations/settings/settings.md#distributed_ddl_task_timeout)),并返回一个包含每个主机查询执行状态的表。 -在发生错误的情况下的行为由 [distributed_ddl_output_mode](../../operations/settings/settings.md#distributed_ddl_output_mode) 设置进行调节,对于 `Replicated` 数据库,最好将其设置为 `null_status_on_timeout` —— 即,如果某些主机未能在 [distributed_ddl_task_timeout](../../operations/settings/settings.md#distributed_ddl_task_timeout) 内执行请求,则不要抛出异常,而是显示该主机的 `NULL` 状态。 +发生错误时的行为由 [distributed_ddl_output_mode](../../operations/settings/settings.md#distributed_ddl_output_mode) 设置进行调节,对于 `Replicated` 数据库,最好将其设置为 `null_status_on_timeout` — 即如果某些主机未能在 [distributed_ddl_task_timeout](../../operations/settings/settings.md#distributed_ddl_task_timeout) 时间内执行请求,则不抛出异常,而是在表中显示它们的 `NULL` 状态。 -[system.clusters](../../operations/system-tables/clusters.md) 系统表包含一个与复制数据库同名的集群,包含该数据库的所有副本。该集群在创建/删除副本时会自动更新,可以用于 [Distributed](/engines/table-engines/special/distributed) 表。 +[system.clusters](../../operations/system-tables/clusters.md) 系统表包含一个名称与复制数据库相同的集群,该集群由数据库的所有副本组成。此集群在创建/删除副本时会自动更新,可以用于 [Distributed](/engines/table-engines/special/distributed) 表。 -创建数据库的新副本时,该副本会自行创建表。如果副本长时间不可用并且落后于复制日志——它会检查其本地元数据与 ZooKeeper 中的当前元数据,移动含有数据的额外表到一个单独的非复制数据库(以免意外删除多余的内容),创建缺少的表,更新表名(如果它们被重命名)。数据在 `ReplicatedMergeTree` 级别上复制,即如果表未被复制,则数据不会被复制(数据库仅负责元数据)。 +当创建数据库的新副本时,该副本会自行创建表。如果副本长时间不可用并且落后于复制日志——它会检查其本地元数据与 ZooKeeper 中的当前元数据, 将额外的包含数据的表移动到一个单独的非复制数据库(以免意外删除任何多余的内容),创建缺失的表,如果表名已被重命名,更新表名。数据是在 `ReplicatedMergeTree` 级别复制的,即如果表未被复制,则数据将不被复制(数据库仅对元数据负责)。 -[`ALTER TABLE FREEZE|ATTACH|FETCH|DROP|DROP DETACHED|DETACH PARTITION|PART`](../../sql-reference/statements/alter/partition.md) 查询是允许的,但不被复制。数据库引擎将仅添加/提取/移除当前副本的分区/部分。然而,如果表本身使用复制表引擎,则在使用 `ATTACH` 后数据将被复制。 +[`ALTER TABLE FREEZE|ATTACH|FETCH|DROP|DROP DETACHED|DETACH PARTITION|PART`](../../sql-reference/statements/alter/partition.md) 查询被允许但不被复制。数据库引擎仅将分区/部分添加/提取/移除到当前副本中。然而,如果表本身使用了复制表引擎,则在使用 `ATTACH` 后数据会被复制。 -如果您只需要配置集群而不维护表复制,请参考 [Cluster Discovery](../../operations/cluster-discovery.md) 特性。 +如果您只需要配置一个集群而不维护表的复制,请参考 [Cluster Discovery](../../operations/cluster-discovery.md) 功能。 ## 使用示例 {#usage-example} -创建一个有三个主机的集群: +创建一个包含三个主机的集群: ```sql node1 :) CREATE DATABASE r ENGINE=Replicated('some/path/r','shard1','replica1'); @@ -81,7 +82,7 @@ FROM system.clusters WHERE cluster='r'; └─────────┴───────────┴─────────────┴───────────┴──────────────┴──────┴──────────┘ ``` -创建分布式表并插入数据: +创建一个分布式表并插入数据: ```sql node2 :) CREATE TABLE r.d (n UInt64) ENGINE=Distributed('r','r','rmt', n % 2); @@ -96,7 +97,7 @@ node1 :) SELECT materialize(hostName()) AS host, groupArray(n) FROM r.d GROUP BY └───────┴───────────────┘ ``` -在一个主机上添加副本: +在另一个主机上添加副本: ```sql node4 :) CREATE DATABASE r ENGINE=Replicated('some/path/r','other_shard','r2'); @@ -113,7 +114,7 @@ node4 :) CREATE DATABASE r ENGINE=Replicated('some/path/r','other_shard','r2'); └─────────┴───────────┴─────────────┴───────────┴──────────────┴──────┴──────────┘ ``` -分布式表也将从新主机获取数据: +该分布式表也将从新主机接收数据: ```sql node2 :) SELECT materialize(hostName()) AS host, groupArray(n) FROM r.d GROUP BY host; diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/replicated.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/replicated.md.hash index fa132cbfe58..7fd1f9ad811 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/replicated.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/replicated.md.hash @@ -1 +1 @@ -c7048883fff456af +9bb8960b95f8d074 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/sqlite.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/sqlite.md index 59a408c4887..9cba0a43165 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/sqlite.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/sqlite.md @@ -1,10 +1,11 @@ --- -'description': '允许连接到 SQLite 数据库,并执行 `INSERT` 和 `SELECT` 查询,以在 ClickHouse 和 SQLite +'description': '允许连接到 SQLite 数据库并执行 `INSERT` 和 `SELECT` 查询,以在 ClickHouse 和 SQLite 之间交换数据。' 'sidebar_label': 'SQLite' 'sidebar_position': 55 'slug': '/engines/database-engines/sqlite' 'title': 'SQLite' +'doc_type': 'reference' --- @@ -21,7 +22,7 @@ ENGINE = SQLite('db_path') **引擎参数** -- `db_path` — 包含 SQLite 数据库的文件路径。 +- `db_path` — SQLite 数据库文件的路径。 ## 数据类型支持 {#data_types-support} @@ -32,14 +33,14 @@ ENGINE = SQLite('db_path') | TEXT | [String](../../sql-reference/data-types/string.md) | | BLOB | [String](../../sql-reference/data-types/string.md) | -## 特性与建议 {#specifics-and-recommendations} +## 特性和建议 {#specifics-and-recommendations} -SQLite 将整个数据库(定义、表、索引和数据本身)作为一个跨平台文件存储在主机上。写入时,SQLite 会锁定整个数据库文件,因此写入操作是按顺序执行的。读操作可以进行多任务处理。 -SQLite 不需要服务管理(如启动脚本)或基于 `GRANT` 和密码的访问控制。访问控制通过授予数据库文件本身的文件系统权限来处理。 +SQLite 将整个数据库(定义、表、索引和数据本身)存储为单个跨平台文件在主机上。在写入时,SQLite 会锁定整个数据库文件,因此写入操作是顺序执行的。读取操作可以进行多任务处理。 +SQLite 不需要服务管理(例如启动脚本)或基于 `GRANT` 和密码的访问控制。访问控制通过赋予数据库文件本身的文件系统权限来处理。 ## 使用示例 {#usage-example} -在 ClickHouse 中,连接到 SQLite 的数据库: +在 ClickHouse 中连接至 SQLite 的数据库: ```sql CREATE DATABASE sqlite_db ENGINE = SQLite('sqlite.db'); @@ -53,7 +54,7 @@ SHOW TABLES FROM sqlite_db; └─────────┘ ``` -显示表: +展示表格: ```sql SELECT * FROM sqlite_db.table1; @@ -66,7 +67,7 @@ SELECT * FROM sqlite_db.table1; │ line3 │ 3 │ └───────┴──────┘ ``` -从 ClickHouse 表中插入数据到 SQLite 表: +将 ClickHouse 表中的数据插入到 SQLite 表中: ```sql CREATE TABLE clickhouse_table(`col1` String,`col2` Int16) ENGINE = MergeTree() ORDER BY col2; diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/sqlite.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/sqlite.md.hash index e05f74ad806..d6f650eada7 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/sqlite.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/database-engines/sqlite.md.hash @@ -1 +1 @@ -461bcef746c98526 +35c7d04fccdd93a0 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/index.md index d367c86263d..c1122bfe936 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/index.md @@ -1,10 +1,11 @@ --- -'description': '引擎的目录页' +'description': '引擎的目录页面' 'slug': '/engines' 'title': '引擎' +'doc_type': 'landing-page' --- -| 页面 | 描述 | +| 页面 | 描述 | |----------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| [数据库引擎](../engines/database-engines/index.md) | ClickHouse中的数据库引擎允许您处理表并确定数据的存储和管理方式。了解有关ClickHouse中各种数据库引擎的更多信息。 | -| [表引擎](../engines/table-engines/index.md) | ClickHouse中的表引擎是一个基本概念,决定了数据的存储、写入和读取方式。了解有关ClickHouse中各种表引擎的更多信息。 | +| [数据库引擎](../engines/database-engines/index.md) | ClickHouse 中的数据库引擎允许您处理表并确定数据的存储和管理方式。了解更多关于 ClickHouse 中可用的各种数据库引擎的信息。 | +| [表引擎](../engines/table-engines/index.md) | ClickHouse 中的表引擎是决定数据如何存储、写入和读取的基本概念。了解更多关于 ClickHouse 中可用的各种表引擎的信息。 | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/index.md.hash index f262639de3c..6a65d32c543 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/index.md.hash @@ -1 +1 @@ -25f510c021abd402 +8ada26f4a1799fb3 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/index.md index 4532ac3a4c9..08e2f00dd21 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/index.md @@ -1,105 +1,115 @@ --- -'description': 'Table Engines 的文档' +'description': 'Table Engines的文档' 'slug': '/engines/table-engines/' 'toc_folder_title': 'Table Engines' 'toc_priority': 26 'toc_title': 'Introduction' 'title': '表引擎' +'doc_type': 'reference' --- # 表引擎 -表引擎(表的类型)决定: +表引擎(表的类型)决定了: - 数据的存储方式和位置,写入和读取的位置。 - 支持哪些查询,以及如何支持。 - 并发数据访问。 -- 是否使用索引(如果存在)。 -- 是否可能多线程请求执行。 +- 索引的使用(如果存在)。 +- 是否可以进行多线程请求执行。 - 数据复制参数。 ## 引擎家族 {#engine-families} ### MergeTree {#mergetree} -最通用和功能强大的高负载任务表引擎。这些引擎的共同特性是快速的数据插入以及随后的后台数据处理。`MergeTree` 家族的引擎支持数据复制(与 [Replicated\*](/engines/table-engines/mergetree-family/replication) 版本引擎)、分区、二级数据跳过索引,以及其他在其他引擎中不支持的特性。 +用于高负载任务的最通用和功能强大的表引擎。这些引擎的共同特性是快速的数据插入,并随后的后台数据处理。`MergeTree` 家族的引擎支持数据复制(与 [Replicated\*](/engines/table-engines/mergetree-family/replication) 版本的引擎)、分区、次级数据跳过索引以及其他在其他引擎中不支持的特性。 -该家族的引擎: +该家族中的引擎: -| MergeTree 引擎 | -|-------------------------------------------------------------------------------------------------------------------------------------| -| [MergeTree](/engines/table-engines/mergetree-family/mergetree) | -| [ReplacingMergeTree](/engines/table-engines/mergetree-family/replacingmergetree) | -| [SummingMergeTree](/engines/table-engines/mergetree-family/summingmergetree) | -| [AggregatingMergeTree](/engines/table-engines/mergetree-family/aggregatingmergetree) | -| [CollapsingMergeTree](/engines/table-engines/mergetree-family/collapsingmergetree) | -| [VersionedCollapsingMergeTree](/engines/table-engines/mergetree-family/versionedcollapsingmergetree) | -| [GraphiteMergeTree](/engines/table-engines/mergetree-family/graphitemergetree) | +| MergeTree 引擎 | +|-------------------------------------------------------------------------------------------------------------------------------------------| +| [MergeTree](/engines/table-engines/mergetree-family/mergetree) | +| [ReplacingMergeTree](/engines/table-engines/mergetree-family/replacingmergetree) | +| [SummingMergeTree](/engines/table-engines/mergetree-family/summingmergetree) | +| [AggregatingMergeTree](/engines/table-engines/mergetree-family/aggregatingmergetree) | +| [CollapsingMergeTree](/engines/table-engines/mergetree-family/collapsingmergetree) | +| [VersionedCollapsingMergeTree](/engines/table-engines/mergetree-family/versionedcollapsingmergetree) | +| [GraphiteMergeTree](/engines/table-engines/mergetree-family/graphitemergetree) | +| [CoalescingMergeTree](/engines/table-engines/mergetree-family/coalescingmergetree) | ### Log {#log} -轻量级的 [引擎](../../engines/table-engines/log-family/index.md),功能最小化。当您需要快速写入许多小表(约 100 万行)并稍后按整体读取时,它们效果最佳。 +轻量级 [引擎](../../engines/table-engines/log-family/index.md),功能最小。当您需要快速写入许多小表(最多约 100 万行)并稍后将其整体读取时,它们最为有效。 -该家族的引擎: +该家族中的引擎: -| Log 引擎 | -|---------------------------------------------------------------------------| -| [TinyLog](/engines/table-engines/log-family/tinylog) | -| [StripeLog](/engines/table-engines/log-family/stripelog) | -| [Log](/engines/table-engines/log-family/log) | +| Log 引擎 | +|----------------------------------------------------------------------------| +| [TinyLog](/engines/table-engines/log-family/tinylog) | +| [StripeLog](/engines/table-engines/log-family/stripelog) | +| [Log](/engines/table-engines/log-family/log) | ### 集成引擎 {#integration-engines} -用于与其他数据存储和处理系统通信的引擎。 +与其他数据存储和处理系统进行通信的引擎。 -该家族的引擎: +该家族中的引擎: | 集成引擎 | -|-----------------------------------------------------------------------| -| [ODBC](../../engines/table-engines/integrations/odbc.md) | -| [JDBC](../../engines/table-engines/integrations/jdbc.md) | -| [MySQL](../../engines/table-engines/integrations/mysql.md) | -| [MongoDB](../../engines/table-engines/integrations/mongodb.md) | -| [Redis](../../engines/table-engines/integrations/redis.md) | -| [HDFS](../../engines/table-engines/integrations/hdfs.md) | -| [S3](../../engines/table-engines/integrations/s3.md) | -| [Kafka](../../engines/table-engines/integrations/kafka.md) | +|---------------------------------------------------------------------------------| +| [ODBC](../../engines/table-engines/integrations/odbc.md) | +| [JDBC](../../engines/table-engines/integrations/jdbc.md) | +| [MySQL](../../engines/table-engines/integrations/mysql.md) | +| [MongoDB](../../engines/table-engines/integrations/mongodb.md) | +| [Redis](../../engines/table-engines/integrations/redis.md) | +| [HDFS](../../engines/table-engines/integrations/hdfs.md) | +| [S3](../../engines/table-engines/integrations/s3.md) | +| [Kafka](../../engines/table-engines/integrations/kafka.md) | | [EmbeddedRocksDB](../../engines/table-engines/integrations/embedded-rocksdb.md) | -| [RabbitMQ](../../engines/table-engines/integrations/rabbitmq.md) | -| [PostgreSQL](../../engines/table-engines/integrations/postgresql.md) | -| [S3Queue](../../engines/table-engines/integrations/s3queue.md) | -| [TimeSeries](../../engines/table-engines/integrations/time-series.md) | +| [RabbitMQ](../../engines/table-engines/integrations/rabbitmq.md) | +| [PostgreSQL](../../engines/table-engines/integrations/postgresql.md) | +| [S3Queue](../../engines/table-engines/integrations/s3queue.md) | +| [TimeSeries](../../engines/table-engines/integrations/time-series.md) | ### 特殊引擎 {#special-engines} -该家族的引擎: +该家族中的引擎: | 特殊引擎 | -|-------------------------------------------------------| -| [Distributed](/engines/table-engines/special/distributed) | -| [Dictionary](/engines/table-engines/special/dictionary) | -| [Merge](/engines/table-engines/special/merge) | -| [Executable](/engines/table-engines/special/executable) | -| [File](/engines/table-engines/special/file) | -| [Null](/engines/table-engines/special/null) | -| [Set](/engines/table-engines/special/set) | -| [Join](/engines/table-engines/special/join) | -| [URL](/engines/table-engines/special/url) | -| [View](/engines/table-engines/special/view) | -| [Memory](/engines/table-engines/special/memory) | -| [Buffer](/engines/table-engines/special/buffer) | -| [External Data](/engines/table-engines/special/external-data) | +|-------------------------------------------------------------| +| [Distributed](/engines/table-engines/special/distributed) | +| [Dictionary](/engines/table-engines/special/dictionary) | +| [Merge](/engines/table-engines/special/merge) | +| [Executable](/engines/table-engines/special/executable) | +| [File](/engines/table-engines/special/file) | +| [Null](/engines/table-engines/special/null) | +| [Set](/engines/table-engines/special/set) | +| [Join](/engines/table-engines/special/join) | +| [URL](/engines/table-engines/special/url) | +| [View](/engines/table-engines/special/view) | +| [Memory](/engines/table-engines/special/memory) | +| [Buffer](/engines/table-engines/special/buffer) | +| [External Data](/engines/table-engines/special/external-data) | | [GenerateRandom](/engines/table-engines/special/generate) | -| [KeeperMap](/engines/table-engines/special/keeper-map) | -| [FileLog](/engines/table-engines/special/filelog) | +| [KeeperMap](/engines/table-engines/special/keeper-map) | +| [FileLog](/engines/table-engines/special/filelog) | ## 虚拟列 {#table_engines-virtual_columns} -虚拟列是表引擎属性,需在引擎源代码中定义。 +虚拟列是一个整合的表引擎属性,在引擎源代码中定义。 -您不应在 `CREATE TABLE` 查询中指定虚拟列,且在 `SHOW CREATE TABLE` 和 `DESCRIBE TABLE` 查询结果中看不到它们。虚拟列也是只读的,因此无法向虚拟列插入数据。 +您不应在 `CREATE TABLE` 查询中指定虚拟列,也无法在 `SHOW CREATE TABLE` 和 `DESCRIBE TABLE` 查询结果中看到它们。虚拟列也是只读的,因此您无法向虚拟列插入数据。 -要从虚拟列中选择数据,必须在 `SELECT` 查询中指定其名称。`SELECT *` 不会返回虚拟列的值。 +要从虚拟列选择数据,必须在 `SELECT` 查询中指定其名称。`SELECT *` 不会返回虚拟列的值。 -如果您创建的表中有一个与表虚拟列同名的列,则该虚拟列将变得不可访问。我们不建议这样做。为避免冲突,虚拟列名称通常以下划线开头。 +如果您创建的表带有与某个虚拟列同名的列,则该虚拟列将变得不可访问。我们不推荐这样做。为了帮助避免冲突,虚拟列的名称通常以下划线作为前缀。 + +- `_table` — 包含读取数据的表的名称。类型:[String](../../sql-reference/data-types/string.md)。 + + 无论使用什么表引擎,每个表都包含一个名为 `_table` 的通用虚拟列。 + + 当查询一个使用 merge 表引擎的表时,您可以在 `WHERE/PREWHERE` 子句中对 `_table` 设置常量条件(例如,`WHERE _table='xyz'`)。在这种情况下,仅对满足 `_table` 条件的表执行读取操作,因此 `_table` 列充当索引。 + + 当使用格式为 `SELECT ... FROM (... UNION ALL ...)` 的查询时,我们可以通过指定 `_table` 列来确定返回行的实际表来源。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/index.md.hash index 3239ae1822e..985abb272a6 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/index.md.hash @@ -1 +1 @@ -efced6cdc7d239cb +3915f18e4fd2427d diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/ExternalDistributed.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/ExternalDistributed.md index fc1c0209dbf..65ab573a596 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/ExternalDistributed.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/ExternalDistributed.md @@ -1,13 +1,14 @@ --- -'description': '`ExternalDistributed` 引擎允许对存储在远程服务器 MySQL 或 PostgreSQL 上的数据执行 `SELECT` - 查询。接受 MySQL 或 PostgreSQL 引擎作为参数,因此可以进行分片。' +'description': '`ExternalDistributed` 引擎允许在存储在远程服务器 MySQL 或 PostgreSQL 上的数据上执行 `SELECT` + 查询。接受 MySQL 或 PostgreSQL 引擎作为参数,因此可以实现分片。' 'sidebar_label': 'ExternalDistributed' 'sidebar_position': 55 'slug': '/engines/table-engines/integrations/ExternalDistributed' 'title': 'ExternalDistributed' +'doc_type': 'reference' --- -`ExternalDistributed` 引擎允许对存储在远程服务器上的 MySQL 或 PostgreSQL 数据执行 `SELECT` 查询。接受 [MySQL](../../../engines/table-engines/integrations/mysql.md) 或 [PostgreSQL](../../../engines/table-engines/integrations/postgresql.md) 引擎作为参数,因此支持分片。 +`ExternalDistributed` 引擎允许在存储于远程服务器 MySQL 或 PostgreSQL 的数据上执行 `SELECT` 查询。接收 [MySQL](../../../engines/table-engines/integrations/mysql.md) 或 [PostgreSQL](../../../engines/table-engines/integrations/postgresql.md) 引擎作为参数,因此可以实现分片。 ## 创建表 {#creating-a-table} @@ -20,12 +21,12 @@ CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] ) ENGINE = ExternalDistributed('engine', 'host:port', 'database', 'table', 'user', 'password'); ``` -请查看 [CREATE TABLE](/sql-reference/statements/create/table) 查询的详细描述。 +查看 [CREATE TABLE](/sql-reference/statements/create/table) 查询的详细描述。 -表结构可以与原始表结构有所不同: +表结构可以与原始表结构不同: -- 列名应与原始表中的列名相同,但您可以只使用部分列且顺序可以不同。 -- 列类型可以与原始表中的列类型不同。ClickHouse 会尝试将值 [cast](/sql-reference/functions/type-conversion-functions#cast) 为 ClickHouse 数据类型。 +- 列名应与原始表中的相同,但可以只使用其中一些列,并且顺序可以不同。 +- 列类型可以与原始表中的不同。 ClickHouse 会尝试 [cast](/sql-reference/functions/type-conversion-functions#cast) 值为 ClickHouse 数据类型。 **引擎参数** @@ -38,17 +39,17 @@ CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] ## 实现细节 {#implementation-details} -支持多个副本,副本之间使用 `|` 分隔,分片之间使用 `,` 分隔。例如: +支持多个副本,副本之间必须用 `|` 分隔,而分片之间则必须用 `,` 分隔。例如: ```sql CREATE TABLE test_shards (id UInt32, name String, age UInt32, money UInt32) ENGINE = ExternalDistributed('MySQL', `mysql{1|2}:3306,mysql{3|4}:3306`, 'clickhouse', 'test_replicas', 'root', 'clickhouse'); ``` -在指定副本时,读取时将为每个分片选择一个可用的副本。如果连接失败,将选择下一个副本,如此类推。如果所有副本的连接尝试都失败,则会以相同的方式重复尝试多次。 +在指定副本时,在读取每个分片时会选择一个可用的副本。如果连接失败,将选择下一个副本,如此类推。如果所有副本的连接尝试都失败,则会重复尝试多次,同样的方式。 -您可以为每个分片指定任意数量的分片和副本。 +您可以为每个分片指定任意数量的副本和任意数量的分片。 -**另请参阅** +**另请参见** - [MySQL 表引擎](../../../engines/table-engines/integrations/mysql.md) - [PostgreSQL 表引擎](../../../engines/table-engines/integrations/postgresql.md) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/ExternalDistributed.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/ExternalDistributed.md.hash index 95df0f68b47..96d8bfe9223 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/ExternalDistributed.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/ExternalDistributed.md.hash @@ -1 +1 @@ -8c62b5a6fec3e7cf +5766efe66f734179 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/arrowflight.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/arrowflight.md new file mode 100644 index 00000000000..d2656590e60 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/arrowflight.md @@ -0,0 +1,67 @@ +--- +'description': '该引擎允许通过 Apache Arrow Flight 查询远程数据集。' +'sidebar_label': 'ArrowFlight' +'sidebar_position': 186 +'slug': '/engines/table-engines/integrations/arrowflight' +'title': 'ArrowFlight' +'doc_type': 'reference' +--- + + +# ArrowFlight + +ArrowFlight 表引擎使 ClickHouse 能够通过 [Apache Arrow Flight](https://arrow.apache.org/docs/format/Flight.html) 协议查询远程数据集。 +此集成允许 ClickHouse 以高性能的列式 Arrow 格式从外部支持 Flight 的服务器获取数据。 + +## 创建表 {#creating-a-table} + +```sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name (name1 [type1], name2 [type2], ...) + ENGINE = ArrowFlight('host:port', 'dataset_name' [, 'username', 'password']); +``` + +**引擎参数** + +* `host:port` — 远程 Arrow Flight 服务器的地址。 +* `dataset_name` — Flight 服务器上数据集的标识符。 +* `username` - 用于基本 HTTP 样式身份验证的用户名。 +* `password` - 用于基本 HTTP 样式身份验证的密码。 +如果未指定 `username` 和 `password`,则表示不使用身份验证 +(只有在 Arrow Flight 服务器允许的情况下才可以工作)。 + +## 使用示例 {#usage-example} + +此示例展示如何创建一个从远程 Arrow Flight 服务器读取数据的表: + +```sql +CREATE TABLE remote_flight_data +( + id UInt32, + name String, + value Float64 +) ENGINE = ArrowFlight('127.0.0.1:9005', 'sample_dataset'); +``` + +将远程数据查询为本地表: + +```sql +SELECT * FROM remote_flight_data ORDER BY id; +``` + +```text +┌─id─┬─name────┬─value─┐ +│ 1 │ foo │ 42.1 │ +│ 2 │ bar │ 13.3 │ +│ 3 │ baz │ 77.0 │ +└────┴─────────┴───────┘ +``` + +## 注意事项 {#notes} + +* 在 ClickHouse 中定义的模式必须与 Flight 服务器返回的模式匹配。 +* 此引擎适用于联合查询、数据虚拟化和解耦存储与计算。 + +## 另见 {#see-also} + +* [Apache Arrow Flight SQL](https://arrow.apache.org/docs/format/FlightSql.html) +* [ClickHouse 中的 Arrow 格式集成](/interfaces/formats/Arrow) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/arrowflight.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/arrowflight.md.hash new file mode 100644 index 00000000000..ca296d0484d --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/arrowflight.md.hash @@ -0,0 +1 @@ +92acdd992e60fdb9 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/azure-queue.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/azure-queue.md index 0efe3edf47e..7299480353d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/azure-queue.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/azure-queue.md @@ -1,15 +1,16 @@ --- -'description': '该引擎与 Azure Blob Storage 生态系统提供集成,允许数据流导入。' +'description': '该引擎提供与 Azure Blob Storage 生态系统的集成,允许流数据导入。' 'sidebar_label': 'AzureQueue' 'sidebar_position': 181 'slug': '/engines/table-engines/integrations/azure-queue' 'title': 'AzureQueue 表引擎' +'doc_type': 'reference' --- # AzureQueue 表引擎 -此引擎提供与 [Azure Blob Storage](https://azure.microsoft.com/en-us/products/storage/blobs) 生态系统的集成,允许流数据导入。 +该引擎提供与 [Azure Blob Storage](https://azure.microsoft.com/en-us/products/storage/blobs) 生态系统的集成,允许流数据导入。 ## 创建表 {#creating-a-table} @@ -25,9 +26,9 @@ CREATE TABLE test (name String, value UInt32) **引擎参数** -`AzureQueue` 参数与 `AzureBlobStorage` 表引擎支持的参数相同。有关参数的详细信息,请参见 [这里](../../../engines/table-engines/integrations/azureBlobStorage.md)。 +`AzureQueue` 参数与 `AzureBlobStorage` 表引擎支持的参数相同。有关参数部分,请参见 [这里](../../../engines/table-engines/integrations/azureBlobStorage.md)。 -与 [AzureBlobStorage](/engines/table-engines/integrations/azureBlobStorage) 表引擎类似,用户可以使用 Azurite 模拟器进行本地 Azure 存储开发。详细信息见 [这里](https://learn.microsoft.com/en-us/azure/storage/common/storage-use-azurite?tabs=docker-hub%2Cblob-storage)。 +与 [AzureBlobStorage](/engines/table-engines/integrations/azureBlobStorage) 表引擎类似,用户可以使用 Azurite 模拟器进行本地 Azure 存储开发。更多细节请见 [这里](https://learn.microsoft.com/en-us/azure/storage/common/storage-use-azurite?tabs=docker-hub%2Cblob-storage)。 **示例** @@ -43,18 +44,19 @@ SETTINGS mode = 'unordered' ## 设置 {#settings} -支持的设置集与 `S3Queue` 表引擎相同,但没有 `s3queue_` 前缀。请参见[设置的完整列表](../../../engines/table-engines/integrations/s3queue.md#settings)。 -要获取针对该表配置的设置列表,请使用 `system.azure_queue_settings` 表。从 `24.10` 起可用。 +支持的设置集合与 `S3Queue` 表引擎相同,但没有 `s3queue_` 前缀。参见 [设置的完整列表](../../../engines/table-engines/integrations/s3queue.md#settings)。 + +要获取为表配置的设置列表,请使用 `system.azure_queue_settings` 表。从 `24.10` 开始可用。 ## 描述 {#description} -`SELECT` 对于流式导入并不特别有用(除非用于调试),因为每个文件只能被导入一次。更实际的做法是使用 [物化视图](../../../sql-reference/statements/create/view.md) 创建实时线程。为此: +`SELECT` 对于流导入并不是特别有用(除了调试),因为每个文件只能导入一次。更实用的方法是使用 [物化视图](../../../sql-reference/statements/create/view.md) 创建实时线程。为此: -1. 使用该引擎从 S3 中指定路径创建一个表,并将其视为数据流。 +1. 使用引擎根据指定路径创建一个表以从S3消费,并将其视为数据流。 2. 创建一个具有所需结构的表。 -3. 创建一个物化视图,将引擎中的数据转换并放入先前创建的表中。 +3. 创建一个物化视图,将数据从引擎转换并放入先前创建的表中。 -当 `MATERIALIZED VIEW` 加入引擎时,它开始在后台收集数据。 +当 `MATERIALIZED VIEW` 连接到引擎时,它会在后台开始收集数据。 示例: @@ -80,13 +82,13 @@ SELECT * FROM stats ORDER BY key; 有关虚拟列的更多信息,请参见 [这里](../../../engines/table-engines/index.md#table_engines-virtual_columns)。 -## 反演 {#introspection} +## 自省 {#introspection} -通过表设置 `enable_logging_to_queue_log=1` 启用表的日志记录。 +通过表设置 `enable_logging_to_queue_log=1` 为表启用日志记录。 -反演能力与 [S3Queue 表引擎](/engines/table-engines/integrations/s3queue#introspection) 相同,但有几个显著的区别: +自省功能与 [S3Queue 表引擎](/engines/table-engines/integrations/s3queue#introspection) 相同,但有几个显著区别: -1. 对于服务器版本 >= 25.1,使用 `system.azure_queue` 访问队列的内存状态。对于较早版本,使用 `system.s3queue`(它还包含 `azure` 表的信息)。 +1. 对于服务器版本 >= 25.1,使用 `system.azure_queue` 获取队列的内存状态。对于较旧版本,使用 `system.s3queue`(它也会包含有关 `azure` 表的信息)。 2. 通过主 ClickHouse 配置启用 `system.azure_queue_log`,例如: ```xml @@ -96,7 +98,7 @@ SELECT * FROM stats ORDER BY key; ``` -此持久表包含与 `system.s3queue` 相同的信息,但针对已处理和失败的文件。 +此持久表与 `system.s3queue` 拥有相同的信息,但针对已处理和失败的文件。 该表具有以下结构: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/azure-queue.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/azure-queue.md.hash index 21d1d63f26e..acbf9a1110f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/azure-queue.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/azure-queue.md.hash @@ -1 +1 @@ -4cd479d5c2b90bab +71b13711c86829f2 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/azureBlobStorage.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/azureBlobStorage.md index 9e1a4638dd6..4b21c9e6a03 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/azureBlobStorage.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/azureBlobStorage.md @@ -1,9 +1,10 @@ --- -'description': '这个引擎提供与 Azure Blob Storage 生态系统的集成。' +'description': '该引擎提供与 Azure Blob Storage 生态系统的集成。' 'sidebar_label': 'Azure Blob Storage' 'sidebar_position': 10 'slug': '/engines/table-engines/integrations/azureBlobStorage' 'title': 'AzureBlobStorage 表引擎' +'doc_type': 'reference' --- @@ -15,26 +16,29 @@ ```sql CREATE TABLE azure_blob_storage_table (name String, value UInt32) - ENGINE = AzureBlobStorage(connection_string|storage_account_url, container_name, blobpath, [account_name, account_key, format, compression]) + ENGINE = AzureBlobStorage(connection_string|storage_account_url, container_name, blobpath, [account_name, account_key, format, compression, partition_strategy, partition_columns_in_data_file, extra_credentials(client_id=, tenant_id=)]) [PARTITION BY expr] [SETTINGS ...] ``` ### 引擎参数 {#engine-parameters} -- `endpoint` — AzureBlobStorage 端点 URL,包含容器和前缀。如果使用的身份验证方法需要,可以选择性地包含 account_name。(`http://azurite1:{port}/[account_name]{container_name}/{data_prefix}`) 或者这些参数可以单独提供,使用 storage_account_url、account_name 和 container。要指定前缀,应使用端点。 -- `endpoint_contains_account_name` - 此标志用于指定端点是否包含 account_name,因为它仅在特定身份验证方法中需要。 (默认值:true) -- `connection_string|storage_account_url` — connection_string 包含账户名称和密钥 ([创建连接字符串](https://learn.microsoft.com/en-us/azure/storage/common/storage-configure-connection-string?toc=%2Fazure%2Fstorage%2Fblobs%2Ftoc.json&bc=%2Fazure%2Fstorage%2Fblobs%2Fbreadcrumb%2Ftoc.json#configure-a-connection-string-for-an-azure-storage-account)),或者您也可以在此提供存储帐户 URL,并将账户名称和账户密钥作为单独的参数提供(见参数 account_name 和 account_key) +- `endpoint` — AzureBlobStorage 端点 URL,包含容器和前缀。可选地可以包含 account_name,如果所使用的身份验证方法需要它。(`http://azurite1:{port}/[account_name]{container_name}/{data_prefix}`),或者这些参数可以单独提供,使用 storage_account_url、account_name 和 container。用于指定前缀时,应使用 endpoint。 +- `endpoint_contains_account_name` - 此标志用于指定端点是否包含 account_name,因为它仅在某些身份验证方法中需要。(默认值:true) +- `connection_string|storage_account_url` — connection_string 包含帐户名称和密钥([创建连接字符串](https://learn.microsoft.com/en-us/azure/storage/common/storage-configure-connection-string?toc=%2Fazure%2Fstorage%2Fblobs%2Ftoc.json&bc=%2Fazure%2Fstorage%2Fblobs%2Fbreadcrumb%2Ftoc.json#configure-a-connection-string-for-an-azure-storage-account)),或者您也可以在这里提供存储帐户 URL,并将帐户名称和帐户密钥作为单独的参数提供(请参见参数 account_name 和 account_key)。 - `container_name` - 容器名称 -- `blobpath` - 文件路径。只在只读模式下支持以下通配符:`*`、`**`、`?`、`{abc,def}` 和 `{N..M}`,其中 `N`、`M` 为数字,`'abc'`、`'def'` 为字符串。 -- `account_name` - 如果使用 storage_account_url,则可以在此指定账户名称 -- `account_key` - 如果使用 storage_account_url,则可以在此指定账户密钥 +- `blobpath` - 文件路径。在只读模式下支持以下通配符:`*`、`**`、`?`、`{abc,def}` 和 `{N..M}`,其中 `N`、`M` — 数字,`'abc'`、`'def'` — 字符串。 +- `account_name` - 如果使用 storage_account_url,则可以在此指定帐户名称。 +- `account_key` - 如果使用 storage_account_url,则可以在此指定帐户密钥。 - `format` — 文件的 [格式](/interfaces/formats.md)。 -- `compression` — 支持的值:`none`、`gzip/gz`、`brotli/br`、`xz/LZMA`、`zstd/zst`。默认情况下,它将根据文件扩展名自动检测压缩。(与设置为 `auto` 相同)。 +- `compression` — 支持的值:`none`、`gzip/gz`、`brotli/br`、`xz/LZMA`、`zstd/zst`。默认情况下,它将通过文件扩展名自动检测压缩。(与设置为 `auto` 的效果相同)。 +- `partition_strategy` – 选项:`WILDCARD` 或 `HIVE`。`WILDCARD` 需要在路径中包含 `{_partition_id}`,该值将替换为分区键。`HIVE` 不允许通配符,假设路径是表根,并生成 Hive 风格的分区目录,使用 Snowflake ID 作为文件名,并将文件格式作为扩展名。默认值为 `WILDCARD`。 +- `partition_columns_in_data_file` - 仅与 `HIVE` 分区策略一起使用。告诉 ClickHouse 是否期望在数据文件中写入分区列。默认值为 `false`。 +- `extra_credentials` - 使用 `client_id` 和 `tenant_id` 进行身份验证。如果提供了 extra_credentials,则优先于 `account_name` 和 `account_key`。 **示例** -用户可以使用 Azurite 模拟器进行本地 Azure 存储开发。更多细节 [在这里](https://learn.microsoft.com/en-us/azure/storage/common/storage-use-azurite?tabs=docker-hub%2Cblob-storage)。如果使用 Azurite 的本地实例,用户可能需要将命令中的 `http://localhost:10000` 替换为 `http://azurite1:10000`,我们假设 Azurite 在主机 `azurite1` 可用。 +用户可以使用 Azurite 模拟器进行本地 Azure 存储开发。更多详细信息请 [点击这里](https://learn.microsoft.com/en-us/azure/storage/common/storage-use-azurite?tabs=docker-hub%2Cblob-storage)。如果使用本地 Azurite 实例,用户可能需要将以下命令中的 `http://azurite1:10000` 替换为 `http://localhost:10000`,假设 Azurite 在主机 `azurite1` 上可用。 ```sql CREATE TABLE test_table (key UInt64, data String) @@ -55,23 +59,23 @@ SELECT * FROM test_table; ## 虚拟列 {#virtual-columns} -- `_path` — 文件路径。类型:`LowCardinality(String)`。 -- `_file` — 文件名称。类型:`LowCardinality(String)`。 +- `_path` — 文件的路径。类型:`LowCardinality(String)`。 +- `_file` — 文件名。类型:`LowCardinality(String)`。 - `_size` — 文件大小(以字节为单位)。类型:`Nullable(UInt64)`。如果大小未知,则值为 `NULL`。 -- `_time` — 文件最后修改时间。类型:`Nullable(DateTime)`。如果时间未知,则值为 `NULL`。 +- `_time` — 文件的最后修改时间。类型:`Nullable(DateTime)`。如果时间未知,则值为 `NULL`。 ## 身份验证 {#authentication} -当前有 3 种身份验证方式: -- `Managed Identity` - 通过提供 `endpoint`、`connection_string` 或 `storage_account_url` 使用。 -- `SAS Token` - 通过提供 `endpoint`、`connection_string` 或 `storage_account_url` 使用。通过 URL 中存在的 '?' 来识别。有关示例,请参见 [azureBlobStorage](/sql-reference/table-functions/azureBlobStorage#using-shared-access-signatures-sas-sas-tokens)。 -- `Workload Identity` - 通过提供 `endpoint` 或 `storage_account_url` 使用。如果在配置中设置了 `use_workload_identity` 参数,([工作负载身份](https://github.com/Azure/azure-sdk-for-cpp/tree/main/sdk/identity/azure-identity#authenticate-azure-hosted-applications)) 被用于身份验证。 +目前有 3 种身份验证方式: +- `Managed Identity` - 通过提供 `endpoint`、`connection_string` 或 `storage_account_url` 来使用。 +- `SAS Token` - 通过提供 `endpoint`、`connection_string` 或 `storage_account_url` 来使用。通过 URL 中的 '?' 来识别。请参见 [azureBlobStorage](/sql-reference/table-functions/azureBlobStorage#using-shared-access-signatures-sas-sas-tokens) 以获取示例。 +- `Workload Identity` - 通过提供 `endpoint` 或 `storage_account_url` 来使用。如果配置中设置了 `use_workload_identity` 参数,([workload identity](https://github.com/Azure/azure-sdk-for-cpp/tree/main/sdk/identity/azure-identity#authenticate-azure-hosted-applications)) 则用于身份验证。 ### 数据缓存 {#data-cache} -`Azure` 表引擎支持本地磁盘的数据缓存。 -有关文件系统缓存配置选项和使用,请参见本 [部分](/operations/storing-data.md/#using-local-cache)。 -缓存是根据存储对象的路径和 ETag 进行的,因此 ClickHouse 不会读取过时的缓存版本。 +`Azure` 表引擎支持在本地磁盘上进行数据缓存。 +有关文件系统缓存配置选项和使用方式,请参见 [此部分](/operations/storing-data.md/#using-local-cache)。 +缓存取决于存储对象的路径和 ETag,因此 ClickHouse 不会读取过时的缓存版本。 要启用缓存,请使用设置 `filesystem_cache_name = ''` 和 `enable_filesystem_cache = 1`。 @@ -81,7 +85,7 @@ FROM azureBlobStorage('DefaultEndpointsProtocol=http;AccountName=devstoreaccount SETTINGS filesystem_cache_name = 'cache_for_azure', enable_filesystem_cache = 1; ``` -1. 将以下部分添加到 ClickHouse 配置文件中: +1. 向 ClickHouse 配置文件添加以下部分: ```xml @@ -94,7 +98,36 @@ SETTINGS filesystem_cache_name = 'cache_for_azure', enable_filesystem_cache = 1; ``` -2. 从 ClickHouse `storage_configuration` 部分重用缓存配置(因此缓存存储),[在这里描述](/operations/storing-data.md/#using-local-cache) +2. 从 ClickHouse 的 `storage_configuration` 部分重用缓存配置(因此缓存存储),[在此处描述](/operations/storing-data.md/#using-local-cache)。 + +### 按分区 {#partition-by} + +`PARTITION BY` — 可选。在大多数情况下,您不需要分区键,如果需要,通常不需要比按月更细粒度的分区。分区不会加速查询(与 ORDER BY 表达式相反)。您不应使用过于细粒度的分区。不要按客户端标识符或名称对数据进行分区(相反,确保客户端标识符或名称是 ORDER BY 表达式中的第一列)。 + +按月分区时,使用 `toYYYYMM(date_column)` 表达式,其中 `date_column` 是类型为 [Date](/sql-reference/data-types/date.md) 的日期列。这里的分区名称采用 `"YYYYMM"` 格式。 + +#### 分区策略 {#partition-strategy} + +`WILDCARD`(默认):将文件路径中的 `{_partition_id}` 通配符替换为实际的分区键。不支持读取。 + +`HIVE` 实现 Hive 风格的分区以进行读取和写入。读取使用递归的 glob 模式进行实现。写入生成的文件格式为:`//.`。 + +注意:使用 `HIVE` 分区策略时,`use_hive_partitioning` 设置没有效果。 + +`HIVE` 分区策略的示例: + +```sql +arthur :) create table azure_table (year UInt16, country String, counter UInt8) ENGINE=AzureBlobStorage(account_name='devstoreaccount1', account_key='Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==', storage_account_url = 'http://localhost:30000/devstoreaccount1', container='cont', blob_path='hive_partitioned', format='Parquet', compression='auto', partition_strategy='hive') PARTITION BY (year, country); + +arthur :) insert into azure_table values (2020, 'Russia', 1), (2021, 'Brazil', 2); + +arthur :) select _path, * from azure_table; + + ┌─_path──────────────────────────────────────────────────────────────────────┬─year─┬─country─┬─counter─┐ +1. │ cont/hive_partitioned/year=2020/country=Russia/7351305360873664512.parquet │ 2020 │ Russia │ 1 │ +2. │ cont/hive_partitioned/year=2021/country=Brazil/7351305360894636032.parquet │ 2021 │ Brazil │ 2 │ + └────────────────────────────────────────────────────────────────────────────┴──────┴─────────┴─────────┘ +``` ## 另请参见 {#see-also} diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/azureBlobStorage.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/azureBlobStorage.md.hash index 511f8b474a4..519d51755fd 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/azureBlobStorage.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/azureBlobStorage.md.hash @@ -1 +1 @@ -9ee4138e8fb7df5d +e7d9da25edfb4ce6 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/deltalake.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/deltalake.md index 497352f7d49..4b775558da4 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/deltalake.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/deltalake.md @@ -4,12 +4,13 @@ 'sidebar_position': 40 'slug': '/engines/table-engines/integrations/deltalake' 'title': 'DeltaLake 表引擎' +'doc_type': 'reference' --- # DeltaLake 表引擎 -该引擎提供对 Amazon S3 中现有 [Delta Lake](https://github.com/delta-io/delta) 表的只读集成。 +此引擎提供与 Amazon S3 中现有的 [Delta Lake](https://github.com/delta-io/delta) 表的只读集成。 ## 创建表 {#create-table} @@ -22,10 +23,10 @@ CREATE TABLE deltalake **引擎参数** -- `url` — 包含现有 Delta Lake 表路径的桶 URL。 -- `aws_access_key_id`,`aws_secret_access_key` - [AWS](https://aws.amazon.com/) 账户用户的长期凭证。您可以使用这些凭证来验证您的请求。该参数是可选的。如果未指定凭证,则将从配置文件中使用。 +- `url` — 指向现有 Delta Lake 表的存储桶 URL 及路径。 +- `aws_access_key_id`, `aws_secret_access_key` - 用于 [AWS](https://aws.amazon.com/) 账户用户的长期凭证。您可以使用这些凭证来验证您的请求。该参数是可选的。如果未指定凭证,则使用配置文件中的凭证。 -引擎参数可以使用 [命名集合](/operations/named-collections.md) 指定。 +引擎参数可以使用 [命名集合](/operations/named-collections.md) 进行指定。 **示例** @@ -55,6 +56,6 @@ CREATE TABLE deltalake ENGINE=DeltaLake(deltalake_conf, filename = 'test_table') `Iceberg` 表引擎和表函数支持与 `S3`、`AzureBlobStorage`、`HDFS` 存储相同的数据缓存。请参见 [这里](../../../engines/table-engines/integrations/s3.md#data-cache)。 -## 另请参阅 {#see-also} +## 另请参见 {#see-also} - [deltaLake 表函数](../../../sql-reference/table-functions/deltalake.md) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/deltalake.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/deltalake.md.hash index 96a63502ae9..8e25f87b6c2 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/deltalake.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/deltalake.md.hash @@ -1 +1 @@ -4b5c5cbddca79208 +6c41270cacc1baf3 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/embedded-rocksdb.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/embedded-rocksdb.md index 9b4d1b508bc..2fdd9050e74 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/embedded-rocksdb.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/embedded-rocksdb.md @@ -1,19 +1,20 @@ --- -'description': '这个引擎允许将 ClickHouse 与 RocksDB 集成' +'description': '此引擎允许将ClickHouse与RocksDB集成' 'sidebar_label': 'EmbeddedRocksDB' 'sidebar_position': 50 'slug': '/engines/table-engines/integrations/embedded-rocksdb' -'title': 'EmbeddedRocksDB 引擎' +'title': '嵌入式RocksDB引擎' +'doc_type': 'reference' --- import CloudNotSupportedBadge from '@theme/badges/CloudNotSupportedBadge'; -# EmbeddedRocksDB 引擎 +# 嵌入式RocksDB引擎 -此引擎允许将 ClickHouse 与 [RocksDB](http://rocksdb.org/) 集成。 +该引擎允许将ClickHouse与[RocksDB](http://rocksdb.org/)集成。 ## 创建表 {#creating-a-table} @@ -29,18 +30,18 @@ CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] 引擎参数: -- `ttl` - 值的生存时间。TTL 以秒为单位。如果 TTL 为 0,则使用常规的 RocksDB 实例(没有 TTL)。 -- `rocksdb_dir` - 已存在的 RocksDB 的目录路径或创建的 RocksDB 的目标路径。使用指定的 `rocksdb_dir` 打开表。 -- `read_only` - 当 `read_only` 设置为 true 时,使用只读模式。对于具有 TTL 的存储,不会触发压缩(既没有手动也没有自动),因此不会移除过期条目。 -- `primary_key_name` – 列表中任意列的名称。 -- `primary key` 必须指定,只支持在主键中使用一列。主键将以二进制形式序列化为 `rocksdb key`。 -- 除主键外的列将按照相应顺序以二进制形式序列化为 `rocksdb` 值。 -- 使用键 `equals` 或 `in` 过滤的查询将优化为从 `rocksdb` 进行多重键查找。 +- `ttl` - 值的生存时间。TTL以秒为单位。如果TTL为0,则使用常规的RocksDB实例(无TTL)。 +- `rocksdb_dir` - 已存在的RocksDB目录的路径或创建的RocksDB的目标路径。以指定的`rocksdb_dir`打开表。 +- `read_only` - 当`read_only`设置为true时,使用只读模式。对于具有TTL的存储,不会触发压缩(无论是手动还是自动),因此不会删除过期条目。 +- `primary_key_name` – 列表中的任意列名。 +- `primary key`必须指定,主键只能支持一列。主键将被序列化为二进制形式作为`rocksdb key`。 +- 除主键外的列将按相应顺序被序列化为二进制形式的`rocksdb value`。 +- 使用key `equals`或`in`过滤的查询将优化为从`rocksdb`进行多key查找。 引擎设置: -- `optimize_for_bulk_insert` – 表为批量插入优化(插入管道将创建 SST 文件并导入到 rocksdb 数据库,而不是写入内存表);默认值:`1`。 -- `bulk_insert_block_size` - 批量插入创建的 SST 文件的最小大小(以行数计算);默认值:`1048449`。 +- `optimize_for_bulk_insert` – 表被优化用于批量插入(插入管道将创建SST文件并导入到rocksdb数据库,而不是写入memtables);默认值:`1`。 +- `bulk_insert_block_size` - 通过批量插入创建的SST文件的最小大小(以行数为单位);默认值:`1048449`。 示例: @@ -58,7 +59,7 @@ PRIMARY KEY key ## 指标 {#metrics} -还有一个 `system.rocksdb` 表,公开 RocksDB 统计信息: +还有`system.rocksdb`表,公开了rocksdb统计信息: ```sql SELECT @@ -74,7 +75,7 @@ FROM system.rocksdb ## 配置 {#configuration} -您还可以使用配置更改任何 [rocksdb 选项](https://github.com/facebook/rocksdb/wiki/Option-String-and-Option-Map): +您还可以使用配置更改任何[RocksDB选项](https://github.com/facebook/rocksdb/wiki/Option-String-and-Option-Map): ```xml @@ -98,13 +99,13 @@ FROM system.rocksdb ``` -默认情况下,简单近似计数优化已关闭,这可能会影响 `count()` 查询的性能。要启用此优化,请设置 `optimize_trivial_approximate_count_query = 1`。此外,该设置会影响 EmbeddedRocksDB 引擎的 `system.tables`,启用该设置以查看 `total_rows` 和 `total_bytes` 的近似值。 +默认情况下,微不足道的近似计数优化被关闭,这可能会影响`count()`查询的性能。要启用此优化,请设置`optimize_trivial_approximate_count_query = 1`。此外,该设置会影响EmbeddedRocksDB引擎的`system.tables`,开启该设置以查看`total_rows`和`total_bytes`的近似值。 ## 支持的操作 {#supported-operations} ### 插入 {#inserts} -当新行插入到 `EmbeddedRocksDB` 时,如果键已存在,则值将被更新;否则,将创建一个新键。 +当新行被插入到`EmbeddedRocksDB`中时,如果密钥已存在,值将被更新,否则将创建一个新密钥。 示例: @@ -114,7 +115,7 @@ INSERT INTO test VALUES ('some key', 1, 'value', 3.2); ### 删除 {#deletes} -可以使用 `DELETE` 查询或 `TRUNCATE` 删除行。 +可以使用`DELETE`查询或`TRUNCATE`删除行。 ```sql DELETE FROM test WHERE key LIKE 'some%' AND v1 > 1; @@ -130,7 +131,7 @@ TRUNCATE TABLE test; ### 更新 {#updates} -可以使用 `ALTER TABLE` 查询更新值。主键不能被更新。 +可以使用`ALTER TABLE`查询更新值。主键不能被更新。 ```sql ALTER TABLE test UPDATE v1 = v1 * 10 + 2 WHERE key LIKE 'some%' AND v3 > 3.1; @@ -138,9 +139,10 @@ ALTER TABLE test UPDATE v1 = v1 * 10 + 2 WHERE key LIKE 'some%' AND v3 > 3.1; ### 连接 {#joins} -支持与 EmbeddedRocksDB 表的特殊 `direct` 连接。此直接连接避免在内存中形成哈希表,而是直接从 EmbeddedRocksDB 中访问数据。 +支持与EmbeddedRocksDB表的特殊`direct`连接。 +此直接连接避免在内存中形成哈希表,并直接从EmbeddedRocksDB访问数据。 -对于大型连接,您可能会看到直接连接的内存使用量大大降低,因为不会创建哈希表。 +在大连接中,您可能会看到直连的内存使用量大大降低,因为没有创建哈希表。 要启用直接连接: ```sql @@ -148,12 +150,12 @@ SET join_algorithm = 'direct, hash' ``` :::tip -当 `join_algorithm` 设置为 `direct, hash` 时,将尽可能使用直接连接,否则使用哈希连接。 +当`join_algorithm`设置为`direct, hash`时,将在可能的情况下使用直接连接,否则使用哈希连接。 ::: #### 示例 {#example} -##### 创建并填充一个 EmbeddedRocksDB 表 {#create-and-populate-an-embeddedrocksdb-table} +##### 创建并填充一个EmbeddedRocksDB表 {#create-and-populate-an-embeddedrocksdb-table} ```sql CREATE TABLE rdb ( @@ -168,13 +170,13 @@ PRIMARY KEY key ```sql INSERT INTO rdb SELECT - toUInt32(sipHash64(number) % 10) as key, - [key, key+1] as value, - ('val2' || toString(key)) as value2 + toUInt32(sipHash64(number) % 10) AS key, + [key, key+1] AS value, + ('val2' || toString(key)) AS value2 FROM numbers_mt(10); ``` -##### 创建并填充一个表以与表 `rdb` 连接 {#create-and-populate-a-table-to-join-with-table-rdb} +##### 创建并填充一个要与表`rdb`连接的表 {#create-and-populate-a-table-to-join-with-table-rdb} ```sql CREATE TABLE t2 @@ -189,7 +191,7 @@ INSERT INTO t2 SELECT number AS k FROM numbers_mt(10) ``` -##### 将连接算法设置为 `direct` {#set-the-join-algorithm-to-direct} +##### 设置连接算法为`direct`{#set-the-join-algorithm-to-direct} ```sql SET join_algorithm = 'direct' @@ -219,5 +221,5 @@ ORDER BY key ASC ``` ### 有关连接的更多信息 {#more-information-on-joins} -- [`join_algorithm` 设置](/operations/settings/settings.md#join_algorithm) -- [JOIN 子句](/sql-reference/statements/select/join.md) +- [`join_algorithm`设置](/operations/settings/settings.md#join_algorithm) +- [JOIN子句](/sql-reference/statements/select/join.md) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/embedded-rocksdb.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/embedded-rocksdb.md.hash index eb6399aaf78..4363cd2a6a1 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/embedded-rocksdb.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/embedded-rocksdb.md.hash @@ -1 +1 @@ -bc76956b2f7223e6 +53acb48e75b78dea diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/hdfs.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/hdfs.md index f66aff09c95..781a30c3d1a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/hdfs.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/hdfs.md @@ -1,10 +1,11 @@ --- -'description': '这个引擎通过允许在 HDFS 上管理数据来提供与 Apache Hadoop 生态系统的集成。这个引擎类似于文件和 URL 引擎,但提供特定于 - Hadoop 的功能。' +'description': '该引擎通过允许在 HDFS 上通过 ClickHouse 管理数据,提供与 Apache Hadoop 生态系统的集成。该引擎类似于文件和 + URL 引擎,但提供 Hadoop 特定的功能。' 'sidebar_label': 'HDFS' 'sidebar_position': 80 'slug': '/engines/table-engines/integrations/hdfs' 'title': 'HDFS' +'doc_type': 'reference' --- import CloudNotSupportedBadge from '@theme/badges/CloudNotSupportedBadge'; @@ -14,11 +15,11 @@ import CloudNotSupportedBadge from '@theme/badges/CloudNotSupportedBadge'; -该引擎通过允许在 ClickHouse 中管理 [HDFS](https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-hdfs/HdfsDesign.html) 上的数据,为 [Apache Hadoop](https://en.wikipedia.org/wiki/Apache_Hadoop) 生态系统提供集成。该引擎类似于 [File](/engines/table-engines/special/file) 和 [URL](/engines/table-engines/special/url) 引擎,但提供了 Hadoop 特有的功能。 +此引擎通过允许在 ClickHouse 上管理 [HDFS](https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-hdfs/HdfsDesign.html) 上的数据,提供与 [Apache Hadoop](https://en.wikipedia.org/wiki/Apache_Hadoop) 生态系统的集成。该引擎与 [File](/engines/table-engines/special/file) 和 [URL](/engines/table-engines/special/url) 引擎类似,但提供了 Hadoop 特定的功能。 -该功能不受 ClickHouse 工程师支持,并且已知质量不稳定。如遇任何问题,请自行修复并提交拉取请求。 +此功能不受 ClickHouse 工程师支持,并且已知质量不稳定。如果遇到任何问题,请自行修复并提交拉取请求。 -## 使用方法 {#usage} +## 用法 {#usage} ```sql ENGINE = HDFS(URI, format) @@ -26,15 +27,15 @@ ENGINE = HDFS(URI, format) **引擎参数** -- `URI` - HDFS 上完整文件的 URI。`URI` 的路径部分可以包含通配符。在这种情况下,表将为只读。 -- `format` - 指定可用文件格式之一。要执行 `SELECT` 查询,格式必须支持输入;要执行 `INSERT` 查询,格式必须支持输出。可用格式在 [Formats](/sql-reference/formats#formats-overview) 部分列出。 +- `URI` - HDFS 中整个文件的 URI。`URI` 的路径部分可以包含通配符。在这种情况下,表将是只读的。 +- `format` - 指定可用文件格式之一。进行 `SELECT` 查询时,格式必须支持输入,而进行 `INSERT` 查询时,格式必须支持输出。可用格式列在 [Formats](/sql-reference/formats#formats-overview) 部分。 - [PARTITION BY expr] ### PARTITION BY {#partition-by} -`PARTITION BY` — 可选。在大多数情况下,您不需要分区键,如果需要,一般情况下,分区键不应比按月更详细。分区不会加速查询(与 ORDER BY 表达式相反)。您应该永远不要使用过于细粒度的分区。不要按照客户端标识符或名称对数据进行分区(相反,让客户端标识符或名称成为 ORDER BY 表达式中的第一列)。 +`PARTITION BY` — 可选。在大多数情况下,您无需分区键,如果需要,通常不需要比按月更细粒度的分区键。分区不会加速查询(与 ORDER BY 表达式相反)。您绝不应使用过于细粒度的分区。不要按客户端标识符或名称对数据进行分区(相反,应将客户端标识符或名称设为 ORDER BY 表达式中的第一列)。 -按月分区时,使用 `toYYYYMM(date_column)` 表达式,其中 `date_column` 是 [Date](/sql-reference/data-types/date.md) 类型的日期列。此处的分区名称为 `"YYYYMM"` 格式。 +按月分区时,使用 `toYYYYMM(date_column)` 表达式,其中 `date_column` 是类型为 [Date](/sql-reference/data-types/date.md) 的日期列。此处的分区名称具有 `"YYYYMM"` 格式。 **示例:** @@ -65,30 +66,30 @@ SELECT * FROM hdfs_engine_table LIMIT 2 ## 实现细节 {#implementation-details} -- 读取和写入可以并行进行。 +- 读写可以并行进行。 - 不支持: - - `ALTER` 和 `SELECT...SAMPLE` 操作。 - - 索引。 - - [零拷贝](../../../operations/storing-data.md#zero-copy) 复制是可能的,但不推荐。 + - `ALTER` 和 `SELECT...SAMPLE` 操作。 + - 索引。 + - [零拷贝](../../../operations/storing-data.md#zero-copy) 复制是可能的,但不建议使用。 - :::note 零拷贝复制不适用于生产环境 - 在 ClickHouse 版本 22.8 及更高版本中,默认禁用零拷贝复制。 不推荐在生产中使用此功能。 + :::note + 零拷贝复制在 ClickHouse 版本 22.8 及更高版本中默认禁用。此功能不建议用于生产环境。 ::: **路径中的通配符** -多个路径组件可以包含通配符。为了进行处理,文件必须存在并且与整个路径模式匹配。文件的列出在 `SELECT` 时确定(而不是在 `CREATE` 时确定)。 +多个路径组件可以具有通配符。要被处理的文件必须存在并符合整个路径模式。文件的列出是在 `SELECT` 时确定的(而不是在 `CREATE` 时)。 -- `*` — 替代任意数量的任意字符(不包括 `/`),也可以替代空字符串。 -- `?` — 替代任意单个字符。 -- `{some_string,another_string,yet_another_one}` — 替代字符串 `'some_string', 'another_string', 'yet_another_one'` 中的任意一个。 -- `{N..M}` — 替代范围内的任意数字,从 N 到 M(包括两个边界)。 +- `*` — 替代除 `/` 外的任何数量的任意字符,包括空字符串。 +- `?` — 替代任何单个字符。 +- `{some_string,another_string,yet_another_one}` — 替代任何字符串 `'some_string', 'another_string', 'yet_another_one'`。 +- `{N..M}` — 替代从 N 到 M 范围内的任何数字,包括两个边界。 -带有 `{}` 的结构与 [remote](../../../sql-reference/table-functions/remote.md) 表函数类似。 +使用 `{}` 的结构类似于 [remote](../../../sql-reference/table-functions/remote.md) 表函数。 **示例** -1. 假设我们在 HDFS 上有多个 TSV 格式的文件,其 URI 如下: +1. 假设我们在 HDFS 上有几个 TSV 格式的文件,URI 如下: - 'hdfs://hdfs1:9000/some_dir/some_file_1' - 'hdfs://hdfs1:9000/some_dir/some_file_2' @@ -97,7 +98,7 @@ SELECT * FROM hdfs_engine_table LIMIT 2 - 'hdfs://hdfs1:9000/another_dir/some_file_2' - 'hdfs://hdfs1:9000/another_dir/some_file_3' -2. 可以通过几种方法创建一个包含所有六个文件的表: +1. 有几种方法可以创建一个由所有六个文件组成的表: @@ -105,7 +106,7 @@ SELECT * FROM hdfs_engine_table LIMIT 2 CREATE TABLE table_with_range (name String, value UInt32) ENGINE = HDFS('hdfs://hdfs1:9000/{some,another}_dir/some_file_{1..3}', 'TSV') ``` -另一种方式: +另一种方法: ```sql CREATE TABLE table_with_question_mark (name String, value UInt32) ENGINE = HDFS('hdfs://hdfs1:9000/{some,another}_dir/some_file_?', 'TSV') @@ -118,19 +119,19 @@ CREATE TABLE table_with_asterisk (name String, value UInt32) ENGINE = HDFS('hdfs ``` :::note -如果文件列表包含带前导零的数字范围,请为每个数字单独使用花括号结构或使用 `?`。 +如果文件列表包含带有前导零的数字范围,请分别为每个数字单独使用大括号构造,或使用 `?`。 ::: **示例** -创建一个文件名为 `file000`, `file001`, ... , `file999` 的表: +创建一个文件名为 `file000`、`file001`、...、`file999` 的表: ```sql CREATE TABLE big_table (name String, value UInt32) ENGINE = HDFS('hdfs://hdfs1:9000/big_dir/file{0..9}{0..9}{0..9}', 'CSV') ``` ## 配置 {#configuration} -类似于 GraphiteMergeTree,HDFS 引擎支持使用 ClickHouse 配置文件的扩展配置。有两个可以使用的配置键:全局 (`hdfs`) 和用户级别 (`hdfs_*`)。首先应用全局配置,然后应用用户级别的配置(如果存在)。 +与 GraphiteMergeTree 类似,HDFS 引擎支持使用 ClickHouse 配置文件进行扩展配置。您可以使用两个配置键:全局 (`hdfs`) 和用户级别 (`hdfs_*`)。全局配置首先应用,然后应用用户级别的配置(如果存在)。 ```xml @@ -150,80 +151,77 @@ CREATE TABLE big_table (name String, value UInt32) ENGINE = HDFS('hdfs://hdfs1:9 #### libhdfs3 支持的 {#supported-by-libhdfs3} -| **参数** | **默认值** | +| **参数** | **默认值** | | - | - | -| rpc\_client\_connect\_tcpnodelay | true | -| dfs\_client\_read\_shortcircuit | true | -| output\_replace-datanode-on-failure | true | -| input\_notretry-another-node | false | -| input\_localread\_mappedfile | true | -| dfs\_client\_use\_legacy\_blockreader\_local | false | -| rpc\_client\_ping\_interval | 10 * 1000 | -| rpc\_client\_connect\_timeout | 600 * 1000 | -| rpc\_client\_read\_timeout | 3600 * 1000 | -| rpc\_client\_write\_timeout | 3600 * 1000 | -| rpc\_client\_socket\_linger\_timeout | -1 | -| rpc\_client\_connect\_retry | 10 | -| rpc\_client\_timeout | 3600 * 1000 | -| dfs\_default\_replica | 3 | -| input\_connect\_timeout | 600 * 1000 | -| input\_read\_timeout | 3600 * 1000 | -| input\_write\_timeout | 3600 * 1000 | -| input\_localread\_default\_buffersize | 1 * 1024 * 1024 | -| dfs\_prefetchsize | 10 | -| input\_read\_getblockinfo\_retry | 3 | -| input\_localread\_blockinfo\_cachesize | 1000 | -| input\_read\_max\_retry | 60 | -| output\_default\_chunksize | 512 | -| output\_default\_packetsize | 64 * 1024 | -| output\_default\_write\_retry | 10 | -| output\_connect\_timeout | 600 * 1000 | -| output\_read\_timeout | 3600 * 1000 | -| output\_write\_timeout | 3600 * 1000 | -| output\_close\_timeout | 3600 * 1000 | -| output\_packetpool\_size | 1024 | -| output\_heartbeat\_interval | 10 * 1000 | -| dfs\_client\_failover\_max\_attempts | 15 | -| dfs\_client\_read\_shortcircuit\_streams\_cache\_size | 256 | -| dfs\_client\_socketcache\_expiryMsec | 3000 | -| dfs\_client\_socketcache\_capacity | 16 | -| dfs\_default\_blocksize | 64 * 1024 * 1024 | -| dfs\_default\_uri | "hdfs://localhost:9000" | -| hadoop\_security\_authentication | "simple" | -| hadoop\_security\_kerberos\_ticket\_cache\_path | "" | -| dfs\_client\_log\_severity | "INFO" | -| dfs\_domain\_socket\_path | "" | - - -[HDFS 配置参考](https://hawq.apache.org/docs/userguide/2.3.0.0-incubating/reference/HDFSConfigurationParameterReference.html) 可能会解释某些参数。 - - -#### ClickHouse 附加参数 {#clickhouse-extras} - -| **参数** | **默认值** | +| rpc\_client\_connect\_tcpnodelay | true | +| dfs\_client\_read\_shortcircuit | true | +| output\_replace-datanode-on-failure | true | +| input\_notretry-another-node | false | +| input\_localread\_mappedfile | true | +| dfs\_client\_use\_legacy\_blockreader\_local | false | +| rpc\_client\_ping\_interval | 10 * 1000 | +| rpc\_client\_connect\_timeout | 600 * 1000 | +| rpc\_client\_read\_timeout | 3600 * 1000 | +| rpc\_client\_write\_timeout | 3600 * 1000 | +| rpc\_client\_socket\_linger\_timeout | -1 | +| rpc\_client\_connect\_retry | 10 | +| rpc\_client\_timeout | 3600 * 1000 | +| dfs\_default\_replica | 3 | +| input\_connect\_timeout | 600 * 1000 | +| input\_read\_timeout | 3600 * 1000 | +| input\_write\_timeout | 3600 * 1000 | +| input\_localread\_default\_buffersize | 1 * 1024 * 1024 | +| dfs\_prefetchsize | 10 | +| input\_read\_getblockinfo\_retry | 3 | +| input\_localread\_blockinfo\_cachesize | 1000 | +| input\_read\_max\_retry | 60 | +| output\_default\_chunksize | 512 | +| output\_default\_packetsize | 64 * 1024 | +| output\_default\_write\_retry | 10 | +| output\_connect\_timeout | 600 * 1000 | +| output\_read\_timeout | 3600 * 1000 | +| output\_write\_timeout | 3600 * 1000 | +| output\_close\_timeout | 3600 * 1000 | +| output\_packetpool\_size | 1024 | +| output\_heartbeat\_interval | 10 * 1000 | +| dfs\_client\_failover\_max\_attempts | 15 | +| dfs\_client\_read\_shortcircuit\_streams\_cache\_size | 256 | +| dfs\_client\_socketcache\_expiryMsec | 3000 | +| dfs\_client\_socketcache\_capacity | 16 | +| dfs\_default\_blocksize | 64 * 1024 * 1024 | +| dfs\_default\_uri | "hdfs://localhost:9000" | +| hadoop\_security\_authentication | "simple" | +| hadoop\_security\_kerberos\_ticket\_cache\_path | "" | +| dfs\_client\_log\_severity | "INFO" | +| dfs\_domain\_socket\_path | "" | + +[HDFS 配置参考](https://hawq.apache.org/docs/userguide/2.3.0.0-incubating/reference/HDFSConfigurationParameterReference.html) 可能会解释一些参数。 + +#### ClickHouse 附加项 {#clickhouse-extras} + +| **参数** | **默认值** | | - | - | -| hadoop\_kerberos\_keytab | "" | -| hadoop\_kerberos\_principal | "" | -| libhdfs3\_conf | "" | +| hadoop\_kerberos\_keytab | "" | +| hadoop\_kerberos\_principal | "" | +| libhdfs3\_conf | "" | ### 限制 {#limitations} -* `hadoop_security_kerberos_ticket_cache_path` 和 `libhdfs3_conf` 只能为全局,不能针对用户 +* `hadoop_security_kerberos_ticket_cache_path` 和 `libhdfs3_conf`只能是全局的,而不是用户特定的。 ## Kerberos 支持 {#kerberos-support} -如果 `hadoop_security_authentication` 参数的值为 `kerberos`,ClickHouse 通过 Kerberos 进行身份验证。 -参数在 [这里](#clickhouse-extras),并且 `hadoop_security_kerberos_ticket_cache_path` 可能会有帮助。 -请注意,由于 libhdfs3 的限制,仅支持传统方法, -数据节点通信不受 SASL 保护(`HADOOP_SECURE_DN_USER` 是这种安全方法的可靠指标)。使用 `tests/integration/test_storage_kerberized_hdfs/hdfs_configs/bootstrap.sh` 作为参考。 +如果 `hadoop_security_authentication` 参数的值为 `kerberos`,ClickHouse 将通过 Kerberos 进行身份验证。 +参数在 [这里](#clickhouse-extras) 可找到,`hadoop_security_kerberos_ticket_cache_path` 可能会有所帮助。 +请注意,由于 libhdfs3 的限制,仅支持传统方法,数据节点之间的通信未通过 SASL 安全(`HADOOP_SECURE_DN_USER` 是此类安全方法的可靠指标)。参考 `tests/integration/test_storage_kerberized_hdfs/hdfs_configs/bootstrap.sh`。 -如果指定了 `hadoop_kerberos_keytab`、`hadoop_kerberos_principal` 或 `hadoop_security_kerberos_ticket_cache_path`,将使用 Kerberos 身份验证。在这种情况下,`hadoop_kerberos_keytab` 和 `hadoop_kerberos_principal` 是必需的。 +如果指定了 `hadoop_kerberos_keytab`、`hadoop_kerberos_principal` 或 `hadoop_security_kerberos_ticket_cache_path`,则将使用 Kerberos 身份验证。在这种情况下,`hadoop_kerberos_keytab` 和 `hadoop_kerberos_principal` 是必需的。 ## HDFS Namenode HA 支持 {#namenode-ha} -libhdfs3 支持 HDFS Namenode HA。 +libhdfs3 支持 HDFS namenode HA。 -- 从 HDFS 节点复制 `hdfs-site.xml` 到 `/etc/clickhouse-server/`。 -- 将以下内容添加到 ClickHouse 配置文件中: +- 将 `hdfs-site.xml` 从 HDFS 节点复制到 `/etc/clickhouse-server/`。 +- 在 ClickHouse 配置文件中添加以下部分: ```xml @@ -231,21 +229,21 @@ libhdfs3 支持 HDFS Namenode HA。 ``` -- 然后使用 `hdfs-site.xml` 中的 `dfs.nameservices` 标签值作为 HDFS URI 中的 Namenode 地址。例如,将 `hdfs://appadmin@192.168.101.11:8020/abc/` 替换为 `hdfs://appadmin@my_nameservice/abc/`。 +- 然后在 HDFS URI 中使用 `hdfs-site.xml` 的 `dfs.nameservices` 标签值作为 namenode 地址。例如,将 `hdfs://appadmin@192.168.101.11:8020/abc/` 替换为 `hdfs://appadmin@my_nameservice/abc/`。 ## 虚拟列 {#virtual-columns} - `_path` — 文件的路径。类型:`LowCardinality(String)`。 - `_file` — 文件名。类型:`LowCardinality(String)`。 -- `_size` — 文件大小(以字节为单位)。类型:`Nullable(UInt64)`。如果大小未知,则值为 `NULL`。 -- `_time` — 文件的最后修改时间。类型:`Nullable(DateTime)`。如果时间未知,则值为 `NULL`。 +- `_size` — 文件大小(以字节为单位)。类型:`Nullable(UInt64)`。如果大小未知,值为 `NULL`。 +- `_time` — 文件的最后修改时间。类型:`Nullable(DateTime)`。如果时间未知,值为 `NULL`。 ## 存储设置 {#storage-settings} -- [hdfs_truncate_on_insert](/operations/settings/settings.md#hdfs_truncate_on_insert) - 允许在插入之前截断文件。默认禁用。 -- [hdfs_create_new_file_on_insert](/operations/settings/settings.md#hdfs_create_new_file_on_insert) - 允许在每次插入时创建新文件(如果格式具有后缀)。默认禁用。 +- [hdfs_truncate_on_insert](/operations/settings/settings.md#hdfs_truncate_on_insert) - 允许在插入前截断文件。默认禁用。 +- [hdfs_create_new_file_on_insert](/operations/settings/settings.md#hdfs_create_new_file_on_insert) - 允许在每次插入时创建一个新文件(如果格式具有后缀)。默认禁用。 - [hdfs_skip_empty_files](/operations/settings/settings.md#hdfs_skip_empty_files) - 允许在读取时跳过空文件。默认禁用。 -**另见** +**另请参阅** - [虚拟列](../../../engines/table-engines/index.md#table_engines-virtual_columns) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/hdfs.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/hdfs.md.hash index e52eb19d414..8fddf3f4a69 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/hdfs.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/hdfs.md.hash @@ -1 +1 @@ -9ae287885e44d41c +76069f68e0379daa diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/hive.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/hive.md index e3c68d3eb48..b9b50a783ad 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/hive.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/hive.md @@ -4,6 +4,7 @@ 'sidebar_position': 84 'slug': '/engines/table-engines/integrations/hive' 'title': 'Hive' +'doc_type': 'guide' --- import CloudNotSupportedBadge from '@theme/badges/CloudNotSupportedBadge'; @@ -13,13 +14,13 @@ import CloudNotSupportedBadge from '@theme/badges/CloudNotSupportedBadge'; -Hive引擎允许您在HDFS Hive表上执行 `SELECT` 查询。目前,支持的输入格式如下: +Hive 引擎允许您在 HDFS Hive 表上执行 `SELECT` 查询。目前,它支持以下输入格式: -- 文本:仅支持简单标量列类型,除了 `binary` +- 文本:仅支持简单标量列类型,除 `binary` 外 -- ORC:支持简单标量列类型,除了 `char`;仅支持复杂类型,如 `array` +- ORC:支持简单标量列类型,除 `char` 外;仅支持复杂类型,例如 `array` -- Parquet:支持所有简单标量列类型;仅支持复杂类型,如 `array` +- Parquet:支持所有简单标量列类型;仅支持复杂类型,例如 `array` ## 创建表 {#creating-a-table} @@ -32,16 +33,16 @@ CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] ) ENGINE = Hive('thrift://host:port', 'database', 'table'); PARTITION BY expr ``` -请参阅 [CREATE TABLE](/sql-reference/statements/create/table) 查询的详细描述。 +请查看 [CREATE TABLE](/sql-reference/statements/create/table) 查询的详细描述。 -表的结构可以与原始Hive表结构不同: -- 列名应与原始Hive表中的列名相同,但您可以仅使用这些列中的某些列,并且顺序可以不同,您还可以使用从其他列计算得出的别名列。 -- 列类型应与原始Hive表中的类型相同。 -- 分区表达式应与原始Hive表一致,并且分区表达式中的列应在表结构内。 +表结构可以与原始 Hive 表结构不同: +- 列名应与原始 Hive 表中的列相同,但您可以只使用其中的一些列且顺序任意,也可以使用从其他列计算的别名列。 +- 列类型应与原始 Hive 表中的列类型相同。 +- 分区表达式应与原始 Hive 表一致,且分区表达式中的列应在表结构中。 **引擎参数** -- `thrift://host:port` — Hive Metastore地址 +- `thrift://host:port` — Hive Metastore 地址 - `database` — 远程数据库名称。 @@ -49,9 +50,9 @@ PARTITION BY expr ## 使用示例 {#usage-example} -### 如何为HDFS文件系统使用本地缓存 {#how-to-use-local-cache-for-hdfs-filesystem} +### 如何为 HDFS 文件系统使用本地缓存 {#how-to-use-local-cache-for-hdfs-filesystem} -我们强烈建议您为远程文件系统启用本地缓存。基准测试显示,启用缓存后速度几乎快2倍。 +我们强烈建议您为远程文件系统启用本地缓存。基准测试表明,启用缓存后几乎快 2 倍。 在使用缓存之前,将其添加到 `config.xml` ```xml @@ -63,14 +64,14 @@ PARTITION BY expr ``` -- enable: 如果为真,ClickHouse将在启动后维护远程文件系统(HDFS)的本地缓存。 +- enable: 如果为 true,ClickHouse 将在启动后维护远程文件系统 (HDFS) 的本地缓存。 - root_dir: 必需。用于存储远程文件系统本地缓存文件的根目录。 -- limit_size: 必需。本地缓存文件的最大大小(以字节为单位)。 -- bytes_read_before_flush: 控制从远程文件系统下载文件时在刷新到本地文件系统前读取的字节数。默认值为1MB。 +- limit_size: 必需。本地缓存文件的最大尺寸(以字节为单位)。 +- bytes_read_before_flush: 控制从远程文件系统下载文件时刷新到本地文件系统前的字节数。默认值为 1MB。 -### 使用ORC输入格式查询Hive表 {#query-hive-table-with-orc-input-format} +### 使用 ORC 输入格式查询 Hive 表 {#query-hive-table-with-orc-input-format} -#### 在Hive中创建表 {#create-table-in-hive} +#### 在 Hive 中创建表 {#create-table-in-hive} ```text hive > CREATE TABLE `test`.`test_orc`( @@ -118,9 +119,9 @@ OK Time taken: 0.295 seconds, Fetched: 1 row(s) ``` -#### 在ClickHouse中创建表 {#create-table-in-clickhouse} +#### 在 ClickHouse 中创建表 {#create-table-in-clickhouse} -在ClickHouse中,从上述创建的Hive表检索数据的表: +在 ClickHouse 中的表,从上述创建的 Hive 表中检索数据: ```sql CREATE TABLE test.test_orc ( @@ -190,9 +191,9 @@ day: 2021-09-18 1 rows in set. Elapsed: 0.078 sec. ``` -### 使用Parquet输入格式查询Hive表 {#query-hive-table-with-parquet-input-format} +### 使用 Parquet 输入格式查询 Hive 表 {#query-hive-table-with-parquet-input-format} -#### 在Hive中创建表 {#create-table-in-hive-1} +#### 在 Hive 中创建表 {#create-table-in-hive-1} ```text hive > @@ -241,9 +242,9 @@ OK Time taken: 0.766 seconds, Fetched: 1 row(s) ``` -#### 在ClickHouse中创建表 {#create-table-in-clickhouse-1} +#### 在 ClickHouse 中创建表 {#create-table-in-clickhouse-1} -在ClickHouse中,从上述创建的Hive表检索数据的表: +在 ClickHouse 中的表,从上述创建的 Hive 表中检索数据: ```sql CREATE TABLE test.test_parquet ( @@ -313,9 +314,9 @@ day: 2021-09-18 1 rows in set. Elapsed: 0.357 sec. ``` -### 使用文本输入格式查询Hive表 {#query-hive-table-with-text-input-format} +### 使用文本输入格式查询 Hive 表 {#query-hive-table-with-text-input-format} -#### 在Hive中创建表 {#create-table-in-hive-2} +#### 在 Hive 中创建表 {#create-table-in-hive-2} ```text hive > @@ -364,9 +365,9 @@ OK Time taken: 0.624 seconds, Fetched: 1 row(s) ``` -#### 在ClickHouse中创建表 {#create-table-in-clickhouse-2} +#### 在 ClickHouse 中创建表 {#create-table-in-clickhouse-2} -在ClickHouse中,从上述创建的Hive表检索数据的表: +在 ClickHouse 中的表,从上述创建的 Hive 表中检索数据: ```sql CREATE TABLE test.test_text ( diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/hive.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/hive.md.hash index 16e338cacbf..be6c3f41134 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/hive.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/hive.md.hash @@ -1 +1 @@ -e3d200d462b96b40 +d2c2d8c5488e7a15 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/hudi.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/hudi.md index d22dc59c3a2..4c09ee9426d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/hudi.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/hudi.md @@ -1,19 +1,20 @@ --- -'description': '该引擎提供与现有 Apache Hudi 表在 Amazon S3 中的只读集成。' +'description': '该引擎提供与现有的 Apache Hudi 表在 Amazon S3 中的只读集成。' 'sidebar_label': 'Hudi' 'sidebar_position': 86 'slug': '/engines/table-engines/integrations/hudi' 'title': 'Hudi 表引擎' +'doc_type': 'reference' --- # Hudi 表引擎 -此引擎提供与 Amazon S3 中现有 Apache [Hudi](https://hudi.apache.org/) 表的只读集成。 +此引擎提供与亚马逊 S3 中现有的 Apache [Hudi](https://hudi.apache.org/) 表的只读集成。 ## 创建表 {#create-table} -请注意,Hudi 表必须已经存在于 S3 中,此命令不接受 DDL 参数来创建新表。 +注意,Hudi 表必须已经存在于 S3 中,此命令不接受 DDL 参数以创建新表。 ```sql CREATE TABLE hudi_table @@ -22,10 +23,10 @@ CREATE TABLE hudi_table **引擎参数** -- `url` — 存在的 Hudi 表的存储桶 URL 路径。 -- `aws_access_key_id`, `aws_secret_access_key` - [AWS](https://aws.amazon.com/) 账户用户的长期凭证。您可以使用这些凭证来验证您的请求。该参数是可选的。如果未指定凭证,则会使用配置文件中的凭证。 +- `url` — 包含现有 Hudi 表路径的存储桶 URL。 +- `aws_access_key_id`,`aws_secret_access_key` - 用于 [AWS](https://aws.amazon.com/) 帐户用户的长期凭证。您可以使用这些凭证来验证您的请求。该参数是可选的。如果未指定凭证,则将使用配置文件中的凭证。 -引擎参数可以使用 [命名集合](/operations/named-collections.md) 指定。 +引擎参数可以使用 [命名集合](/operations/named-collections.md) 进行指定。 **示例** @@ -51,6 +52,6 @@ CREATE TABLE hudi_table ENGINE=Hudi('http://mars-doc-test.s3.amazonaws.com/click CREATE TABLE hudi_table ENGINE=Hudi(hudi_conf, filename = 'test_table') ``` -## 另见 {#see-also} +## 另请参见 {#see-also} - [hudi 表函数](/sql-reference/table-functions/hudi.md) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/hudi.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/hudi.md.hash index e01b1cb1936..926296bd9da 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/hudi.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/hudi.md.hash @@ -1 +1 @@ -20d81132e0861552 +abf4d95bd75a0f75 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/iceberg.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/iceberg.md index 436c9a67ea3..b1b8eac0d1c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/iceberg.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/iceberg.md @@ -1,28 +1,28 @@ --- -'description': '该引擎提供与现有的 Apache Iceberg TABLE 在 Amazon S3、Azure、HDFS 及本地存储的 TABLE - 的只读集成。' +'description': '该引擎提供与现有 Apache Iceberg 表的只读集成,支持 Amazon S3、Azure、HDFS 和本地存储的表。' 'sidebar_label': 'Iceberg' 'sidebar_position': 90 'slug': '/engines/table-engines/integrations/iceberg' 'title': 'Iceberg 表引擎' +'doc_type': 'reference' --- # Iceberg 表引擎 {#iceberg-table-engine} :::warning -我们建议使用 [Iceberg 表函数](/sql-reference/table-functions/iceberg.md) 来处理 ClickHouse 中的 Iceberg 数据。Iceberg 表函数目前提供了足够的功能,提供了对 Iceberg 表的部分只读接口。 +我们建议使用 [Iceberg 表函数](/sql-reference/table-functions/iceberg.md) 来处理 ClickHouse 中的 Iceberg 数据。Iceberg 表函数目前提供了足够的功能,为 Iceberg 表提供了部分只读接口。 -Iceberg 表引擎是可用的,但可能存在限制。ClickHouse 最初并不是为支持具有外部变化模式的表而设计的,这可能会影响 Iceberg 表引擎的功能。因此,与常规表一起使用的某些功能可能不可用或无法正确功能,特别是在使用旧分析器时。 +Iceberg 表引擎是可用的,但可能存在一些限制。ClickHouse 最初并不是为了支持具有外部变更模式的表而设计的,这可能会影响 Iceberg 表引擎的功能。因此,某些适用于常规表的功能可能不可用或无法正常工作,尤其是在使用旧分析器时。 -为了获得最佳兼容性,我们建议在继续改进 Iceberg 表引擎的支持时使用 Iceberg 表函数。 +为了获得最佳兼容性,我们建议在继续改进对 Iceberg 表引擎的支持时使用 Iceberg 表函数。 ::: -该引擎提供与 Amazon S3、Azure、HDFS 上的现有 Apache [Iceberg](https://iceberg.apache.org/) 表以及本地存储表的只读集成。 +该引擎提供了与现有 Apache [Iceberg](https://iceberg.apache.org/) 表的只读集成,这些表存储在 Amazon S3、Azure、HDFS 以及本地。 ## 创建表 {#create-table} -请注意,Iceberg 表必须已经存在于存储中,该命令不接收 DDL 参数以创建新表。 +请注意,Iceberg 表必须已经存在于存储中,此命令不接受用于创建新表的 DDL 参数。 ```sql CREATE TABLE iceberg_table_s3 @@ -75,23 +75,30 @@ CREATE TABLE iceberg_table ENGINE=IcebergS3(iceberg_conf, filename = 'test_table 表引擎 `Iceberg` 现在是 `IcebergS3` 的别名。 ## 模式演变 {#schema-evolution} -目前,借助 ClickHouse,您可以读取其模式随时间变化的 Iceberg 表。我们目前支持读取添加和删除列以及更改其顺序的表。您还可以将要求值的列更改为允许 NULL 的列。此外,我们支持简单类型的许可类型转换,即: +目前,借助 CH,您可以读取随时间变化的 iceberg 表的结构。我们当前支持读取添加和移除列及其顺序发生变化的表。您还可以更改必需值的列为允许 NULL 的列。此外,我们支持简单类型的允许类型转换,即: * int -> long * float -> double -* decimal(P, S) -> decimal(P', S) 其中 P' > P。 +* decimal(P, S) -> decimal(P', S),其中 P' > P。 -目前,无法更改嵌套结构或数组和映射中的元素类型。 +目前,无法更改嵌套结构或数组和地图中的元素类型。 -要读取在创建后其模式已更改的表,可以在创建表时将 allow_dynamic_metadata_for_data_lakes 设置为 true。 +要读取在创建后模式已变化的表并启用动态模式推断,请在创建表时将 allow_dynamic_metadata_for_data_lakes 设置为 true。 ## 分区修剪 {#partition-pruning} -ClickHouse 支持在针对 Iceberg 表的 SELECT 查询中进行分区修剪,这有助于通过跳过不相关的数据文件来优化查询性能。要启用分区修剪,请将 `use_iceberg_partition_pruning` 设置为 1。有关 Iceberg 分区修剪的更多信息,请访问 https://iceberg.apache.org/spec/#partitioning - +ClickHouse 在 SELECT 查询时支持 Iceberg 表的分区修剪,这有助于通过跳过不相关的数据文件来优化查询性能。要启用分区修剪,请设置 `use_iceberg_partition_pruning = 1`。有关 iceberg 分区修剪的更多信息,请访问 https://iceberg.apache.org/spec/#partitioning ## 时间旅行 {#time-travel} -ClickHouse 支持对 Iceberg 表的时间旅行,允许您使用特定的时间戳或快照 ID 查询历史数据。 +ClickHouse 支持 Iceberg 表的时间旅行,允许您使用特定的时间戳或快照 ID 查询历史数据。 + +## 处理有已删除行的表 {#deleted-rows} + +目前,仅支持带有 [位置删除](https://iceberg.apache.org/spec/#position-delete-files) 的 Iceberg 表。 + +以下删除方法 **不支持**: +- [Equality deletes](https://iceberg.apache.org/spec/#equality-delete-files) +- [Deletion vectors](https://iceberg.apache.org/spec/#deletion-vectors)(在 v3 中引入) ### 基本用法 {#basic-usage} ```sql @@ -104,23 +111,23 @@ SELECT * FROM example_table ORDER BY 1 SETTINGS iceberg_snapshot_id = 3547395809148285433 ``` -注意:您不能在同一个查询中同时指定 `iceberg_timestamp_ms` 和 `iceberg_snapshot_id` 参数。 +注意:您不能在同一查询中同时指定 `iceberg_timestamp_ms` 和 `iceberg_snapshot_id` 参数。 -### 重要考虑事项 {#important-considerations} +### 重要考虑 {#important-considerations} - **快照** 通常在以下情况下创建: - - 新数据写入表时 - - 进行某种数据压缩时 + - 向表中写入新数据 + - 执行某种数据压缩 -- **模式更改通常不会创建快照** - 在使用经历模式演变的表进行时间旅行时,这会导致重要的行为。 +- **模式更改通常不创建快照** - 这导致在使用经历过模式演变的表时进行时间旅行时的重要行为。 ### 示例场景 {#example-scenarios} -所有场景均在 Spark 中编写,因为 ClickHouse 目前不支持写入 Iceberg 表。 +所有场景都是用 Spark 编写的,因为 CH 还不支持写入 Iceberg 表。 #### 场景 1:没有新快照的模式更改 {#scenario-1} -考虑此操作顺序: +考虑以下操作序列: ```sql -- Create a table with two columns @@ -155,8 +162,6 @@ SETTINGS iceberg_snapshot_id = 3547395809148285433 +------------+------------+ | 1| Mars| +------------+------------+ - - SELECT * FROM spark_catalog.db.time_travel_example TIMESTAMP AS OF ts2; +------------+------------+ @@ -175,14 +180,14 @@ SETTINGS iceberg_snapshot_id = 3547395809148285433 +------------+------------+-----+ ``` -不同时间戳的查询结果: +在不同时间戳的查询结果: -- 在 ts1 & ts2: 仅原始的两个列出现 -- 在 ts3: 所有三个列出现,第一行的价格为 NULL +- 在 ts1 和 ts2:只有原来的两列出现 +- 在 ts3:出现三列,第一行的价格为 NULL -#### 场景 2:历史和当前模式差异 {#scenario-2} +#### 场景 2:历史与当前模式差异 {#scenario-2} -在当前时刻的时间旅行查询可能会显示与当前表不同的模式: +当前时刻的时间旅行查询可能显示与当前表不同的模式: ```sql -- Create a table @@ -213,8 +218,6 @@ SETTINGS iceberg_snapshot_id = 3547395809148285433 -- Query the table at a current moment SELECT * FROM spark_catalog.db.time_travel_example_2; - - +------------+------------+-----+ |order_number|product_code|price| +------------+------------+-----+ @@ -222,11 +225,11 @@ SETTINGS iceberg_snapshot_id = 3547395809148285433 +------------+------------+-----+ ``` -这是因为 `ALTER TABLE` 不会创建新快照,但对于当前表,Spark 从最新的元数据文件中获取 `schema_id` 的值,而不是快照。 +这是因为 `ALTER TABLE` 不会创建新快照,但是对于当前表,Spark 从最新的元数据文件获取 `schema_id` 的值,而不是快照。 -#### 场景 3:历史和当前模式差异 {#scenario-3} +#### 场景 3:历史与当前模式差异 {#scenario-3} -第二个场景是,在进行时间旅行时,您无法获取在写入任何数据之前表的状态: +第二个问题是,在进行时间旅行时,您无法获取在没有任何数据写入之前表的状态: ```sql -- Create a table @@ -243,37 +246,36 @@ SETTINGS iceberg_snapshot_id = 3547395809148285433 SELECT * FROM spark_catalog.db.time_travel_example_3 TIMESTAMP AS OF ts; -- Finises with error: Cannot find a snapshot older than ts. ``` -在 Clickhouse 中,该行为与 Spark 一致。您可以将 Spark 的 Select 查询自然地替换为 Clickhouse 的 Select 查询,并且效果相同。 +在 Clickhouse 中,该行为与 Spark 一致。您可以在脑中将 Spark 的 Select 查询替换为 Clickhouse 的 Select 查询,这样也能正常工作。 ## 元数据文件解析 {#metadata-file-resolution} -在 ClickHouse 中使用 `Iceberg` 表引擎时,系统需要定位描述 Iceberg 表结构的正确 metadata.json 文件。以下是此解析过程的工作原理: +在 ClickHouse 中使用 `Iceberg` 表引擎时,系统需要定位描述 Iceberg 表结构的正确 metadata.json 文件。解析过程如下: -### 候选搜索(按优先级顺序) {#candidate-search} +### 候选者搜索 {#candidate-search} 1. **直接路径指定**: - * 如果您设置了 `iceberg_metadata_file_path`,系统将通过将其与 Iceberg 表目录路径结合使用此确切路径。 - * 提供此设置后,所有其他解析设置将被忽略。 - +* 如果设置了 `iceberg_metadata_file_path`,系统将使用此确切路径,并与 Iceberg 表目录路径结合。 +* 当提供此设置时,所有其他解析设置将被忽略。 2. **表 UUID 匹配**: - * 如果指定了 `iceberg_metadata_table_uuid`,系统将: - * 仅查看 `metadata` 目录中的 `.metadata.json` 文件 - * 筛选出包含与您指定的 UUID(不区分大小写)相匹配的 `table-uuid` 字段的文件 +* 如果指定了 `iceberg_metadata_table_uuid`,系统将: + * 仅查看 `metadata` 目录中的 `.metadata.json` 文件 + * 筛选包含与您指定的 UUID(不区分大小写)匹配的 `table-uuid` 字段的文件 3. **默认搜索**: - * 如果未提供上述任何设置,则 `metadata` 目录中的所有 `.metadata.json` 文件成为候选。 +* 如果未提供以上任何设置,则 `metadata` 目录中的所有 `.metadata.json` 文件都成为候选者 ### 选择最新文件 {#most-recent-file} -在使用上述规则识别候选文件后,系统确定哪个文件是最新的: +在使用以上规则识别候选文件后,系统确定哪个是最新的: -* 如果启用 `iceberg_recent_metadata_file_by_last_updated_ms_field`: +* 如果启用了 `iceberg_recent_metadata_file_by_last_updated_ms_field`: * 选择具有最大 `last-updated-ms` 值的文件 * 否则: - * 选择最高版本号的文件 - * (版本显示为 `V`,文件名格式为 `V.metadata.json` 或 `V-uuid.metadata.json`) + * 选择版本号最高的文件 + * (版本以 `V` 显示在格式为 `V.metadata.json` 或 `V-uuid.metadata.json` 的文件名中) -**注意**:所有提到的设置都是引擎级别的设置,必须在表创建期间指定,如下所示: +**注意**:所有提到的设置都是引擎级设置,必须在表创建时指定,如下所示: ```sql CREATE TABLE example_table ENGINE = Iceberg( @@ -281,16 +283,16 @@ CREATE TABLE example_table ENGINE = Iceberg( ) SETTINGS iceberg_metadata_table_uuid = '6f6f6407-c6a5-465f-a808-ea8900e35a38'; ``` -**注意**:虽然 Iceberg Catalog 通常处理元数据解析,但 ClickHouse 中的 `Iceberg` 表引擎直接将存储在 S3 中的文件解释为 Iceberg 表,这就是理解这些解析规则的重要性。 +**注意**:虽然 Iceberg Catalogs 通常处理元数据解析,但 ClickHouse 中的 `Iceberg` 表引擎直接将存储在 S3 中的文件解释为 Iceberg 表,因此理解这些解析规则非常重要。 ## 数据缓存 {#data-cache} -`Iceberg` 表引擎和表函数支持与 `S3`、`AzureBlobStorage`、`HDFS` 存储相同的数据缓存。请参见 [此处](../../../engines/table-engines/integrations/s3.md#data-cache)。 +`Iceberg` 表引擎和表函数支持与 `S3`、`AzureBlobStorage`、`HDFS` 存储相同的数据缓存。请参见 [这里](../../../engines/table-engines/integrations/s3.md#data-cache)。 ## 元数据缓存 {#metadata-cache} -`Iceberg` 表引擎和表函数支持存储清单文件、清单列表和元数据 JSON 信息的元数据缓存。缓存存储在内存中。此功能通过设置 `use_iceberg_metadata_files_cache` 控制,默认启用。 +`Iceberg` 表引擎和表函数支持存储清单文件、清单列表和元数据 json 的元数据缓存。缓存存储在内存中。此功能由设置 `use_iceberg_metadata_files_cache` 控制,默认启用。 -## 另见 {#see-also} +## 另请参见 {#see-also} - [iceberg 表函数](/sql-reference/table-functions/iceberg.md) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/iceberg.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/iceberg.md.hash index 969e6f40954..1abdf8b9a28 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/iceberg.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/iceberg.md.hash @@ -1 +1 @@ -4d90ce3130afc6bf +71c0063d1e032bbe diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/index.md index 27bd24a95ae..c390e23d6ad 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/index.md @@ -4,16 +4,47 @@ 'sidebar_position': 40 'slug': '/engines/table-engines/integrations/' 'title': '集成的表引擎' +'doc_type': 'reference' --- -# Table Engines for Integrations +# 表引擎集成 -ClickHouse 提供了多种与外部系统集成的方式,包括表引擎。与所有其他表引擎一样,配置是通过 `CREATE TABLE` 或 `ALTER TABLE` 查询完成的。从用户的角度来看,配置的集成看起来像一个普通的表,但对它的查询会被代理到外部系统。这样的透明查询是此方法相较于替代集成方法(如字典或表函数)的主要优点之一,因为后者在每次使用时都需要自定义查询方法。 +ClickHouse 提供多种与外部系统集成的方式,其中包括表引擎。与其他表引擎一样,配置是通过 `CREATE TABLE` 或 `ALTER TABLE` 查询完成的。对用户而言,配置好的集成看起来就像一个普通的表,但对它的查询会被代理到外部系统。这种透明的查询方式是此方法相对于其他集成方法(如字典或表函数)的一个关键优点,后者在每次使用时都需要使用自定义查询方法。 - + + +| 页面 | 描述 | +|-----|-----| +| [AzureBlobStorage 表引擎](/engines/table-engines/integrations/azureBlobStorage) | 此引擎提供与 Azure Blob Storage 生态系统的集成。 | +| [DeltaLake 表引擎](/engines/table-engines/integrations/deltalake) | 此引擎提供与 Amazon S3 中现有的 Delta Lake 表的只读集成。 | +| [EmbeddedRocksDB 引擎](/engines/table-engines/integrations/embedded-rocksdb) | 此引擎允许将 ClickHouse 与 RocksDB 集成。 | +| [ExternalDistributed](/engines/table-engines/integrations/ExternalDistributed) | `ExternalDistributed` 引擎允许对存储在远程服务器 MySQL 或 PostgreSQL 中的数据执行 `SELECT` 查询。接受 MySQL 或 PostgreSQL 引擎作为参数,因此可以进行分片。 | +| [TimeSeries 引擎](/engines/table-engines/special/time_series) | 存储时间序列的表引擎,即一组与时间戳和标签相关联的值。 | +| [HDFS](/engines/table-engines/integrations/hdfs) | 此引擎通过 ClickHouse 允许管理 HDFS 上的数据,从而与 Apache Hadoop 生态系统集成。此引擎类似于文件和 URL 引擎,但提供了 Hadoop 特定功能。 | +| [Hive](/engines/table-engines/integrations/hive) | Hive 引擎允许您对 HDFS Hive 表执行 `SELECT` 查询。 | +| [Hudi 表引擎](/engines/table-engines/integrations/hudi) | 此引擎提供与 Amazon S3 中现有 Apache Hudi 表的只读集成。 | +| [Iceberg 表引擎](/engines/table-engines/integrations/iceberg) | 此引擎提供与 Amazon S3、Azure、HDFS 中的现有 Apache Iceberg 表及本地存储表的只读集成。 | +| [JDBC](/engines/table-engines/integrations/jdbc) | 允许 ClickHouse 通过 JDBC 连接到外部数据库。 | +| [Kafka 表引擎](/engines/table-engines/integrations/kafka) | Kafka 表引擎可用于与 Apache Kafka 发布工作,并允许您发布或订阅数据流,组织容错存储,处理新消息。 | +| [MaterializedPostgreSQL](/engines/table-engines/integrations/materialized-postgresql) | 创建一个 ClickHouse 表,并将 PostgreSQL 表的数据初始转储到此表中,并开始复制过程。 | +| [MongoDB](/engines/table-engines/integrations/mongodb) | MongoDB 引擎是只读表引擎,允许从远程集合中读取数据。 | +| [MySQL 引擎允许您对存储在远程 MySQL 服务器上的数据执行 `SELECT` 和 `INSERT` 查询。](/engines/table-engines/integrations/mysql) | MySQL 表引擎的文档 | +| [NATS 引擎](/engines/table-engines/integrations/nats) | 此引擎允许将 ClickHouse 与 NATS 集成,以发布或订阅消息主题,并处理新消息。 | +| [ODBC](/engines/table-engines/integrations/odbc) | 允许 ClickHouse 通过 ODBC 连接到外部数据库。 | +| [PostgreSQL 表引擎](/engines/table-engines/integrations/postgresql) | PostgreSQL 引擎允许对存储在远程 PostgreSQL 服务器上的数据执行 `SELECT` 和 `INSERT` 查询。 | +| [RabbitMQ 引擎](/engines/table-engines/integrations/rabbitmq) | 此引擎允许将 ClickHouse 与 RabbitMQ 集成。 | +| [Redis](/engines/table-engines/integrations/redis) | 此引擎允许将 ClickHouse 与 Redis 集成。 | +| [S3 表引擎](/engines/table-engines/integrations/s3) | 此引擎提供与 Amazon S3 生态系统的集成。类似于 HDFS 引擎,但提供 S3 特定的功能。 | +| [S3Queue 表引擎](/engines/table-engines/integrations/s3queue) | 此引擎提供与 Amazon S3 生态系统的集成,并允许流式导入。类似于 Kafka 和 RabbitMQ 引擎,但提供 S3 特定的功能。 | +| [AzureQueue 表引擎](/engines/table-engines/integrations/azure-queue) | 此引擎提供与 Azure Blob Storage 生态系统的集成,允许流式数据导入。 | +| [YTsaurus](/engines/table-engines/integrations/ytsaurus) | 允许从 YTsaurus 集群导入数据的表引擎。 | +| [SQLite](/engines/table-engines/integrations/sqlite) | 此引擎允许导入和导出数据到 SQLite,并支持直接从 ClickHouse 对 SQLite 表的查询。 | +| [ArrowFlight](/engines/table-engines/integrations/arrowflight) | 此引擎允许通过 Apache Arrow Flight 查询远程数据集。 | + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/index.md.hash index c15f3adf1ad..2abecaecf5c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/index.md.hash @@ -1 +1 @@ -e83bb6821ee730e1 +b116c337ae749cb9 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/jdbc.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/jdbc.md index 06a0cabc267..cb4ba117694 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/jdbc.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/jdbc.md @@ -4,6 +4,7 @@ 'sidebar_position': 100 'slug': '/engines/table-engines/integrations/jdbc' 'title': 'JDBC' +'doc_type': 'reference' --- import CloudNotSupportedBadge from '@theme/badges/CloudNotSupportedBadge'; @@ -14,13 +15,13 @@ import CloudNotSupportedBadge from '@theme/badges/CloudNotSupportedBadge'; :::note -clickhouse-jdbc-bridge 包含实验性代码,并且不再支持。它可能含有可靠性问题和安全漏洞。使用它需自担风险。 -ClickHouse 推荐使用内置的表函数,这些函数为临时查询场景(如 Postgres、MySQL、MongoDB 等)提供了更好的替代方案。 +clickhouse-jdbc-bridge 包含实验性代码,并且不再受支持。它可能包含可靠性问题和安全漏洞。使用风险自负。 +ClickHouse 推荐使用 ClickHouse 内置的表函数,这为临时查询场景(如 Postgres、MySQL、MongoDB 等)提供了更好的替代方案。 ::: -允许 ClickHouse 通过 [JDBC](https://en.wikipedia.org/wiki/Java_Database_Connectivity) 连接到外部数据库。 +允许 ClickHouse 通过 [JDBC](https://en.wikipedia.org/wiki/Java_Database_Connectivity) 连接外部数据库。 -为了实现 JDBC 连接,ClickHouse 使用独立程序 [clickhouse-jdbc-bridge](https://github.com/ClickHouse/clickhouse-jdbc-bridge),该程序应作为守护进程运行。 +为了实现 JDBC 连接,ClickHouse 使用单独的程序 [clickhouse-jdbc-bridge](https://github.com/ClickHouse/clickhouse-jdbc-bridge),该程序应作为守护进程运行。 此引擎支持 [Nullable](../../../sql-reference/data-types/nullable.md) 数据类型。 @@ -31,23 +32,25 @@ CREATE TABLE [IF NOT EXISTS] [db.]table_name ( columns list... ) -ENGINE = JDBC(datasource_uri, external_database, external_table) +ENGINE = JDBC(datasource, external_database, external_table) ``` **引擎参数** -- `datasource_uri` — 外部 DBMS 的 URI 或名称。 +- `datasource` — 外部 DBMS 的 URI 或名称。 URI 格式:`jdbc:://:/?user=&password=`。 MySQL 示例:`jdbc:mysql://localhost:3306/?user=root&password=root`。 -- `external_database` — 外部 DBMS 中的数据库。 +- `external_database` — 外部 DBMS 中数据库的名称,或者显式定义的表模式(参见示例)。 -- `external_table` — `external_database` 中表的名称,或如 `select * from table1 where column1=1` 的选择查询。 +- `external_table` — 外部数据库中的表的名称或查询,如 `select * from table1 where column1=1`。 + +- 这些参数也可以通过 [命名集合](operations/named-collections.md) 进行传递。 ## 使用示例 {#usage-example} -通过直接连接 MySQL 服务器和其控制台客户端来创建表: +通过直接连接到 MySQL 服务器的控制台客户端来创建一个表: ```text mysql> CREATE TABLE `test`.`test` ( @@ -100,6 +103,6 @@ SELECT toInt32(number), toFloat32(number * 1.0) FROM system.numbers ``` -## 另请参阅 {#see-also} +## 参见 {#see-also} - [JDBC 表函数](../../../sql-reference/table-functions/jdbc.md)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/jdbc.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/jdbc.md.hash index 37f308eef35..a752ddfc694 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/jdbc.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/jdbc.md.hash @@ -1 +1 @@ -bd04b495a90d6683 +8267bd80b36bc28c diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/kafka.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/kafka.md index da102d3f010..2e116623480 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/kafka.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/kafka.md @@ -1,30 +1,28 @@ --- -'description': 'Kafka 引擎与 Apache Kafka 一起工作,允许您发布或订阅数据流,组织容错存储,并处理数据流。' +'description': 'Kafka 表引擎可以用于与 Apache Kafka 进行发布工作,并让你发布或订阅数据流,组织容错存储,并在流可用时处理它们。' 'sidebar_label': 'Kafka' 'sidebar_position': 110 'slug': '/engines/table-engines/integrations/kafka' -'title': 'Kafka' +'title': 'Kafka 表引擎' +'keywords': +- 'Kafka' +- 'table engine' +'doc_type': 'guide' --- import ExperimentalBadge from '@theme/badges/ExperimentalBadge'; import CloudNotSupportedBadge from '@theme/badges/CloudNotSupportedBadge'; -# Kafka - - +# Kafka 表引擎 :::note -建议 ClickHouse Cloud 用户使用 [ClickPipes](/integrations/clickpipes) 将 Kafka 数据流入 ClickHouse。它原生支持高性能插入,同时确保关注点分离,可以独立扩展数据摄取和集群资源。 +如果您正在使用 ClickHouse Cloud,我们建议使用 [ClickPipes](/integrations/clickpipes)。ClickPipes 原生支持私有网络连接,独立扩展摄取和集群资源,并对流式 Kafka 数据流入 ClickHouse 进行全面监控。 ::: -该引擎与 [Apache Kafka](http://kafka.apache.org/) 一起工作。 - -Kafka 让您能够: - - 发布或订阅数据流。 - 组织容错存储。 -- 持续处理可用的流。 +- 持续处理可用的数据流。 ## 创建表 {#creating-a-table} @@ -59,32 +57,32 @@ SETTINGS [kafka_max_rows_per_message = 1]; ``` -必需的参数: +必填参数: -- `kafka_broker_list` — 以逗号分隔的代理列表(例如,`localhost:9092`)。 +- `kafka_broker_list` — 逗号分隔的代理列表(例如,`localhost:9092`)。 - `kafka_topic_list` — Kafka 主题列表。 -- `kafka_group_name` — Kafka 消费者组。每个组单独跟踪读取边界。如果您不希望消息在集群中重复,必须在所有地方使用相同的组名。 -- `kafka_format` — 消息格式。采用与 SQL `FORMAT` 函数相同的标记法,例如 `JSONEachRow`。有关更多信息,请参见 [Formats](../../../interfaces/formats.md) 部分。 +- `kafka_group_name` — Kafka 消费者组。每个组的读取边界分别跟踪。如果您不希望消息在集群中重复,需在各处使用相同的组名。 +- `kafka_format` — 消息格式。使用与 SQL `FORMAT` 函数相同的符号,例如 `JSONEachRow`。有关更多信息,请参见 [Formats](../../../interfaces/formats.md) 部分。 可选参数: -- `kafka_security_protocol` - 与代理通信所使用的协议。可能的值:`plaintext`、`ssl`、`sasl_plaintext`、`sasl_ssl`。 -- `kafka_sasl_mechanism` - 用于身份验证的 SASL 机制。可能的值:`GSSAPI`、`PLAIN`、`SCRAM-SHA-256`、`SCRAM-SHA-512`、`OAUTHBEARER`。 +- `kafka_security_protocol` - 与代理通信所用的协议。可选值:`plaintext`、`ssl`、`sasl_plaintext`、`sasl_ssl`。 +- `kafka_sasl_mechanism` - 用于身份验证的 SASL 机制。可选值:`GSSAPI`、`PLAIN`、`SCRAM-SHA-256`、`SCRAM-SHA-512`、`OAUTHBEARER`。 - `kafka_sasl_username` - 用于 `PLAIN` 和 `SASL-SCRAM-..` 机制的 SASL 用户名。 - `kafka_sasl_password` - 用于 `PLAIN` 和 `SASL-SCRAM-..` 机制的 SASL 密码。 -- `kafka_schema` — 如果格式要求模式定义,必须使用的参数。例如,[Cap'n Proto](https://capnproto.org/) 要求提供模式文件的路径和根 `schema.capnp:Message` 对象的名称。 -- `kafka_num_consumers` — 每个表的消费者数量。如果单个消费者的吞吐量不足,请指定更多消费者。消费者的总数量不得超过主题中的分区数量,因为每个分区只能分配一个消费者,并且不得大于部署 ClickHouse 服务器上的物理核心数量。默认值:`1`。 -- `kafka_max_block_size` — 获取的最大批量大小(以消息为单位)。默认值:[max_insert_block_size](../../../operations/settings/settings.md#max_insert_block_size)。 -- `kafka_skip_broken_messages` — 对每个块的与模式不兼容的消息的 Kafka 消息解析器容忍度。如果 `kafka_skip_broken_messages = N`,则引擎跳过 *N* 条无法解析的 Kafka 消息(一条消息等于一行数据)。默认值:`0`。 -- `kafka_commit_every_batch` — 每处理完一批数据后提交,而不是在写入整个块后进行单次提交。默认值:`0`。 +- `kafka_schema` — 如果格式需要架构定义,此参数必须使用。例如, [Cap'n Proto](https://capnproto.org/) 需要架构文件的路径和根 `schema.capnp:Message` 对象的名称。 +- `kafka_num_consumers` — 每个表的消费者数量。如果一个消费者的吞吐量不足,请指定更多消费者。消费者的总数不得超过主题中的分区数,因为每个分区只能分配一个消费者,并且不得超过部署 ClickHouse 的服务器上的物理核心数。默认:`1`。 +- `kafka_max_block_size` — 轮询的最大批量大小(以消息为单位)。默认值:[max_insert_block_size](../../../operations/settings/settings.md#max_insert_block_size)。 +- `kafka_skip_broken_messages` — Kafka 消息解析器对每个块中架构不兼容消息的容忍度。如果 `kafka_skip_broken_messages = N`,则引擎会跳过 *N* 个无法解析的 Kafka 消息(消息等于一行数据)。默认值:`0`。 +- `kafka_commit_every_batch` — 在写入整个块后,而不是每次提交时提交每个已消费和处理的批次。默认值:`0`。 - `kafka_client_id` — 客户端标识符。默认为空。 -- `kafka_poll_timeout_ms` — 从 Kafka 进行单次轮询的超时。默认值:[stream_poll_timeout_ms](../../../operations/settings/settings.md#stream_poll_timeout_ms)。 -- `kafka_poll_max_batch_size` — 在单次 Kafka 轮询中要轮询的最大消息数。默认值:[max_block_size](/operations/settings/settings#max_block_size)。 -- `kafka_flush_interval_ms` — 从 Kafka 刷新数据的超时。默认值:[stream_flush_interval_ms](/operations/settings/settings#stream_flush_interval_ms)。 -- `kafka_thread_per_consumer` — 为每个消费者提供独立线程。当启用时,每个消费者独立并行地刷新数据(否则 - 来自多个消费者的行被压缩成一个块)。默认值:`0`。 -- `kafka_handle_error_mode` — 如何处理 Kafka 引擎的错误。可能的值:默认(如果解析消息失败将抛出异常),流(异常消息和原始消息将在虚拟列 `_error` 和 `_raw_message` 中保存)。 -- `kafka_commit_on_select` — 当进行选择查询时提交消息。默认值:`false`。 -- `kafka_max_rows_per_message` — 每个基于行的格式中写入的一条 kafka 消息的最大行数。默认值:`1`。 +- `kafka_poll_timeout_ms` — 从 Kafka 进行单次轮询的超时时间。默认值:[stream_poll_timeout_ms](../../../operations/settings/settings.md#stream_poll_timeout_ms)。 +- `kafka_poll_max_batch_size` — 单次 Kafka 轮询中可以轮询的最大消息数。默认值:[max_block_size](/operations/settings/settings#max_block_size)。 +- `kafka_flush_interval_ms` — 从 Kafka 刷新数据的超时时间。默认值:[stream_flush_interval_ms](/operations/settings/settings#stream_flush_interval_ms)。 +- `kafka_thread_per_consumer` — 为每个消费者提供独立的线程。当启用时,每个消费者独立并行刷新数据(否则——来自多个消费者的行合并为一个块)。默认:`0`。 +- `kafka_handle_error_mode` — 处理 Kafka 引擎错误的方式。可能的值:default(如果解析消息失败,则抛出异常)、stream(异常消息和原始消息将保存在虚拟列 `_error` 和 `_raw_message` 中)、dead_letter_queue(与错误相关的数据将保存在 system.dead_letter_queue 中)。 +- `kafka_commit_on_select` — 在进行选择查询时提交消息。默认值:`false`。 +- `kafka_max_rows_per_message` — 以基于行的格式写入一条 kafka 消息的最大行数。默认:`1`。 示例: @@ -121,7 +119,7 @@ CREATE TABLE queue3 ( 创建表的弃用方法 :::note -在新项目中不要使用此方法。如果可能,请将旧项目切换到上面描述的方法。 +请勿在新项目中使用此方法。如果可能,请将旧项目切换到上述方法。 ::: ```sql @@ -132,23 +130,25 @@ Kafka(kafka_broker_list, kafka_topic_list, kafka_group_name, kafka_format
:::info -Kafka 表引擎不支持具有 [默认值](/sql-reference/statements/create/table#default_values) 的列。如果您需要具有默认值的列,可以在物化视图级别添加它们(见下文)。 +Kafka 表引擎不支持具有 [default value](/sql-reference/statements/create/table#default_values) 的列。如果您需要具有默认值的列,可以在物化视图级别添加它们(见下文)。 ::: ## 描述 {#description} -交付的消息会自动跟踪,因此每个组中的每条消息只计数一次。如果您想获取数据两次,则需要使用另一个组名创建表的副本。 +已交付的消息会自动被跟踪,因此组中的每条消息仅计数一次。如果想要获取数据两次,则需使用另一个组名创建表的副本。 -组是灵活的并在集群中同步。例如,如果您有 10 个主题和 5 个表副本在集群中,则每个副本获得 2 个主题。如果副本数量发生变化,主题会自动在副本之间重新分配。请在 http://kafka.apache.org/intro 上阅读更多内容。 +组是灵活的,并且在集群中同步。例如,如果您有 10 个主题和 5 个表副本,则每个副本会获取 2 个主题。如果副本数量发生变化,主题会自动在副本之间重新分配。在此查阅更多信息 http://kafka.apache.org/intro。 -`SELECT` 对于读取消息并不是特别有用(除非用于调试),因为每条消息只能被读取一次。创建实时线程使用物化视图更为实用。要做到这一点: +建议每个 Kafka 主题都有其专用的消费者组,确保主题与组之间的独占配对,尤其是在主题可能动态创建和删除的环境(例如,测试或暂存环境)。 -1. 使用引擎创建 Kafka 消费者,并将其视为数据流。 -2. 创建具有所需结构的表。 -3. 创建一个物化视图,将来自引擎的数据转换并放入之前创建的表中。 +`SELECT` 在读取消息时并不是特别有用(除了调试),因为每条消息只能读取一次。使用物化视图创建实时线程更加实用。要做到这一点: -当 `MATERIALIZED VIEW` 连接引擎时,它开始在后台收集数据。这使您能够不断接收来自 Kafka 的消息并使用 `SELECT` 将其转换为所需的格式。 -一个 kafka 表可以有任意数量的物化视图,它们不会直接从 kafka 表读取数据,而是以块的形式接收新记录,这样您可以写入多个具有不同详细级别的表(使用分组 - 聚合和不使用)。 +1. 将引擎用于创建 Kafka 消费者,并将其视为数据流。 +2. 创建具有所需结构的表。 +3. 创建物化视图,将引擎中的数据转换并放入先前创建的表中。 + +当 `MATERIALIZED VIEW` 连接引擎时,它会在后台开始收集数据。这使您能够不断接收来自 Kafka 的消息,并使用 `SELECT` 将其转换为所需格式。 +一个 Kafka 表可以有任意数量的物化视图,它们并不直接从 Kafka 表中读取数据,而是接收新的记录(以块的形式),这样您可以将数据写入多个表,并具有不同的详细级别(有聚合和无聚合)。 示例: @@ -166,12 +166,12 @@ CREATE TABLE daily ( ) ENGINE = SummingMergeTree(day, (day, level), 8192); CREATE MATERIALIZED VIEW consumer TO daily - AS SELECT toDate(toDateTime(timestamp)) AS day, level, count() as total + AS SELECT toDate(toDateTime(timestamp)) AS day, level, count() AS total FROM queue GROUP BY day, level; SELECT level, sum(total) FROM daily GROUP BY level; ``` -为了提高性能,接收的消息被分组为 [max_insert_block_size](../../../operations/settings/settings.md#max_insert_block_size) 大小的块。如果在 [stream_flush_interval_ms](/operations/settings/settings#stream_flush_interval_ms) 毫秒内没有形成块,则数据将被刷新到表中,而不考虑块的完整性。 +为了提高性能,接收到的消息被分组为 [max_insert_block_size](../../../operations/settings/settings.md#max_insert_block_size) 大小的块。如果在 [stream_flush_interval_ms](/operations/settings/settings#stream_flush_interval_ms) 毫秒内未形成块,则数据将被刷新到表中,而不管块的完整性。 要停止接收主题数据或更改转换逻辑,请分离物化视图: @@ -180,11 +180,11 @@ DETACH TABLE consumer; ATTACH TABLE consumer; ``` -如果您希望通过 `ALTER` 更改目标表,建议禁用物化视图,以避免目标表和视图数据之间的不一致。 +如果要使用 `ALTER` 更改目标表,建议先禁用物化视图,以避免目标表与视图数据之间的不一致。 ## 配置 {#configuration} -类似于 GraphiteMergeTree,Kafka 引擎支持使用 ClickHouse 配置文件的扩展配置。您可以使用两个配置键:全局(在 `` 下面)和主题级(在 `` 下面)。全局配置首先应用,然后应用主题级配置(如果存在)。 +与 GraphiteMergeTree 类似,Kafka 引擎支持使用 ClickHouse 配置文件进行扩展配置。您可以使用两个配置键:全局(在 `` 之下)和主题级(在 `` 之下)。全局配置首先应用,然后应用主题级配置(如果存在)。 ```xml @@ -226,12 +226,12 @@ ATTACH TABLE consumer; ``` -有关可能的配置选项列表,请参见 [librdkafka 配置参考](https://github.com/edenhill/librdkafka/blob/master/CONFIGURATION.md)。在 ClickHouse 配置中,使用下划线 (`_`) 替代点。例如,`check.crcs=true` 将变为 `true`。 +有关可能的配置选项列表,请参见 [librdkafka 配置参考](https://github.com/edenhill/librdkafka/blob/master/CONFIGURATION.md)。在 ClickHouse 配置中使用下划线(`_`)代替点。例如,`check.crcs=true` 将变为 `true`。 -### Kerberos支持 {#kafka-kerberos-support} +### Kerberos 支持 {#kafka-kerberos-support} -要处理支持 Kerberos 的 Kafka,请添加 `security_protocol` 子元素,值为 `sasl_plaintext`。只要 Kerberos 票证授权票据由操作系统设施获取并缓存即可。 -ClickHouse 可以使用密钥表文件维护 Kerberos 凭证。考虑 `sasl_kerberos_service_name`、`sasl_kerberos_keytab` 和 `sasl_kerberos_principal` 子元素。 +要处理支持 Kerberos 的 Kafka,请添加 `security_protocol` 子元素,其值为 `sasl_plaintext`。只需通过操作系统功能获得并缓存 Kerberos Ticket Granting Ticket 即可。 +ClickHouse 能够使用 keytab 文件维护 Kerberos 凭据。请考虑 `sasl_kerberos_service_name`、`sasl_kerberos_keytab` 和 `sasl_kerberos_principal` 子元素。 示例: @@ -246,53 +246,42 @@ ClickHouse 可以使用密钥表文件维护 Kerberos 凭证。考虑 `sasl_kerb ## 虚拟列 {#virtual-columns} -- `_topic` — Kafka 主题。数据类型: `LowCardinality(String)`。 -- `_key` — 消息的键。数据类型: `String`。 -- `_offset` — 消息的偏移量。数据类型: `UInt64`。 -- `_timestamp` — 消息的时间戳。数据类型: `Nullable(DateTime)`。 -- `_timestamp_ms` — 消息的时间戳(以毫秒为单位)。数据类型: `Nullable(DateTime64(3))`。 -- `_partition` — Kafka 主题的分区。数据类型: `UInt64`。 -- `_headers.name` — 消息头的键数组。数据类型: `Array(String)`。 -- `_headers.value` — 消息头的值数组。数据类型: `Array(String)`。 +- `_topic` — Kafka 主题。数据类型:`LowCardinality(String)`。 +- `_key` — 消息的键。数据类型:`String`。 +- `_offset` — 消息的偏移量。数据类型:`UInt64`。 +- `_timestamp` — 消息的时间戳。数据类型:`Nullable(DateTime)`。 +- `_timestamp_ms` — 消息的毫秒级时间戳。数据类型:`Nullable(DateTime64(3))`。 +- `_partition` — Kafka 主题的分区。数据类型:`UInt64`。 +- `_headers.name` — 消息的头部键的数组。数据类型:`Array(String)`。 +- `_headers.value` — 消息的头部值的数组。数据类型:`Array(String)`。 当 `kafka_handle_error_mode='stream'` 时的附加虚拟列: -- `_raw_message` - 无法成功解析的原始消息。数据类型: `String`。 -- `_error` - 解析失败期间发生的异常消息。数据类型: `String`。 +- `_raw_message` - 无法成功解析的原始消息。数据类型:`String`。 +- `_error` - 解析失败时发生的异常消息。数据类型:`String`。 -注意:当解析成功时,虚拟列 `_raw_message` 和 `_error` 始终为空,仅在解析期间发生异常时填充。 +注意:只有在解析期间发生异常时,`_raw_message` 和 `_error` 虚拟列才会被填充,当消息成功解析时它们始终为空。 ## 数据格式支持 {#data-formats-support} -Kafka 引擎支持 ClickHouse 支持的所有 [格式](../../../interfaces/formats.md)。 -一条 Kafka 消息中的行数取决于格式是行式还是块式: +Kafka 引擎支持 ClickHouse 中支持的所有 [格式](../../../interfaces/formats.md)。 +一条 Kafka 消息中的行数取决于格式是基于行还是基于块: -- 对于行式格式,可以通过设置 `kafka_max_rows_per_message` 控制一条 Kafka 消息中的行数。 -- 对于块式格式,我们无法将块拆分为更小的部分,但可以通过通用设置 [max_block_size](/operations/settings/settings#max_block_size) 控制一个块中的行数。 +- 对于基于行的格式,可以通过设置 `kafka_max_rows_per_message` 来控制一条 Kafka 消息中的行数。 +- 对于基于块的格式,我们无法将块划分为更小的部分,但可以通过通用设置 [max_block_size](/operations/settings/settings#max_block_size) 来控制一个块中的行数。 -## 存储已提交偏移量的引擎在 ClickHouse Keeper 中 {#engine-to-store-committed-offsets-in-clickhouse-keeper} +## 存储已提交偏移量到 ClickHouse Keeper 的引擎 {#engine-to-store-committed-offsets-in-clickhouse-keeper} -如果启用 `allow_experimental_kafka_offsets_storage_in_keeper`,则可以为 Kafka 表引擎指定另外两个设置: - - `kafka_keeper_path` 指定 ClickHouse Keeper 中表的路径 - - `kafka_replica_name` 指定 ClickHouse Keeper 中的副本名 +如果启用了 `allow_experimental_kafka_offsets_storage_in_keeper`,则可以向 Kafka 表引擎指定两个设置: +- `kafka_keeper_path` 指定 ClickHouse Keeper 中表的路径 +- `kafka_replica_name` 指定 ClickHouse Keeper 中的副本名称 -必须指定这两个设置中的全部或全无。当两个设置同时指定时,将使用一种新的实验性 Kafka 引擎。该新引擎不依赖于 Kafka 中存储已提交的偏移量,而是将其存储在 ClickHouse Keeper 中。它仍会尝试将偏移量提交到 Kafka,但仅在创建表时依赖这些偏移量。在其他情况下(表被重启或在某种错误后恢复时),将使用存储在 ClickHouse Keeper 中的偏移量作为继续消费消息的偏移量。除了已提交的偏移量外,它还存储了最后一批消费的消息数,因此如果插入失败,将消费相同数量的消息,从而在必要时启用去重。 +这两个设置必须同时指定或都不指定。当同时指定时,将使用新的实验性 Kafka 引擎。该新引擎不依赖于在 Kafka 中存储已提交的偏移量,而是将其存储在 ClickHouse Keeper 中。它仍然会尝试将偏移量提交到 Kafka,但在创建表时仅依赖这些偏移量。在其他情况下(如表重启或恢复后发生错误),将使用存储在 ClickHouse Keeper 中的偏移量作为继续消费消息的偏移量。除了已提交的偏移量外,它还存储最后一批中消耗的消息数量,因此如果插入失败,仍将消耗相同数量的消息,从而在必要时实现去重。 示例: -```sql -CREATE TABLE experimental_kafka (key UInt64, value UInt64) -ENGINE = Kafka('localhost:19092', 'my-topic', 'my-consumer', 'JSONEachRow') -SETTINGS - kafka_keeper_path = '/clickhouse/{database}/experimental_kafka', - kafka_replica_name = 'r1' -SETTINGS allow_experimental_kafka_offsets_storage_in_keeper=1; -``` - -或者利用 `uuid` 和 `replica` 宏,类似于 ReplicatedMergeTree: - ```sql CREATE TABLE experimental_kafka (key UInt64, value UInt64) ENGINE = Kafka('localhost:19092', 'my-topic', 'my-consumer', 'JSONEachRow') @@ -304,13 +293,13 @@ SETTINGS allow_experimental_kafka_offsets_storage_in_keeper=1; ### 已知限制 {#known-limitations} -由于新引擎是实验性的,因此尚未准备好投入生产。该实现存在一些已知限制: - - 最大的限制是引擎不支持直接读取。使用物化视图从引擎读取和写入到引擎工作正常,但直接读取不行。因此,所有直接的 `SELECT` 查询将失败。 - - 快速删除和重新创建表或将相同的 ClickHouse Keeper 路径指定给不同引擎可能导致问题。最佳实践是在 `kafka_keeper_path` 中使用 `{uuid}` 以避免路径冲突。 - - 为了确保可重复的读取,在单个线程中不能从多个分区消费消息。另一方面,需要定期轮询 Kafka 消费者以保持其活动。因此基于这两个目标,我们决定仅在启用 `kafka_thread_per_consumer` 的情况下允许创建多个消费者,否则对于定期轮询消费者难以避免问题。 - - 由新存储引擎创建的消费者不会出现在 [`system.kafka_consumers`](../../../operations/system-tables/kafka_consumers.md) 表中。 +由于新引擎是实验性的,因此尚未准备好投入生产。实现有几项已知限制: +- 最大的限制是引擎不支持直接读取。使用物化视图从引擎读取和向引擎写入可以正常工作,但直接读取不支持。因此,所有直接的 `SELECT` 查询都会失败。 +- 快速删除和重新创建表,或将相同的 ClickHouse Keeper 路径指定给不同的引擎,可能导致问题。作为最佳实践,您可以在 `kafka_keeper_path` 中使用 `{uuid}` 来避免路径冲突。 +- 为了实现可重复读取,消息不能在单个线程上从多个分区中消费。另一方面,Kafka 消费者必须定期轮询以保持活动。因此,我们决定仅在启用 `kafka_thread_per_consumer` 时允许创建多个消费者,否则避免定期轮询消费者的问题就会太复杂。 +- 新存储引擎创建的消费者不会出现在 [`system.kafka_consumers`](../../../operations/system-tables/kafka_consumers.md) 表中。 -**另请参阅** +**另见** - [虚拟列](../../../engines/table-engines/index.md#table_engines-virtual_columns) - [background_message_broker_schedule_pool_size](/operations/server-configuration-parameters/settings#background_message_broker_schedule_pool_size) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/kafka.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/kafka.md.hash index d34e779d678..e7c827bbcda 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/kafka.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/kafka.md.hash @@ -1 +1 @@ -457cb34add0e2bf4 +ebd3a14d78f4c536 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/materialized-postgresql.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/materialized-postgresql.md index d5df6f11fa6..673c053df7b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/materialized-postgresql.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/materialized-postgresql.md @@ -1,9 +1,10 @@ --- -'description': '创建一个 ClickHouse 表,初始数据来自 PostgreSQL 表的转储,并开始复制过程。' -'sidebar_label': '物化视图PostgreSQL' +'description': '创建一个ClickHouse表,并从PostgreSQL表导入初始数据转储,开始复制过程。' +'sidebar_label': '物化的PostgreSQL' 'sidebar_position': 130 'slug': '/engines/table-engines/integrations/materialized-postgresql' -'title': '物化视图PostgreSQL' +'title': '物化的PostgreSQL' +'doc_type': 'guide' --- import ExperimentalBadge from '@theme/badges/ExperimentalBadge'; @@ -16,19 +17,19 @@ import CloudNotSupportedBadge from '@theme/badges/CloudNotSupportedBadge'; :::note -ClickHouse Cloud 用户建议使用 [ClickPipes](/integrations/clickpipes) 来将 PostgreSQL 复制到 ClickHouse。这原生支持对 PostgreSQL 的高性能变更数据捕获(CDC)。 +推荐 ClickHouse Cloud 用户使用 [ClickPipes](/integrations/clickpipes) 进行 PostgreSQL 到 ClickHouse 的复制。它原生支持 PostgreSQL 的高性能变更数据捕获 (CDC)。 ::: -创建 ClickHouse 表,并用 PostgreSQL 表的初始数据转储进行填充,并启动复制过程,即它执行后台作业以根据发生在远程 PostgreSQL 数据库的 PostgreSQL 表上的新更改进行应用。 +创建 ClickHouse 表,并将 PostgreSQL 表的初始数据转储到其中,并启动复制过程,即执行后台作业以根据远程 PostgreSQL 数据库中 PostgreSQL 表发生的新更改来应用这些更改。 :::note -此表引擎为实验性。要使用它,请在您的配置文件中将 `allow_experimental_materialized_postgresql_table` 设置为 1,或使用 `SET` 命令: +此表引擎属于实验性。要使用它,请在配置文件中将 `allow_experimental_materialized_postgresql_table` 设置为 1,或使用 `SET` 命令: ```sql SET allow_experimental_materialized_postgresql_table=1 ``` ::: -如果需要多个表,强烈建议使用 [MaterializedPostgreSQL](../../../engines/database-engines/materialized-postgresql.md) 数据库引擎,而不是表引擎,并使用 `materialized_postgresql_tables_list` 设置,该设置指定要被复制的表(也可以添加数据库的 `schema`)。在 CPU 使用、连接数和远程 PostgreSQL 数据库内的复制槽方面,这将会更好。 +如果需要多个表,强烈建议使用 [MaterializedPostgreSQL](../../../engines/database-engines/materialized-postgresql.md) 数据库引擎,而不是表引擎,并使用 `materialized_postgresql_tables_list` 设置,该设置指定要复制的表(也可以添加数据库 `schema`)。这在 CPU 使用率、连接数和远程 PostgreSQL 数据库中的复制槽数方面都会更好。 ## 创建表 {#creating-a-table} @@ -46,26 +47,26 @@ PRIMARY KEY key; - `user` — PostgreSQL 用户。 - `password` — 用户密码。 -## 要求 {#requirements} +## 需求 {#requirements} -1. [wal_level](https://www.postgresql.org/docs/current/runtime-config-wal.html) 设置必须具有值 `logical`,并且 `max_replication_slots` 参数必须在 PostgreSQL 配置文件中至少具有值 `2`。 +1. PostgreSQL 配置文件中的 [wal_level](https://www.postgresql.org/docs/current/runtime-config-wal.html) 设置必须具有 `logical` 值,且 `max_replication_slots` 参数的值必须至少为 `2`。 -2. 使用 `MaterializedPostgreSQL` 引擎的表必须具有主键——与 PostgreSQL 表的副本标识索引相同(默认:主键)(请参阅 [关于副本标识索引的详细信息](../../../engines/database-engines/materialized-postgresql.md#requirements))。 +2. `MaterializedPostgreSQL` 引擎的表必须具有主键 — 与 PostgreSQL 表的副本身份索引相同(默认:主键)(请参见 [副本身份索引的详细信息](../../../engines/database-engines/materialized-postgresql.md#requirements))。 -3. 仅允许数据库 [Atomic](https://en.wikipedia.org/wiki/Atomicity_(database_systems))。 +3. 只允许使用数据库 [Atomic](https://en.wikipedia.org/wiki/Atomicity_(database_systems))。 -4. `MaterializedPostgreSQL` 表引擎仅适用于 PostgreSQL 版本 >= 11,因为该实现需要 [pg_replication_slot_advance](https://pgpedia.info/p/pg_replication_slot_advance.html) PostgreSQL 函数。 +4. `MaterializedPostgreSQL` 表引擎仅适用于版本 >= 11 的 PostgreSQL,因为实现需要 [pg_replication_slot_advance](https://pgpedia.info/p/pg_replication_slot_advance.html) PostgreSQL 函数。 ## 虚拟列 {#virtual-columns} -- `_version` — 事务计数器。类型:[UInt64](../../../sql-reference/data-types/int-uint.md)。 +- `_version` — 事务计数器。类型: [UInt64](../../../sql-reference/data-types/int-uint.md)。 -- `_sign` — 删除标记。类型:[Int8](../../../sql-reference/data-types/int-uint.md)。可能的值: - - `1` — 行未被删除, - - `-1` — 行已被删除。 +- `_sign` — 删除标记。类型: [Int8](../../../sql-reference/data-types/int-uint.md)。可能的值: + - `1` — 行未被删除, + - `-1` — 行已被删除。 -这些列在创建表时不需要添加。它们在 `SELECT` 查询中始终可访问。 -`_version` 列等于 `WAL` 中的 `LSN` 位置,因此可以用来检查复制的最新程度。 +在创建表时,这些列不需要添加。它们在 `SELECT` 查询中始终可访问。 +`_version` 列等于 `WAL` 中的 `LSN` 位置,所以可以用来检查复制的最新情况。 ```sql CREATE TABLE postgresql_db.postgresql_replica (key UInt64, value UInt64) @@ -76,5 +77,5 @@ SELECT key, value, _version FROM postgresql_db.postgresql_replica; ``` :::note -不支持复制 [**TOAST**](https://www.postgresql.org/docs/9.5/storage-toast.html) 值。将使用数据类型的默认值。 +不支持 [**TOAST**](https://www.postgresql.org/docs/9.5/storage-toast.html) 值的复制。将使用该数据类型的默认值。 ::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/materialized-postgresql.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/materialized-postgresql.md.hash index 7f4daf8e962..dccb38364ab 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/materialized-postgresql.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/materialized-postgresql.md.hash @@ -1 +1 @@ -aae3422db871676e +2bb440072a1b72cd diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/mongodb.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/mongodb.md index fb7c0373d3e..ce4dbe49911 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/mongodb.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/mongodb.md @@ -1,17 +1,18 @@ --- -'description': 'MongoDB 引擎是只读的表引擎,允许从远程集合中读取数据。' +'description': 'MongoDB 引擎是只读表引擎,允许从远程集合读取数据。' 'sidebar_label': 'MongoDB' 'sidebar_position': 135 'slug': '/engines/table-engines/integrations/mongodb' 'title': 'MongoDB' +'doc_type': 'guide' --- # MongoDB -MongoDB 引擎是一个只读表引擎,允许从远程 [MongoDB](https://www.mongodb.com/) 集合中读取数据。 +MongoDB 引擎是只读表引擎,允许从远程 [MongoDB](https://www.mongodb.com/) 集合中读取数据。 -只支持 MongoDB 服务器 v3.6+。 +仅支持 MongoDB v3.6 以上版本。 [种子列表(`mongodb+srv`)](https://www.mongodb.com/docs/manual/reference/glossary/#std-term-seed-list) 目前不支持。 ## 创建表 {#creating-a-table} @@ -27,26 +28,22 @@ CREATE TABLE [IF NOT EXISTS] [db.]table_name **引擎参数** -- `host:port` — MongoDB 服务器地址。 - -- `database` — 远程数据库名称。 - -- `collection` — 远程集合名称。 - -- `user` — MongoDB 用户。 - -- `password` — 用户密码。 - -- `options` — MongoDB 连接字符串选项(可选参数)。 - -- `oid_columns` - 需要在 WHERE 子句中视为 `oid` 的列的以逗号分隔的列表。默认为 `_id`。 +| 参数 | 描述 | +|---------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `host:port` | MongoDB 服务器地址。 | +| `database` | 远程数据库名称。 | +| `collection` | 远程集合名称。 | +| `user` | MongoDB 用户。 | +| `password` | 用户密码。 | +| `options` | 可选。MongoDB 连接字符串 [选项](https://www.mongodb.com/docs/manual/reference/connection-string-options/#connection-options),格式为 URL 字符串。例如,`'authSource=admin&ssl=true'` | +| `oid_columns` | 需要在 WHERE 子句中被视为 `oid` 的列的以逗号分隔的列表。默认是 `_id`。 | :::tip -如果您使用的是 MongoDB Atlas 云服务,连接 URL 可以从 'Atlas SQL' 选项中获得。 -种子列表(`mongodb**+srv**`) 目前不支持,但将在未来版本中添加。 +如果您正在使用 MongoDB Atlas 云服务,连接 URL 可以从“Atlas SQL”选项中获取。 +种子列表(`mongodb**+srv**`) 目前不支持,但将在未来的版本中添加。 ::: -作为替代,您可以传递 URI: +或者,您可以传递 URI: ```sql ENGINE = MongoDB(uri, collection[, oid_columns]); @@ -54,33 +51,33 @@ ENGINE = MongoDB(uri, collection[, oid_columns]); **引擎参数** -- `uri` — MongoDB 服务器的连接 URI。 - -- `collection` — 远程集合名称。 - -- `oid_columns` - 需要在 WHERE 子句中视为 `oid` 的列的以逗号分隔的列表。默认为 `_id`。 +| 参数 | 描述 | +|---------------|-------------------------------------------------------------------------------------------------------------| +| `uri` | MongoDB 服务器的连接 URI。 | +| `collection` | 远程集合名称。 | +| `oid_columns` | 需要在 WHERE 子句中被视为 `oid` 的列的以逗号分隔的列表。默认是 `_id`。 | ## 类型映射 {#types-mappings} -| MongoDB | ClickHouse | -|-------------------------|-----------------------------------------------------------------------| -| bool, int32, int64 | *任何数字类型*, String | -| double | Float64, String | -| date | Date, Date32, DateTime, DateTime64, String | -| string | String | -| document | String(作为 JSON) | -| array | Array, String(作为 JSON) | -| oid | String | -| binary | 如果在列中则为 String,如果在数组或文档中则为 base64 编码字符串 | -| uuid (binary subtype 4) | UUID | -| *其他* | String | - -如果在 MongoDB 文档中未找到键(例如,列名不匹配),则将插入默认值或 `NULL`(如果该列是可空的)。 +| MongoDB | ClickHouse | +|-------------------------|----------------------------------------------------------------------| +| bool, int32, int64 | *任何数值类型(除非是 Decimal)*,Boolean,String | +| double | Float64,String | +| date | Date,Date32,DateTime,DateTime64,String | +| string | String,*格式正确的任意数值类型(除非是 Decimal)* | +| document | String(作为 JSON) | +| array | Array,String(作为 JSON) | +| oid | String | +| binary | 如果在列中,则为 String;如果在数组或文档中,则为 base64 编码字符串 | +| uuid (binary subtype 4) | UUID | +| *任何其他* | String | + +如果在 MongoDB 文档中找不到键(例如,列名不匹配),则将插入默认值或 `NULL`(如果该列是 Nullable)。 ### OID {#oid} -如果您希望将 `String` 视为 WHERE 子句中的 `oid`,只需将列的名称放在表引擎的最后一个参数中。 -当按 `_id` 列查询记录时,这可能是必要的,因为在 MongoDB 中 `_id` 默认具有 `oid` 类型。 +如果希望将 `String` 在 WHERE 子句中视为 `oid`,只需将列名放在表引擎的最后一个参数中。 +当通过 `_id` 列查询记录时,这可能是必要的,因为该列在 MongoDB 中默认具有 `oid` 类型。 如果表中的 `_id` 字段具有其他类型,例如 `uuid`,则需要指定空的 `oid_columns`,否则将使用此参数的默认值 `_id`。 ```javascript @@ -97,7 +94,7 @@ db.sample_oid.find(); ] ``` -默认情况下,只有 `_id` 被视为 `oid` 列。 +默认情况下,仅 `_id` 被视为 `oid` 列。 ```sql CREATE TABLE sample_oid @@ -110,7 +107,7 @@ SELECT count() FROM sample_oid WHERE _id = '67bf6cc44ebc466d33d42fb2'; --will ou SELECT count() FROM sample_oid WHERE another_oid_column = '67bf6cc40000000000ea41b1'; --will output 0 ``` -在这种情况下,输出将是 `0`,因为 ClickHouse 并不知道 `another_oid_column` 具有 `oid` 类型,因此我们来修复它: +在这种情况下,输出将是 `0`,因为 ClickHouse 不知道 `another_oid_column` 具有 `oid` 类型,因此让我们修复它: ```sql CREATE TABLE sample_oid @@ -133,35 +130,33 @@ SELECT count() FROM sample_oid WHERE another_oid_column = '67bf6cc40000000000ea4 ## 支持的子句 {#supported-clauses} 仅支持具有简单表达式的查询(例如,`WHERE field = ORDER BY field2 LIMIT `)。 -此类表达式将被转换为 MongoDB 查询语言,并在服务器端执行。 -您可以使用 [mongodb_throw_on_unsupported_query](../../../operations/settings/settings.md#mongodb_throw_on_unsupported_query) 禁用所有这些限制。 -在这种情况下,ClickHouse 会尽力转换查询,但这可能会导致全表扫描和在 ClickHouse 端的处理。 +此类表达式将转换为 MongoDB 查询语言并在服务器端执行。 +您可以通过使用 [mongodb_throw_on_unsupported_query](../../../operations/settings/settings.md#mongodb_throw_on_unsupported_query) 来禁用所有这些限制。 +在这种情况下,ClickHouse 尝试在尽可能的情况下转换查询,但这可能导致全表扫描和 ClickHouse 端的处理。 :::note -明确设置文字的类型总是更好,因为 Mongo 要求严格的类型过滤。\ -例如,您想按 `Date` 进行过滤: +最好明确设置文字的类型,因为 Mongo 需要严格的类型过滤。\ +例如,您希望按 `Date` 进行过滤: ```sql SELECT * FROM mongo_table WHERE date = '2024-01-01' ``` -这将不起作用,因为 Mongo 不会将字符串转换为 `Date`,因此您需要手动转换: +这将不起作用,因为 Mongo 不会将字符串转换为 `Date`,因此您需要手动进行转换: ```sql SELECT * FROM mongo_table WHERE date = '2024-01-01'::Date OR date = toDate('2024-01-01') ``` -这适用于 `Date`,`Date32`,`DateTime`,`Bool`,`UUID`。 +这适用于 `Date`、`Date32`、`DateTime`、`Bool`、`UUID`。 ::: - ## 使用示例 {#usage-example} +假设 MongoDB 已加载 [sample_mflix](https://www.mongodb.com/docs/atlas/sample-data/sample-mflix) 数据集 -假设 MongoDB 中已加载 [sample_mflix](https://www.mongodb.com/docs/atlas/sample-data/sample-mflix) 数据集 - -在 ClickHouse 中创建一个表,以允许从 MongoDB 集合读取数据: +在 ClickHouse 中创建一个表,允许从 MongoDB 集合读取数据: ```sql CREATE TABLE sample_mflix_table @@ -174,7 +169,7 @@ CREATE TABLE sample_mflix_table writers Array(String), released Date, imdb String, - year String, + year String ) ENGINE = MongoDB('mongodb://:@atlas-sql-6634be87cefd3876070caf96-98lxs.a.query.mongodb.net/sample_mflix?ssl=true&authSource=admin', 'movies'); ``` @@ -222,9 +217,9 @@ released: 1989-11-22 ```sql -- Find top 3 movies based on Cormac McCarthy's books -SELECT title, toFloat32(JSONExtractString(imdb, 'rating')) as rating +SELECT title, toFloat32(JSONExtractString(imdb, 'rating')) AS rating FROM sample_mflix_table -WHERE arrayExists(x -> x like 'Cormac McCarthy%', writers) +WHERE arrayExists(x -> x LIKE 'Cormac McCarthy%', writers) ORDER BY rating DESC LIMIT 3; ``` @@ -238,6 +233,6 @@ LIMIT 3; ``` ## 故障排除 {#troubleshooting} -您可以在 DEBUG 级别的日志中查看生成的 MongoDB 查询。 +您可以在 DEBUG 级别日志中查看生成的 MongoDB 查询。 实现细节可以在 [mongocxx](https://github.com/mongodb/mongo-cxx-driver) 和 [mongoc](https://github.com/mongodb/mongo-c-driver) 文档中找到。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/mongodb.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/mongodb.md.hash index 3da0d187e16..aa72bb59e09 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/mongodb.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/mongodb.md.hash @@ -1 +1 @@ -02651f019d132c30 +b32bd1ca1eb956f6 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/mysql.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/mysql.md index d0bbb91a2f3..1cdb6c2b8f5 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/mysql.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/mysql.md @@ -4,12 +4,13 @@ 'sidebar_position': 138 'slug': '/engines/table-engines/integrations/mysql' 'title': 'MySQL 引擎允许您对存储在远程 MySQL 服务器上的数据执行 `SELECT` 和 `INSERT` 查询。' +'doc_type': 'reference' --- # MySQL 表引擎 -MySQL 引擎允许您在存储于远程 MySQL 服务器上的数据上执行 `SELECT` 和 `INSERT` 查询。 +MySQL 引擎允许您对存储在远程 MySQL 服务器上的数据执行 `SELECT` 和 `INSERT` 查询。 ## 创建表 {#creating-a-table} @@ -30,13 +31,13 @@ SETTINGS ; ``` -请查看 [CREATE TABLE](/sql-reference/statements/create/table) 查询的详细描述。 +查看 [CREATE TABLE](/sql-reference/statements/create/table) 查询的详细描述。 表结构可以与原始 MySQL 表结构不同: -- 列名应与原始 MySQL 表中的相同,但您可以只使用其中的一些列,并且可以按任何顺序。 -- 列类型可能与原始 MySQL 表中的不同。ClickHouse 会尝试将值 [cast](../../../engines/database-engines/mysql.md#data_types-support) 为 ClickHouse 数据类型。 -- [external_table_functions_use_nulls](/operations/settings/settings#external_table_functions_use_nulls) 设置定义了如何处理 Nullable 列。默认值:1。如果为 0,则表函数不会生成 Nullable 列,并在插入时使用默认值代替 NULL。这也适用于数组中的 NULL 值。 +- 列名应与原始 MySQL 表中的相同,但您可以仅使用这些列中的一些,并且顺序可以任意。 +- 列类型可以与原始 MySQL 表中的不同。ClickHouse 会尝试将值 [cast](../../../engines/database-engines/mysql.md#data_types-support) 到 ClickHouse 数据类型。 +- [external_table_functions_use_nulls](/operations/settings/settings#external_table_functions_use_nulls) 设置定义了如何处理 Nullable 列。默认值:1。如果为 0,则表函数不生成 Nullable 列,而是插入默认值而不是 NULL。这也适用于数组中的 NULL 值。 **引擎参数** @@ -45,18 +46,18 @@ SETTINGS - `table` — 远程表名称。 - `user` — MySQL 用户。 - `password` — 用户密码。 -- `replace_query` — 将 `INSERT INTO` 查询转换为 `REPLACE INTO` 的标志。如果 `replace_query=1`,则查询会被替换。 +- `replace_query` — 将 `INSERT INTO` 查询转换为 `REPLACE INTO` 的标志。如果 `replace_query= 1`,则查询会被替换。 - `on_duplicate_clause` — 添加到 `INSERT` 查询中的 `ON DUPLICATE KEY on_duplicate_clause` 表达式。 - 示例:`INSERT INTO t (c1,c2) VALUES ('a', 2) ON DUPLICATE KEY UPDATE c2 = c2 + 1`,其中 `on_duplicate_clause` 为 `UPDATE c2 = c2 + 1`。请参阅 [MySQL 文档](https://dev.mysql.com/doc/refman/8.0/en/insert-on-duplicate.html) 以查找可以与 `ON DUPLICATE KEY` 子句一起使用的 `on_duplicate_clause`。 - 要指定 `on_duplicate_clause`,您需要将 `0` 传递给 `replace_query` 参数。如果同时传递 `replace_query = 1` 和 `on_duplicate_clause`,ClickHouse 将生成异常。 + 示例:`INSERT INTO t (c1,c2) VALUES ('a', 2) ON DUPLICATE KEY UPDATE c2 = c2 + 1`,其中 `on_duplicate_clause` 为 `UPDATE c2 = c2 + 1`。请参阅 [MySQL 文档](https://dev.mysql.com/doc/refman/8.0/en/insert-on-duplicate.html),了解您可以与 `ON DUPLICATE KEY` 子句一起使用的 `on_duplicate_clause`。 + 要指定 `on_duplicate_clause`,您需要将 `0` 传递给 `replace_query` 参数。如果同时传递 `replace_query = 1` 和 `on_duplicate_clause`,ClickHouse 会产生异常。 -参数也可以通过 [命名集合](/operations/named-collections.md) 传递。在这种情况下,`host` 和 `port` 应该单独指定。这种方法推荐用于生产环境。 +参数也可以使用 [命名集合](/operations/named-collections.md) 传递。在这种情况下,`host` 和 `port` 应分开指定。这种方法推荐用于生产环境。 简单的 `WHERE` 子句,例如 `=, !=, >, >=, <, <=` 在 MySQL 服务器上执行。 -其余条件以及 `LIMIT` 抽样约束在查询到 MySQL 完成后,仅在 ClickHouse 中执行。 +其余条件和 `LIMIT` 采样约束则在查询完成后仅在 ClickHouse 中执行。 -支持多个副本,必须通过 `|` 列出。例如: +支持多个副本,必须使用 `|` 列出。例如: ```sql CREATE TABLE test_replicas (id UInt32, name String, age UInt32, money UInt32) ENGINE = MySQL(`mysql{2|3|4}:3306`, 'clickhouse', 'test_replicas', 'root', 'clickhouse'); @@ -98,7 +99,7 @@ CREATE TABLE mysql_table ENGINE = MySQL('localhost:3306', 'test', 'test', 'bayonet', '123') ``` -或者使用 [命名集合](/operations/named-collections.md): +或使用 [命名集合](/operations/named-collections.md): ```sql CREATE NAMED COLLECTION creds AS @@ -115,7 +116,7 @@ CREATE TABLE mysql_table ENGINE = MySQL(creds, table='test') ``` -从 MySQL 表中检索数据: +从 MySQL 表检索数据: ```sql SELECT * FROM mysql_table @@ -129,33 +130,33 @@ SELECT * FROM mysql_table ## 设置 {#mysql-settings} -默认设置效率不高,因为它们甚至不重用连接。这些设置可以让您提高每秒由服务器运行的查询数。 +默认设置效率不高,因为它们甚至不重用连接。这些设置允许您提高服务器每秒运行的查询数量。 -### connection_auto_close {#connection-auto-close} +### `connection_auto_close` {#connection-auto-close} 允许在查询执行后自动关闭连接,即禁用连接重用。 可能的值: -- 1 — 允许自动关闭连接,因此禁用连接重用。 -- 0 — 不允许自动关闭连接,因此启用连接重用。 +- 1 — 允许自动关闭连接,因此连接重用被禁用 +- 0 — 不允许自动关闭连接,因此连接重用启用 默认值:`1`。 -### connection_max_tries {#connection-max-tries} +### `connection_max_tries` {#connection-max-tries} -设置池的重试次数(带故障转移)。 +设置失败重试池的重试次数。 可能的值: - 正整数。 -- 0 — 不进行池的重试(带故障转移)。 +- 0 — 不对失败重试池进行重试。 默认值:`3`。 -### connection_pool_size {#connection-pool-size} +### `connection_pool_size` {#connection-pool-size} -连接池的大小(如果所有连接都在使用中,查询将等待直到某些连接被释放)。 +连接池的大小(如果所有连接都在使用中,则查询将等待直到某个连接被释放)。 可能的值: @@ -163,9 +164,9 @@ SELECT * FROM mysql_table 默认值:`16`。 -### connection_wait_timeout {#connection-wait-timeout} +### `connection_wait_timeout` {#connection-wait-timeout} -等待空闲连接的超时(以秒为单位)(如果已经有 connection_pool_size 个活动连接),0 - 不等待。 +等待空闲连接的超时(以秒为单位)(如果当前有连接池大小的活动连接),0 - 不等待。 可能的值: @@ -173,7 +174,7 @@ SELECT * FROM mysql_table 默认值:`5`。 -### connect_timeout {#connect-timeout} +### `connect_timeout` {#connect-timeout} 连接超时(以秒为单位)。 @@ -183,9 +184,9 @@ SELECT * FROM mysql_table 默认值:`10`。 -### read_write_timeout {#read-write-timeout} +### `read_write_timeout` {#read-write-timeout} -读/写超时(以秒为单位)。 +读写超时(以秒为单位)。 可能的值: @@ -193,7 +194,7 @@ SELECT * FROM mysql_table 默认值:`300`。 -## 参见 {#see-also} +## 另请参阅 {#see-also} - [MySQL 表函数](../../../sql-reference/table-functions/mysql.md) - [使用 MySQL 作为字典源](/sql-reference/dictionaries#mysql) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/mysql.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/mysql.md.hash index 33785290004..7e5e957194a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/mysql.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/mysql.md.hash @@ -1 +1 @@ -d66c1c7916203ea1 +5a491bdec6a806d7 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/nats.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/nats.md index abd545b83cf..f9e2facd348 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/nats.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/nats.md @@ -1,9 +1,10 @@ --- -'description': '该引擎允许将 ClickHouse 与 NATS 集成,以发布或订阅消息主题,并处理新消息以便它们变得可用。' +'description': '该引擎允许将 ClickHouse 与 NATS 集成,以发布或订阅消息主题,并在新消息可用时处理它们。' 'sidebar_label': 'NATS' 'sidebar_position': 140 'slug': '/engines/table-engines/integrations/nats' 'title': 'NATS 引擎' +'doc_type': 'guide' --- @@ -14,7 +15,7 @@ `NATS` 让您可以: - 发布或订阅消息主题。 -- 处理新消息,当它们可用时。 +- 处理新消息以便于使用。 ## 创建表 {#creating-a-table} @@ -50,39 +51,41 @@ CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] 必需参数: - `nats_url` – 主机:端口(例如,`localhost:5672`)。 -- `nats_subjects` – NATS 表订阅/发布的主题列表。支持通配符主题,如 `foo.*.bar` 或 `baz.>`。 +- `nats_subjects` – NATS 表的主题列表,以进行订阅/发布。支持通配符主题,如 `foo.*.bar` 或 `baz.>`。 - `nats_format` – 消息格式。使用与 SQL `FORMAT` 函数相同的表示法,例如 `JSONEachRow`。有关更多信息,请参见 [Formats](../../../interfaces/formats.md) 部分。 可选参数: -- `nats_schema` – 如果格式需要架构定义,必须使用的参数。例如,[Cap'n Proto](https://capnproto.org/) 需要架构文件的路径和根 `schema.capnp:Message` 对象的名称。 -- `nats_num_consumers` – 每个表的消费者数量。默认值: `1`。如果单个消费者的吞吐量不足,请指定更多消费者。 -- `nats_queue_group` – NATS 订阅者的队列组名称。默认是表名。 -- `nats_max_reconnect` – 已弃用并且没有效果,重连始终以 nats_reconnect_wait 超时永久执行。 -- `nats_reconnect_wait` – 每次重连尝试之间的等待时间(毫秒)。默认值: `5000`。 -- `nats_server_list` - 连接的服务器列表。可以指定以连接到 NATS 集群。 -- `nats_skip_broken_messages` - NATS 消息解析器对每个块中的架构不兼容消息的容忍度。默认值: `0`。如果 `nats_skip_broken_messages = N`,则引擎会跳过 *N* 个无法解析的 NATS 消息(消息等于一行数据)。 -- `nats_max_block_size` - 从 NATS 刷新数据时由轮询收集的行数。默认值: [max_insert_block_size](../../../operations/settings/settings.md#max_insert_block_size)。 -- `nats_flush_interval_ms` - 刷新从 NATS 读取的数据的超时。默认值: [stream_flush_interval_ms](/operations/settings/settings#stream_flush_interval_ms)。 +- `nats_schema` – 如果格式需要架构定义,则必须使用的参数。例如,[Cap'n Proto](https://capnproto.org/) 需要架构文件的路径和根 `schema.capnp:Message` 对象的名称。 +- `nats_stream` – NATS JetStream 的流名称。 +- `nats_consumer` – NATS JetStream 的持久消费者名称。 +- `nats_num_consumers` – 每个表的消费者数量。默认值:`1`。如果单个消费者的吞吐量不足以仅满足 NATS 核心,则应指定更多消费者。 +- `nats_queue_group` – NATS 订阅者的队列组名称。默认值为表名。 +- `nats_max_reconnect` – 已弃用且不再有任何效果,重连将在 nats_reconnect_wait 超时下永久执行。 +- `nats_reconnect_wait` – 重新连接尝试之间的等待时间(以毫秒为单位)。默认值:`5000`。 +- `nats_server_list` - 连接的服务器列表。可指定以连接到 NATS 集群。 +- `nats_skip_broken_messages` - 每个区块 NATS 消息解析器对于架构不兼容的消息的容忍度。默认值:`0`。如果 `nats_skip_broken_messages = N`,则引擎将跳过无法解析的 *N* 个 NATS 消息(每条消息等于一行数据)。 +- `nats_max_block_size` - 从 NATS 刷新数据时通过轮询收集的行数。默认值:[max_insert_block_size](../../../operations/settings/settings.md#max_insert_block_size)。 +- `nats_flush_interval_ms` - 刷新从 NATS 读取的数据的超时。默认值:[stream_flush_interval_ms](/operations/settings/settings#stream_flush_interval_ms)。 - `nats_username` - NATS 用户名。 - `nats_password` - NATS 密码。 -- `nats_token` - NATS 认证令牌。 +- `nats_token` - NATS 身份验证令牌。 - `nats_credential_file` - NATS 凭证文件的路径。 -- `nats_startup_connect_tries` - 启动时的连接尝试次数。默认值: `5`。 -- `nats_max_rows_per_message` — 一条 NATS 消息中写入的最大行数(适用于基于行的格式)。默认值: `1`。 -- `nats_handle_error_mode` — 如何处理 NATS 引擎的错误。可能的值:默认(如果我们无法解析消息,将抛出异常),流(异常消息和原始消息将保存在虚拟列 `_error` 和 `_raw_message` 中)。 +- `nats_startup_connect_tries` - 启动时的连接尝试次数。默认值:`5`。 +- `nats_max_rows_per_message` — 一条 NATS 消息中写入的最大行数(适用于基于行的格式),默认值:`1`。 +- `nats_handle_error_mode` — 如何处理 NATS 引擎的错误。可能的值:默认(如果解析消息失败,将抛出异常),流(异常消息和原始消息将保存在虚拟列 `_error` 和 `_raw_message` 中)。 SSL 连接: -要进行安全连接,请使用 `nats_secure = 1`。 -所使用的库的默认行为是不检查创建的 TLS 连接是否足够安全。证书是否过期、自签名、缺失或无效:都将允许连接。可能会在未来实现对证书的更严格检查。 +要建立安全连接,请使用 `nats_secure = 1`。 +所使用库的默认行为是不检查建立的 TLS 连接是否足够安全。无论证书是否过期、自签名、缺失或无效,连接都将被允许。未来可能会实现更严格的证书检查。 写入 NATS 表: -如果表仅从一个主题读取,则任何插入都将发布到同一主题。 -但是,如果表从多个主题读取,我们需要指定要发布到的主题。 -因此,每当插入到具有多个主题的表中时,都需要设置 `stream_like_engine_insert_queue`。 -您可以从表读取的主题中选择一个,并将数据发布到那里。例如: +如果表仅从一个主题读取,则任何插入都会发布到同一主题。 +但是,如果表来自多个主题,则需要指定要发布到哪个主题。 +因此,在将数据插入包含多个主题的表时,需要设置 `stream_like_engine_insert_queue`。 +您可以选择表读取的一个主题并将数据发布到该主题。例如: ```sql CREATE TABLE queue ( @@ -98,7 +101,7 @@ SETTINGS stream_like_engine_insert_queue = 'subject2' VALUES (1, 1); ``` -还可以添加格式设置以及与 nats 相关的设置。 +同时,可以与与 NATS 相关的设置一起添加格式设置。 示例: @@ -114,7 +117,7 @@ CREATE TABLE queue ( date_time_input_format = 'best_effort'; ``` -NATS 服务器配置可以使用 ClickHouse 配置文件添加。 +可以使用 ClickHouse 配置文件添加 NATS 服务器配置。 更具体地说,您可以为 NATS 引擎添加 Redis 密码: ```xml @@ -127,14 +130,14 @@ NATS 服务器配置可以使用 ClickHouse 配置文件添加。 ## 描述 {#description} -`SELECT` 对于读取消息不是特别有用(除了调试),因为每条消息只能读取一次。使用 [物化视图](../../../sql-reference/statements/create/view.md) 创建实时线程更为实用。为此: +`SELECT` 对于读取消息(除了调试)并不是特别有用,因为每条消息只能读取一次。使用 [物化视图](../../../sql-reference/statements/create/view.md) 创建实时线程更为实用。为此: -1. 使用该引擎创建一个 NATS 消费者,并将其视为数据流。 -2. 创建一个具有所需结构的表。 -3. 创建一个将引擎的数据转换并放入先前创建的表中的物化视图。 +1. 使用引擎创建 NATS 消费者,并将其视为数据流。 +2. 创建具有所需结构的表。 +3. 创建一个将数据从引擎转换并放入先前创建的表中的物化视图。 -当 `MATERIALIZED VIEW` 加入引擎时,它开始在后台收集数据。这使您能够不断接收来自 NATS 的消息,并使用 `SELECT` 将其转换为所需格式。 -一个 NATS 表可以拥有任意数量的物化视图,它们不是直接从表中读取数据,而是以块的形式接收新记录,这样您可以将数据写入多个具有不同细节级别的表(有聚合和没有聚合)。 +当 `MATERIALIZED VIEW` 连接到引擎时,它开始在后台收集数据。这使您能够不断从 NATS 接收消息,并使用 `SELECT` 将其转换为所需格式。 +一个 NATS 表可以有任意多个物化视图,这些视图不会直接从表中读取数据,而是接收新记录(以块形式),这样您可以将数据写入多个具有不同细节级别的表(无论是分组 - 聚合还是不聚合)。 示例: @@ -164,24 +167,23 @@ DETACH TABLE consumer; ATTACH TABLE consumer; ``` -如果您想通过使用 `ALTER` 更改目标表,建议禁用物化视图以避免目标表与视图数据之间的不一致。 +如果您想通过使用 `ALTER` 更改目标表,我们建议禁用物化视图,以避免目标表和来自视图的数据之间的不一致。 ## 虚拟列 {#virtual-columns} - `_subject` - NATS 消息主题。数据类型:`String`。 -如果 `nats_handle_error_mode='stream'`,则还有附加的虚拟列: +当 `nats_handle_error_mode='stream'` 时的附加虚拟列: - `_raw_message` - 无法成功解析的原始消息。数据类型:`Nullable(String)`。 -- `_error` - 解析失败时发生的异常消息。数据类型:`Nullable(String)`。 - -注意:在解析期间发生异常时,`_raw_message` 和 `_error` 虚拟列才会被填充,当消息成功解析时,它们始终为 `NULL`。 +- `_error` - 在解析失败时发生的异常消息。数据类型:`Nullable(String)`。 +注意:当消息成功解析时,`_raw_message` 和 `_error` 虚拟列始终为 `NULL`,仅在解析过程中出现异常时填写。 ## 数据格式支持 {#data-formats-support} -NATS 引擎支持 ClickHouse 中支持的所有 [格式](../../../interfaces/formats.md)。 -一条 NATS 消息中行数的数量取决于格式是基于行的还是基于块的: +NATS 引擎支持 ClickHouse 支持的所有 [格式](../../../interfaces/formats.md)。 +一条 NATS 消息中的行数取决于格式是基于行还是基于块: -- 对于基于行的格式,可以通过设置 `nats_max_rows_per_message` 来控制一条 NATS 消息中的行数。 -- 对于基于块的格式,我们不能将块拆分为更小的部分,但可以通过通用设置 [max_block_size](/operations/settings/settings#max_block_size) 控制单个块中的行数。 +- 对于基于行的格式,一条 NATS 消息中的行数可以通过设置 `nats_max_rows_per_message` 来控制。 +- 对于基于块的格式,我们无法将块分割为更小的部分,但可以通过通用设置 [max_block_size](/operations/settings/settings#max_block_size) 控制每个块中的行数。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/nats.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/nats.md.hash index ffe4f8b0a0f..d7b6874a51a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/nats.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/nats.md.hash @@ -1 +1 @@ -86108ebeea06db77 +571dfde8c7c8bcf9 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/odbc.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/odbc.md index f04a186b70f..725cec4571d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/odbc.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/odbc.md @@ -4,6 +4,7 @@ 'sidebar_position': 150 'slug': '/engines/table-engines/integrations/odbc' 'title': 'ODBC' +'doc_type': 'reference' --- import CloudNotSupportedBadge from '@theme/badges/CloudNotSupportedBadge'; @@ -15,9 +16,9 @@ import CloudNotSupportedBadge from '@theme/badges/CloudNotSupportedBadge'; 允许 ClickHouse 通过 [ODBC](https://en.wikipedia.org/wiki/Open_Database_Connectivity) 连接到外部数据库。 -为了安全地实现 ODBC 连接,ClickHouse 使用一个单独的程序 `clickhouse-odbc-bridge`。如果 ODBC 驱动程序是直接从 `clickhouse-server` 加载的,驱动程序问题可能会导致 ClickHouse 服务器崩溃。ClickHouse 会在需要时自动启动 `clickhouse-odbc-bridge`。ODBC 桥接程序与 `clickhouse-server` 在同一个软件包中安装。 +为了安全地实现 ODBC 连接,ClickHouse 使用一个单独的程序 `clickhouse-odbc-bridge`。如果 ODBC 驱动程序直接从 `clickhouse-server` 加载,驱动程序的问题可能会导致 ClickHouse 服务器崩溃。ClickHouse 在需要时自动启动 `clickhouse-odbc-bridge`。ODBC 桥接程序与 `clickhouse-server` 安装在同一个包中。 -此引擎支持 [Nullable](../../../sql-reference/data-types/nullable.md) 数据类型。 +该引擎支持 [Nullable](../../../sql-reference/data-types/nullable.md) 数据类型。 ## 创建表 {#creating-a-table} @@ -28,32 +29,34 @@ CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] name2 [type2], ... ) -ENGINE = ODBC(connection_settings, external_database, external_table) +ENGINE = ODBC(datasource, external_database, external_table) ``` -查看 [CREATE TABLE](/sql-reference/statements/create/table) 查询的详细描述。 +请参阅 [CREATE TABLE](/sql-reference/statements/create/table) 查询的详细描述。 -表结构可以与源表结构不同: +表结构可能与源表结构不同: -- 列名应与源表中的列名相同,但您可以仅使用这些列中的一部分,并且可以按任何顺序排列。 -- 列类型可以与源表中的类型不同。ClickHouse 会尝试将值 [cast](/sql-reference/functions/type-conversion-functions#cast) 为 ClickHouse 数据类型。 -- [external_table_functions_use_nulls](/operations/settings/settings#external_table_functions_use_nulls) 设置定义了如何处理 Nullable 列。默认值:1。如果为 0,表函数不创建 Nullable 列,而是插入默认值而不是 null。这同样适用于数组中的 NULL 值。 +- 列名应与源表中的相同,但可以只使用部分列,并可以随意排列。 +- 列类型可能与源表中的不同。ClickHouse 尝试将值 [cast](/sql-reference/functions/type-conversion-functions#cast) 为 ClickHouse 数据类型。 +- [external_table_functions_use_nulls](/operations/settings/settings#external_table_functions_use_nulls) 设置定义如何处理 Nullable 列。默认值:1。如果为 0,表函数不会创建 Nullable 列,而是插入默认值而非 null。这同样适用于数组中的 NULL 值。 **引擎参数** -- `connection_settings` — `odbc.ini` 文件中连接设置的节名称。 -- `external_database` — 外部 DBMS 中的数据库名称。 -- `external_table` — `external_database` 中的表名称。 +- `datasource` — `odbc.ini` 文件中连接设置的节名称。 +- `external_database` — 外部 DBMS 中数据库的名称。 +- `external_table` — `external_database` 中表的名称。 + +这些参数也可以通过 [命名集合](operations/named-collections.md) 传递。 ## 使用示例 {#usage-example} **通过 ODBC 从本地 MySQL 安装中检索数据** -此示例已在 Ubuntu Linux 18.04 和 MySQL 服务器 5.7 中检查。 +此示例适用于 Ubuntu Linux 18.04 和 MySQL 服务器 5.7。 确保已安装 unixODBC 和 MySQL Connector。 -默认情况下(如果是通过软件包安装),ClickHouse 作为用户 `clickhouse` 启动。因此,您需要在 MySQL 服务器中创建并配置此用户。 +默认情况下(如果是从包安装),ClickHouse 以用户 `clickhouse` 启动。因此,您需要在 MySQL 服务器中创建并配置此用户。 ```bash $ sudo mysql @@ -113,7 +116,7 @@ mysql> select * from test.test; 1 row in set (0,00 sec) ``` -ClickHouse 中的表,从 MySQL 表中检索数据: +在 ClickHouse 中,从 MySQL 表中检索数据的表: ```sql CREATE TABLE odbc_t diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/odbc.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/odbc.md.hash index 73fcda8302b..73fcc77b944 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/odbc.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/odbc.md.hash @@ -1 +1 @@ -8fce48b64a9da0f4 +323d4a551dfe6ff6 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/postgresql.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/postgresql.md index a0225d0e8af..e339910a8cd 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/postgresql.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/postgresql.md @@ -4,16 +4,17 @@ 'sidebar_position': 160 'slug': '/engines/table-engines/integrations/postgresql' 'title': 'PostgreSQL 表引擎' +'doc_type': 'guide' --- The PostgreSQL engine allows `SELECT` and `INSERT` queries on data stored on a remote PostgreSQL server. :::note -当前仅支持 PostgreSQL 版本 12 及以上。 +当前,仅支持 PostgreSQL 版本 12 及以上。 ::: -:::note 通过 PeerDB 复制或迁移 Postgres 数据 -> 除了 Postgres 表引擎,您还可以使用 [PeerDB](https://docs.peerdb.io/introduction) 来设置从 Postgres 到 ClickHouse 的连续数据管道。PeerDB 是一个专门设计用于通过变更数据捕获 (CDC) 将数据从 Postgres 复制到 ClickHouse 的工具。 +:::note +建议 ClickHouse Cloud 用户使用 [ClickPipes](/integrations/clickpipes) 将 Postgres 数据流式传输到 ClickHouse。这原生支持高性能插入,同时确保关注点分离,并能够独立扩展数据摄取和集群资源。 ::: ## 创建表 {#creating-a-table} @@ -27,13 +28,13 @@ CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] ) ENGINE = PostgreSQL({host:port, database, table, user, password[, schema, [, on_conflict]] | named_collection[, option=value [,..]]}) ``` -请查看 [CREATE TABLE](/sql-reference/statements/create/table) 查询的详细描述。 +查看 [CREATE TABLE](/sql-reference/statements/create/table) 查询的详细描述。 表结构可以与原始 PostgreSQL 表结构不同: -- 列名应与原始 PostgreSQL 表中的相同,但您可以仅使用其中的一部分列,并可以以任意顺序排列。 -- 列类型可以与原始 PostgreSQL 表中的不同。ClickHouse 会尝试 [转换](../../../engines/database-engines/postgresql.md#data_types-support) 值为 ClickHouse 数据类型。 -- [external_table_functions_use_nulls](/operations/settings/settings#external_table_functions_use_nulls) 设置定义了如何处理 Nullable 列。默认值:1。如果为 0,表函数将不创建 Nullable 列,并在插入时使用默认值替代 null。这同样适用于数组中的 NULL 值。 +- 列名称应与原始 PostgreSQL 表中的名称相同,但您可以只使用其中的一些列,并按任意顺序排列。 +- 列类型可能与原始 PostgreSQL 表中的类型不同。ClickHouse 会尝试将值转换为 ClickHouse 数据类型,见 [cast](../../../engines/database-engines/postgresql.md#data_types-support)。 +- [external_table_functions_use_nulls](/operations/settings/settings#external_table_functions_use_nulls) 设置定义了如何处理 Nullable 列。默认值:1。如果为 0,则表函数不会创建 Nullable 列,并插入默认值而不是空值。这同样适用于数组内部的 NULL 值。 **引擎参数** @@ -42,10 +43,10 @@ CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] - `table` — 远程表名称。 - `user` — PostgreSQL 用户。 - `password` — 用户密码。 -- `schema` — 非默认表模式。可选。 -- `on_conflict` — 冲突解决策略。例如:`ON CONFLICT DO NOTHING`。可选。注意:添加此选项会降低插入效率。 +- `schema` — 非默认表架构。可选。 +- `on_conflict` — 冲突解决策略。例如:`ON CONFLICT DO NOTHING`。可选。注意:添加此选项会使插入效率降低。 -建议在生产环境中使用 [命名集合](/operations/named-collections.md)(自版本 21.11 可用)。以下是示例: +建议在生产环境中使用 [命名集合](/operations/named-collections.md)(自版本 21.11 起可用)。以下是一个示例: ```xml @@ -66,21 +67,21 @@ SELECT * FROM postgresql(postgres_creds, table='table1'); ## 实现细节 {#implementation-details} -PostgreSQL 端的 `SELECT` 查询作为 `COPY (SELECT ...) TO STDOUT` 在只读 PostgreSQL 事务中运行,每个 `SELECT` 查询后都会提交。 +在 PostgreSQL 端的 `SELECT` 查询作为 `COPY (SELECT ...) TO STDOUT` 在只读 PostgreSQL 事务内运行,并在每个 `SELECT` 查询后提交。 -简单的 `WHERE` 子句,例如 `=`, `!=`, `>`, `>=`, `<`, `<=`, 和 `IN` 在 PostgreSQL 服务器上执行。 +简单的 `WHERE` 子句,例如 `=`、`!=`、`>`、`>=`、`<`、`<=` 和 `IN` 在 PostgreSQL 服务器上执行。 -所有的连接、聚合、排序、`IN [ array ]` 条件和 `LIMIT` 抽样约束仅在对 PostgreSQL 的查询完成后在 ClickHouse 中执行。 +所有连接、聚合、排序、`IN [ array ]` 条件和 `LIMIT` 抽样限制仅在查询 PostgreSQL 完成后在 ClickHouse 中执行。 -PostgreSQL 端的 `INSERT` 查询作为 `COPY "table_name" (field1, field2, ... fieldN) FROM STDIN` 在 PostgreSQL 事务中运行,每个 `INSERT` 语句后都自动提交。 +在 PostgreSQL 端的 `INSERT` 查询作为 `COPY "table_name" (field1, field2, ... fieldN) FROM STDIN` 在 PostgreSQL 事务内运行,并在每个 `INSERT` 语句后自动提交。 -PostgreSQL 的 `Array` 类型转换为 ClickHouse 数组。 +PostgreSQL 的 `Array` 类型被转换为 ClickHouse 数组。 :::note -请小心 - 在 PostgreSQL 中,像 `type_name[]` 创建的数组数据,可能在同一列的不同表行中包含不同维数的多维数组。但在 ClickHouse 中,所有表行的同一列中仅允许具有相同维数的多维数组。 +要小心 - 在 PostgreSQL 中,创建为 `type_name[]` 的数组数据可以在同一列的不同表行中包含不同维度的多维数组。但在 ClickHouse 中,只允许在同一列的所有表行中具有相同维数的多维数组。 ::: -支持多个副本,副本必须用 `|` 分隔。例如: +支持多个副本,必须用 `|` 列出。例如: ```sql CREATE TABLE test_replicas (id UInt32, name String) ENGINE = PostgreSQL(`postgres{2|3|4}:5432`, 'clickhouse', 'test_replicas', 'postgres', 'mysecretpassword'); @@ -88,7 +89,7 @@ CREATE TABLE test_replicas (id UInt32, name String) ENGINE = PostgreSQL(`postgre 支持 PostgreSQL 字典源的副本优先级。映射中数字越大,优先级越低。最高优先级为 `0`。 -在以下示例中,副本 `example01-1` 的优先级最高: +在下面的示例中,副本 `example01-1` 拥有最高优先级: ```xml @@ -111,7 +112,7 @@ CREATE TABLE test_replicas (id UInt32, name String) ENGINE = PostgreSQL(`postgre ``` -## 用例示例 {#usage-example} +## 使用示例 {#usage-example} ### PostgreSQL 中的表 {#table-in-postgresql} @@ -136,9 +137,9 @@ postgresql> SELECT * FROM test; (1 row) ``` -### 在 ClickHouse 中创建表,并连接到上述创建的 PostgreSQL 表 {#creating-table-in-clickhouse-and-connecting-to--postgresql-table-created-above} +### 在 ClickHouse 中创建表,并连接到上面创建的 PostgreSQL 表 {#creating-table-in-clickhouse-and-connecting-to--postgresql-table-created-above} -此示例使用 [PostgreSQL 表引擎](/engines/table-engines/integrations/postgresql.md) 将 ClickHouse 表连接到 PostgreSQL 表,并使用 SELECT 和 INSERT 语句对 PostgreSQL 数据库进行操作: +此示例使用 [PostgreSQL 表引擎](/engines/table-engines/integrations/postgresql.md) 将 ClickHouse 表连接到 PostgreSQL 表,并使用 SELECT 和 INSERT 语句访问 PostgreSQL 数据库: ```sql CREATE TABLE default.postgresql_table @@ -150,9 +151,9 @@ CREATE TABLE default.postgresql_table ENGINE = PostgreSQL('localhost:5432', 'public', 'test', 'postgres_user', 'postgres_password'); ``` -### 从 PostgreSQL 表插入初始数据到 ClickHouse 表,使用 SELECT 查询 {#inserting-initial-data-from-postgresql-table-into-clickhouse-table-using-a-select-query} +### 使用 SELECT 查询将初始数据从 PostgreSQL 表插入 ClickHouse 表 {#inserting-initial-data-from-postgresql-table-into-clickhouse-table-using-a-select-query} -[postgresql 表函数](/sql-reference/table-functions/postgresql.md) 将数据从 PostgreSQL 复制到 ClickHouse,这通常用于提高在 ClickHouse 中进行查询或分析数据的性能,而不是在 PostgreSQL 中,也可以用于将数据从 PostgreSQL 迁移到 ClickHouse。由于我们将从 PostgreSQL 复制数据到 ClickHouse,因此在 ClickHouse 中使用 MergeTree 表引擎并称其为 postgresql_copy: +[postgresql 表函数](/sql-reference/table-functions/postgresql.md) 将数据从 PostgreSQL 复制到 ClickHouse,这通常用于通过在 ClickHouse 中查询或进行分析来提高数据的查询性能,而不是在 PostgreSQL 中使用,或者也可以用于将数据从 PostgreSQL 迁移到 ClickHouse。由于我们将从 PostgreSQL 向 ClickHouse 复制数据,我们将在 ClickHouse 中使用一个 MergeTree 表引擎并将其命名为 postgresql_copy: ```sql CREATE TABLE default.postgresql_copy @@ -170,17 +171,17 @@ INSERT INTO default.postgresql_copy SELECT * FROM postgresql('localhost:5432', 'public', 'test', 'postgres_user', 'postgres_password'); ``` -### 从 PostgreSQL 表插入增量数据到 ClickHouse 表 {#inserting-incremental-data-from-postgresql-table-into-clickhouse-table} +### 从 PostgreSQL 表向 ClickHouse 表插入增量数据 {#inserting-incremental-data-from-postgresql-table-into-clickhouse-table} -如果在初始插入后继续在 PostgreSQL 表和 ClickHouse 表之间进行同步,您可以在 ClickHouse 中使用 `WHERE` 子句仅插入基于时间戳或唯一序列 ID 添加到 PostgreSQL 的数据。 +如果在初始插入后需要在 PostgreSQL 表和 ClickHouse 表之间进行持续同步,可以在 ClickHouse 中使用 WHERE 子句仅插入根据时间戳或唯一序列 ID 添加到 PostgreSQL 的数据。 -这需要跟踪先前添加的最大 ID 或时间戳,例如: +这将需要跟踪之前添加的最大 ID 或时间戳,例如以下内容: ```sql SELECT max(`int_id`) AS maxIntID FROM default.postgresql_copy; ``` -然后插入 PostgreSQL 表中大于最大值的值 +然后插入来自 PostgreSQL 表大于最大值的值: ```sql INSERT INTO default.postgresql_copy @@ -188,7 +189,7 @@ SELECT * FROM postgresql('localhost:5432', 'public', 'test', 'postges_user', 'po WHERE int_id > maxIntID; ``` -### 从生成的 ClickHouse 表中选择数据 {#selecting-data-from-the-resulting-clickhouse-table} +### 从结果 ClickHouse 表中选择数据 {#selecting-data-from-the-resulting-clickhouse-table} ```sql SELECT * FROM postgresql_copy WHERE str IN ('test'); @@ -200,7 +201,7 @@ SELECT * FROM postgresql_copy WHERE str IN ('test'); └────────────────┴──────┴────────┘ ``` -### 使用非默认模式 {#using-non-default-schema} +### 使用非默认架构 {#using-non-default-schema} ```text postgres=# CREATE SCHEMA "nice.schema"; @@ -218,9 +219,9 @@ CREATE TABLE pg_table_schema_with_dots (a UInt32) **另请参见** - [postgresql 表函数](../../../sql-reference/table-functions/postgresql.md) -- [使用 PostgreSQL 作为字典源](/sql-reference/dictionaries#mysql) +- [将 PostgreSQL 用作字典源](/sql-reference/dictionaries#mysql) ## 相关内容 {#related-content} -- 博客: [ClickHouse 与 PostgreSQL - 数据天堂中的绝配 - 第 1 部分](https://clickhouse.com/blog/migrating-data-between-clickhouse-postgres) -- 博客: [ClickHouse 与 PostgreSQL - 数据天堂中的绝配 - 第 2 部分](https://clickhouse.com/blog/migrating-data-between-clickhouse-postgres-part-2) +- 博客: [ClickHouse 和 PostgreSQL - 数据天作之合 - 第 1 部分](https://clickhouse.com/blog/migrating-data-between-clickhouse-postgres) +- 博客: [ClickHouse 和 PostgreSQL - 数据天作之合 - 第 2 部分](https://clickhouse.com/blog/migrating-data-between-clickhouse-postgres-part-2) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/postgresql.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/postgresql.md.hash index 5b1b485c36f..beeefa2832e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/postgresql.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/postgresql.md.hash @@ -1 +1 @@ -7e25de1837234afc +419dd28626a87aba diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/rabbitmq.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/rabbitmq.md index 4d60783119a..e763ad86f71 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/rabbitmq.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/rabbitmq.md @@ -1,20 +1,21 @@ --- -'description': '这个引擎允许将 ClickHouse 与 RabbitMQ 集成。' +'description': '这个引擎允许将 ClickHouse 集成到 RabbitMQ 中。' 'sidebar_label': 'RabbitMQ' 'sidebar_position': 170 'slug': '/engines/table-engines/integrations/rabbitmq' 'title': 'RabbitMQ 引擎' +'doc_type': 'guide' --- # RabbitMQ 引擎 -该引擎允许将 ClickHouse 与 [RabbitMQ](https://www.rabbitmq.com) 进行集成。 +该引擎允许将 ClickHouse 与 [RabbitMQ](https://www.rabbitmq.com) 集成。 `RabbitMQ` 让您可以: - 发布或订阅数据流。 -- 在数据变得可用时处理流。 +- 处理可用的流。 ## 创建表 {#creating-a-table} @@ -55,39 +56,40 @@ CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] - `rabbitmq_host_port` – 主机:端口(例如,`localhost:5672`)。 - `rabbitmq_exchange_name` – RabbitMQ 交换名称。 -- `rabbitmq_format` – 消息格式。使用与 SQL `FORMAT` 函数相同的表示法,例如 `JSONEachRow`。有关更多信息,请参见 [Formats](../../../interfaces/formats.md) 部分。 +- `rabbitmq_format` – 消息格式。使用与 SQL `FORMAT` 函数相同的语法,例如 `JSONEachRow`。有关更多信息,请参见 [格式](../../../interfaces/formats.md) 部分。 可选参数: - `rabbitmq_exchange_type` – RabbitMQ 交换类型:`direct`、`fanout`、`topic`、`headers`、`consistent_hash`。默认值:`fanout`。 -- `rabbitmq_routing_key_list` – 路由关键字的逗号分隔列表。 -- `rabbitmq_schema` – 如果格式需要 schema 定义,则必须使用的参数。例如,[Cap'n Proto](https://capnproto.org/) 需要 schema 文件的路径和根对象 `schema.capnp:Message` 的名称。 -- `rabbitmq_num_consumers` – 每个表的消费者数量。如果一个消费者的吞吐量不足,请指定更多消费者。默认:`1` -- `rabbitmq_num_queues` – 队列的总数。增加此数字可以显著提高性能。默认:`1`。 -- `rabbitmq_queue_base` - 为队列名称指定提示。该设置的用例在下面描述。 -- `rabbitmq_deadletter_exchange` - 指定 [死信交换](https://www.rabbitmq.com/dlx.html) 的名称。您可以使用此交换名称创建另一个表,在消息重新发布到死信交换时收集消息。默认情况下未指定死信交换。 -- `rabbitmq_persistent` - 如果设置为 1 (true),则在插入查询交付模式将设为 2(将消息标记为“持久”)。默认:`0`。 -- `rabbitmq_skip_broken_messages` – RabbitMQ 消息解析器对每个块中与 schema 不兼容的消息的宽容度。如果 `rabbitmq_skip_broken_messages = N`,则引擎跳过 *N* 条无法解析的 RabbitMQ 消息(消息等于数据的一行)。默认:`0`。 -- `rabbitmq_max_block_size` - 收集的行数,直到从 RabbitMQ 刷新数据。默认值:[max_insert_block_size](../../../operations/settings/settings.md#max_insert_block_size)。 +- `rabbitmq_routing_key_list` – 逗号分隔的路由键列表。 +- `rabbitmq_schema` – 如果格式需要模式定义,则必须使用的参数。例如,[Cap'n Proto](https://capnproto.org/) 要求提供模式文件的路径和根 `schema.capnp:Message` 对象的名称。 +- `rabbitmq_num_consumers` – 每个表的消费者数量。如果一个消费者的吞吐量不足,请指定更多消费者。默认值:`1` +- `rabbitmq_num_queues` – 队列的总数。增加此数字可以显著提高性能。默认值:`1`。 +- `rabbitmq_queue_base` - 指定队列名称的提示。有关此设置的用例请参见下文。 +- `rabbitmq_deadletter_exchange` - 指定 [死信交换](https://www.rabbitmq.com/dlx.html) 的名称。您可以使用此交换名称创建另一个表并在消息重新发布到死信交换时收集消息。默认情况下,不指定死信交换。 +- `rabbitmq_persistent` - 如果设置为 1(真),则插入查询的传递模式将设置为 2(将消息标记为“持久”)。默认值:`0`。 +- `rabbitmq_skip_broken_messages` – RabbitMQ 消息解析器对每个块不兼容模式的消息的容忍度。如果 `rabbitmq_skip_broken_messages = N`,则引擎跳过 *N* 个无法解析的 RabbitMQ 消息(消息等于一行数据)。默认值:`0`。 +- `rabbitmq_max_block_size` - 在从 RabbitMQ 刷新数据之前收集的行数。默认值:[max_insert_block_size](../../../operations/settings/settings.md#max_insert_block_size)。 - `rabbitmq_flush_interval_ms` - 从 RabbitMQ 刷新数据的超时。默认值:[stream_flush_interval_ms](/operations/settings/settings#stream_flush_interval_ms)。 -- `rabbitmq_queue_settings_list` - 在创建队列时设置 RabbitMQ 设置。可用的设置有:`x-max-length`、`x-max-length-bytes`、`x-message-ttl`、`x-expires`、`x-priority`、`x-max-priority`、`x-overflow`、`x-dead-letter-exchange`、`x-queue-type`。`durable` 设置会自动为队列启用。 -- `rabbitmq_address` - 连接的地址。使用此设置或 `rabbitmq_host_port`。 -- `rabbitmq_vhost` - RabbitMQ vhost。默认:`'\'`。 -- `rabbitmq_queue_consume` - 使用用户定义的队列并不进行任何 RabbitMQ 设置:声明交换、队列、绑定。默认:`false`。 +- `rabbitmq_queue_settings_list` - 在创建队列时允许设置 RabbitMQ 设置。可用设置:`x-max-length`、`x-max-length-bytes`、`x-message-ttl`、`x-expires`、`x-priority`、`x-max-priority`、`x-overflow`、`x-dead-letter-exchange`、`x-queue-type`。队列的 `durable` 设置会自动启用。 +- `rabbitmq_address` - 连接地址。使用此设置或 `rabbitmq_host_port`。 +- `rabbitmq_vhost` - RabbitMQ vhost。默认值:`'\'`。 +- `rabbitmq_queue_consume` - 使用用户定义的队列而不进行任何 RabbitMQ 设置:声明交换、队列、绑定。默认值:`false`。 - `rabbitmq_username` - RabbitMQ 用户名。 - `rabbitmq_password` - RabbitMQ 密码。 -- `reject_unhandled_messages` - 在发生错误时拒绝消息(发送 RabbitMQ 否定确认)。如果在 `rabbitmq_queue_settings_list` 中定义了 `x-dead-letter-exchange`,则此设置会自动启用。 -- `rabbitmq_commit_on_select` - 当执行选择查询时提交消息。默认:`false`。 -- `rabbitmq_max_rows_per_message` — 每个 RabbitMQ 消息中写入的最大行数(适用于行格式)。默认:`1`。 -- `rabbitmq_empty_queue_backoff_start` — 如果 RabbitMQ 队列为空,则重新调度读取的开始退避点。 -- `rabbitmq_empty_queue_backoff_end` — 如果 RabbitMQ 队列为空,则重新调度读取的结束退避点。 -- `rabbitmq_handle_error_mode` — 如何处理 RabbitMQ 引擎的错误。可能的值:default(如果解析消息失败,将抛出异常),stream(异常消息和原始消息将保存在虚拟列 `_error` 和 `_raw_message` 中)。 +- `reject_unhandled_messages` - 在出现错误的情况下拒绝消息(发送 RabbitMQ 负确认)。如果在 `rabbitmq_queue_settings_list` 中定义了 `x-dead-letter-exchange`,则此设置会自动启用。 +- `rabbitmq_commit_on_select` - 在进行选择查询时提交消息。默认值:`false`。 +- `rabbitmq_max_rows_per_message` — 单个 RabbitMQ 消息中写入的最大行数(针对行式格式)。默认值:`1`。 +- `rabbitmq_empty_queue_backoff_start` — 在 RabbitMQ 队列为空时,重新调度读取的启动回退点。 +- `rabbitmq_empty_queue_backoff_end` — 在 RabbitMQ 队列为空时,重新调度读取的结束回退点。 +- `rabbitmq_handle_error_mode` — 如何处理 RabbitMQ 引擎的错误。可能的值:default(如果解析消息失败,异常将被抛出),stream(异常消息和原始消息将保存在虚拟列 `_error` 和 `_raw_message` 中),dead_letter_queue(与错误相关的数据将保存在 system.dead_letter_queue 中)。 -* [ ] SSL 连接: + * [ ] SSL 连接: -使用 `rabbitmq_secure = 1` 或在连接地址中使用 `amqps`:`rabbitmq_address = 'amqps://guest:guest@localhost/vhost'`。所使用库的默认行为是不检查创建的 TLS 连接是否安全。无论证书是否过期、自签名、缺失或无效:都将允许连接。可能会在未来实现对于证书的更严格检查。 +使用 `rabbitmq_secure = 1` 或在连接地址中使用 `amqps`:`rabbitmq_address = 'amqps://guest:guest@localhost/vhost'`。 +所使用库的默认行为是不检查创建的 TLS 连接是否足够安全。无论证书是否过期、自签名、丢失或无效:连接都被允许。可能在未来实现对证书的更严格检查。 -还可以将格式设置与与 RabbitMQ 相关的设置一起添加。 +还可以在与 RabbitMQ 相关的设置中添加格式设置。 示例: @@ -103,7 +105,7 @@ CREATE TABLE queue ( date_time_input_format = 'best_effort'; ``` -RabbitMQ 服务器配置应使用 ClickHouse 配置文件进行添加。 +RabbitMQ 服务器配置应使用 ClickHouse 配置文件添加。 必需配置: @@ -124,42 +126,42 @@ RabbitMQ 服务器配置应使用 ClickHouse 配置文件进行添加。 ## 描述 {#description} -`SELECT` 在读取消息时不是特别有用(除了调试),因为每条消息只能读取一次。使用 [物化视图](../../../sql-reference/statements/create/view.md) 创建实时线程更为实用。为此: +`SELECT` 在读取消息时并不是特别有用(除非是调试),因为每条消息只能读取一次。使用 [物化视图](../../../sql-reference/statements/create/view.md) 创建实时线程更为实际。要做到这一点: -1. 使用该引擎创建一个 RabbitMQ 消费者,并将其视为数据流。 -2. 创建一个具有所需结构的表。 -3. 创建一个将数据从引擎转换并放入之前创建的表的物化视图。 +1. 使用该引擎创建 RabbitMQ 消费者并将其视为数据流。 +2. 创建具有所需结构的表。 +3. 创建一个物化视图,将来自引擎的数据转换并放入先前创建的表中。 -当 `MATERIALIZED VIEW` 加入引擎时,它会在后台开始收集数据。这使您能够不断从 RabbitMQ 接收消息并使用 `SELECT` 将其转换为所需格式。 -一个 RabbitMQ 表可以有尽可能多的物化视图。 +当 `MATERIALIZED VIEW` 连接到引擎时,它开始在后台收集数据。这允许您不断从 RabbitMQ 接收消息并使用 `SELECT` 将其转换为所需格式。 +一个 RabbitMQ 表可以有任意数量的物化视图。 可以根据 `rabbitmq_exchange_type` 和指定的 `rabbitmq_routing_key_list` 进行数据通道。 每个表最多只能有一个交换。一个交换可以在多个表之间共享 - 这使得能够同时路由到多个表。 交换类型选项: -- `direct` - 路由基于关键字的精确匹配。例如表关键字列表:`key1,key2,key3,key4,key5`,消息关键字可以等于其中任何一个。 -- `fanout` - 路由到所有表(交换名称相同),不管关键字是什么。 -- `topic` - 路由基于以点分隔的关键字的模式。示例:`*.logs`、`records.*.*.2020`、`*.2018,*.2019,*.2020`。 -- `headers` - 路由基于 `key=value` 匹配,并设有设置 `x-match=all` 或 `x-match=any`。示例表关键字列表:`x-match=all,format=logs,type=report,year=2020`。 -- `consistent_hash` - 数据均匀分配到所有绑定表之间(交换名称相同)。请注意,此交换类型必须通过 RabbitMQ 插件启用:`rabbitmq-plugins enable rabbitmq_consistent_hash_exchange`。 +- `direct` - 路由基于键的精确匹配。示例表键列表:`key1,key2,key3,key4,key5`,消息键可以等于其中任何一个。 +- `fanout` - 路由到所有表(交换名称相同)而不考虑键。 +- `topic` - 路由基于用点分隔的键模式。示例:`*.logs`、`records.*.*.2020`、`*.2018,*.2019,*.2020`。 +- `headers` - 路由根据 `key=value` 匹配,设置 `x-match=all` 或 `x-match=any`。示例表键列表:`x-match=all,format=logs,type=report,year=2020`。 +- `consistent_hash` - 数据在所有绑定表之间均匀分配(交换名称相同)。注意,必须启用此交换类型的 RabbitMQ 插件:`rabbitmq-plugins enable rabbitmq_consistent_hash_exchange`。 -设置 `rabbitmq_queue_base` 可用于以下情况: +`rabbitmq_queue_base` 的设置可用于以下情况: -- 让不同的表共享队列,以便为相同队列注册多个消费者,从而提高性能。如果同时使用 `rabbitmq_num_consumers` 和/或 `rabbitmq_num_queues` 设置,则可以在这些参数相同的情况下实现队列的完全匹配。 -- 能够从某些持久队列恢复读取,前提是并非所有消息均已成功消费。要从一个特定队列恢复消费 - 在 `rabbitmq_queue_base` 设置中设置其名称,而无需指定 `rabbitmq_num_consumers` 和 `rabbitmq_num_queues`(默认值为 1)。要从特定表声明的所有队列恢复消费 - 只需指定相同的设置:`rabbitmq_queue_base`、`rabbitmq_num_consumers`、`rabbitmq_num_queues`。默认情况下,队列名称将对表唯一。 -- 重新使用队列,因为它们声明为持久并且不会自动删除。(可以通过任何 RabbitMQ CLI 工具删除。) +- 让不同的表共享队列,以便可以为相同的队列注册多个消费者,从而改善性能。如果使用 `rabbitmq_num_consumers` 和/或 `rabbitmq_num_queues` 设置,则在这些参数相同的情况下可以实现队列的精确匹配。 +- 能够在不是所有消息都成功消费后从特定持久队列恢复读取。要从一个特定队列恢复消费 - 在 `rabbitmq_queue_base` 设置中设置其名称,并且不指定 `rabbitmq_num_consumers` 和 `rabbitmq_num_queues`(默认值为 1)。要恢复所有声明为特定表的队列的消费 - 只需指定相同的设置:`rabbitmq_queue_base`、`rabbitmq_num_consumers`、`rabbitmq_num_queues`。默认情况下,队列名称将在表之间唯一。 +- 由于它们被声明为持久且不自动删除,因此可以重用队列。(可以通过任何 RabbitMQ CLI 工具删除。) -为了提高性能,接收到的消息会被分组到 [max_insert_block_size](/operations/settings/settings#max_insert_block_size) 大小的块中。如果在 [stream_flush_interval_ms](../../../operations/server-configuration-parameters/settings.md) 毫秒内未形成块,则无论块是否完整,数据都将被刷新到表中。 +为了提高性能,接收到的消息被分组到具有 [max_insert_block_size](/operations/settings/settings#max_insert_block_size) 的块中。如果在 [stream_flush_interval_ms](../../../operations/server-configuration-parameters/settings.md) 毫秒内未形成块,则数据将被刷新到表中,而不管块是否完整。 -如果同时指定 `rabbitmq_num_consumers` 和/或 `rabbitmq_num_queues` 设置以及 `rabbitmq_exchange_type`,则: +如果 `rabbitmq_num_consumers` 和/或 `rabbitmq_num_queues` 设置与 `rabbitmq_exchange_type` 一起指定,则: - 必须启用 `rabbitmq-consistent-hash-exchange` 插件。 -- 发布消息的 `message_id` 属性必须被指定(对每条消息/批次唯一)。 +- 发布的消息的 `message_id` 属性必须指定(对于每条消息/批次唯一)。 -对于插入查询,有消息元数据,它会为每条发布的消息添加:`messageID` 和 `republished` 标志(如果发布超过一次,则为 true) - 可以通过消息头访问。 +对于插入查询,有消息元数据,它会为每条发布的消息添加:`messageID` 和 `republished` 标志(如果发布超过一次,则为真) - 可以通过消息头访问。 -不要使用同一表进行插入和物化视图。 +不要对插入和物化视图使用相同的表。 示例: @@ -186,27 +188,27 @@ SELECT key, value FROM daily ORDER BY key; ## 虚拟列 {#virtual-columns} - `_exchange_name` - RabbitMQ 交换名称。数据类型:`String`。 -- `_channel_id` - 声明了接收此消息的消费者的 ChannelID。数据类型:`String`。 -- `_delivery_tag` - 接收到的消息的 DeliveryTag。按照通道作用域。数据类型:`UInt64`。 +- `_channel_id` - 声明接收消息的消费者的 ChannelID。数据类型:`String`。 +- `_delivery_tag` - 接收消息的 DeliveryTag。按通道作用域。数据类型:`UInt64`。 - `_redelivered` - 消息的 `redelivered` 标志。数据类型:`UInt8`。 -- `_message_id` - 接收到的消息的 messageID;如果发布消息时已设置,则非空。数据类型:`String`。 -- `_timestamp` - 接收到的消息的时间戳;如果发布消息时已设置,则非空。数据类型:`UInt64`。 +- `_message_id` - 接收消息的 messageID;如果在消息发布时设置,则非空。数据类型:`String`。 +- `_timestamp` - 接收消息的时间戳;如果在消息发布时设置,则非空。数据类型:`UInt64`。 -当 `kafka_handle_error_mode='stream'` 时的附加虚拟列: +当 `rabbitmq_handle_error_mode='stream'` 时的附加虚拟列: - `_raw_message` - 无法成功解析的原始消息。数据类型:`Nullable(String)`。 -- `_error` - 解析失败时发生的异常消息。数据类型:`Nullable(String)`。 +- `_error` - 在解析失败时发生的异常消息。数据类型:`Nullable(String)`。 -注意:只有在解析期间发生异常时,`_raw_message` 和 `_error` 虚拟列才会被填充,成功解析消息时它们始终为 `NULL`。 +注意:只有在解析时发生异常的情况下,`_raw_message` 和 `_error` 虚拟列才会填充,当消息成功解析时,它们始终为 `NULL`。 ## 注意事项 {#caveats} -即使您可以在表定义中指定 [默认列表达式](/sql-reference/statements/create/table.md/#default_values)(如 `DEFAULT`、`MATERIALIZED`、`ALIAS`),这些也将被忽略。相反,列将填充其各自类型的默认值。 +即使您可以在表定义中指定 [默认列表达式](/sql-reference/statements/create/table.md/#default_values)(如 `DEFAULT`、`MATERIALIZED`、`ALIAS`),这些也会被忽略。相反,列将填充其类型的各自默认值。 ## 数据格式支持 {#data-formats-support} -RabbitMQ 引擎支持 ClickHouse 中支持的所有 [formats](../../../interfaces/formats.md)。 -一条 RabbitMQ 消息中的行数取决于格式是基于行的还是基于块的: +RabbitMQ 引擎支持 ClickHouse 中支持的所有 [格式](../../../interfaces/formats.md)。 +一个 RabbitMQ 消息中的行数取决于格式是行式还是块式: -- 对于基于行的格式,可以通过设置 `rabbitmq_max_rows_per_message` 控制一条 RabbitMQ 消息中的行数。 -- 对于基于块的格式,我们无法将块拆分为更小的部分,但可以通过一般设置 [max_block_size](/operations/settings/settings#max_block_size) 控制每个块中的行数。 +- 对于行式格式,单个 RabbitMQ 消息中的行数可以通过设置 `rabbitmq_max_rows_per_message` 来控制。 +- 对于块式格式,我们无法将块分割为更小的部分,但可以通过通用设置 [max_block_size](/operations/settings/settings#max_block_size) 控制一个块中的行数。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/rabbitmq.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/rabbitmq.md.hash index f6c567e35dd..ddb5629f5e5 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/rabbitmq.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/rabbitmq.md.hash @@ -1 +1 @@ -a71238cbd01305b7 +a60d3812e96d737a diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/redis.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/redis.md index 39a939ed154..0026bf16074 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/redis.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/redis.md @@ -1,19 +1,16 @@ --- -'description': '该引擎允许将 ClickHouse 与 Redis 集成。' +'description': '这个引擎允许将 ClickHouse 与 Redis 集成。' 'sidebar_label': 'Redis' 'sidebar_position': 175 'slug': '/engines/table-engines/integrations/redis' 'title': 'Redis' +'doc_type': 'guide' --- -import CloudNotSupportedBadge from '@theme/badges/CloudNotSupportedBadge'; - # Redis - - -此引擎允许将 ClickHouse 与 [Redis](https://redis.io/) 集成。由于 Redis 采用键值(kv)模型,我们强烈建议您仅以点方式查询,如 `where k=xx` 或 `where k in (xx, xx)`。 +该引擎允许将 ClickHouse 与 [Redis](https://redis.io/) 集成。由于 Redis 采用键值模型,我们强烈建议您仅以点的方式进行查询,例如 `where k=xx` 或 `where k in (xx, xx)`。 ## 创建表 {#creating-a-table} @@ -29,26 +26,25 @@ PRIMARY KEY(primary_key_name); **引擎参数** -- `host:port` — Redis 服务器地址,您可以忽略端口,默认 Redis 端口为 6379。 -- `db_index` — Redis 数据库索引范围为 0 到 15,默认值为 0。 +- `host:port` — Redis 服务器地址,您可以忽略端口,默认使用 Redis 端口 6379。 +- `db_index` — Redis 数据库索引范围从 0 到 15,默认值为 0。 - `password` — 用户密码,默认值为空字符串。 - `pool_size` — Redis 最大连接池大小,默认值为 16。 -- `primary_key_name` - 列表中的任意列名。 +- `primary_key_name` - 列表中的任何列名称。 :::note 序列化 -`PRIMARY KEY` 仅支持一个列。主键将以二进制形式序列化为 Redis 键。 -主键以外的列将按相应顺序以二进制形式序列化为 Redis 值。 +`PRIMARY KEY` 仅支持一个列。主键将以二进制形式序列化为 Redis 键。除了主键以外的列将按照相应的顺序以二进制形式序列化为 Redis 值。 ::: -参数也可以使用 [命名集合](/operations/named-collections.md) 传递。在这种情况下,`host` 和 `port` 应该分别指定。推荐在生产环境中采用这种方法。目前,所有通过命名集合传递给 redis 的参数都是必需的。 +参数也可以通过 [命名集合](/operations/named-collections.md) 传递。在这种情况下,`host` 和 `port` 应该单独指定。建议在生产环境中使用这种方法。此时,通过命名集合传递给 Redis 的所有参数都是必需的。 :::note 过滤 -使用 `key equals` 或 `in filtering` 的查询将优化为从 Redis 查找多个键。如果没有过滤键的查询将会导致全表扫描,这是一个重操作。 +带有 `key equals` 或 `in filtering` 的查询将被优化为从 Redis 多键查找。如果查询没有过滤键,则会发生全表扫描,这是一个重操作。 ::: ## 使用示例 {#usage-example} -使用 `Redis` 引擎和普通参数在 ClickHouse 中创建一个表: +使用简单参数在 ClickHouse 中创建一个使用 `Redis` 引擎的表: ```sql CREATE TABLE redis_table @@ -61,7 +57,7 @@ CREATE TABLE redis_table ENGINE = Redis('redis1:6379') PRIMARY KEY(key); ``` -或者使用 [命名集合](/operations/named-collections.md): +或使用 [命名集合](/operations/named-collections.md): ```xml @@ -86,10 +82,10 @@ CREATE TABLE redis_table ENGINE = Redis(redis_creds) PRIMARY KEY(key); ``` -插入: +插入数据: ```sql -INSERT INTO redis_table Values('1', 1, '1', 1.0), ('2', 2, '2', 2.0); +INSERT INTO redis_table VALUES('1', 1, '1', 1.0), ('2', 2, '2', 2.0); ``` 查询: @@ -126,7 +122,7 @@ SELECT * FROM redis_table WHERE v1=2; 更新: -请注意,主键不能被更新。 +请注意,主键无法更新。 ```sql ALTER TABLE redis_table UPDATE v1=2 WHERE key='1'; @@ -140,7 +136,7 @@ ALTER TABLE redis_table DELETE WHERE key='1'; 截断: -异步刷新 Redis 数据库。`Truncate` 还支持 SYNC 模式。 +异步刷新 Redis 数据库。同时 `Truncate` 支持 SYNC 模式。 ```sql TRUNCATE TABLE redis_table SYNC; @@ -156,6 +152,6 @@ SELECT * FROM redis_table JOIN merge_tree_table ON merge_tree_table.key=redis_ta ## 限制 {#limitations} -Redis 引擎还支持扫描查询,例如 `where k > xx`,但它有一些限制: -1. 在非常罕见的情况下,扫描查询可能会产生一些重复的键,当它正在进行重新哈希时。详情请参阅 [Redis Scan](https://github.com/redis/redis/blob/e4d183afd33e0b2e6e8d1c79a832f678a04a7886/src/dict.c#L1186-L1269)。 -2. 在扫描过程中,可能会创建和删除键,因此结果数据集可能无法表示一个有效的时间点。 +Redis 引擎也支持扫描查询,例如 `where k > xx`,但它有一些限制: +1. 扫描查询在极少数情况下可能会产生一些重复的键,当它正在重新哈希时。有关详细信息,请参见 [Redis Scan](https://github.com/redis/redis/blob/e4d183afd33e0b2e6e8d1c79a832f678a04a7886/src/dict.c#L1186-L1269)。 +2. 在扫描过程中,可能会创建和删除键,因此结果数据集无法表示有效的时间点。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/redis.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/redis.md.hash index 7d52647fa51..6510c424ebd 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/redis.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/redis.md.hash @@ -1 +1 @@ -7a8900a5b7fcee3e +9569b70fbb16446b diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/s3.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/s3.md index 9f109c4bd12..bbe7901437c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/s3.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/s3.md @@ -1,15 +1,16 @@ --- -'description': '这个引擎与 Amazon S3 生态系统集成。类似于 HDFS 引擎,但提供 S3 特定功能。' +'description': '这个引擎提供与 Amazon S3 生态系统的集成。类似于 HDFS 引擎,但提供 S3 特定的功能。' 'sidebar_label': 'S3' 'sidebar_position': 180 'slug': '/engines/table-engines/integrations/s3' 'title': 'S3 表引擎' +'doc_type': 'reference' --- # S3 表引擎 -该引擎提供与 [Amazon S3](https://aws.amazon.com/s3/) 生态系统的集成。该引擎类似于 [HDFS](/engines/table-engines/integrations/hdfs) 引擎,但提供特定于 S3 的特性。 +该引擎提供与 [Amazon S3](https://aws.amazon.com/s3/) 生态系统的集成。该引擎与 [HDFS](/engines/table-engines/integrations/hdfs) 引擎相似,但提供特定于 S3 的功能。 ## 示例 {#example} @@ -34,22 +35,27 @@ SELECT * FROM s3_engine_table LIMIT 2; ```sql CREATE TABLE s3_engine_table (name String, value UInt32) - ENGINE = S3(path [, NOSIGN | aws_access_key_id, aws_secret_access_key,] format, [compression]) + ENGINE = S3(path [, NOSIGN | aws_access_key_id, aws_secret_access_key,] format, [compression], [partition_strategy], [partition_columns_in_data_file]) [PARTITION BY expr] [SETTINGS ...] ``` ### 引擎参数 {#parameters} -- `path` — 存储桶 URL 及文件路径。在只读模式下支持以下通配符:`*`,`**`,`?`,`{abc,def}` 和 `{N..M}`,其中 `N` 和 `M` 为数字,`'abc'` 和 `'def'` 为字符串。有关更多信息,请参见 [下文](#wildcards-in-path)。 -- `NOSIGN` - 如果该关键字在凭证位置提供,则所有请求将不被签名。 +- `path` — 包含文件路径的存储桶 URL。支持只读模式下的以下通配符:`*`、`**`、`?`、`{abc,def}` 和 `{N..M}`,其中 `N`,`M` 为数字,`'abc'`,`'def'` 为字符串。有关更多信息,请见 [下文](#wildcards-in-path)。 +- `NOSIGN` - 如果在凭证位置提供此关键字,则所有请求将不被签名。 - `format` — 文件的 [格式](/sql-reference/formats#formats-overview)。 -- `aws_access_key_id`, `aws_secret_access_key` - AWS 账户用户的长期凭证。您可以使用这些凭证来进行请求认证。该参数为可选项。如果未指定凭证,则使用配置文件中的凭证。有关更多信息,请参见 [使用 S3 进行数据存储](../mergetree-family/mergetree.md#table_engine-mergetree-s3)。 -- `compression` — 压缩类型。支持的值:`none`,`gzip/gz`,`brotli/br`,`xz/LZMA`,`zstd/zst`。该参数为可选项。默认情况下,它将根据文件扩展名自动检测压缩类型。 +- `aws_access_key_id`,`aws_secret_access_key` - 用于 [AWS](https://aws.amazon.com/) 帐户用户的长期凭据。您可以将其用于身份验证请求。该参数是可选的。如果未指定凭据,则将使用配置文件中的凭据。有关更多信息,请参见 [使用 S3 存储数据](../mergetree-family/mergetree.md#table_engine-mergetree-s3)。 +- `compression` — 压缩类型。支持的值:`none`、`gzip/gz`、`brotli/br`、`xz/LZMA`、`zstd/zst`。该参数为可选项。默认情况下,它将根据文件扩展名自动检测压缩。 +- `partition_strategy` – 选项:`WILDCARD` 或 `HIVE`。`WILDCARD` 需要在路径中包含 `{_partition_id}`,并替换为分区键。`HIVE` 不允许使用通配符,假定路径为表的根,并生成带有 Snowflake ID 作为文件名并以文件格式作为扩展名的 Hive 风格分区目录。默认为 `WILDCARD` +- `partition_columns_in_data_file` - 仅在使用 `HIVE` 分区策略时使用。告知 ClickHouse 是否期望分区列写入数据文件中。默认为 `false`。 +- `storage_class_name` - 选项:`STANDARD` 或 `INTELLIGENT_TIERING`,允许指定 [AWS S3 Intelligent Tiering](https://aws.amazon.com/s3/storage-classes/intelligent-tiering/)。 ### 数据缓存 {#data-cache} -`S3` 表引擎支持在本地磁盘上缓存数据。请参见 [这一节](/operations/storing-data.md/#using-local-cache) 中的文件系统缓存配置选项和使用。缓存的创建依赖于存储对象的路径和 ETag,因此 ClickHouse 不会读取过期的缓存版本。 +`S3` 表引擎支持在本地磁盘上进行数据缓存。 +请参阅此 [部分](/operations/storing-data.md/#using-local-cache) 中的文件系统缓存配置选项和用法。 +缓存是根据路径和存储对象的 ETag 进行的,因此 ClickHouse 不会读取过期版本的缓存。 要启用缓存,请使用设置 `filesystem_cache_name = ''` 和 `enable_filesystem_cache = 1`。 @@ -59,7 +65,7 @@ FROM s3('http://minio:10000/clickhouse//test_3.csv', 'minioadmin', 'minioadminpa SETTINGS filesystem_cache_name = 'cache_for_s3', enable_filesystem_cache = 1; ``` -有两种方式在配置文件中定义缓存。 +有两种方法可以在配置文件中定义缓存。 1. 将以下部分添加到 ClickHouse 配置文件中: @@ -74,24 +80,70 @@ SETTINGS filesystem_cache_name = 'cache_for_s3', enable_filesystem_cache = 1; ``` -2. 从 ClickHouse 的 `storage_configuration` 部分重用缓存配置(因此缓存存储),[详述如下](/operations/storing-data.md/#using-local-cache) +2. 重用来自 ClickHouse `storage_configuration` 部分的缓存配置(因此缓存存储),[在此描述](/operations/storing-data.md/#using-local-cache) -### PARTITION BY {#partition-by} +### 按分区 {#partition-by} -`PARTITION BY` — 可选。在大多数情况下,您不需要分区键,如果需要,则通常不需要比按月更细粒度的分区键。分区不会加速查询(与 ORDER BY 表达式相反)。您不应该使用过于细粒度的分区。不要按客户标识符或名称分区您的数据(相反,将客户标识符或名称作为 ORDER BY 表达式中的第一列)。 +`PARTITION BY` — 可选。在大多数情况下,您不需要分区键,如果需要,通常不需要比按月更细粒度的分区。分区不会加快查询速度(与 ORDER BY 表达式相反)。您永远不应该使用过于细粒度的分区。不要按客户标识符或名称对数据进行分区(相反,请将客户标识符或名称作为 ORDER BY 表达式中的第一列)。 -要按月分区,请使用 `toYYYYMM(date_column)` 表达式,其中 `date_column` 是类型为 [Date](/sql-reference/data-types/date.md) 的日期列。此处的分区名称具有 `"YYYYMM"` 格式。 +按月分区时,请使用 `toYYYYMM(date_column)` 表达式,其中 `date_column` 是类型为 [Date](/sql-reference/data-types/date.md) 的日期列。这里的分区名称采用 `"YYYYMM"` 格式。 + +#### 分区策略 {#partition-strategy} + +`WILDCARD`(默认):将文件路径中的 `{_partition_id}` 通配符替换为实际分区键。不支持读取。 + +`HIVE` 实现 Hive 风格的分区以进行读写。读取是通过递归的 glob 模式实现的,相当于 `SELECT * FROM s3('table_root/**.parquet')`。 +写入生成的文件格式为: `//.`。 + +注意:使用 `HIVE` 分区策略时,`use_hive_partitioning` 设置无效。 + +`HIVE` 分区策略的示例: + +```sql +arthur :) CREATE TABLE t_03363_parquet (year UInt16, country String, counter UInt8) +ENGINE = S3(s3_conn, filename = 't_03363_parquet', format = Parquet, partition_strategy='hive') +PARTITION BY (year, country); + +arthur :) INSERT INTO t_03363_parquet VALUES + (2022, 'USA', 1), + (2022, 'Canada', 2), + (2023, 'USA', 3), + (2023, 'Mexico', 4), + (2024, 'France', 5), + (2024, 'Germany', 6), + (2024, 'Germany', 7), + (1999, 'Brazil', 8), + (2100, 'Japan', 9), + (2024, 'CN', 10), + (2025, '', 11); + +arthur :) select _path, * from t_03363_parquet; + + ┌─_path──────────────────────────────────────────────────────────────────────┬─year─┬─country─┬─counter─┐ + 1. │ test/t_03363_parquet/year=2100/country=Japan/7329604473272971264.parquet │ 2100 │ Japan │ 9 │ + 2. │ test/t_03363_parquet/year=2024/country=France/7329604473323302912.parquet │ 2024 │ France │ 5 │ + 3. │ test/t_03363_parquet/year=2022/country=Canada/7329604473314914304.parquet │ 2022 │ Canada │ 2 │ + 4. │ test/t_03363_parquet/year=1999/country=Brazil/7329604473289748480.parquet │ 1999 │ Brazil │ 8 │ + 5. │ test/t_03363_parquet/year=2023/country=Mexico/7329604473293942784.parquet │ 2023 │ Mexico │ 4 │ + 6. │ test/t_03363_parquet/year=2023/country=USA/7329604473319108608.parquet │ 2023 │ USA │ 3 │ + 7. │ test/t_03363_parquet/year=2025/country=/7329604473327497216.parquet │ 2025 │ │ 11 │ + 8. │ test/t_03363_parquet/year=2024/country=CN/7329604473310720000.parquet │ 2024 │ CN │ 10 │ + 9. │ test/t_03363_parquet/year=2022/country=USA/7329604473298137088.parquet │ 2022 │ USA │ 1 │ +10. │ test/t_03363_parquet/year=2024/country=Germany/7329604473306525696.parquet │ 2024 │ Germany │ 6 │ +11. │ test/t_03363_parquet/year=2024/country=Germany/7329604473306525696.parquet │ 2024 │ Germany │ 7 │ + └────────────────────────────────────────────────────────────────────────────┴──────┴─────────┴─────────┘ +``` ### 查询分区数据 {#querying-partitioned-data} -该示例使用 [docker compose recipe](https://github.com/ClickHouse/examples/tree/5fdc6ff72f4e5137e23ea075c88d3f44b0202490/docker-compose-recipes/recipes/ch-and-minio-S3),集成了 ClickHouse 和 MinIO。您应该能够通过替换端点和认证值来重现相同的查询。 +该示例使用 [docker compose 配方](https://github.com/ClickHouse/examples/tree/5fdc6ff72f4e5137e23ea075c88d3f44b0202490/docker-compose-recipes/recipes/ch-and-minio-S3),集成了 ClickHouse 和 MinIO。您应该能够通过替换端点和身份验证值来重现相同的查询。 -请注意,在 `ENGINE` 配置中,S3 端点使用参数 token `{_partition_id}` 作为 S3 对象(文件名)的一部分,并且 SELECT 查询是针对这些生成的对象名称进行选择的(例如,`test_3.csv`)。 +请注意,`ENGINE` 配置中的 S3 端点使用了参数令牌 `{_partition_id}` 作为 S3 对象(文件名)的一部分,并且 SELECT 查询针对这些生成的对象名称(例如 `test_3.csv`)进行选择。 :::note -如示例所示,当前不直接支持从分区的 S3 表中查询,但可以通过使用 S3 表函数查询单个分区来实现。 +如示例所示,目前不直接支持从分区的 S3 表进行查询,但可以使用 S3 表函数查询各个分区来实现。 -在 S3 中写入分区数据的主要用例是为了将数据转移到另一个 ClickHouse 系统(例如,从本地系统迁移到 ClickHouse Cloud)。由于 ClickHouse 数据集通常非常大,并且网络可靠性有时不完美,因此以子集的形式传输数据集是有意义的,因此需要进行分区写入。 +写入分区数据到 S3 的主要用例是将数据转移到另一个 ClickHouse 系统(例如,从本地系统迁移到 ClickHouse Cloud)。因为 ClickHouse 数据集通常非常大,并且网络可靠性有时不完美,所以分批传输数据集是有意义的,因此进行了分区写入。 ::: #### 创建表 {#create-the-table} @@ -113,13 +165,13 @@ PARTITION BY column3 #### 插入数据 {#insert-data} ```sql -insert into p values (1, 2, 3), (3, 2, 1), (78, 43, 45) +INSERT INTO p VALUES (1, 2, 3), (3, 2, 1), (78, 43, 45) ``` -#### 从分区 3 查询 {#select-from-partition-3} +#### 从分区 3 选择 {#select-from-partition-3} :::tip -该查询使用了 s3 表函数 +此查询使用 S3 表函数 ::: ```sql @@ -132,7 +184,7 @@ FROM s3('http://minio:10000/clickhouse//test_3.csv', 'minioadmin', 'minioadminpa └────┴────┴────┘ ``` -#### 从分区 1 查询 {#select-from-partition-1} +#### 从分区 1 选择 {#select-from-partition-1} ```sql SELECT * FROM s3('http://minio:10000/clickhouse//test_1.csv', 'minioadmin', 'minioadminpassword', 'CSV') @@ -143,7 +195,7 @@ FROM s3('http://minio:10000/clickhouse//test_1.csv', 'minioadmin', 'minioadminpa └────┴────┴────┘ ``` -#### 从分区 45 查询 {#select-from-partition-45} +#### 从分区 45 选择 {#select-from-partition-45} ```sql SELECT * FROM s3('http://minio:10000/clickhouse//test_45.csv', 'minioadmin', 'minioadminpassword', 'CSV') @@ -156,7 +208,7 @@ FROM s3('http://minio:10000/clickhouse//test_45.csv', 'minioadmin', 'minioadminp #### 限制 {#limitation} -您可能会尝试 `Select * from p`,但如上所述,该查询将失败;请使用前面的查询。 +您自然可能尝试 `Select * from p`,但如上所述,此查询将失败;请使用前面的查询。 ```sql SELECT * FROM p @@ -168,58 +220,58 @@ Code: 48. DB::Exception: Received from localhost:9000. DB::Exception: Reading fr ## 插入数据 {#inserting-data} -请注意,行只能插入到新文件中。没有合并周期或文件拆分操作。一旦写入文件,后续插入将失败。为避免这种情况,您可以使用 `s3_truncate_on_insert` 和 `s3_create_new_file_on_insert` 设置。有关更多细节,请参见 [这里](/integrations/s3#inserting-data)。 +请注意,行只能插入到新文件中。没有合并周期或文件拆分操作。一旦写入文件,后续插入将失败。为避免此问题,您可以使用 `s3_truncate_on_insert` 和 `s3_create_new_file_on_insert` 设置。详细信息请参见 [此处](/integrations/s3#inserting-data)。 ## 虚拟列 {#virtual-columns} - `_path` — 文件路径。类型:`LowCardinality(String)`。 - `_file` — 文件名。类型:`LowCardinality(String)`。 -- `_size` — 文件大小(以字节为单位)。类型:`Nullable(UInt64)`。如果大小未知,则值为 `NULL`。 -- `_time` — 文件的最后修改时间。类型:`Nullable(DateTime)`。如果时间未知,则值为 `NULL`。 -- `_etag` — 文件的 ETag。类型:`LowCardinality(String)`。如果 etag 未知,则值为 `NULL`。 +- `_size` — 文件大小(以字节为单位)。类型:`Nullable(UInt64)`。如果大小未知,值为 `NULL`。 +- `_time` — 文件最后修改时间。类型:`Nullable(DateTime)`。如果时间未知,值为 `NULL`。 +- `_etag` — 文件的 ETag。类型:`LowCardinality(String)`。如果 ETag 未知,值为 `NULL`。 -有关虚拟列的更多信息,请见 [这里](../../../engines/table-engines/index.md#table_engines-virtual_columns)。 +有关虚拟列的更多信息,请参见 [这里](../../../engines/table-engines/index.md#table_engines-virtual_columns)。 ## 实现细节 {#implementation-details} - 读取和写入可以并行进行。 - 不支持: - - `ALTER` 和 `SELECT...SAMPLE` 操作。 - - 索引。 - - [零拷贝](../../../operations/storing-data.md#zero-copy) 复制是可能的,但不被支持。 + - `ALTER` 和 `SELECT...SAMPLE` 操作。 + - 索引。 + - [零拷贝](../../../operations/storing-data.md#zero-copy) 复制是可能的,但不受支持。 - :::note 零拷贝复制尚未准备好投入生产 - 在 ClickHouse 版本 22.8 及更高版本中,零拷贝复制默认是禁用的。此功能不建议在生产环境中使用。 + :::note 零拷贝复制尚未准备好用于生产 + ClickHouse 版本 22.8 及更高版本中默认禁用零拷贝复制。此功能不建议用于生产环境。 ::: ## 路径中的通配符 {#wildcards-in-path} -`path` 参数可以使用类似 bash 的通配符指定多个文件。要进行处理,文件必须存在并匹配整个路径模式。文件列出在 `SELECT` 时确定(而不是在 `CREATE` 之时)。 +`path` 参数可以使用类似 bash 的通配符指定多个文件。要进行处理,文件应存在并与整个路径模式匹配。文件列表在 `SELECT` 时确定(而不是在 `CREATE` 时)。 -- `*` — 替代任何数量的任意字符,包括空字符串,但不包括 `/`。 -- `**` — 替代任何数量的任意字符(包括 `/`)及空字符串。 -- `?` — 替代任意单个字符。 -- `{some_string,another_string,yet_another_one}` — 替代任何字符串 `'some_string', 'another_string', 'yet_another_one'`。 -- `{N..M}` — 替代范围从 N 到 M 的任意数字,包括边界。 N 和 M 可以有前导零,例如 `000..078`。 +- `*` — 替代任何数量的任何字符,除了 `/`,包括空字符串。 +- `**` — 替代任何数量的任何字符,包括 `/`,也包括空字符串。 +- `?` — 替代任何单个字符。 +- `{some_string,another_string,yet_another_one}` — 替代任一字符串 `'some_string', 'another_string', 'yet_another_one'`。 +- `{N..M}` — 替代范围内的任意数字,包括 N 和 M 两个边界。N 和 M 可以有前导零,例如 `000..078`。 -带有 `{}` 的构造与 [remote](../../../sql-reference/table-functions/remote.md) 表函数类似。 +带有 `{}` 的结构与 [remote](../../../sql-reference/table-functions/remote.md) 表函数相似。 :::note -如果文件列表包含带有前导零的数字范围,请为每个数字单独使用棱形构造,或使用 `?`。 +如果文件列表包含带前导零的数字范围,请分别为每个数字使用带大括号的结构,或使用 `?`。 ::: -**通配符示例 1** +**带通配符的示例 1** -创建一个表,文件命名为 `file-000.csv`,`file-001.csv`,...,`file-999.csv`: +创建文件命名为 `file-000.csv`、`file-001.csv`,...,`file-999.csv` 的表: ```sql CREATE TABLE big_table (name String, value UInt32) ENGINE = S3('https://clickhouse-public-datasets.s3.amazonaws.com/my-bucket/my_folder/file-{000..999}.csv', 'CSV'); ``` -**通配符示例 2** +**带通配符的示例 2** -假设我们在 S3 上有几个 CSV 格式的文件,URI 如下: +假设我们在 S3 上有几个 CSV 格式的文件,其 URI 如下: - 'https://clickhouse-public-datasets.s3.amazonaws.com/my-bucket/some_folder/some_file_1.csv' - 'https://clickhouse-public-datasets.s3.amazonaws.com/my-bucket/some_folder/some_file_2.csv' @@ -228,24 +280,23 @@ CREATE TABLE big_table (name String, value UInt32) - 'https://clickhouse-public-datasets.s3.amazonaws.com/my-bucket/another_folder/some_file_2.csv' - 'https://clickhouse-public-datasets.s3.amazonaws.com/my-bucket/another_folder/some_file_3.csv' +有几种方法可以创建一个包含所有六个文件的表: -有几种方法可以创建一个由所有六个文件组成的表: - -1. 指定文件后缀范围: +1. 指定文件后缀的范围: ```sql CREATE TABLE table_with_range (name String, value UInt32) ENGINE = S3('https://clickhouse-public-datasets.s3.amazonaws.com/my-bucket/{some,another}_folder/some_file_{1..3}', 'CSV'); ``` -2. 获取所有以 `some_file_` 为前缀的文件(在两个文件夹中不应存在其他具有该前缀的额外文件): +2. 获取所有以 `some_file_` 为前缀的文件(两个文件夹中不应有其他具有该前缀的额外文件): ```sql CREATE TABLE table_with_question_mark (name String, value UInt32) ENGINE = S3('https://clickhouse-public-datasets.s3.amazonaws.com/my-bucket/{some,another}_folder/some_file_?', 'CSV'); ``` -3. 获取两个文件夹中的所有文件(所有文件应满足查询中描述的格式和架构): +3. 获取两个文件夹中的所有文件(所有文件应满足查询中描述的格式和模式): ```sql CREATE TABLE table_with_asterisk (name String, value UInt32) @@ -254,47 +305,47 @@ CREATE TABLE table_with_asterisk (name String, value UInt32) ## 存储设置 {#storage-settings} -- [s3_truncate_on_insert](/operations/settings/settings.md#s3_truncate_on_insert) - 允许在插入前截断文件。默认情况下禁用。 -- [s3_create_new_file_on_insert](/operations/settings/settings.md#s3_create_new_file_on_insert) - 允许在每次插入时创建新文件(如果格式带有后缀)。默认情况下禁用。 -- [s3_skip_empty_files](/operations/settings/settings.md#s3_skip_empty_files) - 允许在读取时跳过空文件。默认情况下启用。 +- [s3_truncate_on_insert](/operations/settings/settings.md#s3_truncate_on_insert) - 允许在插入之前截断文件。默认禁用。 +- [s3_create_new_file_on_insert](/operations/settings/settings.md#s3_create_new_file_on_insert) - 允许在每次插入时创建一个新文件(如果格式具有后缀)。默认禁用。 +- [s3_skip_empty_files](/operations/settings/settings.md#s3_skip_empty_files) - 在读取时允许跳过空文件。默认启用。 -## 与 S3 相关的设置 {#settings} +## S3 相关设置 {#settings} -以下设置可以在查询执行前设定或放置到配置文件中。 +以下设置可以在查询执行之前设置或放置在配置文件中。 -- `s3_max_single_part_upload_size` — 使用单部分上传到 S3 的对象的最大大小。默认值为 `32Mb`。 -- `s3_min_upload_part_size` — 在进行 [S3 分段上传](https://docs.aws.amazon.com/AmazonS3/latest/dev/uploadobjusingmpu.html) 时上传的部分的最小大小。默认值为 `16Mb`。 +- `s3_max_single_part_upload_size` — 使用单个上传到 S3 的对象的最大大小。默认值为 `32Mb`。 +- `s3_min_upload_part_size` — 在 [S3 多部分上传](https://docs.aws.amazon.com/AmazonS3/latest/dev/uploadobjusingmpu.html) 中上传部分的最小大小。默认值为 `16Mb`。 - `s3_max_redirects` — 允许的最大 S3 重定向跳数。默认值为 `10`。 - `s3_single_read_retries` — 单次读取的最大尝试次数。默认值为 `4`。 -- `s3_max_put_rps` — 在限制之前的每秒最大 PUT 请求数。默认值为 `0`(无限制)。 -- `s3_max_put_burst` — 在达到每秒请求限制之前可以同时发出的最大请求数。默认值为 `0`(与 `s3_max_put_rps` 相同)。 -- `s3_max_get_rps` — 在限制之前的每秒最大 GET 请求数。默认值为 `0`(无限制)。 -- `s3_max_get_burst` — 在达到每秒请求限制之前可以同时发出的最大请求数。默认值为 `0`(与 `s3_max_get_rps` 相同)。 -- `s3_upload_part_size_multiply_factor` - 每次从 S3 上传 `s3_multiply_parts_count_threshold` 个部分时,将此因子乘以 `s3_min_upload_part_size`。默认值为 `2`。 -- `s3_upload_part_size_multiply_parts_count_threshold` - 每次上传此数量的部分到 S3 时,`s3_min_upload_part_size` 将乘以 `s3_upload_part_size_multiply_factor`。默认值为 `500`。 -- `s3_max_inflight_parts_for_one_file` - 限制可以同时运行的对单个对象的 PUT 请求数量。其数量应受到限制。值为 `0` 意味着无限制。默认值为 `20`。每个飞行的部分都有一个大小为 `s3_min_upload_part_size` 的缓冲区,前 `s3_upload_part_size_multiply_factor` 个部分的缓冲区较小,对于更大文件则会更多,见 `upload_part_size_multiply_factor`。在默认设置下,一个上传文件占用不超过 `320Mb` 对于小于 `8G` 的文件。在更大的文件中,消耗会更高。 +- `s3_max_put_rps` — 在限制之前的最大 PUT 请求每秒速率。默认值为 `0`(无限制)。 +- `s3_max_put_burst` — 在达到每秒请求限制之前,可以同时发起的最大请求数量。默认为 `0`(与 `s3_max_put_rps` 相等)。 +- `s3_max_get_rps` — 在限制之前的最大 GET 请求每秒速率。默认值为 `0`(无限制)。 +- `s3_max_get_burst` — 在达到每秒请求限制之前,可以同时发起的最大请求数量。默认为 `0`(与 `s3_max_get_rps` 相等)。 +- `s3_upload_part_size_multiply_factor` - 在从单次写入到 S3 上传的 `s3_multiply_parts_count_threshold` 部分每次乘以此因子。默认值为 `2`。 +- `s3_upload_part_size_multiply_parts_count_threshold` - 每次上传到 S3 的此数量的部分,`s3_min_upload_part_size` 乘以 `s3_upload_part_size_multiply_factor`。默认值为 `500`。 +- `s3_max_inflight_parts_for_one_file` - 限制一次性可以并行运行的 PUT 请求数量。该数量应受到限制。值为 `0` 表示无限制。默认值为 `20`。每个在途部分的缓冲区大小为 `s3_min_upload_part_size`,前 `s3_upload_part_size_multiply_factor` 个部分适用,文件较大时则更多,见 `upload_part_size_multiply_factor`。使用默认设置时,一个上传的文件在小于 `8G` 的情况下最多消耗 `320Mb`。较大文件的消耗则更大。 -安全考虑:如果恶意用户可以指定任意 S3 URLs,则必须将 `s3_max_redirects` 设置为零,以避免 [SSRF](https://en.wikipedia.org/wiki/Server-side_request_forgery) 攻击;或者,在服务器配置中指定 `remote_host_filter`。 +安全考虑:如果恶意用户可以指定任意 S3 URL,则 `s3_max_redirects` 必须设置为零,以避免 [SSRF](https://en.wikipedia.org/wiki/Server-side_request_forgery) 攻击;或者在服务器配置中另行指定 `remote_host_filter`。 ## 基于端点的设置 {#endpoint-settings} -可以在配置文件中为特定端点指定以下设置(将通过 URL 的确切前缀匹配): +以下设置可以在配置文件中为给定的端点指定(将通过 URL 的精确前缀进行匹配): - `endpoint` — 指定端点的前缀。必填。 -- `access_key_id` 和 `secret_access_key` — 指定用于给定端点的凭证。可选。 -- `use_environment_credentials` — 如果设置为 `true`,则 S3 客户端将尝试从环境变量和 [Amazon EC2](https://en.wikipedia.org/wiki/Amazon_Elastic_Compute_Cloud) 元数据中获取凭证。可选,默认值为 `false`。 +- `access_key_id` 和 `secret_access_key` — 指定给定端点可用的凭据。可选。 +- `use_environment_credentials` — 如果设置为 `true`,S3 客户端将尝试从环境变量和 [Amazon EC2](https://en.wikipedia.org/wiki/Amazon_Elastic_Compute_Cloud) 元数据中获取凭据。可选,默认值为 `false`。 - `region` — 指定 S3 区域名称。可选。 -- `use_insecure_imds_request` — 如果设置为 `true`,S3 客户端将使用不安全的 IMDS 请求从 Amazon EC2 元数据中获取凭证。可选,默认值为 `false`。 -- `expiration_window_seconds` — 检查基于过期的凭证是否过期的宽限期。可选,默认值为 `120`。 -- `no_sign_request` - 忽略所有凭证,因此请求不会被签名。用于访问公共存储桶。 -- `header` — 向给定端点的请求中添加指定的 HTTP 头。可选,可以指定多次。 -- `access_header` - 向给定端点的请求中添加指定的 HTTP 头,当没有其他来源的凭证时。 -- `server_side_encryption_customer_key_base64` — 如果指定,则设置访问 S3 对象所需的 SSE-C 加密的头。可选。 -- `server_side_encryption_kms_key_id` - 如果指定,将设置访问具有 [SSE-KMS 加密](https://docs.aws.amazon.com/AmazonS3/latest/userguide/UsingKMSEncryption.html) 的 S3 对象所需的头。如果指定空字符串,将使用 AWS 管理的 S3 密钥。可选。 -- `server_side_encryption_kms_encryption_context` - 如果与 `server_side_encryption_kms_key_id` 一起指定,将为 SSE-KMS 设置给定的加密上下文头。可选。 -- `server_side_encryption_kms_bucket_key_enabled` - 如果与 `server_side_encryption_kms_key_id` 一起指定,将为 SSE-KMS 设置启用 S3 存储桶密钥的头。可选,可以是 `true` 或 `false`,默认没有设置(与存储桶级别设置匹配)。 +- `use_insecure_imds_request` — 如果设置为 `true`,S3 客户端在从 Amazon EC2 元数据中获取凭据时将使用不安全的 IMDS 请求。可选,默认值为 `false`。 +- `expiration_window_seconds` — 检查以过期为基础的凭据是否已过期的宽限期。可选,默认值为 `120`。 +- `no_sign_request` - 忽略所有凭据,因此请求不被签名。适用于访问公共存储桶。 +- `header` — 在请求添加指定的 HTTP 头到给定的端点。可选,可以多次指定。 +- `access_header` - 在请求添加指定的 HTTP 头到给定的端点,当没有其他来源的凭据时。 +- `server_side_encryption_customer_key_base64` — 如果指定,则将设置访问 S3 对象所需的 SSE-C 加密所需的头。可选。 +- `server_side_encryption_kms_key_id` - 如果指定,则将设置访问 S3 对象所需的 [SSE-KMS 加密](https://docs.aws.amazon.com/AmazonS3/latest/userguide/UsingKMSEncryption.html) 所需的头。如果指定空字符串,则将使用 AWS 管理的 S3 密钥。可选。 +- `server_side_encryption_kms_encryption_context` - 如果与 `server_side_encryption_kms_key_id` 一起指定,则将设置 SSE-KMS 的给定加密上下文头。可选。 +- `server_side_encryption_kms_bucket_key_enabled` - 如果与 `server_side_encryption_kms_key_id` 一起指定,则将设置启用 SSE-KMS 的 S3 存储桶密钥的头。可选,可以为 `true` 或 `false`,默认为无(匹配存储桶级别的设置)。 - `max_single_read_retries` — 单次读取的最大尝试次数。默认值为 `4`。可选。 -- `max_put_rps`、`max_put_burst`、`max_get_rps` 和 `max_get_burst` - 供特定端点使用的限流设置(见上文描述),而不是逐查询。可选。 +- `max_put_rps`、`max_put_burst`、`max_get_rps` 和 `max_get_burst` - 用于特定端点而不是每个查询的节流设置(见上文描述)。可选。 **示例:** @@ -319,15 +370,15 @@ CREATE TABLE table_with_asterisk (name String, value UInt32) ``` -## 处理归档 {#working-with-archives} +## 处理档案 {#working-with-archives} -假设我们在 S3 上有几个归档文件,URI 如下: +假设我们在 S3 上有几个档案文件,其 URI 如下: - 'https://s3-us-west-1.amazonaws.com/umbrella-static/top-1m-2018-01-10.csv.zip' - 'https://s3-us-west-1.amazonaws.com/umbrella-static/top-1m-2018-01-11.csv.zip' - 'https://s3-us-west-1.amazonaws.com/umbrella-static/top-1m-2018-01-12.csv.zip' -从这些归档中提取数据是可能的,可以使用 ::。通配符可以用于 URL 部分以及 :: 之后的部分(负责归档内部文件的名称)。 +使用 :: 提取这些档案中的数据是可能的。Globs 可以在 URL 部分以及 :: 后的部分(负责档案内文件的名称)使用。 ```sql SELECT * @@ -337,17 +388,18 @@ FROM s3( ``` :::note -ClickHouse 支持三种归档格式: +ClickHouse 支持三种档案格式: ZIP TAR 7Z -尽管 ZIP 和 TAR 归档可以从任何支持的存储位置访问,但 7Z 归档只能从 ClickHouse 安装的本地文件系统中读取。 +虽然 ZIP 和 TAR 档案可以从任何支持的存储位置访问,但 7Z 档案只能从安装 ClickHouse 的本地文件系统读取。 ::: - ## 访问公共存储桶 {#accessing-public-buckets} -ClickHouse 尝试从许多不同类型的来源获取凭证。有时,在访问某些公共存储桶时会出现问题,导致客户端返回 `403` 错误代码。可以通过使用 `NOSIGN` 关键字来避免此问题,强制客户端忽略所有凭证,不对请求进行签名。 +ClickHouse 尝试从许多不同类型的来源获取凭据。 +有时,访问某些公共存储桶时可能会出现问题,导致客户端返回 `403` 错误代码。 +通过使用 `NOSIGN` 关键字,可以避免此问题,从而强制客户端忽略所有凭据,并且不签署请求。 ```sql CREATE TABLE big_table (name String, value UInt32) @@ -356,9 +408,9 @@ CREATE TABLE big_table (name String, value UInt32) ## 优化性能 {#optimizing-performance} -有关优化 s3 函数性能的详细信息,请参见 [我们的详细指南](/integrations/s3/performance)。 +有关优化 S3 功能性能的详细信息,请参见 [我们的详细指南](/integrations/s3/performance)。 -## 另请参见 {#see-also} +## 另请参阅 {#see-also} - [s3 表函数](../../../sql-reference/table-functions/s3.md) - [将 S3 与 ClickHouse 集成](/integrations/s3) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/s3.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/s3.md.hash index b236b4404a0..97972d80775 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/s3.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/s3.md.hash @@ -1 +1 @@ -f6c87801dd861bf6 +735743f89bb0d4dc diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/s3queue.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/s3queue.md index cda75349d3f..cae0b5784d3 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/s3queue.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/s3queue.md @@ -1,10 +1,10 @@ --- -'description': '这个引擎提供与 Amazon S3 生态系统的集成,并允许流式导入。类似于 Kafka 和 RabbitMQ 引擎,但提供了 S3 - 特有的功能。' +'description': '此引擎提供与 Amazon S3 生态系统的集成,并允许流式导入。类似于 Kafka 和 RabbitMQ 引擎,但提供 S3 特定的功能。' 'sidebar_label': 'S3Queue' 'sidebar_position': 181 'slug': '/engines/table-engines/integrations/s3queue' 'title': 'S3Queue 表引擎' +'doc_type': 'reference' --- import ScalePlanFeatureBadge from '@theme/badges/ScalePlanFeatureBadge' @@ -12,7 +12,9 @@ import ScalePlanFeatureBadge from '@theme/badges/ScalePlanFeatureBadge' # S3Queue 表引擎 -该引擎提供与 [Amazon S3](https://aws.amazon.com/s3/) 生态系统的集成,并允许流式导入。该引擎类似于 [Kafka](../../../engines/table-engines/integrations/kafka.md)、[RabbitMQ](../../../engines/table-engines/integrations/rabbitmq.md) 引擎,但提供 S3 特定的功能。 +该引擎提供与 [Amazon S3](https://aws.amazon.com/s3/) 生态系统的集成,并允许流式导入。该引擎类似于 [Kafka](../../../engines/table-engines/integrations/kafka.md) 和 [RabbitMQ](../../../engines/table-engines/integrations/rabbitmq.md) 引擎,但提供了 S3 特定的功能。 + +重要的是要理解 [S3Queue 实现的原始 PR 中的说明](https://github.com/ClickHouse/ClickHouse/pull/49086/files#diff-e1106769c9c8fbe48dd84f18310ef1a250f2c248800fde97586b3104e9cd6af8R183):当 `MATERIALIZED VIEW` 连接到引擎时,S3Queue 表引擎开始在后台收集数据。 ## 创建表 {#creating-a-table} @@ -50,7 +52,7 @@ CREATE TABLE s3_queue_engine_table (name String, value UInt32) **引擎参数** -`S3Queue` 的参数与 `S3` 表引擎支持的参数相同。有关参数部分,请参见 [此处](../../../engines/table-engines/integrations/s3.md#parameters)。 +`S3Queue` 参数与 `S3` 表引擎支持的参数相同。有关参数的详细信息,请参见 [此处](../../../engines/table-engines/integrations/s3.md#parameters)。 **示例** @@ -84,146 +86,156 @@ SETTINGS ## 设置 {#settings} -要获取已为表配置的设置列表,请使用 `system.s3_queue_settings` 表。从 `24.10` 起可用。 +要获取已为表配置的设置列表,请使用 `system.s3_queue_settings` 表。从 `24.10` 开始可用。 -### mode {#mode} +### 模式 {#mode} -可能的值: +可选值: -- unordered — 在无序模式下,已处理文件的集合通过 ZooKeeper 中的持久节点进行跟踪。 -- ordered — 在有序模式下,文件按照字典顺序处理。这意味着,如果某个名为 'BBB' 的文件在某个时刻被处理,而稍后添加了一个名为 'AA' 的文件到存储桶,则该文件将被忽略。仅在 ZooKeeper 中存储成功消费的文件的最大名称(在字典序中的意义)和在不成功加载尝试后将重试的文件名称。 +- unordered — 在无序模式下,所有已处理文件的集合通过 ZooKeeper 中的持久节点进行跟踪。 +- ordered — 在有序模式下,文件按字典顺序处理。这意味着如果名为 'BBB' 的文件在某个时刻被处理,而后名为 'AA' 的文件添加到桶中,则该文件将被忽略。只有成功消费的文件的最大名称(按字典顺序)和在不成功加载尝试后将会重试的文件名会被存储在 ZooKeeper 中。 -默认值:在版本 24.6 之前为 `ordered`。从 24.6 开始没有默认值,该设置需要手动指定。对于在早期版本中创建的表,默认值将保持为 `Ordered` 以保持兼容性。 +默认值:在 24.6 之前为 `ordered`。从 24.6 开始没有默认值,设置成为必需手动指定。对于在早期版本上创建的表,默认值将保持为 `Ordered` 以保持兼容性。 -### after_processing {#after_processing} +### `after_processing` {#after_processing} -成功处理后删除或保留文件。 -可能的值: +在成功处理后删除或保留文件。 +可选值: - keep. - delete. 默认值:`keep`。 -### keeper_path {#keeper_path} +### `keeper_path` {#keeper_path} -可以将 ZooKeeper 中的路径指定为表引擎设置,或者默认路径可以由全局配置提供的路径和表 UUID 形成。 -可能的值: +ZooKeeper 中的路径可以作为表引擎设置指定,或者默认路径可以从全局配置提供的路径和表 UUID 生成。 +可选值: - 字符串。 默认值:`/`。 -### s3queue_loading_retries {#loading_retries} +### `s3queue_loading_retries` {#loading_retries} -重试文件加载的次数,最多指定次数。默认情况下,没有重试。 -可能的值: +最多重试指定次数的文件加载。默认情况下,没有重试。 +可选值: - 正整数。 默认值:`0`。 -### s3queue_processing_threads_num {#processing_threads_num} +### `s3queue_processing_threads_num` {#processing_threads_num} 执行处理的线程数。仅适用于 `Unordered` 模式。 -默认值:CPU 数量或 16。 +默认值:CPU 数或 16。 -### s3queue_parallel_inserts {#parallel_inserts} +### `s3queue_parallel_inserts` {#parallel_inserts} 默认情况下,`processing_threads_num` 将产生一个 `INSERT`,因此它只会下载文件并在多个线程中解析。 -但是这限制了并行性,因此为获得更好的吞吐量使用 `parallel_inserts=true`,这将允许并行插入数据(但请注意,这会导致为 MergeTree 系列生成更多的数据分区片段)。 +但这会限制并行性,因此为了更好的吞吐率使用 `parallel_inserts=true`,这将允许并行插入数据(但请注意,这将导致生成更多的 MergeTree 家族的数据部分)。 :::note -`INSERT` 将根据 `max_process*_before_commit` 设置生成。 +`INSERT`s 将根据 `max_process*_before_commit` 设置生成。 ::: 默认值:`false`。 -### s3queue_enable_logging_to_s3queue_log {#enable_logging_to_s3queue_log} +### `s3queue_enable_logging_to_s3queue_log` {#enable_logging_to_s3queue_log} -启用记录到 `system.s3queue_log`。 +启用日志记录到 `system.s3queue_log`。 默认值:`0`。 -### s3queue_polling_min_timeout_ms {#polling_min_timeout_ms} +### `s3queue_polling_min_timeout_ms` {#polling_min_timeout_ms} -指定 ClickHouse 在进行下一个轮询尝试前等待的最小时间(以毫秒为单位)。 +指定 ClickHouse 在进行下一个轮询尝试之前等待的最短时间(以毫秒为单位)。 -可能的值: +可选值: - 正整数。 默认值:`1000`。 -### s3queue_polling_max_timeout_ms {#polling_max_timeout_ms} +### `s3queue_polling_max_timeout_ms` {#polling_max_timeout_ms} -定义 ClickHouse 在发起下一个轮询尝试前等待的最大时间(以毫秒为单位)。 +定义 ClickHouse 在启动下一个轮询尝试之前等待的最长时间(以毫秒为单位)。 -可能的值: +可选值: - 正整数。 默认值:`10000`。 -### s3queue_polling_backoff_ms {#polling_backoff_ms} +### `s3queue_polling_backoff_ms` {#polling_backoff_ms} -确定在未找到新文件时添加到上一个轮询间隔的额外等待时间。下一个轮询将在前一个间隔和此退避值的总和、或最大间隔中较小者之后发生。 +确定在未找到新文件时,添加到上一个轮询间隔的额外等待时间。下一个轮询在上一个间隔与此退避值的总和,或最大间隔中取较小者后发生。 -可能的值: +可选值: - 正整数。 默认值:`0`。 -### s3queue_tracked_files_limit {#tracked_files_limit} +### `s3queue_tracked_files_limit` {#tracked_files_limit} -允许在使用 'unordered' 模式时限制 ZooKeeper 节点的数量,在 'ordered' 模式下无效。 -如果达到限制,ZooKeeper 节点中最旧的已处理文件将被删除并重新处理。 +如果使用了 'unordered' 模式,可以限制 ZooKeeper 节点的数量,对于 'ordered' 模式则无效。 +如果达到限制,将从 ZooKeeper 节点删除最旧的已处理文件并重新处理。 -可能的值: +可选值: - 正整数。 默认值:`1000`。 -### s3queue_tracked_file_ttl_sec {#tracked_file_ttl_sec} +### `s3queue_tracked_file_ttl_sec` {#tracked_file_ttl_sec} -在 ZooKeeper 节点中存储已处理文件的最大秒数(默认为永久存储),在 'unordered' 模式下有效,在 'ordered' 模式下无效。 -在指定的秒数后,文件将被重新导入。 +最大以秒为单位在 ZooKeeper 节点中存储已处理文件的时间(默认永久存储)对于 'unordered' 模式无效,对于 'ordered' 模式同样无效。 +在指定的秒数之后,文件将被重新导入。 -可能的值: +可选值: - 正整数。 默认值:`0`。 -### s3queue_cleanup_interval_min_ms {#cleanup_interval_min_ms} +### `s3queue_cleanup_interval_min_ms` {#cleanup_interval_min_ms} -针对 'Ordered' 模式。定义一个最小边界,用于重新调度后台任务的间隔,该任务负责维护已追踪文件的 TTL 和最大追踪文件集。 +对于 'Ordered' 模式。定义后台任务的重新调度间隔的最小边界,该任务负责维护跟踪文件的 TTL 和最大跟踪文件集。 默认值:`10000`。 -### s3queue_cleanup_interval_max_ms {#cleanup_interval_max_ms} +### `s3queue_cleanup_interval_max_ms` {#cleanup_interval_max_ms} -针对 'Ordered' 模式。定义一个最大边界,用于重新调度后台任务的间隔,该任务负责维护已追踪文件的 TTL 和最大追踪文件集。 +对于 'Ordered' 模式。定义后台任务的重新调度间隔的最大边界,该任务负责维护跟踪文件的 TTL 和最大跟踪文件集。 默认值:`30000`。 -### s3queue_buckets {#buckets} +### `s3queue_buckets` {#buckets} + +对于 'Ordered' 模式。从 `24.6` 开始可用。如果有多个 S3Queue 表的副本,每个副本都在 keeper 中使用相同的元数据目录,则 `s3queue_buckets` 的值至少需要等于副本的数量。如果同时使用了 `s3queue_processing_threads` 设置,进一步增加 `s3queue_buckets` 的值是有意义的,因为它定义了 `S3Queue` 处理的实际并行性。 + +### `use_persistent_processing_nodes` {#use_persistent_processing_nodes} + +默认情况下,S3Queue 表始终使用临时处理节点,这可能导致数据重复,因为如果 ZooKeeper 会话在 S3Queue 提交已处理文件之前过期,但在开始处理之后则会出现这种情况。此设置强制服务器在会话过期的情况下消除重复的可能性。 + +### `persistent_processing_nodes_ttl_seconds` {#persistent_processing_nodes_ttl_seconds} + +在非正常的服务器终止情况下,如果启用 `use_persistent_processing_nodes`,可能会有未删除的处理节点。此设置定义了可以安全清理这些处理节点的时间段。 -针对 'Ordered' 模式。从 `24.6` 开始可用。如果有多个 S3Queue 表的副本,每个副本使用相同的元数据目录在 keeper 中工作,则 `s3queue_buckets` 的值至少需要等于副本的数量。如果还使用 `s3queue_processing_threads` 设置,则进一步增加 `s3queue_buckets` 的值是有意义的,因为它定义了 `S3Queue` 处理的实际并行性。 +默认值:`3600`(1小时)。 -## 与 S3 相关的设置 {#s3-settings} +## S3 相关设置 {#s3-settings} -引擎支持所有与 S3 相关的设置。有关 S3 设置的更多信息,请参见 [此处](../../../engines/table-engines/integrations/s3.md)。 +引擎支持所有 S3 相关设置。有关 S3 设置的更多信息,请参见 [此处](../../../engines/table-engines/integrations/s3.md)。 ## S3 基于角色的访问 {#s3-role-based-access} s3Queue 表引擎支持基于角色的访问。 -有关为访问存储桶配置角色的步骤,请参阅文档 [此处](/cloud/security/secure-s3)。 +有关配置角色以访问您的存储桶的步骤,请参阅文档 [此处](/cloud/security/secure-s3)。 角色配置完成后,可以通过 `extra_credentials` 参数传递 `roleARN`,如下所示: ```sql @@ -242,21 +254,22 @@ SETTINGS ## S3Queue 有序模式 {#ordered-mode} -`S3Queue` 处理模式允许在 ZooKeeper 中存储更少的元数据,但有一个限制:稍后按时间添加的文件需要具有字母数字更大的名称。 +`S3Queue` 处理模式允许在 ZooKeeper 中存储更少的元数据,但有一个限制,即后添加的文件名称必须在字母数字顺序上大于之前的名称。 -`S3Queue` `ordered` 模式和 `unordered` 一样,支持 `(s3queue_)processing_threads_num` 设置(`s3queue_` 前缀是可选的),它允许控制将在服务器本地处理 `S3` 文件的线程数。此外,`ordered` 模式还引入了另一个名为 `(s3queue_)buckets` 的设置,表示“逻辑线程”。这意味着在分布式场景中,当有多个服务器与 `S3Queue` 表副本时,该设置定义处理单元的数量。例如,每个 `S3Queue` 副本上的每个处理线程将尝试锁定某个用于处理的 `bucket`,每个 `bucket` 通过文件名的哈希关联到特定文件。因此,在分布式场景中,强烈建议将 `(s3queue_)buckets` 设置至少等于或大于副本的数量。设置的桶数量可以大于副本的数量,最优的情况是 `(s3queue_)buckets` 设置等于 `number_of_replicas` 和 `(s3queue_)processing_threads_num` 的乘积。 -不推荐在 `24.6` 版本之前使用 `(s3queue_)processing_threads_num` 设置。 -`(s3queue_)buckets` 设置从 `24.6` 版本开始可用。 +`S3Queue` `ordered` 模式和 `unordered` 一样,支持 `(s3queue_)processing_threads_num` 设置(`s3queue_` 前缀为可选),该设置允许控制在服务器上本地处理 `S3` 文件的线程数。 +此外,`ordered` 模式还引入了名为 `(s3queue_)buckets` 的另一个设置,表示“逻辑线程”。这意味着在分布式场景下,当有多个服务器与 `S3Queue` 表的副本时,此设置定义了处理单元的数量。例如,每个 `S3Queue` 副本上的每个处理线程将尝试锁定某个 `bucket` 以进行处理,每个 `bucket` 通过文件名的哈希与特定文件相关联。因此,在分布式场景中,强烈建议将 `(s3queue_)buckets` 设置至少设置为副本的数量或更大。桶的数量大于副本的数量也是可以的。最优场景是将 `(s3queue_)buckets` 设置等于 `number_of_replicas` 和 `(s3queue_)processing_threads_num` 的乘积。 +不建议在 `24.6` 版本之前使用 `(s3queue_)processing_threads_num` 设置。 +`(s3queue_)buckets` 设置自 `24.6` 版本起可用。 ## 描述 {#description} -`SELECT` 对于流式导入并不是特别有用(除了调试),因为每个文件只能导入一次。实际更为的方式是使用 [物化视图](../../../sql-reference/statements/create/view.md) 创建实时线程。为此: +`SELECT` 对于流式导入并不是特别有用(除非用于调试),因为每个文件只能被导入一次。使用 [物化视图](../../../sql-reference/statements/create/view.md) 创建实时线程更实用。为此: -1. 使用引擎创建一个用于从 S3 中指定路径消费的表,并将其视为数据流。 +1. 使用引擎创建一个表以从 S3 中指定路径进行消费,并将其视为数据流。 2. 创建一个具有所需结构的表。 -3. 创建一个物化视图,以将引擎中的数据转换并放入之前创建的表中。 +3. 创建一个物化视图,将引擎中的数据转换并放入先前创建的表中。 -当 `MATERIALIZED VIEW` 连接引擎时,它会在后台开始收集数据。 +当 `MATERIALIZED VIEW` 连接到引擎时,将开始在后台收集数据。 示例: @@ -278,39 +291,41 @@ SELECT * FROM stats ORDER BY name; ## 虚拟列 {#virtual-columns} - `_path` — 文件路径。 -- `_file` — 文件名称。 +- `_file` — 文件名。 +- `_size` — 文件大小。 +- `_time` — 文件创建时间。 有关虚拟列的更多信息,请参见 [此处](../../../engines/table-engines/index.md#table_engines-virtual_columns)。 ## 路径中的通配符 {#wildcards-in-path} -`path` 参数可以使用类 bash 通配符指定多个文件。要被处理,文件必须存在并匹配整个路径模式。文件列出在 `SELECT` 时确定(而不是在 `CREATE` 时)。 +`path` 参数可以使用类似 bash 的通配符指定多个文件。要进行处理,文件必须存在并与整个路径模式匹配。文件列出在 `SELECT` 时决定(而不是在 `CREATE` 时)。 -- `*` — 替代任意数量的任何字符,但不包括 `/`,包括空字符串。 -- `**` — 替代任意数量的任何字符,包括 `/`,包括空字符串。 +- `*` — 替代任何数量的任意字符(不包括 `/`),包括空字符串。 +- `**` — 替代任何数量的任意字符(包括 `/`),包括空字符串。 - `?` — 替代任意单个字符。 -- `{some_string,another_string,yet_another_one}` — 替代字符串 `'some_string'`, `'another_string'`, `'yet_another_one'` 中的任何一个。 -- `{N..M}` — 替代表 N 到 M 范围内的任何数字,包括两个边界。N 和 M 可以有前导零,例如 `000..078`。 +- `{some_string,another_string,yet_another_one}` — 替代任意字符串 `'some_string', 'another_string', 'yet_another_one'`。 +- `{N..M}` — 替代范围内的任何数值,从 N 到 M,包括两个边界。N 和 M 可以有前导零,例如 `000..078`。 带有 `{}` 的结构类似于 [remote](../../../sql-reference/table-functions/remote.md) 表函数。 ## 限制 {#limitations} -1. 重复行可能是由于: +1. 重复行可能会导致: -- 在文件处理的中间发生异常解析,并通过 `s3queue_loading_retries` 启用重试; +- 在文件处理过程中发生解析异常,并且启用了通过 `s3queue_loading_retries` 的重试; -- 在多个服务器上配置 `S3Queue` 指向相同的路径,且 ZooKeeper 中的 keeper 会话在一个服务器完成已处理文件提交之前到期,这可能导致另一个服务器开始处理该文件,而前一个服务器可能已经部分或全部处理了该文件; +- `S3Queue` 在多个服务器上配置,指向 ZooKeeper 中的相同路径,而 Keeper 会话在一台服务器成功提交已处理文件之前过期,这可能导致另一台服务器接管文件处理,该文件可能已被第一台服务器部分或完全处理;然而,自 25.8 版本以来,如果 `use_persistent_processing_nodes = 1`,则不再存在这种情况。 -- 异常服务器终止。 +- 异常的服务器终止。 -2. 如果在多个服务器上配置 `S3Queue` 指向相同的路径并使用 `Ordered` 模式,则 `s3queue_loading_retries` 将无法工作。这个问题很快会被修复。 +2. 当 `S3Queue` 在多个服务器上配置并指向 ZooKeeper 中的相同路径,并且使用 `Ordered` 模式时,则 `s3queue_loading_retries` 将无效。这个问题将很快修复。 -## 反向检查 {#introspection} +## 内省 {#introspection} -要进行反向检查,请使用 `system.s3queue` 无状态表和 `system.s3queue_log` 持久表。 +要进行内省,请使用 `system.s3queue` 无状态表和 `system.s3queue_log` 持久表。 -1. `system.s3queue`。该表不是持久的,展示 `S3Queue` 的内存状态:当前正在处理的文件、已处理的文件和失败的文件。 +1. `system.s3queue`。此表不是持久的,显示 `S3Queue` 的内存状态:当前正在处理的文件、已处理的文件或失败的文件。 ```sql ┌─statement──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ @@ -352,7 +367,7 @@ exception: 2. `system.s3queue_log`。持久表。具有与 `system.s3queue` 相同的信息,但针对 `processed` 和 `failed` 文件。 -该表具有以下结构: +该表的结构如下: ```sql SHOW CREATE TABLE system.s3queue_log @@ -380,7 +395,7 @@ SETTINGS index_granularity = 8192 │ └────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ ``` -为了使用 `system.s3queue_log`,在服务器配置文件中定义其配置: +为了使用 `system.s3queue_log`,请在服务器配置文件中定义其配置: ```xml diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/s3queue.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/s3queue.md.hash index f094dbd2c1f..17dcd0c74b5 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/s3queue.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/s3queue.md.hash @@ -1 +1 @@ -f5fbb18ef240a13a +af41e4173a40bb02 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/sqlite.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/sqlite.md index 77ec6ce6c5f..be04fd43ea7 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/sqlite.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/sqlite.md @@ -4,6 +4,7 @@ 'sidebar_position': 185 'slug': '/engines/table-engines/integrations/sqlite' 'title': 'SQLite' +'doc_type': 'reference' --- import CloudNotSupportedBadge from '@theme/badges/CloudNotSupportedBadge'; @@ -13,7 +14,7 @@ import CloudNotSupportedBadge from '@theme/badges/CloudNotSupportedBadge'; -该引擎允许将数据导入和导出到 SQLite,并支持直接从 ClickHouse 查询 SQLite 表。 +该引擎允许将数据导入和导出到SQLite,并支持直接从ClickHouse查询SQLite表。 ## 创建表 {#creating-a-table} @@ -27,12 +28,12 @@ CREATE TABLE [IF NOT EXISTS] [db.]table_name **引擎参数** -- `db_path` — SQLite 数据库文件的路径。 -- `table` — SQLite 数据库中的表名。 +- `db_path` — 指向包含数据库的SQLite文件的路径。 +- `table` — SQLite数据库中表的名称。 ## 使用示例 {#usage-example} -展示创建 SQLite 表的查询: +展示了创建SQLite表的查询: ```sql SHOW CREATE TABLE sqlite_db.table2; @@ -47,7 +48,7 @@ CREATE TABLE SQLite.table2 ENGINE = SQLite('sqlite.db','table2'); ``` -从表中返回数据: +返回表中的数据: ```sql SELECT * FROM sqlite_db.table2 ORDER BY col1; @@ -61,7 +62,7 @@ SELECT * FROM sqlite_db.table2 ORDER BY col1; └──────┴───────┘ ``` -**另见** +**另请参阅** - [SQLite](../../../engines/database-engines/sqlite.md) 引擎 - [sqlite](../../../sql-reference/table-functions/sqlite.md) 表函数 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/sqlite.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/sqlite.md.hash index 3ef046bf39e..89c49761d58 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/sqlite.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/sqlite.md.hash @@ -1 +1 @@ -39c98bbcdf7cebc3 +7cc9522415e89a5e diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/time-series.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/time-series.md index ca5dccdde72..bc2da1c33e6 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/time-series.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/time-series.md @@ -1,16 +1,17 @@ --- -'description': '一种表引擎,用于存储时间序列,即与时间戳和标签(或标签)相关联的一组值。' +'description': '一个存储时间序列的表引擎,即一组与时间戳和标签(或标记)相关联的值。' 'sidebar_label': '时间序列' 'sidebar_position': 60 'slug': '/engines/table-engines/special/time_series' 'title': '时间序列引擎' +'doc_type': 'reference' --- import ExperimentalBadge from '@theme/badges/ExperimentalBadge'; import CloudNotSupportedBadge from '@theme/badges/CloudNotSupportedBadge'; -# 时间序列引擎 +# TimeSeries 引擎 @@ -23,8 +24,8 @@ metric_name2[...] = ... ``` :::info -这是一个实验性功能,未来版本可能会以向后不兼容的方式更改。 -使用 [allow_experimental_time_series_table](/operations/settings/settings#allow_experimental_time_series_table) 设置启用时间序列表引擎的使用。 +这是一个实验性功能,未来版本可能会以向后不兼容的方式发生变化。 +启用使用 TimeSeries 表引擎的功能请使用 [allow_experimental_time_series_table](/operations/settings/settings#allow_experimental_time_series_table) 设置。 输入命令 `set allow_experimental_time_series_table = 1`。 ::: @@ -40,24 +41,23 @@ CREATE TABLE name [(columns)] ENGINE=TimeSeries ## 用法 {#usage} -从默认设置开始更容易(允许在不指定列列表的情况下创建 `TimeSeries` 表): +从默认设置开始较为简单(允许在未指定列列表的情况下创建 `TimeSeries` 表): ```sql CREATE TABLE my_table ENGINE=TimeSeries ``` -然后,此表可以通过以下协议使用(必须在服务器配置中分配端口): +然后此表可以与以下协议一起使用(必须在服务器配置中分配端口): - [prometheus remote-write](../../../interfaces/prometheus.md#remote-write) - [prometheus remote-read](../../../interfaces/prometheus.md#remote-read) ## 目标表 {#target-tables} -`TimeSeries` 表没有自己的数据,所有内容都存储在其目标表中。 -这类似于 [物化视图](../../../sql-reference/statements/create/view#materialized-view) 的工作方式, -不同之处在于物化视图有一个目标表, -而 `TimeSeries` 表有三个目标表,分别称为 [data](#data-table)、[tags](#tags-table) 和 [metrics](#metrics-table)。 +`TimeSeries` 表没有自己的数据,所有内容存储在其目标表中。 +这与 [物化视图](../../../sql-reference/statements/create/view#materialized-view) 的工作方式类似, +不同之处在于物化视图只有一个目标表,而 `TimeSeries` 表有三个目标表,分别命名为 [data](#data-table)、[tags](#tags-table) 和 [metrics](#metrics-table)。 -目标表可以在 `CREATE TABLE` 查询中显式指定, +可以在 `CREATE TABLE` 查询中显式指定目标表, 或者 `TimeSeries` 表引擎可以自动生成内部目标表。 目标表如下: @@ -68,55 +68,54 @@ _data_ 表包含与某个标识符相关的时间序列。 _data_ 表必须具有以下列: -| 名称 | 必需? | 默认类型 | 可能类型 | 描述 | +| 名称 | 是否必须 | 默认类型 | 可能的类型 | 描述 | |---|---|---|---|---| -| `id` | [x] | `UUID` | 任意 | 标识指标名称和标签的组合 | +| `id` | [x] | `UUID` | 任何 | 标识指标名称和标签的组合 | | `timestamp` | [x] | `DateTime64(3)` | `DateTime64(X)` | 时间点 | -| `value` | [x] | `Float64` | `Float32` 或 `Float64` | 与 `timestamp` 相关联的值 | - +| `value` | [x] | `Float64` | `Float32` 或 `Float64` | 与 `timestamp` 关联的值 | ### 标签表 {#tags-table} -_tags_ 表包含为指标名称和标签的每个组合计算的标识符。 +_tags_ 表包含为每个指标名称和标签组合计算的标识符。 _tags_ 表必须具有以下列: -| 名称 | 必需? | 默认类型 | 可能类型 | 描述 | +| 名称 | 是否必须 | 默认类型 | 可能的类型 | 描述 | |---|---|---|---|---| -| `id` | [x] | `UUID` | 任意(必须与 [data](#data-table) 表中的 `id` 类型匹配) | `id` 标识指标名称和标签的组合。DEFAULT 表达式指定了如何计算该标识符 | -| `metric_name` | [x] | `LowCardinality(String)` | `String` 或 `LowCardinality(String)` | 指标名称 | -| `` | [ ] | `String` | `String` 或 `LowCardinality(String)` 或 `LowCardinality(Nullable(String))` | 特定标签的值,标签名称和对应列的名称在 [tags_to_columns](#settings) 设置中指定 | -| `tags` | [x] | `Map(LowCardinality(String), String)` | `Map(String, String)` 或 `Map(LowCardinality(String), String)` 或 `Map(LowCardinality(String), LowCardinality(String))` | 标签的映射,不包括标签 `__name__`,该标签包含指标名称,并排除在 [tags_to_columns](#settings) 设置中列出的标签名称 | -| `all_tags` | [ ] | `Map(String, String)` | `Map(String, String)` 或 `Map(LowCardinality(String), String)` 或 `Map(LowCardinality(String), LowCardinality(String))` | 瞬态列,每一行是所有标签的映射,仅排除标签 `__name__`,该标签包含指标名称。该列的唯一目的是在计算 `id` 时使用 | -| `min_time` | [ ] | `Nullable(DateTime64(3))` | `DateTime64(X)` 或 `Nullable(DateTime64(X))` | 具有该 `id` 的时间序列的最小时间戳。如果 [store_min_time_and_max_time](#settings) 设置为 `true`,则创建此列 | -| `max_time` | [ ] | `Nullable(DateTime64(3))` | `DateTime64(X)` 或 `Nullable(DateTime64(X))` | 具有该 `id` 的时间序列的最大时间戳。如果 [store_min_time_and_max_time](#settings) 设置为 `true`,则创建此列 | +| `id` | [x] | `UUID` | 任何(必须与 [data](#data-table) 表中的 `id` 类型匹配) | 一个 `id` 标识指标名称和标签的组合。DEFAULT 表达式指定如何计算该标识符 | +| `metric_name` | [x] | `LowCardinality(String)` | `String` 或 `LowCardinality(String)` | 指标的名称 | +| `` | [ ] | `String` | `String` 或 `LowCardinality(String)` 或 `LowCardinality(Nullable(String))` | 特定标签的值,标签的名称和相应列的名称在 [tags_to_columns](#settings) 设置中指定 | +| `tags` | [x] | `Map(LowCardinality(String), String)` | `Map(String, String)` 或 `Map(LowCardinality(String), String)` 或 `Map(LowCardinality(String), LowCardinality(String))` | 标签的映射,排除标签 `__name__`,包含指标的名称,排除在 [tags_to_columns](#settings) 设置中列出的标签 | +| `all_tags` | [ ] | `Map(String, String)` | `Map(String, String)` 或 `Map(LowCardinality(String), String)` 或 `Map(LowCardinality(String), LowCardinality(String))` | 瞬态列,每行是所有标签的映射,仅排除标签 `__name__`,包含指标的名称。该列的唯一目的是在计算 `id` 时使用 | +| `min_time` | [ ] | `Nullable(DateTime64(3))` | `DateTime64(X)` 或 `Nullable(DateTime64(X))` | 具有该 `id` 的时间序列的最小时间戳。如果 [store_min_time_and_max_time](#settings) 为 `true`,则创建此列 | +| `max_time` | [ ] | `Nullable(DateTime64(3))` | `DateTime64(X)` 或 `Nullable(DateTime64(X))` | 具有该 `id` 的时间序列的最大时间戳。如果 [store_min_time_and_max_time](#settings) 为 `true`,则创建此列 | ### 指标表 {#metrics-table} -_metrics_ 表包含收集的指标的某些信息、这些指标的类型及其描述。 +_metrics_ 表包含收集的指标的一些信息、这些指标的类型及其描述。 _metrics_ 表必须具有以下列: -| 名称 | 必需? | 默认类型 | 可能类型 | 描述 | +| 名称 | 是否必须 | 默认类型 | 可能的类型 | 描述 | |---|---|---|---|---| -| `metric_family_name` | [x] | `String` | `String` 或 `LowCardinality(String)` | 指标系列名称 | -| `type` | [x] | `String` | `String` 或 `LowCardinality(String)` | 指标系列的类型,可能是 "counter"、"gauge"、"summary"、"stateset"、"histogram"、"gaugehistogram" 之一 | -| `unit` | [x] | `String` | `String` 或 `LowCardinality(String)` | 指标中使用的单位 | +| `metric_family_name` | [x] | `String` | `String` 或 `LowCardinality(String)` | 指标系列的名称 | +| `type` | [x] | `String` | `String` 或 `LowCardinality(String)` | 指标系列的类型,可能的值为 "counter"、"gauge"、"summary"、"stateset"、"histogram" 和 "gaugehistogram" | +| `unit` | [x] | `String` | `String` 或 `LowCardinality(String)` | 指标使用的单位 | | `help` | [x] | `String` | `String` 或 `LowCardinality(String)` | 指标的描述 | -插入到 `TimeSeries` 表中的任何行实际上都会存储在这三个目标表中。 -`TimeSeries` 表包含来自 [data](#data-table)、[tags](#tags-table)、[metrics](#metrics-table) 表的所有这些列。 +插入到 `TimeSeries` 表中的任何行实际上都会存储在这三张目标表中。 +`TimeSeries` 表包含来自 [data](#data-table)、[tags](#tags-table) 和 [metrics](#metrics-table) 表的所有列。 ## 创建 {#creation} -有多种方法可以使用 `TimeSeries` 表引擎创建表。 +有多种方法可以创建 `TimeSeries` 表引擎的表。 最简单的语句 ```sql CREATE TABLE my_table ENGINE=TimeSeries ``` -实际上会创建以下表(您可以通过执行 `SHOW CREATE TABLE my_table` 来查看): +实际上会创建以下表(可以通过执行 `SHOW CREATE TABLE my_table` 查看): ```sql CREATE TABLE my_table @@ -143,15 +142,15 @@ METRICS ENGINE = ReplacingMergeTree ORDER BY metric_family_name METRICS INNER UUID '01234567-89ab-cdef-0123-456789abcdef' ``` -所以这些列是自动生成的,并且在此语句中还有三个内部 UUID - -每个内部目标表对应一个 UUID。 +因此,列是自动生成的,并且在该语句中有三个内部 UUID - +每个内部目标表一个。 (内部 UUID 通常不会显示,直到设置 [show_table_uuid_in_table_create_query_if_not_nil](../../../operations/settings/settings#show_table_uuid_in_table_create_query_if_not_nil) -被设置为 `true`。) +为设置。) -内部目标表的名称类似于 `.inner_id.data.xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`, -`.inner_id.tags.xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`,`.inner_id.metrics.xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx` -每个目标表的列是主 `TimeSeries` 表的列的子集: +内部目标表的名称类似于 `.inner_id.data.xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`, +`.inner_id.tags.xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`, `.inner_id.metrics.xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx` +每个目标表的列是主 `TimeSeries` 表的列子集: ```sql CREATE TABLE default.`.inner_id.data.xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx` @@ -191,9 +190,10 @@ ENGINE = ReplacingMergeTree ORDER BY metric_family_name ``` -## 调整列的类型 {#adjusting-column-types} +## 调整列类型 {#adjusting-column-types} -您可以通过在定义主表时显式指定几乎任何内部目标表的列的类型进行调整。例如, +您可以通过在定义主表时显式指定它们来调整内部目标表的几乎任何列的类型。 +例如, ```sql CREATE TABLE my_table @@ -202,7 +202,7 @@ CREATE TABLE my_table ) ENGINE=TimeSeries ``` -这将使内部 [data](#data-table) 表以微秒而不是毫秒存储时间戳: +将使内部 [data](#data-table) 表将时间戳以微秒而不是毫秒存储: ```sql CREATE TABLE default.`.inner_id.data.xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx` @@ -217,49 +217,57 @@ ORDER BY (id, timestamp) ## `id` 列 {#id-column} -`id` 列包含标识符,每个标识符是为指标名称和标签的组合计算的。 -`id` 列的 DEFAULT 表达式是将用于计算这种标识符的表达式。 +`id` 列包含标识符,每个标识符都是为指标名称和标签的组合计算的。 +`id` 列的 DEFAULT 表达式是用于计算此类标识符的表达式。 可以通过显式指定它们来调整 `id` 列的类型和该表达式: ```sql CREATE TABLE my_table ( - id UInt64 DEFAULT sipHash64(metric_name, all_tags) -) ENGINE=TimeSeries + id UInt64 DEFAULT sipHash64(metric_name, all_tags) +) +ENGINE=TimeSeries ``` ## `tags` 和 `all_tags` 列 {#tags-and-all-tags} -有两个包含标签映射的列 - `tags` 和 `all_tags`。在此示例中,它们的含义相同,然而,如果使用 `tags_to_columns` 设置时它们可以不同。该设置允许指定特定标签应存储在单独的列中,而不是存储在 `tags` 列中的映射中: +有两个包含标签映射的列 - `tags` 和 `all_tags`。在这个例子中,它们的意思相同,但如果使用了设置 `tags_to_columns`,它们可能会不同。此设置允许指定某个特定标签应存储在单独的列中,而不是存储在 `tags` 列中的映射内: ```sql -CREATE TABLE my_table ENGINE=TimeSeries SETTINGS = {'instance': 'instance', 'job': 'job'} +CREATE TABLE my_table +ENGINE = TimeSeries +SETTINGS tags_to_columns = {'instance': 'instance', 'job': 'job'} ``` -此语句将在 `my_table` 及其内部 [tags](#tags-table) 目标表的定义中添加列 +该语句将添加列: + ```sql `instance` String, `job` String -```。在此情况下,`tags` 列将不包含标签 `instance` 和 `job`, -但 `all_tags` 列将包含它们。`all_tags` 列是瞬态的,唯一的目的在于用于计算 `id` 列的 DEFAULT 表达式。 +``` -列的类型可以通过显式指定进行调整: +到 `my_table` 和其内部 [tags](#tags-table) 目标表的定义中。在这种情况下,`tags` 列将不包含标签 `instance` 和 `job`, +但 `all_tags` 列将包含它们。`all_tags` 列是瞬态的,唯一目的是在 `id` 列的 DEFAULT 表达式中使用。 + +列的类型可以通过显式指定它们来调整: ```sql -CREATE TABLE my_table (instance LowCardinality(String), job LowCardinality(Nullable(String))) -ENGINE=TimeSeries SETTINGS = {'instance': 'instance', 'job': 'job'} +CREATE TABLE my_table ( + instance LowCardinality(String), + job LowCardinality(Nullable(String)) +) +ENGINE=TimeSeries +SETTINGS tags_to_columns = {'instance': 'instance', 'job': 'job'} ``` ## 内部目标表的表引擎 {#inner-table-engines} 默认情况下,内部目标表使用以下表引擎: -- [data](#data-table) 表使用 [MergeTree](../mergetree-family/mergetree); -- [tags](#tags-table) 表使用 [AggregatingMergeTree](../mergetree-family/aggregatingmergetree),因为相同的数据通常多次插入到此表中,因此我们需要一种方式 -去除重复,并且因为需要对 `min_time` 和 `max_time` 列进行聚合; -- [metrics](#metrics-table) 表使用 [ReplacingMergeTree](../mergetree-family/replacingmergetree),因为相同的数据通常多次插入到此表中,因此我们需要一种方式 -去除重复。 +- [data](#data-table) 表使用 [MergeTree](../mergetree-family/mergetree); +- [tags](#tags-table) 表使用 [AggregatingMergeTree](../mergetree-family/aggregatingmergetree),因为相同数据经常多次插入此表,因此我们需要一种删除重复项的方法,同时因为需要对列 `min_time` 和 `max_time` 进行聚合; +- [metrics](#metrics-table) 表使用 [ReplacingMergeTree](../mergetree-family/replacingmergetree),因为相同数据经常多次插入此表,因此我们需要一种删除重复项的方法。 -如果指定了其他表引擎,也可以用于内部目标表: +也可以使用其他表引擎用于内部目标表,如下所示: ```sql CREATE TABLE my_table ENGINE=TimeSeries @@ -295,11 +303,11 @@ CREATE TABLE my_table ENGINE=TimeSeries DATA data_for_my_table TAGS tags_for_my_ | 名称 | 类型 | 默认值 | 描述 | |---|---|---|---| -| `tags_to_columns` | Map | {} | 指定应放入 [tags](#tags-table) 表中单独列的标签的映射。语法: `{'tag1': 'column1', 'tag2' : column2, ...}` | -| `use_all_tags_column_to_generate_id` | Bool | true | 在生成用于计算时间序列标识符的表达式时,此标志启用在该计算中使用 `all_tags` 列 | -| `store_min_time_and_max_time` | Bool | true | 如果设置为 true,则该表将为每个时间序列存储 `min_time` 和 `max_time` | -| `aggregate_min_time_and_max_time` | Bool | true | 在创建内部目标 `tags` 表时,此标志启用使用 `SimpleAggregateFunction(min, Nullable(DateTime64(3)))` 而不是仅将 `Nullable(DateTime64(3))` 作为 `min_time` 列的类型,`max_time` 列也是如此 | -| `filter_by_min_time_and_max_time` | Bool | true | 如果设置为 true,则该表将使用 `min_time` 和 `max_time` 列进行过滤时间序列 | +| `tags_to_columns` | Map | {} | 映射,指定哪些标签应放入 [tags](#tags-table) 表的单独列中。语法: `{'tag1': 'column1', 'tag2' : column2, ...}` | +| `use_all_tags_column_to_generate_id` | Bool | true | 在生成计算时间序列标识符的表达式时,此标志启用在该计算中使用 `all_tags` 列 | +| `store_min_time_and_max_time` | Bool | true | 如果设置为 true,则表将为每个时间序列存储 `min_time` 和 `max_time` | +| `aggregate_min_time_and_max_time` | Bool | true | 在创建内部目标 `tags` 表时,此标志启用使用 `SimpleAggregateFunction(min, Nullable(DateTime64(3)))` 而不是仅仅 `Nullable(DateTime64(3))` 作为 `min_time` 列的类型,对于 `max_time` 列也是如此 | +| `filter_by_min_time_and_max_time` | Bool | true | 如果设置为 true,则表将使用 `min_time` 和 `max_time` 列来过滤时间序列 | # 函数 {#functions} diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/time-series.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/time-series.md.hash index c40945511d2..e6407ab2536 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/time-series.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/time-series.md.hash @@ -1 +1 @@ -47ca1152facf1ab3 +85611685e8365ae8 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/ytsaurus.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/ytsaurus.md new file mode 100644 index 00000000000..9cac9c43595 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/ytsaurus.md @@ -0,0 +1,131 @@ +--- +'description': '表引擎,允许从 YTsaurus 集群导入数据。' +'sidebar_label': 'YTsaurus' +'sidebar_position': 185 +'slug': '/engines/table-engines/integrations/ytsaurus' +'title': 'YTsaurus' +'keywords': +- 'YTsaurus' +- 'table engine' +'doc_type': 'reference' +--- + +import CloudNotSupportedBadge from '@theme/badges/CloudNotSupportedBadge'; +import ExperimentalBadge from '@theme/badges/ExperimentalBadge'; + + +# YTsaurus + + + + +YTsaurus 表引擎允许您从 YTsaurus 集群导入数据。 + +## 创建表 {#creating-a-table} + +```sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name +( + name1 [type1], + name2 [type2], ... +) ENGINE = YTsaurus('http_proxy_url', 'cypress_path', 'oauth_token') +``` + +:::info +这是一个实验性功能,未来版本可能以向后不兼容的方式更改。 +启用 YTsaurus 表引擎的使用 +使用设置 [`allow_experimental_ytsaurus_table_engine`](/operations/settings/settings#allow_experimental_ytsaurus_table_engine)。 + +您可以通过以下方式进行设置: + +`SET allow_experimental_ytsaurus_table_engine = 1`。 +::: + +**引擎参数** + +- `http_proxy_url` — YTsaurus http 代理的 URL。 +- `cypress_path` — 数据源的 Cypress 路径。 +- `oauth_token` — OAuth 令牌。 + +## 使用示例 {#usage-example} + +显示创建 YTsaurus 表的查询: + +```sql title="Query" +SHOW CREATE TABLE yt_saurus; +``` + +```sql title="Response" +CREATE TABLE yt_saurus +( + `a` UInt32, + `b` String +) +ENGINE = YTsaurus('http://localhost:8000', '//tmp/table', 'password') +``` + +要从表中返回数据,请运行: + +```sql title="Query" +SELECT * FROM yt_saurus; +``` + +```response title="Response" +┌──a─┬─b──┐ +│ 10 │ 20 │ +└────┴────┘ +``` + +## 数据类型 {#data-types} + +### 原始数据类型 {#primitive-data-types} + +| YTsaurus 数据类型 | Clickhouse 数据类型 | +| ------------------ | ---------------------- | +| `int8` | `Int8` | +| `int16` | `Int16` | +| `int32` | `Int32` | +| `int64` | `Int64` | +| `uint8` | `UInt8` | +| `uint16` | `UInt16` | +| `uint32` | `UInt32` | +| `uint64` | `UInt64` | +| `float` | `Float32` | +| `double` | `Float64` | +| `boolean` | `Bool` | +| `string` | `String` | +| `utf8` | `String` | +| `json` | `JSON` | +| `yson(type_v3)` | `JSON` | +| `uuid` | `UUID` | +| `date32` | `Date`(尚不支持) | +| `datetime64` | `Int64` | +| `timestamp64` | `Int64` | +| `interval64` | `Int64` | +| `date` | `Date`(尚不支持) | +| `datetime` | `DateTime` | +| `timestamp` | `DateTime64(6)` | +| `interval` | `UInt64` | +| `any` | `String` | +| `null` | `Nothing` | +| `void` | `Nothing` | +| `T` 和 `required = False` | `Nullable(T)` | + +### 复合类型 {#composite-data-types} + +| YTsaurus 数据类型 | Clickhouse 数据类型 | +| ------------------ | ------------------- | +| `decimal` | `Decimal` | +| `optional` | `Nullable` | +| `list` | `Array` | +| `struct` | `NamedTuple` | +| `tuple` | `Tuple` | +| `variant` | `Variant` | +| `dict` | `Array(Tuple(...)) | +| `tagged` | `T` | + +**另见** + +- [ytsaurus](../../../sql-reference/table-functions/ytsaurus.md) 表函数 +- [ytsaurus 数据模式](https://ytsaurus.tech/docs/en/user-guide/storage/static-schema) +- [ytsaurus 数据类型](https://ytsaurus.tech/docs/en/user-guide/storage/data-types) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/ytsaurus.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/ytsaurus.md.hash new file mode 100644 index 00000000000..873fe827ec1 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/integrations/ytsaurus.md.hash @@ -0,0 +1 @@ +78842e942d27015f diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/log-family/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/log-family/index.md index 3c6c4ed415b..3e6c1b7afd3 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/log-family/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/log-family/index.md @@ -1,54 +1,55 @@ --- 'description': 'Log Engine Family 的文档' -'sidebar_label': '日志系列' +'sidebar_label': '日志家族' 'sidebar_position': 20 'slug': '/engines/table-engines/log-family/' -'title': '日志引擎系列' +'title': '日志引擎家族' +'doc_type': 'guide' --- -# 日志引擎家族 +# Log engine family -这些引擎是针对需要快速写入许多小表(最多约100万行)并能够稍后整体读取它们的场景开发的。 +这些引擎是为需要快速写入许多小表(大约 100 万行)并在稍后将其整体读取的场景而开发的。 -家族引擎: +该系列的引擎: -| 日志引擎 | +| Log Engines | |---------------------------------------------------------------------| | [StripeLog](/engines/table-engines/log-family/stripelog.md) | | [Log](/engines/table-engines/log-family/log.md) | | [TinyLog](/engines/table-engines/log-family/tinylog.md) | -`Log` 家族表引擎可以将数据存储到 [HDFS](/engines/table-engines/integrations/hdfs) 或 [S3](/engines/table-engines/mergetree-family/mergetree.md/#table_engine-mergetree-s3) 分布式文件系统中。 +`Log` 系列表引擎可以将数据存储到 [HDFS](/engines/table-engines/integrations/hdfs) 或 [S3](/engines/table-engines/mergetree-family/mergetree.md/#table_engine-mergetree-s3) 分布式文件系统中。 -:::warning 此引擎不适用于日志数据。 -尽管名称中包含 *Log,* 日志表引擎并不意味着用于存储日志数据。它们仅应在小规模数据需要快速写入的情况下使用。 +:::warning 此引擎不适合用于日志数据。 +尽管名称中带有 *Log,表引擎并不适合存储日志数据。它们只能用于需要快速写入的小容量数据。 ::: -## 公共属性 {#common-properties} +## Common properties {#common-properties} 引擎: -- 在磁盘上存储数据。 +- 将数据存储在磁盘上。 -- 写入时将数据追加到文件末尾。 +- 在写入时将数据附加到文件末尾。 - 支持并发数据访问的锁。 - 在 `INSERT` 查询期间,表被锁定,其他读取和写入数据的查询都等待表解锁。如果没有数据写入查询,则可以并发执行任意数量的数据读取查询。 + 在 `INSERT` 查询期间,表会被锁定,其他读取和写入数据的查询都在等待表解锁。如果没有数据写入查询,则可以同时执行任意数量的数据读取查询。 -- 不支持 [变更](/sql-reference/statements/alter#mutations)。 +- 不支持 [mutations](/sql-reference/statements/alter#mutations)。 - 不支持索引。 这意味着对数据范围的 `SELECT` 查询效率不高。 -- 不以原子方式写入数据。 +- 不按原子方式写入数据。 - 如果写入操作被打断,例如服务器异常关闭,则可能会得到一个包含损坏数据的表。 + 如果某些操作中断了写入操作,例如异常服务器关闭,您可能会得到一个具有损坏数据的表。 -## 区别 {#differences} +## Differences {#differences} -`TinyLog` 引擎是家族中最简单的,提供的功能最少,效率最低。`TinyLog` 引擎不支持多个线程在单个查询中并行读取数据。它的读取速度比其他支持单个查询并行读取的家族引擎慢,并且使用的文件描述符几乎与 `Log` 引擎一样多,因为它在单独的文件中存储每一列。仅在简单的场景中使用它。 +`TinyLog` 引擎是该系列中最简单的,功能最差,效率最低。`TinyLog` 引擎不支持单个查询中多个线程的并行数据读取。它的读取速度比支持单个查询并行读取的该系列其他引擎慢,而且由于将每列存储在单独的文件中,它几乎使用了与 `Log` 引擎相同数量的文件描述符。仅在简单场景中使用它。 -`Log` 和 `StripeLog` 引擎支持并行数据读取。在读取数据时,ClickHouse 使用多个线程。每个线程处理一个独立的数据块。`Log` 引擎为表的每一列使用一个单独的文件。`StripeLog` 将所有数据存储在一个文件中。结果是,`StripeLog` 引擎使用的文件描述符更少,但在读取数据时,`Log` 引擎提供更高的效率。 +`Log` 和 `StripeLog` 引擎支持并行数据读取。在读取数据时,ClickHouse 使用多个线程。每个线程处理一个单独的数据块。`Log` 引擎为表的每一列使用一个单独的文件,而 `StripeLog` 将所有数据存储在一个文件中。因此,`StripeLog` 引擎使用的文件描述符较少,但在读取数据时,`Log` 引擎提供了更高的效率。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/log-family/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/log-family/index.md.hash index e657cc8536d..bcc76776c1f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/log-family/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/log-family/index.md.hash @@ -1 +1 @@ -26a2ea3004cc8f4a +14e28978878cc7f2 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/log-family/log.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/log-family/log.md index eae541bf2ca..ff597217417 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/log-family/log.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/log-family/log.md @@ -3,17 +3,18 @@ 'slug': '/engines/table-engines/log-family/log' 'toc_priority': 33 'toc_title': 'Log' -'title': '日志' +'title': 'Log' +'doc_type': 'reference' --- -# 日志 +# Log -该引擎属于 `Log` 引擎系列。请参阅 [日志引擎系列](../../../engines/table-engines/log-family/index.md) 文章中的 `Log` 引擎的常见属性及其差异。 +该引擎属于 `Log` 引擎系列。有关 `Log` 引擎的共同属性及其在 [Log Engine Family](../../../engines/table-engines/log-family/index.md) 文章中的差异请参阅。 -`Log` 与 [TinyLog](../../../engines/table-engines/log-family/tinylog.md) 的不同之处在于,与列文件一起存在一个小文件 "marks"。这些标记在每个数据块上写入,包含指示在文件中开始读取的位置的偏移量,以跳过指定的行数。这使得可以在多个线程中读取表数据。 -对于并发数据访问,读取操作可以同时进行,而写入操作会阻塞读取和彼此。 -`Log` 引擎不支持索引。同样,如果写入表失败,则表会损坏,读取时将返回错误。`Log` 引擎适用于临时数据、单次写入表以及测试或演示目的。 +`Log` 与 [TinyLog](../../../engines/table-engines/log-family/tinylog.md) 的不同之处在于,列文件旁边有一个小的 "marks" 文件。这些标记在每个数据块上写入,包含指示从哪里开始读取文件以跳过指定行数的偏移量。这使得能够在多个线程中读取表数据。 +对于并发数据访问,读取操作可以同时进行,而写入操作则会阻塞读取和彼此之间的操作。 +`Log` 引擎不支持索引。如果写入表失败,表将损坏,读取将返回错误。`Log` 引擎适合临时数据、只写表以及测试或演示目的。 ## 创建表 {#table_engines-log-creating-a-table} @@ -30,24 +31,24 @@ CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] ## 写入数据 {#table_engines-log-writing-the-data} -`Log` 引擎通过将每列写入自己的文件来有效存储数据。对于每个表,Log 引擎会在指定的存储路径写入以下文件: +`Log` 引擎通过将每列写入其自己的文件来高效存储数据。对于每个表,Log 引擎在指定的存储路径写入以下文件: -- `.bin`:每个列的数据文件,包含序列化和压缩的数据。 -`__marks.mrk`:标记文件,存储每个插入的数据块的偏移量和行计数。标记用于通过允许引擎在读取时跳过无关的数据块,从而促进高效的查询执行。 +- `.bin`:每列的数据文件,包含序列化和压缩的数据。 +`__marks.mrk`:标记文件,存储每个插入的数据块的偏移量和行数。标记用于通过允许引擎在读取时跳过无关的数据块来促进高效查询执行。 ### 写入过程 {#writing-process} 当数据写入 `Log` 表时: 1. 数据被序列化并压缩成块。 -2. 对于每列,压缩的数据被附加到其各自的 `.bin` 文件中。 -3. 在 `__marks.mrk` 文件中添加相应条目,以记录新插入数据的偏移量和行计数。 +2. 对于每一列,将压缩的数据附加到其各自的 `.bin` 文件中。 +3. 将相应的条目添加到 `__marks.mrk` 文件中,以记录新插入数据的偏移量和行数。 ## 读取数据 {#table_engines-log-reading-the-data} -带有标记的文件允许 ClickHouse 并行读取数据。这意味着 `SELECT` 查询以不可预测的顺序返回行。使用 `ORDER BY` 子句对行进行排序。 +包含标记的文件允许 ClickHouse 并行读取数据。这意味着 `SELECT` 查询返回的行顺序是不可预测的。使用 `ORDER BY` 子句对行进行排序。 -## 用法示例 {#table_engines-log-example-of-use} +## 使用示例 {#table_engines-log-example-of-use} 创建一个表: @@ -68,9 +69,9 @@ INSERT INTO log_table VALUES (now(),'REGULAR','The first regular message') INSERT INTO log_table VALUES (now(),'REGULAR','The second regular message'),(now(),'WARNING','The first warning message') ``` -我们使用两个 `INSERT` 查询在 `.bin` 文件中创建两个数据块。 +我们使用了两个 `INSERT` 查询在 `.bin` 文件中创建了两个数据块。 -ClickHouse 在选择数据时使用多个线程。每个线程读取一个单独的数据块,并在完成时独立返回结果行。因此,输出中行块的顺序可能与输入中的相同块的顺序不匹配。例如: +ClickHouse 在选择数据时使用多个线程。每个线程读取一个独立的数据块,并在完成时独立返回结果行。因此,输出中的行块顺序可能与输入中的相同块顺序不匹配。例如: ```sql SELECT * FROM log_table @@ -86,7 +87,7 @@ SELECT * FROM log_table └─────────────────────┴──────────────┴───────────────────────────┘ ``` -对结果进行排序(默认按升序排列): +对结果进行排序(默认升序): ```sql SELECT * FROM log_table ORDER BY timestamp diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/log-family/log.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/log-family/log.md.hash index a32fa19f370..04ae8ed60a1 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/log-family/log.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/log-family/log.md.hash @@ -1 +1 @@ -0e206bcbab741ace +08642bd75e5a49ca diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/log-family/stripelog.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/log-family/stripelog.md index ef6e3ccc0cf..2049ffcee2d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/log-family/stripelog.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/log-family/stripelog.md @@ -4,14 +4,15 @@ 'toc_priority': 32 'toc_title': 'StripeLog' 'title': 'StripeLog' +'doc_type': 'reference' --- # StripeLog -该引擎属于日志引擎系列。有关日志引擎的通用属性及其差异,请参阅 [Log Engine Family](../../../engines/table-engines/log-family/index.md) 文章。 +此引擎属于日志引擎系列。有关日志引擎的共同属性及其在 [Log Engine Family](../../../engines/table-engines/log-family/index.md) 文章中的区别,请参见相关内容。 -在需要写入许多表且数据量较小(少于 100 万行)的场景中使用此引擎。例如,此表可用于存储需要原子处理的传入数据批次。此类型的表在 ClickHouse 服务器上可以有效地使用 100k 个实例。当需要大量表时,应优先使用此表引擎而非 [Log](./log.md),尽管这会影响读取效率。 +在需要写入多个数据量小(少于 1 百万行)的表的场景中使用此引擎。例如,此表可用于存储需要进行原子处理的传入数据批次。此类型的表可以在 ClickHouse 服务器上并存 100k 个实例。在需要大量表时,应优先选择此表引擎,而不是 [Log](./log.md),尽管这样做会牺牲读取效率。 ## 创建表 {#table_engines-stripelog-creating-a-table} @@ -24,26 +25,26 @@ CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] ) ENGINE = StripeLog ``` -请参阅 [CREATE TABLE](/sql-reference/statements/create/table) 查询的详细描述。 +请参见 [CREATE TABLE](/sql-reference/statements/create/table) 查询的详细描述。 ## 写入数据 {#table_engines-stripelog-writing-the-data} -`StripeLog` 引擎将所有列存储在一个文件中。对于每个 `INSERT` 查询,ClickHouse 将数据块附加到表文件的末尾,一次写入一列。 +`StripeLog` 引擎将所有列存储在一个文件中。对于每个 `INSERT` 查询,ClickHouse 会将数据块附加到表文件的末尾,逐列写入数据。 -对于每个表,ClickHouse 写入以下文件: +对于每个表,ClickHouse 写入文件: - `data.bin` — 数据文件。 -- `index.mrk` — 具有标记的文件。标记包含插入的每个数据块中每一列的偏移量。 +- `index.mrk` — 带有标记的文件。标记包含每个插入的数据块每列的偏移量。 `StripeLog` 引擎不支持 `ALTER UPDATE` 和 `ALTER DELETE` 操作。 ## 读取数据 {#table_engines-stripelog-reading-the-data} -包含标记的文件使 ClickHouse 能够并行读取数据。这意味着 `SELECT` 查询返回的行顺序是不确定的。使用 `ORDER BY` 子句对行进行排序。 +带有标记的文件允许 ClickHouse 并行读取数据。这意味着 `SELECT` 查询以不可预测的顺序返回行。使用 `ORDER BY` 子句对行进行排序。 ## 使用示例 {#table_engines-stripelog-example-of-use} -创建一个表: +创建表: ```sql CREATE TABLE stripe_log_table @@ -62,9 +63,9 @@ INSERT INTO stripe_log_table VALUES (now(),'REGULAR','The first regular message' INSERT INTO stripe_log_table VALUES (now(),'REGULAR','The second regular message'),(now(),'WARNING','The first warning message') ``` -我们使用两个 `INSERT` 查询在 `data.bin` 文件中创建两个数据块。 +我们使用了两个 `INSERT` 查询在 `data.bin` 文件中创建了两个数据块。 -ClickHouse 在选择数据时使用多个线程。每个线程读取单独的数据块,并在完成时独立返回结果行。因此,输出中行块的顺序在大多数情况下与输入中相同块的顺序不匹配。例如: +ClickHouse 在选择数据时使用多个线程。每个线程独立读取一个数据块,并在完成后返回结果行。因此,输出中的行块顺序在大多数情况下与输入中的同一块顺序不匹配。例如: ```sql SELECT * FROM stripe_log_table diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/log-family/stripelog.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/log-family/stripelog.md.hash index 6a58cede329..3d69c813b78 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/log-family/stripelog.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/log-family/stripelog.md.hash @@ -1 +1 @@ -288f1e7c2c04bccd +aba847eeb9e8d410 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/log-family/tinylog.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/log-family/tinylog.md index f0862fb5dc6..8a7bf5454a1 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/log-family/tinylog.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/log-family/tinylog.md @@ -4,26 +4,27 @@ 'toc_priority': 34 'toc_title': 'TinyLog' 'title': 'TinyLog' +'doc_type': 'reference' --- # TinyLog -该引擎属于日志引擎系列。有关日志引擎的公共属性及其差异,请参见 [Log Engine Family](../../../engines/table-engines/log-family/index.md)。 +该引擎属于日志引擎家族。有关日志引擎的共同属性及其差异,请参见 [Log Engine Family](../../../engines/table-engines/log-family/index.md)。 -该表引擎通常用于一次写入方法:一次写入数据,然后根据需要读取多次。例如,您可以使用 `TinyLog` 类型的表来处理小批量的中间数据。请注意,在大量小表中存储数据效率较低。 +此表引擎通常采用一次写入的方法:一次性写入数据,然后根据需要读取多次。例如,您可以使用 `TinyLog` 类型的表来处理小批量的中间数据。请注意,将数据存储在大量小表中效率较低。 -查询在单一流中执行。换句话说,该引擎旨在处理相对较小的表(最多约 1,000,000 行)。如果您有许多小表,使用此表引擎是有意义的,因为它比 [Log](../../../engines/table-engines/log-family/log.md) 引擎更简单(需要打开的文件更少)。 +查询在单个流中执行。换句话说,这个引擎旨在用于相对较小的表(最多约 1,000,000 行)。如果您有许多小表,可使用此表引擎,因为它比 [Log](../../../engines/table-engines/log-family/log.md) 引擎更简单(需要打开的文件更少)。 ## Characteristics {#characteristics} -- **简单结构**:与 Log 引擎不同,TinyLog 不使用标记文件。这减少了复杂性,但也限制了对大数据集的性能优化。 -- **单流查询**:对 TinyLog 表的查询在单一流中执行,使其适合处理相对较小的表,通常最多 1,000,000 行。 -- **适合小表**:TinyLog 引擎的简单性使其在管理许多小表时具有优势,因为与 Log 引擎相比,它需要更少的文件操作。 +- **更简单的结构**:与 Log 引擎不同,TinyLog 不使用标记文件。这减少了复杂性,但也限制了对大数据集的性能优化。 +- **单流查询**:对 TinyLog 表的查询在单个流中执行,适用于相对较小的表,通常最多 1,000,000 行。 +- **对小表高效**:TinyLog 引擎的简单性使其在管理许多小表时具有优势,因为与 Log 引擎相比,它需要更少的文件操作。 与 Log 引擎不同,TinyLog 不使用标记文件。这减少了复杂性,但也限制了对更大数据集的性能优化。 -## Creating a Table {#table_engines-tinylog-creating-a-table} +## 创建表 {#table_engines-tinylog-creating-a-table} ```sql CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] @@ -34,19 +35,19 @@ CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] ) ENGINE = TinyLog ``` -有关 [CREATE TABLE](/sql-reference/statements/create/table) 查询的详细描述,请参见。 +请参阅 [CREATE TABLE](/sql-reference/statements/create/table) 查询的详细描述。 -## Writing the Data {#table_engines-tinylog-writing-the-data} +## 写入数据 {#table_engines-tinylog-writing-the-data} -`TinyLog` 引擎将所有列存储在一个文件中。对于每个 `INSERT` 查询,ClickHouse 将数据块附加到表文件的末尾,逐列写入数据。 +`TinyLog` 引擎将所有列存储在一个文件中。对于每个 `INSERT` 查询,ClickHouse 会将数据块附加到表文件的末尾,逐列写入。 -对于每个表,ClickHouse 写入以下文件: +对于每个表,ClickHouse 写入文件: - `.bin`:每列的数据文件,包含序列化和压缩的数据。 `TinyLog` 引擎不支持 `ALTER UPDATE` 和 `ALTER DELETE` 操作。 -## Example of Use {#table_engines-tinylog-example-of-use} +## 用法示例 {#table_engines-tinylog-example-of-use} 创建表: @@ -69,7 +70,7 @@ INSERT INTO tiny_log_table VALUES (now(),'REGULAR','The second regular message') 我们使用了两个 `INSERT` 查询在 `.bin` 文件中创建了两个数据块。 -ClickHouse 使用单一流选择数据。结果,输出中行块的顺序与输入中相同块的顺序一致。例如: +ClickHouse 使用单个流选择数据。结果是输出中行块的顺序与输入中相同块的顺序一致。例如: ```sql SELECT * FROM tiny_log_table diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/log-family/tinylog.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/log-family/tinylog.md.hash index 980f3425f7e..0514a134354 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/log-family/tinylog.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/log-family/tinylog.md.hash @@ -1 +1 @@ -4f43b4e1a44fdfce +2e75aa9932146bde diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/aggregatingmergetree.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/aggregatingmergetree.md index 00768ab35cd..1ebe2cf5275 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/aggregatingmergetree.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/aggregatingmergetree.md @@ -1,29 +1,30 @@ --- -'description': '用单行替换所有具有相同主键(或更准确地说,具有相同的 [排序键](../../../engines/table-engines/mergetree-family/mergetree.md))的行(在单个数据分区内),该行存储聚合函数状态的组合。' +'description': '用单行替换所有具有相同主键(或更准确地说,具有相同[排序键](../../../engines/table-engines/mergetree-family/mergetree.md))的行(在单个数据分区中),该行存储聚合函数状态的组合。' 'sidebar_label': 'AggregatingMergeTree' 'sidebar_position': 60 'slug': '/engines/table-engines/mergetree-family/aggregatingmergetree' 'title': 'AggregatingMergeTree' +'doc_type': 'reference' --- # AggregatingMergeTree -该引擎继承自 [MergeTree](/engines/table-engines/mergetree-family/versionedcollapsingmergetree),更改了数据部分合并的逻辑。ClickHouse 用同一主键(更准确地说,用相同的 [排序键](../../../engines/table-engines/mergetree-family/mergetree.md))替换所有行(在单个数据部分内),取而代之的是存储聚合函数状态组合的单行。 +该引擎继承自 [MergeTree](/engines/table-engines/mergetree-family/versionedcollapsingmergetree),改变了数据部分合并的逻辑。 ClickHouse 用单行(在单个数据部分内)替换所有具有相同主键(更准确地说,具有相同的 [排序键](../../../engines/table-engines/mergetree-family/mergetree.md))的行,该行存储聚合函数状态的组合。 -您可以使用 `AggregatingMergeTree` 表进行增量数据聚合,包括聚合的物化视图。 +您可以使用 `AggregatingMergeTree` 表进行增量数据聚合,包括用于聚合物化视图。 -在下面的视频中,您可以看到如何使用 AggregatingMergeTree 和聚合函数的示例: +您可以在下面的视频中查看如何使用 AggregatingMergeTree 和聚合函数的示例:
-该引擎处理所有类型的列,如下所示: +该引擎处理所有类型的列: -## [AggregateFunction](../../../sql-reference/data-types/aggregatefunction.md) {#aggregatefunction} -## [SimpleAggregateFunction](../../../sql-reference/data-types/simpleaggregatefunction.md) {#simpleaggregatefunction} +- [`AggregateFunction`](../../../sql-reference/data-types/aggregatefunction.md) +- [`SimpleAggregateFunction`](../../../sql-reference/data-types/simpleaggregatefunction.md) -如果使用 `AggregatingMergeTree` 能够将行数按数量级减少,则是合适的选择。 +如果 `AggregatingMergeTree` 可以将行数减少几个数量级,则使用它是合适的。 ## 创建表 {#creating-a-table} @@ -45,14 +46,14 @@ CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] **查询子句** -在创建 `AggregatingMergeTree` 表时,所需的 [子句](../../../engines/table-engines/mergetree-family/mergetree.md) 与创建 `MergeTree` 表时相同。 +创建 `AggregatingMergeTree` 表时,所需的 [子句](../../../engines/table-engines/mergetree-family/mergetree.md) 与创建 `MergeTree` 表时相同。
创建表的弃用方法 :::note -请勿在新项目中使用此方法,并尽可能将旧项目切换到上述描述的方法。 +在新项目中请勿使用此方法,并且如果可能,请将旧项目切换到上述描述的方法。 ::: ```sql @@ -70,19 +71,19 @@ CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] ## SELECT 和 INSERT {#select-and-insert} 要插入数据,请使用带有聚合状态函数的 [INSERT SELECT](../../../sql-reference/statements/insert-into.md) 查询。 -从 `AggregatingMergeTree` 表中选择数据时,请使用 `GROUP BY` 子句以及与插入数据时相同的聚合函数,但使用 `-Merge` 后缀。 +从 `AggregatingMergeTree` 表中选择数据时,请使用 `GROUP BY` 子句和与插入数据时相同的聚合函数,但使用 `-Merge` 后缀。 -在 `SELECT` 查询的结果中,类型为 `AggregateFunction` 的值具有特定于实现的二进制表示,适用于所有 ClickHouse 输出格式。例如,如果您使用 `SELECT` 查询将数据转储为 `TabSeparated` 格式,则可以使用 `INSERT` 查询将此转储加载回去。 +在 `SELECT` 查询的结果中,`AggregateFunction` 类型的值具有特定实现的二进制表示,适用于所有 ClickHouse 输出格式。 例如,如果您使用 `SELECT` 查询将数据转储为 `TabSeparated` 格式,则可以使用 `INSERT` 查询将此转储加载回。 ## 聚合物化视图示例 {#example-of-an-aggregated-materialized-view} -以下示例假设您有一个名为 `test` 的数据库,因此如果尚不存在,请创建它: +以下示例假设您有一个名为 `test` 的数据库。 如果尚不存在,请使用以下命令创建它: ```sql CREATE DATABASE test; ``` -现在创建 `test.visits` 表以包含原始数据: +现在创建包含原始数据的表 `test.visits`: ```sql CREATE TABLE test.visits @@ -94,9 +95,9 @@ CREATE TABLE test.visits ) ENGINE = MergeTree ORDER BY (StartDate, CounterID); ``` -接下来,您需要一个 `AggregatingMergeTree` 表来存储跟踪访客总数和唯一用户数量的 `AggregationFunction`。 +接下来,您需要一个 `AggregatingMergeTree` 表,该表将存储 `AggregationFunction`,以跟踪访问总数和唯一用户数。 -创建一个监视 `test.visits` 表的 `AggregatingMergeTree` 物化视图,并使用 `AggregateFunction` 类型: +创建一个监控 `test.visits` 表的 `AggregatingMergeTree` 物化视图,并使用 [`AggregateFunction`](/sql-reference/data-types/aggregatefunction) 类型: ```sql CREATE TABLE test.agg_visits ( @@ -108,7 +109,7 @@ CREATE TABLE test.agg_visits ( ENGINE = AggregatingMergeTree() ORDER BY (StartDate, CounterID); ``` -创建一个物化视图,将 `test.visits` 中的数据填充到 `test.agg_visits` 中: +创建一个从 `test.visits` 填充 `test.agg_visits` 的物化视图: ```sql CREATE MATERIALIZED VIEW test.visits_mv TO test.agg_visits @@ -128,9 +129,9 @@ INSERT INTO test.visits (StartDate, CounterID, Sign, UserID) VALUES (1667446031000, 1, 3, 4), (1667446031000, 1, 6, 3); ``` -数据同时插入到 `test.visits` 和 `test.agg_visits` 中。 +数据同时插入到 `test.visits` 和 `test.agg_visits`。 -要获取聚合数据,执行一个查询,比如从物化视图 `test.visits_mv` 中的 `SELECT ... GROUP BY ...`: +要获取聚合数据,请执行如下查询 `SELECT ... GROUP BY ...` 从物化视图 `test.visits_mv`: ```sql SELECT @@ -148,7 +149,7 @@ ORDER BY StartDate; └─────────────────────────┴────────┴───────┘ ``` -向 `test.visits` 中添加另外几条记录,但这次尝试为其中一条记录使用不同的时间戳: +再向 `test.visits` 添加一两个记录,但这次尝试为其中一条记录使用不同的时间戳: ```sql INSERT INTO test.visits (StartDate, CounterID, Sign, UserID) @@ -164,6 +165,22 @@ INSERT INTO test.visits (StartDate, CounterID, Sign, UserID) └─────────────────────────┴────────┴───────┘ ``` +在某些情况下,您可能希望避免在插入时预聚合行,以将聚合成本从插入时间转移到合并时间。 通常,必须在物化视图定义的 `GROUP BY` 子句中包含不属于聚合的列,以避免错误。 但是,您可以利用 [`initializeAggregation`](/sql-reference/functions/other-functions#initializeaggregation) 函数,并设置 `optimize_on_insert = 0`(默认启用)来实现这一点。 在这种情况下,不再需要使用 `GROUP BY`: + +```sql +CREATE MATERIALIZED VIEW test.visits_mv TO test.agg_visits +AS SELECT + StartDate, + CounterID, + initializeAggregation('sumState', Sign) AS Visits, + initializeAggregation('uniqState', UserID) AS Users +FROM test.visits; +``` + +:::note +使用 `initializeAggregation` 时,为每一行创建一个聚合状态,而不进行分组。 每个源行在物化视图中产生一行,实际的聚合将在 `AggregatingMergeTree` 合并部分时发生。 只有在 `optimize_on_insert = 0` 时,这才成立。 +::: + ## 相关内容 {#related-content} - 博客: [在 ClickHouse 中使用聚合组合器](https://clickhouse.com/blog/aggregate-functions-combinators-in-clickhouse-for-arrays-maps-and-states) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/aggregatingmergetree.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/aggregatingmergetree.md.hash index 6cc8b7697c4..f973c52bd57 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/aggregatingmergetree.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/aggregatingmergetree.md.hash @@ -1 +1 @@ -93aecd45d93d1f25 +9b08d6590d28fe30 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/annindexes.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/annindexes.md index ce39bf6c5fa..64acb49e9b3 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/annindexes.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/annindexes.md @@ -1,5 +1,5 @@ --- -'description': 'Documentation for 精确和近似最近邻搜索' +'description': '精确与近似向量搜索的文档' 'keywords': - 'vector similarity search' - 'ann' @@ -8,22 +8,24 @@ - 'indices' - 'index' - 'nearest neighbor' -'sidebar_label': '精确和近似最近邻搜索' +- 'vector search' +'sidebar_label': '精确与近似向量搜索' 'slug': '/engines/table-engines/mergetree-family/annindexes' -'title': '精确和近似最近邻搜索' +'title': '精确与近似向量搜索' +'doc_type': 'guide' --- -import BetaBadge from '@theme/badges/BetaBadge'; +import ExperimentalBadge from '@theme/badges/ExperimentalBadge'; -# 精确与近似最近邻搜索 +# 精确和近似向量搜索 -在多维(向量)空间中查找给定点的 N 个最近点的问题被称为 [最近邻搜索](https://en.wikipedia.org/wiki/Nearest_neighbor_search)。 -解决最近邻搜索有两种一般方法: -- 精确最近邻搜索计算给定点与向量空间中所有点之间的距离。这确保了最佳的准确性,即返回的点保证是真正的最近邻。由于向量空间被完全遍历,精确最近邻搜索在实际应用中可能过于缓慢。 -- 近似最近邻搜索指的是一组技术(例如,图和随机森林等特殊数据结构),其计算结果的速度远快于精确最近邻搜索。结果的准确性通常对于实际使用来说是“足够好”的。许多近似技术提供参数以调整结果准确性与搜索时间之间的权衡。 +在多维(向量)空间中,查找给定点最近的 N 个点的问题被称为 [最近邻搜索](https://en.wikipedia.org/wiki/Nearest_neighbor_search),或简称为:向量搜索。 +解决向量搜索有两种一般方法: +- 精确向量搜索计算给定点与向量空间中所有点之间的距离。这确保了最佳的准确性,即返回的点保证是实际的最近邻。由于向量空间被全面探索,精确向量搜索在实际使用中可能过于缓慢。 +- 近似向量搜索是指一组技术(例如,特殊数据结构如图和随机森林),其计算结果比精确向量搜索快得多。结果的准确性通常“足够好”,适用于实际使用。许多近似技术提供参数来调整结果的准确性与搜索时间之间的权衡。 -最近邻搜索(精确或近似)可以用 SQL 表示如下: +向量搜索(精确或近似)可以用 SQL 书写如下: ```sql WITH [...] AS reference_vector @@ -34,23 +36,16 @@ ORDER BY (vectors, reference_vector) LIMIT ``` -向量空间中的点存储在类型为数组的列 `vectors` 中,例如 [Array(Float64)](../../../sql-reference/data-types/array.md)、[Array(Float32)](../../../sql-reference/data-types/array.md) 或 [Array(BFloat16)](../../../sql-reference/data-types/array.md)。 -参考向量是一个常量数组,并作为公共表表达式提供。 -`` 计算参考点与所有存储点之间的距离。 +向量空间中的点存储在数组类型的列 `vectors` 中,例如 [Array(Float64)](../../../sql-reference/data-types/array.md),[Array(Float32)](../../../sql-reference/data-types/array.md) 或 [Array(BFloat16)](../../../sql-reference/data-types/array.md)。 +参考向量是一个常量数组,并作为公共表表达式给出。 +`` 用于计算参考点与所有存储点之间的距离。 可以使用任何可用的 [距离函数](/sql-reference/functions/distance-functions)。 -`` 指定应该返回多少个邻居。 +`` 指定应返回多少个邻居。 +## 精确向量搜索 {#exact-nearest-neighbor-search} -## 精确最近邻搜索 {#exact-nearest-neighbor-search} - -可以直接使用上述 SELECT 查询执行精确最近邻搜索。 +可以使用上述 SELECT 查询执行精确向量搜索。 此类查询的运行时间通常与存储的向量数量及其维度成正比,即数组元素的数量。 -另外,由于 ClickHouse 对所有向量进行暴力扫描,运行时间还取决于查询的线程数量(参见设置 [max_threads](../../../operations/settings/settings.md#max_threads))。 - -加速精确最近邻搜索的一种常见方法是使用较低精度的 [float 数据类型](../../../sql-reference/data-types/float.md)。 -例如,如果向量存储为 `Array(BFloat16)` 而不是 `Array(Float32)`,则数据大小减半,查询运行时间预计也会减半。 -这种方法称为量化,尽管对所有向量进行了全面扫描,但它可能降低结果的准确性。 -如果精度损失是可以接受的,取决于使用案例,并且通常需要实验。 - +此外,由于 ClickHouse 对所有向量执行暴力扫描,因此运行时间还取决于查询的线程数量(请参见设置 [max_threads](../../../operations/settings/settings.md#max_threads))。 ### 示例 {#exact-nearest-neighbor-search-example} ```sql @@ -74,22 +69,18 @@ LIMIT 3; 3. │ 8 │ [0,2.2] │ └────┴─────────┘ ``` +## 近似向量搜索 {#approximate-nearest-neighbor-search} +### 向量相似度索引 {#vector-similarity-index} -## 近似最近邻搜索 {#approximate-nearest-neighbor-search} - - - -ClickHouse 提供了一种特殊的“向量相似性”索引来执行近似最近邻搜索。 +ClickHouse 提供了一种特别的“向量相似度”索引以执行近似向量搜索。 :::note -向量相似性索引目前处于实验阶段。 -要启用它们,请首先运行 `SET allow_experimental_vector_similarity_index = 1`。 -如果遇到问题,请在 [ClickHouse 仓库](https://github.com/clickhouse/clickhouse/issues) 中打开问题。 +向量相似度索引在 ClickHouse 版本 25.8 及更高版本中可用。 +如果遇到问题,请在 [ClickHouse 仓库](https://github.com/clickhouse/clickhouse/issues) 中打开一个问题。 ::: +#### 创建向量相似度索引 {#creating-a-vector-similarity-index} -### 创建向量相似性索引 {#creating-a-vector-similarity-index} - -可以在新表上创建向量相似性索引,如下所示: +可以在新表上创建向量相似度索引,如下所示: ```sql CREATE TABLE table @@ -102,37 +93,37 @@ ENGINE = MergeTree ORDER BY [...] ``` -或者,要向现有表添加向量相似性索引: +或者,要将向量相似度索引添加到现有表中: ```sql ALTER TABLE table ADD INDEX vectors TYPE vector_similarity(, , ) [GRANULARITY ]; ``` -向量相似性索引是特殊类型的跳过索引(参见 [这里](mergetree.md#table_engine-mergetree-data_skipping-indexes) 和 [这里](../../../optimize/skipping-indexes))。 -因此,上述 `ALTER TABLE` 语句仅使索引构建为将来插入到表中的新数据。 -要为现有数据也构建索引,需要将其物化: +向量相似度索引是特殊类型的跳过索引(见 [这里](mergetree.md#table_engine-mergetree-data_skipping-indexes) 和 [这里](../../../optimize/skipping-indexes))。 +因此,上述 `ALTER TABLE` 语句仅导致索引为将来插入到表中的新数据构建。 +要为现有数据构建索引,还需要将其物化: ```sql -ALTER TABLE table MATERIALIZE SETTINGS mutations_sync = 2; +ALTER TABLE table MATERIALIZE INDEX SETTINGS mutations_sync = 2; ``` 函数 `` 必须是 -- `L2Distance`,[欧几里得距离](https://en.wikipedia.org/wiki/Euclidean_distance),表示在欧几里得空间中两点之间的线段长度,或 -- `cosineDistance`,[余弦距离](https://en.wikipedia.org/wiki/Cosine_similarity#Cosine_distance),表示两条非零向量之间的角度。 +- `L2Distance`, [欧氏距离](https://en.wikipedia.org/wiki/Euclidean_distance),表示在欧几里德空间中两点之间的线段长度,或 +- `cosineDistance`, [余弦距离](https://en.wikipedia.org/wiki/Cosine_similarity#Cosine_distance),表示两非零向量之间的角度。 -对于规范化数据,通常最佳选择是 `L2Distance`,否则建议使用 `cosineDistance` 来补偿规模。 +对于标准化的数据,`L2Distance` 通常是最佳选择,否则建议使用 `cosineDistance` 来补偿尺度。 `` 指定底层列中的数组基数(元素数量)。 -如果 ClickHouse 在索引创建过程中发现数组的基数不同,则索引会被丢弃并返回错误。 +如果 ClickHouse 在索引创建过程中发现维度不同的数组,则该索引将被丢弃并返回错误。 -可选的 GRANULARITY 参数 `` 指的是索引颗粒的大小(见 [这里](../../../optimize/skipping-indexes))。 -默认值为 1 亿,适用于大多数用例,但也可以调整。 -我们建议仅对了解所做影响的高级用户进行调整(见 [下文](#differences-to-regular-skipping-indexes))。 +可选的 GRANULARITY 参数 `` 指的是索引粒度的大小(见 [这里](../../../optimize/skipping-indexes))。 +默认值为 1 亿,应该对大多数用例工作得相当好,但也可以进行调整。 +我们建议仅对了解其含义的高级用户进行调整(见 [下文](#differences-to-regular-skipping-indexes))。 -向量相似性索引是通用的,它们可以容纳不同的近似搜索方法。 -实际上使用的方法由参数 `` 指定。 -到目前为止,唯一可用的方法是 HNSW ([学术论文](https://arxiv.org/abs/1603.09320)),这是一种基于层次接近图的流行且先进的近似向量搜索技术。 -如果使用 HNSW 作为类型,用户可以选择性地指定进一步的 HNSW 特定参数: +向量相似度索引是通用的,可以容纳不同的近似搜索方法。 +实际使用的方法由参数 `` 指定。 +到目前为止,唯一可用的方法是 HNSW([学术论文](https://arxiv.org/abs/1603.09320)),这是一种基于分层邻近图的流行的和最先进的近似向量搜索技术。 +如果将 HNSW 作为类型,用户可以选择性地指定进一步的 HNSW 特定参数: ```sql CREATE TABLE table @@ -146,26 +137,67 @@ ORDER BY [...] ``` 这些 HNSW 特定参数包括: -- `` 控制接近图中向量的量化。可能的值为 `f64`、`f32`、`f16`、`bf16` 或 `i8`。默认值为 `bf16`。请注意,此参数不影响底层列中向量的表示。 -- `` 控制每个图节点的邻居数量,也称为 HNSW 超参数 `M`。默认值为 `32`。值为 `0` 表示使用默认值。 -- `` 控制 HNSW 图构建过程中动态候选列表的大小,也称为 HNSW 超参数 `ef_construction`。默认值为 `128`。值为 `0` 表示使用默认值。 +- `` 控制邻接图中色彩向量的量化。可能的值有 `f64`、`f32`、`f16`、`bf16`、`i8` 或 `b1`。默认值是 `bf16`。请注意,此参数不影响底层列中向量的表示。 +- `` 控制每个图节点的邻居数量,也称为 HNSW 超参数 `M`。默认值为 `32`。值 `0` 表示使用默认值。 +- `` 控制 HNSW 图的动态候选列表的大小,也称为 HNSW 超参数 `ef_construction`。默认值为 `128`。值 `0` 表示使用默认值。 -所有 HNSW 特定参数的默认值在大多数用例中有效。因此,我们不建议自定义 HNSW 特定参数。 +所有 HNSW 特定参数的默认值在大多数用例中工作得相当好。 +因此,我们并不建议自定义 HNSW 特定参数。 + +进一步的限制包括: +- 向量相似度索引只能在类型为 [Array(Float32)](../../../sql-reference/data-types/array.md)、[Array(Float64)](../../../sql-reference/data-types/array.md) 或 [Array(BFloat16)](../../../sql-reference/data-types/array.md) 的列上构建。不可允许包含空值和低基数浮点数的数组,如 `Array(Nullable(Float32))` 和 `Array(LowCardinality(Float32))`。 +- 向量相似度索引必须在单列上构建。 +- 向量相似度索引可以建立在计算表达式上(例如,`INDEX index_name arraySort(vectors) TYPE vector_similarity([...])`),但这种索引不能稍后用于近似邻居搜索。 +- 向量相似度索引要求底层列中的所有数组必须具有 ``-数量的元素——在索引创建期间检查此条件。为了尽早检测到此要求的违规,用户可以为向量列添加 [约束](/sql-reference/statements/create/table.md#constraints),例如,`CONSTRAINT same_length CHECK length(vectors) = 256`。 +- 同样,底层列中的数组值不得为空 (`[]`) 或具有默认值(也为 `[]`)。 + +**估算存储和内存消耗** + +用于典型 AI 模型(例如大型语言模型,[LLMs](https://en.wikipedia.org/wiki/Large_language_model))的向量由数百或数千个浮点值生成。 +因此,单个向量值可能具有多个千字节的内存消耗。 +希望估算表中底层向量列所需存储的用户以及为向量相似度索引所需的主存,可以使用以下两个公式: + +表中向量列(未经压缩)的存储消耗: + +```text +Storage consumption = Number of vectors * Dimension * Size of column data type +``` -适用其他限制: -- 向量相似性索引只能构建在类型为 [Array(Float32)](../../../sql-reference/data-types/array.md)、[Array(Float64)](../../../sql-reference/data-types/array.md) 或 [Array(BFloat16)](../../../sql-reference/data-types/array.md) 的列上。不可接受可空和低卡路里浮点数组,例如 `Array(Nullable(Float32))` 和 `Array(LowCardinality(Float32))`。 -- 向量相似性索引必须构建在单列上。 -- 向量相似性索引可以在计算表达式上构建(例如,`INDEX index_name arraySort(vectors) TYPE vector_similarity([...])`),但此类索引不能在以后用于近似邻居搜索。 -- 向量相似性索引要求底层列中的所有数组都有 `` 许多元素 - 这在索引创建期间进行检查。为了尽早检测此要求的违规,用户可以为向量列添加约束(/sql-reference/statements/create/table.md#constraints),例如,`CONSTRAINT same_length CHECK length(vectors) = 256`。 -- 同样,底层列中的数组值不得为空(`[]`)或具有默认值(也为 `[]`)。 +[dbpedia 数据集](https://huggingface.co/datasets/KShivendu/dbpedia-entities-openai-1M) 的示例: + +```text +Storage consumption = 1 million * 1536 * 4 (for Float32) = 6.1 GB +``` + +必须将向量相似度索引从磁盘完全加载到主内存中以执行搜索。 +同样,向量索引也在内存中完全构建,然后保存到磁盘。 + +加载向量索引所需的内存消耗: + +```text +Memory for vectors in the index (mv) = Number of vectors * Dimension * Size of quantized data type +Memory for in-memory graph (mg) = Number of vectors * hnsw_max_connections_per_layer * Bytes_per_node_id (= 4) * Layer_node_repetition_factor (= 2) + +Memory consumption: mv + mg +``` + +[dbpedia 数据集](https://huggingface.co/datasets/KShivendu/dbpedia-entities-openai-1M) 的示例: + +```text +Memory for vectors in the index (mv) = 1 million * 1536 * 2 (for BFloat16) = 3072 MB +Memory for in-memory graph (mg) = 1 million * 64 * 2 * 4 = 512 MB + +Memory consumption = 3072 + 512 = 3584 MB +``` -### 使用向量相似性索引 {#using-a-vector-similarity-index} +上述公式不考虑向量相似度索引分配运行时数据结构(如预分配缓冲区和缓存)所需的额外内存。 +#### 使用向量相似度索引 {#using-a-vector-similarity-index} :::note -要使用向量相似性索引,设置 [compatibility](../../../operations/settings/settings.md) 必须为 `''`(默认值)或 `'25.1'` 或更新版本。 +要使用向量相似度索引,设置 [compatibility](../../../operations/settings/settings.md) 必须为 `''`(默认值)、`'25.1'` 或更高。 ::: -向量相似性索引支持以下形式的 SELECT 查询: +向量相似度索引支持以下形式的 SELECT 查询: ```sql WITH [...] AS reference_vector @@ -176,18 +208,18 @@ ORDER BY (vectors, reference_vector) LIMIT ``` -ClickHouse 的查询优化器尝试匹配上述查询模板并利用可用的向量相似性索引。 -查询只能使用向量相似性索引,如果 SELECT 查询中的距离函数与索引定义中的距离函数相同。 +ClickHouse 的查询优化器会尝试匹配上述查询模板,并利用可用的向量相似度索引。 +查询仅能使用向量相似度索引,如果 SELECT 查询中的距离函数与索引定义中的距离函数相同。 -高级用户可以为设置 [hnsw_candidate_list_size_for_search](../../../operations/settings/settings.md#hnsw_candidate_list_size_for_search) 提供自定义值(也称为 HNSW 超参数 “ef_search”),以调整搜索期间候选列表的大小(例如, `SELECT [...] SETTINGS hnsw_candidate_list_size_for_search = `)。 -该设置的默认值 256 在大多数用例中效果良好。 -更高的设置值意味着更好的准确性,但会造成更慢的性能。 +高级用户可以为设置 [hnsw_candidate_list_size_for_search](../../../operations/settings/settings.md#hnsw_candidate_list_size_for_search) (也称为 HNSW 超参数“ef_search”)提供自定义值,以调整搜索时候的候选列表大小(例如,`SELECT [...] SETTINGS hnsw_candidate_list_size_for_search = `)。 +默认值 256 在大多数用例中表现良好。 +较高的设置值意味着更好的准确性,但会降低性能。 -如果查询可以使用向量相似性索引,ClickHouse 会检查 SELECT 查询中提供的 LIMIT `` 是否在合理范围内。 -更具体来说,如果 `` 大于设置 [max_limit_for_vector_search_queries](../../../operations/settings/settings.md#max_limit_for_vector_search_queries) 的默认值 100 的值,将返回错误。 -过大的 LIMIT 值可能会降低搜索速度,通常表明使用错误。 +如果查询能够使用向量相似度索引,ClickHouse 会检查 SELECT 查询中提供的 LIMIT `` 是否在合理范围内。 +更具体地说,如果 `` 大于设置 [max_limit_for_vector_search_queries](../../../operations/settings/settings.md#max_limit_for_vector_search_queries) 的默认值 100,则返回错误。 +过大的 LIMIT 值可能会降低搜索速度,通常指示使用错误。 -要检查 SELECT 查询是否使用了向量相似性索引,可以在查询前加上 `EXPLAIN indexes = 1`。 +要检查 SELECT 查询是否使用向量相似度索引,可以在查询前加上 `EXPLAIN indexes = 1`。 例如,查询 @@ -222,36 +254,36 @@ LIMIT 10; └─────────────────────────────────────────────────────────────────────────────────────────────────┘ ``` -在此示例中,1 百万个向量存储在 [dbpedia 数据集](https://huggingface.co/datasets/KShivendu/dbpedia-entities-openai-1M) 中,每个维度为 1536,存储在 575 个颗粒中,即每个颗粒 1.7k 行。 -查询请求 10 个邻居,向量相似性索引在 10 个不同的颗粒中找到这 10 个邻居。 -在查询执行期间将读取这 10 个颗粒。 +在此示例中,1 百万向量在 [dbpedia 数据集](https://huggingface.co/datasets/KShivendu/dbpedia-entities-openai-1M) 中,每个维度 1536,存储在 575 个粒度中,即每个粒度 1.7k 行。 +查询请求 10 个邻居,向量相似度索引在 10 个单独的粒度中找到这 10 个邻居。 +在查询执行期间将读取这 10 个粒度。 -当输出包含 `Skip` 以及向量索引的名称和类型(在示例中为 `idx` 和 `vector_similarity`)时,表示使用了向量相似性索引。 -在这种情况下,向量相似性索引丢弃了四个颗粒中的两个,即 50% 的数据。 -可以丢弃更多颗粒,则索引使用的效果越明显。 +如果输出包含 `Skip` 和向量索引的名称和类型(在示例中为 `idx` 和 `vector_similarity`),则正在使用向量相似度索引。 +在这种情况下,向量相似度索引丢弃了四个粒度中的两个,即 50% 的数据。 +越多的粒度被丢弃,索引使用的效果就越好。 :::tip -要强制使用索引,可以在 SELECT 查询中使用设置 [force_data_skipping_indexes](../../../operations/settings/settings#force_data_skipping_indices)(将索引名称作为设置值)。 +要强制使用索引,可以使用设置 [force_data_skipping_indexes](../../../operations/settings/settings#force_data_skipping_indices) 运行 SELECT 查询(提供索引名称作为设置值)。 ::: -**后过滤与前过滤** +**后过滤和预过滤** -用户可以选择性地为 SELECT 查询指定附加过滤条件的 `WHERE` 子句。 -ClickHouse 将使用后过滤或前过滤策略来评估这些过滤条件。 +用户可以选择性地为 SELECT 查询指定带有附加过滤条件的 `WHERE` 子句。 +ClickHouse 将使用后过滤或预过滤策略来评估这些过滤条件。 简而言之,这两种策略确定过滤器评估的顺序: -- 后过滤意味着首先评估向量相似性索引,随后 ClickHouse 评估在 `WHERE` 子句中指定的附加过滤器。 -- 前过滤意味着过滤器评估顺序正好相反。 +- 后过滤意味着首先评估向量相似度索引,然后 ClickHouse 评估在 `WHERE` 子句中指定的附加过滤器。 +- 预过滤意味着过滤器评估的顺序正好相反。 -这两种策略具有不同的权衡: -- 后过滤存在一般性问题,可能返回少于 `LIMIT ` 子句请求的行数。当由向量相似性索引返回的一个或多个结果行未能满足附加过滤条件时,就会发生这种情况。 -- 前过滤通常是一个未解决的问题。某些专业向量数据库提供前过滤算法,但大多数关系数据库(包括 ClickHouse)将回退到精确邻居搜索,即没有索引的暴力扫描。 +这两种策略的权衡不同: +- 后过滤的一般问题是它可能返回少于 `LIMIT ` 子句请求的行数。当向量相似度索引返回的结果行之一或多个未满足附加过滤条件时,会发生这种情况。 +- 预过滤通常是一个未解决的问题。某些专业化的向量数据库提供预过滤算法,但大多数关系数据库(包括 ClickHouse)将退回到精确邻居搜索,即不使用索引的暴力扫描。 使用哪种策略取决于过滤条件。 *附加过滤器是分区键的一部分* -如果附加过滤条件是分区键的一部分,则 ClickHouse 将应用分区裁剪。 -例如,若一个表按列 `year` 范围分区,并运行以下查询: +如果附加过滤条件是分区键的一部分,则 ClickHouse 将应用分区修剪。 +例如,一张表按 `year` 列范围分区,并运行以下查询: ```sql WITH [0., 2.] AS reference_vec @@ -262,30 +294,30 @@ ORDER BY L2Distance(vec, reference_vec) ASC LIMIT 3; ``` -ClickHouse 将修剪掉除 2025 年之外的所有分区。 +ClickHouse 将修剪除 2025 以外的所有分区。 -*附加过滤器不能使用索引评估* +*附加过滤器不能使用索引进行评估* -如果附加过滤条件不能使用索引(主键索引、跳过索引)进行评估,则 ClickHouse 将应用后过滤。 +如果附加过滤条件无法使用索引(主键索引、跳过索引)进行评估,则 ClickHouse 将应用后过滤。 -*附加过滤器可以使用主键索引评估* +*附加过滤器可以使用主键索引进行评估* -如果附加过滤条件可以使用 [主键](mergetree.md#primary-key) 进行评估(即它们形成主键的前缀),且 -- 过滤条件在某个部分中消除了至少一行,则 ClickHouse 将对于该部分中的“存活”范围回退到前过滤, -- 过滤条件在部分中未消除任何行,则 ClickHouse 将对该部分执行后过滤。 +如果附加过滤条件可以使用 [主键](mergetree.md#primary-key) 进行评估(即,它们形成主键的前缀),并且 +- 过滤条件在某个部分内消除了至少一行,则 ClickHouse 将对该部分内“幸存”的范围进行预过滤, +- 过滤条件在某个部分内未消除任何行,则 ClickHouse 将对该部分执行后过滤。 -在实际用例中,后一种情况相对不太可能。 +在实际使用中,后一种情况相对不太可能。 -*附加过滤器可以使用跳过索引评估* +*附加过滤器可以使用跳过索引进行评估* -如果附加过滤条件可以使用 [跳过索引](mergetree.md#table_engine-mergetree-data_skipping-indexes) 进行评估(minmax 索引、集合索引等),ClickHouse 会执行后过滤。 -在此情况下,首先评估向量相似性索引,因为预计它将相对于其他跳过索引删除最多的行。 +如果附加过滤条件可以使用 [跳过索引](mergetree.md#table_engine-mergetree-data_skipping-indexes) (最小最大索引、集合索引等)进行评估,ClickHouse 将执行后过滤。 +在这种情况下,期望首先评估向量相似度索引,因为它可能相对于其他跳过索引移除更多的行。 -为了更精细地控制后过滤与前过滤,可以使用两个设置: +对于后过滤与预过滤的更细控制,可以使用两个设置: -设置 [vector_search_filter_strategy](../../../operations/settings/settings#vector_search_filter_strategy)(默认值:`auto`,其实现以上启发式策略)可以设置为 `prefilter`。 -这对在附加过滤条件非常选择性的情况下强制执行前过滤很有用。 -例如,以下查询可能会从前过滤中受益: +设置 [vector_search_filter_strategy](../../../operations/settings/settings#vector_search_filter_strategy) (默认值:`auto`,实现上述启发式方法)可以设置为 `prefilter`。 +这在附加过滤条件极为选择性时非常有用。 +例如,以下查询可能受益于预过滤: ```sql SELECT bookid, author, title @@ -295,12 +327,12 @@ ORDER BY cosineDistance(book_vector, getEmbedding('Books on ancient Asian empire LIMIT 10 ``` -假设只有极少数书籍的价格低于 2 美元,后过滤可能返回零行,因为向量索引返回的前 10 名匹配项可能都定价在 2 美元以上。 -通过强制前过滤(在查询中添加 `SETTINGS vector_search_filter_strategy = 'prefilter'`),ClickHouse 首先找到所有价格低于 2 美元的书籍,然后对找到的书籍执行暴力向量搜索。 +假设只有少量图书售价低于 2 美元,后过滤可能返回零行,因为向量索引返回的前 10 个匹配项可能全部定价在 2 美元以上。 +通过强制预过滤(在查询中添加 `SETTINGS vector_search_filter_strategy = 'prefilter'`),ClickHouse 首先找到所有低于 2 美元的书籍,然后针对找到的书籍执行暴力向量搜索。 -另一种解决上述问题的方法是将设置 [vector_search_postfilter_multiplier](../../../operations/settings/settings#vector_search_postfilter_multiplier)(默认值:`1.0`)配置为大于 `1.0` 的值(例如,`2.0`)。 -从向量索引获取的最近邻的数量将乘以设置值,然后应用附加过滤以返回 LIMIT 数量的行。 -例如,我们可以再次查询,但乘数为 `3.0`: +作为解决上述问题的另一种方法,可以将设置 [vector_search_index_fetch_multiplier](../../../operations/settings/settings#vector_search_index_fetch_multiplier) (默认:`1.0`,最大:`1000.0`)配置为大于 `1.0` 的值(例如,`2.0`)。 +从向量索引中提取到的最近邻的数量将乘以设置值,然后对此些行应用附加过滤以返回 LIMIT 行。 +例如,我们可以再次查询,但乘倍数为 `3.0`: ```sql SELECT bookid, author, title @@ -308,65 +340,112 @@ FROM books WHERE price < 2.00 ORDER BY cosineDistance(book_vector, getEmbedding('Books on ancient Asian empires')) LIMIT 10 -SETTING vector_search_postfilter_multiplier = 3.0; +SETTING vector_search_index_fetch_multiplier = 3.0; ``` -ClickHouse 将从每个部分的向量索引中获取 3.0 x 10 = 30 个最近邻,然后评估附加过滤。 -只有十个最近邻将被返回。 -我们注意到设置 `vector_search_postfilter_multiplier` 可以缓解问题,但在极端情况下(非常选择性的 WHERE 条件),仍然可能返回的行数少于请求的 N 行。 +ClickHouse 将从每个部分的向量索引中提取 3.0 x 10 = 30 个最近邻,然后评估附加过滤。 +只有十个最接近的邻居将被返回。 +我们注意到,设置 `vector_search_index_fetch_multiplier` 可以减轻问题,但在极端情况下(非常选择性的 WHERE 条件),仍然可能返回的行数少于请求的 N 行。 -### 性能调优 {#performance-tuning} +**重新评估** -**调优压缩** +ClickHouse 中的跳过索引通常在粒度级别过滤,即跳过索引中的查找(内部)返回一个潜在匹配的粒度列表,从而减少随后的扫描中读取的数据量。 +这对跳过索引很好用,但在向量相似度索引的情况下,会产生“粒度不匹配”。 +更具体地说,向量相似度索引确定给定参考向量的 N 个最相似向量的行号,但随后需要将这些行号推断为粒度号。 +ClickHouse 然后将从磁盘加载这些粒度,并对这些粒度中的所有向量执行距离计算。 +此步骤称为重新评估,尽管理论上可以提高准确性——请记住,向量相似度索引返回的是_近似_结果,但在性能方面显然不是最佳的。 -在几乎所有的用例中,底层列中的向量都是密集的,压缩效果不好。 -因此,[压缩](/sql-reference/statements/create/table.md#column_compression_codec) 会减慢对向量列的插入和读取。 +因此,ClickHouse 提供了一种优化,可以禁用重新评估,并直接从索引返回最相似的向量及其距离。 +默认情况下启用此优化,请参见设置 [vector_search_with_rescoring](../../../operations/settings/settings#vector_search_with_rescoring)。 +其工作原理在高层上是 ClickHouse 提供最相似的向量及其距离,作为虚拟列 `_distances`。 +要查看这一点,运行带有 `EXPLAIN header = 1` 的向量搜索查询: + +```sql +EXPLAIN header = 1 +WITH [0., 2.] AS reference_vec +SELECT id +FROM tab +ORDER BY L2Distance(vec, reference_vec) ASC +LIMIT 3 +SETTINGS vector_search_with_rescoring = 0 +``` + +```result +Query id: a2a9d0c8-a525-45c1-96ca-c5a11fa66f47 + + ┌─explain─────────────────────────────────────────────────────────────────────────────────────────────────┐ + 1. │ Expression (Project names) │ + 2. │ Header: id Int32 │ + 3. │ Limit (preliminary LIMIT (without OFFSET)) │ + 4. │ Header: L2Distance(__table1.vec, _CAST([0., 2.]_Array(Float64), 'Array(Float64)'_String)) Float64 │ + 5. │ __table1.id Int32 │ + 6. │ Sorting (Sorting for ORDER BY) │ + 7. │ Header: L2Distance(__table1.vec, _CAST([0., 2.]_Array(Float64), 'Array(Float64)'_String)) Float64 │ + 8. │ __table1.id Int32 │ + 9. │ Expression ((Before ORDER BY + (Projection + Change column names to column identifiers))) │ +10. │ Header: L2Distance(__table1.vec, _CAST([0., 2.]_Array(Float64), 'Array(Float64)'_String)) Float64 │ +11. │ __table1.id Int32 │ +12. │ ReadFromMergeTree (default.tab) │ +13. │ Header: id Int32 │ +14. │ _distance Float32 │ + └─────────────────────────────────────────────────────────────────────────────────────────────────────────┘ +``` + +:::note +未进行重新评估(`vector_search_with_rescoring = 0`)并启用并行副本的查询可能会回退到重新评估。 +::: +#### 性能调优 {#performance-tuning} + +**调整压缩** + +在几乎所有使用案例中,底层列中的向量都是稠密的,压缩效果不佳。 +因此,[压缩](/sql-reference/statements/create/table.md#column_compression_codec) 会减慢向量列的插入和读取。 因此,我们建议禁用压缩。 -为此,为向量列指定 `CODEC(NONE)`,如下所示: +为此,请为向量列指定 `CODEC(NONE)`,如下所示: ```sql CREATE TABLE tab(id Int32, vec Array(Float32) CODEC(NONE), INDEX idx vec TYPE vector_similarity('hnsw', 'L2Distance', 2)) ENGINE = MergeTree ORDER BY id; ``` -**调优索引创建** +**调整索引创建** -向量相似性索引的生命周期与部分的生命周期紧密相关。 -换句话说,每当创建带有定义的向量相似性索引的新部分时,索引也会创建。 -通常发生在数据被 [插入](https://clickhouse.com/docs/guides/inserting-data) 或[合并](https://clickhouse.com/docs/merges) 时。 -不幸的是,HNSW 以较长的索引创建时间而闻名,这可能会明显减慢插入和合并速度。 -理想情况下,仅在数据是不可变或很少更改的情况下使用向量相似性索引。 +向量相似度索引的生命周期与分区的生命周期相关联。 +换句话说,每当创建带有定义的向量相似度索引的新部分时,索引也会创建。 +这通常发生在数据被 [插入](https://clickhouse.com/docs/guides/inserting-data) 或在 [合并](https://clickhouse.com/docs/merges) 过程中。 +不幸的是,HNSW 以长索引创建时间而闻名,这可能显著减慢插入和合并。 +理想情况下,只有在数据是不可变或很少变化的情况下才使用向量相似度索引。 -为加速索引创建,可以使用以下技术: +要加速索引创建,可以使用以下技术: -首先,索引创建可以并行化。 -可以通过服务器设置 [max_build_vector_similarity_index_thread_pool_size](/operations/server-configuration-parameters/settings#max_build_vector_similarity_index_thread_pool_size) 配置最大索引创建线程数。 -为了获得最佳性能,设置值应配置为 CPU 核心数。 +首先,可以并行化索引创建。 +最大索引创建线程数可以通过服务器设置 [max_build_vector_similarity_index_thread_pool_size](/operations/server-configuration-parameters/settings#max_build_vector_similarity_index_thread_pool_size) 进行配置。 +为了实现最佳性能,设置值应配置为 CPU 核心的数量。 -其次,为加速 INSERT 语句,用户可以使用会话设置 [materialize_skip_indexes_on_insert](../../../operations/settings/settings.md#materialize_skip_indexes_on_insert) 禁用在新插入部分上创建跳过索引。 -在此类部分上的 SELECT 查询将回退到精确搜索。 -由于插入的部分相较于总表大小通常较小,因此这的性能影响预计是微不足道的。 +其次,为了加速 INSERT 语句,用户可以使用会话设置 [materialize_skip_indexes_on_insert](../../../operations/settings/settings.md#materialize_skip_indexes_on_insert) 禁用对新插入部分的跳过索引创建。 +对此类部分的 SELECT 查询将退回到精确搜索。 +由于插入的部分通常比整个表的大小小,因此其性能影响预计微不足道。 -第三,为了加速合并,用户可以使用会话设置 [materialize_skip_indexes_on_merge](../../../operations/settings/merge-tree-settings.md#materialize_skip_indexes_on_merge) 禁用在合并部分上创建跳过索引。 -这与语句 [ALTER TABLE \[...\] MATERIALIZE INDEX \[...\]](../../../sql-reference/statements/alter/skipping-index.md#materialize-index) 一起,提供了对向量相似性索引生命周期的显式控制。 -例如,索引创建可以推迟到所有数据已被摄取或在系统负载低的期间(如周末)。 +第三,为了加速合并,用户可以使用会话设置 [materialize_skip_indexes_on_merge](../../../operations/settings/merge-tree-settings.md#materialize_skip_indexes_on_merge) 禁用合并部分的跳过索引创建。 +这与语句 [ALTER TABLE \[...\] MATERIALIZE INDEX \[...\]](../../../sql-reference/statements/alter/skipping-index.md#materialize-index) 一起,提供对向量相似度索引生命周期的显式控制。 +例如,可以将索引创建推迟到所有数据被摄取后或者系统负载较低的时间段(例如,周末)。 -**调优索引使用** +**调整索引使用** -SELECT 查询需要将向量相似性索引加载到主内存中才能使用它们。 -为了避免重复加载相同的向量相似性索引到主内存中,ClickHouse 提供了一个专用的内存缓存来存储此类索引。 +SELECT 查询需要将向量相似度索引加载到主内存中才能使用。 +为避免相同的向量相似度索引多次加载到主内存中,ClickHouse 提供了一个专用于此类索引的内存缓存。 缓存越大,发生不必要加载的次数就越少。 -可以使用服务器设置 [vector_similarity_index_cache_size](../../../operations/server-configuration-parameters/settings.md#vector_similarity_index_cache_size) 配置最大缓存大小。 -默认情况下,缓存的大小可以增长到 5 GB。 +最大缓存大小可以通过服务器设置 [vector_similarity_index_cache_size](../../../operations/server-configuration-parameters/settings.md#vector_similarity_index_cache_size) 进行配置。 +默认情况下,缓存大小最大可达 5 GB。 -向量相似性索引缓存的当前大小显示在 [system.metrics](../../../operations/system-tables/metrics.md) 中: +向量相似度索引缓存的当前大小显示在 [system.metrics](../../../operations/system-tables/metrics.md) 中: ```sql SELECT metric, value FROM system.metrics -WHERE metric = 'VectorSimilarityIndexCacheSize' +WHERE metric = 'VectorSimilarityIndexCacheBytes' ``` -可以从 [system.query_log](../../../operations/system-tables/query_log.md) 中获取某个查询 ID 的缓存命中和未命中信息: +可以从 [system.query_log](../../../operations/system-tables/query_log.md) 中获得某个查询 ID 的缓存命中率和未命中率: ```sql SYSTEM FLUSH LOGS query_log; @@ -377,11 +456,72 @@ WHERE type = 'QueryFinish' AND query_id = '<...>' ORDER BY event_time_microseconds; ``` -对于生产用例,我们建议将缓存设置得足够大,以便所有向量索引始终保持在内存中。 +对于生产用例,我们建议缓存的大小足够大,以便始终将所有向量索引保留在内存中。 + +**调整量化** + +[量化](https://huggingface.co/blog/embedding-quantization) 是减少向量内存占用和构建和遍历向量索引的计算成本的一种技术。 +ClickHouse 向量索引支持以下量化选项: + +| 量化 | 名称 | 每维存储 | +|--------------|--------------------------------|----------------| +| f32 | 单精度 | 4 字节 | +| f16 | 半精度 | 2 字节 | +| bf16 (默认) | 半精度(脑浮点数) | 2 字节 | +| i8 | 四分之一精度 | 1 字节 | +| b1 | 二进制 | 1 位 | + +与对原始全精度浮点值(`f32`)的搜索相比,量化降低了向量搜索的精度。 +但是,在大多数数据集中,半精度脑浮点量化(`bf16`)的精度损失微不足道,因此向量相似度索引默认使用该量化技术。 +四分之一精度(`i8`)和二进制(`b1`)量化在向量搜索中会造成显著的精度损失。 +我们仅在向量相似度索引的大小显著大于可用 DRAM 大小时推荐这两种量化。 +在这种情况下,我们还建议启用重新评估([vector_search_index_fetch_multiplier](../../../operations/settings/settings#vector_search_index_fetch_multiplier),[vector_search_with_rescoring](../../../operations/settings/settings#vector_search_with_rescoring))以提高准确性。 +二进制量化仅建议在 1)标准化嵌入(即向量长度 = 1,OpenAI 模型通常是标准化的),以及 2)如果使用余弦距离作为距离函数。 +二进制量化在内部使用汉明距离来构造和搜索邻接图。 +重新评估步骤使用存储在表中的原始全精度向量通过余弦距离识别最近邻。 + +**调整数据传输** + +向量搜索查询中的参考向量是用户提供的,通常通过调用大型语言模型(LLM)进行检索。 +在 ClickHouse 中运行向量搜索的典型 Python 代码可能如下所示: + +```python +search_v = openai_client.embeddings.create(input = "[Good Books]", model='text-embedding-3-large', dimensions=1536).data[0].embedding + +params = {'search_v': search_v} +result = chclient.query( + "SELECT id FROM items + ORDER BY cosineDistance(vector, %(search_v)s) + LIMIT 10", + parameters = params) +``` + +嵌入向量(上述片段中的 `search_v`)可能具有非常大的维度。 +例如,OpenAI 提供生成 1536 或甚至 3072 维嵌入向量的模型。 +在上述代码中,ClickHouse Python 驱动将嵌入向量替换为可读字符串,然后将整个 SELECT 查询作为字符串发送。 +假设嵌入向量由 1536 个单精度浮点值组成,则发送的字符串长度达到 20 kB。 +这在标记、解析和执行数千次字符串到浮点转换时会造成高 CPU 使用率。 +此外,ClickHouse 服务器日志文件需要大量空间,导致 `system.query_log` 的膨胀。 + +请注意,大多数 LLM 模型返回的嵌入向量为本机浮点的列表或 NumPy 数组。 +因此,我们建议 Python 应用程序以二进制形式绑定参考向量参数,使用以下样式: + +```python +search_v = openai_client.embeddings.create(input = "[Good Books]", model='text-embedding-3-large', dimensions=1536).data[0].embedding + +params = {'$search_v_binary$': np.array(search_v, dtype=np.float32).tobytes()} +result = chclient.query( + "SELECT id FROM items + ORDER BY cosineDistance(vector, (SELECT reinterpret($search_v_binary$, 'Array(Float32)'))) + LIMIT 10" + parameters = params) +``` -### 管理与监控 {#administration} +在该示例中,参考向量以二进制形式原样发送,并在服务器上重新解释为浮点数组。 +这样可以节省服务器端的 CPU 时间,并避免服务器日志和 `system.query_log` 的膨胀。 +#### 管理和监控 {#administration} -可以从 [system.data_skipping_indices](../../../operations/system-tables/data_skipping_indices) 获取向量相似性索引的磁盘大小: +向量相似度索引的磁盘大小可以从 [system.data_skipping_indices](../../../operations/system-tables/data_skipping_indices) 获取: ```sql SELECT database, table, name, formatReadableSize(data_compressed_bytes) @@ -396,33 +536,31 @@ WHERE type = 'vector_similarity'; │ default │ tab │ idx │ 348.00 MB │ └──────────┴───────┴──────┴──────────────────────────┘ ``` - -### 与常规跳过索引的区别 {#differences-to-regular-skipping-indexes} - -与所有常规 [跳过索引](/optimize/skipping-indexes) 一样,向量相似性索引是在颗粒上构建的,每个索引块由 `GRANULARITY = [N]` 颗粒组成(对于正常的跳过索引,`[N]` 默认值为 1)。 -例如,如果表的主索引粒度为 8192(设置 `index_granularity = 8192`)且 `GRANULARITY = 2`,则每个索引块将包含 16384 行。 -然而,近似邻居搜索的数据结构和算法本质上是面向行的。 -它们存储一组行的紧凑表示,并且也返回向量搜索查询的行。 -这导致向量相似性索引的行为与正常跳过索引在某些方面具有一些相当不直观的差异。 - -当用户在某列上定义向量相似性索引时,ClickHouse 将在内部为每个索引块创建一个向量相似性“子索引”。 -子索引是“局部”的,因为它仅了解其包含索引块的行。 -在前面的示例中,假设某列有 65536 行,我们获得四个索引块(跨越八个颗粒),并且每个索引块都有一个向量相似性子索引。 -理论上,子索引能够直接返回其索引块内 N 个最近点的行。 -但是,由于 ClickHouse 按颗粒的粒度从磁盘加载数据到内存,子索引按颗粒粒度推断匹配行。 -这与正常跳过索引不同,正常跳过索引是根据索引块的粒度跳过数据。 - -`GRANULARITY` 参数决定了创建多少个向量相似性子索引。 -较大的 `GRANULARITY` 值意味着更少但更大的向量相似性子索引,直到某列(或某列的数据部分)只具有一个子索引。 -在这种情况下,子索引对所有列行具有“全局”视野,并且可以直接返回该列(部分)中包含相关行的所有颗粒(至多有 `LIMIT [N]` 个这样的颗粒)。 -在第二步中,ClickHouse 将加载这些颗粒,并通过对所有颗粒的所有行执行暴力距离计算来识别实际上最好的行。 -若使用小的 `GRANULARITY` 值,每个子索引将返回多达 `LIMIT N` 个颗粒。 -因此,需加载更多颗粒并进行后过滤。 -请注意,在两种情况下搜索的准确性是一样好的,只是处理性能存在差异。 -通常建议为向量相似性索引使用较大的 `GRANULARITY`,仅在出现内存消耗过大的问题时才回退到较小的 `GRANULARITY` 值。 -如果没有为向量相似性索引指定 `GRANULARITY`,则默认值为 1 亿。 - -### 示例 {#approximate-nearest-neighbor-search-example} +#### 与常规跳过索引的区别 {#differences-to-regular-skipping-indexes} + +与所有常规 [跳过索引](/optimize/skipping-indexes) 一样,向量相似度索引是在粒度上构建的,每个索引块由 `GRANULARITY = [N]`-多个粒度组成(`[N]` = 默认情况下为 1 的正常跳过索引)。 +例如,如果表的主索引粒度为 8192(设置 `index_granularity = 8192`),而 `GRANULARITY = 2`,则每个已索引块将包含 16384 行。 +但是,近似邻居搜索的数据结构和算法本质上是面向行的。 +它们存储一组行的紧凑表示,并为向量搜索查询返回行。 +这造成了一些相当不直观的差异,使得向量相似度索引的行为与正常跳过索引不同。 + +当用户在某列上定义向量相似度索引时,ClickHouse 在内部为每个索引块创建一个向量相似度“子索引”。 +子索引是“局部”的,意味着它只知道其所含索引块的行。 +在前面的示例中,假设某列有 65536 行,则可以获得四个索引块(跨八个粒度)并为每个索引块创建一个向量相似度子索引。 +理论上,子索引能够直接返回其索引块内与最近点的 N 个行。 +但是,由于 ClickHouse 是以粒度的方式从磁盘加载数据到内存,因此子索引在粒度级别推断匹配行。 +这与常规跳过索引不同,常规跳过索引在索引块的粒度上跳过数据。 + +`GRANULARITY` 参数决定创建多少个向量相似度子索引。 +较大的 `GRANULARITY` 值意味着更少但更大的向量相似度子索引,直到某列(或某列的数据部分)只有一个子索引。 +在这种情况下,子索引对所有列行具有“全局”视图,能够直接返回与相关行的列(部分)中所有粒度(最多 `LIMIT [N]`)相关行。 +接下来,ClickHouse 将加载这些粒度并通过对粒度中所有行执行暴力距离计算来识别实际上最好的行。 +使用小的 `GRANULARITY` 值时,每个子索引最多返回 `LIMIT N` 个粒度。 +因此,需加载和后过滤的粒度会更多。 +请注意,在两种情况下搜索的准确性同样良好,只有处理性能不同。 +通常建议对向量相似度索引使用大的 `GRANULARITY`,仅在如向量相似度结构的内存消耗过高等问题的情况下,请回退到较小的 `GRANULARITY` 值。 +如果未为向量相似度索引指定 `GRANULARITY`,则默认值为 1 亿。 +#### 示例 {#approximate-nearest-neighbor-search-example} ```sql CREATE TABLE tab(id Int32, vec Array(Float32), INDEX idx vec TYPE vector_similarity('hnsw', 'L2Distance', 2)) ENGINE = MergeTree ORDER BY id; @@ -446,7 +584,122 @@ LIMIT 3; └────┴─────────┘ ``` -## 参考文献 {#references} +使用近似向量搜索的其他示例数据集: +- [LAION-400M](../../../getting-started/example-datasets/laion-400m-dataset) +- [LAION-5B](../../../getting-started/example-datasets/laion-5b-dataset) +- [dbpedia](../../../getting-started/example-datasets/dbpedia-dataset) +- [hackernews](../../../getting-started/example-datasets/hackernews-vector-search-dataset) +### 量化位 (QBit) {#approximate-nearest-neighbor-search-qbit} + + + +加速精确向量搜索的一种常见方法是使用低精度的 [float 数据类型](../../../sql-reference/data-types/float.md)。 +例如,如果将向量存储为 `Array(BFloat16)` 而不是 `Array(Float32)`,则数据大小减半,并且查询运行时间预计会成比例减少。 +这种方法被称为量化。虽然它加速了计算,但它可能会降低结果的准确性,尽管它对所有向量进行了全面扫描。 + +使用传统量化时,在搜索和存储数据时都会失去精度。在上述示例中,我们将存储 `BFloat16` 而不是 `Float32`,这意味着即使需要,我们也无法进行更精确的搜索。另一种替代方法是存储两份数据:量化版本和全精度版本。虽然这样可行,但它需要冗余存储。考虑一种场景,其中我们原始数据为 `Float64`,想要使用不同精度(16 位、32 位或完整 64 位)进行搜索。我们需要存储三份独立的数据。 + +ClickHouse 提供了量化位 (`QBit`) 数据类型,通过以下方式解决这些限制: +1. 存储原始全精度数据。 +2. 允许在查询时指定量化精度。 + +这通过以位分组格式存储数据来实现(这意味着所有向量的所有 i-th 位一起存储),使得只在所请求的精度级别读取数据。您可以获得量化所带来的减少 I/O 的速度优势,同时在需要时保留所有原始数据。当选择最大精度时,搜索变为精确的。 + +:::note +`QBit` 数据类型及其相关的距离函数目前仍处于实验阶段。要启用它们,请运行 `SET allow_experimental_qbit_type = 1`。 +如果遇到问题,请在 [ClickHouse repository](https://github.com/clickhouse/clickhouse/issues) 中提出问题。 +::: + +要声明 `QBit` 类型的列,请使用以下语法: + +```sql +column_name QBit(element_type, dimension) +``` + +其中: +* `element_type` - 每个向量元素的类型。支持的类型有 `BFloat16`、`Float32` 和 `Float64` +* `dimension` - 每个向量中的元素数量 +#### 创建 `QBit` 表并添加数据 {#qbit-create} + +```sql +CREATE TABLE fruit_animal ( + word String, + vec QBit(Float64, 5) +) ENGINE = MergeTree +ORDER BY word; + +INSERT INTO fruit_animal VALUES + ('apple', [-0.99105519, 1.28887844, -0.43526649, -0.98520696, 0.66154391]), + ('banana', [-0.69372815, 0.25587061, -0.88226235, -2.54593015, 0.05300475]), + ('orange', [0.93338752, 2.06571317, -0.54612565, -1.51625717, 0.69775337]), + ('dog', [0.72138876, 1.55757105, 2.10953259, -0.33961248, -0.62217325]), + ('cat', [-0.56611276, 0.52267331, 1.27839863, -0.59809804, -1.26721048]), + ('horse', [-0.61435682, 0.48542571, 1.21091247, -0.62530446, -1.33082533]); +``` +#### 使用 `QBit` 进行向量搜索 {#qbit-search} + +让我们使用 L2 距离找到与表示单词 'lemon' 的向量最近的邻居。距离函数中的第三个参数指定了位精度 - 较高的值提供更高的准确性但需要更多计算。 + +您可以在 [这里](../../../sql-reference/data-types/qbit.md#vector-search-functions) 找到所有可用的 `QBit` 距离函数。 + +**全精度搜索 (64 位):** + +```sql +SELECT + word, + L2DistanceTransposed(vec, [-0.88693672, 1.31532824, -0.51182908, -0.99652702, 0.59907770], 64) AS distance +FROM fruit_animal +ORDER BY distance; +``` + +```text + ┌─word───┬────────────distance─┐ +1. │ apple │ 0.14639757188169716 │ +2. │ banana │ 1.998961369007679 │ +3. │ orange │ 2.039041552613732 │ +4. │ cat │ 2.752802631487914 │ +5. │ horse │ 2.7555776805484813 │ +6. │ dog │ 3.382295083120104 │ + └────────┴─────────────────────┘ +``` + +**降低精度搜索:** + +```sql +SELECT + word, + L2DistanceTransposed(vec, [-0.88693672, 1.31532824, -0.51182908, -0.99652702, 0.59907770], 12) AS distance +FROM fruit_animal +ORDER BY distance; +``` + +```text + ┌─word───┬───────────distance─┐ +1. │ apple │ 0.757668703053566 │ +2. │ orange │ 1.5499475034938677 │ +3. │ banana │ 1.6168396735102937 │ +4. │ cat │ 2.429752230904804 │ +5. │ horse │ 2.524650475528617 │ +6. │ dog │ 3.17766975527459 │ + └────────┴────────────────────┘ +``` + +请注意,使用 12 位量化时,我们获得了距离的良好近似,并且查询执行更快。相对排序大致保持一致,“apple” 仍然是最接近的匹配。 + +:::note +在当前状态下,加速是由于减少了 I/O,因为我们读取的数据更少。如果原始数据比较宽,例如 `Float64`,选择较低的精度仍会导致在相同宽度的数据上进行距离计算,只是精度较低。 +::: +#### 性能考虑 {#qbit-performance} + +`QBit` 的性能优势来自于减少的 I/O 操作,因为在使用较低精度时需要从存储中读取的数据更少。精度参数直接控制准确性与速度之间的权衡: + +- **更高精度**(接近原始数据宽度):更准确的结果,查询较慢 +- **较低精度**:查询更快,结果近似,减少内存使用 + +:::note +目前,速度的提升来自于减少 I/O,而不是计算优化。当使用较低精度值时,距离计算仍在原始数据宽度上进行。 +::: +### 参考文献 {#references} 博客: - [使用 ClickHouse 进行向量搜索 - 第 1 部分](https://clickhouse.com/blog/vector-search-clickhouse-p1) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/annindexes.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/annindexes.md.hash index b4d7086fc64..e7eaa2001e2 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/annindexes.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/annindexes.md.hash @@ -1 +1 @@ -0717911fec5b2286 +86b0010557b43a5e diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/coalescingmergetree.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/coalescingmergetree.md new file mode 100644 index 00000000000..2ffa8083368 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/coalescingmergetree.md @@ -0,0 +1,141 @@ +--- +'description': 'CoalescingMergeTree 继承自 MergeTree 引擎。其主要特征是在分区合并期间自动存储每个列的最后非空值。' +'sidebar_label': 'CoalescingMergeTree' +'sidebar_position': 50 +'slug': '/engines/table-engines/mergetree-family/coalescingmergetree' +'title': 'CoalescingMergeTree' +'keywords': +- 'CoalescingMergeTree' +'show_related_blogs': true +'doc_type': 'reference' +--- + + +# CoalescingMergeTree + +:::note 从版本 25.6 开始提供 +该表引擎从版本 25.6 及更高版本在 OSS 和 Cloud 中提供。 +::: + +该引擎继承自 [MergeTree](/engines/table-engines/mergetree-family/mergetree)。主要区别在于数据分片的合并方式:对于 `CoalescingMergeTree` 表,ClickHouse 会将所有具有相同主键(或者更准确地说,具有相同的 [排序键](../../../engines/table-engines/mergetree-family/mergetree.md))的行替换为一行,该行包含每列的最新非 NULL 值。 + +这使得列级的 upserts 成为可能,这意味着您可以仅更新特定的列,而不是整个行。 + +`CoalescingMergeTree` 旨在与非键列中的 Nullable 类型一起使用。如果列不是 Nullable,则行为与 [ReplacingMergeTree](/engines/table-engines/mergetree-family/replacingmergetree) 相同。 + +## 创建表 {#creating-a-table} + +```sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE = CoalescingMergeTree([columns]) +[PARTITION BY expr] +[ORDER BY expr] +[SAMPLE BY expr] +[SETTINGS name=value, ...] +``` + +有关请求参数的描述,请参阅 [请求描述](../../../sql-reference/statements/create/table.md)。 + +### CoalescingMergeTree 的参数 {#parameters-of-coalescingmergetree} + +#### 列 {#columns} + +`columns` - 一个包含将要合并的列名的元组。可选参数。 + 这些列必须是数字类型,并且不得在分区或排序键中。 + + 如果未指定 `columns`,ClickHouse 将合并所有不在排序键中的列的值。 + +### 查询子句 {#query-clauses} + +创建 `CoalescingMergeTree` 表时,所需的 [子句](../../../engines/table-engines/mergetree-family/mergetree.md) 与创建 `MergeTree` 表时相同。 + +
+ +创建表的弃用方法 + +:::note +在新项目中不要使用此方法,如果可能,请将旧项目切换到上述方法。 +::: + +```sql +CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] +( + name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1], + name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2], + ... +) ENGINE [=] CoalescingMergeTree(date-column [, sampling_expression], (primary, key), index_granularity, [columns]) +``` + +除了 `columns` 之外,所有参数的含义与 `MergeTree` 相同。 + +- `columns` — 一个包含将被合并的列名的元组。可选参数。有关描述,请参见上面的文字。 + +
+ +## 示例 {#usage-example} + +考虑以下表: + +```sql +CREATE TABLE test_table +( + key UInt64, + value_int Nullable(UInt32), + value_string Nullable(String), + value_date Nullable(Date) +) +ENGINE = CoalescingMergeTree() +ORDER BY key +``` + +向其中插入数据: + +```sql +INSERT INTO test_table VALUES(1, NULL, NULL, '2025-01-01'), (2, 10, 'test', NULL); +INSERT INTO test_table VALUES(1, 42, 'win', '2025-02-01'); +INSERT INTO test_table(key, value_date) VALUES(2, '2025-02-01'); +``` + +结果将如下所示: + +```sql +SELECT * FROM test_table ORDER BY key; +``` + +```text +┌─key─┬─value_int─┬─value_string─┬─value_date─┐ +│ 1 │ 42 │ win │ 2025-02-01 │ +│ 1 │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ 2025-01-01 │ +│ 2 │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ 2025-02-01 │ +│ 2 │ 10 │ test │ ᴺᵁᴸᴸ │ +└─────┴───────────┴──────────────┴────────────┘ +``` + +推荐的查询以获得正确和最终的结果: + +```sql +SELECT * FROM test_table FINAL ORDER BY key; +``` + +```text +┌─key─┬─value_int─┬─value_string─┬─value_date─┐ +│ 1 │ 42 │ win │ 2025-02-01 │ +│ 2 │ 10 │ test │ 2025-02-01 │ +└─────┴───────────┴──────────────┴────────────┘ +``` + +使用 `FINAL` 修饰符强制 ClickHouse 在查询时应用合并逻辑,确保您获得每列的正确合并的“最新”值。这是在从 CoalescingMergeTree 表中查询时最安全和最准确的方法。 + +:::note + +如果基础分片尚未完全合并,则使用 `GROUP BY` 的方法可能会返回不正确的结果。 + +```sql +SELECT key, last_value(value_int), last_value(value_string), last_value(value_date) FROM test_table GROUP BY key; -- Not recommended. +``` + +::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/coalescingmergetree.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/coalescingmergetree.md.hash new file mode 100644 index 00000000000..6b610e5edb2 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/coalescingmergetree.md.hash @@ -0,0 +1 @@ +57c51b17f74316a2 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/collapsingmergetree.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/collapsingmergetree.md index eeac36490f7..b79b0c8d16b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/collapsingmergetree.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/collapsingmergetree.md @@ -1,5 +1,5 @@ --- -'description': '继承自 MergeTree,但在合并过程中添加了崩溃行的逻辑。' +'description': '继承自 MergeTree,但在合并过程中添加了压缩行的逻辑。' 'keywords': - 'updates' - 'collapsing' @@ -7,6 +7,7 @@ 'sidebar_position': 70 'slug': '/engines/table-engines/mergetree-family/collapsingmergetree' 'title': 'CollapsingMergeTree' +'doc_type': 'guide' --- @@ -14,21 +15,19 @@ ## 描述 {#description} -`CollapsingMergeTree` 引擎继承自 [MergeTree](../../../engines/table-engines/mergetree-family/mergetree.md),并在合并过程中添加了行合并的逻辑。 -`CollapsingMergeTree` 表引擎异步删除(合并)一对行,前提是排序键 (`ORDER BY`) 中的所有字段相等,除了特殊字段 `Sign`,其值可以是 `1` 或 `-1`。 -没有相反值 `Sign` 的行会被保留。 +`CollapsingMergeTree` 引擎继承自 [MergeTree](../../../engines/table-engines/mergetree-family/mergetree.md),并在合并过程中添加了行折叠的逻辑。 `CollapsingMergeTree` 表引擎异步删除(折叠)成对的行,如果排序键(`ORDER BY`)中的所有字段除特殊字段 `Sign` 外都是相同的,`Sign` 可以有 `1` 或 `-1` 的值。 没有成对的相反值 `Sign` 的行将被保留。 有关更多详细信息,请参见文档的 [Collapsing](#table_engine-collapsingmergetree-collapsing) 部分。 :::note -该引擎可以显著减少存储量,从而提高 `SELECT` 查询的效率。 +此引擎可能会显著减少存储量,从而提高 `SELECT` 查询的效率。 ::: ## 参数 {#parameters} -该表引擎的所有参数,除了 `Sign` 参数外,具有与 [`MergeTree`](/engines/table-engines/mergetree-family/mergetree) 相同的含义。 +此表引擎的所有参数,除了 `Sign` 参数,与你在 [`MergeTree`](/engines/table-engines/mergetree-family/mergetree) 中看到的含义相同。 -- `Sign` — 代表行类型的列的名称,其中 `1` 是 "状态" 行, `-1` 是 "取消" 行。类型:[Int8](/sql-reference/data-types/int-uint)。 +- `Sign` — 指定一列的名称,该列的行类型,其中 `1` 是 "状态" 行,`-1` 是 "取消" 行。 类型:[Int8](/sql-reference/data-types/int-uint)。 ## 创建表 {#creating-a-table} @@ -48,11 +47,10 @@ ENGINE = CollapsingMergeTree(Sign)
-创建表的弃用方法 +创建表的废弃方法 :::note -下面的方法不建议在新项目中使用。 -我们建议,如果可能,更新旧项目以使用新方法。 +下面的方法不建议在新项目中使用。 如果可能,我们建议将旧项目更新为使用新方法。 ::: ```sql @@ -65,27 +63,23 @@ CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] ENGINE [=] CollapsingMergeTree(date-column [, sampling_expression], (primary, key), index_granularity, Sign) ``` -`Sign` — 代表行类型的列的名称,其中 `1` 是 "状态" 行, `-1` 是 "取消" 行。[Int8](/sql-reference/data-types/int-uint)。 +`Sign` — 指定一列的名称,该列的行类型,其中 `1` 是 "状态" 行,`-1` 是 "取消" 行。[Int8](/sql-reference/data-types/int-uint)。
- 有关查询参数的描述,请参见 [查询描述](../../../sql-reference/statements/create/table.md)。 -- 创建 `CollapsingMergeTree` 表时,所需的 [查询子句](../../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-creating-a-table) 与创建 `MergeTree` 表时所需的相同。 +- 创建 `CollapsingMergeTree` 表时,所需的 [查询子句](../../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-creating-a-table) 与创建 `MergeTree` 表的相同。 -## 合并 {#table_engine-collapsingmergetree-collapsing} +## 折叠 {#table_engine-collapsingmergetree-collapsing} ### 数据 {#data} -考虑需要为某一给定对象保存不断变化的数据的情况。 -每个对象有一行并在每次变化时更新听起来很合理,然而,更新操作对 DBMS 来说开销大且缓慢,因为它们需要重写存储中的数据。 -如果我们需要快速写入数据,执行大量更新的方法是不可接受的,但我们可以始终顺序写入对象的更改。 -为此,我们使用特殊列 `Sign`。 +考虑一种情况,你需要保存某个给定对象的持续变化数据。 将每个对象设置为一行并在任何变化时更新它似乎是合乎逻辑的,然而,更新操作对于 DBMS 而言是昂贵且缓慢的,因为它们需要在存储中重写数据。 如果我们需要快速写入数据,执行大量更新操作并不是一个可接受的方法,但我们始终可以顺序写入一个对象的更改。 为此,我们利用特殊列 `Sign`。 -- 如果 `Sign` = `1`,则表示该行是 "状态" 行:_包含表示当前有效状态的字段的行_。 +- 如果 `Sign` = `1`,则表示该行是 "状态" 行:_包含表示当前有效状态的字段的行_。 - 如果 `Sign` = `-1`,则表示该行是 "取消" 行:_用于取消具有相同属性的对象状态的行_。 -例如,我们想计算用户在某个网站上查看了多少页面以及他们访问页面的持续时间。 -在某一时刻,我们写入以下表示用户活动状态的行: +例如,我们想计算用户在某个网站上查看了多少页面,以及他们访问这些页面的时间。在某个特定时刻,我们记录用户活动的状态如下: ```text ┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ @@ -93,7 +87,7 @@ ENGINE [=] CollapsingMergeTree(date-column [, sampling_expression], (primary, ke └─────────────────────┴───────────┴──────────┴──────┘ ``` -在稍后的时刻,我们记录用户活动的变化并写入以下两行: +在稍后的时刻,我们记录第一次用户活动的变化并用以下两行写入: ```text ┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ @@ -102,10 +96,9 @@ ENGINE [=] CollapsingMergeTree(date-column [, sampling_expression], (primary, ke └─────────────────────┴───────────┴──────────┴──────┘ ``` -第一行取消了对象的先前状态(在这种情况下表示用户)。它应复制 "取消" 行的所有排序键字段,除了 `Sign`。 -上面的第二行包含当前状态。 +第一行取消了对象的先前状态(在这个例子中表示一个用户)。 它应该复制除 `Sign` 外的所有排序键字段。 上面的第二行包含当前状态。 -由于我们只需要用户活动的最后状态,因此可以删除我们插入的原始 "状态" 行和 "取消" 行,如下所示,合并对象的无效(旧)状态: +由于我们只需要用户活动的最后状态,因此我们可以按如下方式删除原始的 "状态" 行和我们插入的 "取消" 行,从而折叠对象的无效(旧)状态: ```text ┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ @@ -115,52 +108,41 @@ ENGINE [=] CollapsingMergeTree(date-column [, sampling_expression], (primary, ke └─────────────────────┴───────────┴──────────┴──────┘ ``` -`CollapsingMergeTree` 在数据分片合并时执行确切的 _合并_ 行为。 +`CollapsingMergeTree` 正是实现这种 _折叠_ 行为,在数据部分合并的过程中发生。 :::note -对此为何每次更改需要两行的原因将在 [算法](#table_engine-collapsingmergetree-collapsing-algorithm) 段落中进一步讨论。 +有关为什么每次变化都需要两行的原因,详见 [算法](#table_engine-collapsingmergetree-collapsing-algorithm) 部分。 ::: **这种方法的特殊性** -1. 编写数据的程序应该记住对象的状态,以便能取消它。"取消" 行应包含 "状态" 行的排序键字段的副本和相反的 `Sign`。这增加了初始存储大小,但使我们能够快速写入数据。 -2. 列中长的增长数组由于写入的负载增加而降低引擎的效率。数据越简单,效率越高。 -3. `SELECT` 结果在很大程度上取决于对象变化历史的一致性。准备插入数据时要准确。使用不一致的数据可能会导致不可预测的结果。例如,非负指标如会话深度的负值。 +1. 编写数据的程序应记住对象的状态,以便能够取消它。 "取消" 行应包含 "状态" 行的排序键字段的副本和相反的 `Sign`。 这增加了存储的初始大小,但允许我们快速写入数据。 +2. 列中较长的递增数组会因写入负载增加而降低引擎效率。 数据越简单,效率越高。 +3. `SELECT` 结果很大程度上依赖于对象变更历史的一致性。 准备插入数据时要准确。 数据不一致可能会导致不可预测的结果。 例如,非负指标(如会话深度)的负值。 ### 算法 {#table_engine-collapsingmergetree-collapsing-algorithm} -当 ClickHouse 合并数据 [片段](/concepts/glossary#parts) 时,具有相同排序键 (`ORDER BY`) 的连续行组最多合并为两行,即 "状态" 行 `Sign` = `1` 和 "取消" 行 `Sign` = `-1`。 -换句话说,在 ClickHouse 中条目会合并。 +当 ClickHouse 合并 [部分](/concepts/glossary#parts) 时,每组具有相同排序键(`ORDER BY`)的连续行最多减少为两行,即 "状态" 行与 `Sign` = `1` 和 "取消" 行与 `Sign` = `-1`。 换句话说,在 ClickHouse 条目中会进行折叠。 -对于每个生成的数据片段,ClickHouse 保存: +对于每个生成的数据部分,ClickHouse 保存: | | | |--|-------------------------------------------------------------------------------------------------------------------------------------| -|1.| 第一个 "取消" 行和最后一个 "状态" 行,如果 "状态" 行和 "取消" 行的数量相匹配,并且最后一行是 "状态" 行。 | -|2.| 如果 "状态" 行的数量多于 "取消" 行,则最后一个 "状态" 行。 | -|3.| 如果 "取消" 行的数量多于 "状态" 行,则第一个 "取消" 行。 | -|4.| 在所有其他情况下,没有行。 | +|1.| 如果 "状态" 行与 "取消" 行的数量相匹配,并且最后一行是 "状态" 行,则保存首个 "取消" 行和最后一个 "状态" 行。 | +|2.| 如果 "状态" 行的数量大于 "取消" 行,则保存最后一个 "状态" 行。 | +|3.| 如果 "取消" 行的数量大于 "状态" 行,则保存首个 "取消" 行。 | +|4.| 在所有其他情况下,不保存行。 | -此外,当 "状态" 行的数量至少比 "取消" 行多两个或 "取消" 行的数量至少比 "状态" 行多两个时,合并将继续。 -然而,ClickHouse 将这种情况视为逻辑错误,并记录在服务器日志中。 -若同一数据被插入多次,就会出现此错误。因此,合并不应改变统计计算的结果。 -更改会逐渐合并,最终几乎每个对象只留下最后状态。 +此外,当 "状态" 行数量至少比 "取消" 行数量多两个,或 "取消" 行数量至少比 "状态" 行数量多两个时,合并将继续。 但是,ClickHouse 将把此情况视为逻辑错误并记录在服务器日志中。 该错误可能会发生在相同数据多次插入的情况下。 因此,折叠不应改变计算统计结果。 更改会逐渐紧缩,最终只保留几乎每个对象的最后状态。 -`Sign` 列是必需的,因为合并算法无法保证所有具有相同排序键的行都会位于同一生成的数据片段中,甚至在同一物理服务器上。 -ClickHouse 通过多个线程处理 `SELECT` 查询,无法预测结果中的行顺序。 +`Sign` 列是必需的,因为合并算法并不能保证所有具有相同排序键的行会在同一结果数据部分中,甚至在同一物理服务器上。 ClickHouse 使用多个线程处理 `SELECT` 查询,无法预测结果中行的顺序。 -如果需要从 `CollapsingMergeTree` 表获取完全"合并"的数据,则需要聚合。 -为了最终完成合并,编写带有 `GROUP BY` 子句和考虑到 Sign 的聚合函数的查询。 -例如,要计算数量,使用 `sum(Sign)` 而不是 `count()`。 -要计算某物的总和,使用 `sum(Sign * x)` 和 `HAVING sum(Sign) > 0`,而不是 `sum(x)`,如以下 [示例](#example-of-use) 所示。 +如果需要从 `CollapsingMergeTree` 表中获取完全 "折叠" 的数据,则需要聚合。 为了完成折叠,请使用 `GROUP BY` 子句和适当考虑符号的聚合函数来编写查询。 例如,计算数量时,使用 `sum(Sign)` 而不是 `count()`。 要计算某个值的总和,使用 `sum(Sign * x)` 并结合 `HAVING sum(Sign) > 0`,而不是 `sum(x)`,如 [示例](#example-of-use) 中所示。 -聚合 `count`、`sum` 和 `avg` 可以这样计算。 -如果一个对象至少有一个未合并的状态,则可以计算聚合 `uniq`。 -聚合 `min` 和 `max` 不能计算,因为 `CollapsingMergeTree` 不保存合并状态的历史。 +聚合 `count`、`sum` 和 `avg` 可以这样计算。 如果一个对象有至少一个未折叠的状态,则可以计算聚合 `uniq`。 聚合 `min` 和 `max` 不能计算,因为 `CollapsingMergeTree` 不保存折叠状态的历史。 :::note -如果您需要无聚合地提取数据(例如,检查最新值是否符合特定条件的行是否存在),您可以使用 `FROM` 子句的 [`FINAL`](../../../sql-reference/statements/select/from.md#final-modifier) 修饰符。它会在返回结果之前合并数据。 -对于 `CollapsingMergeTree`,仅返回每个键的最新状态行。 +如果你需要提取没有聚合的数据(例如,检查是否存在行其最新值符合某些条件),可以使用 `FROM` 子句的 [`FINAL`](../../../sql-reference/statements/select/from.md#final-modifier) 修饰符。 它会在返回结果之前合并数据。 对于 CollapsingMergeTree,将仅返回每个键的最新状态行。 ::: ## 示例 {#examples} @@ -177,7 +159,7 @@ ClickHouse 通过多个线程处理 `SELECT` 查询,无法预测结果中的 └─────────────────────┴───────────┴──────────┴──────┘ ``` -让我们使用 `CollapsingMergeTree` 创建一个表 `UAct`: +我们使用 `CollapsingMergeTree` 创建表 `UAct`: ```sql CREATE TABLE UAct @@ -191,7 +173,7 @@ ENGINE = CollapsingMergeTree(Sign) ORDER BY UserID ``` -接下来我们将插入一些数据: +接下来,我们将插入一些数据: ```sql INSERT INTO UAct VALUES (4324182021466249494, 5, 146, 1) @@ -201,13 +183,13 @@ INSERT INTO UAct VALUES (4324182021466249494, 5, 146, 1) INSERT INTO UAct VALUES (4324182021466249494, 5, 146, -1),(4324182021466249494, 6, 185, 1) ``` -我们使用两个 `INSERT` 查询创建两个不同的数据片段。 +我们使用两个 `INSERT` 查询来创建两个不同的数据部分。 :::note -如果我们通过单个查询插入数据,ClickHouse 只会创建一个数据片段,并且将不会执行任何合并。 +如果我们用一个查询插入数据,ClickHouse 只会创建一个数据部分,并且不会执行任何合并。 ::: -我们可以使用以下内容选择数据: +我们可以使用以下语句选择数据: ```sql SELECT * FROM UAct @@ -223,13 +205,12 @@ SELECT * FROM UAct └─────────────────────┴───────────┴──────────┴──────┘ ``` -让我们查看上面返回的数据,看看合并是否发生... -通过两个 `INSERT` 查询,我们创建了两个数据片段。 -该 `SELECT` 查询在两个线程中执行,并且我们得到了随机的行顺序。 -然而,合并 **没有发生**,因为数据片段尚未合并,而 ClickHouse 在我们无法预测的时刻在后台合并数据片段。 +让我们查看上面返回的数据,看看是否发生了折叠... +通过两个 `INSERT` 查询,我们创建了两个数据部分。 +`SELECT` 查询在两个线程中执行,我们得到了随机顺序的行。 +然而,折叠 **并未发生**,因为数据部分尚未合并,而 ClickHouse 在一个未知的时刻在后台合并数据部分,我们无法预测。 -因此,我们需要进行一次聚合 -我们通过 [`sum`](/sql-reference/aggregate-functions/reference/sum) 聚合函数和 [`HAVING`](/sql-reference/statements/select/having) 子句来执行: +因此,我们需要一个聚合,我们使用 [`sum`](/sql-reference/aggregate-functions/reference/sum) 聚合函数和 [`HAVING`](/sql-reference/statements/select/having) 子句来执行: ```sql SELECT @@ -247,7 +228,7 @@ HAVING sum(Sign) > 0 └─────────────────────┴───────────┴──────────┘ ``` -如果我们不需要聚合并希望强制合并,也可以对 `FROM` 子句使用 `FINAL` 修饰符。 +如果我们不需要聚合并希望强制进行折叠,我们也可以对 `FROM` 子句使用 `FINAL` 修饰符。 ```sql SELECT * FROM UAct FINAL @@ -259,15 +240,14 @@ SELECT * FROM UAct FINAL └─────────────────────┴───────────┴──────────┴──────┘ ``` :::note -这种选择数据的方式效率较低,不建议在扫描大量数据(数百万行)时使用。 +这种选择数据的方式效率较低,并且不建议在大量扫描数据(数百万行)时使用。 ::: ### 另一种方法的示例 {#example-of-another-approach} -该方法的想法是,合并仅考虑关键字段。 -因此,在 "取消" 行中,我们可以指定负值,在求和时等同于先前版本的行,而无需使用 `Sign` 列。 +该方法的基本思想是合并仅考虑键字段。 因此,在 "取消" 行中,我们可以指定负值,以在求和时抵消行的先前版本,而不使用 `Sign` 列。 -对于此示例,我们将使用以下样本数据: +对于此示例,我们将使用以下示例数据: ```text ┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┐ @@ -277,8 +257,7 @@ SELECT * FROM UAct FINAL └─────────────────────┴───────────┴──────────┴──────┘ ``` -为此方法,必须更改 `PageViews` 和 `Duration` 的数据类型以存储负值。 -因此,在使用 `collapsingMergeTree` 创建我们的表 `UAct` 时,我们将这些列的值从 `UInt8` 更改为 `Int16`: +对于这种方法,有必要将 `PageViews` 和 `Duration` 的数据类型更改为存储负值。 因此,我们在使用 `collapsingMergeTree` 创建 `UAct` 表时,将这些列的值从 `UInt8` 更改为 `Int16`: ```sql CREATE TABLE UAct @@ -292,9 +271,9 @@ ENGINE = CollapsingMergeTree(Sign) ORDER BY UserID ``` -让我们通过向我们的表插入数据来测试该方法。 +让我们通过向表中插入数据来测试该方法。 -对于示例或小表,然而,是可接受的: +对于示例或小表,使用此方法是可以接受的: ```sql INSERT INTO UAct VALUES(4324182021466249494, 5, 146, 1); diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/collapsingmergetree.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/collapsingmergetree.md.hash index 636a6030eae..f0497b75b97 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/collapsingmergetree.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/collapsingmergetree.md.hash @@ -1 +1 @@ -dc19e21d60bf17b0 +9187f8b301ec0501 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/custom-partitioning-key.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/custom-partitioning-key.md index 9b749db3629..e194660d1d2 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/custom-partitioning-key.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/custom-partitioning-key.md @@ -1,25 +1,26 @@ --- -'description': '了解如何将自定义分区键添加到 MergeTree 表。' +'description': '学习如何为 MergeTree 表添加自定义分区键。' 'sidebar_label': '自定义分区键' 'sidebar_position': 30 'slug': '/engines/table-engines/mergetree-family/custom-partitioning-key' 'title': '自定义分区键' +'doc_type': 'guide' --- # 自定义分区键 :::note -在大多数情况下,您无需分区键,而在其他大多数情况下,您不需要比按月更细粒度的分区键。 +在大多数情况下,您不需要分区键,在大多数其他情况下,您不需要比按月份更细粒度的分区键。 -您绝不应使用过于细粒度的分区。不要按客户标识符或名称对数据进行分区。相反,将客户标识符或名称放在 ORDER BY 表达式的第一列中。 +您永远不应该使用过于细粒度的分区。不要根据客户标识符或名称对数据进行分区。相反,请将客户标识符或名称作为 ORDER BY 表达式中的第一列。 ::: -分区对于 [MergeTree 家族表](../../../engines/table-engines/mergetree-family/mergetree.md) 可用,包括 [复制表](../../../engines/table-engines/mergetree-family/replication.md) 和 [物化视图](/sql-reference/statements/create/view#materialized-view)。 +分区可用于 [MergeTree 系列表](../../../engines/table-engines/mergetree-family/mergetree.md),包括 [复制表](../../../engines/table-engines/mergetree-family/replication.md) 和 [物化视图](/sql-reference/statements/create/view#materialized-view)。 -分区是按指定标准对表中记录的逻辑组合。您可以通过任意标准设置分区,例如按月、按天或按事件类型。每个分区单独存储,以简化对该数据的操作。在访问数据时,ClickHouse 使用尽可能小的分区子集。分区提高了包含分区键的查询性能,因为 ClickHouse 会在选择分区内的 parts 和 granules 之前过滤出该分区。 +分区是将表中的记录按指定标准进行逻辑组合。您可以根据任意标准设置分区,例如按月份、按天或按事件类型。每个分区单独存储,以简化对这些数据的操作。在访问数据时,ClickHouse 会使用尽可能小的分区子集。对于包含分区键的查询,分区可以提高性能,因为 ClickHouse 会在选择分区内的部分和颗粒之前对该分区进行过滤。 -在 [创建表](../../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-creating-a-table) 时,使用 `PARTITION BY expr` 子句指定分区。分区键可以是表列中的任何表达式。例如,要按月指定分区,可以使用表达式 `toYYYYMM(date_column)`: +在 [创建表](../../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-creating-a-table) 时,可以在 `PARTITION BY expr` 子句中指定分区。分区键可以是表列中的任何表达式。例如,要按月份指定分区,可以使用表达式 `toYYYYMM(date_column)`: ```sql CREATE TABLE visits @@ -41,17 +42,17 @@ PARTITION BY (toMonday(StartDate), EventType) ORDER BY (CounterID, StartDate, intHash32(UserID)); ``` -在此示例中,我们设置按当前周发生的事件类型进行分区。 +在这个例子中,我们根据当前周发生的事件类型设置分区。 -默认情况下,不支持浮点分区键。要使用它,请启用设置 [allow_floating_point_partition_key](../../../operations/settings/merge-tree-settings.md#allow_floating_point_partition_key)。 +默认情况下,不支持浮点数分区键。要使用它,请启用设置 [allow_floating_point_partition_key](../../../operations/settings/merge-tree-settings.md#allow_floating_point_partition_key)。 -当向表中插入新数据时,这些数据作为按主键排序的单独部分(块)存储。在插入后的 10-15 分钟后,同一分区的部分会合并为整个部分。 +插入新数据到表时,这些数据作为按主键排序的独立部分(块)存储。在插入后的 10-15 分钟内,相同分区的部分将被合并为完整部分。 :::info -合并仅适用于在分区表达式上具有相同值的数据部分。这意味着 **您不应创建过于细粒度的分区**(大约超过一千个分区)。否则,`SELECT` 查询的性能会很差,因为文件系统中存在不合理数量的文件和打开的文件描述符。 +仅对具有相同分区表达式值的数据部分进行合并。这意味着 **您不应该创建过于细粒度的分区**(超过大约一千个分区)。否则,`SELECT` 查询的性能会受到影响,因为文件系统中的文件数量和打开的文件描述符过大。 ::: -使用 [system.parts](../../../operations/system-tables/parts.md) 表查看表的部分和分区。例如,假设我们有一个按月分区的 `visits` 表。让我们对 `system.parts` 表执行 `SELECT` 查询: +使用 [system.parts](../../../operations/system-tables/parts.md) 表查看表的部分和分区。例如,假设我们有一个以月份分区的 `visits` 表。让我们对 `system.parts` 表执行 `SELECT` 查询: ```sql SELECT @@ -74,25 +75,25 @@ WHERE table = 'visits' └───────────┴───────────────────┴────────┘ ``` -`partition` 列包含分区的名称。在此示例中有两个分区:`201901` 和 `201902`。您可以使用此列值在 [ALTER ... PARTITION](../../../sql-reference/statements/alter/partition.md) 查询中指定分区名称。 +`partition` 列包含分区的名称。在这个例子中有两个分区:`201901` 和 `201902`。您可以使用此列的值在 [ALTER ... PARTITION](../../../sql-reference/statements/alter/partition.md) 查询中指定分区名称。 `name` 列包含分区数据部分的名称。您可以使用此列在 [ALTER ATTACH PART](/sql-reference/statements/alter/partition#attach-partitionpart) 查询中指定部分的名称。 -让我们分解部分名称:`201901_1_9_2_11`: +我们来分解部分的名称:`201901_1_9_2_11`: - `201901` 是分区名称。 - `1` 是数据块的最小编号。 - `9` 是数据块的最大编号。 -- `2` 是块级别(它形成的合并树深度)。 -- `11` 是变更版本(如果部分已变更) +- `2` 是块级别(它由合并树形成的深度)。 +- `11` 是变更版本(如果部分发生变更) :::info 旧类型表的部分名称为:`20190117_20190123_2_2_0`(最小日期 - 最大日期 - 最小块编号 - 最大块编号 - 级别)。 ::: -`active` 列显示部分的状态。`1` 为活动;`0` 为非活动。例如,合并到较大部分后的源部分会变为非活动。损坏的数据部分也标识为非活动。 +`active` 列显示部分的状态。`1` 表示活动;`0` 表示非活动。例如,合并到较大部分后,剩下的源部分就是非活动部分。损坏的数据部分也会标记为非活动。 -正如示例所示,同一分区存在几个独立的部分(例如,`201901_1_3_1` 和 `201901_1_9_2`)。这意味着这些部分尚未合并。ClickHouse 会定期合并已插入的数据部分,约 15 分钟后。在此基础上,您可以通过 [OPTIMIZE](../../../sql-reference/statements/optimize.md) 查询执行非计划的合并。示例: +如您所见,在这个例子中,同一分区有几个独立的部分(例如,`201901_1_3_1` 和 `201901_1_9_2`)。这意味着这些部分尚未合并。ClickHouse 会定期合并插入的数据部分,约在插入后 15 分钟之后。此外,您可以使用 [OPTIMIZE](../../../sql-reference/statements/optimize.md) 查询执行非计划合并。例如: ```sql OPTIMIZE TABLE visits PARTITION 201902; @@ -111,9 +112,9 @@ OPTIMIZE TABLE visits PARTITION 201902; └───────────┴──────────────────┴────────┘ ``` -非活动部分将在合并后大约 10 分钟删除。 +非活动部分将在合并后约 10 分钟内被删除。 -查看一组部分和分区的另一种方法是进入表的目录:`/var/lib/clickhouse/data///`。例如: +查看部分和分区的另一种方法是进入表的目录:`/var/lib/clickhouse/data//
/`。例如: ```bash /var/lib/clickhouse/data/default/visits$ ls -l @@ -129,20 +130,21 @@ drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 5 12:09 201902_4_6_1 drwxr-xr-x 2 clickhouse clickhouse 4096 Feb 1 16:48 detached ``` -文件夹 '201901_1_1_0'、'201901_1_7_1' 等是部分的目录。每个部分属于相应的分区,并仅包含特定月份的数据(此示例中的表按月分区)。 +目录中的 '201901_1_1_0'、'201901_1_7_1' 等是部分的目录。每个部分与对应的分区相关,只包含某个月的数据(这个例子的表是按月份分区的)。 -`detached` 目录包含通过 [DETACH](/sql-reference/statements/detach) 查询从表中分离的部分。损坏的部分也移动到该目录,而不是被删除。服务器不使用 `detached` 目录中的部分。您可以在此目录中随时添加、删除或修改数据 – 直到您运行 [ATTACH](/sql-reference/statements/alter/partition#attach-partitionpart) 查询,服务器才会知道。 +`detached` 目录包含通过 [DETACH](/sql-reference/statements/detach) 查询从表中分离的部分。损坏的部分也会移到此目录,而不是被删除。服务器不会使用 `detached` 目录中的部分。您可以随时在此目录中添加、删除或修改数据 – 服务器在您运行 [ATTACH](/sql-reference/statements/alter/partition#attach-partitionpart) 查询之前不会知道这些。 -请注意,在运行的服务器上,您不能手动更改文件系统中部分或其数据的集合,因为服务器不会了解此情况。对于非复制表,您可以在服务器停止时执行此操作,但不推荐这样做。在任何情况下,对于复制表,则无法更改部分的集合。 +请注意,在运行服务器上,您不能手动更改文件系统上的部分集或其数据,因为服务器不会知道这一点。对于非复制表,您可以在服务器停止时执行此操作,但不建议这样做。对于复制表,部分集在任何情况下都不能更改。 -ClickHouse 允许您对分区执行操作:删除、从一个表复制到另一个表或创建备份。请参见 [对分区和部分的操作]( /sql-reference/statements/alter/partition) 部分中的所有操作列表。 +ClickHouse 允许您对分区执行操作:删除它们、从一个表复制到另一个表或创建备份。有关所有操作的列表,请参见 [对分区和部分的操作](/sql-reference/statements/alter/partition) 部分。 ## 使用分区键的 Group By 优化 {#group-by-optimisation-using-partition-key} -对于某些表的分区键和查询的分组键组合,可以独立地针对每个分区执行聚合。 -然后,我们不必在最后合并所有执行线程的部分聚合数据,因为我们提供了保证,确保每个分组键值不会出现在两个不同线程的工作集中的情况。 +对于某些表的分区键与查询的 group by 键组合,可能可以独立地为每个分区执行聚合。 +这样,我们在最后就不需要合并来自所有执行线程的部分聚合数据, +因为我们有保证每个 group by 键值不能出现在两个不同线程的工作集中。 -一个典型的例子是: +典型例子是: ```sql CREATE TABLE session_log @@ -162,21 +164,21 @@ GROUP BY UserID; ``` :::note -此类查询的性能在很大程度上依赖于表的布局。因此,优化默认未启用。 +此类查询的性能在很大程度上取决于表的布局。因此,优化默认情况下未启用。 ::: 良好性能的关键因素: -- 查询中涉及的分区数量应足够大(大于 `max_threads / 2`),否则查询将无法充分利用该机器 -- 分区不应太小,以免批处理降级为逐行处理 -- 分区应在大小上可比,以便所有线程大致完成相同工作量 +- 查询中涉及的分区数量应足够大(超过 `max_threads / 2`),否则查询将未充分利用机器 +- 分区不应过小,以免批处理变成逐行处理 +- 分区应在大小上相当,因此所有线程大致执行相同数量的工作 :::info -建议对 `partition by` 子句中的列应用某些哈希函数,以便在分区之间均匀分配数据。 +建议对 `partition by` 子句中的列应用某种哈希函数,以便在分区之间均匀分布数据。 ::: -相关设置为: +相关设置包括: -- `allow_aggregate_partitions_independently` - 控制优化的使用是否启用 -- `force_aggregate_partitions_independently` - 在从正确性的角度看适用时强制使用该优化,但出于评估其合理性的内部逻辑而被禁用 -- `max_number_of_partitions_for_independent_aggregation` - 表可以拥有的最大分区数的硬限制 +- `allow_aggregate_partitions_independently` - 控制优化使用是否启用 +- `force_aggregate_partitions_independently` - 在从正确性角度适用时强制使用,即使因内部逻辑评估其合理性而被禁用 +- `max_number_of_partitions_for_independent_aggregation` - 表可以拥有的最大分区数量的硬限制 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/custom-partitioning-key.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/custom-partitioning-key.md.hash index 68a3ddca8c7..719946702fd 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/custom-partitioning-key.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/custom-partitioning-key.md.hash @@ -1 +1 @@ -980ce16c01fb58e2 +9d915a047c4edfc6 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/graphitemergetree.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/graphitemergetree.md index f27cb4300bc..398c57621b1 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/graphitemergetree.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/graphitemergetree.md @@ -1,17 +1,18 @@ --- -'description': '旨在对 Graphite 数据进行缩减和聚合/平均 (rollup)。' +'description': '旨在精简和聚合/平均 (rollup) Graphite 数据。' 'sidebar_label': 'GraphiteMergeTree' 'sidebar_position': 90 'slug': '/engines/table-engines/mergetree-family/graphitemergetree' 'title': 'GraphiteMergeTree' +'doc_type': 'guide' --- # GraphiteMergeTree -此引擎旨在为 [Graphite](http://graphite.readthedocs.io/en/latest/index.html) 数据进行稀疏和聚合/平均(汇总)。对于希望将 ClickHouse 作为 Graphite 数据存储的开发人员而言,这可能会很有帮助。 +此引擎用于精简和聚合/平均(汇总) [Graphite](http://graphite.readthedocs.io/en/latest/index.html) 数据。它可能对希望将 ClickHouse 用作 Graphite 数据存储的开发人员很有帮助。 -如果您不需要汇总,可以使用任何 ClickHouse 表引擎来存储 Graphite 数据,但如果您需要汇总,请使用 `GraphiteMergeTree`。该引擎能够减少存储的体积,并提高来自 Graphite 的查询效率。 +如果您不需要汇总,可以使用任何 ClickHouse 表引擎来存储 Graphite 数据,但如果需要汇总,请使用 `GraphiteMergeTree`。该引擎减少了存储量并提高了从 Graphite 查询的效率。 该引擎继承了 [MergeTree](../../../engines/table-engines/mergetree-family/mergetree.md) 的属性。 @@ -32,17 +33,17 @@ CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] [SETTINGS name=value, ...] ``` -请参阅 [CREATE TABLE](/sql-reference/statements/create/table) 查询的详细描述。 +请参见 [CREATE TABLE](/sql-reference/statements/create/table) 查询的详细描述。 -Graphite 数据的表应具有以下列,以存储以下数据: +Graphite 数据的表应具有以下列以存储以下数据: -- 指标名称(Graphite 传感器)。数据类型: `String`。 +- 指标名称(Graphite 传感器)。数据类型:`String`。 -- 测量指标的时间。数据类型: `DateTime`。 +- 测量该指标的时间。数据类型:`DateTime`。 -- 指标值。数据类型: `Float64`。 +- 指标的值。数据类型:`Float64`。 -- 指标版本。数据类型:任何数字(ClickHouse 会在版本相同的情况下保存最新的行或最后写入的行。其他行将在数据分片合并期间被删除)。 +- 指标的版本。数据类型:任何数字(ClickHouse 保存具有最高版本的行或如果版本相同则保存最后写入的行。其他行在数据部分的合并过程中被删除)。 这些列的名称应在汇总配置中设置。 @@ -52,14 +53,14 @@ Graphite 数据的表应具有以下列,以存储以下数据: **查询子句** -在创建 `GraphiteMergeTree` 表时,所需的 [子句](../../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-creating-a-table) 与创建 `MergeTree` 表时相同。 +创建 `GraphiteMergeTree` 表时,所需的 [子句](../../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-creating-a-table) 与创建 `MergeTree` 表时相同。
-创建表的弃用方法 +创建表的已弃用方法 :::note -请勿在新项目中使用此方法,如果可能,请将旧项目切换到上述描述的方法。 +在新项目中请勿使用此方法,并在可能的情况下将旧项目切换到上述方法。 ::: ```sql @@ -74,7 +75,7 @@ CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] ) ENGINE [=] GraphiteMergeTree(date-column [, sampling_expression], (primary, key), index_granularity, config_section) ``` -除 `config_section` 外,所有参数的含义与 `MergeTree` 中相同。 +除 `config_section` 之外,所有参数的含义与 `MergeTree` 中相同。 - `config_section` — 配置文件中设置汇总规则的部分名称。 @@ -82,30 +83,30 @@ CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] ## 汇总配置 {#rollup-configuration} -汇总的设置由服务器配置中的 [graphite_rollup](../../../operations/server-configuration-parameters/settings.md#graphite) 参数定义。该参数的名称可以是任意的。您可以创建多个配置并将它们用于不同的表。 +汇总的设置由服务器配置中的 [graphite_rollup](../../../operations/server-configuration-parameters/settings.md#graphite) 参数定义。参数的名称可以是任意的。您可以创建多个配置,并将它们用于不同的表。 汇总配置结构: required-columns patterns -### 必需列 {#required-columns} +### 必需的列 {#required-columns} -#### path_column_name {#path_column_name} +#### `path_column_name` {#path_column_name} -`path_column_name` — 存储指标名称(Graphite 传感器)的列名称。默认值: `Path`。 +`path_column_name` — 存储指标名称(Graphite 传感器)的列名。默认值:`Path`。 -#### time_column_name {#time_column_name} +#### `time_column_name` {#time_column_name} -`time_column_name` — 存储测量该指标时间的列名称。默认值: `Time`。 +`time_column_name` — 存储测量指标时间的列名。默认值:`Time`。 -#### value_column_name {#value_column_name} +#### `value_column_name` {#value_column_name} -`value_column_name` — 存储在 `time_column_name` 指定的时间时指标值的列名称。默认值: `Value`。 +`value_column_name` — 存储在 `time_column_name` 中设置的时间点的指标值的列名。默认值:`Value`。 -#### version_column_name {#version_column_name} +#### `version_column_name` {#version_column_name} -`version_column_name` — 存储指标版本的列名称。默认值: `Timestamp`。 +`version_column_name` — 存储指标版本的列名。默认值:`Timestamp`。 ### 模式 {#patterns} @@ -136,30 +137,31 @@ default ``` :::important -模式必须严格按顺序排列: +模式必须严格排序: 1. 没有 `function` 或 `retention` 的模式。 -1. 既有 `function` 又有 `retention` 的模式。 -1. 默认模式。 +1. 同时具有 `function` 和 `retention` 的模式。 +1. `default` 模式。 ::: -在处理行时,ClickHouse 检查 `pattern` 部分中的规则。每个 `pattern`(包括 `default`)部分可以包含用于聚合的 `function` 参数、`retention` 参数或两者。如果指标名称与 `regexp` 匹配,则应用该 `pattern` 部分(或部分)的规则;否则,将使用 `default` 部分的规则。 +在处理行时,ClickHouse检查 `pattern` 部分中的规则。每个 `pattern`(包括 `default`)部分可以包含用于聚合的 `function` 参数、`retention` 参数或两者。如果指标名称与 `regexp` 匹配,则应用 `pattern` 部分(或部分)的规则;否则,使用 `default` 部分的规则。 `pattern` 和 `default` 部分的字段: -- `rule_type` - 规则类型。它仅适用于特定指标。引擎使用它来区分普通指标和带标签指标。可选参数。默认值: `all`。当性能不重要或仅使用一种指标类型(例如普通指标)时,不需要使用。如果定义了任何特殊类型,系统将创建两种不同的规则集。一个用于普通指标(root.branch.leaf),另一个用于带标签指标(root.branch.leaf;tag1=value1)。 -默认规则在两个集合中都结束。 +- `rule_type` - 规则的类型。仅应用于特定指标。引擎用此来区分普通指标和标签指标。可选参数。默认值:`all`。 +在性能不关键或仅使用一种指标类型(例如普通指标)时,便于不需要使用此参数。默认情况下,仅创建一种类型的规则集。否则,如果定义了任何特殊类型,则将创建两种不同的规则集。一种用于普通指标(root.branch.leaf),另一种用于标签指标(root.branch.leaf;tag1=value1)。 +默认规则在两个集合中都存在。 有效值: - - `all`(默认)- 当省略 `rule_type` 时使用的通用规则。 - - `plain` - 用于普通指标的规则。字段 `regexp` 被处理为正则表达式。 - - `tagged` - 用于带标签指标的规则(指标以 `someName?tag1=value1&tag2=value2&tag3=value3` 的格式存储在数据库中)。正则表达式必须按标签名称排序,如果存在,第一个标签必须是 `__name__`。字段 `regexp` 被处理为正则表达式。 - - `tag_list` - 用于带标签指标的规则,是一种简单 DSL,通过 graphite 格式 `someName;tag1=value1;tag2=value2`, `someName` 或 `tag1=value1;tag2=value2` 来简化指标描述。字段 `regexp` 被转换为 `tagged` 规则。按标签名称排序不是必需的,将自动完成。标签的值(而不是名称)可以设置为正则表达式,例如 `env=(dev|staging)`。 + - `all`(默认) - 通用规则,当省略 `rule_type` 时使用。 + - `plain` - 普通指标的规则。字段 `regexp` 被处理为正则表达式。 + - `tagged` - 标签指标的规则(指标以 `someName?tag1=value1&tag2=value2&tag3=value3` 格式存储在数据库中)。正则表达式必须按标签名称排序,第一个标签必须是 `__name__`(如果存在)。字段 `regexp` 被处理为正则表达式。 + - `tag_list` - 标签指标的规则,为 Graphite 格式中的指标描述提供了一种简单的 DSL,格式为 `someName;tag1=value1;tag2=value2`,`someName`,或 `tag1=value1;tag2=value2`。字段 `regexp` 被转换为 `tagged` 规则。按标签名称的排序是多余的,会自动进行。标签的值(而不是名称)可以设置为正则表达式,例如 `env=(dev|staging)`。 - `regexp` – 指标名称的模式(正则表达式或 DSL)。 -- `age` – 数据的最小年龄(单位:秒)。 -- `precision`– 定义数据年龄的精确程度(单位:秒)。应为 86400(一天中的秒)的除数。 -- `function` – 要应用于年龄在 `[age, age + precision]` 范围内的数据的聚合函数名称。接受的函数: min / max / any / avg。平均值的计算不精确,就像平均值的平均值。 +- `age` – 数据的最小年龄,单位为秒。 +- `precision`– 用于定义数据年龄的精确度,单位为秒。应为 86400(一天中的秒)的除数。 +- `function` – 聚合函数的名称,用于应用于年龄在 `[age, age + precision]` 范围内的数据。接受的函数:min / max / any / avg。平均值的计算不精确,类似于平均数的平均值。 -### 没有规则类型的配置示例 {#configuration-example} +### 示例配置(无规则类型) {#configuration-example} ```xml @@ -194,7 +196,7 @@ default ``` -### 含有规则类型的配置示例 {#configuration-typed-example} +### 示例配置(与规则类型) {#configuration-typed-example} ```xml @@ -269,5 +271,5 @@ default ``` :::note -数据汇总是在合并过程中执行的。通常,对于旧分区,不会启动合并,因此需要使用 [optimize](../../../sql-reference/statements/optimize.md) 手动触发一次未计划的合并才能进行汇总。或使用其他工具,例如 [graphite-ch-optimizer](https://github.com/innogames/graphite-ch-optimizer)。 +数据汇总是在合并过程中执行的。通常,对于旧分区,不会启动合并,因此需要使用 [optimize](../../../sql-reference/statements/optimize.md) 触发一次计划外合并来进行汇总。或者使用其他工具,例如 [graphite-ch-optimizer](https://github.com/innogames/graphite-ch-optimizer)。 ::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/graphitemergetree.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/graphitemergetree.md.hash index 58af4a19569..698dd871089 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/graphitemergetree.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/graphitemergetree.md.hash @@ -1 +1 @@ -d2d8680e92e4e1d4 +6794a202ae366382 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/index.md index c2f8b52b037..30dc54e09bd 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/index.md @@ -4,20 +4,21 @@ 'sidebar_position': 10 'slug': '/engines/table-engines/mergetree-family/' 'title': 'MergeTree 引擎家族' +'doc_type': 'reference' --- # MergeTree 引擎家族 -来自 MergeTree 家族的表引擎是 ClickHouse 数据存储功能的核心。它们提供了大多数用于弹性和高性能数据检索的特性:列式存储、自定义分区、稀疏主索引、二级数据跳过索引等。 +来自 MergeTree 家族的表引擎是 ClickHouse 数据存储能力的核心。它们提供了大多数恢复能力和高性能数据检索的特性:列式存储、自定义分区、稀疏主键索引、次级数据跳过索引等。 -基础 [MergeTree](../../../engines/table-engines/mergetree-family/mergetree.md) 表引擎可以被视为单节点 ClickHouse 实例的默认表引擎,因为它适用于广泛的用例,灵活且实用。 +基础 [MergeTree](../../../engines/table-engines/mergetree-family/mergetree.md) 表引擎可以被视为单节点 ClickHouse 实例的默认表引擎,因为它在广泛的用例中都是多功能且实用的。 -对于生产用途,[ReplicatedMergeTree](../../../engines/table-engines/mergetree-family/replication.md) 是最佳选择,因为它为常规 MergeTree 引擎的所有特性增加了高可用性。额外的好处是在数据摄取时自动数据去重,因此软件在插入过程中遇到网络问题时可以安全地重试。 +对于生产使用,[ReplicatedMergeTree](../../../engines/table-engines/mergetree-family/replication.md) 是最佳选择,因为它为常规 MergeTree 引擎的所有功能增加了高可用性。一个额外的好处是在数据摄取时自动进行数据去重,因此如果在插入过程中发生网络问题,软件可以安全地重试。 -MergeTree 家族的所有其他引擎为特定用例增加了额外的功能。通常,这些功能作为后台的额外数据操作实现。 +MergeTree 家族的其他引擎为一些特定用例增加了额外的功能。通常,这些功能以后台进行的额外数据处理实现。 -MergeTree 引擎的主要缺点是它们相对较重。因此,典型的模式是拥有数量不多的 MergeTree 引擎。如果您需要多个小表,例如用于临时数据,请考虑 [Log 引擎家族](../../../engines/table-engines/log-family/index.md)。 +MergeTree 引擎的主要缺点是它们相对较重。因此,典型的模式是使用数量不多的引擎。如果你需要许多小表,例如用于临时数据,可以考虑 [Log 引擎家族](../../../engines/table-engines/log-family/index.md)。 + + +| 页面 | 描述 | +|-----|-----| +| [MergeTree](/engines/table-engines/mergetree-family/mergetree) | `MergeTree`-家族表引擎设计用于高数据摄取速率和大数据量。 | +| [数据复制](/engines/table-engines/mergetree-family/replication) | ClickHouse 中的数据复制概述 | +| [自定义分区键](/engines/table-engines/mergetree-family/custom-partitioning-key) | 了解如何向 MergeTree 表添加自定义分区键。 | +| [ReplacingMergeTree](/engines/table-engines/mergetree-family/replacingmergetree) | 与 MergeTree 不同,它通过移除具有相同排序键值的重复条目来工作(`ORDER BY` 表部分,而不是 `PRIMARY KEY`)。 | +| [CoalescingMergeTree](/engines/table-engines/mergetree-family/coalescingmergetree) | CoalescingMergeTree 继承自 MergeTree 引擎。其关键特性是在分片合并期间能够自动存储每列的最后一个非空值。 | +| [SummingMergeTree](/engines/table-engines/mergetree-family/summingmergetree) | SummingMergeTree 继承自 MergeTree 引擎。其关键特性是在分片合并期间能够自动对数值数据进行求和。 | +| [AggregatingMergeTree](/engines/table-engines/mergetree-family/aggregatingmergetree) | 用具有相同主键的单行(在单个数据分片内)替换所有行(更准确地说,是具有相同 [排序键](../../../engines/table-engines/mergetree-family/mergetree.md)),并存储聚合函数的状态组合。 | +| [CollapsingMergeTree](/engines/table-engines/mergetree-family/collapsingmergetree) | 继承自 MergeTree,但在合并过程中增加了合并行的逻辑。 | +| [VersionedCollapsingMergeTree](/engines/table-engines/mergetree-family/versionedcollapsingmergetree) | 允许快速写入不断变化的对象状态,并在后台删除旧对象状态。 | +| [GraphiteMergeTree](/engines/table-engines/mergetree-family/graphitemergetree) | 设计用于厚度处理和聚合/平均(汇总)Graphite 数据。 | +| [精确与近似向量搜索](/engines/table-engines/mergetree-family/annindexes) | 精确与近似向量搜索的文档 | +| [使用文本索引进行全文搜索](/engines/table-engines/mergetree-family/invertedindexes) | 快速查找文本中的搜索词。 | + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/index.md.hash index 4ce35e6fea5..f5f9501e39a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/index.md.hash @@ -1 +1 @@ -ad2bf8b0dab79f47 +3940920dd5b95085 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/invertedindexes.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/invertedindexes.md index 1d4ca934204..8ac88fd611c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/invertedindexes.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/invertedindexes.md @@ -1,105 +1,440 @@ --- -'description': '快速找到文本中的搜索词。' +'description': '快速在文本中找到搜索词。' 'keywords': - 'full-text search' -- 'text search' +- 'text index' - 'index' - 'indices' -'sidebar_label': '全词索引' +'sidebar_label': '使用文本索引的全文搜索' 'slug': '/engines/table-engines/mergetree-family/invertedindexes' -'title': '使用全词索引的全文搜索' +'title': '使用文本索引的全文搜索' +'doc_type': 'reference' --- import ExperimentalBadge from '@theme/badges/ExperimentalBadge'; import CloudNotSupportedBadge from '@theme/badges/CloudNotSupportedBadge'; -# 使用全文搜索和全文索引 +# 使用文本索引的全文搜索 -全文索引是一种实验性的 [二级索引](/engines/table-engines/mergetree-family/mergetree.md/#available-types-of-indices),它为 [String](/sql-reference/data-types/string.md) 或 [FixedString](/sql-reference/data-types/fixedstring.md) 列提供快速文本搜索能力。全文索引的主要思想是存储从“术语”到包含这些术语的行的映射。“术语”是字符串列的标记化单元。例如,字符串单元“I will be a little late”默认被标记化为六个术语“I”、“will”、“be”、“a”、“little”和“late”。另一种标记化器是 n-grams。例如,3-gram 标记化的结果将是 21 个术语“I w”、“ wi”、“wil”、“ill”、“ll “、“l b”、“ be”等。输入字符串标记化得越细粒度,生成的全文索引就越大,但也越有用。 +ClickHouse中的文本索引(也称为 ["倒排索引"](https://en.wikipedia.org/wiki/Inverted_index))为字符串数据提供了快速的全文搜索能力。 +该索引将列中的每个标记映射到包含该标记的行。 +标记是通过一种称为标记化的过程生成的。 +例如,ClickHouse默认将英语句子 "All cat like mice." 标记化为 ["All", "cat", "like", "mice"](请注意,尾随的句点被忽略)。 +可用更高级的标记器,例如用于日志数据的标记器。 -
- -
+## 创建文本索引 {#creating-a-text-index} -:::note -全文索引是实验性的,尚不应在生产环境中使用。它们在未来可能会以向后不兼容的方式发生改变,例如在其 DDL/DQL 语法或性能/压缩特性方面。 -::: - -## 用法 {#usage} - -要使用全文索引,首先在配置中启用它们: +要创建文本索引,首先启用相应的实验设置: ```sql SET allow_experimental_full_text_index = true; ``` -可以使用以下语法在字符串列上定义全文索引: +文本索引可以在 [String](/sql-reference/data-types/string.md)、[FixedString](/sql-reference/data-types/fixedstring.md)、[Array(String)](/sql-reference/data-types/array.md)、[Array(FixedString)](/sql-reference/data-types/array.md) 和 [Map](/sql-reference/data-types/map.md) 列上定义(通过 [mapKeys](/sql-reference/functions/tuple-map-functions.md/#mapkeys) 和 [mapValues](/sql-reference/functions/tuple-map-functions.md/#mapvalues) 映射函数),使用以下语法: ```sql CREATE TABLE tab ( `key` UInt64, `str` String, - INDEX inv_idx(str) TYPE gin(tokenizer = 'default|ngram|noop' [, ngram_size = N] [, max_rows_per_postings_list = M]) GRANULARITY 1 + INDEX text_idx(str) TYPE text( + -- Mandatory parameters: + tokenizer = splitByNonAlpha|splitByString(S)|ngrams(N)|array + -- Optional parameters: + [, dictionary_block_size = D] + [, dictionary_block_frontcoding_compression = B] + [, max_cardinality_for_embedded_postings = M] + [, bloom_filter_false_positive_rate = R] + ) [GRANULARITY 64] ) ENGINE = MergeTree ORDER BY key ``` -其中 `tokenizer` 指定标记化器: +`tokenizer` 参数指定标记器: + +- `splitByNonAlpha` 沿非字母数字ASCII字符拆分字符串(另请参见函数 [splitByNonAlpha](/sql-reference/functions/splitting-merging-functions.md/#splitbynonalpha))。 +- `splitByString(S)` 沿某些用户定义的分隔符字符串 `S` 拆分字符串(另请参见函数 [splitByString](/sql-reference/functions/splitting-merging-functions.md/#splitbystring))。 + 分隔符可以通过可选参数指定,例如,`tokenizer = splitByString([', ', '; ', '\n', '\\'])`。 + 请注意,每个字符串可以包含多个字符(例如示例中的 `', '`)。 + 如果没有明确指定默认分隔符列表(例如,`tokenizer = splitByString`),则为单个空格 `[' ']`。 +- `ngrams(N)` 将字符串拆分为大小相等的 `N`-grams(另请参见函数 [ngrams](/sql-reference/functions/splitting-merging-functions.md/#ngrams))。 + ngram长度可以使用可选整数参数指定,范围在2到8之间,例如,`tokenizer = ngrams(3)`。 + 如果没有明确指定默认ngram大小(例如,`tokenizer = ngrams`),则为3。 +- `array` 不执行任何标记化,即每个行值是一个标记(另请参见函数 [array](/sql-reference/functions/array-functions.md/#array))。 + +:::note +`splitByString` 标记器按从左到右的顺序应用拆分分隔符。 +这可能会导致歧义。 +例如,分隔符字符串 `['%21', '%']` 将导致 `%21abc` 被标记为 `['abc']`,而交换这两个分隔符字符串 `['%', '%21']` 将输出 `['21abc']`。 +在大多数情况下,您希望匹配更长的分隔符优先。 +这通常可以通过以递减长度的顺序传递分隔符字符串来实现。 +如果分隔符字符串恰好形成 [前缀码](https://en.wikipedia.org/wiki/Prefix_code),则可以以任意顺序传递。 +::: + +要测试标记器如何拆分输入字符串,可以使用ClickHouse的 [tokens](/sql-reference/functions/splitting-merging-functions.md/#tokens) 函数: + +作为示例, + +```sql +SELECT tokens('abc def', 'ngrams', 3) AS tokens; +``` + +返回 + +```result ++-tokens--------------------------+ +| ['abc','bc ','c d',' de','def'] | ++---------------------------------+ +``` + +ClickHouse中的文本索引作为 [二级索引](/engines/table-engines/mergetree-family/mergetree.md/#skip-index-types) 实现。 +然而,与其他跳过索引不同,文本索引的默认索引 GRANULARITY 为64。 +这个值是经验性选择的,对于大多数用例,它在速度和索引大小之间提供了良好的折衷。 +高级用户可以指定不同的索引粒度(我们不推荐这样做)。 + +
+ +高级参数 + +以下高级参数的默认值在几乎所有情况下都能良好工作。 +我们不建议更改它们。 + +可选参数 `dictionary_block_size`(默认值:128)指定字典块的行数。 + +可选参数 `dictionary_block_frontcoding_compression`(默认值:1)指定字典块是否使用前缀编码作为压缩。 + +可选参数 `max_cardinality_for_embedded_postings`(默认值:16)指定应该嵌入到字典块中的发布列表的基数阈值。 + +可选参数 `bloom_filter_false_positive_rate`(默认值:0.1)指定字典布隆过滤器的假阳性率。 +
+ +文本索引可以在创建表后向列中添加或移除: + +```sql +ALTER TABLE tab DROP INDEX text_idx; +ALTER TABLE tab ADD INDEX text_idx(s) TYPE text(tokenizer = splitByNonAlpha); +``` + +## 使用文本索引 {#using-a-text-index} + +在SELECT查询中使用文本索引非常简单,因为常见的字符串搜索函数会自动利用索引。 +如果不存在索引,以下字符串搜索函数将回退到缓慢的暴力扫描。 -- `default` 将标记化器设置为“tokens('default')”,即沿非字母数字字符拆分字符串。 -- `ngram` 将标记化器设置为“tokens('ngram')”。即将字符串拆分为相等大小的术语。 -- `noop` 将标记化器设置为“tokens('noop')”,即每个值本身就是一个术语。 +### 支持的函数 {#functions-support} -可以通过 `ngram_size` 参数指定 ngram 大小。这个参数是可选的。存在以下变体: +如果在SELECT查询的 `WHERE` 子句中使用文本函数,则可以使用文本索引: -- `ngram_size = N`:其中 `N` 在 2 到 8 之间,将标记化器设置为“tokens('ngram', N)”。 -- 如果未指定:使用默认 ngram 大小,默认为 3。 +```sql +SELECT [...] +FROM [...] +WHERE string_search_function(column_with_text_index) +``` -每个发布列表的最大行数可以通过可选的 `max_rows_per_postings_list` 参数指定。该参数可用于控制发布列表的大小,以避免生成庞大的发布列表文件。存在以下变体: +#### `=` 和 `!=` {#functions-example-equals-notequals} -- `max_rows_per_postings_list = 0`:发布列表的最大行数没有限制。 -- `max_rows_per_postings_list = M`:其中 `M` 应至少为 8192。 -- 如果未指定:使用默认最大行数,默认为 64K。 +`=` ([equals](/sql-reference/functions/comparison-functions.md/#equals)) 和 `!=` ([notEquals](/sql-reference/functions/comparison-functions.md/#notEquals)) 匹配整个给定的搜索词。 -作为一种跳过索引,全文索引可以在表创建后添加或删除到列: +示例: ```sql -ALTER TABLE tab DROP INDEX inv_idx; -ALTER TABLE tab ADD INDEX inv_idx(s) TYPE gin(tokenizer = 'default'); +SELECT * from tab WHERE str = 'Hello'; ``` -要使用该索引,不需要特殊的函数或语法。典型的字符串搜索谓词会自动利用该索引。举个例子,考虑以下示例: +文本索引支持 `=` 和 `!=`,但相等和不等搜索仅与 `array` 标记器有意义(这导致索引存储整个行值)。 + +#### `IN` 和 `NOT IN` {#functions-example-in-notin} + +`IN` ([in](/sql-reference/functions/in-functions)) 和 `NOT IN` ([notIn](/sql-reference/functions/in-functions)) 类似于函数 `equals` 和 `notEquals`,但它们匹配所有(`IN`)或都不匹配(`NOT IN`)搜索词。 + +示例: ```sql -INSERT INTO tab(key, str) values (1, 'Hello World'); -SELECT * from tab WHERE str == 'Hello World'; SELECT * from tab WHERE str IN ('Hello', 'World'); -SELECT * from tab WHERE str LIKE '%Hello%'; -SELECT * from tab WHERE multiSearchAny(str, ['Hello', 'World']); -SELECT * from tab WHERE hasToken(str, 'Hello'); ``` -全文索引也适用于类型为 `Array(String)`、`Array(FixedString)`、`Map(String)` 和 `Map(String)` 的列。 +与 `=` 和 `!=` 的限制相同,即 `IN` 和 `NOT IN` 仅与 `array` 标记器结合使用才有意义。 + +#### `LIKE`、`NOT LIKE` 和 `match` {#functions-example-like-notlike-match} -与其他二级索引一样,每个列部分都有自己的全文索引。此外,每个全文索引在内部被分为“段”。段的存在和大小对于用户通常是透明的,但段大小决定了在索引构建期间的内存消耗(例如,当两个部分被合并时)。配置参数“max_digestion_size_per_segment”(默认:256 MB)控制在创建新段之前从基础列读取的数据量。增加该参数会提高索引构建的中间内存消耗,但也会提高查找性能,因为在评估查询时需要检查的段数平均会减少。 +:::note +这些函数目前仅在索引标记器为 `splitByNonAlpha` 或 `ngrams` 时使用文本索引进行过滤。 +::: + +为了使用 `LIKE` [like](/sql-reference/functions/string-search-functions.md/#like)、`NOT LIKE` ([notLike](/sql-reference/functions/string-search-functions.md/#notlike)) 和 [match](/sql-reference/functions/string-search-functions.md/#match) 函数与文本索引,ClickHouse必须能够从搜索词中提取完整的标记。 + +示例: + +```sql +SELECT count() FROM tab WHERE comment LIKE 'support%'; +``` -## Hacker News 数据集的全文搜索 {#full-text-search-of-the-hacker-news-dataset} +示例中的 `support` 可以匹配 `support`、`supports`、`supporting` 等等。 +这种查询是子字符串查询,文本索引无法加速。 -让我们看看在具有大量文本的大数据集上,全文索引的性能提升。我们将使用 2870 万行对流行的 Hacker News 网站的评论。以下是没有全文索引的表: +为了利用文本索引进行LIKE查询,LIKE模式必须以以下方式重写: + +```sql +SELECT count() FROM tab WHERE comment LIKE ' support %'; -- or `% support %` +``` + +`support` 左右的空格确保该术语可以被提取为标记。 + +#### `startsWith` 和 `endsWith` {#functions-example-startswith-endswith} + +类似于 `LIKE`,函数 [startsWith](/sql-reference/functions/string-functions.md/#startswith) 和 [endsWith](/sql-reference/functions/string-functions.md/#endswith) 仅在能够从搜索词中提取完整标记时才能使用文本索引。 + +示例: + +```sql +SELECT count() FROM tab WHERE startsWith(comment, 'clickhouse support'); +``` + +在此示例中,仅 `clickhouse` 被视为标记。 +`support` 不是标记,因为它可以匹配 `support`、`supports`、`supporting` 等。 + +要查找以 `clickhouse supports` 开头的所有行,请确保在搜索模式后面加一个尾随空格: + +```sql +startsWith(comment, 'clickhouse supports ')` +``` + +同样,`endsWith` 应该在前面加一个空格使用: + +```sql +SELECT count() FROM tab WHERE endsWith(comment, ' olap engine'); +``` + +#### `hasToken` 和 `hasTokenOrNull` {#functions-example-hastoken-hastokenornull} + +函数 [hasToken](/sql-reference/functions/string-search-functions.md/#hastoken) 和 [hasTokenOrNull](/sql-reference/functions/string-search-functions.md/#hastokenornull) 匹配单个给定标记。 + +与先前提到的函数不同,它们不对搜索词进行标记化(它们假设输入是单个标记)。 + +示例: + +```sql +SELECT count() FROM tab WHERE hasToken(comment, 'clickhouse'); +``` + +函数 `hasToken` 和 `hasTokenOrNull` 是与 `text` 索引配合使用的性能最好的函数。 + +#### `hasAnyTokens` 和 `hasAllTokens` {#functions-example-hasanytokens-hasalltokens} + +函数 [hasAnyTokens](/sql-reference/functions/string-search-functions.md/#hasanytokens) 和 [hasAllTokens](/sql-reference/functions/string-search-functions.md/#hasalltokens) 匹配给定标记中的一个或多个。 + +与 `hasToken` 一样,搜索词不会经过标记化。 + +示例: + +```sql +SELECT count() FROM tab WHERE hasAnyTokens(comment, ['clickhouse', 'olap']); + +SELECT count() FROM tab WHERE hasAllTokens(comment, ['clickhouse', 'olap']); +``` + +#### `has` {#functions-example-has} + +数组函数 [has](/sql-reference/functions/array-functions#has) 在字符串数组中匹配单个标记。 + +示例: + +```sql +SELECT count() FROM tab WHERE has(array, 'clickhouse'); +``` + +#### `mapContains` {#functions-example-mapcontains} + +函数 [mapContains](/sql-reference/functions/tuple-map-functions#mapcontains)(别名为: `mapContainsKey`) 在映射的键中与单个标记匹配。 + +示例: + +```sql +SELECT count() FROM tab WHERE mapContainsKey(map, 'clickhouse'); +-- OR +SELECT count() FROM tab WHERE mapContains(map, 'clickhouse'); +``` + +#### `operator[]` {#functions-example-access-operator} + +可以使用访问 [operator[]](/sql-reference/operators#access-operators) 和文本索引过滤键和值。 + +示例: + +```sql +SELECT count() FROM tab WHERE map['engine'] = 'clickhouse'; -- will use the text index if defined +``` + +查看以下示例以了解 `Array(T)` 和 `Map(K, V)` 与文本索引的使用。 + +### 文本索引 `Array` 和 `Map` 支持的示例。 {#text-index-array-and-map-examples} + +#### 为 Array(String) 建立索引 {#text-indexi-example-array} + +在一个简单的博客平台上,作者为他们的文章分配关键词以对内容进行分类。 +一个常见的功能允许用户通过点击关键词或搜索主题来发现相关内容。 + +考虑以下表定义: + +```sql +CREATE TABLE posts ( + post_id UInt64, + title String, + content String, + keywords Array(String) COMMENT 'Author-defined keywords' +) +ENGINE = MergeTree +ORDER BY (post_id); +``` + +没有文本索引,要找到具有特定关键词(例如 `clickhouse`)的帖子需要扫描所有条目: + +```sql +SELECT count() FROM posts WHERE has(keywords, 'clickhouse'); -- slow full-table scan - checks every keyword in every post +``` + +随着平台的发展,这项工作变得越来越缓慢,因为查询必须检查每一行中的每个关键词数组。 + +为了解决这个性能问题,我们可以为 `keywords` 定义一个文本索引,这样它可以创建一个搜索优化结构,预处理所有关键词,从而实现即时查找: + +```sql +ALTER TABLE posts ADD INDEX keywords_idx(keywords) TYPE text(tokenizer = splitByNonAlpha); +``` + +:::note +重要提示:添加文本索引后,必须为现有数据重建索引: + +```sql +ALTER TABLE posts MATERIALIZE INDEX keywords_idx; +``` +::: + +#### 为 Map 建立索引 {#text-index-example-map} + +在日志系统中,服务器请求通常以键值对的形式存储元数据。运营团队需要高效地搜索日志进行调试、安全事件和监控。 + +考虑以下日志表: + +```sql +CREATE TABLE logs ( + id UInt64, + timestamp DateTime, + message String, + attributes Map(String, String) +) +ENGINE = MergeTree +ORDER BY (timestamp); +``` + +没有文本索引,搜索 [Map](/sql-reference/data-types/map.md) 数据需要全表扫描: + +1. 查找所有限制速率的日志: + +```sql +SELECT count() FROM logs WHERE has(mapKeys(attributes), 'rate_limit'); -- slow full-table scan +``` + +2. 查找来自特定IP的所有日志: + +```sql +SELECT count() FROM logs WHERE has(mapValues(attributes), '192.168.1.1'); -- slow full-table scan +``` + +随着日志量的增加,这些查询变得缓慢。 + +解决方案是为 [Map](/sql-reference/data-types/map.md) 的键和值创建文本索引。 + +使用 [mapKeys](/sql-reference/functions/tuple-map-functions.md/#mapkeys) 在需要按字段名或属性类型查找日志时创建文本索引: + +```sql +ALTER TABLE logs ADD INDEX attributes_keys_idx mapKeys(attributes) TYPE text(tokenizer = array); +``` + +使用 [mapValues](/sql-reference/functions/tuple-map-functions.md/#mapvalues) 在需要在属性的实际内容中进行搜索时创建文本索引: + +```sql +ALTER TABLE logs ADD INDEX attributes_vals_idx mapValues(attributes) TYPE text(tokenizer = array); +``` + +:::note +重要提示:添加文本索引后,必须为现有数据重建索引: + +```sql +ALTER TABLE posts MATERIALIZE INDEX attributes_keys_idx; +ALTER TABLE posts MATERIALIZE INDEX attributes_vals_idx; +``` +::: + +1. 查找所有限制速率的请求: + +```sql +SELECT * FROM logs WHERE mapContainsKey(attributes, 'rate_limit'); -- fast +``` + +2. 查找来自特定IP的所有日志: + +```sql +SELECT * FROM logs WHERE has(mapValues(attributes), '192.168.1.1'); -- fast +``` + +## 实现 {#implementation} + +### 索引布局 {#index-layout} + +每个文本索引由两个(抽象)数据结构组成: +- 一个字典,它将每个标记映射到一个发布列表,以及 +- 一组发布列表,每个列表代表一组行号。 + +由于文本索引是跳过索引,因此这些数据结构在逻辑上存在于每个索引粒度内。 + +在创建索引时(每个分片),会创建三个文件: + +**字典块文件 (.dct)** + +索引粒度中的标记按顺序排列并存储在每128个标记的字典块中(块大小可以通过参数 `dictionary_block_size` 配置)。 +字典块文件 (.dct) 包含分片中所有索引粒度的所有字典块。 + +**索引粒度文件 (.idx)** + +索引粒度文件为每个字典块包含块的第一个标记、其在字典块文件中的相对偏移量,以及该块中所有标记的布隆过滤器。 +这种稀疏索引结构类似于ClickHouse的 [稀疏主键索引](https://clickhouse.com/docs/guides/best-practices/sparse-primary-indexes)。 +布隆过滤器允许在搜索的标记不包含在字典块中时,提前跳过字典块。 + +**发布列表文件 (.pst)** + +所有标记的发布列表按顺序排列在发布列表文件中。 +为了节省空间,同时允许快速的交集和并集操作,发布列表以 [roaring bitmaps](https://roaringbitmap.org/) 的形式存储。 +如果发布列表的基数小于16(可以通过参数 `max_cardinality_for_embedded_postings` 配置),则将其嵌入字典中。 + +### 直接读取 {#direct-read} + +某些类型的文本查询可以通过一种称为 "直接读取" 的优化显著加速。 +更具体地说,如果SELECT查询不是从文本列进行投影,则可以应用该优化。 + +示例: + +```sql +SELECT column_a, column_b, ... -- not: column_with_text_index +FROM [...] +WHERE string_search_function(column_with_text_index) +``` + +ClickHouse中的直接读取优化仅使用文本索引(即文本索引查找)回答查询,而无需访问底层文本列。 +文本索引查找相对读取的数据较少,因此比ClickHouse中常规的跳过索引(先执行跳过索引查找,然后加载和过滤存活的粒度)要快得多。 + +**支持的函数** +直接读取优化支持函数 `hasToken`、`searchAll` 和 `searchAny`。 +这些函数还可以通过AND、OR和NOT运算符组合。 +WHERE子句也可以包含额外的非文本搜索函数过滤器(针对文本列或其他列)——在这种情况下,仍将使用直接读取优化,但效果较差(它仅适用于支持的文本搜索函数)。 + +## 示例:Hackernews 数据集 {#hacker-news-dataset} + +让我们看看文本索引在具有大量文本的大型数据集上带来的性能改进。 +我们将使用2800万行来自流行的Hacker News网站的评论。以下是没有文本索引的表: ```sql CREATE TABLE hackernews ( @@ -123,7 +458,7 @@ ENGINE = MergeTree ORDER BY (type, author); ``` -2870 万行评论存储在 S3 的 Parquet 文件中 - 让我们将它们插入到 `hackernews` 表中: +这2800万行的数据在S3中的一个Parquet文件中——让我们将它们插入到 `hackernews` 表中: ```sql INSERT INTO hackernews @@ -149,7 +484,7 @@ INSERT INTO hackernews descendants UInt32'); ``` -考虑在 `comment` 列中搜索术语 `ClickHouse`(及其各种大小写)的简单搜索: +考虑在 `comment` 列中搜索术语 `ClickHouse`(及其各种大小写): ```sql SELECT count() @@ -157,7 +492,7 @@ FROM hackernews WHERE hasToken(lower(comment), 'clickhouse'); ``` -注意执行此查询需要 3 秒: +注意,执行查询需要3秒: ```response ┌─count()─┐ @@ -167,11 +502,11 @@ WHERE hasToken(lower(comment), 'clickhouse'); 1 row in set. Elapsed: 3.001 sec. Processed 28.74 million rows, 9.75 GB (9.58 million rows/s., 3.25 GB/s.) ``` -我们将使用 `ALTER TABLE` 并在 `comment` 列的小写版本上添加一个全文索引,然后将其物化(这可能需要一段时间 - 请等待其物化完成): +我们将使用 `ALTER TABLE` 并在 `comment` 列的小写上添加文本索引,然后将其物化(这可能需要一段时间——等待它物化): ```sql ALTER TABLE hackernews - ADD INDEX comment_lowercase(lower(comment)) TYPE gin; + ADD INDEX comment_lowercase(lower(comment)) TYPE text; ALTER TABLE hackernews MATERIALIZE INDEX comment_lowercase; ``` @@ -184,7 +519,7 @@ FROM hackernews WHERE hasToken(lower(comment), 'clickhouse') ``` -...并注意查询的执行速度快了 4 倍: +...并注意到查询执行速度提升了4倍: ```response ┌─count()─┐ @@ -194,13 +529,13 @@ WHERE hasToken(lower(comment), 'clickhouse') 1 row in set. Elapsed: 0.747 sec. Processed 4.49 million rows, 1.77 GB (6.01 million rows/s., 2.37 GB/s.) ``` -我们还可以搜索多个术语之一或所有术语,即,析取或合取: +我们还可以搜索一个或多个条款,即析取或合取: ```sql -- multiple OR'ed terms SELECT count(*) FROM hackernews -WHERE multiSearchAny(lower(comment), ['oltp', 'olap']); +WHERE hasToken(lower(comment), 'avx') OR hasToken(lower(comment), 'sve'); -- multiple AND'ed terms SELECT count(*) @@ -208,10 +543,8 @@ FROM hackernews WHERE hasToken(lower(comment), 'avx') AND hasToken(lower(comment), 'sve'); ``` -:::note -与其他二级索引不同,全文索引(目前)映射到行号(行 ID)而不是颗粒 ID。这样设计的原因是性能。在实践中,用户通常会一次搜索多个术语。例如,过滤谓词 `WHERE s LIKE '%little%' OR s LIKE '%big%'` 可以通过形成“little”和“big”两个术语的行 ID 列表的并集,直接使用全文索引进行评估。这也意味着提供给索引创建的参数 `GRANULARITY` 是没有意义的(它可能会在未来的语法中被移除)。 -::: - ## 相关内容 {#related-content} -- 博客: [在 ClickHouse 中引入倒排索引](https://clickhouse.com/blog/clickhouse-search-with-inverted-indices) +- 博客: [在ClickHouse中引入倒排索引](https://clickhouse.com/blog/clickhouse-search-with-inverted-indices) +- 博客: [ClickHouse全文搜索内部: 快速、原生、列式](https://clickhouse.com/blog/clickhouse-full-text-search) +- 视频: [全文索引:设计与实验](https://www.youtube.com/watch?v=O_MnyUkrIq8) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/invertedindexes.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/invertedindexes.md.hash index 17639896be0..27ae935d83c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/invertedindexes.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/invertedindexes.md.hash @@ -1 +1 @@ -6dd69a900ca233bd +a7d62dda86fef6ea diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/mergetree.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/mergetree.md index 0255ec23f23..b547626a02a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/mergetree.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/mergetree.md @@ -1,9 +1,10 @@ --- -'description': '`MergeTree`系列表引擎旨在处理高数据摄取率和巨大的数据量。' +'description': '`MergeTree`家族的表引擎设计用于高数据摄取速率和海量数据量。' 'sidebar_label': 'MergeTree' 'sidebar_position': 11 'slug': '/engines/table-engines/mergetree-family/mergetree' 'title': 'MergeTree' +'doc_type': 'reference' --- import ExperimentalBadge from '@theme/badges/ExperimentalBadge'; @@ -12,23 +13,22 @@ import CloudNotSupportedBadge from '@theme/badges/CloudNotSupportedBadge'; # MergeTree -`MergeTree` 引擎和其他 `MergeTree` 系列引擎(例如 `ReplacingMergeTree`、`AggregatingMergeTree`)是 ClickHouse 中最常用和最强大的表引擎。 +`MergeTree` 引擎及其他 `MergeTree` 系列引擎(例如 `ReplacingMergeTree`, `AggregatingMergeTree`)是 ClickHouse 中使用最广泛且最稳健的表引擎。 -`MergeTree` 系列表引擎旨在支持高数据摄取速率和庞大数据量。 -插入操作会创建表的部分,这些部分会被后台进程与其他表部分合并。 +`MergeTree` 系列表引擎旨在支持高数据摄取速率和巨大的数据量。插入操作创建表的部分数据,这些部分数据由后台进程与其他表部分进行合并。 -`MergeTree` 系列表引擎的主要功能: +`MergeTree` 系列表引擎的主要特性: -- 表的主键决定每个表部分内的排序顺序(聚集索引)。主键并不引用单独的行,而是引用8192行的块称为颗粒。这使得庞大数据集的主键小到可以保持在主内存中,同时仍能快速访问磁盘中的数据。 +- 表的主键决定每个表部分的排序顺序(聚集索引)。主键也并不引用单独的行,而是称为颗粒的 8192 行的块。这使得巨大数据集的主键足够小,可以保持在主存储器中,同时仍能提供对磁盘数据的快速访问。 -- 表可以使用任意分区表达式进行分区。当查询允许时,分区修剪确保在读取时省略分区。 +- 表可以使用任意分区表达式进行分区。当查询允许时,分区裁剪确保分区被省略。 -- 数据可以在多个集群节点之间复制,以实现高可用性、故障转移和零停机升级。请参见 [数据复制](/engines/table-engines/mergetree-family/replication.md)。 +- 数据可以跨多个集群节点进行复制,以实现高可用性、故障转移和零停机时间升级。请参阅 [数据复制](/engines/table-engines/mergetree-family/replication.md)。 -- `MergeTree` 表引擎支持各种统计信息类型和采样方法以帮助查询优化。 +- `MergeTree` 表引擎支持各种统计种类和采样方法,以帮助查询优化。 :::note -尽管名称相似,[Merge](/engines/table-engines/special/merge) 引擎与 `*MergeTree` 引擎不同。 +尽管名字相似, [Merge](/engines/table-engines/special/merge) 引擎与 `*MergeTree` 引擎是不同的。 ::: ## 创建表 {#table_engine-mergetree-creating-a-table} @@ -55,71 +55,68 @@ ORDER BY expr [SETTINGS name = value, ...] ``` -有关参数的详细描述,请参见 [CREATE TABLE](/sql-reference/statements/create/table.md) 语句。 +有关参数的详细描述,请参阅 [CREATE TABLE](/sql-reference/statements/create/table.md) 语句。 ### 查询子句 {#mergetree-query-clauses} #### ENGINE {#engine} `ENGINE` — 引擎的名称和参数。`ENGINE = MergeTree()`。`MergeTree` 引擎没有参数。 -#### ORDER_BY {#order_by} +#### ORDER BY {#order_by} `ORDER BY` — 排序键。 -一个列名的元组或任意表达式。例如:`ORDER BY (CounterID + 1, EventDate)`。 +一组列名或任意表达式。示例:`ORDER BY (CounterID + 1, EventDate)`。 如果未定义主键(即未指定 `PRIMARY KEY`),ClickHouse 将使用排序键作为主键。 -如果不需要排序,可以使用语法 `ORDER BY tuple()`。 -另外,如果启用 `create_table_empty_primary_key_by_default` 设置,则 `CREATE TABLE` 语句将隐式添加 `ORDER BY tuple()`。请参见 [选择主键](#selecting-a-primary-key)。 +如果不需要排序,可以使用语法 `ORDER BY tuple()`。另外,如果启用了 `create_table_empty_primary_key_by_default` 设置,则会隐式将 `ORDER BY tuple()` 添加到 `CREATE TABLE` 语句中。请参阅 [选择主键](#selecting-a-primary-key)。 #### PARTITION BY {#partition-by} -`PARTITION BY` — [分区键](/engines/table-engines/mergetree-family/custom-partitioning-key.md)。可选。在大多数情况下,您无需分区键,如果确实需要分区,通常不需要比按月份更精细的分区键。分区并不会加速查询(与 `ORDER BY` 表达式相反)。您绝不能使用过于精细的分区。不要根据客户标识符或名称对数据进行分区(而应将客户标识符或名称设置为 `ORDER BY` 表达式中的第一列)。 +`PARTITION BY` — [分区键](/engines/table-engines/mergetree-family/custom-partitioning-key.md)。可选。大多数情况下,不需要分区键,如果需要分区,通常不需要更细的分区键。分区并不会加速查询(与 ORDER BY 表达式相反)。你绝对不应该使用过于细粒度的分区。请勿按客户标识符或名称对数据进行分区(而是,将客户标识符或名称作为 `ORDER BY` 表达式的第一列)。 -要按月份分区,使用 `toYYYYMM(date_column)` 表达式,其中 `date_column` 是一种 [Date](/sql-reference/data-types/date.md) 类型的日期列。此处的分区名称采用 `"YYYYMM"` 格式。 +按月份分区,请使用 `toYYYYMM(date_column)` 表达式,其中 `date_column` 是一个类型为 [Date](/sql-reference/data-types/date.md) 的日期列。此处的分区名称采用 `"YYYYMM"` 格式。 #### PRIMARY KEY {#primary-key} -`PRIMARY KEY` — 如果它 [与排序键不同](#choosing-a-primary-key-that-differs-from-the-sorting-key),则为主键。可选。 +`PRIMARY KEY` — 如果它与 [排序键](#choosing-a-primary-key-that-differs-from-the-sorting-key) 不同,则为主键。可选。 -指定排序键(使用 `ORDER BY` 子句)隐式指定主键。 -通常,无需在排序键之外另外指定主键。 +指定排序键(使用 `ORDER BY` 子句)隐式指定了一个主键。一般情况下,不需要在排序键之外额外指定主键。 #### SAMPLE BY {#sample-by} `SAMPLE BY` — 采样表达式。可选。 -如果指定,则必须包含在主键内。 -采样表达式必须产生一个无符号整数。 +如果指定,它必须包含在主键中。采样表达式必须返回一个无符号整数。 示例:`SAMPLE BY intHash32(UserID) ORDER BY (CounterID, EventDate, intHash32(UserID))`。 #### TTL {#ttl} -`TTL` — 指定行的存储持续时间和自动部分移动 [在磁盘和卷之间](#table_engine-mergetree-multiple-volumes) 的逻辑的规则列表。可选。 +`TTL` — 一系列规则,指定行的存储时长以及自动部分移动的逻辑 [在磁盘和卷之间](#table_engine-mergetree-multiple-volumes)。可选。 -表达式必须结果为 `Date` 或 `DateTime`,例如 `TTL date + INTERVAL 1 DAY`。 +表达式必须返回一个 `Date` 或 `DateTime`,例如 `TTL date + INTERVAL 1 DAY`。 -规则的类型 `DELETE|TO DISK 'xxx'|TO VOLUME 'xxx'|GROUP BY` 指定在满足表达式(到达当前时间)时将对部分执行的操作:移除过期行、将部分(如果表达式对部分中的所有行满足)移动到指定的磁盘(`TO DISK 'xxx'`)或卷(`TO VOLUME 'xxx'`),或者在过期行中聚合值。规则的默认类型是移除(`DELETE`)。可以指定多个规则列表,但不应超过一个 `DELETE` 规则。 +规则的类型 `DELETE|TO DISK 'xxx'|TO VOLUME 'xxx'|GROUP BY` 指定在表达式满足(达到当前时间)时应对部分采取的操作:移除过期行、将部分(如果表达式对部分中的所有行均满足)移动到指定磁盘(`TO DISK 'xxx'`)或卷(`TO VOLUME 'xxx'`),或对过期行的值进行聚合。默认规则类型是删除(`DELETE`)。可以指定多个规则的列表,但 `DELETE` 规则不得超过一个。 -有关更多详细信息,请参见 [列和表的 TTL](#table_engine-mergetree-ttl)。 +有关更多详细信息,请参阅 [列和表的 TTL](#table_engine-mergetree-ttl)。 #### SETTINGS {#settings} -请参见 [MergeTree 设置](../../../operations/settings/merge-tree-settings.md)。 +请参阅 [MergeTree 设置](../../../operations/settings/merge-tree-settings.md)。 -**部分设置的示例** +**示例:部门设置** ```sql ENGINE MergeTree() PARTITION BY toYYYYMM(EventDate) ORDER BY (CounterID, EventDate, intHash32(UserID)) SAMPLE BY intHash32(UserID) SETTINGS index_granularity=8192 ``` -在示例中,我们按月进行分区。 +在该示例中,我们按月进行分区。 -我们还设置一个用户 ID 哈希的采样表达式。这使您能够为每个 `CounterID` 和 `EventDate` 伪随机数据。如果在选择数据时定义了 [SAMPLE](/sql-reference/statements/select/sample) 子句,ClickHouse 将返回用户子集的均匀伪随机数据样本。 +我们还设置了一条表达式,作为用户 ID 的哈希采样。这使你能够伪随机化表中的数据,对于每个 `CounterID` 和 `EventDate`。如果在选择数据时定义了 [SAMPLE](/sql-reference/statements/select/sample) 子句,ClickHouse 将返回一组均匀的伪随机数据样本。 `index_granularity` 设置可以省略,因为 8192 是默认值。
-创建表的过时方法 +创建表的已弃用方法 :::note -请勿在新项目中使用此方法。如果可能,请将旧项目切换到上述描述的方法。 +请勿在新项目中使用此方法。如果可能,将旧项目迁移至上述方法。 ::: ```sql @@ -133,10 +130,10 @@ CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] **MergeTree() 参数** -- `date-column` — [Date](/sql-reference/data-types/date.md) 类型的列名。ClickHouse 根据此列自动按月创建分区。分区名称为 `"YYYYMM"` 格式。 +- `date-column` — 一个类型为 [Date](/sql-reference/data-types/date.md) 的列的名称。ClickHouse 会根据此列自动按月创建分区。分区名称采用 `"YYYYMM"` 格式。 - `sampling_expression` — 采样表达式。 -- `(primary, key)` — 主键。类型: [Tuple()](/sql-reference/data-types/tuple.md) -- `index_granularity` — 索引的粒度。数据行之间的 "marks" 数量。对于大多数任务,值8192是合适的。 +- `(primary, key)` — 主键。类型:[Tuple()](/sql-reference/data-types/tuple.md) +- `index_granularity` — 索引的粒度。索引标记之间的数据行数。8192 的值适合大多数任务。 **示例** @@ -144,26 +141,26 @@ CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] MergeTree(EventDate, intHash32(UserID), (CounterID, EventDate, intHash32(UserID)), 8192) ``` -`MergeTree` 引擎的配置与上面主要引擎配置方法的示例相同。 +`MergeTree` 引擎与上述示例中主要引擎配置方法相同配置。
## 数据存储 {#mergetree-data-storage} -表由按主键排序的数据部分组成。 +一张表由按主键排序的数据部分组成。 -当数据插入表中时,会创建单独的数据部分,每个部分均按主键进行字典序排序。例如,如果主键为 `(CounterID, Date)`,则部分中的数据按 `CounterID` 排序,而在每个 `CounterID` 内按 `Date` 排序。 +当数据插入表中时,创建单独的数据部分,每个部分根据主键进行字典序排序。例如,如果主键为 `(CounterID, Date)`,则部分中的数据按 `CounterID` 排序,每个 `CounterID` 内部按 `Date` 排序。 -属于不同分区的数据被分割到不同的部分。后台中,ClickHouse 会合并数据部分以提高存储效率。属于不同分区的部分不会合并。合并机制无法保证具有相同主键的所有行都在同一数据部分中。 +属于不同分区的数据被分隔到不同的部分。ClickHouse 在后台合并数据部分以实现更高效的存储。属于不同分区的部分不会被合并。合并机制不保证所有具有相同主键的行都在相同数据部分中。 -数据部分可以以 `Wide` 或 `Compact` 格式存储。在 `Wide` 格式中,每列存储在文件系统中的单独文件中,在 `Compact` 格式中,所有列存储在一个文件中。可以使用 `Compact` 格式来提高小而频繁插入的性能。 +数据部分可以以 `Wide` 或 `Compact` 格式存储。在 `Wide` 格式中,每列分别存储在文件系统中的单独文件中,而在 `Compact` 格式中,所有列存储在一个文件中。`Compact` 格式可用于提高小而频繁的插入的性能。 -数据存储格式由表引擎的 `min_bytes_for_wide_part` 和 `min_rows_for_wide_part` 设置控制。如果数据部分中的字节数或行数少于相应设置的值,则该部分以 `Compact` 格式存储。否则以 `Wide` 格式存储。如果未设置其中任何设置,则数据部分以 `Wide` 格式存储。 +数据存储格式由表引擎的 `min_bytes_for_wide_part` 和 `min_rows_for_wide_part` 设置控制。如果数据部分中的字节数或行数小于相应设置的值,则部分以 `Compact` 格式存储。否则,它以 `Wide` 格式存储。如果没有设置这些选项,则数据部分以 `Wide` 格式存储。 -每个数据部分在逻辑上被划分为颗粒。颗粒是 ClickHouse 在选择数据时读取的最小不可分割数据集。ClickHouse 不会拆分行或值,因此每个颗粒始终包含整数行数。颗粒的第一行标记为该行的主键值。对于每个数据部分,ClickHouse 创建一个索引文件以存储标记。对于每列,无论它是否在主键中,ClickHouse 还会存储相同的标记。这些标记允许您直接在列文件中查找数据。 +每个数据部分在逻辑上被划分为颗粒。颗粒是 ClickHouse 在选择数据时读取的最小不可分割的数据集。ClickHouse 不会分割行或值,因此每个颗粒始终包含整数数量的行。颗粒的第一行以行的主键值标记。对于每个数据部分,ClickHouse 创建一个索引文件来存储标记。对于每列,无论它是否在主键中,ClickHouse 也存储相同的标记。这些标记让你能够直接在列文件中找到数据。 -颗粒大小受表引擎的 `index_granularity` 和 `index_granularity_bytes` 设置限制。颗粒中的行数介于 `[1, index_granularity]` 范围内,具体取决于行的大小。如果单行的大小大于设置值,则颗粒的大小可以超过 `index_granularity_bytes`。在这种情况下,颗粒的大小等于行的大小。 +颗粒的大小受表引擎的 `index_granularity` 和 `index_granularity_bytes` 设置限制。颗粒中的行数在 `[1, index_granularity]` 范围内,具体取决于行的大小。如果单行的大小大于设置值,则颗粒的大小可以超过 `index_granularity_bytes`。在这种情况下,颗粒的大小等于行的大小。 ## 查询中的主键和索引 {#primary-keys-and-indexes-in-queries} -以 `(CounterID, Date)` 主键为例。在这种情况下,排序和索引可以如下所示: +以 `(CounterID, Date)` 主键为例。在此情况下,排序和索引可以如下所示: ```text Whole data: [---------------------------------------------] @@ -176,59 +173,60 @@ Marks numbers: 0 1 2 3 4 5 6 7 8 如果数据查询指定: -- `CounterID in ('a', 'h')`,服务器读取标记范围 `[0, 3)` 和 `[6, 8)` 的数据。 -- `CounterID IN ('a', 'h') AND Date = 3`,服务器读取标记范围 `[1, 3)` 和 `[7, 8)` 的数据。 -- `Date = 3`,服务器读取标记范围 `[1, 10]` 的数据。 +- `CounterID in ('a', 'h')`,服务器会读取标记范围 `[0, 3)` 和 `[6, 8)` 的数据。 +- `CounterID IN ('a', 'h') AND Date = 3`,服务器会读取标记范围 `[1, 3)` 和 `[7, 8)` 的数据。 +- `Date = 3`,服务器会读取标记范围 `[1, 10]` 的数据。 -上述示例表明,使用索引总是比完全扫描更有效。 +以上示例表明,使用索引始终比全表扫描更有效。 -稀疏索引允许读取额外的数据。当从主键的单个范围读取时,每个数据块中可以读取多达 `index_granularity * 2` 的额外行。 +稀疏索引允许读取额外数据。在读取主键的单个范围时,每个数据块中最多可以读取 `index_granularity * 2` 个额外行。 -稀疏索引允许您处理非常大量的表行,因为在大多数情况下,这种索引可以放入计算机的内存中。 +稀疏索引允许你处理非常大量的表行,因为在大多数情况下,此类索引能适应计算机的 RAM。 -ClickHouse 不要求唯一的主键。您可以插入多个具有相同主键的行。 +ClickHouse 不要求主键是唯一的。你可以插入具有相同主键的多行。 -您可以在 `PRIMARY KEY` 和 `ORDER BY` 子句中使用 `Nullable` 类型的表达式,但强烈不建议。要允许此功能,请启用 [allow_nullable_key](/operations/settings/merge-tree-settings/#allow_nullable_key) 设置。 [NULLS_LAST](/sql-reference/statements/select/order-by.md/#sorting-of-special-values) 原则适用于 `ORDER BY` 子句中的 `NULL` 值。 +你可以在 `PRIMARY KEY` 和 `ORDER BY` 子句中使用 `Nullable` 类型的表达式,但强烈不建议这样做。要启用此功能,请打开 [allow_nullable_key](/operations/settings/merge-tree-settings/#allow_nullable_key) 设置。`ORDER BY` 子句中的 [NULLS_LAST](/sql-reference/statements/select/order-by.md/#sorting-of-special-values) 原则适用于 `NULL` 值。 ### 选择主键 {#selecting-a-primary-key} -主键中的列数没有明确限制。根据数据结构,您可以在主键中包含更多或更少的列。这可能会: +主键中列的数量没有明确限制。根据数据结构,你可以在主键中包含更多或更少的列。这可能: -- 改善索引性能。 +- 提高索引的性能。 - 如果主键为 `(a, b)`,则添加另一个列 `c` 将提高性能,如果满足以下条件: + 如果主键是 `(a, b)`,则当满足以下条件时,添加另一列 `c` 将提高性能: - - 存在对列 `c` 的条件的查询。 - - 长数据范围(比 `index_granularity` 长几倍)具有相同的 `(a, b)` 值是常见的。换句话说,当添加另一个列可以跳过相当长的数据范围时。 + - 有针对列 `c` 的查询条件。 + - 长数据范围(比 `index_granularity` 长几倍)具有相同的 `(a, b)` 值是常见的。换句话说,当添加另一列可以跳过相当长的数据范围时。 - 改善数据压缩。 - ClickHouse 按主键对数据进行排序,因此一致性越高,压缩效果越好。 + ClickHouse 根据主键对数据进行排序,因此一致性越高,压缩效果越好。 -- 在 [CollapsingMergeTree](/engines/table-engines/mergetree-family/collapsingmergetree) 和 [SummingMergeTree](/engines/table-engines/mergetree-family/summingmergetree.md) 引擎中提供额外的逻辑来合并数据部分。 +- 在使用 [CollapsingMergeTree](/engines/table-engines/mergetree-family/collapsingmergetree) 和 [SummingMergeTree](/engines/table-engines/mergetree-family/summingmergetree.md) 引擎时提供额外的逻辑。 - 在这种情况下,指定一个与主键不同的 *排序键* 是有意义的。 + 在这种情况下,指定与主键不同的 *排序键* 是有意义的。 -较长的主键会对插入性能和内存消耗产生负面影响,但主键中的额外列在 `SELECT` 查询期间不会影响 ClickHouse 的性能。 +主键过长会对插入性能和内存消耗产生负面影响,但主键中的额外列不会影响 ClickHouse 在 `SELECT` 查询中的性能。 -您可以使用 `ORDER BY tuple()` 语法创建没有主键的表。在这种情况下,ClickHouse 按插入顺序存储数据。如果您希望在通过 `INSERT ... SELECT` 查询插入数据时保留数据顺序,请设置 [max_insert_threads = 1](/operations/settings/settings#max_insert_threads)。 +你可以使用 `ORDER BY tuple()` 语法创建没有主键的表。在这种情况下,ClickHouse 按插入顺序存储数据。如果希望在通过 `INSERT ... SELECT` 查询插入数据时保持数据顺序,请设置 [max_insert_threads = 1](/operations/settings/settings#max_insert_threads)。 -要按初始顺序选择数据,请使用 [单线程](/operations/settings/settings.md/#max_threads) 的 `SELECT` 查询。 +要以初始顺序选择数据,请使用 [单线程](/operations/settings/settings.md/#max_threads) 的 `SELECT` 查询。 ### 选择与排序键不同的主键 {#choosing-a-primary-key-that-differs-from-the-sorting-key} -可以指定一个主键(一个在为每个标记写入索引文件的值的表达式),与排序键(用于对数据部分中的行进行排序的表达式)不同。在这种情况下,主键表达式元组必须是排序键表达式元组的前缀。 +可以指定与排序键(用于对数据部分中的行进行排序的表达式)不同的主键(为每个标记在索引文件中写入的值的表达式)。在这种情况下,主键表达式的元组必须是排序键表达式元组的前缀。 -此功能在使用 [SummingMergeTree](/engines/table-engines/mergetree-family/summingmergetree.md) 和 [AggregatingMergeTree](/engines/table-engines/mergetree-family/aggregatingmergetree.md) 表引擎时非常有用。在使用这些引擎的常见情况下,表具有两种类型的列:*维度* 和 *度量*。典型查询使用任意 `GROUP BY` 和按维度过滤来聚合度量列的值。由于 SummingMergeTree 和 AggregatingMergeTree 会对具有相同排序键值的行进行聚合,因此将所有维度添加到其中是合理的。结果,键表达式由较长的列列表组成,并且此列表必须经常更新以添加新的维度。 +此功能在使用 [SummingMergeTree](/engines/table-engines/mergetree-family/summingmergetree.md) 和 +[AggregatingMergeTree](/engines/table-engines/mergetree-family/aggregatingmergetree.md) 表引擎时非常有用。在使用这些引擎的常见情况下,表具有两种类型的列:*维度* 和 *度量*。典型查询聚合度量列的值,使用任意 `GROUP BY` 及按维度进行过滤。由于 SummingMergeTree 和 AggregatingMergeTree 聚合具有相同排序键值的行,因此将所有维度添加到其中是很自然的。结果,键表达式由长列列表组成,该列表必须频繁地使用新添加的维度进行更新。 -在这种情况下,保留仅提供有效范围扫描的少数列作为主键,并将其余维度列添加到排序键元组中是有意义的。 +在这种情况下,将主键中仅保留少量列以提供高效的范围扫描并将其余维度列添加到排序键元组是有意义的。 -[ALTER](/sql-reference/statements/alter/index.md) 排序键是轻量级操作,因为在向表和排序键同时添加新列时,现有数据部分无需更改。由于旧排序键是新排序键的前缀,并且新添加的列中没有数据,因此在表修改时,数据根据旧排序键和新排序键进行排序。 -### 查询中的索引和分区的使用 {#use-of-indexes-and-partitions-in-queries} +对排序键的 [ALTER](/sql-reference/statements/alter/index.md) 是轻量级的,因为当新列同时添加到表和排序键时,现有数据部分不需要改变。由于旧排序键是新排序键的前缀,并且新添加列中没有数据,因此在表修改时,数据根据旧的和新的排序键进行排序。 +### 查询中索引和分区的使用 {#use-of-indexes-and-partitions-in-queries} -对于 `SELECT` 查询,ClickHouse 会分析是否可以使用索引。如果 `WHERE/PREWHERE` 子句具有表示等式或不等式比较操作的表达式(作为连接元素之一,或完全包含该表达式),或者如果在主键或分区键列或表达式上具有固定前缀的 `IN` 或 `LIKE`,或这些列的某些部分重复函数,或这些表达式的逻辑关系,则可以使用索引。 +对于 `SELECT` 查询,ClickHouse 分析是否可以使用索引。如果 `WHERE/PREWHERE` 子句具有用于表示相等或不等比较操作的表达式(作为连接元素之一,或全部)或在主键或分区键中的列或表达式上与固定前缀的 `IN` 或 `LIKE` 关系,或者这些表达式的逻辑关系,索引可以被使用。 -因此,可以快速针对主键的一个或多个范围运行查询。在此示例中,针对特定跟踪标签、特定标签和日期范围、特定标签和日期、多标签与日期范围等运行的查询将很快。 +因此,可以在主键的一个或多个范围上快速运行查询。在这个例子中,对于特定的追踪标签、特定标签和日期范围、特定标签和日期、多个标签和日期范围等,运行查询将是快速的。 -让我们看一下引擎配置如下: +让我们看一下配置如下的引擎: ```sql ENGINE MergeTree() PARTITION BY toYYYYMM(EventDate) @@ -236,7 +234,7 @@ ORDER BY (CounterID, EventDate) SETTINGS index_granularity=8192 ``` -在这种情况下,在查询中: +在这种情况下,查询中: ```sql SELECT count() FROM table @@ -254,29 +252,29 @@ AND CounterID IN (101500, 731962, 160656) AND (CounterID = 101500 OR EventDate != toDate('2014-05-01')) ``` -ClickHouse 将使用主键索引来修剪不合适的数据,使用按月的分区键来修剪不合适日期范围中的分区。 +ClickHouse 将使用主键索引来修剪不当数据,并使用按月的分区键来修剪不正确日期范围的分区。 -以上查询显示,索引即使在复杂表达式中也会被使用。从表中读取的方式确保使用索引的速度不会慢于完全扫描。 +上面的查询表明,索引甚至在复杂表达式中也在使用。从表中读取数据的组织方式确保使用索引的速度不会比全表扫描更慢。 -在以下示例中,索引无法使用。 +在以下示例中,无法使用索引。 ```sql SELECT count() FROM table WHERE CounterID = 34 OR URL LIKE '%upyachka%' ``` -要检查 ClickHouse 在运行查询时是否可以使用索引,请使用设置 [force_index_by_date](/operations/settings/settings.md/#force_index_by_date) 和 [force_primary_key](/operations/settings/settings#force_primary_key)。 +要检查 ClickHouse 是否可以在查询执行时使用索引,请使用设置 [force_index_by_date](/operations/settings/settings.md/#force_index_by_date) 和 [force_primary_key](/operations/settings/settings#force_primary_key)。 -按月分区的键允许只读取包含来自适当范围的日期的数据块。在此情况下,数据块可能包含多个日期的数据(最多一个完整的月份)。在一个块内,数据按主键排序,而主键可能没有以日期作为第一列。因此,使用仅包含未指定主键前缀的日期条件的查询将导致读取的数据量比单一日期更多。 -### 部分单调主键的索引使用 {#use-of-index-for-partially-monotonic-primary-keys} +按月分区的关键允许仅读取包含来自正确范围的日期的数据块。在这种情况下,数据块可能包含多个日期的数据(最多一个完整的月份)。在块内,数据按主键排序,而主键可能并不是第一列。因此,使用仅具有不指定主键前缀的日期条件的查询将导致读取的数据量多于单个日期。 +### 对于部分单调主键的索引使用 {#use-of-index-for-partially-monotonic-primary-keys} -例如,考虑一个月份的天数。它们形成了一个 [单调序列](https://en.wikipedia.org/wiki/Monotonic_function),但在更长的时间内不是单调的。这是一个部分单调的序列。如果用户使用部分单调主键创建表,ClickHouse 会像往常一样创建稀疏索引。当用户从这种表中选择数据时,ClickHouse 会分析查询条件。如果用户想要在索引的两个标记之间获取数据,并且这两个标记都在一个月内,ClickHouse 可以在这种特定情况下使用索引,因为它可以计算查询参数和索引标记之间的距离。 +以月份中的天数为例。它们形成了一个 [单调序列](https://en.wikipedia.org/wiki/Monotonic_function),但在更长的 períodos 中则不是单调的。这是一个部分单调序列。如果用户使用部分单调主键创建表,ClickHouse 将照常创建稀疏索引。当用户从此类表中选择数据时,ClickHouse 分析查询条件。如果用户希望获取索引的两个标记之间的数据并且这两个标记都在一个月之内,则 ClickHouse 可以在这种情况下使用索引,因为它可以计算查询参数与索引标记之间的距离。 -如果查询参数范围中的主键值未表示单调序列,ClickHouse 则无法使用索引。在这种情况下,ClickHouse 使用完全扫描方法。 +如果查询参数范围内的主键值并不构成单调序列, ClickHouse 将无法使用索引。在这种情况下,ClickHouse 使用完全扫描方法。 -ClickHouse 不仅对月份的日期序列使用此逻辑,还适用于表示部分单调序列的任何主键。 +ClickHouse 不仅对月份序列使用该逻辑,还对任何表示部分单调序列的主键使用该逻辑。 ### 数据跳过索引 {#table_engine-mergetree-data_skipping-indexes} -索引声明位于 `CREATE` 查询的列部分。 +索引声明在 `CREATE` 查询的列部分中。 ```sql INDEX index_name expr TYPE type(...) [GRANULARITY granularity_value] @@ -284,7 +282,7 @@ INDEX index_name expr TYPE type(...) [GRANULARITY granularity_value] 对于 `*MergeTree` 系列的表,可以指定数据跳过索引。 -这些索引汇总有关指定表达式在块中的一些信息,这些块由 `granularity_value` 颗粒(颗粒的大小由表引擎中的 `index_granularity` 设置指定)组成。然后,这些汇总在 `SELECT` 查询中用于减少从磁盘读取的数据量,通过跳过无法满足 `where` 查询的大块数据。 +这些索引在出现在由 `granularity_value` 颗粒(颗粒大小由表引擎中的 `index_granularity` 设置指定)组成的块上的指定表达式中聚合一些信息。然后,这些聚合会在 `SELECT` 查询中用于减少从磁盘读取的数据量,通过跳过无法满足 `where` 查询的大块数据。 `GRANULARITY` 子句可以省略,`granularity_value` 的默认值为 1。 @@ -304,7 +302,7 @@ CREATE TABLE table_name ... ``` -示例中的索引可以被 ClickHouse 用于减少从磁盘读取数据的量,查询如下: +示例中的索引可以被 ClickHouse 用于减少在以下查询中从磁盘读取的数据量: ```sql SELECT count() FROM table WHERE u64 == 10; @@ -327,36 +325,82 @@ INDEX tuple_2_index tuple_column.2 TYPE bloom_filter INDEX nested_1_index col.nested_col1 TYPE bloom_filter INDEX nested_2_index col.nested_col2 TYPE bloom_filter ``` -### 可用的索引类型 {#available-types-of-indices} -#### MinMax {#minmax} +### 跳过索引类型 {#skip-index-types} -存储指定表达式的极值(如果表达式是 `tuple`,则存储每个元素的极值),使用存储的信息跳过数据块,如同主键。 +`MergeTree` 表引擎支持以下类型的跳过索引。 +有关如何使用跳过索引进行性能优化的更多信息,请参见 ["理解 ClickHouse 数据跳过索引"](/optimize/skipping-indexes)。 -语法:`minmax` +- [`MinMax`](#minmax) 索引 +- [`Set`](#set) 索引 +- [`bloom_filter`](#bloom-filter) 索引 +- [`ngrambf_v1`](#n-gram-bloom-filter) 索引 +- [`tokenbf_v1`](#token-bloom-filter) 索引 +#### MinMax 跳过索引 {#minmax} + +对于每个索引颗粒,存储表达式的最小值和最大值。 +(如果表达式为 `tuple` 类型,则为每个元组元素存储最小值和最大值。) + +```text title="Syntax" +minmax +``` #### Set {#set} -存储指定表达式的唯一值(不超过 `max_rows` 行,`max_rows=0` 意味着“没有限制”)。使用这些值来检查 `WHERE` 表达式是否在数据块上不可满足。 +对于每个索引颗粒,最多存储 `max_rows` 个唯一值的指定表达式。 +`max_rows = 0` 表示“存储所有唯一值”。 -语法:`set(max_rows)` -#### Bloom Filter {#bloom-filter} +```text title="Syntax" +set(max_rows) +``` +#### Bloom filter {#bloom-filter} -为指定列存储 [Bloom filter](https://en.wikipedia.org/wiki/Bloom_filter)。可选 `false_positive` 参数可能取值在 0 和 1 之间,指定从过滤器获得误报响应的概率。默认值:0.025。支持的数据类型有:`Int*`、`UInt*`、`Float*`、`Enum`、`Date`、`DateTime`、`String`、`FixedString`、`Array`、`LowCardinality`、`Nullable`、`UUID` 和 `Map`。对于 `Map` 数据类型,客户端可以使用 [mapKeys](/sql-reference/functions/tuple-map-functions.md/#mapkeys) 或 [mapValues](/sql-reference/functions/tuple-map-functions.md/#mapvalues) 函数指定索引应为键或值创建。 +对于每个索引颗粒,为指定列存储一个 [bloom filter](https://en.wikipedia.org/wiki/Bloom_filter)。 -语法:`bloom_filter([false_positive])` -#### N-gram Bloom Filter {#n-gram-bloom-filter} +```text title="Syntax" +bloom_filter([false_positive_rate]) +``` -存储一个包含数据块中所有 n-gram 的 [Bloom filter](https://en.wikipedia.org/wiki/Bloom_filter)。仅适用于以下数据类型:[String](/sql-reference/data-types/string.md)、[FixedString](/sql-reference/data-types/fixedstring.md) 和 [Map](/sql-reference/data-types/map.md)。可用于优化 `EQUALS`、`LIKE` 和 `IN` 表达式。 +`false_positive_rate` 参数可以取 0 到 1 之间的值(默认值为 `0.025`),并指定生成正值的概率(这会增加读取的数据量)。 + +支持以下数据类型: +- `(U)Int*` +- `Float*` +- `Enum` +- `Date` +- `DateTime` +- `String` +- `FixedString` +- `Array` +- `LowCardinality` +- `Nullable` +- `UUID` +- `Map` + +:::note Map 数据类型:指定使用键或值创建索引 +对于 `Map` 数据类型,客户端可以使用 [`mapKeys`](/sql-reference/functions/tuple-map-functions.md/#mapkeys) 或 [`mapValues`](/sql-reference/functions/tuple-map-functions.md/#mapvalues) 函数指定是否应为键或值创建索引。 +::: +#### N-gram bloom filter {#n-gram-bloom-filter} + +对于每个索引颗粒,存储指定列的 [bloom filter](https://en.wikipedia.org/wiki/Bloom_filter) 的 [n-grams](https://en.wikipedia.org/wiki/N-gram)。 -语法:`ngrambf_v1(n, size_of_bloom_filter_in_bytes, number_of_hash_functions, random_seed)` +```text title="Syntax" +ngrambf_v1(n, size_of_bloom_filter_in_bytes, number_of_hash_functions, random_seed) +``` -- `n` — ngram 大小, -- `size_of_bloom_filter_in_bytes` — Bloom filter 大小(可以使用较大值,例如 256 或 512,因为它可以很好地压缩)。 -- `number_of_hash_functions` — Bloom filter 中所用的哈希函数数量。 -- `random_seed` — Bloom filter 哈希函数的种子。 +| 参数 | 描述 | +|---------------------------------|---------------| +| `n` | ngram 大小 | +| `size_of_bloom_filter_in_bytes` | bloom filter 大小(字节)。这里可以使用大值,例如 `256` 或 `512`,因为它可以很好地压缩)。| +|`number_of_hash_functions` | 在 bloom filter 中使用的哈希函数数量。| +|`random_seed` | bloom filter 哈希函数的种子。| -用户可以创建 [UDF](/sql-reference/statements/create/function.md) 来估算 `ngrambf_v1` 的参数。查询语句如下: +此索引仅适用于以下数据类型: +- [`String`](/sql-reference/data-types/string.md) +- [`FixedString`](/sql-reference/data-types/fixedstring.md) +- [`Map`](/sql-reference/data-types/map.md) -```sql +要评估 `ngrambf_v1` 的参数,你可以使用以下 [用户定义函数 (UDFs)](/sql-reference/statements/create/function.md)。 + +```sql title="UDFs for ngrambf_v1" CREATE FUNCTION bfEstimateFunctions [ON CLUSTER cluster] AS (total_number_of_all_grams, size_of_bloom_filter_in_bits) -> round((size_of_bloom_filter_in_bits / total_number_of_all_grams) * log(2)); @@ -372,15 +416,18 @@ AS CREATE FUNCTION bfEstimateGramNumber [ON CLUSTER cluster] AS (number_of_hash_functions, probability_of_false_positives, size_of_bloom_filter_in_bytes) -> ceil(size_of_bloom_filter_in_bytes / (-number_of_hash_functions / log(1 - exp(log(probability_of_false_positives) / number_of_hash_functions)))) - ``` -要使用这些函数,我们需要至少指定两个参数。 -例如,如果颗粒中有 4300 个 ngram,而我们期望误报小于 0.0001。其他参数可以通过执行以下查询来估算: +为了使用这些函数,你需要指定至少两个参数: +- `total_number_of_all_grams` +- `probability_of_false_positives` + +例如,颗粒中有 `4300` 个 ngrams,你希望误报少于 `0.0001`。 +在执行以下查询时,可以估算其他参数: ```sql --- estimate number of bits in the filter -SELECT bfEstimateBmSize(4300, 0.0001) / 8 as size_of_bloom_filter_in_bytes; +SELECT bfEstimateBmSize(4300, 0.0001) / 8 AS size_of_bloom_filter_in_bytes; ┌─size_of_bloom_filter_in_bytes─┐ │ 10304 │ @@ -392,108 +439,117 @@ SELECT bfEstimateFunctions(4300, bfEstimateBmSize(4300, 0.0001)) as number_of_ha ┌─number_of_hash_functions─┐ │ 13 │ └──────────────────────────┘ - ``` -当然,您也可以使用这些函数通过其他条件估算参数。 -这些函数参考 [这里](https://hur.st/bloomfilter)。 -#### Token Bloom Filter {#token-bloom-filter} -与 `ngrambf_v1` 相同,但存储代替 ngram 的 tokens。Tokens 是由非字母数字字符分隔的序列。 +当然,你也可以使用这些函数评估其他条件的参数。 +上述函数参考了 [这里](https://hur.st/bloomfilter) 的 bloom filter 计算器。 +#### Token bloom filter {#token-bloom-filter} -语法:`tokenbf_v1(size_of_bloom_filter_in_bytes, number_of_hash_functions, random_seed)` -#### 专用 {#special-purpose} +token bloom filter 与 `ngrambf_v1` 相同,但存储的是 tokens(由非字母数字字符分隔的序列),而不是 ngrams。 -- 实验性索引以支持近似最近邻搜索。有关详细信息,请参见 [此处](annindexes.md)。 -- 实验性全文索引以支持全文搜索。有关详细信息,请参见 [此处](invertedindexes.md)。 +```text title="Syntax" +tokenbf_v1(size_of_bloom_filter_in_bytes, number_of_hash_functions, random_seed) +``` +#### 向量相似性 {#vector-similarity} + +支持近似最近邻搜索,详细信息见 [这里](annindexes.md)。 +### 文本(实验性) {#text} + +支持全文搜索,详细信息见 [这里](invertedindexes.md)。 ### 函数支持 {#functions-support} -`WHERE` 子句中的条件包含对操作列的函数调用。如果列是索引的一部分,则 ClickHouse 在执行这些函数时尝试使用该索引。ClickHouse 支持不同子集的函数以支持索引。 - -所有函数均可利用 `set` 类型索引。其他索引类型的支持如下: - -| 函数(操作符)/ 索引 | 主键 | minmax | ngrambf_v1 | tokenbf_v1 | bloom_filter | full_text | -|------------------------------------------------------------------------------------------------------------|------|--------|------------|------------|--------------|-----------| -| [equals (=, ==)](/sql-reference/functions/comparison-functions.md/#equals) | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | -| [notEquals(!=, <>)](/sql-reference/functions/comparison-functions.md/#notequals) | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | -| [like](/sql-reference/functions/string-search-functions.md/#like) | ✔ | ✔ | ✔ | ✔ | ✗ | ✔ | -| [notLike](/sql-reference/functions/string-search-functions.md/#notlike) | ✔ | ✔ | ✔ | ✔ | ✗ | ✔ | -| [match](/sql-reference/functions/string-search-functions.md/#match) | ✗ | ✗ | ✔ | ✔ | ✗ | ✔ | -| [startsWith](/sql-reference/functions/string-functions.md/#startswith) | ✔ | ✔ | ✔ | ✔ | ✗ | ✔ | -| [endsWith](/sql-reference/functions/string-functions.md/#endswith) | ✗ | ✗ | ✔ | ✔ | ✗ | ✔ | -| [multiSearchAny](/sql-reference/functions/string-search-functions.md/#multisearchany) | ✗ | ✗ | ✔ | ✗ | ✗ | ✔ | -| [in](/sql-reference/functions/in-functions) | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | -| [notIn](/sql-reference/functions/in-functions) | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | -| [less (`<`)](/sql-reference/functions/comparison-functions.md/#less) | ✔ | ✔ | ✗ | ✗ | ✗ | ✗ | -| [greater (`>`)](/sql-reference/functions/comparison-functions.md/#greater) | ✔ | ✔ | ✗ | ✗ | ✗ | ✗ | -| [lessOrEquals (`<=`)](/sql-reference/functions/comparison-functions.md/#lessorequals) | ✔ | ✔ | ✗ | ✗ | ✗ | ✗ | -| [greaterOrEquals (`>=`)](/sql-reference/functions/comparison-functions.md/#greaterorequals) | ✔ | ✔ | ✗ | ✗ | ✗ | ✗ | -| [empty](/sql-reference/functions/array-functions/#empty) | ✔ | ✔ | ✗ | ✗ | ✗ | ✗ | -| [notEmpty](/sql-reference/functions/array-functions/#notempty) | ✔ | ✔ | ✗ | ✗ | ✗ | ✗ | -| [has](/sql-reference/functions/array-functions#hasarr-elem) | ✗ | ✗ | ✔ | ✔ | ✔ | ✔ | -| [hasAny](/sql-reference/functions/array-functions#hasany) | ✗ | ✗ | ✔ | ✔ | ✔ | ✗ | -| [hasAll](/sql-reference/functions/array-functions#hasall) | ✗ | ✗ | ✔ | ✔ | ✔ | ✗ | -| hasToken | ✗ | ✗ | ✗ | ✔ | ✗ | ✔ | -| hasTokenOrNull | ✗ | ✗ | ✗ | ✔ | ✗ | ✔ | -| hasTokenCaseInsensitive (*) | ✗ | ✗ | ✗ | ✔ | ✗ | ✗ | -| hasTokenCaseInsensitiveOrNull (*) | ✗ | ✗ | ✗ | ✔ | ✗ | ✗ | - -对于小于 ngram 大小的常量参数,不能使用 `ngrambf_v1` 进行查询优化。 - -(*) 对于 `hasTokenCaseInsensitive` 和 `hasTokenCaseInsensitiveOrNull` 生效,必须在小写数据上创建 `tokenbf_v1` 索引,例如 `INDEX idx (lower(str_col)) TYPE tokenbf_v1(512, 3, 0)`。 +在 `WHERE` 子句中的条件包含对列进行操作的函数调用。如果列是索引的一部分,ClickHouse 在执行函数时会尝试使用该索引。ClickHouse 支持不同子集的函数来使用索引。 + +`set` 类型的索引可以被所有函数利用。其他索引类型的支持如下: + +| 函数(操作符) / 索引 | 主键 | minmax | ngrambf_v1 | tokenbf_v1 | bloom_filter | 文本 | +|-------------------------------------------------------------------------------------------------------------------------------|-------------|---------|------------|------------|--------------|------| +| [equals (=, ==)](/sql-reference/functions/comparison-functions.md/#equals) | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | +| [notEquals(!=, <>)](/sql-reference/functions/comparison-functions.md/#notEquals) | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | +| [like](/sql-reference/functions/string-search-functions.md/#like) | ✔ | ✔ | ✔ | ✔ | ✗ | ✔ | +| [notLike](/sql-reference/functions/string-search-functions.md/#notlike) | ✔ | ✔ | ✔ | ✔ | ✗ | ✔ | +| [match](/sql-reference/functions/string-search-functions.md/#match) | ✗ | ✗ | ✔ | ✔ | ✗ | ✔ | +| [startsWith](/sql-reference/functions/string-functions.md/#startswith) | ✔ | ✔ | ✔ | ✔ | ✗ | ✔ | +| [endsWith](/sql-reference/functions/string-functions.md/#endswith) | ✗ | ✗ | ✔ | ✔ | ✗ | ✔ | +| [multiSearchAny](/sql-reference/functions/string-search-functions.md/#multisearchany) | ✗ | ✗ | ✔ | ✗ | ✗ | ✗ | +| [in](/sql-reference/functions/in-functions) | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | +| [notIn](/sql-reference/functions/in-functions) | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | +| [less (`<`)](/sql-reference/functions/comparison-functions.md/#less) | ✔ | ✔ | ✗ | ✗ | ✗ | ✗ | +| [greater (`>`)](/sql-reference/functions/comparison-functions.md/#greater) | ✔ | ✔ | ✗ | ✗ | ✗ | ✗ | +| [lessOrEquals (`<=`)](/sql-reference/functions/comparison-functions.md/#lessOrEquals) | ✔ | ✔ | ✗ | ✗ | ✗ | ✗ | +| [greaterOrEquals (`>=`)](/sql-reference/functions/comparison-functions.md/#greaterOrEquals) | ✔ | ✔ | ✗ | ✗ | ✗ | ✗ | +| [empty](/sql-reference/functions/array-functions/#empty) | ✔ | ✔ | ✗ | ✗ | ✗ | ✗ | +| [notEmpty](/sql-reference/functions/array-functions/#notEmpty) | ✔ | ✔ | ✗ | ✗ | ✗ | ✗ | +| [has](/sql-reference/functions/array-functions#has) | ✗ | ✗ | ✔ | ✔ | ✔ | ✔ | +| [hasAny](/sql-reference/functions/array-functions#hasAny) | ✗ | ✗ | ✔ | ✔ | ✔ | ✗ | +| [hasAll](/sql-reference/functions/array-functions#hasAll) | ✗ | ✗ | ✔ | ✔ | ✔ | ✗ | +| [hasToken](/sql-reference/functions/string-search-functions.md/#hastoken) | ✗ | ✗ | ✗ | ✔ | ✗ | ✔ | +| [hasTokenOrNull](/sql-reference/functions/string-search-functions.md/#hastokenornull) | ✗ | ✗ | ✗ | ✔ | ✗ | ✔ | +| [hasTokenCaseInsensitive (`*`)](/sql-reference/functions/string-search-functions.md/#hastokencaseinsensitive) | ✗ | ✗ | ✗ | ✔ | ✗ | ✗ | +| [hasTokenCaseInsensitiveOrNull (`*`)](/sql-reference/functions/string-search-functions.md/#hastokencaseinsensitiveornull) | ✗ | ✗ | ✗ | ✔ | ✗ | ✗ | +| [hasAnyTokens](/sql-reference/functions/string-search-functions.md/#hasanytokens) | ✗ | ✗ | ✗ | ✗ | ✗ | ✔ | +| [hasAllTokens](/sql-reference/functions/string-search-functions.md/#hasalltokens) | ✗ | ✗ | ✗ | ✗ | ✗ | ✔ | +| [mapContains](/sql-reference/functions/tuple-map-functions#mapcontains) | ✗ | ✗ | ✗ | ✗ | ✗ | ✔ | + +参数少于 ngram 大小的常量参数的函数不能通过 `ngrambf_v1` 来优化查询。 + +(*) 为了使 `hasTokenCaseInsensitive` 和 `hasTokenCaseInsensitiveOrNull` 生效,必须在小写数据上创建 `tokenbf_v1` 索引,例如 `INDEX idx (lower(str_col)) TYPE tokenbf_v1(512, 3, 0)`。 :::note -Bloom filters 可能会存在误报匹配,因此 `ngrambf_v1`、`tokenbf_v1` 和 `bloom_filter` 索引不能用于优化预期函数结果为 false 的查询。 +布隆过滤器可能会有假阳性匹配,因此 `ngrambf_v1`、`tokenbf_v1` 和 `bloom_filter` 索引不能用于优化期望结果为假的查询。 例如: -- 可以优化: - - `s LIKE '%test%'` - - `NOT s NOT LIKE '%test%'` - - `s = 1` - - `NOT s != 1` - - `startsWith(s, 'test')` -- 不能优化: - - `NOT s LIKE '%test%'` - - `s NOT LIKE '%test%'` - - `NOT s = 1` - - `s != 1` - - `NOT startsWith(s, 'test')` +- 可以被优化: + - `s LIKE '%test%'` + - `NOT s NOT LIKE '%test%'` + - `s = 1` + - `NOT s != 1` + - `startsWith(s, 'test')` +- 不能被优化: + - `NOT s LIKE '%test%'` + - `s NOT LIKE '%test%'` + - `NOT s = 1` + - `s != 1` + - `NOT startsWith(s, 'test')` ::: ## 投影 {#projections} -投影像 [物化视图](/sql-reference/statements/create/view),但在部分级别定义。它提供一致性保证,并在查询中自动使用。 +投影类似于 [物化视图](/sql-reference/statements/create/view),但在部分级别进行定义。它提供了一致性保证,并在查询中自动使用。 :::note -在实现投影时,您还应考虑 [force_optimize_projection](/operations/settings/settings#force_optimize_projection) 设置。 +在实现投影时,你还应该考虑 [force_optimize_projection](/operations/settings/settings#force_optimize_projection) 设置。 ::: -具有 [FINAL](/sql-reference/statements/select/from#final-modifier) 修饰符的 `SELECT` 语句不支持投影。 +在具有 [FINAL](/sql-reference/statements/select/from#final-modifier) 修饰符的 `SELECT` 语句中不支持投影。 ### 投影查询 {#projection-query} -投影查询定义一个投影。它隐式地从父表选择数据。 +投影查询定义了一个投影。它隐式地从父表中选择数据。 **语法** ```sql SELECT [GROUP BY] [ORDER BY] ``` -投影可以通过 [ALTER](/sql-reference/statements/alter/projection.md) 语句进行修改或删除。 +投影可以与 [ALTER](/sql-reference/statements/alter/projection.md) 语句一起修改或删除。 ### 投影存储 {#projection-storage} -投影存储在部分目录中。它类似于索引,但包含一个子目录,该目录存储匿名的 `MergeTree` 表的部分。该表由投影的定义查询引入。如果有 `GROUP BY` 子句,则底层存储引擎变为 [AggregatingMergeTree](aggregatingmergetree.md),所有聚合函数转换为 `AggregateFunction`。如果有 `ORDER BY` 子句,则 `MergeTree` 表将其用作主键表达式。在合并过程中,投影部分通过其存储的合并例程进行合并。父表部分的校验和与投影的部分结合。其他维护任务类似于跳过索引的任务。 +投影存储在部分目录中。它类似于索引,但包含一个子目录来存储匿名 `MergeTree` 表的一部分。该表由投影的定义查询引发。如果有 `GROUP BY` 子句,则底层存储引擎成为 [AggregatingMergeTree](aggregatingmergetree.md),所有聚合函数转换为 `AggregateFunction`。如果有 `ORDER BY` 子句,`MergeTree` 表使用其作为主键表达式。在合并过程中,投影部分通过其存储的合并例程进行合并。父表部分的校验和与投影的部分相结合。其他维护工作与跳过索引相似。 ### 查询分析 {#projection-query-analysis} -1. 检查投影是否可以用于回答给定的查询,即它生成的答案是否与对基础表的查询相同。 -2. 选择最佳的可行匹配,其中包含最少的颗粒以读取。 -3. 使用投影的查询管道将与使用原始部分的查询管道不同。如果某些部分中不存在投影,我们可以新增管道以“即时”投影。 +1. 检查投影是否可以用来回答给定的查询,即它生成的答案是否与查询基础表相同。 +2. 选择最佳的可行匹配,即读取的粒度最少。 +3. 使用投影的查询管道将不同于使用原始部分的查询管道。如果某些部分缺少投影,我们可以动态添加管道以“投影”它。 + ## 并发数据访问 {#concurrent-data-access} -对于并发表访问,我们使用多版本控制。换句话说,当一个表被同时读取和更新时,数据从查询时的当前部分集读取。没有长时间的锁定。插入不会妨碍读取操作。 +对于并发表访问,我们使用多版本控制。换句话说,当一个表被同时读取和更新时,数据是从查询时当前的一组部分中读取的。没有冗长的锁。插入不会干扰读取操作。 + +从一个表读取数据会自动并行化。 -从表中读取是自动并行化的。 ## 列和表的 TTL {#table_engine-mergetree-ttl} 确定值的生命周期。 -`TTL` 子句可以为整个表和每个单独列设置。表级 `TTL` 还可以指定自动在磁盘和卷之间移动数据的逻辑,或重新压缩所有数据已过期的部分。 +`TTL` 子句可以为整个表和每个单独的列设置。表级 `TTL` 还可以指定在磁盘和卷之间自动移动数据的逻辑,或重新压缩所有数据已过期的部分。 -表达式必须评估为 [Date](/sql-reference/data-types/date.md)、[Date32](/sql-reference/data-types/date32.md)、[DateTime](/sql-reference/data-types/datetime.md) 或 [DateTime64](/sql-reference/data-types/datetime64.md) 数据类型。 +表达式必须评估为 [Date](/sql-reference/data-types/date.md), [Date32](/sql-reference/data-types/date32.md), [DateTime](/sql-reference/data-types/datetime.md) 或 [DateTime64](/sql-reference/data-types/datetime64.md) 数据类型。 **语法** @@ -504,20 +560,21 @@ TTL time_column TTL time_column + interval ``` -要定义 `interval`,请使用 [时间间隔](/sql-reference/operators#operators-for-working-with-dates-and-times) 操作符,例如: +要定义 `interval`,使用 [time interval](/sql-reference/operators#operators-for-working-with-dates-and-times) 运算符,例如: ```sql TTL date_time + INTERVAL 1 MONTH TTL date_time + INTERVAL 15 HOUR ``` -### Column TTL {#mergetree-column-ttl} -当列中的值过期时,ClickHouse将其替换为该列数据类型的默认值。如果数据部分中的所有列值过期,ClickHouse将从文件系统中的数据部分删除该列。 +### 列 TTL {#mergetree-column-ttl} + +当列中的值过期时,ClickHouse 会用列数据类型的默认值替换它们。如果数据部分中所有列值过期,ClickHouse 会从文件系统中删除此列。 -`TTL` 子句不能用于关键列。 +`TTL` 子句不能用于主键列。 **示例** -#### 创建带有 `TTL` 的表: {#creating-a-table-with-ttl} +#### 创建带有 `TTL` 的表: {#creating-a-table-with-ttl} ```sql CREATE TABLE tab @@ -531,7 +588,7 @@ ENGINE = MergeTree PARTITION BY toYYYYMM(d) ORDER BY d; ``` -#### 为现有表的列添加 TTL {#adding-ttl-to-a-column-of-an-existing-table} +#### 向现有表的列添加 TTL {#adding-ttl-to-a-column-of-an-existing-table} ```sql ALTER TABLE tab @@ -545,9 +602,10 @@ ALTER TABLE tab MODIFY COLUMN c String TTL d + INTERVAL 1 MONTH; ``` + ### 表 TTL {#mergetree-table-ttl} -表可以有一个用于删除过期行的表达式,以及多个用于自动移动部分的表达式,这些部分可以在 [磁盘或卷](#table_engine-mergetree-multiple-volumes) 之间移动。当表中的行过期时,ClickHouse将删除所有对应的行。对于移动或重新压缩的部分,部分的所有行必须满足 `TTL` 表达式标准。 +表可以有一个表达式用于删除过期的行,以及多个表达式用于在 [磁盘或卷](#table_engine-mergetree-multiple-volumes) 之间自动移动部分。当表中的行过期时,ClickHouse 会删除所有对应的行。对于移动或重新压缩部分,部分的所有行必须满足 `TTL` 表达式的标准。 ```sql TTL expr @@ -556,25 +614,25 @@ TTL expr [GROUP BY key_expr [SET v1 = aggr_func(v1) [, v2 = aggr_func(v2) ...]] ] ``` -TTL 规则的类型可以跟随每个 TTL 表达式。它影响在表达式满足(达到当前时间)时要执行的操作: +TTL 规则的类型可以跟随每个 TTL 表达式。它影响一旦表达式被满足(达到当前时间)后要执行的操作: - `DELETE` - 删除过期行(默认操作); -- `RECOMPRESS codec_name` - 使用 `codec_name` 重新压缩数据部分; +- `RECOMPRESS codec_name` - 以 `codec_name` 重新压缩数据部分; - `TO DISK 'aaa'` - 将部分移动到磁盘 `aaa`; - `TO VOLUME 'bbb'` - 将部分移动到磁盘 `bbb`; - `GROUP BY` - 聚合过期行。 -`DELETE` 操作可以与 `WHERE` 子句一起使用,仅删除根据过滤条件的一些过期行: +可以与 `WHERE` 子句同时使用 `DELETE` 操作以仅删除部分过期行,基于过滤条件: ```sql TTL time_column + INTERVAL 1 MONTH DELETE WHERE column = 'value' ``` `GROUP BY` 表达式必须是表主键的前缀。 -如果某列不是 `GROUP BY` 表达式的一部分,并且没有在 `SET` 子句中显式设置,结果行将包含来自分组行的偶然值(就像对其应用了聚合函数 `any` 一样)。 +如果列不是 `GROUP BY` 表达式的一部分并且没有在 `SET` 子句中显式设置,在结果行中,它将包含分组行中的随机值(如同应用了聚合函数 `any`)。 **示例** -#### 创建带有 `TTL` 的表: {#creating-a-table-with-ttl-1} +#### 创建带有 `TTL` 的表: {#creating-a-table-with-ttl-1} ```sql CREATE TABLE tab @@ -589,14 +647,14 @@ TTL d + INTERVAL 1 MONTH DELETE, d + INTERVAL 1 WEEK TO VOLUME 'aaa', d + INTERVAL 2 WEEK TO DISK 'bbb'; ``` -#### 修改表的 `TTL`: {#altering-ttl-of-the-table} +#### 修改表的 `TTL`: {#altering-ttl-of-the-table} ```sql ALTER TABLE tab MODIFY TTL d + INTERVAL 1 DAY; ``` -创建一个表,其中行在一个月后过期。过期的行(日期为星期一)被删除: +创建一个表,其中的行在一个月后过期。过期行中日期为周一的行被删除: ```sql CREATE TABLE table_with_where @@ -609,7 +667,7 @@ PARTITION BY toYYYYMM(d) ORDER BY d TTL d + INTERVAL 1 MONTH DELETE WHERE toDayOfWeek(d) = 1; ``` -#### 创建一个过期行被重新压缩的表: {#creating-a-table-where-expired-rows-are-recompressed} +#### 创建一个表,其中过期行被重新压缩: {#creating-a-table-where-expired-rows-are-recompressed} ```sql CREATE TABLE table_for_recompression @@ -624,7 +682,7 @@ TTL d + INTERVAL 1 MONTH RECOMPRESS CODEC(ZSTD(17)), d + INTERVAL 1 YEAR RECOMPR SETTINGS min_rows_for_wide_part = 0, min_bytes_for_wide_part = 0; ``` -创建一个过期行被聚合的表。结果行 `x` 包含分组行中的最大值,`y` - 最小值,`d` - 来自分组行的任何偶然值。 +创建一个表,其中过期行被聚合。在结果行中 `x` 包含分组行中的最大值,`y` — 最小值,`d` — 分组行中的任何随机值。 ```sql CREATE TABLE table_for_aggregation @@ -639,49 +697,53 @@ ENGINE = MergeTree ORDER BY (k1, k2) TTL d + INTERVAL 1 MONTH GROUP BY k1, k2 SET x = max(x), y = min(y); ``` -### 移除过期数据 {#mergetree-removing-expired-data} -过期 `TTL` 的数据在 ClickHouse 合并数据部分时被移除。 +### 删除过期数据 {#mergetree-removing-expired-data} + +当 ClickHouse 合并数据部分时,带有过期 `TTL` 的数据会被移除。 -当 ClickHouse 检测到数据过期时,它会执行非计划合并。要控制此类合并的频率,可以设置 `merge_with_ttl_timeout`。如果值设置得太低,可能会执行许多非计划合并,从而消耗大量资源。 +当 ClickHouse 检测到数据过期时,它会进行一次非计划合并。要控制此类合并的频率,可以设置 `merge_with_ttl_timeout`。如果值过低,会执行大量非计划合并,可能消耗大量资源。 -如果在合并之间执行 `SELECT` 查询,可能会得到过期数据。为避免这种情况,请在 `SELECT` 之前使用 [OPTIMIZE](/sql-reference/statements/optimize.md) 查询。 +如果在合并之间执行 `SELECT` 查询,可能会获取到过期数据。为了避免这种情况,请在 `SELECT` 之前使用 [OPTIMIZE](/sql-reference/statements/optimize.md) 查询。 -**另见** +**另请参见** - [ttl_only_drop_parts](/operations/settings/merge-tree-settings#ttl_only_drop_parts) 设置 + ## 磁盘类型 {#disk-types} -除了本地块设备,ClickHouse 支持以下存储类型: +除了本地块设备,ClickHouse 还支持以下存储类型: - [`s3` 用于 S3 和 MinIO](#table_engine-mergetree-s3) - [`gcs` 用于 GCS](/integrations/data-ingestion/gcs/index.md/#creating-a-disk) -- [`blob_storage_disk` 用于 Azure Blob 存储](/operations/storing-data#azure-blob-storage) +- [`blob_storage_disk` 用于 Azure Blob Storage](/operations/storing-data#azure-blob-storage) - [`hdfs` 用于 HDFS](/engines/table-engines/integrations/hdfs) -- [`web` 用于只读访问网页](/operations/storing-data#web-storage) +- [`web` 用于只读 Web](/operations/storing-data#web-storage) - [`cache` 用于本地缓存](/operations/storing-data#using-local-cache) -- [`s3_plain` 用于 S3 备份](/operations/backup#backuprestore-using-an-s3-disk) -- [`s3_plain_rewritable` 用于 S3 中不可变、非复制表](/operations/storing-data.md#s3-plain-rewritable-storage) +- [`s3_plain` 用于备份到 S3](/operations/backup#backuprestore-using-an-s3-disk) +- [`s3_plain_rewritable` 用于 S3 中的不可变、非复制表](/operations/storing-data.md#s3-plain-rewritable-storage) + ## 使用多个块设备进行数据存储 {#table_engine-mergetree-multiple-volumes} ### 介绍 {#introduction} -`MergeTree` 家族表引擎可以在多个块设备上存储数据。例如,当某个表的数据隐式地分为“热”数据和“冷”数据时,这会很有用。最新的数据是经常请求的,但只需要很少的空间。相反,尾部肥大的历史数据很少被请求。如果有几个磁盘可用,“热”数据可能位于快速磁盘(例如,NVMe SSD 或内存)上,而“冷”数据则位于相对较慢的磁盘(例如,HDD)上。 +`MergeTree` 系列表引擎可以在多个块设备上存储数据。例如,当某个表的数据隐式分为“热”与“冷”时,这可能很有用。最近的数据经常被请求,但只需要少量空间。相反,胖尾的历史数据很少被请求。如果有多个磁盘可用,“热”数据可以放在快速磁盘上(例如 NVMe SSD 或内存中),而“冷”数据则放在相对较慢的磁盘上(例如 HDD)。 + +数据部分是 `MergeTree` 引擎表的最小可移动单位。属于一个部分的数据存储在一个磁盘上。数据部分可以根据用户设置在后台在磁盘之间移动,也可以通过 [ALTER](/sql-reference/statements/alter/partition) 查询实现。 -数据部分是 `MergeTree` 引擎表的最小可移动单元。属于同一部分的数据存储在同一磁盘上。数据部分可以根据用户设置在后台在磁盘之间移动,也可以通过 [ALTER](/sql-reference/statements/alter/partition) 查询进行移动。 ### 术语 {#terms} - 磁盘 — 挂载到文件系统的块设备。 - 默认磁盘 — 存储在 [path](/operations/server-configuration-parameters/settings.md/#path) 服务器设置中指定路径的磁盘。 -- 卷 — 有序的相等磁盘集合(类似于 [JBOD](https://en.wikipedia.org/wiki/Non-RAID_drive_architectures))。 -- 存储策略 — 卷的集合及其之间移动数据的规则。 +- 卷 — 一组相等的有序磁盘(类似于 [JBOD](https://en.wikipedia.org/wiki/Non-RAID_drive_architectures))。 +- 存储策略 — 卷的集合以及在它们之间移动数据的规则。 + +给定的实体名称可以在系统表中找到,[system.storage_policies](/operations/system-tables/storage_policies) 和 [system.disks](/operations/system-tables/disks)。要对表应用配置的存储策略之一,请使用 `MergeTree` 引擎系列表的 `storage_policy` 设置。 -给这些实体命名的信息可以在系统表 [system.storage_policies](/operations/system-tables/storage_policies) 和 [system.disks](/operations/system-tables/disks) 中找到。要为表应用配置的存储策略,请使用 `MergeTree` 引擎家族表的 `storage_policy` 设置。 ### 配置 {#table_engine-mergetree-multiple-volumes_configure} -磁盘、卷和存储策略应在 `` 标签内声明,或在 `config.d` 目录中的文件中声明。 +磁盘、卷和存储策略应在 `` 标签内声明,放在 `config.d` 目录中的文件中。 :::tip -磁盘也可以在查询的 `SETTINGS` 部分声明。这对于临时地附加磁盘(例如,托管在 URL 上)进行临时分析非常有用。 -有关更多详细信息,请参见 [动态存储](/operations/storing-data#dynamic-configuration)。 +磁盘也可以在查询的 `SETTINGS` 部分声明。这对于临时分析是有用的,可以临时附加一个磁盘,例如,托管在 URL 上。有关更多详细信息,请参见 [动态存储](/operations/storing-data#dynamic-configuration)。 ::: 配置结构: @@ -711,8 +773,8 @@ TTL d + INTERVAL 1 MONTH GROUP BY k1, k2 SET x = max(x), y = min(y); 标签: - `` — 磁盘名称。所有磁盘的名称必须不同。 -- `path` — 服务器将存储数据(`data` 和 `shadow` 文件夹)的路径,应以 '/' 结尾。 -- `keep_free_space_bytes` — 保留的磁盘可用空间量。 +- `path` — 服务器存储数据(`data` 和 `shadow` 文件夹)的路径,应以 `/` 结束。 +- `keep_free_space_bytes` — 要保留的可用磁盘空间量。 磁盘定义的顺序并不重要。 @@ -750,17 +812,17 @@ TTL d + INTERVAL 1 MONTH GROUP BY k1, k2 SET x = max(x), y = min(y); - `policy_name_N` — 策略名称。策略名称必须唯一。 - `volume_name_N` — 卷名称。卷名称必须唯一。 -- `disk` — 卷中的一个磁盘。 -- `max_data_part_size_bytes` — 可以存储在任何卷磁盘上的部分的最大大小。如果合并后的部分估计比 `max_data_part_size_bytes` 大,则该部分将写入下一个卷。基本上,此功能允许在热(SSD)卷上保留新的/小的部分,并在它们达到大尺寸时将其移动到冷(HDD)卷。如果您的策略只有一个卷,请勿使用此设置。 -- `move_factor` — 当可用空间的量低于此因子时,数据会自动开始移动到下一个卷(默认值为 0.1)。ClickHouse 按大小从大到小(降序)对现有部分进行排序,并选择总大小足以满足 `move_factor` 条件的部分。如果所有部分的总大小不足,则所有部分都将被移动。 -- `perform_ttl_move_on_insert` — 禁用在数据部分 INSERT 时的 TTL 移动。默认情况下(如果启用),如果我们插入一个已经根据 TTL 移动规则过期的数据部分,它将立即移动到移动规则中声明的卷/磁盘。如果目标卷/磁盘很慢(例如,S3),那么这可能会显著减慢插入速度。如果禁用,则已过期的数据部分将写入默认卷,然后立即移动到 TTL 卷。 -- `load_balancing` - 磁盘平衡的策略,`round_robin` 或 `least_used`。 -- `least_used_ttl_ms` - 配置更新所有磁盘可用空间的超时(以毫秒为单位)(`0` - 始终更新,`-1` - 永不更新,默认值为 `60000`)。请注意,如果磁盘只能被 ClickHouse 使用并且不受在线文件系统调整/缩小,则可以使用 `-1`,在其他情况下不推荐,因为最终会导致空间分配不正确。 -- `prefer_not_to_merge` — 您不应该使用此设置。禁用此卷上的数据部分合并(这有害并导致性能下降)。当启用此设置时(请勿这样做),不允许合并此卷上的数据(这很糟糕)。这允许(但您不需要它)控制(如果您想控制一些东西,那就是错误)ClickHouse 如何与慢磁盘交互(但 ClickHouse 知道得更好,所以请不要使用此设置)。 -- `volume_priority` — 定义填充卷的优先级(顺序)。较低的值意味着较高的优先级。参数值应为自然数,并且共同覆盖 1 到 N(最低优先级给定)范围内的所有数字,而不跳过任何数字。 - * 如果所有卷都被标记,则将按给定顺序进行优先排序。 - * 如果仅某些卷被标记,则未标记的卷的优先级最低,按它们在配置中定义的顺序优先排序。 - * 如果没有卷被标记,则它们的优先级根据其在配置中声明的顺序进行设置。 +- `disk` — 卷内的一个磁盘。 +- `max_data_part_size_bytes` — 可以存储在任何卷的磁盘上的部分的最大大小。如果已合并部分的大小预计大于 `max_data_part_size_bytes`,则该部分将写入下一个卷。基本上,这个特性允许在热(SSD)卷上保留新的/小的部分,并在它们达到大尺寸时将它们移动到冷(HDD)卷。如果你的策略只有一个卷,请勿使用此设置。 +- `move_factor` — 当可用空间低于此因子时,如果有下一卷,数据会自动开始移动(默认值为 0.1)。ClickHouse 按大小从大到小(降序)对现有部分进行排序,并选择总大小足以满足 `move_factor` 条件的部分。如果所有部分的总大小不足,则所有部分将被移动。 +- `perform_ttl_move_on_insert` — 禁用在数据部分插入时进行 TTL 移动。默认情况下(如果启用),如果我们插入一个根据 TTL 移动规则已经过期的数据部分,它会立即转移到移动规则中声明的卷/磁盘。如果目标卷/磁盘速度较慢(例如 S3),这可能会显著减慢插入。如果禁用,则已经过期的数据部分将写入默认卷,然后立即移至 TTL 卷。 +- `load_balancing` - 磁盘负载均衡策略,`round_robin` 或 `least_used`。 +- `least_used_ttl_ms` - 配置更新所有磁盘上可用空间的超时(以毫秒为单位)(`0` - 始终更新,`-1` - 永不更新,默认值为 `60000`)。请注意,如果磁盘仅能被 ClickHouse 使用,并且不受在线文件系统扩展/缩小的影响,则可以使用 `-1`,在所有其他情况下不建议使用,因为最终会导致空间分布不正确。 +- `prefer_not_to_merge` — 您应避免使用此设置。禁止在此卷上合并数据部分(这有害且会导致性能下降)。当启用此设置时(不要这样做),不允许在此卷上合并数据(这不好)。允许(但您不需要这样做)控制(如果您希望控制某些东西,您在犯错误)ClickHouse 如何处理慢速磁盘(但 ClickHouse 知道得更好,请不要使用此设置)。 +- `volume_priority` — 定义填充卷的优先级(顺序)。值越低优先级越高。参数值应为自然数,并共同涵盖从 1 到 N 的范围(给定最低优先级)且不跳过任何数字。 + * 如果 _所有_ 卷都被标记,则按给定顺序优先排序。 + * 如果仅 _一些_ 卷被标记,则未标记的卷具有最低优先级,并按配置中定义的顺序优先排序。 + * 如果 _没有_ 卷被标记,则其优先级对应于其在配置中声明的顺序。 * 两个卷不能具有相同的优先级值。 配置示例: @@ -806,13 +868,11 @@ TTL d + INTERVAL 1 MONTH GROUP BY k1, k2 SET x = max(x), y = min(y); ``` -在给定示例中,`hdd_in_order` 策略实现了 [轮询调度](https://en.wikipedia.org/wiki/Round-robin_scheduling) 方法。因此,该策略仅定义一个卷(`single`),数据部分在其所有磁盘上按循环顺序存储。这种策略在系统上挂载了几个类似的磁盘但未配置 RAID 的情况下非常有用。请记住,每个单独的磁盘驱动器并不可靠,您可能希望通过复制因子为 3 或更多来进行补偿。 +在给定示例中,`hdd_in_order` 策略实现了 [轮询](https://en.wikipedia.org/wiki/Round-robin_scheduling) 方法。因此该策略仅定义一个卷(`single`),数据部分以循环顺序存储在其所有磁盘上。如果系统中挂载有几块类似的磁盘,但没有配置 RAID,则此策略会非常有用。请记住,每个单独的磁盘驱动器并不可靠,您可能希望通过复制因子为 3 或更多进行补偿。 -如果系统中可以使用不同类型的磁盘,则可以改用 `moving_from_ssd_to_hdd` 策略。卷 `hot` 包含一个SSD磁盘(`fast_ssd`),可以存储在该卷上的部分的最大大小为 1GB。所有大于 1GB 的部分将直接存储在 `cold` 卷上,该卷包含一个HDD磁盘 `disk1`。 -此外,一旦 `fast_ssd` 磁盘填满超过 80%,数据将通过后台进程转移到 `disk1`。 +如果系统中有不同类型的磁盘可用,可以使用 `moving_from_ssd_to_hdd` 策略。卷 `hot` 包含一个 SSD 磁盘(`fast_ssd`),可以存储在此卷上的部分的最大大小为 1GB。所有大于 1GB 的部分将直接存储在包含 HDD 磁盘 `disk1` 的 `cold` 卷中。此外,一旦磁盘 `fast_ssd` 被填充超过 80%,数据将通过后台进程转移到 `disk1`。 -在存储策略中卷的枚举顺序很重要,特别是在列出的至少一个卷没有明确的 `volume_priority` 参数的情况下。 -一旦一个卷填满,数据就会转移到下一个卷。磁盘的枚举顺序也很重要,因为数据按顺序存储在其上。 +在存储策略中枚举卷的顺序很重要,特别是当列出的至少一个卷没有显式的 `volume_priority` 参数时。一旦一个卷被填满,数据将转移到下一个卷。磁盘的枚举顺序也很重要,因为数据以轮流存储的方式存储在它们上面。 创建表时,可以将已配置的存储策略之一应用于该表: @@ -828,42 +888,42 @@ PARTITION BY toYYYYMM(EventDate) SETTINGS storage_policy = 'moving_from_ssd_to_hdd' ``` -`default` 存储策略意味着只使用一个卷,该卷仅包含在 ``中给出的一个磁盘。 -您可以通过 [ALTER TABLE ... MODIFY SETTING] 查询在表创建后更改存储策略,新策略应包括所有旧磁盘和相同名称的卷。 +`default` 存储策略意味着仅使用一个卷,该卷仅由 `` 中给定的一个磁盘组成。 +您可以通过 [ALTER TABLE ... MODIFY SETTING] 查询在表创建后更改存储策略,新策略应包括所有旧磁盘和具有相同名称的卷。 + +执行后台数据部分移动的线程数可以通过 [background_move_pool_size](/operations/server-configuration-parameters/settings.md/#background_move_pool_size) 设置进行更改。 -执行数据部分的后台移动的线程数可以通过 [background_move_pool_size](/operations/server-configuration-parameters/settings.md/#background_move_pool_size) 设置进行更改。 ### 详细信息 {#details} -在 `MergeTree` 表的情况下,数据以不同方式写入磁盘: +在 `MergeTree` 表的情况下,数据以不同的方式写入磁盘: - 作为插入(`INSERT` 查询)的结果。 -- 在后台合并和 [变更](https://clickhouse.com/docs/zh/sql-reference/statements/alter#mutations) 期间。 -- 当从另一个副本下载时。 +- 在后台合并和 [变更](/sql-reference/statements/alter#mutations) 期间。 +- 通过另一个副本下载。 - 作为分区冻结的结果 [ALTER TABLE ... FREEZE PARTITION](/sql-reference/statements/alter/partition#freeze-partition)。 -在这些情况下,除了变更和分区冻结外,部分是根据给定的存储策略存储在卷和磁盘中的: +在所有这些情况下,除了变更和分区冻结,部分都根据给定的存储策略存储在一个卷和一个磁盘上: + +1. 首先选择第一个具有足够磁盘空间可以存储部分(`unreserved_space > current_part_size`)并允许存储给定大小部分(`max_data_part_size_bytes > current_part_size`)的卷。 +2. 在这个卷内,选择跟上一个存储的数据块所用磁盘相邻的磁盘,并且该磁盘的可用空间大于部分大小(`unreserved_space - keep_free_space_bytes > current_part_size`)。 -1. 选择第一个(定义顺序中的)具有足够磁盘空间以存储部分的卷(`unreserved_space > current_part_size`)并允许存储给定大小的部分(`max_data_part_size_bytes > current_part_size`)。 -2. 在该卷中,选择下一个可用的磁盘,该磁盘是用于存储先前数据块的那个磁盘,并且有超过部分大小的可用空间(`unreserved_space - keep_free_space_bytes > current_part_size`)。 +在后台,变更和分区冻结利用 [硬链接](https://en.wikipedia.org/wiki/Hard_link)。不支持不同磁盘之间的硬链接,因此在这种情况下,结果部分存储在与初始部分相同的磁盘上。 -在后台,变更和分区冻结使用 [硬链接](https://en.wikipedia.org/wiki/Hard_link)。不支持不同磁盘之间的硬链接,因此在这种情况下,生成的部分存储在与初始部分相同的磁盘上。 +在后台,部分根据可用空间(`move_factor` 参数)在卷之间移动,按照卷在配置文件中的声明顺序。一些数据永远不会从最后一个卷转移到第一个卷。可以使用系统表 [system.part_log](/operations/system-tables/part_log)(字段 `type = MOVE_PART`)和 [system.parts](/operations/system-tables/parts.md)(字段 `path` 和 `disk`)来监控后台移动。此外,可以在服务器日志中找到详细信息。 -在后台,部分会根据可用空间量(`move_factor` 参数)在卷之间移动,按照配置文件中声明的卷的顺序进行。 -数据永远不会从最后一个卷传输到第一个卷。可以使用系统表 [system.part_log](/operations/system-tables/part_log)(字段 `type = MOVE_PART`)和 [system.parts](/operations/system-tables/parts.md)(字段 `path` 和 `disk`)来监控后台移动。此外,可以在服务器日志中找到详细信息。 +用户可以通过查询 [ALTER TABLE ... MOVE PART\|PARTITION ... TO VOLUME\|DISK ...](/sql-reference/statements/alter/partition) 强制将部分或分区从一个卷移动到另一个卷,同时考虑所有后台操作的限制。查询自行启动移动,不等待后台操作完成。如果可用空间不足或任何要求条件未满足,用户将收到错误消息。 -用户可以使用查询 [ALTER TABLE ... MOVE PART\|PARTITION ... TO VOLUME\|DISK ...](/sql-reference/statements/alter/partition) 强制从一个卷移动一个部分或一个分区到另一个卷,所有后台操作的限制都会被考虑。该查询会主动发起移动,而不会等待后台操作完成。如果可用空间不足或任何所需条件未得到满足,用户将收到错误消息。 +移动数据不会干扰数据复制。因此,对于同一表在不同副本中可以指定不同的存储策略。 -移动数据不会干扰数据复制。因此,可以在不同副本中为同一表指定不同的存储策略。 +在后台合并和变更完成后,旧部分仅在一定时间后被删除(`old_parts_lifetime`)。在此期间,它们不会被移动到其他卷或磁盘。因此,在部分最终被移除之前,它们仍然被计算在占用的磁盘空间评估中。 -在后台合并和变更完成后,仅在一定时间后(`old_parts_lifetime`)移除旧部分。 -在此期间,它们不会移动到其他卷或磁盘。因此,在部分最终被删除之前,它们仍会计入占有的磁盘空间评估。 +用户可以通过 [min_bytes_to_rebalance_partition_over_jbod](/operations/settings/merge-tree-settings.md/#min_bytes_to_rebalance_partition_over_jbod) 设置将新的大型部分均衡地分配到 [JBOD](https://en.wikipedia.org/wiki/Non-RAID_drive_architectures) 卷的不同磁盘上。 -用户可以使用 [min_bytes_to_rebalance_partition_over_jbod](/operations/settings/merge-tree-settings.md/#min_bytes_to_rebalance_partition_over_jbod) 设置将新的大部分分配到 [JBOD](https://en.wikipedia.org/wiki/Non-RAID_drive_architectures) 卷的不同磁盘上的均衡方式。 ## 使用外部存储进行数据存储 {#table_engine-mergetree-s3} -[MergeTree](/engines/table-engines/mergetree-family/mergetree.md) 家族表引擎可以使用类型为 `s3`、`azure_blob_storage`、`hdfs` 磁盘将数据存储到 `S3`、`AzureBlobStorage`、`HDFS`。有关更多详细信息,请参见 [配置外部存储选项](/operations/storing-data.md/#configuring-external-storage)。 +[MergeTree](/engines/table-engines/mergetree-family/mergetree.md)系列表引擎可以通过使用类型为 `s3`, `azure_blob_storage`, `hdfs` 的磁盘将数据存储到 `S3`、`AzureBlobStorage`、`HDFS`。有关更多详细信息,请参见 [配置外部存储选项](/operations/storing-data.md/#configuring-external-storage)。 -使用类型为 `s3` 的磁盘作为外部存储的 [S3](https://aws.amazon.com/s3/) 示例。 +作为使用类型为 `s3` 的外部存储的示例。 配置标记: ```xml @@ -905,30 +965,34 @@ SETTINGS storage_policy = 'moving_from_ssd_to_hdd' ``` -另见 [配置外部存储选项](/operations/storing-data.md/#configuring-external-storage)。 +另请参见 [配置外部存储选项](/operations/storing-data.md/#configuring-external-storage)。 :::note 缓存配置 -ClickHouse 版本 22.3 至 22.7 使用不同的缓存配置,如果您使用其中一个版本,请参见 [使用本地缓存](/operations/storing-data.md/#using-local-cache)。 +ClickHouse 版本 22.3 到 22.7 使用不同的缓存配置, 如果您使用的是这些版本之一,请参见 [使用本地缓存](/operations/storing-data.md/#using-local-cache)。 ::: + ## 虚拟列 {#virtual-columns} -- `_part` — 部分名称。 +- `_part` — 一部分的名称。 - `_part_index` — 查询结果中部分的顺序索引。 -- `_part_starting_offset` — 查询结果中部分的累积起始行。 +- `_part_starting_offset` — 查询结果中部分的累计起始行。 - `_part_offset` — 部分中的行号。 -- `_partition_id` — 分区名称。 +- `_part_granule_offset` — 部分中的粒度数量。 +- `_partition_id` — 分区的名称。 - `_part_uuid` — 唯一部分标识符(如果启用 MergeTree 设置 `assign_part_uuids`)。 -- `_part_data_version` — 部分的数据版本(最小块号或变更版本)。 +- `_part_data_version` — 部分的数据版本(最小区块号或变更版本)。 - `_partition_value` — `partition by` 表达式的值(元组)。 -- `_sample_factor` — 采样因子(来自查询)。 -- `_block_number` — 行的块号,当 `allow_experimental_block_number_column` 设置为 true 时,在合并时保持不变。 +- `_sample_factor` — 抽样因子(来自查询)。 +- `_block_number` — 在插入时分配给行的原始区块编号,在启用 `enable_block_number_column` 时在合并时持久化。 +- `_block_offset` — 在插入时分配给行的原始行号,在启用 `enable_block_offset_column` 时在合并时持久化。 - `_disk_name` — 用于存储的磁盘名称。 -## 列统计信息 {#column-statistics} + +## 列统计 {#column-statistics} -在启用 `set allow_experimental_statistics = 1` 时,统计信息声明在来自 `*MergeTree*` 家族的表的 `CREATE` 查询的列部分中。 +统计声明在 `*MergeTree*` 系列的 `CREATE` 查询的列部分中,当启用 `set allow_experimental_statistics = 1` 时。 ```sql CREATE TABLE tab @@ -940,62 +1004,66 @@ ENGINE = MergeTree ORDER BY a ``` -我们还可以使用 `ALTER` 语句来操作统计信息。 +我们还可以使用 `ALTER` 语句操作统计信息。 ```sql ALTER TABLE tab ADD STATISTICS b TYPE TDigest, Uniq; ALTER TABLE tab DROP STATISTICS a; ``` -这些轻量级统计信息聚合有关列中值分布的信息。统计信息存储在每个部分中,并在每次插入时更新。 -仅在我们启用 `set allow_statistics_optimize = 1` 的情况下,它们可以用于 `prewhere` 优化。 -### 可用的列统计信息类型 {#available-types-of-column-statistics} +这些轻量级统计信息聚合了列中值的分布信息。统计信息存储在每个部分中,并在每次插入时更新。 +仅当我们启用 `set allow_statistics_optimize = 1` 时,它们才能用于 prewhere 优化。 + +### 可用的列统计类型 {#available-types-of-column-statistics} - `MinMax` - 列的最小值和最大值,可用于估计数值列范围过滤器的选择性。 + 列值的最小和最大,这允许评估数值列范围过滤器的选择性。 - 语法: `minmax` + 语法:`minmax` - `TDigest` - [TDigest](https://github.com/tdunning/t-digest) 草图,可用于计算数值列的近似百分位数(例如,第 90 个百分位数)。 + [TDigest](https://github.com/tdunning/t-digest) 草图,它允许计算数值列的近似百分位数(例如第 90 个百分位数)。 - 语法: `tdigest` + 语法:`tdigest` - `Uniq` - [HyperLogLog](https://en.wikipedia.org/wiki/HyperLogLog) 草图,提供了有关列包含多少个不同值的估计。 + [HyperLogLog](https://en.wikipedia.org/wiki/HyperLogLog) 草图,提供对列中不同值数量的估计。 - 语法: `uniq` + 语法:`uniq` - `CountMin` - [CountMin](https://en.wikipedia.org/wiki/Count%E2%80%93min_sketch) 草图,提供了对每个值在列中的频率的近似计数。 + [CountMin](https://en.wikipedia.org/wiki/Count%E2%80%93min_sketch) 草图,提供对列中每个值频率的近似计数。 + + 语法:`countmin` - 语法 `countmin` ### 支持的数据类型 {#supported-data-types} -| | (U)Int*, Float*, Decimal(*), Date*, Boolean, Enum* | String or FixedString | +| | (U)Int*, Float*, Decimal(*), Date*, Boolean, Enum* | String 或 FixedString | |-----------|----------------------------------------------------|-----------------------| | CountMin | ✔ | ✔ | | MinMax | ✔ | ✗ | | TDigest | ✔ | ✗ | | Uniq | ✔ | ✔ | + ### 支持的操作 {#supported-operations} -| | 等式过滤器 (==) | 范围过滤器 (`>, >=, <, <=`) | -|-----------|-------------------|----------------------------| -| CountMin | ✔ | ✗ | -| MinMax | ✗ | ✔ | -| TDigest | ✗ | ✔ | -| Uniq | ✔ | ✗ | +| | 等于过滤器 (==) | 范围过滤器 (`>, >=, <, <=`) | +|-----------|-----------------|------------------------------| +| CountMin | ✔ | ✗ | +| MinMax | ✗ | ✔ | +| TDigest | ✗ | ✔ | +| Uniq | ✔ | ✗ | + ## 列级设置 {#column-level-settings} 某些 MergeTree 设置可以在列级别被覆盖: -- `max_compress_block_size` — 写入表之前进行压缩的最大未压缩数据块大小。 -- `min_compress_block_size` — 写入下一个标记时需要压缩的最小未压缩数据块大小。 +- `max_compress_block_size` — 在写入表之前未压缩数据块的最大大小。 +- `min_compress_block_size` — 写入下一个标记时进行压缩所需的未压缩数据块的最小大小。 示例: @@ -1009,7 +1077,7 @@ ENGINE = MergeTree ORDER BY id ``` -可以使用 [ALTER MODIFY COLUMN](/sql-reference/statements/alter/column.md) 修改或删除列级设置,例如: +列级设置可以使用 [ALTER MODIFY COLUMN](/sql-reference/statements/alter/column.md) 进行修改或移除,例如: - 从列声明中移除 `SETTINGS`: @@ -1023,7 +1091,7 @@ ALTER TABLE tab MODIFY COLUMN document REMOVE SETTINGS; ALTER TABLE tab MODIFY COLUMN document MODIFY SETTING min_compress_block_size = 8192; ``` -- 重置一个或多个设置,还会从表的 CREATE 查询的列表达式中移除设置声明。 +- 重置一个或多个设置,同时移除创建表时列表达式中的设置声明。 ```sql ALTER TABLE tab MODIFY COLUMN document RESET SETTING min_compress_block_size; diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/mergetree.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/mergetree.md.hash index 750d2c29b31..a713f3e53a8 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/mergetree.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/mergetree.md.hash @@ -1 +1 @@ -de14925709bc2c53 +d4d4a04d07b99448 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/replacingmergetree.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/replacingmergetree.md index a3d74c9f1b7..c97f7f8ce03 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/replacingmergetree.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/replacingmergetree.md @@ -1,22 +1,23 @@ --- -'description': '与 MergeTree 不同,它通过相同排序键值 (`ORDER BY` 表部分,而不是 `PRIMARY KEY`) 来移除重复条目。' +'description': '与 MergeTree 不同,它通过相同的排序键值 (`ORDER BY` 表部分,而不是 `PRIMARY KEY`) 移除重复条目。' 'sidebar_label': 'ReplacingMergeTree' 'sidebar_position': 40 'slug': '/engines/table-engines/mergetree-family/replacingmergetree' 'title': 'ReplacingMergeTree' +'doc_type': 'reference' --- # ReplacingMergeTree -该引擎与 [MergeTree](/engines/table-engines/mergetree-family/versionedcollapsingmergetree) 的不同之处在于它删除具有相同 [sorting key](../../../engines/table-engines/mergetree-family/mergetree.md) 值的重复条目(`ORDER BY` 表部分,而不是 `PRIMARY KEY`)。 +该引擎与 [MergeTree](/engines/table-engines/mergetree-family/versionedcollapsingmergetree) 的不同之处在于,它删除具有相同 [sorting key](../../../engines/table-engines/mergetree-family/mergetree.md) 值(即 `ORDER BY` 表部分,而非 `PRIMARY KEY`)的重复条目。 -数据去重仅在合并时发生。合并在背景中以未知的时间进行,因此无法进行计划。一些数据可能会保持未处理状态。尽管可以使用 `OPTIMIZE` 查询运行非计划性合并,但不要依赖它,因为 `OPTIMIZE` 查询将读取和写入大量数据。 +数据去重仅在合并期间发生。合并在后台以未知时间发生,因此无法为其规划。一些数据可能仍未处理。虽然可以使用 `OPTIMIZE` 查询运行未调度的合并,但不要依赖它,因为 `OPTIMIZE` 查询将读取和写入大量数据。 -因此,`ReplacingMergeTree` 适合在后台清除重复数据以节省空间,但不能保证不存在重复项。 +因此,`ReplacingMergeTree` 适合用于在后台清除重复数据以节省空间,但不保证不存在重复项。 :::note -有关 ReplacingMergeTree 的详细指南,包括最佳实践和如何优化性能,可以在 [这里](/guides/replacing-merge-tree) 找到。 +关于 ReplacingMergeTree 的详细指南,包括最佳实践和如何优化性能,可在 [这里](/guides/replacing-merge-tree) 获得。 ::: ## 创建表 {#creating-a-table} @@ -35,22 +36,22 @@ CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] [SETTINGS name=value, ...] ``` -有关请求参数的描述,请参阅 [statement description](../../../sql-reference/statements/create/table.md)。 +有关请求参数的描述,请参见 [statement description](../../../sql-reference/statements/create/table.md)。 :::note -行的唯一性由 `ORDER BY` 表部分确定,而不是由 `PRIMARY KEY`。 +行的唯一性由 `ORDER BY` 表部分决定,而不是 `PRIMARY KEY`。 ::: ## ReplacingMergeTree 参数 {#replacingmergetree-parameters} -### ver {#ver} +### `ver` {#ver} -`ver` — 版本号列。类型为 `UInt*`、`Date`、`DateTime` 或 `DateTime64`。可选参数。 +`ver` — 版本号列。类型为 `UInt*`,`Date`,`DateTime` 或 `DateTime64`。可选参数。 -在合并时,`ReplacingMergeTree` 会从所有具有相同排序键的行中仅保留一个: +在合并时,`ReplacingMergeTree` 会从所有具有相同排序键的行中保留仅一条: -- 如果未设置 `ver`,则选择中的最后一行。选择是一组参与合并的一组分区中的行。最近创建的分区(最后插入的)将在选择中排在最后。因此,在去重之后,对于每个唯一排序键,来自最近插入的最后一行将保留下来。 -- 如果指定了 `ver`,则保留最大版本的行。如果 `ver` 对于几行相同,则将对它们应用“如果未指定 `ver`”的规则,即保留最近插入的行。 +- 如果未设置 `ver`,则选择中最后一条。选择是一组参与合并的部分中的行。最近创建的部分(最后插入)将是选择中的最后一条。因此,去重后,对每个唯一排序键,最近插入的那一行将保留。 +- 如果指定 `ver`,则为最大版本。如果多行的 `ver` 相同,则会对它们使用“如果未指定 `ver`”的规则,即保留最新插入的行。 示例: @@ -95,22 +96,22 @@ SELECT * FROM mySecondReplacingMT FINAL; └─────┴─────────┴─────────────────────┘ ``` -### is_deleted {#is_deleted} +### `is_deleted` {#is_deleted} -`is_deleted` — 在合并过程中用于判断该行数据是否表示状态或需被删除的列名称;`1` 为“已删除”行,`0` 为“状态”行。 +`is_deleted` — 合并时用于确定该行数据是否表示状态或需要删除的列名称;`1` 表示“已删除”行,`0` 表示“状态”行。 -列数据类型 — `UInt8`。 + 列数据类型 — `UInt8`。 :::note -仅在使用 `ver` 时,可以启用 `is_deleted`。 +只有在使用 `ver` 时才能启用 `is_deleted`。 -无论对数据执行何种操作,版本应增加。如果两个插入的行具有相同的版本号,则保留最后插入的行。 +无论对数据进行什么操作,版本应该增加。如果两行插入了相同的版本号,则保留最后插入的行。 -默认情况下,即使该行是删除行,ClickHouse 也会保留某个键的最后一行。这是为了确保可以安全地插入任何未来具有较低版本的行,并且删除行仍会被应用。 +默认情况下,即使那行是删除行,ClickHouse 也会保留一个键的最后一行。这是为了确保未来版本较低的行可以安全插入,删除行仍然能够应用。 -要永久删除这些删除行,请启用表设置 `allow_experimental_replacing_merge_with_cleanup`,并执行以下任一操作: +要永久删除此类删除行,请启用表设置 `allow_experimental_replacing_merge_with_cleanup`,并且: -1. 设置表设置 `enable_replacing_merge_with_cleanup_for_min_age_to_force_merge`、`min_age_to_force_merge_on_partition_only` 和 `min_age_to_force_merge_seconds`。如果分区中的所有分区片段均超过 `min_age_to_force_merge_seconds`,ClickHouse 将将它们全部合并为一个单一的分区并移除任何删除行。 +1. 设置表设置 `enable_replacing_merge_with_cleanup_for_min_age_to_force_merge`、`min_age_to_force_merge_on_partition_only` 和 `min_age_to_force_merge_seconds`。如果分区中的所有部分都超过 `min_age_to_force_merge_seconds`,ClickHouse 将把它们合并为一个部分并删除任何删除行。 2. 手动运行 `OPTIMIZE TABLE table [PARTITION partition | PARTITION ID 'partition_id'] FINAL CLEANUP`。 ::: @@ -150,14 +151,14 @@ select * from myThirdReplacingMT final; ## 查询子句 {#query-clauses} -在创建 `ReplacingMergeTree` 表时需要与创建 `MergeTree` 表时相同的 [子句](../../../engines/table-engines/mergetree-family/mergetree.md)。 +在创建 `ReplacingMergeTree` 表时,所需的 [子句](../../../engines/table-engines/mergetree-family/mergetree.md) 与创建 `MergeTree` 表时相同。
创建表的已弃用方法 :::note -在新项目中不要使用此方法,如果可能,请将旧项目切换到上述描述的方法。 +请勿在新项目中使用此方法,并尽可能将旧项目切换到上述方法。 ::: ```sql @@ -169,17 +170,17 @@ CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] ) ENGINE [=] ReplacingMergeTree(date-column [, sampling_expression], (primary, key), index_granularity, [ver]) ``` -除 `ver` 外的所有参数在 `MergeTree` 中具有相同的含义。 +除了 `ver` 之外,所有参数的含义与 `MergeTree` 中相同。 -- `ver` - 版本列。可选参数。有关描述,请参见上述文本。 +- `ver` - 版本的列。可选参数。有关描述,请参见上面的文本。
-## 查询时间去重 & FINAL {#query-time-de-duplication--final} +## 查询时去重 & FINAL {#query-time-de-duplication--final} -在合并时,ReplacingMergeTree 识别重复行,使用 `ORDER BY` 列的值(用于创建表)作为唯一标识符,保留唯一标识符的最高版本。然而,这仅提供最终正确性 - 并不保证行会被去重,您不应依赖它。因此,查询可能会由于更新和删除行被考虑在内而产生不正确的答案。 +在合并时,ReplacingMergeTree 会识别重复行,使用 `ORDER BY` 列的值(用于创建表)作为唯一标识符,并保留最高版本。然而,这仅提供最终的正确性——它并不保证行会被去重,因此不应依赖于它。因此,查询可能会因更新和删除行被考虑在内而产生不正确的答案。 -为了获得正确的答案,用户需要在后台合并的基础上补充查询时间的去重和删除。这可以使用 `FINAL` 操作符来实现。例如,考虑以下示例: +要获得正确答案,用户需要将后台合并与查询时去重和删除移除相结合。这可以使用 `FINAL` 操作符来实现。例如,考虑以下示例: ```sql CREATE TABLE rmt_example @@ -194,7 +195,7 @@ FROM numbers(1000000000) 0 rows in set. Elapsed: 19.958 sec. Processed 1.00 billion rows, 8.00 GB (50.11 million rows/s., 400.84 MB/s.) ``` -不使用 `FINAL` 的查询产生不正确的计数(确切结果将根据合并而有所不同): +不带 `FINAL` 的查询产生不正确的计数(确切结果将根据合并情况而有所不同): ```sql SELECT count() @@ -207,7 +208,7 @@ FROM rmt_example 1 row in set. Elapsed: 0.002 sec. ``` -添加 `FINAL` 产生正确的结果: +添加 `FINAL` 产生正确结果: ```sql SELECT count() @@ -221,4 +222,4 @@ FINAL 1 row in set. Elapsed: 0.002 sec. ``` -有关 `FINAL` 的进一步详细信息,包括如何优化 `FINAL` 性能,我们建议您阅读我们的 [关于 ReplacingMergeTree 的详细指南](/guides/replacing-merge-tree)。 +有关 `FINAL` 的更多详细信息,包括如何优化 `FINAL` 性能,我们建议阅读我们的 [详细指南:ReplacingMergeTree](/guides/replacing-merge-tree)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/replacingmergetree.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/replacingmergetree.md.hash index 7f3c32704fa..59ddbdb6379 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/replacingmergetree.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/replacingmergetree.md.hash @@ -1 +1 @@ -3078d73052bb3c76 +e5eb4831d3aca9a8 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/replication.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/replication.md index 69dbe7e9c38..b88348e8c78 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/replication.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/replication.md @@ -1,22 +1,22 @@ --- -'description': 'ClickHouse 中数据复制概述' +'description': 'ClickHouse 中的数据复制概述' 'sidebar_label': '数据复制' 'sidebar_position': 20 'slug': '/engines/table-engines/mergetree-family/replication' 'title': '数据复制' +'doc_type': 'reference' --- # 数据复制 :::note -在 ClickHouse Cloud 中,复制由系统为您管理。请在创建表时不要添加参数。例如,您可以将以下文本中的: +在 ClickHouse Cloud 中,复制由系统自动管理。请在创建表时不添加任何参数。例如,在下面的文本中,请将: ```sql ENGINE = ReplicatedMergeTree( '/clickhouse/tables/{shard}/table_name', - '{replica}', - ver + '{replica}' ) ``` @@ -37,24 +37,24 @@ ENGINE = ReplicatedMergeTree - ReplicatedVersionedCollapsingMergeTree - ReplicatedGraphiteMergeTree -复制在单个表级别上工作,而非整个服务器。一个服务器可以同时存储复制和非复制的表。 +复制在单个表级别上工作,而不是整个服务器。一个服务器可以同时存储复制和非复制表。 复制不依赖于分片。每个分片都有自己独立的复制。 -`INSERT` 和 `ALTER` 查询的压缩数据会被复制(有关更多信息,请参见 [ALTER](/sql-reference/statements/alter) 文档)。 +对于 `INSERT` 和 `ALTER` 查询,已压缩的数据会被复制(更多信息,请参阅 [ALTER](/sql-reference/statements/alter) 的文档)。 -`CREATE`、`DROP`、`ATTACH`、`DETACH` 和 `RENAME` 查询仅在单台服务器上执行,并且不被复制: +`CREATE`、`DROP`、`ATTACH`、`DETACH` 和 `RENAME` 查询在单个服务器上执行,并且不被复制: -- `CREATE TABLE` 查询在执行该查询的服务器上创建一个新的可复制表。如果该表在其他服务器上已经存在,则会添加一个新的副本。 -- `DROP TABLE` 查询删除位于执行该查询的服务器上的副本。 -- `RENAME` 查询在某个副本上重命名该表。换句话说,复制表在不同副本上可以有不同的名称。 +- `CREATE TABLE` 查询在执行查询的服务器上创建一个新的可复制表。如果该表在其他服务器上已经存在,它将添加一个新的副本。 +- `DROP TABLE` 查询删除位于执行查询的服务器上的副本。 +- `RENAME` 查询重命名一个副本上的表。换句话说,复制表在不同副本上可以有不同的名称。 -ClickHouse 使用 [ClickHouse Keeper](/guides/sre/keeper/index.md) 存储副本元信息。可以使用 ZooKeeper 版本 3.4.5 或更新版本,但推荐使用 ClickHouse Keeper。 +ClickHouse 使用 [ClickHouse Keeper](/guides/sre/keeper/index.md) 存储副本的元信息。可以使用 ZooKeeper 版本 3.4.5 或更高版本,但建议使用 ClickHouse Keeper。 -要使用复制,请在 [zookeeper](/operations/server-configuration-parameters/settings#zookeeper) 服务器配置部分设置参数。 +要使用复制,请在 [zookeeper](/operations/server-configuration-parameters/settings#zookeeper) 服务器配置部分中设置参数。 :::note -不要忽视安全设置。ClickHouse 支持 ZooKeeper 安全子系统的 `digest` [ACL 方案](https://zookeeper.apache.org/doc/current/zookeeperProgrammers.html#sc_ZooKeeperAccessControl)。 +请勿忽视安全设置。ClickHouse 支持 ZooKeeper 安全子系统的 `digest` [ACL 方案](https://zookeeper.apache.org/doc/current/zookeeperProgrammers.html#sc_ZooKeeperAccessControl)。 ::: 设置 ClickHouse Keeper 集群地址的示例: @@ -76,7 +76,7 @@ ClickHouse 使用 [ClickHouse Keeper](/guides/sre/keeper/index.md) 存储副本 ``` -ClickHouse 还支持在辅助 ZooKeeper 集群中存储副本元信息。通过提供 ZooKeeper 集群名称和路径作为引擎参数来实现。 +ClickHouse 还支持在辅助 ZooKeeper 集群中存储副本的元信息。通过提供 ZooKeeper 集群名称和路径作为引擎参数来实现。 换句话说,它支持在不同的 ZooKeeper 集群中存储不同表的元数据。 设置辅助 ZooKeeper 集群地址的示例: @@ -106,70 +106,55 @@ ClickHouse 还支持在辅助 ZooKeeper 集群中存储副本元信息。通过 ``` -要将表元数据存储在辅助 ZooKeeper 集群中而非默认 ZooKeeper 集群,我们可以使用 SQL 创建具有 -ReplicatedMergeTree 引擎的表,如下所示: +要在辅助 ZooKeeper 集群中存储表的元数据,而不是默认的 ZooKeeper 集群,我们可以使用 SQL 创建具有 ReplicatedMergeTree 引擎的表,如下所示: ```sql CREATE TABLE table_name ( ... ) ENGINE = ReplicatedMergeTree('zookeeper_name_configured_in_auxiliary_zookeepers:path', 'replica_name') ... ``` -您可以指定任何现有的 ZooKeeper 集群,系统将使用该目录来存储自己的数据(该目录在创建可复制表时指定)。 +您可以指定任何现有的 ZooKeeper 集群,系统将使用该目录中的数据(在创建可复制表时指定目录)。 -如果配置文件中没有设置 ZooKeeper,则无法创建复制表,任何现有的复制表将为只读。 +如果配置文件中未设置 ZooKeeper,则无法创建复制表,任何现有的复制表将为只读。 -在 `SELECT` 查询中不会使用 ZooKeeper,因为复制不会影响 `SELECT` 的性能,并且查询的运行速度与非复制表一样快。当查询分布式复制表时,ClickHouse 的行为通过设置 [max_replica_delay_for_distributed_queries](/operations/settings/settings.md/#max_replica_delay_for_distributed_queries) 和 [fallback_to_stale_replicas_for_distributed_queries](/operations/settings/settings.md/#fallback_to_stale_replicas_for_distributed_queries) 进行控制。 +ZooKeeper 不用于 `SELECT` 查询,因为复制不会影响 `SELECT` 的性能,查询的速度与非复制表一样快。在查询分布式复制表时,ClickHouse 的行为受设置 [max_replica_delay_for_distributed_queries](/operations/settings/settings.md/#max_replica_delay_for_distributed_queries) 和 [fallback_to_stale_replicas_for_distributed_queries](/operations/settings/settings.md/#fallback_to_stale_replicas_for_distributed_queries) 的控制。 -对于每个 `INSERT` 查询,大约会通过几次事务向 ZooKeeper 添加十个条目。(更确切地说,这是针对每个插入的数据块;一个 INSERT 查询包含一个数据块或每 `max_insert_block_size = 1048576` 行一个数据块。)这导致相比于非复制表,`INSERT` 的延迟略长。但是,如果您遵循每秒不超过一次 `INSERT` 的建议,便不会产生任何问题。用于协调一个 ZooKeeper 集群的整个 ClickHouse 集群的 `INSERTs` 每秒总数为几百。数据插入的吞吐量(每秒行数)与非复制数据一样高。 +对于每个 `INSERT` 查询,约有十个条目通过多个事务添加到 ZooKeeper。(更准确地说,这是对于每个插入的数据块;一个 INSERT 查询包含一个数据块或每 `max_insert_block_size = 1048576` 行一个块。)这导致与非复制表相比,`INSERT` 的延迟稍长。但是,如果您遵循建议以每秒不超过一个 `INSERT` 的批量插入数据,就不会造成任何问题。协调一个 ZooKeeper 集群的整个 ClickHouse 集群每秒总共会有几百个 `INSERTs`。数据插入的吞吐量(每秒的行数)和非复制数据一样高。 -对于非常大的集群,您可以为不同的分片使用不同的 ZooKeeper 集群。然而,根据我们在大约 300 台服务器的生产集群中的经验,这似乎并不必要。 +对于非常大的集群,您可以为不同的分片使用不同的 ZooKeeper 集群。然而,根据我们的经验,在大约 300 个服务器的生产集群中,这并没有被证明是必要的。 -复制是异步的,多主的。`INSERT` 查询(以及 `ALTER`)可以发送到任何可用的服务器。数据是在执行查询的服务器上进行插入,然后复制到其他服务器。由于它是异步的,最近插入的数据会以某种延迟出现在其他副本上。如果部分副本不可用,数据将在它们变得可用时写入。如果有一个副本可用,延迟是传输压缩数据块所需的时间。执行复制表的后台任务的线程数量可以通过设置 [background_schedule_pool_size](/operations/server-configuration-parameters/settings.md/#background_schedule_pool_size) 来设定。 +复制是异步和多主的。`INSERT` 查询(以及 `ALTER`)可以发送给任何可用的服务器。数据在执行查询的服务器上插入,然后复制到其他服务器。由于它是异步的,最近插入的数据会有一些延迟地出现在其他副本上。如果部分副本不可用,数据将在它们变为可用时写入。如果一台副本可用,则延迟是通过网络传输压缩数据块所需的时间。执行复制表的后台任务的线程数可以通过 [background_schedule_pool_size](/operations/server-configuration-parameters/settings.md/#background_schedule_pool_size) 设置进行调整。 -`ReplicatedMergeTree` 引擎使用一个单独的线程池来执行复制提取。线程池的大小由设置 [background_fetches_pool_size](/operations/server-configuration-parameters/settings#background_fetches_pool_size) 限制,可以通过服务器重启进行调整。 +`ReplicatedMergeTree` 引擎使用单独的线程池来进行复制提取。池的大小由 [background_fetches_pool_size](/operations/server-configuration-parameters/settings#background_fetches_pool_size) 设置限制,可以通过服务器重启进行调整。 -默认情况下,INSERT 查询只等待来自一个副本的写入确认。如果数据只成功写入一个副本,而该副本所在的服务器停止存在,则存储的数据将丢失。要启用从多个副本获取数据写入确认,请使用 `insert_quorum` 选项。 +默认情况下,INSERT 查询仅等待来自一个副本的写入数据确认。如果数据仅成功写入一个副本,并且该副本所在的服务器停止存在,则存储的数据将丢失。要启用从多个副本获取数据写入确认,请使用 `insert_quorum` 选项。 -每个数据块都是原子性写入的。INSERT 查询被分为最多 `max_insert_block_size = 1048576` 行的块。换句话说,如果 `INSERT` 查询的行数少于 1048576 行,它将被原子性地处理。 +每个数据块以原子方式写入。INSERT 查询被分为最多 `max_insert_block_size = 1048576` 行的块。换句话说,如果 INSERT 查询的行数少于 1048576,则它以原子方式进行。 -数据块是去重的。对于多次写入相同数据块(相同大小的数据块包含相同顺序的相同行),该块只会写入一次。原因是在网络故障的情况下,客户端应用程序无法知道数据是否已写入数据库,因此 `INSERT` 查询可以简单地重复执行。数据发送到哪个副本是无关紧要的,`INSERT` 操作是幂等的。去重参数通过 [merge_tree](/operations/server-configuration-parameters/settings.md/#merge_tree) 服务器设置进行控制。 +数据块是去重的。对于多次写入相同的数据块(含有相同大小且按照相同顺序包含相同行的数据块),该块仅写入一次。这是因为在网络故障的情况下,客户端应用程序无法确定数据是否已写入数据库,因此可以简单地重复 INSERT 查询。无论发送到哪个副本,INSERTs 都是幂等的。去重参数由 [merge_tree](/operations/server-configuration-parameters/settings.md/#merge_tree) 服务器设置控制。 -在复制过程中,只有要插入的源数据通过网络传输。进一步的数据转换(合并)在所有副本上以相同方式协调并执行。这最小化了网络使用,这意味着在不同的数据中心之间进行复制时效果良好。(请注意,在不同数据中心中重复数据是复制的主要目标。) +在复制过程中,仅源数据会通过网络传输。进一步的数据转换(合并)会在所有副本上以相同的方式协调和执行。这最小化了网络使用,这意味着当副本位于不同数据中心时,复制运行良好。(请注意,在不同数据中心复制数据是复制的主要目标。) -您可以拥有任何数量的相同数据的副本。根据我们的经验,相对可靠且方便的解决方案是在生产环境中使用双重复制,每台服务器使用 RAID-5 或 RAID-6(在某些情况下使用 RAID-10)。 +您可以拥有相同数据的任意数量的副本。根据我们的经验,比较可靠和方便的解决方案是在生产中使用双重复制,每个服务器使用 RAID-5 或 RAID-6(在某些情况下使用 RAID-10)。 -该系统监控副本上的数据同步,并能够在故障后恢复。故障转移是自动的(对于较小的数据差异)或半自动的(当数据差异过大,可能指示配置错误时)。 +系统监控副本上的数据同步性,并在发生故障后能够恢复。故障转移是自动的(对于轻微的数据差异)或半自动的(当数据差异过大时,可能表示配置错误)。 ## 创建复制表 {#creating-replicated-tables} :::note -在 ClickHouse Cloud 中,复制由系统为您管理。请在创建表时不要添加参数。例如,您将以下文本中的: -```sql -ENGINE = ReplicatedMergeTree('/clickhouse/tables/{shard}/table_name', '{replica}', ver) -``` -替换为: -```sql -ENGINE = ReplicatedMergeTree -``` -::: +在 ClickHouse Cloud 中,复制会自动处理。 -在表引擎名称前加上 `Replicated` 前缀。例如:`ReplicatedMergeTree`。 +使用 [`MergeTree`](/engines/table-engines/mergetree-family/mergetree) 创建表时无需复制参数。系统会内部将 [`MergeTree`](/engines/table-engines/mergetree-family/mergetree) 重写为 [`SharedMergeTree`](/cloud/reference/shared-merge-tree) 以进行复制和数据分配。 + +避免使用 `ReplicatedMergeTree` 或指定复制参数,因为复制由平台管理。 -:::tip -在 ClickHouse Cloud 中添加 `Replicated` 是可选的,因为所有表都是复制的。 ::: ### Replicated\*MergeTree 参数 {#replicatedmergetree-parameters} -#### zoo_path {#zoo_path} - -`zoo_path` — ClickHouse Keeper 中表的路径。 - -#### replica_name {#replica_name} - -`replica_name` — ClickHouse Keeper 中的副本名称。 - -#### other_parameters {#other_parameters} - -`other_parameters` — 用于创建复制版本的引擎参数,例如,`ReplacingMergeTree` 中的版本。 +| 参数 | 描述 | +|-----------------|---------------------------------------------------------------------------| +| `zoo_path` | ClickHouse Keeper 中表的路径。 | +| `replica_name` | ClickHouse Keeper 中的副本名称。 | +| `other_parameters` | 用于创建复制版本的引擎参数,例如 ReplacingMergeTree 中的版本。 | 示例: @@ -188,7 +173,7 @@ SAMPLE BY intHash32(UserID);
-旧语法的示例 +过时语法示例 ```sql CREATE TABLE table_name @@ -201,7 +186,7 @@ CREATE TABLE table_name
-如例所示,这些参数可以包含大括号中的替换。替换的值取自配置文件的 [macros](/operations/server-configuration-parameters/settings.md/#macros) 部分。 +如示例所示,这些参数可以包含花括号中的替换。替换的值来自配置文件的 [macros](/operations/server-configuration-parameters/settings.md/#macros) 部分。 示例: @@ -212,24 +197,24 @@ CREATE TABLE table_name ``` -ClickHouse Keeper 中表的路径对于每个复制表应该是唯一的。不同分片上的表应该有不同的路径。 -在此情况下,路径由以下部分组成: +ClickHouse Keeper 中的表路径对于每个复制表应是唯一的。不同分片上的表应具有不同路径。 +在这种情况下,路径由以下部分组成: -`/clickhouse/tables/` 是公共前缀。我们建议使用这个前缀。 +`/clickhouse/tables/` 是公用前缀。我们建议使用这个。 -`{shard}` 会扩展为分片标识符。 +`{shard}` 将展开为分片标识符。 -`table_name` 是 ClickHouse Keeper 中表的节点名称。最好与表名相同。它是显式定义的,因为与表名不同,它在执行 RENAME 查询后不会更改。 -*提示*:您也可以在 `table_name` 前添加数据库名称。例如:`db_name.table_name` +`table_name` 是 ClickHouse Keeper 中表的节点名称。最好将其设为与表名相同。它是显式定义的,因为与表名不同,它在 RENAME 查询后不会变化。 +*提示*: 您还可以在 `table_name` 前添加数据库名称。例如 `db_name.table_name`。 -两个内置替换 `{database}` 和 `{table}` 可以使用,它们分别扩展为表名和数据库名(除非在 `macros` 部分定义了这些宏)。因此 ZooKeeper 路径可以指定为 `'/clickhouse/tables/{shard}/{database}/{table}'`。 -在使用这些内置替换时,请小心表重命名。ClickHouse Keeper 中的路径无法更改,当表被重命名时,宏将扩展为不同的路径,表将引用 ClickHouse Keeper 中不存在的路径,并进入只读模式。 +两个内置替换 `{database}` 和 `{table}` 可以使用,它们分别展开为表名和数据库名(除非在 `macros` 部分中定义了这些宏)。因此可以将 ZooKeeper 路径指定为 `'/clickhouse/tables/{shard}/{database}/{table}'`。 +在使用这些内置替换时,请注意表名的重命名。ClickHouse Keeper 中的路径无法更改,当表被重命名时,宏将扩展为不同的路径,该表将指向一个在 ClickHouse Keeper 中不存在的路径,并进入只读模式。 -副本名称标识同一表的不同副本。您可以使用服务器名称来标识,如例中所示。名称仅需在每个分片内唯一。 +副本名称标识同一表的不同副本。您可以使用服务器名称作为此名称,如示例所示。该名称仅需在每个分片内是唯一的。 -您可以显式定义参数,而不是使用替换。这在测试和配置小集群时可能是方便的。然而,这种情况下您无法使用分布式 DDL 查询( `ON CLUSTER`)。 +您可以显式定义参数,而不是使用替换。这可能对测试和配置小集群很方便。但是,在这种情况下,您不能使用分布式 DDL 查询(`ON CLUSTER`)。 -在处理大型集群时,我们建议使用替换,因为它们减少了出错的可能性。 +在处理大型集群时,我们建议使用替换,因为它减少了错误的可能性。 您可以在服务器配置文件中为 `Replicated` 表引擎指定默认参数。例如: @@ -247,7 +232,7 @@ CREATE TABLE table_name ( ORDER BY x; ``` -这等同于: +它的等效形式为: ```sql CREATE TABLE table_name ( @@ -256,29 +241,29 @@ CREATE TABLE table_name ( ORDER BY x; ``` -在每个副本上运行 `CREATE TABLE` 查询。此查询创建一个新的复制表,或向现有表添加新的副本。 +在每个副本上运行 `CREATE TABLE` 查询。此查询创建一个新的复制表,或将新副本添加到已有副本中。 -如果在其他副本上表已经包含一些数据后添加新的副本,查询运行后数据将从其他副本复制到新副本。换句话说,新副本与其他副本同步。 +如果在表已在其他副本上包含一些数据后添加新副本,数据将从其他副本复制到新副本中。换句话说,新副本与其他副本同步。 -要删除一个副本,请运行 `DROP TABLE`。但是,只有运行该查询的服务器上的一个副本会被删除。 +要删除一个副本,运行 `DROP TABLE`。但是,仅删除一个副本 - 位于您运行查询的服务器上的那个。 -## 故障后的恢复 {#recovery-after-failures} +## 发生故障后的恢复 {#recovery-after-failures} -如果 ClickHouse Keeper 在服务器启动时不可用,复制表将切换到只读模式。系统会定期尝试连接 ClickHouse Keeper。 +如果 ClickHouse Keeper 在服务器启动时不可用,则复制表切换到只读模式。系统会定期尝试连接到 ClickHouse Keeper。 -如果在 `INSERT` 期间 ClickHouse Keeper 不可用,或与 ClickHouse Keeper 交互时发生错误,则会抛出异常。 +如果 ClickHouse Keeper 在 `INSERT` 期间不可用或在与 ClickHouse Keeper 交互时发生错误,将抛出异常。 -连接到 ClickHouse Keeper 后,系统检查本地文件系统中的数据集是否与预期数据集匹配(ClickHouse Keeper 存储此信息)。如果存在小的不一致,系统会通过与副本同步数据来解决它们。 +连接到 ClickHouse Keeper 后,系统检查本地文件系统中的数据集是否与预期的数据集匹配(ClickHouse Keeper 存储此信息)。如果存在轻微的不一致,系统会通过与副本同步数据来解决它们。 -如果系统检测到损坏的数据部分(文件大小不正确)或未识别的部分(写入文件系统但未记录在 ClickHouse Keeper 中的部分),它会将它们移动到 `detached` 子目录(不会被删除)。任何缺失的部分将从副本复制。 +如果系统发现数据部分损坏(文件大小错误)或未识别部分(写入到文件系统但未在 ClickHouse Keeper 中记录的部分),则将它们移动到 `detached` 子目录(它们不会被删除)。任何缺失的部分将从副本中复制。 请注意,ClickHouse 不会执行任何破坏性操作,例如自动删除大量数据。 -当服务器启动(或与 ClickHouse Keeper 建立新会话)时,它只检查所有文件的数量和大小。如果文件大小匹配,但字节在中间某处被更改,这不会立即被检测到,而仅在尝试读取 `SELECT` 查询的数据时才检测到。查询会抛出关于不匹配的校验和或压缩块大小的异常。在这种情况下,数据部分将被添加到验证队列,必要时将从副本中复制。 +当服务器启动(或与 ClickHouse Keeper 建立新会话)时,仅检查所有文件的数量和大小。如果文件大小匹配但某些字节在中间被更改,则不会立即检测到,而是在尝试读取 `SELECT` 查询的数据时检测到。该查询抛出一个关于不匹配的校验和或压缩块大小的异常。在这种情况下,数据部分被添加到验证队列中,并在必要时从副本中复制。 -如果本地数据集与预期数据集之间的差异过大,则会触发安全机制。服务器将此记录在日志中并拒绝启动。发生这种情况的原因可能是配置错误,比如某个分片上的副本被意外配置为另一个分片上的副本。然而,该机制的阈值设置得相当低,这种情况可能发生在正常的故障恢复过程中。在这种情况下,数据会半自动恢复 - 通过“按下按钮”。 +如果本地数据集与预期集的差异过大,则会触发安全机制。服务器在日志中记录并拒绝启动。原因是该情况可能指示配置错误,例如,如果分片上的副本意外配置为与另一分片上的副本相同。但是,这种机制的阈值设置得很低,这种情况可能在正常故障恢复时发生。在这种情况下,数据是半自动恢复的 - 通过“按下按钮”。 -要开始恢复,在 ClickHouse Keeper 中创建节点 `/path_to_table/replica_name/flags/force_restore_data`,内容可以是任意的,或者运行命令恢复所有复制表: +要开始恢复,请在 ClickHouse Keeper 中创建节点 `/path_to_table/replica_name/flags/force_restore_data`,内容可以是任何内容,或运行命令以恢复所有复制表: ```bash sudo -u clickhouse touch /var/lib/clickhouse/flags/force_restore_data @@ -288,67 +273,67 @@ sudo -u clickhouse touch /var/lib/clickhouse/flags/force_restore_data ## 完全数据丢失后的恢复 {#recovery-after-complete-data-loss} -如果某个服务器上的所有数据和元数据消失,请按照以下步骤进行恢复: +如果一台服务器上的所有数据和元数据消失,请按照以下步骤进行恢复: -1. 在该服务器上安装 ClickHouse。如果使用替换,请在配置文件中正确定义替换,这些配置文件应包含分片标识符和副本。 -2. 如果您有未复制的表需要手动复制到服务器上,请从副本复制其数据(目录 `/var/lib/clickhouse/data/db_name/table_name/` 中)。 -3. 从副本复制位于 `/var/lib/clickhouse/metadata/` 中的表定义。如果在表定义中显式定义了分片或副本标识符,请进行更正,以使其与此副本对应。(或者,启动服务器并执行所有应在 `/var/lib/clickhouse/metadata/` 中的 .sql 文件中的 `ATTACH TABLE` 查询。) -4. 要开始恢复,在 ClickHouse Keeper 中创建节点 `/path_to_table/replica_name/flags/force_restore_data`,内容可以是任意的,或者运行命令恢复所有复制表:`sudo -u clickhouse touch /var/lib/clickhouse/flags/force_restore_data` +1. 在该服务器上安装 ClickHouse。正确定义包含分片标识符和副本的配置文件中的替换(如果使用它们)。 +2. 如果您有未复制的表必须在服务器上手动复制,请从副本中复制它们的数据(在目录 `/var/lib/clickhouse/data/db_name/table_name/` 中)。 +3. 从副本中复制位于 `/var/lib/clickhouse/metadata/` 中的表定义。如果在表定义中显式定义了分片或副本标识符,请更正以使其与该副本相对应。(或者,启动服务器,并进行所有应该在 `/var/lib/clickhouse/metadata/` 中的 .sql 文件中的 `ATTACH TABLE` 查询。) +4. 要开始恢复,在 ClickHouse Keeper 中创建节点 `/path_to_table/replica_name/flags/force_restore_data`,内容可以是任何内容,或运行命令以恢复所有复制表: `sudo -u clickhouse touch /var/lib/clickhouse/flags/force_restore_data` -然后启动服务器(如果已经在运行,则重新启动)。数据将从副本下载。 +然后启动服务器(如果已在运行,则重启)。数据将从副本下载。 -另一种恢复选项是从 ClickHouse Keeper 删除关于丢失副本的信息(`/path_to_table/replica_name`),然后如 "[创建复制表](#creating-replicated-tables)" 中所述重新创建副本。 +另一种恢复选项是在 ClickHouse Keeper 中删除丢失副本的信息(`/path_to_table/replica_name`),然后按照 "[创建复制表](#creating-replicated-tables)" 中的描述重新创建副本。 -在恢复过程中没有网络带宽限制。如果您同时恢复多个副本,请记住这一点。 +在恢复期间没有网络带宽限制。请记住,如果您一次恢复许多副本。 ## 从 MergeTree 转换为 ReplicatedMergeTree {#converting-from-mergetree-to-replicatedmergetree} -我们使用术语 `MergeTree` 来指代所有 `MergeTree 家族` 中的表引擎,和 `ReplicatedMergeTree` 一样。 +我们使用术语 `MergeTree` 来指代 `MergeTree family` 中的所有表引擎,与 `ReplicatedMergeTree` 一样。 -如果您有一个手动复制的 `MergeTree` 表,可以将其转换为复制表。如果您在 `MergeTree` 表中已经收集了大量数据,现在想要启用复制,您可能需要这样做。 +如果您以前有一个手动复制的 `MergeTree` 表,可以将其转换为复制表。如果您已经在 `MergeTree` 表中收集了大量数据,现在想启用复制,则可能需要这样做。 -[ATTACH TABLE ... AS REPLICATED](/sql-reference/statements/attach.md#attach-mergetree-table-as-replicatedmergetree) 语句允许将分离的 `MergeTree` 表附加为 `ReplicatedMergeTree`。 +[ATTACH TABLE ... AS REPLICATED](/sql-reference/statements/attach.md#attach-mergetree-table-as-replicatedmergetree) 语句允许将脱离的 `MergeTree` 表附加为 `ReplicatedMergeTree`。 -如果表的数据目录中设置了 `convert_to_replicated` 标志,则 `MergeTree` 表可以在服务器重启时自动转换(`/store/xxx/xxxyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy/` 中适用于 `Atomic` 数据库)。 -创建空的 `convert_to_replicated` 文件,表将在下次服务器重启时以复制表的形式加载。 +如果在表的数据目录中设置了 `convert_to_replicated` 标志,则 `MergeTree` 表可以在服务器重启时自动转换(`/store/xxx/xxxyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy/` 对于 `Atomic` 数据库)。 +创建空的 `convert_to_replicated` 文件,表将在下次服务器重启时以复制方式加载。 -此查询可用于获取表的数据路径。如果表有多个数据路径,您必须使用第一个。 +可以使用此查询获取表的数据路径。如果表有多个数据路径,则必须使用第一个路径。 ```sql SELECT data_paths FROM system.tables WHERE table = 'table_name' AND database = 'database_name'; ``` -请注意,ReplicatedMergeTree 表将使用 `default_replica_path` 和 `default_replica_name` 设置的值进行创建。 -要在其他副本上创建转换表,您需要在 `ReplicatedMergeTree` 引擎的第一个参数中明确指定其路径。可以使用以下查询获取其路径。 +请注意,ReplicatedMergeTree 表将使用 `default_replica_path` 和 `default_replica_name` 设置的值创建。 +要在其他副本上创建转换后的表,您需要在 `ReplicatedMergeTree` 引擎的第一个参数中显式指定其路径。可以使用以下查询获取其路径。 ```sql SELECT zookeeper_path FROM system.replicas WHERE table = 'table_name'; ``` -还有一种手动方法来实现此操作。 +还有一种手动的方法。 -如果不同副本上的数据不同,首先同步数据,或者在除了一个副本之外的所有副本上删除该数据。 +如果不同副本上的数据不同,请先同步它,或在所有副本上删除该数据,除了一个。 -重命名现有的 MergeTree 表,然后创建一个具有旧名称的 `ReplicatedMergeTree` 表。 -将旧表的数据移动到新表数据目录中的 `detached` 子目录(`/var/lib/clickhouse/data/db_name/table_name/`)。 -然后在其中一个副本上运行 `ALTER TABLE ATTACH PARTITION` 以将这些数据部分添加到工作集中。 +重命名现有的 MergeTree 表,然后使用旧名称创建一个 `ReplicatedMergeTree` 表。 +将数据从旧表移动到新表数据目录中的 `detached` 子目录(`/var/lib/clickhouse/data/db_name/table_name/`)。 +然后在其中一个副本上运行 `ALTER TABLE ATTACH PARTITION` 将这些数据部分添加到工作集。 ## 从 ReplicatedMergeTree 转换为 MergeTree {#converting-from-replicatedmergetree-to-mergetree} -使用 [ATTACH TABLE ... AS NOT REPLICATED](/sql-reference/statements/attach.md#attach-mergetree-table-as-replicatedmergetree) 语句在单个服务器上附加分离的 `ReplicatedMergeTree` 表为 `MergeTree`。 +使用 [ATTACH TABLE ... AS NOT REPLICATED](/sql-reference/statements/attach.md#attach-mergetree-table-as-replicatedmergetree) 语句将脱离的 `ReplicatedMergeTree` 表附加为单个服务器上的 `MergeTree`。 -另一种方法涉及服务器重启。创建一个不同名称的 MergeTree 表。将 `ReplicatedMergeTree` 表数据目录中的所有数据移动到新表的数据目录中。然后删除 `ReplicatedMergeTree` 表并重启服务器。 +另一种方法涉及服务器重启。创建一个具有不同名称的 MergeTree 表。将所有数据从 `ReplicatedMergeTree` 表数据目录移动到新表的数据目录中。然后删除 `ReplicatedMergeTree` 表并重启服务器。 -如果您想要在不启动服务器的情况下摆脱 `ReplicatedMergeTree` 表: +如果您想在不启动服务器的情况下删除 `ReplicatedMergeTree` 表: -- 删除元数据目录(`/var/lib/clickhouse/metadata/`)中对应的 `.sql` 文件。 -- 删除 ClickHouse Keeper 中对应的路径(`/path_to_table/replica_name`)。 +- 删除元数据目录(`/var/lib/clickhouse/metadata/`)中的相应 `.sql` 文件。 +- 删除 ClickHouse Keeper 中的相应路径(`/path_to_table/replica_name`)。 -完成后,您可以启动服务器,创建一个 `MergeTree` 表,将数据移至其目录,然后重启服务器。 +在此之后,您可以启动服务器,创建一个 `MergeTree` 表,将数据移动到其目录中,然后重启服务器。 -## 当 ClickHouse Keeper 集群中的元数据丢失或损坏时的恢复 {#recovery-when-metadata-in-the-zookeeper-cluster-is-lost-or-damaged} +## 在 ClickHouse Keeper 集群中元数据丢失或损坏时的恢复 {#recovery-when-metadata-in-the-zookeeper-cluster-is-lost-or-damaged} -如果 ClickHouse Keeper 中的数据丢失或损坏,您可以按上述所述将数据转移到未复制的表中以保存数据。 +如果 ClickHouse Keeper 中的数据丢失或损坏,可以通过将其移动到如上所述的未复制表中来保存数据。 **另请参见** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/replication.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/replication.md.hash index 7084fbb16c8..8fd8bd283e6 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/replication.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/replication.md.hash @@ -1 +1 @@ -9cf4fb14e2039070 +f918a5bc4d026513 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/summingmergetree.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/summingmergetree.md index 79890889052..d219f05088c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/summingmergetree.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/summingmergetree.md @@ -1,17 +1,18 @@ --- -'description': 'SummingMergeTree 继承自 MergeTree 引擎。它的关键特性是在分区片段合并时自动对数值数据进行求和。' +'description': 'SummingMergeTree 继承自 MergeTree 引擎。它的主要特点是在分区合并期间自动对数值数据进行求和。' 'sidebar_label': 'SummingMergeTree' 'sidebar_position': 50 'slug': '/engines/table-engines/mergetree-family/summingmergetree' 'title': 'SummingMergeTree' +'doc_type': 'reference' --- # SummingMergeTree -该引擎继承自 [MergeTree](/engines/table-engines/mergetree-family/versionedcollapsingmergetree)。其区别在于,当合并 `SummingMergeTree` 表的数据部分时,ClickHouse 会用一行替换所有具有相同主键(更准确地说,是具有相同 [排序键](../../../engines/table-engines/mergetree-family/mergetree.md))的行,该行包含具有数字数据类型的列的总和。如果排序键的构成方式使得单个键值对应于大量行,这将显著减少存储量并加快数据选择。 +该引擎继承自 [MergeTree](/engines/table-engines/mergetree-family/versionedcollapsingmergetree)。不同之处在于,在合并 `SummingMergeTree` 表的数据部分时,ClickHouse 会用一行包含数值列的汇总值替换所有具有相同主键(更准确地说,是相同的 [排序键](../../../engines/table-engines/mergetree-family/mergetree.md))的行。如果排序键的构成方式使得单个键值对应大量行,这将显著减少存储量并加快数据选择速度。 -我们建议将该引擎与 `MergeTree` 一起使用。在 `MergeTree` 表中存储完整数据,并使用 `SummingMergeTree` 存储聚合数据,例如,在准备报告时。这种方法将防止由于主键构成不正确而丢失宝贵数据。 +我们建议将该引擎与 `MergeTree` 一起使用。在 `MergeTree` 表中存储完整数据,并使用 `SummingMergeTree` 存储聚合数据,例如,在准备报告时。这样的做法将防止由于主键构成不当而导致宝贵数据的丢失。 ## 创建表 {#creating-a-table} @@ -30,14 +31,14 @@ CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] 有关请求参数的描述,请参见 [请求描述](../../../sql-reference/statements/create/table.md)。 -### SummingMergeTree 的参数 {#parameters-of-summingmergetree} +### SummingMergeTree 参数 {#parameters-of-summingmergetree} -#### columns {#columns} +#### 列 {#columns} -`columns` - 一个元组,其中包含将被求和的列的名称。可选参数。 - 这些列必须为数字类型,并且不能在分区或排序键中。 +`columns` - 一个元组,包含将被汇总的列名。可选参数。 +这些列必须是数值类型,且不得在分区或排序键中。 - 如果未指定 `columns`,ClickHouse 将总结所有不在排序键中的数字类型的列的值。 +如果未指定 `columns`,ClickHouse 会汇总所有不在排序键中的数值类型列的值。 ### 查询子句 {#query-clauses} @@ -45,10 +46,10 @@ CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster]
-创建表的弃用方法 +创建表的过时方法 :::note -在新项目中请勿使用此方法,并且如果可能,请将旧项目切换到上述描述的方法。 +在新项目中请勿使用此方法,并尽可能将旧项目切换到上述描述的方法。 ::: ```sql @@ -60,9 +61,9 @@ CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] ) ENGINE [=] SummingMergeTree(date-column [, sampling_expression], (primary, key), index_granularity, [columns]) ``` -除 `columns` 外,所有参数的含义与 `MergeTree` 中相同。 +除 `columns` 之外的所有参数与 `MergeTree` 中的含义相同。 -- `columns` — 一个元组,包含将被求和的列的名称。可选参数。有关描述,请参见上述文本。 +- `columns` — 包含将被汇总的列名的元组。可选参数。有关描述,请参见上面的文本。
@@ -83,10 +84,10 @@ ORDER BY key 向其中插入数据: ```sql -INSERT INTO summtt Values(1,1),(1,2),(2,1) +INSERT INTO summtt VALUES(1,1),(1,2),(2,1) ``` -ClickHouse 可能不会完全汇总所有行([见下文](#data-processing)),因此我们在查询中使用聚合函数 `sum` 和 `GROUP BY` 子句。 +ClickHouse 可能不会完全对所有行进行求和([见下文](#data-processing)),因此在查询中我们使用聚合函数 `sum` 和 `GROUP BY` 子句。 ```sql SELECT key, sum(value) FROM summtt GROUP BY key @@ -101,34 +102,34 @@ SELECT key, sum(value) FROM summtt GROUP BY key ## 数据处理 {#data-processing} -当数据插入表中时,它们被原样保存。ClickHouse 定期合并插入的数据部分,此时具有相同主键的行被求和并被替换为每个结果数据部分的一行。 +当数据插入到表中时,它们将按原样保存。ClickHouse 定期合并插入的数据部分,此时具有相同主键的行会被求和并用每个结果数据部分的一行替换。 -ClickHouse 可能合并数据部分,因此不同的结果数据部分可以包含具有相同主键的行,即汇总可能是不完整的。因此,在查询中应使用聚合函数 [sum()](/sql-reference/aggregate-functions/reference/sum) 和 `GROUP BY` 子句,如上面的示例所述。 +ClickHouse 可以合并数据部分,因此不同的结果数据部分可以包含相同主键的行,即求和会不完整。因此,在查询中应该使用聚合函数 [sum()](/sql-reference/aggregate-functions/reference/sum) 和 `GROUP BY` 子句,如上例所示。 -### 汇总的通用规则 {#common-rules-for-summation} +### 求和的通用规则 {#common-rules-for-summation} -具有数字数据类型的列中的值会被求和。列的集合由参数 `columns` 定义。 +具有数值数据类型的列中的值会被求和。列的集合由参数 `columns` 定义。 -如果所有列的汇总值为 0,则该行将被删除。 +如果在求和的所有列中的值均为 0,则行将被删除。 -如果列不在主键中且不被求和,则从现有值中选择任意一个值。 +如果某列不在主键中且未被求和,则从现有值中选择一个任意值。 -对于主键中的列,不会进行求和。 +主键中的列的值不进行求和。 -### 聚合函数列中的求和 {#the-summation-in-the-aggregatefunction-columns} +### AggregateFunction 列中的求和 {#the-summation-in-the-aggregatefunction-columns} -对于 [AggregateFunction 类型](../../../sql-reference/data-types/aggregatefunction.md) 的列,ClickHouse 的行为与 [AggregatingMergeTree](../../../engines/table-engines/mergetree-family/aggregatingmergetree.md) 引擎一致,依据函数执行聚合。 +对于 [AggregateFunction 类型](../../../sql-reference/data-types/aggregatefunction.md) 的列,ClickHouse 的行为类似于 [AggregatingMergeTree](../../../engines/table-engines/mergetree-family/aggregatingmergetree.md) 引擎,根据函数进行聚合。 ### 嵌套结构 {#nested-structures} -表可以具有以特殊方式处理的嵌套数据结构。 +表可以具有特殊处理的嵌套数据结构。 -如果嵌套表的名称以 `Map` 结尾,并且它至少包含两个符合以下标准的列: +如果嵌套表的名称以 `Map` 结尾,并且它至少包含两列,且满足以下条件: -- 第一列是数字 `(*Int*, Date, DateTime)` 或字符串 `(String, FixedString)`,称为 `key`, -- 其他列为算术 `(*Int*, Float32/64)`,称为 `(values...)`, +- 第一列为数值型 `(*Int*, Date, DateTime)` 或字符串类型 `(String, FixedString)`,我们称之为 `key`, +- 其他列为算术型 `(*Int*, Float32/64)`,我们称之为 `(values...)`, -那么该嵌套表被解释为 `key => (values...)` 的映射,当合并其行时,两个数据集的元素通过 `key` 合并,并对相应的 `(values...)` 进行求和。 +则该嵌套表被解释为 `key => (values...)` 的映射,在合并其行时,两个数据集的元素按 `key` 进行合并,并求和对应的 `(values...)`。 示例: @@ -186,9 +187,9 @@ ARRAY JOIN └──────┴─────────┴─────────────┴────────┘ ``` -请求数据时,使用 [sumMap(key, value)](../../../sql-reference/aggregate-functions/reference/summap.md) 函数进行 `Map` 的聚合。 +请求数据时,使用 [sumMap(key, value)](../../../sql-reference/aggregate-functions/reference/summap.md) 函数对 `Map` 进行聚合。 -对于嵌套数据结构,您不需要在求和的列元组中指定其列。 +对于嵌套数据结构,您无需在汇总列的元组中指定其列。 ## 相关内容 {#related-content} diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/summingmergetree.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/summingmergetree.md.hash index 9ba120e0520..5fa5a15473f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/summingmergetree.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/summingmergetree.md.hash @@ -1 +1 @@ -2904a5302d63a1c8 +9ca45c6416f0d12e diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/versionedcollapsingmergetree.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/versionedcollapsingmergetree.md index 37308ef37e3..014b51847da 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/versionedcollapsingmergetree.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/versionedcollapsingmergetree.md @@ -1,9 +1,10 @@ --- -'description': '允许快速写入状态不断变化的对象,并在后台删除旧的对象状态。' +'description': '允许快速写入不断变化的对象状态,并在后台删除旧的对象状态。' 'sidebar_label': 'VersionedCollapsingMergeTree' 'sidebar_position': 80 'slug': '/engines/table-engines/mergetree-family/versionedcollapsingmergetree' 'title': 'VersionedCollapsingMergeTree' +'doc_type': 'reference' --- @@ -11,12 +12,12 @@ 该引擎: -- 允许快速写入状态不断变化的对象。 +- 允许快速写入持续变化的对象状态。 - 在后台删除旧对象状态。这显著减少了存储量。 -有关详细信息,请参见[Collapsing](#table_engines_versionedcollapsingmergetree)部分。 +有关更多详细信息,请参见[Collapsing](#table_engines_versionedcollapsingmergetree)部分。 -该引擎继承自[MergeTree](/engines/table-engines/mergetree-family/versionedcollapsingmergetree),并向合并数据部分的算法中添加了合并行的逻辑。`VersionedCollapsingMergeTree`的目的与[CollapsingMergeTree](../../../engines/table-engines/mergetree-family/collapsingmergetree.md)相同,但使用了不同的合并算法,允许在多个线程中以任意顺序插入数据。特别是,`Version`列有助于正确合并行,即使它们以错误的顺序插入。相比之下,`CollapsingMergeTree`只允许严格连续的插入。 +该引擎继承自[MergeTree](/engines/table-engines/mergetree-family/versionedcollapsingmergetree),并为合并数据部分的算法添加了行合并的逻辑。`VersionedCollapsingMergeTree`的目的与[CollapsingMergeTree](../../../engines/table-engines/mergetree-family/collapsingmergetree.md)相同,但使用不同的合并算法,使得可以在任意顺序中使用多个线程插入数据。尤其是,`Version`列可以帮助正确合并行,即使它们以错误的顺序插入。相比之下,`CollapsingMergeTree`只允许严格连续的插入。 ## 创建表 {#creating-a-table} @@ -33,7 +34,7 @@ CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] [SETTINGS name=value, ...] ``` -有关查询参数的说明,请参见[查询描述](../../../sql-reference/statements/create/table.md)。 +有关查询参数的描述,请参见[查询描述](../../../sql-reference/statements/create/table.md)。 ### 引擎参数 {#engine-parameters} @@ -41,21 +42,21 @@ CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] VersionedCollapsingMergeTree(sign, version) ``` -| 参数 | 描述 | 类型 | -|-----------|----------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `sign` | 行类型列的名称:`1`是“状态”行,`-1`是“取消”行。 | [`Int8`](/sql-reference/data-types/int-uint) | -| `version` | 对象状态的版本列的名称。 | [`Int*`](/sql-reference/data-types/int-uint), [`UInt*`](/sql-reference/data-types/int-uint), [`Date`](/sql-reference/data-types/date), [`Date32`](/sql-reference/data-types/date32), [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) | +| 参数 | 描述 | 类型 | +|-----------|-------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `sign` | 包含行类型的列名:`1`是“状态”行,`-1`是“取消”行。 | [`Int8`](/sql-reference/data-types/int-uint) | +| `version` | 包含对象状态版本的列名。 | [`Int*`](/sql-reference/data-types/int-uint), [`UInt*`](/sql-reference/data-types/int-uint), [`Date`](/sql-reference/data-types/date), [`Date32`](/sql-reference/data-types/date32), [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) | ### 查询子句 {#query-clauses} -创建`VersionedCollapsingMergeTree`表时,所需的[子句](../../../engines/table-engines/mergetree-family/mergetree.md)与创建`MergeTree`表时相同。 +创建`VersionedCollapsingMergeTree`表时,与创建`MergeTree`表时所需的[子句](../../../engines/table-engines/mergetree-family/mergetree.md)相同。
-创建表的弃用方法 +创建表的过时方法 :::note -在新项目中请勿使用此方法。如果可能,请将旧项目切换到上述描述的方法。 +请勿在新项目中使用此方法。如有可能,请将旧项目切换到上述描述的方法。 ::: ```sql @@ -67,13 +68,13 @@ CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] ) ENGINE [=] VersionedCollapsingMergeTree(date-column [, samp#table_engines_versionedcollapsingmergetreeling_expression], (primary, key), index_granularity, sign, version) ``` -除`sign`和`version`外,所有参数在`MergeTree`中的含义相同。 +除`sign`和`version`外,所有参数与`MergeTree`中的含义相同。 -- `sign` — 行类型列的名称:`1`是“状态”行,`-1`是“取消”行。 +- `sign` — 包含行类型的列名:`1`是“状态”行,`-1`是“取消”行。 列数据类型 — `Int8`。 -- `version` — 对象状态的版本列的名称。 +- `version` — 包含对象状态版本的列名。 列数据类型应为`UInt*`。 @@ -83,11 +84,11 @@ CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] ### 数据 {#data} -考虑需要为某个对象保存不断变化的数据的情况。为一个对象保留一行并在发生变化时更新该行是合理的。然而,对于数据库管理系统来说,更新操作是昂贵且缓慢的,因为它需要在存储中重写数据。如果需要快速写入数据,则更新不可接受,但您可以按顺序写入对象的更改,如下所示。 +考虑一种情况,您需要保存某个对象的持续变化的数据。合理的做法是为一个对象保留一行,并在发生更改时更新该行。然而,对于DBMS来说,更新操作成本高且缓慢,因为它需要在存储中重写数据。如果需要快速写入数据,则不可接受更新,但可以按顺序写入对象的更改,如下所示。 -在写入行时使用`Sign`列。如果`Sign = 1`,则表示该行是对象的状态(我们称之为“状态行”)。如果`Sign = -1`,则表示取消具有相同属性的对象状态(我们称之为“取消行”)。还要使用`Version`列,该列应为每个对象状态标识一个单独的编号。 +在写入行时使用`Sign`列。如果`Sign = 1`,这意味着该行是对象的状态(我们称之为“状态”行)。如果`Sign = -1`,则表示取消具有相同属性的对象状态(我们称之为“取消”行)。还使用`Version`列,该列应为每个对象的状态标识唯一的数字。 -例如,我们想计算用户在某个网站上访问了多少页面以及他们在那里待了多长时间。在某个时间点上,我们写入以下用户活动状态的行: +例如,我们希望计算用户在某个网站上访问了多少页面以及他们在上面待了多长时间。在某个时刻,我们写入表示用户活动状态的如下行: ```text ┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ @@ -95,7 +96,7 @@ CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] └─────────────────────┴───────────┴──────────┴──────┴─────────┘ ``` -在稍后的某个时刻,我们注册用户活动的变化并用以下两行写入它。 +稍后,我们记录用户活动的变化并写入以下两行。 ```text ┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ @@ -104,11 +105,11 @@ CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] └─────────────────────┴───────────┴──────────┴──────┴─────────┘ ``` -第一行取消了对象(用户)的先前状态。它应复制取消状态的所有字段,除了`Sign`。 +第一行取消了对象(用户)的上一个状态。它应复制所有被取消状态的字段,除了`Sign`。 第二行包含当前状态。 -因为我们只需要用户活动的最后状态,可以删除 +由于我们只需要用户活动的最后状态,因此可以删除行 ```text ┌──────────────UserID─┬─PageViews─┬─Duration─┬─Sign─┬─Version─┐ @@ -117,31 +118,31 @@ CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] └─────────────────────┴───────────┴──────────┴──────┴─────────┘ ``` -来合并对象的无效(旧)状态。`VersionedCollapsingMergeTree`在合并数据部分时执行此操作。 +,合并对象的无效(旧)状态。`VersionedCollapsingMergeTree`在合并数据部分时执行此操作。 -要了解为什么每次更改需要两行,请参见[算法](#table_engines-versionedcollapsingmergetree-algorithm)。 +要了解为什么我们需要每次变化两行,请参见[算法](#table_engines-versionedcollapsingmergetree-algorithm)。 **使用注意事项** -1. 写入数据的程序应该记住对象的状态,以便能够取消它。“取消”字符串应包含主键字段和“状态”字符串版本的副本,以及相反的`Sign`。这会增加存储的初始大小,但允许快速写入数据。 -2. 列中较长的增长数组会因写入负载而降低引擎的效率。数据越简单,效率越高。 -3. `SELECT`结果在很大程度上取决于对象状态变化历史的一致性。准备插入数据时要准确。使用不一致的数据可能会得到不可预测的结果,例如非负指标的负值,如会话深度。 +1. 写入数据的程序应记住对象的状态,以便能够取消它。“取消”字符串应包含主键字段的副本和“状态”字符串的版本以及相反的`Sign`。这增加了初始存储的大小,但允许快速写入数据。 +2. 列中长而增长的数组会因写入负载而降低引擎的效率。数据越简单,效率越好。 +3. `SELECT`结果强烈依赖于对象更改历史的一致性。在准备插入数据时请保持准确性。使用不一致的数据可能会导致不可预测的结果,例如,对于会话深度等非负指标的负值。 ### 算法 {#table_engines-versionedcollapsingmergetree-algorithm} -当ClickHouse合并数据部分时,它删除每对具有相同主键和版本但不同`Sign`的行。行的顺序无关紧要。 +当ClickHouse合并数据部分时,它会删除每一对具有相同主键和版本且`Sign`不同的行。行的顺序无关紧要。 -当ClickHouse插入数据时,它按主键对行进行排序。如果`Version`列不包含在主键中,ClickHouse会隐式地将其添加到主键中,作为最后一个字段并用于排序。 +当ClickHouse插入数据时,它会根据主键对行进行排序。如果`Version`列不在主键中,ClickHouse会将其隐式添加到主键作为最后一个字段,并使用它进行排序。 ## 选择数据 {#selecting-data} -ClickHouse不保证所有具有相同主键的行将在相同的结果数据部分中,甚至在同一物理服务器上。这对于写入数据和随后合并数据部分都是如此。此外,ClickHouse使用多个线程处理`SELECT`查询,并且无法预测结果中行的顺序。这意味着如果需要从`VersionedCollapsingMergeTree`表中获取完全“合并”的数据,则需要进行聚合。 +ClickHouse不保证具有相同主键的所有行将位于同一个结果数据部分中,甚至同一物理服务器上。这对于写入数据和随后合并数据部分都是如此。此外,ClickHouse使用多个线程处理`SELECT`查询,无法预测结果中的行顺序。这意味着,如果需要从`VersionedCollapsingMergeTree`表中获取完全“合并”的数据,则需要进行聚合。 -要完成合并,请编写带有`GROUP BY`子句和考虑`sign`的聚合函数的查询。例如,要计算数量,请使用`sum(Sign)`而不是`count()`。要计算某些内容的总和,请使用`sum(Sign * x)`而不是`sum(x)`,并添加`HAVING sum(Sign) > 0`。 +为了最终合并,请写入包含`GROUP BY`子句和考虑到符号的聚合函数的查询。例如,要计算数量,请使用`sum(Sign)`而不是`count()`。要计算某个值的总和,请使用`sum(Sign * x)`而不是`sum(x)`,并添加`HAVING sum(Sign) > 0`。 -聚合函数`count`、`sum`和`avg`可以通过这种方式计算。如果对象至少有一个未合并的状态,则可以计算聚合函数`uniq`。聚合函数`min`和`max`无法计算,因为`VersionedCollapsingMergeTree`不保存合并状态的值的历史记录。 +聚合`count`、`sum`和`avg`可以以这种方式计算。如果对象至少有一个未合并的状态,则可以计算聚合`uniq`。聚合`min`和`max`无法计算,因为`VersionedCollapsingMergeTree`不保存合并状态的值历史。 -如果需要提取带有“合并”但不需要聚合的数据(例如,检查是否存在符合某些条件的行的最新值),可以在`FROM`子句中使用`FINAL`修饰符。这种方法效率低下,不应与大表一起使用。 +如果您需要提取带有“合并”但不进行聚合的数据(例如,检查最新值是否匹配某些条件的行是否存在),可以对`FROM`子句使用`FINAL`修饰符。这种方法效率低下,不应与大表一起使用。 ## 使用示例 {#example-of-use} @@ -180,7 +181,7 @@ INSERT INTO UAct VALUES (4324182021466249494, 5, 146, 1, 1) INSERT INTO UAct VALUES (4324182021466249494, 5, 146, -1, 1),(4324182021466249494, 6, 185, 1, 2) ``` -我们使用两个`INSERT`查询创建两个不同的数据部分。如果我们使用单个查询插入数据,ClickHouse将创建一个数据部分,并且永远不会进行任何合并。 +我们使用两个`INSERT`查询创建两个不同的数据部分。如果我们通过单个查询插入数据,ClickHouse将创建一个数据部分,并且永远不会执行任何合并。 获取数据: @@ -198,9 +199,9 @@ SELECT * FROM UAct └─────────────────────┴───────────┴──────────┴──────┴─────────┘ ``` -我们在这里看到什么,合并的部分在哪里? -我们使用两个`INSERT`查询创建了两个数据部分。`SELECT`查询在两个线程中执行,结果是行的随机顺序。 -合并没有发生,因为数据部分还没有合并。ClickHouse在无法预测的时间点合并数据部分。 +我们在这里看到什么,合并部分在哪里? +我们通过两个`INSERT`查询创建了两个数据部分。`SELECT`查询在两个线程中执行,结果是行的随机顺序。 +合并未发生,因为数据部分尚未合并。ClickHouse在我们无法预测的时间点合并数据部分。 这就是我们需要聚合的原因: @@ -221,7 +222,7 @@ HAVING sum(Sign) > 0 └─────────────────────┴───────────┴──────────┴─────────┘ ``` -如果我们不需要聚合并希望强制合并,可以在`FROM`子句中使用`FINAL`修饰符。 +如果我们不需要聚合并想强制合并,可以对`FROM`子句使用`FINAL`修饰符。 ```sql SELECT * FROM UAct FINAL @@ -233,4 +234,4 @@ SELECT * FROM UAct FINAL └─────────────────────┴───────────┴──────────┴──────┴─────────┘ ``` -这是一种非常低效的选择数据的方法。不要将其用于大表。 +这是一种选择数据的非常低效的方法。请勿在大表上使用它。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/versionedcollapsingmergetree.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/versionedcollapsingmergetree.md.hash index 581481e1989..3e91ba141b2 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/versionedcollapsingmergetree.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/mergetree-family/versionedcollapsingmergetree.md.hash @@ -1 +1 @@ -5295374ac77f9b8a +367d046bef720a98 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/alias.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/alias.md new file mode 100644 index 00000000000..03c6864e8fb --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/alias.md @@ -0,0 +1,55 @@ +--- +'description': '创建一个表的别名。' +'sidebar_label': 'Alias' +'sidebar_position': 120 +'slug': '/en/engines/table-engines/special/alias' +'title': '别名表引擎' +'doc_type': 'reference' +--- + + +# Alias 表引擎 + +Alias 表引擎是指向另一个表的引用。 + +## 在 ClickHouse 服务器中的用法 {#usage-in-clickhouse-server} + +```sql +ENGINE = Alias(database_name.table_name) +-- or +ENGINE = Alias(database_name, table_name) +-- or +ENGINE = Alias(UUID) +``` + +- `database_name` 和 `table_name` 参数指定了数据库和被引用表的名称。 +- `UUID` 参数指定了被引用表的 UUID。 + +Alias 表禁止定义表模式,因为它应该始终与引用表相同。 + +## 示例 {#example} + +**1.** 创建 `ref_table` 表以及作为 `ref_table` 别名的 `alias_table` 表: + +```sql +create table ref_table (id UInt32, name String) Engine=MergeTree order by id; +create table alias_table Engine=Alias(default.ref_table); +create table alias_table_with_uuid Engine=Alias('5a39dc94-7b13-432a-b96e-b92cb12957d3'); +``` + +**2.** 向 `ref_table` 或 `alias_table` 插入数据: + +```sql +insert into ref_table values (1, 'one'), (2, 'two'), (3, 'three'); +insert into alias_table values (4, 'four'); +``` + +**3.** 查询数据: + +```sql +select * from alias_table order by id; +``` + +## 实现细节 {#details-of-implementation} + +对 `Alias` 存储的操作将被导向其引用表。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/alias.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/alias.md.hash new file mode 100644 index 00000000000..64f62739f7b --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/alias.md.hash @@ -0,0 +1 @@ +531ed2ddaf4fad3f diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/buffer.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/buffer.md index 5b8b20dd746..4a665dbf54b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/buffer.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/buffer.md @@ -1,67 +1,68 @@ --- -'description': '将数据缓冲到RAM中,定期刷新到另一个表。在读取操作期间,数据同时从缓冲区和另一个表中读取。' +'description': '将数据缓冲到 RAM 中,定期刷新到另一个表。在读取操作期间,数据同时从缓冲区和另一个表中读取。' 'sidebar_label': 'Buffer' 'sidebar_position': 120 'slug': '/engines/table-engines/special/buffer' -'title': '缓冲表引擎' +'title': 'Buffer 表引擎' +'doc_type': 'reference' --- -# Buffer Table Engine +# Buffer 表引擎 -将数据缓冲到 RAM 中,并定期将其刷新到另一张表。在读取操作期间,数据从缓冲区和其他表同时读取。 +将要写入的数据缓冲到 RAM,定期刷新到另一个表。在读取操作期间,数据同时从缓冲区和其他表中读取。 :::note -建议使用 Buffer Table Engine 的替代方案是启用 [asynchronous inserts](/guides/best-practices/asyncinserts.md)。 +推荐使用的 Buffer 表引擎替代方案是启用 [异步插入](/guides/best-practices/asyncinserts.md)。 ::: ```sql Buffer(database, table, num_layers, min_time, max_time, min_rows, max_rows, min_bytes, max_bytes [,flush_time [,flush_rows [,flush_bytes]]]) ``` -### Engine parameters: {#engine-parameters} +### 引擎参数 {#engine-parameters} -#### database {#database} +#### `database` {#database} -`database` – 数据库名称。您可以使用 `currentDatabase()` 或其他返回字符串的常量表达式。 +`database` – 数据库名称。你可以使用 `currentDatabase()` 或者其他返回字符串的常量表达式。 -#### table {#table} +#### `table` {#table} -`table` – 要刷新数据的表。 +`table` – 刷新数据的表。 -#### num_layers {#num_layers} +#### `num_layers` {#num_layers} -`num_layers` – 并行层。table 将物理上表示为 `num_layers` 个独立的缓冲区。 +`num_layers` – 并行层。物理上,表将被表示为 `num_layers` 个独立的缓冲区。 -#### min_time, max_time, min_rows, max_rows, min_bytes, and max_bytes {#min_time-max_time-min_rows-max_rows-min_bytes-and-max_bytes} +#### `min_time`, `max_time`, `min_rows`, `max_rows`, `min_bytes`, 和 `max_bytes` {#min_time-max_time-min_rows-max_rows-min_bytes-and-max_bytes} -从缓冲区刷新数据的条件。 +刷新数据的条件。 -### Optional engine parameters: {#optional-engine-parameters} +### 可选引擎参数 {#optional-engine-parameters} -#### flush_time, flush_rows, and flush_bytes {#flush_time-flush_rows-and-flush_bytes} +#### `flush_time`, `flush_rows`, 和 `flush_bytes` {#flush_time-flush_rows-and-flush_bytes} -在后台刷新数据的条件(省略或为零表示没有 `flush*` 参数)。 +在后台刷新数据的条件(省略或零表示没有 `flush*` 参数)。 -如果满足所有的 `min*` 条件或至少一个 `max*` 条件,则从缓冲区刷新数据并写入目标表。 +当满足所有 `min*` 条件或至少一个 `max*` 条件时,数据将从缓冲区刷新并写入目标表。 -此外,如果满足至少一个 `flush*` 条件,则在后台启动刷新。这与 `max*` 不同,因为 `flush*` 允许您单独配置后台刷新,以避免对 Buffer 表的 `INSERT` 查询增加延迟。 +此外,如果满足至少一个 `flush*` 条件,将在后台发起刷新。这与 `max*` 的区别在于,`flush*` 允许你单独配置后台刷新,以避免为 Buffer 表的 `INSERT` 查询增加延迟。 -#### min_time, max_time, and flush_time {#min_time-max_time-and-flush_time} +#### `min_time`, `max_time`, 和 `flush_time` {#min_time-max_time-and-flush_time} -从首次写入缓冲区时起的秒数的条件。 +自第一次写入缓冲区以来的时间条件(以秒为单位)。 -#### min_rows, max_rows, and flush_rows {#min_rows-max_rows-and-flush_rows} +#### `min_rows`, `max_rows`, 和 `flush_rows` {#min_rows-max_rows-and-flush_rows} -缓冲区中行数的条件。 +缓冲区内行数的条件。 -#### min_bytes, max_bytes, and flush_bytes {#min_bytes-max_bytes-and-flush_bytes} +#### `min_bytes`, `max_bytes`, 和 `flush_bytes` {#min_bytes-max_bytes-and-flush_bytes} -缓冲区中字节数的条件。 +缓冲区内字节数的条件。 -在写入操作期间,数据会插入到一个或多个随机的缓冲区(用 `num_layers` 配置)。或者,如果要插入的数据部分足够大(大于 `max_rows` 或 `max_bytes`),则会直接写入目标表,跳过缓冲区。 +在写入操作期间,数据将插入到一个或多个随机缓冲区(使用 `num_layers` 配置)。或者,如果要插入的数据部分足够大(大于 `max_rows` 或 `max_bytes`),它将直接写入目标表,跳过缓冲区。 -刷新数据的条件是单独为每个 `num_layers` 缓冲区计算的。例如,如果 `num_layers = 16` 且 `max_bytes = 100000000`,则最大内存占用为 1.6 GB。 +刷新数据的条件会为每个 `num_layers` 缓冲区单独计算。例如,如果 `num_layers = 16` 且 `max_bytes = 100000000`,则最大 RAM 消耗为 1.6 GB。 示例: @@ -69,42 +70,42 @@ Buffer(database, table, num_layers, min_time, max_time, min_rows, max_rows, min_ CREATE TABLE merge.hits_buffer AS merge.hits ENGINE = Buffer(merge, hits, 1, 10, 100, 10000, 1000000, 10000000, 100000000) ``` -创建一个 `merge.hits_buffer` 表,具有与 `merge.hits` 相同的结构并使用 Buffer 引擎。当写入此表时,数据在 RAM 中缓冲,随后写入 'merge.hits' 表。当满足以下任一条件时,单个缓冲区被创建并刷新数据: -- 自上次刷新以来已过去 100 秒(`max_time`)或 -- 已写入 100 万行(`max_rows`)或 -- 已写入 100 MB 的数据(`max_bytes`)或 -- 自上次刷新以来已过去 10 秒(`min_time`)并且已写入 10,000 行(`min_rows`)和 10 MB(`min_bytes`)的数据 +创建一个与 `merge.hits` 结构相同的 `merge.hits_buffer` 表,并使用 Buffer 引擎。当写入此表时,数据被缓冲到 RAM 中,随后写入 'merge.hits' 表中。当满足以下任一条件时,将创建一个单独的缓冲区并进行刷新: +- 自上次刷新以来已经过 100 秒(`max_time`),或 +- 已写入 100 万行(`max_rows`),或 +- 已写入 100 MB 数据(`max_bytes`),或 +- 已经过 10 秒(`min_time`),并且已写入 10,000 行(`min_rows`)和 10 MB(`min_bytes`)的数据。 -例如,如果只写入了一行数据,经过 100 秒后,将会刷新,不论如何。但如果写入了许多行数据,则数据将更早刷新。 +例如,如果仅写入了一行,经过 100 秒后将刷新,无论如何。但如果写入了许多行,数据将更早被刷新。 -当服务器停止或执行 `DROP TABLE` 或 `DETACH TABLE` 时,缓冲的数据也会刷新到目标表。 +当服务器停止时,使用 `DROP TABLE` 或 `DETACH TABLE` 命令,缓冲的数据也将刷新到目标表中。 -您可以在单引号中设置为空字符串作为数据库和表名。这表示没有目标表。在这种情况下,当达到数据刷新条件时,缓冲区将被简单清空。这在保持内存中数据的窗口时可能会很有用。 +你可以用单引号表示的空字符串设置数据库和表名。这表示没有目标表。在这种情况下,当达到数据刷新条件时,缓冲区将简单清空。这可能对于在内存中保持数据窗口很有用。 -从 Buffer 表读取数据时,数据同时来自缓冲区和目标表(如果存在)。 -请注意,Buffer 表不支持索引。换句话说,缓冲区中的数据会被完全扫描,这对于大型缓冲区可能会很慢。(对于从属表中的数据,将使用其支持的索引。) +从 Buffer 表读取时,数据是同时从缓冲区和目标表(如果存在的话)处理的。 +请注意,Buffer 表不支持索引。换句话说,缓冲区中的数据将被完全扫描,对于大型缓冲区可能会变得很慢。(对于从属表中的数据,将使用它支持的索引。) -如果 Buffer 表中的列集与从属表中的列集不匹配,则会插入存在于两个表中的列的子集。 +如果 Buffer 表中的列集合与从属表的列集合不匹配,则只插入两个表中都存在的列的子集。 -如果 Buffer 表中的某列与从属表中的类型不匹配,服务器日志中将记录一条错误消息,且缓冲区将被清空。 -如果在刷新缓冲区时从属表不存在,也会发生相同的情况。 +如果 Buffer 表与从属表中某列的类型不匹配,服务器日志中将记录错误消息,并且将清空缓冲区。 +如果缓冲区刷新时从属表不存在,也会发生相同的情况。 :::note -在 2021 年 10 月 26 日之前发布的版本上对 Buffer 表运行 ALTER 将导致 `Block structure mismatch` 错误(请参见 [#15117](https://github.com/ClickHouse/ClickHouse/issues/15117) 和 [#30565](https://github.com/ClickHouse/ClickHouse/pull/30565)),因此删除 Buffer 表并重新创建是唯一的选择。在尝试对 Buffer 表运行 ALTER 之前,请检查您的版本是否修复了此错误。 +在 2021 年 10 月 26 日之前发布的版本上对 Buffer 表运行 ALTER 会导致 `Block structure mismatch` 错误(见 [#15117](https://github.com/ClickHouse/ClickHouse/issues/15117) 和 [#30565](https://github.com/ClickHouse/ClickHouse/pull/30565)),因此删除 Buffer 表然后重新创建是唯一的选项。在尝试对 Buffer 表运行 ALTER 之前,请检查该错误在你的版本中是否已修复。 ::: -如果服务器异常重启,缓冲区中的数据将丢失。 +如果服务器异常重启,缓冲区中的数据将会丢失。 -`FINAL` 和 `SAMPLE` 对于 Buffer 表无法正常工作。这些条件会传递给目标表,但未用于处理缓冲区中的数据。如果需要这些功能,建议仅将 Buffer 表用于写入,同时从目标表读取。 +对于 Buffer 表,`FINAL` 和 `SAMPLE` 的工作并不正确。这些条件会传递到目标表,但不会用于缓冲区中数据的处理。如果需要这些特性,建议仅将 Buffer 表用于写入,同时从目标表中读取。 -在向 Buffer 表添加数据时,锁定其中一个缓冲区。如果同时执行从表读取操作,将导致延迟。 +在向 Buffer 表添加数据时,其中一个缓冲区会被锁定。这会导致如果同时从表中执行读取操作时出现延迟。 -插入到 Buffer 表中的数据可能会在从属表中以不同的顺序和不同的块出现。因此,正确使用 Buffer 表写入 CollapsingMergeTree 会变得困难。为避免问题,可以将 `num_layers` 设置为 1。 +插入到 Buffer 表的数据可能会以不同的顺序和不同的块进入从属表。因此,Buffer 表在向 CollapsingMergeTree 正确写入时使用起来比较困难。为避免问题,可以将 `num_layers` 设置为 1。 -如果目标表是副本,则在写入 Buffer 表时会失去一些副本表的预期特性。行的随机顺序变化和数据部分大小导致数据去重停止工作,这意味着在副本表中无法实现可靠的“精确一次”写入。 +如果目标表是复制的,在向 Buffer 表写入时会失去某些复制表的预期特性。行的随机顺序变化和数据部分的大小变化导致数据去重停止工作,这意味着在复制表中无法进行可靠的“恰好一次”写入。 -由于这些缺点,我们仅建议在少数情况下使用 Buffer 表。 +由于这些缺点,我们只建议在少数情况下使用 Buffer 表。 -当从大量服务器在单位时间内接收到过多的 INSERT 时,会使用 Buffer 表,而且数据在插入之前不能缓冲,这意味着 INSERT 速度无法足够快。 +当在单位时间内从大量服务器接收过多的 INSERT 时,Buffer 表会被使用,此时数据无法在插入之前进行缓冲,导致 INSERT 速度无法足够快。 -请注意,逐行插入数据没有意义,即便是对于 Buffer 表。这只会产生每秒几千行的速度,而插入较大数据块则可以产生超过一百万行每秒的速度。 +请注意,即使对于 Buffer 表,一次插入一行数据也是没有意义的。这将只能产生每秒几千行的速度,而插入更大的数据块可以产生超过每秒一百万行的速度。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/buffer.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/buffer.md.hash index 7e31ab189e8..e5a1b5ad161 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/buffer.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/buffer.md.hash @@ -1 +1 @@ -658fe78501648c5b +8525533478118634 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/dictionary.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/dictionary.md index 20a9f812261..e356b7043b0 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/dictionary.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/dictionary.md @@ -1,19 +1,20 @@ --- -'description': '`Dictionary` 引擎将字典数据作为 ClickHouse 表显示。' +'description': '`Dictionary` 引擎将字典数据呈现为 ClickHouse 表。' 'sidebar_label': 'Dictionary' 'sidebar_position': 20 'slug': '/engines/table-engines/special/dictionary' 'title': '字典表引擎' +'doc_type': 'reference' --- # 字典表引擎 -`Dictionary` 引擎将 [字典](../../../sql-reference/dictionaries/index.md) 数据作为一个 ClickHouse 表显示。 +`Dictionary` 引擎将 [字典](../../../sql-reference/dictionaries/index.md) 数据显示为 ClickHouse 表。 ## 示例 {#example} -作为一个例子,考虑一个 `products` 的字典,其配置如下: +作为一个示例,考虑一个 `products` 的字典,其配置如下: ```xml @@ -70,7 +71,7 @@ WHERE name = 'products' 您可以使用 [dictGet\*](/sql-reference/functions/ext-dict-functions#dictget-dictgetordefault-dictgetornull) 函数以这种格式获取字典数据。 -当您需要获取原始数据或在执行 `JOIN` 操作时,这种视图并不有用。在这些情况下,您可以使用 `Dictionary` 引擎,它以表的形式显示字典数据。 +当您需要获取原始数据或在进行 `JOIN` 操作时,这种视图就不太有用了。在这些情况下,您可以使用 `Dictionary` 引擎,它以表格的形式显示字典数据。 语法: @@ -81,7 +82,7 @@ CREATE TABLE %table_name% (%fields%) engine = Dictionary(%dictionary_name%)` 使用示例: ```sql -create table products (product_id UInt64, title String) Engine = Dictionary(products); +CREATE TABLE products (product_id UInt64, title String) ENGINE = Dictionary(products); ``` Ok @@ -89,7 +90,7 @@ create table products (product_id UInt64, title String) Engine = Dictionary(prod 查看表中的内容。 ```sql -select * from products limit 1; +SELECT * FROM products LIMIT 1; ``` ```text diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/dictionary.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/dictionary.md.hash index 4d5fe2d1173..15c02361f8e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/dictionary.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/dictionary.md.hash @@ -1 +1 @@ -5357cae661d2d9e3 +2e9dccbf4b4e4477 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/distributed.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/distributed.md index 24210d0b8a7..eb52b1a6b41 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/distributed.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/distributed.md @@ -1,19 +1,22 @@ --- -'description': '使用分布式引擎的表不存储任何自己的数据,但允许在多个服务器上进行分布式查询处理。读取会自动并行化。在读取时,会使用远程服务器上的表索引(如果存在的话)。' +'description': '具有 Distributed 引擎的表不存储自身任何数据,但允许在多个服务器上进行分布式查询处理。读取会自动并行化。在读取过程中,如果远程服务器上有表索引,则会使用它们。' 'sidebar_label': 'Distributed' 'sidebar_position': 10 'slug': '/engines/table-engines/special/distributed' 'title': '分布式表引擎' +'doc_type': 'reference' --- # 分布式表引擎 -:::warning -要在云中创建分布式表引擎,可以使用 [remote 和 remoteSecure](../../../sql-reference/table-functions/remote) 表函数。在 ClickHouse Cloud 中无法使用 `Distributed(...)` 语法。 +:::warning Cloud 中的分布式引擎 +要在 ClickHouse Cloud 中创建分布式表引擎,您可以使用 [`remote` 和 `remoteSecure`](../../../sql-reference/table-functions/remote) 表函数。 +`Distributed(...)` 语法不能在 ClickHouse Cloud 中使用。 ::: -使用分布式引擎的表不存储自己的任何数据,而是允许在多个服务器上进行分布式查询处理。读取会自动并行化。在读取期间,如果远程服务器上有表索引,则会使用它们。 +具有分布式引擎的表不存储自己的数据,而是允许在多个服务器上进行分布式查询处理。 +读取操作会自动并行化。在读取时,如果存在,远程服务器上的表索引将被使用。 ## 创建表 {#distributed-creating-a-table} @@ -29,7 +32,7 @@ CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] ### 从表创建 {#distributed-from-a-table} -当 `Distributed` 表指向当前服务器上的表时,可以采用该表的模式: +当 `Distributed` 表指向当前服务器上的表时,您可以采用该表的模式: ```sql CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] AS [db2.]name2 ENGINE = Distributed(cluster, database, table[, sharding_key[, policy_name]]) [SETTINGS name=value, ...] @@ -37,94 +40,46 @@ CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] AS [db2.]name2 ### 分布式参数 {#distributed-parameters} -#### cluster {#cluster} - -`cluster` - 服务器配置文件中的集群名称 - -#### database {#database} - -`database` - 远程数据库的名称 - -#### table {#table} - -`table` - 远程表的名称 - -#### sharding_key {#sharding_key} - -`sharding_key` - (可选)分片键 - -指定 `sharding_key` 是必要的,具体包括以下情况: - -- 用于向分布式表进行 `INSERT`(因为表引擎需要 `sharding_key` 来确定如何拆分数据)。然而,如果启用了 `insert_distributed_one_random_shard` 设置,则 `INSERT` 无需分片键。 -- 用于与 `optimize_skip_unused_shards` 一起使用,因为 `sharding_key` 是确定应该查询哪些分片所必需的。 - -#### policy_name {#policy_name} - -`policy_name` - (可选)策略名称,将用于存储后台发送的临时文件。 +| 参数 | 描述 | +|--------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `cluster` | 服务器配置文件中的集群名称 | +| `database` | 远程数据库的名称 | +| `table` | 远程表的名称 | +| `sharding_key` (可选) | 分片键。
指定 `sharding_key` 对于以下操作是必要的:
  • 对于分布式表的 `INSERT`(因为表引擎需要 `sharding_key` 来确定如何拆分数据)。但是,如果启用了 `insert_distributed_one_random_shard` 设置,则 `INSERT` 不需要分片键。
  • 与 `optimize_skip_unused_shards` 一起使用,因为需要 `sharding_key` 来确定应该查询哪些分片
| +| `policy_name` (可选) | 策略名称,将用于存储后台发送的临时文件 | **另见** - - [distributed_foreground_insert](../../../operations/settings/settings.md#distributed_foreground_insert) 设置 - - [MergeTree](../../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-multiple-volumes) 的示例 - +- [distributed_foreground_insert](../../../operations/settings/settings.md#distributed_foreground_insert) 设置 +- [MergeTree](../../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-multiple-volumes) 的示例 ### 分布式设置 {#distributed-settings} -#### fsync_after_insert {#fsync_after_insert} - -`fsync_after_insert` - 在向分布式进行后台插入后对文件数据执行 `fsync`。确保操作系统在 **发起节点** 磁盘上刷新整个插入的数据。 - -#### fsync_directories {#fsync_directories} - -`fsync_directories` - 对目录执行 `fsync`。确保操作系统在与分布式表的后台插入相关的操作(例如插入、发送数据到分片等)之后刷新目录元数据。 - -#### skip_unavailable_shards {#skip_unavailable_shards} - -`skip_unavailable_shards` - 如果为真,ClickHouse 会静默跳过不可用的分片。当以下情况发生时,分片标记为不可用:1)由于连接失败无法访问分片。2)通过 DNS 无法解析分片。3)分片上不存在表。默认值为 false。 - -#### bytes_to_throw_insert {#bytes_to_throw_insert} - -`bytes_to_throw_insert` - 如果待处理的压缩字节数超过此数,则将引发异常。0 - 不引发。默认值为 0。 - -#### bytes_to_delay_insert {#bytes_to_delay_insert} - -`bytes_to_delay_insert` - 如果待处理的压缩字节数超过此数,查询将被延迟。0 - 不延迟。默认值为 0。 - -#### max_delay_to_insert {#max_delay_to_insert} - -`max_delay_to_insert` - 在后台发送有很多待处理字节的情况下,将数据插入分布式表的最大延迟,单位为秒。默认值为 60。 - -#### background_insert_batch {#background_insert_batch} - -`background_insert_batch` - 同 [distributed_background_insert_batch](../../../operations/settings/settings.md#distributed_background_insert_batch) - -#### background_insert_split_batch_on_failure {#background_insert_split_batch_on_failure} - -`background_insert_split_batch_on_failure` - 同 [distributed_background_insert_split_batch_on_failure](../../../operations/settings/settings.md#distributed_background_insert_split_batch_on_failure) - -#### background_insert_sleep_time_ms {#background_insert_sleep_time_ms} - -`background_insert_sleep_time_ms` - 同 [distributed_background_insert_sleep_time_ms](../../../operations/settings/settings.md#distributed_background_insert_sleep_time_ms) - -#### background_insert_max_sleep_time_ms {#background_insert_max_sleep_time_ms} - -`background_insert_max_sleep_time_ms` - 同 [distributed_background_insert_max_sleep_time_ms](../../../operations/settings/settings.md#distributed_background_insert_max_sleep_time_ms) - -#### flush_on_detach {#flush_on_detach} - -`flush_on_detach` - 在 DETACH/DROP/服务器关闭时刷新数据到远程节点。默认值为 true。 +| 设置 | 描述 | 默认值 | +|------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------| +| `fsync_after_insert` | 在背景插入分布式表后对文件数据执行 `fsync`。确保操作系统将整个插入的数据刷新到 **发起节点** 的磁盘上。 | `false` | +| `fsync_directories` | 对目录执行 `fsync`。确保操作系统在与分布式表的后台插入相关的操作之后刷新目录元数据(插入后、将数据发送到分片后等)。 | `false` | +| `skip_unavailable_shards` | 如果为 true,ClickHouse 将悄无声息地跳过不可用的分片。当满足以下条件时,分片被标记为不可用:1) 由于连接失败无法访问分片;2) 通过 DNS 无法解析分片;3) 分片上不存在该表。 | `false` | +| `bytes_to_throw_insert` | 如果待插入的压缩字节数超过此值,将抛出异常。`0` - 不抛出。 | `0` | +| `bytes_to_delay_insert` | 如果待插入的压缩字节数超过此值,则查询将被延迟。`0` - 不延迟。 | `0` | +| `max_delay_to_insert` | 向分布式表插入数据的最大延迟(秒),如果有大量待发送的字节。 | `60` | +| `background_insert_batch` | 与 [`distributed_background_insert_batch`](../../../operations/settings/settings.md#distributed_background_insert_batch) 相同 | `0` | +| `background_insert_split_batch_on_failure`| 与 [`distributed_background_insert_split_batch_on_failure`](../../../operations/settings/settings.md#distributed_background_insert_split_batch_on_failure) 相同 | `0` | +| `background_insert_sleep_time_ms` | 与 [`distributed_background_insert_sleep_time_ms`](../../../operations/settings/settings.md#distributed_background_insert_sleep_time_ms) 相同 | `0` | +| `background_insert_max_sleep_time_ms` | 与 [`distributed_background_insert_max_sleep_time_ms`](../../../operations/settings/settings.md#distributed_background_insert_max_sleep_time_ms) 相同 | `0` | +| `flush_on_detach` | 在 `DETACH`/`DROP`/服务器关闭时将数据刷新到远程节点。 | `true` | :::note -**耐久性设置** (`fsync_...`): +**持久性设置** (`fsync_...`): -- 仅影响后台插入(即 `distributed_foreground_insert=false`),数据首先存储在发起节点磁盘上,然后在后台发送到分片。 -- 可能显著降低插入性能。 -- 影响写入存储在分布式表文件夹中的数据到 **接收您插入的节点**。如果需要对底层 MergeTree 表写入数据的保证 - 请参见 `system.merge_tree_settings` 中的耐久性设置 (`...fsync...`)。 +- 仅影响后台 `INSERT`(即 `distributed_foreground_insert=false`),数据首先存储在发起节点的磁盘上,然后在后台发送到分片。 +- 可能会显著降低 `INSERT` 性能 +- 影响写入存储在分布式表文件夹中的数据到 **接收您插入的节点**。如果您需要确保写入数据到底层 MergeTree 表,则请参见 `system.merge_tree_settings` 中的持久性设置(`...fsync...`) -有关 **插入限制设置** (`..._insert`),请另见: +有关 **插入限制设置** (`..._insert`),另见: -- [distributed_foreground_insert](../../../operations/settings/settings.md#distributed_foreground_insert) 设置 -- [prefer_localhost_replica](/operations/settings/settings#prefer_localhost_replica) 设置 -- `bytes_to_throw_insert` 在 `bytes_to_delay_insert` 之前处理,因此不应将其设置为小于 `bytes_to_delay_insert` 的值。 +- [`distributed_foreground_insert`](../../../operations/settings/settings.md#distributed_foreground_insert) 设置 +- [`prefer_localhost_replica`](/operations/settings/settings#prefer_localhost_replica) 设置 +- `bytes_to_throw_insert` 在 `bytes_to_delay_insert` 之前处理,因此您不应将其设置为小于 `bytes_to_delay_insert` 的值 ::: **示例** @@ -137,13 +92,13 @@ SETTINGS fsync_directories=0; ``` -数据将从 `logs` 集群中的所有服务器读取,来自每个服务器上位于 `default.hits` 表的数据。数据不仅会被读取,还会在远程服务器上部分处理(到一定程度)。例如,对于一个带有 `GROUP BY` 的查询,数据会在远程服务器上聚合,并将聚合函数的中间状态发送给请求者服务器。然后数据将进一步聚合。 +数据将从 `logs` 集群中的所有服务器读取,来自每个服务器上位于 `default.hits` 表中的数据。数据不仅被读取,而且在远程服务器上部分处理(在可能的范围内)。例如,对于包含 `GROUP BY` 的查询,数据将在远程服务器上聚合,聚合函数的中间状态将发送到请求服务器。然后,对数据进行进一步聚合。 -可以使用返回字符串的常量表达式代替数据库名称。例如:`currentDatabase()`。 +您可以使用返回字符串的常量表达式来替代数据库名称。例如:`currentDatabase()`。 ## 集群 {#distributed-clusters} -集群在 [服务器配置文件](../../../operations/configuration-files.md)中配置: +集群在 [服务器配置文件](../../../operations/configuration-files.md) 中配置: ```xml @@ -199,81 +154,83 @@ SETTINGS ``` -这里定义了一个名为 `logs` 的集群,该集群由两个分片组成,每个分片包含两个副本。分片指的是包含数据不同部分的服务器(为了读取所有数据,必须访问所有分片)。副本是复制服务器(为了读取所有数据,可以访问任何一个副本上的数据)。 +在此处定义了一个名为 `logs` 的集群,该集群由两个分片组成,每个分片包含两个副本。分片指的是包含不同数据部分的服务器(为了读取所有数据,您必须访问所有分片)。副本是复制服务器(为了读取所有数据,您可以访问任何一个副本上的数据)。 集群名称不得包含点。 -为每个服务器指定参数 `host`、`port`,可选的 `user`、`password`、`secure`、`compression`、`bind_host`: +为每个服务器指定 `host`、`port`,以及可选的 `user`、`password`、`secure`、`compression`、`bind_host` 参数: -- `host` - 远程服务器的地址。可以使用域名或 IPv4 或 IPv6 地址。如果指定了域名,服务器启动时会进行 DNS 请求,结果会在服务器运行期间保留。如果 DNS 请求失败,服务器不会启动。如果更改 DNS 记录,请重新启动服务器。 -- `port` - 用于通讯活动的 TCP 端口(配置中的 `tcp_port`,通常设置为 9000)。不要与 `http_port` 混淆。 -- `user` - 连接到远程服务器的用户名称。默认值为 `default` 用户。该用户必须有权限连接到指定的服务器。权限在 `users.xml` 文件中配置。有关更多信息,请参见 [访问权限](../../../guides/sre/user-management/index.md) 部分。 -- `password` - 连接到远程服务器的密码(未屏蔽)。默认值:空字符串。 -- `secure` - 是否使用安全的 SSL/TLS 连接。通常还需要指定端口(默认安全端口是 `9440`)。服务器应在 `9440` 上侦听,并配置正确的证书。 -- `compression` - 使用数据压缩。默认值:`true`。 -- `bind_host` - 从此节点连接到远程服务器时使用的源地址。仅支持 IPv4 地址。适用于需要设置 ClickHouse 分布式查询所用源 IP 地址的高级部署用例。 +| 参数 | 描述 | 默认值 | +|--------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------| +| `host` | 远程服务器的地址。您可以使用域名或 IPv4 或 IPv6 地址。如果指定域名,服务器在启动时会进行 DNS 请求,并将结果存储,直到服务器关闭。如果 DNS 请求失败,服务器将不会启动。如果您更改了 DNS 记录,请重启服务器。 | - | +| `port` | 用于消息传递活动的 TCP 端口(配置中的 `tcp_port`,通常设置为 9000)。请勿与 `http_port` 混淆。 | - | +| `user` | 连接到远程服务器的用户名称。此用户必须具有访问指定服务器的权限。在 `users.xml` 文件中配置访问。有关更多信息,请参见 [访问权限](../../../guides/sre/user-management/index.md) 部分。 | `default` | +| `password` | 连接到远程服务器的密码(未加密)。 | '' | +| `secure` | 是否使用安全的 SSL/TLS 连接。通常还需要指定端口(默认安全端口是 `9440`)。服务器应该在 `9440` 上监听,并正确配置证书。 | `false` | +| `compression`| 使用数据压缩。 | `true` | +| `bind_host` | 从此节点连接到远程服务器时使用的源地址。仅支持 IPv4 地址。旨在用于需要设置 ClickHouse 分布式查询所用源 IP 地址的高级部署用例。 | - | -在指定副本时,读取时将为每个分片选择一个可用的副本。您可以配置负载均衡算法(选择访问哪个副本的偏好) - 请参见 [load_balancing](../../../operations/settings/settings.md#load_balancing) 设置。如果与服务器的连接未建立,将尝试快速连接。如果连接失败,将选择下一个副本,依此类推。如果所有副本的连接请求均失败,则会以相同的方式重复尝试几次。这有利于提高弹性,但并不提供完全的容错能力:远程服务器可能接受连接,但可能无法正常工作或工作不良。 +在指定副本时,读取时会为每个分片选择一个可用副本。您可以配置负载均衡算法(访问哪个副本的偏好)– 请参见 [load_balancing](../../../operations/settings/settings.md#load_balancing) 设置。如果无法与服务器建立连接,将尝试进行短时间的连接。如果连接失败,将选择下一个副本,依此类推。如果所有副本的连接尝试都失败,将重复相同的尝试多次。这有利于恢复,但并不提供完整的故障容错性:远程服务器可能接受连接,但可能无法正常工作或工作不良。 -您可以仅指定一个分片(在这种情况下,查询处理应称为远程查询,而不是分布式查询),或者指定任意数量的分片。在每个分片中,您可以指定从一个到任意数量的副本。每个分片可以指定不同数量的副本。 +您可以只指定一个分片(在这种情况下,查询处理应称为远程,而不是分布式)或任意数量的分片。在每个分片中,您可以指定从一个到任意数量的副本。您可以为每个分片指定不同数量的副本。 -您可以在配置中指定尽可能多的集群。 +您可以在配置中指定任意数量的集群。 -要查看集群,请使用 `system.clusters` 表。 +要查看您的集群,请使用 `system.clusters` 表。 -`Distributed` 引擎允许像本地服务器一样与集群进行交互。然而,集群的配置不能动态指定,必须在服务器配置文件中配置。通常,集群中的所有服务器将具有相同的集群配置(尽管这不是必需的)。来自配置文件的集群在不重新启动服务器的情况下实时更新。 +`Distributed` 引擎允许像本地服务器一样与集群一起工作。然而,集群的配置不能动态指定,必须在服务器配置文件中配置。通常,集群中的所有服务器将具有相同的集群配置(尽管这不是必需的)。来自配置文件的集群可以在不停机的情况下动态更新。 -如果您需要每次发送查询到未知的分片和副本集合,则无需创建 `Distributed` 表 - 请使用 `remote` 表函数。请参见 [表函数](../../../sql-reference/table-functions/index.md) 部分。 +如果您需要每次都将查询发送到未知的分片和副本集合,则无需创建一个 `Distributed` 表 - 请改用 `remote` 表函数。请参见 [表函数](../../../sql-reference/table-functions/index.md) 部分。 ## 写入数据 {#distributed-writing-data} -有两种方法可以将数据写入集群: +有两种方法可以向集群写入数据: -首先,您可以定义哪些服务器写入哪些数据,并直接在每个分片上执行写入。换句话说,在 `Distributed` 表指向的集群中的远程表上执行直接的 `INSERT` 语句。这是最灵活的解决方案,因为您可以使用任何分片方案,即使由于主题领域的要求而变得不平凡。这也是最优的解决方案,因为数据可以完全独立地写入不同的分片。 +首先,您可以定义哪些服务器写入哪些数据,并在每个分片上直接执行写入。换句话说,直接在指向的集群的远程表上执行 `INSERT` 语句。这是最灵活的解决方案,因为您可以使用任何分片方案,甚至可以使用由于主题领域的要求而非平凡的方案。这也是最优的解决方案,因为数据可以完全独立地写入不同的分片。 -其次,您可以在 `Distributed` 表上执行 `INSERT` 语句。在这种情况下,表会将插入的数据分配到服务器上。为了写入 `Distributed` 表,它必须配置 `sharding_key` 参数(除非只有一个分片)。 +其次,您可以在 `Distributed` 表上执行 `INSERT` 语句。在这种情况下,表将自行在服务器之间分配插入的数据。为了写入 `Distributed` 表,必须配置 `sharding_key` 参数(除非只有一个分片)。 -每个分片可以在配置文件中定义 ``。默认情况下,权重为 `1`。数据根据分片权重按比例分配到分片。所有分片的权重相加,然后每个分片的权重除以总和以确定每个分片的比例。例如,如果有两个分片,第一个的权重为 1,而第二个的权重为 2,则第一个将接收三分之一(1 / 3)的插入行,第二个将接收三分之二(2 / 3)。 +每个分片在配置文件中可以定义一个 ``。默认情况下,权重为 `1`。数据根据分片权重的比例在分片之间分配。所有分片的权重相加,然后每个分片的权重除以总权重以确定每个分片的比例。例如,如果有两个分片,第一个的权重为 1,而第二个的权重为 2,则第一个将发送三分之一(1 / 3)的插入行,而第二个将发送三分之二(2 / 3)。 -每个分片可以在配置文件中定义 `internal_replication` 参数。如果将此参数设置为 `true`,则写入操作将选择第一个健康的副本并向其写入数据。如果 `Distributed` 表底层的表是副本表(例如任何 `Replicated*MergeTree` 表引擎),则会接收写入,并自动复制到其他副本。 +每个分片可以在配置文件中定义 `internal_replication` 参数。如果该参数设置为 `true`,则写入操作选择第一个健康的副本并将数据写入其中。如果 `Distributed` 表底层的表是复制表(例如,任何 `Replicated*MergeTree` 表引擎),则将有一个表副本接收写入,并且将自动复制到其他副本。 -如果 `internal_replication` 设置为 `false`(默认值),则数据将写入所有副本。在这种情况下,`Distributed` 表将自己复制数据。这比使用副本表更糟糕,因为副本的一致性未被检查,随着时间的推移,它们将包含略微不同的数据。 +如果 `internal_replication` 设置为 `false`(默认),数据会写入所有副本。在这种情况下,`Distributed` 表自行复制数据。这比使用复制表更糟糕,因为没有检查副本的一致性,并且随着时间的推移,它们将包含略有不同的数据。 -要选择将数据行发送到的分片,分析分片表达式,并计算其余数,除以分片总权重。行会被发送到对应于 `prev_weights` 到 `prev_weights + weight` 的余数的半区间的分片,其中 `prev_weights` 是权重最小的分片的总权重,而 `weight` 是该分片的权重。例如,如果有两个分片,第一个的权重为 9,而第二个的权重为 10,则对于余数在范围 \[0, 9) 的行,将发送到第一个分片,对于余数在范围 \[9, 19) 的行,将发送到第二个分片。 +要选择将行数据发送到哪个分片,分析分片表达式并取其余数,而其余数是通过将其除以所有分片的总权重得到的。该行被发送到对应于从 `prev_weights` 到 `prev_weights + weight` 的余数的半区间的分片,其中 `prev_weights` 是最小编号的分片的总权重,`weight` 是该分片的权重。例如,如果有两个分片,第一个的权重为 9,第二个的权重为 10,则该行将在余数范围 \[0, 9) 中发送到第一个分片,而在余数范围 \[9, 19) 中发送到第二个分片。 -分片表达式可以是任何返回整数的常量和表列的表达式。例如,您可以使用表达式 `rand()` 进行随机数据分配,或 `UserID` 进行按用户 ID 除法余数分配(这样单个用户的数据将位于单个分片上,从而简化按用户运行的 `IN` 和 `JOIN`)。如果某一列分布不够均匀,您可以将其包裹在哈希函数中,比如 `intHash64(UserID)`。 +分片表达式可以是返回整数的常量和表列的任何表达式。例如,您可以使用表达式 `rand()` 来随机分配数据,或者使用 `UserID` 根据用户 ID 的余数进行分配(这样单个用户的数据将位于单个分片中,这简化了基于用户的 `IN` 和 `JOIN` 的运行)。如果某一列的分布不够均匀,您可以将其嵌入哈希函数,例如 `intHash64(UserID)`。 -简单的除法余数是一个有限的分片解决方案,并不总是合适。它适用于中等和大卷数(数十个服务器),但不适用于非常大的卷数(数百个服务器或更多)。在后者的情况下,更应使用主题领域所需的分片方案,而不是使用在 `Distributed` 表中的记录。 +简单的余数除法是一种有限的分片解决方案,并不总是合适。它适用于中等和大容量的数据(数十台服务器),但不适用于非常大容量的数据(数百台服务器或更多)。在后者的情况下,请使用主题领域所需的分片方案,而不是在 `Distributed` 表中使用条目。 在以下情况下,您应关注分片方案: -- 使用需要按特定键连接数据的查询(`IN` 或 `JOIN`)。如果数据按此键分片,则可以使用本地的 `IN` 或 `JOIN` 而不是全球的 `IN` 或 `GLOBAL JOIN`,效率将高得多。 -- 使用大量服务器(数百台或更多),并伴随大量小查询,例如对单个客户的数据查询(例如网站、广告客户或合作伙伴)。为了使小查询不影响整个集群,将单个客户的数据放在单个分片上是有意义的。或者,您可以设置双层分片:将整个集群分为“层”,其中一层可能由多个分片组成。单个客户的数据位于单个层上,但可以根据需要向层中添加分片,并且数据在其中随机分布。每层创建 `Distributed` 表,并为全局查询创建一个共享的分布式表。 +- 使用需要通过特定键连接数据的查询(`IN` 或 `JOIN`)。如果数据根据该键分片,您可以使用本地 `IN` 或 `JOIN`,而不是 `GLOBAL IN` 或 `GLOBAL JOIN`,这会高效得多。 +- 使用了大量服务器(数百台或更多)和大量小查询,例如单个客户(例如网站、广告客户或合作伙伴)的数据查询。为了使小查询不影响整个集群,将单个客户的数据放在单个分片上是有意义的。或者,您可以设置双层分片:将整个集群分为“层”,每层可以包含多个分片。单个客户的数据位于单个层上,但可以根据需要向层中添加分片,数据在其中随机分配。为每层创建 `Distributed` 表,并为全局查询创建一个共享的分布式表。 -数据以后台方式写入。当插入到表中时,数据块只会写入本地文件系统。数据会尽快在后台发送到远程服务器。发送数据的周期性由 [distributed_background_insert_sleep_time_ms](../../../operations/settings/settings.md#distributed_background_insert_sleep_time_ms) 和 [distributed_background_insert_max_sleep_time_ms](../../../operations/settings/settings.md#distributed_background_insert_max_sleep_time_ms) 设置管理。`Distributed` 引擎单独发送每个包含插入数据的文件,但您可以通过 [distributed_background_insert_batch](../../../operations/settings/settings.md#distributed_background_insert_batch) 设置启用批量发送。此设置通过更好地利用本地服务器和网络资源来提高集群性能。您应检查数据是否成功发送,方法是在表目录中检查文件列表(等待发送的数据):`/var/lib/clickhouse/data/database/table/`。后台任务的线程数可以由 [background_distributed_schedule_pool_size](/operations/server-configuration-parameters/settings#background_distributed_schedule_pool_size) 设置。 +数据在后台写入。在表中插入时,数据块仅写入本地文件系统。数据会尽快在后台发送到远程服务器。发送数据的周期由 [distributed_background_insert_sleep_time_ms](../../../operations/settings/settings.md#distributed_background_insert_sleep_time_ms) 和 [distributed_background_insert_max_sleep_time_ms](../../../operations/settings/settings.md#distributed_background_insert_max_sleep_time_ms) 设置来管理。`Distributed` 引擎单独发送每个插入数据的文件,但是您可以通过 [distributed_background_insert_batch](../../../operations/settings/settings.md#distributed_background_insert_batch) 设置启用批量发送文件。此设置通过更好地利用本地服务器和网络资源来改善集群性能。您应该通过检查表目录中的文件列表(待发送的数据)来检查数据是否成功发送:`/var/lib/clickhouse/data/database/table/`。执行后台任务的线程数量可以通过 [background_distributed_schedule_pool_size](/operations/server-configuration-parameters/settings#background_distributed_schedule_pool_size) 设置进行设置。 -如果服务器不存在或在对 `Distributed` 表执行 `INSERT` 后因故障重启而导致损坏,则可能会丢失插入的数据。如果表目录中检测到损坏的数据部分,则会将其转移到 `broken` 子目录中,并不再使用。 +如果服务器在向 `Distributed` 表执行 `INSERT` 后消失或发生了粗暴重启(例如,因硬件故障),则插入的数据可能会丢失。如果在表目录中检测到损坏的数据部分,它将被转移到 `broken` 子目录并不再使用。 ## 读取数据 {#distributed-reading-data} -查询 `Distributed` 表时,`SELECT` 查询将发送到所有分片,并且无论数据在分片中的分布如何(它们可以完全随机分布)都能正常工作。当您添加新的分片时,您无需将旧数据转移到它中。相反,您可以通过使用更大的权重将新数据写入其中 - 数据将稍微不均匀分配,但查询将正确且高效地运行。 +在查询 `Distributed` 表时,`SELECT` 查询会发送到所有分片,并且无论数据如何在分片中分配(它们可以完全随机分配),都可以工作。当您添加新分片时,不必将旧数据转移到其中。相反,您可以通过使用更大的权重向其中写入新数据——数据的分配会略显不均,但查询将有效且正确地工作。 -当启用 `max_parallel_replicas` 选项时,查询处理将在单个分片内的所有副本之间并行化处理。有关更多信息,请参见 [max_parallel_replicas](../../../operations/settings/settings.md#max_parallel_replicas) 部分。 +当启用 `max_parallel_replicas` 选项时,查询处理在单个分片内并行化到所有副本。有关更多信息,请参见 [max_parallel_replicas](../../../operations/settings/settings.md#max_parallel_replicas) 部分。 -要了解有关分布式 `in` 和 `global in` 查询如何处理的更多信息,请参阅 [此处](/sql-reference/operators/in#distributed-subqueries) 文档。 +要了解有关分布式 `in` 和 `global in` 查询如何处理的更多信息,请参阅 [此处](/sql-reference/operators/in#distributed-subqueries) 的文档。 ## 虚拟列 {#virtual-columns} -#### _shard_num {#_shard_num} +#### _Shard_num {#_shard_num} -`_shard_num` - 包含来自表 `system.clusters` 的 `shard_num` 值。类型:[UInt32](../../../sql-reference/data-types/int-uint.md)。 +`_shard_num` — 包含表 `system.clusters` 中的 `shard_num` 值。类型:[UInt32](../../../sql-reference/data-types/int-uint.md)。 :::note -由于 [remote](../../../sql-reference/table-functions/remote.md) 和 [cluster](../../../sql-reference/table-functions/cluster.md) 表函数在内部创建临时的分布式表,因此 `_shard_num` 在那里也可以使用。 +由于 [`remote`](../../../sql-reference/table-functions/remote.md) 和 [`cluster`](../../../sql-reference/table-functions/cluster.md) 表函数内部创建临时的分布式表,因此 `_shard_num` 在那里也可以使用。 ::: **另见** -- [虚拟列](../../../engines/table-engines/index.md#table_engines-virtual_columns) 说明 -- [background_distributed_schedule_pool_size](/operations/server-configuration-parameters/settings#background_distributed_schedule_pool_size) 设置 -- [shardNum()](../../../sql-reference/functions/other-functions.md#shardnum) 和 [shardCount()](../../../sql-reference/functions/other-functions.md#shardcount) 函数 +- [虚拟列](../../../engines/table-engines/index.md#table_engines-virtual_columns) 描述 +- [`background_distributed_schedule_pool_size`](/operations/server-configuration-parameters/settings#background_distributed_schedule_pool_size) 设置 +- [`shardNum()`](../../../sql-reference/functions/other-functions.md#shardnum) 和 [`shardCount()`](../../../sql-reference/functions/other-functions.md#shardcount) 函数 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/distributed.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/distributed.md.hash index d331ca262fb..05326949339 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/distributed.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/distributed.md.hash @@ -1 +1 @@ -7ccc20c170b84501 +c914e6affcd4d26d diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/executable.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/executable.md index 1f208d7cbf8..acd0512664b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/executable.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/executable.md @@ -1,24 +1,25 @@ --- -'description': '`Executable` 和 `ExecutablePool` 表引擎允许您定义一个表,其行是从您定义的脚本生成的(通过写入 **stdout**)。' +'description': '`Executable` 和 `ExecutablePool` 表引擎允许您定义一个表,其行是由您定义的脚本生成的(通过将行写入 **stdout**)。' 'sidebar_label': '可执行' 'sidebar_position': 40 'slug': '/engines/table-engines/special/executable' -'title': '可执行与可执行池表引擎' +'title': '可执行和可执行池表引擎' +'doc_type': 'reference' --- -# 可执行和可执行池表引擎 +# `Executable` 和 `ExecutablePool` 表引擎 -`Executable` 和 `ExecutablePool` 表引擎允许你定义一个表,其行由你定义的脚本生成(通过写行到 **stdout**)。可执行脚本存储在 `users_scripts` 目录中,可以从任何源读取数据。 +`Executable` 和 `ExecutablePool` 表引擎允许您定义一个表,其行是由您定义的脚本生成的(通过将行写入 **stdout**)。可执行脚本存储在 `users_scripts` 目录中,并可以从任何来源读取数据。 -- `Executable` 表:在每个查询时运行脚本 +- `Executable` 表:每次查询时都运行脚本 - `ExecutablePool` 表:维护一个持久进程池,并从池中获取进程进行读取 -你可以选择性地包含一个或多个输入查询,这些查询将其结果流式传输到 **stdin** 供脚本读取。 +您可以选择性地包含一个或多个输入查询,将其结果流式传输到 **stdin** 供脚本读取。 -## 创建可执行表 {#creating-an-executable-table} +## 创建 `Executable` 表 {#creating-an-executable-table} -`Executable` 表引擎需要两个参数:脚本的名称和传入数据的格式。你可以选择性地传入一个或多个输入查询: +`Executable` 表引擎需要两个参数:脚本的名称和传入数据的格式。您可以选择性地传入一个或多个输入查询: ```sql Executable(script_name, format, [input_query...]) @@ -27,20 +28,19 @@ Executable(script_name, format, [input_query...]) 以下是 `Executable` 表的相关设置: - `send_chunk_header` - - 描述:在发送数据块到进程之前,发送每个块中的行数。此设置可以帮助你以更高效的方式编写脚本,从而预分配一些资源 - - 默认值:false + - 描述:在发送分块进行处理之前,发送每个分块中的行数。此设置有助于以更高效的方式编写脚本以预分配一些资源 + - 默认值:false - `command_termination_timeout` - - 描述:命令终止超时(以秒为单位) - - 默认值:10 + - 描述:命令终止超时时间(以秒为单位) + - 默认值:10 - `command_read_timeout` - - 描述:从命令 stdout 读取数据的超时(以毫秒为单位) - - 默认值:10000 + - 描述:从命令 stdout 读取数据的超时时间(以毫秒为单位) + - 默认值:10000 - `command_write_timeout` - - 描述:向命令 stdin 写入数据的超时(以毫秒为单位) - - 默认值:10000 + - 描述:向命令 stdin 写入数据的超时时间(以毫秒为单位) + - 默认值:10000 - -让我们看一个例子。以下 Python 脚本名为 `my_script.py`,保存在 `user_scripts` 文件夹中。它读取一个数字 `i`,并打印 `i` 个随机字符串,每个字符串前面都有一个以制表符分隔的数字: +让我们来看一个例子。以下 Python 脚本名为 `my_script.py`,并保存在 `user_scripts` 文件夹中。它读取一个数字 `i` 并打印 `i` 个随机字符串,每个字符串前面都有一个用制表符分隔的数字: ```python #!/usr/bin/python3 @@ -68,7 +68,7 @@ if __name__ == "__main__": main() ``` -以下的 `my_executable_table` 是从 `my_script.py` 的输出构建的,每当你从 `my_executable_table` 运行 `SELECT` 时,将生成 10 个随机字符串: +以下的 `my_executable_table` 是根据 `my_script.py` 的输出构建的,每次从 `my_executable_table` 执行 `SELECT` 时,它将生成 10 个随机字符串: ```sql CREATE TABLE my_executable_table ( @@ -78,7 +78,7 @@ CREATE TABLE my_executable_table ( ENGINE = Executable('my_script.py', TabSeparated, (SELECT 10)) ``` -创建表后会立即返回,不会调用脚本。查询 `my_executable_table` 将导致脚本被调用: +创建表的操作会立即返回,而不会调用脚本。查询 `my_executable_table` 会导致脚本被调用: ```sql SELECT * FROM my_executable_table @@ -101,9 +101,9 @@ SELECT * FROM my_executable_table ## 将查询结果传递给脚本 {#passing-query-results-to-a-script} -用户在 Hacker News 网站上留下评论。Python 包含一个自然语言处理工具包 (`nltk`),其中有一个 `SentimentIntensityAnalyzer` 用于判断评论是正面的、负面的还是中性的,包括为评论分配一个在 -1(非常负面的评论)到 1(非常正面的评论)之间的值。让我们创建一个 `Executable` 表,使用 `nltk` 计算 Hacker News 评论的情感。 +Hacker News 网站的用户会发表评论。Python 包含一个自然语言处理工具包(`nltk`),里面有一个 `SentimentIntensityAnalyzer` 用于判断评论是积极的、消极的还是中性的 - 包括赋值在 -1(非常消极的评论)和 1(非常积极的评论)之间。让我们创建一个 `Executable` 表,使用 `nltk` 计算 Hacker News 评论的情感。 -此示例使用 [这里描述的 `hackernews` 表](/engines/table-engines/mergetree-family/invertedindexes/#full-text-search-of-the-hacker-news-dataset)。`hackernews` 表包含一个类型为 `UInt64` 的 `id` 列和一个名为 `comment` 的 `String` 列。让我们开始定义 `Executable` 表: +该示例使用 [这里描述的](../../engines/table-engines/mergetree-family/invertedindexes/#hacker-news-dataset) `hackernews` 表。`hackernews` 表包括一个类型为 `UInt64` 的 `id` 列和一个名为 `comment` 的 `String` 列。让我们从定义 `Executable` 表开始: ```sql CREATE TABLE sentiment ( @@ -117,13 +117,13 @@ ENGINE = Executable( ); ``` -关于 `sentiment` 表的一些评论: +关于 `sentiment` 表的一些说明: -- 文件 `sentiment.py` 保存在 `user_scripts` 文件夹中(即 `user_scripts_path` 设置的默认文件夹) +- 文件 `sentiment.py` 保存在 `user_scripts` 文件夹中(`user_scripts_path` 设置的默认文件夹) - `TabSeparated` 格式意味着我们的 Python 脚本需要生成包含制表符分隔值的原始数据行 -- 查询从 `hackernews` 中选择两列。Python 脚本需要从传入的行中解析出这些列的值 +- 查询选择了 `hackernews` 中的两个列。Python 脚本需要从传入的行中解析出这些列的值 -以下是 `sentiment.py` 的定义: +这是 `sentiment.py` 的定义: ```python #!/usr/local/bin/python3.9 @@ -156,22 +156,22 @@ if __name__ == "__main__": main() ``` -关于我们的 Python 脚本的一些评论: +关于我们的 Python 脚本的一些说明: -- 为了使其正常工作,你需要运行 `nltk.downloader.download('vader_lexicon')`。这本可以放在脚本中,但那样的话,每次在 `sentiment` 表上执行查询时都会下载,这是不高效的 -- 每个 `row` 的值将是 `SELECT id, comment FROM hackernews WHERE id > 0 AND comment != '' LIMIT 20` 结果集中的一行 -- 传入行是用制表符分隔的,因此我们使用 Python 的 `split` 函数解析出 `id` 和 `comment` -- `polarity_scores` 的结果是一个 JSON 对象,包含一些值。我们决定只是抓取这个 JSON 对象的 `compound` 值 -- 请记住,ClickHouse 中的 `sentiment` 表使用 `TabSeparated` 格式并包含两列,因此我们的 `print` 函数用制表符分隔这些列 +- 为了使其工作,您需要运行 `nltk.downloader.download('vader_lexicon')`。这可以放在脚本中,但这样每次在 `sentiment` 表上执行查询时都会下载 - 这不是高效的 +- 每个 `row` 的值将是 `SELECT id, comment FROM hackernews WHERE id > 0 AND comment != '' LIMIT 20` 查询结果集中的一行 +- 传入的行是制表符分隔的,因此我们使用 Python 的 `split` 函数解析出 `id` 和 `comment` +- `polarity_scores` 的结果是一个包含多个值的 JSON 对象。我们决定只抓取该 JSON 对象的 `compound` 值 +- 请记住,ClickHouse 中的 `sentiment` 表使用 `TabSeparated` 格式并包含两个列,因此我们的 `print` 函数用制表符分隔这些列 -每次你写一个从 `sentiment` 表中选择行的查询时,`SELECT id, comment FROM hackernews WHERE id > 0 AND comment != '' LIMIT 20` 查询将被执行,并且结果会传递给 `sentiment.py`。我们来测试一下: +每次您编写查询以从 `sentiment` 表中选择行时,查询 `SELECT id, comment FROM hackernews WHERE id > 0 AND comment != '' LIMIT 20` 会被执行,并将结果传递给 `sentiment.py`。让我们测试一下: ```sql SELECT * FROM sentiment ``` -响应看起来像: +响应如下所示: ```response ┌───────id─┬─sentiment─┐ @@ -198,17 +198,16 @@ FROM sentiment └──────────┴───────────┘ ``` +## 创建 `ExecutablePool` 表 {#creating-an-executablepool-table} -## 创建可执行池表 {#creating-an-executablepool-table} - -`ExecutablePool` 的语法类似于 `Executable`,但有一些仅适用于 `ExecutablePool` 表的相关设置: +`ExecutablePool` 的语法与 `Executable` 类似,但有一些特定于 `ExecutablePool` 表的相关设置: - `pool_size` - - 描述:进程池大小。如果大小为 0,则没有大小限制 - - 默认值:16 + - 描述:进程池大小。如果大小为 0,则没有大小限制 + - 默认值:16 - `max_command_execution_time` - - 描述:最大命令执行时间(以秒为单位) - - 默认值:10 + - 描述:最大命令执行时间(以秒为单位) + - 默认值:10 我们可以轻松地将上述 `sentiment` 表转换为使用 `ExecutablePool` 而不是 `Executable`: @@ -226,4 +225,4 @@ SETTINGS pool_size = 4; ``` -当你的客户端查询 `sentiment_pooled` 表时,ClickHouse 会按需维护 4 个进程。 +当您的客户端查询 `sentiment_pooled` 表时,ClickHouse 将按需维护 4 个进程。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/executable.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/executable.md.hash index 53b6974667e..ca44c1ad6bb 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/executable.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/executable.md.hash @@ -1 +1 @@ -9bda640eedb0575f +57c56a1096c7c211 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/external-data.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/external-data.md index 3d83fb59623..ab1a27cff76 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/external-data.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/external-data.md @@ -1,42 +1,43 @@ --- -'description': 'ClickHouse 允许向服务器发送处理查询所需的数据,连同一个 `SELECT` 查询。这些数据被放入一个临时表中,可以在查询中使用(例如,在 +'description': 'ClickHouse 允许将所需的数据发送给服务器,以处理查询,连同 `SELECT` 查询一起发送。这些数据被放置在一个临时表中,并可以在查询中使用(例如,在 `IN` 操作符中)。' 'sidebar_label': '外部数据' 'sidebar_position': 130 'slug': '/engines/table-engines/special/external-data' -'title': '外部数据用于查询处理' +'title': '用于查询处理的外部数据' +'doc_type': 'reference' --- # 外部数据用于查询处理 -ClickHouse 允许向服务器发送处理查询所需的数据,连同一个 `SELECT` 查询。这些数据被放入一个临时表中(参见“临时表”一节),并可以在查询中使用(例如,在 `IN` 操作符中)。 +ClickHouse 允许将处理查询所需的数据与 `SELECT` 查询一起发送到服务器。这些数据被放入一个临时表中(请参见“临时表”部分),可以在查询中使用(例如,在 `IN` 操作符中)。 -例如,如果你有一个包含重要用户标识符的文本文件,你可以将其上传到服务器,并使用该列表进行过滤的查询一起发送。 +例如,如果您有一个包含重要用户标识符的文本文件,您可以将其与使用该列表进行过滤的查询一起上传到服务器。 -如果需要执行超过一个查询,并且外部数据量很大,请不要使用此功能。最好提前将数据上传到数据库。 +如果您需要运行多个查询并处理大量外部数据,请勿使用此功能。最好提前将数据上传到数据库。 -外部数据可以通过命令行客户机(在非交互模式下)或通过 HTTP 接口上传。 +外部数据可以通过命令行客户端(非交互模式)或 HTTP 接口上传。 -在命令行客户机中,可以以以下格式指定参数部分 +在命令行客户端中,您可以以以下格式指定参数部分 ```bash --external --file=... [--name=...] [--format=...] [--types=...|--structure=...] ``` -您可以有多个这样的部分,以传输表的数量。 +您可以拥有多个这样的部分,具体数量取决于所传输的表的数量。 **–external** – 标记子句的开始。 -**–file** – 包含表转储的文件路径,或 -,表示标准输入。 -只能从标准输入检索单个表。 +**–file** – 表转储文件的路径,或者 -,表示标准输入。 +只能从标准输入中检索单个表。 -以下参数是可选的:**–name** – 表的名称。如果省略,则使用 _data。 -**–format** – 文件中的数据格式。如果省略,则使用 TabSeparated。 +以下参数是可选的:**–name**– 表的名称。如果省略,使用 _data。 +**–format** – 文件中的数据格式。如果省略,使用 TabSeparated。 以下参数之一是必需的:**–types** – 用逗号分隔的列类型列表。例如:`UInt64,String`。列将命名为 _1, _2, ... -**–structure** – 表结构的格式为 `UserID UInt64`, `URL String`。定义列的名称和类型。 +**–structure**– 表结构,格式为 `UserID UInt64`, `URL String`。定义列的名称和类型。 -在 'file' 中指定的文件将由在 'format' 中指定的格式解析,使用在 'types' 或 'structure' 中指定的数据类型。表将被上传到服务器,并以 'name' 中的名称作为临时表可访问。 +在 'file' 中指定的文件将根据 'format' 中指定的格式进行解析,使用在 'types' 或 'structure' 中指定的数据类型。该表将上传到服务器,并在那里作为名为 'name' 的临时表进行访问。 示例: @@ -51,7 +52,7 @@ $ cat /etc/passwd | sed 's/:/\t/g' | clickhouse-client --query="SELECT shell, co /bin/sync 1 ``` -使用 HTTP 接口时,外部数据以 multipart/form-data 格式传递。每个表作为单独的文件传输。表名称取自文件名。`query_string` 传递的参数为 `name_format`、`name_types` 和 `name_structure`,其中 `name` 是这些参数对应的表的名称。参数的含义与使用命令行客户机时相同。 +使用 HTTP 接口时,外部数据以 multipart/form-data 格式传递。每个表作为单独的文件进行传输。表名取自文件名。`query_string` 中传递参数 `name_format`、`name_types` 和 `name_structure`,其中 `name` 是这些参数所对应的表名。参数的含义与使用命令行客户端时相同。 示例: @@ -66,4 +67,4 @@ $ curl -F 'passwd=@passwd.tsv;' 'http://localhost:8123/?query=SELECT+shell,+coun /bin/sync 1 ``` -对于分布式查询处理,临时表会发送到所有远程服务器。 +对于分布式查询处理,临时表将发送到所有远程服务器。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/external-data.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/external-data.md.hash index 08d91b117d0..5fad29969b2 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/external-data.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/external-data.md.hash @@ -1 +1 @@ -68dcd5169f61bacf +ed2dfffffb66406d diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/file.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/file.md index 6bae5b35e81..5a5dff2bc77 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/file.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/file.md @@ -1,42 +1,43 @@ --- -'description': '文件表引擎以受支持的文件格式(`TabSeparated`、`Native` 等)保持数据在文件中。' +'description': '文件表引擎将数据保存在文件中,格式为支持的文件格式之一 (`TabSeparated`, `Native`, 等等)。' 'sidebar_label': '文件' 'sidebar_position': 40 'slug': '/engines/table-engines/special/file' 'title': '文件表引擎' +'doc_type': 'reference' --- -# 文件表引擎 +# `File` 表引擎 -文件表引擎将数据保存在支持的 [文件格式](/interfaces/formats#formats-overview)(`TabSeparated`、`Native` 等)中的文件中。 +`File` 表引擎将数据存储在支持的 [文件格式](/interfaces/formats#formats-overview) 中的文件中(如 `TabSeparated`、`Native` 等)。 使用场景: - 从 ClickHouse 导出数据到文件。 - 将数据从一种格式转换为另一种格式。 -- 通过在磁盘上编辑文件来更新 ClickHouse 中的数据。 +- 通过编辑磁盘上的文件更新 ClickHouse 中的数据。 :::note 此引擎当前在 ClickHouse Cloud 中不可用,请 [改用 S3 表函数](/sql-reference/table-functions/s3.md)。 ::: -## 在 ClickHouse 服务器中的使用 {#usage-in-clickhouse-server} +## 在 ClickHouse Server 中的使用 {#usage-in-clickhouse-server} ```sql File(Format) ``` -`Format` 参数指定可用的文件格式之一。要执行 `SELECT` 查询,格式必须支持输入;要执行 `INSERT` 查询,格式必须支持输出。可用格式列在 [格式](/interfaces/formats#formats-overview) 部分。 +`Format` 参数指定可用的文件格式之一。要执行 `SELECT` 查询,必须支持输入格式;要执行 `INSERT` 查询,必须支持输出格式。可用的格式在 [Formats](/interfaces/formats#formats-overview) 部分列出。 -ClickHouse 不允许为 `File` 指定文件系统路径。它将使用服务器配置中通过 [path](../../../operations/server-configuration-parameters/settings.md) 设置定义的文件夹。 +ClickHouse 不允许为 `File` 指定文件系统路径。它将使用服务器配置中由 [path](../../../operations/server-configuration-parameters/settings.md) 设置定义的文件夹。 -使用 `File(Format)` 创建表时,会在该文件夹中创建一个空子目录。将数据写入该表时,数据将被放入该子目录中的 `data.Format` 文件中。 +使用 `File(Format)` 创建表时,它会在该文件夹中创建一个空子目录。当数据写入该表时,会放入该子目录中的 `data.Format` 文件中。 -您可以手动在服务器文件系统中创建此子文件夹和文件,然后 [ATTACH](../../../sql-reference/statements/attach.md) 到具有匹配名称的表信息,这样您就可以查询该文件中的数据。 +您可以手动在服务器文件系统中创建此子文件夹和文件,然后将其 [ATTACH](../../../sql-reference/statements/attach.md) 到具有匹配名称的表信息,以便从该文件中查询数据。 :::note -请谨慎使用此功能,因为 ClickHouse 不会跟踪对这些文件的外部更改。通过 ClickHouse 和 ClickHouse 外部的同时写入结果是未定义的。 +使用此功能时要小心,因为 ClickHouse 不会跟踪对该文件的外部更改。通过 ClickHouse 和外部方式同时写入的结果是未定义的。 ::: ## 示例 {#example} @@ -47,7 +48,7 @@ ClickHouse 不允许为 `File` 指定文件系统路径。它将使用服务器 CREATE TABLE file_engine_table (name String, value UInt32) ENGINE=File(TabSeparated) ``` -默认情况下,ClickHouse 会在 `/var/lib/clickhouse/data/default/file_engine_table` 下创建文件夹。 +默认情况下,ClickHouse 将创建文件夹 `/var/lib/clickhouse/data/default/file_engine_table`。 **2.** 手动创建 `/var/lib/clickhouse/data/default/file_engine_table/data.TabSeparated`,内容为: @@ -72,7 +73,7 @@ SELECT * FROM file_engine_table ## 在 ClickHouse-local 中的使用 {#usage-in-clickhouse-local} -在 [clickhouse-local](../../../operations/utilities/clickhouse-local.md) 中,文件引擎除了接受 `Format` 之外,还接受文件路径。可以使用数字或人类可读的名称(如 `0` 或 `stdin`,`1` 或 `stdout`)指定默认的输入/输出流。可以通过附加的引擎参数或文件扩展名(`gz`、`br` 或 `xz`)来读取和写入压缩文件。 +在 [clickhouse-local](../../../operations/utilities/clickhouse-local.md) 中,File 引擎除了 `Format` 之外,还接受文件路径。默认的输入/输出流可以使用数字或人类可读的名称,如 `0` 或 `stdin`,`1` 或 `stdout`。可以根据额外的引擎参数或文件扩展名(`gz`、`br` 或 `xz`)读取和写入压缩文件。 **示例:** @@ -82,32 +83,32 @@ $ echo -e "1,2\n3,4" | clickhouse-local -q "CREATE TABLE table (a Int64, b Int64 ## 实现细节 {#details-of-implementation} -- 可以并发执行多个 `SELECT` 查询,但 `INSERT` 查询会相互等待。 +- 可以同时执行多个 `SELECT` 查询,但 `INSERT` 查询将相互等待。 - 支持通过 `INSERT` 查询创建新文件。 -- 如果文件已存在,`INSERT` 将在其中追加新值。 +- 如果文件存在,`INSERT` 将在其中附加新值。 - 不支持: - - `ALTER` - - `SELECT ... SAMPLE` - - 索引 - - 复制 + - `ALTER` + - `SELECT ... SAMPLE` + - 索引 + - 复制 -## 分区 {#partition-by} +## PARTITION BY {#partition-by} -`PARTITION BY` — 可选。 可以通过对分区键进行分区,来创建单独的文件。在大多数情况下,您不需要分区键,如果需要,通常不需要比按月份更细粒度的分区。分区不会加速查询(与 ORDER BY 表达式相比)。您永远不应该使用过于细粒度的分区。不要按客户标识符或名称对数据进行分区(而是让客户标识符或名称成为 ORDER BY 表达式中的第一列)。 +`PARTITION BY` — 可选。可以通过在分区键上对数据进行分区来创建单独的文件。在大多数情况下,您不需要分区键,如果需要,通常不需要比按月更细粒度的分区。分区不会加速查询(与 `ORDER BY` 表达式相反)。您绝对不应使用过于细粒度的分区。不要根据客户标识符或名称对数据进行分区(而是将客户标识符或名称作为 `ORDER BY` 表达式中的第一列)。 -要按月份分区,请使用 `toYYYYMM(date_column)` 表达式,其中 `date_column` 是类型为 [Date](/sql-reference/data-types/date.md) 的日期列。此处分区名称采用 `"YYYYMM"` 格式。 +要按月分区,请使用 `toYYYYMM(date_column)` 表达式,其中 `date_column` 是类型为 [Date](/sql-reference/data-types/date.md) 的日期列。此处的分区名称具有 `"YYYYMM"` 格式。 ## 虚拟列 {#virtual-columns} - `_path` — 文件路径。类型:`LowCardinality(String)`。 - `_file` — 文件名。类型:`LowCardinality(String)`。 -- `_size` — 文件大小(以字节为单位)。类型:`Nullable(UInt64)`。如果大小未知,值为 `NULL`。 -- `_time` — 文件的最后修改时间。类型:`Nullable(DateTime)`。如果时间未知,值为 `NULL`。 +- `_size` — 文件大小(以字节为单位)。类型:`Nullable(UInt64)`。如果大小未知,则值为 `NULL`。 +- `_time` — 文件的最后修改时间。类型:`Nullable(DateTime)`。如果时间未知,则值为 `NULL`。 ## 设置 {#settings} -- [engine_file_empty_if_not_exists](/operations/settings/settings#engine_file_empty_if_not_exists) - 允许从不存在的文件中选择空数据。默认禁用。 -- [engine_file_truncate_on_insert](/operations/settings/settings#engine_file_truncate_on_insert) - 允许在插入之前截断文件。默认禁用。 -- [engine_file_allow_create_multiple_files](/operations/settings/settings.md#engine_file_allow_create_multiple_files) - 如果格式有后缀,则允许在每次插入时创建新文件。默认禁用。 -- [engine_file_skip_empty_files](/operations/settings/settings.md#engine_file_skip_empty_files) - 允许在读取时跳过空文件。默认禁用。 -- [storage_file_read_method](/operations/settings/settings.md#engine_file_empty_if_not_exists) - 从存储文件读取数据的方法,值为 `read`、`pread`、`mmap` 之一。mmap 方法不适用于 clickhouse-server(它用于 clickhouse-local)。默认值:对于 clickhouse-server 是 `pread`,对于 clickhouse-local 是 `mmap`。 +- [engine_file_empty_if_not_exists](/operations/settings/settings#engine_file_empty_if_not_exists) - 允许从不存在的文件中选择空数据。默认情况下禁用。 +- [engine_file_truncate_on_insert](/operations/settings/settings#engine_file_truncate_on_insert) - 允许在插入之前截断文件。默认情况下禁用。 +- [engine_file_allow_create_multiple_files](/operations/settings/settings.md#engine_file_allow_create_multiple_files) - 允许在每次插入时创建新文件(如果格式具有后缀)。默认情况下禁用。 +- [engine_file_skip_empty_files](/operations/settings/settings.md#engine_file_skip_empty_files) - 允许在读取时跳过空文件。默认情况下禁用。 +- [storage_file_read_method](/operations/settings/settings#engine_file_empty_if_not_exists) - 从存储文件读取数据的方法,选项之一:`read`、`pread`、`mmap`。mmap 方法不适用于 clickhouse-server(它是为 clickhouse-local 设计的)。默认值:clickhouse-server 为 `pread`,clickhouse-local 为 `mmap`。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/file.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/file.md.hash index ea06f6119d2..d612256cfb2 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/file.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/file.md.hash @@ -1 +1 @@ -320bc44b972e6a3a +e6e56e5abcb0607f diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/filelog.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/filelog.md index 87eda0061d0..1a9332fe790 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/filelog.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/filelog.md @@ -1,20 +1,21 @@ --- -'description': '该引擎允许将应用程序日志文件处理为记录流。' +'description': '该引擎允许将应用程序日志文件作为记录流进行处理。' 'sidebar_label': 'FileLog' 'sidebar_position': 160 'slug': '/engines/table-engines/special/filelog' 'title': 'FileLog 引擎' +'doc_type': 'reference' --- -# FileLog Engine {#filelog-engine} +# `FileLog` 引擎 {#filelog-engine} 该引擎允许将应用程序日志文件处理为记录流。 -`FileLog` 允许您: +`FileLog` 让您可以: - 订阅日志文件。 -- 在新记录追加到订阅的日志文件时处理这些记录。 +- 处理附加到订阅日志文件的新记录。 ## 创建表 {#creating-a-table} @@ -37,32 +38,32 @@ CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] 引擎参数: -- `path_to_logs` – 要订阅的日志文件的路径。它可以是包含日志文件的目录的路径,也可以是单个日志文件的路径。请注意,ClickHouse 仅允许 `user_files` 目录中的路径。 -- `format_name` - 记录格式。请注意,FileLog 将文件中的每一行作为单独的记录处理,而不是所有数据格式都适合它。 +- `path_to_logs` – 要订阅的日志文件的路径。可以是包含日志文件的目录路径或单个日志文件的路径。请注意,ClickHouse 仅允许路径在 `user_files` 目录内。 +- `format_name` - 记录格式。请注意,FileLog 将文件中的每一行作为单独的记录进行处理,并非所有数据格式都适合它。 可选参数: -- `poll_timeout_ms` - 从日志文件进行单次轮询的超时时间。默认值:[stream_poll_timeout_ms](../../../operations/settings/settings.md#stream_poll_timeout_ms)。 -- `poll_max_batch_size` — 单次轮询中最多获取的记录数量。默认值:[max_block_size](/operations/settings/settings#max_block_size)。 -- `max_block_size` — 单次轮询的最大批处理大小(以记录为单位)。默认值:[max_insert_block_size](../../../operations/settings/settings.md#max_insert_block_size)。 -- `max_threads` - 解析文件的最大线程数,默认值为 0,这意味着线程数为 max(1, physical_cpu_cores / 4)。 -- `poll_directory_watch_events_backoff_init` - 监视目录线程的初始休眠值。默认值:`500`。 -- `poll_directory_watch_events_backoff_max` - 监视目录线程的最大休眠值。默认值:`32000`。 -- `poll_directory_watch_events_backoff_factor` - 退避的速度,默认是指数型。默认值:`2`。 -- `handle_error_mode` — 处理 FileLog 引擎错误的方式。可能的值:default(如果无法解析消息,将抛出异常),stream(异常消息和原始消息将保存在虚拟列 `_error` 和 `_raw_message` 中)。 +- `poll_timeout_ms` - 从日志文件进行单次轮询的超时。默认值: [stream_poll_timeout_ms](../../../operations/settings/settings.md#stream_poll_timeout_ms). +- `poll_max_batch_size` — 单次轮询中要轮询的最大记录数。默认值: [max_block_size](/operations/settings/settings#max_block_size). +- `max_block_size` — 轮询的最大批处理大小(以记录为单位)。默认值: [max_insert_block_size](../../../operations/settings/settings.md#max_insert_block_size). +- `max_threads` - 解析文件的最大线程数,默认值为 0,表示数量将是 max(1, physical_cpu_cores / 4)。 +- `poll_directory_watch_events_backoff_init` - 监视目录线程的初始休眠值。默认值: `500`。 +- `poll_directory_watch_events_backoff_max` - 监视目录线程的最大休眠值。默认值: `32000`。 +- `poll_directory_watch_events_backoff_factor` - 回退速度,默认是指数形式。默认值: `2`。 +- `handle_error_mode` — FileLog 引擎的错误处理方式。可能的值:default(如果消息解析失败将抛出异常),stream(异常消息和原始消息将保存在虚拟列 `_error` 和 `_raw_message` 中)。 ## 描述 {#description} -传递的记录会自动跟踪,因此日志文件中的每一条记录只会被计算一次。 +已传递的记录会自动跟踪,因此日志文件中的每条记录只会被计数一次。 -`SELECT` 对于读取记录并不是特别有用(除非用于调试),因为每条记录只能读取一次。利用 [物化视图](../../../sql-reference/statements/create/view.md) 创建实时线程更为实用。为此: +`SELECT` 对于读取记录并不是特别有用(除非用于调试),因为每条记录只能读取一次。建立实时线程使用 [物化视图](../../../sql-reference/statements/create/view.md) 更为实用。为此: -1. 使用引擎创建一个 FileLog 表,并将其视为数据流。 -2. 创建一个具有所需结构的表。 -3. 创建一个物化视图,将引擎中的数据转换并放入先前创建的表中。 +1. 使用引擎创建一个 FileLog 表,并将其视为数据流。 +2. 创建一个具有所需结构的表。 +3. 创建一个物化视图,将来自引擎的数据转换并放入先前创建的表中。 -当 `MATERIALIZED VIEW` 连接到引擎时,它会在后台开始收集数据。这允许您不断从日志文件接收记录,并使用 `SELECT` 将其转换为所需格式。 -一个 FileLog 表可以有任意数量的物化视图,它们不会直接从表中读取数据,而是接收新记录(以块的形式),通过这种方式,您可以将数据写入多个具有不同细节级别的表(带分组 - 聚合和不带)。 +当 `MATERIALIZED VIEW` 连接引擎时,它会开始在后台收集数据。这使您能够不断接收来自日志文件的记录,并使用 `SELECT` 将其转换为所需格式。 +一个 FileLog 表可以拥有任意数量的物化视图,它们不会直接从表中读取数据,而是接收新记录(以块的形式),通过这种方式,您可以向多个表写入不同的细节级别(具有分组 - 聚合和不带分组)。 示例: @@ -80,7 +81,7 @@ CREATE TABLE daily ( ) ENGINE = SummingMergeTree(day, (day, level), 8192); CREATE MATERIALIZED VIEW consumer TO daily - AS SELECT toDate(toDateTime(timestamp)) AS day, level, count() as total + AS SELECT toDate(toDateTime(timestamp)) AS day, level, count() AS total FROM queue GROUP BY day, level; SELECT level, sum(total) FROM daily GROUP BY level; @@ -93,16 +94,16 @@ DETACH TABLE consumer; ATTACH TABLE consumer; ``` -如果您想通过 `ALTER` 更改目标表,我们建议禁用物化视图,以避免目标表和视图数据之间的不一致。 +如果您希望通过使用 `ALTER` 更改目标表,建议禁用物化视图,以避免目标表与视图中的数据之间的不一致。 ## 虚拟列 {#virtual-columns} -- `_filename` - 日志文件的名称。数据类型:`LowCardinality(String)`。 -- `_offset` - 日志文件中的偏移量。数据类型:`UInt64`。 +- `_filename` - 日志文件的名称。数据类型: `LowCardinality(String)`。 +- `_offset` - 日志文件中的偏移量。数据类型: `UInt64`。 -当 `handle_error_mode='stream'` 时的附加虚拟列: +当 `handle_error_mode='stream'` 时的额外虚拟列: -- `_raw_record` - 无法成功解析的原始记录。数据类型:`Nullable(String)`。 -- `_error` - 解析失败时发生的异常消息。数据类型:`Nullable(String)`。 +- `_raw_record` - 无法成功解析的原始记录。数据类型: `Nullable(String)`。 +- `_error` - 解析失败时发生的异常消息。数据类型: `Nullable(String)`。 注意:`_raw_record` 和 `_error` 虚拟列仅在解析期间发生异常时填充,当消息成功解析时,它们始终为 `NULL`。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/filelog.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/filelog.md.hash index 343dd7f83f9..a6cbfb2e990 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/filelog.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/filelog.md.hash @@ -1 +1 @@ -fac8b3dd9af57bae +5f99b11a18b45586 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/generate.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/generate.md index 05e4f6a8039..32e098c415f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/generate.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/generate.md @@ -1,16 +1,17 @@ --- -'description': 'GenerateRandom 表引擎为给定的表结构生成随机数据。' +'description': 'GenerateRandom 表引擎为给定的表架构生成随机数据。' 'sidebar_label': 'GenerateRandom' 'sidebar_position': 140 'slug': '/engines/table-engines/special/generate' 'title': 'GenerateRandom 表引擎' +'doc_type': 'reference' --- -The GenerateRandom 表引擎为给定的表模式生成随机数据。 +生成随机数据表引擎根据给定的表模式生成随机数据。 -使用示例: +用法示例: -- 在测试中使用,以填充可复现的大表。 +- 用于测试,以填充可重现的大表。 - 为模糊测试生成随机输入。 ## 在 ClickHouse 服务器中的使用 {#usage-in-clickhouse-server} @@ -19,11 +20,11 @@ The GenerateRandom 表引擎为给定的表模式生成随机数据。 ENGINE = GenerateRandom([random_seed [,max_string_length [,max_array_length]]]) ``` -`max_array_length` 和 `max_string_length` 参数分别指定生成数据中所有数组或映射列和字符串的最大长度。 +`max_array_length` 和 `max_string_length` 参数指定生成数据中所有数组或映射列和字符串的最大长度。 -Generate 表引擎仅支持 `SELECT` 查询。 +生成表引擎仅支持 `SELECT` 查询。 -它支持所有可以存储在表中的 [DataTypes](../../../sql-reference/data-types/index.md),但不包括 `AggregateFunction`。 +它支持所有可以存储在表中的 [DataTypes](../../../sql-reference/data-types/index.md),除了 `AggregateFunction`。 ## 示例 {#example} @@ -50,8 +51,8 @@ SELECT * FROM generate_engine_table LIMIT 3 ## 实现细节 {#details-of-implementation} - 不支持: - - `ALTER` - - `SELECT ... SAMPLE` - - `INSERT` - - 索引 - - 复制 + - `ALTER` + - `SELECT ... SAMPLE` + - `INSERT` + - 索引 + - 复制 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/generate.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/generate.md.hash index 6b2a3e1bf1f..d75f181304c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/generate.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/generate.md.hash @@ -1 +1 @@ -398be151ec5dff1b +ca23186276ce0e94 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/index.md index 431c81473e9..68d5b65d66b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/index.md @@ -1,9 +1,10 @@ --- -'description': 'Special 表引擎的文档' +'description': '特殊表引擎的文档' 'sidebar_label': 'Special' 'sidebar_position': 50 'slug': '/engines/table-engines/special/' 'title': '特殊表引擎' +'doc_type': 'reference' --- @@ -11,11 +12,11 @@ 表引擎主要分为三大类: -- [MergeTree 引擎系列](../../../engines/table-engines/mergetree-family/index.md) 用于主要的生产使用。 +- [MergeTree 引擎系列](../../../engines/table-engines/mergetree-family/index.md) 用于主要生产用途。 - [Log 引擎系列](../../../engines/table-engines/log-family/index.md) 用于小型临时数据。 -- [集成的表引擎](../../../engines/table-engines/integrations/index.md)。 +- [集成用表引擎](../../../engines/table-engines/integrations/index.md)。 -其余的引擎在其目的上是独特的,尚未分为系列,因此它们被放置在这个“特殊”类别中。 +其余的引擎在目的上是独特的,尚未分组为系列,因此它们被放置在这个“特殊”类别中。 + + +| 页面 | 描述 | +|-----|-----| +| [分布式表引擎](/engines/table-engines/special/distributed) | 使用分布式引擎的表不存储自己的任何数据,但允许在多个服务器上进行分布式查询处理。读取会自动并行化。在读取过程中,会使用远程服务器上的表索引(如果有的话)。 | +| [字典表引擎](/engines/table-engines/special/dictionary) | `Dictionary` 引擎将字典数据显示为 ClickHouse 表。 | +| [合并表引擎](/engines/table-engines/special/merge) | `Merge` 引擎(不要与 `MergeTree` 混淆)不存储数据本身,但允许同时从任何数量的其他表中读取。 | +| [可执行和可执行池表引擎](/engines/table-engines/special/executable) | `Executable` 和 `ExecutablePool` 表引擎允许您定义一个表,其行是从您定义的脚本生成的(通过将行写入 **stdout**)。 | +| [文件表引擎](/engines/table-engines/special/file) | 文件表引擎将数据保存在支持的文件格式之一的文件中(如 `TabSeparated`、`Native` 等)。 | +| [空表引擎](/engines/table-engines/special/null) | 当写入 `Null` 表时,数据会被忽略。当从 `Null` 表中读取时,响应为空。 | +| [集合表引擎](/engines/table-engines/special/set) | 始终驻留在内存中的数据集。它用于 `IN` 操作符的右侧。 | +| [连接表引擎](/engines/table-engines/special/join) | 用于 JOIN 操作的可选预准备数据结构。 | +| [URL 表引擎](/engines/table-engines/special/url) | 从远程 HTTP/HTTPS 服务器查询数据。该引擎类似于文件引擎。 | +| [视图表引擎](/engines/table-engines/special/view) | 用于实现视图(有关更多信息,请参见 `CREATE VIEW query`)。它不存储数据,只存储指定的 `SELECT` 查询。在从表中读取时,会运行此查询(并删除查询中所有不必要的列)。 | +| [内存表引擎](/engines/table-engines/special/memory) | 内存引擎将数据以未压缩形式存储在 RAM 中。数据以读取时接收到的完全相同的形式存储。换句话说,从此表读取是完全免费的。 | +| [缓冲表引擎](/engines/table-engines/special/buffer) | 在内存中缓冲要写入的数据,定期将其刷新到另一个表。在读取操作期间,数据同时从缓冲区和另一个表中读取。 | +| [别名表引擎](/en/engines/table-engines/special/alias) | 创建表的别名。 | +| [查询处理的外部数据](/engines/table-engines/special/external-data) | ClickHouse 允许向服务器发送处理查询所需的数据,以及 `SELECT` 查询。这些数据被放置在临时表中,可以在查询中使用(例如,在 `IN` 操作符中)。 | +| [生成随机表引擎](/engines/table-engines/special/generate) | GenerateRandom 表引擎为给定的表架构生成随机数据。 | +| [KeeperMap](/engines/table-engines/special/keeper-map) | 该引擎允许您使用 Keeper/ZooKeeper 集群作为一致的键值存储,具有可线性化写入和顺序一致读的特性。 | +| [文件日志引擎](/engines/table-engines/special/filelog) | 该引擎允许将应用程序日志文件作为记录流进行处理。 | + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/index.md.hash index 93bdb90031f..ab4142b3839 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/index.md.hash @@ -1 +1 @@ -1a91d5efc31561da +900f3897f9f368c8 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/join.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/join.md index 4a27312e46f..1c9875f5ef8 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/join.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/join.md @@ -1,20 +1,25 @@ --- -'description': '用于 JOIN 操作的可选准备数据结构。' +'description': '可选的准备数据结构,用于 JOIN 操作。' 'sidebar_label': 'Join' 'sidebar_position': 70 'slug': '/engines/table-engines/special/join' 'title': 'Join 表引擎' +'doc_type': 'reference' --- -# Join Table Engine +# `Join` 表引擎 -用于 [JOIN](/sql-reference/statements/select/join) 操作的可选预处理数据结构。 +用于 [JOIN](/sql-reference/statements/select/join) 操作的可选准备数据结构。 :::note 这不是关于 [JOIN 子句](/sql-reference/statements/select/join) 本身的文章。 ::: +:::note +在 ClickHouse Cloud 中,如果您的服务是使用早于 25.4 的版本创建的,您需要使用 `SET compatibility=25.4` 将兼容性设置为至少 25.4。 +::: + ## 创建表 {#creating-a-table} ```sql @@ -25,86 +30,86 @@ CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] ) ENGINE = Join(join_strictness, join_type, k1[, k2, ...]) ``` -查看 [CREATE TABLE](/sql-reference/statements/create/table) 查询的详细描述。 +请参阅 [CREATE TABLE](/sql-reference/statements/create/table) 查询的详细描述。 ## 引擎参数 {#engine-parameters} -### join_strictness {#join_strictness} +### `join_strictness` {#join_strictness} `join_strictness` – [JOIN 严格性](/sql-reference/statements/select/join#supported-types-of-join)。 -### join_type {#join_type} +### `join_type` {#join_type} `join_type` – [JOIN 类型](/sql-reference/statements/select/join#supported-types-of-join)。 -### 主键列 {#key-columns} +### 关键列 {#key-columns} -`k1[, k2, ...]` – 来自 `USING` 子句的主键列,进行 `JOIN` 操作。 +`k1[, k2, ...]` – `USING` 子句中的关键列,`JOIN` 操作使用这些列。 -在没有引号的情况下输入 `join_strictness` 和 `join_type` 参数,例如 `Join(ANY, LEFT, col1)`。它们必须与表将用于的 `JOIN` 操作匹配。如果参数不匹配,ClickHouse 不会抛出异常,可能会返回不正确的数据。 +输入 `join_strictness` 和 `join_type` 参数时请不带引号,例如 `Join(ANY, LEFT, col1)`。它们必须与将用于的 `JOIN` 操作相匹配。如果参数不匹配,ClickHouse 不会引发异常,可能会返回不正确的数据。 -## 特性和建议 {#specifics-and-recommendations} +## 具体细节和建议 {#specifics-and-recommendations} ### 数据存储 {#data-storage} -`Join` 表数据始终位于 RAM 中。当向表中插入行时,ClickHouse 会将数据块写入磁盘上的目录,以便在服务器重启时可以恢复。 +`Join` 表的数据始终位于 RAM 中。当向表中插入行时,ClickHouse 将数据块写入磁盘上的目录,以便在服务器重启时可以恢复。 -如果服务器错误地重启,磁盘上的数据块可能会丢失或损坏。在这种情况下,您可能需要手动删除包含损坏数据的文件。 +如果服务器不正确重启,磁盘上的数据块可能会丢失或损坏。在这种情况下,可能需要手动删除损坏数据的文件。 ### 选择和插入数据 {#selecting-and-inserting-data} -您可以使用 `INSERT` 查询向 `Join` 引擎表添加数据。如果表是使用 `ANY` 严格性创建的,则重复键的数据将被忽略。使用 `ALL` 严格性时,所有行都会被添加。 +您可以使用 `INSERT` 查询向 `Join` 引擎表添加数据。如果表是以 `ANY` 严格性创建的,则会忽略重复键的数据。使用 `ALL` 严格性时,所有行都会被添加。 -`Join` 引擎表的主要用例如下: +`Join` 引擎表的主要使用场景如下: - 将表放置在 `JOIN` 子句的右侧。 -- 调用 [joinGet](/sql-reference/functions/other-functions.md/#joinget) 函数,该函数允许您以与字典相同的方式从表中提取数据。 +- 调用 [joinGet](/sql-reference/functions/other-functions.md/#joinget) 函数,允许您以与从字典中提取数据相同的方式提取表中的数据。 ### 删除数据 {#deleting-data} -对于 `Join` 引擎表的 `ALTER DELETE` 查询实现为 [变更](/sql-reference/statements/alter/index.md#mutations)。`DELETE` 变更读取过滤后的数据,并覆盖内存和磁盘中的数据。 +对于 `Join` 引擎表,`ALTER DELETE` 查询作为 [变更](/sql-reference/statements/alter/index.md#mutations) 实现。`DELETE` 变更读取过滤后的数据并覆盖内存和磁盘中的数据。 ### 限制和设置 {#join-limitations-and-settings} -创建表时,应用以下设置: +创建表时应用以下设置: -#### join_use_nulls {#join_use_nulls} +#### `join_use_nulls` {#join_use_nulls} [join_use_nulls](/operations/settings/settings.md/#join_use_nulls) -#### max_rows_in_join {#max_rows_in_join} +#### `max_rows_in_join` {#max_rows_in_join} [max_rows_in_join](/operations/settings/settings#max_rows_in_join) -#### max_bytes_in_join {#max_bytes_in_join} +#### `max_bytes_in_join` {#max_bytes_in_join} [max_bytes_in_join](/operations/settings/settings#max_bytes_in_join) -#### join_overflow_mode {#join_overflow_mode} +#### `join_overflow_mode` {#join_overflow_mode} [join_overflow_mode](/operations/settings/settings#join_overflow_mode) -#### join_any_take_last_row {#join_any_take_last_row} +#### `join_any_take_last_row` {#join_any_take_last_row} [join_any_take_last_row](/operations/settings/settings.md/#join_any_take_last_row) -#### join_use_nulls {#join_use_nulls-1} +#### `join_use_nulls` {#join_use_nulls-1} -#### persistent {#persistent} +#### 持久性 {#persistent} -禁用 `Join` 和 [Set](/engines/table-engines/special/set.md) 表引擎的持久性。 +禁用 Join 和 [Set](/engines/table-engines/special/set.md) 表引擎的持久性。 -减少 I/O 开销。适用于追求性能且不需要持久性的场景。 +减少 I/O 开销。适合追求性能而不需要持久性的场景。 -可能的值: +可选值: -- 1 — 开启。 -- 0 — 关闭。 +- 1 — 启用。 +- 0 — 禁用。 默认值:`1`。 -`Join` 引擎表不能在 `GLOBAL JOIN` 操作中使用。 +`Join` 引擎表不能用于 `GLOBAL JOIN` 操作。 -`Join` 引擎允许在 `CREATE TABLE` 语句中指定 [join_use_nulls](/operations/settings/settings.md/#join_use_nulls) 设置。 [SELECT](/sql-reference/statements/select/index.md) 查询应具有相同的 `join_use_nulls` 值。 +`Join` 引擎允许在 `CREATE TABLE` 语句中指定 [join_use_nulls](/operations/settings/settings.md/#join_use_nulls) 设置。[SELECT](/sql-reference/statements/select/index.md) 查询应具有相同的 `join_use_nulls` 值。 ## 使用示例 {#example} @@ -142,7 +147,7 @@ SELECT * FROM id_val ANY LEFT JOIN id_val_join USING (id); └────┴─────┴─────────────────┘ ``` -作为替代,您可以指定连接键值从 `Join` 表中检索数据: +作为替代,您可以从 `Join` 表中检索数据,指定连接键值: ```sql SELECT joinGet('id_val_join', 'val', toUInt32(1)); @@ -154,7 +159,7 @@ SELECT joinGet('id_val_join', 'val', toUInt32(1)); └────────────────────────────────────────────┘ ``` -从 `Join` 表删除一行: +从 `Join` 表中删除一行: ```sql ALTER TABLE id_val_join DELETE WHERE id = 3; diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/join.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/join.md.hash index 9fd45ba5501..8f7ada9f6d4 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/join.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/join.md.hash @@ -1 +1 @@ -10e3a822f99b5edd +84bbd3da2b8ba7e6 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/keepermap.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/keepermap.md index b781ee5af4c..5b1904f1575 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/keepermap.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/keepermap.md @@ -1,17 +1,18 @@ --- -'description': '这个引擎允许你使用 Keeper/ZooKeeper 集群作为一致的键值存储,具有线性可写和顺序一致的读取。' +'description': '该引擎允许您使用 Keeper/ZooKeeper 集群作为一致的键值存储,具有线性化写入和顺序一致性读取。' 'sidebar_label': 'KeeperMap' 'sidebar_position': 150 'slug': '/engines/table-engines/special/keeper-map' 'title': 'KeeperMap' +'doc_type': 'reference' --- # KeeperMap {#keepermap} -这个引擎允许您将 Keeper/ZooKeeper 集群用作一致的键值存储,支持线性可写和顺序一致的读取。 +此引擎允许您使用 Keeper/ZooKeeper 集群作为一致的键值存储,具备线性可写和顺序一致的读取。 -要启用 KeeperMap 存储引擎,您需要使用 `` 配置定义存储表的 ZooKeeper 路径。 +要启用 KeeperMap 存储引擎,您需要使用 `` 配置定义一个 ZooKeeper 路径以存储表。 例如: @@ -21,7 +22,7 @@ ``` -其中路径可以是任何其他有效的 ZooKeeper 路径。 +其中路径可以是任何有效的 ZooKeeper 路径。 ## 创建表 {#creating-a-table} @@ -37,15 +38,15 @@ CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] 引擎参数: - `root_path` - 存储 `table_name` 的 ZooKeeper 路径。 -该路径不应包含由 `` 配置定义的前缀,因为前缀会自动附加到 `root_path`。 -此外,支持 `auxiliary_zookeeper_cluster_name:/some/path` 格式,其中 `auxiliary_zookeeper_cluster` 是在 `` 配置中定义的 ZooKeeper 集群。 +该路径不应包含由 `` 配置定义的前缀,因为前缀将自动附加到 `root_path`。 +此外,还支持 `auxiliary_zookeeper_cluster_name:/some/path` 格式,其中 `auxiliary_zookeeper_cluster` 是在 `` 配置中定义的 ZooKeeper 集群。 默认情况下,使用在 `` 配置中定义的 ZooKeeper 集群。 -- `keys_limit` - 表中允许的键的数量。 -此限制是一个软限制,在某些边缘情况下,表中可能会有更多键。 -- `primary_key_name` – 列表中的任何列名。 -- 必须指定 `primary key`,它仅支持主键中的一列。主键将在 ZooKeeper 中以二进制形式序列化为 `node name`。 -- 除主键外的列将按相应顺序序列化为二进制,并存储为由序列化键定义的结果节点的值。 -- 带有键 `equals` 或 `in` 过滤的查询将优化为从 `Keeper` 中进行多键查找,否则将获取所有值。 +- `keys_limit` - 允许在表中存在的键数。 +该限制是软限制,某些边缘情况下可能会有更多键进入表中。 +- `primary_key_name` – 列表中的任何列名称。 +- 必须指定 `primary key`,它仅支持在主键中使用一列。主键将在 ZooKeeper 中作为 `node name` 以二进制格式序列化。 +- 除主键外的列将按相应顺序序列化为二进制,并作为由序列化键定义的结果节点的值存储。 +- 具有键 `equals` 或 `in` 过滤的查询将被优化为从 `Keeper` 进行多键查找,否则将获取所有值。 示例: @@ -61,7 +62,7 @@ ENGINE = KeeperMap('/keeper_map_table', 4) PRIMARY KEY key ``` -使用 +与 ```xml @@ -69,19 +70,19 @@ PRIMARY KEY key ``` -每个值,作为 `(v1, v2, v3)` 的二进制序列化,将存储在 `Keeper` 中的 `/keeper_map_tables/keeper_map_table/data/serialized_key` 内。 -此外,键的数量将有一个软限制为 4。 +每个值,即 `(v1, v2, v3)` 的二进制序列化,将存储在 `Keeper` 的 `/keeper_map_tables/keeper_map_table/data/serialized_key` 中。 +此外,键的数量将有 4 的软限制。 -如果在同一 ZooKeeper 路径上创建多个表,则值将保持持久,直到至少有 1 个表在使用它。 +如果在同一 ZooKeeper 路径上创建多个表,这些值将被持久化,直到至少存在 1 个使用该路径的表。 因此,在创建表时可以使用 `ON CLUSTER` 子句,并共享来自多个 ClickHouse 实例的数据。 -当然,可以在不相关的 ClickHouse 实例上手动运行具有相同路径的 `CREATE TABLE`,以获得相同的数据共享效果。 +当然,也可以在不相关的 ClickHouse 实例上手动运行具有相同路径的 `CREATE TABLE` 来实现相同的数据共享效果。 ## 支持的操作 {#supported-operations} ### 插入 {#inserts} -当新行插入到 `KeeperMap` 时,如果键不存在,将为该键创建一个新条目。 -如果键存在,并且设置 `keeper_map_strict_mode` 被设置为 `true`,则抛出异常,否则,键的值将被覆盖。 +当新行插入 `KeeperMap` 中时,如果键不存在,将为该键创建一个新条目。 +如果键存在,并且设置 `keeper_map_strict_mode` 为 `true`,将抛出异常;否则,键的值将被覆盖。 示例: @@ -92,7 +93,7 @@ INSERT INTO keeper_map_table VALUES ('some key', 1, 'value', 3.2); ### 删除 {#deletes} 可以使用 `DELETE` 查询或 `TRUNCATE` 删除行。 -如果键存在,并且设置 `keeper_map_strict_mode` 被设置为 `true`,则仅在能够以原子方式执行时,获取和删除数据才会成功。 +如果键存在,并且设置 `keeper_map_strict_mode` 为 `true`,只有在可以原子执行时,才能成功获取和删除数据。 ```sql DELETE FROM keeper_map_table WHERE key LIKE 'some%' AND v1 > 1; @@ -109,7 +110,7 @@ TRUNCATE TABLE keeper_map_table; ### 更新 {#updates} 可以使用 `ALTER TABLE` 查询更新值。主键无法更新。 -如果设置 `keeper_map_strict_mode` 被设置为 `true`,则仅在以原子方式执行时,获取和更新数据才会成功。 +如果设置 `keeper_map_strict_mode` 为 `true`,只有在原子执行时,才能成功获取和更新数据。 ```sql ALTER TABLE keeper_map_table UPDATE v1 = v1 * 10 + 2 WHERE key LIKE 'some%' AND v3 > 3.1; diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/keepermap.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/keepermap.md.hash index 0ad37c0eaa5..6c5c75d05b8 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/keepermap.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/keepermap.md.hash @@ -1 +1 @@ -1c8f6004616bbfd4 +44df49e4c6c9a122 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/memory.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/memory.md index bbb7ccc0764..7d2624fb32a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/memory.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/memory.md @@ -1,48 +1,49 @@ --- -'description': 'Memory 引擎将数据存储在 RAM 中,以未压缩形式存储。数据以读取时接收的完全相同的形式存储。换句话说,从此表读取是完全免费的。' +'description': '内存引擎将数据存储在RAM中,未压缩的形式。数据以接收到的完全相同的形式存储。当读取时,换句话说,从这个表中读取是完全免费的。' 'sidebar_label': 'Memory' 'sidebar_position': 110 'slug': '/engines/table-engines/special/memory' 'title': '内存表引擎' +'doc_type': 'reference' --- -# Memory Table Engine +# 内存表引擎 :::note -在 ClickHouse Cloud 上使用 Memory 表引擎时,数据并不会跨所有节点复制(这是设计使然)。为了保证所有查询都路由到同一节点,并且 Memory 表引擎正常工作,您可以执行以下任一操作: +在 ClickHouse Cloud 上使用内存表引擎时,数据不会在所有节点之间复制(设计如此)。为了确保所有查询都路由到同一节点,并且内存表引擎按预期工作,您可以执行以下操作之一: - 在同一会话中执行所有操作 -- 使用支持 TCP 或原生接口的客户端(这启用粘性连接支持),例如 [clickhouse-client](/interfaces/cli) +- 使用 TCP 或本机接口(支持粘性连接)的客户端,例如 [clickhouse-client](/interfaces/cli) ::: -Memory 引擎将数据存储在 RAM 中,以未压缩的形式。数据以接收时的完全相同格式存储。换句话说,从这个表读取是完全免费的。 -并发数据访问是同步的。锁很短:读写操作不会相互阻塞。 +内存引擎将数据以未压缩的形式存储在 RAM 中。数据以接收时的确切形式存储。换句话说,从该表读取数据是完全免费的。 +并发数据访问是同步的。锁是短的:读写操作不会互相阻塞。 不支持索引。读取是并行化的。 -在简单查询中,最大生产力(超过 10 GB/sec)是通过避免从磁盘读取、解压缩或反序列化数据而实现的。(我们应该注意到,在许多情况下,MergeTree 引擎的生产力几乎也有这么高。) -重启服务器时,数据会从表中消失,表变为空。 -通常情况下,使用这种表引擎是没有必要的。然而,它可以用于测试,以及在相对较少的行(最多约 100,000,000 行)上需要最大速度的任务。 +在简单查询上,最大生产率(超过 10 GB/sec)是可以实现的,因为没有从磁盘读取、解压缩或反序列化数据。(我们应该注意,在许多情况下,MergeTree 引擎的生产率几乎与此相当。) +在重启服务器时,数据会从表中消失,表变为空。 +通常情况下,使用此表引擎是没有理由的。然而,它可以用于测试,以及需要在相对较少的行(最多大约 100,000,000 行)上实现最大速度的任务。 -系统使用 Memory 引擎进行带有外部查询数据的临时表(参见“处理查询的外部数据”一节),并用于实现 `GLOBAL IN`(参见“IN 操作符”一节)。 +系统使用内存引擎处理带有外部查询数据的临时表(请参阅“处理查询的外部数据”节),以及实现 `GLOBAL IN`(请参阅“IN 运算符”节)。 -可以指定上下限以限制 Memory 引擎表的大小,有效地使其作为循环缓冲区(参见 [Engine Parameters](#engine-parameters))。 +可以指定上下限来限制内存引擎表的大小,从而有效地允许它作为循环缓冲区(请参阅 [引擎参数](#engine-parameters))。 -## Engine Parameters {#engine-parameters} +## 引擎参数 {#engine-parameters} -- `min_bytes_to_keep` — 当内存表大小受限时,最小保留字节数。 +- `min_bytes_to_keep` — 当内存表大小达到上限时保留的最小字节数。 - 默认值: `0` - 需要 `max_bytes_to_keep` -- `max_bytes_to_keep` — 在内存表中保留的最大字节数,旧行在每次插入时被删除(即循环缓冲区)。如果要删除的旧批次行在添加大量数据块时低于 `min_bytes_to_keep` 限制,则最大字节可以超过所述限制。 +- `max_bytes_to_keep` — 在内存表中保留的最大字节数,其中最旧的行在每次插入时被删除(即循环缓冲区)。如果在添加一个大块时要删除的最旧行批次低于 `min_bytes_to_keep` 限制,则最大字节数可以超过规定的限制。 - 默认值: `0` -- `min_rows_to_keep` — 当内存表大小受限时,最小保留行数。 +- `min_rows_to_keep` — 当内存表大小达到上限时保留的最小行数。 - 默认值: `0` - 需要 `max_rows_to_keep` -- `max_rows_to_keep` — 在内存表中保留的最大行数,旧行在每次插入时被删除(即循环缓冲区)。如果要删除的旧批次行在添加大量数据块时低于 `min_rows_to_keep` 限制,则最大行数可以超过所述限制。 +- `max_rows_to_keep` — 在内存表中保留的最大行数,其中最旧的行在每次插入时被删除(即循环缓冲区)。如果在添加一个大块时要删除的最旧行批次低于 `min_rows_to_keep` 限制,则最大行数可以超过规定的限制。 - 默认值: `0` - `compress` - 是否压缩内存中的数据。 - 默认值: `false` -## Usage {#usage} +## 用法 {#usage} **初始化设置** ```sql @@ -54,9 +55,9 @@ CREATE TABLE memory (i UInt32) ENGINE = Memory SETTINGS min_rows_to_keep = 100, ALTER TABLE memory MODIFY SETTING min_rows_to_keep = 100, max_rows_to_keep = 1000; ``` -**注意:** `bytes` 和 `rows` 的限制参数可以同时设置,但将遵循 `max` 和 `min` 的下限。 +**注意:** `bytes` 和 `rows` 限制参数可以同时设置,但是将遵守 `max` 和 `min` 的下限。 -## Examples {#examples} +## 示例 {#examples} ```sql CREATE TABLE memory (i UInt32) ENGINE = Memory SETTINGS min_bytes_to_keep = 4096, max_bytes_to_keep = 16384; @@ -72,7 +73,7 @@ INSERT INTO memory SELECT * FROM numbers(9000, 1000); -- 8'192 bytes /* 4. checking a very large block overrides all */ INSERT INTO memory SELECT * FROM numbers(9000, 10000); -- 65'536 bytes -SELECT total_bytes, total_rows FROM system.tables WHERE name = 'memory' and database = currentDatabase(); +SELECT total_bytes, total_rows FROM system.tables WHERE name = 'memory' AND database = currentDatabase(); ``` ```text @@ -81,7 +82,7 @@ SELECT total_bytes, total_rows FROM system.tables WHERE name = 'memory' and data └─────────────┴────────────┘ ``` -还有,对于行: +同时,对于行: ```sql CREATE TABLE memory (i UInt32) ENGINE = Memory SETTINGS min_rows_to_keep = 4000, max_rows_to_keep = 10000; @@ -98,7 +99,7 @@ INSERT INTO memory SELECT * FROM numbers(9000, 1000); -- 1'000 rows /* 4. checking a very large block overrides all */ INSERT INTO memory SELECT * FROM numbers(9000, 10000); -- 10'000 rows -SELECT total_bytes, total_rows FROM system.tables WHERE name = 'memory' and database = currentDatabase(); +SELECT total_bytes, total_rows FROM system.tables WHERE name = 'memory' AND database = currentDatabase(); ``` ```text diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/memory.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/memory.md.hash index 69e3a865438..b5098a6213e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/memory.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/memory.md.hash @@ -1 +1 @@ -a364d9b151f456cd +0ed5fe47e4f3b1e8 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/merge.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/merge.md index 7e1b2973ddd..7b6283c4238 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/merge.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/merge.md @@ -1,60 +1,53 @@ --- -'description': '`Merge` 引擎 (不要与 `MergeTree` 混淆) 并不存储数据本身,而是允许同时从任意数量的其他表中读取数据。' +'description': '`Merge` 引擎(不要与 `MergeTree` 混淆)不自己存储数据,但允许同时从任意数量的其他表中读取.' 'sidebar_label': 'Merge' 'sidebar_position': 30 'slug': '/engines/table-engines/special/merge' 'title': 'Merge Table Engine' +'doc_type': 'reference' --- -# Merge Table Engine +# Merge 表引擎 -`Merge` 引擎(不要与 `MergeTree` 混淆)并不存储数据,而是允许同时从任意数量的其他表中读取数据。 +`Merge` 引擎(不应与 `MergeTree` 混淆)并不存储数据,而是允许同时从任意数量的其他表中读取。 -读取是自动并行化的。不支持向表中写入数据。读取时,将使用实际被读取的表的索引(如果存在)。 +读取自动并行化。不支持对表的写入。在读取时,如果存在的实际读取表的索引将被使用。 ## 创建表 {#creating-a-table} ```sql -CREATE TABLE ... Engine=Merge(db_name, tables_regexp [, table_to_write]) +CREATE TABLE ... Engine=Merge(db_name, tables_regexp) ``` ## 引擎参数 {#engine-parameters} -### db_name {#db_name} +### `db_name` {#db_name} `db_name` — 可能的值: - - 数据库名称, - - 返回数据库名称字符串的常量表达式,例如 `currentDatabase()`, - - `REGEXP(expression)`,其中 `expression` 是用于匹配数据库名称的正则表达式。 +- 数据库名称, +- 返回数据库名称字符串的常量表达式,例如 `currentDatabase()`, +- `REGEXP(expression)`,其中 `expression` 是用于匹配数据库名称的正则表达式。 -### tables_regexp {#tables_regexp} +### `tables_regexp` {#tables_regexp} -`tables_regexp` — 用于匹配指定数据库中的表名称的正则表达式。 +`tables_regexp` — 用于匹配指定数据库或数据库集中的表名称的正则表达式。 -正则表达式 — [re2](https://github.com/google/re2)(支持 PCRE 的一个子集),区分大小写。 -请参阅“匹配”部分关于正则表达式转义符号的说明。 +正则表达式 — [re2](https://github.com/google/re2)(支持 PCRE 的子集),区分大小写。 +请参阅“匹配”部分中关于转义符号的说明。 -### table_to_write {#table_to_write} +## 用法 {#usage} -`table_to_write` - 插入到 `Merge` 表时要写入的表名。 -可能的值: - - `'db_name.table_name'` - 插入到特定数据库中的特定表。 - - `'table_name'` - 插入到表 `db_name.table_name`。仅在第一个参数 `db_name` 不是正则表达式时允许。 - - `auto` - 插入到按字典顺序排列传递给 `tables_regexp` 的最后一个表。仅在第一个参数 `db_name` 不是正则表达式时允许。 +在选择要读取的表时,`Merge` 表本身不会被选择,即使它与正则表达式匹配。这是为了避免循环。 +创建两个 `Merge` 表,它们会无休止地尝试读取彼此数据的可能性是存在的,但这并不是一个好主意。 -## 使用方法 {#usage} - -在选择要读取的表时,即使 `Merge` 表匹配正则表达式,它本身也不会被选择。这是为了避免循环。 -可以创建两个 `Merge` 表,它们会互相尝试读取对方的数据,但这并不是一个好主意。 - -使用 `Merge` 引擎的典型方式是将大量的 `TinyLog` 表视为单个表进行操作。 +使用 `Merge` 引擎的典型方式是像处理一张单一表一样处理大量的 `TinyLog` 表。 ## 示例 {#examples} **示例 1** -考虑两个数据库 `ABC_corporate_site` 和 `ABC_store`。`all_visitors` 表将包含来自两个数据库中 `visitors` 表的 ID。 +考虑两个数据库 `ABC_corporate_site` 和 `ABC_store`。`all_visitors` 表将包含来自两个数据库中的 `visitors` 表的 ID。 ```sql CREATE TABLE all_visitors (id UInt32) ENGINE=Merge(REGEXP('ABC_*'), 'visitors'); @@ -62,7 +55,7 @@ CREATE TABLE all_visitors (id UInt32) ENGINE=Merge(REGEXP('ABC_*'), 'visitors'); **示例 2** -假设您有一个旧表 `WatchLog_old`,并决定在不将数据移动到新表 `WatchLog_new` 的情况下更改分区,因此您需要查看两个表中的数据。 +假设您有一个旧表 `WatchLog_old`,并决定在不将数据移动到新表 `WatchLog_new` 的情况下更改分区,并且您需要查看这两个表中的数据。 ```sql CREATE TABLE WatchLog_old(date Date, UserId Int64, EventType String, Cnt UInt64) @@ -73,7 +66,7 @@ CREATE TABLE WatchLog_new(date Date, UserId Int64, EventType String, Cnt UInt64) ENGINE=MergeTree PARTITION BY date ORDER BY (UserId, EventType) SETTINGS index_granularity=8192; INSERT INTO WatchLog_new VALUES ('2018-01-02', 2, 'hit', 3); -CREATE TABLE WatchLog as WatchLog_old ENGINE=Merge(currentDatabase(), '^WatchLog', 'WatchLog_new'); +CREATE TABLE WatchLog AS WatchLog_old ENGINE=Merge(currentDatabase(), '^WatchLog'); SELECT * FROM WatchLog; ``` @@ -87,29 +80,13 @@ SELECT * FROM WatchLog; └────────────┴────────┴───────────┴─────┘ ``` -插入到表 `WatchLog` 的内容将进入表 `WatchLog_new` -```sql -INSERT INTO WatchLog VALUES ('2018-01-03', 3, 'hit', 3); - -SELECT * FROM WatchLog_New; -``` - -```text -┌───────date─┬─UserId─┬─EventType─┬─Cnt─┐ -│ 2018-01-02 │ 2 │ hit │ 3 │ -└────────────┴────────┴───────────┴─────┘ -┌───────date─┬─UserId─┬─EventType─┬─Cnt─┐ -│ 2018-01-03 │ 3 │ hit │ 3 │ -└────────────┴────────┴───────────┴─────┘ -``` - ## 虚拟列 {#virtual-columns} -- `_table` — 包含读取数据的表的名称。类型:[String](../../../sql-reference/data-types/string.md)。 +- `_table` — 包含读取数据的表的名称。类型: [String](../../../sql-reference/data-types/string.md)。 - 您可以在 `WHERE/PREWHERE` 子句中设置对 `_table` 的常量条件(例如,`WHERE _table='xyz'`)。在这种情况下,仅对满足 `_table` 条件的表执行读取操作,因此 `_table` 列充当索引。 + 您可以在 `WHERE/PREWHERE` 子句中设置 `_table` 的常量条件(例如,`WHERE _table='xyz'`)。在这种情况下,读取操作仅针对满足 `_table` 条件的表进行,因此 `_table` 列充当索引。 -**另请参阅** +**另见** - [虚拟列](../../../engines/table-engines/index.md#table_engines-virtual_columns) - [merge](../../../sql-reference/table-functions/merge.md) 表函数 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/merge.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/merge.md.hash index 9ea895310c0..5632e332f76 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/merge.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/merge.md.hash @@ -1 +1 @@ -68825be57255da2c +a5eb357ccc1d81f4 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/null.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/null.md index 6a311361d85..59af83301e8 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/null.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/null.md @@ -1,16 +1,17 @@ --- -'description': '当写入 `Null` 表时,数据会被忽略。当从 `Null` 表读取时,响应为空。' +'description': '写入 `Null` 表时,数据会被忽略。从 `Null` 表中读取时,响应为空。' 'sidebar_label': 'Null' 'sidebar_position': 50 'slug': '/engines/table-engines/special/null' 'title': 'Null 表引擎' +'doc_type': 'reference' --- -# Null 表引擎 +# `Null` 表引擎 -在写入 `Null` 表时,数据会被忽略。在从 `Null` 表读取时,返回的响应是空的。 +写入 `Null` 表时,数据会被忽略。从 `Null` 表读取时,响应为空。 :::note -如果你在想为什么这有用,请注意你可以在 `Null` 表上创建物化视图。因此,写入表中的数据最终会影响视图,但原始的原始数据仍会被丢弃。 +如果您想知道这有什么用,请注意您可以在 `Null` 表上创建一个物化视图。因此,写入表中的数据将最终影响该视图,但原始的原始数据将仍然被丢弃。 ::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/null.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/null.md.hash index 90863020c5e..794202c7f18 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/null.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/null.md.hash @@ -1 +1 @@ -5c3da08a411765e5 +7899276c204c4e79 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/set.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/set.md index f82af7930bc..cd3c68e1a64 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/set.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/set.md @@ -1,36 +1,41 @@ --- -'description': '一个始终在RAM中的数据集。它旨在用于`IN`操作符的右侧。' +'description': '一个始终在RAM中的数据集。它旨在用于`IN` 操作符的右侧。' 'sidebar_label': '设置' 'sidebar_position': 60 'slug': '/engines/table-engines/special/set' 'title': '设置表引擎' +'doc_type': 'reference' --- # 设置表引擎 -一个始终存储在 RAM 中的数据集。它旨在用于 `IN` 运算符的右侧(请参阅“IN 运算符”部分)。 +:::note +在 ClickHouse Cloud 中,如果您的服务是在 25.4 之前的版本创建的,您需要使用 `SET compatibility=25.4` 将兼容性设置为至少 25.4。 +::: -您可以使用 `INSERT` 向表中插入数据。新元素将被添加到数据集中,而重复的元素将被忽略。 -但是您不能从表中执行 `SELECT`。检索数据的唯一方法是将其用作 `IN` 运算符的右半边。 +数据集始终驻留在 RAM 中。它旨在用于 `IN` 操作符的右侧(请参阅“IN 操作符”部分)。 -数据始终位于 RAM 中。对于 `INSERT`,插入的数据块也会写入磁盘上的表目录。当服务器启动时,这些数据会加载到 RAM 中。换句话说,重启后数据仍然保持原位。 +您可以使用 `INSERT` 向表中插入数据。新的元素将被添加到数据集中,而重复项将被忽略。 +但是,您不能从表中执行 `SELECT`。检索数据的唯一方法是在 `IN` 操作符的右半部分使用它。 -对于粗略的服务器重新启动,磁盘上的数据块可能会丢失或损坏。在后者的情况下,您可能需要手动删除损坏数据的文件。 +数据始终位于 RAM 中。对于 `INSERT`,插入的数据块也会写入磁盘上的表目录。当服务器启动时,这些数据会加载到 RAM 中。换句话说,重启后,数据仍然保持原位。 + +在粗暴的服务器重启中,磁盘上的数据块可能会丢失或损坏。在后一种情况下,您可能需要手动删除包含损坏数据的文件。 ### 限制和设置 {#join-limitations-and-settings} 创建表时,应用以下设置: -#### persistent {#persistent} +#### 持久性 {#persistent} 禁用 Set 和 [Join](/engines/table-engines/special/join) 表引擎的持久性。 -减少 I/O 开销。适用于追求性能且不需要持久性的场景。 +减少 I/O 开销。适合追求性能且不需要持久性的场景。 -可能的值: +可选值: - 1 — 启用。 - 0 — 禁用。 -默认值:`1`。 +默认值: `1`。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/set.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/set.md.hash index cd3e9087be1..c1ab75a404c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/set.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/set.md.hash @@ -1 +1 @@ -437af011ae7b9853 +be285876019209f9 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/url.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/url.md index 0077a7637a0..0b82f92f1bd 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/url.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/url.md @@ -1,25 +1,26 @@ --- -'description': '查询数据到/从远程 HTTP/HTTPS 服务器。这个引擎类似于 File 引擎。' +'description': '从远程 HTTP/HTTPS 服务器查询数据。这个引擎类似于 File 引擎。' 'sidebar_label': 'URL' 'sidebar_position': 80 'slug': '/engines/table-engines/special/url' 'title': 'URL 表引擎' +'doc_type': 'reference' --- -# URL 表引擎 +# `URL` 表引擎 从远程 HTTP/HTTPS 服务器查询数据。该引擎类似于 [File](../../../engines/table-engines/special/file.md) 引擎。 -语法:`URL(URL [,Format] [,CompressionMethod])` +语法: `URL(URL [,Format] [,CompressionMethod])` -- `URL` 参数必须符合统一资源定位符的结构。指定的 URL 必须指向一个使用 HTTP 或 HTTPS 的服务器。这不需要任何额外的头部来获取服务器的响应。 +- `URL` 参数必须符合统一资源定位符的结构。指定的 URL 必须指向使用 HTTP 或 HTTPS 的服务器。这不需要任何额外的头信息来获取服务器的响应。 -- `Format` 必须是 ClickHouse 可以在 `SELECT` 查询中使用的格式,如果需要,也可以在 `INSERT` 中使用。有关支持格式的完整列表,请参见 [Formats](/interfaces/formats#formats-overview)。 +- `Format` 必须是 ClickHouse 可以在 `SELECT` 查询中使用的格式,并在必要时用于 `INSERT`。有关支持的格式的完整列表,请参见 [Formats](/interfaces/formats#formats-overview)。 - 如果未指定此参数,ClickHouse 会根据 `URL` 参数的后缀自动检测格式。如果 `URL` 参数的后缀与任何支持的格式不匹配,则无法创建表。例如,对于引擎表达式 `URL('http://localhost/test.json')`,将应用 `JSON` 格式。 + 如果未指定此参数,ClickHouse 将自动从 `URL` 参数的后缀检测格式。如果 `URL` 参数的后缀与任何支持的格式不匹配,则无法创建表。例如,对于引擎表达式 `URL('http://localhost/test.json')`,应用 `JSON` 格式。 -- `CompressionMethod` 指示 HTTP 主体是否应该被压缩。如果启用压缩,通过 URL 引擎发送的 HTTP 数据包将包含 'Content-Encoding' 头,以指示使用的压缩方法。 +- `CompressionMethod` 指示 HTTP 正文是否应该被压缩。如果启用了压缩,URL 引擎发送的 HTTP 数据包将包含 'Content-Encoding' 头,以指示使用了哪种压缩方法。 要启用压缩,请首先确保 `URL` 参数指示的远程 HTTP 端点支持相应的压缩算法。 @@ -35,15 +36,15 @@ - none - auto -如果未指定 `CompressionMethod`,则默认为 `auto`。这意味着 ClickHouse 会根据 `URL` 参数的后缀自动检测压缩方法。如果后缀与上述列出的任何压缩方法匹配,则应用相应的压缩,否则将不启用压缩。 +如果未指定 `CompressionMethod`,则默认为 `auto`。这意味着 ClickHouse 会自动从 `URL` 参数的后缀检测压缩方法。如果后缀与上述列出任一压缩方法匹配,则应用相应的压缩,否则不会启用任何压缩。 -例如,对于引擎表达式 `URL('http://localhost/test.gzip')`,将应用 `gzip` 压缩方法,但对于 `URL('http://localhost/test.fr')`,由于后缀 `fr` 不匹配任何上述压缩方法,因此不会启用压缩。 +例如,对于引擎表达式 `URL('http://localhost/test.gzip')`,应用 `gzip` 压缩方法,但对于 `URL('http://localhost/test.fr')`,没有启用压缩,因为后缀 `fr` 不匹配上述任何压缩方法。 -## 使用方法 {#using-the-engine-in-the-clickhouse-server} +## 使用 {#using-the-engine-in-the-clickhouse-server} -`INSERT` 和 `SELECT` 查询将分别转换为 `POST` 和 `GET` 请求。为了处理 `POST` 请求,远程服务器必须支持 [Chunked transfer encoding](https://en.wikipedia.org/wiki/Chunked_transfer_encoding)。 +`INSERT` 和 `SELECT` 查询分别被转换为 `POST` 和 `GET` 请求。为了处理 `POST` 请求,远程服务器必须支持 [Chunked transfer encoding](https://en.wikipedia.org/wiki/Chunked_transfer_encoding)。 -您可以使用 [max_http_get_redirects](/operations/settings/settings#max_http_get_redirects) 设置限制 HTTP GET 重定向的最大跳转次数。 +您可以使用 [max_http_get_redirects](/operations/settings/settings#max_http_get_redirects) 设置限制最大 HTTP GET 重定向跳转次数。 ## 示例 {#example} @@ -54,7 +55,7 @@ CREATE TABLE url_engine_table (word String, value UInt64) ENGINE=URL('http://127.0.0.1:12345/', CSV) ``` -**2.** 使用标准 Python 3 工具创建一个基本 HTTP 服务器并启动它: +**2.** 使用标准的 Python 3 工具创建基本的 HTTP 服务器并启动它: ```python3 from http.server import BaseHTTPRequestHandler, HTTPServer @@ -91,17 +92,17 @@ SELECT * FROM url_engine_table ## 实现细节 {#details-of-implementation} -- 读写操作可以并行进行 +- 读取和写入可以并行进行 - 不支持: - - `ALTER` 和 `SELECT...SAMPLE` 操作。 - - 索引。 - - 复制。 + - `ALTER` 和 `SELECT...SAMPLE` 操作。 + - 索引。 + - 复制。 ## 虚拟列 {#virtual-columns} - `_path` — `URL` 的路径。类型:`LowCardinality(String)`。 - `_file` — `URL` 的资源名称。类型:`LowCardinality(String)`。 -- `_size` — 资源的大小(以字节为单位)。类型:`Nullable(UInt64)`。如果大小未知,则值为 `NULL`。 +- `_size` — 资源大小(字节)。类型:`Nullable(UInt64)`。如果大小未知,则值为 `NULL`。 - `_time` — 文件的最后修改时间。类型:`Nullable(DateTime)`。如果时间未知,则值为 `NULL`。 - `_headers` - HTTP 响应头。类型:`Map(LowCardinality(String), LowCardinality(String))`。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/url.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/url.md.hash index e518e4e8050..01e3d45b9b3 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/url.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/url.md.hash @@ -1 +1 @@ -e14293775456537d +cc7d4bb2308d2077 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/view.md b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/view.md index 7d557bab0a7..a6ffc8bcfef 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/view.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/view.md @@ -1,12 +1,13 @@ --- -'description': '用于实现视图(欲了解更多信息,请参见 `CREATE VIEW 查询`)。它不存储数据,而仅存储指定的 `SELECT` 查询。当从表中读取时,它运行此查询(并删除查询中所有不必要的列)。' +'description': '用于实现视图(有关更多信息,请参阅 `CREATE VIEW 查询`)。它不存储数据,而仅存储指定的 `SELECT` 查询。读取表时,它运行此查询(并删除查询中所有不必要的列)。' 'sidebar_label': '视图' 'sidebar_position': 90 'slug': '/engines/table-engines/special/view' 'title': '视图表引擎' +'doc_type': 'reference' --- -# View Table Engine +# 视图表引擎 -用于实现视图(更多信息,请参见 `CREATE VIEW query`)。它不存储数据,而只是存储指定的 `SELECT` 查询。在从表中读取时,它会运行此查询(并删除查询中所有不必要的列)。 +用于实现视图(有关更多信息,请参见 `CREATE VIEW 查询`)。它不存储数据,仅存储指定的 `SELECT` 查询。在读取表时,它会运行此查询(并删除查询中所有不必要的列)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/view.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/view.md.hash index 42b8b2dad49..cdf04101489 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/view.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/engines/table-engines/special/view.md.hash @@ -1 +1 @@ -d855be041d808fff +1b4faaa531ed564e diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/faq/general/columnar-database.md b/i18n/zh/docusaurus-plugin-content-docs/current/faq/general/columnar-database.md index e3d4d33b9c8..a34973fbef2 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/faq/general/columnar-database.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/faq/general/columnar-database.md @@ -3,7 +3,8 @@ 'title': '什么是列式数据库?' 'toc_hidden': true 'toc_priority': 101 -'description': '本页面描述了列式数据库是什么' +'description': '本页面描述了什么是列式数据库。' +'doc_type': 'reference' --- import Image from '@theme/IdealImage'; @@ -13,22 +14,22 @@ import ColumnOriented from '@site/static/images/column-oriented.gif'; # 什么是列式数据库? {#what-is-a-columnar-database} -列式数据库独立地存储每一列的数据。这允许仅针对在给定查询中使用的列从磁盘读取数据。代价是影响整个行的操作变得相对昂贵。列式数据库的同义词是列导向数据库管理系统。ClickHouse 是这样一个系统的典型例子。 +列式数据库独立存储每一列的数据。这允许仅从磁盘读取在任何给定查询中使用的那些列的数据。代价是影响整行的操作变得相对更昂贵。列式数据库的同义词是列导向数据库管理系统。ClickHouse 是这种系统的典型示例。 列式数据库的主要优势包括: -- 仅使用少量列的查询。 +- 只使用众多列中的少数几列的查询。 - 针对大量数据的聚合查询。 - 列式数据压缩。 -下面是传统行导向系统和列式数据库在构建报告时的区别示意图: +下面是传统行式系统与列式数据库在构建报告时的区别插图: -**传统行导向** - +**传统行式** + **列式** -列式数据库是分析应用的首选,因为它允许在表中包含许多列以备不时之需,但在读取查询执行时不为未使用的列付出代价(传统的 OLTP 数据库在查询时读取所有数据,因为数据是按行存储而不是按列存储的)。列导向数据库设计用于大数据处理和数据仓库,它们通常通过使用低成本硬件的分布式集群进行原生扩展,以增加吞吐量。ClickHouse 通过结合 [distributed](../../engines/table-engines/special/distributed.md) 和 [replicated](../../engines/table-engines/mergetree-family/replication.md) 表来实现这一点。 +列式数据库是分析应用的首选,因为它允许表中有许多列以备不时之需,但在读取查询执行时不会为未使用的列付出代价(传统的OLTP数据库在查询时读取所有数据,因为数据是按行存储的,而不是按列)。列导向数据库旨在处理大数据和数据仓库,它们通常采用低成本硬件的分布式集群来提高吞吐量。ClickHouse 通过结合 [distributed](../../engines/table-engines/special/distributed.md) 和 [replicated](../../engines/table-engines/mergetree-family/replication.md) 表来实现这一点。 -如果您想深入了解列式数据库的历史、它们与行导向数据库的不同之处以及列式数据库的使用案例,请参见 [列式数据库指南](https://clickhouse.com/engineering-resources/what-is-columnar-database)。 +如果您想深入了解列式数据库的历史、它们与行式数据库的区别以及列式数据库的用例,请参阅 [列式数据库指南](https://clickhouse.com/engineering-resources/what-is-columnar-database)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/faq/general/columnar-database.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/faq/general/columnar-database.md.hash index 87cf8c75250..bedd7018dad 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/faq/general/columnar-database.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/faq/general/columnar-database.md.hash @@ -1 +1 @@ -01baf6163d3274e0 +0e3eb3f47f2a3af8 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/faq/general/dbms-naming.md b/i18n/zh/docusaurus-plugin-content-docs/current/faq/general/dbms-naming.md index 1acd51a2d69..b3f3b2dfcbd 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/faq/general/dbms-naming.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/faq/general/dbms-naming.md @@ -4,18 +4,19 @@ 'toc_priority': 10 'slug': '/faq/general/dbms-naming' 'description': '了解 "ClickHouse" 是什么意思?' +'doc_type': 'reference' --- -# What Does "ClickHouse" Mean? {#what-does-clickhouse-mean} +# "ClickHouse" 的含义是什么? {#what-does-clickhouse-mean} -它是“**Click**stream”和“Data ware**House**”的结合。它来源于Yandex.Metrica最初的用例,当时ClickHouse被设计用来记录互联网上所有用户的点击行为,至今仍然履行这一职责。您可以在[ClickHouse history](../../about-us/history.md)页面上阅读更多关于这个用例的信息。 +它是“**Click**stream”和“Data ware**House**”的结合。它源于在 Yandex.Metrica 中的最初用例,在那里 ClickHouse 扮演着记录来自互联网的所有用户点击的角色,并且它仍然承担着这个任务。您可以在[ClickHouse 历史](../../about-us/history.md)页面上阅读更多关于此用例的信息。 -这种双重含义有两个后果: +这种两部分的含义有两个后果: -- 正确的书写方式是Click**H**ouse,H必须大写。 -- 如果需要缩写,使用**CH**。由于某些历史原因,在中国缩写为CK也很流行,这主要是因为早期关于ClickHouse的中文讲座使用了这种形式。 +- 唯一正确的书写方式是 Click**H**ouse,H 必须大写。 +- 如果您需要缩写,可以使用 **CH**。出于一些历史原因,在中国使用 CK 作为缩写也很流行,主要是因为有一个关于 ClickHouse 的中文演讲最初使用了这种形式。 :::info -在ClickHouse命名多年后,这种将两个有独立含义的词组合在一起的命名方式被卡内基梅隆大学的数据库副教授Andy Pavlo在一项[研究中](https://www.cs.cmu.edu/~pavlo/blog/2020/03/on-naming-a-database-management-system.html)强调为命名数据库的最佳方式。ClickHouse与Postgres分享了他“有史以来最佳数据库名称”奖。 +在 ClickHouse 命名多年后,这种将两个各自有意义单词组合的方法在[Andy Pavlo 的研究](https://www.cs.cmu.edu/~pavlo/blog/2020/03/on-naming-a-database-management-system.html)中被强调为命名数据库的最佳方式,他是卡内基梅隆大学的数据库副教授。ClickHouse 与 Postgres 共享了他“有史以来最佳数据库名称”的奖项。 ::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/faq/general/dbms-naming.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/faq/general/dbms-naming.md.hash index 3d9ab2e5053..139294d82a6 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/faq/general/dbms-naming.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/faq/general/dbms-naming.md.hash @@ -1 +1 @@ -3e23b89d13268e75 +62b249903fe56820 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/faq/general/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/faq/general/index.md index fc0c248a957..7279ab01c07 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/faq/general/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/faq/general/index.md @@ -8,22 +8,23 @@ - 'what is' 'title': '关于 ClickHouse 的常见问题' 'description': '索引页面列出关于 ClickHouse 的常见问题' +'doc_type': 'landing-page' --- -# 关于 ClickHouse 的常见问题 +# 一般关于 ClickHouse 的问题 - [什么是 ClickHouse?](../../intro.md) -- [为什么 ClickHouse 这么快?](../../concepts/why-clickhouse-is-so-fast.md) +- [为什么 ClickHouse 这么快?](../../concepts/why-clickhouse-is-so-fast.mdx) - [谁在使用 ClickHouse?](../../faq/general/who-is-using-clickhouse.md) - [“ClickHouse”是什么意思?](../../faq/general/dbms-naming.md) - [“Не тормозит”是什么意思?](../../faq/general/ne-tormozit.md) - [什么是 OLAP?](../../faq/general/olap.md) - [什么是列式数据库?](../../faq/general/columnar-database.md) - [我该如何选择主键?](../../guides/best-practices/sparse-primary-indexes.md) -- [为什么不使用像 MapReduce 这样的东西?](../../faq/general/mapreduce.md) +- [为什么不使用类似 MapReduce 的东西?](../../faq/general/mapreduce.md) - [我如何为 ClickHouse 贡献代码?](/knowledgebase/how-do-i-contribute-code-to-clickhouse) -:::info 没有找到您要找的内容? -请查看我们的 [知识库](/knowledgebase/) 以及这里文档中提供的许多有用文章。 +:::info 看不到您想要的内容? +请查看我们的 [知识库](/knowledgebase/) ,并浏览文档中众多有用的文章。 ::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/faq/general/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/faq/general/index.md.hash index 77464e7ed72..52122147391 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/faq/general/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/faq/general/index.md.hash @@ -1 +1 @@ -0fb0bd4d6d7b4421 +850fadb2fcabdf49 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/faq/general/mapreduce.md b/i18n/zh/docusaurus-plugin-content-docs/current/faq/general/mapreduce.md index ef3b7709a1d..fb3a394ecc8 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/faq/general/mapreduce.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/faq/general/mapreduce.md @@ -3,16 +3,17 @@ 'title': '为什么不使用像 MapReduce 这样的东西?' 'toc_hidden': true 'toc_priority': 110 -'description': '本页面解释了为什么您会选择 ClickHouse 而不是 MapReduce' +'description': '本页解释了您为什么会选择 ClickHouse 而不是 MapReduce' 'keywords': - 'MapReduce' +'doc_type': 'reference' --- -# 为什么不使用类似MapReduce的东西? {#why-not-use-something-like-mapreduce} +# 为什么不使用类似 MapReduce 的东西? {#why-not-use-something-like-mapreduce} -我们可以将像MapReduce这样的系统称为分布式计算系统,其中reduce操作基于分布式排序。这类系统中最常见的开源解决方案是 [Apache Hadoop](http://hadoop.apache.org)。 +我们可以将类似 MapReduce 的系统称为分布式计算系统,其中 reduce 操作基于分布式排序。在这个类别中,最常见的开源解决方案是 [Apache Hadoop](http://hadoop.apache.org)。 -由于延迟较高,这些系统不适合用于在线查询。换句话说,它们不能用作Web界面的后端。这类系统对于实时数据更新并不实用。如果操作的结果及所有中间结果(如果有的话)都位于单个服务器的RAM中,那么分布式排序并不是执行reduce操作的最佳方式,这通常是在线查询的情况。在这种情况下,哈希表是执行reduce操作的最佳方法。优化map-reduce任务的常见方法是使用RAM中的哈希表进行预聚合(部分reduce)。用户手动执行此优化。在运行简单的map-reduce任务时,分布式排序是导致性能降低的主要原因之一。 +由于其高延迟,这些系统不适合在线查询。换句话说,它们不能作为 Web 界面的后端。这些类型的系统对实时数据更新没有用处。如果操作的结果和所有中间结果(如果有的话)位于单个服务器的 RAM 中,那么分布式排序并不是执行 reduce 操作的最佳方式,而这通常是在线查询的情况。在这种情况下,哈希表是执行 reduce 操作的最佳方法。优化 map-reduce 任务的一种常见方法是在 RAM 中使用哈希表进行预聚合(部分 reduce)。用户手动执行此优化。在运行简单的 map-reduce 任务时,分布式排序是导致性能降低的主要原因之一。 -大多数MapReduce实现允许您在集群上执行任意代码。但是,声明性查询语言更适合OLAP,以便快速运行实验。例如,Hadoop具有Hive和Pig。还可以考虑Cloudera Impala或Spark的Shark(已过时),以及Spark SQL、Presto和Apache Drill。在运行此类任务时,性能相对于专用系统来说极其不理想,但相对较高的延迟使得这些系统作为Web界面的后端变得不切实际。 +多数 MapReduce 实现允许你在集群上执行任意代码。但声明性查询语言更适合于 OLAP,以便快速运行实验。例如,Hadoop 有 Hive 和 Pig。还可以考虑 Cloudera Impala 或 Shark(过时)用于 Spark,以及 Spark SQL、Presto 和 Apache Drill。在运行这些任务时,性能相较于专门的系统非常不理想,但相对较高的延迟使得使用这些系统作为 Web 界面的后端不切实际。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/faq/general/mapreduce.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/faq/general/mapreduce.md.hash index d054ed3e066..c9b2ad96aa4 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/faq/general/mapreduce.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/faq/general/mapreduce.md.hash @@ -1 +1 @@ -61580d7afdf44cc0 +f6a4f971dcc4eeff diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/faq/general/ne-tormozit.md b/i18n/zh/docusaurus-plugin-content-docs/current/faq/general/ne-tormozit.md index 72939ef58d1..8d18dddc93e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/faq/general/ne-tormozit.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/faq/general/ne-tormozit.md @@ -3,31 +3,32 @@ 'title': '“не тормозит”是什么意思?' 'toc_hidden': true 'toc_priority': 11 -'description': '此页面解释了“Не тормозит”是什么意思' +'description': '本页面解释了“Не тормозит”的含义' 'keywords': - 'Yandex' +'doc_type': 'reference' --- # "Не тормозит"是什么意思? {#what-does-ne-tormozit-mean} -当人们看到复古的(限量生产)ClickHouse T恤时,我们经常会收到这个问题。它们的正面印着大大的**“ClickHouse не тормозит”**字样。 +当人们看到复古(限量生产)ClickHouse T恤时,我们经常会收到这个问题。它们的前面用大字号的粗体字写着**"ClickHouse не тормозит"**。 -在ClickHouse成为开源之前,它是由一家大型欧洲IT公司[ Yandex](https://yandex.com/company/)开发的内部存储系统。因此,它最初在西里尔字母中得到了这个口号,即“не тормозит”(发音为“ne tormozit”)。在开源发布之后,我们首先为本地活动生产了一些这样的T恤,使用这个口号毫无疑问是明智的选择。 +在ClickHouse开源之前,它是由一家大型欧洲IT公司[“Yandex”](https://yandex.com/company/)开发的内部存储系统。因此,它最初得到了用西里尔字母书写的口号“не тормозит”(发音为“ne tormozit”)。开源发布后,我们首次为当地活动制作了一些这样的T恤,并毫不犹豫地使用了这个口号。 -第二批这些T恤本应该在国际活动中赠送,我们试图制作一个口号的英文版本。 -不幸的是,我们就是想不出一个响亮的英文等价词。原句的表达优雅而简洁,而T恤上的空间限制使我们未能找到一个足够好的翻译,因为大多数选项要么太长,要么不准确。 -我们决定在为国际活动生产的T恤上仍然保留这个口号。这似乎是一个伟大的决定,因为全世界的人在看到它时都感到非常惊讶和好奇。 +第二批这些T恤计划在国际活动中赠送,我们尝试制作这个口号的英文版本。 +不幸的是,我们无法找到一个引人注目的英文等效表达。原句优雅且简练,而T恤上的空间限制使我们无法找到一个足够好的翻译,因为大多数选项似乎太长或不准确。 +我们决定继续在为国际活动制作的T恤上保持这个口号。这被证明是一个很好的决定,因为世界各地的人们在看到它时都感到惊讶和好奇。 -那么,它是什么意思呢?以下是一些翻译*“не тормозит”*的方法: +那么,它的意思是什么?以下是*“не тормозит”*的一些翻译方式: -- 如果字面翻译,它听起来像*“ClickHouse不踩刹车”*。 -- 更短,但不太精准的翻译可能是*“ClickHouse不慢”*、*“ClickHouse不延迟”*或者仅仅是*“ClickHouse快”*。 +- 如果字面翻译,它听起来像是*“ClickHouse不踩刹车踏板”*。 +- 更简短但不够精确的翻译可能是*“ClickHouse不慢”*、*“ClickHouse不滞后”*或简单的*“ClickHouse很快”*。 -如果你还没有亲眼见过这些T恤,可以在许多与ClickHouse有关的视频中在线查看它们。例如,下面这个: +如果您还没有亲眼见过这些T恤,您可以在许多与ClickHouse相关的视频中在线查看它们。例如,这个:
-_P.S. 这些T恤不出售_,它们是在一些[ClickHouse Meetup](https://www.meetup.com/pro/clickhouse/)上免费赠送的,通常作为最佳提问或其他积极参与形式的礼物。现在,这些T恤不再生产,已成为备受追捧的收藏品。 +_P.S. 这些T恤不是售卖的_,它们是免费的,在一些[ClickHouse Meetups](https://www.meetup.com/pro/clickhouse/)上赠送,通常作为最佳问题或其他积极参与形式的礼物。现在,这些T恤不再生产,它们已成为非常珍贵的收藏品。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/faq/general/ne-tormozit.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/faq/general/ne-tormozit.md.hash index 737348dd3a3..8a28faeea94 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/faq/general/ne-tormozit.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/faq/general/ne-tormozit.md.hash @@ -1 +1 @@ -76e42b9f7862b46e +5c690bb06c75e997 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/faq/general/olap.md b/i18n/zh/docusaurus-plugin-content-docs/current/faq/general/olap.md index 490b00eac81..8edb9cd3363 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/faq/general/olap.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/faq/general/olap.md @@ -3,42 +3,43 @@ 'title': '什么是 OLAP?' 'toc_hidden': true 'toc_priority': 100 -'description': '关于 Online Analytical Processing 的解释' +'description': '关于在线分析处理的解释' 'keywords': - 'OLAP' +'doc_type': 'reference' --- -# 什么是 OLAP? {#what-is-olap} +# 什么是 OLAP? {#what-is-olap} -[OLAP](https://en.wikipedia.org/wiki/Online_analytical_processing) 代表在线分析处理。它是一个广泛的术语,可以从两个角度来看待:技术和商业。但是从高层次来看,你可以将这些词反向阅读: +[OLAP](https://en.wikipedia.org/wiki/Online_analytical_processing) 代表联机分析处理(Online Analytical Processing)。这是一个广泛的术语,可以从两个视角来看:技术和业务。但是从高层次来看,你可以反向理解这些词: 处理 -: 一些源数据正在被处理... +:一些源数据被处理... 分析 -: ...以生成一些分析报告和洞察... +:...以生成一些分析报告和见解... 在线 -: ...实时处理。 +:...实时进行。 ## 从商业角度看 OLAP {#olap-from-the-business-perspective} -近年来,商界人士开始意识到数据的价值。盲目做出决策的公司往往无法跟上竞争的步伐。成功公司的数据驱动方法迫使他们收集所有可能在做出商业决策时远程有用的数据,并需要及时分析数据的机制。这就是 OLAP 数据库管理系统 (DBMS) 的用武之地。 +近年来,商业人士开始意识到数据的价值。盲目做出决策的公司,往往未能跟上竞争的步伐。成功公司的数据驱动方法迫使他们收集所有可能对业务决策有用的数据,并需要及时分析这些数据的机制。这就是 OLAP 数据库管理系统(DBMS)发挥作用的地方。 -在商业意义上,OLAP 允许公司持续规划、分析和报告运营活动,从而最大化效率、减少开支,并最终征服市场份额。这可以在内部系统中完成,或者外包给像网络/移动分析服务、CRM 服务等 SaaS 提供商。OLAP 是许多 BI 应用程序(商业智能)背后的技术。 +从商业意义上讲,OLAP 允许公司持续规划、分析和报告操作活动,从而最大化效率、减少开支,并最终征服市场份额。这可以在内部系统中完成,也可以外包给 SaaS 提供商,如网络/移动分析服务、客户关系管理服务等。OLAP 是许多商业智能应用程序(Business Intelligence)的技术基础。 -ClickHouse 是一个 OLAP 数据库管理系统,通常作为分析特定域数据的 SaaS 解决方案的后端。然而,一些企业仍然不愿与第三方提供商共享他们的数据,自建数据仓库的场景也是可行的。 +ClickHouse 是一个 OLAP 数据库管理系统,通常用作分析特定领域数据的 SaaS 解决方案的后端。然而,一些公司仍然不愿与第三方提供商共享数据,内部数据仓库的模式也是可行的。 ## 从技术角度看 OLAP {#olap-from-the-technical-perspective} -所有数据库管理系统都可以分为两类:OLAP(在线**分析**处理)和 OLTP(在线**事务**处理)。前者专注于构建报告,每个报告基于大量历史数据,但频率不高。而后者通常处理持续的事务流,不断修改数据的当前状态。 +所有数据库管理系统可以分为两组:OLAP(联机**分析**处理)和 OLTP(联机**事务**处理)。前者专注于构建基于历史数据的大型报告,但执行频率不高。而后者通常处理持续不断的事务流,不断修改数据的当前状态。 -在实践中,OLAP 和 OLTP 并不是类别,更像是一个光谱。大多数真实系统通常专注于其中一个,但提供一些解决方案或权宜之计,如果也需要另一种类型的工作负载。这种情况通常迫使企业运营多个集成的存储系统,这可能不是大问题,但拥有更多的系统使维护成本更高。因此,近年来的趋势是 HTAP(**混合事务/分析处理**),当两种工作负载都能被单一数据库管理系统同样良好地处理时。 +在实践中,OLAP 和 OLTP 不是类别,更像是一个光谱。大多数真实系统通常专注于其中一种,但如果还需要相反类型的工作负载,它们也提供一些解决方案或变通方法。这种情况常常迫使企业操作多个集成的存储系统,这可能不是大问题,但拥有更多系统使维护成本更高。因此,近年来的趋势是 HTAP(**混合事务/分析处理**),当单一数据库管理系统能同样良好地处理两种类型的工作负载。 -即使一个 DBMS 最初是作为纯 OLAP 或纯 OLTP 开始的,它们也被迫朝着 HTAP 的方向发展,以跟上竞争。而 ClickHouse 也不例外,最初它被设计为 [尽可能快的 OLAP 系统](../../concepts/why-clickhouse-is-so-fast.md),并且它仍然没有全面的事务支持,但一些特性如一致的读/写和更新/删除数据的变更功能不得不被添加。 +即使一个 DBMS 最初是作为纯 OLAP 或纯 OLTP 启动的,它们也被迫向 HTAP 方向发展,以跟上竞争。ClickHouse 也不例外,最初它被设计为一个 [尽可能快速的 OLAP 系统](../../concepts/why-clickhouse-is-so-fast.mdx),并且它仍然不具备完整的事务支持,但一些特性如一致的读写和更新/删除数据的变更操作被添加了进来。 -OLAP 和 OLTP 系统之间的根本权衡仍然存在: +OLAP 和 OLTP 系统之间的基本权衡仍然是: -- 高效生成分析报告的关键是能够独立读取列,因此大多数 OLAP 数据库是 [列式](../../faq/general/columnar-database.md), -- 而将列单独存储会增加对行的操作成本,例如追加或就地修改,这与列的数量成正比(如果系统试图收集事件的所有细节以防万一,则可以非常庞大)。因此,大多数 OLTP 系统将数据按行排列存储。 +- 高效构建分析报告,能够单独读取列是至关重要的,因此大多数 OLAP 数据库是 [列式](../../faq/general/columnar-database.md) 的, +- 而分开存储列会增加对行进行操作(如追加或就地修改)的成本,比例上与列的数量成正比(如果系统试图收集事件的所有细节以防万一,这个数量可以非常庞大)。因此,大多数 OLTP 系统以行为单位存储数据。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/faq/general/olap.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/faq/general/olap.md.hash index 108ea9f8d5f..ad5f4906ef0 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/faq/general/olap.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/faq/general/olap.md.hash @@ -1 +1 @@ -6656d0bb7ec84bd6 +d82bba13cf0d0be3 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/faq/general/who-is-using-clickhouse.md b/i18n/zh/docusaurus-plugin-content-docs/current/faq/general/who-is-using-clickhouse.md index 12971d07c4d..6d4370933d6 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/faq/general/who-is-using-clickhouse.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/faq/general/who-is-using-clickhouse.md @@ -6,19 +6,20 @@ 'description': '描述谁在使用 ClickHouse' 'keywords': - 'customer' +'doc_type': 'reference' --- -# Who is using ClickHouse? {#who-is-using-clickhouse} +# 谁在使用 ClickHouse? {#who-is-using-clickhouse} -作为一个开源产品,这个问题并不是那么简单。你不必告诉任何人如果你想开始使用 ClickHouse,你只需获取源代码或预编译的包。没有合同需要签署,而[Apache 2.0 许可](https://github.com/ClickHouse/ClickHouse/blob/master/LICENSE)允许无限制的软件分发。 +作为一个开源产品,这个问题并不容易回答。如果你想开始使用 ClickHouse,完全不需要告诉任何人,你只需获取源代码或预编译的包。没有需要签署的合同,[Apache 2.0 许可证](https://github.com/ClickHouse/ClickHouse/blob/master/LICENSE) 允许不受限制的软件分发。 -此外,技术栈通常在保密协议 (NDA) 涉及的灰色区域内。一些公司认为他们使用的技术是竞争优势,即使它们是开源的,也不允许员工公开分享任何细节。有些公司看到一些公关风险,仅在获得公关部门批准后,允许员工分享实施细节。 +此外,技术栈通常处于 NDA 保护的灰色地带。一些公司认为他们使用的技术是竞争优势,即使这些技术是开源的,也不允许员工公开分享任何细节。有些公司则担心公共关系风险,只允许员工在获得公关部门批准后分享实现细节。 那么,如何判断谁在使用 ClickHouse 呢? -一种方式是**询问周围的人**。如果不是书面形式,人们更愿意分享他们公司使用的技术、使用案例、使用的硬件类型、数据量等。我们定期与全球各地的用户在[ClickHouse Meetups](https://www.youtube.com/channel/UChtmrD-dsdpspr42P_PyRAw/playlists)进行交流,并听到关于1000多家使用ClickHouse的公司的故事。不幸的是,这些故事不能被重复,我们试图将这些故事视为在 NDA 下讲述的,以避免潜在的麻烦。但你可以参加我们未来的任何聚会,自己与其他用户交谈。有多种方式来宣布聚会,比如,你可以订阅[我们的 Twitter](http://twitter.com/ClickHouseDB/)。 +一种方法是 **问问周围的人**。如果没有书面形式,大家通常更愿意分享他们公司使用的技术、使用案例、所用硬件、数据量等。我们在全球范围内的[ClickHouse 见面会上](https://www.youtube.com/channel/UChtmrD-dsdpspr42P_PyRAw/playlists) 定期与用户交流,听说过1000多家公司使用 ClickHouse。遗憾的是,这些故事并不是可复现的,我们尽量将这些故事视为在 NDA 保护下所述,以避免任何潜在的麻烦。不过,你可以参加我们未来的任何一次见面会,与其他用户自行交流。见面会的公告方式有很多,例如,你可以关注[我们的 Twitter](http://twitter.com/ClickHouseDB/)。 -第二种方式是寻找**公开表示**使用 ClickHouse 的公司。因为通常会有一些硬证据,例如博客文章、演讲视频录制、幻灯片等,这种信息更为实质。我们在我们的 **[Adopters](../../about-us/adopters.md)** 页面上收集了此类证据的链接合集。欢迎你分享你雇主的故事或你偶然发现的一些链接(但尽量不要在此过程中违反你的 NDA)。 +第二种方法是寻找 **公开表示** 使用 ClickHouse 的公司。这更为实质,因为通常有一些确凿的证据,如博客文章、讲座视频记录、幻灯片等。我们在 **[采纳者](../../about-us/adopters.md)** 页面上收集了这些证据的链接。欢迎贡献你雇主的故事或你偶然发现的一些链接(但请尽量不要在此过程中违反你的 NDA)。 -你可以在采纳者列表中找到一些非常大的公司的名字,例如 Bloomberg、Cisco、中国电信、腾讯或 Lyft,但通过第一种方法,我们发现还有更多公司。例如,如果查看[福布斯(2020)列出的最大 IT 公司名单](https://www.forbes.com/sites/hanktucker/2020/05/13/worlds-largest-technology-companies-2020-apple-stays-on-top-zoom-and-uber-debut/),其中一半以上以某种方式使用 ClickHouse。此外,不提及[Yandex](../../about-us/history.md)将是不公平的,这家公司最初在2016年开源了 ClickHouse,并且是欧洲最大的 IT 公司之一。 +在采纳者名单中,你可以找到一些大型公司的名字,如 Bloomberg、Cisco、中国电信、腾讯或 Lyft,但是通过第一种方法,我们发现还有更多。例如,如果你查看[福布斯(2020)列出的最大 IT 公司名单](https://www.forbes.com/sites/hanktucker/2020/05/13/worlds-largest-technology-companies-2020-apple-stays-on-top-zoom-and-uber-debut/),其中超过一半以某种方式使用 ClickHouse。此外,不能不提到[雅虎](../../about-us/history.md),这家公司于2016年最早将 ClickHouse 开源,并且恰好是欧洲最大的 IT 公司之一。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/faq/general/who-is-using-clickhouse.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/faq/general/who-is-using-clickhouse.md.hash index b30b0b8b079..ef99800a8be 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/faq/general/who-is-using-clickhouse.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/faq/general/who-is-using-clickhouse.md.hash @@ -1 +1 @@ -7ca2a14579288be6 +8d9e61ab4bc5ad93 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/faq/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/faq/index.md index b7f2256081b..211cc1fd985 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/faq/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/faq/index.md @@ -4,12 +4,13 @@ 'description': '常见问题的登录页面' 'pagination_prev': null 'pagination_next': null +'doc_type': 'landing-page' --- -| 页面 | 描述 | -|---------------------------------------------------------------|----------------------------------------------------------------------------------------| -| [关于 ClickHouse 的常见问题](general/index.md) | 我们收到的一些关于 ClickHouse 的常见问题。 | -| [为什么不使用类似 MapReduce 的东西?](general/mapreduce.md) | 解释为什么 MapReduce 实现不适合 OLAP 场景。 | -| [“не тормозит”是什么意思](general/ne-tormozit.md) | 解释“не тормозит”的意思,你可能在 ClickHouse 的 T 恤上看到过这个词。 | -| [什么是 OLAP](general/olap.md) | 解释什么是在线分析处理(Online Analytical Processing)。 | -| [谁在使用 ClickHouse](general/who-is-using-clickhouse.md) | 了解谁在使用 ClickHouse。 | +| 页面 | 描述 | +|-------------------------------------------------------------------|-----------------------------------------------------------------------------------| +| [有关 ClickHouse 的常见问题](general/index.md) | 我们关于 ClickHouse 的常见问题。 | +| [为什么不使用像 MapReduce 这样的东西?](general/mapreduce.md) | 解释为什么 MapReduce 实现不适合 OLAP 场景。 | +| [“не тормозит” 是什么意思](general/ne-tormozit.md) | 解释“не тормозит”的含义,您可能在 ClickHouse T 恤上见过。 | +| [什么是 OLAP](general/olap.md) | 在线分析处理(Online Analytical Processing)的解释。 | +| [谁在使用 ClickHouse](general/who-is-using-clickhouse.md) | 了解谁在使用 ClickHouse。 | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/faq/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/faq/index.md.hash index 326ab82995f..ed2c340a7eb 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/faq/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/faq/index.md.hash @@ -1 +1 @@ -2205140d0773c473 +31bfe83d9d5de681 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/faq/integration/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/faq/integration/index.md index 2fa84d63b58..f1deb8d1db6 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/faq/integration/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/faq/integration/index.md @@ -8,20 +8,21 @@ - 'questions' - 'integrations' 'title': '有关将 ClickHouse 与其他系统集成的问题' -'description': '列出与将 ClickHouse 与其他系统集成相关的问题的登录页面' +'description': '列出与将 ClickHouse 与其他系统集成相关的问题的登陆页面' +'doc_type': 'landing-page' --- # 关于集成 ClickHouse 和其他系统的问题 -- [如何将数据从 ClickHouse 导出到文件?](https://clickhouse.com/docs/knowledgebase/file-export) +- [我如何将数据从 ClickHouse 导出到文件?](https://clickhouse.com/docs/knowledgebase/file-export) - [如何将 JSON 导入 ClickHouse?](/integrations/data-ingestion/data-formats/json/intro.md) - [我如何将 Kafka 连接到 ClickHouse?](/integrations/data-ingestion/kafka/index.md) - [我可以将我的 Java 应用程序连接到 ClickHouse 吗?](/integrations/data-ingestion/dbms/jdbc-with-clickhouse.md) -- [ClickHouse 可以读取 MySQL 的表吗?](/integrations/data-ingestion/dbms/mysql/index.md) +- [ClickHouse 可以读取 MySQL 的表吗?](/integrations/mysql) - [ClickHouse 可以读取 PostgreSQL 的表吗?](/integrations/data-ingestion/dbms/postgresql/connecting-to-postgresql.md) -- [如果我在通过 ODBC 连接到 Oracle 时遇到编码问题怎么办?](/faq/integration/oracle-odbc.md) +- [如果我在通过 ODBC 连接 Oracle 时遇到编码问题,该怎么办?](/faq/integration/oracle-odbc.md) -:::info 你找不到你想要的内容? -查看我们的 [知识库](/knowledgebase/) 并浏览这里文档中提供的许多有用文章。 +:::info 找不到您要找的内容吗? +查看我们的 [知识库](/knowledgebase/) ,并浏览此文档中许多有用的文章。 ::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/faq/integration/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/faq/integration/index.md.hash index bb1c453c3ba..a9ef0d9bd6a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/faq/integration/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/faq/integration/index.md.hash @@ -1 +1 @@ -b4f55d342e4cafcb +6eeea882a0b844af diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/faq/integration/json-import.md b/i18n/zh/docusaurus-plugin-content-docs/current/faq/integration/json-import.md index 3538d2aa395..6a49380bb70 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/faq/integration/json-import.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/faq/integration/json-import.md @@ -3,13 +3,14 @@ 'title': '如何将JSON导入ClickHouse?' 'toc_hidden': true 'toc_priority': 11 -'description': '此页面展示了如何将JSON导入ClickHouse' +'description': '本页面向您展示如何将JSON导入ClickHouse' +'doc_type': 'guide' --- -# 如何将 JSON 导入到 ClickHouse? {#how-to-import-json-into-clickhouse} +# 如何将 JSON 导入 ClickHouse? {#how-to-import-json-into-clickhouse} -ClickHouse 支持多种 [输入和输出的数据格式](../../interfaces/formats.md)。其中有多种 JSON 变体,但用于数据摄取的最常用格式是 [JSONEachRow](../../interfaces/formats.md#jsoneachrow)。它期望每行一个 JSON 对象,每个对象由换行符分隔。 +ClickHouse 支持广泛的 [输入和输出数据格式](../../interfaces/formats.md)。其中有多种 JSON 变体,但最常用于数据摄取的是 [JSONEachRow](../../interfaces/formats.md#jsoneachrow)。它期望每行有一个 JSON 对象,每个对象通过换行符分隔。 ## 示例 {#examples} @@ -25,13 +26,13 @@ $ echo '{"foo":"bar"}' | curl 'http://localhost:8123/?query=INSERT%20INTO%20test $ echo '{"foo":"bar"}' | clickhouse-client --query="INSERT INTO test FORMAT JSONEachRow" ``` -与其手动插入数据,您不妨考虑使用 [集成工具](../../integrations/index.mdx)。 +您可以考虑使用 [集成工具](../../integrations/index.mdx) 而不是手动插入数据。 ## 有用的设置 {#useful-settings} -- `input_format_skip_unknown_fields` 允许插入 JSON,即使有额外的未在表模式中存在的字段(通过丢弃它们)。 +- `input_format_skip_unknown_fields` 允许插入 JSON,即使有额外字段不在表模式中(通过丢弃它们)。 - `input_format_import_nested_json` 允许将嵌套 JSON 对象插入到 [Nested](../../sql-reference/data-types/nested-data-structures/index.md) 类型的列中。 :::note -设置作为 `GET` 参数为 HTTP 接口指定,或作为以 `--` 前缀的额外命令行参数为 `CLI` 接口指定。 +设置作为 `GET` 参数为 HTTP 接口指定,或作为以 `--` 为前缀的额外命令行参数为 `CLI` 接口指定。 ::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/faq/integration/json-import.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/faq/integration/json-import.md.hash index 691d710674d..b2344686b40 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/faq/integration/json-import.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/faq/integration/json-import.md.hash @@ -1 +1 @@ -188b5a9c939c0bca +590e101ce9f7fd10 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/faq/integration/oracle-odbc.md b/i18n/zh/docusaurus-plugin-content-docs/current/faq/integration/oracle-odbc.md index 5b2ac48c913..8e435c39980 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/faq/integration/oracle-odbc.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/faq/integration/oracle-odbc.md @@ -1,15 +1,16 @@ --- 'slug': '/faq/integration/oracle-odbc' -'title': '当我通过 ODBC 使用 Oracle 时,如果遇到编码问题该怎么办?' +'title': '如果我在通过 ODBC 使用 Oracle 时遇到编码问题怎么办?' 'toc_hidden': true 'toc_priority': 20 -'description': '本页面提供关于当您通过 ODBC 使用 Oracle 时遇到编码问题的处理指导' +'description': '本页提供关于在通过 ODBC 使用 Oracle 时,如果遇到编码问题应该怎么做的指导。' +'doc_type': 'guide' --- -# 使用 Oracle ODBC 时的编码问题怎么办? {#oracle-odbc-encodings} +# 如果我在通过 ODBC 使用 Oracle 时遇到编码问题怎么办? {#oracle-odbc-encodings} -如果您通过 Oracle ODBC 驱动程序将 Oracle 作为 ClickHouse 外部字典的源,您需要在 `/etc/default/clickhouse` 中为 `NLS_LANG` 环境变量设置正确的值。有关更多信息,请参阅 [Oracle NLS_LANG FAQ](https://www.oracle.com/technetwork/products/globalization/nls-lang-099431.html)。 +如果您通过 Oracle ODBC 驱动程序将 Oracle 作为 ClickHouse 外部字典的来源,则需要在 `/etc/default/clickhouse` 中为 `NLS_LANG` 环境变量设置正确的值。有关更多信息,请参见 [Oracle NLS_LANG 常见问题](https://www.oracle.com/technetwork/products/globalization/nls-lang-099431.html)。 **示例** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/faq/integration/oracle-odbc.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/faq/integration/oracle-odbc.md.hash index f66d464e2e6..7b5d0a09c4a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/faq/integration/oracle-odbc.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/faq/integration/oracle-odbc.md.hash @@ -1 +1 @@ -3a20b44372d4174e +a92db6ea64659abe diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/faq/operations/delete-old-data.md b/i18n/zh/docusaurus-plugin-content-docs/current/faq/operations/delete-old-data.md index 3117a7bad8e..15c5ecafa15 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/faq/operations/delete-old-data.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/faq/operations/delete-old-data.md @@ -3,32 +3,32 @@ 'title': '是否可以从 ClickHouse 表中删除旧记录?' 'toc_hidden': true 'toc_priority': 20 -'description': '本页面回答了是否可以从 ClickHouse 表中删除旧记录的问题' +'description': '本页回答了是否可以从 ClickHouse 表中删除旧记录的问题' +'doc_type': 'reference' --- # 是否可以从 ClickHouse 表中删除旧记录? {#is-it-possible-to-delete-old-records-from-a-clickhouse-table} -简短的回答是“可以”。 ClickHouse 有多种机制可以通过删除旧数据来释放磁盘空间。每种机制针对不同的场景。 +简短的回答是“可以”。ClickHouse 具有多种机制,可以通过删除旧数据来释放磁盘空间。每种机制针对不同的场景。 ## TTL {#ttl} -ClickHouse 允许在满足某些条件时自动删除值。该条件配置为基于任何列的表达式,通常只是对任何时间戳列的静态偏移。 +ClickHouse 允许在某些条件发生时自动删除值。这个条件是基于任何列配置的表达式,通常只是针对任何时间戳列的静态偏移量。 -这种方法的主要优势在于,它不需要任何外部系统来触发,一旦配置了 TTL,数据删除将自动在后台进行。 +这种方法的主要优势是,它不需要任何外部系统来触发,一旦配置了 TTL,数据删除就会在后台自动发生。 :::note -TTL 也可以用于将数据移动到 [/dev/null](https://en.wikipedia.org/wiki/Null_device),还可以在不同的存储系统之间移动,例如从 SSD 到 HDD。 +TTL 也可以用于将数据移动到不仅是 [/dev/null](https://en.wikipedia.org/wiki/Null_device),还可以在不同的存储系统之间移动,比如从 SSD 到 HDD。 ::: -有关 [配置 TTL](../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-ttl) 的更多详细信息。 +有关 [配置 TTL](../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-ttl) 的更多细节。 ## DELETE FROM {#delete-from} - -[DELETE FROM](/sql-reference/statements/delete.md) 允许在 ClickHouse 中执行标准 DELETE 查询。筛选子句中标记为删除的行将被标记,并从未来的结果集中移除。行的清理是异步进行的。 +[DELETE FROM](/sql-reference/statements/delete.md) 允许在 ClickHouse 中运行标准的 DELETE 查询。过滤条件中目标行将被标记为已删除,并从未来的结果集中移除。行的清理是异步进行的。 :::note -从版本 23.3 及更新版本开始,DELETE FROM 一般可用。在更早版本中,它是实验性的,必须通过以下方式启用: +DELETE FROM 一般在 23.3 版本及更新版本中可用。在旧版本中,它是实验性的,必须通过以下方式启用: ```sql SET allow_experimental_lightweight_delete = true; ``` @@ -36,22 +36,22 @@ SET allow_experimental_lightweight_delete = true; ## ALTER DELETE {#alter-delete} -ALTER DELETE 使用异步批处理操作删除行。与 DELETE FROM 不同,在 ALTER DELETE 之后运行的查询以及在批处理操作完成之前将包括目标删除的行。有关更多详细信息,请参阅 [ALTER DELETE](/sql-reference/statements/alter/delete.md) 文档。 +ALTER DELETE 使用异步批处理操作删除行。与 DELETE FROM 不同,在 ALTER DELETE 之后和批处理操作完成之前运行的查询将包含被标记为删除的行。有关更多详细信息,请参见 [ALTER DELETE](/sql-reference/statements/alter/delete.md) 文档。 -可以发布 `ALTER DELETE` 来灵活地删除旧数据。如果需要定期执行,主要缺点将是需要一个外部系统来提交查询。还有一些性能考虑,因为即使只有一行需要删除,变更操作也会重写完整的分片。 +`ALTER DELETE` 可以灵活地删除旧数据。如果您需要定期执行此操作,主要的缺点是需要有一个外部系统来提交查询。由于变更重写完整的分区,即使只有一行要删除,还有一些性能考虑。 -这是使基于 ClickHouse 系统符合 [GDPR](https://gdpr-info.eu) 的最常见方法。 +这是使基于 ClickHouse 的系统符合 [GDPR](https://gdpr-info.eu) 最常见的方法。 -有关 [变更](https://clickhouse.com/docs/en/sql-reference/statements/alter#mutations) 的更多详细信息。 +有关 [变更]( /sql-reference/statements/alter#mutations) 的更多细节。 ## DROP PARTITION {#drop-partition} -`ALTER TABLE ... DROP PARTITION` 提供了一种经济高效的方式来删除整个分区。它不那么灵活,需要在创建表时配置适当的分区方案,但仍然涵盖了大多数常见的情况。像变更一样,需要从外部系统执行以便定期使用。 +`ALTER TABLE ... DROP PARTITION` 提供了一种成本高效的方式来删除整个分区。它的灵活性不高,需要在表创建时配置适当的分区方案,但仍然涵盖了大多数常见情况。像变更一样,通常需要从外部系统执行以便定期使用。 -有关 [操作分区](https://clickhouse.com/docs/en/sql-reference/statements/alter/partition) 的更多详细信息。 +有关 [操控分区]( /sql-reference/statements/alter/partition) 的更多细节。 ## TRUNCATE {#truncate} -从表中删除所有数据是相当激进的,但在某些情况下,这可能正是您所需要的。 +从表中删除所有数据是一个相对激进的操作,但在某些情况下,这可能正是您需要的。 -有关 [表截断](https://clickhouse.com/docs/en/sql-reference/statements/truncate.md) 的更多详细信息。 +有关 [表截断]( /sql-reference/statements/truncate.md) 的更多细节。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/faq/operations/delete-old-data.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/faq/operations/delete-old-data.md.hash index e739fd96c23..b50727959b6 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/faq/operations/delete-old-data.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/faq/operations/delete-old-data.md.hash @@ -1 +1 @@ -066dd351201aa717 +12186897438885e5 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/faq/operations/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/faq/operations/index.md index 92e9b8d431b..970d387798f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/faq/operations/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/faq/operations/index.md @@ -4,20 +4,21 @@ 'sidebar_label': '关于操作 ClickHouse 服务器和集群的问题' 'title': '关于操作 ClickHouse 服务器和集群的问题' 'description': '关于操作 ClickHouse 服务器和集群的问题的登录页面' +'doc_type': 'landing-page' --- # 关于操作 ClickHouse 服务器和集群的问题 -- [我应该在生产环境中使用哪个 ClickHouse 版本?](/faq/operations/production.md) -- [可以将 ClickHouse 部署为独立的存储和计算吗?](/faq/operations/separate_storage.md) +- [我应该在生产中使用哪个 ClickHouse 版本?](/faq/operations/production.md) +- [可以将 ClickHouse 与独立存储和计算部署吗?](/faq/operations/separate_storage.md) - [可以从 ClickHouse 表中删除旧记录吗?](/faq/operations/delete-old-data.md) -- [我该如何配置 ClickHouse Keeper?](/guides/sre/keeper/index.md) +- [我该如何配置 ClickHouse Keeper?](/guides/sre/keeper/index.md) - [ClickHouse 可以与 LDAP 集成吗?](/guides/sre/user-management/configuring-ldap.md) - [我该如何在 ClickHouse 中配置用户、角色和权限?](/guides/sre/user-management/index.md) -- [您可以在 ClickHouse 中更新或删除行吗?](/guides/developer/mutations.md) +- [你可以在 ClickHouse 中更新或删除行吗?](/guides/developer/mutations.md) - [ClickHouse 支持多区域复制吗?](/faq/operations/multi-region-replication.md) -:::info 找不到您要寻找的内容? -查看我们的 [知识库](/knowledgebase/) 并浏览此文档中提供的许多有用文章。 +:::info 没找到您要找的内容? +请查看我们的 [知识库](/knowledgebase/) ,并浏览文档中许多有用的文章。 ::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/faq/operations/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/faq/operations/index.md.hash index e4ebb7249a0..9d9d97b9e0f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/faq/operations/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/faq/operations/index.md.hash @@ -1 +1 @@ -f2fcb77e75e8680d +adf992718d37d1dc diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/faq/operations/multi-region-replication.md b/i18n/zh/docusaurus-plugin-content-docs/current/faq/operations/multi-region-replication.md index 35792ad9d77..88090da8ac2 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/faq/operations/multi-region-replication.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/faq/operations/multi-region-replication.md @@ -4,13 +4,14 @@ 'toc_hidden': true 'toc_priority': 30 'description': '本页面回答 ClickHouse 是否支持多区域复制' +'doc_type': 'reference' --- -# Does ClickHouse support multi-region replication? {#does-clickhouse-support-multi-region-replication} +# ClickHouse 是否支持多区域复制? {#does-clickhouse-support-multi-region-replication} -简短的回答是“是的”。然而,我们建议保持所有区域/数据中心之间的延迟在两位数范围内,否则写性能会受到影响,因为它经过分布式共识协议。例如,美国东海岸之间的复制可能会运行良好,但在美国和欧洲之间则不然。 +简短的回答是“是的”。然而,我们建议在所有区域/数据中心之间保持两位数范围内的延迟,否则写入性能将受到影响,因为它会通过分布式共识协议进行。例如,美国海岸之间的复制可能会正常工作,但美国与欧洲之间则不会。 -在配置方面,与单区域复制没有区别,只需使用位于不同位置的主机作为副本。 +在配置方面,与单区域复制没有差别,只需为副本使用位于不同位置的主机即可。 -有关更多信息,请参见 [full article on data replication](../../engines/table-engines/mergetree-family/replication.md)。 +有关更多信息,请参阅 [完整的数据复制文章](../../engines/table-engines/mergetree-family/replication.md)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/faq/operations/multi-region-replication.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/faq/operations/multi-region-replication.md.hash index e571b4fbb44..66ab18c4e49 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/faq/operations/multi-region-replication.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/faq/operations/multi-region-replication.md.hash @@ -1 +1 @@ -2dc91b204d1d01d5 +6dd9c5a935ba246a diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/faq/operations/production.md b/i18n/zh/docusaurus-plugin-content-docs/current/faq/operations/production.md index de085fc8b0f..7905e9bdeaf 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/faq/operations/production.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/faq/operations/production.md @@ -3,66 +3,67 @@ 'title': '在生产中使用哪个 ClickHouse 版本?' 'toc_hidden': true 'toc_priority': 10 -'description': '本页提供关于在生产中使用哪个 ClickHouse 版本的指导' +'description': '该页面提供关于在生产中使用哪个 ClickHouse 版本的指导' +'doc_type': 'guide' --- -# Which ClickHouse Version to Use in Production? {#which-clickhouse-version-to-use-in-production} +# Which ClickHouse version to use in production? {#which-clickhouse-version-to-use-in-production} -首先,让我们讨论一下人们为什么会问这个问题。主要有两个原因: +首先,让我们讨论一下人们为什么会问这个问题。主要有两个关键原因: -1. ClickHouse 的开发速度非常快,通常每年会有 10 次以上的稳定版本发布。这使得可选择的版本范围广泛,而这并不是一个简单的选择。 -2. 一些用户希望避免花费时间去弄清楚哪个版本最适合他们的用例,而只是跟随其他人的建议。 +1. ClickHouse 的开发速度非常快,通常每年会有超过 10 个稳定版本发布。这使得可选择的版本范围非常广泛,而选择并不简单。 +2. 有些用户希望避免花时间查明哪个版本最适合他们的使用场景,只想遵循别人的建议。 -第二个原因更为根本,因此我们将首先讨论这个问题,然后再回到不同 ClickHouse 版本的选择上。 +第二个原因更为根本,因此我们先从这一点开始,然后再讨论如何浏览不同的 ClickHouse 版本。 -## Which ClickHouse Version Do You Recommend? {#which-clickhouse-version-do-you-recommend} +## Which ClickHouse version do you recommend? {#which-clickhouse-version-do-you-recommend} -雇佣顾问或相信一些已知专家以摆脱您对生产环境的责任是非常诱人的。您安装某个别人推荐的特定 ClickHouse 版本;如果出现任何问题——那就不是您的错误,是别人的。这种推理是一个大陷阱。没有外部人士比您更了解您公司的生产环境。 +雇佣顾问或信任一些知名专家来摆脱对您的生产环境的责任是很有诱惑的。您安装某个特定的 ClickHouse 版本,这个版本是别人推荐的;如果出现了问题 - 那不是您的错,是别人的。这种推理是一个大的陷阱。没有外部人士比您更清楚您公司生产环境中发生了什么。 -那么,您如何正确选择要升级到哪个 ClickHouse 版本?或者您如何选择第一个 ClickHouse 版本?首先,您需要投资于建立一个**真实的预生产环境**。理想情况下,它应该是一个完全相同的影子副本,但这通常成本很高。 +那么,您如何正确选择要升级到的 ClickHouse 版本呢?或者,您如何选择第一个 ClickHouse 版本呢?首先,您需要投入时间设置一个 **真实的预生产环境**。理想情况下,它可以是一个完全相同的影子副本,但通常成本较高。 -以下是一些关键点,以便在预生产环境中以较低的成本获得合理的准确性: +以下是一些关键点,以在预生产环境中以较低的成本获得合理的保真度: -- 预生产环境需要运行一组与您计划在生产中运行的查询尽可能接近的查询: - - 不要让它只有只读并带有一些静止数据。 - - 不要让它是只有写入的,仅仅复制数据而没有生成一些典型报告。 - - 不要在不应用模式迁移的情况下将其清空。 -- 使用一小部分真实的生产数据和查询。尽量选择一个仍然具有代表性的样本,并使 `SELECT` 查询返回合理的结果。如果您的数据敏感并且内部政策不允许其离开生产环境,可以使用数据混淆技术。 -- 确保预生产环境由您的监控和警报软件覆盖,与您的生产环境相同。 -- 如果您的生产环境跨多个数据中心或区域,确保您的预生产环境也同样如此。 -- 如果您的生产环境使用如复制、分布式表和级联物化视图等复杂功能,请确保在预生产环境中以相似的方式进行配置。 -- 在预生产环境中使用与生产环境大致相同数量或规格更小的服务器或虚拟机存在权衡,或者使用较少的但大小相同的服务器或虚拟机。第一种选择可能会捕获额外的网络相关问题,而后者更易于管理。 +- 预生产环境需要运行与您打算在生产中运行的查询尽可能接近的查询集: + - 不要让它只读取一些冻结的数据。 + - 不要让它只写入数据而不构建一些典型的报告。 + - 不要清除它,而是应用模式迁移。 +- 使用真实生产数据和查询的样本。尝试选择一个仍然具有代表性的样本,并使 `SELECT` 查询返回合理的结果。如果您的数据敏感且内部政策不允许它离开生产环境,请使用混淆处理。 +- 确保预生产环境的监控和警报软件与生产环境一样得到覆盖。 +- 如果您的生产环境跨越多个数据中心或区域,请确保预生产环境也这样设置。 +- 如果您的生产使用复杂的特性,如复制、分布式表和级联物化视图,请确保它们在预生产中也这样配置。 +- 在预生产中使用与生产中大致相同数量的服务器或虚拟机(VM),但大小较小,或者数量较少但大小相同之间存在权衡。第一种选择可能会捕获额外的网络相关问题,而后者则更易于管理。 -第二个需要投资的领域是**自动化测试基础设施**。不要假设如果某种查询成功执行一次,它将永远如此。进行一些 ClickHouse 被模拟的单元测试是可以的,但请确保您的产品具有合理的自动化测试集,这些测试必须针对真实的 ClickHouse 运行,以检查所有重要的用例是否按预期工作。 +第二个投资领域是 **自动化测试基础设施**。不要假设如果某种查询成功执行过一次,它将永远继续这样做。虽然可以有一些单元测试,其中 ClickHouse 被模拟,但确保您的产品有一套合理的自动化测试,这些测试针对真实的 ClickHouse 运行,并检查所有重要的用例是否仍按预期工作。 -迈出的一步可以是向 [ClickHouse 的开源测试基础设施](https://github.com/ClickHouse/ClickHouse/tree/master/tests) 贡献这些自动化测试,这些测试在日常开发中不断使用。学习[如何运行它](../../development/tests.md)并将您的测试适配到该框架中确实需要一些额外的时间和努力,但这将确保 ClickHouse 发布时已经通过这些测试进行验证,而不是在事后报告问题后反复浪费时间,然后等待缺陷修复的实施、回溯和发布。一些公司甚至将对基础设施的测试贡献作为公司内部政策(称为 [Beyonce's Rule](https://www.oreilly.com/library/view/software-engineering-at/9781492082781/ch01.html#policies_that_scale_well) 在 Google 内部实施)。 +进一步的步骤是为 [ClickHouse 的开源测试基础设施](https://github.com/ClickHouse/ClickHouse/tree/master/tests) 贡献这些自动化测试,这在其日常开发中不断使用。学习 [如何运行它](../../development/tests.md),然后如何将您的测试适应这个框架,确实会花费一些额外的时间和精力,但这将通过确保 ClickHouse 发布时已进行测试而得到回报,而不是反复浪费时间在问题报告后,等待 Bug 修复去实施、回溯和发布。有些公司甚至将此类测试贡献作为其内部政策的要求(称为 [Beyonce's Rule](https://www.oreilly.com/library/view/software-engineering-at/9781492082781/ch01.html#policies_that_scale_well) 在 Google 中)。 -当您有了预生产环境和测试基础设施后,选择最佳版本就变得简单了: +当您准备好预生产环境和测试基础设施后,选择最佳版本就简单了: -1. 定期对新的 ClickHouse 版本运行您的自动化测试。对于被标记为 `testing` 的 ClickHouse 版本也可以这样做,但不建议继续向前推进。 -2. 部署通过测试的 ClickHouse 版本到预生产中,并检查所有进程是否按预期运行。 -3. 将您发现的问题报告给 [ClickHouse GitHub Issues](https://github.com/ClickHouse/ClickHouse/issues)。 -4. 如果没有重大问题,您可以安全地开始将 ClickHouse 版本部署到您的生产环境。投资于逐步发布自动化的系统,该系统实现类似于 [canary releases](https://martinfowler.com/bliki/CanaryRelease.html) 或 [green-blue deployments](https://martinfowler.com/bliki/BlueGreenDeployment.html) 的方法可能会进一步降低生产环境中出现问题的风险。 +1. 定期针对新的 ClickHouse 版本运行自动化测试。您甚至可以对标记为 `testing` 的 ClickHouse 版本进行测试,但不建议继续推进后续步骤。 +2. 部署通过测试的 ClickHouse 版本到预生产,并检查所有过程是否按预期运行。 +3. 报告您发现的任何问题到 [ClickHouse GitHub Issues](https://github.com/ClickHouse/ClickHouse/issues)。 +4. 如果没有重大问题,开始将 ClickHouse 版本部署到生产环境应该是安全的。投资于逐步发布自动化,实施类似于 [canary releases](https://martinfowler.com/bliki/CanaryRelease.html) 或 [green-blue deployments](https://martinfowler.com/bliki/BlueGreenDeployment.html) 的方法,可以进一步减少生产中出现问题的风险。 -正如您可能注意到的,上述方法中没有什么特定于 ClickHouse 的内容——如果人们认真对待其生产环境,他们会对任何所依赖的基础设施这样做。 +正如您可能注意到的,上述方法没有特别针对 ClickHouse - 如果人们认真对待他们的生产环境,他们对任何基础设施都会这样做。 -## How to Choose Between ClickHouse Releases? {#how-to-choose-between-clickhouse-releases} +## How to choose between ClickHouse releases? {#how-to-choose-between-clickhouse-releases} -如果您查看 ClickHouse 软件包仓库的内容,您会看到两种类型的软件包: +如果您查看 ClickHouse 包存储库的内容,您会看到两种类型的软件包: -1. `stable` -2. `lts`(长期支持) +1. `stable` +2. `lts`(长期支持) -以下是选择这两者之间的一些指导: +以下是如何选择这两者之间的一些指导: -- `stable` 是我们默认推荐的软件包类型。它们大约每月发布一次(因此在合理延迟下提供新功能),并且最近三个稳定版本在诊断和回溯错误修复方面受到支持。 -- `lts` 每年发布两次,并在初始发布后支持一年。在以下情况下,您可能更倾向于使用它们而非 `stable`: - - 您的公司有一些内部政策,不允许频繁升级或使用非 LTS 软件。 - - 您在一些次要产品中使用 ClickHouse,这些产品要么不需要复杂的 ClickHouse 功能,要么没有足够的资源以保持其更新。 +- `stable` 是我们默认推荐的软件包类型。这些包大约每月发布一次(因此提供合理延迟的新功能),并且最新的三个稳定版本在诊断和回溯 Bug 修复方面受到支持。 +- `lts` 每年发布两次,并在初始发布后支持一年。您在以下情况下可能更喜欢它们而不是 `stable`: + - 您的公司有一些内部政策,不允许频繁升级或使用非 LTS 软件。 + - 您在某些次要产品中使用 ClickHouse,这些产品既不需要任何复杂的 ClickHouse 特性,也没有足够的资源进行更新。 -许多最初认为 `lts` 是最佳选择的团队,最终出于某些对其产品重要的新功能原因,仍然会转向 `stable`。 +许多最初认为 `lts` 是最佳选择的团队最终仍然会因某些对其产品重要的最近功能而转换回 `stable`。 :::tip -在升级 ClickHouse 时还有一件事情需要记住:我们始终关注版本之间的兼容性,但有时保留某些细节并不合理,可能会发生变化。因此,请确保在升级之前查看 [changelog](/whats-new/changelog/index.md),以了解是否有任何关于向后不兼容更改的说明。 +在升级 ClickHouse 时还有一件事需要记住:我们始终关注各版本之间的兼容性,但有时保持兼容性是不合理的,一些小细节可能会发生变化。因此,在升级之前,请确保检查 [changelog](/whats-new/changelog/index.md),以查看是否有关于向后不兼容更改的说明。 ::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/faq/operations/production.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/faq/operations/production.md.hash index 00ff00a7cef..358a78aeb88 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/faq/operations/production.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/faq/operations/production.md.hash @@ -1 +1 @@ -f26411440da6af28 +897f628edea5f950 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/faq/operations/separate_storage.md b/i18n/zh/docusaurus-plugin-content-docs/current/faq/operations/separate_storage.md index 34d825beedf..6c876bb7ded 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/faq/operations/separate_storage.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/faq/operations/separate_storage.md @@ -1,12 +1,13 @@ --- 'slug': '/faq/operations/deploy-separate-storage-and-compute' -'title': '将 ClickHouse 部署在单独的存储和计算上是否可能?' -'sidebar_label': '将 ClickHouse 部署在单独的存储和计算上是否可能?' +'title': '是否可以部署 ClickHouse 以实现存储和计算分离?' +'sidebar_label': '是否可以部署 ClickHouse 以实现存储和计算分离?' 'toc_hidden': true 'toc_priority': 20 -'description': '此页面提供了关于是否可以将 ClickHouse 部署在单独的存储和计算上的答案。' +'description': '本页面提供关于是否可以部署 ClickHouse 以实现存储和计算分离的答案' +'doc_type': 'guide' --- 简短的回答是“是的”。 -对象存储(S3, GCS)可以作为 ClickHouse 表中数据的弹性主存储后端。已发布 [S3-backed MergeTree](/integrations/data-ingestion/s3/index.md) 和 [GCS-backed MergeTree](/integrations/data-ingestion/gcs/index.md) 指南。在这种配置中,仅将元数据存储在计算节点的本地。您可以轻松地在此设置中扩展和缩减计算资源,因为附加节点只需复制元数据。 +对象存储 (S3, GCS) 可以作为 ClickHouse 表中数据的弹性主存储后端。我们已发布 [基于 S3 的 MergeTree](/integrations/data-ingestion/s3/index.md) 和 [基于 GCS 的 MergeTree](/integrations/data-ingestion/gcs/index.md) 指南。在此配置中,仅在计算节点上本地存储元数据。您可以轻松地在此设置中扩展和缩减计算资源,因为额外的节点仅需要复制元数据。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/faq/operations/separate_storage.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/faq/operations/separate_storage.md.hash index 45ee44ba318..7a5ad4b6fa7 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/faq/operations/separate_storage.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/faq/operations/separate_storage.md.hash @@ -1 +1 @@ -4c5aff4db36a77b2 +33b2488cc9c20fad diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/faq/troubleshooting.md b/i18n/zh/docusaurus-plugin-content-docs/current/faq/troubleshooting.md deleted file mode 100644 index bc74cdca04a..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/faq/troubleshooting.md +++ /dev/null @@ -1,25 +0,0 @@ ---- -'title': '故障排除' -'slug': '/faq/troubleshooting' -'description': '如何解决常见的 ClickHouse Cloud 错误信息。' ---- - -## ClickHouse Cloud 故障排除 {#clickhouse-cloud-troubleshooting} - -### 无法访问 ClickHouse Cloud 服务 {#unable-to-access-a-clickhouse-cloud-service} - -如果您看到类似以下的错误消息,您的 IP 访问列表可能拒绝了访问: - -```response -curl: (35) error:02FFF036:system library:func(4095):Connection reset by peer -``` -或 -```response -curl: (35) LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to HOSTNAME.clickhouse.cloud:8443 -``` -或 -```response -Code: 210. DB::NetException: SSL connection unexpectedly closed (e46453teek.us-east-2.aws.clickhouse-staging.com:9440). (NETWORK_ERROR) -``` - -请检查 [IP 访问列表](/cloud/security/setting-ip-filters),如果您尝试从未被允许的列表外连接,则您的连接将会失败。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/faq/troubleshooting.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/faq/troubleshooting.md.hash deleted file mode 100644 index 2221ba0db80..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/faq/troubleshooting.md.hash +++ /dev/null @@ -1 +0,0 @@ -b827a3738b382499 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/faq/use-cases/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/faq/use-cases/index.md index 3655ab2815c..f802c754b93 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/faq/use-cases/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/faq/use-cases/index.md @@ -4,14 +4,15 @@ 'sidebar_label': '关于 ClickHouse 用例的问题' 'title': '关于 ClickHouse 用例的问题' 'description': '着陆页列出关于 ClickHouse 用例的常见问题' +'doc_type': 'landing-page' --- -# 关于 ClickHouse 用例的问题 +# 有关 ClickHouse 用例的问题 - [我可以将 ClickHouse 用作时间序列数据库吗?](/knowledgebase/time-series) - [我可以将 ClickHouse 用作键值存储吗?](/knowledgebase/key-value) -:::info 找不到您要找的内容? -请查看我们的 [知识库](/knowledgebase/) ,并浏览文档中找到的许多有用文章。 +:::info 你没有找到想要的内容? +查看我们的 [知识库](/knowledgebase/),并浏览文档中很多有用的文章。 ::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/faq/use-cases/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/faq/use-cases/index.md.hash index d877f5e89bc..b9106fcf1cd 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/faq/use-cases/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/faq/use-cases/index.md.hash @@ -1 +1 @@ -64b2b3caa97c9529 +5482b6055dcc88aa diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/faq/use-cases/key-value.md b/i18n/zh/docusaurus-plugin-content-docs/current/faq/use-cases/key-value.md index c42bad590a6..36cb06863c6 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/faq/use-cases/key-value.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/faq/use-cases/key-value.md @@ -1,20 +1,21 @@ --- 'slug': '/faq/use-cases/key-value' -'title': '我可以将 ClickHouse 作为键值存储吗?' +'title': '我可以将 ClickHouse 用作键值存储吗?' 'toc_hidden': true 'toc_priority': 101 -'description': '回答了关于 ClickHouse 是否可以用作键值存储的常见问题。' +'description': '解答了关于是否可以将 ClickHouse 用作键值存储的常见问题。' +'doc_type': 'reference' --- # 我可以将 ClickHouse 用作键值存储吗? {#can-i-use-clickhouse-as-a-key-value-storage} -简短的回答是 **“不可以”**。键值负载在 **不** 使用 ClickHouse 的情况下排名靠前。毕竟它是一个 [OLAP](../../faq/general/olap.md) 系统,而市场上有许多出色的键值存储系统。 +简短的回答是 **"否"**。键值工作负载在 **不** 使用 ClickHouse 的情况列表中名列前茅。毕竟,它是一个 [OLAP](../../faq/general/olap.md) 系统,而市面上有许多优秀的键值存储系统。 -然而,在某些情况下,使用 ClickHouse 进行类似键值的查询仍然是有意义的。通常,这是一种低预算产品,其主要工作负载是分析性质并很适合 ClickHouse,但还有一些需要键值模式的辅助过程,其请求吞吐量不高且没有严格的延迟要求。如果您有无限的预算,您会为这个辅助工作负载安装一个次要的键值数据库,但实际上,维护一个额外存储系统(监控、备份等)会带来额外成本,而这些成本可能是希望避免的。 +但是,在某些情况下,使用 ClickHouse 进行类似键值的查询仍然是有意义的。通常,这是一些低预算产品,其中主要工作负载是分析性质并且适合 ClickHouse,但还有一些次要过程需要键值模式,且请求吞吐量不是很高,并且没有严格的延迟要求。如果你有无限的预算,你会为这个次要工作负载安装一个额外的键值数据库,但实际上,维护一个额外存储系统(监控、备份等)的额外成本可能是希望避免的。 -如果您决定不遵循建议,并对 ClickHouse 运行一些类似键值的查询,以下是一些提示: +如果你决定不遵循建议,并对 ClickHouse 执行一些类似键值的查询,以下是一些提示: -- ClickHouse 中点查询成本高的主要原因是其 [MergeTree 表引擎系列](../..//engines/table-engines/mergetree-family/mergetree.md) 的稀疏主索引。此索引无法直接指向特定的行数据,而是指向每第 N 行,系统必须从临近的 N 行扫描到所需行,并在此过程中读取多余的数据。在键值场景中,使用 `index_granularity` 设置可能有助于降低 N 的值。 -- ClickHouse 将每列保存在一组单独的文件中,因此要组装一整行,它需要遍历这些文件。随着列数的增加,文件的数量呈线性增加,因此在键值场景中,可能值得避免使用许多列,而将所有有效载荷放入一个单一的 `String` 列中,并使用 JSON、Protobuf 或其他合适的序列化格式进行编码。 -- 还有一种替代方法,使用 [Join](../../engines/table-engines/special/join.md) 表引擎,而不是普通的 `MergeTree` 表,并使用 [joinGet](../../sql-reference/functions/other-functions.md#joinget) 函数来检索数据。这可以提供更好的查询性能,但可能存在一些可用性和可靠性问题。以下是一个 [使用示例](https://github.com/ClickHouse/ClickHouse/blob/master/tests/queries/0_stateless/00800_versatile_storage_join.sql#L49-L51)。 +- 在 ClickHouse 中,点查询费用高的主要原因是它稀疏的主 [MergeTree 表引擎系列](../..//engines/table-engines/mergetree-family/mergetree.md) 的索引。该索引无法指向每一行数据,相反,它指向每 N 行,系统必须从相邻的 N 行扫描到所需行,沿途读取过多的数据。在键值场景中,使用 `index_granularity` 设置可以减少 N 的值可能是有用的。 +- ClickHouse 将每列保存在一组独立的文件中,因此要组装一整行数据,它需要遍历每个文件。随着列数的增加,文件的数量线性增加,因此在键值场景中,可能需要避免使用过多的列,将所有负载放在单个 `String` 列中,并以某种序列化格式(如 JSON、Protobuf 或其他合理的格式)进行编码。 +- 还有一种替代方法,使用 [Join](../../engines/table-engines/special/join.md) 表引擎而不是普通的 `MergeTree` 表,并使用 [joinGet](../../sql-reference/functions/other-functions.md#joinget) 函数来检索数据。这可能提供更好的查询性能,但可能存在一些可用性和可靠性问题。这里有一个 [用例示例](https://github.com/ClickHouse/ClickHouse/blob/master/tests/queries/0_stateless/00800_versatile_storage_join.sql#L49-L51)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/faq/use-cases/key-value.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/faq/use-cases/key-value.md.hash index 7a03360f0b4..d3067bf57c1 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/faq/use-cases/key-value.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/faq/use-cases/key-value.md.hash @@ -1 +1 @@ -9ae3589b050333f1 +275bb6d0112f3eab diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/faq/use-cases/time-series.md b/i18n/zh/docusaurus-plugin-content-docs/current/faq/use-cases/time-series.md index 944b429b9ae..b100b64ac0d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/faq/use-cases/time-series.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/faq/use-cases/time-series.md @@ -4,17 +4,18 @@ 'toc_hidden': true 'toc_priority': 101 'description': '页面描述如何将 ClickHouse 用作时间序列 DATABASE' +'doc_type': 'guide' --- -# 我可以将 ClickHouse 用作时间序列数据库吗? {#can-i-use-clickhouse-as-a-time-series-database} +# Can I use ClickHouse as a time-series database? {#can-i-use-clickhouse-as-a-time-series-database} -_注意:请参阅博客 [在 ClickHouse 中处理时间序列数据](https://clickhouse.com/blog/working-with-time-series-data-and-functions-ClickHouse),了解更多使用 ClickHouse 进行时间序列分析的示例。_ +_Note: 请参见博客 [在ClickHouse中处理时间序列数据](https://clickhouse.com/blog/working-with-time-series-data-and-functions-ClickHouse),了解使用ClickHouse进行时间序列分析的更多示例。_ -ClickHouse 是一个通用的数据存储解决方案,用于 [OLAP](../../faq/general/olap.md) 工作负载,而许多专门的 [时间序列数据库管理系统](https://clickhouse.com/engineering-resources/what-is-time-series-database) 也存在。尽管如此,ClickHouse 在 [查询执行速度](../../concepts/why-clickhouse-is-so-fast.md) 上的优势使其在许多情况下超越了专门系统。关于这个主题有很多独立的基准测试,所以我们在这里不打算进行测试。相反,让我们专注于 ClickHouse 中重要的功能,以便满足您的用例。 +ClickHouse是一个通用的数据存储解决方案,适用于[OLAP](../../faq/general/olap.md)工作负载,尽管还有许多专业化的[时间序列数据库管理系统](https://clickhouse.com/engineering-resources/what-is-time-series-database)。然而,ClickHouse对[查询执行速度的关注](../../concepts/why-clickhouse-is-so-fast.mdx)使其在许多情况下超越了专业系统。关于这个主题有许多独立的基准测试,因此我们在这里不进行测试。相反,让我们关注对于你的用例来说,使用ClickHouse的重要特性。 -首先,有 **[专用编解码器](../../sql-reference/statements/create/table.md#specialized-codecs)**,使得典型的时间序列更高效。这些编解码器可以是常见的算法,如 `DoubleDelta` 和 `Gorilla`,或特定于 ClickHouse 的算法,如 `T64`。 +首先,有**[专业编解码器](../../sql-reference/statements/create/table.md#specialized-codecs)**,使典型的时间序列数据更具优势。包括常见的算法,如`DoubleDelta`和`Gorilla`,以及特定于ClickHouse的`T64`。 -其次,时间序列查询通常只涉及最近的数据,例如一天或一周之前的数据。使用同时具有快速 NVMe/SSD 驱动器和高容量 HDD 驱动器的服务器是合理的。ClickHouse 的 [TTL](/engines/table-engines/mergetree-family/mergetree#table_engine-mergetree-ttl) 特性允许配置将新鲜的热数据保留在快速驱动器上,并随着其变老逐渐移至较慢的驱动器。如果您的要求需要,甚至可以进行更老数据的汇总或移除。 +其次,时间序列查询通常只涉及最近的数据,例如一天或一周前的数据。使用同时拥有快速的NVMe/SSD驱动器和大容量HDD驱动器的服务器是合理的。ClickHouse的[TTL](/engines/table-engines/mergetree-family/mergetree#table_engine-mergetree-ttl)特性允许配置将新鲜的热数据保存在快速驱动器上,并随着时间的推移逐渐将其移动到较慢的驱动器上。如果你的要求需要,甚至可以进行更旧数据的汇总或删除。 -尽管这与 ClickHouse 存储和处理原始数据的理念相悖,您仍然可以使用 [物化视图](../../sql-reference/statements/create/view.md) 来满足更严格的延迟或成本要求。 +尽管这违背了ClickHouse存储和处理原始数据的理念,但你可以使用[物化视图](../../sql-reference/statements/create/view.md)来满足更严格的延迟或成本要求。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/faq/use-cases/time-series.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/faq/use-cases/time-series.md.hash index a54bd1162e2..31d1db78882 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/faq/use-cases/time-series.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/faq/use-cases/time-series.md.hash @@ -1 +1 @@ -75065302f8e5c36a +59840eda68787efd diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/amazon-reviews.md b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/amazon-reviews.md index 1261206dd11..1ab5c1f7cf1 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/amazon-reviews.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/amazon-reviews.md @@ -1,20 +1,21 @@ --- -'description': '超过1.5亿条客户对亚马逊产品的评价' +'description': '超过 1.5 亿条 亚马逊 产品的客户评价' 'sidebar_label': '亚马逊客户评价' 'slug': '/getting-started/example-datasets/amazon-reviews' 'title': '亚马逊客户评价' +'doc_type': 'reference' --- -这个数据集包含超过1.5亿条亚马逊产品的客户评论。数据存储在AWS S3中的snappy压缩Parquet文件中,总大小为49GB(压缩后)。让我们逐步将其插入到ClickHouse中。 +这个数据集包含超过 1.5 亿条关于亚马逊产品的客户评价。这些数据以 snappy 压缩的 Parquet 文件形式存储在 AWS S3 中,压缩后的总大小为 49GB。让我们逐步了解如何将其插入到 ClickHouse 中。 :::note -下面的查询是在**生产**实例的ClickHouse Cloud上执行的。有关更多信息,请参见 -["Playground specifications"](/getting-started/playground#specifications)。 +下面的查询是在 **生产** 实例的 ClickHouse Cloud 上执行的。有关更多信息,请参见 +["Playground specifications"](/getting-started/playground#specifications). ::: ## 加载数据集 {#loading-the-dataset} -1. 在不将数据插入ClickHouse的情况下,我们可以直接查询它。让我们抓取一些行,以便可以查看它们的样子: +1. 在不将数据插入 ClickHouse 的情况下,我们可以直接查询它。让我们抓取一些行,以查看它们的样子: ```sql SELECT * @@ -22,7 +23,7 @@ FROM s3('https://datasets-documentation.s3.eu-west-3.amazonaws.com/amazon_review LIMIT 3 ``` -这些行的样子如下: +这些行看起来像: ```response Row 1: @@ -80,7 +81,7 @@ review_headline: but overall this case is pretty sturdy and provides good prot review_body: The front piece was a little difficult to secure to the phone at first, but overall this case is pretty sturdy and provides good protection for the phone, which is what I need. I would buy this case again. ``` -2. 让我们定义一个新的`MergeTree`表,命名为`amazon_reviews`,以在ClickHouse中存储这些数据: +2. 让我们定义一个名为 `amazon_reviews` 的新 `MergeTree` 表,以在 ClickHouse 中存储这些数据: ```sql CREATE DATABASE amazon @@ -112,7 +113,7 @@ ENGINE = MergeTree ORDER BY (review_date, product_category) ``` -3. 以下`INSERT`命令使用`s3Cluster`表函数,该函数允许通过集群中的所有节点并行处理多个S3文件。我们还使用了通配符,以插入任何以`https://datasets-documentation.s3.eu-west-3.amazonaws.com/amazon_reviews/amazon_reviews_*.snappy.parquet`开头的文件: +3. 以下 `INSERT` 命令使用 `s3Cluster` 表函数,允许使用集群的所有节点并行处理多个 S3 文件。我们还使用通配符插入任何以 `https://datasets-documentation.s3.eu-west-3.amazonaws.com/amazon_reviews/amazon_reviews_*.snappy.parquet` 开头的文件: ```sql INSERT INTO amazon.amazon_reviews SELECT * @@ -121,17 +122,17 @@ FROM s3Cluster('default', ``` :::tip -在ClickHouse Cloud中,集群的名称是`default`。如果没有集群,请将`default`更改为您集群的名称...或者使用`s3`表函数(而不是`s3Cluster`)。 +在 ClickHouse Cloud 中,集群的名称是 `default`。如果没有集群,将 `default` 更改为您集群的名称……或者使用 `s3` 表函数(而不是 `s3Cluster`)。 ::: -5. 该查询不会花费太长时间 - 平均约每秒300,000行。在大约5分钟内,您应该可以看到所有行已插入: +5. 该查询的时间不长——平均约 30 万行每秒。大约 5 分钟内,您应该会看到所有行插入: ```sql runnable SELECT formatReadableQuantity(count()) FROM amazon.amazon_reviews ``` -6. 让我们看看我们的数据占用了多少空间: +6. 让我们查看一下我们的数据占用了多少空间: ```sql runnable SELECT @@ -147,11 +148,11 @@ GROUP BY disk_name ORDER BY size DESC ``` -原始数据大约为70G,但在ClickHouse中压缩后约占30G。 +原始数据大约为 70GB,但在 ClickHouse 中压缩后占用大约 30GB。 ## 示例查询 {#example-queries} -7. 让我们运行一些查询。以下是数据集中前10条最有帮助的评论: +7. 让我们运行一些查询。以下是数据集中前 10 条最有帮助的评论: ```sql runnable SELECT @@ -163,10 +164,10 @@ LIMIT 10 ``` :::note -此查询使用[投影](/data-modeling/projections)来加快性能。 +该查询使用了一个 [projection](/data-modeling/projections) 来加速性能。 ::: -8. 以下是亚马逊上评论最多的前10种产品: +8. 这是在亚马逊上评论最多的前 10 种产品: ```sql runnable SELECT @@ -178,7 +179,7 @@ ORDER BY 2 DESC LIMIT 10; ``` -9. 这是每个产品每月的平均评价评分(一个实际的[亚马逊工作面试问题](https://datalemur.com/questions/sql-avg-review-ratings)!): +9. 这是每个产品每月的平均评价评分(实际的 [亚马逊面试问题](https://datalemur.com/questions/sql-avg-review-ratings)!): ```sql runnable SELECT @@ -195,7 +196,7 @@ ORDER BY LIMIT 20; ``` -10. 以下是每个产品类别的投票总数。该查询执行很快,因为`product_category`在主键中: +10. 这是每个产品类别的投票总数。该查询速度很快,因为 `product_category` 在主键中: ```sql runnable SELECT @@ -206,7 +207,7 @@ GROUP BY product_category ORDER BY 1 DESC ``` -11. 让我们找出在评论中出现**“awful”**一词最频繁的产品。这是一项巨大的任务 - 超过1.51亿个字符串需要解析以查找一个单词: +11. 让我们找出在评论中出现“**awful**”这个词频率最高的产品。这是一项大任务——需要解析超过 1.51 亿个字符串以寻找一个单词: ```sql runnable settings={'enable_parallel_replicas':1} SELECT @@ -221,9 +222,9 @@ ORDER BY count DESC LIMIT 50; ``` -注意如此大量数据的查询时间。结果也很有趣! +注意对于如此大量数据的查询时间。结果也非常有趣! -12. 我们可以再次运行相同的查询,只不过这次我们在评论中搜索**awesome**: +12. 我们可以再次运行相同的查询,这次在评论中搜索 **awesome**: ```sql runnable settings={'enable_parallel_replicas':1} SELECT diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/amazon-reviews.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/amazon-reviews.md.hash index 2ad5a6dd233..89f1b5e6671 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/amazon-reviews.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/amazon-reviews.md.hash @@ -1 +1 @@ -0792d96c84865e67 +bee27b4c10be45c3 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/amplab-benchmark.md b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/amplab-benchmark.md index 6a15756e7c1..c47abe42379 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/amplab-benchmark.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/amplab-benchmark.md @@ -1,15 +1,16 @@ --- 'description': '用于比较数据仓库解决方案性能的基准数据集。' -'sidebar_label': 'AMPLab 大数据基准' +'sidebar_label': 'AMPLab 大数据基准测试' 'slug': '/getting-started/example-datasets/amplab-benchmark' -'title': 'AMPLab 大数据基准' +'title': 'AMPLab 大数据基准测试' +'doc_type': 'reference' --- See https://amplab.cs.berkeley.edu/benchmark/ -在 https://aws.amazon.com 注册一个免费账户。需要提供信用卡、电子邮件和电话号码。在 https://console.aws.amazon.com/iam/home?nc2=h_m_sc#security_credential 获取一个新的访问密钥。 +Sign up for a free account at https://aws.amazon.com. It requires a credit card, email, and phone number. Get a new access key at https://console.aws.amazon.com/iam/home?nc2=h_m_sc#security_credential -在控制台中运行以下命令: +Run the following in the console: ```bash $ sudo apt-get install s3cmd @@ -24,7 +25,7 @@ $ s3cmd sync s3://big-data-benchmark/pavlo/text-deflate/5nodes/ . $ cd .. ``` -运行以下 ClickHouse 查询: +Run the following ClickHouse 查询: ```sql CREATE TABLE rankings_tiny @@ -88,7 +89,7 @@ CREATE TABLE uservisits_5nodes_on_single ) ENGINE = MergeTree(visitDate, visitDate, 8192); ``` -返回控制台: +Go back to the console: ```bash $ for i in tiny/rankings/*.deflate; do echo $i; zlib-flate -uncompress < $i | clickhouse-client --host=example-perftest01j --query="INSERT INTO rankings_tiny FORMAT CSV"; done @@ -99,7 +100,7 @@ $ for i in 5nodes/rankings/*.deflate; do echo $i; zlib-flate -uncompress < $i | $ for i in 5nodes/uservisits/*.deflate; do echo $i; zlib-flate -uncompress < $i | clickhouse-client --host=example-perftest01j --query="INSERT INTO uservisits_5nodes_on_single FORMAT CSV"; done ``` -获取数据样本的查询: +用于获取数据样本的查询: ```sql SELECT pageURL, pageRank FROM rankings_1node WHERE pageRank > 1000 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/amplab-benchmark.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/amplab-benchmark.md.hash index de899a19628..9b060261b93 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/amplab-benchmark.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/amplab-benchmark.md.hash @@ -1 +1 @@ -955aa7116a01089e +01b1db24ccac4963 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/brown-benchmark.md b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/brown-benchmark.md index 7443d45442b..608d5d0d136 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/brown-benchmark.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/brown-benchmark.md @@ -3,9 +3,10 @@ 'sidebar_label': '布朗大学基准测试' 'slug': '/getting-started/example-datasets/brown-benchmark' 'title': '布朗大学基准测试' +'doc_type': 'reference' --- -`MgBench` 是一种新的分析基准,用于机器生成的日志数据, [Andrew Crotty](http://cs.brown.edu/people/acrotty/)。 +`MgBench` 是一个针对机器生成日志数据的新分析基准,[Andrew Crotty](http://cs.brown.edu/people/acrotty/)。 下载数据: ```bash @@ -54,7 +55,6 @@ ENGINE = MergeTree() ORDER BY (machine_group, machine_name, log_time); ``` - ```sql CREATE TABLE mgbench.logs2 ( log_time DateTime, @@ -67,7 +67,6 @@ ENGINE = MergeTree() ORDER BY log_time; ``` - ```sql CREATE TABLE mgbench.logs3 ( log_time DateTime64, @@ -91,7 +90,7 @@ clickhouse-client --query "INSERT INTO mgbench.logs2 FORMAT CSVWithNames" < mgbe clickhouse-client --query "INSERT INTO mgbench.logs3 FORMAT CSVWithNames" < mgbench3.csv ``` -## 运行基准查询: {#run-benchmark-queries} +## 运行基准查询 {#run-benchmark-queries} ```sql USE mgbench; @@ -122,7 +121,6 @@ FROM ( GROUP BY machine_name; ``` - ```sql -- Q1.2: Which computer lab machines have been offline in the past day? @@ -254,7 +252,6 @@ WHERE status_code >= 200 AND log_time < TIMESTAMP '2012-05-20 00:00:00'; ``` - ```sql -- Q2.3: What was the average path depth for top-level requests in the past month? @@ -280,7 +277,6 @@ GROUP BY top_level ORDER BY top_level; ``` - ```sql -- Q2.4: During the last 3 months, which clients have made an excessive number of requests? @@ -293,7 +289,6 @@ HAVING COUNT(*) >= 100000 ORDER BY num_requests DESC; ``` - ```sql -- Q2.5: What are the daily unique visitors? @@ -308,7 +303,6 @@ GROUP BY dt ORDER BY dt; ``` - ```sql -- Q2.6: What are the average and maximum data transfer rates (Gbps)? @@ -322,7 +316,6 @@ FROM ( ) AS r; ``` - ```sql -- Q3.1: Did the indoor temperature reach freezing over the weekend? @@ -333,7 +326,6 @@ WHERE event_type = 'temperature' AND log_time >= '2019-11-29 17:00:00.000'; ``` - ```sql -- Q3.4: Over the past 6 months, how frequently were each door opened? @@ -348,7 +340,7 @@ GROUP BY device_name, ORDER BY ct DESC; ``` -下面的查询 3.5 使用了 UNION。 设置用于组合 SELECT 查询结果的模式。 当共享与 UNION 时未明确指定 UNION ALL 或 UNION DISTINCT 时,仅使用该设置。 +以下查询 3.5 使用了 UNION。设置用于组合 SELECT 查询结果的模式。此设置仅在共享 UNION 时使用,而未明确指定 UNION ALL 或 UNION DISTINCT。 ```sql SET union_default_mode = 'DISTINCT' ``` @@ -407,7 +399,6 @@ WHERE dt >= DATE '2019-06-01' AND dt < DATE '2019-09-01'; ``` - ```sql -- Q3.6: For each device category, what are the monthly power consumption metrics? @@ -453,4 +444,4 @@ ORDER BY yr, mo; ``` -数据也可用于 [Playground](https://sql.clickhouse.com) 中的交互式查询,[示例](https://sql.clickhouse.com?query_id=1MXMHASDLEQIP4P1D1STND)。 +数据还可以在 [Playground](https://sql.clickhouse.com) 中进行互动查询,[示例](https://sql.clickhouse.com?query_id=1MXMHASDLEQIP4P1D1STND)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/brown-benchmark.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/brown-benchmark.md.hash index 044d86f77df..a999d50de6f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/brown-benchmark.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/brown-benchmark.md.hash @@ -1 +1 @@ -6f9e00357462da2d +949b813f1200c59c diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/cell-towers.md b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/cell-towers.md index 65264d00dd7..dbfc2d9878a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/cell-towers.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/cell-towers.md @@ -1,9 +1,10 @@ --- -'description': '了解如何将 OpenCelliD 数据加载到 ClickHouse,连接 Apache Superset 到 ClickHouse,并基于数据构建仪表板' +'description': '学习如何将 OpenCelliD 数据加载到 ClickHouse,连接 Apache Superset 到 ClickHouse,并基于数据构建仪表板' 'sidebar_label': '地理数据' 'sidebar_position': 3 'slug': '/getting-started/example-datasets/cell-towers' -'title': '使用基站数据集的地理数据' +'title': '使用小区塔数据集的地理数据' +'doc_type': 'reference' --- import ConnectionDetails from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_gather_your_details_http.mdx'; @@ -34,29 +35,29 @@ import superset_cell_tower_dashboard from '@site/static/images/getting-started/e - 将 Apache Superset 连接到 ClickHouse - 基于数据集中的数据构建仪表板 -以下是本指南中创建的仪表板的预览: +以下是本指南中创建的仪表板预览: - + ## 获取数据集 {#get-the-dataset} -该数据集来自 [OpenCelliD](https://www.opencellid.org/) - 世界上最大的信号塔开放数据库。 +该数据集来自 [OpenCelliD](https://www.opencellid.org/) - 世界上最大的开放移动信号塔数据库。 -截至 2021 年,它包含了全球超过 4000 万条关于信号塔(GSM、LTE、UMTS 等)的记录,以及它们的地理坐标和元数据(国家代码、网络等)。 +截至 2021 年,它包含关于全球超过 4000 万个移动信号塔(GSM、LTE、UMTS 等)的记录,其中包含地理坐标和元数据(国家代码、网络等)。 -OpenCelliD 项目采用创意共享署名-相同方式共享 4.0 国际许可证, chúng tôi 在同一许可证条款下重新分发该数据集的快照。注册后可以下载最新版本的数据集。 +OpenCelliD 项目根据知识共享署名-相同方式共享 4.0 国际许可证进行许可,我们在相同许可证的条款下重新分发该数据集的快照。经过登录后,您可以下载数据集的最新版本。 ### 加载示例数据 {#load-the-sample-data} -ClickHouse Cloud 提供了一个简单的按钮来从 S3 上传此数据集。登录到您的 ClickHouse Cloud 组织,或者在 [ClickHouse.cloud](https://clickhouse.cloud) 创建一个免费试用账户。 +ClickHouse Cloud 提供了一键式上传此数据集到 S3 的功能。登录到您的 ClickHouse Cloud 组织,或在 [ClickHouse.cloud](https://clickhouse.cloud) 创建免费试用。 -从 **示例数据** 选项卡中选择 **信号塔** 数据集,并 **加载数据**: +从 **示例数据** 选项卡中选择 **移动信号塔** 数据集,然后 **加载数据**: - + ### 检查 cell_towers 表的模式 {#examine-the-schema-of-the-cell_towers-table} ```sql @@ -65,7 +66,7 @@ DESCRIBE TABLE cell_towers -这是 `DESCRIBE` 的输出。稍后在本指南中将描述字段类型的选择。 +这是 `DESCRIBE` 的输出。接下来,本指南将描述字段类型的选择。 ```response ┌─name──────────┬─type──────────────────────────────────────────────────────────────────┬ │ radio │ Enum8('' = 0, 'CDMA' = 1, 'GSM' = 2, 'LTE' = 3, 'NR' = 4, 'UMTS' = 5) │ @@ -122,7 +123,7 @@ INSERT INTO cell_towers SELECT * FROM s3('https://datasets-documentation.s3.amaz ## 运行一些示例查询 {#examples} -1. 按类型分类的信号塔数量: +1. 按类型统计移动信号塔数量: ```sql SELECT radio, count() AS c FROM cell_towers GROUP BY radio ORDER BY c DESC @@ -139,7 +140,7 @@ SELECT radio, count() AS c FROM cell_towers GROUP BY radio ORDER BY c DESC 5 rows in set. Elapsed: 0.011 sec. Processed 43.28 million rows, 43.28 MB (3.83 billion rows/s., 3.83 GB/s.) ``` -2. 按 [手机国家代码 (MCC)](https://en.wikipedia.org/wiki/Mobile_country_code) 分类的信号塔: +2. 按 [移动国家代码 (MCC)](https://en.wikipedia.org/wiki/Mobile_country_code) 查询移动信号塔: ```sql SELECT mcc, count() FROM cell_towers GROUP BY mcc ORDER BY count() DESC LIMIT 10 @@ -161,11 +162,11 @@ SELECT mcc, count() FROM cell_towers GROUP BY mcc ORDER BY count() DESC LIMIT 10 10 rows in set. Elapsed: 0.019 sec. Processed 43.28 million rows, 86.55 MB (2.33 billion rows/s., 4.65 GB/s.) ``` -根据上述查询和 [MCC 列表](https://en.wikipedia.org/wiki/Mobile_country_code),信号塔数量最多的国家是:美国、德国和俄罗斯。 +根据上述查询和 [MCC 列表](https://en.wikipedia.org/wiki/Mobile_country_code),有最多移动信号塔的国家是美国、德国和俄罗斯。 -您可能希望在 ClickHouse 中创建一个 [字典](../../sql-reference/dictionaries/index.md) 来解码这些值。 +您可以在 ClickHouse 中创建一个 [字典](../../sql-reference/dictionaries/index.md) 来解码这些值。 -## 用例:结合地理数据 {#use-case} +## 用例:融合地理数据 {#use-case} 使用 [`pointInPolygon`](/sql-reference/functions/geo/coordinates.md/#pointinpolygon) 函数。 @@ -190,7 +191,7 @@ moscow (polygon Array(Tuple(Float64, Float64))); -2. 这是莫斯科(不包括“新莫斯科”)的大致形状: +2. 这是莫斯科的粗略轮廓(不包括“新莫斯科”): ```sql INSERT INTO moscow VALUES ([(37.84172564285271, 55.78000432402266), @@ -244,7 +245,7 @@ INSERT INTO moscow VALUES ([(37.84172564285271, 55.78000432402266), (37.84172564285271, 55.78000432402266)]); ``` -3. 检查莫斯科内有多少信号塔: +3. 检查莫斯科有多少个移动信号塔: ```sql SELECT count() FROM cell_towers @@ -258,39 +259,39 @@ WHERE pointInPolygon((lon, lat), (SELECT * FROM moscow)) 1 rows in set. Elapsed: 0.067 sec. Processed 43.28 million rows, 692.42 MB (645.83 million rows/s., 10.33 GB/s.) ``` -## 模式评审 {#review-of-the-schema} +## 模式审查 {#review-of-the-schema} -在 Superset 中构建可视化之前,查看您将要使用的列。该数据集主要提供全球移动信号塔的位置信息(经度和纬度)以及无线电类型。列的描述可以在 [社区论坛](https://community.opencellid.org/t/documenting-the-columns-in-the-downloadable-cells-database-csv/186) 中找到。本次构建的可视化所使用的列描述如下: +在 Superset 中构建可视化之前,请查看您将使用的列。该数据集主要提供全球移动信号塔的位置(经度和纬度)和无线电类型。各列的描述可以在 [社区论坛](https://community.opencellid.org/t/documenting-the-columns-in-the-downloadable-cells-database-csv/186) 中找到。将在仪表板中使用的列描述如下: -以下是从 OpenCelliD 论坛获取的列描述: +以下是来自 OpenCelliD 论坛的字段描述: -| 列 | 描述 | -|--------------|--------------------------------------------------------| -| radio | 技术代:CDMA、GSM、UMTS、5G NR | -| mcc | 手机国家代码:`204` 是荷兰 | -| lon | 经度:与纬度一起,近似信号塔位置 | -| lat | 纬度:与经度一起,近似信号塔位置 | +| 列名 | 描述 | +|--------------|---------------------------------------------------| +| radio | 技术代:CDMA、GSM、UMTS、5G NR | +| mcc | 移动国家代码:`204` 是荷兰 | +| lon | 经度:配合纬度,估算塔位置 | +| lat | 纬度:配合经度,估算塔位置 | :::tip mcc -要查找您的 MCC,请查看 [移动网络代码](https://en.wikipedia.org/wiki/Mobile_country_code),并在 **手机国家代码** 列中使用三位数字。 +要查找您的 MCC,请查看 [移动网络代码](https://en.wikipedia.org/wiki/Mobile_country_code),并在 **移动国家代码** 列中使用这三个数字。 ::: -该表的模式被设计为在磁盘上紧凑存储并提高查询速度。 -- `radio` 数据以 `Enum8` (`UInt8`) 格式存储,而不是字符串。 -- `mcc` 或手机国家代码以 `UInt16` 格式存储,因为我们知道其范围是 1 - 999。 -- `lon` 和 `lat` 为 `Float64`。 +该表的模式设计是为了在磁盘上高效存储和快速查询。 +- `radio` 数据以 `Enum8`(`UInt8`)格式存储,而不是字符串。 +- `mcc` 或移动国家代码以 `UInt16` 格式存储,因为我们知道范围是 1 - 999。 +- `lon` 和 `lat` 是 `Float64` 类型。 -本指南中没有其他字段在查询或可视化中使用,但如果您对此感兴趣,可以在上面链接的论坛中找到它们的描述。 +本指南中的查询或可视化未使用其他字段,但如果您感兴趣,可以在上述论坛中找到描述。 ## 使用 Apache Superset 构建可视化 {#build-visualizations-with-apache-superset} -Superset 可以轻松地通过 Docker 运行。如果您已经在运行 Superset,只需使用 `pip install clickhouse-connect` 将其连接到 ClickHouse。如果您需要安装 Superset,请直接打开 **在 Docker 中启动 Apache Superset**。 +Superset 可以轻松通过 Docker 运行。如果您已经运行了 Superset,您只需使用 `pip install clickhouse-connect` 添加 ClickHouse 连接。如果您需要安装 Superset,请直接打开 **在 Docker 中启动 Apache Superset**。 -要使用 OpenCelliD 数据集构建 Superset 仪表板,您应: +要使用 OpenCelliD 数据集构建 Superset 仪表板,您应该: - 将您的 ClickHouse 服务添加为 Superset **数据库** -- 将表 **cell_towers** 添加为 Superset **数据集** +- 将 **cell_towers** 表添加为 Superset **数据集** - 创建一些 **图表** - 将图表添加到 **仪表板** @@ -298,70 +299,70 @@ Superset 可以轻松地通过 Docker 运行。如果您已经在运行 Superset -在 Superset 中,可以通过选择数据库类型并提供连接详细信息来添加数据库。打开 Superset,寻找 **+**,它有一个包含 **数据** 和 **连接数据库** 选项的菜单。 +在 Superset 中,可以通过选择数据库类型并提供连接详细信息来添加数据库。打开 Superset,寻找 **+**,它会有一个菜单,提供 **数据** 和 **连接数据库** 选项。 从列表中选择 **ClickHouse Connect**: - + :::note -如果 **ClickHouse Connect** 不是您的选项之一,那么您需要安装它。命令为 `pip install clickhouse-connect`,更多信息 [可在此处查找](https://pypi.org/project/clickhouse-connect/)。 +如果 **ClickHouse Connect** 不是您的选项之一,则需要安装它。命令是 `pip install clickhouse-connect`,更多信息请参见 [此处](https://pypi.org/project/clickhouse-connect/)。 ::: -#### 添加您的连接详细信息: {#add-your-connection-details} +#### 添加连接详细信息 {#add-your-connection-details} :::tip -连接到 ClickHouse Cloud 或其他强制使用 SSL 的 ClickHouse 系统时,请确保启用 **SSL**。 +确保您在连接到 ClickHouse Cloud 或其他强制使用 SSL 的 ClickHouse 系统时启用 **SSL**。 ::: -### 将表 **cell_towers** 添加为 Superset **数据集** {#add-the-table-cell_towers-as-a-superset-dataset} +### 将 **cell_towers** 表添加为 Superset **数据集** {#add-the-table-cell_towers-as-a-superset-dataset} -在 Superset 中,**数据集** 映射到数据库中的一个表。单击添加数据集并选择您的 ClickHouse 服务,包含您表的数据库 (`default`),以及选择 `cell_towers` 表: +在 Superset 中,**数据集** 对应于数据库中的一个表。单击添加数据集,选择您的 ClickHouse 服务、包含您表的数据库(`default`),然后选择 `cell_towers` 表: ### 创建一些 **图表** {#create-some-charts} -在 Superset 中选择添加图表时,您必须指定数据集 (`cell_towers`) 和图表类型。由于 OpenCelliD 数据集提供了信号塔的经纬度坐标,因此我们将创建一个 **地图** 图表。**deck.gl 散点图** 类型适合此数据集,因为它可以很好地处理地图上的密集数据点。 +当您选择在 Superset 中添加图表时,需要指定数据集(`cell_towers`)和图表类型。由于 OpenCelliD 数据集为移动信号塔提供经度和纬度坐标,因此我们将创建一个 **地图** 图表。**deck.gl 散点图** 类型适合此数据集,因为它在地图上可以很好地处理密集数据点。 -#### 指定地图使用的查询 {#specify-the-query-used-for-the-map} +#### 指定用于地图的查询 {#specify-the-query-used-for-the-map} -deck.gl 散点图需要经度和纬度,并且可以对查询应用一个或多个过滤器。在此示例中,应用了两个过滤器:一个用于具有 UMTS 无线电的信号塔,另一个用于分配给荷兰的手机国家代码。 +deck.gl 散点图需要经度和纬度,查询还可以应用一个或多个过滤器。在此示例中,应用了两个过滤器,一个是 UMTS 无线电的移动信号塔,一个是分配给荷兰的移动国家代码。 字段 `lon` 和 `lat` 包含经度和纬度: -添加过滤器 `mcc` = `204` (或替换为其他 `mcc` 值): +添加一个过滤器,`mcc` = `204` (或替换为任何其他 `mcc` 值): -添加过滤器 `radio` = `'UMTS'` (或替换为其他 `radio` 值,您可以在 `DESCRIBE TABLE cell_towers` 的输出中查看选项): +添加一个过滤器,`radio` = `'UMTS'` (或替换为任何其他 `radio` 值,可以在 `DESCRIBE TABLE cell_towers` 的输出中查看可选项): -这是针对 `radio = 'UMTS'` 和 `mcc = 204` 的图表的完整配置: +这是过滤 `radio = 'UMTS'` 和 `mcc = 204` 的图表完整配置: -单击 **更新图表** 以呈现可视化效果。 +单击 **更新图表** 以呈现可视化。 ### 将图表添加到 **仪表板** {#add-the-charts-to-a-dashboard} -此截图显示了具有 LTE、UMTS 和 GSM 无线电的信号塔位置。所有图表都是以相同方式创建的,并且它们被添加到一个仪表板中。 +此屏幕截图显示了带有 LTE、UMTS 和 GSM 无线电的移动信号塔位置。所有图表的创建方式相同,并都添加到一个仪表板中。 - + :::tip -数据也可在 [Playground](https://sql.clickhouse.com) 中进行交互式查询。 +该数据也可用于 [Playground](https://sql.clickhouse.com) 中进行交互查询。 -这个 [示例](https://sql.clickhouse.com?query_id=UV8M4MAGS2PWAUOAYAAARM) 将为您自动填充用户名甚至查询。 +这个 [示例](https://sql.clickhouse.com?query_id=UV8M4MAGS2PWAUOAYAAARM) 将为您填充用户名甚至查询。 -虽然您不能在 Playground 中创建表,但您可以运行所有查询,甚至使用 Superset(调整主机名和端口号)。 +虽然您无法在 Playground 中创建表,但可以运行所有查询,甚至使用 Superset(调整主机名和端口号)。 ::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/cell-towers.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/cell-towers.md.hash index d38047c8e04..e470b059a85 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/cell-towers.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/cell-towers.md.hash @@ -1 +1 @@ -8f6475c38f2319ab +8bfa107a7034a83b diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/covid19.md b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/covid19.md index 1d964b98cb4..148684d6d06 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/covid19.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/covid19.md @@ -1,21 +1,22 @@ --- -'description': 'COVID-19 Open-Data 是一个大型的开源 DATABASE,包含 COVID-19 流行病学数据及相关因素,如人口统计、经济和政府响应。' -'sidebar_label': 'COVID-19 Open-Data' +'description': 'COVID-19 开放数据是一个大型的开源 DATABASE,包含 COVID-19 流行病学数据和相关因素,如人口统计、经济和政府响应。' +'sidebar_label': 'COVID-19 开放数据' 'slug': '/getting-started/example-datasets/covid19' -'title': 'COVID-19 Open-Data' +'title': 'COVID-19 开放数据' +'doc_type': 'reference' --- -COVID-19 Open-Data 旨在构建最大的 Covid-19 流行病学数据库,并提供一套强大的广泛协变量。它包括来自公开渠道、已授权的数据,涉及人口统计、经济、流行病学、地理、健康、住院、流动性、政府响应、天气等多个方面。 +COVID-19 Open-Data 尝试汇集最大的 Covid-19 流行病数据库,此外还提供了一套强大的扩展协变量。它包括与人口统计、经济、流行病学、地理、健康、住院、流动性、政府应对、天气等相关的开放、公共来源的数据,均已获得许可。 -详细信息可以在 GitHub [这里](https://github.com/GoogleCloudPlatform/covid-19-open-data) 查阅。 +详细信息请查看 GitHub [这里](https://github.com/GoogleCloudPlatform/covid-19-open-data)。 将这些数据插入 ClickHouse 非常简单... :::note -以下命令是在 [ClickHouse Cloud](https://clickhouse.cloud) 的 **Production** 实例上执行的。您也可以在本地安装的环境中轻松运行它们。 +以下命令在 [ClickHouse Cloud](https://clickhouse.cloud) 的 **Production** 实例上执行。您也可以在本地安装上轻松运行它们。 ::: -1. 让我们看看数据的样子: +1. 让我们看看数据是什么样的: ```sql DESCRIBE url( @@ -51,7 +52,7 @@ FROM url('https://storage.googleapis.com/covid19-open-data/v3/epidemiology.csv') LIMIT 100; ``` -注意 `url` 函数可以轻松从 CSV 文件中读取数据: +注意 `url` 函数可以轻松地从 CSV 文件中读取数据: ```response ┌─c1─────────┬─c2───────────┬─c3────────────┬─c4───────────┬─c5────────────┬─c6─────────┬─c7───────────────────┬─c8──────────────────┬─c9───────────────────┬─c10───────────────┐ @@ -65,7 +66,7 @@ LIMIT 100; └────────────┴──────────────┴───────────────┴──────────────┴───────────────┴────────────┴──────────────────────┴─────────────────────┴──────────────────────┴───────────────────┘ ``` -3. 现在我们在了解数据的样子后,将创建一个表: +3. 现在我们知道数据的样子了,来创建一个表: ```sql CREATE TABLE covid19 ( @@ -106,7 +107,7 @@ INSERT INTO covid19 ); ``` -5. 进行得很快 - 让我们看看插入了多少行: +5. 这速度相当快 - 让我们看看插入了多少行: ```sql SELECT formatReadableQuantity(count()) @@ -119,7 +120,7 @@ FROM covid19; └─────────────────────────────────┘ ``` -6. 让我们看看记录了多少 Covid-19 的总病例: +6. 让我们看看记录的 Covid-19 确诊病例总数: ```sql SELECT formatReadableQuantity(sum(new_confirmed)) @@ -132,7 +133,7 @@ FROM covid19; └────────────────────────────────────────────┘ ``` -7. 您会注意到数据中很多日期的值为 0 - 要么是周末,要么是没有每天报告数字的日子。我们可以使用窗口函数来平滑新病例的每日平均值: +7. 您会注意到数据中有很多 0 的日期 - 要么是周末,要么是每日数据未报告的日子。我们可以使用窗口函数来平滑新病例的每日平均数: ```sql SELECT @@ -143,7 +144,7 @@ SELECT FROM covid19; ``` -8. 这个查询确定每个地点的最新值。我们不能使用 `max(date)`,因为并非所有国家每天都有报告,所以我们使用 `ROW_NUMBER` 获取最后一行: +8. 此查询确定每个位置的最新值。我们不能使用 `max(date)`,因为并不是所有国家每天都有报告,因此我们使用 `ROW_NUMBER` 抓取最后一行: ```sql WITH latest_deaths_data AS @@ -151,7 +152,7 @@ WITH latest_deaths_data AS date, new_deceased, new_confirmed, - ROW_NUMBER() OVER (PARTITION BY location_key ORDER BY date DESC) as rn + ROW_NUMBER() OVER (PARTITION BY location_key ORDER BY date DESC) AS rn FROM covid19) SELECT location_key, date, @@ -162,7 +163,7 @@ FROM latest_deaths_data WHERE rn=1; ``` -9. 我们可以使用 `lagInFrame` 来确定每天新病例的 `LAG`。在这个查询中,我们按 `US_DC` 位置过滤: +9. 我们可以使用 `lagInFrame` 来确定每一天新病例的 `LAG`。在此查询中,我们按 `US_DC` 位置进行过滤: ```sql SELECT @@ -174,7 +175,7 @@ FROM covid19 WHERE location_key = 'US_DC'; ``` -响应看起来像: +响应如下: ```response ┌─confirmed_cases_delta─┬─new_confirmed─┬─location_key─┬───────date─┐ @@ -196,7 +197,7 @@ WHERE location_key = 'US_DC'; │ 3 │ 21 │ US_DC │ 2020-03-23 │ ``` -10. 这个查询计算每天新病例的变化百分比,并在结果集中包含一个简单的 `increase` 或 `decrease` 列: +10. 此查询计算每日新病例的变化百分比,并在结果集中包含一个简单的 `increase` 或 `decrease` 列: ```sql WITH confirmed_lag AS ( @@ -227,7 +228,7 @@ FROM confirmed_percent_change WHERE location_key = 'US_DC'; ``` -结果看起来像 +结果如下: ```response ┌───────date─┬─new_confirmed─┬─percent_change─┬─trend─────┐ @@ -261,5 +262,5 @@ WHERE location_key = 'US_DC'; ``` :::note -正如在 [GitHub repo](https://github.com/GoogleCloudPlatform/covid-19-open-data) 中提到的,该数据集自 2022 年 9 月 15 日起不再更新。 +正如在 [GitHub 仓库](https://github.com/GoogleCloudPlatform/covid-19-open-data) 中提到的,数据集自 2022 年 9 月 15 日起不再更新。 ::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/covid19.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/covid19.md.hash index caef2b440e8..1c80c702157 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/covid19.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/covid19.md.hash @@ -1 +1 @@ -604ac96d5d8f0b2b +cd7f48c59247bb44 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/criteo.md b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/criteo.md index c99a1a0d618..4dfc358d4d4 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/criteo.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/criteo.md @@ -1,13 +1,14 @@ --- -'description': '来自 Criteo 的一 terabyte 点击日志' -'sidebar_label': '来自 Criteo 的 Terabyte 点击日志' +'description': '来自 Criteo 的一 TB 点击日志' +'sidebar_label': 'Criteo 的 TB 点击日志' 'slug': '/getting-started/example-datasets/criteo' -'title': '来自 Criteo 的 Terabyte 点击日志' +'title': 'Criteo 的 TB 点击日志' +'doc_type': 'reference' --- -下载数据从 http://labs.criteo.com/downloads/download-terabyte-click-logs/ +下载数据来自 http://labs.criteo.com/downloads/download-terabyte-click-logs/ -创建一个表以导入日志到: +创建一个表以导入日志到: ```sql CREATE TABLE criteo_log ( @@ -55,13 +56,13 @@ CREATE TABLE criteo_log ( ) ENGINE = Log; ``` -插入数据: +插入数据: ```bash $ for i in {00..23}; do echo $i; zcat datasets/criteo/day_${i#0}.gz | sed -r 's/^/2000-01-'${i/00/24}'\t/' | clickhouse-client --host=example-perftest01j --query="INSERT INTO criteo_log FORMAT TabSeparated"; done ``` -为转换的数据创建一个表: +为转换后的数据创建一个表: ```sql CREATE TABLE criteo @@ -112,7 +113,7 @@ PARTITION BY toYYYYMM(date) ORDER BY (date, icat1) ``` -从原始日志转换数据并将其放入第二个表: +从原始日志转换数据并放入第二个表: ```sql INSERT INTO diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/criteo.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/criteo.md.hash index 526eca4c21e..520e7b7aa3e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/criteo.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/criteo.md.hash @@ -1 +1 @@ -b094f8bc22734261 +10c51b01249e5dbe diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/dbpedia.md b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/dbpedia.md new file mode 100644 index 00000000000..e29f84d9011 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/dbpedia.md @@ -0,0 +1,315 @@ +--- +'description': '数据集包含来自 Wikipedia 的 100 万篇文章及其向量嵌入' +'sidebar_label': 'dbpedia 数据集' +'slug': '/getting-started/example-datasets/dbpedia-dataset' +'title': 'dbpedia 数据集' +'keywords': +- 'semantic search' +- 'vector similarity' +- 'approximate nearest neighbours' +- 'embeddings' +'doc_type': 'reference' +--- + +The [dbpedia 数据集](https://huggingface.co/datasets/Qdrant/dbpedia-entities-openai3-text-embedding-3-large-1536-1M) 包含来自 Wikipedia 的 100 万篇文章及其使用 [text-embedding-3-large](https://platform.openai.com/docs/models/text-embedding-3-large) 模型生成的向量嵌入。 + +该数据集是理解向量嵌入、向量相似性搜索和生成 AI 的绝佳入门数据集。我们使用该数据集演示 ClickHouse 中的 [近似最近邻搜索](../../engines/table-engines/mergetree-family/annindexes.md) 以及一个简单但强大的问答应用程序。 + +## 数据集详情 {#dataset-details} + +该数据集包含位于 [huggingface.co](https://huggingface.co/api/datasets/Qdrant/dbpedia-entities-openai3-text-embedding-3-large-1536-1M/parquet/default/train/) 的 26 个 `Parquet` 文件。文件名为 `0.parquet`、`1.parquet`、...、`25.parquet`。要查看数据集的一些示例行,请访问这个 [Hugging Face 页面](https://huggingface.co/datasets/Qdrant/dbpedia-entities-openai3-text-embedding-3-large-1536-1M)。 + +## 创建表 {#create-table} + +创建 `dbpedia` 表以存储文章 ID、标题、文本和嵌入向量: + +```sql +CREATE TABLE dbpedia +( + id String, + title String, + text String, + vector Array(Float32) CODEC(NONE) +) ENGINE = MergeTree ORDER BY (id); + +``` + +## 加载表 {#load-table} + +要从所有 Parquet 文件加载数据集,请运行以下 shell 命令: + +```shell +$ seq 0 25 | xargs -P1 -I{} clickhouse client -q "INSERT INTO dbpedia SELECT _id, title, text, \"text-embedding-3-large-1536-embedding\" FROM url('https://huggingface.co/api/datasets/Qdrant/dbpedia-entities-openai3-text-embedding-3-large-1536-1M/parquet/default/train/{}.parquet') SETTINGS max_http_get_redirects=5,enable_url_encoding=0;" +``` + +或者,可以像下面所示的那样运行单个 SQL 语句以加载每个 Parquet 文件: + +```sql +INSERT INTO dbpedia SELECT _id, title, text, "text-embedding-3-large-1536-embedding" FROM url('https://huggingface.co/api/datasets/Qdrant/dbpedia-entities-openai3-text-embedding-3-large-1536-1M/parquet/default/train/0.parquet') SETTINGS max_http_get_redirects=5,enable_url_encoding=0; +INSERT INTO dbpedia SELECT _id, title, text, "text-embedding-3-large-1536-embedding" FROM url('https://huggingface.co/api/datasets/Qdrant/dbpedia-entities-openai3-text-embedding-3-large-1536-1M/parquet/default/train/1.parquet') SETTINGS max_http_get_redirects=5,enable_url_encoding=0; +... +INSERT INTO dbpedia SELECT _id, title, text, "text-embedding-3-large-1536-embedding" FROM url('https://huggingface.co/api/datasets/Qdrant/dbpedia-entities-openai3-text-embedding-3-large-1536-1M/parquet/default/train/25.parquet') SETTINGS max_http_get_redirects=5,enable_url_encoding=0; + +``` + +验证在 `dbpedia` 表中看到 100 万行: + +```sql +SELECT count(*) +FROM dbpedia + + ┌─count()─┐ +1. │ 1000000 │ + └─────────┘ +``` + +## 语义搜索 {#semantic-search} + +推荐阅读: ["向量嵌入 OpenAPI 指南"](https://platform.openai.com/docs/guides/embeddings) + +使用向量嵌入的语义搜索(也称为 _相似性搜索_)涉及以下步骤: + +- 接受来自用户的自然语言搜索查询,例如 _"告诉我一些风景优美的火车旅行"_、_“设定在欧洲的悬疑小说”_ 等等 +- 使用 LLM 模型为搜索查询生成嵌入向量 +- 在数据集中查找与搜索嵌入向量最近的邻居 + +_最近邻居_ 是指与用户查询相关的文档、图像或内容。检索到的结果是生成 AI 应用程序中检索增强生成 (RAG) 的关键输入。 + +## 运行暴力搜索向量相似性搜索 {#run-a-brute-force-vector-similarity-search} + +KNN (k - 最近邻) 搜索或暴力搜索涉及计算数据集中每个向量与搜索嵌入向量之间的距离,然后对距离进行排序以获得最近邻居。 使用 `dbpedia` 数据集,观察语义搜索的快速技术是使用数据集本身的嵌入向量作为搜索向量。例如: + +```sql title="Query" +SELECT id, title +FROM dbpedia +ORDER BY cosineDistance(vector, ( SELECT vector FROM dbpedia WHERE id = '') ) ASC +LIMIT 20 +``` + +```response title="Response" + ┌─id────────────────────────────────────────┬─title───────────────────────────┐ + 1. │ │ The Remains of the Day │ + 2. │ │ The Remains of the Day (film) │ + 3. │ │ Never Let Me Go (novel) │ + 4. │ │ Last Orders │ + 5. │ │ The Unconsoled │ + 6. │ │ The Hours (novel) │ + 7. │ │ An Artist of the Floating World │ + 8. │ │ Heat and Dust │ + 9. │ │ A Pale View of Hills │ +10. │ │ Howards End (film) │ +11. │ │ When We Were Orphans │ +12. │ │ A Passage to India (film) │ +13. │ │ Memoirs of a Survivor │ +14. │ │ The Child in Time │ +15. │ │ The Sea, the Sea │ +16. │ │ The Master (novel) │ +17. │ │ The Memorial │ +18. │ │ The Hours (film) │ +19. │ │ Human Remains (film) │ +20. │ │ Kazuo Ishiguro │ + └───────────────────────────────────────────┴─────────────────────────────────┘ +#highlight-next-line +20 rows in set. Elapsed: 0.261 sec. Processed 1.00 million rows, 6.22 GB (3.84 million rows/s., 23.81 GB/s.) +``` + +记录查询延迟,以便与 ANN(使用向量索引)的查询延迟进行比较。 +还应记录冷启动操作系统文件缓存情况下的查询延迟及 `max_threads=1` 的情况,以识别实际计算使用情况和存储带宽使用情况(将其外推到拥有数百万个向量的生产数据集!) + +## 构建向量相似性索引 {#build-vector-similarity-index} + +运行以下 SQL 以在 `vector` 列上定义并构建向量相似性索引: + +```sql +ALTER TABLE dbpedia ADD INDEX vector_index vector TYPE vector_similarity('hnsw', 'cosineDistance', 1536, 'bf16', 64, 512); + +ALTER TABLE dbpedia MATERIALIZE INDEX vector_index SETTINGS mutations_sync = 2; +``` + +索引创建和搜索的参数及性能考虑在 [文档](../../engines/table-engines/mergetree-family/annindexes.md) 中进行了描述。 + +构建和保存索引可能需要几分钟,具体取决于可用的 CPU 核心数量和存储带宽。 + +## 执行 ANN 搜索 {#perform-ann-search} + +_近似最近邻_ 或 ANN 是指一组技术(例如,图和随机森林等特定数据结构),它们计算结果的速度比精确向量搜索快得多。结果的准确度通常对于实际使用来说是“足够好”的。许多近似技术提供参数以调整结果准确性和搜索时间之间的权衡。 + +一旦向量相似性索引构建完成,向量搜索查询将自动使用该索引: + +```sql title="Query" +SELECT + id, + title +FROM dbpedia +ORDER BY cosineDistance(vector, ( + SELECT vector + FROM dbpedia + WHERE id = '' + )) ASC +LIMIT 20 +``` + +```response title="Response" + ┌─id──────────────────────────────────────────────┬─title─────────────────────────────────┐ + 1. │ │ Glacier Express │ + 2. │ │ BVZ Zermatt-Bahn │ + 3. │ │ Gornergrat railway │ + 4. │ │ RegioExpress │ + 5. │ │ Matterhorn Gotthard Bahn │ + 6. │ │ Rhaetian Railway │ + 7. │ │ Gotthard railway │ + 8. │ │ Furka–Oberalp railway │ + 9. │ │ Jungfrau railway │ +10. │ │ Monte Generoso railway │ +11. │ │ Montreux–Oberland Bernois railway │ +12. │ │ Brienz–Rothorn railway │ +13. │ │ Lauterbrunnen–Mürren mountain railway │ +14. │ │ Luzern–Stans–Engelberg railway line │ +15. │ │ Rigi Railways │ +16. │ │ Saint-Gervais–Vallorcine railway │ +17. │ │ Gatwick Express │ +18. │ │ Brünig railway line │ +19. │ │ Regional-Express │ +20. │ │ Schynige Platte railway │ + └─────────────────────────────────────────────────┴───────────────────────────────────────┘ +#highlight-next-line +20 rows in set. Elapsed: 0.025 sec. Processed 32.03 thousand rows, 2.10 MB (1.29 million rows/s., 84.80 MB/s.) +``` + +## 为搜索查询生成嵌入 {#generating-embeddings-for-search-query} + +到目前为止看到的相似性搜索查询使用 `dbpedia` 表中的现有向量作为搜索向量。在实际应用中,搜索向量必须为用户输入的查询生成,该查询可以是自然语言的。搜索向量应使用与生成数据集嵌入向量相同的 LLM 模型生成。 + +下面列出了一个示例 Python 脚本,演示如何程序性地调用 OpenAI API 来使用 `text-embedding-3-large` 模型生成嵌入向量。然后将搜索嵌入向量作为参数传递给 `SELECT` 查询中的 `cosineDistance()` 函数。 + +运行该脚本需要在环境变量 `OPENAI_API_KEY` 中设置 OpenAI API 密钥。 +OpenAI API 密钥可在 https://platform.openai.com 注册后获取。 + +```python +import sys +from openai import OpenAI +import clickhouse_connect + +ch_client = clickhouse_connect.get_client(compress=False) # Pass ClickHouse credentials +openai_client = OpenAI() # Set OPENAI_API_KEY environment variable + +def get_embedding(text, model): + text = text.replace("\n", " ") + return openai_client.embeddings.create(input = [text], model=model, dimensions=1536).data[0].embedding + + +while True: + # Accept the search query from user + print("Enter a search query :") + input_query = sys.stdin.readline(); + + # Call OpenAI API endpoint to get the embedding + print("Generating the embedding for ", input_query); + embedding = get_embedding(input_query, + model='text-embedding-3-large') + + # Execute vector search query in ClickHouse + print("Querying clickhouse...") + params = {'v1':embedding, 'v2':10} + result = ch_client.query("SELECT id,title,text FROM dbpedia ORDER BY cosineDistance(vector, %(v1)s) LIMIT %(v2)s", parameters=params) + + for row in result.result_rows: + print(row[0], row[1], row[2]) + print("---------------") +``` + +## 问答演示应用程序 {#q-and-a-demo-application} + +上述示例演示了使用 ClickHouse 的语义搜索和文档检索。接下来是一个非常简单但具有高潜力的生成 AI 示例应用程序。 + +该应用执行以下步骤: + +1. 接受用户输入的 _主题_ +2. 通过调用 OpenAI API 生成与 `text-embedding-3-large` 模型关联的 _主题_ 的嵌入向量 +3. 使用在 `dbpedia` 表上进行的向量相似性搜索检索高度相关的 Wikipedia 文章/文档 +4. 接受用户与 _主题_ 相关的自然语言自由形式问题 +5. 使用 OpenAI `gpt-3.5-turbo` 聊天 API 根据在步骤 #3 中检索到的文档中的知识回答问题。 + 步骤 #3 中检索到的文档作为 _上下文_ 传递给聊天 API,并且是生成 AI 中的关键链接。 + +先列出运行问答应用程序的一些对话示例,然后是问答应用程序的代码。运行该应用程序需要在环境变量 `OPENAI_API_KEY` 中设置 OpenAI API 密钥。OpenAI API 密钥可在 https://platform.openai.com 注册后获取。 + +```shell +$ python3 QandA.py + +Enter a topic : FIFA world cup 1990 +Generating the embedding for 'FIFA world cup 1990' and collecting 100 articles related to it from ClickHouse... + +Enter your question : Who won the golden boot +Salvatore Schillaci of Italy won the Golden Boot at the 1990 FIFA World Cup. + + +Enter a topic : Cricket world cup +Generating the embedding for 'Cricket world cup' and collecting 100 articles related to it from ClickHouse... + +Enter your question : Which country has hosted the world cup most times +England and Wales have hosted the Cricket World Cup the most times, with the tournament being held in these countries five times - in 1975, 1979, 1983, 1999, and 2019. + +$ +``` + +代码: + +```Python +import sys +import time +from openai import OpenAI +import clickhouse_connect + +ch_client = clickhouse_connect.get_client(compress=False) # Pass ClickHouse credentials here +openai_client = OpenAI() # Set the OPENAI_API_KEY environment variable + +def get_embedding(text, model): + text = text.replace("\n", " ") + return openai_client.embeddings.create(input = [text], model=model, dimensions=1536).data[0].embedding + +while True: + # Take the topic of interest from user + print("Enter a topic : ", end="", flush=True) + input_query = sys.stdin.readline() + input_query = input_query.rstrip() + + # Generate an embedding vector for the search topic and query ClickHouse + print("Generating the embedding for '" + input_query + "' and collecting 100 articles related to it from ClickHouse..."); + embedding = get_embedding(input_query, + model='text-embedding-3-large') + + params = {'v1':embedding, 'v2':100} + result = ch_client.query("SELECT id,title,text FROM dbpedia ORDER BY cosineDistance(vector, %(v1)s) LIMIT %(v2)s", parameters=params) + + # Collect all the matching articles/documents + results = "" + for row in result.result_rows: + results = results + row[2] + + print("\nEnter your question : ", end="", flush=True) + question = sys.stdin.readline(); + + # Prompt for the OpenAI Chat API + query = f"""Use the below content to answer the subsequent question. If the answer cannot be found, write "I don't know." + +Content: +\"\"\" +{results} +\"\"\" + +Question: {question}""" + + GPT_MODEL = "gpt-3.5-turbo" + response = openai_client.chat.completions.create( + messages=[ + {'role': 'system', 'content': "You answer questions about {input_query}."}, + {'role': 'user', 'content': query}, + ], + model=GPT_MODEL, + temperature=0, + ) + + # Print the answer to the question! + print(response.choices[0].message.content) + print("\n") +``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/dbpedia.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/dbpedia.md.hash new file mode 100644 index 00000000000..d581ff3ff95 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/dbpedia.md.hash @@ -0,0 +1 @@ +8f07d3c7dbaed6a9 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/environmental-sensors.md b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/environmental-sensors.md index 216c06e98e7..b20b05d1511 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/environmental-sensors.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/environmental-sensors.md @@ -1,21 +1,22 @@ --- -'description': '来自 Sensor.Community 的超过 200 亿条记录,Sensor.Community 是一个由贡献者驱动的全球传感器网络,创建开放的环境数据。' +'description': '来自 Sensor.Community 的超过 20 亿条数据记录,这是一个由贡献者驱动的全球传感器网络,创建开放的环境数据。' 'sidebar_label': '环境传感器数据' 'slug': '/getting-started/example-datasets/environmental-sensors' 'title': '环境传感器数据' +'doc_type': 'reference' --- import Image from '@theme/IdealImage'; import no_events_per_day from '@site/static/images/getting-started/example-datasets/sensors_01.png'; import sensors_02 from '@site/static/images/getting-started/example-datasets/sensors_02.png'; -[Sensor.Community](https://sensor.community/en/) 是一个由贡献者驱动的全球传感器网络,用于创建开放的环境数据。这些数据是从全球各地的传感器收集的。任何人都可以购买传感器并将其放置在自己喜欢的地方。用于下载数据的 API 在 [GitHub](https://github.com/opendata-stuttgart/meta/wiki/APIs) 上,数据根据 [数据库内容许可协议 (DbCL)](https://opendatacommons.org/licenses/dbcl/1-0/) 自由提供。 +[Sensor.Community](https://sensor.community/en/) 是一个由贡献者驱动的全球传感器网络,创建开放环境数据。这些数据来自全世界的传感器。任何人都可以购买传感器并将其放置在任何他们喜欢的地方。下载数据的 API 在 [GitHub](https://github.com/opendata-stuttgart/meta/wiki/APIs) 上,数据根据 [Database Contents License (DbCL)](https://opendatacommons.org/licenses/dbcl/1-0/) 自由提供。 :::important -数据集中有超过 200 亿条记录,因此除非您的资源可以处理此类高容量,否则请小心仅复制粘贴下面的命令。下面的命令是在 [ClickHouse Cloud](https://clickhouse.cloud) 的 **生产** 实例上执行的。 +该数据集拥有超过 200 亿条记录,因此在复制粘贴以下命令时请小心,除非您的资源能够处理这种量级。这些命令是在 [ClickHouse Cloud](https://clickhouse.cloud) 的 **Production** 实例上执行的。 ::: -1. 数据在 S3 中,因此我们可以使用 `s3` 表函数从文件中创建一个表。我们还可以就地查询数据。在尝试将其插入 ClickHouse 之前,先查看几行数据: +1. 数据存储在 S3 中,因此我们可以使用 `s3` 表函数从文件创建一个表。我们也可以在原地查询数据。在尝试将其插入到 ClickHouse 之前,让我们先查看几行数据: ```sql SELECT * @@ -27,7 +28,7 @@ LIMIT 10 SETTINGS format_csv_delimiter = ';'; ``` -数据以 CSV 文件的形式存储,但使用分号作为分隔符。行的格式如下: +数据以 CSV 文件形式存在,但使用分号作为分隔符。行的格式如下: ```response ┌─sensor_id─┬─sensor_type─┬─location─┬────lat─┬────lon─┬─timestamp───────────┬──pressure─┬─altitude─┬─pressure_sealevel─┬─temperature─┐ @@ -44,7 +45,7 @@ SETTINGS format_csv_delimiter = ';'; └───────────┴─────────────┴──────────┴────────┴────────┴─────────────────────┴───────────┴──────────┴───────────────────┴─────────────┘ ``` -2. 我们将使用以下 `MergeTree` 表将数据存储在 ClickHouse 中: +2. 我们将使用以下 `MergeTree` 表来在 ClickHouse 中存储数据: ```sql CREATE TABLE sensors @@ -73,9 +74,9 @@ ENGINE = MergeTree ORDER BY (timestamp, sensor_id); ``` -3. ClickHouse Cloud 服务有一个名为 `default` 的集群。我们将使用 `s3Cluster` 表函数,该函数从集群中的节点并行读取 S3 文件。(如果您没有集群,只需使用 `s3` 函数并删除集群名称。) +3. ClickHouse Cloud 服务有一个名为 `default` 的集群。我们将使用 `s3Cluster` 表函数,从您集群中的节点并行读取 S3 文件。(如果您没有集群,只需使用 `s3` 函数并删除集群名称。) -这个查询将花费一些时间 - 数据未压缩约为 1.67T: +这个查询会花费一些时间 - 未压缩的数据约为 1.67T: ```sql INSERT INTO sensors @@ -113,13 +114,13 @@ SETTINGS parallel_distributed_insert_select = 1; ``` -这是响应 - 显示了行数和处理速度。输入速率超过每秒 600 万行! +这是响应 - 显示行数和处理速度。输入速率超过每秒 600 万行! ```response 0 rows in set. Elapsed: 3419.330 sec. Processed 20.69 billion rows, 1.67 TB (6.05 million rows/s., 488.52 MB/s.) ``` -4. 让我们看看 `sensors` 表需要多少存储磁盘: +4. 让我们看看 `sensors` 表需要多少存储空间: ```sql SELECT @@ -136,7 +137,7 @@ GROUP BY ORDER BY size DESC; ``` -1.67T 被压缩到 310 GiB,并且有 206.9 亿行: +1.67T 的数据压缩到 310 GiB,且有 20.69 亿行: ```response ┌─disk_name─┬─compressed─┬─uncompressed─┬─compr_rate─┬────────rows─┬─part_count─┐ @@ -144,7 +145,7 @@ ORDER BY size DESC; └───────────┴────────────┴──────────────┴────────────┴─────────────┴────────────┘ ``` -5. 现在让我们分析数据,看看自传感器部署以来数据的数量是如何随时间增加的: +5. 现在数据已经在 ClickHouse 中,让我们分析一下。请注意,随着更多传感器的部署,数据量随时间增加: ```sql SELECT @@ -155,11 +156,11 @@ GROUP BY date ORDER BY date ASC; ``` -我们可以在 SQL 控制台中创建图表以可视化结果: +我们可以在 SQL 控制台中创建一个图表来可视化结果: -6. 这个查询计算过于炎热和潮湿的天数: +6. 这个查询计算了过热和潮湿天气的天数: ```sql WITH @@ -167,9 +168,9 @@ WITH SELECT day, count() FROM sensors WHERE temperature >= 40 AND temperature <= 50 AND humidity >= 90 GROUP BY day -ORDER BY day asc; +ORDER BY day ASC; ``` -这是结果的可视化: +以下是结果的可视化: - + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/environmental-sensors.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/environmental-sensors.md.hash index 607130c6d1f..144c3bad6b5 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/environmental-sensors.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/environmental-sensors.md.hash @@ -1 +1 @@ -5bccaeafb2cc0c9b +f7473a435bf94d85 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/foursquare-os-places.md b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/foursquare-os-places.md index d7027845cbc..cd689c1df8a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/foursquare-os-places.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/foursquare-os-places.md @@ -1,10 +1,11 @@ --- 'description': '数据集包含超过 1 亿条记录,包含关于地图上地点的信息,例如商店、餐馆、公园、游乐场和纪念碑。' -'sidebar_label': 'Foursquare 地点' +'sidebar_label': 'Foursquare 场所' 'slug': '/getting-started/example-datasets/foursquare-places' -'title': 'Foursquare 地点' +'title': 'Foursquare 场所' 'keywords': - 'visualizing' +'doc_type': 'reference' --- import Image from '@theme/IdealImage'; @@ -15,15 +16,16 @@ import visualization_4 from '@site/static/images/getting-started/example-dataset ## Dataset {#dataset} -此数据集由 Foursquare 提供,您可以在 [下载](https://docs.foursquare.com/data-products/docs/access-fsq-os-places) 的同时,依据 Apache 2.0 许可证免费使用。 +这个由 Foursquare 提供的数据集可以在 [download](https://docs.foursquare.com/data-products/docs/access-fsq-os-places) +上免费下载并在 Apache 2.0 许可证下使用。 -它包含超过 1 亿条商业兴趣点 (POI) 记录,涵盖商店、餐馆、公园、游乐场和纪念碑等。同时,它还包括这些地点的额外元数据,例如类别和社交媒体信息。 +它包含超过 1 亿条商业兴趣点 (POI) 的记录,如商店、餐馆、公园、游乐场和纪念碑。它还包括关于这些地方的额外元数据,例如类别和社交媒体信息。 ## Data exploration {#data-exploration} -为了探索数据,我们将使用 [`clickhouse-local`](https://clickhouse.com/blog/extracting-converting-querying-local-files-with-sql-clickhouse-local),这是一个小型命令行工具,提供完整的 ClickHouse 引擎,您也可以使用 ClickHouse Cloud、`clickhouse-client` 或者 `chDB`。 +为了探索数据,我们将使用 [`clickhouse-local`](https://clickhouse.com/blog/extracting-converting-querying-local-files-with-sql-clickhouse-local),这是一个小型命令行工具,提供完整的 ClickHouse 引擎,尽管你也可以使用 ClickHouse Cloud、`clickhouse-client` 或甚至 `chDB`。 -运行以下查询以从存储数据的 S3 存储桶中选择数据: +运行以下查询以选择存储数据的 s3 存储桶中的数据: ```sql title="Query" SELECT * FROM s3('s3://fsq-os-places-us-east-1/release/dt=2025-04-08/places/parquet/*') LIMIT 1 @@ -60,7 +62,7 @@ geom: �^��a�^@Bσ��� bbox: (-122.39003793803701,37.62120111687914,-122.39003793803701,37.62120111687914) ``` -我们看到有相当多的字段为 `ᴺᵁᴸᴸ`,因此可以在查询中添加一些额外条件,以获取更多可用数据: +我们看到相当多的字段为 `ᴺᵁᴸᴸ`,因此我们可以在查询中添加一些额外的条件,以获取更多可用的数据: ```sql title="Query" SELECT * FROM s3('s3://fsq-os-places-us-east-1/release/dt=2025-04-08/places/parquet/*') @@ -98,7 +100,7 @@ geom: ᴺᵁᴸᴸ bbox: (NULL,NULL,NULL,NULL) ``` -运行以下查询以使用 `DESCRIBE` 查看数据的自动推断模式: +运行以下查询以使用 `DESCRIBE` 查看数据的自动推断架构: ```sql title="Query" DESCRIBE s3('s3://fsq-os-places-us-east-1/release/dt=2025-04-08/places/parquet/*') @@ -141,7 +143,7 @@ DESCRIBE s3('s3://fsq-os-places-us-east-1/release/dt=2025-04-08/places/parquet/* ## Loading the data into ClickHouse {#loading-the-data} -如果您希望将数据持久化到磁盘,可以使用 `clickhouse-server` 或 ClickHouse Cloud。 +如果你希望将数据持久保存在磁盘上,可以使用 `clickhouse-server` 或 ClickHouse Cloud。 要创建表,请运行以下命令: @@ -188,50 +190,50 @@ CREATE TABLE foursquare_mercator ORDER BY mortonEncode(mercator_x, mercator_y) ``` -请注意对多个列使用 [`LowCardinality`](/sql-reference/data-types/lowcardinality) 数据类型,这会将数据类型的内部表示更改为字典编码。使用字典编码数据可以显著提高许多应用程序中 `SELECT` 查询的性能。 +请注意,多个列使用了 [`LowCardinality`](/sql-reference/data-types/lowcardinality) 数据类型,这改变了数据类型的内部表示,并进行了字典编码。对于许多应用程序,使用字典编码的数据可显著提高 `SELECT` 查询的性能。 -此外,还创建了两个 `UInt32` `MATERIALIZED` 列 `mercator_x` 和 `mercator_y`,它们将经纬度坐标映射到 [Web Mercator 投影](https://en.wikipedia.org/wiki/Web_Mercator_projection),以便更轻松地将地图分段为瓦片: +此外,会创建两个 `UInt32` 的 `MATERIALIZED` 列 `mercator_x` 和 `mercator_y`,它们将 纬度/经度 坐标映射到 [Web Mercator 投影](https://en.wikipedia.org/wiki/Web_Mercator_projection),以便于将地图细分为图块: ```sql mercator_x UInt32 MATERIALIZED 0xFFFFFFFF * ((longitude + 180) / 360), mercator_y UInt32 MATERIALIZED 0xFFFFFFFF * ((1 / 2) - ((log(tan(((latitude + 90) / 360) * pi())) / 2) / pi())), ``` -让我们逐一解析上述每个列的作用。 +让我们逐列分解上面的内容。 **mercator_x** -此列将经度值转换为 Mercator 投影中的 X 坐标: +该列将经度值转换为墨卡托投影中的 X 坐标: - `longitude + 180` 将经度范围从 [-180, 180] 移动到 [0, 360] -- 除以 360 将其归一化到 0 和 1 之间的值 -- 乘以 `0xFFFFFFFF`(最大 32 位无符号整数的十六进制表示)将此归一化值按比例缩放到 32 位整数的完整范围 +- 除以 360 将其归一化到 0 到 1 之间的值 +- 乘以 `0xFFFFFFFF`(最大 32 位无符号整数的十六进制表示)将该归一化值缩放到 32 位整数的整个范围 **mercator_y** -此列将纬度值转换为 Mercator 投影中的 Y 坐标: +该列将纬度值转换为墨卡托投影中的 Y 坐标: - `latitude + 90` 将纬度从 [-90, 90] 移动到 [0, 180] - 除以 360 并乘以 pi() 将其转换为三角函数所需的弧度 -- `log(tan(...))` 部分是 Mercator 投影公式的核心 -- 乘以 `0xFFFFFFFF` 将其缩放到完整的 32 位整数范围 +- `log(tan(...))` 部分是墨卡托投影公式的核心 +- 乘以 `0xFFFFFFFF` 为完整的 32 位整数范围缩放 -指定 `MATERIALIZED` 确保在 `INSERT` 数据时 ClickHouse 计算这些列的值,而不需要在 `INSERT` 语句中指定这些列(它们并不是原始数据模式的一部分)。 +指定 `MATERIALIZED` 确保 ClickHouse 在我们 `INSERT` 数据时计算这些列的值,而无需在 `INSERT` 语句中指定这些列(这不是原始数据架构的一部分)。 -该表按 `mortonEncode(mercator_x, mercator_y)` 排序,以生成 `mercator_x` 和 `mercator_y` 的 Z-order 空间填充曲线,以显著提高地理空间查询性能。此 Z-order 曲线排序确保数据根据空间接近度物理组织: +该表按 `mortonEncode(mercator_x, mercator_y)` 排序,这产生了一条 `mercator_x`、`mercator_y` 的 Z-order 填充曲线,以显著提高地理空间查询性能。这种 Z-order 曲线排序确保数据按空间接近性进行物理组织: ```sql ORDER BY mortonEncode(mercator_x, mercator_y) ``` -还为更快的搜索创建了两个 `minmax` 索引: +还创建了两个 `minmax` 索引以加快搜索速度: ```sql INDEX idx_x mercator_x TYPE minmax, INDEX idx_y mercator_y TYPE minmax ``` -如您所见,ClickHouse 拥有您进行实时映射应用所需的一切! +如你所见,ClickHouse 拥有实时地图应用程序所需的一切! 运行以下查询以加载数据: @@ -242,14 +244,16 @@ SELECT * FROM s3('s3://fsq-os-places-us-east-1/release/dt=2025-04-08/places/parq ## Visualizing the data {#data-visualization} -要查看此数据集的各种可能性,请访问 [adsb.exposed](https://adsb.exposed/?dataset=Places&zoom=5&lat=52.3488&lng=4.9219)。adsb.exposed 最初是由共同创始人兼首席技术官 Alexey Milovidov 创建的,用于可视化 ADS-B(自动依赖监视广播)航班数据,数据量是 1000 倍。 在一次公司黑客马拉松中,Alexey 将 Foursquare 数据添加到该工具中。 +要查看此数据集的可能性,请查看 [adsb.exposed](https://adsb.exposed/?dataset=Places&zoom=5&lat=52.3488&lng=4.9219)。 +adsb.exposed 最初是由联合创始人和首席技术官 Alexey Milovidov 构建的,以可视化 ADS-B (自动依赖监视广播) +飞行数据,其数据量大 1000 倍。在公司黑客马拉松期间,Alexey 将 Foursquare 数据添加到该工具中。 -以下是一些我们喜欢的可视化,供您欣赏。 +以下是一些我们最喜欢的可视化供您欣赏。 - + - + - + - + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/foursquare-os-places.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/foursquare-os-places.md.hash index 66707445add..14f3cfe69d0 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/foursquare-os-places.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/foursquare-os-places.md.hash @@ -1 +1 @@ -4a9a535fcab956c8 +b6e3f73a774afb3d diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/github-events.md b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/github-events.md index b791d1be65b..e5128e4efe9 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/github-events.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/github-events.md @@ -1,10 +1,11 @@ --- -'description': '数据集包含从 2011 年到 2020 年 12 月 6 日的所有 GitHub 事件,大小为 31 亿条记录。' +'description': '数据集包含自2011年到2020年12月6日的所有 GitHub 事件,大小为31亿条记录。' 'sidebar_label': 'GitHub 事件' 'slug': '/getting-started/example-datasets/github-events' 'title': 'GitHub 事件数据集' +'doc_type': 'reference' --- -数据集包含2011年到2020年12月6日的所有GitHub事件,大小为31亿条记录。下载大小为75 GB,如果以lz4压缩存储在表中,则需要最多200 GB的磁盘空间。 +数据集包含从2011年到2020年12月6日的所有GitHub事件,大小为31亿条记录。下载大小为75 GB,如果以lz4压缩存储在表中,则需要最多200 GB的磁盘空间。 -完整的数据集描述、见解、下载说明和交互式查询已发布 [here](https://ghe.clickhouse.tech/). +完整的数据集描述、洞见、下载说明和交互查询可在 [这里](https://ghe.clickhouse.tech/) 找到。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/github-events.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/github-events.md.hash index 92c83529b02..f75ea4d6e68 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/github-events.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/github-events.md.hash @@ -1 +1 @@ -25a25bbd2a2ed6f1 +8912ecd843675979 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/github.md b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/github.md index 8e6f73002e2..6fa9c3bd5b4 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/github.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/github.md @@ -3,10 +3,11 @@ 'sidebar_label': 'Github Repo' 'sidebar_position': 1 'slug': '/getting-started/example-datasets/github' -'title': '使用 GitHub 数据编写查询在 ClickHouse 中' +'title': '在 ClickHouse 中使用 GitHub 数据编写查询' 'keywords': - 'Github' 'show_related_blogs': true +'doc_type': 'reference' --- import Image from '@theme/IdealImage'; @@ -15,13 +16,13 @@ import superset_commits_authors from '@site/static/images/getting-started/exampl import superset_authors_matrix from '@site/static/images/getting-started/example-datasets/superset-authors-matrix.png' import superset_authors_matrix_v2 from '@site/static/images/getting-started/example-datasets/superset-authors-matrix_v2.png' -这个数据集包含了 ClickHouse 仓库的所有提交记录和更改。可以利用 ClickHouse 附带的原生 `git-import` 工具生成。 +这个数据集包含了 ClickHouse 仓库的所有提交和更改。它可以使用随 ClickHouse 分发的本机 `git-import` 工具生成。 -生成的数据为以下每个表提供一个 `tsv` 文件: +生成的数据为以下每个表提供了一个 `tsv` 文件: -- `commits` - 包含统计信息的提交记录。 -- `file_changes` - 每个提交中更改的文件及其更改信息和统计数据。 -- `line_changes` - 每个提交中每个更改文件的每一行更改,包含该行的完整信息和该行之前更改的信息。 +- `commits` - 具有统计信息的提交。 +- `file_changes` - 每个提交中更改的文件,包括关于更改和统计信息的信息。 +- `line_changes` - 每个提交中每个更改文件中的每一行更改,包含关于该行的完整信息以及关于该行的上一个更改的信息。 截至 2022 年 11 月 8 日,每个 TSV 的大小和行数大致如下: @@ -31,7 +32,7 @@ import superset_authors_matrix_v2 from '@site/static/images/getting-started/exam ## 生成数据 {#generating-the-data} -这一步是可选的。我们免费分发这些数据 - 参见 [下载和插入数据](#downloading-and-inserting-the-data)。 +这是可选的。我们免费分发数据 - 请参见 [下载和插入数据](#downloading-and-inserting-the-data)。 ```bash git clone git@github.com:ClickHouse/ClickHouse.git @@ -39,15 +40,15 @@ cd ClickHouse clickhouse git-import --skip-paths 'generated\.cpp|^(contrib|docs?|website|libs/(libcityhash|liblz4|libdivide|libvectorclass|libdouble-conversion|libcpuid|libzstd|libfarmhash|libmetrohash|libpoco|libwidechar_width))/' --skip-commits-with-messages '^Merge branch ' ``` -这将在 ClickHouse 仓库上大约需要 3 分钟(截至 2022 年 11 月 8 日,在 MacBook Pro 2021 上)。 +这个过程大约需要 3 分钟(截至 2022 年 11 月 8 日在 MacBook Pro 2021 上)才能完成 ClickHouse 仓库的操作。 -可以通过工具的原生帮助获取完整的可用选项列表。 +可从工具的原生帮助中获取可用选项的完整列表。 ```bash clickhouse git-import -h ``` -此帮助文档还提供了以上每个表的 DDL,例如: +该帮助还提供了上述每个表的 DDL,例如 ```sql CREATE TABLE git.commits @@ -68,26 +69,26 @@ CREATE TABLE git.commits ) ENGINE = MergeTree ORDER BY time; ``` -**这些查询应该可以在任何仓库上使用。欢迎探索并报告您的发现** 一些关于执行时间的指导(截至 2022 年 11 月): +**这些查询应该适用于任何仓库。随意探索并报告您的发现** 关于执行时间的一些指导(截至 2022 年 11 月): - Linux - `~/clickhouse git-import` - 160 分钟 ## 下载和插入数据 {#downloading-and-inserting-the-data} -以下数据可用于重现工作环境。或者,您可以在 play.clickhouse.com 中找到可用的数据集 - 参见 [查询](#queries) 以获取更多详细信息。 +以下数据可用于重现工作环境。或者,该数据集可在 play.clickhouse.com 上获得 - 请参见 [查询](#queries) 以获取详细信息。 -以下仓库的生成文件可以在下方找到: +生成的以下仓库的文件如下: - ClickHouse(2022 年 11 月 8 日) - - https://datasets-documentation.s3.amazonaws.com/github/commits/clickhouse/commits.tsv.xz - 2.5 MB - - https://datasets-documentation.s3.amazonaws.com/github/commits/clickhouse/file_changes.tsv.xz - 4.5MB - - https://datasets-documentation.s3.amazonaws.com/github/commits/clickhouse/line_changes.tsv.xz - 127.4 MB + - https://datasets-documentation.s3.amazonaws.com/github/commits/clickhouse/commits.tsv.xz - 2.5 MB + - https://datasets-documentation.s3.amazonaws.com/github/commits/clickhouse/file_changes.tsv.xz - 4.5MB + - https://datasets-documentation.s3.amazonaws.com/github/commits/clickhouse/line_changes.tsv.xz - 127.4 MB - Linux(2022 年 11 月 8 日) - - https://datasets-documentation.s3.amazonaws.com/github/commits/linux/commits.tsv.xz - 44 MB - - https://datasets-documentation.s3.amazonaws.com/github/commits/linux/file_changes.tsv.xz - 467MB - - https://datasets-documentation.s3.amazonaws.com/github/commits/linux/line_changes.tsv.xz - 1.1G + - https://datasets-documentation.s3.amazonaws.com/github/commits/linux/commits.tsv.xz - 44 MB + - https://datasets-documentation.s3.amazonaws.com/github/commits/linux/file_changes.tsv.xz - 467MB + - https://datasets-documentation.s3.amazonaws.com/github/commits/linux/line_changes.tsv.xz - 1.1G -要插入这些数据,请通过执行以下查询准备数据库: +要插入这些数据,请通过执行以下查询来准备数据库: ```sql DROP DATABASE IF EXISTS git; @@ -182,7 +183,7 @@ CREATE TABLE git.line_changes ) ENGINE = MergeTree ORDER BY time; ``` -使用 `INSERT INTO SELECT` 和 [s3 function](/sql-reference/table-functions/s3) 插入数据。例如,在下面,我们将 ClickHouse 文件插入到各自的表中: +使用 `INSERT INTO SELECT` 和 [s3 function](/sql-reference/table-functions/s3) 插入数据。例如,在下面,我们将 ClickHouse 文件插入到它们各自的表中: *commits* @@ -213,13 +214,13 @@ FROM s3('https://datasets-documentation.s3.amazonaws.com/github/commits/clickhou ## 查询 {#queries} -该工具通过其帮助输出建议了几条查询。除了这些外,我们还回答了一些附加的补充问题。这些查询的复杂性大致按工具的任意顺序递增。 +该工具通过其帮助输出建议了几个查询。我们已经回答了这些查询,并补充了一些其他补充性的问题。这些查询的复杂性大致递增,与工具的任意顺序相对。 -该数据集在 [play.clickhouse.com](https://sql.clickhouse.com?query_id=DCQPNPAIMAQXRLHYURLKVJ) 中可用以 `git_clickhouse` 数据库提供。我们为所有查询提供了此环境的链接,并根据需要调整数据库名称。请注意,由于数据收集时间的差异,play 结果可能与此处所示不同。 +该数据集可在 [play.clickhouse.com](https://sql.clickhouse.com?query_id=DCQPNPAIMAQXRLHYURLKVJ) 的 `git_clickhouse` 数据库中获得。我们为所有查询提供一个指向这个环境的链接,根据需要调整数据库名称。请注意,由于数据收集时间的不同,play 结果可能与此处呈现的结果有所不同。 ### 单个文件的历史 {#history-of-a-single-file} -最简单的查询。在这里,我们查看 `StorageReplicatedMergeTree.cpp` 的所有提交消息。由于这些可能更有趣,我们按最近的消息排序。 +最简单的查询。在这里,我们查看 `StorageReplicatedMergeTree.cpp` 的所有提交消息。由于这些消息可能更有趣,我们优先显示最新的消息。 [play](https://sql.clickhouse.com?query_id=COAZRFX2YFULDBXRQTCQ1S) @@ -255,7 +256,7 @@ LIMIT 10 10 rows in set. Elapsed: 0.006 sec. Processed 12.10 thousand rows, 1.60 MB (1.93 million rows/s., 255.40 MB/s.) ``` -我们还可以查看行变更,排除重命名,即我们不会显示在重命名前以不同名称存在的文件的变更: +我们还可以查看行更改,排除重命名,即我们不会显示重命名事件之前的更改,当文件存在于不同的名称下: [play](https://sql.clickhouse.com?query_id=AKS9SYLARFMZCHGAAQNEBN) @@ -289,13 +290,13 @@ LIMIT 10 10 rows in set. Elapsed: 0.258 sec. Processed 7.54 million rows, 654.92 MB (29.24 million rows/s., 2.54 GB/s.) ``` -请注意,这个查询还存在一个更复杂的变体,我们在考虑重命名时查找 [逐行提交历史](#line-by-line-commit-history-of-a-file)。 +请注意,更复杂的变体存在于该查询中,我们考虑重命名情况查找 [逐行提交历史](#line-by-line-commit-history-of-a-file)。 -### 查找当前活跃文件 {#find-the-current-active-files} +### 查找当前活动文件 {#find-the-current-active-files} -这对于后续分析非常重要,因为我们只想考虑仓库中当前的文件。我们将此集合估算为未被重命名或删除(然后重新添加/重命名)的文件。 +这对后续分析很重要,当我们只想考虑仓库中的当前文件时。我们估算这个集合为未重命名或未删除(然后重新添加/重命名)的文件。 -**请注意,在重命名过程中,似乎 `dbms`,`libs`,`tests/testflows/` 目录下的文件存在损坏的提交历史。因此我们也排除这些。** +**请注意,关于 `dbms`、`libs`、`tests/testflows/` 目录下的文件,在重命名过程中似乎存在已损坏的提交历史。因此我们也将其排除。** [play](https://sql.clickhouse.com?query_id=2HNFWPCFWEEY92WTAPMA7W) @@ -337,7 +338,7 @@ LIMIT 10 10 rows in set. Elapsed: 0.085 sec. Processed 532.10 thousand rows, 8.68 MB (6.30 million rows/s., 102.64 MB/s.) ``` -注意,这允许文件重命名然后重新命名为其原始值。首先,我们对因重命名而删除的文件的 `old_path` 进行聚合。我们将其与每个 `path` 的最后一次操作合并。最后,我们过滤此列表,确保最后操作不是 `Delete`。 +请注意,这允许文件被重命名,然后再重命名为其原始值。首先,我们汇总因重命名而删除的文件的 `old_path` 列表。然后我们将其与每个 `path` 的最后操作进行联合。最后,我们将此列表过滤为最后事件不是 `Delete` 的项。 [play](https://sql.clickhouse.com?query_id=1OXCKMOH2JVMSHD3NS2WW6) @@ -372,22 +373,22 @@ FROM 1 row in set. Elapsed: 0.089 sec. Processed 532.10 thousand rows, 8.68 MB (6.01 million rows/s., 97.99 MB/s.) ``` -请注意,我们在导入时跳过了多个目录,例如: +请注意,我们在导入过程中跳过了几个目录,例如 `--skip-paths 'generated\.cpp|^(contrib|docs?|website|libs/(libcityhash|liblz4|libdivide|libvectorclass|libdouble-conversion|libcpuid|libzstd|libfarmhash|libmetrohash|libpoco|libwidechar_width))/'` -将此模式应用于 `git list-files`,报告为 18155。 +将此模式应用于 `git list-files`,报告了 18155。 ```bash git ls-files | grep -v -E 'generated\.cpp|^(contrib|docs?|website|libs/(libcityhash|liblz4|libdivide|libvectorclass|libdouble-conversion|libcpuid|libzstd|libfarmhash|libmetrohash|libpoco|libwidechar_width))/' | wc -l 18155 ``` -**因此,我们当前的解决方案是对当前文件的估计** +**因此,我们当前的解决方案是对当前文件的估算** -这里的差异是由几个因素造成的: +这里的差异由几个因素造成: -- 重命名可能发生在文件的其他更改的同时。这些在 file_changes 中被列为单独的事件,但时间相同。`argMax` 函数无法区分这些 - 它会选择第一个值。插入的自然顺序(唯一知晓正确顺序的方法)不会在联合中保持,因此修改事件可能会被选择。例如,在 `src/Functions/geometryFromColumn.h` 文件在重命名为 `src/Functions/geometryConverters.h` 之前有几个修改。我们的当前解决方案可能会将一个修改事件选为最新变更,导致 `src/Functions/geometryFromColumn.h` 被保留。 +- 重命名可以与文件的其他修改同时发生。这些在 file_changes 中列出为独立事件,但时间相同。`argMax` 函数无法区分这些事件 - 它会选择第一个值。插入的自然排序(知道正确顺序的唯一手段)在联合中没有维持,因此可以选择修改事件。例如,下面 `src/Functions/geometryFromColumn.h` 文件在重命名为 `src/Functions/geometryConverters.h` 之前有几次修改。我们的当前解决方案可能将 Modify 事件作为最新更改,从而保留 `src/Functions/geometryFromColumn.h`。 [play](https://sql.clickhouse.com?query_id=SCXWMR9GBMJ9UNZYQXQBFA) @@ -416,13 +417,13 @@ WHERE (path = 'src/Functions/geometryFromColumn.h') OR (old_path = 'src/Function └─────────────┴────────────────────────────────────┴────────────────────────────────────┴─────────────────────┴──────────────────────────────────────────┘ 11 rows in set. Elapsed: 0.030 sec. Processed 266.05 thousand rows, 6.61 MB (8.89 million rows/s., 220.82 MB/s.) ``` -- 损坏的提交历史 - 缺失删除事件。源和原因待定。 +- 提交历史损坏 - 缺失删除事件。源和原因尚待确定。 -这些差异不应对我们的分析造成显著影响。**我们欢迎该查询的改进版本**。 +这些差异不应对我们的分析产生有意义的影响。 **我们欢迎此查询的改进版本**。 -### 列出修改次数最多的文件 {#list-files-with-most-modifications} +### 列出修改最多的文件 {#list-files-with-most-modifications} -限制在当前文件中,我们将修改次数视为删除和添加的总和。 +限制为当前文件,我们认为修改的数量为删除和添加的总和。 [play](https://sql.clickhouse.com?query_id=MHXPSBNPTDMJYR3OYSXVR7) @@ -475,7 +476,7 @@ LIMIT 10 10 rows in set. Elapsed: 0.134 sec. Processed 798.15 thousand rows, 16.46 MB (5.95 million rows/s., 122.62 MB/s.) ``` -### 提交通常发生在哪一天? {#what-day-of-the-week-do-commits-usually-occur} +### 提交通常发生在什么星期几? {#what-day-of-the-week-do-commits-usually-occur} [play](https://sql.clickhouse.com?query_id=GED2STFSYJDRAA59H8RLIV) @@ -498,11 +499,11 @@ GROUP BY dayOfWeek(time) AS day_of_week 7 rows in set. Elapsed: 0.262 sec. Processed 62.78 thousand rows, 251.14 KB (239.73 thousand rows/s., 958.93 KB/s.) ``` -这在周五出现一些生产力减退是可以理解的。很高兴看到人们在周末提交代码!非常感谢我们的贡献者! +这合理,因为周五生产力有所下降。很高兴看到人们在周末提交代码!非常感谢我们的贡献者! -### 子目录/文件的历史 - 随着时间的推移行数、提交和贡献者数量 {#history-of-subdirectoryfile---number-of-lines-commits-and-contributors-over-time} +### 子目录/文件的历史 - 随时间变化的行数、提交和贡献者 {#history-of-subdirectoryfile---number-of-lines-commits-and-contributors-over-time} -如果不加过滤,这将产生一个很大的查询结果,无法显示或可视化。因此,我们允许在以下示例中过滤一个文件或子目录。我们在这里使用 `toStartOfWeek` 函数按周分组 - 根据需要进行调整。 +如果不加过滤,这将产生一个非常大的查询结果,不切实际地显示或可视化。因此,我们允许在以下示例中过滤文件或子目录。在这里,我们使用 `toStartOfWeek` 函数按周分组 - 根据需要进行调整。 [play](https://sql.clickhouse.com?query_id=REZRXDVU7CAWT5WKNJSTNY) @@ -536,17 +537,17 @@ LIMIT 10 这些数据可视化效果很好。下面我们使用 Superset。 -**添加和删除的行:** +**对于新增和删除的行数:** - + -**提交和作者:** +**对于提交和作者:** - + -### 作者最多的文件数量 {#list-files-with-maximum-number-of-authors} +### 列出作者最多的文件 {#list-files-with-maximum-number-of-authors} -仅限当前文件。 +仅限于当前文件。 [play](https://sql.clickhouse.com?query_id=CYQFNQNK9TAMPU2OZ8KG5Y) @@ -599,9 +600,9 @@ LIMIT 10 10 rows in set. Elapsed: 0.239 sec. Processed 798.15 thousand rows, 14.13 MB (3.35 million rows/s., 59.22 MB/s.) ``` -### 仓库中最旧的代码行 {#oldest-lines-of-code-in-the-repository} +### 仓库中最古老的代码行 {#oldest-lines-of-code-in-the-repository} -仅限当前文件。 +仅限于当前文件。 [play](https://sql.clickhouse.com?query_id=VWPBPGRZVGTHOCQYWNQZNT) @@ -658,7 +659,7 @@ LIMIT 10 ### 历史最长的文件 {#files-with-longest-history} -仅限当前文件。 +仅限于当前文件。 [play](https://sql.clickhouse.com?query_id=VWPBPGRZVGTHOCQYWNQZNT) @@ -712,13 +713,13 @@ LIMIT 10 10 rows in set. Elapsed: 0.124 sec. Processed 798.15 thousand rows, 14.71 MB (6.44 million rows/s., 118.61 MB/s.) ``` -我们的核心数据结构 Merge Tree 显然在不断演变,具有较长的编辑历史! +我们的核心数据结构 Merge Tree 显然在不断演变,具有悠久的编辑历史! -### 关于文档和代码分布的贡献者分布 {#distribution-of-contributors-with-respect-to-docs-and-code-over-the-month} +### 关于文档和代码的贡献者分布 {#distribution-of-contributors-with-respect-to-docs-and-code-over-the-month} -**在数据捕获期间,`docs/` 文件夹中的更改由于提交历史非常混乱而被过滤掉。因此该查询的结果不准确。** +**在数据采集期间,由于 `docs/` 文件夹的更改历史非常脏,因此对其进行了过滤,因此此查询的结果不准确。** -在某些时间(例如,在发布日期附近)我们是否写更多的文档?我们可以使用 `countIf` 函数计算简单的比例,并使用 `bar` 函数可视化结果。 +我们在每个月的某些时候(例如发布日期附近)是否写更多的文档?我们可以使用 `countIf` 函数计算一个简单的比率,并使用 `bar` 函数可视化结果。 [play](https://sql.clickhouse.com?query_id=BA4RZUXUHNQBH9YK7F2T9J) @@ -775,11 +776,11 @@ FROM 31 rows in set. Elapsed: 0.043 sec. Processed 7.54 million rows, 40.53 MB (176.71 million rows/s., 950.40 MB/s.) ``` -在月末附近可能多一些,但总体来看我们保持了良好的均匀分布。再次强调,由于在数据插入期间过滤了文档,因此这一点不可靠。 +也许在月底的时候会多一点,但总体来说,我们保持良好的均匀分布。再说一次,由于在数据插入期间对文档的过滤,这一点不可靠。 -### 影响最大的作者 {#authors-with-the-most-diverse-impact} +### 影响最广泛的作者 {#authors-with-the-most-diverse-impact} -我们认为多样性是作者贡献的独特文件数量。 +我们在这里考虑多样性,即作者贡献的独特文件数量。 [play](https://sql.clickhouse.com?query_id=MT8WBABUKYBYSBA78W5TML) @@ -809,7 +810,7 @@ LIMIT 10 10 rows in set. Elapsed: 0.041 sec. Processed 266.05 thousand rows, 4.92 MB (6.56 million rows/s., 121.21 MB/s.) ``` -让我们看看谁在最近的工作中有最多样化的提交。我们不按日期限制,而是限制在某个作者的最近 N 次提交(在这种情况下,我们使用 3 次,可以根据需要进行修改): +让我们看看谁在最近的工作中拥有最多样的提交。我们不会限制日期,而是限制作者最近的 N 次提交(在这种情况下,我们使用 3 次,但欢迎您进行修改): [play](https://sql.clickhouse.com?query_id=4Q3D67FWRIVWTY8EIDDE5U) @@ -856,7 +857,7 @@ LIMIT 10 ### 作者的最爱文件 {#favorite-files-for-an-author} -在这里我们选择我们的创始人 [Alexey Milovidov](https://github.com/alexey-milovidov) 并将分析限制在当前文件。 +在这里我们选择我们的创始人 [Alexey Milovidov](https://github.com/alexey-milovidov),并将我们的分析限制为当前文件。 [play](https://sql.clickhouse.com?query_id=OKGZBACRHVGCRAGCZAJKMF) @@ -909,7 +910,7 @@ LIMIT 10 10 rows in set. Elapsed: 0.106 sec. Processed 798.15 thousand rows, 13.97 MB (7.51 million rows/s., 131.41 MB/s.) ``` -这很有道理,因为 Alexey 一直负责维护更改日志。但如果我们用文件的基本名称来识别他的热门文件 - 这样可以考虑重命名,并应重点关注代码贡献。 +这是有道理的,因为 Alexey 一直负责维护变更日志。但如果我们使用文件的基本名称来识别他的热门文件呢 - 这允许重命名,并应重点关注代码贡献。 [play](https://sql.clickhouse.com?query_id=P9PBDZGOSVTKXEXU73ZNAJ) @@ -940,11 +941,11 @@ LIMIT 10 这可能更能反映他的兴趣领域。 -### 最大的文件与最低的作者数量 {#largest-files-with-lowest-number-of-authors} +### 最大文件,拥有最少作者 {#largest-files-with-lowest-number-of-authors} -为此,我们首先需要识别最大的文件。通过从提交历史重建每个文件,估算这一点将非常昂贵! +为此,我们首先需要识别最大的文件。假设通过从提交历史中重建每个文件进行完整文件重建,将会非常昂贵! -为了估算,假设我们限制在当前文件,我们对添加的行进行求和并减去删除的行。然后,我们可以计算长度与作者数量的比率。 +为估算,假设我们限制为当前文件,我们将行添加相加并减去删除。然后,我们可以计算长度与作者数量的比率。 [play](https://sql.clickhouse.com?query_id=PVSDOHZYUMRDDUZFEYJC7J) @@ -999,7 +1000,7 @@ LIMIT 10 10 rows in set. Elapsed: 0.138 sec. Processed 798.15 thousand rows, 16.57 MB (5.79 million rows/s., 120.11 MB/s.) ``` -文本字典可能不太现实,因此让我们通过文件扩展名过滤限制在代码上! +文本字典可能不太现实,因此让我们通过文件扩展名过滤仅限于代码! [play](https://sql.clickhouse.com?query_id=BZHGWUIZMPZZUHS5XRBK2M) @@ -1053,7 +1054,7 @@ LIMIT 10 10 rows in set. Elapsed: 0.140 sec. Processed 798.15 thousand rows, 16.84 MB (5.70 million rows/s., 120.32 MB/s.) ``` -这其中存在一些近期偏见 - 较新文件的提交机会较少。那么如果我们将限制设定为至少 1 年前的文件呢? +这存在一些时效偏差 - 新文件有更少的提交机会。如果我们限制为至少 1 年的文件,会怎么样? [play](https://sql.clickhouse.com?query_id=RMHHZEDHFUCBGRQVQA2732) @@ -1110,9 +1111,9 @@ LIMIT 10 10 rows in set. Elapsed: 0.143 sec. Processed 798.15 thousand rows, 18.00 MB (5.58 million rows/s., 125.87 MB/s.) ``` -### 按时间分布的提交和代码行数; 按工作日、按作者; 针对特定子目录 {#commits-and-lines-of-code-distribution-by-time-by-weekday-by-author-for-specific-subdirectories} +### 提交和代码行随时间的分布;按星期几、按作者;针对特定子目录 {#commits-and-lines-of-code-distribution-by-time-by-weekday-by-author-for-specific-subdirectories} -我们将其解释为按工作日添加和删除的行数。在这种情况下,我们重点关注 [Functions directory](https://github.com/ClickHouse/ClickHouse/tree/master/src/Functions) +我们将其解释为每周中按天添加和删除的行数。在这种情况下,我们关注 [Functions 目录](https://github.com/ClickHouse/ClickHouse/tree/master/src/Functions) [play](https://sql.clickhouse.com?query_id=PF3KEMYG5CVLJGCFYQEGB1) @@ -1139,7 +1140,7 @@ GROUP BY toDayOfWeek(time) AS dayOfWeek 7 rows in set. Elapsed: 0.034 sec. Processed 266.05 thousand rows, 14.66 MB (7.73 million rows/s., 425.56 MB/s.) ``` -以及按时间段, +以及按小时分布, [play](https://sql.clickhouse.com?query_id=Q4VDVKEGHHRBCUJHNCVTF1) @@ -1183,7 +1184,7 @@ GROUP BY toHour(time) AS hourOfDay 24 rows in set. Elapsed: 0.039 sec. Processed 266.05 thousand rows, 14.66 MB (6.77 million rows/s., 372.89 MB/s.) ``` -这个分布是合理的,因为我们的开发团队大多数在阿姆斯特丹。`bar` 函数帮助我们可视化这些分布: +这一分布是合理的,因为我们大多数开发团队在阿姆斯特丹。`bar` 函数帮助我们可视化这些分布: [play](https://sql.clickhouse.com?query_id=9AZ8CENV8N91YGW7T6IB68) @@ -1235,16 +1236,16 @@ FROM 24 rows in set. Elapsed: 0.038 sec. Processed 266.05 thousand rows, 14.66 MB (7.09 million rows/s., 390.69 MB/s.) ``` -### 显示哪些作者倾向于重写其他作者代码的矩阵 {#matrix-of-authors-that-shows-what-authors-tends-to-rewrite-another-authors-code} +### 作者矩阵,显示哪些作者更倾向于重写其他作者的代码 {#matrix-of-authors-that-shows-what-authors-tends-to-rewrite-another-authors-code} -`sign = -1` 表示代码删除。我们排除了标点符号和空行的插入。 +`sign = -1` 表示代码删除。我们排除标点符号和空行的插入。 [play](https://sql.clickhouse.com?query_id=448O8GWAHY3EM6ZZ7AGLAM) ```sql SELECT - prev_author || '(a)' as add_author, - author || '(d)' as delete_author, + prev_author || '(a)' AS add_author, + author || '(d)' AS delete_author, count() AS c FROM git.line_changes WHERE (sign = -1) AND (file_extension IN ('h', 'cpp')) AND (line_type NOT IN ('Punct', 'Empty')) AND (author != prev_author) AND (prev_author != '') @@ -1281,17 +1282,17 @@ LIMIT 100 20 rows in set. Elapsed: 0.098 sec. Processed 7.54 million rows, 42.16 MB (76.67 million rows/s., 428.99 MB/s.) ``` -一个 Sankey 图(SuperSet)可以很好地可视化这一点。请注意,我们将 `LIMIT BY` 增加到 3,以获取每个作者的前 3 个代码删除者,以提高视觉效果的多样性。 +Sankey 图(SuperSet)可以很好地可视化这一点。请注意,我们将 `LIMIT BY` 增加到 3,以获取每个作者的前三个代码删除者,以改善可视化的多样性。 - + -Alexey 显然喜欢删除其他人的代码。我们将他排除,以便更平衡地查看代码删除。 +Alexey 显然喜欢删除其他人的代码。让我们排除他,以便更平衡地查看代码删除情况。 - + -### 谁是每周的最高贡献者百分比? {#who-is-the-highest-percentage-contributor-per-day-of-week} +### 每周贡献最高百分比的作者是谁? {#who-is-the-highest-percentage-contributor-per-day-of-week} -如果我们仅考虑提交数量: +如果仅考虑提交的数量: [play](https://sql.clickhouse.com?query_id=WXPKFJCAHOKYKEVTWNFVCY) @@ -1322,7 +1323,7 @@ LIMIT 1 BY day_of_week 7 rows in set. Elapsed: 0.012 sec. Processed 62.78 thousand rows, 395.47 KB (5.44 million rows/s., 34.27 MB/s.) ``` -好吧,可能有一些优势在于最长的贡献者 - 我们的创始人 Alexey。让我们将分析限制在过去一年。 +好的,这里可能有一些优势给了最长的贡献者 - 我们的创始人 Alexey。让我们限制分析到过去一年。 [play](https://sql.clickhouse.com?query_id=8YRJGHFTNJAWJ96XCJKKEH) @@ -1354,9 +1355,9 @@ LIMIT 1 BY day_of_week 7 rows in set. Elapsed: 0.004 sec. Processed 21.82 thousand rows, 140.02 KB (4.88 million rows/s., 31.29 MB/s.) ``` -这仍然有点简单,并未反映人们的工作。 +这仍然有点简单,并不能反映人们的工作。 -一个更好的指标可能是每一天作为总工作量的一部分,谁是最高贡献者。注意,我们平等对待代码的删除和添加。 +更好的指标可能是每一天的顶级贡献者占过去一年工作的总量的比例。请注意,我们将删除和添加代码视为相等。 [play](https://sql.clickhouse.com?query_id=VQF4KMRDSUEXGS1JFVDJHV) @@ -1404,9 +1405,9 @@ INNER JOIN 7 rows in set. Elapsed: 0.014 sec. Processed 106.12 thousand rows, 1.38 MB (7.61 million rows/s., 98.65 MB/s.) ``` -### 仓库中的代码年龄分布 {#distribution-of-code-age-across-repository} +### 仓库中代码年龄的分布 {#distribution-of-code-age-across-repository} -我们将分析限制在当前文件。为了简单起见,我们将结果限制为深度为 2,每个根文件夹 5 个文件。根据需要进行调整。 +我们将分析限制为当前文件。为了简洁起见,我们将结果限制为深度为 2,每个根文件夹 5 个文件。根据需要进行调整。 [play](https://sql.clickhouse.com?query_id=6YWAUQYPZINZDJGBEZBNWG) @@ -1487,9 +1488,9 @@ LIMIT 5 BY root 24 rows in set. Elapsed: 0.129 sec. Processed 798.15 thousand rows, 15.11 MB (6.19 million rows/s., 117.08 MB/s.) ``` -### 哪些作者的代码被其他作者删除的比例? {#what-percentage-of-code-for-an-author-has-been-removed-by-other-authors} +### 某个作者的代码有多少百分比被其他作者删除? {#what-percentage-of-code-for-an-author-has-been-removed-by-other-authors} -对于这个问题,我们需要将作者编写的行数除以他们被另外贡献者删除的行数总和。 +对于这个问题,我们需要找出一个作者写的行数除以他们被其他贡献者删除的行数总和。 [play](https://sql.clickhouse.com?query_id=T4DTWTB36WFSEYAZLMGRNF) @@ -1537,9 +1538,9 @@ LIMIT 10 10 rows in set. Elapsed: 0.126 sec. Processed 15.07 million rows, 73.51 MB (119.97 million rows/s., 585.16 MB/s.) ``` -### 列出被重写次数最多的文件 {#list-files-that-were-rewritten-most-number-of-times} +### 重写次数最多的文件 {#list-files-that-were-rewritten-most-number-of-times} -解决这个问题的最简单方法可能是简单地计算每个路径的行修改次数(限制在当前文件): +这个问题最简单的方法可能是简单地计算每条路径(仅限于当前文件)的行修改次数,例如: ```sql WITH current_files AS @@ -1590,9 +1591,9 @@ LIMIT 10 10 rows in set. Elapsed: 0.160 sec. Processed 8.07 million rows, 98.99 MB (50.49 million rows/s., 619.49 MB/s.) ``` -然而这并没有捕捉到“重写”的概念,即在任何提交中大部分文件的更改。这需要更复杂的查询。如果我们将重写定义为删除超过 50% 的文件和添加 50%。您可以根据自己的解读来调整查询。 +然而,这并没有捕捉到“重写”的概念,即在任何提交中,大部分文件都会变更。这需要一个更复杂的查询。如果我们将重写定义为超过 50% 的文件被删除,并且 50% 被添加,您可以根据自己的理解调整查询。 -查询仅限于当前文件。我们通过按 `path` 和 `commit_hash` 聚合列出所有文件更改,返回添加和删除的行数。使用窗口函数,我们通过执行累积和来估计文件的总大小,并估算任何变更对文件大小的影响为 `lines added - lines removed`。通过这项统计数据,我们可以计算每个更改中已添加或删除的文件百分比。最后,我们计算出构成重写的文件更改次数,即 `(percent_add >= 0.5) AND (percent_delete >= 0.5) AND current_size > 50`。注意,我们要求文件超过 50 行以避免较早对文件的贡献被计为重写。这也避免了对非常小文件的偏见,因它们在被重写时可能更容易。 +该查询仅限于当前文件。通过按 `path` 和 `commit_hash` 分组列出所有文件更改,返回增加和删除的行数。使用窗口函数,我们可以通过执行累积求和来估算文件在某一时刻的总大小,并将任何更改对文件大小的影响估算为 `lines added - lines removed`。使用此统计信息,我们可以计算每次更改中文件添加或删除的百分比。最后,我们计算构成重写的每个文件的文件更改数量,即 `(percent_add >= 0.5) AND (percent_delete >= 0.5) AND current_size > 50`。请注意,我们要求文件的行数超过 50 行,以避免早期对文件的贡献被算作重写。这也避免了对非常小文件的偏见,这些文件可能更容易被重写。 [play](https://sql.clickhouse.com?query_id=5PL1QLNSH6QQTR8H9HINNP) @@ -1678,9 +1679,468 @@ LIMIT 10 10 rows in set. Elapsed: 0.299 sec. Processed 798.15 thousand rows, 31.52 MB (2.67 million rows/s., 105.29 MB/s.) ``` -### 哪一天的代码被重写的机会最大? {#what-weekday-does-the-code-have-the-highest-chance-to-be-re-written} +### 哪一天代码最有可能留在仓库中? {#what-weekday-does-the-code-have-the-highest-chance-to-stay-in-the-repository} -类似于 [重写次数最多的文件](#list-files-that-were-rewritten-most-number-of-times) 和 [重写次数最多的文件或被最多作者重写](#list-files-that-were-rewritten-most-number-of-times),但我们按工作日起聚合。根据需要调整,例如每年的月份。 +为此,我们需要唯一地识别代码行。我们通过路径和行内容来估算(因为同一行可能多次出现在文件中)。 + +我们查询添加的行,并与删除的行连接 - 过滤到后者发生在前者之后的情况。这给我们提供了已删除的行,从中我们可以计算这些事件之间的时间。 + +最后,我们在这个数据集上汇总,以计算每周中代码在仓库中停留的平均天数。 + +[play](https://sql.clickhouse.com?query_id=GVF23LEZTNZI22BT8LZBBE) + +```sql +SELECT + day_of_week_added, + count() AS num, + avg(days_present) AS avg_days_present +FROM +( + SELECT + added_code.line, + added_code.time AS added_day, + dateDiff('day', added_code.time, removed_code.time) AS days_present + FROM + ( + SELECT + path, + line, + max(time) AS time + FROM git.line_changes + WHERE (sign = 1) AND (line_type NOT IN ('Punct', 'Empty')) + GROUP BY + path, + line + ) AS added_code + INNER JOIN + ( + SELECT + path, + line, + max(time) AS time + FROM git.line_changes + WHERE (sign = -1) AND (line_type NOT IN ('Punct', 'Empty')) + GROUP BY + path, + line + ) AS removed_code USING (path, line) + WHERE removed_code.time > added_code.time +) +GROUP BY dayOfWeek(added_day) AS day_of_week_added + +┌─day_of_week_added─┬────num─┬───avg_days_present─┐ +│ 1 │ 171879 │ 193.81759260875384 │ +│ 2 │ 141448 │ 153.0931013517335 │ +│ 3 │ 161230 │ 137.61553681076722 │ +│ 4 │ 255728 │ 121.14149799787273 │ +│ 5 │ 203907 │ 141.60181847606998 │ +│ 6 │ 62305 │ 202.43449161383518 │ +│ 7 │ 70904 │ 220.0266134491707 │ +└───────────────────┴────────┴────────────────────┘ + +7 rows in set. Elapsed: 3.965 sec. Processed 15.07 million rows, 1.92 GB (3.80 million rows/s., 483.50 MB/s.) +``` + +### 按平均代码年龄排序的文件 {#files-sorted-by-average-code-age} + +此查询使用与 [哪一天代码最有可能留在仓库中](#what-weekday-does-the-code-have-the-highest-chance-to-stay-in-the-repository) 相同的原则 - 通过路径和行内容唯一地识别代码行。 +这使我们能够识别代码添加和删除之间的时间。我们过滤当前文件和代码,只需对行的时间进行平均即可。 + +[play](https://sql.clickhouse.com?query_id=3CYYT7HEHWRFHVCM9JCKSU) + +```sql +WITH + current_files AS + ( + SELECT path + FROM + ( + SELECT + old_path AS path, + max(time) AS last_time, + 2 AS change_type + FROM git.file_changes + GROUP BY old_path + UNION ALL + SELECT + path, + max(time) AS last_time, + argMax(change_type, time) AS change_type + FROM git.clickhouse_file_changes + GROUP BY path + ) + GROUP BY path + HAVING (argMax(change_type, last_time) != 2) AND (NOT match(path, '(^dbms/)|(^libs/)|(^tests/testflows/)|(^programs/server/store/)')) + ORDER BY path ASC + ), + lines_removed AS + ( + SELECT + added_code.path AS path, + added_code.line, + added_code.time AS added_day, + dateDiff('day', added_code.time, removed_code.time) AS days_present + FROM + ( + SELECT + path, + line, + max(time) AS time, + any(file_extension) AS file_extension + FROM git.line_changes + WHERE (sign = 1) AND (line_type NOT IN ('Punct', 'Empty')) + GROUP BY + path, + line + ) AS added_code + INNER JOIN + ( + SELECT + path, + line, + max(time) AS time + FROM git.line_changes + WHERE (sign = -1) AND (line_type NOT IN ('Punct', 'Empty')) + GROUP BY + path, + line + ) AS removed_code USING (path, line) + WHERE (removed_code.time > added_code.time) AND (path IN (current_files)) AND (file_extension IN ('h', 'cpp', 'sql')) + ) +SELECT + path, + avg(days_present) AS avg_code_age +FROM lines_removed +GROUP BY path +ORDER BY avg_code_age DESC +LIMIT 10 + +┌─path────────────────────────────────────────────────────────────┬──────avg_code_age─┐ +│ utils/corrector_utf8/corrector_utf8.cpp │ 1353.888888888889 │ +│ tests/queries/0_stateless/01288_shard_max_network_bandwidth.sql │ 881 │ +│ src/Functions/replaceRegexpOne.cpp │ 861 │ +│ src/Functions/replaceRegexpAll.cpp │ 861 │ +│ src/Functions/replaceOne.cpp │ 861 │ +│ utils/zookeeper-remove-by-list/main.cpp │ 838.25 │ +│ tests/queries/0_stateless/01356_state_resample.sql │ 819 │ +│ tests/queries/0_stateless/01293_create_role.sql │ 819 │ +│ src/Functions/ReplaceStringImpl.h │ 810 │ +│ src/Interpreters/createBlockSelector.cpp │ 795 │ +└─────────────────────────────────────────────────────────────────┴───────────────────┘ + +10 rows in set. Elapsed: 3.134 sec. Processed 16.13 million rows, 1.83 GB (5.15 million rows/s., 582.99 MB/s.) +``` + +### 谁倾向于写更多的测试 / CPP 代码 / 注释? {#who-tends-to-write-more-tests--cpp-code--comments} + +我们可以通过几种方式来解决这个问题。关注代码与测试的比率,这个查询相对简单 - 计算对包含 `tests` 的文件夹的贡献数量,并计算与总贡献的比率。 + +请注意,我们限制对超过 20 次更改的用户进行关注,以专注于常规提交者,避免对一次性贡献的偏见。 + +[play](https://sql.clickhouse.com?query_id=JGKZSEQDPDTDKZXD3ZCGLE) + +```sql +SELECT + author, + countIf((file_extension IN ('h', 'cpp', 'sql', 'sh', 'py', 'expect')) AND (path LIKE '%tests%')) AS test, + countIf((file_extension IN ('h', 'cpp', 'sql')) AND (NOT (path LIKE '%tests%'))) AS code, + code / (code + test) AS ratio_code +FROM git.clickhouse_file_changes +GROUP BY author +HAVING code > 20 +ORDER BY code DESC +LIMIT 20 + +┌─author───────────────┬─test─┬──code─┬─────────ratio_code─┐ +│ Alexey Milovidov │ 6617 │ 41799 │ 0.8633303040317251 │ +│ Nikolai Kochetov │ 916 │ 13361 │ 0.9358408629263851 │ +│ alesapin │ 2408 │ 8796 │ 0.785076758300607 │ +│ kssenii │ 869 │ 6769 │ 0.8862267609321812 │ +│ Maksim Kita │ 799 │ 5862 │ 0.8800480408347096 │ +│ Alexander Tokmakov │ 1472 │ 5727 │ 0.7955271565495208 │ +│ Vitaly Baranov │ 1764 │ 5521 │ 0.7578586135895676 │ +│ Ivan Lezhankin │ 843 │ 4698 │ 0.8478613968597726 │ +│ Anton Popov │ 599 │ 4346 │ 0.8788675429726996 │ +│ Ivan │ 2630 │ 4269 │ 0.6187853312074214 │ +│ Azat Khuzhin │ 1664 │ 3697 │ 0.689610147360567 │ +│ Amos Bird │ 400 │ 2901 │ 0.8788245986064829 │ +│ proller │ 1207 │ 2377 │ 0.6632254464285714 │ +│ chertus │ 453 │ 2359 │ 0.8389046941678521 │ +│ alexey-milovidov │ 303 │ 2321 │ 0.8845274390243902 │ +│ Alexey Arno │ 169 │ 2310 │ 0.9318273497377975 │ +│ Vitaliy Lyudvichenko │ 334 │ 2283 │ 0.8723729461215132 │ +│ Robert Schulze │ 182 │ 2196 │ 0.9234650967199327 │ +│ CurtizJ │ 460 │ 2158 │ 0.8242933537051184 │ +│ Alexander Kuzmenkov │ 298 │ 2092 │ 0.8753138075313808 │ +└──────────────────────┴──────┴───────┴────────────────────┘ + +20 rows in set. Elapsed: 0.034 sec. Processed 266.05 thousand rows, 4.65 MB (7.93 million rows/s., 138.76 MB/s.) +``` + +我们可以将此分布绘制为直方图。 + +[play](https://sql.clickhouse.com?query_id=S5AJIIRGSUAY1JXEVHQDAK) + +```sql +WITH ( + SELECT histogram(10)(ratio_code) AS hist + FROM + ( + SELECT + author, + countIf((file_extension IN ('h', 'cpp', 'sql', 'sh', 'py', 'expect')) AND (path LIKE '%tests%')) AS test, + countIf((file_extension IN ('h', 'cpp', 'sql')) AND (NOT (path LIKE '%tests%'))) AS code, + code / (code + test) AS ratio_code + FROM git.clickhouse_file_changes + GROUP BY author + HAVING code > 20 + ORDER BY code DESC + LIMIT 20 + ) + ) AS hist +SELECT + arrayJoin(hist).1 AS lower, + arrayJoin(hist).2 AS upper, + bar(arrayJoin(hist).3, 0, 100, 500) AS bar + +┌──────────────lower─┬──────────────upper─┬─bar───────────────────────────┐ +│ 0.6187853312074214 │ 0.6410053888179964 │ █████ │ +│ 0.6410053888179964 │ 0.6764177968945693 │ █████ │ +│ 0.6764177968945693 │ 0.7237343804750673 │ █████ │ +│ 0.7237343804750673 │ 0.7740802855073157 │ █████▋ │ +│ 0.7740802855073157 │ 0.807297655565091 │ ████████▋ │ +│ 0.807297655565091 │ 0.8338381996094653 │ ██████▎ │ +│ 0.8338381996094653 │ 0.8533566747727687 │ ████████▋ │ +│ 0.8533566747727687 │ 0.871392376017531 │ █████████▍ │ +│ 0.871392376017531 │ 0.904916108899021 │ ████████████████████████████▋ │ +│ 0.904916108899021 │ 0.9358408629263851 │ █████████████████▌ │ +└────────────────────┴────────────────────┴───────────────────────────────┘ +10 rows in set. Elapsed: 0.051 sec. Processed 266.05 thousand rows, 4.65 MB (5.24 million rows/s., 91.64 MB/s.) +``` + +大多数贡献者写的代码比测试多,这是可以预见的。 + +那么,谁在贡献代码时添加的注释最多? + +[play](https://sql.clickhouse.com?query_id=EXPHDIURBTOXXOK1TGNNYD) + +```sql +SELECT + author, + avg(ratio_comments) AS avg_ratio_comments, + sum(code) AS code +FROM +( + SELECT + author, + commit_hash, + countIf(line_type = 'Comment') AS comments, + countIf(line_type = 'Code') AS code, + if(comments > 0, comments / (comments + code), 0) AS ratio_comments + FROM git.clickhouse_line_changes + GROUP BY + author, + commit_hash +) +GROUP BY author +ORDER BY code DESC +LIMIT 10 +┌─author─────────────┬──avg_ratio_comments─┬────code─┐ +│ Alexey Milovidov │ 0.1034915408309902 │ 1147196 │ +│ s-kat │ 0.1361718900215362 │ 614224 │ +│ Nikolai Kochetov │ 0.08722993407690126 │ 218328 │ +│ alesapin │ 0.1040477684726504 │ 198082 │ +│ Vitaly Baranov │ 0.06446875712939285 │ 161801 │ +│ Maksim Kita │ 0.06863376297549255 │ 156381 │ +│ Alexey Arno │ 0.11252677608033655 │ 146642 │ +│ Vitaliy Zakaznikov │ 0.06199215397180561 │ 138530 │ +│ kssenii │ 0.07455322590796751 │ 131143 │ +│ Artur │ 0.12383737231074826 │ 121484 │ +└────────────────────┴─────────────────────┴─────────┘ +10 rows in set. Elapsed: 0.290 sec. Processed 7.54 million rows, 394.57 MB (26.00 million rows/s., 1.36 GB/s.) +``` + +请注意,我们按代码贡献进行排序。所有大型贡献者的注释比例出乎意料地高,这也是我们代码容易读取的部分原因。 + +### 随着时间的推移,作者的提交如何变化,代码/注释比例? {#how-does-an-authors-commits-change-over-time-with-respect-to-codecomments-percentage} + +按作者进行计算显而易见, + +```sql +SELECT + author, + countIf(line_type = 'Code') AS code_lines, + countIf((line_type = 'Comment') OR (line_type = 'Punct')) AS comments, + code_lines / (comments + code_lines) AS ratio_code, + toStartOfWeek(time) AS week +FROM git.line_changes +GROUP BY + time, + author +ORDER BY + author ASC, + time ASC +LIMIT 10 + +┌─author──────────────────────┬─code_lines─┬─comments─┬─────────ratio_code─┬───────week─┐ +│ 1lann │ 8 │ 0 │ 1 │ 2022-03-06 │ +│ 20018712 │ 2 │ 0 │ 1 │ 2020-09-13 │ +│ 243f6a8885a308d313198a2e037 │ 0 │ 2 │ 0 │ 2020-12-06 │ +│ 243f6a8885a308d313198a2e037 │ 0 │ 112 │ 0 │ 2020-12-06 │ +│ 243f6a8885a308d313198a2e037 │ 0 │ 14 │ 0 │ 2020-12-06 │ +│ 3ldar-nasyrov │ 2 │ 0 │ 1 │ 2021-03-14 │ +│ 821008736@qq.com │ 27 │ 2 │ 0.9310344827586207 │ 2019-04-21 │ +│ ANDREI STAROVEROV │ 182 │ 60 │ 0.7520661157024794 │ 2021-05-09 │ +│ ANDREI STAROVEROV │ 7 │ 0 │ 1 │ 2021-05-09 │ +│ ANDREI STAROVEROV │ 32 │ 12 │ 0.7272727272727273 │ 2021-05-09 │ +└─────────────────────────────┴────────────┴──────────┴────────────────────┴────────────┘ + +10 rows in set. Elapsed: 0.145 sec. Processed 7.54 million rows, 51.09 MB (51.83 million rows/s., 351.44 MB/s.) +``` + +然而,理想情况下,我们希望观察这种变化在所有作者中从他们开始提交的第一天起的聚合变化。他们是否会逐渐减少编写的注释数量? + +为此,我们首先计算每个作者随时间的注释比率 - 类似于 [谁倾向于写更多的测试 / CPP 代码 / 注释?](#who-tends-to-write-more-tests--cpp-code--comments)。这与每个作者的开始日期结合在一起,使我们能够计算按周偏移的注释比率。 + +在计算出所有作者的平均按周偏移后的结果后,我们按每 10 周取样这些结果。 + +[play](https://sql.clickhouse.com?query_id=SBHEWR8XC4PRHY13HPPKCN) + +```sql +WITH author_ratios_by_offset AS + ( + SELECT + author, + dateDiff('week', start_dates.start_date, contributions.week) AS week_offset, + ratio_code + FROM + ( + SELECT + author, + toStartOfWeek(min(time)) AS start_date + FROM git.line_changes + WHERE file_extension IN ('h', 'cpp', 'sql') + GROUP BY author AS start_dates + ) AS start_dates + INNER JOIN + ( + SELECT + author, + countIf(line_type = 'Code') AS code, + countIf((line_type = 'Comment') OR (line_type = 'Punct')) AS comments, + comments / (comments + code) AS ratio_code, + toStartOfWeek(time) AS week + FROM git.line_changes + WHERE (file_extension IN ('h', 'cpp', 'sql')) AND (sign = 1) + GROUP BY + time, + author + HAVING code > 20 + ORDER BY + author ASC, + time ASC + ) AS contributions USING (author) + ) +SELECT + week_offset, + avg(ratio_code) AS avg_code_ratio +FROM author_ratios_by_offset +GROUP BY week_offset +HAVING (week_offset % 10) = 0 +ORDER BY week_offset ASC +LIMIT 20 + +┌─week_offset─┬──────avg_code_ratio─┐ +│ 0 │ 0.21626798253005078 │ +│ 10 │ 0.18299433892099454 │ +│ 20 │ 0.22847255749045017 │ +│ 30 │ 0.2037816688365288 │ +│ 40 │ 0.1987063517030308 │ +│ 50 │ 0.17341406302829748 │ +│ 60 │ 0.1808884776496144 │ +│ 70 │ 0.18711773536450496 │ +│ 80 │ 0.18905573684766458 │ +│ 90 │ 0.2505147771581594 │ +│ 100 │ 0.2427673990917429 │ +│ 110 │ 0.19088569009169926 │ +│ 120 │ 0.14218574654598348 │ +│ 130 │ 0.20894252550489317 │ +│ 140 │ 0.22316626978848397 │ +│ 150 │ 0.1859507592277053 │ +│ 160 │ 0.22007759757363546 │ +│ 170 │ 0.20406936638195144 │ +│ 180 │ 0.1412102467834332 │ +│ 190 │ 0.20677550885049117 │ +└─────────────┴─────────────────────┘ + +20 rows in set. Elapsed: 0.167 sec. Processed 15.07 million rows, 101.74 MB (90.51 million rows/s., 610.98 MB/s.) +``` + +令人鼓舞的是,我们的注释百分比相对稳定,并不会随着作者贡献时间的延长而下降。 + +### 代码被重写的平均时间是什么,代码衰变的中位数(半衰期)? {#what-is-the-average-time-before-code-will-be-rewritten-and-the-median-half-life-of-code-decay} + +我们可以使用与 [重写次数最多的文件](#list-files-that-were-rewritten-most-number-of-times) 或 [被最多作者重写的文件](#list-files-that-were-rewritten-most-number-of-times) 相同的原则来识别重写,但考虑所有文件。使用窗口函数来计算每个文件之间重写的时间。从中,我们可以计算出所有文件的平均值和中位数。 + +[play](https://sql.clickhouse.com?query_id=WSHUEPJP9TNJUH7QITWWOR) + +```sql +WITH + changes AS + ( + SELECT + path, + commit_hash, + max_time, + type, + num_added, + num_deleted, + sum(num_added - num_deleted) OVER (PARTITION BY path ORDER BY max_time ASC) AS current_size, + if(current_size > 0, num_added / current_size, 0) AS percent_add, + if(current_size > 0, num_deleted / current_size, 0) AS percent_delete + FROM + ( + SELECT + path, + max(time) AS max_time, + commit_hash, + any(lines_added) AS num_added, + any(lines_deleted) AS num_deleted, + any(change_type) AS type + FROM git.file_changes + WHERE (change_type IN ('Add', 'Modify')) AND (file_extension IN ('h', 'cpp', 'sql')) + GROUP BY + path, + commit_hash + ORDER BY + path ASC, + max_time ASC + ) + ), + rewrites AS + ( + SELECT + *, + any(max_time) OVER (PARTITION BY path ORDER BY max_time ASC ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) AS previous_rewrite, + dateDiff('day', previous_rewrite, max_time) AS rewrite_days + FROM changes + WHERE (type = 'Modify') AND (percent_add >= 0.5) AND (percent_delete >= 0.5) AND (current_size > 50) + ) +SELECT + avgIf(rewrite_days, rewrite_days > 0) AS avg_rewrite_time, + quantilesTimingIf(0.5)(rewrite_days, rewrite_days > 0) AS half_life +FROM rewrites + +┌─avg_rewrite_time─┬─half_life─┐ +│ 122.2890625 │ [23] │ +└──────────────────┴───────────┘ + +1 row in set. Elapsed: 0.388 sec. Processed 266.05 thousand rows, 22.85 MB (685.82 thousand rows/s., 58.89 MB/s.) +``` + +### 编写代码的最糟糕时间是什么,因为代码被重写的可能性最大? {#what-is-the-worst-time-to-write-code-in-sense-that-the-code-has-highest-chance-to-be-re-written} + +类似于 [代码重写的平均时间是什么,代码衰变的中位数(半衰期)](#what-is-the-average-time-before-code-will-be-rewritten-and-the-median-half-life-of-code-decay) 和 [重写次数最多的文件](#list-files-that-were-rewritten-most-number-of-times),但我们按每周的天数汇总。根据需要进行调整,例如按月份。 [play](https://sql.clickhouse.com?query_id=8PQNWEWHAJTGN6FTX59KH2) @@ -1742,9 +2202,9 @@ GROUP BY dayOfWeek 7 rows in set. Elapsed: 0.466 sec. Processed 7.54 million rows, 701.52 MB (16.15 million rows/s., 1.50 GB/s.) ``` -### 哪些作者的代码是最“粘”的? {#which-authors-code-is-the-most-sticky} +### 哪些作者的代码最“粘y”? {#which-authors-code-is-the-most-sticky} -我们定义“粘”是作者的代码在被重写之前保持的时间。与之前的问题 [重写时间的平均值以及代码衰减的半衰期](#what-is-the-average-time-before-code-will-be-rewritten-and-the-median-half-life-of-code-decay) 相似 - 使用相同的重写指标,即对文件的添加和删除都是 50%。我们计算每位作者的平均重写时间,仅考虑贡献超过两个文件的贡献者。 +我们将“粘性”定义为一个作者的代码在被重写之前保持的时间。类似于之前的问题 [代码重写的平均时间是什么,代码衰变的中位数(半衰期)](#what-is-the-average-time-before-code-will-be-rewritten-and-the-median-half-life-of-code-decay) - 使用相同的重写指标,即文件的 50% 添加和 50% 删除。我们计算作者的平均重写时间,并仅考虑贡献者超过两个文件的情况。 [play](https://sql.clickhouse.com?query_id=BKHLVVWN5SET1VTIFQ8JVK) @@ -1821,9 +2281,9 @@ LIMIT 10 ### 作者连续提交的最大天数 {#most-consecutive-days-of-commits-by-an-author} -该查询首先需要我们计算出作者提交的天数。通过窗口函数,按作者进行分区,我们可以计算出他们提交之间的天数。对于每个提交,如果距离上一个提交的时间为 1 天,我们将其标记为连续(1),否则标记为 0 - 将这个结果存储在 `consecutive_day` 中。 +该查询首先需要我们计算作者提交的日期。使用窗口函数,通过作者进行分区,我们可以计算他们提交之间的天数。对于每次提交,如果与上次提交的时间间隔为 1 天,我们将其标记为连续 (1),否则为 0 - 将此结果存储在 `consecutive_day` 中。 -我们后续的数组函数计算每个作者最长的连续 1 的序列。首先,使用 `groupArray` 函数收集所有作者的 `consecutive_day` 值。然后将这个 1 和 0 的数组在 0 值处分割成子数组。最后,我们计算最长的子数组。 +我们后续的数组函数计算每个作者连续 1 的最长序列。首先,使用 `groupArray` 函数收集一个作者的所有 `consecutive_day` 值。这个1和0的数组然后根据0的值拆分成子数组。最后,我们计算最长子数组。 [play](https://sql.clickhouse.com?query_id=S3E64UYCAMDAYJRSXINVFR) @@ -1876,7 +2336,7 @@ LIMIT 10 ### 文件的逐行提交历史 {#line-by-line-commit-history-of-a-file} -文件可以被重命名。当发生这种情况时,出现一个重命名事件,其中 `path` 列被设置为文件的新路径,`old_path` 列表示之前的位置,例如: +文件可能被重命名。当发生这种情况时,我们会获得重命名事件,其中 `path` 列设置为文件的新路径,而 `old_path` 代表之前的位置,例如 [play](https://sql.clickhouse.com?query_id=AKTW3Z8JZAPQ4H9BH2ZFRX) @@ -1897,11 +2357,11 @@ WHERE (path = 'src/Storages/StorageReplicatedMergeTree.cpp') AND (change_type = 1 row in set. Elapsed: 0.135 sec. Processed 266.05 thousand rows, 20.73 MB (1.98 million rows/s., 154.04 MB/s.) ``` -这使得查看文件的完整历史变得具有挑战性,因为我们没有一个唯一的值来连接所有行或文件更改。 +这使得查看文件的完整历史变得具有挑战性,因为我们没有可以连接所有行或文件更改的单一值。 -为了解决这个问题,我们可以使用用户定义函数(UDFs)。当前无法递归,因此为了识别文件的历史,我们必须定义一系列相互调用的 UDF。 +为了解决这个问题,我们可以使用用户定义函数(UDF)。目前,这些函数不能是递归的,因此要识别文件的历史,我们必须定义一系列明确定义的 UDF,这些函数相互调用。 -这意味着我们最多只能追踪 5 层重命名历史。文件被重命名超过这个次数的可能性不大,因此目前这已足够。 +这意味着我们只能追踪到最多 5 层的重命名;下面的示例深度为 5。文件不太可能重命名超过此,因此现在这里只有这个是足够的。 ```sql CREATE FUNCTION file_path_history AS (n) -> if(empty(n), [], arrayConcat([n], file_path_history_01((SELECT if(empty(old_path), Null, old_path) FROM git.file_changes WHERE path = n AND (change_type = 'Rename' OR change_type = 'Add') LIMIT 1)))); @@ -1912,7 +2372,7 @@ CREATE FUNCTION file_path_history_04 AS (n) -> if(isNull(n), [], arrayConcat([n] CREATE FUNCTION file_path_history_05 AS (n) -> if(isNull(n), [], [n]); ``` -通过调用 `file_path_history('src/Storages/StorageReplicatedMergeTree.cpp')`,我们递归通过重命名历史,每个函数使用 `old_path` 调用下一个层次。结果使用 `arrayConcat` 组合。 +通过调用 `file_path_history('src/Storages/StorageReplicatedMergeTree.cpp')`,我们遍历重命名历史,每个函数用 `old_path` 调用下一个级别。结果使用 `arrayConcat` 组合。 例如, @@ -1926,7 +2386,7 @@ SELECT file_path_history('src/Storages/StorageReplicatedMergeTree.cpp') AS paths 1 row in set. Elapsed: 0.074 sec. Processed 344.06 thousand rows, 6.27 MB (4.65 million rows/s., 84.71 MB/s.) ``` -我们可以利用这一能力现在组装文件的整个历史提交。在这个例子中,我们展示每个 `path` 值的一个提交。 +我们现在可以利用这一能力来组装一个文件的整个历史的提交。在这个示例中,我们展示每个 `path` 值的一个提交。 ```sql SELECT @@ -1955,9 +2415,9 @@ FORMAT PrettyCompactMonoBlock ### Git blame {#git-blame} -由于当前无法在数组函数中保持状态,因此准确的结果特别难以获得。这可以通过 `arrayFold` 或 `arrayReduce` 实现,实现每次迭代时保持状态。 +由于当前无法在数组函数中保持状态,因此获取确切结果非常困难。这可以通过 `arrayFold` 或 `arrayReduce` 来实现,这使每次迭代都可以保存状态。 -一个大致解决方案,足够进行高层分析,可能如下所示: +一个足够高层次分析的近似解决方案可能看起来像这样: ```sql SELECT @@ -1995,4 +2455,4 @@ LIMIT 20 20 rows in set. Elapsed: 0.547 sec. Processed 7.88 million rows, 679.20 MB (14.42 million rows/s., 1.24 GB/s.) ``` -我们欢迎在这里提供准确和改进的解决方案。 +我们欢迎在此提供准确和改进的解决方案。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/github.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/github.md.hash index ce79825d8de..df9120ca97b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/github.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/github.md.hash @@ -1 +1 @@ -df41cdb16eb620cc +07e7b649a35fc9fa diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/hacker-news-vector-search.md b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/hacker-news-vector-search.md new file mode 100644 index 00000000000..2ae341fd022 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/hacker-news-vector-search.md @@ -0,0 +1,349 @@ +--- +'description': '数据集包含超过 2800 万个 Hacker News 帖子及其向量嵌入' +'sidebar_label': 'Hacker News 向量搜索数据集' +'slug': '/getting-started/example-datasets/hackernews-vector-search-dataset' +'title': 'Hacker News 向量搜索数据集' +'keywords': +- 'semantic search' +- 'vector similarity' +- 'approximate nearest neighbours' +- 'embeddings' +'doc_type': 'guide' +--- + +## 介绍 {#introduction} + +[Hacker News 数据集](https://news.ycombinator.com/) 包含 2874 万 +条帖子及其向量嵌入。这些嵌入是使用 [SentenceTransformers](https://sbert.net/) 模型 [all-MiniLM-L6-v2](https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2) 生成的。每个嵌入向量的维度为 `384`。 + +该数据集可用于走访大型、真实世界向量搜索应用程序的设计、规模和性能方面,该应用程序建立在用户生成的文本数据之上。 + +## 数据集详细信息 {#dataset-details} + +ClickHouse 提供的完整数据集与向量嵌入作为一个单一的 `Parquet` 文件存储在 [S3 bucket](https://clickhouse-datasets.s3.amazonaws.com/hackernews-miniLM/hackernews_part_1_of_1.parquet) + +我们建议用户首先进行规模估算,以通过参考 [文档](../../engines/table-engines/mergetree-family/annindexes.md) 来估计该数据集的存储和内存需求。 + +## 步骤 {#steps} + + + +### 创建表 {#create-table} + +创建 `hackernews` 表以存储帖子及其嵌入和相关属性: + +```sql +CREATE TABLE hackernews +( + `id` Int32, + `doc_id` Int32, + `text` String, + `vector` Array(Float32), + `node_info` Tuple( + start Nullable(UInt64), + end Nullable(UInt64)), + `metadata` String, + `type` Enum8('story' = 1, 'comment' = 2, 'poll' = 3, 'pollopt' = 4, 'job' = 5), + `by` LowCardinality(String), + `time` DateTime, + `title` String, + `post_score` Int32, + `dead` UInt8, + `deleted` UInt8, + `length` UInt32 +) +ENGINE = MergeTree +ORDER BY id; +``` + +`id` 仅为递增整数。额外的属性可用于谓词,以理解向量相似度搜索以及与后过滤/前过滤结合的情况,正如 [文档](../../engines/table-engines/mergetree-family/annindexes.md) 中所解释的那样。 + +### 加载数据 {#load-table} + +要从 `Parquet` 文件加载数据集,请运行以下 SQL 语句: + +```sql +INSERT INTO hackernews SELECT * FROM s3('https://clickhouse-datasets.s3.amazonaws.com/hackernews-miniLM/hackernews_part_1_of_1.parquet'); +``` + +将 2874 万行插入表中将需要几分钟。 + +### 构建向量相似度索引 {#build-vector-similarity-index} + +运行以下 SQL 以定义并构建 `hackernews` 表的 `vector` 列上的向量相似度索引: + +```sql +ALTER TABLE hackernews ADD INDEX vector_index vector TYPE vector_similarity('hnsw', 'cosineDistance', 384, 'bf16', 64, 512); + +ALTER TABLE hackernews MATERIALIZE INDEX vector_index SETTINGS mutations_sync = 2; +``` + +索引创建和搜索的参数及性能考虑在 [文档](../../engines/table-engines/mergetree-family/annindexes.md) 中进行了描述。 +上述语句分别使用 HNSW 超参数 `M` 和 `ef_construction` 的值 64 和 512。 +用户需要通过评估索引构建时间和搜索结果质量来仔细选择这些参数的最佳值。 + +构建和保存索引可能需要几分钟到几个小时,具体取决于可用的 CPU 核心数量和存储带宽。 + +### 执行 ANN 搜索 {#perform-ann-search} + +一旦构建了向量相似度索引,向量搜索查询将自动使用该索引: + +```sql title="Query" +SELECT id, title, text +FROM hackernews +ORDER BY cosineDistance( vector, ) +LIMIT 10 + +``` + +第一次将向量索引加载到内存可能需要几秒钟到几分钟。 + +### 为搜索查询生成嵌入 {#generating-embeddings-for-search-query} + +[Sentence Transformers](https://www.sbert.net/) 提供本地、易于使用的嵌入 +模型,用于捕获句子和段落的语义含义。 + +HackerNews 数据集中包含从 +[all-MiniLM-L6-v2](https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2) 模型生成的向量嵌入。 + +下面提供一个示例 Python 脚本,演示如何使用 `sentence_transformers` Python 包程序化生成 +嵌入向量。搜索嵌入向量随后作为参数传递给 `SELECT` 查询中的 [`cosineDistance()`](/sql-reference/functions/distance-functions#cosineDistance) 函数。 + +```python +from sentence_transformers import SentenceTransformer +import sys + +import clickhouse_connect + +print("Initializing...") + +model = SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2') + +chclient = clickhouse_connect.get_client() # ClickHouse credentials here + +while True: + # Take the search query from user + print("Enter a search query :") + input_query = sys.stdin.readline(); + texts = [input_query] + + # Run the model and obtain search vector + print("Generating the embedding for ", input_query); + embeddings = model.encode(texts) + + print("Querying ClickHouse...") + params = {'v1':list(embeddings[0]), 'v2':20} + result = chclient.query("SELECT id, title, text FROM hackernews ORDER BY cosineDistance(vector, %(v1)s) LIMIT %(v2)s", parameters=params) + print("Results :") + for row in result.result_rows: + print(row[0], row[2][:100]) + print("---------") + +``` + +下面显示了运行上述 Python 脚本和相似度搜索结果的示例 +(仅打印每个前 20 条帖子的 100 个字符): + +```text +Initializing... + +Enter a search query : +Are OLAP cubes useful + +Generating the embedding for "Are OLAP cubes useful" + +Querying ClickHouse... + +Results : + +27742647 smartmic: +slt2021: OLAP Cube is not dead, as long as you use some form of:

1. GROUP BY multiple fi +--------- +27744260 georgewfraser:A data mart is a logical organization of data to help humans understand the schema. Wh +--------- +27761434 mwexler:"We model data according to rigorous frameworks like Kimball or Inmon because we must r +--------- +28401230 chotmat: +erosenbe0: OLAP database is just a copy, replica, or archive of data with a schema designe +--------- +22198879 Merick:+1 for Apache Kylin, it's a great project and awesome open source community. If anyone i +--------- +27741776 crazydoggers:I always felt the value of an OLAP cube was uncovering questions you may not know to as +--------- +22189480 shadowsun7: +_Codemonkeyism: After maintaining an OLAP cube system for some years, I'm not that +--------- +27742029 smartmic: +gengstrand: My first exposure to OLAP was on a team developing a front end to Essbase that +--------- +22364133 irfansharif: +simo7: I'm wondering how this technology could work for OLAP cubes.

An OLAP cube +--------- +23292746 scoresmoke:When I was developing my pet project for Web analytics ( int: + encoding = tiktoken.encoding_for_model(encoding_name) + num_tokens = len(encoding.encode(string)) + return num_tokens + +model = SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2') + +chclient = clickhouse_connect.get_client(compress=False) # ClickHouse credentials here + +while True: + # Take the search query from user + print("Enter a search topic :") + input_query = sys.stdin.readline(); + texts = [input_query] + + # Run the model and obtain search or reference vector + print("Generating the embedding for ----> ", input_query); + embeddings = model.encode(texts) + + print("Querying ClickHouse...") + params = {'v1':list(embeddings[0]), 'v2':100} + result = chclient.query("SELECT id,title,text FROM hackernews ORDER BY cosineDistance(vector, %(v1)s) LIMIT %(v2)s", parameters=params) + + # Just join all the search results + doc_results = "" + for row in result.result_rows: + doc_results = doc_results + "\n" + row[2] + + print("Initializing chatgpt-3.5-turbo model") + model_name = "gpt-3.5-turbo" + + text_splitter = CharacterTextSplitter.from_tiktoken_encoder( + model_name=model_name + ) + + texts = text_splitter.split_text(doc_results) + + docs = [Document(page_content=t) for t in texts] + + llm = ChatOpenAI(temperature=0, model_name=model_name) + + prompt_template = """ +Write a concise summary of the following in not more than 10 sentences: + + +{text} + + +CONSCISE SUMMARY : +""" + + prompt = PromptTemplate(template=prompt_template, input_variables=["text"]) + + num_tokens = num_tokens_from_string(doc_results, model_name) + + gpt_35_turbo_max_tokens = 4096 + verbose = False + + print("Summarizing search results retrieved from ClickHouse...") + + if num_tokens <= gpt_35_turbo_max_tokens: + chain = load_summarize_chain(llm, chain_type="stuff", prompt=prompt, verbose=verbose) + else: + chain = load_summarize_chain(llm, chain_type="map_reduce", map_prompt=prompt, combine_prompt=prompt, verbose=verbose) + + summary = chain.run(docs) + + print(f"Summary from chatgpt-3.5: {summary}") +``` + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/hacker-news-vector-search.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/hacker-news-vector-search.md.hash new file mode 100644 index 00000000000..6101aff94aa --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/hacker-news-vector-search.md.hash @@ -0,0 +1 @@ +9fe7cbb35c6d7424 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/hacker-news.md b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/hacker-news.md new file mode 100644 index 00000000000..5bd188b0c70 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/hacker-news.md @@ -0,0 +1,645 @@ +--- +'description': '数据集包含 2800 万行的 hacker news 数据。' +'sidebar_label': 'Hacker News' +'slug': '/getting-started/example-datasets/hacker-news' +'title': 'Hacker News 数据集' +'doc_type': 'reference' +--- + + +# Hacker News 数据集 + +> 在本教程中,您将从 CSV 和 Parquet 格式中向 ClickHouse 表插入 2800 万行 Hacker News 数据,并运行一些简单的查询来探索数据。 + +## CSV {#csv} + + + +### 下载 CSV {#download} + +数据集的 CSV 版本可以从我们的公共 [S3 bucket](https://datasets-documentation.s3.eu-west-3.amazonaws.com/hackernews/hacknernews.csv.gz) 下载,或者通过运行以下命令来获取: + +```bash +wget https://datasets-documentation.s3.eu-west-3.amazonaws.com/hackernews/hacknernews.csv.gz +``` + +这个压缩文件大小为 4.6GB,包含 2800 万行,下载需要大约 5-10 分钟。 + +### 采样数据 {#sampling} + +[`clickhouse-local`](/operations/utilities/clickhouse-local/) 允许用户对本地文件进行快速处理,而无需部署和配置 ClickHouse 服务器。 + +在将任何数据存储到 ClickHouse 之前,让我们使用 clickhouse-local 对文件进行采样。 +从控制台运行: + +```bash +clickhouse-local +``` + +接下来,运行以下命令来探索数据: + +```sql title="Query" +SELECT * +FROM file('hacknernews.csv.gz', CSVWithNames) +LIMIT 2 +SETTINGS input_format_try_infer_datetimes = 0 +FORMAT Vertical +``` + +```response title="Response" +Row 1: +────── +id: 344065 +deleted: 0 +type: comment +by: callmeed +time: 2008-10-26 05:06:58 +text: What kind of reports do you need?

ActiveMerchant just connects your app to a gateway for cc approval and processing.

Braintree has very nice reports on transactions and it's very easy to refund a payment.

Beyond that, you are dealing with Rails after all–it's pretty easy to scaffold out some reports from your subscriber base. +dead: 0 +parent: 344038 +poll: 0 +kids: [] +url: +score: 0 +title: +parts: [] +descendants: 0 + +Row 2: +────── +id: 344066 +deleted: 0 +type: story +by: acangiano +time: 2008-10-26 05:07:59 +text: +dead: 0 +parent: 0 +poll: 0 +kids: [344111,344202,344329,344606] +url: http://antoniocangiano.com/2008/10/26/what-arc-should-learn-from-ruby/ +score: 33 +title: What Arc should learn from Ruby +parts: [] +descendants: 10 +``` + +此命令中有许多微妙的能力。 +[`file`](/sql-reference/functions/files/#file) 操作符允许您从本地磁盘读取文件,仅指定格式为 `CSVWithNames`。 +最重要的是,架构将从文件内容中自动推断出。 +另外注意 `clickhouse-local` 如何能够读取压缩文件,并根据扩展名推断 gzip 格式。 +`Vertical` 格式用于更轻松地查看每一列的数据。 + +### 使用模式推断加载数据 {#loading-the-data} + +加载数据最简单且功能最强大的工具是 `clickhouse-client`:这是一个功能丰富的本地命令行客户端。 +要加载数据,您可以再次利用模式推断,依赖 ClickHouse 来确定列的数据类型。 + +运行以下命令以创建一个表并直接从远程 CSV 文件插入数据,通过 [`url`](https://clickhouse.com/docs/en/sql-reference/table-functions/url) 函数访问内容。 +架构将自动推断: + +```sql +CREATE TABLE hackernews ENGINE = MergeTree ORDER BY tuple +( +) EMPTY AS SELECT * FROM url('https://datasets-documentation.s3.eu-west-3.amazonaws.com/hackernews/hacknernews.csv.gz', 'CSVWithNames'); +``` + +这将创建一个空表,使用从数据推断出的架构。 +[`DESCRIBE TABLE`](/sql-reference/statements/describe-table) 命令允许我们理解这些分配的类型。 + +```sql title="Query" +DESCRIBE TABLE hackernews +``` + +```text title="Response" +┌─name────────┬─type─────────────────────┬ +│ id │ Nullable(Float64) │ +│ deleted │ Nullable(Float64) │ +│ type │ Nullable(String) │ +│ by │ Nullable(String) │ +│ time │ Nullable(String) │ +│ text │ Nullable(String) │ +│ dead │ Nullable(Float64) │ +│ parent │ Nullable(Float64) │ +│ poll │ Nullable(Float64) │ +│ kids │ Array(Nullable(Float64)) │ +│ url │ Nullable(String) │ +│ score │ Nullable(Float64) │ +│ title │ Nullable(String) │ +│ parts │ Array(Nullable(Float64)) │ +│ descendants │ Nullable(Float64) │ +└─────────────┴──────────────────────────┴ +``` + +要将数据插入此表中,请使用 `INSERT INTO, SELECT` 命令。 +结合 `url` 函数,数据将直接从 URL 流式传输: + +```sql +INSERT INTO hackernews SELECT * +FROM url('https://datasets-documentation.s3.eu-west-3.amazonaws.com/hackernews/hacknernews.csv.gz', 'CSVWithNames') +``` + +您已经成功使用一条命令将 2800 万行插入到 ClickHouse 中! + +### 探索数据 {#explore} + +通过运行以下查询,对 Hacker News 故事和特定列进行采样: + +```sql title="Query" +SELECT + id, + title, + type, + by, + time, + url, + score +FROM hackernews +WHERE type = 'story' +LIMIT 3 +FORMAT Vertical +``` + +```response title="Response" +Row 1: +────── +id: 2596866 +title: +type: story +by: +time: 1306685152 +url: +score: 0 + +Row 2: +────── +id: 2596870 +title: WordPress capture users last login date and time +type: story +by: wpsnipp +time: 1306685252 +url: http://wpsnipp.com/index.php/date/capture-users-last-login-date-and-time/ +score: 1 + +Row 3: +────── +id: 2596872 +title: Recent college graduates get some startup wisdom +type: story +by: whenimgone +time: 1306685352 +url: http://articles.chicagotribune.com/2011-05-27/business/sc-cons-0526-started-20110527_1_business-plan-recession-college-graduates +score: 1 +``` + +虽然模式推断是初始数据探索的一个优秀工具,但它是“最佳努力”的,不能替代为您的数据定义最佳架构的长期方案。 + +### 定义架构 {#define-a-schema} + +显而易见的立即优化是为每个字段定义类型。 +除了将时间字段声明为 `DateTime` 类型外,我们在删除现有数据集后为下方的每个字段定义适当的类型。 +在 ClickHouse 中,数据的主键 id 通过 `ORDER BY` 子句定义。 + +选择适当的类型和决定在 `ORDER BY` 子句中包含哪些列将有助于提高查询速度和压缩效果。 + +运行下面的查询以删除旧架构并创建改进的架构: + +```sql title="Query" +DROP TABLE IF EXISTS hackernews; + +CREATE TABLE hackernews +( + `id` UInt32, + `deleted` UInt8, + `type` Enum('story' = 1, 'comment' = 2, 'poll' = 3, 'pollopt' = 4, 'job' = 5), + `by` LowCardinality(String), + `time` DateTime, + `text` String, + `dead` UInt8, + `parent` UInt32, + `poll` UInt32, + `kids` Array(UInt32), + `url` String, + `score` Int32, + `title` String, + `parts` Array(UInt32), + `descendants` Int32 +) + ENGINE = MergeTree +ORDER BY id +``` + +使用优化后的架构,您现在可以从本地文件系统插入数据。 +同样使用 `clickhouse-client`,通过显式的 `INSERT INTO` 使用 `INFILE` 子句插入文件。 + +```sql title="Query" +INSERT INTO hackernews FROM INFILE '/data/hacknernews.csv.gz' FORMAT CSVWithNames +``` + +### 运行示例查询 {#run-sample-queries} + +以下是一些示例查询,以激励您编写自己的查询。 + +#### “ClickHouse” 在 Hacker News 中的传播程度如何? {#how-pervasive} + +得分字段提供了故事的流行度指标,而 `id` 字段和 `||` +连接操作符可用于生成指向原始帖子的链接。 + +```sql title="Query" +SELECT + time, + score, + descendants, + title, + url, + 'https://news.ycombinator.com/item?id=' || toString(id) AS hn_url +FROM hackernews +WHERE (type = 'story') AND (title ILIKE '%ClickHouse%') +ORDER BY score DESC +LIMIT 5 FORMAT Vertical +``` + +```response title="Response" +Row 1: +────── +time: 1632154428 +score: 519 +descendants: 159 +title: ClickHouse, Inc. +url: https://github.com/ClickHouse/ClickHouse/blob/master/website/blog/en/2021/clickhouse-inc.md +hn_url: https://news.ycombinator.com/item?id=28595419 + +Row 2: +────── +time: 1614699632 +score: 383 +descendants: 134 +title: ClickHouse as an alternative to Elasticsearch for log storage and analysis +url: https://pixeljets.com/blog/clickhouse-vs-elasticsearch/ +hn_url: https://news.ycombinator.com/item?id=26316401 + +Row 3: +────── +time: 1465985177 +score: 243 +descendants: 70 +title: ClickHouse – high-performance open-source distributed column-oriented DBMS +url: https://clickhouse.yandex/reference_en.html +hn_url: https://news.ycombinator.com/item?id=11908254 + +Row 4: +────── +time: 1578331410 +score: 216 +descendants: 86 +title: ClickHouse cost-efficiency in action: analyzing 500B rows on an Intel NUC +url: https://www.altinity.com/blog/2020/1/1/clickhouse-cost-efficiency-in-action-analyzing-500-billion-rows-on-an-intel-nuc +hn_url: https://news.ycombinator.com/item?id=21970952 + +Row 5: +────── +time: 1622160768 +score: 198 +descendants: 55 +title: ClickHouse: An open-source column-oriented database management system +url: https://github.com/ClickHouse/ClickHouse +hn_url: https://news.ycombinator.com/item?id=27310247 +``` + +ClickHouse 的噪声是否随着时间的推移而增加?这里展示了将 `time` 字段定义为 `DateTime` 的重要性,因为使用适当的数据类型允许您使用 `toYYYYMM()` 函数: + +```sql title="Query" +SELECT + toYYYYMM(time) AS monthYear, + bar(count(), 0, 120, 20) +FROM hackernews +WHERE (type IN ('story', 'comment')) AND ((title ILIKE '%ClickHouse%') OR (text ILIKE '%ClickHouse%')) +GROUP BY monthYear +ORDER BY monthYear ASC +``` + +```response title="Response" +┌─monthYear─┬─bar(count(), 0, 120, 20)─┐ +│ 201606 │ ██▎ │ +│ 201607 │ ▏ │ +│ 201610 │ ▎ │ +│ 201612 │ ▏ │ +│ 201701 │ ▎ │ +│ 201702 │ █ │ +│ 201703 │ ▋ │ +│ 201704 │ █ │ +│ 201705 │ ██ │ +│ 201706 │ ▎ │ +│ 201707 │ ▎ │ +│ 201708 │ ▏ │ +│ 201709 │ ▎ │ +│ 201710 │ █▌ │ +│ 201711 │ █▌ │ +│ 201712 │ ▌ │ +│ 201801 │ █▌ │ +│ 201802 │ ▋ │ +│ 201803 │ ███▏ │ +│ 201804 │ ██▏ │ +│ 201805 │ ▋ │ +│ 201806 │ █▏ │ +│ 201807 │ █▌ │ +│ 201808 │ ▋ │ +│ 201809 │ █▌ │ +│ 201810 │ ███▌ │ +│ 201811 │ ████ │ +│ 201812 │ █▌ │ +│ 201901 │ ████▋ │ +│ 201902 │ ███ │ +│ 201903 │ ▋ │ +│ 201904 │ █ │ +│ 201905 │ ███▋ │ +│ 201906 │ █▏ │ +│ 201907 │ ██▎ │ +│ 201908 │ ██▋ │ +│ 201909 │ █▋ │ +│ 201910 │ █ │ +│ 201911 │ ███ │ +│ 201912 │ █▎ │ +│ 202001 │ ███████████▋ │ +│ 202002 │ ██████▌ │ +│ 202003 │ ███████████▋ │ +│ 202004 │ ███████▎ │ +│ 202005 │ ██████▏ │ +│ 202006 │ ██████▏ │ +│ 202007 │ ███████▋ │ +│ 202008 │ ███▋ │ +│ 202009 │ ████ │ +│ 202010 │ ████▌ │ +│ 202011 │ █████▏ │ +│ 202012 │ ███▋ │ +│ 202101 │ ███▏ │ +│ 202102 │ █████████ │ +│ 202103 │ █████████████▋ │ +│ 202104 │ ███▏ │ +│ 202105 │ ████████████▋ │ +│ 202106 │ ███ │ +│ 202107 │ █████▏ │ +│ 202108 │ ████▎ │ +│ 202109 │ ██████████████████▎ │ +│ 202110 │ ▏ │ +└───────────┴──────────────────────────┘ +``` + +看起来“ClickHouse”的受欢迎程度随着时间的推移而增长。 + +#### 谁是 ClickHouse 相关文章的顶级评论者? {#top-commenters} + +```sql title="Query" +SELECT + by, + count() AS comments +FROM hackernews +WHERE (type IN ('story', 'comment')) AND ((title ILIKE '%ClickHouse%') OR (text ILIKE '%ClickHouse%')) +GROUP BY by +ORDER BY comments DESC +LIMIT 5 +``` + +```response title="Response" +┌─by──────────┬─comments─┐ +│ hodgesrm │ 78 │ +│ zX41ZdbW │ 45 │ +│ manigandham │ 39 │ +│ pachico │ 35 │ +│ valyala │ 27 │ +└─────────────┴──────────┘ +``` + +#### 哪些评论产生了最多的兴趣? {#comments-by-most-interest} + +```sql title="Query" +SELECT + by, + sum(score) AS total_score, + sum(length(kids)) AS total_sub_comments +FROM hackernews +WHERE (type IN ('story', 'comment')) AND ((title ILIKE '%ClickHouse%') OR (text ILIKE '%ClickHouse%')) +GROUP BY by +ORDER BY total_score DESC +LIMIT 5 +``` + +```response title="Response" +┌─by───────┬─total_score─┬─total_sub_comments─┐ +│ zX41ZdbW │ 571 │ 50 │ +│ jetter │ 386 │ 30 │ +│ hodgesrm │ 312 │ 50 │ +│ mechmind │ 243 │ 16 │ +│ tosh │ 198 │ 12 │ +└──────────┴─────────────┴────────────────────┘ +``` + + + +## Parquet {#parquet} + +ClickHouse 的一个优势是能够处理任意数量的 [格式](/interfaces/formats)。 +CSV 代表了一个相当理想的用例,但并不是数据交换中最有效的格式。 + +接下来,您将从 Parquet 文件中加载数据,这是一个高效的列式格式。 + +Parquet 拥有最小的数据类型,ClickHouse 需要遵循这些类型信息,并且这些类型信息编码在格式本身中。 +对 Parquet 文件的类型推断必然会导致与 CSV 文件的架构略有不同。 + + + +### 插入数据 {#insert-the-data} + +运行以下查询以读取相同的 Parquet 格式数据,同样使用 url 函数读取远程数据: + +```sql +DROP TABLE IF EXISTS hackernews; + +CREATE TABLE hackernews +ENGINE = MergeTree +ORDER BY id +SETTINGS allow_nullable_key = 1 EMPTY AS +SELECT * +FROM url('https://datasets-documentation.s3.eu-west-3.amazonaws.com/hackernews/hacknernews.parquet', 'Parquet') + +INSERT INTO hackernews SELECT * +FROM url('https://datasets-documentation.s3.eu-west-3.amazonaws.com/hackernews/hacknernews.parquet', 'Parquet') +``` + +:::note Parquet 的 Null 键 +作为 Parquet 格式的条件,我们必须接受键可能为 `NULL`, +即使它们不在数据中。 +::: + +运行以下命令以查看推断的架构: + +```sql title="Query" +┌─name────────┬─type───────────────────┬ +│ id │ Nullable(Int64) │ +│ deleted │ Nullable(UInt8) │ +│ type │ Nullable(String) │ +│ time │ Nullable(Int64) │ +│ text │ Nullable(String) │ +│ dead │ Nullable(UInt8) │ +│ parent │ Nullable(Int64) │ +│ poll │ Nullable(Int64) │ +│ kids │ Array(Nullable(Int64)) │ +│ url │ Nullable(String) │ +│ score │ Nullable(Int32) │ +│ title │ Nullable(String) │ +│ parts │ Array(Nullable(Int64)) │ +│ descendants │ Nullable(Int32) │ +└─────────────┴────────────────────────┴ +``` + +与 CSV 文件一样,您可以手动指定架构,以更好地控制所选择的类型,并直接从 s3 插入数据: + +```sql +CREATE TABLE hackernews +( + `id` UInt64, + `deleted` UInt8, + `type` String, + `author` String, + `timestamp` DateTime, + `comment` String, + `dead` UInt8, + `parent` UInt64, + `poll` UInt64, + `children` Array(UInt32), + `url` String, + `score` UInt32, + `title` String, + `parts` Array(UInt32), + `descendants` UInt32 +) +ENGINE = MergeTree +ORDER BY (type, author); + +INSERT INTO hackernews +SELECT * FROM s3( + 'https://datasets-documentation.s3.eu-west-3.amazonaws.com/hackernews/hacknernews.parquet', + 'Parquet', + 'id UInt64, + deleted UInt8, + type String, + by String, + time DateTime, + text String, + dead UInt8, + parent UInt64, + poll UInt64, + kids Array(UInt32), + url String, + score UInt32, + title String, + parts Array(UInt32), + descendants UInt32'); +``` + +### 添加跳过索引以加速查询 {#add-skipping-index} + +要找出有多少评论提及“ClickHouse”,请运行以下查询: + +```sql title="Query" +SELECT count(*) +FROM hackernews +WHERE hasToken(lower(comment), 'ClickHouse'); +``` + +```response title="Response" +#highlight-next-line +1 row in set. Elapsed: 0.843 sec. Processed 28.74 million rows, 9.75 GB (34.08 million rows/s., 11.57 GB/s.) +┌─count()─┐ +│ 516 │ +└─────────┘ +``` + +接下来,您将创建一个反向 [索引](/engines/table-engines/mergetree-family/invertedindexes) 在“comment” 列上,以加速此查询。 +请注意,小写评论将被索引,以独立于大小写查找术语。 + +运行以下命令以创建索引: + +```sql +ALTER TABLE hackernews ADD INDEX comment_idx(lower(comment)) TYPE inverted; +ALTER TABLE hackernews MATERIALIZE INDEX comment_idx; +``` + +索引的生成会花费一些时间(要检查索引是否已创建,请使用系统表 `system.data_skipping_indices`)。 + +一旦索引创建完成,再次运行查询: + +```sql title="Query" +SELECT count(*) +FROM hackernews +WHERE hasToken(lower(comment), 'clickhouse'); +``` + +注意查询现在只需 0.248 秒,而之前没有索引时为 0.843 秒: + +```response title="Response" +#highlight-next-line +1 row in set. Elapsed: 0.248 sec. Processed 4.54 million rows, 1.79 GB (18.34 million rows/s., 7.24 GB/s.) +┌─count()─┐ +│ 1145 │ +└─────────┘ +``` + +可以使用 [`EXPLAIN`](/sql-reference/statements/explain) 子句了解为什么添加此索引使查询速度提升约 3.4 倍。 + +```response text="Query" +EXPLAIN indexes = 1 +SELECT count(*) +FROM hackernews +WHERE hasToken(lower(comment), 'clickhouse') +``` + +```response title="Response" +┌─explain─────────────────────────────────────────┐ +│ Expression ((Projection + Before ORDER BY)) │ +│ Aggregating │ +│ Expression (Before GROUP BY) │ +│ Filter (WHERE) │ +│ ReadFromMergeTree (default.hackernews) │ +│ Indexes: │ +│ PrimaryKey │ +│ Condition: true │ +│ Parts: 4/4 │ +│ Granules: 3528/3528 │ +│ Skip │ +│ Name: comment_idx │ +│ Description: inverted GRANULARITY 1 │ +│ Parts: 4/4 │ +│ Granules: 554/3528 │ +└─────────────────────────────────────────────────┘ +``` + +注意到索引允许跳过大量粒度,以加速查询。 + +现在还可以高效地搜索一个或多个术语: + +```sql title="Query" +SELECT count(*) +FROM hackernews +WHERE multiSearchAny(lower(comment), ['oltp', 'olap']); +``` + +```response title="Response" +┌─count()─┐ +│ 2177 │ +└─────────┘ +``` + +```sql title="Query" +SELECT count(*) +FROM hackernews +WHERE hasToken(lower(comment), 'avx') AND hasToken(lower(comment), 'sve'); +``` + +```response +┌─count()─┐ +│ 22 │ +└─────────┘ +``` + + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/hacker-news.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/hacker-news.md.hash new file mode 100644 index 00000000000..d41847b7abd --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/hacker-news.md.hash @@ -0,0 +1 @@ +2fa40cd6a6d85670 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/laion.md b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/laion.md index 828b806bcd0..4ef01e4d6a5 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/laion.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/laion.md @@ -1,17 +1,18 @@ --- -'description': '数据集包含 400 百万图像,带有英文图像说明' +'description': '数据集包含 4 亿张图像,带有英文图像说明' 'sidebar_label': 'Laion-400M 数据集' 'slug': '/getting-started/example-datasets/laion-400m-dataset' 'title': 'Laion-400M 数据集' +'doc_type': 'reference' --- -The [Laion-400M dataset](https://laion.ai/blog/laion-400-open-dataset/) 包含 4 亿张带有英文图像描述的图像。如今,Laion 提供了 [一个更大的数据集](https://laion.ai/blog/laion-5b/),但与之合作的方式将是类似的。 +[Laion-400M 数据集](https://laion.ai/blog/laion-400-open-dataset/) 包含 4 亿张带有英文图片标题的图像。目前 Laion 提供了 [一个更大的数据集](https://laion.ai/blog/laion-5b/),但使用方式类似。 -该数据集包含图像 URL、图像和图像描述的嵌入、图像与图像描述之间的相似性评分,以及元数据,如图像宽度/高度、许可证和 NSFW 标志。我们可以使用该数据集来演示 [近似最近邻搜索](../../engines/table-engines/mergetree-family/annindexes.md) 在 ClickHouse 中的用法。 +该数据集包含图像 URL、图像及其标题的嵌入、图像与标题之间的相似度评分,以及元数据,例如图像的宽度/高度、许可证和 NSFW 标志。我们可以使用该数据集来演示 [近似最近邻搜索](../../engines/table-engines/mergetree-family/annindexes.md) 在 ClickHouse 中的实现。 ## 数据准备 {#data-preparation} -嵌入和元数据存储在原始数据的不同文件中。数据准备步骤下载数据、合并文件,将其转换为 CSV 并导入到 ClickHouse 中。您可以使用以下 `download.sh` 脚本来实现: +嵌入和元数据存储在原始数据中的不同文件中。数据准备步骤下载数据、合并文件,转换为 CSV 后导入 ClickHouse。您可以使用以下 `download.sh` 脚本进行操作: ```bash number=${1} @@ -52,11 +53,11 @@ data = data[['url', 'caption', 'NSFW', 'similarity', "image_embedding", "text_em # transform np.arrays to lists -data['image_embedding'] = data['image_embedding'].apply(lambda x: list(x)) -data['text_embedding'] = data['text_embedding'].apply(lambda x: list(x)) +data['image_embedding'] = data['image_embedding'].apply(lambda x: x.tolist()) +data['text_embedding'] = data['text_embedding'].apply(lambda x: x.tolist()) -# this small hack is needed becase caption sometimes contains all kind of quotes +# this small hack is needed because caption sometimes contains all kind of quotes data['caption'] = data['caption'].apply(lambda x: x.replace("'", " ").replace('"', " ")) @@ -74,13 +75,13 @@ os.system(f"rm {npy_file} {metadata_file} {text_npy}") seq 0 409 | xargs -P1 -I{} bash -c './download.sh {}' ``` -数据集被分成 410 个文件,每个文件包含约 100 万行。如果您想使用较小的数据子集,只需调整限制,例如 `seq 0 9 | ...`。 +数据集被分成 410 个文件,每个文件大约包含 100 万行。如果您希望使用更小的子集,只需调整限制,例如 `seq 0 9 | ...`。 -(上述 Python 脚本速度非常慢(每个文件约 2-10 分钟),占用大量内存(每个文件 41 GB),并且生成的 CSV 文件较大(每个 10 GB),所以请小心。如果您的 RAM 足够,可以增加 `-P1` 数字以提高并行性。如果仍然太慢,请考虑制定更好的导入程序——也许将 .npy 文件转换为 parquet,然后用 ClickHouse 处理所有其他操作。) +(上述 Python 脚本速度较慢(每个文件约 2-10 分钟),占用大量内存(每个文件 41 GB),并且生成的 CSV 文件较大(每个 10 GB),所以请小心。如果您的 RAM 足够,可以将 `-P1` 的数字增加以实现更高的并行性。如果仍然太慢,可以考虑提出更好的摄取过程 - 也许先将 .npy 文件转换为 parquet,然后用 ClickHouse 进行所有其他处理。) ## 创建表 {#create-table} -要创建一个没有索引的表,请运行: +要最初创建一个没有索引的表,请运行: ```sql CREATE TABLE laion @@ -98,100 +99,103 @@ ORDER BY id SETTINGS index_granularity = 8192 ``` -要将 CSV 文件导入到 ClickHouse 中: +要将 CSV 文件导入 ClickHouse,请执行: ```sql INSERT INTO laion FROM INFILE '{path_to_csv_files}/*.csv' ``` -## 运行无 ANN 索引的暴力近似最近邻搜索 {#run-a-brute-force-ann-search-without-ann-index} +请注意,`id` 列仅供说明,并由脚本填充非唯一值。 -要运行暴力的近似最近邻搜索,请运行: +## 运行暴力向量相似度搜索 {#run-a-brute-force-vector-similarity-search} + +要运行暴力近似向量搜索,请执行: ```sql -SELECT url, caption FROM laion ORDER BY L2Distance(image_embedding, {target:Array(Float32)}) LIMIT 30 +SELECT url, caption FROM laion ORDER BY cosineDistance(image_embedding, {target:Array(Float32)}) LIMIT 10 ``` -`target` 是一个包含 512 个元素的数组和一个客户端参数。获取这样的数组的方便方法将在文章结束时呈现。现在,我们可以将随机猫图像的嵌入作为 `target` 进行运行。 +`target` 是一个包含 512 个元素的数组和一个客户端参数。最后,将在文章末尾介绍获取此类数组的方便方法。现在,我们可以将随机 LEGO 套装图片的嵌入作为 `target`。 **结果** ```markdown -┌─url───────────────────────────────────────────────────────────────────────────────────────────────────────────┬─caption────────────────────────────────────────────────────────────────┐ -│ https://s3.amazonaws.com/filestore.rescuegroups.org/6685/pictures/animals/13884/13884995/63318230_463x463.jpg │ Adoptable Female Domestic Short Hair │ -│ https://s3.amazonaws.com/pet-uploads.adoptapet.com/8/b/6/239905226.jpg │ Adopt A Pet :: Marzipan - New York, NY │ -│ http://d1n3ar4lqtlydb.cloudfront.net/9/2/4/248407625.jpg │ Adopt A Pet :: Butterscotch - New Castle, DE │ -│ https://s3.amazonaws.com/pet-uploads.adoptapet.com/e/e/c/245615237.jpg │ Adopt A Pet :: Tiggy - Chicago, IL │ -│ http://pawsofcoronado.org/wp-content/uploads/2012/12/rsz_pumpkin.jpg │ Pumpkin an orange tabby kitten for adoption │ -│ https://s3.amazonaws.com/pet-uploads.adoptapet.com/7/8/3/188700997.jpg │ Adopt A Pet :: Brian the Brad Pitt of cats - Frankfort, IL │ -│ https://s3.amazonaws.com/pet-uploads.adoptapet.com/8/b/d/191533561.jpg │ Domestic Shorthair Cat for adoption in Mesa, Arizona - Charlie │ -│ https://s3.amazonaws.com/pet-uploads.adoptapet.com/0/1/2/221698235.jpg │ Domestic Shorthair Cat for adoption in Marietta, Ohio - Daisy (Spayed) │ -└───────────────────────────────────────────────────────────────────────────────────────────────────────────────┴────────────────────────────────────────────────────────────────────────┘ - -8 rows in set. Elapsed: 6.432 sec. Processed 19.65 million rows, 43.96 GB (3.06 million rows/s., 6.84 GB/s.) + ┌─url───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┬─caption──────────────────────────────────────────────────────────────────────────┐ + 1. │ https://s4.thcdn.com/productimg/600/600/11340490-9914447026352671.jpg │ LEGO Friends: Puppy Treats & Tricks (41304) │ + 2. │ https://www.avenuedelabrique.com/img/uploads/f20fd44bfa4bd49f2a3a5fad0f0dfed7d53c3d2f.jpg │ Nouveau LEGO Friends 41334 Andrea s Park Performance 2018 │ + 3. │ http://images.esellerpro.com/2489/I/667/303/3938_box_in.jpg │ 3938 LEGO Andreas Bunny House Girls Friends Heartlake Age 5-12 / 62 Pieces New! │ + 4. │ http://i.shopmania.org/180x180/7/7f/7f1e1a2ab33cde6af4573a9e0caea61293dfc58d.jpg?u=https%3A%2F%2Fs.s-bol.com%2Fimgbase0%2Fimagebase3%2Fextralarge%2FFC%2F4%2F0%2F9%2F9%2F9200000049789904.jpg │ LEGO Friends Avonturenkamp Boomhuis - 41122 │ + 5. │ https://s.s-bol.com/imgbase0/imagebase/large/FC/5/5/9/4/1004004011684955.jpg │ LEGO Friends Andrea s Theatershow - 3932 │ + 6. │ https://www.jucariicucubau.ro/30252-home_default/41445-lego-friends-ambulanta-clinicii-veterinare.jpg │ 41445 - LEGO Friends - Ambulanta clinicii veterinare │ + 7. │ https://cdn.awsli.com.br/600x1000/91/91201/produto/24833262/234c032725.jpg │ LEGO FRIENDS 41336 EMMA S ART CAFÉ │ + 8. │ https://media.4rgos.it/s/Argos/6174930_R_SET?$Thumb150$&$Web$ │ more details on LEGO Friends Stephanie s Friendship Cake Set - 41308. │ + 9. │ https://thumbs4.ebaystatic.com/d/l225/m/mG4k6qAONd10voI8NUUMOjw.jpg │ Lego Friends Gymnast 30400 Polybag 26 pcs │ +10. │ http://www.ibrickcity.com/wp-content/gallery/41057/thumbs/thumbs_lego-41057-heartlake-horse-show-friends-3.jpg │ lego-41057-heartlake-horse-show-friends-3 │ + └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┴──────────────────────────────────────────────────────────────────────────────────┘ + +10 rows in set. Elapsed: 4.605 sec. Processed 100.38 million rows, 309.98 GB (21.80 million rows/s., 67.31 GB/s.) ``` -## 运行带 ANN 索引的 ANN {#run-a-ann-with-an-ann-index} +## 使用向量相似度索引运行近似向量相似度搜索 {#run-an-approximate-vector-similarity-search-with-a-vector-similarity-index} -创建一个带 ANN 索引的新表,并从现有表中插入数据: +现在让我们在表上定义两个向量相似度索引。 ```sql -CREATE TABLE laion_annoy -( - `id` Int64, - `url` String, - `caption` String, - `NSFW` String, - `similarity` Float32, - `image_embedding` Array(Float32), - `text_embedding` Array(Float32), - INDEX annoy_image image_embedding TYPE annoy(), - INDEX annoy_text text_embedding TYPE annoy() -) -ENGINE = MergeTree -ORDER BY id -SETTINGS index_granularity = 8192; +ALTER TABLE laion ADD INDEX image_index image_embedding TYPE vector_similarity('hnsw', 'cosineDistance', 512, 'bf16', 64, 256) +ALTER TABLE laion ADD INDEX text_index text_embedding TYPE vector_similarity('hnsw', 'cosineDistance', 512, 'bf16', 64, 256) +``` + +索引创建和搜索的参数及性能考虑在 [文档中](../../engines/table-engines/mergetree-family/annindexes.md) 进行了描述。上述索引定义指定了一个 HNSW 索引,使用“余弦距离”作为距离度量,参数“hnsw_max_connections_per_layer”设置为 64,参数“hnsw_candidate_list_size_for_construction”设置为 256。该索引使用半精度浮点数(bfloat16)作为量化,以优化内存使用。 + +要构建和物化索引,请运行以下语句: -INSERT INTO laion_annoy SELECT * FROM laion; +```sql +ALTER TABLE laion MATERIALIZE INDEX image_index; +ALTER TABLE laion MATERIALIZE INDEX text_index; ``` -默认情况下,Annoy 索引用 L2 距离作为度量。索引创建和搜索的进一步调优参数在 Annoy 索引 [文档](../../engines/table-engines/mergetree-family/annindexes.md) 中进行了描述。现在,我们再次用相同的查询进行检查: +构建和保存索引可能需要几分钟甚至几个小时,具体取决于行数和 HNSW 索引参数。 + +要执行向量搜索,只需再次执行相同的查询: ```sql -SELECT url, caption FROM laion_annoy ORDER BY l2Distance(image_embedding, {target:Array(Float32)}) LIMIT 8 +SELECT url, caption FROM laion ORDER BY cosineDistance(image_embedding, {target:Array(Float32)}) LIMIT 10 ``` **结果** ```response -┌─url──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┬─caption──────────────────────────────────────────────────────────────┐ -│ http://tse1.mm.bing.net/th?id=OIP.R1CUoYp_4hbeFSHBaaB5-gHaFj │ bed bugs and pets can cats carry bed bugs pets adviser │ -│ http://pet-uploads.adoptapet.com/1/9/c/1963194.jpg?336w │ Domestic Longhair Cat for adoption in Quincy, Massachusetts - Ashley │ -│ https://thumbs.dreamstime.com/t/cat-bed-12591021.jpg │ Cat on bed Stock Image │ -│ https://us.123rf.com/450wm/penta/penta1105/penta110500004/9658511-portrait-of-british-short-hair-kitten-lieing-at-sofa-on-sun.jpg │ Portrait of british short hair kitten lieing at sofa on sun. │ -│ https://www.easypetmd.com/sites/default/files/Wirehaired%20Vizsla%20(2).jpg │ Vizsla (Wirehaired) image 3 │ -│ https://images.ctfassets.net/yixw23k2v6vo/0000000200009b8800000000/7950f4e1c1db335ef91bb2bc34428de9/dog-cat-flickr-Impatience_1.jpg?w=600&h=400&fm=jpg&fit=thumb&q=65&fl=progressive │ dog and cat image │ -│ https://i1.wallbox.ru/wallpapers/small/201523/eaa582ee76a31fd.jpg │ cats, kittens, faces, tonkinese │ -│ https://www.baxterboo.com/images/breeds/medium/cairn-terrier.jpg │ Cairn Terrier Photo │ -└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┴──────────────────────────────────────────────────────────────────────┘ - -8 rows in set. Elapsed: 0.641 sec. Processed 22.06 thousand rows, 49.36 MB (91.53 thousand rows/s., 204.81 MB/s.) + ┌─url───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┬─caption──────────────────────────────────────────────────────────────────────────┐ + 1. │ https://s4.thcdn.com/productimg/600/600/11340490-9914447026352671.jpg │ LEGO Friends: Puppy Treats & Tricks (41304) │ + 2. │ https://www.avenuedelabrique.com/img/uploads/f20fd44bfa4bd49f2a3a5fad0f0dfed7d53c3d2f.jpg │ Nouveau LEGO Friends 41334 Andrea s Park Performance 2018 │ + 3. │ http://images.esellerpro.com/2489/I/667/303/3938_box_in.jpg │ 3938 LEGO Andreas Bunny House Girls Friends Heartlake Age 5-12 / 62 Pieces New! │ + 4. │ http://i.shopmania.org/180x180/7/7f/7f1e1a2ab33cde6af4573a9e0caea61293dfc58d.jpg?u=https%3A%2F%2Fs.s-bol.com%2Fimgbase0%2Fimagebase3%2Fextralarge%2FFC%2F4%2F0%2F9%2F9%2F9200000049789904.jpg │ LEGO Friends Avonturenkamp Boomhuis - 41122 │ + 5. │ https://s.s-bol.com/imgbase0/imagebase/large/FC/5/5/9/4/1004004011684955.jpg │ LEGO Friends Andrea s Theatershow - 3932 │ + 6. │ https://www.jucariicucubau.ro/30252-home_default/41445-lego-friends-ambulanta-clinicii-veterinare.jpg │ 41445 - LEGO Friends - Ambulanta clinicii veterinare │ + 7. │ https://cdn.awsli.com.br/600x1000/91/91201/produto/24833262/234c032725.jpg │ LEGO FRIENDS 41336 EMMA S ART CAFÉ │ + 8. │ https://media.4rgos.it/s/Argos/6174930_R_SET?$Thumb150$&$Web$ │ more details on LEGO Friends Stephanie s Friendship Cake Set - 41308. │ + 9. │ https://thumbs4.ebaystatic.com/d/l225/m/mG4k6qAONd10voI8NUUMOjw.jpg │ Lego Friends Gymnast 30400 Polybag 26 pcs │ +10. │ http://www.ibrickcity.com/wp-content/gallery/41057/thumbs/thumbs_lego-41057-heartlake-horse-show-friends-3.jpg │ lego-41057-heartlake-horse-show-friends-3 │ + └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┴──────────────────────────────────────────────────────────────────────────────────┘ + +10 rows in set. Elapsed: 0.019 sec. Processed 137.27 thousand rows, 24.42 MB (7.38 million rows/s., 1.31 GB/s.) ``` -速度显著提高,但结果的准确性降低。这是因为 ANN 索引只能提供近似搜索结果。请注意该示例搜索了相似图像嵌入,但也可以搜索正向图像描述嵌入。 +查询延迟显著降低,因为最近的邻居是通过向量索引检索的。使用向量相似度索引的向量相似度搜索可能返回略有不同的结果,与暴力搜索结果有所不同。通过仔细选择 HNSW 参数并评估索引质量,HNSW 索引可能实现接近 1 的召回率(与暴力搜索相同的准确性)。 ## 使用 UDF 创建嵌入 {#creating-embeddings-with-udfs} -通常希望为新图像或新图像描述创建嵌入,并在数据中搜索相似的图像/图像描述对。我们可以使用 [UDF](/sql-reference/functions/udf) 来创建 `target` 向量,而无需离开客户端。重要的是使用相同的模型创建数据和新嵌入以进行搜索。以下脚本利用了同样支撑数据集的 `ViT-B/32` 模型。 +通常希望为新图像或新图像标题创建嵌入,并在数据中搜索相似的图像/图像标题对。我们可以使用 [UDF](/sql-reference/functions/udf) 在客户端内创建 `target` 向量,而无需离开客户端。重要的是使用相同的模型来创建数据和新嵌入以进行搜索。以下脚本利用了 `ViT-B/32` 模型,该模型也是数据集的基础。 ### 文本嵌入 {#text-embeddings} -首先,将以下 Python 脚本存储在 ClickHouse 数据路径的 `user_scripts/` 目录中并使其可执行(`chmod +x encode_text.py`)。 +首先,将以下 Python 脚本存储在 ClickHouse 数据路径的 `user_scripts/` 目录中,并使其可执行(`chmod +x encode_text.py`)。 -`encode_text.py`: +`encode_text.py`: ```python #!/usr/bin/python3 +#!Note: Change the above python3 executable location if a virtual env is being used. import clip import torch import numpy as np @@ -208,7 +212,7 @@ if __name__ == '__main__': sys.stdout.flush() ``` -然后在 ClickHouse 服务器配置文件中创建 `encode_text_function.xml`,此路径在 `/path/to/*_function.xml` 中引用。 +然后在 ClickHouse 服务器配置文件中 `/path/to/*_function.xml` 引用的位置创建 `encode_text_function.xml`。 ```xml @@ -227,21 +231,32 @@ if __name__ == '__main__': ``` -您现在可以简单使用: +现在您可以简单地使用: ```sql SELECT encode_text('cat'); ``` -第一次运行会很慢,因为它加载模型,但重复运行将会很快。然后我们可以将输出复制到 `SET param_target=...`,并可以轻松写查询。 + +第一次运行会很慢,因为它加载模型,但后续运行会很快。然后我们可以将输出复制到 `SET param_target=...`,轻松编写查询。或者,`encode_text()` 函数可以直接作为 `cosineDistance` 函数的参数使用: + +```SQL +SELECT url +FROM laion +ORDER BY cosineDistance(text_embedding, encode_text('a dog and a cat')) ASC +LIMIT 10 +``` + +注意,`encode_text()` UDF 本身可能需要几秒钟来计算和发出嵌入向量。 ### 图像嵌入 {#image-embeddings} -图像嵌入可以类似创建,但我们将向 Python 脚本提供本地图像的路径,而不是图像描述文本。 +图像嵌入可以类似地创建,我们提供一个 Python 脚本,可以生成本地作为文件存储的图像的嵌入。 `encode_image.py` ```python #!/usr/bin/python3 +#!Note: Change the above python3 executable location if a virtual env is being used. import clip import torch import numpy as np @@ -278,8 +293,27 @@ if __name__ == '__main__': ``` -然后运行以下查询: +获取一个示例图像以进行搜索: + +```shell + +# get a random image of a LEGO set +$ wget http://cdn.firstcry.com/brainbees/images/products/thumb/191325a.jpg +``` + +然后运行此查询以生成上述图像的嵌入: ```sql SELECT encode_image('/path/to/your/image'); ``` + +完整的搜索查询为: + +```sql +SELECT + url, + caption +FROM laion +ORDER BY cosineDistance(image_embedding, encode_image('/path/to/your/image')) ASC +LIMIT 10 +``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/laion.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/laion.md.hash index 92da208c2a2..1705605df76 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/laion.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/laion.md.hash @@ -1 +1 @@ -937b172d68ea3a04 +7d853914f84059ea diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/laion5b.md b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/laion5b.md new file mode 100644 index 00000000000..06c57b87775 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/laion5b.md @@ -0,0 +1,196 @@ +--- +'description': '数据集包含来自 LAION 5B 数据集的 1 亿个向量' +'sidebar_label': 'LAION 5B 数据集' +'slug': '/getting-started/example-datasets/laion-5b-dataset' +'title': 'LAION 5B 数据集' +'keywords': +- 'semantic search' +- 'vector similarity' +- 'approximate nearest neighbours' +- 'embeddings' +'doc_type': 'reference' +--- + +import search_results_image from '@site/static/images/getting-started/example-datasets/laion5b_visualization_1.png' +import Image from '@theme/IdealImage'; + +## 介绍 {#introduction} + +[LAION 5b 数据集](https://laion.ai/blog/laion-5b/) 包含 58.5 亿个图像-文本嵌入和相关的图像元数据。嵌入是使用 `Open AI CLIP` 模型 [ViT-L/14](https://huggingface.co/sentence-transformers/clip-ViT-L-14) 生成的。每个嵌入向量的维度是 `768`。 + +该数据集可用于大型实际向量搜索应用程序的设计、大小和性能方面建模。该数据集可用于文本到图像搜索和图像到图像搜索。 + +## 数据集细节 {#dataset-details} + +完整的数据集以 `npy` 和 `Parquet` 文件的混合形式在 [the-eye.eu](https://the-eye.eu/public/AI/cah/laion5b/) 提供。 + +ClickHouse 已在 `S3` 桶中提供了 1 亿个向量的子集。该 `S3` 桶包含 10 个 `Parquet` 文件,每个 `Parquet` 文件填充了 1000 万行。 + +我们建议用户首先运行一个规模评估练习,通过参考 [文档](../../engines/table-engines/mergetree-family/annindexes.md) 来估算该数据集的存储和内存要求。 + +## 步骤 {#steps} + + + +### 创建表 {#create-table} + +创建 `laion_5b_100m` 表以存储嵌入及其相关属性: + +```sql +CREATE TABLE laion_5b_100m +( + id UInt32, + image_path String, + caption String, + NSFW Nullable(String) default 'unknown', + similarity Float32, + LICENSE Nullable(String), + url String, + key String, + status LowCardinality(String), + width Int32, + height Int32, + original_width Int32, + original_height Int32, + exif Nullable(String), + md5 String, + vector Array(Float32) CODEC(NONE) +) ENGINE = MergeTree ORDER BY (id) +``` + +`id` 只是一个递增的整数。其他属性可以用于谓词,以理解结合后过滤/前过滤的向量相似性搜索,如 [文档](../../engines/table-engines/mergetree-family/annindexes.md) 中所述。 + +### 加载数据 {#load-table} + +要从所有 `Parquet` 文件加载数据集,运行以下 SQL 语句: + +```sql +INSERT INTO laion_5b_100m SELECT * FROM s3('https://clickhouse-datasets.s3.amazonaws.com/laion-5b/laion5b_100m_*.parquet'); +``` + +将 1 亿行加载到表中可能需要几分钟。 + +或者,可以运行单独的 SQL 语句以加载特定数量的文件/行。 + +```sql +INSERT INTO laion_5b_100m SELECT * FROM s3('https://clickhouse-datasets.s3.amazonaws.com/laion-5b/laion5b_100m_part_1_of_10.parquet'); +INSERT INTO laion_5b_100m SELECT * FROM s3('https://clickhouse-datasets.s3.amazonaws.com/laion-5b/laion5b_100m_part_2_of_10.parquet'); +⋮ +``` + +### 运行暴力向量相似性搜索 {#run-a-brute-force-vector-similarity-search} + +KNN(k - 最近邻)搜索或暴力搜索涉及计算数据集中每个向量与搜索嵌入向量的距离,然后对距离进行排序以获取最近邻。我们可以使用数据集中的一个向量作为搜索向量。例如: + +```sql title="Query" +SELECT id, url +FROM laion_5b_100m +ORDER BY cosineDistance( vector, (SELECT vector FROM laion_5b_100m WHERE id = 9999) ) ASC +LIMIT 20 + +The vector in the row with id = 9999 is the embedding for an image of a Deli restaurant. +``` + +```response title="Response" + ┌───────id─┬─url───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ + 1. │ 9999 │ https://certapro.com/belleville/wp-content/uploads/sites/1369/2017/01/McAlistersFairviewHgts.jpg │ + 2. │ 60180509 │ https://certapro.com/belleville/wp-content/uploads/sites/1369/2017/01/McAlistersFairviewHgts-686x353.jpg │ + 3. │ 1986089 │ https://www.gannett-cdn.com/-mm-/ceefab710d945bb3432c840e61dce6c3712a7c0a/c=30-0-4392-3280/local/-/media/2017/02/14/FortMyers/FortMyers/636226855169587730-McAlister-s-Exterior-Signage.jpg?width=534&height=401&fit=crop │ + 4. │ 51559839 │ https://img1.mashed.com/img/gallery/how-rich-is-the-mcalisters-deli-ceo-and-whats-the-average-pay-of-its-employees/intro-1619793841.jpg │ + 5. │ 22104014 │ https://www.restaurantmagazine.com/wp-content/uploads/2016/04/Largest-McAlisters-Deli-Franchisee-to-Expand-into-Nebraska.jpg │ + 6. │ 54337236 │ http://www.restaurantnews.com/wp-content/uploads/2015/11/McAlisters-Deli-Giving-Away-Gift-Cards-With-Win-One-Gift-One-Holiday-Promotion.jpg │ + 7. │ 20770867 │ http://www.restaurantnews.com/wp-content/uploads/2016/04/McAlisters-Deli-Aims-to-Attract-New-Franchisees-in-Florida-as-Chain-Enters-New-Markets.jpg │ + 8. │ 22493966 │ https://www.restaurantmagazine.com/wp-content/uploads/2016/06/McAlisters-Deli-Aims-to-Attract-New-Franchisees-in-Columbus-Ohio-as-Chain-Expands-feature.jpg │ + 9. │ 2224351 │ https://holttribe.com/wp-content/uploads/2019/10/60880046-879A-49E4-8E13-1EE75FB24980-900x675.jpeg │ +10. │ 30779663 │ https://www.gannett-cdn.com/presto/2018/10/29/PMUR/685f3e50-cce5-46fb-9a66-acb93f6ea5e5-IMG_6587.jpg?crop=2166,2166,x663,y0&width=80&height=80&fit=bounds │ +11. │ 54939148 │ https://www.priceedwards.com/sites/default/files/styles/staff_property_listing_block/public/for-lease/images/IMG_9674%20%28Custom%29_1.jpg?itok=sa8hrVBT │ +12. │ 95371605 │ http://www.restaurantmagazine.com/wp-content/uploads/2015/08/McAlisters-Deli-Signs-Development-Agreement-with-Kingdom-Foods-to-Grow-in-Southern-Mississippi.jpg │ +13. │ 79564563 │ https://www.restaurantmagazine.com/wp-content/uploads/2016/05/McAlisters-Deli-Aims-to-Attract-New-Franchisees-in-Denver-as-Chain-Expands.jpg │ +14. │ 76429939 │ http://www.restaurantnews.com/wp-content/uploads/2016/08/McAlisters-Deli-Aims-to-Attract-New-Franchisees-in-Pennsylvania-as-Chain-Expands.jpg │ +15. │ 96680635 │ https://img.claz.org/tc/400x320/9w3hll-UQNHGB9WFlhSGAVCWhheBQkeWh5SBAkUWh9SBgsJFxRcBUMNSR4cAQENXhJARwgNTRYcBAtDWh5WRQEJXR5SR1xcFkYKR1tYFkYGR1pVFiVyP0ImaTA │ +16. │ 48716846 │ http://tse2.mm.bing.net/th?id=OIP.nN2qJqGUJs_fVNdTiFyGnQHaEc │ +17. │ 4472333 │ https://sgi.offerscdn.net/i/zdcs-merchants/05lG0FpXPIvsfiHnT3N8FQE.h200.w220.flpad.v22.bffffff.png │ +18. │ 82667887 │ https://irs2.4sqi.net/img/general/200x200/11154479_OEGbrkgWB5fEGrrTkktYvCj1gcdyhZn7TSQSAqN2Yqw.jpg │ +19. │ 57525607 │ https://knoji.com/images/logo/mcalistersdelicom.jpg │ +20. │ 15785896 │ https://www.groupnimb.com/mimg/merimg/mcalister-s-deli_1446088739.jpg │ + └──────────┴───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ + +#highlight-next-line +20 rows in set. Elapsed: 3.968 sec. Processed 100.38 million rows, 320.81 GB (25.30 million rows/s., 80.84 GB/s.) +``` + +请注意查询延迟,以便我们可以将其与 ANN(使用向量索引)的查询延迟进行比较。对于 1 亿行,上述查询在没有向量索引的情况下可能需要几秒钟/几分钟才能完成。 + +### 构建向量相似性索引 {#build-vector-similarity-index} + +运行以下 SQL 在 `laion_5b_100m` 表的 `vector` 列上定义并构建向量相似性索引: + +```sql +ALTER TABLE laion_5b_100m ADD INDEX vector_index vector TYPE vector_similarity('hnsw', 'cosineDistance', 768, 'bf16', 64, 512); + +ALTER TABLE laion_5b_100m MATERIALIZE INDEX vector_index SETTINGS mutations_sync = 2; +``` + +索引创建和搜索的参数以及性能考虑在 [文档](../../engines/table-engines/mergetree-family/annindexes.md) 中描述。上述语句分别使用 64 和 512 作为 HNSW 超参数 `M` 和 `ef_construction` 的值。用户需要通过评估索引构建时间和对应于所选值的搜索结果质量来仔细选择这些参数的最佳值。 + +构建和保存索引可能需要几个小时,具体取决于可用的 CPU 核心数量和存储带宽。 + +### 执行 ANN 搜索 {#perform-ann-search} + +一旦构建了向量相似性索引,向量搜索查询将自动使用该索引: + +```sql title="Query" +SELECT id, url +FROM laion_5b_100m +ORDER BY cosineDistance( vector, (SELECT vector FROM laion_5b_100m WHERE id = 9999) ) ASC +LIMIT 20 + +``` + +第一次将向量索引加载到内存中可能需要几秒钟/几分钟。 + +### 为搜索查询生成嵌入 {#generating-embeddings-for-search-query} + +`LAION 5b` 数据集嵌入向量是使用 `OpenAI CLIP` 模型 `ViT-L/14` 生成的。 + +下面提供了一个示例 Python 脚本,以演示如何使用 `CLIP` API 程序化生成嵌入向量。搜索嵌入向量随后作为参数传递给 `SELECT` 查询中的 [`cosineDistance()`](/sql-reference/functions/distance-functions#cosineDistance) 函数。 + +要安装 `clip` 包,请参阅 [OpenAI GitHub 库](https://github.com/openai/clip)。 + +```python +import torch +import clip +import numpy as np +import sys +import clickhouse_connect + +device = "cuda" if torch.cuda.is_available() else "cpu" +model, preprocess = clip.load("ViT-L/14", device=device) + + +# Search for images that contain both a dog and a cat +text = clip.tokenize(["a dog and a cat"]).to(device) + +with torch.no_grad(): + text_features = model.encode_text(text) + np_arr = text_features.detach().cpu().numpy() + + # Pass ClickHouse credentials here + chclient = clickhouse_connect.get_client() + + params = {'v1': list(np_arr[0])} + result = chclient.query("SELECT id, url FROM laion_5b_100m ORDER BY cosineDistance(vector, %(v1)s) LIMIT 100", + parameters=params) + + # Write the results to a simple HTML page that can be opened in the browser. Some URLs may have become obsolete. + print("") + for r in result.result_rows: + print("') + print("") +``` + +上述搜索的结果如下所示: + + + + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/laion5b.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/laion5b.md.hash new file mode 100644 index 00000000000..6a53890d1a1 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/laion5b.md.hash @@ -0,0 +1 @@ +44526d66e2039e18 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/menus.md b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/menus.md index efc656ba9d8..b21eb21e8af 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/menus.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/menus.md @@ -1,21 +1,22 @@ --- -'description': '数据集包含130万条酒店、餐厅和咖啡馆菜单的历史数据记录,及其菜品和价格。' -'sidebar_label': '纽约公共图书馆 "菜单上有什么?" 数据集' +'description': '数据集包含 130 万条历史数据记录,记录了酒店、餐馆和咖啡馆的菜单及其价格。' +'sidebar_label': '纽约公共图书馆 "菜单上的内容?" 数据集' 'slug': '/getting-started/example-datasets/menus' -'title': '纽约公共图书馆 "菜单上有什么?" 数据集' +'title': '纽约公共图书馆 "菜单上的内容?" 数据集' +'doc_type': 'reference' --- -数据集由纽约公共图书馆创建。它包含酒店、餐馆和咖啡馆菜单上菜肴及其价格的历史数据。 +数据集由纽约公共图书馆创建。它包含酒店、餐馆和咖啡馆菜单的历史数据,包括菜肴及其价格。 -来源: [http://menus.nypl.org/data](http://menus.nypl.org/data) -数据属于公共领域。 +来源: http://menus.nypl.org/data +数据处于公有领域。 -数据来自图书馆的档案,可能不完整,难以进行统计分析。然而,这些数据也非常美味。 -数据量仅为130万个记录,关于菜单中的菜肴——对于ClickHouse来说,这是一个非常小的数据量,但仍然是一个很好的例子。 +数据来自图书馆的档案,可能并不完整,且对统计分析来说较为困难。尽管如此,它也非常美味。 +数据的大小大约为 130 万条关于菜单中的菜肴记录 — 对于 ClickHouse 而言,这是一小部分数据量,但仍然是一个很好的示例。 ## 下载数据集 {#download-dataset} -运行命令: +运行命令: ```bash wget https://s3.amazonaws.com/menusdata.nypl.org/gzips/2021_08_01_07_01_17_data.tgz @@ -26,8 +27,8 @@ md5sum 2021_08_01_07_01_17_data.tgz # Checksum should be equal to: db6126724de939a5481e3160a2d67d15 ``` -如有需要,请将链接替换为 http://menus.nypl.org/data 中的最新链接。 -下载大小约为35 MB。 +如有需要,将链接替换为 http://menus.nypl.org/data 上的最新链接。 +下载大小约为 35 MB。 ## 解压数据集 {#unpack-dataset} @@ -35,13 +36,13 @@ md5sum 2021_08_01_07_01_17_data.tgz tar xvf 2021_08_01_07_01_17_data.tgz ``` -解压后的大小约为150 MB。 +解压后的大小约为 150 MB。 -数据被归一化,包含四个表: -- `Menu` — 关于菜单的信息:餐厅名称、菜单查看日期等。 -- `Dish` — 关于菜肴的信息:菜肴名称及一些特征。 -- `MenuPage` — 关于菜单中页面的信息,因为每个页面属于某个菜单。 -- `MenuItem` — 菜单中的一项。某个菜单页面上的菜肴及其价格:链接到菜肴和菜单页面。 +数据经过规范化,包含四个表: +- `Menu` — 关于菜单的信息:餐厅的名称、菜单出现的日期等。 +- `Dish` — 关于菜肴的信息:菜肴的名称及一些特征。 +- `MenuPage` — 关于菜单页的信息,因为每一页属于某个菜单。 +- `MenuItem` — 菜单的一项。某个菜单页上的菜肴及其价格:指向菜肴和菜单页的链接。 ## 创建表 {#create-tables} @@ -112,7 +113,7 @@ CREATE TABLE menu_item ## 导入数据 {#import-data} -将数据上传到ClickHouse,运行: +将数据上传至 ClickHouse,运行: ```bash clickhouse-client --format_csv_allow_single_quotes 0 --input_format_null_as_default 0 --query "INSERT INTO dish FORMAT CSVWithNames" < Dish.csv @@ -121,20 +122,20 @@ clickhouse-client --format_csv_allow_single_quotes 0 --input_format_null_as_defa clickhouse-client --format_csv_allow_single_quotes 0 --input_format_null_as_default 0 --date_time_input_format best_effort --query "INSERT INTO menu_item FORMAT CSVWithNames" < MenuItem.csv ``` -我们使用 [CSVWithNames](../../interfaces/formats.md#csvwithnames) 格式,因为数据以带有表头的CSV格式表示。 +我们使用 [CSVWithNames](../../interfaces/formats.md#csvwithnames) 格式,因为数据以带表头的 CSV 表示。 -我们禁用 `format_csv_allow_single_quotes`,因为数据字段仅使用双引号,单引号可以在值内部出现,并且不应混淆CSV解析器。 +我们禁用 `format_csv_allow_single_quotes`,因为数据字段仅使用双引号,而单引号可以在值内使用,不应干扰 CSV 解析器。 -我们禁用 [input_format_null_as_default](/operations/settings/formats#input_format_null_as_default),因为我们的数据没有 [NULL](/operations/settings/formats#input_format_null_as_default)。否则,ClickHouse将尝试解析 `\N` 序列,并可能会将其与数据中的 `\` 混淆。 +我们禁用 [input_format_null_as_default](/operations/settings/formats#input_format_null_as_default),因为我们的数据没有 [NULL](/operations/settings/formats#input_format_null_as_default)。否则 ClickHouse 将尝试解析 `\N` 序列,可能会与数据中的 `\` 混淆。 -设置 [date_time_input_format best_effort](/operations/settings/formats#date_time_input_format) 允许以多种格式解析 [DateTime](../../sql-reference/data-types/datetime.md) 字段。例如,没有秒的ISO-8601格式如 '2000-01-01 01:02' 将被识别。没有该设置,仅允许固定的DateTime格式。 +设置 [date_time_input_format best_effort](/operations/settings/formats#date_time_input_format) 允许以多种格式解析 [DateTime](../../sql-reference/data-types/datetime.md) 字段。例如,ISO-8601 格式(没有秒,如 '2000-01-01 01:02')将被识别。没有此设置时,仅允许固定的 DateTime 格式。 -## 反规范化数据 {#denormalize-data} +## 非规范化数据 {#denormalize-data} -数据以 [规范化形式](https://en.wikipedia.org/wiki/Database_normalization#Normal_forms) 展示在多个表中。这意味着如果您想查询菜单项中的菜肴名称,您需要执行 [JOIN](/sql-reference/statements/select/join)。 -对于典型的分析任务,处理预先参与的(pre-JOINed)数据更为高效,以避免每次都进行 `JOIN`。这被称为“反规范化”数据。 +数据以多个表的形式以 [规范化形式](https://en.wikipedia.org/wiki/Database_normalization#Normal_forms) 呈现。这意味着如果要查询菜单项中的菜肴名称,您必须执行 [JOIN](/sql-reference/statements/select/join)。 +对于典型的分析任务,预先联接的数据更高效,以避免每次都进行 `JOIN`。这被称为“非规范化”数据。 -我们将创建一个名为 `menu_item_denorm` 的表,其中将包含所有连接在一起的数据: +我们将创建一个名为 `menu_item_denorm` 的表,包含所有联接的数据: ```sql CREATE TABLE menu_item_denorm @@ -199,7 +200,7 @@ SELECT count() FROM menu_item_denorm; ## 运行一些查询 {#run-queries} -### 菜肴的平均历史价格 {#query-averaged-historical-prices} +### 平均历史菜肴价格 {#query-averaged-historical-prices} 查询: @@ -239,7 +240,7 @@ ORDER BY d ASC; └──────┴─────────┴──────────────────────┴──────────────────────────────┘ ``` -对此请谨慎对待。 +对此要持保留态度。 ### 汉堡价格 {#query-burger-prices} @@ -310,11 +311,11 @@ ORDER BY d ASC; └──────┴─────────┴──────────────────────┴─────────────────────────────┘ ``` -要获取伏特加,我们必须写 `ILIKE '%vodka%'`,这无疑是一个声明。 +要获得伏特加,我们必须写 `ILIKE '%vodka%'`,这绝对构成了一种声明。 ### 鱼子酱 {#query-caviar} -让我们打印鱼子酱的价格。同时让我们打印任何包含鱼子酱的菜肴名称。 +让我们打印鱼子酱的价格。同时打印任何带有鱼子酱的菜肴的名称。 查询: @@ -353,8 +354,8 @@ ORDER BY d ASC; └──────┴─────────┴──────────────────────┴──────────────────────────────────┴─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ ``` -至少他们有鱼子酱和伏特加。非常好。 +至少他们有鱼子酱与伏特加。非常好。 ## 在线游乐场 {#playground} -数据已上传到ClickHouse Playground,[示例](https://sql.clickhouse.com?query_id=KB5KQJJFNBKHE5GBUJCP1B)。 +数据已上传至 ClickHouse Playground,[示例](https://sql.clickhouse.com?query_id=KB5KQJJFNBKHE5GBUJCP1B)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/menus.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/menus.md.hash index 85211099b3c..f132208bda9 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/menus.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/menus.md.hash @@ -1 +1 @@ -e3233ee6f40d6684 +0076962219045c74 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/metrica.md b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/metrica.md index 05883a1c8a4..1e4af3026f1 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/metrica.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/metrica.md @@ -1,20 +1,21 @@ --- -'description': '数据集由两个表组成,包含带有点击和访问的匿名化网络分析数据' +'description': '数据集包含两个表,包含带有点击和访问的匿名化网络分析数据' 'sidebar_label': '网络分析数据' 'slug': '/getting-started/example-datasets/metrica' 'title': '匿名化的网络分析' +'doc_type': 'reference' --- -# 匿名网站分析数据 +# 匿名网页分析数据 -该数据集由两个包含匿名网站分析数据的表构成,分别为点击量(`hits_v1`)和访问量(`visits_v1`)。 +该数据集由两个表组成,包含匿名网页分析数据,包括点击量(`hits_v1`)和访问量(`visits_v1`)。 -这些表可以作为压缩的 `tsv.xz` 文件下载。除了本文档中讨论的示例外,一个扩展版(7.5GB)的 `hits` 表包含1亿行,作为TSV文件可在 [https://datasets.clickhouse.com/hits/tsv/hits_100m_obfuscated_v1.tsv.xz](https://datasets.clickhouse.com/hits/tsv/hits_100m_obfuscated_v1.tsv.xz) 下载。 +表格可以作为压缩的 `tsv.xz` 文件下载。除了本文所使用的示例外,还有一个扩展版本(7.5GB)的 `hits` 表,包含 1 亿行数据,作为 TSV 格式可在 [https://datasets.clickhouse.com/hits/tsv/hits_100m_obfuscated_v1.tsv.xz](https://datasets.clickhouse.com/hits/tsv/hits_100m_obfuscated_v1.tsv.xz) 下载。 ## 下载并导入数据 {#download-and-ingest-the-data} -### 下载点击量压缩TSV文件: {#download-the-hits-compressed-tsv-file} +### 下载点击量压缩TSV文件 {#download-the-hits-compressed-tsv-file} ```bash curl https://datasets.clickhouse.com/hits/tsv/hits_v1.tsv.xz | unxz --threads=`nproc` > hits_v1.tsv @@ -43,7 +44,7 @@ clickhouse-client --query "CREATE TABLE datasets.hits_v1 ( WatchID UInt64, Java clickhouse-client --query="CREATE TABLE default.hits_100m_obfuscated (WatchID UInt64, JavaEnable UInt8, Title String, GoodEvent Int16, EventTime DateTime, EventDate Date, CounterID UInt32, ClientIP UInt32, RegionID UInt32, UserID UInt64, CounterClass Int8, OS UInt8, UserAgent UInt8, URL String, Referer String, Refresh UInt8, RefererCategoryID UInt16, RefererRegionID UInt32, URLCategoryID UInt16, URLRegionID UInt32, ResolutionWidth UInt16, ResolutionHeight UInt16, ResolutionDepth UInt8, FlashMajor UInt8, FlashMinor UInt8, FlashMinor2 String, NetMajor UInt8, NetMinor UInt8, UserAgentMajor UInt16, UserAgentMinor FixedString(2), CookieEnable UInt8, JavascriptEnable UInt8, IsMobile UInt8, MobilePhone UInt8, MobilePhoneModel String, Params String, IPNetworkID UInt32, TraficSourceID Int8, SearchEngineID UInt16, SearchPhrase String, AdvEngineID UInt8, IsArtifical UInt8, WindowClientWidth UInt16, WindowClientHeight UInt16, ClientTimeZone Int16, ClientEventTime DateTime, SilverlightVersion1 UInt8, SilverlightVersion2 UInt8, SilverlightVersion3 UInt32, SilverlightVersion4 UInt16, PageCharset String, CodeVersion UInt32, IsLink UInt8, IsDownload UInt8, IsNotBounce UInt8, FUniqID UInt64, OriginalURL String, HID UInt32, IsOldCounter UInt8, IsEvent UInt8, IsParameter UInt8, DontCountHits UInt8, WithHash UInt8, HitColor FixedString(1), LocalEventTime DateTime, Age UInt8, Sex UInt8, Income UInt8, Interests UInt16, Robotness UInt8, RemoteIP UInt32, WindowName Int32, OpenerName Int32, HistoryLength Int16, BrowserLanguage FixedString(2), BrowserCountry FixedString(2), SocialNetwork String, SocialAction String, HTTPError UInt16, SendTiming UInt32, DNSTiming UInt32, ConnectTiming UInt32, ResponseStartTiming UInt32, ResponseEndTiming UInt32, FetchTiming UInt32, SocialSourceNetworkID UInt8, SocialSourcePage String, ParamPrice Int64, ParamOrderID String, ParamCurrency FixedString(3), ParamCurrencyID UInt16, OpenstatServiceName String, OpenstatCampaignID String, OpenstatAdID String, OpenstatSourceID String, UTMSource String, UTMMedium String, UTMCampaign String, UTMContent String, UTMTerm String, FromTag String, HasGCLID UInt8, RefererHash UInt64, URLHash UInt64, CLID UInt32) ENGINE = MergeTree() PARTITION BY toYYYYMM(EventDate) ORDER BY (CounterID, EventDate, intHash32(UserID)) SAMPLE BY intHash32(UserID) SETTINGS index_granularity = 8192" ``` -### 导入点击量数据: {#import-the-hits-data} +### 导入点击量数据 {#import-the-hits-data} ```bash cat hits_v1.tsv | clickhouse-client --query "INSERT INTO datasets.hits_v1 FORMAT TSV" --max_insert_block_size=100000 @@ -59,7 +60,7 @@ clickhouse-client --query "SELECT COUNT(*) FROM datasets.hits_v1" 8873898 ``` -### 下载访问量压缩TSV文件: {#download-the-visits-compressed-tsv-file} +### 下载访问量压缩TSV文件 {#download-the-visits-compressed-tsv-file} ```bash curl https://datasets.clickhouse.com/visits/tsv/visits_v1.tsv.xz | unxz --threads=`nproc` > visits_v1.tsv @@ -70,7 +71,7 @@ md5sum visits_v1.tsv # Checksum should be equal to: 6dafe1a0f24e59e3fc2d0fed85601de6 ``` -### 创建访问量表 {#create-the-visits-table} +### 创建访问表 {#create-the-visits-table} ```bash clickhouse-client --query "CREATE TABLE datasets.visits_v1 ( CounterID UInt32, StartDate Date, Sign Int8, IsNew UInt8, VisitID UInt64, UserID UInt64, StartTime DateTime, Duration UInt32, UTCStartTime DateTime, PageViews Int32, Hits Int32, IsBounce UInt8, Referer String, StartURL String, RefererDomain String, StartURLDomain String, EndURL String, LinkURL String, IsDownload UInt8, TraficSourceID Int8, SearchEngineID UInt16, SearchPhrase String, AdvEngineID UInt8, PlaceID Int32, RefererCategories Array(UInt16), URLCategories Array(UInt16), URLRegions Array(UInt32), RefererRegions Array(UInt32), IsYandex UInt8, GoalReachesDepth Int32, GoalReachesURL Int32, GoalReachesAny Int32, SocialSourceNetworkID UInt8, SocialSourcePage String, MobilePhoneModel String, ClientEventTime DateTime, RegionID UInt32, ClientIP UInt32, ClientIP6 FixedString(16), RemoteIP UInt32, RemoteIP6 FixedString(16), IPNetworkID UInt32, SilverlightVersion3 UInt32, CodeVersion UInt32, ResolutionWidth UInt16, ResolutionHeight UInt16, UserAgentMajor UInt16, UserAgentMinor UInt16, WindowClientWidth UInt16, WindowClientHeight UInt16, SilverlightVersion2 UInt8, SilverlightVersion4 UInt16, FlashVersion3 UInt16, FlashVersion4 UInt16, ClientTimeZone Int16, OS UInt8, UserAgent UInt8, ResolutionDepth UInt8, FlashMajor UInt8, FlashMinor UInt8, NetMajor UInt8, NetMinor UInt8, MobilePhone UInt8, SilverlightVersion1 UInt8, Age UInt8, Sex UInt8, Income UInt8, JavaEnable UInt8, CookieEnable UInt8, JavascriptEnable UInt8, IsMobile UInt8, BrowserLanguage UInt16, BrowserCountry UInt16, Interests UInt16, Robotness UInt8, GeneralInterests Array(UInt16), Params Array(String), Goals Nested(ID UInt32, Serial UInt32, EventTime DateTime, Price Int64, OrderID String, CurrencyID UInt32), WatchIDs Array(UInt64), ParamSumPrice Int64, ParamCurrency FixedString(3), ParamCurrencyID UInt16, ClickLogID UInt64, ClickEventID Int32, ClickGoodEvent Int32, ClickEventTime DateTime, ClickPriorityID Int32, ClickPhraseID Int32, ClickPageID Int32, ClickPlaceID Int32, ClickTypeID Int32, ClickResourceID Int32, ClickCost UInt32, ClickClientIP UInt32, ClickDomainID UInt32, ClickURL String, ClickAttempt UInt8, ClickOrderID UInt32, ClickBannerID UInt32, ClickMarketCategoryID UInt32, ClickMarketPP UInt32, ClickMarketCategoryName String, ClickMarketPPName String, ClickAWAPSCampaignName String, ClickPageName String, ClickTargetType UInt16, ClickTargetPhraseID UInt64, ClickContextType UInt8, ClickSelectType Int8, ClickOptions String, ClickGroupBannerID Int32, OpenstatServiceName String, OpenstatCampaignID String, OpenstatAdID String, OpenstatSourceID String, UTMSource String, UTMMedium String, UTMCampaign String, UTMContent String, UTMTerm String, FromTag String, HasGCLID UInt8, FirstVisit DateTime, PredLastVisit Date, LastVisit Date, TotalVisits UInt32, TraficSource Nested(ID Int8, SearchEngineID UInt16, AdvEngineID UInt8, PlaceID UInt16, SocialSourceNetworkID UInt8, Domain String, SearchPhrase String, SocialSourcePage String), Attendance FixedString(16), CLID UInt32, YCLID UInt64, NormalizedRefererHash UInt64, SearchPhraseHash UInt64, RefererDomainHash UInt64, NormalizedStartURLHash UInt64, StartURLDomainHash UInt64, NormalizedEndURLHash UInt64, TopLevelDomain UInt64, URLScheme UInt64, OpenstatServiceNameHash UInt64, OpenstatCampaignIDHash UInt64, OpenstatAdIDHash UInt64, OpenstatSourceIDHash UInt64, UTMSourceHash UInt64, UTMMediumHash UInt64, UTMCampaignHash UInt64, UTMContentHash UInt64, UTMTermHash UInt64, FromHash UInt64, WebVisorEnabled UInt8, WebVisorActivity UInt32, ParsedParams Nested(Key1 String, Key2 String, Key3 String, Key4 String, Key5 String, ValueDouble Float64), Market Nested(Type UInt8, GoalID UInt32, OrderID String, OrderPrice Int64, PP UInt32, DirectPlaceID UInt32, DirectOrderID UInt32, DirectBannerID UInt32, GoodID String, GoodName String, GoodQuantity Int32, GoodPrice Int64), IslandID FixedString(16)) ENGINE = CollapsingMergeTree(Sign) PARTITION BY toYYYYMM(StartDate) ORDER BY (CounterID, StartDate, intHash32(UserID), VisitID) SAMPLE BY intHash32(UserID) SETTINGS index_granularity = 8192" @@ -81,7 +82,7 @@ clickhouse-client --query "CREATE TABLE datasets.visits_v1 ( CounterID UInt32, cat visits_v1.tsv | clickhouse-client --query "INSERT INTO datasets.visits_v1 FORMAT TSV" --max_insert_block_size=100000 ``` -验证计数 +验证行数 ```bash clickhouse-client --query "SELECT COUNT(*) FROM datasets.visits_v1" ``` @@ -90,9 +91,9 @@ clickhouse-client --query "SELECT COUNT(*) FROM datasets.visits_v1" 1680609 ``` -## 一个示例 JOIN {#an-example-join} +## 示例 JOIN {#an-example-join} -点击量和访问量数据集用于 ClickHouse 的测试例程,这是测试套件中的一个查询。其余测试在本页末尾的 *下一步* 部分中提到。 +点击量和访问量数据集在 ClickHouse 测试例程中使用,这是测试套件中的一个查询。其余测试在本页底部的 *下一步* 部分中提到。 ```sql clickhouse-client --query "SELECT @@ -134,10 +135,10 @@ FORMAT PrettyCompact" ## 下一步 {#next-steps} -[ClickHouse 中稀疏主索引的实用介绍](/guides/best-practices/sparse-primary-indexes.md) 使用点击量数据集讨论 ClickHouse 索引与传统关系数据库的差异、ClickHouse 如何构建和使用稀疏主索引以及索引最佳实践。 +[ClickHouse 中稀疏主索引的实用介绍](/guides/best-practices/sparse-primary-indexes.md) 使用点击量数据集讨论 ClickHouse 索引与传统关系数据库的区别,以及 ClickHouse 如何构建和使用稀疏主索引及索引最佳实践。 -有关这些表的其他查询示例可以在 ClickHouse 的 [有状态测试](https://github.com/ClickHouse/ClickHouse/blob/d7129855757f38ceec3e4ecc6dafacdabe9b178f/tests/queries/1_stateful/00172_parallel_join.sql) 中找到。 +关于这些表的额外查询示例可以在 ClickHouse 的 [状态测试](https://github.com/ClickHouse/ClickHouse/blob/d7129855757f38ceec3e4ecc6dafacdabe9b178f/tests/queries/1_stateful/00172_parallel_join.sql) 中找到。 :::note -测试套件使用数据库名称 `test`,表名为 `hits` 和 `visits`。 您可以重命名您的数据库和表,或者编辑测试文件中的 SQL。 +测试套件使用数据库名称 `test`,表名为 `hits` 和 `visits`。您可以重命名数据库和表,或编辑测试文件中的 SQL。 ::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/metrica.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/metrica.md.hash index 033755a738b..1bea480d324 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/metrica.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/metrica.md.hash @@ -1 +1 @@ -848d3084c9ed37c8 +8ac379a9b79f9829 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/noaa.md b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/noaa.md index fc9cab6e658..90687ee00fc 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/noaa.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/noaa.md @@ -1,35 +1,36 @@ --- -'description': '过去 120 年的 25 亿行气候数据' +'description': '过去120年的25亿行气候数据' 'sidebar_label': 'NOAA 全球历史气候网络' 'sidebar_position': 1 'slug': '/getting-started/example-datasets/noaa' 'title': 'NOAA 全球历史气候网络' +'doc_type': 'reference' --- -这个数据集包含了过去120年的气象测量数据。每一行代表一个时间点和一个气象站的测量值。 +该数据集包含过去120年的天气测量数据。每行是一个时间点和站点的测量值。 -更准确地说,根据该数据的[来源](https://github.com/awslabs/open-data-docs/tree/main/docs/noaa/noaa-ghcn): +更准确地说,依据[这些数据的来源](https://github.com/awslabs/open-data-docs/tree/main/docs/noaa/noaa-ghcn): -> GHCN-Daily是一个包含全球陆地日常观察的数据集。它包含来自全球陆地气象站的基于站点的测量,其中约三分之二的数据仅用于降水测量(Menne等,2012)。GHCN-Daily是来自多个来源的气候记录的复合体,这些记录经过合并并接受了共同的质量保证审查(Durre等,2010)。该档案包括以下气象要素: +> GHCN-Daily是一个包含全球陆地面积日常观测数据的数据集。它包含来自全世界陆地站点的基于站点的测量,约三分之二是仅用于降水测量(Menne et al., 2012)。GHCN-Daily是来自众多来源的气候记录的组合,这些记录合并在一起并进行了统一的质量保证审查(Durre et al., 2010)。存档包括以下气象要素: - 日最高气温 - 日最低气温 - 观察时的气温 - - 降水量(即雨水、融化的雪) - - 降雪量 + - 降水量(即,雨、水化雪) + - 积雪 - 雪深 - 其他可用的要素 -以下部分简要概述了将此数据集引入ClickHouse所涉及的步骤。如果您有兴趣详细了解每个步骤,我们建议您查看我们标题为["探索庞大的现实世界数据集:ClickHouse中的100多年的天气记录"](https://clickhouse.com/blog/real-world-data-noaa-climate-data)的博客文章。 +下面的部分简要概述了将该数据集导入ClickHouse所涉及的步骤。如果您想了解每一步的详细信息,我们建议您查看我们博客中的文章《["探索庞大的现实世界数据集:100年以上的天气记录在ClickHouse中"](https://clickhouse.com/blog/real-world-data-noaa-climate-data)》。 ## 下载数据 {#downloading-the-data} -- 一个[预准备版本](#pre-prepared-data)的数据,已被清理、重新构造和丰富。该数据覆盖1900年至2022年。 -- [下载原始数据](#original-data)并转换为ClickHouse所需的格式。希望添加自己列的用户可以探索这种方法。 +- [预处理版本](#pre-prepared-data)的数据,已清洗、重构和丰富。该数据覆盖1900年至2022年。 +- [下载原始数据](#original-data)并转换为ClickHouse所需的格式。希望添加自己列的用户可以考虑此方法。 -### 预准备数据 {#pre-prepared-data} +### 预处理数据 {#pre-prepared-data} -更具体地说,已删除未通过Noaa的任何质量保证检查的行。数据也已从每行一个测量值重构为每个气象站ID和日期一行,即。 +更具体地说,已删除未通过Noaa质量检查的行。数据也已从每行一个测量重构为每个站点id和日期一行,即: ```csv "station_id","date","tempAvg","tempMax","tempMin","precipitation","snowfall","snowDepth","percentDailySun","averageWindSpeed","maxWindSpeed","weatherType" @@ -39,11 +40,11 @@ "AEM00041194","2022-08-02",381,424,352,0,0,0,0,0,0,0 ``` -这种结构更容易查询,并确保结果表的稀疏性降低。最后,数据还通过添加经纬度进行了丰富。 +这使得查询更简单,并确保结果表结构不那么稀疏。最后,数据还补充了经度和纬度。 -该数据可在以下S3位置获取。您可以将数据下载到本地文件系统(并使用ClickHouse客户端插入)或直接插入到ClickHouse中(请参阅[从S3插入](#inserting-from-s3))。 +该数据可在以下的S3位置获得。您可以将数据下载到本地文件系统(并使用ClickHouse客户端插入),或直接插入到ClickHouse中(请参见[从S3插入](#inserting-from-s3))。 -下载方式: +要下载: ```bash wget https://datasets-documentation.s3.eu-west-3.amazonaws.com/noaa/noaa_enriched.parquet @@ -51,7 +52,7 @@ wget https://datasets-documentation.s3.eu-west-3.amazonaws.com/noaa/noaa_enriche ### 原始数据 {#original-data} -以下详细说明了下载和转换原始数据以准备加载到ClickHouse中的步骤。 +以下是下载和转换原始数据以准备加载到ClickHouse中的步骤。 #### 下载 {#download} @@ -79,34 +80,34 @@ $ clickhouse-local --query "SELECT * FROM '2021.csv.gz' LIMIT 10" --format Prett └─────────────┴──────────┴──────┴─────┴──────┴──────┴────┴──────┘ ``` -总结[格式文档](https://github.com/awslabs/open-data-docs/tree/main/docs/noaa/noaa-ghcn): - -总结格式文档及其列: - - - 11个字符的站点识别代码。它本身编码了一些有用的信息。 - - YEAR/MONTH/DAY = 8个字符的日期,格式为YYYYMMDD(例如19860529 = 1986年5月29日)。 - - ELEMENT = 4个字符元素类型指示符。实际上是测量类型。虽然有许多测量可用,但我们选择以下: - - PRCP - 降水量(十分之一毫米) - - SNOW - 降雪量(毫米) - - SNWD - 雪深(毫米) - - TMAX - 最高气温(十分之一度C) - - TAVG - 平均气温(十分之一度C) - - TMIN - 最低气温(十分之一度C) - - PSUN - 每日日照百分比(百分比) - - AWND - 平均日风速(十分之一米每秒) - - WSFG - 峰值阵风速(十分之一米每秒) - - WT** = 天气类型,其中**定义天气类型。完整天气类型列表在此。 -- DATA VALUE = 5个字符的数据值,对应于ELEMENT,即测量的值。 -- M-FLAG = 1个字符的测量标记。这有10个可能的值。其中一些值表示数据准确性可疑。我们接受当其设置为"P"时的数据 - 识别为缺失推定为零,因这是只与PRCP、SNOW和SNWD测量相关。 -- Q-FLAG是测量质量标志,有14个可能值。我们只对空值的数据感兴趣,即未通过任何质量保证检查的数据。 -- S-FLAG是观察源标志。对我们的分析没有用,忽略。 -- OBS-TIME = 4个字符的观察时间,格式为小时-分钟(即0700 = 早上7:00)。通常在较旧的数据中不出现。我们在此过程中忽略它。 - -每行一个测量值会导致ClickHouse中稀疏的表结构。我们应该将数据转换为每个时间和气象站一行,每种测量类型及其相关值为一列。首先,我们将数据集限制为那些没有问题的行,即`qFlag`等于空字符串的行。 +总结[格式文档](https://github.com/awslabs/open-data-docs/tree/main/docs/noaa/noaa-ghcn): + +总结格式文档和列顺序: + +- 一个11位的站点识别码。它本身编码了一些有用的信息 +- 年/月/日 = 8位日期,以YYYYMMDD格式表示(例如,19860529 = 1986年5月29日) +- 元素 = 4位元素类型指示符。实际上是测量类型。虽然有许多可用的测量,但我们选择以下: + - PRCP - 降水(十分之一毫米) + - SNOW - 积雪(毫米) + - SNWD - 雪深(毫米) + - TMAX - 最高气温(十分之一摄氏度) + - TAVG - 平均气温(十分之一摄氏度) + - TMIN - 最低气温(十分之一摄氏度) + - PSUN - 日潜在日照百分比(百分比) + - AWND - 日平均风速(十分之一米每秒) + - WSFG - 峰值阵风风速(十分之一米每秒) + - WT** = 天气类型,其中**定义天气类型。天气类型完整列表在此。 + - 数据值 = 5位数据值对应元素,即测量的值。 + - M-FLAG = 1位测量标志。此标志有10个可能值。其中一些值表明数据准确性可疑。我们接受数据时此值为“P” - 被认为缺失且认为为零,因为这仅与PRCP、SNOW和SNWD测量有关。 +- Q-FLAG是测量质量标志,有14个可能值。我们只关注没有值的数据,即没有未通过任何质量保证检查的记录。 +- S-FLAG是观察源标志。对我们的分析没有用,予以忽略。 +- OBS-TIME = 4字符的观察时间,以小时-分钟格式表示(即0700 = 上午7:00)。在较旧数据中通常不存在。我们为我们的目的忽略这一点。 + +每行一个测量会导致ClickHouse中的表结构稀疏。我们应将修改转化为每个时间和站点一行,每种测量类型及其相关值为一列。首先,我们将数据集限制为那些没有问题的行,即`qFlag`等于空字符串的行。 #### 清理数据 {#clean-the-data} -使用[ClickHouse local](https://clickhouse.com/blog/extracting-converting-querying-local-files-with-sql-clickhouse-local),我们可以过滤出代表感兴趣的测量值并满足我们质量要求的行: +使用[ClickHouse local](https://clickhouse.com/blog/extracting-converting-querying-local-files-with-sql-clickhouse-local),我们可以过滤出满足我们关注的测量并符合质量要求的行: ```bash clickhouse local --query "SELECT count() @@ -115,11 +116,11 @@ FROM file('*.csv.gz', CSV, 'station_id String, date String, measurement String, 2679264563 ``` -由于有超过26亿行,由于需要解析所有文件,查询速度较慢。在我们的8核机器上,大约需要160秒。 +在超过26亿行的情况下,由于需要解析所有文件,这不是一个快速的查询。在我们的8核机器上,这大约需要160秒。 -### 透视数据 {#pivot-data} +### 数据透视 {#pivot-data} -虽然每行一个测量值的结构可以与ClickHouse一起使用,但这会不必要地复杂化未来的查询。理想情况下,我们需要每个气象站ID和日期一行,其中每个测量类型及其相关值作为列,即。 +虽然每行的测量结构可以在ClickHouse中使用,但会不必要地复杂化将来的查询。理想情况下,我们需要以每个站点ID和日期一行为单位,每个测量类型及其相关值为一列,即: ```csv "station_id","date","tempAvg","tempMax","tempMin","precipitation","snowfall","snowDepth","percentDailySun","averageWindSpeed","maxWindSpeed","weatherType" @@ -129,7 +130,7 @@ FROM file('*.csv.gz', CSV, 'station_id String, date String, measurement String, "AEM00041194","2022-08-02",381,424,352,0,0,0,0,0,0,0 ``` -使用ClickHouse local和简单的`GROUP BY`,我们可以将数据重新透视为这种结构。为了限制内存开销,我们一次处理一个文件。 +使用ClickHouse local和简单的`GROUP BY`,我们可以将数据重塑为这种结构。为了限制内存开销,我们按文件逐个处理。 ```bash for i in {1900..2022} @@ -153,11 +154,11 @@ ORDER BY station_id, date FORMAT CSV" >> "noaa.csv"; done ``` -该查询生成一个50GB的文件`noaa.csv`。 +此查询生成一个50GB的单个文件`noaa.csv`。 ### 丰富数据 {#enriching-the-data} -数据中除了站点ID外没有位置信息,站点ID包含一个前缀国家代码。理想情况下,每个气象站应该有与之关联的经纬度。为此,NOAA便捷地提供了每个气象站的详细信息,作为单独的[ghcnd-stations.txt](https://github.com/awslabs/open-data-docs/tree/main/docs/noaa/noaa-ghcn#format-of-ghcnd-stationstxt-file)。该文件有[几个列](https://github.com/awslabs/open-data-docs/tree/main/docs/noaa/noaa-ghcn#format-of-ghcnd-stationstxt-file),其中对我们未来的分析有用的有五个:id、纬度、经度、海拔和名称。 +该数据除了站点ID外没有位置信息,该ID包含一个前缀国家代码。理想情况下,每个站点都应有一个相关联的经度和纬度。为此,NOAA便利地提供了各站点的详细信息,作为一个单独的[ghcnd-stations.txt](https://github.com/awslabs/open-data-docs/tree/main/docs/noaa/noaa-ghcn#format-of-ghcnd-stationstxt-file)。该文件有[多个列](https://github.com/awslabs/open-data-docs/tree/main/docs/noaa/noaa-ghcn#format-of-ghcnd-stationstxt-file),其中有五个对我们未来的分析有用:id、纬度、经度、海拔和名称。 ```bash wget http://noaa-ghcn-pds.s3.amazonaws.com/ghcnd-stations.txt @@ -184,7 +185,7 @@ FROM file('noaa.csv', CSV, 'station_id String, date Date32, tempAvg Int32, tempMax Int32, tempMin Int32, precipitation Int32, snowfall Int32, snowDepth Int32, percentDailySun Int8, averageWindSpeed Int32, maxWindSpeed Int32, weatherType UInt8') as noaa LEFT OUTER JOIN stations ON noaa.station_id = stations.id INTO OUTFILE 'noaa_enriched.parquet' FORMAT Parquet SETTINGS format_regexp='^(.{11})\s+(\-?\d{1,2}\.\d{4})\s+(\-?\d{1,3}\.\d{1,4})\s+(\-?\d*\.\d*)\s+(.*)\s+(?:[\d]*)'" ``` -该查询运行需几分钟,生成6.4 GB的文件`noaa_enriched.parquet`。 +该查询运行几分钟并生成一个6.4 GB的文件`noaa_enriched.parquet`。 ## 创建表 {#create-table} @@ -216,15 +217,15 @@ CREATE TABLE noaa ### 从本地文件插入 {#inserting-from-local-file} -可以如下从本地文件插入数据(通过ClickHouse客户端): +数据可以按如下方式从本地文件中插入(通过ClickHouse客户端): ```sql INSERT INTO noaa FROM INFILE '/noaa_enriched.parquet' ``` -其中``代表磁盘上本地文件的完整路径。 +其中``表示本地磁盘上文件的完整路径。 -请参见[这里](https://clickhouse.com/blog/real-world-data-noaa-climate-data#load-the-data)以了解如何加速此加载。 +有关如何加快此加载速度的信息,请参见[这里](https://clickhouse.com/blog/real-world-data-noaa-climate-data#load-the-data)。 ### 从S3插入 {#inserting-from-s3} @@ -233,11 +234,11 @@ INSERT INTO noaa SELECT * FROM s3('https://datasets-documentation.s3.eu-west-3.amazonaws.com/noaa/noaa_enriched.parquet') ``` -有关如何加速这一过程,请参见我们关于[优化大数据加载](https://clickhouse.com/blog/supercharge-your-clickhouse-data-loads-part2)的博客文章。 +有关如何加速此过程,请参见我们博客中关于[优化大数据加载](https://clickhouse.com/blog/supercharge-your-clickhouse-data-loads-part2)的文章。 ## 示例查询 {#sample-queries} -### 史上最高气温 {#highest-temperature-ever} +### 有史以来最高温度 {#highest-temperature-ever} ```sql SELECT @@ -263,11 +264,11 @@ LIMIT 5 5 rows in set. Elapsed: 0.514 sec. Processed 1.06 billion rows, 4.27 GB (2.06 billion rows/s., 8.29 GB/s.) ``` -与[Furnace Creek](https://www.google.com/maps/place/36%C2%B027'00.0%22N+116%C2%B052'00.1%22W/@36.1329666,-116.1104099,8.95z/data=!4m5!3m4!1s0x0:0xf2ed901b860f4446!8m2!3d36.45!4d-116.8667)的[记录](https://en.wikipedia.org/wiki/List_of_weather_records#Highest_temperatures_ever_recorded)一致,截止2023年。 +与[Furnace Creek](https://www.google.com/maps/place/36%C2%B027'00.0%22N+116%C2%B052'00.1%22W/@36.1329666,-116.1104099,8.95z/data=!4m5!3m4!1s0x0:0xf2ed901b860f4446!8m2!3d36.45!4d-116.8667)的[记录文件](https://en.wikipedia.org/wiki/List_of_weather_records#Highest_temperatures_ever_recorded)一致,截至2023年。 ### 最佳滑雪胜地 {#best-ski-resorts} -使用[滑雪胜地列表](https://gist.githubusercontent.com/gingerwizard/dd022f754fd128fdaf270e58fa052e35/raw/622e03c37460f17ef72907afe554cb1c07f91f23/ski_resort_stats.csv)及其各自的位置,我们将这些与过去5年中降雪量最多的前1000个气象站进行联接。通过[geoDistance](/sql-reference/functions/geo/coordinates/#geodistance)对该联接进行排序,并将结果限制在距离小于20公里的情况下,我们选择每个滑雪胜地的首个结果,并按降雪总量进行排序。请注意我们还限制滑雪胜地的海拔在1800米以上,作为良好滑雪条件的广泛指标。 +利用[滑雪胜地列表](https://gist.githubusercontent.com/gingerwizard/dd022f754fd128fdaf270e58fa052e35/raw/622e03c37460f17ef72907afe554cb1c07f91f23/ski_resort_stats.csv)和相应的位置信息,我们将这些信息与过去5年中任意月份最多的前1000个天气站匹配。按[geoDistance](/sql-reference/functions/geo/coordinates/#geodistance)对这些连接进行排序,并将结果限制在距离小于20km的情况下,我们选择每个胜地的顶部结果,并按总雪量进行排序。请注意,我们还限制滑雪胜地的高度在1800米以上,作为良好滑雪条件的宽泛指标。 ```sql SELECT @@ -334,8 +335,8 @@ LIMIT 5 Peak memory usage: 67.66 MiB. ``` -## 感谢 {#credits} +## 鸣谢 {#credits} -我们要感谢全球历史气候网络在准备、清理和分发此数据方面所做的努力。我们对此表示感谢。 +我们要感谢全球历史气候网络在准备、清洗和分发此数据方面的努力。我们非常感谢你们的付出。 -Menne, M.J., I. Durre, B. Korzeniewski, S. McNeal, K. Thomas, X. Yin, S. Anthony, R. Ray, R.S. Vose, B.E.Gleason, 和 T.G. Houston, 2012: 全球历史气候网络 - 每日 (GHCN-Daily), 版本3. [指示小数点后的子集,例如版本3.25]。 NOAA国家环境信息中心。 http://doi.org/10.7289/V5D21VHZ [17/08/2020] +Menne, M.J., I. Durre, B. Korzeniewski, S. McNeal, K. Thomas, X. Yin, S. Anthony, R. Ray, R.S. Vose, B.E.Gleason, 和 T.G. Houston, 2012: 《全球历史气候网络 - 日常数据(GHCN-Daily)》,版本3。[使用小数点后指示所用子集,例如版本3.25]。NOAA国家环境信息中心。http://doi.org/10.7289/V5D21VHZ [17/08/2020] diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/noaa.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/noaa.md.hash index 913d2475b5b..6923c19c32b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/noaa.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/noaa.md.hash @@ -1 +1 @@ -6b760811cbfd7eed +870d7501ef21f5be diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/nyc-taxi.md b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/nyc-taxi.md index 8970c6dd336..4143b323edf 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/nyc-taxi.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/nyc-taxi.md @@ -1,29 +1,31 @@ --- -'description': '自2009年以来,来自纽约市的数十亿次出租车和租赁车辆(Uber,Lyft等)行程的数据' +'description': '自2009年以来,纽约市起源的数十亿次出租车和租赁车辆(Uber,Lyft等)行程的数据' 'sidebar_label': '纽约出租车数据' 'sidebar_position': 2 'slug': '/getting-started/example-datasets/nyc-taxi' 'title': '纽约出租车数据' +'doc_type': 'reference' --- import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; -The New York taxi data sample consists of 3+ billion taxi and for-hire vehicle (Uber, Lyft, etc.) trips originating in New York City since 2009. This getting started guide uses a 3m row sample. +纽约出租车数据样本包含自2009年以来在纽约市出发的超过30亿次出租车和租赁车辆(Uber、Lyft等)行程。此快速入门指南使用3百万行的样本。 -The full dataset can be obtained in a couple of ways: +完整数据集可以通过几种方式获取: -- 直接从 S3 或 GCS 将数据插入到 ClickHouse Cloud +- 直接从 S3 或 GCS 将数据插入 ClickHouse Cloud - 下载准备好的分区 -- 或者用户可以在我们的演示环境中查询完整的数据集,访问 [sql.clickhouse.com](https://sql.clickhouse.com/?query=U0VMRUNUIGNvdW50KCkgRlJPTSBueWNfdGF4aS50cmlwcw&chart=eyJ0eXBlIjoibGluZSIsImNvbmZpZyI6eyJ0aXRsZSI6IlRlbXBlcmF0dXJlIGJ5IGNvdW50cnkgYW5kIHllYXIiLCJ4YXhpcyI6InllYXIiLCJ5YXhpcyI6ImNvdW50KCkiLCJzZXJpZXMiOiJDQVNUKHBhc3Nlbmdlcl9jb3VudCwgJ1N0cmluZycpIn19)。 +- 或者用户可以在我们的演示环境中查询完整数据集,地址是 [sql.clickhouse.com](https://sql.clickhouse.com/?query=U0VMRUNUIGNvdW50KCkgRlJPTSBueWNfdGF4aS50cmlwcw&chart=eyJ0eXBlIjoibGluZSIsImNvbmZpZyI6eyJ0aXRsZSI6IlRlbXBlcmF0dXJlIGJ5IGNvdW50cnkgYW5kIHllYXIiLCJ4YXhpcyI6InllYXIiLCJ5YXhpcyI6ImNvdW50KCkiLCJzZXJpZXMiOiJDQVNUKHBhc3Nlbmdlcl9jb3VudCwgJ1N0cmluZycpIn19)。 :::note -以下示例查询在 **Production** 实例的 ClickHouse Cloud 上执行。有关更多信息,请参见 ["Playground specifications"](/getting-started/playground#specifications)。 +以下示例查询是在 ClickHouse Cloud 的 **生产** 实例上执行的。有关更多信息,请参见 +["Playground specifications"](/getting-started/playground#specifications)。 ::: -## Create the table trips {#create-the-table-trips} +## 创建表 trips {#create-the-table-trips} -开始时创建一个用于出租车行程的表: +首先创建一个用于出租车行程的表: ```sql @@ -52,16 +54,16 @@ ENGINE = MergeTree PRIMARY KEY (pickup_datetime, dropoff_datetime); ``` -## Load the Data directly from Object Storage {#load-the-data-directly-from-object-storage} +## 从对象存储直接加载数据 {#load-the-data-directly-from-object-storage} -用户可以获取一小部分数据(300万行),以便熟悉这些数据。数据以 TSV 文件的形式存储在对象存储中,可以通过 `s3` 表函数轻松流入 ClickHouse Cloud。 +用户可以获取数据的一个小子集(300万行)以熟悉它。这些数据存储在对象存储中的 TSV 文件中,容易通过 `s3` 表函数流入 ClickHouse Cloud。 -相同的数据存储在 S3 和 GCS 中,请选择其中一个选项卡。 +相同的数据同时存储在 S3 和 GCS 中;选择任一标签。 -以下命令将三个文件从 S3 存储桶流入 `trips_small` 表(`{0..2}` 语法是值 0、1 和 2 的通配符): +以下命令将三个文件从 S3 存储桶流入 `trips_small` 表中(`{0..2}` 语法是 0、1 和 2 的通配符): ```sql INSERT INTO nyc_taxi.trips_small @@ -91,7 +93,7 @@ FROM s3( -以下命令将三个文件从 GCS 存储桶流入 `trips` 表(`{0..2}` 语法是值 0、1 和 2 的通配符): +以下命令将三个文件从 GCS 存储桶流入 `trips` 表(`{0..2}` 语法是 0、1 和 2 的通配符): ```sql INSERT INTO nyc_taxi.trips_small @@ -121,18 +123,18 @@ FROM gcs( -## Sample Queries {#sample-queries} +## 示例查询 {#sample-queries} -以下查询是针对上述示例执行的。用户可以在完整的数据集上运行示例查询,访问 [sql.clickhouse.com](https://sql.clickhouse.com/?query=U0VMRUNUIGNvdW50KCkgRlJPTSBueWNfdGF4aS50cmlwcw&chart=eyJ0eXBlIjoibGluZSIsImNvbmZpZyI6eyJ0aXRsZSI6IlRlbXBlcmF0dXJlIGJ5IGNvdW50cnkgYW5kIHllYXIiLCJ4YXhpcyI6InllYXIiLCJ5YXhpcyI6ImNvdW50KCkiLCJzZXJpZXMiOiJDQVNUKHBhc3Nlbmdlcl9jb3VudCwgJ1N0cmluZycpIn19),将下面的查询修改为使用表 `nyc_taxi.trips`。 +以下查询是在上述样本上执行的。用户可以在完整数据集上运行示例查询,地址是 [sql.clickhouse.com](https://sql.clickhouse.com/?query=U0VMRUNUIGNvdW50KCkgRlJPTSBueWNfdGF4aS50cmlwcw&chart=eyJ0eXBlIjoibGluZSIsImNvbmZpZyI6eyJ0aXRsZSI6IlRlbXBlcmF0dXJlIGJ5IGNvdW50cnkgYW5kIHllYXIiLCJ4YXhpcyI6InllYXIiLCJ5YXhpcyI6ImNvdW50KCkiLCJzZXJpZXMiOiJDQVNUKHBhc3Nlbmdlcl9jb3VudCwgJ1N0cmluZycpIn19),并修改下面的查询以使用表 `nyc_taxi.trips`。 -让我们看一下插入了多少行: +让我们看看插入了多少行: ```sql runnable SELECT count() FROM nyc_taxi.trips_small; ``` -每个 TSV 文件大约有 100 万行,三个文件总共有 3,000,317 行。让我们看看几行数据: +每个 TSV 文件约有 1M 行,三份文件总共有 3,000,317 行。让我们看几行数据: ```sql runnable SELECT * @@ -140,9 +142,9 @@ FROM nyc_taxi.trips_small LIMIT 10; ``` -请注意,有关于接送日期、地理坐标、票价细节、纽约社区等的列。 +注意包括接送日期、地理坐标、费用细节、纽约社区等多个列。 -让我们运行几个查询。这个查询显示了接送频率最高的前 10 个社区: +让我们执行几个查询。此查询显示了接送频率最高的前 10 个社区: ```sql runnable SELECT @@ -154,7 +156,7 @@ ORDER BY count DESC LIMIT 10; ``` -这个查询显示了根据乘客人数的平均票价: +此查询显示基于乘客数量的平均费用: ```sql runnable view='chart' chart_config='eyJ0eXBlIjoiYmFyIiwiY29uZmlnIjp7InhheGlzIjoicGFzc2VuZ2VyX2NvdW50IiwieWF4aXMiOiJhdmcodG90YWxfYW1vdW50KSIsInRpdGxlIjoiQXZlcmFnZSBmYXJlIGJ5IHBhc3NlbmdlciBjb3VudCJ9fQ' SELECT @@ -165,7 +167,7 @@ WHERE passenger_count < 10 GROUP BY passenger_count; ``` -这是乘客人数与行程距离之间的相关性: +这是乘客数量与行程距离之间的相关性: ```sql runnable chart_config='eyJ0eXBlIjoiaG9yaXpvbnRhbCBiYXIiLCJjb25maWciOnsieGF4aXMiOiJwYXNzZW5nZXJfY291bnQiLCJ5YXhpcyI6ImRpc3RhbmNlIiwic2VyaWVzIjoiY291bnRyeSIsInRpdGxlIjoiQXZnIGZhcmUgYnkgcGFzc2VuZ2VyIGNvdW50In19' SELECT @@ -177,15 +179,16 @@ GROUP BY passenger_count ORDER BY passenger_count ASC ``` -## Download of Prepared Partitions {#download-of-prepared-partitions} +## 下载准备好的分区 {#download-of-prepared-partitions} :::note -以下步骤提供有关原始数据集的信息,以及将准备好的分区加载到自管理的 ClickHouse 服务器环境的方法。 +以下步骤提供有关原始数据集的信息,以及将准备好的分区加载到自管理 ClickHouse 服务器环境中的方法。 ::: -请参见 https://github.com/toddwschneider/nyc-taxi-data 和 http://tech.marksblogg.com/billion-nyc-taxi-rides-redshift.html 获取数据集的描述和下载说明。 +有关数据集的描述和下载说明,请参见 https://github.com/toddwschneider/nyc-taxi-data 和 http://tech.marksblogg.com/billion-nyc-taxi-rides-redshift.html。 -下载后的结果将在 CSV 文件中生成约 227 GB 的未压缩数据。通过 1 Gbit 连接下载大约需要一个小时(从 s3.amazonaws.com 并行下载可以恢复至少一半的 1 Gbit 通道)。某些文件可能未完全下载。检查文件大小并重新下载任何可疑的文件。 +下载将生成约 227 GB 的未压缩数据,格式为 CSV 文件。通过 1 Gbit 连接的下载大约需要一个小时(从 s3.amazonaws.com 进行并行下载可以恢复至少一半的 1 Gbit 通道)。 +某些文件可能无法完全下载。检查文件大小并重新下载任何可疑文件。 ```bash $ curl -O https://datasets.clickhouse.com/trips_mergetree/partitions/trips_mergetree.tar @@ -201,10 +204,10 @@ $ clickhouse-client --query "select count(*) from datasets.trips_mergetree" ``` :::info -如果您将要运行以下描述的查询,您必须使用完整的表名 `datasets.trips_mergetree`。 +如果您将运行以下描述的查询,您必须使用完整的表名 `datasets.trips_mergetree`。 ::: -## Results on Single Server {#results-on-single-server} +## 单服务器上的结果 {#results-on-single-server} Q1: @@ -243,13 +246,13 @@ ORDER BY year, count(*) DESC; 使用的服务器如下: -两个 Intel(R) Xeon(R) CPU E5-2650 v2 @ 2.60GHz,总共有 16 个物理核心,128 GiB RAM,8x6 TB HD 在硬件 RAID-5 上 +两台 Intel(R) Xeon(R) CPU E5-2650 v2 @ 2.60GHz,共 16 个物理核心,128 GiB RAM,8x6 TB 硬盘的硬件 RAID-5 -执行时间是三次运行中最好的。但是从第二次运行开始,查询从文件系统缓存中读取数据。不再进行其他缓存:数据在每次运行中都被读取和处理。 +执行时间为三次运行中的最佳时间。但是从第二次运行开始,查询从文件系统缓存中读取数据。不再进行进一步的缓存:每次运行均从头读取数据并处理。 -在三个服务器上创建一个表: +在三台服务器上创建一个表: -在每个服务器上: +在每台服务器上: ```sql CREATE TABLE default.trips_mergetree_third ( trip_id UInt32, vendor_id Enum8('1' = 1, '2' = 2, 'CMT' = 3, 'VTS' = 4, 'DDS' = 5, 'B02512' = 10, 'B02598' = 11, 'B02617' = 12, 'B02682' = 13, 'B02764' = 14), pickup_date Date, pickup_datetime DateTime, dropoff_date Date, dropoff_datetime DateTime, store_and_fwd_flag UInt8, rate_code_id UInt8, pickup_longitude Float64, pickup_latitude Float64, dropoff_longitude Float64, dropoff_latitude Float64, passenger_count UInt8, trip_distance Float64, fare_amount Float32, extra Float32, mta_tax Float32, tip_amount Float32, tolls_amount Float32, ehail_fee Float32, improvement_surcharge Float32, total_amount Float32, payment_type_ Enum8('UNK' = 0, 'CSH' = 1, 'CRE' = 2, 'NOC' = 3, 'DIS' = 4), trip_type UInt8, pickup FixedString(25), dropoff FixedString(25), cab_type Enum8('yellow' = 1, 'green' = 2, 'uber' = 3), pickup_nyct2010_gid UInt8, pickup_ctlabel Float32, pickup_borocode UInt8, pickup_boroname Enum8('' = 0, 'Manhattan' = 1, 'Bronx' = 2, 'Brooklyn' = 3, 'Queens' = 4, 'Staten Island' = 5), pickup_ct2010 FixedString(6), pickup_boroct2010 FixedString(7), pickup_cdeligibil Enum8(' ' = 0, 'E' = 1, 'I' = 2), pickup_ntacode FixedString(4), pickup_ntaname Enum16('' = 0, 'Airport' = 1, 'Allerton-Pelham Gardens' = 2, 'Annadale-Huguenot-Prince\'s Bay-Eltingville' = 3, 'Arden Heights' = 4, 'Astoria' = 5, 'Auburndale' = 6, 'Baisley Park' = 7, 'Bath Beach' = 8, 'Battery Park City-Lower Manhattan' = 9, 'Bay Ridge' = 10, 'Bayside-Bayside Hills' = 11, 'Bedford' = 12, 'Bedford Park-Fordham North' = 13, 'Bellerose' = 14, 'Belmont' = 15, 'Bensonhurst East' = 16, 'Bensonhurst West' = 17, 'Borough Park' = 18, 'Breezy Point-Belle Harbor-Rockaway Park-Broad Channel' = 19, 'Briarwood-Jamaica Hills' = 20, 'Brighton Beach' = 21, 'Bronxdale' = 22, 'Brooklyn Heights-Cobble Hill' = 23, 'Brownsville' = 24, 'Bushwick North' = 25, 'Bushwick South' = 26, 'Cambria Heights' = 27, 'Canarsie' = 28, 'Carroll Gardens-Columbia Street-Red Hook' = 29, 'Central Harlem North-Polo Grounds' = 30, 'Central Harlem South' = 31, 'Charleston-Richmond Valley-Tottenville' = 32, 'Chinatown' = 33, 'Claremont-Bathgate' = 34, 'Clinton' = 35, 'Clinton Hill' = 36, 'Co-op City' = 37, 'College Point' = 38, 'Corona' = 39, 'Crotona Park East' = 40, 'Crown Heights North' = 41, 'Crown Heights South' = 42, 'Cypress Hills-City Line' = 43, 'DUMBO-Vinegar Hill-Downtown Brooklyn-Boerum Hill' = 44, 'Douglas Manor-Douglaston-Little Neck' = 45, 'Dyker Heights' = 46, 'East Concourse-Concourse Village' = 47, 'East Elmhurst' = 48, 'East Flatbush-Farragut' = 49, 'East Flushing' = 50, 'East Harlem North' = 51, 'East Harlem South' = 52, 'East New York' = 53, 'East New York (Pennsylvania Ave)' = 54, 'East Tremont' = 55, 'East Village' = 56, 'East Williamsburg' = 57, 'Eastchester-Edenwald-Baychester' = 58, 'Elmhurst' = 59, 'Elmhurst-Maspeth' = 60, 'Erasmus' = 61, 'Far Rockaway-Bayswater' = 62, 'Flatbush' = 63, 'Flatlands' = 64, 'Flushing' = 65, 'Fordham South' = 66, 'Forest Hills' = 67, 'Fort Greene' = 68, 'Fresh Meadows-Utopia' = 69, 'Ft. Totten-Bay Terrace-Clearview' = 70, 'Georgetown-Marine Park-Bergen Beach-Mill Basin' = 71, 'Glen Oaks-Floral Park-New Hyde Park' = 72, 'Glendale' = 73, 'Gramercy' = 74, 'Grasmere-Arrochar-Ft. Wadsworth' = 75, 'Gravesend' = 76, 'Great Kills' = 77, 'Greenpoint' = 78, 'Grymes Hill-Clifton-Fox Hills' = 79, 'Hamilton Heights' = 80, 'Hammels-Arverne-Edgemere' = 81, 'Highbridge' = 82, 'Hollis' = 83, 'Homecrest' = 84, 'Hudson Yards-Chelsea-Flatiron-Union Square' = 85, 'Hunters Point-Sunnyside-West Maspeth' = 86, 'Hunts Point' = 87, 'Jackson Heights' = 88, 'Jamaica' = 89, 'Jamaica Estates-Holliswood' = 90, 'Kensington-Ocean Parkway' = 91, 'Kew Gardens' = 92, 'Kew Gardens Hills' = 93, 'Kingsbridge Heights' = 94, 'Laurelton' = 95, 'Lenox Hill-Roosevelt Island' = 96, 'Lincoln Square' = 97, 'Lindenwood-Howard Beach' = 98, 'Longwood' = 99, 'Lower East Side' = 100, 'Madison' = 101, 'Manhattanville' = 102, 'Marble Hill-Inwood' = 103, 'Mariner\'s Harbor-Arlington-Port Ivory-Graniteville' = 104, 'Maspeth' = 105, 'Melrose South-Mott Haven North' = 106, 'Middle Village' = 107, 'Midtown-Midtown South' = 108, 'Midwood' = 109, 'Morningside Heights' = 110, 'Morrisania-Melrose' = 111, 'Mott Haven-Port Morris' = 112, 'Mount Hope' = 113, 'Murray Hill' = 114, 'Murray Hill-Kips Bay' = 115, 'New Brighton-Silver Lake' = 116, 'New Dorp-Midland Beach' = 117, 'New Springville-Bloomfield-Travis' = 118, 'North Corona' = 119, 'North Riverdale-Fieldston-Riverdale' = 120, 'North Side-South Side' = 121, 'Norwood' = 122, 'Oakland Gardens' = 123, 'Oakwood-Oakwood Beach' = 124, 'Ocean Hill' = 125, 'Ocean Parkway South' = 126, 'Old Astoria' = 127, 'Old Town-Dongan Hills-South Beach' = 128, 'Ozone Park' = 129, 'Park Slope-Gowanus' = 130, 'Parkchester' = 131, 'Pelham Bay-Country Club-City Island' = 132, 'Pelham Parkway' = 133, 'Pomonok-Flushing Heights-Hillcrest' = 134, 'Port Richmond' = 135, 'Prospect Heights' = 136, 'Prospect Lefferts Gardens-Wingate' = 137, 'Queens Village' = 138, 'Queensboro Hill' = 139, 'Queensbridge-Ravenswood-Long Island City' = 140, 'Rego Park' = 141, 'Richmond Hill' = 142, 'Ridgewood' = 143, 'Rikers Island' = 144, 'Rosedale' = 145, 'Rossville-Woodrow' = 146, 'Rugby-Remsen Village' = 147, 'Schuylerville-Throgs Neck-Edgewater Park' = 148, 'Seagate-Coney Island' = 149, 'Sheepshead Bay-Gerritsen Beach-Manhattan Beach' = 150, 'SoHo-TriBeCa-Civic Center-Little Italy' = 151, 'Soundview-Bruckner' = 152, 'Soundview-Castle Hill-Clason Point-Harding Park' = 153, 'South Jamaica' = 154, 'South Ozone Park' = 155, 'Springfield Gardens North' = 156, 'Springfield Gardens South-Brookville' = 157, 'Spuyten Duyvil-Kingsbridge' = 158, 'St. Albans' = 159, 'Stapleton-Rosebank' = 160, 'Starrett City' = 161, 'Steinway' = 162, 'Stuyvesant Heights' = 163, 'Stuyvesant Town-Cooper Village' = 164, 'Sunset Park East' = 165, 'Sunset Park West' = 166, 'Todt Hill-Emerson Hill-Heartland Village-Lighthouse Hill' = 167, 'Turtle Bay-East Midtown' = 168, 'University Heights-Morris Heights' = 169, 'Upper East Side-Carnegie Hill' = 170, 'Upper West Side' = 171, 'Van Cortlandt Village' = 172, 'Van Nest-Morris Park-Westchester Square' = 173, 'Washington Heights North' = 174, 'Washington Heights South' = 175, 'West Brighton' = 176, 'West Concourse' = 177, 'West Farms-Bronx River' = 178, 'West New Brighton-New Brighton-St. George' = 179, 'West Village' = 180, 'Westchester-Unionport' = 181, 'Westerleigh' = 182, 'Whitestone' = 183, 'Williamsbridge-Olinville' = 184, 'Williamsburg' = 185, 'Windsor Terrace' = 186, 'Woodhaven' = 187, 'Woodlawn-Wakefield' = 188, 'Woodside' = 189, 'Yorkville' = 190, 'park-cemetery-etc-Bronx' = 191, 'park-cemetery-etc-Brooklyn' = 192, 'park-cemetery-etc-Manhattan' = 193, 'park-cemetery-etc-Queens' = 194, 'park-cemetery-etc-Staten Island' = 195), pickup_puma UInt16, dropoff_nyct2010_gid UInt8, dropoff_ctlabel Float32, dropoff_borocode UInt8, dropoff_boroname Enum8('' = 0, 'Manhattan' = 1, 'Bronx' = 2, 'Brooklyn' = 3, 'Queens' = 4, 'Staten Island' = 5), dropoff_ct2010 FixedString(6), dropoff_boroct2010 FixedString(7), dropoff_cdeligibil Enum8(' ' = 0, 'E' = 1, 'I' = 2), dropoff_ntacode FixedString(4), dropoff_ntaname Enum16('' = 0, 'Airport' = 1, 'Allerton-Pelham Gardens' = 2, 'Annadale-Huguenot-Prince\'s Bay-Eltingville' = 3, 'Arden Heights' = 4, 'Astoria' = 5, 'Auburndale' = 6, 'Baisley Park' = 7, 'Bath Beach' = 8, 'Battery Park City-Lower Manhattan' = 9, 'Bay Ridge' = 10, 'Bayside-Bayside Hills' = 11, 'Bedford' = 12, 'Bedford Park-Fordham North' = 13, 'Bellerose' = 14, 'Belmont' = 15, 'Bensonhurst East' = 16, 'Bensonhurst West' = 17, 'Borough Park' = 18, 'Breezy Point-Belle Harbor-Rockaway Park-Broad Channel' = 19, 'Briarwood-Jamaica Hills' = 20, 'Brighton Beach' = 21, 'Bronxdale' = 22, 'Brooklyn Heights-Cobble Hill' = 23, 'Brownsville' = 24, 'Bushwick North' = 25, 'Bushwick South' = 26, 'Cambria Heights' = 27, 'Canarsie' = 28, 'Carroll Gardens-Columbia Street-Red Hook' = 29, 'Central Harlem North-Polo Grounds' = 30, 'Central Harlem South' = 31, 'Charleston-Richmond Valley-Tottenville' = 32, 'Chinatown' = 33, 'Claremont-Bathgate' = 34, 'Clinton' = 35, 'Clinton Hill' = 36, 'Co-op City' = 37, 'College Point' = 38, 'Corona' = 39, 'Crotona Park East' = 40, 'Crown Heights North' = 41, 'Crown Heights South' = 42, 'Cypress Hills-City Line' = 43, 'DUMBO-Vinegar Hill-Downtown Brooklyn-Boerum Hill' = 44, 'Douglas Manor-Douglaston-Little Neck' = 45, 'Dyker Heights' = 46, 'East Concourse-Concourse Village' = 47, 'East Elmhurst' = 48, 'East Flatbush-Farragut' = 49, 'East Flushing' = 50, 'East Harlem North' = 51, 'East Harlem South' = 52, 'East New York' = 53, 'East New York (Pennsylvania Ave)' = 54, 'East Tremont' = 55, 'East Village' = 56, 'East Williamsburg' = 57, 'Eastchester-Edenwald-Baychester' = 58, 'Elmhurst' = 59, 'Elmhurst-Maspeth' = 60, 'Erasmus' = 61, 'Far Rockaway-Bayswater' = 62, 'Flatbush' = 63, 'Flatlands' = 64, 'Flushing' = 65, 'Fordham South' = 66, 'Forest Hills' = 67, 'Fort Greene' = 68, 'Fresh Meadows-Utopia' = 69, 'Ft. Totten-Bay Terrace-Clearview' = 70, 'Georgetown-Marine Park-Bergen Beach-Mill Basin' = 71, 'Glen Oaks-Floral Park-New Hyde Park' = 72, 'Glendale' = 73, 'Gramercy' = 74, 'Grasmere-Arrochar-Ft. Wadsworth' = 75, 'Gravesend' = 76, 'Great Kills' = 77, 'Greenpoint' = 78, 'Grymes Hill-Clifton-Fox Hills' = 79, 'Hamilton Heights' = 80, 'Hammels-Arverne-Edgemere' = 81, 'Highbridge' = 82, 'Hollis' = 83, 'Homecrest' = 84, 'Hudson Yards-Chelsea-Flatiron-Union Square' = 85, 'Hunters Point-Sunnyside-West Maspeth' = 86, 'Hunts Point' = 87, 'Jackson Heights' = 88, 'Jamaica' = 89, 'Jamaica Estates-Holliswood' = 90, 'Kensington-Ocean Parkway' = 91, 'Kew Gardens' = 92, 'Kew Gardens Hills' = 93, 'Kingsbridge Heights' = 94, 'Laurelton' = 95, 'Lenox Hill-Roosevelt Island' = 96, 'Lincoln Square' = 97, 'Lindenwood-Howard Beach' = 98, 'Longwood' = 99, 'Lower East Side' = 100, 'Madison' = 101, 'Manhattanville' = 102, 'Marble Hill-Inwood' = 103, 'Mariner\'s Harbor-Arlington-Port Ivory-Graniteville' = 104, 'Maspeth' = 105, 'Melrose South-Mott Haven North' = 106, 'Middle Village' = 107, 'Midtown-Midtown South' = 108, 'Midwood' = 109, 'Morningside Heights' = 110, 'Morrisania-Melrose' = 111, 'Mott Haven-Port Morris' = 112, 'Mount Hope' = 113, 'Murray Hill' = 114, 'Murray Hill-Kips Bay' = 115, 'New Brighton-Silver Lake' = 116, 'New Dorp-Midland Beach' = 117, 'New Springville-Bloomfield-Travis' = 118, 'North Corona' = 119, 'North Riverdale-Fieldston-Riverdale' = 120, 'North Side-South Side' = 121, 'Norwood' = 122, 'Oakland Gardens' = 123, 'Oakwood-Oakwood Beach' = 124, 'Ocean Hill' = 125, 'Ocean Parkway South' = 126, 'Old Astoria' = 127, 'Old Town-Dongan Hills-South Beach' = 128, 'Ozone Park' = 129, 'Park Slope-Gowanus' = 130, 'Parkchester' = 131, 'Pelham Bay-Country Club-City Island' = 132, 'Pelham Parkway' = 133, 'Pomonok-Flushing Heights-Hillcrest' = 134, 'Port Richmond' = 135, 'Prospect Heights' = 136, 'Prospect Lefferts Gardens-Wingate' = 137, 'Queens Village' = 138, 'Queensboro Hill' = 139, 'Queensbridge-Ravenswood-Long Island City' = 140, 'Rego Park' = 141, 'Richmond Hill' = 142, 'Ridgewood' = 143, 'Rikers Island' = 144, 'Rosedale' = 145, 'Rossville-Woodrow' = 146, 'Rugby-Remsen Village' = 147, 'Schuylerville-Throgs Neck-Edgewater Park' = 148, 'Seagate-Coney Island' = 149, 'Sheepshead Bay-Gerritsen Beach-Manhattan Beach' = 150, 'SoHo-TriBeCa-Civic Center-Little Italy' = 151, 'Soundview-Bruckner' = 152, 'Soundview-Castle Hill-Clason Point-Harding Park' = 153, 'South Jamaica' = 154, 'South Ozone Park' = 155, 'Springfield Gardens North' = 156, 'Springfield Gardens South-Brookville' = 157, 'Spuyten Duyvil-Kingsbridge' = 158, 'St. Albans' = 159, 'Stapleton-Rosebank' = 160, 'Starrett City' = 161, 'Steinway' = 162, 'Stuyvesant Heights' = 163, 'Stuyvesant Town-Cooper Village' = 164, 'Sunset Park East' = 165, 'Sunset Park West' = 166, 'Todt Hill-Emerson Hill-Heartland Village-Lighthouse Hill' = 167, 'Turtle Bay-East Midtown' = 168, 'University Heights-Morris Heights' = 169, 'Upper East Side-Carnegie Hill' = 170, 'Upper West Side' = 171, 'Van Cortlandt Village' = 172, 'Van Nest-Morris Park-Westchester Square' = 173, 'Washington Heights North' = 174, 'Washington Heights South' = 175, 'West Brighton' = 176, 'West Concourse' = 177, 'West Farms-Bronx River' = 178, 'West New Brighton-New Brighton-St. George' = 179, 'West Village' = 180, 'Westchester-Unionport' = 181, 'Westerleigh' = 182, 'Whitestone' = 183, 'Williamsbridge-Olinville' = 184, 'Williamsburg' = 185, 'Windsor Terrace' = 186, 'Woodhaven' = 187, 'Woodlawn-Wakefield' = 188, 'Woodside' = 189, 'Yorkville' = 190, 'park-cemetery-etc-Bronx' = 191, 'park-cemetery-etc-Brooklyn' = 192, 'park-cemetery-etc-Manhattan' = 193, 'park-cemetery-etc-Queens' = 194, 'park-cemetery-etc-Staten Island' = 195), dropoff_puma UInt16) ENGINE = MergeTree(pickup_date, pickup_datetime, 8192); @@ -267,7 +270,7 @@ CREATE TABLE trips_mergetree_x3 AS trips_mergetree_third ENGINE = Distributed(pe INSERT INTO trips_mergetree_x3 SELECT * FROM trips_mergetree; ``` -这耗时 2454 秒。 +这需要 2454 秒。 在三台服务器上: @@ -276,21 +279,21 @@ Q2:0.438 秒。 Q3:0.733 秒。 Q4:1.241 秒。 -没有意外,因为查询是线性扩展的。 +这里没有意外,因为查询呈线性增长。 -我们还有来自 140 台服务器集群的结果: +我们还拥有 140 台服务器集群的结果: Q1:0.028 秒。 Q2:0.043 秒。 Q3:0.051 秒。 Q4:0.072 秒。 -在这种情况下,查询处理时间主要受网络延迟的影响。 -我们使用位于不同数据中心的客户端运行查询,而不是集群所在的数据中心,这增加了大约 20 毫秒的延迟。 +在这种情况下,查询处理时间主要由网络延迟决定。 +我们执行了与位于不同数据中心的客户端的查询,这增加了约 20 毫秒的延迟。 -## Summary {#summary} +## 摘要 {#summary} -| servers | Q1 | Q2 | Q3 | Q4 | +| 服务器 | Q1 | Q2 | Q3 | Q4 | |---------|-------|-------|-------|-------| | 1, E5-2650v2 | 0.490 | 1.224 | 2.104 | 3.593 | | 3, E5-2650v2 | 0.212 | 0.438 | 0.733 | 1.241 | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/nyc-taxi.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/nyc-taxi.md.hash index 96d5a17ce11..cb5bc5a469b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/nyc-taxi.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/nyc-taxi.md.hash @@ -1 +1 @@ -cd230b9fe8d9551f +77f48468936f30b5 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/nypd_complaint_data.md b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/nypd_complaint_data.md index 24625ba73dc..af221d269e2 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/nypd_complaint_data.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/nypd_complaint_data.md @@ -1,44 +1,45 @@ --- -'description': '在 5 步中摄取和查询制表符分隔值数据' +'description': '在 5 步中摄取和查询 Tab 分隔值数据' 'sidebar_label': 'NYPD Complaint Data' 'slug': '/getting-started/example-datasets/nypd_complaint_data' 'title': 'NYPD Complaint Data' +'doc_type': 'reference' --- -标签分隔值(TSV)文件是常见的文件格式,可能在文件的第一行包含字段标题。ClickHouse 可以摄取 TSV,并且可以在不摄取文件的情况下查询 TSV。本指南涵盖了这两种情况。如果您需要查询或摄取 CSV 文件,使用相同的技术,只需在格式参数中将 `TSV` 替换为 `CSV`。 +Tab 分隔值,或称 TSV 文件,是一种常见的文件格式,可能会在文件的第一行包含字段标题。ClickHouse 可以导入 TSV 文件,也可以在不导入文件的情况下查询 TSV 文件。本指南涵盖这两种情况。如果您需要查询或导入 CSV 文件,使用相同的技巧,只需在格式参数中将 `TSV` 替换为 `CSV`。 -在本指南中,您将: +在阅读本指南时,您将: - **调查**:查询 TSV 文件的结构和内容。 -- **确定目标 ClickHouse 架构**:选择适当的数据类型,并将现有数据映射到这些类型。 -- **创建一个 ClickHouse 表**。 -- **预处理并流式传输** 数据到 ClickHouse。 +- **确定目标 ClickHouse 模式**:选择适当的数据类型,并将现有数据映射到这些类型。 +- **创建 ClickHouse 表**。 +- **预处理并流式** 将数据发送到 ClickHouse。 - **对 ClickHouse 运行一些查询**。 -本指南使用的数据集来自纽约市开放数据团队,包含有关"报告给纽约市警察局(NYPD)的所有有效重罪、轻罪和违规行为的犯罪数据"的信息。在撰写时,数据文件大小为 166MB,但此文件定期更新。 +本指南使用的数据集来自纽约市开放数据团队,包含有关“向纽约市警察局 (NYPD) 报告的所有有效重罪、轻罪和违规犯罪的数据”。截至撰写时,数据文件大小为 166MB,但会定期更新。 **来源**:[data.cityofnewyork.us](https://data.cityofnewyork.us/Public-Safety/NYPD-Complaint-Data-Current-Year-To-Date-/5uac-w243) **使用条款**:https://www1.nyc.gov/home/terms-of-use.page ## 前提条件 {#prerequisites} -- 访问 [NYPD Complaint Data Current (Year To Date)](https://data.cityofnewyork.us/Public-Safety/NYPD-Complaint-Data-Current-Year-To-Date-/5uac-w243) 页面下载数据集,点击导出按钮,并选择 **TSV for Excel**。 -- 安装 [ClickHouse 服务端和客户端](../../getting-started/install/install.mdx) +- 通过访问 [NYPD Complaint Data Current (Year To Date)](https://data.cityofnewyork.us/Public-Safety/NYPD-Complaint-Data-Current-Year-To-Date-/5uac-w243) 页面,点击导出按钮,并选择 **TSV for Excel** 下载数据集。 +- 安装 [ClickHouse 服务器和客户端](../../getting-started/install/install.mdx) ### 关于本指南中描述的命令的说明 {#a-note-about-the-commands-described-in-this-guide} 本指南中有两种类型的命令: -- 部分命令查询 TSV 文件,这些命令在命令提示符下运行。 -- 其余命令查询 ClickHouse,这些命令在 `clickhouse-client` 或 Play UI 中运行。 +- 一些命令是查询 TSV 文件,这些命令在命令提示符下运行。 +- 其他命令是查询 ClickHouse 的,这些命令在 `clickhouse-client` 或 Play UI 中运行。 :::note -本指南中的示例假设您已将 TSV 文件保存到 `${HOME}/NYPD_Complaint_Data_Current__Year_To_Date_.tsv`,请根据需要调整命令。 +本指南中的示例假定您已将 TSV 文件保存到 `${HOME}/NYPD_Complaint_Data_Current__Year_To_Date_.tsv`,如果需要,请调整命令。 ::: ## 熟悉 TSV 文件 {#familiarize-yourself-with-the-tsv-file} -在开始使用 ClickHouse 数据库之前,请熟悉数据。 +在开始使用 ClickHouse 数据库之前,请先熟悉数据。 ### 查看源 TSV 文件中的字段 {#look-at-the-fields-in-the-source-tsv-file} -这是一个查询 TSV 文件的命令示例,但暂时不要运行它。 +这是查询 TSV 文件的命令示例,但请暂时不要运行它。 ```sh clickhouse-local --query \ "describe file('${HOME}/NYPD_Complaint_Data_Current__Year_To_Date_.tsv', 'TSVWithNames')" @@ -54,9 +55,9 @@ CMPLNT_FR_TM Nullable(String) ``` :::tip -通常情况下,上述命令会告诉您输入数据中的哪些字段是数字,哪些是字符串,哪些是元组。但并不总是如此。因为 ClickHouse 通常用于包含数十亿条记录的数据集,所以为了避免解析数十亿行数据以推断架构,默认情况下只检查 100 行以 [推断架构](/integrations/data-formats/json/inference)。下面的响应可能与您看到的内容不匹配,因为数据集每年更新几次。查看数据字典,您可以看到 CMPLNT_NUM 被指定为文本,而不是数字。通过使用设置 `SETTINGS input_format_max_rows_to_read_for_schema_inference=2000` 来覆盖默认的 100 行推断,您可以更好地了解内容。 +大多数情况下,上述命令会告知您输入数据中哪些字段是数字,哪些是字符串,哪些是元组。但这并不总是如此。由于 ClickHouse 通常用于包含数十亿条记录的数据集,因此默认检查的行数为 100,目的是为了 [推断模式](/integrations/data-formats/json/inference),以避免解析数十亿行来推断模式。下面的响应可能与您看到的不同,因为该数据集每年会更新几次。查看数据字典您会看到,CMPLNT_NUM 被指定为文本,而不是数字。通过将推断的默认值(100 行)更改为 `SETTINGS input_format_max_rows_to_read_for_schema_inference=2000`,您可以更好地了解内容。 -注意:从版本 22.5 开始,推断架构的默认行数为 25,000 行,因此仅在您使用较旧版本或需要超过 25,000 行进行采样时才更改该设置。 +注意:从版本 22.5 开始,推断模式的默认值现在为 25,000 行,因此仅在您使用的是旧版本或需要超过 25,000 行进行抽样时才更改此设置。 ::: 在命令提示符下运行此命令。您将使用 `clickhouse-local` 查询您下载的 TSV 文件中的数据。 @@ -106,11 +107,11 @@ Lat_Lon Tuple(Nullable(Float64), Nullable(Float64)) New Georeferenced Column Nullable(String) ``` -此时,您应检查 TSV 文件中的列是否与 [数据集网页](https://data.cityofnewyork.us/Public-Safety/NYPD-Complaint-Data-Current-Year-To-Date-/5uac-w243) 中“此数据集的列”部分中指定的名称和类型相匹配。数据类型不够具体,所有数字字段都设置为 `Nullable(Float64)`,而其他所有字段都为 `Nullable(String)`。当您创建一个 ClickHouse 表以存储数据时,可以指定更合适和高效的类型。 +此时,您应该检查 TSV 文件中的列是否与 [数据集网页](https://data.cityofnewyork.us/Public-Safety/NYPD-Complaint-Data-Current-Year-To-Date-/5uac-w243) 中的 **Columns in this Dataset** 部分中指定的名称和类型匹配。数据类型不是很具体,所有数字字段都设置为 `Nullable(Float64)`,所有其他字段都是 `Nullable(String)`。当您创建一个 ClickHouse 表来存储数据时,可以指定更适合和更高性能的类型。 -### 确定适当的架构 {#determine-the-proper-schema} +### 确定适当的模式 {#determine-the-proper-schema} -为了确定字段应使用哪些类型,需要了解数据的外观。例如,字段 `JURISDICTION_CODE` 是数字:它应该是 `UInt8`,还是 `Enum`,或者 `Float64` 合适? +为了确定字段应该使用什么类型,有必要了解数据的外观。例如,字段 `JURISDICTION_CODE` 是数字:它应该是 `UInt8`,还是 `Enum`,或者 `Float64` 是否合适? ```sql clickhouse-local --input_format_max_rows_to_read_for_schema_inference=2000 \ @@ -145,11 +146,11 @@ clickhouse-local --input_format_max_rows_to_read_for_schema_inference=2000 \ └───────────────────┴─────────┘ ``` -查询响应显示 `JURISDICTION_CODE` 很适合 `UInt8`。 +查询响应显示,`JURISDICTION_CODE` 很适合使用 `UInt8`。 -同样,查看一些 `String` 字段,看看它们是否适合 `DateTime` 或 [`LowCardinality(String)`](../../sql-reference/data-types/lowcardinality.md) 字段。 +类似地,查看一些 `String` 字段,看看它们是否适合用作 `DateTime` 或 [`LowCardinality(String)`](../../sql-reference/data-types/lowcardinality.md) 字段。 -例如,字段 `PARKS_NM` 被描述为“发生地点 NYC 公园、游乐场或绿地的名称(如适用,州立公园不包括在内)”。纽约市的公园名称可以很好地作为 `LowCardinality(String)` 的候选: +例如,字段 `PARKS_NM` 被描述为“NYC 公园、游乐场或绿地的名称(如果适用,州立公园不包括在内)”。纽约市的公园名称可能是 `LowCardinality(String)` 的好候选: ```sh clickhouse-local --input_format_max_rows_to_read_for_schema_inference=2000 \ @@ -166,7 +167,7 @@ clickhouse-local --input_format_max_rows_to_read_for_schema_inference=2000 \ └─────────────────────┘ ``` -查看一些公园的名称: +看看一些公园名称: ```sql clickhouse-local --input_format_max_rows_to_read_for_schema_inference=2000 \ --query \ @@ -192,10 +193,10 @@ clickhouse-local --input_format_max_rows_to_read_for_schema_inference=2000 \ └────────────────────────────┘ ``` -在撰写时使用的数据集在 `PARK_NM` 列中只有数百个不同的公园和游乐场。根据 [LowCardinality](/sql-reference/data-types/lowcardinality#description) 的建议,保持在 `LowCardinality(String)` 字段中不超过 10,000 个不同字符串,这个数量是比较小的。 +截至撰写时,所使用的数据集中 `PARK_NM` 列只有几百个不同的公园和游乐场。根据 [LowCardinality](/sql-reference/data-types/lowcardinality#description) 的建议,保持在 `LowCardinality(String)` 字段中不超过 10,000 个不同字符串,这个数字很小。 ### DateTime 字段 {#datetime-fields} -根据 [数据集网页](https://data.cityofnewyork.us/Public-Safety/NYPD-Complaint-Data-Current-Year-To-Date-/5uac-w243) 中的"此数据集的列"部分,有报告事件开始和结束的日期和时间字段。查看 `CMPLNT_FR_DT` 和 `CMPLT_TO_DT` 的最小值和最大值,可以了解这些字段是否始终填充: +根据 [数据集网页](https://data.cityofnewyork.us/Public-Safety/NYPD-Complaint-Data-Current-Year-To-Date-/5uac-w243) 中的 **Columns in this Dataset** 部分,存在报告事件开始和结束的日期和时间字段。查看 `CMPLNT_FR_DT` 和 `CMPLT_TO_DT` 的最小值和最大值,可以大致了解这些字段是否总是被填充: ```sh title="CMPLNT_FR_DT" clickhouse-local --input_format_max_rows_to_read_for_schema_inference=2000 \ @@ -259,24 +260,24 @@ FORMAT PrettyCompact" ## 制定计划 {#make-a-plan} -基于上述调查: -- `JURISDICTION_CODE` 应该转换为 `UInt8`。 -- `PARKS_NM` 应该转换为 `LowCardinality(String)` -- `CMPLNT_FR_DT` 和 `CMPLNT_FR_TM` 始终填充(可能默认时间为 `00:00:00`) +根据以上调查: +- `JURISDICTION_CODE` 应该被转换为 `UInt8`。 +- `PARKS_NM` 应该被转换为 `LowCardinality(String)` +- `CMPLNT_FR_DT` 和 `CMPLNT_FR_TM` 始终被填充(可能默认时间为 `00:00:00`) - `CMPLNT_TO_DT` 和 `CMPLNT_TO_TM` 可能为空 -- 日期和时间在源数据中存储在单独字段中 -- 日期格式为 `mm/dd/yyyy` -- 时间格式为 `hh:mm:ss` -- 可将日期和时间串联成 DateTime 类型 -- 一些日期在 1970 年 1 月 1 日之前,这意味着我们需要 64 位 DateTime +- 源中日期和时间存储在不同字段中 +- 日期为 `mm/dd/yyyy` 格式 +- 时间为 `hh:mm:ss` 格式 +- 日期和时间可以合并为 DateTime 类型 +- 存在一些日期在 1970 年 1 月 1 日之前,这意味着我们需要一个 64 位的 DateTime :::note -还有许多更改需要对类型进行,所有这些都可以通过遵循相同的调查步骤来确定。查看字段中的不同字符串数量、数字的最小值和最大值,并做出决策。后面指南中给出的表架构包含许多低基数字符串和无符号整数字段,以及很少的浮点数字类型。 +还有很多类型转换的变化,可以通过遵循相同的调查步骤来确定。查看字段中不同字符串的数量,数字的最小值和最大值,并作出决定。后面指南中给出的表模式有许多低基数字符串和非负整数字段,浮点数很少。 ::: -## 串联日期和时间字段 {#concatenate-the-date-and-time-fields} +## 合并日期和时间字段 {#concatenate-the-date-and-time-fields} -要将日期和时间字段 `CMPLNT_FR_DT` 和 `CMPLNT_FR_TM` 串联成一个可以转换为 `DateTime` 的单一 `String`,选择两个字段并用串联运算符连接:`CMPLNT_FR_DT || ' ' || CMPLNT_FR_TM`。`CMPLNT_TO_DT` 和 `CMPLNT_TO_TM` 字段类似处理。 +要将日期和时间字段 `CMPLNT_FR_DT` 和 `CMPLNT_FR_TM` 合并为一个可以转换为 `DateTime` 的 `String`,选择两个字段并用连接操作符连接:`CMPLNT_FR_DT || ' ' || CMPLNT_FR_TM`。`CMPLNT_TO_DT` 和 `CMPLNT_TO_TM` 字段类似处理。 ```sh clickhouse-local --input_format_max_rows_to_read_for_schema_inference=2000 \ @@ -305,7 +306,7 @@ FORMAT PrettyCompact" ## 将日期和时间字符串转换为 DateTime64 类型 {#convert-the-date-and-time-string-to-a-datetime64-type} -在本指南早期,我们发现 TSV 文件中的日期在 1970 年 1 月 1 日之前,这意味着我们需要 64 位 DateTime 类型的日期。此外,日期还需要从 `MM/DD/YYYY` 转换为 `YYYY/MM/DD` 格式。上述两项都可以通过 [`parseDateTime64BestEffort()`](../../sql-reference/functions/type-conversion-functions.md#parsedatetime64besteffort) 完成。 +在本指南早些时候,我们发现 TSV 文件中有些日期早于 1970 年 1 月 1 日,这意味着我们需要一个 64 位的 DateTime 类型来存储这些日期。这些日期还需要从 `MM/DD/YYYY` 转换为 `YYYY/MM/DD` 格式。这两者都可以通过 [`parseDateTime64BestEffort()`](../../sql-reference/functions/type-conversion-functions.md#parsedatetime64besteffort) 实现。 ```sh clickhouse-local --input_format_max_rows_to_read_for_schema_inference=2000 \ @@ -320,7 +321,7 @@ LIMIT 25 FORMAT PrettyCompact" ``` -上面第 2 行和第 3 行包含了上一步的串联,而第 4 行和第 5 行则将字符串解析为 `DateTime64`。当投诉结束时间未必存在时,使用 `parseDateTime64BestEffortOrNull`。 +上述第 2 行和第 3 行包含了上一步的连接,第 4 行和第 5 行将字符串解析为 `DateTime64`。由于投诉结束时间不一定存在,因此使用 `parseDateTime64BestEffortOrNull`。 结果: ```response @@ -353,30 +354,29 @@ FORMAT PrettyCompact" └─────────────────────────┴─────────────────────────┘ ``` :::note -上面显示为 `1925` 的日期来自数据中的错误。在原始数据中有几个记录,其日期在 `1019` 年至 `1022` 年之间,应该被记录为 `2019` 年至 `2022` 年。它们被存储为 1925 年 1 月 1 日,因为这是 64 位 DateTime 可存储的最早日期。 +上述日期 `1925` 是由于数据中的错误而显示的。原始数据中有几个记录的日期在 `1019` 到 `1022` 年之间,实际上应该为 `2019` 到 `2022`。它们被存储为 1925 年 1 月 1 日,因为这是 64 位 DateTime 可以表示的最早日期。 ::: ## 创建表 {#create-a-table} -上述对列数据类型的决策在下面的表架构中反映。我们还需要决定表用于 `ORDER BY` 和 `PRIMARY KEY` 的列。必须至少指定 `ORDER BY` 或 `PRIMARY KEY` 之一。以下是决定包含哪些列的 `ORDER BY` 的一些指导,并在本文档末尾的 *下一步* 部分中提供更多信息。 +以上对列的数据类型的决策反映在下面的表架构中。我们还需要决定用于表的 `ORDER BY` 和 `PRIMARY KEY`。`ORDER BY` 或 `PRIMARY KEY` 中至少需要指定其中之一。以下是确定要包含在 `ORDER BY` 中的字段的一些指导方针,更多信息请参见本文件末尾的 *Next Steps* 部分。 -### Order By 和 Primary Key 子句 {#order-by-and-primary-key-clauses} +### `ORDER BY` 和 `PRIMARY KEY` 子句 {#order-by-and-primary-key-clauses} -- `ORDER BY` 元组应包含在查询过滤器中使用的字段 -- 为了最大化磁盘压缩,`ORDER BY` 元组应按升序基数排序 -- 如果存在,`PRIMARY KEY` 元组必须是 `ORDER BY` 元组的一个子集 -- 如果只指定 `ORDER BY`,则将使用相同的元组作为 `PRIMARY KEY` -- 如果指定了 `PRIMARY KEY` 元组,则将使用 `PRIMARY KEY` 元组创建主键索引,否则使用 `ORDER BY` 元组 -- `PRIMARY KEY` 索引保存在主内存中 +- `ORDER BY` 元组应包括用于查询过滤器的字段 +- 为了最大化磁盘上的压缩,`ORDER BY` 元组应按升序基数排序 +- 如果存在,则 `PRIMARY KEY` 元组必须是 `ORDER BY` 元组的一个子集 +- 如果仅指定 `ORDER BY`,则使用相同的元组作为 `PRIMARY KEY` +- 如果指定了 `PRIMARY KEY`,则创建时使用 `PRIMARY KEY` 元组;否则,使用 `ORDER BY` 元组 +- `PRIMARY KEY` 索引存储在主内存中 -查看数据集和通过查询可能回答的问题,我们可能决定查看随着时间推移在纽约市五个区报告的犯罪类型。这些字段可能包括在 `ORDER BY` 中: - -| 列 | 描述(来自数据字典) | -| ----------- | --------------------------------------------------- | -| OFNS_DESC | 对应关键代码的罪犯描述 | -| RPT_DT | 向警方报告事件的日期 | -| BORO_NM | 事件发生区的名称 | +查看数据集以及可能通过查询回答的问题,我们可能会决定查看纽约市五个区内随时间变化的犯罪类型。这些字段可能会被包含在 `ORDER BY` 中: +| 列 | 描述(来自数据字典) | +| --------- | ------------------------------------------ | +| OFNS_DESC | 与关键代码对应的罪犯描述 | +| RPT_DT | 事件向警方报告的日期 | +| BORO_NM | 事件发生的辖区名称 | 查询 TSV 文件以获取这三个候选列的基数: @@ -397,19 +397,19 @@ clickhouse-local --input_format_max_rows_to_read_for_schema_inference=2000 \ │ 60.00 │ 306.00 │ 6.00 │ └───────────────────────┴────────────────────┴─────────────────────┘ ``` -按照基数排序,`ORDER BY` 变为: +按基数排序,`ORDER BY` 变为: ```sql ORDER BY ( BORO_NM, OFNS_DESC, RPT_DT ) ``` :::note -下表将使用更易于阅读的列名,上面的名称将映射到 +下表将使用更易读的列名,以上名称将映射到 ```sql ORDER BY ( borough, offense_description, date_reported ) ``` ::: -将数据类型变化与 `ORDER BY` 元组结合起来,得到以下表结构: +综合数据类型更改和 `ORDER BY` 元组,得到此表结构: ```sql CREATE TABLE NYPD_Complaint ( @@ -449,9 +449,9 @@ CREATE TABLE NYPD_Complaint ( ORDER BY ( borough, offense_description, date_reported ) ``` -### 找到表的主键 {#finding-the-primary-key-of-a-table} +### 查找表的主键 {#finding-the-primary-key-of-a-table} -ClickHouse `system` 数据库,尤其是 `system.table` 中包含您刚刚创建的表的所有信息。此查询显示 `ORDER BY`(排序键)和 `PRIMARY KEY`: +ClickHouse 的 `system` 数据库,特别是 `system.table` 中包含您刚创建的表的所有信息。此查询显示 `ORDER BY`(排序键)和 `PRIMARY KEY`: ```sql SELECT partition_key, @@ -479,12 +479,12 @@ table: NYPD_Complaint ## 预处理和导入数据 {#preprocess-import-data} -我们将使用 `clickhouse-local` 工具进行数据预处理,并使用 `clickhouse-client` 进行上传。 +我们将使用 `clickhouse-local` 工具进行数据预处理,并使用 `clickhouse-client` 上传它。 -### 使用的 `clickhouse-local` 参数 {#clickhouse-local-arguments-used} +### `clickhouse-local` 使用的参数 {#clickhouse-local-arguments-used} :::tip -`table='input'` 在下面的 clickhouse-local 参数中出现。 clickhouse-local 获取提供的输入(`cat ${HOME}/NYPD_Complaint_Data_Current__Year_To_Date_.tsv`)并将输入插入表中。默认情况下,表名为 `table`。在本指南中,表名设置为 `input` 以使数据流更清晰。最后一参数是选择来自表的查询(`FROM input`),然后将其传送给 `clickhouse-client` 来填充表 `NYPD_Complaint`。 +`table='input'` 出现在下面的 clickhouse-local 参数中。clickhouse-local 取提供的输入(`cat ${HOME}/NYPD_Complaint_Data_Current__Year_To_Date_.tsv`)并将其插入一个表中。默认情况下,表的名称为 `table`。在本指南中,表的名称设置为 `input`,以使数据流更清晰。clickhouse-local 的最后一个参数是一个从表中选择的查询(`FROM input`),然后将其传递给 `clickhouse-client` 以填充表 `NYPD_Complaint`。 ::: ```sql @@ -534,7 +534,7 @@ cat ${HOME}/NYPD_Complaint_Data_Current__Year_To_Date_.tsv \ ## 验证数据 {#validate-data} :::note -数据集每年变化一次或多次,您的数量可能与本文件中的内容不匹配。 +数据集每年会发生一次或多次变化,您的计数可能与本文件中的数据不匹配。 ::: 查询: @@ -554,7 +554,7 @@ FROM NYPD_Complaint 1 row in set. Elapsed: 0.001 sec. ``` -ClickHouse 中数据集的大小仅为原始 TSV 文件的 12%,将原始 TSV 文件的大小与表的大小进行比较: +ClickHouse 中数据集的大小仅为原始 TSV 文件的 12%,请比较原始 TSV 文件的大小与表的大小: 查询: @@ -571,7 +571,6 @@ WHERE name = 'NYPD_Complaint' └─────────────────────────────────┘ ``` - ## 运行一些查询 {#run-queries} ### 查询 1. 按月比较投诉数量 {#query-1-compare-the-number-of-complaints-by-month} @@ -610,7 +609,7 @@ Query id: 7fbd4244-b32a-4acf-b1f3-c3aa198e74d9 12 rows in set. Elapsed: 0.006 sec. Processed 208.99 thousand rows, 417.99 KB (37.48 million rows/s., 74.96 MB/s.) ``` -### 查询 2. 按区比较投诉总数 {#query-2-compare-total-number-of-complaints-by-borough} +### 查询 2. 按辖区比较总投诉数量 {#query-2-compare-total-number-of-complaints-by-borough} 查询: @@ -642,4 +641,4 @@ Query id: 8cdcdfd4-908f-4be0-99e3-265722a2ab8d ## 下一步 {#next-steps} -[ClickHouse 中稀疏主索引的实用介绍](/guides/best-practices/sparse-primary-indexes.md) 讨论了 ClickHouse 索引与传统关系数据库的不同之处,ClickHouse 如何构建和使用稀疏主索引,以及索引的最佳实践。 +[A Practical Introduction to Sparse Primary Indexes in ClickHouse](/guides/best-practices/sparse-primary-indexes.md) 讨论了 ClickHouse 索引与传统关系数据库之间的差异,ClickHouse 如何构建和使用稀疏主索引,以及索引的最佳实践。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/nypd_complaint_data.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/nypd_complaint_data.md.hash index cbb907970ea..4d418034c23 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/nypd_complaint_data.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/nypd_complaint_data.md.hash @@ -1 +1 @@ -0596da80b81c6b77 +04e7d44ba4572f21 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/ontime.md b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/ontime.md index fcc27467ea7..8c8e5c69fa5 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/ontime.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/ontime.md @@ -3,9 +3,10 @@ 'sidebar_label': 'OnTime 航空公司航班数据' 'slug': '/getting-started/example-datasets/ontime' 'title': 'OnTime' +'doc_type': 'reference' --- -这个数据集包含来自运输统计局的数据。 +这个数据集包含来自交通统计局的数据。 ## 创建表 {#creating-a-table} @@ -139,7 +140,7 @@ wget --no-check-certificate --continue https://transtats.bts.gov/PREZIP/On_Time_ ls -1 *.zip | xargs -I{} -P $(nproc) bash -c "echo {}; unzip -cq {} '*.csv' | sed 's/\.00//g' | clickhouse-client --input_format_csv_empty_as_default 1 --query='INSERT INTO ontime FORMAT CSVWithNames'" ``` -(如果您的服务器内存不足或出现其他问题,请移除 `-P $(nproc)` 部分) +(如果您的服务器内存不足或出现其他问题,请删除 `-P $(nproc)` 部分) ## 从保存的副本导入 {#import-from-a-saved-copy} @@ -165,7 +166,7 @@ FROM ); ``` -Q1. 2000年至2008年每天的航班数量 +Q1. 2000年到2008年间每日航班数量 ```sql SELECT DayOfWeek, count(*) AS c @@ -175,7 +176,7 @@ GROUP BY DayOfWeek ORDER BY c DESC; ``` -Q2. 2000-2008年按周几分组延误超过10分钟的航班数量 +Q2. 2000-2008年间,延误超过10分钟的航班数量,按周几分组 ```sql SELECT DayOfWeek, count(*) AS c @@ -185,7 +186,7 @@ GROUP BY DayOfWeek ORDER BY c DESC; ``` -Q3. 2000-2008年按机场分组的延误数量 +Q3. 2000-2008年间,按机场分类的延误数量 ```sql SELECT Origin, count(*) AS c @@ -196,7 +197,7 @@ ORDER BY c DESC LIMIT 10; ``` -Q4. 2007年按航空公司分组的延误数量 +Q4. 2007年按航空公司分类的延误数量 ```sql SELECT IATA_CODE_Reporting_Airline AS Carrier, count(*) @@ -206,10 +207,10 @@ GROUP BY Carrier ORDER BY count(*) DESC; ``` -Q5. 2007年按航空公司分组的延误百分比 +Q5. 2007年按航空公司分类的延误比例 ```sql -SELECT Carrier, c, c2, c*100/c2 as c3 +SELECT Carrier, c, c2, c*100/c2 AS c3 FROM ( SELECT @@ -232,7 +233,7 @@ JOIN ORDER BY c3 DESC; ``` -同一查询的更好版本: +相同查询的更好版本: ```sql SELECT IATA_CODE_Reporting_Airline AS Carrier, avg(DepDelay>10)*100 AS c3 @@ -242,10 +243,10 @@ GROUP BY Carrier ORDER BY c3 DESC ``` -Q6. 对于更广泛年份范围(2000-2008)的先前请求 +Q6. 之前请求的更广泛的年份范围,2000-2008 ```sql -SELECT Carrier, c, c2, c*100/c2 as c3 +SELECT Carrier, c, c2, c*100/c2 AS c3 FROM ( SELECT @@ -268,7 +269,7 @@ JOIN ORDER BY c3 DESC; ``` -同一查询的更好版本: +相同查询的更好版本: ```sql SELECT IATA_CODE_Reporting_Airline AS Carrier, avg(DepDelay>10)*100 AS c3 @@ -278,31 +279,31 @@ GROUP BY Carrier ORDER BY c3 DESC; ``` -Q7. 按年份划分的延误超过10分钟的航班百分比 +Q7. 按年份分类延误超过10分钟的航班比例 ```sql SELECT Year, c1/c2 FROM ( - select + SELECT Year, - count(*)*100 as c1 - from ontime + count(*)*100 AS c1 + FROM ontime WHERE DepDelay>10 GROUP BY Year ) q JOIN ( - select + SELECT Year, - count(*) as c2 - from ontime + count(*) AS c2 + FROM ontime GROUP BY Year ) qq USING (Year) ORDER BY Year; ``` -同一查询的更好版本: +相同查询的更好版本: ```sql SELECT Year, avg(DepDelay>10)*100 @@ -311,12 +312,12 @@ GROUP BY Year ORDER BY Year; ``` -Q8. 按连接城市数量划分的不同时期的最热门目的地 +Q8. 按直接连接城市数量分类的最热门目的地,适用于各个年份范围 ```sql SELECT DestCityName, uniqExact(OriginCityName) AS u FROM ontime -WHERE Year >= 2000 and Year <= 2010 +WHERE Year >= 2000 AND Year <= 2010 GROUP BY DestCityName ORDER BY u DESC LIMIT 10; ``` @@ -341,9 +342,9 @@ WHERE DayOfWeek NOT IN (6,7) AND OriginState NOT IN ('AK', 'HI', 'PR', 'VI') AND DestState NOT IN ('AK', 'HI', 'PR', 'VI') AND FlightDate < '2010-01-01' -GROUP by Carrier -HAVING cnt>100000 and max(Year)>1990 -ORDER by rate DESC +GROUP BY Carrier +HAVING cnt>100000 AND max(Year)>1990 +ORDER BY rate DESC LIMIT 1000; ``` @@ -385,9 +386,9 @@ ORDER BY c DESC LIMIT 10; ``` -您还可以在 Playground 中玩数据,[示例](https://sql.clickhouse.com?query_id=M4FSVBVMSHY98NKCQP8N4K)。 +您还可以在 Playground 中玩数据, [示例](https://sql.clickhouse.com?query_id=M4FSVBVMSHY98NKCQP8N4K)。 -这个性能测试是由 Vadim Tkachenko 创建的。请参阅: +这个性能测试由 Vadim Tkachenko 创建。详细信息请参见: - https://www.percona.com/blog/2009/10/02/analyzing-air-traffic-performance-with-infobright-and-monetdb/ - https://www.percona.com/blog/2009/10/26/air-traffic-queries-in-luciddb/ diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/ontime.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/ontime.md.hash index f32f97dc2fc..a6fdfe602bc 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/ontime.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/ontime.md.hash @@ -1 +1 @@ -9a929aafea10d051 +ccebeca99a8fb712 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/opensky.md b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/opensky.md deleted file mode 100644 index dbcc25297e2..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/opensky.md +++ /dev/null @@ -1,416 +0,0 @@ ---- -'description': '此数据集中的数据来源于完整的 OpenSky 数据集并经过清洗,旨在展示 COVID-19 大流行期间航班的变化。' -'sidebar_label': '航班数据' -'slug': '/getting-started/example-datasets/opensky' -'title': '众包的航班数据来自 The OpenSky Network 2020' ---- - -该数据集中的数据来源于完整的OpenSky数据集,并经过清洗,旨在展示COVID-19大流行期间航空交通的发展。数据涵盖自2019年1月1日起,网络中超过2500名成员所见的所有航班。直到COVID-19大流行结束,数据集会定期添加更多数据。 - -来源: https://zenodo.org/records/5092942 - -Martin Strohmeier, Xavier Olive, Jannis Luebbe, Matthias Schaefer, 和 Vincent Lenders -“2019–2020年OpenSky网络的众包航空交通数据” -《地球系统科学数据》13(2), 2021 -https://doi.org/10.5194/essd-13-357-2021 - -## 下载数据集 {#download-dataset} - -运行命令: - -```bash -wget -O- https://zenodo.org/records/5092942 | grep -oE 'https://zenodo.org/records/5092942/files/flightlist_[0-9]+_[0-9]+\.csv\.gz' | xargs wget -``` - -在良好的互联网连接下,下载大约需要2分钟。共有30个文件,总大小为4.3 GB。 - -## 创建表 {#create-table} - -```sql -CREATE TABLE opensky -( - callsign String, - number String, - icao24 String, - registration String, - typecode String, - origin String, - destination String, - firstseen DateTime, - lastseen DateTime, - day DateTime, - latitude_1 Float64, - longitude_1 Float64, - altitude_1 Float64, - latitude_2 Float64, - longitude_2 Float64, - altitude_2 Float64 -) ENGINE = MergeTree ORDER BY (origin, destination, callsign); -``` - -## 导入数据 {#import-data} - -以并行方式将数据上传到ClickHouse: - -```bash -ls -1 flightlist_*.csv.gz | xargs -P100 -I{} bash -c 'gzip -c -d "{}" | clickhouse-client --date_time_input_format best_effort --query "INSERT INTO opensky FORMAT CSVWithNames"' -``` - -- 在这里,我们将文件列表(`ls -1 flightlist_*.csv.gz`)传递给`xargs`进行并行处理。 -`xargs -P100`指定最多使用100个并行工作者,但由于我们只有30个文件,因此工作者的数量将只有30。 -- 对于每个文件,`xargs`将使用`bash -c`运行一个脚本。该脚本有以 `{}` 形式的替代,`xargs`命令将用文件名替代它(我们在调用`xargs`时使用了 `-I{}`)。 -- 脚本将解压文件(`gzip -c -d "{}")到标准输出(`-c`参数),输出将被重定向到`clickhouse-client`。 -- 我们还要求解析[DateTime](../../sql-reference/data-types/datetime.md)字段,使用扩展解析器 ([--date_time_input_format best_effort](/operations/settings/formats#date_time_input_format)) 识别带时区偏移的ISO-8601格式。 - -最后,`clickhouse-client`将执行插入。它将以[CSVWithNames](../../interfaces/formats.md#csvwithnames)格式读取输入数据。 - -并行上传耗时24秒。 - -如果你不喜欢并行上传,这里是顺序变体: - -```bash -for file in flightlist_*.csv.gz; do gzip -c -d "$file" | clickhouse-client --date_time_input_format best_effort --query "INSERT INTO opensky FORMAT CSVWithNames"; done -``` - -## 验证数据 {#validate-data} - -查询: - -```sql -SELECT count() FROM opensky; -``` - -结果: - -```text -┌──count()─┐ -│ 66010819 │ -└──────────┘ -``` - -ClickHouse中数据集的大小仅为2.66 GiB,请确认。 - -查询: - -```sql -SELECT formatReadableSize(total_bytes) FROM system.tables WHERE name = 'opensky'; -``` - -结果: - -```text -┌─formatReadableSize(total_bytes)─┐ -│ 2.66 GiB │ -└─────────────────────────────────┘ -``` - -## 运行一些查询 {#run-queries} - -总旅行距离为680亿公里。 - -查询: - -```sql -SELECT formatReadableQuantity(sum(geoDistance(longitude_1, latitude_1, longitude_2, latitude_2)) / 1000) FROM opensky; -``` - -结果: - -```text -┌─formatReadableQuantity(divide(sum(geoDistance(longitude_1, latitude_1, longitude_2, latitude_2)), 1000))─┐ -│ 68.72 billion │ -└──────────────────────────────────────────────────────────────────────────────────────────────────────────┘ -``` - -平均航班距离约为1000公里。 - -查询: - -```sql -SELECT round(avg(geoDistance(longitude_1, latitude_1, longitude_2, latitude_2)), 2) FROM opensky; -``` - -结果: - -```text - ┌─round(avg(geoDistance(longitude_1, latitude_1, longitude_2, latitude_2)), 2)─┐ -1. │ 1041090.67 │ -- 1.04 million - └──────────────────────────────────────────────────────────────────────────────┘ -``` - -### 最繁忙的起始机场及平均距离 {#busy-airports-average-distance} - -查询: - -```sql -SELECT - origin, - count(), - round(avg(geoDistance(longitude_1, latitude_1, longitude_2, latitude_2))) AS distance, - bar(distance, 0, 10000000, 100) AS bar -FROM opensky -WHERE origin != '' -GROUP BY origin -ORDER BY count() DESC -LIMIT 100; -``` - -结果: - -```text - ┌─origin─┬─count()─┬─distance─┬─bar────────────────────────────────────┐ - 1. │ KORD │ 745007 │ 1546108 │ ███████████████▍ │ - 2. │ KDFW │ 696702 │ 1358721 │ █████████████▌ │ - 3. │ KATL │ 667286 │ 1169661 │ ███████████▋ │ - 4. │ KDEN │ 582709 │ 1287742 │ ████████████▊ │ - 5. │ KLAX │ 581952 │ 2628393 │ ██████████████████████████▎ │ - 6. │ KLAS │ 447789 │ 1336967 │ █████████████▎ │ - 7. │ KPHX │ 428558 │ 1345635 │ █████████████▍ │ - 8. │ KSEA │ 412592 │ 1757317 │ █████████████████▌ │ - 9. │ KCLT │ 404612 │ 880355 │ ████████▋ │ - 10. │ VIDP │ 363074 │ 1445052 │ ██████████████▍ │ - 11. │ EDDF │ 362643 │ 2263960 │ ██████████████████████▋ │ - 12. │ KSFO │ 361869 │ 2445732 │ ████████████████████████▍ │ - 13. │ KJFK │ 349232 │ 2996550 │ █████████████████████████████▊ │ - 14. │ KMSP │ 346010 │ 1287328 │ ████████████▋ │ - 15. │ LFPG │ 344748 │ 2206203 │ ██████████████████████ │ - 16. │ EGLL │ 341370 │ 3216593 │ ████████████████████████████████▏ │ - 17. │ EHAM │ 340272 │ 2116425 │ █████████████████████▏ │ - 18. │ KEWR │ 337696 │ 1826545 │ ██████████████████▎ │ - 19. │ KPHL │ 320762 │ 1291761 │ ████████████▊ │ - 20. │ OMDB │ 308855 │ 2855706 │ ████████████████████████████▌ │ - 21. │ UUEE │ 307098 │ 1555122 │ ███████████████▌ │ - 22. │ KBOS │ 304416 │ 1621675 │ ████████████████▏ │ - 23. │ LEMD │ 291787 │ 1695097 │ ████████████████▊ │ - 24. │ YSSY │ 272979 │ 1875298 │ ██████████████████▋ │ - 25. │ KMIA │ 265121 │ 1923542 │ ███████████████████▏ │ - 26. │ ZGSZ │ 263497 │ 745086 │ ███████▍ │ - 27. │ EDDM │ 256691 │ 1361453 │ █████████████▌ │ - 28. │ WMKK │ 254264 │ 1626688 │ ████████████████▎ │ - 29. │ CYYZ │ 251192 │ 2175026 │ █████████████████████▋ │ - 30. │ KLGA │ 248699 │ 1106935 │ ███████████ │ - 31. │ VHHH │ 248473 │ 3457658 │ ██████████████████████████████████▌ │ - 32. │ RJTT │ 243477 │ 1272744 │ ████████████▋ │ - 33. │ KBWI │ 241440 │ 1187060 │ ███████████▋ │ - 34. │ KIAD │ 239558 │ 1683485 │ ████████████████▋ │ - 35. │ KIAH │ 234202 │ 1538335 │ ███████████████▍ │ - 36. │ KFLL │ 223447 │ 1464410 │ ██████████████▋ │ - 37. │ KDAL │ 212055 │ 1082339 │ ██████████▋ │ - 38. │ KDCA │ 207883 │ 1013359 │ ██████████▏ │ - 39. │ LIRF │ 207047 │ 1427965 │ ██████████████▎ │ - 40. │ PANC │ 206007 │ 2525359 │ █████████████████████████▎ │ - 41. │ LTFJ │ 205415 │ 860470 │ ████████▌ │ - 42. │ KDTW │ 204020 │ 1106716 │ ███████████ │ - 43. │ VABB │ 201679 │ 1300865 │ █████████████ │ - 44. │ OTHH │ 200797 │ 3759544 │ █████████████████████████████████████▌ │ - 45. │ KMDW │ 200796 │ 1232551 │ ████████████▎ │ - 46. │ KSAN │ 198003 │ 1495195 │ ██████████████▊ │ - 47. │ KPDX │ 197760 │ 1269230 │ ████████████▋ │ - 48. │ SBGR │ 197624 │ 2041697 │ ████████████████████▍ │ - 49. │ VOBL │ 189011 │ 1040180 │ ██████████▍ │ - 50. │ LEBL │ 188956 │ 1283190 │ ████████████▋ │ - 51. │ YBBN │ 188011 │ 1253405 │ ████████████▌ │ - 52. │ LSZH │ 187934 │ 1572029 │ ███████████████▋ │ - 53. │ YMML │ 187643 │ 1870076 │ ██████████████████▋ │ - 54. │ RCTP │ 184466 │ 2773976 │ ███████████████████████████▋ │ - 55. │ KSNA │ 180045 │ 778484 │ ███████▋ │ - 56. │ EGKK │ 176420 │ 1694770 │ ████████████████▊ │ - 57. │ LOWW │ 176191 │ 1274833 │ ████████████▋ │ - 58. │ UUDD │ 176099 │ 1368226 │ █████████████▋ │ - 59. │ RKSI │ 173466 │ 3079026 │ ██████████████████████████████▋ │ - 60. │ EKCH │ 172128 │ 1229895 │ ████████████▎ │ - 61. │ KOAK │ 171119 │ 1114447 │ ███████████▏ │ - 62. │ RPLL │ 170122 │ 1440735 │ ██████████████▍ │ - 63. │ KRDU │ 167001 │ 830521 │ ████████▎ │ - 64. │ KAUS │ 164524 │ 1256198 │ ████████████▌ │ - 65. │ KBNA │ 163242 │ 1022726 │ ██████████▏ │ - 66. │ KSDF │ 162655 │ 1380867 │ █████████████▋ │ - 67. │ ENGM │ 160732 │ 910108 │ █████████ │ - 68. │ LIMC │ 160696 │ 1564620 │ ███████████████▋ │ - 69. │ KSJC │ 159278 │ 1081125 │ ██████████▋ │ - 70. │ KSTL │ 157984 │ 1026699 │ ██████████▎ │ - 71. │ UUWW │ 156811 │ 1261155 │ ████████████▌ │ - 72. │ KIND │ 153929 │ 987944 │ █████████▊ │ - 73. │ ESSA │ 153390 │ 1203439 │ ████████████ │ - 74. │ KMCO │ 153351 │ 1508657 │ ███████████████ │ - 75. │ KDVT │ 152895 │ 74048 │ ▋ │ - 76. │ VTBS │ 152645 │ 2255591 │ ██████████████████████▌ │ - 77. │ CYVR │ 149574 │ 2027413 │ ████████████████████▎ │ - 78. │ EIDW │ 148723 │ 1503985 │ ███████████████ │ - 79. │ LFPO │ 143277 │ 1152964 │ ███████████▌ │ - 80. │ EGSS │ 140830 │ 1348183 │ █████████████▍ │ - 81. │ KAPA │ 140776 │ 420441 │ ████▏ │ - 82. │ KHOU │ 138985 │ 1068806 │ ██████████▋ │ - 83. │ KTPA │ 138033 │ 1338223 │ █████████████▍ │ - 84. │ KFFZ │ 137333 │ 55397 │ ▌ │ - 85. │ NZAA │ 136092 │ 1581264 │ ███████████████▋ │ - 86. │ YPPH │ 133916 │ 1271550 │ ████████████▋ │ - 87. │ RJBB │ 133522 │ 1805623 │ ██████████████████ │ - 88. │ EDDL │ 133018 │ 1265919 │ ████████████▋ │ - 89. │ ULLI │ 130501 │ 1197108 │ ███████████▊ │ - 90. │ KIWA │ 127195 │ 250876 │ ██▌ │ - 91. │ KTEB │ 126969 │ 1189414 │ ███████████▊ │ - 92. │ VOMM │ 125616 │ 1127757 │ ███████████▎ │ - 93. │ LSGG │ 123998 │ 1049101 │ ██████████▍ │ - 94. │ LPPT │ 122733 │ 1779187 │ █████████████████▋ │ - 95. │ WSSS │ 120493 │ 3264122 │ ████████████████████████████████▋ │ - 96. │ EBBR │ 118539 │ 1579939 │ ███████████████▋ │ - 97. │ VTBD │ 118107 │ 661627 │ ██████▌ │ - 98. │ KVNY │ 116326 │ 692960 │ ██████▊ │ - 99. │ EDDT │ 115122 │ 941740 │ █████████▍ │ -100. │ EFHK │ 114860 │ 1629143 │ ████████████████▎ │ - └────────┴─────────┴──────────┴────────────────────────────────────────┘ -``` - -### 三个主要莫斯科机场的航班数量(每周) {#flights-from-moscow} - -查询: - -```sql -SELECT - toMonday(day) AS k, - count() AS c, - bar(c, 0, 10000, 100) AS bar -FROM opensky -WHERE origin IN ('UUEE', 'UUDD', 'UUWW') -GROUP BY k -ORDER BY k ASC; -``` - -结果: - -```text - ┌──────────k─┬────c─┬─bar──────────────────────────────────────────────────────────────────────────┐ - 1. │ 2018-12-31 │ 5248 │ ████████████████████████████████████████████████████▍ │ - 2. │ 2019-01-07 │ 6302 │ ███████████████████████████████████████████████████████████████ │ - 3. │ 2019-01-14 │ 5701 │ █████████████████████████████████████████████████████████ │ - 4. │ 2019-01-21 │ 5638 │ ████████████████████████████████████████████████████████▍ │ - 5. │ 2019-01-28 │ 5731 │ █████████████████████████████████████████████████████████▎ │ - 6. │ 2019-02-04 │ 5683 │ ████████████████████████████████████████████████████████▋ │ - 7. │ 2019-02-11 │ 5759 │ █████████████████████████████████████████████████████████▌ │ - 8. │ 2019-02-18 │ 5736 │ █████████████████████████████████████████████████████████▎ │ - 9. │ 2019-02-25 │ 5873 │ ██████████████████████████████████████████████████████████▋ │ - 10. │ 2019-03-04 │ 5965 │ ███████████████████████████████████████████████████████████▋ │ - 11. │ 2019-03-11 │ 5900 │ ███████████████████████████████████████████████████████████ │ - 12. │ 2019-03-18 │ 5823 │ ██████████████████████████████████████████████████████████▏ │ - 13. │ 2019-03-25 │ 5899 │ ██████████████████████████████████████████████████████████▊ │ - 14. │ 2019-04-01 │ 6043 │ ████████████████████████████████████████████████████████████▍ │ - 15. │ 2019-04-08 │ 6098 │ ████████████████████████████████████████████████████████████▊ │ - 16. │ 2019-04-15 │ 6196 │ █████████████████████████████████████████████████████████████▊ │ - 17. │ 2019-04-22 │ 6486 │ ████████████████████████████████████████████████████████████████▋ │ - 18. │ 2019-04-29 │ 6682 │ ██████████████████████████████████████████████████████████████████▋ │ - 19. │ 2019-05-06 │ 6739 │ ███████████████████████████████████████████████████████████████████▍ │ - 20. │ 2019-05-13 │ 6600 │ ██████████████████████████████████████████████████████████████████ │ - 21. │ 2019-05-20 │ 6575 │ █████████████████████████████████████████████████████████████████▋ │ - 22. │ 2019-05-27 │ 6786 │ ███████████████████████████████████████████████████████████████████▋ │ - 23. │ 2019-06-03 │ 6872 │ ████████████████████████████████████████████████████████████████████▋ │ - 24. │ 2019-06-10 │ 7045 │ ██████████████████████████████████████████████████████████████████████▍ │ - 25. │ 2019-06-17 │ 7045 │ ██████████████████████████████████████████████████████████████████████▍ │ - 26. │ 2019-06-24 │ 6852 │ ████████████████████████████████████████████████████████████████████▌ │ - 27. │ 2019-07-01 │ 7248 │ ████████████████████████████████████████████████████████████████████████▍ │ - 28. │ 2019-07-08 │ 7284 │ ████████████████████████████████████████████████████████████████████████▋ │ - 29. │ 2019-07-15 │ 7142 │ ███████████████████████████████████████████████████████████████████████▍ │ - 30. │ 2019-07-22 │ 7108 │ ███████████████████████████████████████████████████████████████████████ │ - 31. │ 2019-07-29 │ 7251 │ ████████████████████████████████████████████████████████████████████████▌ │ - 32. │ 2019-08-05 │ 7403 │ ██████████████████████████████████████████████████████████████████████████ │ - 33. │ 2019-08-12 │ 7457 │ ██████████████████████████████████████████████████████████████████████████▌ │ - 34. │ 2019-08-19 │ 7502 │ ███████████████████████████████████████████████████████████████████████████ │ - 35. │ 2019-08-26 │ 7540 │ ███████████████████████████████████████████████████████████████████████████▍ │ - 36. │ 2019-09-02 │ 7237 │ ████████████████████████████████████████████████████████████████████████▎ │ - 37. │ 2019-09-09 │ 7328 │ █████████████████████████████████████████████████████████████████████████▎ │ - 38. │ 2019-09-16 │ 5566 │ ███████████████████████████████████████████████████████▋ │ - 39. │ 2019-09-23 │ 7049 │ ██████████████████████████████████████████████████████████████████████▍ │ - 40. │ 2019-09-30 │ 6880 │ ████████████████████████████████████████████████████████████████████▋ │ - 41. │ 2019-10-07 │ 6518 │ █████████████████████████████████████████████████████████████████▏ │ - 42. │ 2019-10-14 │ 6688 │ ██████████████████████████████████████████████████████████████████▊ │ - 43. │ 2019-10-21 │ 6667 │ ██████████████████████████████████████████████████████████████████▋ │ - 44. │ 2019-10-28 │ 6303 │ ███████████████████████████████████████████████████████████████ │ - 45. │ 2019-11-04 │ 6298 │ ██████████████████████████████████████████████████████████████▊ │ - 46. │ 2019-11-11 │ 6137 │ █████████████████████████████████████████████████████████████▎ │ - 47. │ 2019-11-18 │ 6051 │ ████████████████████████████████████████████████████████████▌ │ - 48. │ 2019-11-25 │ 5820 │ ██████████████████████████████████████████████████████████▏ │ - 49. │ 2019-12-02 │ 5942 │ ███████████████████████████████████████████████████████████▍ │ - 50. │ 2019-12-09 │ 4891 │ ████████████████████████████████████████████████▊ │ - 51. │ 2019-12-16 │ 5682 │ ████████████████████████████████████████████████████████▋ │ - 52. │ 2019-12-23 │ 6111 │ █████████████████████████████████████████████████████████████ │ - 53. │ 2019-12-30 │ 5870 │ ██████████████████████████████████████████████████████████▋ │ - 54. │ 2020-01-06 │ 5953 │ ███████████████████████████████████████████████████████████▌ │ - 55. │ 2020-01-13 │ 5698 │ ████████████████████████████████████████████████████████▊ │ - 56. │ 2020-01-20 │ 5339 │ █████████████████████████████████████████████████████▍ │ - 57. │ 2020-01-27 │ 5566 │ ███████████████████████████████████████████████████████▋ │ - 58. │ 2020-02-03 │ 5801 │ ██████████████████████████████████████████████████████████ │ - 59. │ 2020-02-10 │ 5692 │ ████████████████████████████████████████████████████████▊ │ - 60. │ 2020-02-17 │ 5912 │ ███████████████████████████████████████████████████████████ │ - 61. │ 2020-02-24 │ 6031 │ ████████████████████████████████████████████████████████████▎ │ - 62. │ 2020-03-02 │ 6105 │ █████████████████████████████████████████████████████████████ │ - 63. │ 2020-03-09 │ 5823 │ ██████████████████████████████████████████████████████████▏ │ - 64. │ 2020-03-16 │ 4659 │ ██████████████████████████████████████████████▌ │ - 65. │ 2020-03-23 │ 3720 │ █████████████████████████████████████▏ │ - 66. │ 2020-03-30 │ 1720 │ █████████████████▏ │ - 67. │ 2020-04-06 │ 849 │ ████████▍ │ - 68. │ 2020-04-13 │ 710 │ ███████ │ - 69. │ 2020-04-20 │ 725 │ ███████▏ │ - 70. │ 2020-04-27 │ 920 │ █████████▏ │ - 71. │ 2020-05-04 │ 859 │ ████████▌ │ - 72. │ 2020-05-11 │ 1047 │ ██████████▍ │ - 73. │ 2020-05-18 │ 1135 │ ███████████▎ │ - 74. │ 2020-05-25 │ 1266 │ ████████████▋ │ - 75. │ 2020-06-01 │ 1793 │ █████████████████▊ │ - 76. │ 2020-06-08 │ 1979 │ ███████████████████▋ │ - 77. │ 2020-06-15 │ 2297 │ ██████████████████████▊ │ - 78. │ 2020-06-22 │ 2788 │ ███████████████████████████▊ │ - 79. │ 2020-06-29 │ 3389 │ █████████████████████████████████▊ │ - 80. │ 2020-07-06 │ 3545 │ ███████████████████████████████████▍ │ - 81. │ 2020-07-13 │ 3569 │ ███████████████████████████████████▋ │ - 82. │ 2020-07-20 │ 3784 │ █████████████████████████████████████▋ │ - 83. │ 2020-07-27 │ 3960 │ ███████████████████████████████████████▌ │ - 84. │ 2020-08-03 │ 4323 │ ███████████████████████████████████████████▏ │ - 85. │ 2020-08-10 │ 4581 │ █████████████████████████████████████████████▋ │ - 86. │ 2020-08-17 │ 4791 │ ███████████████████████████████████████████████▊ │ - 87. │ 2020-08-24 │ 4928 │ █████████████████████████████████████████████████▎ │ - 88. │ 2020-08-31 │ 4687 │ ██████████████████████████████████████████████▋ │ - 89. │ 2020-09-07 │ 4643 │ ██████████████████████████████████████████████▍ │ - 90. │ 2020-09-14 │ 4594 │ █████████████████████████████████████████████▊ │ - 91. │ 2020-09-21 │ 4478 │ ████████████████████████████████████████████▋ │ - 92. │ 2020-09-28 │ 4382 │ ███████████████████████████████████████████▋ │ - 93. │ 2020-10-05 │ 4261 │ ██████████████████████████████████████████▌ │ - 94. │ 2020-10-12 │ 4243 │ ██████████████████████████████████████████▍ │ - 95. │ 2020-10-19 │ 3941 │ ███████████████████████████████████████▍ │ - 96. │ 2020-10-26 │ 3616 │ ████████████████████████████████████▏ │ - 97. │ 2020-11-02 │ 3586 │ ███████████████████████████████████▋ │ - 98. │ 2020-11-09 │ 3403 │ ██████████████████████████████████ │ - 99. │ 2020-11-16 │ 3336 │ █████████████████████████████████▎ │ -100. │ 2020-11-23 │ 3230 │ ████████████████████████████████▎ │ -101. │ 2020-11-30 │ 3183 │ ███████████████████████████████▋ │ -102. │ 2020-12-07 │ 3285 │ ████████████████████████████████▋ │ -103. │ 2020-12-14 │ 3367 │ █████████████████████████████████▋ │ -104. │ 2020-12-21 │ 3748 │ █████████████████████████████████████▍ │ -105. │ 2020-12-28 │ 3986 │ ███████████████████████████████████████▋ │ -106. │ 2021-01-04 │ 3906 │ ███████████████████████████████████████ │ -107. │ 2021-01-11 │ 3425 │ ██████████████████████████████████▎ │ -108. │ 2021-01-18 │ 3144 │ ███████████████████████████████▍ │ -109. │ 2021-01-25 │ 3115 │ ███████████████████████████████▏ │ -110. │ 2021-02-01 │ 3285 │ ████████████████████████████████▋ │ -111. │ 2021-02-08 │ 3321 │ █████████████████████████████████▏ │ -112. │ 2021-02-15 │ 3475 │ ██████████████████████████████████▋ │ -113. │ 2021-02-22 │ 3549 │ ███████████████████████████████████▍ │ -114. │ 2021-03-01 │ 3755 │ █████████████████████████████████████▌ │ -115. │ 2021-03-08 │ 3080 │ ██████████████████████████████▋ │ -116. │ 2021-03-15 │ 3789 │ █████████████████████████████████████▊ │ -117. │ 2021-03-22 │ 3804 │ ██████████████████████████████████████ │ -118. │ 2021-03-29 │ 4238 │ ██████████████████████████████████████████▍ │ -119. │ 2021-04-05 │ 4307 │ ███████████████████████████████████████████ │ -120. │ 2021-04-12 │ 4225 │ ██████████████████████████████████████████▎ │ -121. │ 2021-04-19 │ 4391 │ ███████████████████████████████████████████▊ │ -122. │ 2021-04-26 │ 4868 │ ████████████████████████████████████████████████▋ │ -123. │ 2021-05-03 │ 4977 │ █████████████████████████████████████████████████▋ │ -124. │ 2021-05-10 │ 5164 │ ███████████████████████████████████████████████████▋ │ -125. │ 2021-05-17 │ 4986 │ █████████████████████████████████████████████████▋ │ -126. │ 2021-05-24 │ 5024 │ ██████████████████████████████████████████████████▏ │ -127. │ 2021-05-31 │ 4824 │ ████████████████████████████████████████████████▏ │ -128. │ 2021-06-07 │ 5652 │ ████████████████████████████████████████████████████████▌ │ -129. │ 2021-06-14 │ 5613 │ ████████████████████████████████████████████████████████▏ │ -130. │ 2021-06-21 │ 6061 │ ████████████████████████████████████████████████████████████▌ │ -131. │ 2021-06-28 │ 2554 │ █████████████████████████▌ │ - └────────────┴──────┴──────────────────────────────────────────────────────────────────────────────┘ -``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/opensky.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/opensky.md.hash deleted file mode 100644 index c418ffc96a5..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/opensky.md.hash +++ /dev/null @@ -1 +0,0 @@ -2268533fe84303b5 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/recipes.md b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/recipes.md deleted file mode 100644 index 68e0873c8bf..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/recipes.md +++ /dev/null @@ -1,335 +0,0 @@ ---- -'description': 'RecipeNLG 数据集,包含 220 万条食谱' -'sidebar_label': '食谱数据集' -'slug': '/getting-started/example-datasets/recipes' -'title': '食谱数据集' ---- - -The RecipeNLG 数据集可以从 [这里](https://recipenlg.cs.put.poznan.pl/dataset) 下载。它包含 220 万个食谱,大小略小于 1 GB。 - -## 下载并解压数据集 {#download-and-unpack-the-dataset} - -1. 访问下载页面 [https://recipenlg.cs.put.poznan.pl/dataset](https://recipenlg.cs.put.poznan.pl/dataset)。 -2. 接受条款和条件并下载 zip 文件。 -3. 可选:使用 `md5sum dataset.zip` 验证 zip 文件,应该等于 `3a168dfd0912bb034225619b3586ce76`。 -4. 使用 `unzip dataset.zip` 解压 zip 文件。您将在 `dataset` 目录中得到 `full_dataset.csv` 文件。 - -## 创建表 {#create-a-table} - -运行 clickhouse-client 并执行以下 CREATE 查询: - -```sql -CREATE TABLE recipes -( - title String, - ingredients Array(String), - directions Array(String), - link String, - source LowCardinality(String), - NER Array(String) -) ENGINE = MergeTree ORDER BY title; -``` - -## 插入数据 {#insert-the-data} - -运行以下命令: - -```bash -clickhouse-client --query " - INSERT INTO recipes - SELECT - title, - JSONExtract(ingredients, 'Array(String)'), - JSONExtract(directions, 'Array(String)'), - link, - source, - JSONExtract(NER, 'Array(String)') - FROM input('num UInt32, title String, ingredients String, directions String, link String, source LowCardinality(String), NER String') - FORMAT CSVWithNames -" --input_format_with_names_use_header 0 --format_csv_allow_single_quote 0 --input_format_allow_errors_num 10 < full_dataset.csv -``` - -这是一个展示如何解析自定义 CSV 的示例,因为它需要多种调整。 - -说明: -- 数据集为 CSV 格式,但在插入时需要一些预处理;我们使用表函数 [input](../../sql-reference/table-functions/input.md) 来执行预处理; -- CSV 文件的结构在表函数 `input` 的参数中指定; -- 字段 `num`(行号)是多余的 - 我们从文件解析并忽略它; -- 我们使用 `FORMAT CSVWithNames` 但 CSV 中的表头将被忽略(通过命令行参数 `--input_format_with_names_use_header 0`),因为表头不包含第一个字段的名称; -- 文件仅使用双引号来括起来 CSV 字符串;一些字符串没有用双引号括起来,单引号不能被解析为字符串的括起来 - 这就是为什么我们还添加 `--format_csv_allow_single_quote 0` 参数; -- CSV 中的一些字符串无法解析,因为它们的值开头包含 `\M/` 序列; CSV 中唯一以反斜杠开头的值可以是 `\N`,被解析为 SQL NULL。我们添加 `--input_format_allow_errors_num 10` 参数,可以跳过最多十条格式错误的记录; -- 成分、方向和 NER 字段都有数组;这些数组以不寻常的形式表示:它们被序列化为字符串作为 JSON,然后放在 CSV 中 - 我们将它们解析为 String,然后使用 [JSONExtract](../../sql-reference/functions/json-functions.md) 函数将其转换为 Array。 - -## 验证插入的数据 {#validate-the-inserted-data} - -通过检查行数: - -查询: - -```sql -SELECT count() FROM recipes; -``` - -结果: - -```text -┌─count()─┐ -│ 2231142 │ -└─────────┘ -``` - -## 示例查询 {#example-queries} - -### 按食谱数量排序的顶级成分: {#top-components-by-the-number-of-recipes} - -在这个示例中,我们学习如何使用 [arrayJoin](../../sql-reference/functions/array-join.md) 函数将数组扩展为一组行。 - -查询: - -```sql -SELECT - arrayJoin(NER) AS k, - count() AS c -FROM recipes -GROUP BY k -ORDER BY c DESC -LIMIT 50 -``` - -结果: - -```text -┌─k────────────────────┬──────c─┐ -│ salt │ 890741 │ -│ sugar │ 620027 │ -│ butter │ 493823 │ -│ flour │ 466110 │ -│ eggs │ 401276 │ -│ onion │ 372469 │ -│ garlic │ 358364 │ -│ milk │ 346769 │ -│ water │ 326092 │ -│ vanilla │ 270381 │ -│ olive oil │ 197877 │ -│ pepper │ 179305 │ -│ brown sugar │ 174447 │ -│ tomatoes │ 163933 │ -│ egg │ 160507 │ -│ baking powder │ 148277 │ -│ lemon juice │ 146414 │ -│ Salt │ 122558 │ -│ cinnamon │ 117927 │ -│ sour cream │ 116682 │ -│ cream cheese │ 114423 │ -│ margarine │ 112742 │ -│ celery │ 112676 │ -│ baking soda │ 110690 │ -│ parsley │ 102151 │ -│ chicken │ 101505 │ -│ onions │ 98903 │ -│ vegetable oil │ 91395 │ -│ oil │ 85600 │ -│ mayonnaise │ 84822 │ -│ pecans │ 79741 │ -│ nuts │ 78471 │ -│ potatoes │ 75820 │ -│ carrots │ 75458 │ -│ pineapple │ 74345 │ -│ soy sauce │ 70355 │ -│ black pepper │ 69064 │ -│ thyme │ 68429 │ -│ mustard │ 65948 │ -│ chicken broth │ 65112 │ -│ bacon │ 64956 │ -│ honey │ 64626 │ -│ oregano │ 64077 │ -│ ground beef │ 64068 │ -│ unsalted butter │ 63848 │ -│ mushrooms │ 61465 │ -│ Worcestershire sauce │ 59328 │ -│ cornstarch │ 58476 │ -│ green pepper │ 58388 │ -│ Cheddar cheese │ 58354 │ -└──────────────────────┴────────┘ - -50 rows in set. Elapsed: 0.112 sec. Processed 2.23 million rows, 361.57 MB (19.99 million rows/s., 3.24 GB/s.) -``` - -### 最复杂的草莓食谱 {#the-most-complex-recipes-with-strawberry} - -```sql -SELECT - title, - length(NER), - length(directions) -FROM recipes -WHERE has(NER, 'strawberry') -ORDER BY length(directions) DESC -LIMIT 10 -``` - -结果: - -```text -┌─title────────────────────────────────────────────────────────────┬─length(NER)─┬─length(directions)─┐ -│ Chocolate-Strawberry-Orange Wedding Cake │ 24 │ 126 │ -│ Strawberry Cream Cheese Crumble Tart │ 19 │ 47 │ -│ Charlotte-Style Ice Cream │ 11 │ 45 │ -│ Sinfully Good a Million Layers Chocolate Layer Cake, With Strawb │ 31 │ 45 │ -│ Sweetened Berries With Elderflower Sherbet │ 24 │ 44 │ -│ Chocolate-Strawberry Mousse Cake │ 15 │ 42 │ -│ Rhubarb Charlotte with Strawberries and Rum │ 20 │ 42 │ -│ Chef Joey's Strawberry Vanilla Tart │ 7 │ 37 │ -│ Old-Fashioned Ice Cream Sundae Cake │ 17 │ 37 │ -│ Watermelon Cake │ 16 │ 36 │ -└──────────────────────────────────────────────────────────────────┴─────────────┴────────────────────┘ - -10 rows in set. Elapsed: 0.215 sec. Processed 2.23 million rows, 1.48 GB (10.35 million rows/s., 6.86 GB/s.) -``` - -在这个示例中,我们使用 [has](../../sql-reference/functions/array-functions.md#hasarr-elem) 函数按数组元素进行过滤,并根据方向的数量进行排序。 - -有一个婚礼蛋糕需要完整的 126 个步骤来制作!展示这些步骤: - -查询: - -```sql -SELECT arrayJoin(directions) -FROM recipes -WHERE title = 'Chocolate-Strawberry-Orange Wedding Cake' -``` - -结果: - -```text -┌─arrayJoin(directions)───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ -│ Position 1 rack in center and 1 rack in bottom third of oven and preheat to 350F. │ -│ Butter one 5-inch-diameter cake pan with 2-inch-high sides, one 8-inch-diameter cake pan with 2-inch-high sides and one 12-inch-diameter cake pan with 2-inch-high sides. │ -│ Dust pans with flour; line bottoms with parchment. │ -│ Combine 1/3 cup orange juice and 2 ounces unsweetened chocolate in heavy small saucepan. │ -│ Stir mixture over medium-low heat until chocolate melts. │ -│ Remove from heat. │ -│ Gradually mix in 1 2/3 cups orange juice. │ -│ Sift 3 cups flour, 2/3 cup cocoa, 2 teaspoons baking soda, 1 teaspoon salt and 1/2 teaspoon baking powder into medium bowl. │ -│ using electric mixer, beat 1 cup (2 sticks) butter and 3 cups sugar in large bowl until blended (mixture will look grainy). │ -│ Add 4 eggs, 1 at a time, beating to blend after each. │ -│ Beat in 1 tablespoon orange peel and 1 tablespoon vanilla extract. │ -│ Add dry ingredients alternately with orange juice mixture in 3 additions each, beating well after each addition. │ -│ Mix in 1 cup chocolate chips. │ -│ Transfer 1 cup plus 2 tablespoons batter to prepared 5-inch pan, 3 cups batter to prepared 8-inch pan and remaining batter (about 6 cups) to 12-inch pan. │ -│ Place 5-inch and 8-inch pans on center rack of oven. │ -│ Place 12-inch pan on lower rack of oven. │ -│ Bake cakes until tester inserted into center comes out clean, about 35 minutes. │ -│ Transfer cakes in pans to racks and cool completely. │ -│ Mark 4-inch diameter circle on one 6-inch-diameter cardboard cake round. │ -│ Cut out marked circle. │ -│ Mark 7-inch-diameter circle on one 8-inch-diameter cardboard cake round. │ -│ Cut out marked circle. │ -│ Mark 11-inch-diameter circle on one 12-inch-diameter cardboard cake round. │ -│ Cut out marked circle. │ -│ Cut around sides of 5-inch-cake to loosen. │ -│ Place 4-inch cardboard over pan. │ -│ Hold cardboard and pan together; turn cake out onto cardboard. │ -│ Peel off parchment.Wrap cakes on its cardboard in foil. │ -│ Repeat turning out, peeling off parchment and wrapping cakes in foil, using 7-inch cardboard for 8-inch cake and 11-inch cardboard for 12-inch cake. │ -│ Using remaining ingredients, make 1 more batch of cake batter and bake 3 more cake layers as described above. │ -│ Cool cakes in pans. │ -│ Cover cakes in pans tightly with foil. │ -│ (Can be prepared ahead. │ -│ Let stand at room temperature up to 1 day or double-wrap all cake layers and freeze up to 1 week. │ -│ Bring cake layers to room temperature before using.) │ -│ Place first 12-inch cake on its cardboard on work surface. │ -│ Spread 2 3/4 cups ganache over top of cake and all the way to edge. │ -│ Spread 2/3 cup jam over ganache, leaving 1/2-inch chocolate border at edge. │ -│ Drop 1 3/4 cups white chocolate frosting by spoonfuls over jam. │ -│ Gently spread frosting over jam, leaving 1/2-inch chocolate border at edge. │ -│ Rub some cocoa powder over second 12-inch cardboard. │ -│ Cut around sides of second 12-inch cake to loosen. │ -│ Place cardboard, cocoa side down, over pan. │ -│ Turn cake out onto cardboard. │ -│ Peel off parchment. │ -│ Carefully slide cake off cardboard and onto filling on first 12-inch cake. │ -│ Refrigerate. │ -│ Place first 8-inch cake on its cardboard on work surface. │ -│ Spread 1 cup ganache over top all the way to edge. │ -│ Spread 1/4 cup jam over, leaving 1/2-inch chocolate border at edge. │ -│ Drop 1 cup white chocolate frosting by spoonfuls over jam. │ -│ Gently spread frosting over jam, leaving 1/2-inch chocolate border at edge. │ -│ Rub some cocoa over second 8-inch cardboard. │ -│ Cut around sides of second 8-inch cake to loosen. │ -│ Place cardboard, cocoa side down, over pan. │ -│ Turn cake out onto cardboard. │ -│ Peel off parchment. │ -│ Slide cake off cardboard and onto filling on first 8-inch cake. │ -│ Refrigerate. │ -│ Place first 5-inch cake on its cardboard on work surface. │ -│ Spread 1/2 cup ganache over top of cake and all the way to edge. │ -│ Spread 2 tablespoons jam over, leaving 1/2-inch chocolate border at edge. │ -│ Drop 1/3 cup white chocolate frosting by spoonfuls over jam. │ -│ Gently spread frosting over jam, leaving 1/2-inch chocolate border at edge. │ -│ Rub cocoa over second 6-inch cardboard. │ -│ Cut around sides of second 5-inch cake to loosen. │ -│ Place cardboard, cocoa side down, over pan. │ -│ Turn cake out onto cardboard. │ -│ Peel off parchment. │ -│ Slide cake off cardboard and onto filling on first 5-inch cake. │ -│ Chill all cakes 1 hour to set filling. │ -│ Place 12-inch tiered cake on its cardboard on revolving cake stand. │ -│ Spread 2 2/3 cups frosting over top and sides of cake as a first coat. │ -│ Refrigerate cake. │ -│ Place 8-inch tiered cake on its cardboard on cake stand. │ -│ Spread 1 1/4 cups frosting over top and sides of cake as a first coat. │ -│ Refrigerate cake. │ -│ Place 5-inch tiered cake on its cardboard on cake stand. │ -│ Spread 3/4 cup frosting over top and sides of cake as a first coat. │ -│ Refrigerate all cakes until first coats of frosting set, about 1 hour. │ -│ (Cakes can be made to this point up to 1 day ahead; cover and keep refrigerate.) │ -│ Prepare second batch of frosting, using remaining frosting ingredients and following directions for first batch. │ -│ Spoon 2 cups frosting into pastry bag fitted with small star tip. │ -│ Place 12-inch cake on its cardboard on large flat platter. │ -│ Place platter on cake stand. │ -│ Using icing spatula, spread 2 1/2 cups frosting over top and sides of cake; smooth top. │ -│ Using filled pastry bag, pipe decorative border around top edge of cake. │ -│ Refrigerate cake on platter. │ -│ Place 8-inch cake on its cardboard on cake stand. │ -│ Using icing spatula, spread 1 1/2 cups frosting over top and sides of cake; smooth top. │ -│ Using pastry bag, pipe decorative border around top edge of cake. │ -│ Refrigerate cake on its cardboard. │ -│ Place 5-inch cake on its cardboard on cake stand. │ -│ Using icing spatula, spread 3/4 cup frosting over top and sides of cake; smooth top. │ -│ Using pastry bag, pipe decorative border around top edge of cake, spooning more frosting into bag if necessary. │ -│ Refrigerate cake on its cardboard. │ -│ Keep all cakes refrigerated until frosting sets, about 2 hours. │ -│ (Can be prepared 2 days ahead. │ -│ Cover loosely; keep refrigerated.) │ -│ Place 12-inch cake on platter on work surface. │ -│ Press 1 wooden dowel straight down into and completely through center of cake. │ -│ Mark dowel 1/4 inch above top of frosting. │ -│ Remove dowel and cut with serrated knife at marked point. │ -│ Cut 4 more dowels to same length. │ -│ Press 1 cut dowel back into center of cake. │ -│ Press remaining 4 cut dowels into cake, positioning 3 1/2 inches inward from cake edges and spacing evenly. │ -│ Place 8-inch cake on its cardboard on work surface. │ -│ Press 1 dowel straight down into and completely through center of cake. │ -│ Mark dowel 1/4 inch above top of frosting. │ -│ Remove dowel and cut with serrated knife at marked point. │ -│ Cut 3 more dowels to same length. │ -│ Press 1 cut dowel back into center of cake. │ -│ Press remaining 3 cut dowels into cake, positioning 2 1/2 inches inward from edges and spacing evenly. │ -│ Using large metal spatula as aid, place 8-inch cake on its cardboard atop dowels in 12-inch cake, centering carefully. │ -│ Gently place 5-inch cake on its cardboard atop dowels in 8-inch cake, centering carefully. │ -│ Using citrus stripper, cut long strips of orange peel from oranges. │ -│ Cut strips into long segments. │ -│ To make orange peel coils, wrap peel segment around handle of wooden spoon; gently slide peel off handle so that peel keeps coiled shape. │ -│ Garnish cake with orange peel coils, ivy or mint sprigs, and some berries. │ -│ (Assembled cake can be made up to 8 hours ahead. │ -│ Let stand at cool room temperature.) │ -│ Remove top and middle cake tiers. │ -│ Remove dowels from cakes. │ -│ Cut top and middle cakes into slices. │ -│ To cut 12-inch cake: Starting 3 inches inward from edge and inserting knife straight down, cut through from top to bottom to make 6-inch-diameter circle in center of cake. │ -│ Cut outer portion of cake into slices; cut inner portion into slices and serve with strawberries. │ -└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ - -126 rows in set. Elapsed: 0.011 sec. Processed 8.19 thousand rows, 5.34 MB (737.75 thousand rows/s., 480.59 MB/s.) -``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/recipes.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/recipes.md.hash deleted file mode 100644 index 3f6e4727537..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/recipes.md.hash +++ /dev/null @@ -1 +0,0 @@ -c55828182ab33add diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/reddit-comments.md b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/reddit-comments.md deleted file mode 100644 index 8867bcb7e38..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/reddit-comments.md +++ /dev/null @@ -1,657 +0,0 @@ ---- -'description': '数据集包含从 2005 年 12 月到 2023 年 3 月在 Reddit 上公开可用的评论,超过 14B 行的数据,格式为 JSON' -'sidebar_label': 'Reddit 评论' -'slug': '/getting-started/example-datasets/reddit-comments' -'title': 'Reddit 评论数据集' ---- - -这个数据集包含自2005年12月到2023年3月在Reddit上公开可用的评论,数据超过140亿行。原始数据以JSON格式存储在压缩文件中,行的格式如下: - -```json -{"controversiality":0,"body":"A look at Vietnam and Mexico exposes the myth of market liberalisation.","subreddit_id":"t5_6","link_id":"t3_17863","stickied":false,"subreddit":"reddit.com","score":2,"ups":2,"author_flair_css_class":null,"created_utc":1134365188,"author_flair_text":null,"author":"frjo","id":"c13","edited":false,"parent_id":"t3_17863","gilded":0,"distinguished":null,"retrieved_on":1473738411} -{"created_utc":1134365725,"author_flair_css_class":null,"score":1,"ups":1,"subreddit":"reddit.com","stickied":false,"link_id":"t3_17866","subreddit_id":"t5_6","controversiality":0,"body":"The site states \"What can I use it for? Meeting notes, Reports, technical specs Sign-up sheets, proposals and much more...\", just like any other new breeed of sites that want us to store everything we have on the web. And they even guarantee multiple levels of security and encryption etc. But what prevents these web site operators fom accessing and/or stealing Meeting notes, Reports, technical specs Sign-up sheets, proposals and much more, for competitive or personal gains...? I am pretty sure that most of them are honest, but what's there to prevent me from setting up a good useful site and stealing all your data? Call me paranoid - I am.","retrieved_on":1473738411,"distinguished":null,"gilded":0,"id":"c14","edited":false,"parent_id":"t3_17866","author":"zse7zse","author_flair_text":null} -{"gilded":0,"distinguished":null,"retrieved_on":1473738411,"author":"[deleted]","author_flair_text":null,"edited":false,"id":"c15","parent_id":"t3_17869","subreddit":"reddit.com","score":0,"ups":0,"created_utc":1134366848,"author_flair_css_class":null,"body":"Jython related topics by Frank Wierzbicki","controversiality":0,"subreddit_id":"t5_6","stickied":false,"link_id":"t3_17869"} -{"gilded":0,"retrieved_on":1473738411,"distinguished":null,"author_flair_text":null,"author":"[deleted]","edited":false,"parent_id":"t3_17870","id":"c16","subreddit":"reddit.com","created_utc":1134367660,"author_flair_css_class":null,"score":1,"ups":1,"body":"[deleted]","controversiality":0,"stickied":false,"link_id":"t3_17870","subreddit_id":"t5_6"} -{"gilded":0,"retrieved_on":1473738411,"distinguished":null,"author_flair_text":null,"author":"rjoseph","edited":false,"id":"c17","parent_id":"t3_17817","subreddit":"reddit.com","author_flair_css_class":null,"created_utc":1134367754,"score":1,"ups":1,"body":"Saft is by far the best extension you could tak onto your Safari","controversiality":0,"link_id":"t3_17817","stickied":false,"subreddit_id":"t5_6"} -``` - -感谢Percona提供的[获取此数据集的动机](https://www.percona.com/blog/big-data-set-reddit-comments-analyzing-clickhouse/),我们已经将其下载并存储在S3存储桶中。 - -## 创建一个表 {#creating-a-table} - -:::note -以下命令是在最小内存设置为720GB的ClickHouse Cloud生产实例上执行的。要在自己的集群上运行此命令,请将`s3Cluster`函数调用中的`default`替换为您的集群名称。如果您没有集群,请将`s3Cluster`函数替换为`s3`函数。 -::: - -1. 让我们为Reddit数据创建一个表: - -```sql -CREATE TABLE reddit -( - subreddit LowCardinality(String), - subreddit_id LowCardinality(String), - subreddit_type Enum('public' = 1, 'restricted' = 2, 'user' = 3, 'archived' = 4, 'gold_restricted' = 5, 'private' = 6), - author LowCardinality(String), - body String CODEC(ZSTD(6)), - created_date Date DEFAULT toDate(created_utc), - created_utc DateTime, - retrieved_on DateTime, - id String, - parent_id String, - link_id String, - score Int32, - total_awards_received UInt16, - controversiality UInt8, - gilded UInt8, - collapsed_because_crowd_control UInt8, - collapsed_reason Enum('' = 0, 'comment score below threshold' = 1, 'may be sensitive content' = 2, 'potentially toxic' = 3, 'potentially toxic content' = 4), - distinguished Enum('' = 0, 'moderator' = 1, 'admin' = 2, 'special' = 3), - removal_reason Enum('' = 0, 'legal' = 1), - author_created_utc DateTime, - author_fullname LowCardinality(String), - author_patreon_flair UInt8, - author_premium UInt8, - can_gild UInt8, - can_mod_post UInt8, - collapsed UInt8, - is_submitter UInt8, - _edited String, - locked UInt8, - quarantined UInt8, - no_follow UInt8, - send_replies UInt8, - stickied UInt8, - author_flair_text LowCardinality(String) -) -ENGINE = MergeTree -ORDER BY (subreddit, created_date, author); -``` - -:::note -S3中的文件名以`RC_YYYY-MM`开头,其中`YYYY-MM`的范围为`2005-12`到`2023-02`。然而,压缩格式有几次变化,因此文件扩展名不一致。例如: - -- 文件名最初是`RC_2005-12.bz2`到`RC_2017-11.bz2` -- 然后它们的格式是`RC_2017-12.xz`到`RC_2018-09.xz` -- 最终是`RC_2018-10.zst`到`RC_2023-02.zst` -::: - - -## 加载数据 {#load-data} - -2. 以下文件包含2017年12月的8600万条记录: - -```sql -INSERT INTO reddit - SELECT * - FROM s3( - 'https://your-bucket.s3.amazonaws.com/reddit/original/RC_2017-12.xz', - 'JSONEachRow' - ); - -``` - -3. 这将花费一些时间,具体取决于您的资源,但完成后请验证它是否成功: - -```sql -SELECT formatReadableQuantity(count()) -FROM reddit; -``` - -```response -┌─formatReadableQuantity(count())─┐ -│ 85.97 million │ -└─────────────────────────────────┘ -``` - -4. 让我们看看2017年12月有多少个唯一子版块: - -```sql -SELECT uniqExact(subreddit) -FROM reddit; -``` - -```response -┌─uniqExact(subreddit)─┐ -│ 91613 │ -└──────────────────────┘ - -1 row in set. Elapsed: 1.572 sec. Processed 85.97 million rows, 367.43 MB (54.71 million rows/s., 233.80 MB/s.) -``` - -## 示例查询 {#example-queries} - -5. 此查询返回评论数量最多的前10个子版块: - -```sql -SELECT - subreddit, - count() AS c -FROM reddit -GROUP BY subreddit -ORDER BY c DESC -LIMIT 20; -``` - -```response -┌─subreddit───────┬───────c─┐ -│ AskReddit │ 5245881 │ -│ politics │ 1753120 │ -│ nfl │ 1220266 │ -│ nba │ 960388 │ -│ The_Donald │ 931857 │ -│ news │ 796617 │ -│ worldnews │ 765709 │ -│ CFB │ 710360 │ -│ gaming │ 602761 │ -│ movies │ 601966 │ -│ soccer │ 590628 │ -│ Bitcoin │ 583783 │ -│ pics │ 563408 │ -│ StarWars │ 562514 │ -│ funny │ 547563 │ -│ leagueoflegends │ 517213 │ -│ teenagers │ 492020 │ -│ DestinyTheGame │ 477377 │ -│ todayilearned │ 472650 │ -│ videos │ 450581 │ -└─────────────────┴─────────┘ - -20 rows in set. Elapsed: 0.368 sec. Processed 85.97 million rows, 367.43 MB (233.34 million rows/s., 997.25 MB/s.) -``` - -6. 这里是2017年12月以发表评论数量计的前10位作者: - -```sql -SELECT - author, - count() AS c -FROM reddit -GROUP BY author -ORDER BY c DESC -LIMIT 10; -``` - -```response -┌─author──────────┬───────c─┐ -│ [deleted] │ 5913324 │ -│ AutoModerator │ 784886 │ -│ ImagesOfNetwork │ 83241 │ -│ BitcoinAllBot │ 54484 │ -│ imguralbumbot │ 45822 │ -│ RPBot │ 29337 │ -│ WikiTextBot │ 25982 │ -│ Concise_AMA_Bot │ 19974 │ -│ MTGCardFetcher │ 19103 │ -│ TotesMessenger │ 19057 │ -└─────────────────┴─────────┘ - -10 rows in set. Elapsed: 8.143 sec. Processed 85.97 million rows, 711.05 MB (10.56 million rows/s., 87.32 MB/s.) -``` - -## 加载整个数据集 {#loading-the-entire-dataset} - -7. 我们已经插入了一些数据,但我们将重新开始: - -```sql -TRUNCATE TABLE reddit; -``` - -8. 这是一个有趣的数据集,看起来我们可以找到一些很好的信息,所以让我们继续插入2005年至2023年的整个数据集。出于实际考虑,从每年开始插入数据是一个不错的选择... - -```sql -INSERT INTO reddit - SELECT * - FROM s3Cluster( - 'default', - 'https://your-bucket.s3.amazonaws.com/reddit/original/RC_2005*', - 'JSONEachRow' - ) - SETTINGS zstd_window_log_max = 31; -``` - -...并以以下内容结束: - -```sql -INSERT INTO reddit -SELECT * -FROM s3Cluster( - 'default', - 'https://your-bucket.s3.amazonaws.com/reddit/original/RC_2023*', - 'JSONEachRow' - ) -SETTINGS zstd_window_log_max = 31; -``` - -如果您没有集群,请使用`s3`而不是`s3Cluster`: - -```sql -INSERT INTO reddit -SELECT * -FROM s3( - 'https://your-bucket.s3.amazonaws.com/reddit/original/RC_2005*', - 'JSONEachRow' - ) -SETTINGS zstd_window_log_max = 31; -``` - -8. 为了验证插入是否成功,这里是每年的行数(截至2023年2月): - -```sql -SELECT - toYear(created_utc) AS year, - formatReadableQuantity(count()) -FROM reddit -GROUP BY year; -``` - -```response - -┌─year─┬─formatReadableQuantity(count())─┐ -│ 2005 │ 1.07 thousand │ -│ 2006 │ 417.18 thousand │ -│ 2007 │ 2.46 million │ -│ 2008 │ 7.24 million │ -│ 2009 │ 18.86 million │ -│ 2010 │ 42.93 million │ -│ 2011 │ 28.91 million │ -│ 2012 │ 260.31 million │ -│ 2013 │ 402.21 million │ -│ 2014 │ 531.80 million │ -│ 2015 │ 667.76 million │ -│ 2016 │ 799.90 million │ -│ 2017 │ 972.86 million │ -│ 2018 │ 1.24 billion │ -│ 2019 │ 1.66 billion │ -│ 2020 │ 2.16 billion │ -│ 2021 │ 2.59 billion │ -│ 2022 │ 2.82 billion │ -│ 2023 │ 474.86 million │ -└──────┴─────────────────────────────────┘ -``` - -9. 让我们看看插入了多少行,以及表占用了多少磁盘空间: - -```sql -SELECT - sum(rows) AS count, - formatReadableQuantity(count), - formatReadableSize(sum(bytes)) AS disk_size, - formatReadableSize(sum(data_uncompressed_bytes)) AS uncompressed_size -FROM system.parts -WHERE (table = 'reddit') AND active; -``` - -请注意,磁盘存储的压缩率约为未压缩大小的1/3: - -```response -┌───────count─┬─formatReadableQuantity(sum(rows))─┬─disk_size─┬─uncompressed_size─┐ -│ 14688534662 │ 14.69 billion │ 1.03 TiB │ 3.26 TiB │ -└─────────────┴───────────────────────────────────┴───────────┴───────────────────┘ - -1 row in set. Elapsed: 0.005 sec. -``` - -## 示例查询 - 每月的评论、作者和子版块 {#example-query-comments} - -10. 以下查询显示我们每个月有多少评论、作者和子版块: - -```sql -SELECT - toStartOfMonth(created_utc) AS firstOfMonth, - count() AS c, - bar(c, 0, 50000000, 25) AS bar_count, - uniq(author) AS authors, - bar(authors, 0, 5000000, 25) AS bar_authors, - uniq(subreddit) AS subreddits, - bar(subreddits, 0, 100000, 25) AS bar_subreddits -FROM reddit -GROUP BY firstOfMonth -ORDER BY firstOfMonth ASC; -``` - -这是一个大型查询,需要处理超过146.9亿行,但我们仍然获得了令人印象深刻的响应时间(约48秒): - -```response -┌─firstOfMonth─┬─────────c─┬─bar_count─────────────────┬──authors─┬─bar_authors───────────────┬─subreddits─┬─bar_subreddits────────────┐ -│ 2005-12-01 │ 1075 │ │ 394 │ │ 1 │ │ -│ 2006-01-01 │ 3666 │ │ 791 │ │ 2 │ │ -│ 2006-02-01 │ 9095 │ │ 1464 │ │ 18 │ │ -│ 2006-03-01 │ 13859 │ │ 1958 │ │ 15 │ │ -│ 2006-04-01 │ 19090 │ │ 2334 │ │ 21 │ │ -│ 2006-05-01 │ 26859 │ │ 2698 │ │ 21 │ │ -│ 2006-06-01 │ 29163 │ │ 3043 │ │ 19 │ │ -│ 2006-07-01 │ 37031 │ │ 3532 │ │ 22 │ │ -│ 2006-08-01 │ 50559 │ │ 4750 │ │ 24 │ │ -│ 2006-09-01 │ 50675 │ │ 4908 │ │ 21 │ │ -│ 2006-10-01 │ 54148 │ │ 5654 │ │ 31 │ │ -│ 2006-11-01 │ 62021 │ │ 6490 │ │ 23 │ │ -│ 2006-12-01 │ 61018 │ │ 6707 │ │ 24 │ │ -│ 2007-01-01 │ 81341 │ │ 7931 │ │ 23 │ │ -│ 2007-02-01 │ 95634 │ │ 9020 │ │ 21 │ │ -│ 2007-03-01 │ 112444 │ │ 10842 │ │ 23 │ │ -│ 2007-04-01 │ 126773 │ │ 10701 │ │ 26 │ │ -│ 2007-05-01 │ 170097 │ │ 11365 │ │ 25 │ │ -│ 2007-06-01 │ 178800 │ │ 11267 │ │ 22 │ │ -│ 2007-07-01 │ 203319 │ │ 12482 │ │ 25 │ │ -│ 2007-08-01 │ 225111 │ │ 14124 │ │ 30 │ │ -│ 2007-09-01 │ 259497 │ ▏ │ 15416 │ │ 33 │ │ -│ 2007-10-01 │ 274170 │ ▏ │ 15302 │ │ 36 │ │ -│ 2007-11-01 │ 372983 │ ▏ │ 15134 │ │ 43 │ │ -│ 2007-12-01 │ 363390 │ ▏ │ 15915 │ │ 31 │ │ -│ 2008-01-01 │ 452990 │ ▏ │ 18857 │ │ 126 │ │ -│ 2008-02-01 │ 441768 │ ▏ │ 18266 │ │ 173 │ │ -│ 2008-03-01 │ 463728 │ ▏ │ 18947 │ │ 292 │ │ -│ 2008-04-01 │ 468317 │ ▏ │ 18590 │ │ 323 │ │ -│ 2008-05-01 │ 536380 │ ▎ │ 20861 │ │ 375 │ │ -│ 2008-06-01 │ 577684 │ ▎ │ 22557 │ │ 575 │ ▏ │ -│ 2008-07-01 │ 592610 │ ▎ │ 23123 │ │ 657 │ ▏ │ -│ 2008-08-01 │ 595959 │ ▎ │ 23729 │ │ 707 │ ▏ │ -│ 2008-09-01 │ 680892 │ ▎ │ 26374 │ ▏ │ 801 │ ▏ │ -│ 2008-10-01 │ 789874 │ ▍ │ 28970 │ ▏ │ 893 │ ▏ │ -│ 2008-11-01 │ 792310 │ ▍ │ 30272 │ ▏ │ 1024 │ ▎ │ -│ 2008-12-01 │ 850359 │ ▍ │ 34073 │ ▏ │ 1103 │ ▎ │ -│ 2009-01-01 │ 1051649 │ ▌ │ 38978 │ ▏ │ 1316 │ ▎ │ -│ 2009-02-01 │ 944711 │ ▍ │ 43390 │ ▏ │ 1132 │ ▎ │ -│ 2009-03-01 │ 1048643 │ ▌ │ 46516 │ ▏ │ 1203 │ ▎ │ -│ 2009-04-01 │ 1094599 │ ▌ │ 48284 │ ▏ │ 1334 │ ▎ │ -│ 2009-05-01 │ 1201257 │ ▌ │ 52512 │ ▎ │ 1395 │ ▎ │ -│ 2009-06-01 │ 1258750 │ ▋ │ 57728 │ ▎ │ 1473 │ ▎ │ -│ 2009-07-01 │ 1470290 │ ▋ │ 60098 │ ▎ │ 1686 │ ▍ │ -│ 2009-08-01 │ 1750688 │ ▉ │ 67347 │ ▎ │ 1777 │ ▍ │ -│ 2009-09-01 │ 2032276 │ █ │ 78051 │ ▍ │ 1784 │ ▍ │ -│ 2009-10-01 │ 2242017 │ █ │ 93409 │ ▍ │ 2071 │ ▌ │ -│ 2009-11-01 │ 2207444 │ █ │ 95940 │ ▍ │ 2141 │ ▌ │ -│ 2009-12-01 │ 2560510 │ █▎ │ 104239 │ ▌ │ 2141 │ ▌ │ -│ 2010-01-01 │ 2884096 │ █▍ │ 114314 │ ▌ │ 2313 │ ▌ │ -│ 2010-02-01 │ 2687779 │ █▎ │ 115683 │ ▌ │ 2522 │ ▋ │ -│ 2010-03-01 │ 3228254 │ █▌ │ 125775 │ ▋ │ 2890 │ ▋ │ -│ 2010-04-01 │ 3209898 │ █▌ │ 128936 │ ▋ │ 3170 │ ▊ │ -│ 2010-05-01 │ 3267363 │ █▋ │ 131851 │ ▋ │ 3166 │ ▊ │ -│ 2010-06-01 │ 3532867 │ █▊ │ 139522 │ ▋ │ 3301 │ ▊ │ -│ 2010-07-01 │ 806612 │ ▍ │ 76486 │ ▍ │ 1955 │ ▍ │ -│ 2010-08-01 │ 4247982 │ ██ │ 164071 │ ▊ │ 3653 │ ▉ │ -│ 2010-09-01 │ 4704069 │ ██▎ │ 186613 │ ▉ │ 4009 │ █ │ -│ 2010-10-01 │ 5032368 │ ██▌ │ 203800 │ █ │ 4154 │ █ │ -│ 2010-11-01 │ 5689002 │ ██▊ │ 226134 │ █▏ │ 4383 │ █ │ -│ 2010-12-01 │ 3642690 │ █▊ │ 196847 │ ▉ │ 3914 │ ▉ │ -│ 2011-01-01 │ 3924540 │ █▉ │ 215057 │ █ │ 4240 │ █ │ -│ 2011-02-01 │ 3859131 │ █▉ │ 223485 │ █ │ 4371 │ █ │ -│ 2011-03-01 │ 2877996 │ █▍ │ 208607 │ █ │ 3870 │ ▉ │ -│ 2011-04-01 │ 3859131 │ █▉ │ 248931 │ █▏ │ 4881 │ █▏ │ -│ 2011-06-01 │ 3859131 │ █▉ │ 267197 │ █▎ │ 5255 │ █▎ │ -│ 2011-08-01 │ 2943405 │ █▍ │ 259428 │ █▎ │ 5806 │ █▍ │ -│ 2011-10-01 │ 3859131 │ █▉ │ 327342 │ █▋ │ 6958 │ █▋ │ -│ 2011-12-01 │ 3728313 │ █▊ │ 354817 │ █▊ │ 7713 │ █▉ │ -│ 2012-01-01 │ 16350205 │ ████████▏ │ 696110 │ ███▍ │ 14281 │ ███▌ │ -│ 2012-02-01 │ 16015695 │ ████████ │ 722892 │ ███▌ │ 14949 │ ███▋ │ -│ 2012-03-01 │ 17881943 │ ████████▉ │ 789664 │ ███▉ │ 15795 │ ███▉ │ -│ 2012-04-01 │ 19044534 │ █████████▌ │ 842491 │ ████▏ │ 16440 │ ████ │ -│ 2012-05-01 │ 20388260 │ ██████████▏ │ 886176 │ ████▍ │ 16974 │ ████▏ │ -│ 2012-06-01 │ 21897913 │ ██████████▉ │ 946798 │ ████▋ │ 17952 │ ████▍ │ -│ 2012-07-01 │ 24087517 │ ████████████ │ 1018636 │ █████ │ 19069 │ ████▊ │ -│ 2012-08-01 │ 25703326 │ ████████████▊ │ 1094445 │ █████▍ │ 20553 │ █████▏ │ -│ 2012-09-01 │ 23419524 │ ███████████▋ │ 1088491 │ █████▍ │ 20831 │ █████▏ │ -│ 2012-10-01 │ 24788236 │ ████████████▍ │ 1131885 │ █████▋ │ 21868 │ █████▍ │ -│ 2012-11-01 │ 24648302 │ ████████████▎ │ 1167608 │ █████▊ │ 21791 │ █████▍ │ -│ 2012-12-01 │ 26080276 │ █████████████ │ 1218402 │ ██████ │ 22622 │ █████▋ │ -│ 2013-01-01 │ 30365867 │ ███████████████▏ │ 1341703 │ ██████▋ │ 24696 │ ██████▏ │ -│ 2013-02-01 │ 27213960 │ █████████████▌ │ 1304756 │ ██████▌ │ 24514 │ ██████▏ │ -│ 2013-03-01 │ 30771274 │ ███████████████▍ │ 1391703 │ ██████▉ │ 25730 │ ██████▍ │ -│ 2013-04-01 │ 33259557 │ ████████████████▋ │ 1485971 │ ███████▍ │ 27294 │ ██████▊ │ -│ 2013-05-01 │ 33126225 │ ████████████████▌ │ 1506473 │ ███████▌ │ 27299 │ ██████▊ │ -│ 2013-06-01 │ 32648247 │ ████████████████▎ │ 1506650 │ ███████▌ │ 27450 │ ██████▊ │ -│ 2013-07-01 │ 34922133 │ █████████████████▍ │ 1561771 │ ███████▊ │ 28294 │ ███████ │ -│ 2013-08-01 │ 34766579 │ █████████████████▍ │ 1589781 │ ███████▉ │ 28943 │ ███████▏ │ -│ 2013-09-01 │ 31990369 │ ███████████████▉ │ 1570342 │ ███████▊ │ 29408 │ ███████▎ │ -│ 2013-10-01 │ 35940040 │ █████████████████▉ │ 1683770 │ ████████▍ │ 30273 │ ███████▌ │ -│ 2013-11-01 │ 37396497 │ ██████████████████▋ │ 1757467 │ ████████▊ │ 31173 │ ███████▊ │ -│ 2013-12-01 │ 39810216 │ ███████████████████▉ │ 1846204 │ █████████▏ │ 32326 │ ████████ │ -│ 2014-01-01 │ 42420655 │ █████████████████████▏ │ 1927229 │ █████████▋ │ 35603 │ ████████▉ │ -│ 2014-02-01 │ 38703362 │ ███████████████████▎ │ 1874067 │ █████████▎ │ 37007 │ █████████▎ │ -│ 2014-03-01 │ 42459956 │ █████████████████████▏ │ 1959888 │ █████████▊ │ 37948 │ █████████▍ │ -│ 2014-04-01 │ 42440735 │ █████████████████████▏ │ 1951369 │ █████████▊ │ 38362 │ █████████▌ │ -│ 2014-05-01 │ 42514094 │ █████████████████████▎ │ 1970197 │ █████████▊ │ 39078 │ █████████▊ │ -│ 2014-06-01 │ 41990650 │ ████████████████████▉ │ 1943850 │ █████████▋ │ 38268 │ █████████▌ │ -│ 2014-07-01 │ 46868899 │ ███████████████████████▍ │ 2059346 │ ██████████▎ │ 40634 │ ██████████▏ │ -│ 2014-08-01 │ 46990813 │ ███████████████████████▍ │ 2117335 │ ██████████▌ │ 41764 │ ██████████▍ │ -│ 2014-09-01 │ 44992201 │ ██████████████████████▍ │ 2124708 │ ██████████▌ │ 41890 │ ██████████▍ │ -│ 2014-10-01 │ 47497520 │ ███████████████████████▋ │ 2206535 │ ███████████ │ 43109 │ ██████████▊ │ -│ 2014-11-01 │ 46118074 │ ███████████████████████ │ 2239747 │ ███████████▏ │ 43718 │ ██████████▉ │ -│ 2014-12-01 │ 48807699 │ ████████████████████████▍ │ 2372945 │ ███████████▊ │ 43823 │ ██████████▉ │ -│ 2015-01-01 │ 53851542 │ █████████████████████████ │ 2499536 │ ████████████▍ │ 47172 │ ███████████▊ │ -│ 2015-02-01 │ 48342747 │ ████████████████████████▏ │ 2448496 │ ████████████▏ │ 47229 │ ███████████▊ │ -│ 2015-03-01 │ 54564441 │ █████████████████████████ │ 2550534 │ ████████████▊ │ 48156 │ ████████████ │ -│ 2015-04-01 │ 55005780 │ █████████████████████████ │ 2609443 │ █████████████ │ 49865 │ ████████████▍ │ -│ 2015-05-01 │ 54504410 │ █████████████████████████ │ 2585535 │ ████████████▉ │ 50137 │ ████████████▌ │ -│ 2015-06-01 │ 54258492 │ █████████████████████████ │ 2595129 │ ████████████▉ │ 49598 │ ████████████▍ │ -│ 2015-07-01 │ 58451788 │ █████████████████████████ │ 2720026 │ █████████████▌ │ 55022 │ █████████████▊ │ -│ 2015-08-01 │ 58075327 │ █████████████████████████ │ 2743994 │ █████████████▋ │ 55302 │ █████████████▊ │ -│ 2015-09-01 │ 55574825 │ █████████████████████████ │ 2672793 │ █████████████▎ │ 53960 │ █████████████▍ │ -│ 2015-10-01 │ 59494045 │ █████████████████████████ │ 2816426 │ ██████████████ │ 70210 │ █████████████████▌ │ -│ 2015-11-01 │ 57117500 │ █████████████████████████ │ 2847146 │ ██████████████▏ │ 71363 │ █████████████████▊ │ -│ 2015-12-01 │ 58523312 │ █████████████████████████ │ 2854840 │ ██████████████▎ │ 94559 │ ███████████████████████▋ │ -│ 2016-01-01 │ 61991732 │ █████████████████████████ │ 2920366 │ ██████████████▌ │ 108438 │ █████████████████████████ │ -│ 2016-02-01 │ 59189875 │ █████████████████████████ │ 2854683 │ ██████████████▎ │ 109916 │ █████████████████████████ │ -│ 2016-03-01 │ 63918864 │ █████████████████████████ │ 2969542 │ ██████████████▊ │ 84787 │ █████████████████████▏ │ -│ 2016-04-01 │ 64271256 │ █████████████████████████ │ 2999086 │ ██████████████▉ │ 61647 │ ███████████████▍ │ -│ 2016-05-01 │ 65212004 │ █████████████████████████ │ 3034674 │ ███████████████▏ │ 67465 │ ████████████████▊ │ -│ 2016-06-01 │ 65867743 │ █████████████████████████ │ 3057604 │ ███████████████▎ │ 75170 │ ██████████████████▊ │ -│ 2016-07-01 │ 66974735 │ █████████████████████████ │ 3199374 │ ███████████████▉ │ 77732 │ ███████████████████▍ │ -│ 2016-08-01 │ 69654819 │ █████████████████████████ │ 3239957 │ ████████████████▏ │ 63080 │ ███████████████▊ │ -│ 2016-09-01 │ 67024973 │ █████████████████████████ │ 3190864 │ ███████████████▉ │ 62324 │ ███████████████▌ │ -│ 2016-10-01 │ 71826553 │ █████████████████████████ │ 3284340 │ ████████████████▍ │ 62549 │ ███████████████▋ │ -│ 2016-11-01 │ 71022319 │ █████████████████████████ │ 3300822 │ ████████████████▌ │ 69718 │ █████████████████▍ │ -│ 2016-12-01 │ 72942967 │ █████████████████████████ │ 3430324 │ █████████████████▏ │ 71705 │ █████████████████▉ │ -│ 2017-01-01 │ 78946585 │ █████████████████████████ │ 3572093 │ █████████████████▊ │ 78198 │ ███████████████████▌ │ -│ 2017-02-01 │ 70609487 │ █████████████████████████ │ 3421115 │ █████████████████ │ 69823 │ █████████████████▍ │ -│ 2017-03-01 │ 79723106 │ █████████████████████████ │ 3638122 │ ██████████████████▏ │ 73865 │ ██████████████████▍ │ -│ 2017-04-01 │ 77478009 │ █████████████████████████ │ 3620591 │ ██████████████████ │ 74387 │ ██████████████████▌ │ -│ 2017-05-01 │ 79810360 │ █████████████████████████ │ 3650820 │ ██████████████████▎ │ 74356 │ ██████████████████▌ │ -│ 2017-06-01 │ 79901711 │ █████████████████████████ │ 3737614 │ ██████████████████▋ │ 72114 │ ██████████████████ │ -│ 2017-07-01 │ 81798725 │ █████████████████████████ │ 3872330 │ ███████████████████▎ │ 76052 │ ███████████████████ │ -│ 2017-08-01 │ 84658503 │ █████████████████████████ │ 3960093 │ ███████████████████▊ │ 77798 │ ███████████████████▍ │ -│ 2017-09-01 │ 83165192 │ █████████████████████████ │ 3880501 │ ███████████████████▍ │ 78402 │ ███████████████████▌ │ -│ 2017-10-01 │ 85828912 │ █████████████████████████ │ 3980335 │ ███████████████████▉ │ 80685 │ ████████████████████▏ │ -│ 2017-11-01 │ 84965681 │ █████████████████████████ │ 4026749 │ ████████████████████▏ │ 82659 │ ████████████████████▋ │ -│ 2017-12-01 │ 85973810 │ █████████████████████████ │ 4196354 │ ████████████████████▉ │ 91984 │ ██████████████████████▉ │ -│ 2018-01-01 │ 91558594 │ █████████████████████████ │ 4364443 │ █████████████████████▊ │ 102577 │ █████████████████████████ │ -│ 2018-02-01 │ 86467179 │ █████████████████████████ │ 4277899 │ █████████████████████▍ │ 104610 │ █████████████████████████ │ -│ 2018-03-01 │ 96490262 │ █████████████████████████ │ 4422470 │ ██████████████████████ │ 112559 │ █████████████████████████ │ -│ 2018-04-01 │ 98101232 │ █████████████████████████ │ 4572434 │ ██████████████████████▊ │ 105284 │ █████████████████████████ │ -│ 2018-05-01 │ 100109100 │ █████████████████████████ │ 4698908 │ ███████████████████████▍ │ 103910 │ █████████████████████████ │ -│ 2018-06-01 │ 100009462 │ █████████████████████████ │ 4697426 │ ███████████████████████▍ │ 101107 │ █████████████████████████ │ -│ 2018-07-01 │ 108151359 │ █████████████████████████ │ 5099492 │ █████████████████████████ │ 106184 │ █████████████████████████ │ -│ 2018-08-01 │ 107330940 │ █████████████████████████ │ 5084082 │ █████████████████████████ │ 109985 │ █████████████████████████ │ -│ 2018-09-01 │ 104473929 │ █████████████████████████ │ 5011953 │ █████████████████████████ │ 109710 │ █████████████████████████ │ -│ 2018-10-01 │ 112346556 │ █████████████████████████ │ 5320405 │ █████████████████████████ │ 112533 │ █████████████████████████ │ -│ 2018-11-01 │ 112573001 │ █████████████████████████ │ 5353282 │ █████████████████████████ │ 112211 │ █████████████████████████ │ -│ 2018-12-01 │ 121953600 │ █████████████████████████ │ 5611543 │ █████████████████████████ │ 118291 │ █████████████████████████ │ -│ 2019-01-01 │ 129386587 │ █████████████████████████ │ 6016687 │ █████████████████████████ │ 125725 │ █████████████████████████ │ -│ 2019-02-01 │ 120645639 │ █████████████████████████ │ 5974488 │ █████████████████████████ │ 125420 │ █████████████████████████ │ -│ 2019-03-01 │ 137650471 │ █████████████████████████ │ 6410197 │ █████████████████████████ │ 135924 │ █████████████████████████ │ -│ 2019-04-01 │ 138473643 │ █████████████████████████ │ 6416384 │ █████████████████████████ │ 139844 │ █████████████████████████ │ -│ 2019-05-01 │ 142463421 │ █████████████████████████ │ 6574836 │ █████████████████████████ │ 142012 │ █████████████████████████ │ -│ 2019-06-01 │ 134172939 │ █████████████████████████ │ 6601267 │ █████████████████████████ │ 140997 │ █████████████████████████ │ -│ 2019-07-01 │ 145965083 │ █████████████████████████ │ 6901822 │ █████████████████████████ │ 147802 │ █████████████████████████ │ -│ 2019-08-01 │ 146854393 │ █████████████████████████ │ 6993882 │ █████████████████████████ │ 151888 │ █████████████████████████ │ -│ 2019-09-01 │ 137540219 │ █████████████████████████ │ 7001362 │ █████████████████████████ │ 148839 │ █████████████████████████ │ -│ 2019-10-01 │ 145909884 │ █████████████████████████ │ 7160126 │ █████████████████████████ │ 152075 │ █████████████████████████ │ -│ 2019-11-01 │ 138512489 │ █████████████████████████ │ 7098723 │ █████████████████████████ │ 164597 │ █████████████████████████ │ -│ 2019-12-01 │ 146012313 │ █████████████████████████ │ 7438261 │ █████████████████████████ │ 166966 │ █████████████████████████ │ -│ 2020-01-01 │ 153498208 │ █████████████████████████ │ 7703548 │ █████████████████████████ │ 174390 │ █████████████████████████ │ -│ 2020-02-01 │ 148386817 │ █████████████████████████ │ 7582031 │ █████████████████████████ │ 170257 │ █████████████████████████ │ -│ 2020-03-01 │ 166266315 │ █████████████████████████ │ 8339049 │ █████████████████████████ │ 192460 │ █████████████████████████ │ -│ 2020-04-01 │ 178511581 │ █████████████████████████ │ 8991649 │ █████████████████████████ │ 202334 │ █████████████████████████ │ -│ 2020-05-01 │ 189993779 │ █████████████████████████ │ 9331358 │ █████████████████████████ │ 217357 │ █████████████████████████ │ -│ 2020-06-01 │ 187914434 │ █████████████████████████ │ 9085003 │ █████████████████████████ │ 223362 │ █████████████████████████ │ -│ 2020-07-01 │ 194244994 │ █████████████████████████ │ 9321706 │ █████████████████████████ │ 228222 │ █████████████████████████ │ -│ 2020-08-01 │ 196099301 │ █████████████████████████ │ 9368408 │ █████████████████████████ │ 230251 │ █████████████████████████ │ -│ 2020-09-01 │ 182549761 │ █████████████████████████ │ 9271571 │ █████████████████████████ │ 227889 │ █████████████████████████ │ -│ 2020-10-01 │ 186583890 │ █████████████████████████ │ 9396112 │ █████████████████████████ │ 233715 │ █████████████████████████ │ -│ 2020-11-01 │ 186083723 │ █████████████████████████ │ 9623053 │ █████████████████████████ │ 234963 │ █████████████████████████ │ -│ 2020-12-01 │ 191317162 │ █████████████████████████ │ 9898168 │ █████████████████████████ │ 249115 │ █████████████████████████ │ -│ 2021-01-01 │ 210496207 │ █████████████████████████ │ 10503943 │ █████████████████████████ │ 259805 │ █████████████████████████ │ -│ 2021-02-01 │ 193510365 │ █████████████████████████ │ 10215033 │ █████████████████████████ │ 253656 │ █████████████████████████ │ -│ 2021-03-01 │ 207454415 │ █████████████████████████ │ 10365629 │ █████████████████████████ │ 267263 │ █████████████████████████ │ -│ 2021-04-01 │ 204573086 │ █████████████████████████ │ 10391984 │ █████████████████████████ │ 270543 │ █████████████████████████ │ -│ 2021-05-01 │ 217655366 │ █████████████████████████ │ 10648130 │ █████████████████████████ │ 288555 │ █████████████████████████ │ -│ 2021-06-01 │ 208027069 │ █████████████████████████ │ 10397311 │ █████████████████████████ │ 291520 │ █████████████████████████ │ -│ 2021-07-01 │ 210955954 │ █████████████████████████ │ 10063967 │ █████████████████████████ │ 252061 │ █████████████████████████ │ -│ 2021-08-01 │ 225681244 │ █████████████████████████ │ 10383556 │ █████████████████████████ │ 254569 │ █████████████████████████ │ -│ 2021-09-01 │ 220086513 │ █████████████████████████ │ 10298344 │ █████████████████████████ │ 256826 │ █████████████████████████ │ -│ 2021-10-01 │ 227527379 │ █████████████████████████ │ 10729882 │ █████████████████████████ │ 283328 │ █████████████████████████ │ -│ 2021-11-01 │ 228289963 │ █████████████████████████ │ 10995197 │ █████████████████████████ │ 302386 │ █████████████████████████ │ -│ 2021-12-01 │ 235807471 │ █████████████████████████ │ 11312798 │ █████████████████████████ │ 313876 │ █████████████████████████ │ -│ 2022-01-01 │ 256766679 │ █████████████████████████ │ 12074520 │ █████████████████████████ │ 340407 │ █████████████████████████ │ -│ 2022-02-01 │ 219927645 │ █████████████████████████ │ 10846045 │ █████████████████████████ │ 293236 │ █████████████████████████ │ -│ 2022-03-01 │ 236554668 │ █████████████████████████ │ 11330285 │ █████████████████████████ │ 302387 │ █████████████████████████ │ -│ 2022-04-01 │ 231188077 │ █████████████████████████ │ 11697995 │ █████████████████████████ │ 316303 │ █████████████████████████ │ -│ 2022-05-01 │ 230492108 │ █████████████████████████ │ 11448584 │ █████████████████████████ │ 323725 │ █████████████████████████ │ -│ 2022-06-01 │ 218842949 │ █████████████████████████ │ 11400399 │ █████████████████████████ │ 324846 │ █████████████████████████ │ -│ 2022-07-01 │ 242504279 │ █████████████████████████ │ 12049204 │ █████████████████████████ │ 335621 │ █████████████████████████ │ -│ 2022-08-01 │ 247215325 │ █████████████████████████ │ 12189276 │ █████████████████████████ │ 337873 │ █████████████████████████ │ -│ 2022-09-01 │ 234131223 │ █████████████████████████ │ 11674079 │ █████████████████████████ │ 326325 │ █████████████████████████ │ -│ 2022-10-01 │ 237365072 │ █████████████████████████ │ 11804508 │ █████████████████████████ │ 336063 │ █████████████████████████ │ -│ 2022-11-01 │ 229478878 │ █████████████████████████ │ 11543020 │ █████████████████████████ │ 323122 │ █████████████████████████ │ -│ 2022-12-01 │ 238862690 │ █████████████████████████ │ 11967451 │ █████████████████████████ │ 331668 │ █████████████████████████ │ -│ 2023-01-01 │ 253577512 │ █████████████████████████ │ 12264087 │ █████████████████████████ │ 332711 │ █████████████████████████ │ -│ 2023-02-01 │ 221285501 │ █████████████████████████ │ 11537091 │ █████████████████████████ │ 317879 │ █████████████████████████ │ -└──────────────┴───────────┴───────────────────────────┴──────────┴───────────────────────────┴────────────┴───────────────────────────┘ - -203 rows in set. Elapsed: 48.492 sec. Processed 14.69 billion rows, 213.35 GB (302.91 million rows/s., 4.40 GB/s.) -``` - -## 更多查询 {#more-queries} - -11. 这里是2022年的前10个子版块: - -```sql -SELECT - subreddit, - count() AS count -FROM reddit -WHERE toYear(created_utc) = 2022 -GROUP BY subreddit -ORDER BY count DESC -LIMIT 10; -``` - -```response -┌─subreddit──────┬────count─┐ -│ AskReddit │ 72312060 │ -│ AmItheAsshole │ 25323210 │ -│ teenagers │ 22355960 │ -│ worldnews │ 17797707 │ -│ FreeKarma4U │ 15652274 │ -│ FreeKarma4You │ 14929055 │ -│ wallstreetbets │ 14235271 │ -│ politics │ 12511136 │ -│ memes │ 11610792 │ -│ nba │ 11586571 │ -└────────────────┴──────────┘ - -10 rows in set. Elapsed: 5.956 sec. Processed 14.69 billion rows, 126.19 GB (2.47 billion rows/s., 21.19 GB/s.) -``` - -12. 让我们看看在2018到2019年间,哪些子版块的评论数量增长最大: - -```sql -SELECT - subreddit, - newcount - oldcount AS diff -FROM -( - SELECT - subreddit, - count(*) AS newcount - FROM reddit - WHERE toYear(created_utc) = 2019 - GROUP BY subreddit -) -ALL INNER JOIN -( - SELECT - subreddit, - count(*) AS oldcount - FROM reddit - WHERE toYear(created_utc) = 2018 - GROUP BY subreddit -) USING (subreddit) -ORDER BY diff DESC -LIMIT 50 -SETTINGS joined_subquery_requires_alias = 0; -``` - -看起来2019年,表情包和青少年在Reddit上相当活跃: - -```response -┌─subreddit────────────┬─────diff─┐ -│ AskReddit │ 18765909 │ -│ memes │ 16496996 │ -│ teenagers │ 13071715 │ -│ AmItheAsshole │ 12312663 │ -│ dankmemes │ 12016716 │ -│ unpopularopinion │ 6809935 │ -│ PewdiepieSubmissions │ 6330844 │ -│ Market76 │ 5213690 │ -│ relationship_advice │ 4060717 │ -│ Minecraft │ 3328659 │ -│ freefolk │ 3227970 │ -│ classicwow │ 3063133 │ -│ Animemes │ 2866876 │ -│ gonewild │ 2457680 │ -│ PublicFreakout │ 2452288 │ -│ gameofthrones │ 2411661 │ -│ RoastMe │ 2378781 │ -│ ShitPostCrusaders │ 2345414 │ -│ AnthemTheGame │ 1813152 │ -│ nfl │ 1804407 │ -│ Showerthoughts │ 1797968 │ -│ Cringetopia │ 1764034 │ -│ pokemon │ 1763269 │ -│ entitledparents │ 1744852 │ -│ HistoryMemes │ 1721645 │ -│ MortalKombat │ 1718184 │ -│ trashy │ 1684357 │ -│ ChapoTrapHouse │ 1675363 │ -│ Brawlstars │ 1663763 │ -│ iamatotalpieceofshit │ 1647381 │ -│ ukpolitics │ 1599204 │ -│ cursedcomments │ 1590781 │ -│ Pikabu │ 1578597 │ -│ wallstreetbets │ 1535225 │ -│ AskOuija │ 1533214 │ -│ interestingasfuck │ 1528910 │ -│ aww │ 1439008 │ -│ wholesomememes │ 1436566 │ -│ SquaredCircle │ 1432172 │ -│ insanepeoplefacebook │ 1290686 │ -│ borderlands3 │ 1274462 │ -│ FreeKarma4U │ 1217769 │ -│ YangForPresidentHQ │ 1186918 │ -│ FortniteCompetitive │ 1184508 │ -│ AskMen │ 1180820 │ -│ EpicSeven │ 1172061 │ -│ MurderedByWords │ 1112476 │ -│ politics │ 1084087 │ -│ barstoolsports │ 1068020 │ -│ BattlefieldV │ 1053878 │ -└──────────────────────┴──────────┘ - -50 rows in set. Elapsed: 10.680 sec. Processed 29.38 billion rows, 198.67 GB (2.75 billion rows/s., 18.60 GB/s.) -``` - -## 其他查询 {#other-queries} - -13. 还有一个查询:让我们比较ClickHouse的提及量与其他技术,如Snowflake和Postgres。这个查询相当庞大,因为它需要对146.9亿条评论中的子串进行三次搜索,但性能实在相当令人印象深刻。(不幸的是,ClickHouse用户在Reddit上尚未非常活跃): - -```sql -SELECT - toStartOfQuarter(created_utc) AS quarter, - sum(if(positionCaseInsensitive(body, 'clickhouse') > 0, 1, 0)) AS clickhouse, - sum(if(positionCaseInsensitive(body, 'snowflake') > 0, 1, 0)) AS snowflake, - sum(if(positionCaseInsensitive(body, 'postgres') > 0, 1, 0)) AS postgres -FROM reddit -GROUP BY quarter -ORDER BY quarter ASC; -``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/reddit-comments.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/reddit-comments.md.hash deleted file mode 100644 index a1afa4874be..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/reddit-comments.md.hash +++ /dev/null @@ -1 +0,0 @@ -888c2a36d26a9f0b diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/stackoverflow.md b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/stackoverflow.md index 0f691fbf18d..801744ca461 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/stackoverflow.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/stackoverflow.md @@ -1,36 +1,37 @@ --- -'description': '使用 ClickHouse 分析 Stack Overflow 数据' +'description': '使用ClickHouse分析Stack Overflow数据' 'sidebar_label': 'Stack Overflow' 'sidebar_position': 1 'slug': '/getting-started/example-datasets/stackoverflow' -'title': '使用 ClickHouse 分析 Stack Overflow 数据' +'title': '使用ClickHouse分析Stack Overflow数据' 'keywords': - 'StackOverflow' 'show_related_blogs': true +'doc_type': 'reference' --- import Image from '@theme/IdealImage'; import stackoverflow from '@site/static/images/getting-started/example-datasets/stackoverflow.png' -这个数据集包含了 Stack Overflow 上发生的所有 `Posts`, `Users`, `Votes`, `Comments`, `Badges`, `PostHistory`, 和 `PostLinks`。 +该数据集包含在 Stack Overflow 上发生的所有 `Posts`、`Users`、`Votes`、`Comments`、`Badges`、`PostHistory` 和 `PostLinks`。 -用户可以下载预先准备好的 Parquet 版本的数据,该版本包含截至 2024 年 4 月的所有帖子,或下载最新的 XML 格式数据并加载。Stack Overflow 定期提供此数据的更新 - 历史上每 3 个月更新一次。 +用户可以下载经过预处理的 Parquet 版本数据,这些数据包含截至 2024 年 4 月的每一篇帖子,或者下载最新的 XML 格式数据并加载。在历史上,Stack Overflow 定期提供这些数据更新——通常每 3 个月一次。 -以下图表展示了假设为 Parquet 格式的可用表的模式。 +以下图表显示了假设 Parquet 格式的可用表的架构。 -关于此数据模式的描述可以在 [这里](https://meta.stackexchange.com/questions/2677/database-schema-documentation-for-the-public-data-dump-and-sede) 找到。 +有关此数据架构的描述可以在 [这里](https://meta.stackexchange.com/questions/2677/database-schema-documentation-for-the-public-data-dump-and-sede) 找到。 ## 预准备数据 {#pre-prepared-data} -我们提供了这份数据的 Parquet 格式副本,更新截止到 2024 年 4 月。虽然对于 ClickHouse 而言行数不多(6000 万条帖子),但该数据集包含大量文本和大 String 列。 +我们提供这一数据的 Parquet 格式副本,最新版本截至 2024 年 4 月。尽管就行数(6000万条帖子)而言对于 ClickHouse 来说数据量较小,但该数据集包含大量文本和大的字符串列。 ```sql CREATE DATABASE stackoverflow ``` -以下时间记录适用于位于 `eu-west-2` 的 96 GiB,24 vCPU ClickHouse Cloud 集群。数据集位于 `eu-west-3`。 +以下时间为位于 `eu-west-2` 的 96 GiB、24 vCPU ClickHouse Cloud 集群的时间。数据集位于 `eu-west-3`。 ### Posts {#posts} @@ -69,7 +70,7 @@ INSERT INTO stackoverflow.posts SELECT * FROM s3('https://datasets-documentation 0 rows in set. Elapsed: 265.466 sec. Processed 59.82 million rows, 38.07 GB (225.34 thousand rows/s., 143.42 MB/s.) ``` -帖子也按年份提供,例如 [https://datasets-documentation.s3.eu-west-3.amazonaws.com/stackoverflow/parquet/posts/2020.parquet](https://datasets-documentation.s3.eu-west-3.amazonaws.com/stackoverflow/parquet/posts/2020.parquet) +帖子也可以按年份提供,例如 [https://datasets-documentation.s3.eu-west-3.amazonaws.com/stackoverflow/parquet/posts/2020.parquet](https://datasets-documentation.s3.eu-west-3.amazonaws.com/stackoverflow/parquet/posts/2020.parquet) ### Votes {#votes} @@ -91,7 +92,7 @@ INSERT INTO stackoverflow.votes SELECT * FROM s3('https://datasets-documentation 0 rows in set. Elapsed: 21.605 sec. Processed 238.98 million rows, 2.13 GB (11.06 million rows/s., 98.46 MB/s.) ``` -投票也按年份提供,例如 [https://datasets-documentation.s3.eu-west-3.amazonaws.com/stackoverflow/parquet/votes/2020.parquet](https://datasets-documentation.s3.eu-west-3.amazonaws.com/stackoverflow/parquet/votes/2020.parquet) +投票也可以按年份提供,例如 [https://datasets-documentation.s3.eu-west-3.amazonaws.com/stackoverflow/parquet/votes/2020.parquet](https://datasets-documentation.s3.eu-west-3.amazonaws.com/stackoverflow/parquet/votes/2020.parquet) ### Comments {#comments} @@ -114,7 +115,7 @@ INSERT INTO stackoverflow.comments SELECT * FROM s3('https://datasets-documentat 0 rows in set. Elapsed: 56.593 sec. Processed 90.38 million rows, 11.14 GB (1.60 million rows/s., 196.78 MB/s.) ``` -评论也按年份提供,例如 [https://datasets-documentation.s3.eu-west-3.amazonaws.com/stackoverflow/parquet/comments/2020.parquet](https://datasets-documentation.s3.eu-west-3.amazonaws.com/stackoverflow/parquet/comments/2020.parquet) +评论也可以按年份提供,例如 [https://datasets-documentation.s3.eu-west-3.amazonaws.com/stackoverflow/parquet/comments/2020.parquet](https://datasets-documentation.s3.eu-west-3.amazonaws.com/stackoverflow/parquet/comments/2020.parquet) ### Users {#users} @@ -207,7 +208,7 @@ INSERT INTO stackoverflow.posthistory SELECT * FROM s3('https://datasets-documen ## 原始数据集 {#original-dataset} -原始数据集以压缩(7zip)XML 格式可在 [https://archive.org/download/stackexchange](https://archive.org/download/stackexchange) 下载 - 文件前缀为 `stackoverflow.com*`。 +原始数据集以压缩的 (7zip) XML 格式可在 [https://archive.org/download/stackexchange](https://archive.org/download/stackexchange) 获取 - 文件前缀为 `stackoverflow.com*`。 ### 下载 {#download} @@ -221,13 +222,13 @@ wget https://archive.org/download/stackexchange/stackoverflow.com-Users.7z wget https://archive.org/download/stackexchange/stackoverflow.com-Votes.7z ``` -这些文件的大小可达 35GB,下载时间约为 30 分钟,具体取决于互联网连接 - 下载服务器的速度限制约为 20MB/sec。 +这些文件最大可达 35GB,下载时间约为 30 分钟,具体取决于网络连接 - 下载服务器的速度限制在约 20MB/秒。 ### 转换为 JSON {#convert-to-json} -截至目前,ClickHouse 不支持将 XML 作为输入格式。要将数据加载到 ClickHouse,我们首先将其转换为 NDJSON。 +在撰写时,ClickHouse 还不支持 XML 作为输入格式。为了将数据加载到 ClickHouse 中,我们首先将其转换为 NDJSON。 -为了将 XML 转换为 JSON,我们推荐使用 [`xq`](https://github.com/kislyuk/yq) Linux 工具,这是一个简单的 XML 文档的 `jq` 封装。 +要将 XML 转换为 JSON,我们推荐使用 [`xq`](https://github.com/kislyuk/yq) Linux 工具,这是一个用于 XML 文档的简单 `jq` 封装。 安装 xq 和 jq: @@ -236,11 +237,11 @@ sudo apt install jq pip install yq ``` -以下步骤适用于上述任意文件。我们以 `stackoverflow.com-Posts.7z` 文件为例。根据需要进行修改。 +以下步骤适用于上述任何文件。我们以 `stackoverflow.com-Posts.7z` 文件为例,按需修改。 -使用 [p7zip](https://p7zip.sourceforge.net/) 解压缩文件。这样将生成一个 XML 文件 - 在本例中为 `Posts.xml`。 +使用 [p7zip](https://p7zip.sourceforge.net/) 提取文件。这将生成一个 XML 文件 - 在此案例中为 `Posts.xml`。 -> 文件压缩比大约为 4.5x。在 22GB 压缩的情况下,帖子文件需要大约 97G 解压缩后。 +> 文件压缩比例约为4.5x。在22GB压缩后,帖子文件解压后需要大约97G。 ```bash p7zip -d stackoverflow.com-Posts.7z @@ -256,15 +257,15 @@ cd posts tail +3 ../Posts.xml | head -n -1 | split -l 10000 --filter='{ printf "\n"; cat - ; printf "\n"; } > $FILE' - ``` -在运行上述命令后,用户将得到一组文件,每个文件都有 10000 行。这确保下一条命令的内存开销不会过大(XML 到 JSON 的转换是在内存中完成的)。 +运行上述命令后,用户将获得一组每个包含 10000 行的文件。这确保了下一个命令的内存开销不会过大(XML 到 JSON 的转换是在内存中进行的)。 ```bash find . -maxdepth 1 -type f -exec xq -c '.rows.row[]' {} \; | sed -e 's:"@:":g' > posts_v2.json ``` -上述命令将生成一个 `posts.json` 文件。 +上述命令将生成一个名为 `posts.json` 的文件。 -使用以下命令将其加载到 ClickHouse 中。请注意,`posts.json` 文件的模式是特定的,这需要根据数据类型进行调整,以与目标表对齐。 +使用以下命令加载到 ClickHouse 中。请注意,为 `posts.json` 文件指定了架构。这需要根据数据类型进行调整,以便与目标表对齐。 ```bash clickhouse local --query "SELECT * FROM file('posts.json', JSONEachRow, 'Id Int32, PostTypeId UInt8, AcceptedAnswerId UInt32, CreationDate DateTime64(3, \'UTC\'), Score Int32, ViewCount UInt32, Body String, OwnerUserId Int32, OwnerDisplayName String, LastEditorUserId Int32, LastEditorDisplayName String, LastEditDate DateTime64(3, \'UTC\'), LastActivityDate DateTime64(3, \'UTC\'), Title String, Tags String, AnswerCount UInt16, CommentCount UInt8, FavoriteCount UInt8, ContentLicense String, ParentId String, CommunityOwnedDate DateTime64(3, \'UTC\'), ClosedDate DateTime64(3, \'UTC\')') FORMAT Native" | clickhouse client --host --secure --password --query "INSERT INTO stackoverflow.posts_v2 FORMAT Native" @@ -272,9 +273,9 @@ clickhouse local --query "SELECT * FROM file('posts.json', JSONEachRow, 'Id Int3 ## 示例查询 {#example-queries} -几个简单的问题,以帮助您入门。 +一些简单的问题供您入门。 -### Stack Overflow 上最流行的标签 {#most-popular-tags-on-stack-overflow} +### Stack Overflow 上最受欢迎的标签 {#most-popular-tags-on-stack-overflow} ```sql @@ -303,9 +304,9 @@ LIMIT 10 Peak memory usage: 224.03 MiB. ``` -### 拥有最多答案的用户(活跃账户) {#user-with-the-most-answers-active-accounts} +### 回答最多的用户(活跃账户) {#user-with-the-most-answers-active-accounts} -账户需要一个 `UserId`。 +账户需要 `UserId`。 ```sql SELECT @@ -329,7 +330,7 @@ LIMIT 5 Peak memory usage: 206.45 MiB. ``` -### 具有最多观看次数的与 ClickHouse 相关的帖子 {#clickhouse-related-posts-with-the-most-views} +### 点击屋相关帖子中浏览量最多的 {#clickhouse-related-posts-with-the-most-views} ```sql SELECT @@ -393,6 +394,6 @@ LIMIT 3 Peak memory usage: 6.05 GiB. ``` -## 署名 {#attribution} +## 归属 {#attribution} -我们感谢 Stack Overflow 根据 `cc-by-sa 4.0` 许可提供此数据,感谢他们的努力,以及数据的原始来源 [https://archive.org/details/stackexchange](https://archive.org/details/stackexchange)。 +我们感谢 Stack Overflow 在 `cc-by-sa 4.0` 许可下提供此数据,承认他们的努力以及数据的原始来源,链接为 [https://archive.org/details/stackexchange](https://archive.org/details/stackexchange)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/stackoverflow.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/stackoverflow.md.hash index 1b96de667a6..ccbc12f07bf 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/stackoverflow.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/stackoverflow.md.hash @@ -1 +1 @@ -d2dce3e57a22067f +a120c735386d06dc diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/star-schema.md b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/star-schema.md index ba67f79843f..a2a8282af70 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/star-schema.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/star-schema.md @@ -3,17 +3,18 @@ 'sidebar_label': '星型模式基准' 'slug': '/getting-started/example-datasets/star-schema' 'title': '星型模式基准 (SSB, 2009)' +'doc_type': 'reference' --- -星型模式基准大致基于[TPC-H](tpch.md)的表和查询,但与TPC-H不同,它使用星型模式布局。 -大部分数据位于一个巨大的事实表中,该表被多个小维度表环绕。 -查询将事实表与一个或多个维度表连接,以应用筛选条件,例如`MONTH = 'JANUARY'`。 +星型架构基准大致基于 [TPC-H](tpch.md) 的表和查询,但与 TPC-H 不同,它使用星型架构布局。 +大部分数据位于一个巨大的事实表中,周围环绕着多个小的维度表。 +查询通过将事实表与一个或多个维度表连接来应用过滤条件,例如 `MONTH = 'JANUARY'`。 参考文献: -- [Star Schema Benchmark](https://cs.umb.edu/~poneil/StarSchemaB.pdf) (O'Neil等人),2009 -- [Variations of the Star Schema Benchmark to Test the Effects of Data Skew on Query Performance](https://doi.org/10.1145/2479871.2479927) (Rabl等人),2013 +- [星型架构基准](https://cs.umb.edu/~poneil/StarSchemaB.pdf) (O'Neil et. al),2009 +- [测试数据倾斜对查询性能影响的星型架构基准的变体](https://doi.org/10.1145/2479871.2479927) (Rabl et. al.),2013 -首先,检查星型模式基准库并编译数据生成器: +首先,检查星型架构基准的代码库并编译数据生成器: ```bash git clone https://github.com/vadimtk/ssb-dbgen.git @@ -21,7 +22,7 @@ cd ssb-dbgen make ``` -然后,生成数据。参数`-s`指定比例因子。例如,使用`-s 100`时,生成6亿行数据。 +然后,生成数据。参数 `-s` 指定比例因子。例如,使用 `-s 100`,会生成 6 亿行。 ```bash ./dbgen -s 1000 -T c @@ -31,7 +32,7 @@ make ./dbgen -s 1000 -T d ``` -现在在ClickHouse中创建表: +现在在 ClickHouse 中创建表: ```sql CREATE TABLE customer @@ -128,8 +129,8 @@ clickhouse-client --query "INSERT INTO lineorder FORMAT CSV" < lineorder.tbl clickhouse-client --query "INSERT INTO date FORMAT CSV" < date.tbl ``` -在ClickHouse的许多用例中,多个表被转换为一个单一的非规范化平面表。 -这一步是可选的,下面的查询列出了其原始形式和为非规范化表重写的格式。 +在 ClickHouse 的许多用例中,多张表被转换为一个单一的去规范化平面表。 +这个步骤是可选的,下面的查询以其原始形式和为去规范化表重写的格式列出。 ```sql SET max_memory_usage = 20000000000; @@ -181,7 +182,7 @@ INNER JOIN supplier AS s ON s.S_SUPPKEY = l.LO_SUPPKEY INNER JOIN part AS p ON p.P_PARTKEY = l.LO_PARTKEY; ``` -查询通过`./qgen -s `生成。对于`s = 100`的示例查询: +查询由 `./qgen -s ` 生成。`s = 100` 的示例查询: Q1.1 @@ -198,7 +199,7 @@ WHERE AND LO_QUANTITY < 25; ``` -非规范化表: +去规范化表: ```sql SELECT @@ -226,7 +227,7 @@ WHERE AND LO_QUANTITY BETWEEN 26 AND 35; ``` -非规范化表: +去规范化表: ```sql SELECT @@ -255,7 +256,7 @@ WHERE AND LO_QUANTITY BETWEEN 26 AND 35; ``` -非规范化表: +去规范化表: ```sql SELECT @@ -295,7 +296,7 @@ ORDER BY P_BRAND; ``` -非规范化表: +去规范化表: ```sql SELECT @@ -341,7 +342,7 @@ ORDER BY P_BRAND; ``` -非规范化表: +去规范化表: ```sql SELECT @@ -384,7 +385,7 @@ ORDER BY P_BRAND; ``` -非规范化表: +去规范化表: ```sql SELECT @@ -429,7 +430,7 @@ ORDER BY REVENUE DESC; ``` -非规范化表: +去规范化表: ```sql SELECT @@ -481,7 +482,7 @@ ORDER BY REVENUE DESC; ``` -非规范化表: +去规范化表: ```sql SELECT @@ -534,7 +535,7 @@ ORDER BY revenue DESC; ``` -非规范化表: +去规范化表: ```sql SELECT @@ -586,7 +587,7 @@ ORDER BY revenue DESC; ``` -非规范化表: +去规范化表: ```sql SELECT @@ -637,7 +638,7 @@ ORDER BY C_NATION ``` -非规范化表: +去规范化表: ```sql SELECT @@ -687,7 +688,7 @@ ORDER BY P_CATEGORY ``` -非规范化表: +去规范化表: ```sql SELECT @@ -744,7 +745,7 @@ ORDER BY P_BRAND ``` -非规范化表: +去规范化表: ```sql SELECT diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/star-schema.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/star-schema.md.hash index 654eebe1dd5..ffc362d9312 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/star-schema.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/star-schema.md.hash @@ -1 +1 @@ -ae628edb1a80b92b +96c337d34bba8a27 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/tpcds.md b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/tpcds.md index 313e60e828d..5cca1e4bb23 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/tpcds.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/tpcds.md @@ -1,16 +1,17 @@ --- -'description': 'TPC-DS基准数据集和查询。' +'description': 'TPC-DS 基准数据集和查询。' 'sidebar_label': 'TPC-DS' 'slug': '/getting-started/example-datasets/tpcds' 'title': 'TPC-DS (2012)' +'doc_type': 'reference' --- -类似于 [Star Schema Benchmark (SSB)](star-schema.md),TPC-DS 基于 [TPC-H](tpch.md),但采取了相反的路线,即通过存储在复杂的雪花模式中扩展所需的连接数(24 个表而不是 8 个表)。数据分布是不均匀的(例如,正态分布和泊松分布)。它包含 99 个带有随机替换的报告和即席查询。 +类似于 [Star Schema Benchmark (SSB)](star-schema.md),TPC-DS 基于 [TPC-H](tpch.md),但采取了相反的路线,即通过存储在复杂的雪花模型中扩展所需的连接数量(24 张表而不是 8 张表)。数据分布存在偏斜(例如,正态分布和泊松分布)。它包括 99 个随机替换的报告和临时查询。 参考文献 -- [TPC-DS 的制作](https://dl.acm.org/doi/10.5555/1182635.1164217) (Nambiar), 2006 +- [TPC-DS 的创建](https://dl.acm.org/doi/10.5555/1182635.1164217) (Nambiar), 2006 -首先,检查 TPC-DS 存储库并编译数据生成器: +首先,检查 TPC-DS 仓库并编译数据生成器: ```bash git clone https://github.com/gregrahn/tpcds-kit.git @@ -18,19 +19,19 @@ cd tpcds-kit/tools make ``` -然后,生成数据。参数 `-scale` 指定了比例因子。 +然后,生成数据。参数 `-scale` 指定比例因子。 ```bash ./dsdgen -scale 1 ``` -接下来,生成查询(使用相同的比例因子): +接着,生成查询(使用相同的比例因子): ```bash ./dsqgen -DIRECTORY ../query_templates/ -INPUT ../query_templates/templates.lst -SCALE 1 # generates 99 queries in out/query_0.sql ``` -现在在 ClickHouse 中创建表。您可以使用 tools/tpcds.sql 中的原始表定义,或者使用经过“调优”的表定义,在适当的地方正确定义主键索引和 LowCardinality 类型的列类型。 +现在在 ClickHouse 中创建表。您可以使用 tools/tpcds.sql 中的原始表定义,或者在适当的地方使用正确定义的主键索引和 LowCardinality 类型的列的“调优”表定义。 ```sql CREATE TABLE call_center( @@ -254,7 +255,7 @@ CREATE TABLE inventory ( inv_date_sk UInt32, inv_item_sk Int64, inv_warehouse_sk Int64, - inv_quantity_on_hand Nullable(Int32) + inv_quantity_on_hand Nullable(Int32), PRIMARY KEY (inv_date_sk, inv_item_sk, inv_warehouse_sk), ); @@ -404,7 +405,7 @@ CREATE TABLE store ( s_zip LowCardinality(Nullable(String)), s_country LowCardinality(Nullable(String)), s_gmt_offset Nullable(Decimal(7,2)), - s_tax_precentage Nullable(Decimal(7,2)), + s_tax_percentage Nullable(Decimal(7,2)), PRIMARY KEY (s_store_sk) ); @@ -555,7 +556,7 @@ CREATE TABLE web_site ( ); ``` -数据可以如下导入: +数据可以按如下方式导入: ```bash clickhouse-client --format_csv_delimiter '|' --query "INSERT INTO call_center FORMAT CSV" < call_center.tbl @@ -587,5 +588,5 @@ clickhouse-client --format_csv_delimiter '|' --query "INSERT INTO web_site FORMA 然后运行生成的查询。 ::::warning -TPC-DS 大量使用相关子查询,而在撰写本文时(2024 年 9 月),ClickHouse 不支持这些查询 ([issue #6697](https://github.com/ClickHouse/ClickHouse/issues/6697))。因此,上述许多基准查询将因错误而失败。 +TPC-DS 大量使用相关子查询,而在撰写本文时(2024 年 9 月)ClickHouse 尚不支持这些查询([issue #6697](https://github.com/ClickHouse/ClickHouse/issues/6697))。因此,上述许多基准查询将因错误而失败。 :::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/tpcds.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/tpcds.md.hash index 12313a5af7c..a5e282a9543 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/tpcds.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/tpcds.md.hash @@ -1 +1 @@ -2e040044c29e0fee +3a3b2e9b8f81aac1 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/tpch.md b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/tpch.md index 8f95fe27062..a4b8b25516d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/tpch.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/tpch.md @@ -1,22 +1,23 @@ --- -'description': 'TPC-H基准数据集和查询。' +'description': 'TPC-H 基准数据集和查询.' 'sidebar_label': 'TPC-H' 'slug': '/getting-started/example-datasets/tpch' 'title': 'TPC-H (1999)' +'doc_type': 'reference' --- -一个流行的基准测试,它模拟了批发供应商的内部数据仓库。数据以第三范式表示,查询运行时需要大量连接。尽管它已经存在很久,并且假设数据是均匀和独立分布的,这种假设并不现实,但到目前为止,TPC-H 仍然是最流行的 OLAP 基准测试。 +一个流行的基准测试,模拟了批发供应商的内部数据仓库。数据存储为 3NF(第三范式)表示,这在查询运行时需要大量的连接。尽管它有些陈旧,并且对数据均匀和独立分布的假设不现实,但截至目前,TPC-H 仍然是最受欢迎的 OLAP 基准测试。 **参考文献** - [TPC-H](https://www.tpc.org/tpc_documents_current_versions/current_specifications5.asp) -- [用于决策支持和网络商务的新 TPC 基准](https://doi.org/10.1145/369275.369291) (Poess et. al., 2000) -- [TPC-H 分析:有影响的基准中隐藏的信息和经历的教训](https://doi.org/10.1007/978-3-319-04936-6_5) (Boncz et. al.), 2013 +- [新的 TPC 基准测试用于决策支持和网络商务](https://doi.org/10.1145/369275.369291) (Poess et. al., 2000) +- [TPC-H 分析:有影响力的基准测试中的隐含信息和经验教训](https://doi.org/10.1007/978-3-319-04936-6_5) (Boncz et. al.), 2013 - [量化 TPC-H 瓶颈及其优化](https://doi.org/10.14778/3389133.3389138) (Dresseler et. al.), 2020 ## 数据生成与导入 {#data-generation-and-import} -首先,检出 TPC-H 仓库,并编译数据生成器: +首先,检查 TPC-H 存储库并编译数据生成器: ```bash git clone https://github.com/gregrahn/tpch-kit.git @@ -30,29 +31,29 @@ make ./dbgen -s 100 ``` -规模因子为 100 时,详细的表大小: +规模因子为 100 的详细表大小: -| 表名 | 行数 | 在 ClickHouse 中的压缩大小 | -|---------|---------------|-----------------------------| -| nation | 25 | 2 kB | -| region | 5 | 1 kB | -| part | 20.000.000 | 895 MB | -| supplier| 1.000.000 | 75 MB | -| partsupp| 80.000.000 | 4.37 GB | -| customer| 15.000.000 | 1.19 GB | -| orders | 150.000.000 | 6.15 GB | -| lineitem| 600.00.00 | 26.69 GB | +| 表 | 大小(行数) | 在 ClickHouse 中的压缩大小 | +|--------|--------------|-------------------------------| +| nation | 25 | 2 kB | +| region | 5 | 1 kB | +| part | 20,000,000 | 895 MB | +| supplier | 1,000,000 | 75 MB | +| partsupp | 80,000,000 | 4.37 GB | +| customer | 15,000,000 | 1.19 GB | +| orders | 150,000,000 | 6.15 GB | +| lineitem | 600,000,000 | 26.69 GB | -(ClickHouse 中的压缩大小是从 `system.tables.total_bytes` 获取的,基于以下表定义。) +(ClickHouse 中的压缩大小来自 `system.tables.total_bytes`,基于以下表定义。) 现在在 ClickHouse 中创建表。 我们尽可能遵循 TPC-H 规范的规则: -- 主键仅为规范第 1.4.2.2 部分中提到的列创建。 -- 替换参数已在规范第 2.1.x.4 部分中用查询验证的值替换。 -- 根据第 1.4.2.1 部分,表定义不使用可选的 `NOT NULL` 约束,即使 `dbgen` 默认生成它们。 - ClickHouse 中 `SELECT` 查询的性能不受 `NOT NULL` 约束的存在或缺失的影响。 -- 根据第 1.3.1 部分,我们使用 ClickHouse 的原生数据类型(例如 `Int32`、`String`)来实现规范中提到的抽象数据类型(例如 `Identifier`、`Variable text, size N`)。这唯一的效果是可读性更好,由 `dbgen` 生成的 SQL-92 数据类型(例如 `INTEGER`、`VARCHAR(40)`)在 ClickHouse 中也能工作。 +- 只为规范第 1.4.2.2 节中提到的列创建主键。 +- 替代参数根据规范第 2.1.x.4 节中的查询验证值被替换。 +- 根据第 1.4.2.1 节,表定义不使用可选的 `NOT NULL` 约束,即使 `dbgen` 默认生成它们。 + ClickHouse 中 `SELECT` 查询的性能不受 `NOT NULL` 约束存在或不存在的影响。 +- 根据第 1.3.1 节,我们使用 ClickHouse 的本机数据类型(例如 `Int32`、`String`)来实现规范中提到的抽象数据类型(例如 `Identifier`、`Variable text, size N`)。这样做唯一的效果是提高可读性,通过 `dbgen` 生成的 SQL-92 数据类型(例如 `INTEGER`、`VARCHAR(40)`)在 ClickHouse 中也可以工作。 ```sql CREATE TABLE nation ( @@ -161,7 +162,7 @@ clickhouse-client --format_csv_delimiter '|' --query "INSERT INTO lineitem FORMA ``` :::note -您可以选择从公共 S3 存储桶中导入数据,而不是使用 tpch-kit 并自己生成表。确保首先使用上述 `CREATE` 语句创建空表。 +除了使用 tpch-kit 自行生成表之外,您还可以选择从公共 S3 桶导入数据。确保先使用上述 `CREATE` 语句创建空表。 ```sql -- Scaling factor 1 @@ -192,12 +193,22 @@ INSERT INTO lineitem SELECT * FROM s3('https://clickhouse-datasets.s3.amazonaws. Setting [`join_use_nulls`](../../operations/settings/settings.md#join_use_nulls) should be enabled to produce correct results according to SQL standard. ::: -The queries are generated by `./qgen -s `. Example queries for `s = 100`: +:::note +Some TPC-H queries query use correlated subqueries which are available since v25.8. +Please use at least this ClickHouse version to run the queries. + +In ClickHouse versions 25.5, 25.6, 25.7, it is necessary to set additionally: -**Correctness** +```sql +SET allow_experimental_correlated_subqueries = 1; +``` +::: -The result of the queries agrees with the official results unless mentioned otherwise. To verify, generate a TPC-H database with scale -factor = 1 (`dbgen`, see above) and compare with the [expected results in tpch-kit](https://github.com/gregrahn/tpch-kit/tree/master/dbgen/answers). +查询由 `./qgen -s ` 生成。以下是 `s = 100` 的示例查询: + +**正确性** + +除非另有说明,查询结果与官方结果一致。要验证,请使用规模因子 = 1 生成 TPC-H 数据库(`dbgen`,见上文),并与 [tpch-kit 中的预期结果](https://github.com/gregrahn/tpch-kit/tree/master/dbgen/answers) 进行比较。 **Q1** @@ -228,8 +239,6 @@ ORDER BY **Q2** ```sql -SET allow_experimental_correlated_subqueries = 1; -- since v25.5 - SELECT s_acctbal, s_name, @@ -275,62 +284,6 @@ ORDER BY p_partkey; ``` -::::note -在 v25.5 之前,由于相关子查询,该查询无法开箱即用。相关问题: https://github.com/ClickHouse/ClickHouse/issues/6697 - -这个替代公式有效,并已验证返回参考结果。 - -```sql -WITH MinSupplyCost AS ( - SELECT - ps_partkey, - MIN(ps_supplycost) AS min_supplycost - FROM - partsupp ps - JOIN - supplier s ON ps.ps_suppkey = s.s_suppkey - JOIN - nation n ON s.s_nationkey = n.n_nationkey - JOIN - region r ON n.n_regionkey = r.r_regionkey - WHERE - r.r_name = 'EUROPE' - GROUP BY - ps_partkey -) -SELECT - s.s_acctbal, - s.s_name, - n.n_name, - p.p_partkey, - p.p_mfgr, - s.s_address, - s.s_phone, - s.s_comment -FROM - part p -JOIN - partsupp ps ON p.p_partkey = ps.ps_partkey -JOIN - supplier s ON s.s_suppkey = ps.ps_suppkey -JOIN - nation n ON s.s_nationkey = n.n_nationkey -JOIN - region r ON n.n_regionkey = r.r_regionkey -JOIN - MinSupplyCost msc ON ps.ps_partkey = msc.ps_partkey AND ps.ps_supplycost = msc.min_supplycost -WHERE - p.p_size = 15 - AND p.p_type LIKE '%BRASS' - AND r.r_name = 'EUROPE' -ORDER BY - s.s_acctbal DESC, - n.n_name, - s.s_name, - p.p_partkey; -``` -:::: - **Q3** ```sql @@ -361,8 +314,6 @@ ORDER BY **Q4** ```sql -SET allow_experimental_correlated_subqueries = 1; -- since v25.5 - SELECT o_orderpriority, count(*) AS order_count @@ -386,39 +337,6 @@ ORDER BY o_orderpriority; ``` -::::note -在 v25.5 之前,由于相关子查询,该查询无法开箱即用。相关问题: https://github.com/ClickHouse/ClickHouse/issues/6697 - -这个替代公式有效,并已验证返回参考结果。 - -```sql -WITH ValidLineItems AS ( - SELECT - l_orderkey - FROM - lineitem - WHERE - l_commitdate < l_receiptdate - GROUP BY - l_orderkey -) -SELECT - o.o_orderpriority, - COUNT(*) AS order_count -FROM - orders o -JOIN - ValidLineItems vli ON o.o_orderkey = vli.l_orderkey -WHERE - o.o_orderdate >= DATE '1993-07-01' - AND o.o_orderdate < DATE '1993-07-01' + INTERVAL '3' MONTH -GROUP BY - o.o_orderpriority -ORDER BY - o.o_orderpriority; -``` -:::: - **Q5** ```sql @@ -463,9 +381,9 @@ WHERE ``` ::::note -截至 2025 年 2 月,该查询由于小数加法的错误而无法开箱即用。相关问题: https://github.com/ClickHouse/ClickHouse/issues/70136 +截至 2025 年 2 月,由于小数加法的错误,该查询无法直接使用。相关问题:[https://github.com/ClickHouse/ClickHouse/issues/70136](https://github.com/ClickHouse/ClickHouse/issues/70136) -这个替代公式有效,并已验证返回参考结果。 +这种替代形式有效,并且经过验证返回参考结果。 ```sql SELECT @@ -692,7 +610,7 @@ FROM lineitem WHERE o_orderkey = l_orderkey - AND l_shipmode in ('MAIL', 'SHIP') + AND l_shipmode IN ('MAIL', 'SHIP') AND l_commitdate < l_receiptdate AND l_shipdate < l_commitdate AND l_receiptdate >= DATE '1994-01-01' @@ -712,7 +630,7 @@ SELECT FROM ( SELECT c_custkey, - count(o_orderkey) as c_count + count(o_orderkey) AS c_count FROM customer LEFT OUTER JOIN orders ON c_custkey = o_custkey @@ -790,7 +708,7 @@ SELECT p_brand, p_type, p_size, - count(distinct ps_suppkey) AS supplier_cnt + count(DISTINCT ps_suppkey) AS supplier_cnt FROM partsupp, part @@ -798,8 +716,8 @@ WHERE p_partkey = ps_partkey AND p_brand <> 'Brand#45' AND p_type NOT LIKE 'MEDIUM POLISHED%' - AND p_size in (49, 14, 23, 45, 19, 3, 36, 9) - AND ps_suppkey NOT in ( + AND p_size IN (49, 14, 23, 45, 19, 3, 36, 9) + AND ps_suppkey NOT IN ( SELECT s_suppkey FROM @@ -821,8 +739,6 @@ ORDER BY **Q17** ```sql -SET allow_experimental_correlated_subqueries = 1; -- since v25.5 - SELECT sum(l_extendedprice) / 7.0 AS avg_yearly FROM @@ -842,37 +758,6 @@ WHERE ); ``` -::::note -在 v25.5 之前,由于相关子查询,该查询无法开箱即用。相关问题: https://github.com/ClickHouse/ClickHouse/issues/6697 - -这个替代公式有效,并已验证返回参考结果。 - -```sql -WITH AvgQuantity AS ( - SELECT - l_partkey, - AVG(l_quantity) * 0.2 AS avg_quantity - FROM - lineitem - GROUP BY - l_partkey -) -SELECT - SUM(l.l_extendedprice) / 7.0 AS avg_yearly -FROM - lineitem l -JOIN - part p ON p.p_partkey = l.l_partkey -JOIN - AvgQuantity aq ON l.l_partkey = aq.l_partkey -WHERE - p.p_brand = 'Brand#23' - AND p.p_container = 'MED BOX' - AND l.l_quantity < aq.avg_quantity; - -``` -:::: - **Q18** ```sql @@ -888,7 +773,7 @@ FROM orders, lineitem WHERE - o_orderkey in ( + o_orderkey IN ( SELECT l_orderkey FROM @@ -923,30 +808,30 @@ WHERE ( p_partkey = l_partkey AND p_brand = 'Brand#12' - AND p_container in ('SM CASE', 'SM BOX', 'SM PACK', 'SM PKG') + AND p_container IN ('SM CASE', 'SM BOX', 'SM PACK', 'SM PKG') AND l_quantity >= 1 AND l_quantity <= 1 + 10 AND p_size BETWEEN 1 AND 5 - AND l_shipmode in ('AIR', 'AIR REG') + AND l_shipmode IN ('AIR', 'AIR REG') AND l_shipinstruct = 'DELIVER IN PERSON' ) OR ( p_partkey = l_partkey AND p_brand = 'Brand#23' - AND p_container in ('MED BAG', 'MED BOX', 'MED PKG', 'MED PACK') + AND p_container IN ('MED BAG', 'MED BOX', 'MED PKG', 'MED PACK') AND l_quantity >= 10 AND l_quantity <= 10 + 10 AND p_size BETWEEN 1 AND 10 - AND l_shipmode in ('AIR', 'AIR REG') + AND l_shipmode IN ('AIR', 'AIR REG') AND l_shipinstruct = 'DELIVER IN PERSON' ) OR ( p_partkey = l_partkey AND p_brand = 'Brand#34' - AND p_container in ('LG CASE', 'LG BOX', 'LG PACK', 'LG PKG') + AND p_container IN ('LG CASE', 'LG BOX', 'LG PACK', 'LG PKG') AND l_quantity >= 20 AND l_quantity <= 20 + 10 AND p_size BETWEEN 1 AND 15 - AND l_shipmode in ('AIR', 'AIR REG') + AND l_shipmode IN ('AIR', 'AIR REG') AND l_shipinstruct = 'DELIVER IN PERSON' ); ``` @@ -954,8 +839,6 @@ WHERE **Q20** ```sql -SET allow_experimental_correlated_subqueries = 1; -- since v25.5 - SELECT s_name, s_address @@ -995,15 +878,9 @@ ORDER BY s_name; ``` -::::note -在 v25.5 之前,由于相关子查询,该查询无法开箱即用。相关问题: https://github.com/ClickHouse/ClickHouse/issues/6697 -:::: - **Q21** ```sql -SET allow_experimental_correlated_subqueries = 1; -- since v25.5 - SELECT s_name, count(*) AS numwait @@ -1044,15 +921,10 @@ ORDER BY numwait DESC, s_name; ``` -::::note -在 v25.5 之前,由于相关子查询,该查询无法开箱即用。相关问题: https://github.com/ClickHouse/ClickHouse/issues/6697 -:::: **Q22** ```sql -SET allow_experimental_correlated_subqueries = 1; -- since v25.5 - SELECT cntrycode, count(*) AS numcust, @@ -1090,7 +962,3 @@ GROUP BY ORDER BY cntrycode; ``` - -::::note -在 v25.5 之前,由于相关子查询,该查询无法开箱即用。相关问题: https://github.com/ClickHouse/ClickHouse/issues/6697 -:::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/tpch.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/tpch.md.hash index e9f3c02c8b4..84ad55363f9 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/tpch.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/tpch.md.hash @@ -1 +1 @@ -908f2197364dd38d +fb8c06f681ab86c3 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/tw-weather.md b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/tw-weather.md index ab8683fcf09..1ac6f2b7f22 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/tw-weather.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/tw-weather.md @@ -1,16 +1,17 @@ --- -'description': '过去 128 年的天气观测数据,共 1.31 亿行' +'description': '过去128年中,131百万行天气观察数据' 'sidebar_label': '台湾历史天气数据集' 'sidebar_position': 1 'slug': '/getting-started/example-datasets/tw-weather' 'title': '台湾历史天气数据集' +'doc_type': 'reference' --- -这个数据集包含过去128年的历史气象观测测量记录。每一行都是某个时间点和天气站的测量值。 +这个数据集包含了过去128年的历史气象观测测量数据。每一行是某个时间点和气象站的测量结果。 -该数据集的来源可以在[这里](https://github.com/Raingel/historical_weather)找到,天气站编号的列表可以在[这里](https://github.com/Raingel/weather_station_list)找到。 +该数据集的来源可以在 [这里](https://github.com/Raingel/historical_weather) 找到,气象站编号的列表可以在 [这里](https://github.com/Raingel/weather_station_list) 找到。 -> 气象数据集的来源包括中央气象局建立的气象站(站代码以C0、C1和4开头)以及属于农业委员会的农业气象站(站代码不包括上述提到的情况): +> 气象数据集的来源包括中央气象局建立的气象站(站点代码以C0、C1和4开头)以及农业委员会所属的农业气象站(站点代码不包含上述所提到的代码): - StationId - MeasuredDate,观测时间 @@ -22,12 +23,12 @@ ## 下载数据 {#downloading-the-data} -- 一份适用于ClickHouse的[预处理版本](#pre-processed-data),已清理、重组和增强。该数据集涵盖1896年至2023年。 -- [下载原始原始数据](#original-raw-data)并转换为ClickHouse要求的格式。希望添加自己列的用户可以探索或完成自己的方法。 +- 一个 [预处理版本](#pre-processed-data) 的数据用于ClickHouse,经过清理、重构和丰富。该数据集覆盖1896年至2023年。 +- [下载原始原始数据](#original-raw-data) 并转换为ClickHouse所需的格式。希望添加自己列的用户可以探索或完善自己的方法。 ### 预处理数据 {#pre-processed-data} -该数据集已从每行一个测量值重组为每个天气站ID和测量日期一行,例如: +该数据集已经从每行一个测量重构为每个气象站id和测量日期一行,即: ```csv StationId,MeasuredDate,StnPres,Tx,RH,WS,WD,WSGust,WDGust,Precp,GloblRad,TxSoil0cm,TxSoil5cm,TxSoil20cm,TxSoil50cm,TxSoil100cm,SeaPres,Td,PrecpHour,SunShine,TxSoil10cm,EvapA,Visb,UVI,Cloud Amount,TxSoil30cm,TxSoil200cm,TxSoil300cm,TxSoil500cm,VaporPressure @@ -37,11 +38,11 @@ C0X100,2016-01-01 03:00:00,1021.3,15.8,74,1.5,353.0,,,,,,,,,,,,,,,,,,,,,,, C0X100,2016-01-01 04:00:00,1021.2,15.8,74,1.7,8.0,,,,,,,,,,,,,,,,,,,,,,, ``` -查询变得简单,并且确保结果表更少稀疏,某些元素为null,因为它们在该气象站不可用。 +查询非常简便,并确保结果表较少稀疏,某些元素由于无法在该气象站测量而为null。 -该数据集可在以下Google Cloud Storage位置找到。用户可以将数据集下载到本地文件系统(并使用ClickHouse客户端插入)或直接插入ClickHouse中(请参见[从URL插入](#inserting-from-url))。 +该数据集可在以下Google CloudStorage位置获取。您可以将数据集下载到本地文件系统(然后使用ClickHouse客户端插入),或直接插入到ClickHouse中(请参见 [从URL插入](#inserting-from-url))。 -下载方式如下: +下载方法: ```bash wget https://storage.googleapis.com/taiwan-weather-observaiton-datasets/preprocessed_weather_daily_1896_2023.tar.gz @@ -64,7 +65,7 @@ md5sum daily_weather_preprocessed_1896_2023.csv ### 原始原始数据 {#original-raw-data} -以下是下载原始原始数据以进行转换和处理的步骤。 +以下是关于下载原始原始数据以进行转换和转化的步骤的详细信息。 #### 下载 {#download} @@ -95,7 +96,7 @@ cat *.csv | md5sum # Checksum should be equal to: b26db404bf84d4063fac42e576464ce1 ``` -#### 检索台湾天气站 {#retrieve-the-taiwan-weather-stations} +#### 获取台湾气象站 {#retrieve-the-taiwan-weather-stations} ```bash wget -O weather_sta_list.csv https://github.com/Raingel/weather_station_list/raw/main/data/weather_sta_list.csv @@ -146,7 +147,7 @@ ENGINE = MergeTree ORDER BY (MeasuredDate); ``` -## 插入到ClickHouse中 {#inserting-into-clickhouse} +## 插入数据到ClickHouse {#inserting-into-clickhouse} ### 从本地文件插入 {#inserting-from-local-file} @@ -156,9 +157,9 @@ ORDER BY (MeasuredDate); INSERT INTO tw_weather_data FROM INFILE '/path/to/daily_weather_preprocessed_1896_2023.csv' ``` -其中`/path/to`表示本地文件在磁盘上的具体用户路径。 +其中`/path/to`表示磁盘上本地文件的特定用户路径。 -插入数据后,示例响应输出如下: +在将数据插入到ClickHouse后,示例响应输出如下: ```response Query id: 90e4b524-6e14-4855-817c-7e6f98fbeabb @@ -175,7 +176,7 @@ INSERT INTO tw_weather_data SELECT * FROM url('https://storage.googleapis.com/taiwan-weather-observaiton-datasets/daily_weather_preprocessed_1896_2023.csv', 'CSVWithNames') ``` -要了解如何加速这一过程,请参阅我们关于[优化大数据加载](https://clickhouse.com/blog/supercharge-your-clickhouse-data-loads-part2)的博客文章。 +要了解如何加快这一过程,请参见我们博客文章中的 [调优大量数据加载](https://clickhouse.com/blog/supercharge-your-clickhouse-data-loads-part2)。 ## 检查数据行和大小 {#check-data-rows-and-sizes} @@ -192,7 +193,7 @@ FROM tw_weather_data; └─────────────────────────────────┘ ``` -2. 让我们查看该表使用了多少磁盘空间: +2. 让我们看看这个表占用了多少磁盘空间: ```sql SELECT @@ -210,7 +211,7 @@ WHERE (`table` = 'tw_weather_data') AND active ## 示例查询 {#sample-queries} -### Q1:检索特定年份每个天气站的最高露点温度 {#q1-retrieve-the-highest-dew-point-temperature-for-each-weather-station-in-the-specific-year} +### Q1: 获取每个气象站在特定年份的最高露点温度 {#q1-retrieve-the-highest-dew-point-temperature-for-each-weather-station-in-the-specific-year} ```sql SELECT @@ -256,7 +257,7 @@ GROUP BY StationId 30 rows in set. Elapsed: 0.045 sec. Processed 6.41 million rows, 187.33 MB (143.92 million rows/s., 4.21 GB/s.) ``` -### Q2:以特定时间范围、字段和天气站raw数据获取 {#q2-raw-data-fetching-with-the-specific-duration-time-range-fields-and-weather-station} +### Q2: 使用特定时间范围、字段和气象站的原始数据获取 {#q2-raw-data-fetching-with-the-specific-duration-time-range-fields-and-weather-station} ```sql SELECT @@ -294,8 +295,8 @@ LIMIT 10 10 rows in set. Elapsed: 0.009 sec. Processed 91.70 thousand rows, 2.33 MB (9.67 million rows/s., 245.31 MB/s.) ``` -## 致谢 {#credits} +## 感谢 {#credits} -我们要感谢中央气象局和农业委员会农业气象观测网络(站)的努力,他们为准备、清理和分发此数据集做出了贡献。我们对此表示感谢。 +我们要感谢中央气象局和农业委员会的农业气象观测网络(站)在准备、清理和分配此数据集方面所做的努力。我们对此表示感谢。 -Ou, J.-H., Kuo, C.-H., Wu, Y.-F., Lin, G.-C., Lee, M.-H., Chen, R.-K., Chou, H.-P., Wu, H.-Y., Chu, S.-C., Lai, Q.-J., Tsai, Y.-C., Lin, C.-C., Kuo, C.-C., Liao, C.-T., Chen, Y.-N., Chu, Y.-W., Chen, C.-Y., 2023. 面向应用的深度学习模型用于台湾稻瘟病的早期预警。生态信息学73, 101950. https://doi.org/10.1016/j.ecoinf.2022.101950 [2022年12月13日] +Ou, J.-H., Kuo, C.-H., Wu, Y.-F., Lin, G.-C., Lee, M.-H., Chen, R.-K., Chou, H.-P., Wu, H.-Y., Chu, S.-C., Lai, Q.-J., Tsai, Y.-C., Lin, C.-C., Kuo, C.-C., Liao, C.-T., Chen, Y.-N., Chu, Y.-W., Chen, C.-Y., 2023. 面向应用的深度学习模型用于台湾水稻病害的早期预警。生态信息学 73, 101950. https://doi.org/10.1016/j.ecoinf.2022.101950 [13/12/2022] diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/tw-weather.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/tw-weather.md.hash index 150ea00a787..21fde782d57 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/tw-weather.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/tw-weather.md.hash @@ -1 +1 @@ -7957b25b3baad99a +acb086ae38fb7f8a diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/uk-price-paid.md b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/uk-price-paid.md index fa13bbfabf0..a339036b549 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/uk-price-paid.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/uk-price-paid.md @@ -1,16 +1,17 @@ --- -'description': '了解如何使用投影来改善您经常运行的查询的性能,使用英国房地产数据集,该数据集包含有关英格兰和威尔士房地产价格的数据' +'description': '了解如何使用投影来提高您频繁运行的查询性能,使用包含关于英格兰和威尔士房地产价格的数据的UK property数据集' 'sidebar_label': 'UK Property Prices' 'sidebar_position': 1 'slug': '/getting-started/example-datasets/uk-price-paid' 'title': '英国房地产价格数据集' +'doc_type': 'tutorial' --- -此数据包含英格兰和威尔士房地产支付的价格。自1995年以来,数据可用,未压缩形式的数据集大小约为4 GiB(在 ClickHouse 中只占约278 MiB)。 +这份数据包含了在英格兰和威尔士支付的房地产价格。数据自1995年以来可用,未压缩形式的数据集大小约为4 GiB(在 ClickHouse 中仅占约 278 MiB)。 - 来源: https://www.gov.uk/government/statistical-data-sets/price-paid-data-downloads -- 字段说明: https://www.gov.uk/guidance/about-the-price-paid-data -- 包含 HM Land Registry 数据 © Crown copyright 和数据库版权 2021。该数据根据开放政府许可证 v3.0 进行许可。 +- 字段描述: https://www.gov.uk/guidance/about-the-price-paid-data +- 包含 HM 土地注册处数据 © 皇冠版权和数据库权利 2021。该数据根据开放政府许可证 v3.0 授予许可。 ## 创建表 {#create-table} @@ -38,17 +39,17 @@ ENGINE = MergeTree ORDER BY (postcode1, postcode2, addr1, addr2); ``` -## 预处理和插入数据 {#preprocess-import-data} +## 预处理并插入数据 {#preprocess-import-data} -我们将使用 `url` 函数将数据流式传输到 ClickHouse。我们需要先对一些传入数据进行预处理,包括: -- 将 `postcode` 拆分为两个不同的列 - `postcode1` 和 `postcode2`,这对存储和查询更为优化 -- 将 `time` 字段转换为日期,因为它只包含00:00时间 +我们将使用 `url` 函数将数据流式传输到 ClickHouse。我们需要首先预处理一些进入的数据,包括: +- 将 `postcode` 切分为两个不同的列 - `postcode1` 和 `postcode2`,这样更有利于存储和查询 +- 将 `time` 字段转换为日期,因为它仅包含 00:00 时间 - 忽略 [UUid](../../sql-reference/data-types/uuid.md) 字段,因为我们在分析中不需要它 -- 使用 [transform](../../sql-reference/functions/other-functions.md#transform) 函数将 `type` 和 `duration` 转换为更可读的 `Enum` 字段 -- 将 `is_new` 字段从单字符字符串(`Y`/`N`)转换为 [UInt8](/sql-reference/data-types/int-uint) 字段,值为0或1 -- 删除最后两列,因为它们的值都是相同的(值为0) +- 使用 [transform](../../sql-reference/functions/other-functions.md#transform) 函数将 `type` 和 `duration` 转换为更易读的 `Enum` 字段 +- 将 `is_new` 字段从单字符字符串(`Y`/`N`)转换为 [UInt8](/sql-reference/data-types/int-uint) 字段,其值为 0 或 1 +- 删除最后两列,因为它们的值都是相同的(即 0) -`url` 函数将数据从网络服务器流式传输到您的 ClickHouse 表中。以下命令将500万行插入到 `uk_price_paid` 表中: +`url` 函数将数据从网页服务器流式传输到您的 ClickHouse 表中。以下命令将 500 万行插入到 `uk_price_paid` 表中: ```sql INSERT INTO uk.uk_price_paid @@ -89,18 +90,18 @@ FROM url( ) SETTINGS max_http_get_redirects=10; ``` -等待数据插入 - 这将根据网络速度花费一两分钟时间。 +等待数据插入 - 这可能需要一两分钟,具体取决于网络速度。 ## 验证数据 {#validate-data} -让我们通过查看插入了多少行来验证它是否成功: +让我们通过查看插入了多少行来验证操作是否成功: ```sql runnable SELECT count() FROM uk.uk_price_paid ``` -在运行此查询时,数据集中有27,450,499行。让我们看看 ClickHouse 中该表的存储大小是多少: +在运行此查询时,数据集包含 27,450,499 行。让我们看看 ClickHouse 中表的存储大小: ```sql runnable SELECT formatReadableSize(total_bytes) @@ -108,11 +109,11 @@ FROM system.tables WHERE name = 'uk_price_paid' ``` -注意,该表的大小仅为221.43 MiB! +注意表的大小仅为 221.43 MiB! -## 运行一些查询 {#run-queries} +## 执行一些查询 {#run-queries} -让我们运行一些查询以分析数据: +让我们运行一些查询来分析数据: ### 查询 1. 每年的平均价格 {#average-price} @@ -141,9 +142,9 @@ GROUP BY year ORDER BY year ``` -2020年房价发生了一些变化!但这可能并不令人惊讶... +2020 年的房价发生了什么变化!但这可能并不令人惊讶... -### 查询 3. 最昂贵的邻里 {#most-expensive-neighborhoods} +### 查询 3. 最昂贵的社区 {#most-expensive-neighborhoods} ```sql runnable SELECT @@ -162,10 +163,10 @@ ORDER BY price DESC LIMIT 100 ``` -## 用投影加速查询 {#speeding-up-queries-with-projections} +## 使用投影加速查询 {#speeding-up-queries-with-projections} -我们可以使用投影来加速这些查询。有关此数据集的示例,请参见 ["Projections"](/data-modeling/projections)。 +我们可以使用投影来加速这些查询。有关该数据集的示例,请参见 ["Projections"](/data-modeling/projections)。 ### 在游乐场中测试 {#playground} -数据集也可以在 [在线游乐场](https://sql.clickhouse.com?query_id=TRCWH5ZETY4SEEK8ISCCAX) 中使用。 +该数据集在 [在线游乐场](https://sql.clickhouse.com?query_id=TRCWH5ZETY4SEEK8ISCCAX) 中也可用。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/uk-price-paid.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/uk-price-paid.md.hash index 902a8a4e3b6..c574b7083a5 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/uk-price-paid.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/uk-price-paid.md.hash @@ -1 +1 @@ -0410d06546a68783 +d43bd9ae7b51e7fa diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/wikistat.md b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/wikistat.md index ffc80d64033..9658a6c0159 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/wikistat.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/wikistat.md @@ -3,17 +3,18 @@ 'sidebar_label': 'WikiStat' 'slug': '/getting-started/example-datasets/wikistat' 'title': 'WikiStat' +'doc_type': 'reference' --- -该数据集包含 0.5 万亿条记录。 +数据集包含 0.5 万亿条记录。 -请观看 FOSDEM 2023 的视频: https://www.youtube.com/watch?v=JlcI2Vfz_uk +观看 FOSDEM 2023 的视频:https://www.youtube.com/watch?v=JlcI2Vfz_uk -以及演示文稿: https://presentations.clickhouse.com/fosdem2023/ +以及演示文稿:https://presentations.clickhouse.com/fosdem2023/ -数据来源: https://dumps.wikimedia.org/other/pageviews/ +数据源:https://dumps.wikimedia.org/other/pageviews/ -获取链接列表: +获取链接列表: ```shell for i in {2015..2023}; do for j in {01..12}; do @@ -24,15 +25,15 @@ for i in {2015..2023}; do done | sort | uniq | tee links.txt ``` -下载数据: +下载数据: ```shell sed -r 's!pageviews-([0-9]{4})([0-9]{2})[0-9]{2}-[0-9]+\.gz!https://dumps.wikimedia.org/other/pageviews/\1/\1-\2/\0!' \ links.txt | xargs -P3 wget --continue ``` -(大约需要 3 天时间) +(这将需要大约 3 天) -创建表: +创建表: ```sql CREATE TABLE wikistat @@ -47,7 +48,7 @@ ENGINE = MergeTree ORDER BY (path, time); ``` -加载数据: +加载数据: ```shell clickhouse-local --query " @@ -64,7 +65,7 @@ clickhouse-local --query " " | clickhouse-client --query "INSERT INTO wikistat FORMAT Native" ``` -或者加载清理后的数据: +或加载清理后的数据: ```sql INSERT INTO wikistat WITH diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/wikistat.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/wikistat.md.hash index 96cc20f520d..bff9b9741bb 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/wikistat.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/wikistat.md.hash @@ -1 +1 @@ -d37808d440084bae +139d35426078ad56 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/youtube-dislikes.md b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/youtube-dislikes.md index c1022c26178..e252b3ac7e9 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/youtube-dislikes.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/youtube-dislikes.md @@ -1,27 +1,28 @@ --- -'description': '一个包含YouTube视频不喜欢的集合。' +'description': '一组 YouTube 视频的不喜欢集合。' 'sidebar_label': 'YouTube 不喜欢' 'slug': '/getting-started/example-datasets/youtube-dislikes' -'title': 'YouTube 视频不喜欢的数据集' +'title': 'YouTube 视频不喜欢数据集' +'doc_type': 'reference' --- -在2021年11月,YouTube 从所有视频中删除了公开的 ***不喜欢*** 数量。虽然创作者仍可以看到不喜欢的数量,但观众只能看到视频收到的 ***喜欢*** 数量。 +在2021年11月,YouTube 从所有视频中移除了公共的 ***不喜欢*** 计数。虽然创作者仍然可以看到不喜欢的数量,但观众只能看到视频收到的 ***喜欢*** 数量。 :::important -该数据集包含超过 45.5 亿条记录,因此在没有足够资源处理该类型数据时,请小心直接复制和粘贴下面的命令。这些命令是在 **生产** 实例的 [ClickHouse Cloud](https://clickhouse.cloud) 上执行的。 +该数据集包含超过 45.5 亿条记录,因此请谨慎使用下面的命令进行复制和粘贴,除非您的资源能够处理如此庞大的数据量。下面的命令是在 [ClickHouse Cloud](https://clickhouse.cloud) 的 **生产** 实例上执行的。 ::: -数据为 JSON 格式,可以从 [archive.org](https://archive.org/download/dislikes_youtube_2021_12_video_json_files) 下载。我们已经将相同的数据提供在 S3 中,以便能够更有效地下载到 ClickHouse Cloud 实例中。 +数据采用 JSON 格式,可以从 [archive.org](https://archive.org/download/dislikes_youtube_2021_12_video_json_files) 下载。我们已经将相同的数据在 S3 上提供,以便更有效地下载到 ClickHouse Cloud 实例中。 -以下是在 ClickHouse Cloud 中创建表并插入数据的步骤。 +以下是创建 ClickHouse Cloud 中的表并插入数据的步骤。 :::note -下面的步骤同样适用于本地安装的 ClickHouse。唯一的变化是使用 `s3` 函数而不是 `s3cluster`(除非您配置了集群 - 在这种情况下,将 `default` 更改为您的集群名称)。 +以下步骤在 ClickHouse 的本地安装上也可以轻松工作。唯一的变化是使用 `s3` 函数来代替 `s3cluster`(除非您已配置集群 - 在这种情况下,将 `default` 更改为您的集群名称)。 ::: ## 分步说明 {#step-by-step-instructions} -1. 让我们来看一下数据的样子。 `s3cluster` 表函数返回一个表,因此我们可以 `DESCRIBE` 结果: +1. 让我们看看数据的样子。`s3cluster` 表函数返回一个表,因此我们可以对结果进行 `DESCRIBE`: ```sql DESCRIBE s3( @@ -58,7 +59,7 @@ ClickHouse 从 JSON 文件推断出以下模式: └─────────────────────┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┘ ``` -2. 根据推断出的模式,我们整理了数据类型并添加了主键。定义以下表: +2. 根据推断出的模式,我们清理了数据类型并添加了主键。定义以下表: ```sql CREATE TABLE youtube @@ -89,10 +90,10 @@ ENGINE = MergeTree ORDER BY (uploader, upload_date) ``` -3. 以下命令将记录从 S3 文件流式传输到 `youtube` 表中。 +3. 以下命令将记录从 S3 文件流入 `youtube` 表中。 :::important -这将插入大量数据 - 46.5 亿行。如果您不想要整个数据集,简单地添加一个带有所需行数的 `LIMIT` 子句即可。 +这将插入大量数据 - 46.5 亿行。如果您不想要整个数据集,只需添加一个 `LIMIT` 子句,指定所需的行数。 ::: ```sql @@ -126,13 +127,13 @@ FROM s3( ) ``` -关于我们的 `INSERT` 命令的一些说明: +关于我们的 `INSERT` 命令的一些评论: -- `parseDateTimeBestEffortUSOrZero` 函数在输入日期字段可能没有正确格式时非常方便。如果 `fetch_date` 无法被正确解析,将被设置为 `0`。 -- `upload_date` 列包含有效日期,但也包含像 "4 hours ago" 这样的字符串 - 这显然不是有效日期。我们决定在 `upload_date_str` 中存储原始值,并尝试使用 `toDate(parseDateTimeBestEffortUSOrZero(upload_date::String))` 来解析它。如果解析失败,我们只会得到 `0`。 -- 我们使用了 `ifNull` 以避免表中出现 `NULL` 值。如果输入值为 `NULL`,`ifNull` 函数将其设置为空字符串。 +- `parseDateTimeBestEffortUSOrZero` 函数在传入日期字段可能格式不正确时特别有用。如果 `fetch_date` 未能正确解析,则会被设置为 `0` +- `upload_date` 列包含有效日期,但也包含类似 “4 hours ago” 的字符串 - 这显然不是有效日期。我们选择将原始值存储在 `upload_date_str` 中,并尝试使用 `toDate(parseDateTimeBestEffortUSOrZero(upload_date::String))` 进行解析。如果解析失败,我们只会得到 `0` +- 我们使用 `ifNull` 来避免在表中获取 `NULL` 值。如果传入的值为 `NULL`,则 `ifNull` 函数将值设置为空字符串 -4. 在 ClickHouse Cloud 的 SQL 控制台中打开一个新标签(或新的 `clickhouse-client` 窗口),观察计数的增加。插入 45.6 亿行需要一些时间,具体取决于您的服务器资源。(不进行任何设置调整,大约需要 4.5 小时。) +4. 在 ClickHouse Cloud 的 SQL 控制台中打开一个新选项卡(或一个新的 `clickhouse-client` 窗口),并观察计数的增加。插入 45.6B 行将需要一段时间,具体取决于您的服务器资源。(在没有任何设置调整的情况下,大约需要 4.5 小时。) ```sql SELECT formatReadableQuantity(count()) @@ -145,7 +146,7 @@ FROM youtube └─────────────────────────────────┘ ``` -5. 数据插入完成后,继续计算您喜欢的视频或频道的不喜欢数量。让我们看看 ClickHouse 上传了多少个视频: +5. 数据插入完成后,可以开始计算您最喜欢的视频或频道的不喜欢数量。让我们看看 ClickHouse 上传了多少视频: ```sql SELECT count() @@ -162,10 +163,10 @@ WHERE uploader = 'ClickHouse'; ``` :::note -上述查询运行如此快速,因为我们选择 `uploader` 作为主键的第一列 - 所以只需要处理 237k 行。 +上述查询运行得很快,因为我们选择 `uploader` 作为主键的第一个列 - 所以它只需处理 237k 行。 ::: -6. 让我们查看 ClickHouse 视频的喜欢和不喜欢: +6. 让我们看看 ClickHouse 视频的喜欢和不喜欢数量: ```sql SELECT @@ -192,7 +193,7 @@ ORDER BY dislike_count DESC; 84 rows in set. Elapsed: 0.013 sec. Processed 155.65 thousand rows, 16.94 MB (11.96 million rows/s., 1.30 GB/s.) ``` -7. 这是在 `title` 或 `description` 字段中搜索 **ClickHouse** 的视频: +7. 这是一个搜索在 `title` 或 `description` 字段中包含 **ClickHouse** 的视频: ```sql SELECT @@ -208,7 +209,7 @@ ORDER BY view_count DESC; ``` -此查询必须处理每一行,同时还要解析两个字符串列。即便如此,我们在 415 万行/秒的速度下获得了良好的性能: +这个查询必须处理每一行,并且需要解析两个字符串列。即便如此,我们仍然获得了 415 万行/秒的合理性能: ```response 1174 rows in set. Elapsed: 1099.368 sec. Processed 4.56 billion rows, 1.98 TB (4.15 million rows/s., 1.80 GB/s.) @@ -225,9 +226,9 @@ ORDER BY ## 问题 {#questions} -### 如果某人禁用了评论,是否降低了人们实际点击喜欢或不喜欢的机会? {#if-someone-disables-comments-does-it-lower-the-chance-someone-will-actually-click-like-or-dislike} +### 如果有人禁用了评论,是否会降低人们点击喜欢或不喜欢的机会? {#if-someone-disables-comments-does-it-lower-the-chance-someone-will-actually-click-like-or-dislike} -当评论被禁用时,人们是否更有可能通过喜欢或不喜欢来表达他们对视频的感受? +在禁用评论时,人们是否更可能通过点赞或点踩来表达他们对视频的感受? ```sql SELECT @@ -280,14 +281,14 @@ ORDER BY 启用评论似乎与更高的参与率相关。 -### 视频数量随时间变化 - 显著事件? {#how-does-the-number-of-videos-change-over-time---notable-events} +### 视频数量随时间的变化 - 显著事件是什么? {#how-does-the-number-of-videos-change-over-time---notable-events} ```sql SELECT toStartOfMonth(toDateTime(upload_date)) AS month, uniq(uploader_id) AS uploaders, - count() as num_videos, - sum(view_count) as view_count + count() AS num_videos, + sum(view_count) AS view_count FROM youtube GROUP BY month ORDER BY month ASC; @@ -316,11 +317,11 @@ ORDER BY month ASC; │ 2006-10-01 │ 404873 │ 897590 │ 27357846117 │ ``` -可见上传者在COVID期间的激增 [非常明显](https://www.theverge.com/2020/3/27/21197642/youtube-with-me-style-videos-views-coronavirus-cook-workout-study-home-beauty)。 +上传者的激增 [在新冠疫情期间很明显](https://www.theverge.com/2020/3/27/21197642/youtube-with-me-style-videos-views-coronavirus-cook-workout-study-home-beauty)。 -### 随时间推移更加多的字幕以及何时 {#more-subtitles-over-time-and-when} +### 随时间变化的字幕数量及何时变化 {#more-subtitles-over-time-and-when} -随着语音识别的进步,创建字幕变得比以往任何时候都容易,YouTube 在 2009 年底增加了自动字幕功能 - 当时是跃升的开始吗? +伴随着语音识别的进步,创建视频字幕变得比以往任何时候都容易,YouTube在2009年底增加了自动字幕功能 - 这时是否是一个跃升? ```sql SELECT @@ -352,9 +353,10 @@ ORDER BY month ASC; ``` -数据结果显示 2009 年出现了激增。显然,在那时,YouTube 正在删除他们的社区字幕功能,这允许您为其他人的视频上传字幕。这促使了一个非常成功的活动,鼓励创作者为听障和耳聋观众的视频添加字幕。 +数据显示,在2009年出现了激增。显然,那时 YouTube 正在移除其社区字幕功能,该功能允许您为其他人的视频上传字幕。 +这促使了一场非常成功的运动,以让创作者为听力障碍和失聪观众添加字幕。 -### 随时间推移的最高上传者 {#top-uploaders-over-time} +### 随时间变化的顶级上传者 {#top-uploaders-over-time} ```sql WITH uploaders AS @@ -397,7 +399,7 @@ ORDER BY │ 2008-09-01 │ WWE │ 3717092 │ 0.07872802579349912 │ ``` -### 随着观看次数增加,喜欢比例如何变化? {#how-do-like-ratio-changes-as-views-go-up} +### 随着观看次数的增加,点赞比例是如何变化的? {#how-do-like-ratio-changes-as-views-go-up} ```sql SELECT @@ -407,9 +409,9 @@ SELECT FROM ( SELECT - power(10, CEILING(log10(view_count + 1))) as view_range, + power(10, CEILING(log10(view_count + 1))) AS view_range, is_comments_enabled, - avg(like_count / dislike_count) as like_ratio + avg(like_count / dislike_count) AS like_ratio FROM youtube WHERE dislike_count > 0 GROUP BY view_range, @@ -445,7 +447,7 @@ ORDER BY └───────────────────┴─────────────────────┴────────────┘ ``` -### 观看次数是如何分配的? {#how-are-views-distributed} +### 观看次数是如何分布的? {#how-are-views-distributed} ```sql SELECT diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/youtube-dislikes.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/youtube-dislikes.md.hash index 83997a3eaea..f9f1380f8a5 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/youtube-dislikes.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/example-datasets/youtube-dislikes.md.hash @@ -1 +1 @@ -5be86b72338123bb +ee722f39928a05a5 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/index.md index e225dedec17..05971a7d5b9 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/index.md @@ -11,47 +11,52 @@ 'sidebar_position': 0 'slug': '/getting-started/example-datasets/' 'title': '教程和示例数据集' +'doc_type': 'landing-page' --- # 教程和示例数据集 -我们有很多资源可以帮助您入门并了解 ClickHouse 的工作原理: +我们提供了很多资源来帮助您入门并了解 ClickHouse 的工作原理: -- 如果您需要让 ClickHouse 快速运行,请查看我们的 [快速开始](../quick-start.mdx) +- 如果您需要安装和运行 ClickHouse,请查看我们的 [快速入门](/get-started/quick-start) - [ClickHouse 教程](../tutorial.md) 分析了纽约市出租车出行的数据集 -此外,示例数据集提供了良好的使用 ClickHouse 经验,学习重要的技术和技巧,并了解如何利用 ClickHouse 中许多强大的功能。示例数据集包括: +此外,示例数据集为使用 ClickHouse 提供了很好的体验,帮助您学习重要的技术和技巧,以及了解如何利用 ClickHouse 中的许多强大功能。示例数据集包括: + + | 页面 | 描述 | |-----|-----| -| [纽约出租车数据](/getting-started/example-datasets/nyc-taxi) | 自 2009 年以来来自纽约市的数十亿次出租车和租车(Uber,Lyft 等)出行的数据 | -| [Criteo 的 TB 点击日志](/getting-started/example-datasets/criteo) | 来自 Criteo 的一 terabyte 点击日志 | -| [WikiStat](/getting-started/example-datasets/wikistat) | 探索包含 0.5 万亿条记录的 WikiStat 数据集。 | -| [TPC-DS (2012)](/getting-started/example-datasets/tpcds) | TPC-DS 基准数据集和查询。 | -| [食谱数据集](/getting-started/example-datasets/recipes) | RecipeNLG 数据集,包含 220 万个食谱 | -| [COVID-19 开放数据](/getting-started/example-datasets/covid19) | COVID-19 开放数据是一个大型开放源代码数据库,包含 COVID-19 流行病学数据及相关因素,如人口统计、经济和政府响应 | -| [NOAA 全球历史气候网络](/getting-started/example-datasets/noaa) | 过去 120 年的 25 亿行气候数据 | -| [GitHub 事件数据集](/getting-started/example-datasets/github-events) | 包含从 2011 到 2020 年 12 月 6 日 GitHub 上所有事件的数据集,大小为 31 亿条记录。 | -| [亚马逊客户评论](/getting-started/example-datasets/amazon-reviews) | 超过 1.5 亿条亚马逊产品的客户评论 | -| [布朗大学基准](/getting-started/example-datasets/brown-benchmark) | 一种用于机器生成日志数据的新分析基准 | -| [使用 GitHub 数据在 ClickHouse 中编写查询](/getting-started/example-datasets/github) | 包含 ClickHouse 仓库所有提交和更改的数据集 | +| [美国国家海洋和大气管理局全球历史气候网络](/getting-started/example-datasets/noaa) | 过去 120 年的 25 亿行气候数据 | +| [使用 GitHub 数据在 ClickHouse 中编写查询](/getting-started/example-datasets/github) | 包含 ClickHouse 仓库所有提交和变更的数据集 | | [使用 ClickHouse 分析 Stack Overflow 数据](/getting-started/example-datasets/stackoverflow) | 使用 ClickHouse 分析 Stack Overflow 数据 | +| [英国房产价格数据集](/getting-started/example-datasets/uk-price-paid) | 学习如何使用投影提高您频繁运行的查询的性能,使用的 UK 房产数据集包含有关英格兰和威尔士房地产支付价格的数据 | +| [台湾历史气象数据集](/getting-started/example-datasets/tw-weather) | 过去 128 年的 1.31 亿行气象观测数据 | +| [纽约出租车数据](/getting-started/example-datasets/nyc-taxi) | 自 2009 年以来来自纽约市的数十亿次出租车和租用车辆(Uber、Lyft 等)出行的数据 | +| [使用手机信号塔数据的地理数据](/getting-started/example-datasets/cell-towers) | 学习如何将 OpenCelliD 数据加载到 ClickHouse 中,连接 Apache Superset 到 ClickHouse 并基于数据构建仪表板 | +| [亚马逊客户评价](/getting-started/example-datasets/amazon-reviews) | 超过 1.5 亿条亚马逊产品的客户评价 | | [AMPLab 大数据基准](/getting-started/example-datasets/amplab-benchmark) | 用于比较数据仓库解决方案性能的基准数据集。 | -| [纽约公共图书馆“菜单上有什么?”数据集](/getting-started/example-datasets/menus) | 包含关于酒店、餐馆和咖啡馆菜单的历史数据的 130 万条记录,包含菜品及其价格。 | -| [Laion-400M 数据集](/getting-started/example-datasets/laion-400m-dataset) | 包含 4 亿张带有英文图像说明的图像的数据集 | +| [匿名网络分析](/getting-started/example-datasets/metrica) | 包含匿名网络分析数据(访问量和访问次数)的两个表的数据集 | +| [布朗大学基准](/getting-started/example-datasets/brown-benchmark) | 针对机器生成日志数据的新分析基准 | +| [COVID-19 开放数据](/getting-started/example-datasets/covid19) | COVID-19 开放数据是一个大型开源数据库,包含 COVID-19 流行病学数据和与之相关的因素,如人口统计、经济和政府回应 | +| [dbpedia 数据集](/getting-started/example-datasets/dbpedia-dataset) | 包含来自维基百科的 100 万篇文章及其向量嵌入的数据集 | +| [环境传感器数据](/getting-started/example-datasets/environmental-sensors) | 来自 Sensor.Community 的超过 200 亿条数据记录,这是一个由贡献者驱动的全球传感器网络,创建开放环境数据。 | +| [Foursquare 地点](/getting-started/example-datasets/foursquare-places) | 包含关于地图上地点(如商店、餐馆、公园、游乐场和纪念碑)信息的超过 1 亿条记录的数据集。 | +| [GitHub 事件数据集](/getting-started/example-datasets/github-events) | 包含 2011 年至 2020 年 12 月 6 日间 GitHub 上所有事件的数据集,数据规模为 31 亿条记录。 | +| [黑客新闻数据集](/getting-started/example-datasets/hacker-news) | 包含 2800 万行黑客新闻数据的数据集。 | +| [黑客新闻向量搜索数据集](/getting-started/example-datasets/hackernews-vector-search-dataset) | 包含 2800 万条黑客新闻帖子及其向量嵌入的数据集 | +| [LAION 5B 数据集](/getting-started/example-datasets/laion-5b-dataset) | 包含来自 LAION 5B 数据集的 1 亿个向量的数据集 | +| [Laion-400M 数据集](/getting-started/example-datasets/laion-400m-dataset) | 包含 4 亿张带有英文图像标题的图像的数据集 | +| [纽约公共图书馆“菜单上有什么?”数据集](/getting-started/example-datasets/menus) | 包含 130 万条关于酒店、餐厅和咖啡馆的历史菜单数据的记录,连同价格。 | +| [纽约市警察局投诉数据](/getting-started/example-datasets/nypd_complaint_data) | 5 步骤内摄取和查询制表符分隔值数据 | +| [准点](/getting-started/example-datasets/ontime) | 包含航空公司航班准点表现的数据集 | | [星型模式基准 (SSB, 2009)](/getting-started/example-datasets/star-schema) | 星型模式基准 (SSB) 数据集和查询 | -| [英国房产价格数据集](/getting-started/example-datasets/uk-price-paid) | 学习如何使用投影来提高您经常运行的查询的性能,使用 UK 房产数据集,其中包含关于英格兰和威尔士房地产交易价格的数据 | -| [Reddit 评论数据集](/getting-started/example-datasets/reddit-comments) | 包含从 2005 年 12 月到 2023 年 3 月 Reddit 上公开评论的数据集,包含超过 140 亿行 JSON 格式数据 | -| [OnTime](/getting-started/example-datasets/ontime) | 包含航空公司航班准时表现的数据集 | -| [台湾历史气象数据集](/getting-started/example-datasets/tw-weather) | 过去 128 年的 1.31 亿行天气观测数据 | -| [来自 OpenSky 网络的众包空中交通数据 2020](/getting-started/example-datasets/opensky) | 该数据集中的数据来源并从完整的 OpenSky 数据集清理,以说明 COVID-19 大流行期间的空中交通发展。 | -| [NYPD 投诉数据](/getting-started/example-datasets/nypd_complaint_data) | 以 5 个步骤吸收和查询制表符分隔值数据 | +| [来自 Criteo 的 TB 点击日志](/getting-started/example-datasets/criteo) | 来自 Criteo 的一个 TB 点击日志 | +| [TPC-DS (2012)](/getting-started/example-datasets/tpcds) | TPC-DS 基准数据集和查询。 | | [TPC-H (1999)](/getting-started/example-datasets/tpch) | TPC-H 基准数据集和查询。 | -| [Foursquare 地点](/getting-started/example-datasets/foursquare-places) | 具有超过 1 亿条记录的数据集,包含有关地图上地方的信息,例如商店、餐馆、公园、游乐场和纪念碑。 | -| [YouTube 不喜欢的数据集](/getting-started/example-datasets/youtube-dislikes) | YouTube 视频的不喜欢集合。 | -| [使用移动塔数据的地理数据](/getting-started/example-datasets/cell-towers) | 学习如何将 OpenCelliD 数据加载到 ClickHouse,将 Apache Superset 连接到 ClickHouse,并基于数据构建仪表板 | -| [环境传感器数据](/getting-started/example-datasets/environmental-sensors) | 来自 Sensor.Community 的超过 200 亿条记录的数据,这是一个由贡献者驱动的全球传感器网络,创建开放的环境数据。 | -| [匿名网站分析](/getting-started/example-datasets/metrica) | 包含两个表的数据集,包含匿名网站分析数据及其访问量和点击量 | +| [WikiStat](/getting-started/example-datasets/wikistat) | 探索包含 0.5 万亿条记录的 WikiStat 数据集。 | +| [YouTube 的不喜欢数据集](/getting-started/example-datasets/youtube-dislikes) | 一组 YouTube 视频的不喜欢记录。 | + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/index.md.hash index b9700d62a89..1c66fa5504c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/index.md.hash @@ -1 +1 @@ -a94756431eef4487 +d4fa07428e9a7b5c diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/_snippets/_deb_install.md b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/_snippets/_deb_install.md index 8c671ef9b5c..f7aa8ad2b34 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/_snippets/_deb_install.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/_snippets/_deb_install.md @@ -1,19 +1,14 @@ ---- -null -... ---- - import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; # 在 Debian/Ubuntu 上安装 ClickHouse {#install-from-deb-packages} -> 建议使用官方预编译的 `deb` 包来安装 **Debian** 或 **Ubuntu**。 +> 推荐使用官方预编译的 `deb` 包用于 **Debian** 或 **Ubuntu**。 -## 设置 Debian 存储库 {#setup-the-debian-repository} +## 设置 Debian 仓库 {#setup-the-debian-repository} 要安装 ClickHouse,请运行以下命令: @@ -39,11 +34,11 @@ echo "deb [signed-by=/usr/share/keyrings/clickhouse-keyring.gpg arch=${ARCH}] ht sudo apt-get update ``` -- 您可以将 `stable` 替换为 `lts`,以根据需要使用不同的 [发布类型](/knowledgebase/production)。 -- 您可以从 [packages.clickhouse.com](https://packages.clickhouse.com/deb/pool/main/c/) 手动下载并安装软件包。 +- 您可以根据需要将 `stable` 替换为 `lts` 以使用不同的 [发布类型](/knowledgebase/production)。 +- 您可以从 [packages.clickhouse.com](https://packages.clickhouse.com/deb/pool/main/c/) 手动下载和安装软件包。

-旧版本的 deb-packages 安装方法 +旧版本的 deb-package 安装方法 ```bash @@ -108,8 +103,8 @@ clickhouse-client --password :::tip 在生产环境中,我们强烈建议在专用节点上运行 ClickHouse Keeper。 -在测试环境中,如果您决定在同一台服务器上运行 ClickHouse Server 和 ClickHouse Keeper, -则无需安装 ClickHouse Keeper,因为它已包含在 ClickHouse 服务器中。 +在测试环境中,如果您决定在同一服务器上运行 ClickHouse 服务器和 ClickHouse Keeper, +则无需单独安装 ClickHouse Keeper,因为它包含在 ClickHouse 服务器中。 ::: 要在独立的 ClickHouse Keeper 服务器上安装 `clickhouse-keeper`,请运行: @@ -130,18 +125,18 @@ sudo systemctl status clickhouse-keeper ## 软件包 {#packages} -可用的各种 deb 软件包详述如下: +可用的各种 deb 软件包详情如下: -| 包 | 描述 | -|--------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `clickhouse-common-static` | 安装 ClickHouse 编译的二进制文件。 | -| `clickhouse-server` | 创建 `clickhouse-server` 的符号链接并安装默认服务器配置。 | -| `clickhouse-client` | 创建 `clickhouse-client` 的符号链接和其他与客户端相关的工具,并安装客户端配置文件。 | -| `clickhouse-common-static-dbg` | 安装带调试信息的 ClickHouse 编译的二进制文件。 | -| `clickhouse-keeper` | 用于在专用 ClickHouse Keeper 节点上安装 ClickHouse Keeper。如果您在与 ClickHouse 服务器相同的服务器上运行 ClickHouse Keeper,则无需安装此软件包。安装 ClickHouse Keeper 及默认的 ClickHouse Keeper 配置文件。 | +| 软件包 | 描述 | +|--------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `clickhouse-common-static` | 安装 ClickHouse 编译的二进制文件。 | +| `clickhouse-server` | 创建 `clickhouse-server` 的符号链接并安装默认的服务器配置。 | +| `clickhouse-client` | 创建 `clickhouse-client` 及其他与客户端相关工具的符号链接,并安装客户端配置文件。 | +| `clickhouse-common-static-dbg` | 安装 ClickHouse 编译的二进制文件,并包含调试信息。 | +| `clickhouse-keeper` | 用于在专用 ClickHouse Keeper 节点上安装 ClickHouse Keeper。如果您在与 ClickHouse 服务器相同的服务器上运行 ClickHouse Keeper,则无需安装此软件包。安装 ClickHouse Keeper 和默认的 ClickHouse Keeper 配置文件。 |
:::info -如果您需要安装特定版本的 ClickHouse,您必须安装具有相同版本的所有软件包: +如果您需要安装特定版本的 ClickHouse,必须安装所有相同版本的软件包: `sudo apt-get install clickhouse-server=21.8.5.7 clickhouse-client=21.8.5.7 clickhouse-common-static=21.8.5.7` ::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/_snippets/_docker.md b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/_snippets/_docker.md index cf5bd93b760..767c2c74c6b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/_snippets/_docker.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/_snippets/_docker.md @@ -1,12 +1,7 @@ ---- -null -... ---- - # 使用 Docker 安装 ClickHouse -为了方便,以下是 [Docker Hub](https://hub.docker.com/r/clickhouse/clickhouse-server/) 上的指南。可用的 Docker 镜像使用官方的 ClickHouse deb 包。 +下面为了方便起见重现了 [Docker Hub](https://hub.docker.com/r/clickhouse/clickhouse-server/) 上的指南。可用的 Docker 镜像使用官方的 ClickHouse deb 包。 Docker 拉取命令: @@ -17,16 +12,16 @@ docker pull clickhouse/clickhouse-server ## 版本 {#versions} - `latest` 标签指向最新稳定分支的最新发布版本。 -- 像 `22.2` 的分支标签指向相应分支的最新发布版本。 -- 完整版本标签如 `22.2.3` 和 `22.2.3.5` 指向相应的发布版本。 +- 分支标签如 `22.2` 指向相应分支的最新发布版本。 +- 完整版本标签如 `22.2.3` 和 `22.2.3.5` 指向相应版本的发布。 - `head` 标签是从默认分支的最新提交构建的。 -- 每个标签都有一个可选的 `-alpine` 后缀,以反映其基于 `alpine`。 +- 每个标签都有一个可选的 `-alpine` 后缀,以反映其基于 `alpine` 构建。 ### 兼容性 {#compatibility} -- amd64 镜像需要支持 [SSE3 指令](https://en.wikipedia.org/wiki/SSE3)。几乎所有2005年之后的 x86 CPU 都支持 SSE3。 -- arm64 镜像需要支持 [ARMv8.2-A 架构](https://en.wikipedia.org/wiki/AArch64#ARMv8.2-A),并且还需要 Load-Acquire RCpc 寄存器。该寄存器在 ARMv8.2-A 版本中是可选的,在 [ARMv8.3-A](https://en.wikipedia.org/wiki/AArch64#ARMv8.3-A) 中是强制性的。支持的设备包括 Graviton >=2、Azure 和 GCP 实例。不支持的设备示例有 Raspberry Pi 4 (ARMv8.0-A) 和 Jetson AGX Xavier/Orin (ARMv8.2-A)。 -- 从 ClickHouse 24.11 开始,Ubuntu 镜像开始使用 `ubuntu:22.04` 作为基础镜像。它需要 docker 版本 >= `20.10.10`,包含 [patch](https://github.com/moby/moby/commit/977283509f75303bc6612665a04abf76ff1d2468)。作为变通方法,您可以使用 `docker run --security-opt seccomp=unconfined`,但这有安全隐患。 +- amd64 镜像需要支持 [SSE3 指令](https://en.wikipedia.org/wiki/SSE3)。几乎所有 2005 年以后发布的 x86 CPU 都支持 SSE3。 +- arm64 镜像需要支持 [ARMv8.2-A 架构](https://en.wikipedia.org/wiki/AArch64#ARMv8.2-A),此外还需要 Load-Acquire RCpc 寄存器。该寄存器在 ARMv8.2-A 版本中是可选的,而在 [ARMv8.3-A](https://en.wikipedia.org/wiki/AArch64#ARMv8.3-A) 中是强制性的。支持的设备包括 Graviton >=2、Azure 和 GCP 实例。例子包括不支持的设备如 Raspberry Pi 4 (ARMv8.0-A) 和 Jetson AGX Xavier/Orin (ARMv8.2-A)。 +- 自 ClickHouse 24.11 以来,Ubuntu 镜像开始使用 `ubuntu:22.04` 作为基础镜像。它需要 docker 版本 >= `20.10.10`,包含 [补丁](https://github.com/moby/moby/commit/977283509f75303bc6612665a04abf76ff1d2468)。作为一种变通方法,您可以使用 `docker run --security-opt seccomp=unconfined`,但这有安全隐患。 ## 如何使用此镜像 {#how-to-use-image} @@ -36,11 +31,11 @@ docker pull clickhouse/clickhouse-server docker run -d --name some-clickhouse-server --ulimit nofile=262144:262144 clickhouse/clickhouse-server ``` -默认情况下,ClickHouse 只能通过 Docker 网络访问。请参阅下面的网络部分。 +默认情况下,ClickHouse 仅通过 Docker 网络可访问。请参见下面的网络部分。 -默认情况下,启动的上述服务器实例将作为 `default` 用户运行,无需密码。 +默认情况下,启动上述服务器实例将作为没有密码的 `default` 用户运行。 -### 从本地客户端连接 {#connect-to-it-from-native-client} +### 从本地客户端连接它 {#connect-to-it-from-native-client} ```bash docker run -it --rm --network=container:some-clickhouse-server --entrypoint clickhouse-client clickhouse/clickhouse-server @@ -49,17 +44,17 @@ docker run -it --rm --network=container:some-clickhouse-server --entrypoint clic docker exec -it some-clickhouse-server clickhouse-client ``` -有关 ClickHouse 客户端的更多信息,请参阅 [ClickHouse 客户端](/interfaces/cli)。 +有关 ClickHouse 客户端的更多信息,请参见 [ClickHouse client](/interfaces/cli)。 -### 使用 curl 连接 {#connect-to-it-using-curl} +### 使用 curl 连接它 {#connect-to-it-using-curl} ```bash echo "SELECT 'Hello, ClickHouse!'" | docker run -i --rm --network=container:some-clickhouse-server buildpack-deps:curl curl 'http://localhost:8123/?query=' -s --data-binary @- ``` -有关 HTTP 接口的更多信息,请参阅 [ClickHouse HTTP 接口](/interfaces/http)。 +有关 HTTP 接口的更多信息,请参见 [ClickHouse HTTP Interface](/interfaces/http)。 -### 停止/移除容器 {#stopping-removing-container} +### 停止 / 移除容器 {#stopping-removing-container} ```bash docker stop some-clickhouse-server @@ -69,17 +64,19 @@ docker rm some-clickhouse-server ### 网络 {#networking} :::note -预定义用户 `default` 除非设置了密码,否则没有网络访问权限,请参阅“如何在启动时创建默认数据库和用户”和下面的“管理 `default` 用户” +预定义用户 `default` 默认没有网络访问权限,除非设置了密码, +请参见下面的“如何在启动时创建默认数据库和用户”和“管理 `default` 用户”。 ::: -您可以通过 [映射特定端口](https://docs.docker.com/config/containers/container-networking/) 将容器内部的 ClickHouse 公开到主机端口: +您可以通过 [映射特定端口](https://docs.docker.com/config/containers/container-networking/) 从容器内部使用主机端口来暴露在 Docker 中运行的 ClickHouse: ```bash docker run -d -p 18123:8123 -p19000:9000 -e CLICKHOUSE_PASSWORD=changeme --name some-clickhouse-server --ulimit nofile=262144:262144 clickhouse/clickhouse-server echo 'SELECT version()' | curl 'http://localhost:18123/?password=changeme' --data-binary @- ``` -或者通过允许容器直接使用 [主机端口](https://docs.docker.com/network/host/) 使用 `--network=host`(也可以实现更好的网络性能): +或者通过允许容器直接使用 [主机端口](https://docs.docker.com/network/host/) 使用 `--network=host` +(也有助于实现更好的网络性能): ```bash docker run -d --network=host --name some-clickhouse-server --ulimit nofile=262144:262144 clickhouse/clickhouse-server @@ -87,12 +84,12 @@ echo 'SELECT version()' | curl 'http://localhost:8123/' --data-binary @- ``` :::note -上面示例中的默认用户仅对本地请求可用 +上面示例中的用户 default 仅对本地主机请求可用。 ::: ### 卷 {#volumes} -通常,您可能希望在容器内部挂载以下文件夹以实现持久性: +通常,您可能希望在容器内挂载以下文件夹以实现持久性: - `/var/lib/clickhouse/` - ClickHouse 存储数据的主要文件夹 - `/var/log/clickhouse-server/` - 日志 @@ -104,15 +101,15 @@ docker run -d \ --name some-clickhouse-server --ulimit nofile=262144:262144 clickhouse/clickhouse-server ``` -您还可能希望挂载: +您可能还希望挂载: -- `/etc/clickhouse-server/config.d/*.xml` - 带有服务器配置调整的文件 -- `/etc/clickhouse-server/users.d/*.xml` - 带有用户设置调整的文件 +- `/etc/clickhouse-server/config.d/*.xml` - 包含服务器配置调整的文件 +- `/etc/clickhouse-server/users.d/*.xml` - 包含用户设置调整的文件 - `/docker-entrypoint-initdb.d/` - 包含数据库初始化脚本的文件夹(见下文)。 -## Linux 功能 {#linear-capabilities} +## Linux 能力 {#linear-capabilities} -ClickHouse 有一些高级功能,这需要启用多个 [Linux 功能](https://man7.org/linux/man-pages/man7/capabilities.7.html)。 +ClickHouse 具有一些高级功能,要求启用几个 [Linux 能力](https://man7.org/linux/man-pages/man7/capabilities.7.html)。 它们是可选的,可以使用以下 [docker 命令行参数](https://docs.docker.com/engine/reference/run/#runtime-privilege-and-linux-capabilities) 启用: @@ -122,13 +119,13 @@ docker run -d \ --name some-clickhouse-server --ulimit nofile=262144:262144 clickhouse/clickhouse-server ``` -有关更多信息,请参阅 [“在 Docker 中配置 CAP_IPC_LOCK 和 CAP_SYS_NICE 功能”](/knowledgebase/configure_cap_ipc_lock_and_cap_sys_nice_in_docker)。 +有关更多信息,请参见 [“在 Docker 中配置 CAP_IPC_LOCK 和 CAP_SYS_NICE 能力”](/knowledgebase/configure_cap_ipc_lock_and_cap_sys_nice_in_docker)。 ## 配置 {#configuration} -容器通过端口 8123 提供 [HTTP 接口](https://clickhouse.com/docs/interfaces/http_interface/),通过端口 9000 提供 [本地客户端](https://clickhouse.com/docs/interfaces/tcp/)。 +容器暴露了端口 8123 用于 [HTTP 接口](https://clickhouse.com/docs/interfaces/http_interface/) 和端口 9000 用于 [本地客户端](https://clickhouse.com/docs/interfaces/tcp/)。 -ClickHouse 配置以文件 "config.xml" 表示([文档](https://clickhouse.com/docs/operations/configuration_files/))。 +ClickHouse 配置通过文件 "config.xml" 表示 ([文档](https://clickhouse.com/docs/operations/configuration_files/))。 ### 使用自定义配置启动服务器实例 {#start-server-instance-with-custom-config} @@ -136,14 +133,14 @@ ClickHouse 配置以文件 "config.xml" 表示([文档](https://clickhouse.com docker run -d --name some-clickhouse-server --ulimit nofile=262144:262144 -v /path/to/your/config.xml:/etc/clickhouse-server/config.xml clickhouse/clickhouse-server ``` -### 以自定义用户启动服务器 {#start-server-custom-user} +### 以自定义用户身份启动服务器 {#start-server-custom-user} -当您使用挂载本地目录的镜像时,您可能希望指定用户以维护正确的文件所有权。使用 `--user` 参数并挂载 `/var/lib/clickhouse` 和 `/var/log/clickhouse-server` 到容器内。否则,镜像将会提示错误并不会启动。 +当您使用挂载的本地目录的镜像时,您可能想指定用户以保持文件的适当所有权。使用 `--user` 参数并挂载 `/var/lib/clickhouse` 和 `/var/log/clickhouse-server` 到容器内部。否则,镜像将抱怨并不启动。 -### 以 root 用户启动服务器 {#start-server-from-root} +### 以 root 身份启动服务器 {#start-server-from-root} -以 root 用户启动服务器在启用用户命名空间的情况下非常有用。 -为此运行: +以 root 身份启动服务器在启用用户命名空间的情况下是有用的。 +为此,请运行: ```bash docker run --rm -e CLICKHOUSE_RUN_AS_ROOT=1 --name clickhouse-server-userns -v "$PWD/logs/clickhouse:/var/log/clickhouse-server" -v "$PWD/data/clickhouse:/var/lib/clickhouse" clickhouse/clickhouse-server @@ -151,7 +148,7 @@ docker run --rm -e CLICKHOUSE_RUN_AS_ROOT=1 --name clickhouse-server-userns -v " ### 如何在启动时创建默认数据库和用户 {#how-to-create-default-db-and-user} -有时,您可能希望在容器启动时创建一个用户(默认使用名为 `default` 的用户)和数据库。您可以使用环境变量 `CLICKHOUSE_DB`,`CLICKHOUSE_USER`,`CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT` 和 `CLICKHOUSE_PASSWORD` 来实现: +有时您可能希望在容器启动时创建一个用户(默认使用用户名为 `default`)和数据库。您可以使用环境变量 `CLICKHOUSE_DB`、`CLICKHOUSE_USER`、`CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT` 和 `CLICKHOUSE_PASSWORD` 来做到这一点: ```bash docker run --rm -e CLICKHOUSE_DB=my_database -e CLICKHOUSE_USER=username -e CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT=1 -e CLICKHOUSE_PASSWORD=password -p 9000:9000/tcp clickhouse/clickhouse-server @@ -159,7 +156,7 @@ docker run --rm -e CLICKHOUSE_DB=my_database -e CLICKHOUSE_USER=username -e CLIC #### 管理 `default` 用户 {#managing-default-user} -如果未设置 `CLICKHOUSE_USER`,`CLICKHOUSE_PASSWORD` 或 `CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT`,则默认情况下用户 `default` 被禁用网络访问。 +如果未设置 `CLICKHOUSE_USER`、`CLICKHOUSE_PASSWORD` 或 `CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT`,则默认情况下,用户 `default` 将禁用网络访问。 有一种方法可以通过将环境变量 `CLICKHOUSE_SKIP_USER_SETUP` 设置为 1 来不安全地使 `default` 用户可用: @@ -169,7 +166,7 @@ docker run --rm -e CLICKHOUSE_SKIP_USER_SETUP=1 -p 9000:9000/tcp clickhouse/clic ## 如何扩展此镜像 {#how-to-extend-image} -要在基于此镜像的镜像中执行其他初始化,请在 `/docker-entrypoint-initdb.d` 下添加一个或多个 `*.sql`,`*.sql.gz` 或 `*.sh` 脚本。在入口点调用 `initdb` 后,它将运行任何 `*.sql` 文件,运行任何可执行的 `*.sh` 脚本,并源任何在该目录中找到的非可执行 `*.sh` 脚本,以便在启动服务之前进行进一步初始化。 -此外,您可以提供环境变量 `CLICKHOUSE_USER` 和 `CLICKHOUSE_PASSWORD`,这些将用于初始化过程中点击点击客户端。 +要在此基础上派生的镜像中执行其他初始化,请在 `/docker-entrypoint-initdb.d` 下添加一个或多个 `*.sql`、`*.sql.gz` 或 `*.sh` 脚本。在 entrypoint 调用 `initdb` 后,它将运行任何 `*.sql` 文件,运行任何可执行的 `*.sh` 脚本,并读取该目录中找到的任何非可执行的 `*.sh` 脚本以在启动服务之前执行进一步的初始化。 +此外,您可以提供环境变量 `CLICKHOUSE_USER` 和 `CLICKHOUSE_PASSWORD`,在初始化过程中将用于 clickhouse-client。 -例如,要添加另一个用户和数据库,请将以下内容添加到 `/docker-entrypoint-initdb.d/init-db.sh`: +例如,要添加另一个用户和数据库,可以将以下内容添加到 `/docker-entrypoint-initdb.d/init-db.sh`: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/_snippets/_linux_tar_install.md b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/_snippets/_linux_tar_install.md index 72d63cbafe7..7c0ea583e1a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/_snippets/_linux_tar_install.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/_snippets/_linux_tar_install.md @@ -1,30 +1,25 @@ ---- -null -... ---- - # 使用 tgz 压缩包安装 ClickHouse -> 推荐在所有无法安装 `deb` 或 `rpm` 软件包的 Linux 发行版上使用官方预编译的 `tgz` 压缩包。 +> 推荐使用官方预编译的 `tgz` 压缩包,适用于所有 Linux 发行版,在无法安装 `deb` 或 `rpm` 软件包的情况下。 -## 下载并安装最新的稳定版本 {#install-latest-stable} +## 下载并安装最新稳定版本 {#install-latest-stable} -所需版本可以通过 `curl` 或 `wget` 从 https://packages.clickhouse.com/tgz/ 下载。 -下载的压缩包应该解压并通过安装脚本进行安装。 +所需版本可以通过 `curl` 或 `wget` 从仓库 https://packages.clickhouse.com/tgz/ 下载。 +下载后的压缩包应使用安装脚本进行解压和安装。 以下是如何安装最新稳定版本的示例。 :::note -对于生产环境,推荐使用最新的 `stable` 版本。 -您可以在这个 [GitHub 页面](https://github.com/ClickHouse/ClickHouse/tags) 上找到发布号,后缀为 `-stable`。 +对于生产环境,建议使用最新的 `stable` 版本。 +您可以在这 [GitHub 页面](https://github.com/ClickHouse/ClickHouse/tags) 上找到版本号,后缀为 `-stable`。 ::: ## 获取最新的 ClickHouse 版本 {#get-latest-version} -从 GitHub 获取最新的 ClickHouse 版本并将其存储在 `LATEST_VERSION` 变量中。 +从 GitHub 获取最新的 ClickHouse 版本并存储在 `LATEST_VERSION` 变量中。 ```bash LATEST_VERSION=$(curl -s https://raw.githubusercontent.com/ClickHouse/ClickHouse/master/utils/list-versions/version_date.tsv | \ @@ -46,8 +41,7 @@ esac ## 下载每个 ClickHouse 组件的 tarball {#download-tarballs} -下载每个 ClickHouse 组件的 tarball。循环先尝试特定架构的 -软件包,然后回退到通用软件包。 +下载每个 ClickHouse 组件的 tarball。循环首先尝试特定架构的软件包,然后回退到通用软件包。 ```bash for PKG in clickhouse-common-static clickhouse-common-static-dbg clickhouse-server clickhouse-client clickhouse-keeper @@ -59,7 +53,7 @@ done ## 解压并安装软件包 {#extract-and-install} -运行以下命令以解压并安装以下软件包: +运行以下命令以解压和安装以下软件包: - `clickhouse-common-static` ```bash @@ -70,7 +64,6 @@ tar -xzvf "clickhouse-common-static-$LATEST_VERSION-${ARCH}.tgz" \ sudo "clickhouse-common-static-$LATEST_VERSION/install/doinst.sh" ``` - - `clickhouse-common-static-dbg` ```bash @@ -102,6 +95,4 @@ tar -xzvf "clickhouse-client-$LATEST_VERSION-${ARCH}.tgz" \ sudo "clickhouse-client-$LATEST_VERSION/install/doinst.sh" ``` - - diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/_snippets/_linux_tar_install.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/_snippets/_linux_tar_install.md.hash index 1e9d4967d15..c259faa4749 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/_snippets/_linux_tar_install.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/_snippets/_linux_tar_install.md.hash @@ -1 +1 @@ -ce88623104cf637c +9c3b18fc7dba4e78 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/_snippets/_macos.md b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/_snippets/_macos.md index dd91047d0f8..b1f0e8853cd 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/_snippets/_macos.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/_snippets/_macos.md @@ -1,8 +1,3 @@ ---- -null -... ---- - import Image from "@theme/IdealImage"; import dev_error from "@site/static/images/knowledgebase/fix-the-developer-verification-error-in-macos/dev-verification-error.png"; import privacy_default from "@site/static/images/knowledgebase/fix-the-developer-verification-error-in-macos/privacy-and-security-default-view.png"; @@ -13,24 +8,24 @@ import privacy_allow from "@site/static/images/knowledgebase/fix-the-developer-v -## 使用社区 Homebrew 配方安装 {#install-using-community-homebrew-formula} +## 使用社区 Homebrew 配方进行安装 {#install-using-community-homebrew-formula} -要在 macOS 上使用 [Homebrew](https://brew.sh/) 安装 ClickHouse,您可以使用 ClickHouse 社区 [homebrew 配方](https://formulae.brew.sh/cask/clickhouse)。 +要在 macOS 上使用 [Homebrew](https://brew.sh/) 安装 ClickHouse,您可以使用 ClickHouse 社区提供的 [homebrew 配方](https://formulae.brew.sh/cask/clickhouse)。 ```bash brew install --cask clickhouse ``` -## 修复 MacOS 中的开发者验证错误 {#fix-developer-verification-error-macos} +## 修复 macOS 中的开发者验证错误 {#fix-developer-verification-error-macos} -如果您使用 `brew` 安装 ClickHouse,可能会遇到来自 MacOS 的错误。 -默认情况下,MacOS 不会运行无法验证的开发者创建的应用程序或工具。 +如果您使用 `brew` 安装 ClickHouse,您可能会遇到来自 macOS 的错误。 +默认情况下,macOS 不会运行由无法验证的开发者创建的应用程序或工具。 -当您尝试运行任何 `clickhouse` 命令时,可能会看到此错误: +当您尝试运行任何 `clickhouse` 命令时,您可能会看到以下错误: -要绕过此验证错误,您需要从 MacOS 的隔离箱中删除该应用程序,方法是找到系统设置窗口中的相应设置、使用终端或重新安装 ClickHouse。 +要解决此验证错误,您需要通过在系统设置窗口中找到相应的设置、使用终端或重新安装 ClickHouse 来从 macOS 的隔离箱中移除该应用。 ### 系统设置过程 {#system-settings-process} @@ -41,18 +36,18 @@ brew install --cask clickhouse -1. 滚动到窗口底部,找到一条消息,内容为 _"clickhouse-macos-aarch64" 被阻止使用,因为它不是来自已识别开发者的。 +1. 向下滚动到窗口底部,找到一条消息,内容为 _"clickhouse-macos-aarch64" 被阻止使用,因为它不是来自已识别的开发者。 1. 点击 **仍然允许**。 -1. 输入您的 MacOS 用户密码。 +1. 输入您的 macOS 用户密码。 -现在您应该能够在终端中运行 `clickhouse` 命令。 +您现在应该能够在终端中运行 `clickhouse` 命令。 ### 终端过程 {#terminal-process} -有时按下 `仍然允许` 按钮并不能解决此问题,在这种情况下,您也可以使用命令行执行此过程。 +有时,按下 `仍然允许` 按钮并不能解决此问题,在这种情况下,您还可以通过命令行执行此过程。 或者您可能更喜欢使用命令行! 首先找出 Homebrew 安装的 `clickhouse` 可执行文件的位置: @@ -61,38 +56,38 @@ brew install --cask clickhouse which clickhouse ``` -这应该输出如下内容: +这应该输出类似于以下内容: ```shell /opt/homebrew/bin/clickhouse ``` -通过运行 `xattr -d com.apple.quarantine` 删除 `clickhouse` 的隔离状态,后面跟上之前命令的路径: +通过运行 `xattr -d com.apple.quarantine` 后跟前一个命令中的路径来从隔离箱中移除 `clickhouse`: ```shell xattr -d com.apple.quarantine /opt/homebrew/bin/clickhouse ``` -现在您应该能够运行 `clickhouse` 可执行文件: +您现在应该能够运行 `clickhouse` 可执行文件: ```shell clickhouse ``` -这应该输出如下内容: +这应该输出类似于以下内容: ```bash Use one of the following commands: clickhouse local [args] clickhouse client [args] clickhouse benchmark [args] -... +``` -## Fix the issue by reinstalling ClickHouse {#fix-issue} +## 通过重新安装 ClickHouse 修复问题 {#fix-issue} -Brew has a command-line option which avoids quarantining installed binaries in the first place. +Brew 有一个命令行选项,避免在第一时间隔离已安装的二进制文件。 -First, uninstall ClickHouse: +首先,卸载 ClickHouse: ```shell brew uninstall clickhouse diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/_snippets/_macos.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/_snippets/_macos.md.hash index 02a2a0a8ee1..8716f8a7671 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/_snippets/_macos.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/_snippets/_macos.md.hash @@ -1 +1 @@ -3b6e4a216dd3db85 +9f73b5b7f8591684 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/_snippets/_quick_install.md b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/_snippets/_quick_install.md index 3855e2d69ca..7906e00ddc8 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/_snippets/_quick_install.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/_snippets/_quick_install.md @@ -1,32 +1,27 @@ ---- -null -... ---- +# 通过脚本使用 curl 安装 ClickHouse -# 使用 curl 脚本安装 ClickHouse - -如果您不需要为生产环境安装 ClickHouse,最快的方式是使用 curl 运行安装脚本。该脚本将为您的操作系统确定合适的二进制文件。 +如果您不需要在生产环境中安装 ClickHouse,最快的设置方法是运行使用 curl 的安装脚本。该脚本将确定适合您操作系统的二进制文件。 ## 使用 curl 安装 ClickHouse {#install-clickhouse-using-curl} -运行以下命令下载适合您的操作系统的单个二进制文件。 +运行以下命令以下载适合您操作系统的单一二进制文件。 ```bash curl https://clickhouse.com/ | sh ``` :::note -对于 Mac 用户:如果您收到无法验证二进制文件开发者的错误,请参见 [这里](/knowledgebase/fix-developer-verification-error-in-macos)。 +对于 Mac 用户:如果您收到二进制文件的开发者无法验证的错误,请查看 [这里](/knowledgebase/fix-developer-verification-error-in-macos)。 ::: ## 启动 clickhouse-local {#start-clickhouse-local} -`clickhouse-local` 允许您使用 ClickHouse 强大的 SQL 语法处理本地和远程文件,无需配置。表数据存储在临时位置,这意味着在重启 `clickhouse-local` 后,先前创建的表将不再可用。 +`clickhouse-local` 允许您使用 ClickHouse 强大的 SQL 语法处理本地和远程文件,无需配置。表数据存储在临时位置,这意味着在重新启动 `clickhouse-local` 后,之前创建的表将不再可用。 -运行以下命令启动 [clickhouse-local](/operations/utilities/clickhouse-local): +运行以下命令以启动 [clickhouse-local](/operations/utilities/clickhouse-local): ```bash ./clickhouse @@ -34,7 +29,7 @@ curl https://clickhouse.com/ | sh ## 启动 clickhouse-server {#start-clickhouse-server} -如果您希望持久化数据,您需要运行 `clickhouse-server`。您可以使用以下命令启动 ClickHouse 服务器: +如果您希望持久化数据,您将需要运行 `clickhouse-server`。您可以使用以下命令启动 ClickHouse 服务器: ```bash ./clickhouse server @@ -42,13 +37,13 @@ curl https://clickhouse.com/ | sh ## 启动 clickhouse-client {#start-clickhouse-client} -服务器运行后,打开一个新的终端窗口并运行以下命令启动 `clickhouse-client`: +服务器启动后,打开一个新的终端窗口并运行以下命令以启动 `clickhouse-client`: ```bash ./clickhouse client ``` -您将看到类似这样的内容: +您将看到如下内容: ```response ./clickhouse client @@ -59,12 +54,12 @@ Connected to ClickHouse server version 24.5.1. local-host :) ``` -表数据存储在当前目录中,并且在 ClickHouse 服务器重启后仍然可用。如果需要,您可以将 `-C config.xml` 作为额外的命令行参数传递给 `./clickhouse server`,并在配置文件中提供进一步的配置。所有可用的配置设置都在 [这里](/operations/server-configuration-parameters/settings) 和 [示例配置文件模板](https://github.com/ClickHouse/ClickHouse/blob/master/programs/server/config.xml) 中有详细记录。 +表数据存储在当前目录中,并且在 ClickHouse 服务器重新启动后仍然可用。如有必要,您可以将 `-C config.xml` 作为额外的命令行参数传递给 `./clickhouse server` 并在配置文件中提供进一步的配置。所有可用的配置设置在 [这里](/operations/server-configuration-parameters/settings) 和 [示例配置文件模板](https://github.com/ClickHouse/ClickHouse/blob/master/programs/server/config.xml) 中有文档说明。 -您现在准备开始向 ClickHouse 发送 SQL 命令了! +您现在准备好开始向 ClickHouse 发送 SQL 命令了! :::tip -[快速开始](/quick-start.mdx) 介绍了创建表和插入数据的步骤。 +[快速入门](/get-started/quick-start) 指导您完成创建表和插入数据的步骤。 ::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/_snippets/_quick_install.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/_snippets/_quick_install.md.hash index 6bf44c62680..749a08e0924 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/_snippets/_quick_install.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/_snippets/_quick_install.md.hash @@ -1 +1 @@ -d4d61480dfb324cc +b077704209f9ea1c diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/_snippets/_rpm_install.md b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/_snippets/_rpm_install.md index 0cb4eedd590..9aa0bcd784c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/_snippets/_rpm_install.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/_snippets/_rpm_install.md @@ -1,17 +1,12 @@ ---- -null -... ---- +# 在 rpm 系统上安装 ClickHouse {#from-rpm-packages} -# 在基于rpm的发行版上安装ClickHouse {#from-rpm-packages} - -> 建议使用官方预编译的 `rpm` 软件包来安装 **CentOS**、**RedHat** 以及其他所有基于rpm的 +> 建议使用官方预编译的 `rpm` 软件包来安装 **CentOS**、**RedHat** 及所有其他基于 rpm 的 > Linux 发行版。 -## 设置RPM仓库 {#setup-the-rpm-repository} +## 设置 RPM 仓库 {#setup-the-rpm-repository} 通过运行以下命令添加官方仓库: @@ -20,34 +15,34 @@ sudo yum install -y yum-utils sudo yum-config-manager --add-repo https://packages.clickhouse.com/rpm/clickhouse.repo ``` -对于使用 `zypper` 包管理器的系统(如openSUSE,SLES),请运行: +对于使用 `zypper` 包管理器的系统 (openSUSE, SLES),请运行: ```bash sudo zypper addrepo -r https://packages.clickhouse.com/rpm/clickhouse.repo -g sudo zypper --gpg-auto-import-keys refresh clickhouse-stable ``` -在下面的步骤中,`yum install` 可以根据您使用的包管理器替换为 `zypper install`。 +在以下步骤中,`yum install` 可以根据您使用的包管理器替换为 `zypper install`。 -## 安装ClickHouse服务器和客户端 {#install-clickhouse-server-and-client-1} +## 安装 ClickHouse 服务器和客户端 {#install-clickhouse-server-and-client-1} -要安装ClickHouse,运行以下命令: +要安装 ClickHouse,请运行以下命令: ```bash sudo yum install -y clickhouse-server clickhouse-client ``` -- 您可以将 `stable` 替换为 `lts`,以根据您的需求使用不同的 [发布类型](/knowledgebase/production)。 +- 您可以根据需要将 `stable` 替换为 `lts` 以使用不同的 [版本类型](/knowledgebase/production)。 - 您可以从 [packages.clickhouse.com/rpm](https://packages.clickhouse.com/rpm/stable) 手动下载和安装软件包。 -- 要指定特定版本,请在软件包名称的末尾添加 `-$version`,例如: +- 要指定特定版本,请在软件包名称末尾添加 `-$version`,例如: ```bash sudo yum install clickhouse-server-22.8.7.34 ``` -## 启动ClickHouse服务器 {#start-clickhouse-server-1} +## 启动 ClickHouse 服务器 {#start-clickhouse-server-1} -要启动ClickHouse服务器,请运行: +要启动 ClickHouse 服务器,请运行: ```bash sudo systemctl enable clickhouse-server @@ -55,7 +50,7 @@ sudo systemctl start clickhouse-server sudo systemctl status clickhouse-server ``` -要启动ClickHouse客户端,请运行: +要启动 ClickHouse 客户端,请运行: ```sql clickhouse-client @@ -67,20 +62,21 @@ clickhouse-client clickhouse-client --password ``` -## 安装独立的ClickHouse Keeper {#install-standalone-clickhouse-keeper-1} +## 安装独立的 ClickHouse Keeper {#install-standalone-clickhouse-keeper-1} :::tip -在生产环境中,我们强烈建议在专用节点上运行ClickHouse Keeper。 -在测试环境中,如果您决定在同一服务器上运行ClickHouse Server和ClickHouse Keeper,则无需安装ClickHouse Keeper,因为它已包含在ClickHouse服务器中。 +在生产环境中,我们强烈建议在专用节点上运行 ClickHouse Keeper。 +在测试环境中,如果您决定在同一服务器上运行 ClickHouse Server 和 ClickHouse Keeper, +则无需单独安装 ClickHouse Keeper,因为它已包含在 ClickHouse 服务器中。 ::: -要在独立的ClickHouse Keeper服务器上安装 `clickhouse-keeper`,请运行: +要在独立的 ClickHouse Keeper 服务器上安装 `clickhouse-keeper`,请运行: ```bash sudo yum install -y clickhouse-keeper ``` -## 启用并启动ClickHouse Keeper {#enable-and-start-clickhouse-keeper-1} +## 启用并启动 ClickHouse Keeper {#enable-and-start-clickhouse-keeper-1} ```bash sudo systemctl enable clickhouse-keeper diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/_snippets/_windows_install.md b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/_snippets/_windows_install.md index 7c6966a0486..b5a32f6c5cc 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/_snippets/_windows_install.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/_snippets/_windows_install.md @@ -1,75 +1,70 @@ ---- -null -... ---- +# 在 Windows 上通过 WSL 安装 ClickHouse -# 在Windows上通过WSL安装ClickHouse - -## 系统要求 {#requirements} +## 需求 {#requirements} :::note -要在Windows上安装ClickHouse,您需要WSL(Windows子系统Linux)。 +要在 Windows 上安装 ClickHouse,您需要 WSL(Windows 子系统 Linux)。 ::: -## 安装WSL {#install-wsl} +## 安装 WSL {#install-wsl} -以管理员身份打开Windows PowerShell并运行以下命令: +以管理员身份打开 Windows PowerShell,并运行以下命令: ```bash wsl --install ``` -系统将提示您输入新的UNIX用户名和密码。在您输入所需的用户名和密码后,您应该会看到类似以下的消息: +系统会提示您输入新的 UNIX 用户名和密码。输入所需的用户名和密码后,您应该会看到类似以下的消息: ```bash Welcome to Ubuntu 24.04.1 LTS (GNU/Linux 5.15.133.1-microsoft-WSL2 x86_64) ``` -## 通过脚本使用curl安装ClickHouse {#install-clickhouse-via-script-using-curl} +## 通过 curl 脚本安装 ClickHouse {#install-clickhouse-via-script-using-curl} -运行以下命令通过脚本使用curl安装ClickHouse: +运行以下命令通过 curl 脚本安装 ClickHouse: ```bash curl https://clickhouse.com/ | sh ``` -如果脚本成功运行,您将看到消息: +如果脚本成功运行,您将看到以下消息: ```bash Successfully downloaded the ClickHouse binary, you can run it as: ./clickhouse ``` -## 启动clickhouse-local {#start-clickhouse-local} +## 启动 clickhouse-local {#start-clickhouse-local} -`clickhouse-local`允许您使用ClickHouse强大的SQL语法处理本地和远程文件,而无需配置。表数据存储在临时位置,这意味着在重启`clickhouse-local`后,先前创建的表将不再可用。 +`clickhouse-local` 允许您使用 ClickHouse 强大的 SQL 语法处理本地和远程文件,无需配置。表数据存储在临时位置,这意味着在重新启动 `clickhouse-local` 后,之前创建的表将不再可用。 -运行以下命令启动[clickhouse-local](/operations/utilities/clickhouse-local): +运行以下命令启动 [clickhouse-local](/operations/utilities/clickhouse-local): ```bash ./clickhouse ``` -## 启动clickhouse-server {#start-clickhouse-server} +## 启动 clickhouse-server {#start-clickhouse-server} -如果您希望持久化数据,您需要运行`clickhouse-server`。您可以使用以下命令启动ClickHouse服务器: +如果您希望持久化数据,您需要运行 `clickhouse-server`。您可以使用以下命令启动 ClickHouse 服务器: ```bash ./clickhouse server ``` -## 启动clickhouse-client {#start-clickhouse-client} +## 启动 clickhouse-client {#start-clickhouse-client} -服务器启动后,打开一个新的终端窗口并运行以下命令以启动`clickhouse-client`: +服务器启动后,打开一个新的终端窗口并运行以下命令以启动 `clickhouse-client`: ```bash ./clickhouse client ``` -您将看到类似以下内容: +您将看到如下内容: ```response ./clickhouse client @@ -80,8 +75,8 @@ Connected to ClickHouse server version 24.5.1. local-host :) ``` -表数据存储在当前目录中,并且在ClickHouse服务器重启后仍可用。如果需要,您可以将`-C config.xml`作为附加命令行参数传递给`./clickhouse server`,并在配置文件中提供更多配置。所有可用的配置设置在[这里](/operations/server-configuration-parameters/settings)和[示例配置文件模板](https://github.com/ClickHouse/ClickHouse/blob/master/programs/server/config.xml)中都有文档说明。 +表数据存储在当前目录中,并且在 ClickHouse 服务器重新启动后仍然可用。如果需要,您可以将 `-C config.xml` 作为附加命令行参数传递给 `./clickhouse server`,并在配置文件中提供更多配置。所有可用的配置设置在 [这里](/operations/server-configuration-parameters/settings) 和 [示例配置文件模板](https://github.com/ClickHouse/ClickHouse/blob/master/programs/server/config.xml) 中记录。 -您现在已经准备好开始向ClickHouse发送SQL命令! +您现在准备好向 ClickHouse 发送 SQL 命令了! diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/advanced.md b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/advanced.md index 2190b039b91..7830637d779 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/advanced.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/advanced.md @@ -1,5 +1,5 @@ --- -'description': '编译 ClickHouse 源码或安装 CI 生成的二进制文件的 Instructions' +'description': '从源代码编译 ClickHouse 或安装 CI 生成的二进制文件的说明' 'keywords': - 'ClickHouse' - 'install' @@ -10,20 +10,21 @@ 'slug': '/install/advanced' 'title': '高级安装方法' 'hide_title': false +'doc_type': 'guide' --- ## 从源代码编译 {#compile-from-source} -要手动编译 ClickHouse,请按照 [Linux](/development/build.md) 或 [macOS](/development/build-osx.md) 的说明进行操作。 +要手动编译 ClickHouse,请遵循 [Linux](/development/build.md) 或 [macOS](/development/build-osx.md) 的说明。 -您可以编译包并安装它们,或者在不安装包的情况下使用程序。 +您可以编译包并安装它们或在不安装包的情况下使用程序。 ```xml Client: /programs/clickhouse-client Server: /programs/clickhouse-server ``` -您需要手动创建数据和元数据文件夹,并为所需用户 `chown` 它们。它们的路径可以在服务器配置(src/programs/server/config.xml)中更改,默认路径为: +您需要手动创建数据和元数据文件夹,并对其进行 `chown` 设置为所需的用户。它们的路径可以在服务器配置中更改 (src/programs/server/config.xml),默认情况下它们是: ```bash /var/lib/clickhouse/data/default/ @@ -34,18 +35,18 @@ Server: /programs/clickhouse-server ## 安装 CI 生成的二进制文件 {#install-a-ci-generated-binary} -ClickHouse 的持续集成(CI)基础设施为 [ClickHouse 仓库](https://github.com/clickhouse/clickhouse/) 中的每个提交生成特定的构建,例如 [sanitized](https://github.com/google/sanitizers) 构建、未优化的(Debug)构建、交叉编译构建等。虽然这些构建通常仅在开发期间有用,但在某些情况下对用户来说也可能有趣。 +ClickHouse 的持续集成 (CI) 基础设施为 [ClickHouse 仓库](https://github.com/clickhouse/clickhouse/) 中的每个提交生成专用构建,例如 [sanitized](https://github.com/google/sanitizers) 构建、未优化 (Debug) 构建、交叉编译构建等。虽然此类构建在开发期间通常才有用,但在某些情况下,对用户来说也可能很有趣。 :::note -由于 ClickHouse 的 CI 正在不断发展,下载 CI 生成的构建的确切步骤可能会有所不同。 -此外,CI 可能会删除过旧的构建工件,使其无法下载。 +由于 ClickHouse 的 CI 随着时间而发展,下载 CI 生成构建的确切步骤可能会有所不同。 +此外,CI 可能会删除旧的构建工件,使其无法下载。 ::: -例如,要下载 ClickHouse v23.4 的 aarch64 二进制文件,请按照以下步骤进行: +例如,要下载 ClickHouse v23.4 的 aarch64 二进制文件,请按照以下步骤操作: -- 查找版本 v23.4 的 GitHub 拉取请求:[Release pull request for branch 23.4](https://github.com/ClickHouse/ClickHouse/pull/49238) -- 点击“Commits”,然后点击您希望安装的特定版本的一个类似于“Update autogenerated version to 23.4.2.1 and contributors”的提交。 -- 点击绿色复选框 / 黄色圆点 / 红色叉号以打开 CI 检查列表。 -- 点击列表中“Builds”旁边的“Details”,这将打开一个类似于 [这个页面](https://s3.amazonaws.com/clickhouse-test-reports/46793/b460eb70bf29b19eadd19a1f959b15d186705394/clickhouse_build_check/report.html) 的页面。 -- 找到 compiler = "clang-*-aarch64" 的行 - 有多行。 +- 找到 v23.4 发布的 GitHub 拉取请求:[Release pull request for branch 23.4](https://github.com/ClickHouse/ClickHouse/pull/49238) +- 点击“提交”,然后点击您要安装的特定版本类似于“将自动生成的版本更新为 23.4.2.1 和贡献者”的提交。 +- 点击绿色检查/黄色点/红色叉以打开 CI 检查列表。 +- 在列表中点击"Builds"旁边的“详细信息”;这将打开一个类似于 [此页面](https://s3.amazonaws.com/clickhouse-test-reports/46793/b460eb70bf29b19eadd19a1f959b15d186705394/clickhouse_build_check/report.html) 的页面。 +- 找到编译器 = "clang-*-aarch64" 的行——会有多行。 - 下载这些构建的工件。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/advanced.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/advanced.md.hash index 17b737ec9fa..02feb43516e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/advanced.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/advanced.md.hash @@ -1 +1 @@ -af25af033e5c76f8 +1ad389baec4f9c3a diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/debian_ubuntu.md b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/debian_ubuntu.md index a13e191c4cc..9c70e4077a7 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/debian_ubuntu.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/debian_ubuntu.md @@ -1,5 +1,5 @@ --- -'description': '在Debian/Ubuntu Linux上安装ClickHouse' +'description': '在 Debian/Ubuntu Linux 上安装 ClickHouse' 'keywords': - 'ClickHouse' - 'install' @@ -8,8 +8,9 @@ - 'deb' 'sidebar_label': 'Debian/Ubuntu' 'slug': '/install/debian_ubuntu' -'title': '在Debian/Ubuntu上安装ClickHouse' +'title': '在 Debian/Ubuntu 上安装 ClickHouse' 'hide_title': true +'doc_type': 'guide' --- import DebianProd from './_snippets/_deb_install.md' diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/debian_ubuntu.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/debian_ubuntu.md.hash index be7d7541fb2..d92683c50d7 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/debian_ubuntu.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/debian_ubuntu.md.hash @@ -1 +1 @@ -0df8c4dffb04b138 +4739e7c7aa367dd5 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/docker.md b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/docker.md index edbc0ca8a3c..c61f2a10512 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/docker.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/docker.md @@ -6,8 +6,9 @@ - 'Docker' 'sidebar_label': 'Docker' 'slug': '/install/docker' -'title': '使用 Docker 安装 ClickHouse' +'title': '通过 Docker 安装 ClickHouse' 'hide_title': true +'doc_type': 'guide' --- import Docker from './_snippets/_docker.md' diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/docker.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/docker.md.hash index 5913ffa42ad..b1de82baa3c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/docker.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/docker.md.hash @@ -1 +1 @@ -06d7e6938b4a79ec +26a0bb71c4377d1e diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/install.mdx b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/install.mdx index d50a9b8b230..61419a95989 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/install.mdx +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/install.mdx @@ -8,6 +8,7 @@ 'sidebar_label': '安装' 'slug': '/install' 'title': '安装 ClickHouse' +'doc_type': 'guide' --- import InstallSelector from '@site/src/components/Install/Install' @@ -19,25 +20,26 @@ import RPMProd from './_snippets/_rpm_install.md' import MacOSProd from './_snippets/_macos.md' import Docker from './_snippets/_docker.md' import {CardPrimary} from '@clickhouse/click-ui/bundled'; +import {galaxyOnClick} from '@site/src/lib/galaxy/galaxy' # 安装说明
-或者,选择一个平台、分发版本和安装方式,以下是 Opensource ClickHouse 的安装说明: +或者,选择以下平台、发行版和安装方法,以查看 Opensource ClickHouse 的安装说明: } diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/install.mdx.hash b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/install.mdx.hash index 3e3f943468f..c9ecb5bf438 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/install.mdx.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/install.mdx.hash @@ -1 +1 @@ -5aaf8460e580e424 +cd1c75a8c9d58702 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/macos.md b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/macos.md index db1b29a1b4a..422b08aafed 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/macos.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/macos.md @@ -6,8 +6,9 @@ - 'MacOS' 'sidebar_label': 'MacOS' 'slug': '/install/macOS' -'title': '通过 Homebrew 安装 ClickHouse' +'title': '使用 Homebrew 安装 ClickHouse' 'hide_title': true +'doc_type': 'guide' --- import MacOSProd from './_snippets/_macos.md' diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/macos.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/macos.md.hash index 99a7f82c2fc..3589b9cfe6e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/macos.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/macos.md.hash @@ -1 +1 @@ -0a1dc00dd37f7819 +52deafa2f7d1593c diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/other_linux.md b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/other_linux.md index 163b9e84b32..74efec343ef 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/other_linux.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/other_linux.md @@ -7,8 +7,9 @@ - 'tar' 'sidebar_label': '其他 Linux' 'slug': '/install/linux_other' -'title': '使用 tgz 归档安装 ClickHouse' +'title': '使用 tgz 压缩包安装 ClickHouse' 'hide_title': true +'doc_type': 'guide' --- import Tar from './_snippets/_linux_tar_install.md' diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/other_linux.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/other_linux.md.hash index 360080b83a6..d47d76b0cd6 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/other_linux.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/other_linux.md.hash @@ -1 +1 @@ -fc409de0c18bc080 +6c5efaed2554723d diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/quick-install-curl.md b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/quick-install-curl.md index 026c39a07b1..5cca33dd4c8 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/quick-install-curl.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/quick-install-curl.md @@ -7,8 +7,9 @@ - 'curl' 'sidebar_label': '快速安装' 'slug': '/install/quick-install-curl' -'title': '通过脚本使用 curl 安装 ClickHouse' +'title': '通过 curl 使用脚本安装 ClickHouse' 'hide_title': true +'doc_type': 'guide' --- import QuickInstall from './_snippets/_quick_install.md' diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/quick-install-curl.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/quick-install-curl.md.hash index 6fcfd4c00f3..7fd0b5e1ba1 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/quick-install-curl.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/quick-install-curl.md.hash @@ -1 +1 @@ -2d2ce2f22a556da5 +868c885de22428c2 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/redhat.md b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/redhat.md index 46ba520549e..f2d3c436390 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/redhat.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/redhat.md @@ -10,6 +10,7 @@ 'slug': '/install/redhat' 'title': '在基于rpm的Linux发行版上安装ClickHouse' 'hide_title': true +'doc_type': 'guide' --- import RPM from './_snippets/_rpm_install.md' diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/redhat.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/redhat.md.hash index 9d465d423a1..27014308743 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/redhat.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/redhat.md.hash @@ -1 +1 @@ -5622fa1569f522bd +c06a2fc979646db2 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/windows.md b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/windows.md index 258c11f4deb..da2ae5b73cb 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/windows.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/windows.md @@ -1,5 +1,5 @@ --- -'description': '在 Windows 上通过 WSL 安装 ClickHouse' +'description': '在WSL上安装ClickHouse的Windows' 'keywords': - 'ClickHouse' - 'install' @@ -7,8 +7,9 @@ - 'rpm' 'sidebar_label': 'Windows' 'slug': '/install/windows' -'title': '在 Windows 上通过 WSL 安装 ClickHouse' +'title': '在WSL上安装ClickHouse的Windows' 'hide_title': true +'doc_type': 'guide' --- import Windows from './_snippets/_windows_install.md' diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/windows.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/windows.md.hash index d6f59b64e08..21650e7bca8 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/windows.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/install/windows.md.hash @@ -1 +1 @@ -bb3ad178ec7d45e2 +cb3d5ebc056b28f7 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/playground.md b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/playground.md index ea3cf5cca1b..f40b190a2c9 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/playground.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/playground.md @@ -1,5 +1,5 @@ --- -'description': 'ClickHouse Playground 允许人们通过即时运行查询来实验 ClickHouse,而无需设置他们的服务器或集群。' +'description': 'ClickHouse Playground 允许人们通过即时运行查询来实验 ClickHouse ,而无需设置他们的服务器或集群。' 'keywords': - 'clickhouse' - 'playground' @@ -9,42 +9,44 @@ 'sidebar_label': 'ClickHouse Playground' 'slug': '/getting-started/playground' 'title': 'ClickHouse Playground' +'doc_type': 'guide' --- -# ClickHouse Playground +# ClickHouse playground -[ClickHouse Playground](https://sql.clickhouse.com) 允许用户通过即时运行查询来实验 ClickHouse,而无需设置他们的服务器或集群。Playground 中提供了几个示例数据集。 +[ClickHouse Playground](https://sql.clickhouse.com) 允许用户通过即时运行查询来试验 ClickHouse,而无需设置他们的服务器或集群。 +在 Playground 中提供了若干示例数据集。 您可以使用任何 HTTP 客户端向 Playground 发起查询,例如 [curl](https://curl.haxx.se) 或 [wget](https://www.gnu.org/software/wget/),或使用 [JDBC](../interfaces/jdbc.md) 或 [ODBC](../interfaces/odbc.md) 驱动程序建立连接。有关支持 ClickHouse 的软件产品的更多信息,请访问 [这里](../integrations/index.mdx)。 ## Credentials {#credentials} -| 参数 | 值 | -|:----------------------|:-------------------------------------| -| HTTPS 端点 | `https://play.clickhouse.com:443/` | -| 原生 TCP 端点 | `play.clickhouse.com:9440` | -| 用户 | `explorer` 或 `play` | -| 密码 | (空) | +| 参数 | 值 | +|:--------------------|:-------------------------------------| +| HTTPS 端点 | `https://play.clickhouse.com:443/` | +| 原生 TCP 端点 | `play.clickhouse.com:9440` | +| 用户 | `explorer` 或 `play` | +| 密码 | (空) | ## Limitations {#limitations} -查询以只读用户的身份执行。这意味着有一些限制: +查询以只读用户身份执行。这意味着一些限制: - 不允许 DDL 查询 - 不允许 INSERT 查询 -该服务还对其使用有配额限制。 +该服务在使用上也有配额限制。 ## Examples {#examples} -使用 `curl` 的 HTTPS 端点示例: +HTTPS 端点示例使用 `curl`: ```bash curl "https://play.clickhouse.com/?user=explorer" --data-binary "SELECT 'Play ClickHouse'" ``` -使用 [CLI](../interfaces/cli.md) 的 TCP 端点示例: +TCP 端点示例使用 [CLI](../interfaces/cli.md): ```bash clickhouse client --secure --host play.clickhouse.com --user explorer @@ -52,8 +54,8 @@ clickhouse client --secure --host play.clickhouse.com --user explorer ## Playground specifications {#specifications} -我们的 ClickHouse Playground 运行在以下规格上: +我们的 ClickHouse Playground 的规格如下: -- 托管在美国中部地区的 Google Cloud (GCE) (US-Central-1) +- 托管在美国中部地区(US-Central-1)的 Google Cloud (GCE) 上 - 3 副本设置 -- 每个副本 256 GiB 的存储和 59 个虚拟 CPU。 +- 每个副本 256 GiB 存储和 59 虚拟 CPU。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/playground.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/playground.md.hash index 3b0f6f98240..468cd434633 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/playground.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/playground.md.hash @@ -1 +1 @@ -1ae6338cec94b038 +48f1b0895da329b3 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/quick-start/cloud.mdx b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/quick-start/cloud.mdx new file mode 100644 index 00000000000..b2123d39e57 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/quick-start/cloud.mdx @@ -0,0 +1,313 @@ +--- +'sidebar_position': 1 +'slug': '/getting-started/quick-start/cloud' +'sidebar_label': 'Cloud' +'keywords': +- 'clickhouse' +- 'install' +- 'getting started' +- 'quick start' +'title': 'ClickHouse Cloud 快速入门' +'description': 'ClickHouse Cloud 的快速入门指南' +'doc_type': 'guide' +--- + +import Image from '@theme/IdealImage'; +import signup_page from '@site/static/images/_snippets/signup_page.png'; +import select_plan from '@site/static/images/_snippets/select_plan.png'; +import createservice1 from '@site/static/images/_snippets/createservice1.png'; +import scaling_limits from '@site/static/images/_snippets/scaling_limits.png'; +import createservice8 from '@site/static/images/_snippets/createservice8.png'; +import show_databases from '@site/static/images/_snippets/show_databases.png'; +import service_connect from '@site/static/images/_snippets/service_connect.png'; +import data_sources from '@site/static/images/_snippets/data_sources.png'; +import select_data_source from '@site/static/images/_snippets/select_data_source.png'; +import client_details from '@site/static/images/_snippets/client_details.png'; +import new_rows_from_csv from '@site/static/images/_snippets/new_rows_from_csv.png'; +import SQLConsoleDetail from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_launch_sql_console.md'; + + +# ClickHouse Cloud 快速入门 + +> 使用 ClickHouse 的快速和简单的方法是在 [ClickHouse Cloud](https://console.clickhouse.cloud) 中创建一个新的服务。在本快速入门指南中,我们将通过三个简单步骤帮助您设置。 + + + +## 创建 ClickHouse 服务 {#1-create-a-clickhouse-service} + +要在 [ClickHouse Cloud](https://console.clickhouse.cloud) 中创建免费的 ClickHouse 服务,您只需通过完成以下步骤进行注册: + + - 在 [注册页面](https://console.clickhouse.cloud/signUp) 创建账户 + - 您可以选择使用电子邮件或通过 Google SSO、Microsoft SSO、AWS Marketplace、Google Cloud 或 Microsoft Azure 注册 + - 如果您使用电子邮件和密码注册,请记得在接下来的 24 小时内通过电子邮件中收到的链接验证您的电子邮件地址 + - 使用您刚刚创建的用户名和密码登录 + + +
+ +登录后,ClickHouse Cloud 会启动入职向导,引导您创建新的 ClickHouse 服务。选择您希望部署服务的区域,并为您的新服务命名: + + +
+ +默认情况下,新组织会被放置在 Scale 级别,并将在每个副本上创建 3 个 ^^replica^^,每个副本配置有 4 个 VCPUs 和 16 GiB RAM。[垂直自动扩展](/manage/scaling#vertical-auto-scaling) 在 Scale 级别上默认启用。服务创建后,可以在您的组织的“计划”页面上更改组织级别。 + +如果需要,用户可以自定义服务资源,指定副本缩放的最小和最大大小。在准备就绪后,选择 `创建服务`。 + + +
+ +恭喜您!您的 ClickHouse Cloud 服务已启动并运行,入职过程已完成。继续阅读以了解如何开始导入和查询您的数据。 + +## 连接到 ClickHouse {#2-connect-to-clickhouse} +连接到 ClickHouse 有 2 种方法: + - 使用我们基于 Web 的 SQL 控制台连接 + - 使用您的应用连接 +
+### 使用 SQL 控制台连接 {#connect-using-sql-console} + +为了快速入门,ClickHouse 提供了一个基于 Web 的 SQL 控制台,您将在完成入职后被重定向到该控制台。 + + + +创建一个查询选项卡并输入一个简单查询,以验证您的连接是否正常工作: + +```sql +SHOW databases +``` + +您应该能在列表中看到 4 个数据库,以及您可能添加的任何数据库。 + + +
+ +就这样 - 您准备好开始使用您的新 ClickHouse 服务了! + +### 使用您的应用连接 {#connect-with-your-app} + +从导航菜单中按下连接按钮。将打开一个模态窗口,提供您服务的凭据,并为您提供如何连接您的接口或语言客户端的一系列说明。 + + +
+ +如果您无法看到您的语言客户端,您可以查看我们的 [集成列表](/integrations)。 + +## 添加数据 {#3-add-data} + +ClickHouse 在数据方面表现更好!有多种添加数据的方法,其中大多数可以在导航菜单中的数据源页面上找到。 + + +
+ +您可以使用以下方法上传数据: + - 设置一个 ClickPipe 从 S3、Postgres、Kafka、GCS 等数据源开始导入数据 + - 使用 SQL 控制台 + - 使用 ClickHouse 客户端 + - 上传文件 - 支持的格式包括 JSON、CSV 和 TSV + - 从文件 URL 上传数据 + +### ClickPipes {#clickpipes} + +[ClickPipes](http://clickhouse.com/docs/integrations/clickpipes) 是一个管理集成平台,使得从多样的数据源中导入数据变得简单,只需点击几下按钮。ClickPipes 的强大和可扩展架构确保了一致的性能和可靠性,适用于最苛刻的工作负载。ClickPipes 可用于长期流媒体需求或一次性数据加载任务。 + + +
+ +### 使用 SQL 控制台添加数据 {#add-data-using-the-sql-console} + +像大多数数据库管理系统一样,ClickHouse 将表逻辑上分组到 **数据库** 中。使用 [`CREATE DATABASE`](../../sql-reference/statements/create/database.md) 命令在 ClickHouse 中创建一个新数据库: + +```sql +CREATE DATABASE IF NOT EXISTS helloworld +``` + +运行以下命令,在 `helloworld` 数据库中创建一个名为 `my_first_table` 的表: + +```sql +CREATE TABLE helloworld.my_first_table +( + user_id UInt32, + message String, + timestamp DateTime, + metric Float32 +) +ENGINE = MergeTree() +PRIMARY KEY (user_id, timestamp) +``` + +在上述示例中,`my_first_table` 是一个 [`MergeTree`](../../engines/table-engines/mergetree-family/mergetree.md) 表,具有四列: + + - `user_id`: 一个 32 位无符号整数 ([UInt32](../../sql-reference/data-types/int-uint.md)) + - `message`: [String](../../sql-reference/data-types/string.md) 数据类型,替代其他数据库系统中的 `VARCHAR`、`BLOB`、`CLOB` 等类型 + - `timestamp`: 一个 [DateTime](../../sql-reference/data-types/datetime.md) 值,表示某个特定时刻 + - `metric`: 一个 32 位浮点数 ([Float32](../../sql-reference/data-types/float.md)) + +:::note 表引擎 +表引擎决定: + - 数据的存储方式和位置 + - 支持哪些查询 + - 数据是否进行复制 +
+有许多表引擎可以选择,但对于单节点 ClickHouse 服务器上的简单表, [`MergeTree`](/engines/table-engines/mergetree-family/mergetree.md) 可能是您的最佳选择。 +::: + +#### 主键简要介绍 {#a-brief-intro-to-primary-keys} + +在您进一步操作之前,了解 ClickHouse 中主键是如何工作的非常重要(主键的实现可能似乎出乎意料!): + + - ClickHouse 中的主键在表中的每一行上 **_不是唯一的_** + +ClickHouse 表的 ^^primary key^^ 决定了数据写入磁盘时的排序方式。每 8192 行或 10MB 数据(称为 **索引粒度**)在 ^^primary key^^ 索引文件中创建一个条目。这个粒度概念创建了一个 **^^稀疏索引^^**,可以轻松适应内存,粒度代表在 `SELECT` 查询中处理的一小部分列数据。 + +通过 `PRIMARY KEY` 参数可以定义 ^^primary key^^。如果您未指定 `PRIMARY KEY` 而定义了表,则该键成为 `ORDER BY` 子句中指定的元组。如果同时指定了 `PRIMARY KEY` 和 `ORDER BY`,则 ^^primary key^^ 必须是排序顺序的子集。 + +^^primary key^^ 也是 ^^排序键^^,是一个 `(user_id, timestamp)` 的元组。因此,存储在每个列文件中的数据将按 `user_id` 然后按 `timestamp` 排序。 + +要深入了解 ClickHouse 的核心概念,请参见 ["核心概念"](../../managing-data/core-concepts/index.md)。 + +#### 将数据插入表中 {#insert-data-into-your-table} + +您可以使用常见的 [`INSERT INTO TABLE`](../../sql-reference/statements/insert-into.md) 命令与 ClickHouse 进行交互,但重要的是要理解,每次向 [`MergeTree`](/engines/table-engines/mergetree-family/mergetree.md) 表插入时,会在存储中创建一个 **part**。 + +:::tip ClickHouse 最佳实践 +每批次插入大量行 - 成千上万甚至数百万行一次。别担心 - ClickHouse 可以轻松处理这种规模,并且通过向您的服务发送更少的写请求,会 [为您节省金钱](/best-practices/selecting-an-insert-strategy#batch-inserts-if-synchronous)。 +::: + +
+ +即使是简单的示例,假设我们一次插入多行: + +```sql +INSERT INTO helloworld.my_first_table (user_id, message, timestamp, metric) VALUES + (101, 'Hello, ClickHouse!', now(), -1.0 ), + (102, 'Insert a lot of rows per batch', yesterday(), 1.41421 ), + (102, 'Sort your data based on your commonly-used queries', today(), 2.718 ), + (101, 'Granules are the smallest chunks of data read', now() + 5, 3.14159 ) +``` + +:::note +注意 `timestamp` 列是使用各种 [**Date**](../../sql-reference/data-types/date.md) 和 [**DateTime**](../../sql-reference/data-types/datetime.md) 函数填充的。ClickHouse 有数以百计的有用函数,您可以 [在 **函数** 部分查看](/sql-reference/functions/)。 +::: + +让我们验证一下它是否成功: + +```sql +SELECT * FROM helloworld.my_first_table +``` + +### 使用 ClickHouse 客户端添加数据 {#add-data-using-the-clickhouse-client} + +您还可以使用名为 [**clickhouse client**](/interfaces/cli) 的命令行工具连接到您的 ClickHouse Cloud 服务。单击左侧菜单中的 `Connect` 以访问这些详细信息。在对话框中从下拉列表中选择 `Native`: + + +
+ +1. 安装 [ClickHouse](/interfaces/cli)。 + +2. 运行命令,替换您的主机名、用户名和密码: + +```bash +./clickhouse client --host HOSTNAME.REGION.CSP.clickhouse.cloud \ +--secure --port 9440 \ +--user default \ +--password +``` +如果您看到微笑的提示,您就可以运行查询了! +```response +:) +``` + +3. 通过运行以下查询尝试一下: + +
+ +```sql +SELECT * +FROM helloworld.my_first_table +ORDER BY timestamp +``` + +注意响应以漂亮的表格格式返回: + +```response +┌─user_id─┬─message────────────────────────────────────────────┬───────────timestamp─┬──metric─┐ +│ 102 │ Insert a lot of rows per batch │ 2022-03-21 00:00:00 │ 1.41421 │ +│ 102 │ Sort your data based on your commonly-used queries │ 2022-03-22 00:00:00 │ 2.718 │ +│ 101 │ Hello, ClickHouse! │ 2022-03-22 14:04:09 │ -1 │ +│ 101 │ Granules are the smallest chunks of data read │ 2022-03-22 14:04:14 │ 3.14159 │ +└─────────┴────────────────────────────────────────────────────┴─────────────────────┴─────────┘ + +4 rows in set. Elapsed: 0.008 sec. +``` + +4. 添加一个 [`FORMAT`](../../sql-reference/statements/select/format.md) 子句以指定 [ClickHouse 的多种支持输出格式之一](/interfaces/formats): + +
+ +```sql +SELECT * +FROM helloworld.my_first_table +ORDER BY timestamp +FORMAT TabSeparated +``` +在上述查询中,输出以制表符分隔返回: +```response +Query id: 3604df1c-acfd-4117-9c56-f86c69721121 + +102 Insert a lot of rows per batch 2022-03-21 00:00:00 1.41421 +102 Sort your data based on your commonly-used queries 2022-03-22 00:00:00 2.718 +101 Hello, ClickHouse! 2022-03-22 14:04:09 -1 +101 Granules are the smallest chunks of data read 2022-03-22 14:04:14 3.14159 + +4 rows in set. Elapsed: 0.005 sec. +``` + +5. 要退出 `clickhouse client`,输入 **exit** 命令: + +
+ +```bash +exit +``` + +### 上传文件 {#upload-a-file} + +开始使用数据库时,常见的一项任务是插入您已有数据的文件。我们在线上有一些样本数据,您可以插入,这些数据代表点击流数据 - 包括用户 ID、访问过的 URL,以及事件的时间戳。 + +假设我们有以下内容在名为 `data.csv` 的 CSV 文件中: + +```bash title="data.csv" +102,This is data in a file,2022-02-22 10:43:28,123.45 +101,It is comma-separated,2022-02-23 00:00:00,456.78 +103,Use FORMAT to specify the format,2022-02-21 10:43:30,678.90 +``` + +1. 以下命令将数据插入到 `my_first_table` 中: + +
+ +```bash +./clickhouse client --host HOSTNAME.REGION.CSP.clickhouse.cloud \ +--secure --port 9440 \ +--user default \ +--password \ +--query='INSERT INTO helloworld.my_first_table FORMAT CSV' < data.csv +``` + +2. 如果从 SQL 控制台查询,现在请注意新行出现在表中: + +
+ + +
+ +
+ +## 接下来做什么? {#whats-next} + +- [教程](/tutorial.md) 让您插入 200 万行到表中并编写一些分析查询 +- 我们有一个 [示例数据集列表](/getting-started/index.md),包含有关如何插入它们的说明 +- 查看我们关于 [ClickHouse 入门](https://clickhouse.com/company/events/getting-started-with-clickhouse/) 的 25 分钟视频 +- 如果您的数据来自外部来源,请查看我们的 [集成指南集合](/integrations/index.mdx),以连接消息队列、数据库、管道等 +- 如果您使用的是 UI/BI 可视化工具,请查看 [将 UI 连接到 ClickHouse 的用户指南](/integrations/data-visualization) +- 有关 [主键](/guides/best-practices/sparse-primary-indexes.md) 的用户指南是您需要了解的有关主键及其定义的所有信息 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/quick-start/cloud.mdx.hash b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/quick-start/cloud.mdx.hash new file mode 100644 index 00000000000..c8078662a62 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/quick-start/cloud.mdx.hash @@ -0,0 +1 @@ +5684d8f73f50c105 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/quick-start/index.mdx b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/quick-start/index.mdx new file mode 100644 index 00000000000..837a624f1fe --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/quick-start/index.mdx @@ -0,0 +1,111 @@ +--- +'description': '几分钟内启动并运行 ClickHouse,探索一些示例数据,并构建您的解决方案' +'keywords': +- 'clickhouse' +- 'quick start' +'sidebar_label': '快速入门' +'sidebar_position': 0 +'slug': '/get-started/quick-start' +'title': '快速入门' +'doc_type': 'landing-page' +--- + +import {CardSecondary, CardPromotion} from '@clickhouse/click-ui/bundled'; +import Link from '@docusaurus/Link'; + +
+
+
+ + + +
+
+ + + +
+
+
+ + + +
+
diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/quick-start/index.mdx.hash b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/quick-start/index.mdx.hash new file mode 100644 index 00000000000..ce1fa688046 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/quick-start/index.mdx.hash @@ -0,0 +1 @@ +90eddc14b452c2ff diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/quick-start.mdx b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/quick-start/oss.mdx similarity index 55% rename from i18n/zh/docusaurus-plugin-content-docs/current/quick-start.mdx rename to i18n/zh/docusaurus-plugin-content-docs/current/getting-started/quick-start/oss.mdx index 2ef74cea122..06cc98246c7 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/quick-start.mdx +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/quick-start/oss.mdx @@ -1,15 +1,15 @@ --- -'slug': '/getting-started/quick-start' -'sidebar_label': '快速入门' -'sidebar_position': 1 +'slug': '/getting-started/quick-start/oss' +'sidebar_label': 'OSS' +'sidebar_position': 2 'keywords': - 'getting started' - 'quick start' - 'beginner-friendly' -'pagination_next': 'getting-started/index' -'title': '快速入门' +'title': 'ClickHouse OSS 快速入门' 'description': 'ClickHouse 快速入门指南' 'show_related_blogs': true +'doc_type': 'guide' --- import Tabs from '@theme/Tabs'; @@ -17,27 +17,26 @@ import TabItem from '@theme/TabItem'; import CodeBlock from '@theme/CodeBlock'; import {VerticalStepper} from '@clickhouse/click-ui/bundled'; -**欢迎使用 ClickHouse!** -在这个快速入门教程中,我们将通过 8 个简单的步骤来帮助您设置环境。您将下载适用于您操作系统的二进制文件,学习如何运行 ClickHouse 服务器,并使用 ClickHouse 客户端创建表,然后向其中插入数据并运行查询以选择这些数据。 +# ClickHouse OSS 快速入门 -让我们开始吧? +> 在本快速入门教程中,我们将通过8个简单步骤让您设置好 OSS ClickHouse。您将下载适合您操作系统的二进制文件,学习如何运行 ClickHouse 服务器,使用 ClickHouse 客户端创建一个表,然后向其插入数据并运行查询以选择该数据。 ## 下载 ClickHouse {#download-the-binary} -ClickHouse 原生支持 Linux、FreeBSD 和 macOS,并可以通过 [WSL](https://learn.microsoft.com/en-us/windows/wsl/about) 在 Windows 上运行。下载 ClickHouse 本地版本的最简单方法是运行以下 `curl` 命令。它会检测您的操作系统是否受支持,然后下载适合的 ClickHouse 二进制文件。 +ClickHouse 原生运行在 Linux、FreeBSD 和 macOS 上,并可以通过 [WSL](https://learn.microsoft.com/en-us/windows/wsl/about) 在 Windows 上运行。最简单的本地下载 ClickHouse 的方法是运行以下 `curl` 命令。它会确定您的操作系统是否受支持,然后下载适合的 ClickHouse 二进制文件。 :::note -我们建议您在一个新的空子目录中运行下面的命令,因为一些配置文件将在初次运行 ClickHouse 服务器时在二进制文件所在的目录中创建。 +我们建议在新的空子目录中运行以下命令,因为一些配置文件将在第一次运行 ClickHouse 服务器时在二进制文件所在的目录下创建。 ::: ```bash curl https://clickhouse.com/ | sh ``` -您应该会看到: +您应该能看到: ``` Successfully downloaded the ClickHouse binary, you can run it as: @@ -47,13 +46,12 @@ You can also install it: sudo ./clickhouse install ``` -在这一阶段,您可以忽略提示运行 `install` 命令。 +在此阶段,您可以忽略运行 `install` 命令的提示。 :::note -对于 Mac 用户:如果您遇到无法验证二进制文件开发者的错误,请参考 ["修复 MacOS 中的开发者验证错误"](https://clickhouse.com/docs/knowledgebase/fix-developer-verification-error-in-macos)。 +对于 Mac 用户:如果您收到二进制文件的开发者无法验证的错误,请查看 ["解决 MacOS 中的开发者验证错误"](https://clickhouse.com/docs/knowledgebase/fix-developer-verification-error-in-macos)。 ::: - ## 启动服务器 运行以下命令以启动 ClickHouse 服务器: @@ -62,17 +60,17 @@ sudo ./clickhouse install ./clickhouse server ``` -您应该会看到终端日志不断输出。这是预期的。在 ClickHouse 中,[默认日志级别](https://clickhouse.com/docs/knowledgebase/why_default_logging_verbose) 设置为 `trace` 而非 `warning`。 +您应该能看到终端充满日志。这是可以预期的。在 ClickHouse 中,[默认日志级别](https://clickhouse.com/docs/knowledgebase/why_default_logging_verbose) 设置为 `trace` 而不是 `warning`。 ## 启动客户端 -使用 `clickhouse-client` 连接到您的 ClickHouse 服务。打开一个新终端,切换到您的 `clickhouse` 二进制文件保存的目录,并运行以下命令: +使用 `clickhouse-client` 连接到您的 ClickHouse 服务。打开一个新的终端,将目录切换到 `clickhouse` 二进制文件保存的地方,然后运行以下命令: ```bash ./clickhouse client ``` -您应该看到一个微笑的图标,表示您已连接到运行在 localhost 上的服务: +您应该能看到一个微笑的脸,表示它已连接到运行在 localhost 上的服务: ```response my-host :) @@ -80,7 +78,7 @@ my-host :) ## 创建表 -使用 `CREATE TABLE` 定义一个新表。典型的 SQL DDL 命令在 ClickHouse 中有效,但有一个额外要求——ClickHouse 中的表需要一个 `ENGINE` 子句。使用 [`MergeTree`](/engines/table-engines/mergetree-family/mergetree) 来利用 ClickHouse 的性能优势: +使用 `CREATE TABLE` 定义一个新表。在 ClickHouse 中,典型的 SQL DDL 命令是有效的,但有一点不同——ClickHouse 中的表需要 `ENGINE` 子句。使用 [`MergeTree`](/engines/table-engines/mergetree-family/mergetree) 来利用 ClickHouse 的性能优势: ```sql CREATE TABLE my_first_table @@ -96,11 +94,11 @@ PRIMARY KEY (user_id, timestamp) ## 插入数据 -您可以使用熟悉的 `INSERT INTO TABLE` 命令与 ClickHouse 交互,但重要的是要理解,每次向 `MergeTree` 表插入数据都会在存储中创建一个我们称之为 **part** 的部分。这些部分随后会在后台通过 ClickHouse 合并。 +您可以使用熟悉的 `INSERT INTO TABLE` 命令来插入数据到 ClickHouse,但需要注意的是,每次向 `MergeTree` 表插入时,ClickHouse 中会创建一个我们称之为 **part** 的存储。这些 ^^parts^^ 后续会被 ClickHouse 在后台合并。 -在 ClickHouse 中,我们尝试一次批量插入大量行(数量可达到数万甚至数百万),以尽量减少需要在后台处理的 [**parts**](/parts) 的数量。 +在 ClickHouse 中,我们尽量一次性批量插入大量行(数万行甚至数百万行),以最小化在后台进程中需要合并的 [**parts**](/parts) 数量。 -在本指南中,暂时不必担心这个问题。运行以下命令以向您的表中插入几行数据: +在本指南中,我们暂时不需要担心这个。运行以下命令将几行数据插入到您的表中: ```sql INSERT INTO my_first_table (user_id, message, timestamp, metric) VALUES @@ -112,14 +110,14 @@ INSERT INTO my_first_table (user_id, message, timestamp, metric) VALUES ## 查询您的新表 -您可以像与任何 SQL 数据库一样编写 `SELECT` 查询: +您可以像在任何 SQL 数据库中一样编写 `SELECT` 查询: ```sql SELECT * FROM my_first_table ORDER BY timestamp ``` -注意,响应以良好的表格格式返回: +请注意,响应以漂亮的表格格式返回: ```text ┌─user_id─┬─message────────────────────────────────────────────┬───────────timestamp─┬──metric─┐ @@ -134,17 +132,17 @@ ORDER BY timestamp ## 插入您自己的数据 -下一步是将您自己的数据导入 ClickHouse。我们有很多 [表函数](/sql-reference/table-functions/index.md) 和 [集成方案](/integrations) 用于数据摄取。下面的选项卡中提供了一些示例,或者您可以查看我们的 [Integrations](/integrations) 页面,以获取与 ClickHouse 集成的技术的详细列表。 +下一步是将您自己的数据导入 ClickHouse。我们有许多 [表函数](/sql-reference/table-functions/index.md) 和 [集成方式](/integrations) 来获取数据。我们在下面的选项卡中有一些示例,或者您可以查看我们的 [集成方式](/integrations) 页面,找到与 ClickHouse 集成的众多技术。 - 使用 [`s3` 表函数](/sql-reference/table-functions/s3.md) 从 S3 读取文件。这是一个表函数——意味着结果是一个可以: + 使用 [`s3` 表函数](/sql-reference/table-functions/s3.md) 从 S3 读取文件。这是一个表函数——意味着结果是一个表,可以: - 1. 作为 `SELECT` 查询的源(允许您运行临时查询并将数据保留在 S3 中),或者... - 2. 将结果表插入到 `MergeTree` 表中(当您准备将数据移动到 ClickHouse 时) + 1. 被用作 `SELECT` 查询的源(允许您运行临时查询并将数据保留在 S3 中),或... + 2. 将结果表插入到 `MergeTree` 表中(当您准备好将数据转移到 ClickHouse 时) - 一个临时查询的示例: + 临时查询看起来像: ```sql SELECT @@ -158,7 +156,7 @@ GROUP BY passenger_count ORDER BY passenger_count; ``` - 移动数据到 ClickHouse 表的示例如下,其中 `nyc_taxi` 是一个 `MergeTree` 表: + 将数据移到 ClickHouse 表中如下,其中 `nyc_taxi` 是一个 `MergeTree` 表: ```sql INSERT INTO nyc_taxi @@ -169,12 +167,12 @@ SELECT * FROM s3( SETTINGS input_format_allow_errors_num=25000; ``` - 查看我们的 [AWS S3 文档页面](/integrations/data-ingestion/s3/index.md) 以获取有关如何使用 S3 的更多详细信息和示例。 + 查看我们的 [AWS S3 文档页面合集](/integrations/data-ingestion/s3/index.md),获取更多关于如何将 S3 与 ClickHouse 结合使用的详细信息和示例。
- 用于读取 AWS S3 中数据的 [`s3` 表函数](/sql-reference/table-functions/s3.md) 也可以在 Google Cloud Storage 中使用。 + 用于读取 AWS S3 中数据的 [`s3` 表函数](/sql-reference/table-functions/s3.md) 也适用于 Google Cloud Storage 中的文件。 例如: @@ -190,7 +188,7 @@ FROM s3( LIMIT 1000 ``` - 有关 [`s3` 表函数页面](/sql-reference/table-functions/s3.md) 的更多详细信息,请查看。 + 在 [`s3` 表函数页面](/sql-reference/table-functions/s3.md) 获取更多详细信息。
@@ -209,12 +207,12 @@ FROM url( ); ``` - 有关 [`url` 表函数页面](/sql-reference/table-functions/url) 的更多详细信息,请查看。 + 在 [`url` 表函数页面](/sql-reference/table-functions/url) 获取更多详细信息。
- 使用 [`file` 表引擎](/sql-reference/table-functions/file) 从本地文件读取数据。为了简单起见,将文件复制到 `user_files` 目录中(该目录位于您下载 ClickHouse 二进制文件的目录中)。 + 使用 [`file` 表引擎](/sql-reference/table-functions/file) 读取本地文件。为了简单起见,将文件复制到 `user_files` 目录(该目录位于您下载 ClickHouse 二进制文件的目录中)。 ```sql DESCRIBE TABLE file('comments.tsv') @@ -231,7 +229,7 @@ Query id: 8ca9b2f9-65a2-4982-954a-890de710a336 └───────────┴─────────────────────────┘ ``` - 请注意,ClickHouse 通过分析大量行来推断您列的名称和数据类型。如果 ClickHouse 无法从文件名中确定文件格式,您可以将其作为第二个参数指定: + 请注意,ClickHouse 通过分析大量行来推断列的名称和数据类型。如果 ClickHouse 无法从文件名中确定文件格式,您可以将其作为第二个参数指定: ```sql SELECT count() @@ -241,7 +239,7 @@ FROM file( ) ``` - 阅读 [`file` 表函数](/sql-reference/table-functions/file) 文档页面以获取更多详细信息。 + 查看 [`file` 表函数](/sql-reference/table-functions/file) 文档页面以获取更多详细信息。
@@ -260,7 +258,7 @@ postgresql( ; ``` - 阅读 [`postgresql` 表函数](/sql-reference/table-functions/postgresql) 文档页面以获取更多详细信息。 + 查看 [`postgresql` 表函数](/sql-reference/table-functions/postgresql) 文档页面以获取更多详细信息。
@@ -279,7 +277,7 @@ mysql( ; ``` - 阅读 [`mysql` 表函数](/sql-reference/table-functions/mysql) 文档页面以获取更多详细信息。 + 查看 [`mysql` 表函数](/sql-reference/table-functions/mysql) 文档页面以获取更多详细信息。
@@ -296,43 +294,43 @@ odbc( ); ``` - 阅读 [`odbc` 表函数](/sql-reference/table-functions/odbc) 和 [`jdbc` 表函数](/sql-reference/table-functions/jdbc) 文档页面以获取更多详细信息。 + 查看 [`odbc` 表函数](/sql-reference/table-functions/odbc) 和 [`jdbc` 表函数](/sql-reference/table-functions/jdbc) 文档页面以获取更多详细信息。
- + 消息队列可以通过相应的表引擎将数据流入 ClickHouse,包括: - - **Kafka**:使用 [`Kafka` 表引擎](/engines/table-engines/integrations/kafka) 集成 Kafka - - **Amazon MSK**:集成 [Amazon Managed Streaming for Apache Kafka (MSK)](/integrations/kafka/cloud/amazon-msk/) - - **RabbitMQ**:使用 [`RabbitMQ` 表引擎](/engines/table-engines/integrations/rabbitmq) 集成 RabbitMQ + - **Kafka**:使用 [`Kafka` 表引擎](/engines/table-engines/integrations/kafka) 与 Kafka 集成 + - **Amazon MSK**:与 [亚马逊托管的 Apache Kafka 流服务 (MSK)](/integrations/kafka/cloud/amazon-msk/) 集成 + - **RabbitMQ**:使用 [`RabbitMQ` 表引擎](/engines/table-engines/integrations/rabbitmq) 与 RabbitMQ 集成
- + - ClickHouse 具有从以下来源读取数据的表函数: + ClickHouse 有表函数从以下来源读取数据: - - **Hadoop**:使用 [`hdfs` 表函数](/sql-reference/table-functions/hdfs) 集成 Apache Hadoop - - **Hudi**:使用 [`hudi` 表函数](/sql-reference/table-functions/hudi) 从 S3 中现有的 Apache Hudi 表读取数据 - - **Iceberg**:使用 [`iceberg` 表函数](/sql-reference/table-functions/iceberg) 从 S3 中现有的 Apache Iceberg 表读取数据 - - **DeltaLake**:使用 [`deltaLake` 表函数](/sql-reference/table-functions/deltalake) 从 S3 中现有的 Delta Lake 表读取数据 + - **Hadoop**:使用 [`hdfs` 表函数](/sql-reference/table-functions/hdfs) 与 Apache Hadoop 集成 + - **Hudi**:使用 [`hudi` 表函数](/sql-reference/table-functions/hudi) 从 S3 中读取现有的 Apache Hudi 表 + - **Iceberg**:使用 [`iceberg` 表函数](/sql-reference/table-functions/iceberg) 从 S3 中读取现有的 Apache Iceberg 表 + - **DeltaLake**:使用 [`deltaLake` 表函数](/sql-reference/table-functions/deltalake) 从 S3 中读取现有的 Delta Lake 表
- + - 查看我们的 [ClickHouse 集成长列表](/integrations),以了解如何将现有框架和数据源连接到 ClickHouse。 + 查看我们的 [ClickHouse 集成方式的长列表](/integrations),了解如何将您现有的框架和数据源连接到 ClickHouse。
## 探索 -- 查看我们的 [核心概念](/managing-data/core-concepts) 部分,了解 ClickHouse 的一些基本原理。 -- 查看 [高级教程](tutorial.md),该教程对 ClickHouse 的关键概念和功能进行了更深入的探讨。 -- 通过我们在 [ClickHouse Academy](https://learn.clickhouse.com/visitor_class_catalog) 的免费的按需培训课程继续您的学习。 -- 我们有一个 [示例数据集](/getting-started/example-datasets/) 的列表,附有插入它们的说明。 -- 如果您的数据来自外部源,请查看我们的 [集成指南集合](/integrations/),以了解如何连接消息队列、数据库、管道等。 +- 查看我们的 [核心概念](/managing-data/core-concepts) 部分,了解 ClickHouse 在内部运作的一些基础知识。 +- 查看 [高级教程](tutorial.md),深入探讨 ClickHouse 的关键概念和功能。 +- 通过参加我们在 [ClickHouse Academy](https://learn.clickhouse.com/visitor_class_catalog) 提供的免费在线培训课程继续学习。 +- 我们有一份 [示例数据集](/getting-started/example-datasets/) 的列表,以及插入它们的说明。 +- 如果您的数据来自外部来源,请查看我们的 [集成指南集合](/integrations/),了解如何连接到消息队列、数据库、管道等。 - 如果您使用的是 UI/BI 可视化工具,请查看 [连接 UI 到 ClickHouse 的用户指南](/integrations/data-visualization/)。 -- 关于 [主键](/guides/best-practices/sparse-primary-indexes.md) 的用户指南包含了您需要了解的所有内容,以及如何定义主键。 +- 关于 [主键](/guides/best-practices/sparse-primary-indexes.md) 的用户指南包含您需要了解的所有关于主键的信息以及如何定义它们。
diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/quick-start/oss.mdx.hash b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/quick-start/oss.mdx.hash new file mode 100644 index 00000000000..e6472da02f6 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/getting-started/quick-start/oss.mdx.hash @@ -0,0 +1 @@ +7d6e906be963a099 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/_snippets/_performance_optimizations_table_of_contents.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/_snippets/_performance_optimizations_table_of_contents.md new file mode 100644 index 00000000000..d3b5a4420bb --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/_snippets/_performance_optimizations_table_of_contents.md @@ -0,0 +1,17 @@ +| 主题 | 描述 | +|------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| [查询优化指南](/optimize/query-optimization) | 从这里开始学习查询优化基础知识,涵盖常见场景和性能技巧,以提高查询执行速度。 | +| [主索引高级指南](/guides/best-practices/sparse-primary-indexes) | 深入了解 ClickHouse 独特的稀疏主索引系统,它与传统数据库的不同之处,以及最佳实践以实现最佳索引策略。 | +| [查询并行性](/optimize/query-parallelism) | 了解 ClickHouse 如何使用处理通道和 `max_threads` 设置来实现查询执行的并行化,包括如何检查和优化并行执行。 | +| [分区键](/optimize/partitioning-key) | 精通分区键选择,以通过启用高效的数据分段修剪来显著提高查询性能,避免常见的分区陷阱。 | +| [数据跳过索引](/optimize/skipping-indexes) | 战略性地应用二级索引,以跳过不相关的数据块,加速非主键列上的过滤查询。 | +| [`PREWHERE` 优化](/optimize/prewhere) | 理解 `PREWHERE` 如何通过在读取不必要的列之前过滤数据来自动减少 I/O,以及如何监控其有效性。 | +| [批量插入](/optimize/bulk-inserts) | 通过有效地批量插入数据以最大化摄取吞吐量并减少资源开销。 | +| [异步插入](/optimize/asynchronous-inserts) | 通过利用服务器端批量处理来减少客户端复杂性,提高高频插入的吞吐量,从而改善插入性能。 | +| [避免变更](/optimize/avoid-mutations) | 设计仅附加的工作流,消除成本高昂的 `UPDATE` 和 `DELETE` 操作,同时维护数据的准确性和性能。 | +| [避免可空列](/optimize/avoid-nullable-columns) | 在可能的情况下,通过使用默认值而不是可空列来减少存储开销并提高查询性能。 | +| [避免 `OPTIMIZE FINAL`](/optimize/avoidoptimizefinal) | 理解何时该使用和不该使用 `OPTIMIZE TABLE FINAL` | +| [分析器](/operations/analyzer) | 利用 ClickHouse 的新查询分析器识别性能瓶颈,并优化查询执行计划以提高效率。 | +| [查询分析](/operations/optimizing-performance/sampling-query-profiler) | 使用抽样查询分析器分析查询执行模式,识别性能热点,并优化资源使用。 | +| [查询缓存](/operations/query-cache) | 通过启用和配置 ClickHouse 的内置查询结果缓存,加速频繁执行的 `SELECT` 查询。 | +| [测试硬件](/operations/performance-test) | 在任何服务器上运行 ClickHouse 性能基准测试,无需安装以评估硬件能力。(不适用于 ClickHouse Cloud) | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/_snippets/_performance_optimizations_table_of_contents.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/_snippets/_performance_optimizations_table_of_contents.md.hash new file mode 100644 index 00000000000..9c7babdfc3f --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/_snippets/_performance_optimizations_table_of_contents.md.hash @@ -0,0 +1 @@ +b86ceeb68b5106fd diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/asyncinserts.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/asyncinserts.md index 4997a8ab5ae..e3410619145 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/asyncinserts.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/asyncinserts.md @@ -2,7 +2,8 @@ 'slug': '/optimize/asynchronous-inserts' 'sidebar_label': '异步插入' 'title': '异步插入 (async_insert)' -'description': '使用异步插入作为批量数据的替代方案。' +'description': '将异步插入用作批量数据的替代方案。' +'doc_type': 'guide' --- import Content from '@site/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/_snippets/_async_inserts.md'; diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/asyncinserts.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/asyncinserts.md.hash index b85503d296e..7b76dd86a79 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/asyncinserts.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/asyncinserts.md.hash @@ -1 +1 @@ -5ab546f57c716696 +3eebffe581fcad56 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/avoidmutations.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/avoidmutations.md index 82684d776cc..9522613e459 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/avoidmutations.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/avoidmutations.md @@ -1,8 +1,9 @@ --- 'slug': '/optimize/avoid-mutations' -'sidebar_label': '避免变更' -'title': '避免变更' -'description': '变更是指操作表数据的 ALTER 查询' +'sidebar_label': '避免突变' +'title': '避免突变' +'description': '突变是指操作表数据的 ALTER 查询' +'doc_type': 'guide' --- import Content from '@site/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/_snippets/_avoid_mutations.md'; diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/avoidmutations.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/avoidmutations.md.hash index b5e00c68f4b..7b677ab1fde 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/avoidmutations.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/avoidmutations.md.hash @@ -1 +1 @@ -bbd22eaa83df58a8 +a12af684b16c7fc6 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/avoidnullablecolumns.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/avoidnullablecolumns.md index ebc5854a043..e07ccb5e9b1 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/avoidnullablecolumns.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/avoidnullablecolumns.md @@ -2,7 +2,8 @@ 'slug': '/optimize/avoid-nullable-columns' 'sidebar_label': '避免 Nullable 列' 'title': '避免 Nullable 列' -'description': '为什么在 ClickHouse 中应避免 Nullable 列' +'description': '为什么应在 ClickHouse 中避免 Nullable 列' +'doc_type': 'guide' --- import Content from '@site/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/_snippets/_avoid_nullable_columns.md'; diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/avoidnullablecolumns.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/avoidnullablecolumns.md.hash index f253e6ae767..ecef2b983d9 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/avoidnullablecolumns.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/avoidnullablecolumns.md.hash @@ -1 +1 @@ -1a8cf67ce9470fb0 +0867b82884e1680b diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/avoidoptimizefinal.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/avoidoptimizefinal.md index 3f1d65e9068..ae4ae638680 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/avoidoptimizefinal.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/avoidoptimizefinal.md @@ -1,8 +1,9 @@ --- 'slug': '/optimize/avoidoptimizefinal' -'sidebar_label': '避免 OPTIMIZE FINAL' -'title': '避免 OPTIMIZE FINAL' -'description': '使用 OPTIMIZE TABLE ... FINAL 查询将启动数据分区片段的非计划合并。' +'sidebar_label': '避免优化最终' +'title': '避免优化最终' +'description': '使用 OPTIMIZE TABLE ... FINAL 查询将启动数据分区的非计划合并。' +'doc_type': 'guide' --- import Content from '@site/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/_snippets/_avoid_optimize_final.md'; diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/avoidoptimizefinal.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/avoidoptimizefinal.md.hash index 2e38d207e1b..64450f28950 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/avoidoptimizefinal.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/avoidoptimizefinal.md.hash @@ -1 +1 @@ -425e70d4259aabb4 +0e750ef2097f3a92 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/bulkinserts.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/bulkinserts.md index e11dbfb9180..52a1922352d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/bulkinserts.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/bulkinserts.md @@ -2,7 +2,8 @@ 'slug': '/optimize/bulk-inserts' 'sidebar_label': '批量插入' 'title': '批量插入' -'description': '发送较少的插入,每个插入包含更多的数据,将减少所需的写入次数。' +'description': '发送较少量的插入,每个插入包含更多的数据,将减少所需的写入次数。' +'doc_type': 'guide' --- import Content from '@site/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/_snippets/_bulk_inserts.md'; diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/bulkinserts.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/bulkinserts.md.hash index 4855e1f0fe3..acf0223b051 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/bulkinserts.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/bulkinserts.md.hash @@ -1 +1 @@ -43a78e4988da9ee6 +1b0fcc82e8b471b8 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/index.md index 2e22dd31fb9..97544c51610 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/index.md @@ -1,31 +1,16 @@ --- 'slug': '/operations/overview' -'sidebar_label': '性能和优化概述' -'description': '性能和优化的概述页面' -'title': '性能和优化' +'sidebar_label': '性能与优化概述' +'description': '性能与优化的概述页面' +'title': '性能与优化' +'doc_type': 'reference' --- +import TableOfContents from '@site/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/_snippets/_performance_optimizations_table_of_contents.md'; -# 性能和优化 -本节包含了提高 ClickHouse 性能的技巧和最佳实践。 -我们建议用户在阅读本节之前先阅读 [核心概念](/parts), -该部分涵盖了改善性能所需的主要概念。 +# 性能与优化 -| 主题 | 描述 | -|---------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| [查询优化指南](/optimize/query-optimization) | 这是查询优化的良好起点,这个简单的指南描述了使用不同性能和优化技术改善查询性能的常见场景。 | -| [主索引高级指南](/guides/best-practices/sparse-primary-indexes) | 深入探讨 ClickHouse 索引,包括它与其他数据库系统的不同之处,ClickHouse 如何构建和使用表的稀疏主索引以及在 ClickHouse 中进行索引时的一些最佳实践。 | -| [查询并行性](/optimize/query-parallelism) | 解释了 ClickHouse 如何使用处理通道和 max_threads 设置并行执行查询。 涉及数据如何在通道之间分配,max_threads 如何应用,何时未被完全使用,以及如何使用 EXPLAIN 和跟踪日志检查执行。 | -| [分区键](/optimize/partitioning-key) | 深入探讨 ClickHouse 的分区键优化。 解释了选择合适的分区键如何显著提高查询性能,因其允许 ClickHouse 快速定位相关数据片段。 涵盖选择高效分区键的最佳实践和可能避免的陷阱。 | -| [数据跳过索引](/optimize/skipping-indexes) | 解释了数据跳过索引作为优化性能的一种方式。 | -| [PREWHERE 优化](/optimize/prewhere) | 解释了 PREWHERE 如何通过避免读取不必要的列数据来减少 I/O。 显示如何自动应用它,如何选择过滤顺序,以及如何使用 EXPLAIN 和日志进行监控。 | -| [批量插入](/optimize/bulk-inserts) | 解释了在 ClickHouse 中使用批量插入的好处。 | -| [异步插入](/optimize/asynchronous-inserts) | 重点介绍了 ClickHouse 的异步插入功能。 可能解释了异步插入如何工作(在服务器上批量处理数据以实现高效插入)及其好处(通过卸载插入处理来提高性能)。 还可能涵盖如何启用异步插入以及在 ClickHouse 环境中有效使用它们的注意事项。 | -| [避免变更](/optimize/avoid-mutations) | 讨论了在 ClickHouse 中避免变更(更新和删除)的重要性。 推荐使用仅追加插入以获得最佳性能,并建议处理数据更改的替代方法。 | -| [避免 Nullable 列](/optimize/avoid-nullable-columns) | 讨论了为什么您可能想要避免 Nullable 列以节省空间并提高性能。 演示了如何为列设置默认值。 | -| [避免 Optimize Final](/optimize/avoidoptimizefinal) | 解释了 `OPTIMIZE TABLE ... FINAL` 查询是资源密集型的,并建议优化 ClickHouse 性能的替代方法。 | -| [分析器](/operations/analyzer) | 考察 ClickHouse 分析器,这是一个用于分析和优化查询的工具。 讨论了分析器的工作原理,其好处(例如,识别性能瓶颈),以及如何使用它来提高 ClickHouse 查询的效率。 | -| [查询分析](/operations/optimizing-performance/sampling-query-profiler) | 解释了 ClickHouse 的抽样查询分析工具,这是一个帮助分析查询执行的工具。 | -| [查询缓存](/operations/query-cache) | 详细介绍了 ClickHouse 的查询缓存,这是一项旨在通过缓存频繁执行的 `SELECT` 查询结果来提高性能的功能。 | -| [测试硬件](/operations/performance-test) | 如何在任何服务器上运行基本的 ClickHouse 性能测试,而无需安装 ClickHouse 程序包。 (不适用于 ClickHouse Cloud) | +本节包含了提高 ClickHouse 性能的技巧和最佳实践。我们建议用户在阅读本节之前先阅读 [核心概念](/parts),该部分涵盖了提高性能所需的主要概念。 + + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/index.md.hash index 3c74dab3f50..bb4513d78a4 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/index.md.hash @@ -1 +1 @@ -6fe52ea489be4c9e +1aff4a7040a66470 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/partitioningkey.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/partitioningkey.md index c5996a8bd43..9fd8c0f83c4 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/partitioningkey.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/partitioningkey.md @@ -2,7 +2,8 @@ 'slug': '/optimize/partitioning-key' 'sidebar_label': 'Partitioning Key' 'title': '选择低基数分区键' -'description': '使用低基数分区键,或者避免为您的 TABLE 使用任何分区键。' +'description': '使用低基数分区键或避免为你的表使用任何分区键。' +'doc_type': 'guide' --- import Content from '@site/i18n/zh/docusaurus-plugin-content-docs/current/best-practices/partitioning_keys.mdx'; diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/partitioningkey.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/partitioningkey.md.hash index cbab87140b2..25a7d40bb46 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/partitioningkey.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/partitioningkey.md.hash @@ -1 +1 @@ -84d7119464ae481c +37e958785d7e4e07 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/prewhere.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/prewhere.md index d4c7f355a69..93cec51a4a8 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/prewhere.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/prewhere.md @@ -2,8 +2,9 @@ 'slug': '/optimize/prewhere' 'sidebar_label': 'PREWHERE 优化' 'sidebar_position': 21 -'description': 'PREWHERE 通过避免读取不必要的列数据来减少 I/O。' -'title': 'PREWHERE 优化如何工作?' +'description': 'PREWHERE 通过避免读取不必要的列数据来减少 I/O.' +'title': 'PREWHERE 优化是如何工作的?' +'doc_type': 'guide' --- import visual01 from '@site/static/images/guides/best-practices/prewhere_01.gif'; @@ -14,98 +15,95 @@ import visual05 from '@site/static/images/guides/best-practices/prewhere_05.gif' import Image from '@theme/IdealImage'; -# PREWHERE 优化是如何工作的? +# PREWHERE优化是如何工作的? -[PREWHERE 子句](/sql-reference/statements/select/prewhere) 是 ClickHouse 中的一种查询执行优化。它通过避免不必要的数据读取,减少 I/O 并提高查询速度,在从磁盘读取非过滤列之前筛选掉不相关的数据。 +[PREWHERE子句](/sql-reference/statements/select/prewhere) 是ClickHouse中的一种查询执行优化。它通过避免不必要的数据读取,减少I/O并提高查询速度,在从磁盘读取非过滤列之前过滤掉无关数据。 -本指南解释了 PREWHERE 的工作原理、如何测量其影响以及如何对其进行优化以获得最佳性能。 +本指南解释了PREWHERE的工作原理,如何测量其影响,以及如何调整以获得最佳性能。 +## 没有PREWHERE优化的查询处理 {#query-processing-without-prewhere-optimization} -## 无 PREWHERE 优化的查询处理 {#query-processing-without-prewhere-optimization} +我们将通过示例说明如何在不使用PREWHERE的情况下处理对[uk_price_paid_simple](/parts) 表的查询: -我们将首先说明如何在不使用 PREWHERE 的情况下处理对 [uk_price_paid_simple](/parts) 表的查询: - - +

-① 查询包含一个对 `town` 列的过滤条件,该列是表的主键的一部分,因此也是主索引的一部分。 - -② 为了加速查询,ClickHouse 将表的主索引加载到内存中。 +① 查询包含对`town`列的过滤,该列是表的主键的一部分,因此也是主索引的一部分。 -③ 它扫描索引条目,以确定 `town` 列中哪些区块可能包含与谓词匹配的行。 +② 为了加速查询,ClickHouse将表的主索引加载到内存中。 -④ 这些潜在相关的区块被加载到内存中,并且与查询所需的任何其他列的区块按位置对齐。 +③ 它扫描索引条目,以识别`town`列中的哪些粒度可能包含与谓词匹配的行。 -⑤ 然后,在查询执行过程中应用剩余的过滤条件。 +④ 这些潜在相关的粒度与任何其他需要用于查询的列的按位置对齐的粒度一起加载到内存中。 -如您所见,在没有 PREWHERE 的情况下,即使只有少量行实际匹配,所有潜在相关的列也会在过滤之前全部加载。 +⑤ 剩余的过滤器将在查询执行期间应用。 +如您所见,没有PREWHERE时,在过滤之前加载了所有潜在相关的列,即使只有少数行实际匹配。 -## PREWHERE 如何提高查询效率 {#how-prewhere-improves-query-efficiency} +## PREWHERE如何提高查询效率 {#how-prewhere-improves-query-efficiency} -以下动画展示了如何在所有查询谓词上应用 PREWHERE 子句时处理上述查询。 +以下动画展示了如何在上述查询上应用PREWHERE子句来处理所有查询谓词。 前三个处理步骤与之前相同: - +

-① 查询包含一个对 `town` 列的过滤条件,该列是表的主键的一部分——因此也是主索引的一部分。 +① 查询包含对`town`列的过滤,该列是表的主键的一部分——因此也是主索引的一部分。 -② 与没有 PREWHERE 子句的运行类似,为了加速查询,ClickHouse 将主索引加载到内存中, +② 类似于未使用PREWHERE子句的情况,为了加速查询,ClickHouse将主索引加载到内存中。 -③ 然后扫描索引条目,以确定 `town` 列中哪些区块可能包含与谓词匹配的行。 +③ 然后扫描索引条目,以识别`town`列中的哪些粒度可能包含与谓词匹配的行。 -现在,得益于 PREWHERE 子句,下一步不同:ClickHouse 逐列过滤数据,仅加载真正需要的内容,而不是提前读取所有相关列。这大大减少了 I/O,尤其是对于宽表。 +现在,多亏了PREWHERE子句,下一步有所不同:ClickHouse通过逐列过滤数据,仅加载真正需要的数据,而不是提前读取所有相关列。这大大减少了I/O,尤其是对于宽表。 -在每一步中,它只加载包含至少一行通过——即匹配——先前过滤的区块。因此,每个过滤条件可加载和评估的区块数单调减少: +在每一步中,它仅加载包含至少一行经过—即匹配—之前过滤条件的粒度。结果是,每个过滤条件需要加载和评估的粒度数量单调减少: -**步骤 1:按城市过滤**
-ClickHouse 开始 PREWHERE 处理,通过 ①读取 `town` 列中选定的区块,并检查哪些区块实际上包含与 `London` 匹配的行。 +**步骤1:按town过滤**
+ClickHouse开始PREWHERE处理,通过①读取`town`列中选定的粒度,并检查哪些实际包含与`London`匹配的行。 -在我们的例子中,所有选定的区块都匹配,因此 ② 选择下一个过滤列——`date`——的相应位置对齐的区块进行处理: +在我们的示例中,所有选定的粒度都匹配,因此②为下一个过滤列`date`选择了相应的按位置对齐的粒度: - +

-**步骤 2:按日期过滤**
-接下来,ClickHouse ①读取选定的 `date` 列区块以评估过滤条件 `date > '2024-12-31'`。 +**步骤2:按date过滤**
+接下来,ClickHouse ①读取选定的`date`列粒度以评估过滤条件`date > '2024-12-31'`。 -在这种情况下,三个区块中有两个包含匹配的行,因此 ② 仅选择它们的相应位置对齐的区块——来自下一个过滤列——`price`——进行进一步处理: +在这种情况下,三个粒度中有两个包含匹配行,因此②仅选择它们的按位置对齐的粒度作为下一个过滤列`price`的进一步处理: - +

-**步骤 3:按价格过滤**
-最后,ClickHouse ①读取 `price` 列中选定的两个区块以评估最后的过滤条件 `price > 10_000`。 +**步骤3:按price过滤**
+最后,ClickHouse ①读取`price`列中选择的两个粒度以评估最后的过滤条件`price > 10_000`。 -仅有两个区块中的一个包含匹配的行,因此 ② 仅需加载从 `SELECT` 列——`street`——的相应位置对齐的区块进行进一步处理: +只有两个粒度中的一个包含匹配行,因此②仅需要加载其按位置对齐的粒度,即`SELECT`列中的`street`,以进行进一步处理: - +

-通过最后一步,仅加载包含匹配行的最小列区块集合。这导致较低的内存使用、更少的磁盘 I/O 和更快的查询执行。 +到最后一步时,仅加载包含匹配行的最小列粒度集。这导致较低的内存使用,减少磁盘I/O,并加快查询执行速度。 -:::note PREWHERE 减少读取数据,而不是处理的行 -请注意,ClickHouse 在 PREWHERE 和非 PREWHERE 版本的查询中处理的行数相同。然而,应用了 PREWHERE 优化后,并不需要为每个处理的行加载所有列值。 +:::note PREWHERE减少数据读取,而不是处理的行数 +请注意,在PREWHERE和非PREWHERE版本的查询中,ClickHouse处理的行数是相同的。然而,应用PREWHERE优化后,不需要为每个处理的行加载所有列值。 ::: -## PREWHERE 优化是自动应用的 {#prewhere-optimization-is-automatically-applied} - -PREWHERE 子句可以手动添加,如上面的示例所示。然而,您不需要手动编写 PREWHERE。当设置 [`optimize_move_to_prewhere`](/operations/settings/settings#optimize_move_to_prewhere) 被启用(默认为 true)时,ClickHouse 会自动将过滤条件从 WHERE 移动到 PREWHERE,优先考虑那些能够最大程度减少读取量的条件。 +## PREWHERE优化是自动应用的 {#prewhere-optimization-is-automatically-applied} -其思想是较小的列更快地扫描,而在处理较大列的时候,大多数区块已经被过滤掉。由于所有列的行数相同,因此列的大小主要取决于其数据类型,例如,`UInt8` 列通常比 `String` 列小得多。 +可以手动添加PREWHERE子句,如上述示例所示。然而,您不需要手动编写PREWHERE。当设置[`optimize_move_to_prewhere`](/operations/settings/settings#optimize_move_to_prewhere)启用时(默认值为true),ClickHouse会自动将过滤条件从WHERE移到PREWHERE,优先处理那些将最大程度减少读取量的条件。 -作为从版本 [23.2](https://clickhouse.com/blog/clickhouse-release-23-02#multi-stage-prewhere--alexander-gololobov) 起 ClickHouse 默认遵循此策略,按未压缩大小的升序对 PREWHERE 过滤列进行排序以进行多步处理。 +其思想是,较小的列扫描速度更快,并且在处理较大的列时,大多数粒度通常已经被过滤掉。由于所有列的行数相同,列的大小主要由其数据类型决定,例如,`UInt8`列通常远小于`String`列。 -从版本 [23.11](https://clickhouse.com/blog/clickhouse-release-23-11#column-statistics-for-prewhere) 开始,可选的列统计信息可以通过根据实际数据选择性选择过滤处理顺序进一步改善这一点,而不仅仅依赖列的大小。 +自版本[23.2](https://clickhouse.com/blog/clickhouse-release-23-02#multi-stage-prewhere--alexander-gololobov)以来,ClickHouse默认遵循此策略,为多步骤处理按未压缩大小升序排序PREWHERE过滤列。 +自版本[23.11](https://clickhouse.com/blog/clickhouse-release-23-11#column-statistics-for-prewhere)起,可选的列统计信息可以进一步改善这一点,通过根据实际数据选择性选择过滤处理顺序,而不仅仅是列大小。 -## 如何测量 PREWHERE 的影响 {#how-to-measure-prewhere-impact} +## 如何测量PREWHERE的影响 {#how-to-measure-prewhere-impact} -要验证 PREWHERE 是否帮助了您的查询,您可以比较启用和禁用 `optimize_move_to_prewhere` 设置时查询的性能。 +要验证PREWHERE对您的查询是否有帮助,您可以比较启用和未启用`optimize_move_to_prewhere设置`的查询性能。 -我们首先在禁用 `optimize_move_to_prewhere` 设置的情况下运行查询: +我们从禁用`optimize_move_to_prewhere`设置开始运行查询: ```sql SELECT @@ -113,7 +111,7 @@ SELECT FROM uk.uk_price_paid_simple WHERE - town = 'LONDON' and date > '2024-12-31' and price < 10_000 + town = 'LONDON' AND date > '2024-12-31' AND price < 10_000 SETTINGS optimize_move_to_prewhere = false; ``` @@ -128,16 +126,16 @@ SETTINGS optimize_move_to_prewhere = false; Peak memory usage: 132.10 MiB. ``` -在处理 231 万行查询时,ClickHouse 读取了 **23.36 MB** 的列数据。 +ClickHouse在处理2.31百万行时读取了**23.36 MB**的列数据。 -接下来,我们在启用 `optimize_move_to_prewhere` 设置的情况下运行查询。(请注意,此设置是可选的,因为该设置默认启用): +接下来,我们运行启用`optimize_move_to_prewhere`设置的查询。(请注意,虽然这个设置是可选的,但默认情况下是启用的): ```sql SELECT street FROM uk.uk_price_paid_simple WHERE - town = 'LONDON' and date > '2024-12-31' and price < 10_000 + town = 'LONDON' AND date > '2024-12-31' AND price < 10_000 SETTINGS optimize_move_to_prewhere = true; ``` @@ -152,11 +150,11 @@ SETTINGS optimize_move_to_prewhere = true; Peak memory usage: 132.11 MiB. ``` -处理的行数相同(231 万),但得益于 PREWHERE,ClickHouse 读取的列数据量减少了三倍——仅 6.74 MB,而不是 23.36 MB——这使得总运行时间减少了 3 倍。 +处理的行数相同(2.31百万),但由于PREWHERE,ClickHouse读取的列数据减少了超过三倍——仅6.74 MB,而不是23.36 MB——这将总运行时间缩短了3倍。 -要深入了解 ClickHouse 是如何在背后应用 PREWHERE 的,请使用 EXPLAIN 和跟踪日志。 +为了深入了解ClickHouse如何在后台应用PREWHERE,您可以使用EXPLAIN和跟踪日志。 -我们使用 [EXPLAIN](/sql-reference/statements/explain#explain-plan) 子句检查查询的逻辑计划: +我们使用[EXPLAIN](/sql-reference/statements/explain#explain-plan)子句检查查询的逻辑计划: ```sql EXPLAIN PLAN actions = 1 SELECT @@ -177,18 +175,18 @@ Prewhere info ... ``` -我们在此省略了计划输出中的大部分内容,因为它相当冗长。本质上,它显示所有三个列谓词都自动移动到了 PREWHERE。 +我们在此省略大部分计划输出,因为它相当冗长。本质上,它显示所有三个列谓词已被自动移动到PREWHERE。 -当您自己重现时,您还会在查询计划中看到这些谓词的顺序是基于列的数据类型大小。由于我们没有启用列统计信息,ClickHouse 使用大小作为确定 PREWHERE 处理顺序的后备依据。 +在您自己复制此过程时,您还会在查询计划中看到这些谓词的顺序是基于列的数据类型大小。由于我们未启用列统计,ClickHouse使用大小作为确定PREWHERE处理顺序的后备。 -如果您想进一步探究,您可以通过指示 ClickHouse 在查询执行期间返回所有测试级别的日志条目来观察每个个体的 PREWHERE 处理步骤: +如果您想更深入了解,您可以通过指示ClickHouse在查询执行期间返回所有测试级日志条目来观察每个单独的PREWHERE处理步骤: ```sql SELECT street FROM uk.uk_price_paid_simple WHERE - town = 'LONDON' and date > '2024-12-31' and price < 10_000 + town = 'LONDON' AND date > '2024-12-31' AND price < 10_000 SETTINGS send_logs_level = 'test'; ``` @@ -205,8 +203,8 @@ SETTINGS send_logs_level = 'test'; ## 关键要点 {#key-takeaways} -* PREWHERE 避免了读取后续过滤掉的列数据,从而节省 I/O 和内存。 -* 当 `optimize_move_to_prewhere` 启用时(默认),它会自动工作。 -* 过滤顺序很重要:小而选择性的列应优先处理。 -* 使用 `EXPLAIN` 和日志验证 PREWHERE 的应用并理解其影响。 -* PREWHERE 在宽表和具有选择性过滤的大规模扫描中效果最为显著。 +* PREWHERE避免读取后续将被过滤掉的列数据,从而节省I/O和内存。 +* 当`optimize_move_to_prewhere`启用时(默认),它会自动工作。 +* 过滤顺序很重要:小且选择性强的列应优先。 +* 使用`EXPLAIN`和日志验证PREWHERE是否应用,并理解其影响。 +* PREWHERE对宽表和大扫描与选择性过滤条件的影响最大。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/prewhere.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/prewhere.md.hash index f19c9394166..0645fa639fb 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/prewhere.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/prewhere.md.hash @@ -1 +1 @@ -153b016212076ebe +e0721d91981ef0b3 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/query-optimization.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/query-optimization.md index 479aac41fef..ed66c0cd52b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/query-optimization.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/query-optimization.md @@ -2,64 +2,65 @@ 'slug': '/optimize/query-optimization' 'sidebar_label': '查询优化' 'title': '查询优化指南' -'description': '一个简单的查询优化指南,描述提高查询性能的常见方法' +'description': '一个简单的查询优化指南,描述了提高查询性能的常见方法' +'doc_type': 'guide' --- import queryOptimizationDiagram1 from '@site/static/images/guides/best-practices/query_optimization_diagram_1.png'; import Image from '@theme/IdealImage'; -# 查询优化的简单指南 +# 一个简单的查询优化指南 -本节旨在通过常见场景来说明如何使用不同的性能和优化技术,如 [analyzer](/operations/analyzer)、[查询分析](/operations/optimizing-performance/sampling-query-profiler) 或 [避免使用 Nullable 列](/optimize/avoid-nullable-columns),来提高 ClickHouse 查询的性能。 +本节旨在通过常见场景说明如何使用不同的性能和优化技术,比如 [analyzer](/operations/analyzer)、[query profiling](/operations/optimizing-performance/sampling-query-profiler) 或 [避免 Nullable 列](/optimize/avoid-nullable-columns),以提高 ClickHouse 查询性能。 -## 了解查询性能 {#understand-query-performance} +## 理解查询性能 {#understand-query-performance} -考虑性能优化的最佳时机是当你在将数据首次导入 ClickHouse 之前设置 [数据模式](/data-modeling/schema-design) 的时候。 +考虑性能优化的最佳时机是在首次将数据导入 ClickHouse 之前设置您的 [数据模式](/data-modeling/schema-design)。 -但说实话;很难预测你的数据将增长多少或将执行什么类型的查询。 +但说实话;很难预测您的数据将增长多少或将执行哪些类型的查询。 -如果你有一个现有的部署,想要改进其中的一些查询,第一步是理解这些查询的执行情况,以及为什么某些查询在几毫秒内执行而其他查询则需要更长时间。 +如果您有一个现有的部署,并且想要改善几个查询,第一步是理解这些查询的性能,以及为什么有些查询需要几毫秒才能执行,而另一些则需要更长时间。 -ClickHouse 提供了一整套工具来帮助你理解查询是如何被执行的,以及执行过程中消耗了哪些资源。 +ClickHouse 提供了一套丰富的工具,帮助您理解查询是如何执行的,以及执行过程中消耗的资源。 -在本节中,我们将探讨这些工具以及如何使用它们。 +在本节中,我们将查看这些工具以及如何使用它们。 -## 一般考虑事项 {#general-considerations} +## 一般考虑 {#general-considerations} -要理解查询性能,我们需要了解 ClickHouse 在执行查询时发生了什么。 +要理解查询性能,首先我们要了解在 ClickHouse 中执行查询时会发生什么。 -以下部分是经过简化的,采取了一些捷径;这里的目的是不是让你淹没于细节中,而是让你迅速了解基本概念。如需更多信息,可以阅读 [查询分析器](/operations/analyzer)。 +以下部分经过简化,采取了一些简化措施;此处的目的不是给您灌输细节,而是让您了解基本概念。有关更多信息,您可以阅读 [查询分析器](/operations/analyzer)。 -从一个非常高层的角度来看,当 ClickHouse 执行查询时,会发生以下事情: +从一个非常高层的角度看,当 ClickHouse 执行查询时,发生以下情况: - - **查询解析与分析** +- **查询解析和分析** 查询被解析和分析,并创建一个通用的查询执行计划。 - - **查询优化** +- **查询优化** -查询执行计划被优化,不需要的数据被剪枝,并从查询计划构建出一个查询管道。 +查询执行计划被优化,冗余数据被修剪,并根据查询计划构建查询管道。 - - **查询管道执行** +- **查询管道执行** -数据被并行读取和处理。在此阶段,ClickHouse 实际上执行查询操作,如过滤、聚合和排序。 +数据被并行读取和处理。在这一阶段,ClickHouse 实际上执行查询操作,比如过滤、聚合和排序。 - - **最终处理** +- **最终处理** -结果被合并、排序,并格式化为最终结果,然后发送给客户端。 +结果被合并、排序并格式化为最终结果,然后发送到客户端。 -实际上,许多 [优化](/concepts/why-clickhouse-is-so-fast) 正在进行中,我们将在本指南中详细讨论,但目前,这些主要概念给我们提供了一个良好的理解,了解在 ClickHouse 执行查询时发生了什么。 +实际上,会发生许多 [优化](/concepts/why-clickhouse-is-so-fast),我们将在本指南中详细讨论,但现在,这些主要概念使我们对 ClickHouse 执行查询时背后发生的事情有了良好的理解。 -通过这种高层次的理解,让我们审视 ClickHouse 提供的工具及其如何用于追踪影响查询性能的指标。 +有了这一高层次的理解,让我们来看看 ClickHouse 提供的工具,以及如何使用它来跟踪影响查询性能的指标。 ## 数据集 {#dataset} -我们将使用一个真实的例子来说明我们如何接近查询性能。 +我们将使用一个真实的例子来说明我们如何处理查询性能。 -让我们使用 NYC Taxi 数据集,其中包含纽约市的出租车行程数据。首先,我们从未优化的状态开始导入 NYC 出租车数据集。 +让我们使用 NYC Taxi 数据集,它包含纽约市的出租车行程数据。首先,我们开始导入没有优化的 NYC 出租车数据集。 -以下是创建表和从 S3 存储桶插入数据的命令。请注意,我们自愿从数据中推断模式,这并没有经过优化。 +以下是从 S3 存储桶创建表并插入数据的命令。请注意,我们自愿从数据中推断出模式,这并没有经过优化。 ```sql -- Create table with inferred schema @@ -74,7 +75,7 @@ FROM s3Cluster ('default','https://datasets-documentation.s3.eu-west-3.amazonaws.com/nyc-taxi/clickhouse-academy/nyc_taxi_2009-2010.parquet'); ``` -让我们看看从数据中自动推断出的表模式。 +让我们看看从数据中自动推断的表模式。 ```sql --- Display inferred table schema @@ -103,17 +104,17 @@ CREATE TABLE nyc_taxi.trips_small_inferred ORDER BY tuple() ``` -## 找出慢查询 {#spot-the-slow-queries} +## 识别慢查询 {#spot-the-slow-queries} ### 查询日志 {#query-logs} -默认情况下,ClickHouse 会收集和记录关于每个执行查询的信息,在 [查询日志](/operations/system-tables/query_log) 中。这些数据存储在表 `system.query_log` 中。 +默认情况下,ClickHouse 收集并记录每个执行查询的信息,存储在 [查询日志](/operations/system-tables/query_log) 中。该数据存储在表 `system.query_log` 中。 -对于每个执行的查询,ClickHouse 会记录统计信息,如查询执行时间、读取的行数,以及资源使用情况(如 CPU、内存使用或文件系统缓存命中)。 +对于每个执行的查询,ClickHouse 记录统计信息,比如查询执行时间、读取的行数和资源使用情况,例如 CPU、内存使用或文件系统缓存命中。 -因此,查询日志是调查慢查询的好地方。你可以轻松找到执行时间较长的查询,并显示每个查询的资源使用信息。 +因此,查询日志是调查慢查询的良好起点。您可以轻松查看执行时间较长的查询,并显示每个查询的资源使用信息。 -让我们找出我们 NYC 出租车数据集中前五个运行时间较长的查询。 +让我们找出 NYC 出租车数据集中运行时间最长的前五个查询。 ```sql -- Find top 5 long running queries from nyc_taxi database in the last 1 hour @@ -214,9 +215,9 @@ read_rows: 329044175 tables: ['nyc_taxi.trips_small_inferred'] ``` -字段 `query_duration_ms` 指示该特定查询的执行时间。根据来自查询日志的结果,我们可以看到第一个查询的运行时间为 2967ms,这可以得到改进。 +字段 `query_duration_ms` 表示该特定查询的执行时间。从查询日志的结果看来,第一个查询运行需要 2967 毫秒,这可以进行改进。 -你可能还想知道哪些查询给系统带来了压力,可以通过检查消耗最多内存或 CPU 的查询来了解。 +您可能还想通过检查使用最多内存或 CPU 的查询,来了解哪些查询正在给系统施加压力。 ```sql -- Top queries by memory usage @@ -236,9 +237,9 @@ ORDER BY memory_usage DESC LIMIT 30 ``` -让我们隔离这些长时间运行的查询,重新运行几次以了解响应时间。 +让我们隔离发现的长时间运行查询,并重新运行几次以理解响应时间。 -此时,关闭文件系统缓存是至关重要的,办法是将 `enable_filesystem_cache` 设置为 0,以提高可重复性。 +在这一点上,关闭文件系统缓存非常重要,通过将 `enable_filesystem_cache` 设置为 0 来提高可重复性。 ```sql -- Disable filesystem cache @@ -292,21 +293,21 @@ FORMAT JSON Peak memory usage: 451.53 MiB. ``` -将其汇总在一个表中,以便于阅读。 +总结成表格以便于阅读。 -| 名称 | 耗时 | 处理的行数 | 峰值内存 | +| 名称 | 消耗时间 | 处理的行数 | 峰值内存 | | ------- | --------- | -------------- | ----------- | -| 查询 1 | 1.699 秒 | 3.2904 亿 | 440.24 MiB | -| 查询 2 | 1.419 秒 | 3.2904 亿 | 546.75 MiB | -| 查询 3 | 1.414 秒 | 3.2904 亿 | 451.53 MiB | +| 查询 1 | 1.699 秒 | 3.2904 亿 | 440.24 MiB | +| 查询 2 | 1.419 秒 | 3.2904 亿 | 546.75 MiB | +| 查询 3 | 1.414 秒 | 3.2904 亿 | 451.53 MiB | -让我们更好地理解查询所实现的效果。 +让我们更加了解一下这些查询的作用。 -- 查询 1 计算平均时速超过 30 英里每小时的行程的距离分布。 -- 查询 2 查找每周的行程数量和平均费用。 -- 查询 3 计算数据集中每次行程的平均时间。 +- 查询 1 计算以超过 30 英里每小时的平均速度的行程距离分布。 +- 查询 2 查找每周的行程数量和平均费用。 +- 查询 3 计算数据集中每次行程的平均时间。 -这些查询都没有进行复杂的处理,除了第一个查询每次执行时动态计算行程时间。但是,这些查询的执行时间超过了一秒,在 ClickHouse 的世界里,这是一个非常长的时间。我们还可以注意到这些查询的内存使用;每个查询差不多 400 MB 的内存相当可观。此外,每个查询读取的行数似乎都是相同的(即 3.2904 亿)。让我们迅速确认一下这个表有多少行。 +这些查询并没有进行非常复杂的处理,除了第一个查询在每次执行时按需计算行程时间。然而,这些查询的执行时间都超过了一秒钟,在 ClickHouse 的世界中,这是非常长的时间。我们还可以注意到这些查询的内存使用情况;每个查询大约 400 MB 的内存用量相当高。此外,每个查询似乎读取的行数是相同的(即 3.2904 亿)。让我们快速确认一下这个表中有多少行。 ```sql -- Count number of rows in table @@ -320,19 +321,19 @@ Query id: 733372c5-deaf-4719-94e3-261540933b23 └───────────┘ ``` -该表包含 3.2904 亿行,因此每个查询都是对表的全表扫描。 +表中包含 3.2904 亿行,因此每个查询都在对表进行完整扫描。 -### 解释语句 {#explain-statement} +### Explain 语句 {#explain-statement} -现在我们有了一些长时间运行的查询,让我们理解它们是如何执行的。为此,ClickHouse 支持 [EXPLAIN 语句命令](/sql-reference/statements/explain)。它是一个非常有用的工具,提供查询执行阶段的详细视图,而不实际运行查询。尽管对非 ClickHouse 专家而言,查看输出可能会感到不知所措,但它仍然是深入了解查询如何执行的重要工具。 +现在我们有了一些长时间运行的查询,让我们了解它们是如何执行的。为此,ClickHouse 支持 [EXPLAIN 语句命令](/sql-reference/statements/explain)。它是一个非常有用的工具,提供了所有查询执行阶段的详细视图,而无需实际运行查询。虽然对非 ClickHouse 专家来说,查看这个可能令人不知所措,但它仍然是深入了解查询执行方式的重要工具。 -文档提供了关于 EXPLAIN 语句是什么以及如何使用它分析查询执行的详细 [指南](/guides/developer/understanding-query-execution-with-the-analyzer)。我们不重复该指南中的内容,而是专注于几个命令,帮助我们找到查询执行性能瓶颈。 +文档提供了关于 EXPLAIN 语句是什么以及如何使用它分析查询执行的详细 [指南](/guides/developer/understanding-query-execution-with-the-analyzer)。我们不会重复这本指南中的内容,而是专注于一些将帮助我们找到查询执行性能瓶颈的命令。 **Explain indexes = 1** -我们用 EXPLAIN indexes = 1 来检查查询计划。查询计划是一个树状结构,显示查询将如何执行。在那里,你可以看到查询中的子句将以什么顺序执行。EXPLAIN 语句返回的查询计划可以从下到上进行阅读。 +首先使用 EXPLAIN indexes = 1 来检查查询计划。查询计划是一个表明查询将如何执行的树形结构。您可以看到查询的子句将以何种顺序被执行。EXPLAIN 语句返回的查询计划可以从下到上读取。 -我们尝试使用我们第一个长时间运行的查询。 +让我们尝试使用我们的一条长时运行查询。 ```sql EXPLAIN indexes = 1 @@ -354,13 +355,13 @@ Query id: f35c412a-edda-4089-914b-fa1622d69868 └─────────────────────────────────────────────────────┘ ``` -输出是直接的。查询开始时将数据从 `nyc_taxi.trips_small_inferred` 表中读取。然后,应用 WHERE 子句来根据计算的值过滤行。过滤后的数据准备进行聚合,并计算分位数。最后,结果被排序并输出。 +输出非常简单。查询首先从 `nyc_taxi.trips_small_inferred` 表中读取数据。然后,应用 WHERE 子句根据计算的值过滤行。筛选后的数据被准备进行聚合,计算分位数。最后,结果被排序并输出。 -在这里,我们可以注意到没有使用主键,这很合理,因为我们在创建该表时没有定义任何主键。因此,ClickHouse 在执行查询时对整张表进行了全表扫描。 +在这里,我们可以注意到没有使用主键,这很合理,因为在创建表时我们没有定义任何主键。因此,ClickHouse 对查询进行了全表扫描。 **Explain Pipeline** -EXPLAIN Pipeline 展示了查询的具体执行策略。在这里,你可以看到 ClickHouse 实际上是如何执行我们之前查看的通用查询计划的。 +EXPLAIN Pipeline 显示了查询的具体执行策略。在这里,您可以看到 ClickHouse 实际上如何执行我们之前看到的通用查询计划。 ```sql EXPLAIN PIPELINE @@ -388,43 +389,43 @@ Query id: c7e11e7b-d970-4e35-936c-ecfc24e3b879 12. │ MergeTreeSelect(pool: PrefetchedReadPool, algorithm: Thread) × 59 0 → 1 │ ``` -在这里,我们可以注意到用于执行查询的线程数量:59 个线程,表示出色的并行化。这加快了查询,需要在较小机器上执行的时间会更长。并行运行的线程数量可以解释查询使用的高内存容量。 +在这里,我们可以注意到用于执行查询的线程数量:59 个线程,指示出高度并行化。这加速了查询,在较小的机器上执行将花费更长时间。并行运行的线程数量可以解释查询使用的高内存量。 -理想情况下,你应该以相同的方式调查所有慢查询,以识别不必要的复杂查询计划,并了解每个查询读取的行数以及消耗的资源。 +理想情况下,您将以相同的方式调查所有的慢查询,以识别不必要的复杂查询计划,并了解每个查询读取的行数和消耗的资源。 ## 方法论 {#methodology} -在生产环境中识别问题查询可能很困难,因为在你的 ClickHouse 部署上,可能会有大量查询在任何给定时刻被执行。 +在生产环境中识别问题查询可能很困难,因为在您的 ClickHouse 部署上,可能在任何给定时间都有大量查询被执行。 -如果你知道哪个用户、数据库或表存在问题,可以使用 `system.query_logs` 中的 `user`、`tables` 或 `databases` 字段来缩小搜索范围。 +如果您知道哪个用户、数据库或表存在问题,可以使用 `system.query_logs` 中的 `user`、`tables` 或 `databases` 字段来缩小搜索范围。 -一旦识别出想要优化的查询,你可以着手进行优化。在这个阶段,开发者常犯的一个错误是同时更改多个内容,进行临时实验,最终通常会得出混合结果,但更重要的是缺乏对使查询更快的因素的良好理解。 +一旦确定要优化的查询,您可以开始对它们进行优化。在这一阶段,开发人员常犯的一个常见错误是同时更改多个内容,进行临时实验,通常以混合结果告终,但更重要的是,缺乏对使查询更快的原因的良好理解。 -查询优化需要结构。我不是在谈论高级基准测试,而是在设置一个简单的流程,以了解你的更改如何影响查询性能,这可以带来很大帮助。 +查询优化需要结构。我不是在谈论高级基准测试,而是在简单的过程中了解您的更改如何影响查询性能会有很大帮助。 -首先从查询日志中识别出你的慢查询,然后在隔离状态下调查潜在的改善。当测试查询时,确保禁用文件系统缓存。 +首先,从查询日志中识别您的慢查询,然后逐个调查潜在的改进。当测试查询时,请确保禁用文件系统缓存。 -> ClickHouse 利用 [缓存](/operations/caches) 在不同阶段加速查询性能。这对于查询性能有好处,但在故障排除期间,可能会隐藏潜在的 I/O 瓶颈或不良的表模式。因此,我建议在测试期间关闭文件系统缓存。在生产环境中确保开启。 +> ClickHouse 利用 [缓存](/operations/caches) 在不同阶段加速查询性能。这对查询性能是有好处的,但在故障排除期间,它可能会掩盖潜在的 I/O 瓶颈或不良的表模式。因此,我建议在测试期间关闭文件系统缓存。确保在生产设置中启用它。 -一旦识别出潜在的优化,建议逐个实施这些优化,以更好地跟踪它们如何影响性能。下面是描述一般方法的图表。 +一旦您识别出潜在的优化,建议逐一实施,以便更好地跟踪它们如何影响性能。以下是描述一般方法的图表。 - + -_最后,注意异常值;查询可能会变慢,这是比较常见的,可能是由于用户尝试了临时的开销查询或者系统因其他原因面临压力。你可以通过字段 normalized_query_hash 分组,识别定期执行的开销查询。这些查询可能就是你想要调查的。_ +_最后,要谨慎对待异常情况;查询可能运行缓慢是相当常见的,可能是因为用户尝试了一个临时的昂贵查询,或者系统因其他原因承受压力。您可以按字段 normalized_query_hash 分组,确定定期执行的昂贵查询。这些可能是您想要调查的查询。_ ## 基本优化 {#basic-optimization} -现在我们有了测试的框架,可以开始优化。 +现在我们已经有了测试的框架,我们可以开始优化。 -开始时最好的地方是看看数据是如何存储的。就像任何数据库一样,我们读取的数据越少,查询执行的速度越快。 +开始的最佳地方是查看数据的存储方式。对于任何数据库而言,读取的数据越少,查询的执行速度就越快。 -根据你摄取数据的方式,你可能利用了 ClickHouse [能力](/interfaces/schema-inference) 根据摄取的数据推断表模式。虽然这在开始时非常方便,但如果你想优化查询性能,你需要审查数据模式,以最适合你的用例。 +根据您如何导入数据,您可能已经利用 ClickHouse 的 [能力](/interfaces/schema-inference) 根据导入的数据推断出表模式。尽管这对于开始工作非常实用,但如果您想优化查询性能,则需要审查数据模式,以最好地适应用例。 ### Nullable {#nullable} -如 [最佳实践文档](/best-practices/select-data-types#avoid-nullable-columns) 所述,尽可能避免使用 nullable 列。虽然经常使用 nullable 列会使数据摄取机制更灵活,但它们会对性能产生负面影响,因为每次都必须处理额外的列。 +如 [最佳实践文档](/best-practices/select-data-types#avoid-nullable-columns) 中所述,尽量避免使用 Nullable 列。经常使用它们似乎很诱人,因为它们使数据导入机制更加灵活,但它们对性能产生了负面影响,因为每次都必须处理额外的列。 -运行一个计算 NULL 值行数的 SQL 查询,可以很容易揭示出你表中实际需要 使用 Nullable 值的列。 +运行统计计数 NULL 值的 SQL 查询可以轻易揭示您表中实际上需要 Nullable 值的列。 ```sql -- Find non-null values columns @@ -464,15 +465,15 @@ pickup_location_id_nulls: 0 dropoff_location_id_nulls: 0 ``` -我们只有两个列有 NULL 值:`mta_tax` 和 `payment_type`。其余字段不应该使用 `Nullable` 列。 +我们只有两个包含空值的列:`mta_tax` 和 `payment_type`。其余字段不应使用 `Nullable` 列。 ### 低基数 {#low-cardinality} -对字符串应用的一个简单优化是充分利用 LowCardinality 数据类型。如 [低基数文档](/sql-reference/data-types/lowcardinality) 中所述,ClickHouse 对 LowCardinality 列应用字典编码,这显著提高了查询性能。 +对字符串施加的简单优化是充分利用 LowCardinality 数据类型。如低基数 [文档](/sql-reference/data-types/lowcardinality) 中所述,ClickHouse 对 LowCardinality 列应用字典编码,这显著提高了查询性能。 -确定哪些列是 LowCardinality 的良好候选列的一个简单经验法则是,任何唯一值少于 10,000 的列都是完美候选列。 +判断哪些列适合 LowCardinality 的简单经验法则是:任何唯一值少于 10,000 的列都是绝佳候选者。 -你可以使用以下 SQL 查询查找具有低唯一值数量的列。 +您可以使用以下 SQL 查询查找唯一值数量少的列。 ```sql -- Identify low cardinality columns @@ -494,13 +495,13 @@ uniq(dropoff_location_id): 260 uniq(vendor_id): 3 ``` -对于低基数,这四列 `ratecode_id`、`pickup_location_id`、`dropoff_location_id` 和 `vendor_id` 是 LowCardinality 字段类型的良好候选列。 +具有低基数的这四列,`ratecode_id`、`pickup_location_id`、`dropoff_location_id` 和 `vendor_id`,是良好的 LowCardinality 字段类型候选者。 ### 优化数据类型 {#optimize-data-type} -Clickhouse 支持大量数据类型。确保选择符合你的用例的最小数据类型,以优化性能并减少磁盘上的数据存储空间。 +ClickHouse 支持大量数据类型。请确保选择适合您用例的尽可能小的数据类型,以优化性能并减少磁盘上的数据存储空间。 -对于数字,你可以检查数据集中最小/最大值,以检查当前精度值是否与数据集的实际情况匹配。 +对于数字,您可以检查数据集中最小/最大值,以检查当前的精度值是否与数据集的实际情况相符。 ```sql -- Find min/max values for the payment_type field @@ -516,11 +517,11 @@ Query id: 4306a8e1-2a9c-4b06-97b4-4d902d2233eb └───────────────────┴───────────────────┘ ``` -对于日期,你应选择与数据集相匹配、最适合于回答你打算运行的查询的精度。 +对于日期,您应该选择与数据集相匹配并最适合回答您计划执行的查询的精度。 ### 应用优化 {#apply-the-optimizations} -让我们创建一个新表以使用优化过的模式,并重新导入数据。 +让我们创建一个新表以使用优化模式,并重新导入数据。 ```sql -- Create table with optimized data @@ -548,17 +549,17 @@ ORDER BY tuple(); INSERT INTO trips_small_no_pk SELECT * FROM trips_small_inferred ``` -我们使用新表再次运行查询以检查改进情况。 +我们再次使用新表运行查询,以检查改进情况。 -| 名称 | 运行 1 - 耗时 | 耗时 | 处理的行数 | 峰值内存 | -| ------- | -------------- | --------- | -------------- | ----------- | -| 查询 1 | 1.699 秒 | 1.353 秒 | 3.2904 亿 | 337.12 MiB | -| 查询 2 | 1.419 秒 | 1.171 秒 | 3.2904 亿 | 531.09 MiB | -| 查询 3 | 1.414 秒 | 1.188 秒 | 3.2904 亿 | 265.05 MiB | +| 名称 | 运行 1 - 消耗时间 | 消耗时间 | 处理的行数 | 峰值内存 | +| ------- | --------------- | --------- | -------------- | ----------- | +| 查询 1 | 1.699 秒 | 1.353 秒 | 3.2904 亿 | 337.12 MiB | +| 查询 2 | 1.419 秒 | 1.171 秒 | 3.2904 亿 | 531.09 MiB | +| 查询 3 | 1.414 秒 | 1.188 秒 | 3.2904 亿 | 265.05 MiB | -我们注意到查询时间和内存使用方面都有一些改善。由于数据模式的优化,我们减少了所代表数据的总数据量,导致内存消耗降低和处理时间缩短。 +我们注意到查询时间和内存使用情况都有所改善。感谢数据模式的优化,我们减少了表示数据的总数据量,导致内存消耗得到改善,并缩短了处理时间。 -让我们检查表的大小以查看差异。 +让我们检查一下表的大小以查看差异。 ```sql SELECT @@ -581,35 +582,35 @@ Query id: 72b5eb1c-ff33-4fdb-9d29-dd076ac6f532 └──────────────────────┴────────────┴──────────────┴───────────┘ ``` -新表比之前的表小得多。我们看到该表的磁盘空间减少了约 34%(7.38 GiB 对比 4.89 GiB)。 +新表比之前的表小得多。我们看到表的磁盘空间减少了约 34%(7.38 GiB 对比 4.89 GiB)。 ## 主键的重要性 {#the-importance-of-primary-keys} -ClickHouse 中的主键与大多数传统数据库系统中的工作方式有所不同。在这些系统中,主键强制执行唯一性和数据完整性。任何试图插入重复主键值的尝试都会被拒绝,并且通常会为快速查找创建 B 树或基于哈希的索引。 +ClickHouse 中的主键与大多数传统数据库系统的工作原理不同。在这些系统中,主键强制唯一性和数据完整性。任何试图插入重复主键值的操作都会被拒绝,并通常会创建 B 树或基于哈希的索引以实现快速查找。 -在 ClickHouse 中,主键的 [目标](/guides/best-practices/sparse-primary-indexes#a-table-with-a-primary-key) 是不同的;它不强制执行唯一性或帮助确保数据完整性。相反,它旨在优化查询性能。主键定义了数据在磁盘上的存储顺序,并作为稀疏索引实现,存储指向每个 granule 第一行的指针。 +在 ClickHouse 中,主键的 [目标](/guides/best-practices/sparse-primary-indexes#a-table-with-a-primary-key) 是不同的;它不会强制唯一性或帮助数据完整性。相反,它旨在优化查询性能。主键定义了数据在磁盘上的存储顺序,并实现为稀疏索引,存储指向每个粒度第一行的指针。 -> 在 ClickHouse 中,granules 是在查询执行期间读取的最小数据单位。它们包含最多固定数量的行,由 index_granularity 决定,默认值为 8192 行。granules 是连续存储并按主键排序的。 +> ClickHouse 中的颗粒是查询执行期间读取的最小数据单元。它们包含固定数量的行,由 index_granularity 确定,默认值为 8192 行。颗粒按主键连续存储且排序。 -选择一组好的主键对于性能很重要,实际上,通常会在不同的表中存储相同的数据,并使用不同的主键集合来加速特定的查询集合。 +选择一组良好的主键对性能至关重要,实际上,常见的做法是在不同的表中存储相同的数据,并使用不同的主键组合来加速特定的一组查询。 -ClickHouse 支持的其他选项,如投影或物化视图,允许你对相同数据使用不同的主键集。该博客系列的第二部分将对此进行更深入的讲解。 +ClickHouse 支持的其他选项,如投影或物化视图,允许您对同一数据使用不同的主键集合。本系列博客的第二部分将对此进行更详细的讨论。 ### 选择主键 {#choose-primary-keys} -选择正确的主键集合是一个复杂的话题,可能需要权衡和实验以找到最佳组合。 +选择正确的主键组合是一个复杂的话题,可能需要权衡和实验以找到最佳组合。 -目前,我们将遵循以下简单做法: +目前,我们将遵循这些简单的做法: -- 使用在大多数查询中用于过滤的字段 -- 首先选择基数较低的列 -- 在你的主键中考虑基于时间的组件,因为在时间戳数据集上按时间过滤是很常见的。 +- 使用在大多数查询中被用作过滤的字段 +- 优先选择基数较低的列 +- 考虑在主键中包含基于时间的组件,因为在时间戳数据集中按时间过滤是相当常见的。 在我们的案例中,我们将尝试以下主键:`passenger_count`、`pickup_datetime` 和 `dropoff_datetime`。 -`passenger_count` 的基数很小(24 个唯一值),并且使用于我们的慢查询中。我们还添加了时间戳字段(`pickup_datetime` 和 `dropoff_datetime`),因为它们经常被过滤。 +乘客数量的基数较小(24 个唯一值),并在我们缓慢的查询中被使用。我们还添加时间戳字段(`pickup_datetime` 和 `dropoff_datetime`),因为它们通常可以被过滤。 -创建一个带有主键的新表并重新导入数据。 +创建一个新的包含主键的表,并重新导入数据。 ```sql CREATE TABLE trips_small_pk @@ -636,7 +637,7 @@ PRIMARY KEY (passenger_count, pickup_datetime, dropoff_datetime); INSERT INTO trips_small_pk SELECT * FROM trips_small_inferred ``` -然后我们重新运行我们的查询。我们汇总了三次实验的结果,以查看在耗时、处理的行数和内存消耗方面的改进。 +然后我们重新运行查询。我们将三次实验的结果汇总,以查看消耗时间、处理的行数和内存使用情况的改善情况。
@@ -652,7 +653,7 @@ INSERT INTO trips_small_pk SELECT * FROM trips_small_inferred - + @@ -686,7 +687,7 @@ INSERT INTO trips_small_pk SELECT * FROM trips_small_inferred - + @@ -695,7 +696,7 @@ INSERT INTO trips_small_pk SELECT * FROM trips_small_inferred - + @@ -720,7 +721,7 @@ INSERT INTO trips_small_pk SELECT * FROM trips_small_inferred - + @@ -729,7 +730,7 @@ INSERT INTO trips_small_pk SELECT * FROM trips_small_inferred - + @@ -740,9 +741,9 @@ INSERT INTO trips_small_pk SELECT * FROM trips_small_inferred
耗时消耗时间 1.699 秒 1.353 秒 0.765 秒
耗时消耗时间 1.419 秒 1.171 秒 0.248 秒处理的行数 3.2904 亿 3.2904 亿41.46 百万4146 万
峰值内存
耗时消耗时间 1.414 秒 1.188 秒 0.431 秒处理的行数 3.2904 亿 3.2904 亿276.99 百万2.7699 亿
峰值内存
-我们可以看到在执行时间和内存使用方面都有显著的改善。 +我们可以看到执行时间和使用内存的显著改善。 -查询 2 从主键中受益最大。让我们来看一下生成的查询计划与之前的不同之处。 +查询 2 受益于主键的改进。让我们看看生成的查询计划与之前有何不同。 ```sql EXPLAIN indexes = 1 @@ -777,10 +778,10 @@ Query id: 30116a77-ba86-4e9f-a9a2-a01670ad2e15 └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ ``` -由于主键,只选择了表 granules 的一个子集。这大大提高了查询性能,因为 ClickHouse 需要处理的数据量显著减少。 +感谢主键的存在,仅选择了部分表颗粒。这大大提高了查询性能,因为 ClickHouse 处理的数据显著减少。 -## 后续步骤 {#next-steps} +## 下一步 {#next-steps} -希望本指南能让你很好地理解如何使用 ClickHouse 调查慢查询以及如何使它们更快。要进一步探索这个主题,你可以阅读更多关于 [查询分析器](/operations/analyzer) 和 [分析](/operations/optimizing-performance/sampling-query-profiler) 的内容,以更好地理解 ClickHouse 是如何执行查询的。 +希望本指南能帮助您更好地理解如何使用 ClickHouse 调查慢查询以及如何使其更快。要进一步了解此主题,您可以阅读有关 [查询分析器](/operations/analyzer) 和 [概况分析](/operations/optimizing-performance/sampling-query-profiler) 的更多内容,以更详细地理解 ClickHouse 如何执行您的查询。 -随着你对 ClickHouse 特性的熟悉,我建议你阅读有关 [分区键](/optimize/partitioning-key) 和 [数据跳过索引](/optimize/skipping-indexes) 的内容,以了解更多可以加速查询的高级技术。 +随着您对 ClickHouse 特性的熟悉,我建议您阅读有关 [分区键](/optimize/partitioning-key) 和 [数据跳过索引](/optimize/skipping-indexes) 的内容,以了解可以用来加速查询的更高级技术。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/query-optimization.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/query-optimization.md.hash index 7601a72fd38..7cdee1691da 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/query-optimization.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/query-optimization.md.hash @@ -1 +1 @@ -aeb560bcaf5fa134 +d42a5b97e603eb29 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/query-parallelism.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/query-parallelism.md index fcba4ff450a..d57a618c787 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/query-parallelism.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/query-parallelism.md @@ -4,6 +4,7 @@ 'sidebar_position': 20 'description': 'ClickHouse 使用处理通道和 max_threads 设置来并行化查询执行。' 'title': 'ClickHouse 如何并行执行查询' +'doc_type': 'guide' --- import visual01 from '@site/static/images/guides/best-practices/query-parallelism_01.gif'; @@ -16,57 +17,56 @@ import Image from '@theme/IdealImage'; # ClickHouse 如何并行执行查询 -ClickHouse 是 [为速度而构建的](/concepts/why-clickhouse-is-so-fast)。它以高度并行的方式执行查询,利用所有可用的 CPU 核心,将数据分配到处理通道,并且通常将硬件推向其极限。 +ClickHouse 是 [为速度而构建的](/concepts/why-clickhouse-is-so-fast)。它以高度并行的方式执行查询,利用所有可用的 CPU 核心,在处理通道之间分配数据,常常将硬件推向极限。 -本指南介绍了 ClickHouse 如何实现查询并行性,以及如何调整或监控它以提高大型工作负载的性能。 +本指南将逐步介绍 ClickHouse 中查询并行性是如何工作的,以及如何调整或监控查询以提升大型工作负载的性能。 我们使用对 [uk_price_paid_simple](/parts) 数据集的聚合查询来说明关键概念。 - ## 步骤:ClickHouse 如何并行化聚合查询 {#step-by-step-how-clickHouse-parallelizes-an-aggregation-query} -当 ClickHouse ① 执行一个带有过滤条件的聚合查询时,它 ② 将主键索引加载到内存中,以 ③ 确定需要处理哪些粒度,以及哪些可以安全跳过: +当 ClickHouse ① 运行一个在表的主键上带过滤器的聚合查询时,它 ② 将主索引加载到内存以 ③ 确定需要处理的粒度以及可以安全跳过的粒度: -Index analysis +索引分析 ### 在处理通道之间分配工作 {#distributing-work-across-processing-lanes} -选择的数据随后通过 `n` 个并行的 [处理通道](/academic_overview#4-2-multi-core-parallelization) 进行 [动态](#load-balancing-across-processing-lanes) 分配,这些通道按块流式处理数据并生成最终结果: +选择的数据随后在 `n` 个并行的 [处理通道](/academic_overview#4-2-multi-core-parallelization) 中 [动态](#load-balancing-across-processing-lanes) 分配,这些通道将数据逐块流式处理到最终结果中: -4 parallel processing lanes +4 个并行处理通道

-`n` 个并行处理通道的数量由 [max_threads](/operations/settings/settings#max_threads) 设置控制,默认情况下与服务器上可用的 CPU 核心数量匹配。在上面的示例中,我们假设有 `4` 个核心。 +并行处理通道的数量 `n` 由 [max_threads](/operations/settings/settings#max_threads) 设置控制,默认情况下与 ClickHouse 在服务器上可用的 CPU 核心数量匹配。在上述例子中,我们假设有 `4` 个核心。 -在一台具有 `8` 个核心的机器上,查询处理的吞吐量大致会翻倍(但内存使用也会相应增加),因为更多的通道并行处理数据: +在一台具有 `8` 个核心的机器上,查询处理吞吐量大约会翻倍(但内存使用量也会相应增加),因为更多的通道并行处理数据: -8 parallel processing lanes +8 个并行处理通道

有效的通道分配是最大化 CPU 利用率和减少总查询时间的关键。 ### 在分片表上处理查询 {#processing-queries-on-sharded-tables} -当表数据分布在多个服务器作为 [分片](/shards) 时,每台服务器并行处理其分片。在每台服务器内部,本地数据使用并行处理通道进行处理,正如上面描述的那样: +当表数据在多个服务器之间分布为 [分片](/shards) 时,每台服务器并行处理其分片。在每台服务器内部,本地数据的处理也使用前面描述的并行处理通道: -Distributed lanes +分布式通道

-最初接收查询的服务器会收集来自各个分片的所有子结果,并将它们合并为最终的全局结果。 +最初接收查询的服务器收集来自各个分片的所有子结果,并将它们合并为最终的全局结果。 -在分片之间分配查询负载允许并行性的水平扩展,特别适合高吞吐量环境。 +在分片之间分配查询负载允许横向扩展并行性,特别适合高吞吐量环境。 :::note ClickHouse Cloud 使用并行副本而不是分片 -在 ClickHouse Cloud 中,通过 [并行副本](https://clickhouse.com/docs/deployment-guides/parallel-replicas) 实现相同的并行性,这些副本在无状态计算节点中类似于共享无集群中的分片。每个 ClickHouse Cloud 副本处理部分数据并行处理并贡献于最终结果,就像独立的分片一样。 +在 ClickHouse Cloud 中,这种并行性是通过 [并行副本](https://clickhouse.com/docs/deployment-guides/parallel-replicas) 实现的,类似于在无共享集群中的分片。每个 ClickHouse Cloud 副本——一个无状态计算节点——并行处理一部分数据,并为最终结果做出贡献,就像独立分片一样。 ::: ## 监控查询并行性 {#monitoring-query-parallelism} -使用这些工具验证您的查询是否充分利用了可用 CPU 资源,并在不利用时进行诊断。 +使用这些工具来验证查询是否充分利用可用的 CPU 资源,并诊断何时没有做到这一点。 -我们在一台具有 59 个 CPU 核心的测试服务器上运行此查询,这允许 ClickHouse 充分展示其查询并行性。 +我们在一台具有 59 个 CPU 核心的测试服务器上运行此操作,这使 ClickHouse 能够充分展示其查询并行性。 -为了观察示例查询是如何执行的,我们可以指示 ClickHouse 服务器在聚合查询期间返回所有跟踪级别的日志条目。为了展示,我们移除了查询的谓词——否则只会处理 3 个粒度,这不足以让 ClickHouse 利用更多的并行处理通道: +为了观察示例查询的执行方式,我们可以指示 ClickHouse 服务器在聚合查询期间返回所有跟踪级别的日志条目。在此演示中,我们移除了查询的谓词——否则仅会处理 3 个粒度,这不足以让 ClickHouse 利用更多的并行处理通道: ```sql runnable=false SELECT max(price) @@ -83,12 +83,10 @@ SETTINGS send_logs_level='trace'; 我们可以看到 +* ① ClickHouse 需要读取 3,609 个粒度(在跟踪日志中表示为标记),覆盖 3 个数据范围。 +* ② 通过 59 个 CPU 核心,它将这项工作分配到 59 条并行处理流中——每条通道一个。 - -* ① ClickHouse 需要读取 3,609 个粒度(在跟踪日志中标记为标记),分布在 3 个数据范围内。 -* ② 使用 59 个 CPU 核心,它通过 59 个并行处理通道分配这项工作——一个通道对应一条流。 - -或者,我们可以使用 [EXPLAIN](/sql-reference/statements/explain#explain-pipeline) 子句检查 [物理操作计划](/academic_overview#4-2-multi-core-parallelization)——也称为“查询管道”——以了解聚合查询的执行情况: +另外,我们可以使用 [EXPLAIN](/sql-reference/statements/explain#explain-pipeline) 子句来检查 [物理操作计划](/academic_overview#4-2-multi-core-parallelization),也称为"查询管道",以获取聚合查询的详细信息: ```sql runnable=false EXPLAIN PIPELINE SELECT @@ -112,23 +110,21 @@ FROM └───────────────────────────────────────────────────────────────────────────────────┘ ``` -注意:从底部向顶部读取上述操作计划。每一行表示物理执行计划中的一个阶段,从底部的存储读取数据开始,到顶部的最终处理步骤结束。标记为 `× 59` 的操作在非重叠的数据区域上并发执行,跨 59 个并行处理通道。这反映了 `max_threads` 的值,并说明查询的每个阶段如何跨 CPU 核心并行化。 - -ClickHouse 的 [嵌入式网络用户界面](/interfaces/http)(可通过 `/play` 端点访问)可以将上述物理计划呈现为图形可视化。在此示例中,我们将 `max_threads` 设置为 `4`,以保持可视化紧凑,仅显示 4 个并行处理通道: +注意:请从下往上阅读上述操作计划。每一行代表物理执行计划中的一个阶段,从底部的存储读取数据开始,到顶部的最终处理步骤结束。标记为 `× 59` 的操作是在 59 条并行处理通道上对不重叠的数据区域并发执行的。这反映了 `max_threads` 的值,并说明了查询的每个阶段如何在 CPU 核心之间并行化。 -Query pipeline +ClickHouse 的 [嵌入式 Web UI](/interfaces/http)(在 `/play` 端点可用)可以将上述物理计划呈现为图形可视化。在此示例中,我们将 `max_threads` 设置为 `4` 以保持可视化紧凑,仅显示 4 条并行处理通道: -注意:从左到右读取可视化。每一行代表一个并行处理通道,逐块流式传输数据,并应用过滤、聚合和最终处理步骤等转换。在此示例中,您可以看到与 `max_threads = 4` 设置对应的四个并行通道。 +查询管道 +注意:从左到右阅读可视化。每一行代表一条并行处理通道,该通道逐块流式处理数据,并应用过滤、聚合和最终处理阶段等变换。在此示例中,您可以看到四条与 `max_threads = 4` 设置对应的并行通道。 ### 在处理通道之间进行负载均衡 {#load-balancing-across-processing-lanes} -请注意,物理计划中的 `Resize` 操作会 [重新分区和重新分配](/academic_overview#4-2-multi-core-parallelization) 数据块流,以确保它们被均匀利用。当数据范围在匹配查询谓词的行数上有所差异时,这种重新平衡尤其重要,否则某些通道可能会过载,而另一些则处于空闲状态。通过重新分配工作,快速通道有效地帮助较慢的通道,从而优化整体查询运行时间。 +注意,物理计划中的 `Resize` 操作 [重新划分和重新分配](/academic_overview#4-2-multi-core-parallelization) 数据块流,以保持通道的均匀利用。这种重新平衡在数据范围中匹配查询谓词的行数变化时尤其重要,否则某些通道可能会超负荷,而其他通道则闲置。通过重新分配工作,快速通道有效地帮助较慢的通道,优化整体查询运行时间。 +## 为什么 `max_threads` 并不总是被尊重 {#why-max-threads-isnt-always-respected} -## 为什么 max_threads 并不总是被遵循 {#why-max-threads-isnt-always-respected} - -如上所述,`n` 个并行处理通道的数量由 `max_threads` 设置控制,默认情况下与服务器上可用的 CPU 核心数量匹配: +如上所述,并行处理通道的数量 `n` 由 `max_threads` 设置控制,默认情况下与 ClickHouse 在服务器上可用的 CPU 核心数量匹配: ```sql runnable=false SELECT getSetting('max_threads'); ``` @@ -139,7 +135,7 @@ SELECT getSetting('max_threads'); └───────────────────────────┘ ``` -但是,`max_threads` 值可能会被忽略,具体取决于选择的处理数据量: +但是,`max_threads` 的值可能会被忽略,这取决于选定的数据量: ```sql runnable=false EXPLAIN PIPELINE SELECT @@ -155,7 +151,7 @@ WHERE town = 'LONDON'; MergeTreeSelect(pool: PrefetchedReadPool, algorithm: Thread) × 30 ``` -如上面操作计划提取所示,即使 `max_threads` 设置为 `59`,ClickHouse 仍然使用仅 **30** 个并发流来扫描数据。 +如上面的操作计划摘录所示,即使 `max_threads` 设置为 `59`,ClickHouse 也只使用 **30** 条并发流来扫描数据。 现在让我们运行查询: ```sql runnable=false @@ -175,7 +171,7 @@ WHERE town = 'LONDON'; Peak memory usage: 27.24 MiB. ``` -如上面输出所示,查询处理了 231 万行,并读取了 13.66MB 的数据。这是因为在索引分析阶段,ClickHouse 为处理选择了 **282** 个粒度,每个粒度包含 8,192 行,总计约 231 万行: +如上面的输出所示,查询处理了 231 万行,读取了 13.66MB 的数据。这是因为在索引分析阶段,ClickHouse 选择了 **282 个粒度** 进行处理,每个粒度包含 8,192 行,合计大约 231 万行: ```sql runnable=false EXPLAIN indexes = 1 @@ -203,11 +199,11 @@ WHERE town = 'LONDON'; └───────────────────────────────────────────────────────┘ ``` -无论配置的 `max_threads` 值如何,ClickHouse 只会在有足够数据的情况下分配额外的并行处理通道。“max” 的含义是一个上限,而不是使用线程的保证数量。 +无论配置的 `max_threads` 值如何,ClickHouse 仅在有足够数据 justify 它们时才会分配额外的并行处理通道。`max_threads` 中的 "max" 指的是一个上限,而不是使用线程的保证数量。 -“足够的数据”主要由两个设置决定,这两个设置定义了每个处理通道应处理的最小行数(默认 163,840 行)和最小字节数(默认 2,097,152 字节): +"足够的数据" 主要由两个设置决定,它们定义了每个处理通道应处理的最小行数(默认 163,840 行)和最小字节数(默认 2,097,152 字节): -对于无共享的集群: +对于无共享集群: * [merge_tree_min_rows_for_concurrent_read](https://clickhouse.com/docs/operations/settings/settings#merge_tree_min_rows_for_concurrent_read) * [merge_tree_min_bytes_for_concurrent_read](https://clickhouse.com/docs/operations/settings/settings#merge_tree_min_bytes_for_concurrent_read) @@ -215,15 +211,14 @@ WHERE town = 'LONDON'; * [merge_tree_min_rows_for_concurrent_read_for_remote_filesystem](https://clickhouse.com/docs/operations/settings/settings#merge_tree_min_rows_for_concurrent_read_for_remote_filesystem) * [merge_tree_min_bytes_for_concurrent_read_for_remote_filesystem](https://clickhouse.com/docs/operations/settings/settings#merge_tree_min_bytes_for_concurrent_read_for_remote_filesystem) -另外,还有一个读取任务大小的硬性下限,由以下设置控制: +此外,还有一个读取任务大小的硬性下限,由以下设置控制: * [Merge_tree_min_read_task_size](https://clickhouse.com/docs/operations/settings/settings#merge_tree_min_read_task_size) + [merge_tree_min_bytes_per_task_for_remote_reading](https://clickhouse.com/docs/operations/settings/settings#merge_tree_min_bytes_per_task_for_remote_reading) -:::warning 请勿修改这些设置 -我们不建议在生产环境中修改这些设置。这些设置在这里仅用于说明为什么 `max_threads` 并不总是决定实际的并行级别。 +:::warning 不要修改这些设置 +我们不推荐在生产环境中修改这些设置。这里展示它们仅是为了说明为什么 `max_threads` 并不总是决定实际的并行级别。 ::: - -出于演示目的,让我们检查物理计划,并覆盖这些设置以强制最大并发: +为了演示目的,让我们检查一下物理计划,强制最大并发的这些设置被覆盖: ```sql runnable=false EXPLAIN PIPELINE SELECT @@ -244,24 +239,23 @@ SETTINGS MergeTreeSelect(pool: PrefetchedReadPool, algorithm: Thread) × 59 ``` -现在 ClickHouse 使用 59 个并发流扫描数据,完全遵循配置的 `max_threads`。 +现在 ClickHouse 使用 59 条并发流来扫描数据,完全尊重配置的 `max_threads`。 -这表明,对于小数据集的查询,ClickHouse 会主动限制并发。仅在测试中使用设置覆盖——而不是在生产中——因为它们可能导致低效的执行或资源争用。 +这表明对于小数据集的查询,ClickHouse 会故意限制并发性。仅在测试中使用设置覆盖——不要在生产环境中使用,因为它们可能导致效率低下的执行或资源争用。 ## 关键要点 {#key-takeaways} -* ClickHouse 使用与 `max_threads` 绑定的处理通道对查询进行并行化。 -* 实际的通道数量取决于选择处理的数据的大小。 +* ClickHouse 使用与 `max_threads` 相关的处理通道并行化查询。 +* 实际的通道数量取决于选定处理的数据的大小。 * 使用 `EXPLAIN PIPELINE` 和跟踪日志分析通道使用情况。 +## 更多信息来源 {#where-to-find-more-information} -## 了解更多信息的地方 {#where-to-find-more-information} - -如果您想深入了解 ClickHouse 如何并行执行查询以及如何在规模上实现高性能,请探索以下资源: +如果您想深入了解 ClickHouse 如何并行执行查询以及如何在规模下实现高性能,请探索以下资源: -* [查询处理层 – VLDB 2024 论文(网页版)](/academic_overview#4-query-processing-layer) - 详细分析 ClickHouse 的内部执行模型,包括调度、管道化和操作符设计。 +* [查询处理层 - VLDB 2024 论文(网页版)](/academic_overview#4-query-processing-layer) - ClickHouse 内部执行模型的详细分解,包括调度、管道化和操作符设计。 -* [部分聚合状态解释](https://clickhouse.com/blog/clickhouse_vs_elasticsearch_mechanics_of_count_aggregations#-multi-core-parallelization) - 对部分聚合状态如何使处理通道实现高效并行执行的技术深入探讨。 +* [部分聚合状态的解释](https://clickhouse.com/blog/clickhouse_vs_elasticsearch_mechanics_of_count_aggregations#-multi-core-parallelization) - 深入探讨部分聚合状态如何促进处理通道之间的高效并行执行的技术细节。 -* 一段详细介绍 ClickHouse 查询处理步骤的视频教程: - +* 一段视频教程详细介绍 ClickHouse 查询处理的所有步骤: + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/query-parallelism.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/query-parallelism.md.hash index 5cea0620856..09424d50439 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/query-parallelism.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/query-parallelism.md.hash @@ -1 +1 @@ -aa56721341d037cf +68fe36f2d1ae21c4 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/skipping-indexes.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/skipping-indexes.md index f2aa859d0b7..7a861834e41 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/skipping-indexes.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/skipping-indexes.md @@ -2,8 +2,9 @@ 'slug': '/optimize/skipping-indexes' 'sidebar_label': '数据跳过索引' 'sidebar_position': 2 -'description': '跳过索引使 ClickHouse 能够跳过读取保证没有匹配值的重要数据块。' +'description': '跳过索引用于使 ClickHouse 跳过读取保证没有匹配值的重要数据块。' 'title': '理解 ClickHouse 数据跳过索引' +'doc_type': 'guide' --- import simple_skip from '@site/static/images/guides/best-practices/simple_skip.png'; @@ -15,29 +16,29 @@ import Image from '@theme/IdealImage'; ## 介绍 {#introduction} -许多因素会影响 ClickHouse 的查询性能。在大多数情况下,关键因素是 ClickHouse 是否能够在评估查询的 WHERE 子句条件时使用主键。因此,选择适用于最常见查询模式的主键对于有效的表设计至关重要。 +许多因素会影响 ClickHouse 的查询性能。在大多数场景中,关键因素是 ClickHouse 能否在评估查询 WHERE 子句条件时使用主键。因此,选择适用于最常见查询模式的主键对有效的表设计至关重要。 -然而,无论主键调优得多么仔细,必然会出现无法高效使用主键的查询用例。用户通常依赖 ClickHouse 处理时间序列类型的数据,但他们往往希望根据其他业务维度分析这些同样的数据,例如客户ID、网站 URL 或产品编号。在这种情况下,查询性能可能会大幅下降,因为可能需要对每个列值进行全面扫描以应用 WHERE 子句条件。尽管在这些情况下 ClickHouse 仍然相对快速,但评估数百万或数十亿个单个值会导致“非索引”查询的执行速度远低于基于主键的查询。 +然而,无论主键调整得多么细致,都会不可避免地出现无法有效利用主键的查询用例。用户通常依赖 ClickHouse 来处理时间序列类型的数据,但他们往往希望根据其他业务维度(例如客户 ID、网站 URL 或产品编号)分析相同的数据。在这种情况下,查询性能可能会显著下降,因为可能需要对每一列值进行全表扫描以应用 WHERE 子句条件。尽管在这种情况下 ClickHouse 仍然相对快速,但评估数百万或数十亿个单独的值导致的“非索引”查询的执行速度将远低于基于主键的查询。 -在传统关系数据库中,解决此问题的一种方法是在表上附加一个或多个“次级”索引。这是一种 b-tree 结构,允许数据库以 O(log(n)) 的时间而不是 O(n) 的时间(全表扫描)找到所有匹配的行,其中 n 是行数。然而,这种类型的次级索引不适用于 ClickHouse(或其他列存储数据库),因为磁盘上没有单独的行可以添加到索引中。 +在传统的关系型数据库中,解决这个问题的一种方法是为表附加一个或多个“次级”索引。这是一种 b-tree 结构,它允许数据库以 O(log(n)) 的时间复杂度找到所有匹配的行,而不是 O(n) 的时间复杂度(即表扫描),其中 n 是行数。然而,这种次级索引在 ClickHouse(或其他面向列的数据库)中不起作用,因为在磁盘上没有单独的行可以添加到索引中。 -相反,ClickHouse 提供了一种不同类型的索引,在特定情况下可以显著提高查询速度。这些结构被标记为“跳过”索引,因为它们使 ClickHouse 可以跳过读取保证没有匹配值的大块数据。 +相反,ClickHouse 提供了一种不同类型的索引,在特定情况下可以显著提高查询速度。这些结构被称为“跳过”索引,因为它们允许 ClickHouse 跳过读取保证没有匹配值的大块数据。 ## 基本操作 {#basic-operation} -用户只能在 MergeTree 家族的表上使用数据跳过索引。每个数据跳过索引有四个主要参数: +用户只能在 MergeTree 系列表上使用数据跳过索引。每个数据跳过索引有四个主要参数: -- 索引名称。索引名称用于在每个分区中创建索引文件。而且,删除或物化索引时也需要作为参数。 -- 索引表达式。索引表达式用于计算存储在索引中的值集。它可以是列、简单运算符和/或由索引类型确定的函数子集的组合。 -- TYPE。索引的类型控制计算,以确定是否可以跳过读取和评估每个索引块。 -- GRANULARITY。每个索引块由 GRANULARITY 个小颗粒组成。例如,如果主表索引的颗粒度为 8192 行,而索引颗粒度为 4,则每个索引的“块”将为 32768 行。 +- 索引名称。索引名称用于在每个分区中创建索引文件。此外,在删除或物化索引时也需要该参数。 +- 索引表达式。索引表达式用于计算存储在索引中的值集合。它可以是列的组合、简单运算符和/或由索引类型确定的函数子集。 +- TYPE。索引类型控制确定是否可以跳过读取和评估每个索引块的计算。 +- GRANULARITY。每个索引块由 GRANULARITY 个颗粒组成。例如,如果主表索引的粒度是 8192 行,且索引粒度是 4,则每个索引“块”将包含 32768 行。 -当用户创建数据跳过索引时,表的每个数据部分目录中将会有两个额外的文件。 +当用户创建数据跳过索引时,每个数据部分目录中会有两个额外的文件。 -- `skp_idx_{index_name}.idx`,其中包含排序后的表达式值 -- `skp_idx_{index_name}.mrk2`,其中包含相应的数据列文件的偏移量。 +- `skp_idx_{index_name}.idx`,该文件包含有序的表达值 +- `skp_idx_{index_name}.mrk2`,该文件包含与关联数据列文件的相应偏移量。 -如果在执行查询并读取相关列文件时 WHERE 子句过滤条件的某些部分匹配跳过索引表达式,ClickHouse 将使用索引文件数据来判断每个相关的数据块是否必须处理或可以跳过(假设该块尚未通过应用主键而被排除)。为了使用一个非常简单的例子,考虑以下加载了可预测数据的表。 +如果在执行查询并读取相关列文件时,WHERE 子句过滤条件的某一部分与跳过索引表达式匹配,ClickHouse 会使用索引文件数据来确定是否必须处理每个相关数据块,或者可以跳过该块(假设该块尚未通过应用主键排除)。为简单起见,考虑以下使用可预测数据加载的表。 ```sql CREATE TABLE skip_table @@ -51,7 +52,7 @@ SETTINGS index_granularity=8192; INSERT INTO skip_table SELECT number, intDiv(number,4096) FROM numbers(100000000); ``` -在执行一个不使用主键的简单查询时,`my_value` 列中的所有 1 亿条记录都会被扫描: +当执行一个不使用主键的简单查询时,将扫描 `my_value` 列中的所有 1 亿条条目: ```sql SELECT * FROM skip_table WHERE my_value IN (125, 700) @@ -71,15 +72,15 @@ SELECT * FROM skip_table WHERE my_value IN (125, 700) ALTER TABLE skip_table ADD INDEX vix my_value TYPE set(100) GRANULARITY 2; ``` -通常跳过索引仅应用于新插入的数据,因此仅添加索引不会影响上述查询。 +通常,跳过索引只在新插入的数据上应用,因此仅添加索引不会影响上述查询。 -要对已经存在的数据进行索引,使用以下语句: +要对已存在的数据进行索引,请使用此语句: ```sql ALTER TABLE skip_table MATERIALIZE INDEX vix; ``` -使用新创建的索引重新运行查询: +重新运行使用新创建索引的查询: ```sql SELECT * FROM skip_table WHERE my_value IN (125, 700) @@ -93,91 +94,94 @@ SELECT * FROM skip_table WHERE my_value IN (125, 700) 8192 rows in set. Elapsed: 0.051 sec. Processed 32.77 thousand rows, 360.45 KB (643.75 thousand rows/s., 7.08 MB/s.) ``` -ClickHouse 处理的不是 800 兆字节的 1 亿行,而只是读取和分析了 32768 行的 360 千字节 --- 四个颗粒,每个颗粒 8192 行。 +ClickHouse 只读取和分析 32768 行 360 KB 的数据,而不是处理 800 MB 的 1 亿行数据——四个每个 8192 行的颗粒。 -更加直观地说,这就是如何读取和选择 `my_value` 为 125 的 4096 行,以及如何跳过后续行而不从磁盘读取: +以更直观的形式,这就是具有 `my_value` 为 125 的 4096 行如何被读取和选择,以及后续行如何在未从磁盘读取的情况下被跳过: -Simple Skip +简单跳过 -用户可以通过在执行查询时启用跟踪来访问关于跳过索引使用的详细信息。从 clickhouse-client 设置 `send_logs_level`: +用户可以通过在执行查询时启用跟踪来访问跳过索引使用的详细信息。从 clickhouse-client 中,设置 `send_logs_level`: ```sql SET send_logs_level='trace'; ``` -这将在尝试调优查询 SQL 和表索引时提供有用的调试信息。从上面的例子中,调试日志显示跳过索引丢弃了所有除了两个颗粒之外的块: +这将提供有用的调试信息,以便调整查询 SQL 和表索引。从上述示例中,调试日志显示跳过索引丢弃了除两个颗粒之外的所有颗粒: ```sql default.skip_table (933d4b2c-8cea-4bf9-8c93-c56e900eefd1) (SelectExecutor): Index `vix` has dropped 6102/6104 granules. ``` ## 跳过索引类型 {#skip-index-types} + ### minmax {#minmax} + -这种轻量级索引类型不需要参数。它存储每个块的索引表达式的最小值和最大值(如果表达式是元组,它为元组元素的每个成员单独存储值)。此类型非常适合按值松散排序的列。该索引类型通常在查询处理中应用的成本最低。 +这种轻量级索引类型不需要参数。它存储每个块的索引表达式的最小值和最大值(如果表达式是元组,它将分别存储元组元素的每个值)。这种类型适用于按值排序较松散的列。这种索引类型通常在查询处理时成本最低。 -这种类型的索引仅对标量或元组表达式正确工作 -- 索引不会应用于返回数组或映射数据类型的表达式。 +这种类型的索引仅适用于标量或元组表达式——索引不会应用于返回数组或映射数据类型的表达式。 + ### set {#set} + -这种轻量级索引类型接受一个参数,即每个块的值集的 max_size(0 允许无限数量的离散值)。此集合包含块中的所有值(如果值的数量超过 max_size,则为空)。该索引类型在每个颗粒集合中低基数的列上效果良好(本质上,“聚集在一起”),但整体基数较高。 +这种轻量级索引类型接受一个参数,即每个块的值集的最大大小(0 表示允许无限数量的离散值)。这个集合包含块中的所有值(如果值的数量超过最大大小,则为空)。这种索引类型适用于每组颗粒中基数较低的列(基本上是“聚集在一起”),但整体基数较高。 -该索引的成本、性能和有效性取决于块内的基数。如果每个块包含大量唯一值,则评估查询条件与大型索引集的比较将非常昂贵,或者由于超过 max_size,索引将不被应用,因为索引为空。 +此索引的成本、性能和有效性取决于块内的基数。如果每个块包含大量唯一值,则针对大型索引集评估查询条件将非常昂贵,或者由于超出最大大小,索引将不会被应用,因为索引是空的。 ### Bloom 过滤器类型 {#bloom-filter-types} -*Bloom 过滤器* 是一种数据结构,允许以空间高效的方式测试集合成员资格,但有一些小的假阳性机会。在跳过索引的情况下,假阳性并不是一个重要问题,因为唯一的不利之处是读取一些不必要的块。然而,假阳性的潜在可能性确实意味着索引表达式应该被期望为真,否则有效数据可能会被跳过。 +*Bloom 过滤器*是一种数据结构,允许高效的空间测试集合成员资格,但存在轻微的假阳性几率。在跳过索引的情况下,假阳性并不是一个重大问题,因为唯一的缺点是读取一些不必要的块。然而,假阳性的潜在可能意味着所索引的表达式应该被期望为真,否则有效数据可能会被跳过。 -由于 Bloom 过滤器能够更高效地处理对大量离散值的测试,它们可以适用于生成更多待测试值的条件表达式。特别地,Bloom 过滤器索引可以应用于数组,其中测试数组的每个值,并且可以通过将键或值转换为数组使用 mapKeys 或 mapValues 函数来应用于映射。 +由于 Bloom 过滤器能够更高效地处理大量离散值的测试,它们可以适用于产生更多值以进行测试的条件表达式。特别是,Bloom 过滤器索引可以应用于数组,其中数组的每个值都被测试,或通过使用 mapKeys 或 mapValues 函数将键或值转换为数组应用于映射。 -基于 Bloom 过滤器的有三种数据跳过索引类型: +基于 Bloom 过滤器有三种数据跳过索引类型: -* 基本的 **bloom_filter**,接受一个可选参数,允许的“假阳性”率在 0 到 1 之间(如果没有指定,使用 .025)。 +* 基本的 **bloom_filter**,它接受一个允许的“假阳性”率的单个可选参数,范围在 0 到 1(如果未指定,则使用 .025)。 -* 专用的 **tokenbf_v1**。它接受三个参数,均与调整使用的 Bloom 过滤器有关: (1) 过滤器的大小,以字节为单位(更大的过滤器假阳性较少,但存储成本较高), (2) 应用的哈希函数数量(同样,更多的哈希过滤器可以减少假阳性),以及 (3) Bloom 过滤器哈希函数的种子。有关这些参数如何影响 Bloom 过滤器功能的更多详细信息,请查阅计算器 [在这里](https://hur.st/bloomfilter/)。 -该索引仅适用于 String、FixedString 和 Map 数据类型。输入表达式按非字母数字字符分隔成字符序列。例如,列值为 `This is a candidate for a "full text" search` 将包含标记 `This` `is` `a` `candidate` `for` `full` `text` `search`。它用于 LIKE、EQUALS、IN、hasToken() 和类似的在更长字符串内搜索单词和其他值。例如,可能的一个用法是在自由格式应用程序日志行的列中搜索少量类名或行号。 +* 专门的 **tokenbf_v1**。它接受三个参数,均与调整所使用的 Bloom 过滤器有关:(1) 过滤器的大小(以字节为单位)(较大的过滤器假阳性较少,但会增加存储成本),(2) 应用的哈希函数数量(同样,更多的哈希过滤器可减少假阳性),以及 (3) Bloom 过滤器哈希函数的种子。有关这些参数如何影响 Bloom 过滤器功能的更多详细信息,请查看计算器 [这里](https://hur.st/bloomfilter/)。 +该索引仅适用于 String、FixedString 和 Map 数据类型。输入表达式分割为由非字母数字字符分隔的字符序列。例如,列值为 `This is a candidate for a "full text" search` 的字符串将包含令牌 `This` `is` `a` `candidate` `for` `full` `text` `search`。它旨在用于 LIKE、EQUALS、IN、hasToken() 和类似的词与其他值在较长字符串中的搜索。例如,可能的用法之一是在自由表单应用程序日志行的列中搜索少量类名或行号。 -* 专用的 **ngrambf_v1**。该索引的功能与令牌索引相同。在 Bloom 过滤器设置之前,它还需一个附加参数,即要索引的 ngram 的大小。ngram 是长度为 `n` 的字符字符串,因此字符串 `A short string` 的 ngram 大小为 4 的话将会索引为: +* 专门的 **ngrambf_v1**。该索引的功能与令牌索引相同。它在 Bloom 过滤器设置之前需要一个额外参数,即要索引的 ngram 的大小。ngram 是长度为 `n` 的字符字符串,包括任何字符,因此字符串 `A short string` 具有 ngram 大小 4 将被索引为: ```text 'A sh', ' sho', 'shor', 'hort', 'ort ', 'rt s', 't st', ' str', 'stri', 'trin', 'ring' ``` -该索引对于文本搜索也很有用,特别是在没有单词分隔的语言中,例如中文。 +该索引对于文本搜索也非常有用,尤其是对于没有单词间隔的语言,如中文。 ## 跳过索引函数 {#skip-index-functions} -数据跳过索引的核心目的在于限制热门查询所分析的数据量。考虑到 ClickHouse 数据的分析性质,这些查询的模式在大多数情况下包含功能表达式。因此,跳过索引必须与常用函数正确互动才能高效。这可以发生在: -* 插入数据并且索引被定义为功能表达式(表达式的结果存储在索引文件中),或者 -* 查询被处理,并将表达式应用于存储的索引值,以决定是否排除该块。 +数据跳过索引的核心目的是限制受欢迎查询分析的数据量。鉴于 ClickHouse 数据的分析特性,这些查询的模式在大多数情况下包含函数表达式。因此,跳过索引必须与常见函数正确交互以提高效率。这可以在以下两种情况下发生: +* 数据插入时,索引被定义为函数表达式(表达式的结果存储在索引文件中),或者 +* 查询在处理时,表达式应用于存储的索引值,以确定是否排除该块。 -每种跳过索引类型都基于适合索引实现的可用 ClickHouse 函数子集进行工作,列出在 [这里](/engines/table-engines/mergetree-family/mergetree/#functions-support)。一般来说,集合索引和基于 Bloom 过滤器的索引(另一种类型的集合索引)都是无序的,因此不适用于范围。相比之下,minmax 索引在处理范围时特别有效,因为确定是否存在范围交集非常快速。部分匹配函数 LIKE、startsWith、endsWith 和 hasToken 的有效性取决于所使用的索引类型、索引表达式和数据的特定形状。 +每种类型的跳过索引都适用于与索引实现相关的 ClickHouse 函数子集,详细信息请参见 [这里](/engines/table-engines/mergetree-family/mergetree/#functions-support)。通常,set 索引和基于 Bloom 过滤器的索引(另一种类型的 set 索引)都是无序的,因此不适用于范围。相比之下,minmax 索引特别适用于范围,因为确定范围是否相交非常快速。部分匹配函数 LIKE、startsWith、endsWith 和 hasToken 的有效性取决于所用的索引类型、索引表达式和数据的特定形状。 ## 跳过索引设置 {#skip-index-settings} -有两个可用于跳过索引的设置。 +有两个适用于跳过索引的可用设置。 -* **use_skip_indexes** (0 或 1,默认值为 1)。并非所有查询都能有效使用跳过索引。如果某个特定的过滤条件可能包括大多数颗粒,则应用数据跳过索引将产生不必要且有时是显著的成本。对于不太可能从任何跳过索引中受益的查询,将值设置为 0。 -* **force_data_skipping_indices** (以逗号分隔的索引名称列表)。该设置可用于防止某些类型的低效查询。在查询某个表的成本太高,除非使用跳过索引的情况下,此设置与一个或多个索引名称一起使用,将返回任何未使用列出索引的查询的异常。这将防止书写不良的查询消耗服务器资源。 +* **use_skip_indexes** (0 或 1,默认值 1)。并非所有查询都可以有效使用跳过索引。如果特定的过滤条件可能包含大多数颗粒,则应用数据跳过索引会产生不必要,有时是显著的成本。对于不太可能受益于任何跳过索引的查询,将值设置为 0。 +* **force_data_skipping_indices** (逗号分隔的索引名称列表)。此设置可用于防止某些类型的低效查询。在查询表的成本过高,除非使用跳过索引的情况下,使用此设置及一个或多个索引名称将返回不使用列出索引的任何查询的异常。这将防止编写不良查询从而消耗服务器资源。 -## 跳过最佳实践 {#skip-best-practices} +## 跳过索引最佳实践 {#skip-best-practices} -跳过索引并不直观,特别是对于习惯于RDMS领域的基于行的次级索引或文档存储的倒排索引的用户。要获得任何好处,应用 ClickHouse 数据跳过索引必须避免足够的颗粒读取,以抵消计算索引的成本。至关重要的是,如果某个值在一个索引块中出现一次,那么就意味着必须将整个块读入内存并评估,从而无谓地产生了索引成本。 +跳过索引并不直观,尤其是对于习惯于来自 RDMS 领域的基于行的次级索引或来自文档存储的倒排索引的用户。为了获得任何好处,应用 ClickHouse 数据跳过索引必须避免读取足够的颗粒以抵消计算索引的成本。至关重要的是,如果值在索引块中出现至少一次,这意味着整个块必须被读取到内存中并经过评估,并且已不必要地产生了索引成本。 考虑以下数据分布: -Bad Skip +不良跳过 -假设主键/排序键是 `timestamp`,并且 `visitor_id` 上有一个索引。考虑以下查询: +假设主键/排序键为 `timestamp`,并且 `visitor_id` 上有索引。考虑以下查询: ```sql SELECT timestamp, url FROM table WHERE visitor_id = 1001` ``` -在这种数据分布下,传统的次级索引将非常有利。与其读取所有 32768 行以找到 5 行请求的 visitor_id,不如次级索引仅包含 5 个行位置,而只读取这 5 行的内容。对于 ClickHouse 数据跳过索引而言,情况正好相反。无论跳过索引的类型如何,`visitor_id` 列中的所有 32768 个值都会被测试。 +在这种数据分布下,传统的次级索引将非常有利。它不会读取所有 32768 行以查找请求的 visitor_id 的 5 行,而是次级索引仅包括五个行位置,并且仅会读取这五行数据。 ClickHouse 数据跳过索引则完全相反。无论跳过索引的类型如何,`visitor_id` 列中的所有 32768 个值都将被测试。 -因此,试图通过简单地将索引添加到关键列来加速 ClickHouse 查询的自然冲动往往是错误的。在调查其他替代方案后,例如修改主键(请参见 [如何选择主键](../best-practices/sparse-primary-indexes.md))、使用投影或使用物化视图,仅应使用此高级功能。即使数据跳过索引是合适的,通常也需要仔细调优索引和表。 +因此,尝试通过简单地向关键列添加索引来加速 ClickHouse 查询的自然冲动往往是错误的。在调查其他替代方案后,这种高级功能才应该使用,例如修改主键(请参见 [如何选择主键](../best-practices/sparse-primary-indexes.md))、使用投影或使用物化视图。即使数据跳过索引是合适的,仔细调整索引和表通常也是必要的。 -在大多数情况下,有用的跳过索引需要主键与目标非主键列/表达式之间有较强的相关性。如果没有相关性(如上图所示),那么块中数千个值的行符合过滤条件的可能性就很高,因此很少会跳过块。相反,如果主键(如时间)范围与潜在的索引列(如电视观众年龄)中的值紧密相关,那么 minmax 类型的索引很可能是有利的。请注意,在插入数据时,可能通过在排序/ORDER BY 键中包含额外的列,或以将与主键相关的值分组插入的方式来增加这种相关性。例如,某个特定 site_id 的所有事件可以被聚集并一起插入,即使主键是包含来自大量站点的事件的时间戳。这将导致许多颗粒仅包含几个 site_id,因此在按特定 site_id 值搜索时可以跳过许多块。 +在大多数情况下,有用的跳过索引需要主键与目标非主列/表达式之间存在较强的关联。如果没有关联(如上图所示),那么在包含数千个值的块中,至少有一行满足过滤条件的几率很高,因此很少会跳过块。相反,如果主键的值范围(例如一天中的时间)与潜在索引列中的值(例如电视观看者的年龄)强烈相关,则 minmax 类型的索引可能是有益的。请注意,在插入数据时可以通过在排序/ORDER BY 键中包含额外的列,或通过将与主键相关联的值在插入时分组来增加这种关联性。例如,尽管主键是包含来自大量站点的事件的时间戳,但某个特定 site_id 的所有事件可以在同一批次中分组并一起插入。这将导致许多颗粒只包含少量 site_id,因此在按特定 site_id 值搜索时可以跳过许多块。 -跳过索引的另一个良好候选者是对于高基数表达式,其中任何一个值在数据中相对稀疏。例如,一个观察平台跟踪 API 请求中的错误代码。虽然某些错误代码在数据中很少见,但可能在搜索中尤其重要。在 error_code 列上使用集合跳过索引将允许绕过绝大多数不包含错误的块,从而显著改善以错误为重点的查询。 +对于高基数表达式,其中任何一个值在数据中相对稀疏,另一个好的跳过索引候选是。一个例子可能是跟踪 API 请求中的错误代码的可观测性平台。某些错误代码在数据中虽然较少出现,但可能对搜索特别重要。在 `error_code` 列上应用集合跳过索引将允许跳过绝大多数不包含错误的块,从而显著提高重点查询的效率。 -最后,关键的最佳实践是不断测试。与寻找文档的 b-tree 次级索引或倒排索引不同,数据跳过索引的行为并不容易预测。将它们添加到表中会在数据摄取时和任何由于多种原因而未从索引中受益的查询中产生实际的成本。它们应始终在现实世界类型的数据上进行测试,测试还应包括类型、颗粒大小和其他参数的变化。测试通常会揭示出仅通过思考实验而不明显的模式和陷阱。 +最后,关键的最佳实践是测试、测试、再测试。与 b-tree 次级索引或用于搜索文档的倒排索引不同,数据跳过索引的行为并不容易预测。将它们添加到表中会在数据摄取和查询中产生显著成本,出于各种原因并不受益于索引的查询。它们应始终在实际数据类型上进行测试,测试应包括类型、粒度大小和其他参数的变化。测试往往会揭示出仅靠思考实验无法发现的模式和陷阱。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/skipping-indexes.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/skipping-indexes.md.hash index d18effe146d..dcf304a54fa 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/skipping-indexes.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/skipping-indexes.md.hash @@ -1 +1 @@ -3e2cd02bc66b9544 +56175d4fa0614acb diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/sparse-primary-indexes.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/sparse-primary-indexes.md index a729995b7fc..e9e393dbd79 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/sparse-primary-indexes.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/sparse-primary-indexes.md @@ -1,10 +1,11 @@ --- 'sidebar_label': '主键索引' 'sidebar_position': 1 -'description': '在本指南中,我们将深入探讨ClickHouse索引。' -'title': '对ClickHouse中主键索引的实用介绍' +'description': '在本指南中,我们将深入研究 ClickHouse 索引。' +'title': '在 ClickHouse 中主键索引的实用介绍' 'slug': '/guides/best-practices/sparse-primary-indexes' 'show_related_blogs': true +'doc_type': 'guide' --- import sparsePrimaryIndexes01 from '@site/static/images/guides/best-practices/sparse-primary-indexes-01.png'; @@ -34,42 +35,41 @@ import sparsePrimaryIndexes15b from '@site/static/images/guides/best-practices/s import Image from '@theme/IdealImage'; -# ClickHouse 主索引的实用介绍 -## 介绍 {#introduction} +# ClickHouse 主索引的实际介绍 +## 引言 {#introduction} 在本指南中,我们将深入探讨 ClickHouse 的索引。我们将详细说明和讨论: -- [ClickHouse 中的索引与传统关系数据库管理系统的不同之处](#an-index-design-for-massive-data-scales) -- [ClickHouse 是如何构建和使用表的稀疏主索引的](#a-table-with-a-primary-key) -- [在 ClickHouse 中索引的一些最佳实践](#using-multiple-primary-indexes) +- [ClickHouse 的索引与传统关系数据库管理系统的不同之处](#an-index-design-for-massive-data-scales) +- [ClickHouse 如何构建和使用表的稀疏主索引](#a-table-with-a-primary-key) +- [在 ClickHouse 中的索引最佳实践](#using-multiple-primary-indexes) 您可以选择在自己的机器上执行本指南中提供的所有 ClickHouse SQL 语句和查询。 -有关 ClickHouse 的安装和入门说明,请参见 [快速开始](/quick-start.mdx)。 +有关 ClickHouse 的安装及入门说明,请参见 [快速开始](/get-started/quick-start)。 :::note -本指南专注于 ClickHouse 稀疏主索引。 +本指南关注于 ClickHouse 的稀疏主索引。 -有关 ClickHouse 的 [二级数据跳过索引](/engines/table-engines/mergetree-family/mergetree.md/#table_engine-mergetree-data_skipping-indexes),请参见 [教程](/guides/best-practices/skipping-indexes.md)。 +有关 ClickHouse [二级数据跳过索引](/engines/table-engines/mergetree-family/mergetree.md/#table_engine-mergetree-data_skipping-indexes),请参阅 [教程](/guides/best-practices/skipping-indexes.md)。 ::: ### 数据集 {#data-set} -在整个指南中,我们将使用一个匿名的网络流量数据集示例。 +在本指南中,我们将使用一个示例的匿名化网页流量数据集。 -- 我们将使用数据集中 8.87 百万行(事件)的一个子集。 -- 未压缩的数据大小为 8.87 百万事件,约为 700 MB。在 ClickHouse 中存储时,压缩为 200 MB。 -- 在我们的子集中,每一行包含三列,指示在特定时间点击 URL 的互联网用户(`UserID` 列、`URL` 列、`EventTime` 列)。 +- 我们将使用来自示例数据集的 8.87 百万行(事件)的一个子集。 +- 未压缩数据大小为 8.87 百万事件,约 700 MB。存储在 ClickHouse 中时压缩为 200 MB。 +- 在我们的子集中,每行包含三列,指示一个互联网用户(`UserID` 列)在特定时间(`EventTime` 列)点击了一个 URL(`URL` 列)。 -有了这三列,我们已经可以构建一些典型的网络分析查询,例如: +通过这三列,我们已经可以定义一些典型的网页分析查询,例如: - “特定用户点击次数最多的前 10 个 URL 是什么?” - “最常点击特定 URL 的前 10 个用户是谁?” - “用户在特定 URL 上点击的最热门时间(例如一周中的天数)是什么?” - ### 测试机器 {#test-machine} -本文档中给出的所有运行时数字均基于在配备 Apple M1 Pro 芯片和 16GB RAM 的 MacBook Pro 上本地运行 ClickHouse 22.2.1。 +本文档中给出的所有运行时数据基于在配备 Apple M1 Pro 芯片和 16GB RAM 的 MacBook Pro 本地运行的 ClickHouse 22.2.1。 ### 完整表扫描 {#a-full-table-scan} -为了查看在没有主键的情况下查询是如何在我们的数据集中执行的,我们通过执行以下 SQL DDL 语句创建一个表(使用 MergeTree 表引擎): +为了查看没有主键的数据集上如何执行查询,我们通过执行以下 SQL DDL 语句创建一个表(使用 MergeTree 表引擎): ```sql CREATE TABLE hits_NoPrimaryKey @@ -82,8 +82,8 @@ ENGINE = MergeTree PRIMARY KEY tuple(); ``` -接下来,使用以下 SQL 插入语句将部分点击数据集插入该表。 -这使用了 [URL 表函数](/sql-reference/table-functions/url.md),以从 clickhouse.com 上远程托管的完整数据集中加载部分数据: +接下来,使用以下 SQL 插入语句将部分点击数据集插入表中。 +这将使用 [URL 表函数](/sql-reference/table-functions/url.md) 从 clickhouse.com 上加载一个完整数据集的子集: ```sql INSERT INTO hits_NoPrimaryKey SELECT @@ -93,37 +93,36 @@ INSERT INTO hits_NoPrimaryKey SELECT FROM url('https://datasets.clickhouse.com/hits/tsv/hits_v1.tsv.xz', 'TSV', 'WatchID UInt64, JavaEnable UInt8, Title String, GoodEvent Int16, EventTime DateTime, EventDate Date, CounterID UInt32, ClientIP UInt32, ClientIP6 FixedString(16), RegionID UInt32, UserID UInt64, CounterClass Int8, OS UInt8, UserAgent UInt8, URL String, Referer String, URLDomain String, RefererDomain String, Refresh UInt8, IsRobot UInt8, RefererCategories Array(UInt16), URLCategories Array(UInt16), URLRegions Array(UInt32), RefererRegions Array(UInt32), ResolutionWidth UInt16, ResolutionHeight UInt16, ResolutionDepth UInt8, FlashMajor UInt8, FlashMinor UInt8, FlashMinor2 String, NetMajor UInt8, NetMinor UInt8, UserAgentMajor UInt16, UserAgentMinor FixedString(2), CookieEnable UInt8, JavascriptEnable UInt8, IsMobile UInt8, MobilePhone UInt8, MobilePhoneModel String, Params String, IPNetworkID UInt32, TraficSourceID Int8, SearchEngineID UInt16, SearchPhrase String, AdvEngineID UInt8, IsArtifical UInt8, WindowClientWidth UInt16, WindowClientHeight UInt16, ClientTimeZone Int16, ClientEventTime DateTime, SilverlightVersion1 UInt8, SilverlightVersion2 UInt8, SilverlightVersion3 UInt32, SilverlightVersion4 UInt16, PageCharset String, CodeVersion UInt32, IsLink UInt8, IsDownload UInt8, IsNotBounce UInt8, FUniqID UInt64, HID UInt32, IsOldCounter UInt8, IsEvent UInt8, IsParameter UInt8, DontCountHits UInt8, WithHash UInt8, HitColor FixedString(1), UTCEventTime DateTime, Age UInt8, Sex UInt8, Income UInt8, Interests UInt16, Robotness UInt8, GeneralInterests Array(UInt16), RemoteIP UInt32, RemoteIP6 FixedString(16), WindowName Int32, OpenerName Int32, HistoryLength Int16, BrowserLanguage FixedString(2), BrowserCountry FixedString(2), SocialNetwork String, SocialAction String, HTTPError UInt16, SendTiming Int32, DNSTiming Int32, ConnectTiming Int32, ResponseStartTiming Int32, ResponseEndTiming Int32, FetchTiming Int32, RedirectTiming Int32, DOMInteractiveTiming Int32, DOMContentLoadedTiming Int32, DOMCompleteTiming Int32, LoadEventStartTiming Int32, LoadEventEndTiming Int32, NSToDOMContentLoadedTiming Int32, FirstPaintTiming Int32, RedirectCount Int8, SocialSourceNetworkID UInt8, SocialSourcePage String, ParamPrice Int64, ParamOrderID String, ParamCurrency FixedString(3), ParamCurrencyID UInt16, GoalsReached Array(UInt32), OpenstatServiceName String, OpenstatCampaignID String, OpenstatAdID String, OpenstatSourceID String, UTMSource String, UTMMedium String, UTMCampaign String, UTMContent String, UTMTerm String, FromTag String, HasGCLID UInt8, RefererHash UInt64, URLHash UInt64, CLID UInt32, YCLID UInt64, ShareService String, ShareURL String, ShareTitle String, ParsedParams Nested(Key1 String, Key2 String, Key3 String, Key4 String, Key5 String, ValueDouble Float64), IslandID FixedString(16), RequestNum UInt32, RequestTry UInt8') WHERE URL != ''; ``` -响应为: +返回的结果是: ```response Ok. 0 rows in set. Elapsed: 145.993 sec. Processed 8.87 million rows, 18.40 GB (60.78 thousand rows/s., 126.06 MB/s.) ``` -ClickHouse 客户端的结果输出显示,上述语句将 8.87 百万行插入了该表。 +ClickHouse 客户端的结果输出显示,上述语句将 8.87 百万行插入到表中。 -最后,为了简化本指南后面的讨论并使图表和结果可重复,我们使用 FINAL 关键字对表进行 [优化](/sql-reference/statements/optimize.md): +最后,为了简化本指南后面的讨论并使图表和结果可重复,我们使用 FINAL 关键字来 [优化](/sql-reference/statements/optimize.md) 表: ```sql OPTIMIZE TABLE hits_NoPrimaryKey FINAL; ``` :::note -通常在将数据加载到表后并不要求或推荐立即优化表。 -为什么此示例需要这样做将变得显而易见。 +通常,在将数据加载到表中后,立即优化表并不是必需的,也不建议这么做。为什么在此示例中需要这样做将变得显而易见。 ::: -现在,我们执行第一个网络分析查询。以下查询计算用户 ID 为 749927693 的互联网用户点击次数最多的前 10 个 URL: +现在我们执行第一个网页分析查询。以下是计算用户 ID 为 749927693 的互联网用户点击次数最多的前 10 个 URL: ```sql -SELECT URL, count(URL) as Count +SELECT URL, count(URL) AS Count FROM hits_NoPrimaryKey WHERE UserID = 749927693 GROUP BY URL ORDER BY Count DESC LIMIT 10; ``` -响应为: +返回结果是: ```response ┌─URL────────────────────────────┬─Count─┐ │ http://auto.ru/chatay-barana.. │ 170 │ @@ -145,21 +144,20 @@ Processed 8.87 million rows, 70.45 MB (398.53 million rows/s., 3.17 GB/s.) ``` -ClickHouse 客户端的结果输出表明,ClickHouse 执行了完整的表扫描!我们表中的 8.87 百万行的每一行都被流入 ClickHouse。这不具有可扩展性。 - -为了使这一过程(更)高效且(更)快速,我们需要使用具有适当主键的表。这将使 ClickHouse 基于主键列自动创建稀疏主索引,从而显著加快我们示例查询的执行速度。 +ClickHouse 客户端的结果输出表明,ClickHouse 执行了完整表扫描!我们表中 8.87 百万行中的每一行都被流入 ClickHouse。这无法扩展。 +为了使这(大大)更高效且(更)快速,我们需要使用一个具有合适主键的表。这将允许 ClickHouse 自动(基于主键的列)创建一个稀疏主索引,然后可以用来显著加快我们示例查询的执行。 ## ClickHouse 索引设计 {#clickhouse-index-design} -### 大规模数据的索引设计 {#an-index-design-for-massive-data-scales} +### 大规模数据规模的索引设计 {#an-index-design-for-massive-data-scales} -在传统的关系数据库管理系统中,主索引将为每一行表包含一个条目。这将导致主索引为我们的数据集包含 8.87 百万条条目。这样的索引允许快速定位特定行,从而为查找查询和点更新提供高效性。在 `B(+)-Tree` 数据结构中搜索一个条目的平均时间复杂度为 `O(log n)`;更准确地说,`log_b n = log_2 n / log_2 b`,其中 `b` 是 `B(+)-Tree` 的分支因子,`n` 是索引行的数量。因为 `b` 通常在几百到几千之间,`B(+)-Trees` 是非常浅的结构,定位记录所需的磁盘寻址次数很少。对于 8.87 百万行和分支因子为 1000,平均需要 2.3 次磁盘寻址。这个能力是有代价的:额外的磁盘和内存开销、更高的插入成本以及在向表中添加新行和索引条目时,有时需要重新平衡 B-Tree。 +在传统的关系数据库管理系统中,主索引将包含每个表行的一个条目。这将导致主索引对于我们的数据集包含 8.87 百万条条目。这样的索引可以快速定位特定行,从而在查找查询和点更新上实现高效率。在 `B(+)-Tree` 数据结构中搜索一个条目的平均时间复杂度为 `O(log n)`;更准确地说,`log_b n = log_2 n / log_2 b`,其中 `b` 是 `B(+)-Tree` 的分支因子,`n` 是已索引的行数。由于 `b` 通常在几百到几千之间,`B(+)-Trees` 是非常浅的结构,需要的磁盘寻址次数较少。对于 8.87 百万行和分支因子为 1000 的情况,平均需要 2.3 次磁盘寻址。这个能力是有代价的:额外的磁盘和内存开销,添加新行和索引条目时更高的插入成本,以及有时需要重新平衡 B 树。 -考虑到与 B-Tree 索引相关的挑战,ClickHouse 中的表引擎采用了不同的方法。ClickHouse 的 [MergeTree 引擎家族](/engines/table-engines/mergetree-family/index.md) 被设计和优化以处理大规模数据量。这些表被设计为每秒接收数百万行的插入,并存储巨大的数据(数百 TB)。数据以 [逐部分](#mergetree-data-storage) 的方式快速写入表中,并在后台应用合并部分的规则。在 ClickHouse 中,每个部分都有自己的主索引。当部分合并时,合并部分的主索引也会合并。在 ClickHouse 被设计为支持的大规模环境中,磁盘和内存效率至关重要。因此,主索引为每个部分仅具有一个索引条目(称为“标记”),每组行(称为“粒度”)一个 —— 这种技术称为 **稀疏索引**。 +考虑到 B-Tree 索引相关的挑战,ClickHouse 中的表引擎采用了不同的方法。ClickHouse [MergeTree 引擎系列](/engines/table-engines/mergetree-family/index.md) 被设计和优化以处理大量数据。这些表旨在每秒接收数百万行的插入,并存储非常大的(数百 PB)数据量。数据以 [分片方式](/engines/table-engines/mergetree-family/mergetree.md/#mergetree-data-storage) 快速写入,以便在后台应用合并分片的规则。在 ClickHouse 中,每个分片都有自己的主索引。当合并分片时,合并分片的主索引也会被合并。在 ClickHouse 设计的大规模系统中,确保磁盘和内存的高效使用至关重要。因此,主索引对于每个分片只有一个索引条目(称为“标记”),每组行(称为“颗粒”)对应一个条目 - 这种技术被称为 **稀疏索引**。 -稀疏索引是可能的,因为 ClickHouse 按照主键列的顺序在磁盘上存储一部分的行。与直接定位单行(如基于 B-Tree 的索引)不同,稀疏主索引允许它快速通过对索引条目的二分搜索识别可能与查询匹配的行组。定位到的潜在匹配的行组(粒度)然后以并行的方式流入 ClickHouse 引擎,以找到匹配项。这种索引设计使主索引体积小(它可以并且必须完全装入主内存),同时显著加快查询执行时间:尤其是对数据分析用例中典型的范围查询。 +稀疏索引之所以可行,是因为 ClickHouse 在磁盘上按照主键列的顺序存储行。稀疏主索引允许快速(通过索引条目进行二分搜索)识别可能匹配查询的行组,而不是直接定位单个行。然后,找到的可能匹配的行组(颗粒)被并行流入 ClickHouse 引擎,以找到匹配的行。此索引设计允许主索引小(它可以且必须完全 fitting into the main memory),同时仍显著加快查询执行时间:尤其是对于数据分析用例中的典型范围查询。 -以下详细说明 ClickHouse 如何构建和使用其稀疏主索引。在文章后面,我们将讨论选择、删除和排序构建索引所用表列(主键列)的最佳实践。 -### 具有主键的表 {#a-table-with-a-primary-key} +以下详细说明了 ClickHouse 如何构建和使用其稀疏主索引。稍后在文章中,我们将讨论一些最佳实践,以选择、删除和排序用于构建索引(主键列)的表列。 +### 带有主键的表 {#a-table-with-a-primary-key} 创建一个具有复合主键的表,主键列为 UserID 和 URL: @@ -184,23 +182,23 @@ SETTINGS index_granularity = 8192, index_granularity_bytes = 0, compress_primary

-为了简化本指南后续的讨论,以及使图表和结果可重复,DDL 语句: +为了简化本指南后面讨论,并使图表和结果可重复,DDL 语句:

-DDL 语句中的主键导致基于两个指定的关键列创建主索引。 +上述 DDL 语句中的主键导致根据指定的两个键列创建主索引。
接下来插入数据: @@ -230,7 +228,7 @@ INSERT INTO hits_UserID_URL SELECT FROM url('https://datasets.clickhouse.com/hits/tsv/hits_v1.tsv.xz', 'TSV', 'WatchID UInt64, JavaEnable UInt8, Title String, GoodEvent Int16, EventTime DateTime, EventDate Date, CounterID UInt32, ClientIP UInt32, ClientIP6 FixedString(16), RegionID UInt32, UserID UInt64, CounterClass Int8, OS UInt8, UserAgent UInt8, URL String, Referer String, URLDomain String, RefererDomain String, Refresh UInt8, IsRobot UInt8, RefererCategories Array(UInt16), URLCategories Array(UInt16), URLRegions Array(UInt32), RefererRegions Array(UInt32), ResolutionWidth UInt16, ResolutionHeight UInt16, ResolutionDepth UInt8, FlashMajor UInt8, FlashMinor UInt8, FlashMinor2 String, NetMajor UInt8, NetMinor UInt8, UserAgentMajor UInt16, UserAgentMinor FixedString(2), CookieEnable UInt8, JavascriptEnable UInt8, IsMobile UInt8, MobilePhone UInt8, MobilePhoneModel String, Params String, IPNetworkID UInt32, TraficSourceID Int8, SearchEngineID UInt16, SearchPhrase String, AdvEngineID UInt8, IsArtifical UInt8, WindowClientWidth UInt16, WindowClientHeight UInt16, ClientTimeZone Int16, ClientEventTime DateTime, SilverlightVersion1 UInt8, SilverlightVersion2 UInt8, SilverlightVersion3 UInt32, SilverlightVersion4 UInt16, PageCharset String, CodeVersion UInt32, IsLink UInt8, IsDownload UInt8, IsNotBounce UInt8, FUniqID UInt64, HID UInt32, IsOldCounter UInt8, IsEvent UInt8, IsParameter UInt8, DontCountHits UInt8, WithHash UInt8, HitColor FixedString(1), UTCEventTime DateTime, Age UInt8, Sex UInt8, Income UInt8, Interests UInt16, Robotness UInt8, GeneralInterests Array(UInt16), RemoteIP UInt32, RemoteIP6 FixedString(16), WindowName Int32, OpenerName Int32, HistoryLength Int16, BrowserLanguage FixedString(2), BrowserCountry FixedString(2), SocialNetwork String, SocialAction String, HTTPError UInt16, SendTiming Int32, DNSTiming Int32, ConnectTiming Int32, ResponseStartTiming Int32, ResponseEndTiming Int32, FetchTiming Int32, RedirectTiming Int32, DOMInteractiveTiming Int32, DOMContentLoadedTiming Int32, DOMCompleteTiming Int32, LoadEventStartTiming Int32, LoadEventEndTiming Int32, NSToDOMContentLoadedTiming Int32, FirstPaintTiming Int32, RedirectCount Int8, SocialSourceNetworkID UInt8, SocialSourcePage String, ParamPrice Int64, ParamOrderID String, ParamCurrency FixedString(3), ParamCurrencyID UInt16, GoalsReached Array(UInt32), OpenstatServiceName String, OpenstatCampaignID String, OpenstatAdID String, OpenstatSourceID String, UTMSource String, UTMMedium String, UTMCampaign String, UTMContent String, UTMTerm String, FromTag String, HasGCLID UInt8, RefererHash UInt64, URLHash UInt64, CLID UInt32, YCLID UInt64, ShareService String, ShareURL String, ShareTitle String, ParsedParams Nested(Key1 String, Key2 String, Key3 String, Key4 String, Key5 String, ValueDouble Float64), IslandID FixedString(16), RequestNum UInt32, RequestTry UInt8') WHERE URL != ''; ``` -响应如下: +返回的结果如下: ```response 0 rows in set. Elapsed: 149.432 sec. Processed 8.87 million rows, 18.40 GB (59.38 thousand rows/s., 123.16 MB/s.) ``` @@ -260,7 +258,7 @@ WHERE (table = 'hits_UserID_URL') AND (active = 1) FORMAT Vertical; ``` -响应为: +返回的结果为: ```response part_type: Wide @@ -272,108 +270,105 @@ primary_key_bytes_in_memory: 96.93 KiB marks: 1083 bytes_on_disk: 207.07 MiB - 1 rows in set. Elapsed: 0.003 sec. ``` -ClickHouse 客户端输出显示: +ClickHouse 客户端的输出显示: -- 表的数据以 [宽格式](/engines/table-engines/mergetree-family/mergetree.md/#mergetree-data-storage) 存储在磁盘上的特定目录中,意味着每一列在该目录中将有一个数据文件(和一个标记文件)。 -- 表具有 8.87 百万行。 +- 表的数据以 [宽格式](/engines/table-engines/mergetree-family/mergetree.md/#mergetree-data-storage) 存储在磁盘上的特定目录中,这意味着该目录中每个表列将有一个数据文件(和一个标记文件)。 +- 表有 8.87 百万行。 - 所有行的未压缩数据总大小为 733.28 MB。 -- 所有行在磁盘上的压缩大小为 206.94 MB。 -- 表具有 1083 个条目的主索引(称为“标记”),索引的大小为 96.93 KB。 -- 总体而言,表的数据和标记文件以及主索引文件在磁盘上一起占用 207.07 MB。 - -### 数据按主键列的顺序存储在磁盘上 {#data-is-stored-on-disk-ordered-by-primary-key-columns} +- 所有行在磁盘上的压缩大小总共为 206.94 MB。 +- 表具有 1083 个条目(称为“标记”)的主索引,索引大小为 96.93 KB。 +- 综合来看,表的数据、标记文件和主索引文件在磁盘上总共占用 207.07 MB。 +### 数据按照主键列的顺序存储在磁盘上 {#data-is-stored-on-disk-ordered-by-primary-key-columns} -我们上面创建的表具有 +我们上面创建的表有 - 复合 [主键](/engines/table-engines/mergetree-family/mergetree.md/#primary-keys-and-indexes-in-queries) `(UserID, URL)` 和 - 复合 [排序键](/engines/table-engines/mergetree-family/mergetree.md/#choosing-a-primary-key-that-differs-from-the-sorting-key) `(UserID, URL, EventTime)`。 :::note -- 如果我们只指定排序键,则主键将隐式定义为等于排序键。 +- 如果我们只指定了排序键,则主键将隐式定义为等于排序键。 -- 为了提高内存利用率,我们显式指定了仅包含我们查询过滤的列的主键。基于主键的主索引完全加载到主内存中。 +- 为了实现内存效率,我们显式指定了仅包含我们查询过滤的列的主键。基于主键的主索引完全加载到主内存中。 -- 为了在指南的图表中保持一致并最大化压缩比率,我们定义了一个单独的排序键,其中包含所有表的列(如果在同一列中相似的数据彼此靠近,例如通过排序.then 这些数据将被更好地压缩)。 +- 为了在指南的图表中保持一致性,并最大限度提高压缩比,我们定义了一个单独的排序键,其中包含所有表列(如果在一个列中相似数据放在相互靠近的位置,例如通过排序,那么该数据会更好地压缩)。 -- 如果同时指定主键和排序键,则主键需要是排序键的前缀。 +- 如果同时指定了主键,则主键需要是排序键的前缀。 ::: -插入的行在磁盘上按照主键列(和排序键中的额外 `EventTime` 列)以字典序(升序)存储。 +插入的行按主键列(和附加的 `EventTime` 列)在磁盘上的字典序(升序)顺序存储。 :::note -ClickHouse 允许插入具有相同主键列值的多行。在这种情况下(请参见下图中的第 1 行和第 2 行),最终顺序由指定的排序键决定,因此 `EventTime` 列的值。 +ClickHouse 允许插入具有相同主键列值的多行。在这种情况下(参见下图的第 1 行和第 2 行),最终顺序由指定的排序键确定,因此 `EventTime` 列的值也会影响顺序。 ::: -ClickHouse 是一个 列式数据库管理系统。如下图所示 -- 对于磁盘上的表示,每个表列有一个单独的数据文件(*.bin),该列的所有值都是以 压缩 格式存储的,并且 -- 8.87 百万行在磁盘上以主键列(和额外排序键列)的字典顺序存储,即在这种情况下 - - 首先按 `UserID`, +ClickHouse 是一个 列式数据库管理系统。如下面的图所示 +- 对于磁盘上的表示,每个表列都有一个单独的数据文件 (*.bin),该列的所有值都存储为压缩的格式,并且 +- 8.87 百万行在磁盘上按照主键列(以及附加排序键列)的字典顺序存储,即在这种情况下 + - 首先按 `UserID` 排序, - 然后按 `URL`, - 最后按 `EventTime`: Sparse Primary Indices 01 -`UserID.bin`、`URL.bin` 和 `EventTime.bin` 是存储 `UserID`、`URL` 和 `EventTime` 列值的数据文件。 +`UserID.bin`、`URL.bin` 和 `EventTime.bin` 是在磁盘上存储 `UserID`、`URL` 和 `EventTime` 列值的数据文件。 :::note - 由于主键定义了磁盘上行的字典序,因此一个表只能有一个主键。 -- 为了与 ClickHouse 内部的行编号方案保持一致,我们从 0 开始编号行,该方案也用于日志消息。 +- 我们将行的编号从 0 开始,以便与 ClickHouse 内部的行编号方案保持一致,该方案也用于日志消息。 ::: -### 数据被组织为粒度以进行并行数据处理 {#data-is-organized-into-granules-for-parallel-data-processing} +### 数据被组织成颗粒以进行并行数据处理 {#data-is-organized-into-granules-for-parallel-data-processing} -为了处理数据,表的列值在逻辑上被划分为粒度。 -粒度是流入 ClickHouse 进行数据处理的最小不可分割数据集。 -这意味着 ClickHouse 始终以流式方式(并行)读取一整组(粒度)行,而不是读取单个行。 +出于数据处理的目的,表的列值在逻辑上被划分为颗粒。 +颗粒是流入 ClickHouse 进行数据处理的最小不可分割数据集。 +这意味着 ClickHouse 总是以流式方式并行读取整组(颗粒)的行,而不是逐行读取。 :::note -列值不会物理存储在粒度内:粒度只是用于查询处理的列值的逻辑组织。 +列值并不是物理地存储在颗粒内:颗粒只是查询处理的列值的逻辑组织。 ::: -以下图表显示了我们表 8.87 百万行的(列值的)组织方式 -根据表的 DDL 语句中包含的 `index_granularity` 设置(设置为默认值 8192),它被组织成 1083 个粒度。 +以下图表显示了我们表的 8.87 百万行(列值)是如何组织成 1083 个颗粒,结果是因为表的 DDL 语句包含设置 `index_granularity`(设置为其默认值 8192)。 Sparse Primary Indices 02 -根据磁盘上的物理顺序,前 8192 行(它们的列值)逻辑上属于粒度 0,然后接下来的 8192 行(它们的列值)属于粒度 1,依此类推。 +首先(基于在磁盘上的物理顺序)8192 行(其列值)逻辑上属于颗粒 0,然后下一个 8192 行(其列值)属于颗粒 1,依此类推。 :::note -- 最后一个粒度(粒度 1082)“包含”少于 8192 行。 +- 最后一个颗粒(颗粒 1082)“包含”少于 8192 行。 -- 我们在本指南开头的“DDL 语句详情”中提到,我们禁用了 [自适应索引粒度](/whats-new/changelog/2019.md/#experimental-features-1)(为了简化本指南中的讨论以及使图表和结果可重复)。 +- 我们在本指南的开头提到,在“DDL 语句详情”中,我们禁用了 [自适应索引粒度](/whats-new/changelog/2019.md/#experimental-features-1)(目的是简化本指南中的讨论并使图表和结果可重复)。 -因此我们示例表的所有粒度(除了最后一个)都具有相同的大小。 + 因此,示例表的所有颗粒(最后一个颗粒除外)都具有相同的大小。 -- 对于具有自适应索引粒度的表(索引粒度默认是自适应的),某些粒度的大小可能少于 8192 行,具体取决于行数据的大小。 +- 对于具有自适应索引粒度的表(根据 [默认值](/operations/settings/merge-tree-settings#index_granularity_bytes) 自适应索引粒度,某些颗粒的大小可能小于 8192 行,这取决于行数据大小)。 -- 我们用橙色标记了主键列中的一些列值(`UserID`、`URL`)。 -这些橙色标记的列值是每个粒度的每行的主键列值。 -正如我们下面看到的,这些橙色标记的列值将是表主索引中的条目。 +- 我们用橙色标记了来自主键列(`UserID`、`URL`)的一些列值。 + 这些橙色标记的列值是每个颗粒的每一行的主键列值。 + 正如我们将在后面看到的,这些橙色标记的列值将是表主索引的条目。 -- 我们从 0 开始编号粒度,以便与 ClickHouse 的内部编号方案保持一致,该方案也用于日志消息。 +- 我们将颗粒编号从 0 开始,以便与 ClickHouse 内部的编号方案保持一致,该方案也用于日志消息。 ::: -### 主索引每个粒度有一个条目 {#the-primary-index-has-one-entry-per-granule} +### 主索引每个颗粒有一个条目 {#the-primary-index-has-one-entry-per-granule} -主索引是基于上面图中显示的粒度创建的。该索引是一个未压缩的平面数组文件(primary.idx),包含从 0 开始的所谓数字索引标记。 +主索引基于上图所示的颗粒创建。该索引是一个未压缩的平面数组文件(primary.idx),包含所谓的从 0 开始的数值索引标记。 -下面的图表显示该索引存储每个粒度的第一行的主键列值(在上面的图中标记为橙色)。 -换句话说:主索引存储表中每第 8192 行的主键列值(基于主键列定义的物理行顺序)。 -例如: -- 第一个索引条目(下图中的 'mark 0')存储上面图中粒度 0 第一行的键列值, -- 第二个索引条目(下图中的 'mark 1')存储上面图中粒度 1 第一行的键列值,依此类推。 +下图表明,索引存储了每个颗粒的第一行的主键列值(上图中标记为橙色的值)。 +换句话说:主索引存储来自表中每隔 8192 行的主键列值(根据主键列定义的物理行顺序)。 +例如 +- 第一个索引条目(下图中的“标记 0”)存储来自上图中颗粒 0 的第一行的键列值, +- 第二个索引条目(下图中的“标记 1”)存储来自上图中颗粒 1 的第一行的键列值,依此类推。 Sparse Primary Indices 03a -总的来说,该索引对我们的 8.87 百万行和 1083 个粒度的表有 1083 个条目: +对于我们有 8.87 百万行和 1083 个颗粒的表,索引总共有 1083 个条目: Sparse Primary Indices 03b :::note -- 对于具有 [自适应索引粒度](/whats-new/changelog/2019.md/#experimental-features-1) 的表,主索引中还会存储一个“最后”附加标记,记录最后一行的主键列的值,但由于我们禁用了自适应索引粒度(为了简化本指南中的讨论以及使图表和结果可重复),因此我们示例表的索引不包括这个最后标记。 +- 对于具有 [自适应索引粒度](/whats-new/changelog/2019.md/#experimental-features-1) 的表,主索引中还存储一个“最终”额外的标记,记录最后一行的主键列值,但因为我们禁用了自适应索引粒度(以简化本指南的讨论并使图表和结果可重复),因此我们的示例表的索引不包括此最终标记。 -- 主索引文件完全加载到主内存中。如果文件大于可用的空闲内存空,ClickHouse 会抛出错误。 +- 主索引文件完全加载到主内存中。如果文件大于可用的空闲内存空间,ClickHouse 将引发错误。 :::
@@ -382,9 +377,9 @@ ClickHouse 是一个 file 表函数 检查示例表的主索引的内容。 +在自管理的 ClickHouse 集群上,我们可以使用 file 表函数 检查示例表的主索引内容。 -为此,我们首先需要将主索引文件复制到运行中的集群节点的 user_files_path: +为此,我们首先需要将主索引文件复制到正在运行的集群中某个节点的 user_files_path
  • 步骤 1:获取包含主索引文件的部分路径
  • ` @@ -394,12 +389,12 @@ SELECT path FROM system.parts WHERE table = 'hits_UserID_URL' AND active = 1 返回 `/Users/tomschreiber/Clickhouse/store/85f/85f4ee68-6e28-4f08-98b1-7d8affa1d88c/all_1_9_4` 在测试机器上。
  • 步骤 2:获取 user_files_path
  • -在 Linux 上,默认 user_files_path 是 +Linux 上默认的 user_files_path 是 `/var/lib/clickhouse/user_files/` -在 Linux 上,您可以检查其是否已更改:`$ grep user_files_path /etc/clickhouse-server/config.xml` +在 Linux 上,您可以检查它是否被更改:`$ grep user_files_path /etc/clickhouse-server/config.xml` -在测试机器上,该路径为 `/Users/tomschreiber/Clickhouse/user_files/` +在测试机器上,路径是 `/Users/tomschreiber/Clickhouse/user_files/`
  • 步骤 3:将主索引文件复制到 user_files_path
  • @@ -414,21 +409,21 @@ SELECT path FROM system.parts WHERE table = 'hits_UserID_URL' AND active = 1 ` SELECT count( )
    FROM file('primary-hits_UserID_URL.idx', 'RowBinary', 'UserID UInt32, URL String'); ` -返回 `1083` +结果为 `1083`
  • 获取前两个索引标记
  • ` SELECT UserID, URL
    FROM file('primary-hits_UserID_URL.idx', 'RowBinary', 'UserID UInt32, URL String')
    LIMIT 0, 2; ` -返回 +结果为 ` 240923, http://showtopics.html%3...
    4073710, http://mk.ru&pos=3_0 ` -
  • 获取最后一个索引标记
  • +
  • 获取最后的索引标记
  • ` SELECT UserID, URL FROM file('primary-hits_UserID_URL.idx', 'RowBinary', 'UserID UInt32, URL String')
    LIMIT 1082, 1; ` @@ -438,30 +433,29 @@ SELECT UserID, URL FROM file('primary-hits_UserID_URL.idx', 'RowBinary', 'UserID `

-这与我们的示例表的主索引内容的图表完全匹配: +这与我们示例表的主索引内容图完全匹配:

-主键条目被称为索引标记,因为每个索引条目标记特定数据范围的开始。特别对于示例表: +主键条目被称为索引标记,因为每个索引条目标记了特定数据范围的起始位置。具体来说,对于示例表: - UserID 索引标记: - 存储在主索引中的 `UserID` 值按升序排列。
- 因此,上图中的 'mark 1' 表示粒度 1 中所有表行的 `UserID` 值以及所有后续粒度的值保证大于或等于 4.073.710。 + 存储在主索引中的 `UserID` 值按升序排序。
+ 图中的“标记 1”因此表明颗粒 1 及所有后续颗粒中的所有表行的 `UserID` 值都保证大于或等于 4,073,710。 - [稍后我们将看到](#the-primary-index-is-used-for-selecting-granules),这个全局顺序使 ClickHouse 能够在查询过滤第一个主键列时,对索引标记使用 二分查找算法。 + [正如我们稍后将看到的](#the-primary-index-is-used-for-selecting-granules),这种全局顺序使 ClickHouse 能够 使用二分搜索算法 在查询过滤主键的第一列时,对第一列的索引标记运行搜索。 - URL 索引标记: - 主键列 `UserID` 和 `URL` 的类似基数意味着所有关键列中第一个列之后的索引标记通常仅指示数据范围,只要前一个键列值在当前粒度的所有行中保持不变。
-由于图中的标记 0 和标记 1 的 UserID 值不同,ClickHouse 不能假设粒度 0 中所有表行的所有 URL 值都大于或等于 `'http://showtopics.html%3...'`。然而,如果上图中标记 0 和标记 1 的 UserID 值相同(意味着在粒度 0 中所有表行的 UserID 值保持不变),ClickHouse 可以假设粒度 0 中所有表行的所有 URL 值都大于或等于 `'http://showtopics.html%3...'`。 + 主键列 `UserID` 和 `URL` 的相似基数意味着所有后续主键列索引标记通常只指示数据范围,只要前驱键列值在至少当前颗粒内的所有表行均保持一致。
例如,因为图中标记 0 和标记 1 的 UserID 值不同,所以 ClickHouse 无法假定颗粒 0 中所有表行的 URL 值都大于或等于 `'http://showtopics.html%3...'`。然而,如果图中标记 0 和标记 1 的 UserID 值相同(意味着 UserID 值在颗粒 0 的所有表行中保持一致),ClickHouse 可以假定颗粒 0 中所有表行的 URL 值都大于或等于 `'http://showtopics.html%3...'`。 -我们将稍后详细讨论这对查询执行性能的影响。 -### 主索引用于选择粒度 {#the-primary-index-is-used-for-selecting-granules} + 我们将稍后详细讨论此对查询执行性能的影响。 +### 主索引用于选择颗粒 {#the-primary-index-is-used-for-selecting-granules} -我们现在可以执行查询,并得到主索引的支持。 +现在我们可以在主索引的支持下执行查询。 -以下查询计算用户 ID 为 749927693 的用户点击次数最多的前 10 个 URL。 +以下是计算 UserID 为 749927693 的用户点击次数最多的前 10 个 URL。 ```sql SELECT URL, count(URL) AS Count @@ -472,7 +466,7 @@ ORDER BY Count DESC LIMIT 10; ``` -响应为: +返回结果为: ```response ┌─URL────────────────────────────┬─Count─┐ @@ -495,9 +489,9 @@ Processed 8.19 thousand rows, 740.18 KB (1.53 million rows/s., 138.59 MB/s.) ``` -ClickHouse 客户端的输出现在显示,取而代之的是执行完整的表扫描,只有 8.19 千行被流入 ClickHouse。 +ClickHouse 客户端的输出现在显示,与执行完整表扫描不同,仅有 8,190 行流入了 ClickHouse。 -如果 启用跟踪日志记录,然后 ClickHouse 服务器日志文件显示 ClickHouse 正在对 1083 个 UserID 索引标记执行 二分查找,以识别可能包含 UserID 列值为 `749927693` 的行的粒度。这需要 19 步,平均时间复杂度为 `O(log2 n)`: +如果启用了 跟踪日志记录,则 ClickHouse 服务器日志文件显示 ClickHouse 正在对 1083 个 UserID 索引标记进行 二分搜索,以识别可能包含 `749927693` 的 UserID 列值的颗粒。这需要 19 步,平均时间复杂度为 `O(log2 n)`: ```response ...Executor): Key condition: (column 0 in [749927693, 749927693]) @@ -513,7 +507,7 @@ ClickHouse 客户端的输出现在显示,取而代之的是执行完整的表 ...Reading ...approx. 8192 rows starting from 1441792 ``` -我们可以在上面的跟踪日志中看到,找到 1083 个标记中的一个满足查询。 +我们可以在上述跟踪日志中看到,1083 个现有标记中有一个标记满足了查询。
@@ -521,11 +515,11 @@ ClickHouse 客户端的输出现在显示,取而代之的是执行完整的表

-标记 176 被识别(‘找到左边界标记’是包含的,’找到右边界标记’是不包括的),因此粒度 176 中的所有 8192 行(从行 1.441.792 开始 - 我们将在本指南的后面部分看到)然后流入 ClickHouse,以寻找实际具有 UserID 列值为 `749927693` 的行。 +标记 176 被识别(“找到左边界标记”是包含的,“找到右边界标记”是排除的),因此颗粒 176 中的所有 8192 行(从第 1,441,792 行开始 - 我们将在后面的指南中看到)将被流入 ClickHouse,以查找实际满足 `749927693` 的 UserID 列值的行。

-我们还可以通过在示例查询中使用 EXPLAIN 子句 进行重现: +我们也可以通过在我们的示例查询中使用 EXPLAIN 子句 来重复这一点: ```sql EXPLAIN indexes = 1 SELECT URL, count(URL) AS Count @@ -536,7 +530,7 @@ ORDER BY Count DESC LIMIT 10; ``` -响应如下: +返回结果如下: ```response ┌─explain───────────────────────────────────────────────────────────────────────────────┐ @@ -562,132 +556,131 @@ LIMIT 10; 16 rows in set. Elapsed: 0.003 sec. ``` -客户端输出显示,1083 个粒度中有一个被选择为可能包含 UserID 列值为 749927693 的行。 +客户端输出显示,1083 个颗粒中有一个颗粒被选为可能包含 UserID 列值为 749927693 的行。 :::note 结论 -当查询过滤的列是复合键的一部分且是第一个键列时,ClickHouse 会对键列的索引标记运行二分查找算法。 +当查询在包含复合键的列(且为首个键列)上进行过滤时,ClickHouse 会对键列索引标记运行二分搜索算法。 :::
-正如上面讨论的那样,ClickHouse 使用其稀疏主索引快速(通过二分查找)选择可能包含匹配查询的行的粒度。 +正如上文所述,ClickHouse 使用其稀疏主索引快速(通过二分搜索)选择可能包含与查询匹配的行的颗粒。 -这是 ClickHouse 查询执行的 **第一阶段(粒度选择)**。 +这是 ClickHouse 查询执行的 **第一阶段(颗粒选择)**。 -在 **第二阶段(数据读取)** 中,ClickHouse 定位所选的粒度,以流入 ClickHouse 引擎所有这些行,从而找到实际匹配查询的行。 +在 **第二阶段(数据读取)**,ClickHouse 正在定位所选择的颗粒,以便将其所有行流入 ClickHouse 引擎,以找到实际满足查询的行。 -我们将在以下部分详细讨论这一第二阶段。 -### 标记文件用于定位 granules {#mark-files-are-used-for-locating-granules} +我们将在下面的部分中更详细地讨论第二阶段。 +### 标记文件用于定位分片 {#mark-files-are-used-for-locating-granules} -下图说明了我们表的主索引文件的一部分。 +下图展示了我们表的主索引文件的一部分。 Sparse Primary Indices 04 -如上所述,通过对索引的 1083 个 UserID 标记进行二分查找,识别出标记 176。因此,其对应的 granule 176 可能包含 UserID 列值为 749.927.693 的行。 +如前所述,通过对索引的1083个UserID标记进行二分查找,标记176被识别出来。因此,其对应的分片176可能包含UserID列值为749.927.693的行。
- Granule 选择详情 + 分片选择详情

-上图显示,标记 176 是第一个索引条目,其中关联的 granule 176 的最小 UserID 值小于 749.927.693,而下一个标记(标记 177)的 granule 177 的最小 UserID 值大于该值。因此,仅标记 176 的对应 granule 176 可能包含 UserID 列值为 749.927.693 的行。 +上面的图表显示标记176是第一个索引条目,其关联的分片176的最小UserID值小于749.927.693,同时下一个标记(标记177)的分片177的最小UserID值大于此值。因此,只有标记176对应的分片176可能包含UserID列值为749.927.693的行。

-为了确认(或否定)granule 176 中是否包含 UserID 列值为 749.927.693 的某些行,需要将属于该 granule 的所有 8192 行流式传输到 ClickHouse。 +为了确认(或不确认)分片176中是否包含UserID列值为749.927.693的行,需将属于该分片的8192行全部流入ClickHouse。 -为此,ClickHouse 需要知道 granule 176 的物理位置。 +为此,ClickHouse需知道分片176的物理位置。 -在 ClickHouse 中,所有 granule 的物理位置都存储在标记文件中。类似于数据文件,每个表列都有一个标记文件。 +在ClickHouse中,我们表的所有分片的物理位置存储在标记文件中。与数据文件类似,每个表列都有一个标记文件。 -下图显示了存储表的 `UserID`、`URL` 和 `EventTime` 列的 granules 物理位置的三个标记文件 `UserID.mrk`、`URL.mrk` 和 `EventTime.mrk`。 +下图展示了三个标记文件`UserID.mrk`、`URL.mrk`和`EventTime.mrk`,它们存储了表的`UserID`、`URL`和`EventTime`列的分片物理位置。 Sparse Primary Indices 05 -我们已经讨论了主索引是一个扁平的无压缩数组文件(primary.idx),其中包含从 0 开始编号的索引标记。 +我们已经讨论了主索引是一个扁平的未压缩数组文件(primary.idx),它包含从0开始编号的索引标记。 -类似地,标记文件也是一个扁平的无压缩数组文件(*.mrk),其中包含从 0 开始编号的标记。 +同样,标记文件也是一个扁平的未压缩数组文件(*.mrk),包含从0开始编号的标记。 -一旦 ClickHouse 确定并选择了可能包含查询匹配行的 granule 的索引标记,就可以在标记文件中执行位置数组查找,以获得该 granule 的物理位置。 +一旦ClickHouse识别并选择了一个可能包含符合查询的行的分片的索引标记,就可以在标记文件中执行位置数组查找,以获取该分片的物理位置。 -每个特定列的标记文件条目存储以偏移量的形式提供两个位置: +每个特定列的标记文件条目以偏移量的形式存储两个位置: -- 第一个偏移量(上图中的 'block_offset')定位了包含所选 granule 压缩版本的 ,该块位于 压缩 列数据文件中。这个压缩块可能包含几个压缩的 granules。定位到的压缩文件块在读取时被解压缩到主内存中。 +- 第一个偏移量('block_offset'在上图中)定位了包含所选分片压缩版本的,在压缩列数据文件中。该压缩块可能包含几个压缩的分片。定位到的压缩文件块在读取时会解压到主内存中。 -- 第二个偏移量(上图中的 'granule_offset')来自标记文件,提供了未压缩块数据中 granule 的位置。 +- 第二个偏移量('granule_offset'在上图中)来自标记文件,提供了未压缩块数据中分片的位置。 -然后,属于定位的未压缩 granule 的所有 8192 行被流式传输到 ClickHouse 进行进一步处理。 +然后,将所有属于定位的未压缩分片的8192行流入ClickHouse以进行进一步处理。 :::note -- 对于具有 [宽格式](/engines/table-engines/mergetree-family/mergetree.md/#mergetree-data-storage) 且没有 [自适应索引粒度](/whats-new/changelog/2019.md/#experimental-features-1) 的表,ClickHouse 如上图所示使用 `.mrk` 标记文件,包含每个条目的两个 8 字节长地址。这些条目是物理位置的 granules,它们的大小相同。 +- 对于[宽格式](/engines/table-engines/mergetree-family/mergetree.md/#mergetree-data-storage)及无[自适应索引粒度](/whats-new/changelog/2019.md/#experimental-features-1)的表,ClickHouse使用上面所示的`.mrk`标记文件,该文件包含每个条目两个8字节长的地址。这些条目是大小相同的分片的物理位置。 -索引粒度在 [默认情况下](/operations/settings/merge-tree-settings#index_granularity_bytes) 是自适应的,但对于我们的示例表,我们禁用了自适应索引粒度(为了简化本文中的讨论,以及使图表和结果可重现)。我们的表使用宽格式,因为数据的大小大于 [min_bytes_for_wide_part](/operations/settings/merge-tree-settings#min_bytes_for_wide_part)(对于自管理集群默认值为 10 MB)。 +索引粒度默认[是自适应的](/operations/settings/merge-tree-settings#index_granularity_bytes),但为了简化本指南的讨论,以及使图表和结果可重复,我们对示例表禁用了自适应索引粒度。我们的表使用宽格式是因为数据的大小大于[min_bytes_for_wide_part](/operations/settings/merge-tree-settings#min_bytes_for_wide_part)(默认为自管理集群的10 MB)。 -- 对于具有宽格式且具有自适应索引粒度的表,ClickHouse 使用 `.mrk2` 标记文件,其中的条目与 `.mrk` 标记文件相似,但每个条目包含一个额外的第三个值:与当前条目关联的 granule 的行数。 +- 对于宽格式且具有自适应索引粒度的表,ClickHouse使用`.mrk2`标记文件,该文件包含与`.mrk`标记文件类似的条目,但每个条目增加了一个第三个值:当前条目关联的分片的行数。 -- 对于 [紧凑格式](/engines/table-engines/mergetree-family/mergetree.md/#mergetree-data-storage) 的表,ClickHouse 使用 `.mrk3` 标记文件。 +- 对于[紧凑格式](/engines/table-engines/mergetree-family/mergetree.md/#mergetree-data-storage)的表,ClickHouse使用`.mrk3`标记文件。 ::: - :::note 为什么使用标记文件 -为什么主索引不直接包含与索引标记对应的 granules 的物理位置? +为什么主索引不直接包含与索引标记对应的分片的物理位置? -因为在 ClickHouse 设计的那个非常大的规模上,非常重要的是高效地使用磁盘和内存。 +因为在ClickHouse旨在应对的非常大规模下,重要的是要非常有效地使用磁盘和内存。 -主索引文件需要适合主内存。 +主索引文件必须适应主内存。 -对于我们的示例查询,ClickHouse 使用主索引并选择一个可能包含与我们的查询匹配的行的单个 granule。只有在这个 granule 中,ClickHouse 才需要物理位置以流式传输相应的行进行进一步处理。 +对于我们的示例查询,ClickHouse使用了主索引并选择了一个可能包含符合我们查询条件的行的单个分片。仅对于该单个分片,ClickHouse才需要物理位置以流入相应的行进行进一步处理。 -此外,这些偏移信息仅对 UserID 和 URL 列是必需的。 +此外,偏移信息仅对UserID和URL列是必需的。 -对于未在查询中使用的列(例如 `EventTime`),不需要偏移信息。 +对于查询中未使用的列,例如`EventTime`,不需要偏移信息。 -对于我们的示例查询,ClickHouse 仅需要在 UserID 数据文件 (UserID.bin) 中 granule 176 的两个物理位置偏移量,以及在 URL 数据文件 (URL.bin) 中 granule 176 的两个物理位置偏移量。 +对于我们的示例查询,ClickHouse仅需要分片176在UserID数据文件(UserID.bin)中的两个物理位置偏移,以及分片176在URL数据文件(URL.bin)中的两个物理位置偏移。 -通过标记文件提供的间接性避免将所有 1083 个 granules 的物理位置条目直接存储在主索引中:从而避免在主内存中存储不必要(可能未使用)的数据。 +标记文件提供的间接性避免了直接在主索引中存储所有三个列的1083个分片的物理位置条目:从而避免在主内存中存储不必要的(可能未使用的)数据。 ::: -下图和以下文本说明了 ClickHouse 如何在 UserID.bin 数据文件中定位 granule 176。 +下图及以下文本展示了对于我们的示例查询ClickHouse如何在UserID.bin数据文件中定位分片176。 Sparse Primary Indices 06 -我们之前在本指南中讨论了 ClickHouse 选择了主索引标记 176,因此 granule 176 可能包含与我们的查询匹配的行。 +我们在本指南早先讨论过,ClickHouse选择了主索引标记176,因此分片176可能包含符合我们查询条件的行。 -ClickHouse 现在使用选定的标记号 (176) 从索引中进行位置数组查找,以获取定位 granule 176 的两个偏移量。 +ClickHouse现在使用索引中的选定标记号(176)在UserID.mrk标记文件中进行位置数组查找,以获取定位分片176的两个偏移量。 -如所示,第一个偏移量定位了包含 granule 176 压缩版本的 UserID.bin 数据文件中的压缩文件块。 +如图所示,第一个偏移量定位了包含分片176压缩版本的UserID.bin数据文件中的压缩文件块。 -一旦定位的文件块被解压缩到主内存中,标记文件中的第二个偏移量可以用于定位未压缩数据中的 granule 176。 +一旦定位的文件块解压到主内存中,标记文件中的第二个偏移量可用于在未压缩数据中定位分片176。 -ClickHouse 需要从 UserID.bin 数据文件和 URL.bin 数据文件中定位(并流式传输所有值)granule 176,以执行我们的示例查询(针对 UserID 为 749.927.693 的互联网用户点击次数最多的前 10 个 URL)。 +ClickHouse需要从UserID.bin和URL.bin数据文件中定位(并流入所有值)分片176,以执行我们的示例查询(获取UserID为749.927.693的用户点击最多的前10个URL)。 -上图显示了 ClickHouse 如何为 UserID.bin 数据文件定位 granule。 +上述图示了ClickHouse如何定位UserID.bin数据文件的分片。 -同时,ClickHouse 对 URL.bin 数据文件的 granule 176 做同样的操作。两个相应的 granules 对齐并被流式传输到 ClickHouse 引擎进行进一步处理,即对所有 UserID 为 749.927.693 的行聚合和计数 URL 值,然后最终输出按计数降序排列的 10 大 URL 组。 +同时,ClickHouse在URL.bin数据文件中也对分片176执行相同的操作。这两个相应的分片对齐并进入ClickHouse引擎进行进一步处理,即对所有UserID为749.927.693的行,按组聚合和计数URL值,然后最后按计数降序输出最大的10个URL组。 ## 使用多个主索引 {#using-multiple-primary-indexes} -### 次级键列可能(不)低效 {#secondary-key-columns-can-not-be-inefficient} +### 次要键列可能(不)效率低下 {#secondary-key-columns-can-not-be-inefficient} -当查询在作为复合键一部分的列上进行过滤且为第一个键列时,[ClickHouse 在键列的索引标记上运行二分查找算法](#the-primary-index-is-used-for-selecting-granules)。 +当查询在复合键的一部分列上进行过滤,并且是第一个键列时,[ClickHouse就会在该键列的索引标记上运行二分查找算法](#the-primary-index-is-used-for-selecting-granules)。 -但当查询在作为复合键一部分的列上过滤,但不是第一个键列时,会发生什么? +但是,当查询在复合键的某一列上进行过滤,但该列不是第一个键列时会发生什么? :::note -我们讨论一个场景,即查询明确不在第一个键列上过滤,而是在次级键列上进行过滤。 +我们讨论了一个场景,即查询显式不在第一个键列上进行过滤,而是在次要键列上进行过滤。 -当查询在第一个键列和任何后续键列上进行过滤时,ClickHouse 在第一个键列的索引标记上运行二分查找。 +当查询在第一个键列和第一个键列之后的任何键列上进行过滤时,ClickHouse正在对第一个键列的索引标记执行二分查找。 :::

-我们使用一个查询来计算最频繁点击 URL “http://public_search”的前 10 个用户: +我们使用一个查询,计算最常点击URL "http://public_search" 的前10个用户: ```sql SELECT UserID, count(UserID) AS Count @@ -698,7 +691,7 @@ ORDER BY Count DESC LIMIT 10; ``` -响应为: +响应为: ```response ┌─────UserID─┬─Count─┐ │ 2459550954 │ 3741 │ @@ -720,9 +713,9 @@ Processed 8.81 million rows, 799.69 MB (102.11 million rows/s., 9.27 GB/s.) ``` -客户端输出表明,尽管 [URL 列是复合主键的一部分](#a-table-with-a-primary-key),ClickHouse 几乎执行了全表扫描!ClickHouse 从 8.87 百万行的表中读取了 8.81 百万行。 +客户端输出显示,尽管[URL列是复合主键的一部分](#a-table-with-a-primary-key),ClickHouse几乎执行了全表扫描!ClickHouse从表的887万行中读取了881万行。 -如果启用 [trace_logging](/operations/server-configuration-parameters/settings#logger),那么 ClickHouse 服务器日志文件显示,ClickHouse 在 1083 个 URL 索引标记上使用了 通用排除搜索 以识别可能包含行的 granules,其 URL 列值为 “http://public_search”: +如果启用[trace_logging](/operations/server-configuration-parameters/settings#logger),则ClickHouse服务器日志文件显示,ClickHouse对1083个URL索引标记使用了通用排除搜索,以识别可能包含URL列值为"http://public_search"的行的分片: ```response ...Executor): Key condition: (column 1 in ['http://public_search', 'http://public_search']) @@ -736,129 +729,129 @@ Processed 8.81 million rows, 1076/1083 marks by primary key, 1076 marks to read from 5 ranges ...Executor): Reading approx. 8814592 rows with 10 streams ``` -我们可以在上述示例跟踪日志中看到,1076(通过标记)个 granules 被选中为可能包含匹配 URL 值的行。 +我们可以在上面的示例跟踪日志中看到,通过标记选定的1076个(来自1083个)分片可能包含具有匹配URL值的行。 -这导致 8.81 百万行被流式传输到 ClickHouse 引擎(通过使用 10 个流并行),以识别实际包含 URL 值 “http://public_search”的行。 +因此,ClickHouse流入了881万行(通过10个流并行)进入ClickHouse引擎,以识别哪些实际包含URL值"http://public_search"的行。 -然而,正如我们稍后将看到的,实际上,仅 39 个 granules 出选中 1076 个 granules 实际上包含匹配行。 +然而,正如我们稍后将看到的,在选定的1076个分片中,只有39个实际包含匹配的行。 -虽然基于复合主键 (UserID, URL) 的主索引对加速过滤特定 UserID 值的行的查询非常有用,但但它在加速过滤特定 URL 值的行的查询时并没有提供显著帮助。 +虽然基于复合主键(UserID, URL)的主索引对加速过滤特定UserID值的行非常有用,但在加速过滤特定URL值的查询中,该索引并未提供显著的帮助。 -原因在于 URL 列不是第一个键列,因此 ClickHouse 对 URL 列的索引标记使用通用排除搜索算法(而不是二分查找),而 **该算法的有效性取决于** URL 列与其前驱键列 UserID 之间的基数差异。 +原因是URL列不是第一个键列,因此ClickHouse在URL列的索引标记上使用了通用排除搜索算法(而不是二分查找),而且**该算法的有效性依赖于**URL列与其前驱键列UserID之间的基数差异。 -为了说明这一点,我们提供一些通用排除搜索如何工作的细节。 +为了说明这一点,我们提供了一些通用排除搜索的工作原理的细节。 ### 通用排除搜索算法 {#generic-exclusion-search-algorithm} -以下是说明 ClickHouse 通用排除搜索算法 如何工作,当通过次级列选择 granules 时,前驱键列具有低(或高)基数。 +以下示意了ClickHouse通用排除搜索算法在通过次要列选择分片时的工作原理,其中前驱键列具有较低或较高的基数。 -对于这两种情况,我们假设: -- 一个查询在搜索 URL 值 = "W3" 的行。 -- 我们的点击表的抽象版本,UserID 和 URL 的简化值。 -- 相同的复合主键 (UserID, URL) 作为索引。这意味着行首先按 UserID 值排序。具有相同 UserID 值的行随后按 URL 排序。 -- 每个 granule 的大小为两个,即每个 granule 包含两行。 +我们假设对于这两种情况的例子: +- 查询正在寻找URL值= "W3" 的行。 +- 我们命中的表的抽象版本,UserID和URL的值简化。 +- 相同的复合主键(UserID, URL)作为索引。这意味着行首先按UserID值排序。具有相同UserID值的行按URL排序。 +- 分片大小为两个,即每个分片包含两行。 -我们在以下图表上标出每个 granule 的第一行的键列值。 +我们用橙色标记了每个分片的前驱键列值的第一行的关键列值。 -**前驱键列具有低(或较低的)基数** +**前驱键列具有较低的基数** -假设 UserID 的基数较低。在这种情况下,可能同一个 UserID 值分布在多个表行和 granules 以及索引标记中。对于具有相同 UserID 的索引标记,URL 值按升序排序(因为表行首先按 UserID 排序,然后按 URL 排序)。这允许有效过滤,如下所述: +假设UserID具有较低的基数。在这种情况下,相同UserID值的行可能分布在多个表行和分片中,因此索引标记的数量。对于具有相同UserID的索引标记,URL值是按升序排列的(因为表的行首先按UserID排序,然后按URL)。这允许如下面所述的高效过滤: Sparse Primary Indices 06 -对于上图中我们抽象示例数据的 granule 选择过程,有三种不同的场景: +上面的图对于我们的抽象示例数据的分片选择过程有三种不同的场景: -1. 索引标记 0 的 **URL 值小于 W3,并且直接后续索引标记的 URL 值也小于 W3**,可以排除,因为标记 0 和 1 具有相同的 UserID 值。请注意,此排除前提确保 granule 0 完全由 U1 UserID 值组成,以便 ClickHouse 可以假设 granule 0 中的最大 URL 值也小于 W3,因此可以排除该 granule。 +1. 索引标记0,其**URL值小于W3,并且直接后续的索引标记的URL值也小于W3**,可以被排除,因为标记0和1具有相同的UserID值。请注意,此排除先决条件确保分片0完全由U1 UserID值组成,因此ClickHouse可以假设分片0中的最大URL值也小于W3并排除该分片。 -2. 索引标记 1 的 **URL 值小于(或等于) W3,并且直接后续索引标记的 URL 值大于(或等于) W3** 被选中,因为这意味着 granule 1 可能包含 URL W3 的行。 +2. 索引标记1,其**URL值小于(或等于)W3,且直接后续的索引标记的URL值大于(或等于)W3**,被选中,因为这意味着分片1可能包含URL W3的行。 -3. 索引标记 2 和 3 的 **URL 值大于 W3** 可以被排除,因为主索引的索引标记存储每个 granule 第一行的键列值,而表行在磁盘上按键列值排序,因此 granule 2 和 3 不可能包含 URL 值 W3。 +3. 索引标记2和3,其**URL值大于W3**,可以被排除,因为主索引的索引标记存储了每个分片的第一行的关键列值,因此分片2和3不可能包含URL值W3。 -**前驱键列具有高(或较高的)基数** +**前驱键列具有较高的基数** -当 UserID 具有较高基数时,同一个 UserID 值分布在多个表行和 granules 的可能性较小。这意味着索引标记的 URL 值不是单调增加的: +当UserID具有较高的基数时,情况就不太可能相同的UserID值分布在多个表行和分片中。这意味着索引标记的URL值并不是单调增加的: Sparse Primary Indices 06 -如上图所示,所有标记的 URL 值小于 W3 的索引标记都被选中,以流式传输其关联的 granules 的行到 ClickHouse 引擎。 +如上图所示,所有显示的标记,其URL值小于W3的,都被选中以流入其关联分片的行到ClickHouse引擎。 -这是因为虽然上图中的所有索引标记都属于上述场景 1,但它们不满足被提及的排除前提,即 *直接后续索引标记与当前标记具有相同的 UserID 值*,因此不能被排除。 +这是因为,尽管这一图中的所有索引标记都落入了上述场景1,它们并不满足提到的排除先决条件,即**直接后续的索引标记与当前标记具有相同的UserID值**,因此不能被排除。 -例如,考虑索引标记 0 的 **URL 值小于 W3,并且直接后续索引标记的 URL 值也小于 W3**。这不能被排除,因为直接后续索引标记 1 不具有与当前标记 0 相同的 UserID 值。 +例如,考虑索引标记0,其**URL值小于W3,并且直接后续的索引标记的URL值也小于W3**。这**不能**被排除,因为直接后续的索引标记1与当前标记0不具有相同的UserID值。 -这最终阻止 ClickHouse 对 granule 0 中的最大 URL 值做出假设。相反,它必须假设 granule 0 可能包含 URL 值 W3 的行,并被迫选择标记 0。 +这最终阻止了ClickHouse对分片0中的最大URL值做出假设。相反,它必须假设分片0可能包含URL值W3,并被迫选择标记0。 -标记 1、2 和 3 的情况也是如此。 +标记1、2和3也是同样的场景。 :::note 结论 -ClickHouse 使用的 通用排除搜索算法 而不是 二分查找算法,当查询在作为复合键一部分的列上过滤时,但不是第一个键列时,在前驱键列具有低(或较低)基数时效果最佳。 +ClickHouse使用的通用排除搜索算法,而不是二分查找算法,当查询在复合键的一部分列上进行过滤,但不是第一个键列时,最有效的时候是当前驱键列具有较低的基数。 ::: -在我们的示例数据集中,两个键列 (UserID, URL) 具有相似的高基数,并且,如前所述,当 URL 列的前驱键列具有高(或相似)基数时,通用排除搜索算法的效果不佳。 +在我们的示例数据集中,两个关键列(UserID, URL)具有相似的高基数,如前所述,当URL列的前驱键列具有较高或相似的基数时,通用排除搜索算法并不有效。 ### 关于数据跳过索引的说明 {#note-about-data-skipping-index} -由于 UserID 和 URL 的基数相似较高,因此我们的 [查询在 URL 上过滤](/guides/best-practices/sparse-primary-indexes#secondary-key-columns-can-not-be-inefficient) 在创建 URL 列的 [次级数据跳过索引](./skipping-indexes.md) 时也不会有太大益处, -对于我们具有复合主键 (UserID, URL) 的 [表](#a-table-with-a-primary-key)。 +由于UserID和URL的基数相似较高,我们[在URL上过滤的查询](/guides/best-practices/sparse-primary-indexes#secondary-key-columns-can-not-be-inefficient)也不会从在URL列上创建[次要数据跳过索引](./skipping-indexes.md)中受益 +的[复合主键表(UserID,URL)](#a-table-with-a-primary-key)。 -例如,这两条语句在我们表的 URL 列上创建并填充一个 [minmax](/engines/table-engines/mergetree-family/mergetree.md/#primary-keys-and-indexes-in-queries) 数据跳过索引: +例如,这两个语句在URL列上创建并填充[最小最大](/engines/table-engines/mergetree-family/mergetree.md/#primary-keys-and-indexes-in-queries)数据跳过索引: ```sql ALTER TABLE hits_UserID_URL ADD INDEX url_skipping_index URL TYPE minmax GRANULARITY 4; ALTER TABLE hits_UserID_URL MATERIALIZE INDEX url_skipping_index; ``` -ClickHouse 现在创建了一个附加索引,该索引存储 - 每组 4 个连续的 [granules](#data-is-organized-into-granules-for-parallel-data-processing)(注意上面 `ALTER TABLE` 语句中的 `GRANULARITY 4` 子句) - 最小和最大 URL 值: +ClickHouse现在创建了一个附加索引,该索引按4个连续[分片](#data-is-organized-into-granules-for-parallel-data-processing)(注意上面的`GRANULARITY 4`子句) 存储最小值和最大值施。 Sparse Primary Indices 13a -第一个索引条目(上图中的 'mark 0')存储属于我们表的前 4 个 granules 的 [行的最小和最大 URL 值](#data-is-organized-into-granules-for-parallel-data-processing)。 +第一个索引条目(上述图中的'mark 0')存储我们表的前4个分片的[行的最小和最大URL值](#data-is-organized-into-granules-for-parallel-data-processing)。 -第二个索引条目('mark 1')存储属于我们表的下 4 个 granules 的行的最小和最大 URL 值,以此类推。 +第二个索引条目('mark 1')存储我们表的下4个分片的行的最小和最大URL值,依此类推。 -(ClickHouse 还为数据跳过索引创建了一个特殊的 [标记文件](#mark-files-are-used-for-locating-granules),用于 [定位](#mark-files-are-used-for-locating-granules) 与索引标记关联的 granule 组。) +(ClickHouse也为数据跳过索引创建了特殊的[标记文件](#mark-files-are-used-for-locating-granules),用于[定位](#mark-files-are-used-for-locating-granules)与索引标记相关的分片组。) -由于 UserID 和 URL 的基数相似较高,因此当执行我们的 [查询过滤在 URL 上](#secondary-key-columns-can-not-be-inefficient) 时,这个次级数据跳过索引不能有效帮助排除 granules。 +由于UserID和URL的基数相似较高,该次要数据跳过索引无法在我们执行[查询URL的过滤](#secondary-key-columns-can-not-be-inefficient)时帮助排除分片。 -查询所需的特定 URL 值(即 'http://public_search')很可能在索引为每个 granule 组存储的最小和最大值之间,导致 ClickHouse 被迫选择该 granule 组(因为它们可能包含与查询匹配的行)。 +查询所寻求的特定URL值(即'http://public_search')很可能位于由索引为每个分片组存储的最小值和最大值之间,导致ClickHouse被迫选择分片组(因为它们可能包含与查询条件匹配的行)。 ### 需要使用多个主索引 {#a-need-to-use-multiple-primary-indexes} -因此,如果我们想显著加快过滤特定 URL 的行的示例查询,则需要使用针对该查询优化的主索引。 +因此,如果我们希望显著加快我们的示例查询(过滤特定URL的行),则需要使用针对该查询优化的主索引。 -如果我们还希望保持查询过滤特定 UserID 的良好性能,则需要使用多个主索引。 +如果我们还希望保持示例查询(过滤特定UserID的行)的良好性能,则需要使用多个主索引。 -以下是实现的方式。 +以下是实现的几种方法。 -### 创建附加主索引的选项 {#options-for-creating-additional-primary-indexes} +### 创建额外主索引的选项 {#options-for-creating-additional-primary-indexes} -如果我们希望显著加快两个示例查询 - 一个是过滤特定 UserID 的行,另一个是过滤特定 URL 的行 - 那么我们需要使用多个主索引,使用以下三种选项中的一种: +如果我们希望显著加快两个示例查询 — 一个过滤特定UserID的行,另一个过滤特定URL的行,则需要通过以下三种选项使用多个主索引: -- 创建一个 **第二张表**,其主键不同。 -- 在我们现有的表上创建一个 **物化视图**。 -- 向我们现有的表添加一个 **投影**。 +- 创建具有不同主键的**第二张表**。 +- 在现有表上创建**物化视图**。 +- 向现有表添加**投影**。 -这三种选项都将有效地将我们的示例数据复制到附加表中,以重新组织表的主索引和行排序顺序。 +这三种选项将有效地将我们示例数据复制到附加表中,以重组表的主索引和行排序顺序。 -然而,这三种选项在附加表相对于查询和插入语句的路由的透明性上有所不同。 +但是,这三种选项在用户查询和插入语句的路由方面透明度上有所不同。 -当创建一个 **第二张表**,其主键不同,则必须显式将查询发送到最适合该查询的表版本,并且必须显式将新数据插入到两个表中,以保持表之间的同步: +当创建具有不同主键的**第二张表**时,则必须显式将查询发送到最佳适合该查询的表版本,并且必须显式将新数据插入到两个表中以保持同步: Sparse Primary Indices 09a -使用 **物化视图** 时,附加表会隐式创建,数据在两个表之间自动保持同步: +使用**物化视图**,将隐式创建附加表,数据会在两个表之间自动保持同步: Sparse Primary Indices 09b -**投影** 是最透明的选项,因为除了自动保持隐式创建(和隐藏的)附加表与数据变化同步外,ClickHouse 还会自动为查询选择最有效的表版本: +而**投影**是最透明的选择,因为除了自动保持隐式创建(和隐藏)附加表与数据变化同步外,ClickHouse会自动选择最有效的表版本用于查询: Sparse Primary Indices 09c -在以下部分中,我们将详细讨论这三种创建和使用多个主索引的选项,并提供实际示例。 +接下来,我们详细讨论这三种创建和使用多个主索引的选项,并提供实际示例。 -### 选项 1:次级表 {#option-1-secondary-tables} +### 选项1:次要表 {#option-1-secondary-tables} -我们创建一个新的附加表,在主键中切换键列的顺序(与原始表相比): +我们创建一个新附加表,其中我们改变主键中关键列的顺序(与我们的原始表相比): ```sql CREATE TABLE hits_URL_UserID @@ -874,11 +867,11 @@ ORDER BY (URL, UserID, EventTime) SETTINGS index_granularity = 8192, index_granularity_bytes = 0, compress_primary_key = 0; ``` -将我们 [原始表](#a-table-with-a-primary-key) 中的 8.87 百万行插入该附加表: +插入所有887万行到我们的[原始表](#a-table-with-a-primary-key)中到附加表: ```sql INSERT INTO hits_URL_UserID -SELECT * from hits_UserID_URL; +SELECT * FROM hits_UserID_URL; ``` 响应如下: @@ -894,7 +887,7 @@ Ok. OPTIMIZE TABLE hits_URL_UserID FINAL; ``` -由于我们切换了主键中列的顺序,插入的行现在以不同的字典序顺序存储在磁盘上(与我们 [原始表](#a-table-with-a-primary-key) 相比),因此该表的 1083 个 granules 也包含不同的值: +因为我们改变了主键中列的顺序,插入的行现在按不同的字典顺序存储在磁盘上(与我们的[原始表](#a-table-with-a-primary-key)相比),因此该表的1083个分片也包含不同的值: Sparse Primary Indices 10 @@ -902,7 +895,7 @@ OPTIMIZE TABLE hits_URL_UserID FINAL; Sparse Primary Indices 11 -现在可以用来显著加快我们示例查询的执行,该查询过滤 URL 列以计算最频繁点击 URL “http://public_search”的前 10 个用户: +现在可以用来显著加快执行我们的示例查询(过滤URL列)以计算最常点击URL "http://public_search" 的前10个用户: ```sql SELECT UserID, count(UserID) AS Count -- highlight-next-line @@ -937,13 +930,13 @@ Processed 319.49 thousand rows, 11.38 MB (18.41 million rows/s., 655.75 MB/s.) ``` -现在,ClickHouse 更有效地执行了该查询,而不是 [几乎进行全表扫描](/guides/best-practices/sparse-primary-indexes#efficient-filtering-on-secondary-key-columns)。 +现在,ClickHouse执行该查询要有效得多,而不是[几乎进行全表扫描](/guides/best-practices/sparse-primary-indexes#efficient-filtering-on-secondary-key-columns)。 -在我们 [原始表](#a-table-with-a-primary-key) 的主索引中,UserID 是第一个,URL 是第二个键列,ClickHouse 对索引标记使用了 [通用排除搜索](/guides/best-practices/sparse-primary-indexes#generic-exclusion-search-algorithm) 来执行该查询,这并不有效,因为 UserID 和 URL 的基数相似较高。 +在[原始表](#a-table-with-a-primary-key)的主索引中,UserID是第一个,URL是第二个键列,ClickHouse使用了[通用排除搜索](/guides/best-practices/sparse-primary-indexes#generic-exclusion-search-algorithm)来执行该查询,但由于UserID和URL的基数相似高,因此效果不佳。 -将 URL 作为主索引中的首列,ClickHouse 现在对索引标记运行 二分查找。 -ClickHouse 服务器日志文件中的相关跟踪日志确认: +将URL作为主索引中的第一个列,ClickHouse现在运行二分查找在索引标记上。 +ClickHouse服务器日志文件中的相应跟踪日志确认: ```response ...Executor): Key condition: (column 0 in ['http://public_search', 'http://public_search']) @@ -959,16 +952,17 @@ ClickHouse 服务器日志文件中的相关跟踪日志确认: 39/1083 marks by primary key, 39 marks to read from 1 ranges ...Executor): Reading approx. 319488 rows with 2 streams ``` -ClickHouse 仅选择了 39 个索引标记,而不是使用通用排除搜索时的 1076 个。 +ClickHouse仅选择39个索引标记,而不是1076个,当使用通用排除搜索时。 + +注意,附加表专门用于加快对URL的过滤查询的执行。 -请注意,附加表经过优化,可以加快执行根据 URL 过滤的示例查询。 +与我们[原始表](#a-table-with-a-primary-key)中对[次要键列](#secondary-key-columns-can-not-be-inefficient)的该查询的[糟糕性能](/guides/best-practices/sparse-primary-indexes#secondary-key-columns-can-not-be-inefficient)相似,我们的[过滤`UserIDs`的示例查询](#the-primary-index-is-used-for-selecting-granules)在新附加表中也不会以非常有效的方式运行,因为UserID现在是该表主索引中的第二个键列,因此ClickHouse将使用通用排除搜索进行分片选择,而这对于UserID和URL的基数相似高是[不太有效的](/guides/best-practices/sparse-primary-indexes#generic-exclusion-search-algorithm)。 -与我们 [原始表](#a-table-with-a-primary-key) 的查询表现出 [较差的性能](/guides/best-practices/sparse-primary-indexes#secondary-key-columns-can-not-be-inefficient) 相同,我们的 [根据 UserIDs 过滤的示例查询](#the-primary-index-is-used-for-selecting-granules) 在新附加表中也不会有效执行,因为 UserID 现在是该表主索引中的第二个键列,因此 ClickHouse 将对 granule 选择使用通用排除搜索,这对于 UserID 和 URL 的 [相似高基数](/guides/best-practices/sparse-primary-indexes#generic-exclusion-search-algorithm) 并不有效。 -点击详情框以获取具体信息。 +展开详情框以获取具体信息。
- 现在根据 UserIDs 过滤的查询性能较差 + 现在过滤UserIDs的查询性能差

@@ -1020,10 +1014,10 @@ Processed 8.02 million rows,

-我们现在有两个表。分别优化用于加快针对 `UserIDs` 的查询和加快针对 URLs 的查询: -### 选项 2:物化视图 {#option-2-materialized-views} +我们现在有两个表。分别优化以加速对`UserIDs`的查询和加速对URL的查询: +### 选项2:物化视图 {#option-2-materialized-views} -在我们现有的表上创建一个 [物化视图](/sql-reference/statements/create/view.md)。 +在现有表上创建[物化视图](/sql-reference/statements/create/view.md)。 ```sql CREATE MATERIALIZED VIEW mv_hits_URL_UserID ENGINE = MergeTree() @@ -1042,23 +1036,23 @@ Ok. ``` :::note -- 我们在视图的主键中(与我们 [原始表](#a-table-with-a-primary-key) 相比)切换了键列的顺序 -- 物化视图由一个 **隐式创建的表** 支持,其行顺序和主索引基于给定的主键定义 -- 隐式创建的表可以通过 `SHOW TABLES` 查询列出,并且其名称以 `.inner` 开头 -- 也可以首先显式创建物化视图的支持表,然后视图可以通过 `TO [db].[table]` [子句](/sql-reference/statements/create/view.md) 定位该表 -- 我们使用 `POPULATE` 关键字以便立即用来自源表 [hits_UserID_URL](#a-table-with-a-primary-key) 的所有 8.87 百万行填充隐式创建的表 -- 如果向源表 hits_UserID_URL 插入新行,则也会自动插入到隐式创建的表中 -- 实际上,隐式创建的表具有与我们 [显式创建的次级表](/guides/best-practices/sparse-primary-indexes#option-1-secondary-tables) 相同的行顺序和主索引: +- 我们在视图的主键中切换了关键列的顺序(与我们的[原始表](#a-table-with-a-primary-key)相比) +- 该物化视图由**隐式创建的表**支持,其行顺序和主索引基于给定的主键定义 +- 该隐式创建的表通过`SHOW TABLES`查询列出,其名称以 `.inner` 开头 +- 也可以首先明确为物化视图创建后备表,然后通过 `TO [db].[table]` [子句](/sql-reference/statements/create/view.md) 指向该表 +- 我们使用`POPULATE`关键字立即将隐式创建的表填充来自源表[hits_UserID_URL](#a-table-with-a-primary-key)的所有887万行 +- 如果新行被插入到源表hits_UserID_URL中,那么这些行也会自动插入到隐式创建的表中 +- 实际上,隐式创建的表具有与我们[显式创建的次要表](/guides/best-practices/sparse-primary-indexes#option-1-secondary-tables)相同的行顺序和主索引: Sparse Primary Indices 12b1 -ClickHouse 将隐式创建的表(及其主索引)背后的列数据文件(*.bin)、标记文件(*.mrk2)和主索引(primary.idx)存储在 ClickHouse 服务器数据目录的特殊文件夹中: +ClickHouse将隐式创建表和其主索引的[列数据文件](#data-is-stored-on-disk-ordered-by-primary-key-columns)(*.bin)、[标记文件](#mark-files-are-used-for-locating-granules)(*.mrk2)和[主索引](#the-primary-index-has-one-entry-per-granule)(primary.idx)存储在ClickHouse服务器数据目录中的特殊文件夹内: Sparse Primary Indices 12b2 ::: -隐式创建的表(及其主索引)支持物化视图现在可以用来显著加快执行我们示例查询根据 URL 列过滤: +物化视图背后的隐式创建的表(及其主索引)现在可以用来显著加快执行我们示例查询的过滤的URL列: ```sql SELECT UserID, count(UserID) AS Count -- highlight-next-line @@ -1092,9 +1086,9 @@ Processed 335.87 thousand rows, 13.54 MB (12.91 million rows/s., 520.38 MB/s.) ``` -因为有效地隐式创建的表(及其主索引)支持的物化视图与我们 [显式创建的次级表](/guides/best-practices/sparse-primary-indexes#option-1-secondary-tables) 相同,因此查询的执行方式与显式创建的表相同。 +因为物化视图背后的隐式创建的表(及其主索引)在功能上与我们[显式创建的次要表](/guides/best-practices/sparse-primary-indexes#option-1-secondary-tables)相同,因此该查询的执行效果与采用显式创建的表相同。 -ClickHouse 服务器日志文件中的相关跟踪日志确认,ClickHouse 正在对索引标记运行二分查找: +ClickHouse服务器日志文件中的相应跟踪日志确认,ClickHouse在索引标记上执行二分查找: ```response ...Executor): Key condition: (column 0 in ['http://public_search', @@ -1109,9 +1103,9 @@ ClickHouse 服务器日志文件中的相关跟踪日志确认,ClickHouse 正 41/1083 marks by primary key, 41 marks to read from 4 ranges ...Executor): Reading approx. 335872 rows with 4 streams ``` -### 选项 3:投影 {#option-3-projections} +### 选项3:投影 {#option-3-projections} -在我们现有的表上创建投影: +在现有表上创建投影: ```sql ALTER TABLE hits_UserID_URL ADD PROJECTION prj_url_userid @@ -1121,31 +1115,30 @@ ALTER TABLE hits_UserID_URL ); ``` -并对投影进行物化: +并将投影物化: ```sql ALTER TABLE hits_UserID_URL MATERIALIZE PROJECTION prj_url_userid; ``` :::note -- 投影创建一个 **隐藏表**,其行顺序和主索引基于投影的给定 `ORDER BY` 子句 -- 隐藏表不会通过 `SHOW TABLES` 查询列出 -- 我们使用 `MATERIALIZE` 关键字以便立即用来自源表 [hits_UserID_URL](#a-table-with-a-primary-key) 的所有 8.87 百万行填充隐藏表 -- 如果向源表 hits_UserID_URL 插入新行,则也会自动插入到隐藏表中 -- 查询总是(在语法上)针对源表 hits_UserID_URL,但如果隐藏表的行顺序和主索引允许更有效的查询执行,则会使用该隐藏表 -- 请注意,投影不会使使用 ORDER BY 的查询更有效,即使 ORDER BY 与投影的 ORDER BY 声明匹配(见 https://github.com/ClickHouse/ClickHouse/issues/47333) -- 实际上,隐式创建的隐藏表具有与我们 [显式创建的次级表](/guides/best-practices/sparse-primary-indexes#option-1-secondary-tables) 相同的行顺序和主索引: +- 该投影创建了一个**隐藏表**,其行顺序和主索引基于给定的投影的`ORDER BY`子句 +- 该隐藏表不会通过`SHOW TABLES`查询列出 +- 我们使用`MATERIALIZE`关键字立即填充隐藏表,包含来自源表[hits_UserID_URL](#a-table-with-a-primary-key)的所有887万行 +- 如果新行被插入到源表hits_UserID_URL中,那么这些行也会自动插入到隐藏表中 +- 查询始终(在语法上)针对源表hits_UserID_URL,但如果行顺序和隐藏表的主索引允许更有效的查询执行,则将使用该隐藏表 +- 请注意,即使ORDER BY与投影的ORDER BY语句匹配,投影也不会使使用ORDER BY的查询更加高效(见https://github.com/ClickHouse/ClickHouse/issues/47333) +- 隐式创建的隐藏表在功能上与我们[显式创建的次要表](/guides/best-practices/sparse-primary-indexes#option-1-secondary-tables)相同: Sparse Primary Indices 12c1 -ClickHouse 将隐式创建的表(及其主索引)创建投影的列数据文件(*.bin)、标记文件(*.mrk2)和主索引(primary.idx)存储在源表的数据文件、标记文件和主索引文件旁边的特殊文件夹中(如下图所示的橙色标记): +ClickHouse将隐式创建的表(*.bin)、标记文件(*.mrk2)和主索引(primary.idx)存储在与源表的数据文件、标记文件和主索引文件相邻的特殊文件夹中(在下面的屏幕截图中标记为橙色): Sparse Primary Indices 12c2 ::: - -通过投影创建的隐藏表(及其主索引)现在可以(隐式)用于显著加快执行我们示例查询,过滤 URL 列。请注意,查询在语法上是针对投影的源表。 +投影创建的隐藏表(及其主索引)现在可以(隐式)用于显著加快执行我们示例查询的过滤的URL列。请注意,查询在语法上是针对投影的源表的。 ```sql SELECT UserID, count(UserID) AS Count -- highlight-next-line @@ -1179,10 +1172,9 @@ Processed 319.49 thousand rows, 1 1.38 MB (11.05 million rows/s., 393.58 MB/s.) ``` -因为通过投影创建的隐式表(及其主索引)实际上与我们 [显式创建的次级表](/guides/best-practices/sparse-primary-indexes#option-1-secondary-tables) 相同,因此查询的执行方式与显式创建的表相同。 - -ClickHouse 服务器日志文件中的相关跟踪日志确认,ClickHouse 正在对索引标记运行二分查找: +因为投影创建的隐藏表(及其主索引)在功能上与我们[显式创建的次要表](/guides/best-practices/sparse-primary-indexes#option-1-secondary-tables)相同,因此该查询的执行效果与采用显式创建的表相同。 +ClickHouse服务器日志文件中的相应跟踪日志确认,ClickHouse在索引标记上执行二分查找: ```response ...Executor): Key condition: (column 0 in ['http://public_search', @@ -1203,34 +1195,34 @@ ClickHouse 服务器日志文件中的相关跟踪日志确认,ClickHouse 正 ``` ### 摘要 {#summary} -我们带有复合主键(UserID,URL)的 [表](#a-table-with-a-primary-key) 的主索引在加速 [过滤 UserID 的查询](#the-primary-index-is-used-for-selecting-granules) 时非常有用。但是,该索引在加速 [过滤 URL 的查询](/guides/best-practices/sparse-primary-indexes#secondary-key-columns-can-not-be-inefficient) 时并没有提供显著的帮助,尽管 URL 列是复合主键的一部分。 +我们带有复合主键 (UserID, URL) 的 [表](#a-table-with-a-primary-key) 的主索引对于加速 [基于 UserID 过滤的查询](#the-primary-index-is-used-for-selecting-granules) 非常有用。但尽管 URL 列是复合主键的一部分,这个索引对于加速 [基于 URL 过滤的查询](/guides/best-practices/sparse-primary-indexes#secondary-key-columns-can-not-be-inefficient) 并没有提供显著的帮助。 反之亦然: -我们带有复合主键(URL,UserID)的 [表](/guides/best-practices/sparse-primary-indexes#option-1-secondary-tables) 在加速 [过滤 URL 的查询](/guides/best-practices/sparse-primary-indexes#secondary-key-columns-can-not-be-inefficient) 时表现良好,但在 [过滤 UserID 的查询](#the-primary-index-is-used-for-selecting-granules) 中没有提供太多支持。 +我们带有复合主键 (URL, UserID) 的 [表](/guides/best-practices/sparse-primary-indexes#option-1-secondary-tables) 能够加速 [基于 URL 过滤的查询](/guides/best-practices/sparse-primary-indexes#secondary-key-columns-can-not-be-inefficient),但对 [基于 UserID 过滤的查询](#the-primary-index-is-used-for-selecting-granules) 并没有提供太多支持。 -由于主键列 UserID 和 URL 的基数相似且均很高,过滤第二个键列的查询 [并不太受益于第二个键列在索引中的存在](#generic-exclusion-search-algorithm)。 +因为主键列 UserID 和 URL 的基数相似较高,因此基于第二个键列进行过滤的查询 [并不太受益于该第二个键列在索引中的存在](#generic-exclusion-search-algorithm)。 -因此,移除主索引中的第二个键列(从而降低索引的内存消耗)并 [使用多个主索引](/guides/best-practices/sparse-primary-indexes#using-multiple-primary-indexes) 是合理的。 +因此,删除主索引中的第二个键列是有意义的(从而使索引的内存消耗减少),并且可以 [使用多个主索引](/guides/best-practices/sparse-primary-indexes#using-multiple-primary-indexes)。 -然而,如果复合主键中的键列在基数上存在较大差异,那么按照基数升序排列主键列对于 [查询是有益的](/guides/best-practices/sparse-primary-indexes#generic-exclusion-search-algorithm)。 +然而,如果复合主键中的键列在基数上存在较大差异,那么 [对于查询](/guides/best-practices/sparse-primary-indexes#generic-exclusion-search-algorithm) 来说,将主键列按基数升序排列是有益的。 -键列之间的基数差异越大,它们在键中排列的顺序越重要。我们将在下一节中演示这一点。 +键列之间的基数差异越大,键中这些列的顺序就越重要。我们将在下一节中演示这一点。 ## 高效排序键列 {#ordering-key-columns-efficiently} 在复合主键中,键列的顺序可以显著影响: -- 查询中过滤二级键列的效率,以及 -- 表的数据文件的压缩比。 +- 查询中对次级键列的过滤效率,以及 +- 表数据文件的压缩比。 -为了演示这一点,我们将使用我们的 [Web 流量示例数据集](#data-set) 的一个版本,其中每行包含三个列,指示互联网“用户”(`UserID` 列)对 URL (`URL` 列) 的访问是否被标记为机器人流量(`IsRobot` 列)。 +为了证明这一点,我们将使用我们 [网络流量示例数据集](#data-set) 的一个版本,其中每行包含三列,指示互联网“用户” (`UserID` 列) 对某个 URL (`URL` 列) 的访问是否被标记为机器人流量 (`IsRobot` 列)。 -我们将使用包含上述三个列的复合主键来加速计算典型网络分析查询的速度,这些查询可以计算 -- 访问特定 URL 的流量中有多少(百分比)来自机器人,以及 -- 我们对特定用户是否是(不是)机器人(该用户的流量中有多少(不是)被假定为机器人流量)的信心。 +我们将使用一个包含上述三个列的复合主键,用于加速典型的网络分析查询,这些查询计算: +- 针对特定 URL 的流量中有多少(百分比)来自机器人,或 +- 我们对特定用户(不是)机器人的信心有多大(该用户的流量有多少(不)被假设为机器人流量)。 -我们使用此查询来计算我们希望用作复合主键键列的三个列的基数(请注意,我们使用 [URL 表函数](/sql-reference/table-functions/url.md) 来临时查询 TSV 数据,而无需创建本地表)。在 `clickhouse client` 中运行此查询: +我们使用这个查询来计算我们希望作为复合主键的键列中的三个列的基数(注意,我们使用 [URL 表函数](/sql-reference/table-functions/url.md) 来临时查询 TSV 数据,无需创建本地表)。在 `clickhouse client` 中运行此查询: ```sql SELECT formatReadableQuantity(uniq(URL)) AS cardinality_URL, @@ -1245,23 +1237,23 @@ FROM FROM url('https://datasets.clickhouse.com/hits/tsv/hits_v1.tsv.xz') WHERE URL != '' ) -``` -响应为: +``` +响应是: ```response ┌─cardinality_URL─┬─cardinality_UserID─┬─cardinality_IsRobot─┐ │ 2.39 million │ 119.08 thousand │ 4.00 │ └─────────────────┴────────────────────┴─────────────────────┘ 1 row in set. Elapsed: 118.334 sec. Processed 8.87 million rows, 15.88 GB (74.99 thousand rows/s., 134.21 MB/s.) -``` +``` -我们可以看到,基数之间的差异很大,尤其是在 `URL` 和 `IsRobot` 列之间,因此这些列在复合主键中的顺序对提高过滤这些列的查询效率和实现表的列数据文件的最佳压缩比都至关重要。 +我们可以看到,特别是在 `URL` 和 `IsRobot` 列之间存在较大的基数差异,因此这些列在复合主键中的顺序对于加速基于这些列的查询和实现表的列数据文件的最佳压缩比至关重要。 -为了演示这一点,我们为我们的机器人流量分析数据创建两个表版本: -- 表 `hits_URL_UserID_IsRobot`,其复合主键为 `(URL, UserID, IsRobot)`,我们按基数降序排列键列 -- 表 `hits_IsRobot_UserID_URL`,其复合主键为 `(IsRobot, UserID, URL)`,我们按基数升序排列键列 +为了证明这一点,我们创建两个用于我们机器人流量分析数据的表版本: +- 一个表 `hits_URL_UserID_IsRobot`,其复合主键为 `(URL, UserID, IsRobot)`,在这个表中我们按基数降序排列键列 +- 一个表 `hits_IsRobot_UserID_URL`,其复合主键为 `(IsRobot, UserID, URL)`,在这个表中我们按基数升序排列键列 -创建复合主键 `(URL, UserID, IsRobot)` 的表 `hits_URL_UserID_IsRobot`: +创建复合主键为 `(URL, UserID, IsRobot)` 的表 `hits_URL_UserID_IsRobot`: ```sql CREATE TABLE hits_URL_UserID_IsRobot ( @@ -1288,7 +1280,7 @@ WHERE URL != ''; 0 rows in set. Elapsed: 104.729 sec. Processed 8.87 million rows, 15.88 GB (84.73 thousand rows/s., 151.64 MB/s.) ``` -接下来,创建复合主键 `(IsRobot, UserID, URL)` 的表 `hits_IsRobot_UserID_URL`: +接下来,创建复合主键为 `(IsRobot, UserID, URL)` 的表 `hits_IsRobot_UserID_URL`: ```sql CREATE TABLE hits_IsRobot_UserID_URL ( @@ -1300,7 +1292,7 @@ ENGINE = MergeTree -- highlight-next-line PRIMARY KEY (IsRobot, UserID, URL); ``` -并用我们用于填充上一个表的相同 887 万行填充它: +并用我们用来填充前一个表的同样的 887 万行填充它: ```sql INSERT INTO hits_IsRobot_UserID_URL SELECT @@ -1310,26 +1302,26 @@ INSERT INTO hits_IsRobot_UserID_URL SELECT FROM url('https://datasets.clickhouse.com/hits/tsv/hits_v1.tsv.xz') WHERE URL != ''; ``` -响应为: +响应是: ```response 0 rows in set. Elapsed: 95.959 sec. Processed 8.87 million rows, 15.88 GB (92.48 thousand rows/s., 165.50 MB/s.) ``` -### 在二级键列上高效过滤 {#efficient-filtering-on-secondary-key-columns} +### 高效过滤次级键列 {#efficient-filtering-on-secondary-key-columns} -当查询至少过滤一个属于复合键的列,并且是第一个键列时,[ClickHouse 会在键列的索引标记上运行二分查找算法](#the-primary-index-is-used-for-selecting-granules)。 +当查询至少过滤一个作为复合键一部分的列,并且是第一个键列时,[ClickHouse 将在其索引标记上运行二分搜索算法](#the-primary-index-is-used-for-selecting-granules)。 -当查询仅过滤一个属于复合键的列,但不是第一个键列时,[ClickHouse 使用通用排除搜索算法来处理键列的索引标记](https://github.com/ClickHouse/ClickHouse/blob/22.3/src/Storages/MergeTree/MergeTreeDataSelectExecutor.cpp#L1444)。 +当查询仅在作为复合键一部分的列上过滤,但不是第一个键列时,[ClickHouse 使用在键列索引标记上的通用排除搜索算法](/guides/best-practices/sparse-primary-indexes#secondary-key-columns-can-not-be-inefficient)。 -在第二种情况下,复合主键中键列的顺序对于 [通用排除搜索算法](https://github.com/ClickHouse/ClickHouse/blob/22.3/src/Storages/MergeTree/MergeTreeDataSelectExecutor.cpp#L1444) 的有效性至关重要。 +对于第二种情况,复合主键中键列的顺序对 [通用排除搜索算法](https://github.com/ClickHouse/ClickHouse/blob/22.3/src/Storages/MergeTree/MergeTreeDataSelectExecutor.cpp#L1444) 的有效性是至关重要的。 -这是一个在我们按基数降序排列键列 `(URL, UserID, IsRobot)` 的表上过滤 `UserID` 列的查询: +以下是一个在按基数降序排列键列的表中过滤 `UserID` 列的查询: ```sql SELECT count(*) FROM hits_URL_UserID_IsRobot WHERE UserID = 112304 ``` -响应为: +响应是: ```response ┌─count()─┐ │ 73 │ @@ -1342,13 +1334,13 @@ Processed 7.92 million rows, 31.67 MB (306.90 million rows/s., 1.23 GB/s.) ``` -这是在我们按基数升序排列键列 `(IsRobot, UserID, URL)` 的表上执行的相同查询: +这是在按基数升序排列键列的表上的相同查询: ```sql SELECT count(*) FROM hits_IsRobot_UserID_URL WHERE UserID = 112304 ``` -响应为: +响应是: ```response ┌─count()─┐ │ 73 │ @@ -1361,13 +1353,13 @@ Processed 20.32 thousand rows, 81.28 KB (6.61 million rows/s., 26.44 MB/s.) ``` -我们可以看到,在按基数升序排列键列的表上,查询执行的效率和速度明显更高。 +我们可以看到,在按基数升序排列键列的表上,查询执行显著更有效和更快。 -原因在于 [通用排除搜索算法](https://github.com/ClickHouse/ClickHouse/blob/22.3/src/Storages/MergeTree/MergeTreeDataSelectExecutor.cpp#L1444) 在通过前驱键列具有低基数的二级键列选择 [分区片段](#the-primary-index-is-used-for-selecting-granules) 时效果最佳。我们在本指南的 [上一节](#generic-exclusion-search-algorithm) 中详细说明了这一点。 +原因是 [通用排除搜索算法](https://github.com/ClickHouse/ClickHouse/blob/22.3/src/Storages/MergeTree/MergeTreeDataSelectExecutor.cpp#L1444) 在通过次级键列选择 [分区片段](#the-primary-index-is-used-for-selecting-granules) 时最有效,当前驱键列具有较低的基数。我们在本指南的 [前一节](#generic-exclusion-search-algorithm) 中详细说明了这一点。 ### 数据文件的最佳压缩比 {#optimal-compression-ratio-of-data-files} -此查询比较了我们上面创建的两个表中 `UserID` 列的压缩比: +此查询比较了我们上述两个表中 `UserID` 列的压缩比: ```sql SELECT @@ -1380,7 +1372,7 @@ FROM system.columns WHERE (table = 'hits_URL_UserID_IsRobot' OR table = 'hits_IsRobot_UserID_URL') AND (name = 'UserID') ORDER BY Ratio ASC ``` -响应为: +响应是: ```response ┌─Table───────────────────┬─Column─┬─Uncompressed─┬─Compressed─┬─Ratio─┐ │ hits_URL_UserID_IsRobot │ UserID │ 33.83 MiB │ 11.24 MiB │ 3 │ @@ -1390,83 +1382,83 @@ ORDER BY Ratio ASC 2 rows in set. Elapsed: 0.006 sec. ``` -我们可以看到,在按基数升序排列键列的表中,`UserID` 列的压缩比显著更高。 +我们可以看到,对于按基数升序排列键列的表,`UserID` 列的压缩比显著更高。 -尽管在两个表中存储的数据完全相同(我们在两个表中插入了 887 万行),但复合主键中键列的顺序对表的 [列数据文件](#data-is-stored-on-disk-ordered-by-primary-key-columns) 所需的压缩数据的磁盘空间有显著影响: -- 在带有复合主键 `(URL, UserID, IsRobot)` 的表 `hits_URL_UserID_IsRobot` 中,我们按基数降序排列键列,`UserID.bin` 数据文件占用 **11.24 MiB** 磁盘空间 -- 在带有复合主键 `(IsRobot, UserID, URL)` 的表 `hits_IsRobot_UserID_URL` 中,我们按基数升序排列键列,`UserID.bin` 数据文件仅占用 **877.47 KiB** 磁盘空间 +尽管在两个表中存储的完全相同的数据(我们在两个表中插入了相同的 887 万行),但复合主键中键列的顺序对表的 [列数据文件](#data-is-stored-on-disk-ordered-by-primary-key-columns) 中 压缩 数据所需的磁盘空间有显著影响: +- 在复合主键为 `(URL, UserID, IsRobot)` 的表 `hits_URL_UserID_IsRobot` 中,我们按基数降序排列键列,`UserID.bin` 数据文件占用 **11.24 MiB** 的磁盘空间 +- 在复合主键为 `(IsRobot, UserID, URL)` 的表 `hits_IsRobot_UserID_URL` 中,我们按基数升序排列键列,`UserID.bin` 数据文件仅占用 **877.47 KiB** 的磁盘空间 -为了提高表列在磁盘上的数据压缩比,不仅能节省磁盘空间,还能使读取该列的数据的查询(尤其是分析查询)更快,因为从磁盘到主内存(操作系统的文件缓存)移动列数据所需的 I/O 更少。 +对于表中某列的数据在磁盘上具有良好的压缩比,不仅可以节省磁盘空间,还可以加快需要从该列读取数据的查询(尤其是分析性查询),因为从磁盘将该列的数据移动到主内存(操作系统的文件缓存)所需的 I/O 更少。 -接下来我们说明为什么按基数升序排列主键列对表的列的压缩比是有益的。 +在接下来的内容中,我们将说明为什么按基数升序排列主键列有利于表中列的压缩比。 -下图展示了主键中按基数升序排列的行在磁盘上的顺序: +下面的图示描绘了主键的行在磁盘上的顺序,其中键列按基数升序排列: Sparse Primary Indices 14a -我们讨论过 [表的行数据在磁盘上以主键列的顺序存储](#data-is-stored-on-disk-ordered-by-primary-key-columns)。 +我们讨论过 [表的行数据是在磁盘上按主键列的顺序存储的](#data-is-stored-on-disk-ordered-by-primary-key-columns)。 -在上面的图中,表的行(它们在磁盘上的列值)首先按其 `cl` 值排序,对于具有相同 `cl` 值的行按其 `ch` 值排序。由于第一个键列 `cl` 的基数较低,可能会有具有相同 `cl` 值的行。因此,`ch` 值通常也是有序的(在本地 - 对于具有相同 `cl` 值的行)。 +在上面的图中,表的行(它们在磁盘上的列值)首先按其 `cl` 值排序,具有相同 `cl` 值的行按其 `ch` 值排序。由于第一个键列 `cl` 的基数较低,因此很可能存在具有相同 `cl` 值的行。因此,由于这个原因,`ch` 值也可能是有序的(本地 - 对于具有相同 `cl` 值的行)。 -如果在一列中,相似的数据相互靠近,例如通过排序,那么该数据将被更好地压缩。 -一般而言,压缩算法受益于数据的运行长度(它看到的数据越多,压缩效果越好)和局部性(数据越相似,压缩比越好)。 +如果在某列中,相似的数据彼此靠近,例如通过排序,那么这些数据的压缩效果会更好。 +通常,压缩算法受益于数据的重复长度(数据量越大,压缩效果越好) +和局部性(数据越相似,压缩比越好)。 -与上面的图相对,下面的图展示了主键中按基数降序排列的行在磁盘上的顺序: +与上面的图示相比,下面的图示描绘了主键的行在磁盘上的顺序,其中键列按基数降序排列: Sparse Primary Indices 14b -现在,表的行首先按其 `ch` 值排序,对于具有相同 `ch` 值的行按其 `cl` 值排序。 -但由于第一个键列 `ch` 的基数较高,不太可能会有具有相同 `ch` 值的行。因此,这使得 `cl` 值的排序(在本地 - 对于具有相同 `ch` 值的行)也不太可能。 +现在,表的行首先按其 `ch` 值排序,具有相同 `ch` 值的行按其 `cl` 值排序。 +但是,由于第一个键列 `ch` 的基数较高,因此可能不存在具有相同 `ch` 值的行。因此,由于这个原因,`cl` 值也不太可能是有序的(本地 - 对于具有相同 `ch` 值的行)。 -因此,`cl` 值很可能是随机顺序的,因此其局部性和压缩比都较差。 +因此,`cl` 值很可能是随机顺序,因此局部性差,以至于压缩比也变得很差。 ### 摘要 {#summary-1} -对于查询中二级键列的高效过滤和表的列数据文件的压缩比,将主键中的列按基数升序排列是有益的。 +对于查询中对次级键列的高效过滤和表的列数据文件的压缩比,将主键中的列按基数升序排列是有益的。 ## 高效识别单行 {#identifying-single-rows-efficiently} -尽管从一般来说,这不是 [ClickHouse](https://clickhouse.com/docs/knowledgebase/key-value) 的最佳用例, -但有时构建在 ClickHouse 之上的应用需要识别 ClickHouse 表中的单行。 +尽管一般来说这不是 [ClickHouse 的最佳用例](/knowledgebase/key-value),但有时在 ClickHouse 上构建的应用程序需要识别 ClickHouse 表的单行。 -直观的解决方案可能是使用 [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier) 列,每行有一个唯一值,并将该列用作主键列以快速检索行。 +一个直观的解决方案可能是使用一个具有唯一值的 [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier) 列,并将该列用作主键列以快速检索行。 为了实现最快的检索,UUID 列 [需要是第一个键列](#the-primary-index-is-used-for-selecting-granules)。 -我们讨论过,由于 [ClickHouse 表的行数据在磁盘上按主键列的顺序存储](#data-is-stored-on-disk-ordered-by-primary-key-columns),在主键或复合主键中将高基数列(如 UUID 列)放在基数较低的列之前 [不利于其他表列的压缩比](#optimal-compression-ratio-of-data-files)。 +我们讨论过,由于 [ClickHouse 表的行数据是在磁盘上按主键列存储的](#data-is-stored-on-disk-ordered-by-primary-key-columns),在主键或复合主键中具有非常高基数的列(比如 UUID 列)在低基数列之前 [对其他表列的压缩比是有害的](#optimal-compression-ratio-of-data-files)。 -在最快的检索与最佳数据压缩之间的折衷是使用一个复合主键,其中 UUID 是最后一个键列,放置在用于确保表某些列良好压缩比的基数较低的键列之后。 +在最快检索和最佳数据压缩之间的折中是在复合主键中使用 UUID 作为最后一个键列,在低(或较低)基数键列之后,这些列用于确保一些表列的良好压缩比。 ### 一个具体示例 {#a-concrete-example} -一个具体示例是明文粘贴服务 [https://pastila.nl](https://pastila.nl),由 Alexey Milovidov 开发并 [博客写过](https://clickhouse.com/blog/building-a-paste-service-with-clickhouse/)。 +一个具体示例是纯文本粘贴服务 [https://pastila.nl](https://pastila.nl),由 Alexey Milovidov 开发并 [博文介绍](https://clickhouse.com/blog/building-a-paste-service-with-clickhouse/)。 -在文本区域发生每次更改时,数据自动保存到 ClickHouse 表的行中(每次更改一行)。 +每次更改文本区域时,数据都会自动保存到 ClickHouse 表的行中(每次更改一行)。 -识别和检索(特定版本的)粘贴内容的一种方法是将内容哈希作为包含内容的表行的 UUID。 +一种识别和检索(特定版本的)粘贴内容的方法是使用内容的哈希作为包含该内容的表行的 UUID。 -下图显示 -- 内容更改时(例如,由用户在文本区域中键入文本时)行的插入顺序,以及 -- 当使用 `PRIMARY KEY (hash)` 时插入行的数据在磁盘上的存储顺序: +下图展示了 +- 当内容发生变化时行的插入顺序(例如,通过在文本区域中输入文本的按键)以及 +- 使用 `PRIMARY KEY (hash)` 时插入行的数据在磁盘上的顺序: Sparse Primary Indices 15a -由于 `hash` 列用作主键列 -- 可以 [非常快速地](#the-primary-index-is-used-for-selecting-granules) 检索特定行,但 -- 表的行(它们的列数据)在磁盘上按(唯一且随机的)哈希值升序存储。因此,内容列的值也随机存储,没有数据局部性,导致 **内容列数据文件的压缩比次优**。 +因为 `hash` 列被用作主键列, +- 特定行可以 [非常快速地](#the-primary-index-is-used-for-selecting-granules) 检索,但 +- 表的行(它们的列数据)在磁盘上按(唯一和随机的)哈希值按升序存储。因此,内容列的值也以随机顺序存储,导致 **内容列数据文件的压缩比不理想**。 -为了显著提高内容列的压缩比,同时仍保持快速检索特定行,pastila.nl 使用两个哈希(和一个复合主键)来识别特定行: -- 如上所述的内容哈希,对于不同的数据是不同的,和 -- 一种 [局部敏感哈希(指纹)](https://en.wikipedia.org/wiki/Locality-sensitive_hashing),在数据小变更时 **不** 改变。 +为了在保持对特定行的快速检索的同时显著提高内容列的压缩比,pastila.nl 使用了两个哈希(和一个复合主键)来标识特定行: +- 上述讨论的内容哈希,对于不同数据是不同的, +- 一个 [局部敏感哈希(指纹)](https://en.wikipedia.org/wiki/Locality-sensitive_hashing),在数据发生小变化时 **不会** 改变。 -下图显示 -- 内容发生更改时(例如,由用户在文本区域中键入文本时)行的插入顺序,以及 -- 当使用复合 `PRIMARY KEY (fingerprint, hash)` 时插入行的数据在磁盘上的存储顺序: +下图展示了 +- 当内容发生变化时行的插入顺序(例如,通过在文本区域中输入文本的按键)以及 +- 使用复合 `PRIMARY KEY (fingerprint, hash)` 时插入行的数据在磁盘上的顺序: Sparse Primary Indices 15b -此时,行在磁盘上首先按 `fingerprint` 排序,对于具有相同指纹值的行,其 `hash` 值决定了最终顺序。 +现在,磁盘上的行首先按 `fingerprint` 排序,对于具有相同指纹值的行,它们的 `hash` 值决定了最终顺序。 -由于数据仅因小变化而不同,因此获得相同指纹值的相似数据现在在内容列中彼此靠近存储。这对内容列的压缩比是非常有利的,因为压缩算法通常受益于数据的局部性(数据越相似,压缩比越好)。 +由于仅在小变化中有所不同的数据得到相同指纹值,因此相似的数据现在在内容列的磁盘上近似存储。这对内容列的压缩比是很有利的,因为压缩算法通常受益于数据的局部性(数据越相似,压缩比越好)。 -折衷是需要两个字段(`fingerprint` 和 `hash`)来检索特定行,以最佳利用由复合 `PRIMARY KEY (fingerprint, hash)` 产生的主索引。 +其折中是需要两个字段(`fingerprint` 和 `hash`)才能在最优地利用复合 `PRIMARY KEY (fingerprint, hash)` 产生的主索引来检索特定行。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/sparse-primary-indexes.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/sparse-primary-indexes.md.hash index 7566be908e1..3cbd00a8ad3 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/sparse-primary-indexes.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/best-practices/sparse-primary-indexes.md.hash @@ -1 +1 @@ -f397530f2221af39 +86aea05fb02e28e1 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/creating-tables.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/creating-tables.md index e781fd1c078..75277b37366 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/creating-tables.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/creating-tables.md @@ -1,9 +1,10 @@ --- 'sidebar_position': 1 'sidebar_label': '创建表' -'title': '在ClickHouse中创建表' +'title': '在 ClickHouse 中创建表' 'slug': '/guides/creating-tables' -'description': '了解在ClickHouse中创建表' +'description': '了解在 ClickHouse 中创建表' +'doc_type': 'guide' --- @@ -15,7 +16,7 @@ CREATE DATABASE IF NOT EXISTS helloworld ``` -同样,使用 `CREATE TABLE` 来定义一个新表。如果不指定数据库名称,则表将在 `default` 数据库中。 +同样,使用 `CREATE TABLE` 定义一个新表。如果不指定数据库名称,则表将位于 `default` 数据库中。 以下名为 `my_first_table` 的表是在 `helloworld` 数据库中创建的: @@ -33,32 +34,32 @@ PRIMARY KEY (user_id, timestamp) 在上述示例中,`my_first_table` 是一个 `MergeTree` 表,包含四列: -- `user_id`:一个 32 位无符号整数 -- `message`:一个 `String` 数据类型,替代了其他数据库系统中的 `VARCHAR`、`BLOB`、`CLOB` 等类型 -- `timestamp`:一个 `DateTime` 值,表示一个时间点 -- `metric`:一个 32 位浮点数 +- `user_id`: 一个 32 位无符号整数 +- `message`: `String` 数据类型,替代了其他数据库系统中的 `VARCHAR`、`BLOB`、`CLOB` 等类型 +- `timestamp`: 一个 `DateTime` 值,表示一个时间点 +- `metric`: 一个 32 位浮点数 :::note -表引擎决定了: -- 数据如何存储以及存储在哪里 +表引擎决定: +- 数据是如何及存储在哪里 - 支持哪些查询 -- 数据是否被复制 +- 数据是否复制 -有许多引擎可供选择,但对于单节点 ClickHouse 服务器上的简单表, [MergeTree](/engines/table-engines/mergetree-family/mergetree.md) 可能是您的首选。 +可以选择多种引擎,但对于单节点 ClickHouse 服务器上的简单表而言,[MergeTree](/engines/table-engines/mergetree-family/mergetree.md) 是您可能的选择。 ::: -## 主键简要介绍 {#a-brief-intro-to-primary-keys} +## 对主键的简要介绍 {#a-brief-intro-to-primary-keys} -在您继续之前,重要的是要理解 ClickHouse 中主键的工作原理(主键的实现可能会让人感到意外!): +在继续之前,了解 ClickHouse 中主键的工作原理非常重要(主键的实现可能看起来有些意外!): -- ClickHouse 中的主键对于表中的每一行 **_不是唯一的_** +- ClickHouse 中的主键对表中的每一行 **_不是唯一的_** -ClickHouse 表的主键决定了数据在写入磁盘时的排序方式。每 8,192 行或 10MB 数据(称为 **索引粒度**)会在主键索引文件中创建一个条目。该粒度概念创建了一个 **稀疏索引**,可以轻松装入内存,粒度表示在 `SELECT` 查询中处理的最小列数据量的条带。 +ClickHouse 表的主键决定了数据写入磁盘时的排序方式。每 8,192 行或 10MB 的数据(称为 **索引粒度**)在主键索引文件中创建一个条目。这个粒度概念创建了一个 **稀疏索引**,可以轻松适应内存,并且这些粒度表示在 `SELECT` 查询中处理的列数据的最小量条带。 -可以使用 `PRIMARY KEY` 参数定义主键。如果您定义的表未指定 `PRIMARY KEY`,则键将成为 `ORDER BY` 子句中指定的元组。如果同时指定了 `PRIMARY KEY` 和 `ORDER BY`,则主键必须是排序顺序的前缀。 +可以使用 `PRIMARY KEY` 参数定义主键。如果您定义一个没有指定 `PRIMARY KEY` 的表,则主键将成为 `ORDER BY` 子句中指定的元组。如果同时指定 `PRIMARY KEY` 和 `ORDER BY`,则主键必须是排序顺序的前缀。 -主键也是排序键,它是一个 `(user_id, timestamp)` 的元组。因此,存储在每个列文件中的数据将按 `user_id` 然后 `timestamp` 排序。 +主键也是排序键,元组为 `(user_id, timestamp)`。因此,存储在每个列文件中的数据将按 `user_id` 排序,然后按 `timestamp` 排序。 :::tip -有关更多详细信息,请查看 ClickHouse Academy 中的 [建模数据培训模块](https://learn.clickhouse.com/visitor_catalog_class/show/1328860/?utm_source=clickhouse&utm_medium=docs)。 +有关更多详细信息,请查看 ClickHouse 学院中的 [建模数据培训模块](https://learn.clickhouse.com/visitor_catalog_class/show/1328860/?utm_source=clickhouse&utm_medium=docs)。 ::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/creating-tables.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/creating-tables.md.hash index fafce972029..5ee8aa71323 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/creating-tables.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/creating-tables.md.hash @@ -1 +1 @@ -e3e8153db2c85077 +eab43da8bcb16150 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/alternative-query-languages.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/alternative-query-languages.md index 24324ab2623..2d0ea8902f9 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/alternative-query-languages.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/alternative-query-languages.md @@ -3,15 +3,16 @@ 'sidebar_label': '替代查询语言' 'title': '替代查询语言' 'description': '在 ClickHouse 中使用替代查询语言' +'doc_type': 'reference' --- import ExperimentalBadge from '@theme/badges/ExperimentalBadge'; -除了标准 SQL,ClickHouse 还支持各种替代查询语言来查询数据。 +除了标准 SQL,ClickHouse 还支持多种替代查询语言来查询数据。 当前支持的方言有: - `clickhouse`:ClickHouse 的默认 [SQL 方言](../../chdb/reference/sql-reference.md) -- `prql`:[管道关系查询语言 (PRQL)](https://prql-lang.org/) +- `prql`:[管道化关系查询语言 (PRQL)](https://prql-lang.org/) - `kusto`:[Kusto 查询语言 (KQL)](https://learn.microsoft.com/en-us/azure/data-explorer/kusto/query) 使用哪种查询语言由设置 `dialect` 控制。 @@ -24,7 +25,7 @@ import ExperimentalBadge from '@theme/badges/ExperimentalBadge'; SET dialect = 'clickhouse' ``` -## 管道关系查询语言 (PRQL) {#pipelined-relational-query-language-prql} +## 管道化关系查询语言 (PRQL) {#pipelined-relational-query-language-prql} @@ -45,7 +46,7 @@ aggregate { } ``` -在底层,ClickHouse 使用从 PRQL 到 SQL 的转译来运行 PRQL 查询。 +实际上,ClickHouse 使用从 PRQL 到 SQL 的转译来运行 PRQL 查询。 ## Kusto 查询语言 (KQL) {#kusto-query-language-kql} diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/alternative-query-languages.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/alternative-query-languages.md.hash index 0389a064406..4a9649eeefd 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/alternative-query-languages.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/alternative-query-languages.md.hash @@ -1 +1 @@ -f625c965ebdaf7af +702866fdeba92c64 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/cascading-materialized-views.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/cascading-materialized-views.md index 99b2c794851..1ea32df822f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/cascading-materialized-views.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/cascading-materialized-views.md @@ -1,41 +1,42 @@ --- 'slug': '/guides/developer/cascading-materialized-views' 'title': '级联物化视图' -'description': '如何使用多个物化视图从一个源表.' +'description': '如何使用来自源表的多个物化视图。' 'keywords': - 'materialized view' - 'aggregation' +'doc_type': 'guide' --- # 级联物化视图 -此示例演示如何创建一个物化视图,然后如何将第二个物化视图级联到第一个视图。在这一页中,您将看到如何做到这一点、许多可能性以及限制。通过使用第二个物化视图作为源,您可以回答不同的用例。 +本示例演示如何创建物化视图,然后如何在第一个物化视图上级联第二个物化视图。在本页面中,您将看到如何实现这一点,许多可能性,以及限制。通过使用第二个物化视图作为源创建物化视图,可以满足不同的用例。 - +
示例: -我们将使用一个虚拟数据集,记录一组域名每小时的视图数量。 +我们将使用一组虚假的数据集,记录一组域名每小时的访问量。 我们的目标 -1. 我们需要按月对每个域名的数据进行聚合, -2. 我们还需要按年对每个域名的数据进行聚合。 +1. 我们需要按月汇总每个域名的数据, +2. 我们还需要按年汇总每个域名的数据。 您可以选择以下选项之一: -- 编写查询,在 SELECT 请求期间读取和聚合数据 -- 在摄取时将数据准备为新的格式 -- 在摄取时将数据准备为特定的聚合格式。 +- 编写查询,在 SELECT 请求期间读取和汇总数据 +- 在数据摄取时准备数据为新格式 +- 在摄取时准备数据进行特定汇总。 -使用物化视图准备数据将使您能够限制 ClickHouse 需要处理的数据量和计算,从而加快 SELECT 请求的速度。 +使用物化视图准备数据将使您限制 ClickHouse 需要处理的数据和计算量,从而加快 SELECT 请求的速度。 ## 物化视图的源表 {#source-table-for-the-materialized-views} -创建源表,因为我们的目标涉及对聚合数据进行报告,而不是对单个行进行报告,我们可以解析它,将信息传递给物化视图,并丢弃实际的输入数据。这满足了我们的目标并节省了存储,因此我们将使用 `Null` 表引擎。 +创建源表,因为我们的目标涉及对汇总数据进行报告,而非单独的行,我们可以解析数据,将信息传递给物化视图,并丢弃实际的输入数据。这符合我们的目标,并节省存储空间,因此我们将使用 `Null` 表引擎。 ```sql CREATE DATABASE IF NOT EXISTS analytics; @@ -52,12 +53,12 @@ ENGINE = Null ``` :::note -您可以在 Null 表上创建物化视图。因此,写入该表的数据将影响视图,但原始原始数据仍将被丢弃。 +您可以在 Null 表上创建物化视图。因此,写入表中的数据将影响视图,但原始的原始数据将仍然被丢弃。 ::: -## 按月聚合的表和物化视图 {#monthly-aggregated-table-and-materialized-view} +## 按月汇总的表和物化视图 {#monthly-aggregated-table-and-materialized-view} -对于第一个物化视图,我们需要创建 `Target` 表,在本示例中,它将是 `analytics.monthly_aggregated_data`,我们将按月和域名存储视图的总和。 +对于第一个物化视图,我们需要创建名为 `Target` 的表,在本示例中,它将是 `analytics.monthly_aggregated_data`,我们将按月和域名存储访问量的总和。 ```sql CREATE TABLE analytics.monthly_aggregated_data @@ -86,11 +87,11 @@ GROUP BY month ``` -## 按年聚合的表和物化视图 {#yearly-aggregated-table-and-materialized-view} +## 按年汇总的表和物化视图 {#yearly-aggregated-table-and-materialized-view} 现在我们将创建第二个物化视图,它将链接到我们之前的目标表 `monthly_aggregated_data`。 -首先,我们将创建一个新目标表,该表将存储按年聚合的每个域名的视图总和。 +首先,我们将创建一个新的目标表,用于存储按年汇总的每个域名的访问量总和。 ```sql CREATE TABLE analytics.year_aggregated_data @@ -103,11 +104,11 @@ ENGINE = SummingMergeTree() ORDER BY (domain_name, year) ``` -此步骤定义了级联。`FROM` 语句将使用 `monthly_aggregated_data` 表,这意味着数据流将是: +这一步定义了级联。`FROM` 语句将使用 `monthly_aggregated_data` 表,这意味着数据流将是: -1. 数据发送到 `hourly_data` 表。 -2. ClickHouse 将把接收到的数据转发到第一个物化视图 `monthly_aggregated_data` 表, -3. 最后,步骤 2 中接收到的数据将被转发到 `year_aggregated_data`。 +1. 数据进入 `hourly_data` 表。 +2. ClickHouse 将转发收到的数据到第一个物化视图 `monthly_aggregated_data` 表, +3. 最后,第二步中收到的数据将转发到 `year_aggregated_data`。 ```sql CREATE MATERIALIZED VIEW analytics.year_aggregated_data_mv @@ -116,7 +117,7 @@ AS SELECT toYear(toStartOfYear(month)) AS year, domain_name, - sumMerge(sumCountViews) as sumCountViews + sumMerge(sumCountViews) AS sumCountViews FROM analytics.monthly_aggregated_data GROUP BY domain_name, @@ -124,16 +125,16 @@ GROUP BY ``` :::note -在使用物化视图时,一个常见的误解是数据是从表中读取的。实际上,`物化视图` 的工作方式并非如此;转发的数据是插入的块,而不是表中的最终结果。 +在使用物化视图时,一个常见的误解是数据是从表中读取的,物化视图并不是这样工作的;转发的数据是插入的块,而不是表中的最终结果。 -假设在本示例中,`monthly_aggregated_data` 使用的引擎是 CollapsingMergeTree,被转发到我们第二个物化视图 `year_aggregated_data_mv` 的数据将不是已合并表的最终结果,而是转发的包含字段的块,如在 `SELECT ... GROUP BY` 中定义的那样。 +我们假设在这个示例中,`monthly_aggregated_data` 中使用的引擎是 CollapsingMergeTree,转发到我们第二个物化视图 `year_aggregated_data_mv` 的数据不会是已合并表的最终结果,而是转发带有在 `SELECT ... GROUP BY` 中定义的字段的数据块。 -如果您使用 CollapsingMergeTree、ReplacingMergeTree,甚至 SummingMergeTree,并打算创建级联物化视图,则需要理解此处描述的限制。 +如果您使用 CollapsingMergeTree、ReplacingMergeTree,甚至 SummingMergeTree,并计划创建级联的物化视图,您需要了解这里描述的限制。 ::: ## 示例数据 {#sample-data} -现在是通过插入一些数据来测试我们的级联物化视图的时刻: +现在是通过插入一些数据来测试我们的级联物化视图的时候了: ```sql INSERT INTO analytics.hourly_data (domain_name, event_time, count_views) @@ -143,7 +144,7 @@ VALUES ('clickhouse.com', '2019-01-01 10:00:00', 1), ('clickhouse.com', '2020-01-01 00:00:00', 6); ``` -如果您选择 `analytics.hourly_data` 的内容,您将看到如下所示,因为表引擎是 `Null`,但数据已经被处理。 +如果您选择 `analytics.hourly_data` 的内容,您将看到以下内容,因为表引擎是 `Null`,但数据已经被处理。 ```sql SELECT * FROM analytics.hourly_data @@ -155,14 +156,14 @@ Ok. 0 rows in set. Elapsed: 0.002 sec. ``` -我们使用了一个小型数据集,以确保我们能够跟踪并比较结果与我们的预期。一旦您的流量在小型数据集上是正确的,您可以直接移动到大量数据。 +我们使用了一个小数据集,以确保可以跟踪并与预期结果进行比较,一旦您的流程与小数据集正确,您可以转向大量数据。 ## 结果 {#results} -如果您尝试通过选择 `sumCountViews` 字段来查询目标表,您将看到二进制表示(在某些终端中),因为该值未作为数字存储,而是作为 AggregateFunction 类型存储。 -要获取聚合的最终结果,您应该使用 `-Merge` 后缀。 +如果您尝试通过选择 `sumCountViews` 字段来查询目标表,您将在某些终端中看到二进制表示,因为该值不是以数字存储,而是以 AggregateFunction 类型存储。 +要获得汇总的最终结果,您应该使用 `-Merge` 后缀。 -您可以使用此查询查看存储在 AggregateFunction 中的特殊字符: +您可以使用以下查询查看存储在 AggregateFunction 中的特殊字符: ```sql SELECT sumCountViews FROM analytics.monthly_aggregated_data @@ -178,11 +179,11 @@ SELECT sumCountViews FROM analytics.monthly_aggregated_data 3 rows in set. Elapsed: 0.003 sec. ``` -相反,让我们尝试使用 `Merge` 后缀来获取 `sumCountViews` 值: +相反,尝试使用 `Merge` 后缀来获取 `sumCountViews` 值: ```sql SELECT - sumMerge(sumCountViews) as sumCountViews + sumMerge(sumCountViews) AS sumCountViews FROM analytics.monthly_aggregated_data; ``` @@ -194,28 +195,28 @@ FROM analytics.monthly_aggregated_data; 1 row in set. Elapsed: 0.003 sec. ``` -在 `AggregatingMergeTree` 中,我们已将 `AggregateFunction` 定义为 `sum`,因此可以使用 `sumMerge`。当我们在 `AggregateFunction` 上使用函数 `avg` 时,我们将使用 `avgMerge`,以此类推。 +在 `AggregatingMergeTree` 中,我们将 `AggregateFunction` 定义为 `sum`,因此我们可以使用 `sumMerge`。当我们对 `AggregateFunction` 使用函数 `avg` 时,将使用 `avgMerge`,依此类推。 ```sql SELECT month, domain_name, - sumMerge(sumCountViews) as sumCountViews + sumMerge(sumCountViews) AS sumCountViews FROM analytics.monthly_aggregated_data GROUP BY domain_name, month ``` -现在我们可以检查物化视图是否满足我们定义的目标。 +现在我们可以审核物化视图是否满足我们定义的目标。 -现在我们在目标表 `monthly_aggregated_data` 中存储了数据,我们可以获取每个域名按月聚合的数据: +现在,数据已存储在目标表 `monthly_aggregated_data` 中,我们可以获取按月汇总的每个域名的数据: ```sql SELECT month, domain_name, - sumMerge(sumCountViews) as sumCountViews + sumMerge(sumCountViews) AS sumCountViews FROM analytics.monthly_aggregated_data GROUP BY domain_name, @@ -232,7 +233,7 @@ GROUP BY 3 rows in set. Elapsed: 0.004 sec. ``` -每个域名按年聚合的数据: +按年汇总的每个域名的数据: ```sql SELECT @@ -254,12 +255,11 @@ GROUP BY 2 rows in set. Elapsed: 0.004 sec. ``` +## 将多个源表合并为单个目标表 {#combining-multiple-source-tables-to-single-target-table} -## 将多个源表合并到单个目标表 {#combining-multiple-source-tables-to-single-target-table} +物化视图也可以用于将多个源表合并到同一个目标表。这对于创建与 `UNION ALL` 逻辑相似的物化视图非常有用。 -物化视图也可以用于将多个源表合并到同一目标表中。这对于创建类似于 `UNION ALL` 逻辑的物化视图非常有用。 - -首先,创建两个源表,表示不同的指标集合: +首先,创建两个源表,表示不同的指标集: ```sql CREATE TABLE analytics.impressions @@ -277,7 +277,7 @@ CREATE TABLE analytics.clicks ; ``` -然后创建带有组合指标集的 `Target` 表: +然后创建带有合并指标集的 `Target` 表: ```sql CREATE TABLE analytics.daily_overview @@ -289,7 +289,7 @@ CREATE TABLE analytics.daily_overview ) ENGINE = AggregatingMergeTree ORDER BY (on_date, domain_name) ``` -创建两个指向相同 `Target` 表的物化视图。您不需要明确包含缺失的列: +创建两个指向相同 `Target` 表的物化视图。您不需要显式包含缺失的列: ```sql CREATE MATERIALIZED VIEW analytics.daily_impressions_mv @@ -323,7 +323,7 @@ GROUP BY ; ``` -现在,当您插入值时,这些值将被聚合到 `Target` 表的各自列中: +现在,当您插入值时,这些值将聚合到 `Target` 表中的相应列中: ```sql INSERT INTO analytics.impressions (domain_name, event_time) @@ -340,7 +340,7 @@ VALUES ('clickhouse.com', '2019-01-01 00:00:00'), ; ``` -在 `Target` 表中合并的展示次数和点击次数: +`Target` 表中的合并展示和点击: ```sql SELECT @@ -356,7 +356,7 @@ GROUP BY ; ``` -此查询应输出类似如下内容: +该查询应输出类似于: ```response ┌────on_date─┬─domain_name────┬─impressions─┬─clicks─┐ diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/cascading-materialized-views.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/cascading-materialized-views.md.hash index cc1fe633320..178880e126c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/cascading-materialized-views.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/cascading-materialized-views.md.hash @@ -1 +1 @@ -5b0d0dd541852dc1 +36a0576c4bc0f2a4 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/debugging-memory-issues.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/debugging-memory-issues.md index f07444267e7..fdedd45516b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/debugging-memory-issues.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/debugging-memory-issues.md @@ -2,16 +2,17 @@ 'slug': '/guides/developer/debugging-memory-issues' 'sidebar_label': '调试内存问题' 'sidebar_position': 1 -'description': '查询以帮助您调试内存问题。' +'description': '查询帮助您调试内存问题。' 'keywords': - 'memory issues' 'title': '调试内存问题' +'doc_type': 'guide' --- # 调试内存问题 {#debugging-memory-issues} -当遇到内存问题或内存泄漏时,了解哪些查询和资源正在消耗大量内存是非常有帮助的。下面您可以找到一些查询,它们可以帮助您通过查找哪些查询、数据库和表可以优化来调试内存问题: +在遇到内存问题或内存泄漏时,了解哪些查询和资源占用了大量内存是非常有帮助的。以下是一些查询,可以帮助您通过查找哪些查询、数据库和表可以进行优化来调试内存问题: ## 按峰值内存使用列出当前运行的进程 {#list-currently-running-processes-by-peak-memory} @@ -35,13 +36,13 @@ SELECT FROM system.asynchronous_metrics WHERE - metric like '%Cach%' - or metric like '%Mem%' -order by - value desc; + metric LIKE '%Cach%' + OR metric LIKE '%Mem%' +ORDER BY + value DESC; ``` -## 按当前内存使用列出表 {#list-tables-by-current-memory-usage} +## 按当前内存使用量列出表 {#list-tables-by-current-memory-usage} ```sql SELECT @@ -58,7 +59,7 @@ WHERE engine IN ('Memory','Set','Join'); SELECT formatReadableSize(sum(memory_usage)) FROM system.merges; ``` -## 输出当前运行进程所使用的总内存 {#output-total-memory-used-by-currently-running-processes} +## 输出当前运行的进程所使用的总内存 {#output-total-memory-used-by-currently-running-processes} ```sql SELECT formatReadableSize(sum(memory_usage)) FROM system.processes; @@ -70,12 +71,14 @@ SELECT formatReadableSize(sum(memory_usage)) FROM system.processes; SELECT formatReadableSize(sum(bytes_allocated)) FROM system.dictionaries; ``` -## 输出主键所使用的总内存 {#output-total-memory-used-by-primary-keys} +## 输出主键和索引粒度所使用的总内存 {#output-total-memory-used-by-primary-keys} ```sql SELECT - sumIf(data_uncompressed_bytes, part_type = 'InMemory') as memory_parts, + sumIf(data_uncompressed_bytes, part_type = 'InMemory') AS memory_parts, formatReadableSize(sum(primary_key_bytes_in_memory)) AS primary_key_bytes_in_memory, - formatReadableSize(sum(primary_key_bytes_in_memory_allocated)) AS primary_key_bytes_in_memory_allocated + formatReadableSize(sum(primary_key_bytes_in_memory_allocated)) AS primary_key_bytes_in_memory_allocated, + formatReadableSize(sum(index_granularity_bytes_in_memory)) AS index_granularity_bytes_in_memory, + formatReadableSize(sum(index_granularity_bytes_in_memory_allocated)) AS index_granularity_bytes_in_memory_allocated FROM system.parts; ``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/debugging-memory-issues.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/debugging-memory-issues.md.hash index 9f6346e176c..1f9f83a93ca 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/debugging-memory-issues.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/debugging-memory-issues.md.hash @@ -1 +1 @@ -6922a935d709913b +d7cd8ebdacbcad5d diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/deduplicating-inserts-on-retries.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/deduplicating-inserts-on-retries.md index 24970346a25..fd9843bbc81 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/deduplicating-inserts-on-retries.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/deduplicating-inserts-on-retries.md @@ -1,57 +1,69 @@ --- 'slug': '/guides/developer/deduplicating-inserts-on-retries' -'title': '去重插入失败重试' +'title': '去重插入操作的重试' 'description': '在重试插入操作时防止重复数据' 'keywords': - 'deduplication' - 'deduplicate' - 'insert retries' - 'inserts' +'doc_type': 'guide' --- -插入操作有时可能因超时等错误而失败。当插入失败时,数据可能已成功插入,也可能没有。 本指南介绍如何在插入重试时启用去重,以确保相同数据不会被插入多次。 +插入操作有时可能由于超时等错误而失败。当插入失败时,数据可能已成功插入,也可能未成功插入。本指南介绍了如何在插入重试时启用去重,以确保相同的数据不会被插入多次。 -当插入被重试时,ClickHouse会尝试确定数据是否已经成功插入。如果插入的数据被标记为重复,ClickHouse将不会将其插入到目标表中。然而,用户仍然会收到一个成功的操作状态,就好像数据已正常插入一样。 +当插入被重试时,ClickHouse 尝试确定数据是否已成功插入。如果插入的数据被标记为重复,ClickHouse 不会将其插入目标表中。但是,用户仍然会收到一条成功的操作状态,仿佛数据是正常插入的。 -## 启用重试时插入去重 {#enabling-insert-deduplication-on-retries} +## 限制 {#limitations} + +### 不确定的插入状态 {#uncertain-insert-status} + +用户必须重试插入操作,直到成功为止。如果所有重试都失败,则无法确定数据是否已插入。当涉及物化视图时,也不清楚数据可能出现在什么表中。物化视图可能与源表不同步。 + +### 去重窗口限制 {#deduplication-window-limit} + +如果在重试序列中发生超过 `*_deduplication_window` 的其他插入操作,去重可能无法按预期工作。在这种情况下,相同的数据可以被插入多次。 + +## 在重试时启用插入去重 {#enabling-insert-deduplication-on-retries} ### 表的插入去重 {#insert-deduplication-for-tables} -**仅支持 `*MergeTree` 引擎的插入去重。** +**只有 `*MergeTree` 引擎支持插入时去重。** -对于 `*ReplicatedMergeTree` 引擎,插入去重默认启用,并由 [`replicated_deduplication_window`](/operations/settings/merge-tree-settings#replicated_deduplication_window) 和 [`replicated_deduplication_window_seconds`](/operations/settings/merge-tree-settings#replicated_deduplication_window_seconds) 设置进行控制。对于非复制的 `*MergeTree` 引擎,去重由 [`non_replicated_deduplication_window`](/operations/settings/merge-tree-settings#non_replicated_deduplication_window) 设置进行控制。 +对于 `*ReplicatedMergeTree` 引擎,插入去重默认为启用,并由 [`replicated_deduplication_window`](/operations/settings/merge-tree-settings#replicated_deduplication_window) 和 [`replicated_deduplication_window_seconds`](/operations/settings/merge-tree-settings#replicated_deduplication_window_seconds) 设置控制。对于非复制的 `*MergeTree` 引擎,去重由 [`non_replicated_deduplication_window`](/operations/settings/merge-tree-settings#non_replicated_deduplication_window) 设置控制。 -上述设置确定表的去重日志的参数。去重日志存储有限数量的 `block_id`,这决定了去重的工作方式(见下文)。 +上述设置决定了表的去重日志的参数。去重日志存储有限数量的 `block_id`,这些 `block_id` 决定了去重的工作方式(见下文)。 ### 查询级别的插入去重 {#query-level-insert-deduplication} -设置 `insert_deduplicate=1` 在查询级别启用去重。请注意,如果您以 `insert_deduplicate=0` 插入数据,则即使您使用 `insert_deduplicate=1` 重试插入,也无法对该数据进行去重。这是因为在使用 `insert_deduplicate=0` 进行插入时不会为块写入 `block_id`。 +设置 `insert_deduplicate=1` 在查询级别启用去重。请注意,如果您使用 `insert_deduplicate=0` 插入数据,则即使您重试插入时设置为 `insert_deduplicate=1`,该数据也无法去重。这是因为在使用 `insert_deduplicate=0` 插入时未为块写入 `block_id`。 ## 插入去重的工作原理 {#how-insert-deduplication-works} -当数据插入 ClickHouse 时,它会根据行数和字节数将数据拆分为多个块。 +当数据插入到 ClickHouse 中时,它根据行数和字节将数据拆分为块。 -对于使用 `*MergeTree` 引擎的表,每个块被分配一个唯一的 `block_id`,这是该块数据的哈希值。这个 `block_id` 被用作插入操作的唯一键。如果在去重日志中找到相同的 `block_id`,则该块被视为重复,并且不会插入到表中。 +对于使用 `*MergeTree` 引擎的表,每个块被分配一个唯一的 `block_id`,这是该块数据的哈希值。此 `block_id` 用作插入操作的唯一键。如果在去重日志中找到相同的 `block_id`,则该块被视为重复,不插入表中。 -这种方法在插入包含不同数据的情况下效果良好。然而,如果相同数据被故意插入多次,您需要使用 `insert_deduplication_token` 设置来控制去重过程。该设置允许您为每个插入指定一个唯一的令牌,ClickHouse 用其来判断数据是否是重复的。 +这种方法在插入包含不同数据的情况下效果良好。然而,如果故意多次插入相同的数据,则需要使用设置 `insert_deduplication_token` 来控制去重过程。该设置允许您为每次插入指定一个唯一的令牌,ClickHouse 使用该令牌来确定数据是否为重复。 -对于 `INSERT ... VALUES` 查询,将插入的数据拆分为块是确定性的,并由设置决定。因此,用户应使用与初始操作相同的设置值来重试插入。 +对于 `INSERT ... VALUES` 查询,将插入的数据拆分为块是确定性的,并由设置决定。因此,用户应使用与初始操作相同的设置值重试插入。 -对于 `INSERT ... SELECT` 查询,重要的是查询的 `SELECT` 部分在每次操作中都返回相同的数据且顺序相同。请注意,在实际使用中这很难实现。为了确保重试时数据顺序稳定,请在查询的 `SELECT` 部分定义一个精确的 `ORDER BY` 部分。请记住,选择表可能在重试之间被更新:结果数据可能已更改,去重将不会发生。此外,在插入大量数据的情况下,插入后块的数量可能会超出去重日志窗口,ClickHouse 将无法知道去重块。 +对于 `INSERT ... SELECT` 查询,确保查询的 `SELECT` 部分在每次操作中返回相同的数据且顺序相同是很重要的。请注意,在实际使用中很难实现这一点。为了确保重试时数据顺序稳定,请在查询的 `SELECT` 部分定义精确的 `ORDER BY` 部分。请记住,被选中的表在重试之间可能会被更新:结果数据可能已更改,且不会发生去重。此外,在插入大量数据的情况下,插入后块的数量可能会超出去重日志窗口,ClickHouse 将无法知道去重这些块。 ## 使用物化视图的插入去重 {#insert-deduplication-with-materialized-views} -当表有一个或多个物化视图时,插入的数据也会插入到这些视图的目标中,并应用定义的转换。转换后的数据在重试时也会去重。ClickHouse 对物化视图的去重方式与对插入目标表的数据进行去重的方式相同。 +当一个表有一个或多个物化视图时,插入的数据也会根据定义的转换插入到这些视图的目标中。转换后的数据在重试时也会进行去重。ClickHouse 以与去重插入目标表中的数据相同的方式对物化视图执行去重。 -您可以使用源表的以下设置来控制此过程: +您可以使用以下设置控制这些过程: - [`replicated_deduplication_window`](/operations/settings/merge-tree-settings#replicated_deduplication_window) - [`replicated_deduplication_window_seconds`](/operations/settings/merge-tree-settings#replicated_deduplication_window_seconds) - [`non_replicated_deduplication_window`](/operations/settings/merge-tree-settings#non_replicated_deduplication_window) -您还可以使用用户配置设置 [`deduplicate_blocks_in_dependent_materialized_views`](/operations/settings/settings#deduplicate_blocks_in_dependent_materialized_views)。 +您还必须启用用户配置文件设置 [`deduplicate_blocks_in_dependent_materialized_views`](/operations/settings/settings#deduplicate_blocks_in_dependent_materialized_views)。 +启用设置 `insert_deduplicate=1` 后,在源表中插入的数据会进行去重。设置 `deduplicate_blocks_in_dependent_materialized_views=1` 还可以在依赖表中启用去重。如果希望完全去重,则必须同时启用这两个设置。 -当将块插入物化视图下的表时,ClickHouse 通过对来源表的 `block_id` 和附加标识符进行哈希来计算 `block_id`。 这确保在物化视图中进行准确的去重,即使在达到物化视图下的目标表之前应用了任何转换,数据仍然可以基于其原始插入进行区分。 +在将块插入物化视图下的表时,ClickHouse 通过对来自源表的 `block_id` 和其他标识符的字符串进行哈希来计算 `block_id`。这确保了在物化视图内的准确去重,使数据能够根据其原始插入进行区分,而不管在到达物化视图下的目标表之前应用了什么转换。 ## 示例 {#examples} @@ -59,7 +71,7 @@ 在物化视图内部生成的相同块不会去重,因为它们基于不同的插入数据。 -以下是一个例子: +以下是示例: ```sql CREATE TABLE dst @@ -91,7 +103,7 @@ SET min_insert_block_size_rows=0; SET min_insert_block_size_bytes=0; ``` -上述设置使我们能够从一个表中选择一系列仅包含一行的块。这些小块不会被压缩,并且在插入到表中之前保持相同。 +上述设置允许我们从一个包含只有一行的块系列中选择。这些小块不会被压缩,并且在插入到表中之前保持不变。 ```sql SET deduplicate_blocks_in_dependent_materialized_views=1; @@ -109,7 +121,7 @@ SELECT *, _part FROM dst -ORDER by all; +ORDER BY all; ┌─key─┬─value─┬─_part─────┐ │ 1 │ B │ all_0_0_0 │ @@ -117,14 +129,14 @@ ORDER by all; └─────┴───────┴───────────┘ ``` -在这里我们看到两个部分已插入到 `dst` 表中。来自选择的 2 块 -- 插入时的 2 部分。这些部分包含不同的数据。 +在这里我们看到两个部分已被插入到 `dst` 表中。来自选择的 2 个块 -- 在插入时有 2 个部分。这些部分包含不同的数据。 ```sql SELECT *, _part FROM mv_dst -ORDER by all; +ORDER BY all; ┌─key─┬─value─┬─_part─────┐ │ 0 │ B │ all_0_0_0 │ @@ -132,7 +144,7 @@ ORDER by all; └─────┴───────┴───────────┘ ``` -在这里我们看到有 2 部分已插入到 `mv_dst` 表中。这些部分包含相同的数据,但它们没有被去重。 +在这里我们看到 2 个部分已被插入到 `mv_dst` 表中。这些部分包含相同的数据,但不被去重。 ```sql INSERT INTO dst SELECT @@ -144,7 +156,7 @@ SELECT *, _part FROM dst -ORDER by all; +ORDER BY all; ┌─key─┬─value─┬─_part─────┐ │ 1 │ B │ all_0_0_0 │ @@ -163,9 +175,9 @@ ORDER by all; └─────┴───────┴───────────┘ ``` -在这里我们看到当我们重试插入时,所有数据都被去重。去重在 `dst` 和 `mv_dst` 表中都有效。 +在这里我们看到,当我们重试插入时,所有数据均被去重。去重对于 `dst` 和 `mv_dst` 表均有效。 -### 插入时相同块 {#identical-blocks-on-insertion} +### 插入时的相同块 {#identical-blocks-on-insertion} ```sql CREATE TABLE dst @@ -177,13 +189,12 @@ ENGINE = MergeTree ORDER BY tuple() SETTINGS non_replicated_deduplication_window=1000; - SET max_block_size=1; SET min_insert_block_size_rows=0; SET min_insert_block_size_bytes=0; ``` -插入: +插入操作: ```sql INSERT INTO dst SELECT @@ -196,16 +207,16 @@ SELECT *, _part FROM dst -ORDER by all; +ORDER BY all; ┌─'from dst'─┬─key─┬─value─┬─_part─────┐ │ from dst │ 0 │ A │ all_0_0_0 │ └────────────┴─────┴───────┴───────────┘ ``` -在上述设置下,来自选择的两个块 -- 结果应该是向 `dst` 表插入两个块。然而,我们看到只有一个块被插入到 `dst` 表中。这是因为第二个块已被去重。它具有相同的数据和作为去重键的 `block_id`,该值是从插入的数据中计算的哈希。这个行为与预期不符。这种情况比较少见,但理论上是可能的。为了正确处理此类情况,用户必须提供一个 `insert_deduplication_token`。让我们通过以下示例来修复这个问题: +使用上述设置,选择的结果产生两个块——因此,应该有两个块插入到 `dst` 表中。然而,我们看到只插入到了表 `dst` 中的一个块。这是因为第二个块已被去重。它的数据相同,并且去重的键 `block_id` 是根据插入数据的哈希值计算得出的。这种行为是意外的。这种情况虽然不常见,但理论上是可能的。为了正确处理这种情况,用户必须提供一个 `insert_deduplication_token`。让我们用以下示例来解决这个问题: -### 使用 `insert_deduplication_token` 的插入时相同块 {#identical-blocks-in-insertion-with-insert_deduplication_token} +### 使用 `insert_deduplication_token` 的插入相同块 {#identical-blocks-in-insertion-with-insert_deduplication_token} ```sql CREATE TABLE dst @@ -222,7 +233,7 @@ SET min_insert_block_size_rows=0; SET min_insert_block_size_bytes=0; ``` -插入: +插入操作: ```sql INSERT INTO dst SELECT @@ -236,7 +247,7 @@ SELECT *, _part FROM dst -ORDER by all; +ORDER BY all; ┌─'from dst'─┬─key─┬─value─┬─_part─────┐ │ from dst │ 0 │ A │ all_2_2_0 │ @@ -244,10 +255,10 @@ ORDER by all; └────────────┴─────┴───────┴───────────┘ ``` -两个相同的块按预期插入。 +两个相同的块已按预期插入。 ```sql -select 'second attempt'; +SELECT 'second attempt'; INSERT INTO dst SELECT 0 AS key, @@ -260,7 +271,7 @@ SELECT *, _part FROM dst -ORDER by all; +ORDER BY all; ┌─'from dst'─┬─key─┬─value─┬─_part─────┐ │ from dst │ 0 │ A │ all_2_2_0 │ @@ -268,10 +279,10 @@ ORDER by all; └────────────┴─────┴───────┴───────────┘ ``` -重试插入按预期被去重。 +重试插入如预期般去重。 ```sql -select 'third attempt'; +SELECT 'third attempt'; INSERT INTO dst SELECT 1 AS key, @@ -284,7 +295,7 @@ SELECT *, _part FROM dst -ORDER by all; +ORDER BY all; ┌─'from dst'─┬─key─┬─value─┬─_part─────┐ │ from dst │ 0 │ A │ all_2_2_0 │ @@ -292,9 +303,9 @@ ORDER by all; └────────────┴─────┴───────┴───────────┘ ``` -即使包含不同插入数据,该插入也被去重。请注意,`insert_deduplication_token` 具有更高的优先级:在提供 `insert_deduplication_token` 时,ClickHouse 不会使用数据的哈希和。 +该插入也被去重,尽管它包含了不同的插入数据。请注意,`insert_deduplication_token` 的优先级更高:当提供 `insert_deduplication_token` 时,ClickHouse 不会使用数据的哈希和。 -### 不同插入操作在物化视图底层表中生成相同数据 {#different-insert-operations-generate-the-same-data-after-transformation-in-the-underlying-table-of-the-materialized-view} +### 不同插入操作在物化视图的基础表中经过转换后生成相同数据 {#different-insert-operations-generate-the-same-data-after-transformation-in-the-underlying-table-of-the-materialized-view} ```sql CREATE TABLE dst @@ -376,9 +387,9 @@ ORDER by all; └───────────────┴─────┴───────┴───────────┘ ``` -我们每次插入不同的数据。然而,相同的数据被插入到 `mv_dst` 表中。数据没有去重,因为源数据是不同的。 +我们每次插入不同的数据。然而,相同的数据被插入到 `mv_dst` 表中。数据未被去重,因为源数据不同。 -### 不同的物化视图在一个底层表中插入等效数据 {#different-materialized-view-inserts-into-one-underlying-table-with-equivalent-data} +### 不同物化视图插入到一个基础表中但数据相同 {#different-materialized-view-inserts-into-one-underlying-table-with-equivalent-data} ```sql CREATE TABLE dst @@ -443,10 +454,10 @@ ORDER by all; └───────────────┴─────┴───────┴───────────┘ ``` -两个相同的块插入到表 `mv_dst` 中(如预期)。 +两个相同的块被插入到表 `mv_dst`(如预期)。 ```sql -select 'second attempt'; +SELECT 'second attempt'; INSERT INTO dst VALUES (1, 'A'); @@ -455,7 +466,7 @@ SELECT *, _part FROM dst -ORDER by all; +ORDER BY all; ┌─'from dst'─┬─key─┬─value─┬─_part─────┐ │ from dst │ 1 │ A │ all_0_0_0 │ @@ -474,4 +485,4 @@ ORDER by all; └───────────────┴─────┴───────┴───────────┘ ``` -该重试操作在 `dst` 和 `mv_dst` 两个表中都被去重。 +该重试操作在 `dst` 和 `mv_dst` 两个表中进行了去重。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/deduplicating-inserts-on-retries.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/deduplicating-inserts-on-retries.md.hash index 84e5a225edb..9cc4759ca97 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/deduplicating-inserts-on-retries.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/deduplicating-inserts-on-retries.md.hash @@ -1 +1 @@ -05b579ce63235c92 +b233dbb9ab778e77 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/deduplication.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/deduplication.md index f93fd9ad1dd..8f800f64286 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/deduplication.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/deduplication.md @@ -2,8 +2,9 @@ 'slug': '/guides/developer/deduplication' 'sidebar_label': '去重策略' 'sidebar_position': 3 -'description': '当您需要执行频繁的 upserts、更新和删除时,请使用去重.' +'description': '当您需要频繁进行 upserts、更新和删除时,请使用去重。' 'title': '去重策略' +'doc_type': 'guide' --- import deduplication from '@site/static/images/guides/developer/de_duplication.png'; @@ -12,35 +13,35 @@ import Image from '@theme/IdealImage'; # 去重策略 -**去重** 是指 ***删除数据集中重复行的过程***。在OLTP数据库中,这很容易实现,因为每一行都有唯一的主键,但代价是插入速度较慢。每一行插入前必须先进行查找,如果找到,就需要替换。 +**去重** 是指 ***移除数据集中重复行的过程***。在 OLTP 数据库中,这个过程比较简单,因为每一行都有一个唯一的主键,但这会导致插入速度变慢。每插入一行都需要先进行查找,如果找到,需要进行替换。 -ClickHouse在数据插入方面是为速度而构建的。存储文件是不可变的,ClickHouse在插入一行之前不会检查现有的主键,因此去重需要更多的工作。这也意味着去重不是即时的,它是 **最终的**,这有几个副作用: +ClickHouse 在数据插入方面是为了速度而设计的。存储文件是不可变的,并且 ClickHouse 在插入行之前不检查现有的主键,因此去重涉及更多的工作。这也意味着去重不是立即发生的,它是 **最终** 的,这有一些副作用: -- 在任何时刻,您的表仍然可能有重复项(具有相同排序键的行) -- 真实的重复行删除发生在合并分区的过程中 -- 您的查询需要允许存在重复项的可能性 +- 在任何时刻,您的表中可能仍然存在重复项(具有相同排序键的行) +- 实际的重复行移除发生在分区合并期间 +- 您的查询需要考虑可能存在重复项的情况
||| |------|----| -|去重标志|ClickHouse提供关于去重以及许多其他主题的免费培训。[删除和更新数据培训模块](https://learn.clickhouse.com/visitor_catalog_class/show/1328954/?utm_source=clickhouse&utm_medium=docs)是一个很好的起点。| +|Deduplication Logo|ClickHouse 提供免费的去重和其他主题的培训。 [删除和更新数据](/visitor_catalog_class/show/1328954/?utm_source=clickhouse&utm_medium=docs) 培训模块是一个很好的开始。|
## 去重选项 {#options-for-deduplication} -ClickHouse使用以下表引擎实现去重: +在 ClickHouse 中,去重是通过以下表引擎实现的: -1. `ReplacingMergeTree` 表引擎:使用此表引擎时,具有相同排序键的重复行会在合并期间被删除。`ReplacingMergeTree`是模拟upsert行为的一个好选择(当您希望查询返回最后插入的行时)。 +1. `ReplacingMergeTree` 表引擎:使用此表引擎,具有相同排序键的重复行在合并期间被移除。`ReplacingMergeTree` 是模拟 upsert 行为(您希望查询返回最后插入的行)的良好选择。 -2. 消除行:`CollapsingMergeTree`和`VersionedCollapsingMergeTree`表引擎使用一种逻辑,其中现有行被“取消”,并插入新行。它们的实现比`ReplacingMergeTree`更复杂,但您的查询和聚合可以更简单地编写,而不必担心数据是否已经合并。这两个表引擎在您需要频繁更新数据时非常有用。 +2. 消除行:`CollapsingMergeTree` 和 `VersionedCollapsingMergeTree` 表引擎使用一种逻辑,即现有行被“取消”,并插入新行。它们的实现比 `ReplacingMergeTree` 复杂,但您的查询和聚合可以更简单,因为可以不必担心数据是否已合并。这两个表引擎在需要频繁更新数据时非常有用。 -我们在下面将详细介绍这两种技术。有关更多详细信息,请查看我们的免费的按需[删除和更新数据培训模块](https://learn.clickhouse.com/visitor_catalog_class/show/1328954/?utm_source=clickhouse&utm_medium=docs)。 +我们下面将讨论这两种技术。有关更多详细信息,请查看我们的免费按需 [删除和更新数据培训模块](/visitor_catalog_class/show/1328954/?utm_source=clickhouse&utm_medium=docs)。 -## 使用 ReplacingMergeTree 实现 Upserts {#using-replacingmergetree-for-upserts} +## 使用 ReplacingMergeTree 进行 Upserts {#using-replacingmergetree-for-upserts} -让我们看一个简单的例子,其中一张表包含 Hacker News 的评论,具有表示评论被查看次数的 views 列。假设我们在文章发布时插入一行,并在每天上插入一行,如果视图次数增加,则更新该行: +让我们来看一个简单的例子,其中一个表包含 Hacker News 评论,并有一个表示评论被查看次数的 views 列。假设我们在文章发布时插入一行,并在每一天更新一次,如果值增加,就 upsert 一行: ```sql CREATE TABLE hackernews_rmt ( @@ -61,7 +62,7 @@ INSERT INTO hackernews_rmt VALUES (2, 'ch_fan', 'This is post #2', 0) ``` -要更新`views`列,可以插入一行具有相同主键的新行(注意`views`列的新值): +要更新 `views` 列,请插入一行与主键相同的新行(注意 `views` 列的新值): ```sql INSERT INTO hackernews_rmt VALUES @@ -69,7 +70,7 @@ INSERT INTO hackernews_rmt VALUES (2, 'ch_fan', 'This is post #2', 200) ``` -现在表中有4行: +现在表中有 4 行: ```sql SELECT * @@ -87,7 +88,7 @@ FROM hackernews_rmt └────┴─────────┴─────────────────┴───────┘ ``` -上面输出中的单独框演示了幕后发生的两个部分——数据尚未合并,因此重复行尚未被删除。让我们在`SELECT`查询中使用`FINAL`关键字,这将导致查询结果的逻辑合并: +输出中的单独框展示了幕后这两个部分——这些数据尚未合并,因此重复行尚未被移除。让我们在 `SELECT` 查询中使用 `FINAL` 关键字,这将导致查询结果的逻辑合并: ```sql SELECT * @@ -102,15 +103,15 @@ FINAL └────┴─────────┴─────────────────┴───────┘ ``` -结果只有2行,且最后插入的行是返回的行。 +结果只有 2 行,最后插入的行是被返回的行。 :::note -如果您的数据量很小,使用`FINAL`是可以的。如果您处理大量数据,使用`FINAL`可能不是最佳选择。让我们讨论一下更好的选择,以查找列的最新值... +如果您的数据量较小,使用 `FINAL` 是可以的。但如果您处理的是大量数据,使用 `FINAL` 可能不是最佳选择。让我们讨论一个更好的选项来查找列的最新值。 ::: ### 避免使用 FINAL {#avoiding-final} -让我们再次更新两个唯一行的`views`列: +让我们再次更新两个唯一行的 `views` 列: ```sql INSERT INTO hackernews_rmt VALUES @@ -118,7 +119,7 @@ INSERT INTO hackernews_rmt VALUES (2, 'ch_fan', 'This is post #2', 250) ``` -现在表中有6行,因为实际合并尚未发生(仅在使用`FINAL`时进行了查询时间合并)。 +表现在有 6 行,因为实际的合并尚未发生(只有查询时的合并,当我们使用 `FINAL` 时)。 ```sql SELECT * @@ -140,7 +141,7 @@ FROM hackernews_rmt └────┴─────────┴─────────────────┴───────┘ ``` -与其使用`FINAL`,不如使用一些业务逻辑——我们知道`views`列始终在增加,因此我们可以使用`max`函数选择具有最大值的行,以所需列进行分组: +不使用 `FINAL`,让我们使用一些业务逻辑——我们知道 `views` 列总是增加的,因此我们可以在按所需列分组后,使用 `max` 函数选择具有最大值的行: ```sql SELECT @@ -159,15 +160,15 @@ GROUP BY (id, author, comment) └────┴─────────┴─────────────────┴────────────┘ ``` -如上所示的聚合查询实际上在查询性能上可能比使用`FINAL`关键字更优。 +如上面的查询所示的分组实际上可能在查询性能上比使用 `FINAL` 关键字更高效。 -我们的[删除和更新数据培训模块](https://learn.clickhouse.com/visitor_catalog_class/show/1328954/?utm_source=clickhouse&utm_medium=docs)进一步扩展了这个例子,包括如何使用`version`列与`ReplacingMergeTree`。 +我们的 [删除和更新数据培训模块](/visitor_catalog_class/show/1328954/?utm_source=clickhouse&utm_medium=docs) 扩展了这个例子,包括如何使用 `version` 列与 `ReplacingMergeTree`。 ## 使用 CollapsingMergeTree 频繁更新列 {#using-collapsingmergetree-for-updating-columns-frequently} -更新列涉及删除现有行并用新值替换它。正如您已经看到的,这种类型的修改在 ClickHouse 中是 _最终_ 发生的——即在合并时。如果您需要更新许多行,避免使用`ALTER TABLE..UPDATE`而只是插入新数据与现有数据并行,实际上可能更高效。我们可以添加一列来表明数据是过期的还是新的……而实际上,有一个表引擎已经很好地实现了这一行为,特别是考虑到它会自动为您删除过期数据。让我们看看它是如何工作的。 +更新列涉及删除现有行并用新值替换它。如您所见,这种类型的突变在 ClickHouse 中是 _最终_ 发生的——在合并期间。如果您有很多行要更新,实际上避免使用 `ALTER TABLE..UPDATE`,而是只插入新数据并与现有数据并行,可以更高效。我们可以添加一个列来指示数据是过期的还是新的……实际上有一个表引擎已经非常好地实现了这种行为,尤其是考虑到它自动为您删除过期数据。让我们看看它是如何工作的。 -假设我们使用外部系统跟踪Hacker News评论的查看次数,每隔几个小时将数据推送到ClickHouse。我们希望删除旧行,新行表示每个Hacker News评论的新状态。我们可以使用`CollapsingMergeTree`实现这一行为。 +假设我们使用外部系统跟踪 Hacker News 评论的查看次数,并且每隔几个小时,我们将数据推送到 ClickHouse。我们希望删除旧行,新行代表每个 Hacker News 评论的新状态。我们可以使用 `CollapsingMergeTree` 来实现这种行为。 让我们定义一个表来存储查看次数: @@ -182,22 +183,22 @@ ENGINE = CollapsingMergeTree(sign) PRIMARY KEY (id, author) ``` -注意,`hackernews_views`表中有一个Int8类型的列,命名为sign,这被称为 **状态** 列。状态列的名称是任意的,但`Int8`数据类型是必需的,请注意,此列名称是在`CollapsingMergeTree`表的构造函数中传递的。 +注意 `hackernews_views` 表有一个名为 sign 的 `Int8` 列,被称为 **sign** 列。sign 列的名称是任意的,但 `Int8` 数据类型是必需的,并且注意列名在 `CollapsingMergeTree` 表的构造函数中被传递。 -`CollapsingMergeTree`表的状态列是什么?它表示行的 _状态_,并且状态列只能为1或-1。它的工作原理如下: +`CollapsingMergeTree` 表的 sign 列是什么?它表示行的 _状态_,且 sign 列只能为 1 或 -1。它的工作原理如下: -- 如果两行具有相同的主键(如果排序顺序与主键不同),但具有不同的状态列值,则被插入的最后一行用+1表示,并成为状态行,其他行互相取消。 -- 在合并期间取消的行会被删除。 -- 没有匹配对的行将保留。 +- 如果两行具有相同的主键(或如果排序顺序不同于主键),但 sign 列的值不同,则最后插入的带有 +1 的行成为状态行,而其他行则相互取消 +- 在合并期间,相互取消的行会被删除 +- 没有匹配对的行会被保留 -让我们向`hackernews_views`表中添加一行。由于它是此主键的唯一行,因此我们将其状态设置为1: +让我们向 `hackernews_views` 表添加一行。由于它是该主键的唯一行,我们将其状态设置为 1: ```sql INSERT INTO hackernews_views VALUES (123, 'ricardo', 0, 1) ``` -现在假设我们想更改`views`列。您插入两行:一行取消现有行,另一行包含该行的新状态: +现在假设我们想要更改 `views` 列。您插入了两行:一行取消现有行,另一行包含行的新状态: ```sql INSERT INTO hackernews_views VALUES @@ -205,7 +206,7 @@ INSERT INTO hackernews_views VALUES (123, 'ricardo', 150, 1) ``` -此时表中具有主键`(123, 'ricardo')`的行有3行: +表现在有主键 `(123, 'ricardo')` 的 3 行: ```sql SELECT * @@ -222,7 +223,7 @@ FROM hackernews_views └─────┴─────────┴───────┴──────┘ ``` -注意添加`FINAL`将返回当前状态行: +注意添加 `FINAL` 返回当前状态行: ```sql SELECT * @@ -236,10 +237,10 @@ FINAL └─────┴─────────┴───────┴──────┘ ``` -但显然,对于大型表,不推荐使用`FINAL`。 +但当然,使用 `FINAL` 不推荐用于大表。 :::note -在我们的示例中,传入`views`列的值并不是必需的,也不必与旧行的`views`当前值匹配。实际上,您只需使用主键和-1即可取消一行: +在我们的例子中,传递给 `views` 列的值并不是真正需要的,也不需要与旧行的当前 `views` 值匹配。实际上,您可以使用主键和 -1 取消一行: ```sql INSERT INTO hackernews_views(id, author, sign) VALUES @@ -249,11 +250,11 @@ INSERT INTO hackernews_views(id, author, sign) VALUES ## 来自多个线程的实时更新 {#real-time-updates-from-multiple-threads} -使用`CollapsingMergeTree`表,行使用状态列彼此取消,并且行的状态由最后插入的行确定。但是,如果您在不同的线程中插入行,而行的插入顺序可能不一致,这可能会造成问题。使用“最后”行在这种情况下不起作用。 +使用 `CollapsingMergeTree` 表,行使用 sign 列相互取消,行的状态由最后插入的行决定。但是,如果您从不同的线程插入行,行的插入顺序可能不同,这会导致问题。在这种情况下,使用“最后”行并不起作用。 -这时,`VersionedCollapsingMergeTree` 就派上用场了——它像`CollapsingMergeTree`一样合并行,但不再保留最后插入的行,而是保留您指定的具有最高版本列值的行。 +这就是 `VersionedCollapsingMergeTree` 发挥作用的地方——它像 `CollapsingMergeTree` 一样合并行,但它保留的是您指定的具有最高值的版本列的行,而不是保持最后插入的行。 -让我们看个例子。假设我们想跟踪 Hacker News 评论的查看次数,并且数据经常更新。我们希望报表使用最新值,而无需强制或等待合并。我们从一个与`CollapsedMergeTree`类似的表开始,但我们添加了一列来存储行状态的版本: +让我们看一个例子。假设我们想要跟踪我们的 Hacker News 评论的查看次数,并且数据频繁更新。我们希望报告使用最新值,而不强迫或等待合并。我们开始创建一个与 `CollapsedMergeTree` 类似的表,但我们添加一个列来存储行状态的版本: ```sql CREATE TABLE hackernews_views_vcmt ( @@ -267,13 +268,13 @@ ENGINE = VersionedCollapsingMergeTree(sign, version) PRIMARY KEY (id, author) ``` -注意表使用`VersionsedCollapsingMergeTree`作为引擎,并传递了 **状态列** 和 **版本列**。这里是表的工作原理: +注意该表使用 `VersionsedCollapsingMergeTree` 作为引擎,并传入 **sign 列** 和 **version 列**。这里是该表的工作原理: -- 删除具有相同主键和版本且状态不同的每对行。 -- 行插入的顺序无关紧要。 -- 请注意,如果版本列不是主键的一部分,ClickHouse会隐式将其作为最后一个字段添加到主键中。 +- 它删除每对具有相同主键和版本并且 sign 不同的行 +- 插入行的顺序无关紧要 +- 请注意,如果版本列不是主键的一部分,ClickHouse 会将其隐式地添加到主键中,作为最后一个字段 -编写查询时,使用相同类型的逻辑——按主键分组,并使用巧妙的逻辑避免那些已经被取消但尚未删除的行。让我们向`hackernews_views_vcmt`表中添加一些行: +在编写查询时,您使用相同的逻辑——按主键分组,并使用巧妙的逻辑来避免尚未删除的已取消行。让我们向 `hackernews_views_vcmt` 表添加一些行: ```sql INSERT INTO hackernews_views_vcmt VALUES @@ -282,7 +283,7 @@ INSERT INTO hackernews_views_vcmt VALUES (3, 'kenny', 0, 1, 1) ``` -现在我们更新其中两行并删除其中一行。要取消一行,请确保包含之前的版本号(因为它是主键的一部分): +现在我们更新两行并删除其中一行。要取消一行,请确保包括先前的版本号(因为它是主键的一部分): ```sql INSERT INTO hackernews_views_vcmt VALUES @@ -293,7 +294,7 @@ INSERT INTO hackernews_views_vcmt VALUES (3, 'kenny', 1000, 1, 2) ``` -我们将运行与之前相同的查询,该查询巧妙地根据状态列添加和减去值: +我们将运行与之前相同的查询,巧妙地根据 sign 列添加和减去值: ```sql SELECT @@ -315,7 +316,7 @@ ORDER BY id ASC └────┴─────────┴────────────────────────────┘ ``` -让我们强制进行表合并: +让我们强制合并表: ```sql OPTIMIZE TABLE hackernews_views_vcmt @@ -335,10 +336,10 @@ FROM hackernews_views_vcmt └────┴─────────┴───────┴──────┴─────────┘ ``` -当您想在从多个客户端和/或线程插入行时实现去重时,`VersionedCollapsingMergeTree`表非常方便。 +`VersionedCollapsingMergeTree` 表在您想要在从多个客户端和/或线程插入行时实现去重时非常方便。 -## 为什么我的行没有去重? {#why-arent-my-rows-being-deduplicated} +## 为什么我的行没有被去重? {#why-arent-my-rows-being-deduplicated} -插入的行可能未去重的一个原因是您在`INSERT`语句中使用了非幂等的函数或表达式。例如,如果您插入行时列是`createdAt DateTime64(3) DEFAULT now()`,那么您的行一定是唯一的,因为每一行将具有`createdAt`列的唯一默认值。MergeTree / ReplicatedMergeTree表引擎将不知道去重,因为每条插入的行都会生成唯一的校验和。 +插入的行可能未被去重的一个原因是您在 `INSERT` 语句中使用了非幂等的函数或表达式。例如,如果您在插入行时使用列 `createdAt DateTime64(3) DEFAULT now()`,您的行 guaranteed 是唯一的,因为每一行的 `createdAt` 列将具有唯一的默认值。MergeTree / ReplicatedMergeTree 表引擎将不会知道去重,因为每一插入行将生成唯一的校验和。 -在这种情况下,您可以为每批行指定自己的`insert_deduplication_token`,以确保对同一批的多次插入不会导致相同的行被重新插入。有关如何使用此设置的详细信息,请参见 [有关 `insert_deduplication_token` 的文档](/operations/settings/settings#insert_deduplication_token)。 +在这种情况下,您可以为每批行指定自己的 `insert_deduplication_token`,以确保同一批次的多次插入不会导致相同的行被重新插入。有关此设置的更多详细信息,请参见 [关于 `insert_deduplication_token` 的文档](/operations/settings/settings#insert_deduplication_token)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/deduplication.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/deduplication.md.hash index 051dc8745c8..693b86139ed 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/deduplication.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/deduplication.md.hash @@ -1 +1 @@ -263ae6e68394b5ef +341c939a6fcc0366 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/dynamic-column-selection.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/dynamic-column-selection.md new file mode 100644 index 00000000000..0bb95a31543 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/dynamic-column-selection.md @@ -0,0 +1,197 @@ +--- +'slug': '/guides/developer/dynamic-column-selection' +'sidebar_label': '动态列选择' +'title': '动态列选择' +'description': '在 ClickHouse 中使用替代查询语言' +'doc_type': 'guide' +--- + +[动态列选择](/docs/sql-reference/statements/select#dynamic-column-selection) 是一个强大但未被充分利用的 ClickHouse 功能,它允许您使用正则表达式选择列,而无需单独命名每一列。您还可以使用 `APPLY` 修饰符将函数应用于匹配的列,这使其在数据分析和转换任务中极其有用。 + +我们将通过 [纽约出租车数据集](/docs/getting-started/example-datasets/nyc-taxi) 来学习如何使用此功能,您也可以在 [ClickHouse SQL 游乐场](https://sql.clickhouse.com?query=LS0gRGF0YXNldCBjb250YWluaW5nIHRheGkgcmlkZSBkYXRhIGluIE5ZQyBmcm9tIDIwMDkuIE1vcmUgaW5mbyBoZXJlOiBodHRwczovL2NsaWNraG91c2UuY29tL2RvY3MvZW4vZ2V0dGluZy1zdGFydGVkL2V4YW1wbGUtZGF0YXNldHMvbnljLXRheGkKU0VMRUNUICogRlJPTSBueWNfdGF4aS50cmlwcyBMSU1JVCAxMDA) 中找到该数据集。 + + + +## 选择匹配模式的列 {#selecting-columns} + +让我们从一个常见场景开始:从纽约出租车数据集中选择仅包含 `_amount` 的列。我们可以使用 `COLUMNS` 表达式和正则表达式,而无需手动输入每个列名: + +```sql +FROM nyc_taxi.trips +SELECT COLUMNS('.*_amount') +LIMIT 10; +``` + +> [在 SQL 游乐场中尝试此查询](https://sql.clickhouse.com?query=U0VMRUNUIENPTFVNTlMoJy4qX2Ftb3VudCcpCkZST00gbnljX3RheGkudHJpcHMKTElNSVQgMTA7&run_query=true) + +该查询返回前 10 行,但仅返回名称匹配模式 `.*_amount`(以 "_amount" 结尾的任意字符)的列。 + +```text + ┌─fare_amount─┬─tip_amount─┬─tolls_amount─┬─total_amount─┐ + 1. │ 9 │ 0 │ 0 │ 9.8 │ + 2. │ 9 │ 0 │ 0 │ 9.8 │ + 3. │ 3.5 │ 0 │ 0 │ 4.8 │ + 4. │ 3.5 │ 0 │ 0 │ 4.8 │ + 5. │ 3.5 │ 0 │ 0 │ 4.3 │ + 6. │ 3.5 │ 0 │ 0 │ 4.3 │ + 7. │ 2.5 │ 0 │ 0 │ 3.8 │ + 8. │ 2.5 │ 0 │ 0 │ 3.8 │ + 9. │ 5 │ 0 │ 0 │ 5.8 │ +10. │ 5 │ 0 │ 0 │ 5.8 │ + └─────────────┴────────────┴──────────────┴──────────────┘ +``` + +假设我们还想返回包含 `fee` 或 `tax` 的列。 +我们可以更新正则表达式以包含这些内容: + +```sql +SELECT COLUMNS('.*_amount|fee|tax') +FROM nyc_taxi.trips +ORDER BY rand() +LIMIT 3; +``` + +> [在 SQL 游乐场中尝试此查询](https://sql.clickhouse.com?query=U0VMRUNUIENPTFVNTlMoJy4qX2Ftb3VudHxmZWV8dGF4JykKRlJPTSBueWNfdGF4aS50cmlwcwpPUkRFUiBCWSByYW5kKCkgCkxJTUlUIDM7&run_query=true) + +```text + ┌─fare_amount─┬─mta_tax─┬─tip_amount─┬─tolls_amount─┬─ehail_fee─┬─total_amount─┐ +1. │ 5 │ 0.5 │ 1 │ 0 │ 0 │ 7.8 │ +2. │ 12.5 │ 0.5 │ 0 │ 0 │ 0 │ 13.8 │ +3. │ 4.5 │ 0.5 │ 1.66 │ 0 │ 0 │ 9.96 │ + └─────────────┴─────────┴────────────┴──────────────┴───────────┴──────────────┘ +``` + +## 选择多个模式 {#selecting-multiple-patterns} + +我们可以在单个查询中组合多个列模式: + +```sql +SELECT + COLUMNS('.*_amount'), + COLUMNS('.*_date.*') +FROM nyc_taxi.trips +LIMIT 5; +``` + +> [在 SQL 游乐场中尝试此查询](https://sql.clickhouse.com?query=U0VMRUNUIAogICAgQ09MVU1OUygnLipfYW1vdW50JyksCiAgICBDT0xVTU5TKCcuKl9kYXRlLionKQpGUk9NIG55Y190YXhpLnRyaXBzCkxJTUlUIDU7&run_query=true) + +```text + ┌─fare_amount─┬─tip_amount─┬─tolls_amount─┬─total_amount─┬─pickup_date─┬─────pickup_datetime─┬─dropoff_date─┬────dropoff_datetime─┐ +1. │ 9 │ 0 │ 0 │ 9.8 │ 2001-01-01 │ 2001-01-01 00:01:48 │ 2001-01-01 │ 2001-01-01 00:15:47 │ +2. │ 9 │ 0 │ 0 │ 9.8 │ 2001-01-01 │ 2001-01-01 00:01:48 │ 2001-01-01 │ 2001-01-01 00:15:47 │ +3. │ 3.5 │ 0 │ 0 │ 4.8 │ 2001-01-01 │ 2001-01-01 00:02:08 │ 2001-01-01 │ 2001-01-01 01:00:02 │ +4. │ 3.5 │ 0 │ 0 │ 4.8 │ 2001-01-01 │ 2001-01-01 00:02:08 │ 2001-01-01 │ 2001-01-01 01:00:02 │ +5. │ 3.5 │ 0 │ 0 │ 4.3 │ 2001-01-01 │ 2001-01-01 00:02:26 │ 2001-01-01 │ 2001-01-01 00:04:49 │ + └─────────────┴────────────┴──────────────┴──────────────┴─────────────┴─────────────────────┴──────────────┴─────────────────────┘ +``` + +## 对所有列应用函数 {#applying-functions} + +我们还可以使用 [`APPLY`](/sql-reference/statements/select) 修饰符在每一列上应用函数。 +例如,如果我们想找到每一列的最大值,可以运行以下查询: + +```sql +SELECT COLUMNS('.*_amount|fee|tax') APPLY(max) +FROM nyc_taxi.trips; +``` + +> [在 SQL 游乐场中尝试此查询](https://sql.clickhouse.com?query=U0VMRUNUIENPTFVNTlMoJy4qX2Ftb3VudHxmZWV8dGF4JykgQVBQTFkobWF4KQpGUk9NIG55Y190YXhpLnRyaXBzOw&run_query=true) + +```text + ┌─max(fare_amount)─┬─max(mta_tax)─┬─max(tip_amount)─┬─max(tolls_amount)─┬─max(ehail_fee)─┬─max(total_amount)─┐ +1. │ 998310 │ 500000.5 │ 3950588.8 │ 7999.92 │ 1.95 │ 3950611.5 │ + └──────────────────┴──────────────┴─────────────────┴───────────────────┴────────────────┴───────────────────┘ +``` + +或者,也许我们想看看平均值: + +```sql +SELECT COLUMNS('.*_amount|fee|tax') APPLY(avg) +FROM nyc_taxi.trips +``` + +> [在 SQL 游乐场中尝试此查询](https://sql.clickhouse.com?query=U0VMRUNUIENPTFVNTlMoJy4qX2Ftb3VudHxmZWV8dGF4JykgQVBQTFkoYXZnKQpGUk9NIG55Y190YXhpLnRyaXBzOw&run_query=true) + +```text + ┌─avg(fare_amount)─┬───────avg(mta_tax)─┬────avg(tip_amount)─┬──avg(tolls_amount)─┬──────avg(ehail_fee)─┬──avg(total_amount)─┐ +1. │ 11.8044154834777 │ 0.4555942672733423 │ 1.3469850969211845 │ 0.2256511991414463 │ 3.37600560437412e-9 │ 14.423323722271563 │ + └──────────────────┴────────────────────┴────────────────────┴────────────────────┴─────────────────────┴────────────────────┘ +``` + +这些值包含很多小数位,但幸运的是,我们可以通过链接函数来解决这个问题。在这种情况下,我们将应用 avg 函数,后跟 round 函数: + +```sql +SELECT COLUMNS('.*_amount|fee|tax') APPLY(avg) APPLY(round) +FROM nyc_taxi.trips; +``` + +> [在 SQL 游乐场中尝试此查询](https://sql.clickhouse.com?query=U0VMRUNUIENPTFVNTlMoJy4qX2Ftb3VudHxmZWV8dGF4JykgQVBQTFkoYXZnKSBBUFBMWShyb3VuZCkKRlJPTSBueWNfdGF4aS50cmlwczs&run_query=true) + +```text + ┌─round(avg(fare_amount))─┬─round(avg(mta_tax))─┬─round(avg(tip_amount))─┬─round(avg(tolls_amount))─┬─round(avg(ehail_fee))─┬─round(avg(total_amount))─┐ +1. │ 12 │ 0 │ 1 │ 0 │ 0 │ 14 │ + └─────────────────────────┴─────────────────────┴────────────────────────┴──────────────────────────┴───────────────────────┴──────────────────────────┘ +``` + +但这会将平均值四舍五入为整数。如果我们想四舍五入到两位小数,我们也可以这样做。除了接受函数,`APPLY` 修饰符还接受一个 lambda,这给了我们灵活性,以便让 round 函数将我们的平均值四舍五入到两位小数: + +```sql +SELECT COLUMNS('.*_amount|fee|tax') APPLY(avg) APPLY(x -> round(x, 2)) +FROM nyc_taxi.trips; +``` + +> [在 SQL 游乐场中尝试此查询](https://sql.clickhouse.com?query=U0VMRUNUIENPTFVNTlMoJy4qX2Ftb3VudHxmZWV8dGF4JykgQVBQTFkgYXZnIEFQUExZIHggLT4gcm91bmQoeCwgMikKRlJPTSBueWNfdGF4aS50cmlwcw&run_query=true) + +```text + ┌─round(avg(fare_amount), 2)─┬─round(avg(mta_tax), 2)─┬─round(avg(tip_amount), 2)─┬─round(avg(tolls_amount), 2)─┬─round(avg(ehail_fee), 2)─┬─round(avg(total_amount), 2)─┐ +1. │ 11.8 │ 0.46 │ 1.35 │ 0.23 │ 0 │ 14.42 │ + └────────────────────────────┴────────────────────────┴───────────────────────────┴─────────────────────────────┴──────────────────────────┴─────────────────────────────┘ +``` + +## 替换列 {#replacing-columns} + +到目前为止都很好。但是假设我们想调整其中一个值,同时保持其他值不变。例如,也许我们想将总金额翻倍,并将 MTA 税除以 1.1。我们可以使用 [`REPLACE`](/sql-reference/statements/select) 修饰符来做到这一点,它将在替换一列的同时保持其他列不变。 + +```sql +FROM nyc_taxi.trips +SELECT + COLUMNS('.*_amount|fee|tax') + REPLACE( + total_amount*2 AS total_amount, + mta_tax/1.1 AS mta_tax + ) + APPLY(avg) + APPLY(col -> round(col, 2)); +``` + +> [在 SQL 游乐场中尝试此查询](https://sql.clickhouse.com?query=RlJPTSBueWNfdGF4aS50cmlwcyAKU0VMRUNUIAogIENPTFVNTlMoJy4qX2Ftb3VudHxmZWV8dGF4JykKICBSRVBMQUNFKAogICAgdG90YWxfYW1vdW50KjIgQVMgdG90YWxfYW1vdW50LAogICAgbXRhX3RheC8xLjEgQVMgbXRhX3RheAogICkgCiAgQVBQTFkoYXZnKQogIEFQUExZKGNvbCAtPiByb3VuZChjb2wsIDIpKTs&run_query=true) + +```text + ┌─round(avg(fare_amount), 2)─┬─round(avg(di⋯, 1.1)), 2)─┬─round(avg(tip_amount), 2)─┬─round(avg(tolls_amount), 2)─┬─round(avg(ehail_fee), 2)─┬─round(avg(mu⋯nt, 2)), 2)─┐ +1. │ 11.8 │ 0.41 │ 1.35 │ 0.23 │ 0 │ 28.85 │ + └────────────────────────────┴──────────────────────────┴───────────────────────────┴─────────────────────────────┴──────────────────────────┴──────────────────────────┘ +``` + +## 排除列 {#excluding-columns} + +我们还可以选择通过使用 [`EXCEPT`](/sql-reference/statements/select) 修饰符来排除一个字段。例如,要删除 `tolls_amount` 列,我们可以写出以下查询: + +```sql +FROM nyc_taxi.trips +SELECT + COLUMNS('.*_amount|fee|tax') EXCEPT(tolls_amount) + REPLACE( + total_amount*2 AS total_amount, + mta_tax/1.1 AS mta_tax + ) + APPLY(avg) + APPLY(col -> round(col, 2)); +``` + +> [在 SQL 游乐场中尝试此查询](https://sql.clickhouse.com?query=RlJPTSBueWNfdGF4aS50cmlwcyAKU0VMRUNUIAogIENPTFVNTlMoJy4qX2Ftb3VudHxmZWV8dGF4JykgRVhDRVBUKHRvbGxzX2Ftb3VudCkKICBSRVBMQUNFKAogICAgdG90YWxfYW1vdW50KjIgQVMgdG90YWxfYW1vdW50LAogICAgbXRhX3RheC8xLjEgQVMgbXRhX3RheAogICkgCiAgQVBQTFkoYXZnKQogIEFQUExZKGNvbCAtPiByb3VuZChjb2wsIDIpKTs&run_query=true) + +```text + ┌─round(avg(fare_amount), 2)─┬─round(avg(di⋯, 1.1)), 2)─┬─round(avg(tip_amount), 2)─┬─round(avg(ehail_fee), 2)─┬─round(avg(mu⋯nt, 2)), 2)─┐ +1. │ 11.8 │ 0.41 │ 1.35 │ 0 │ 28.85 │ + └────────────────────────────┴──────────────────────────┴───────────────────────────┴──────────────────────────┴──────────────────────────┘ +``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/dynamic-column-selection.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/dynamic-column-selection.md.hash new file mode 100644 index 00000000000..da844b7ef87 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/dynamic-column-selection.md.hash @@ -0,0 +1 @@ +0dbc8dd2ce8fb2c1 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/index.md index b4e59bc5b06..60516bf952c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/index.md @@ -3,6 +3,7 @@ 'sidebar_label': '高级指南概述' 'description': '高级指南的概述' 'title': '高级指南' +'doc_type': 'guide' --- @@ -12,12 +13,12 @@ | 指南 | 描述 | |------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| [替代查询语言](../developer/alternative-query-languages) | 关于支持的替代方言及其用法的指南。提供每种方言的查询示例。 | -| [级联物化视图](../developer/cascading-materialized-views) | 关于如何创建物化视图并级联它们的指南,将多个源表组合成一个目标表。包含使用级联物化视图按月和按年聚合一组域名数据的示例。 | -| [调试内存问题](../developer/debugging-memory-issues) | 关于如何调试 ClickHouse 内存问题的指南。 | -| [重试中的去重插入](../developer/deduplicating-inserts-on-retries) | 关于如何处理可能重试失败插入情况下的指南。 | -| [去重策略](../developer/deduplication) | 深入探讨数据去重的指南,一种从数据库中删除重复行的技术。解释 OLTP 系统中基于主键的去重与 ClickHouse 的去重方法之间的差异,以及如何在 ClickHouse 查询中处理重复数据场景。 | -| [填补时间序列数据中的空白](../developer/time-series-filling-gaps) | 提供有关 ClickHouse 处理时间序列数据能力的指南,包括填补数据空白的技术,以创建更完整和连续的时间序列信息表示。 | -| [使用 TTL (生存时间) 管理数据](../developer/ttl) | 讨论如何使用 `WITH FILL` 子句填补时间序列数据中空白的指南。涵盖如何用 0 值填补空白、如何指定填补空白的起始点、如何填补到特定的结束点,以及如何为累积计算插值。 | -| [使用分析工具理解查询执行](../developer/understanding-query-execution-with-the-analyzer) | 通过引入分析工具解密 ClickHouse 查询执行的指南。解释分析器如何将查询分解为一系列步骤,帮助您可视化和排除整个执行过程中的故障,以达到最佳性能。 | -| [在 ClickHouse 中使用 JOINs](../joining-tables) | 简化在 ClickHouse 中连接表的指南。涵盖不同的连接类型(`INNER`、`LEFT`、`RIGHT` 等),探讨高效连接的最佳实践(例如将较小的表放在右侧),并提供有关 ClickHouse 内部连接算法的见解,以帮助您优化复杂数据关系的查询。 | +| [替代查询语言](../developer/alternative-query-languages) | 一份关于支持的替代方言以及如何使用它们的指南。提供了每种方言的查询示例。 | +| [级联物化视图](../developer/cascading-materialized-views) | 一份关于如何创建物化视图并将它们级联在一起,结合多个源表到一个目标表中的指南。包含了一个使用级联物化视图按月和年汇总一组域名数据的示例。 | +| [调试内存问题](../developer/debugging-memory-issues) | 一份关于如何调试 ClickHouse 内存问题的指南。 | +| [重试时去重插入](../developer/deduplicating-inserts-on-retries) | 一份关于如何处理可能重试失败插入情况的指南。 | +| [去重策略](../developer/deduplication) | 一份深入探讨数据去重的指南,去重是一种从数据库中移除重复行的技术。解释了与 OLTP 系统中基于主键的去重的区别,ClickHouse 的去重方法,以及如何在 ClickHouse 查询中处理重复数据场景。 | +| [填补时间序列数据中的缺口](../developer/time-series-filling-gaps) | 一份提供 ClickHouse 在处理时间序列数据方面能力的指南,包括填补数据缺口的技术,以创建更完整和连续的时间序列信息表示。 | +| [使用 TTL (生存时间) 管理数据](../developer/ttl) | 一份讨论如何使用 `WITH FILL` 子句填补时间序列数据缺口的指南。涵盖如何用 0 值填补缺口、如何指定填补缺口的起始点、如何填补到特定的结束点,以及如何插值用于累计计算的值。 | +| [通过分析器理解查询执行](../developer/understanding-query-execution-with-the-analyzer) | 一份揭开 ClickHouse 查询执行神秘面纱的指南,介绍分析器工具。解释了分析器如何将查询分解为一系列步骤,使您能够可视化和排除整个执行过程中的故障,以实现最佳性能。 | +| [在 ClickHouse 中使用 JOIN](../joining-tables) | 一份简化在 ClickHouse 中连接表的指南。涵盖不同的连接类型(`INNER`、`LEFT`、`RIGHT` 等),探讨高效连接的最佳实践(如将较小的表放在右侧),并提供有关 ClickHouse 内部连接算法的见解,帮助您优化复杂数据关系的查询。 | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/index.md.hash index 59cd6b92436..3ce92165ed3 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/index.md.hash @@ -1 +1 @@ -99adb7825ee79957 +48db13ce22b0a6aa diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/lightweight-delete.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/lightweight-delete.md index faacfe359e2..944324a8107 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/lightweight-delete.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/lightweight-delete.md @@ -3,7 +3,8 @@ 'title': '轻量级删除' 'keywords': - 'lightweight delete' -'description': '提供关于ClickHouse中轻量级删除的概述' +'description': '提供有关 ClickHouse 中轻量级删除的概述' +'doc_type': 'reference' --- import Content from '@site/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/delete.md'; diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/lightweight-delete.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/lightweight-delete.md.hash index 6cd13ef8875..930bc145872 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/lightweight-delete.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/lightweight-delete.md.hash @@ -1 +1 @@ -52ce7986ce4e0ee7 +058b4ec7549cd7aa diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/lightweight-update.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/lightweight-update.md deleted file mode 100644 index df1c2941a72..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/lightweight-update.md +++ /dev/null @@ -1,93 +0,0 @@ ---- -'slug': '/guides/developer/lightweight-update' -'sidebar_label': '轻量级更新' -'title': '轻量级更新' -'keywords': -- 'lightweight update' -'description': '提供关于轻量级更新的描述' ---- - -## 轻量级更新 {#lightweight-update} - -当轻量级更新启用时,更新的行会立即标记为已更新,后续的 `SELECT` 查询将自动返回已更改的值。当轻量级更新未启用时,您可能需要等待后台进程应用您的变更才能看到已更改的值。 - -可以通过启用查询级设置 `apply_mutations_on_fly` 来为 `MergeTree` 系列表启用轻量级更新。 - -```sql -SET apply_mutations_on_fly = 1; -``` - -## 示例 {#example} - -让我们创建一个表并执行一些变更: -```sql -CREATE TABLE test_on_fly_mutations (id UInt64, v String) -ENGINE = MergeTree ORDER BY id; - --- Disable background materialization of mutations to showcase --- default behavior when lightweight updates are not enabled -SYSTEM STOP MERGES test_on_fly_mutations; -SET mutations_sync = 0; - --- Insert some rows in our new table -INSERT INTO test_on_fly_mutations VALUES (1, 'a'), (2, 'b'), (3, 'c'); - --- Update the values of the rows -ALTER TABLE test_on_fly_mutations UPDATE v = 'd' WHERE id = 1; -ALTER TABLE test_on_fly_mutations DELETE WHERE v = 'd'; -ALTER TABLE test_on_fly_mutations UPDATE v = 'e' WHERE id = 2; -ALTER TABLE test_on_fly_mutations DELETE WHERE v = 'e'; -``` - -让我们通过 `SELECT` 查询检查更新的结果: -```sql --- Explicitly disable lightweight updates -SET apply_mutations_on_fly = 0; - -SELECT id, v FROM test_on_fly_mutations ORDER BY id; -``` - -请注意,当我们查询新表时,行的值尚未更新: - -```response -┌─id─┬─v─┐ -│ 1 │ a │ -│ 2 │ b │ -│ 3 │ c │ -└────┴───┘ -``` - -现在让我们看看启用轻量级更新后会发生什么: - -```sql --- Enable lightweight updates -SET apply_mutations_on_fly = 1; - -SELECT id, v FROM test_on_fly_mutations ORDER BY id; -``` - -`SELECT` 查询现在立即返回正确的结果,无需等待变更应用: - -```response -┌─id─┬─v─┐ -│ 3 │ c │ -└────┴───┘ -``` - -## 性能影响 {#performance-impact} - -当轻量级更新启用时,变更不会立即物化,而只会在 `SELECT` 查询期间应用。然而,请注意,变更仍会在后台异步物化,这是一项耗时的过程。 - -如果提交的变更数量持续超过在一定时间间隔内处理的变更数量,未物化的变更队列将不断增长。这将导致 `SELECT` 查询性能最终下降。 - -我们建议启用设置 `apply_mutations_on_fly`,同时结合其他 `MergeTree` 级别的设置,例如 `number_of_mutations_to_throw` 和 `number_of_mutations_to_delay`,以限制未物化变更的无限增长。 - -## 对子查询和非确定性函数的支持 {#support-for-subqueries-and-non-deterministic-functions} - -轻量级更新对子查询和非确定性函数的支持有限。仅支持结果大小合理的标量子查询(由设置 `mutations_max_literal_size_to_replace` 控制)。仅支持常量非确定性函数(例如,函数 `now()`)。 - -这些行为由以下设置控制: - -- `mutations_execute_nondeterministic_on_initiator` - 如果为 true,非确定性函数在发起副本上执行,并在 `UPDATE` 和 `DELETE` 查询中作为字面量替换。默认值:`false`。 -- `mutations_execute_subqueries_on_initiator` - 如果为 true,标量子查询在发起副本上执行,并在 `UPDATE` 和 `DELETE` 查询中作为字面量替换。默认值:`false`。 -- `mutations_max_literal_size_to_replace` - 要在 `UPDATE` 和 `DELETE` 查询中替换的序列化字面量的最大字节大小。默认值:`16384`(16 KiB)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/lightweight-update.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/lightweight-update.md.hash deleted file mode 100644 index ce568fde54b..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/lightweight-update.md.hash +++ /dev/null @@ -1 +0,0 @@ -f8cb2a2928fc4276 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/merge-table-function.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/merge-table-function.md new file mode 100644 index 00000000000..ccb66483bbc --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/merge-table-function.md @@ -0,0 +1,216 @@ +--- +'slug': '/guides/developer/merge-table-function' +'sidebar_label': 'Merge table function' +'title': 'Merge table function' +'description': '同時查询多个表。' +'doc_type': 'reference' +--- + +The [merge table function](https://clickhouse.com/docs/sql-reference/table-functions/merge) 让我们能够并行查询多个表。这通过创建一个临时的 [Merge](https://clickhouse.com/docs/engines/table-engines/special/merge) 表来实现,并通过对它们的列进行并集并推导出共同类型来得出该表的结构。 + + + +## 设置表 {#setup-tables} + +我们将借助 [Jeff Sackmann's tennis dataset](https://github.com/JeffSackmann/tennis_atp) 学习如何使用此函数。我们将处理包含自1960年代以来的比赛的CSV文件,但我们将为每十年创建一个稍微不同的模式。我们还会为1990年代添加几个额外的列。 + +导入语句如下所示: + +```sql +CREATE OR REPLACE TABLE atp_matches_1960s ORDER BY tourney_id AS +SELECT tourney_id, surface, winner_name, loser_name, winner_seed, loser_seed, score +FROM url('https://raw.githubusercontent.com/JeffSackmann/tennis_atp/refs/heads/master/atp_matches_{1968..1969}.csv') +SETTINGS schema_inference_make_columns_nullable=0, + schema_inference_hints='winner_seed Nullable(String), loser_seed Nullable(UInt8)'; + +CREATE OR REPLACE TABLE atp_matches_1970s ORDER BY tourney_id AS +SELECT tourney_id, surface, winner_name, loser_name, winner_seed, loser_seed, splitByWhitespace(score) AS score +FROM url('https://raw.githubusercontent.com/JeffSackmann/tennis_atp/refs/heads/master/atp_matches_{1970..1979}.csv') +SETTINGS schema_inference_make_columns_nullable=0, + schema_inference_hints='winner_seed Nullable(UInt8), loser_seed Nullable(UInt8)'; + +CREATE OR REPLACE TABLE atp_matches_1980s ORDER BY tourney_id AS +SELECT tourney_id, surface, winner_name, loser_name, winner_seed, loser_seed, splitByWhitespace(score) AS score +FROM url('https://raw.githubusercontent.com/JeffSackmann/tennis_atp/refs/heads/master/atp_matches_{1980..1989}.csv') +SETTINGS schema_inference_make_columns_nullable=0, + schema_inference_hints='winner_seed Nullable(UInt16), loser_seed Nullable(UInt16)'; + +CREATE OR REPLACE TABLE atp_matches_1990s ORDER BY tourney_id AS +SELECT tourney_id, surface, winner_name, loser_name, winner_seed, loser_seed, splitByWhitespace(score) AS score, + toBool(arrayExists(x -> position(x, 'W/O') > 0, score))::Nullable(bool) AS walkover, + toBool(arrayExists(x -> position(x, 'RET') > 0, score))::Nullable(bool) AS retirement +FROM url('https://raw.githubusercontent.com/JeffSackmann/tennis_atp/refs/heads/master/atp_matches_{1990..1999}.csv') +SETTINGS schema_inference_make_columns_nullable=0, + schema_inference_hints='winner_seed Nullable(UInt16), loser_seed Nullable(UInt16), surface Enum(\'Hard\', \'Grass\', \'Clay\', \'Carpet\')'; +``` + +## 多个表的模式 {#schema-multiple-tables} + +我们可以运行以下查询,将每个表中的列及其类型并排列出,以便更容易看出差异。 + +```sql +SELECT * EXCEPT(position) FROM ( + SELECT position, name, + any(if(table = 'atp_matches_1960s', type, null)) AS 1960s, + any(if(table = 'atp_matches_1970s', type, null)) AS 1970s, + any(if(table = 'atp_matches_1980s', type, null)) AS 1980s, + any(if(table = 'atp_matches_1990s', type, null)) AS 1990s + FROM system.columns + WHERE database = currentDatabase() AND table LIKE 'atp_matches%' + GROUP BY ALL + ORDER BY position ASC +) +SETTINGS output_format_pretty_max_value_width=25; +``` + +```text +┌─name────────┬─1960s────────────┬─1970s───────────┬─1980s────────────┬─1990s─────────────────────┐ +│ tourney_id │ String │ String │ String │ String │ +│ surface │ String │ String │ String │ Enum8('Hard' = 1, 'Grass'⋯│ +│ winner_name │ String │ String │ String │ String │ +│ loser_name │ String │ String │ String │ String │ +│ winner_seed │ Nullable(String) │ Nullable(UInt8) │ Nullable(UInt16) │ Nullable(UInt16) │ +│ loser_seed │ Nullable(UInt8) │ Nullable(UInt8) │ Nullable(UInt16) │ Nullable(UInt16) │ +│ score │ String │ Array(String) │ Array(String) │ Array(String) │ +│ walkover │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ Nullable(Bool) │ +│ retirement │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ Nullable(Bool) │ +└─────────────┴──────────────────┴─────────────────┴──────────────────┴───────────────────────────┘ +``` + +让我们来看一下这些差异: + +* 1970年代将 `winner_seed` 的类型从 `Nullable(String)` 更改为 `Nullable(UInt8)`,将 `score` 从 `String` 更改为 `Array(String)`。 +* 1980年代将 `winner_seed` 和 `loser_seed` 的类型从 `Nullable(UInt8)` 更改为 `Nullable(UInt16)`。 +* 1990年代将 `surface` 从 `String` 更改为 `Enum('Hard', 'Grass', 'Clay', 'Carpet')`,并添加了 `walkover` 和 `retirement` 列。 + +## 使用merge查询多个表 {#querying-multiple-tables} + +让我们写一个查询,找出约翰·麦肯罗赢得的对手种子为#1的比赛: + +```sql +SELECT loser_name, score +FROM merge('atp_matches*') +WHERE winner_name = 'John McEnroe' +AND loser_seed = 1; +``` + +```text +┌─loser_name────┬─score───────────────────────────┐ +│ Bjorn Borg │ ['6-3','6-4'] │ +│ Bjorn Borg │ ['7-6','6-1','6-7','5-7','6-4'] │ +│ Bjorn Borg │ ['7-6','6-4'] │ +│ Bjorn Borg │ ['4-6','7-6','7-6','6-4'] │ +│ Jimmy Connors │ ['6-1','6-3'] │ +│ Ivan Lendl │ ['6-2','4-6','6-3','6-7','7-6'] │ +│ Ivan Lendl │ ['6-3','3-6','6-3','7-6'] │ +│ Ivan Lendl │ ['6-1','6-3'] │ +│ Stefan Edberg │ ['6-2','6-3'] │ +│ Stefan Edberg │ ['7-6','6-2'] │ +│ Stefan Edberg │ ['6-2','6-2'] │ +│ Jakob Hlasek │ ['6-3','7-6'] │ +└───────────────┴─────────────────────────────────┘ +``` + +接下来,假设我们想过滤这些比赛,找出麦肯罗种子为#3或更低的比赛。这有点棘手,因为 `winner_seed` 在各个表中使用不同的类型: + +```sql +SELECT loser_name, score, winner_seed +FROM merge('atp_matches*') +WHERE winner_name = 'John McEnroe' +AND loser_seed = 1 +AND multiIf( + variantType(winner_seed) = 'UInt8', variantElement(winner_seed, 'UInt8') >= 3, + variantType(winner_seed) = 'UInt16', variantElement(winner_seed, 'UInt16') >= 3, + variantElement(winner_seed, 'String')::UInt16 >= 3 +); +``` + +我们使用 [`variantType`](/docs/sql-reference/functions/other-functions#varianttype) 函数检查每行的 `winner_seed` 类型,然后使用 [`variantElement`](/docs/sql-reference/functions/other-functions#variantelement) 提取底层值。当类型为 `String` 时,我们将其转换为数字,然后进行比较。运行查询的结果如下所示: + +```text +┌─loser_name────┬─score─────────┬─winner_seed─┐ +│ Bjorn Borg │ ['6-3','6-4'] │ 3 │ +│ Stefan Edberg │ ['6-2','6-3'] │ 6 │ +│ Stefan Edberg │ ['7-6','6-2'] │ 4 │ +│ Stefan Edberg │ ['6-2','6-2'] │ 7 │ +└───────────────┴───────────────┴─────────────┘ +``` + +## 使用merge时行来自哪个表? {#which-table-merge} + +如果我们想知道行来自哪个表呢?我们可以使用 `_table` 虚拟列来实现,如以下查询所示: + +```sql +SELECT _table, loser_name, score, winner_seed +FROM merge('atp_matches*') +WHERE winner_name = 'John McEnroe' +AND loser_seed = 1 +AND multiIf( + variantType(winner_seed) = 'UInt8', variantElement(winner_seed, 'UInt8') >= 3, + variantType(winner_seed) = 'UInt16', variantElement(winner_seed, 'UInt16') >= 3, + variantElement(winner_seed, 'String')::UInt16 >= 3 +); +``` + +```text +┌─_table────────────┬─loser_name────┬─score─────────┬─winner_seed─┐ +│ atp_matches_1970s │ Bjorn Borg │ ['6-3','6-4'] │ 3 │ +│ atp_matches_1980s │ Stefan Edberg │ ['6-2','6-3'] │ 6 │ +│ atp_matches_1980s │ Stefan Edberg │ ['7-6','6-2'] │ 4 │ +│ atp_matches_1980s │ Stefan Edberg │ ['6-2','6-2'] │ 7 │ +└───────────────────┴───────────────┴───────────────┴─────────────┘ +``` + +我们也可以在查询中使用这个虚拟列来计算 `walkover` 列的值: + +```sql +SELECT _table, walkover, count() +FROM merge('atp_matches*') +GROUP BY ALL +ORDER BY _table; +``` + +```text +┌─_table────────────┬─walkover─┬─count()─┐ +│ atp_matches_1960s │ ᴺᵁᴸᴸ │ 7542 │ +│ atp_matches_1970s │ ᴺᵁᴸᴸ │ 39165 │ +│ atp_matches_1980s │ ᴺᵁᴸᴸ │ 36233 │ +│ atp_matches_1990s │ true │ 128 │ +│ atp_matches_1990s │ false │ 37022 │ +└───────────────────┴──────────┴─────────┘ +``` + +我们可以看到,除 `atp_matches_1990s` 之外的所有行 `walkover` 列都是 `NULL`。我们需要更新我们的查询,以检查如果 `walkover` 列为 `NULL`,`score` 列是否包含字符串 `W/O`: + +```sql +SELECT _table, + multiIf( + walkover IS NOT NULL, + walkover, + variantType(score) = 'Array(String)', + toBool(arrayExists( + x -> position(x, 'W/O') > 0, + variantElement(score, 'Array(String)') + )), + variantElement(score, 'String') LIKE '%W/O%' + ), + count() +FROM merge('atp_matches*') +GROUP BY ALL +ORDER BY _table; +``` + +如果 `score` 的基础类型是 `Array(String)`,我们必须遍历数组以查找 `W/O`,而如果它的类型是 `String`,我们可以直接在字符串中搜索 `W/O`。 + +```text +┌─_table────────────┬─multiIf(isNo⋯, '%W/O%'))─┬─count()─┐ +│ atp_matches_1960s │ true │ 242 │ +│ atp_matches_1960s │ false │ 7300 │ +│ atp_matches_1970s │ true │ 422 │ +│ atp_matches_1970s │ false │ 38743 │ +│ atp_matches_1980s │ true │ 92 │ +│ atp_matches_1980s │ false │ 36141 │ +│ atp_matches_1990s │ true │ 128 │ +│ atp_matches_1990s │ false │ 37022 │ +└───────────────────┴──────────────────────────┴─────────┘ +``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/merge-table-function.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/merge-table-function.md.hash new file mode 100644 index 00000000000..fb8adc0bb36 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/merge-table-function.md.hash @@ -0,0 +1 @@ +9de043e7bd9fe746 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/mutations.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/mutations.md index 266bb77f086..c9c76105038 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/mutations.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/mutations.md @@ -5,18 +5,20 @@ 'keywords': - 'UPDATE' - 'DELETE' +- 'mutations' 'title': '更新和删除 ClickHouse 数据' 'description': '描述如何在 ClickHouse 中执行更新和删除操作' 'show_related_blogs': false +'doc_type': 'guide' --- -# 更新和删除 ClickHouse 数据 +# 更新和删除 ClickHouse 数据的变更 -尽管 ClickHouse 是面向高流量分析工作负载,但在某些情况下可以修改或删除现有数据。这些操作被称为“突变”,并使用 `ALTER TABLE` 命令执行。您还可以使用 ClickHouse 的轻量级删除功能来 `DELETE` 一行。 +尽管 ClickHouse 主要针对高容量分析工作负载,但在某些情况下,可以修改或删除现有数据。这些操作被称为“变更”,并使用 `ALTER TABLE` 命令执行。 :::tip -如果您需要频繁更新,考虑在 ClickHouse 中使用 [去重](../developer/deduplication.md),这允许您更新和/或删除行而不会生成突变事件。 +如果您需要频繁更新,请考虑在 ClickHouse 中使用 [去重](../developer/deduplication.md),这允许您更新和/或删除行而不会生成变更事件。或者,使用 [轻量级更新](/docs/sql-reference/statements/update) 或 [轻量级删除](/guides/developer/lightweight-delete)。 ::: ## 更新数据 {#updating-data} @@ -27,11 +29,11 @@ ALTER TABLE [.] UPDATE = WHERE ``` -`` 是在满足 `` 时列的新值。 `` 必须与列的数据类型相同或可以使用 `CAST` 运算符转换为相同的数据类型。`` 应该为数据的每一行返回一个 `UInt8`(零或非零)值。可以在一个 `ALTER TABLE` 命令中用逗号组合多个 `UPDATE ` 语句。 +`` 是满足 `` 的列的新值。`` 必须与列的数据类型相同,或可以使用 `CAST` 运算符转换为相同的数据类型。`` 应该对每一行数据返回一个 `UInt8`(零或非零)值。多个 `UPDATE ` 语句可以用逗号分隔组合在一个 `ALTER TABLE` 命令中。 **示例**: -1. 这样的突变允许使用字典查找将 `visitor_ids` 替换为新的值: +1. 这样的变更允许使用字典查找将 `visitor_ids` 替换为新值: ```sql ALTER TABLE website.clicks @@ -39,7 +41,7 @@ UPDATE visitor_id = getDict('visitors', 'new_visitor_id', visitor_id) WHERE visit_date < '2022-01-01' ``` -2. 在一个命令中修改多个值比多个命令更有效: +2. 在一个命令中修改多个值可能比多个命令更高效: ```sql ALTER TABLE website.clicks @@ -47,7 +49,7 @@ UPDATE url = substring(url, position(url, '://') + 3), visitor_id = new_visit_id WHERE visit_date < '2022-01-01' ``` -3. 突变可以在分片表上 `ON CLUSTER` 执行: +3. 对于分片表,可以执行 `ON CLUSTER` 变更: ```sql ALTER TABLE clicks ON CLUSTER main_cluster @@ -56,7 +58,7 @@ WHERE visitor_id ILIKE '%robot%' ``` :::note -无法更新作为主键或排序键的列。 +无法更新主键或排序键的一部分的列。 ::: ## 删除数据 {#deleting-data} @@ -67,40 +69,40 @@ WHERE visitor_id ILIKE '%robot%' ALTER TABLE [.]
DELETE WHERE ``` -`` 应该为每一行数据返回一个 UInt8 值。 +`` 应该对每一行数据返回一个 UInt8 值。 **示例** -1. 删除列在值数组中的任何记录: +1. 删除列中值在某个数组中的任何记录: ```sql ALTER TABLE website.clicks DELETE WHERE visitor_id in (253, 1002, 4277) ``` -2. 此查询修改了什么? +2. 这个查询修改了什么? ```sql ALTER TABLE clicks ON CLUSTER main_cluster DELETE WHERE visit_date < '2022-01-02 15:00:00' AND page_id = '573' ``` :::note -要删除表中的所有数据,使用 `TRUNCATE TABLE [` 命令更为高效。该命令也可以在 `ON CLUSTER` 执行。 +要删除表中的所有数据,使用命令 `TRUNCATE TABLE [` 更为高效。该命令也可以在 `ON CLUSTER` 上执行。 ::: -查看 [`DELETE` 语句](/sql-reference/statements/delete.md) 文档页面以获取更多详细信息。 +查看 [`DELETE` 语句](/sql-reference/statements/delete.md) 文档页面以获取更多详情。 ## 轻量级删除 {#lightweight-deletes} -删除行的另一个选项是使用 `DELETE FROM` 命令,这被称为 **轻量级删除**。被删除的行会立即标记为已删除,并将在所有后续查询中自动过滤,因此您不必等待分片的合并或使用 `FINAL` 关键字。数据清理在后台异步发生。 +删除行的另一种选择是使用 `DELETE FROM` 命令,这被称为 **轻量级删除**。被删除的行会立即被标记为已删除,并将自动从所有后续查询中过滤掉,因此您无需等待分区片段的合并或使用 `FINAL` 关键字。数据的清理在后台异步进行。 ```sql DELETE FROM [db.]table [ON CLUSTER cluster] [WHERE expr] ``` -例如,以下查询删除 `hits` 表中 `Title` 列包含文本 `hello` 的所有行: +例如,以下查询从 `hits` 表中删除所有 `Title` 列包含文本 `hello` 的行: ```sql DELETE FROM hits WHERE Title LIKE '%hello%'; ``` -关于轻量级删除的一些说明: +关于轻量级删除的几点说明: - 此功能仅适用于 `MergeTree` 表引擎系列。 -- 轻量级删除默认是异步的。将 `mutations_sync` 设置为 1 以等待一个副本处理该语句,将 `mutations_sync` 设置为 2 以等待所有副本处理完毕。 +- 轻量级删除默认是异步的。将 `mutations_sync` 设置为 1 以等待一个副本处理该语句,将 `mutations_sync` 设置为 2 以等待所有副本。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/mutations.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/mutations.md.hash index 24100c112d0..64a676eb052 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/mutations.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/mutations.md.hash @@ -1 +1 @@ -ed49c96c4a3ede9a +1064cd99f717ba2a diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/on-fly-mutations.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/on-fly-mutations.md new file mode 100644 index 00000000000..70c7f7d5ba5 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/on-fly-mutations.md @@ -0,0 +1,95 @@ +--- +'slug': '/guides/developer/on-the-fly-mutations' +'sidebar_label': '动态变更' +'title': '动态变更' +'keywords': +- 'On-the-fly mutation' +'description': '提供动态变更的描述' +'doc_type': 'guide' +--- + +## 实时突变 {#on-the-fly-mutations} + +当实时突变启用时,更新的行会立即标记为已更新,后续的 `SELECT` 查询将自动返回更改后的值。当实时突变未启用时,您可能需要等待后台进程应用突变才能查看更改的值。 + +可以通过启用查询级设置 `apply_mutations_on_fly` 来为 `MergeTree` 家族表启用实时突变。 + +```sql +SET apply_mutations_on_fly = 1; +``` + +## 示例 {#example} + +让我们创建一个表并运行一些突变: +```sql +CREATE TABLE test_on_fly_mutations (id UInt64, v String) +ENGINE = MergeTree ORDER BY id; + +-- Disable background materialization of mutations to showcase +-- default behavior when on-the-fly mutations are not enabled +SYSTEM STOP MERGES test_on_fly_mutations; +SET mutations_sync = 0; + +-- Insert some rows in our new table +INSERT INTO test_on_fly_mutations VALUES (1, 'a'), (2, 'b'), (3, 'c'); + +-- Update the values of the rows +ALTER TABLE test_on_fly_mutations UPDATE v = 'd' WHERE id = 1; +ALTER TABLE test_on_fly_mutations DELETE WHERE v = 'd'; +ALTER TABLE test_on_fly_mutations UPDATE v = 'e' WHERE id = 2; +ALTER TABLE test_on_fly_mutations DELETE WHERE v = 'e'; +``` + +现在让我们通过 `SELECT` 查询检查更新的结果: + +```sql +-- Explicitly disable on-the-fly-mutations +SET apply_mutations_on_fly = 0; + +SELECT id, v FROM test_on_fly_mutations ORDER BY id; +``` + +请注意,当我们查询新表时,行的值尚未更新: + +```response +┌─id─┬─v─┐ +│ 1 │ a │ +│ 2 │ b │ +│ 3 │ c │ +└────┴───┘ +``` + +现在让我们看看启用实时突变时会发生什么: + +```sql +-- Enable on-the-fly mutations +SET apply_mutations_on_fly = 1; + +SELECT id, v FROM test_on_fly_mutations ORDER BY id; +``` + +`SELECT` 查询现在立即返回正确的结果,无需等待突变应用: + +```response +┌─id─┬─v─┐ +│ 3 │ c │ +└────┴───┘ +``` + +## 性能影响 {#performance-impact} + +当实时突变启用时,突变不会立即物化,而是在 `SELECT` 查询期间才会应用。然而,请注意,突变仍在后台异步物化,这是一项繁重的过程。 + +如果提交的突变数量持续超过在某个时间间隔内处理的突变数量,则未物化的突变队列将不断增长。这将导致 `SELECT` 查询性能的最终下降。 + +我们建议同时启用设置 `apply_mutations_on_fly` 和其他 `MergeTree` 级别的设置,如 `number_of_mutations_to_throw` 和 `number_of_mutations_to_delay`,以限制未物化突变的无限增长。 + +## 对子查询和非确定性函数的支持 {#support-for-subqueries-and-non-deterministic-functions} + +实时突变对子查询和非确定性函数的支持有限。仅支持具有合理大小结果的标量子查询(由设置 `mutations_max_literal_size_to_replace` 控制)。仅支持常量非确定性函数(例如,函数 `now()`)。 + +这些行为由以下设置控制: + +- `mutations_execute_nondeterministic_on_initiator` - 如果为真,非确定性函数将在发起副本上执行,并在 `UPDATE` 和 `DELETE` 查询中替换为字面量。默认值:`false`。 +- `mutations_execute_subqueries_on_initiator` - 如果为真,标量子查询将在发起副本上执行,并在 `UPDATE` 和 `DELETE` 查询中替换为字面量。默认值:`false`。 +- `mutations_max_literal_size_to_replace` - 要在 `UPDATE` 和 `DELETE` 查询中替换的序列化字面量的最大大小(以字节为单位)。默认值:`16384` (16 KiB)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/on-fly-mutations.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/on-fly-mutations.md.hash new file mode 100644 index 00000000000..3c27e625d4d --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/on-fly-mutations.md.hash @@ -0,0 +1 @@ +a82a6443cca196e8 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/replacing-merge-tree.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/replacing-merge-tree.md index 920ff5a1ecb..16943517a9b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/replacing-merge-tree.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/replacing-merge-tree.md @@ -6,32 +6,30 @@ - 'replacingmergetree' - 'inserts' - 'deduplication' +'doc_type': 'guide' --- import postgres_replacingmergetree from '@site/static/images/migrations/postgres-replacingmergetree.png'; import Image from '@theme/IdealImage'; -在事务型数据库针对事务更新和删除工作负载进行优化时,OLAP 数据库对这些操作提供较少的保证。相反,它们对以批量方式插入的不可变数据进行优化,从而显著加快分析查询的速度。虽然 ClickHouse 通过突变操作提供了更新操作以及一种轻量级删除行的方法,但其列式结构意味着这些操作应谨慎调度,如上述所述。这些操作是异步处理的,使用单个线程进行处理,并且(在更新情况下)需要在磁盘上重写数据。因此,它们不应用于大量小的更改。 +尽管事务数据库在事务更新和删除工作负载上经过优化,但 OLAP 数据库对这些操作的保证较少。相反,它们在批量插入不可变数据的情况下进行优化,以实现显著更快的分析查询。虽然 ClickHouse 通过变更提供了更新操作,以及轻量级的删除行的方式,但其列式结构意味着这些操作应谨慎安排,如上所述。这些操作是异步处理的,使用单线程处理,并要求(在更新的情况下)数据在磁盘上被重写。因此,它们不应被用于高数量的小变更。 +为了处理更新和删除行的流,同时避免上述使用模式,我们可以使用 ClickHouse 表引擎 ReplacingMergeTree。 -为了处理更新和删除行的流,并避免上述使用模式,我们可以使用 ClickHouse 表引擎 ReplacingMergeTree。 +## 插入行的自动上载 {#automatic-upserts-of-inserted-rows} -## 自动更新插入行 {#automatic-upserts-of-inserted-rows} +[ReplacingMergeTree 表引擎](/engines/table-engines/mergetree-family/replacingmergetree) 允许对行应用更新操作,无需使用低效的 `ALTER` 或 `DELETE` 语句,提供了用户插入相同行的多个副本并标记一个为最新版本的能力。后台进程则异步移除同一行的较旧版本,通过不可变插入高效模拟更新操作。 +这依赖于表引擎识别重复行的能力。这是通过使用 `ORDER BY` 子句来确定唯一性来实现的,即如果两行在 `ORDER BY` 中指定的列上具有相同的值,则它们被视为重复。一列 `version` 列,在定义表时指定,允许在识别出两行为重复时保留最新版本,即保留版本值最高的行。 +我们在下面的示例中说明这个过程。在这里,行通过 A 列(表的 `ORDER BY`)唯一标识。我们假设这些行是作为两个批次插入的,导致在磁盘上形成两个数据部分。稍后,在异步后台进程中,这些部分被合并在一起。 -[ReplacingMergeTree 表引擎](/engines/table-engines/mergetree-family/replacingmergetree) 允许对行执行更新操作,无需使用低效的 `ALTER` 或 `DELETE` 语句,用户可以插入多份相同的行,并将其中一份标记为最新版本。后台进程异步移除同一行的旧版本,通过使用不可变的插入高效地模拟更新操作。 +ReplacingMergeTree 另外允许指定一个删除列。它可以包含 0 或 1,其中值为 1 表示该行(及其副本)已被删除,而值为 0 表示相反。**注意:已删除的行在合并时不会被删除。** -这依赖于表引擎识别重复行的能力。通过使用 `ORDER BY` 子句来确定唯一性,即如果两行在 `ORDER BY` 中指定的列的值相同,则它们被视为重复。定义表时指定的 `version` 列允许在识别到两行重复时保留最新版本,即保留版本值最高的行。 +在此过程期间,部分合并期间发生以下情况: -我们在下面的示例中说明这个过程。在这里,行通过 A 列独特地标识(表的 `ORDER BY`)。我们假设这些行以两个批次插入,从而在磁盘上形成两个数据部分。稍后,在异步后台处理过程中,这些部分将合并在一起。 +- 被值 1 标识的 A 列行具有版本为 2 的更新行和版本为 3(删除列值为 1)的删除行。因此,标记为已删除的最新行被保留。 +- 被值 2 标识的 A 列行具有两个更新行。后一个行在价格列上保留值为 6。 +- 被值 3 标识的 A 列行具有版本为 1 的行和版本为 2 的删除行。这个删除行被保留。 -ReplacingMergeTree 还允许指定删除列。该列可以包含 0 或 1 值,其中值为 1 表示该行(及其副本)已被删除,0 表示其他情况。**注意:删除的行在合并时不会被移除。** - -在这个过程中,部分合并时会发生以下情况: - -- 对于 A 列值为 1 的行,有一行版本为 2 的更新行和一行版本为 3 的删除行(删除列值为 1)。因此,标记为删除的最新行被保留。 -- 对于 A 列值为 2 的行,有两行更新行。较后的一行被保留,价格列的值为 6。 -- 对于 A 列值为 3 的行,有一行版本为 1 和一行版本为 2 的删除行。该删除行被保留。 - -通过这个合并过程,我们得到了四行,代表最终状态: +通过此合并过程,我们得到了四个表示最终状态的行:
@@ -39,10 +37,10 @@ ReplacingMergeTree 还允许指定删除列。该列可以包含 0 或 1 值,
-请注意,删除的行不会被移除。可以使用 `OPTIMIZE table FINAL CLEANUP` 强制删除。这需要实验性设置 `allow_experimental_replacing_merge_with_cleanup=1`。此操作仅在以下条件下发出: +注意,已删除的行永远不会被删除。可以通过 `OPTIMIZE table FINAL CLEANUP` 强制删除它们。这需要实验性设置 `allow_experimental_replacing_merge_with_cleanup=1`。仅在以下条件下发出: -1. 在操作发出后,您可以确保不会插入任何旧版本的行(对于那些将被清理的行)。如果这些行被插入,它们将被错误地保留,因为已删除的行将不再存在。 -2. 确保在发出清理之前所有副本都已同步。这可以通过以下命令实现: +1. 你可以确保在发出操作后不会插入带有旧版本的行(对于那些正在被清理的行)。如果这些行被插入,它们会被错误地保留,因为已删除的行将不再存在。 +2. 在发出清理之前确保所有副本保持同步。这可以通过命令实现:
@@ -50,21 +48,20 @@ ReplacingMergeTree 还允许指定删除列。该列可以包含 0 或 1 值, SYSTEM SYNC REPLICA table ``` -我们建议在确保 (1) 后暂停插入,直到此命令和后续的清理完成。 +我们建议在确认 (1) 后暂停插入,直到此命令和随后的清理完成。 -> 使用 ReplacingMergeTree 处理删除操作仅建议用于删除数量低到中等的表(少于 10%),除非可以按照上述条件安排清理时间段。 +> 对于删除的处理,使用 ReplacingMergeTree 仅推荐用于删除数量较少到中等的表(少于 10%),除非可以根据上述条件安排清理周期。 -> 提示:用户还可以对不再受到更改影响的选择性分区发出 `OPTIMIZE FINAL CLEANUP`。 +> 提示:用户也可以对不再发生变化的选择分区执行 `OPTIMIZE FINAL CLEANUP`。 ## 选择主键/去重键 {#choosing-a-primarydeduplication-key} -上述内容中,我们强调了在 ReplacingMergeTree 的情况下必须满足的一个重要额外约束:`ORDER BY` 的列值在变更中唯一标识一行。如果是从像 Postgres 的事务型数据库迁移,则原 Postgres 主键应包含在 ClickHouse 的 `ORDER BY` 子句中。 - -ClickHouse 的用户将熟悉选择其表中 `ORDER BY` 子句的列以[优化查询性能](/data-modeling/schema-design#choosing-an-ordering-key)。通常,这些列应基于您[频繁查询的列并按增大基数顺序列出](/guides/best-practices/sparse-primary-indexes#an-index-design-for-massive-data-scales)。重要的是,ReplacingMergeTree 施加了一个额外约束:这些列必须是不可变的,即如果从 Postgres 复制,则仅在底层 Postgres 数据中不更改的情况下,将列添加到此子句中。虽然其他列可以改变,但它们在唯一行标识中需保持一致。 +上面提到,在使用 ReplacingMergeTree 的情况下,必须满足一个重要的附加约束:`ORDER BY` 列的值在变更过程中唯一标识一行。如果从像 Postgres 这样的事务数据库迁移,则应该在 Clickhouse 的 `ORDER BY` 子句中包含原始 Postgres 主键。 -对于分析工作负载而言,Postgres 主键通常几乎没有用,因为用户很少进行点行查找。鉴于我们建议按增大基数的顺序排列列,并且在 `[ORDER BY] 中列出的前面列的匹配通常更快](/guides/best-practices/sparse-primary-indexes#ordering-key-columns-efficiently),Postgres 主键应附加到 `ORDER BY` 的末尾(除非它具有分析价值)。如果多个列在 Postgres 中形成主键,应将其附加到 `ORDER BY` 中,同时尊重基数和查询值的可能性。用户可能还希望通过 `MATERIALIZED` 列使用值的连接生成一个唯一主键。 +ClickHouse 用户会熟悉在其表的 `ORDER BY` 子句中选择列以[优化查询性能](/data-modeling/schema-design#choosing-an-ordering-key)。通常,这些列应根据你的[常见查询并按递增基数列出](/guides/best-practices/sparse-primary-indexes#an-index-design-for-massive-data-scales)进行选择。重要的是,ReplacingMergeTree 施加了一个额外的约束——这些列必须是不可变的,即如果是从 Postgres 复制,只应在这些列在底层 Postgres 数据中不变的情况下将其添加到此子句中。虽然其他列可以更改,但这些列需要保持一致,以便唯一识别行。 +对于分析工作负载,Postgres 主键通常用途不大,因为用户很少进行点行查找。考虑到我们建议这些列按基数递增的顺序排列,以及与[在 ORDER BY 之前列出列匹配通常会更快](/guides/best-practices/sparse-primary-indexes#ordering-key-columns-efficiently),Postgres 主键应添加到 `ORDER BY` 的末尾(除非它具有分析价值)。如果 Postgres 中的多个列组成主键,应该将其附加到 `ORDER BY`,遵循基数和查询值的可能性。用户可能还希望通过 `MATERIALIZED` 列使用值的串联生成唯一主键。 -考虑 Stack Overflow 数据集中的帖子表。 +考虑 Stack Overflow 数据集中的 posts 表。 ```sql CREATE TABLE stackoverflow.posts_updateable @@ -99,15 +96,15 @@ PARTITION BY toYear(CreationDate) ORDER BY (PostTypeId, toDate(CreationDate), CreationDate, Id) ``` -我们使用 `(PostTypeId, toDate(CreationDate), CreationDate, Id)` 的 `ORDER BY` 键。`Id` 列每个帖子都是唯一的,确保可以去重。根据需求添加 `Version` 和 `Deleted` 列到模式中。 +我们使用 `(PostTypeId, toDate(CreationDate), CreationDate, Id)` 的 `ORDER BY` 键。`Id` 列是每个帖子的唯一标识,确保行可以去重。根据要求往模式中添加了 `Version` 和 `Deleted` 列。 ## 查询 ReplacingMergeTree {#querying-replacingmergetree} -在合并时,ReplacingMergeTree 使用 `ORDER BY` 列的值作为唯一标识符,识别重复行,要么保留最高版本的行,要么如果最新版本指示删除,则删除所有重复行。然而,这仅提供最终的正确性 - 它不保证行将被去重,因此不应对此产生依赖。因此,由于在查询中考虑到更新和删除行,查询可能会产生不正确的答案。 +在合并时,ReplacingMergeTree 使用 `ORDER BY` 列的值作为唯一标识符来识别重复行,并保留最高版本或在最新版本指示删除时删除所有重复。这仅提供最终正确性——它并不保证行会被去重,因此你不应依赖它。因此,查询可能由于更新和删除行被考虑在查询中而导致错误答案。 -为了获取正确的答案,用户需要在查询时去重和删除移除,来补充后台合并。这可以通过使用 `FINAL` 运算符实现。 +为了获得正确的答案,用户需要在查询时间的去重和删除移除中补充后台合并。这可以通过使用 `FINAL` 运算符实现。 -考虑上面的帖子表。我们可以使用加载此数据集的普通方法,但在值 0 之外指定删除和版本列。例如出于示范目的,我们只加载 10000 行。 +考虑上面的 posts 表。我们可以使用加载此数据集的正常方法,但除了值 0 外,还指定删除和版本列。例如,仅加载 10,000 行。 ```sql INSERT INTO stackoverflow.posts_updateable SELECT 0 AS Version, 0 AS Deleted, * @@ -116,7 +113,7 @@ FROM s3('https://datasets-documentation.s3.eu-west-3.amazonaws.com/stackoverflow 0 rows in set. Elapsed: 1.980 sec. Processed 8.19 thousand rows, 3.52 MB (4.14 thousand rows/s., 1.78 MB/s.) ``` -让我们确认行数: +确认行数: ```sql SELECT count() FROM stackoverflow.posts_updateable @@ -128,7 +125,7 @@ SELECT count() FROM stackoverflow.posts_updateable 1 row in set. Elapsed: 0.002 sec. ``` -我们现在更新我们的回答统计信息。我们并不是更新这些值,而是插入 5000 行的行的新副本,并将它们的版本号加一(这意味着表中将存在 150 行)。我们可以通过简单的 `INSERT INTO SELECT` 来模拟这一点: +我们现在更新我们的帖子答案统计数据。我们不是更新这些值,而是插入 5000 行的新副本,并将它们的版本号加一(这意味着该表中将存在 150 行)。我们可以通过简单的 `INSERT INTO SELECT` 来模拟这一点: ```sql INSERT INTO posts_updateable SELECT @@ -163,7 +160,7 @@ LIMIT 5000 0 rows in set. Elapsed: 4.056 sec. Processed 1.42 million rows, 2.20 GB (349.63 thousand rows/s., 543.39 MB/s.) ``` -此外,我们通过重新插入行但将删除列值设置为 1 来删除 1000 个随机帖子。同样,模拟这个也可以通过简单的 `INSERT INTO SELECT`。 +此外,我们通过重新插入行但删除列值为 1 来删除 1000 条随机帖子。再一次,模拟这可以通过简单的 `INSERT INTO SELECT` 完成。 ```sql INSERT INTO posts_updateable SELECT @@ -198,7 +195,7 @@ LIMIT 1000 0 rows in set. Elapsed: 0.166 sec. Processed 135.53 thousand rows, 212.65 MB (816.30 thousand rows/s., 1.28 GB/s.) ``` -上述操作的结果将是 16,000 行,即 10,000 + 5000 + 1000。正确的总数是,实际上我们应该比原始总数少 1000 行,即 10,000 - 1000 = 9000。 +上述操作的结果将是 16,000 行,即 10,000 + 5000 + 1000。这里的正确总数实际上应该仅少于我们原始总数 1000 行,即 10,000 - 1000 = 9000。 ```sql SELECT count() @@ -210,7 +207,7 @@ FROM posts_updateable 1 row in set. Elapsed: 0.002 sec. ``` -您的结果在这里会有所不同,具体取决于发生的合并情况。我们可以看到这里的总数不同,因为我们有重复的行。对表应用 `FINAL` 将返回正确的结果。 +你的结果将因发生的合并而异。我们可以看到这里的总数不同,因为我们有重复行。对表应用 `FINAL` 可以提供正确的结果。 ```sql SELECT count() @@ -227,17 +224,18 @@ Peak memory usage: 8.14 MiB. ## FINAL 性能 {#final-performance} -尽管持续改进,`FINAL` 运算符对查询仍会有性能开销。当查询未在主键列上进行过滤时,这种开销最为明显,导致读取更多数据,并增加去重开销。如果用户使用 `WHERE` 条件在关键列上进行过滤,通过去重所加载和传递的数据会减少。 +`FINAL` 运算符确实对查询有小的性能开销。 +这在查询未对主键列进行过滤时最为明显,使得读取更多数据并增加去重的开销。如果用户使用 `WHERE` 条件针对键列进行过滤,则加载和传递给去重的数据将减少。 -如果 `WHERE` 条件未使用关键列,ClickHouse 在使用 `FINAL` 时不会当前利用 `PREWHERE` 优化。此优化旨在减少读取未过滤列的行数。有关模拟此 `PREWHERE` 从而潜在提高性能的示例,可以在[此处](https://clickhouse.com/blog/clickhouse-postgresql-change-data-capture-cdc-part-1#final-performance)找到。 +如果 `WHERE` 条件未使用键列,ClickHouse 目前在使用 `FINAL` 时不会利用 `PREWHERE` 优化。此优化旨在减少读取未过滤列的行数。模拟此 `PREWHERE` 的例子,从而可能提高性能,可以在[这里](https://clickhouse.com/blog/clickhouse-postgresql-change-data-capture-cdc-part-1#final-performance)找到。 ## 利用分区与 ReplacingMergeTree {#exploiting-partitions-with-replacingmergetree} -ClickHouse 的数据合并发生在分区级别。使用 ReplacingMergeTree 时,我们建议用户根据最佳实践对表进行分区,前提是用户可以确保**分区键对行不改变**。这将确保与同一行相关的更新发送到同一 ClickHouse 分区。您可以重用 Postgres 的相同分区键,只要您遵循此处概述的最佳实践。 +ClickHouse 中的数据合并发生在分区级别。在使用 ReplacingMergeTree 时,我们建议用户根据最佳实践为他们的表进行分区,前提是用户能够确保这个**分区键对于一行不变**。这将确保与同一行相关的更新将发送到同一 ClickHouse 分区。只要遵循此处概述的最佳实践,您可以重用与 Postgres 相同的分区键。 -假设是这种情况,用户可以使用设置 `do_not_merge_across_partitions_select_final=1` 来提高 `FINAL` 查询性能。此设置使得在使用 FINAL 时,分区独立进行合并和处理。 +假设情况如此,用户可以使用设置 `do_not_merge_across_partitions_select_final=1` 来提高 `FINAL` 查询性能。此设置导致在使用 FINAL 时分区独立合并和处理。 -考虑以下帖子表,其中我们不使用分区: +考虑以下帖子表,我们不使用任何分区: ```sql CREATE TABLE stackoverflow.posts_no_part @@ -256,7 +254,7 @@ FROM s3('https://datasets-documentation.s3.eu-west-3.amazonaws.com/stackoverflow 0 rows in set. Elapsed: 182.895 sec. Processed 59.82 million rows, 38.07 GB (327.07 thousand rows/s., 208.17 MB/s.) ``` -为了确保 `FINAL` 需要执行一些操作,我们更新 1m 行 - 通过插入重复行将其 `AnswerCount` 递增。 +为了确保 `FINAL` 需要做一些工作,我们更新 1m 行——通过插入重复行将其 `AnswerCount` 增加。 ```sql INSERT INTO posts_no_part SELECT Version + 1 AS Version, Deleted, Id, PostTypeId, AcceptedAnswerId, CreationDate, Score, ViewCount, Body, OwnerUserId, OwnerDisplayName, LastEditorUserId, LastEditorDisplayName, LastEditDate, LastActivityDate, Title, Tags, AnswerCount + 1 AS AnswerCount, CommentCount, FavoriteCount, ContentLicense, ParentId, CommunityOwnedDate, ClosedDate @@ -264,7 +262,7 @@ FROM posts_no_part LIMIT 1000000 ``` -计算每年答案的总和,并使用 `FINAL`: +计算每年的答案总和,使用 `FINAL`: ```sql SELECT toYear(CreationDate) AS year, sum(AnswerCount) AS total_answers @@ -283,7 +281,7 @@ ORDER BY year ASC Peak memory usage: 2.09 GiB. ``` -对按年分区的表重复相同的步骤,并使用 `do_not_merge_across_partitions_select_final=1` 重复上述查询。 +对按年分区的表重复相同步骤,并与使用 `do_not_merge_across_partitions_select_final=1` 重新执行上述查询。 ```sql CREATE TABLE stackoverflow.posts_with_part @@ -317,42 +315,42 @@ ORDER BY year ASC 17 rows in set. Elapsed: 0.994 sec. Processed 64.65 million rows, 983.64 MB (65.02 million rows/s., 989.23 MB/s.) ``` -如所示,分区在此情况下显著改善了查询性能,通过允许去重过程在分区级别并行发生。 +如图所示,在这种情况下,通过允许去重过程在分区级别并行发生,分区显著提高了查询性能。 ## 合并行为考虑 {#merge-behavior-considerations} -ClickHouse 的合并选择机制不仅仅是简单地合并部分。下面,我们将探讨在 ReplacingMergeTree 上下文中的这种行为,包括用于启用对旧数据更激进合并的配置选项以及较大部分的考虑因素。 +ClickHouse 的合并选择机制超越了简单的部分合并。下面,我们在 ReplacingMergeTree 的背景下检查此行为,包括启用对旧数据进行更激进合并的配置选项和对较大部分的考虑。 ### 合并选择逻辑 {#merge-selection-logic} -尽管合并旨在将部分数量最小化,但它还需要在写放大成本与此目标之间保持平衡。因此,如果部分范围的合并会导致过度的写放大,则将其排除在外。这种行为有助于防止资源不必要的使用,并延长存储组件的使用寿命。 +虽然合并旨在最小化部分数量,但它也平衡这个目标与写入放大效应的成本。因此,如果合并会导致过度的写入放大,一些部分范围将被排除在合并之外,基于内部计算。这种行为有助于防止不必要的资源使用,并延长存储组件的寿命。 -### 对大部分的合并行为 {#merging-behavior-on-large-parts} +### 对大型部分的合并行为 {#merging-behavior-on-large-parts} -ClickHouse 中的 ReplacingMergeTree 引擎经过优化以通过合并数据部分来管理重复行,仅保留基于指定唯一键的每行的最新版本。然而,当合并部分达到 max_bytes_to_merge_at_max_space_in_pool 阈值时,即使设置了 min_age_to_force_merge_seconds,它也将不再被选择进行进一步合并。因此,无法再依赖自动合并来移除可能随着持续数据插入而累积的重复行。 +ClickHouse 中的 ReplacingMergeTree 引擎经过优化以通过合并数据部分来管理重复行,仅保留每行基于指定的唯一键的最新版本。然而,当合并后的部分达到 max_bytes_to_merge_at_max_space_in_pool 阈值时,它将不再被选中进行进一步的合并,即使 min_age_to_force_merge_seconds 被设置。因此,自动合并不能再依赖于去除随着数据插入而可能累积的重复数据。 -为了解决这个问题,用户可以调用 OPTIMIZE FINAL 来手动合并部分并移除重复行。与自动合并不同,OPTIMIZE FINAL 将绕过 max_bytes_to_merge_at_max_space_in_pool 阈值,仅根据可用资源(特别是磁盘空间)合并部分,直到每个分区余留一个部分。然而,该方法在大表上可能消耗大量内存,并且可能需要在添加新数据时重复执行。 +为了解决此问题,用户可以调用 OPTIMIZE FINAL 来手动合并部分并移除重复行。与自动合并不同,OPTIMIZE FINAL 会绕过 max_bytes_to_merge_at_max_space_in_pool 阈值,仅基于可用资源,尤其是磁盘空间合并部分,直到每个分区中只剩一个部分。然而,在大型表上,该方法可能会消耗大量内存,并且可能需要随着新数据的添加而重复执行。 -为了保持性能,建议对表进行分区。这可以帮助防止数据部分达到最大合并大小,并减少持续人工优化的需求。 +为了保持性能的可持续解决方案,建议对表进行分区。这可以帮助防止数据部分达到最大合并大小,并减少持续手动优化的需要。 ### 跨分区的合并与分区 {#partitioning-and-merging-across-partitions} -如在利用分区与 ReplacingMergeTree 中所讨论的,我们建议将表分区作为最佳实践。分区将数据隔离以实现更高效的合并,并避免在查询执行期间跨分区合并。这种行为在 23.12 及更高版本中得到了增强:如果分区键是排序键的前缀,则查询时不会跨分区合并,从而提高查询性能。 +正如在利用 ReplacingMergeTree 的分区中讨论的,我们推荐将表进行分区作为最佳实践。分区隔离数据以实现更高效的合并,并在查询执行时避免跨分区合并。自 23.12 版本以来,此行为得到了增强:如果分区键是排序键的前缀,在查询时不进行跨分区合并,从而提高查询性能。 -### 调整合并以提高查询性能 {#tuning-merges-for-better-query-performance} +### 为更好的查询性能调整合并 {#tuning-merges-for-better-query-performance} -默认情况下,min_age_to_force_merge_seconds 和 min_age_to_force_merge_on_partition_only 分别设置为 0 和 false,禁用这些功能。在此配置中,ClickHouse 将应用标准合并行为,而不会根据分区年龄强制合并。 +默认情况下,min_age_to_force_merge_seconds 和 min_age_to_force_merge_on_partition_only 分别设置为 0 和 false,禁用这些功能。在此配置中,ClickHouse 将应用标准合并行为,而不基于分区年龄强制合并。 -如果为 min_age_to_force_merge_seconds 指定了值,则 ClickHouse 将忽略对超过指定时间段的部分的正常合并启发式。虽然这通常仅在目的是最小化部分总数时有效,但它通过减少查询时需要合并的部分数量,可以提高 ReplacingMergeTree 的查询性能。 +如果指定了 min_age_to_force_merge_seconds 的值,ClickHouse 将忽略比指定时间段还大的部分的正常合并启发式。虽然这通常仅在目标是最小化部分总数时有效,但它可以通过减少查询时需要合并的部分数量来提高 ReplacingMergeTree 的查询性能。 -使用设置 min_age_to_force_merge_on_partition_only=true 进一步调整此行为,要求分区中的所有部分必须大于 min_age_to_force_merge_seconds,才能进行激进合并。此配置允许旧分区随着时间的推移合并为一个部分,从而整合数据并保持查询性能。 +通过将 min_age_to_force_merge_on_partition_only 设置为 true 进一步调整该行为,要求分区中的所有部分都要超过 min_age_to_force_merge_seconds 的年龄,才能进行激进合并。此配置允许旧分区随着时间的推移合并为单个部分,从而整合数据并维持查询性能。 ### 推荐设置 {#recommended-settings} :::warning -调整合并行为是一项高级操作。我们建议在生产工作负载中启用这些设置之前咨询 ClickHouse 支持。 +调整合并行为是一项高级操作。我们建议在生产工作负载中启用这些设置之前,先咨询 ClickHouse 支持。 ::: -在大多数情况下,将 min_age_to_force_merge_seconds 设置为一个低值—显著低于分区周期—是首选。这可以最大限度地减少部分数量,并防止在使用 FINAL 运算符时不必要的合并。 +在大多数情况下,将 min_age_to_force_merge_seconds 设置为一个较低的值——显著低于分区周期——是首选。这将最小化部分数量,并防止在使用 FINAL 运算符时在查询时进行不必要的合并。 -例如,考虑一个已经合并为一个部分的每月分区。如果一个小的零散插入在此分区内创建了一个新部分,由于 ClickHouse 必须读取多个部分直到合并完成,查询性能可能会受到影响。设置 min_age_to_force_merge_seconds 可以确保这些部分得到积极合并,防止查询性能退化。 +例如,考虑一个已经合并为一个部分的按月分区。如果一个小的、孤立的插入在此分区内创建了一个新部分,则查询性能可能会受到影响,因为 ClickHouse 必须读取多个部分直到合并完成。设置 min_age_to_force_merge_seconds 可以确保这些部分被激进合并,从而防止查询性能的下降。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/replacing-merge-tree.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/replacing-merge-tree.md.hash index 50dcbf3accc..d4935f74f18 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/replacing-merge-tree.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/replacing-merge-tree.md.hash @@ -1 +1 @@ -c47deda9d052b8f5 +34b3d94999ac94e6 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/time-series-filling-gaps.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/time-series-filling-gaps.md index 868cc924bfa..add17edd2f2 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/time-series-filling-gaps.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/time-series-filling-gaps.md @@ -1,24 +1,23 @@ --- 'slug': '/guides/developer/time-series-filling-gaps' -'sidebar_label': '时间序列 - 填补空缺' +'sidebar_label': '时间序列 - 填补空白' 'sidebar_position': 10 -'description': '填补时间序列数据中的空缺。' +'description': '填补时间序列数据中的空白。' 'keywords': - 'time series' - 'gap fill' -'title': '填补时间序列数据中的空缺' +'title': '填补时间序列数据中的空白' +'doc_type': 'guide' --- -# 填补时间序列数据中的空白 +# 填补时间序列数据的空白 -在处理时间序列数据时,由于缺失数据或不活动,数据中可能会出现空白。 -通常情况下,我们不希望在查询数据时存在这些空白。在这种情况下,`WITH FILL` 子句可以派上用场。 -本指南讨论了如何使用 `WITH FILL` 来填补时间序列数据中的空白。 +在处理时间序列数据时,由于缺失数据或不活动,可能会出现数据空白。通常情况下,当我们查询数据时,不希望这些空白存在。在这种情况下,`WITH FILL` 子句可以派上用场。本指南讨论了如何使用 `WITH FILL` 来填补时间序列数据中的空白。 ## 设置 {#setup} -假设我们有以下表格,用于存储由 GenAI 图像服务生成的图像的元数据: +假设我们有以下表格,该表存储由 GenAI 图像服务生成的图像元数据: ```sql CREATE TABLE images @@ -47,14 +46,14 @@ INSERT INTO images VALUES (1088619208425437515, '2023-03-24 00:24:05.160', 1024, ## 按桶查询 {#querying-by-bucket} -我们将探索在 2023 年 3 月 24 日的 `00:24:03` 和 `00:24:04` 之间创建的图像,因此让我们为这些时间点创建一些参数: +我们将探索 2023 年 3 月 24 日 `00:24:03` 到 `00:24:04` 之间创建的图像,因此让我们为这些时刻创建一些参数: ```sql SET param_start = '2023-03-24 00:24:03', param_end = '2023-03-24 00:24:04'; ``` -接下来,我们将编写一个查询,将数据分组到 100 毫秒的桶中,并返回在该桶中创建的图像数量: +接下来,我们将编写一个查询,将数据分组为 100 毫秒的桶,并返回在该桶中创建的图像数量: ```sql SELECT @@ -77,13 +76,11 @@ ORDER BY bucket ASC └─────────────────────────┴───────┘ ``` -结果集仅包括在其中创建了图像的桶,但对于时间序列分析,我们可能希望返回每个 100 毫秒的桶,即使它没有任何条目。 +结果集仅包括创建了图像的桶,但对于时间序列分析,我们可能希望返回每个 100 毫秒的桶,即使它没有任何条目。 ## WITH FILL {#with-fill} -我们可以使用 `WITH FILL` 子句来填补这些空白。 -我们还将指定 `STEP`,即要填补的空白的大小。 -对于 `DateTime` 类型,默认值是 1 秒,但我们希望填补 100 毫秒的空白,因此我们将步长值设置为 100 毫秒: +我们可以使用 `WITH FILL` 子句来填补这些空白。我们还将指定 `STEP`,即要填补的空白大小。对于 `DateTime` 类型,这默认值为 1 秒,但我们希望填补长度为 100 毫秒的空白,所以我们将 100 毫秒作为我们的步长值: ```sql SELECT @@ -115,11 +112,11 @@ STEP toIntervalMillisecond(100); └─────────────────────────┴───────┘ ``` -我们可以看到,空白在 `count` 列中已被 0 值填充。 +我们可以看到,空白在 `count` 列中已填补为 0 值。 ## WITH FILL...FROM {#with-fillfrom} -不过,时间范围的开始处仍有一个空白,我们可以通过指定 `FROM` 来解决这个问题: +然而,时间范围开始处仍然存在一个空白,我们可以通过指定 `FROM` 来修复它: ```sql SELECT @@ -158,12 +155,11 @@ STEP toIntervalMillisecond(100); └─────────────────────────┴───────┘ ``` -从结果中可以看到,`00:24:03.000` 到 `00:24:03.500` 的桶现在都已出现。 +从结果中我们可以看到,从 `00:24:03.000` 到 `00:24:03.500` 的桶现在都出现了。 ## WITH FILL...TO {#with-fillto} -不过,我们仍然缺少一些时间范围结束时的桶,我们可以通过提供 `TO` 值来填补这些空白。 -`TO` 是不包含的,因此我们将结束时间加上一小段时间,以确保它被包括在内: +不过,我们仍然缺少一些来自时间范围结束的桶,我们可以通过提供一个 `TO` 值来填补。`TO` 是不包含的,因此我们将结束时间稍微加上一点,以确保它被包含: ```sql SELECT @@ -205,12 +201,11 @@ STEP toIntervalMillisecond(100); └─────────────────────────┴───────┘ ``` -所有空白现在都已填补,我们从 `00:24:03.000` 到 `00:24:05.000` 的每 100 毫秒都有条目。 +现在所有的空白都已经被填补,我们有从 `00:24:03.000` 到 `00:24:05.000` 每 100 毫秒的条目。 ## 累计计数 {#cumulative-count} -假设我们现在想保持跨桶创建的图像数量的累计计数。 -我们可以通过添加一个 `cumulative` 列来实现,如下所示: +假设我们现在想要保持每个桶中创建的图像数量的累计计数。我们可以通过添加一个 `cumulative` 列来实现,如下所示: ```sql SELECT @@ -253,12 +248,11 @@ STEP toIntervalMillisecond(100); └─────────────────────────┴───────┴────────────┘ ``` -累计列中的值并未按照我们希望的方式工作。 +累计列中的值并没有按我们希望的方式工作。 ## WITH FILL...INTERPOLATE {#with-fillinterpolate} -任何 `count` 列中为 `0` 的行,`cumulative` 列中也为 `0`,而我们希望它使用 `cumulative` 列中的上一个值。 -我们可以通过使用 `INTERPOLATE` 子句来实现,如下所示: +任何 `count` 列中为 `0` 的行在累计列中也为 `0`,而我们更希望它使用累计列中的前一个值。我们可以通过使用 `INTERPOLATE` 子句来做到这一点,如下所示: ```sql SELECT @@ -302,8 +296,7 @@ INTERPOLATE (cumulative); └─────────────────────────┴───────┴────────────┘ ``` -看起来好多了。 -现在为了完成它,让我们使用 `bar` 函数添加一个条形图,别忘了将我们的新列添加到 `INTERPOLATE` 子句中。 +这看起来好多了。现在让我们用 `bar` 函数添加一个条形图,不要忘记将我们的新列添加到 `INTERPOLATE` 子句中。 ```sql SELECT diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/time-series-filling-gaps.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/time-series-filling-gaps.md.hash index 0857adebfe3..27f91de52d0 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/time-series-filling-gaps.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/time-series-filling-gaps.md.hash @@ -1 +1 @@ -d4b1d30d7fa81654 +41413d018d712435 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/ttl.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/ttl.md index 8f8b1b2f892..57099a8cddc 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/ttl.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/ttl.md @@ -8,9 +8,10 @@ - 'clickhouse' - 'old' - 'data' -'description': '生存时间 (TTL) 指的是在经过一定时间间隔后,可以移动、删除或汇总行或列的能力。' +'description': '生存时间 (TTL) 指的是在经过特定时间间隔后,实现行或列被移动、删除或汇总的能力。' 'title': '使用生存时间 (TTL) 管理数据' 'show_related_blogs': true +'doc_type': 'guide' --- import CloudNotSupportedBadge from '@theme/badges/CloudNotSupportedBadge'; @@ -20,11 +21,11 @@ import CloudNotSupportedBadge from '@theme/badges/CloudNotSupportedBadge'; ## TTL 概述 {#overview-of-ttl} -TTL(生存时间)指的是在经过一定时间段后,可以将行或列移动、删除或汇总的能力。虽然“生存时间”这个词听起来像是只适用于删除旧数据,但 TTL 有多种用例: +TTL(生存时间)指的是在一定时间间隔后将行或列移动、删除或汇总的能力。虽然“生存时间”这个表达听起来好像只适用于删除旧数据,但 TTL 有几个用途: -- 删除旧数据:不出所料,您可以在指定时间间隔后删除行或列 -- 在磁盘之间移动数据:经过一段时间后,您可以在存储卷之间移动数据 - 这对于部署热/温/冷架构非常有用 -- 数据汇总:在删除之前,将旧数据汇总成各种有用的聚合和计算 +- 删除旧数据:毫无疑问,您可以在指定的时间间隔后删除行或列 +- 在磁盘之间移动数据:在一定时间后,您可以在存储卷之间移动数据——这对于部署热/温/冷架构很有用 +- 数据汇总:在删除之前,将旧数据汇总为各种有用的聚合和计算 :::note TTL 可以应用于整个表或特定列。 @@ -32,7 +33,7 @@ TTL 可以应用于整个表或特定列。 ## TTL 语法 {#ttl-syntax} -`TTL` 子句可以出现在列定义之后和/或表定义的末尾。使用 `INTERVAL` 子句来定义一个时间长度(需要是 `Date` 或 `DateTime` 数据类型)。例如,以下表具有两个带有 `TTL` 子句的列: +`TTL` 子句可以出现在列定义后和/或表定义的末尾。使用 `INTERVAL` 子句定义时间长度(需要是 `Date` 或 `DateTime` 数据类型)。例如,以下表有两个带有 `TTL` 子句的列: ```sql CREATE TABLE example1 ( @@ -45,9 +46,9 @@ ENGINE = MergeTree ORDER BY tuple() ``` -- x 列的生存时间为从时间戳列开始的 1 个月 -- y 列的生存时间为从时间戳列开始的 1 天 -- 当时间间隔到期时,列到期。ClickHouse 将列值替换为其数据类型的默认值。如果数据部分中的所有列值到期,ClickHouse 将从文件系统中的数据部分删除该列。 +- x 列的生存时间为来自时间戳列的 1 个月 +- y 列的生存时间为来自时间戳列的 1 天 +- 当时间间隔到期时,列会过期。ClickHouse 用其数据类型的默认值替换列值。如果数据部分的所有列值均过期,则 ClickHouse 从文件系统中的数据部分删除该列。 :::note TTL 规则可以被更改或删除。有关更多详细信息,请参见 [Manipulations with Table TTL](/sql-reference/statements/alter/ttl.md) 页面。 @@ -55,26 +56,26 @@ TTL 规则可以被更改或删除。有关更多详细信息,请参见 [Manip ## 触发 TTL 事件 {#triggering-ttl-events} -删除或聚合过期行不是即时的 - 只在表合并期间发生。如果您有一个没有积极合并的表(出于任何原因),则有两个设置触发 TTL 事件: +过期行的删除或聚合并不是立即发生的——它只在表合并期间发生。如果您有一个未积极合并的表(出于任何原因),有两个设置可以触发 TTL 事件: -- `merge_with_ttl_timeout`:在重复合并带有删除 TTL 的表之前的最小延迟(秒)。默认值为 14400 秒(4 小时)。 -- `merge_with_recompression_ttl_timeout`:在重复合并带有重新压缩 TTL(在删除之前汇总数据的规则)的表之前的最小延迟(秒)。默认值:14400 秒(4 小时)。 +- `merge_with_ttl_timeout`:在重复执行删除 TTL 合并之前的最小延迟(以秒为单位)。默认值为 14400 秒(4 小时)。 +- `merge_with_recompression_ttl_timeout`:在重复执行重压缩 TTL 合并(在删除之前汇总数据的规则)之前的最小延迟(以秒为单位)。默认值:14400 秒(4 小时)。 -因此,默认情况下,您的 TTL 规则将至少每 4 小时应用于您的表。如果您需要更频繁地应用 TTL 规则,只需修改以上设置。 +因此,默认情况下,您的 TTL 规则每 4 小时至少会应用到您的表上。如果您需要更频繁地应用 TTL 规则,只需修改上述设置。 :::note -这不是一个很好的解决方案(或者我们推荐您经常使用的解决方案),但您仍可以使用 `OPTIMIZE` 强制合并: +这不是一个很好的解决方案(或我们推荐您经常使用的方案),但您也可以使用 `OPTIMIZE` 强制合并: ```sql OPTIMIZE TABLE example1 FINAL ``` -`OPTIMIZE` 初始化您的表部分的非调度合并,`FINAL` 则强制重新优化(如果您的表已经是单个部分)。 +`OPTIMIZE` 会初始化您表的分区的非计划合并,并且如果您的表已经是单个分区,`FINAL` 会强制重新优化。 ::: ## 删除行 {#removing-rows} -要在经过一定时间后从表中删除整行,请在表级别定义 TTL 规则: +要在一段时间后从表中删除整个行,请在表级别定义 TTL 规则: ```sql CREATE TABLE customers ( @@ -88,7 +89,8 @@ ORDER BY timestamp TTL timestamp + INTERVAL 12 HOUR ``` -此外,可以基于记录的值定义 TTL 规则。这可以通过指定一个 where 条件轻松实现。允许多个条件: +此外,可以根据记录的值定义 TTL 规则。通过指定 WHERE 条件可以轻松实现。 +允许多个条件: ```sql CREATE TABLE events @@ -105,7 +107,7 @@ TTL time + INTERVAL 1 MONTH DELETE WHERE event != 'error', ## 删除列 {#removing-columns} -假设您不想删除整行,而只是希望余额和地址列过期。让我们修改 `customers` 表,并为这两列添加 2 小时的 TTL: +假设您只想让余额和地址列过期,而不是删除整个行。让我们修改 `customers` 表,为两个列添加 2 小时的 TTL: ```sql ALTER TABLE customers @@ -115,9 +117,9 @@ MODIFY COLUMN address String TTL timestamp + INTERVAL 2 HOUR ## 实现汇总 {#implementing-a-rollup} -假设我们想在经过一定时间后删除行,但保留某些用于报告的数据。我们不想要所有细节 - 只需几个历史数据的聚合结果。通过在 `TTL` 表达式中添加 `GROUP BY` 子句以及一些列来存储聚合结果,可以实现这一点。 +假设我们想在一定时间后删除行,但保留一些数据用于报告目的。我们不希望所有的细节——只需要一些历史数据的汇总结果。这可以通过在 `TTL` 表达式中添加 `GROUP BY` 子句来实现,并在表中添加一些列以存储汇总结果。 -假设在以下 `hits` 表中,我们希望删除旧行,但保留 `hits` 列的总和和最大值,然后再删除这些行。我们将需要一个字段来存储这些值,并需要在汇总最大值和总和的 `TTL` 子句中添加 `GROUP BY` 子句: +假设在以下 `hits` 表中,我们想删除旧行,但在删除行之前保留 `hits` 列的总和和最大值。我们需要一个字段来存储这些值,并且需要在汇总总和和最大值的 `TTL` 子句中添加 `GROUP BY` 子句: ```sql CREATE TABLE hits ( @@ -138,21 +140,21 @@ TTL timestamp + INTERVAL 1 DAY 关于 `hits` 表的一些说明: -- `TTL` 子句中的 `GROUP BY` 列必须是 `PRIMARY KEY` 的前缀,并且我们希望按天开始对结果进行分组。因此,将 `toStartOfDay(timestamp)` 添加到主键中 -- 我们添加了两个字段来存储聚合结果:`max_hits` 和 `sum_hits` -- 为了使我们的逻辑正常工作,必须将 `max_hits` 和 `sum_hits` 的默认值设置为 `hits`,基于 `SET` 子句的定义 +- `TTL` 子句中的 `GROUP BY` 列必须是 `PRIMARY KEY` 的前缀,并且我们希望按一天的开始来对结果进行分组。因此,向主键中添加了 `toStartOfDay(timestamp)` +- 我们添加了两个字段来存储汇总结果:`max_hits` 和 `sum_hits` +- 根据 `SET` 子句的定义,将 `max_hits` 和 `sum_hits` 的默认值设置为 `hits` 是必需的,以使我们的逻辑正常工作。 ## 实现热/温/冷架构 {#implementing-a-hotwarmcold-architecture} :::note -如果您使用的是 ClickHouse Cloud,本课程中的步骤不适用。您不必担心在 ClickHouse Cloud 中移动旧数据。 +如果您使用的是 ClickHouse Cloud,本课程中的步骤不适用。您无需担心在 ClickHouse Cloud 中移动旧数据。 ::: -处理大量数据时的一个常见做法是根据数据变旧的过程移动数据。以下是在 ClickHouse 中使用 `TTL` 命令的 `TO DISK` 和 `TO VOLUME` 子句实现热/温/冷架构的步骤。(顺便说一下,这并不一定要是冷热之分 - 您可以使用 TTL 根据任何用例移动数据。) +在处理大量数据时,常见的做法是随着数据变旧而移动这些数据。以下是在 ClickHouse 中使用 `TTL` 命令的 `TO DISK` 和 `TO VOLUME` 子句实现热/温/冷架构的步骤。(顺便说一下,这不一定是热和冷的事情——您可以使用 TTL 来根据您的用例移动数据。) -1. `TO DISK` 和 `TO VOLUME` 选项指的是在 ClickHouse 配置文件中定义的磁盘或卷的名称。创建一个名为 `my_system.xml`(或任何文件名)的新文件,该文件定义了您的磁盘,然后定义使用您磁盘的卷。将 XML 文件放在 `/etc/clickhouse-server/config.d/` 中以使配置应用于您的系统: +1. `TO DISK` 和 `TO VOLUME` 选项指的是在您的 ClickHouse 配置文件中定义的磁盘或卷的名称。创建一个名为 `my_system.xml`(或任何文件名)的新文件,定义您的磁盘,然后定义使用您的磁盘的卷。将 XML 文件放置在 `/etc/clickhouse-server/config.d/` 中,以便对系统应用配置: ```xml @@ -192,7 +194,7 @@ TTL timestamp + INTERVAL 1 DAY ``` -2. 上述配置引用了三个指向 ClickHouse 可以读取和写入的文件夹的磁盘。卷可以包含一个或多个磁盘 - 我们为三个磁盘各自定义了一个卷。让我们查看这些磁盘: +2. 上面的配置引用了三个指向 ClickHouse 可以读写的文件夹的磁盘。卷可以包含一个或多个磁盘——我们为每个磁盘定义了一个卷。让我们查看这些磁盘: ```sql SELECT name, path, free_space, total_space @@ -208,7 +210,7 @@ FROM system.disks └─────────────┴────────────────┴──────────────┴──────────────┘ ``` -3. 并且……让我们验证这些卷: +3. 并且……让我们确认卷: ```sql SELECT @@ -226,7 +228,7 @@ FROM system.storage_policies └─────────────┴───────────────┘ ``` -4. 现在我们将添加一个 `TTL` 规则,将数据在热、温和冷卷之间移动: +4. 现在我们将添加一个 `TTL` 规则,将数据在热、温、冷卷之间移动: ```sql ALTER TABLE my_table @@ -236,14 +238,14 @@ ALTER TABLE my_table trade_date + INTERVAL 4 YEAR TO VOLUME 'cold_volume'; ``` -5. 新的 `TTL` 规则应该体现出来,但您可以强制执行以确保: +5. 新的 `TTL` 规则应该生效,但您可以强制执行以确保: ```sql ALTER TABLE my_table MATERIALIZE TTL ``` -6. 使用 `system.parts` 表验证您的数据已移动到预期的磁盘: +6. 使用 `system.parts` 表验证您的数据已经移动到预期的磁盘: ```sql Using the system.parts table, view which disks the parts are on for the crypto_prices table: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/ttl.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/ttl.md.hash index e1881c128a4..3aef8968a62 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/ttl.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/ttl.md.hash @@ -1 +1 @@ -9b708d4baba01598 +5eb0d63f5ba1fa19 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/understanding-query-execution-with-the-analyzer.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/understanding-query-execution-with-the-analyzer.md index 8c62bf000a6..4694a10913b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/understanding-query-execution-with-the-analyzer.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/understanding-query-execution-with-the-analyzer.md @@ -1,8 +1,9 @@ --- 'slug': '/guides/developer/understanding-query-execution-with-the-analyzer' -'sidebar_label': '理解使用分析器的查询执行' -'title': '理解使用分析器的查询执行' +'sidebar_label': '理解查询执行与分析器' +'title': '理解查询执行与分析器' 'description': '描述如何使用分析器来理解 ClickHouse 如何执行您的查询' +'doc_type': 'guide' --- import analyzer1 from '@site/static/images/guides/developer/analyzer1.png'; @@ -13,9 +14,9 @@ import analyzer5 from '@site/static/images/guides/developer/analyzer5.png'; import Image from '@theme/IdealImage'; -# 理解分析器的查询执行 +# 理解使用分析器的查询执行 -ClickHouse 查询执行的速度极快,但查询的执行并不是一个简单的故事。让我们尝试理解一个 `SELECT` 查询是如何执行的。为了说明这一点,让我们在 ClickHouse 的表中添加一些数据: +ClickHouse 对查询的处理速度非常快,但查询的执行并不是一个简单的故事。让我们尝试理解一个 `SELECT` 查询是如何执行的。为了说明这一点,让我们在 ClickHouse 中的一个表中添加一些数据: ```sql CREATE TABLE session_events( @@ -33,15 +34,15 @@ INSERT INTO session_events SELECT * FROM generateRandom('clientId UUID, type Enum(\'type1\', \'type2\')', 1, 10, 2) LIMIT 1000; ``` -现在我们在 ClickHouse 中有了一些数据,我们想运行一些查询并理解它们的执行。查询的执行被分解为许多个步骤。可以使用相应的 `EXPLAIN` 查询分析和排除故障查询执行的每个步骤。以下图表总结了这些步骤: +现在我们在 ClickHouse 中有了一些数据,我们想运行一些查询并理解它们的执行。查询的执行被分解为多个步骤。每个查询执行的步骤都可以通过相应的 `EXPLAIN` 查询进行分析和排查。这些步骤在下面的图表中总结: -让我们看看查询执行过程中的每个实体。我们将选取几个查询,然后使用 `EXPLAIN` 语句进行检查。 +让我们观察查询执行过程中每个实体的动作。我们将进行几个查询,然后使用 `EXPLAIN` 语句检查它们。 ## 解析器 {#parser} -解析器的目标是将查询文本转换为抽象语法树 (AST)。这个步骤可以使用 `EXPLAIN AST` 进行可视化: +解析器的目标是将查询文本转换为 AST(抽象语法树)。这个步骤可以使用 `EXPLAIN AST` 可视化: ```sql EXPLAIN AST SELECT min(timestamp), max(timestamp) FROM session_events; @@ -64,21 +65,21 @@ EXPLAIN AST SELECT min(timestamp), max(timestamp) FROM session_events; └────────────────────────────────────────────────────┘ ``` -输出是一个可以被可视化的抽象语法树,如下所示: +输出是一个抽象语法树,可以如下所示可视化: -每个节点都有相应的子节点,整个树代表了查询的整体结构。这是一个逻辑结构,有助于处理查询。从最终用户的角度来看(除非对查询执行感兴趣),这不是非常有用;这个工具主要由开发人员使用。 +每个节点都有相应的子节点,整体树结构表示查询的整体结构。这是一个逻辑结构,用于帮助处理查询。从最终用户的角度来看(除非对查询执行感兴趣),它并不是非常有用;这个工具主要由开发者使用。 ## 分析器 {#analyzer} -ClickHouse 当前有两种分析器架构。您可以通过设置 `enable_analyzer=0` 来使用旧架构。新架构默认启用。我们在此仅描述新架构,因为旧架构在新分析器普遍可用后将被弃用。 +ClickHouse 目前有两种架构供分析器使用。你可以通过设置 `enable_analyzer=0` 来使用旧架构。默认情况下启用新架构。我们将在这里仅描述新架构,因为旧架构将在新分析器普遍可用后被弃用。 :::note -新架构应该为我们提供一个更好的框架,以提高 ClickHouse 的性能。然而,由于它是查询处理步骤的一个基本组件,它也可能对某些查询产生负面影响,并且存在 [已知的不兼容性](/operations/analyzer#known-incompatibilities)。您可以通过更改查询或用户级别的 `enable_analyzer` 设置来回退到旧分析器。 +新架构应为我们提供更好的框架,以提高 ClickHouse 的性能。然而,由于它是查询处理步骤的一个基本组成部分,它也可能对某些查询产生负面影响,并且存在[已知的不兼容性](/operations/analyzer#known-incompatibilities)。你可以通过在查询或用户级别更改 `enable_analyzer` 设置来恢复到旧分析器。 ::: -分析器是查询执行的重要步骤。它接受抽象语法树并将其转换为查询树。查询树相对于抽象语法树的主要好处在于许多组件将被解析,例如存储。我们还知道从哪个表中读取,别名也已解析,树中知道使用的不同数据类型。凭借这些好处,分析器可以应用优化。这些优化的工作方式是通过“遍历”。每个遍历将寻找不同的优化。您可以在 [这里](https://github.com/ClickHouse/ClickHouse/blob/76578ebf92af3be917cd2e0e17fea2965716d958/src/Analyzer/QueryTreePassManager.cpp#L249) 查看所有遍历,让我们在实践中看看我们之前的查询: +分析器是查询执行的重要步骤。它接收 AST 并将其转换为查询树。与 AST 相比,查询树的主要好处在于许多组件将被解析,例如存储实例。我们还知道从哪个表读取,别名也被解析,树知道所使用的不同数据类型。拥有所有这些好处后,分析器可以应用优化。这些优化的工作方式是通过“传递”。每个传递将寻找不同的优化。你可以[在这里](https://github.com/ClickHouse/ClickHouse/blob/76578ebf92af3be917cd2e0e17fea2965716d958/src/Analyzer/QueryTreePassManager.cpp#L249)看到所有的传递,让我们用之前的查询看看实际效果: ```sql EXPLAIN QUERY TREE passes=0 SELECT min(timestamp) AS minimum_date, max(timestamp) AS maximum_date FROM session_events SETTINGS allow_experimental_analyzer=1; @@ -125,11 +126,11 @@ EXPLAIN QUERY TREE passes=20 SELECT min(timestamp) AS minimum_date, max(timestam └───────────────────────────────────────────────────────────────────────────────────────────┘ ``` -在两次执行之间,您可以看到别名和投影的解析。 +在两次执行之间,你可以看到别名和投影的解析。 -## 规划器 {#planner} +## 计划器 {#planner} -规划器接受查询树并从中构建查询计划。查询树告诉我们希望对特定查询做什么,而查询计划则告诉我们将如何做。这将作为查询计划的一部分进行额外优化。您可以使用 `EXPLAIN PLAN` 或 `EXPLAIN` 查看查询计划(`EXPLAIN` 将执行 `EXPLAIN PLAN`)。 +计划器从查询树构建查询计划。查询树告诉我们针对特定查询要做什么,而查询计划告诉我们将如何做到这一点。计划过程还将进行额外的优化。你可以使用 `EXPLAIN PLAN` 或 `EXPLAIN` 查看查询计划(`EXPLAIN` 将执行 `EXPLAIN PLAN`)。 ```sql EXPLAIN PLAN WITH @@ -147,7 +148,7 @@ SELECT type, min(timestamp) AS minimum_date, max(timestamp) AS maximum_date, cou └──────────────────────────────────────────────────┘ ``` -尽管这给我们提供了一些信息,但我们仍然可以获得更多。例如,也许我们想知道需要进行投影的列的名称。您可以向查询添加头信息: +虽然这给我们提供了一些信息,但我们可以获得更多信息。例如,也许我们想知道我们需要创建的投影的列名。你可以在查询中添加头部: ```SQL EXPLAIN header = 1 @@ -183,7 +184,7 @@ GROUP BY type └──────────────────────────────────────────────────┘ ``` -所以现在您知道需要为最后一个投影创建的列名(`minimum_date`、`maximum_date` 和 `percentage`),但您可能还想了解所有需要执行的操作的详细信息。您可以通过设置 `actions=1` 来做到这一点。 +现在你知道需要为最后的投影创建的列名(`minimum_date`、`maximum_date` 和 `percentage`),但你可能也想知道所有需要执行操作的详细信息。你可以通过设置 `actions=1` 来做到这一点。 ```sql EXPLAIN actions = 1 @@ -199,7 +200,6 @@ SELECT FROM session_events GROUP BY type - ┌─explain────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │ Expression ((Projection + Before ORDER BY)) │ │ Actions: INPUT :: 0 -> type String : 0 │ @@ -238,11 +238,11 @@ GROUP BY type └────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ ``` -现在您可以看到所有使用的输入、函数、别名和数据类型。您可以在 [这里](https://github.com/ClickHouse/ClickHouse/blob/master/src/Processors/QueryPlan/Optimizations/Optimizations.h) 查看规划器将应用的一些优化。 +你现在可以看到所有使用的输入、函数、别名和数据类型。你可以在[这里](https://github.com/ClickHouse/ClickHouse/blob/master/src/Processors/QueryPlan/Optimizations/Optimizations.h)看到规划者将应用的一些优化。 ## 查询管道 {#query-pipeline} -查询管道是从查询计划生成的。查询管道与查询计划非常相似,区别在于它不是一棵树而是一个图。它突出了 ClickHouse 将如何执行查询以及将使用哪些资源。分析查询管道非常有用,可以查看输入/输出方面的瓶颈。让我们拿前面的查询来查看查询管道的执行: +查询管道是从查询计划生成的。查询管道与查询计划非常相似,不同之处在于它不是树而是图。它突出了 ClickHouse 将如何执行查询以及将使用哪些资源。分析查询管道对于查看输入/输出方面的瓶颈非常有用。让我们用之前的查询看一下查询管道执行: ```sql EXPLAIN PIPELINE @@ -271,7 +271,7 @@ GROUP BY type; └────────────────────────────────────────────────────────────────────────────┘ ``` -括号内是查询计划步骤,旁边是处理器。这是很好的信息,但因为这是一个图,如果能以图的形式可视化会更好。我们有一个设置 `graph` 可以设置为 1,并指定输出格式为 TSV: +括号内是查询计划步骤,旁边是处理器。这是非常好的信息,但由于这是一个图,最好将其可视化。我们有一个设置 `graph` 可以设置为 1,并指定输出格式为 TSV: ```sql EXPLAIN PIPELINE graph=1 WITH @@ -332,11 +332,11 @@ digraph } ``` -然后您可以复制该输出并粘贴到 [这里](https://dreampuf.github.io/GraphvizOnline),将生成以下图: +然后你可以复制这个输出并粘贴到[这里](https://dreampuf.github.io/GraphvizOnline),这将生成以下图: -白色矩形对应于管道节点,灰色矩形对应于查询计划步骤,`x` 后跟一个数字对应于正在使用的输入/输出数量。如果您不想以紧凑的形式看到它们,您始终可以添加 `compact=0`: +一个白色矩形对应于一个管道节点,灰色矩形对应于查询计划步骤,后面跟着数字的 `x` 对应于正在使用的输入/输出数量。如果你不想以紧凑形式查看它们,你可以始终添加 `compact=0`: ```sql EXPLAIN PIPELINE graph = 1, compact = 0 @@ -376,7 +376,7 @@ digraph -为什么 ClickHouse 不使用多个线程读取表?让我们尝试向表中添加更多数据: +为什么 ClickHouse 不使用多线程从表中读取数据?让我们尝试在我们的表中添加更多数据: ```sql INSERT INTO session_events SELECT * FROM generateRandom('clientId UUID, @@ -386,7 +386,7 @@ INSERT INTO session_events SELECT * FROM generateRandom('clientId UUID, type Enum(\'type1\', \'type2\')', 1, 10, 2) LIMIT 1000000; ``` -现在让我们再次运行我们的 `EXPLAIN` 查询: +现在让我们再次运行 `EXPLAIN` 查询: ```sql EXPLAIN PIPELINE graph = 1, compact = 0 @@ -435,8 +435,8 @@ digraph -所以执行器决定不对操作进行并行化,因为数据量不够大。通过添加更多行,执行器随后决定如图所示使用多个线程。 +因此,执行器决定不并行化操作,因为数据量不足。通过添加更多行,执行器随后决定使用多线程,如图所示。 ## 执行器 {#executor} -最后,查询执行的最后一步由执行器完成。它将接受查询管道并执行它。根据您是进行 `SELECT`、`INSERT` 还是 `INSERT SELECT`,有不同类型的执行器。 +最后,查询执行的最后一步由执行器完成。它将接收查询管道并执行它。根据你在执行 `SELECT`、`INSERT` 或 `INSERT SELECT` 时的不同,执行器有不同的类型。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/understanding-query-execution-with-the-analyzer.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/understanding-query-execution-with-the-analyzer.md.hash index 31e3efec9a8..edabd6125a4 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/understanding-query-execution-with-the-analyzer.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/developer/understanding-query-execution-with-the-analyzer.md.hash @@ -1 +1 @@ -e50dc2662ccd0d35 +2b0de755afc8de64 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/anyIf.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/anyIf.md index 8fe83f0277a..78d2840f866 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/anyIf.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/anyIf.md @@ -9,6 +9,7 @@ - 'examples' - 'anyIf' 'sidebar_label': 'anyIf' +'doc_type': 'reference' --- @@ -16,13 +17,13 @@ ## 描述 {#description} -[`If`](/sql-reference/aggregate-functions/combinators#-if) 组合器可以应用于 [`any`](/sql-reference/aggregate-functions/reference/any) 聚合函数,以选择匹配给定条件的某个列中首次遇到的元素。 +[`If`](/sql-reference/aggregate-functions/combinators#-if) 组合子可以应用于 [`any`](/sql-reference/aggregate-functions/reference/any) 聚合函数,以选择给定列中第一个遇到的符合给定条件的元素。 ## 示例用法 {#example-usage} -在这个示例中,我们将创建一个存储销售数据及成功标志的表,并使用 `anyIf` 选取大于和小于 200 的 `transaction_id`。 +在这个例子中,我们将创建一个存储销售数据的表,其中包含成功标志,并且我们将使用 `anyIf` 选择交易金额超过和低于 200 的第一个 `transaction_id`。 -我们首先创建一个表并向其中插入数据: +我们首先创建一个表并插入数据: ```sql title="Query" CREATE TABLE sales( @@ -44,8 +45,8 @@ INSERT INTO sales VALUES ```sql SELECT - anyIf(transaction_id, amount < 200) as tid_lt_200, - anyIf(transaction_id, amount > 200) as tid_gt_200 + anyIf(transaction_id, amount < 200) AS tid_lt_200, + anyIf(transaction_id, amount > 200) AS tid_gt_200 FROM sales; ``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/anyIf.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/anyIf.md.hash index d42da56fb3a..0afb21a2599 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/anyIf.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/anyIf.md.hash @@ -1 +1 @@ -eb027895ea1eec31 +e96cfd05e000be92 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/argMaxIf.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/argMaxIf.md index dcad1a5294e..c87d0e70bec 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/argMaxIf.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/argMaxIf.md @@ -9,6 +9,7 @@ - 'examples' - 'argMaxIf' 'sidebar_label': 'argMaxIf' +'doc_type': 'reference' --- @@ -16,13 +17,13 @@ ## 描述 {#description} -[`If`](/sql-reference/aggregate-functions/combinators#-if) 组合器可以应用于 [`argMax`](/sql-reference/aggregate-functions/reference/argmax) 函数,以查找与 `val` 的最大值对应的 `arg` 值,仅针对满足条件的行,使用 `argMaxIf` 聚合组合器函数。 +[`If`](/sql-reference/aggregate-functions/combinators#-if) 组合器可以应用于 [`argMax`](/sql-reference/aggregate-functions/reference/argmax) 函数,以查找满足条件为真的行中,与 `val` 的最大值对应的 `arg` 值,使用 `argMaxIf` 聚合组合函数。 -当您需要找到数据集中与最大值关联的值时,`argMaxIf` 函数非常有用,但仅适用于满足特定条件的行。 +当需要查找与数据集中最大值相关的值,但仅限于满足特定条件的行时,`argMaxIf` 函数非常有用。 ## 示例用法 {#example-usage} -在这个示例中,我们将使用产品销售的示例数据集来演示 `argMaxIf` 的工作原理。我们将找到价格最高的产品名称,但仅针对售出至少 10 次的产品。 +在此示例中,我们将使用一个产品销售的示例数据集来演示 `argMaxIf` 的工作原理。我们将找到价格最高的产品名称,但仅限于销售次数至少为 10 次的产品。 ```sql title="Query" CREATE TABLE product_sales @@ -36,14 +37,14 @@ INSERT INTO product_sales VALUES ('Laptop', 999.99, 10), ('Phone', 499.99, 15), ('Tablet', 299.99, 0), - ('Watch', 199.99, 5), + ('Watch', 1199.99, 5), ('Headphones', 79.99, 20); -SELECT argMaxIf(product_name, price, sales_count >= 10) as most_expensive_popular_product +SELECT argMaxIf(product_name, price, sales_count >= 10) AS most_expensive_popular_product FROM product_sales; ``` -`argMaxIf` 函数将返回所有售出至少 10 次的产品中价格最高的产品名称 (sales_count >= 10)。在这种情况下,它将返回 'Laptop',因为它在热门产品中具有最高价格 (999.99)。 +`argMaxIf` 函数将返回销售次数至少为 10 次的所有产品中价格最高的产品名称(sales_count >= 10)。在这种情况下,它将返回 'Laptop',因为在热门产品中它的价格最高(999.99)。 ```response title="Response" ┌─most_expensi⋯lar_product─┐ @@ -51,7 +52,7 @@ FROM product_sales; └──────────────────────────┘ ``` -## 另请参阅 {#see-also} +## 另请参见 {#see-also} - [`argMax`](/sql-reference/aggregate-functions/reference/argmax) - [`argMin`](/sql-reference/aggregate-functions/reference/argmin) - [`argMinIf`](/examples/aggregate-function-combinators/argMinIf) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/argMaxIf.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/argMaxIf.md.hash index f0db3303370..c9cd6e7c76e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/argMaxIf.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/argMaxIf.md.hash @@ -1 +1 @@ -0fe6adcc7b594d77 +d227869e635b7c1e diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/argMinIf.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/argMinIf.md index 35f27c88a55..853e2447e06 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/argMinIf.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/argMinIf.md @@ -9,6 +9,7 @@ - 'examples' - 'argMinIf' 'sidebar_label': 'argMinIf' +'doc_type': 'reference' --- @@ -16,13 +17,13 @@ ## 描述 {#description} -[`If`](/sql-reference/aggregate-functions/combinators#-if) 组合器可以应用于 [`argMin`](/sql-reference/aggregate-functions/reference/argmin) 函数,以查找与 `val` 最小值相对应的 `arg` 值,适用于条件为真的行,使用 `argMinIf` 聚合组合器函数。 +[`If`](/sql-reference/aggregate-functions/combinators#-if) 组合器可以应用于 [`argMin`](/sql-reference/aggregate-functions/reference/argmin) 函数,以查找在条件为真的行中 `val` 的最小值对应的 `arg` 的值,使用 `argMinIf` 聚合组合器函数。 -当您需要在数据集中查找与最小值关联的值,但仅针对满足特定条件的行时,`argMinIf` 函数非常有用。 +当您需要查找与数据集中最小值相关联的值,但仅针对满足特定条件的行时,`argMinIf` 函数非常有用。 ## 示例用法 {#example-usage} -在此示例中,我们将创建一个存储产品价格及其时间戳的表,并使用 `argMinIf` 找出每个产品在有库存时的最低价格。 +在这个示例中,我们将创建一个存储产品价格及其时间戳的表,并使用 `argMinIf` 查找每个产品的最低价格,当它有库存时。 ```sql title="Query" CREATE TABLE product_prices( @@ -42,12 +43,12 @@ INSERT INTO product_prices VALUES SELECT product_id, - argMinIf(price, timestamp, in_stock = 1) as lowest_price_when_in_stock + argMinIf(price, timestamp, in_stock = 1) AS lowest_price_when_in_stock FROM product_prices GROUP BY product_id; ``` -`argMinIf` 函数将找到每个产品对应的最早时间戳的价格,但仅考虑 `in_stock = 1` 的行。例如: +`argMinIf` 函数将查找对应于每个产品最早时间戳的价格,但仅考虑 `in_stock = 1` 的行。例如: - 产品 1:在有库存的行中,10.99 的时间戳最早(10:00:00) - 产品 2:在有库存的行中,20.99 的时间戳最早(11:00:00) @@ -58,7 +59,7 @@ GROUP BY product_id; └────────────┴────────────────────────────┘ ``` -## 另见 {#see-also} +## 另请参见 {#see-also} - [`argMin`](/sql-reference/aggregate-functions/reference/argmin) - [`argMax`](/sql-reference/aggregate-functions/reference/argmax) - [`argMaxIf`](/examples/aggregate-function-combinators/argMaxIf) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/argMinIf.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/argMinIf.md.hash index 99e23a9ab91..30d373b2d17 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/argMinIf.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/argMinIf.md.hash @@ -1 +1 @@ -a6036cce7aa32370 +8ab7e6b88cbbd41a diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/avgIf.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/avgIf.md index aa1a00291d6..99c9fa9b456 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/avgIf.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/avgIf.md @@ -9,6 +9,7 @@ - 'examples' - 'avgIf' 'sidebar_label': 'avgIf' +'doc_type': 'reference' --- @@ -16,11 +17,11 @@ ## 描述 {#description} -[`If`](/sql-reference/aggregate-functions/combinators#-if) 组合器可以应用于 [`avg`](/sql-reference/aggregate-functions/reference/avg) 函数,以计算条件为真的行的值的算术平均数,使用 `avgIf` 聚合组合器函数。 +[`If`](/sql-reference/aggregate-functions/combinators#-if) 组合器可以应用于 [`avg`](/sql-reference/aggregate-functions/reference/avg) 函数,以计算条件为真时的行值的算术平均值,使用 `avgIf` 聚合组合器函数。 ## 示例用法 {#example-usage} -在这个示例中,我们将创建一个存储销售数据及其成功标志的表,并将使用 `avgIf` 来计算成功交易的平均销售金额。 +在此示例中,我们将创建一个存储销售数据及成功标志的表,并使用 `avgIf` 计算成功交易的平均销售金额。 ```sql title="Query" CREATE TABLE sales( @@ -38,11 +39,11 @@ INSERT INTO sales VALUES (6, 175.25, 1); SELECT - avgIf(amount, is_successful = 1) as avg_successful_sale + avgIf(amount, is_successful = 1) AS avg_successful_sale FROM sales; ``` -`avgIf` 函数仅会计算 `is_successful = 1` 的行的平均金额。在这种情况下,它将对金额 100.50、200.75、300.00 和 175.25 进行平均。 +`avgIf` 函数将仅对 `is_successful = 1` 的行计算平均金额。在这种情况下,它将平均金额:100.50、200.75、300.00 和 175.25。 ```response title="Response" ┌─avg_successful_sale─┐ @@ -50,6 +51,6 @@ FROM sales; └─────────────────────┘ ``` -## 另请参见 {#see-also} +## 参见 {#see-also} - [`avg`](/sql-reference/aggregate-functions/reference/avg) - [`If combinator`](/sql-reference/aggregate-functions/combinators#-if) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/avgIf.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/avgIf.md.hash index 241c041a592..9b9caff81f1 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/avgIf.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/avgIf.md.hash @@ -1 +1 @@ -2c9f8d6a17142d4c +56c39646c8eeee10 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/avgMap.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/avgMap.md index 301d0849d1b..a1973399622 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/avgMap.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/avgMap.md @@ -9,6 +9,7 @@ - 'examples' - 'avgMap' 'sidebar_label': 'avgMap' +'doc_type': 'reference' --- @@ -20,7 +21,7 @@ ## 示例用法 {#example-usage} -在这个示例中,我们将创建一个表,用于存储不同时间段的状态码及其计数,每行包含一个状态码及其对应计数的 Map。我们将使用 `avgMap` 来计算每个状态码在每个时间段内的平均计数。 +在这个例子中,我们将创建一个表,该表存储不同时间段的状态代码及其计数,其中每行包含一个状态代码到其对应计数的 Map。我们将使用 `avgMap` 计算每个时间段内每个状态代码的平均计数。 ```sql title="Query" CREATE TABLE metrics( @@ -42,14 +43,14 @@ FROM metrics GROUP BY timeslot; ``` -`avgMap` 函数将计算每个状态码在每个时间段内的平均计数。例如: -- 在时间段 '2000-01-01 00:00:00': +`avgMap` 函数将计算每个时间段内每个状态代码的平均计数。例如: +- 在时间段 '2000-01-01 00:00:00': - 状态 'a': 15 - 状态 'b': 25 - 状态 'c': (35 + 45) / 2 = 40 - 状态 'd': 55 - 状态 'e': 65 -- 在时间段 '2000-01-01 00:01:00': +- 在时间段 '2000-01-01 00:01:00': - 状态 'd': 75 - 状态 'e': 85 - 状态 'f': (95 + 105) / 2 = 100 @@ -62,6 +63,6 @@ GROUP BY timeslot; └─────────────────────┴──────────────────────────────────────┘ ``` -## 另请参见 {#see-also} +## 另请参阅 {#see-also} - [`avg`](/sql-reference/aggregate-functions/reference/avg) - [`Map 组合器`](/sql-reference/aggregate-functions/combinators#-map) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/avgMap.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/avgMap.md.hash index b50d0de6a2d..9a3544735e1 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/avgMap.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/avgMap.md.hash @@ -1 +1 @@ -f2d5c7a0e9eb6cdd +524a3dbea39a916f diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/avgMerge.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/avgMerge.md index 04bce333a49..51511c20744 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/avgMerge.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/avgMerge.md @@ -9,20 +9,21 @@ - 'examples' - 'avgMerge' 'sidebar_label': 'avgMerge' +'doc_type': 'reference' --- # avgMerge {#avgMerge} -## Description {#description} +## 描述 {#description} -[`Merge`](/sql-reference/aggregate-functions/combinators#-state) 合成器可以应用于 [`avg`](/sql-reference/aggregate-functions/reference/avg) 函数,通过组合部分聚合状态来产生最终结果。 +[`Merge`](/sql-reference/aggregate-functions/combinators#-state) 组合器可以应用于 [`avg`](/sql-reference/aggregate-functions/reference/avg) 函数,通过组合部分聚合状态来生成最终结果。 -## Example Usage {#example-usage} +## 示例用法 {#example-usage} -`Merge` 合成器与 `State` 合成器密切相关。请参阅 ["avgState example usage"](/examples/aggregate-function-combinators/avgState/#example-usage) 以获取 `avgMerge` 和 `avgState` 的示例。 +`Merge` 组合器与 `State` 组合器密切相关。有关 `avgMerge` 和 `avgState` 的示例,请参阅 ["avgState 示例用法"](/examples/aggregate-function-combinators/avgState/#example-usage)。 -## See also {#see-also} +## 另请参阅 {#see-also} - [`avg`](/sql-reference/aggregate-functions/reference/avg) - [`Merge`](/sql-reference/aggregate-functions/combinators#-merge) - [`MergeState`](/sql-reference/aggregate-functions/combinators#-mergestate) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/avgMerge.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/avgMerge.md.hash index 219e190d654..e5050fd8d5f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/avgMerge.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/avgMerge.md.hash @@ -1 +1 @@ -07597e74cdade01e +142a061f19774150 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/avgMergeState.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/avgMergeState.md index f086c41b521..068fb6364fe 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/avgMergeState.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/avgMergeState.md @@ -9,6 +9,7 @@ - 'examples' - 'avgMergeState' 'sidebar_label': 'avgMergeState' +'doc_type': 'reference' --- import Tabs from '@theme/Tabs'; @@ -19,17 +20,11 @@ import TabItem from '@theme/TabItem'; ## 描述 {#description} -[`MergeState`](/sql-reference/aggregate-functions/combinators#-state) 组合器 -可以应用于[`avg`](/sql-reference/aggregate-functions/reference/avg) -函数,以合并类型为 `AverageFunction(avg, T)` 的部分聚合状态并 -返回一个新的中间聚合状态。 +[`MergeState`](/sql-reference/aggregate-functions/combinators#-state) 组合器可以应用于 [`avg`](/sql-reference/aggregate-functions/reference/avg) 函数,以合并类型为 `AverageFunction(avg, T)` 的部分聚合状态,并返回一个新的中间聚合状态。 ## 示例用法 {#example-usage} -`MergeState` 组合器对于多层聚合场景尤其有用,在这些场景中,您想要 -结合预聚合的状态并将其保持为状态(而不是最终确定它们)以进行后续处理。 -为了说明这一点,我们将查看一个示例,其中我们将个别服务器性能指标 -转换为跨多个级别的分层聚合:服务器级别 → 区域级别 → 数据中心级别。 +`MergeState` 组合器在多层级聚合场景中特别有用,在这些场景中,您希望组合预聚合状态并将其维护为状态(而不是最终状态)以进行进一步处理。为了说明这一点,我们将看一个示例,其中将单个服务器性能指标转换为跨多个级别的层次聚合:服务器级别 → 区域级别 → 数据中心级别。 首先,我们创建一个表来存储原始数据: @@ -46,8 +41,7 @@ ENGINE = MergeTree() ORDER BY (region, server_id, timestamp); ``` -我们将创建一个服务器级别的聚合目标表,并定义一个增量 -物化视图作为插入触发器: +我们将创建一个服务器级别的聚合目标表,并定义一个增量物化视图作为其插入触发器: ```sql CREATE TABLE server_performance @@ -71,7 +65,7 @@ FROM raw_server_metrics GROUP BY server_id, region, datacenter; ``` -我们将在区域和数据中心级别做同样的事情: +我们将在区域和数据中心级别执行相同的操作: ```sql CREATE TABLE region_performance @@ -92,7 +86,7 @@ AS SELECT FROM server_performance GROUP BY region, datacenter; --- datacenter level table and Materialized View +-- datacenter level table and materialized view CREATE TABLE datacenter_performance ( @@ -111,7 +105,7 @@ FROM region_performance GROUP BY datacenter; ``` -然后,我们将向源表插入示例原始数据: +然后我们将向源表插入示例原始数据: ```sql INSERT INTO raw_server_metrics (timestamp, server_id, region, datacenter, response_time_ms) VALUES @@ -193,8 +187,7 @@ INSERT INTO raw_server_metrics (timestamp, server_id, region, datacenter, respon (now(), 301, 'eu-central', 'dc2', 135); ``` -让我们再次检查数据中心级别的性能。请注意整个 -聚合链是如何自动更新的: +让我们再次检查数据中心级别的性能。注意整个聚合链是如何自动更新的: ```sql SELECT @@ -212,7 +205,7 @@ ORDER BY datacenter; └────────────┴────────────────────┘ ``` -## 另请参见 {#see-also} +## 另见 {#see-also} - [`avg`](/sql-reference/aggregate-functions/reference/avg) - [`AggregateFunction`](/sql-reference/data-types/aggregatefunction) - [`Merge`](/sql-reference/aggregate-functions/combinators#-merge) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/avgMergeState.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/avgMergeState.md.hash index 572b03035d9..f2d3371c2a0 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/avgMergeState.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/avgMergeState.md.hash @@ -1 +1 @@ -d96bc65bf75836e1 +fce255f510165731 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/avgResample.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/avgResample.md index 6080677cc56..1b43c5ff2d9 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/avgResample.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/avgResample.md @@ -1,7 +1,7 @@ --- 'slug': '/examples/aggregate-function-combinators/avgResample' 'title': 'avgResample' -'description': '使用 avg 的 Resample 组合器示例' +'description': '使用 avg 的 Resample 组合器的示例' 'keywords': - 'avg' - 'Resample' @@ -9,23 +9,24 @@ - 'examples' - 'avgResample' 'sidebar_label': 'avgResample' +'doc_type': 'reference' --- # countResample {#countResample} -## 描述 {#description} +## Description {#description} [`Resample`](/sql-reference/aggregate-functions/combinators#-resample) 组合器可以应用于[`count`](/sql-reference/aggregate-functions/reference/count) -聚合函数,以计算指定键列在固定数量的区间(`N`)中的值。 +聚合函数,以在固定数量的时间间隔(`N`)中计数指定键列的值。 -## 示例用法 {#example-usage} +## Example usage {#example-usage} -### 基本示例 {#basic-example} +### Basic example {#basic-example} -我们来看一个示例。我们将创建一个表,该表包含员工的`name`、`age` 和 -`wage`,并插入一些数据: +让我们来看一个例子。我们将创建一个包含员工的 `name`、`age` 和 +`wage` 的表,并插入一些数据: ```sql CREATE TABLE employee_data @@ -46,10 +47,10 @@ INSERT INTO employee_data (name, age, wage) VALUES ('Brian', 60, 16.0); ``` -让我们获取年龄在区间 `[30,60)` -和 `[60,75)`(`[` 是排他性的,`)` 是包含性的)中的人的平均工资。由于我们使用整数 -表示年龄,我们得到年龄在区间 `[30, 59]` 和 `[60,74]`。 -为此,我们将`Resample` 组合器应用于 `avg` 聚合函数。 +让我们获取年龄在 `[30,60)` +和 `[60,75)` 区间内的人的平均工资(`[` 是排除的,`)` 是包含的)。由于我们对年龄使用整数 +表示,因此获得的年龄在 `[30, 59]` 和 `[60,74]` 区间内。 +为此,我们将 `Resample` 组合器应用于 `avg` 聚合函数。 ```sql WITH avg_wage AS @@ -68,6 +69,6 @@ FROM avg_wage; └──────────────────┘ ``` -## 另请参阅 {#see-also} +## See also {#see-also} - [`count`](/sql-reference/aggregate-functions/reference/count) - [`Resample combinator`](/sql-reference/aggregate-functions/combinators#-resample) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/avgResample.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/avgResample.md.hash index b7598d110ef..db708bd7610 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/avgResample.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/avgResample.md.hash @@ -1 +1 @@ -fe12c7978ae18ae8 +7647bac8c59344b9 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/avgState.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/avgState.md index e745849f458..ae7e4f2edd0 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/avgState.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/avgState.md @@ -9,6 +9,7 @@ - 'examples' - 'avgState' 'sidebar_label': 'avgState' +'doc_type': 'reference' --- @@ -16,11 +17,11 @@ ## 描述 {#description} -[`State`](/sql-reference/aggregate-functions/combinators#-state) 组合器可以应用于 [`avg`](/sql-reference/aggregate-functions/reference/avg) 函数,以生成 `AggregateFunction(avg, T)` 类型的中间状态,其中 `T` 是用于计算平均值的指定类型。 +[`State`](/sql-reference/aggregate-functions/combinators#-state) 组合器可以应用于 [`avg`](/sql-reference/aggregate-functions/reference/avg) 函数,以产生 `AggregateFunction(avg, T)` 类型的中间状态,其中 `T` 是指定的平均值类型。 ## 示例用法 {#example-usage} -在这个例子中,我们将看看如何使用 `AggregateFunction` 类型,以及 `avgState` 函数来聚合网站流量数据。 +在这个示例中,我们将看看如何使用 `AggregateFunction` 类型,与 `avgState` 函数一起聚合网站流量数据。 首先创建网站流量数据的源表: @@ -36,7 +37,7 @@ ENGINE = MergeTree() ORDER BY (page_id, viewed_at); ``` -创建一个聚合表来存储平均响应时间。请注意,`avg` 不能使用 `SimpleAggregateFunction` 类型,因为它需要一个复杂的状态(一个总和和一个计数)。因此,我们使用 `AggregateFunction` 类型: +创建将存储平均响应时间的聚合表。请注意 `avg` 不能使用 `SimpleAggregateFunction` 类型,因为它需要复杂的状态(和一个计数)。因此,我们使用 `AggregateFunction` 类型: ```sql CREATE TABLE page_performance @@ -49,7 +50,7 @@ ENGINE = AggregatingMergeTree() ORDER BY page_id; ``` -创建一个增量物化视图,它将作为新数据的插入触发器,并将中间状态数据存储在上述定义的目标表中: +创建一个增量物化视图,该视图将作为新数据的插入触发器,并在上述定义的目标表中存储中间状态数据: ```sql CREATE MATERIALIZED VIEW page_performance_mv @@ -62,7 +63,7 @@ FROM raw_page_views GROUP BY page_id, page_name; ``` -向源表插入一些初始数据,在磁盘上创建一个分区片段: +将一些初始数据插入源表,创建磁盘上的一个部分: ```sql INSERT INTO raw_page_views (page_id, page_name, response_time_ms) VALUES @@ -74,7 +75,7 @@ INSERT INTO raw_page_views (page_id, page_name, response_time_ms) VALUES (3, 'About', 90); ``` -插入更多数据以在磁盘上创建第二个分区片段: +插入更多数据以在磁盘上创建第二个部分: ```sql INSERT INTO raw_page_views (page_id, page_name, response_time_ms) VALUES @@ -108,9 +109,9 @@ FROM page_performance └─────────┴───────────┴───────────────────┴────────────────────────────────┘ ``` -请注意,`avg_response_time` 列的类型为 `AggregateFunction(avg, UInt32)`,并存储中间状态信息。同样要注意,`avg_response_time` 的行数据对我们没有用处,我们看到一些奇怪的文本字符,比如 `�, n, F, }`。这是终端尝试将二进制数据显示为文本的结果。原因在于 `AggregateFunction` 类型以一种为高效存储和计算而优化的二进制格式存储其状态,而不是为了人类的可读性。这个二进制状态包含计算平均值所需的所有信息。 +注意,`avg_response_time` 列的类型是 `AggregateFunction(avg, UInt32)` 并存储中间状态信息。还注意到 `avg_response_time` 的行数据对我们没有用处,并且我们看到奇怪的文本字符,如 `�, n, F, }`。这是终端尝试将二进制数据作为文本显示的结果。其原因是 `AggregateFunction` 类型以为高效存储和计算而优化的二进制格式存储其状态,而不是为了人类可读性。此二进制状态包含计算平均值所需的所有信息。 -为了使用它,可以使用 `Merge` 组合器: +要利用它,可以使用 `Merge` 组合器: ```sql SELECT @@ -133,6 +134,6 @@ ORDER BY page_id; └─────────┴───────────┴──────────────────────────┘ ``` -## 另见 {#see-also} +## 另请参阅 {#see-also} - [`avg`](/sql-reference/aggregate-functions/reference/avg) - [`State`](/sql-reference/aggregate-functions/combinators#-state) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/avgState.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/avgState.md.hash index f0f8a59ca3b..6778648e2a3 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/avgState.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/avgState.md.hash @@ -1 +1 @@ -a2baf220b555befe +cd8e7636a426bce2 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/countIf.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/countIf.md index 0c0db6e5a76..421ceab92f8 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/countIf.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/countIf.md @@ -9,18 +9,19 @@ - 'examples' - 'countIf' 'sidebar_label': 'countIf' +'doc_type': 'reference' --- # countIf {#countif} -## Description {#description} +## 描述 {#description} -[`If`](/sql-reference/aggregate-functions/combinators#-if) 组合器可以应用于 [`count`](/sql-reference/aggregate-functions/reference/count) 函数,以计算条件为真的行数,使用 `countIf` 聚合组合函数。 +[`If`](/sql-reference/aggregate-functions/combinators#-if) 组合器可以应用于 [`count`](/sql-reference/aggregate-functions/reference/count) 函数,以计算条件为真的行数,使用 `countIf` 聚合组合器函数。 -## Example Usage {#example-usage} +## 示例用法 {#example-usage} -在这个例子中,我们将创建一个用于存储用户登录尝试的表,并使用 `countIf` 来计算成功登录的数量。 +在这个示例中,我们将创建一个表,用于存储用户登录尝试,并将使用 `countIf` 来计算成功登录的次数。 ```sql title="Query" CREATE TABLE login_attempts( @@ -39,12 +40,12 @@ INSERT INTO login_attempts VALUES SELECT user_id, - countIf(is_successful = 1) as successful_logins + countIf(is_successful = 1) AS successful_logins FROM login_attempts GROUP BY user_id; ``` -`countIf` 函数将仅计算 `is_successful = 1` 的行数,对于每个用户。 +`countIf` 函数将仅计算 `is_successful = 1` 的行数,针对每个用户。 ```response title="Response" ┌─user_id─┬─successful_logins─┐ @@ -53,6 +54,6 @@ GROUP BY user_id; └─────────┴───────────────────┘ ``` -## See also {#see-also} +## 另见 {#see-also} - [`count`](/sql-reference/aggregate-functions/reference/count) - [`If combinator`](/sql-reference/aggregate-functions/combinators#-if) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/countIf.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/countIf.md.hash index a1a21b5a24e..a64eac73cb9 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/countIf.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/countIf.md.hash @@ -1 +1 @@ -784c701de731b506 +37303af207382689 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/countResample.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/countResample.md index 8a722e64b06..db5f07cfcde 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/countResample.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/countResample.md @@ -1,7 +1,7 @@ --- 'slug': '/examples/aggregate-function-combinators/countResample' 'title': 'countResample' -'description': '使用 count 的 Resample 组合器的示例' +'description': '使用 count 的 Resample 组合子的示例' 'keywords': - 'count' - 'Resample' @@ -9,6 +9,7 @@ - 'examples' - 'countResample' 'sidebar_label': 'countResample' +'doc_type': 'reference' --- @@ -16,11 +17,9 @@ ## Description {#description} -[`Resample`](/sql-reference/aggregate-functions/combinators#-resample) -组合器可以应用于[`count`](/sql-reference/aggregate-functions/reference/count) -聚合函数,以在固定数量的区间(`N`)中计算指定键列的值。 +[`Resample`](/sql-reference/aggregate-functions/combinators#-resample) 组合器可以应用于 [`count`](/sql-reference/aggregate-functions/reference/count) 聚合函数,以在固定数量的区间(`N`)中统计指定键列的值。 -## Example Usage {#example-usage} +## Example usage {#example-usage} ### Basic example {#basic-example} @@ -45,7 +44,7 @@ INSERT INTO employee_data (name, age, wage) VALUES ('Brian', 60, 16.0); ``` -让我们计算年龄在区间 `[30,60)` 和 `[60,75)` 的所有人。由于我们使用整数表示年龄,因此我们得到的年龄在 `[30, 59]` 和 `[60,74]` 区间。为此,我们将 `Resample` 组合器应用于 `count`。 +我们将统计年龄在区间 `[30,60)` 和 `[60,75)` 的所有人。由于我们使用整数表示年龄,因此我们得到的年龄在 `[30, 59]` 和 `[60,74]` 区间内。为此,我们将 `Resample` 组合器应用于 `count`。 ```sql SELECT countResample(30, 75, 30)(name, age) AS amount FROM employee_data diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/countResample.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/countResample.md.hash index 671e6b0b33c..edd0268fcb1 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/countResample.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/countResample.md.hash @@ -1 +1 @@ -e708c66cb0678e4d +ad793788a6745323 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/groupArrayDistinct.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/groupArrayDistinct.md index 7e89c8d3a60..13ff41256ed 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/groupArrayDistinct.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/groupArrayDistinct.md @@ -9,20 +9,21 @@ - 'examples' - 'groupArrayDistinct' 'sidebar_label': 'groupArrayDistinct' +'doc_type': 'reference' --- # groupArrayDistinct {#sumdistinct} -## 描述 {#description} +## Description {#description} [`groupArrayDistinct`](/sql-reference/aggregate-functions/combinators#-foreach) 组合器可以应用于 [`groupArray`](/sql-reference/aggregate-functions/reference/sum) 聚合函数,以创建一个包含不同参数值的数组。 -## 示例用法 {#example-usage} +## Example usage {#example-usage} -在这个例子中,我们将使用在我们的 [SQL playground](https://sql.clickhouse.com/) 中可用的 `hits` 数据集。 +在这个例子中,我们将利用我们 [SQL playground](https://sql.clickhouse.com/) 中可用的 `hits` 数据集。 -想象一下,你想要找出你的网站上每个独特的登录页面域名 (`URLDomain`) 对应的所有唯一的用户代理操作系统代码 (`OS`),这些记录是为了了解访问该域名的访客所使用的操作系统类型。这将帮助你理解与网站不同部分交互的操作系统的多样性。 +想象一下,你想要找出你的网站上每个不同的着陆页域名 (`URLDomain`),对于访问该域名的访客记录的所有独特用户代理操作系统代码 (`OS`)。这将帮助你理解与网站不同部分互动的操作系统的多样性。 ```sql runnable SELECT @@ -35,6 +36,6 @@ ORDER BY URLDomain ASC LIMIT 20; ``` -## 另请参见 {#see-also} +## See also {#see-also} - [`groupArray`](/sql-reference/aggregate-functions/reference/grouparray) - [`Distinct combinator`](/sql-reference/aggregate-functions/combinators#-distinct) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/groupArrayDistinct.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/groupArrayDistinct.md.hash index 7b0032309f0..9328b3670d3 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/groupArrayDistinct.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/groupArrayDistinct.md.hash @@ -1 +1 @@ -124812464974da51 +8aa71b79b897d45c diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/groupArrayResample.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/groupArrayResample.md index 03480dc2b42..92630626c34 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/groupArrayResample.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/groupArrayResample.md @@ -1,6 +1,6 @@ --- 'slug': '/examples/aggregate-function-combinators/groupArrayResample' -'title': 'groupArrayResample' +'title': 'groupArray重采样' 'description': '使用 Resample 组合器与 groupArray 的示例' 'keywords': - 'groupArray' @@ -9,6 +9,7 @@ - 'examples' - 'groupArrayResample' 'sidebar_label': 'groupArrayResample' +'doc_type': 'reference' --- @@ -17,15 +18,15 @@ ## 描述 {#description} [`Resample`](/sql-reference/aggregate-functions/combinators#-resample) -组合器可以应用于[`groupArray`](/sql-reference/aggregate-functions/reference/sum)聚合函数,以 +组合器可以应用于[`groupArray`](/sql-reference/aggregate-functions/reference/sum) 聚合函数,以 将指定键列的范围划分为固定数量的区间(`N`), -并通过从落入每个区间的数据点中选择一个代表值(对应于最小键)来构造结果数组。 -它创建一种下采样的数据视图,而不是收集所有值。 +并通过从每个区间内落入的数据点中选择一个代表值(对应于最小键)来构建结果数组。 +它创建一个下采样的数据视图,而不是收集所有值。 ## 示例用法 {#example-usage} -让我们看一个例子。我们将创建一个包含员工 `name`、`age` 和 -`wage` 的表,并插入一些数据: +让我们看一个例子。我们将创建一个包含员工的`name`、`age`和 +`wage`的表,并插入一些数据: ```sql CREATE TABLE employee_data @@ -45,14 +46,14 @@ INSERT INTO employee_data (name, age, wage) VALUES ('Brian', 60, 16.0); ``` -让我们获取年龄在区间 `[30,60)` -和 `[60,75)` 之间的人的名字。由于我们对年龄使用整数表示法,因此我们获得年龄在 -`[30, 59]` 和 `[60,74]` 区间。 +让我们获取年龄在区间`[30,60)` +和`[60,75)`内的人的名字。由于我们对年龄使用整数表示,因此我们得到的年龄区间为 +`[30, 59]`和`[60,74]`。 -为了将名字聚合到一个数组中,我们使用 `groupArray` 聚合函数。 -它接受一个参数。在我们的案例中,它是名字列。`groupArrayResample` -函数应使用年龄列按年龄聚合名字。为了定义 -所需的区间,我们将 `30`、`75` 和 `30` 作为参数传递给 `groupArrayResample` +为了将名字聚合到数组中,我们使用`groupArray`聚合函数。 +它接受一个参数。在我们的例子中,它是名字列。`groupArrayResample` +函数应该使用年龄列按照年龄聚合名字。为了定义 +所需的区间,我们将`30`、`75`、`30`作为参数传递给`groupArrayResample` 函数: ```sql diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/groupArrayResample.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/groupArrayResample.md.hash index e080a5b4199..bd757fe17d2 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/groupArrayResample.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/groupArrayResample.md.hash @@ -1 +1 @@ -be43f2c7f85bb84d +1f62eff31b4d7569 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/maxMap.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/maxMap.md index 5bf253940ad..fcddd10024e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/maxMap.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/maxMap.md @@ -9,6 +9,7 @@ - 'examples' - 'maxMap' 'sidebar_label': 'maxMap' +'doc_type': 'reference' --- @@ -16,11 +17,11 @@ ## 描述 {#description} -[`Map`](/sql-reference/aggregate-functions/combinators#-map) 组合器可以应用于 [`max`](/sql-reference/aggregate-functions/reference/max) 函数,以根据每个键来计算 Map 中的最大值,使用 `maxMap` 聚合组合器函数。 +[`Map`](/sql-reference/aggregate-functions/combinators#-map) 组合器可以应用于 [`max`](/sql-reference/aggregate-functions/reference/max) 函数,通过 `maxMap` 聚合组合器函数根据每个键计算 Map 中的最大值。 ## 示例用法 {#example-usage} -在这个例子中,我们将创建一个表,用于存储不同时间段的状态码及其计数,其中每一行包含一个状态码到其对应计数的 Map。我们将使用 `maxMap` 来找出每个时间段内每个状态码的最大计数。 +在这个示例中,我们将创建一个表,用于存储不同时间段的状态代码及其计数,其中每一行包含一个状态代码到其对应计数的 Map。我们将使用 `maxMap` 来查找每个时间段内每个状态代码的最大计数。 ```sql title="Query" CREATE TABLE metrics( @@ -42,14 +43,14 @@ FROM metrics GROUP BY timeslot; ``` -`maxMap` 函数将找到每个时间段内每个状态码的最大计数。例如: -- 在时间段 '2000-01-01 00:00:00': +`maxMap` 函数将找到每个时间段内每个状态代码的最大计数。例如: +- 在时间段 '2000-01-01 00:00:00': - 状态 'a': 15 - 状态 'b': 25 - 状态 'c': max(35, 45) = 45 - 状态 'd': 55 - 状态 'e': 65 -- 在时间段 '2000-01-01 00:01:00': +- 在时间段 '2000-01-01 00:01:00': - 状态 'd': 75 - 状态 'e': 85 - 状态 'f': max(95, 105) = 105 @@ -62,6 +63,6 @@ GROUP BY timeslot; └─────────────────────┴──────────────────────────────────────┘ ``` -## 另见 {#see-also} +## 另请参见 {#see-also} - [`max`](/sql-reference/aggregate-functions/reference/max) - [`Map 组合器`](/sql-reference/aggregate-functions/combinators#-map) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/maxMap.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/maxMap.md.hash index bc2e21ceafc..d9902bf96a1 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/maxMap.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/maxMap.md.hash @@ -1 +1 @@ -033162d8743415a1 +e4533ad85eee4845 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/maxSimpleState.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/maxSimpleState.md index ee1a65c352f..c5d8648735c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/maxSimpleState.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/maxSimpleState.md @@ -1,7 +1,7 @@ --- 'slug': '/examples/aggregate-function-combinators/maxSimpleState' 'title': 'maxSimpleState' -'description': '使用 minSimpleState 组合器的示例' +'description': '使用 minSimpleState 组合子的示例' 'keywords': - 'min' - 'state' @@ -10,20 +10,21 @@ - 'examples' - 'minSimpleState' 'sidebar_label': 'minSimpleState' +'doc_type': 'reference' --- # minSimpleState {#minsimplestate} -## Description {#description} +## 描述 {#description} [`SimpleState`](/sql-reference/aggregate-functions/combinators#-simplestate) 组合器可以应用于 [`max`](/sql-reference/aggregate-functions/reference/max) 函数,以返回所有输入值中的最大值。它返回的结果类型为 `SimpleAggregateState`。 -## Example Usage {#example-usage} +## 示例用法 {#example-usage} 在 [`minSimpleState`](/examples/aggregate-function-combinators/minSimpleState/#example-usage) 中给出的示例演示了 `maxSimpleState` 和 `minSimpleState` 的用法。 -## See also {#see-also} +## 另请参见 {#see-also} - [`max`](/sql-reference/aggregate-functions/reference/max) -- [`SimpleState combinator`](/sql-reference/aggregate-functions/combinators#-simplestate) -- [`SimpleAggregateFunction type`](/sql-reference/data-types/simpleaggregatefunction) +- [`SimpleState 组合器`](/sql-reference/aggregate-functions/combinators#-simplestate) +- [`SimpleAggregateFunction 类型`](/sql-reference/data-types/simpleaggregatefunction) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/maxSimpleState.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/maxSimpleState.md.hash index ce27a70a6e9..cb074d1840d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/maxSimpleState.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/maxSimpleState.md.hash @@ -1 +1 @@ -54578a0772b2d5bb +34ebf442b7a9bd13 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/minMap.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/minMap.md index 0659fa4b25f..31f6074cd5d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/minMap.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/minMap.md @@ -9,6 +9,7 @@ - 'examples' - 'minMap' 'sidebar_label': 'minMap' +'doc_type': 'reference' --- @@ -16,11 +17,11 @@ ## 描述 {#description} -[`Map`](/sql-reference/aggregate-functions/combinators#-map) 组合器可以应用于 [`min`](/sql-reference/aggregate-functions/reference/min) 函数,以计算每个键在 Map 中的最小值,使用 `minMap` 聚合组合器函数。 +[`Map`](/sql-reference/aggregate-functions/combinators#-map) 组合器可以应用于 [`min`](/sql-reference/aggregate-functions/reference/min) 函数,以根据每个键在 Map 中计算最小值,使用 `minMap` 聚合组合器函数。 ## 示例用法 {#example-usage} -在这个示例中,我们将创建一个存储状态码及其在不同时间段计数的表,每行包含一个状态码到其对应计数的 Map。我们将使用 `minMap` 在每个时间段内查找每个状态码的最小计数。 +在这个示例中,我们将创建一个表,该表存储不同时间段的状态代码及其计数,其中每一行包含一个状态代码到其相应计数的 Map。我们将使用 `minMap` 来查找每个时间段内每个状态代码的最小计数。 ```sql title="Query" CREATE TABLE metrics( @@ -42,7 +43,7 @@ FROM metrics GROUP BY timeslot; ``` -`minMap` 函数将在每个时间段内查找每个状态码的最小计数。例如: +`minMap` 函数将查找每个时间段内每个状态代码的最小计数。例如: - 在时间段 '2000-01-01 00:00:00': - 状态 'a': 15 - 状态 'b': 25 @@ -62,6 +63,6 @@ GROUP BY timeslot; └─────────────────────┴──────────────────────────────────────┘ ``` -## 另见 {#see-also} +## 另请参阅 {#see-also} - [`min`](/sql-reference/aggregate-functions/reference/min) - [`Map 组合器`](/sql-reference/aggregate-functions/combinators#-map) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/minMap.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/minMap.md.hash index 8cd713a4603..1fecddcd7d3 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/minMap.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/minMap.md.hash @@ -1 +1 @@ -0bb2296305f2b360 +66e4eb47ec9a097f diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/minSimpleState.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/minSimpleState.md index d0607cfd4b1..776bbaab45f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/minSimpleState.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/minSimpleState.md @@ -10,6 +10,7 @@ - 'examples' - 'minSimpleState' 'sidebar_label': 'minSimpleState' +'doc_type': 'reference' --- @@ -21,9 +22,9 @@ ## 示例用法 {#example-usage} -让我们看一个使用跟踪每日温度读数的表的实际例子。对于每个位置,我们希望保持记录的最低温度。使用 `SimpleAggregateFunction` 类型和 `min`,当遇到更低的温度时,存储的值会自动更新。 +让我们看一个实际的例子,使用一个跟踪每日温度读取的表格。对于每个地点,我们希望保持记录的最低温度。使用 `SimpleAggregateFunction` 类型与 `min` 时,当遇到较低的温度时,存储的值会自动更新。 -创建原始温度读数的源表: +创建原始温度读取的源表: ```sql CREATE TABLE raw_temperature_readings @@ -51,7 +52,7 @@ ENGINE = AggregatingMergeTree() ORDER BY location_id; ``` -创建一个增量物化视图,它将作为插入数据的触发器,并维护每个位置的最低和最高温度。 +创建一个增量物化视图,该视图将作为插入数据的触发器,并维护每个地点的最低和最高温度。 ```sql CREATE MATERIALIZED VIEW temperature_extremes_mv @@ -65,7 +66,7 @@ FROM raw_temperature_readings GROUP BY location_id, location_name; ``` -插入一些初始温度读数: +插入一些初始温度读取: ```sql INSERT INTO raw_temperature_readings (location_id, location_name, temperature) VALUES @@ -75,7 +76,7 @@ INSERT INTO raw_temperature_readings (location_id, location_name, temperature) V (4, 'East', 8); ``` -这些读数会被物化视图自动处理。让我们检查当前状态: +这些读取会被物化视图自动处理。让我们检查当前状态: ```sql SELECT @@ -96,7 +97,7 @@ ORDER BY location_id; └─────────────┴───────────────┴──────────┴──────────┘ ``` -插入一些更多的数据: +插入更多数据: ```sql INSERT INTO raw_temperature_readings (location_id, location_name, temperature) VALUES @@ -132,7 +133,7 @@ ORDER BY location_id; └─────────────┴───────────────┴──────────┴──────────┘ ``` -注意,上面我们为每个位置插入了两个值。这是因为分区片段尚未合并(并由 `AggregatingMergeTree` 聚合)。要从部分状态中获得最终结果,我们需要添加 `GROUP BY`: +请注意,上面每个位置都有两个插入值。这是因为部分还没有合并(并由 `AggregatingMergeTree` 聚合)。为了从部分状态中获取最终结果,我们需要添加 `GROUP BY`: ```sql SELECT @@ -157,10 +158,10 @@ ORDER BY location_id; ``` :::note -使用 `SimpleState`,您无需使用 `Merge` 组合器来合并部分聚合状态。 +使用 `SimpleState`,您无需使用 `Merge` 组合器来组合部分聚合状态。 ::: -## 另见 {#see-also} +## 参见 {#see-also} - [`min`](/sql-reference/aggregate-functions/reference/min) - [`SimpleState 组合器`](/sql-reference/aggregate-functions/combinators#-simplestate) - [`SimpleAggregateFunction 类型`](/sql-reference/data-types/simpleaggregatefunction) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/minSimpleState.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/minSimpleState.md.hash index abf03ca274e..7a61665e12d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/minSimpleState.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/minSimpleState.md.hash @@ -1 +1 @@ -70ad805946f7ac26 +6ea1d1fe10c3a149 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/quantilesTimingArrayIf.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/quantilesTimingArrayIf.md index e272bf24c71..1fe22ba994a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/quantilesTimingArrayIf.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/quantilesTimingArrayIf.md @@ -10,21 +10,22 @@ - 'examples' - 'quantilesTimingArrayIf' 'sidebar_label': 'quantilesTimingArrayIf' +'doc_type': 'reference' --- # quantilesTimingArrayIf {#quantilestimingarrayif} -## Description {#description} +## 描述 {#description} [`Array`](/sql-reference/aggregate-functions/combinators#-array) 和 [`If`](/sql-reference/aggregate-functions/combinators#-if) -组合器可应用于[`quantilesTiming`](/sql-reference/aggregate-functions/reference/quantiletiming) -函数,以计算条件为真的行中数组中时间值的分位数,使用 `quantilesTimingArrayIf` 聚合组合器函数。 +组合器可以应用于 [`quantilesTiming`](/sql-reference/aggregate-functions/reference/quantiletiming) +函数,以计算在条件为真的行中,数组中时间值的分位数,使用 `quantilesTimingArrayIf` 聚合组合函数。 -## Example Usage {#example-usage} +## 示例用法 {#example-usage} -在此示例中,我们将创建一个表,存储不同端点的 API 响应时间, -并使用 `quantilesTimingArrayIf` 计算成功请求的响应时间分位数。 +在这个例子中,我们将创建一个表来存储不同端点的 API 响应时间, +并将使用 `quantilesTimingArrayIf` 来计算成功请求的响应时间分位数。 ```sql title="Query" CREATE TABLE api_responses( @@ -45,14 +46,14 @@ FROM api_responses GROUP BY endpoint; ``` -`quantilesTimingArrayIf` 函数将只计算成功率超过 95% 的端点的分位数。 +`quantilesTimingArrayIf` 函数将仅计算成功率高于 95% 的端点的分位数。 返回的数组按顺序包含以下分位数: - 0 (最小值) - 0.25 (第一个四分位数) - 0.5 (中位数) - 0.75 (第三个四分位数) -- 0.95 (第 95 个百分位数) -- 0.99 (第 99 个百分位数) +- 0.95 (第 95 百分位数) +- 0.99 (第 99 百分位数) - 1.0 (最大值) ```response title="Response" @@ -63,6 +64,6 @@ GROUP BY endpoint; └──────────┴─────────────────────────────────────────────────────────────────────┘ ``` -## See also {#see-also} +## 参见 {#see-also} - [`quantilesTiming`](/sql-reference/aggregate-functions/reference/quantiletiming) - [`If combinator`](/sql-reference/aggregate-functions/combinators#-if) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/quantilesTimingArrayIf.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/quantilesTimingArrayIf.md.hash index 855017b0318..1225005c75f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/quantilesTimingArrayIf.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/quantilesTimingArrayIf.md.hash @@ -1 +1 @@ -d98ffbf12b53fdd0 +440e51ea76b2bb68 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/quantilesTimingIf.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/quantilesTimingIf.md index a73b1f744cc..3351ae57880 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/quantilesTimingIf.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/quantilesTimingIf.md @@ -9,6 +9,7 @@ - 'examples' - 'quantilesTimingIf' 'sidebar_label': 'quantilesTimingIf' +'doc_type': 'reference' --- @@ -16,11 +17,11 @@ ## 描述 {#description} -[`If`](/sql-reference/aggregate-functions/combinators#-if) 组合器可以应用于 [`quantilesTiming`](/sql-reference/aggregate-functions/reference/quantiletiming) 函数,以计算条件为真的行的时间值的分位数,使用 `quantilesTimingIf` 聚合组合器函数。 +[`If`](/sql-reference/aggregate-functions/combinators#-if) 组合器可以应用于 [`quantilesTiming`](/sql-reference/aggregate-functions/reference/quantiletiming) 函数,以计算条件为真的行的时间值分位数,使用 `quantilesTimingIf` 聚合组合器函数。 ## 示例用法 {#example-usage} -在这个例子中,我们将创建一个表来存储不同端点的 API 响应时间,并且我们将使用 `quantilesTimingIf` 来计算成功请求的响应时间分位数。 +在这个例子中,我们将创建一个表,用于存储不同端点的 API 响应时间,我们将使用 `quantilesTimingIf` 计算成功请求的响应时间分位数。 ```sql title="Query" CREATE TABLE api_responses( @@ -62,14 +63,14 @@ FROM api_responses GROUP BY endpoint; ``` -`quantilesTimingIf` 函数只会计算成功请求的分位数(is_successful = 1)。返回的数组按顺序包含以下分位数: -- 0(最小值) -- 0.25(第一个四分位数) -- 0.5(中位数) -- 0.75 (第三个四分位数) -- 0.95(95 百分位数) -- 0.99(99 百分位数) -- 1.0(最大值) +`quantilesTimingIf` 函数将仅计算成功请求的分位数 (is_successful = 1)。返回的数组包含以下按顺序排列的分位数: +- 0 (最小值) +- 0.25 (第一个四分位数) +- 0.5 (中位数) +- 0.75 (第三个四分位数) +- 0.95 (第95百分位数) +- 0.99 (第99百分位数) +- 1.0 (最大值) ```response title="Response" ┌─endpoint─┬─response_time_quantiles─────────────────────────────────────────────┐ @@ -79,6 +80,6 @@ GROUP BY endpoint; └──────────┴─────────────────────────────────────────────────────────────────────┘ ``` -## 另见 {#see-also} +## 参见 {#see-also} - [`quantilesTiming`](/sql-reference/aggregate-functions/reference/quantiletiming) - [`If 组合器`](/sql-reference/aggregate-functions/combinators#-if) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/quantilesTimingIf.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/quantilesTimingIf.md.hash index ed523856931..8ca0a9ecde8 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/quantilesTimingIf.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/quantilesTimingIf.md.hash @@ -1 +1 @@ -a892771754f3fd35 +28ac5d1edbd447fa diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/sumArray.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/sumArray.md index 73929ebfe4b..19a8c001393 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/sumArray.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/sumArray.md @@ -9,6 +9,7 @@ - 'examples' - 'sumArray' 'sidebar_label': 'sumArray' +'doc_type': 'reference' --- @@ -16,13 +17,16 @@ ## 描述 {#description} -[`Array`](/sql-reference/aggregate-functions/combinators#-array) 组合器可以应用于 [`sum`](/sql-reference/aggregate-functions/reference/sum) 函数,以使用 `sumArray` 聚合组合器函数计算数组中所有元素的总和。 +[`Array`](/sql-reference/aggregate-functions/combinators#-array) 组合器 +可以应用于 [`sum`](/sql-reference/aggregate-functions/reference/sum) +函数,以计算数组中所有元素的总和,使用 `sumArray` +聚合组合器函数。 -当您需要计算数据集中多个数组中所有元素的总和时,`sumArray` 函数非常有用。 +当需要计算数据集中多个数组中所有元素的总和时,`sumArray` 函数非常有用。 ## 示例用法 {#example-usage} -在这个例子中,我们将使用一个关于不同产品类别的每日销售的示例数据集来演示 `sumArray` 的工作原理。我们将计算每一天所有类别的总销售额。 +在此示例中,我们将使用一个关于不同产品类别的每日销售的示例数据集,以演示 `sumArray` 的工作原理。我们将计算每一天所有类别的总销售额。 ```sql title="Query" CREATE TABLE daily_category_sales @@ -39,16 +43,17 @@ INSERT INTO daily_category_sales VALUES SELECT date, category_sales, - sumArray(category_sales) as total_sales_sumArray, - sum(arraySum(category_sales)) as total_sales_arraySum + sumArray(category_sales) AS total_sales_sumArray, + sum(arraySum(category_sales)) AS total_sales_arraySum FROM daily_category_sales GROUP BY date, category_sales; ``` -`sumArray` 函数将对每个 `category_sales` 数组中的所有元素求和。例如,在 `2024-01-01`,它计算 `100 + 200 + 150 = 450`。这与 `arraySum` 得到的结果相同。 +`sumArray` 函数将对每个 `category_sales` 数组中的所有元素进行求和。 +例如,在 `2024-01-01`,它计算 `100 + 200 + 150 = 450`。这与 `arraySum` 的结果相同。 -## 另请参阅 {#see-also} +## 另请参见 {#see-also} - [`sum`](/sql-reference/aggregate-functions/reference/sum) -- [`arraySum`](/sql-reference/functions/array-functions#arraysum) +- [`arraySum`](/sql-reference/functions/array-functions#arraySum) - [`Array combinator`](/sql-reference/aggregate-functions/combinators#-array) - [`sumMap`](/examples/aggregate-function-combinators/sumMap) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/sumArray.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/sumArray.md.hash index 9062f3c1315..dd89f1299ac 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/sumArray.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/sumArray.md.hash @@ -1 +1 @@ -2a1e57f1d0141ab8 +b27f4aff9b357025 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/sumForEach.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/sumForEach.md index 27df0751bfd..6b8c6133800 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/sumForEach.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/sumForEach.md @@ -1,34 +1,35 @@ --- 'slug': '/examples/aggregate-function-combinators/sumForEach' 'title': 'sumForEach' -'description': '使用 sumArray 组合器的示例' +'description': '使用 sumForEach 聚合函数的示例' 'keywords': - 'sum' -- 'array' +- 'ForEach' - 'combinator' - 'examples' -- 'sumArray' -'sidebar_label': 'sumArray' +- 'sumForEach' +'sidebar_label': 'sumForEach' +'doc_type': 'reference' --- -# sumArray {#sumforeach} +# sumForEach {#sumforeach} ## Description {#description} -[`ForEach`](/sql-reference/aggregate-functions/combinators#-foreach) 组合器可以应用于 [`sum`](/sql-reference/aggregate-functions/reference/sum) 聚合函数,将其从作用于行值的聚合函数转变为作用于数组列的聚合函数,应用聚合到每行数组中的每个元素。 +[`ForEach`](/sql-reference/aggregate-functions/combinators#-foreach) 组合器可以应用于 [`sum`](/sql-reference/aggregate-functions/reference/sum) 聚合函数,将其从一个操作行值的聚合函数转变为一个操作数组列的聚合函数,在跨行的每个元素上应用聚合。 -## Example Usage {#example-usage} +## Example usage {#example-usage} -在这个例子中,我们将使用在我们的 [SQL playground](https://sql.clickhouse.com/) 中可用的 `hits` 数据集。 +在这个例子中,我们将利用我们 [SQL playground](https://sql.clickhouse.com/) 中提供的 `hits` 数据集。 -`hits` 表包含一个名为 `isMobile` 的 UInt8 类型列,可能为 `0` 表示桌面,或 `1` 表示移动设备: +`hits` 表包含一个名为 `isMobile` 的 UInt8 类型列,可以是 `0` 表示桌面或 `1` 表示移动设备: ```sql runnable SELECT EventTime, IsMobile FROM metrica.hits ORDER BY rand() LIMIT 10 ``` -我们将使用 `sumForEach` 聚合组合器函数来分析桌面与移动流量随一天的每小时变化。点击下面的播放按钮以交互方式运行查询: +我们将使用 `sumForEach` 聚合组合器函数来分析桌面与移动流量如何按小时变化。点击下面的播放按钮以交互方式运行查询: ```sql runnable SELECT @@ -45,4 +46,4 @@ ORDER BY hour_of_day; ## See also {#see-also} - [`sum`](/sql-reference/aggregate-functions/reference/sum) -- [`ForEach combinator`](/sql-reference/aggregate-functions/combinators#-foreach) +- [`ForEach` combinator](/sql-reference/aggregate-functions/combinators#-foreach) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/sumForEach.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/sumForEach.md.hash index 86ed867548c..dd20eba307d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/sumForEach.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/sumForEach.md.hash @@ -1 +1 @@ -20475ed33a7d4fcf +b691da0028c8b9e2 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/sumIf.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/sumIf.md index 000cfa92afc..bd319cc676c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/sumIf.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/sumIf.md @@ -9,6 +9,7 @@ - 'examples' - 'sumIf' 'sidebar_label': 'sumIf' +'doc_type': 'reference' --- @@ -17,11 +18,11 @@ ## 描述 {#description} [`If`](/sql-reference/aggregate-functions/combinators#-if) 组合器可以应用于 [`sum`](/sql-reference/aggregate-functions/reference/sum) -函数,以计算条件为真的行的值之和,使用 `sumIf` 聚合组合器函数。 +函数,以计算条件为真的行的值的总和,使用 `sumIf` 聚合组合器函数。 ## 示例用法 {#example-usage} -在此示例中,我们将创建一个存储销售数据及成功标志的表,并使用 `sumIf` 计算成功交易的总销售额。 +在这个例子中,我们将创建一个存储销售数据及成功标志的表,并使用 `sumIf` 来计算成功交易的总销售额。 ```sql title="Query" CREATE TABLE sales( @@ -39,12 +40,12 @@ INSERT INTO sales VALUES (6, 175.25, 1); SELECT - sumIf(amount, is_successful = 1) as total_successful_sales + sumIf(amount, is_successful = 1) AS total_successful_sales FROM sales; ``` `sumIf` 函数将仅对 `is_successful = 1` 的金额进行求和。 -在这种情况下,它将求和:100.50 + 200.75 + 300.00 + 175.25。 +在这个例子中,它将求和:100.50 + 200.75 + 300.00 + 175.25。 ```response title="Response" ┌─total_successful_sales─┐ @@ -54,8 +55,8 @@ FROM sales; ### 按价格方向计算交易量 {#calculate-trading-vol-price-direction} -在此示例中,我们将使用 [ClickHouse playground](https://sql.clickhouse.com/) 提供的 `stock` 表, -计算 2002 年上半年按价格方向的交易量。 +在此示例中,我们将使用 [ClickHouse playground](https://sql.clickhouse.com/) 中的 `stock` 表 +来计算2002年上半年按价格方向的交易量。 ```sql title="Query" SELECT @@ -89,8 +90,8 @@ ORDER BY month; ### 按股票符号计算交易量 {#calculate-trading-volume} -在此示例中,我们将使用 [ClickHouse playground](https://sql.clickhouse.com/) 提供的 `stock` 表, -计算 2006 年三家当时最大的科技公司的股票符号交易量。 +在此示例中,我们将使用 [ClickHouse playground](https://sql.clickhouse.com/) 中的 `stock` 表 +来计算2006年三家当时最大的科技公司的股票符号交易量。 ```sql title="Query" SELECT @@ -125,4 +126,4 @@ ORDER BY month; ## 另请参阅 {#see-also} - [`sum`](/sql-reference/aggregate-functions/reference/sum) -- [`If 组合器`](/sql-reference/aggregate-functions/combinators#-if) +- [`If combinator`](/sql-reference/aggregate-functions/combinators#-if) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/sumIf.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/sumIf.md.hash index be094b7d3ee..24c7d634fc0 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/sumIf.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/sumIf.md.hash @@ -1 +1 @@ -0463fb6572766d08 +1a564f585dddf53d diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/sumMap.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/sumMap.md index 89cbf5062eb..67221d43131 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/sumMap.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/sumMap.md @@ -9,6 +9,7 @@ - 'examples' - 'sumMap' 'sidebar_label': 'sumMap' +'doc_type': 'reference' --- @@ -20,7 +21,7 @@ ## 示例用法 {#example-usage} -在这个例子中,我们将创建一个表,用于存储状态码及其在不同时间段内的计数,每行包含一个状态码到其对应计数的 Map。我们将使用 `sumMap` 计算每个时间段内每个状态码的总计数。 +在这个示例中,我们将创建一个表,存储不同时间段的状态码及其计数,其中每一行包含一个状态码到其相应计数的 Map。我们将使用 `sumMap` 来计算每个时间段内每个状态码的总计数。 ```sql title="Query" CREATE TABLE metrics( @@ -62,6 +63,6 @@ GROUP BY timeslot; └─────────────────────┴──────────────────────────────────────┘ ``` -## 另见 {#see-also} +## 另请参阅 {#see-also} - [`sum`](/sql-reference/aggregate-functions/reference/sum) - [`Map 组合器`](/sql-reference/aggregate-functions/combinators#-map) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/sumMap.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/sumMap.md.hash index 047baa87fab..5fbe17e40d6 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/sumMap.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/sumMap.md.hash @@ -1 +1 @@ -002bae85cbe2d7c5 +a81bed42a5eed625 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/sumSimpleState.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/sumSimpleState.md index 8d37fdc0363..4d4fa2e998b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/sumSimpleState.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/sumSimpleState.md @@ -10,6 +10,7 @@ - 'examples' - 'sumSimpleState' 'sidebar_label': 'sumSimpleState' +'doc_type': 'reference' --- @@ -17,13 +18,13 @@ ## 描述 {#description} -[`SimpleState`](/sql-reference/aggregate-functions/combinators#-simplestate) 组合器可以应用于 [`sum`](/sql-reference/aggregate-functions/reference/sum) 函数,以返回所有输入值的总和。它返回的结果类型为 [`SimpleAggregateFunction`](/docs/sql-reference/data-types/simpleaggregatefunction)。 +[`SimpleState`](/sql-reference/aggregate-functions/combinators#-simplestate) 组合器可以应用于 [`sum`](/sql-reference/aggregate-functions/reference/sum) 函数,以返回所有输入值的总和。它将结果返回为 [`SimpleAggregateFunction`](/docs/sql-reference/data-types/simpleaggregatefunction) 类型。 ## 示例用法 {#example-usage} ### 跟踪点赞和点踩 {#tracking-post-votes} -让我们来看一个实际的示例,使用一个跟踪帖子投票的表。对于每个帖子,我们想要维护点赞、点踩和总体得分的累积总数。使用 `SimpleAggregateFunction` 类型与 sum 结合非常适合这个用例,因为我们只需要存储运行总数,而不是聚合的整个状态。因此,这将更快,并且不需要合并部分聚合状态。 +让我们看一个使用跟踪帖子投票的表的实际示例。对于每个帖子,我们希望维护点赞、点踩和整体得分的运行总计。使用 `SimpleAggregateFunction` 类型与 sum 结合适合这类用例,因为我们只需要存储运行总计,而不需要整个聚合状态。因此,它将更快,并且不需要合并部分聚合状态。 首先,我们创建一个用于原始数据的表: @@ -51,7 +52,7 @@ ENGINE = AggregatingMergeTree() ORDER BY post_id; ``` -然后,我们创建一个包含 `SimpleAggregateFunction` 类型列的物化视图: +然后,我们创建一个具有 `SimpleAggregateFunction` 类型列的物化视图: ```sql CREATE MATERIALIZED VIEW mv_vote_processor TO vote_aggregates @@ -102,5 +103,5 @@ ORDER BY post_id ASC; ## 另请参阅 {#see-also} - [`sum`](/sql-reference/aggregate-functions/reference/sum) -- [`SimpleState 组合器`](/sql-reference/aggregate-functions/combinators#-simplestate) -- [`SimpleAggregateFunction 类型`](/sql-reference/data-types/simpleaggregatefunction) +- [`SimpleState combinator`](/sql-reference/aggregate-functions/combinators#-simplestate) +- [`SimpleAggregateFunction type`](/sql-reference/data-types/simpleaggregatefunction) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/sumSimpleState.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/sumSimpleState.md.hash index 378ed8180d5..1a24642b52e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/sumSimpleState.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/sumSimpleState.md.hash @@ -1 +1 @@ -19e781070892ef2f +f55c2fb6160a265d diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/uniqArray.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/uniqArray.md index 7fd5fa8b69a..59f569ac54d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/uniqArray.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/uniqArray.md @@ -9,6 +9,7 @@ - 'examples' - 'uniqArray' 'sidebar_label': 'uniqArray' +'doc_type': 'reference' --- @@ -16,13 +17,15 @@ ## 描述 {#description} -[`Array`](/sql-reference/aggregate-functions/combinators#-array) 组合器可以应用于 [`uniq`](/sql-reference/aggregate-functions/reference/uniq) 函数,以计算所有数组中唯一元素的近似数量,使用 `uniqArray` 聚合组合器函数。 +[`Array`](/sql-reference/aggregate-functions/combinators#-array) 组合器 +可以应用于 [`uniq`](/sql-reference/aggregate-functions/reference/uniq) +函数,以计算所有数组中唯一元素的近似数量,使用 `uniqArray` 聚合组合器函数。 -`uniqArray` 函数在需要计算数据集中多个数组中的唯一元素时非常有用。它相当于使用 `uniq(arrayJoin())`,其中 `arrayJoin` 首先扁平化数组,然后 `uniq` 计算唯一元素的数量。 +当你需要在数据集中计算多个数组中的唯一元素时,`uniqArray` 函数非常有用。它相当于使用 `uniq(arrayJoin())`,其中 `arrayJoin` 首先将数组扁平化,然后 `uniq` 计算唯一元素的数量。 ## 示例用法 {#example-usage} -在这个例子中,我们将使用一个用户兴趣的示例数据集,涵盖不同类别,以演示 `uniqArray` 的工作原理。我们将其与 `uniq(arrayJoin())` 进行比较,以显示计算唯一元素的差异。 +在这个例子中,我们将使用一个关于用户在不同类别中兴趣的示例数据集来演示 `uniqArray` 的工作原理。我们将其与 `uniq(arrayJoin())` 进行比较,以显示在计算唯一元素时的区别。 ```sql title="Query" CREATE TABLE user_interests @@ -37,14 +40,15 @@ INSERT INTO user_interests VALUES (3, ['reading', 'cooking']); SELECT - uniqArray(interests) as unique_interests_total, - uniq(arrayJoin(interests)) as unique_interests_arrayJoin + uniqArray(interests) AS unique_interests_total, + uniq(arrayJoin(interests)) AS unique_interests_arrayJoin FROM user_interests; ``` -`uniqArray` 函数计算所有合并数组中的唯一元素,类似于 `uniq(arrayJoin())`。在这个例子中: -- `uniqArray` 返回 5,因为所有用户中有 5 个独特的兴趣:'reading', 'gaming', 'music', 'sports', 'cooking' -- `uniq(arrayJoin())` 也返回 5,显示这两个函数都计算所有数组中的唯一元素 +`uniqArray` 函数计算所有合并数组中的唯一元素数量,类似于 `uniq(arrayJoin())`。 +在这个例子中: +- `uniqArray` 返回 5,因为在所有用户中有 5 个独特的兴趣:'reading'(阅读)、'gaming'(游戏)、'music'(音乐)、'sports'(运动)、'cooking'(烹饪) +- `uniq(arrayJoin())` 也返回 5,显示两个函数都计算了所有数组中的唯一元素 ```response title="Response" ┌─unique_interests_total─┬─unique_interests_arrayJoin─┐ @@ -55,5 +59,5 @@ FROM user_interests; ## 另请参见 {#see-also} - [`uniq`](/sql-reference/aggregate-functions/reference/uniq) - [`arrayJoin`](/sql-reference/functions/array-join) -- [`Array 组合器`](/sql-reference/aggregate-functions/combinators#-array) +- [`Array combinator`](/sql-reference/aggregate-functions/combinators#-array) - [`uniqCombined`](/sql-reference/aggregate-functions/reference/uniqcombined) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/uniqArray.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/uniqArray.md.hash index f494423842b..d06d2df5d9a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/uniqArray.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/uniqArray.md.hash @@ -1 +1 @@ -9d8c80ca6b4f14c2 +725419c209b4bfd0 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/uniqArrayIf.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/uniqArrayIf.md index caa66fb4a51..f8791a0fb6d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/uniqArrayIf.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/uniqArrayIf.md @@ -10,6 +10,7 @@ - 'examples' - 'uniqArrayIf' 'sidebar_label': 'uniqArrayIf' +'doc_type': 'reference' --- @@ -17,19 +18,19 @@ ## 描述 {#description} -[`Array`](/sql-reference/aggregate-functions/combinators#-array) 和 [`If`](/sql-reference/aggregate-functions/combinators#-if) 组合器可以应用于 [`uniq`](/sql-reference/aggregate-functions/reference/uniq) 函数,以便在条件为真时,计算数组中唯一值的数量,通过使用 `uniqArrayIf` 聚合组合器函数。 +[`Array`](/sql-reference/aggregate-functions/combinators#-array) 和 [`If`](/sql-reference/aggregate-functions/combinators#-if) 组合器可以应用于 [`uniq`](/sql-reference/aggregate-functions/reference/uniq) 函数,以使用 `uniqArrayIf` 聚合组合器函数计算在条件为真时数组中唯一值的数量。 :::note -- `If` 和 `Array` 可以组合使用。然而,`Array` 必须首先出现,然后是 `If`。 +- `If` 和 `Array` 可以结合使用。然而,`Array` 必须放在前面,然后是 `If`。 ::: -当您希望根据特定条件计算数组中的唯一元素,而无需使用 `arrayJoin` 时,这非常有用。 +当您想要根据特定条件计算数组中的唯一元素而不必使用 `arrayJoin` 时,这非常有用。 ## 示例用法 {#example-usage} -### 按段类型和参与度级别计算查看的唯一产品 {#count-unique-products} +### 按段类型和参与度级别计算唯一浏览产品数 {#count-unique-products} -在此示例中,我们将使用一个包含用户购物会话数据的表,计算特定用户段的用户和会话中停留时间的参与度指标所查看的唯一产品数量。 +在此示例中,我们将使用一个包含用户购物会话数据的表来计算在特定用户段的用户和参与度指标为会话中花费的时间的情况下浏览的唯一产品数。 ```sql title="Query" CREATE TABLE user_shopping_sessions diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/uniqArrayIf.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/uniqArrayIf.md.hash index 16044049064..2812486479d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/uniqArrayIf.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/examples/aggregate_function_combinators/uniqArrayIf.md.hash @@ -1 +1 @@ -49cbd2e146adc04f +46356a8622b2e45b diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/inserting-data.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/inserting-data.md index 164984a7faf..f8ec30f2edc 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/inserting-data.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/inserting-data.md @@ -1,12 +1,13 @@ --- 'title': '插入 ClickHouse 数据' -'description': '如何将数据插入到 ClickHouse 中' +'description': '如何将数据插入 ClickHouse' 'keywords': - 'INSERT' - 'Batch Insert' 'sidebar_label': '插入 ClickHouse 数据' 'slug': '/guides/inserting-data' 'show_related_blogs': true +'doc_type': 'guide' --- import postgres_inserts from '@site/static/images/guides/postgres-inserts.png'; @@ -14,7 +15,7 @@ import Image from '@theme/IdealImage'; ## 基本示例 {#basic-example} -您可以使用熟悉的 `INSERT INTO TABLE` 命令与 ClickHouse。让我们向在开始指南中创建的表中插入一些数据 ["在 ClickHouse 中创建表"](./creating-tables)。 +您可以使用熟悉的 `INSERT INTO TABLE` 命令与 ClickHouse。一起来插入一些数据到我们在入门指南中创建的表 ["在 ClickHouse 中创建表"](./creating-tables)。 ```sql INSERT INTO helloworld.my_first_table (user_id, message, timestamp, metric) VALUES @@ -24,13 +25,13 @@ INSERT INTO helloworld.my_first_table (user_id, message, timestamp, metric) VALU (101, 'Granules are the smallest chunks of data read', now() + 5, 3.14159 ) ``` -为了验证是否成功,我们将运行以下 `SELECT` 查询: +为了验证这个操作是否成功,我们将运行以下 `SELECT` 查询: ```sql SELECT * FROM helloworld.my_first_table ``` -返回结果为: +返回结果如下: ```response user_id message timestamp metric @@ -40,92 +41,92 @@ user_id message timestamp 102 Sort your data based on your commonly-used queries 2024-11-13 00:00:00 2.718 ``` -## 向 ClickHouse 插入与 OLTP 数据库的对比 {#inserting-into-clickhouse-vs-oltp-databases} +## 向 ClickHouse 插入数据与向 OLTP 数据库插入数据的比较 {#inserting-into-clickhouse-vs-oltp-databases} -作为一个 OLAP(在线分析处理)数据库,ClickHouse 针对高性能和可扩展性进行了优化,允许每秒插入数百万行。这是通过高度并行化的架构和高效的列式压缩相结合实现的,但在即时一致性上有所妥协。更具体来说,ClickHouse 针对仅追加操作进行了优化,并且仅提供最终一致性保证。 +作为一个 OLAP(在线分析处理)数据库,ClickHouse 针对高性能和可扩展性进行了优化,允许每秒插入数百万行数据。这是通过高度并行化的架构和高效的列式压缩相结合实现的,但在即时一致性上做出了妥协。更具体来说,ClickHouse 是针对仅追加操作进行优化的,并且只提供最终一致性保证。 -相比之下,Postgres 等 OLTP 数据库专门针对具有完整 ACID 合规性的事务插入进行了优化,确保强一致性和可靠性保证。PostgreSQL 使用 MVCC(多版本并发控制)来处理并发事务,这涉及维护多个版本的数据。这些事务可能一次只涉及少量行,由于可靠性保证而导致的额外开销会限制插入性能。 +相对而言,像 Postgres 这样的 OLTP 数据库专门针对事务插入进行了优化,具有完整的 ACID 兼容性,确保强一致性和可靠性保证。PostgreSQL 使用 MVCC(多版本并发控制)来处理并发事务,这涉及维护数据的多个版本。这些事务在某个时刻可能只涉及少量行,并且由于可靠性保证而会产生可观的开销,从而限制插入性能。 -为了在保持强一致性保证的同时实现高插入性能,用户在向 ClickHouse 插入数据时应遵循以下简单规则。遵循这些规则将有助于避免用户在首次使用 ClickHouse 时常遇到的问题,并尝试复制适用于 OLTP 数据库的插入策略。 +为了在保持强一致性保证的同时实现高插入性能,用户在向 ClickHouse 插入数据时应遵循下面描述的简单规则。遵循这些规则将有助于避免用户在第一次使用 ClickHouse 时常遇到的问题,并尝试复制适用于 OLTP 数据库的插入策略。 ## 插入的最佳实践 {#best-practices-for-inserts} ### 大批量插入 {#insert-in-large-batch-sizes} -默认情况下,发送到 ClickHouse 的每个插入都会使 ClickHouse 立即创建一个存储部分,包含来自插入的数据以及需要存储的其他元数据。因此,发送较少的插入但每个插入包含更多数据,与发送较多插入但每个插入包含较少数据相比,将减少所需的写入数量。通常,我们建议每次插入至少 1,000 行,理想情况下在 10,000 到 100,000 行之间。 -(更多详细信息请见 [这里](https://clickhouse.com/blog/asynchronous-data-inserts-in-clickhouse#data-needs-to-be-batched-for-optimal-performance))。 +默认情况下,每个发送到 ClickHouse 的插入会导致 ClickHouse 立即创建一个存储部分,其中包含插入的数据以及需要存储的其他元数据。因此,发送较小数量但每个包含更多数据的插入比发送数量较多但每个包含较少数据的插入将减少所需的写入次数。一般来说,我们建议一次插入至少 1,000 行的数据,理想情况下在 10,000 到 100,000 行之间。 +(更多详细信息 [请点击这里](https://clickhouse.com/blog/asynchronous-data-inserts-in-clickhouse#data-needs-to-be-batched-for-optimal-performance))。 -如果大批量插入不可行,请使用下面描述的异步插入。 +如果无法进行大批量插入,请使用下面描述的异步插入。 -### 确保一致的批处理以便幂等重试 {#ensure-consistent-batches-for-idempotent-retries} +### 确保一致的批次以实现幂等重试 {#ensure-consistent-batches-for-idempotent-retries} -默认情况下,向 ClickHouse 的插入是同步的并且是幂等的(即多次执行相同的插入操作与执行一次具有相同的效果)。对于 MergeTree 引擎系列的表,ClickHouse 默认情况下会自动 [去重插入](https://clickhouse.com/blog/common-getting-started-issues-with-clickhouse#5-deduplication-at-insert-time)。 +默认情况下,向 ClickHouse 的插入是同步的并且是幂等的(即,执行相同的插入操作多次的效果与执行一次相同)。对于 MergeTree 引擎家族的表,ClickHouse 默认会自动 [去重插入](https://clickhouse.com/blog/common-getting-started-issues-with-clickhouse#5-deduplication-at-insert-time)。 -这意味着在以下情况下,插入仍然具有弹性: +这意味着在以下情况下插入仍然具有弹性: -- 1. 如果接收数据的节点出现问题,插入查询将超时(或给出更具体的错误),并且不会获得确认。 -- 2. 如果数据被节点写入但由于网络中断无法将确认返回给查询的发送方,则发送方会收到超时或网络错误。 +- 1. 如果接收数据的节点出现问题,插入查询将超时(或给出更具体的错误)并且不会获得确认。 +- 2. 如果数据已被节点写入但由于网络中断无法将确认返回给查询的发送者,发送者将会收到超时或网络错误。 -从客户端的角度来看,(i) 和 (ii) 可能很难区分。然而,在这两种情况下,未确认的插入可以立即重试。只要重试的插入查询包含相同的数据且顺序相同,ClickHouse 将自动忽略如果(未确认)原始插入成功的重试插入。 +从客户端的角度来看,(i)和(ii)可能难以区分。然而,在这两种情况下,未确认的插入可以立即重试。只要重试的插入查询包含相同的数据和相同的顺序,ClickHouse 将自动忽略重试的插入,如果(未确认的)原始插入成功。 ### 向 MergeTree 表或分布式表插入 {#insert-to-a-mergetree-table-or-a-distributed-table} -我们建议直接插入到 MergeTree(或 Replicated 表)中,如果数据是分片的,则在一组节点之间平衡请求,并设置 `internal_replication=true`。这将让 ClickHouse 将数据复制到任何可用的副本分片中,并确保数据最终一致。 +我们建议直接向 MergeTree(或副本表)插入数据,如果数据是分片的,请在一组节点之间平衡请求,并设置 `internal_replication=true`。这将让 ClickHouse 将数据复制到任何可用的副本分片,并确保数据最终一致。 -如果这种客户端负载均衡不方便,则用户可以通过 [分布式表](/engines/table-engines/special/distributed) 插入数据,从而在节点之间分配写入。再次建议设置 `internal_replication=true`。但是需要注意的是,这种方法的性能略差,因为写入需要先在具有分布式表的节点上进行,然后再发送到分片。 +如果这种客户端负载均衡不方便,用户可以通过 [分布式表](/engines/table-engines/special/distributed) 插入,然后将写入分配到各个节点。再次建议设置 `internal_replication=true`。但需注意,这种方法的性能略低,因为写入必须在具有分布式表的节点本地进行,然后再发送到分片。 -### 对小批量数据使用异步插入 {#use-asynchronous-inserts-for-small-batches} +### 使用异步插入进行小批量插入 {#use-asynchronous-inserts-for-small-batches} -在某些场景下,客户端批处理不可行,例如具有数百或数千个单用途代理发送日志、指标、跟踪等的可观察性用例。在这种情况下,数据的实时传输对于尽快检测问题和异常至关重要。此外,观察到的系统中事件激增的风险可能会导致在尝试客户端缓冲可观察性数据时出现大内存激增及相关问题。如果无法插入大批量数据,用户可以使用 [异步插入](/best-practices/selecting-an-insert-strategy#asynchronous-inserts) 将批处理委托给 ClickHouse。 +在某些情况下,客户端批处理不可行,例如,在有数百或数千个单用途代理发送日志、度量和跟踪的可观察性用例中。在这种情况下,实时传输该数据是及早检测问题和异常的关键。此外,观察系统中可能会出现事件高峰,这可能导致在尝试在客户端缓冲可观察性数据时出现大的内存峰值和相关问题。如果无法插入大批量数据,用户可以使用 [异步插入](/best-practices/selecting-an-insert-strategy#asynchronous-inserts) 将批处理委托给 ClickHouse。 -使用异步插入时,数据首先被插入到缓冲区,然后在 3 步后写入数据库存储,如下图所示: +通过异步插入,数据首先插入到缓冲区,然后在后续的三个步骤中写入数据库存储,如下图所示: 启用异步插入后,ClickHouse: -(1) 异步接收插入查询。 -(2) 首先将查询的数据写入内存缓冲区。 -(3) 仅在下一次缓冲区刷新时将数据排序并写入数据库存储,成为一部分。 +(1) 异步接收插入查询。 +(2) 首先将查询的数据写入内存缓冲区。 +(3) 仅在下次缓冲区刷新发生时,将数据排序并写入数据库存储。 -在缓冲区刷新之前,来自同一客户端或其他客户端的其他异步插入查询的数据可以在缓冲区中收集。通过缓冲区刷新创建的部分可能包含来自多个异步插入查询的数据。通常,这些机制将数据的批处理从客户端转移到服务器端(ClickHouse 实例)。 +在缓冲区刷新之前,来自同一客户端或其他客户端的其他异步插入查询的数据可以在缓冲区中收集。由缓冲区刷新创建的部分可能包含来自多个异步插入查询的数据。通常,这种机制将数据的批处理从客户端转移到服务器端(ClickHouse 实例)。 :::note -请注意,在数据刷新到数据库存储之前,查询无法搜索到数据,并且缓冲区刷新的配置是可调的。 +请注意,在数据刷新到数据库存储之前,该数据不能通过查询进行检索,并且缓冲区刷新是可配置的。 -有关配置异步插入的完整详细信息,请参见 [这里](/optimize/asynchronous-inserts#enabling-asynchronous-inserts),更深入的讨论可见 [这里](https://clickhouse.com/blog/asynchronous-data-inserts-in-clickhouse)。 +有关配置异步插入的完整细节,请参见 [这里](/optimize/asynchronous-inserts#enabling-asynchronous-inserts),更深入的讨论请见 [这里](https://clickhouse.com/blog/asynchronous-data-inserts-in-clickhouse)。 ::: -### 使用官方 ClickHouse 客户端 {#use-official-clickhouse-clients} +### 使用官方的 ClickHouse 客户端 {#use-official-clickhouse-clients} -ClickHouse 在最流行的编程语言中都有客户端。这些客户端经过优化,以确保正确执行插入,并原生支持异步插入,无论是直接如 [Go 客户端](/integrations/go#async-insert),还是在查询、用户或连接级别设置中启用的间接方式。 +ClickHouse 在最流行的编程语言中都有客户端。这些客户端得到了优化,以确保插入操作的正确执行,并直接支持异步插入,例如在 [Go 客户端](/integrations/go#async-insert) 中,或者在查询、用户或连接级别设定中启用时间接支持。 -请参阅 [客户端和驱动程序](/interfaces/cli) 以获取可用 ClickHouse 客户端和驱动程序的完整列表。 +请参见 [客户端和驱动](/interfaces/cli) 获取可用的 ClickHouse 客户端和驱动的完整列表。 -### 优先使用原生格式 {#prefer-the-native-format} +### 优先选择原生格式 {#prefer-the-native-format} -ClickHouse 在插入(和查询)时支持多种 [输入格式](/interfaces/formats)。这是与 OLTP 数据库的一个显著区别,并使从外部源加载数据变得更加容易 - 特别是与 [表函数](/sql-reference/table-functions) 和从磁盘文件加载数据的能力结合使用时。这些格式非常适合临时数据加载和数据工程任务。 +ClickHouse 在插入(和查询)时支持多种 [输入格式](/interfaces/formats)。这与 OLTP 数据库有显著区别,并且使得从外部源加载数据变得更加容易——特别是与 [表函数](/sql-reference/table-functions) 和从磁盘文件加载数据的能力相结合。这些格式非常适合临时数据加载和数据工程任务。 -对于希望实现最佳插入性能的应用程序,用户应使用 [原生](/interfaces/formats/Native) 格式插入。这被大多数客户端(例如 Go 和 Python)支持,并确保服务器的工作量最小,因为此格式已经是列式的。通过这样做,负责将数据转换为列式格式的责任转移到客户端。这对于高效扩展插入非常重要。 +对于希望实现最佳插入性能的应用程序,用户应使用 [原生](/interfaces/formats/Native) 格式进行插入。这得到了大多数客户端(如 Go 和 Python)的支持,并确保服务器需要做的工作最少,因为此格式已经是列式的。通过这样做,将数据转换为列式格式的责任放在了客户端。这对于有效扩展插入至关重要。 -另外,用户可以使用 [RowBinary 格式](/interfaces/formats/RowBinary)(如 Java 客户端使用的格式),如果更喜欢行格式 - 这通常比原生格式更易于编写。在压缩、网络开销和服务器处理方面,这比其他行格式(如 [JSON](/interfaces/formats/JSON))更有效。对于希望快速集成且写入吞吐量较低的用户,可以考虑 [JSONEachRow](/interfaces/formats/JSONEachRow) 格式。用户应注意,ClickHouse 解析该格式会产生 CPU 开销。 +或者,如果更喜欢行格式,用户可以使用 [RowBinary 格式](/interfaces/formats/RowBinary)(如 Java 客户端所使用),这通常比原生格式更容易写入。这种格式在压缩、网络开销和服务器处理方面比其他行格式(如 [JSON](/interfaces/formats/JSON))效率更高。对于希望快速集成且写入吞吐量较低的用户,可以考虑使用 [JSONEachRow](/interfaces/formats/JSONEachRow) 格式。用户应注意,这种格式会在 ClickHouse 中引入 CPU 解析开销。 ### 使用 HTTP 接口 {#use-the-http-interface} -与许多传统数据库不同,ClickHouse 支持 HTTP 接口。用户可以使用此接口进行数据的插入和查询,使用上述任何格式。这通常比 ClickHouse 的原生协议更可取,因为它允许流量轻松与负载均衡器切换。我们预计使用原生协议插入性能会有小差异,这会导致稍微少一些开销。现有客户端使用这两种协议(在某些情况下,两者均使用,例如 Go 客户端)。原生协议确实允许轻松跟踪查询进度。 +与许多传统数据库不同,ClickHouse 支持 HTTP 接口。用户可以使用此接口插入和查询数据,使用上述任一格式。这通常比 ClickHouse 的原生协议更受欢迎,因为它允许与负载均衡器轻松切换流量。我们预计使用原生协议时,插入性能会有小的差异,因为其开销稍低。现有客户端使用这两种协议(在某些情况下,两者都在使用,例如 Go 客户端)。原生协议确实允许轻松跟踪查询进度。 -有关进一步细节,请参见 [HTTP 接口](/interfaces/http)。 +有关更多详细信息,请见 [HTTP 接口](/interfaces/http)。 ## 从 Postgres 加载数据 {#loading-data-from-postgres} 要从 Postgres 加载数据,用户可以使用: -- `PeerDB by ClickHouse`,一种专门为 PostgreSQL 数据库复制设计的 ETL 工具。这在以下两种情况下可用: - - ClickHouse Cloud - 通过我们的 [新连接器](/integrations/clickpipes/postgres) 在 ClickPipes 中可用,这是我们的托管输入服务。 +- `PeerDB by ClickHouse`,一个专门为 PostgreSQL 数据库复制设计的 ETL 工具。这在以下两个方面提供支持: + - ClickHouse Cloud - 通过我们在 ClickPipes 中的新连接器 [获取](https://clickhouse.com/integrations/clickpipes/postgres),这是我们的管理型导入服务。 - 自管理 - 通过 [开源项目](https://github.com/PeerDB-io/peerdb)。 -- [PostgreSQL 表引擎](/integrations/postgresql#using-the-postgresql-table-engine) 直接读取数据,如前面示例所示。通常适用于基于已知水印(例如时间戳)进行的批量复制,或者是一次性迁移。这种方法可以扩展到数千万行。希望迁移较大数据集的用户应考虑多次请求,每次处理一部分数据。可以为每个分块使用暂存表,然后将其分区移动到最终表。这允许重试失败的请求。有关此批量加载策略的更多详细信息,请参见这里。 -- 数据可以以 CSV 格式从 PostgreSQL 导出。然后,可以通过本地文件或使用表函数通过对象存储插入到 ClickHouse 中。 +- [PostgreSQL 表引擎](/integrations/postgresql#using-the-postgresql-table-engine) 直接读取数据,正如之前的示例所示。当基于已知水印(例如时间戳)的批量复制足够时,或者这是一次性的迁移。这种方法可以扩展到数千万行。用户希望迁移更大的数据集时,可以考虑多次请求,每次处理一块数据。可以为每块数据使用暂存表,在其分区迁移到最终表之前。这使得失败的请求能够重试。有关此批量加载策略的更多详细信息,请参见此处。 +- 数据可以以 CSV 格式从 PostgreSQL 导出。这可以从本地文件或通过对象存储使用表函数插入到 ClickHouse 中。 :::note 需要帮助插入大型数据集? -如果您在插入大型数据集时需要帮助,或在将数据导入 ClickHouse Cloud 时遇到任何错误,请通过 support@clickhouse.com 联系我们,我们将提供帮助。 +如果您需要帮助插入大型数据集或在将数据导入 ClickHouse Cloud 时遇到任何错误,请通过 support@clickhouse.com 与我们联系,我们将提供帮助。 ::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/inserting-data.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/inserting-data.md.hash index 6fca4c087b6..a1922d31f37 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/inserting-data.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/inserting-data.md.hash @@ -1 +1 @@ -e264941631a381ad +e5159110736a6021 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/joining-tables.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/joining-tables.md index d3c3bc1e081..d12018abab1 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/joining-tables.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/joining-tables.md @@ -1,10 +1,11 @@ --- 'title': '在 ClickHouse 中使用 JOINs' -'description': '如何在 ClickHouse 中连接 TABLES' +'description': '如何在 ClickHouse 中连接 TABLE' 'keywords': - 'joins' - 'join tables' 'slug': '/guides/joining-tables' +'doc_type': 'guide' --- import Image from '@theme/IdealImage'; @@ -14,15 +15,15 @@ import joins_3 from '@site/static/images/guides/joins-3.png'; import joins_4 from '@site/static/images/guides/joins-4.png'; import joins_5 from '@site/static/images/guides/joins-5.png'; -ClickHouse 具有 [完整的 `JOIN` 支持](https://clickhouse.com/blog/clickhouse-fully-supports-joins-part1),提供多种连接算法。为了最大化性能,我们建议遵循本指南中列出的连接优化建议。 +ClickHouse 具有 [完整的 `JOIN` 支持](https://clickhouse.com/blog/clickhouse-fully-supports-joins-part1),提供了多种连接算法。为了最大化性能,我们建议遵循本指南中列出的连接优化建议。 -- 为了获得最佳性能,用户应尽量减少查询中的 `JOIN` 数量,特别是在实时分析工作负载中,要求毫秒级性能。查询中的 `JOIN` 数量应以 3 到 4 次为上限。我们在 [数据建模部分](/data-modeling/schema-design) 中详细介绍了许多减少连接的方法,包括反规范化、字典和物化视图。 -- 当前,ClickHouse 不会重新排序连接。始终确保最小的表位于连接的右侧。这将在大多数连接算法中保留在内存中,并确保查询的内存开销最低。 -- 如果您的查询需要直接连接,例如 `LEFT ANY JOIN` - 如下所示,我们建议在可能的情况下使用 [字典](/dictionary)。 +- 对于最佳性能,用户应尽量减少查询中的 `JOIN` 数量,特别是在需要毫秒性能的实时分析工作负载中。一个查询的最大连接数应为 3 到 4 个。我们在 [数据建模部分](/data-modeling/schema-design) 中详细介绍了一些减少连接的变化,包括非规范化、字典和物化视图。 +- 目前,ClickHouse 不会重新排序连接。始终确保最小的表位于 JOIN 的右侧。这将被大多数连接算法保存在内存中,并确保查询的内存开销最低。 +- 如果您的查询需要直接连接,即 `LEFT ANY JOIN` - 如下所示,我们建议在可能的情况下使用 [字典](/dictionary)。 - + -- 如果执行内部连接,通常更优的做法是将其写为使用 `IN` 子句的子查询。考虑以下查询,它们在功能上是等价的。两个查询都找出问题中没有提到 ClickHouse 但在 `comments` 中提到的 `posts` 数量。 +- 如果执行内部连接,通常将其写为使用 `IN` 子句的子查询更为优化。考虑以下两个功能上等效的查询。两者都查找在问题中不提及 ClickHouse 但在 `comments` 中提及的 `posts` 数量。 ```sql SELECT count() @@ -38,9 +39,9 @@ WHERE (p.Title != '') AND (p.Title NOT ILIKE '%clickhouse%') AND (p.Body NOT ILI Peak memory usage: 1.23 GiB. ``` -请注意,我们使用 `ANY INNER JOIN` 而不是单纯的 `INNER` 连接,因为我们不想要笛卡尔积,即每个帖子只希望有一个匹配。 +请注意,我们使用 `ANY INNER JOIN` 而不是普通的 `INNER` 连接,因为我们不想要笛卡尔积,即我们希望每个帖子仅匹配一次。 -这个连接可以通过使用子查询来改写,显著提高性能: +此连接可以使用子查询重写,从而显著提高性能: ```sql SELECT count() @@ -58,9 +59,9 @@ WHERE (Title != '') AND (Title NOT ILIKE '%clickhouse%') AND (Body NOT ILIKE '%c Peak memory usage: 323.52 MiB. ``` -尽管 ClickHouse 尝试将条件下推到所有连接子句和子查询中,我们建议用户始终在可能的情况下手动将条件应用于所有子子句,从而最小化需要 `JOIN` 的数据大小。考虑以下示例,我们希望计算自 2020 年以来与 Java 相关的帖子获得的点赞数。 +尽管 ClickHouse 尝试将条件下推到所有连接子句和子查询中,我们仍然建议用户总是手动将条件应用于所有子子句,以尽量减少要 `JOIN` 的数据大小。考虑以下示例,我们希望计算自 2020 年以来与 Java 相关的帖子点赞数量。 -一个天真的查询,当较大的表在左侧时,完成时间为 56 秒: +一个朴素的查询,左侧是较大的表,完成时间为 56 秒: ```sql SELECT countIf(VoteTypeId = 2) AS upvotes @@ -75,7 +76,7 @@ WHERE has(arrayFilter(t -> (t != ''), splitByChar('|', p.Tags)), 'java') AND (p. 1 row in set. Elapsed: 56.642 sec. Processed 252.30 million rows, 1.62 GB (4.45 million rows/s., 28.60 MB/s.) ``` -重新排序此连接后,性能显著提升至 1.5 秒: +将此 JOIN 重新排序显著提高了性能,时间缩短至 1.5 秒: ```sql SELECT countIf(VoteTypeId = 2) AS upvotes @@ -90,7 +91,7 @@ WHERE has(arrayFilter(t -> (t != ''), splitByChar('|', p.Tags)), 'java') AND (p. 1 row in set. Elapsed: 1.519 sec. Processed 252.30 million rows, 1.62 GB (166.06 million rows/s., 1.07 GB/s.) ``` -在右侧表中添加过滤器将性能进一步提高到 0.5 秒。 +向左侧表添加过滤器使性能进一步提升至 0.5 秒。 ```sql SELECT countIf(VoteTypeId = 2) AS upvotes @@ -106,7 +107,7 @@ WHERE has(arrayFilter(t -> (t != ''), splitByChar('|', p.Tags)), 'java') AND (p. Peak memory usage: 249.42 MiB. ``` -通过将 `INNER JOIN` 移动到子查询中,此查询能够得到更大的提升,正如前面提到的,保持外部和内部查询的过滤器。 +如前所述,通过将 `INNER JOIN` 移动到子查询中,此查询可以进一步改进,同时保持外部和内部查询的过滤器。 ```sql SELECT count() AS upvotes @@ -125,19 +126,19 @@ WHERE (VoteTypeId = 2) AND (PostId IN ( Peak memory usage: 250.66 MiB. ``` -## 选择连接算法 {#choosing-a-join-algorithm} +## 选择 JOIN 算法 {#choosing-a-join-algorithm} -ClickHouse 支持多种 [连接算法](https://clickhouse.com/blog/clickhouse-fully-supports-joins-part1)。这些算法通常在性能和内存使用之间权衡。以下是基于相对内存消耗和执行时间的 ClickHouse 连接算法概述: +ClickHouse 支持多种 [连接算法](https://clickhouse.com/blog/clickhouse-fully-supports-joins-part1)。这些算法通常在性能和内存使用之间进行权衡。以下是基于 ClickHouse 连接算法的相对内存消耗和执行时间的概述:
- +
-这些算法决定了连接查询的规划和执行方式。默认情况下,ClickHouse 根据所使用的连接类型及连接表的严格性和引擎使用直接或哈希连接算法。或者,ClickHouse 可以配置为在运行时根据资源可用性和使用情况动态选择和更改连接算法:当 `join_algorithm=auto` 时,ClickHouse 首先尝试哈希连接算法,如果该算法的内存限制被违反,算法会动态切换为部分合并连接。您可以通过跟踪日志查看选择了哪个算法。ClickHouse 还允许用户通过 `join_algorithm` 设置来指定希望使用的连接算法。 +这些算法决定了连接查询的计划和执行方式。默认情况下,ClickHouse 根据所使用的连接类型、严格性和连接表的引擎使用直接或哈希连接算法。或者,ClickHouse 可以配置为在运行时根据资源可用性和使用情况自适应选择并动态更改要使用的连接算法:当 `join_algorithm=auto` 时,ClickHouse 首先尝试哈希连接算法,如果该算法的内存限制被违反,则算法会动态切换至部分合并连接。您可以通过跟踪日志观察选择了哪个算法。ClickHouse 还允许用户通过 `join_algorithm` 设置指定所需的连接算法。 -下表显示了每种连接算法支持的 `JOIN` 类型,并应在优化之前考虑: +下面显示了每种连接算法支持的 `JOIN` 类型,优化前应考虑这些类型:
@@ -147,11 +148,11 @@ ClickHouse 支持多种 [连接算法](https://clickhouse.com/blog/clickhouse-fu 每种 `JOIN` 算法的详细描述可以在 [这里](https://clickhouse.com/blog/clickhouse-fully-supports-joins-hash-joins-part2) 找到,包括它们的优缺点和扩展特性。 -选择合适的连接算法取决于您是想优化内存还是性能。 +选择合适的连接算法取决于您是希望优化内存还是性能。 ## 优化 JOIN 性能 {#optimizing-join-performance} -如果您的主要优化指标是性能,并希望尽快执行连接,您可以使用以下决策树来选择合适的连接算法: +如果您的关键优化指标是性能,并且希望尽快执行连接,可以使用以下决策树来选择合适的连接算法:
@@ -159,23 +160,23 @@ ClickHouse 支持多种 [连接算法](https://clickhouse.com/blog/clickhouse-fu
-- **(1)** 如果右侧表中的数据可以预先加载到一个内存中的低延迟键值数据结构中,例如一个字典,并且如果连接键与基础键值存储的键属性匹配,并且如果 `LEFT ANY JOIN` 语义足够的话 - 那么 **直接连接** 是适用的,并提供最快的方法。 +- **(1)** 如果来自右侧表的数据可以预加载到一个内存中低延迟的键值数据结构中,例如字典,并且连接键与底层键值存储的键属性匹配,如果 `LEFT ANY JOIN` 语义是足够的 - 则 **直接连接** 适用,并提供最快的方法。 -- **(2)** 如果表的 [物理行顺序](/guides/best-practices/sparse-primary-indexes#data-is-stored-on-disk-ordered-by-primary-key-columns) 与连接键排序顺序匹配,情况就要具体情况而定。在这种情况下,**全排序合并连接** [跳过](https://clickhouse.com/blog/clickhouse-fully-supports-joins-full-sort-partial-merge-part3#utilizing-physical-row-order) 排序阶段,从而显著降低内存使用,并且根据数据大小和连接键值分布,执行时间可能比某些哈希连接算法更快。 +- **(2)** 如果您表的 [物理行顺序](/guides/best-practices/sparse-primary-indexes#data-is-stored-on-disk-ordered-by-primary-key-columns) 与连接键排序顺序匹配,那么这要看情况。在这种情况下,**全排序合并连接** [跳过](https://clickhouse.com/blog/clickhouse-fully-supports-joins-full-sort-partial-merge-part3#utilizing-physical-row-order) 排序阶段,从而显著减少内存使用,加之根据数据大小和连接键值的分布,执行时间比某些哈希连接算法更快。 -- **(3)** 如果右侧表适合内存,即使考虑到 **并行哈希连接** 的 [额外内存使用开销](https://clickhouse.com/blog/clickhouse-fully-supports-joins-hash-joins-part2#summary),那么这个算法或哈希连接可能会更快。这取决于数据大小、数据类型和连接键列的值分布。 +- **(3)** 如果右侧表可以适应内存,即使有 [额外的内存使用开销](https://clickhouse.com/blog/clickhouse-fully-supports-joins-hash-joins-part2#summary) 的 **并行哈希连接**,那么此算法或哈希连接可能更快。这取决于数据大小、数据类型和连接键列的值分布。 -- **(4)** 如果右侧表不适合内存,那么情况又要具体情况而定。ClickHouse 提供三种非内存绑定的连接算法。所有这三种算法都会临时将数据溢出到磁盘。**全排序合并连接** 和 **部分合并连接** 需要对数据进行提前排序。而 **Grace 哈希连接** 是根据数据构建哈希表。根据数据的体量、数据类型和连接键列的值分布,构建哈希表可能比排序数据要快,反之亦然。 +- **(4)** 如果右侧表不能适应内存,则这又要看情况。ClickHouse 提供三种不依赖于内存的连接算法。所有这三种算法都暂时将数据溢出到磁盘。**全排序合并连接** 和 **部分合并连接** 需要对数据进行预排序。**Grace 哈希连接** 则从数据构建哈希表。根据数据量、数据类型和连接键列的值分布,某些情况下,从数据构建哈希表的速度可能快于对数据进行排序,反之亦然。 -部分合并连接旨在减少内存使用,但代价是连接速度相对较慢。当左表的物理行顺序不与连接键的排序顺序匹配时,尤其如此。 +部分合并连接在连接大表时优化了内存的使用,但牺牲了连接速度,因此速度相当慢。尤其是在左表的物理行顺序与连接键排序顺序不匹配时。 -Grace 哈希连接是三种非内存绑定连接算法中最灵活的一个,并提供了良好的内存使用与连接速度的控制,其 [grace_hash_join_initial_buckets](https://github.com/ClickHouse/ClickHouse/blob/23.5/src/Core/Settings.h#L759) 设置。根据数据量,Grace 哈希连接可能比部分合并算法速度更快或更慢,当选择的 [桶](https://clickhouse.com/blog/clickhouse-fully-supports-joins-hash-joins-part2#description-2) 数量使得这两种算法的内存使用基本对齐时。如果 Grace 哈希连接的内存使用配置约等于与全排序合并的内存使用量,则在我们的测试运行中,全排序合并连接的速度总是更快。 +Grace 哈希连接是三种不依赖于内存的连接算法中最灵活的,提供了良好的内存使用与连接速度的控制,其 [grace_hash_join_initial_buckets](https://github.com/ClickHouse/ClickHouse/blob/23.5/src/Core/Settings.h#L759) 设置。根据数据量,当选择的 [buckets](https://clickhouse.com/blog/clickhouse-fully-supports-joins-hash-joins-part2#description-2) 数量使得两种算法的内存使用大致对齐时,Grace 哈希可能比部分合并算法快或慢。当 Grace 哈希连接的内存使用配置得大致与全排序合并的内存使用对齐时,在我们的测试运行中,全排序合并总是更快。 -三种非内存绑定算法中哪一种最快取决于数据量、数据类型和连接键列的值分布。始终最好使用真实的数据量进行基准测试,以确定哪种算法是最快的。 +三种非内存约束算法中哪个算法最快取决于数据的数量、数据类型和连接键列的值分布。最好使用现实数据量的真实数据运行一些基准测试,以确定哪个算法是最快的。 -## 针对内存进行优化 {#optimizing-for-memory} +## 优化内存使用 {#optimizing-for-memory} -如果您希望优化连接以实现最低的内存使用,而不是最快的执行时间,那么您可以使用这个决策树: +如果您希望将连接优化为最低的内存使用,而不是最快的执行时间,则可以使用以下决策树:
@@ -183,7 +184,7 @@ Grace 哈希连接是三种非内存绑定连接算法中最灵活的一个,
-- **(1)** 如果您的表的物理行顺序与连接键排序顺序匹配,那么 **全排序合并连接** 的内存使用将降至最低。并且在排序阶段 [禁用](https://clickhouse.com/blog/clickhouse-fully-supports-joins-full-sort-partial-merge-part3#utilizing-physical-row-order) 的情况下,会有良好的连接速度。 -- **(2)** 可以通过 [配置](https://github.com/ClickHouse/ClickHouse/blob/23.5/src/Core/Settings.h#L759) 高数量的 [桶](https://clickhouse.com/blog/clickhouse-fully-supports-joins-hash-joins-part2#description-2) 来调优 **Grace 哈希连接** 以实现极低的内存使用,代价是连接速度。**部分合并连接** 刻意使用较少的主内存。启用外部排序的 **全排序合并连接** 通常会比部分合并连接使用更多的内存(假设行顺序不匹配键排序顺序),但在连接执行时间上具有显著的好处。 +- **(1)** 如果您的表的物理行顺序与连接键的排序顺序匹配,则 **全排序合并连接** 的内存使用是最低的。再加上良好的连接速度,因为排序阶段是 [禁用](https://clickhouse.com/blog/clickhouse-fully-supports-joins-full-sort-partial-merge-part3#utilizing-physical-row-order) 的。 +- **(2)** **Grace 哈希连接** 可以通过 [配置](https://github.com/ClickHouse/ClickHouse/blob/23.5/src/Core/Settings.h#L759) 高数量的 [buckets](https://clickhouse.com/blog/clickhouse-fully-supports-joins-hash-joins-part2#description-2) 来调优,以非常低的内存使用为代价。**部分合并连接** 有意使用较少的主内存。**全排序合并连接** 启用外部排序的情况下通常使用的内存比部分合并连接多(假设行顺序与键排序顺序不匹配),其好处是显著更好的连接执行时间。 -对于需要 above 内容更多详细信息的用户,我们推荐以下 [博客系列](https://clickhouse.com/blog/clickhouse-fully-supports-joins-part1)。 +对于需要更多详细信息的用户,我们推荐以下 [博客系列](https://clickhouse.com/blog/clickhouse-fully-supports-joins-part1)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/joining-tables.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/joining-tables.md.hash index ec15cb8661d..1d754b26d0a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/joining-tables.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/joining-tables.md.hash @@ -1 +1 @@ -528c61ff7a36b3a0 +6a4df61964d0f45a diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/manage-and-deploy-index.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/manage-and-deploy-index.md index b34ee25d27d..b62fcf9f7da 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/manage-and-deploy-index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/manage-and-deploy-index.md @@ -2,35 +2,36 @@ 'title': '管理和部署概述' 'description': '管理和部署的概述页面' 'slug': '/guides/manage-and-deploy-index' +'doc_type': 'landing-page' --- -# 管理与部署 +# 管理和部署 本节包含以下主题: -| 主题 | 描述 | -|-------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------| -| [部署与扩展](/deployment-guides/index) | 基于 ClickHouse 支持和服务组织提供给用户的建议的工作部署示例。 | -| [存储与计算的分离](/guides/separation-storage-compute) | 探索如何使用 ClickHouse 和 S3 实现存储与计算分离的架构的指南。 | -| [硬件和尺寸建议](/guides/sizing-and-hardware-recommendations) | 讨论针对开源用户的硬件、计算、内存和磁盘配置的一般建议的指南。 | -| [配置 ClickHouse Keeper](/guides/sre/keeper/clickhouse-keeper) | 如何配置 ClickHouse Keeper 的信息和示例。 | -| [网络端口](/guides/sre/network-ports) | ClickHouse 使用的网络端口列表。 | -| [重新平衡分片](/guides/sre/scaling-clusters) | 关于重新平衡分片的建议。 | -| [ClickHouse 是否支持多区域复制?](/faq/operations/multi-region-replication) | 关于多区域复制的常见问题解答。 | -| [在生产环境中使用哪个 ClickHouse 版本?](/faq/operations/production) | 关于用于生产的 ClickHouse 版本的常见问题解答。 | -| [集群发现](/operations/cluster-discovery) | ClickHouse 集群发现功能的信息和示例。 | -| [监控](/operations/monitoring) | 如何监控 ClickHouse 的硬件资源利用率和服务器指标的信息。 | -| [使用 OpenTelemetry 追踪 ClickHouse](/operations/opentelemetry) | 关于如何在 ClickHouse 中使用 OpenTelemetry 的信息。 | -| [配额](/operations/quotas) | 关于 ClickHouse 中配额的信息和示例。 | -| [与 Zookeeper 的安全通信](/operations/ssl-zookeeper) | 设置 ClickHouse 与 Zookeeper 之间安全通信的指南。 | -| [启动脚本](/operations/startup-scripts) | 在启动期间运行启动脚本的示例,对迁移或自动模式创建非常有用。 | -| [用于存储数据的外部磁盘](/operations/storing-data) | 配置 ClickHouse 的外部存储的信息和示例。 | -| [分配分析](/operations/allocation-profiling) | 使用 jemalloc 的分配采样和分析的信息和示例。 | -| [备份与恢复](/operations/backup) | 将数据备份到本地磁盘或外部存储的指南。 | -| [缓存](/operations/caches) | ClickHouse 中各种缓存类型的解释。 | -| [工作负载调度](/operations/workload-scheduling) | 关于 ClickHouse 中工作负载调度的解释。 | -| [自管理升级](/operations/update) | 进行自管理升级的指南。 | -| [故障排除](/guides/troubleshooting) | 各种故障排除技巧。 | -| [使用建议](/operations/tips) | 各种 ClickHouse 硬件和软件使用建议。 | -| [分布式 DDL](/sql-reference/distributed-ddl) | `ON CLUSTER` 子句的解释。 | +| 主题 | 描述 | +|-------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------| +| [部署和扩展](/deployment-guides/index) | 基于ClickHouse支持和服务组织提供给ClickHouse用户的建议的工作部署示例。 | +| [存储和计算的分离](/guides/separation-storage-compute) | 指南探讨如何使用ClickHouse和S3实现存储和计算分离的架构。 | +| [硬件和规模建议](/guides/sizing-and-hardware-recommendations) | 指南讨论开源用户在硬件、计算、内存和磁盘配置方面的一般建议。 | +| [配置ClickHouse Keeper](/guides/sre/keeper/clickhouse-keeper) | 关于如何配置ClickHouse Keeper的信息和示例。 | +| [网络端口](/guides/sre/network-ports) | ClickHouse使用的网络端口列表。 | +| [重平衡分片](/guides/sre/scaling-clusters) | 关于重平衡分片的建议。 | +| [ClickHouse支持多区域复制吗?](/faq/operations/multi-region-replication) | 关于多区域复制的常见问题解答。 | +| [在生产中使用哪个ClickHouse版本?](/faq/operations/production) | 关于生产使用ClickHouse版本的常见问题解答。 | +| [集群发现](/operations/cluster-discovery) | 关于ClickHouse的集群发现功能的信息和示例。 | +| [监控](/operations/monitoring) | 关于如何监控ClickHouse的硬件资源利用率和服务器指标的信息。 | +| [使用OpenTelemetry进行ClickHouse追踪](/operations/opentelemetry) | 关于如何将OpenTelemetry与ClickHouse一起使用的信息。 | +| [配额](/operations/quotas) | 关于ClickHouse中配额的信息和示例。 | +| [与Zookeeper的安全通信](/operations/ssl-zookeeper) | 设置ClickHouse与Zookeeper之间安全通信的指南。 | +| [启动脚本](/operations/startup-scripts) | 示例:如何在启动时运行启动脚本,适用于迁移或自动模式创建。 | +| [用于存储数据的外部磁盘](/operations/storing-data) | 关于如何配置ClickHouse的外部存储的信息和示例。 | +| [分配分析](/operations/allocation-profiling) | 有关使用jemalloc进行分配采样和分析的信息和示例。 | +| [备份和恢复](/operations/backup) | 将数据备份到本地磁盘或外部存储的指南。 | +| [缓存](/operations/caches) | 解释ClickHouse中各种缓存类型的信息。 | +| [工作负载调度](/operations/workload-scheduling) | 解释ClickHouse中的工作负载调度。 | +| [自管理升级](/operations/update) | 进行自管理升级的指南。 | +| [故障排除](/guides/troubleshooting) | 各种故障排除提示。 | +| [使用建议](/operations/tips) | 各种ClickHouse硬件和软件使用建议。 | +| [分布式DDL](/sql-reference/distributed-ddl) | 解释`ON CLUSTER`子句。 | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/manage-and-deploy-index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/manage-and-deploy-index.md.hash index 1dd168be811..7b15b0dbcb5 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/manage-and-deploy-index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/manage-and-deploy-index.md.hash @@ -1 +1 @@ -052e850e6a684abd +f367d36162d1e0d2 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/separation-storage-compute.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/separation-storage-compute.md index c63b969af49..826a3d259aa 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/separation-storage-compute.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/separation-storage-compute.md @@ -1,9 +1,10 @@ --- 'sidebar_position': 1 -'sidebar_label': '存储与计算的分离' +'sidebar_label': '存储与计算分离' 'slug': '/guides/separation-storage-compute' -'title': '存储与计算的分离' -'description': '本指南探讨如何使用 ClickHouse 和 S3 实现分离存储与计算的架构。' +'title': '存储与计算分离' +'description': '本指南探讨了如何使用 ClickHouse 和 S3 来实现具有分离存储和计算的架构。' +'doc_type': 'guide' --- import Image from '@theme/IdealImage'; @@ -17,23 +18,23 @@ import s3_bucket_example from '@site/static/images/guides/s3_bucket_example.png' 本指南探讨如何使用 ClickHouse 和 S3 实现存储与计算分离的架构。 -存储与计算的分离意味着计算资源和存储资源是独立管理的。在 ClickHouse 中,这可以实现更好的可扩展性、成本效益和灵活性。您可以根据需要独立扩展存储和计算资源,从而优化性能和成本。 +存储与计算的分离意味着计算资源和存储资源是独立管理的。在 ClickHouse 中,这允许更好的可扩展性、成本效率和灵活性。您可以根据需要独立扩展存储和计算资源,从而优化性能和成本。 -使用 ClickHouse 和 S3 非常适合那些对“冷”数据的查询性能要求不高的用例。ClickHouse 支持使用 S3 作为 `MergeTree` 引擎的存储,通过 `S3BackedMergeTree`。这个表引擎使用户能够在保持 `MergeTree` 引擎的插入和查询性能的同时,利用 S3 的可扩展性和成本优势。 +对于对 "冷" 数据的查询性能要求较低的用例,使用 S3 支持的 ClickHouse 特别有用。ClickHouse 支持使用 S3 作为 `MergeTree` 引擎的存储,采用 `S3BackedMergeTree`。此表引擎使用户能够充分利用 S3 的可扩展性和成本优势,同时保持 `MergeTree` 引擎的插入和查询性能。 -请注意,实现和管理存储与计算分离的架构比标准的 ClickHouse 部署要复杂得多。虽然自管理的 ClickHouse 允许如本指南所述的存储和计算分离,我们建议您使用 [ClickHouse Cloud](https://clickhouse.com/cloud),它允许您在此架构中使用 ClickHouse,而无需进行配置,使用 [`SharedMergeTree` 表引擎](/cloud/reference/shared-merge-tree)。 +请注意,与标准 ClickHouse 部署相比,实现和管理存储与计算的分离架构要复杂得多。虽然自管理的 ClickHouse 如本指南所述允许存储与计算的分离,但我们建议使用 [ClickHouse Cloud](https://clickhouse.com/cloud),使您可以在此架构中使用 ClickHouse 而无需配置,使用 [`SharedMergeTree` 表引擎](/cloud/reference/shared-merge-tree)。 *本指南假设您使用的是 ClickHouse 版本 22.8 或更高版本。* :::warning -请勿配置任何 AWS/GCS 生命周期策略。这不受支持,可能导致表损坏。 +请勿配置任何 AWS/GCS 生命周期策略。这不受支持,并可能导致表损坏。 ::: -## 1. 将 S3 用作 ClickHouse 磁盘 {#1-use-s3-as-a-clickhouse-disk} +## 1. 将 S3 作为 ClickHouse 磁盘使用 {#1-use-s3-as-a-clickhouse-disk} ### 创建磁盘 {#creating-a-disk} -在 ClickHouse 的 `config.d` 目录中创建一个新文件,以存储存储配置: +在 ClickHouse 的 `config.d` 目录中创建一个新文件以存储存储配置: ```bash vim /etc/clickhouse-server/config.d/storage_config.xml @@ -72,15 +73,15 @@ vim /etc/clickhouse-server/config.d/storage_config.xml ``` -如果您需要进一步指定 S3 磁盘的设置,例如指定 `region` 或发送自定义 HTTP `header`,您可以在 [这里](/engines/table-engines/mergetree-family/mergetree.md/#table_engine-mergetree-s3) 找到相关设置的列表。 +如果您需要进一步指定 S3 磁盘的设置,例如指定 `region` 或发送自定义 HTTP `header`,您可以在此处找到相关设置的列表 [here](/engines/table-engines/mergetree-family/mergetree.md/#table_engine-mergetree-s3)。 -您还可以将 `access_key_id` 和 `secret_access_key` 替换为以下内容,这将尝试从环境变量和 Amazon EC2 元数据中获取凭证: +您还可以用以下内容替换 `access_key_id` 和 `secret_access_key`,这将尝试从环境变量和 Amazon EC2 元数据获取凭证: ```bash true ``` -创建配置文件后,您需要将文件的所有者更新为 clickhouse 用户和组: +创建配置文件后,您需要将文件的所有权更新为 clickhouse 用户和组: ```bash chown clickhouse:clickhouse /etc/clickhouse-server/config.d/storage_config.xml @@ -92,11 +93,11 @@ chown clickhouse:clickhouse /etc/clickhouse-server/config.d/storage_config.xml service clickhouse-server restart ``` -## 2. 创建由 S3 支持的表 {#2-create-a-table-backed-by-s3} +## 2. 创建一个基于 S3 的表 {#2-create-a-table-backed-by-s3} 为了测试我们是否正确配置了 S3 磁盘,我们可以尝试创建并查询一个表。 -创建一个指定新的 S3 存储策略的表: +创建一个指定新 S3 存储策略的表: ```sql CREATE TABLE my_s3_table @@ -109,9 +110,9 @@ ORDER BY id SETTINGS storage_policy = 's3_main'; ``` -请注意,我们不需要将引擎指定为 `S3BackedMergeTree`。如果 ClickHouse 检测到表使用 S3 进行存储,它会自动在内部转换引擎类型。 +请注意,我们不需要将引擎指定为 `S3BackedMergeTree`。如果 ClickHouse 检测到该表使用 S3 进行存储,它会自动在内部转换引擎类型。 -显示表已使用正确策略创建: +显示该表已使用正确策略创建: ```sql SHOW CREATE TABLE my_s3_table; @@ -139,7 +140,7 @@ INSERT INTO my_s3_table (id, column1) VALUES (1, 'abc'), (2, 'xyz'); ``` -让我们验证我们的行已插入: +让我们验证我们的行是否已插入: ```sql SELECT * FROM my_s3_table; @@ -154,24 +155,24 @@ SELECT * FROM my_s3_table; 2 rows in set. Elapsed: 0.284 sec. ``` -在 AWS 控制台中,如果您的数据已成功插入 S3,您应该会看到 ClickHouse 在您指定的存储桶中创建了新文件。 +在 AWS 控制台中,如果您的数据已成功插入到 S3,您应该看到 ClickHouse 在您指定的存储桶中创建了新文件。 -如果一切顺利,您现在正在使用存储与计算分离的 ClickHouse! +如果一切顺利,您现在正在使用 ClickHouse 进行存储与计算的分离! - + -## 3. 实现故障容错的复制(可选) {#3-implementing-replication-for-fault-tolerance-optional} +## 3. 实现容错的复制(可选) {#3-implementing-replication-for-fault-tolerance-optional} :::warning -请勿配置任何 AWS/GCS 生命周期策略。这不受支持,可能导致表损坏。 +请勿配置任何 AWS/GCS 生命周期策略。这不受支持,并可能导致表损坏。 ::: -为了实现故障容错,您可以使用多个分布在多个 AWS 区域的 ClickHouse 服务器节点,每个节点都有一个 S3 存储桶。 +为了实现容错,您可以使用分散在多个 AWS 区域的多个 ClickHouse 服务器节点,每个节点都有一个 S3 存储桶。 -使用 S3 磁盘的复制可以通过使用 `ReplicatedMergeTree` 表引擎来实现。有关详细信息,请参阅以下指南: -- [在两个 AWS 区域之间复制单个分片,使用 S3 对象存储](/integrations/s3#s3-multi-region)。 +可以通过使用 `ReplicatedMergeTree` 表引擎来实现 S3 磁盘的复制。有关详细信息,请参阅以下指南: +- [使用 S3 对象存储在两个 AWS 区域之间复制单个分片](/integrations/s3#s3-multi-region)。 ## 进一步阅读 {#further-reading} - [SharedMergeTree 表引擎](/cloud/reference/shared-merge-tree) -- [SharedMergeTree 公告博客](https://clickhouse.com/blog/clickhouse-cloud-boosts-performance-with-sharedmergetree-and-lightweight-updates) +- [SharedMergeTree公告博客](https://clickhouse.com/blog/clickhouse-cloud-boosts-performance-with-sharedmergetree-and-lightweight-updates) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/separation-storage-compute.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/separation-storage-compute.md.hash index 01a2a1351a9..ac5b00eb095 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/separation-storage-compute.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/separation-storage-compute.md.hash @@ -1 +1 @@ -3988606d7e30b6b1 +4572544d2ae7c34e diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/sre/configuring-ssl.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/sre/configuring-ssl.md index c2be6996a63..6683586301a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/sre/configuring-ssl.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/sre/configuring-ssl.md @@ -3,7 +3,8 @@ 'sidebar_label': '配置 SSL-TLS' 'sidebar_position': 20 'title': '配置 SSL-TLS' -'description': '本指南提供简单且最小的设置,以配置 ClickHouse 使用 OpenSSL 证书来验证连接。' +'description': '本指南提供简单和最小的设置以配置 ClickHouse 使用 OpenSSL 证书来验证连接。' +'doc_type': 'guide' --- import SelfManaged from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_self_managed_only_automated.md'; @@ -11,21 +12,22 @@ import configuringSsl01 from '@site/static/images/guides/sre/configuring-ssl_01. import Image from '@theme/IdealImage'; + # 配置 SSL-TLS -本指南提供了简单且最小的设置以配置 ClickHouse 使用 OpenSSL 证书来验证连接。为了演示,创建了自签名的证书颁发机构 (CA) 证书和密钥,并使用节点证书以适当的设置进行连接。 +本指南提供简单 minimal 的设置,以配置 ClickHouse 使用 OpenSSL 证书来验证连接。为了本演示,创建了自签名的证书颁发机构 (CA) 证书和密钥,以及节点证书,以便进行适当设置的连接。 :::note -TLS 实现是复杂的,有许多选项需要考虑,以确保完全安全和稳健的部署。这是一个基础教程,包含基本的 SSL/TLS 配置示例。请咨询你的 PKI/安全团队,以为你的组织生成正确的证书。 +TLS 实现非常复杂,有很多选项需要考虑,以确保完全安全和稳健的部署。这是一个基础教程,包含基本的 SSL/TLS 配置示例。请与您的 PKI/安全团队协作,生成适合您组织的正确证书。 -请查看此 [关于证书使用的基础教程](https://ubuntu.com/server/docs/security-certificates) 以获得简介概述。 +查看这个 [关于证书使用的基础教程](https://ubuntu.com/server/docs/security-certificates) 获取入门概述。 ::: ## 1. 创建 ClickHouse 部署 {#1-create-a-clickhouse-deployment} -本指南是基于在以下主机上使用 DEB 包(通过 apt)安装的 Ubuntu 20.04 和 ClickHouse 编写的。域名为 `marsnet.local`: +本指南是基于 Ubuntu 20.04 和在以下主机上使用 DEB 包(通过 apt)安装的 ClickHouse 编写的。域名为 `marsnet.local`: |主机 |IP 地址| |--------|-------------| @@ -33,15 +35,13 @@ TLS 实现是复杂的,有许多选项需要考虑,以确保完全安全和 |`chnode2` |192.168.1.222| |`chnode3` |192.168.1.223| - :::note -请查看 [快速入门](/getting-started/install/install.mdx) 获取有关如何安装 ClickHouse 的更多详情。 +查看 [快速入门](/getting-started/install/install.mdx) 获取更多关于如何安装 ClickHouse 的详细信息。 ::: - ## 2. 创建 SSL 证书 {#2-create-ssl-certificates} :::note -使用自签名证书仅用于演示目的,不能用于生产环境。证书请求应该创建以由组织签名,并通过将配置中的 CA 链进行验证。然而,这些步骤可以用于配置和测试设置,然后可以使用实际将要使用的证书替换。 +使用自签名证书仅为演示目的,不应在生产中使用。应创建证书请求,由组织签名并使用将在设置中配置的 CA 链验证。然而,这些步骤可用于配置和测试设置,然后可以由将要使用的实际证书替换。 ::: 1. 生成一个将用于新 CA 的密钥: @@ -49,13 +49,13 @@ TLS 实现是复杂的,有许多选项需要考虑,以确保完全安全和 openssl genrsa -out marsnet_ca.key 2048 ``` -2. 生成一个新的自签名 CA 证书。以下命令将创建一个新的证书,用于使用 CA 密钥对其他证书进行签名: +2. 生成一个新的自签名 CA 证书。以下将创建一个新证书,用于使用 CA 密钥签署其他证书: ```bash openssl req -x509 -subj "/CN=marsnet.local CA" -nodes -key marsnet_ca.key -days 1095 -out marsnet_ca.crt ``` :::note - 将密钥和 CA 证书备份到集群外的安全位置。在生成节点证书后,应从集群节点中删除密钥。 + 在集群之外的安全位置备份密钥和 CA 证书。生成节点证书后,应从集群节点中删除密钥。 ::: 3. 验证新 CA 证书的内容: @@ -77,7 +77,7 @@ openssl x509 -req -in chnode2.csr -out chnode2.crt -CA marsnet_ca.crt -CAkey mar openssl x509 -req -in chnode3.csr -out chnode3.crt -CA marsnet_ca.crt -CAkey marsnet_ca.key -days 365 -copy_extensions copy ``` -6. 验证证书的主题和颁发者: +6. 验证证书的主题和发行者: ```bash openssl x509 -in chnode1.crt -text -noout ``` @@ -88,20 +88,20 @@ openssl verify -CAfile marsnet_ca.crt chnode1.crt chnode1.crt: OK ``` -## 3. 创建并配置用于存储证书和密钥的目录。 {#3-create-and-configure-a-directory-to-store-certificates-and-keys} +## 3. 创建并配置一个目录以存储证书和密钥。 {#3-create-and-configure-a-directory-to-store-certificates-and-keys} :::note -这必须在每个节点上完成。请在每个主机上使用适当的证书和密钥。 +这必须在每个节点上完成。确保在每个主机上使用适当的证书和密钥。 ::: -1. 在每个节点中创建一个可被 ClickHouse 访问的目录中的文件夹。我们建议使用默认配置目录(例如 `/etc/clickhouse-server`): +1. 在每个节点上创建一个 ClickHouse 可访问的目录中的文件夹。我们建议使用默认配置目录(例如 `/etc/clickhouse-server`): ```bash mkdir /etc/clickhouse-server/certs ``` -2. 将 CA 证书、节点证书和对应于每个节点的密钥复制到新证书目录。 +2. 将 CA 证书、节点证书和相应节点的密钥复制到新的证书目录中。 -3. 更新所有权和权限,以允许 ClickHouse 读取证书: +3. 更新所有者和权限,以允许 ClickHouse 读取证书: ```bash chown clickhouse:clickhouse -R /etc/clickhouse-server/certs chmod 600 /etc/clickhouse-server/certs/* @@ -120,20 +120,19 @@ drwx------ 5 clickhouse clickhouse 4096 Apr 12 20:23 ../ ## 4. 使用 ClickHouse Keeper 配置基本集群的环境 {#4-configure-the-environment-with-basic-clusters-using-clickhouse-keeper} -对于此部署环境,每个节点使用以下 ClickHouse Keeper 设置。每个服务器将拥有自己的 ``。 (例如,`chnode1` 的 `1`,依此类推。) +对于此部署环境,每个节点使用以下 ClickHouse Keeper 设置。每个服务器将有其自己的 ``。 (例如,`1` 代表节点 `chnode1`,依此类推。) :::note -推荐的端口是 ClickHouse Keeper 的 `9281`。然而,该端口是可以配置的,如果该端口已被环境中的其他应用程序使用,则可以设置其他端口。 +推荐的端口为 `9281` 用于 ClickHouse Keeper。但是,此端口是可配置的,如果该端口已经被环境中的其他应用程序使用,可以设置其他端口。 有关所有选项的完整说明,请访问 https://clickhouse.com/docs/operations/clickhouse-keeper/ ::: - -1. 在 ClickHouse 服务器的 `config.xml` 中的 `` 标签内添加以下内容: +1. 在 ClickHouse 服务器 `config.xml` 中的 `` 标签内添加以下内容: :::note 对于生产环境,建议在 `config.d` 目录中使用单独的 `.xml` 配置文件。 - 有关更多信息,请访问 https://clickhouse.com/docs/operations/configuration-files/ + 获取更多信息,请访问 https://clickhouse.com/docs/operations/configuration-files/ ::: ```xml @@ -170,7 +169,7 @@ drwx------ 5 clickhouse clickhouse 4096 Apr 12 20:23 ../ ``` -2. 在所有节点上取消注释并更新 keeper 设置,并将 `` 标志设置为 1: +2. 取消注释并更新所有节点上的 Keeper 设置,并将 `` 标志设置为 1: ```xml @@ -191,13 +190,13 @@ drwx------ 5 clickhouse clickhouse 4096 Apr 12 20:23 ../ ``` -3. 更新并将以下集群设置添加到 `chnode1` 和 `chnode2`。 `chnode3` 将用于 ClickHouse Keeper 仲裁。 +3. 更新并添加以下集群设置到 `chnode1` 和 `chnode2`。`chnode3` 将用于 ClickHouse Keeper 的法定人数。 :::note - 对于此配置,仅配置了一个示例集群。测试样本集群必须被删除、注释掉,或者如果存在正在测试的现有集群,则必须更新端口并添加 `` 选项。如果在安装或 `users.xml` 文件中最初配置了 `default` 用户具有密码,则必须设置 `` 和 ``。 + 对于此配置,仅配置了一个示例集群。测试样本集群必须被删除、注释掉,或者如果存在正在测试的现有集群,则必须更新端口并添加 `` 选项。如果在安装或 `users.xml` 文件中初始配置 `default` 用户设置了密码,则必须设置 `` 和 ``。 ::: - 下面的命令在两个服务器(每个节点一个)上创建了一个带有一个分片副本的集群。 + 以下创建一个在两个服务器(每个节点各一个)上具有一个分片副本的集群。 ```xml @@ -221,7 +220,7 @@ drwx------ 5 clickhouse clickhouse 4096 Apr 12 20:23 ../ ``` -4. 定义宏值以能够创建用于测试的 ReplicatedMergeTree 表。在 `chnode1` 上: +4. 定义宏值,以便能够创建一个用于测试的 ReplicatedMergeTree 表。在 `chnode1` 上: ```xml 1 @@ -238,9 +237,9 @@ drwx------ 5 clickhouse clickhouse 4096 Apr 12 20:23 ../ ``` ## 5. 在 ClickHouse 节点上配置 SSL-TLS 接口 {#5-configure-ssl-tls-interfaces-on-clickhouse-nodes} -以下设置在 ClickHouse 服务器的 `config.xml` 中配置 +以下设置在 ClickHouse 服务器 `config.xml` 中配置 -1. 设定部署的显示名称(可选): +1. 设置部署的显示名称(可选): ```xml clickhouse ``` @@ -256,23 +255,23 @@ drwx------ 5 clickhouse clickhouse 4096 Apr 12 20:23 ../ ``` -4. 在每个节点上配置 ClickHouse Native 安全 TCP 端口,并禁用默认的不安全端口: +4. 在每个节点上配置 ClickHouse 原生安全 TCP 端口并禁用默认的非安全端口: ```xml 9440 ``` -5. 在每个节点上配置 `interserver https` 端口,并禁用默认的不安全端口: +5. 在每个节点上配置 `interserver https` 端口并禁用默认的非安全端口: ```xml 9010 ``` -6. 使用证书和路径配置 OpenSSL +6. 配置 OpenSSL 与证书和路径 :::note 每个文件名和路径必须更新为与正在配置的节点匹配。 - 例如,在配置 `chnode2` 主机时,更新 `` 条目为 `chnode2.crt`。 + 例如,在配置 `chnode2` 主机时,更新 `` 项为 `chnode2.crt`。 ::: ```xml @@ -300,10 +299,9 @@ drwx------ 5 clickhouse clickhouse 4096 Apr 12 20:23 ../ ``` - 有关更多信息,请访问 https://clickhouse.com/docs/operations/server-configuration-parameters/settings/#server_configuration_parameters-openssl - + 获取更多信息,请访问 https://clickhouse.com/docs/operations/server-configuration-parameters/settings/#server_configuration_parameters-openssl -7. 为每个节点配置 gRPC 以使用 SSL: +7. 为每个节点配置 gRPC 以进行 SSL: ```xml 1 @@ -319,9 +317,9 @@ drwx------ 5 clickhouse clickhouse 4096 Apr 12 20:23 ../ ``` - 有关更多信息,请访问 https://clickhouse.com/docs/interfaces/grpc/ + 获取更多信息,请访问 https://clickhouse.com/docs/interfaces/grpc/ -8. 在至少一个节点上配置 ClickHouse 客户端,以便在其自己的 `config.xml` 文件中使用 SSL 进行连接(默认在 `/etc/clickhouse-client/` 中): +8. 配置 ClickHouse 客户端在至少一个节点中使用 SSL 进行连接,配置在其自己的 `config.xml` 文件中(默认在 `/etc/clickhouse-client/`): ```xml @@ -344,12 +342,12 @@ drwx------ 5 clickhouse clickhouse 4096 Apr 12 20:23 ../ ``` ## 6. 测试 {#6-testing} -1. 逐个启动所有节点: +1. 按顺序启动所有节点: ```bash service clickhouse-server start ``` -2. 验证安全端口是否已启动并在监听,应该在每个节点上类似于以下示例: +2. 验证安全端口是否处于活动状态并正确监听,每个节点应类似于以下示例: ```bash root@chnode1:/etc/clickhouse-server# netstat -ano | grep tcp ``` @@ -380,9 +378,9 @@ tcp6 0 0 192.168.1.221:9444 192.168.1.223:41976 ESTABLISHED |9440 | 安全 Native TCP 协议| |9444 | ClickHouse Keeper Raft 端口 | -3. 验证 ClickHouse Keeper 健康 -典型的 [4 字母命令 (4lW)](/guides/sre/keeper/index.md#four-letter-word-commands) 命令在没有 TLS 的情况下使用 `echo` 无法工作,以下是如何在 `openssl` 会话中使用这些命令。 - - 使用 `openssl` 启动一个交互式会话 +3. 验证 ClickHouse Keeper 的健康状态 +典型的 [4 字母词 (4lW)](/guides/sre/keeper/index.md#four-letter-word-commands) 命令在没有 TLS 的情况下使用 `echo` 将无法工作,这里是如何在 `openssl` 会话中使用这些命令。 + - 使用 `openssl` 启动交互式会话 ```bash openssl s_client -connect chnode1.marsnet.local:9281 @@ -406,7 +404,7 @@ MIICtDCCAZwCFD321grxU3G5pf6hjitf2u7vkusYMA0GCSqGSIb3DQEBCwUAMBsx ... ``` - - 在 openssl 会话中发送 4LW 命令 +- 在 openssl 会话中发送 4LW 命令 ```bash mntr @@ -456,16 +454,16 @@ Connected to ClickHouse server version 22.3.3 revision 54455. clickhouse :) ``` -5. 使用 `https` 接口登录 Play UI,地址为 `https://chnode1.marsnet.local:8443/play`。 +5. 使用 `https` 接口登录到 Play UI,地址为 `https://chnode1.marsnet.local:8443/play`。 - + :::note - 浏览器将显示一个不受信的证书,因为它是从工作站访问的,并且证书不在客户端计算机的根 CA 存储中。 - 当使用公共权威或企业 CA 颁发的证书时,应该显示为受信任。 + 由于它是从工作站访问的,因此浏览器将显示一个不受信任的证书,并且证书不在客户端机器的根 CA 存储中。 + 使用公共机构或企业 CA 发布的证书时,应该显示为受信任。 ::: -6. 创建一个副本表: +6. 创建一个复制表: ```sql clickhouse :) CREATE TABLE repl_table ON CLUSTER cluster_1S_2R ( @@ -493,7 +491,7 @@ VALUES (2,'2022-04-02','def'); ``` -8. 通过查看 `chnode2` 上的行来验证复制: +8. 通过在 `chnode2` 上查看行来验证复制: ```sql SELECT * FROM repl_table ``` @@ -507,4 +505,4 @@ SELECT * FROM repl_table ## 总结 {#summary} -本文重点介绍了如何配置带有 SSL/TLS 的 ClickHouse 环境。在生产环境中,设置将因不同的需求而有所不同;例如,证书验证级别、协议、密码等。 但你现在应该对配置和实施安全连接所涉及的步骤有了良好的理解。 +本文重点介绍了如何配置 ClickHouse 环境以使用 SSL/TLS。生产环境中的设置将根据不同的要求而有所不同;例如,证书验证级别、协议、密码等。但您现在应该对配置和实施安全连接所涉及的步骤有了清晰的理解。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/sre/configuring-ssl.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/sre/configuring-ssl.md.hash index a105b6df38d..05ae514489b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/sre/configuring-ssl.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/sre/configuring-ssl.md.hash @@ -1 +1 @@ -1ae8066e8563a918 +a67a8e5f2ad77a0d diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/sre/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/sre/index.md index 357cf6d1f40..2675295baae 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/sre/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/sre/index.md @@ -1,10 +1,11 @@ --- 'slug': '/security-and-authentication' -'title': '安全与认证' -'description': '安全与认证的着陆页' +'title': '安全性和认证' +'description': '安全性和认证的登陆页面' +'doc_type': 'landing-page' --- -| 页面 | 描述 | -|------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------| -| [用户与角色](/operations/access-rights) | 了解更多关于 ClickHouse 如何基于 RBAC 方法支持访问控制管理的内容。 | -| [外部身份验证器](/operations/external-authenticators) | 了解更多关于 OSS ClickHouse 如何使用外部服务支持用户身份验证和管理的内容。 | +| 页面 | 描述 | +|------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------| +| [用户与角色](/operations/access-rights) | 了解更多关于 ClickHouse 如何支持基于 RBAC 方法的访问控制管理。 | +| [外部身份验证器](/operations/external-authenticators) | 了解更多关于 OSS ClickHouse 如何使用外部服务进行用户身份验证和管理。 | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/sre/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/sre/index.md.hash index 99f9631cd5d..f1978a6268c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/sre/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/sre/index.md.hash @@ -1 +1 @@ -613c1892f3fb58ef +8e88d383e47e80f4 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/sre/keeper/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/sre/keeper/index.md index 1d7cb727c2e..25551cfb450 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/sre/keeper/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/sre/keeper/index.md @@ -6,8 +6,9 @@ - 'Keeper' - 'ZooKeeper' - 'clickhouse-keeper' -'description': 'ClickHouse Keeper,或 clickhouse-keeper,替代 ZooKeeper,提供复制和协调。' +'description': 'ClickHouse Keeper,或称为 clickhouse-keeper,替代了 ZooKeeper 并提供复制和协调。' 'title': 'ClickHouse Keeper' +'doc_type': 'guide' --- import SelfManaged from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_self_managed_only_automated.md'; @@ -17,100 +18,99 @@ import SelfManaged from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_s -ClickHouse Keeper 提供数据 [复制](/engines/table-engines/mergetree-family/replication.md) 和 [分布式 DDL](/sql-reference/distributed-ddl.md) 查询执行的协调系统。 ClickHouse Keeper 与 ZooKeeper 兼容。 +ClickHouse Keeper 提供了用于数据 [复制](/engines/table-engines/mergetree-family/replication.md) 和 [分布式 DDL](/sql-reference/distributed-ddl.md) 查询执行的协调系统。ClickHouse Keeper 兼容 ZooKeeper。 ### 实现细节 {#implementation-details} -ZooKeeper 是第一个著名的开源协调系统之一。它用 Java 实现,具有简单而强大的数据模型。ZooKeeper 的协调算法,即 ZooKeeper 原子广播(ZAB),不提供读取的线性化保证,因为每个 ZooKeeper 节点都是本地服务读取。与 ZooKeeper 不同,ClickHouse Keeper 是用 C++ 编写的,并使用 [RAFT 算法](https://raft.github.io/) [实现](https://github.com/eBay/NuRaft)。此算法允许读取和写入的线性化,并有多种语言的开源实现。 +ZooKeeper 是第一个广为人知的开源协调系统之一。它是用 Java 实现的,并具有相对简单而强大的数据模型。ZooKeeper 的协调算法,ZooKeeper Atomic Broadcast (ZAB),不提供读取的线性化保证,因为每个 ZooKeeper 节点在本地处理读取。与 ZooKeeper 不同,ClickHouse Keeper 是用 C++ 编写的,并使用 [RAFT 算法](https://raft.github.io/) [实现](https://github.com/eBay/NuRaft)。该算法允许读取和写入的线性化,并在不同语言中有几种开源实现。 -默认情况下,ClickHouse Keeper 提供与 ZooKeeper 相同的保证:可线性化的写入和不可线性化的读取。它有一个兼容的客户端-服务器协议,因此可以使用任何标准的 ZooKeeper 客户端与 ClickHouse Keeper 进行交互。快照和日志的格式与 ZooKeeper 不兼容,但 `clickhouse-keeper-converter` 工具可以将 ZooKeeper 数据转换为 ClickHouse Keeper 快照。ClickHouse Keeper 中的服务器间协议也与 ZooKeeper 不兼容,因此不可能建立混合的 ZooKeeper / ClickHouse Keeper 集群。 +默认情况下,ClickHouse Keeper 提供与 ZooKeeper 相同的保证:线性化写入和非线性化读取。它具有兼容的客户端-服务器协议,因此可以使用任何标准的 ZooKeeper 客户端与 ClickHouse Keeper 进行交互。快照和日志与 ZooKeeper 的格式不兼容,但 `clickhouse-keeper-converter` 工具可以实现将 ZooKeeper 数据转换为 ClickHouse Keeper 快照。ClickHouse Keeper 中的服务器间协议也与 ZooKeeper 不兼容,因此混合的 ZooKeeper / ClickHouse Keeper 集群是不可能的。 -ClickHouse Keeper 支持与 [ZooKeeper](https://zookeeper.apache.org/doc/r3.1.2/zookeeperProgrammers.html#sc_ZooKeeperAccessControl) 相同的访问控制列表(ACL)。ClickHouse Keeper 支持相同的权限集,具有相同的内置方案:`world`,`auth` 和 `digest`。摘要身份验证方案使用配对 `username:password`,密码以 Base64 编码。 +ClickHouse Keeper 支持与 [ZooKeeper](https://zookeeper.apache.org/doc/r3.1.2/zookeeperProgrammers.html#sc_ZooKeeperAccessControl) 一样的访问控制列表 (ACL)。ClickHouse Keeper 支持相同的权限集,并具有相同的内置方案:`world`、`auth` 和 `digest`。消化身份验证方案使用 `username:password` 的配对,密码以 Base64 编码。 :::note 不支持外部集成。 ::: ### 配置 {#configuration} -ClickHouse Keeper 可以作为 ZooKeeper 的独立替代品使用,也可以作为 ClickHouse 服务器的内部部分。在这两种情况下,配置几乎是相同的 `.xml` 文件。 +ClickHouse Keeper 可以作为 ZooKeeper 的独立替代品使用,也可以作为 ClickHouse 服务器的内部部分。在这两种情况下,配置几乎都是相同的 `.xml` 文件。 #### Keeper 配置设置 {#keeper-configuration-settings} -主要的 ClickHouse Keeper 配置标签是 ``,具有以下参数: - -| 参数 | 描述 | 默认值 | -|-------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------| -| `tcp_port` | 客户端连接的端口。 | `2181` | -| `tcp_port_secure` | 客户端与 keeper-server 之间 SSL 连接的安全端口。 | - | -| `server_id` | 唯一服务器 ID,ClickHouse Keeper 群集中的每个参与者必须具有唯一的数字(1,2,3,依此类推)。 | - | -| `log_storage_path` | 协调日志的路径,就像 ZooKeeper 一样,最好在不忙的节点上存储日志。 | - | -| `snapshot_storage_path` | 协调快照的路径。 | - | -| `enable_reconfiguration` | 启用通过 [`reconfig`](#reconfiguration) 动态重新配置群集。 | `False` | -| `max_memory_usage_soft_limit` | Keeper 最大内存使用的软限制(字节)。 | `max_memory_usage_soft_limit_ratio` * `physical_memory_amount` | -| `max_memory_usage_soft_limit_ratio` | 如果未设置 `max_memory_usage_soft_limit` 或设置为零,则使用此值来定义默认软限制。 | `0.9` | -| `cgroups_memory_observer_wait_time` | 如果未设置或设置为 `0` ,则使用此时间间隔观察物理内存的数量。一旦内存量发生变化,我们将通过 `max_memory_usage_soft_limit_ratio` 重新计算 Keeper 的内存软限制。 | `15` | -| `http_control` | [HTTP 控制](#http-control) 接口的配置。 | - | -| `digest_enabled` | 启用实时数据一致性检查 | `True` | -| `create_snapshot_on_exit` | 在关闭时创建快照 | - | -| `hostname_checks_enabled` | 启用群集配置的主机名有效性检查(例如,是否使用 localhost 与远程端点) | `True` | -| `four_letter_word_white_list` | 4lw 命令的白名单。 | `conf, cons, crst, envi, ruok, srst, srvr, stat, wchs, dirs, mntr, isro, rcvr, apiv, csnp, lgif, rqld, ydld` | - - -其他常见参数继承自 ClickHouse 服务器配置(`listen_host`,`logger` 等)。 +主要的 ClickHouse Keeper 配置标签是 ``,并具有以下参数: + +| 参数 | 描述 | 默认值 | +|--------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------| +| `tcp_port` | 客户端连接的端口。 | `2181` | +| `tcp_port_secure` | 客户端与 keeper-server 之间 SSL 连接的安全端口。 | - | +| `server_id` | 唯一的服务器 ID,ClickHouse Keeper 集群的每个参与者必须有一个唯一的数字 (1, 2, 3 等)。 | - | +| `log_storage_path` | 协调日志的路径,与 ZooKeeper 一样,最好将日志存储在不忙的节点上。 | - | +| `snapshot_storage_path` | 协调快照的路径。 | - | +| `enable_reconfiguration` | 通过 [`reconfig`](#reconfiguration) 启用动态集群重新配置。 | `False` | +| `max_memory_usage_soft_limit` | Keeper 最大内存使用的软限制(以字节为单位)。 | `max_memory_usage_soft_limit_ratio` * `physical_memory_amount` | +| `max_memory_usage_soft_limit_ratio` | 如果未设置或设置为零,则使用此值定义默认软限制。 | `0.9` | +| `cgroups_memory_observer_wait_time` | 如果未设置 `max_memory_usage_soft_limit` 或设置为 `0`,则使用此间隔观察物理内存的数量。一旦内存数量发生变化,我们将按 `max_memory_usage_soft_limit_ratio` 重新计算 Keeper 的内存软限制。 | `15` | +| `http_control` | [HTTP 控制](#http-control) 接口的配置。 | - | +| `digest_enabled` | 启用实时数据一致性检查。 | `True` | +| `create_snapshot_on_exit` | 在关闭时创建快照。 | - | +| `hostname_checks_enabled` | 启用集群配置的主机名检查的合理性(例如,使用了远程端点的情况下 localhost)。 | `True` | +| `four_letter_word_white_list` | 4lw 命令的白名单。 | `conf, cons, crst, envi, ruok, srst, srvr, stat, wchs, dirs, mntr, isro, rcvr, apiv, csnp, lgif, rqld, ydld` | +| `enable_ipv6` | 启用 IPv6 | `True` | + +其他公共参数从 ClickHouse 服务器配置中继承(`listen_host`、`logger` 等)。 #### 内部协调设置 {#internal-coordination-settings} 内部协调设置位于 `.` 部分,并具有以下参数: -| 参数 | 描述 | 默认值 | -|-------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------| -| `operation_timeout_ms` | 单个客户端操作的超时(毫秒) | `10000` | -| `min_session_timeout_ms` | 客户端会话的最小超时(毫秒) | `10000` | -| `session_timeout_ms` | 客户端会话的最大超时(毫秒) | `100000` | -| `dead_session_check_period_ms` | ClickHouse Keeper 检查死会话并将其删除的频率(毫秒) | `500` | -| `heart_beat_interval_ms` | ClickHouse Keeper 领导者向跟随者发送心跳的频率(毫秒) | `500` | -| `election_timeout_lower_bound_ms` | 如果跟随者在此时间间隔内未收到来自领导者的心跳,则可以发起领导者选举。必须小于或等于 `election_timeout_upper_bound_ms`。理想情况下它们不应相等。 | `1000` | -| `election_timeout_upper_bound_ms` | 如果跟随者在此时间间隔内未收到来自领导者的心跳,则必须发起领导者选举。 | `2000` | -| `rotate_log_storage_interval` | 在单个文件中存储多少条日志记录。 | `100000` | -| `reserved_log_items` | 在压缩之前要存储多少条协调日志记录。 | `100000` | -| `snapshot_distance` | ClickHouse Keeper 将多长时间创建新快照(以日志中的记录数计算)。 | `100000` | -| `snapshots_to_keep` | 要保留多少个快照。 | `3` | -| `stale_log_gap` | 领导者认为跟随者过时的阈值,并向其发送快照而不是日志。 | `10000` | -| `fresh_log_gap` | 节点变得新鲜的时间。 | `200` | -| `max_requests_batch_size` | 在发送给 RAFT 之前请求批处理的最大大小(请求计数)。 | `100` | -| `force_sync` | 在每次写入协调日志时调用 `fsync`。 | `true` | -| `quorum_reads` | 通过整个 RAFT 共识以类似速度执行读取请求作为写入。 | `false` | -| `raft_logs_level` | 有关协调的文本日志级别(trace,debug 等)。 | `system default` | -| `auto_forwarding` | 允许将跟随者的写入请求转发给领导者。 | `true` | -| `shutdown_timeout` | 等待完成内部连接并关闭(毫秒)。 | `5000` | -| `startup_timeout` | 如果服务器未在指定超时内连接到其他法定成员,则将终止(毫秒)。 | `30000` | -| `async_replication` | 启用异步复制。在实现更好的性能的同时保留所有写入和读取保证。该设置默认禁用,以避免破坏向后兼容性。 | `false` | -| `latest_logs_cache_size_threshold` | 最新日志条目内存中缓存的最大总大小 | `1GiB` | -| `commit_logs_cache_size_threshold` | 下一个提交所需的日志条目内存中缓存的最大总大小 | `500MiB` | -| `disk_move_retries_wait_ms` | 在文件在磁盘之间移动时发生故障后,等待重试之间的等待时间 | `1000` | -| `disk_move_retries_during_init` | 在初始化过程中在文件在磁盘之间移动时发生故障后的重试次数 | `100` | -| `experimental_use_rocksdb` | 使用 rocksdb 作为后端存储 | `0` | - -法定配置位于 `.` 部分,其中包含服务器描述。 - -整个法定的唯一参数是 `secure`,该参数启用法定成员之间通信的加密连接。如果需要在节点之间进行内部通信的 SSL 连接,则将参数设置为 `true`,否则可以不指定。 - -每个 `` 的主要参数为: +| 参数 | 描述 | 默认值 | +|----------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------| +| `operation_timeout_ms` | 单个客户端操作的超时(毫秒)。 | `10000` | +| `min_session_timeout_ms` | 客户端会话的最小超时(毫秒)。 | `10000` | +| `session_timeout_ms` | 客户端会话的最大超时(毫秒)。 | `100000` | +| `dead_session_check_period_ms` | ClickHouse Keeper 检查死会话并将其移除的频率(毫秒)。 | `500` | +| `heart_beat_interval_ms` | ClickHouse Keeper 领导者向跟随者发送心跳的频率(毫秒)。 | `500` | +| `election_timeout_lower_bound_ms` | 如果跟随者在此间隔内没有收到来自领导者的心跳,则可以发起领导者选举。必须小于或等于 `election_timeout_upper_bound_ms`。理想情况下它们不应相等。 | `1000` | +| `election_timeout_upper_bound_ms` | 如果跟随者在此间隔内没有收到来自领导者的心跳,则必须发起领导者选举。 | `2000` | +| `rotate_log_storage_interval` | 单个文件中要存储的日志记录数量。 | `100000` | +| `reserved_log_items` | 在压缩之前要存储的协调日志记录数量。 | `100000` | +| `snapshot_distance` | ClickHouse Keeper 创建新快照的频率(以日志中的记录数量为单位)。 | `100000` | +| `snapshots_to_keep` | 要保留的快照数量。 | `3` | +| `stale_log_gap` | 领导者认为跟随者陈旧的阈值,并向其发送快照而不是日志。 | `10000` | +| `fresh_log_gap` | 节点变得新鲜的时候。 | `200` | +| `max_requests_batch_size` | 在发送到 RAFT 之前请求计数的最大批大小。 | `100` | +| `force_sync` | 在每次写入协调日志时调用 `fsync`。 | `true` | +| `quorum_reads` | 通过整个 RAFT 共识以类似速度执行读取请求作为写入。 | `false` | +| `raft_logs_level` | 有关协调的文本记录级别(跟踪、调试等)。 | `system default` | +| `auto_forwarding` | 允许将写请求从跟随者转发到领导者。 | `true` | +| `shutdown_timeout` | 等待完成内部连接并关闭(毫秒)。 | `5000` | +| `startup_timeout` | 如果服务器在指定超时内未连接到其他法定参与者,它将终止(毫秒)。 | `30000` | +| `async_replication` | 启用异步复制。在实现更好性能的同时,所有写入和读取保证都得以保留。默认为禁用设置,以避免破坏向后兼容性。 | `false` | +| `latest_logs_cache_size_threshold` | 最新日志条目的内存缓存的最大总大小。 | `1GiB` | +| `commit_logs_cache_size_threshold` | 需要提交流的日志条目的内存缓存的最大总大小。 | `500MiB` | +| `disk_move_retries_wait_ms` | 在文件在磁盘之间移动时发生故障后重试之间等待多久。 | `1000` | +| `disk_move_retries_during_init` | 初始化期间在文件在磁盘之间移动时发生故障后重试的数量。 | `100` | +| `experimental_use_rocksdb` | 使用 rocksdb 作为后端存储。 | `0` | + +法定配置位于`.` 部分并包含服务器描述。 + +整个法定的唯一参数是 `secure`,它启用法定参与者之间通信的加密连接。如果需要对节点之间的内部通信进行 SSL 连接,则该参数可以设置为 `true`,否则可以不指定。 + +每个 `` 的主要参数是: - `id` — 法定中的服务器标识符。 -- `hostname` — 该服务器所在的主机名。 -- `port` — 该服务器侦听连接的端口。 -- `can_become_leader` — 设置为 `false` 将服务器设置为 `learner`。如果省略,则值为 `true`。 +- `hostname` — 此服务器的主机名。 +- `port` — 此服务器监听连接的端口。 +- `can_become_leader` — 设置为 `false` 将服务器设置为 `learner`。如果省略,则默认为 `true`。 :::note -在更改 ClickHouse Keeper 集群的拓扑时(例如,替换服务器),请确保保持 `server_id` 与 `hostname` 的映射一致,并避免为不同的服务器重新排列或重用现有 `server_id`(例如,如果您依赖于自动化脚本来部署 ClickHouse Keeper,可能会发生这种情况)。 +在更改 ClickHouse Keeper 集群的拓扑结构(例如,替换服务器)时,请确保保持 `server_id` 到 `hostname` 的映射一致,并避免对不同服务器打乱或重用现有的 `server_id`(例如,如果依赖自动化脚本来部署 ClickHouse Keeper,可能会发生这种情况)。 -如果 Keeper 实例的主机可以更改,建议定义和使用主机名,而不是原始 IP 地址。更改主机名等同于移除和重新添加服务器,这在某些情况下可能无法做到(例如,对于法定没有足够的 Keeper 实例)。 +如果 Keeper 实例的主机可能会更改,建议定义并使用主机名,而不是原始 IP 地址。更改主机名等同于移除并重新添加该服务器,这在某些情况下可能无法做到(例如,法定实例不足)。 ::: :::note -`async_replication` 默认情况下被禁用,以避免破坏向后兼容性。如果您在群集中运行的所有 Keeper 实例都是支持 `async_replication` 的版本(v23.9+),我们建议启用它,因为它可以在没有任何缺点的情况下提高性能。 +`async_replication` 默认情况下被禁用,以避免破坏向后兼容性。如果您的所有 Keeper 实例都运行支持 `async_replication` 的版本(v23.9+),建议您启用它,因为它可以在没有任何缺点的情况下提高性能。 ::: - -包含三个节点的法定配置示例可在 [集成测试](https://github.com/ClickHouse/ClickHouse/tree/master/tests/integration) 中找到,前缀为 `test_keeper_`。服务器 #1 的示例配置: +三个节点法定的配置示例可以在 [集成测试](https://github.com/ClickHouse/ClickHouse/tree/master/tests/integration) 中找到,前缀为 `test_keeper_`。以下是服务器 #1 的示例配置: ```xml @@ -146,24 +146,24 @@ ClickHouse Keeper 可以作为 ZooKeeper 的独立替代品使用,也可以作 ``` ### 如何运行 {#how-to-run} -ClickHouse Keeper 包含在 ClickHouse 服务器包中,只需将 `` 的配置添加到 `/etc/your_path_to_config/clickhouse-server/config.xml` 中,然后像往常一样启动 ClickHouse 服务器。如果您想单独运行 ClickHouse Keeper,可以以类似方式启动它: +ClickHouse Keeper 打包在 ClickHouse 服务器包中,只需将 `` 的配置添加到您的 `/etc/your_path_to_config/clickhouse-server/config.xml` 中,然后像往常一样启动 ClickHouse 服务器。如果您想单独运行 ClickHouse Keeper,可以以类似方式启动: ```bash clickhouse-keeper --config /etc/your_path_to_config/config.xml ``` -如果您没有符号链接(`clickhouse-keeper`),可以创建它或将 `keeper` 作为参数指定给 `clickhouse`: +如果您没有符号链接 (`clickhouse-keeper`),可以创建它或在 `clickhouse` 中指定 `keeper` 作为参数: ```bash clickhouse keeper --config /etc/your_path_to_config/config.xml ``` -### 四字母命令 {#four-letter-word-commands} +### 四字命令 {#four-letter-word-commands} -ClickHouse Keeper 还提供 4lw 命令,这些命令与 Zookeeper 几乎相同。每个命令由四个字母组成,例如 `mntr`,`stat` 等。有一些更有趣的命令:`stat` 提供有关服务器和连接客户端的一些一般信息,而 `srvr` 和 `cons` 分别提供有关服务器和连接的详细信息。 +ClickHouse Keeper 还提供了与 ZooKeeper 几乎相同的 4lw 命令。每个命令由四个字母组成,如 `mntr`、`stat` 等。有一些更有趣的命令:`stat` 提供关于服务器和连接的客户端的一些一般信息,而 `srvr` 和 `cons` 分别提供关于服务器和连接的详细信息。 4lw 命令有一个白名单配置 `four_letter_word_white_list`,其默认值为 `conf,cons,crst,envi,ruok,srst,srvr,stat,wchs,dirs,mntr,isro,rcvr,apiv,csnp,lgif,rqld,ydld`。 -您可以通过 telnet 或 nc 在客户端端口向 ClickHouse Keeper 发出命令。 +您可以通过 telnet 或 nc 在客户端端口向 ClickHouse Keeper 发送命令。 ```bash echo mntr | nc localhost 9181 @@ -171,13 +171,13 @@ echo mntr | nc localhost 9181 以下是详细的 4lw 命令: -- `ruok`:测试服务器是否处于非错误状态。如果服务器正在运行,将响应 `imok`。否则,将根本不响应。响应 `imok` 并不一定表示服务器已加入法定,只表示服务器进程处于活动状态并绑定到指定的客户端端口。使用 "stat" 获取有关法定和客户端连接信息的状态详细信息。 +- `ruok`:测试服务器是否在非错误状态下运行。如果正在运行,服务器将响应 `imok`。否则,它将根本不响应。响应 `imok` 并不一定表示服务器已加入法定,只表示服务器进程处于活动状态并绑定到指定的客户端端口。使用 "stat" 获取关于法定和客户端连接信息的状态详细信息。 ```response imok ``` -- `mntr`:输出可用于监控集群健康状况的变量列表。 +- `mntr`:输出一系列可以用于监测集群健康的变量。 ```response zk_version v21.11.1.1-prestable-7a4a0b0edef0ad6e0aa662cd3b90c3f4acf796e7 @@ -213,7 +213,7 @@ Mode: leader Node count: 4 ``` -- `stat`:列出服务器和连接客户端的简要详细信息。 +- `stat`:列出服务器和连接的客户端的简要详细信息。 ```response ClickHouse Keeper version: v21.11.1.1-prestable-7a4a0b0edef0ad6e0aa662cd3b90c3f4acf796e7 @@ -230,13 +230,13 @@ Mode: leader Node count: 4 ``` -- `srst`:重置服务器统计信息。该命令将影响 `srvr`,`mntr` 和 `stat` 的结果。 +- `srst`:重置服务器统计信息。该命令将影响 `srvr`、`mntr` 和 `stat` 的结果。 ```response Server stats reset. ``` -- `conf`:打印有关服务配置的详细信息。 +- `conf`:打印关于服务配置的详细信息。 ```response server_id=1 @@ -269,7 +269,7 @@ compress_snapshots_with_zstd_format=true configuration_change_tries_count=20 ``` -- `cons`:列出所有连接到该服务器的客户端的完整连接/会话详细信息。包括接收/发送的数据包数量、会话 ID、操作延迟、上次执行的操作等信息... +- `cons`:列出所有连接到此服务器的客户端的完整连接/会话详细信息,包括收到/发送的数据包数量、会话 ID、操作延迟、最后执行的操作等信息。 ```response 192.168.1.1:52163(recved=0,sent=0,sid=0xffffffffffffffff,lop=NA,est=1636454787393,to=30000,lzxid=0xffffffffffffffff,lresp=0,llat=0,minlat=0,avglat=0,maxlat=0) @@ -282,7 +282,7 @@ configuration_change_tries_count=20 Connection stats reset. ``` -- `envi`:打印有关服务环境的详细信息 +- `envi`:打印关于服务环境的详细信息。 ```response Environment: @@ -298,42 +298,41 @@ user.dir=/Users/JackyWoo/project/jd/clickhouse/cmake-build-debug/programs/ user.tmp=/var/folders/b4/smbq5mfj7578f2jzwn602tt40000gn/T/ ``` - -- `dirs`:显示快照和日志文件的总大小(以字节为单位) +- `dirs`:显示快照和日志文件的总大小(以字节为单位)。 ```response snapshot_dir_size: 0 log_dir_size: 3875 ``` -- `isro`:测试服务器是否以只读模式运行。如果在只读模式下,服务器将响应 `ro`;如果未处于只读模式,则响应 `rw`。 +- `isro`:测试服务器是否在只读模式下运行。如果处于只读模式,则服务器将响应 `ro`,如果不处于只读模式,则响应 `rw`。 ```response rw ``` -- `wchs`:列出服务器的监视信息的简要信息。 +- `wchs`:列出服务器的监视的简要信息。 ```response 1 connections watching 1 paths Total watches:1 ``` -- `wchc`:按会话列出服务器的监视详细信息。输出与关联监视路径(路径)的会话(连接)列表。注意,根据监视的数量,可能会很昂贵(影响服务器性能),请谨慎使用。 +- `wchc`:按会话列出服务器的监视的详细信息。这输出与相关监视(路径)关联的会话(连接)的列表。请注意,根据监视的数量,此操作可能是昂贵的(影响服务器性能),请谨慎使用。 ```response 0x0000000000000001 /clickhouse/task_queue/ddl ``` -- `wchp`:按路径列出服务器的监视详细信息。输出与关联会话的路径(znodes)列表。注意,根据监视的数量,可能会很昂贵(即影响服务器性能),请谨慎使用。 +- `wchp`:按路径列出服务器的监视的详细信息。这输出与相关会话关联的路径(znodes)的列表。请注意,根据监视的数量,此操作可能是昂贵的(即,对服务器性能产生影响),请谨慎使用。 ```response /clickhouse/task_queue/ddl 0x0000000000000001 ``` -- `dump`:列出未完成的会话和临时节点。此操作仅适用于领导者。 +- `dump`:列出未完成的会话和临时节点。这仅在领导者上有效。 ```response Sessions dump (2): @@ -344,13 +343,13 @@ Sessions with Ephemerals (1): /clickhouse/task_queue/ddl ``` -- `csnp`:调度快照创建任务。如果调度的快照成功,将返回最后提交的日志索引;如果失败,则返回 `Failed to schedule snapshot creation task.`。请注意,`lgif` 命令可以帮助您确定快照是否完成。 +- `csnp`:安排创建快照任务。如果成功,则返回已调度快照的最后提交日志索引。如果失败,则返回 `Failed to schedule snapshot creation task.` 请注意,`lgif` 命令可以帮助您确定快照是否完成。 ```response 100 ``` -- `lgif`:Keeper 日志信息。`first_log_idx` : 我在日志存储中的第一个日志索引;`first_log_term` : 我在日志中的第一个日志任期;`last_log_idx` : 我在日志存储中的最后一个日志索引;`last_log_term` : 我的最后一个日志任期;`last_committed_log_idx` : 我在状态机中最后提交的日志索引;`leader_committed_log_idx` : 从我的角度看,领导者提交的日志索引;`target_committed_log_idx` : 应提交的目标日志索引;`last_snapshot_idx` : 最近快照中的最大已提交日志索引。 +- `lgif`:Keeper 日志信息。 `first_log_idx` : 我在日志存储中的第一个日志索引; `first_log_term` : 我的第一个日志任期; `last_log_idx` : 我在日志存储中的最后一个日志索引; `last_log_term` : 我的最后一个日志任期; `last_committed_log_idx` : 我在状态机中的最后提交日志索引; `leader_committed_log_idx` : 从我的角度来看,领导者提交的日志索引; `target_committed_log_idx` : 应该提交到的目标日志索引; `last_snapshot_idx` : 在最后快照中最大提交的日志索引。 ```response first_log_idx 1 @@ -363,7 +362,7 @@ target_committed_log_idx 101 last_snapshot_idx 50 ``` -- `rqld`:请求成为新的领导者。如果请求已发送,将返回 `Sent leadership request to leader.`,如果请求未发送,将返回 `Failed to send leadership request to leader.`。请注意,如果节点已经是领导者,结果与请求相同。 +- `rqld`:请求成为新领导者。如果请求已发送,返回 `Sent leadership request to leader.`,如果请求未发送,返回 `Failed to send leadership request to leader.` 请注意,如果节点已经是领导者,则结果与请求发送相同。 ```response Sent leadership request to leader. @@ -377,7 +376,7 @@ multi_read 1 check_not_exists 0 ``` -- `ydld`:请求放弃领导权并成为跟随者。如果接收请求的服务器是领导者,它将首先暂停写入操作,等待后继者(当前领导者绝不能是后继者)完成对最新日志的赶超,然后辞职。后继者将被自动选择。如果请求发送,将返回 `Sent yield leadership request to leader.`,如果请求未发送,将返回 `Failed to send yield leadership request to leader.`。请注意,如果节点已经是跟随者,结果与请求相同。 +- `ydld`:请求放弃领导权并成为跟随者。如果接收请求的服务器是领导者,它将首先暂停写操作,等待后继者(当前领导者永远不能是后继者)完成最新日志的补追,然后辞职。后继者将自动选择。如果请求已发送,返回 `Sent yield leadership request to leader.`,如果请求未发送,返回 `Failed to send yield leadership request to leader.` 请注意,如果节点已经是跟随者,则结果与请求发送相同。 ```response Sent yield leadership request to leader. @@ -407,7 +406,7 @@ AIOWriteBytes 0 Number of bytes written with Linux or FreeBSD AIO interf ``` ### HTTP 控制 {#http-control} -ClickHouse Keeper 提供 HTTP 接口以检查副本是否准备好接收流量。它可用于云环境,例如 [Kubernetes](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#define-readiness-probes)。 +ClickHouse Keeper 提供 HTTP 接口以检查副本是否准备好接收流量。这可以在云环境中使用,例如 [Kubernetes](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#define-readiness-probes)。 启用 `/ready` 端点的配置示例: @@ -425,10 +424,10 @@ ClickHouse Keeper 提供 HTTP 接口以检查副本是否准备好接收流量 ``` ### 功能标志 {#feature-flags} -Keeper 完全兼容 ZooKeeper 及其客户端,但它还引入了一些唯一的功能和请求类型,可供 ClickHouse 客户端使用。 -由于这些功能可能会引入向后不兼容的更改,因此默认情况下大多数功能都处于禁用状态,可以通过 `keeper_server.feature_flags` 配置启用。 -所有功能都可以显式禁用。 -如果要为 Keeper 群集启用新功能,建议首先将群集中所有 Keeper 实例更新为支持该功能的版本,然后再启用该功能。 +Keeper 完全与 ZooKeeper 及其客户端兼容,但还引入了一些可供 ClickHouse 客户端使用的独特功能和请求类型。 +由于这些功能可能会引入向后不兼容的更改,因此大多数功能默认情况下被禁用,并可以使用 `keeper_server.feature_flags` 配置启用。 +可以明确禁用所有功能。 +如果您想为 Keeper 集群启用新功能,建议您首先将集群中的所有 Keeper 实例更新为支持该功能的版本,然后再启用该功能。 禁用 `multi_read` 和启用 `check_not_exists` 的功能标志配置示例: @@ -445,18 +444,25 @@ Keeper 完全兼容 ZooKeeper 及其客户端,但它还引入了一些唯一 以下功能可用: -- `multi_read` - 支持读取多个请求。默认值:`1` -- `filtered_list` - 支持按节点类型(临时或持久)过滤结果的列表请求。默认值:`1` -- `check_not_exists` - 支持 `CheckNotExists` 请求,断言节点不存在。默认值:`0` -- `create_if_not_exists` - 支持 `CreateIfNotExists` 请求,如果节点不存在则尝试创建。如果存在,则不应用任何更改,并返回 `ZOK`。默认值:`0` -- `remove_recursive` - 支持 `RemoveRecursive` 请求,删除该节点及其子树。默认值:`0` +| 功能 | 描述 | 默认值 | +|--------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------|-------| +| `multi_read` | 对多读取请求的支持 | `1` | +| `filtered_list` | 对按节点类型(临时或持久性)过滤结果的列表请求的支持 | `1` | +| `check_not_exists` | 支持 `CheckNotExists` 请求,该请求断言节点不存在 | `1` | +| `create_if_not_exists` | 支持 `CreateIfNotExists` 请求,如果节点不存在,它将尝试创建节点。如果存在,则不进行更改并返回 `ZOK` | `1` | +| `remove_recursive` | 支持 `RemoveRecursive` 请求,该请求将删除节点及其子树 | `1` | + +:::note +某些功能标志从版本 25.7 开始默认启用。 +将 Keeper 升级到 25.7+ 的推荐方式是首先升级到 24.9+ 版本。 +::: ### 从 ZooKeeper 迁移 {#migration-from-zookeeper} -从 ZooKeeper 无缝迁移到 ClickHouse Keeper 是不可能的。您必须停止 ZooKeeper 群集,转换数据,然后启动 ClickHouse Keeper。 `clickhouse-keeper-converter` 工具可将 ZooKeeper 日志和快照转换为 ClickHouse Keeper 快照。它仅适用于 ZooKeeper > 3.4。迁移步骤: +无缝迁移从 ZooKeeper 到 ClickHouse Keeper 是不可能的。您必须停止您的 ZooKeeper 集群,转换数据,然后启动 ClickHouse Keeper。 `clickhouse-keeper-converter` 工具允许将 ZooKeeper 日志和快照转换为 ClickHouse Keeper 快照。它仅支持 ZooKeeper > 3.4。迁移步骤: 1. 停止所有 ZooKeeper 节点。 -2. 可选,但建议:找到 ZooKeeper 领导节点,启动并停止它。这将强制 ZooKeeper 创建一致的快照。 +2. 可选,但建议执行:找到 ZooKeeper 领导节点,重新启动它。这将强制 ZooKeeper 创建一致的快照。 3. 在领导节点上运行 `clickhouse-keeper-converter`,例如: @@ -464,45 +470,46 @@ Keeper 完全兼容 ZooKeeper 及其客户端,但它还引入了一些唯一 clickhouse-keeper-converter --zookeeper-logs-dir /var/lib/zookeeper/version-2 --zookeeper-snapshots-dir /var/lib/zookeeper/version-2 --output-dir /path/to/clickhouse/keeper/snapshots ``` -4. 将快照复制到配置了 `keeper` 的 ClickHouse 服务器节点或启动 ClickHouse Keeper 代替 ZooKeeper。快照必须在所有节点上持久存在,否则空节点可能更快,其中一个可能成为领导者。 +4. 将快照复制到配置了 `keeper` 的 ClickHouse 服务器节点,或在 ZooKeeper 的地方启动 ClickHouse Keeper。快照必须在所有节点上持久存在,否则空节点可能会更快,并且其中一个可以成为领导者。 :::note -`keeper-converter` 工具在 Keeper 独立二进制文件中不可用。 +`keeper-converter` 工具在 Keeper 独立二进制版本中不可用。 如果您已安装 ClickHouse,可以直接使用该二进制文件: ```bash clickhouse keeper-converter ... ``` -否则,您可以 [下载二进制文件](/getting-started/quick-start#download-the-binary) 并按照上述描述运行该工具,而无需安装 ClickHouse。 +否则,您可以[下载二进制文件](/getting-started/quick-start/oss#download-the-binary)并按上述方式运行该工具,而无需安装 ClickHouse。 ::: -### 恢复失去的法定人数 {#recovering-after-losing-quorum} +### 在失去法定人数后恢复 {#recovering-after-losing-quorum} -由于 ClickHouse Keeper 使用 Raft,它可以容忍一定数量的节点崩溃,具体取决于集群的大小。 \ -例如,对于一个 3 节点集群,如果只有 1 个节点崩溃,它将继续正常工作。 +由于 ClickHouse Keeper 使用 Raft,它可以容忍一定数量的节点崩溃,具体取决于集群大小。\ +例如,对于 3 节点集群,如果仅 1 个节点崩溃,它将继续正常工作。 -集群配置可以动态配置,但存在一些限制。重新配置同样依赖于 Raft,因此要添加/移除节点,您需要拥有法定人数。如果您同时失去了集群中的太多节点,且没有任何机会重新启动它们,Raft 将停止工作,并不允许您以常规方式重新配置集群。 +集群配置可以动态配置,但有一些限制。重新配置也依赖于 Raft,因此要从集群中添加/移除节点,您需要拥有法定人数。如果您的集群中同时失去的节点过多,并且没有机会重新启动它们,Raft 将停止工作,并不允许您以常规方式重新配置集群。 -然而,ClickHouse Keeper 具有恢复模式,允许您仅使用 1 个节点强制重新配置集群。只有在您无法再次启动节点或在同一端点上启动新实例时,这种操作才应作为最后的手段进行。 +尽管如此,ClickHouse Keeper 具有恢复模式,可以强制您以仅 1 个节点重新配置集群。 +这应该仅作为最后的手段,如果您无法再次启动节点,或在同一端点上启动新实例。 -继续之前要注意的重要事项: +在继续之前需要注意的重要事项: - 确保失败的节点无法再次连接到集群。 -- 在步骤规定之前,请勿启动任何新节点。 +- 在步骤中指定之前,请不要启动任何新节点。 -确保上述事项为真后,您需要执行以下操作: -1. 选择一个 Keeper 节点作为新的领导者。请注意,该节点的数据将用于整个集群,因此建议使用状态最新的节点。 -2. 在做其他任何事情之前,备份所选节点的 `log_storage_path` 和 `snapshot_storage_path` 文件夹。 -3. 在您想要使用的所有节点上重新配置集群。 -4. 向您选择的节点发送四字母命令 `rcvr`,这将使该节点进入恢复模式,或者停止所选节点上的 Keeper 实例,然后使用 `--force-recovery` 参数重新启动它。 -5. 一一启动新节点上的 Keeper 实例,确保在启动下一个实例之前,`mntr` 对 `zk_server_state` 返回 `follower`。 -6. 在恢复模式下,领导者节点将对 `mntr` 命令返回错误消息,直到它与新节点达成法定人数为止,并拒绝来自客户端和跟随者的任何请求。 -7. 达成法定人数后,领导者节点将恢复正常操作模式,接受所有请求并通过 Raft 验证,`mntr` 应该对 `zk_server_state` 返回 `leader`。 +确保上述事项属实后,您需要执行以下操作: +1. 选择一个 Keeper 节点作为新的领导者。要注意的是,该节点的数据将用于整个集群,因此建议使用状态最新的节点。 +2. 在执行其他任何操作之前,备份所选节点的 `log_storage_path` 和 `snapshot_storage_path` 文件夹。 +3. 在您想使用的所有节点上重新配置集群。 +4. 向所选节点发送四个字母的命令 `rcvr`,这将使节点进入恢复模式,或者在所选节点上停止 Keeper 实例并使用 `--force-recovery` 参数再次启动。 +5. 一个接一个地启动新节点上的 Keeper 实例,确保在启动下一个节点之前,`mntr` 对 `zk_server_state` 返回 `follower`。 +6. 处于恢复模式时,领导节点将返回 `mntr` 命令的错误消息,直到它与新节点达成法定人数,并拒绝来自客户端和跟随者的任何请求。 +7. 达成法定人数后,领导节点将恢复到正常的操作模式,接受所有请求,并使用 Raft 进行验证,`mntr` 应返回 `leader`,对于 `zk_server_state`。 -## 使用 Keeper 的磁盘 {#using-disks-with-keeper} +## 与 Keeper 一起使用磁盘 {#using-disks-with-keeper} Keeper 支持一部分 [外部磁盘](/operations/storing-data.md) 用于存储快照、日志文件和状态文件。 -支持的磁盘类型有: +支持的磁盘类型包括: - s3_plain - s3 - local @@ -544,22 +551,22 @@ Keeper 支持一部分 [外部磁盘](/operations/storing-data.md) 用于存储 ``` -要为日志使用磁盘,`keeper_server.log_storage_disk` 配置应设置为磁盘名称。 -要为快照使用磁盘,`keeper_server.snapshot_storage_disk` 配置应设置为磁盘名称。 -此外,可以通过使用 `keeper_server.latest_log_storage_disk` 和 `keeper_server.latest_snapshot_storage_disk` 分别为最新日志或快照使用不同的磁盘。 +要将磁盘用于日志,`keeper_server.log_storage_disk` 配置应该设置为磁盘的名称。 +要将磁盘用于快照,`keeper_server.snapshot_storage_disk` 配置应该设置为磁盘的名称。 +此外,可以使用 `keeper_server.latest_log_storage_disk` 和 `keeper_server.latest_snapshot_storage_disk` 分别为最新日志或快照使用不同的磁盘。 在这种情况下,Keeper 会在创建新日志或快照时自动将文件移动到正确的磁盘。 -要为状态文件使用磁盘,`keeper_server.state_storage_disk` 配置应设置为磁盘名称。 +要将磁盘用于状态文件,`keeper_server.state_storage_disk` 配置应该设置为磁盘的名称。 -在磁盘之间移动文件是安全的,如果 Keeper 在传输中停止,数据不会丢失。 +在磁盘之间移动文件是安全的,如果 Keeper 在传输中途停止,数据没有丢失的风险。 在文件完全移动到新磁盘之前,它不会从旧磁盘中删除。 -将 `keeper_server.coordination_settings.force_sync` 设置为 `true`(默认值为 `true`)的 Keeper 无法满足所有类型磁盘的一些保证。 -目前,只有类型为 `local` 的磁盘支持持久同步。 -如果使用 `force_sync`,`log_storage_disk` 应该是一个 `local` 磁盘,前提是未使用 `latest_log_storage_disk`。 -如果使用 `latest_log_storage_disk`,它应该始终是一个 `local` 磁盘。 -如果禁用 `force_sync`,所有类型的磁盘可以在任何设置中使用。 +将 `keeper_server.coordination_settings.force_sync` 设置为 `true`(默认值为 `true`)的 Keeper 不能满足所有类型磁盘的一些保证。 +目前,只有 `local` 类型的磁盘支持持久同步。 +如果使用 `force_sync`,则如果未使用 `latest_log_storage_disk`,`log_storage_disk` 应为 `local` 磁盘。 +如果使用 `latest_log_storage_disk`,则它应该始终是 `local` 磁盘。 +如果禁用 `force_sync`,所有类型的磁盘都可以在任何设置中使用。 -Keeper 实例的可能存储设置如下所示: +Keeper 实例的可能存储设置可能如下所示: ```xml @@ -573,20 +580,20 @@ Keeper 实例的可能存储设置如下所示: ``` -该实例将所有但最新的日志存储在 `log_s3_plain` 磁盘上,而最新的日志将位于 `log_local` 磁盘上。 -同样的逻辑适用于快照,所有但最新的快照将存储在 `snapshot_s3_plain` 中,而最新的快照将位于 `snapshot_local` 磁盘上。 +该实例将在磁盘 `log_s3_plain` 上存储除最新日志之外的所有内容,而最新日志将在 `log_local` 磁盘上。 +相同的逻辑适用于快照,除最新快照外的所有快照将存储在 `snapshot_s3_plain` 上,而最新快照将存储在 `snapshot_local` 磁盘上。 ### 更改磁盘设置 {#changing-disk-setup} -:::important -在应用新磁盘设置之前,请手动备份所有 Keeper 日志和快照。 +:::重要 +在应用新的磁盘设置之前,手动备份所有 Keeper 日志和快照。 ::: -如果定义了分层磁盘设置(使用单独的磁盘用于最新文件),Keeper 在启动时将尝试自动将文件移动到正确的磁盘。 -同样的保证适用于前面;在文件完全移动到新磁盘之前,它不会从旧磁盘中删除,因此可以安全地进行多次重启。 +如果定义了分层磁盘设置(为最新文件使用单独的磁盘),Keeper 将在启动时尝试自动将文件移动到正确的磁盘。 +与之前相同的保证依然适用;在文件完全移动到新磁盘之前,它不会从旧磁盘中删除,因此可以安全地进行多次重启。 -如果需要将文件移动到全新的磁盘(或从 2 磁盘设置移动到单一磁盘设置),可以使用多个定义的 `keeper_server.old_snapshot_storage_disk` 和 `keeper_server.old_log_storage_disk`。 +如果需要将文件移动到一个完全新的磁盘(或从 2 磁盘设置移动到单一磁盘设置),可以使用多个定义 `keeper_server.old_snapshot_storage_disk` 和 `keeper_server.old_log_storage_disk`。 -以下配置展示了我们如何从以前的 2 磁盘设置移动到全新的单磁盘设置: +以下配置展示了如何将之前的 2 磁盘设置迁移到一个全新的单磁盘设置: ```xml @@ -603,32 +610,32 @@ Keeper 实例的可能存储设置如下所示: ``` 在启动时,所有日志文件将从 `log_local` 和 `log_s3_plain` 移动到 `log_local2` 磁盘。 -同时,所有快照文件将从 `snapshot_local` 和 `snapshot_s3_plain` 移动到 `snapshot_local2` 磁盘。 +同样,所有快照文件将从 `snapshot_local` 和 `snapshot_s3_plain` 移动到 `snapshot_local2` 磁盘。 ## 配置日志缓存 {#configuring-logs-cache} -为了最小化从磁盘读取的数据量,Keeper 在内存中缓存日志条目。 -如果请求很大,日志条目将占用过多内存,因此缓存的日志数量有上限。 +为了减少从磁盘读取的数据量,Keeper 在内存中缓存日志条目。 +如果请求很大,日志条目将占用过多的内存,因此缓存的日志数量是受到限制的。 该限制由以下两个配置控制: -- `latest_logs_cache_size_threshold` - 缓存中存储的最新日志的总大小 -- `commit_logs_cache_size_threshold` - 下一个需要提交的后续日志的总大小 +- `latest_logs_cache_size_threshold` - 存储在缓存中的最新日志的总大小 +- `commit_logs_cache_size_threshold` - 需要提交的后续日志的总大小 -如果默认值太大,可以通过减少这两个配置来降低内存使用。 +如果默认值过大,您可以通过减少这两个配置来减少内存使用。 :::note 您可以使用 `pfev` 命令检查从每个缓存和文件中读取的日志数量。 -您还可以使用 Prometheus 端点的度量来跟踪两个缓存的当前大小。 +您还可以使用 Prometheus 端点的指标跟踪两个缓存的当前大小。 ::: ## Prometheus {#prometheus} -Keeper 可以公开供 [Prometheus](https://prometheus.io) 抓取的度量数据。 +Keeper 可以为从 [Prometheus](https://prometheus.io) 抓取的指标数据进行暴露。 设置: -- `endpoint` - Prometheus 服务器抓取度量的 HTTP 端点。以 '/' 开头。 -- `port` - `endpoint` 的端口。 -- `metrics` - 设置为从 [system.metrics](/operations/system-tables/metrics) 表中公开度量的标志。 -- `events` - 设置为从 [system.events](/operations/system-tables/events) 表中公开度量的标志。 -- `asynchronous_metrics` - 设置为从 [system.asynchronous_metrics](/operations/system-tables/asynchronous_metrics) 表中公开当前度量值的标志。 +- `endpoint` – Prometheus 服务器抓取指标的 HTTP 端点。从 '/' 开始。 +- `port` – `endpoint` 的端口。 +- `metrics` – 用于从 [system.metrics](/operations/system-tables/metrics) 表中暴露指标的标志。 +- `events` – 用于从 [system.events](/operations/system-tables/events) 表中暴露指标的标志。 +- `asynchronous_metrics` – 用于从 [system.asynchronous_metrics](/operations/system-tables/asynchronous_metrics) 表中暴露当前指标值的标志。 **示例** @@ -649,25 +656,25 @@ Keeper 可以公开供 [Prometheus](https://prometheus.io) 抓取的度量数据 ``` -检查(用您的 ClickHouse 服务器的 IP 地址或主机名替换 `127.0.0.1`): +检查(将 `127.0.0.1` 替换为您的 ClickHouse 服务器的 IP 地址或主机名): ```bash curl 127.0.0.1:9363/metrics ``` -另请参见 ClickHouse Cloud [Prometheus 集成](/integrations/prometheus)。 +还请查看 ClickHouse Cloud [Prometheus 集成](/integrations/prometheus)。 ## ClickHouse Keeper 用户指南 {#clickhouse-keeper-user-guide} -本指南提供了简单且最小的设置,以配置 ClickHouse Keeper,并示范如何测试分布式操作。该示例使用 3 个在 Linux 上的节点进行。 -### 1. 配置带 Keeper 设置的节点 {#1-configure-nodes-with-keeper-settings} +本指南提供了配置 ClickHouse Keeper 的简单最小设置,并展示了如何测试分布式操作的示例。该示例在 Linux 上使用 3 个节点执行。 +### 1. 配置带有 Keeper 设置的节点 {#1-configure-nodes-with-keeper-settings} -1. 在 3 个主机上安装 3 个 ClickHouse 实例(`chnode1`,`chnode2`,`chnode3`)。 (查看 [快速入门](/getting-started/install/install.mdx) 获取有关安装 ClickHouse 的详细信息。) +1. 在 3 个主机(`chnode1`,`chnode2`,`chnode3`)上安装 3 个 ClickHouse 实例。(有关 ClickHouse 安装的详细信息,请查看[快速开始](/getting-started/install/install.mdx))。 -2. 在每个节点上添加以下条目,以允许通过网络接口进行外部通信。 +2. 在每个节点上,添加以下条目以允许通过网络接口进行外部通信。 ```xml 0.0.0.0 ``` -3. 将以下 ClickHouse Keeper 配置添加到所有三个服务器中,更新每个服务器的 `` 设置;对于 `chnode1` 应为 `1`,对于 `chnode2` 应为 `2`,以此类推。 +3. 将以下 ClickHouse Keeper 配置添加到所有三个服务器,并为每个服务器更新 `` 设置;`chnode1` 的值为 `1`,`chnode2` 为 `2`,依此类推。 ```xml 9181 @@ -705,17 +712,16 @@ curl 127.0.0.1:9363/metrics |参数 |描述 |示例 | |----------|------------------------------|---------------------| - |tcp_port | Keeper 客户端使用的端口|9181,默认值对应 ZooKeeper 的 2181| - |server_id| 在 Raft 配置中每个 ClickHouse Keeper 服务器的标识符| 1| - |coordination_settings| 超时等参数的部分| 超时:10000,日志级别:trace| - |server | 参与服务器的定义|每个服务器定义的列表| - |raft_configuration| Keeper 集群中每个服务器的设置| 每个服务器及其设置| - |id | Keeper 服务的服务器数字 ID|1| - |hostname | Keeper 集群中每个服务器的主机名、IP 或完全合格域名|`chnode1.domain.com`| - |port|用于监听内部 Keeper 连接的端口|9234| - - -4. 启用 Zookeeper 组件。它将使用 ClickHouse Keeper 引擎: + |tcp_port |Keeper 客户端将使用的端口|9181,默认等同于 ZooKeeper 中的 2181| + |server_id| 用于 Raft 配置的每个 ClickHouse Keeper 服务器的标识符| 1| + |coordination_settings| 包含超时等参数的部分| timeouts: 10000, log level: trace| + |server |参与服务器的定义|每个服务器的定义列表| + |raft_configuration| Keeper 集群中每个服务器的设置| 每个服务器和设置| + |id |Keeper 服务的服务器的数字 ID|1| + |hostname |Keeper 集群中每个服务器的主机名、IP 或 FQDN|`chnode1.domain.com`| + |port|供服务器间会话的端口|9234| + +4. 启用 Zookeeper 组件。它将使用 ClickHouse Keeper 引擎: ```xml @@ -737,25 +743,25 @@ curl 127.0.0.1:9363/metrics |参数 |描述 |示例 | |----------|------------------------------|---------------------| - |node | ClickHouse Keeper 连接的节点列表|每个服务器的设置条目| - |host| ClickHouse Keeper 节点的主机名、IP 或完全合格域名| `chnode1.domain.com`| + |node |ClickHouse Keeper 连接节点的列表|每个服务器的设置条目| + |host|每个 ClickHouse Keeper 节点的主机名、IP 或 FQDN| `chnode1.domain.com`| |port|ClickHouse Keeper 客户端端口| 9181| -5. 重启 ClickHouse 并验证每个 Keeper 实例是否正在运行。在每个服务器上执行以下命令。`ruok` 命令返回 `imok`,如果 Keeper 正在运行且健康: +5. 重新启动 ClickHouse 并验证每个 Keeper 实例是否正在运行。在每个服务器上执行以下命令。如果 Keeper 正在运行并且健康,`ruok` 命令将返回 `imok`: ```bash # echo ruok | nc localhost 9181; echo imok ``` -6. `system` 数据库中有一个名为 `zookeeper` 的表,包含您的 ClickHouse Keeper 实例的详细信息。让我们查看该表: +6. `system` 数据库中有一个名为 `zookeeper` 的表,包含您 ClickHouse Keeper 实例的详细信息。让我们查看该表: ```sql SELECT * FROM system.zookeeper WHERE path IN ('/', '/clickhouse') ``` - 表如下所示: + 表看起来像: ```response ┌─name───────┬─value─┬─czxid─┬─mzxid─┬───────────────ctime─┬───────────────mtime─┬─version─┬─cversion─┬─aversion─┬─ephemeralOwner─┬─dataLength─┬─numChildren─┬─pzxid─┬─path────────┐ │ clickhouse │ │ 124 │ 124 │ 2022-03-07 00:49:34 │ 2022-03-07 00:49:34 │ 0 │ 2 │ 0 │ 0 │ 0 │ 2 │ 5693 │ / │ @@ -765,7 +771,7 @@ WHERE path IN ('/', '/clickhouse') ``` ### 2. 在 ClickHouse 中配置集群 {#2--configure-a-cluster-in-clickhouse} -1. 让我们配置一个简单的集群,包含 2 个分片和 2 个节点上的一个副本。第三个节点将用于实现 ClickHouse Keeper 中的法定人数。更新 `chnode1` 和 `chnode2` 的配置。以下集群定义每个节点上有 1 个分片,总共 2 个分片,没有复制。在此示例中,一些数据将在一个节点上,另一些数据将在另一个节点上: +1. 让我们配置一个简单的集群,包含 2 个分片和仅在 2 个节点上的 1 个副本。第三个节点将被用来满足 ClickHouse Keeper 的法定人数要求。更新 `chnode1` 和 `chnode2` 上的配置。以下集群在每个节点上定义 1 个分片,总共 2 个分片且没有复制。在此示例中,部分数据将在一个节点上,而部分数据将在另一个节点上: ```xml @@ -791,20 +797,19 @@ WHERE path IN ('/', '/clickhouse') |参数 |描述 |示例 | |----------|------------------------------|---------------------| - |shard | 集群定义中的副本列表|每个分片的副本列表| - |replica| 每个副本的设置列表|每个副本的设置条目| - |host| 将主机副本的服务器的主机名、IP 或完全合格域名|`chnode1.domain.com`| - |port| 用于使用本地 TCP 协议进行通信的端口|9000| - |user| 用于对集群实例进行身份验证的用户名|default| - |password| 允许连接到集群实例的用户的密码|`ClickHouse123!`| - - -2. 重启 ClickHouse 并验证集群是否创建成功: + |shard |集群定义中副本的列表|每个分片的副本列表| + |replica|每个副本的设置列表|每个副本的设置条目| + |host|将承载副本分片的服务器的主机名、IP 或 FQDN|`chnode1.domain.com`| + |port|用于使用原生 TCP 协议进行通信的端口|9000| + |user|将用于对集群实例进行身份验证的用户名|default| + |password|用于定义用户的密码,以允许连接到集群实例|`ClickHouse123!`| + +2. 重新启动 ClickHouse 并验证集群是否已创建: ```bash SHOW clusters; ``` - 您应该能看到您的集群: + 您应该会看到您的集群: ```response ┌─cluster───────┐ │ cluster_2S_1R │ @@ -812,12 +817,12 @@ SHOW clusters; ``` ### 3. 创建并测试分布式表 {#3-create-and-test-distributed-table} -1. 使用 ClickHouse 客户端在新集群上创建一个新数据库,`ON CLUSTER` 子句会自动在两个节点上创建该数据库。 +1. 使用 ClickHouse 客户端在 `chnode1` 上为新集群创建一个新数据库。`ON CLUSTER` 子句会自动在两个节点上创建数据库。 ```sql CREATE DATABASE db1 ON CLUSTER 'cluster_2S_1R'; ``` -2. 在 `db1` 数据库上创建一个新表。同样,`ON CLUSTER` 在两个节点上创建该表。 +2. 在 `db1` 数据库上创建一个新表。同样,`ON CLUSTER` 会在两个节点上创建该表。 ```sql CREATE TABLE db1.table1 on cluster 'cluster_2S_1R' ( @@ -846,7 +851,7 @@ VALUES (4, 'jkl') ``` -5. 请注意,在每个节点上运行 `SELECT` 语句仅显示该节点上的数据。例如,在 `chnode1` 上: +5. 请注意,在每个节点上运行 `SELECT` 语句只显示该节点上的数据。例如,在 `chnode1` 上: ```sql SELECT * FROM db1.table1 @@ -879,7 +884,7 @@ Query id: c43763cc-c69c-4bcc-afbe-50e764adfcbf └────┴─────────┘ ``` -6. 您可以创建一个 `Distributed` 表来表示两个分片上的数据。带有 `Distributed` 表引擎的表不会存储自己的数据,而是允许在多个服务器上进行分布式查询处理。读取会命中所有的分片,而写入可以分布在分片之间。在 `chnode1` 上运行以下查询: +6. 您可以创建一个 `Distributed` 表来表示两个分片上的数据。具有 `Distributed` 表引擎的表不会存储自己的数据,而允许在多个服务器上进行分布式查询处理。读取操作会影响所有分片,写入操作可以在分片之间分布。在 `chnode1` 上运行以下查询: ```sql CREATE TABLE db1.dist_table ( id UInt64, @@ -888,7 +893,7 @@ CREATE TABLE db1.dist_table ( ENGINE = Distributed(cluster_2S_1R,db1,table1) ``` -7. 查询 `dist_table` 返回来自两个分片的所有四行数据: +7. 注意查询 `dist_table` 返回了来自两个分片的所有四行数据: ```sql SELECT * FROM db1.dist_table @@ -910,23 +915,29 @@ Query id: 495bffa0-f849-4a0c-aeea-d7115a54747a ``` ### 总结 {#summary} -本指南演示了如何使用 ClickHouse Keeper 设置集群。借助 ClickHouse Keeper,您可以配置集群并定义可以在分片之间复制的分布式表。 +本指南演示了如何使用 ClickHouse Keeper 设置集群。通过 ClickHouse Keeper,您可以配置集群并定义可以跨分片复制的分布式表。 ## 使用唯一路径配置 ClickHouse Keeper {#configuring-clickhouse-keeper-with-unique-paths} ### 描述 {#description} -本文介绍了如何使用内置的 `{uuid}` 宏设置在 ClickHouse Keeper 或 ZooKeeper 中创建唯一条目。唯一路径在频繁创建和删除表时非常有用,因为这避免了必须等待几分钟的 Keeper 垃圾收集以删除路径条目,因为每次创建路径时都会使用新的 `uuid`;路径永远不会重用。 +本文描述了如何使用内置的 `{uuid}` 宏设置 +在 ClickHouse Keeper 或 ZooKeeper 中创建唯一条目。唯一 +路径在频繁创建和删除表时帮助 +因为这避免了必须等待几分钟才能进行 Keeper 垃圾收集, +以删除路径条目;因为每次创建路径都会使用新的 `uuid` +在该路径中;路径永远不会重复使用。 ### 示例环境 {#example-environment} -一个三节点集群,将配置在所有三个节点上运行 ClickHouse Keeper,并在两个节点上运行 ClickHouse。这为 ClickHouse Keeper 提供了三个节点(包括一个决胜节点),以及由两个副本组成的单个 ClickHouse 分片。 +三节点集群将配置为在所有三个节点上运行 ClickHouse Keeper, +在两个节点上运行 ClickHouse。这为 ClickHouse Keeper 提供了三个节点(包括一个打破平局的节点),以及由两个副本组成的单个 ClickHouse 分片。 |节点|描述| |-----|-----| |`chnode1.marsnet.local`|数据节点 - 集群 `cluster_1S_2R`| |`chnode2.marsnet.local`|数据节点 - 集群 `cluster_1S_2R`| -|`chnode3.marsnet.local`| ClickHouse Keeper 决胜节点| +|`chnode3.marsnet.local`| ClickHouse Keeper 平局打破节点| -集群示例配置: +集群的示例配置: ```xml @@ -951,8 +962,8 @@ Query id: 495bffa0-f849-4a0c-aeea-d7115a54747a ``` ### 设置使用 `{uuid}` 的表的步骤 {#procedures-to-set-up-tables-to-use-uuid} -1. 在每个服务器上配置宏 -服务器 1 的示例: +1. 在每台服务器上配置宏 +示例为服务器 1: ```xml 1 @@ -960,10 +971,10 @@ Query id: 495bffa0-f849-4a0c-aeea-d7115a54747a ``` :::note -请注意,我们为 `shard` 和 `replica` 定义了宏,但这里不需要定义 `{uuid}`,它是内置的。 +请注意,我们为 `shard` 和 `replica` 定义了宏,但这里没有定义 `{uuid}`,它是内置的,无需定义。 ::: -2. 创建一个数据库 +2. 创建数据库 ```sql CREATE DATABASE db_uuid @@ -983,7 +994,7 @@ Query id: 07fb7e65-beb4-4c30-b3ef-bd303e5c42b5 └───────────────────────┴──────┴────────┴───────┴─────────────────────┴──────────────────┘ ``` -3. 使用宏和 `{uuid}` 创建集群上的表 +3. 使用宏和 `{uuid}` 在集群中创建表 ```sql CREATE TABLE db_uuid.uuid_table1 ON CLUSTER 'cluster_1S_2R' @@ -1012,10 +1023,10 @@ Query id: 8f542664-4548-4a02-bd2a-6f2c973d0dc4 └───────────────────────┴──────┴────────┴───────┴─────────────────────┴──────────────────┘ ``` -4. 创建一个分布式表 +4. 创建一个分布式表 ```sql -create table db_uuid.dist_uuid_table1 on cluster 'cluster_1S_2R' +CREATE TABLE db_uuid.dist_uuid_table1 ON CLUSTER 'cluster_1S_2R' ( id UInt64, column1 String @@ -1039,7 +1050,7 @@ Query id: 3bc7f339-ab74-4c7d-a752-1ffe54219c0e └───────────────────────┴──────┴────────┴───────┴─────────────────────┴──────────────────┘ ``` ### 测试 {#testing} -1. 向第一个节点插入数据(例如 `chnode1`) +1. 向第一个节点插入数据(例如 `chnode1`) ```sql INSERT INTO db_uuid.uuid_table1 ( id, column1) @@ -1057,7 +1068,7 @@ Ok. 1 row in set. Elapsed: 0.033 sec. ``` -2. 向第二个节点插入数据(例如,`chnode2`) +2. 向第二个节点插入数据(例如 `chnode2`) ```sql INSERT INTO db_uuid.uuid_table1 ( id, column1) @@ -1096,7 +1107,7 @@ Query id: 6cbab449-9e7f-40fe-b8c2-62d46ba9f5c8 2 rows in set. Elapsed: 0.007 sec. ``` ### 替代方案 {#alternatives} -默认复制路径可以预先通过宏定义,同时也可以使用 `{uuid}` +默认复制路径可以通过宏和 `{uuid}` 预先定义 1. 在每个节点上为表设置默认值 ```xml @@ -1137,7 +1148,7 @@ Query id: ab68cda9-ae41-4d6d-8d3b-20d8255774ee 2 rows in set. Elapsed: 1.175 sec. ``` -3. 验证它使用了默认配置中的设置 +3. 验证它是否使用了默认配置中使用的设置 ```sql SHOW CREATE TABLE db_uuid.uuid_table1; ``` @@ -1155,7 +1166,7 @@ ORDER BY id 1 row in set. Elapsed: 0.003 sec. ``` -### 排查故障 {#troubleshooting} +### 故障排除 {#troubleshooting} 获取表信息和 UUID 的示例命令: ```sql @@ -1163,14 +1174,15 @@ SELECT * FROM system.tables WHERE database = 'db_uuid' AND name = 'uuid_table1'; ``` -获取在 ZooKeeper 中具有 UUID 的表信息的示例命令 +获取 ZooKeeper 中表信息及 UUID 的示例命令 ```sql SELECT * FROM system.zookeeper WHERE path = '/clickhouse/tables/1/db_uuid/9e8a3cc2-0dec-4438-81a7-c3e63ce2a1cf/replicas'; ``` :::note -数据库必须是 `Atomic`,如果是从早期版本升级,则 `default` 数据库可能是 `Ordinary` 类型。 +数据库必须是 `Atomic`,如果从先前的版本升级,则 +`default` 数据库可能是 `Ordinary` 类型。 ::: 检查: @@ -1201,12 +1213,13 @@ Query id: b047d459-a1d2-4016-bcf9-3e97e30e49c2 ### 描述 {#description-1} -如果将 `keeper_server.enable_reconfiguration` 设置为开启状态,ClickHouse Keeper 部分支持 ZooKeeper 的 [`reconfig`](https://zookeeper.apache.org/doc/r3.5.3-beta/zookeeperReconfig.html#sc_reconfig_modifying) -命令进行动态集群重新配置。 +ClickHouse Keeper 部分支持 ZooKeeper [`reconfig`](https://zookeeper.apache.org/doc/r3.5.3-beta/zookeeperReconfig.html#sc_reconfig_modifying) +命令用于动态集群重新配置,如果 `keeper_server.enable_reconfiguration` 被打开。 :::note -如果此设置关闭,您可以通过手动更改副本的 `raft_configuration` 部分来重新配置集群。确保在所有副本上编辑文件,因为只有领导者会应用更改。 -另外,您可以通过任何兼容 ZooKeeper 的客户端发送 `reconfig` 查询。 +如果此设置关闭,您可以通过手动更改副本的 `raft_configuration` +部分重新配置集群。确保在所有副本上编辑文件,因为只有领导会应用更改。 +或者,您可以通过任何与 ZooKeeper 兼容的客户端发送 `reconfig` 查询。 ::: 虚拟节点 `/keeper/config` 包含最后提交的集群配置,格式如下: @@ -1217,9 +1230,9 @@ server.id2 = ... ... ``` -- 每个服务器条目以换行符分隔。 -- `server_type` 是 `participant` 或 `learner` ([learner](https://github.com/eBay/NuRaft/blob/master/docs/readonly_member.md) 不参与领导者选举)。 -- `server_priority` 是一个非负整数,用于告诉 [哪些节点应在领导者选举中优先](https://github.com/eBay/NuRaft/blob/master/docs/leader_election_priority.md)。 +- 每个服务器条目由换行符分隔。 +- `server_type` 是 `participant` 或 `learner`([learner](https://github.com/eBay/NuRaft/blob/master/docs/readonly_member.md) 不参与领导选举)。 +- `server_priority` 是一个非负整数,告诉 [在领导选举中应优先考虑哪些节点](https://github.com/eBay/NuRaft/blob/master/docs/leader_election_priority.md)。 优先级为 0 意味着服务器永远不会成为领导者。 示例: @@ -1231,7 +1244,7 @@ server.2=zoo2:9234;participant;1 server.3=zoo3:9234;participant;1 ``` -您可以使用 `reconfig` 命令添加新服务器、移除现有服务器并更改现有服务器的优先级,以下是示例(使用 `clickhouse-keeper-client`): +您可以使用 `reconfig` 命令添加新服务器、删除现有服务器,并更改现有服务器的优先级,以下是示例(使用 `clickhouse-keeper-client`): ```bash @@ -1245,7 +1258,7 @@ reconfig remove "3,4" reconfig add "server.5=localhost:5123;participant;8" ``` -以下是 `kazoo` 的示例: +这里是 `kazoo` 的示例: ```python @@ -1257,51 +1270,52 @@ reconfig(joining="server.5=localhost:123,server.6=localhost:234;learner", leavin reconfig(joining="server.5=localhost:5123;participant;8", leaving=None) ``` -在 `joining` 中的服务器应符合上述描述的服务器格式。服务器条目应以逗号分隔。 +`joining` 中的服务器应符合上述描述的服务器格式。服务器条目应以逗号分隔。 在添加新服务器时,您可以省略 `server_priority`(默认值为 1)和 `server_type`(默认值为 `participant`)。 -如果您想更改现有服务器的优先级,请将其添加到 `joining` 并指定目标优先级。 -服务器的主机、端口和类型必须与现有服务器配置相等。 +如果要更改现有服务器的优先级,请将其添加到 `joining` 中,设置目标优先级。 +服务器的主机、端口和类型必须与现有服务器配置相同。 -服务器按其在 `joining` 和 `leaving` 中出现的顺序添加和移除。 -`joining` 中的所有更新都在 `leaving` 中的更新之前处理。 +服务器按在 `joining` 和 `leaving` 中出现的顺序添加和删除。 +所有来自 `joining` 的更新在处理来自 `leaving` 的更新之前完成。 -在 Keeper 重新配置实现中有一些注意事项: +Keeper 重新配置实现中存在一些注意事项: - 仅支持增量重新配置。带有非空 `new_members` 的请求将被拒绝。 - ClickHouse Keeper 的实现依赖于 NuRaft API 动态更改成员资格。NuRaft 提供了逐个添加或逐个删除单个服务器的方法。这意味着每次更改配置(`joining` 的每个部分、`leaving` 的每个部分)必须单独决定。因此,无法提供捆绑的重新配置,因为这对最终用户来说会产生误导。 + ClickHouse Keeper 的实现依赖于 NuRaft API 动态改变成员资格。NuRaft 具有添加单个服务器或一次删除单个服务器的功能。这意味着配置的每一次更改(每一部分 `joining`,每一部分 `leaving`)必须单独决定。因此,没有可用的大规模重新配置,因为这对最终用户来说是具有误导性的。 - 更改服务器类型(participant/learner)也是不可能的,因为 NuRaft 不支持,唯一的方法是删除并添加服务器,这同样会导致误导。 + 更改服务器类型(participant/learner)也不可行,因为 NuRaft 不支持这样的操作,唯一的方法是删除并添加服务器,这同样会误导用户。 -- 您无法使用返回的 `znodestat` 值。 -- `from_version` 字段未使用。所有设置了 `from_version` 的请求都会被拒绝。 - 这是因为 `/keeper/config` 是一个虚拟节点,这意味着它不存储在持久存储中,而是为每个请求动态生成指定的节点配置。 - 做出这个决定是为了避免数据重复,因为 NuRaft 已经存储了此配置。 -- 与 ZooKeeper 不同,没有办法通过提交 `sync` 命令等待集群重新配置。 - 新配置将会_逐渐_应用,但没有时间保证。 -- `reconfig` 命令可能因各种原因而失败。您可以检查集群的状态,看看更新是否已应用。 +- 您不能使用返回的 `znodestat` 值。 +- `from_version` 字段未使用。所有设置 `from_version` 的请求被拒绝。 + 这是因为 `/keeper/config` 是一个虚拟节点,这意味着它不存储在 + 永久存储中,而是每个请求的指定节点配置动态生成。 + 这一决定是为了不重复数据,因为 NuRaft 已经存储了此配置。 +- 与 ZooKeeper 不同,通过提交 `sync` 命令,无法等待集群重新配置。 + 新配置将 _最终_ 应用,但没有时间保证。 +- `reconfig` 命令可能因各种原因失败。您可以检查集群的状态,看看更新是否应用。 ## 将单节点 Keeper 转换为集群 {#converting-a-single-node-keeper-into-a-cluster} -有时需要将实验性 Keeper 节点扩展为集群。以下是逐步执行 3 节点集群的方案: +有时需要将实验性 Keeper 节点扩展为集群。以下是如何逐步执行 3 节点集群的方案: -- **重要**:新节点必须批量添加,数量少于当前法定人数,否则它们将相互选举领导者。在这个示例中一个接一个地添加。 +- **重要提示**:新节点必须分批添加,数量少于现有法定人数,否则它们会在它们之间选举领导者。在此示例中,逐个添加。 - 现有的 Keeper 节点必须启用 `keeper_server.enable_reconfiguration` 配置参数。 - 启动第二个节点,使用完整的新 Keeper 集群配置。 - 启动后,将其添加到节点 1,使用 [`reconfig`](#reconfiguration)。 -- 现在,启动第三个节点并使用 [`reconfig`](#reconfiguration) 将其添加。 -- 更新 `clickhouse-server` 配置,在其中添加新的 Keeper 节点,然后重启以应用更改。 -- 更新节点 1 的 raft 配置,并可选择性重启它。 +- 现在,启动第三个节点并使用 [`reconfig`](#reconfiguration) 添加它。 +- 更新 `clickhouse-server` 配置,添加新 Keeper 节点,并重新启动以应用更改。 +- 更新节点 1 的 Raft 配置,并可选择重启它。 -为确保您对该过程有信心,这里有一个 [sandbox repository](https://github.com/ClickHouse/keeper-extend-cluster)。 +为了对该过程感到放心,这里有一个 [沙箱仓库](https://github.com/ClickHouse/keeper-extend-cluster)。 ## 不支持的功能 {#unsupported-features} -虽然 ClickHouse Keeper 旨在与 ZooKeeper 完全兼容,但目前有一些功能尚未实现(尽管开发仍在进行中): +虽然 ClickHouse Keeper 旨在与 ZooKeeper 完全兼容,但仍有一些功能当前未实现(尽管正在开发中): - [`create`](https://zookeeper.apache.org/doc/r3.9.1/apidocs/zookeeper-server/org/apache/zookeeper/ZooKeeper.html#create(java.lang.String,byte%5B%5D,java.util.List,org.apache.zookeeper.CreateMode,org.apache.zookeeper.data.Stat)) 不支持返回 `Stat` 对象 -- [`create`](https://zookeeper.apache.org/doc/r3.9.1/apidocs/zookeeper-server/org/apache/zookeeper/ZooKeeper.html#create(java.lang.String,byte%5B%5D,java.util.List,org.apache.zookeeper.CreateMode,org.apache.zookeeper.data.Stat)) 不支持 [TTL](https://zookeeper.apache.org/doc/r3.9.1/apidocs/zookeeper-server/org/apache/zookeeper/CreateMode.html#PERSISTENT_WITH_TTL) -- [`addWatch`](https://zookeeper.apache.org/doc/r3.9.1/apidocs/zookeeper-server/org/apache/zookeeper/ZooKeeper.html#addWatch(java.lang.String,org.apache.zookeeper.Watcher,org.apache.zookeeper.AddWatchMode)) 不适用于 [`PERSISTENT`](https://zookeeper.apache.org/doc/r3.9.1/apidocs/zookeeper-server/org/apache/zookeeper/AddWatchMode.html#PERSISTENT) 监视器 -- [`removeWatch`](https://zookeeper.apache.org/doc/r3.9.1/apidocs/zookeeper-server/org/apache/zookeeper/ZooKeeper.html#removeWatches(java.lang.String,org.apache.zookeeper.Watcher,org.apache.zookeeper.Watcher.WatcherType,boolean)) 和 [`removeAllWatches`](https://zookeeper.apache.org/doc/r3.9.1/apidocs/zookeeper-server/org/apache/zookeeper/ZooKeeper.html#removeAllWatches(java.lang.String,org.apache.zookeeper.Watcher,org.apache.zookeeper.WatcherType,boolean)) 不受支持 +- [`create`](https://zookeeper.apache.org/doc/r3.9.1/apidocs/zookeeper-server/org/apache/zookeeper/ZooKeeper.html#create(java.lang.String,byte%5B%5D,java.util.List,org.apache.zookeeper.CreateMode,org.apache.zookeeper.data.Stat)) 不支持 [TTL](https://zookeeper.apache.org/doc/r3.9.1/apidocs/zookeeper-server/org/apache/zookeeper/CreateMode.html#PERSISTENT_WITH_TTL) +- [`addWatch`](https://zookeeper.apache.org/doc/r3.9.1/apidocs/zookeeper-server/org/apache/zookeeper/ZooKeeper.html#addWatch(java.lang.String,org.apache.zookeeper.Watcher,org.apache.zookeeper.AddWatchMode)) 不适用于 [`PERSISTENT`](https://zookeeper.apache.org/doc/r3.9.1/apidocs/zookeeper-server/org/apache/zookeeper/AddWatchMode.html#PERSISTENT) 监视 +- [`removeWatch`](https://zookeeper.apache.org/doc/r3.9.1/apidocs/zookeeper-server/org/apache/zookeeper/ZooKeeper.html#removeWatches(java.lang.String,org.apache.zookeeper.Watcher,org.apache.zookeeper.Watcher.WatcherType,boolean)) 和 [`removeAllWatches`](https://zookeeper.apache.org/doc/r3.9.1/apidocs/zookeeper-server/org/apache/zookeeper/ZooKeeper.html#removeAllWatches(java.lang.String,org.apache.zookeeper.Watcher.WatcherType,boolean)) 不受支持 - `setWatches` 不受支持 - 创建 [`CONTAINER`](https://zookeeper.apache.org/doc/r3.5.1-alpha/api/org/apache/zookeeper/CreateMode.html) 类型的 znodes 不受支持 -- 不支持 [`SASL 认证`](https://cwiki.apache.org/confluence/display/ZOOKEEPER/Zookeeper+and+SASL) +- 不支持 [`SASL 身份验证`](https://cwiki.apache.org/confluence/display/ZOOKEEPER/Zookeeper+and+SASL) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/sre/keeper/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/sre/keeper/index.md.hash index cf0dbcd086f..d740e75b04d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/sre/keeper/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/sre/keeper/index.md.hash @@ -1 +1 @@ -be6a7fe87dc95fd9 +8f027998bca0ce84 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/sre/network-ports.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/sre/network-ports.md index 2f876325a34..c289360bbec 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/sre/network-ports.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/sre/network-ports.md @@ -3,31 +3,32 @@ 'sidebar_label': '网络端口' 'title': '网络端口' 'description': '可用网络端口及其用途的描述' +'doc_type': 'reference' --- # 网络端口 :::note -描述为 **默认** 的端口表示端口号在 `/etc/clickhouse-server/config.xml` 中配置。要自定义您的设置,请将文件添加到 `/etc/clickhouse-server/config.d/`。有关更多信息,请参阅 [配置文件](/operations/configuration-files) 文档。 +描述为 **默认** 的端口表示该端口号配置在 `/etc/clickhouse-server/config.xml` 中。要自定义您的设置,请在 `/etc/clickhouse-server/config.d/` 中添加一个文件。有关详细信息,请参见 [配置文件](/operations/configuration-files) 文档。 ::: -|端口|描述| -|----|-----------| -|2181|ZooKeeper 默认服务端口。 **注意:请参阅 `9181` 以获取 ClickHouse Keeper**| -|8123|HTTP 默认端口| -|8443|HTTP SSL/TLS 默认端口| -|9000|原生协议端口(也称为 ClickHouse TCP 协议)。用于 ClickHouse 应用程序和进程,如 `clickhouse-server`、`clickhouse-client` 和原生 ClickHouse 工具。用于分布式查询的服务器间通信。| -|9004|MySQL 模拟端口| -|9005|PostgreSQL 模拟端口(如果为 ClickHouse 启用了 SSL,则也用于安全通信)。| -|9009|用于低级数据访问的服务器间通信端口。用于数据交换、复制和服务器间通信。| -|9010|服务器间通信的 SSL/TLS 端口| -|9011|原生协议 PROXYv1 协议端口| -|9019|JDBC 桥接| -|9100|gRPC 端口| -|9181|推荐的 ClickHouse Keeper 端口| -|9234|推荐的 ClickHouse Keeper Raft 端口(如果启用了 `1`,还用于安全通信)| -|9363|Prometheus 默认指标端口| -|9281|推荐的安全 SSL ClickHouse Keeper 端口| -|9440|原生协议 SSL/TLS 端口| -|42000|Graphite 默认端口| +|端口|描述|云|OSS| +|----|-----------|-----|---| +|2181|ZooKeeper 默认服务端口。 **注意:有关 ClickHouse Keeper,请参见 `9181`**||✓| +|8123|HTTP 默认端口||✓| +|8443|HTTP SSL/TLS 默认端口|✓|✓| +|9000|原生协议端口(也称为 ClickHouse TCP 协议)。由 ClickHouse 应用程序和进程(如 `clickhouse-server`,`clickhouse-client` 和原生 ClickHouse 工具)使用。用于分布式查询的服务器间通信。||✓| +|9004|MySQL 模拟端口||✓| +|9005|PostgreSQL 模拟端口(也用于启用 SSL 的 ClickHouse 的安全通信)。||✓| +|9009|低级数据访问的服务器间通信端口。用于数据交换、复制和服务器间通信。||✓| +|9010|服务器间通信的 SSL/TLS||✓| +|9011|原生协议 PROXYv1 协议端口||✓| +|9019|JDBC 桥接||✓| +|9100|gRPC 端口||✓| +|9181|推荐的 ClickHouse Keeper 端口||✓| +|9234|推荐的 ClickHouse Keeper Raft 端口(如果启用 `1` 也用于安全通信)||✓| +|9363|Prometheus 默认指标端口||✓| +|9281|推荐的安全 SSL ClickHouse Keeper 端口||✓| +|9440|原生协议 SSL/TLS 端口|✓|✓| +|42000|Graphite 默认端口||✓| diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/sre/network-ports.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/sre/network-ports.md.hash index b04c32e3cff..a3fc8a2cc44 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/sre/network-ports.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/sre/network-ports.md.hash @@ -1 +1 @@ -e1a1ce935a2dde8a +6d705acb365c2589 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/sre/scaling-clusters.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/sre/scaling-clusters.md index a576fc93d6a..388d4f5b597 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/sre/scaling-clusters.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/sre/scaling-clusters.md @@ -2,19 +2,20 @@ 'slug': '/guides/sre/scaling-clusters' 'sidebar_label': '重新平衡分片' 'sidebar_position': 20 -'description': 'ClickHouse 不支持自动分片重新平衡,因此我们提供了一些最佳实践,以便如何重新平衡分片。' +'description': 'ClickHouse 不支持自动分片重新平衡,因此我们提供一些最佳实践来平衡分片。' 'title': '重新平衡数据' +'doc_type': 'guide' --- # 重新平衡数据 -ClickHouse 不支持自动分片重新平衡。然而,有一些方法可以按优先顺序重新平衡分片: +ClickHouse 不支持自动分片重新平衡。然而,有几种按优先顺序重新平衡分片的方法: -1. 调整 [分布式表](/engines/table-engines/special/distributed.md) 的分片,使写入偏向新的分片。这可能会导致集群上的负载不平衡和热点,但在写入吞吐量不是非常高的情况下,这在大多数场景中是可行的。它不要求用户更改其写入目标,即可以保持为分布式表。这并不有助于重新平衡现有数据。 +1. 调整 [分布式表](/engines/table-engines/special/distributed.md) 的分片,允许写入偏向新的分片。这可能导致集群中的负载不均衡和热点,但在大多数写入吞吐量不是极高的场景中是可行的。这不需要用户更改他们的写入目标,即可以保持为分布式表。这并不有助于重新平衡现有数据。 -2. 作为 (1) 的替代方法,修改现有集群并专门向新分片写入,直到集群达到平衡 - 手动加权写入。这与 (1) 有相同的限制。 +2. 作为 (1) 的替代方案,修改现有集群并专门写入新分片,直到集群平衡 - 手动加权写入。这与 (1) 有相同的限制。 -3. 如果您需要重新平衡现有数据并且已经对数据进行了分区,请考虑分离分区并手动将它们重新定位到另一个节点,然后再重新连接到新分片。这比后续技术更手动,但可能更快速且对资源的消耗更少。这是一个手动操作,因此需要考虑数据的重新平衡。 +3. 如果您需要重新平衡现有数据并且已经对数据进行了分区,考虑分离分区并手动将其重新定位到另一个节点,然后再重新附加到新分片。这比后续技术更为手动,但可能更快且资源消耗更少。这是一个手动操作,因此需要考虑数据的重新平衡。 -4. 通过 [INSERT FROM SELECT](/sql-reference/statements/insert-into.md/#inserting-the-results-of-select) 将数据从源集群导出到新集群。在非常大的数据集上,这不会产生良好的性能,并且可能会在源集群上产生显著的 IO 并消耗大量的网络资源。这代表着最后的手段。 +4. 通过 [INSERT FROM SELECT](/sql-reference/statements/insert-into.md/#inserting-the-results-of-select) 将数据从源集群导出到新集群。这在非常大的数据集上性能不佳,并可能对源集群造成显著的 IO,并使用大量网络资源。这代表着最后的手段。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/sre/scaling-clusters.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/sre/scaling-clusters.md.hash index 39c0c9db855..f3b0c45cde3 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/sre/scaling-clusters.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/sre/scaling-clusters.md.hash @@ -1 +1 @@ -18940ce41ab50c80 +2254000775e6888a diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/sre/user-management/configuring-ldap.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/sre/user-management/configuring-ldap.md index e85311de812..fdc1170d3d3 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/sre/user-management/configuring-ldap.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/sre/user-management/configuring-ldap.md @@ -2,18 +2,19 @@ 'sidebar_label': '配置 LDAP' 'sidebar_position': 2 'slug': '/guides/sre/configuring-ldap' -'title': '配置 ClickHouse 以使用 LDAP 进行身份验证和角色映射' -'description': '描述如何配置 ClickHouse 以使用 LDAP 进行身份验证和角色映射' +'title': '配置 ClickHouse 使用 LDAP 进行身份验证和角色映射' +'description': '描述如何配置 ClickHouse 使用 LDAP 进行身份验证和角色映射' +'doc_type': 'guide' --- import SelfManaged from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_self_managed_only_no_roadmap.md'; -# 配置 ClickHouse 使用 LDAP 进行身份验证和角色映射 +# 配置 ClickHouse 以使用 LDAP 进行身份验证和角色映射 -ClickHouse 可以配置为使用 LDAP 来验证 ClickHouse 数据库用户。本文提供了一个简单示例,演示如何将 ClickHouse 与一个公共目录中的 LDAP 系统集成进行身份验证。 +ClickHouse 可以配置为使用 LDAP 验证 ClickHouse 数据库用户。 本指南提供了将 ClickHouse 与 LDAP 系统集成的简单示例,该系统可以对公共目录进行身份验证。 ## 1. 在 ClickHouse 中配置 LDAP 连接设置 {#1-configure-ldap-connection-settings-in-clickhouse} @@ -22,7 +23,7 @@ ClickHouse 可以配置为使用 LDAP 来验证 ClickHouse 数据库用户。本 $ ldapsearch -x -b dc=example,dc=com -H ldap://ldap.forumsys.com ``` - 返回的内容类似于: + 回复将类似于以下内容: ```response # extended LDIF @@ -48,7 +49,7 @@ dc: example ... ``` -2. 编辑 `config.xml` 文件,添加以下内容以配置 LDAP: +2. 编辑 `config.xml` 文件并添加以下内容以配置 LDAP: ```xml @@ -62,28 +63,28 @@ dc: example ``` :::note - `` 标签是用于识别特定 LDAP 服务器的任意标签。 + `` 标签是一个任意标签,用于标识特定的 LDAP 服务器。 ::: - 这些是上述使用的基本设置: + 以上所用的基本设置如下: - |参数 |描述 |示例 | - |-------------|------------------------------|---------------------------| - |host |LDAP 服务器的主机名或 IP |ldap.forumsys.com | - |port |LDAP 服务器的目录端口 |389 | - |bind_dn |用户的路径模板 |`uid={user_name},dc=example,dc=com`| - |enable_tls |是否使用安全 LDAP |no | - |tls_require_cert |是否要求连接时要有证书 |never | + |参数 |描述 |示例 | + |-----------|--------------------------------|-----------------------------| + |host |LDAP 服务器的主机名或 IP |ldap.forumsys.com | + |port |LDAP 服务器的目录端口 |389 | + |bind_dn |用户的模板路径 |`uid={user_name},dc=example,dc=com`| + |enable_tls |是否使用安全的 LDAP |no | + |tls_require_cert |是否需要连接的证书 |never | :::note - 在本例中,由于公共服务器使用 389 并且不使用安全端口,因此为了演示目的,我们禁用 TLS。 + 在此示例中,由于公共服务器使用 389 并且不使用安全端口,因此我们出于演示目的禁用 TLS。 ::: :::note - 查看 [LDAP 文档页面](../../../operations/external-authenticators/ldap.md) 以获取有关 LDAP 设置的更多详细信息。 + 有关 LDAP 设置的更多详细信息,请查看 [LDAP 文档页面](../../../operations/external-authenticators/ldap.md)。 ::: -3. 在 `` 部分中添加 `` 部分以配置用户角色映射。该部分定义了用户何时被认证以及用户将获得什么角色。在此基本示例中,任何通过 LDAP 进行身份验证的用户将获得 `scientists_role`,该角色将在 ClickHouse 的后续步骤中定义。该部分应类似于: +3. 将 `` 部分添加到 `` 部分以配置用户角色映射。 该部分定义何时对用户进行身份验证以及用户将获得什么角色。 在这个基本示例中,任何通过 LDAP 进行身份验证的用户将获得 `scientists_role`,该角色将在 ClickHouse 中的后续步骤中定义。 该部分应如下所示: ```xml @@ -106,23 +107,22 @@ dc: example ``` - 这些是上述使用的基本设置: - - |参数 |描述 |示例 | - |-------------|------------------------------|---------------------------| - |server |在之前的 ldap_servers 部分中定义的标签 |test_ldap_server | - |roles |在 ClickHouse 中定义的用户将映射到的角色名 |scientists_role | - |base_dn |开始搜索用户组的基本路径 |dc=example,dc=com | - |search_filter|用于识别选择用于映射用户的组的 ldap 搜索过滤器 |`(&(objectClass=groupOfUniqueNames)(uniqueMember={bind_dn}))`| - |attribute |应返回值的属性名称 |cn | + 以上所用的基本设置如下: + |参数 |描述 |示例 | + |-----------|--------------------------------|-----------------------------| + |server |在之前的 ldap_servers 部分中定义的标签|test_ldap_server | + |roles |在 ClickHouse 中定义的角色名称,用户将映射到|scientists_role | + |base_dn |搜索用户所在组的基路径 |dc=example,dc=com | + |search_filter|用于识别选择映射用户的组的 ldap 搜索过滤器|`(&(objectClass=groupOfUniqueNames)(uniqueMember={bind_dn}))`| + |attribute |应返回的特定属性名称 |cn | 4. 重启您的 ClickHouse 服务器以应用设置。 ## 2. 配置 ClickHouse 数据库角色和权限 {#2-configure-clickhouse-database-roles-and-permissions} :::note -本节中的过程假定已经启用了 ClickHouse 中的 SQL 访问控制和账户管理。要启用,请查看 [SQL 用户和角色指南](index.md)。 +本节中的过程假定已启用 ClickHouse 中的 SQL 访问控制和账户管理。 要启用,请查看 [SQL 用户和角色指南](index.md)。 ::: 1. 在 ClickHouse 中创建一个与 `config.xml` 文件的角色映射部分中使用的名称相同的角色 @@ -130,7 +130,7 @@ dc: example CREATE ROLE scientists_role; ``` -2. 授予该角色所需的权限。以下语句授予能够通过 LDAP 进行身份验证的任何用户管理权限: +2. 向该角色授予所需的权限。 以下语句向能够通过 LDAP 进行身份验证的任何用户授予管理员权限: ```sql GRANT ALL ON *.* TO scientists_role; ``` @@ -148,10 +148,10 @@ chnode1 :) ``` :::note - 在步骤 1 中使用 `ldapsearch` 命令查看目录中所有可用用户,所有用户的密码均为 `password` + 在第 1 步中使用 `ldapsearch` 命令查看目录中可用的所有用户,所有用户的密码都是 `password` ::: -2. 测试用户是否正确映射到 `scientists_role` 角色并具有管理权限 +2. 测试用户是否正确映射到 `scientists_role` 角色并具有管理员权限 ```sql SHOW DATABASES ``` @@ -174,5 +174,5 @@ Query id: 93b785ff-1482-4eda-95b0-b2d68b2c5e0f 9 rows in set. Elapsed: 0.004 sec. ``` -## 摘要 {#summary} -本文演示了如何配置 ClickHouse 以验证 LDAP 服务器并映射到角色的基础知识。 还可以为 ClickHouse 中的单个用户配置选项,但让这些用户通过 LDAP 进行验证而不配置自动角色映射。LDAP 模块还可以用于连接到 Active Directory。 +## 总结 {#summary} +本文演示了配置 ClickHouse 以对 LDAP 服务器进行身份验证以及映射到角色的基础知识。 还可以选择在 ClickHouse 中配置单个用户,但无需配置自动角色映射即可使用 LDAP 对这些用户进行身份验证。 LDAP 模块也可以用于连接到 Active Directory。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/sre/user-management/configuring-ldap.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/sre/user-management/configuring-ldap.md.hash index 368c2f078cb..15920ba0d8c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/sre/user-management/configuring-ldap.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/sre/user-management/configuring-ldap.md.hash @@ -1 +1 @@ -7da78a8a41020218 +8677c0ad02cbd725 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/sre/user-management/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/sre/user-management/index.md index 576afe9b78d..64e182358ca 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/sre/user-management/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/sre/user-management/index.md @@ -9,69 +9,70 @@ - 'User Management' - 'RBAC' - 'Security' -'description': '描述了在 ClickHouse Cloud 中的访问控制和账户管理' +'description': '描述 ClickHouse Cloud 中的访问控制和账户管理' +'doc_type': 'guide' --- # 在 ClickHouse 中创建用户和角色 -ClickHouse 支持基于 [RBAC](https://en.wikipedia.org/wiki/Role-based_access_control) 的访问控制管理。 +ClickHouse 支持基于 [RBAC](https://en.wikipedia.org/wiki/Role-based_access_control) 方法的访问控制管理。 -ClickHouse 访问实体: +ClickHouse 访问实体包括: - [用户账户](#user-account-management) - [角色](#role-management) - [行策略](#row-policy-management) - [设置配置文件](#settings-profiles-management) - [配额](#quotas-management) -您可以通过以下方式配置访问实体: +您可以使用以下方式配置访问实体: -- 基于 SQL 的工作流。 +- 基于 SQL 的工作流程。 您需要 [启用](#enabling-access-control) 此功能。 -- 服务器 [配置文件](/operations/configuration-files.md) `users.xml` 和 `config.xml`。 +- 服务器的 [配置文件](/operations/configuration-files.md) `users.xml` 和 `config.xml`。 -我们推荐使用基于 SQL 的工作流。两种配置方法可以同时工作,因此,如果您使用服务器配置文件来管理账户和访问权限,您可以顺利切换到基于 SQL 的工作流。 +我们建议使用基于 SQL 的工作流程。两种配置方法可以同时使用,因此如果您使用服务器配置文件来管理账户和访问权限,您可以顺利切换到基于 SQL 的工作流程。 :::note -您不能同时通过这两种配置方法管理同一个访问实体。 +您不能通过两种配置方法同时管理相同的访问实体。 ::: :::note -如果您想管理 ClickHouse Cloud Console 用户,请参考此 [页面](/cloud/security/cloud-access-management)。 +如果您正在寻找管理 ClickHouse Cloud 控制台用户的信息,请参考此 [页面](/cloud/security/cloud-access-management) ::: -要查看所有用户、角色、配置文件等及其所有权限,请使用 [`SHOW ACCESS`](/sql-reference/statements/show#show-access) 语句。 +要查看所有用户、角色、配置文件等及其所有授权,请使用 [`SHOW ACCESS`](/sql-reference/statements/show#show-access) 语句。 ## 概述 {#access-control-usage} -默认情况下,ClickHouse 服务器提供 `default` 用户账户,该账户不允许使用基于 SQL 的访问控制和账户管理,但拥有所有权限和权限。当未定义用户名时,例如,从客户端登录或在分布式查询中,使用 `default` 用户账户。在分布式查询处理中,如果服务器或集群的配置未指定 [用户名和密码](/engines/table-engines/special/distributed.md) 属性,则使用默认用户账户。 +默认情况下,ClickHouse 服务器提供 `default` 用户账户,该账户不允许使用基于 SQL 的访问控制和账户管理,但拥有所有权利和权限。当用户名未定义时,例如,在客户端登录或在分布式查询中,使用默认用户账户。如果服务器或集群的配置未指定 [用户和密码](/engines/table-engines/special/distributed.md) 属性,则在分布式查询处理时使用默认用户账户。 -如果您刚开始使用 ClickHouse,可以考虑以下场景: +如果您刚开始使用 ClickHouse,请考虑以下场景: -1. [启用](#enabling-access-control) SQL 驱动的访问控制和账户管理,用于 `default` 用户。 -2. 登录到 `default` 用户账户并创建所有必需的用户。不要忘记创建管理员账户(`GRANT ALL ON *.* TO admin_user_account WITH GRANT OPTION`)。 -3. [限制权限](/operations/settings/permissions-for-queries) 给 `default` 用户,并禁用其 SQL 驱动的访问控制和账户管理。 +1. [启用](#enabling-access-control) `default` 用户的基于 SQL 的访问控制和账户管理。 +2. 登录到 `default` 用户账户并创建所有所需用户。别忘了创建一个管理员账户(`GRANT ALL ON *.* TO admin_user_account WITH GRANT OPTION`)。 +3. [限制权限](/operations/settings/permissions-for-queries) 对于 `default` 用户并禁用其基于 SQL 的访问控制和账户管理。 ### 当前解决方案的属性 {#access-control-properties} -- 您可以为数据库和表授予权限,即使它们不存在。 -- 如果删除了一个表,则与该表相关的所有权限不会被撤销。这意味着即使您稍后创建一个同名的新表,所有权限仍然有效。要撤销与已删除表相关的权限,您需要执行,例如,`REVOKE ALL PRIVILEGES ON db.table FROM ALL` 查询。 -- 权限没有有效期设置。 +- 您可以为不存在的数据库和表授予权限。 +- 如果表被删除,与该表对应的所有权限不会被撤销。这意味着即使您稍后创建一个同名的新表,所有权限仍然有效。要撤销对应于已删除表的权限,您需要执行,例如,`REVOKE ALL PRIVILEGES ON db.table FROM ALL` 查询。 +- 权限没有寿命设置。 ### 用户账户 {#user-account-management} -用户账户是一个访问实体,允许在 ClickHouse 中进行身份验证。用户账户包含: +用户账户是一个访问实体,允许在 ClickHouse 中授权某人。用户账户包含: -- 身份识别信息。 -- 定义用户可以执行的查询范围的 [特权](/sql-reference/statements/grant.md#privileges)。 +- 身份信息。 +- [权限](/sql-reference/statements/grant.md#privileges),定义用户可以执行的查询范围。 - 允许连接到 ClickHouse 服务器的主机。 -- 分配的和默认角色。 -- 在用户登录时默认应用的设置及其约束。 +- 分配的和默认的角色。 +- 用户登录时应用的设置及其约束。 - 分配的设置配置文件。 -可以通过 [GRANT](/sql-reference/statements/grant.md) 查询或分配 [角色](#role-management) 向用户账户授予权限。要从用户中撤销权限,ClickHouse 提供了 [REVOKE](/sql-reference/statements/revoke.md) 查询。要列出用户的权限,请使用 [SHOW GRANTS](/sql-reference/statements/show#show-grants) 语句。 +可以通过 [GRANT](/sql-reference/statements/grant.md) 查询或通过分配 [角色](#role-management) 来授予用户账户权限。要从用户中撤销权限,ClickHouse 提供 [REVOKE](/sql-reference/statements/revoke.md) 查询。要列出用户的权限,请使用 [SHOW GRANTS](/sql-reference/statements/show#show-grants) 语句。 管理查询: @@ -83,22 +84,22 @@ ClickHouse 访问实体: ### 设置应用 {#access-control-settings-applying} -设置可以以不同方式进行配置:针对用户账户、其授权的角色以及设置配置文件。在用户登录时,如果为不同访问实体配置了设置,该设置的值和约束将按以下优先级应用(从高到低): +设置可以以不同方式配置:对于用户账户、其授予的角色和设置配置文件。在用户登录时,如果为不同的访问实体配置了设置,则该设置的值和约束按以下优先级应用(从高到低): 1. 用户账户设置。 -2. 用户账户的默认角色的设置。如果某些角色中配置了某个设置,则该设置的应用顺序未定义。 -3. 分配给用户或其默认角色的设置配置文件中的设置。如果某些配置文件中配置了某个设置,则该设置的应用顺序未定义。 -4. 默认或来自 [默认配置文件](/operations/server-configuration-parameters/settings#default_profile) 应用到整个服务器的设置。 +2. 用户账户的默认角色设置。如果某些角色中配置了设置,则设置应用的顺序是未定义的。 +3. 分配给用户或其默认角色的设置配置文件中的设置。如果在某些配置文件中配置了设置,则设置应用的顺序是未定义的。 +4. 默认情况下或从 [默认配置文件](/operations/server-configuration-parameters/settings#default_profile) 应用到整个服务器的设置。 ### 角色 {#role-management} -角色是一个访问实体的容器,可以授予用户账户。 +角色是可以授予用户账户的访问实体的容器。 角色包含: -- [特权](/sql-reference/statements/grant#privileges) +- [权限](/sql-reference/statements/grant#privileges) - 设置和约束 -- 已分配角色的列表 +- 分配角色的列表 管理查询: @@ -110,14 +111,14 @@ ClickHouse 访问实体: - [SHOW CREATE ROLE](/sql-reference/statements/show#show-create-role) - [SHOW ROLES](/sql-reference/statements/show#show-roles) -可以通过 [GRANT](/sql-reference/statements/grant.md) 查询授予角色特权。要从角色中撤销权限,ClickHouse 提供了 [REVOKE](/sql-reference/statements/revoke.md) 查询。 +可以通过 [GRANT](/sql-reference/statements/grant.md) 查询授予角色权限。要从角色中撤销权限,ClickHouse 提供 [REVOKE](/sql-reference/statements/revoke.md) 查询。 #### 行策略 {#row-policy-management} -行策略是定义用户或角色可用哪些行的过滤器。行策略包含针对特定表的过滤器,以及应使用此行策略的角色和/或用户列表。 +行策略是一个过滤器,定义哪些行可以被用户或角色访问。行策略包含一个特定表的过滤器,以及应使用该行策略的角色和/或用户列表。 :::note -行策略仅对具有只读访问权限的用户有意义。如果用户可以修改表或在表之间复制分区,则这会破坏行策略的限制。 +行政策仅对具有只读访问权限的用户有意义。如果用户可以修改表或在表之间复制分区,则这会破坏行政策的限制。 ::: 管理查询: @@ -130,7 +131,7 @@ ClickHouse 访问实体: ### 设置配置文件 {#settings-profiles-management} -设置配置文件是一组 [设置](/operations/settings/index.md)。设置配置文件包含设置和约束,以及一个角色和/或用户列表,这些角色和/或用户应用此配置文件。 +设置配置文件是一组 [设置](/operations/settings/index.md)。设置配置文件包含设置和约束,以及适用该配置文件的角色和/或用户列表。 管理查询: @@ -142,9 +143,9 @@ ClickHouse 访问实体: ### 配额 {#quotas-management} -配额限制资源的使用。参见 [Quotas](/operations/quotas.md)。 +配额限制资源使用。请参阅 [配额](/operations/quotas.md)。 -配额包含一组限额,适用于某些时间段,以及一个角色和/或用户列表,这些角色和/或用户应使用此配额。 +配额包含某些时段的一组限制,以及应使用该配额的角色和/或用户列表。 管理查询: @@ -155,16 +156,15 @@ ClickHouse 访问实体: - [SHOW QUOTA](/sql-reference/statements/show#show-quota) - [SHOW QUOTAS](/sql-reference/statements/show#show-quotas) -### 启用 SQL 驱动的访问控制和账户管理 {#enabling-access-control} +### 启用基于 SQL 的访问控制和账户管理 {#enabling-access-control} -- 设置用于配置存储的目录。 +- 设置配置存储目录。 - ClickHouse 将访问实体配置存储在由 [access_control_path](/operations/server-configuration-parameters/settings.md#access_control_path) 服务器配置参数设置的文件夹中。 + ClickHouse 将访问实体的配置存储在 [access_control_path](/operations/server-configuration-parameters/settings.md#access_control_path) 服务器配置参数所设置的文件夹中。 -- 为至少一个用户账户启用 SQL 驱动的访问控制和账户管理。 - - 默认情况下,所有用户的 SQL 驱动访问控制和账户管理都被禁用。您需要在 `users.xml` 配置文件中配置至少一个用户,并将 [`access_management`](/operations/settings/settings-users.md#access_management-user-setting)、`named_collection_control`、`show_named_collections` 和 `show_named_collections_secrets` 设置的值设置为 1。 +- 为至少一个用户账户启用基于 SQL 的访问控制和账户管理。 + 默认情况下,对所有用户禁用基于 SQL 的访问控制和账户管理。您需要在 `users.xml` 配置文件中配置至少一个用户,并将 [`access_management`](/operations/settings/settings-users.md#access_management-user-setting)、`named_collection_control`、`show_named_collections` 和 `show_named_collections_secrets` 的值设置为 1。 ## 定义 SQL 用户和角色 {#defining-sql-users-and-roles} @@ -172,7 +172,7 @@ ClickHouse 访问实体: 如果您在 ClickHouse Cloud 中工作,请查看 [Cloud access management](/cloud/security/cloud-access-management)。 ::: -本文展示了定义 SQL 用户和角色的基本知识,并将这些特权和权限应用于数据库、表、行和列。 +本文介绍了定义 SQL 用户和角色的基本知识,以及如何将这些权限和权限应用于数据库、表、行和列。 ### 启用 SQL 用户模式 {#enabling-sql-user-mode} @@ -185,14 +185,14 @@ ClickHouse 访问实体: ``` :::note - `default` 用户是唯一一个在新安装时创建的用户,并且默认用于节点间通信的账户。 + `default` 用户是唯一在新安装时创建的用户,也是默认用于节点间通信的账户。 - 在生产环境中,建议在使用 SQL 管理用户配置了节点间通信后禁用此用户,并同时配置了 ``、集群凭据和/或节点间 HTTP 和传输协议凭据,因为 `default` 账户用于节点间通信。 + 在生产环境中,建议在使用 SQL 管理用户配置节点间通信后禁用该用户,并将节点间通信配置为 ``、集群凭据和/或节点间 HTTP 和传输协议凭据,因为 `default` 账户用于节点间通信。 ::: -2. 重启节点以应用更改。 +2. 重启节点以应用更改。 -3. 启动 ClickHouse 客户端: +3. 启动 ClickHouse 客户端: ```sql clickhouse-client --user default --password ``` @@ -207,14 +207,14 @@ CREATE USER clickhouse_admin IDENTIFIED BY 'password'; GRANT ALL ON *.* TO clickhouse_admin WITH GRANT OPTION; ``` -## ALTER 权限 {#alter-permissions} +## 修改权限 {#alter-permissions} -本文旨在帮助您更好地理解如何定义权限,以及在使用 `ALTER` 语句时特权用户如何工作。 +本文旨在帮助您更好地理解如何定义权限,以及在使用 `ALTER` 语句为特权用户时权限如何工作。 -`ALTER` 语句分为几类,其中一些是分层的,而另一些不是,必须显式定义。 +`ALTER` 语句分为几个类别,其中一些是分层的,而另一些则不是,必须明确定义。 **示例数据库、表和用户配置** -1. 使用管理员用户创建一个示例用户 +1. 以管理员用户身份创建一个示例用户 ```sql CREATE USER my_user IDENTIFIED BY 'password'; ``` @@ -235,15 +235,15 @@ CREATE USER my_alter_admin IDENTIFIED BY 'password'; ``` :::note -要授予或撤销权限,管理员用户必须具有 `WITH GRANT OPTION` 特权。 +要授予或撤销权限,管理员用户必须具有 `WITH GRANT OPTION` 权限。 例如: ```sql GRANT ALTER ON my_db.* WITH GRANT OPTION ``` -要 `GRANT` 或 `REVOKE` 权限,用户必须首先拥有这些权限。 +要 `GRANT` 或 `REVOKE` 权限,用户必须首先自己拥有这些权限。 ::: -**授予或撤销特权** +**授予或撤销权限** `ALTER` 层次结构: @@ -290,13 +290,13 @@ GRANT ALTER ON my_db.* WITH GRANT OPTION 使用 `GRANT ALTER on *.* TO my_user` 只会影响顶层的 `ALTER TABLE` 和 `ALTER VIEW`,其他 `ALTER` 语句必须单独授予或撤销。 -例如,授予基本的 `ALTER` 权限: +例如,授予基本 `ALTER` 权限: ```sql GRANT ALTER ON my_db.my_table TO my_user; ``` -生成的权限集: +由此得到的权限集: ```sql SHOW GRANTS FOR my_user; @@ -312,9 +312,9 @@ Query id: 706befbc-525e-4ec1-a1a2-ba2508cc09e3 └──────────────────────────────────────────────────────────────┘ ``` -这将授予上述示例中 `ALTER TABLE` 和 `ALTER VIEW` 下的所有权限,但是,它不会授予其他某些 `ALTER` 权限,例如 `ALTER ROW POLICY`(请参阅层次结构,您会看到 `ALTER ROW POLICY` 不是 `ALTER TABLE` 或 `ALTER VIEW` 的子项)。这些必须显式地授予或撤销。 +这将授予来自上例中的 `ALTER TABLE` 和 `ALTER VIEW` 下的所有权限,然而,它不会授予其他某些 `ALTER` 权限,例如 `ALTER ROW POLICY`(返回查看层次结构,您会看到 `ALTER ROW POLICY` 不是 `ALTER TABLE` 或 `ALTER VIEW` 的子项)。那些必须显式授予或撤销。 -如果只需要 `ALTER` 权限的子集,则可分别授予每个权限,如果该权限有子特权,则这些子特权也会自动授予。 +如果只需要 `ALTER` 权限的一个子集,则可以单独授予每个权限,如果该权限有子权限,则这些子权限也会自动授予。 例如: @@ -322,7 +322,7 @@ Query id: 706befbc-525e-4ec1-a1a2-ba2508cc09e3 GRANT ALTER COLUMN ON my_db.my_table TO my_user; ``` -权限将被设置为: +授予将被设置为: ```sql SHOW GRANTS FOR my_user; @@ -340,7 +340,7 @@ Query id: 47b3d03f-46ac-4385-91ec-41119010e4e2 1 row in set. Elapsed: 0.004 sec. ``` -这还会提供以下子特权: +这还赋予以下子权限: ```sql ALTER ADD COLUMN @@ -353,11 +353,11 @@ ALTER RENAME COLUMN 2. 从用户和角色撤销 `ALTER` 权限 -`REVOKE` 语句的工作方式与 `GRANT` 语句类似。 +`REVOKE` 语句与 `GRANT` 语句的工作方式类似。 -如果用户/角色被授予了子特权,则可以直接撤销该子特权,或者撤销其继承的更高层特权。 +如果用户/角色被授予了子权限,您可以直接撤销该子权限,或撤销更高层的权限。 -例如,如果用户被授予 `ALTER ADD COLUMN` +例如,如果用户被授予了 `ALTER ADD COLUMN` ```sql GRANT ALTER ADD COLUMN ON my_db.my_table TO my_user; @@ -387,13 +387,13 @@ Query id: 27791226-a18f-46c8-b2b4-a9e64baeb683 └─────────────────────────────────────────────────────┘ ``` -可以单独撤销特权: +权限可以单独被撤销: ```sql REVOKE ALTER ADD COLUMN ON my_db.my_table FROM my_user; ``` -或者可以从任何上级撤销(撤销所有列子特权): +或可以从任何上层撤销(撤销所有的 COLUMN 子权限): ```response REVOKE ALTER COLUMN ON my_db.my_table FROM my_user; @@ -423,18 +423,18 @@ Ok. 0 rows in set. Elapsed: 0.003 sec. ``` -**附加** +**补充** -特权必须由不仅具有 `WITH GRANT OPTION` 权限的用户授予,还必须拥有特权本身。 +权限必须由不仅具有 `WITH GRANT OPTION` 权限,同时也拥有权限的用户授予。 -1. 要授予管理员用户权限,同时允许他们管理一组权限 +1. 要授予管理员用户权限,并允许他们管理一组权限 以下是一个示例: ```sql GRANT SELECT, ALTER COLUMN ON my_db.my_table TO my_alter_admin WITH GRANT OPTION; ``` -现在,该用户可以授予或撤销 `ALTER COLUMN` 和所有子特权。 +现在该用户可以授予或撤销 `ALTER COLUMN` 和所有子权限。 **测试** @@ -453,7 +453,7 @@ GRANT ADD COLUMN ON my_db.my_table TO my_user; clickhouse-client --user my_user --password password --port 9000 --host ``` -4. 测试添加一列 +4. 测试添加列 ```sql ALTER TABLE my_db.my_table ADD COLUMN column2 String; ``` @@ -485,7 +485,7 @@ Query id: ab9cb2d0-5b1a-42e1-bc9c-c7ff351cb272 └─────────┴────────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┘ ``` -4. 测试删除一列 +4. 测试删除列 ```sql ALTER TABLE my_db.my_table DROP COLUMN column2; ``` @@ -496,24 +496,23 @@ ALTER TABLE my_db.my_table Query id: 50ad5f6b-f64b-4c96-8f5f-ace87cea6c47 - 0 rows in set. Elapsed: 0.004 sec. Received exception from server (version 22.5.1): Code: 497. DB::Exception: Received from chnode1.marsnet.local:9440. DB::Exception: my_user: Not enough privileges. To execute this query it's necessary to have grant ALTER DROP COLUMN(column2) ON my_db.my_table. (ACCESS_DENIED) ``` -5. 测试通过授予权限来测试更改管理员 +5. 通过授予权限测试修改管理员 ```sql GRANT SELECT, ALTER COLUMN ON my_db.my_table TO my_alter_admin WITH GRANT OPTION; ``` -6. 使用更改管理员用户登录 +6. 使用修改管理员用户登录 ```bash clickhouse-client --user my_alter_admin --password password --port 9000 --host ``` -7. 授予子特权 +7. 授予子权限 ```sql GRANT ALTER ADD COLUMN ON my_db.my_table TO my_user; ``` @@ -526,7 +525,7 @@ Query id: 1c7622fa-9df1-4c54-9fc3-f984c716aeba Ok. ``` -8. 测试授予权限,该更改管理员用户没有的权限不是管理员用户的授予子权限。 +8. 测试授予的权限是否为修改管理员用户不具备的,而不是管理员用户授权的子权限。 ```sql GRANT ALTER UPDATE ON my_db.my_table TO my_user; ``` @@ -536,7 +535,6 @@ GRANT ALTER UPDATE ON my_db.my_table TO my_user Query id: 191690dc-55a6-4625-8fee-abc3d14a5545 - 0 rows in set. Elapsed: 0.004 sec. Received exception from server (version 22.5.1): @@ -544,4 +542,4 @@ Code: 497. DB::Exception: Received from chnode1.marsnet.local:9440. DB::Exceptio ``` **总结** -对于 `ALTER`,权限在表和视图中是分层的,但对于其他 `ALTER` 语句则不是。权限可以以细粒度设置或按权限分组设置,并且可以以类似方式撤销。授予或撤销的用户必须具有 `WITH GRANT OPTION` 以在用户上设置权限,包括实际用户本身,并且必须已经拥有该权限。如果执行用户没有自己的授予选项权限,则不能撤销自己的权限。 +`ALTER` 权限对于 `ALTER` 表和视图是分层的,但对于其他 `ALTER` 语句则不是。权限可以以粒度级别设置或通过权限组进行设置,并且可以以类似的方式进行撤销。授予或撤销的用户必须具有 `WITH GRANT OPTION` 来设置用户权限,包括正在操作的用户自身,并且必须已经拥有该权限。如果正在操作的用户没有授予权限,不能撤销自己的权限。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/sre/user-management/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/sre/user-management/index.md.hash index 36876786bab..85437649415 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/sre/user-management/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/sre/user-management/index.md.hash @@ -1 +1 @@ -6917ecc06b94e582 +04b2a6adbece2e9f diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/sre/user-management/ssl-user-auth.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/sre/user-management/ssl-user-auth.md index 7478f3b9408..8650885e310 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/sre/user-management/ssl-user-auth.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/sre/user-management/ssl-user-auth.md @@ -2,51 +2,52 @@ 'sidebar_label': 'SSL 用户证书身份验证' 'sidebar_position': 3 'slug': '/guides/sre/ssl-user-auth' -'title': '配置 SSL 用户证书用于身份验证' -'description': '本指南提供简单和最低限度的设置,以使用 SSL 用户证书配置身份验证。' +'title': '配置 SSL 用户证书进行身份验证' +'description': '本指南提供简单的最小设置,以便使用 SSL 用户证书配置身份验证。' +'doc_type': 'guide' --- import SelfManaged from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_self_managed_only_no_roadmap.md'; -# 配置 SSL 用户证书进行认证 +# 配置用于身份验证的 SSL 用户证书 -本指南提供了简单且最小化的设置以配置使用 SSL 用户证书进行认证。该教程基于[配置 SSL-TLS 用户指南](../configuring-ssl.md)。 +本指南提供了简单且最小的设置来配置使用 SSL 用户证书进行身份验证。该教程基于 [配置 SSL-TLS 用户指南](../configuring-ssl.md)。 :::note -在使用 `https`、`native`、`mysql` 和 `postgresql` 接口时支持 SSL 用户认证。 +在使用 `https`、`native`、`mysql` 和 `postgresql` 接口时,支持 SSL 用户身份验证。 -ClickHouse 节点需要设置 `strict` 以实现安全认证(尽管 `relaxed` 在测试目的时是可行的)。 +ClickHouse 节点需要设置 `strict` 以实现安全身份验证(尽管 `relaxed` 在测试时也可以工作)。 -如果您使用 AWS NLB 与 MySQL 接口,您需要联系 AWS 支持以启用未 documented 的选项: +如果您在 MySQL 接口上使用 AWS NLB,您必须请求 AWS 支持启用未记录的选项: -> 我希望能够像下面这样配置我们的 NLB 代理协议 v2 `proxy_protocol_v2.client_to_server.header_placement,Value=on_first_ack`。 +> 我希望能够将我们的 NLB 代理协议 v2 配置为 `proxy_protocol_v2.client_to_server.header_placement,Value=on_first_ack`。 ::: ## 1. 创建 SSL 用户证书 {#1-create-ssl-user-certificates} :::note -本示例使用自签名证书和自签名 CA。对于生产环境,请创建 CSR 并提交给您的 PKI 团队或证书提供商以获取适当的证书。 +此示例使用自签名证书和自签名 CA。对于生产环境,请创建 CSR 并提交给您的 PKI 团队或证书提供商以获得适当的证书。 ::: -1. 生成证书签署请求 (CSR) 和密钥。基本格式如下: +1. 生成证书签名请求(CSR)和密钥。基本格式如下: ```bash openssl req -newkey rsa:2048 -nodes -subj "/CN=:" -keyout .key -out .csr ``` - 在此示例中,我们将为该示例环境中将使用的域和用户使用此内容: + 在本示例中,我们将在此示例环境中使用此域和用户: ```bash openssl req -newkey rsa:2048 -nodes -subj "/CN=chnode1.marsnet.local:cert_user" -keyout chnode1_cert_user.key -out chnode1_cert_user.csr ``` :::note - CN 是任意的,任何字符串都可以用作证书的标识符。它将在创建用户的以下步骤中使用。 + CN 是任意的,可以使用任何字符串作为证书的标识符。在以下步骤创建用户时会使用到它。 ::: -2. 生成并签署将用于认证的新用户证书。基本格式如下: +2. 生成并签署将用于身份验证的新用户证书。基本格式如下: ```bash openssl x509 -req -in .csr -out .crt -CA .crt -CAkey .key -days 365 ``` - 在此示例中,我们将为该示例环境中将使用的域和用户使用此内容: + 在本示例中,我们将在此示例环境中使用此域和用户: ```bash openssl x509 -req -in chnode1_cert_user.csr -out chnode1_cert_user.crt -CA marsnet_ca.crt -CAkey marsnet_ca.key -days 365 ``` @@ -54,24 +55,24 @@ openssl x509 -req -in chnode1_cert_user.csr -out chnode1_cert_user.crt -CA marsn ## 2. 创建 SQL 用户并授予权限 {#2-create-a-sql-user-and-grant-permissions} :::note -有关如何启用 SQL 用户和设置角色的详细信息,请参阅[定义 SQL 用户和角色](index.md) 用户指南。 +有关如何启用 SQL 用户和设置角色的详细信息,请参阅 [定义 SQL 用户和角色](index.md) 用户指南。 ::: -1. 创建一个 SQL 用户,定义为使用证书认证: +1. 创建一个定义为使用证书身份验证的 SQL 用户: ```sql CREATE USER cert_user IDENTIFIED WITH ssl_certificate CN 'chnode1.marsnet.local:cert_user'; ``` -2. 授予新证书用户权限: +2. 向新证书用户授予权限: ```sql GRANT ALL ON *.* TO cert_user WITH GRANT OPTION; ``` :::note - 在本练习中,出于演示目的,用户被授予完全的管理员权限。有关权限设置,请参考 ClickHouse [RBAC 文档](/guides/sre/user-management/index.md)。 + 在此练习中,为了演示目的,该用户被授予完全管理权限。有关权限设置,请参阅 ClickHouse [RBAC 文档](/guides/sre/user-management/index.md)。 ::: :::note - 我们建议使用 SQL 定义用户和角色。然而,如果您当前在配置文件中定义用户和角色,则用户将如下所示: + 我们建议使用 SQL 来定义用户和角色。然而,如果您当前在配置文件中定义用户和角色,则用户将如下所示: ```xml @@ -89,12 +90,11 @@ GRANT ALL ON *.* TO cert_user WITH GRANT OPTION; ``` ::: - ## 3. 测试 {#3-testing} 1. 将用户证书、用户密钥和 CA 证书复制到远程节点。 -2. 在 ClickHouse [客户端配置](/interfaces/cli.md#configuration_files) 中配置 OpenSSL,并设置证书和路径。 +2. 在 ClickHouse [客户端配置](/interfaces/cli.md#configuration_files) 中配置 OpenSSL,并指定证书和路径。 ```xml @@ -111,15 +111,14 @@ GRANT ALL ON *.* TO cert_user WITH GRANT OPTION; clickhouse-client --user --query 'SHOW TABLES' ``` :::note - 请注意,当在配置中指定证书时,传递给 clickhouse-client 的密码会被忽略。 + 请注意,当在配置中指定证书时,传递给 clickhouse-client 的密码将被忽略。 ::: - ## 4. 测试 HTTP {#4-testing-http} 1. 将用户证书、用户密钥和 CA 证书复制到远程节点。 -2. 使用 `curl` 测试一个示例 SQL 命令。基本格式如下: +2. 使用 `curl` 测试示例 SQL 命令。基本格式如下: ```bash echo 'SHOW TABLES' | curl 'https://:8443' --cert .crt --key .key --cacert .crt -H "X-ClickHouse-SSL-Certificate-Auth: on" -H "X-ClickHouse-User: " --data-binary @- ``` @@ -135,10 +134,9 @@ information_schema system ``` :::note - 请注意,没有指定密码,证书用于替代密码,并且是 ClickHouse 认证用户的方式。 + 请注意,没有指定密码,证书用于替代密码,并且 ClickHouse 将使用该证书验证用户身份。 ::: +## 摘要 {#summary} -## 总结 {#summary} - -本文展示了创建和配置 SSL 证书认证用户的基础知识。此方法可以与 `clickhouse-client` 或任何支持 `https` 接口且可以设置 HTTP 头的客户端一起使用。生成的证书和密钥应保持私密并限制访问,因为证书用于认证和授权用户在 ClickHouse 数据库上的操作。将证书和密钥视为密码对待。 +本文展示了为 SSL 证书身份验证创建和配置用户的基本知识。此方法可以与 `clickhouse-client` 或任何支持 `https` 接口并且可以设置 HTTP 头的客户端一起使用。生成的证书和密钥应保持私密并有限制访问,因为证书用于验证和授权用户在 ClickHouse 数据库上的操作。请将证书和密钥视为密码对待。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/sre/user-management/ssl-user-auth.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/sre/user-management/ssl-user-auth.md.hash index 38838f83536..131604726b4 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/sre/user-management/ssl-user-auth.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/sre/user-management/ssl-user-auth.md.hash @@ -1 +1 @@ -d14411943b5aef88 +a3adb5b105e5ac6f diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/troubleshooting.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/troubleshooting.md index cc4fba8f84b..359a06d724c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/troubleshooting.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/troubleshooting.md @@ -2,36 +2,37 @@ 'title': '故障排除' 'description': '安装故障排除指南' 'slug': '/guides/troubleshooting' +'doc_type': 'guide' --- ## 安装 {#installation} -### 使用 apt-key 无法从 keyserver.ubuntu.com 导入 GPG 密钥 {#cannot-import-gpg-keys-from-keyserverubuntucom-with-apt-key} +### 无法通过 apt-key 从 keyserver.ubuntu.com 导入 GPG 密钥 {#cannot-import-gpg-keys-from-keyserverubuntucom-with-apt-key} -`apt-key` 功能已经被 [高级包工具(APT)弃用](https://manpages.debian.org/bookworm/apt/apt-key.8.en.html)。用户应使用 `gpg` 命令。请参阅 [安装指南](../getting-started/install/install.mdx) 文章。 +`apt-key` 功能已被 [高级包工具(APT)弃用](https://manpages.debian.org/bookworm/apt/apt-key.8.en.html)。用户应使用 `gpg` 命令。请参阅 [安装指南](../getting-started/install/install.mdx) 文章。 -### 使用 gpg 无法从 keyserver.ubuntu.com 导入 GPG 密钥 {#cannot-import-gpg-keys-from-keyserverubuntucom-with-gpg} +### 无法通过 gpg 从 keyserver.ubuntu.com 导入 GPG 密钥 {#cannot-import-gpg-keys-from-keyserverubuntucom-with-gpg} -1. 查看是否已安装 `gpg`: +1. 查看您的 `gpg` 是否已安装: ```shell sudo apt-get install gnupg ``` -### 无法使用 apt-get 从 ClickHouse 仓库获取 deb 包 {#cannot-get-deb-packages-from-clickhouse-repository-with-apt-get} +### 无法通过 apt-get 从 ClickHouse 仓库获取 deb 包 {#cannot-get-deb-packages-from-clickhouse-repository-with-apt-get} 1. 检查防火墙设置。 -1. 如果由于某种原因无法访问仓库,请按照 [安装指南](../getting-started/install/install.mdx) 文章中所述下载软件包,并使用 `sudo dpkg -i ` 命令手动安装它们。您还需要 `tzdata` 包。 +1. 如果由于某种原因无法访问仓库,请按照 [安装指南](../getting-started/install/install.mdx) 文章中的描述下载包并使用 `sudo dpkg -i ` 命令手动安装它们。您还需要 `tzdata` 包。 -### 无法使用 apt-get 从 ClickHouse 仓库更新 deb 包 {#cannot-update-deb-packages-from-clickhouse-repository-with-apt-get} +### 无法通过 apt-get 更新 ClickHouse 仓库中的 deb 包 {#cannot-update-deb-packages-from-clickhouse-repository-with-apt-get} -当 GPG 密钥更改时,可能会出现此问题。 +当 GPG 密钥更改时,可能会发生此问题。 -请使用 [设置](/install/debian_ubuntu) 页面中的手册更新仓库配置。 +请使用 [设置](/install/debian_ubuntu) 页面中的手册来更新仓库配置。 -### 使用 `apt-get update` 时出现不同的警告 {#you-get-different-warnings-with-apt-get-update} +### 您在使用 `apt-get update` 时收到不同的警告 {#you-get-different-warnings-with-apt-get-update} -完整的警告消息如下: +完成的警告信息为以下之一: ```shell N: Skipping acquire of configured file 'main/binary-i386/Packages' as repository 'https://packages.clickhouse.com/deb stable InRelease' doesn't support architecture 'i386' @@ -53,7 +54,7 @@ Err:11 https://packages.clickhouse.com/deb stable InRelease 400 Bad Request [IP: 172.66.40.249 443] ``` -要解决上述问题,请使用以下脚本: +为了解决上述问题,请使用以下脚本: ```shell sudo rm /var/lib/apt/lists/packages.clickhouse.com_* /var/lib/dpkg/arch /var/lib/apt/lists/partial/packages.clickhouse.com_* @@ -61,18 +62,18 @@ sudo apt-get clean sudo apt-get autoclean ``` -### 因签名错误无法使用 Yum 获取软件包 {#cant-get-packages-with-yum-because-of-wrong-signature} +### 由于签名错误无法通过 Yum 获取包 {#cant-get-packages-with-yum-because-of-wrong-signature} -可能的问题:缓存错误,可能是在 2022-09 更新 GPG 密钥后损坏。 +可能的问题:缓存错误,可能在 2022-09 更新 GPG 密钥后损坏。 -解决方案是清理 Yum 的缓存和库目录: +解决方案是清除 Yum 的缓存和 lib 目录: ```shell sudo find /var/lib/yum/repos/ /var/cache/yum/ -name 'clickhouse-*' -type d -exec rm -rf {} + sudo rm -f /etc/yum.repos.d/clickhouse.repo ``` -之后请按照 [安装指南](/install/redhat) 进行操作。 +之后按照 [安装指南](/install/redhat) 操作 ## 连接到服务器 {#connecting-to-the-server} @@ -97,26 +98,26 @@ sudo service clickhouse-server start #### 检查日志 {#check-the-logs} -`clickhouse-server` 的主日志默认位于 `/var/log/clickhouse-server/clickhouse-server.log`。 +`clickhouse-server` 的主要日志默认位于 `/var/log/clickhouse-server/clickhouse-server.log`。 如果服务器成功启动,您应该看到以下字符串: - ` Application: starting up.` — 服务器已启动。 - ` Application: Ready for connections.` — 服务器正在运行并准备接受连接。 -如果 `clickhouse-server` 由于配置错误启动失败,您应该看到带有错误描述的 `` 字符串。例如: +如果 `clickhouse-server` 启动失败并出现配置错误,您应该看到 `` 字符串及其错误描述。例如: ```plaintext 2019.01.11 15:23:25.549505 [ 45 ] {} ExternalDictionaries: Failed reloading 'event2id' external dictionary: Poco::Exception. Code: 1000, e.code() = 111, e.displayText() = Connection refused, e.what() = Connection refused ``` -如果您在文件末尾未看到错误,请从以下字符串开始筛查整个文件: +如果在文件末尾未看到错误,请从字符串开始查看整个文件: ```plaintext Application: starting up. ``` -如果您尝试在服务器上启动第二个 `clickhouse-server` 实例,您会看到以下日志: +如果您尝试在服务器上启动第二个 `clickhouse-server` 实例,您将看到以下日志: ```plaintext 2019.01.11 15:25:11.151730 [ 1 ] {} : Starting ClickHouse 19.1.0 with revision 54413 @@ -134,19 +135,19 @@ Revision: 54413 #### 查看 system.d 日志 {#see-systemd-logs} -如果您在 `clickhouse-server` 日志中没有找到任何有用的信息或没有日志,您可以使用以下命令查看 `system.d` 日志: +如果您在 `clickhouse-server` 日志中没有找到任何有用的信息,或者没有任何日志,可以使用以下命令查看 `system.d` 日志: ```shell sudo journalctl -u clickhouse-server ``` -#### 以交互模式启动 clickhouse-server {#start-clickhouse-server-in-interactive-mode} +#### 在交互模式下启动 clickhouse-server {#start-clickhouse-server-in-interactive-mode} ```shell sudo -u clickhouse /usr/bin/clickhouse-server --config-file /etc/clickhouse-server/config.xml ``` -此命令以交互应用程序的形式启动服务器,并使用自动启动脚本的标准参数。在此模式下,`clickhouse-server` 会在控制台中打印所有事件消息。 +此命令将服务器作为交互式应用程序使用自启动脚本的标准参数启动。在此模式下,`clickhouse-server` 会在控制台中打印所有事件消息。 ### 配置参数 {#configuration-parameters} @@ -154,11 +155,11 @@ sudo -u clickhouse /usr/bin/clickhouse-server --config-file /etc/clickhouse-serv 1. Docker 设置: - - 如果您在 IPv6 网络中运行 ClickHouse,请确保设置 `network=host`。 + - 如果您在 IPv6 网络中运行 ClickHouse,请确保设置了 `network=host`。 1. 端点设置。 - 检查 [listen_host](/operations/server-configuration-parameters/settings#listen_host) 和 [tcp_port](/operations/server-configuration-parameters/settings#tcp_port) 设置。 - - 默认情况下,ClickHouse 服务器仅接受本地主机连接。 + - 默认情况下,ClickHouse 服务器仅接受 localhost 连接。 1. HTTP 协议设置: @@ -169,15 +170,15 @@ sudo -u clickhouse /usr/bin/clickhouse-server --config-file /etc/clickhouse-serv - 检查: - [tcp_port_secure](/operations/server-configuration-parameters/settings#tcp_port_secure) 设置。 - [SSL 证书](/operations/server-configuration-parameters/settings#openssl) 的设置。 - - 连接时使用正确的参数。例如,使用 `clickhouse_client` 的 `port_secure` 参数。 + - 连接时使用正确的参数。例如,使用 `port_secure` 参数与 `clickhouse_client`。 1. 用户设置: - - 可能使用了错误的用户名或密码。 + - 您可能使用了错误的用户名或密码。 ## 查询处理 {#query-processing} -如果 ClickHouse 无法处理查询,它会向客户端发送错误描述。在 `clickhouse-client` 中,您将在控制台中获得错误描述。如果使用 HTTP 接口,ClickHouse 会在响应体中发送错误描述。例如: +如果 ClickHouse 无法处理查询,它会向客户端发送错误描述。在 `clickhouse-client` 中,您将在控制台中获得错误描述。如果您使用 HTTP 接口,ClickHouse 会在响应体中发送错误描述。例如: ```shell $ curl 'http://localhost:8123/' --data-binary "SELECT a" @@ -186,10 +187,10 @@ Code: 47, e.displayText() = DB::Exception: Unknown identifier: a. Note that ther 如果您使用 `stack-trace` 参数启动 `clickhouse-client`,ClickHouse 将返回带有错误描述的服务器堆栈跟踪。 -您可能会看到关于连接中断的消息。在这种情况下,您可以重复查询。如果每次执行查询时连接都中断,请检查服务器日志中的错误。 +您可能会看到有关连接中断的消息。在这种情况下,您可以重复该查询。如果每次执行查询时连接都中断,请检查服务器日志中的错误。 ## 查询处理的效率 {#efficiency-of-query-processing} -如果您发现 ClickHouse 工作得很慢,需要对服务器资源和网络进行负载分析,以优化您的查询。 +如果您发现 ClickHouse 工作缓慢,则需要分析服务器资源和网络的负载以优化查询。 -您可以使用 clickhouse-benchmark 工具来分析查询。它显示每秒处理的查询数量、每秒处理的行数以及查询处理时间的百分位数。 +您可以使用 clickhouse-benchmark 工具来分析查询。它显示每秒处理的查询次数、每秒处理的行数以及查询处理时间的分位数。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/troubleshooting.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/troubleshooting.md.hash index dead6aad5a5..dee498795a6 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/troubleshooting.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/troubleshooting.md.hash @@ -1 +1 @@ -4b26882df651ae33 +bbb23eb135a72122 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/writing-queries.md b/i18n/zh/docusaurus-plugin-content-docs/current/guides/writing-queries.md index 161abd10509..36e5552bc86 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/writing-queries.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/writing-queries.md @@ -3,14 +3,15 @@ 'sidebar_label': '选择数据' 'title': '选择 ClickHouse 数据' 'slug': '/guides/writing-queries' -'description': '了解有关 Selecting ClickHouse Data 的内容' +'description': '了解关于 Selecting ClickHouse Data' 'keywords': - 'SELECT' - 'data formats' 'show_related_blogs': true +'doc_type': 'guide' --- -ClickHouse 是一个 SQL 数据库,您可以通过编写您已经熟悉的 `SELECT` 查询来查询数据。例如: +ClickHouse 是一个 SQL 数据库,您可以通过编写您已经熟悉的相同类型的 `SELECT` 查询来查询您的数据。例如: ```sql SELECT * @@ -19,10 +20,10 @@ ORDER BY timestamp ``` :::note -查看 [SQL 参考](../sql-reference/statements/select/index.md) 以获取有关语法和可用子句及选项的更多详细信息。 +有关语法和可用子句及选项的更多详细信息,请查看 [SQL 参考](../sql-reference/statements/select/index.md)。 ::: -注意,响应以美观的表格格式返回: +请注意,响应以良好的表格格式返回: ```response ┌─user_id─┬─message────────────────────────────────────────────┬───────────timestamp─┬──metric─┐ @@ -35,7 +36,7 @@ ORDER BY timestamp 4 rows in set. Elapsed: 0.008 sec. ``` -添加一个 `FORMAT` 子句以指定 ClickHouse 支持的 [许多输出格式](../interfaces/formats.md) 中的一个: +添加一个 `FORMAT` 子句以指定 ClickHouse [支持的多种输出格式](../interfaces/formats.md) 之一: ```sql SELECT * FROM helloworld.my_first_table @@ -57,5 +58,5 @@ Query id: 3604df1c-acfd-4117-9c56-f86c69721121 ``` :::note -ClickHouse 支持超过 70 种输入和输出格式,因此在成千上万的函数和所有数据格式之间,您可以使用 ClickHouse 执行一些令人印象深刻且快速的 ETL 风格数据转换。实际上,您甚至不需要运行中的 ClickHouse 服务器来转换数据 - 您可以使用 `clickhouse-local` 工具。查看 [clickhouse-local 的文档页面](../operations/utilities/clickhouse-local.md) 以获取详细信息。 +ClickHouse 支持超过 70 种输入和输出格式,因此在数千个函数和所有数据格式之间,您可以使用 ClickHouse 执行一些令人印象深刻且快速的类似 ETL 的数据转换。事实上,您甚至不需要一个正在运行的 ClickHouse 服务器来转换数据 - 您可以使用 `clickhouse-local` 工具。有关 `clickhouse-local` 的详细信息,请查看 [文档页面](../operations/utilities/clickhouse-local.md)。 ::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/guides/writing-queries.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/guides/writing-queries.md.hash index 84d2d1e2001..5d4413a01e7 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/guides/writing-queries.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/guides/writing-queries.md.hash @@ -1 +1 @@ -53f0007ed60c17e7 +2d51a22a9fec22e1 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/cli.mdx b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/cli.mdx index 099d0e6235c..cc552a89af8 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/cli.mdx +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/cli.mdx @@ -4,7 +4,8 @@ 'title': 'clickhouse-client' 'slug': '/integrations/sql-clients/cli' 'displayed_sidebar': 'integrations' -'description': '页面描述 CLI 接口' +'description': '页面描述 CLI 界面' +'doc_type': 'reference' --- import Content from '@site/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/cli.md'; diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/cli.mdx.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/cli.mdx.hash index c9d883b4301..66baab841e5 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/cli.mdx.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/cli.mdx.hash @@ -1 +1 @@ -f1678b93e25bfcec +b7e76bc035e719e2 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/apache-spark/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/apache-spark/index.md index f83e14349b3..28e077ce198 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/apache-spark/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/apache-spark/index.md @@ -1,14 +1,15 @@ --- -'sidebar_label': '将Apache Spark与ClickHouse集成' +'sidebar_label': '将 Apache Spark 与 ClickHouse 集成' 'sidebar_position': 1 'slug': '/integrations/apache-spark' -'description': 'Apache Spark与ClickHouse的介绍' +'description': 'Apache Spark 与 ClickHouse 的介绍' 'keywords': - 'clickhouse' - 'Apache Spark' - 'migrating' - 'data' -'title': '将Apache Spark与ClickHouse集成' +'title': '将 Apache Spark 与 ClickHouse 集成' +'doc_type': 'guide' --- import Tabs from '@theme/Tabs'; @@ -22,11 +23,11 @@ import TOCInline from '@theme/TOCInline'; [Apache Spark](https://spark.apache.org/) 是一个多语言引擎,用于在单节点机器或集群上执行数据工程、数据科学和机器学习。 -将 Apache Spark 和 ClickHouse 连接的主要方式有两种: +连接 Apache Spark 和 ClickHouse 有两种主要方式: -1. [Spark Connector](./apache-spark/spark-native-connector) - Spark 连接器实现了 `DataSourceV2` 并具有自己的目录管理。截至目前,这是集成 ClickHouse 和 Spark 的推荐方式。 +1. [Spark Connector](./apache-spark/spark-native-connector) - Spark 连接器实现了 `DataSourceV2` 并拥有自己的目录管理。到目前为止, 这是集成 ClickHouse 和 Spark 的推荐方法。 2. [Spark JDBC](./apache-spark/spark-jdbc) - 使用 [JDBC 数据源](https://spark.apache.org/docs/latest/sql-data-sources-jdbc.html) 集成 Spark 和 ClickHouse。

-这两种解决方案均已成功测试,并与各种 API 完全兼容,包括 Java、Scala、PySpark 和 Spark SQL。 +这两种解决方案都已成功测试,并与 Java、Scala、PySpark 和 Spark SQL 等各种 API 完全兼容。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/apache-spark/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/apache-spark/index.md.hash index b32ae38e39b..6151ba57bd2 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/apache-spark/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/apache-spark/index.md.hash @@ -1 +1 @@ -ad7e56deb9684ee1 +ff87dc1cf9d5d1cd diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/apache-spark/spark-jdbc.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/apache-spark/spark-jdbc.md index a5a39220dde..17cf0c454fe 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/apache-spark/spark-jdbc.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/apache-spark/spark-jdbc.md @@ -2,7 +2,7 @@ 'sidebar_label': 'Spark JDBC' 'sidebar_position': 3 'slug': '/integrations/apache-spark/spark-jdbc' -'description': 'Apache Spark与ClickHouse的介绍' +'description': '有关 Apache Spark 和 ClickHouse 的介绍' 'keywords': - 'clickhouse' - 'Apache Spark' @@ -10,6 +10,7 @@ - 'migrating' - 'data' 'title': 'Spark JDBC' +'doc_type': 'guide' --- import Tabs from '@theme/Tabs'; @@ -18,8 +19,7 @@ import TOCInline from '@theme/TOCInline'; # Spark JDBC -JDBC 是 Spark 中最常用的数据源之一。 -在本节中,我们将提供有关如何在 Spark 中使用 [ClickHouse 官方 JDBC 连接器](/integrations/language-clients/java/jdbc) 的详细信息。 +JDBC 是 Spark 中最常用的数据源之一。在本节中,我们将提供有关如何使用 [ClickHouse 官方 JDBC 连接器](/integrations/language-clients/java/jdbc) 与 Spark 的详细信息。 @@ -36,7 +36,6 @@ public static void main(String[] args) { String jdbcURL = "jdbc:ch://localhost:8123/default"; String query = "select * from example_table where id > 2"; - //--------------------------------------------------------------------------------------------------- // Load the table from ClickHouse using jdbc method //--------------------------------------------------------------------------------------------------- @@ -59,10 +58,8 @@ public static void main(String[] args) { .option("query", query) .load(); - df2.show(); - // Stop the Spark session spark.stop(); } @@ -79,7 +76,6 @@ object ReadData extends App { val jdbcURL = "jdbc:ch://localhost:8123/default" val query: String = "select * from example_table where id > 2" - //--------------------------------------------------------------------------------------------------- // Load the table from ClickHouse using jdbc method //--------------------------------------------------------------------------------------------------- @@ -104,8 +100,6 @@ object ReadData extends App { df2.show() - - // Stop the Spark session// Stop the Spark session spark.stop() @@ -194,7 +188,6 @@ public static void main(String[] args) { rows.add(RowFactory.create(1, "John")); rows.add(RowFactory.create(2, "Doe")); - Dataset df = spark.createDataFrame(rows, schema); //--------------------------------------------------------------------------------------------------- @@ -218,7 +211,6 @@ public static void main(String[] args) { .option("password", "123456") .save(); - // Stop the Spark session spark.stop(); } @@ -240,7 +232,6 @@ object WriteData extends App { // Create a sample DataFrame - val rows = Seq(Row(1, "John"), Row(2, "Doe")) val schema = List( @@ -274,7 +265,6 @@ object WriteData extends App { .option("password", "123456") .save() - // Stop the Spark session// Stop the Spark session spark.stop() @@ -322,7 +312,6 @@ df.write \ .mode("append") \ .save() - ``` @@ -349,9 +338,8 @@ INSERT INTO TABLE jdbcTable ## 并行性 {#parallelism} -使用 Spark JDBC 时,Spark 使用单个分区读取数据。要实现更高的并发性,您必须指定 `partitionColumn`、`lowerBound`、`upperBound` 和 `numPartitions`,这些选项描述了如何在从多个工作节点并行读取时对表进行分区。 -有关更多信息,请访问 Apache Spark 的官方文档,了解 [JDBC 配置](https://spark.apache.org/docs/latest/sql-data-sources-jdbc.html#data-source-option)。 +使用 Spark JDBC 时,Spark 使用单个分区读取数据。为了实现更高的并发性,您必须指定 `partitionColumn`、`lowerBound`、`upperBound` 和 `numPartitions`,这些参数描述了在从多个工作节点并行读取时如何对表进行分区。有关更多信息,请访问 Apache Spark 的官方文档,了解 [JDBC 配置](https://spark.apache.org/docs/latest/sql-data-sources-jdbc.html#data-source-option)。 ## JDBC 限制 {#jdbc-limitations} -* 截至目前,您只能通过 JDBC 向现有表中插入数据(目前没有方法在 DF 插入时自动创建表,正如 Spark 在使用其他连接器时所做的那样)。 +* 到目前为止,您只能通过 JDBC 将数据插入现有表中(目前没有办法在数据帧插入时自动创建表,正如 Spark 与其他连接器所做的那样)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/apache-spark/spark-jdbc.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/apache-spark/spark-jdbc.md.hash index 1144b7581ea..3644063a8ad 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/apache-spark/spark-jdbc.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/apache-spark/spark-jdbc.md.hash @@ -1 +1 @@ -f7be0b9af2d201ad +8c30f02b283f3adf diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/apache-spark/spark-native-connector.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/apache-spark/spark-native-connector.md index ad79d2335ef..14c77d51304 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/apache-spark/spark-native-connector.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/apache-spark/spark-native-connector.md @@ -2,13 +2,14 @@ 'sidebar_label': 'Spark 原生连接器' 'sidebar_position': 2 'slug': '/integrations/apache-spark/spark-native-connector' -'description': '与 ClickHouse 的 Apache Spark 介绍' +'description': '介绍 Apache Spark 与 ClickHouse' 'keywords': - 'clickhouse' - 'Apache Spark' - 'migrating' - 'data' 'title': 'Spark 连接器' +'doc_type': 'guide' --- import Tabs from '@theme/Tabs'; @@ -18,39 +19,42 @@ import TOCInline from '@theme/TOCInline'; # Spark 连接器 -此连接器利用 ClickHouse 特定的优化,例如高级分区和谓词下推,以改善查询性能和数据处理。该连接器基于 [ClickHouse 的官方 JDBC 连接器](https://github.com/ClickHouse/clickhouse-java),并管理其自己的目录。 +此连接器利用 ClickHouse 特有的优化,比如高级分区和谓词下推,来提高查询性能和数据处理能力。 +该连接器基于 [ClickHouse 的官方 JDBC 连接器](https://github.com/ClickHouse/clickhouse-java),并管理自己的目录。 -在 Spark 3.0 之前,Spark 缺乏内置的目录概念,因此用户通常依赖外部目录系统,例如 Hive Metastore 或 AWS Glue。使用这些外部解决方案时,用户在访问 Spark 中的数据源表之前,必须手动注册它们。然而,自从 Spark 3.0 引入目录概念以来,Spark 现在可以通过注册目录插件自动发现表。 +在 Spark 3.0 之前,Spark 缺乏内置的目录概念,因此用户通常依赖于 Hive Metastore 或 AWS Glue 等外部目录系统。 +使用这些外部解决方案,用户必须在访问 Spark 中的数据源表之前手动注册它们。 +然而,由于 Spark 3.0 引入了目录概念,Spark 现在可以通过注册目录插件自动发现表。 -Spark 的默认目录是 `spark_catalog`,表通过 `{catalog name}.{database}.{table}` 来识别。使用新的目录功能,现在可以在单个 Spark 应用程序中添加和使用多个目录。 +Spark 的默认目录是 `spark_catalog`,表通过 `{catalog name}.{database}.{table}` 进行识别。 +借助新的目录功能,现在可以在单个 Spark 应用程序中添加和使用多个目录。 - -## 需求 {#requirements} +## 要求 {#requirements} - Java 8 或 17 - Scala 2.12 或 2.13 -- Apache Spark 3.3, 3.4 或 3.5 - +- Apache Spark 3.3、3.4 或 3.5 ## 兼容性矩阵 {#compatibility-matrix} -| 版本 | 兼容的 Spark 版本 | ClickHouse JDBC 版本 | -|-------|---------------------------|---------------------| -| main | Spark 3.3, 3.4, 3.5 | 0.6.3 | -| 0.8.1 | Spark 3.3, 3.4, 3.5 | 0.6.3 | -| 0.8.0 | Spark 3.3, 3.4, 3.5 | 0.6.3 | -| 0.7.3 | Spark 3.3, 3.4 | 0.4.6 | -| 0.6.0 | Spark 3.3 | 0.3.2-patch11 | -| 0.5.0 | Spark 3.2, 3.3 | 0.3.2-patch11 | -| 0.4.0 | Spark 3.2, 3.3 | 不依赖于 | -| 0.3.0 | Spark 3.2, 3.3 | 不依赖于 | -| 0.2.1 | Spark 3.2 | 不依赖于 | -| 0.1.2 | Spark 3.2 | 不依赖于 | - +| 版本 | 兼容的 Spark 版本 | ClickHouse JDBC 版本 | +|--------|---------------------------|----------------------| +| main | Spark 3.3、3.4、3.5 | 0.6.3 | +| 0.8.1 | Spark 3.3、3.4、3.5 | 0.6.3 | +| 0.8.0 | Spark 3.3、3.4、3.5 | 0.6.3 | +| 0.7.3 | Spark 3.3、3.4 | 0.4.6 | +| 0.6.0 | Spark 3.3 | 0.3.2-patch11 | +| 0.5.0 | Spark 3.2、3.3 | 0.3.2-patch11 | +| 0.4.0 | Spark 3.2、3.3 | 不依赖于 | +| 0.3.0 | Spark 3.2、3.3 | 不依赖于 | +| 0.2.1 | Spark 3.2 | 不依赖于 | +| 0.1.2 | Spark 3.2 | 不依赖于 | ## 安装与设置 {#installation--setup} -要将 ClickHouse 与 Spark 集成,有多种安装选项以适应不同的项目设置。您可以将 ClickHouse Spark 连接器作为依赖项直接添加到项目的构建文件中(例如在 Maven 的 `pom.xml` 或 SBT 的 `build.sbt` 中)。另外,您可以将所需的 JAR 文件放在 `$SPARK_HOME/jars/` 文件夹中,或在 `spark-submit` 命令中使用 `--jars` 选项直接传递它们。这两种方法都确保 ClickHouse 连接器在您的 Spark 环境中可用。 - +为了将 ClickHouse 与 Spark 集成,有多种安装选项以适应不同的项目设置。 +您可以将 ClickHouse Spark 连接器作为依赖项直接添加到项目的构建文件中(例如在 Maven 的 `pom.xml` 或 SBT 的 `build.sbt` 中)。 +另外,您可以将所需的 JAR 文件放入 `$SPARK_HOME/jars/` 文件夹中,或在 `spark-submit` 命令中通过 `--jars` 标志直接传递它们。 +这两种方法都确保 ClickHouse 连接器在您的 Spark 环境中可用。 ### 作为依赖项导入 {#import-as-a-dependency} @@ -76,7 +80,7 @@ Spark 的默认目录是 `spark_catalog`,表通过 `{catalog name}.{database}. ``` -如果您想使用 SNAPSHOT 版本,请添加以下存储库。 +如果要使用 SNAPSHOT 版本,请添加以下仓库。 ```maven @@ -98,7 +102,7 @@ dependencies { } ``` -如果您想使用 SNAPSHOT 版本,请添加以下存储库: +如果要使用 SNAPSHOT 版本,请添加以下仓库: ```gradle repositries { @@ -117,64 +121,64 @@ libraryDependencies += "com.clickhouse.spark" %% clickhouse-spark-runtime-{{ spa -在使用 Spark 的 shell 选项(Spark SQL CLI、Spark Shell CLI 和 Spark Submit 命令)时,可以通过传递所需的 JAR 来注册依赖项: +在使用 Spark 的 shell 选项(Spark SQL CLI、Spark Shell CLI 和 Spark Submit 命令)时,可以通过传递所需的 jars 注册依赖项: ```text $SPARK_HOME/bin/spark-sql \ --jars /path/clickhouse-spark-runtime-{{ spark_binary_version }}_{{ scala_binary_version }}:{{ stable_version }}.jar,/path/clickhouse-jdbc-{{ clickhouse_jdbc_version }}-all.jar ``` -如果您想避免将 JAR 文件复制到 Spark 客户端节点,可以使用以下命令: +如果您想避免将 JAR 文件复制到 Spark 客户端节点,可以改用以下方法: ```text --repositories https://{maven-central-mirror or private-nexus-repo} \ ---packages com.clickhouse.spark:clickhouse-spark-runtime-{{ spark_binary_version }}_{{ scala_binary_version }}:{{ stable_version }},com.clickhouse:clickhouse-jdbc:{{ clickhouse_jdbc_version }}:all +--packages com.clickhouse.spark:clickhouse-spark-runtime-{{ spark_binary_version }}_{{ scala_binary_version }}:{{ stable_version }},com.clickhouse:clickhouse-jdbc:{{ clickhouse_jdbc_version }} ``` -注意:对于仅使用 SQL 的用例,建议使用 [Apache Kyuubi](https://github.com/apache/kyuubi) 进行生产。 +注意:对于仅 SQL 的用例,建议使用 [Apache Kyuubi](https://github.com/apache/kyuubi) 进行生产。 - ### 下载库 {#download-the-library} -二进制 JAR 的名称模式为: +二进制 JAR 的名称模式是: ```bash clickhouse-spark-runtime-${spark_binary_version}_${scala_binary_version}-${version}.jar ``` -您可以在 [Maven Central Repository](https://repo1.maven.org/maven2/com/clickhouse/spark/) 中找到所有可用的发布 JAR 文件,以及在 [Sonatype OSS Snapshots Repository](https://s01.oss.sonatype.org/content/repositories/snapshots/com/clickhouse/) 中找到所有每日构建的 SNAPSHOT JAR 文件。 +您可以在 [Maven Central Repository](https://repo1.maven.org/maven2/com/clickhouse/spark/) 找到所有可用的已发布 JAR 文件,所有每日构建的 SNAPSHOT JAR 文件可在 [Sonatype OSS Snapshots Repository](https://s01.oss.sonatype.org/content/repositories/snapshots/com/clickhouse/) 找到。 -:::重要 -必须包含带有 "all" 分类器的 [clickhouse-jdbc JAR](https://mvnrepository.com/artifact/com.clickhouse/clickhouse-jdbc),因为连接器依赖于 [clickhouse-http](https://mvnrepository.com/artifact/com.clickhouse/clickhouse-http-client) 和 [clickhouse-client](https://mvnrepository.com/artifact/com.clickhouse/clickhouse-client) — 这两者都捆绑在 clickhouse-jdbc:all 中。或者,如果您不想使用完整的 JDBC 包,可以单独添加 [clickhouse-client JAR](https://mvnrepository.com/artifact/com.clickhouse/clickhouse-client) 和 [clickhouse-http](https://mvnrepository.com/artifact/com.clickhouse/clickhouse-http-client)。 +:::important +务必包含带有 "all" 分类的 [clickhouse-jdbc JAR](https://mvnrepository.com/artifact/com.clickhouse/clickhouse-jdbc),因为连接器依赖于 [clickhouse-http](https://mvnrepository.com/artifact/com.clickhouse/clickhouse-http-client) 和 [clickhouse-client](https://mvnrepository.com/artifact/com.clickhouse/clickhouse-client) — 这两者都包含在 clickhouse-jdbc:all 中。 +或者,如果您不想使用完整的 JDBC 包,可以单独添加 [clickhouse-client JAR](https://mvnrepository.com/artifact/com.clickhouse/clickhouse-client) 和 [clickhouse-http](https://mvnrepository.com/artifact/com.clickhouse/clickhouse-http-client)。 -无论如何,请确保包版本根据 [兼容性矩阵](#compatibility-matrix) 兼容。 +无论如何,请确保根据 [兼容性矩阵](#compatibility-matrix) 验证包版本的兼容性。 ::: - ## 注册目录(必需) {#register-the-catalog-required} -为了访问您的 ClickHouse 表,您必须使用以下配置配置新的 Spark 目录: +为了访问您的 ClickHouse 表,您必须用以下配置来配置一个新的 Spark 目录: -| 属性 | 值 | 默认值 | 必需 | -|------------------------------------------|------------------------------------------|----------------|------| -| `spark.sql.catalog.` | `com.clickhouse.spark.ClickHouseCatalog` | N/A | 是 | -| `spark.sql.catalog..host` | `` | `localhost` | 否 | -| `spark.sql.catalog..protocol` | `http` | `http` | 否 | -| `spark.sql.catalog..http_port` | `` | `8123` | 否 | -| `spark.sql.catalog..user` | `` | `default` | 否 | -| `spark.sql.catalog..password` | `` | (空字符串) | 否 | -| `spark.sql.catalog..database` | `` | `default` | 否 | -| `spark..write.format` | `json` | `arrow` | 否 | +| 属性 | 值 | 默认值 | 必需 | +|-----------------------------------------------|-------------------------------------------|-------------|--------| +| `spark.sql.catalog.` | `com.clickhouse.spark.ClickHouseCatalog` | N/A | 是 | +| `spark.sql.catalog..host` | `` | `localhost` | 否 | +| `spark.sql.catalog..protocol` | `http` | `http` | 否 | +| `spark.sql.catalog..http_port` | `` | `8123` | 否 | +| `spark.sql.catalog..user` | `` | `default` | 否 | +| `spark.sql.catalog..password` | `` | (空字符串) | 否 | +| `spark.sql.catalog..database` | `` | `default` | 否 | +| `spark..write.format` | `json` | `arrow` | 否 | -这些设置可以通过以下方式之一进行设置: +这些设置可以通过以下几种方式设置: * 编辑/创建 `spark-defaults.conf`。 -* 将配置传递给您的 `spark-submit` 命令(或传递给您的 `spark-shell`/`spark-sql` CLI 命令)。 -* 在初始化上下文时添加配置。 +* 将配置传递给您的 `spark-submit` 命令(或传递给您的 `spark-shell` / `spark-sql` CLI 命令)。 +* 在初始化您的上下文时添加配置。 -:::重要 -在处理 ClickHouse 集群时,您需要为每个实例设置唯一的目录名称。例如: +:::important +在使用 ClickHouse 集群时,您需要为每个实例设置一个唯一的目录名称。 +例如: ```text spark.sql.catalog.clickhouse1 com.clickhouse.spark.ClickHouseCatalog @@ -196,19 +200,17 @@ spark.sql.catalog.clickhouse2.database default spark.sql.catalog.clickhouse2.option.ssl true ``` -这样,您将能够通过 `clickhouse1..` 从 Spark SQL 访问 clickhouse1 表 `.`,并通过 `clickhouse2..` 访问 clickhouse2 表 `.`。 +这样,您就可以通过 `clickhouse1..` 从 Spark SQL 访问 clickhouse1 表 `.`,并通过 `clickhouse2..` 访问 clickhouse2 表 `.`。 ::: - ## ClickHouse Cloud 设置 {#clickhouse-cloud-settings} -连接到 [ClickHouse Cloud](https://clickhouse.com) 时,请确保启用 SSL 并设置适当的 SSL 模式。例如: +在连接到 [ClickHouse Cloud](https://clickhouse.com) 时,请确保启用 SSL 并设置适当的 SSL 模式。例如: ```text spark.sql.catalog.clickhouse.option.ssl true spark.sql.catalog.clickhouse.option.ssl_mode NONE ``` - ## 读取数据 {#read-data} @@ -315,7 +317,6 @@ SELECT * FROM jdbcTable; - ## 写入数据 {#write-data} @@ -344,7 +345,6 @@ public static void main(String[] args) throws AnalysisException { DataTypes.createStructField("name", DataTypes.StringType, false), }); - List data = Arrays.asList( RowFactory.create(1, "Alice"), RowFactory.create(2, "Bob") @@ -405,7 +405,7 @@ from pyspark.sql import SparkSession from pyspark.sql import Row -# Feel free to use any other packages combination satesfying the compatability martix provided above. +# Feel free to use any other packages combination satesfying the compatibility matrix provided above. packages = [ "com.clickhouse.spark:clickhouse-spark-runtime-3.4_2.12:0.8.0", "com.clickhouse:clickhouse-client:0.7.0", @@ -436,15 +436,13 @@ df = spark.createDataFrame(data) # Write DataFrame to ClickHouse df.writeTo("clickhouse.default.example_table").append() - - ``` ```sql - -- resultTalbe is the Spark intermediate df we want to insert into clickhouse.default.example_table + -- resultTable is the Spark intermediate df we want to insert into clickhouse.default.example_table INSERT INTO TABLE clickhouse.default.example_table SELECT * FROM resultTable; @@ -452,14 +450,20 @@ INSERT INTO TABLE clickhouse.default.example_table - ## DDL 操作 {#ddl-operations} -您可以使用 Spark SQL 对 ClickHouse 实例执行 DDL 操作,所有更改立即在 ClickHouse 中持久化。Spark SQL 允许您准确地按照您在 ClickHouse 中的写法编写查询,因此您可以直接执行诸如 CREATE TABLE、TRUNCATE 等命令,而无需修改,例如: +您可以使用 Spark SQL 在 ClickHouse 实例上执行 DDL 操作,所有更改将立即在 ClickHouse 中持久化。 +Spark SQL 允许您以与 ClickHouse 完全相同的方式编写查询,因此您可以直接执行如 CREATE TABLE、TRUNCATE 等命令,而无需修改,例如: + +:::note +在使用 Spark SQL 时,仅可以一次执行一个语句。 +::: ```sql +USE clickhouse; +``` -use clickhouse; +```sql CREATE TABLE test_db.tbl_sql ( create_time TIMESTAMP NOT NULL, @@ -475,105 +479,102 @@ TBLPROPERTIES ( ); ``` -上述示例演示了 Spark SQL 查询,您可以在应用程序中使用任何 API——Java、Scala、PySpark 或 shell 运行这些查询。 - +上述示例展示了 Spark SQL 查询,您可以在您的应用程序中使用任何 API——Java、Scala、PySpark 或 shell 运行。 ## 配置 {#configurations} 以下是连接器中可调节的配置:
-| 键 | 默认值 | 描述 | 自版本 | -|---------------------------------------------------|------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------| -| spark.clickhouse.ignoreUnsupportedTransform | false | ClickHouse 支持使用复杂表达式作为分片键或分区值,例如 `cityHash64(col_1, col_2)`,而这些在 Spark 中当前不受支持。如果 `true`,则忽略不受支持的表达式,否则快速失败并抛出异常。注意,当启用 `spark.clickhouse.write.distributed.convertLocal` 时,忽略不受支持的分片键可能会损坏数据。 | 0.4.0 | -| spark.clickhouse.read.compression.codec | lz4 | 用于读取数据时解压缩的编解码器。支持的编解码器:none、lz4。 | 0.5.0 | -| spark.clickhouse.read.distributed.convertLocal | true | 在读取分布式表时,读取本地表而不是自身。如果 `true`,则忽略 `spark.clickhouse.read.distributed.useClusterNodes`。 | 0.1.0 | -| spark.clickhouse.read.fixedStringAs | binary | 将 ClickHouse FixedString 类型读取为指定的 Spark 数据类型。支持的类型:binary、string。 | 0.8.0 | -| spark.clickhouse.read.format | json | 读取的序列化格式。支持的格式:json、binary。 | 0.6.0 | -| spark.clickhouse.read.runtimeFilter.enabled | false | 启用读取的运行时过滤器。 | 0.8.0 | -| spark.clickhouse.read.splitByPartitionId | true | 如果为 `true`,通过虚拟列 `_partition_id` 构建输入分区过滤器,而不是分区值。已知在通过分区值组装 SQL 谓词时存在问题。此特性需要 ClickHouse Server v21.6+。 | 0.4.0 | -| spark.clickhouse.useNullableQuerySchema | false | 如果为 `true`,在执行 `CREATE/REPLACE TABLE ... AS SELECT ...` 时将查询架构的所有字段标记为可空。注意,此配置需要 SPARK-43390(可在 Spark 3.5 中使用),没有此补丁,会始终表现为 `true`。 | 0.8.0 | -| spark.clickhouse.write.batchSize | 10000 | 写入 ClickHouse 时每批的记录数量。 | 0.1.0 | -| spark.clickhouse.write.compression.codec | lz4 | 写入数据时使用的压缩编解码器。支持的编解码器:none、lz4。 | 0.3.0 | -| spark.clickhouse.write.distributed.convertLocal | false | 写入分布式表时,写入本地表而不是自身。如果为 `true`,则忽略 `spark.clickhouse.write.distributed.useClusterNodes`。 | 0.1.0 | -| spark.clickhouse.write.distributed.useClusterNodes | true | 写入分布式表时写入集群的所有节点。 | 0.1.0 | -| spark.clickhouse.write.format | arrow | 写入的序列化格式。支持的格式:json、arrow。 | 0.4.0 | -| spark.clickhouse.write.localSortByKey | true | 如果为 `true`,在写入之前按排序键进行本地排序。 | 0.3.0 | -| spark.clickhouse.write.localSortByPartition | spark.clickhouse.write.repartitionByPartition 的值 | 如果为 `true`,在写入之前按分区进行本地排序。如果未设置,等于 `spark.clickhouse.write.repartitionByPartition`。 | 0.3.0 | -| spark.clickhouse.write.maxRetry | 3 | 单批写入因可重试代码失败而重试的最大次数。 | 0.1.0 | -| spark.clickhouse.write.repartitionByPartition | true | 在写入之前是否按 ClickHouse 分区键重新分区数据,以满足 ClickHouse 表的分布。 | 0.3.0 | -| spark.clickhouse.write.repartitionNum | 0 | 在写入之前需要重新分区以满足 ClickHouse 表的分布,使用此配置来指定重新分区的数量,值小于 1 意味着不需要。 | 0.1.0 | -| spark.clickhouse.write.repartitionStrictly | false | 如果为 `true`,Spark 将严格按分区分配传入记录,以满足在写入时传递给数据源表的分布要求。否则,Spark 可能会应用某些优化以加快查询速度,但会打破分配要求。注意,此配置需要 SPARK-37523(可在 Spark 3.4 中使用),没有此补丁,会始终表现为 `true`。 | 0.3.0 | -| spark.clickhouse.write.retryInterval | 10s | 写入重试之间的时间间隔(以秒为单位)。 | 0.1.0 | -| spark.clickhouse.write.retryableErrorCodes | 241 | 写入失败时 ClickHouse 服务器返回的可重试错误代码。 | 0.1.0 | - +| 键 | 默认 | 描述 | 版本 | +|------------------------------------------------|---------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------| +| spark.clickhouse.ignoreUnsupportedTransform | false | ClickHouse 支持使用复杂表达式作为分片键或分区值,例如 `cityHash64(col_1, col_2)`,Spark 当前不支持。如果为 `true`,则忽略不受支持的表达式,否则在异常情况下快速失败。注意,当启用 `spark.clickhouse.write.distributed.convertLocal` 时,忽略不支持的分片键可能会损坏数据。 | 0.4.0 | +| spark.clickhouse.read.compression.codec | lz4 | 用于读取数据时解压缩的编解码器。支持的编解码器:none,lz4。 | 0.5.0 | +| spark.clickhouse.read.distributed.convertLocal | true | 读取分布式表时,读取本地表而不是自身。如果为 `true`,则忽略 `spark.clickhouse.read.distributed.useClusterNodes`。 | 0.1.0 | +| spark.clickhouse.read.fixedStringAs | binary | 将 ClickHouse FixedString 类型读取为指定的 Spark 数据类型。支持的类型:binary,string | 0.8.0 | +| spark.clickhouse.read.format | json | 用于读取的序列化格式。支持的格式:json,binary | 0.6.0 | +| spark.clickhouse.read.runtimeFilter.enabled | false | 启用读取时的运行时过滤器。 | 0.8.0 | +| spark.clickhouse.read.splitByPartitionId | true | 如果为 `true`,则通过虚拟列 `_partition_id` 构建输入分区过滤器,而不是分区值。通过分区值组装 SQL 谓词存在已知问题。此功能需要 ClickHouse Server v21.6+ | 0.4.0 | +| spark.clickhouse.useNullableQuerySchema | false | 如果为 `true`,则在执行 `CREATE/REPLACE TABLE ... AS SELECT ...` 创建表时,将查询模式的所有字段标记为可为空。注意,此配置需要 SPARK-43390(在 Spark 3.5 中可用),不带此补丁,它始终被视为 `true`。 | 0.8.0 | +| spark.clickhouse.write.batchSize | 10000 | 写入 ClickHouse 时每批次的记录数。 | 0.1.0 | +| spark.clickhouse.write.compression.codec | lz4 | 用于写入时压缩数据的编解码器。支持的编解码器:none,lz4。 | 0.3.0 | +| spark.clickhouse.write.distributed.convertLocal | false | 写入分布式表时,写入本地表而不是自身。如果为 `true`,则忽略 `spark.clickhouse.write.distributed.useClusterNodes`。 | 0.1.0 | +| spark.clickhouse.write.distributed.useClusterNodes | true | 写入分布式表时向集群的所有节点写入。 | 0.1.0 | +| spark.clickhouse.write.format | arrow | 用于写入的序列化格式。支持的格式:json,arrow | 0.4.0 | +| spark.clickhouse.write.localSortByKey | true | 如果为 `true`,则在写入之前按排序键进行本地排序。 | 0.3.0 | +| spark.clickhouse.write.localSortByPartition | spark.clickhouse.write.repartitionByPartition 的值 | 如果为 `true`,则在写入之前按分区进行本地排序。如果未设置,则等于 `spark.clickhouse.write.repartitionByPartition`。 | 0.3.0 | +| spark.clickhouse.write.maxRetry | 3 | 对于单批次写入因可重试代码失败而进行的最大重试次数。 | 0.1.0 | +| spark.clickhouse.write.repartitionByPartition | true | 是否按 ClickHouse 分区键对数据进行重新分区,以符合 ClickHouse 表的分布要求。 | 0.3.0 | +| spark.clickhouse.write.repartitionNum | 0 | 在写入之前,必须重新分区以符合 ClickHouse 表的分布要求,使用此配置指定重新分区数量,值小于 1 表示没有要求。 | 0.1.0 | +| spark.clickhouse.write.repartitionStrictly | false | 如果为 `true`,则 Spark 将严格地将传入记录分配到分区,以满足在将记录传递给数据源表时的分布要求。否则,Spark 可能会应用某些优化以加快查询速度,但破坏分布要求。注意,此配置需要 SPARK-37523(在 Spark 3.4 中可用),不带此补丁,它始终被视为 `true`。 | 0.3.0 | +| spark.clickhouse.write.retryInterval | 10s | 写入重试之间的秒数间隔。 | 0.1.0 | +| spark.clickhouse.write.retryableErrorCodes | 241 | ClickHouse 服务器在写入失败时返回的可重试错误代码。 | 0.1.0 | ## 支持的数据类型 {#supported-data-types} -本节概述了 Spark 和 ClickHouse 之间的数据类型映射。下面的表提供了从 ClickHouse 读取到 Spark 以及从 Spark 插入数据到 ClickHouse 时转换数据类型的快速参考。 - +本节概述了 Spark 和 ClickHouse 之间数据类型的映射。 +下表为从 ClickHouse 读取到 Spark 以及从 Spark 插入到 ClickHouse 时转换数据类型提供了快捷参考。 ### 从 ClickHouse 读取数据到 Spark {#reading-data-from-clickhouse-into-spark} -| ClickHouse 数据类型 | Spark 数据类型 | 支持 | 是否原始 | 注释 | -|---------------------------------------------------------------|------------------------------|-------|----------|-------------------------------------------| -| `Nothing` | `NullType` | ✅ | 是 | | -| `Bool` | `BooleanType` | ✅ | 是 | | -| `UInt8`, `Int16` | `ShortType` | ✅ | 是 | | -| `Int8` | `ByteType` | ✅ | 是 | | -| `UInt16`,`Int32` | `IntegerType` | ✅ | 是 | | -| `UInt32`,`Int64`, `UInt64` | `LongType` | ✅ | 是 | | -| `Int128`,`UInt128`, `Int256`, `UInt256` | `DecimalType(38, 0)` | ✅ | 是 | | -| `Float32` | `FloatType` | ✅ | 是 | | -| `Float64` | `DoubleType` | ✅ | 是 | | -| `String`, `JSON`, `UUID`, `Enum8`, `Enum16`, `IPv4`, `IPv6` | `StringType` | ✅ | 是 | | -| `FixedString` | `BinaryType`, `StringType` | ✅ | 是 | 由配置 `READ_FIXED_STRING_AS` 控制 | -| `Decimal` | `DecimalType` | ✅ | 是 | 精度和标度最多为 `Decimal128` | -| `Decimal32` | `DecimalType(9, scale)` | ✅ | 是 | | -| `Decimal64` | `DecimalType(18, scale)` | ✅ | 是 | | -| `Decimal128` | `DecimalType(38, scale)` | ✅ | 是 | | -| `Date`, `Date32` | `DateType` | ✅ | 是 | | -| `DateTime`, `DateTime32`, `DateTime64` | `TimestampType` | ✅ | 是 | | -| `Array` | `ArrayType` | ✅ | 否 | 数组元素类型也会被转换 | -| `Map` | `MapType` | ✅ | 否 | 键仅限于 `StringType` | -| `IntervalYear` | `YearMonthIntervalType(Year)`| ✅ | 是 | | -| `IntervalMonth` | `YearMonthIntervalType(Month)`| ✅ | 是 | | -| `IntervalDay`, `IntervalHour`, `IntervalMinute`, `IntervalSecond` | `DayTimeIntervalType` | ✅ | 否 | 使用特定的间隔类型 | -| `Object` | | ❌ | | | -| `Nested` | | ❌ | | | -| `Tuple` | | ❌ | | | -| `Point` | | ❌ | | | -| `Polygon` | | ❌ | | | -| `MultiPolygon` | | ❌ | | | -| `Ring` | | ❌ | | | -| `IntervalQuarter` | | ❌ | | | -| `IntervalWeek` | | ❌ | | | -| `Decimal256` | | ❌ | | | -| `AggregateFunction` | | ❌ | | | -| `SimpleAggregateFunction` | | ❌ | | | - +| ClickHouse 数据类型 | Spark 数据类型 | 受支持 | 是否原始类型 | 备注 | +|---------------------------------------------------------------|-----------------------------|--------|--------------|---------------------------------------------------| +| `Nothing` | `NullType` | ✅ | 是 | | +| `Bool` | `BooleanType` | ✅ | 是 | | +| `UInt8`, `Int16` | `ShortType` | ✅ | 是 | | +| `Int8` | `ByteType` | ✅ | 是 | | +| `UInt16`,`Int32` | `IntegerType` | ✅ | 是 | | +| `UInt32`,`Int64`, `UInt64` | `LongType` | ✅ | 是 | | +| `Int128`,`UInt128`, `Int256`, `UInt256` | `DecimalType(38, 0)` | ✅ | 是 | | +| `Float32` | `FloatType` | ✅ | 是 | | +| `Float64` | `DoubleType` | ✅ | 是 | | +| `String`, `JSON`, `UUID`, `Enum8`, `Enum16`, `IPv4`, `IPv6` | `StringType` | ✅ | 是 | | +| `FixedString` | `BinaryType`, `StringType` | ✅ | 是 | 受配置 `READ_FIXED_STRING_AS` 控制 | +| `Decimal` | `DecimalType` | ✅ | 是 | 精度和小数位最高可达 `Decimal128` | +| `Decimal32` | `DecimalType(9, scale)` | ✅ | 是 | | +| `Decimal64` | `DecimalType(18, scale)` | ✅ | 是 | | +| `Decimal128` | `DecimalType(38, scale)` | ✅ | 是 | | +| `Date`, `Date32` | `DateType` | ✅ | 是 | | +| `DateTime`, `DateTime32`, `DateTime64` | `TimestampType` | ✅ | 是 | | +| `Array` | `ArrayType` | ✅ | 否 | 数组元素类型也会被转换 | +| `Map` | `MapType` | ✅ | 否 | 键仅限于 `StringType` | +| `IntervalYear` | `YearMonthIntervalType(Year)`| ✅ | 是 | | +| `IntervalMonth` | `YearMonthIntervalType(Month)`| ✅ | 是 | | +| `IntervalDay`, `IntervalHour`, `IntervalMinute`, `IntervalSecond` | `DayTimeIntervalType` | ✅ | 否 | 使用特定的区间类型 | +| `Object` | | ❌ | | | +| `Nested` | | ❌ | | | +| `Tuple` | | ❌ | | | +| `Point` | | ❌ | | | +| `Polygon` | | ❌ | | | +| `MultiPolygon` | | ❌ | | | +| `Ring` | | ❌ | | | +| `IntervalQuarter` | | ❌ | | | +| `IntervalWeek` | | ❌ | | | +| `Decimal256` | | ❌ | | | +| `AggregateFunction` | | ❌ | | | +| `SimpleAggregateFunction` | | ❌ | | | ### 从 Spark 插入数据到 ClickHouse {#inserting-data-from-spark-into-clickhouse} -| Spark 数据类型 | ClickHouse 数据类型 | 支持 | 是否原始 | 注释 | -|-------------------------------------|----------------------|-------|----------|----------------------------------------| -| `BooleanType` | `UInt8` | ✅ | 是 | | -| `ByteType` | `Int8` | ✅ | 是 | | -| `ShortType` | `Int16` | ✅ | 是 | | -| `IntegerType` | `Int32` | ✅ | 是 | | -| `LongType` | `Int64` | ✅ | 是 | | -| `FloatType` | `Float32` | ✅ | 是 | | -| `DoubleType` | `Float64` | ✅ | 是 | | -| `StringType` | `String` | ✅ | 是 | | -| `VarcharType` | `String` | ✅ | 是 | | -| `CharType` | `String` | ✅ | 是 | | -| `DecimalType` | `Decimal(p, s)` | ✅ | 是 | 精度和标度最多为 `Decimal128` | -| `DateType` | `Date` | ✅ | 是 | | -| `TimestampType` | `DateTime` | ✅ | 是 | | -| `ArrayType` (列表、元组或数组) | `Array` | ✅ | 否 | 数组元素类型也会被转换 | -| `MapType` | `Map` | ✅ | 否 | 键仅限于 `StringType` | -| `Object` | | ❌ | | | -| `Nested` | | ❌ | | | +| Spark 数据类型 | ClickHouse 数据类型 | 受支持 | 是否原始类型 | 备注 | +|-------------------------------------|----------------------|--------|--------------|----------------------------------------| +| `BooleanType` | `UInt8` | ✅ | 是 | | +| `ByteType` | `Int8` | ✅ | 是 | | +| `ShortType` | `Int16` | ✅ | 是 | | +| `IntegerType` | `Int32` | ✅ | 是 | | +| `LongType` | `Int64` | ✅ | 是 | | +| `FloatType` | `Float32` | ✅ | 是 | | +| `DoubleType` | `Float64` | ✅ | 是 | | +| `StringType` | `String` | ✅ | 是 | | +| `VarcharType` | `String` | ✅ | 是 | | +| `CharType` | `String` | ✅ | 是 | | +| `DecimalType` | `Decimal(p, s)` | ✅ | 是 | 精度和小数位最高可达 `Decimal128` | +| `DateType` | `Date` | ✅ | 是 | | +| `TimestampType` | `DateTime` | ✅ | 是 | | +| `ArrayType`(列表、元组或数组) | `Array` | ✅ | 否 | 数组元素类型也会被转换 | +| `MapType` | `Map` | ✅ | 否 | 键仅限于 `StringType` | +| `Object` | | ❌ | | | +| `Nested` | | ❌ | | | ## 贡献与支持 {#contributing-and-support} -如果您想为该项目贡献或报告任何问题,我们欢迎您的意见! -访问我们的 [GitHub 仓库](https://github.com/ClickHouse/spark-clickhouse-connector) 来打开问题、建议改进或提交拉取请求。 +如果您想为该项目做出贡献或报告任何问题,我们欢迎您的意见! +请访问我们的 [GitHub 仓库](https://github.com/ClickHouse/spark-clickhouse-connector) 开启一个问题,建议改进或提交拉取请求。 欢迎贡献!在开始之前,请查看仓库中的贡献指南。 感谢您帮助改善我们的 ClickHouse Spark 连接器! diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/apache-spark/spark-native-connector.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/apache-spark/spark-native-connector.md.hash index b571bdc939d..41c9ec16c30 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/apache-spark/spark-native-connector.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/apache-spark/spark-native-connector.md.hash @@ -1 +1 @@ -d4895b120ec23145 +4d3cbdae484d3965 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/aws-glue/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/aws-glue/index.md index a97599079cc..79d954c6737 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/aws-glue/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/aws-glue/index.md @@ -10,59 +10,127 @@ - 'glue' - 'migrating' - 'data' -'title': '将 Amazon Glue 与 ClickHouse 集成' +- 'spark' +'title': '将 Amazon Glue 与 ClickHouse 和 Spark 集成' +'doc_type': 'guide' --- +import Image from '@theme/IdealImage'; import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; +import notebook_connections_config from '@site/static/images/integrations/data-ingestion/aws-glue/notebook-connections-config.png'; +import dependent_jars_path_option from '@site/static/images/integrations/data-ingestion/aws-glue/dependent_jars_path_option.png'; -# 将 Amazon Glue 与 ClickHouse 集成 +# 将 Amazon Glue 与 ClickHouse 和 Spark 集成 -[Amazon Glue](https://aws.amazon.com/glue/) 是由亚马逊网络服务(AWS)提供的完全托管的无服务器数据集成服务。它简化了发现、准备和转换数据以进行分析、机器学习和应用开发的流程。 +[Amazon Glue](https://aws.amazon.com/glue/) 是 Amazon Web Services (AWS) 提供的全托管无服务器数据集成服务。它简化了数据发现、准备和转换的过程,以便进行分析、机器学习和应用开发。 -尽管尚无 Glue ClickHouse 连接器,但可以利用官方 JDBC 连接器与 ClickHouse 连接和集成: +## 安装 {#installation} +要将您的 Glue 代码与 ClickHouse 集成,您可以通过以下其中一种方式使用我们的官方 Spark 连接器: +- 从 AWS Marketplace 安装 ClickHouse Glue 连接器(推荐)。 +- 手动将 Spark 连接器的 JAR 文件添加到您的 Glue 作业中。 + + + + +1.

订阅连接器

+要在您的账户中访问连接器,请从 AWS Marketplace 订阅 ClickHouse AWS Glue 连接器。 + +2.

授予所需权限

+确保您的 Glue 作业的 IAM 角色具有所需的权限,如最低权限 [指南](https://docs.aws.amazon.com/glue/latest/dg/getting-started-min-privs-job.html#getting-started-min-privs-connectors) 中所述。 + +3.

激活连接器并创建连接

+您可以通过单击 [此链接](https://console.aws.amazon.com/gluestudio/home#/connector/add-connection?connectorName="ClickHouse%20AWS%20Glue%20Connector"&connectorType="Spark"&connectorUrl=https://709825985650.dkr.ecr.us-east-1.amazonaws.com/clickhouse/clickhouse-glue:1.0.0&connectorClassName="com.clickhouse.spark.ClickHouseCatalog") 直接激活连接器并创建连接,该链接将打开预填关键字段的 Glue 连接创建页面。为连接命名,然后按创建(此阶段无需提供 ClickHouse 连接详细信息)。 + +4.

在 Glue 作业中使用

+在您的 Glue 作业中,选择 `Job details` 选项卡,并展开 `Advanced properties` 窗口。在 `Connections` 部分,选择您刚才创建的连接。连接器会自动将所需的 JAR 注入作业运行时。 + + + +:::note +Glue 连接器中使用的 JAR 是为 `Spark 3.3`、`Scala 2` 和 `Python 3` 构建的。配置 Glue 作业时,请确保选择这些版本。 +::: + +
+ +要手动添加所需的 JAR,请按照以下步骤操作: +1. 将以下 JAR 上传到 S3 存储桶 - `clickhouse-jdbc-0.6.X-all.jar` 和 `clickhouse-spark-runtime-3.X_2.X-0.8.X.jar`。 +2. 确保 Glue 作业可以访问此存储桶。 +3. 在 `Job details` 选项卡下,向下滚动并展开 `Advanced properties` 下拉菜单,在 `Dependent JARs path` 中填写 JAR 路径: + + + + +
+ +## 示例 {#example} - + ```java -import com.amazonaws.services.glue.util.Job -import com.amazonaws.services.glue.util.GlueArgParser import com.amazonaws.services.glue.GlueContext -import org.apache.spark.SparkContext +import com.amazonaws.services.glue.util.GlueArgParser +import com.amazonaws.services.glue.util.Job +import com.clickhouseScala.Native.NativeSparkRead.spark import org.apache.spark.sql.SparkSession -import org.apache.spark.sql.DataFrame -import scala.collection.JavaConverters._ -import com.amazonaws.services.glue.log.GlueLogger +import scala.collection.JavaConverters._ +import org.apache.spark.sql.types._ +import org.apache.spark.sql.functions._ -// Initialize Glue job -object GlueJob { +object ClickHouseGlueExample { def main(sysArgs: Array[String]) { - val sc: SparkContext = new SparkContext() - val glueContext: GlueContext = new GlueContext(sc) - val spark: SparkSession = glueContext.getSparkSession - val logger = new GlueLogger - import spark.implicits._ - // @params: [JOB_NAME] val args = GlueArgParser.getResolvedOptions(sysArgs, Seq("JOB_NAME").toArray) - Job.init(args("JOB_NAME"), glueContext, args.asJava) - - // JDBC connection details - val jdbcUrl = "jdbc:ch://{host}:{port}/{schema}" - val jdbcProperties = new java.util.Properties() - jdbcProperties.put("user", "default") - jdbcProperties.put("password", "*******") - jdbcProperties.put("driver", "com.clickhouse.jdbc.ClickHouseDriver") - // Load the table from ClickHouse - val df: DataFrame = spark.read.jdbc(jdbcUrl, "my_table", jdbcProperties) - - // Show the Spark df, or use it for whatever you like - df.show() - - // Commit the job + val sparkSession: SparkSession = SparkSession.builder + .config("spark.sql.catalog.clickhouse", "com.clickhouse.spark.ClickHouseCatalog") + .config("spark.sql.catalog.clickhouse.host", "") + .config("spark.sql.catalog.clickhouse.protocol", "https") + .config("spark.sql.catalog.clickhouse.http_port", "") + .config("spark.sql.catalog.clickhouse.user", "default") + .config("spark.sql.catalog.clickhouse.password", "") + .config("spark.sql.catalog.clickhouse.database", "default") + // for ClickHouse cloud + .config("spark.sql.catalog.clickhouse.option.ssl", "true") + .config("spark.sql.catalog.clickhouse.option.ssl_mode", "NONE") + .getOrCreate + + val glueContext = new GlueContext(sparkSession.sparkContext) + Job.init(args("JOB_NAME"), glueContext, args.asJava) + import sparkSession.implicits._ + + val url = "s3://{path_to_cell_tower_data}/cell_towers.csv.gz" + + val schema = StructType(Seq( + StructField("radio", StringType, nullable = false), + StructField("mcc", IntegerType, nullable = false), + StructField("net", IntegerType, nullable = false), + StructField("area", IntegerType, nullable = false), + StructField("cell", LongType, nullable = false), + StructField("unit", IntegerType, nullable = false), + StructField("lon", DoubleType, nullable = false), + StructField("lat", DoubleType, nullable = false), + StructField("range", IntegerType, nullable = false), + StructField("samples", IntegerType, nullable = false), + StructField("changeable", IntegerType, nullable = false), + StructField("created", TimestampType, nullable = false), + StructField("updated", TimestampType, nullable = false), + StructField("averageSignal", IntegerType, nullable = false) + )) + + val df = sparkSession.read + .option("header", "true") + .schema(schema) + .csv(url) + + // Write to ClickHouse + df.writeTo("clickhouse.default.cell_towers").append() + + + // Read from ClickHouse + val dfRead = spark.sql("select * from clickhouse.default.cell_towers") Job.commit() } } @@ -78,6 +146,8 @@ from awsglue.utils import getResolvedOptions from pyspark.context import SparkContext from awsglue.context import GlueContext from awsglue.job import Job +from pyspark.sql import Row + ## @params: [JOB_NAME] args = getResolvedOptions(sys.argv, ['JOB_NAME']) @@ -88,23 +158,34 @@ logger = glueContext.get_logger() spark = glueContext.spark_session job = Job(glueContext) job.init(args['JOB_NAME'], args) -jdbc_url = "jdbc:ch://{host}:{port}/{schema}" -query = "select * from my_table" - -# For cloud usage, please add ssl options -df = (spark.read.format("jdbc") - .option("driver", 'com.clickhouse.jdbc.ClickHouseDriver') - .option("url", jdbc_url) - .option("user", 'default') - .option("password", '*******') - .option("query", query) - .load()) - -logger.info("num of rows:") -logger.info(str(df.count())) -logger.info("Data sample:") -logger.info(str(df.take(10))) +spark.conf.set("spark.sql.catalog.clickhouse", "com.clickhouse.spark.ClickHouseCatalog") +spark.conf.set("spark.sql.catalog.clickhouse.host", "") +spark.conf.set("spark.sql.catalog.clickhouse.protocol", "https") +spark.conf.set("spark.sql.catalog.clickhouse.http_port", "") +spark.conf.set("spark.sql.catalog.clickhouse.user", "default") +spark.conf.set("spark.sql.catalog.clickhouse.password", "") +spark.conf.set("spark.sql.catalog.clickhouse.database", "default") +spark.conf.set("spark.clickhouse.write.format", "json") +spark.conf.set("spark.clickhouse.read.format", "arrow") + +# for ClickHouse cloud +spark.conf.set("spark.sql.catalog.clickhouse.option.ssl", "true") +spark.conf.set("spark.sql.catalog.clickhouse.option.ssl_mode", "NONE") + + +# Create DataFrame +data = [Row(id=11, name="John"), Row(id=12, name="Doe")] +df = spark.createDataFrame(data) + + +# Write DataFrame to ClickHouse +df.writeTo("clickhouse.default.example_table").append() + + +# Read DataFrame from ClickHouse +df_read = spark.sql("select * from clickhouse.default.example_table") +logger.info(str(df.take(10))) job.commit() ``` @@ -112,4 +193,4 @@ job.commit() -有关更多详细信息,请访问我们的 [Spark & JDBC 文档](/integrations/apache-spark/spark-jdbc#read-data)。 +有关更多详细信息,请访问我们的 [Spark 文档](/integrations/apache-spark). diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/aws-glue/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/aws-glue/index.md.hash index 4c1623be060..4cc4ddaf769 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/aws-glue/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/aws-glue/index.md.hash @@ -1 +1 @@ -61bd53b1772bfbcc +020fa8ebb82f3c0f diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/azure-data-factory/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/azure-data-factory/index.md index 772fadbd957..0c002774586 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/azure-data-factory/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/azure-data-factory/index.md @@ -7,10 +7,11 @@ - 'microsoft' - 'data' 'title': '将 Azure 数据引入 ClickHouse' +'doc_type': 'guide' --- -| 页面 | 描述 | -|-----------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| [概述](./overview.md) | 概述将 Azure 数据导入 ClickHouse 的两种方法 | -| [使用 ClickHouse 的 azureBlobStorage 表函数](./using_azureblobstorage.md) | 选项 1 - 一种高效且简单的方法,通过使用 `azureBlobStorage` 表函数将数据从 Azure Blob Storage 或 Azure Data Lake Storage 复制到 ClickHouse | -| [使用 ClickHouse 的 HTTP 接口](./using_http_interface.md) | 选项 2 - 不让 ClickHouse 从 Azure 拉取数据,而是让 Azure 数据工厂通过它的 HTTP 接口将数据推送到 ClickHouse | +| 页面 | 描述 | +|-----------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| [概述](./overview.md) | 概述了将 Azure 数据导入 ClickHouse 的两种方法 | +| [使用 ClickHouse 的 azureBlobStorage 表函数](./using_azureblobstorage.md) | 选项 1 - 一种高效且简单的方法,通过 `azureBlobStorage` 表函数将数据从 Azure Blob 存储或 Azure 数据湖存储复制到 ClickHouse | +| [使用 ClickHouse 的 HTTP 接口](./using_http_interface.md) | 选项 2 - 而不是让 ClickHouse 从 Azure 拉取数据,而是让 Azure 数据工厂通过其 HTTP 接口将数据推送到 ClickHouse | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/azure-data-factory/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/azure-data-factory/index.md.hash index 5b1eb577748..93c92f12ade 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/azure-data-factory/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/azure-data-factory/index.md.hash @@ -1 +1 @@ -9cbabb93b437918f +224e5d71d7466f0b diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/azure-data-factory/overview.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/azure-data-factory/overview.md index 39e1906e39e..cc1ff995776 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/azure-data-factory/overview.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/azure-data-factory/overview.md @@ -1,23 +1,24 @@ --- -'sidebar_label': '概览' +'sidebar_label': '概述' 'slug': '/integrations/azure-data-factory/overview' -'description': '将 Azure 数据导入 ClickHouse - 概览' +'description': '将 Azure 数据引入 ClickHouse - 概述' 'keywords': - 'azure data factory' - 'azure' - 'microsoft' - 'data' -'title': '将 Azure 数据导入 ClickHouse' +'title': '将 Azure 数据引入 ClickHouse' +'doc_type': 'guide' --- -# 将 Azure 数据导入 ClickHouse +# 将 Azure 数据引入 ClickHouse -Microsoft Azure 提供了广泛的工具来存储、转换和分析数据。 然而,在许多场景中,ClickHouse 可以为低延迟查询和处理巨大数据集提供显著更好的性能。此外,与通用 Azure 数据库相比,ClickHouse 的列式存储和压缩可以大大降低查询大量分析数据的成本。 +Microsoft Azure 提供了一系列工具来存储、转换和分析数据。然而,在许多场景中,ClickHouse 可以提供显著更好的低延迟查询和处理大规模数据集的性能。此外,ClickHouse 的列式存储和压缩可以大大降低与通用 Azure 数据库相比查询大量分析数据的成本。 -在本节文档中,我们将探讨两种将数据从 Microsoft Azure 导入 ClickHouse 的方法: +在本节文档中,我们将探讨将 Microsoft Azure 中的数据引入 ClickHouse 的两种方法: -| 方法 | 描述 | -|----------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| [使用 `azureBlobStorage` 表函数](./using_azureblobstorage.md) | 涉及使用 ClickHouse 的 [`azureBlobStorage` 表函数](https://clickhouse.com/docs/sql-reference/table-functions/azureBlobStorage) 直接从 Azure Blob 存储传输数据。 | -| [使用 ClickHouse HTTP 接口](./using_http_interface.md) | 使用 [ClickHouse HTTP 接口](https://clickhouse.com/docs/interfaces/http) 作为 Azure 数据工厂中的数据源,允许您在数据流活动中复制数据或将其用作管道的一部分。 | +| 方法 | 描述 | +|----------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| [使用 `azureBlobStorage` 表函数](./using_azureblobstorage.md) | 涉及使用 ClickHouse 的 [`azureBlobStorage` 表函数](https://clickhouse.com/docs/sql-reference/table-functions/azureBlobStorage) 直接从 Azure Blob 存储传输数据。 | +| [使用 ClickHouse HTTP 接口](./using_http_interface.md) | 在 Azure 数据工厂中将 [ClickHouse HTTP 接口](https://clickhouse.com/docs/interfaces/http) 用作数据源,允许您复制数据或在数据流活动中使用它,作为管道的一部分。 | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/azure-data-factory/overview.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/azure-data-factory/overview.md.hash index 42713d7db5f..93947b77bd1 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/azure-data-factory/overview.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/azure-data-factory/overview.md.hash @@ -1 +1 @@ -b1a7d563c479b984 +20950f6dc95f3d8c diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/azure-data-factory/using_azureblobstorage.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/azure-data-factory/using_azureblobstorage.md index 34463c9b7ca..c0c7890e041 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/azure-data-factory/using_azureblobstorage.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/azure-data-factory/using_azureblobstorage.md @@ -8,7 +8,8 @@ - 'microsoft' - 'data' - 'azureBlobStorage' -'title': '使用 ClickHouse 的 azureBlobStorage 表函数将 Azure 数据导入 ClickHouse' +'title': '使用 ClickHouse 的 azureBlobStorage 表函数将 Azure 数据引入 ClickHouse' +'doc_type': 'guide' --- import Image from '@theme/IdealImage'; @@ -18,30 +19,30 @@ import azureDataStoreAccessKeys from '@site/static/images/integr # 使用 ClickHouse 的 azureBlobStorage 表函数 {#using-azureBlobStorage-function} -这是从 Azure Blob Storage 或 Azure Data Lake Storage 复制数据到 ClickHouse 的最有效和简便的方法之一。通过这个表函数,您可以指示 ClickHouse 直接连接 Azure 存储并按需读取数据。 +这是从 Azure Blob Storage 或 Azure Data Lake Storage 复制数据到 ClickHouse 的最有效且简单的方式之一。使用此表函数,您可以指示 ClickHouse 直接连接到 Azure 存储并按需读取数据。 -它提供了类似表的接口,使您可以直接从源选择、插入和过滤数据。该函数高度优化,并支持许多广泛使用的文件格式,包括 `CSV`、`JSON`、`Parquet`、`Arrow`、`TSV`、`ORC`、`Avro` 等。完整列表请参见 ["数据格式"](/interfaces/formats)。 +它提供了一个表格般的接口,允许您直接从源中选择、插入和过滤数据。该函数经过高度优化,支持许多广泛使用的文件格式,包括 `CSV`、`JSON`、`Parquet`、`Arrow`、`TSV`、`ORC`、`Avro` 等。有关完整列表,请参阅 ["数据格式"](/interfaces/formats)。 -在本节中,我们将介绍将数据从 Azure Blob Storage 转移到 ClickHouse 的简单入门指南,以及有效使用此函数的重要注意事项。有关更多详细信息和高级选项,请参考官方文档: +在本节中,我们将逐步介绍从 Azure Blob Storage 向 ClickHouse 传输数据的简单入门指南,以及有效使用此函数的注意事项。有关更多详细信息和高级选项,请参考官方文档: [`azureBlobStorage` 表函数文档页面](https://clickhouse.com/docs/sql-reference/table-functions/azureBlobStorage) ## 获取 Azure Blob Storage 访问密钥 {#acquiring-azure-blob-storage-access-keys} -为允许 ClickHouse 访问您的 Azure Blob Storage,您需要一个带访问密钥的连接字符串。 +要允许 ClickHouse 访问您的 Azure Blob Storage,您需要一个包含访问密钥的连接字符串。 -1. 在 Azure 门户中,导航到您的 **存储帐户**。 +1. 在 Azure 门户中,导航到您的 **存储账户**。 -2. 在左侧菜单中,选择 **访问密钥** 选项,在 **安全性 + 网络** 部分下。 - +2. 在左侧菜单中,选择 **访问密钥**,位于 **安全性 + 网络** 部分。 + -3. 选择 **key1** 或 **key2**,并点击 **连接字符串** 字段旁边的 **显示** 按钮。 - +3. 选择 **key1** 或 **key2**,然后单击 **连接字符串** 字段旁边的 **显示** 按钮。 + -4. 复制连接字符串 — 您将在 azureBlobStorage 表函数中使用此作为参数。 +4. 复制连接字符串——您将在 azureBlobStorage 表函数中将其用作参数。 ## 从 Azure Blob Storage 查询数据 {#querying-the-data-from-azure-blob-storage} -打开您喜欢的 ClickHouse 查询控制台 — 这可以是 ClickHouse Cloud 网络界面、ClickHouse CLI 客户端或您用于运行查询的任何其他工具。一旦您准备好连接字符串和 ClickHouse 查询控制台,您就可以开始直接从 Azure Blob Storage 查询数据。 +打开您喜欢的 ClickHouse 查询控制台——这可以是 ClickHouse Cloud 网络界面、ClickHouse CLI 客户端或您用来运行查询的任何其他工具。一旦您准备好连接字符串和 ClickHouse 查询控制台,您就可以开始直接从 Azure Blob Storage 查询数据。 在以下示例中,我们查询存储在名为 data-container 的容器中的 JSON 文件中的所有数据: @@ -53,7 +54,7 @@ SELECT * FROM azureBlobStorage( 'JSONEachRow'); ``` -如果您希望将数据复制到本地 ClickHouse 表(例如,my_table),则可以使用 `INSERT INTO ... SELECT` 语句: +如果您想将该数据复制到本地 ClickHouse 表(例如 my_table)中,可以使用 `INSERT INTO ... SELECT` 语句: ```sql INSERT INTO my_table @@ -64,29 +65,27 @@ SELECT * FROM azureBlobStorage( 'JSONEachRow'); ``` -这允许您有效地将外部数据拉入 ClickHouse,而无需中间 ETL 步骤。 +这使您能够高效地将外部数据拉入 ClickHouse,而无需中间的 ETL 步骤。 ## 使用环境传感器数据集的简单示例 {#simple-example-using-the-environmental-sensors-dataset} 作为示例,我们将从环境传感器数据集中下载一个文件。 -1. 下载一个 [示例文件](https://clickhouse-public-datasets.s3.eu-central-1.amazonaws.com/sensors/monthly/2019-06_bmp180.csv.zst) - 来自 [环境传感器数据集](https://clickhouse.com/docs/getting-started/example-datasets/environmental-sensors) +1. 从 [环境传感器数据集](https://clickhouse.com/docs/getting-started/example-datasets/environmental-sensors) 下载一个 [示例文件](https://clickhouse-public-datasets.s3.eu-central-1.amazonaws.com/sensors/monthly/2019-06_bmp180.csv.zst)。 -2. 在 Azure 门户中,如果您还没有存储帐户,请创建一个新的存储帐户。 +2. 在 Azure 门户中,如果您还没有存储账户,请创建一个新的存储账户。 :::warning -请确保您的存储帐户启用了 **允许存储帐户密钥访问**,否则将无法使用帐户密钥访问数据。 +确保您的存储账户启用了 **允许存储账户密钥访问**,否则您将无法使用账户密钥访问数据。 ::: -3. 在您的存储帐户中创建一个新容器。在本示例中,我们将其命名为 sensors。 - 如果您使用的是现有容器,则可以跳过此步骤。 +3. 在您的存储账户中创建一个新容器。在此示例中,我们将其命名为 sensors。如果您使用的是现有的容器,可以跳过此步骤。 4. 将之前下载的 `2019-06_bmp180.csv.zst` 文件上传到容器中。 5. 按照前面描述的步骤获取 Azure Blob Storage 连接字符串。 -现在一切都已设置完毕,您可以直接从 Azure Blob Storage 查询数据: +现在一切都已设置完成,您可以直接从 Azure Blob Storage 查询数据: ```sql SELECT * @@ -99,7 +98,7 @@ LIMIT 10 SETTINGS format_csv_delimiter = ';' ``` -7. 要将数据加载到表中,请创建原始数据集中使用的架构的简化版本: +7. 为了将数据加载到表中,请创建一个简化版本的原始数据集所使用的模式: ```sql CREATE TABLE sensors ( @@ -114,10 +113,10 @@ ORDER BY (timestamp, sensor_id); ``` :::info -有关在查询 Azure Blob Storage 等外部数据源时的配置选项和架构推断的更多信息,请参见 [从输入数据自动推断架构](https://clickhouse.com/docs/interfaces/schema-inference) +有关查询外部源(如 Azure Blob Storage)时的配置选项和模式推断的更多信息,请参见 [从输入数据自动推断模式](https://clickhouse.com/docs/interfaces/schema-inference)。 ::: -8. 现在将数据从 Azure Blob Storage 插入到 sensors 表中: +8. 现在将 Azure Blob Storage 中的数据插入到 sensors 表中: ```sql INSERT INTO sensors SELECT sensor_id, lat, lon, timestamp, temperature @@ -129,12 +128,12 @@ FROM azureBlobStorage( SETTINGS format_csv_delimiter = ';' ``` -您的传感器表现在已填充来自存储在 Azure Blob Storage 中的 `2019-06_bmp180.csv.zst` 文件的数据。 +您的 sensors 表现在已填充来自 Azure Blob Storage 中的 `2019-06_bmp180.csv.zst` 文件的数据。 ## 其他资源 {#additional-resources} -这只是使用 azureBlobStorage 函数的基本介绍。有关更多高级选项和配置详细信息,请参考官方文档: +这只是使用 azureBlobStorage 函数的基本介绍。有关更高级的选项和配置细节,请参阅官方文档: - [azureBlobStorage 表函数](https://clickhouse.com/docs/sql-reference/table-functions/azureBlobStorage) - [输入和输出数据的格式](https://clickhouse.com/docs/sql-reference/formats) -- [从输入数据自动推断架构](https://clickhouse.com/docs/interfaces/schema-inference) +- [从输入数据自动推断模式](https://clickhouse.com/docs/interfaces/schema-inference) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/azure-data-factory/using_azureblobstorage.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/azure-data-factory/using_azureblobstorage.md.hash index 900f319016c..a405c145f55 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/azure-data-factory/using_azureblobstorage.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/azure-data-factory/using_azureblobstorage.md.hash @@ -1 +1 @@ -4b2d29f859500469 +9c3813c8dc0bff90 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/azure-data-factory/using_http_interface.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/azure-data-factory/using_http_interface.md index 368d4035a05..c133f17dc45 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/azure-data-factory/using_http_interface.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/azure-data-factory/using_http_interface.md @@ -9,6 +9,7 @@ - 'data' - 'http interface' 'title': '使用 ClickHouse HTTP 接口将 Azure 数据导入 ClickHouse' +'doc_type': 'guide' --- import Image from '@theme/IdealImage'; @@ -39,27 +40,31 @@ import adfCopyDataSinkSelectPost from '@site/static/images/integr import adfCopyDataDebugSuccess from '@site/static/images/integrations/data-ingestion/azure-data-factory/adf-copy-data-debug-success.png'; -# 在 Azure Data Factory 中使用 ClickHouse HTTP 接口 {#using-clickhouse-http-interface-in-azure-data-factory} +# 使用 ClickHouse HTTP 接口在 Azure 数据工厂中 {#using-clickhouse-http-interface-in-azure-data-factory} -[`azureBlobStorage` 表函数](https://clickhouse.com/docs/sql-reference/table-functions/azureBlobStorage) 是将数据从 Azure Blob 存储导入 ClickHouse 的快速且便捷的方法。然而,由于以下原因,使用它可能并不总是合适的: +[`azureBlobStorage` 表函数](https://clickhouse.com/docs/sql-reference/table-functions/azureBlobStorage) +是将数据从 Azure Blob 存储快速便捷地导入 ClickHouse 的方法。然而,使用它可能并不总是合适,原因如下: -- 您的数据可能并不是存储在 Azure Blob 存储中 —— 例如,它可能存储在 Azure SQL 数据库、Microsoft SQL Server 或 Cosmos DB 中。 -- 安全策略可能会完全阻止外部访问 Blob 存储 —— 例如,如果存储帐户被锁定而没有公共端点。 +- 您的数据可能并未存储在 Azure Blob 存储中——例如,它可能在 Azure SQL Database、Microsoft SQL Server 或 Cosmos DB 中。 +- 安全策略可能会完全阻止对 Blob 存储的外部访问——例如,如果存储帐户被锁定且没有公共终端。 -在这种情况下,您可以使用 Azure Data Factory 配合 [ClickHouse HTTP 接口](https://clickhouse.com/docs/interfaces/http) 将数据从 Azure 服务发送到 ClickHouse。 +在这种情况下,您可以结合使用 Azure 数据工厂和 +[ClickHouse HTTP 接口](https://clickhouse.com/docs/interfaces/http) +将数据从 Azure 服务发送到 ClickHouse。 -这种方法会逆转数据流:Azure Data Factory 将数据推送到 ClickHouse,而不是让 ClickHouse 从 Azure 拉取数据。这种方式通常要求您的 ClickHouse 实例可以从公共互联网访问。 +这种方法反转了数据流:不是让 ClickHouse 从 Azure 拉取数据,而是由 Azure 数据工厂将数据推送到 ClickHouse。这种方法通常要求您的 ClickHouse 实例可从公共互联网访问。 :::info -通过使用 Azure Data Factory 的自托管集成运行时,可以避免将 ClickHouse 实例暴露于互联网。此设置允许通过私有网络发送数据。然而,这超出了本文的范围。您可以在官方指南中找到更多信息: +您可以通过使用 Azure 数据工厂的自托管集成运行时避免将 ClickHouse 实例暴露于互联网。这种设置允许通过私有网络发送数据。然而,这超出了本文的范围。您可以在官方指南中找到更多信息: [创建和配置自托管集成运行时](https://learn.microsoft.com/en-us/azure/data-factory/create-self-hosted-integration-runtime?tabs=data-factory) ::: -## 将 ClickHouse 转换为 REST 服务 {#turning-clickhouse-to-a-rest-service} +## 将 ClickHouse 转变为 REST 服务 {#turning-clickhouse-to-a-rest-service} -Azure Data Factory 支持以 JSON 格式通过 HTTP 向外部系统发送数据。我们可以利用这一能力直接将数据插入 ClickHouse,使用 [ClickHouse HTTP 接口](https://clickhouse.com/docs/interfaces/http)。您可以在 [ClickHouse HTTP 接口文档](https://clickhouse.com/docs/interfaces/http) 中了解更多信息。 +Azure 数据工厂支持以 JSON 格式通过 HTTP 将数据发送到外部系统。我们可以利用此功能通过 [ClickHouse HTTP 接口](https://clickhouse.com/docs/interfaces/http) 将数据直接插入 ClickHouse。 +您可以在 [ClickHouse HTTP 接口文档](https://clickhouse.com/docs/interfaces/http) 中了解更多信息。 -在这个示例中,我们只需指定目标表,定义输入数据格式为 JSON,并包含选项以允许更灵活的时间戳解析。 +在此示例中,我们只需指定目标表,将输入数据格式定义为 JSON,并包含选项以允许更灵活的时间戳解析。 ```sql INSERT INTO my_table @@ -69,94 +74,94 @@ SETTINGS FORMAT JSONEachRow ``` -要将此查询作为 HTTP 请求的一部分发送,您只需将其作为 URL 编码字符串传递给 ClickHouse 端点中的查询参数: +要将此查询作为 HTTP 请求的一部分发送,您只需将其作为 URL 编码的字符串传递到 ClickHouse 端点中的查询参数: ```text https://your-clickhouse-url.com?query=INSERT%20INTO%20my_table%20SETTINGS%20date_time_input_format%3D%27best_effort%27%2C%20input_format_json_read_objects_as_strings%3D1%20FORMAT%20JSONEachRow%0A ``` :::info -Azure Data Factory 可以使用其内置的 `encodeUriComponent` 函数自动处理此编码,因此您不需要手动完成。 +Azure 数据工厂可以使用其内置的 `encodeUriComponent` 函数自动处理此编码,因此您不必手动进行。 ::: -现在,您可以将 JSON 格式的数据发送到此 URL。数据应该与目标表的结构匹配。这里是一个使用 curl 的简单示例,假设有一个包含三列 `col_1`、`col_2` 和 `col_3` 的表。 +现在您可以将格式为 JSON 的数据发送到此 URL。数据应与目标表的结构匹配。这里是一个使用 curl 的简单示例,假设表有三列:`col_1`、`col_2` 和 `col_3`。 ```text curl \ -XPOST "https://your-clickhouse-url.com?query=" \ --data '{"col_1":9119,"col_2":50.994,"col_3":"2019-06-01 00:00:00"}' ``` -您还可以发送 JSON 对象的数组,或 JSON Lines(换行分隔的 JSON 对象)。Azure Data Factory 使用 JSON 数组格式,这与 ClickHouse 的 `JSONEachRow` 输入完全兼容。 +您还可以发送 JSON 对象的数组,或 JSON Lines(换行分隔的 JSON 对象)。Azure 数据工厂使用 JSON 数组格式,这与 ClickHouse 的 `JSONEachRow` 输入完美兼容。 -如您所见,在这一步中,您不需要在 ClickHouse 方面做任何特殊操作。HTTP 接口已经提供了充当 REST 风格端点所需的所有功能 — 无需额外配置。 +如您所见,在这一步中,您在 ClickHouse 侧不需要做任何特殊处理。HTTP 接口已经提供了作为 REST 风格端点所需的一切——无需额外配置。 -现在我们已经使 ClickHouse 像 REST 端点一样工作,就可以配置 Azure Data Factory 使用它。 +现在我们已使 ClickHouse 像 REST 端点一样工作,是时候配置 Azure 数据工厂以使用它了。 -在接下来的步骤中,我们将创建一个 Azure Data Factory 实例,设置链接服务到您的 ClickHouse 实例,定义一个“REST sink”的数据集,并创建一个将数据从 Azure 发送到 ClickHouse 的复制数据活动。 +在接下来的步骤中,我们将创建一个 Azure 数据工厂实例,设置与您的 ClickHouse 实例的链接服务,定义一个用于 [REST sink](https://learn.microsoft.com/en-us/azure/data-factory/connector-rest) 的数据集,并创建一个 Copy Data 活动以将数据从 Azure 发送到 ClickHouse。 -## 创建 Azure Data Factory 实例 {#create-an-azure-data-factory-instance} +## 创建 Azure 数据工厂实例 {#create-an-azure-data-factory-instance} -本指南假设您拥有 Microsoft Azure 账户,并且已经配置了订阅和资源组。如果您已经配置了 Azure Data Factory,可以安全跳过此步骤,直接使用现有服务。 +本指南假设您拥有 Microsoft Azure 帐户的访问权限,并且您已经配置了订阅和资源组。如果您已配置 Azure 数据工厂,则可以安全跳过此步骤,直接使用您现有的服务进入下一步。 -1. 登录到 [Microsoft Azure 门户](https://portal.azure.com/),点击 **创建资源**。 +1. 登录到 [Microsoft Azure 门户](https://portal.azure.com/),然后单击 **创建资源**。 -2. 在左侧的类别窗格中,选择 **分析**,然后在流行服务列表中点击 **数据工厂**。 +2. 在左侧的类别面板中,选择 **分析**,然后在热门服务列表中单击 **数据工厂**。 -3. 选择您的订阅和资源组,输入新数据工厂实例的名称,选择区域并将版本保持为 V2。 +3. 选择您的订阅和资源组,为新的数据工厂实例输入名称,选择区域并将版本保留为 V2。 -3. 点击 **审核 + 创建**,然后点击 **创建** 启动部署。 +4. 单击 **审核 + 创建**,然后单击 **创建** 以启动部署。 -一旦部署成功完成,您就可以开始使用新的 Azure Data Factory 实例。 +一旦部署成功完成,您可以开始使用新的 Azure 数据工厂实例。 ## 创建新的基于 REST 的链接服务 {#-creating-new-rest-based-linked-service} -1. 登录到 Microsoft Azure 门户,打开您的 Data Factory 实例。 +1. 登录到 Microsoft Azure 门户并打开您的数据工厂实例。 -2. 在数据工厂概述页面上,点击 **启动工作室**。 +2. 在数据工厂概述页面上,单击 **启动工作室**。 -3. 在左侧菜单中,选择 **管理**,然后进入 **链接服务**,点击 **+ 新建** 创建新的链接服务。 +3. 在左侧菜单中选择 **管理**,然后转到 **链接服务**,单击 **+ 新建** 创建新的链接服务。 -4. 在 **新链接服务搜索栏** 中,输入 **REST**,选择 **REST**,然后点击 **继续** 创建 [REST 连接器](https://learn.microsoft.com/en-us/azure/data-factory/connector-rest) 实例。 +4. 在 **新建链接服务搜索栏** 中,输入 **REST**,选择 **REST**,然后单击 **继续** 创建 [REST 连接器](https://learn.microsoft.com/en-us/azure/data-factory/connector-rest) 实例。 -5. 在链接服务配置窗格中输入新服务的名称,点击 **基本 URL** 字段,然后点击 **添加动态内容**(该链接仅在选中此字段时可见)。 +5. 在链接服务配置面板中输入新服务的名称,单击 **基本 URL** 字段,然后单击 **添加动态内容**(此链接仅在选择字段时出现)。 -6. 在动态内容窗格中,您可以创建一个参数化的 URL,这样可以在为不同的表创建数据集时稍后定义查询 —— 这使得链接服务可重用。 +6. 在动态内容面板中,您可以创建一个参数化的 URL,这使您能够在为不同表创建数据集时定义查询——这使链接服务可重用。 -7. 点击过滤器输入旁边的 **"+"**,添加一个新参数,将其命名为 `pQuery`,将类型设置为字符串,将默认值设置为 `SELECT 1`。点击 **保存**。 +7. 单击过滤输入旁边的 **"+"**,添加一个新参数,命名为 `pQuery`,将类型设置为字符串,并将默认值设置为 `SELECT 1`。然后单击 **保存**。 -8. 在表达式字段中,输入以下内容并点击 **确定**。将 `your-clickhouse-url.com` 替换为您 ClickHouse 实例的实际地址。 +8. 在表达式字段中输入以下内容并单击 **确定**。用您实际的 ClickHouse 实例地址替换 `your-clickhouse-url.com`。 ```text @{concat('https://your-clickhouse-url.com:8443/?query=', encodeUriComponent(linkedService().pQuery))} ``` -9. 回到主表单,选择基本身份验证,输入用于连接 ClickHouse HTTP 接口的用户名和密码,点击 **测试连接**。如果一切配置正确,您将看到成功消息。 +9. 返回主表单,选择基本认证,输入用于连接您的 ClickHouse HTTP 接口的用户名和密码,单击 **测试连接**。如果一切配置正确,您会看到成功消息。 -10. 点击 **创建** 完成设置。 +10. 单击 **创建** 完成设置。 现在您应该在列表中看到新注册的基于 REST 的链接服务。 -## 为 ClickHouse HTTP 接口创建新的数据集 {#creating-a-new-dataset-for-the-clickhouse-http-interface} +## 为 ClickHouse HTTP 接口创建新数据集 {#creating-a-new-dataset-for-the-clickhouse-http-interface} -现在我们已经为 ClickHouse HTTP 接口配置了链接服务,我们可以创建一个数据集,Azure Data Factory 将使用它向 ClickHouse 发送数据。 +现在我们已经为 ClickHouse HTTP 接口配置了链接服务,可以创建一个数据集,Azure 数据工厂将用其向 ClickHouse 发送数据。 -在这个示例中,我们将插入一小部分的 [环境传感器数据](https://clickhouse.com/docs/getting-started/example-datasets/environmental-sensors)。 +在这个示例中,我们将插入一小部分 [环境传感器数据](https://clickhouse.com/docs/getting-started/example-datasets/environmental-sensors)。 -1. 打开您选择的 ClickHouse 查询控制台 —— 这可以是 ClickHouse Cloud 网络界面、CLI 客户端或您用来运行查询的任何其他接口 —— 并创建目标表: +1. 打开您选择的 ClickHouse 查询控制台——这可以是 ClickHouse Cloud Web UI、CLI 客户端或您用来运行查询的其他界面——并创建目标表: ```sql CREATE TABLE sensors ( @@ -170,16 +175,16 @@ ENGINE = MergeTree ORDER BY (timestamp, sensor_id); ``` -2. 在 Azure Data Factory Studio 中,在左侧窗格中选择作者。悬停在数据集项上,点击三点图标,选择新数据集。 +2. 在 Azure 数据工厂 Studio 中,在左侧面板中选择作者。将鼠标悬停在数据集项上,单击三点图标,然后选择新建数据集。 -3. 在搜索栏中输入 **REST**,选择 **REST**,点击 **继续**。输入数据集的名称,选择您在上一步创建的 **链接服务**。点击 **确定** 创建数据集。 +3. 在搜索栏中输入 **REST**,选择 **REST**,然后单击 **继续**。为您的数据集输入名称,并选择您在上一步中创建的 **链接服务**。单击 **确定** 创建数据集。 -4. 现在您应该在左侧的数据集部分看到新创建的数据集。选择该数据集以打开其属性。您会看到在链接服务中定义的 `pQuery` 参数。点击 **值** 文本字段。然后点击 **添加动态** 内容。 +4. 现在,您应该在左侧的工厂资源面板中的数据集部分下看到您新创建的数据集。选择该数据集以打开其属性。您将看到在链接服务中定义的 `pQuery` 参数。单击 **值** 文本字段。然后单击 **添加动态** 内容。 -5. 在打开的窗格中,粘贴以下查询: +5. 在打开的面板中,粘贴以下查询: ```sql INSERT INTO sensors SETTINGS @@ -189,54 +194,53 @@ FORMAT JSONEachRow ``` :::danger - 查询中的所有单引号 `'` 必须替换为两个单引号 `''`。这是 Azure Data Factory 的表达式解析器所要求的。如果不进行转义,您可能不会立即看到错误 —— 但在您尝试使用或保存数据集时,它会失败。例如,`'best_effort'` 必须写成 `''best_effort''`。 + 查询中的所有单引号 `'` 必须替换为两个单引号 `''`。这是 Azure 数据工厂的表达式解析器的要求。如果您不对其进行转义,您可能不会立即看到错误——但在尝试使用或保存数据集时会失败。例如,`'best_effort'` 必须写为 `''best_effort''`。 ::: -6. 点击确定以保存表达式。点击测试连接。如果一切配置正确,您将看到连接成功的消息。点击页面顶部的 发布全部 以保存更改。 +6. 单击确定以保存表达式。单击测试连接。如果一切配置正确,您将看到连接成功的消息。单击页面顶部的发布所有以保存您的更改。 ### 设置示例数据集 {#setting-up-an-example-dataset} -在这个示例中,我们将不使用完整的环境传感器数据集,而只是使用一小部分可在 [传感器数据集示例](https://datasets-documentation.s3.eu-west-3.amazonaws.com/environmental/sensors.csv) 中找到的数据。 +在此示例中,我们将不使用完整的环境传感器数据集,而只使用可用的 [传感器数据集示例](https://datasets-documentation.s3.eu-west-3.amazonaws.com/environmental/sensors.csv) 的小子集。 :::info -为了使本指南更集中,我们不会详细讲解在 Azure Data Factory 中创建源数据集的确切步骤。您可以将样本数据上传到任何您选择的存储服务 —— 例如,Azure Blob 存储、Microsoft SQL Server,甚至是 Azure Data Factory 支持的其他文件格式。 +为了使本指南集中,我们将不详细说明在 Azure 数据工厂中创建源数据集的确切步骤。您可以将样本数据上传到您选择的任何存储服务——例如,Azure Blob 存储、Microsoft SQL Server,甚至是 Azure 数据工厂支持的其他文件格式。 ::: -将数据集上传到您的 Azure Blob 存储(或其他首选存储服务),然后在 Azure Data Factory Studio 中,转到工厂资源窗格。创建一个指向上传数据的新数据集。点击 发布全部 以保存更改。 +将数据集上传到您的 Azure Blob 存储(或其他首选存储服务)中,然后在 Azure 数据工厂 Studio 中转到工厂资源面板。创建一个指向已上传数据的新数据集。单击发布所有以保存您的更改。 -## 创建复制活动以将数据传输到 ClickHouse {#creating-the-copy-activity-to-transfer-data-to-clickhouse} +## 创建 Copy 活动以将数据传输到 ClickHouse {#creating-the-copy-activity-to-transfer-data-to-clickhouse} -现在我们已经配置了输入和输出数据集,我们可以设置一个 **复制数据** 活动将数据从我们的示例数据集传输到 ClickHouse 中的 `sensors` 表。 +现在我们已经配置了输入和输出数据集,可以设置 **Copy Data** 活动,将数据从示例数据集传输到 ClickHouse 中的 `sensors` 表。 -1. 打开 **Azure Data Factory Studio**,转到 **作者选项卡**。在 **工厂资源** 窗格中,悬停在 **管道** 上,点击三点图标,选择 **新建管道**。 +1. 打开 **Azure 数据工厂 Studio**,转到 **作者选项卡**。在 **工厂资源** 面板中,将鼠标悬停在 **管道** 上,单击三点图标,然后选择 **新建管道**。 -2. 在 **活动** 窗格中,展开 **移动和转换** 部分,将 **复制数据** 活动拖到画布上。 +2. 在 **活动** 面板中,展开 **移动和转换** 部分,然后将 **Copy Data** 活动拖到画布上。 -3. 选择 **源** 选项卡,选择您之前创建的源数据集。 +3. 选择 **来源** 选项卡,然后选择您之前创建的源数据集。 -4. 转到 **接收器** 选项卡,选择为您的传感器表创建的 ClickHouse 数据集。将 **请求方法** 设置为 POST。确保 **HTTP 压缩类型** 设置为 **无**。 +4. 转到 **接收方** 选项卡,选择为您的传感器表创建的 ClickHouse 数据集。将 **请求方法** 设置为 POST。确保 **HTTP 压缩类型** 设置为 **无**。 :::warning - HTTP 压缩在 Azure Data Factory 的复制数据活动中无法正常工作。当启用时,Azure 发送的有效负载仅由零字节组成 —— 可能是服务中的一个 bug。请确保保持禁用压缩。 + 在 Azure 数据工厂的 Copy Data 活动中,HTTP 压缩不能正常工作。当启用时,Azure 仅发送包含零字节的有效负载——这可能是服务中的一个错误。请确保将压缩禁用。 ::: :::info - 我们建议保持默认批处理大小为 10,000,甚至进一步增加。有关详细信息,请参见 - [选择插入策略 / 如果是同步,则批量插入](https://clickhouse.com/docs/best-practices/selecting-an-insert-strategy#batch-inserts-if-synchronous)。 + 我们建议保留默认批量大小 10,000,甚至进一步增加。如果需要更多详细信息,请参见 [选择插入策略 / 如果同步则批量插入](https://clickhouse.com/docs/best-practices/selecting-an-insert-strategy#batch-inserts-if-synchronous)。 ::: -5. 点击画布顶部的 **调试** 以运行管道。稍等片刻,活动将排队并执行。如果一切配置正确,任务应以 **成功** 状态完成。 +5. 单击画布顶部的 **调试** 运行管道。稍等片刻,活动将被排队并执行。如果一切配置正确,任务应以 **成功** 状态完成。 -6. 完成后,点击 **发布全部** 以保存您的管道和数据集更改。 +6. 完成后,单击 **发布所有** 以保存您的管道和数据集更改。 ## 其他资源 {#additional-resources-1} - [HTTP 接口](https://clickhouse.com/docs/interfaces/http) -- [使用 Azure Data Factory 从 REST 端点复制和转换数据](https://learn.microsoft.com/en-us/azure/data-factory/connector-rest?tabs=data-factory) +- [使用 Azure 数据工厂从 REST 端点复制和转换数据](https://learn.microsoft.com/en-us/azure/data-factory/connector-rest?tabs=data-factory) - [选择插入策略](https://clickhouse.com/docs/best-practices/selecting-an-insert-strategy) - [创建和配置自托管集成运行时](https://learn.microsoft.com/en-us/azure/data-factory/create-self-hosted-integration-runtime?tabs=data-factory) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/azure-data-factory/using_http_interface.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/azure-data-factory/using_http_interface.md.hash index 7d8858dfa57..198353637b2 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/azure-data-factory/using_http_interface.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/azure-data-factory/using_http_interface.md.hash @@ -1 +1 @@ -70ce4a81195e5495 +86cafd9597d1f479 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/azure-synapse/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/azure-synapse/index.md index c620f5acd4d..fcccec76371 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/azure-synapse/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/azure-synapse/index.md @@ -1,7 +1,7 @@ --- 'sidebar_label': 'Azure Synapse' 'slug': '/integrations/azure-synapse' -'description': '与 ClickHouse 一起使用 Azure Synapse 的介绍' +'description': '介绍 Azure Synapse 和 ClickHouse' 'keywords': - 'clickhouse' - 'azure synapse' @@ -11,6 +11,7 @@ - 'azure spark' - 'data' 'title': '将 Azure Synapse 与 ClickHouse 集成' +'doc_type': 'guide' --- import TOCInline from '@theme/TOCInline'; @@ -21,9 +22,9 @@ import sparkUICHSettings from '@site/static/images/integrations/data-ingestion/a # 将 Azure Synapse 与 ClickHouse 集成 -[Azure Synapse](https://azure.microsoft.com/en-us/products/synapse-analytics) 是一个集成的分析服务,结合了大数据、数据科学和仓库,以实现快速、大规模的数据分析。在 Synapse 中,Spark 池提供按需、可扩展的 [Apache Spark](https://spark.apache.org) 集群,使用户能够运行复杂的数据转换、机器学习和与外部系统的集成。 +[Azure Synapse](https://azure.microsoft.com/en-us/products/synapse-analytics) 是一种集成的分析服务,结合了大数据、数据科学和仓储,能够实现快速的大规模数据分析。在 Synapse 中,Spark 池提供按需的、可扩展的 [Apache Spark](https://spark.apache.org) 集群,让用户能够运行复杂的数据转换、机器学习和与外部系统的集成。 -本文将向您展示在 Azure Synapse 中使用 Apache Spark 时如何集成 [ClickHouse Spark 连接器](/integrations/apache-spark/spark-native-connector)。 +本文将向您展示如何在 Azure Synapse 中使用 Apache Spark 时集成 [ClickHouse Spark 连接器](/integrations/apache-spark/spark-native-connector)。 @@ -35,22 +36,23 @@ Azure Synapse 支持三种级别的 [包维护](https://learn.microsoft.com/en-u
-请遵循 [管理 Apache Spark 池库指南](https://learn.microsoft.com/en-us/azure/synapse-analytics/spark/apache-spark-manage-pool-packages),并将以下所需依赖项添加到您的 Spark 应用程序中: - - `clickhouse-spark-runtime-{spark_version}_{scala_version}-{connector_version}.jar` - [官方 Maven](https://mvnrepository.com/artifact/com.clickhouse.spark) - - `clickhouse-jdbc-{java_client_version}-all.jar` - [官方 Maven](https://mvnrepository.com/artifact/com.clickhouse/clickhouse-jdbc) +请遵循 [管理 Apache Spark 池的库指南](https://learn.microsoft.com/en-us/azure/synapse-analytics/spark/apache-spark-manage-pool-packages),并将以下所需依赖项添加到您的 Spark 应用程序中: +- `clickhouse-spark-runtime-{spark_version}_{scala_version}-{connector_version}.jar` - [官方 maven](https://mvnrepository.com/artifact/com.clickhouse.spark) +- `clickhouse-jdbc-{java_client_version}-all.jar` - [官方 maven](https://mvnrepository.com/artifact/com.clickhouse/clickhouse-jdbc) -请访问我们的 [Spark 连接器兼容性矩阵](/integrations/apache-spark/spark-native-connector#compatibility-matrix) 文档,以了解哪些版本适合您的需求。 +请访问我们的 [Spark 连接器兼容性矩阵](/integrations/apache-spark/spark-native-connector#compatibility-matrix) 文档,了解哪些版本适合您的需求。 ## 将 ClickHouse 添加为目录 {#add-clickhouse-as-catalog} 有多种方法可以将 Spark 配置添加到您的会话中: -* 自定义配置文件以在会话中加载 +* 自定义配置文件,以随您的会话加载 * 通过 Azure Synapse UI 添加配置 * 在您的 Synapse 笔记本中添加配置 -请遵循 [管理 Apache Spark 配置](https://learn.microsoft.com/en-us/azure/synapse-analytics/spark/apache-spark-azure-create-spark-configuration),并添加 [连接器所需的 Spark 配置](/integrations/apache-spark/spark-native-connector#register-the-catalog-required)。 +请遵循此 [管理 Apache Spark 配置](https://learn.microsoft.com/en-us/azure/synapse-analytics/spark/apache-spark-azure-create-spark-configuration) +并添加 [连接器所需的 Spark 配置](/integrations/apache-spark/spark-native-connector#register-the-catalog-required)。 -例如,您可以在笔记本中使用以下设置配置 Spark 会话: +例如,您可以在笔记本中使用以下设置配置您的 Spark 会话: ```python %%configure -f @@ -67,23 +69,22 @@ Azure Synapse 支持三种级别的 [包维护](https://learn.microsoft.com/en-u } ``` -确保它位于第一个单元格中,如下所示: +确保它位于第一个单元中,如下所示: -请访问 [ClickHouse Spark 配置页面](/integrations/apache-spark/spark-native-connector#configurations) 以获取其他设置。 +请访问 [ClickHouse Spark 配置页面](/integrations/apache-spark/spark-native-connector#configurations) 了解其他设置。 :::info -在使用 ClickHouse Cloud 时,请确保设置 [所需的 Spark 设置](/integrations/apache-spark/spark-native-connector#clickhouse-cloud-settings)。 +在使用 ClickHouse Cloud 时,请确保设置 [所需的 Spark 设置](/integrations/apache-spark/spark-native-connector#clickhouse-cloud-settings)。 ::: ## 设置验证 {#setup-verification} -要验证依赖项和配置是否成功设置,请访问您的会话的 Spark UI,并转到您的 `Environment` 选项卡。那里,查找与 ClickHouse 相关的设置: +要验证依赖项和配置是否成功设置,请访问您的会话的 Spark UI,并转到您的 `Environment` 选项卡。在那里,查找与 ClickHouse 相关的设置: - ## 其他资源 {#additional-resources} - [ClickHouse Spark 连接器文档](/integrations/apache-spark) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/azure-synapse/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/azure-synapse/index.md.hash index fb7de325c5d..ad92998f3d1 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/azure-synapse/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/azure-synapse/index.md.hash @@ -1 +1 @@ -9610d6fdf33e5e35 +b7d79e417d61681b diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/aws-privatelink.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/aws-privatelink.md index 6f321513b3c..6cb7b639f0e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/aws-privatelink.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/aws-privatelink.md @@ -1,8 +1,9 @@ --- 'sidebar_label': 'AWS PrivateLink for ClickPipes' -'description': '通过 AWS PrivateLink 在 ClickPipes 和数据源之间建立安全连接。' +'description': '使用 AWS PrivateLink 在 ClickPipes 与数据源之间建立安全连接。' 'slug': '/integrations/clickpipes/aws-privatelink' 'title': 'AWS PrivateLink for ClickPipes' +'doc_type': 'guide' --- import cp_service from '@site/static/images/integrations/data-ingestion/clickpipes/cp_service.png'; @@ -19,84 +20,168 @@ import Image from '@theme/IdealImage'; # AWS PrivateLink for ClickPipes -您可以使用 [AWS PrivateLink](https://aws.amazon.com/privatelink/) 在 VPC、AWS 服务、您的本地系统和 ClickHouse Cloud 之间建立安全连接,而不将流量暴露于公共互联网。 +您可以使用 [AWS PrivateLink](https://aws.amazon.com/privatelink/) 在 VPC、AWS 服务、您的本地系统和 ClickHouse Cloud 之间建立安全的连接,而无需将流量暴露给公共互联网。 -本文件概述了 ClickPipes 反向私有端点功能,允许设置 AWS PrivateLink VPC 端点。 +本文档概述了 ClickPipes 反向私有端点功能,允许设置 AWS PrivateLink VPC 端点。 + +## 支持的 ClickPipes 数据源 {#supported-sources} + +ClickPipes 反向私有端点功能仅限于以下数据源类型: +- Kafka +- Postgres +- MySQL ## 支持的 AWS PrivateLink 端点类型 {#aws-privatelink-endpoint-types} -ClickPipes 反向私有端点可以通过以下 AWS PrivateLink 方法之一进行配置: +ClickPipes 反向私有端点可以使用以下 AWS PrivateLink 方法之一进行配置: - [VPC 资源](https://docs.aws.amazon.com/vpc/latest/privatelink/privatelink-access-resources.html) -- [MSK multi-VPC 连接用于 MSK ClickPipe](https://docs.aws.amazon.com/msk/latest/developerguide/aws-access-mult-vpc.html) +- [MSK 多 VPC 连接适用于 MSK ClickPipe](https://docs.aws.amazon.com/msk/latest/developerguide/aws-access-mult-vpc.html) - [VPC 端点服务](https://docs.aws.amazon.com/vpc/latest/privatelink/privatelink-share-your-services.html) -请按照上述链接中的详细说明设置相应的 AWS PrivateLink 共享。 - ### VPC 资源 {#vpc-resource} -您可以通过 PrivateLink 在 ClickPipes 中访问 VPC 资源。 -资源配置可以针对特定主机或 RDS 集群 ARN 进行设置。 -不支持跨区域。 +您可以使用 [PrivateLink](https://docs.aws.amazon.com/vpc/latest/privatelink/privatelink-access-resources.html) 在 ClickPipes 中访问您的 VPC 资源。此方法不需要在数据源前设置负载均衡器。 -这是从 RDS 集群中获取数据的 Postgres CDC 的首选选择。 +资源配置可以针对特定主机或 RDS 集群 ARN。跨区域连接不受支持。 -有关详细信息,请参见 [入门指南](https://docs.aws.amazon.com/vpc/latest/privatelink/resource-configuration.html)。 +这是从 RDS 集群摄取 Postgres CDC 数据的首选选择。 -:::info -VPC 资源需要与 ClickPipes 帐户共享。将 `072088201116` 添加到您的资源共享配置中的允许主体中。 -有关详细信息,请参见 AWS 指南 [共享资源](https://docs.aws.amazon.com/ram/latest/userguide/working-with-sharing-create.html)。 +要与 VPC 资源设置 PrivateLink: +1. 创建资源网关 +2. 创建资源配置 +3. 创建资源共享 + + + +#### 创建资源网关 {#create-resource-gateway} + +资源网关是接收您 VPC 中指定资源流量的节点。 + +:::note +建议您的资源网关附加子网具有足够的可用 IP 地址。建议每个子网至少使用 `/26` 子网掩码。 + +对于每个 VPC 端点(每个反向私有端点),AWS 要求每个子网连续块的 16 个 IP 地址。 (`/28` 子网掩码) 如果不符合此要求,反向私有端点将转为失败状态。 ::: -### MSK multi-VPC 连接 {#msk-multi-vpc} +您可以通过 [AWS 控制台](https://docs.aws.amazon.com/vpc/latest/privatelink/create-resource-gateway.html) 创建资源网关,也可以使用以下命令: + +```bash +aws vpc-lattice create-resource-gateway \ + --vpc-identifier \ + --subnet-ids \ + --security-group-ids \ + --name +``` -MSK multi-VPC 是 AWS MSK 的内置功能,允许您将多个 VPC 连接到单个 MSK 集群。 -私有 DNS 支持是开箱即用的,不需要任何额外配置。 -不支持跨区域。 +输出将包含资源网关 ID,您将在下一步中需要它。 -这是 ClickPipes 对于 MSK 推荐的选项。 -有关详细信息,请参见 [入门指南](https://docs.aws.amazon.com/msk/latest/developerguide/mvpc-getting-started.html)。 +在您继续之前,您需要等待资源网关进入 `Active` 状态。您可以通过运行以下命令检查状态: + +```bash +aws vpc-lattice get-resource-gateway \ + --resource-gateway-identifier +``` + +#### 创建 VPC 资源配置 {#create-resource-configuration} + +资源配置与资源网关关联,使您的资源可访问。 + +您可以通过 [AWS 控制台](https://docs.aws.amazon.com/vpc/latest/privatelink/create-resource-configuration.html) 创建资源配置,也可以使用以下命令: + +```bash +aws vpc-lattice create-resource-configuration \ + --resource-gateway-identifier \ + --type \ + --resource-configuration-definition \ + --name +``` + +最简单的 [资源配置类型](https://docs.aws.amazon.com/vpc-lattice/latest/ug/resource-configuration.html#resource-configuration-types) 是单个资源配置。您可以直接使用 ARN 进行配置,或者共享一个可以公开解析的 IP 地址或域名。 + +例如,要使用 RDS 集群的 ARN 进行配置: + +```bash +aws vpc-lattice create-resource-configuration \ + --name my-rds-cluster-config \ + --type ARN \ + --resource-gateway-identifier rgw-0bba03f3d56060135 \ + --resource-configuration-definition 'arnResource={arn=arn:aws:rds:us-east-1:123456789012:cluster:my-rds-cluster}' +``` + +:::note +您不能为公开访问的集群创建资源配置。如果您的集群公开可访问,您必须在创建资源配置之前修改集群以使其私有,或改用 [IP 允许列表](/integrations/clickpipes#list-of-static-ips)。有关更多信息,请参见 [AWS 文档](https://docs.aws.amazon.com/vpc/latest/privatelink/resource-configuration.html#resource-definition)。 +::: + +输出将包含资源配置 ARN,您将在下一步中需要它。还将包含一个资源配置 ID,您将需要使用 VPC 资源建立 ClickPipe 连接。 + +#### 创建资源共享 {#create-resource-share} + +共享您的资源需要一个资源共享。这是通过资源访问管理器(RAM)进行的。 + +您可以通过 [AWS 控制台](https://docs.aws.amazon.com/ram/latest/userguide/working-with-sharing-create.html) 将资源配置放入资源共享中,或者通过运行以下命令,使用 ClickPipes 账户 ID `072088201116` (arn:aws:iam::072088201116:root): + +```bash +aws ram create-resource-share \ + --principals 072088201116 \ + --resource-arns \ + --name +``` + +输出将包含资源共享 ARN,您将需要它来设置与 VPC 资源的 ClickPipe 连接。 + +您已准备好使用 VPC 资源 [创建具有反向私有端点的 ClickPipe](#creating-clickpipe)。您需要: +- 将 `VPC 端点类型` 设置为 `VPC Resource`。 +- 将 `资源配置 ID` 设置为步骤 2 中创建的资源配置的 ID。 +- 将 `资源共享 ARN` 设置为步骤 3 中创建的资源共享的 ARN。 + +有关 VPC 资源 PrivateLink 的更多详细信息,请参见 [AWS 文档](https://docs.aws.amazon.com/vpc/latest/privatelink/privatelink-access-resources.html)。 + + + +### MSK 多 VPC 连接 {#msk-multi-vpc} + +[AWS MSK 的多 VPC 连接](https://docs.aws.amazon.com/msk/latest/developerguide/aws-access-mult-vpc.html) 是 AWS MSK 的内置功能,允许您将多个 VPC 连接到单个 MSK 集群。支持私有 DNS,即开箱即用,无需任何额外配置。跨区域连接不受支持。 + +这是 ClickPipes 针对 MSK 的推荐选项。有关更多详细信息,请参阅 [入门指南](https://docs.aws.amazon.com/msk/latest/developerguide/mvpc-getting-started.html)。 :::info -请更新您的 MSK 集群策略,并将 `072088201116` 添加到您的 MSK 集群的允许主体中。 -有关详细信息,请参见 AWS 指南 [附加集群策略](https://docs.aws.amazon.com/msk/latest/developerguide/mvpc-cluster-owner-action-policy.html)。 +更新您的 MSK 集群策略,并将 `072088201116` 添加到允许的主体中,以便访问您的 MSK 集群。有关更多详细信息,请参阅 AWS 指南 [附加集群策略](https://docs.aws.amazon.com/msk/latest/developerguide/mvpc-cluster-owner-action-policy.html)。 ::: -请查看我们的 [MSK 设置指南以获取 ClickPipes](/knowledgebase/aws-privatelink-setup-for-msk-clickpipes),了解如何设置连接。 +请遵循我们的 [ClickPipes MSK 设置指南](/knowledgebase/aws-privatelink-setup-for-msk-clickpipes) 了解如何设置连接。 ### VPC 端点服务 {#vpc-endpoint-service} -VPC 服务是与 ClickPipes 共享数据源的另一种方法。 -它需要在您的数据源前设置 NLB(网络负载均衡器)并配置 VPC 端点服务以使用 NLB。 +[VPC 端点服务](https://docs.aws.amazon.com/vpc/latest/privatelink/privatelink-share-your-services.html) 是另一种与 ClickPipes 共享数据源的方法。这需要在数据源前设置 NLB(网络负载均衡器),并配置 VPC 端点服务以使用 NLB。 -VPC 端点服务可以 [配置为私有 DNS](https://docs.aws.amazon.com/vpc/latest/privatelink/manage-dns-names.html), -该 DNS 将在 ClickPipes VPC 中可访问。 +VPC 端点服务可以与 [私有 DNS](https://docs.aws.amazon.com/vpc/latest/privatelink/manage-dns-names.html) 配置,这将在 ClickPipes VPC 中可访问。 -它是以下情况的首选选择: +这是首选选择: - 任何需要私有 DNS 支持的本地 Kafka 设置 - [Postgres CDC 的跨区域连接](/knowledgebase/aws-privatelink-setup-for-clickpipes) -- MSK 集群的跨区域连接。有关帮助,请联系 ClickHouse 支持团队。 +- MSK 集群的跨区域连接。请联系 ClickHouse 支持团队以获得帮助。 -有关详细信息,请参见 [入门指南](https://docs.aws.amazon.com/vpc/latest/privatelink/privatelink-share-your-services.html)。 +有关更多详细信息,请参见 [入门指南](https://docs.aws.amazon.com/vpc/latest/privatelink/privatelink-share-your-services.html)。 :::info -将 ClickPipes 帐户 ID `072088201116` 添加到您的 VPC 端点服务的允许主体中。 -有关详细信息,请参见 AWS 指南 [管理权限](https://docs.aws.amazon.com/vpc/latest/privatelink/configure-endpoint-service.html#add-remove-permissions)。 +将 ClickPipes 账户 ID `072088201116` 添加到允许的主体中,以便访问您的 VPC 端点服务。有关管理权限的更多详细信息,请参见 AWS 指南 [管理权限](https://docs.aws.amazon.com/vpc/latest/privatelink/configure-endpoint-service.html#add-remove-permissions)。 ::: :::info -可以为 ClickPipes 配置 [跨区域访问](https://docs.aws.amazon.com/vpc/latest/privatelink/privatelink-share-your-services.html#endpoint-service-cross-region)。 -将 [您的 ClickPipe 区域](#aws-privatelink-regions) 添加到您的 VPC 端点服务的允许区域中。 +可以为 ClickPipes 配置 [跨区域访问](https://docs.aws.amazon.com/vpc/latest/privatelink/privatelink-share-your-services.html#endpoint-service-cross-region)。将 [您的 ClickPipe 区域](#aws-privatelink-regions) 添加到 VPC 端点服务中的允许区域。 ::: -## 创建带有反向私有端点的 ClickPipe {#creating-clickpipe} +## 创建具有反向私有端点的 ClickPipe {#creating-clickpipe} + + -1. 访问您 ClickHouse Cloud 服务的 SQL 控制台。 +1. 访问您的 ClickHouse Cloud 服务的 SQL 控制台。 -2. 在左侧菜单上选择 `Data Sources` 按钮并单击 "Set up a ClickPipe" +2. 在左侧菜单中选择 `Data Sources` 按钮,然后点击“设置 ClickPipe” @@ -108,13 +193,12 @@ VPC 端点服务可以 [配置为私有 DNS](https://docs.aws.amazon.com/vpc/lat -5. 选择现有的反向私有端点或创建新的。 +5. 选择任何现有的反向私有端点或创建一个新端点。 :::info -如果需要 RDS 的跨区域访问,则需要创建 VPC 端点服务, -[本指南应提供](/knowledgebase/aws-privatelink-setup-for-clickpipes) 一个良好的起点来设置它。 +如果 RDS 需要跨区域访问,您需要创建一个 VPC 端点服务,并且 [本指南应提供](/knowledgebase/aws-privatelink-setup-for-clickpipes) 一个好的起点来设置它。 -对于同一区域访问,创建 VPC 资源是推荐的方法。 +对于同区域访问,创建 VPC 资源是推荐的方式。 ::: @@ -124,59 +208,55 @@ VPC 端点服务可以 [配置为私有 DNS](https://docs.aws.amazon.com/vpc/lat - 对于 VPC 资源,提供配置共享 ARN 和配置 ID。 - - 对于 MSK multi-VPC,提供集群 ARN 和用于创建端点的身份验证方法。 + - 对于 MSK 多 VPC,提供集群 ARN 和用于与创建的端点一起使用的身份验证方法。 - 对于 VPC 端点服务,提供服务名称。 -7. 单击 `Create` 并等待反向私有端点准备就绪。 +7. 点击 `Create`,并等待反向私有端点准备就绪。 - 如果您正在创建新的端点,则设置该端点可能需要一些时间。 - 一旦端点准备就绪,页面将自动刷新。 - VPC 端点服务可能需要在您的 AWS 控制台中接受连接请求。 + 如果您正在创建一个新端点,那么设置这个端点将需要一些时间。一旦端点准备就绪,页面将自动刷新。VPC 端点服务可能需要在您的 AWS 控制台中接受连接请求。 8. 一旦端点准备就绪,您可以使用 DNS 名称连接到数据源。 - 在端点列表中,您可以看到可用端点的 DNS 名称。 - 它可以是 ClickPipes 自行配置的内部 DNS 名称或由 PrivateLink 服务提供的私有 DNS 名称。 - DNS 名称不是完整的网络地址。 - 根据数据源添加对应的端口。 + 在端点列表中,您可以看到可用端点的 DNS 名称。它可以是 ClickPipes 提供的内部 DNS 名称或由 PrivateLink 服务提供的私有 DNS 名称。DNS 名称不是完整的网络地址。根据数据源添加端口。 MSK 连接字符串可以在 AWS 控制台中访问。 - 要查看完整的 DNS 名称列表,请在云服务设置中访问它。 + 要查看完整的 DNS 名称列表,可以在云服务设置中访问。 -## 管理现有的反向私有端点 {#managing-existing-endpoints} + -您可以在 ClickHouse Cloud 服务设置中管理现有的反向私有端点: +## 管理现有反向私有端点 {#managing-existing-endpoints} -1. 在侧边栏找到 `Settings` 按钮并单击它。 +您可以在 ClickHouse Cloud 服务设置中管理现有反向私有端点: - + + +1. 在侧边栏找到 `Settings` 按钮并点击它。 + + 2. 在 `ClickPipe reverse private endpoints` 部分中点击 `Reverse private endpoints`。 - + - 反向私有端点的扩展信息将在飞出窗口中显示。 + 反向私有端点的扩展信息会在弹出窗口中显示。 - 可以从这里移除端点。这将影响使用该端点的任何 ClickPipes。 + 可以从这里移除端点。这将影响使用此端点的任何 ClickPipes。 -## 支持的 AWS 区域 {#aws-privatelink-regions} + -以下 AWS 区域支持 AWS PrivateLink: +## 支持的 AWS 区域 {#aws-privatelink-regions} -- `us-east-1` - 用于运行在 `us-east-1` 区域的 ClickHouse 服务 -- `eu-central-1` - 用于在欧洲区域运行的 ClickHouse 服务 -- `us-east-2` - 用于其他地方运行的 ClickHouse 服务 +ClickPipes 的 AWS PrivateLink 支持仅限于特定 AWS 区域。请参阅 [ClickPipes 区域列表](/integrations/clickpipes#list-of-static-ips) 查看可用区域。 -此限制不适用于 PrivateLink VPC 端点服务类型,因为它支持跨区域连接。 +此限制不适用于启用跨区域连接的 PrivateLink VPC 端点服务。 ## 限制 {#limitations} -在 ClickHouse Cloud 中为 ClickPipes 创建的 AWS PrivateLink 端点无法保证与 ClickHouse Cloud 服务位于同一 AWS 区域。 +在 ClickHouse Cloud 中创建的 ClickPipes 的 AWS PrivateLink 端点无法保证与 ClickHouse Cloud 服务位于同一 AWS 区域。 目前,仅 VPC 端点服务支持跨区域连接。 -私有端点与特定 ClickHouse 服务关联,无法在服务之间转移。 -对于单个 ClickHouse 服务,可以有多个 ClickPipes 共享同一个端点。 +私有端点与特定的 ClickHouse 服务关联,无法在服务之间传输。多个 ClickPipes 针对单个 ClickHouse 服务可以重用相同的端点。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/aws-privatelink.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/aws-privatelink.md.hash index 282ec17ab29..c3877a179c6 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/aws-privatelink.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/aws-privatelink.md.hash @@ -1 +1 @@ -70c753afe0a0660c +1c232fde99f09a8b diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/index.md index 318b1804abf..32cb2a5407d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/index.md @@ -3,6 +3,7 @@ 'description': '无缝连接您的外部数据源到 ClickHouse Cloud。' 'slug': '/integrations/clickpipes' 'title': '与 ClickHouse Cloud 集成' +'doc_type': 'guide' --- import Kafkasvg from '@site/static/images/integrations/logos/kafka.svg'; @@ -17,9 +18,11 @@ import DOsvg from '@site/static/images/integrations/logos/digitalocean.svg'; import ABSsvg from '@site/static/images/integrations/logos/azureblobstorage.svg'; import Postgressvg from '@site/static/images/integrations/logos/postgresql.svg'; import Mysqlsvg from '@site/static/images/integrations/logos/mysql.svg'; +import Mongodbsvg from '@site/static/images/integrations/logos/mongodb.svg'; import redpanda_logo from '@site/static/images/integrations/logos/logo_redpanda.png'; import clickpipes_stack from '@site/static/images/integrations/data-ingestion/clickpipes/clickpipes_stack.png'; import cp_custom_role from '@site/static/images/integrations/data-ingestion/clickpipes/cp_custom_role.png'; +import cp_advanced_settings from '@site/static/images/integrations/data-ingestion/clickpipes/cp_advanced_settings.png'; import Image from '@theme/IdealImage'; @@ -27,74 +30,108 @@ import Image from '@theme/IdealImage'; ## 介绍 {#introduction} -[ClickPipes](/integrations/clickpipes) 是一个管理集成平台,使从多种来源获取数据变得如此简单,只需单击几下按钮。 ClickPipes 的强大和可扩展架构旨在应对最苛刻的工作负载,确保一致的性能和可靠性。 ClickPipes 可用于长期流式传输需求或一次性数据加载作业。 +[ClickPipes](/integrations/clickpipes) 是一个托管集成平台,使从多种来源摄取数据变得简单,仅需点击几个按钮。ClickPipes 设计用于满足最苛刻的工作负载,其强大且可扩展的架构确保持续的性能和可靠性。ClickPipes 可用于长期流式传输需求或一次性数据加载作业。 ## 支持的数据源 {#supported-data-sources} -| 名称 | 徽标 | 类型 | 状态 | 描述 | -|----------------------|---------------------------------------------------------------------------------------------------|-----------|-------------------|--------------------------------------------------------------------------------------------------| -| Apache Kafka | | 流式 | 稳定 | 配置 ClickPipes,开始从 Apache Kafka 中获取流式数据到 ClickHouse Cloud。 | -| Confluent Cloud | | 流式 | 稳定 | 通过我们的直接集成,解锁 Confluent 和 ClickHouse Cloud 的强大组合。 | -| Redpanda | | 流式 | 稳定 | 配置 ClickPipes,开始从 Redpanda 中获取流式数据到 ClickHouse Cloud。 | -| AWS MSK | | 流式 | 稳定 | 配置 ClickPipes,开始从 AWS MSK 中获取流式数据到 ClickHouse Cloud。 | -| Azure Event Hubs | | 流式 | 稳定 | 配置 ClickPipes,开始从 Azure Event Hubs 中获取流式数据到 ClickHouse Cloud。 | -| WarpStream | | 流式 | 稳定 | 配置 ClickPipes,开始从 WarpStream 中获取流式数据到 ClickHouse Cloud。 | -| Amazon S3 | | 对象存储 | 稳定 | 配置 ClickPipes 以获取大量来自对象存储的数据。 | -| Google Cloud Storage | | 对象存储 | 稳定 | 配置 ClickPipes 以获取大量来自对象存储的数据。 | -| DigitalOcean Spaces | | 对象存储 | 稳定 | 配置 ClickPipes 以获取大量来自对象存储的数据。 | -| Azure Blob Storage | | 对象存储 | 私有测试 | 配置 ClickPipes 以获取大量来自对象存储的数据。 | -| Amazon Kinesis | | 流式 | 稳定 | 配置 ClickPipes,开始从 Amazon Kinesis 中获取流式数据到 ClickHouse Cloud。 | -| Postgres | | DBMS | 稳定 | 配置 ClickPipes,开始从 Postgres 中获取数据到 ClickHouse Cloud。 | -| MySQL | | DBMS | 私有测试 | 配置 ClickPipes,开始从 MySQL 中获取数据到 ClickHouse Cloud。 | +| 名称 | 标志 | 类型 | 状态 | 描述 | +|----------------------------------------------------|--------------------------------------------------------------------------------------------------|----------|------------------|--------------------------------------------------------------------------------------------------| +| [Apache Kafka](/integrations/clickpipes/kafka) | | 流式 | 稳定 | 配置 ClickPipes 并开始将流式数据从 Apache Kafka 导入 ClickHouse Cloud。 | +| Confluent Cloud | | 流式 | 稳定 | 通过我们的直接集成释放 Confluent 和 ClickHouse Cloud 的组合力量。 | +| Redpanda | | 流式 | 稳定 | 配置 ClickPipes 并开始将流式数据从 Redpanda 导入 ClickHouse Cloud。 | +| AWS MSK | | 流式 | 稳定 | 配置 ClickPipes 并开始将流式数据从 AWS MSK 导入 ClickHouse Cloud。 | +| Azure Event Hubs | | 流式 | 稳定 | 配置 ClickPipes 并开始将流式数据从 Azure Event Hubs 导入 ClickHouse Cloud。有关指导,请参见 [Azure Event Hubs FAQ](/integrations/clickpipes/kafka/faq/#azure-eventhubs)。 | +| WarpStream | | 流式 | 稳定 | 配置 ClickPipes 并开始将流式数据从 WarpStream 导入 ClickHouse Cloud。 | +| Amazon S3 | | 对象存储 | 稳定 | 配置 ClickPipes 从对象存储中摄取大量数据。 | +| Google Cloud Storage | | 对象存储 | 稳定 | 配置 ClickPipes 从对象存储中摄取大量数据。 | +| DigitalOcean Spaces | | 对象存储 | 稳定 | 配置 ClickPipes 从对象存储中摄取大量数据。 | +| Azure Blob Storage | | 对象存储 | 稳定 | 配置 ClickPipes 从对象存储中摄取大量数据。 | +| [Amazon Kinesis](/integrations/clickpipes/kinesis) | | 流式 | 稳定 | 配置 ClickPipes 并开始将流式数据从 Amazon Kinesis 导入 ClickHouse Cloud。 | +| [Postgres](/integrations/clickpipes/postgres) | | DBMS | 稳定 | 配置 ClickPipes 并开始将数据从 Postgres 导入 ClickHouse Cloud。 | +| [MySQL](/integrations/clickpipes/mysql) | | DBMS | 公共测试版 | 配置 ClickPipes 并开始将数据从 MySQL 导入 ClickHouse Cloud。 | +| [MongoDB](/integrations/clickpipes/mongodb) | | DBMS | 私人预览 | 配置 ClickPipes 并开始将数据从 MongoDB 导入 ClickHouse Cloud。 | + +更多连接器将会添加到 ClickPipes,您可以通过 [联系我们](https://clickhouse.com/company/contact?loc=clickpipes) 了解更多信息。 +## 静态 IP 列表 {#list-of-static-ips} -更多连接器将添加到 ClickPipes,您可以通过 [联系我们](https://clickhouse.com/company/contact?loc=clickpipes) 了解更多信息。 - +以下是 ClickPipes 用于连接到外部服务的静态 NAT IP(按区域划分)。将相关实例区域的 IP 添加到您的 IP 允许列表中以允许流量。 + +对于所有服务,ClickPipes 的流量将源自基于服务位置的默认区域: +- **eu-central-1**:适用于所有 EU 区域的服务(包括 GCP 和 Azure EU 区域)。 +- **us-east-1**:适用于 AWS `us-east-1` 中的所有服务。 +- **ap-south-1**:适用于 AWS `ap-south-1` 自 2025 年 6 月 25 日创建的服务(在此日期之前创建的服务使用 `us-east-2` 的 IP)。 +- **ap-southeast-2**:适用于 AWS `ap-southeast-2` 自 2025 年 6 月 25 日创建的服务(在此日期之前创建的服务使用 `us-east-2` 的 IP)。 +- **us-west-2**:适用于 AWS `us-west-2` 自 2025 年 6 月 24 日创建的服务(在此日期之前创建的服务使用 `us-east-2` 的 IP)。 +- **us-east-2**:适用于未明确列出的所有其他区域(包括 GCP 和 Azure US 区域)。 + +| AWS 区域 | IP 地址 | +|---------------------------------------| ------------------------------------------------------------------------------------------------------------------------------------------------ | +| **eu-central-1** | `18.195.233.217`, `3.127.86.90`, `35.157.23.2`, `18.197.167.47`, `3.122.25.29`, `52.28.148.40` | +| **us-east-1** | `54.82.38.199`, `3.90.133.29`, `52.5.177.8`, `3.227.227.145`, `3.216.6.184`, `54.84.202.92`, `3.131.130.196`, `3.23.172.68`, `3.20.208.150` | +| **us-east-2** | `3.131.130.196`, `3.23.172.68`, `3.20.208.150`, `3.132.20.192`, `18.119.76.110`, `3.134.185.180` | +| **ap-south-1** (自 2025 年 6 月 25 日起) | `13.203.140.189`, `13.232.213.12`, `13.235.145.208`, `35.154.167.40`, `65.0.39.245`, `65.1.225.89` | +| **ap-southeast-2** (自 2025 年 6 月 25 日起) | `3.106.48.103`, `52.62.168.142`, `13.55.113.162`, `3.24.61.148`, `54.206.77.184`, `54.79.253.17` | +| **us-west-2** (自 2025 年 6 月 24 日起) | `52.42.100.5`, `44.242.47.162`, `52.40.44.52`, `44.227.206.163`, `44.246.241.23`, `35.83.230.19` | -## 静态 IP 列表 {#list-of-static-ips} +## 调整 ClickHouse 设置 {#adjusting-clickhouse-settings} +ClickHouse Cloud 为大多数用例提供了合理的默认值。然而,如果您需要针对 ClickPipes 目标表调整一些 ClickHouse 设置,特别为 ClickPipes 创建的角色是最灵活的解决方案。 +步骤: +1. 创建一个自定义角色 `CREATE ROLE my_clickpipes_role SETTINGS ...`。有关详细信息,请参阅 [CREATE ROLE](/sql-reference/statements/create/role.md) 语法。 +2. 在 ClickPipes 创建期间的“详细信息和设置”步骤中,将自定义角色添加到 ClickPipes 用户。 -以下是 ClickPipes 用于连接到您的外部服务的静态 NAT IP(按地区划分)。将您相关实例区域的 IP 添加到您的 IP 允许列表中以允许流量。如果您的实例区域未在此列出,则将使用默认区域: + -- **eu-central-1** 适用于所有 EU 区域 -- **us-east-1** 适用于 `us-east-1` 中的实例 -- **us-east-2** 适用于其他区域 +## 调整 ClickPipes 高级设置 {#clickpipes-advanced-settings} +ClickPipes 提供了覆盖大多数用例需求的合理默认值。如果您的用例需要额外的微调,您可以调整以下设置: -| ClickHouse Cloud 区域 | IP 地址 | -|-------------------------|-------------------------------------------------------------------------------| -| **eu-central-1** | `18.195.233.217`, `3.127.86.90`, `35.157.23.2`, `18.197.167.47`, `3.122.25.29`, `52.28.148.40` | -| **us-east-2** | `3.131.130.196`, `3.23.172.68`, `3.20.208.150`, `3.132.20.192`, `18.119.76.110`, `3.134.185.180` | -| **us-east-1** | `54.82.38.199`, `3.90.133.29`, `52.5.177.8`, `3.227.227.145`, `3.216.6.184`, `54.84.202.92`, `3.131.130.196`, `3.23.172.68`, `3.20.208.150` | +### 对象存储 ClickPipes {#clickpipes-advanced-settings-object-storage} +| 设置 | 默认值 | 描述 | +|------------------------------------|---------------|---------------------------------------------------------------------------------------| +| `Max insert bytes` | 10GB | 在单个插入批处理中处理的字节数。 | +| `Max file count` | 100 | 在单个插入批处理中处理的最大文件数。 | +| `Max threads` | auto(3) | [文件处理的最大并发线程数](/operations/settings/settings#max_threads)。 | +| `Max insert threads` | 1 | [文件处理的最大并发插入线程数](/operations/settings/settings#max_insert_threads)。 | +| `Min insert block size bytes` | 1GB | [可插入到表中的块的最小字节大小](/operations/settings/settings#min_insert_block_size_bytes)。 | +| `Max download threads` | 4 | [最大并发下载线程数](/operations/settings/settings#max_download_threads)。 | +| `Object storage polling interval` | 30s | 配置在将数据插入 ClickHouse 集群之前的最大等待时间。 | +| `Parallel distributed insert select` | 2 | [并行分布式插入选择设置](/operations/settings/settings#parallel_distributed_insert_select)。 | +| `Parallel view processing` | false | 是否启用[附加视图的并行推送而非顺序推送](/operations/settings/settings#parallel_view_processing)。 | +| `Use cluster function` | true | 是否在多个节点之间并行处理文件。 | -## 调整 ClickHouse 设置 {#adjusting-clickhouse-settings} + -ClickHouse Cloud 为大多数用例提供合理的默认设置。 然而,如果您需要为 ClickPipes 目标表调整某些 ClickHouse 设置,专用角色是最灵活的解决方案。 -步骤: -1. 创建自定义角色 `CREATE ROLE my_clickpipes_role SETTINGS ...`。有关详细信息,请参见 [CREATE ROLE](/sql-reference/statements/create/role.md) 语法。 -2. 在 ClickPipes 创建过程中,在 `细节和设置` 步骤中将自定义角色添加到 ClickPipes 用户。 +### 流式 ClickPipes {#clickpipes-advanced-settings-streaming} - +| 设置 | 默认值 | 描述 | +|------------------------------------|---------------|---------------------------------------------------------------------------------------| +| `Streaming max insert wait time` | 5s | 配置在将数据插入 ClickHouse 集群之前的最大等待时间。 | ## 错误报告 {#error-reporting} +ClickPipes 将根据数据摄取过程中的错误类型将错误存储在两个单独的表中。 +### 记录错误 {#record-errors} +ClickPipes 将在您的目标表旁创建一个表,后缀为 `_clickpipes_error`。该表将包含来自格式错误的数据或模式不匹配的任何错误,并将包括整个无效消息。该表具有 [TTL](/engines/table-engines/mergetree-family/mergetree#table_engine-mergetree-ttl) 为 7 天。 +### 系统错误 {#system-errors} +与 ClickPipe 操作相关的错误将存储在 `system.clickpipes_log` 表中。这将存储与您的 ClickPipe 操作相关的所有其他错误(网络、连接等)。该表具有 [TTL](/engines/table-engines/mergetree-family/mergetree#table_engine-mergetree-ttl) 为 7 天。 -ClickPipes 将在您的目标表旁创建一个后缀为 `_clickpipes_error` 的表。该表将包含来自 ClickPipe 操作(网络、连接等)的任何错误,以及任何不符合模式的数据。错误表的 [TTL](/engines/table-engines/mergetree-family/mergetree#table_engine-mergetree-ttl) 为 7 天。如果 ClickPipes 在 15 分钟后无法连接到数据源或目标,则 ClickPipes 实例停止并在错误表中存储适当的消息(前提是 ClickHouse 实例可用)。 - -## 常见问题解答 {#faq} +如果 ClickPipes 在 15 分钟内无法连接到数据源,或者在 1 小时内无法连接到目标,ClickPipes 实例将停止并在系统错误表中存储适当的消息(前提是 ClickHouse 实例可用)。 +## 常见问题 {#faq} - **什么是 ClickPipes?** - ClickPipes 是一个 ClickHouse Cloud 功能,使用户能够轻松连接他们的 ClickHouse 服务与外部数据源,特别是 Kafka。使用 ClickPipes for Kafka,用户可以轻松地持续将数据加载到 ClickHouse 中,使其可用于实时分析。 + ClickPipes 是 ClickHouse Cloud 的一项功能,使用户能够轻松地将 ClickHouse 服务连接到外部数据源,特别是 Kafka。通过 ClickPipes for Kafka,用户可以轻松地将数据持续加载到 ClickHouse 中,使其可用于实时分析。 -- **ClickPipes 是否支持数据转换?** +- **ClickPipes 支持数据转换吗?** - 是的,ClickPipes 通过暴露 DDL 创建来支持基本数据转换。 然后,您可以在数据加载到 ClickHouse Cloud 服务的目标表时,利用 ClickHouse 的 [物化视图功能](/guides/developer/cascading-materialized-views) 对数据进行更高级的转换。 + 是的,ClickPipes 支持通过暴露 DDL 创建来进行基本的数据转换。您可以利用 ClickHouse 的 [物化视图功能](/guides/developer/cascading-materialized-views) 对加载到 ClickHouse Cloud 服务的目标表的数据应用更高级的转换。 -- **使用 ClickPipes 是否需要额外费用?** +- **使用 ClickPipes 会产生额外费用吗?** - ClickPipes 按两个维度计费:获取的数据和计算。定价的完整细节可在 [此页面](/cloud/manage/jan-2025-faq/pricing-dimensions#clickpipes-pricing-faq) 上找到。运行 ClickPipes 可能还会导致在目标 ClickHouse Cloud 服务上产生与任何数据加载工作负载类似的间接计算和存储费用。 + ClickPipes 在两个维度上计费:摄取的数据和计算。定价的完整细节可以在 [此页面](/cloud/reference/billing/clickpipes) 上找到。运行 ClickPipes 也可能会在目标 ClickHouse Cloud 服务上产生间接的计算和存储费用,类似于任何摄取工作负载。 -- **使用 ClickPipes for Kafka 时有没有办法处理错误或故障?** +- **在使用 ClickPipes for Kafka 时,有没有办法处理错误或故障?** - 是的,当从 Kafka 消费数据时,如果发生故障,ClickPipes for Kafka 会自动重试。 ClickPipes 还支持启用一个专用错误表,该表将在 7 天内保存错误和格式不正确的数据。 + 是的,ClickPipes for Kafka 在从 Kafka 消费数据时,如果遇到任何操作问题(包括网络问题、连接问题等),将自动重试。在遇到格式错误的数据或无效的模式时,ClickPipes 将在 record_error 表中存储记录并继续处理。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/index.md.hash index cba18ad33c3..7b641edab1a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/index.md.hash @@ -1 +1 @@ -8c90a2382c9f48f0 +1a591c9deef6bcf5 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/kafka.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/kafka.md deleted file mode 100644 index dba5530a759..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/kafka.md +++ /dev/null @@ -1,390 +0,0 @@ ---- -'sidebar_label': 'ClickPipes for Kafka' -'description': '无缝连接您的 Kafka 数据源到 ClickHouse Cloud。' -'slug': '/integrations/clickpipes/kafka' -'sidebar_position': 1 -'title': '将 Kafka 与 ClickHouse Cloud 集成' ---- - -import Kafkasvg from '@site/static/images/integrations/logos/kafka.svg'; -import Confluentsvg from '@site/static/images/integrations/logos/confluent.svg'; -import Msksvg from '@site/static/images/integrations/logos/msk.svg'; -import Azureeventhubssvg from '@site/static/images/integrations/logos/azure_event_hubs.svg'; -import Warpstreamsvg from '@site/static/images/integrations/logos/warpstream.svg'; -import redpanda_logo from '@site/static/images/integrations/logos/logo_redpanda.png'; -import cp_service from '@site/static/images/integrations/data-ingestion/clickpipes/cp_service.png'; -import cp_step0 from '@site/static/images/integrations/data-ingestion/clickpipes/cp_step0.png'; -import cp_step1 from '@site/static/images/integrations/data-ingestion/clickpipes/cp_step1.png'; -import cp_step2 from '@site/static/images/integrations/data-ingestion/clickpipes/cp_step2.png'; -import cp_step3 from '@site/static/images/integrations/data-ingestion/clickpipes/cp_step3.png'; -import cp_step4a from '@site/static/images/integrations/data-ingestion/clickpipes/cp_step4a.png'; -import cp_step4a3 from '@site/static/images/integrations/data-ingestion/clickpipes/cp_step4a3.png'; -import cp_step4b from '@site/static/images/integrations/data-ingestion/clickpipes/cp_step4b.png'; -import cp_step5 from '@site/static/images/integrations/data-ingestion/clickpipes/cp_step5.png'; -import cp_success from '@site/static/images/integrations/data-ingestion/clickpipes/cp_success.png'; -import cp_remove from '@site/static/images/integrations/data-ingestion/clickpipes/cp_remove.png'; -import cp_destination from '@site/static/images/integrations/data-ingestion/clickpipes/cp_destination.png'; -import cp_overview from '@site/static/images/integrations/data-ingestion/clickpipes/cp_overview.png'; -import Image from '@theme/IdealImage'; - - -# 将 Kafka 与 ClickHouse Cloud 集成 -## 前提条件 {#prerequisite} -您已熟悉 [ClickPipes 简介](./index.md)。 - -## 创建您的第一个 Kafka ClickPipe {#creating-your-first-kafka-clickpipe} - -1. 访问您 ClickHouse Cloud 服务的 SQL 控制台。 - - - -2. 在左侧菜单中选择 `Data Sources` 按钮,并点击“设置 ClickPipe”。 - - - -3. 选择您的数据源。 - - - -4. 填写表单,为您的 ClickPipe 提供一个名称、可选描述、您的凭据和其他连接细节。 - - - -5. 配置模式注册表。对于 Avro 流,要求提供有效的模式;对于 JSON,则是可选的。该模式将用于解析 [AvroConfluent](../../../interfaces/formats.md/#data-format-avro-confluent) 或验证所选主题上的 JSON 消息。 -- 无法解析的 Avro 消息或未通过验证的 JSON 消息将生成错误。 -- 模式注册表的“根”路径。例如,Confluent Cloud 模式注册表 URL 只是一个没有路径的 HTTPS url,如 `https://test-kk999.us-east-2.aws.confluent.cloud`。如果仅指定根路径,则在第 4 步中用于确定列名称和类型的模式将由嵌入在示例 Kafka 消息中的 id 确定。 -- 使用数字模式 id 的模式文档路径 `/schemas/ids/[ID]`。使用模式 id 的完整 url 为 `https://registry.example.com/schemas/ids/1000`。 -- 使用主题名称的模式文档路径 `/subjects/[subject_name]`。可以通过在 url 后面附加 `/versions/[version]` 来引用特定版本(否则 ClickPipes 将检索最新版本)。使用模式主题的完整 url 为 `https://registry.example.com/subjects/events` 或 `https://registry/example.com/subjects/events/versions/4`。 - -请注意,在所有情况下,如果消息中嵌入的模式 ID 指向已更新或不同的模式,ClickPipes 将自动从注册表中检索。 如果消息是写入的,没有嵌入的模式 id,则必须指定特定模式 ID 或主题以解析所有消息。 - -6. 选择您的主题,用户界面将显示主题中的示例文档。 - - - -7. 在下一步中,您可以选择将数据摄取到新 ClickHouse 表中还是重用现有表。按照屏幕中的说明修改你的表名称、模式和设置。您可以在顶部的示例表中实时预览您的更改。 - - - - 您还可以使用提供的控件自定义高级设置。 - - - -8. 或者,您可以选择将数据摄取到现有 ClickHouse 表中。在这种情况下,用户界面将允许您将来源字段映射到所选目标表中的 ClickHouse 字段。 - - - -9. 最后,您可以为内部 ClickPipes 用户配置权限。 - - **权限:** ClickPipes 将为写入目标表的数据创建一个专用用户。您可以使用自定义角色或预定义角色之一为此内部用户选择一个角色: - - `完全访问`: 拥有对集群的完全访问权限。如果您在目标表中使用物化视图或字典,这可能会很有用。 - - `仅目标表`: 仅对目标表拥有 `INSERT` 权限。 - - - -10. 通过点击“完成设置”,系统将注册您的 ClickPipe,您将能够在摘要表中看到它。 - - - - - - 摘要表提供控件以从来源或 ClickHouse 中显示目标表的示例数据。 - - - - 以及控件以删除 ClickPipe 并显示摄取作业的摘要。 - - - -11. **恭喜!** 您已成功设置您的第一个 ClickPipe。如果这是一个流式 ClickPipe,它将持续运行,从远程数据源实时摄取数据。 - -## 支持的数据源 {#supported-data-sources} - -| 名称 |Logo|类型 | 状态 | 描述 | -|-----------------------|----|-------|----------------|------------------------------------------------------------------------------------------------------| -| Apache Kafka ||流式 | 稳定 | 配置 ClickPipes 并开始从 Apache Kafka 向 ClickHouse Cloud 摄取流式数据。 | -| Confluent Cloud ||流式 | 稳定 | 通过我们的直接集成释放 Confluent 和 ClickHouse Cloud 的组合力量。 | -| Redpanda ||流式 | 稳定 | 配置 ClickPipes 并开始从 Redpanda 向 ClickHouse Cloud 摄取流式数据。 | -| AWS MSK ||流式 | 稳定 | 配置 ClickPipes 并开始从 AWS MSK 向 ClickHouse Cloud 摄取流式数据。 | -| Azure Event Hubs ||流式 | 稳定 | 配置 ClickPipes 并开始从 Azure Event Hubs 向 ClickHouse Cloud 摄取流式数据。 | -| WarpStream ||流式 | 稳定 | 配置 ClickPipes 并开始从 WarpStream 向 ClickHouse Cloud 摄取流式数据。 | - -更多连接器将被添加到 ClickPipes,您可以通过 [与我们联系](https://clickhouse.com/company/contact?loc=clickpipes) 了解更多信息。 - -## 支持的数据格式 {#supported-data-formats} - -支持的格式有: -- [JSON](../../../interfaces/formats.md/#json) -- [AvroConfluent](../../../interfaces/formats.md/#data-format-avro-confluent) - -### 支持的数据类型 {#supported-data-types} - -#### 标准类型支持 {#standard-types-support} -当前 ClickPipes 支持以下标准 ClickHouse 数据类型: - -- 基本数字类型 - \[U\]Int8/16/32/64 和 Float32/64 -- 大整型 - \[U\]Int128/256 -- 十进制类型 -- 布尔值 -- 字符串 -- 固定字符串 -- 日期,Date32 -- 日期时间,DateTime64(仅支持 UTC 时区) -- Enum8/Enum16 -- UUID -- IPv4 -- IPv6 -- 所有 ClickHouse LowCardinality 类型 -- 具有任何上述类型(包括 Nullable)的键和值的 Map -- 使用任何上述类型(包括 Nullable,单层深度)的元组和数组 - -#### 变体类型支持(实验性) {#variant-type-support} -如果您的 Cloud 服务正在运行 ClickHouse 25.3 或更高版本,则变体类型的支持是自动的。否则,您将需要提交支持票以在您的服务上启用它。 - -ClickPipes 在以下情况下支持变体类型: -- Avro 联合。如果您的 Avro 模式包含多个非空类型的联合,ClickPipes 将推断适当的变体类型。否则,对于 Avro 数据,不支持变体类型。 -- JSON 字段。您可以手动为源数据流中的任何 JSON 字段指定变体类型(如 `Variant(String, Int64, DateTime)`)。由于 ClickPipes 确定要使用的正确变体子类型的方式,因此变体定义中只能使用一个整数或日期时间类型 - 例如 `Variant(Int64, UInt32)` 不受支持。 - -#### JSON 类型支持(实验性) {#json-type-support} -如果您的 Cloud 服务正在运行 ClickHouse 25.3 或更高版本,则 JSON 类型的支持是自动的。否则,您将需要提交支持票以在您的服务上启用它。 - -ClickPipes 在以下情况下支持 JSON 类型: -- Avro 记录类型可以始终分配给 JSON 列。 -- 如果列实际包含 JSON 字符串对象,则 Avro 字符串和字节类型可以分配给 JSON 列。 -- 始终为 JSON 对象的 JSON 字段可以分配给 JSON 目标列。 - -请注意,您需要手动将目标列更改为所需的 JSON 类型,包括任何固定或跳过的路径。 - -### Avro {#avro} -#### 支持的 Avro 数据类型 {#supported-avro-data-types} - -ClickPipes 支持所有 Avro 原语和复杂类型,以及除 `time-millis`、`time-micros`、`local-timestamp-millis`、`local_timestamp-micros` 和 `duration` 之外的所有 Avro 逻辑类型。Avro 的 `record` 类型转换为元组,`array` 类型转换为数组,`map` 类型转换为 Map(仅限字符串键)。一般来说,此处列出的转换可用 [here](/interfaces/formats/Avro#data-types-matching)。我们建议使用精确类型匹配 Avro 数字类型,因为 ClickPipes 不检查类型转换中的溢出或精度损失。 - -#### Nullable 类型和 Avro 联合 {#nullable-types-and-avro-unions} - -在 Avro 中,通过使用 `(T, null)` 或 `(null, T)` 的联合模式来定义可为空类型,其中 T 是基本 Avro 类型。在模式推导期间,此类联合将映射到 ClickHouse 的“Nullable”列。请注意,ClickHouse 不支持 `Nullable(Array)`、`Nullable(Map)` 或 `Nullable(Tuple)` 类型。这些类型的 Avro 空联合将映射到非空版本(Avro 记录类型映射到 ClickHouse 命名元组)。对于这些类型,Avro 空值将插入为: -- 一个空数组,用于 null Avro 数组 -- 一个空 Map,用于 null Avro Map -- 一个命名元组,包含所有默认/零值,用于 null Avro 记录 - -ClickPipes 目前不支持包含其他 Avro 联合的模式(随着新的 ClickHouse 变体和 JSON 数据类型的成熟,这可能会发生变化)。如果 Avro 模式包含“非空”联合,则 ClickPipes 在尝试计算 Avro 模式与 ClickHouse 列类型之间的映射时将生成错误。 - -#### Avro 模式管理 {#avro-schema-management} - -ClickPipes 动态从配置的模式注册表中检索并应用 Avro 模式,使用嵌入在每个消息/事件中的模式 ID。模式更新会自动检测和处理。 - -目前 ClickPipes 仅与使用 [Confluent 模式注册表 API](https://docs.confluent.io/platform/current/schema-registry/develop/api.html) 的模式注册表兼容。除了 Confluent Kafka 和 Cloud,Redpanda、AWS MSK 和 Upstash 模式注册表也包含在内。ClickPipes 目前不兼容 AWS Glue 模式注册表或 Azure 模式注册表(即将推出)。 - -以下规则适用于检索到的 Avro 模式与 ClickHouse 目标表之间的映射: -- 如果 Avro 模式包含的字段未包括在 ClickHouse 目标映射中,该字段将被忽略。 -- 如果 Avro 模式缺少在 ClickHouse 目标映射中定义的字段,ClickHouse 列将填充为“零”值,如 0 或空字符串。请注意,对于 ClickPipes 插入,当前不会评估 [DEFAULT](/sql-reference/statements/create/table#default) 表达式(这是一个临时限制,期待对 ClickHouse 服务器默认处理的更新)。 -- 如果 Avro 模式字段与 ClickHouse 列不兼容,则该行/消息的插入将失败,失败将记录在 ClickPipes 错误表中。请注意,支持几种隐式转换(如数字类型之间的转换),但并不是所有(例如,Avro `record` 字段不能插入到 `Int32` ClickHouse 列中)。 - -## Kafka 虚拟列 {#kafka-virtual-columns} - -以下虚拟列支持与 Kafka 兼容的流数据源。创建新目标表时,可以使用 `Add Column` 按钮添加虚拟列。 - -| 名称 | 描述 | 推荐数据类型 | -|-----------------|---------------------------------------------|-----------------| -| _key | Kafka 消息键 | String | -| _timestamp | Kafka 时间戳(毫秒精度) | DateTime64(3) | -| _partition | Kafka 分区 | Int32 | -| _offset | Kafka 偏移 | Int64 | -| _topic | Kafka 主题 | String | -| _header_keys | 记录头中的键的并行数组 | Array(String) | -| _header_values | 记录头中的头部的并行数组 | Array(String) | -| _raw_message | 完整的 Kafka 消息 | String | - -请注意,_raw_message 列仅建议用于 JSON 数据。对于仅需要 JSON 字符串的用例(例如使用 ClickHouse [`JsonExtract*`](/sql-reference/functions/json-functions#jsonextract-functions) 函数填充下游物化视图),删除所有“非虚拟”列可能会提高 ClickPipes 的性能。 - -## 限制 {#limitations} - -- 不支持 [DEFAULT](/sql-reference/statements/create/table#default)。 - -## 交付语义 {#delivery-semantics} -ClickPipes for Kafka 提供 `at-least-once` 交付语义(作为最常用的方法之一)。我们希望您通过 [联系表单](https://clickhouse.com/company/contact?loc=clickpipes) 提供对交付语义的反馈。如果您需要恰好一次的语义,我们建议使用我们的官方 [`clickhouse-kafka-connect`](https://clickhouse.com/blog/real-time-event-streaming-with-kafka-connect-confluent-cloud-clickhouse) 终端。 - -## 认证 {#authentication} -对于 Apache Kafka 协议数据源,ClickPipes 支持 [SASL/PLAIN](https://docs.confluent.io/platform/current/kafka/authentication_sasl/authentication_sasl_plain.html) 认证及 TLS 加密,以及 `SASL/SCRAM-SHA-256` 和 `SASL/SCRAM-SHA-512`。根据流数据源(Redpanda、MSK 等),将根据兼容性启用所有或部分这些身份验证机制。如果您有不同的身份验证需求,请 [给我们反馈](https://clickhouse.com/company/contact?loc=clickpipes)。 - -### IAM {#iam} - -:::info -MSK ClickPipe 的 IAM 认证是一个 beta 功能。 -::: - -ClickPipes 支持以下 AWS MSK 认证 - - - [SASL/SCRAM-SHA-512](https://docs.aws.amazon.com/msk/latest/developerguide/msk-password.html) 认证 - - [IAM 凭证或基于角色的访问](https://docs.aws.amazon.com/msk/latest/developerguide/how-to-use-iam-access-control.html) 认证 - -使用 IAM 认证连接到 MSK 中介时,IAM 角色必须具有必要的权限。 -以下是 Apache Kafka APIs 对于 MSK 所需 IAM 策略的示例: - -```json -{ - "Version": "2012-10-17", - "Statement": [ - { - "Effect": "Allow", - "Action": [ - "kafka-cluster:Connect" - ], - "Resource": [ - "arn:aws:kafka:us-west-2:12345678912:cluster/clickpipes-testing-brokers/b194d5ae-5013-4b5b-ad27-3ca9f56299c9-10" - ] - }, - { - "Effect": "Allow", - "Action": [ - "kafka-cluster:DescribeTopic", - "kafka-cluster:ReadData" - ], - "Resource": [ - "arn:aws:kafka:us-west-2:12345678912:topic/clickpipes-testing-brokers/*" - ] - }, - { - "Effect": "Allow", - "Action": [ - "kafka-cluster:AlterGroup", - "kafka-cluster:DescribeGroup" - ], - "Resource": [ - "arn:aws:kafka:us-east-1:12345678912:group/clickpipes-testing-brokers/*" - ] - } - ] -} -``` - -#### 配置受信任关系 {#configuring-a-trusted-relationship} - -如果您使用 IAM 角色 ARN 进行 MSK 认证,则需要在 ClickHouse Cloud 实例之间添加受信任关系,以便角色可以被假定。 - -:::note -基于角色的访问仅适用于部署到 AWS 的 ClickHouse Cloud 实例。 -::: - -```json -{ - "Version": "2012-10-17", - "Statement": [ - ... - { - "Effect": "Allow", - "Principal": { - "AWS": "arn:aws:iam::12345678912:role/CH-S3-your-clickhouse-cloud-role" - }, - "Action": "sts:AssumeRole" - }, - ] -} -``` - -### 自定义证书 {#custom-certificates} -ClickPipes for Kafka 支持为具有 SASL & 公共 SSL/TLS 证书的 Kafka 中介上传自定义证书。您可以在 ClickPipe 设置的 SSL 证书部分上传您的证书。 -:::note -请注意,尽管我们支持与 SASL 一起上传单个 SSL 证书,但目前不支持 SSL 与互为 TLS (mTLS)。 -::: - -## 性能 {#performance} - -### 批处理 {#batching} -ClickPipes 将数据分批插入 ClickHouse。这样做是为了避免在数据库中创建过多的分区片段,这可能会导致集群中的性能问题。 - -当满足以下条件之一时,批次将被插入: -- 批量大小已达到最大尺寸(100,000 行或 20MB) -- 批量最大开放时间已达到(5 秒) - -### 延迟 {#latency} - -延迟(定义为生产 Kafka 消息与消息在 ClickHouse 中可用之间的时间)将取决于许多因素(即中介延迟、网络延迟、消息大小/格式)。上面一节中描述的 [批处理](#batching) 也将影响延迟。我们始终建议使用典型负载测试您的特定用例以确定预期的延迟。 - -ClickPipes 不提供任何关于延迟的保证。如果您对延迟有特定的低延迟要求,请 [联系我们](https://clickhouse.com/company/contact?loc=clickpipes)。 - -### 扩展 {#scaling} - -ClickPipes for Kafka 旨在水平扩展。默认情况下,我们创建一个消费组,其中包含一个消费者。 -您可以使用 ClickPipe 详细视图中的扩展控件更改这一设置。 - -ClickPipes 提供高可用性和分区区域分布架构。 -这需要扩展到至少两个消费者。 - -无论运行多少个消费者,容错机制都是设计的一部分。 -如果消费者或其基础设施发生故障, -ClickPipe 将自动重新启动该消费者并继续处理消息。 - -## 常见问题解答 {#faq} - -### 一般 {#general} - -- **ClickPipes for Kafka 是如何工作的?** - - ClickPipes 使用专用架构运行 Kafka 消费者 API 从指定主题读取数据,然后将数据插入到特定 ClickHouse Cloud 服务的 ClickHouse 表中。 - -- **ClickPipes 和 ClickHouse Kafka 表引擎有什么区别?** - - Kafka 表引擎是 ClickHouse 核心功能,采用“拉取模型”,点击 ClickHouse 服务器本身连接到 Kafka,拉取事件然后写入本地。 - - ClickPipes 是一个独立于 ClickHouse 服务的云服务,它连接到 Kafka(或其他数据源)并将事件推送到关联的 ClickHouse Cloud 服务。这种解耦架构允许更优的操作灵活性、明显分离的关注点、可扩展的数据摄取、优雅的失败管理、可扩展性等。 - -- **使用 ClickPipes for Kafka 有什么要求?** - - 为了使用 ClickPipes for Kafka,您需要运行的 Kafka 中介和启用 ClickPipes 的 ClickHouse Cloud 服务。您还需要确保 ClickHouse Cloud 可以访问您的 Kafka 中介。这可以通过允许 Kafka 端的远程连接来实现,在您的 Kafka 设置中将 [ClickHouse Cloud 出口 IP 地址](/manage/security/cloud-endpoints-api) 列入白名单。 - -- **ClickPipes for Kafka 支持 AWS PrivateLink 吗?** - - 支持 AWS PrivateLink。有关更多信息,请 [与我们联系](https://clickhouse.com/company/contact?loc=clickpipes)。 - -- **我可以使用 ClickPipes for Kafka 将数据写入 Kafka 主题吗?** - - 不可以,ClickPipes for Kafka 设计用于从 Kafka 主题读取数据,而不是将数据写入它们。要将数据写入 Kafka 主题,您需要使用专用的 Kafka 生产者。 - -- **ClickPipes 支持多个中介吗?** - - 是的,如果这些中介是同一法定人数的一部分,则可以将它们一起配置,使用 `,` 分隔。 - -### Upstash {#upstash} - -- **ClickPipes 支持 Upstash 吗?** - - 是的。 Upstash Kafka 产品于 2024 年 9 月 11 日进入弃用期,为期 6 个月。现有客户可以继续使用 ClickPipes 及其现有 Upstash Kafka 中介,使用 ClickPipes 用户界面上的通用 Kafka 瓦片。在弃用通知之前,现有的 Upstash Kafka ClickPipes 不受影响。当弃用期结束时,ClickPipe 将停止运行。 - -- **ClickPipes 支持 Upstash 模式注册表吗?** - - 不支持。ClickPipes 与 Upstash Kafka 模式注册表不兼容。 - -- **ClickPipes 支持 Upstash QStash 工作流吗?** - - 不支持。除非在 QStash 工作流中引入与 Kafka 兼容的接口,否则它将无法与 Kafka ClickPipes 一起使用。 - -### Azure EventHubs {#azure-eventhubs} - -- **Azure Event Hubs ClickPipe 在没有 Kafka 接口的情况下能否工作?** - - 不能。ClickPipes 要求 Azure Event Hubs 启用 Kafka 接口。Kafka 协议仅在它们的标准、优质和专用 SKU 价格层中支持。 - -- **Azure 模式注册表与 ClickPipes 的工作吗?** - - 不支持。ClickPipes 当前与 Event Hubs 模式注册表不兼容。 - -- **我的策略需要什么权限才能从 Azure Event Hubs 消费?** - - 要列出主题和消费事件,给予 ClickPipes 的共享访问策略至少需要包含一个“侦听”声明。 - -- **为什么我的 Event Hubs 没有返回任何数据?** - - 如果您的 ClickHouse 实例位于与您的 Event Hubs 部署不同的区域或大陆,您可能会在启用 ClickPipes 时遇到超时,并且在从 Event Hub 消费数据时出现更高的延迟。最佳实践是将 ClickHouse Cloud 部署和 Azure Event Hubs 部署位于靠近彼此的云区域,以避免不良性能。 - -- **我应该包含 Azure Event Hubs 的端口号吗?** - - 是的。ClickPipes 期望您为 Kafka 接口包含您的端口号,应为 `:9093`。 - -- **ClickPipes 的 IP 地址对于 Azure Event Hubs 仍然相关吗?** - - 是的。如果您限制对 Event Hubs 实例的流量,请添加 [文档中的静态 NAT IPs](./index.md#list-of-static-ips)。 - -- **连接字符串是用于 Event Hub 还是用于 Event Hub 命名空间?** - - 两者都可以,但我们建议使用命名空间级别的共享访问策略,以便从多个 Event Hubs 获取示例。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/kafka.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/kafka.md.hash deleted file mode 100644 index 1220ce1de8b..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/kafka.md.hash +++ /dev/null @@ -1 +0,0 @@ -9f1863c46f1c561f diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/kafka/01_create-kafka-clickpipe.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/kafka/01_create-kafka-clickpipe.md new file mode 100644 index 00000000000..07717c0f2a2 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/kafka/01_create-kafka-clickpipe.md @@ -0,0 +1,72 @@ +--- +'sidebar_label': '创建你的第一个 Kafka ClickPipe' +'description': '逐步指南以创建你的第一个 Kafka ClickPipe。' +'slug': '/integrations/clickpipes/kafka/create-your-first-kafka-clickpipe' +'sidebar_position': 1 +'title': '创建你的第一个 Kafka ClickPipe' +'doc_type': 'guide' +--- + +import cp_step0 from '@site/static/images/integrations/data-ingestion/clickpipes/cp_step0.png'; +import cp_step1 from '@site/static/images/integrations/data-ingestion/clickpipes/cp_step1.png'; +import cp_step2 from '@site/static/images/integrations/data-ingestion/clickpipes/cp_step2.png'; +import cp_step3 from '@site/static/images/integrations/data-ingestion/clickpipes/cp_step3.png'; +import cp_step4a from '@site/static/images/integrations/data-ingestion/clickpipes/cp_step4a.png'; +import cp_step5 from '@site/static/images/integrations/data-ingestion/clickpipes/cp_step5.png'; +import cp_overview from '@site/static/images/integrations/data-ingestion/clickpipes/cp_overview.png'; +import cp_table_settings from '@site/static/images/integrations/data-ingestion/clickpipes/cp_table_settings.png'; +import Image from '@theme/IdealImage'; + + +# 创建您的第一个 Kafka ClickPipe {#creating-your-first-kafka-clickpipe} + +> 在本指南中,我们将带您完成创建第一个 Kafka ClickPipe 的过程。 + + + +## 导航到数据源 {#1-load-sql-console} +选择左侧菜单中的 `数据源` 按钮,然后点击“设置 ClickPipe”。 + + +## 选择数据源 {#2-select-data-source} +从列表中选择您的 Kafka 数据源。 + + +## 配置数据源 {#3-configure-data-source} +填写表单,为您的 ClickPipe 提供一个名称、描述(可选)、凭据和其他连接详细信息。 + + +## 配置模式注册中心(可选) {#4-configure-your-schema-registry} +有效的模式对于 Avro 流是必需的。有关如何配置模式注册中心的更多详细信息,请参阅 [模式注册中心](./02_schema-registries.md)。 + +## 配置反向私有端点(可选) {#5-configure-reverse-private-endpoint} +配置反向私有端点,以允许 ClickPipes 使用 AWS PrivateLink 连接到您的 Kafka 集群。 +有关更多信息,请参阅我们的 [AWS PrivateLink 文档](../aws-privatelink.md)。 + +## 选择您的主题 {#6-select-your-topic} +选择您的主题,UI 将显示该主题的示例文档。 + + +## 配置您的目标表 {#7-configure-your-destination-table} + +在下一步中,您可以选择是否希望将数据导入到新的 ClickHouse 表中,或重用现有的表。按照屏幕上的说明修改您的表名称、模式和设置。您可以在顶部的示例表中实时预览您的更改。 + + + +您还可以使用提供的控件自定义高级设置。 + + + +## 配置权限 {#8-configure-permissions} +ClickPipes 将为将数据写入目标表创建一个专用用户。您可以使用自定义角色或预定义角色之一来为该内部用户选择角色: +- `完全访问`: 对集群具有完全访问权限。如果您在目标表中使用物化视图或字典,这可能会很有用。 +- `仅目标表`: 仅对目标表具有 `INSERT` 权限。 + + + +## 完成设置 {#9-complete-setup} +点击“创建 ClickPipe”将创建并运行您的 ClickPipe。它现在将在数据源部分列出。 + + + + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/kafka/01_create-kafka-clickpipe.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/kafka/01_create-kafka-clickpipe.md.hash new file mode 100644 index 00000000000..564a2ada91a --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/kafka/01_create-kafka-clickpipe.md.hash @@ -0,0 +1 @@ +29bbf026debcb50b diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/kafka/02_schema-registries.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/kafka/02_schema-registries.md new file mode 100644 index 00000000000..043574e7ab2 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/kafka/02_schema-registries.md @@ -0,0 +1,47 @@ +--- +'sidebar_label': '与模式注册表集成' +'description': '如何将 ClickPipes 与模式注册表集成以进行模式管理' +'slug': '/integrations/clickpipes/kafka/schema-registries' +'sidebar_position': 1 +'title': 'Kafka ClickPipe 的模式注册表' +'doc_type': 'guide' +--- + + +# Schema registries {#schema-registries} + +ClickPipes 支持 Avro 数据流的模式注册中心。 + +## Supported registries for Kafka ClickPipes {#supported-schema-registries} + +支持与 Confluent Schema Registry API 兼容的模式注册中心。这包括: + +- Confluent Schema Registry +- Redpanda Schema Registry + +ClickPipes 目前不支持 AWS Glue Schema Registry 或 Azure Schema Registry。如果您需要对这些模式注册中心的支持,请 [联系团队](https://clickhouse.com/company/contact?loc=clickpipes)。 + +## Configuration {#schema-registry-configuration} + +使用 Avro 数据的 ClickPipes 需要一个模式注册中心。这可以通过以下三种方式之一进行配置: + +1. 提供模式主题的完整路径(例如 `https://registry.example.com/subjects/events`) + - 可选地,通过在 URL 后附加 `/versions/[version]` 来引用特定版本(否则 ClickPipes 将检索最新版本)。 +2. 提供模式 ID 的完整路径(例如 `https://registry.example.com/schemas/ids/1000`) +3. 提供根模式注册中心的 URL(例如 `https://registry.example.com`) + +## How it works {#how-schema-registries-work} + +ClickPipes 动态地从配置的模式注册中心检索和应用 Avro 模式。 +- 如果消息中嵌入了模式 ID,将使用该 ID 来检索模式。 +- 如果消息中未嵌入模式 ID,将使用 ClickPipe 配置中指定的模式 ID 或主题名称来检索模式。 +- 如果消息是在未嵌入模式 ID 的情况下写入,并且在 ClickPipe 配置中未指定模式 ID 或主题名称,则将不检索模式,该消息将被跳过,并在 ClickPipes 错误表中记录 `SOURCE_SCHEMA_ERROR`。 +- 如果消息不符合模式,则该消息将被跳过,并在 ClickPipes 错误表中记录 `DATA_PARSING_ERROR`。 + +## Schema mapping {#schema-mapping} + +以下规则应用于检索到的 Avro 模式与 ClickHouse 目标表之间的映射: + +- 如果 Avro 模式包含 ClickHouse 目标映射中未包含的字段,则该字段将被忽略。 +- 如果 Avro 模式缺少 ClickHouse 目标映射中定义的字段,则 ClickHouse 列将填充为“零”值,例如 0 或空字符串。请注意,DEFAULT 表达式目前不会被 ClickPipes 插入评估(这是暂时性限制,待更新 ClickHouse 服务器的默认处理)。 +- 如果 Avro 模式字段与 ClickHouse 列不兼容,则该行/消息的插入将失败,失败将记录在 ClickPipes 错误表中。请注意,支持某些隐式转换(例如,在数值类型之间),但并非全部(例如,Avro 记录字段不能插入 Int32 ClickHouse 列)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/kafka/02_schema-registries.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/kafka/02_schema-registries.md.hash new file mode 100644 index 00000000000..13295af8ac9 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/kafka/02_schema-registries.md.hash @@ -0,0 +1 @@ +04c1c7498cd36667 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/kafka/03_reference.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/kafka/03_reference.md new file mode 100644 index 00000000000..adb8735c701 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/kafka/03_reference.md @@ -0,0 +1,103 @@ +--- +'sidebar_label': '参考' +'description': '详细说明由 Kafka ClickPipes 支持的格式、来源、交付语义、身份验证和实验性功能' +'slug': '/integrations/clickpipes/kafka/reference' +'sidebar_position': 1 +'title': '参考' +'doc_type': 'reference' +--- + +import Kafkasvg from '@site/static/images/integrations/logos/kafka.svg'; +import Confluentsvg from '@site/static/images/integrations/logos/confluent.svg'; +import Msksvg from '@site/static/images/integrations/logos/msk.svg'; +import Azureeventhubssvg from '@site/static/images/integrations/logos/azure_event_hubs.svg'; +import Warpstreamsvg from '@site/static/images/integrations/logos/warpstream.svg'; +import redpanda_logo from '@site/static/images/integrations/logos/logo_redpanda.png'; +import Image from '@theme/IdealImage'; +import ExperimentalBadge from '@site/src/theme/badges/ExperimentalBadge'; + + +# 参考 + +## 支持的数据源 {#supported-data-sources} + +| 名称 | Logo| 类型 | 状态 | 描述 | +|-------------------------|-----|-------|----------------|-------------------------------------------------------------------------------------------------| +| Apache Kafka || 流式 | 稳定 | 配置 ClickPipes,并开始将 Apache Kafka 的流式数据导入 ClickHouse Cloud。 | +| Confluent Cloud || 流式 | 稳定 | 通过我们的直接集成,释放 Confluent 与 ClickHouse Cloud 的组合能力。 | +| Redpanda || 流式 | 稳定 | 配置 ClickPipes,并开始将 Redpanda 的流式数据导入 ClickHouse Cloud。 | +| AWS MSK || 流式 | 稳定 | 配置 ClickPipes,并开始将 AWS MSK 的流式数据导入 ClickHouse Cloud。 | +| Azure Event Hubs || 流式 | 稳定 | 配置 ClickPipes,并开始将 Azure Event Hubs 的流式数据导入 ClickHouse Cloud。 | +| WarpStream || 流式 | 稳定 | 配置 ClickPipes,并开始将 WarpStream 的流式数据导入 ClickHouse Cloud。 | + +## 支持的数据格式 {#supported-data-formats} + +支持的格式有: +- [JSON](/integrations/data-formats/json/overview) +- [AvroConfluent](/interfaces/formats/AvroConfluent) + +## 支持的数据类型 {#supported-data-types} + +### 标准 {#standard-types-support} + +当前 ClickPipes 支持以下标准 ClickHouse 数据类型: + +- 基本数值类型 - \[U\]Int8/16/32/64、Float32/64 和 BFloat16 +- 大整数类型 - \[U\]Int128/256 +- 十进制类型 +- 布尔型 +- 字符串 +- 固定字符串 +- 日期、Date32 +- 日期时间、DateTime64 (仅支持 UTC 时区) +- Enum8/Enum16 +- UUID +- IPv4 +- IPv6 +- 所有 ClickHouse LowCardinality 类型 +- 使用上述任何类型(包括 Nullable)的键和值的 Map +- 使用上述任何类型(包括 Nullable,仅支持一层深度)的 Tuple 和 Array +- SimpleAggregateFunction 类型(用于 AggregatingMergeTree 或 SummingMergeTree 目的地) + +### Avro {#avro} + +#### 支持的 Avro 数据类型 {#supported-avro-data-types} +ClickPipes 支持所有 Avro 原始和复杂类型,以及所有 Avro 逻辑类型,除了 `time-millis`、`time-micros`、`local-timestamp-millis`、`local_timestamp-micros` 和 `duration`。 Avro 的 `record` 类型转换为 Tuple,`array` 类型转换为 Array,`map` 转换为 Map(仅支持字符串键)。一般来说,列出 [这里](/interfaces/formats/Avro#data-type-mapping) 的转换是可用的。我们建议对 Avro 数值类型使用精确的类型匹配,因为 ClickPipes 不会检查类型转换中的溢出或精度损失。或者,所有 Avro 类型可以插入到 `String` 列中,在这种情况下将作为有效的 JSON 字符串表示。 + +#### Nullable 类型和 Avro 联合 {#nullable-types-and-avro-unions} +Avro 中的 Nullable 类型通过使用 `(T, null)` 或 `(null, T)` 的联合模式定义,其中 T 是基本的 Avro 类型。在模式推断过程中,此类联合将映射到 ClickHouse "Nullable" 列。请注意,ClickHouse 不支持 +`Nullable(Array)`、`Nullable(Map)` 或 `Nullable(Tuple)` 类型。这些类型的 Avro null 联合将映射到非 Nullable 版本(Avro Record 类型映射到 ClickHouse 命名的 Tuple)。对于这些类型的 Avro "null" 将插入为: +- 空 Array 对于空的 Avro array +- 空 Map 对于空的 Avro Map +- 具有所有默认/零值的命名 Tuple 对于空的 Avro Record + +#### 变体类型支持 {#variant-type-support} +ClickPipes 在以下情况下支持变体类型: +- Avro 联合。如果您的 Avro 模式包含多个非空类型的联合,ClickPipes 将推断出适当的变体类型。对于 Avro 数据,变体类型在其他情况下不被支持。 +- JSON 字段。您可以为源数据流中的任何 JSON 字段手动指定变体类型(例如 `Variant(String, Int64, DateTime)`)。由于 ClickPipes 确定使用正确变体子类型的方式,变体定义中只能使用一个整数或日期时间类型——例如,`Variant(Int64, UInt32)` 不被支持。 + +#### JSON 类型支持 {#json-type-support} +ClickPipes 在以下情况下支持 JSON 类型: +- Avro Record 类型始终可以分配给 JSON 列。 +- Avro String 和 Bytes 类型可以分配给 JSON 列,前提是列确实包含 JSON 字符串对象。 +- 始终为 JSON 对象的 JSON 字段可以分配给 JSON 目标列。 + +请注意,您需要手动将目标列更改为所需的 JSON 类型,包括任何固定或跳过的路径。 + +## Kafka 虚拟列 {#kafka-virtual-columns} + +以下虚拟列对于与 Kafka 兼容的流式数据源是支持的。在创建新目标表时,可以通过使用 `Add Column` 按钮添加虚拟列。 + +| 名称 | 描述 | 推荐数据类型 | +|----------------------|----------------------------------------------|--------------------| +| `_key` | Kafka 消息键 | `String` | +| `_timestamp` | Kafka 时间戳(毫秒精度) | `DateTime64(3)` | +| `_partition` | Kafka 分区 | `Int32` | +| `_offset` | Kafka 偏移 | `Int64` | +| `_topic` | Kafka 主题 | `String` | +| `_header_keys` | 记录头中的键的并行数组 | `Array(String)` | +| `_header_values` | 记录头中的值的并行数组 | `Array(String)` | +| `_raw_message` | 完整的 Kafka 消息 | `String` | + +请注意,`_raw_message` 列仅建议用于 JSON 数据。 +对于仅需要 JSON 字符串的用例(例如,使用 ClickHouse [`JsonExtract*`](/sql-reference/functions/json-functions#jsonextract-functions) 函数来填充下游的物化视图),删除所有“非虚拟”列可能会提高 ClickPipes 的性能。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/kafka/03_reference.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/kafka/03_reference.md.hash new file mode 100644 index 00000000000..01f016fd60c --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/kafka/03_reference.md.hash @@ -0,0 +1 @@ +39c35ae2e01ea31f diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/kafka/04_best_practices.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/kafka/04_best_practices.md new file mode 100644 index 00000000000..fbf38d4fa42 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/kafka/04_best_practices.md @@ -0,0 +1,151 @@ +--- +'sidebar_label': '最佳实践' +'description': '详细说明在使用 Kafka ClickPipes 时应遵循的最佳实践' +'slug': '/integrations/clickpipes/kafka/best-practices' +'sidebar_position': 1 +'title': '最佳实践' +'doc_type': 'guide' +--- + + +# 最佳实践 {#best-practices} + +## 消息压缩 {#compression} + +我们强烈建议对您的 Kafka 主题使用压缩。压缩可以显著节省数据传输成本,并几乎不会影响性能。 +要了解有关 Kafka 中消息压缩的更多信息,我们建议您首先查看 [指南](https://www.confluent.io/blog/apache-kafka-message-compression/)。 + +## 限制 {#limitations} + +- [`DEFAULT`](/sql-reference/statements/create/table#default) 不受支持。 + +## 交付语义 {#delivery-semantics} + +ClickPipes for Kafka 提供 `at-least-once` 交付语义(这是最常用的方法之一)。我们欢迎您通过 [联系表单](https://clickhouse.com/company/contact?loc=clickpipes) 提供有关交付语义的反馈。如果您需要 exactly-once 语义,我们建议您使用我们的官方 [`clickhouse-kafka-connect`](https://clickhouse.com/blog/real-time-event-streaming-with-kafka-connect-confluent-cloud-clickhouse) 汇点。 + +## 认证 {#authentication} + +对于 Apache Kafka 协议数据源,ClickPipes 支持 [SASL/PLAIN](https://docs.confluent.io/platform/current/kafka/authentication_sasl/authentication_sasl_plain.html) 认证,并提供 TLS 加密,以及 `SASL/SCRAM-SHA-256` 和 `SASL/SCRAM-SHA-512`。根据流媒体源(Redpanda、MSK 等),将启用所有或部分这些认证机制,具体取决于兼容性。如果您的认证需求有所不同,请 [给我们反馈](https://clickhouse.com/company/contact?loc=clickpipes)。 + +### IAM {#iam} + +:::info +MSK ClickPipe 的 IAM 认证是一个 beta 功能。 +::: + +ClickPipes 支持以下 AWS MSK 认证 + +- [SASL/SCRAM-SHA-512](https://docs.aws.amazon.com/msk/latest/developerguide/msk-password.html) 认证 +- [IAM 凭证或基于角色的访问](https://docs.aws.amazon.com/msk/latest/developerguide/how-to-use-iam-access-control.html) 认证 + +使用 IAM 认证连接到 MSK 代理时,IAM 角色必须具有必要权限。 +以下是 MSK 用于 Apache Kafka API 的必要 IAM 策略的示例: + +```json +{ + "Version": "2012-10-17", + "Statement": [ + { + "Effect": "Allow", + "Action": [ + "kafka-cluster:Connect" + ], + "Resource": [ + "arn:aws:kafka:us-west-2:12345678912:cluster/clickpipes-testing-brokers/b194d5ae-5013-4b5b-ad27-3ca9f56299c9-10" + ] + }, + { + "Effect": "Allow", + "Action": [ + "kafka-cluster:DescribeTopic", + "kafka-cluster:ReadData" + ], + "Resource": [ + "arn:aws:kafka:us-west-2:12345678912:topic/clickpipes-testing-brokers/*" + ] + }, + { + "Effect": "Allow", + "Action": [ + "kafka-cluster:AlterGroup", + "kafka-cluster:DescribeGroup" + ], + "Resource": [ + "arn:aws:kafka:us-east-1:12345678912:group/clickpipes-testing-brokers/*" + ] + } + ] +} +``` + +#### 配置受信任关系 {#configuring-a-trusted-relationship} + +如果您使用 IAM 角色 ARN 进行 MSK 身份验证,则需要在您的 ClickHouse Cloud 实例之间添加受信任关系,以便角色可以被使用。 + +:::note +基于角色的访问仅适用于部署到 AWS 的 ClickHouse Cloud 实例。 +::: + +```json +{ + "Version": "2012-10-17", + "Statement": [ + ... + { + "Effect": "Allow", + "Principal": { + "AWS": "arn:aws:iam::12345678912:role/CH-S3-your-clickhouse-cloud-role" + }, + "Action": "sts:AssumeRole" + }, + ] +} +``` + +### 自定义证书 {#custom-certificates} + +ClickPipes for Kafka 支持为使用非公共服务器证书的 Kafka 代理上传自定义证书。 +也支持上传客户端证书和密钥,以进行基于 TLS 的双向认证(mTLS)。 + +## 性能 {#performance} + +### 批处理 {#batching} + +ClickPipes 将数据批量插入到 ClickHouse 中。这是为了避免在数据库中创建过多的部分,从而导致集群中的性能问题。 + +当满足以下任一条件时,批量将被插入: +- 批量大小达到最大值(每 1GB 虚拟内存 100,000 行或 32MB) +- 批处理已打开的最长时间(5 秒) + +### 延迟 {#latency} + +延迟(定义为生产 Kafka 消息与消息在 ClickHouse 中可用之间的时间)将取决于多个因素(即代理延迟、网络延迟、消息大小/格式)。上面描述的 [批处理](#batching) 也将影响延迟。我们始终建议在典型负载下测试您的特定用例,以确定预期延迟。 + +ClickPipes 不提供关于延迟的任何保证。如果您有特定的低延迟要求,请 [联系我们](https://clickhouse.com/company/contact?loc=clickpipes)。 + +### 扩展性 {#scaling} + +ClickPipes for Kafka 旨在横向和纵向扩展。默认情况下,我们创建一个包含一个消费者的消费者组。可以在 ClickPipe 创建期间或在 **设置** -> **高级设置** -> **扩展** 下的任何其他时间进行配置。 + +ClickPipes 提供高可用性,并采用可用区分布式体系结构。 +这需要至少扩展到两个消费者。 + +无论运行消费者的数量如何,容错都是设计的结果。 +如果消费者或其底层基础设施发生故障,ClickPipe 将自动重启该消费者并继续处理消息。 + +### 基准 {#benchmarks} + +下面是一些 ClickPipes for Kafka 的非正式基准,可以用于获取基准性能的一般想法。需要了解的是,许多因素可以影响性能,包括消息大小、数据类型和数据格式。您的结果可能会有所不同,我们在此显示的内容不是实际性能的保证。 + +基准详细信息: + +- 我们使用了生产的 ClickHouse Cloud 服务,确保资源足够,以确保通过插入处理不会对 ClickHouse 产生瓶颈。 +- ClickHouse Cloud 服务、Kafka 集群(Confluent Cloud)和 ClickPipe 均在同一区域(`us-east-2`)运行。 +- ClickPipe 配置为单个 L 大小的副本(4 GiB 的 RAM 和 1 vCPU)。 +- 示例数据包括嵌套数据,混合有 `UUID`、`String` 和 `Int` 数据类型。其他数据类型,如 `Float`、`Decimal` 和 `DateTime`,可能性能较差。 +- 使用压缩和未压缩数据的性能没有明显差异。 + +| 副本大小 | 消息大小 | 数据格式 | 吞吐量 | +|-----------|----------|-----------|--------| +| Large (L) | 1.6kb | JSON | 63mb/s | +| Large (L) | 1.6kb | Avro | 99mb/s | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/kafka/04_best_practices.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/kafka/04_best_practices.md.hash new file mode 100644 index 00000000000..4ef5331b98e --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/kafka/04_best_practices.md.hash @@ -0,0 +1 @@ +7455d7f2cbce3ba4 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/kafka/05_faq.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/kafka/05_faq.md new file mode 100644 index 00000000000..dd8bb923868 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/kafka/05_faq.md @@ -0,0 +1,115 @@ +--- +'sidebar_label': 'FAQ' +'description': '关于 Kafka 的 ClickPipes 的常见问题' +'slug': '/integrations/clickpipes/kafka/faq' +'sidebar_position': 1 +'title': 'Kafka ClickPipes 常见问题' +'doc_type': 'guide' +--- + +## Kafka ClickPipes 常见问题 {#faq} + +### 一般 {#general} + +
+ +ClickPipes for Kafka 是如何工作的? + +ClickPipes 使用专门的架构,通过 Kafka Consumer API 从指定主题读取数据,然后将数据插入到特定的 ClickHouse Cloud 服务中的 ClickHouse 表中。 +
+ +
+ +ClickPipes 和 ClickHouse Kafka 表引擎有什么区别? + +Kafka 表引擎是 ClickHouse 的核心功能,采用“拉取模型”,由 ClickHouse 服务器自身连接到 Kafka,拉取事件并将其本地写入。 + +ClickPipes 是一个独立的云服务,与 ClickHouse 服务独立运行。它连接到 Kafka(或其他数据源)并将事件推送到关联的 ClickHouse Cloud 服务。这种解耦架构提供了卓越的操作灵活性、明确的关注点分离、可扩展的数据摄取、优雅的故障管理、可扩展性等。 +
+ +
+ +使用 ClickPipes for Kafka 有哪些要求? + +要使用 ClickPipes for Kafka,您需要一个正在运行的 Kafka broker 和一个启用了 ClickPipes 的 ClickHouse Cloud 服务。您还需要确保 ClickHouse Cloud 可以访问您的 Kafka broker。这可以通过允许 Kafka 端的远程连接来实现,并在 Kafka 设置中将 [ClickHouse Cloud 出口 IP 地址](/manage/security/cloud-endpoints-api) 列入白名单。或者,您可以使用 [AWS PrivateLink](/integrations/clickpipes/aws-privatelink) 将 ClickPipes for Kafka 连接到您的 Kafka brokers。 +
+ +
+ +ClickPipes for Kafka 支持 AWS PrivateLink 吗? + +支持 AWS PrivateLink。有关设置的更多信息,请参阅 [文档](/integrations/clickpipes/aws-privatelink)。 +
+ +
+ +我可以使用 ClickPipes for Kafka 写入数据到 Kafka 主题吗? + +不可以,ClickPipes for Kafka 旨在从 Kafka 主题读取数据,而不是将数据写入它们。要向 Kafka 主题写入数据,您需要使用专门的 Kafka producer。 +
+ +
+ +ClickPipes 支持多个 brokers 吗? + +是的,如果 brokers 是同一法定人数的一部分,您可以将它们一起配置,用 `,` 分隔。 +
+ +
+ +ClickPipes 副本可以扩展吗? + +是的,ClickPipes for streaming 可以进行横向和纵向扩展。 +横向扩展通过添加更多副本来增加吞吐量,而纵向扩展则增加分配给每个副本的资源(CPU 和 RAM),以处理更高负载的工作负载。 +这可以在创建 ClickPipe 时或在 **设置** -> **高级设置** -> **扩展** 中的任何其他时刻配置。 +
+ +### Azure 事件中心 {#azure-eventhubs} + +
+ +Azure 事件中心 ClickPipe 可以在没有 Kafka 表面的情况下工作吗? + +不可以。ClickPipes 需要事件中心命名空间启用 Kafka 表面。此功能仅在 **基础** 以上的服务层级中可用。有关更多信息,请参阅 [Azure 事件中心文档](https://learn.microsoft.com/en-us/azure/event-hubs/event-hubs-quickstart-kafka-enabled-event-hubs?tabs=passwordless#create-an-azure-event-hubs-namespace)。 +
+ +
+ +Azure Schema Registry 与 ClickPipes 兼容吗? + +不兼容。ClickPipes 仅支持与 Confluent Schema Registry API 兼容的模式注册,而 Azure Schema Registry 并不符合此要求。如果您需要支持此模式注册,请 [联系我们的团队](https://clickhouse.com/company/contact?loc=clickpipes)。 +
+ +
+ +我的策略需要什么权限才能从 Azure 事件中心消费? + +要列出主题和消费事件,赋予 ClickPipes 的共享访问策略至少需要一个“监听”声明。 +
+ +
+ +为什么我的事件中心没有返回任何数据? + +如果您的 ClickHouse 实例与您的事件中心部署位于不同的区域或大陆,您在启动 ClickPipes 时可能会遇到超时,并在从事件中心消费数据时遇到更高的延迟。我们建议将 ClickHouse Cloud 和 Azure 事件中心部署在同一云区域,或彼此靠近的区域,以避免性能开销。 +
+ +
+ +我应该为 Azure 事件中心包括端口号吗? + +是的。ClickPipes 希望您为 Kafka 表面包含端口号,应该是 `:9093`。 +
+ +
+ +ClickPipes 的 IP 地址对于 Azure 事件中心仍然相关吗? + +是的。要限制流量到您的事件中心实例,请添加 [文档中的静态 NAT IP 地址](../index.md#list-of-static-ips)。 +
+ +
+这是事件中心的连接字符串,还是事件中心命名空间的连接字符串? + +两者都可以工作。我们强烈建议在 **命名空间级别** 使用共享访问策略,从多个事件中心获取样本。 +
diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/kafka/05_faq.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/kafka/05_faq.md.hash new file mode 100644 index 00000000000..2f862705d5c --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/kafka/05_faq.md.hash @@ -0,0 +1 @@ +07c7b8ff65feb8a3 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/kafka/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/kafka/index.md new file mode 100644 index 00000000000..95162fbc36f --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/kafka/index.md @@ -0,0 +1,17 @@ +--- +'description': '着陆页,包含 Kafka ClickPipes 部分的内容目录' +'slug': '/integrations/clickpipes/kafka' +'sidebar_position': 1 +'title': 'Kafka ClickPipes' +'doc_type': 'landing-page' +--- + + +| 页面 | 描述 | +|-----|-----| +| [参考](/integrations/clickpipes/kafka/reference) | 详细说明了Kafka ClickPipes支持的格式、来源、交付语义、认证及实验特性 | +| [Kafka ClickPipe的schema注册表](/integrations/clickpipes/kafka/schema-registries) | 如何与schema管理的schema注册表集成ClickPipes | +| [创建你的第一个Kafka ClickPipe](/integrations/clickpipes/kafka/create-your-first-kafka-clickpipe) | 创建你的第一个Kafka ClickPipe的逐步指南。 | +| [Kafka ClickPipes常见问题](/integrations/clickpipes/kafka/faq) | 关于Kafka的ClickPipes的常见问题 | +| [最佳实践](/integrations/clickpipes/kafka/best-practices) | 与Kafka ClickPipes合作时应遵循的最佳实践详细说明 | + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/kafka/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/kafka/index.md.hash new file mode 100644 index 00000000000..89484dfcdf8 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/kafka/index.md.hash @@ -0,0 +1 @@ +bcc0bdb26819868e diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/kinesis.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/kinesis.md index 73ff3c38dec..9ddd2f5a893 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/kinesis.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/kinesis.md @@ -1,8 +1,9 @@ --- -'sidebar_label': 'ClickPipes 用于 Amazon Kinesis' -'description': '无缝连接您的 Amazon Kinesis 数据源与 ClickHouse Cloud。' +'sidebar_label': 'ClickPipes for Amazon Kinesis' +'description': '无缝连接您的 Amazon Kinesis 数据源到 ClickHouse Cloud。' 'slug': '/integrations/clickpipes/kinesis' 'title': '将 Amazon Kinesis 与 ClickHouse Cloud 集成' +'doc_type': 'guide' --- import cp_service from '@site/static/images/integrations/data-ingestion/clickpipes/cp_service.png'; @@ -23,7 +24,7 @@ import Image from '@theme/IdealImage'; # 将 Amazon Kinesis 与 ClickHouse Cloud 集成 ## 前提条件 {#prerequisite} -您已熟悉 [ClickPipes 介绍](./index.md) 并设置了 [IAM 凭证](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html) 或 [IAM 角色](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles.html)。请按照 [Kinesis 基于角色的访问指南](./secure-kinesis.md) 获取关于如何设置与 ClickHouse Cloud 兼容的角色的信息。 +您已熟悉 [ClickPipes 入门](./index.md) 并已设置 [IAM 凭证](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html) 或 [IAM 角色](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles.html)。请参阅 [Kinesis 基于角色的访问指南](./secure-kinesis.md),了解如何设置与 ClickHouse Cloud 兼容的角色。 ## 创建您的第一个 ClickPipe {#creating-your-first-clickpipe} @@ -31,7 +32,7 @@ import Image from '@theme/IdealImage'; -2. 在左侧菜单中选择 `Data Sources` 按钮,然后点击“设置 ClickPipe” +2. 在左侧菜单中选择 `Data Sources` 按钮并点击 "Set up a ClickPipe" @@ -39,15 +40,15 @@ import Image from '@theme/IdealImage'; -4. 填写表单,为您的 ClickPipe 提供名称、描述(可选)、您的 IAM 角色或凭证及其他连接详细信息。 +4. 填写表单,为您的 ClickPipe 提供名称、描述(可选)、您的 IAM 角色或凭证及其他连接详情。 -5. 选择 Kinesis 流和起始偏移量。用户界面将显示所选源(Kafka 主题等)的示例文档。您还可以为 Kinesis 流启用增强的扇出,以提高 ClickPipe 的性能和稳定性(有关增强扇出的更多信息,请见 [这里](https://aws.amazon.com/blogs/aws/kds-enhanced-fanout))。 +5. 选择 Kinesis 数据流和起始偏移量。用户界面将显示所选源(Kafka 主题等)的示例文档。您还可以为 Kinesis 数据流启用增强扇出,以提高 ClickPipe 的性能和稳定性(有关增强扇出的更多信息,请参见 [这里](https://aws.amazon.com/blogs/aws/kds-enhanced-fanout)) -6. 在下一步中,您可以选择是否将数据摄取到新的 ClickHouse 表中或重用现有的表。按照屏幕上的说明修改表名、模式和设置。您可以在顶部的示例表中实时预览更改。 +6. 在下一步中,您可以选择是将数据导入到新的 ClickHouse 表中,还是重用现有表。按照屏幕中的说明修改您的表名称、模式和设置。您可以在顶部的示例表中实时预览您的更改。 @@ -55,33 +56,33 @@ import Image from '@theme/IdealImage'; -7. 或者,您可以决定将数据摄取到现有的 ClickHouse 表中。在这种情况下,用户界面将允许您将源字段映射到所选目标表中的 ClickHouse 字段。 +7. 或者,您可以决定将数据导入现有的 ClickHouse 表。在这种情况下,用户界面将允许您将源中的字段映射到所选目标表中的 ClickHouse 字段。 8. 最后,您可以为内部 ClickPipes 用户配置权限。 - **权限:** ClickPipes 将为写入数据到目标表创建一个专用用户。您可以使用自定义角色或预定义角色选择此内部用户的角色: - - `Full access`:对集群具有完全访问权限。如果您使用目标表的物化视图或字典,这可能会很有用。 - - `Only destination table`:仅对目标表具有 `INSERT` 权限。 + **权限:** ClickPipes 将为将数据写入目标表创建一个专用用户。您可以使用自定义角色或预定义角色之一选择该内部用户的角色: + - `Full access`:具有对集群的完全访问权限。如果您使用物化视图或与目标表的字典,这可能会很有用。 + - `Only destination table`:只对目标表具有 `INSERT` 权限。 -9. 点击“完成设置”,系统将注册您的 ClickPipe,您将能够在摘要表中查看它。 +9. 点击 "Complete Setup" 后,系统将注册您的 ClickPipe,您将能在摘要表中看到它。 - 摘要表提供控件,以显示来自源或 ClickHouse 中的目标表的示例数据 + 摘要表提供了显示源或 ClickHouse 中目标表的示例数据的控件 - 以及控件来删除 ClickPipe 并显示摄取作业的摘要。 + 以及删除 ClickPipe 和显示导入作业摘要的控件。 -10. **恭喜!** 您已成功设置您的第一个 ClickPipe。如果这是一个流式 ClickPipe,它将持续运行,从您的远程数据源实时摄取数据。否则将摄取批处理并完成。 +10. **恭喜!**您已成功设置您的第一个 ClickPipe。如果这是一个流式 ClickPipe,它将持续运行,实时从您的远程数据源中导入数据。否则,它将批量导入并完成。 ## 支持的数据格式 {#supported-data-formats} @@ -91,79 +92,74 @@ import Image from '@theme/IdealImage'; ## 支持的数据类型 {#supported-data-types} ### 标准类型支持 {#standard-types-support} -当前 ClickHouse 数据库支持以下 ClickPipes 数据类型: +当前 ClickPipes 支持以下 ClickHouse 数据类型: -- 基本数值类型 - \[U\]Int8/16/32/64 和 Float32/64 -- 大整数类型 - \[U\]Int128/256 +- 基本数字类型 - \[U\]Int8/16/32/64,Float32/64 和 BFloat16 +- 大整型 - \[U\]Int128/256 - 十进制类型 -- 布尔类型 +- 布尔型 - 字符串 - 固定字符串 - 日期、Date32 -- 日期时间、DateTime64(仅 UTC 时区) +- 日期时间、DateTime64(仅限 UTC 时区) - Enum8/Enum16 - UUID - IPv4 - IPv6 -- 所有 ClickHouse 低基数类型 -- 使用上述任何类型(包括 Nullable)的键和值的 Map -- 使用上述任何类型的元素(包括 Nullable,深度仅限一层)的 Tuple 和 Array -- -### 变体类型支持(实验性) {#variant-type-support} -如果您的 Cloud 服务运行 ClickHouse 25.3 或更高版本,则变体类型支持是自动的。否则,您需要提交支持工单以在您的服务上启用它。 +- 所有 ClickHouse LowCardinality 类型 +- 使用上述任一类型(包括 Nullable)的键和值的 Map +- 使用上述任一类型(包括 Nullable,限制为一层深度)的 Tuple 和 Array +- SimpleAggregateFunction 类型(用于 AggregatingMergeTree 或 SummingMergeTree 目标) -您可以手动为源数据流中的任何 JSON 字段指定变体类型(例如 `Variant(String, Int64, DateTime)`)。由于 ClickPipes 确定使用正确的变体子类型的方式,因此变体定义中只能使用一种整数或日期时间类型 - 例如,`Variant(Int64, UInt32)` 不被支持。 +### 变体类型支持 {#variant-type-support} +您可以为源数据流中的任何 JSON 字段手动指定变体类型(例如 `Variant(String, Int64, DateTime)`)。由于 ClickPipes 确定正确的变体子类型的方法,变体定义中只能使用一个整数或日期时间类型 - 例如,不支持 `Variant(Int64, UInt32)`。 -### JSON 类型支持(实验性) {#json-type-support} -如果您的 Cloud 服务运行 ClickHouse 25.3 或更高版本,则 JSON 类型支持是自动的。否则,您需要提交支持工单以在您的服务上启用它。 - -始终是 JSON 对象的 JSON 字段可以分配给 JSON 目标列。您需要手动将目标列更改为所需的 JSON 类型,包括任何固定或跳过的路径。 +### JSON 类型支持 {#json-type-support} +始终为 JSON 对象的 JSON 字段可以分配给 JSON 目标列。您将必须手动将目标列更改为所需的 JSON 类型,包括任何固定或跳过的路径。 ## Kinesis 虚拟列 {#kinesis-virtual-columns} -对于 Kinesis 流,支持以下虚拟列。在创建新目标表时,可以使用 `Add Column` 按钮添加虚拟列。 +以下虚拟列支持 Kinesis 流。在创建新的目标表时,可以使用 `Add Column` 按钮添加虚拟列。 -| 名称 | 描述 | 推荐数据类型 | -|------------------|--------------------------------------------------------|-----------------------| -| _key | Kinesis 分区键 | 字符串 | -| _timestamp | Kinesis 近似到达时间戳(毫秒精度) | DateTime64(3) | -| _stream | Kinesis 流名称 | 字符串 | -| _sequence_number | Kinesis 序列号 | 字符串 | -| _raw_message | 完整的 Kinesis 消息 | 字符串 | +| 名称 | 描述 | 推荐数据类型 | +|-------------------|------------------------------------------------------------|---------------------| +| _key | Kinesis 分区键 | 字符串 | +| _timestamp | Kinesis 近似到达时间戳(毫秒精度) | DateTime64(3) | +| _stream | Kinesis 流名称 | 字符串 | +| _sequence_number | Kinesis 序列号 | 字符串 | +| _raw_message | 完整的 Kinesis 消息 | 字符串 | -_raw_message 字段可用于仅需要完整 Kinesis JSON 记录的情况下(例如使用 ClickHouse [`JsonExtract*`](/sql-reference/functions/json-functions#jsonextract-functions) 函数填充下游物化视图)。对于此类管道,删除所有“非虚拟”列可以提高 ClickPipes 的性能。 +_raw_message 字段可以在仅需要完整的 Kinesis JSON 记录的情况下使用(例如使用 ClickHouse [`JsonExtract*`](/sql-reference/functions/json-functions#jsonextract-functions) 函数填充下游物化视图)。对于这样的管道,删除所有 "非虚拟" 列可能会提高 ClickPipes 的性能。 ## 限制 {#limitations} -- [DEFAULT](/sql-reference/statements/create/table#default) 不被支持。 +- 不支持 [DEFAULT](/sql-reference/statements/create/table#default)。 ## 性能 {#performance} -### 批量 {#batching} -ClickPipes 以批量方式将数据插入 ClickHouse。这样可以避免在数据库中创建过多的部分,从而导致集群性能问题。 +### 批处理 {#batching} +ClickPipes 以批处理方式将数据插入 ClickHouse。这是为了避免在数据库中创建过多的分区片段,这可能导致集群性能问题。 -批量插入在满足以下条件之一时发生: -- 批量大小达到最大值(100,000 行或 20MB) -- 批量已打开的最长时间(5 秒) +当满足以下任一条件时,批次将被插入: +- 批次大小已达到最大大小(每 1GB 副本内存 100,000 行或 32MB) +- 批次已打开的最长时间(5 秒) ### 延迟 {#latency} -延迟(定义为 Kinesis 消息发送到流中和消息在 ClickHouse 中可用之间的时间)将依赖于多个因素(即 Kinesis 延迟、网络延迟、消息大小/格式)。上述节中描述的 [批量处理](#batching) 也将影响延迟。我们总是建议测试您的特定用例,以了解您可以预期的延迟。 +延迟(定义为 Kinesis 消息发送到流与消息在 ClickHouse 中可用之间的时间)将取决于多种因素(即 Kinesis 延迟、网络延迟、消息大小/格式)。上述部分中的 [批处理](#batching) 也会影响延迟。我们始终建议测试您的具体用例,以了解您可以预期的延迟。 -如果您有特定的低延迟需求,请 [联系我们](https://clickhouse.com/company/contact?loc=clickpipes)。 +如果您有特定的低延迟要求,请 [与我们联系](https://clickhouse.com/company/contact?loc=clickpipes)。 ### 扩展性 {#scaling} -ClickPipes for Kinesis 旨在水平扩展。默认情况下,我们创建一个具有一个消费者的消费者组。 -这可以通过 ClickPipe 详情视图中的扩展控件进行更改。 +Kinesis 的 ClickPipes 设计为能够水平和垂直扩展。默认情况下,我们创建一个包含一个消费者的消费者组。这可以在 ClickPipe 创建期间进行配置,或在 **设置** -> **高级设置** -> **扩展性** 中的任何其他时刻进行配置。 -ClickPipes 提供高可用性和可用区分布式架构。 -这需要将消费者数量扩展到至少两个。 +ClickPipes 提供高可用性,具有可用区分布式架构。 +这需要扩展到至少两个消费者。 -无论运行的消费者数量如何,容错都是设计而成的。 -如果一个消费者或其底层基础设施发生故障, -ClickPipe 将自动重新启动该消费者并继续处理消息。 +无论运行的消费者数量如何,故障容限都是凭设计而可用的。 +如果消费者或其基础设施出现故障,ClickPipe 将自动重启消费者并继续处理消息。 ## 身份验证 {#authentication} -要访问 Amazon Kinesis 流,您可以使用 [IAM 凭证](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html) 或 [IAM 角色](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles.html)。有关如何设置 IAM 角色的更多详细信息,您可以 [参考此指南](./secure-kinesis.md),以获取与 ClickHouse Cloud 兼容的角色的设置信息。 +要访问 Amazon Kinesis 流,您可以使用 [IAM 凭证](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html) 或 [IAM 角色](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles.html)。有关如何设置 IAM 角色的更多信息,您可以 [参考此指南](./secure-kinesis.md),了解如何设置与 ClickHouse Cloud 兼容的角色。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/kinesis.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/kinesis.md.hash index cef5cc9e7b5..5cfe1a5a3e3 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/kinesis.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/kinesis.md.hash @@ -1 +1 @@ -b0d87816bd4c378a +fbf45875120fe5f4 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/add_table.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/add_table.md new file mode 100644 index 00000000000..64dab5ff01e --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/add_table.md @@ -0,0 +1,33 @@ +--- +'title': '将特定表添加到 ClickPipe' +'description': '描述将特定表添加到 ClickPipe 所需的步骤。' +'sidebar_label': '添加表' +'slug': '/integrations/clickpipes/mongodb/add_table' +'show_title': false +'doc_type': 'guide' +--- + +import Image from '@theme/IdealImage'; +import add_table from '@site/static/images/integrations/data-ingestion/clickpipes/postgres/add_table.png' + + +# 将特定表添加到 ClickPipe + +在某些情况下,将特定表添加到管道中会很有用。随着事务或分析工作负载的扩展,这成为一种常见的需求。 + +## 将特定表添加到 ClickPipe 的步骤 {#add-tables-steps} + +可以通过以下步骤完成此操作: +1. [暂停](./pause_and_resume.md) 管道。 +2. 点击编辑表设置。 +3. 定位您的表 - 您可以通过搜索栏搜索找到它。 +4. 通过点击复选框选择表。 +
+ + +5. 点击更新。 +6. 更新成功后,管道将依次显示状态 `Setup`、`Snapshot` 和 `Running`。可以在 **Tables** 标签中跟踪表的初始加载。 + +:::info +现有表的 CDC 在新表的快照完成后会自动恢复。 +::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/add_table.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/add_table.md.hash new file mode 100644 index 00000000000..133023f7a2b --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/add_table.md.hash @@ -0,0 +1 @@ +0369b8076a2e2762 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/controlling_sync.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/controlling_sync.md new file mode 100644 index 00000000000..91ba9137d0f --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/controlling_sync.md @@ -0,0 +1,56 @@ +--- +'title': '控制 MongoDB ClickPipe 的同步' +'description': '文档用于控制 MongoDB ClickPipe 的同步' +'slug': '/integrations/clickpipes/mongodb/sync_control' +'sidebar_label': '控制同步' +'doc_type': 'guide' +--- + +import edit_sync_button from '@site/static/images/integrations/data-ingestion/clickpipes/postgres/edit_sync_button.png' +import create_sync_settings from '@site/static/images/integrations/data-ingestion/clickpipes/postgres/create_sync_settings.png' +import edit_sync_settings from '@site/static/images/integrations/data-ingestion/clickpipes/postgres/sync_settings_edit.png' +import cdc_syncs from '@site/static/images/integrations/data-ingestion/clickpipes/postgres/cdc_syncs.png' +import Image from '@theme/IdealImage'; + +该文档描述了如何控制MongoDB ClickPipe的同步,当ClickPipe处于**CDC (运行)模式**时。 + +## 概述 {#overview} + +数据库ClickPipes的架构由两个并行进程组成 - 从源数据库拉取数据和推送到目标数据库。拉取过程由同步配置控制,该配置定义了数据应每隔多长时间拉取,以及每次应拉取多少数据。我们所说的“每次”是指一批 - 因为ClickPipe以批量方式拉取和推送数据。 + +控制MongoDB ClickPipe同步的主要方式有两种。当以下设置之一启用时,ClickPipe将开始推送数据。 + +### 同步间隔 {#interval} + +管道的同步间隔是ClickPipe将从源数据库拉取记录的时间(以秒为单位)。我们推送到ClickHouse的时间不包括在此间隔中。 + +默认值为**1分钟**。 +同步间隔可以设置为任何正整数值,但建议保持在10秒以上。 + +### 拉取批大小 {#batch-size} + +拉取批大小是ClickPipe在一次批处理中将从源数据库拉取的记录数量。记录是指在属于管道的集合中进行的插入、更新和删除操作。 + +默认值为**100,000**条记录。 +安全的最大值为1000万。 + +### 配置同步设置 {#configuring} + +您可以在创建ClickPipe时或编辑现有ClickPipe时设置同步间隔和拉取批大小。 +在创建ClickPipe时,这些设置将在创建向导的第二步中显示,如下所示: + + + +在编辑现有ClickPipe时,您可以转到管道的**设置**选项卡,暂停管道,然后单击**配置**: + + + +这将打开一个飞出窗口,其中包含同步设置,您可以在其中更改同步间隔和拉取批大小: + + + +### 监控同步控制行为 {#monitoring} + +您可以在ClickPipe的**指标**选项卡中的**CDC Syncs**表中看到每个批处理所需的时间。请注意,这里的持续时间包括推送时间,以及如果没有行输入,ClickPipe将等待,等待时间也包括在持续时间内。 + + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/controlling_sync.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/controlling_sync.md.hash new file mode 100644 index 00000000000..160afd4628e --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/controlling_sync.md.hash @@ -0,0 +1 @@ +dea510599443b5e5 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/datatypes.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/datatypes.md new file mode 100644 index 00000000000..aa3188f8fe6 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/datatypes.md @@ -0,0 +1,30 @@ +--- +'title': '支持的数据类型' +'slug': '/integrations/clickpipes/mongodb/datatypes' +'description': '页面描述 MongoDB ClickPipe 数据类型从 MongoDB 映射到 ClickHouse' +'doc_type': 'reference' +--- + +MongoDB将数据记录存储为BSON文档。在ClickPipes中,您可以配置以将BSON文档以JSON或JSON字符串的形式导入到ClickHouse。下表显示了支持的BSON到JSON字段类型映射: + +| MongoDB BSON类型 | ClickHouse JSON类型 | 备注 | +| ------------------------ | -------------------------------------- | ------------------------ | +| ObjectId | String | | +| String | String | | +| 32位整数 | Int64 | | +| 64位整数 | Int64 | | +| Double | Float64 | | +| Boolean | Bool | | +| Date | String | ISO 8601格式 | +| 正则表达式 | \{Options: String, Pattern: String\} | MongoDB正则表达式,固定字段:Options(正则标志)和Pattern(正则模式) | +| 时间戳 | \{T: Int64, I: Int64\} | MongoDB内部时间戳格式,固定字段:T(时间戳)和I(增量) | +| Decimal128 | String | | +| 二进制数据 | \{Data: String, Subtype: Int64\} | MongoDB二进制数据,固定字段:Data(base64编码)和Subtype([二进制类型](https://www.mongodb.com/docs/manual/reference/bson-types/#binary-data)) | +| JavaScript | String | | +| Null | Null | | +| 数组 | Dynamic | 同质类型的数组变为Array(Nullable(T)); 混合原始类型的数组提升为最一般的公共类型; 复杂不兼容类型的数组变为元组 | +| 对象 | Dynamic | 每个嵌套字段递归映射 | + +:::info +要了解有关ClickHouse的JSON数据类型的更多信息,请参阅 [我们的文档](https://clickhouse.com/docs/sql-reference/data-types/newjson)。 +::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/datatypes.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/datatypes.md.hash new file mode 100644 index 00000000000..e3715ec5ab7 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/datatypes.md.hash @@ -0,0 +1 @@ +b207142f4a928e88 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/faq.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/faq.md new file mode 100644 index 00000000000..bf65e984e67 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/faq.md @@ -0,0 +1,66 @@ +--- +'sidebar_label': '常见问题' +'description': '关于 ClickPipes for MongoDB 的常见问题。' +'slug': '/integrations/clickpipes/mongodb/faq' +'sidebar_position': 2 +'title': 'ClickPipes for MongoDB 常见问题解答' +'doc_type': 'reference' +--- + + +# ClickPipes for MongoDB FAQ + +### Can I query for individual fields in the JSON datatype? {#can-i-query-for-individual-fields-in-the-json-datatype} + +对于直接字段访问,例如 `{"user_id": 123}`,您可以使用 **点表示法**: +```sql +SELECT doc.user_id as user_id FROM your_table; +``` +对于嵌套对象字段的直接字段访问,例如 `{"address": { "city": "San Francisco", "state": "CA" }}`,使用 `^` 运算符: +```sql +SELECT doc.^address.city AS city FROM your_table; +``` +对于聚合,使用 `CAST` 函数或 `::` 语法将字段转换为适当的类型: +```sql +SELECT sum(doc.shipping.cost::Float32) AS total_shipping_cost FROM t1; +``` +要了解有关 JSON 的更多信息,请参阅我们的 [Working with JSON guide](./quickstart)。 + +### How do I flatten the nested MongoDB documents in ClickHouse? {#how-do-i-flatten-the-nested-mongodb-documents-in-clickhouse} + +MongoDB 文档默认以 JSON 类型在 ClickHouse 中进行复制,保留嵌套结构。您有几种选项可以将这些数据扁平化。如果您想将数据扁平化为列,您可以使用普通视图、物化视图或查询时访问。 + +1. **普通视图**:使用普通视图来封装扁平化逻辑。 +2. **物化视图**:对于较小的数据集,您可以使用可刷新的物化视图,并结合 [`FINAL` 修饰符](/sql-reference/statements/select/from#final-modifier) 定期扁平化并去重数据。对于较大的数据集,我们建议使用增量物化视图而不使用 `FINAL`,以实时扁平化数据,然后在查询时去重数据。 +3. **查询时访问**:不仅限于扁平化,可以使用点表示法直接访问查询中的嵌套字段。 + +有关详细示例,请参阅我们的 [Working with JSON guide](./quickstart)。 + +### Can I connect MongoDB databases that don't have a public IP or are in private networks? {#can-i-connect-mongodb-databases-that-dont-have-a-public-ip-or-are-in-private-networks} + +我们支持 AWS PrivateLink 连接没有公共 IP 或位于私有网络中的 MongoDB 数据库。目前不支持 Azure Private Link 和 GCP Private Service Connect。 + +### What happens if I delete a database/table from my MongoDB database? {#what-happens-if-i-delete-a-database-table-from-my-mongodb-database} + +当您从 MongoDB 中删除数据库/表时,ClickPipes 将继续运行,但删除的数据库/表将停止复制更改。ClickHouse 中的相应表将被保留。 + +### How does MongoDB CDC Connector handle transactions? {#how-does-mongodb-cdc-connector-handle-transactions} + +事务内的每个文档更改都单独处理并发送到 ClickHouse。更改按它们在 oplog 中出现的顺序应用;只有提交的更改才会复制到 ClickHouse。如果 MongoDB 事务被回滚,这些更改将不会出现在变更流中。 + +有关更多示例,请参阅我们的 [Working with JSON guide](./quickstart)。 + +### How do I handle `resume of change stream was not possible, as the resume point may no longer be in the oplog.` error? {#resume-point-may-no-longer-be-in-the-oplog-error} + +此错误通常发生在 oplog 被截断时,ClickPipe 无法在预期的点恢复变更流。要解决此问题,请 [重新同步 ClickPipe](./resync.md)。为避免此问题再次发生,我们建议 [增加 oplog 保留期限](./source/atlas#enable-oplog-retention)(或如果您在自管理 MongoDB,请 [点击这里](./source/generic#enable-oplog-retention))。 + +### How is replication managed? {#how-is-replication-managed} + +我们使用 MongoDB 的原生变更流 API 跟踪数据库中的更改。变更流 API 通过利用 MongoDB 的 oplog(操作日志)提供可恢复的数据库更改流。ClickPipe 使用 MongoDB 的恢复令牌跟踪 oplog 中的位置,并确保每个更改都复制到 ClickHouse。 + +### Which read preference should I use? {#which-read-preference-should-i-use} + +使用哪个读取偏好取决于您的具体使用情况。如果您想最小化对主节点的负载,我们建议使用 `secondaryPreferred` 读取偏好。如果您想优化数据摄取延迟,我们建议使用 `primaryPreferred` 读取偏好。有关更多详细信息,请参阅 [MongoDB documentation](https://www.mongodb.com/docs/manual/core/read-preference/#read-preference-modes-1)。 + +### Does the MongoDB ClickPipe support Sharded Cluster? {#does-the-mongodb-clickpipe-support-sharded-cluster} +是的,MongoDB ClickPipe 同时支持副本集和分片集群。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/faq.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/faq.md.hash new file mode 100644 index 00000000000..b894d8fc098 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/faq.md.hash @@ -0,0 +1 @@ +b61afc57f2b1903e diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/index.md new file mode 100644 index 00000000000..6a1f884eed9 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/index.md @@ -0,0 +1,105 @@ +--- +'sidebar_label': '从 MongoDB 到 ClickHouse 导入数据' +'description': '描述如何无缝连接您的 MongoDB 到 ClickHouse Cloud.' +'slug': '/integrations/clickpipes/mongodb' +'title': '从 MongoDB 到 ClickHouse (使用 CDC) 导入数据' +'doc_type': 'guide' +--- + +import BetaBadge from '@theme/badges/BetaBadge'; +import cp_service from '@site/static/images/integrations/data-ingestion/clickpipes/cp_service.png'; +import cp_step0 from '@site/static/images/integrations/data-ingestion/clickpipes/cp_step0.png'; +import mongodb_tile from '@site/static/images/integrations/data-ingestion/clickpipes/mongodb/mongodb-tile.png' +import mongodb_connection_details from '@site/static/images/integrations/data-ingestion/clickpipes/mongodb/mongodb-connection-details.png' +import select_destination_db from '@site/static/images/integrations/data-ingestion/clickpipes/mongodb/select-destination-db.png' +import ch_permissions from '@site/static/images/integrations/data-ingestion/clickpipes/postgres/ch-permissions.jpg' +import Image from '@theme/IdealImage'; + + +# 从 MongoDB 向 ClickHouse 导入数据(使用 CDC) + + + +:::info +通过 ClickPipes 从 MongoDB 向 ClickHouse Cloud 导入数据处于公开测试阶段。 +::: + +:::note +在 ClickHouse Cloud 控制台和文档中,“表”和“集合”可以互换使用,适用于 MongoDB。 +::: + +您可以使用 ClickPipes 将数据从 MongoDB 数据库导入到 ClickHouse Cloud。源 MongoDB 数据库可以托管在本地或云端,如使用 MongoDB Atlas 等服务。 + +## 前提条件 {#prerequisites} + +首先,您需要确保您的 MongoDB 数据库已正确配置用于复制。配置步骤取决于您如何部署 MongoDB,因此请遵循以下相关指南: + +1. [MongoDB Atlas](./mongodb/source/atlas) + +2. [通用 MongoDB](./mongodb/source/generic) + +一旦您的源 MongoDB 数据库设置完成,您可以继续创建您的 ClickPipe。 + +## 创建您的 ClickPipe {#create-your-clickpipe} + +确保您已登录到您的 ClickHouse Cloud 账户。如果您还没有账户,可以 [在这里注册](https://cloud.clickhouse.com/)。 + +1. 在 ClickHouse Cloud 控制台中,导航至您的 ClickHouse Cloud 服务。 + + + +2. 在左侧菜单中选择 `数据源` 按钮,然后点击“设置 ClickPipe”。 + + + +3. 选择 `MongoDB CDC` 瓦片。 + + + +### 添加您的源 MongoDB 数据库连接 {#add-your-source-mongodb-database-connection} + +4. 填写您在前提条件步骤中配置的源 MongoDB 数据库的连接详细信息。 + + :::info + 在开始添加连接详细信息之前,请确保您已在防火墙规则中白名单 ClickPipes 的 IP 地址。在以下页面,您可以找到 [ClickPipes IP 地址列表](../index.md#list-of-static-ips)。 + 有关更多信息,请参考在 [本页面顶部](#prerequisites) 链接的源 MongoDB 设置指南。 + ::: + + + +填写连接详细信息后,点击 `下一步`。 + +#### 配置高级设置 {#advanced-settings} + +如果需要,您可以配置高级设置。下面提供了每个设置的简要描述: + +- **同步间隔**:这是 ClickPipes 轮询源数据库以检测更改的间隔。这对目标 ClickHouse 服务有影响,对于费用敏感的用户,我们建议将此值保持在较高的数值(超过 `3600`)。 +- **拉取批处理大小**:在单个批处理中获取的行数。这是一个最佳努力设置,可能并不在所有情况下都得到遵守。 +- **并行快照表的数量**:在初始快照期间将并行获取的表的数量。当您有大量表时,这很有用,您可以控制并行提取的表的数量。 + +### 配置表 {#configure-the-tables} + +5. 在这里,您可以选择 ClickPipe 的目标数据库。您可以选择现有数据库或创建一个新数据库。 + + + +6. 您可以选择要从源 MongoDB 数据库复制的表。在选择表时,您还可以选择重命名目标 ClickHouse 数据库中的表。 + +### 审查权限并启动 ClickPipe {#review-permissions-and-start-the-clickpipe} + +7. 从权限下拉菜单中选择“完全访问”角色,然后点击“完成设置”。 + + + +## 接下来是什么? {#whats-next} + +一旦您设置好 ClickPipe 从 MongoDB 向 ClickHouse Cloud 复制数据,您可以专注于如何查询和建模数据以获得最佳性能。 + +## 注意事项 {#caveats} + +使用此连接器时请注意以下几点: + +- 我们要求 MongoDB 版本为 5.1.0+。 +- 我们使用 MongoDB 的原生变更流 API 进行 CDC,它依赖于 MongoDB 的 oplog 来捕获实时更改。 +- 默认情况下,来自 MongoDB 的文档作为 JSON 类型复制到 ClickHouse。这允许灵活的模式管理,并使得可以使用 ClickHouse 中丰富的 JSON 操作符进行查询和分析。您可以在[这里](https://clickhouse.com/docs/sql-reference/data-types/newjson)了解有关查询 JSON 数据的更多信息。 +- 自助式 PrivateLink 配置目前不可用。如果您在 AWS 上并需要 PrivateLink,请联系 db-integrations-support@clickhouse.com 或创建支持票据——我们将与您合作以启用它。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/index.md.hash new file mode 100644 index 00000000000..23894f86afc --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/index.md.hash @@ -0,0 +1 @@ +d734eade8b1276a3 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/lifecycle.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/lifecycle.md new file mode 100644 index 00000000000..04a83fc25af --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/lifecycle.md @@ -0,0 +1,65 @@ +--- +'sidebar_label': 'MongoDB ClickPipe 的生命周期' +'description': '各种管道状态及其含义' +'slug': '/integrations/clickpipes/mongodb/lifecycle' +'title': 'MongoDB ClickPipe 的生命周期' +'doc_type': 'guide' +--- + + +# MongoDB ClickPipe 的生命周期 {#lifecycle} + +这是有关 MongoDB ClickPipe 各个阶段、它可以拥有的不同状态及其含义的文档。 + +## 配置 {#provisioning} + +当您点击“创建 ClickPipe”按钮时,ClickPipe 会处于 `Provisioning` 状态。配置过程是我们启动用于运行 ClickPipes 服务的底层基础设施,同时注册一些管道的初始元数据。由于 ClickPipes 在服务中共享计算资源,因此您的第二个 ClickPipe 的创建速度会比第一个快得多,因为基础设施已经到位。 + +## 设置 {#setup} + +在管道配置后,它进入 `Setup` 状态。在这个状态下,我们创建目标的 ClickHouse 表。 + +## 快照 {#snapshot} + +一旦设置完成,我们进入 `Snapshot` 状态(除非它是仅限 CDC 的管道,这将转换为 `Running`)。`Snapshot`、`Initial Snapshot` 和 `Initial Load`(更常见)是可互换的术语。在这个状态下,我们对源 MongoDB 集合进行快照并将其加载到 ClickHouse 中。oplog 的保留设置应考虑到初始加载时间。当触发重新同步或向现有管道添加新表时,管道也将进入 `Snapshot` 状态。 + +## 运行 {#running} + +初始加载完成后,管道进入 `Running` 状态(除非它是仅限快照的管道,这将转换为 `Completed`)。在这里,管道开始执行 `Change-Data Capture`。在此状态下,我们开始从源 MongoDB 集群向 ClickHouse 流式传输更改。有关控制 CDC 的信息,请参见 [控制 CDC 的文档](./sync_control)。 + +## 暂停 {#paused} + +当管道处于 `Running` 状态时,您可以暂停它。这将停止 CDC 过程,管道将进入 `Paused` 状态。在此状态下,未从源 MongoDB 拉取新数据,但 ClickHouse 中的现有数据保持不变。您可以从此状态恢复管道。 + +## 正在暂停 {#pausing} + +:::note +此状态即将推出。如果您正在使用我们的 [OpenAPI](https://clickhouse.com/docs/cloud/manage/openapi),请考虑现在为其添加支持,以确保您的集成在发布时继续正常工作。 +::: +当您点击“暂停”按钮时,管道进入 `Pausing` 状态。这是一个临时状态,我们正在停止 CDC 过程。一旦 CDC 过程完全停止,管道将进入 `Paused` 状态。 + +## 修改 {#modifying} +:::note +此状态即将推出。如果您正在使用我们的 [OpenAPI](https://clickhouse.com/docs/cloud/manage/openapi),请考虑现在为其添加支持,以确保您的集成在发布时继续正常工作。 +::: +目前,这表示管道正在删除表的过程中。 + +## 重新同步 {#resync} +:::note +此状态即将推出。如果您正在使用我们的 [OpenAPI](https://clickhouse.com/docs/cloud/manage/openapi),请考虑现在为其添加支持,以确保您的集成在发布时继续正常工作。 +::: +此状态表示管道正在重新同步的阶段,其中正在对 _resync 表与原始表进行原子交换。有关重新同步的更多信息,请参见 [重新同步文档](./resync)。 + +## 完成 {#completed} + +此状态适用于仅限快照的管道,并表示快照已完成,没有更多的工作要做。 + +## 失败 {#failed} + +如果管道中出现无法恢复的错误,它将进入 `Failed` 状态。您可以联系支持或 [重新同步](./resync) 您的管道以从此状态恢复。 + +## 降级 {#degraded} + +:::note +此状态即将推出。如果您正在使用我们的 [OpenAPI](https://clickhouse.com/docs/cloud/manage/openapi),请考虑现在为其添加支持,以确保您的集成在发布时继续正常工作。 +::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/lifecycle.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/lifecycle.md.hash new file mode 100644 index 00000000000..a1d6e94828d --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/lifecycle.md.hash @@ -0,0 +1 @@ +60fdb1b4f78aaf3a diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/pause_and_resume.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/pause_and_resume.md new file mode 100644 index 00000000000..bb9432d3dcd --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/pause_and_resume.md @@ -0,0 +1,47 @@ +--- +'title': '暂停和恢复 MongoDB ClickPipe' +'description': '暂停和恢复 MongoDB ClickPipe' +'sidebar_label': '暂停表' +'slug': '/integrations/clickpipes/mongodb/pause_and_resume' +'doc_type': 'guide' +--- + +import Image from '@theme/IdealImage'; +import pause_button from '@site/static/images/integrations/data-ingestion/clickpipes/postgres/pause_button.png' +import pause_dialog from '@site/static/images/integrations/data-ingestion/clickpipes/postgres/pause_dialog.png' +import pause_status from '@site/static/images/integrations/data-ingestion/clickpipes/postgres/pause_status.png' +import resume_button from '@site/static/images/integrations/data-ingestion/clickpipes/postgres/resume_button.png' +import resume_dialog from '@site/static/images/integrations/data-ingestion/clickpipes/postgres/resume_dialog.png' + +在某些场景中,暂停 MongoDB ClickPipe 是很有用的。例如,您可能希望在静态状态下对现有数据进行一些分析,或者您可能正在对 MongoDB 进行升级。以下是如何暂停和恢复 MongoDB ClickPipe 的步骤。 + +## 暂停 MongoDB ClickPipe 的步骤 {#pause-clickpipe-steps} + +1. 在数据源选项卡中,点击您希望暂停的 MongoDB ClickPipe。 +2. 前往 **设置** 选项卡。 +3. 点击 **暂停** 按钮。 + + + +4. 应出现一个确认对话框。再次点击暂停。 + + + +5. 前往 **指标** 选项卡。 +6. 等待管道状态变为 **暂停**。 + + + +## 恢复 MongoDB ClickPipe 的步骤 {#resume-clickpipe-steps} +1. 在数据源选项卡中,点击您希望恢复的 MongoDB ClickPipe。镜像的状态最初应该为 **暂停**。 +2. 前往 **设置** 选项卡。 +3. 点击 **恢复** 按钮。 + + + +4. 应出现一个确认对话框。再次点击恢复。 + + + +5. 前往 **指标** 选项卡。 +6. 等待管道状态变为 **运行**。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/pause_and_resume.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/pause_and_resume.md.hash new file mode 100644 index 00000000000..f5fd257076f --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/pause_and_resume.md.hash @@ -0,0 +1 @@ +6395fbbdc8a584d5 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/quickstart.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/quickstart.md new file mode 100644 index 00000000000..044ae92d86e --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/quickstart.md @@ -0,0 +1,371 @@ +--- +'title': '在 ClickHouse 中处理 JSON' +'sidebar_label': '处理 JSON' +'slug': '/integrations/clickpipes/mongodb/quickstart' +'description': '从 MongoDB 通过 ClickPipes 复制到 ClickHouse 的 JSON 数据的常见模式' +'doc_type': 'guide' +--- + + +# 在 ClickHouse 中使用 JSON + +本指南提供了从 MongoDB 通过 ClickPipes 复制到 ClickHouse 的 JSON 数据的常见模式。 + +假设我们在 MongoDB 中创建了一个集合 `t1` 来跟踪客户订单: + +```javascript +db.t1.insertOne({ + "order_id": "ORD-001234", + "customer_id": 98765, + "status": "completed", + "total_amount": 299.97, + "order_date": new Date(), + "shipping": { + "method": "express", + "city": "Seattle", + "cost": 19.99 + }, + "items": [ + { + "category": "electronics", + "price": 149.99 + }, + { + "category": "accessories", + "price": 24.99 + } + ] +}) +``` + +MongoDB CDC Connector 使用原生 JSON 数据类型将 MongoDB 文档复制到 ClickHouse。 在 ClickHouse 中复制的表 `t1` 将包含以下行: + +```shell +Row 1: +────── +_id: "68a4df4b9fe6c73b541703b0" +doc: {"_id":"68a4df4b9fe6c73b541703b0","customer_id":"98765","items":[{"category":"electronics","price":149.99},{"category":"accessories","price":24.99}],"order_date":"2025-08-19T20:32:11.705Z","order_id":"ORD-001234","shipping":{"city":"Seattle","cost":19.99,"method":"express"},"status":"completed","total_amount":299.97} +_peerdb_synced_at: 2025-08-19 20:50:42.005000000 +_peerdb_is_deleted: 0 +_peerdb_version: 0 +``` + +## 表模式 {#table-schema} + +复制的表使用以下标准模式: + +```shell +┌─name───────────────┬─type──────────┐ +│ _id │ String │ +│ doc │ JSON │ +│ _peerdb_synced_at │ DateTime64(9) │ +│ _peerdb_version │ Int64 │ +│ _peerdb_is_deleted │ Int8 │ +└────────────────────┴───────────────┘ +``` + +- `_id`: 来自 MongoDB 的主键 +- `doc`: 作为 JSON 数据类型复制的 MongoDB 文档 +- `_peerdb_synced_at`: 记录最后一次同步行的时间 +- `_peerdb_version`: 跟踪行的版本;在行被更新或删除时递增 +- `_peerdb_is_deleted`: 标记行是否已删除 + +### ReplacingMergeTree 表引擎 {#replacingmergetree-table-engine} + +ClickPipes 使用 `ReplacingMergeTree` 表引擎系列将 MongoDB 集合映射到 ClickHouse。 使用此引擎,更新被建模为插入具有更新版本 (`_peerdb_version`) 的文档,用于给定的主键 (`_id`),使得针对版本化插入的更新、替换和删除能够高效处理。 + +`ReplacingMergeTree` 会在后台异步清除重复项。 为了确保同一行没有重复项,请使用 [`FINAL` modifier](/sql-reference/statements/select/from#final-modifier)。例如: + +```sql +SELECT * FROM t1 FINAL; +``` + +### 处理删除 {#handling-deletes} + +来自 MongoDB 的删除操作以使用 `_peerdb_is_deleted` 列标记为已删除的新行传播。 您通常希望在查询中过滤掉这些行: + +```sql +SELECT * FROM t1 FINAL WHERE _peerdb_is_deleted = 0; +``` + +您还可以创建行级策略以自动过滤掉已删除的行,而不是在每个查询中指定过滤器: + +```sql +CREATE ROW POLICY policy_name ON t1 +FOR SELECT USING _peerdb_is_deleted = 0; +``` + +## 查询 JSON 数据 {#querying-json-data} + +您可以使用点语法直接查询 JSON 字段: + +```sql title="Query" +SELECT + doc.order_id, + doc.shipping.method +FROM t1; +``` + +```shell title="Result" +┌-─doc.order_id─┬─doc.shipping.method─┐ +│ ORD-001234 │ express │ +└───────────────┴─────────────────────┘ +``` + +当使用点语法查询 _嵌套对象字段_ 时,请确保添加 [`^`](https://clickhouse.com/docs/sql-reference/data-types/newjson#reading-json-sub-objects-as-sub-columns) 运算符: + +```sql title="Query" +SELECT doc.^shipping as shipping_info FROM t1; +``` + +```shell title="Result" +┌─shipping_info──────────────────────────────────────┐ +│ {"city":"Seattle","cost":19.99,"method":"express"} │ +└────────────────────────────────────────────────────┘ +``` + +### 动态类型 {#dynamic-type} + +在 ClickHouse 中,JSON 中的每个字段都有 `Dynamic` 类型。 动态类型允许 ClickHouse 存储任何类型的值,而无需提前知道类型。 您可以使用 `toTypeName` 函数验证这一点: + +```sql title="Query" +SELECT toTypeName(doc.customer_id) AS type FROM t1; +``` + +```shell title="Result" +┌─type────┐ +│ Dynamic │ +└─────────┘ +``` + +要检查字段的底层数据类型,可以使用 `dynamicType` 函数。 请注意,在不同的行中,同一字段名称可以具有不同的数据类型: + +```sql title="Query" +SELECT dynamicType(doc.customer_id) AS type FROM t1; +``` + +```shell title="Result" +┌─type──┐ +│ Int64 │ +└───────┘ +``` + +[常规函数](https://clickhouse.com/docs/sql-reference/functions/regular-functions) 适用于动态类型,就像它们适用于常规列一样: + +**示例 1:日期解析** + +```sql title="Query" +SELECT parseDateTimeBestEffortOrNull(doc.order_date) AS order_date FROM t1; +``` + +```shell title="Result" +┌─order_date──────────┐ +│ 2025-08-19 20:32:11 │ +└─────────────────────┘ +``` + +**示例 2:条件逻辑** + +```sql title="Query" +SELECT multiIf( + doc.total_amount < 100, 'less_than_100', + doc.total_amount < 1000, 'less_than_1000', + '1000+') AS spendings +FROM t1; +``` + +```shell title="Result" +┌─spendings──────┐ +│ less_than_1000 │ +└────────────────┘ +``` + +**示例 3:数组操作** + +```sql title="Query" +SELECT length(doc.items) AS item_count FROM t1; +``` + +```shell title="Result" +┌─item_count─┐ +│ 2 │ +└────────────┘ +``` + +### 字段类型转换 {#field-casting} + +[聚合函数](https://clickhouse.com/docs/sql-reference/aggregate-functions/combinators) 在 ClickHouse 中无法直接与动态类型一起使用。 例如,如果您尝试直接在动态类型上使用 `sum` 函数,您将获得以下错误: + +```sql +SELECT sum(doc.shipping.cost) AS shipping_cost FROM t1; +-- DB::Exception: Illegal type Dynamic of argument for aggregate function sum. (ILLEGAL_TYPE_OF_ARGUMENT) +``` + +要使用聚合函数,请通过 `CAST` 函数或 `::` 语法将字段转换为适当的类型: + +```sql title="Query" +SELECT sum(doc.shipping.cost::Float32) AS shipping_cost FROM t1; +``` + +```shell title="Result" +┌─shipping_cost─┐ +│ 19.99 │ +└───────────────┘ +``` + +:::note +从动态类型转换为底层数据类型(由 `dynamicType` 决定)是非常高效的,因为 ClickHouse 已经在其内部以底层类型存储值。 +::: + +## 扁平化 JSON {#flattening-json} + +### 正常视图 {#normal-view} + +您可以在 JSON 表上创建正常视图,以封装扁平化/转换逻辑,以便像查询关系表一样查询数据。 正常视图是轻量级的,因为它们仅存储查询本身,而不存储底层数据。 例如: + +```sql +CREATE VIEW v1 AS +SELECT + CAST(doc._id, 'String') AS object_id, + CAST(doc.order_id, 'String') AS order_id, + CAST(doc.customer_id, 'Int64') AS customer_id, + CAST(doc.status, 'String') AS status, + CAST(doc.total_amount, 'Decimal64(2)') AS total_amount, + CAST(parseDateTime64BestEffortOrNull(doc.order_date, 3), 'DATETIME(3)') AS order_date, + doc.^shipping AS shipping_info, + doc.items AS items +FROM t1 FINAL +WHERE _peerdb_is_deleted = 0; +``` + +此视图将具有以下模式: + +```shell +┌─name────────────┬─type───────────┐ +│ object_id │ String │ +│ order_id │ String │ +│ customer_id │ Int64 │ +│ status │ String │ +│ total_amount │ Decimal(18, 2) │ +│ order_date │ DateTime64(3) │ +│ shipping_info │ JSON │ +│ items │ Dynamic │ +└─────────────────┴────────────────┘ +``` + +您现在可以像查询扁平化表一样查询该视图: + +```sql +SELECT + customer_id, + sum(total_amount) +FROM v1 +WHERE shipping_info.city = 'Seattle' +GROUP BY customer_id +ORDER BY customer_id DESC +LIMIT 10; +``` + +### 可刷新的物化视图 {#refreshable-materialized-view} + +您可以创建 [可刷新的物化视图](https://clickhouse.com/docs/materialized-view/refreshable-materialized-view),这些视图使您能够安排查询执行以去重行,并将结果存储在扁平化目标表中。 每次安排的刷新时,目标表将被最新的查询结果替换。 + +此方法的一个主要优势是使用 `FINAL` 关键字的查询在刷新期间只运行一次,从而消除了在目标表上使用 `FINAL` 的后续查询的需要。 + +一个缺点是目标表中的数据仅在最近刷新时是最新的。 对于许多用例,几分钟到几小时的刷新间隔在数据新鲜度和查询性能之间提供了良好的平衡。 + +```sql +CREATE TABLE flattened_t1 ( + `_id` String, + `order_id` String, + `customer_id` Int64, + `status` String, + `total_amount` Decimal(18, 2), + `order_date` DateTime64(3), + `shipping_info` JSON, + `items` Dynamic +) +ENGINE = ReplacingMergeTree() +PRIMARY KEY _id +ORDER BY _id; + +CREATE MATERIALIZED VIEW rmv REFRESH EVERY 1 HOUR TO flattened_t1 AS +SELECT + CAST(doc._id, 'String') AS _id, + CAST(doc.order_id, 'String') AS order_id, + CAST(doc.customer_id, 'Int64') AS customer_id, + CAST(doc.status, 'String') AS status, + CAST(doc.total_amount, 'Decimal64(2)') AS total_amount, + CAST(parseDateTime64BestEffortOrNull(doc.order_date, 3), 'DATETIME(3)') AS order_date, + doc.^shipping AS shipping_info, + doc.items AS items +FROM t1 FINAL +WHERE _peerdb_is_deleted = 0; +``` + +您现在可以直接查询表 `flattened_t1` 而无需 `FINAL` 修饰符: + +```sql +SELECT + customer_id, + sum(total_amount) +FROM flattened_t1 +WHERE shipping_info.city = 'Seattle' +GROUP BY customer_id +ORDER BY customer_id DESC +LIMIT 10; +``` + +### 增量物化视图 {#incremental-materialized-view} + +如果您想实时访问扁平化列,您可以创建 [增量物化视图](https://clickhouse.com/docs/materialized-view/incremental-materialized-view)。 如果您的表有频繁更新,不推荐在物化视图中使用 `FINAL` 修饰符,因为每次更新都会触发合并。 相反,您可以通过在物化视图上构建正常视图在查询时去重数据。 + +```sql +CREATE TABLE flattened_t1 ( + `_id` String, + `order_id` String, + `customer_id` Int64, + `status` String, + `total_amount` Decimal(18, 2), + `order_date` DateTime64(3), + `shipping_info` JSON, + `items` Dynamic, + `_peerdb_version` Int64, + `_peerdb_synced_at` DateTime64(9), + `_peerdb_is_deleted` Int8 +) +ENGINE = ReplacingMergeTree() +PRIMARY KEY _id +ORDER BY _id; + +CREATE MATERIALIZED VIEW imv TO flattened_t1 AS +SELECT + CAST(doc._id, 'String') AS _id, + CAST(doc.order_id, 'String') AS order_id, + CAST(doc.customer_id, 'Int64') AS customer_id, + CAST(doc.status, 'String') AS status, + CAST(doc.total_amount, 'Decimal64(2)') AS total_amount, + CAST(parseDateTime64BestEffortOrNull(doc.order_date, 3), 'DATETIME(3)') AS order_date, + doc.^shipping AS shipping_info, + doc.items, + _peerdb_version, + _peerdb_synced_at, + _peerdb_is_deleted +FROM t1; + +CREATE VIEW flattened_t1_final AS +SELECT * FROM flattened_t1 FINAL WHERE _peerdb_is_deleted = 0; +``` + +您现在可以按如下方式查询视图 `flattened_t1_final`: + +```sql +SELECT + customer_id, + sum(total_amount) +FROM flattened_t1_final +AND shipping_info.city = 'Seattle' +GROUP BY customer_id +ORDER BY customer_id DESC +LIMIT 10; +``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/quickstart.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/quickstart.md.hash new file mode 100644 index 00000000000..564bd501583 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/quickstart.md.hash @@ -0,0 +1 @@ +99f9f47142048b5d diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/remove_table.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/remove_table.md new file mode 100644 index 00000000000..a999bca64de --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/remove_table.md @@ -0,0 +1,27 @@ +--- +'title': '从 ClickPipe 中移除特定表' +'description': '从 ClickPipe 中移除特定表' +'sidebar_label': '移除表' +'slug': '/integrations/clickpipes/mongodb/removing_tables' +'doc_type': 'guide' +--- + +import Image from '@theme/IdealImage'; +import remove_table from '@site/static/images/integrations/data-ingestion/clickpipes/postgres/remove_table.png' + +在某些情况下,从 MongoDB ClickPipe 中排除特定的表是有意义的——例如,如果一个表不需要用于你的分析工作负载,跳过它可以减少 ClickHouse 中的存储和复制费用。 + +## 移除特定表的步骤 {#remove-tables-steps} + +第一步是从管道中移除该表。这可以通过以下步骤完成: + +1. [暂停](./pause_and_resume.md) 管道。 +2. 点击编辑表设置。 +3. 定位到你的表——这可以通过在搜索栏中搜索来完成。 +4. 通过点击选中的复选框取消选择该表。 +
+ + + +5. 点击更新。 +6. 更新成功后,在 **Metrics** 标签中状态将显示为 **Running**。该表将不再被此 ClickPipe 复制。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/remove_table.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/remove_table.md.hash new file mode 100644 index 00000000000..66e85668b01 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/remove_table.md.hash @@ -0,0 +1 @@ +f51b040490d2ead0 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/resync.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/resync.md new file mode 100644 index 00000000000..8139f0e5a0f --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/resync.md @@ -0,0 +1,43 @@ +--- +'title': '重新同步数据库 ClickPipe' +'description': '关于重新同步数据库 ClickPipe 的文档' +'slug': '/integrations/clickpipes/mongodb/resync' +'sidebar_label': '重新同步 ClickPipe' +'doc_type': 'guide' +--- + +import resync_button from '@site/static/images/integrations/data-ingestion/clickpipes/postgres/resync_button.png' +import Image from '@theme/IdealImage'; + +### Resync 的作用是什么? {#what-mongodb-resync-do} + +Resync 涉及以下操作按顺序进行: + +1. 现有的 ClickPipe 被删除,然后启动一个新的“resync” ClickPipe。因此,当您进行 resync 时,源表结构的变化将被捕获。 +2. resync ClickPipe 会创建(或替换)一组新的目标表,这些表的名称与原始表相同,但带有 `_resync` 后缀。 +3. 对 `_resync` 表执行初始加载。 +4. 然后,`_resync` 表与原始表进行交换。在交换之前,将软删除的行从原始表转移到 `_resync` 表。 + +原始 ClickPipe 的所有设置都在 resync ClickPipe 中保留。原始 ClickPipe 的统计信息在用户界面中被清除。 + +### Resync ClickPipe 的使用案例 {#use-cases-mongodb-resync} + +以下是几个场景: + +1. 您可能需要对源表进行重大模式更改,这会破坏现有的 ClickPipe,您需要重新启动。在进行更改后,您只需点击 Resync。 +2. 特别对于 ClickHouse,您可能需要更改目标表上的 ORDER BY 键。您可以 Resync 来将数据重新填充到具有正确排序键的新表中。 + +### Resync ClickPipe 指南 {#guide-mongodb-resync} + +1. 在数据源标签中,点击您希望重新同步的 MongoDB ClickPipe。 +2. 转到 **设置** 标签。 +3. 点击 **Resync** 按钮。 + + + +4. 确认的对话框应出现。再次点击 Resync。 +5. 转到 **指标** 标签。 +6. 等待管道的状态变为 **Setup** 或 **Snapshot**。 +7. 可以在 **表** 标签中的 **初始加载统计** 部分监控 resync 的初始加载情况。 +8. 一旦初始加载完成,管道将原子地将 `_resync` 表与原始表进行交换。在交换期间,状态将变为 **Resync**。 +9. 一旦交换完成,管道将进入 **Running** 状态,并在启用的情况下执行 CDC。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/resync.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/resync.md.hash new file mode 100644 index 00000000000..a6b729d47dc --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/resync.md.hash @@ -0,0 +1 @@ +38a581da52f57e44 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/source/atlas.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/source/atlas.md new file mode 100644 index 00000000000..0d5fc5fce07 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/source/atlas.md @@ -0,0 +1,59 @@ +--- +'sidebar_label': 'MongoDB Atlas' +'description': '逐步指南,介绍如何将 MongoDB Atlas 设置为 ClickPipes 的数据源' +'slug': '/integrations/clickpipes/mongodb/source/atlas' +'title': 'MongoDB Atlas 源设置指南' +'doc_type': 'guide' +--- + +import mongo_atlas_configuration from '@site/static/images/integrations/data-ingestion/clickpipes/mongodb/mongo-atlas-cluster-overview-configuration.png' +import mngo_atlas_additional_settings from '@site/static/images/integrations/data-ingestion/clickpipes/mongodb/mongo-atlas-expand-additional-settings.png' +import mongo_atlas_retention_hours from '@site/static/images/integrations/data-ingestion/clickpipes/mongodb/mongo-atlas-set-retention-hours.png' +import mongo_atlas_add_user from '@site/static/images/integrations/data-ingestion/clickpipes/mongodb/mongo-atlas-add-new-database-user.png' +import mongo_atlas_add_roles from '@site/static/images/integrations/data-ingestion/clickpipes/mongodb/mongo-atlas-database-user-privilege.png' +import mongo_atlas_restrict_access from '@site/static/images/integrations/data-ingestion/clickpipes/mongodb/mongo-atlas-restrict-access.png' +import Image from '@theme/IdealImage'; + + +# MongoDB Atlas 源设置指南 + +## 配置 oplog 保留时间 {#enable-oplog-retention} + +复制需要最低 24 小时的 oplog 保留时间。我们建议将 oplog 保留时间设置为 72 小时或更长时间,以确保在初始快照完成之前不会截断 oplog。通过用户界面设置 oplog 保留时间的步骤如下: + +1. 在 MongoDB Atlas 控制台中,导航到集群的 `Overview` 标签页,并点击 `Configuration` 标签页。 + + +2. 点击 `Additional Settings` 并向下滚动到 `More Configuration Options`。 + + +3. 点击 `More Configuration Options` 并将最小 oplog 窗口设置为 `72 hours` 或更长。 + + +4. 点击 `Review Changes` 进行审查,然后点击 `Apply Changes` 部署更改。 + +## 配置数据库用户 {#configure-database-user} + +登录到 MongoDB Atlas 控制台后,在左侧导航栏的 Security 标签下点击 `Database Access`。然后点击 “Add New Database User”。 + +ClickPipes 需要密码验证: + + + +ClickPipes 需要具有以下角色的用户: + +- `readAnyDatabase` +- `clusterMonitor` + +您可以在 `Specific Privileges` 部分找到这些角色: + + + +您可以进一步指定希望授予 ClickPipes 用户访问权限的集群(/实例): + + + +## 接下来会发生什么? {#whats-next} + +您现在可以 [创建您的 ClickPipe](../index.md),并开始从您的 MongoDB 实例向 ClickHouse Cloud 导入数据。 +请确保记下设置 MongoDB 实例时使用的连接详细信息,因为在创建 ClickPipe 的过程中将需要这些信息。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/source/atlas.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/source/atlas.md.hash new file mode 100644 index 00000000000..971f0ae94f8 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/source/atlas.md.hash @@ -0,0 +1 @@ +c3883a78727265aa diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/source/generic.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/source/generic.md new file mode 100644 index 00000000000..0c94c1184da --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/source/generic.md @@ -0,0 +1,60 @@ +--- +'sidebar_label': '通用 MongoDB' +'description': '将任何 MongoDB 实例设置为 ClickPipes 的数据源' +'slug': '/integrations/clickpipes/mongodb/source/generic' +'title': '通用 MongoDB 源设置指南' +'doc_type': 'guide' +--- + + +# 通用 MongoDB 源设置指南 + +:::info + +如果您使用的是 MongoDB Atlas,请参阅特定指南 [这里](./atlas)。 + +::: + +## 启用 oplog 保留 {#enable-oplog-retention} + +复制需要最少 24 小时的 oplog 保留。我们建议将 oplog 保留设置为 72 小时或更长,以确保在初始快照完成之前不会截断 oplog。 + +您可以通过在 MongoDB shell 中运行以下命令来检查当前的 oplog 保留(您必须具有 `clusterMonitor` 角色才能运行此命令): + +```javascript +db.getSiblingDB("admin").serverStatus().oplogTruncation.oplogMinRetentionHours +``` + +要将 oplog 保留设置为 72 小时,请作为管理员用户在副本集的每个节点上运行以下命令: + +```javascript +db.adminCommand({ + "replSetResizeOplog" : 1, + "minRetentionHours": 72 +}) +``` + +有关 `replSetResizeOplog` 命令和 oplog 保留的更多详细信息,请参阅 [MongoDB 文档](https://www.mongodb.com/docs/manual/reference/command/replSetResizeOplog/)。 + +## 配置数据库用户 {#configure-database-user} + +作为管理员用户连接到您的 MongoDB 实例,并执行以下命令以创建一个用于 MongoDB CDC ClickPipes 的用户: + +```javascript +db.getSiblingDB("admin").createUser({ + user: "clickpipes_user", + pwd: "some_secure_password", + roles: ["readAnyDatabase", "clusterMonitor"], +}) +``` + +:::note + +请确保将 `clickpipes_user` 和 `some_secure_password` 替换为您所需的用户名和密码。 + +::: + +## 接下来是什么? {#whats-next} + +现在您可以 [创建您的 ClickPipe](../index.md) 并开始将数据从您的 MongoDB 实例摄取到 ClickHouse Cloud。 +请确保记录您在设置 MongoDB 实例时使用的连接详细信息,因为在创建 ClickPipe 过程中您将需要它们。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/source/generic.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/source/generic.md.hash new file mode 100644 index 00000000000..113970a1ae6 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/source/generic.md.hash @@ -0,0 +1 @@ +6869908d5ee96c41 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/table_resync.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/table_resync.md new file mode 100644 index 00000000000..4c2869e060a --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/table_resync.md @@ -0,0 +1,27 @@ +--- +'title': '重新同步特定的表' +'description': '在 MongoDB ClickPipe 中重新同步特定的表' +'slug': '/integrations/clickpipes/mongodb/table_resync' +'sidebar_label': '重新同步表' +'doc_type': 'guide' +--- + + +# 重新同步特定表 {#resync-tables} + +在某些情况下,重新同步管道的特定表可能是有用的。一些示例用例可能是在 MongoDB 上进行重大架构更改,或者在 ClickHouse 上进行某些数据重新建模。 + +虽然通过点击按钮重新同步单个表仍在进行中,但本指南将分享如何在 MongoDB ClickPipe 中今天实现此目标的步骤。 + +### 1. 从管道中移除表 {#removing-table} + +可以按照 [表移除指南](./removing_tables) 进行操作。 + +### 2. 在 ClickHouse 上截断或删除表 {#truncate-drop-table} + +此步骤旨在避免在下一步中再次添加该表时出现数据重复。您可以通过前往 ClickHouse Cloud 中的 **SQL 控制台** 选项卡并运行查询来执行此操作。 +请注意,如果表已存在于 ClickHouse 并且不为空,我们会阻止表的添加。 + +### 3. 再次将表添加到 ClickPipe 中 {#add-table-again} + +可以按照 [表添加指南](./add_table) 进行操作。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/table_resync.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/table_resync.md.hash new file mode 100644 index 00000000000..805d5b16c84 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mongodb/table_resync.md.hash @@ -0,0 +1 @@ +25f60049cae24cc0 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/add_table.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/add_table.md new file mode 100644 index 00000000000..09b53f23a21 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/add_table.md @@ -0,0 +1,33 @@ +--- +'title': '将特定表添加到 ClickPipe' +'description': '描述将特定表添加到 ClickPipe 所需的步骤。' +'sidebar_label': '添加表' +'slug': '/integrations/clickpipes/mysql/add_table' +'show_title': false +'doc_type': 'guide' +--- + +import Image from '@theme/IdealImage'; +import add_table from '@site/static/images/integrations/data-ingestion/clickpipes/postgres/add_table.png' + + +# 将特定表添加到 ClickPipe + +在某些情况下,添加特定表到管道是非常有用的。随着您的事务或分析工作负载的扩展,这种需求变得越来越普遍。 + +## 将特定表添加到 ClickPipe 的步骤 {#add-tables-steps} + +可以通过以下步骤完成: +1. [暂停](./pause_and_resume.md)管道。 +2. 点击编辑表设置。 +3. 定位您的表 - 可以通过在搜索栏中搜索来完成此操作。 +4. 通过点击复选框选择表。 +
+ + +5. 点击更新。 +6. 更新成功后,管道的状态将依次为 `Setup`、`Snapshot` 和 `Running`。表的初始加载可以在 **Tables** 标签中跟踪。 + +:::info +现有表的 CDC 在新表快照完成后会自动恢复。 +::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/add_table.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/add_table.md.hash new file mode 100644 index 00000000000..e3c0061014e --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/add_table.md.hash @@ -0,0 +1 @@ +f71e6157bfa335f9 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/controlling_sync.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/controlling_sync.md new file mode 100644 index 00000000000..c4cf5b899ca --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/controlling_sync.md @@ -0,0 +1,60 @@ +--- +'title': '控制 MySQL ClickPipe 的同步' +'description': '文档用于控制 MySQL ClickPipe 的同步' +'slug': '/integrations/clickpipes/mysql/sync_control' +'sidebar_label': '控制同步' +'doc_type': 'guide' +--- + +import edit_sync_button from '@site/static/images/integrations/data-ingestion/clickpipes/postgres/edit_sync_button.png' +import create_sync_settings from '@site/static/images/integrations/data-ingestion/clickpipes/postgres/create_sync_settings.png' +import edit_sync_settings from '@site/static/images/integrations/data-ingestion/clickpipes/postgres/sync_settings_edit.png' +import cdc_syncs from '@site/static/images/integrations/data-ingestion/clickpipes/postgres/cdc_syncs.png' +import Image from '@theme/IdealImage'; + +这份文档描述了如何控制MySQL ClickPipe的同步,当ClickPipe处于**CDC(运行中)模式**时。 + +## 概述 {#overview} + +数据库ClickPipes的架构由两个并行进程组成 - 从源数据库提取数据和将数据推送到目标数据库。提取过程由一个同步配置控制,该配置定义了数据应多久提取一次以及每次应提取多少数据。这里的“每次”指的是一个批次 - 因为ClickPipe是以批次的方式提取和推送数据。 + +有两种主要方式可以控制MySQL ClickPipe的同步。ClickPipe将在以下设置之一启动推送。 + +### 同步间隔 {#interval} + +管道的同步间隔是ClickPipe从源数据库提取记录的时间(以秒为单位)。推送到ClickHouse的时间不包括在此间隔内。 + +默认值为**1分钟**。 +同步间隔可以设置为任何正整数值,但建议保持在10秒以上。 + +### 提取批次大小 {#batch-size} + +提取批次大小是ClickPipe在一个批次中从源数据库提取的记录数量。记录指的是对管道中所涉及表的插入、更新和删除操作。 + +默认值为**100,000**条记录。 +安全的最大值是1000万。 + +### 一个例外:源上长事务 {#transactions} + +当源数据库上运行一个事务时,ClickPipe会等待直到收到该事务的COMMIT后才会继续。这会**覆盖**同步间隔和提取批次大小的设置。 + +### 配置同步设置 {#configuring} + +您可以在创建ClickPipe时或编辑现有的ClickPipe时设置同步间隔和提取批次大小。 +在创建ClickPipe时,可以在创建向导的第二步看到它,如下所示: + + + +在编辑现有ClickPipe时,您可以转到管道的**设置**选项卡,暂停管道,然后在此处点击**配置**: + + + +这将打开一个飞出窗口,显示同步设置,您可以在这里更改同步间隔和提取批次大小: + + + +### 监控同步控制行为 {#monitoring} + +您可以在ClickPipe的**指标**选项卡中的**CDC Syncs**表中查看每个批次所需的时间。请注意,这里的持续时间包括推送时间,如果没有行进入,ClickPipe会等待,等待时间也包括在持续时间内。 + + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/controlling_sync.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/controlling_sync.md.hash new file mode 100644 index 00000000000..a00037e6d1b --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/controlling_sync.md.hash @@ -0,0 +1 @@ +c4c374703dde2931 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/datatypes.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/datatypes.md index a1f5ac3f4ba..9181e2c8245 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/datatypes.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/datatypes.md @@ -1,31 +1,32 @@ --- -'title': 'ClickPipes for MySQL: 支持的数据类型' +'title': '支持的数据类型' 'slug': '/integrations/clickpipes/mysql/datatypes' -'description': '页面描述 MySQL ClickPipe 数据类型从 MySQL 到 ClickHouse 的映射' +'description': '页面描述了 MySQL ClickPipe 数据类型从 MySQL 到 ClickHouse 的映射' +'doc_type': 'reference' --- -以下是 MySQL ClickPipe 支持的数据类型映射: +这是 MySQL ClickPipe 支持的数据类型映射: -| MySQL 类型 | ClickHouse 类型 | 备注 | -| -------------------------------------------------------------------------- | ------------------------------------------ | -------------------------------------------------------------------------------------- | -| Enum | LowCardinality(String) | | -| Set | String | | -| Decimal | Decimal | | -| TinyInt | Int8 | 支持无符号。 | -| SmallInt | Int16 | 支持无符号。 | -| MediumInt, Int | Int32 | 支持无符号。 | -| BigInt | Int64 | 支持无符号。 | -| Year | Int16 | | -| TinyText, Text, MediumText, LongText | String | | -| TinyBlob, Blob, MediumBlob, LongBlob | String | | -| Char, Varchar | String | | -| Binary, VarBinary | String | | -| TinyInt(1) | Bool | | -| JSON | String | MySQL 专用;MariaDB 中的 `json` 只是 `text` 的别名,并带有约束。 | -| Geometry & Geometry Types | String | WKT(已知文本)。WKT 可能会有小的精度损失。 | -| Vector | Array(Float32) | MySQL 专用;MariaDB 很快会添加支持。 | -| Float | Float32 | 由于文本协议,ClickHouse 的精度可能与 MySQL 在初始加载时有所不同。 | -| Double | Float64 | 由于文本协议,ClickHouse 的精度可能与 MySQL 在初始加载时有所不同。 | -| Date | Date32 | | -| Time | DateTime64(6) | 日期部分为 Unix 纪元。 | -| Datetime, Timestamp | DateTime64(6) | | +| MySQL 类型 | ClickHouse 类型 | 备注 | +| --------------------------| -----------------------| -------------------------------------------------------------------------------------- | +| Enum | LowCardinality(String) || +| Set | String || +| Decimal | Decimal || +| TinyInt | Int8 | 支持无符号。| +| SmallInt | Int16 | 支持无符号。| +| MediumInt, Int | Int32 | 支持无符号。| +| BigInt | Int64 | 支持无符号。| +| Year | Int16 || +| TinyText, Text, MediumText, LongText | String || +| TinyBlob, Blob, MediumBlob, LongBlob | String || +| Char, Varchar | String || +| Binary, VarBinary | String || +| TinyInt(1) | Bool || +| JSON | String | 仅限 MySQL;MariaDB 的 `json` 只是 `text` 的别名,并带有约束。 | +| Geometry & Geometry Types | String | WKT (已知文本)。WKT 可能会有小的精度损失。 | +| Vector | Array(Float32) | 仅限 MySQL;MariaDB 即将添加支持。 | +| Float | Float32 | 由于文本协议,ClickHouse 的精度可能与 MySQL 在初始加载时有所不同。| +| Double | Float64 | 由于文本协议,ClickHouse 的精度可能与 MySQL 在初始加载时有所不同。| +| Date | Date32 | 00 日/月 映射到 01。| +| Time | DateTime64(6) | 从 unix 纪元开始的时间偏移。| +| Datetime, Timestamp | DateTime64(6) | 00 日/月 映射到 01。| diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/datatypes.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/datatypes.md.hash index 7f86e11c7c4..40fd5009bad 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/datatypes.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/datatypes.md.hash @@ -1 +1 @@ -4e5f7e6b08fd9969 +a97bf926bf690798 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/faq.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/faq.md index fbec0a9f9fa..f6f2e09ce7e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/faq.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/faq.md @@ -1,35 +1,49 @@ --- -'sidebar_label': '常见问题' -'description': '关于 MySQL 的 ClickPipes 的常见问题。' +'sidebar_label': '常见问题解答' +'description': '关于 ClickPipes for MySQL 的常见问题。' 'slug': '/integrations/clickpipes/mysql/faq' 'sidebar_position': 2 -'title': 'MySQL 的 ClickPipes 常见问题' +'title': 'ClickPipes for MySQL 常见问题解答' +'doc_type': 'reference' --- -# ClickPipes for MySQL 常见问题 +# ClickPipes for MySQL 常见问题解答 -### MySQL ClickPipe 是否支持 MariaDB? {#does-the-clickpipe-support-mariadb} +### MySQL ClickPipe 支持 MariaDB 吗? {#does-the-clickpipe-support-mariadb} 是的,MySQL ClickPipe 支持 MariaDB 10.0 及以上版本。其配置与 MySQL 非常相似,默认使用 GTID 复制。 -### MySQL ClickPipe 是否支持 PlanetScale、Vitess 或 TiDB? {#does-the-clickpipe-support-planetscale-vitess} +### MySQL ClickPipe 支持 PlanetScale、Vitess 或 TiDB 吗? {#does-the-clickpipe-support-planetscale-vitess} 不,这些不支持 MySQL 的 binlog API。 -### 复制是如何管理的? {#how-is-replication-managed} -我们支持 `GTID` 和 `FilePos` 复制。与 Postgres 不同的是,没有槽位来管理偏移量。相反,您必须配置 MySQL 服务器以具有足够的 binlog 保留期。如果我们在 binlog 中的偏移量无效 *(例如,镜像暂停太长时间,或者在使用 `FilePos` 复制时发生数据库故障转移)*,那么您需要重新同步管道。请确保根据目标表优化物化视图,因为低效的查询会导致数据摄取缓慢,进而落后于保留期。 +### 复制是如何管理的? {#how-is-replication-managed} +我们支持 `GTID` 和 `FilePos` 复制。与 Postgres 不同,没有槽来管理偏移量。相反,您必须配置 MySQL 服务器以具有足够的 binlog 保留时间。如果我们在 binlog 中的偏移量失效 *(例如,镜像暂停时间过长,或在使用 `FilePos` 复制时发生数据库故障转移)*,那么您将需要重新同步管道。确保根据目标表优化物化视图,因为低效的查询可能会减慢数据注入,导致超出保留期。 -不活动的数据库也可能轮换日志文件,而不允许 ClickPipes 进展到更新的偏移量。您可能需要设置一个心跳表,并定期更新。 +不活动的数据库也可能在未允许 ClickPipes 进展到更新的偏移量的情况下旋转日志文件。您可能需要设置一个带有定期更新的心跳表。 -### 为什么我在连接 MySQL 时遇到 TLS 证书验证错误? {#tls-certificate-validation-error} +在初始加载开始时,我们记录要启动的 binlog 偏移量。此偏移量在初始加载完成时仍然必须有效,以便 CDC 继续进展。如果您正在注入大量数据,请确保配置适当的 binlog 保留时间。在设置表时,您可以通过在高级设置中配置 *为初始加载使用自定义分区键* 来加快初始加载,以便我们可以并行加载单个表。 -在连接 MySQL 时,您可能会遇到诸如 `x509: certificate is not valid for any names` 或 `x509: certificate signed by unknown authority` 的证书错误。这是因为 ClickPipes 默认启用了 TLS 加密。 +### 为什么连接到 MySQL 时会出现 TLS 证书验证错误? {#tls-certificate-validation-error} -您有几种选项来解决这些问题: +连接到 MySQL 时,您可能会遇到诸如 `x509: certificate is not valid for any names` 或 `x509: certificate signed by unknown authority` 的证书错误。这是因为 ClickPipes 默认启用 TLS 加密。 -1. **设置 TLS Host 字段** - 当您的连接中的主机名与证书不同时(在通过 Endpoint Service 的 AWS PrivateLink 中常见)。将“TLS Host (可选)”设置为与证书的通用名称 (CN) 或主题备用名称 (SAN) 匹配。 +您有几个选项可以解决这些问题: -2. **上传您的根 CA** - 针对使用内部证书颁发机构的 MySQL 服务器或在默认实例 CA 配置下的 Google Cloud SQL。有关如何访问 Google Cloud SQL 证书的更多信息,请参见 [这一部分](https://clickhouse.com/docs/integrations/clickpipes/mysql/source/gcp#download-root-ca-certificate-gcp-mysql)。 +1. **设置 TLS 主机字段** - 当您的连接中的主机名与证书不同时(在使用 AWS PrivateLink 通过 Endpoint Service 时常见)。将“TLS 主机(可选)”设置为与证书的公用名 (CN) 或主题备用名称 (SAN) 匹配。 -3. **配置服务器证书** - 更新服务器的 SSL 证书以包含所有连接主机名,并使用受信任的证书颁发机构。 +2. **上传您的根 CA** - 对于使用内部证书颁发机构或 Google Cloud SQL 在默认每实例 CA 配置中的 MySQL 服务器。有关如何访问 Google Cloud SQL 证书的更多信息,请参见 [此部分](https://clickhouse.com/docs/integrations/clickpipes/mysql/source/gcp#download-root-ca-certificate-gcp-mysql)。 -4. **跳过证书验证** - 对于自托管的 MySQL 或 MariaDB,它们的默认配置提供我们无法验证的自签名证书 ([MySQL](https://dev.mysql.com/doc/refman/8.4/en/creating-ssl-rsa-files-using-mysql.html#creating-ssl-rsa-files-using-mysql-automatic), [MariaDB](https://mariadb.com/kb/en/securing-connections-for-client-and-server/#enabling-tls-for-mariadb-server))。依赖此证书在传输中加密数据,但存在服务器冒充的风险。我们建议在生产环境中使用正式签名的证书,但此选项对于在一次性实例上测试或连接到遗留基础设施时非常有用。 +3. **配置服务器证书** - 更新您的服务器 SSL 证书以包含所有连接主机名并使用受信任的证书颁发机构。 + +4. **跳过证书验证** - 对于自托管的 MySQL 或 MariaDB,其默认配置提供无法验证的自签名证书 ([MySQL](https://dev.mysql.com/doc/refman/8.4/en/creating-ssl-rsa-files-using-mysql.html#creating-ssl-rsa-files-using-mysql-automatic), [MariaDB](https://mariadb.com/kb/en/securing-connections-for-client-and-server/#enabling-tls-for-mariadb-server))。依赖此证书可以加密传输中的数据,但存在服务器冒充的风险。我们建议在生产环境中使用妥善签署的证书,但在一次性实例上进行测试或连接到遗留基础设施时,此选项非常有用。 + +### 你们支持架构变更吗? {#do-you-support-schema-changes} + +有关更多信息,请参阅 [ClickPipes for MySQL: 架构变更传播支持](./schema-changes) 页面。 + +### 你们支持复制 MySQL 外键级联删除 `ON DELETE CASCADE` 吗? {#support-on-delete-cascade} + +由于 MySQL [处理级联删除的方式](https://dev.mysql.com/doc/refman/8.0/en/innodb-and-mysql-replication.html),因此不将其写入 binlog。因此,ClickPipes(或任何 CDC 工具)无法复制它们。这可能导致数据不一致。建议使用触发器来支持级联删除。 + +### 为什么我无法复制带有点的表? {#replicate-table-dot} +PeerDB 目前存在一个限制,源表标识符中的点 - 即架构名称或表名称 - 不支持复制,因为 PeerDB 无法分辨在这种情况下什么是架构,什么是表,因为它是按点分割的。我们正在努力支持分别输入架构和表,以解决此限制。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/faq.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/faq.md.hash index e76823b8959..c32fd7c8445 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/faq.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/faq.md.hash @@ -1 +1 @@ -3f5adb66cf998882 +074c1fd9b6cdac61 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/index.md index 709e5520036..6f3bbbe27f3 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/index.md @@ -1,8 +1,9 @@ --- -'sidebar_label': 'ClickPipes for MySQL' -'description': '描述如何无缝连接你的 MySQL 与 ClickHouse Cloud。' +'sidebar_label': '从 MySQL 到 ClickHouse 进行数据摄取' +'description': '描述如何无缝连接您的 MySQL 到 ClickHouse Cloud。' 'slug': '/integrations/clickpipes/mysql' -'title': '从 MySQL 向 ClickHouse (使用 CDC) 导入数据' +'title': '从 MySQL 到 ClickHouse 进行数据摄取 (使用 CDC)' +'doc_type': 'guide' --- import BetaBadge from '@theme/badges/BetaBadge'; @@ -16,19 +17,19 @@ import ch_permissions from '@site/static/images/integrations/data-ingestion/clic import Image from '@theme/IdealImage'; -# 从 MySQL 向 ClickHouse 进行数据摄取(CDC) +# 从 MySQL 向 ClickHouse 中摄取数据 (使用 CDC) :::info -目前,通过 ClickPipes 从 MySQL 向 ClickHouse Cloud 进行数据摄取处于私人预览阶段。 +通过 ClickPipes 将数据从 MySQL 摄取到 ClickHouse Cloud 当前处于公开测试阶段。 ::: -您可以使用 ClickPipes 将源 MySQL 数据库中的数据摄取到 ClickHouse Cloud。源 MySQL 数据库可以托管在本地或云中。 +您可以使用 ClickPipes 将数据从源 MySQL 数据库摄取到 ClickHouse Cloud。源 MySQL 数据库可以托管在本地或使用 Amazon RDS、Google Cloud SQL 等服务在云中。 ## 前提条件 {#prerequisites} -要开始,您首先需要确保您的 MySQL 数据库已正确设置。根据您的源 MySQL 实例,您可以遵循以下任一指南: +要开始,您首先需要确保您的 MySQL 数据库已正确配置为 binlog 复制。配置步骤取决于您部署 MySQL 的方式,因此请遵循以下相关指南: 1. [Amazon RDS MySQL](./mysql/source/rds) @@ -36,20 +37,24 @@ import Image from '@theme/IdealImage'; 3. [Cloud SQL for MySQL](./mysql/source/gcp) -4. [Amazon RDS MariaDB](./mysql/source/rds_maria) +4. [通用 MySQL](./mysql/source/generic) -一旦您的源 MySQL 数据库设置完成,您可以继续创建您的 ClickPipe。 +5. [Amazon RDS MariaDB](./mysql/source/rds_maria) -## 创建 ClickPipe {#creating-your-clickpipe} +6. [通用 MariaDB](./mysql/source/generic_maria) -确保您已登录到您的 ClickHouse Cloud 帐户。如果您还没有帐户,您可以在 [这里](https://cloud.clickhouse.com/) 注册。 +一旦您的源 MySQL 数据库设置完成,您可以继续创建 ClickPipe。 + +## 创建你的 ClickPipe {#create-your-clickpipe} + +确保您已登录到您的 ClickHouse Cloud 账户。如果您还没有账户,可以 [在这里注册](https://cloud.clickhouse.com/)。 [//]: # ( TODO update image here) 1. 在 ClickHouse Cloud 控制台中,导航到您的 ClickHouse Cloud 服务。 -2. 在左侧菜单中选择 `Data Sources` 按钮,然后点击 "Set up a ClickPipe" +2. 选择左侧菜单中的 `数据源` 按钮,然后点击 "设置 ClickPipe" @@ -57,61 +62,63 @@ import Image from '@theme/IdealImage'; -### 添加源 MySQL 数据库连接 {#adding-your-source-mysql-database-connection} +### 添加源 MySQL 数据库连接 {#add-your-source-mysql-database-connection} 4. 填写您在前提条件步骤中配置的源 MySQL 数据库的连接详细信息。 :::info - - 在开始添加连接详细信息之前,请确保您已在防火墙规则中列入 ClickPipes IP 地址的白名单。您可以在以下页面找到 [ClickPipes IP 地址列表](../index.md#list-of-static-ips)。 - 有关更多信息,请参考本页顶部链接的源 MySQL 设置指南 [prerequisites](#prerequisites)。 - + 在您开始添加连接详细信息之前,请确保已在防火墙规则中将 ClickPipes IP 地址列入白名单。在以下页面中,您可以找到 [ClickPipes IP 地址列表](../index.md#list-of-static-ips)。 + 有关更多信息,请参考此页面顶部链接的源 MySQL 设置指南 [(前提条件)](#prerequisites)。 ::: -#### (可选) 设置 SSH 隧道 {#optional-setting-up-ssh-tunneling} +#### (可选)设置 SSH 隧道 {#optional-set-up-ssh-tunneling} -如果您的源 MySQL 数据库不可公开访问,您可以指定 SSH 隧道详细信息。 +如果您的源 MySQL 数据库无法公开访问,您可以指定 SSH 隧道详细信息。 -1. 启用 "Use SSH Tunnelling" 切换开关。 +1. 启用 "使用 SSH 隧道" 切换。 2. 填写 SSH 连接详细信息。 -3. 若要使用基于密钥的身份验证,请点击 "Revoke and generate key pair" 生成新的密钥对,并将生成的公钥复制到您的 SSH 服务器下的 `~/.ssh/authorized_keys`。 -4. 点击 "Verify Connection" 验证连接。 +3. 若要使用基于密钥的身份验证,单击 "撤销并生成密钥对" 以生成新的密钥对,并将生成的公钥复制到您的 SSH 服务器下的 `~/.ssh/authorized_keys` 文件中。 +4. 点击 "验证连接" 以验证连接。 :::note - -请确保在防火墙规则中为 SSH 突破主机列入 [ClickPipes IP 地址](../clickpipes#list-of-static-ips) 的白名单,以便 ClickPipes 可以建立 SSH 隧道。 - +确保在防火墙规则中将 [ClickPipes IP 地址](../clickpipes#list-of-static-ips) 列入白名单,以便 SSH 路由主机可以建立 SSH 隧道。 ::: -填写连接详细信息后,点击 "Next"。 +填写连接详细信息后,单击 `下一步`。 #### 配置高级设置 {#advanced-settings} -如果需要,您可以配置高级设置。以下是每个设置的简要描述: +如果需要,您可以配置高级设置。以下是每个设置的简要说明: -- **同步间隔**:这是 ClickPipes 查询源数据库以获取更改的频率。对于对成本敏感的用户,我们建议将其保持在较高值(超过 `3600`)。 -- **初始加载的并行线程**:用于获取初始快照的并行工作者数量。当您的表数量较大时,这非常有用,您可以控制用于获取初始快照的并行工作者数量。此设置是按表设置的。 -- **拉取批处理大小**:一次批量拉取的行数。这是一个最佳努力设置,并可能在所有情况下不被尊重。 -- **每个分区的快照行数**:在初始快照期间在每个分区中获取的行数。当您的表中有大量行时,这很有用,您可以控制在每个分区中获取的行数。 -- **并行快照的表数量**:在初始快照期间并行获取的表数量。当您的表数量较大时,这很有用,您可以控制并行获取的表数。 +- **同步间隔**:这是 ClickPipes 轮询源数据库以获取更改的间隔。对于成本敏感的用户,我们建议将其保持在较高值(超过 `3600`)。 +- **初始加载的并行线程**:这是用于获取初始快照的并行工作者数量。当您有大量表时,这很有用,您可以控制获取初始快照所用的并行工作者数量。此设置是每个表的。 +- **拉取批量大小**:在单个批次中要获取的行数。这是一个最佳努力设置,可能在所有情况下都无法得到遵守。 +- **每个分区的快照行数**:在初始快照时每个分区将获取的行数。当您在表中有大量行并希望控制在每个分区中获取的行数时,这非常有用。 +- **并行快照表的数量**:在初始快照期间将并行获取的表数量。当您有大量表并希望控制并行获取的表数量时,这很有用。 -### 配置表 {#configuring-the-tables} +### 配置表 {#configure-the-tables} -5. 在此选择 ClickPipe 的目标数据库。您可以选择现有的数据库或创建一个新数据库。 +5. 在这里,您可以选择 ClickPipe 的目标数据库。您可以选择现有数据库或创建新数据库。 -6. 您可以选择要从源 MySQL 数据库中复制的表。在选择表时,您还可以选择在目标 ClickHouse 数据库中重命名表并排除特定列。 +6. 您可以选择要从源 MySQL 数据库复制的表。在选择表时,您还可以选择在目标 ClickHouse 数据库中重命名表以及排除特定列。 ### 审核权限并启动 ClickPipe {#review-permissions-and-start-the-clickpipe} -7. 从权限下拉菜单中选择 "Full access" 角色,并点击 "Complete Setup"。 +7. 从权限下拉菜单中选择 "完全访问" 角色,然后点击 "完成设置"。 -最后,请参考 ["ClickPipes for MySQL FAQ"](/integrations/clickpipes/mysql/faq) 页面以获取有关常见问题及其解决方法的更多信息。 +最后,请参考 ["ClickPipes for MySQL FAQ"](/integrations/clickpipes/mysql/faq) 页面以获取关于常见问题和解决方案的更多信息。 + +## 接下来做什么? {#whats-next} + +[//]: # "TODO Write a MySQL-specific migration guide and best practices similar to the existing one for PostgreSQL. The current migration guide points to the MySQL table engine, which is not ideal." + +一旦您设置了 ClickPipe 从 MySQL 向 ClickHouse Cloud 复制数据,您可以专注于如何查询和建模您的数据以获得最佳性能。有关 MySQL CDC 和故障排除的常见问题,请参见 [MySQL FAQs 页面](/integrations/data-ingestion/clickpipes/mysql/faq.md)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/index.md.hash index 4e37eb87f20..2f543a6c9d7 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/index.md.hash @@ -1 +1 @@ -f283c3bb4c6b952d +12a9355b1a5ded17 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/lifecycle.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/lifecycle.md new file mode 100644 index 00000000000..08bdb48826a --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/lifecycle.md @@ -0,0 +1,65 @@ +--- +'sidebar_label': 'MySQL ClickPipe 的生命周期' +'description': '各种管道状态及其含义' +'slug': '/integrations/clickpipes/mysql/lifecycle' +'title': 'MySQL ClickPipe 的生命周期' +'doc_type': 'guide' +--- + + +# MySQL ClickPipe 的生命周期 {#lifecycle} + +这是关于 MySQL ClickPipe 各个阶段、不同状态及其含义的文档。请注意,这同样适用于 MariaDB。 + +## 供应 {#provisioning} + +当你点击创建 ClickPipe 按钮时,ClickPipe 会在 `Provisioning` 状态下创建。供应过程是在这一阶段,我们为服务启动运行 ClickPipes 的基础设施,并为管道注册一些初始元数据。由于在一个服务中,ClickPipes 的计算是共享的,因此你的第二个 ClickPipe 会比第一个创建得更快,因为基础设施已经就位。 + +## 设置 {#setup} + +管道供应完成后,进入 `Setup` 状态。在这一状态下,我们创建目标 ClickHouse 表。同时,我们还会在这里获取并记录源表的表定义。 + +## 快照 {#snapshot} + +完成设置后,我们进入 `Snapshot` 状态(除非是仅 CDC 管道,这种情况下会过渡到 `Running` 状态)。`Snapshot`、`Initial Snapshot` 和 `Initial Load`(更常见)是可以互换的术语。在此状态下,我们对源 MySQL 表进行快照并将其加载到 ClickHouse 中。二进制日志的保留设置应考虑初始加载时间。有关初始加载的更多信息,请参见 [并行初始加载文档](./parallel_initial_load)。当触发重新同步或向已有管道中添加新表时,管道也会进入 `Snapshot` 状态。 + +## 运行 {#running} + +一旦初始加载完成,管道进入 `Running` 状态(除非是仅快照管道,这种情况下会过渡到 `Completed` 状态)。在此状态下,管道开始 `Change-Data Capture`(变更数据捕获)。我们开始读取源数据库的二进制日志,并将数据批量同步到 ClickHouse 中。有关控制 CDC 的信息,请参见 [控制 CDC 文档](./sync_control)。 + +## 暂停 {#paused} + +一旦管道处于 `Running` 状态,你可以暂停它。这将停止 CDC 过程,管道将进入 `Paused` 状态。在此状态下,源数据库不会再拉取新数据,但 ClickHouse 中的现有数据保持不变。你可以从这个状态恢复管道。 + +## 暂停中 {#pausing} + +:::note +此状态即将推出。如果你正在使用我们的 [OpenAPI](https://clickhouse.com/docs/cloud/manage/openapi),请考虑现在添加对它的支持,以确保在发布时你的集成继续正常工作。 +::: +当你点击暂停按钮时,管道进入 `Pausing` 状态。这是一个临时状态,我们正在停止 CDC 过程。一旦 CDC 过程完全停止,管道将进入 `Paused` 状态。 + +## 修改 {#modifying} +:::note +此状态即将推出。如果你正在使用我们的 [OpenAPI](https://clickhouse.com/docs/cloud/manage/openapi),请考虑现在添加对它的支持,以确保在发布时你的集成继续正常工作。 +::: +当前,这表示管道正在移除表的过程中。 + +## 重新同步 {#resync} +:::note +此状态即将推出。如果你正在使用我们的 [OpenAPI](https://clickhouse.com/docs/cloud/manage/openapi),请考虑现在添加对它的支持,以确保在发布时你的集成继续正常工作。 +::: +此状态表示管道正在执行重新同步,它正在进行 _resync 表与原表的原子交换。有关重新同步的更多信息,请参见 [重新同步文档](./resync)。 + +## 完成 {#completed} + +此状态适用于仅快照管道,表示快照已完成,并且没有更多工作要做。 + +## 失败 {#failed} + +如果管道发生不可恢复的错误,它将进入 `Failed` 状态。你可以联系支持或 [重新同步](./resync) 你的管道以从此状态恢复。 + +## 降级 {#degraded} + +:::note +此状态即将推出。如果你正在使用我们的 [OpenAPI](https://clickhouse.com/docs/cloud/manage/openapi),请考虑现在添加对它的支持,以确保在发布时你的集成继续正常工作。 +::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/lifecycle.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/lifecycle.md.hash new file mode 100644 index 00000000000..5061054e4ad --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/lifecycle.md.hash @@ -0,0 +1 @@ +cf31a9f2d89e0024 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/parallel_initial_load.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/parallel_initial_load.md new file mode 100644 index 00000000000..a0fcbff5a31 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/parallel_initial_load.md @@ -0,0 +1,51 @@ +--- +'title': 'MySQL ClickPipe 中的并行快照' +'description': '文档解释 MySQL ClickPipe 中的并行快照' +'slug': '/integrations/clickpipes/mysql/parallel_initial_load' +'sidebar_label': '并行快照的工作原理' +'doc_type': 'guide' +--- + +import snapshot_params from '@site/static/images/integrations/data-ingestion/clickpipes/mysql/snapshot_params.png' +import partition_key from '@site/static/images/integrations/data-ingestion/clickpipes/mysql/partition_key.png' +import Image from '@theme/IdealImage'; + +这份文档解释了 MySQL ClickPipe 中的并行快照/初始加载工作原理,并介绍了可以用于控制它的快照参数。 + +## 概述 {#overview-mysql-snapshot} + +初始加载是 CDC ClickPipe 的第一阶段,在此阶段,ClickPipe 会将源数据库中表的历史数据同步到 ClickHouse,然后再开始 CDC。很多时候,开发人员会以单线程的方式进行。然而,MySQL ClickPipe 可以并行化该过程,这可以显著加快初始加载速度。 + +### 分区键列 {#key-mysql-snapshot} + +一旦我们启用了功能标志,您应该在 ClickPipe 表选择器中看到以下设置(在创建和编辑 ClickPipe 时): + + +MySQL ClickPipe 使用源表上的一个列来逻辑上对源表进行分区。这个列称为 **分区键列**。它用于将源表划分为多个分区,然后 ClickPipe 可以并行处理这些分区。 + +:::warning +分区键列必须在源表中被索引,以便获得良好的性能提升。可以通过在 MySQL 中运行 `SHOW INDEX FROM ` 来查看。 +::: + +### 逻辑分区 {#logical-partitioning-mysql-snapshot} + +让我们来讨论以下设置: + + + +#### 每个分区的快照行数 {#numrows-mysql-snapshot} +此设置控制构成一个分区的行数。ClickPipe 将以此大小的块读取源表,并根据设置的初始加载并行处理这些块。默认值是每个分区 100,000 行。 + +#### 初始加载并行度 {#parallelism-mysql-snapshot} +此设置控制并行处理多少个分区。默认值为 4,这意味着 ClickPipe 将并行读取源表的 4 个分区。可以增加此值以加快初始加载,但建议根据源实例规格将其保持在合理的值,以避免对源数据库造成过大压力。ClickPipe 将根据源表的大小和每个分区的行数自动调整分区数量。 + +#### 并行快照中的表数量 {#tables-parallel-mysql-snapshot} +此设置与并行快照没有直接关系,但它控制在初始加载过程中并行处理多少个表。默认值为 1。请注意,这是在分区并行性基础之上的,因此如果您有 4 个分区和 2 个表,则 ClickPipe 将并行读取 8 个分区。 + +### 监控 MySQL 中的并行快照 {#monitoring-parallel-mysql-snapshot} +您可以在 MySQL 中运行 **SHOW processlist** 来查看并行快照的实际情况。ClickPipe 会创建多个连接到源数据库,每个连接读取源表的不同分区。如果您看到具有不同范围的 **SELECT** 查询,这意味着 ClickPipe 正在读取源表。您还可以在这里看到 COUNT(*) 和分区查询。 + +### 限制 {#limitations-parallel-mysql-snapshot} +- 快照参数在管道创建后不能被编辑。如果您想更改它们,则必须创建一个新的 ClickPipe。 +- 在现有 ClickPipe 中添加表时,您不能更改快照参数。ClickPipe 将使用现有参数处理新表。 +- 分区键列不应包含 `NULL`,因为它们会被分区逻辑跳过。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/parallel_initial_load.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/parallel_initial_load.md.hash new file mode 100644 index 00000000000..6ed044e1111 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/parallel_initial_load.md.hash @@ -0,0 +1 @@ +62a727aca901c648 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/pause_and_resume.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/pause_and_resume.md new file mode 100644 index 00000000000..67a4ad47d43 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/pause_and_resume.md @@ -0,0 +1,47 @@ +--- +'title': '暂停和恢复 MySQL ClickPipe' +'description': '暂停和恢复 MySQL ClickPipe' +'sidebar_label': '暂停表' +'slug': '/integrations/clickpipes/mysql/pause_and_resume' +'doc_type': 'guide' +--- + +import Image from '@theme/IdealImage'; +import pause_button from '@site/static/images/integrations/data-ingestion/clickpipes/postgres/pause_button.png' +import pause_dialog from '@site/static/images/integrations/data-ingestion/clickpipes/postgres/pause_dialog.png' +import pause_status from '@site/static/images/integrations/data-ingestion/clickpipes/postgres/pause_status.png' +import resume_button from '@site/static/images/integrations/data-ingestion/clickpipes/postgres/resume_button.png' +import resume_dialog from '@site/static/images/integrations/data-ingestion/clickpipes/postgres/resume_dialog.png' + +在某些情况下,暂停 MySQL ClickPipe 会很有用。例如,您可能希望对静态状态下的现有数据进行一些分析。或者,您可能正在对 MySQL 进行升级。以下是如何暂停和恢复 MySQL ClickPipe 的步骤。 + +## 暂停 MySQL ClickPipe 的步骤 {#pause-clickpipe-steps} + +1. 在数据源选项卡中,点击您希望暂停的 MySQL ClickPipe。 +2. 进入 **设置** 选项卡。 +3. 点击 **暂停** 按钮。 + + + +4. 应该会出现一个确认对话框。再次点击暂停。 + + + +4. 进入 **指标** 选项卡。 +5. 在大约 5 秒后(以及页面刷新时),管道的状态应为 **已暂停**。 + + + +## 恢复 MySQL ClickPipe 的步骤 {#resume-clickpipe-steps} +1. 在数据源选项卡中,点击您希望恢复的 MySQL ClickPipe。镜像的初始状态应为 **已暂停**。 +2. 进入 **设置** 选项卡。 +3. 点击 **恢复** 按钮。 + + + +4. 应该会出现一个确认对话框。再次点击恢复。 + + + +5. 进入 **指标** 选项卡。 +6. 在大约 5 秒后(以及页面刷新时),管道的状态应为 **运行中**。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/pause_and_resume.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/pause_and_resume.md.hash new file mode 100644 index 00000000000..9e725153110 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/pause_and_resume.md.hash @@ -0,0 +1 @@ +f83d6f4c014c837d diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/remove_table.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/remove_table.md new file mode 100644 index 00000000000..364a30b86a2 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/remove_table.md @@ -0,0 +1,27 @@ +--- +'title': '从 ClickPipe 中移除特定表' +'description': '从 ClickPipe 中移除特定表' +'sidebar_label': '移除表' +'slug': '/integrations/clickpipes/mysql/removing_tables' +'doc_type': 'guide' +--- + +import Image from '@theme/IdealImage'; +import remove_table from '@site/static/images/integrations/data-ingestion/clickpipes/postgres/remove_table.png' + +在某些情况下,将特定表从 MySQL ClickPipe 中排除是有意义的 - 例如,如果某个表对您的分析工作负载没有必要,跳过它可以减少 ClickHouse 中的存储和复制成本。 + +## 移除特定表的步骤 {#remove-tables-steps} + +第一步是从管道中移除该表。这可以通过以下步骤完成: + +1. [暂停](./pause_and_resume.md)管道。 +2. 点击“编辑表设置”。 +3. 找到您的表 - 可以通过在搜索栏中搜索来完成。 +4. 通过点击选中的复选框取消选择该表。 +
+ + + +5. 点击更新。 +6. 成功更新后,在 **Metrics** 标签中状态将变为 **Running**。该表将不再被此 ClickPipe 复制。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/remove_table.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/remove_table.md.hash new file mode 100644 index 00000000000..dd66fb95768 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/remove_table.md.hash @@ -0,0 +1 @@ +e038e2040a4ac5c3 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/resync.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/resync.md new file mode 100644 index 00000000000..d29c3c3db04 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/resync.md @@ -0,0 +1,47 @@ +--- +'title': '重新同步数据库 ClickPipe' +'description': '关于重新同步数据库 ClickPipe 的文档' +'slug': '/integrations/clickpipes/mysql/resync' +'sidebar_label': '重新同步 ClickPipe' +'doc_type': 'guide' +--- + +import resync_button from '@site/static/images/integrations/data-ingestion/clickpipes/postgres/resync_button.png' +import Image from '@theme/IdealImage'; + +### Resync 的作用是什么? {#what-mysql-resync-do} + +Resync 涉及以下操作: + +1. 现有的 ClickPipe 被删除,并启动一个新的 "resync" ClickPipe。这样,在重新同步时,源表结构的更改将会被捕捉到。 +2. resync ClickPipe 创建(或替换)一组新的目标表,这些表的名称与原始表相同,只是带有 `_resync` 后缀。 +3. 对 `_resync` 表执行初始加载。 +4. 然后,`_resync` 表与原始表进行交换。在交换之前,软删除的行会从原始表转移到 `_resync` 表。 + +原始 ClickPipe 的所有设置在 resync ClickPipe 中被保留。原始 ClickPipe 的统计信息在用户界面中被清除。 + +### Resync ClickPipe 的使用场景 {#use-cases-mysql-resync} + +以下是几个场景: + +1. 你可能需要对源表进行重大模式更改,这会破坏现有的 ClickPipe,你需要重新启动。在进行更改后,你只需点击 Resync。 +2. 特别是对于 ClickHouse,可能需要更改目标表的 ORDER BY 键。你可以通过 Resync 将数据重新填充到具有正确排序键的新表中。 + +:::note +你可以多次进行 resync,但是请在重新同步时考虑源数据库的负载。 +::: + +### Resync ClickPipe 指南 {#guide-mysql-resync} + +1. 在数据源选项卡中,点击你想重新同步的 MySQL ClickPipe。 +2. 前往 **设置** 选项卡。 +3. 点击 **Resync** 按钮。 + + + +4. 将弹出确认对话框。请再次点击 Resync。 +5. 前往 **指标** 选项卡。 +6. 在大约 5 秒内(以及页面刷新后),管道的状态应为 **设置** 或 **快照**。 +7. 可以在 **表** 选项卡的 **初始加载统计** 部分监控重新同步的初始加载。 +8. 一旦初始加载完成,管道将原子性地将 `_resync` 表与原始表交换。在交换过程中,状态将为 **Resync**。 +9. 一旦交换完成,管道将进入 **运行** 状态,并在启用的情况下执行 CDC。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/resync.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/resync.md.hash new file mode 100644 index 00000000000..74581a76265 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/resync.md.hash @@ -0,0 +1 @@ +d3d0844fb3a80814 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/schema-changes.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/schema-changes.md new file mode 100644 index 00000000000..235d5899dd6 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/schema-changes.md @@ -0,0 +1,16 @@ +--- +'title': '架构更改传播支持' +'slug': '/integrations/clickpipes/mysql/schema-changes' +'description': '页面描述源表中 ClickPipes 可检测到的架构更改类型' +'doc_type': 'reference' +--- + +ClickPipes for MySQL 可以检测源表中的模式变化,并在某些情况下自动将这些变化传播到目标表。每个 DDL 操作的处理方式在下面进行了文档说明: + +[//]: # "TODO Extend this page with behavior on rename, data type changes, and truncate + guidance on how to handle incompatible schema changes." + +| 模式变化类型 | 行为 | +| ------------------------------------------------------------------------------------- | ------------------------------------- | +| 添加新列 (`ALTER TABLE ADD COLUMN ...`) | 自动传播。新的列将在模式变化后复制的所有行中填充 | +| 添加带有默认值的新列 (`ALTER TABLE ADD COLUMN ... DEFAULT ...`) | 自动传播。新的列将在模式变化后复制的所有行中填充,但现有行在未进行全表刷新时不会显示默认值 | +| 删除现有列 (`ALTER TABLE DROP COLUMN ...`) | 检测到,但**不**传播。删除的列将在模式变化后复制的所有行中填充为 `NULL` | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/schema-changes.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/schema-changes.md.hash new file mode 100644 index 00000000000..f20c8764117 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/schema-changes.md.hash @@ -0,0 +1 @@ +b99823ace4f6a481 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/source/aurora.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/source/aurora.md index 98effe8c1fe..9f2084731c6 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/source/aurora.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/source/aurora.md @@ -1,15 +1,16 @@ --- 'sidebar_label': 'Amazon Aurora MySQL' -'description': '逐步指南,介绍如何将 Amazon Aurora MySQL 设置为 ClickPipes 的数据源' +'description': '逐步指南,介绍如何将 Amazon Aurora MySQL 设置为 ClickPipes 的源' 'slug': '/integrations/clickpipes/mysql/source/aurora' 'title': 'Aurora MySQL 源设置指南' +'doc_type': 'guide' --- import rds_backups from '@site/static/images/integrations/data-ingestion/clickpipes/mysql/source/rds/rds-backups.png'; import parameter_group_in_blade from '@site/static/images/integrations/data-ingestion/clickpipes/postgres/source/rds/parameter_group_in_blade.png'; import security_group_in_rds_mysql from '@site/static/images/integrations/data-ingestion/clickpipes/mysql/source/rds/security-group-in-rds-mysql.png'; import edit_inbound_rules from '@site/static/images/integrations/data-ingestion/clickpipes/postgres/source/rds/edit_inbound_rules.png'; -import aurora_config from '@site/static/images/integrations/data-ingestion/clickpipes/mysql/parameter_group/rds_config.png'; +import aurora_config from '@site/static/images/integrations/data-ingestion/clickpipes/mysql/parameter_group/aurora_config.png'; import binlog_format from '@site/static/images/integrations/data-ingestion/clickpipes/mysql/parameter_group/binlog_format.png'; import binlog_row_image from '@site/static/images/integrations/data-ingestion/clickpipes/mysql/parameter_group/binlog_row_image.png'; import binlog_row_metadata from '@site/static/images/integrations/data-ingestion/clickpipes/mysql/parameter_group/binlog_row_metadata.png'; @@ -20,85 +21,93 @@ import Image from '@theme/IdealImage'; # Aurora MySQL 源设置指南 -这是一个逐步指南,讲述如何配置您的 Aurora MySQL 实例,通过 MySQL ClickPipe 复制其数据。 -
-:::info -我们还建议您查看 MySQL FAQ [在这里](/integrations/data-ingestion/clickpipes/mysql/faq.md)。FAQ 页面会不断更新。 -::: +本分步指南展示了如何配置 Amazon Aurora MySQL 将数据复制到 ClickHouse Cloud,使用 [MySQL ClickPipe](../index.md)。有关 MySQL CDC 的常见问题,请参见 [MySQL 常见问题页面](/integrations/data-ingestion/clickpipes/mysql/faq.md)。 ## 启用二进制日志保留 {#enable-binlog-retention-aurora} -二进制日志是一组日志文件,包含对 MySQL 服务器实例所做的数据修改的信息,复制需要二进制日志文件。必须遵循以下两个步骤: -### 1. 通过自动备份启用二进制日志 {#enable-binlog-logging-aurora} -自动备份功能决定了 MySQL 是否启用二进制日志。可以在 AWS 控制台中设置: +二进制日志是一组包含有关对 MySQL 服务器实例进行的数据修改的信息的日志文件,二进制日志文件是复制所必需的。要在 Aurora MySQL 中配置二进制日志保留,您必须 [启用二进制日志记录](#enable-binlog-logging) 和 [增加 binlog 保留间隔](#binlog-retention-interval)。 + +### 1. 通过自动备份启用二进制日志 {#enable-binlog-logging} + +自动备份功能决定了 MySQL 是否启用二进制日志。可以在 RDS 控制台为您的实例配置自动备份,导航到 **修改** > **附加配置** > **备份**,然后选择 **启用自动备份** 复选框(如果尚未选择)。 -建议根据复制用例将备份保留期限设定为合理较长的值。 +我们建议根据复制用例将 **备份保留期** 设置为一个相对较长的值。 + +### 2. 增加 binlog 保留间隔 {#binlog-retention-interval} -### 2. 二进制日志保留小时数 {#binlog-retention-hours-aurora} -必须调用以下过程,以确保复制时二进制日志的可用性: +:::warning +如果 ClickPipes 尝试恢复复制,而所需的 binlog 文件由于配置的 binlog 保留值而被清除,则 ClickPipe 将进入错误状态,需要重新同步。 +::: + +默认情况下,Aurora MySQL 会尽快清除二进制日志(即,_惰性清除_)。我们建议将 binlog 保留间隔增加到至少 **72 小时**,以确保在故障场景下可用的二进制日志文件。要设置 binlog 保留间隔 ([`binlog retention hours`](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/mysql-stored-proc-configuring.html#mysql_rds_set_configuration-usage-notes.binlog-retention-hours)),请使用 [`mysql.rds_set_configuration`](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/mysql-stored-proc-configuring.html#mysql_rds_set_configuration) 过程: + +[//]: # "NOTE Most CDC providers recommend the maximum retention period for Aurora RDS (7 days/168 hours). Since this has an impact on disk usage, we conservatively recommend a minimum of 3 days/72 hours." ```text -mysql=> call mysql.rds_set_configuration('binlog retention hours', 24); +mysql=> call mysql.rds_set_configuration('binlog retention hours', 72); ``` -如果未设置此配置,Amazon RDS 会尽快清除二进制日志,从而造成二进制日志中的缺口。 -## 在参数组中配置 binlog 设置 {#binlog-parameter-group-aurora} +如果未设置此配置或设置为较低的间隔,可能会导致二进制日志中的间隙,从而影响 ClickPipes 恢复复制的能力。 + +## 配置 binlog 设置 {#binlog-settings} -参数组可以在您点击 RDS 控制台中的 MySQL 实例后找到,然后转到 `Configurations` 选项卡。 +要找到参数组,请在 RDS 控制台中点击您的 MySQL 实例,然后导航到 **配置** 标签。 - +:::tip +如果您有 MySQL 集群,上述参数可以在 [DB 集群](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/USER_WorkingWithParamGroups.CreatingCluster.html) 参数组中找到,而不是 DB 实例组中。 +::: -点击参数组链接后,您将进入该页面。您将在右上角看到一个编辑按钮。 + + +
+点击参数组链接,这将带您到其专用页面。您应该会在右上角看到一个 **编辑** 按钮。 -以下设置需要设置如下: +
+以下参数需要设置如下: 1. 将 `binlog_format` 设置为 `ROW`。 - + -2. 将 `binlog_row_metadata` 设置为 `FULL` +2. 将 `binlog_row_metadata` 设置为 `FULL`。 -3. 将 `binlog_row_image` 设置为 `FULL` +3. 将 `binlog_row_image` 设置为 `FULL`。 -然后点击右上角的 `Save Changes`。您可能需要重启实例才能使更改生效 - 确认这一点的方法是在 RDS 实例的 Configurations 选项卡的参数组链接旁边看到 `Pending reboot`。
+然后,点击右上角的 **保存更改**。您可能需要重启您的实例才能使更改生效 — 一种知道这一点的方法是在 Aurora 实例的 **配置** 标签中,您能在参数组链接旁边看到 `待重启`。 + +## 启用 GTID 模式(推荐) {#gtid-mode} + :::tip -如果您有一个 MySQL 集群,上述参数将在 [DB Cluster](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/USER_WorkingWithParamGroups.CreatingCluster.html) 参数组中找到,而不是 DB 实例组。 +MySQL ClickPipe 也支持在未启用 GTID 模式的情况下进行复制。然而,建议启用 GTID 模式以获得更好的性能和更容易的故障排除。 ::: -## 启用 GTID 模式 {#gtid-mode-aurora} -全局事务标识符 (GTID) 是分配给每个已提交事务的唯一 ID。它们简化了 binlog 复制并使故障排除更加直接。 +[全局事务标识符 (GTIDs)](https://dev.mysql.com/doc/refman/8.0/en/replication-gtids.html) 是分配给 MySQL 中每个已提交事务的唯一 ID。它们简化了 binlog 复制,并使故障排除更为简单。我们 **建议** 启用 GTID 模式,以便 MySQL ClickPipe 可以使用基于 GTID 的复制。 -如果您的 MySQL 实例为 MySQL 5.7、8.0 或 8.4,我们建议启用 GTID 模式,以便 MySQL ClickPipe 可以使用 GTID 复制。 +GTID 基于复制支持 Amazon Aurora MySQL v2 (MySQL 5.7) 和 v3 (MySQL 8.0),以及 Aurora Serverless v2。要为您的 Aurora MySQL 实例启用 GTID 模式,请按照以下步骤操作: -要为您的 MySQL 实例启用 GTID 模式,请按照以下步骤操作: 1. 在 RDS 控制台中,点击您的 MySQL 实例。 -2. 点击 `Configurations` 选项卡。 +2. 点击 **配置** 标签。 3. 点击参数组链接。 -4. 点击右上角的 `Edit` 按钮。 +4. 点击右上角的 **编辑** 按钮。 5. 将 `enforce_gtid_consistency` 设置为 `ON`。 6. 将 `gtid-mode` 设置为 `ON`。 -7. 点击右上角的 `Save Changes`。 -8. 重启实例以使更改生效。 +7. 点击右上角的 **保存更改**。 +8. 重启您的实例以使更改生效。 - + -
-:::info -MySQL ClickPipe 也支持没有 GTID 模式的复制。然而,推荐启用 GTID 模式,以获得更好的性能和更简单的故障排除。 -::: - -## 配置数据库用户 {#configure-database-user-aurora} +## 配置数据库用户 {#configure-database-user} -以管理员用户身份连接到您的 Aurora MySQL 实例,并执行以下命令: +以管理员用户身份连接到您的 Aurora MySQL 实例并执行以下命令: 1. 为 ClickPipes 创建一个专用用户: @@ -106,7 +115,7 @@ MySQL ClickPipe 也支持没有 GTID 模式的复制。然而,推荐启用 GTI CREATE USER 'clickpipes_user'@'%' IDENTIFIED BY 'some-password'; ``` -2. 授予模式权限。以下示例展示了 `mysql` 数据库的权限。针对您想要复制的每个数据库和主机重复这些命令: +2. 授予模式权限。以下示例展示了 `mysql` 数据库的权限。对每个您想要复制的数据库和主机重复这些命令: ```sql GRANT SELECT ON `mysql`.* TO 'clickpipes_user'@'host'; @@ -123,12 +132,16 @@ GRANT REPLICATION SLAVE ON *.* TO 'clickpipes_user'@'%'; ### 基于 IP 的访问控制 {#ip-based-access-control} -如果您想限制对 Aurora 实例的流量,请将 [文档中列出的静态 NAT IPs](../../index.md#list-of-static-ips) 添加到您的 Aurora 安全组的 `Inbound rules` 中,如下所示: +要限制对您的 Aurora MySQL 实例的流量,请将 [记录的静态 NAT IPs](../../index.md#list-of-static-ips) 添加到您的 Aurora 安全组的 **入站规则**。 -### 通过 AWS PrivateLink 实现私有访问 {#private-access-via-aws-privatelink} +### 通过 AWS PrivateLink 的私有访问 {#private-access-via-aws-privatelink} + +要通过私人网络连接到您的 Aurora MySQL 实例,您可以使用 AWS PrivateLink。请遵循 [ClickPipes 的 AWS PrivateLink 设置指南](/knowledgebase/aws-privatelink-setup-for-clickpipes) 设置连接。 + +## 接下来是什么? {#whats-next} -要通过私有网络连接到您的 Aurora 实例,您可以使用 AWS PrivateLink。请按照我们的 [AWS PrivateLink ClickPipes 设置指南](/knowledgebase/aws-privatelink-setup-for-clickpipes) 设置连接。 +现在您的 Amazon Aurora MySQL 实例已配置为 binlog 复制,并安全连接到 ClickHouse Cloud,您可以 [创建您的第一个 MySQL ClickPipe](/integrations/clickpipes/mysql/#create-your-clickpipe)。有关 MySQL CDC 的常见问题,请参见 [MySQL 常见问题页面](/integrations/data-ingestion/clickpipes/mysql/faq.md)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/source/aurora.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/source/aurora.md.hash index 250de9c74f2..8479fbf7ac3 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/source/aurora.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/source/aurora.md.hash @@ -1 +1 @@ -4235ebf0a27f9b0f +6dc688eb267a921b diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/source/gcp.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/source/gcp.md index c88978d6e2a..e96463558e7 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/source/gcp.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/source/gcp.md @@ -1,8 +1,9 @@ --- -'sidebar_label': 'Cloud SQL For MySQL ' -'description': '逐步指南,介绍如何将 Cloud SQL for MySQL 设置为 ClickPipes 的数据源' +'sidebar_label': 'Cloud SQL For MySQL' +'description': '逐步指南,说明如何将 Cloud SQL for MySQL 设置为 ClickPipes 的数据源' 'slug': '/integrations/clickpipes/mysql/source/gcp' 'title': 'Cloud SQL for MySQL 源设置指南' +'doc_type': 'guide' --- import gcp_pitr from '@site/static/images/integrations/data-ingestion/clickpipes/mysql/source/gcp/gcp-mysql-pitr.png'; @@ -16,33 +17,33 @@ import Image from '@theme/IdealImage'; # Cloud SQL for MySQL 源设置指南 -这是一个逐步指导,说明如何配置您的 Cloud SQL for MySQL 实例,通过 MySQL ClickPipe 复制其数据。 +这是一个逐步指南,介绍如何配置您的 Cloud SQL for MySQL 实例,以通过 MySQL ClickPipe 复制其数据。 ## 启用二进制日志保留 {#enable-binlog-retention-gcp} -二进制日志是一组日志文件,包含有关对 MySQL 服务器实例进行的数据修改的信息,并且二进制日志文件是复制所必需的。 +二进制日志是一组日志文件,包含对 MySQL 服务器实例进行的数据修改信息,且二进制日志文件是进行复制所必需的。 ### 通过 PITR 启用二进制日志 {#enable-binlog-logging-gcp} -PITR 功能决定了 Google Cloud 中 MySQL 的二进制日志是否打开或关闭。可以在 Cloud 控制台中设置,通过编辑您的 Cloud SQL 实例并向下滚动到以下部分。 +PITR 功能决定了 Google Cloud 中 MySQL 的二进制日志是否开启。您可以在 Cloud 控制台中,通过编辑 Cloud SQL 实例并向下滚动到以下部分来进行设置。 -建议根据复制用例将值设置为一个合理的较长值。 +根据复制用例,建议将值设置为一个合理的较长值。 -如果尚未配置,请确保在数据库标志部分通过编辑 Cloud SQL 设置以下内容: -1. `binlog_expire_logs_seconds` 设置为 >= `86400`(1 天)。 +如果尚未配置,请确保在数据库标志部分通过编辑 Cloud SQL 来设置这些标志: +1. `binlog_expire_logs_seconds` 设置为 >= `86400` (1 天) 的值。 2. `binlog_row_metadata` 设置为 `FULL` 3. `binlog_row_image` 设置为 `FULL` -要执行此操作,请单击实例概述页面右上角的 `Edit` 按钮。 +为此,请单击实例概述页面右上角的 `编辑` 按钮。 -然后向下滚动到 `Flags` 部分并添加上述标志。 +然后向下滚动到 `Flags` 部分,并添加上述标志。 ## 配置数据库用户 {#configure-database-user-gcp} -以 root 用户身份连接到您的 Cloud SQL MySQL 实例并执行以下命令: +以 root 用户身份连接到您的 Cloud SQL MySQL 实例,并执行以下命令: 1. 为 ClickPipes 创建一个专用用户: @@ -50,13 +51,13 @@ PITR 功能决定了 Google Cloud 中 MySQL 的二进制日志是否打开或关 CREATE USER 'clickpipes_user'@'host' IDENTIFIED BY 'some-password'; ``` -2. 授予架构权限。以下示例显示了 `clickpipes` 数据库的权限。对每个要复制的数据库和主机重复这些命令: +2. 授予模式权限。以下示例显示了 `clickpipes` 数据库的权限。对每个您想要复制的数据库和主机重复这些命令: ```sql GRANT SELECT ON `clickpipes`.* TO 'clickpipes_user'@'host'; ``` -3. 授予用户复制权限: +3. 授予该用户复制权限: ```sql GRANT REPLICATION CLIENT ON *.* TO 'clickpipes_user'@'%'; @@ -65,21 +66,21 @@ GRANT REPLICATION SLAVE ON *.* TO 'clickpipes_user'@'%'; ## 配置网络访问 {#configure-network-access-gcp-mysql} -如果您希望限制对 Cloud SQL 实例的流量,请将 [文档中的静态 NAT IP](../../index.md#list-of-static-ips) 添加到您的 Cloud SQL MySQL 实例的白名单 IP 中。 -这可以通过编辑实例或在 Cloud 控制台的侧边栏中转到 `Connections` 选项卡来完成。 +如果您想限制对 Cloud SQL 实例的流量,请将 [文档中列出的静态 NAT IP](../../index.md#list-of-static-ips) 添加到您的 Cloud SQL MySQL 实例的允许名单 IP 中。 +这可以通过编辑实例或在 Cloud 控制台的侧边栏中前往 `Connections` 选项卡完成。 - + ## 下载并使用根 CA 证书 {#download-root-ca-certificate-gcp-mysql} 要连接到您的 Cloud SQL 实例,您需要下载根 CA 证书。 -1. 在 Cloud 控制台中访问您的 Cloud SQL 实例。 -2. 点击侧边栏中的 `Connections`。 -3. 点击 `Security` 选项卡。 -4. 在 `Manage server CA certificates` 部分,点击底部的 `DOWNLOAD CERTIFICATES` 按钮。 +1. 在 Cloud 控制台中,转到您的 Cloud SQL 实例。 +2. 在侧边栏中单击 `Connections`。 +3. 单击 `Security` 选项卡。 +4. 在 `Manage server CA certificates` 部分,单击底部的 `DOWNLOAD CERTIFICATES` 按钮。 -5. 在 ClickPipes UI 中,上传下载的证书以创建新的 MySQL ClickPipe。 +5. 在 ClickPipes UI 中,在创建新的 MySQL ClickPipe 时上传下载的证书。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/source/gcp.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/source/gcp.md.hash index 62ce22d48bf..9e18358bc38 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/source/gcp.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/source/gcp.md.hash @@ -1 +1 @@ -b0854b16a09439e5 +daf9a2a379814eb9 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/source/generic.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/source/generic.md new file mode 100644 index 00000000000..718f645e999 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/source/generic.md @@ -0,0 +1,141 @@ +--- +'sidebar_label': 'Generic MySQL' +'description': '将任何 MySQL 实例设置为 ClickPipes 的数据源' +'slug': '/integrations/clickpipes/mysql/source/generic' +'title': '通用 MySQL 源设置指南' +'doc_type': 'guide' +--- + + +# 通用 MySQL 源设置指南 + +:::info + +如果您使用的是支持的提供商(在侧边栏中),请参阅该提供商的特定指南。 + +::: + +## 启用二进制日志保留 {#enable-binlog-retention} + +二进制日志包含对 MySQL 服务器实例所做的数据修改的信息,并且要求用于复制。 + +### MySQL 8.x 及更新版本 {#binlog-v8-x} + +要在您的 MySQL 实例上启用二进制日志记录,请确保配置以下设置: + +```sql +log_bin = ON -- default value +binlog_format = ROW -- default value +binlog_row_image = FULL -- default value +binlog_row_metadata = FULL +binlog_expire_logs_seconds = 86400 -- 1 day or higher; default is 30 days +``` + +要检查这些设置,请运行以下 SQL 命令: +```sql +SHOW VARIABLES LIKE 'log_bin'; +SHOW VARIABLES LIKE 'binlog_format'; +SHOW VARIABLES LIKE 'binlog_row_image'; +SHOW VARIABLES LIKE 'binlog_row_metadata'; +SHOW VARIABLES LIKE 'binlog_expire_logs_seconds'; +``` + +如果值不匹配,您可以运行以下 SQL 命令进行设置: +```sql +SET PERSIST log_bin = ON; +SET PERSIST binlog_format = ROW; +SET PERSIST binlog_row_image = FULL; +SET PERSIST binlog_row_metadata = FULL; +SET PERSIST binlog_expire_logs_seconds = 86400; +``` + +如果您已更改 `log_bin` 设置,则需要重启 MySQL 实例以使更改生效。 + +更改设置后,请继续进行 [配置数据库用户](#configure-database-user)。 + +### MySQL 5.7 {#binlog-v5-x} + +要在您的 MySQL 5.7 实例上启用二进制日志记录,请确保配置以下设置: + +```sql +server_id = 1 -- or greater; anything but 0 +log_bin = ON +binlog_format = ROW -- default value +binlog_row_image = FULL -- default value +expire_logs_days = 1 -- or higher; 0 would mean logs are preserved forever +``` + +要检查这些设置,请运行以下 SQL 命令: +```sql +SHOW VARIABLES LIKE 'server_id'; +SHOW VARIABLES LIKE 'log_bin'; +SHOW VARIABLES LIKE 'binlog_format'; +SHOW VARIABLES LIKE 'binlog_row_image'; +SHOW VARIABLES LIKE 'expire_logs_days'; +``` + +如果值不匹配,您可以在配置文件中进行设置(通常位于 `/etc/my.cnf` 或 `/etc/mysql/my.cnf`): +```ini +[mysqld] +server_id = 1 +log_bin = ON +binlog_format = ROW +binlog_row_image = FULL +expire_logs_days = 1 +``` + +您需要重启 MySQL 实例以使更改生效。 + +:::note + +对于 MySQL 5.7,不支持列排除,因为 `binlog_row_metadata` 设置尚未引入。 + +::: + +## 配置数据库用户 {#configure-database-user} + +以 root 用户身份连接到您的 MySQL 实例并执行以下命令: + +1. 为 ClickPipes 创建一个专用用户: + +```sql +CREATE USER 'clickpipes_user'@'%' IDENTIFIED BY 'some_secure_password'; +``` + +2. 授予架构权限。以下示例显示了 `clickpipes` 数据库的权限。对每个要复制的数据库和主机重复这些命令: + +```sql +GRANT SELECT ON `clickpipes`.* TO 'clickpipes_user'@'%'; +``` + +3. 授予用户复制权限: + +```sql +GRANT REPLICATION CLIENT ON *.* TO 'clickpipes_user'@'%'; +GRANT REPLICATION SLAVE ON *.* TO 'clickpipes_user'@'%'; +``` + +:::note + +请确保将 `clickpipes_user` 和 `some_secure_password` 替换为您想要的用户名和密码。 + +::: + +## SSL/TLS 配置(推荐) {#ssl-tls-configuration} + +SSL 证书确保与您的 MySQL 数据库的安全连接。配置取决于您的证书类型: + +**受信任的证书颁发机构(DigiCert、Let's Encrypt 等)** - 无需额外配置。 + +**内部证书颁发机构** - 从您的 IT 团队获取根 CA 证书文件。在 ClickPipes 管理界面,在创建新的 MySQL ClickPipe 时上传它。 + +**自托管 MySQL** - 从您的 MySQL 服务器复制 CA 证书(通常位于 `/var/lib/mysql/ca.pem`),并在创建新的 MySQL ClickPipe 时在 UI 中上传。使用服务器的 IP 地址作为主机。 + +**没有服务器访问权限的自托管 MySQL** - 联系您的 IT 团队获取证书。作为最后手段,使用 ClickPipes 管理界面中的“跳过证书验证”切换(出于安全原因不推荐)。 + +有关 SSL/TLS 选项的更多信息,请查看我们的 [常见问题解答](https://clickhouse.com/docs/integrations/clickpipes/mysql/faq#tls-certificate-validation-error)。 + +## 接下来是什么? {#whats-next} + +您现在可以 [创建 ClickPipe](../index.md),并开始将数据从您的 MySQL 实例导入到 ClickHouse Cloud。 +确保记录您在设置 MySQL 实例时使用的连接详细信息,因为在创建 ClickPipe 过程中需要这些信息。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/source/generic.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/source/generic.md.hash new file mode 100644 index 00000000000..69ab429c53f --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/source/generic.md.hash @@ -0,0 +1 @@ +a3479fb966b7e3da diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/source/generic_maria.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/source/generic_maria.md new file mode 100644 index 00000000000..5961d033d35 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/source/generic_maria.md @@ -0,0 +1,110 @@ +--- +'sidebar_label': '通用 MariaDB' +'description': '将任何 MariaDB 实例设置为 ClickPipes 的数据源' +'slug': '/integrations/clickpipes/mysql/source/generic_maria' +'title': '通用 MariaDB 源设置指南' +'doc_type': 'guide' +--- + + +# 通用 MariaDB 源设置指南 + +:::info + +如果您使用的是支持的提供程序(在侧边栏中),请参考该提供程序的特定指南。 + +::: + +## 启用二进制日志保留 {#enable-binlog-retention} + +二进制日志包含有关对 MariaDB 服务器实例所做的数据修改的信息,并且是复制所必需的。 + +要在您的 MariaDB 实例上启用二进制日志,请确保配置以下设置: + +```sql +server_id = 1 -- or greater; anything but 0 +log_bin = ON +binlog_format = ROW +binlog_row_image = FULL +binlog_row_metadata = FULL -- introduced in 10.5.0 +expire_logs_days = 1 -- or higher; 0 would mean logs are preserved forever +``` + +要检查这些设置,请运行以下 SQL 命令: +```sql +SHOW VARIABLES LIKE 'server_id'; +SHOW VARIABLES LIKE 'log_bin'; +SHOW VARIABLES LIKE 'binlog_format'; +SHOW VARIABLES LIKE 'binlog_row_image'; +SHOW VARIABLES LIKE 'binlog_row_metadata'; +SHOW VARIABLES LIKE 'expire_logs_days'; +``` + +如果值不匹配,则可以在配置文件中设置它们(通常位于 `/etc/my.cnf` 或 `/etc/my.cnf.d/mariadb-server.cnf`): +```ini +[mysqld] +server_id = 1 +log_bin = ON +binlog_format = ROW +binlog_row_image = FULL +binlog_row_metadata = FULL ; only in 10.5.0 and newer +expire_logs_days = 1 +``` + +如果源数据库是副本,请确保还启用 `log_slave_updates`。 + +您需要重新启动 MariaDB 实例以使更改生效。 + +:::note + +对于 MariaDB \<= 10.4,不支持列排除,因为尚未引入 `binlog_row_metadata` 设置。 + +::: + +## 配置数据库用户 {#configure-database-user} + +以 root 用户身份连接到您的 MariaDB 实例,并执行以下命令: + +1. 为 ClickPipes 创建专用用户: + +```sql +CREATE USER 'clickpipes_user'@'%' IDENTIFIED BY 'some_secure_password'; +``` + +2. 授予模式权限。以下示例显示了对 `clickpipes` 数据库的权限。对每个您希望复制的数据库和主机重复这些命令: + +```sql +GRANT SELECT ON `clickpipes`.* TO 'clickpipes_user'@'%'; +``` + +3. 授予用户复制权限: + +```sql +GRANT REPLICATION CLIENT ON *.* TO 'clickpipes_user'@'%'; +GRANT REPLICATION SLAVE ON *.* TO 'clickpipes_user'@'%'; +``` + +:::note + +确保用您想要的用户名和密码替换 `clickpipes_user` 和 `some_secure_password`。 + +::: + +## SSL/TLS 配置(推荐) {#ssl-tls-configuration} + +SSL 证书确保与您的 MariaDB 数据库的安全连接。配置取决于您的证书类型: + +**受信任的证书颁发机构 (DigiCert, Let's Encrypt 等)** - 无需额外配置。 + +**内部证书颁发机构** - 从 IT 团队获取根 CA 证书文件。在 ClickPipes UI 中,在创建新的 MariaDB ClickPipe 时上传它。 + +**自托管的 MariaDB** - 从您的 MariaDB 服务器复制 CA 证书(通过 `my.cnf` 中的 `ssl_ca` 设置查找路径)。在 ClickPipes UI 中,在创建新的 MariaDB ClickPipe 时上传它。使用服务器的 IP 地址作为主机。 + +**自托管的 MariaDB(11.4 及以上)** - 如果您的服务器已设置 `ssl_ca`,请按照上述选项进行操作。否则,请与 IT 团队协商以提供适当的证书。作为最后手段,请在 ClickPipes UI 中使用“跳过证书验证”切换(出于安全原因,不推荐使用)。 + +有关 SSL/TLS 选项的更多信息,请查看我们的 [常见问题解答](https://clickhouse.com/docs/integrations/clickpipes/mysql/faq#tls-certificate-validation-error)。 + +## 接下来是什么? {#whats-next} + +您现在可以 [创建您的 ClickPipe](../index.md),并开始将数据从您的 MariaDB 实例导入到 ClickHouse Cloud。 +请确保记下您在设置 MariaDB 实例时使用的连接详细信息,因为在创建 ClickPipe 过程中将需要这些信息。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/source/generic_maria.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/source/generic_maria.md.hash new file mode 100644 index 00000000000..5c3b63cd24f --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/source/generic_maria.md.hash @@ -0,0 +1 @@ +85a650b97355cb09 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/source/rds.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/source/rds.md index cd6f15318e1..bd5b16df6b9 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/source/rds.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/source/rds.md @@ -3,6 +3,7 @@ 'description': '逐步指南,介绍如何将 Amazon RDS MySQL 设置为 ClickPipes 的数据源' 'slug': '/integrations/clickpipes/mysql/source/rds' 'title': 'RDS MySQL 源设置指南' +'doc_type': 'guide' --- import rds_backups from '@site/static/images/integrations/data-ingestion/clickpipes/mysql/source/rds/rds-backups.png'; @@ -18,90 +19,99 @@ import enable_gtid from '@site/static/images/integrations/data-ingestion/clickpi import Image from '@theme/IdealImage'; -# RDS MySQL 数据源设置指南 +# RDS MySQL 源设置指南 -这是一个逐步指南,介绍如何配置您的 RDS MySQL 实例,以通过 MySQL ClickPipe 复制其数据。 -
-:::info -我们还建议您查看 MySQL 常见问题解答 [这里](/integrations/data-ingestion/clickpipes/mysql/faq.md)。常见问题解答页面正在积极更新中。 -::: +本分步指南将指导您如何配置 Amazon RDS MySQL,以使用 [MySQL ClickPipe](../index.md) 将数据复制到 ClickHouse Cloud。有关 MySQL CDC 的常见问题,请参阅 [MySQL 常见问题页面](/integrations/data-ingestion/clickpipes/mysql/faq.md)。 ## 启用二进制日志保留 {#enable-binlog-retention-rds} -二进制日志是一组日志文件,包含对 MySQL 服务器实例进行的数据修改信息,二进制日志文件是复制所必需的。必须遵循以下两个步骤: -### 1. 通过自动备份启用二进制日志 {#enable-binlog-logging-rds} -自动备份功能决定是否为 MySQL 开启二进制日志。可以在 AWS 控制台中设置: +二进制日志是一组日志文件,包含对 MySQL 服务器实例进行的数据修改信息,二进制日志文件是进行复制所必需的。要在 RDS MySQL 中配置二进制日志保留,您必须 [启用二进制日志](#enable-binlog-logging) 并 [增加 binlog 保留时间间隔](#binlog-retention-interval)。 + +### 1. 通过自动备份启用二进制日志 {#enable-binlog-logging} + +自动备份功能决定了 MySQL 是否启用二进制日志。可以通过 RDS 控制台为您的实例配置自动备份,步骤是导航到 **修改** > **附加配置** > **备份**,然后选中 **启用自动备份** 复选框(如果尚未选中)。 -根据复制使用案例,建议将备份保留期限设置为合理的长时间值。 +我们建议将 **备份保留期** 设置为一个相对较长的值,具体取决于复制的使用场景。 -### 2. 二进制日志保留小时数 {#binlog-retention-hours-rds} -Amazon RDS for MySQL 使用不同的方法来设置 binlog 保留时间,即包含更改的 binlog 文件被保留的时间。如果某些更改在 binlog 文件被删除之前未被读取,则复制将无法继续。binlog 保留小时数的默认值为 NULL,这意味着不保留二进制日志。 +### 2. 增加 binlog 保留时间间隔 {#binlog-retention-interval} -要指定在 DB 实例上保留二进制日志的小时数,请使用 mysql.rds_set_configuration 函数,设置一个足够长的 binlog 保留期限以进行复制。推荐的最小值为 `24 小时`。 +:::warning +如果 ClickPipes 尝试恢复复制,而由于配置的 binlog 保留值导致所需的 binlog 文件被清除,ClickPipe 将进入错误状态,需进行重新同步。 +::: + +默认情况下,Amazon RDS 尽快清除二进制日志(即 _延迟清除_)。我们建议将 binlog 保留时间间隔增加到至少 **72 小时**,以确保在故障场景下二进制日志文件的可用性。要设置二进制日志保留时间间隔 ([`binlog retention hours`](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/mysql-stored-proc-configuring.html#mysql_rds_set_configuration-usage-notes.binlog-retention-hours)),请使用 [`mysql.rds_set_configuration`](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/mysql-stored-proc-configuring.html#mysql_rds_set_configuration) 存储过程: + +[//]: # "注意:大多数 CDC 提供商建议 RDS 的最大保留期为 7 天/168 小时。由于这会影响磁盘使用情况,我们保守建议设置最低 3 天/72 小时。" ```text -mysql=> call mysql.rds_set_configuration('binlog retention hours', 24); +mysql=> call mysql.rds_set_configuration('binlog retention hours', 72); ``` -## 在参数组中配置 binlog 设置 {#binlog-parameter-group-rds} +如果未设置此配置或设置为较低的时间间隔,可能会导致二进制日志中出现空白,从而影响 ClickPipes 恢复复制的能力。 + +## 配置 binlog 设置 {#binlog-settings} + +可以通过在 RDS 控制台中单击您的 MySQL 实例,然后导航到 **配置** 选项卡找到参数组。 -参数组可以在 RDS 控制台中单击您的 MySQL 实例,然后转到 `Configurations` 标签找到。 +:::tip +如果您有 MySQL 集群,以下参数可以在 [DB 集群](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/USER_WorkingWithParamGroups.CreatingCluster.html) 参数组中找到,而不是在 DB 实例组中。 +::: -单击参数组链接后,您将进入该参数组的页面。您会在右上方看到一个编辑按钮。 +
+单击参数组链接,您将被带到该页面的专用部分。您应该在右上角看到一个 **编辑** 按钮。 -需要按如下设置以下参数: +以下参数需要设置如下: 1. 将 `binlog_format` 设置为 `ROW`。 - + 2. 将 `binlog_row_metadata` 设置为 `FULL` - + 3. 将 `binlog_row_image` 设置为 `FULL` - - -然后单击右上方的 `Save Changes`。您可能需要重启实例以使更改生效 - 判断这一点的方法是,如果您在 RDS 实例的配置选项卡中看到参数组链接旁边有 `Pending reboot`。 +
+然后,单击右上角的 **保存更改**。您可能需要重启实例以使更改生效 —— 确认的方法是查看 RDS 实例的 **配置** 选项卡中参数组链接旁是否显示 `待重启`。 + +## 启用 GTID 模式 {#gtid-mode} + :::tip -如果您有 MySQL 集群,上述参数将位于 [DB Cluster](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/USER_WorkingWithParamGroups.CreatingCluster.html) 参数组中,而不是 DB 实例组中。 +MySQL ClickPipe 也支持在没有 GTID 模式的情况下进行复制。然而,建议启用 GTID 模式以获得更好的性能和更简单的故障排除。 ::: -## 启用 GTID 模式 {#gtid-mode-rds} -全球事务标识符 (GTID) 是分配给 MySQL 中每个已提交事务的唯一 ID。它们简化了 binlog 复制,并使故障排除更加简单。 +[全局事务标识符 (GTIDs)](https://dev.mysql.com/doc/refman/8.0/en/replication-gtids.html) 是分配给 MySQL 中每个已提交事务的唯一 ID。它们简化了 binlog 复制并使故障排除更加直接。我们 **建议** 启用 GTID 模式,以便 MySQL ClickPipe 可以使用基于 GTID 的复制。 -如果您的 MySQL 实例是 MySQL 5.7、8.0 或 8.4,我们建议启用 GTID 模式,以便 MySQL ClickPipe 可以使用 GTID 复制。 +GTID 基于的复制支持 Amazon RDS 的 MySQL 版本 5.7、8.0 和 8.4。要为您的 Aurora MySQL 实例启用 GTID 模式,请按照以下步骤操作: -要为您的 MySQL 实例启用 GTID 模式,请按照以下步骤操作: -1. 在 RDS 控制台中,单击您的 MySQL 实例。 -2. 单击 `Configurations` 标签。 +1. 在 RDS 控制台中单击您的 MySQL 实例。 +2. 点击 **配置** 选项卡。 3. 单击参数组链接。 -4. 单击右上角的 `Edit` 按钮。 +4. 单击右上角的 **编辑** 按钮。 5. 将 `enforce_gtid_consistency` 设置为 `ON`。 6. 将 `gtid-mode` 设置为 `ON`。 -7. 单击右上角的 `Save Changes`。 +7. 单击右上角的 **保存更改**。 8. 重启您的实例以使更改生效。 - +
:::tip -MySQL ClickPipe 也支持在不启用 GTID 模式的情况下进行复制。然而,建议启用 GTID 模式以获得更好的性能和更简单的故障排除。 +MySQL ClickPipe 也支持在没有 GTID 模式的情况下进行复制。然而,建议启用 GTID 模式以获得更好的性能和更简单的故障排除。 ::: +## 配置数据库用户 {#configure-database-user} -## 配置数据库用户 {#configure-database-user-rds} - -以管理员用户身份连接到您的 RDS MySQL 实例并执行以下命令: +作为管理员用户连接到 RDS MySQL 实例并执行以下命令: 1. 为 ClickPipes 创建一个专用用户: @@ -109,7 +119,7 @@ MySQL ClickPipe 也支持在不启用 GTID 模式的情况下进行复制。然 CREATE USER 'clickpipes_user'@'host' IDENTIFIED BY 'some-password'; ``` -2. 授予模式权限。以下示例显示了 `mysql` 数据库的权限。对于每个您想要复制的数据库和主机,重复这些命令: +2. 授予模式权限。以下示例显示了对 `mysql` 数据库的权限。对每个您要复制的数据库和主机重复这些命令: ```sql GRANT SELECT ON `mysql`.* TO 'clickpipes_user'@'host'; @@ -126,12 +136,16 @@ GRANT REPLICATION SLAVE ON *.* TO 'clickpipes_user'@'%'; ### 基于 IP 的访问控制 {#ip-based-access-control} -如果您想要限制对您的 RDS 实例的流量,请将 [记录的静态 NAT IPs](../../index.md#list-of-static-ips) 添加到您 RDS 安全组的 `Inbound rules`。 +要限制流量到您的 Aurora MySQL 实例,请将 [文档中的静态 NAT IP](../../index.md#list-of-static-ips) 添加到 RDS 安全组的 **入站规则** 中。 -### 通过 AWS PrivateLink 的私有访问 {#private-access-via-aws-privatelink} +### 通过 AWS PrivateLink 进行私有访问 {#private-access-via-aws-privatelink} + +要通过专用网络连接到您的 RDS 实例,可以使用 AWS PrivateLink。请按照 [ClickPipes 的 AWS PrivateLink 设置指南](/knowledgebase/aws-privatelink-setup-for-clickpipes) 设置连接。 + +## 下一步骤 {#next-steps} -要通过私有网络连接到 RDS 实例,您可以使用 AWS PrivateLink。请遵循我们的 [AWS PrivateLink ClickPipes 设置指南](/knowledgebase/aws-privatelink-setup-for-clickpipes) 来设置连接。 +现在您的 Amazon RDS MySQL 实例已配置为 binlog 复制并安全连接到 ClickHouse Cloud,您可以 [创建您的第一个 MySQL ClickPipe](/integrations/clickpipes/mysql/#create-your-clickpipe)。有关 MySQL CDC 的常见问题,请参阅 [MySQL 常见问题页面](/integrations/data-ingestion/clickpipes/mysql/faq.md)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/source/rds.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/source/rds.md.hash index 7fc031b1396..c8bfd6c1afa 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/source/rds.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/source/rds.md.hash @@ -1 +1 @@ -d9e776f578a6c85a +ce10e04992212115 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/source/rds_maria.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/source/rds_maria.md index 3a18c312070..3ed0621d217 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/source/rds_maria.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/source/rds_maria.md @@ -3,6 +3,7 @@ 'description': '逐步指南,介绍如何将 Amazon RDS MariaDB 设置为 ClickPipes 的数据源' 'slug': '/integrations/clickpipes/mysql/source/rds_maria' 'title': 'RDS MariaDB 源设置指南' +'doc_type': 'guide' --- import rds_backups from '@site/static/images/integrations/data-ingestion/clickpipes/mysql/source/rds/rds-backups.png'; @@ -18,27 +19,27 @@ import Image from '@theme/IdealImage'; # RDS MariaDB 源设置指南 -这是一个逐步指南,介绍如何配置您的 RDS MariaDB 实例以通过 MySQL ClickPipe 复制其数据。 +这是一个关于如何配置您的 RDS MariaDB 实例以通过 MySQL ClickPipe 复制其数据的逐步指南。
:::info -我们还建议查看 MySQL 常见问题解答 [here](/integrations/data-ingestion/clickpipes/mysql/faq.md)。常见问题解答页面正在积极更新。 +我们还建议您查看 MySQL 常见问题解答 [这里](/integrations/data-ingestion/clickpipes/mysql/faq.md)。常见问题解答页面正在积极更新中。 ::: ## 启用二进制日志保留 {#enable-binlog-retention-rds} -二进制日志是一组日志文件,包含对 MySQL 服务器实例所做的数据修改信息。二进制日志文件是复制所必需的。必须遵循以下两个步骤: +二进制日志是一组包含对 MySQL 服务器实例所做的数据修改信息的日志文件。复制需要二进制日志文件。必须遵循以下两个步骤: -### 1. 通过自动备份启用二进制日志{#enable-binlog-logging-rds} +### 1. 通过自动备份启用二进制日志 {#enable-binlog-logging-rds} -自动备份功能决定 MySQL 的二进制日志是否开启。可以在 AWS 控制台中进行设置: +自动备份功能决定是否为 MySQL 打开或关闭二进制日志。可以在 AWS 控制台中设置: -建议根据复制使用案例将备份保留时间设置为合理的较长值。 +建议根据复制用例将备份保留时间设置为合理较长的值。 -### 2. Binlog 保留时间(小时){#binlog-retention-hours-rds} -Amazon RDS for MariaDB 有不同的方法来设置 binlog 保留时间,即包含更改的 binlog 文件保持的时间。如果在 binlog 文件被删除之前未读取某些更改,复制将无法继续。binlog 保留时间的默认值是 NULL,这意味着不保留二进制日志。 +### 2. Binlog 保留小时数 {#binlog-retention-hours-rds} +Amazon RDS for MariaDB 具有不同的设置 binlog 保留时长的方法,即包含更改的 binlog 文件保留的时间。如果在 binlog 文件被删除之前未读取某些更改,复制将无法继续。binlog 保留小时数的默认值为 NULL,这意味着二进制日志不被保留。 -要指定在 DB 实例上保留二进制日志的小时数,请使用 mysql.rds_set_configuration 函数,设置一个足够长的 binlog 保留时间以进行复制。`24小时`是推荐的最小值。 +要指定在数据库实例上保留二进制日志的小时数,请使用 mysql.rds_set_configuration 函数,并设置足够长的 binlog 保留周期以进行复制。推荐的最小值是 `24 小时`。 ```text mysql=> call mysql.rds_set_configuration('binlog retention hours', 24); @@ -46,41 +47,41 @@ mysql=> call mysql.rds_set_configuration('binlog retention hours', 24); ## 在参数组中配置 binlog 设置 {#binlog-parameter-group-rds} -参数组可以通过点击 RDS 控制台中的 MariaDB 实例,然后导航到 `Configurations` 选项卡找到。 +可以在 RDS 控制台中单击您的 MariaDB 实例,然后导航到 `Configurations` 选项卡找到参数组。 -点击参数组链接后,您将进入参数组链接页面。您会在右上角看到一个编辑按钮: +点击参数组链接后,您将进入参数组链接页面。在右上角您会看到一个“编辑”按钮: -设置 `binlog_format`、`binlog_row_metadata` 和 `binlog_row_image` 需要如下配置: +需要将 `binlog_format`、`binlog_row_metadata` 和 `binlog_row_image` 设置如下: 1. 将 `binlog_format` 设置为 `ROW`。 -2. 将 `binlog_row_metadata` 设置为 `FULL` +2. 将 `binlog_row_metadata` 设置为 `FULL`。 -3. 将 `binlog_row_image` 设置为 `FULL` +3. 将 `binlog_row_image` 设置为 `FULL`。 -接下来,点击右上角的 `Save Changes`。您可能需要重新启动您的实例以使更改生效。如果您在 RDS 实例的 Configurations 选项卡中的参数组链接旁看到 `Pending reboot`,这表明需要重新启动您的实例。 +接下来,点击右上角的 `Save Changes`。您可能需要重启实例以使更改生效。如果在 RDS 实例的 Configurations 选项卡中看到参数组链接旁边有 `Pending reboot`,这表明您的实例需要重启。
:::tip -如果您有一个 MariaDB 集群,以上参数将在 [DB Cluster](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/USER_WorkingWithParamGroups.CreatingCluster.html) 参数组中找到,而不是 DB 实例组中。 +如果您有 MariaDB 集群,上述参数将在 [DB Cluster](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/USER_WorkingWithParamGroups.CreatingCluster.html) 参数组中找到,而不是 DB 实例组。 ::: ## 启用 GTID 模式 {#gtid-mode-rds} -全局事务标识符 (GTIDs) 是分配给每个已提交事务的唯一 ID,这些事务在 MySQL/MariaDB 中。这些标识符简化了 binlog 复制,并使故障排除更简单。MariaDB 默认启用 GTID 模式,因此无需用户操作即可使用。 +全局事务标识符(GTID)是分配给每个已提交事务的唯一 ID。它们简化了 binlog 复制,并使故障排除更加简单。MariaDB 默认启用 GTID 模式,因此无需用户采取任何操作即可使用它。 ## 配置数据库用户 {#configure-database-user-rds} -以管理员用户身份连接到您的 RDS MariaDB 实例并执行以下命令: +以管理员用户连接到您的 RDS MariaDB 实例并执行以下命令: 1. 为 ClickPipes 创建一个专用用户: @@ -88,7 +89,7 @@ mysql=> call mysql.rds_set_configuration('binlog retention hours', 24); CREATE USER 'clickpipes_user'@'host' IDENTIFIED BY 'some-password'; ``` -2. 授予模式权限。以下示例展示了对 `mysql` 数据库的权限。对于您希望复制的每个数据库和主机,重复这些命令: +2. 授予架构权限。以下示例显示了对 `mysql` 数据库的权限。对每个要复制的数据库和主机重复这些命令: ```sql GRANT SELECT ON `mysql`.* TO 'clickpipes_user'@'host'; diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/source/rds_maria.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/source/rds_maria.md.hash index 9f87e3e1d0d..df3c5b5f7db 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/source/rds_maria.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/source/rds_maria.md.hash @@ -1 +1 @@ -9859cd7ba00651e0 +fee54cd24f9d7e02 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/table_resync.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/table_resync.md new file mode 100644 index 00000000000..816c2359db2 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/table_resync.md @@ -0,0 +1,27 @@ +--- +'title': '重新同步特定表' +'description': '在 MySQL ClickPipe 中重新同步特定表' +'slug': '/integrations/clickpipes/mysql/table_resync' +'sidebar_label': '重新同步表' +'doc_type': 'guide' +--- + + +# 重新同步特定表 {#resync-tables} + +在某些场景中,重新同步管道的特定表是非常有用的。一些示例用例可能是在 MySQL 上进行重大架构更改,或者在 ClickHouse 上进行数据重建。 + +虽然通过点击按钮重新同步单个表的功能仍在完善中,但本指南将分享如何在 MySQL ClickPipe 中实现这一目标的步骤。 + +### 1. 从管道中移除表 {#removing-table} + +这可以通过遵循 [表移除指南](./removing_tables) 来完成。 + +### 2. 在 ClickHouse 上截断或删除表 {#truncate-drop-table} + +此步骤是为了避免在下一步再次添加此表时数据重复。您可以通过在 ClickHouse Cloud 中导航到 **SQL 控制台** 选项卡并运行查询来完成此操作。 +注意,我们有验证机制阻止添加已经存在于 ClickHouse 中且不为空的表。 + +### 3. 再次将表添加到 ClickPipe {#add-table-again} + +这可以通过遵循 [表添加指南](./add_table) 来完成。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/table_resync.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/table_resync.md.hash new file mode 100644 index 00000000000..83bc80963d0 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/mysql/table_resync.md.hash @@ -0,0 +1 @@ +f70d349832524a4a diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/object-storage.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/object-storage.md index 2df57db2534..3bb0bbed2b3 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/object-storage.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/object-storage.md @@ -1,8 +1,9 @@ --- -'sidebar_label': 'ClickPipes 用于对象存储' -'description': '无缝连接您的对象存储与 ClickHouse Cloud.' +'sidebar_label': 'ClickPipes for Object Storage' +'description': '无缝连接您的对象存储与 ClickHouse Cloud。' 'slug': '/integrations/clickpipes/object-storage' 'title': '将对象存储与 ClickHouse Cloud 集成' +'doc_type': 'guide' --- import S3svg from '@site/static/images/integrations/logos/amazon_s3_logo.svg'; @@ -25,14 +26,14 @@ import Image from '@theme/IdealImage'; # 将对象存储与 ClickHouse Cloud 集成 -对象存储 ClickPipes 提供了一种简单且弹性的方式,将来自 Amazon S3、Google Cloud Storage、Azure Blob Storage 和 DigitalOcean Spaces 的数据导入到 ClickHouse Cloud。支持一次性和持续性数据输入,并具有精确一次的语义。 +对象存储 ClickPipes 提供了一种简单且具有弹性的方式,可以将来自 Amazon S3、Google Cloud Storage、Azure Blob Storage 和 DigitalOcean Spaces 的数据导入到 ClickHouse Cloud 中。支持一次性和连续的数据导入,并且具有准确一次的语义。 -## 先决条件 {#prerequisite} -您已熟悉 [ClickPipes 简介](./index.md)。 +## 前提条件 {#prerequisite} +您需要熟悉 [ClickPipes 介绍](./index.md)。 ## 创建您的第一个 ClickPipe {#creating-your-first-clickpipe} -1. 在云控制台中,选择左侧菜单上的 `Data Sources` 按钮,并点击“设置 ClickPipe” +1. 在云控制台中,选择左侧菜单中的 `数据源` 按钮,然后点击“设置 ClickPipe” @@ -40,15 +41,15 @@ import Image from '@theme/IdealImage'; -3. 填写表单,为您的 ClickPipe 提供名称、描述(可选)、您的 IAM 角色或凭据以及存储桶 URL。您可以使用类 bash 的通配符指定多个文件。有关更多信息,请 [查看有关路径中使用通配符的文档](#limitations)。 +3. 填写表单,为您的 ClickPipe 提供一个名称、描述(可选)、您的 IAM 角色或凭证以及桶 URL。您可以使用类似 bash 的通配符指定多个文件。有关更多信息,请[参见使用通配符的文档](#limitations)。 -4. UI 将显示指定存储桶中的文件列表。选择您的数据格式(我们目前支持 ClickHouse 格式的子集),并选择是否要启用持续输入 [更多细节如下](#continuous-ingest)。 +4. UI 会显示指定桶中的文件列表。选择您的数据格式(我们目前支持 ClickHouse 格式的子集),并选择是否要启用连续导入 [更多细节如下](#continuous-ingest)。 -5. 在下一步中,您可以选择将数据输入到新的 ClickHouse 表中,或重用现有表。按照屏幕中的说明修改您的表名称、模式和设置。您可以在顶部的示例表中看到更改的实时预览。 +5. 在下一步中,您可以选择是否要将数据导入到新的 ClickHouse 表中,或者重用现有的表。请按照屏幕上的说明修改您的表名、模式和设置。您可以在顶部的示例表中实时预览您的更改。 @@ -56,126 +57,132 @@ import Image from '@theme/IdealImage'; -6. 或者,您可以决定将数据输入到现有的 ClickHouse 表中。在这种情况下,UI 将允许您将字段从源映射到所选目标表中的 ClickHouse 字段。 +6. 另外,您可以决定将数据导入到现有的 ClickHouse 表中。在这种情况下,UI 将允许您将源字段映射到所选目标表中的 ClickHouse 字段。 :::info -您还可以将 [虚拟列](../../sql-reference/table-functions/s3#virtual-columns)(如 `_path` 或 `_size`)映射到字段。 +您还可以将 [虚拟列](../../sql-reference/table-functions/s3#virtual-columns),如 `_path` 或 `_size`,映射到字段。 ::: 7. 最后,您可以为内部 ClickPipes 用户配置权限。 - **权限:** ClickPipes 将为写入目标表创建一个专用用户。您可以使用自定义角色或预定义角色之一选择该内部用户的角色: - - `全访问`:具有对集群的完全访问权限。如果使用目标表的物化视图或字典,则需要此权限。 + **权限:** ClickPipes 将为写入目标表的数据创建一个专用用户。您可以为这个内部用户选择一个角色,使用自定义角色或预定义角色之一: + - `完全访问`:对集群具有完全访问权限。如果您使用物化视图或字典与目标表,必需该权限。 - `仅目标表`:仅对目标表具有 `INSERT` 权限。 -8. 通过点击“完成设置”,系统将注册您的 ClickPipe,您将能够在摘要表中看到它。 +8. 点击“完成设置”,系统将注册您的 ClickPipe,您将能够在汇总表中看到它。 - 摘要表提供了在 ClickHouse 中显示源或目标表的示例数据的控件 + 汇总表提供控件以显示 ClickHouse 中源表或目标表的样本数据 - 以及用于删除 ClickPipe 和显示数据输入作业摘要的控件。 + 以及用于移除 ClickPipe 和显示导入作业摘要的控件。 - + -9. **恭喜!** 您已成功设置第一个 ClickPipe。 如果这是一个流式 ClickPipe,它将持续运行,从您的远程数据源实时输入数据。否则,它将输入批处理并完成。 +Image +9. **恭喜!** 您已成功设置首个 ClickPipe。如果这是一个流式 ClickPipe,它将持续运行,实时从您的远程数据源导入数据。否则,它会导入批次并完成。 ## 支持的数据源 {#supported-data-sources} -| 名称 | Logo | 类型 | 状态 | 描述 | -|----------------------|-----|-------------|-------|---------------------------------------------------------------------------------------------| -| Amazon S3 ||对象存储 | 稳定 | 配置 ClickPipes 从对象存储中输入大量数据。 | -| Google Cloud Storage ||对象存储 | 稳定 | 配置 ClickPipes 从对象存储中输入大量数据。 | -| DigitalOcean Spaces | | 对象存储 | 稳定 | 配置 ClickPipes 从对象存储中输入大量数据。 | -| Azure Blob Storage | | 对象存储 | 私有测试版 | 配置 ClickPipes 从对象存储中输入大量数据。 | +| 名称 | Logo | 类型 | 状态 | 描述 | +|----------------------|------|--------------|-----------------|------------------------------------------------------------------------------------------------| +| Amazon S3 | | 对象存储 | 稳定 | 配置 ClickPipes 从对象存储导入大量数据。 | +| Google Cloud Storage | | 对象存储 | 稳定 | 配置 ClickPipes 从对象存储导入大量数据。 | +| DigitalOcean Spaces | | 对象存储 | 稳定 | 配置 ClickPipes 从对象存储导入大量数据。 | +| Azure Blob Storage | | 对象存储 | 稳定 | 配置 ClickPipes 从对象存储导入大量数据。 | -更多连接程序将添加到 ClickPipes,您可以通过 [联系我们](https://clickhouse.com/company/contact?loc=clickpipes) 了解更多信息。 +更多连接器将添加到 ClickPipes,您可以通过 [联系我们](https://clickhouse.com/company/contact?loc=clickpipes) 了解更多。 ## 支持的数据格式 {#supported-data-formats} -支持的格式有: +支持的格式为: - [JSON](/interfaces/formats/JSON) - [CSV](/interfaces/formats/CSV) - [Parquet](/interfaces/formats/Parquet) - [Avro](/interfaces/formats/Avro) -## 精确一次语义 {#exactly-once-semantics} +## 准确一次的语义 {#exactly-once-semantics} -在输入大型数据集时可能会出现各种类型的故障,这可能导致部分插入或重复数据。对象存储 ClickPipes 具有抗插入失败的弹性,并提供精确一次的语义。这是通过使用临时“暂存”表来实现的。数据首先插入暂存表中。如果插入过程中出现问题,可以截断暂存表并从干净的状态重试插入。只有在插入完成并成功后,暂存表中的分区才会移动到目标表中。要了解有关该策略的更多信息,请查看 [这篇博客文章](https://clickhouse.com/blog/supercharge-your-clickhouse-data-loads-part3)。 +在导入大型数据集时,可能会发生各种类型的故障,这可能导致部分插入或重复数据。对象存储 ClickPipes 对插入失败具有弹性,并提供准确一次的语义。这是通过使用临时“暂存”表实现的。数据首先插入到暂存表中。如果此插入出现问题,则可以截断暂存表并从干净的状态重新尝试插入。只有在插入完成并成功后,暂存表中的分区才会移动到目标表中。要了解更多有关此策略的信息,请查看 [这篇博客文章](https://clickhouse.com/blog/supercharge-your-clickhouse-data-loads-part3)。 ### 视图支持 {#view-support} -目标表上的物化视图也受到支持。ClickPipes 将为目标表创建暂存表,以及任何依赖的物化视图。 +目标表上的物化视图也受支持。ClickPipes 将为目标表创建暂存表,以及任何依赖的物化视图。 -我们不会为非物化视图创建暂存表。这意味着如果您有一个目标表和一个或多个下游物化视图,那么这些物化视图应避免通过目标表的视图选择数据。否则,您可能会发现物化视图中缺少数据。 +我们不会为非物化视图创建暂存表。这意味着如果您有一个目标表,有一个或多个下游的物化视图,则这些物化视图应避免通过目标表中的视图选择数据。否则,您可能会发现物化视图中缺少数据。 -## 扩展性 {#scaling} +## 扩展 {#scaling} -对象存储 ClickPipes 的规模基于由 [配置的垂直自动扩展设置](/manage/scaling#configuring-vertical-auto-scaling) 确定的最小 ClickHouse 服务大小。ClickPipe 的大小在创建管道时确定。对 ClickHouse 服务设置的后续更改不会影响 ClickPipe 的大小。 +对象存储 ClickPipes 的扩展基于通过 [配置的垂直自动调整设置](/manage/scaling#configuring-vertical-auto-scaling) 确定的最小 ClickHouse 服务大小。ClickPipe 的大小在管道创建时确定。随后的 ClickHouse 服务设置更改将不会影响 ClickPipe 大小。 -为了提高大型输入作业的吞吐量,我们建议在创建 ClickPipe 之前扩展 ClickHouse 服务。 +为了提高大导入作业的吞吐量,我们建议在创建 ClickPipe 之前扩展 ClickHouse 服务。 ## 限制 {#limitations} -- 对目标表、其物化视图(包括级联物化视图)或物化视图的目标表的任何更改都可能导致临时错误,这将被重试。为了获得最佳结果,我们建议停止管道,进行必要的修改,然后重新启动管道,以便变更被采纳并避免错误。 -- 支持的视图类型存在限制。有关更多信息,请阅读 [精确一次语义](#exactly-once-semantics) 和 [视图支持](#view-support) 部分。 -- 对于在 GCP 或 Azure 部署的 ClickHouse Cloud 实例,不支持 S3 ClickPipes 的角色身份验证。仅支持 AWS ClickHouse Cloud 实例。 -- ClickPipes 仅会尝试输入大小为 10GB 或更小的对象。如果文件大于 10GB,则会将错误追加到 ClickPipes 专用错误表中。 -- 在包含超过 10 万个文件的容器上,Azure Blob Storage 管道的持续输入将有约 10-15 秒的延迟来检测新文件。延迟会随着文件数量的增加而增加。 -- S3 / GCS ClickPipes **不** 与 [S3 表函数](/sql-reference/table-functions/s3) 共享列表语法,也不与 [AzureBlobStorage 表函数](/sql-reference/table-functions/azureBlobStorage) 共享。 +- 对目标表、其物化视图(包括级联物化视图)或物化视图的目标表的任何更改都可能导致临时错误并会重试。为了获得最佳结果,我们建议停止管道,进行必要的修改,然后重新启动管道以让更改被采纳并避免错误。 +- 对支持的视图类型有一些限制。请阅读有关 [准确一次的语义](#exactly-once-semantics) 和 [视图支持](#view-support) 的部分以获取更多信息。 +- 对于在 GCP 或 Azure 部署的 ClickHouse Cloud 实例,S3 ClickPipes 不支持角色认证。仅在 AWS ClickHouse Cloud 实例中支持。 +- ClickPipes 仅尝试导入大小为 10GB 或更小的对象。如果文件超过 10GB,错误将被附加到 ClickPipes 的专用错误表中。 +- 具有连续导入的 Azure Blob Storage 管道在文件超过 100,000 个的容器中将具有大约 10-15 秒的延迟来检测新文件。延迟随文件数量增加。 +- 对象存储 ClickPipes **不** 与 [S3 表函数](/sql-reference/table-functions/s3) 共享列出语法,也不与使用 [AzureBlobStorage 表函数](/sql-reference/table-functions/azureBlobStorage) 的 Azure 共享。 - `?` — 替代任何单个字符 - - `*` — 替代任何数量的任何字符,包括空字符串 - - `**` — 替代任何数量的任何字符,包括空字符串 + - `*` — 替代任何数量的字符,包括空字符串 + - `**` — 替代任何数量的字符,包括空字符串 :::note -这是有效路径(对于 S3): +这是一个有效的路径(对于 S3): https://datasets-documentation.s3.eu-west-3.amazonaws.com/http/**.ndjson.gz -这不是有效路径。`{N..M}` 在 ClickPipes 中不受支持。 +这是一个无效的路径。 `{N..M}` 在 ClickPipes 中不受支持。 https://datasets-documentation.s3.eu-west-3.amazonaws.com/http/{documents-01,documents-02}.ndjson.gz ::: -## 持续输入 {#continuous-ingest} -ClickPipes 支持来自 S3、GCS、Azure Blob Storage 和 DigitalOcean Spaces 的持续输入。当启用时,ClickPipes 会连续从指定路径输入数据,并以每 30 秒一次的速度轮询新文件。然而,新文件必须在字典上大于上一个输入的文件。这意味着它们的命名方式必须定义输入顺序。例如,文件命名为 `file1`、`file2`、`file3` 等,将按顺序输入。如果添加了一个名为 `file0` 的新文件,ClickPipes 将不会输入它,因为它在字典上并不大于上一个输入的文件。 +## 连续导入 {#continuous-ingest} +ClickPipes 支持从 S3、GCS、Azure Blob Storage 和 DigitalOcean Spaces 进行连续导入。当启用时,ClickPipes 持续从指定路径导入数据,并以每 30 秒的频率轮询新文件。然而,新文件必须在字典上大于最后一个导入的文件。这意味着它们必须以某种方式命名,以定义导入顺序。例如,命名为 `file1`、`file2`、`file3` 等文件将按顺序导入。如果添加一个名称为 `file0` 的新文件,ClickPipes 将不会导入它,因为它没有大于最后一个导入文件的字典。 -## 存档表 {#archive-table} -ClickPipes 将创建一个与目标表并列的表,后缀为 `s3_clickpipe__archive`。该表将包含 ClickPipe 已输入的所有文件的列表。该表用于在输入过程中跟踪文件,并可以用来验证文件是否已输入。存档表具有 7 天的 [TTL](/engines/table-engines/mergetree-family/mergetree#table_engine-mergetree-ttl)。 +## 归档表 {#archive-table} +ClickPipes 会在您的目标表旁边创建一个后缀为 `s3_clickpipe__archive` 的表。该表将包含 ClickPipe 导入的所有文件的列表。该表用于在导入过程中跟踪文件,并可用于验证文件是否已导入。归档表的 [TTL](/engines/table-engines/mergetree-family/mergetree#table_engine-mergetree-ttl) 为 7 天。 :::note -这些表不会通过 ClickHouse Cloud SQL 控制台可见,您需要通过外部客户端连接,可以使用 HTTPS 或原生连接来读取它们。 +这些表不会通过 ClickHouse Cloud SQL 控制台可见,您需要通过外部客户端连接,无论是通过 HTTPS 还是原生连接来读取它们。 ::: ## 身份验证 {#authentication} ### S3 {#s3} -您可以在没有配置的情况下访问公共存储桶,对于受保护的存储桶,您可以使用 [IAM 凭据](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html) 或 [IAM 角色](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles.html)。要使用 IAM 角色,您需要按照 [本指南](/cloud/security/secure-s3) 中的说明创建 IAM 角色。在创建后复制新 IAM 角色的 Arn 并将其粘贴到 ClickPipe 配置中作为“IAM ARN 角色”。 +支持公开访问和受保护的 S3 存储桶。 + +公共存储桶需要在其策略中允许 `s3:GetObject` 和 `s3:ListBucket` 两个操作。 + +受保护的存储桶可以使用 [IAM 凭证](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html) 或 [IAM 角色](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles.html) 进行访问。 +要使用 IAM 角色,您需要按照 [本指南](/cloud/security/secure-s3) 中指定的方式创建 IAM 角色。创建后复制新 IAM 角色的 Arn 并将其粘贴到 ClickPipe 配置中的“IAM ARN 角色”。 ### GCS {#gcs} -与 S3 类似,您可以在没有配置的情况下访问公共存储桶,对于受保护的存储桶,您可以使用 [HMAC 密钥](https://cloud.google.com/storage/docs/authentication/managing-hmackeys) 替代 AWS IAM 凭据。您可以阅读 Google Cloud 关于 [如何设置此类密钥](https://cloud.google.com/storage/docs/authentication/hmackeys) 的指南。 +与 S3 类似,您可以在没有配置的情况下访问公共存储桶,受保护的存储桶可以使用 [HMAC 密钥](https://cloud.google.com/storage/docs/authentication/managing-hmackeys),代替 AWS IAM 凭证。您可以阅读 Google Cloud 的 [如何设置该密钥](https://cloud.google.com/storage/docs/authentication/hmackeys) 的指南。 -GCS 的服务账户不直接受支持。必须在对非公共存储桶进行身份验证时使用 HMAC(IAM)凭据。 -附加到 HMAC 凭据的服务账户权限应为 `storage.objects.list` 和 `storage.objects.get`。 +GCS 的服务账户不直接支持。在认证非公开存储桶时,必须使用 HMAC(IAM)凭证。 +与 HMAC 凭证相关的服务账户权限应为 `storage.objects.list` 和 `storage.objects.get`。 ### DigitalOcean Spaces {#dospaces} -目前仅支持受保护的 DigitalOcean 空间存储桶。您需要“访问密钥”和“秘密密钥”来访问存储桶及其文件。您可以阅读 [本指南](https://docs.digitalocean.com/products/spaces/how-to/manage-access/) 了解如何创建访问密钥。 +目前仅支持受保护的 DigitalOcean 存储桶。您需要一个“访问密钥”和一个“秘密密钥”才能访问存储桶及其文件。您可以阅读 [本指南](https://docs.digitalocean.com/products/spaces/how-to/manage-access/) 了解如何创建访问密钥。 ### Azure Blob Storage {#azureblobstorage} -目前仅支持受保护的 Azure Blob Storage 存储桶。身份验证通过连接字符串完成,该字符串支持访问密钥和共享密钥。有关更多信息,请阅读 [本指南](https://learn.microsoft.com/en-us/azure/storage/common/storage-configure-connection-string)。 +目前仅支持受保护的 Azure Blob Storage 存储桶。通过连接字符串进行身份验证,支持访问密钥和共享密钥。有关更多信息,请阅读 [本指南](https://learn.microsoft.com/en-us/azure/storage/common/storage-configure-connection-string)。 ## 常见问题解答 {#faq} -- **ClickPipes 支持以 `gs://` 为前缀的 GCS 存储桶吗?** +- **ClickPipes 是否支持以 `gs://` 前缀开头的 GCS 存储桶?** -不支持。出于互操作性原因,我们要求您用 `https://storage.googleapis.com/`替换您的 `gs://` 存储桶前缀。 +不。出于互操作性原因,我们请求您将 `gs://` 存储桶前缀替换为 `https://storage.googleapis.com/`。 -- **GCS 公共存储桶需要什么权限?** +- **GCS 公开存储桶需要什么权限?** -`allUsers` 需要适当的角色分配。在存储桶级别必须授予 `roles/storage.objectViewer` 角色。该角色提供 `storage.objects.list` 权限,允许 ClickPipes 列出存储桶中的所有对象,这是注册和输入所必需的。该角色还包括 `storage.objects.get` 权限,这对于读取或下载存储桶中的单个对象是必需的。有关更多信息,请参阅 [Google Cloud 访问控制](https://cloud.google.com/storage/docs/access-control/iam-roles)。 +`allUsers` 需要适当的角色分配。必须在存储桶级别授予 `roles/storage.objectViewer` 角色。此角色提供 `storage.objects.list` 权限,允许 ClickPipes 列出存储桶中的所有对象,这是入驻和导入所需的。此角色还包括 `storage.objects.get` 权限,这对于读取或下载存储桶中的单个对象是必需的。请参见 [Google Cloud 访问控制](https://cloud.google.com/storage/docs/access-control/iam-roles) 获取更多信息。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/object-storage.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/object-storage.md.hash index fa8ac2e33d7..8a191929646 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/object-storage.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/object-storage.md.hash @@ -1 +1 @@ -c437c0207d5644fb +30307a0ec147172f diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/add_table.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/add_table.md index b4100afccf1..37e791ebfd3 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/add_table.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/add_table.md @@ -1,9 +1,10 @@ --- 'title': '将特定表添加到 ClickPipe' -'description': '描述将特定表添加到 ClickPipe 所需的步骤。' +'description': '描述将特定表添加到 ClickPipe 的步骤。' 'sidebar_label': '添加表' 'slug': '/integrations/clickpipes/postgres/add_table' 'show_title': false +'doc_type': 'guide' --- import Image from '@theme/IdealImage'; @@ -12,17 +13,21 @@ import add_table from '@site/static/images/integrations/data-ingestion/clickpipe # 将特定表添加到 ClickPipe -在某些情况下,将特定表添加到管道是有用的。当你的事务或分析工作负载规模扩大时,这变得常见。 +在某些场景中,将特定表添加到管道是很有用的。随着事务或分析工作负载的扩展,这成为一种常见的需求。 ## 将特定表添加到 ClickPipe 的步骤 {#add-tables-steps} -可以通过以下步骤完成: -1. [暂停](./pause_and_resume.md)管道。 -2. 点击“编辑表设置”。 -3. 定位你的表 - 可以通过在搜索栏中搜索来完成。 -4. 通过点击复选框选择表。 +可以按照以下步骤进行操作: +1. [暂停](./pause_and_resume.md) 管道。 +2. 点击编辑表设置。 +3. 找到您的表 - 可以通过在搜索栏中搜索来完成。 +4. 通过点击复选框选择该表。
5. 点击更新。 -6. 更新成功后,管道将按顺序显示 `Setup`、`Snapshot` 和 `Running` 状态。表的初始加载可以在 **Tables** 标签中跟踪。 +6. 更新成功后,管道将依次显示状态 `Setup`、`Snapshot` 和 `Running`。可以在 **Tables** 标签页中跟踪表的初始加载情况。 + +:::info +现有表的 CDC 在新表的快照完成后会自动恢复。 +::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/add_table.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/add_table.md.hash index 95b09e85649..b092a6a0f8c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/add_table.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/add_table.md.hash @@ -1 +1 @@ -e5dae695fa594f88 +50c7a9faae097393 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/controlling_sync.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/controlling_sync.md new file mode 100644 index 00000000000..e0d81b0f676 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/controlling_sync.md @@ -0,0 +1,65 @@ +--- +'title': '控制 Postgres ClickPipe 的同步' +'description': '用于控制 Postgres ClickPipe 同步的文档' +'slug': '/integrations/clickpipes/postgres/sync_control' +'sidebar_label': '控制同步' +'doc_type': 'guide' +--- + +import edit_sync_button from '@site/static/images/integrations/data-ingestion/clickpipes/postgres/edit_sync_button.png' +import create_sync_settings from '@site/static/images/integrations/data-ingestion/clickpipes/postgres/create_sync_settings.png' +import edit_sync_settings from '@site/static/images/integrations/data-ingestion/clickpipes/postgres/sync_settings_edit.png' +import cdc_syncs from '@site/static/images/integrations/data-ingestion/clickpipes/postgres/cdc_syncs.png' +import Image from '@theme/IdealImage'; + +This document describes how to control the sync of a Postgres ClickPipe when the ClickPipe is in **CDC (Running) mode**. + +## Overview {#overview} + +Database ClickPipes have an architecture that consists of two parallel processes - pulling from the source database and pushing to the target database. The pulling process is controlled by a sync configuration that defines how often the data should be pulled and how much data should be pulled at a time. By "at a time", we mean one batch - since the ClickPipe pulls and pushes data in batches. + +There are two main ways to control the sync of a Postgres ClickPipe. The ClickPipe will start pushing when one of the below settings kicks in. + +### Sync interval {#interval} + +管道的同步间隔是 ClickPipe 从源数据库拉取记录的时间量(以秒为单位)。推送的数据到 ClickHouse 的时间不包括在这个间隔内。 + +默认值是 **1分钟**。 +同步间隔可以设置为任何正整数值,但建议保持在10秒以上。 + +### Pull batch size {#batch-size} + +拉取批次大小是 ClickPipe 在一个批次中从源数据库拉取的记录数量。记录包括在管道中表上进行的插入、更新和删除。 + +默认情况下为 **100,000** 条记录。 +安全的最大值是 1000 万。 + +### An exception: Long-running transactions on source {#transactions} + +当在源数据库上运行事务时,ClickPipe 会等待直到收到该事务的 COMMIT 后才继续。这将 **覆盖** 同步间隔和拉取批次大小。 + +### Configuring sync settings {#configuring} + +您可以在创建 ClickPipe 时或编辑现有 ClickPipe 时设置同步间隔和拉取批次大小。 +在创建 ClickPipe 时,可以在创建向导的第二步看到,如下所示: + + + +在编辑现有 ClickPipe 时,您可以前往管道的 **设置** 标签,暂停管道,然后点击这里的 **配置**: + + + +这将打开一个侧边栏,显示同步设置,您可以在这里更改同步间隔和拉取批次大小: + + + +### Tweaking the sync settings to help with replication slot growth {#tweaking} + +让我们讨论如何使用这些设置来处理 CDC 管道的大型复制槽。 +推送到 ClickHouse 的时间不会随从源数据库拉取的时间线性缩放。这可以利用来减小大型复制槽的大小。 +通过增加同步间隔和拉取批次大小,ClickPipe 将一次性从源数据库拉取大量数据,然后再推送到 ClickHouse。 + +### Monitoring sync control behaviour {#monitoring} +您可以在 ClickPipe 的 **指标** 标签中的 **CDC Syncs** 表中查看每个批次所花费的时间。请注意,这里的持续时间包括推送时间,并且如果没有传入行,ClickPipe 会等待,等待时间也包括在持续时间内。 + + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/controlling_sync.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/controlling_sync.md.hash new file mode 100644 index 00000000000..03aed25eaa7 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/controlling_sync.md.hash @@ -0,0 +1 @@ +8704d11dcd47d2b9 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/deduplication.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/deduplication.md index 4c59143ab08..652c4abcb10 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/deduplication.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/deduplication.md @@ -1,28 +1,29 @@ --- 'sidebar_label': '去重策略' -'description': '处理重复和已删除的行。' +'description': '处理重复和删除的行。' 'slug': '/integrations/clickpipes/postgres/deduplication' 'title': '去重策略 (使用 CDC)' +'doc_type': 'guide' --- import clickpipes_initial_load from '@site/static/images/integrations/data-ingestion/clickpipes/postgres/postgres-cdc-initial-load.png'; import Image from '@theme/IdealImage'; -更新和删除从 Postgres 复制到 ClickHouse 的操作由于其数据存储结构和复制过程而导致 ClickHouse 中出现重复行。本页面介绍了为什么会发生这种情况以及在 ClickHouse 中处理重复项的策略。 +更新和删除从 Postgres 复制到 ClickHouse 导致 ClickHouse 中出现重复行,这是由于其数据存储结构和复制过程造成的。该页面涵盖了为什么会发生这种情况以及在 ClickHouse 中处理重复的策略。 -## 数据是如何被复制的? {#how-does-data-get-replicated} +## 数据如何被复制? {#how-does-data-get-replicated} ### PostgreSQL 逻辑解码 {#PostgreSQL-logical-decoding} -ClickPipes 使用 [Postgres 逻辑解码](https://www.pgedge.com/blog/logical-replication-evolution-in-chronological-order-clustering-solution-built-around-logical-replication) 来实时消费在 Postgres 中发生的变化。Postgres 中的逻辑解码过程使得像 ClickPipes 这样的客户端能够以人类可读的格式接收变化,即一系列的 INSERT、UPDATE 和 DELETE。 +ClickPipes 使用 [Postgres 逻辑解码](https://www.pgedge.com/blog/logical-replication-evolution-in-chronological-order-clustering-solution-built-around-logical-replication) 来消费在 Postgres 中发生的更改。Postgres 中的逻辑解码过程使得像 ClickPipes 这样的客户端能够以人类可读的格式接收更改,即一系列的 INSERT、UPDATE 和 DELETE。 ### ReplacingMergeTree {#replacingmergetree} -ClickPipes 将 Postgres 表映射到 ClickHouse,使用 [ReplacingMergeTree](/engines/table-engines/mergetree-family/replacingmergetree) 引擎。ClickHouse 在仅追加的工作负载中表现最佳,不建议频繁的 UPDATE 操作。这就是 ReplacingMergeTree 特别强大的地方。 +ClickPipes 使用 [ReplacingMergeTree](/engines/table-engines/mergetree-family/replacingmergetree) 引擎将 Postgres 表映射到 ClickHouse。ClickHouse 在处理仅追加工作负载时表现最好,并且不建议频繁的 UPDATE。这也是 ReplacingMergeTree 特别强大的地方。 -使用 ReplacingMergeTree 时,更新被建模为行的插入,其具有更新版本 (`_peerdb_version`) ,而删除则作为具有更新版本且 `_peerdb_is_deleted` 标记为 true 的插入。ReplacingMergeTree 引擎在后台去重/合并数据,并保留给定主键(id)的最新行版本,从而高效处理作为版本化插入的 UPDATE 和 DELETE 操作。 +使用 ReplacingMergeTree,更新被建模为带有新版本(`_peerdb_version`)的行插入,而删除则是带有新版本并且 `_peerdb_is_deleted` 标记为 true 的插入。ReplacingMergeTree 引擎在后台对数据进行去重复/合并,并为给定主键(id)保留最新版本的行,从而实现对 UPDATE 和 DELETE 作为版本化插入的有效处理。 -下面是由 ClickPipes 执行的 CREATE Table 语句的示例,用于在 ClickHouse 中创建表。 +下面是 ClickPipes 执行的 CREATE Table 语句的示例,用于在 ClickHouse 中创建表。 ```sql CREATE TABLE users @@ -50,50 +51,50 @@ ORDER BY id; ### 说明性示例 {#illustrative-example} -下面的示例演示了使用 ClickPipes 在 PostgreSQL 和 ClickHouse 之间同步表 `users` 的基本过程。 +下面的插图展示了在 PostgreSQL 和 ClickHouse 之间使用 ClickPipes 同步 `users` 表的基本示例。 -**步骤 1** 显示了 PostgreSQL 和 ClickPipes 中的 2 行的初始快照,并将这 2 行初始加载到 ClickHouse。正如您所观察到的,两行都被按原样复制到 ClickHouse。 +**步骤 1** 显示了 PostgreSQL 中 2 行的初始快照,以及 ClickPipes 将这 2 行初始加载到 ClickHouse。正如您所观察到的,两行被原样复制到 ClickHouse。 -**步骤 2** 显示了在 users 表上的三种操作:插入新行、更新现有行和删除另一行。 +**步骤 2** 显示了对 users 表的三项操作:插入一行新数据,更新一行现有数据,以及删除另一行。 -**步骤 3** 显示了 ClickPipes 如何将 INSERT、UPDATE 和 DELETE 操作复制到 ClickHouse 作为版本化插入。UPDATE 作为 ID 为 2 的行的新版本出现,而 DELETE 作为 ID 为 1 的新版本出现,此版本使用 `_is_deleted` 标记为 true。因此,ClickHouse 的行数比 PostgreSQL 多出三行。 +**步骤 3** 显示了 ClickPipes 如何将 INSERT、UPDATE 和 DELETE 操作作为版本化插入复制到 ClickHouse。UPDATE 作为 ID 为 2 的行的新版本出现,而 DELETE 作为 ID 为 1 的新版本出现,并使用 `_is_deleted` 标记为 true。因此,ClickHouse 相对于 PostgreSQL 多出了三条行。 -因此,执行简单查询如 `SELECT count(*) FROM users;` 可能会在 ClickHouse 和 PostgreSQL 中产生不同的结果。根据 [ClickHouse 合并文档](/merges#replacing-merges),过时的行版本最终会在合并过程中被丢弃。然而,这个合并的时机是不可预测的,这意味着 ClickHouse 中的查询可能会在合并发生之前返回不一致的结果。 +结果,运行简单查询 `SELECT count(*) FROM users;` 可能在 ClickHouse 和 PostgreSQL 中产生不同的结果。根据 [ClickHouse 合并文档](/merges#replacing-merges),过时的行版本最终会在合并过程中被丢弃。然而,这一合并的时机无法预测,意味着在发生合并之前,ClickHouse 中的查询可能返回不一致的结果。 -我们如何确保 ClickHouse 和 PostgreSQL 中的查询结果相同? +我们如何确保 ClickHouse 和 PostgreSQL 中查询结果相同? -### 使用 FINAL 关键字去重 {#deduplicate-using-final-keyword} +### 使用 FINAL 关键字进行去重 {#deduplicate-using-final-keyword} -在 ClickHouse 查询中去重数据的推荐方式是使用 [FINAL 修饰符.](/sql-reference/statements/select/from#final-modifier) 这确保仅返回去重后的行。 +在 ClickHouse 查询中去重数据的推荐方式是使用 [FINAL 修饰符](/sql-reference/statements/select/from#final-modifier)。这确保仅返回去重后的行。 -让我们看看如何将其应用于三个不同的查询。 +让我们看一下如何将其应用到三个不同的查询中。 _请注意以下查询中的 WHERE 子句,用于过滤掉已删除的行。_ - **简单计数查询**:计算帖子数量。 -这是您可以运行的最简单的查询,以检查同步是否顺利。两个查询应返回相同的计数。 +这是您可以运行的最简单的查询,用于检查同步是否正常。两个查询应返回相同的计数。 ```sql -- PostgreSQL SELECT count(*) FROM posts; -- ClickHouse -SELECT count(*) FROM posts FINAL where _peerdb_is_deleted=0; +SELECT count(*) FROM posts FINAL WHERE _peerdb_is_deleted=0; ``` -- **带 JOIN 的简单聚合**:累计最多浏览量的前 10 个用户。 +- **带 JOIN 的简单聚合**:前 10 个获取最多查看次数的用户。 -这是对单个表的聚合示例。在这里出现重复项将大大影响总和函数的结果。 +这是对单个表进行聚合的示例。这里出现重复会极大影响 sum 函数的结果。 ```sql -- PostgreSQL SELECT sum(p.viewcount) AS viewcount, - p.owneruserid as user_id, - u.displayname as display_name + p.owneruserid AS user_id, + u.displayname AS display_name FROM posts p LEFT JOIN users u ON u.id = p.owneruserid -- highlight-next-line @@ -122,13 +123,13 @@ LIMIT 10 #### FINAL 设置 {#final-setting} -您可以使用 [FINAL 设置](/operations/settings/settings#final) 自动将其应用于查询中的所有表,而不是将 FINAL 修饰符添加到查询中的每个表名。 +您可以使用 [FINAL 设置](/operations/settings/settings#final) 自动将 FINAL 修饰符应用于查询中所有表,而无需将其添加到查询中的每个表名称。 -此设置可以根据每个查询或整个会话来应用。 +此设置可以对每个查询或对整个会话应用。 ```sql -- Per query FINAL setting -SELECT count(*) FROM posts SETTINGS final = 1; +SELECT count(*) FROM posts SETTINGS FINAL = 1; -- Set FINAL for the session SET final = 1; @@ -137,26 +138,26 @@ SELECT count(*) FROM posts; #### 行策略 {#row-policy} -隐藏冗余的 `_peerdb_is_deleted = 0` 过滤器的简单方法是使用 [ROW 策略.](/docs/operations/access-rights#row-policy-management) 下面是一个创建行策略的示例,以从表投票的所有查询中排除已删除的行。 +隐藏冗余的 `_peerdb_is_deleted = 0` 过滤器的一种简单方法是使用 [行策略](/docs/operations/access-rights#row-policy-management)。下面是创建行策略的示例,以在 votes 表上的所有查询中排除已删除的行。 ```sql -- Apply row policy to all users CREATE ROW POLICY cdc_policy ON votes FOR SELECT USING _peerdb_is_deleted = 0 TO ALL; ``` -> 行策略适用于用户和角色列表。在这个例子中,它适用于所有用户和角色。这可以调整为仅适用于特定用户或角色。 +> 行策略应用于用户和角色的列表。在这个例子中,它应用于所有用户和角色。这可以调整为仅针对特定用户或角色。 -### 像与 Postgres 一样查询 {#query-like-with-postgres} +### 与 Postgres 类似的查询 {#query-like-with-postgres} -将分析数据集从 PostgreSQL 迁移到 ClickHouse 通常需要修改应用程序查询以考虑数据处理和查询执行的差异。 +将分析数据集从 PostgreSQL 迁移到 ClickHouse 通常需要修改应用程序查询,以考虑数据处理和查询执行的差异。 -本节将探讨在保持原始查询不变的同时去重数据的技术。 +本节将探讨在不更改原始查询的情况下去重数据的技术。 #### 视图 {#views} -[视图](/sql-reference/statements/create/view#normal-view) 是隐藏查询中的 FINAL 关键字的好方法,因为它们不存储任何数据,而是每次访问时从另一个表中读取。 +[视图](/sql-reference/statements/create/view#normal-view) 是隐藏查询中的 FINAL 关键字的好方法,因为它们不存储任何数据,只是在每次访问时从另一个表读取。 -下面是为 ClickHouse 中的数据库中每个表创建视图的示例,带有 FINAL 关键字和删除行的过滤器。 +下面是创建我们的 ClickHouse 数据库中每个表的视图的示例,带有 FINAL 关键字和已删除行的过滤器。 ```sql CREATE VIEW posts_view AS SELECT * FROM posts FINAL WHERE _peerdb_is_deleted=0; @@ -165,7 +166,7 @@ CREATE VIEW votes_view AS SELECT * FROM votes FINAL WHERE _peerdb_is_deleted=0; CREATE VIEW comments_view AS SELECT * FROM comments FINAL WHERE _peerdb_is_deleted=0; ``` -然后,我们可以使用在 PostgreSQL 中使用的相同查询查询这些视图。 +然后,我们可以使用在 PostgreSQL 中使用的相同查询来查询视图。 ```sql -- Most viewed posts @@ -181,11 +182,11 @@ LIMIT 10 #### 可刷新的物化视图 {#refreshable-material-view} -另一种方法是使用 [可刷新的物化视图](/materialized-view/refreshable-materialized-view),该视图可以让您安排查询执行,以去重行并将结果存储在目标表中。每次安排的刷新后,目标表将被最新的查询结果替换。 +另一种方法是使用 [可刷新的物化视图](/materialized-view/refreshable-materialized-view),这使您能够安排查询执行以去重行并将结果存储在目标表中。每次安排刷新的时候,目标表都用最新的查询结果替代。 -此方法的关键优势在于,使用 FINAL 关键字的查询在刷新过程中只运行一次,这消除了对目标表上后续查询使用 FINAL 的需求。 +此方法的关键优势在于使用 FINAL 关键字的查询在刷新过程中仅运行一次,从而消除了对目标表后续查询使用 FINAL 的需要。 -然而,缺点是目标表中的数据仅与最近的刷新保持同步。也就是说,对于许多用例,几分钟到几个小时的刷新间隔可能就足够了。 +然而,缺点是目标表中的数据仅与最近的刷新保持同步。也就是说,对于许多用例,几分钟到几小时的刷新间隔可能足够。 ```sql -- Create deduplicated posts table diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/deduplication.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/deduplication.md.hash index dc4cffb9043..bdce85a34fe 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/deduplication.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/deduplication.md.hash @@ -1 +1 @@ -72d8af3ec2a2730c +8237502218b60921 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/faq.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/faq.md index 6d81813cd81..91959e65be7 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/faq.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/faq.md @@ -1,19 +1,23 @@ --- -'sidebar_label': '常见问题' -'description': '有关 ClickPipes for Postgres 的常见问题。' +'sidebar_label': 'FAQ' +'description': '关于 ClickPipes for Postgres 的常见问题。' 'slug': '/integrations/clickpipes/postgres/faq' 'sidebar_position': 2 'title': 'ClickPipes for Postgres 常见问题解答' +'doc_type': 'reference' --- +import failover_slot from '@site/static/images/integrations/data-ingestion/clickpipes/postgres/failover_slot.png' +import Image from '@theme/IdealImage'; + # ClickPipes for Postgres 常见问题解答 -### 空闲状态如何影响我的 Postgres CDC ClickPipe? {#how-does-idling-affect-my-postgres-cdc-clickpipe} +### 闲置状态如何影响我的 Postgres CDC ClickPipe? {#how-does-idling-affect-my-postgres-cdc-clickpipe} -如果你的 ClickHouse Cloud 服务处于空闲状态,你的 Postgres CDC ClickPipe 将继续同步数据,你的服务将在下一个同步间隔唤醒以处理传入数据。一旦同步完成并达到空闲时间段,你的服务将再次进入空闲状态。 +如果您的 ClickHouse Cloud 服务处于闲置状态,您的 Postgres CDC ClickPipe 将继续同步数据,您的服务将在下一个同步间隔唤醒以处理传入的数据。一旦同步完成并达到闲置期,您的服务将再次进入闲置状态。 -例如,如果你的同步间隔设置为 30 分钟,而你的服务空闲时间设置为 10 分钟,则你的服务每 30 分钟会唤醒并激活 10 分钟,然后再次进入空闲状态。 +举例来说,如果您的同步间隔设置为 30 分钟,而您的服务闲置时间设置为 10 分钟,您的服务将每 30 分钟唤醒一次并活动 10 分钟,然后再次进入闲置状态。 ### ClickPipes 如何处理 Postgres 中的 TOAST 列? {#how-are-toast-columns-handled-in-clickpipes-for-postgres} @@ -21,138 +25,166 @@ ### ClickPipes 如何处理 Postgres 中的生成列? {#how-are-generated-columns-handled-in-clickpipes-for-postgres} -有关更多信息,请参阅 [Postgres 生成列:陷阱和最佳实践](./generated_columns) 页面。 +有关更多信息,请参阅 [Postgres 生成列:注意事项和最佳实践](./generated_columns) 页面。 + +### 表是否需要有主键才能成为 Postgres CDC 的一部分? {#do-tables-need-to-have-primary-keys-to-be-part-of-postgres-cdc} + +为了通过 ClickPipes for Postgres 复制表,表必须定义主键或 [REPLICA IDENTITY](https://www.postgresql.org/docs/current/sql-altertable.html#SQL-ALTERTABLE-REPLICA-IDENTITY)。 -### 表是否需要具有主键才能成为 Postgres CDC 的一部分? {#do-tables-need-to-have-primary-keys-to-be-part-of-postgres-cdc} +- **主键**:最直接的方法是在表上定义主键。这为每一行提供唯一标识符,这对于跟踪更新和删除至关重要。在这种情况下,您可以将 REPLICA IDENTITY 设置为 `DEFAULT`(默认行为)。 +- **副本身份标识**:如果表没有主键,您可以设置副本身份标识。副本身份标识可以设置为 `FULL`,这意味着整个行将用于识别更改。或者,您可以选择如果表上已经存在唯一索引,则将其设置为使用该索引,然后将 REPLICA IDENTITY 设置为 `USING INDEX index_name`。 +要将副本身份标识设置为 FULL,您可以使用以下 SQL 命令: +```sql +ALTER TABLE your_table_name REPLICA IDENTITY FULL; +``` +REPLICA IDENTITY FULL 还启用未更改的 TOAST 列的复制。更多内容请见 [这里](./toast)。 -是的,对于 CDC,因此表必须具有主键或 [REPLICA IDENTITY](https://www.postgresql.org/docs/current/sql-altertable.html#SQL-ALTERTABLE-REPLICA-IDENTITY)。REPLICA IDENTITY 可以设置为 FULL 或配置为使用唯一索引。 +请注意,使用 `REPLICA IDENTITY FULL` 可能会对性能产生影响,也会导致更快的 WAL 增长,特别是对于没有主键且频繁更新或删除的表,因为它需要记录更多数据以反映每个更改。如果您对设置表的主键或副本身份标识有任何疑问或需要帮助,请与我们的支持团队联系以获取指导。 -### 你们支持作为 Postgres CDC 一部分的分区表吗? {#do-you-support-partitioned-tables-as-part-of-postgres-cdc} +重要的是要注意,如果未定义主键或副本身份标识,ClickPipes 将无法复制该表的更改,您可能会在复制过程期间遇到错误。因此,建议在设置 ClickPipe 之前检查您的表模式并确保其满足这些要求。 -是的,分区表开箱即用,只要它们定义了 PRIMARY KEY 或 REPLICA IDENTITY。PRIMARY KEY 和 REPLICA IDENTITY 必须在父表及其分区上都存在。您可以在 [此处](https://blog.peerdb.io/real-time-change-data-capture-for-postgres-partitioned-tables) 阅读更多信息。 +### 您支持作为 Postgres CDC 一部分的分区表吗? {#do-you-support-partitioned-tables-as-part-of-postgres-cdc} -### 我可以连接没有公共 IP 或位于私有网络中的 Postgres 数据库吗? {#can-i-connect-postgres-databases-that-dont-have-a-public-ip-or-are-in-private-networks} +是的,分区表在开箱即用时得到支持,只要它们定义了主键或副本身份标识。主键和副本身份标识必须在父表及其分区中均存在。您可以在 [这里](https://blog.peerdb.io/real-time-change-data-capture-for-postgres-partitioned-tables) 阅读更多有关此方面的信息。 -是的! ClickPipes for Postgres 提供两种连接私有网络中的数据库的方法: +### 我可以连接没有公共 IP 或位于私有网络的 Postgres 数据库吗? {#can-i-connect-postgres-databases-that-dont-have-a-public-ip-or-are-in-private-networks} + +可以! ClickPipes for Postgres 提供两种连接私有网络数据库的方法: 1. **SSH 隧道** - - 对于大多数用例效果良好 - - 请查看设置说明 [这里](/integrations/clickpipes/postgres#adding-your-source-postgres-database-connection) - - 适用于所有区域 + - 适用于大多数用例 + - 有关设置说明,请参见 [这里](/integrations/clickpipes/postgres#adding-your-source-postgres-database-connection) + - 在所有区域均可使用 2. **AWS PrivateLink** - - 在三个 AWS 区域提供: + - 在三个 AWS 区域中可用: - us-east-1 - - us-east-2 + - us-east-2 - eu-central-1 - - 有关详细的设置说明,请参阅我们的 [PrivateLink 文档](/knowledgebase/aws-privatelink-setup-for-clickpipes) - - 在PrivateLink不可用的区域,请使用SSH隧道 + - 有关详细的设置说明,请参见我们的 [PrivateLink 文档](/knowledgebase/aws-privatelink-setup-for-clickpipes) + - 对于未提供 PrivateLink 的区域,请使用 SSH 隧道 + +### 您如何处理 UPDATE 和 DELETE? {#how-do-you-handle-updates-and-deletes} -### 你们如何处理 UPDATE 和 DELETE? {#how-do-you-handle-updates-and-deletes} +ClickPipes for Postgres 捕获 Postgres 中的 INSERT 和 UPDATE 作为在 ClickHouse 中具有不同版本的新行(使用 `_peerdb_` 版本列)。ReplacingMergeTree 表引擎根据排序键(ORDER BY 列)在后台定期执行去重,只保留具有最新 `_peerdb_` 版本的行。 -ClickPipes for Postgres 捕获来自 Postgres 的 INSERTs 和 UPDATEs 作为 ClickHouse 中具有不同版本(使用 `_peerdb_` 版本列)的新行。ReplacingMergeTree 表引擎定期基于排序键(ORDER BY 列)在后台执行去重,仅保留具有最新 `_peerdb_` 版本的行。 +来自 Postgres 的 DELETE 作为标记为已删除的新行传播(使用 `_peerdb_is_deleted` 列)。由于去重过程是异步的,您可能会暂时看到重复项。为了解决此问题,您需要在查询层处理去重。 -来自 Postgres 的 DELETE 被传播为标记为已删除的新行(使用 `_peerdb_is_deleted` 列)。由于去重过程是异步的,你可能会暂时看到重复。为了解决这个问题,你需要在查询层处理去重。 +还要注意,默认情况下,Postgres 在 DELETE 操作期间不会发送不属于主键或副本身份标识的列值。如果您想在 DELETE 操作期间捕获完整的行数据,您可以将 [REPLICA IDENTITY](https://www.postgresql.org/docs/current/sql-altertable.html#SQL-ALTERTABLE-REPLICA-IDENTITY) 设置为 FULL。 有关更多详细信息,请参考: * [ReplacingMergeTree 表引擎最佳实践](https://docs.peerdb.io/bestpractices/clickhouse_datamodeling#replacingmergetree-table-engine) -* [Postgres 到 ClickHouse CDC 内部博客](https://clickhouse.com/blog/postgres-to-clickhouse-data-modeling-tips) +* [Postgres 到 ClickHouse CDC 内部原理博客](https://clickhouse.com/blog/postgres-to-clickhouse-data-modeling-tips) -### 你们支持模式变更吗? {#do-you-support-schema-changes} +### 我可以在 PostgreSQL 中更新主键列吗? {#can-i-update-primary-key-columns-in-postgresql} -有关更多信息,请参阅 [ClickPipes for Postgres:模式更改传播支持](./schema-changes) 页面。 +:::warning +PostgreSQL 中的主键更新不能在 ClickHouse 中被正确重放。 + +此限制存在的原因是 `ReplacingMergeTree` 去重是基于 `ORDER BY` 列(通常与主键对应)进行的。当 PostgreSQL 中的主键被更新时,它在 ClickHouse 中表现为具有不同键的新行,而不是现有行的更新。这可能导致 ClickHouse 表中存在旧的和新的主键值。 +::: -### ClickPipes for Postgres CDC 的费用是什么? {#what-are-the-costs-for-clickpipes-for-postgres-cdc} +请注意,在 PostgreSQL 数据库设计中,更新主键列并不常见,因为主键旨在是不可变的标识符。大多数应用程序通过设计避免主键更新,这使得此限制在典型用例中很少遇到。 -在预览期间,ClickPipes 免费。GA 之后,定价尚未确定。目标是使定价合理,并与外部 ETL 工具相比具有很强的竞争力。 +有一个实验性设置可以启用主键更新处理,但它具有显著的性能影响,并且不建议在未经过仔细考虑的情况下用于生产。 -### 我的复制槽大小在增加或没有减少;可能是什么问题? {#my-replication-slot-size-is-growing-or-not-decreasing-what-might-be-the-issue} +如果您的用例需要在 PostgreSQL 中更新主键列并希望这些更改在 ClickHouse 中正确反映,请通过 [db-integrations-support@clickhouse.com](mailto:db-integrations-support@clickhouse.com) 联系我们的支持团队,讨论您的具体需求和潜在解决方案。 -如果你发现你的 Postgres 复制槽的大小不断增加或没有回落,通常意味着 **WAL(预写日志)记录没有被你的 CDC 管道或复制过程足够快速地消费(或“重放”)**。以下是最常见的原因及其解决方法。 +### 您支持架构更改吗? {#do-you-support-schema-changes} -1. **数据库活动的突然激增** - - 大批量更新、大规模插入或重大模式变更可迅速生成大量 WAL 数据。 - - 复制槽将持有这些 WAL 记录,直到它们被消费,从而导致大小暂时激增。 +有关更多信息,请参阅 [ClickPipes for Postgres:架构更改传播支持](./schema-changes) 页面。 -2. **长时间运行的事务** - - 打开的事务强迫 Postgres 保留自事务开始以来生成的所有 WAL 段,这可能会显著增加槽大小。 - - 将 `statement_timeout` 和 `idle_in_transaction_session_timeout` 设置为合理值,以防止事务无限期保持打开状态: +### ClickPipes for Postgres CDC 的费用是多少? {#what-are-the-costs-for-clickpipes-for-postgres-cdc} + +有关详细定价信息,请参阅 [我们主要计费概述页面上的 ClickPipes for Postgres CDC 定价部分](/cloud/reference/billing/clickpipes)。 + +### 我的复制插槽大小正在增长或没有减少;可能是什么问题? {#my-replication-slot-size-is-growing-or-not-decreasing-what-might-be-the-issue} + +如果您注意到 Postgres 复制插槽的大小持续增加或未下降,这通常意味着 **WAL(预写日志)记录没有被您的 CDC 管道或复制过程快速消费(或“重放”)**。以下是最常见的原因以及如何解决它们。 + +1. **数据库活动的突然激增** + - 大批量更新、批量插入或重大架构更改可以迅速生成大量 WAL 数据。 + - 复制插槽将保存这些 WAL 记录,直到它们被消费,从而导致暂时的规模激增。 + +2. **长时间运行的事务** + - 打开的事务会强制 Postgres 保留自事务开始以来生成的所有 WAL 段,这可能会显著增加插槽大小。 + - 将 `statement_timeout` 和 `idle_in_transaction_session_timeout` 设置为合理值,以防止事务无限期保持开放: ```sql -SELECT +SELECT pid, state, age(now(), xact_start) AS transaction_duration, query AS current_query -FROM +FROM pg_stat_activity -WHERE +WHERE xact_start IS NOT NULL -ORDER BY +ORDER BY age(now(), xact_start) DESC; ``` - 使用此查询识别异常长时间运行的事务。 + 使用此查询识别异常长时间运行的事务。 -3. **维护或工具操作(例如,`pg_repack`)** - - `pg_repack` 等工具可以重写整个表,短时间内生成大量 WAL 数据。 - - 在流量较低的时间段安排这些操作,或在它们运行时密切监控你的 WAL 使用。 +3. **维护或实用程序操作(例如,`pg_repack`)** + - 像 `pg_repack` 这样的工具可以重写整个表,在短时间内生成大量 WAL 数据。 + - 在流量较低的时间进行这些操作,或在它们运行时密切监控您的 WAL 使用情况。 -4. **VACUUM 和 VACUUM ANALYZE** - - 尽管对于数据库健康至关重要,这些操作可能会产生额外的 WAL 流量——尤其是在扫描大表时。 - - 考虑使用自动真空调优参数,或在非高峰期安排手动 VACUUM 操作。 +4. **VACUUM 和 VACUUM ANALYZE** + - 尽管对数据库健康至关重要,这些操作可能会产生额外的 WAL 流量,特别是如果它们扫描大表。 + - 考虑使用 autovacuum 调优参数或在非高峰时段安排手动 VACUUM 操作。 -5. **复制消费者未积极读取该槽** - - 如果你的 CDC 管道(例如 ClickPipes)或其他复制消费者停止、暂停或崩溃,WAL 数据将积累在槽中。 - - 确保你的管道持续运行,并检查日志以获取连接或身份验证错误。 +5. **复制消费者未积极读取槽** + - 如果您的 CDC 管道(例如 ClickPipes)或其他复制消费者停止、暂停或崩溃,WAL 数据将积累在插槽中。 + - 确保您的管道持续运行并检查日志以查看连接或身份验证错误。 -有关此主题的深入探讨,请查看我们的博客文章:[克服 Postgres 逻辑解码的陷阱](https://blog.peerdb.io/overcoming-pitfalls-of-postgres-logical-decoding#heading-beware-of-replication-slot-growth-how-to-monitor-it)。 +有关此主题的深入探讨,可以查看我们的博客文章:[克服 Postgres 逻辑解码的陷阱](https://blog.peerdb.io/overcoming-pitfalls-of-postgres-logical-decoding#heading-beware-of-replication-slot-growth-how-to-monitor-it)。 ### Postgres 数据类型如何映射到 ClickHouse? {#how-are-postgres-data-types-mapped-to-clickhouse} -ClickPipes for Postgres 的目标是在 ClickHouse 端尽可能地原生映射 Postgres 数据类型。本文档提供了每种数据类型及其映射的完整列表:[数据类型矩阵](https://docs.peerdb.io/datatypes/datatype-matrix)。 +ClickPipes for Postgres 旨在尽可能原生地在 ClickHouse 端映射 Postgres 数据类型。此文档提供了每种数据类型及其映射的全面列表:[数据类型矩阵](https://docs.peerdb.io/datatypes/datatype-matrix)。 -### 在从 Postgres 复制数据到 ClickHouse 时,我可以定义自己数据类型的映射吗? {#can-i-define-my-own-data-type-mapping-while-replicating-data-from-postgres-to-clickhouse} +### 我可以在将数据从 Postgres 复制到 ClickHouse 时定义自己的数据类型映射吗? {#can-i-define-my-own-data-type-mapping-while-replicating-data-from-postgres-to-clickhouse} -目前,我们不支持在管道中定义自定义数据类型映射。不过,请注意 ClickPipes 使用的默认数据类型映射是高度原生的。Postgres 中的大多数列类型都尽可能接近映射为 ClickHouse 中的本地等价类型。例如,Postgres 中的整数数组类型在 ClickHouse 中被映射为整数数组类型。 +目前,我们不支持在管道中定义自定义数据类型映射。但是,请注意,ClickPipes 使用的默认数据类型映射是高度原生的。大多数 Postgres 中的列类型在 ClickHouse 中被尽可能接近其原生等效物进行复制。例如,Postgres 中的整数数组类型在 ClickHouse 中被复制为整数数组类型。 ### JSON 和 JSONB 列如何从 Postgres 复制? {#how-are-json-and-jsonb-columns-replicated-from-postgres} -JSON 和 JSONB 列在 ClickHouse 中被复制为字符串类型。由于 ClickHouse 支持原生的 [JSON 类型](/sql-reference/data-types/newjson),你可以在 ClickPipes 表上创建物化视图来执行转换(如有必要)。或者,你可以直接在字符串列上使用 [JSON 函数](/sql-reference/functions/json-functions)。我们正在积极开发一个功能,该功能将 JSON 和 JSONB 列直接复制到 ClickHouse 的 JSON 类型中。该功能预计将在几个月内可用。 +JSON 和 JSONB 列在 ClickHouse 中作为字符串类型进行复制。由于 ClickHouse 支持原生 [JSON 类型](/sql-reference/data-types/newjson),您可以在 ClickPipes 表上创建物化视图来执行翻译,如有需要。或者,您可以直接在字符串列上使用 [JSON 函数](/sql-reference/functions/json-functions)。我们正在积极开发一个功能,可以直接将 JSON 和 JSONB 列复制到 ClickHouse 的 JSON 类型中。预计该功能将在几个月内可用。 -### 当镜像暂停时,插入会发生什么? {#what-happens-to-inserts-when-a-mirror-is-paused} +### 当镜像暂停时插入会发生什么? {#what-happens-to-inserts-when-a-mirror-is-paused} -当你暂停镜像时,消息会在源 Postgres 的复制槽中排队,确保它们被缓冲并不会丢失。然而,暂停和恢复镜像将重新建立连接,具体时间取决于源。 +当您暂停镜像时,消息会在源 Postgres 的复制插槽中排队,确保它们被缓冲并不会丢失。然而,暂停和恢复镜像将重新建立连接,这可能需要一些时间,具体取决于源。 -在此过程中,同步(从 Postgres 提取数据并将其流式传输到 ClickHouse 原始表)和规范化(从原始表到目标表)操作都会中止。然而,它们保留了恢复所需的状态。 +在此过程中,同步(从 Postgres 拉取数据并将其流式传输到 ClickHouse 原始表)和规范化(从原始表到目标表)操作会被中止。然而,它们保留了所需的状态以确保可以持久地恢复。 -- 对于 sync,如果在中途被取消,Postgres 中的 confirmed_flush_lsn 不会推进,因此下一次同步将从与中止任务相同的位置开始,以确保数据一致性。 -- 对于 normalize,ReplacingMergeTree 插入顺序处理去重。 +- 对于同步,如果中途被取消,则 Postgres 中的 confirmed_flush_lsn 不会被推进,因此下一个同步将从与中止的同步相同的位置开始,以确保数据一致性。 +- 对于规范化,ReplacingMergeTree 插入顺序处理去重。 -总之,虽然在暂停期间同步和规范化过程会终止,但这样做是安全的,因为它们可以在没有数据丢失或不一致的情况下恢复。 +总之,虽然在暂停期间同步和规范化过程会被终止,但这样做是安全的,因为它们可以在没有数据丢失或不一致的情况下恢复。 -### ClickPipe 的创建可以自动化或通过 API 或 CLI 完成吗? {#can-clickpipe-creation-be-automated-or-done-via-api-or-cli} +### ClickPipe 创建可以自动化或通过 API 或 CLI 完成吗? {#can-clickpipe-creation-be-automated-or-done-via-api-or-cli} -Postgres ClickPipe 也可以通过 [OpenAPI](https://clickhouse.com/docs/cloud/manage/openapi) 端点创建和管理。该功能处于测试阶段,API 参考可以在 [这里](https://clickhouse.com/docs/cloud/manage/api/swagger#tag/beta) 找到。我们还在积极开发 Terraform 支持以创建 Postgres ClickPipes。 +Postgres ClickPipe 也可以通过 [OpenAPI](https://clickhouse.com/docs/cloud/manage/openapi) 端点创建和管理。该功能正在测试中,API 参考可以在 [这里](https://clickhouse.com/docs/cloud/manage/api/swagger#tag/beta) 找到。我们还在积极开发 Terraform 支持,以创建 Postgres ClickPipes。 ### 我如何加速我的初始加载? {#how-do-i-speed-up-my-initial-load} -你不能加速已经运行的初始加载。然而,你可以通过调整某些设置来优化未来的初始加载。默认情况下,设置配置为 4 个并行线程,分区的快照行数设置为 100,000。这些是高级设置,通常对于大多数用例来说是足够的。 +您不能加速已经运行的初始加载。但是,您可以通过调整某些设置来优化未来的初始加载。默认情况下,这些设置配置为 4 个并行线程,每个分区的快照行数设置为 100,000。这些是高级设置,通常对大多数用例足够。 -对于 Postgres 版本 13 或更低,CTID 范围扫描较慢,这些设置变得更加关键。在这种情况下,请考虑以下流程来提高性能: +对于 PostgreSQL 版本 13 或更低,CTID 范围扫描较慢,这些设置变得更为关键。在这种情况下,请考虑以下过程来提高性能: -1. **删除现有的管道**:这是应用新设置所必需的。 -2. **删除 ClickHouse 上的目标表**:确保删除之前管道创建的表。 -3. **使用优化设置创建新的管道**:通常,将每个分区的快照行数增加到 100 万到 1000 万之间,具体取决于你的特定需求和 Postgres 实例可以处理的负载。 +1. **删除现有管道**:这对于应用新设置是必要的。 +2. **删除 ClickHouse 上的目标表**:确保移除由之前的管道创建的表。 +3. **使用优化的设置创建新的管道**:通常,将每个分区的快照行数增加到 100 万到 1000 万之间,具体取决于您的特定要求以及您的 Postgres 实例可以处理的负载。 -这些调整应该显著提高初始加载的性能,特别是对于较旧的 Postgres 版本。如果你使用的是 Postgres 14 或更高版本,这些设置由于对 CTID 范围扫描的改进而影响较小。 +这些调整应该显著增强初始加载的性能,特别是对于较旧的 Postgres 版本。如果您使用的是 Postgres 14 或更高版本,这些设置的影响较小,因为对 CTID 范围扫描的支持有所改善。 -### 我在设置复制时应该如何范围我的发布? {#how-should-i-scope-my-publications-when-setting-up-replication} +### 在设置复制时,我应该如何界定我的发布范围? {#how-should-i-scope-my-publications-when-setting-up-replication} -你可以让 ClickPipes 管理你的发布(需要额外权限),或自己创建它们。使用 ClickPipes 管理的发布时,当你编辑管道时,我们会自动处理表的添加和删除。如果是自管理,请细心限制你的发布,仅包括你需要复制的表——包括不必要的表将减慢 Postgres WAL 解码。 +您可以让 ClickPipes 管理您的发布(需要额外权限)或自己创建。通过 ClickPipes 管理的发布,我们会在您编辑管道时自动处理表的添加和删除。如果自主管理,请仔细界定您的发布范围,仅包括您需要复制的表——包括不必要的表将减慢 Postgres WAL 解码的速度。 -如果你在发布中包含任何表,请确保它具有主键或 `REPLICA IDENTITY FULL`。如果你有没有主键的表,为所有表创建发布会导致这些表上的 DELETE 和 UPDATE 操作失败。 +如果您在发布中包含任何表,请确保它至少具有主键或 `REPLICA IDENTITY FULL`。如果您有没有主键的表,为所有表创建发布将导致这些表的 DELETE 和 UPDATE 操作失败。 -要识别数据库中没有主键的表,你可以使用以下查询: +要识别数据库中没有主键的表,您可以使用以下查询: ```sql SELECT table_schema, table_name FROM information_schema.tables @@ -164,16 +196,16 @@ WHERE table_schema NOT IN ('information_schema', 'pg_catalog', 'pgq', 'londiste'); ``` -处理没有主键的表时,有两个选项: +在处理没有主键的表时,您有两个选择: 1. **从 ClickPipes 中排除没有主键的表**: - 创建仅包含具有主键的表的发布: + 仅使用具有主键的表创建发布: ```sql CREATE PUBLICATION clickpipes_publication FOR TABLE table_with_primary_key1, table_with_primary_key2, ...; ``` -2. **在 ClickPipes 中包括没有主键的表**: - 如果你想包括没有主键的表,你需要将它们的副本身份更改为 `FULL`。这确保 UPDATE 和 DELETE 操作正常工作: +2. **在 ClickPipes 中包含没有主键的表**: + 如果要包括没有主键的表,则需要将它们的副本身份标识更改为 `FULL`。这确保 UPDATE 和 DELETE 操作能够正常工作: ```sql ALTER TABLE table_without_primary_key1 REPLICA IDENTITY FULL; ALTER TABLE table_without_primary_key2 REPLICA IDENTITY FULL; @@ -181,101 +213,147 @@ CREATE PUBLICATION clickpipes_publication FOR TABLE <...>, <...>; ``` :::tip -如果你手动创建发布,而不是让 ClickPipes 管理它,我们不建议创建 `FOR ALL TABLES` 的发布,这将导致 Postgres 到 ClickPipes 的流量增加(为管道中未包含的其他表发送更改),并降低整体效率。 +如果您手动创建发布而不是让 ClickPipes 管理它,我们不建议创建 `FOR ALL TABLES` 的发布,这会导致更多来自 Postgres 到 ClickPipes 的流量(向其他未在管道中的表发送更改),并降低整体效率。 + +对于手动创建的发布,请在将任何表添加到管道之前,将它们添加到发布中。 +::: -对于手动创建的发布,请在将任何表添加到管道之前,将其添加到发布中。 +:::warning +如果您正在从 Postgres 读取副本/热备份进行复制,您需要在主实例上创建自己的发布,这将自动传播到备份。在这种情况下,ClickPipe 将无法管理发布,因为您无法在备份上创建发布。 ::: -## 推荐的 `max_slot_wal_keep_size` 设置 {#recommended-max_slot_wal_keep_size-settings} +### 推荐的 `max_slot_wal_keep_size` 设置 {#recommended-max_slot_wal_keep_size-settings} -- **最低限度:** 设置 [`max_slot_wal_keep_size`](https://www.postgresql.org/docs/devel/runtime-config-replication.html#GUC-MAX-SLOT-WAL-KEEP-SIZE) 保留至少 **两天** 的 WAL 数据。 -- **对于大型数据库(高交易量):** 保留至少 **2-3 倍** 的每日峰值 WAL 生成量。 -- **对于存储受限的环境:** 保守调整,以 **避免磁盘耗尽**,同时确保复制稳定。 +- **至少:**设置 [`max_slot_wal_keep_size`](https://www.postgresql.org/docs/devel/runtime-config-replication.html#GUC-MAX-SLOT-WAL-KEEP-SIZE) 以保留至少 **两天的** WAL 数据。 +- **对于大型数据库(高事务量):**至少保留 **2-3 倍** 的每天峰值 WAL 生成。 +- **对于存储受限的环境:**适度调整以 **避免磁盘耗尽**,同时确保复制的稳定性。 -### 如何计算正确的值 {#how-to-calculate-the-right-value} +#### 如何计算正确值 {#how-to-calculate-the-right-value} -要确定合适的设置,请测量 WAL 生成速率: +要确定正确的设置,请测量 WAL 生成率: -#### 对于 PostgreSQL 10 及以上版本: {#for-postgresql-10} +##### 对于 PostgreSQL 10+ {#for-postgresql-10} ```sql SELECT pg_wal_lsn_diff(pg_current_wal_insert_lsn(), '0/0') / 1024 / 1024 AS wal_generated_mb; ``` -#### 对于 PostgreSQL 9.6 及以下版本: {#for-postgresql-96-and-below} +##### 对于 PostgreSQL 9.6 及以下版本: {#for-postgresql-96-and-below} ```sql SELECT pg_xlog_location_diff(pg_current_xlog_insert_location(), '0/0') / 1024 / 1024 AS wal_generated_mb; ``` -* 在一天中的不同时间运行上述查询,特别是在高交易期。 +* 在一天中的不同时间运行上述查询,特别是在高交易期间。 * 计算每 24 小时生成多少 WAL。 * 将该数字乘以 2 或 3 以提供足够的保留。 -* 将 `max_slot_wal_keep_size` 设置为结果值(以 MB 或 GB 为单位)。 +* 将 `max_slot_wal_keep_size` 设置为以 MB 或 GB 为单位的结果值。 -#### 示例: {#example} +##### 示例 {#example} -如果你的数据库每天生成 100 GB 的 WAL,请设置: +如果您的数据库每天生成 100 GB 的 WAL,请设置: ```sql max_slot_wal_keep_size = 200GB ``` -### 我的复制槽无效。我该怎么办? {#my-replication-slot-is-invalidated-what-should-i-do} +### 我在日志中看到 ReceiveMessage EOF 错误。这意味着什么? {#im-seeing-a-receivemessage-eof-error-in-the-logs-what-does-it-mean} -恢复 ClickPipe 的唯一方法是触发重新同步,你可以在设置页面进行操作。 +`ReceiveMessage` 是 Postgres 逻辑解码协议中的一个函数,用于从复制流中读取消息。EOF(文件结束)错误表示在尝试从复制流中读取时,与 Postgres 服务器的连接意外关闭。 -复制槽无效的最常见原因是你的 PostgreSQL 数据库上低的 `max_slot_wal_keep_size` 设置(例如,几 GB)。我们建议增加这个值。[请参考这一部分](/integrations/clickpipes/postgres/faq#recommended-max_slot_wal_keep_size-settings) 来调优 `max_slot_wal_keep_size`。理想情况下,它应该至少设置为 200GB,以防止复制槽无效。 +这是一种可恢复的,完全无害的错误。ClickPipes 会自动尝试重新连接并恢复复制过程。 -在少数情况下,即使未配置 `max_slot_wal_keep_size` 也可能发生此问题。这可能是由于 PostgreSQL 中的一种复杂且罕见的错误,尽管原因仍不明确。 +可能出现这种情况的原因有几个: +- **低 wal_sender_timeout:** 请确保 `wal_sender_timeout` 至少为 5 分钟或更长。此设置控制服务器在关闭连接之前等待来自客户端的响应的时间。如果超时时间过短,可能会导致过早断开连接。 +- **网络问题:**临时网络中断可能导致连接中断。 +- **Postgres 服务器重启:**如果 Postgres 服务器重启或崩溃,则连接将丢失。 -## 我在 ClickHouse 上看到内存不足(OOM)现象,而我的 ClickPipe 正在摄取数据。你能帮忙吗? {#i-am-seeing-out-of-memory-ooms-on-clickhouse-while-my-clickpipe-is-ingesting-data-can-you-help} +### 我的复制插槽失效了。我该怎么做? {#my-replication-slot-is-invalidated-what-should-i-do} -ClickHouse 上 OOM 的一个常见原因是你的服务配置过小。这意味着你当前的服务配置没有足够的资源(例如内存或 CPU)来有效处理摄取加载。我们强烈建议扩大服务以满足 ClickPipe 数据摄取的需求。 +恢复 ClickPipe 的唯一方法是触发重新同步,您可以在“设置”页面执行此操作。 -我们观察到的另一个原因是下游物化视图中存在可能未优化的连接: +复制插槽失效的最常见原因是 PostgreSQL 数据库上 `max_slot_wal_keep_size` 设置过低(例如,几 GB)。我们建议增加此值。有关 `max_slot_wal_keep_size` 的调优,请参阅 [本节](/integrations/clickpipes/postgres/faq#recommended-max_slot_wal_keep_size-settings)。理想情况下,此值应设置为至少 200GB,以防止复制插槽失效。 -- 对于 JOIN 的一个常见优化技巧是如果你有一个 `LEFT JOIN`,而右侧表非常大。在这种情况下,重写查询以使用 `RIGHT JOIN` 并将更大的表移到左侧。这使得查询规划器能够更有效地利用内存。 +在极少数情况下,我们发现即使未配置 `max_slot_wal_keep_size` 也会出现此问题。这可能是由于 PostgreSQL 中的一种复杂且罕见的错误,尽管原因依然不清楚。 -- 另一个 JOIN 的优化技巧是通过 `子查询` 或 `CTE` 明确过滤表,然后在这些子查询之间执行 `JOIN`。这为规划器提供了关于如何有效过滤行和执行 `JOIN` 的提示。 +### 在 ClickHouse 中,我在 ClickPipe 数据摄取时看到内存不足(OOM)。你能帮忙吗? {#i-am-seeing-out-of-memory-ooms-on-clickhouse-while-my-clickpipe-is-ingesting-data-can-you-help} -## 我在初始加载期间看到 `invalid snapshot identifier`。我该怎么办? {#i-am-seeing-an-invalid-snapshot-identifier-during-the-initial-load-what-should-i-do} +ClickHouse 上 OOM 的一个常见原因是您的服务配置不足。这意味着您当前的服务配置没有足够的资源(例如内存或 CPU)来有效处理摄取负载。我们强烈建议增加服务规模,以满足 ClickPipe 数据摄取的需求。 -`invalid snapshot identifier` 错误发生在 ClickPipes 与你的 Postgres 数据库之间发生连接中断时。这可能是由于网关超时、数据库重启或其他瞬态问题导致的。 +我们观察到的另一个原因是下游物化视图存在潜在的未优化连接: -建议在初始加载进行时不要进行任何破坏性操作如升级或重启你的 Postgres 数据库,并确保到数据库的网络连接稳定。 +- 对于 JOIN 的一项常见优化技术是,如果您具有关联一个非常大的右侧表的 `LEFT JOIN`。在这种情况下,请重写查询以使用 `RIGHT JOIN`,并将较大的表移动到左侧。这使查询规划更具内存效率。 -要解决此问题,你可以从 ClickPipes 界面触发重新同步。这将从头开始重新启动初始加载过程。 +- 对于 JOIN 的另一种优化是通过 `子查询` 或 `CTE` 明确过滤表,然后跨这些子查询执行 `JOIN`。这为规划器提供提示,以有效过滤行和执行 `JOIN`。 -## 如果我在 Postgres 中删除一个发布会发生什么? {#what-happens-if-i-drop-a-publication-in-postgres} +### 在初始加载期间,我在看到 `invalid snapshot identifier` 错误。我该怎么办? {#i-am-seeing-an-invalid-snapshot-identifier-during-the-initial-load-what-should-i-do} -在 Postgres 中删除一个发布将中断你的 ClickPipe 连接,因为发布是 ClickPipe 从源处拉取更改所必需的。当这种情况发生时,你通常会收到一个错误警告,指示该发布不再存在。 +`invalid snapshot identifier` 错误发生在 ClickPipes 和您的 Postgres 数据库之间存在连接中断时。这可能是由于网关超时、数据库重启或其他瞬态问题。 -在删除发布后恢复你的 ClickPipe 的步骤: +建议您在初始加载进行时不要进行任何破坏性操作,例如升级或重启您的 Postgres 数据库,并确保与数据库的网络连接稳定。 -1. 在 Postgres 中创建一个同名的包含所需表的新发布 -2. 点击 ClickPipe 设置选项卡中的 '重新同步表' 按钮 +要解决此问题,您可以从 ClickPipes UI 触发重新同步。这将从头开始重新启动初始加载过程。 -此重新同步是必要的,因为重新创建的发布在 Postgres 中将具有不同的对象标识符(OID),即使它的名称相同。重新同步过程刷新你的目标表并恢复连接。 +### 如果我在 Postgres 中放弃发布会发生什么? {#what-happens-if-i-drop-a-publication-in-postgres} -或者,如果你愿意,可以创建一个全新的管道。 +在 Postgres 中放弃发布将破坏您的 ClickPipe 连接,因为必须发布才能从源中提取更改。当发生这种情况时,您通常会收到错误警报,指示该发布不再存在。 -请注意,如果你正在处理分区表,请确保以适当的设置创建你的发布: +在删除发布后恢复 ClickPipe: + +1. 在 Postgres 中创建一个具有相同名称和所需表的新发布 +2. 在 ClickPipe 的设置选项卡中点击“重新同步表”按钮 + +重新同步是必要的,因为重新创建的发布将在 Postgres 中具有不同的对象标识符(OID),即使它具有相同的名称。重新同步过程刷新您的目标表并恢复连接。 + +或者,如果您愿意,也可以创建一个全新的管道。 + +请注意,如果您使用的是分区表,请确保使用适当的设置创建发布: ```sql -CREATE PUBLICATION clickpipes_publication -FOR TABLE <...>, <...> +CREATE PUBLICATION clickpipes_publication +FOR TABLE <...>, <...> WITH (publish_via_partition_root = true); ``` -## 如果我看到 `Unexpected Datatype` 错误或 `Cannot parse type XX ...` 怎样办? {#what-if-i-am-seeing-unexpected-datatype-errors} +### 如果我看到 `Unexpected Datatype` 错误或 `Cannot parse type XX ...` 怎么办? {#what-if-i-am-seeing-unexpected-datatype-errors} -此错误通常发生当源 Postgres 数据库具有一个在摄取过程中无法映射的数据类型时。 +此错误通常发生于源 Postgres 数据库具有无法在摄取期间映射的数据类型。 有关更具体的问题,请参阅以下可能性。 ### `Cannot parse type Decimal(XX, YY), expected non-empty binary data with size equal to or less than ...` {#cannot-parse-type-decimal-expected-non-empty-binary-data-with-size-equal-to-or-less-than} -Postgres 的 `NUMERIC` 具有非常高的精度(小数点前最多 131072 位;小数点后最多 16383 位),而 ClickHouse Decimal 类型允许最多(76 位、39 的小数位)。 -系统假设 _通常_ 大小不会达到如此之高,因此对于同样的情况进行乐观转换,因为源表可能包含大量行或者某一行可能在 CDC 阶段到达。 +Postgres `NUMERIC` 具有非常高的精度(在小数点前最多 131072 位;在小数点后最多 16383 位),而 ClickHouse Decimal 类型允许的最大值为 (76 位,39 位小数)。 +系统假定 _通常_ 大小不会达到如此之高,并在同一源表可以具有大量行或行可以在 CDC 阶段到达的情况下进行乐观施加转换。 + +当前的解决方法是将 NUMERIC 类型映射为 ClickHouse 中的字符串。要启用此功能,请向支持团队提出请求,将为您的 ClickPipes 启用该功能。 + +### 在复制/创建槽期间,我看到错误 `invalid memory alloc request size ` {#postgres-invalid-memalloc-bug} + +在 Postgres 补丁版本 17.5/16.9/15.13/14.18/13.21 中引入了一个错误,导致某些工作负载可造成内存使用量的指数增加,导致内存分配请求 >1GB,这 Postgres 视为无效。此错误 [已被修复](https://github.com/postgres/postgres/commit/d87d07b7ad3b782cb74566cd771ecdb2823adf6a) 并将在下一个 Postgres 补丁系列中(17.6...)发布。请与您的 Postgres 提供商确认此补丁版本何时可供升级。如果立即无法升级,可能需要重新同步管道,因为它会触发错误。 + +### 我需要在 ClickHouse 中维护完整的历史记录,即使在源 Postgres 数据库中删除数据时。我可以在 ClickPipes 中完全忽略来自 Postgres 的 DELETE 和 TRUNCATE 操作吗? {#ignore-delete-truncate} + +可以!在创建 Postgres ClickPipe 之前,创建一个没有 DELETE 操作的发布。例如: +```sql +CREATE PUBLICATION FOR TABLES IN SCHEMA WITH (publish = 'insert,update'); +``` +然后在设置您的 Postgres ClickPipe 时,请确保选择此发布名称。 + +请注意,TRUNCATE 操作将被 ClickPipes 忽略,且不会复制到 ClickHouse。 + +### 为什么我不能复制包含点的表? {#replicate-table-dot} +PeerDB 当前存在一个限制,即源表标识符(即架构名称或表名称)中的点不受支持,因为 PeerDB 无法辨别在这种情况下什么是架构,什么是表,因为它在点上拆分。 +我们正在努力支持单独输入架构和表,以绕过此限制。 + +### 初始加载完成,但 ClickHouse 中没有/缺少数据。这可能是什么问题? {#initial-load-issue} +如果您的初始加载已完成且没有错误,但目标 ClickHouse 表缺少数据,可能是您在源 Postgres 表上启用了 RLS(行级安全)政策。 +还值得检查的是: +- 用户是否具有读取源表的足够权限。 +- ClickHouse 侧是否存在任何行政策,这可能在过滤行。 + +### ClickPipe 能否创建带有故障转移启用的复制槽? {#failover-slot} +可以,对于复制模式为 CDC 或快照 + CDC 的 Postgres ClickPipe,您可以通过在创建 ClickPipe 时在 `高级设置` 部分切换以下开关来创建带有故障转移启用的复制槽。请注意,您的 Postgres 版本必须为 17 或更高版本才能使用此功能。 + + -当前的解决方法是将 NUMERIC 类型映射为 ClickHouse 上的字符串。要启用此功能,请向支持团队提交工单并为你的 ClickPipes 启用此设置。 +如果源配置正确,槽在故障转移到 Postgres 读取副本后将被保留,确保连续的数据复制。了解更多信息 [这里](https://www.postgresql.org/docs/current/logical-replication-failover.html)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/faq.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/faq.md.hash index 24bcd1bc310..c0633a49358 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/faq.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/faq.md.hash @@ -1 +1 @@ -30b2cd3bbc44cd01 +7a0c6673901ede50 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/index.md index f5bda37c16e..c8a2ed7bb6f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/index.md @@ -1,8 +1,9 @@ --- -'sidebar_label': '从 Postgres 向 ClickHouse 传输数据' -'description': '无缝连接你的 Postgres 和 ClickHouse Cloud.' +'sidebar_label': '从 Postgres 到 ClickHouse 的数据摄取' +'description': '无缝连接你的 Postgres 到 ClickHouse Cloud。' 'slug': '/integrations/clickpipes/postgres' -'title': '从 Postgres 向 ClickHouse (使用 CDC) 传输数据' +'title': '从 Postgres 到 ClickHouse 的数据摄取 (使用 CDC)' +'doc_type': 'guide' --- import BetaBadge from '@theme/badges/BetaBadge'; @@ -17,9 +18,9 @@ import ch_permissions from '@site/static/images/integrations/data-ingestion/clic import Image from '@theme/IdealImage'; -# 将数据从 Postgres 导入到 ClickHouse(使用 CDC) +# 从 Postgres 到 ClickHouse 的数据摄取(使用 CDC) -您可以使用 ClickPipes 将数据从源 Postgres 数据库导入到 ClickHouse Cloud。源 Postgres 数据库可以在本地或云中托管,包括 Amazon RDS、Google Cloud SQL、Azure Database for Postgres、Supabase 等。 +您可以使用 ClickPipes 将数据从源 Postgres 数据库摄取到 ClickHouse Cloud。源 Postgres 数据库可以托管在本地或云端,包括 Amazon RDS、Google Cloud SQL、Azure Database for Postgres、Supabase 等。 ## 前提条件 {#prerequisites} @@ -39,43 +40,43 @@ import Image from '@theme/IdealImage'; 7. [Crunchy Bridge Postgres](./postgres/source/crunchy-postgres) -8. [Generic Postgres Source](./postgres/source/generic),如果您使用的是其他 Postgres 提供商或使用自托管实例。 +8. [通用 Postgres 来源](./postgres/source/generic),如果您使用的是其他 Postgres 提供商或使用自托管实例。 9. [TimescaleDB](./postgres/source/timescale),如果您在托管服务或自托管实例上使用 TimescaleDB 扩展。 - :::warning -不支持基于 CDC 的复制的 Postgres 代理,如 PgBouncer、RDS Proxy、Supabase Pooler 等。请确保在 ClickPipes 设置中**不要**使用它们,而是添加实际 Postgres 数据库的连接详细信息。 +Postgres 代理如 PgBouncer、RDS Proxy、Supabase Pooler 等,不支持基于 CDC 的复制。请确保在 ClickPipes 设置中**不要使用它们**,而是添加实际 Postgres 数据库的连接详情。 ::: 一旦您的源 Postgres 数据库设置完成,您可以继续创建您的 ClickPipe。 -## 创建 ClickPipe {#creating-your-clickpipe} +## 创建您的 ClickPipe {#creating-your-clickpipe} -确保您已登录到您的 ClickHouse Cloud 账户。如果您还没有账户,可以在 [这里](https://cloud.clickhouse.com/) 注册。 +确保您已登录到 ClickHouse Cloud 账户。如果您还没有账户,可以在 [这里注册](https://cloud.clickhouse.com/)。 [//]: # ( TODO update image here) 1. 在 ClickHouse Cloud 控制台中,导航到您的 ClickHouse Cloud 服务。 -2. 在左侧菜单上选择 `Data Sources` 按钮,然后点击 "Set up a ClickPipe" +2. 在左侧菜单中选择 `Data Sources` 按钮,然后点击“设置 ClickPipe” -3. 选择 `Postgres CDC` 模块 +3. 选择 `Postgres CDC` 瓦片 -### 添加源 Postgres 数据库连接 {#adding-your-source-postgres-database-connection} +### 添加您的源 Postgres 数据库连接 {#adding-your-source-postgres-database-connection} -4. 填写您在前提条件步骤中配置的源 Postgres 数据库的连接详细信息。 +4. 填写您在前提条件步骤中配置的源 Postgres 数据库的连接详情。 :::info - 在您开始添加连接详细信息之前,请确保在防火墙规则中将 ClickPipes IP 地址列入白名单。您可以在 [这里](../index.md#list-of-static-ips) 找到 ClickPipes IP 地址列表。有关更多信息,请参考 [本页顶部](#prerequisites) 提到的源 Postgres 设置指南。 + 在开始添加连接详情之前,请确保在防火墙规则中列入 ClickPipes IP 地址。您可以在 [这里](../index.md#list-of-static-ips) 找到 ClickPipes IP 地址的列表。 + 有关更多信息,请参考本页顶部链接的源 Postgres 设置指南 [前提条件](#prerequisites)。 ::: @@ -83,31 +84,32 @@ import Image from '@theme/IdealImage'; #### (可选)设置 AWS Private Link {#optional-setting-up-aws-private-link} -如果您的源 Postgres 数据库托管在 AWS 上,您可以使用 AWS Private Link 进行连接。这在您希望保持数据传输隐私时非常有用。您可以按照 [设置指南来设置连接](/integrations/clickpipes/aws-privatelink)。 +如果您的源 Postgres 数据库托管在 AWS 上,您可以使用 AWS Private Link 进行连接。这对于想要保持数据传输私密的用户非常有用。 +您可以遵循 [设置指南来设置连接](/integrations/clickpipes/aws-privatelink)。 #### (可选)设置 SSH 隧道 {#optional-setting-up-ssh-tunneling} -如果您的源 Postgres 数据库无法公开访问,您可以指定 SSH 隧道详细信息。 +如果您的源 Postgres 数据库不可公开访问,您可以指定 SSH 隧道的详细信息。 -1. 启用 "Use SSH Tunnelling" 切换开关。 -2. 填写 SSH 连接详细信息。 +1. 启用“使用 SSH 隧道”切换按钮。 +2. 填写 SSH 连接详情。 -3. 要使用基于密钥的身份验证,单击 "Revoke and generate key pair" 生成新的密钥对,并将生成的公钥复制到您的 SSH 服务器 `~/.ssh/authorized_keys` 下。 -4. 单击 "Verify Connection" 以验证连接。 +3. 要使用基于密钥的身份验证,请单击“撤销并生成密钥对”以生成新密钥对,并将生成的公钥复制到您的 SSH 服务器的 `~/.ssh/authorized_keys`。 +4. 单击“验证连接”以验证连接。 :::note -确保在防火墙规则中为 SSH 大师主机列入 [ClickPipes IP 地址](../clickpipes#list-of-static-ips) 的白名单,以便 ClickPipes 可以建立 SSH 隧道。 +确保在 SSH 中继主机的防火墙规则中列入 [ClickPipes IP 地址](../clickpipes#list-of-static-ips),以便 ClickPipes 可以建立 SSH 隧道。 ::: -一旦填写了连接详细信息,单击 "Next"。 +填写连接详情后,单击“下一步”。 ### 配置复制设置 {#configuring-the-replication-settings} -5. 确保从下拉列表中选择在前提条件步骤中创建的复制槽。 +5. 确保从下拉列表中选择前提条件步骤中创建的复制槽。 @@ -115,33 +117,32 @@ import Image from '@theme/IdealImage'; 如果需要,您可以配置高级设置。每个设置的简要描述如下: -- **同步间隔**: 这是 ClickPipes 轮询源数据库以检测更改的间隔。对于成本敏感的用户,我们建议将其保持在较高的值(超过 `3600`)。 -- **初始加载的并行线程**: 这是用于获取初始快照的并行工作者数量。当您有大量表并希望控制获取初始快照时使用的并行工作者数量时,这很有用。此设置是针对每个表的。 -- **拉取批大小**: 单次批次要获取的行数。这是一个最佳努力的设置,可能在某些情况下无法遵守。 -- **每个分区的快照行数**: 在初始快照期间,每个分区将获取的行数。当您在表中有大量行并希望控制每个分区获取的行数时,这很有用。 -- **并行快照表数**: 在初始快照期间将并行获取的表的数量。当您有大量表,并希望控制并行获取的表数时,这很有用。 - +- **同步间隔**:这是 ClickPipes 每次轮询源数据库以获取更改的时间间隔。这会影响目标 ClickHouse 服务,对于对成本敏感的用户,我们建议将此值保持在较高的值(超过 `3600`)。 +- **初始加载的并行线程**:这是用于获取初始快照的并行工作者的数量。当您有大量表并希望控制用于获取初始快照的并行工作者数量时,这非常有用。此设置是按表计算的。 +- **拉取批量大小**:单次批量中要提取的行数。这是基于最大努力的设置,在某些情况下可能无法遵守。 +- **每个分区的快照行数**:这是在初始快照期间在每个分区中要获取的行数。当您的表中有大量行且希望控制每个分区获取的行数时,这非常有用。 +- **并行快照的表数量**:这是在初始快照期间将并行提取的表数量。当您有大量表并希望控制并行提取的表数量时,这非常有用。 ### 配置表 {#configuring-the-tables} -6. 在这里,您可以选择 ClickPipe 的目标数据库。您可以选择现有数据库或创建新数据库。 +6. 在此处,您可以选择 ClickPipe 的目标数据库。您可以选择一个现有的数据库或创建一个新的。 -7. 您可以从源 Postgres 数据库中选择要复制的表。在选择表时,您还可以选择在目标 ClickHouse 数据库中重命名表以及排除特定列。 +7. 您可以选择要从源 Postgres 数据库复制的表。在选择表时,您还可以选择在目标 ClickHouse 数据库中重命名表以及排除特定列。 :::warning - 如果您在 ClickHouse 中定义的 Ordering Key 与 Postgres 中的主键不同,请务必查看所有相关的 [注意事项](/integrations/clickpipes/postgres/ordering_keys)! + 如果您在 ClickHouse 中定义的排序键与 Postgres 中的主键不同,请务必阅读有关的所有 [注意事项](/integrations/clickpipes/postgres/ordering_keys) ::: -### 审查权限并开始 ClickPipe {#review-permissions-and-start-the-clickpipe} +### 审查权限并启动 ClickPipe {#review-permissions-and-start-the-clickpipe} -8. 从权限下拉列表中选择 "Full access" 角色,然后单击 "Complete Setup"。 +8. 从权限下拉菜单中选择“完全访问”角色,然后单击“完成设置”。 -## 接下来是什么? {#whats-next} +## 接下来做什么? {#whats-next} -一旦您将数据从 Postgres 移动到 ClickHouse,接下来的显而易见的问题是如何在 ClickHouse 中查询和建模您的数据,以最大限度地利用它。请参考 [迁移指南](/migrations/postgresql/overview) 获取有关从 PostgreSQL 迁移到 ClickHouse 的逐步方法。此外,请确保查看有关 [去重策略(使用 CDC)](/integrations/clickpipes/postgres/deduplication) 和 [Ordering Keys](/integrations/clickpipes/postgres/ordering_keys) 的页面,以了解如何处理重复项并在使用 CDC 时自定义排序键。 +一旦您设置了 ClickPipe 将数据从 PostgreSQL 复制到 ClickHouse Cloud,您可以专注于如何查询和建模您的数据以获取最佳性能。请参阅 [迁移指南](/migrations/postgresql/overview),评估哪种策略最适合您的需求,以及有关 CDC 工作负载的最佳实践的 [去重策略(使用 CDC)](/integrations/clickpipes/postgres/deduplication) 和 [排序键](/integrations/clickpipes/postgres/ordering_keys) 页面。 -最后,请参考 ["ClickPipes for Postgres FAQ"](/integrations/clickpipes/postgres/faq) 页面以获取有关常见问题及其解决方法的更多信息。 +有关 PostgreSQL CDC 和故障排除的常见问题,请参阅 [Postgres 常见问题页面](/integrations/clickpipes/postgres/faq)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/index.md.hash index a9bff0b0523..059194c9a48 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/index.md.hash @@ -1 +1 @@ -506c7391e1a627cf +03dac69fc16d8411 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/lifecycle.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/lifecycle.md new file mode 100644 index 00000000000..91d5f594d44 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/lifecycle.md @@ -0,0 +1,65 @@ +--- +'sidebar_label': 'Postgres ClickPipe 的生命周期' +'description': '各种管道状态及其含义' +'slug': '/integrations/clickpipes/postgres/lifecycle' +'title': 'Postgres ClickPipe 的生命周期' +'doc_type': 'guide' +--- + + +# Postgres ClickPipe 的生命周期 {#lifecycle} + +这是关于 Postgres ClickPipe 各个阶段、它可能拥有的不同状态以及其含义的文档。 + +## 配置中 {#provisioning} + +当您点击 "创建 ClickPipe" 按钮时,ClickPipe 在 `配置中` 状态下被创建。配置过程是我们启动底层基础设施以运行 ClickPipes 的服务,同时为管道注册一些初始元数据。由于 ClickPipes 的计算资源在服务中是共享的,因此您的第二个 ClickPipe 的创建速度会比第一个快得多——因为基础设施已经到位。 + +## 设置中 {#setup} + +在管道配置好之后,它进入 `设置中` 状态。在这个状态下,我们创建目标 ClickHouse 表。同时我们在此处获取并记录您的源表的表定义。 + +## 快照 {#snapshot} + +一旦设置完成,我们进入 `快照` 状态(除非它是仅支持 CDC 的管道,这将过渡到 `运行中`)。`快照`、`初始快照` 和 `初始加载`(更常见)是可以互换的术语。在这个状态下,我们对源数据库表进行快照并将其加载到 ClickHouse 中。这并不使用逻辑复制,但在此步骤中会创建复制槽,因此您的 `max_slot_wal_keep_size` 和存储参数应考虑到初始加载期间槽的增长。有关初始加载的更多信息,请参见 [并行初始加载文档](./parallel_initial_load)。当触发重新同步或向现有管道添加新表时,管道也会进入 `快照` 状态。 + +## 运行中 {#running} + +一旦初始加载完成,管道进入 `运行中` 状态(除非它是仅支持快照的管道,这将过渡到 `完成`)。在此状态下,管道开始进行 `变更数据捕获`。在这个状态中,我们开始从源数据库到 ClickHouse 的逻辑复制。有关控制 CDC 的信息,请参见 [控制 CDC 文档](./sync_control)。 + +## 暂停 {#paused} + +一旦管道处于 `运行中` 状态,您可以暂停它。这将停止 CDC 过程,管道将进入 `暂停` 状态。在这个状态下,不会从源数据库提取新数据,但 ClickHouse 中现有的数据保持完好。您可以从此状态恢复管道。 + +## 正在暂停 {#pausing} + +:::note +此状态即将推出。如果您正在使用我们的 [OpenAPI](https://clickhouse.com/docs/cloud/manage/openapi),请考虑现在就添加对它的支持,以确保在发布时您的集成继续正常工作。 +::: +当您点击暂停按钮时,管道进入 `正在暂停` 状态。这是一个短暂状态,我们正在停止 CDC 过程。一旦 CDC 过程完全停止,管道将进入 `暂停` 状态。 + +## 正在修改 {#modifying} +:::note +此状态即将推出。如果您正在使用我们的 [OpenAPI](https://clickhouse.com/docs/cloud/manage/openapi),请考虑现在就添加对它的支持,以确保在发布时您的集成继续正常工作。 +::: +当前,这表示管道正在删除表的过程中。 + +## 重新同步 {#resync} +:::note +此状态即将推出。如果您正在使用我们的 [OpenAPI](https://clickhouse.com/docs/cloud/manage/openapi),请考虑现在就添加对它的支持,以确保在发布时您的集成继续正常工作。 +::: +此状态表示管道处于重新同步阶段,其中正在执行 _重新同步 表和原始表的原子交换。有关重新同步的更多信息,请参见 [重新同步文档](./resync)。 + +## 已完成 {#completed} + +此状态适用于仅限快照的管道,表示快照已完成且没有更多工作要做。 + +## 失败 {#failed} + +如果管道出现不可恢复的错误,它将进入 `失败` 状态。您可以与支持部门联系或 [重新同步](./resync) 您的管道以从此状态恢复。 + +## 降级 {#degraded} + +:::note +此状态即将推出。如果您正在使用我们的 [OpenAPI](https://clickhouse.com/docs/cloud/manage/openapi),请考虑现在就添加对它的支持,以确保在发布时您的集成继续正常工作。 +::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/lifecycle.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/lifecycle.md.hash new file mode 100644 index 00000000000..43f34edf997 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/lifecycle.md.hash @@ -0,0 +1 @@ +a04700f22ad6df55 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/maintenance.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/maintenance.md index 381f22b7d78..bd77f86189a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/maintenance.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/maintenance.md @@ -1,16 +1,17 @@ --- -'sidebar_label': '维护时间窗口' -'description': 'Postgres 的 ClickPipes 维护时间窗口。' +'sidebar_label': '维护窗口' +'description': 'Postgres 的 ClickPipes 维护窗口。' 'slug': '/integrations/clickpipes/postgres/maintenance' -'title': 'Postgres 的 ClickPipes 维护时间窗口' +'title': 'Postgres 的 ClickPipes 维护窗口' +'doc_type': 'reference' --- # Postgres ClickPipes 的维护窗口 -即将到来的 Postgres ClickPipes 维护窗口定于: -- **日期:** 2025年4月17日 -- **时间:** UTC 时间 07:00 - 08:00 +Postgres ClickPipes 的维护窗口即将到来,时间安排如下: +- **日期:** 2025 年 4 月 17 日 +- **时间:** UTC 上午 07:00 - 上午 08:00 -在此期间,您的 Postgres Pipes 将会经历短暂的停机。 -维护窗口结束后,ClickPipes 将会重新可用并恢复正常操作。 +在此期间,您的 Postgres Pipes 将经历短暂的停机。 +维护窗口结束后,ClickPipes 将再次可用,并恢复正常操作。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/maintenance.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/maintenance.md.hash index 7df5f499d0b..0c4636d3dc0 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/maintenance.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/maintenance.md.hash @@ -1 +1 @@ -66d31508b0d50eec +db92cbf844a4e97c diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/ordering_keys.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/ordering_keys.md index 47e6dae6624..51ca39992e2 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/ordering_keys.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/ordering_keys.md @@ -3,19 +3,20 @@ 'description': '如何定义自定义排序键。' 'slug': '/integrations/clickpipes/postgres/ordering_keys' 'title': '排序键' +'doc_type': 'guide' --- -Ordering Keys (也称为排序键) 定义了 ClickHouse 中表的数据如何在磁盘上排序和索引。当从 Postgres 进行复制时,ClickPipes 将 Postgres 表的主键设置为 ClickHouse 中相应表的排序键。在大多数情况下,Postgres 主键足以充当排序键,因为 ClickHouse 已经针对快速扫描进行了优化,通常不需要自定义排序键。 +Ordering Keys (即排序键) 定义了在 ClickHouse 中如何对数据进行磁盘排序和索引。当从 Postgres 进行复制时,ClickPipes 将 Postgres 的表主键设置为 ClickHouse 中相应表的排序键。在大多数情况下,Postgres 主键作为排序键就足够了,因为 ClickHouse 已针对快速扫描进行了优化,通常不需要自定义排序键。 -正如在 [迁移指南](https://docs.peerdb.io/mirror/ordering-key-different) 中所描述的,对于较大的用例,您应该在 ClickHouse 排序键中包含除了 Postgres 主键之外的额外列,以优化查询。 +如 [迁移指南](/migrations/postgresql/data-modeling-techniques) 中所述,对于较大的用例,您应该在 ClickHouse 的排序键中包含除了 Postgres 主键之外的其他列,以优化查询。 -默认情况下,使用 CDC 时,选择与 Postgres 主键不同的排序键可能会导致 ClickHouse 中的数据去重问题。这是因为 ClickHouse 中的排序键具有双重作用:它同时控制数据索引和排序,并且充当去重键。解决此问题的最简单方法是定义可刷新的物化视图。 +默认情况下,如果使用 CDC,选择一个与 Postgres 主键不同的排序键可能会导致 ClickHouse 中的数据去重问题。这是因为 ClickHouse 中的排序键同时承担了两个角色:它控制数据的索引和排序,同时作为去重键。解决此问题的最简单方法是定义可刷新的物化视图。 ## 使用可刷新的物化视图 {#use-refreshable-materialized-views} -定义自定义排序键 (ORDER BY) 的一个简单方法是使用 [可刷新的物化视图](/materialized-view/refreshable-materialized-view) (MVs)。这些视图允许您定期(例如,每 5 或 10 分钟)使用所需的排序键复制整个表。 +定义自定义排序键 (ORDER BY) 的一种简单方法是使用 [可刷新的物化视图](/materialized-view/refreshable-materialized-view) (MVs)。这些视图允许您定期(例如,每 5 或 10 分钟)复制整个表,并使用所需的排序键。 -以下是一个带有自定义 ORDER BY 和所需去重的可刷新的 MV 示例: +下面是一个带有自定义 ORDER BY 和必要去重的可刷新物化视图的示例: ```sql CREATE MATERIALIZED VIEW posts_final @@ -26,25 +27,25 @@ SELECT * FROM posts FINAL WHERE _peerdb_is_deleted = 0; -- this does the deduplication ``` -## 无可刷新的物化视图的自定义排序键 {#custom-ordering-keys-without-refreshable-materialized-views} +## 无需可刷新的物化视图的自定义排序键 {#custom-ordering-keys-without-refreshable-materialized-views} -如果由于数据规模的原因可刷新的物化视图无法使用,以下是一些建议,您可以遵循这些建议在较大的表上定义自定义排序键并克服与去重相关的问题。 +如果由于数据规模原因可刷新的物化视图无法使用,您可以遵循以下几个建议,在较大的表上定义自定义排序键并克服与去重相关的问题。 ### 选择对于给定行不会改变的排序键列 {#choose-ordering-key-columns-that-dont-change-for-a-given-row} -在 ClickHouse 的排序键中包含额外列(除了 Postgres 的主键)时,我们建议选择每行不会改变的列。这有助于防止与 ReplacingMergeTree 相关的数据一致性和去重问题。 +在 ClickHouse 的排序键中(除了 Postgres 的主键之外)包含额外列时,我们建议选择对于每行不会改变的列。这有助于防止使用 ReplacingMergeTree 时的数据一致性和去重问题。 -例如,在一个多租户的 SaaS 应用中,使用 (`tenant_id`, `id`) 作为排序键是一个不错的选择。这些列唯一标识每行,而且即使其他列发生变化,`tenant_id` 对于某个 `id` 仍然保持不变。由于按 id 去重与按 (tenant_id, id) 去重一致,这有助于避免可能由于 tenant_id 变化而引发的数据 [去重问题](https://docs.peerdb.io/mirror/ordering-key-different)。 +例如,在一个多租户的 SaaS 应用中,使用 (`tenant_id`, `id`) 作为排序键是一个不错的选择。这些列唯一标识每一行,并且即使其他列改变,`tenant_id` 对于一个 `id` 仍然保持不变。由于通过 id 去重与通过 (tenant_id, id) 去重是一致的,这有助于避免由于 tenant_id 的变化而可能引发的数据 [去重问题](https://docs.peerdb.io/mirror/ordering-key-different)。 -### 在 Postgres 表上设置主副本标识为自定义排序键 {#set-replica-identity-on-postgres-tables-to-custom-ordering-key} +### 将 Postgres 表的副本身份设置为自定义排序键 {#set-replica-identity-on-postgres-tables-to-custom-ordering-key} -为了让 Postgres CDC 按预期工作,重要的是修改表上的 `REPLICA IDENTITY` 以包含排序键列。这对准确处理 DELETE 至关重要。 +为了使 Postgres CDC 按预期工作,重要的是要修改表上的 `REPLICA IDENTITY`,以包括排序键列。这对于准确处理 DELETE 操作至关重要。 -如果 `REPLICA IDENTITY` 不包含排序键列,Postgres CDC 将无法捕获主键以外的列的值 - 这是 Postgres 逻辑解码的一个限制。所有除了主键之外的排序键列在 Postgres 中将为 null。这影响去重,这意味着行的先前版本可能无法与最新删除版本(其中 `_peerdb_is_deleted` 设置为 1)进行去重。 +如果 `REPLICA IDENTITY` 不包括排序键列,Postgres CDC 将无法捕获除主键以外的列的值——这是 Postgres 逻辑解码的一个限制。除 Postgres 中的主键外,所有排序键列将为 null。这会影响去重,意味着行的先前版本可能不会与最新的已删除版本(其中 `_peerdb_is_deleted` 设为 1)去重。 -在上述包含 `owneruserid` 和 `id` 的示例中,如果主键没有包含 `owneruserid`,您需要在 (`owneruserid`, `id`) 上创建 `UNIQUE INDEX` 并将其设置为表的 `REPLICA IDENTITY`。这确保 Postgres CDC 捕获必要的列值以实现准确的复制和去重。 +在上述 `owneruserid` 和 `id` 的示例中,如果主键未包含 `owneruserid`,则需要在 (`owneruserid`, `id`) 上拥有一个 `UNIQUE INDEX` 并将其设置为表的 `REPLICA IDENTITY`。这确保了 Postgres CDC 捕获必要的列值,以便进行准确的复制和去重。 -以下是如何在 events 表上执行此操作的示例。确保将其应用于所有具有修改排序键的表。 +下面是如何在事件表上执行此操作的示例。确保将其应用于所有修改过排序键的表。 ```sql -- Create a UNIQUE INDEX on (owneruserid, id) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/ordering_keys.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/ordering_keys.md.hash index 3847e8377bd..80111d23088 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/ordering_keys.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/ordering_keys.md.hash @@ -1 +1 @@ -4ae631ab10830f50 +e5d4db9abcaa3345 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/parallel_initial_load.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/parallel_initial_load.md new file mode 100644 index 00000000000..9930bd62af8 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/parallel_initial_load.md @@ -0,0 +1,48 @@ +--- +'title': 'Postgres ClickPipe中的并行快照' +'description': '文档解释Postgres ClickPipe中的并行快照' +'slug': '/integrations/clickpipes/postgres/parallel_initial_load' +'sidebar_label': '并行快照如何工作' +'doc_type': 'guide' +--- + +import snapshot_params from '@site/static/images/integrations/data-ingestion/clickpipes/postgres/snapshot_params.png' +import Image from '@theme/IdealImage'; + +This document explains parallelized snapshot/initial load in the Postgres ClickPipe works and talks about the snapshot parameters that can be used to control it. + +## 概述 {#overview-pg-snapshot} + +初始加载是CDC ClickPipe的第一阶段,在此阶段,ClickPipe将源数据库中表的历史数据同步到ClickHouse,然后再开始CDC。很多时候,开发者会采用单线程的方式进行这项工作,比如使用pg_dump或pg_restore,或者使用单个线程从源数据库读取并写入ClickHouse。然而,Postgres ClickPipe可以并行化这个过程,这可以显著加快初始加载的速度。 + +### Postgres中的CTID列 {#ctid-pg-snapshot} +在Postgres中,表中的每一行都有一个唯一标识符称为CTID。这是一个系统列,默认情况下对用户不可见,但可以用来唯一标识表中的行。CTID是块号和块内偏移量的组合,这使得访问行的效率很高。 + +### 逻辑分区 {#logical-partitioning-pg-snapshot} +Postgres ClickPipe使用CTID列对源表进行逻辑分区。它通过首先对源表执行COUNT(*),然后执行窗口函数分区查询以获取每个分区的CTID范围,从而获得分区。这使得ClickPipe可以并行读取源表,每个分区由单独的线程处理。 + +让我们讨论以下设置: + + + +#### 每个分区的快照行数 {#numrows-pg-snapshot} + +此设置控制每个分区包含多少行。ClickPipe将以此大小的块读取源表,这些块将根据设置的初始加载并行性并行处理。默认值是每个分区100,000行。 + +#### 初始加载并行性 {#parallelism-pg-snapshot} + +此设置控制并行处理多少个分区。默认值为4,这意味着ClickPipe将并行读取源表中的4个分区。可以增加此值以加快初始加载,但建议根据源实例的规格将其保持在合理的值,以避免对源数据库造成过大的压力。ClickPipe将根据源表的大小和每个分区的行数自动调整分区数。 + +#### 并行快照的表数 {#tables-parallel-pg-snapshot} + +与并行快照没有直接关系,但此设置控制在初始加载期间并行处理多少个表。默认值为1。请注意,这在分区的并行性之上,因此如果您有4个分区和2个表,ClickPipe将并行读取8个分区。 + +### 监控Postgres中的并行快照 {#monitoring-parallel-pg-snapshot} + +您可以分析**pg_stat_activity**以查看并行快照的运行情况。ClickPipe将创建多个连接到源数据库,每个连接读取源表的不同分区。如果您看到具有不同CTID范围的**FETCH**查询,这意味着ClickPipe正在读取源表。您也可以在这里看到COUNT(*)和分区查询。 + +### 限制 {#limitations-parallel-pg-snapshot} + +- 快照参数在管道创建后不能被编辑。如果您想更改它们,您必须创建一个新的ClickPipe。 +- 当向现有ClickPipe添加表时,您不能更改快照参数。ClickPipe将对新表使用现有参数。 +- 分区键列不应包含`NULL`,因为分区逻辑会跳过它们。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/parallel_initial_load.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/parallel_initial_load.md.hash new file mode 100644 index 00000000000..93cff895e31 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/parallel_initial_load.md.hash @@ -0,0 +1 @@ +cdb2bd7b24fb8c1a diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/pause_and_resume.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/pause_and_resume.md index 6fcf913ca4e..9b0ab536a23 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/pause_and_resume.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/pause_and_resume.md @@ -1,8 +1,9 @@ --- -'title': '暂停和恢复 Postgres ClickPipe' -'description': '暂停和恢复 Postgres ClickPipe' +'title': '暂停和恢复一个 Postgres ClickPipe' +'description': '暂停和恢复一个 Postgres ClickPipe' 'sidebar_label': '暂停表' 'slug': '/integrations/clickpipes/postgres/pause_and_resume' +'doc_type': 'guide' --- import Image from '@theme/IdealImage'; @@ -12,40 +13,39 @@ import pause_status from '@site/static/images/integrations/data-ingestion/clickp import resume_button from '@site/static/images/integrations/data-ingestion/clickpipes/postgres/resume_button.png' import resume_dialog from '@site/static/images/integrations/data-ingestion/clickpipes/postgres/resume_dialog.png' -There are scenarios where it would be useful to pause a Postgres ClickPipe. For example, you may want to run some analytics on existing data in a static state. Or, you might be performing upgrades on Postgres. Here is how you can pause and resume a Postgres ClickPipe. +在某些情况下,暂停 Postgres ClickPipe 将是有用的。例如,您可能希望对处于静态状态的现有数据进行一些分析。或者,您可能正在对 Postgres 进行升级。以下是如何暂停和恢复 Postgres ClickPipe 的步骤。 -## Steps to pause a Postgres ClickPipe {#pause-clickpipe-steps} +## 暂停 Postgres ClickPipe 的步骤 {#pause-clickpipe-steps} -1. 在数据源标签中,点击您希望暂停的 Postgres ClickPipe。 -2. 转到 **设置** 标签。 +1. 在数据源选项卡中,点击您希望暂停的 Postgres ClickPipe。 +2. 转到 **设置** 选项卡。 3. 点击 **暂停** 按钮。 -
-4. 将出现确认对话框。再次点击暂停。 -
+4. 将出现一个确认对话框。再次点击暂停。 -4. 转到 **指标** 标签。 -5. 在大约 5 秒后(也可以在页面刷新时),管道的状态应为 **已暂停**。 -
+4. 转到 **指标** 选项卡。 +5. 大约 5 秒后(并且在页面刷新时),管道的状态应该是 **已暂停**。 + +:::warning +暂停 Postgres ClickPipe 不会暂停复制槽的增长。 +::: -## Steps to resume a Postgres ClickPipe {#resume-clickpipe-steps} -1. 在数据源标签中,点击您希望恢复的 Postgres ClickPipe。镜像的状态应该最初显示为 **已暂停**。 -2. 转到 **设置** 标签。 +## 恢复 Postgres ClickPipe 的步骤 {#resume-clickpipe-steps} +1. 在数据源选项卡中,点击您希望恢复的 Postgres ClickPipe。此时镜像的状态应为 **已暂停**。 +2. 转到 **设置** 选项卡。 3. 点击 **恢复** 按钮。 -
-4. 将出现确认对话框。再次点击恢复。 -
+4. 将出现一个确认对话框。再次点击恢复。 -5. 转到 **指标** 标签。 -6. 在大约 5 秒后(也可以在页面刷新时),管道的状态应为 **运行中**。 +5. 转到 **指标** 选项卡。 +6. 大约 5 秒后(并且在页面刷新时),管道的状态应该是 **正在运行**。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/pause_and_resume.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/pause_and_resume.md.hash index e464824b278..2ff17e403c5 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/pause_and_resume.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/pause_and_resume.md.hash @@ -1 +1 @@ -f9c01f68d2225b43 +122a1375f9394f79 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/postgres_generated_columns.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/postgres_generated_columns.md index 2f79b510707..7f09445037e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/postgres_generated_columns.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/postgres_generated_columns.md @@ -1,29 +1,32 @@ --- 'title': 'Postgres 生成列:注意事项和最佳实践' 'slug': '/integrations/clickpipes/postgres/generated_columns' -'description': '页面描述在使用 PostgreSQL 生成列的表时需要牢记的重要考虑事项,这些表正在进行复制' +'description': '页面描述了在使用 PostgreSQL 生成列时在被复制的表中需要牢记的重要考虑因素' +'doc_type': 'guide' --- -在使用 PostgreSQL 的生成列的情况下,如果表格正在被复制,需要注意一些重要的事项。这些问题可能会影响复制过程和目标系统中的数据一致性。 +在使用 PostgreSQL 的生成列的表进行复制时,有一些重要的考虑事项。这些问题可能会影响复制过程和目标系统中的数据一致性。 -## 关于生成列的问题 {#the-problem-with-generated-columns} +## 生成列的问题 {#the-problem-with-generated-columns} -1. **未通过 `pgoutput` 发布:** 生成列并未通过 `pgoutput` 逻辑复制插件进行发布。这意味着当您将 PostgreSQL 数据复制到另一个系统时,生成列的值不会包含在复制数据流中。 +1. **未通过 `pgoutput` 发布:** 生成列不会通过 `pgoutput` 逻辑复制插件发布。这意味着在将数据从 PostgreSQL 复制到另一个系统时,生成列的值不会包含在复制流中。 -2. **主键问题:** 如果生成列是您的主键的一部分,这可能会在目标系统上导致去重问题。由于生成列的值并没有被复制,目标系统将无法获取必要的信息来正确识别和去重行。 +2. **主键问题:** 如果生成列是主键的一部分,这可能会在目标上导致去重问题。由于生成列的值没有被复制,目标系统将没有必要的信息来正确识别和去重行。 + +3. **架构更改问题:** 如果您向一个已经被复制的表添加生成列,新列在目标中将不会被填充 - 因为 Postgres 不会提供新列的 RelationMessage。如果您随后向同一表添加新的非生成列,则 ClickPipe 在尝试协调架构时,将无法在目标中找到生成列,导致复制过程失败。 ## 最佳实践 {#best-practices} -为了规避这些限制,考虑以下最佳实践: +为了绕过这些限制,可以考虑以下最佳实践: -1. **在目标系统上重新创建生成列:** 不要依赖复制过程处理生成列,建议使用像 dbt(数据构建工具)或其他数据转换机制在目标系统上重新创建这些列。 +1. **在目标上重新创建生成列:** 不要依靠复制过程来处理生成列,建议使用 dbt(数据生成工具)或其他数据转换机制在目标上重新创建这些列。 -2. **避免在主键中使用生成列:** 在设计将被复制的表时,最好避免将生成列作为主键的一部分。 +2. **避免在主键中使用生成列:** 在设计将被复制的表时,最好避免将生成列纳入主键的一部分。 -## 即将改进的用户界面 {#upcoming-improvements-to-ui} +## 即将推出的 UI 改进 {#upcoming-improvements-to-ui} -在即将发布的版本中,我们计划添加一个用户界面,帮助用户完成以下任务: +在即将发布的版本中,我们计划添加一个 UI,帮助用户处理以下事项: -1. **识别包含生成列的表:** 用户界面将具有识别包含生成列的表的功能。这将帮助用户了解哪些表受到此问题影响。 +1. **识别具有生成列的表:** UI 将具有识别包含生成列的表的功能。这将帮助用户理解哪些表受到此问题的影响。 -2. **文档和最佳实践:** 用户界面将包含在复制表中使用生成列的最佳实践,包括如何避免常见陷阱的指导。 +2. **文档和最佳实践:** UI 将包括在复制表中使用生成列的最佳实践,提供如何避免常见陷阱的指导。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/postgres_generated_columns.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/postgres_generated_columns.md.hash index b420bdddd0c..811cdfe3ab3 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/postgres_generated_columns.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/postgres_generated_columns.md.hash @@ -1 +1 @@ -1d0d36849e35b676 +0c4dfee408835241 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/remove_table.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/remove_table.md index 09d5f04a959..5886a1a7190 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/remove_table.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/remove_table.md @@ -1,26 +1,27 @@ --- -'title': '从 ClickPipe 中删除特定表' -'description': '从 ClickPipe 中删除特定表' -'sidebar_label': '删除表' +'title': '从 ClickPipe 中移除特定表' +'description': '从 ClickPipe 中移除特定表' +'sidebar_label': '移除表' 'slug': '/integrations/clickpipes/postgres/removing_tables' +'doc_type': 'guide' --- import Image from '@theme/IdealImage'; import remove_table from '@site/static/images/integrations/data-ingestion/clickpipes/postgres/remove_table.png' -在某些情况下,将特定表从 Postgres ClickPipe 中排除是有意义的——例如,如果某个表不需要用于您的分析工作负载,跳过它可以减少 ClickHouse 中的存储和复制成本。 +在某些情况下,排除特定的表从 Postgres ClickPipe 是有意义的 - 例如,如果一个表对你的分析工作负载没有必要,跳过它可以降低 ClickHouse 中的存储和复制成本。 ## 移除特定表的步骤 {#remove-tables-steps} -第一步是从管道中移除该表。可以通过以下步骤完成: +第一步是从管道中移除表。这可以通过以下步骤完成: -1. [暂停](./pause_and_resume.md)管道。 +1. [暂停](./pause_and_resume.md) 管道。 2. 点击编辑表设置。 -3. 找到您的表——可以通过在搜索栏中搜索来完成。 -4. 通过单击选中的复选框取消选择该表。 +3. 找到你的表 - 这可以通过在搜索框中搜索来完成。 +4. 点击选中复选框取消选择该表。
5. 点击更新。 -6. 更新成功后,在 **Metrics** 选项卡中状态将显示为 **Running**。该表将不再被此 ClickPipe 复制。 +6. 更新成功后,在 **指标** 标签中状态将显示为 **运行中**。该表将不再被此 ClickPipe 复制。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/remove_table.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/remove_table.md.hash index 7e0502ca08c..a5c16b9a0c3 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/remove_table.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/remove_table.md.hash @@ -1 +1 @@ -009654c974b7a066 +0be1ffbebc3aada2 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/resync.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/resync.md new file mode 100644 index 00000000000..f2031ec3c66 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/resync.md @@ -0,0 +1,47 @@ +--- +'title': '重新同步数据库 ClickPipe' +'description': '数据库 ClickPipe 重新同步文档' +'slug': '/integrations/clickpipes/postgres/resync' +'sidebar_label': '重新同步 ClickPipe' +'doc_type': 'guide' +--- + +import resync_button from '@site/static/images/integrations/data-ingestion/clickpipes/postgres/resync_button.png' +import Image from '@theme/IdealImage'; + +### Resync 的作用是什么? {#what-postgres-resync-do} + +Resync 涉及以下操作: +1. 现有的 ClickPipe 会被删除,并启动一个新的“resync” ClickPipe。因此,当你进行 resync 时,源表结构的更改将会被捕获。 +2. resync ClickPipe 创建(或替换)一组新的目标表,这些表的名称与原始表相同,但后面加上 `_resync` 后缀。 +3. 在 `_resync` 表上执行初始加载。 +4. 然后将 `_resync` 表与原始表进行交换。在交换之前,软删除的行会从原始表转移到 `_resync` 表。 + +原始 ClickPipe 的所有设置会在 resync ClickPipe 中保留。原始 ClickPipe 的统计信息会在用户界面中清除。 + +### resync ClickPipe 的使用场景 {#use-cases-postgres-resync} + +以下是一些场景: + +1. 你可能需要对源表进行重大模式更改,这会破坏现有的 ClickPipe,你需要重新启动。你只需在进行更改后点击 Resync。 +2. 特别是对于 Clickhouse,可能需要更改目标表的 ORDER BY 键。你可以通过 Resync 重新填充数据到具有正确排序键的新表中。 +3. ClickPipe 的复制插槽失效:Resync 创建一个新的 ClickPipe 和源数据库上的新插槽。 + +:::note +你可以多次进行 resync,但请考虑到在进行 resync 时源数据库的负载,因为每次都涉及使用并行线程的初始加载。 +::: + +### Resync ClickPipe 指南 {#guide-postgres-resync} + +1. 在数据源选项卡中,点击你希望进行 resync 的 Postgres ClickPipe。 +2. 前往 **设置** 选项卡。 +3. 点击 **Resync** 按钮。 + + + +4. 应该会出现一个确认对话框。再次点击 Resync。 +5. 前往 **度量** 选项卡。 +6. 大约 5 秒后(并在页面刷新时),管道的状态应为 **Setup** 或 **Snapshot**。 +7. 可以在 **表** 选项卡的 **初始加载统计信息** 部分监控 resync 的初始加载。 +8. 一旦初始加载完成,管道将原子性地将 `_resync` 表与原始表进行交换。在交换期间,状态将为 **Resync**。 +9. 一旦交换完成,管道将进入 **Running** 状态,并在启用时执行 CDC。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/resync.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/resync.md.hash new file mode 100644 index 00000000000..0026e040bb8 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/resync.md.hash @@ -0,0 +1 @@ +775867ae7b348af6 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/scaling.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/scaling.md new file mode 100644 index 00000000000..ffd57a44eb4 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/scaling.md @@ -0,0 +1,95 @@ +--- +'title': '通过 OpenAPI 扩展 DB ClickPipes' +'description': '文档用于通过 OpenAPI 扩展 DB ClickPipes' +'slug': '/integrations/clickpipes/postgres/scaling' +'sidebar_label': '扩展' +'doc_type': 'guide' +--- + +:::caution 大多数用户不需要此API +DB ClickPipes的默认配置旨在开箱即用地处理大多数工作负载。如果您认为您的工作负载需要扩展,请打开一个[支持案例](https://clickhouse.com/support/program),我们将指导您调整适合用例的最佳设置。 +::: + +扩展API可能对以下情况有用: +- 大量初始加载(超过4 TB) +- 尽可能快速地迁移适量数据 +- 在同一服务下支持超过8个CDC ClickPipes + +在尝试扩展之前,请考虑: +- 确保源DB有足够的可用容量 +- 在创建ClickPipe时,首先调整[初始负载并行性和分区](/integrations/clickpipes/postgres/parallel_initial_load) +- 检查源上是否存在[长时间运行的事务](/integrations/clickpipes/postgres/sync_control#transactions),这些事务可能导致CDC延迟 + +**增加规模将成比例地增加您的ClickPipes计算成本。** 如果您仅为初始加载进行扩展,则在快照完成后缩小规模以避免意外费用是很重要的。有关定价的更多详细信息,请参见[Postgres CDC定价](/cloud/reference/billing/clickpipes)。 + +## 该过程的前提条件 {#prerequisites} + +在开始之前,您需要: + +1. 具有目标ClickHouse Cloud服务的管理员权限的[ClickHouse API密钥](/cloud/manage/openapi)。 +2. 在某个时间点在服务中配置的DB ClickPipe(Postgres、MySQL或MongoDB)。CDC基础设施与第一个ClickPipe一起创建,扩展端点从那时起可用。 + +## 扩展DB ClickPipes的步骤 {#cdc-scaling-steps} + +在运行任何命令之前设置以下环境变量: + +```bash +ORG_ID= +SERVICE_ID= +KEY_ID= +KEY_SECRET= +``` + +获取当前的扩展配置(可选): + +```bash +curl --silent --user $KEY_ID:$KEY_SECRET \ +https://api.clickhouse.cloud/v1/organizations/$ORG_ID/services/$SERVICE_ID/clickpipesCdcScaling \ +| jq + + +# example result: +{ + "result": { + "replicaCpuMillicores": 2000, + "replicaMemoryGb": 8 + }, + "requestId": "04310d9e-1126-4c03-9b05-2aa884dbecb7", + "status": 200 +} +``` + +设置所需的扩展。支持的配置包括1-24个CPU核心,内存(GB)设置为核心数量的4倍: + +```bash +cat < SHOW wal_sender_timeout ; 如果尚未配置,请按照以下步骤操作: -1. 为您的 Aurora PostgreSQL 版本创建一个新的参数组,并设置所需的设置: +1. 为您的 Aurora PostgreSQL 版本创建一个新参数组,并设置所需的设置: - 将 `rds.logical_replication` 设置为 1 - 将 `wal_sender_timeout` 设置为 0 - + -2. 将新的参数组应用于您的 Aurora PostgreSQL 集群 +2. 将新参数组应用于您的 Aurora PostgreSQL 集群 - + -3. 重新启动您的 Aurora 集群以应用更改 +3. 重启您的 Aurora 集群以应用更改 ## 配置数据库用户 {#configure-database-user} -使用管理员用户连接到您的 Aurora PostgreSQL 写入实例,并执行以下命令: +作为管理员用户连接到您的 Aurora PostgreSQL 写入实例,并执行以下命令: 1. 为 ClickPipes 创建一个专用用户: @@ -73,7 +74,7 @@ postgres=> SHOW wal_sender_timeout ; CREATE USER clickpipes_user PASSWORD 'some-password'; ``` -2. 授予模式权限。以下示例显示的是 `public` 模式的权限。对每个您想要复制的模式重复这些命令: +2. 授予架构权限。以下示例显示了 `public` 架构的权限。对每个要复制的架构重复这些命令: ```sql GRANT USAGE ON SCHEMA "public" TO clickpipes_user; @@ -87,48 +88,46 @@ ALTER DEFAULT PRIVILEGES IN SCHEMA "public" GRANT SELECT ON TABLES TO clickpipes GRANT rds_replication TO clickpipes_user; ``` -4. 创建一个用于复制的发布: +4. 创建用于复制的发布: ```sql CREATE PUBLICATION clickpipes_publication FOR ALL TABLES; ``` - ## 配置网络访问 {#configure-network-access} ### 基于 IP 的访问控制 {#ip-based-access-control} -如果您想限制对 Aurora 集群的流量,请将 [记录的静态 NAT IP](../../index.md#list-of-static-ips) 添加到您的 Aurora 安全组的 `入站规则` 中。 +如果您想限制对 Aurora 集群的流量,请将[文档中列出的静态 NAT IPs](../../index.md#list-of-static-ips)添加到您 Aurora 安全组的 `Inbound rules` 中。 - + -### 通过 AWS PrivateLink 进行私有访问 {#private-access-via-aws-privatelink} +### 通过 AWS PrivateLink 的私有访问 {#private-access-via-aws-privatelink} -要通过私有网络连接到您的 Aurora 集群,您可以使用 AWS PrivateLink。按照我们的 [ClickPipes 的 AWS PrivateLink 设置指南](/knowledgebase/aws-privatelink-setup-for-clickpipes) 来设置连接。 +要通过私有网络连接到您的 Aurora 集群,可以使用 AWS PrivateLink。请按照我们的[ClickPipes 的 AWS PrivateLink 设置指南](/knowledgebase/aws-privatelink-setup-for-clickpipes)进行连接设置。 -### Aurora 特定注意事项 {#aurora-specific-considerations} +### 特定于 Aurora 的考虑事项 {#aurora-specific-considerations} -在使用 Aurora PostgreSQL 设置 ClickPipes 时,请记住以下注意事项: +在使用 Aurora PostgreSQL 设置 ClickPipes 时,请牢记以下考虑事项: -1. **连接终端**:始终连接到 Aurora 集群的写入终端,因为逻辑复制需要写入访问权限来创建复制槽,并且必须连接到主实例。 +1. **连接端点**:始终连接到您 Aurora 集群的写入端点,因为逻辑复制需要写入访问权限以创建复制槽并且必须连接到主实例。 -2. **故障转移处理**:在故障转移事件中,Aurora 将自动提升一个阅读器成为新的写入器。ClickPipes 将检测到断开连接并尝试重新连接到写入终端,此时它将指向新的主实例。 +2. **故障转移处理**:在发生故障转移时,Aurora 会自动提升一个读取实例为新的写入实例。ClickPipes 将检测到断开连接并尝试重新连接到写入端点,该端点现在将指向新的主实例。 -3. **全球数据库**:如果您使用的是 Aurora 全球数据库,您应连接到主区域的写入终端,因为跨区域复制已经处理了区域之间的数据移动。 +3. **全局数据库**:如果您使用 Aurora 全局数据库,应连接到主区域的写入端点,因为跨区域复制已经处理了区域之间的数据传输。 -4. **存储注意事项**:Aurora 的存储层在集群中的所有实例之间共享,这可以为逻辑复制提供比标准 RDS 更好的性能。 +4. **存储考虑**:Aurora 的存储层在集群中的所有实例之间共享,这可以为逻辑复制提供比标准 RDS 更好的性能。 -### 处理动态集群终端 {#dealing-with-dynamic-cluster-endpoints} +### 处理动态集群端点 {#dealing-with-dynamic-cluster-endpoints} -虽然 Aurora 提供了稳定的终端,可以自动路由到适当的实例,但还有一些附加方法可以确保一致的连接: +虽然 Aurora 提供了稳定的端点,可以自动路由到适当的实例,但还有一些额外的方法可以确保一致的连接性: -1. 对于高可用性设置,将应用程序配置为使用 Aurora 写入终端,该终端将自动指向当前主实例。 +1. 对于高可用性设置,请配置您的应用程序使用 Aurora 写入端点,该端点自动指向当前的主实例。 -2. 如果使用跨区域复制,请考虑为每个区域设置单独的 ClickPipes 以减少延迟并提高容错能力。 +2. 如果使用跨区域复制,请考虑为每个区域设置单独的 ClickPipes,以减少延迟并提高容错能力。 -## 接下来呢? {#whats-next} +## 接下来做什么? {#whats-next} -现在您可以 [创建您的 ClickPipe](../index.md) 并开始将数据从您的 Aurora PostgreSQL 集群摄取到 ClickHouse Cloud。 -请确保记录您在设置 Aurora PostgreSQL 集群时使用的连接详细信息,因为您将在 ClickPipe 创建过程中需要这些信息。 +您现在可以[创建您的 ClickPipe](../index.md)并开始将数据从您的 Aurora PostgreSQL 集群导入到 ClickHouse Cloud。在设置 Aurora PostgreSQL 集群时,请确保记下您使用的连接详细信息,因为在创建 ClickPipe 时需要这些信息。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/aurora.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/aurora.md.hash index 749c1bc55e7..35e11ea4fb1 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/aurora.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/aurora.md.hash @@ -1 +1 @@ -72968c73dc8d0f25 +01362d78b8eec2aa diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/azure-flexible-server-postgres.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/azure-flexible-server-postgres.md index 41474f5c91d..b58226ce527 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/azure-flexible-server-postgres.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/azure-flexible-server-postgres.md @@ -3,6 +3,7 @@ 'description': '将 Azure Flexible Server for Postgres 设置为 ClickPipes 的数据源' 'slug': '/integrations/clickpipes/postgres/source/azure-flexible-server-postgres' 'title': 'Azure Flexible Server for Postgres 源设置指南' +'doc_type': 'guide' --- import server_parameters from '@site/static/images/integrations/data-ingestion/clickpipes/postgres/source/azure-flexible-server-postgres/server_parameters.png'; @@ -12,37 +13,37 @@ import firewall from '@site/static/images/integrations/data-ingestion/clickpipes import Image from '@theme/IdealImage'; -# Azure Flexible Server for Postgres 源设置指南 +# Azure 灵活服务器的 Postgres 源设置指南 ClickPipes 支持 Postgres 版本 12 及更高版本。 ## 启用逻辑复制 {#enable-logical-replication} -**如果 `wal_level` 已设置为 `logical`,则您无需**按照以下步骤操作。如果您是从另一个数据复制工具迁移,这个设置通常应该是预配置的。 +**如果 `wal_level` 被设置为 `logical`,您无需** 执行以下步骤。如果您是从其他数据复制工具迁移过来的,此设置通常会是预配置的。 1. 点击 **服务器参数** 部分 - + 2. 将 `wal_level` 编辑为 `logical` - + -3. 此更改需要重启服务器。因此,请在请求时重新启动。 +3. 该更改将需要重新启动服务器。因此在请求时请重启。 ## 创建 ClickPipes 用户并授予权限 {#creating-clickpipes-user-and-granting-permissions} -通过管理员用户连接到您的 Azure Flexible Server Postgres,并运行以下命令: +通过管理员用户连接到您的 Azure 灵活服务器 Postgres,并运行以下命令: -1. 为 ClickPipes 专门创建一个 Postgres 用户。 +1. 为 ClickPipes 创建一个专用的 Postgres 用户。 ```sql CREATE USER clickpipes_user PASSWORD 'some-password'; ``` -2. 为您要从中复制表的架构提供只读访问权限给 `clickpipes_user`。以下示例显示了如何为 `public` 架构设置权限。如果您想授予多个架构的访问权限,可以为每个架构运行这三条命令。 +2. 向 `clickpipes_user` 提供从您复制表的架构的只读访问权限。下面的示例展示了为 `public` 架构设置权限。如果您想要授予多个架构的访问权限,您可以为每个架构运行这三条命令。 ```sql GRANT USAGE ON SCHEMA "public" TO clickpipes_user; @@ -50,13 +51,13 @@ GRANT SELECT ON ALL TABLES IN SCHEMA "public" TO clickpipes_user; ALTER DEFAULT PRIVILEGES IN SCHEMA "public" GRANT SELECT ON TABLES TO clickpipes_user; ``` -3. 授予该用户复制访问权限: +3. 授予该用户复制权限: ```sql ALTER ROLE clickpipes_user REPLICATION; ``` -4. 创建您将在将来用于创建镜像(复制)的发布。 +4. 创建将用于将来创建 MIRROR(复制)的出版物。 ```sql CREATE PUBLICATION clickpipes_publication FOR ALL TABLES; @@ -68,17 +69,15 @@ CREATE PUBLICATION clickpipes_publication FOR ALL TABLES; ALTER ROLE clickpipes_user SET wal_sender_timeout to 0; ``` - ## 将 ClickPipes IP 添加到防火墙 {#add-clickpipes-ips-to-firewall} 请按照以下步骤将 [ClickPipes IP](../../index.md#list-of-static-ips) 添加到您的网络。 -1. 转到 **网络** 标签,并将 [ClickPipes IP](../../index.md#list-of-static-ips) 添加到您的 Azure Flexible Server Postgres 的防火墙,或者如果您使用 SSH 隧道,则将其添加到跳板服务器/堡垒机。 - - +1. 转到 **网络** 标签,并将 [ClickPipes IP](../../index.md#list-of-static-ips) 添加到您 Azure 灵活服务器 Postgres 的防火墙,或如果您正在使用 SSH 隧道,则添加到跳转服务器/堡垒主机。 + ## 接下来是什么? {#whats-next} 您现在可以 [创建您的 ClickPipe](../index.md),并开始将数据从您的 Postgres 实例导入 ClickHouse Cloud。 -请务必记录您在设置 Postgres 实例时使用的连接详细信息,因为在创建 ClickPipe 过程中您将需要这些信息。 +请确保记下您在设置 Postgres 实例时使用的连接详细信息,因为在创建 ClickPipe 过程中您将需要它们。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/azure-flexible-server-postgres.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/azure-flexible-server-postgres.md.hash index 1a294c208e3..3ff140ea1bc 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/azure-flexible-server-postgres.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/azure-flexible-server-postgres.md.hash @@ -1 +1 @@ -6f47a0d65e470e76 +23361b6ba4658a18 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/crunchy-postgres.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/crunchy-postgres.md index d34a479d525..bb2ce5b26b7 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/crunchy-postgres.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/crunchy-postgres.md @@ -3,6 +3,7 @@ 'description': '将 Crunchy Bridge Postgres 设置为 ClickPipes 的数据源' 'slug': '/integrations/clickpipes/postgres/source/crunchy-postgres' 'title': 'Crunchy Bridge Postgres 源设置指南' +'doc_type': 'guide' --- import firewall_rules_crunchy_bridge from '@site/static/images/integrations/data-ingestion/clickpipes/postgres/source/setup/crunchy-postgres/firewall_rules_crunchy_bridge.png' @@ -16,7 +17,7 @@ ClickPipes 支持 Postgres 版本 12 及更高版本。 ## 启用逻辑复制 {#enable-logical-replication} -Crunchy Bridge 默认启用逻辑复制,具体请参见 [默认设置](https://docs.crunchybridge.com/how-to/logical-replication)。确保以下设置正确配置。如果未正确配置,请相应调整。 +Crunchy Bridge 默认启用逻辑复制 [default](https://docs.crunchybridge.com/how-to/logical-replication)。确保以下设置配置正确。如果不正确,请相应调整。 ```sql SHOW wal_level; -- should be logical @@ -26,7 +27,7 @@ SHOW max_replication_slots; -- should be 10 ## 创建 ClickPipes 用户并授予权限 {#creating-clickpipes-user-and-granting-permissions} -通过 `postgres` 用户连接到您的 Crunchy Bridge Postgres,并运行以下命令: +通过 `postgres` 用户连接到你的 Crunchy Bridge Postgres 并运行以下命令: 1. 创建一个专门用于 ClickPipes 的 Postgres 用户。 @@ -34,7 +35,7 @@ SHOW max_replication_slots; -- should be 10 CREATE USER clickpipes_user PASSWORD 'some-password'; ``` -2. 授予 `clickpipes_user` 从中复制表的模式的只读访问权限。下面的示例显示了为 `public` 模式授予权限。如果您想要授予多个模式的访问权限,可以对每个模式运行这三条命令。 +2. 向 `clickpipes_user` 授予只读访问你用于复制表的模式。下面的示例显示了授予 `public` 模式的权限。如果你想对多个模式授予访问权限,可以对每个模式运行这三个命令。 ```sql GRANT USAGE ON SCHEMA "public" TO clickpipes_user; @@ -42,13 +43,13 @@ GRANT SELECT ON ALL TABLES IN SCHEMA "public" TO clickpipes_user; ALTER DEFAULT PRIVILEGES IN SCHEMA "public" GRANT SELECT ON TABLES TO clickpipes_user; ``` -3. 授予该用户复制访问权限: +3. 向此用户授予复制访问权限: ```sql ALTER ROLE clickpipes_user REPLICATION; ``` -4. 创建将在未来用于创建 MIRROR(复制)的出版物。 +4. 创建你将在未来用来创建 MIRROR(复制)的发布。 ```sql CREATE PUBLICATION clickpipes_publication FOR ALL TABLES; @@ -56,12 +57,12 @@ CREATE PUBLICATION clickpipes_publication FOR ALL TABLES; ## 安全列表 ClickPipes IPs {#safe-list-clickpipes-ips} -通过在 Crunchy Bridge 中添加防火墙规则,将 [ClickPipes IPs](../../index.md#list-of-static-ips) 列入安全列表。 +通过在 Crunchy Bridge 中添加防火墙规则来安全列出 [ClickPipes IPs](../../index.md#list-of-static-ips)。 - + -## 接下来是什么? {#whats-next} +## 接下来怎么办? {#whats-next} -您现在可以 [创建您的 ClickPipe](../index.md),并开始从您的 Postgres 实例向 ClickHouse Cloud 导入数据。请确保记录您在设置 Postgres 实例时使用的连接详细信息,因为在创建 ClickPipe 时您将需要这些信息。 +你现在可以 [创建你的 ClickPipe](../index.md) 并开始将数据从你的 Postgres 实例导入到 ClickHouse Cloud。请确保记下设置 Postgres 实例时使用的连接详细信息,因为你在创建 ClickPipe 过程中将需要它们。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/crunchy-postgres.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/crunchy-postgres.md.hash index b1c66ce426d..e6f5b3dd3ee 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/crunchy-postgres.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/crunchy-postgres.md.hash @@ -1 +1 @@ -7fb168e0b6250ea8 +fd58a387184fb83e diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/generic.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/generic.md index f7240493f0e..3555cc99882 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/generic.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/generic.md @@ -1,8 +1,9 @@ --- 'sidebar_label': '通用 Postgres' -'description': '将任何 Postgres 实例设置为 ClickPipes 的源' +'description': '将任何 Postgres 实例设置为 ClickPipes 的数据源' 'slug': '/integrations/clickpipes/postgres/source/generic' 'title': '通用 Postgres 源设置指南' +'doc_type': 'guide' --- @@ -10,11 +11,10 @@ :::info -如果您使用的是受支持的提供商(在侧边栏中),请参考该提供商的具体指南。 +如果您使用的是支持的提供商(在侧边栏中),请参阅该提供商的具体指南。 ::: - ClickPipes 支持 Postgres 版本 12 及更高版本。 ## 启用逻辑复制 {#enable-logical-replication} @@ -29,7 +29,7 @@ wal_level = logical SHOW wal_level; ``` - 输出应该是 `logical`。如果不是,请运行: + 输出应为 `logical`。如果不是,请运行: ```sql ALTER SYSTEM SET wal_level = logical; ``` @@ -45,13 +45,12 @@ SHOW max_wal_senders; SHOW max_replication_slots; ``` - 如果值与推荐值不匹配,您可以运行以下 SQL 命令进行设置: + 如果值不匹配推荐值,您可以运行以下 SQL 命令来进行设置: ```sql ALTER SYSTEM SET max_wal_senders = 10; ALTER SYSTEM SET max_replication_slots = 10; ``` -3. 如果您对配置进行了上述更改,您需要重新启动 Postgres 实例以使更改生效。 - +3. 如果您对上述配置进行了任何更改,则需要重新启动 Postgres 实例以使更改生效。 ## 创建具有权限和发布的用户 {#creating-a-user-with-permissions-and-publication} @@ -72,16 +71,15 @@ ALTER SYSTEM SET max_replication_slots = 10; ``` :::note -确保用您想要的用户名和密码替换 `clickpipes_user` 和 `clickpipes_password`。 +确保将 `clickpipes_user` 和 `clickpipes_password` 替换为您想要的用户名和密码。 ::: - ## 在 pg_hba.conf 中启用对 ClickPipes 用户的连接 {#enabling-connections-in-pg_hbaconf-to-the-clickpipes-user} -如果您是自服务用户,您需要通过以下步骤允许来自 ClickPipes IP 地址的连接。如果您使用的是托管服务,可以按照提供商的文档进行相同的操作。 +如果您是自服务,您需要按照以下步骤允许从 ClickPipes IP 地址连接到 ClickPipes 用户。如果您使用的是托管服务,您可以通过遵循提供商的文档来执行相同操作。 -1. 对 `pg_hba.conf` 文件进行必要的更改,以允许来自 ClickPipes IP 地址的连接。`pg_hba.conf` 文件中的示例条目如下所示: +1. 对 `pg_hba.conf` 文件进行必要更改,以允许从 ClickPipes IP 地址连接到 ClickPipes 用户。`pg_hba.conf` 文件中的示例条目如下所示: ```response host all clickpipes_user 0.0.0.0/0 scram-sha-256 ``` @@ -91,12 +89,11 @@ host all clickpipes_user 0.0.0.0/0 scram-sha-256 SELECT pg_reload_conf(); ``` - ## 增加 `max_slot_wal_keep_size` {#increase-max_slot_wal_keep_size} -这是一个推荐的配置更改,以确保大事务/提交不会导致复制槽被删除。 +这是一个推荐的配置更改,以确保大型事务/提交不会导致复制槽被删除。 -您可以通过更新 `postgresql.conf` 文件,将 PostgreSQL 实例的 `max_slot_wal_keep_size` 参数增加到更高的值(至少 100GB 或 `102400`)。 +您可以将 PostgreSQL 实例的 `max_slot_wal_keep_size` 参数增加到更高的值(至少 100GB 或 `102400`),通过更新 `postgresql.conf` 文件。 ```sql max_slot_wal_keep_size = 102400 @@ -109,11 +106,11 @@ SELECT pg_reload_conf(); :::note -关于该值的更好建议,您可以联系 ClickPipes 团队。 +有关该值的更好推荐,您可以联系 ClickPipes 团队。 ::: -## 下一步是什么? {#whats-next} +## 接下来做什么? {#whats-next} -您现在可以 [创建您的 ClickPipe](../index.md) 并开始将数据从您的 Postgres 实例导入到 ClickHouse Cloud。 -请确保记录下您在设置 Postgres 实例时使用的连接详细信息,因为在创建 ClickPipe 过程中您将需要这些信息。 +您现在可以 [创建您的 ClickPipe](../index.md) 并开始将数据从您的 Postgres 实例导入 ClickHouse Cloud。 +请务必记下在设置 Postgres 实例时使用的连接详细信息,因为在创建 ClickPipe 过程中需要使用这些信息。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/generic.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/generic.md.hash index 6e997aa9aba..d615dadd968 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/generic.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/generic.md.hash @@ -1 +1 @@ -3362718631b231ea +fe53b318f0381558 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/google-cloudsql.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/google-cloudsql.md index 222cc7230dd..cf8611a69c0 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/google-cloudsql.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/google-cloudsql.md @@ -1,8 +1,9 @@ --- 'sidebar_label': 'Google Cloud SQL' -'description': '将 Google Cloud SQL Postgres 实例设置为 ClickPipes 的数据源' +'description': '将谷歌云 SQL Postgres 实例设置为 ClickPipes 的数据源' 'slug': '/integrations/clickpipes/postgres/source/google-cloudsql' -'title': 'Google Cloud SQL Postgres 源设置指南' +'title': '谷歌云 SQL Postgres 源设置指南' +'doc_type': 'guide' --- import edit_button from '@site/static/images/integrations/data-ingestion/clickpipes/postgres/source/google-cloudsql/edit.png'; @@ -20,41 +21,39 @@ import Image from '@theme/IdealImage'; :::info -如果您使用的是边栏中支持的提供商,请参考该提供商的具体指南。 +如果您使用所支持的提供商之一(在侧边栏中),请参阅该提供商的特定指南。 ::: - ## 支持的 Postgres 版本 {#supported-postgres-versions} -Postgres 12 或更高版本的任何版本 +任何版本为 Postgres 12 或更高版本。 ## 启用逻辑复制 {#enable-logical-replication} -**如果** 设置 `cloudsql.logical_decoding` 为开启且 `wal_sender_timeout` 为 0,则您不需要执行下面的步骤。如果您是从其他数据复制工具迁移,此设置通常应已预配置。 +**如果设置 `cloudsql.logical_decoding` 为开启且 `wal_sender_timeout` 为 0,则您不需要** 按照以下步骤操作。这些设置在迁移自其他数据复制工具时通常会预先配置。 1. 点击概览页面上的 **编辑** 按钮。 -2. 前往标志,并将 `cloudsql.logical_decoding` 更改为开启,`wal_sender_timeout` 更改为 0。此更改将需要重启您的 Postgres 服务器。 +2. 转到标志,并将 `cloudsql.logical_decoding` 更改为开启,`wal_sender_timeout` 更改为 0。这些更改需要重启您的 Postgres 服务器。 - ## 创建 ClickPipes 用户并授予权限 {#creating-clickpipes-user-and-granting-permissions} -通过管理员用户连接到您的 Cloud SQL Postgres 并运行以下命令: +通过管理员用户连接到您的 Cloud SQL Postgres,并运行以下命令: -1. 为专门的 ClickPipes 创建一个 Postgres 用户。 +1. 为 ClickPipes 创建一个 Postgres 用户。 ```sql CREATE USER clickpipes_user PASSWORD 'some-password'; ``` -2. 为从中复制表的模式提供只读访问权限给 `clickpipes_user`。下面的示例展示了为 `public` 模式设置权限。如果您想要授予多个模式的访问权限,可以为每个模式运行这三个命令。 +2. 向 `clickpipes_user` 提供从中复制表的架构的只读访问权限。以下示例显示了为 `public` 架构设置权限。如果您希望授予多个架构的访问权限,可以对每个架构运行这三条命令。 ```sql GRANT USAGE ON SCHEMA "public" TO clickpipes_user; @@ -62,13 +61,13 @@ GRANT SELECT ON ALL TABLES IN SCHEMA "public" TO clickpipes_user; ALTER DEFAULT PRIVILEGES IN SCHEMA "public" GRANT SELECT ON TABLES TO clickpipes_user; ``` -3. 授予该用户复制访问权限: +3. 授予此用户复制访问权限: ```sql ALTER ROLE clickpipes_user REPLICATION; ``` -4. 创建将在未来用于创建 MIRROR(复制)的发布。 +4. 创建将来用于创建 MIRROR(复制)的发布。 ```sql CREATE PUBLICATION clickpipes_publication FOR ALL TABLES; @@ -76,22 +75,21 @@ CREATE PUBLICATION clickpipes_publication FOR ALL TABLES; [//]: # (TODO 添加 SSH 隧道) - ## 将 ClickPipes IP 添加到防火墙 {#add-clickpipes-ips-to-firewall} -请遵循以下步骤将 ClickPipes IP 添加到您的网络。 +请按照以下步骤将 ClickPipes IP 添加到您的网络。 :::note -如果您正在使用 SSH 隧道,则需要将 [ClickPipes IP](../../index.md#list-of-static-ips) 添加到跳转服务器/堡垒主机的防火墙规则中。 +如果您使用 SSH 隧道,则需要将 [ClickPipes IP](../../index.md#list-of-static-ips) 添加到跳转服务器/堡垒的防火墙规则中。 ::: -1. 前往 **连接** 部分 +1. 转到 **连接** 部分 -2. 前往网络子部分 +2. 转到网络子部分 @@ -100,7 +98,7 @@ CREATE PUBLICATION clickpipes_publication FOR ALL TABLES; - ## 下一步是什么? {#whats-next} -您现在可以 [创建您的 ClickPipe](../index.md),并开始将数据从您的 Postgres 实例导入 ClickHouse Cloud。在设置 Postgres 实例时,请确保记下您使用的连接详细信息,因为在创建 ClickPipe 过程中您将需要这些信息。 +您现在可以 [创建您的 ClickPipe](../index.md) 并开始将数据从您的 Postgres 实例加载到 ClickHouse Cloud 中。 +确保记下您在设置 Postgres 实例时使用的连接详细信息,因为在 ClickPipe 创建过程中将需要这些信息。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/google-cloudsql.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/google-cloudsql.md.hash index 5f631c85faf..4c0f46d3d4f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/google-cloudsql.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/google-cloudsql.md.hash @@ -1 +1 @@ -5de14e657c542865 +cf5ba8e7ae1d7d30 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/neon-postgres.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/neon-postgres.md index 19876bb5eb2..6bf124f1efc 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/neon-postgres.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/neon-postgres.md @@ -3,6 +3,7 @@ 'description': '将 Neon Postgres 实例设置为 ClickPipes 的数据源' 'slug': '/integrations/clickpipes/postgres/source/neon-postgres' 'title': 'Neon Postgres 源设置指南' +'doc_type': 'guide' --- import neon_commands from '@site/static/images/integrations/data-ingestion/clickpipes/postgres/source/setup/neon-postgres/neon-commands.png' @@ -15,14 +16,13 @@ import Image from '@theme/IdealImage'; # Neon Postgres 源设置指南 -这是关于如何设置 Neon Postgres 的指南,您可以在 ClickPipes 中用于复制。确保您已登录到您的 [Neon 控制台](https://console.neon.tech/app/projects) 以进行此设置。 +这是一个关于如何设置 Neon Postgres 的指南,您可以将其用于 ClickPipes 的复制。确保您已登录到您的 [Neon 控制台](https://console.neon.tech/app/projects) 进行此设置。 ## 创建具有权限的用户 {#creating-a-user-with-permissions} -让我们为 ClickPipes 创建一个新用户,并授予适合 CDC 所需的权限,同时创建一个将用于复制的出版物。 +让我们为 ClickPipes 创建一个新的用户,并授予其适合 CDC 的必要权限,同时创建一个用于复制的发布。 -为此,您可以前往 **SQL 编辑器** 选项卡。 -在这里,我们可以运行以下 SQL 命令: +为此,您可以前往 **SQL 编辑器** 选项卡。在这里,我们可以运行以下 SQL 命令: ```sql CREATE USER clickpipes_user PASSWORD 'clickpipes_password'; @@ -37,41 +37,39 @@ import Image from '@theme/IdealImage'; CREATE PUBLICATION clickpipes_publication FOR ALL TABLES; ``` - + -点击 **运行** 以准备好出版物和用户。 +单击 **运行**,以准备好一个发布和一个用户。 ## 启用逻辑复制 {#enable-logical-replication} -在 Neon 中,您可以通过 UI 启用逻辑复制。这对于 ClickPipes 的 CDC 复制数据是必要的。 -前往 **设置** 选项卡,然后转到 **逻辑复制** 部分。 + +在 Neon 中,您可以通过 UI 启用逻辑复制。这对于 ClickPipes 的 CDC 复制数据是必要的。前往 **设置** 选项卡,然后转到 **逻辑复制** 部分。 -点击 **启用** 以完成设置。一旦您启用它,您应该会看到以下成功消息。 +单击 **启用**,以在这里完成设置。您启用后应该会看到以下成功消息。 -让我们验证以下设置在您的 Neon Postgres 实例中: +让我们验证您 Neon Postgres 实例中的以下设置: ```sql SHOW wal_level; -- should be logical SHOW max_wal_senders; -- should be 10 SHOW max_replication_slots; -- should be 10 ``` -## IP 白名单(针对 Neon 企业计划) {#ip-whitelisting-for-neon-enterprise-plan} -如果您有 Neon 企业计划,您可以将 [ClickPipes IPs](../../index.md#list-of-static-ips) 加入白名单,以允许从 ClickPipes 到您的 Neon Postgres 实例的复制。 -为此,您可以点击 **设置** 选项卡,然后转到 **IP 允许** 部分。 +## IP 白名单 (适用于 Neon 企业计划) {#ip-whitelisting-for-neon-enterprise-plan} + +如果您拥有 Neon 企业计划,可以将 [ClickPipes IP](../../index.md#list-of-static-ips) 加入白名单,以允许 ClickPipes 对您的 Neon Postgres 实例进行复制。为此,您可以单击 **设置** 选项卡并转到 **IP 允许** 部分。 -## 复制连接详情 {#copy-connection-details} -现在我们已经准备好用户、出版物以及启用了复制,我们可以复制连接详情以创建一个新的 ClickPipe。 -前往 **仪表板**,在显示连接字符串的文本框中, -将视图更改为 **仅参数**。我们将在下一步中需要这些参数。 +## 复制连接详细信息 {#copy-connection-details} + +现在我们已经准备好了用户、发布,并启用了复制,我们可以复制连接详细信息以创建新的 ClickPipe。前往 **仪表板**,在显示连接字符串的文本框中,将视图更改为 **仅参数**。我们将在下一步中需要这些参数。 - + -## 接下来是什么? {#whats-next} +## 下一步怎么办? {#whats-next} -您现在可以 [创建您的 ClickPipe](../index.md) 并开始将数据从您的 Postgres 实例引入 ClickHouse Cloud。 -请确保记下设置 Postgres 实例时使用的连接详情,因为在 ClickPipe 创建过程中您将需要它们。 +您现在可以 [创建您的 ClickPipe](../index.md) 并开始从您的 Postgres 实例向 ClickHouse Cloud 中摄取数据。请确保记下您在设置 Postgres 实例时使用的连接详细信息,因为在创建 ClickPipe 过程中您将需要这些信息。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/neon-postgres.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/neon-postgres.md.hash index e5386c32f6b..691c6c49416 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/neon-postgres.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/neon-postgres.md.hash @@ -1 +1 @@ -291a2838e900db3b +62236768ae9d5ec3 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/planetscale.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/planetscale.md new file mode 100644 index 00000000000..c3d023ac3a9 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/planetscale.md @@ -0,0 +1,79 @@ +--- +'sidebar_label': 'Planetscale for Postgres' +'description': '将 Planetscale 设置为 ClickPipes 的数据源' +'slug': '/integrations/clickpipes/postgres/source/planetscale' +'title': 'PlanetScale for Postgres 源设置指南' +'doc_type': 'guide' +--- + +import planetscale_wal_level_logical from '@site/static/images/integrations/data-ingestion/clickpipes/postgres/source/planetscale/planetscale_wal_level_logical.png'; +import planetscale_max_slot_wal_keep_size from '@site/static/images/integrations/data-ingestion/clickpipes/postgres/source/planetscale/planetscale_max_slot_wal_keep_size.png'; +import Image from '@theme/IdealImage'; + + +# PlanetScale for Postgres 源设置指南 + +:::info +PlanetScale for Postgres 目前处于 [早期访问](https://planetscale.com/postgres) 阶段。 +::: + +## 支持的 Postgres 版本 {#supported-postgres-versions} + +ClickPipes 支持 Postgres 版本 12 及更高版本。 + +## 启用逻辑复制 {#enable-logical-replication} + +1. 要在您的 Postgres 实例上启用复制,我们需要确保以下设置已配置: + +```sql +wal_level = logical +``` + 要检查相同的内容,您可以运行以下 SQL 命令: +```sql +SHOW wal_level; +``` + + 默认情况下,输出应该是 `logical`。如果不是,请登录到 PlanetScale 控制台,转到 `Cluster configuration->Parameters`,并向下滚动到 `Write-ahead log` 进行更改。 + + + +:::warning +在 PlanetScale 控制台中更改此设置将会触发重启。 +::: + +2. 此外,建议将 `max_slot_wal_keep_size` 的设置从默认的 4GB 增加。这也可通过 PlanetScale 控制台进行,方法是转到 `Cluster configuration->Parameters` 然后向下滚动到 `Write-ahead log`。有关新值的帮助,请查看 [这里](../faq#recommended-max_slot_wal_keep_size-settings)。 + + + +## 创建具有权限和发布的用户 {#creating-a-user-with-permissions-and-publication} + +让我们为 ClickPipes 创建一个具有适合 CDC 的必要权限的新用户,并创建一个我们将用于复制的发布。 + +为此,您可以使用默认的 `postgres.<...>` 用户连接到您的 PlanetScale Postgres 实例,并运行以下 SQL 命令: +```sql + CREATE USER clickpipes_user PASSWORD 'clickpipes_password'; + GRANT USAGE ON SCHEMA "public" TO clickpipes_user; +-- You may need to grant these permissions on more schemas depending on the tables you're moving + GRANT SELECT ON ALL TABLES IN SCHEMA "public" TO clickpipes_user; + ALTER DEFAULT PRIVILEGES IN SCHEMA "public" GRANT SELECT ON TABLES TO clickpipes_user; + +-- Give replication permission to the USER + ALTER USER clickpipes_user REPLICATION; + +-- Create a publication. We will use this when creating the pipe +-- When adding new tables to the ClickPipe, you'll need to manually add them to the publication as well. + CREATE PUBLICATION clickpipes_publication FOR TABLE <...>, <...>, <...>; +``` +:::note +确保将 `clickpipes_user` 和 `clickpipes_password` 替换为您想要的用户名和密码。 +::: + +## 注意事项 {#caveats} +1. 要连接到 PlanetScale Postgres,目前的分支需要附加到上述创建的用户名后。例如,如果创建的用户名为 `clickpipes_user`,则在 ClickPipe 创建期间提供的实际用户需要是 `clickpipes_user`.`branch`,其中 `branch` 指的是当前 PlanetScale Postgres [分支](https://planetscale.com/docs/postgres/branching) 的 “id”。要快速确定这一点,您可以参考您之前用于创建用户的 `postgres` 用户的用户名,句点后的部分将是分支 id。 +2. 连接到 PlanetScale Postgres 的 CDC 管道时,请勿使用 `PSBouncer` 端口(当前为 `6432`),必须使用常规端口 `5432`。仅在初始加载的管道中可以使用任一端口。 +3. 请确保您仅连接到主实例,[连接到副本实例](https://planetscale.com/docs/postgres/scaling/replicas#how-to-query-postgres-replicas) 当前不支持。 + +## 接下来是什么? {#whats-next} + +您现在可以 [创建您的 ClickPipe](../index.md) 并开始将数据从您的 Postgres 实例导入到 ClickHouse Cloud。 +请务必记下您在设置 Postgres 实例时使用的连接详细信息,因为在创建 ClickPipe 过程中您将需要这些信息。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/planetscale.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/planetscale.md.hash new file mode 100644 index 00000000000..940a31f863d --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/planetscale.md.hash @@ -0,0 +1 @@ +fc49722676b07407 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/rds.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/rds.md index c8517e9f838..77031bf5973 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/rds.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/rds.md @@ -1,8 +1,9 @@ --- 'sidebar_label': 'Amazon RDS Postgres' -'description': '将 Amazon RDS Postgres 设置为 ClickPipes 的数据源' +'description': '将 Amazon RDS Postgres 设置为 ClickPipes 的源' 'slug': '/integrations/clickpipes/postgres/source/rds' 'title': 'RDS Postgres 源设置指南' +'doc_type': 'guide' --- import parameter_group_in_blade from '@site/static/images/integrations/data-ingestion/clickpipes/postgres/source/rds/parameter_group_in_blade.png'; @@ -27,7 +28,7 @@ ClickPipes 支持 Postgres 版本 12 及更高版本。 - `rds.logical_replication = 1` - `wal_sender_timeout = 0` -如果您之前使用过其他数据复制工具,这些设置通常会预先配置。 +如果您之前使用过其他数据复制工具,这些设置通常是预先配置的。 ```text postgres=> SHOW rds.logical_replication ; @@ -45,7 +46,7 @@ postgres=> SHOW wal_sender_timeout ; 如果尚未配置,请按照以下步骤操作: -1. 为您的 Postgres 版本创建新的参数组并包含所需的设置: +1. 为您的 Postgres 版本创建一个新的参数组,并设置所需的设置: - 将 `rds.logical_replication` 设置为 1 - 将 `wal_sender_timeout` 设置为 0 @@ -57,7 +58,7 @@ postgres=> SHOW wal_sender_timeout ; 2. 将新的参数组应用于您的 RDS Postgres 数据库 - + 3. 重启您的 RDS 实例以应用更改 @@ -65,15 +66,15 @@ postgres=> SHOW wal_sender_timeout ; ## 配置数据库用户 {#configure-database-user} -以管理员用户连接到您的 RDS Postgres 实例并执行以下命令: +以管理员用户身份连接到您的 RDS Postgres 实例并执行以下命令: -1. 为 ClickPipes 创建专用用户: +1. 为 ClickPipes 创建一个专用用户: ```sql CREATE USER clickpipes_user PASSWORD 'some-password'; ``` -2. 授予架构权限。以下示例显示 `public` 架构的权限。对您要复制的每个架构重复这些命令: +2. 授予模式权限。以下示例显示了对 `public` 模式的权限。对于您想要复制的每个模式,请重复这些命令: ```sql GRANT USAGE ON SCHEMA "public" TO clickpipes_user; @@ -87,7 +88,7 @@ ALTER DEFAULT PRIVILEGES IN SCHEMA "public" GRANT SELECT ON TABLES TO clickpipes GRANT rds_replication TO clickpipes_user; ``` -4. 创建一个用于复制的出版物: +4. 创建一个用于复制的发布: ```sql CREATE PUBLICATION clickpipes_publication FOR ALL TABLES; @@ -97,7 +98,7 @@ CREATE PUBLICATION clickpipes_publication FOR ALL TABLES; ### 基于 IP 的访问控制 {#ip-based-access-control} -如果您希望限制对 RDS 实例的流量,请将 [文档中列出的静态 NAT IPs](../../index.md#list-of-static-ips) 添加到 RDS 安全组的 `Inbound rules` 中。 +如果您希望限制对 RDS 实例的流量,请将 [文档中列出的静态 NAT IPs](../../index.md#list-of-static-ips) 添加到您的 RDS 安全组的 `Inbound rules`。 @@ -108,14 +109,14 @@ CREATE PUBLICATION clickpipes_publication FOR ALL TABLES; 要通过私有网络连接到您的 RDS 实例,可以使用 AWS PrivateLink。请按照我们的 [ClickPipes 的 AWS PrivateLink 设置指南](/knowledgebase/aws-privatelink-setup-for-clickpipes) 设置连接。 ### RDS Proxy 的解决方法 {#workarounds-for-rds-proxy} -RDS Proxy 不支持逻辑复制连接。如果您的 RDS 中有动态 IP 地址且无法使用 DNS 名称或 lambda,这里有一些替代方案: +RDS Proxy 不支持逻辑复制连接。如果您的 RDS 中有动态 IP 地址且无法使用 DNS 名称或 Lambda,则可以考虑以下替代方案: -1. 使用 cron 作业,定期解析 RDS 终端节点的 IP 并在更改时更新 NLB。 -2. 使用 RDS 事件通知与 EventBridge/SNS:通过 AWS RDS 事件通知自动触发更新。 +1. 使用定时任务定期解析 RDS 终端节点的 IP,并在更改时更新 NLB。 +2. 使用 RDS 事件通知与 EventBridge/SNS:使用 AWS RDS 事件通知自动触发更新。 3. 稳定的 EC2:部署一个 EC2 实例作为轮询服务或基于 IP 的代理。 4. 使用 Terraform 或 CloudFormation 等工具自动化 IP 地址管理。 -## 接下来是什么? {#whats-next} +## 接下来做什么? {#whats-next} 您现在可以 [创建您的 ClickPipe](../index.md),并开始将数据从您的 Postgres 实例导入到 ClickHouse Cloud。 -请确保记录下您在设置 Postgres 实例时使用的连接详细信息,因为在创建 ClickPipe 过程中需要这些信息。 +请确保记录下您在设置 Postgres 实例时使用的连接详细信息,因为在创建 ClickPipe 过程中您将需要这些信息。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/rds.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/rds.md.hash index ac3a3256a6e..cfeef5ef1cc 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/rds.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/rds.md.hash @@ -1 +1 @@ -2e99c1b72f9b936b +cf6d87d4aea23351 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/supabase.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/supabase.md index 2a587bca0e6..72182a3c86b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/supabase.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/supabase.md @@ -3,6 +3,7 @@ 'description': '将 Supabase 实例设置为 ClickPipes 的数据源' 'slug': '/integrations/clickpipes/postgres/source/supabase' 'title': 'Supabase 源设置指南' +'doc_type': 'guide' --- import supabase_commands from '@site/static/images/integrations/data-ingestion/clickpipes/postgres/source/setup/supabase/supabase-commands.jpg' @@ -12,18 +13,17 @@ import Image from '@theme/IdealImage'; # Supabase 源设置指南 -这是关于如何为 ClickPipes 设置 Supabase Postgres 的指南。 +这是一个关于如何设置 Supabase Postgres 以便在 ClickPipes 中使用的指南。 :::note -ClickPipes 原生支持通过 IPv6 进行无缝复制的 Supabase。 +ClickPipes 原生支持通过 IPv6 使用 Supabase,以实现无缝复制。 ::: +## 创建具有权限和复制槽的用户 {#creating-a-user-with-permissions-and-replication-slot} -## 创建具有权限和复制插槽的用户 {#creating-a-user-with-permissions-and-replication-slot} - -我们来为 ClickPipes 创建一个具有适合 CDC 的必要权限的新用户,并创建一个我们将用于复制的发布。 +让我们为 ClickPipes 创建一个新用户,赋予必要的权限以适应 CDC,并创建一个用于复制的发布。 为此,您可以前往您的 Supabase 项目的 **SQL 编辑器**。在这里,我们可以运行以下 SQL 命令: ```sql @@ -41,46 +41,48 @@ ClickPipes 原生支持通过 IPv6 进行无缝复制的 Supabase。 - -单击 **运行** 以准备一个发布和一个用户。 +点击 **运行** 以准备好一个发布和一个用户。 :::note -确保将 `clickpipes_user` 和 `clickpipes_password` 替换为您想要的用户名和密码。 +确保将 `clickpipes_user` 和 `clickpipes_password` 替换为您所需的用户名和密码。 -另外,请记住在 ClickPipes 中创建镜像时使用相同的发布名称。 +此外,创建 ClickPipes 镜像时,请记得使用相同的发布名称。 ::: - ## 增加 `max_slot_wal_keep_size` {#increase-max_slot_wal_keep_size} - :::warning 此步骤将重新启动您的 Supabase 数据库,并可能导致短暂的停机。 -您可以通过以下 [Supabase Docs](https://supabase.com/docs/guides/database/custom-postgres-config#cli-supported-parameters) 提高您 Supabase 数据库的 `max_slot_wal_keep_size` 参数的值(至少 100GB 或 `102400`)。 +您可以将 Supabase 数据库的 `max_slot_wal_keep_size` 参数增加到更高的值(至少 100GB 或 `102400`),具体方法请参见 [Supabase 文档](https://supabase.com/docs/guides/database/custom-postgres-config#cli-supported-parameters) -如需更好的建议,您可以联系 ClickPipes 团队。 +如需对此值的更佳建议,您可以联系 ClickPipes 团队。 ::: -## 用于 Supabase 的连接详情 {#connection-details-to-use-for-supabase} +## Supabase 的连接详情 {#connection-details-to-use-for-supabase} 前往您的 Supabase 项目的 `项目设置` -> `数据库`(在 `配置` 下)。 -**重要**:在此页面上禁用 `显示连接池器`,然后转到 `连接参数` 部分并记录/复制参数。 +**重要**:在此页面上禁用 `显示连接池`,然后前往 `连接参数` 部分,记下/复制这些参数。 - + :::info -连接池器不支持基于 CDC 的复制,因此需要禁用。 +连接池不支持基于 CDC 的复制,因此需要禁用。 ::: +## 关于 RLS 的说明 {#note-on-rls} +ClickPipes Postgres 用户不能受到 RLS 策略的限制,否则可能导致数据缺失。您可以通过运行以下命令禁用该用户的 RLS 策略: +```sql +ALTER USER clickpipes_user BYPASSRLS; +``` -## 接下来是什么? {#whats-next} +## 下一步是什么? {#whats-next} -您现在可以 [创建您的 ClickPipe](../index.md),并开始从您的 Postgres 实例向 ClickHouse Cloud 导入数据。确保记下您在设置 Postgres 实例时使用的连接详情,因为您在创建 ClickPipe 过程中需要这些信息。 +您现在可以 [创建您的 ClickPipe](../index.md),并开始将数据从您的 Postgres 实例导入到 ClickHouse Cloud。请确保记下在设置 Postgres 实例时使用的连接详情,因为在创建 ClickPipe 过程中将需要这些信息。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/supabase.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/supabase.md.hash index c7590e874d5..461bb463af5 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/supabase.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/supabase.md.hash @@ -1 +1 @@ -b9112f4063157960 +e4c744d7f73d8e7b diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/timescale.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/timescale.md index 27dd8301b39..c5f15c0caeb 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/timescale.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/timescale.md @@ -5,26 +5,27 @@ 'title': 'Postgres与TimescaleDB源设置指南' 'keywords': - 'TimescaleDB' +'doc_type': 'guide' --- import BetaBadge from '@theme/badges/BetaBadge'; -# Postgres with TimescaleDB 源设置指南 +# 配置使用 TimescaleDB 的 Postgres 源设置指南 ## 背景 {#background} -[TimescaleDB](https://github.com/timescale/timescaledb) 是由 Timescale Inc 开发的开源 Postgres 扩展,它旨在提高分析查询的性能,而无需迁移离开 Postgres。这是通过创建由扩展管理的“超表”,并支持自动分区为“块”来实现的。超表还支持透明压缩和混合行列存储(称为“hypercore”),尽管这些功能需要具有专有许可证的扩展版本。 +[TimescaleDB](https://github.com/timescale/timescaledb) 是由 Timescale Inc 开发的开源 Postgres 扩展,旨在提高分析查询的性能,而无需远离 Postgres。这是通过创建由扩展管理的“超表”来实现的,它支持自动分区为“分块”。超表还支持透明压缩和混合行列存储(称为“hypercore”),尽管这些特性需要具有专有许可证的扩展版本。 -Timescale Inc 还为 TimescaleDB 提供两种托管服务: +Timescale Inc 还为 TimescaleDB 提供两项托管服务: - `Managed Service for Timescale` - `Timescale Cloud`。 -有第三方供应商提供托管服务,允许您使用 TimescaleDB 扩展,但由于许可证限制,这些供应商仅支持开源版本的扩展。 +还有第三方供应商提供托管服务,允许您使用 TimescaleDB 扩展,但由于许可原因,这些供应商仅支持扩展的开源版本。 -Timescale 超表在多个方面的行为与常规 Postgres 表不同。这给复制它们的过程带来了一些复杂性,这就是为什么考虑复制 Timescale 超表的能力应被视为 **尽力而为**。 +Timescale 超表与常规 Postgres 表在多个方面的行为不同。这给复制过程带来了一些复杂性,这就是为什么复制 Timescale 超表的能力应视为 **尽力而为**。 ## 支持的 Postgres 版本 {#supported-postgres-versions} @@ -32,26 +33,26 @@ ClickPipes 支持 Postgres 版本 12 及更高版本。 ## 启用逻辑复制 {#enable-logical-replication} -要遵循的步骤取决于您的 TimescaleDB 实例的部署方式。 +要遵循的步骤取决于您部署 TimescaleDB 的 Postgres 实例的方式。 -- 如果您使用的是托管服务,并且您的服务提供商在侧边栏中列出,请遵循该提供商的指南。 +- 如果您使用的是托管服务,并且您的提供商在侧边栏中列出,请遵循该提供商的指南。 - 如果您自己部署 TimescaleDB,请遵循通用指南。 -对于其他托管服务,如果尚未启用逻辑复制,请向您的服务提供商提交支持票。 +对于其他托管服务,如果尚未启用逻辑复制,请向您的供应商提交支持工单以获得帮助。 :::info -Timescale Cloud 不支持启用逻辑复制,这是在 CDC 模式下 Postgres 管道所需的。因此,Timescale Cloud 的用户只能进行一次性加载数据(`Initial Load Only`)与 Postgres ClickPipe。 +Timescale Cloud 不支持启用逻辑复制,这在 CDC 模式下对于 Postgres 管道是必需的。因此,Timescale Cloud 的用户只能执行一次性数据加载(`Initial Load Only`)与 Postgres ClickPipe。 ::: ## 配置 {#configuration} -Timescale 超表不存储插入到其中的任何数据。相反,数据存储在 `_timescaledb_internal` 模式下的多个对应“块”表中。对于在超表上运行查询,这并没有问题。但在逻辑复制过程中,我们检测到的变化不是在超表中,而是在块表中。Postgres ClickPipe 有逻辑可以自动将块表中的更改重新映射到父超表,但这需要额外的步骤。 +Timescale 超表并不存储插入到它们中的任何数据。相反,数据存储在多个对应的“分块”表中,这些表位于 `_timescaledb_internal` 模式下。对于运行超表上的查询,这并不成问题。但在进行逻辑复制时,我们不是在超表中检测更改,而是在分块表中检测。Postgres ClickPipe 具有自动重新映射来自分块表的更改到父超表的逻辑,但这需要额外的步骤。 :::info -如果您只想进行一次性加载数据(`Initial Load Only`),请跳过第 2 步及后续步骤。 +如果您只想执行一次性数据加载(`Initial Load Only`),请跳过步骤 2 及之后的步骤。 ::: -1. 为管道创建一个 Postgres 用户,并授予其 `SELECT` 权限,允许查询您希望复制的表。 +1. 为管道创建一个 Postgres 用户,并授予其对您希望复制的表的 `SELECT` 权限。 ```sql CREATE USER clickpipes_user PASSWORD 'clickpipes_password'; @@ -63,25 +64,27 @@ ALTER DEFAULT PRIVILEGES IN SCHEMA "public" GRANT SELECT ON TABLES TO clickpipes ``` :::note -确保将 `clickpipes_user` 和 `clickpipes_password` 替换为您希望使用的用户名和密码。 +确保将 `clickpipes_user` 和 `clickpipes_password` 替换为您想要的用户名和密码。 ::: -2. 作为 Postgres 超级用户/管理员用户,在源实例上创建一个发布,其中包含您要复制的表和超表 **并且还包括整个 `_timescaledb_internal` 模式**。在创建 ClickPipe 时,您需要选择此发布。 +2. 作为 Postgres 超级用户/管理员用户,在源实例中创建一个包含您要复制的表和超表的发布,并 **同时包括整个 `_timescaledb_internal` 模式**。在创建 ClickPipe 时,您需要选择此发布。 ```sql -- When adding new tables to the ClickPipe, you'll need to add them to the publication as well manually. - CREATE PUBLICATION clickpipes_publication FOR TABLE <...>, TABLES IN SCHEMA _timescaledb_internal; + CREATE PUBLICATION clickpipes_publication FOR TABLE <...>, <...>, TABLES IN SCHEMA _timescaledb_internal; ``` :::tip -我们不推荐创建 `FOR ALL TABLES` 的发布,这会导致更多的流量从 Postgres 到 ClickPipes(发送其他不在管道中的表的更改),并降低整体效率。 +我们不推荐创建 `FOR ALL TABLES` 的发布,这会导致更多来自 Postgres 到 ClickPipes 的流量(发送其他不在管道中的表更改),从而降低整体效率。 + +对于手动创建的发布,请在将任何表添加到管道之前,将其添加到发布中。 ::: :::info -某些托管服务未授予其管理员用户创建整个模式发布所需的权限。如果是这种情况,请向您的服务提供商提交支持票。或者,您可以跳过此步骤及后续步骤,并进行一次性加载数据。 +某些托管服务可能没有授予其管理员用户创建整个模式发布所需的权限。如果是这种情况,请向您的供应商提交支持工单。或者,您可以跳过此步骤和后面的步骤,执行一次性数据加载。 ::: -3. 授予先前创建的用户复制权限。 +3. 授予之前创建的用户复制权限。 ```sql -- Give replication permission to the USER @@ -90,16 +93,6 @@ ALTER DEFAULT PRIVILEGES IN SCHEMA "public" GRANT SELECT ON TABLES TO clickpipes 完成这些步骤后,您应该能够继续 [创建 ClickPipe](../index.md)。 -## 故障排查 {#troubleshooting} - -表的初始加载可能会遇到错误: - -```sql -ERROR: transparent decompression only supports tableoid system column (SQLSTATE 42P10) -``` - -您可能需要禁用 [压缩](https://docs.timescale.com/api/latest/compression/decompress_chunk) 或 [hypercore 列存储](https://docs.timescale.com/api/latest/hypercore/convert_to_rowstore) 对于这些表。 - ## 配置网络访问 {#configure-network-access} -如果您想限制对 Timescale 实例的流量,请允许列入白名单的 [文档中的静态 NAT IP 地址](../../index.md#list-of-static-ips)。不同供应商的操作步骤会有所不同,请咨询侧边栏,如果您的供应商在列出中,或者向他们提交票据。 +如果您想限制对 Timescale 实例的流量,请允许列入白名单的 [文档中列出的静态 NAT IP](../../index.md#list-of-static-ips)。执行此操作的说明可能因提供商而异,请查看侧边栏,如果您的提供商在列表中,或与他们提交工单。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/timescale.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/timescale.md.hash index 37ddccb7f50..d0f37522950 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/timescale.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/source/timescale.md.hash @@ -1 +1 @@ -d3e2dc57289d5633 +db7536f9b41fc4ae diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/table_resync.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/table_resync.md index 60695c5f4ed..bdb6cceabe3 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/table_resync.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/table_resync.md @@ -3,24 +3,24 @@ 'description': '在 Postgres ClickPipe 中重新同步特定表' 'slug': '/integrations/clickpipes/postgres/table_resync' 'sidebar_label': '重新同步表' +'doc_type': 'guide' --- -# 重同步特定表 {#resync-tables} +# 重新同步特定表 {#resync-tables} -在某些情况下,重同步管道的特定表会很有用。一些示例用例可能是在 Postgres 上进行重大模式更改,或者在 ClickHouse 上进行某些数据重建。 +在某些场景中,重新同步管道中的特定表可能会很有用。一些示例用例可能是在 Postgres 上进行重大模式更改,或者在 ClickHouse 上进行一些数据重建。 -虽然通过单击按钮重同步单个表仍在进行中,但本指南将分享如何在 Postgres ClickPipe 中实现这一目标的步骤。 +虽然通过点击按钮重新同步单个表尚在开发中,但本指南将分享如何在 Postgres ClickPipe 中实现这一目标的步骤。 ### 1. 从管道中移除表 {#removing-table} -可以按照 [移除表指南](./removing_tables) 进行操作。 +可以遵循 [表移除指南](./removing_tables)。 ### 2. 在 ClickHouse 上截断或删除表 {#truncate-drop-table} -此步骤是为了避免在下一步中重新添加此表时出现数据重复。您可以通过前往 ClickHouse Cloud 中的 **SQL 控制台** 选项卡并运行查询来执行此操作。 -请注意,由于 PeerDB 默认创建 ReplacingMergeTree 表,因此如果您的表足够小,临时重复是无害的,则可以跳过此步骤。 +此步骤旨在避免在下一步中重新添加此表时出现数据重复。您可以通过前往 ClickHouse Cloud 中的 **SQL 控制台** 选项卡并运行查询来实现。请注意,我们有验证机制来阻止在 ClickHouse 中添加表,如果该表已存在且不为空。 ### 3. 再次将表添加到 ClickPipe {#add-table-again} -可以按照 [添加表指南](./add_table) 进行操作。 +可以遵循 [表添加指南](./add_table)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/table_resync.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/table_resync.md.hash index 8706c30b037..99fa0cd0551 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/table_resync.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/table_resync.md.hash @@ -1 +1 @@ -1fcb2a2ef7b56839 +d027b9734950be1f diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/toast.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/toast.md index 324939ff004..a47cddace31 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/toast.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/toast.md @@ -1,18 +1,19 @@ --- 'title': '处理 TOAST 列' -'description': '学习如何处理 TOAST 列在从 PostgreSQL 复制数据到 ClickHouse 时.' +'description': '学习如何在将数据从 PostgreSQL 复制到 ClickHouse 时处理 TOAST 列。' 'slug': '/integrations/clickpipes/postgres/toast' +'doc_type': 'guide' --- -在将数据从 PostgreSQL 复制到 ClickHouse 时,了解 TOAST(The Oversized-Attribute Storage Technique)列的限制和特殊注意事项非常重要。本指南将帮助您识别并正确处理复制过程中的 TOAST 列。 +当从 PostgreSQL 复制数据到 ClickHouse 时,了解 TOAST (超大属性存储技术) 列的限制和特殊考虑非常重要。本指南将帮助您识别并正确处理复制过程中的 TOAST 列。 ## PostgreSQL 中的 TOAST 列是什么? {#what-are-toast-columns-in-postgresql} -TOAST(The Oversized-Attribute Storage Technique)是 PostgreSQL 处理大字段值的机制。当一行超出最大行大小(通常为 2KB,但这可能因 PostgreSQL 版本和具体设置而异)时,PostgreSQL 会自动将大字段值移动到单独的 TOAST 表中,仅在主表中存储一个指针。 +TOAST (超大属性存储技术) 是 PostgreSQL 用于处理大字段值的机制。当一行超过最大行大小(通常为 2KB,但这可能会根据 PostgreSQL 版本和确切设置有所不同)时,PostgreSQL 会自动将大字段值移动到单独的 TOAST 表中,并仅在主表中存储一个指针。 -需要注意的是,在变更数据捕获(CDC)期间,未更改的 TOAST 列不会包含在复制流中。如果处理不当,这可能导致数据复制不完整。 +需要注意的是,在变更数据捕获 (CDC) 过程中,未更改的 TOAST 列不会包含在复制流中。如果处理不当,这可能导致数据复制不完整。 -在初始加载(快照)期间,所有列值,包括 TOAST 列,将正确复制,无论其大小如何。本指南所描述的限制主要影响初始加载后的持续 CDC 过程。 +在初始加载(快照)期间,所有列的值,包括 TOAST 列,将正确复制,而不考虑它们的大小。本指南中描述的限制主要影响在初始加载后的持续 CDC 过程。 您可以在此处阅读有关 TOAST 及其在 PostgreSQL 中实现的更多信息:https://www.postgresql.org/docs/current/storage-toast.html @@ -21,7 +22,7 @@ TOAST(The Oversized-Attribute Storage Technique)是 PostgreSQL 处理大字 要识别一个表是否具有 TOAST 列,您可以使用以下 SQL 查询: ```sql -SELECT a.attname, pg_catalog.format_type(a.atttypid, a.atttypmod) as data_type +SELECT a.attname, pg_catalog.format_type(a.atttypid, a.atttypmod) AS data_type FROM pg_attribute a JOIN pg_class c ON a.attrelid = c.oid WHERE c.relname = 'your_table_name' @@ -30,11 +31,11 @@ WHERE c.relname = 'your_table_name' AND a.attnum > 0; ``` -此查询将返回可能被 TOAST 存储的列的名称和数据类型。然而,重要的是要注意,此查询仅识别基于其数据类型和存储属性适合 TOAST 存储的列。要确定这些列是否确实包含 TOAST 数据,您需要考虑这些列中的值是否超过了大小。数据的实际 TOAST 处理取决于这些列中存储的具体内容。 +该查询将返回可能被 TOAST 存储的列的名称和数据类型。然而,需要注意的是,此查询仅识别根据其数据类型和存储属性符合 TOAST 存储条件的列。要确定这些列是否实际包含 TOAST 数据,您需要考虑这些列中的值是否超过了大小。数据的实际 TOAST化取决于存储在这些列中的具体内容。 ## 确保正确处理 TOAST 列 {#ensuring-proper-handling-of-toast-columns} -为了确保在复制过程中正确处理 TOAST 列,您应将表的 `REPLICA IDENTITY` 设置为 `FULL`。这告诉 PostgreSQL 在 UPDATE 和 DELETE 操作的 WAL 中包含完整的旧行,从而确保所有列值(包括 TOAST 列)可用于复制。 +为了确保在复制过程中正确处理 TOAST 列,您应该将表的 `REPLICA IDENTITY` 设置为 `FULL`。这告诉 PostgreSQL 在 UPDATE 和 DELETE 操作中将完整的旧行包含在 WAL 中,确保所有列值(包括 TOAST 列)可用于复制。 您可以使用以下 SQL 命令将 `REPLICA IDENTITY` 设置为 `FULL`: @@ -42,22 +43,22 @@ WHERE c.relname = 'your_table_name' ALTER TABLE your_table_name REPLICA IDENTITY FULL; ``` -有关设置 `REPLICA IDENTITY FULL` 时的性能考虑,请参考 [这篇博文](https://xata.io/blog/replica-identity-full-performance)。 +有关设置 `REPLICA IDENTITY FULL` 时性能考虑的更多信息,请参考 [这篇博客文章](https://xata.io/blog/replica-identity-full-performance)。 ## 当未设置 REPLICA IDENTITY FULL 时的复制行为 {#replication-behavior-when-replica-identity-full-is-not-set} -如果未为具有 TOAST 列的表设置 `REPLICA IDENTITY FULL`,您在复制到 ClickHouse 时可能会遇到以下问题: +如果对于具有 TOAST 列的表未设置 `REPLICA IDENTITY FULL`,在复制到 ClickHouse 时,您可能会遇到以下问题: 1. 对于 INSERT 操作,所有列(包括 TOAST 列)将被正确复制。 2. 对于 UPDATE 操作: - - 如果 TOAST 列未被修改,则其值将在 ClickHouse 中显示为 NULL 或空。 - - 如果 TOAST 列被修改,则将被正确复制。 + - 如果 TOAST 列未被修改,其值将在 ClickHouse 中显示为 NULL 或空。 + - 如果 TOAST 列被修改,它将被正确复制。 -3. 对于 DELETE 操作,TOAST 列值将在 ClickHouse 中显示为 NULL 或空。 +3. 对于 DELETE 操作,TOAST 列的值将在 ClickHouse 中显示为 NULL 或空。 -这些行为可能导致您的 PostgreSQL 源和 ClickHouse 目标之间的数据不一致。因此,对于具有 TOAST 列的表,设置 `REPLICA IDENTITY FULL` 来确保准确和完整的数据复制至关重要。 +这些行为可能导致 PostgreSQL 源和 ClickHouse 目标之间的数据不一致。因此,对于具有 TOAST 列的表,设置 `REPLICA IDENTITY FULL` 以确保准确和完整的数据复制至关重要。 ## 结论 {#conclusion} -在从 PostgreSQL 复制到 ClickHouse 时,正确处理 TOAST 列对于维护数据完整性至关重要。通过识别 TOAST 列并设置适当的 `REPLICA IDENTITY`,您可以确保数据准确和完整地被复制。 +正确处理 TOAST 列对于在从 PostgreSQL 复制到 ClickHouse 时维护数据完整性至关重要。通过识别 TOAST 列并设置适当的 `REPLICA IDENTITY`,您可以确保数据准确完整地复制。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/toast.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/toast.md.hash index a3216cb8635..9ad3cfdf8ad 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/toast.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/postgres/toast.md.hash @@ -1 +1 @@ -484eb80b9e8480ca +41a3e35c1bc7dde3 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/secure-kinesis.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/secure-kinesis.md index 04eaf2f8b30..ab2f9dc63b2 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/secure-kinesis.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/secure-kinesis.md @@ -2,109 +2,98 @@ 'slug': '/integrations/clickpipes/secure-kinesis' 'sidebar_label': 'Kinesis 基于角色的访问' 'title': 'Kinesis 基于角色的访问' -'description': '本文演示了 ClickPipes 客户如何利用基于角色的访问来与 Amazon Kinesis 进行身份验证,并安全访问他们的数据流。' +'description': '本文演示了ClickPipes客户如何利用基于角色的访问来进行身份验证,以安全访问Amazon Kinesis及其数据流。' +'doc_type': 'guide' +'keywords': +- 'Amazon Kinesis' --- import secure_kinesis from '@site/static/images/integrations/data-ingestion/clickpipes/securekinesis.jpg'; import secures3_arn from '@site/static/images/cloud/security/secures3_arn.png'; import Image from '@theme/IdealImage'; -这篇文章展示了 ClickPipes 客户如何利用基于角色的访问来与 Amazon Kinesis 进行身份验证,并安全地访问他们的数据流。 +这篇文章演示了 ClickPipes 客户如何利用基于角色的访问来通过 Amazon Kinesis 进行身份验证,并安全地访问他们的数据流。 -## 介绍 {#introduction} - -在深入设置安全的 Kinesis 访问之前,了解其机制是很重要的。以下是 ClickPipes 如何通过假设客户 AWS 帐户中的角色来访问 Amazon Kinesis 流的概述。 +## 前提条件 {#prerequisite} - +要遵循本指南,您需要: +- 一项有效的 ClickHouse Cloud 服务 +- 一个 AWS 账户 -通过这种方式,客户可以在一个地方(假设角色的 IAM 策略)管理对其 Kinesis 数据流的所有访问,而无需单独修改每个流的访问策略。 +## 介绍 {#introduction} -## 设置 {#setup} +在深入了解安全 Kinesis 访问的设置之前,理解机制非常重要。以下是 ClickPipes 如何通过假设客户 AWS 账户中的角色来访问 Amazon Kinesis 流的概述。 -### 获取 ClickHouse 服务 IAM 角色 Arn {#obtaining-the-clickhouse-service-iam-role-arn} + -1 - 登录到您的 ClickHouse 云帐户。 +使用这种方法,客户可以在一个地方(假设角色的 IAM 策略)管理对其 Kinesis 数据流的所有访问,而无需单独修改每个流的访问策略。 -2 - 选择您想创建集成的 ClickHouse 服务。 +## 设置 {#setup} -3 - 选择 **设置** 标签。 + -4 - 向下滚动到页面底部的 **网络安全信息** 部分。 +### 获取 ClickHouse 服务的 IAM 角色 Arn {#obtaining-the-clickhouse-service-iam-role-arn} -5 - 复制服务的 **服务角色 ID (IAM)** 值,如下所示。 +- 1. 登录到您的 ClickHouse 云账户。 +- 2. 选择您要创建集成的 ClickHouse 服务。 +- 3. 选择 **设置** 标签。 +- 4. 向下滚动到页面底部的 **网络安全信息** 部分。 +- 5. 复制服务的 **服务角色 ID (IAM)** 值,如下所示。 - + ### 设置 IAM 假设角色 {#setting-up-iam-assume-role} -#### 手动创建 IAM 角色。 {#manually-create-iam-role} - -1 - 使用具有创建和管理 IAM 角色权限的 IAM 用户登录到您的 AWS 账户。 - -2 - 浏览到 IAM 服务控制台。 +#### 手动创建 IAM 角色 {#manually-create-iam-role} -3 - 创建一个新的 IAM 角色,并使用以下 IAM 和信任策略。请注意,IAM 角色的名称 **必须以** `ClickHouseAccessRole-` 开头,才能正常工作。 +- 1. 使用具有创建和管理 IAM 角色权限的 IAM 用户在网页浏览器中登录到您的 AWS 账户。 +- 2. 浏览到 IAM 服务控制台。 +- 3. 创建一个新的 IAM 角色,可信实体类型为 `AWS account`。注意,该 IAM 角色的名称 **必须以** `ClickHouseAccessRole-` 开头,以使其正常工作。 -信任策略(请将 `{ClickHouse_IAM_ARN}` 替换为隶属于您的 ClickHouse 实例的 IAM 角色 arn): +对于信任策略,请将 `{ClickHouse_IAM_ARN}` 替换为属于您的 ClickHouse 实例的 IAM 角色 Arn。 +对于 IAM 策略,请将 `{STREAM_NAME}` 替换为您的 Kinesis 流名称。 ```json { "Version": "2012-10-17", "Statement": [ { + "Sid": "Statement1", "Effect": "Allow", "Principal": { "AWS": "{ClickHouse_IAM_ARN}" }, "Action": "sts:AssumeRole" + }, + { + "Action": [ + "kinesis:DescribeStream", + "kinesis:GetShardIterator", + "kinesis:GetRecords", + "kinesis:ListShards", + "kinesis:SubscribeToShard", + "kinesis:DescribeStreamConsumer", + "kinesis:RegisterStreamConsumer", + "kinesis:DeregisterStreamConsumer", + "kinesis:ListStreamConsumers" + ], + "Resource": [ + "arn:aws:kinesis:region:account-id:stream/{STREAM_NAME}/*" + ], + "Effect": "Allow" + }, + { + "Action": [ + "kinesis:ListStreams" + ], + "Resource": "*", + "Effect": "Allow" } ] } -``` -IAM 策略(请将 `{STREAM_NAME}` 替换为您的 Kinesis 流名称): + -```json -{ - "Version": "2012-10-17", - "Statement": [ - { - "Action": [ - "kinesis:DescribeStream", - "kinesis:GetShardIterator", - "kinesis:GetRecords", - "kinesis:ListShards", - "kinesis:SubscribeToShard", - "kinesis:DescribeStreamConsumer", - "kinesis:RegisterStreamConsumer", - "kinesis:DeregisterStreamConsumer", - "kinesis:ListStreamConsumers" - ], - "Resource": [ - "arn:aws:kinesis:region:account-id:stream/{STREAM_NAME}" - ], - "Effect": "Allow" - }, - { - "Action": [ - "kinesis:SubscribeToShard", - "kinesis:DescribeStreamConsumer" - ], - "Resource": [ - "arn:aws:kinesis:region:account-id:stream/{STREAM_NAME}/*" - ], - "Effect": "Allow" - }, - { - "Action": [ - "kinesis:ListStreams" - ], - "Resource": "*", - "Effect": "Allow" - } - ] - -} ``` -4 - 创建后复制新的 **IAM 角色 Arn**。这是访问您的 Kinesis 流所需的内容。 +- 4. 创建后复制新生成的 **IAM 角色 Arn**。这是访问您的 Kinesis 流所需的内容。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/secure-kinesis.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/secure-kinesis.md.hash index 60dbf49171c..a2b20608ad1 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/secure-kinesis.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/secure-kinesis.md.hash @@ -1 +1 @@ -30709c60779cbe0c +65d05075fcc7eb74 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/secure-rds.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/secure-rds.md new file mode 100644 index 00000000000..a97e70d87bf --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/secure-rds.md @@ -0,0 +1,125 @@ +--- +'slug': '/integrations/clickpipes/secure-rds' +'sidebar_label': 'AWS IAM DB 认证 (RDS/Aurora)' +'title': 'AWS IAM DB 认证 (RDS/Aurora)' +'description': '本文演示了 ClickPipes 客户如何利用基于角色的访问来与 Amazon RDS/Aurora 进行身份验证,并安全访问他们的 + DATABASE。' +'doc_type': 'guide' +--- + +import secures3_arn from '@site/static/images/cloud/security/secures3_arn.png'; +import Image from '@theme/IdealImage'; + +这篇文章演示了 ClickPipes 用户如何利用基于角色的访问来使用 Amazon Aurora 和 RDS 进行身份验证并安全地访问他们的数据库。 + +:::warning +对于 AWS RDS Postgres 和 Aurora Postgres,您只能运行 `Initial Load Only` 的 ClickPipes,因为 AWS IAM 数据库身份验证的限制。 + +对于 MySQL 和 MariaDB,这个限制不适用,您可以同时运行 `Initial Load Only` 和 `CDC` ClickPipes。 +::: + +## 设置 {#setup} + +### 获取 ClickHouse 服务 IAM 角色 Arn {#obtaining-the-clickhouse-service-iam-role-arn} + +1 - 登录到您的 ClickHouse 云账户。 + +2 - 选择您要创建集成的 ClickHouse 服务。 + +3 - 选择 **设置** 选项卡。 + +4 - 向下滚动到页面底部的 **网络安全信息** 部分。 + +5 - 复制下方显示的与该服务对应的 **服务角色 ID (IAM)** 值。 + + + +我们将该值称为 `{ClickHouse_IAM_ARN}`。这是用于访问您的 RDS/Aurora 实例的 IAM 角色。 + +### 配置 RDS/Aurora 实例 {#configuring-the-rds-aurora-instance} + +#### 启用 IAM 数据库身份验证 {#enabling-iam-db-authentication} +1. 登录到您的 AWS 账户,导航到您要配置的 RDS 实例。 +2. 点击 **修改** 按钮。 +3. 向下滚动到 **数据库身份验证** 部分。 +4. 启用 **密码和 IAM 数据库身份验证** 选项。 +5. 点击 **继续** 按钮。 +6. 审查更改,然后点击 **立即应用** 选项。 + +#### 获取 RDS/Aurora 资源 ID {#obtaining-the-rds-resource-id} + +1. 登录到您的 AWS 账户,导航到您要配置的 RDS/Aurora 实例。 +2. 点击 **配置** 选项卡。 +3. 注意 **资源 ID** 值。它应该看起来像 `db-xxxxxxxxxxxxxx`。我们将该值称为 `{RDS_RESOURCE_ID}`。这是将在 IAM 策略中用于允许访问 RDS 实例的资源 ID。 + +#### 设置数据库用户 {#setting-up-the-database-user} + +##### PostgreSQL {#setting-up-the-database-user-postgres} + +1. 连接到您的 RDS/Aurora 实例,并使用以下命令创建一个新的数据库用户: +```sql +CREATE USER clickpipes_iam_user; +GRANT rds_iam TO clickpipes_iam_user; +``` +2. 在 [PostgreSQL 源设置指南](postgres/source/rds) 中按照其余步骤配置您的 RDS 实例以用于 ClickPipes。 + +##### MySQL / MariaDB {#setting-up-the-database-user-mysql} + +1. 连接到您的 RDS/Aurora 实例,并使用以下命令创建一个新的数据库用户: +```sql +CREATE USER 'clickpipes_iam_user' IDENTIFIED WITH AWSAuthenticationPlugin AS 'RDS'; +``` +2. 在 [MySQL 源设置指南](mysql/source/rds) 中按照其余步骤配置您的 RDS/Aurora 实例以用于 ClickPipes。 + +### 设置 IAM 角色 {#setting-up-iam-role} + +#### 手动创建 IAM 角色。 {#manually-create-iam-role} + +1 - 使用具有创建和管理 IAM 角色权限的 IAM 用户,在网页浏览器中登录到您的 AWS 账户。 + +2 - 浏览到 IAM 服务控制台。 + +3 - 创建一个新的 IAM 角色,并添加以下 IAM 和信任策略。 + +信任策略(请将 `{ClickHouse_IAM_ARN}` 替换为属于您的 ClickHouse 实例的 IAM 角色 arn): + +```json +{ + "Version": "2012-10-17", + "Statement": [ + { + "Effect": "Allow", + "Principal": { + "AWS": "{ClickHouse_IAM_ARN}" + }, + "Action": [ + "sts:AssumeRole", + "sts:TagSession" + ] + } + ] +} +``` + +IAM 策略(请将 `{RDS_RESOURCE_ID}` 替换为您的 RDS 实例的资源 ID)。请确保将 `{RDS_REGION}` 替换为您的 RDS/Aurora 实例所在的区域,以及将 `{AWS_ACCOUNT}` 替换为您的 AWS 账户 ID: + +```json +{ + "Version": "2012-10-17", + "Statement": [ + { + "Effect": "Allow", + "Action": [ + "rds-db:connect" + ], + "Resource": [ + "arn:aws:rds-db:{RDS_REGION}:{AWS_ACCOUNT}:dbuser:{RDS_RESOURCE_ID}/clickpipes_iam_user" + ] + } + ] +} +``` + +4 - 创建后复制新的 **IAM 角色 Arn**。这就是从 ClickPipes 安全访问您的 AWS 数据库所需的。我们将其称为 `{RDS_ACCESS_IAM_ROLE_ARN}`。 + +现在,您可以使用此 IAM 角色从 ClickPipes 进行身份验证,以访问您的 RDS/Aurora 实例。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/secure-rds.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/secure-rds.md.hash new file mode 100644 index 00000000000..1237b39c9dd --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/clickpipes/secure-rds.md.hash @@ -0,0 +1 @@ +30e4dd4cacb733b6 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/arrow-avro-orc.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/arrow-avro-orc.md index 1c8ae443287..7da0d413d63 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/arrow-avro-orc.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/arrow-avro-orc.md @@ -2,20 +2,21 @@ 'sidebar_label': 'Avro、Arrow 和 ORC' 'sidebar_position': 5 'slug': '/integrations/data-formats/arrow-avro-orc' -'title': '在 ClickHouse 中使用 Avro、Arrow 和 ORC 数据' -'description': '页面描述如何在 ClickHouse 中使用 Avro、Arrow 和 ORC 数据' +'title': '在 ClickHouse 中处理 Avro、Arrow 和 ORC 数据' +'description': '页面描述如何在 ClickHouse 中处理 Avro、Arrow 和 ORC 数据' +'doc_type': 'guide' --- # 在 ClickHouse 中使用 Avro、Arrow 和 ORC 数据 -Apache 发布了多种数据格式,这些格式在分析环境中被广泛使用,其中包括流行的 [Avro](https://avro.apache.org/)、[Arrow](https://arrow.apache.org/) 和 [Orc](https://orc.apache.org/)。 ClickHouse 支持使用列表中的任意格式导入和导出数据。 +Apache 发布了多种在分析环境中广泛使用的数据格式,包括流行的 [Avro](https://avro.apache.org/)、[Arrow](https://arrow.apache.org/) 和 [Orc](https://orc.apache.org/)。ClickHouse 支持使用该列表中的任何格式导入和导出数据。 -## 在 Avro 格式中导入和导出数据 {#importing-and-exporting-in-avro-format} +## Avro 格式的导入和导出 {#importing-and-exporting-in-avro-format} -ClickHouse 支持读取和写入 [Apache Avro](https://avro.apache.org/) 数据文件,这些文件在 Hadoop 系统中被广泛使用。 +ClickHouse 支持读取和写入 [Apache Avro](https://avro.apache.org/) 数据文件,这些文件在 Hadoop 系统中得到了广泛应用。 -要从 [avro 文件](assets/data.avro) 导入数据,我们应该在 `INSERT` 语句中使用 [Avro](/interfaces/formats.md/#data-format-avro) 格式: +要从 [avro 文件](assets/data.avro) 导入,我们应在 `INSERT` 语句中使用 [Avro](/interfaces/formats.md/#data-format-avro) 格式: ```sql INSERT INTO sometable @@ -23,7 +24,7 @@ FROM INFILE 'data.avro' FORMAT Avro ``` -使用 [file()](/sql-reference/functions/files.md/#file) 函数,我们可以在实际导入数据之前探索 Avro 文件: +使用 [file()](/sql-reference/functions/files.md/#file) 函数,我们还可以在实际导入数据之前探索 Avro 文件: ```sql SELECT path, hits @@ -51,7 +52,7 @@ FORMAT Avro; ### Avro 和 ClickHouse 数据类型 {#avro-and-clickhouse-data-types} -在导入或导出 Avro 文件时,请考虑 [数据类型匹配](/interfaces/formats/Avro#data-types-matching)。在从 Avro 文件加载数据时使用显式类型转换: +在导入或导出 Avro 文件时,请考虑 [数据类型匹配](/interfaces/formats/Avro#data-type-mapping)。在从 Avro 文件加载数据时使用显式类型转换: ```sql SELECT @@ -70,7 +71,7 @@ LIMIT 3; ### Kafka 中的 Avro 消息 {#avro-messages-in-kafka} -当 Kafka 消息使用 Avro 格式时,ClickHouse 可以使用 [AvroConfluent](/interfaces/formats.md/#data-format-avro-confluent) 格式和 [Kafka](/engines/table-engines/integrations/kafka.md) 引擎读取这样的流: +当 Kafka 消息使用 Avro 格式时,ClickHouse 可以使用 [AvroConfluent](/interfaces/formats.md/#data-format-avro-confluent) 格式和 [Kafka](/engines/table-engines/integrations/kafka.md) 引擎读取此类流: ```sql CREATE TABLE some_topic_stream @@ -87,7 +88,7 @@ kafka_format = 'AvroConfluent'; ## 使用 Arrow 格式 {#working-with-arrow-format} -另一种列式格式是 [Apache Arrow](https://arrow.apache.org/),ClickHouse 也支持此格式的导入和导出。要从 [Arrow 文件](assets/data.arrow) 导入数据,我们使用 [Arrow](/interfaces/formats.md/#data-format-arrow) 格式: +另一个列式格式是 [Apache Arrow](https://arrow.apache.org/),ClickHouse 也支持其导入和导出。从 [Arrow 文件](assets/data.arrow) 导入数据时,我们使用 [Arrow](/interfaces/formats.md/#data-format-arrow) 格式: ```sql INSERT INTO sometable @@ -95,7 +96,7 @@ FROM INFILE 'data.arrow' FORMAT Arrow ``` -导出到 Arrow 文件的方式相同: +导出到 Arrow 文件的工作方式也相同: ```sql SELECT * FROM sometable @@ -103,13 +104,13 @@ INTO OUTFILE 'export.arrow' FORMAT Arrow ``` -此外,检查 [数据类型匹配](/interfaces/formats/Arrow#data-types-matching),以确定是否需要手动转换。 +此外,请检查 [数据类型匹配](/interfaces/formats/Arrow#data-types-matching),以查看是否需要手动转换。 ### Arrow 数据流 {#arrow-data-streaming} -[ArrowStream](/interfaces/formats.md/#data-format-arrow-stream) 格式可用于处理 Arrow 数据流(用于内存处理)。ClickHouse 可以读取和写入 Arrow 流。 +可以使用 [ArrowStream](/interfaces/formats.md/#data-format-arrow-stream) 格式处理 Arrow 流(用于内存处理)。ClickHouse 可以读取和写入 Arrow 流。 -为了演示 ClickHouse 如何流式传输 Arrow 数据,让我们将其通过以下 Python 脚本传输(它读取 Arrow 流格式的输入流,并将结果输出为 Pandas 表): +为演示 ClickHouse 如何流式处理 Arrow 数据,让我们将其传输到以下 Python 脚本(它以 Arrow 流式格式读取输入流,并将结果输出为 Pandas 表): ```python import sys, pyarrow as pa @@ -118,7 +119,7 @@ with pa.ipc.open_stream(sys.stdin.buffer) as reader: print(reader.read_pandas()) ``` -现在,我们可以通过将 ClickHouse 的输出传输到脚本来流式传输数据: +现在,我们可以通过将 ClickHouse 的输出管道到脚本中来流式输出数据: ```bash clickhouse-client -q "SELECT path, hits FROM some_data LIMIT 3 FORMAT ArrowStream" | python3 arrow.py @@ -136,11 +137,11 @@ ClickHouse 也可以使用相同的 ArrowStream 格式读取 Arrow 流: arrow-stream | clickhouse-client -q "INSERT INTO sometable FORMAT ArrowStream" ``` -我们使用 `arrow-stream` 作为 Arrow 数据流的可能源。 +我们已经使用 `arrow-stream` 作为 Arrow 数据流的一个可能来源。 ## 导入和导出 ORC 数据 {#importing-and-exporting-orc-data} -[Apache ORC](https://orc.apache.org/) 格式是一种列式存储格式,通常用于 Hadoop。 ClickHouse 支持使用 [ORC 格式](/interfaces/formats.md/#data-format-orc) 导入和导出 [Orc 数据](assets/data.orc): +[Apache ORC](https://orc.apache.org/) 格式是一种列式存储格式,通常用于 Hadoop。ClickHouse 支持使用 [ORC 格式](/interfaces/formats.md/#data-format-orc) 导入和导出 [Orc 数据](assets/data.orc): ```sql SELECT * @@ -153,11 +154,11 @@ FROM INFILE 'data.orc' FORMAT ORC; ``` -此外,检查 [数据类型匹配](/interfaces/formats/ORC) 以及 [其他设置](/interfaces/formats/Parquet#format-settings),以调整导出和导入。 +此外,请检查 [数据类型匹配](/interfaces/formats/ORC) 以及 [附加设置](/interfaces/formats/Parquet#format-settings) 以调整导出和导入。 ## 进一步阅读 {#further-reading} -ClickHouse 引入了对多种格式(包括文本和二进制)的支持,以覆盖各种场景和平台。在以下文章中探索更多格式及其使用方法: +ClickHouse 引入了对多种格式的支持,包括文本和二进制格式,以覆盖各种场景和平台。在以下文章中探索更多格式及其工作方式: - [CSV 和 TSV 格式](csv-tsv.md) - [JSON 格式](/integrations/data-ingestion/data-formats/json/intro.md) @@ -165,4 +166,4 @@ ClickHouse 引入了对多种格式(包括文本和二进制)的支持,以 - [本地和二进制格式](binary.md) - [SQL 格式](sql.md) -同时,查看 [clickhouse-local](https://clickhouse.com/blog/extracting-converting-querying-local-files-with-sql-clickhouse-local) - 一个便携式全功能工具,用于处理本地/远程文件,而无需 ClickHouse 服务器。 +同时查看 [clickhouse-local](https://clickhouse.com/blog/extracting-converting-querying-local-files-with-sql-clickhouse-local) - 这是一个功能齐全的可移植工具,用于在不需要 Clickhouse 服务器的情况下处理本地/远程文件。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/arrow-avro-orc.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/arrow-avro-orc.md.hash index 17dca17bf07..c7742ae30fd 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/arrow-avro-orc.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/arrow-avro-orc.md.hash @@ -1 +1 @@ -4d927a358f11b24e +11ad4588b2a8a274 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/binary.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/binary.md index 9e1f87ef13b..2b862e23042 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/binary.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/binary.md @@ -1,8 +1,9 @@ --- -'sidebar_label': '二进制和本地' +'sidebar_label': '二进制和原生' 'slug': '/integrations/data-formats/binary-native' -'title': '在 ClickHouse 中使用本地和二进制格式' -'description': '页面描述如何在 ClickHouse 中使用本地和二进制格式' +'title': '在 ClickHouse 中使用原生和二进制格式' +'description': '页面描述如何在 ClickHouse 中使用原生和二进制格式' +'doc_type': 'guide' --- import CloudNotSupportedBadge from '@theme/badges/CloudNotSupportedBadge'; @@ -10,24 +11,24 @@ import CloudNotSupportedBadge from '@theme/badges/CloudNotSupportedBadge'; # 在 ClickHouse 中使用原生和二进制格式 -ClickHouse 支持多种二进制格式,这些格式可以提供更好的性能和空间效率。二进制格式在字符编码方面也是安全的,因为数据以二进制形式保存。 +ClickHouse 支持多种二进制格式,这些格式可以提高性能和空间效率。二进制格式在字符编码方面也是安全的,因为数据以二进制形式保存。 -我们将使用一些数据 [表](assets/some_data.sql) 和 [数据](assets/some_data.tsv) 进行演示,您可以在您的 ClickHouse 实例上进行复现。 +我们将使用 some_data [表](assets/some_data.sql) 和 [数据](assets/some_data.tsv) 进行演示,欢迎您在自己的 ClickHouse 实例中复现。 -## 导出为原生 ClickHouse 格式 {#exporting-in-a-native-clickhouse-format} +## 导出为 ClickHouse 原生格式 {#exporting-in-a-native-clickhouse-format} -在 ClickHouse 节点之间导入和导出数据最有效的数据格式是 [Native](/interfaces/formats.md/#native) 格式。导出是通过 `INTO OUTFILE` 子句进行的: +在 ClickHouse 节点之间导入和导出数据的最有效格式是 [Native](/interfaces/formats.md/#native) 格式。导出是通过 `INTO OUTFILE` 子句完成的: ```sql SELECT * FROM some_data INTO OUTFILE 'data.clickhouse' FORMAT Native ``` -这将创建 [data.clickhouse](assets/data.clickhouse) 文件,采用原生格式。 +这将创建一个名为 [data.clickhouse](assets/data.clickhouse) 的文件,格式为原生格式。 ### 从原生格式导入 {#importing-from-a-native-format} -要导入数据,可以使用 [file()](/sql-reference/table-functions/file.md) 用于较小文件或探索目的: +要导入数据,我们可以针对较小的文件或探索目的使用 [file()](/sql-reference/table-functions/file.md): ```sql DESCRIBE file('data.clickhouse', Native); @@ -41,10 +42,10 @@ DESCRIBE file('data.clickhouse', Native); ``` :::tip -使用 `file()` 函数时,如果使用 ClickHouse Cloud,您需要在文件所在机器上的 `clickhouse client` 中运行命令。另一种选择是使用 [`clickhouse-local`](/operations/utilities/clickhouse-local.md) 在本地探索文件。 +使用 `file()` 函数时,使用 ClickHouse Cloud 时需要在文件所在的机器上运行 `clickhouse client` 中的命令。另一种选择是使用 [`clickhouse-local`](/operations/utilities/clickhouse-local.md) 在本地探索文件。 ::: -在生产环境中,我们使用 `FROM INFILE` 导入数据: +在生产中,我们使用 `FROM INFILE` 导入数据: ```sql INSERT INTO sometable @@ -54,7 +55,7 @@ FORMAT Native ### 原生格式压缩 {#native-format-compression} -我们还可以在导出数据到原生格式时启用压缩(以及大多数其他格式),使用 `COMPRESSION` 子句: +我们还可以在将数据导出为原生格式时启用压缩(同样适用于大多数其他格式),使用 `COMPRESSION` 子句: ```sql SELECT * FROM some_data @@ -63,7 +64,7 @@ COMPRESSION 'lz4' FORMAT Native ``` -我们使用 LZ4 压缩进行导出。在导入数据时,我们需要指定它: +我们使用 LZ4 压缩进行导出。在导入数据时必须指定它: ```sql INSERT INTO sometable @@ -72,7 +73,7 @@ COMPRESSION 'lz4' FORMAT Native ``` -## 导出为 RowBinary {#exporting-to-rowbinary} +## 导出到 RowBinary {#exporting-to-rowbinary} 另一个支持的二进制格式是 [RowBinary](/interfaces/formats.md/#rowbinary),它允许以二进制表示的行导入和导出数据: @@ -81,10 +82,10 @@ SELECT * FROM some_data INTO OUTFILE 'data.binary' FORMAT RowBinary ``` -这将生成 [data.binary](assets/data.binary) 文件,采用二进制行格式。 +这将生成一个名为 [data.binary](assets/data.binary) 的文件,格式为二进制行格式。 ### 探索 RowBinary 文件 {#exploring-rowbinary-files} -此格式不支持自动模式推断,因此在加载之前,我们必须明确定义模式: +此格式不支持自动模式推断,因此在加载之前,我们必须显式定义模式: ```sql SELECT * @@ -101,7 +102,7 @@ LIMIT 5 └────────────────────────────────┴────────────┴──────┘ ``` -考虑使用 [RowBinaryWithNames](/interfaces/formats.md/#rowbinarywithnames),它还添加了带有列列表的标题行。[RowBinaryWithNamesAndTypes](/interfaces/formats.md/#rowbinarywithnamesandtypes) 还会添加一行带有列类型的额外标题。 +考虑使用 [RowBinaryWithNames](/interfaces/formats.md/#rowbinarywithnames),它还会添加一个带有列列表的标题行。[RowBinaryWithNamesAndTypes](/interfaces/formats.md/#rowbinarywithnamesandtypes) 还将添加一个带有列类型的额外标题行。 ### 从 RowBinary 文件导入 {#importing-from-rowbinary-files} 要从 RowBinary 文件加载数据,我们可以使用 `FROM INFILE` 子句: @@ -114,19 +115,20 @@ FORMAT RowBinary ## 使用 RawBLOB 导入单个二进制值 {#importing-single-binary-value-using-rawblob} -假设我们想要读取整个二进制文件并将其保存到表中的一个字段。这是可以使用 [RawBLOB 格式](/interfaces/formats.md/#rawblob) 的情况。该格式只能与单列表直接使用: +假设我们想读取整个二进制文件并将其保存到表中的一个字段中。 +此时可以使用 [RawBLOB 格式](/interfaces/formats.md/#rawblob)。该格式只能与单列表直接使用: ```sql -CREATE TABLE images(data String) Engine = Memory +CREATE TABLE images(data String) ENGINE = Memory ``` -让我们将图像文件保存到 `images` 表中: +让我们将一个图像文件保存到 `images` 表中: ```bash cat image.jpg | clickhouse-client -q "INSERT INTO images FORMAT RawBLOB" ``` -我们可以检查 `data` 字段长度,等于原始文件大小: +我们可以检查 `data` 字段的长度,它将等于原始文件的大小: ```sql SELECT length(data) FROM images @@ -139,7 +141,7 @@ SELECT length(data) FROM images ### 导出 RawBLOB 数据 {#exporting-rawblob-data} -该格式也可以用于使用 `INTO OUTFILE` 子句导出数据: +此格式也可以用来通过 `INTO OUTFILE` 子句导出数据: ```sql SELECT * FROM images LIMIT 1 @@ -147,11 +149,11 @@ INTO OUTFILE 'out.jpg' FORMAT RawBLOB ``` -请注意,我们必须使用 `LIMIT 1` 因为导出超过一个值将创建一个损坏的文件。 +注意,我们必须使用 `LIMIT 1`,因为导出多个值将创建一个损坏的文件。 ## MessagePack {#messagepack} -ClickHouse 支持使用 [MsgPack](/interfaces/formats.md/#msgpack) 导入和导出到 [MessagePack](https://msgpack.org/)。要导出为 MessagePack 格式: +ClickHouse 支持使用 [MsgPack](/interfaces/formats.md/#msgpack) 导入和导出 [MessagePack](https://msgpack.org/)。要导出为 MessagePack 格式: ```sql SELECT * @@ -172,7 +174,7 @@ FORMAT MsgPack -要使用 [Protocol Buffers](/interfaces/formats.md/#protobuf),我们首先需要定义一个 [模式文件](assets/schema.proto): +要使用 [Protocol Buffers](/interfaces/formats.md/#protobuf),我们首先需要定义一个 [schema file](assets/schema.proto): ```protobuf syntax = "proto3"; @@ -184,7 +186,7 @@ message MessageType { }; ``` -该模式文件的路径(在我们的例子中为 `schema.proto`)在 [Protobuf](/interfaces/formats.md/#protobuf) 格式的 `format_schema` 设置选项中设置: +此模式文件 (`schema.proto` 在我们的例子中) 的路径在 [Protobuf](/interfaces/formats.md/#protobuf) 格式的 `format_schema` 设置选项中指定: ```sql SELECT * FROM some_data @@ -193,13 +195,13 @@ FORMAT Protobuf SETTINGS format_schema = 'schema:MessageType' ``` -这将数据保存到 [proto.bin](assets/proto.bin) 文件。ClickHouse 还支持导入 Protobuf 数据以及嵌套消息。考虑使用 [ProtobufSingle](/interfaces/formats.md/#protobufsingle) 来处理单个 Protocol Buffer 消息(此情况下将省略长度分隔符)。 +这会将数据保存到 [proto.bin](assets/proto.bin) 文件中。ClickHouse 还支持导入 Protobuf 数据以及嵌套消息。考虑使用 [ProtobufSingle](/interfaces/formats.md/#protobufsingle) 来处理单个 Protocol Buffer 消息(在这种情况下将省略长度分隔符)。 ## Cap'n Proto {#capn-proto} -另一个 ClickHouse 支持的流行二进制序列化格式是 [Cap'n Proto](https://capnproto.org/)。与 `Protobuf` 格式类似,我们必须在我们的例子中定义一个模式文件([`schema.capnp`](assets/schema.capnp)): +ClickHouse 支持的另一种流行二进制序列化格式是 [Cap'n Proto](https://capnproto.org/)。与 `Protobuf` 格式类似,我们必须在示例中定义一个模式文件 ([`schema.capnp`](assets/schema.capnp)): ```response @0xec8ff1a10aa10dbe; @@ -211,7 +213,7 @@ struct PathStats { } ``` -现在我们可以使用 [CapnProto](/interfaces/formats.md/#capnproto) 格式及该模式进行导入和导出: +现在我们可以使用 [CapnProto](/interfaces/formats.md/#capnproto) 格式和此模式进行导入和导出: ```sql SELECT @@ -224,11 +226,11 @@ FORMAT CapnProto SETTINGS format_schema = 'schema:PathStats' ``` -请注意,我们必须将 `Date` 列强制转换为 `UInt32` 以 [匹配相应类型](/interfaces/formats/CapnProto#data_types-matching-capnproto)。 +请注意,我们必须将 `Date` 列强制转换为 `UInt32` 以 [匹配相应的类型](/interfaces/formats/CapnProto#data_types-matching-capnproto)。 ## 其他格式 {#other-formats} -ClickHouse 引入对许多格式的支持,包括文本和二进制,以覆盖各种场景和平台。在以下文章中探索更多格式及其工作方式: +ClickHouse 引入了对多种格式的支持,包括文本和二进制,以涵盖各种场景和平台。请在以下文章中探索更多格式及其使用方法: - [CSV 和 TSV 格式](csv-tsv.md) - [Parquet](parquet.md) @@ -237,4 +239,4 @@ ClickHouse 引入对许多格式的支持,包括文本和二进制,以覆盖 - **原生和二进制格式** - [SQL 格式](sql.md) -同时也查看 [clickhouse-local](https://clickhouse.com/blog/extracting-converting-querying-local-files-with-sql-clickhouse-local) - 一个便携的全功能工具,可以在不启动 ClickHouse 服务器的情况下处理本地/远程文件。 +同时查看 [clickhouse-local](https://clickhouse.com/blog/extracting-converting-querying-local-files-with-sql-clickhouse-local) - 一款便携式功能齐全的工具,可在不启动 ClickHouse 服务器的情况下处理本地/远程文件。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/binary.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/binary.md.hash index 4f97e0b4e9c..c8b80c1e808 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/binary.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/binary.md.hash @@ -1 +1 @@ -17788adf6ed3b52c +a42a74c6e2658890 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/csv-tsv.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/csv-tsv.md index 0beb17189ce..9edc4039e04 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/csv-tsv.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/csv-tsv.md @@ -1,18 +1,19 @@ --- 'sidebar_label': 'CSV 和 TSV' 'slug': '/integrations/data-formats/csv-tsv' -'title': '在 ClickHouse 中使用 CSV 和 TSV 数据' -'description': '页面描述如何在 ClickHouse 中使用 CSV 和 TSV 数据' +'title': '在 ClickHouse 中处理 CSV 和 TSV 数据' +'description': '页面描述如何在 ClickHouse 中处理 CSV 和 TSV 数据' +'doc_type': 'guide' --- # 在 ClickHouse 中处理 CSV 和 TSV 数据 -ClickHouse 支持从 CSV 文件导入和导出数据。由于 CSV 文件可能具有不同的格式特性,包括标题行、自定义分隔符和转义符号,ClickHouse 提供了格式和设置,以便高效处理每种情况。 +ClickHouse 支持从 CSV 导入数据和导出数据。由于 CSV 文件可能具有不同的格式特性,包括标题行、自定义分隔符和转义符,ClickHouse 提供格式和设置来有效地解决每种情况。 ## 从 CSV 文件导入数据 {#importing-data-from-a-csv-file} -在导入数据之前,让我们创建一个具有相关结构的表: +在导入数据之前,先创建一个相关结构的表: ```sql CREATE TABLE sometable @@ -25,7 +26,7 @@ ENGINE = MergeTree ORDER BY tuple(month, path) ``` -要将数据从 [CSV 文件](assets/data_small.csv) 导入到 `sometable` 表中,我们可以将文件直接通过管道传递给 clickhouse-client: +要将数据从 [CSV 文件](assets/data_small.csv) 导入到 `sometable` 表中,我们可以直接将文件通过管道传递给 clickhouse-client: ```bash clickhouse-client -q "INSERT INTO sometable FORMAT CSV" < data_small.csv @@ -39,15 +40,16 @@ FROM INFILE 'data_small.csv' FORMAT CSV ``` -在这里,我们使用 `FORMAT CSV` 子句来让 ClickHouse 理解文件格式。我们还可以使用 [url()](/sql-reference/table-functions/url.md) 函数直接从 URL 加载数据或使用 [s3()](/sql-reference/table-functions/s3.md) 函数从 S3 文件加载数据。 +在这里,我们使用 `FORMAT CSV` 子句以便 ClickHouse 理解文件格式。我们还可以直接通过 [url()](/sql-reference/table-functions/url.md) 函数从 URL 加载数据,或者通过 [s3()](/sql-reference/table-functions/s3.md) 函数从 S3 文件加载数据。 :::tip -我们可以跳过对 `file()` 和 `INFILE`/`OUTFILE` 的显式格式设置。在这种情况下,ClickHouse 将根据文件扩展名自动检测格式。 +在 `file()` 和 `INFILE`/`OUTFILE` 的情况下,我们可以跳过显式格式设置。 +在这种情况下,ClickHouse 将自动根据文件扩展名检测格式。 ::: -### 带标题的 CSV 文件 {#csv-files-with-headers} +### 带有标题的 CSV 文件 {#csv-files-with-headers} -假设我们的 [CSV 文件带有标题](assets/data_small_headers.csv): +假设我们的 [CSV 文件包含标题](assets/data_small_headers.csv): ```bash head data-small-headers.csv @@ -64,25 +66,25 @@ head data-small-headers.csv clickhouse-client -q "INSERT INTO sometable FORMAT CSVWithNames" < data_small_headers.csv ``` -在这种情况下,ClickHouse 在从文件导入数据时会跳过第一行。 +在这种情况下,ClickHouse 在导入数据时会跳过第一行。 :::tip -从 23.1 [版本](https://github.com/ClickHouse/ClickHouse/releases) 开始,当使用 `CSV` 类型时,ClickHouse 将自动检测 CSV 文件中的标题,因此无需使用 `CSVWithNames` 或 `CSVWithNamesAndTypes`。 +从 [版本](https://github.com/ClickHouse/ClickHouse/releases) 23.1 开始,ClickHouse 会在使用 `CSV` 格式时自动检测 CSV 文件中的标题,因此不需要使用 `CSVWithNames` 或 `CSVWithNamesAndTypes`。 ::: -### 带自定义分隔符的 CSV 文件 {#csv-files-with-custom-delimiters} +### 带有自定义分隔符的 CSV 文件 {#csv-files-with-custom-delimiters} -如果 CSV 文件使用除了逗号以外的其他分隔符,我们可以使用 [format_csv_delimiter](/operations/settings/settings-formats.md/#format_csv_delimiter) 选项来设置相关符号: +如果 CSV 文件使用逗号以外的分隔符,我们可以使用 [format_csv_delimiter](/operations/settings/settings-formats.md/#format_csv_delimiter) 选项设置相关符号: ```sql SET format_csv_delimiter = ';' ``` -现在,当我们从 CSV 文件导入时,`;` 符号将作为分隔符使用,而不是逗号。 +现在,当我们从 CSV 文件导入时,将使用 `;` 符号作为分隔符,而不是逗号。 ### 跳过 CSV 文件中的行 {#skipping-lines-in-a-csv-file} -有时,我们可能会在从 CSV 文件导入数据时跳过某些行。这可以使用 [input_format_csv_skip_first_lines](/operations/settings/settings-formats.md/#input_format_csv_skip_first_lines) 选项来完成: +有时,我们可能希望在从 CSV 文件导入数据时跳过一定数量的行。这可以使用 [input_format_csv_skip_first_lines](/operations/settings/settings-formats.md/#input_format_csv_skip_first_lines) 选项完成: ```sql SET input_format_csv_skip_first_lines = 10 @@ -99,15 +101,15 @@ SELECT count(*) FROM file('data-small.csv', CSV) └─────────┘ ``` -该 [文件](assets/data_small.csv) 有 1000 行,但 ClickHouse 只加载了 990,因为我们要求跳过前 10 行。 +该 [文件](assets/data_small.csv) 有 1k 行,但 ClickHouse 只加载了 990 行,因为我们要求跳过前 10 行。 :::tip -使用 `file()` 函数时,使用 ClickHouse Cloud,您需要在文件所在的机器上使用 `clickhouse client` 运行命令。另一个选择是使用 [`clickhouse-local`](/operations/utilities/clickhouse-local.md) 在本地探索文件。 +使用 `file()` 函数时,使用 ClickHouse Cloud,您需要在文件所在的机器上使用 `clickhouse client` 运行命令。另一种选择是使用 [`clickhouse-local`](/operations/utilities/clickhouse-local.md) 本地探索文件。 ::: -### 在 CSV 文件中处理 NULL 值 {#treating-null-values-in-csv-files} +### 处理 CSV 文件中的 NULL 值 {#treating-null-values-in-csv-files} -NULL 值的编码方式可能因生成文件的应用程序而异。默认情况下,ClickHouse 在 CSV 中使用 `\N` 表示 Null 值。但我们可以使用 [format_csv_null_representation](/operations/settings/settings-formats.md/#format_tsv_null_representation) 选项来更改此行为。 +NULL 值的编码方式可能因生成文件的应用程序而异。默认情况下,ClickHouse 使用 `\N` 作为 CSV 中的 NULL 值。但我们可以使用 [format_csv_null_representation](/operations/settings/settings-formats.md/#format_tsv_null_representation) 选项来更改这一点。 假设我们有以下 CSV 文件: @@ -118,7 +120,7 @@ Joe,Nothing Nothing,70 ``` -如果我们从该文件加载数据,ClickHouse 会将 `Nothing` 视为字符串(这是正确的): +如果我们从该文件加载数据,ClickHouse 将把 `Nothing` 视为字符串(这是正确的): ```sql SELECT * FROM file('nulls.csv') @@ -137,7 +139,7 @@ SELECT * FROM file('nulls.csv') SET format_csv_null_representation = 'Nothing' ``` -现在我们在预期的位置得到了 `NULL`: +现在我们在期望的位置得到了 `NULL`: ```sql SELECT * FROM file('nulls.csv') @@ -152,21 +154,21 @@ SELECT * FROM file('nulls.csv') ## TSV(制表符分隔)文件 {#tsv-tab-separated-files} -制表符分隔的数据格式广泛用作数据交换格式。要将数据从 [TSV 文件](assets/data_small.tsv) 加载到 ClickHouse,使用 [TabSeparated](/interfaces/formats.md/#tabseparated) 格式: +制表符分隔的数据格式被广泛用作数据交换格式。要将数据从 [TSV 文件](assets/data_small.tsv) 导入 ClickHouse,使用 [TabSeparated](/interfaces/formats.md/#tabseparated) 格式: ```bash clickhouse-client -q "INSERT INTO sometable FORMAT TabSeparated" < data_small.tsv ``` -还有一个 [TabSeparatedWithNames](/interfaces/formats.md/#tabseparatedwithnames) 格式,可以处理带有标题的 TSV 文件。同样,我们可以使用 [input_format_tsv_skip_first_lines](/operations/settings/settings-formats.md/#input_format_tsv_skip_first_lines) 选项跳过前 X 行。 +还有一个 [TabSeparatedWithNames](/interfaces/formats.md/#tabseparatedwithnames) 格式,允许处理具有标题的 TSV 文件。与 CSV 一样,我们可以使用 [input_format_tsv_skip_first_lines](/operations/settings/settings-formats.md/#input_format_tsv_skip_first_lines) 选项跳过前 X 行。 ### 原始 TSV {#raw-tsv} -有时,TSV 文件保存时没有转义制表符和换行符。我们应该使用 [TabSeparatedRaw](/interfaces/formats.md/#tabseparatedraw) 来处理此类文件。 +有时,TSV 文件在保存时不对制表符和换行符进行转义。我们应该使用 [TabSeparatedRaw](/interfaces/formats.md/#tabseparatedraw) 来处理这种文件。 ## 导出到 CSV {#exporting-to-csv} -我们之前示例中的任何格式也可以用于导出数据。要将数据从表(或查询)导出到 CSV 格式,我们使用相同的 `FORMAT` 子句: +我们在之前的示例中提到的任何格式也可以用于导出数据。要将数据从表(或查询)导出到 CSV 格式,我们使用相同的 `FORMAT` 子句: ```sql SELECT * @@ -182,7 +184,7 @@ FORMAT CSV "2016_Greater_Western_Sydney_Giants_season","2017-05-01",86 ``` -要向 CSV 文件添加标题,我们使用 [CSVWithNames](/interfaces/formats.md/#csvwithnames) 格式: +要为 CSV 文件添加标题,我们使用 [CSVWithNames](/interfaces/formats.md/#csvwithnames) 格式: ```sql SELECT * @@ -199,9 +201,9 @@ FORMAT CSVWithNames "2016_Greater_Western_Sydney_Giants_season","2017-05-01",86 ``` -### 将导出数据保存到 CSV 文件 {#saving-exported-data-to-a-csv-file} +### 将导出的数据保存到 CSV 文件 {#saving-exported-data-to-a-csv-file} -要将导出数据保存到文件中,我们可以使用 [INTO...OUTFILE](/sql-reference/statements/select/into-outfile.md) 子句: +要将导出的数据保存到文件中,我们可以使用 [INTO...OUTFILE](/sql-reference/statements/select/into-outfile.md) 子句: ```sql SELECT * @@ -213,11 +215,11 @@ FORMAT CSVWithNames 36838935 rows in set. Elapsed: 1.304 sec. Processed 36.84 million rows, 1.42 GB (28.24 million rows/s., 1.09 GB/s.) ``` -请注意,ClickHouse 只需 **~1** 秒即可将 3600 万行保存到 CSV 文件中。 +注意 ClickHouse 需要 **~1** 秒钟来将 36m 行保存到 CSV 文件中。 -### 导出带自定义分隔符的 CSV {#exporting-csv-with-custom-delimiters} +### 导出带有自定义分隔符的 CSV {#exporting-csv-with-custom-delimiters} -如果我们希望使用除逗号以外的分隔符,我们可以使用 [format_csv_delimiter](/operations/settings/settings-formats.md/#format_csv_delimiter) 设置选项: +如果我们希望使用除了逗号以外的其他分隔符,可以使用 [format_csv_delimiter](/operations/settings/settings-formats.md/#format_csv_delimiter) 设置选项: ```sql SET format_csv_delimiter = '|' @@ -241,7 +243,7 @@ FORMAT CSV ### 为 Windows 导出 CSV {#exporting-csv-for-windows} -如果我们希望 CSV 文件在 Windows 环境中正常工作,我们应该考虑启用 [output_format_csv_crlf_end_of_line](/operations/settings/settings-formats.md/#output_format_csv_crlf_end_of_line) 选项。这将使用 `\r\n` 作为换行符,而不是 `\n`: +如果我们希望生成的 CSV 文件在 Windows 环境中正常工作,应该考虑启用 [output_format_csv_crlf_end_of_line](/operations/settings/settings-formats.md/#output_format_csv_crlf_end_of_line) 选项。这将使用 `\r\n` 作为换行符,而不是 `\n`: ```sql SET output_format_csv_crlf_end_of_line = 1; @@ -249,7 +251,7 @@ SET output_format_csv_crlf_end_of_line = 1; ## CSV 文件的模式推断 {#schema-inference-for-csv-files} -在许多情况下,我们可能需要处理未知的 CSV 文件,因此我们必须探索为列使用哪些类型。ClickHouse 默认会根据其对给定 CSV 文件的分析来尝试猜测数据格式。这被称为“模式推断”。检测到的数据类型可以使用 `DESCRIBE` 语句与 [file()](/sql-reference/table-functions/file.md) 函数结合使用进行探索: +在很多情况下,我们可能会处理未知的 CSV 文件,因此我们必须探索应为列使用哪些类型。Clickhouse 默认会根据对给定 CSV 文件的分析尝试猜测数据格式。这被称为“模式推断”。可以使用 `DESCRIBE` 语句配合 [file()](/sql-reference/table-functions/file.md) 函数来探索检测到的数据类型: ```sql DESCRIBE file('data-small.csv', CSV) @@ -262,7 +264,7 @@ DESCRIBE file('data-small.csv', CSV) └──────┴──────────────────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┘ ``` -在这里,ClickHouse 能够有效地猜测我们 CSV 文件的列类型。如果我们不希望 ClickHouse 进行猜测,可以使用以下选项禁用此功能: +在这里,ClickHouse 可以有效地猜测我们的 CSV 文件的列类型。如果我们不希望 ClickHouse 猜测,可以通过以下选项禁用此功能: ```sql SET input_format_csv_use_best_effort_in_schema_inference = 0 @@ -270,9 +272,9 @@ SET input_format_csv_use_best_effort_in_schema_inference = 0 在这种情况下,所有列类型将被视为 `String`。 -### 导入和导出具有显式列类型的 CSV {#exporting-and-importing-csv-with-explicit-column-types} +### 导出和导入带有显式列类型的 CSV {#exporting-and-importing-csv-with-explicit-column-types} -ClickHouse 还允许在使用 [CSVWithNamesAndTypes](/interfaces/formats.md/#csvwithnamesandtypes) (以及其他 *WithNames 格式系列)导出数据时显式设置列类型: +ClickHouse 还允许在导出数据时显式设置列类型,使用 [CSVWithNamesAndTypes](/interfaces/formats.md/#csvwithnamesandtypes)(以及其他 *WithNames 格式系列): ```sql SELECT * @@ -290,7 +292,7 @@ FORMAT CSVWithNamesAndTypes "2016_Greater_Western_Sydney_Giants_season","2017-05-01",86 ``` -该格式将包含两行标题 - 一行包含列名称,另一行包含列类型。这将允许 ClickHouse(以及其他应用程序)在从 [这样的文件](assets/data_csv_types.csv) 加载数据时识别列类型: +该格式将包含两行标题 - 一行为列名,另一行为列类型。这将允许 ClickHouse(及其他应用程序)在从 [此类文件](assets/data_csv_types.csv) 加载数据时识别列类型: ```sql DESCRIBE file('data_csv_types.csv', CSVWithNamesAndTypes) @@ -303,19 +305,19 @@ DESCRIBE file('data_csv_types.csv', CSVWithNamesAndTypes) └───────┴────────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┘ ``` -现在 ClickHouse 根据第二行标题而不是进行猜测来识别列类型。 +现在 ClickHouse 根据(第二)标题行识别列类型,而不是进行猜测。 ## 自定义分隔符、分隔符和转义规则 {#custom-delimiters-separators-and-escaping-rules} -在复杂的情况下,文本数据可以以高度自定义的方式格式化,但仍然具有结构。ClickHouse 有一个特殊的 [CustomSeparated](/interfaces/formats.md/#format-customseparated) 格式,用于此类情况,可以设置自定义转义规则、分隔符、行分隔符和开始/结束符号。 +在复杂的情况下,文本数据可能以高度自定义的方式格式化,但仍然具有结构。ClickHouse 为此类情况提供特殊的 [CustomSeparated](/interfaces/formats.md/#format-customseparated) 格式,该格式允许设置自定义的转义规则、分隔符、行分隔符以及起始/结束符号。 -假设我们在文件中有以下数据: +假设我们文件中有以下数据: ```text row('Akiba_Hebrew_Academy';'2017-08-01';241),row('Aegithina_tiphia';'2018-02-01';34),... ``` -我们可以看到单个行被 `row()` 包裹,行之间用 `,` 分隔,单个值用 `;` 分隔。在这种情况下,我们可以使用以下设置从该文件读取数据: +我们可以看到,单个行用 `row()` 包裹,行之间用 `,` 分隔,单个值用 `;` 分隔。在这种情况下,我们可以使用以下设置从该文件读取数据: ```sql SET format_custom_row_before_delimiter = 'row('; @@ -325,7 +327,7 @@ SET format_custom_row_between_delimiter = ','; SET format_custom_escaping_rule = 'Quoted'; ``` -现在我们可以从自定义格式的 [文件](assets/data_small_custom.txt) 中加载数据: +现在我们可以从我们自定义格式的 [文件](assets/data_small_custom.txt) 中加载数据: ```sql SELECT * @@ -340,11 +342,11 @@ LIMIT 3 └───────────────────────────┴────────────┴─────┘ ``` -我们也可以使用 [CustomSeparatedWithNames](/interfaces/formats.md/#customseparatedwithnames) 以正确导出和导入标题。请探索 [regex 和模板](templates-regex.md) 格式以处理更复杂的情况。 +我们还可以使用 [CustomSeparatedWithNames](/interfaces/formats.md/#customseparatedwithnames) 正确导出和导入标题。探索 [regex 和模板](templates-regex.md) 格式以处理更复杂的情况。 -## 处理大 CSV 文件 {#working-with-large-csv-files} +## 处理大型 CSV 文件 {#working-with-large-csv-files} -CSV 文件可能很大,ClickHouse 可以高效处理任何大小的文件。大文件通常是压缩的,ClickHouse 在处理之前无需解压缩。我们可以在插入时使用 `COMPRESSION` 子句: +CSV 文件可能很大,而 ClickHouse 对任何大小的文件都能高效处理。大文件通常是压缩的,而 ClickHouse 在处理时不需要进行解压缩。我们可以在插入时使用 `COMPRESSION` 子句: ```sql INSERT INTO sometable @@ -352,7 +354,7 @@ FROM INFILE 'data_csv.csv.gz' COMPRESSION 'gzip' FORMAT CSV ``` -如果省略 `COMPRESSION` 子句,ClickHouse 仍会根据文件扩展名尝试猜测文件压缩。相同的方法也可以用于将文件直接导出为压缩格式: +如果省略 `COMPRESSION` 子句,ClickHouse 仍会尝试根据其扩展名猜测文件压缩。相同的方法可以用来直接将文件导出到压缩格式: ```sql SELECT * @@ -365,7 +367,7 @@ COMPRESSION 'gzip' FORMAT CSV ## 其他格式 {#other-formats} -ClickHouse 引入了对多种格式的支持,包括文本和二进制,以覆盖各种场景和平台。请在以下文章中探索更多格式及其使用方法: +ClickHouse 引入了支持多种格式的功能,包括文本和二进制,以涵盖各种场景和平台。探索更多格式及其工作方式,请查看以下文章: - **CSV 和 TSV 格式** - [Parquet](parquet.md) @@ -374,4 +376,4 @@ ClickHouse 引入了对多种格式的支持,包括文本和二进制,以覆 - [原生和二进制格式](binary.md) - [SQL 格式](sql.md) -同时查看 [clickhouse-local](https://clickhouse.com/blog/extracting-converting-querying-local-files-with-sql-clickhouse-local) - 一款便携式全功能工具,可在无需 Clickhouse 服务器的情况下处理本地/远程文件。 +还可以查看 [clickhouse-local](https://clickhouse.com/blog/extracting-converting-querying-local-files-with-sql-clickhouse-local) - 一个便携的全功能工具,用于在不需要 ClickHouse 服务器的情况下处理本地/远程文件。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/csv-tsv.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/csv-tsv.md.hash index 0c9d2454e8e..1e60fab5e95 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/csv-tsv.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/csv-tsv.md.hash @@ -1 +1 @@ -3242afae8d353526 +212d5890c688ecb4 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/intro.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/intro.md index 62711f79d77..5fd9d03721d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/intro.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/intro.md @@ -1,6 +1,6 @@ --- 'slug': '/integrations/data-formats' -'sidebar_label': '概览' +'sidebar_label': '概述' 'sidebar_position': 1 'keywords': - 'clickhouse' @@ -12,20 +12,21 @@ 'title': '从各种数据格式导入到 ClickHouse' 'description': '页面描述如何将各种数据格式导入到 ClickHouse' 'show_related_blogs': true +'doc_type': 'guide' --- # 从各种数据格式导入到 ClickHouse -在本节文档中,您可以找到加载各种文件类型的示例。 +在本节文档中,您可以找到从各种文件类型加载的示例。 ### [**二进制**](/integrations/data-ingestion/data-formats/binary.md) {#binary} -导出和加载二进制格式,如 ClickHouse Native、MessagePack、Protocol Buffers 和 Cap'n Proto。 +导出和加载二进制格式,例如 ClickHouse 原生格式、MessagePack、协议缓冲区和 Cap'n Proto。 ### [**CSV 和 TSV**](/integrations/data-ingestion/data-formats/csv-tsv.md) {#csv-and-tsv} -导入和导出 CSV 系列,包括 TSV,支持自定义标题和分隔符。 +导入和导出 CSV 系列,包括 TSV,并支持自定义头部和分隔符。 ### [**JSON**](/integrations/data-ingestion/data-formats/json/intro.md) {#json} @@ -37,6 +38,6 @@ ### [**SQL 数据**](/integrations/data-ingestion/data-formats/sql.md) {#sql-data} -需要导入到 MySQL 或 Postgresql 的 SQL 转储吗?别再寻找了。 +需要将 SQL 转储导入到 MySQL 或 PostgreSQL 吗?请不要再找其他地方了。 -如果您希望连接像 Grafana、Tableau 等 BI 工具,请查看文档的 [可视化类别](../../data-visualization/index.md)。 +如果您正在寻找连接 BI 工具,如 Grafana、Tableau 等,请查看文档的 [可视化类别](../../data-visualization/index.md)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/intro.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/intro.md.hash index e338d76b060..08f37478cba 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/intro.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/intro.md.hash @@ -1 +1 @@ -97a4e916ca15bcd1 +9dc3db84991ae628 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/json/exporting.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/json/exporting.md index 365c7ff6baa..b8006f37227 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/json/exporting.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/json/exporting.md @@ -7,12 +7,13 @@ - 'clickhouse' - 'formats' - 'exporting' +'doc_type': 'guide' --- # 导出 JSON -几乎所有用于导入的 JSON 格式也可以用于导出。最受欢迎的是 [`JSONEachRow`](/interfaces/formats.md/#jsoneachrow): +几乎任何用于导入的 JSON 格式都可以用于导出。最常用的是 [`JSONEachRow`](/interfaces/formats.md/#jsoneachrow): ```sql SELECT * FROM sometable FORMAT JSONEachRow @@ -23,7 +24,7 @@ SELECT * FROM sometable FORMAT JSONEachRow {"path":"Ahmadabad-e_Kalij-e_Sofla","month":"2017-01-01","hits":3} ``` -或者我们可以使用 [`JSONCompactEachRow`](/interfaces/formats#jsoncompacteachrow) 通过跳过列名来节省磁盘空间: +或者我们可以使用 [`JSONCompactEachRow`](/interfaces/formats#jsoncompacteachrow) 来通过跳过列名来节省磁盘空间: ```sql SELECT * FROM sometable FORMAT JSONCompactEachRow @@ -34,9 +35,9 @@ SELECT * FROM sometable FORMAT JSONCompactEachRow ["Ahmadabad-e_Kalij-e_Sofla", "2017-01-01", 3] ``` -## 将数据类型重写为字符串 {#overriding-data-types-as-strings} +## 以字符串重写数据类型 {#overriding-data-types-as-strings} -ClickHouse 遵循数据类型,并将 JSON 根据标准导出。但是在需要所有值编码为字符串的情况下,我们可以使用 [JSONStringsEachRow](/interfaces/formats.md/#jsonstringseachrow) 格式: +ClickHouse 尊重数据类型,并将 JSON 导出按标准操作。但在某些情况下,我们需要将所有值编码为字符串,可以使用 [JSONStringsEachRow](/interfaces/formats.md/#jsonstringseachrow) 格式: ```sql SELECT * FROM sometable FORMAT JSONStringsEachRow @@ -47,7 +48,7 @@ SELECT * FROM sometable FORMAT JSONStringsEachRow {"path":"Ahmadabad-e_Kalij-e_Sofla","month":"2017-01-01","hits":"3"} ``` -现在,`hits` 数值列被编码为字符串。将所有值导出为字符串的功能支持所有 JSON* 格式,只需探索 `JSONStrings\*` 和 `JSONCompactStrings\*` 格式: +现在,`hits` 数字列被编码为字符串。将值导出为字符串是所有 JSON* 格式都支持的,只需探索 `JSONStrings\*` 和 `JSONCompactStrings\*` 格式: ```sql SELECT * FROM sometable FORMAT JSONCompactStringsEachRow @@ -58,9 +59,9 @@ SELECT * FROM sometable FORMAT JSONCompactStringsEachRow ["Ahmadabad-e_Kalij-e_Sofla", "2017-01-01", "3"] ``` -## 将元数据与数据一起导出 {#exporting-metadata-together-with-data} +## 导出元数据和数据一起 {#exporting-metadata-together-with-data} -通用的 [JSON](/interfaces/formats.md/#json) 格式,在应用中很流行,将导出不止是结果数据,还包括列类型和查询统计: +通用 [JSON](/interfaces/formats.md/#json) 格式,在应用程序中很流行,不仅导出结果数据,还包括列类型和查询统计信息: ```sql SELECT * FROM sometable FORMAT JSON @@ -97,7 +98,7 @@ SELECT * FROM sometable FORMAT JSON } ``` -[JSONCompact](/interfaces/formats.md/#jsoncompact) 格式将打印相同的元数据,但对数据本身使用压缩形式: +[JSONCompact](/interfaces/formats.md/#jsoncompact) 格式将打印相同的元数据,但对数据本身使用压缩过的形式: ```sql SELECT * FROM sometable FORMAT JSONCompact @@ -131,11 +132,11 @@ SELECT * FROM sometable FORMAT JSONCompact } ``` -考虑 [`JSONStrings`](/interfaces/formats.md/#jsonstrings) 或 [`JSONCompactStrings`](/interfaces/formats.md/#jsoncompactstrings) 变体以将所有值编码为字符串。 +考虑使用 [`JSONStrings`](/interfaces/formats.md/#jsonstrings) 或 [`JSONCompactStrings`](/interfaces/formats.md/#jsoncompactstrings) 变体将所有值编码为字符串。 -## 导出 JSON 数据和结构的紧凑方式 {#compact-way-to-export-json-data-and-structure} +## 稀疏导出 JSON 数据和结构的方式 {#compact-way-to-export-json-data-and-structure} -更有效的获取数据及其结构的方法是使用 [`JSONCompactEachRowWithNamesAndTypes`](/interfaces/formats.md/#jsoncompacteachrowwithnamesandtypes) 格式: +有一种更有效的方法可以获取数据及其结构,即使用 [`JSONCompactEachRowWithNamesAndTypes`](/interfaces/formats.md/#jsoncompacteachrowwithnamesandtypes) 格式: ```sql SELECT * FROM sometable FORMAT JSONCompactEachRowWithNamesAndTypes @@ -148,11 +149,11 @@ SELECT * FROM sometable FORMAT JSONCompactEachRowWithNamesAndTypes ["Ahmadabad-e_Kalij-e_Sofla", "2017-01-01", 3] ``` -这将使用紧凑的 JSON 格式,并在前面加上两行标题,包含列名和类型。此格式随后可用于将数据摄入另一个 ClickHouse 实例(或其他应用)。 +这将使用一个压缩的 JSON 格式,在前面加上两行带有列名和类型的标题行。此格式随后可以用于将数据导入到另一个 ClickHouse 实例(或其他应用程序)中。 ## 导出 JSON 到文件 {#exporting-json-to-a-file} -要将导出的 JSON 数据保存到文件中,我们可以使用 [INTO OUTFILE](/sql-reference/statements/select/into-outfile.md) 子句: +要将导出的 JSON 数据保存到文件,我们可以使用 [INTO OUTFILE](/sql-reference/statements/select/into-outfile.md) 子句: ```sql SELECT * FROM sometable INTO OUTFILE 'out.json' FORMAT JSONEachRow @@ -161,7 +162,7 @@ SELECT * FROM sometable INTO OUTFILE 'out.json' FORMAT JSONEachRow 36838935 rows in set. Elapsed: 2.220 sec. Processed 36.84 million rows, 1.27 GB (16.60 million rows/s., 572.47 MB/s.) ``` -ClickHouse 仅用了 2 秒钟即可将近 3700 万条记录导出到 JSON 文件中。我们还可以使用 `COMPRESSION` 子句来动态启用压缩: +ClickHouse 在 2 秒内导出了近 3700 万条记录到 JSON 文件。我们还可以使用 `COMPRESSION` 子句来启用实时压缩: ```sql SELECT * FROM sometable INTO OUTFILE 'out.json.gz' FORMAT JSONEachRow @@ -170,7 +171,7 @@ SELECT * FROM sometable INTO OUTFILE 'out.json.gz' FORMAT JSONEachRow 36838935 rows in set. Elapsed: 22.680 sec. Processed 36.84 million rows, 1.27 GB (1.62 million rows/s., 56.02 MB/s.) ``` -虽然实现所需时间更多,但会生成更小的压缩文件: +虽然这需要更多时间来完成,但生成的压缩文件小得多: ```bash 2.2G out.json diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/json/exporting.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/json/exporting.md.hash index 8bb667ebdf7..f94f4f5d4a7 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/json/exporting.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/json/exporting.md.hash @@ -1 +1 @@ -2fb664d5f5dc0517 +78ce7e973eb83272 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/json/formats.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/json/formats.md index cc7209d22b3..863f1d9228b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/json/formats.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/json/formats.md @@ -7,12 +7,13 @@ - 'json' - 'formats' - 'json formats' +'doc_type': 'guide' --- # 处理其他 JSON 格式 -之前加载 JSON 数据的示例假设使用 [`JSONEachRow`](/interfaces/formats/JSONEachRow) (`NDJSON`) 格式。该格式将每行 JSON 中的键作为列读取。例如: +早期加载 JSON 数据的示例假设使用 [`JSONEachRow`](/interfaces/formats/JSONEachRow)(`NDJSON`)。该格式将每行 JSON 中的键作为列读取。例如: ```sql SELECT * @@ -30,19 +31,19 @@ LIMIT 5 5 rows in set. Elapsed: 0.449 sec. ``` -虽然这通常是 JSON 中最常用的格式,但用户可能会遇到其他格式,或需要将 JSON 作为单个对象读取。 +虽然这通常是 JSON 最常用的格式,但用户可能会遇到其他格式,或者需要将 JSON 作为单个对象读取。 -以下是其他常见格式读取和加载 JSON 的示例。 +我们在下面提供了读取和加载其他常见格式 JSON 的示例。 -## 将 JSON 读取为对象 {#reading-json-as-an-object} +## 将 JSON 作为对象读取 {#reading-json-as-an-object} -我们之前的示例展示了 `JSONEachRow` 如何读取换行符分隔的 JSON,每行被读取为映射到表行的单独对象,每个键映射到一列。这对于 JSON 可预测且每列具有单一类型的情况是理想的。 +我们之前的示例展示了 `JSONEachRow` 如何读取以换行符分隔的 JSON,每行作为单独的对象映射到表行,每个键映射到列。这对于 JSON 可预测且每列只有单一类型的情况是理想的。 -相反,`JSONAsObject` 将每行视为一个单独的 `JSON` 对象,并将其存储在一个类型为 [`JSON`](/sql-reference/data-types/newjson) 的单列中,更适合需要嵌套 JSON 负载和动态键且可能有多种类型的情况。 +相反,`JSONAsObject` 将每行视为一个单一的 `JSON` 对象,并将其存储在类型为 [`JSON`](/sql-reference/data-types/newjson) 的单个列中,这使得它更适合嵌套 JSON 有效载荷和键动态且可能具有多个类型的情况。 -对于逐行插入,请使用 `JSONEachRow`,对于储存灵活或动态 JSON 数据,请使用 [`JSONAsObject`](/interfaces/formats/JSONAsObject)。 +在进行逐行插入时使用 `JSONEachRow`,而在存储灵活或动态 JSON 数据时使用 [`JSONAsObject`](/interfaces/formats/JSONAsObject)。 -将上述示例与下面读取相同数据为每行 JSON 对象的查询进行对比: +将上面的示例与以下查询进行对比,该查询每行读取相同数据作为 JSON 对象: ```sql SELECT * @@ -60,7 +61,7 @@ LIMIT 5 5 rows in set. Elapsed: 0.338 sec. ``` -`JSONAsObject` 对于使用单个 JSON 对象列插入行非常有用,例如: +`JSONAsObject` 对于使用单个 JSON 对象列插入表行非常有用,例如: ```sql CREATE TABLE pypi @@ -86,7 +87,7 @@ LIMIT 2; 2 rows in set. Elapsed: 0.003 sec. ``` -在处理对象结构不一致的情况下,`JSONAsObject` 格式也可能适用于读取换行符分隔的 JSON。例如,如果某个键在各行中类型不同(可能有时是字符串,而其他时候是对象)。在这种情况下,ClickHouse 不能通过 `JSONEachRow` 推断出稳定的架构,而 `JSONAsObject` 允许数据在没有严格类型强制的情况下被导入,将每个 JSON 行整体存储在单列中。例如,注意 `JSONEachRow` 如何在以下示例中失败: +当对象结构不一致时,`JSONAsObject` 格式对于读取以换行符分隔的 JSON 也可能很有用。例如,如果一个键在不同的行中类型不一致(它有时是字符串,有时是对象)。在这种情况下,ClickHouse 无法通过 `JSONEachRow` 推断出稳定的模式,而 `JSONAsObject` 允许数据在不强制类型的情况下被摄取,将每个 JSON 行作为整体存储在单个列中。例如,注意 `JSONEachRow` 在以下示例中失败: ```sql SELECT count() @@ -100,8 +101,8 @@ Code: 117. DB::Exception: JSON objects have ambiguous data: in some objects path To increase the maximum number of rows/bytes to read for structure determination, use setting input_format_max_rows_to_read_for_schema_inference/input_format_max_bytes_to_read_for_schema_inference. You can specify the structure manually: (in file/uri bluesky/file_0001.json.gz). (CANNOT_EXTRACT_TABLE_STRUCTURE) ``` - -相反,在这种情况下可以使用 `JSONAsObject` ,因为 `JSON` 类型支持同一子列的多种类型。 + +相反,`JSONAsObject` 可以在这种情况下使用,因为 `JSON` 类型支持同一子列的多种类型。 ```sql SELECT count() @@ -116,7 +117,7 @@ FROM s3('https://clickhouse-public-datasets.s3.amazonaws.com/bluesky/file_0001.j ## JSON 对象数组 {#array-of-json-objects} -JSON 数据最流行的形式之一是将 JSON 对象的列表放在 JSON 数组中,如 [这个示例](../assets/list.json): +JSON 数据中最流行的形式之一是在 JSON 数组中拥有 JSON 对象列表,例如 [这个示例](../assets/list.json): ```bash > cat list.json @@ -148,7 +149,7 @@ ENGINE = MergeTree ORDER BY tuple(month, path) ``` -要导入 JSON 对象的列表,可以使用 [`JSONEachRow`](/interfaces/formats.md/#jsoneachrow) 格式(从 [list.json](../assets/list.json) 文件插入数据): +要导入 JSON 对象列表,我们可以使用 [`JSONEachRow`](/interfaces/formats.md/#jsoneachrow) 格式(从 [list.json](../assets/list.json) 文件插入数据): ```sql INSERT INTO sometable @@ -172,7 +173,7 @@ FROM sometable ## JSON 对象键 {#json-object-keys} -在某些情况下,JSON 对象的列表可以被编码为对象属性,而不是数组元素(例如,见 [objects.json](../assets/objects.json)): +在某些情况下,JSON 对象列表可以被编码为对象属性,而不是数组元素(参见 [objects.json](../assets/objects.json) 作为示例): ```bash cat objects.json @@ -194,7 +195,7 @@ cat objects.json } ``` -ClickHouse 可以使用 [`JSONObjectEachRow`](/interfaces/formats.md/#jsonobjecteachrow) 格式加载这种类型的数据: +ClickHouse 可以使用 [`JSONObjectEachRow`](/interfaces/formats.md/#jsonobjecteachrow) 格式从这种数据加载数据: ```sql INSERT INTO sometable FROM INFILE 'objects.json' FORMAT JSONObjectEachRow; @@ -210,13 +211,13 @@ SELECT * FROM sometable; ### 指定父对象键值 {#specifying-parent-object-key-values} -假设我们还想在表中保存父对象键的值。在这种情况下,我们可以使用 [以下选项](/operations/settings/settings-formats.md/#format_json_object_each_row_column_for_object_name) 来定义我们想要保存键值的列名: +假设我们还想将父对象键中的值保存到表中。在这种情况下,我们可以使用 [以下选项](/operations/settings/settings-formats.md/#format_json_object_each_row_column_for_object_name) 来定义我们希望保存键值的列的名称: ```sql SET format_json_object_each_row_column_for_object_name = 'id' ``` -现在,我们可以使用 [`file()`](/sql-reference/functions/files.md/#file) 函数检查将从原始 JSON 文件加载的数据: +现在,我们可以使用 [`file()`](/sql-reference/functions/files.md/#file) 函数检查将从原始 JSON 文件加载哪些数据: ```sql SELECT * FROM file('objects.json', JSONObjectEachRow) @@ -229,11 +230,11 @@ SELECT * FROM file('objects.json', JSONObjectEachRow) └────┴─────────────────┴────────────┴──────┘ ``` -注意 `id` 列已经通过键值正确填充。 +注意 `id` 列已正确填充键值。 ## JSON 数组 {#json-arrays} -有时,为了节省空间,JSON 文件以数组格式而非对象格式编码。在这种情况下,我们处理的是 [JSON 数组列表](../assets/arrays.json): +有时,为了节省空间,JSON 文件被编码为数组而不是对象。在这种情况下,我们处理的是 [JSON 数组列表](../assets/arrays.json): ```bash cat arrays.json @@ -244,7 +245,7 @@ cat arrays.json ["1971-72_Utah_Stars_season", "2016-10-01", 1] ``` -在这种情况下,ClickHouse 将加载该数据,并根据数组中的顺序将每个值归属到相应的列。我们使用 [`JSONCompactEachRow`](/interfaces/formats.md/#jsoncompacteachrow) 格式: +在这种情况下,ClickHouse 将加载此数据并根据数组中的顺序将每个值归属到相应的列。我们使用 [`JSONCompactEachRow`](/interfaces/formats.md/#jsoncompacteachrow) 格式来处理: ```sql SELECT * FROM sometable @@ -259,7 +260,7 @@ SELECT * FROM sometable ### 从 JSON 数组导入单独列 {#importing-individual-columns-from-json-arrays} -在某些情况下,数据可以按列而非按行编码。在这种情况下,父 JSON 对象包含带有值的列。看看 [以下文件](../assets/columns.json): +在某些情况下,数据可以被编码为列式而不是行式。在这种情况下,一个父 JSON 对象包含带有值的列。看看 [以下文件](../assets/columns.json): ```bash cat columns.json @@ -272,7 +273,7 @@ cat columns.json } ``` -ClickHouse 使用 [`JSONColumns`](/interfaces/formats.md/#jsoncolumns) 格式解析这样的数据: +ClickHouse 使用 [`JSONColumns`](/interfaces/formats.md/#jsoncolumns) 格式解析如此格式的数据: ```sql SELECT * FROM file('columns.json', JSONColumns) @@ -285,7 +286,7 @@ SELECT * FROM file('columns.json', JSONColumns) └────────────────────────────┴────────────┴──────┘ ``` -在处理 [列的数组](../assets/columns-array.json) 而不是对象时,也支持更紧凑的格式,使用 [`JSONCompactColumns`](/interfaces/formats.md/#jsoncompactcolumns) 格式: +在处理 [列数组](../assets/columns-array.json) 而不是使用 [`JSONCompactColumns`](/interfaces/formats.md/#jsoncompactcolumns) 格式的对象时,还支持更紧凑的格式: ```sql SELECT * FROM file('columns-array.json', JSONCompactColumns) @@ -300,7 +301,7 @@ SELECT * FROM file('columns-array.json', JSONCompactColumns) ## 保存 JSON 对象而不是解析 {#saving-json-objects-instead-of-parsing} -在某些情况下,您可能希望将 JSON 对象保存到单个 `String`(或 `JSON`)列中,而不是解析它。这在处理具有不同结构的 JSON 对象列表时非常有用。让我们以 [这个文件](../assets/custom.json) 为例,其中我们在父列表中有多个不同的 JSON 对象: +在某些情况下,您可能希望将 JSON 对象保存到单个 `String`(或 `JSON`)列中,而不是解析它。当处理具有不同结构的 JSON 对象列表时,这可能会很有用。以 [这个文件](../assets/custom.json) 为例,我们在一个父列表中有多个不同的 JSON 对象: ```bash cat custom.json @@ -324,7 +325,7 @@ ENGINE = MergeTree ORDER BY () ``` -现在我们可以使用 [`JSONAsString`](/interfaces/formats.md/#jsonasstring) 格式从文件加载数据,以保留 JSON 对象而不是解析它们: +现在我们可以使用 [`JSONAsString`](/interfaces/formats.md/#jsonasstring) 格式从文件加载数据,以保持 JSON 对象而不是解析它们: ```sql INSERT INTO events (data) @@ -332,7 +333,7 @@ FROM INFILE 'custom.json' FORMAT JSONAsString ``` -我们可以使用 [JSON 函数](/sql-reference/functions/json-functions.md) 查询保存的对象: +我们可以使用 [JSON 函数](/sql-reference/functions/json-functions.md) 来查询保存的对象: ```sql SELECT @@ -348,11 +349,11 @@ FROM events └────────┴──────────────────────────────────────────────────────┘ ``` -注意,`JSONAsString` 在我们有 JSON 对象逐行格式的文件时(通常与 `JSONEachRow` 格式一起使用)运行良好。 +注意 `JSONAsString` 在我们有 JSON 对象逐行格式化文件(通常与 `JSONEachRow` 格式一起使用)时非常有效。 -## 嵌套对象的架构 {#schema-for-nested-objects} +## 嵌套对象的模式 {#schema-for-nested-objects} -在处理 [嵌套 JSON 对象](../assets/list-nested.json) 时,我们还可以定义显式架构,并使用复杂类型([`Array`](/sql-reference/data-types/array.md)、[`Object Data Type`](/sql-reference/data-types/object-data-type) 或 [`Tuple`](/sql-reference/data-types/tuple.md))加载数据: +在处理 [嵌套 JSON 对象](../assets/list-nested.json) 的情况下,我们还可以定义明确的模式,并使用复杂类型([`Array`](/sql-reference/data-types/array.md),[`JSON`](/integrations/data-formats/json/overview) 或 [`Tuple`](/sql-reference/data-types/tuple.md))来加载数据: ```sql SELECT * @@ -373,7 +374,7 @@ LIMIT 1 SET input_format_import_nested_json = 1 ``` -这使我们能够使用点表示法引用嵌套 JSON 对象键(记得用反引号包裹它们以便正常工作): +这使我们能够使用点符号引用嵌套 JSON 对象键(记得用反引号符号包裹以生效): ```sql SELECT * @@ -386,11 +387,11 @@ LIMIT 1 └───────────────┴──────────────────────┴────────────┴──────┘ ``` -通过这种方式,我们可以展平嵌套 JSON 对象,或使用某些嵌套值将其作为单独列保存。 +这样我们可以将嵌套 JSON 对象扁平化或使用某些嵌套值将它们保存为独立的列。 ## 跳过未知列 {#skipping-unknown-columns} -默认情况下,ClickHouse 在导入 JSON 数据时会忽略未知列。我们试着将原始文件导入到没有 `month` 列的表中: +默认情况下,ClickHouse 在导入 JSON 数据时会忽略未知列。让我们尝试将原始文件导入到不包含 `month` 列的表中: ```sql CREATE TABLE shorttable @@ -402,7 +403,7 @@ ENGINE = MergeTree ORDER BY path ``` -我们仍然可以将 3 列的 [原始 JSON 数据](../assets/list.json) 插入到该表中: +我们仍然可以将 [原始 JSON 数据](../assets/list.json) 以 3 列插入此表: ```sql INSERT INTO shorttable FROM INFILE 'list.json' FORMAT JSONEachRow; @@ -432,9 +433,9 @@ Code: 117. DB::Exception: Unknown field found while parsing JSONEachRow format: ## BSON {#bson} -ClickHouse 允许从 [BSON](https://bsonspec.org/) 编码文件导入和导出数据。该格式被一些数据库管理系统使用,例如 [MongoDB](https://github.com/mongodb/mongo) 数据库。 +ClickHouse 允许从 [BSON](https://bsonspec.org/) 编码文件中导出和导入数据。该格式被一些 DBMS 使用,例如 [MongoDB](https://github.com/mongodb/mongo) 数据库。 -要导入 BSON 数据,我们使用 [BSONEachRow](/interfaces/formats.md/#bsoneachrow) 格式。让我们从 [此 BSON 文件](../assets/data.bson) 导入数据: +要导入 BSON 数据,我们使用 [BSONEachRow](/interfaces/formats.md/#bsoneachrow) 格式。让我们从 [这个 BSON 文件](../assets/data.bson) 导入数据: ```sql SELECT * FROM file('data.bson', BSONEachRow) @@ -447,7 +448,7 @@ SELECT * FROM file('data.bson', BSONEachRow) └───────────────────────────┴───────┴──────┘ ``` -我们还可以使用相同的格式导出到 BSON 文件: +我们还可以使用相同格式导出到 BSON 文件: ```sql SELECT * @@ -456,4 +457,4 @@ INTO OUTFILE 'out.bson' FORMAT BSONEachRow ``` -之后,我们将把数据导出到 `out.bson` 文件。 +之后,我们的数据将导出到 `out.bson` 文件中。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/json/formats.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/json/formats.md.hash index a5cf4762999..3020b8b1cc9 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/json/formats.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/json/formats.md.hash @@ -1 +1 @@ -908565680797f79e +ca7a1aca4d20f1dd diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/json/inference.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/json/inference.md index ff16a09e7d5..47ef08620e8 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/json/inference.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/json/inference.md @@ -1,30 +1,29 @@ --- -'title': 'JSON 模式推断' +'title': 'JSON schema 推断' 'slug': '/integrations/data-formats/json/inference' -'description': '如何使用 JSON 模式推断' +'description': '如何使用 JSON schema 推断' 'keywords': - 'json' - 'schema' - 'inference' - 'schema inference' +'doc_type': 'guide' --- -import PrivatePreviewBadge from '@theme/badges/PrivatePreviewBadge'; - -ClickHouse 可以自动确定 JSON 数据的结构。这可以直接用于查询 JSON 数据,例如在磁盘上使用 `clickhouse-local` 或 S3 存储桶,和/或在将数据加载到 ClickHouse 之前自动创建模式。 +ClickHouse 可以自动确定 JSON 数据的结构。这可以用于直接查询 JSON 数据,例如在磁盘上使用 `clickhouse-local` 或 S3 存储桶,和/或在将数据加载到 ClickHouse 之前自动创建模式。 ## 何时使用类型推断 {#when-to-use-type-inference} -* **一致的结构** - 您将要推断类型的数据包含您感兴趣的所有键。类型推断是基于对数据进行采样,直到达到 [最大行数](/operations/settings/formats#input_format_max_rows_to_read_for_schema_inference) 或 [字节数](/operations/settings/formats#input_format_max_bytes_to_read_for_schema_inference)。在采样之后的数据中,额外的列将被忽略,无法查询。 -* **一致的类型** - 特定键的数据类型需要兼容,即必须能够自动将一种类型强制转换为另一种类型。 +* **一致的结构** - 从中推断类型的数据包含您关注的所有键。类型推断基于对数据的采样,直到 [最大行数](/operations/settings/formats#input_format_max_rows_to_read_for_schema_inference) 或 [字节数](/operations/settings/formats#input_format_max_bytes_to_read_for_schema_inference)。在采样后的数据中,额外的列将被忽略,无法查询。 +* **一致的类型** - 特定键的数据类型需要兼容,即必须能够自动强制转换一种类型为另一种类型。 -如果您有更动态的 JSON,其中新键被添加并且同一路径可能有多种类型,请参见 ["处理半结构化和动态数据"](/integrations/data-formats/json/inference#working-with-semi-structured-data)。 +如果您有更动态的 JSON,其中添加了新键且同一路径可能出现多种类型,请参见 ["处理半结构化和动态数据"](/integrations/data-formats/json/inference#working-with-semi-structured-data)。 ## 检测类型 {#detecting-types} -以下假设 JSON 一致结构且每个路径只有一种类型。 +以下假定 JSON 结构一致并且每个路径具有单一类型。 -我们之前的示例使用了 `NDJSON` 格式的简单版本 [Python PyPI 数据集](https://clickpy.clickhouse.com/)。在本节中,我们探讨一个具有嵌套结构的更复杂数据集 - [arXiv 数据集](https://www.kaggle.com/datasets/Cornell-University/arxiv?resource=download),包含 250 万篇学术论文。此数据集中每一行以 `NDJSON` 形式分布,代表一篇已发布的学术论文。示例行如下所示: +我们之前的示例使用了一个简单版本的 [Python PyPI 数据集](https://clickpy.clickhouse.com/) ,格式为 `NDJSON`。在本节中,我们探讨一个具有嵌套结构的更复杂数据集 - [arXiv 数据集](https://www.kaggle.com/datasets/Cornell-University/arxiv?resource=download),包含 250 万篇学术论文。该数据集中的每一行,分布为 `NDJSON`,代表一篇已发表的学术论文。以下是一个示例行: ```json { @@ -60,17 +59,17 @@ ClickHouse 可以自动确定 JSON 数据的结构。这可以直接用于查询 } ``` -该数据需要比前面的示例更复杂的模式。我们在下面概述定义此模式的过程,介绍了 `Tuple` 和 `Array` 等复杂类型。 +该数据需要比之前更复杂的模式。我们在下面概述了定义此模式的过程,引入复杂类型,如 `Tuple` 和 `Array`。 -此数据集存储在公共 S3 存储桶中,位于 `s3://datasets-documentation/arxiv/arxiv.json.gz`。 +该数据集存储在公共的 S3 存储桶中,地址为 `s3://datasets-documentation/arxiv/arxiv.json.gz`。 -您可以看到上面的数据集包含嵌套的 JSON 对象。虽然用户应该起草并版本化他们的模式,但推断允许从数据中推断类型。这使得可以自动生成模式 DDL,避免手动构建并加速开发过程。 +您可以看到,上述数据集包含嵌套的 JSON 对象。虽然用户应该起草和版本控制他们的模式,但推断允许从数据中推断类型。这允许自动生成模式 DDL,避免手动构建,加速开发过程。 :::note 自动格式检测 -除了检测模式外,JSON 模式推断将自动根据文件扩展名和内容推断数据格式。上述文件由于自动检测被识别为 NDJSON。 +除了检测模式外,JSON 模式推断还会根据文件扩展名和内容自动推断数据的格式。由于上述文件被自动检测为 NDJSON。 ::: -使用 [s3 function](/sql-reference/table-functions/s3) 和 `DESCRIBE` 命令显示将被推断的类型。 +使用 [s3 函数](/sql-reference/table-functions/s3) 和 `DESCRIBE` 命令显示将要推断的类型。 ```sql DESCRIBE TABLE s3('https://datasets-documentation.s3.eu-west-3.amazonaws.com/arxiv/arxiv.json.gz') @@ -94,21 +93,21 @@ SETTINGS describe_compact_output = 1 │ authors_parsed │ Array(Array(Nullable(String))) │ └────────────────┴─────────────────────────────────────────────────────────────────────────┘ ``` -:::note 避免 Null -您会看到,很多列被检测为 Nullable。我们 [不建议在不绝对需要时使用 Nullable](/sql-reference/data-types/nullable#storage-features) 类型。您可以使用 [schema_inference_make_columns_nullable](/operations/settings/formats#schema_inference_make_columns_nullable) 来控制何时应用 Nullable 的行为。 +:::note 避免空值 +可以看到很多列被检测为 Nullable。我们 [不建议在不绝对需要时使用 Nullable](/sql-reference/data-types/nullable#storage-features) 类型。您可以使用 [schema_inference_make_columns_nullable](/operations/settings/formats#schema_inference_make_columns_nullable) 控制何时应用 Nullable 的行为。 ::: -我们可以看到大多数列已自动检测为 `String`,而 `update_date` 列被正确检测为 `Date`。 `versions` 列已创建为 `Array(Tuple(created String, version String))` 以存储对象列表,`authors_parsed` 被定义为 `Array(Array(String))` 用于嵌套数组。 +我们可以看到大多数列已自动检测为 `String`,而 `update_date` 列正确地被检测为 `Date`。`versions` 列已创建为 `Array(Tuple(created String, version String))`,以存储对象列表,而 `authors_parsed` 被定义为 `Array(Array(String))`,用于嵌套数组。 :::note 控制类型检测 -日期和日期时间的自动检测可以通过设置 [`input_format_try_infer_dates`](/operations/settings/formats#input_format_try_infer_dates) 和 [`input_format_try_infer_datetimes`](/operations/settings/formats#input_format_try_infer_datetimes) 分别进行控制(两者默认启用)。对对象作为元组推断的控制由设置 [`input_format_json_try_infer_named_tuples_from_objects`](/operations/settings/formats#input_format_json_try_infer_named_tuples_from_objects) 控制。其他控制 JSON 模式推断的设置,如数字的自动检测,可以在 [此处]( /interfaces/schema-inference#text-formats) 找到。 +日期和日期时间的自动检测可以通过设置 [`input_format_try_infer_dates`](/operations/settings/formats#input_format_try_infer_dates) 和 [`input_format_try_infer_datetimes`](/operations/settings/formats#input_format_try_infer_datetimes) 分别控制(默认情况下均启用)。对象作为元组的推断受设置 [`input_format_json_try_infer_named_tuples_from_objects`](/operations/settings/formats#input_format_json_try_infer_named_tuples_from_objects) 控制。控制 JSON 模式推断的其他设置,如数字的自动检测,可以在 [这里](/interfaces/schema-inference#text-formats) 找到。 ::: ## 查询 JSON {#querying-json} -以下假设 JSON 是一致结构并且每个路径只有一种类型。 +以下假定 JSON 结构一致并且每个路径具有单一类型。 -我们可以依赖模式推断直接查询 JSON 数据。下面,我们找出每年的顶级作者,利用日期和数组的自动检测。 +我们可以依靠模式推断来就地查询 JSON 数据。下面,我们查找每年的顶级作者,利用日期和数组被自动检测的事实。 ```sql SELECT @@ -148,11 +147,11 @@ LIMIT 1 BY year 18 rows in set. Elapsed: 20.172 sec. Processed 2.52 million rows, 1.39 GB (124.72 thousand rows/s., 68.76 MB/s.) ``` -模式推断使我们能够在无需指定模式的情况下查询 JSON 文件,从而加速临时数据分析任务。 +模式推断使我们能够查询 JSON 文件,而不需要指定模式,加速临时数据分析任务。 ## 创建表 {#creating-tables} -我们可以依赖模式推断为表创建模式。以下的 `CREATE AS EMPTY` 命令导致推断表的 DDL 并创建表。这不会加载任何数据: +我们可以依靠模式推断来创建表的模式。以下 `CREATE AS EMPTY` 命令使表的 DDL 被推断并创建表。此操作不会加载任何数据: ```sql CREATE TABLE arxiv @@ -189,11 +188,11 @@ ENGINE = MergeTree ORDER BY update_date ``` -上述即为该数据的正确模式。模式推断基于对数据的采样,逐行读取数据。根据格式提取列值,使用递归解析器和启发式方法来确定每个值的类型。在模式推断中读取的最大行数和字节由设置 [`input_format_max_rows_to_read_for_schema_inference`](/operations/settings/formats#input_format_max_rows_to_read_for_schema_inference) (默认 25000)和 [`input_format_max_bytes_to_read_for_schema_inference`](/operations/settings/formats#input_format_max_bytes_to_read_for_schema_inference) (默认 32MB)控制。如果检测不正确,用户可以根据 [此处]( /operations/settings/formats#schema_inference_make_columns_nullable) 的描述提供提示。 +以上就是此数据的正确模式。模式推断基于对数据进行采样并逐行读取数据。列值根据格式提取,使用递归解析器和启发式方法来确定每个值的类型。在模式推断中从数据中读取的最大行数和字节数由设置 [`input_format_max_rows_to_read_for_schema_inference`](/operations/settings/formats#input_format_max_rows_to_read_for_schema_inference) (默认 25000)和 [`input_format_max_bytes_to_read_for_schema_inference`](/operations/settings/formats#input_format_max_bytes_to_read_for_schema_inference) (默认 32MB)控制。如果检测不正确,用户可以提供提示,如 [这里](/operations/settings/formats#schema_inference_make_columns_nullable) 所述。 -### 从代码片段创建表 {#creating-tables-from-snippets} +### 从片段创建表 {#creating-tables-from-snippets} -上述示例使用 S3 上的文件创建表模式。用户可以希望从单行代码片段创建模式。这可以通过使用 [format](/sql-reference/table-functions/format) 函数实现,如下所示: +以上示例使用 S3 上的文件创建表模式。用户可能希望从单行片段创建模式。这可以通过使用 [format](/sql-reference/table-functions/format) 函数,如下所示实现: ```sql CREATE TABLE arxiv @@ -226,9 +225,9 @@ ORDER BY update_date ## 加载 JSON 数据 {#loading-json-data} -以下假设 JSON 是一致结构并且每个路径只有一种类型。 +以下假定 JSON 结构一致并且每个路径具有单一类型。 -之前的命令创建了一个可以加载数据的表。您现在可以使用以下的 `INSERT INTO SELECT` 将数据插入到您的表中: +之前的命令创建了一个可以加载数据的表。现在您可以使用以下 `INSERT INTO SELECT` 将数据插入到表中: ```sql INSERT INTO arxiv SELECT * @@ -238,9 +237,9 @@ FROM s3('https://datasets-documentation.s3.eu-west-3.amazonaws.com/arxiv/arxiv.j Peak memory usage: 870.67 MiB. ``` -有关从其他源(例如文件)加载数据的示例,请参见 [此处]( /sql-reference/statements/insert-into)。 +有关从其他源(例如文件)加载数据的示例,请参见 [这里](/sql-reference/statements/insert-into)。 -数据加载后,我们可以查询数据,选择使用格式 `PrettyJSONEachRow` 来显示行的原始结构: +一旦加载,我们可以查询我们的数据,选择使用格式 `PrettyJSONEachRow` 以显示原始结构中的行: ```sql SELECT * @@ -280,19 +279,17 @@ FORMAT PrettyJSONEachRow ## 处理错误 {#handling-errors} -有时,您可能会遇到坏数据。例如,特定列没有正确的类型或 JSON 对象格式不正确。为此,您可以使用设置 [`input_format_allow_errors_num`](/operations/settings/formats#input_format_allow_errors_num) 和 [`input_format_allow_errors_ratio`](/operations/settings/formats#input_format_allow_errors_ratio) 来允许某些行被忽略,如果数据触发插入错误。此外,可以提供 [提示](/operations/settings/formats#schema_inference_hints) 来帮助推断。 +有时,您可能会遇到错误数据。例如,特定列没有正确的类型或格式不正确的 JSON 对象。为此,您可以使用设置 [`input_format_allow_errors_num`](/operations/settings/formats#input_format_allow_errors_num) 和 [`input_format_allow_errors_ratio`](/operations/settings/formats#input_format_allow_errors_ratio) 来允许在数据触发插入错误时忽略一定数量的行。此外,可以提供 [提示](/operations/settings/formats#schema_inference_hints) 来帮助推断。 ## 处理半结构化和动态数据 {#working-with-semi-structured-data} - - -我们之前的示例使用了具有静态且众所周知的键名和类型的 JSON。情况往往并非如此 - 键可以被添加或其类型可以更改。这在可观察性数据等用例中很常见。 +我们之前的示例使用了具有固定键名和类型的静态 JSON。情况往往不是这样 - 可以添加键或它们的类型可能会发生变化。这在可观测性数据等用例中是非常常见的。 -ClickHouse 通过专用的 [`JSON`](/sql-reference/data-types/newjson) 类型来处理此问题。 +ClickHouse 通过专用的 [`JSON`](/sql-reference/data-types/newjson) 类型来处理此情况。 -如果您知道您的 JSON 动态性很高,具有许多唯一键和相同键的多种类型,我们建议不要使用 `JSONEachRow` 进行模式推断以尝试为每个键推断列 - 即使数据是换行分隔的 JSON 格式。 +如果您知道您的 JSON 高度动态,具有许多独特的键和相同键的多种类型,我们建议不要使用 `JSONEachRow` 的模式推断来尝试为每个键推断列 - 即使数据是以换行分隔的 JSON 格式。 -考虑以下从扩展版本上面的 [Python PyPI 数据集](https://clickpy.clickhouse.com/) 数据集的示例。在这里,我们添加了一个任意的 `tags` 列,其中包含随机键值对。 +考虑以下来自上述 [Python PyPI 数据集](https://clickpy.clickhouse.com/) 的扩展版本的示例。在这里,我们添加了一个任意的 `tags` 列,包含随机键值对。 ```json { @@ -311,7 +308,7 @@ ClickHouse 通过专用的 [`JSON`](/sql-reference/data-types/newjson) 类型来 } ``` -这部分数据以换行分隔的 JSON 格式公开提供。如果我们尝试对该文件进行模式推断,您会发现性能较差,返回极为冗长的响应: +该数据的样本以换行分隔的 JSON 格式公开可用。如果我们尝试对该文件进行模式推断,您会发现性能不佳,响应非常冗长: ```sql DESCRIBE s3('https://datasets-documentation.s3.eu-west-3.amazonaws.com/pypi/pypi_with_tags/sample_rows.json.gz') @@ -321,11 +318,11 @@ DESCRIBE s3('https://datasets-documentation.s3.eu-west-3.amazonaws.com/pypi/pypi 9 rows in set. Elapsed: 127.066 sec. ``` -这里的主要问题是使用 `JSONEachRow` 格式进行推断。这试图推断 **JSON 中每个键的列类型** - 实际上试图对数据应用静态模式,而没有使用 [`JSON`](/sql-reference/data-types/newjson) 类型。 +这里的主要问题是使用 `JSONEachRow` 格式进行推断。它尝试为 JSON 中的 **每个键推断一个列类型** - 有效地试图对数据应用静态模式,而不使用 [`JSON`](/sql-reference/data-types/newjson) 类型。 -对于成千上万的唯一列,这种推断方法速度很慢。作为替代,用户可以使用 `JSONAsObject` 格式。 +由于拥有数千个唯一列,这种推断方式很慢。作为替代方案,用户可以使用 `JSONAsObject` 格式。 -`JSONAsObject` 将整个输入视为一个单独的 JSON 对象,并将其存储在单个类型为 [`JSON`](/sql-reference/data-types/newjson) 的列中,使其更适合处理高度动态或嵌套的 JSON 负载。 +`JSONAsObject` 将整个输入视为一个单一的 JSON 对象,并将其存储在类型为 [`JSON`](/sql-reference/data-types/newjson) 的单一列中,更适合高度动态或嵌套的 JSON 有效载荷。 ```sql DESCRIBE TABLE s3('https://datasets-documentation.s3.eu-west-3.amazonaws.com/pypi/pypi_with_tags/sample_rows.json.gz', 'JSONAsObject') @@ -338,14 +335,14 @@ SETTINGS describe_compact_output = 1 1 row in set. Elapsed: 0.005 sec. ``` -在列具有无法调和的多种类型的情况下,此格式也是必不可少的。例如,考虑一个 `sample.json` 文件,其换行分隔的 JSON 内容如下: +这种格式在存在类型无法调和的情况下也是必不可少的。例如,请考虑一个名为 `sample.json` 的文件,包含以下换行分隔的 JSON: ```json {"a":1} {"a":"22"} ``` -在这种情况下,ClickHouse 能够强制类型冲突,并将列 `a` 解析为 `Nullable(String)`。 +在这种情况下,ClickHouse 可以强制类型冲突并将列 `a` 解析为 `Nullable(String)`。 ```sql DESCRIBE TABLE s3('https://datasets-documentation.s3.eu-west-3.amazonaws.com/json/sample.json') @@ -359,17 +356,17 @@ SETTINGS describe_compact_output = 1 ``` :::note 类型强制转换 -这种类型的强制转换可以通过多个设置来控制。上述示例依赖设置 [`input_format_json_read_numbers_as_strings`](/operations/settings/formats#input_format_json_read_numbers_as_strings)。 +此类型强制转换可以通过多个设置来控制。上述示例依赖于设置 [`input_format_json_read_numbers_as_strings`](/operations/settings/formats#input_format_json_read_numbers_as_strings)。 ::: -但是,一些类型是互不兼容的。考虑以下示例: +但是,一些类型不兼容。考虑以下示例: ```json {"a":1} {"a":{"b":2}} ``` -在这种情况下,这里任何形式的类型转换都是不可能的。因此 `DESCRIBE` 命令失败: +在这种情况下,此处的任何形式的类型转换都是不可能的。因此, `DESCRIBE` 命令失败: ```sql DESCRIBE s3('https://datasets-documentation.s3.eu-west-3.amazonaws.com/json/conflict_sample.json') @@ -381,7 +378,7 @@ Code: 636. DB::Exception: Received from sql-clickhouse.clickhouse.com:9440. DB:: Code: 53. DB::Exception: Automatically defined type Tuple(b Int64) for column 'a' in row 1 differs from type defined by previous rows: Int64. You can specify the type for this column using setting schema_inference_hints. ``` -在这种情况下,`JSONAsObject` 将每一行视为一个单独的 [`JSON`](/sql-reference/data-types/newjson) 类型(该类型支持同一列具有多种类型)。这一点至关重要: +在这种情况下,`JSONAsObject` 将每一行视为单一的 [`JSON`](/sql-reference/data-types/newjson) 类型(支持同一列具有多种类型)。这是至关重要的: ```sql DESCRIBE TABLE s3('https://datasets-documentation.s3.eu-west-3.amazonaws.com/json/conflict_sample.json', JSONAsObject) @@ -394,6 +391,6 @@ SETTINGS enable_json_type = 1, describe_compact_output = 1 1 row in set. Elapsed: 0.010 sec. ``` -## 进一步阅读 {#further-reading} +## 深入阅读 {#further-reading} -欲了解有关数据类型推断的更多信息,您可以参考 [此]( /interfaces/schema-inference) 文档页面。 +要了解有关数据类型推断的更多信息,请参阅 [此](/interfaces/schema-inference) 文档页面。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/json/inference.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/json/inference.md.hash index f939b715ed9..bb24e943bc8 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/json/inference.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/json/inference.md.hash @@ -1 +1 @@ -7dfb6c0a9aa1b6fc +1d56887bb4479310 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/json/intro.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/json/intro.md index 6a73e9d2743..697e7a4910a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/json/intro.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/json/intro.md @@ -8,6 +8,7 @@ - 'json' - 'clickhouse' 'score': 10 +'doc_type': 'guide' --- @@ -26,11 +27,11 @@
-ClickHouse 提供了多种处理 JSON 的方法,每种方法都有各自的优缺点和使用场景。在本指南中,我们将讨论如何加载 JSON 并优化设计您的模式。本文包含以下章节: +ClickHouse 提供了几种处理 JSON 的方法,每种方法都有其各自的优缺点和使用场景。在本指南中,我们将介绍如何加载 JSON 以及如何最佳设计您的架构。该指南包括以下部分: -- [加载 JSON](/integrations/data-formats/json/loading) - 在 ClickHouse 中使用简单模式加载和查询结构化和半结构化 JSON。 -- [JSON 模式推断](/integrations/data-formats/json/inference) - 使用 JSON 模式推断查询 JSON 并创建表模式。 -- [设计 JSON 模式](/integrations/data-formats/json/schema) - 设计和优化您的 JSON 模式的步骤。 +- [加载 JSON](/integrations/data-formats/json/loading) - 使用简单架构在 ClickHouse 中加载和查询结构化和半结构化的 JSON。 +- [JSON 架构推断](/integrations/data-formats/json/inference) - 使用 JSON 架构推断查询 JSON 并创建表架构。 +- [设计 JSON 架构](/integrations/data-formats/json/schema) - 设计和优化您的 JSON 架构的步骤。 - [导出 JSON](/integrations/data-formats/json/exporting) - 如何导出 JSON。 -- [处理其他 JSON 格式](/integrations/data-formats/json/other-formats) - 关于处理非换行分隔 (NDJSON) 的 JSON 格式的一些提示。 -- [建模 JSON 的其他方法](/integrations/data-formats/json/other-approaches) - 建模 JSON 的传统方法。 **不推荐使用。** +- [处理其他 JSON 格式](/integrations/data-formats/json/other-formats) - 一些处理除了换行分隔的 (NDJSON) 以外的 JSON 格式的提示。 +- [建模 JSON 的其他方法](/integrations/data-formats/json/other-approaches) - 建模 JSON 的传统方法。**不推荐。** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/json/intro.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/json/intro.md.hash index 0d03cd23f11..7cd0e3615b5 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/json/intro.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/json/intro.md.hash @@ -1 +1 @@ -a42322e99453c2d0 +dfc21c93e3ccfa90 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/json/loading.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/json/loading.md index 33a644f4106..099ac999fba 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/json/loading.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/json/loading.md @@ -11,20 +11,19 @@ - 'loading' - 'inserting' 'score': 15 +'doc_type': 'guide' --- -import PrivatePreviewBadge from '@theme/badges/PrivatePreviewBadge'; - # 加载 JSON {#loading-json} -以下示例提供了加载结构化和半结构化 JSON 数据的一个非常简单的例子。有关更复杂的 JSON,包括嵌套结构,请参阅指南 [**设计 JSON 模式**](/integrations/data-formats/json/schema)。 +以下示例提供了加载结构化和半结构化 JSON 数据的非常简单的示例。有关更复杂的 JSON,包括嵌套结构,请参阅指南 [**设计 JSON 模式**](/integrations/data-formats/json/schema)。 ## 加载结构化 JSON {#loading-structured-json} -在本节中,我们假设 JSON 数据采用 [`NDJSON`](https://github.com/ndjson/ndjson-spec)(换行符分隔的 JSON)格式,在 ClickHouse 中被称为 [`JSONEachRow`](/interfaces/formats#jsoneachrow),且结构良好,即列名和类型是固定的。`NDJSON` 是加载 JSON 的首选格式,因为它简洁且有效利用空间,但其他格式也受支持,用于输入和输出 [input and output](/interfaces/formats#json)。 +在本节中,我们假设 JSON 数据采用 [`NDJSON`](https://github.com/ndjson/ndjson-spec)(换行分隔 JSON)格式,在 ClickHouse 中称为 [`JSONEachRow`](/interfaces/formats#jsoneachrow),并且结构良好,即列名和类型是固定的。由于其简洁性和高效的空间使用,`NDJSON` 是加载 JSON 的首选格式,但其他格式也受支持,包括 [输入和输出](/interfaces/formats#json)。 -考虑以下 JSON 示例,表示来自 [Python PyPI 数据集](https://clickpy.clickhouse.com/) 的一行: +考虑以下 JSON 示例,表示来自 [Python PyPI 数据集](https://clickpy.clickhouse.com/) 的一行数据。 ```json { @@ -39,19 +38,19 @@ import PrivatePreviewBadge from '@theme/badges/PrivatePreviewBadge'; } ``` -为了将此 JSON 对象加载到 ClickHouse 中,必须定义一个表模式。 +为了将此 JSON 对象加载到 ClickHouse 中,必须定义表模式。 -在这个简单的情况下,我们的结构是静态的,我们的列名是已知的,且它们的类型是明确定义的。 +在这个简单的例子中,我们的结构是静态的,我们的列名是已知的,类型也是明确定义的。 -虽然 ClickHouse 通过 JSON 类型支持半结构化数据,其中键名及其类型可以是动态的,但在这里这是不必要的。 +尽管 ClickHouse 通过 JSON 类型支持半结构化数据,其中键名及其类型可以是动态的,但在这里这是不必要的。 -:::note 尽可能优先使用静态模式 -在列名和类型固定且不期望新列的情况下,始终在生产环境中优先使用静态定义的模式。 +:::note 尽可能选择静态模式 +在您的列具有固定名称和类型且不期望新列的情况下,在生产环境中始终优先选择静态定义的模式。 -对于高度动态的数据,建议使用 JSON 类型,其中列的名称和类型可能会发生变化。此类型在原型开发和数据探索中也非常有用。 +对于高度动态的数据,JSON 类型是首选,由于列的名称和类型可能会改变。此类型在原型设计和数据探索中也很有用。 ::: -下方显示了一个简单的模式,其中 **JSON 键映射到列名**: +下面显示了一个简单的模式,其中 **JSON 键映射到列名**: ```sql CREATE TABLE pypi ( @@ -69,10 +68,10 @@ ORDER BY (project, date) ``` :::note 排序键 -我们通过 `ORDER BY` 子句选择了一个排序键。有关排序键及其选择的更多详细信息,请参见 [这里](/data-modeling/schema-design#choosing-an-ordering-key)。 +我们通过 `ORDER BY` 子句选择了一个排序键。有关排序键及如何选择它们的详细信息,请参见 [此处](/data-modeling/schema-design#choosing-an-ordering-key)。 ::: -ClickHouse 可以以多种格式加载 JSON 数据,自动从扩展名和内容推断类型。我们可以使用 [S3 函数](/sql-reference/table-functions/s3) 读取上述表的 JSON 文件: +ClickHouse 可以以几种格式加载 JSON 数据,自动根据扩展名和内容推断类型。我们可以使用 [S3 函数](/sql-reference/table-functions/s3) 读取上述表的 JSON 文件: ```sql SELECT * @@ -85,17 +84,17 @@ LIMIT 1 1 row in set. Elapsed: 1.232 sec. ``` -请注意,我们无需指定文件格式。相反,我们使用通配符模式读取桶中的所有 `*.json.gz` 文件。ClickHouse 自动推断文件扩展名和内容为 `JSONEachRow`(ndjson)格式。如果 ClickHouse 无法检测到格式,可以通过参数函数手动指定格式。 +注意我们无需指定文件格式。相反,我们使用通配符模式读取存储桶中的所有 `*.json.gz` 文件。 ClickHouse 会自动根据文件扩展名和内容推断格式为 `JSONEachRow`(ndjson)。如果 ClickHouse 无法检测格式,可以通过参数函数手动指定格式。 ```sql SELECT * FROM s3('https://datasets-documentation.s3.eu-west-3.amazonaws.com/pypi/json/*.json.gz', JSONEachRow) ``` :::note 压缩文件 -上述文件也被压缩。这由 ClickHouse 自动检测和处理。 +上述文件也是压缩的。ClickHouse 会自动检测和处理压缩文件。 ::: -为了加载这些文件中的行,我们可以使用 [`INSERT INTO SELECT`](/sql-reference/statements/insert-into#inserting-the-results-of-select): +要加载这些文件中的行,我们可以使用 [`INSERT INTO SELECT`](/sql-reference/statements/insert-into#inserting-the-results-of-select): ```sql INSERT INTO pypi SELECT * FROM s3('https://datasets-documentation.s3.eu-west-3.amazonaws.com/pypi/json/*.json.gz') @@ -113,7 +112,7 @@ SELECT * FROM pypi LIMIT 2 2 rows in set. Elapsed: 0.005 sec. Processed 8.19 thousand rows, 908.03 KB (1.63 million rows/s., 180.38 MB/s.) ``` -行也可以使用 [`FORMAT` 子句](/sql-reference/statements/select/format) 进行内联加载,例如: +行也可以通过 [`FORMAT` 子句](/sql-reference/statements/select/format) 内联加载,例如: ```sql INSERT INTO pypi @@ -121,17 +120,15 @@ FORMAT JSONEachRow {"date":"2022-11-15","country_code":"CN","project":"clickhouse-connect","type":"bdist_wheel","installer":"bandersnatch","python_minor":"","system":"","version":"0.2.8"} ``` -这些示例假设使用 `JSONEachRow` 格式。也支持其他常见的 JSON 格式,相关加载示例提供 [这里](/integrations/data-formats/json/other-formats)。 +这些示例假设使用 `JSONEachRow` 格式。支持其他常见的 JSON 格式,这些格式的加载示例在 [此处](/integrations/data-formats/json/other-formats) 提供。 ## 加载半结构化 JSON {#loading-semi-structured-json} - - -我们之前的示例加载了具有已知键名和类型的静态 JSON。这往往不是情况 - 键可以被添加或其类型可以改变。这在可观察性数据等用例中很常见。 +我们之前的示例加载了具有静态且已知键名和类型的 JSON。这种情况通常不是这样 - 密钥可以被添加或其类型可以改变。这在可观察性数据等用例中是很常见的。 -ClickHouse 通过专用的 [`JSON`](/sql-reference/data-types/newjson) 类型来处理这个问题。 +ClickHouse 通过专用的 [`JSON`](/sql-reference/data-types/newjson) 类型处理这种情况。 -考虑来自上述 [Python PyPI 数据集](https://clickpy.clickhouse.com/) 的扩展版本的以下示例。在这里,我们添加了一列任意的 `tags`,其中包含随机的键值对。 +考虑以下示例,来自上述 [Python PyPI 数据集](https://clickpy.clickhouse.com/) 的扩展版本。在这里,我们添加了一个任意的 `tags` 列,包含随机键值对。 ```json { @@ -151,7 +148,7 @@ ClickHouse 通过专用的 [`JSON`](/sql-reference/data-types/newjson) 类型来 ``` -这里的 tags 列是不可预测的,因此我们无法对其建模。为了加载这些数据,我们可以使用我们之前的模式,但提供一个附加的 `tags` 列,类型为 [`JSON`](/sql-reference/data-types/newjson): +这里的 tags 列是不可预测的,因此我们无法为其建模。要加载这些数据,我们可以使用我们之前的模式,但提供一个额外的 `tags` 列,其类型为 [`JSON`](/sql-reference/data-types/newjson): ```sql SET enable_json_type = 1; @@ -172,7 +169,7 @@ ENGINE = MergeTree ORDER BY (project, date); ``` -我们使用与原始数据集相同的方法填充表: +我们使用与原始数据集相同的方法填充表格: ```sql INSERT INTO pypi_with_tags SELECT * FROM s3('https://datasets-documentation.s3.eu-west-3.amazonaws.com/pypi/pypi_with_tags/sample.json.gz') @@ -199,20 +196,20 @@ LIMIT 2 2 rows in set. Elapsed: 0.149 sec. ``` -请注意,加载数据时的性能差异。JSON 列在插入时需要类型推断,并且如果存在多于一种类型的列,则需要额外的存储。虽然可以配置 JSON 类型(请参见 [设计 JSON 模式](/integrations/data-formats/json/schema))以实现与显式声明列相当的性能,但它在开箱即用时有意灵活。然而,这种灵活性也会带来一些成本。 +注意这里加载数据时的性能差异。JSON 列在插入时需要进行类型推断,如果存在多个类型的列,则还需要额外存储。尽管可以配置 JSON 类型(参见 [设计 JSON 模式](/integrations/data-formats/json/schema))以实现与显式声明列的等效性能,但它的灵活性是在开箱即用的情况下设计的。然而,这种灵活性是有代价的。 ### 何时使用 JSON 类型 {#when-to-use-the-json-type} -在以下情况下使用 JSON 类型: +当您的数据: -* 具有 **不可预测的键**,可能会随时间变化。 -* 包含 **具有不同类型的值**(例如,路径有时可能包含字符串,有时可能是数字)。 -* 需要模式灵活性,而严格类型不可行。 +* 具有 **不可预测的键**,这些键可以随时间变化。 +* 包含 **具有不同类型的值**(例如,一个路径有时可能包含一个字符串,有时是一个数字)。 +* 需要模式灵活性,而严格类型不切实际。 -如果您的数据结构已知且一致,几乎没有必要使用 JSON 类型,即使您的数据是 JSON 格式。具体而言,如果您的数据具有: +如果您的数据结构是已知且一致的,则几乎不需要使用 JSON 类型,即使您的数据是 JSON 格式。具体来说,如果您的数据具有: -* **已知键的扁平结构**:使用标准列类型,例如 String。 -* **可预测的嵌套**:为这些结构使用 Tuple、Array 或 Nested 类型。 -* **可预测结构但具有不同类型**:考虑使用 Dynamic 或 Variant 类型。 +* **具有已知键的扁平结构**:使用标准列类型,例如 String。 +* **可预测的嵌套**:使用 Tuple、Array 或 Nested 类型来表示这些结构。 +* **具有不同类型的可预测结构**:可以考虑使用 Dynamic 或 Variant 类型。 -您还可以像上面的示例那样混合使用方法,使用静态列对应可预测的顶层键,并为负载的动态部分使用单一的 JSON 列。 +您还可以像我们在上述示例中所做的那样混合使用方法,使用静态列来表示可预测的顶级键,并使用单个 JSON 列来表示有效负载的动态部分。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/json/loading.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/json/loading.md.hash index f70da9d6560..28297e1245f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/json/loading.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/json/loading.md.hash @@ -1 +1 @@ -967c6f95ca7ea957 +8469e536dba818aa diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/json/other.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/json/other.md index dc406bc37cb..ceaa4eaab04 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/json/other.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/json/other.md @@ -5,24 +5,25 @@ 'keywords': - 'json' - 'formats' +'doc_type': 'reference' --- # 其他建模 JSON 的方法 -**以下是 ClickHouse 中建模 JSON 的替代方案。这些方法是为了完整性而记录的,并且在 JSON 类型开发之前适用,因此在大多数用例中通常不推荐使用。** +**以下是在 ClickHouse 中建模 JSON 的替代方法。这些方法是为了完整性而记录,并且在 JSON 类型开发之前适用,因此在大多数用例中通常不推荐或不适用。** -:::note 应用对象级别的方法 -在相同的模式中,可以对不同的对象应用不同的技术。例如,某些对象可以使用 `String` 类型解决,而其他对象则可以使用 `Map` 类型。请注意,一旦使用了 `String` 类型,则不需要做进一步的模式决定。相反,可以在 `Map` 键中嵌套子对象 - 包括一个表示 JSON 的 `String` - 正如我们下面所示: +:::note 应用对象级别方法 +不同的技术可以应用于同一模式中的不同对象。例如,有些对象最好使用 `String` 类型解决,而其他对象则使用 `Map` 类型。请注意,一旦使用了 `String` 类型,就不需要进一步做出模式决策。相反,可以在 `Map` 键中嵌套子对象 - 包括表示 JSON 的 `String` - 正如我们在下面展示的那样: ::: -## 使用 String {#using-string} +## 使用 String 类型 {#using-string} -如果对象高度动态,结构不可预测并包含任意嵌套对象,用户应使用 `String` 类型。可以在查询时使用 JSON 函数提取值,如下所示。 +如果对象高度动态,没有可预测的结构并包含任意嵌套对象,用户应该使用 `String` 类型。可以在查询时使用 JSON 函数提取值,如我们下面所示。 -对于拥有动态 JSON 的用户,使用上述结构化方法处理数据通常不可行,这些 JSON 要么有可能会变化,要么其模式不易理解。为了获得绝对的灵活性,用户可以简单地将 JSON 作为 `String` 存储,然后使用函数根据需要提取字段。这代表了将 JSON 处理为结构化对象的极端对立面。这种灵活性带来了显著的缺陷 - 主要是查询语法复杂性的增加以及性能下降。 +使用上述结构化方法处理数据对于那些具有动态 JSON 的用户通常是不可行的,这类 JSON 可能会发生变化或者其模式并不明确。为了绝对的灵活性,用户可以简单地将 JSON 存储为 `String`,然后根据需要使用函数提取字段。这代表了将 JSON 作为结构化对象处理的极端相反方式。这种灵活性带来了显著的缺点 - 主要是查询语法复杂性的增加以及性能的下降。 -如前所述,对于 [原始人员对象](/integrations/data-formats/json/schema#static-vs-dynamic-json),我们无法确保 `tags` 列的结构。我们插入原始行(包括 `company.labels`,我们暂时忽略),将 `Tags` 列声明为 `String`: +正如前面提到的,对于 [原始人员对象](/integrations/data-formats/json/schema#static-vs-dynamic-json),我们无法确保 `tags` 列的结构。我们插入原始行(包括 `company.labels`,我们暂时忽略),将 `Tags` 列声明为 `String`: ```sql CREATE TABLE people @@ -48,7 +49,7 @@ Ok. 1 row in set. Elapsed: 0.002 sec. ``` -我们可以选择 `tags` 列,并看到 JSON 已作为字符串插入: +我们可以选择 `tags` 列,看到 JSON 已被插入为字符串: ```sql SELECT tags @@ -61,10 +62,10 @@ FROM people 1 row in set. Elapsed: 0.001 sec. ``` -[`JSONExtract`](/sql-reference/functions/json-functions#jsonextract-functions) 函数可用于检索此 JSON 中的值。考虑下面这个简单的例子: +[`JSONExtract`](/sql-reference/functions/json-functions#jsonextract-functions) 函数可以用来从这个 JSON 中检索值。考虑以下简单示例: ```sql -SELECT JSONExtractString(tags, 'holidays') as holidays FROM people +SELECT JSONExtractString(tags, 'holidays') AS holidays FROM people ┌─holidays──────────────────────────────────────┐ │ [{"year":2024,"location":"Azores, Portugal"}] │ @@ -73,9 +74,9 @@ SELECT JSONExtractString(tags, 'holidays') as holidays FROM people 1 row in set. Elapsed: 0.002 sec. ``` -请注意,这些函数需要同时引用 `String` 列 `tags` 和提取 JSON 的路径。嵌套路径要求函数嵌套,例如 `JSONExtractUInt(JSONExtractString(tags, 'car'), 'year')`,它提取列 `tags.car.year`。通过函数 [`JSON_QUERY`](/sql-reference/functions/json-functions#json_query) 和 [`JSON_VALUE`](/sql-reference/functions/json-functions#json_value),可以简化嵌套路径的提取。 +注意这些函数同时需要引用 `String` 列 `tags` 和 JSON 中的路径进行提取。嵌套路径需要嵌套函数,例如 `JSONExtractUInt(JSONExtractString(tags, 'car'), 'year')`,它提取列 `tags.car.year`。通过 [`JSON_QUERY`](/sql-reference/functions/json-functions#JSON_QUERY) 和 [`JSON_VALUE`](/sql-reference/functions/json-functions#JSON_VALUE) 函数,可以简化嵌套路径的提取。 -考虑极端情况下的 `arxiv` 数据集,我们将整个正文视为 `String`。 +考虑在 `arxiv` 数据集中将整个主体视为 `String` 的极端情况。 ```sql CREATE TABLE arxiv ( @@ -84,7 +85,7 @@ CREATE TABLE arxiv ( ENGINE = MergeTree ORDER BY () ``` -要插入此模式,我们需要使用 `JSONAsString` 格式: +为了插入到这个模式中,我们需要使用 `JSONAsString` 格式: ```sql INSERT INTO arxiv SELECT * @@ -93,7 +94,7 @@ FROM s3('https://datasets-documentation.s3.eu-west-3.amazonaws.com/arxiv/arxiv.j 0 rows in set. Elapsed: 25.186 sec. Processed 2.52 million rows, 1.38 GB (99.89 thousand rows/s., 54.79 MB/s.) ``` -假设我们希望按年份统计发布的论文数量。对比使用字符串的以下查询与模式的 [结构化版本](/integrations/data-formats/json/inference#creating-tables): +假设我们希望按年份计算发布的论文数量。将以下仅使用字符串的查询与此模式的 [结构化版本](/integrations/data-formats/json/inference#creating-tables) 对比: ```sql -- using structured schema @@ -147,29 +148,29 @@ LIMIT 10 Peak memory usage: 205.98 MiB. ``` -请注意,这里使用 XPath 表达式来根据方法过滤 JSON,即 `JSON_VALUE(body, '$.versions[0].created')`。 +注意此处使用 XPath 表达式来按方法过滤 JSON,即 `JSON_VALUE(body, '$.versions[0].created')`。 -字符串函数明显比显式类型转换带索引慢 (> 10x)。上述查询始终需要完全扫描整个表并处理每一行。尽管在小数据集上这样的查询仍然会很快,但在更大型的数据集中,性能会降低。 +字符串函数明显比使用索引的显式类型转换慢 (> 10 倍)。上述查询始终需要对整个表进行扫描并处理每一行。虽然在如上所示的小型数据集上这些查询仍然会很快,但在较大的数据集上性能会下降。 -这种方法的灵活性伴随着明显的性能和语法成本,仅应对高度动态的对象使用。 +这种方法的灵活性以明显的性能和语法成本为代价,应该仅用于模式中高度动态的对象。 ### 简单 JSON 函数 {#simple-json-functions} -上述示例使用了 JSON* 函数系列。它们利用了基于 [simdjson](https://github.com/simdjson/simdjson) 的完整 JSON 解析器,该解析器在解析时很严格,并将处于不同级别的相同字段加以区分。这些函数能够处理语法正确但格式不佳的 JSON,例如键之间的双空格字符。 +上述示例使用了一系列 JSON* 函数。这些函数利用了基于 [simdjson](https://github.com/simdjson/simdjson) 的完整 JSON 解析器,该解析器具有严格的解析能力,并且能够区分在不同级别嵌套的相同字段。该函数能够处理语法正确但格式不良的 JSON,例如键之间的双空格。 -还有一组更快且更严格的函数。这些 `simpleJSON*` 函数通过对 JSON 的结构和格式做出严格假设,提供潜在的优越性能。具体要求如下: +有一组更快且更严格的函数可供使用。这些 `simpleJSON*` 函数通过对 JSON 的结构和格式做出严格假设,提供了潜在的性能优势。具体来说: -- 字段名必须为常量 -- 字段名称编码一致,例如 `simpleJSONHas('{"abc":"def"}', 'abc') = 1`,而 `visitParamHas('{"\\u0061\\u0062\\u0063":"def"}', 'abc') = 0` -- 字段名称在所有嵌套结构中是唯一的。对嵌套级别不做区分,匹配是无差别的。如果存在多个匹配字段,则使用第一个匹配的字段。 -- 除了字符串文字外,不允许有特殊字符。这包括空格。以下是无效的,并且无法解析。 +- 字段名称必须是常量 +- 字段名称必须一致编码,例如 `simpleJSONHas('{"abc":"def"}', 'abc') = 1`,但 `visitParamHas('{"\\u0061\\u0062\\u0063":"def"}', 'abc') = 0` +- 字段名称在所有嵌套结构中必须是唯一的。嵌套级别之间没有区别,匹配是无差别的。在多个匹配字段的情况下,使用第一个出现的字段。 +- 除字符串字面量外,不允许有特殊字符。这包括空格。以下是无效的,不会被解析。 ```json {"@timestamp": 893964617, "clientip": "40.135.0.0", "request": {"method": "GET", "path": "/images/hm_bg.jpg", "version": "HTTP/1.0"}, "status": 200, "size": 24736} ``` -而下面的将正确解析: +而且,以下将正确解析: ```json {"@timestamp":893964617,"clientip":"40.135.0.0","request":{"method":"GET", @@ -203,27 +204,27 @@ LIMIT 10 Peak memory usage: 211.49 MiB. ``` -上述查询使用 `simpleJSONExtractString` 提取 `created` 键,利用我们只需获取已发布日期的第一个值。在这种情况下,`simpleJSON*` 函数的限制对性能提升是可接受的。 +上述查询使用 `simpleJSONExtractString` 提取 `created` 键,利用我们只想要发布日期的第一个值的事实。在这种情况下,`simpleJSON*` 函数的限制对于性能的提升是可以接受的。 -## 使用 Map {#using-map} +## 使用 Map 类型 {#using-map} -如果对象用于存储任意键,且大多数为同一类型,则考虑使用 `Map` 类型。理想情况下,唯一键的数量不应超过几百个。`Map` 类型也可以用于具有子对象的对象,前提是后者在其类型上具有一致性。一般来说,我们建议将 `Map` 类型用于标签和标签,例如日志数据中的 Kubernetes pod 标签。 +如果对象用于存储任意键,大多数为一种类型,请考虑使用 `Map` 类型。理想情况下,唯一键的数量不应超过数百个。对于具有子对象的对象,也可以考虑使用 `Map` 类型,前提是后者的类型要统一。一般而言,我们建议将 `Map` 类型用于标签和标签,例如日志数据中的 Kubernetes pod 标签。 -虽然 `Map` 提供了一种简单的方式来表示嵌套结构,但他们有一些显著的限制: +虽然 `Map` 提供了一种简单代表嵌套结构的方式,但它有一些显著的限制: -- 所有字段必须是同一类型。 -- 访问子列需要特殊的 Map 语法,因为这些字段不存在为列。整个对象 _是_ 一列。 -- 访问子列会加载整个 `Map` 值,即所有兄弟和它们各自的值。对于较大的 Map,这可能会导致显著的性能惩罚。 +- 所有字段必须为相同类型。 +- 访问子列需要特殊的映射语法,因为字段并不存在为列。整个对象 _是_ 一列。 +- 访问子列会加载整个 `Map` 值,即所有兄弟及其各自的值。对于较大的 Maps,这可能导致显著的性能损失。 :::note 字符串键 -在将对象建模为 `Map` 时,使用 `String` 键来存储 JSON 键名称。因此 Map 将始终是 `Map(String, T)`,其中 `T` 取决于数据。 +当将对象建模为 `Map`s 时,使用 `String` 键来存储 JSON 键名。因此,映射将始终是 `Map(String, T)`,其中 `T` 取决于数据。 ::: #### 原始值 {#primitive-values} -`Map` 的最简单应用是当对象包含相同的原始类型作为值时。在大多数情况下,这涉及将 `String` 类型用于值 `T`。 +`Map` 的最简单应用场景是当对象包含相同原始类型的值。在大多数情况下,这涉及到使用 `String` 类型作为值 `T`。 -考虑我们之前的 [人员 JSON](/integrations/data-formats/json/schema#static-vs-dynamic-json),其中 `company.labels` 对象被确定为动态。重要的是,我们只期望将类型为 String 的键值对添加到这个对象中。因此,我们可以将其声明为 `Map(String, String)`: +考虑我们之前的 [人员 JSON](/integrations/data-formats/json/schema#static-vs-dynamic-json),其中 `company.labels` 对象被确定为动态。重要的是,我们只期望将类型为 String 的键值对添加到该对象。因此,我们可以将其声明为 `Map(String, String)`: ```sql CREATE TABLE people @@ -243,7 +244,7 @@ ENGINE = MergeTree ORDER BY username ``` -我们可以插入我们原始的完整 JSON 对象: +我们可以插入原始完整的 JSON 对象: ```sql INSERT INTO people FORMAT JSONEachRow @@ -254,7 +255,7 @@ Ok. 1 row in set. Elapsed: 0.002 sec. ``` -在请求对象中查询这些字段需要使用 Map 语法,例如: +在请求对象中查询这些字段需要使用映射语法,例如: ```sql SELECT company.labels FROM people @@ -274,13 +275,13 @@ SELECT company.labels['type'] AS type FROM people 1 row in set. Elapsed: 0.001 sec. ``` -此时可以使用完整的 `Map` 函数查询,详细描述见 [这里](/sql-reference/functions/tuple-map-functions.md)。如果您的数据没有一致的类型,则存在执行 [必要的类型强制转换](/sql-reference/functions/type-conversion-functions) 的函数。 +可以查询的完整 `Map` 函数可在 [此处](/sql-reference/functions/tuple-map-functions.md) 查找。如果你的数据不是一致的类型,可以使用函数进行 [必要的类型转换](/sql-reference/functions/type-conversion-functions)。 #### 对象值 {#object-values} -`Map` 类型也可以考虑用于具有子对象的对象,只要后者在其类型上保持一致。 +对于具有子对象的对象,`Map` 类型也可以被考虑,前提是后者具有类型一致性。 -假设我们 `persons` 对象的 `tags` 键需要一致的结构,其中每个 `tag` 的子对象具有 `name` 和 `time` 列。这样 JSON 文档的简化示例如下: +假设我们 `persons` 对象的 `tags` 键需要一个一致的结构,其中每个 `tag` 的子对象都有 `name` 和 `time` 列。这样 JSON 文档的简化示例如下: ```json { @@ -331,7 +332,7 @@ FORMAT JSONEachRow 1 row in set. Elapsed: 0.001 sec. ``` -在这种情况下使用 Map 通常是罕见的,建议对数据进行重建,使动态键名不再有子对象。例如,上述内容可以重建为允许使用 `Array(Tuple(key String, name String, time DateTime))`。 +在这种情况下,使用映射的情况通常是罕见的,这表明数据应重新建模,以便动态键名没有子对象。例如,上述内容可以重新建模为如下,使得使用 `Array(Tuple(key String, name String, time DateTime))` 成为可能。 ```json { @@ -354,9 +355,9 @@ FORMAT JSONEachRow } ``` -## 使用 Nested {#using-nested} +## 使用 Nested 类型 {#using-nested} -[Nested 类型](/sql-reference/data-types/nested-data-structures/nested) 可用于建模静态对象,这些对象很少发生变化,提供了一种替代 `Tuple` 和 `Array(Tuple)` 的方案。我们一般建议避免将此类型用于 JSON,因为它的行为通常令人困惑。`Nested` 的主要优点是可以在排序键中使用子列。 +[Nested 类型](/sql-reference/data-types/nested-data-structures/nested) 可用于建模静态对象,这些对象很少会发生变化,提供了 `Tuple` 和 `Array(Tuple)` 的替代方案。我们通常建议避免将此类型用于 JSON,因为其行为往往令人困惑。`Nested` 的主要好处是可以在排序键中使用子列。 下面,我们提供一个使用 Nested 类型建模静态对象的示例。考虑以下简单的 JSON 日志条目: @@ -374,7 +375,7 @@ FORMAT JSONEachRow } ``` -我们可以将 `request` 键声明为 `Nested`。类似于 `Tuple`,我们需要指定子列。 +我们可以将 `request` 键声明为 `Nested`。与 `Tuple` 类似,我们需要指定子列。 ```sql -- default @@ -395,7 +396,7 @@ CREATE table http #### flatten_nested=1 {#flatten_nested1} -值为 `1`(默认值)不支持任意层级的嵌套。使用此值时,可以将嵌套数据结构视为多个 [Array](/sql-reference/data-types/array) 列,且长度相同。字段 `method`、`path` 和 `version` 实际上都是独立的 `Array(Type)` 列,并有一个关键约束:**`method`、`path` 和 `version` 字段的长度必须相同。** 如果使用 `SHOW CREATE TABLE`,将会得到如下示例: +值为 `1`(默认值)不支持任意级别的嵌套。使用此值,最容易将嵌套数据结构视为多个长度相同的 [Array](/sql-reference/data-types/array) 列。字段 `method`、`path` 和 `version` 在效果上都是单独的 `Array(Type)` 列,并且有一个关键约束:**`method`、`path` 和 `version` 字段的长度必须相同。** 如果我们使用 `SHOW CREATE TABLE`,这将得到体现: ```sql SHOW CREATE TABLE http @@ -414,7 +415,7 @@ ENGINE = MergeTree ORDER BY (status, timestamp) ``` -下面,我们插入到此表中: +在下面,我们插入此表: ```sql SET input_format_import_nested_json = 1; @@ -423,9 +424,9 @@ FORMAT JSONEachRow {"timestamp":897819077,"clientip":"45.212.12.0","request":[{"method":"GET","path":"/french/images/hm_nav_bar.gif","version":"HTTP/1.0"}],"status":200,"size":3305} ``` -这里有几点重要事项: +这里有几个重要要点需要注意: -* 我们需要使用 `input_format_import_nested_json` 设置将 JSON 作为嵌套结构插入。没有此设置,我们需要将 JSON 扁平化,即。 +* 我们需要使用设置 `input_format_import_nested_json` 将 JSON 作为嵌套结构插入。否则,我们需要将 JSON 压平,即。 ```sql INSERT INTO http FORMAT JSONEachRow @@ -453,7 +454,7 @@ INSERT INTO http FORMAT JSONEachRow } ``` -可以使用点表示法查询列: +列可以使用点表示法进行查询: ```sql SELECT clientip, status, size, `request.method` FROM http WHERE has(request.method, 'GET'); @@ -464,15 +465,15 @@ SELECT clientip, status, size, `request.method` FROM http WHERE has(request.meth 1 row in set. Elapsed: 0.002 sec. ``` -请注意,对子列使用的 `Array` 意味着可以充分利用全套 [Array 函数](/sql-reference/functions/array-functions),包括 [`ARRAY JOIN`](/sql-reference/statements/select/array-join) 子句 - 如果您的列具有多个值,这将非常有用。 +注意子列使用 `Array` 意味着可以潜在地利用完整的 [Array 函数](/sql-reference/functions/array-functions),包括 [`ARRAY JOIN`](/sql-reference/statements/select/array-join) 子句 - 如果你的列有多个值,这将非常有用。 #### flatten_nested=0 {#flatten_nested0} -这允许任意层级的嵌套,并意味着嵌套列保持为单个 `Tuple` 的数组 - 实际上它们变成了 `Array(Tuple)` 的相同形式。 +这允许任意级别的嵌套,并意味着嵌套列保持为单个 `Tuple` 数组 - 实际上,它们变得与 `Array(Tuple)` 相同。 -**这是使用 `Nested` 的首选方式,通常也是最简单的方式。如我们下面所示,它只要求所有对象都是一个列表。** +**这是使用 JSON 结合 `Nested` 的首选方式,通常也是最简单的方式。正如我们下面所示,它只要求所有对象都是列表。** -下面,我们重新创建表并重新插入一行: +在下面,我们重新创建我们的表并重新插入一行: ```sql CREATE TABLE http @@ -505,11 +506,11 @@ FORMAT JSONEachRow {"timestamp":897819077,"clientip":"45.212.12.0","request":[{"method":"GET","path":"/french/images/hm_nav_bar.gif","version":"HTTP/1.0"}],"status":200,"size":3305} ``` -这里有几点重要事项: +这里有几个重要要点需要注意: -* 不需要 `input_format_import_nested_json` 来插入。 -* `SHOW CREATE TABLE` 中保留了 `Nested` 类型。该列的底层实质上是 `Array(Tuple(Nested(method LowCardinality(String), path String, version LowCardinality(String))))` -* 因此,我们需要将 `request` 作为数组插入,即。 +* 插入时不需要 `input_format_import_nested_json`。 +* 在 `SHOW CREATE TABLE` 中保留了 `Nested` 类型。在此列下实际是 `Array(Tuple(Nested(method LowCardinality(String), path String, version LowCardinality(String))))` +* 因此,我们被要求将 `request` 插入为一个数组,即。 ```json { @@ -527,7 +528,7 @@ FORMAT JSONEachRow } ``` -可以再次使用点表示法查询列: +列再次可以使用点表示法进行查询: ```sql SELECT clientip, status, size, `request.method` FROM http WHERE has(request.method, 'GET'); @@ -540,7 +541,7 @@ SELECT clientip, status, size, `request.method` FROM http WHERE has(request.meth ### 示例 {#example} -上述数据的大型示例可在 s3 的公共桶中找到:`s3://datasets-documentation/http/`。 +上述数据的较大示例可以在公共 S3 存储桶中找到,位于: `s3://datasets-documentation/http/`。 ```sql SELECT * @@ -563,9 +564,9 @@ FORMAT PrettyJSONEachRow 1 row in set. Elapsed: 0.312 sec. ``` -考虑到 JSON 的约束和输入格式,我们使用以下查询插入此示例数据集。在这里,我们设置 `flatten_nested=0`。 +考虑到 JSON 的约束和输入格式,我们使用以下查询插入此样本数据集。在这里,我们将 `flatten_nested=0`。 -以下语句插入了 1000 万行,因此此过程可能需要几分钟来执行。如有需要,请应用 `LIMIT`: +以下语句插入 1000 万行,因此可能需要几分钟才能执行。如果需要,请应用 `LIMIT`: ```sql INSERT INTO http @@ -574,14 +575,14 @@ size FROM s3('https://datasets-documentation.s3.eu-west-3.amazonaws.com/http/doc 'JSONEachRow'); ``` -查询此数据需要我们将请求字段作为数组访问。下面,我们总结了固定时间段内的错误和 HTTP 方法。 +查询这些数据要求我们将请求字段视为数组。下面,我们总结在固定时间段内的错误和 HTTP 方法。 ```sql -SELECT status, request.method[1] as method, count() as c +SELECT status, request.method[1] AS method, count() AS c FROM http WHERE status >= 400 AND toDateTime(timestamp) BETWEEN '1998-01-01 00:00:00' AND '1998-06-01 00:00:00' -GROUP by method, status +GROUP BY method, status ORDER BY c DESC LIMIT 5; ┌─status─┬─method─┬─────c─┐ @@ -597,9 +598,9 @@ ORDER BY c DESC LIMIT 5; ### 使用成对数组 {#using-pairwise-arrays} -成对数组提供了一种在将 JSON 表示为字符串的灵活性和更结构化方法的性能之间的平衡。模式是灵活的,因为可以潜在地向根添加任何新字段。然而,这需要显著更复杂的查询语法,并且与嵌套结构不兼容。 +成对数组在将 JSON 表示为字符串的灵活性和更结构化方法的性能之间提供了平衡。这一模式灵活性体现在根节点可以潜在添加任何新字段。然而,这需要显著更复杂的查询语法,并且不兼容嵌套结构。 -例如,考虑以下表: +作为示例,考虑以下表: ```sql CREATE TABLE http_with_arrays ( @@ -609,7 +610,7 @@ CREATE TABLE http_with_arrays ( ENGINE = MergeTree ORDER BY tuple(); ``` -要插入此表,我们需要将 JSON 构建为键值对的列表。以下查询说明了如何使用 `JSONExtractKeysAndValues` 来实现这一点: +要插入到此表中,我们需要将 JSON 结构化为键值对列表。以下查询说明了如何使用 `JSONExtractKeysAndValues` 来实现这一点: ```sql SELECT @@ -627,7 +628,7 @@ values: ['893964617','40.135.0.0','{"method":"GET","path":"/images/hm_bg.jpg","v 1 row in set. Elapsed: 0.416 sec. ``` -注意请求列仍然作为字符串表示的嵌套结构。我们可以向根添加任何新键。我们还可以在 JSON 本身中有任意差异。要插入我们的本地表,请执行以下操作: +注意请求列仍作为嵌套结构表示为字符串。我们可以将任何新键插入到根。我们还可以在 JSON 本身中有任意差异。要插入到我们的本地表中,执行以下操作: ```sql INSERT INTO http_with_arrays @@ -639,25 +640,4 @@ FROM s3('https://datasets-documentation.s3.eu-west-3.amazonaws.com/http/document 0 rows in set. Elapsed: 12.121 sec. Processed 10.00 million rows, 107.30 MB (825.01 thousand rows/s., 8.85 MB/s.) ``` -查询此结构需要使用 [`indexOf`](/sql-reference/functions/array-functions#indexofarr-x) 函数识别所需键的索引(该索引应与值的顺序一致)。这可以用于访问值数组列,即 `values[indexOf(keys, 'status')]`。我们仍然需要一个 JSON 解析方法用于请求列 - 在这种情况下为 `simpleJSONExtractString`。 - -```sql -SELECT toUInt16(values[indexOf(keys, 'status')]) as status, - simpleJSONExtractString(values[indexOf(keys, 'request')], 'method') as method, - count() as c -FROM http_with_arrays -WHERE status >= 400 - AND toDateTime(values[indexOf(keys, '@timestamp')]) BETWEEN '1998-01-01 00:00:00' AND '1998-06-01 00:00:00' -GROUP by method, status ORDER BY c DESC LIMIT 5; - -┌─status─┬─method─┬─────c─┐ -│ 404 │ GET │ 11267 │ -│ 404 │ HEAD │ 276 │ -│ 500 │ GET │ 160 │ -│ 500 │ POST │ 115 │ -│ 400 │ GET │ 81 │ -└────────┴────────┴───────┘ - -5 rows in set. Elapsed: 0.383 sec. Processed 8.22 million rows, 1.97 GB (21.45 million rows/s., 5.15 GB/s.) -Peak memory usage: 51.35 MiB. -``` +查询此结构需要使用 [`indexOf`](/sql-reference/functions/array-functions#indexOf) 函数来识别所需键的索引(这应该与值的顺序一致)。这可用于访问值数组列,即 `values[indexOf(keys, 'status')]`。我们仍然需要为请求列使用 JSON 解析方法 - 在这种情况下,`simpleJSONExtractString`。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/json/other.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/json/other.md.hash index e2e51eddd87..e6ea7f437f6 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/json/other.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/json/other.md.hash @@ -1 +1 @@ -fa9d9fb7005d0254 +6d78779c40f119bf diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/json/schema.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/json/schema.md index d35e0365031..22e87533194 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/json/schema.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/json/schema.md @@ -1,7 +1,7 @@ --- -'title': '设计 JSON 架构' +'title': '设计 JSON 模式' 'slug': '/integrations/data-formats/json/schema' -'description': '如何最佳地设计 JSON 架构' +'description': '如何最佳地设计 JSON 模式' 'keywords': - 'json' - 'clickhouse' @@ -12,31 +12,31 @@ - 'structured' - 'semi-structured' 'score': 20 +'doc_type': 'guide' --- -import PrivatePreviewBadge from '@theme/badges/PrivatePreviewBadge'; import Image from '@theme/IdealImage'; import json_column_per_type from '@site/static/images/integrations/data-ingestion/data-formats/json_column_per_type.png'; import json_offsets from '@site/static/images/integrations/data-ingestion/data-formats/json_offsets.png'; import shared_json_column from '@site/static/images/integrations/data-ingestion/data-formats/json_shared_column.png'; -# 设计您的架构 +# 设计您的模式 -虽然可以使用 [架构推断](/integrations/data-formats/json/inference) 为 JSON 数据建立初始架构,并在 S3 等地方查询 JSON 数据文件,用户应该旨在为他们的数据建立一个优化的版本化架构。我们在下面讨论建模 JSON 结构的推荐方法。 +虽然 [模式推断](/integrations/data-formats/json/inference) 可用于为 JSON 数据建立初始模式并在指定位置查询 JSON 数据文件,例如在 S3 中,但用户应旨在为其数据建立一个优化的版本化模式。我们将在下面讨论建模 JSON 结构的推荐方法。 -## 静态与动态 JSON {#static-vs-dynamic-json} +## 静态 vs 动态 JSON {#static-vs-dynamic-json} -定义 JSON 架构的主要任务是确定每个键值的适当类型。我们建议用户递归应用以下规则于 JSON 层次结构中的每个键,以确定每个键的适当类型。 +定义 JSON 模式的主要任务是确定每个键值的适当类型。我们建议用户对 JSON 层次结构中的每个键递归应用以下规则,以确定每个键的适当类型。 -1. **基本类型** - 如果键的值是基本类型,无论它是子对象的一部分还是在根部,都确保根据一般架构 [设计最佳实践](/data-modeling/schema-design) 和 [类型优化规则](/data-modeling/schema-design#optimizing-types) 选择其类型。原始类型的数组,例如下面的 `phone_numbers`,可以建模为 `Array()`,例如 `Array(String)`。 -2. **静态与动态** - 如果键的值是复杂对象,即一个对象或对象数组,确定其是否可能会发生变化。那些很少有新键的对象,添加新键可以通过 [`ALTER TABLE ADD COLUMN`](/sql-reference/statements/alter/column#add-column) 的架构变更进行预测和处理的,可以被认为是 **静态** 的。这包括在某些 JSON 文档中可能仅提供部分键的对象。频繁添加新键和/或不可预测的对象应被视为 **动态** 的。**这里的例外是具有数百或数千个子键的结构,为了方便可以被视为动态**。 +1. **原始类型** - 如果键的值是原始类型,无论它是处于子对象中还是在根级别,都确保根据一般的模式 [设计最佳实践](/data-modeling/schema-design) 和 [类型优化规则](/data-modeling/schema-design#optimizing-types) 选择其类型。原始类型的数组,例如下面的 `phone_numbers`,可以建模为 `Array()`,例如 `Array(String)`。 +2. **静态 vs 动态** - 如果键的值是复杂对象,即一个或多个对象的数组,确定它是否会发生变化。那些很少有新键的对象,添加新键可以预测并通过 [`ALTER TABLE ADD COLUMN`](/sql-reference/statements/alter/column#add-column) 进行模式更改的,可以视为 **静态**。这包括在某些 JSON 文档中可能仅提供键的子集的对象。添加新键的对象频繁且/或不可预测的,应视为 **动态**。**这里的例外是具有数百或数千个子键的结构,可以方便地视为动态。** -要确定一个值是 **静态** 还是 **动态**,请查看相关部分 [**处理静态对象**](/integrations/data-formats/json/schema#handling-static-structures) 和 [**处理动态对象**](/integrations/data-formats/json/schema#handling-semi-structured-dynamic-structures) 。 +要确定值是 **静态** 还是 **动态**,请查看下面相关章节 [**处理静态对象**](/integrations/data-formats/json/schema#handling-static-structures) 和 [**处理动态对象**](/integrations/data-formats/json/schema#handling-semi-structured-dynamic-structures)。

-**重要**:以上规则应递归应用。如果确定键的值是动态的,则无需进一步评估,可以遵循 [**处理动态对象**](/integrations/data-formats/json/schema#handling-semi-structured-dynamic-structures) 中的指南。如果对象是静态的,则继续评估子键,直到遇到键值为基本类型或动态键。 +**重要:** 上述规则应递归应用。如果键的值被确定为动态,则不需要进一步评估,可以遵循 [**处理动态对象**](/integrations/data-formats/json/schema#handling-semi-structured-dynamic-structures) 中的指南。如果对象是静态的,则继续评估子键,直到遇到原始键值或动态键为止。 为了说明这些规则,我们使用以下 JSON 示例表示一个人: @@ -90,20 +90,20 @@ import shared_json_column from '@site/static/images/integrations/data-ingestion/ 应用这些规则: -- 根键 `name`、`username`、`email`、`website` 可以表示为类型 `String`。列 `phone_numbers` 是一个类型为 `Array(String)` 的原始数组,`dob` 和 `id` 的类型分别为 `Date` 和 `UInt32`。 -- `address` 对象不会添加新键(只会添加新的地址对象),因此可以认为是 **静态** 的。如果我们递归,所有子列都可以视为原始类型(类型为 `String`),除了 `geo`。这也是一个具有两个 `Float32` 列 `lat` 和 `lon` 的静态结构。 -- 列 `tags` 是 **动态** 的。我们假设可以向此对象添加新的任意标签,类型和结构不一。 -- `company` 对象是 **静态** 的,最多将始终包含指定的3个键。子键 `name` 和 `catchPhrase` 是类型为 `String`。键 `labels` 是 **动态** 的。我们假设可以向此对象添加新的任意标签。值将始终是类型为字符串的键值对。 +- 根键 `name`、`username`、`email`、`website` 可以表示为 `String` 类型。列 `phone_numbers` 是原始类型的数组,类型为 `Array(String)`,`dob` 和 `id` 的类型分别为 `Date` 和 `UInt32`。 +- `address` 对象不会添加新键(仅新地址对象),因此可以视为 **静态**。如果我们递归,所有子列都可以视为原始类型(且类型为 `String`),除了 `geo`。这也是一个静态结构,包含两个 `Float32` 类型的列,即 `lat` 和 `lon`。 +- `tags` 列是 **动态的**。我们假设可以向该对象添加任意类型和结构的新标签。 +- `company` 对象是 **静态的**,并且始终最多包含指定的 3 个键。子键 `name` 和 `catchPhrase` 是 `String` 类型。键 `labels` 是 **动态的**。我们假设可以向该对象添加任意类型的标签。值始终是键值对,类型为字符串。 :::note -具有数百或数千个静态键的结构可以被视为动态,因为静态声明这些列通常是不现实的。然而,尽可能 [跳过路径](#using-type-hints-and-skipping-paths) 不需要的键,以节省存储和推断开销。 +具有数百或数千个静态键的结构可以视为动态,因为在静态声明这些列的情况下很少是现实的。然而,在可能的情况下 [跳过路径](#using-type-hints-and-skipping-paths) ,以节省存储和推断开销。 ::: ## 处理静态结构 {#handling-static-structures} -我们建议使用命名元组(即 `Tuple`)来处理静态结构。对象数组可以使用元组数组(即 `Array(Tuple)`)来表示。在元组内部,列及其相应的类型应使用相同的规则定义。这可以导致嵌套元组以表示嵌套对象,如下所示。 +我们建议使用命名元组来处理静态结构,即 `Tuple`。对象数组可以使用元组数组来保存,即 `Array(Tuple)`。在元组内部,应使用相同的规则来定义列及其相应的类型。这可能会导致嵌套元组以表示嵌套对象,如下所示。 -为了说明这一点,我们使用之前的 JSON 人物示例,省略动态对象: +为了说明这一点,我们使用之前的 JSON 人示例,省略动态对象: ```json { @@ -136,7 +136,7 @@ import shared_json_column from '@site/static/images/integrations/data-ingestion/ } ``` -该表的架构如下所示: +该表的模式如下所示: ```sql CREATE TABLE people @@ -155,16 +155,16 @@ ENGINE = MergeTree ORDER BY username ``` -注意 `company` 列定义为 `Tuple(catchPhrase String, name String)`。`address` 键使用 `Array(Tuple)`,嵌套 `Tuple` 用于表示 `geo` 列。 +请注意,`company` 列被定义为 `Tuple(catchPhrase String, name String)`。`address` 键使用 `Array(Tuple)`,并嵌套 `Tuple` 来表示 `geo` 列。 -可以将当前结构的 JSON 插入到此表中: +JSON 可以按其当前结构插入到此表中: ```sql INSERT INTO people FORMAT JSONEachRow {"id":1,"name":"Clicky McCliickHouse","username":"Clicky","email":"clicky@clickhouse.com","address":[{"street":"Victor Plains","suite":"Suite 879","city":"Wisokyburgh","zipcode":"90566-7771","geo":{"lat":-43.9509,"lng":-34.4618}}],"phone_numbers":["010-692-6593","020-192-3333"],"website":"clickhouse.com","company":{"name":"ClickHouse","catchPhrase":"The real-time data warehouse for analytics"},"dob":"2007-03-31"} ``` -在上述示例中,我们的数据最小,但如下面所示,我们可以通过它们的周期分隔名称查询元组列。 +在我们之前的示例中,我们的数据很少,但如下面所示,我们可以按其点分隔的名称查询元组列。 ```sql SELECT @@ -177,7 +177,7 @@ FROM people └───────────────────┴──────────────┘ ``` -注意,`address.street` 列被返回为 `Array`。要按位置查询数组中的特定对象,应在列名后指定数组偏移量。例如,访问第一个地址中的街道: +请注意,`address.street` 列被返回为一个 `Array`。要按位置查询数组中的特定对象,数组偏移量应在列名称后指定。例如,要访问第一个地址中的街道: ```sql SELECT address.street[1] AS street @@ -190,7 +190,7 @@ FROM people 1 row in set. Elapsed: 0.001 sec. ``` -子列也可以用在 [来自 `24.12`](https://clickhouse.com/blog/clickhouse-release-24-12#json-subcolumns-as-table-primary-key) 的排序键中: +子列也可以用于来自 [`24.12`](https://clickhouse.com/blog/clickhouse-release-24-12#json-subcolumns-as-table-primary-key) 的排序键: ```sql CREATE TABLE people @@ -209,12 +209,11 @@ ENGINE = MergeTree ORDER BY company.name ``` - ### 处理默认值 {#handling-default-values} -即使 JSON 对象是结构化的,但它们通常是稀疏的,仅提供已知键的子集。幸运的是,`Tuple` 类型不需要 JSON 有效负载中的所有列。如果未提供,将使用默认值。 +即使 JSON 对象是结构化的,它们通常也是稀疏的,仅提供已知键的子集。幸运的是,`Tuple` 类型不要求 JSON 有效负载中的所有列。如果未提供,将使用默认值。 -考虑我们之前的 `people` 表和以下稀疏 JSON,缺失 `suite`、`geo`、`phone_numbers` 和 `catchPhrase` 键。 +考虑我们之前的 `people` 表以及以下稀疏 JSON,缺少键 `suite`、`geo`、`phone_numbers` 和 `catchPhrase`。 ```json { @@ -237,7 +236,7 @@ ORDER BY company.name } ``` -我们可以看到下面这一行可以成功插入: +我们可以看到,下面这一行可以成功插入: ```sql INSERT INTO people FORMAT JSONEachRow @@ -248,7 +247,7 @@ Ok. 1 row in set. Elapsed: 0.002 sec. ``` -查询这一行时,我们可以看到未提供的列(包括子对象)使用了默认值: +查询这一行后,我们可以看到对于省略的列(包括子对象)使用了默认值: ```sql SELECT * @@ -284,15 +283,15 @@ FORMAT PrettyJSONEachRow 1 row in set. Elapsed: 0.001 sec. ``` -:::note 区分空和 null -如果用户需要区分某个值是空的还是未提供,可以使用 [Nullable](/sql-reference/data-types/nullable) 类型。除非绝对必要,否则 [应避免](/best-practices/select-data-types#avoid-nullable-columns) 使用,因为这会对这些列的存储和查询性能产生负面影响。 +:::note 区分空值和 null +如果用户需要区分一个值是空的还是未提供的,可以使用 [Nullable](/sql-reference/data-types/nullable) 类型。除非绝对需要,否则 [应避免](/best-practices/select-data-types#avoid-nullable-columns) 使用,因为这会对这些列的存储和查询性能产生负面影响。 ::: ### 处理新列 {#handling-new-columns} -虽然当 JSON 键是静态时,结构化方法是最简单的,如果可以计划对架构的更改,即新键是已知的,并且可以相应地修改架构,这种方法仍然可以使用。 +虽然当 JSON 键静态时,结构化的方法是最简单的,但如果可以计划模式变化,即新键是提前已知的,仍然可以使用此方法并相应地修改模式。 -请注意,ClickHouse 默认会忽略有效负载中提供的但不在架构中的 JSON 键。考虑以下修改过的 JSON 有效负载,添加了 `nickname` 键: +请注意,ClickHouse 默认会忽略有效负载中提供的并且不在模式中的 JSON 键。考虑以下修改后的 JSON 有效负载,添加了 `nickname` 键: ```json { @@ -326,7 +325,7 @@ FORMAT PrettyJSONEachRow } ``` -这个 JSON 可以成功插入,而忽略了 `nickname` 键: +此 JSON 可以成功插入,并忽略 `nickname` 键: ```sql INSERT INTO people FORMAT JSONEachRow @@ -337,7 +336,7 @@ Ok. 1 row in set. Elapsed: 0.002 sec. ``` -可以使用 [`ALTER TABLE ADD COLUMN`](/sql-reference/statements/alter/column#add-column) 命令向架构添加列。可以通过 `DEFAULT` 语句指定默认值,如果在随后的插入中未指定,将使用该值。对于此值不存在的行(因为它们是在值创建之前插入的),也将返回此默认值。如果未指定 `DEFAULT` 值,将使用该类型的默认值。 +可以使用 [`ALTER TABLE ADD COLUMN`](/sql-reference/statements/alter/column#add-column) 命令向模式添加列。可以通过 `DEFAULT` 子句指定默认值,如果在随后的插入中未指定,则会使用该默认值。对于未提供该值的行(因为它们在创建该值之前插入),也将返回此默认值。如果未指定 `DEFAULT` 值,则会使用该类型的默认值。 例如: @@ -367,20 +366,18 @@ SELECT id, nickname FROM people ## 处理半结构化/动态结构 {#handling-semi-structured-dynamic-structures} - - -如果 JSON 数据是半结构化的,其中键可以动态添加和/或具有多种类型,则推荐使用 [`JSON`](/sql-reference/data-types/newjson) 类型。 +如果 JSON 数据是半结构化的,其中键可以动态添加和/或具有多个类型,建议使用 [`JSON`](/sql-reference/data-types/newjson) 类型。 更具体地说,当您的数据: -- 具有 **不可预测的键**,可能会随时间变化。 -- 包含 **类型各异的值**(例如,路径有时可能包含字符串,有时包含数字)。 -- 需要灵活的架构,而严格的类型定义不可行。 -- 您有 **数百或甚至数千个** 静态路径,但显然不现实进行明确声明。这通常比较少见。 +- 具有 **不可预测的键**,可能会随着时间推移而变化。 +- 包含 **具有不同类型的值**(例如,一个路径有时可能包含字符串,有时可能包含数字)。 +- 需要模式灵活性,其中严格类型化不可行。 +- 你有 **数百或甚至千个** 路径,它们是静态的,但显然不现实地明确声明。这往往是罕见的。 -考虑我们之前的 [人 JSON](/integrations/data-formats/json/schema#static-vs-dynamic-json),其中 `company.labels` 对象被确定为动态。 +考虑我们的 [早期人 JSON](/integrations/data-formats/json/schema#static-vs-dynamic-json) 示例,其中 `company.labels` 对象被确定为动态。 -假设 `company.labels` 包含任意键。此外,此结构中任何键的类型在行之间可能不一致。例如: +假设 `company.labels` 包含任意键。此外,这个结构中任何键的类型可能在行之间不一致。例如: ```json { @@ -482,30 +479,30 @@ SELECT id, nickname FROM people } ``` -考虑到 `company.labels` 列在对象之间的动态性质,涉及键和类型,我们有几种选项来建模此数据: +鉴于 `company.labels` 列在对象之间的动态性质,包括键和值类型,我们有几种选项来建模此数据: -- **单一 JSON 列** - 将整个架构表示为一个单一的 `JSON` 列,允许所有结构在其下动态。 -- **目标 JSON 列** - 仅使用 `JSON` 类型用于 `company.labels` 列,保留上面使用的结构化架构用于所有其他列。 +- **单一 JSON 列** - 将整个模式表示为一个单一的 `JSON` 列,允许在其下方的所有结构都是动态的。 +- **有针对性的 JSON 列** - 仅对 `company.labels` 列使用 `JSON` 类型,对所有其他列保留上面使用的结构化模式。 -虽然第一种方法 [不符合之前的方法](#static-vs-dynamic-json),但单一 JSON 列的方法对于原型和数据工程任务是有用的。 +虽然第一种方法 [与之前的方法不符](#static-vs-dynamic-json),但单一 JSON 列的方法对原型设计和数据工程任务是有用的。 -对于大规模生产部署 ClickHouse,我们建议在可能的情况下对结构保持具体性,并对目标动态子结构使用 JSON 类型。 +对于大规模生产部署的 ClickHouse,我们建议在可能的情况下使用结构的特定性,并为有针对性的动态子结构使用 JSON 类型。 -严格的架构有许多好处: +严格的模式有许多好处: -- **数据验证** – 强制执行严格的架构以避免特定结构之外的列膨胀风险。 -- **避免列膨胀的风险** - 尽管 JSON 类型可扩展到数千列,但当子列作为专用列存储时,这会导致列文件膨胀,从而影响性能。为了减轻这一问题,JSON 使用的底层 [动态类型](/sql-reference/data-types/dynamic) 提供了 [`max_dynamic_paths`](/sql-reference/data-types/newjson#reading-json-paths-as-sub-columns) 参数,该参数限制存储为单独列文件的唯一路径数量。一旦达到阈值,其他路径将以紧凑的编码格式存储在共享列文件中,从而保持性能和存储效率,同时支持灵活的数据摄取。然而,访问此共享列文件的性能则不如专用列文件。需要注意的是,JSON 列可以与 [类型提示](#using-type-hints-and-skipping-paths) 一起使用。“提示”列将提供与专用列相同的性能。 -- **更简单的路径和类型自省** - 尽管 JSON 类型支持 [自省函数](/sql-reference/data-types/newjson#introspection-functions) 来确定已推断的类型和路径,但静态结构可能更易于探索,例如使用 `DESCRIBE`。 +- **数据验证** – 强制执行严格的模式避免了管道溢出的风险,而超出特定结构。 +- **避免列溢出的风险** - 尽管 JSON 类型可以扩展到可能数千列,但如果子列作为专用列存储,这可能会导致列文件的爆炸,创建过多的列文件会影响性能。为了缓解这一点,JSON 使用的基本 [Dynamic type](/sql-reference/data-types/dynamic) 提供了一个 [`max_dynamic_paths`](/sql-reference/data-types/newjson#reading-json-paths-as-sub-columns) 参数,限制存储为单独列文件的唯一路径数。一旦达到阈值,额外的路径将使用紧凑编码格式存储在共享列文件中,在支持灵活数据摄取的同时保持性能和存储效率。然而,访问此共享列文件的性能较差。请注意,JSON 列可以与 [类型提示](#using-type-hints-and-skipping-paths) 一起使用。"提示" 列将提供与专用列相同的性能。 +- **简化路径和类型的内省** - 尽管 JSON 类型支持 [内省函数](/sql-reference/data-types/newjson#introspection-functions) 以确定已经推断出的类型和路径,但静态结构可以更简单地进行探索,例如使用 `DESCRIBE`。 ### 单一 JSON 列 {#single-json-column} -这种方法对于原型设计和数据工程任务是有用的。对于生产环境,尽量仅对动态子结构使用 `JSON`。 +这种方法对原型设计和数据工程任务很有用。对于生产,尽可能只在必要时为动态子结构使用 `JSON`。 -:::note 性能考虑 -单一 JSON 列可以通过跳过(不存储)不需要的 JSON 路径以及使用 [类型提示](#using-type-hints-and-skipping-paths) 来进行优化。类型提示允许用户明确定义子列的类型,从而在查询时跳过推断和间接处理。这可以用来实现与使用显式架构时相同的性能。有关更多细节,请参见 ["使用类型提示和跳过路径"](#using-type-hints-and-skipping-paths)。 +:::note 性能注意事项 +单个 JSON 列可以通过跳过(不存储)不需要的 JSON 路径以及使用 [类型提示](#using-type-hints-and-skipping-paths) 来优化。类型提示允许用户显式定义子列的类型,从而跳过推断和在查询时的间接处理。这可以用于提供与使用显式模式相同的性能。详见 ["使用类型提示和跳过路径"](#using-type-hints-and-skipping-paths)。 ::: -这里单一 JSON 列的架构很简单: +这里单个 JSON 列的模式是简单的: ```sql SET enable_json_type = 1; @@ -519,10 +516,10 @@ ORDER BY json.username; ``` :::note -我们在 JSON 定义中为 `username` 列提供了 [类型提示](#using-type-hints-and-skipping-paths),因为我们在排序/主键中使用了它。这有助于 ClickHouse 知道此列不会为 null,并确保它知道使用哪个 `username` 子列(每种类型可能有多个,因此如果不指示则会产生歧义)。 +在 JSON 定义中,我们对 `username` 列提供了 [类型提示](#using-type-hints-and-skipping-paths),因为我们在排序/主键中使用它。这有助于 ClickHouse 知道此列不会为 null,并确保它知道使用哪个 `username` 子列(每种类型可能有多个,因此否则会产生歧义)。 ::: -向上述表插入行可以使用 `JSONAsObject` 格式实现: +可以使用 `JSONAsObject` 格式将行插入到上述表中: ```sql INSERT INTO people FORMAT JSONAsObject @@ -536,7 +533,6 @@ INSERT INTO people FORMAT JSONAsObject 1 row in set. Elapsed: 0.004 sec. ``` - ```sql SELECT * FROM people @@ -553,10 +549,10 @@ json: {"address":[{"city":"Wisokyburgh","geo":{"lat":-43.9509,"lng":-34.4618},"s 2 rows in set. Elapsed: 0.005 sec. ``` -我们可以使用 [自省函数](/sql-reference/data-types/newjson#introspection-functions) 确定推断出的子列及其类型。例如: +我们可以使用 [内省函数](/sql-reference/data-types/newjson#introspection-functions) 确定推断的子列及其类型。例如: ```sql -SELECT JSONDynamicPathsWithTypes(json) as paths +SELECT JSONDynamicPathsWithTypes(json) AS paths FROM people FORMAT PrettyJsonEachRow @@ -604,9 +600,9 @@ FORMAT PrettyJsonEachRow 2 rows in set. Elapsed: 0.009 sec. ``` -有关自省函数的完整列表,请参见 ["自省函数"](/sql-reference/data-types/newjson#introspection-functions) +有关完整的内省函数列表,请参见 ["内省函数"](/sql-reference/data-types/newjson#introspection-functions)。 -[子路径可以通过](https://sql-reference/data-types/newjson#reading-json-paths-as-sub-columns) 使用 `.` 符号访问,例如: +[子路径可以通过](/sql-reference/data-types/newjson#reading-json-paths-as-sub-columns) 使用 `.` 表示法访问,例如: ```sql SELECT json.name, json.email FROM people @@ -619,9 +615,9 @@ SELECT json.name, json.email FROM people 2 rows in set. Elapsed: 0.006 sec. ``` -注意缺失行中的列被返回为 `NULL`。 +请注意,缺失于行中的列被返回为 `NULL`。 -此外,对于同一类型的路径,创建了单独的子列。例如,对于 `company.labels.type` 既有 `String` 类型也有 `Array(Nullable(String))` 类型子列。虽然尽可能返回这两者,我们可以使用 `.:` 语法定位特定的子列: +此外,对于具有相同类型的路径,将创建一个单独的子列。例如,存在一个 `company.labels.type` 的子列,分别为 `String` 和 `Array(Nullable(String))`。虽然尽可能返回两个,我们可以使用 `.:` 语法来定位特定的子列: ```sql SELECT json.company.labels.type @@ -645,7 +641,7 @@ FROM people 2 rows in set. Elapsed: 0.009 sec. ``` -为了返回嵌套子对象,需要 `^`。这是一个设计选择,以避免读取大量列 - 除非显式请求。未经 `^` 访问的对象将返回 `NULL`,如下所示: +要返回嵌套的子对象,必须使用 `^`,这是为了避免读取大量列 - 除非明确请求。没有 `^` 的访问对象将返回 `NULL`,如下所示: ```sql -- sub objects will not be returned by default @@ -671,12 +667,11 @@ FROM people 2 rows in set. Elapsed: 0.004 sec. ``` +### 有针对性的 JSON 列 {#targeted-json-column} -### 目标 JSON 列 {#targeted-json-column} - -虽然在原型设计和数据工程挑战中有用,但我们建议在生产中尽可能使用显式架构。 +在原型设计和数据工程挑战中很有用,但我们建议在生产中尽可能使用显式模式。 -我们之前的示例可以用单一 `JSON` 列来建模 `company.labels` 列。 +我们之前的示例可以模建为 `company.labels` 列的单个 `JSON` 列。 ```sql CREATE TABLE people @@ -710,7 +705,6 @@ INSERT INTO people FORMAT JSONEachRow 1 row in set. Elapsed: 0.440 sec. ``` - ```sql SELECT * FROM people @@ -745,8 +739,7 @@ tags: {"hobby":"Databases","holidays":[{"year":2024,"location":"Azores, 2 rows in set. Elapsed: 0.005 sec. ``` -可以使用 [自省函数](/sql-reference/data-types/newjson#introspection-functions) 确定 `company.labels` 列的推断路径和类型。 - +[Introspection functions](/sql-reference/data-types/newjson#introspection-functions) 可以用于确定推断的 `company.labels` 列的路径和类型。 ```sql SELECT JSONDynamicPathsWithTypes(company.labels) AS paths @@ -774,7 +767,7 @@ FORMAT PrettyJsonEachRow ### 使用类型提示和跳过路径 {#using-type-hints-and-skipping-paths} -类型提示允许我们为路径及其子列指定类型,防止不必要的类型推断。考虑以下示例,我们在 JSON 列 `company.labels` 中指定键 `dissolved`、`employees` 和 `founded` 的类型。 +类型提示允许我们为路径及其子列指定类型,从而防止不必要的类型推断。考虑以下示例,其中我们为 JSON 列 `company.labels` 中的 JSON 键 `dissolved`、`employees` 和 `founded` 指定类型。 ```sql CREATE TABLE people @@ -816,7 +809,7 @@ INSERT INTO people FORMAT JSONEachRow 1 row in set. Elapsed: 0.440 sec. ``` -注意这些列现在具有我们的显式类型: +请注意,这些列现在具有我们的显式类型: ```sql SELECT JSONAllPathsWithTypes(company.labels) AS paths @@ -843,7 +836,7 @@ FORMAT PrettyJsonEachRow 2 rows in set. Elapsed: 0.003 sec. ``` -此外,我们可以使用 [`SKIP` 和 `SKIP REGEXP`](/sql-reference/data-types/newjson) 参数跳过不想存储的 JSON 路径,以最小化存储并避免对不需要的路径进行不必要的推断。例如,假设我们对上面的数据使用单一 JSON 列。我们可以跳过 `address` 和 `company` 路径: +此外,我们可以使用 [`SKIP` 和 `SKIP REGEXP`](/sql-reference/data-types/newjson) 参数跳过我们不想存储的路径,以最小化存储并避免对不需要路径的推断。例如,假设我们对上述数据使用单个 JSON 列。我们可以跳过 `address` 和 `company` 路径: ```sql CREATE TABLE people @@ -864,7 +857,7 @@ INSERT INTO people FORMAT JSONAsObject 1 row in set. Elapsed: 0.440 sec. ``` -注意我们的列已从数据中排除: +请注意,我们的列已从数据中排除: ```sql @@ -929,30 +922,31 @@ FORMAT PrettyJSONEachRow 2 rows in set. Elapsed: 0.004 sec. ``` - #### 使用类型提示优化性能 {#optimizing-performance-with-type-hints} -类型提示不仅是避免不必要的类型推断的方式 - 它们完全消除了存储和处理间接性,并且允许指定 [最佳原始类型](/data-modeling/schema-design#optimizing-types)。具有类型提示的 JSON 路径总是像传统列一样存储,避免在查询时需要 [**区分列**](https://clickhouse.com/blog/a-new-powerful-json-data-type-for-clickhouse#storage-extension-for-dynamically-changing-data) 或动态解析。 +类型提示不仅仅是避免不必要类型推断的方法 - 它们完全消除了存储和处理间接性,并允许指定 [最佳原始类型](/data-modeling/schema-design#optimizing-types)。具有类型提示的 JSON 路径始终像传统列一样存储,跳过在查询时的 [**区分列**](https://clickhouse.com/blog/a-new-powerful-json-data-type-for-clickhouse#storage-extension-for-dynamically-changing-data) 或动态解析的需要。 + +这意味着,利用良好定义的类型提示,嵌套 JSON 键获得与一开始作为顶级列建模时相同的性能和效率。 -这意味着,对于结构大体一致但仍可从 JSON 的灵活性中受益的数据集,类型提示提供了一种方便的方法来保持性能,而无需重新构建您的架构或摄取管道。 +因此,对于主要一致但仍受益于 JSON 灵活性的 数据集,类型提示提供了一种便捷的方式来保持性能,而无需重构您的模式或摄取管道。 ### 配置动态路径 {#configuring-dynamic-paths} -ClickHouse 以真正的列式布局存储每个 JSON 路径作为子列,使其能够实现与传统列相同的性能优势,例如压缩、SIMD 加速处理和最小的磁盘 I/O。您 JSON 数据中的每个唯一路径和类型组合可以在磁盘上成为其自己的列文件。 +ClickHouse 将每个 JSON 路径存储为真实列式布局中的子列,从而启用与传统列相同的性能优势,例如压缩、SIMD 加速处理和最小磁盘 I/O。您 JSON 数据中的每个唯一路径和类型组合可以成为其在磁盘上的单独列文件。 - + -例如,当插入两个类型不同的 JSON 路径时,ClickHouse 将每个 [具体类型的值存储在不同的子列中](https://clickhouse.com/blog/a-new-powerful-json-data-type-for-clickhouse#storage-extension-for-dynamically-changing-data)。这些子列可以独立访问,从而最小化不必要的 I/O。注意,当查询具有多种类型的列时,其值仍作为单列响应返回。 +例如,当插入两个具有不同类型的 JSON 路径时,ClickHouse 将每个 [具体类型的值存储在不同的子列中](https://clickhouse.com/blog/a-new-powerful-json-data-type-for-clickhouse#storage-extension-for-dynamically-changing-data)。这些子列可以独立访问,从而最小化不必要的 I/O。请注意,当查询具有多种类型的列时,其值仍以单个列式响应返回。 -此外,通过利用偏移量,ClickHouse 确保这些子列保持稠密,没有为缺失的 JSON 路径存储默认值。该方法最大化了压缩,并进一步减少了 I/O。 +此外,通过利用偏移量,ClickHouse 确保这些子列保持稠密,不会为缺失的 JSON 路径存储默认值。这种方法最大程度地提高了压缩并进一步降低了 I/O。 - + -然而,在具有高基数或高度可变 JSON 结构的场景中——例如遥测管道、日志或机器学习特征存储——这种行为可能导致列文件的爆炸。每个新的唯一 JSON 路径都会导致生成一个新的列文件,每个路径下的每个类型变体都会导致生成一个额外的列文件。虽然这对读取性能是最优的,但带来了操作挑战:文件描述符耗尽、内存使用量增加和由于小文件数量较多而导致的合并变慢。 +然而,在具有高基数或高度可变 JSON 结构的场景中,例如遥测管道、日志或机器学习特征存储,可能会导致列文件的爆炸。每一个新的唯一 JSON 路径都会导致一个新的列文件,每个路径下的每种类型变体都导致额外的列文件。尽管这对读取性能是最佳的,但它引入了操作上的挑战:文件描述符耗尽、内存使用增加和由于小文件过多导致的合并速度减慢。 -为了解决这个问题,ClickHouse 引入了溢出子列的概念:一旦不同 JSON 路径的数量超过阈值,额外的路径将以紧凑编码格式存储在一个共享文件中。尽管该文件仍可查询,但其性能特性不如专用子列。 +为了解决此问题,ClickHouse 引入了溢出子列的概念:一旦不同的 JSON 路径数超过阈值,额外路径将以紧凑编码格式存储在一个共享文件中。这个文件仍然可以查询,但不具备与专用子列相同的性能特征。 - + 此阈值由 JSON 类型声明中的 [`max_dynamic_paths`](/sql-reference/data-types/newjson#reaching-the-limit-of-dynamic-paths-inside-json) 参数控制。 @@ -965,6 +959,6 @@ ENGINE = MergeTree ORDER BY tuple(); ``` -**避免将此参数设置得过高** - 大值会增加资源消耗并降低效率。一般经验是,保持在 10,000 以下。对于具有高度动态结构的工作负载,使用类型提示和 `SKIP` 参数限制存储的内容。 +**避免将此参数设置得过高** - 较大的值会增加资源消耗并降低效率。作为经验法则,应将其保持在 10,000 以下。对于具有高度动态结构的工作负载,使用类型提示和 `SKIP` 参数来限制存储内容。 -对于好奇有关这种新列类型实现的用户,我们建议阅读我们的详细博客文章 ["ClickHouse 的一种新的强大 JSON 数据类型"](https://clickhouse.com/blog/a-new-powerful-json-data-type-for-clickhouse)。 +对于对这种新列类型的实现感兴趣的用户,我们建议阅读我们的详细博客文章 ["ClickHouse 的新强大 JSON 数据类型"](https://clickhouse.com/blog/a-new-powerful-json-data-type-for-clickhouse)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/json/schema.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/json/schema.md.hash index 13364d46d53..743f7cf7de2 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/json/schema.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/json/schema.md.hash @@ -1 +1 @@ -6bf43ff793ca6a0a +c0f48a0a9e4b9a52 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/parquet.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/parquet.md index 4f125b405c4..40881bcaa6a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/parquet.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/parquet.md @@ -4,30 +4,31 @@ 'slug': '/integrations/data-formats/parquet' 'title': '在 ClickHouse 中使用 Parquet' 'description': '页面描述如何在 ClickHouse 中使用 Parquet' +'doc_type': 'guide' --- -# 在 ClickHouse 中使用 Parquet +# 在 ClickHouse 中处理 Parquet -Parquet 是一种高效的文件格式,以列式方式存储数据。 +Parquet 是一种高效的文件格式,可以以列式方式存储数据。 ClickHouse 支持读取和写入 Parquet 文件。 :::tip -在查询中引用文件路径时,ClickHouse 尝试读取的位置将取决于您使用的 ClickHouse 变种。 +在查询中引用文件路径时,ClickHouse 尝试读取的路径将取决于您使用的 ClickHouse 变体。 -如果您正在使用 [`clickhouse-local`](/operations/utilities/clickhouse-local.md),它将从您启动 ClickHouse Local 所在位置的相对路径读取。 -如果您通过 `clickhouse client` 使用 ClickHouse Server 或 ClickHouse Cloud,它将从服务器上 `/var/lib/clickhouse/user_files/` 目录的相对路径读取。 +如果您使用的是 [`clickhouse-local`](/operations/utilities/clickhouse-local.md),则它将从您启动 ClickHouse Local 的位置相对路径读取。 +如果您通过 `clickhouse client` 使用 ClickHouse Server 或 ClickHouse Cloud,则它将相对于服务器上的 `/var/lib/clickhouse/user_files/` 目录读取。 ::: -## 从 Parquet 导入数据 {#importing-from-parquet} +## 从 Parquet 导入 {#importing-from-parquet} -在加载数据之前,我们可以使用 [file()](/sql-reference/functions/files.md/#file) 函数探索一个 [示例 Parquet 文件](assets/data.parquet) 的结构: +在加载数据之前,我们可以使用 [file()](/sql-reference/functions/files.md/#file) 函数来探索一个 [示例 parquet 文件](assets/data.parquet) 的结构: ```sql DESCRIBE TABLE file('data.parquet', Parquet); ``` -我们将 [Parquet](/interfaces/formats.md/#data-format-parquet) 作为第二个参数使用,因此 ClickHouse 知道文件格式。这将打印出带有类型的列: +我们将 [Parquet](/interfaces/formats.md/#data-format-parquet) 用作第二个参数,这样 ClickHouse 就知道文件格式。这将打印出带有类型的列: ```response ┌─name─┬─type─────────────┬─default_type─┬─default_expression─┬─comment─┬─codec_expression─┬─ttl_expression─┐ @@ -37,7 +38,7 @@ DESCRIBE TABLE file('data.parquet', Parquet); └──────┴──────────────────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┘ ``` -我们还可以在实际导入数据之前使用 SQL 的所有功能来探索文件: +我们还可以在实际导入数据之前,使用 SQL 的全部功能来探索文件: ```sql SELECT * @@ -57,9 +58,9 @@ LIMIT 3; 在这种情况下,ClickHouse 将根据文件扩展名自动检测格式。 ::: -## 导入到现有表中 {#importing-to-an-existing-table} +## 导入到现有表 {#importing-to-an-existing-table} -让我们创建一个表,以便将 Parquet 数据导入其中: +让我们创建一个表,以便我们可以导入 Parquet 数据: ```sql CREATE TABLE sometable @@ -72,7 +73,7 @@ ENGINE = MergeTree ORDER BY (date, path); ``` -现在我们可以使用 `FROM INFILE` 子句导入数据: +现在,我们可以使用 `FROM INFILE` 子句导入数据: ```sql INSERT INTO sometable @@ -92,11 +93,11 @@ LIMIT 5; └───────────────────────────────┴────────────┴──────┘ ``` -请注意,ClickHouse 自动将 Parquet 字符串(在 `date` 列中)转换为 `Date` 类型。这是因为 ClickHouse 会根据目标表中的类型自动进行类型转换。 +注意 ClickHouse 自动将 Parquet 字符串(在 `date` 列中)转换为 `Date` 类型。这是因为 ClickHouse 基于目标表中的类型自动进行类型转换。 ## 将本地文件插入到远程服务器 {#inserting-a-local-file-to-remote-server} -如果您想将本地的 Parquet 文件插入到远程 ClickHouse 服务器,可以通过将文件内容传送到 `clickhouse-client` 来实现,如下所示: +如果您想将本地 Parquet 文件插入到远程 ClickHouse 服务器,可以通过将文件内容发送到 `clickhouse-client` 来实现,如下所示: ```sql clickhouse client -q "INSERT INTO sometable FORMAT Parquet" < data.parquet @@ -104,7 +105,7 @@ clickhouse client -q "INSERT INTO sometable FORMAT Parquet" < data.parquet ## 从 Parquet 文件创建新表 {#creating-new-tables-from-parquet-files} -由于 ClickHouse 可以读取 Parquet 文件模式,我们可以即时创建表: +由于 ClickHouse 可以读取 Parquet 文件架构,我们可以动态创建表: ```sql CREATE TABLE imported_from_parquet @@ -114,7 +115,7 @@ SELECT * FROM file('data.parquet', Parquet) ``` -这将从给定的 Parquet 文件自动创建并填充表: +这将根据给定的 parquet 文件自动创建并填充一个表: ```sql DESCRIBE TABLE imported_from_parquet; @@ -127,15 +128,15 @@ DESCRIBE TABLE imported_from_parquet; └──────┴──────────────────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┘ ``` -默认情况下,ClickHouse 对列名、类型和数值很严格。但是,有时我们可以在导入过程中跳过不存在的列或不支持的值。这可以通过 [Parquet 设置](/interfaces/formats/Parquet#format-settings) 来管理。 +默认情况下,ClickHouse 对列名称、类型和数值非常严格。但有时,我们可以在导入过程中跳过不存在的列或不支持的值。这可以通过 [Parquet 设置](/interfaces/formats/Parquet#format-settings) 来管理。 ## 导出为 Parquet 格式 {#exporting-to-parquet-format} :::tip -在使用 ClickHouse Cloud 的 `INTO OUTFILE` 时,您需要在将写入文件的机器上运行 `clickhouse client` 中的命令。 +使用 ClickHouse Cloud 的 `INTO OUTFILE` 时,您需要在将要写入文件的机器上以 `clickhouse client` 运行命令。 ::: -要将任何表或查询结果导出到 Parquet 文件,可以使用 `INTO OUTFILE` 子句: +要将任何表或查询结果导出到 Parquet 文件,我们可以使用 `INTO OUTFILE` 子句: ```sql SELECT * @@ -146,8 +147,8 @@ FORMAT Parquet 这将在工作目录中创建 `export.parquet` 文件。 -## ClickHouse 与 Parquet 数据类型 {#clickhouse-and-parquet-data-types} -ClickHouse 与 Parquet 数据类型大致相同,但仍然 [有一些差异](/interfaces/formats/Parquet#data-types-matching-parquet)。例如,ClickHouse 将 `DateTime` 类型导出为 Parquet 的 `int64`。如果我们再将其导入到 ClickHouse 中,我们将看到数字([time.parquet 文件](assets/time.parquet)): +## ClickHouse 和 Parquet 数据类型 {#clickhouse-and-parquet-data-types} +ClickHouse 和 Parquet 数据类型大致相同,但仍然有一些 [细微差别](/interfaces/formats/Parquet#data-types-matching-parquet)。例如,ClickHouse 将 `DateTime` 类型导出为 Parquet 的 `int64`。如果我们将其重新导入到 ClickHouse 中,将会看到数字([time.parquet 文件](assets/time.parquet)): ```sql SELECT * FROM file('time.parquet', Parquet); @@ -180,10 +181,9 @@ FROM file('time.parquet', Parquet); └───┴─────────────────────┘ ``` - ## 深入阅读 {#further-reading} -ClickHouse 引入对多种格式的支持,包括文本和二进制,以覆盖各种场景和平台。在以下文章中探索更多格式及其使用方式: +ClickHouse 引入了对多种格式的支持,包括文本和二进制,以覆盖各种场景和平台。可以在以下文章中探索更多格式及其处理方式: - [CSV 和 TSV 格式](csv-tsv.md) - [Avro、Arrow 和 ORC](arrow-avro-orc.md) @@ -192,4 +192,4 @@ ClickHouse 引入对多种格式的支持,包括文本和二进制,以覆盖 - [原生和二进制格式](binary.md) - [SQL 格式](sql.md) -同时也可以查看 [clickhouse-local](https://clickhouse.com/blog/extracting-converting-querying-local-files-with-sql-clickhouse-local) - 一个可移植的全功能工具,无需 ClickHouse 服务器即可处理本地/远程文件。 +还可以查看 [clickhouse-local](https://clickhouse.com/blog/extracting-converting-querying-local-files-with-sql-clickhouse-local) - 一个便携式功能齐全的工具,可以在无需 Clickhouse 服务器的情况下处理本地/远程文件。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/parquet.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/parquet.md.hash index d885e816e6e..4cf3315ea3a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/parquet.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/parquet.md.hash @@ -1 +1 @@ -bfc300c6d7308d21 +cc6b715e4287807c diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/sql.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/sql.md index d0fd877379b..dd757a3f83b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/sql.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/sql.md @@ -2,7 +2,8 @@ 'sidebar_label': 'SQL 转储' 'slug': '/integrations/data-formats/sql' 'title': '在 ClickHouse 中插入和转储 SQL 数据' -'description': '页面描述如何使用 SQL 转储在其他 DATABASE 和 ClickHouse 之间传输数据。' +'description': '页面描述了如何使用 SQL 转储在其他 DATABASE 和 ClickHouse 之间传输数据。' +'doc_type': 'guide' --- @@ -21,7 +22,7 @@ INTO OUTFILE 'dump.sql' FORMAT SQLInsert ``` -通过禁用 [`output_format_sql_insert_include_column_names`](/operations/settings/settings-formats.md/#output_format_sql_insert_include_column_names) 选项可以省略列名: +可以通过禁用 [`output_format_sql_insert_include_column_names`](/operations/settings/settings-formats.md/#output_format_sql_insert_include_column_names) 选项来省略列名称: ```sql SET output_format_sql_insert_include_column_names = 0 @@ -35,7 +36,7 @@ mysql some_db < dump.sql 我们假设 `some_table` 表存在于 `some_db` MySQL 数据库中。 -某些 DBMS 可能限制在单个批次中可以处理多少值。默认情况下,ClickHouse 将创建 65k 值的批次,但可以通过 [`output_format_sql_insert_max_batch_size`](/operations/settings/settings-formats.md/#output_format_sql_insert_max_batch_size) 选项进行更改: +某些数据库管理系统可能限制单个批处理可以处理的值的数量。默认情况下,ClickHouse 将创建 65k 值的批处理,但可以使用 [`output_format_sql_insert_max_batch_size`](/operations/settings/settings-formats.md/#output_format_sql_insert_max_batch_size) 选项进行更改: ```sql SET output_format_sql_insert_max_batch_size = 1000; @@ -43,7 +44,7 @@ SET output_format_sql_insert_max_batch_size = 1000; ### 导出一组值 {#exporting-a-set-of-values} -ClickHouse 有 [Values](/interfaces/formats.md/#data-format-values) 格式,它类似于 SQLInsert,但省略了 `INSERT INTO table VALUES` 部分,并仅返回一组值: +ClickHouse 具有 [Values](/interfaces/formats.md/#data-format-values) 格式,该格式类似于 SQLInsert,但省略了 `INSERT INTO table VALUES` 部分,仅返回一组值: ```sql SELECT * FROM some_data LIMIT 3 FORMAT Values @@ -71,7 +72,7 @@ LIMIT 5 └────────────────────────────────┴────────────┴──────┘ ``` -默认情况下,ClickHouse 将跳过未知列(由 [input_format_skip_unknown_fields](/operations/settings/settings-formats.md/#input_format_skip_unknown_fields) 选项控制)并处理转储中第一个找到的表的数据(如果多个表被转储到一个文件中)。DDL 语句将被跳过。要将数据从 MySQL 转储加载到表中([mysql.sql](assets/mysql.sql) 文件): +默认情况下,ClickHouse 将跳过未知列(通过 [input_format_skip_unknown_fields](/operations/settings/settings-formats.md/#input_format_skip_unknown_fields) 选项控制),并处理转储中第一个找到的表的数据(如果多个表转储到单个文件中)。DDL 语句将被跳过。要将数据从 MySQL 转储加载到表中([mysql.sql](assets/mysql.sql) 文件): ```sql INSERT INTO some_data @@ -88,7 +89,7 @@ SELECT * FROM file('mysql.sql', MySQLDump) ``` -在这里,我们根据 ClickHouse 自动推测的结构创建了一个名为 `table_from_mysql` 的表。ClickHouse 会根据数据检测类型或在可用时使用 DDL: +在这里,我们创建了一个名为 `table_from_mysql` 的表,基于 ClickHouse 自动推断的结构。ClickHouse 根据数据检测类型或在可用时使用 DDL: ```sql DESCRIBE TABLE table_from_mysql; @@ -103,13 +104,13 @@ DESCRIBE TABLE table_from_mysql; ## 其他格式 {#other-formats} -ClickHouse 支持多种文本和二进制格式,以涵盖各种场景和平台。请在以下文章中探索更多格式及其使用方法: +ClickHouse 引入了对多种格式的支持,包括文本和二进制格式,以覆盖各种场景和平台。在以下文章中探索更多格式及其使用方法: - [CSV 和 TSV 格式](csv-tsv.md) - [Parquet](parquet.md) - [JSON 格式](/integrations/data-ingestion/data-formats/json/intro.md) - [正则表达式和模板](templates-regex.md) -- [本地和二进制格式](binary.md) +- [原生和二进制格式](binary.md) - **SQL 格式** -同时查看 [clickhouse-local](https://clickhouse.com/blog/extracting-converting-querying-local-files-with-sql-clickhouse-local) - 一款便携式的全功能工具,可在无需 ClickHouse 服务器的情况下处理本地/远程文件。 +同时查看 [clickhouse-local](https://clickhouse.com/blog/extracting-converting-querying-local-files-with-sql-clickhouse-local) - 一款便携式功能齐全的工具,可在本地/远程文件上操作,无需 ClickHouse 服务器。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/sql.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/sql.md.hash index e2b28e88258..80a9aecf74f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/sql.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/sql.md.hash @@ -1 +1 @@ -5bb96b0e6121247f +dabaaa6f18b7b029 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/templates-regex.md b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/templates-regex.md index 8a623228c97..b1f1d20691e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/templates-regex.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/integrations/data-ingestion/data-formats/templates-regex.md @@ -2,16 +2,17 @@ 'sidebar_label': '正则表达式和模板' 'sidebar_position': 3 'slug': '/integrations/data-formats/templates-regexp' -'title': '在 ClickHouse 中使用模板和正则表达式导入和导出自定义文本数据' -'description': '页面描述了如何在 ClickHouse 中使用模板和正则表达式导入和导出自定义文本' +'title': '使用模板和正则表达式在 ClickHouse 中导入和导出自定义文本数据' +'description': '页面描述如何使用模板和正则表达式在 ClickHouse 中导入和导出自定义文本' +'doc_type': 'guide' --- # 使用模板和正则表达式在 ClickHouse 中导入和导出自定义文本数据 -我们经常需要处理自定义文本格式的数据。这可能是非标准格式、无效 JSON 或损坏的 CSV。使用像 CSV 或 JSON 这样的标准解析器在所有情况下都无法正常工作。但是,ClickHouse 为我们提供了强大的模板和正则表达式格式。 +我们经常需要处理自定义文本格式的数据。这可能是非标准格式,无效的 JSON,或者损坏的 CSV。使用标准解析器如 CSV 或 JSON 在所有这些情况下都无法正常工作。但 ClickHouse 提供了强大的模板和正则表达式格式来满足我们的需求。 -## 基于模板的导入 {#importing-based-on-a-template} +## 基于模板导入 {#importing-based-on-a-template} 假设我们想从以下 [日志文件](assets/error.log) 导入数据: ```bash @@ -24,7 +25,7 @@ head error.log 2023/01/16 05:34:55 [error] client: 9.9.7.6, server: example.com "GET /h5/static/cert/icon_yanzhengma.png HTTP/1.1" ``` -我们可以使用 [Template](/interfaces/formats.md/#format-template) 格式来导入这些数据。我们必须定义一个模板字符串,其中包含每行输入数据的值占位符: +我们可以使用 [模板](/interfaces/formats.md/#format-template) 格式导入这些数据。我们需要定义一个带有每行输入数据值占位符的模板字符串: ```response
uJ67E2Nfzg>|PLI@3thZ?ovfl#$JH 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

-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 Zdl{A@R1O&x{|5ib-cr1oA#L#N{{fwzpwR#T diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/images/mysql1.png b/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/images/mysql1.png deleted file mode 100644 index 3236999facaf6995b0db0d12ac7433eb07b3346a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 134935 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

7acxcu%{|B&;1E}k1KvQ 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 D_JRaB diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/images/mysql2.png b/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/images/mysql2.png deleted file mode 100644 index 3a3dca24009984b437d2029c0d39678776215f78..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 220612 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

;|KI=dG-j0eY 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®}>d)xCf{mRy^EV7-%$1ILz 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

;|KI=dG-j0eY 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®}>d)xCf{mRy^EV7-%$1ILz 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

ymmc?G0#3M59UMy@WQ({ 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%0DF+yQiHQIm0EFCaMMg_wPrGdXA%^tIz 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%0Dcw~@^oLB=;1 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 ZQ#syzy5um=d>#1D_?*Qbg=bvv{2wCdiV6S# diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/jdbc.md b/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/jdbc.md index e7316c138e0..033b497620f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/jdbc.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/jdbc.md @@ -1,12 +1,13 @@ --- -'description': '连接到 ClickHouse 的 Java 应用程序使用 JDBC 驱动程序的指南' +'description': '用于从 Java 应用程序连接到 ClickHouse 的 JDBC 驱动程序指南' 'sidebar_label': 'JDBC 驱动程序' 'sidebar_position': 20 'slug': '/interfaces/jdbc' 'title': 'JDBC 驱动程序' +'doc_type': 'guide' --- # JDBC 驱动程序 -使用 [官方 JDBC 驱动程序](/docs/integrations/language-clients/java/jdbc)(以及 Java 客户端)从您的 Java 应用程序访问 ClickHouse。 +使用 [官方 JDBC 驱动程序](/docs/integrations/language-clients/java/jdbc) (以及 Java 客户端)从您的 Java 应用程序访问 ClickHouse。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/jdbc.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/jdbc.md.hash index 462e887c17a..66bf9d8c6bd 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/jdbc.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/jdbc.md.hash @@ -1 +1 @@ -9bea386e71fef821 +987a06b38ef6984f diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/mysql.md b/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/mysql.md index e1bcfea6c48..c7914ec3c97 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/mysql.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/mysql.md @@ -4,6 +4,7 @@ 'sidebar_position': 25 'slug': '/interfaces/mysql' 'title': 'MySQL 接口' +'doc_type': 'guide' --- import Image from '@theme/IdealImage'; @@ -15,83 +16,83 @@ import mysql3 from '@site/static/images/interfaces/mysql3.png'; # MySQL 接口 -ClickHouse 支持 MySQL 网络协议。这使得某些没有原生 ClickHouse 连接器的客户端能够利用 MySQL 协议,同时它已被与以下 BI 工具验证: +ClickHouse 支持 MySQL 线协议。这使得某些没有原生 ClickHouse 连接器的客户端可以利用 MySQL 协议,该协议已与以下 BI 工具进行验证: - [Looker Studio](../integrations/data-visualization/looker-studio-and-clickhouse.md) - [Tableau Online](../integrations/tableau-online) - [QuickSight](../integrations/quicksight) -如果您尝试其他未经测试的客户端或集成,请注意可能存在以下限制: +如果您正在尝试其他未测试的客户端或集成,请注意可能存在以下限制: -- SSL 实现可能不完全兼容;可能会出现潜在的 [TLS SNI](https://www.cloudflare.com/learning/ssl/what-is-sni/) 问题。 -- 某些工具可能需要尚未实现的方言特性(例如,特定于 MySQL 的函数或设置)。 +- SSL 实现可能不完全兼容;可能存在潜在的 [TLS SNI](https://www.cloudflare.com/learning/ssl/what-is-sni/) 问题。 +- 特定工具可能需要尚未实现的方言特性(例如,特定于 MySQL 的函数或设置)。 -如果有可用的原生驱动程序(例如, [DBeaver](../integrations/dbeaver)),建议使用它而不是 MySQL 接口。此外,虽然大多数 MySQL 语言客户端应该可以正常工作,但 MySQL 接口并不能保证能直接替代已有 MySQL 查询的代码库。 +如果有原生驱动程序可用(例如, [DBeaver](../integrations/dbeaver)),建议使用它而不是 MySQL 接口。此外,虽然大多数 MySQL 语言客户端应该能够正常工作,但 MySQL 接口并不能保证可以直接替代已有 MySQL 查询的代码库。 -如果您的用例涉及某个没有原生 ClickHouse 驱动程序的特定工具,并且您希望通过 MySQL 接口使用它,并且发现某些不兼容性 - 请在 ClickHouse 仓库中 [创建一个问题](https://github.com/ClickHouse/ClickHouse/issues)。 +如果您的用例涉及没有原生 ClickHouse 驱动程序的特定工具,并且您希望通过 MySQL 接口使用它,并且发现某些不兼容的问题 - 请在 ClickHouse 仓库中 [创建一个问题](https://github.com/ClickHouse/ClickHouse/issues)。 ::::note -为了更好地支持上述 BI 工具的 SQL 方言,ClickHouse 的 MySQL 接口隐式地使用设置 [prefer_column_name_to_alias = 1](/operations/settings/settings#prefer_column_name_to_alias) 来运行 SELECT 查询。 -这无法关闭,在极少数边缘情况下,发送到 ClickHouse 的正常和 MySQL 查询接口的查询可能会表现出不同的行为。 +为了更好地支持上述 BI 工具的 SQL 方言,ClickHouse 的 MySQL 接口隐式地运行使用设置 [prefer_column_name_to_alias = 1](/operations/settings/settings#prefer_column_name_to_alias) 的 SELECT 查询。 +这不能关闭,并且在极少数边缘情况下,可能导致发送到 ClickHouse 的普通查询接口和 MySQL 查询接口之间的行为不同。 :::: ## 在 ClickHouse Cloud 上启用 MySQL 接口 {#enabling-the-mysql-interface-on-clickhouse-cloud} -1. 创建 ClickHouse Cloud 服务后,单击 `Connect` 按钮。 +1. 创建 ClickHouse Cloud 服务后,点击 `Connect` 按钮。
- + -2. 将 `Connect with` 下拉菜单更改为 `MySQL`。 +2. 将 `Connect with` 下拉菜单更改为 `MySQL`。
- + -3. 切换开关以启用此特定服务的 MySQL 接口。这将为该服务暴露端口 `3306` 并提示您显示包含您唯一 MySQL 用户名的 MySQL 连接屏幕。密码将与服务的默认用户密码相同。 +3. 切换开关以启用此特定服务的 MySQL 接口。这将为该服务开放端口 `3306`,并提示您查看包含您唯一 MySQL 用户名的 MySQL 连接屏幕。密码将与服务的默认用户密码相同。
- + 复制显示的 MySQL 连接字符串。 - + ## 在 ClickHouse Cloud 中创建多个 MySQL 用户 {#creating-multiple-mysql-users-in-clickhouse-cloud} -默认情况下,有一个内置的 `mysql4` 用户,其密码与 `default` 用户相同。`` 部分是您 ClickHouse Cloud 主机名的第一个段。这种格式对于与实现安全连接但不提供 [SNI 信息](https://www.cloudflare.com/learning/ssl/what-is-sni) 的工具使用是必要的,这使得在没有额外提示在用户名中的情况下进行内部路由变得不可能(MySQL 控制台客户端就是其中一种工具)。 +默认情况下,存在一个内置的 `mysql4` 用户,其密码与 `default` 用户相同。`` 部分是您 ClickHouse Cloud 主机名的第一个部分。此格式对于实现安全连接的工具是必要的,但这些工具在其 TLS 握手中并未提供 [SNI 信息](https://www.cloudflare.com/learning/ssl/what-is-sni),这使得在没有用户名中的额外提示的情况下无法进行内部路由(MySQL 控制台客户端就是其中一种工具)。 -因此,我们 _强烈建议_ 在创建打算与 MySQL 接口一起使用的新用户时遵循 `mysql4_` 格式,其中 `` 是用来标识您的云服务的提示,而 `` 是您选择的任意后缀。 +因此,我们 _强烈推荐_ 在创建新用户时遵循 `mysql4_` 格式,此处 `` 是识别您的 Cloud 服务的提示,`` 是您选择的任意后缀。 :::tip -对于 ClickHouse Cloud 主机名为 `foobar.us-east1.aws.clickhouse.cloud`,`` 部分等于 `foobar`,自定义 MySQL 用户名可能看起来像 `mysql4foobar_team1`。 +对于 ClickHouse Cloud 主机名为 `foobar.us-east1.aws.clickhouse.cloud` 的情况,`` 部分等于 `foobar`,一个自定义 MySQL 用户名可以为 `mysql4foobar_team1`。 ::: -您可以创建额外的用户与 MySQL 接口一起使用,例如,如果您需要应用额外的设置。 +如果您需要应用额外设置,可以创建额外用户以供 MySQL 接口使用。 -1. 可选 - 创建一个适用于您自定义用户的 [设置配置文件](/sql-reference/statements/create/settings-profile)。例如,创建名为 `my_custom_profile` 的额外设置,该设置在与我们稍后创建的用户连接时默认应用: +1. 可选 - 创建一个 [设置配置文件](/sql-reference/statements/create/settings-profile) 以应用于您的自定义用户。例如,`my_custom_profile` 带有额外设置,当我们连接后面创建的用户时,默认应用: ```sql CREATE SETTINGS PROFILE my_custom_profile SETTINGS prefer_column_name_to_alias=1; ``` - `prefer_column_name_to_alias` 仅作为示例,您可以在其中使用其他设置。 -2. [创建用户](/sql-reference/statements/create/user),使用以下格式: `mysql4_`([见上文](#creating-multiple-mysql-users-in-clickhouse-cloud))。密码必须为双 SHA1 格式。例如: + `prefer_column_name_to_alias` 仅用作示例,您可以在此使用其他设置。 +2. [创建用户](/sql-reference/statements/create/user) ,使用以下格式:`mysql4_` ([参见上面](#creating-multiple-mysql-users-in-clickhouse-cloud))。密码必须采用双 SHA1 格式。例如: ```sql CREATE USER mysql4foobar_team1 IDENTIFIED WITH double_sha1_password BY 'YourPassword42$'; ``` - 或者如果您希望为该用户使用自定义配置文件: + 或者,如果您希望此用户使用自定义配置文件: ```sql CREATE USER mysql4foobar_team1 IDENTIFIED WITH double_sha1_password BY 'YourPassword42$' SETTINGS PROFILE 'my_custom_profile'; ``` 其中 `my_custom_profile` 是您之前创建的配置文件的名称。 -3. [授予](/sql-reference/statements/grant) 新用户必要的权限,以与所需的表或数据库进行交互。例如,若要仅授予对 `system.query_log` 的访问权限: +3. [授予](/sql-reference/statements/grant) 新用户与所需的表或数据库交互的必要权限。例如,如果您只想授予访问 `system.query_log` 的权限: ```sql GRANT SELECT ON system.query_log TO mysql4foobar_team1; @@ -99,19 +100,19 @@ GRANT SELECT ON system.query_log TO mysql4foobar_team1; 4. 使用创建的用户通过 MySQL 接口连接到您的 ClickHouse Cloud 服务。 -### 在 ClickHouse Cloud 中排除多个 MySQL 用户的问题 {#troubleshooting-multiple-mysql-users-in-clickhouse-cloud} +### 故障排除 ClickHouse Cloud 中的多个 MySQL 用户 {#troubleshooting-multiple-mysql-users-in-clickhouse-cloud} -如果您创建了一个新的 MySQL 用户,并且在通过 MySQL CLI 客户端连接时看到以下错误: +如果您创建了新的 MySQL 用户,并且在使用 MySQL CLI 客户端连接时看到以下错误: ```sql ERROR 2013 (HY000): Lost connection to MySQL server at 'reading authorization packet', system error: 54 ``` -在这种情况下,请确保用户名遵循 `mysql4_` 格式,如上所述([见上文](#creating-multiple-mysql-users-in-clickhouse-cloud))。 +在这种情况下,请确保用户名遵循 `mysql4_` 格式,如([上面](#creating-multiple-mysql-users-in-clickhouse-cloud))所述。 ## 在自管理 ClickHouse 上启用 MySQL 接口 {#enabling-the-mysql-interface-on-self-managed-clickhouse} -将 [mysql_port](../operations/server-configuration-parameters/settings.md#mysql_port) 设置添加到服务器的配置文件中。例如,您可以在 `config.d/` 目录中的新 XML 文件中定义端口 [文件夹](../operations/configuration-files): +将 [mysql_port](../operations/server-configuration-parameters/settings.md#mysql_port) 设置添加到服务器的配置文件中。例如,您可以在 `config.d/` [文件夹](../operations/configuration-files) 中定义一个新 XML 文件来指定端口: ```xml @@ -119,7 +120,7 @@ ERROR 2013 (HY000): Lost connection to MySQL server at 'reading authorization pa ``` -启动 ClickHouse 服务器并查找类似以下内容的日志消息,提及监听 MySQL 兼容协议: +启动您的 ClickHouse 服务器,并查找类似以下的日志消息,提到监听 MySQL 兼容协议: ```bash {} Application: Listening for MySQL compatibility protocol: 127.0.0.1:9004 @@ -127,7 +128,7 @@ ERROR 2013 (HY000): Lost connection to MySQL server at 'reading authorization pa ## 将 MySQL 连接到 ClickHouse {#connect-mysql-to-clickhouse} -以下命令演示如何将 MySQL 客户端 `mysql` 连接到 ClickHouse: +以下命令演示了如何将 MySQL 客户端 `mysql` 连接到 ClickHouse: ```bash mysql --protocol tcp -h [hostname] -u [username] -P [port_number] [database_name] @@ -139,7 +140,7 @@ mysql --protocol tcp -h [hostname] -u [username] -P [port_number] [database_name $ mysql --protocol tcp -h 127.0.0.1 -u default -P 9004 default ``` -如果连接成功,输出如下: +如果连接成功,输出将为: ```text Welcome to the MySQL monitor. Commands end with ; or \g. @@ -157,16 +158,16 @@ Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> ``` -为了与所有 MySQL 客户端兼容,建议在配置文件中指定用户密码为 [双 SHA1](/operations/settings/settings-users#user-namepassword) 格式。 -如果用户密码使用 [SHA256](/sql-reference/functions/hash-functions#sha1-sha224-sha256-sha512-sha512_256) 指定,则某些客户端将无法进行身份验证(如 mysqljs 和旧版本的命令行工具 MySQL 和 MariaDB)。 +为了与所有 MySQL 客户端兼容,建议在配置文件中使用 [双 SHA1](/operations/settings/settings-users#user-namepassword) 指定用户密码。 +如果用户密码使用 [SHA256](/sql-reference/functions/hash-functions#SHA256) 指定,则某些客户端将无法进行身份验证(mysqljs 和旧版本的命令行工具 MySQL 和 MariaDB)。 限制: -- 不支持准备好的查询 +- 不支持预处理查询 - 某些数据类型以字符串形式发送 -要取消长查询,请使用 `KILL QUERY connection_id` 语句(在处理中时将其替换为 `KILL QUERY WHERE query_id = connection_id`)。例如: +要取消长查询,请使用 `KILL QUERY connection_id` 语句(在执行时会替换为 `KILL QUERY WHERE query_id = connection_id`)。例如: ```bash $ mysql --protocol tcp -h mysql_server -P 9004 default -u default --password=123 -e "KILL QUERY 123456;" diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/mysql.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/mysql.md.hash index 4b06d3d7eef..a9b4b89ed6b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/mysql.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/mysql.md.hash @@ -1 +1 @@ -2ff02f3af3b4fc0e +33f15ba6fa2b202b diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/native-clients-interfaces-index.md b/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/native-clients-interfaces-index.md index cdc59a46788..26b543b344a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/native-clients-interfaces-index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/native-clients-interfaces-index.md @@ -1,5 +1,5 @@ --- -'description': '针对 ClickHouse 的本地客户端和接口' +'description': 'ClickHouse 的原生客户端和接口' 'keywords': - 'clients' - 'interfaces' @@ -7,18 +7,19 @@ - 'SQL console' - 'drivers' 'slug': '/interfaces/natives-clients-and-interfaces' -'title': '本地客户端和接口' +'title': '原生客户端和接口' +'doc_type': 'landing-page' --- -# 原生客户端和接口 +# 原生客户端与接口 -ClickHouse 提供多种原生客户端和接口,允许您连接到 ClickHouse。 +ClickHouse 提供多种不同的原生客户端和接口,允许您连接到 ClickHouse。 有关更多信息,请参见以下页面: -| 部分 | 摘要 | -|----------------------------------------------------------|-----------------------------------------------------------------------------------| -| [命令行客户端](/interfaces/cli) | 支持命令行选项和配置文件的原生命令行客户端。 | -| [驱动程序和接口](/interfaces/overview) | 多种网络接口、库和可视化接口。 | -| [SQL 控制台](/integrations/sql-clients/sql-console) | 在 ClickHouse Cloud 中与您的数据进行交互的一种快速便捷方式。 | +| 部分 | 摘要 | +|--------------------------------------------------------------|--------------------------------------------------------------------------------------| +| [命令行客户端](/interfaces/cli) | 支持命令行选项和配置文件的原生命令行客户端。 | +| [驱动程序与接口](/interfaces/overview) | 多种网络接口、库和可视化接口。 | +| [SQL 控制台](/integrations/sql-clients/sql-console) | 在 ClickHouse Cloud 中与您的数据交互的快速便捷方式。 | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/native-clients-interfaces-index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/native-clients-interfaces-index.md.hash index bd590904084..cbed9acd37b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/native-clients-interfaces-index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/native-clients-interfaces-index.md.hash @@ -1 +1 @@ -9cf74e67c5acfe54 +36d5e47aa4e2c7a6 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/odbc.md b/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/odbc.md index cfcad26deb2..22fff2dd85c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/odbc.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/odbc.md @@ -3,10 +3,11 @@ 'sidebar_label': 'ODBC Driver' 'sidebar_position': 35 'slug': '/interfaces/odbc' -'title': 'ODBC Driver' +'title': 'ODBC 驱动程序' +'doc_type': 'reference' --- -# ODBC 驱动程序 +# ODBC 驱动 -使用 [官方 ODBC 驱动程序](https://github.com/ClickHouse/clickhouse-odbc) 访问 ClickHouse 作为数据源。 +使用 [官方 ODBC 驱动](https://github.com/ClickHouse/clickhouse-odbc) 以将 ClickHouse 作为数据源进行访问。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/odbc.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/odbc.md.hash index 7a2d87a2ef5..523e59ebc12 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/odbc.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/odbc.md.hash @@ -1 +1 @@ -f3c99bca39e2b00c +7c7c16ad11c75470 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/overview.md b/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/overview.md index e62cf27d57f..ccfab9fed5c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/overview.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/overview.md @@ -1,5 +1,5 @@ --- -'description': '连接到 ClickHouse 的网络接口、驱动程序和工具的概述' +'description': '关于网络接口、驱动程序和连接到 ClickHouse 的工具的概述' 'keywords': - 'clickhouse' - 'network' @@ -15,16 +15,16 @@ 'sidebar_label': '概述' 'slug': '/interfaces/overview' 'title': '驱动程序和接口' +'doc_type': 'reference' --- # 驱动程序和接口 -ClickHouse 提供了三种网络接口(可以选择性地通过 TLS 进行封装以增加安全性): +ClickHouse 提供了两种网络接口(它们可以选择性地用 TLS 包装以增强安全性): -- [HTTP](http.md),文档完备且易于直接使用。 -- [Native TCP](../interfaces/tcp.md),开销更小。 -- [gRPC](grpc.md)。 +- [HTTP](http.md),文档详细且易于直接使用。 +- [Native TCP](../interfaces/tcp.md),开销较小。 在大多数情况下,建议使用适当的工具或库,而不是直接与这些接口交互。以下是 ClickHouse 官方支持的工具: @@ -33,13 +33,17 @@ ClickHouse 提供了三种网络接口(可以选择性地通过 TLS 进行封 - [ODBC 驱动程序](../interfaces/odbc.md) - [C++ 客户端库](../interfaces/cpp.md) -ClickHouse 服务器为高级用户提供了嵌入式可视化接口: +ClickHouse 还支持两种 RPC 协议: +- [gRPC 协议](grpc.md),专为 ClickHouse 设计。 +- [Apache Arrow Flight](arrowflight.md)。 + +ClickHouse 服务器提供了嵌入式可视化界面,以满足高级用户需求: - Play UI:在浏览器中打开 `/play`; - 高级仪表板:在浏览器中打开 `/dashboard`; - ClickHouse 工程师的二进制符号查看器:在浏览器中打开 `/binary`; -此外,还有多种第三方库可用于与 ClickHouse 进行交互: +此外,还有广泛的第三方库可用于与 ClickHouse 进行交互: - [客户端库](../interfaces/third-party/client-libraries.md) - [集成](../interfaces/third-party/integrations.md) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/overview.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/overview.md.hash index f1d868744ea..e48698ab0f8 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/overview.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/overview.md.hash @@ -1 +1 @@ -eece67c6f7df5a42 +fd061ac9a882bf13 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/postgresql.md b/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/postgresql.md index 400cfd83e02..1f4c3d1959c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/postgresql.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/postgresql.md @@ -4,12 +4,17 @@ 'sidebar_position': 20 'slug': '/interfaces/postgresql' 'title': 'PostgreSQL 接口' +'doc_type': 'reference' --- +import CloudNotSupportedBadge from '@theme/badges/CloudNotSupportedBadge'; + # PostgreSQL 接口 -ClickHouse 支持 PostgreSQL 线协议,这允许您使用 Postgres 客户端连接到 ClickHouse。从某种意义上说,ClickHouse 可以假装成为 PostgreSQL 实例 - 允许您连接一个 ClickHouse 尚未直接支持的 PostgreSQL 客户端应用程序(例如,Amazon Redshift)。 + + +ClickHouse 支持 PostgreSQL 线协议,这允许您使用 Postgres 客户端连接到 ClickHouse。在某种程度上,ClickHouse 可以假装是一个 PostgreSQL 实例 - 允许您连接到 ClickHouse 的 PostgreSQL 客户端应用程序,即那些 ClickHouse 尚未直接支持的客户端(例如,Amazon Redshift)。 要启用 PostgreSQL 线协议,请将 [postgresql_port](../operations/server-configuration-parameters/settings.md#postgresql_port) 设置添加到您的服务器配置文件中。例如,您可以在 `config.d` 文件夹中定义一个新的 XML 文件来指定端口: @@ -19,13 +24,13 @@ ClickHouse 支持 PostgreSQL 线协议,这允许您使用 Postgres 客户端 ``` -启动您的 ClickHouse 服务器,并查找类似于以下信息的日志消息,提到 **正在侦听 PostgreSQL 兼容协议**: +启动您的 ClickHouse 服务器并查找类似以下信息的日志消息,提到 **正在监听 PostgreSQL 兼容协议**: ```response {} Application: Listening for PostgreSQL compatibility protocol: 127.0.0.1:9005 ``` -## 将 psql 连接到 ClickHouse {#connect-psql-to-clickhouse} +## 连接 psql 到 ClickHouse {#connect-psql-to-clickhouse} 以下命令演示如何将 PostgreSQL 客户端 `psql` 连接到 ClickHouse: @@ -40,7 +45,7 @@ psql -p 9005 -h 127.0.0.1 -U alice default ``` :::note -`psql` 客户端需要使用密码登录,因此您将无法使用没有密码的 `default` 用户进行连接。请为 `default` 用户分配一个密码,或使用其他用户登录。 +`psql` 客户端需要使用密码登录,因此您将无法使用没有密码的 `default` 用户连接。请为 `default` 用户分配一个密码,或以其他用户身份登录。 ::: `psql` 客户端会提示输入密码: @@ -55,7 +60,7 @@ Type "help" for help. default=> ``` -就这样!您现在有一个连接到 ClickHouse 的 PostgreSQL 客户端,所有命令和查询都在 ClickHouse 上执行。 +就是这样!您现在有一个连接到 ClickHouse 的 PostgreSQL 客户端,所有命令和查询都将在 ClickHouse 上执行。 :::note PostgreSQL 协议目前仅支持明文密码。 @@ -63,9 +68,9 @@ PostgreSQL 协议目前仅支持明文密码。 ## 使用 SSL {#using-ssl} -如果您在 ClickHouse 实例上配置了 SSL/TLS,那么 `postgresql_port` 将使用相同的设置(该端口对安全和不安全的客户端是共享的)。 +如果您在 ClickHouse 实例上配置了 SSL/TLS,那么 `postgresql_port` 将使用相同的设置(此端口对于安全和不安全的客户端是共享的)。 -每个客户端都有自己使用 SSL 进行连接的方法。以下命令演示如何传入证书和密钥,以安全地将 `psql` 连接到 ClickHouse: +每个客户端都有自己使用 SSL 连接的方法。以下命令演示如何传递证书和密钥,以安全地将 `psql` 连接到 ClickHouse: ```bash psql "port=9005 host=127.0.0.1 user=alice dbname=default sslcert=/path/to/certificate.pem sslkey=/path/to/key.pem sslrootcert=/path/to/rootcert.pem sslmode=verify-ca" @@ -73,11 +78,11 @@ psql "port=9005 host=127.0.0.1 user=alice dbname=default sslcert=/path/to/certif ## 使用 SCRAM-SHA-256 配置 ClickHouse 用户身份验证 {#using-scram-sha256} -为了确保 ClickHouse 中的用户身份验证安全,建议使用 SCRAM-SHA-256 协议。通过在 users.xml 文件中指定 `password_scram_sha256_hex` 元素来配置用户。密码哈希必须使用 num_iterations=4096 生成。 +为了确保 ClickHouse 中安全的用户身份验证,建议使用 SCRAM-SHA-256 协议。通过在 users.xml 文件中指定 `password_scram_sha256_hex` 元素来配置用户。密码哈希必须使用 num_iterations=4096 生成。 -确保 psql 客户端支持并在连接时协商 SCRAM-SHA-256。 +确保 psql 客户端在连接期间支持并协商 SCRAM-SHA-256。 -用户 `user_with_sha256` 的示例配置,密码为 `abacaba`: +用户 `user_with_sha256` 使用密码 `abacaba` 的示例配置: ```xml @@ -85,4 +90,4 @@ psql "port=9005 host=127.0.0.1 user=alice dbname=default sslcert=/path/to/certif ``` -查看 [PostgreSQL 文档](https://jdbc.postgresql.org/documentation/head/ssl-client.html) 以获取更多有关其 SSL 设置的详细信息。 +查看 [PostgreSQL 文档](https://jdbc.postgresql.org/documentation/head/ssl-client.html) 以获取有关其 SSL 设置的更多详细信息。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/postgresql.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/postgresql.md.hash index b3f7eddd859..5264ba742ce 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/postgresql.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/postgresql.md.hash @@ -1 +1 @@ -e94eccaed6e51556 +d703bcaeef9f29c5 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/prometheus.md b/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/prometheus.md index 1a7de58acff..008d6616cde 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/prometheus.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/prometheus.md @@ -4,6 +4,7 @@ 'sidebar_position': 19 'slug': '/interfaces/prometheus' 'title': 'Prometheus 协议' +'doc_type': 'reference' --- @@ -12,10 +13,10 @@ ## 暴露指标 {#expose} :::note -如果您使用的是 ClickHouse Cloud,可以使用 [Prometheus Integration](/integrations/prometheus) 将指标暴露给 Prometheus。 +如果您正在使用 ClickHouse Cloud,您可以使用 [Prometheus Integration](/integrations/prometheus) 将指标暴露给 Prometheus。 ::: -ClickHouse 可以暴露其自身的指标以供 Prometheus 抓取: +ClickHouse 可以暴露其自身的指标供 Prometheus 抓取: ```xml @@ -25,6 +26,8 @@ ClickHouse 可以暴露其自身的指标以供 Prometheus 抓取: true true true + true + true Section `` can be used to make more extended handlers. @@ -42,6 +45,8 @@ This section is similar to [](/interfaces/http) but works for pro true true true + true + true @@ -50,15 +55,17 @@ This section is similar to [](/interfaces/http) but works for pro 设置: -| 名称 | 默认值 | 描述 | -|------------------------------|------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `port` | none | 用于提供暴露指标协议的端口。 | -| `endpoint` | `/metrics` | Prometheus 服务器抓取指标的 HTTP 端点。以 `/` 开头。与 `` 部分不应同时使用。 | -| `url` / `headers` / `method` | none | 用于查找请求的匹配处理程序的过滤器。类似于 [``](/interfaces/http) 部分中同名字段。 | -| `metrics` | true | 暴露来自 [system.metrics](/operations/system-tables/metrics) 表的指标。 | -| `asynchronous_metrics` | true | 暴露来自 [system.asynchronous_metrics](/operations/system-tables/asynchronous_metrics) 表的当前指标值。 | -| `events` | true | 暴露来自 [system.events](/operations/system-tables/events) 表的指标。 | -| `errors` | true | 暴露自上次服务器重启以来按错误代码发生的错误数量。此信息也可以从 [system.errors](/operations/system-tables/errors) 获取。 | +| 名称 | 默认值 | 描述 | +|------------------------------|------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `port` | none | 用于提供暴露指标协议的端口。 | +| `endpoint` | `/metrics` | Prometheus 服务器抓取指标的 HTTP 端点。以 `/` 开头。不得与 `` 部分一起使用。 | +| `url` / `headers` / `method` | none | 用于找到请求匹配处理程序的过滤器。与 [``](/interfaces/http) 部分中的同名字段类似。 | +| `metrics` | true | 从 [system.metrics](/operations/system-tables/metrics) 表中暴露指标。 | +| `asynchronous_metrics` | true | 从 [system.asynchronous_metrics](/operations/system-tables/asynchronous_metrics) 表中暴露当前指标值。 | +| `events` | true | 从 [system.events](/operations/system-tables/events) 表中暴露指标。 | +| `errors` | true | 暴露自上次服务器重启以来按错误代码发生的错误数量。该信息还可以从 [system.errors](/operations/system-tables/errors) 获取。 | +| `histograms` | true | 从 [system.histogram_metrics](/operations/system-tables/histogram_metrics) 暴露直方图指标 | +| `dimensional_metrics` | true | 从 [system.dimensional_metrics](/operations/system-tables/dimensional_metrics) 暴露维度指标 | 检查(将 `127.0.0.1` 替换为您的 ClickHouse 服务器的 IP 地址或主机名): ```bash @@ -68,7 +75,8 @@ curl 127.0.0.1:9363/metrics ## 远程写入协议 {#remote-write} ClickHouse 支持 [remote-write](https://prometheus.io/docs/specs/remote_write_spec/) 协议。 -数据通过此协议接收并写入一个 [TimeSeries](/engines/table-engines/special/time_series) 表(应事先创建)。 +通过该协议接收数据并写入 [TimeSeries](/engines/table-engines/special/time_series) 表 +(该表应提前创建)。 ```xml @@ -88,17 +96,17 @@ ClickHouse 支持 [remote-write](https://prometheus.io/docs/specs/remote_write_s 设置: -| 名称 | 默认值 | 描述 | -|------------------------------|---------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `port` | none | 用于提供 `remote-write` 协议的端口。 | -| `url` / `headers` / `method` | none | 用于查找请求的匹配处理程序的过滤器。类似于 [``](/interfaces/http) 部分中同名字段。 | -| `table` | none | 要写入通过 `remote-write` 协议接收的数据的 [TimeSeries](/engines/table-engines/special/time_series) 表的名称。此名称可以选择性地包含数据库的名称。 | -| `database` | none | 表的名称 `table` 设置指定的数据库名称,如果在 `table` 设置中未指定。 | +| 名称 | 默认值 | 描述 | +|------------------------------|------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `port` | none | 用于提供 `remote-write` 协议的端口。 | +| `url` / `headers` / `method` | none | 用于找到请求匹配处理程序的过滤器。与 [``](/interfaces/http) 部分中的同名字段类似。 | +| `table` | none | 要写入通过 `remote-write` 协议接收到的数据的 [TimeSeries](/engines/table-engines/special/time_series) 表的名称。该名称可以选择性地包含数据库名称。 | +| `database` | none | 如果在 `table` 设置中未指定,则指定 `table` 设置中所指表所在数据库的名称。 | ## 远程读取协议 {#remote-read} ClickHouse 支持 [remote-read](https://prometheus.io/docs/prometheus/latest/querying/remote_read_api/) 协议。 -数据从 [TimeSeries](/engines/table-engines/special/time_series) 表中读取,并通过此协议发送。 +从 [TimeSeries](/engines/table-engines/special/time_series) 表中读取数据并通过该协议发送。 ```xml @@ -118,16 +126,16 @@ ClickHouse 支持 [remote-read](https://prometheus.io/docs/prometheus/latest/que 设置: -| 名称 | 默认值 | 描述 | -|------------------------------|---------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `port` | none | 用于提供 `remote-read` 协议的端口。 | -| `url` / `headers` / `method` | none | 用于查找请求的匹配处理程序的过滤器。类似于 [``](/interfaces/http) 部分中同名字段。 | -| `table` | none | 要读取数据以通过 `remote-read` 协议发送的 [TimeSeries](/engines/table-engines/special/time_series) 表的名称。此名称可以选择性地包含数据库的名称。 | -| `database` | none | 表的名称 `table` 设置指定的数据库名称,如果在 `table` 设置中未指定。 | +| 名称 | 默认值 | 描述 | +|------------------------------|------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `port` | none | 用于提供 `remote-read` 协议的端口。 | +| `url` / `headers` / `method` | none | 用于找到请求匹配处理程序的过滤器。与 [``](/interfaces/http) 部分中的同名字段类似。 | +| `table` | none | 要读取并通过 `remote-read` 协议发送数据的 [TimeSeries](/engines/table-engines/special/time_series) 表的名称。该名称可以选择性地包含数据库名称。 | +| `database` | none | 如果在 `table` 设置中未指定,则指定 `table` 设置中所指表所在数据库的名称。 | ## 多协议配置 {#multiple-protocols} -多个协议可以在一个地方一起指定: +可以在一个地方一起指定多个协议: ```xml @@ -141,6 +149,8 @@ ClickHouse 支持 [remote-read](https://prometheus.io/docs/prometheus/latest/que true true true + true + true diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/prometheus.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/prometheus.md.hash index e08b19ce83c..1812c6cd1f5 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/prometheus.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/prometheus.md.hash @@ -1 +1 @@ -748e345bc20b0c77 +2caf3b5cd30deb1e diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/schema-inference.md b/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/schema-inference.md index 0d399c0fe27..9f614cf497b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/schema-inference.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/schema-inference.md @@ -1,21 +1,24 @@ --- -'description': '页面描述在 ClickHouse 中从输入数据自动推断模式' +'description': '页面描述了在 ClickHouse 中从输入数据自动推断模式' 'sidebar_label': '模式推断' 'slug': '/interfaces/schema-inference' 'title': '从输入数据自动推断模式' +'doc_type': 'reference' --- -ClickHouse可以在几乎所有支持的 [输入格式](formats.md) 中自动确定输入数据的结构。本文档将描述何时使用模式推断,它如何与不同的输入格式配合使用,以及可以控制它的哪些设置。 -## 使用方法 {#usage} +ClickHouse 可以在几乎所有支持的 [输入格式](formats.md) 中自动确定输入数据的结构。本文档将描述何时使用模式推断,它如何与不同的输入格式配合使用以及哪些设置可以控制它。 -当ClickHouse需要以特定的数据格式读取数据而结构未知时,会使用模式推断。 -## 表函数 [file](../sql-reference/table-functions/file.md), [s3](../sql-reference/table-functions/s3.md), [url](../sql-reference/table-functions/url.md), [hdfs](../sql-reference/table-functions/hdfs.md), [azureBlobStorage](../sql-reference/table-functions/azureBlobStorage.md)。 {#table-functions-file-s3-url-hdfs-azureblobstorage} +## 使用 {#usage} -这些表函数有一个可选参数 `structure`,用于输入数据的结构。如果未指定此参数或设置为 `auto`,则将根据数据推断结构。 +当 ClickHouse 需要以特定的数据格式读取数据而结构未知时,会使用模式推断。 + +## 表函数 [file](../sql-reference/table-functions/file.md), [s3](../sql-reference/table-functions/s3.md), [url](../sql-reference/table-functions/url.md), [hdfs](../sql-reference/table-functions/hdfs.md), [azureBlobStorage](../sql-reference/table-functions/azureBlobStorage.md) {#table-functions-file-s3-url-hdfs-azureblobstorage} + +这些表函数有一个可选参数 `structure`,用于输入数据的结构。如果未指定此参数或将其设置为 `auto`,则将根据数据推断结构。 **示例:** -假设我们在 `user_files` 目录中有一个 `hobbies.jsonl` 文件,格式为 JSONEachRow,内容如下: +假设我们有一个位于 `user_files` 目录中的 JSONEachRow 格式的文件 `hobbies.jsonl`,内容如下: ```json {"id" : 1, "age" : 25, "name" : "Josh", "hobbies" : ["football", "cooking", "music"]} {"id" : 2, "age" : 19, "name" : "Alan", "hobbies" : ["tennis", "art"]} @@ -23,7 +26,7 @@ ClickHouse可以在几乎所有支持的 [输入格式](formats.md) 中自动确 {"id" : 4, "age" : 47, "name" : "Brayan", "hobbies" : ["movies", "skydiving"]} ``` -ClickHouse可以在您未指定其结构的情况下读取此数据: +ClickHouse 可以在您未指定其结构的情况下读取这些数据: ```sql SELECT * FROM file('hobbies.jsonl') ``` @@ -50,13 +53,14 @@ DESCRIBE file('hobbies.jsonl') │ hobbies │ Array(Nullable(String)) │ │ │ │ │ │ └─────────┴─────────────────────────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┘ ``` -## 表引擎 [File](../engines/table-engines/special/file.md), [S3](../engines/table-engines/integrations/s3.md), [URL](../engines/table-engines/special/url.md), [HDFS](../engines/table-engines/integrations/hdfs.md), [azureBlobStorage](../engines/table-engines/integrations/azureBlobStorage.md) {#table-engines-file-s3-url-hdfs-azureblobstorage} -如果在 `CREATE TABLE` 查询中未指定列的列表,则表的结构将从数据中自动推断。 +## 表引擎 [File](../engines/table-engines/special/file.md), [S3](../engines/table-engines/integrations/s3.md), [URL](../engines/table-engines/special/url.md), [HDFS](../engines/table-engines/integrations/hdfs.md), [azureBlobStorage](../engines/table-engines/integrations/azureBlobStorage.md) {#table-engines-file-s3-url-hdfs-azureblobstorage} + +如果在 `CREATE TABLE` 查询中未指定列的列表,表的结构将从数据中自动推断。 **示例:** -让我们使用文件 `hobbies.jsonl`。我们可以使用文件中的数据创建一个引擎为 `File` 的表: +我们使用文件 `hobbies.jsonl`。我们可以使用这个文件中的数据创建一个引擎为 `File` 的表: ```sql CREATE TABLE hobbies ENGINE=File(JSONEachRow, 'hobbies.jsonl') ``` @@ -85,13 +89,14 @@ DESCRIBE TABLE hobbies │ hobbies │ Array(Nullable(String)) │ │ │ │ │ │ └─────────┴─────────────────────────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┘ ``` + ## clickhouse-local {#clickhouse-local} -`clickhouse-local` 有一个可选参数 `-S/--structure`,用于输入数据的结构。如果未指定此参数或设置为 `auto`,则将根据数据推断结构。 +`clickhouse-local` 有一个可选参数 `-S/--structure`,用于输入数据的结构。如果未指定此参数或将其设置为 `auto`,将从数据中推断结构。 **示例:** -让我们使用文件 `hobbies.jsonl`。我们可以使用 `clickhouse-local` 查询该文件中的数据: +我们使用文件 `hobbies.jsonl`。我们可以使用 `clickhouse-local` 查询此文件中的数据: ```shell clickhouse-local --file='hobbies.jsonl' --table='hobbies' --query='DESCRIBE TABLE hobbies' ``` @@ -110,18 +115,19 @@ clickhouse-local --file='hobbies.jsonl' --table='hobbies' --query='SELECT * FROM 3 32 Lana ['fitness','reading','shopping'] 4 47 Brayan ['movies','skydiving'] ``` -## 使用插入表的结构 {#using-structure-from-insertion-table} -当表函数 `file/s3/url/hdfs` 用于将数据插入表中时,可以选择使用插入表的结构,而不是从数据中提取。这可以提高插入性能,因为模式推断可能需要一些时间。此外,当表具有优化的结构时,它会很有用,因此不会在类型之间执行转换。 +## 从插入表使用结构 {#using-structure-from-insertion-table} + +当使用表函数 `file/s3/url/hdfs` 将数据插入表中时,可以选择使用插入表的结构,而不是从数据中提取它。这样可以提高插入性能,因为模式推断可能需要一些时间。此外,当表具有优化的模式时,这也会有所帮助,因此不会进行类型转换。 -有一个特殊的设置 [use_structure_from_insertion_table_in_table_functions](/operations/settings/settings.md/#use_structure_from_insertion_table_in_table_functions) 控制此行为。它有3种可能的值: +有一个特别设置 [use_structure_from_insertion_table_in_table_functions](/operations/settings/settings.md/#use_structure_from_insertion_table_in_table_functions) 控制此行为。它有 3 个可能的值: - 0 - 表函数将从数据中提取结构。 - 1 - 表函数将使用插入表的结构。 -- 2 - ClickHouse 将自动确定是否可以使用插入表的结构或使用模式推断。默认值。 +- 2 - ClickHouse 会自动确定是否可以使用插入表的结构或使用模式推断。默认值。 **示例 1:** -让我们以以下结构创建表 `hobbies1`: +让我们创建表 `hobbies1`,结构如下: ```sql CREATE TABLE hobbies1 ( @@ -134,17 +140,17 @@ ENGINE = MergeTree ORDER BY id; ``` -并从文件 `hobbies.jsonl` 中插入数据: +并从文件 `hobbies.jsonl` 插入数据: ```sql INSERT INTO hobbies1 SELECT * FROM file(hobbies.jsonl) ``` -在这种情况下,文件中的所有列都将插入到表中而不作更改,因此ClickHouse将使用插入表的结构,而不是模式推断。 +在这种情况下,文件中的所有列都直接插入到表中,因此 ClickHouse 将使用插入表的结构,而不是模式推断。 **示例 2:** -让我们以以下结构创建表 `hobbies2`: +让我们创建表 `hobbies2`,结构如下: ```sql CREATE TABLE hobbies2 ( @@ -156,17 +162,17 @@ CREATE TABLE hobbies2 ORDER BY id; ``` -并从文件 `hobbies.jsonl` 中插入数据: +并从文件 `hobbies.jsonl` 插入数据: ```sql INSERT INTO hobbies2 SELECT id, age, hobbies FROM file(hobbies.jsonl) ``` -在这种情况下,`SELECT` 查询中的所有列都存在于表中,因此ClickHouse将使用插入表的结构。注意,它只适用于支持读取子集列的输入格式,如 JSONEachRow、TSKV、Parquet 等(因此它不适用于 TSV 格式)。 +在这种情况下,`SELECT` 查询中的所有列都存在于表中,因此 ClickHouse 将使用插入表的结构。 请注意,这仅适用于支持读取部分列的输入格式,如 JSONEachRow、TSKV、Parquet 等(因此不会适用于 TSV 格式)。 **示例 3:** -让我们以以下结构创建表 `hobbies3`: +让我们创建表 `hobbies3`,结构如下: ```sql CREATE TABLE hobbies3 @@ -179,17 +185,17 @@ CREATE TABLE hobbies3 ORDER BY identifier; ``` -并从文件 `hobbies.jsonl` 中插入数据: +并从文件 `hobbies.jsonl` 插入数据: ```sql INSERT INTO hobbies3 SELECT id, age, hobbies FROM file(hobbies.jsonl) ``` -在这种情况下,列 `id` 在 `SELECT` 查询中使用,但表中没有此列(它有一个名为 `identifier` 的列),因此ClickHouse无法使用插入表的结构,将使用模式推断。 +在这种情况下,列 `id` 在 `SELECT` 查询中被使用,但表中没有此列(表中有一列名为 `identifier`),因此 ClickHouse 无法使用插入表的结构,模式推断将被使用。 **示例 4:** -让我们以以下结构创建表 `hobbies4`: +让我们创建表 `hobbies4`,结构如下: ```sql CREATE TABLE hobbies4 @@ -201,30 +207,31 @@ CREATE TABLE hobbies4 ORDER BY id; ``` -并从文件 `hobbies.jsonl` 中插入数据: +并从文件 `hobbies.jsonl` 插入数据: ```sql INSERT INTO hobbies4 SELECT id, empty(hobbies) ? NULL : hobbies[1] FROM file(hobbies.jsonl) ``` -在这种情况下,在 `SELECT` 查询中对列 `hobbies` 执行了一些操作以将其插入到表中,因此ClickHouse无法使用插入表的结构,将使用模式推断。 +在这种情况下,`SELECT` 查询中对列 `hobbies` 执行了一些操作,所以 ClickHouse 无法使用插入表的结构,模式推断将被使用。 + ## 模式推断缓存 {#schema-inference-cache} -对于大多数输入格式,模式推断读取一些数据以确定其结构,而此过程可能需要一些时间。为了防止ClickHouse在每次从同一文件读取数据时推断相同的模式,推断出的模式会被缓存,当再次访问同一文件时,ClickHouse将使用缓存中的模式。 +对于大多数输入格式,模式推断会读取一些数据以确定其结构,这个过程可能需要一些时间。为了防止 ClickHouse 每次从同一文件读取数据时都推断相同的模式,推断的模式会被缓存,当再次访问同一文件时,ClickHouse 将使用缓存中的模式。 有一些特殊设置控制此缓存: -- `schema_inference_cache_max_elements_for_{file/s3/hdfs/url/azure}` - 对应表函数的最大缓存模式数。默认值为 `4096`。这些设置应在服务器配置中进行设置。 -- `schema_inference_use_cache_for_{file,s3,hdfs,url,azure}` - 允许开启/关闭用于模式推断的缓存。这些设置可以在查询中使用。 +- `schema_inference_cache_max_elements_for_{file/s3/hdfs/url/azure}` - 相应表函数的最大缓存模式数。默认值为 `4096`。这些设置应该在服务器配置中设置。 +- `schema_inference_use_cache_for_{file,s3,hdfs,url,azure}` - 允许打开/关闭模式推断的缓存。这些设置可以在查询中使用。 -文件的模式可以通过修改数据或更改格式设置来更改。因此,模式推断缓存是通过文件来源、格式名称、所用格式设置和文件的最后修改时间来识别模式的。 +文件的模式可以通过修改数据或更改格式设置来改变。因此,模式推断缓存通过文件源、格式名称、使用的格式设置和文件的最后修改时间来识别模式。 -注意:某些通过URL在 `url` 表函数中访问的文件可能不包含有关最后修改时间的信息;在这种情况下,有一个特殊设置 `schema_inference_cache_require_modification_time_for_url`。禁用此设置允许在没有最后修改时间的情况下使用缓存中的模式。 +注意:某些通过 `url` 表函数访问的文件可能不包含最后修改时间的信息;在这种情况下,有一个特殊设置 `schema_inference_cache_require_modification_time_for_url`。禁用此设置允许对这些文件使用缓存中的模式,而无需最后修改时间。 -还有一个系统表 [schema_inference_cache](../operations/system-tables/schema_inference_cache.md),其中包含所有当前缓存的模式,并且系统查询 `SYSTEM DROP SCHEMA CACHE [FOR File/S3/URL/HDFS]` 允许清除所有源或特定源的模式缓存。 +此外,还有一个系统表 [schema_inference_cache](../operations/system-tables/schema_inference_cache.md),包含缓存中所有当前的模式,以及系统查询 `SYSTEM DROP SCHEMA CACHE [FOR File/S3/URL/HDFS]`,它允许清除所有源或特定源的模式缓存。 **示例:** -让我们尝试从s3中的示例数据集 `github-2022.ndjson.gz` 推断结构,并查看模式推断缓存是如何工作的: +让我们试着从 s3 推断一个示例数据集 `github-2022.ndjson.gz` 的结构,看看模式推断缓存是如何工作的: ```sql DESCRIBE TABLE s3('https://datasets-documentation.s3.eu-west-3.amazonaws.com/github/github-2022.ndjson.gz') @@ -276,7 +283,7 @@ SETTINGS input_format_json_read_objects_as_strings = 1 5 rows in set. Elapsed: 0.611 sec ``` -如您所见,对于同一文件,未使用缓存中的模式,因为改变了可能影响推断模式的设置。 +如您所见,由于影响推断模式的设置已更改,因此对同一文件未使用缓存中的模式。 让我们检查一下 `system.schema_inference_cache` 表的内容: @@ -290,9 +297,9 @@ SELECT schema, format, source FROM system.schema_inference_cache WHERE storage=' └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┴────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────┘ ``` -如您所见,对于同一文件有两种不同的模式。 +如您所见,对于同一文件,有两个不同的模式。 -我们可以使用系统查询清除模式缓存: +我们可以使用一个系统查询清除模式缓存: ```sql SYSTEM DROP SCHEMA CACHE FOR S3 ``` @@ -307,20 +314,22 @@ SELECT count() FROM system.schema_inference_cache WHERE storage='S3' │ 0 │ └─────────┘ ``` + ## 文本格式 {#text-formats} -对于文本格式,ClickHouse逐行读取数据,根据格式提取列值,然后使用一些递归解析器和启发式方法来确定每个值的类型。在模式推断时,从数据中读取的最大行数和字节数由设置 `input_format_max_rows_to_read_for_schema_inference`(默认25000)和 `input_format_max_bytes_to_read_for_schema_inference`(默认32Mb)控制。默认情况下,所有推断的类型都是 [Nullable](../sql-reference/data-types/nullable.md),但您可以通过设置 `schema_inference_make_columns_nullable` 来更改此设置(请参见 [设置](#settings-for-text-formats) 部分的示例)。 +对于文本格式,ClickHouse 按行读取数据,根据格式提取列值,然后使用一些递归解析器和启发式方法确定每个值的类型。在模式推断中读取的数据的最大行数和字节数由设置 `input_format_max_rows_to_read_for_schema_inference`(默认值为 25000)和 `input_format_max_bytes_to_read_for_schema_inference`(默认值为 32Mb)控制。默认情况下,所有推断的类型都是 [Nullable](../sql-reference/data-types/nullable.md),但您可以通过设置 `schema_inference_make_columns_nullable` 更改此设置(见 [settings](#settings-for-text-formats) 部分的示例)。 + ### JSON 格式 {#json-formats} -在JSON格式中,ClickHouse 根据JSON规范解析值,然后尝试为其找到最合适的数据类型。 +在 JSON 格式中,ClickHouse 根据 JSON 规范解析值,然后尝试为它们找到最合适的数据类型。 -让我们看看它是如何工作的,可以推断出哪些类型以及可以在JSON格式中使用哪些特定设置。 +让我们看看它是如何工作的,可以推断出什么类型以及在 JSON 格式中可以使用哪些具体设置。 **示例** -在这里及后面的示例中,将使用 [format](../sql-reference/table-functions/format.md) 表函数。 +在这里和后面的示例中,将使用 [format](../sql-reference/table-functions/format.md) 表函数。 -整数、浮点、布尔值、字符串: +整数、浮点数、布尔值、字符串: ```sql DESC format(JSONEachRow, '{"int" : 42, "float" : 42.42, "string" : "Hello, World!"}'); ``` @@ -357,7 +366,7 @@ DESC format(JSONEachRow, '{"arr" : [1, 2, 3], "nested_arrays" : [[1, 2, 3], [4, └───────────────┴───────────────────────────────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┘ ``` -如果数组包含 `null`,ClickHouse 会使用其他数组元素的类型: +如果数组包含 `null`,ClickHouse 将使用其他数组元素的类型: ```sql DESC format(JSONEachRow, '{"arr" : [null, 42, null]}') ``` @@ -367,9 +376,21 @@ DESC format(JSONEachRow, '{"arr" : [null, 42, null]}') └──────┴────────────────────────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┘ ``` -具名元组: +如果数组包含不同类型的值,并且设置 `input_format_json_infer_array_of_dynamic_from_array_of_different_types` 被启用(默认启用),则它将被视为 `Array(Dynamic)`: +```sql +SET input_format_json_infer_array_of_dynamic_from_array_of_different_types=1; +DESC format(JSONEachRow, '{"arr" : [42, "hello", [1, 2, 3]]}'); +``` + +```response +┌─name─┬─type───────────┬─default_type─┬─default_expression─┬─comment─┬─codec_expression─┬─ttl_expression─┐ +│ arr │ Array(Dynamic) │ │ │ │ │ │ +└──────┴────────────────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┘ +``` + +命名元组: -启用设置 `input_format_json_try_infer_named_tuples_from_objects` 后,在模式推断过程中,ClickHouse 将尝试从JSON对象中推断具名元组。结果的具名元组将包含来自示例数据的所有相应JSON对象的所有元素。 +当设置 `input_format_json_try_infer_named_tuples_from_objects` 启用时,在模式推断期间 ClickHouse 将尝试从 JSON 对象推断命名元组。结果命名元组将包含来自样本数据中所有相应 JSON 对象的所有元素。 ```sql SET input_format_json_try_infer_named_tuples_from_objects = 1; @@ -382,10 +403,11 @@ DESC format(JSONEachRow, '{"obj" : {"a" : 42, "b" : "Hello"}}, {"obj" : {"a" : 4 └──────┴────────────────────────────────────────────────────────────────────────────────────────────────────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┘ ``` -无名元组: +未命名元组: -在JSON格式中,我们将具有不同类型元素的数组视为无名元组。 +如果将设置 `input_format_json_infer_array_of_dynamic_from_array_of_different_types` 禁用,我们将把包含不同类型元素的数组视为 JSON 格式中的未命名元组。 ```sql +SET input_format_json_infer_array_of_dynamic_from_array_of_different_types = 0; DESC format(JSONEachRow, '{"tuple" : [1, "Hello, World!", [1, 2, 3]]}') ``` ```response @@ -394,8 +416,9 @@ DESC format(JSONEachRow, '{"tuple" : [1, "Hello, World!", [1, 2, 3]]}') └───────┴──────────────────────────────────────────────────────────────────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┘ ``` -如果某些值为 `null` 或为空,我们会使用其他行对应值的类型: +如果某些值为 `null` 或为空,我们将使用其他行中对应值的类型: ```sql +SET input_format_json_infer_array_of_dynamic_from_array_of_different_types=0; DESC format(JSONEachRow, $$ {"tuple" : [1, null, null]} {"tuple" : [null, "Hello, World!", []]} @@ -410,8 +433,8 @@ DESC format(JSONEachRow, $$ 映射: -在JSON中,我们可以读取具有相同类型值的对象作为Map类型。 -注意:只有在禁用设置 `input_format_json_read_objects_as_strings` 和 `input_format_json_try_infer_named_tuples_from_objects` 时此设置才会生效。 +在 JSON 中,我们可以将具有相同类型值的对象读取为映射类型。 +注意:这仅在设置 `input_format_json_read_objects_as_strings` 和 `input_format_json_try_infer_named_tuples_from_objects` 禁用时有效。 ```sql SET input_format_json_read_objects_as_strings = 0, input_format_json_try_infer_named_tuples_from_objects = 0; @@ -423,7 +446,7 @@ DESC format(JSONEachRow, '{"map" : {"key1" : 42, "key2" : 24, "key3" : 4}}') └──────┴──────────────────────────────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┘ ``` -JSON对象类型(如果启用设置 `allow_experimental_object_type`): +JSON 对象类型(如果启用设置 `allow_experimental_object_type`): ```sql SET allow_experimental_object_type = 1 @@ -449,7 +472,7 @@ DESC format(JSONEachRow, '{"value" : [[[42, 24], []], {"key1" : 42, "key2" : 24} └───────┴──────────────────────────────────────────────────────────────────────────────────────────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┘ ``` -如果ClickHouse无法确定某些键的类型,因为数据仅包含null/空对象/空数组,如果启用设置 `input_format_json_infer_incomplete_types_as_strings`,将使用类型 `String`,否则将抛出异常: +如果 ClickHouse 无法为某个键确定类型,因为数据仅包含空值/空对象/空数组,当设置 `input_format_json_infer_incomplete_types_as_strings` 启用时将使用类型 `String`,否则将抛出异常: ```sql DESC format(JSONEachRow, '{"arr" : [null, null]}') SETTINGS input_format_json_infer_incomplete_types_as_strings = 1; ``` @@ -467,10 +490,11 @@ Cannot determine type for column 'arr' by first 1 rows of data, most likely this column contains only Nulls or empty Arrays/Maps. ... ``` -#### JSON设置 {#json-settings} + +#### JSON 设置 {#json-settings} ##### input_format_json_try_infer_numbers_from_strings {#input_format_json_try_infer_numbers_from_strings} -启用此设置可允许从字符串值中推断数字。 +启用此设置允许从字符串值推断数字。 此设置默认禁用。 @@ -490,8 +514,7 @@ DESC format(JSONEachRow, $$ ``` ##### input_format_json_try_infer_named_tuples_from_objects {#input_format_json_try_infer_named_tuples_from_objects} -启用此设置可允许从JSON对象中推断具名元组。结果的具名元组将包含来自示例数据的所有相应JSON对象的所有元素。 -当JSON数据不稀疏时,这可能会很有用,因为数据样本将包含所有可能的对象键。 +启用此设置允许从 JSON 对象推断命名元组。结果的命名元组将包含来自样本数据中所有相应 JSON 对象的所有元素。当 JSON 数据不稀疏时,这个设置可能会很有用,样本数据将包含所有可能的对象键。 此设置默认启用。 @@ -522,16 +545,15 @@ DESC format(JSONEachRow, '{"array" : [{"a" : 42, "b" : "Hello"}, {}, {"c" : [1,2 │ array │ Array(Tuple(a Nullable(Int64), b Nullable(String), c Array(Nullable(Int64)), d Nullable(Date))) │ │ │ │ │ │ └───────┴─────────────────────────────────────────────────────────────────────────────────────────────────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┘ ``` -##### input_format_json_use_string_type_for_ambiguous_paths_in_named_tuples_inference_from_objects {#input_format_json_use_string_type_for_ambiguous_paths_in_named_tuples_inference_from_objects} +##### input_format_json_use_string_type_for_ambiguous_paths_in_named_tuples_inference_from_objects {#input_format_json_use_string_type_for_ambiguous_paths_in_named-tuple-inference-from-objects} -启用此设置可允许在从JSON对象推断具名元组(当启用 `input_format_json_try_infer_named_tuples_from_objects` 时)时,对模糊路径使用字符串类型,而不是抛出异常。 -它允许将JSON对象读取为具名元组,即使存在模糊路径。 +启用此设置允许在从 JSON 对象推断命名元组时对模糊路径使用字符串类型(当启用 `input_format_json_try_infer_named_tuples_from_objects`)而不是抛出异常。它允许在存在模糊路径的情况下将 JSON 对象读取为命名元组。 默认禁用。 **示例** -禁用设置: +禁用设置时: ```sql SET input_format_json_try_infer_named_tuples_from_objects = 1; SET input_format_json_use_string_type_for_ambiguous_paths_in_named_tuples_inference_from_objects = 0; @@ -545,7 +567,7 @@ Code: 117. DB::Exception: JSON objects have ambiguous data: in some objects path You can specify the structure manually. (CANNOT_EXTRACT_TABLE_STRUCTURE) ``` -启用设置: +启用设置时: ```sql SET input_format_json_try_infer_named_tuples_from_objects = 1; SET input_format_json_use_string_type_for_ambiguous_paths_in_named_tuples_inference_from_objects = 1; @@ -565,12 +587,11 @@ SELECT * FROM format(JSONEachRow, '{"obj" : {"a" : 42}}, {"obj" : {"a" : {"b" : ``` ##### input_format_json_read_objects_as_strings {#input_format_json_read_objects_as_strings} -启用此设置可允许将嵌套JSON对象作为字符串读取。 -此设置可用于在不使用JSON对象类型的情况下读取嵌套JSON对象。 +启用此设置允许将嵌套 JSON 对象作为字符串读取。该设置可用于在不使用 JSON 对象类型的情况下读取嵌套 JSON 对象。 此设置默认启用。 -注意:启用此设置仅在禁用设置 `input_format_json_try_infer_named_tuples_from_objects` 时生效。 +注意:启用此设置仅在 `input_format_json_try_infer_named_tuples_from_objects` 设置禁用时生效。 ```sql SET input_format_json_read_objects_as_strings = 1, input_format_json_try_infer_named_tuples_from_objects = 0; @@ -586,7 +607,7 @@ DESC format(JSONEachRow, $$ ``` ##### input_format_json_read_numbers_as_strings {#input_format_json_read_numbers_as_strings} -启用此设置可允许将数值作为字符串读取。 +启用此设置允许将数值作为字符串读取。 此设置默认启用。 @@ -606,7 +627,7 @@ DESC format(JSONEachRow, $$ ``` ##### input_format_json_read_bools_as_numbers {#input_format_json_read_bools_as_numbers} -启用此设置可允许将布尔值作为数字读取。 +启用此设置允许将布尔值作为数字读取。 此设置默认启用。 @@ -626,7 +647,7 @@ DESC format(JSONEachRow, $$ ``` ##### input_format_json_read_bools_as_strings {#input_format_json_read_bools_as_strings} -启用此设置可允许将布尔值作为字符串读取。 +启用此设置允许将布尔值作为字符串读取。 此设置默认启用。 @@ -646,7 +667,7 @@ DESC format(JSONEachRow, $$ ``` ##### input_format_json_read_arrays_as_strings {#input_format_json_read_arrays_as_strings} -启用此设置可允许将JSON数组值作为字符串读取。 +启用此设置允许将 JSON 数组值作为字符串读取。 此设置默认启用。 @@ -663,8 +684,7 @@ SELECT arr, toTypeName(arr), JSONExtractArrayRaw(arr)[3] from format(JSONEachRow ``` ##### input_format_json_infer_incomplete_types_as_strings {#input_format_json_infer_incomplete_types_as_strings} -启用此设置可允许在模式推断期间使用字符串类型,用于数据样本中仅包含 `Null`/`{}`/`[]` 的JSON键。 -在JSON格式中,如果启用(默认启用),任何值都可以读取为字符串,并且我们可以通过使用未知类型的键的字符串类型避免错误,例如“无法确定列 'column_name' 的类型,因为前25000行数据大多包含空值或空数组/映射”的错误。 +启用此设置允许对样本数据中的 JSON 键在仅包含 `Null`/`{}`/`[]` 的情况下,在模式推断时使用字符串类型。在 JSON 格式中,如果启用所有对应设置(它们都是默认启用),任何值都可以作为字符串读取,我们可以通过对未知类型的键使用字符串类型,避免在模式推断中出现诸如 `无法通过前 25000 行数据确定列 'column_name' 的类型,该列很可能只包含 Nulls 或空数组/映射` 的错误。 示例: @@ -686,15 +706,15 @@ SELECT * FROM format(JSONEachRow, '{"obj" : {"a" : [1,2,3], "b" : "hello", "c" : ``` ### CSV {#csv} -在CSV格式中,ClickHouse根据分隔符从行中提取列值。ClickHouse期望除数字和字符串之外的所有类型都用双引号括起来。如果值在双引号中,ClickHouse尝试使用递归解析器解析引号内的数据,然后尝试为其找到最合适的数据类型。如果值不在双引号中,ClickHouse尝试将其解析为数字,如果值不是数字,ClickHouse将其视为字符串。 +在 CSV 格式中,ClickHouse 根据分隔符从行中提取列值。ClickHouse 期望所有类型,除了数字和字符串,都用双引号括起来。如果值在双引号中,ClickHouse 将尝试使用递归解析器解析引号内的数据,然后尝试为其找到最合适的数据类型。如果值不在双引号中,ClickHouse 将尝试将其解析为数字,如果该值不是数字,则 ClickHouse 将其视为字符串。 -如果您不希望ClickHouse尝试使用一些解析器和启发式方法来确定复杂类型,可以禁用设置 `input_format_csv_use_best_effort_in_schema_inference`,ClickHouse将把所有列视为字符串。 +如果您不希望 ClickHouse 尝试使用某些解析器和启发式方法来确定复杂类型,可以禁用设置 `input_format_csv_use_best_effort_in_schema_inference`,并且 ClickHouse 将所有列视为字符串。 -如果启用设置 `input_format_csv_detect_header`,ClickHouse将在推断模式时尝试检测带有列名(可能还有类型)的头部。此设置默认启用。 +如果启用设置 `input_format_csv_detect_header`,ClickHouse 将尝试在推断模式时检测带有列名(以及可能的类型)的头部。此设置默认启用。 **示例:** -整数、浮点、布尔值、字符串: +整数、浮点数、布尔值、字符串: ```sql DESC format(CSV, '42,42.42,true,"Hello,World!"') ``` @@ -751,7 +771,7 @@ DESC format(CSV, $$"['Hello', 'world']","[['Abc', 'Def'], []]"$$) └──────┴────────────────────────────────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┘ ``` -如果数组包含null,ClickHouse将使用其他数组元素的类型: +如果数组包含 null,ClickHouse 将使用其他数组元素的类型: ```sql DESC format(CSV, '"[NULL, 42, NULL]"') ``` @@ -781,7 +801,7 @@ DESC format(CSV, $$"[{'key1' : [[42, 42], []], 'key2' : [[null], [42]]}]"$$) └──────┴───────────────────────────────────────────────────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┘ ``` -如果ClickHouse无法确定引号内的类型,因为数据仅包含空值,ClickHouse将其视为字符串: +如果 ClickHouse 无法确定引号内的类型,因为数据仅包含 null,ClickHouse 将其视为字符串: ```sql DESC format(CSV, '"[NULL, NULL]"') ``` @@ -804,7 +824,7 @@ DESC format(CSV, '"[1,2,3]",42.42,Hello World!') └──────┴──────────────────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┘ ``` -标题自动检测示例(当启用 `input_format_csv_detect_header` 时): +启用 `input_format_csv_detect_header` 的头部自动检测示例: 仅名称: ```sql @@ -841,7 +861,7 @@ $$) └────────┴───────────────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┘ ``` -请注意,标题仅在至少有一列具有非字符串类型的情况下才能检测到。如果所有列都是字符串类型,则不会检测到标题: +请注意,只有在至少有一列具有非字符串类型时,才能检测头部。如果所有列都是字符串类型,则不会检测到头部: ```sql SELECT * FROM format(CSV, @@ -858,10 +878,11 @@ $$) │ World │ Hello │ └──────────────┴───────────────┘ ``` -#### CSV设置 {#csv-settings} + +#### CSV 设置 {#csv-settings} ##### input_format_csv_try_infer_numbers_from_strings {#input_format_csv_try_infer_numbers_from_strings} -启用此设置可允许从字符串值中推断数字。 +启用此设置允许从字符串值推断数字。 此设置默认禁用。 @@ -879,15 +900,15 @@ DESC format(CSV, '42,42.42'); ``` ### TSV/TSKV {#tsv-tskv} -在TSV/TSKV格式中,ClickHouse根据表格分隔符从行中提取列值,然后使用递归解析器解析提取的值,以确定最合适的类型。如果无法确定类型,ClickHouse将此值视为字符串。 +在 TSV/TSKV 格式中,ClickHouse 根据制表符分隔符从行中提取列值,然后使用递归解析器解析提取的值以确定最合适的类型。如果无法确定类型,ClickHouse 将此值视为字符串。 -如果您不希望ClickHouse尝试使用一些解析器和启发式方法来确定复杂类型,可以禁用设置 `input_format_tsv_use_best_effort_in_schema_inference`,ClickHouse将把所有列视为字符串。 +如果您不希望 ClickHouse 尝试使用某些解析器和启发式方法来确定复杂类型,可以禁用设置 `input_format_tsv_use_best_effort_in_schema_inference`,并且 ClickHouse 将所有列视为字符串。 -如果启用设置 `input_format_tsv_detect_header`,ClickHouse将在推断模式时尝试检测带有列名(可能还有类型)的头部。此设置默认启用。 +如果启用设置 `input_format_tsv_detect_header`,ClickHouse 将在推断模式时尝试检测带有列名(以及可能的类型)的头部。此设置默认启用。 **示例:** -整数、浮点、布尔值、字符串: +整数、浮点数、布尔值、字符串: ```sql DESC format(TSV, '42 42.42 true Hello,World!') ``` @@ -944,7 +965,7 @@ DESC format(TSV, '[''Hello'', ''world''] [[''Abc'', ''Def''], []]') └──────┴────────────────────────────────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┘ ``` -如果数组包含null,ClickHouse将使用其他数组元素的类型: +如果数组包含 null,ClickHouse 将使用其他数组元素的类型: ```sql DESC format(TSV, '[NULL, 42, NULL]') ``` @@ -984,7 +1005,7 @@ DESC format(TSV, $$[{'key1' : [(42, 'Hello'), (24, NULL)], 'key2' : [(NULL, ',') └──────┴─────────────────────────────────────────────────────────────────────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┘ ``` -如果ClickHouse无法确定类型,因为数据仅包含空值,ClickHouse将其视为字符串: +如果 ClickHouse 无法确定类型,因为数据仅包含 null,ClickHouse 将其视为字符串: ```sql DESC format(TSV, '[NULL, NULL]') ``` @@ -1007,7 +1028,7 @@ DESC format(TSV, '[1,2,3] 42.42 Hello World!') └──────┴──────────────────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┘ ``` -标题自动检测示例(当启用 `input_format_tsv_detect_header` 时): +启用 `input_format_tsv_detect_header` 的头部自动检测示例: 仅名称: ```sql @@ -1044,7 +1065,7 @@ $$) └────────┴───────────────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┘ ``` -请注意,标题仅在至少有一列具有非字符串类型的情况下才能检测到。如果所有列都是字符串类型,则不会检测到标题: +请注意,只有在至少有一列具有非字符串类型时,才能检测头部。如果所有列都是字符串类型,则不会检测到头部: ```sql SELECT * FROM format(TSV, @@ -1063,11 +1084,11 @@ $$) ``` ### 值 {#values} -在Values格式中,ClickHouse从行中提取列值,然后使用递归解析器进行解析,类似于字面值的解析。 +在 Values 格式中,ClickHouse 从行中提取列值,然后使用递归解析器解析它,类似于文本字面量的解析方式。 **示例:** -整数、浮点、布尔值、字符串: +整数、浮点数、布尔值、字符串: ```sql DESC format(Values, $$(42, 42.42, true, 'Hello,World!')$$) ``` @@ -1104,7 +1125,7 @@ DESC format(Values, '([1,2,3], [[1, 2], [], [3, 4]])') └──────┴───────────────────────────────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┘ ``` -如果数组包含null,ClickHouse将使用其他数组元素的类型: +如果数组包含 null,ClickHouse 将使用其他数组元素的类型: ```sql DESC format(Values, '([NULL, 42, NULL])') ``` @@ -1144,7 +1165,7 @@ DESC format(Values, $$([{'key1' : [(42, 'Hello'), (24, NULL)], 'key2' : [(NULL, └──────┴─────────────────────────────────────────────────────────────────────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┘ ``` -如果ClickHouse无法确定类型,因为数据仅包含空值,将抛出异常: +如果 ClickHouse 无法确定类型,因为数据仅包含 null,将抛出异常: ```sql DESC format(Values, '([NULL, NULL])') ``` @@ -1167,12 +1188,429 @@ DESC format(TSV, '[1,2,3] 42.42 Hello World!') │ c3 │ Nullable(String) │ │ │ │ │ │ └──────┴──────────────────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┘ ``` -### 自描述格式 {#self-describing-formats} +### 自定义分隔符 {#custom-separated} + +在 CustomSeparated 格式中,ClickHouse 首先根据指定的分隔符从行中提取所有列值,然后尝试根据转义规则推断每个值的数据类型。 + +如果启用设置 `input_format_custom_detect_header`,ClickHouse 将尝试在推断模式时检测带有列名(以及可能的类型)的头部。此设置默认启用。 + +**示例** + +```sql +SET format_custom_row_before_delimiter = '', + format_custom_row_after_delimiter = '\n', + format_custom_row_between_delimiter = '\n', + format_custom_result_before_delimiter = '\n', + format_custom_result_after_delimiter = '\n', + format_custom_field_delimiter = '', + format_custom_escaping_rule = 'Quoted' + +DESC format(CustomSeparated, $$ +42.42'Some string 1'[1, NULL, 3] + +NULL'Some string 3'[1, 2, NULL] + +$$) +``` +```response +┌─name─┬─type───────────────────┬─default_type─┬─default_expression─┬─comment─┬─codec_expression─┬─ttl_expression─┐ +│ c1 │ Nullable(Float64) │ │ │ │ │ │ +│ c2 │ Nullable(String) │ │ │ │ │ │ +│ c3 │ Array(Nullable(Int64)) │ │ │ │ │ │ +└──────┴────────────────────────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┘ +``` + +启用 `input_format_custom_detect_header` 的头部自动检测示例: + +```sql +SET format_custom_row_before_delimiter = '', + format_custom_row_after_delimiter = '\n', + format_custom_row_between_delimiter = '\n', + format_custom_result_before_delimiter = '\n', + format_custom_result_after_delimiter = '\n', + format_custom_field_delimiter = '', + format_custom_escaping_rule = 'Quoted' + +DESC format(CustomSeparated, $$ +'number''string''array' + +42.42'Some string 1'[1, NULL, 3] + +NULL'Some string 3'[1, 2, NULL] + +$$) +``` + +```response +┌─number─┬─string────────┬─array──────┐ +│ 42.42 │ Some string 1 │ [1,NULL,3] │ +│ ᴺᵁᴸᴸ │ Some string 3 │ [1,2,NULL] │ +└────────┴───────────────┴────────────┘ +``` +### 模板 {#template} + +在 Template 格式中,ClickHouse 首先根据指定的模板从行中提取所有列值,然后尝试根据它们的转义规则推断每个值的数据类型。 + +**示例** + +假设我们有一个内容如下的文件 `resultset`: +```bash + +${data} +``` + +还有一个内容如下的文件 `row_format`: + +```text +${column_1:CSV}${column_2:Quoted}${column_3:JSON} +``` + +那么我们可以执行以下查询: + +```sql +SET format_template_rows_between_delimiter = '\n', + format_template_row = 'row_format', + format_template_resultset = 'resultset_format' + +DESC format(Template, $$ +42.42'Some string 1'[1, null, 2] + +\N'Some string 3'[1, 2, null] + +$$) +``` +```response +┌─name─────┬─type───────────────────┬─default_type─┬─default_expression─┬─comment─┬─codec_expression─┬─ttl_expression─┐ +│ column_1 │ Nullable(Float64) │ │ │ │ │ │ +│ column_2 │ Nullable(String) │ │ │ │ │ │ +│ column_3 │ Array(Nullable(Int64)) │ │ │ │ │ │ +└──────────┴────────────────────────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┘ +``` +### 正则表达式 {#regexp} + +类似于模板,在 Regexp 格式中,ClickHouse 首先根据指定的正则表达式从行中提取所有列值,然后尝试根据指定的转义规则推断每个值的数据类型。 + +**示例** + +```sql +SET format_regexp = '^Line: value_1=(.+?), value_2=(.+?), value_3=(.+?)', + format_regexp_escaping_rule = 'CSV' + +DESC format(Regexp, $$Line: value_1=42, value_2="Some string 1", value_3="[1, NULL, 3]" +Line: value_1=2, value_2="Some string 2", value_3="[4, 5, NULL]"$$) +``` +```response +┌─name─┬─type───────────────────┬─default_type─┬─default_expression─┬─comment─┬─codec_expression─┬─ttl_expression─┐ +│ c1 │ Nullable(Int64) │ │ │ │ │ │ +│ c2 │ Nullable(String) │ │ │ │ │ │ +│ c3 │ Array(Nullable(Int64)) │ │ │ │ │ │ +└──────┴────────────────────────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┘ +``` +### 文本格式的设置 {#settings-for-text-formats} +#### input_format_max_rows_to_read_for_schema_inference/input_format_max_bytes_to_read_for_schema_inference {#input-format-max-rows-to-read-for-schema-inference} + +这些设置控制在模式推断时读取的数据量。读取的行/字节越多,模式推断所花费的时间就越长,但更有可能正确确定类型(尤其是当数据包含大量 null 时)。 + +默认值: +- `25000` 用于 `input_format_max_rows_to_read_for_schema_inference`。 +- `33554432`(32 Mb)用于 `input_format_max_bytes_to_read_for_schema_inference`。 +#### column_names_for_schema_inference {#column-names-for-schema-inference} + +用于没有显式列名的格式的模式推断的列名列表。指定的名称将被用作默认值 `c1,c2,c3,...` 的替代。格式: `column1,column2,column3,...`。 + +**示例** + +```sql +DESC format(TSV, 'Hello, World! 42 [1, 2, 3]') settings column_names_for_schema_inference = 'str,int,arr' +``` +```response +┌─name─┬─type───────────────────┬─default_type─┬─default_expression─┬─comment─┬─codec_expression─┬─ttl_expression─┐ +│ str │ Nullable(String) │ │ │ │ │ │ +│ int │ Nullable(Int64) │ │ │ │ │ │ +│ arr │ Array(Nullable(Int64)) │ │ │ │ │ │ +└──────┴────────────────────────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┘ +``` +#### schema_inference_hints {#schema-inference-hints} + +用于模式推断的列名和类型列表,而不是自动确定的类型。格式: 'column_name1 column_type1,column_name2 column_type2,...'。此设置可用于指定无法自动确定类型的列的类型,或用于优化模式。 + +**示例** + +```sql +DESC format(JSONEachRow, '{"id" : 1, "age" : 25, "name" : "Josh", "status" : null, "hobbies" : ["football", "cooking"]}') SETTINGS schema_inference_hints = 'age LowCardinality(UInt8), status Nullable(String)', allow_suspicious_low_cardinality_types=1 +``` +```response +┌─name────┬─type────────────────────┬─default_type─┬─default_expression─┬─comment─┬─codec_expression─┬─ttl_expression─┐ +│ id │ Nullable(Int64) │ │ │ │ │ │ +│ age │ LowCardinality(UInt8) │ │ │ │ │ │ +│ name │ Nullable(String) │ │ │ │ │ │ +│ status │ Nullable(String) │ │ │ │ │ │ +│ hobbies │ Array(Nullable(String)) │ │ │ │ │ │ +└─────────┴─────────────────────────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┘ +``` +#### schema_inference_make_columns_nullable {#schema-inference-make-columns-nullable} + +控制在没有 nullability 信息的格式下使推断类型为 `Nullable`。可能的值: +* 0 - 推断的类型永远不会是 `Nullable`, +* 1 - 所有推断的类型将是 `Nullable`, +* 2 或 'auto' - 对于文本格式,仅当列在模式推断期间的样本中包含 `NULL` 时,推断的类型才会为 `Nullable`;对于强类型格式(Parquet、ORC、Arrow),则从文件元数据中获取 nullability 信息, +* 3 - 对于文本格式,使用 `Nullable`;对于强类型格式,使用文件元数据。 + +默认值: 3。 + +**示例** + +```sql +SET schema_inference_make_columns_nullable = 1 +DESC format(JSONEachRow, $$ + {"id" : 1, "age" : 25, "name" : "Josh", "status" : null, "hobbies" : ["football", "cooking"]} + {"id" : 2, "age" : 19, "name" : "Alan", "status" : "married", "hobbies" : ["tennis", "art"]} + $$) +``` +```response +┌─name────┬─type────────────────────┬─default_type─┬─default_expression─┬─comment─┬─codec_expression─┬─ttl_expression─┐ +│ id │ Nullable(Int64) │ │ │ │ │ │ +│ age │ Nullable(Int64) │ │ │ │ │ │ +│ name │ Nullable(String) │ │ │ │ │ │ +│ status │ Nullable(String) │ │ │ │ │ │ +│ hobbies │ Array(Nullable(String)) │ │ │ │ │ │ +└─────────┴─────────────────────────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┘ +``` +```sql +SET schema_inference_make_columns_nullable = 'auto'; +DESC format(JSONEachRow, $$ + {"id" : 1, "age" : 25, "name" : "Josh", "status" : null, "hobbies" : ["football", "cooking"]} + {"id" : 2, "age" : 19, "name" : "Alan", "status" : "married", "hobbies" : ["tennis", "art"]} + $$) +``` +```response +┌─name────┬─type─────────────┬─default_type─┬─default_expression─┬─comment─┬─codec_expression─┬─ttl_expression─┐ +│ id │ Int64 │ │ │ │ │ │ +│ age │ Int64 │ │ │ │ │ │ +│ name │ String │ │ │ │ │ │ +│ status │ Nullable(String) │ │ │ │ │ │ +│ hobbies │ Array(String) │ │ │ │ │ │ +└─────────┴──────────────────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┘ +``` + +```sql +SET schema_inference_make_columns_nullable = 0; +DESC format(JSONEachRow, $$ + {"id" : 1, "age" : 25, "name" : "Josh", "status" : null, "hobbies" : ["football", "cooking"]} + {"id" : 2, "age" : 19, "name" : "Alan", "status" : "married", "hobbies" : ["tennis", "art"]} + $$) +``` +```response + +┌─name────┬─type──────────┬─default_type─┬─default_expression─┬─comment─┬─codec_expression─┬─ttl_expression─┐ +│ id │ Int64 │ │ │ │ │ │ +│ age │ Int64 │ │ │ │ │ │ +│ name │ String │ │ │ │ │ │ +│ status │ String │ │ │ │ │ │ +│ hobbies │ Array(String) │ │ │ │ │ │ +└─────────┴───────────────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┘ +``` +#### input_format_try_infer_integers {#input-format-try-infer-integers} + +:::note +此设置不适用于 `JSON` 数据类型。 +::: + +如启用,ClickHouse将在文本格式的模式推断中尝试推断整数,而不是浮点数。如果样本数据中列中的所有数值都是整数,则结果类型将为 `Int64`,如果至少有一个数值为浮点数,则结果类型将为 `Float64`。如果样本数据仅包含整数,并且至少一个整数为正且超出了 `Int64`,则 ClickHouse 将推断为 `UInt64`。 + +默认启用。 + +**示例** + +```sql +SET input_format_try_infer_integers = 0 +DESC format(JSONEachRow, $$ + {"number" : 1} + {"number" : 2} + $$) +``` +```response +┌─name───┬─type──────────────┬─default_type─┬─default_expression─┬─comment─┬─codec_expression─┬─ttl_expression─┐ +│ number │ Nullable(Float64) │ │ │ │ │ │ +└────────┴───────────────────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┘ +``` +```sql +SET input_format_try_infer_integers = 1 +DESC format(JSONEachRow, $$ + {"number" : 1} + {"number" : 2} + $$) +``` +```response +┌─name───┬─type────────────┬─default_type─┬─default_expression─┬─comment─┬─codec_expression─┬─ttl_expression─┐ +│ number │ Nullable(Int64) │ │ │ │ │ │ +└────────┴─────────────────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┘ +``` +```sql +DESC format(JSONEachRow, $$ + {"number" : 1} + {"number" : 18446744073709551615} + $$) +``` +```response +┌─name───┬─type─────────────┬─default_type─┬─default_expression─┬─comment─┬─codec_expression─┬─ttl_expression─┐ +│ number │ Nullable(UInt64) │ │ │ │ │ │ +└────────┴──────────────────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┘ +``` +```sql +DESC format(JSONEachRow, $$ + {"number" : 1} + {"number" : 2.2} + $$) +``` +```response +┌─name───┬─type──────────────┬─default_type─┬─default_expression─┬─comment─┬─codec_expression─┬─ttl_expression─┐ +│ number │ Nullable(Float64) │ │ │ │ │ │ +└────────┴───────────────────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┘ +``` +#### input_format_try_infer_datetimes {#input-format-try-infer-datetimes} + +如果启用,ClickHouse 将尝试从字符串字段的模式推断中推断类型 `DateTime` 或 `DateTime64`。如果样本数据中列的所有字段的解析成功,则结果类型将为 `DateTime` 或 `DateTime64(9)`(如果任何日期时间具有小数部分),如果至少有一个字段未解析为日期时间,则结果类型将为 `String`。 + +默认启用。 + +**示例** + +```sql +SET input_format_try_infer_datetimes = 0; +DESC format(JSONEachRow, $$ + {"datetime" : "2021-01-01 00:00:00", "datetime64" : "2021-01-01 00:00:00.000"} + {"datetime" : "2022-01-01 00:00:00", "datetime64" : "2022-01-01 00:00:00.000"} + $$) +``` +```response +┌─name───────┬─type─────────────┬─default_type─┬─default_expression─┬─comment─┬─codec_expression─┬─ttl_expression─┐ +│ datetime │ Nullable(String) │ │ │ │ │ │ +│ datetime64 │ Nullable(String) │ │ │ │ │ │ +└────────────┴──────────────────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┘ +``` +```sql +SET input_format_try_infer_datetimes = 1; +DESC format(JSONEachRow, $$ + {"datetime" : "2021-01-01 00:00:00", "datetime64" : "2021-01-01 00:00:00.000"} + {"datetime" : "2022-01-01 00:00:00", "datetime64" : "2022-01-01 00:00:00.000"} + $$) +``` +```response +┌─name───────┬─type────────────────────┬─default_type─┬─default_expression─┬─comment─┬─codec_expression─┬─ttl_expression─┐ +│ datetime │ Nullable(DateTime) │ │ │ │ │ │ +│ datetime64 │ Nullable(DateTime64(9)) │ │ │ │ │ │ +└────────────┴─────────────────────────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┘ +``` +```sql +DESC format(JSONEachRow, $$ + {"datetime" : "2021-01-01 00:00:00", "datetime64" : "2021-01-01 00:00:00.000"} + {"datetime" : "unknown", "datetime64" : "unknown"} + $$) +``` +```response +┌─name───────┬─type─────────────┬─default_type─┬─default_expression─┬─comment─┬─codec_expression─┬─ttl_expression─┐ +│ datetime │ Nullable(String) │ │ │ │ │ │ +│ datetime64 │ Nullable(String) │ │ │ │ │ │ +└────────────┴──────────────────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┘ +``` +#### input_format_try_infer_datetimes_only_datetime64 {#input-format-try-infer-datetimes-only-datetime64} + +如果启用,即使日期时间值不包含小数部分,ClickHouse 也将始终在启用 `input_format_try_infer_datetimes` 时推断为 `DateTime64(9)`。 + +默认禁用。 + +**示例** + +```sql +SET input_format_try_infer_datetimes = 1; +SET input_format_try_infer_datetimes_only_datetime64 = 1; +DESC format(JSONEachRow, $$ + {"datetime" : "2021-01-01 00:00:00", "datetime64" : "2021-01-01 00:00:00.000"} + {"datetime" : "2022-01-01 00:00:00", "datetime64" : "2022-01-01 00:00:00.000"} + $$) +``` + +```response +┌─name───────┬─type────────────────────┬─default_type─┬─default_expression─┬─comment─┬─codec_expression─┬─ttl_expression─┐ +│ datetime │ Nullable(DateTime64(9)) │ │ │ │ │ │ +│ datetime64 │ Nullable(DateTime64(9)) │ │ │ │ │ │ +└────────────┴─────────────────────────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┘ +``` + +注意:在模式推断期间解析日期时间时,遵循设置 [date_time_input_format](/operations/settings/settings-formats.md#date_time_input_format) + +#### input_format_try_infer_dates {#input-format-try-infer-dates} + +如果启用,ClickHouse 将尝试从字符串字段的模式推断中推断类型 `Date`。如果样本数据中列的所有字段的解析成功,则结果类型将为 `Date`,如果至少有一个字段未解析为日期,则结果类型将为 `String`。 + +默认启用。 + +**示例** + +```sql +SET input_format_try_infer_datetimes = 0, input_format_try_infer_dates = 0 +DESC format(JSONEachRow, $$ + {"date" : "2021-01-01"} + {"date" : "2022-01-01"} + $$) +``` +```response +┌─name─┬─type─────────────┬─default_type─┬─default_expression─┬─comment─┬─codec_expression─┬─ttl_expression─┐ +│ date │ Nullable(String) │ │ │ │ │ │ +└──────┴──────────────────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┘ +``` +```sql +SET input_format_try_infer_dates = 1 +DESC format(JSONEachRow, $$ + {"date" : "2021-01-01"} + {"date" : "2022-01-01"} + $$) +``` +```response +┌─name─┬─type───────────┬─default_type─┬─default_expression─┬─comment─┬─codec_expression─┬─ttl_expression─┐ +│ date │ Nullable(Date) │ │ │ │ │ │ +└──────┴────────────────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┘ +``` +```sql +DESC format(JSONEachRow, $$ + {"date" : "2021-01-01"} + {"date" : "unknown"} + $$) +``` +```response +┌─name─┬─type─────────────┬─default_type─┬─default_expression─┬─comment─┬─codec_expression─┬─ttl_expression─┐ +│ date │ Nullable(String) │ │ │ │ │ │ +└──────┴──────────────────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┘ +``` +#### input_format_try_infer_exponent_floats {#input-format-try-infer-exponent-floats} + +如果启用,ClickHouse 将尝试在文本格式(除了 JSON 中的数字始终推断为指数形式)中推断浮点数的指数形式。 + +默认禁用。 + +**示例** + +```sql +SET input_format_try_infer_exponent_floats = 1; +DESC format(CSV, +$$1.1E10 +2.3e-12 +42E00 +$$) +``` +```response +┌─name─┬─type──────────────┬─default_type─┬─default_expression─┬─comment─┬─codec_expression─┬─ttl_expression─┐ +│ c1 │ Nullable(Float64) │ │ │ │ │ │ +└──────┴───────────────────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┘ +``` +## 自描述格式 {#self-describing-formats} + +自描述格式包含数据结构的信息,通常是某种头部描述、二进制类型树或某种表格。为了自动推断这种格式文件的模式,ClickHouse 读取数据的一部分,包含有关类型的信息,并将其转换为 ClickHouse 表的模式。 -自描述格式在数据本身中包含有关数据结构的信息,可以是带有描述的某个头部、二进制类型树或某种表。为了自动从这种格式的文件中推断模式,ClickHouse读取包含类型信息的数据部分并将其转换为ClickHouse表的模式。 ### 带有 -WithNamesAndTypes 后缀的格式 {#formats-with-names-and-types} -ClickHouse支持一些带有后缀 -WithNamesAndTypes 的文本格式。此后缀表示数据在实际数据之前包含两行列名和类型。在此类格式的模式推断中,ClickHouse读取前两行,并提取列名和类型。 +ClickHouse 支持一些带有 -WithNamesAndTypes 后缀的文本格式。此后缀意味着数据在实际数据之前包含两行附加的列名和类型。在这种格式的模式推断中,ClickHouse 读取前两行并提取列名和类型。 **示例** @@ -1190,10 +1628,9 @@ $$) │ arr │ Array(UInt8) │ │ │ │ │ │ └──────┴──────────────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┘ ``` -### 带有元数据的JSON格式 {#json-with-metadata} +### 带有元数据的 JSON 格式 {#json-with-metadata} -某些JSON输入格式([JSON](formats.md#json), [JSONCompact](/interfaces/formats/JSONCompact), [JSONColumnsWithMetadata](/interfaces/formats/JSONColumnsWithMetadata))包含带有列名和类型的元数据。 -在此类格式的模式推断中,ClickHouse会读取这些元数据。 +某些 JSON 输入格式([JSON](formats.md#json), [JSONCompact](/interfaces/formats/JSONCompact), [JSONColumnsWithMetadata](/interfaces/formats/JSONColumnsWithMetadata))包含带有列名和类型的元数据。在这种格式的模式推断中,ClickHouse 读取这些元数据。 **示例** ```sql @@ -1244,9 +1681,9 @@ $$) ``` ### Avro {#avro} -在Avro格式中,ClickHouse从数据中读取其模式,并使用以下类型匹配将其转换为ClickHouse模式: +在 Avro 格式中,ClickHouse 从数据中读取其模式并将其转换为 ClickHouse 模式,采用以下类型匹配: -| Avro数据类型 | ClickHouse数据类型 | +| Avro 数据类型 | ClickHouse 数据类型 | |------------------------------------|--------------------------------------------------------------------------------| | `boolean` | [Bool](../sql-reference/data-types/boolean.md) | | `int` | [Int32](../sql-reference/data-types/int-uint.md) | @@ -1263,189 +1700,178 @@ $$) | `string (uuid)` \* | [UUID](../sql-reference/data-types/uuid.md) | | `binary (decimal)` \* | [Decimal(P, S)](../sql-reference/data-types/decimal.md) | -\* [Avro逻辑类型](https://avro.apache.org/docs/current/spec.html#Logical+Types) +\* [Avro 逻辑类型](https://avro.apache.org/docs/current/spec.html#Logical+Types) -其他Avro类型不支持。 +其他 Avro 类型不受支持。 ### Parquet {#parquet} -在 Parquet 格式中,ClickHouse 从数据中读取其模式并使用以下类型匹配将其转换为 ClickHouse 模式: - -| Parquet 数据类型 | ClickHouse 数据类型 | -|------------------------------|---------------------------------------------------------| -| `BOOL` | [Bool](../sql-reference/data-types/boolean.md) | -| `UINT8` | [UInt8](../sql-reference/data-types/int-uint.md) | -| `INT8` | [Int8](../sql-reference/data-types/int-uint.md) | -| `UINT16` | [UInt16](../sql-reference/data-types/int-uint.md) | -| `INT16` | [Int16](../sql-reference/data-types/int-uint.md) | -| `UINT32` | [UInt32](../sql-reference/data-types/int-uint.md) | -| `INT32` | [Int32](../sql-reference/data-types/int-uint.md) | -| `UINT64` | [UInt64](../sql-reference/data-types/int-uint.md) | -| `INT64` | [Int64](../sql-reference/data-types/int-uint.md) | -| `FLOAT` | [Float32](../sql-reference/data-types/float.md) | -| `DOUBLE` | [Float64](../sql-reference/data-types/float.md) | -| `DATE` | [Date32](../sql-reference/data-types/date32.md) | -| `TIME (ms)` | [DateTime](../sql-reference/data-types/datetime.md) | -| `TIMESTAMP`, `TIME (us, ns)` | [DateTime64](../sql-reference/data-types/datetime64.md) | -| `STRING`, `BINARY` | [String](../sql-reference/data-types/string.md) | -| `DECIMAL` | [Decimal](../sql-reference/data-types/decimal.md) | -| `LIST` | [Array](../sql-reference/data-types/array.md) | -| `STRUCT` | [Tuple](../sql-reference/data-types/tuple.md) | -| `MAP` | [Map](../sql-reference/data-types/map.md) | - -其他 Parquet 类型不被支持。默认情况下,所有推断的类型都是 `Nullable`,但可以通过设置 `schema_inference_make_columns_nullable` 进行更改。 - +在 Parquet 格式中,ClickHouse 从数据中读取其模式,并使用以下类型匹配将其转换为 ClickHouse 模式: + +| Parquet 数据类型 | ClickHouse 数据类型 | +|-------------------------------|-----------------------------------------------------| +| `BOOL` | [Bool](../sql-reference/data-types/boolean.md) | +| `UINT8` | [UInt8](../sql-reference/data-types/int-uint.md) | +| `INT8` | [Int8](../sql-reference/data-types/int-uint.md) | +| `UINT16` | [UInt16](../sql-reference/data-types/int-uint.md) | +| `INT16` | [Int16](../sql-reference/data-types/int-uint.md) | +| `UINT32` | [UInt32](../sql-reference/data-types/int-uint.md) | +| `INT32` | [Int32](../sql-reference/data-types/int-uint.md) | +| `UINT64` | [UInt64](../sql-reference/data-types/int-uint.md) | +| `INT64` | [Int64](../sql-reference/data-types/int-uint.md) | +| `FLOAT` | [Float32](../sql-reference/data-types/float.md) | +| `DOUBLE` | [Float64](../sql-reference/data-types/float.md) | +| `DATE` | [Date32](../sql-reference/data-types/date32.md) | +| `TIME (ms)` | [DateTime](../sql-reference/data-types/datetime.md) | +| `TIMESTAMP`, `TIME (us, ns)` | [DateTime64](../sql-reference/data-types/datetime64.md)| +| `STRING`, `BINARY` | [String](../sql-reference/data-types/string.md) | +| `DECIMAL` | [Decimal](../sql-reference/data-types/decimal.md) | +| `LIST` | [Array](../sql-reference/data-types/array.md) | +| `STRUCT` | [Tuple](../sql-reference/data-types/tuple.md) | +| `MAP` | [Map](../sql-reference/data-types/map.md) | + +其他 Parquet 类型不受支持。 ### Arrow {#arrow} -在 Arrow 格式中,ClickHouse 从数据中读取其模式并使用以下类型匹配将其转换为 ClickHouse 模式: - -| Arrow 数据类型 | ClickHouse 数据类型 | -|---------------------------------|---------------------------------------------------------| -| `BOOL` | [Bool](../sql-reference/data-types/boolean.md) | -| `UINT8` | [UInt8](../sql-reference/data-types/int-uint.md) | -| `INT8` | [Int8](../sql-reference/data-types/int-uint.md) | -| `UINT16` | [UInt16](../sql-reference/data-types/int-uint.md) | -| `INT16` | [Int16](../sql-reference/data-types/int-uint.md) | -| `UINT32` | [UInt32](../sql-reference/data-types/int-uint.md) | -| `INT32` | [Int32](../sql-reference/data-types/int-uint.md) | -| `UINT64` | [UInt64](../sql-reference/data-types/int-uint.md) | -| `INT64` | [Int64](../sql-reference/data-types/int-uint.md) | -| `FLOAT`, `HALF_FLOAT` | [Float32](../sql-reference/data-types/float.md) | -| `DOUBLE` | [Float64](../sql-reference/data-types/float.md) | -| `DATE32` | [Date32](../sql-reference/data-types/date32.md) | -| `DATE64` | [DateTime](../sql-reference/data-types/datetime.md) | -| `TIMESTAMP`, `TIME32`, `TIME64` | [DateTime64](../sql-reference/data-types/datetime64.md) | -| `STRING`, `BINARY` | [String](../sql-reference/data-types/string.md) | -| `DECIMAL128`, `DECIMAL256` | [Decimal](../sql-reference/data-types/decimal.md) | -| `LIST` | [Array](../sql-reference/data-types/array.md) | -| `STRUCT` | [Tuple](../sql-reference/data-types/tuple.md) | -| `MAP` | [Map](../sql-reference/data-types/map.md) | - -其他 Arrow 类型不被支持。默认情况下,所有推断的类型都是 `Nullable`,但可以通过设置 `schema_inference_make_columns_nullable` 进行更改。 - +在 Arrow 格式中,ClickHouse 从数据中读取其模式,并使用以下类型匹配将其转换为 ClickHouse 模式: + +| Arrow 数据类型 | ClickHouse 数据类型 | +|---------------------------------|-----------------------------------------------------| +| `BOOL` | [Bool](../sql-reference/data-types/boolean.md) | +| `UINT8` | [UInt8](../sql-reference/data-types/int-uint.md) | +| `INT8` | [Int8](../sql-reference/data-types/int-uint.md) | +| `UINT16` | [UInt16](../sql-reference/data-types/int-uint.md) | +| `INT16` | [Int16](../sql-reference/data-types/int-uint.md) | +| `UINT32` | [UInt32](../sql-reference/data-types/int-uint.md) | +| `INT32` | [Int32](../sql-reference/data-types/int-uint.md) | +| `UINT64` | [UInt64](../sql-reference/data-types/int-uint.md) | +| `INT64` | [Int64](../sql-reference/data-types/int-uint.md) | +| `FLOAT`, `HALF_FLOAT` | [Float32](../sql-reference/data-types/float.md) | +| `DOUBLE` | [Float64](../sql-reference/data-types/float.md) | +| `DATE32` | [Date32](../sql-reference/data-types/date32.md) | +| `DATE64` | [DateTime](../sql-reference/data-types/datetime.md) | +| `TIMESTAMP`, `TIME32`, `TIME64` | [DateTime64](../sql-reference/data-types/datetime64.md)| +| `STRING`, `BINARY` | [String](../sql-reference/data-types/string.md) | +| `DECIMAL128`, `DECIMAL256` | [Decimal](../sql-reference/data-types/decimal.md) | +| `LIST` | [Array](../sql-reference/data-types/array.md) | +| `STRUCT` | [Tuple](../sql-reference/data-types/tuple.md) | +| `MAP` | [Map](../sql-reference/data-types/map.md) | + +其他 Arrow 类型不受支持。 ### ORC {#orc} -在 ORC 格式中,ClickHouse 从数据中读取其模式并使用以下类型匹配将其转换为 ClickHouse 模式: - -| ORC 数据类型 | ClickHouse 数据类型 | -|--------------------------------------|---------------------------------------------------------| -| `Boolean` | [Bool](../sql-reference/data-types/boolean.md) | -| `Tinyint` | [Int8](../sql-reference/data-types/int-uint.md) | -| `Smallint` | [Int16](../sql-reference/data-types/int-uint.md) | -| `Int` | [Int32](../sql-reference/data-types/int-uint.md) | -| `Bigint` | [Int64](../sql-reference/data-types/int-uint.md) | -| `Float` | [Float32](../sql-reference/data-types/float.md) | -| `Double` | [Float64](../sql-reference/data-types/float.md) | -| `Date` | [Date32](../sql-reference/data-types/date32.md) | -| `Timestamp` | [DateTime64](../sql-reference/data-types/datetime64.md) | -| `String`, `Char`, `Varchar`,`BINARY` | [String](../sql-reference/data-types/string.md) | -| `Decimal` | [Decimal](../sql-reference/data-types/decimal.md) | -| `List` | [Array](../sql-reference/data-types/array.md) | -| `Struct` | [Tuple](../sql-reference/data-types/tuple.md) | -| `Map` | [Map](../sql-reference/data-types/map.md) | - -其他 ORC 类型不被支持。默认情况下,所有推断的类型都是 `Nullable`,但可以通过设置 `schema_inference_make_columns_nullable` 进行更改。 - +在 ORC 格式中,ClickHouse 从数据中读取其模式,并使用以下类型匹配将其转换为 ClickHouse 模式: + +| ORC 数据类型 | ClickHouse 数据类型 | +|--------------------------------------|-----------------------------------------------------| +| `Boolean` | [Bool](../sql-reference/data-types/boolean.md) | +| `Tinyint` | [Int8](../sql-reference/data-types/int-uint.md) | +| `Smallint` | [Int16](../sql-reference/data-types/int-uint.md) | +| `Int` | [Int32](../sql-reference/data-types/int-uint.md) | +| `Bigint` | [Int64](../sql-reference/data-types/int-uint.md) | +| `Float` | [Float32](../sql-reference/data-types/float.md) | +| `Double` | [Float64](../sql-reference/data-types/float.md) | +| `Date` | [Date32](../sql-reference/data-types/date32.md) | +| `Timestamp` | [DateTime64](../sql-reference/data-types/datetime64.md)| +| `String`, `Char`, `Varchar`, `BINARY` | [String](../sql-reference/data-types/string.md) | +| `Decimal` | [Decimal](../sql-reference/data-types/decimal.md) | +| `List` | [Array](../sql-reference/data-types/array.md) | +| `Struct` | [Tuple](../sql-reference/data-types/tuple.md) | +| `Map` | [Map](../sql-reference/data-types/map.md) | + +其他 ORC 类型不受支持。 ### Native {#native} -Native 格式在 ClickHouse 内部使用,并在数据中包含模式。 -在模式推断中,ClickHouse 从数据中读取模式而不进行任何转换。 - -## Formats with external schema {#formats-with-external-schema} - -这样的格式需要在特定模式语言的单独文件中描述数据的模式。 -为了自动推断这些格式文件的模式,ClickHouse 从单独的文件中读取外部模式并将其转换为 ClickHouse 表模式。 +本地格式在 ClickHouse 内部使用,并在数据中包含模式。 +在模式推断中,ClickHouse 从数据中读取模式,而不进行任何转换。 +## 具有外部模式的格式 {#formats-with-external-schema} +这些格式需要在特定的模式语言中以单独文件描述数据的模式。 +为了自动推断这些格式中文件的模式,ClickHouse 从单独的文件读取外部模式,并将其转换为 ClickHouse 表模式。 ### Protobuf {#protobuf} 在 Protobuf 格式的模式推断中,ClickHouse 使用以下类型匹配: -| Protobuf 数据类型 | ClickHouse 数据类型 | -|-------------------------------|---------------------------------------------------| -| `bool` | [UInt8](../sql-reference/data-types/int-uint.md) | -| `float` | [Float32](../sql-reference/data-types/float.md) | -| `double` | [Float64](../sql-reference/data-types/float.md) | -| `int32`, `sint32`, `sfixed32` | [Int32](../sql-reference/data-types/int-uint.md) | -| `int64`, `sint64`, `sfixed64` | [Int64](../sql-reference/data-types/int-uint.md) | -| `uint32`, `fixed32` | [UInt32](../sql-reference/data-types/int-uint.md) | -| `uint64`, `fixed64` | [UInt64](../sql-reference/data-types/int-uint.md) | -| `string`, `bytes` | [String](../sql-reference/data-types/string.md) | -| `enum` | [Enum](../sql-reference/data-types/enum.md) | -| `repeated T` | [Array(T)](../sql-reference/data-types/array.md) | -| `message`, `group` | [Tuple](../sql-reference/data-types/tuple.md) | - +| Protobuf 数据类型 | ClickHouse 数据类型 | +|--------------------------------|-----------------------------------------------| +| `bool` | [UInt8](../sql-reference/data-types/int-uint.md) | +| `float` | [Float32](../sql-reference/data-types/float.md) | +| `double` | [Float64](../sql-reference/data-types/float.md) | +| `int32`, `sint32`, `sfixed32` | [Int32](../sql-reference/data-types/int-uint.md) | +| `int64`, `sint64`, `sfixed64` | [Int64](../sql-reference/data-types/int-uint.md) | +| `uint32`, `fixed32` | [UInt32](../sql-reference/data-types/int-uint.md) | +| `uint64`, `fixed64` | [UInt64](../sql-reference/data-types/int-uint.md) | +| `string`, `bytes` | [String](../sql-reference/data-types/string.md) | +| `enum` | [Enum](../sql-reference/data-types/enum.md) | +| `repeated T` | [Array(T)](../sql-reference/data-types/array.md) | +| `message`, `group` | [Tuple](../sql-reference/data-types/tuple.md) | ### CapnProto {#capnproto} 在 CapnProto 格式的模式推断中,ClickHouse 使用以下类型匹配: -| CapnProto 数据类型 | ClickHouse 数据类型 | -|------------------------------------|--------------------------------------------------------| -| `Bool` | [UInt8](../sql-reference/data-types/int-uint.md) | -| `Int8` | [Int8](../sql-reference/data-types/int-uint.md) | -| `UInt8` | [UInt8](../sql-reference/data-types/int-uint.md) | -| `Int16` | [Int16](../sql-reference/data-types/int-uint.md) | -| `UInt16` | [UInt16](../sql-reference/data-types/int-uint.md) | -| `Int32` | [Int32](../sql-reference/data-types/int-uint.md) | -| `UInt32` | [UInt32](../sql-reference/data-types/int-uint.md) | -| `Int64` | [Int64](../sql-reference/data-types/int-uint.md) | -| `UInt64` | [UInt64](../sql-reference/data-types/int-uint.md) | -| `Float32` | [Float32](../sql-reference/data-types/float.md) | -| `Float64` | [Float64](../sql-reference/data-types/float.md) | -| `Text`, `Data` | [String](../sql-reference/data-types/string.md) | -| `enum` | [Enum](../sql-reference/data-types/enum.md) | -| `List` | [Array](../sql-reference/data-types/array.md) | -| `struct` | [Tuple](../sql-reference/data-types/tuple.md) | -| `union(T, Void)`, `union(Void, T)` | [Nullable(T)](../sql-reference/data-types/nullable.md) | - -## Strong-typed binary formats {#strong-typed-binary-formats} - -在这样的格式中,每个序列化值包含有关其类型(可能还有名称)的信息,但没有关于整个表的信息。 -在这些格式的模式推断中,ClickHouse 按行读取数据(最多读取 `input_format_max_rows_to_read_for_schema_inference` 行或 `input_format_max_bytes_to_read_for_schema_inference` 字节),并从数据中提取每个值的类型(可能还有名称),然后将这些类型转换为 ClickHouse 类型。 - +| CapnProto 数据类型 | ClickHouse 数据类型 | +|------------------------------------|--------------------------------------------------| +| `Bool` | [UInt8](../sql-reference/data-types/int-uint.md) | +| `Int8` | [Int8](../sql-reference/data-types/int-uint.md) | +| `UInt8` | [UInt8](../sql-reference/data-types/int-uint.md) | +| `Int16` | [Int16](../sql-reference/data-types/int-uint.md) | +| `UInt16` | [UInt16](../sql-reference/data-types/int-uint.md) | +| `Int32` | [Int32](../sql-reference/data-types/int-uint.md) | +| `UInt32` | [UInt32](../sql-reference/data-types/int-uint.md) | +| `Int64` | [Int64](../sql-reference/data-types/int-uint.md) | +| `UInt64` | [UInt64](../sql-reference/data-types/int-uint.md) | +| `Float32` | [Float32](../sql-reference/data-types/float.md) | +| `Float64` | [Float64](../sql-reference/data-types/float.md) | +| `Text`, `Data` | [String](../sql-reference/data-types/string.md) | +| `enum` | [Enum](../sql-reference/data-types/enum.md) | +| `List` | [Array](../sql-reference/data-types/array.md) | +| `struct` | [Tuple](../sql-reference/data-types/tuple.md) | +| `union(T, Void)`, `union(Void, T)` | [Nullable(T)](../sql-reference/data-types/nullable.md)| +## 强类型二进制格式 {#strong-typed-binary-formats} + +在这些格式中,每个序列化值包含其类型(可能还有其名称)的信息,但没有关于整个表的信息。 +在这样的格式的模式推断中,ClickHouse 逐行读取数据(达到 `input_format_max_rows_to_read_for_schema_inference` 行或 `input_format_max_bytes_to_read_for_schema_inference` 字节)并提取每个值的类型(可能还包括名称),然后将这些类型转换为 ClickHouse 类型。 ### MsgPack {#msgpack} -在 MsgPack 格式中,各行之间没有分隔符,要对该格式使用模式推断,您应使用设置 `input_format_msgpack_number_of_columns` 指定表中的列数。ClickHouse 使用以下类型匹配: - -| MessagePack 数据类型 (`INSERT`) | ClickHouse 数据类型 | -|--------------------------------------------------------------------|-----------------------------------------------------------| -| `int N`, `uint N`, `negative fixint`, `positive fixint` | [Int64](../sql-reference/data-types/int-uint.md) | -| `bool` | [UInt8](../sql-reference/data-types/int-uint.md) | -| `fixstr`, `str 8`, `str 16`, `str 32`, `bin 8`, `bin 16`, `bin 32` | [String](../sql-reference/data-types/string.md) | -| `float 32` | [Float32](../sql-reference/data-types/float.md) | -| `float 64` | [Float64](../sql-reference/data-types/float.md) | -| `uint 16` | [Date](../sql-reference/data-types/date.md) | -| `uint 32` | [DateTime](../sql-reference/data-types/datetime.md) | -| `uint 64` | [DateTime64](../sql-reference/data-types/datetime.md) | -| `fixarray`, `array 16`, `array 32` | [Array](../sql-reference/data-types/array.md) | -| `fixmap`, `map 16`, `map 32` | [Map](../sql-reference/data-types/map.md) | - -默认情况下,所有推断的类型都是 `Nullable`,但可以通过设置 `schema_inference_make_columns_nullable` 进行更改。 - +在 MsgPack 格式中,行之间没有分隔符,要使用此格式的模式推断,您应该使用设置 `input_format_msgpack_number_of_columns` 指定表中的列数。ClickHouse 使用以下类型匹配: + +| MessagePack 数据类型 (`INSERT`) | ClickHouse 数据类型 | +|---------------------------------------------------------------|-----------------------------------------------------| +| `int N`, `uint N`, `negative fixint`, `positive fixint` | [Int64](../sql-reference/data-types/int-uint.md) | +| `bool` | [UInt8](../sql-reference/data-types/int-uint.md) | +| `fixstr`, `str 8`, `str 16`, `str 32`, `bin 8`, `bin 16`, `bin 32` | [String](../sql-reference/data-types/string.md) | +| `float 32` | [Float32](../sql-reference/data-types/float.md) | +| `float 64` | [Float64](../sql-reference/data-types/float.md) | +| `uint 16` | [Date](../sql-reference/data-types/date.md) | +| `uint 32` | [DateTime](../sql-reference/data-types/datetime.md) | +| `uint 64` | [DateTime64](../sql-reference/data-types/datetime.md) | +| `fixarray`, `array 16`, `array 32` | [Array](../sql-reference/data-types/array.md) | +| `fixmap`, `map 16`, `map 32` | [Map](../sql-reference/data-types/map.md) | + +默认情况下,所有推断的类型都在 `Nullable` 中,但可以使用设置 `schema_inference_make_columns_nullable` 进行更改。 ### BSONEachRow {#bsoneachrow} -在 BSONEachRow 中,每行数据以 BSON 文档的形式呈现。在模式推断中,ClickHouse 逐一读取 BSON 文档并提取值、名称和数据类型,然后使用以下类型匹配将这些类型转换为 ClickHouse 类型: - -| BSON 类型 | ClickHouse 类型 | -|-----------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------| -| `\x08` boolean | [Bool](../sql-reference/data-types/boolean.md) | -| `\x10` int32 | [Int32](../sql-reference/data-types/int-uint.md) | -| `\x12` int64 | [Int64](../sql-reference/data-types/int-uint.md) | -| `\x01` double | [Float64](../sql-reference/data-types/float.md) | -| `\x09` datetime | [DateTime64](../sql-reference/data-types/datetime64.md) | -| `\x05` binary with`\x00` binary subtype, `\x02` string, `\x0E` symbol, `\x0D` JavaScript code | [String](../sql-reference/data-types/string.md) | -| `\x07` ObjectId, | [FixedString(12)](../sql-reference/data-types/fixedstring.md) | -| `\x05` binary with `\x04` uuid subtype, size = 16 | [UUID](../sql-reference/data-types/uuid.md) | -| `\x04` array | [Array](../sql-reference/data-types/array.md)/[Tuple](../sql-reference/data-types/tuple.md) (如果嵌套类型不同) | -| `\x03` document | [Named Tuple](../sql-reference/data-types/tuple.md)/[Map](../sql-reference/data-types/map.md) (带字符串键) | - -默认情况下,所有推断的类型都是 `Nullable`,但可以通过设置 `schema_inference_make_columns_nullable` 进行更改。 - -## Formats with constant schema {#formats-with-constant-schema} - -这些格式中的数据始终具有相同的模式。 - +在 BSONEachRow 中,每一行数据表示为 BSON 文档。在模式推断中,ClickHouse 逐个读取 BSON 文档,并从数据中提取值、名称和类型,然后使用以下类型匹配将这些类型转换为 ClickHouse 类型: + +| BSON 类型 | ClickHouse 类型 | +|-----------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------| +| `\x08` boolean | [Bool](../sql-reference/data-types/boolean.md) | +| `\x10` int32 | [Int32](../sql-reference/data-types/int-uint.md) | +| `\x12` int64 | [Int64](../sql-reference/data-types/int-uint.md) | +| `\x01` double | [Float64](../sql-reference/data-types/float.md) | +| `\x09` datetime | [DateTime64](../sql-reference/data-types/datetime64.md) | +| `\x05` binary with `\x00` binary subtype, `\x02` string, `\x0E` symbol, `\x0D` JavaScript code | [String](../sql-reference/data-types/string.md) | +| `\x07` ObjectId, | [FixedString(12)](../sql-reference/data-types/fixedstring.md) | +| `\x05` binary with `\x04` uuid subtype, size = 16 | [UUID](../sql-reference/data-types/uuid.md) | +| `\x04` array | [Array](../sql-reference/data-types/array.md)/[Tuple](../sql-reference/data-types/tuple.md)(如果嵌套类型不同) | +| `\x03` document | [Named Tuple](../sql-reference/data-types/tuple.md)/[Map](../sql-reference/data-types/map.md)(带有字符串键) | + +默认情况下,所有推断的类型都在 `Nullable` 中,但可以使用设置 `schema_inference_make_columns_nullable` 进行更改。 +## 具有固定模式的格式 {#formats-with-constant-schema} + +这种格式中的数据始终具有相同的模式。 ### LineAsString {#line-as-string} -在这种格式中,ClickHouse 将整个行从数据读取到具有 `String` 数据类型的单个列中。该格式的推断类型始终为 `String`,列名为 `line`。 +在此格式中,ClickHouse 从数据中将整行读取到具有 `String` 数据类型的单列中。此格式的推断类型始终为 `String`,列名为 `line`。 **示例** @@ -1457,10 +1883,9 @@ DESC format(LineAsString, 'Hello\nworld!') │ line │ String │ │ │ │ │ │ └──────┴────────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┘ ``` - ### JSONAsString {#json-as-string} -在这种格式中,ClickHouse 将整个 JSON 对象从数据读取到具有 `String` 数据类型的单个列中。该格式的推断类型始终为 `String`,列名为 `json`。 +在此格式中,ClickHouse 从数据中将整个 JSON 对象读取到具有 `String` 数据类型的单列中。此格式的推断类型始终为 `String`,列名为 `json`。 **示例** @@ -1472,10 +1897,9 @@ DESC format(JSONAsString, '{"x" : 42, "y" : "Hello, World!"}') │ json │ String │ │ │ │ │ │ └──────┴────────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┘ ``` - ### JSONAsObject {#json-as-object} -在这种格式中,ClickHouse 将整个 JSON 对象从数据读取到具有 `Object('json')` 数据类型的单个列中。该格式的推断类型始终为 `String`,列名为 `json`。 +在此格式中,ClickHouse 从数据中将整个 JSON 对象读取到具有 `Object('json')` 数据类型的单列中。此格式的推断类型始终为 `String`,列名为 `json`。 注意:此格式仅在启用 `allow_experimental_object_type` 时有效。 @@ -1489,35 +1913,33 @@ DESC format(JSONAsString, '{"x" : 42, "y" : "Hello, World!"}') SETTINGS allow_ex │ json │ Object('json') │ │ │ │ │ │ └──────┴────────────────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┘ ``` +## 模式推断模式 {#schema-inference-modes} -## Schema inference modes {#schema-inference-modes} - -从数据文件集推断模式可以在两种不同模式下工作:`default` 和 `union`。 +从一组数据文件进行模式推断可以在两种不同的模式下工作:`default` 和 `union`。 模式由设置 `schema_inference_mode` 控制。 +### 默认模式 {#default-schema-inference-mode} -### Default mode {#default-schema-inference-mode} - -在默认模式下,ClickHouse 假设所有文件具有相同的模式,并尝试通过逐个读取文件推断模式,直到成功为止。 +在默认模式中,ClickHouse 假定所有文件具有相同的模式,并尝试通过逐个读取文件来推断模式,直到成功为止。 示例: 假设我们有 3 个文件 `data1.jsonl`、`data2.jsonl` 和 `data3.jsonl`,内容如下: -`data1.jsonl`: +`data1.jsonl`: ```json {"field1" : 1, "field2" : null} {"field1" : 2, "field2" : null} {"field1" : 3, "field2" : null} ``` -`data2.jsonl`: +`data2.jsonl`: ```json {"field1" : 4, "field2" : "Data4"} {"field1" : 5, "field2" : "Data5"} {"field1" : 6, "field2" : "Data5"} ``` -`data3.jsonl`: +`data3.jsonl`: ```json {"field1" : 7, "field2" : "Data7", "field3" : [1, 2, 3]} {"field1" : 8, "field2" : "Data8", "field3" : [4, 5, 6]} @@ -1538,31 +1960,29 @@ DESC format(JSONAsString, '{"x" : 42, "y" : "Hello, World!"}') SETTINGS allow_ex └────────┴──────────────────┘ ``` -如我们所见,文件 `data3.jsonl` 中没有 `field3`。 -这是因为 ClickHouse 首先尝试从文件 `data1.jsonl` 推断模式,但由于 `field2` 仅为 null 而失败, -然后尝试从 `data2.jsonl` 推断模式并成功,所以没有读取文件 `data3.jsonl` 的数据。 +正如我们所看到的,我们没有从文件 `data3.jsonl` 中获得 `field3`。 +发生这种情况是因为 ClickHouse 首先尝试从文件 `data1.jsonl` 推断模式,由于 `field2` 只有 null,推断失败,然后尝试从 `data2.jsonl` 推断模式并成功,因此未读取来自 `data3.jsonl` 的数据。 +### 联合模式 {#default-schema-inference-mode-1} -### Union mode {#default-schema-inference-mode-1} - -在联接模式下,ClickHouse 假设文件可以具有不同的模式,因此它推断所有文件的模式,然后将它们联接到公共模式。 +在联合模式中,ClickHouse 假定文件可能具有不同的模式,因此它推断所有文件的模式,然后将它们联合为公共模式。 假设我们有 3 个文件 `data1.jsonl`、`data2.jsonl` 和 `data3.jsonl`,内容如下: -`data1.jsonl`: +`data1.jsonl`: ```json {"field1" : 1} {"field1" : 2} {"field1" : 3} ``` -`data2.jsonl`: +`data2.jsonl`: ```json {"field2" : "Data4"} {"field2" : "Data5"} {"field2" : "Data5"} ``` -`data3.jsonl`: +`data3.jsonl`: ```json {"field3" : [1, 2, 3]} {"field3" : [4, 5, 6]} @@ -1584,20 +2004,19 @@ DESC format(JSONAsString, '{"x" : 42, "y" : "Hello, World!"}') SETTINGS allow_ex └────────┴────────────────────────┘ ``` -如我们所见,我们有来自所有文件的所有字段。 +正如我们所看到的,我们从所有文件中都有所有字段。 注意: -- 由于某些文件可能不包含结果模式中的某些列,因此联接模式仅支持读取列子集的格式(如 JSONEachRow、Parquet、TSVWithNames 等),而不适用于其他格式(如 CSV、TSV、JSONCompactEachRow 等)。 -- 如果 ClickHouse 无法从某个文件推断模式,则将抛出异常。 -- 如果您有很多文件,从所有文件读取模式可能需要很长时间。 - -## Automatic format detection {#automatic-format-detection} +- 由于一些文件可能不包含结果模式中的某些列,联合模式仅支持那些支持读取列子集的格式(如 JSONEachRow、Parquet、TSVWithNames 等),且不适用于其他格式(如 CSV、TSV、JSONCompactEachRow 等)。 +- 如果 ClickHouse 无法从其中一个文件推断模式,则会抛出异常。 +- 如果您有许多文件,从所有文件读取模式可能需要很长时间。 +## 自动格式检测 {#automatic-format-detection} -如果数据格式未指定且无法通过文件扩展名确定,ClickHouse 将尝试通过其内容检测文件格式。 +如果未指定数据格式且无法通过文件扩展名确定,ClickHouse 将尝试通过内容检测文件格式。 **示例:** -假设我们有 `data`,其内容如下: +假设我们有 `data`,其内容如下: ```csv "a","b" 1,"Data1" @@ -1605,7 +2024,7 @@ DESC format(JSONAsString, '{"x" : 42, "y" : "Hello, World!"}') SETTINGS allow_ex 3,"Data3" ``` -我们可以在不指定格式或结构的情况下检查和查询此文件: +我们可以检查和查询此文件,而无需指定格式或结构: ```sql :) desc file(data); ``` @@ -1630,5 +2049,5 @@ DESC format(JSONAsString, '{"x" : 42, "y" : "Hello, World!"}') SETTINGS allow_ex ``` :::note -ClickHouse 只能检测某些格式的子集,这种检测需要一些时间,最好明确指定格式。 +ClickHouse 只能检测某些格式的子集,且这种检测需要一些时间,通常最好显式指定格式。 ::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/schema-inference.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/schema-inference.md.hash index f3cddc5850f..a8c8cf09a33 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/schema-inference.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/schema-inference.md.hash @@ -1 +1 @@ -f840ce3faca0fcd6 +946e79b12d7aec46 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/ssh.md b/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/ssh.md index 2c89ced8f07..ee3eaf19863 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/ssh.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/ssh.md @@ -1,13 +1,14 @@ --- -'description': 'ClickHouse 中 SSH 接口的文档' +'description': 'ClickHouse 中的 SSH 接口文档' 'keywords': - 'client' - 'ssh' - 'putty' -'sidebar_label': 'SSH 接口' +'sidebar_label': 'SSH Interface' 'sidebar_position': 60 'slug': '/interfaces/ssh' 'title': 'SSH 接口' +'doc_type': 'reference' --- import ExperimentalBadge from '@theme/badges/ExperimentalBadge'; @@ -21,14 +22,14 @@ import CloudNotSupportedBadge from '@theme/badges/CloudNotSupportedBadge'; ## 前言 {#preface} -ClickHouse 服务器允许使用 SSH 协议直接连接到自身。任何客户端都是允许的。 +ClickHouse 服务器允许通过 SSH 协议直接连接到自身。任何客户端均被允许。 -在创建 [数据库用户并通过 SSH 密钥进行身份验证](/knowledgebase/how-to-connect-to-ch-cloud-using-ssh-keys) 后: +在创建了一个 [由 SSH 密钥识别的数据库用户](/knowledgebase/how-to-connect-to-ch-cloud-using-ssh-keys) 后: ```sql CREATE USER abcuser IDENTIFIED WITH ssh_key BY KEY '' TYPE 'ssh-ed25519'; ``` -您可以使用此密钥连接到 ClickHouse 服务器。它将打开一个伪终端 (PTY),并启动一个 clickhouse-client 的交互式会话。 +您可以使用此密钥连接到 ClickHouse 服务器。它将打开一个伪终端 (PTY) 并启动 clickhouse-client 的交互会话。 ```bash > ssh -i ~/test_ssh/id_ed25519 abcuser@localhost -p 9022 @@ -47,17 +48,16 @@ Query id: cdd91b7f-215b-4537-b7df-86d19bf63f64 1 row in set. Elapsed: 0.002 sec. ``` -也支持通过 SSH 执行命令(非交互模式): +SSH 方式下的命令执行(非交互模式)也是支持的: ```bash > ssh -i ~/test_ssh/id_ed25519 abcuser@localhost -p 9022 "select 1" 1 ``` - ## 服务器配置 {#server-configuration} -为了启用 SSH 服务器功能,您需要取消注释或在 `config.xml` 中放置以下部分: +为了启用 SSH 服务器功能,您需要在 `config.xml` 中取消注释或添加以下部分: ```xml 9022 @@ -68,7 +68,7 @@ Query id: cdd91b7f-215b-4537-b7df-86d19bf63f64 ``` -主机密钥是 SSH 协议的重要组成部分。此密钥的公钥部分存储在客户端的 `~/.ssh/known_hosts` 文件中,通常用于防止中间人攻击。当第一次连接到服务器时,您将看到以下消息: +主机密钥是 SSH 协议的一个重要组成部分。此密钥的公钥部分存储在客户端的 `~/.ssh/known_hosts` 文件中,通常用于防止中间人攻击。当第一次连接到服务器时,您将看到以下消息: ```shell The authenticity of host '[localhost]:9022 ([127.0.0.1]:9022)' can't be established. @@ -77,9 +77,9 @@ This key is not known by any other names Are you sure you want to continue connecting (yes/no/[fingerprint])? ``` -这实际上意味着:“您是否想记住此主机的公钥并继续连接?”。 +这实际上意味着:“您是否希望记住此主机的公钥并继续连接?”。 -您可以告知您的 SSH 客户端不验证主机,通过传递一个选项: +您可以通过传递一个选项告诉您的 SSH 客户端不要验证主机: ```bash ssh -o "StrictHostKeyChecking no" user@host @@ -87,10 +87,9 @@ ssh -o "StrictHostKeyChecking no" user@host ## 配置嵌入式客户端 {#configuring-embedded-client} -您可以向嵌入式客户端传递选项,类似于普通的 `clickhouse-client`,但有一些限制。 -由于这是一个 SSH 协议,唯一向目标主机传递参数的方法是通过环境变量。 +您可以将选项传递给嵌入式客户端,类似于普通的 `clickhouse-client`,但有一些限制。由于这是 SSH 协议,传递参数到目标主机的唯一方法是通过环境变量。 -例如,设置 `format` 可以这样完成: +例如,可以通过以下方式设置 `format`: ```bash > ssh -o SetEnv="format=Pretty" -i ~/test_ssh/id_ed25519 abcuser@localhost -p 9022 "SELECT 1" @@ -101,11 +100,11 @@ ssh -o "StrictHostKeyChecking no" user@host └───┘ ``` -您可以通过这种方式更改任何用户级设置,并且还可以传递大多数普通的 `clickhouse-client` 选项(除了在此设置中没有意义的选项)。 +您可以通过这种方式更改任何用户级设置,并另外传递大多数普通的 `clickhouse-client` 选项(除了在此设置中没有意义的选项)。 -重要提示: +重要: -如果同时传递了 `query` 选项和 SSH 命令,后者将被添加到要执行的查询列表中: +如果同时传递了 `query` 选项和 SSH 命令,则后者会被添加到待执行的查询列表中: ```bash ubuntu ip-10-1-13-116@~$ ssh -o SetEnv="format=Pretty query=\"SELECT 2;\"" -i ~/test_ssh/id_ed25519 abcuser@localhost -p 9022 "SELECT 1" diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/ssh.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/ssh.md.hash index 31a30b38d65..e4c9a0d8259 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/ssh.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/ssh.md.hash @@ -1 +1 @@ -99db21f7d1693679 +d2658687c138f18c diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/tcp.md b/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/tcp.md index 89a0a783c50..8f37687b01a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/tcp.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/tcp.md @@ -4,9 +4,10 @@ 'sidebar_position': 18 'slug': '/interfaces/tcp' 'title': '本地接口 (TCP)' +'doc_type': 'reference' --- # 原生接口 (TCP) -原生协议用于 [命令行客户端](../interfaces/cli.md)、分布式查询处理期间的服务器间通信,以及其他 C++ 程序。不幸的是,原生 ClickHouse 协议尚未正式规范,但可以通过 ClickHouse 源代码进行逆向工程(从 [这里开始](https://github.com/ClickHouse/ClickHouse/tree/master/src/Client))和/或通过截取和分析 TCP 流量。 +原生协议用于 [命令行客户端](../interfaces/cli.md)、在分布式查询处理期间的服务器间通信,以及其他 C++ 程序中。不幸的是,原生 ClickHouse 协议尚未正式规范,但可以通过反向工程从 ClickHouse 源代码中获取(大约从 [这里](https://github.com/ClickHouse/ClickHouse/tree/master/src/Client) 开始)和/或通过拦截和分析 TCP 流量来获得。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/tcp.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/tcp.md.hash index d5acc6957c3..7459a7e5021 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/tcp.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/tcp.md.hash @@ -1 +1 @@ -b5f8ce197e3b7e3f +d5af93465ede6c7e diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/third-party/client-libraries.md b/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/third-party/client-libraries.md index 04ef74e1ec2..592c9ee7a3c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/third-party/client-libraries.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/third-party/client-libraries.md @@ -1,86 +1,89 @@ --- -'description': '不同编程语言可用的第三方客户端库概述' -'sidebar_label': 'Client Libraries' +'description': '不同编程语言的可用第三方客户端库概述' +'sidebar_label': '客户端库' 'sidebar_position': 26 'slug': '/interfaces/third-party/client-libraries' -'title': '第三方开发者的客户端库' +'title': '来自第三方开发者的客户端库' +'doc_type': 'reference' --- -# 第三方开发者的客户端库 +# 第三方开发的客户端库 :::note -ClickHouse Inc **不** 维护以下列出的库,并且没有进行任何广泛的测试以确保其质量。 +ClickHouse Inc 不会维护以下列出的库,并且没有做过 extensive 的测试来确保它们的质量。 ::: ### Python {#python} - - [infi.clickhouse_orm](https://github.com/Infinidat/infi.clickhouse_orm) - - [clickhouse-driver](https://github.com/mymarilyn/clickhouse-driver) - - [clickhouse-client](https://github.com/yurial/clickhouse-client) - - [aiochclient](https://github.com/maximdanilchenko/aiochclient) - - [asynch](https://github.com/long2ice/asynch) +- [Moose OLAP](https://docs.fiveonefour.com/moose/olap) +- [infi.clickhouse_orm](https://github.com/Infinidat/infi.clickhouse_orm) +- [clickhouse-driver](https://github.com/mymarilyn/clickhouse-driver) +- [clickhouse-client](https://github.com/yurial/clickhouse-client) +- [aiochclient](https://github.com/maximdanilchenko/aiochclient) +- [asynch](https://github.com/long2ice/asynch) ### PHP {#php} - - [smi2/phpclickhouse](https://packagist.org/packages/smi2/phpClickHouse) - - [8bitov/clickhouse-php-client](https://packagist.org/packages/8bitov/clickhouse-php-client) - - [bozerkins/clickhouse-client](https://packagist.org/packages/bozerkins/clickhouse-client) - - [simpod/clickhouse-client](https://packagist.org/packages/simpod/clickhouse-client) - - [seva-code/php-click-house-client](https://packagist.org/packages/seva-code/php-click-house-client) - - [SeasClick C++ client](https://github.com/SeasX/SeasClick) - - [one-ck](https://github.com/lizhichao/one-ck) - - [glushkovds/phpclickhouse-laravel](https://packagist.org/packages/glushkovds/phpclickhouse-laravel) - - [glushkovds/php-clickhouse-schema-builder](https://packagist.org/packages/glushkovds/php-clickhouse-schema-builder) - - [kolya7k ClickHouse PHP extension](https://github.com//kolya7k/clickhouse-php) - - [hyvor/clickhouse-php](https://github.com/hyvor/clickhouse-php) +- [smi2/phpclickhouse](https://packagist.org/packages/smi2/phpClickHouse) +- [8bitov/clickhouse-php-client](https://packagist.org/packages/8bitov/clickhouse-php-client) +- [bozerkins/clickhouse-client](https://packagist.org/packages/bozerkins/clickhouse-client) +- [simpod/clickhouse-client](https://packagist.org/packages/simpod/clickhouse-client) +- [seva-code/php-click-house-client](https://packagist.org/packages/seva-code/php-click-house-client) +- [SeasClick C++ client](https://github.com/SeasX/SeasClick) +- [one-ck](https://github.com/lizhichao/one-ck) +- [glushkovds/phpclickhouse-laravel](https://packagist.org/packages/glushkovds/phpclickhouse-laravel) +- [glushkovds/php-clickhouse-schema-builder](https://packagist.org/packages/glushkovds/php-clickhouse-schema-builder) +- [kolya7k ClickHouse PHP 扩展](https://github.com//kolya7k/clickhouse-php) +- [hyvor/clickhouse-php](https://github.com/hyvor/clickhouse-php) ### Go {#go} - - [clickhouse](https://github.com/kshvakov/clickhouse/) - - [go-clickhouse](https://github.com/roistat/go-clickhouse) - - [chconn](https://github.com/vahid-sohrabloo/chconn) - - [mailrugo-clickhouse](https://github.com/mailru/go-clickhouse) - - [golang-clickhouse](https://github.com/leprosus/golang-clickhouse) - - [uptrace/go-clickhouse](https://clickhouse.uptrace.dev/) +- [clickhouse](https://github.com/kshvakov/clickhouse/) +- [go-clickhouse](https://github.com/roistat/go-clickhouse) +- [chconn](https://github.com/vahid-sohrabloo/chconn) +- [mailrugo-clickhouse](https://github.com/mailru/go-clickhouse) +- [golang-clickhouse](https://github.com/leprosus/golang-clickhouse) +- [uptrace/go-clickhouse](https://clickhouse.uptrace.dev/) ### Swift {#swift} - - [ClickHouseNIO](https://github.com/patrick-zippenfenig/ClickHouseNIO) - - [ClickHouseVapor ORM](https://github.com/patrick-zippenfenig/ClickHouseVapor) +- [ClickHouseNIO](https://github.com/patrick-zippenfenig/ClickHouseNIO) +- [ClickHouseVapor ORM](https://github.com/patrick-zippenfenig/ClickHouseVapor) ### NodeJs {#nodejs} - - [clickhouse (NodeJs)](https://github.com/TimonKK/clickhouse) - - [node-clickhouse](https://github.com/apla/node-clickhouse) - - [nestjs-clickhouse](https://github.com/depyronick/nestjs-clickhouse) - - [clickhouse-client](https://github.com/depyronick/clickhouse-client) - - [node-clickhouse-orm](https://github.com/zimv/node-clickhouse-orm) - - [clickhouse-ts](https://github.com/bytadaniel/clickhouse-ts) - - [clickcache](https://github.com/bytadaniel/clickcache) +- [Moose OLAP](https://docs.fiveonefour.com/moose/olap) +- [clickhouse (NodeJs)](https://github.com/TimonKK/clickhouse) +- [node-clickhouse](https://github.com/apla/node-clickhouse) +- [nestjs-clickhouse](https://github.com/depyronick/nestjs-clickhouse) +- [clickhouse-client](https://github.com/depyronick/clickhouse-client) +- [node-clickhouse-orm](https://github.com/zimv/node-clickhouse-orm) +- [clickhouse-ts](https://github.com/bytadaniel/clickhouse-ts) +- [clickcache](https://github.com/bytadaniel/clickcache) ### Perl {#perl} - - [perl-DBD-ClickHouse](https://github.com/elcamlost/perl-DBD-ClickHouse) - - [HTTP-ClickHouse](https://metacpan.org/release/HTTP-ClickHouse) - - [AnyEvent-ClickHouse](https://metacpan.org/release/AnyEvent-ClickHouse) +- [perl-DBD-ClickHouse](https://github.com/elcamlost/perl-DBD-ClickHouse) +- [HTTP-ClickHouse](https://metacpan.org/release/HTTP-ClickHouse) +- [AnyEvent-ClickHouse](https://metacpan.org/release/AnyEvent-ClickHouse) ### Ruby {#ruby} - - [ClickHouse (Ruby)](https://github.com/shlima/click_house) - - [clickhouse-activerecord](https://github.com/PNixx/clickhouse-activerecord) +- [ClickHouse (Ruby)](https://github.com/shlima/click_house) +- [clickhouse-activerecord](https://github.com/PNixx/clickhouse-activerecord) ### Rust {#rust} - - [clickhouse.rs](https://github.com/loyd/clickhouse.rs) - - [clickhouse-rs](https://github.com/suharev7/clickhouse-rs) - - [Klickhouse](https://github.com/Protryon/klickhouse) +- [clickhouse.rs](https://github.com/loyd/clickhouse.rs) +- [clickhouse-rs](https://github.com/suharev7/clickhouse-rs) +- [Klickhouse](https://github.com/Protryon/klickhouse) ### R {#r} - - [RClickHouse](https://github.com/IMSMWU/RClickHouse) +- [RClickHouse](https://github.com/IMSMWU/RClickHouse) ### Java {#java} - - [clickhouse-client-java](https://github.com/VirtusAI/clickhouse-client-java) - - [clickhouse-client](https://github.com/Ecwid/clickhouse-client) +- [clickhouse-client-java](https://github.com/VirtusAI/clickhouse-client-java) +- [clickhouse-client](https://github.com/Ecwid/clickhouse-client) ### Scala {#scala} - - [clickhouse-scala-client](https://github.com/crobox/clickhouse-scala-client) +- [clickhouse-scala-client](https://github.com/crobox/clickhouse-scala-client) ### Kotlin {#kotlin} - - [AORM](https://github.com/TanVD/AORM) +- [AORM](https://github.com/TanVD/AORM) ### C# {#c} - - [Octonica.ClickHouseClient](https://github.com/Octonica/ClickHouseClient) - - [ClickHouse.Ado](https://github.com/killwort/ClickHouse-Net) - - [ClickHouse.Client](https://github.com/DarkWanderer/ClickHouse.Client) - - [ClickHouse.Net](https://github.com/ilyabreev/ClickHouse.Net) +- [Octonica.ClickHouseClient](https://github.com/Octonica/ClickHouseClient) +- [ClickHouse.Ado](https://github.com/killwort/ClickHouse-Net) +- [ClickHouse.Client](https://github.com/DarkWanderer/ClickHouse.Client) +- [ClickHouse.Net](https://github.com/ilyabreev/ClickHouse.Net) ### Elixir {#elixir} - - [clickhousex](https://github.com/appodeal/clickhousex/) - - [pillar](https://github.com/sofakingworld/pillar) - - [ecto_ch](https://github.com/plausible/ecto_ch) - - [req_ch](https://github.com/livebook-dev/req_ch) +- [clickhousex](https://github.com/appodeal/clickhousex/) +- [pillar](https://github.com/sofakingworld/pillar) +- [ecto_ch](https://github.com/plausible/ecto_ch) +- [req_ch](https://github.com/livebook-dev/req_ch) ### Nim {#nim} - - [nim-clickhouse](https://github.com/leonardoce/nim-clickhouse) +- [nim-clickhouse](https://github.com/leonardoce/nim-clickhouse) ### Haskell {#haskell} - - [hdbc-clickhouse](https://github.com/zaneli/hdbc-clickhouse) - - [ClickHaskell](https://clickhaskell.dev/) +- [hdbc-clickhouse](https://github.com/zaneli/hdbc-clickhouse) +- [ClickHaskell](https://clickhaskell.dev/) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/third-party/client-libraries.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/third-party/client-libraries.md.hash index 401764dc0d0..96e101a621c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/third-party/client-libraries.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/third-party/client-libraries.md.hash @@ -1 +1 @@ -1da0fe3991bb5af2 +944b793de0c77a10 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/third-party/gui.md b/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/third-party/gui.md index 392e2736dc7..4ec43f3f82f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/third-party/gui.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/third-party/gui.md @@ -1,73 +1,90 @@ --- -'description': '用于与 ClickHouse 一起工作的第三方 GUI 工具和应用程序列表' -'sidebar_label': '可视化接口' +'description': '与 ClickHouse 一起使用的第三方 GUI 工具和应用程序的列表' +'sidebar_label': '视觉界面' 'sidebar_position': 28 'slug': '/interfaces/third-party/gui' -'title': '第三方开发者的可视化接口' +'title': '来自第三方开发者的视觉界面' +'doc_type': 'reference' --- -# 来自第三方开发者的可视化接口 +# 第三方开发者的可视化接口 ## 开源 {#open-source} ### agx {#agx} -[agx](https://github.com/agnosticeng/agx) 是一款利用 Tauri 和 SvelteKit 构建的桌面应用程序,提供现代化的界面用于探索和查询使用 ClickHouse 嵌入式数据库引擎(chdb)处理的数据。 +[agx](https://github.com/agnosticeng/agx) 是一个使用 Tauri 和 SvelteKit 构建的桌面应用程序,提供了一个现代化的基于 ClickHouse 嵌入式数据库引擎 (chdb) 的数据探索和查询接口。 -- 在运行本地应用时利用 ch-db。 -- 在运行 Web 实例时可以连接到 Clickhouse 实例。 -- Monaco 编辑器让你感到熟悉。 +- 在运行本地应用程序时利用 ch-db。 +- 在运行 web 实例时可以连接到 ClickHouse 实例。 +- Monaco 编辑器,让您感到熟悉。 - 多种不断发展的数据可视化。 ### ch-ui {#ch-ui} -[ch-ui](https://github.com/caioricciuti/ch-ui) 是一个简单的 React.js 应用界面,旨在执行查询和可视化 ClickHouse 数据库的数据。它是使用 React 和 ClickHouse Web 客户端构建的,提供简洁且用户友好的 UI,方便数据库交互。 +[ch-ui](https://github.com/caioricciuti/ch-ui) 是一个简单的 React.js 应用界面,旨在为 ClickHouse 数据库执行查询和可视化数据。它使用 React 和 ClickHouse 的 web 客户端构建,提供了一个流畅且用户友好的 UI,便于数据库交互。 -特点: +功能: - ClickHouse 集成:轻松管理连接并执行查询。 - 响应式标签管理:动态处理多个标签,如查询和表标签。 -- 性能优化:利用 Indexed DB 实现高效的缓存和状态管理。 -- 本地数据存储:所有数据都在浏览器中本地存储,确保没有数据被发送到其他地方。 +- 性能优化:利用 Indexed DB 进行高效缓存和状态管理。 +- 本地数据存储:所有数据保存在浏览器本地,确保数据不被发送到其他地方。 ### ChartDB {#chartdb} -[ChartDB](https://chartdb.io) 是一款免费的开源工具,用于可视化和设计数据库架构,包括 ClickHouse,使用单个查询构建。它使用 React 构建,提供无缝且用户友好的体验,无需数据库凭据或注册即可开始使用。 +[ChartDB](https://chartdb.io) 是一个免费的开源工具,允许您通过单个查询可视化和设计数据库模式,包括 ClickHouse。它使用 React 构建,提供无缝的用户体验,无需数据库凭据或注册即可开始使用。 -特点: +功能: -- 架构可视化:即时导入和可视化你的 ClickHouse 架构,包括含有物化视图和标准视图的 ER 图,并展示表的引用。 -- AI 驱动的 DDL 导出:轻松生成 DDL 脚本以改善架构管理和文档编制。 -- 多 SQL 方言支持:兼容多种 SQL 方言,适用于不同数据库环境。 -- 无需注册或凭据:所有功能直接在浏览器中访问,保持无障碍和安全。 +- 模式可视化:即时导入并可视化您的 ClickHouse 模式,包括带物化视图和标准视图的 ER 图,显示对表的引用。 +- AI 驱动的 DDL 导出:轻松生成 DDL 脚本,以便更好地管理模式和文档。 +- 多 SQL 方言支持:兼容多种 SQL 方言,适用于各种数据库环境。 +- 无需注册或凭据:所有功能在浏览器中直接访问,方便又安全。 [ChartDB 源代码](https://github.com/chartdb/chartdb)。 +### DataPup {#datapup} + +[DataPup](https://github.com/DataPupOrg/DataPup) 是一个现代的 AI 辅助跨平台数据库客户端,支持本地 ClickHouse。 + +功能: + +- AI 驱动的 SQL 查询助手,提供智能建议 +- 原生 ClickHouse 连接支持,安全凭据处理 +- 美观,易于访问的界面,提供多种主题(浅色、深色和彩色变体) +- 高级查询结果过滤和探索 +- 跨平台支持(macOS、Windows、Linux) +- 快速响应的性能 +- 开源且 MIT 许可 + ### ClickHouse Schema Flow Visualizer {#clickhouse-schemaflow-visualizer} -一款强大的 Web 应用程序,用于使用 Mermaid.js 图表可视化 ClickHouse 表关系。 +[ClickHouse Schema Flow Visualizer](https://github.com/FulgerX2007/clickhouse-schemaflow-visualizer) 是一个强大的开源网络应用程序,使用 Mermaid.js 图表可视化 ClickHouse 表关系。可以通过直观的界面浏览数据库和表,探索表元数据,查看可选的行数和大小信息,并导出交互式模式图。 -特点: +功能: - 通过直观的界面浏览 ClickHouse 数据库和表 - 使用 Mermaid.js 图表可视化表关系 +- 颜色编码的图标匹配表类型,以便更好地可视化 - 查看表之间数据流的方向 - 将图表导出为独立的 HTML 文件 -- 使用 TLS 支持安全连接到 ClickHouse -- 适用于所有设备的响应式 Web 界面 +- 切换元数据可见性(表行和大小信息) +- 使用 TLS 支持与 ClickHouse 的安全连接 +- 支持所有设备的响应式网络界面 [ClickHouse Schema Flow Visualizer - 源代码](https://github.com/FulgerX2007/clickhouse-schemaflow-visualizer) ### Tabix {#tabix} -Tabix 项目的 ClickHouse Web 界面。 +[Tabix](https://github.com/tabixio/tabix) 项目的 ClickHouse 网络界面。 -特点: +功能: -- 从浏览器直接与 ClickHouse 交互,无需安装其他软件。 +- 直接通过浏览器与 ClickHouse 交互,无需安装额外软件。 - 带语法高亮的查询编辑器。 -- 命令的自动完成。 +- 命令自动补全。 - 查询执行的图形分析工具。 - 颜色方案选项。 @@ -75,18 +92,18 @@ Tabix 项目的 ClickHouse Web 界面。 ### HouseOps {#houseops} -[HouseOps](https://github.com/HouseOps/HouseOps) 是一个适用于 OSX、Linux 和 Windows 的 UI/IDE。 +[HouseOps](https://github.com/HouseOps/HouseOps) 是一款适用于 OSX、Linux 和 Windows 的 UI/IDE。 -特点: +功能: -- 带语法高亮的查询构建器。以表格或 JSON 视图查看响应。 +- 带语法高亮的查询构建器。可以以表格或 JSON 视图查看响应。 - 将查询结果导出为 CSV 或 JSON。 -- 包含描述的进程列表。写模式。能够停止(`KILL`)进程。 -- 数据库图,显示所有表及其列的额外信息。 +- 进程列表和描述。写入模式。可以停止 (`KILL`) 进程。 +- 数据库图。展示所有表及其列的附加信息。 - 快速查看列大小。 - 服务器配置。 -以下功能正在计划开发中: +以下功能计划开发: - 数据库管理。 - 用户管理。 @@ -97,154 +114,154 @@ Tabix 项目的 ClickHouse Web 界面。 ### LightHouse {#lighthouse} -[LightHouse](https://github.com/VKCOM/lighthouse) 是一款轻量级的 ClickHouse Web 界面。 +[LightHouse](https://github.com/VKCOM/lighthouse) 是一个轻量级的 ClickHouse 网络界面。 -特点: +功能: - 带过滤和元数据的表列表。 -- 带过滤和排序的表预览。 +- 表预览,支持过滤和排序。 - 只读查询执行。 ### Redash {#redash} -[Redash](https://github.com/getredash/redash) 是一款数据可视化平台。 +[Redash](https://github.com/getredash/redash) 是一个数据可视化平台。 -支持包括 ClickHouse 在内的多种数据源,Redash 可以将来自不同数据源的查询结果合并为一个最终数据集。 +支持多种数据源,包括 ClickHouse,Redash 可以将来自不同数据源的查询结果合并为一个最终数据集。 -特点: +功能: - 强大的查询编辑器。 - 数据库浏览器。 -- 可视化工具,可以以不同的形式表示数据。 +- 可视化工具,让您以不同形式展示数据。 ### Grafana {#grafana} -[Grafana](https://grafana.com/grafana/plugins/grafana-clickhouse-datasource/) 是一款监控和可视化平台。 +[Grafana](https://grafana.com/grafana/plugins/grafana-clickhouse-datasource/) 是一个监控和可视化平台。 -"Grafana 允许你查询、可视化、警报和理解你的指标,无论它们存储在哪里。创建、探索并与团队共享仪表板,培养数据驱动的文化。受到社区的信任和喜爱" — grafana.com。 +“Grafana 允许您查询、可视化、警报和理解您的度量,无论它们存储在哪里。创建、探索和与您的团队共享仪表板,培养数据驱动的文化。受到社区的信任和喜爱” — grafana.com。 -ClickHouse 数据源插件支持 ClickHouse 作为后端数据库。 +ClickHouse 数据源插件为 ClickHouse 作为后台数据库提供支持。 ### qryn {#qryn} -[qryn](https://metrico.in) 是一个多语言高性能可观察性栈用于 ClickHouse _(原名 cLoki)_,支持 Grafana 原生集成,允许用户获取和分析来自任何支持 Loki/LogQL、Prometheus/PromQL、OTLP/Tempo、Elastic、InfluxDB 等的代理的日志、指标和遥测跟踪。 +[qryn](https://metrico.in) 是一个多语言、高性能的 ClickHouse 观察堆栈 _(前称 cLoki)_,支持与 Grafana 的原生集成,允许用户从任何支持 Loki/LogQL、Prometheus/PromQL、OTLP/Tempo、Elastic、InfluxDB 等代理中摄取和分析日志、度量和遥测迹。 -特点: +功能: -- 内置探索 UI 和 LogQL CLI 用于查询、提取和可视化数据 -- 原生 Grafana API 支持查询、处理、摄取、追踪和无插件告警 -- 强大的管道,用于动态搜索、过滤和提取日志、事件、跟踪等数据 -- 与 LogQL、PromQL、InfluxDB、Elastic 等透明兼容的摄取和 PUSH API -- 可与 Promtail、Grafana-Agent、Vector、Logstash、Telegraf 等代理一起使用 +- 内置 Explore UI 和 LogQL CLI 用于查询、提取和可视化数据 +- 原生 Grafana API 支持查询、处理、摄取、追踪和警报,无需插件 +- 强大的管道,动态搜索、过滤和提取日志、事件、追踪及更多数据 +- 摄取和 PUSH API 与 LogQL、PromQL、InfluxDB、Elastic 及更多透明兼容 +- 与 Promtail、Grafana-Agent、Vector、Logstash、Telegraf 等代理即用即用 ### DBeaver {#dbeaver} -[DBeaver](https://dbeaver.io/) - 通用的桌面数据库客户端,支持 ClickHouse。 +[DBeaver](https://dbeaver.io/) 是一个通用的桌面数据库客户端,支持 ClickHouse。 -特点: +功能: -- 带语法高亮和自动完成功能的查询开发。 -- 带过滤器的表列表和元数据搜索。 +- 带语法高亮和自动补全的查询开发。 +- 带过滤器和元数据搜索的表列表。 - 表数据预览。 -- 完整文本搜索。 +- 全文搜索。 -默认情况下,DBeaver 不使用会话连接(例如 CLI 是如此)。如果需要会话支持(例如为会话设置设置),请编辑驱动连接属性并将 `session_id` 设置为随机字符串(它在后台使用 http 连接)。然后可以在查询窗口中使用任何设置。 +默认情况下,DBeaver 不使用会话连接(例如 CLI 会连接)。如果您需要会话支持(例如设置会话的设置),请编辑驱动程序连接属性,并将 `session_id` 设置为随机字符串(它在内部使用 http 连接)。然后,您可以从查询窗口使用任何设置。 ### clickhouse-cli {#clickhouse-cli} -[clickhouse-cli](https://github.com/hatarist/clickhouse-cli) 是一个替代的 Command-line 客户端,用于 ClickHouse,使用 Python 3 编写。 +[clickhouse-cli](https://github.com/hatarist/clickhouse-cli) 是一个替代的 ClickHouse 命令行客户端,使用 Python 3 编写。 -特点: +功能: -- 自动完成。 +- 自动补全。 - 查询和数据输出的语法高亮。 - 数据输出的分页支持。 -- 自定义 PostgreSQL 风格的命令。 +- 自定义的 PostgreSQL 风格命令。 ### clickhouse-flamegraph {#clickhouse-flamegraph} -[clickhouse-flamegraph](https://github.com/Slach/clickhouse-flamegraph) 是一个用于可视化 `system.trace_log` 的专用工具,呈现为 [flamegraph](http://www.brendangregg.com/flamegraphs.html)。 +[clickhouse-flamegraph](https://github.com/Slach/clickhouse-flamegraph) 是一个专门用于将 `system.trace_log` 可视化为 [flamegraph](http://www.brendangregg.com/flamegraphs.html) 的工具。 ### clickhouse-plantuml {#clickhouse-plantuml} -[cickhouse-plantuml](https://pypi.org/project/clickhouse-plantuml/) 是生成表架构的 [PlantUML](https://plantuml.com/) 图的脚本。 +[cickhouse-plantuml](https://pypi.org/project/clickhouse-plantuml/) 是一个生成表模式图的 [PlantUML](https://plantuml.com/) 脚本。 -### ClickHouse table graph {#clickhouse-table-graph} +### ClickHouse 表图 {#clickhouse-table-graph} -[ClickHouse table graph](https://github.com/mbaksheev/clickhouse-table-graph) 是一个简单的 CLI 工具,用于可视化 ClickHouse 表之间的依赖关系。该工具从 `system.tables` 表中检索表之间的连接,并按 [mermaid](https://mermaid.js.org/syntax/flowchart.html) 格式构建依赖流图。使用此工具可以轻松可视化表依赖关系并理解 ClickHouse 数据库中的数据流。得益于 mermaid,生成的流图看起来美观,并且可以轻松添加到你的 markdown 文档中。 +[ClickHouse table graph](https://github.com/mbaksheev/clickhouse-table-graph) 是一个简单的 CLI 工具,用于可视化 ClickHouse 表之间的依赖关系。该工具从 `system.tables` 表中检索表之间的连接,并以 [mermaid](https://mermaid.js.org/syntax/flowchart.html) 格式构建依赖关系流程图。使用此工具,您可以轻松地可视化表依赖关系并理解 ClickHouse 数据库中的数据流。得益于 mermaid,生成的流程图看起来美观且可以轻松地添加到您的 markdown 文档中。 ### xeus-clickhouse {#xeus-clickhouse} -[xeus-clickhouse](https://github.com/wangfenjin/xeus-clickhouse) 是一个 Jupyter 核心,用于 ClickHouse,支持在 Jupyter 中使用 SQL 查询 CH 数据。 +[xeus-clickhouse](https://github.com/wangfenjin/xeus-clickhouse) 是用于 ClickHouse 的 Jupyter 内核,支持在 Jupyter 中使用 SQL 查询 CH 数据。 ### MindsDB Studio {#mindsdb} -[MindsDB](https://mindsdb.com/) 是一个开源的 AI 层,适用于包括 ClickHouse 在内的数据库,允许你轻松开发、训练和部署最先进的机器学习模型。MindsDB Studio (GUI) 允许你从数据库中训练新模型,解释模型的预测,识别潜在的数据偏见,并使用可解释 AI 功能评估和可视化模型准确性,以更快地调整和优化你的机器学习模型。 +[MindsDB](https://mindsdb.com/) 是一个针对包括 ClickHouse 在内的数据库的开源 AI 层,允许您轻松开发、训练和部署最先进的机器学习模型。 MindsDB Studio(GUI)允许您从数据库训练新模型,解释模型做出的预测,识别潜在数据偏差,并使用可解释 AI 功能评估和可视化模型准确性,以更快地调整和优化机器学习模型。 ### DBM {#dbm} -[DBM](https://github.com/devlive-community/dbm) 是一个可视化管理工具,专为 ClickHouse 设计! +[DBM](https://github.com/devlive-community/dbm) 是一个 ClickHouse 的可视化管理工具! -特点: +功能: -- 支持查询历史(分页、清除所有等)。 -- 支持选择的 SQL 子句查询。 -- 支持终止查询。 -- 支持表管理(元数据、删除、预览)。 -- 支持数据库管理(删除、创建)。 -- 支持自定义查询。 -- 支持多数据源管理(连接测试、监控)。 -- 支持监控(处理器、连接、查询)。 -- 支持数据迁移。 +- 支持查询历史(分页、清空等) +- 支持选定 SQL 子句的查询 +- 支持终止查询 +- 支持表管理(元数据、删除、预览) +- 支持数据库管理(删除、创建) +- 支持自定义查询 +- 支持多个数据源管理(连接测试、监控) +- 支持监控(处理器、连接、查询) +- 支持数据迁移 ### Bytebase {#bytebase} -[Bytebase](https://bytebase.com) 是一个基于 Web 的开源架构变更和版本控制工具,适用于团队。它支持多种数据库,包括 ClickHouse。 +[Bytebase](https://bytebase.com) 是一个基于 web 的开源模式变更和版本控制工具,支持包括 ClickHouse 在内的各种数据库。 -特点: +功能: -- 开发人员和 DBA 之间的架构审查。 -- Data-as-Code,将架构在 VCS 中版本控制,比如 GitLab,并在代码提交时触发部署。 -- 提供每个环境策略的流线化部署。 +- 开发者和 DBA 之间的模式审查。 +- 数据库即代码,版本控制模式在版本控制系统(如 GitLab)中,并在代码提交时触发部署。 +- 根据环境策略简化部署。 - 完整的迁移历史。 -- 检测架构漂移。 +- 模式漂移检测。 - 备份与恢复。 -- RBAC。 +- 基于角色的访问控制(RBAC)。 ### Zeppelin-Interpreter-for-ClickHouse {#zeppelin-interpreter-for-clickhouse} -[Zeppelin-Interpreter-for-ClickHouse](https://github.com/SiderZhang/Zeppelin-Interpreter-for-ClickHouse) 是一个用于 ClickHouse 的 [Zeppelin](https://zeppelin.apache.org) 解释器。与 JDBC 解释器相比,它可以提供更好的超时控制来处理长时间运行的查询。 +[Zeppelin-Interpreter-for-ClickHouse](https://github.com/SiderZhang/Zeppelin-Interpreter-for-ClickHouse) 是一个 ClickHouse 的 [Zeppelin](https://zeppelin.apache.org) 解释器。与 JDBC 解释器相比,可以为长时间运行的查询提供更好的超时控制。 ### ClickCat {#clickcat} -[ClickCat](https://github.com/clickcat-project/ClickCat) 是一个友好的用户界面,让你搜索、探索和可视化你的 ClickHouse 数据。 +[ClickCat](https://github.com/clickcat-project/ClickCat) 是一个友好的用户界面,让您搜索、探索和可视化 ClickHouse 数据。 -特点: +功能: -- 一个在线 SQL 编辑器,可以在不安装任何软件的情况下运行你的 SQL 代码。 -- 你可以观察所有进程和变更。对于那些未完成的进程,你可以在 UI 中将其终止。 -- 指标包括集群分析、数据分析和查询分析。 +- 一个在线 SQL 编辑器,可以运行您的 SQL 代码,无需安装。 +- 您可以观察所有进程和变更。对于那些未完成的进程,您可以在 UI 中终止它们。 +- 指标包含集群分析、数据分析和查询分析。 ### ClickVisual {#clickvisual} -[ClickVisual](https://clickvisual.net/) ClickVisual 是一个轻量级的开源日志查询、分析和报警可视化平台。 +[ClickVisual](https://clickvisual.net/) ClickVisual 是一个轻量级开源日志查询、分析和报警可视化平台。 -特点: +功能: - 支持一键创建分析日志库 - 支持日志收集配置管理 - 支持用户定义的索引配置 - 支持报警配置 -- 支持库和表的权限配置 +- 支持权限粒度到库和表权限配置 ### ClickHouse-Mate {#clickmate} -[ClickHouse-Mate](https://github.com/metrico/clickhouse-mate) 是一个 Angular Web 客户端 + 用户界面,用于搜索和探索 ClickHouse 中的数据。 +[ClickHouse-Mate](https://github.com/metrico/clickhouse-mate) 是一个 Angular 网络客户端 + 用于在 ClickHouse 中搜索和探索数据的用户界面。 -特点: +功能: -- ClickHouse SQL 查询自动完成 -- 快速数据库和表树导航 +- ClickHouse SQL 查询自动补全 +- 快速的数据库和表树导航 - 高级结果过滤和排序 - 内联 ClickHouse SQL 文档 - 查询预设和历史记录 @@ -254,38 +271,54 @@ ClickHouse 数据源插件支持 ClickHouse 作为后端数据库。 ### Uptrace {#uptrace} -[Uptrace](https://github.com/uptrace/uptrace) 是一款 APM 工具,提供分布式追踪和由 OpenTelemetry 和 ClickHouse 支持的指标。 +[Uptrace](https://github.com/uptrace/uptrace) 是一个 APM 工具,提供分布式追踪和由 OpenTelemetry 与 ClickHouse 支持的度量。 -特点: +功能: -- [OpenTelemetry 追踪](https://uptrace.dev/opentelemetry/distributed-tracing.html)、指标和日志。 -- 使用 AlertManager 发送电子邮件/Slack/PagerDuty 通知。 -- 类似 SQL 的查询语言来聚合跨度。 -- 类似 PromQL 的语言来查询指标。 -- 预构建的指标仪表板。 +- [OpenTelemetry 追踪](https://uptrace.dev/opentelemetry/distributed-tracing.html)、度量和日志。 +- 使用 AlertManager 的电子邮件/Slack/PagerDuty 通知。 +- 类 SQL 的查询语言来聚合跨度。 +- 类 PromQL 的语言来查询度量。 +- 预构建的度量仪表板。 - 通过 YAML 配置支持多个用户/项目。 ### clickhouse-monitoring {#clickhouse-monitoring} -[clickhouse-monitoring](https://github.com/duyet/clickhouse-monitoring) 是一个简单的 Next.js 仪表板,依赖于 `system.*` 表来帮助监控和提供 ClickHouse 集群的概览。 +[clickhouse-monitoring](https://github.com/duyet/clickhouse-monitoring) 是一个简单的 Next.js 仪表板,依赖于 `system.*` 表以帮助监视并提供您的 ClickHouse 集群的概览。 -特点: +功能: -- 查询监控:当前查询、查询历史、查询资源(内存、读取的分区、文件打开等)、最昂贵的查询、使用最多的表或列等。 -- 集群监控:总内存/CPU 使用情况、分布式队列、全局设置、mergetree 设置、指标等。 -- 表和分区信息:大小、行数、压缩、分区大小等,按列级别详细展示。 -- 有用的工具:Zookeeper 数据探索、查询 EXPLAIN、终止查询等。 -- 可视化指标图:查询和资源使用情况、合并/变更的数量、合并性能、查询性能等。 +- 查询监视:当前查询、查询历史、查询资源(内存、读取的部分、文件打开等)、最昂贵的查询、使用最多的表或列等。 +- 集群监视:总内存/CPU 使用、分布式队列、全局设置、mergetree 设置、度量等。 +- 表和部分信息:在列级的详细信息、大小、行数、压缩、部分大小等。 +- 实用工具:Zookeeper 数据探索、查询 EXPLAIN、终止查询等。 +- 可视化度量图表:查询和资源使用情况、合并/变更次数、合并性能、查询性能等。 ### CKibana {#ckibana} -[CKibana](https://github.com/TongchengOpenSource/ckibana) 是一个轻量级服务,允许你轻松搜索、探索和可视化 ClickHouse 数据,使用原生 Kibana UI。 +[CKibana](https://github.com/TongchengOpenSource/ckibana) 是一个轻量级服务,允许您轻松搜索、探索和可视化 ClickHouse 数据,使用原生的 Kibana UI。 -特点: +功能: - 将原生 Kibana UI 的图表请求转换为 ClickHouse 查询语法。 -- 支持高级功能,如抽样和缓存,以增强查询性能。 -- 将用户从 ElasticSearch 迁移到 ClickHouse 后的学习成本降至最低。 +- 支持采样和缓存等高级功能以增强查询性能。 +- 降低从 ElasticSearch 迁移到 ClickHouse 后用户的学习成本。 + +### Telescope {#telescope} + +[Telescope](https://iamtelescope.net/) 是一个现代化的网络界面,用于探索存储在 ClickHouse 中的日志。它提供了一个用户友好的界面,用于查询、可视化和管理日志数据,并具备细粒度的访问控制。 + +功能: + +- 干净、响应迅速的 UI,配有强大的过滤器和可定制的字段选择。 +- FlyQL 语法,便于直观和表达性的日志过滤。 +- 基于时间的图表,支持分组,包括嵌套 JSON、Map 和 Array 字段。 +- 可选的原始 SQL `WHERE` 查询支持用于高级过滤(带权限检查)。 +- 保存的视图:保存并共享查询和布局的自定义 UI 配置。 +- 基于角色的访问控制(RBAC)和 GitHub 认证集成。 +- ClickHouse 端无需额外代理或组件。 + +[Telescope 源代码](https://github.com/iamtelescope/telescope) · [在线演示](https://demo.iamtelescope.net) ## 商业 {#commercial} @@ -293,107 +326,106 @@ ClickHouse 数据源插件支持 ClickHouse 作为后端数据库。 [DataGrip](https://www.jetbrains.com/datagrip/) 是 JetBrains 的数据库 IDE,专门支持 ClickHouse。它还嵌入在其他基于 IntelliJ 的工具中:PyCharm、IntelliJ IDEA、GoLand、PhpStorm 等。 -特点: +功能: -- 非常快速的代码完成。 +- 非常快速的代码补全。 - ClickHouse 语法高亮。 - 支持 ClickHouse 特有的功能,例如嵌套列、表引擎。 - 数据编辑器。 -- 重构功能。 +- 重构。 - 搜索和导航。 ### Yandex DataLens {#yandex-datalens} -[Yandex DataLens](https://cloud.yandex.ru/services/datalens) 是一项数据可视化和分析服务。 +[Yandex DataLens](https://cloud.yandex.ru/services/datalens) 是一个数据可视化和分析服务。 -特点: +功能: -- 提供广泛的可用可视化,从简单的条形图到复杂的仪表板。 -- 仪表板可以公开发布。 -- 支持多种数据源,包括 ClickHouse。 +- 广泛范围的可用可视化,涵盖简单的条形图到复杂的仪表板。 +- 仪表板可以公开可用。 +- 支持多个数据源,包括 ClickHouse。 - 基于 ClickHouse 的物化数据存储。 -DataLens 对于低负载项目,即使是商业用途,也是[免费](https://cloud.yandex.com/docs/datalens/pricing)的。 +DataLens 对于低负载项目(甚至商用)[免费提供](https://cloud.yandex.com/docs/datalens/pricing)。 - [DataLens 文档](https://cloud.yandex.com/docs/datalens/)。 -- [教程](https://cloud.yandex.com/docs/solutions/datalens/data-from-ch-visualization) 关于从 ClickHouse 数据库可视化数据。 +- [教程](https://cloud.yandex.com/docs/solutions/datalens/data-from-ch-visualization) 分享如何可视化 ClickHouse 数据库中的数据。 ### Holistics Software {#holistics-software} [Holistics](https://www.holistics.io/) 是一个全栈数据平台和商业智能工具。 -特点: +功能: -- 自动化的电子邮件、Slack 和 Google Sheet 报告调度。 -- 具备可视化、版本控制、自动完成、可重用查询组件和动态过滤的 SQL 编辑器。 +- 自动电子邮件、Slack 和 Google Sheet 报告的调度。 +- 带可视化、版本控制、自动补全、可重用查询组件和动态过滤器的 SQL 编辑器。 - 通过 iframe 嵌入报告和仪表板的分析。 - 数据准备和 ETL 能力。 -- 支持关系数据映射的 SQL 数据建模。 +- 支持关系数据的 SQL 数据建模。 ### Looker {#looker} -[Looker](https://looker.com) 是一个数据平台和商业智能工具,支持 50 多种数据库方言,包括 ClickHouse。Looker 可用作 SaaS 平台和自托管。用户可以通过浏览器使用 Looker 探索数据、构建可视化和仪表板、安排报告并与同事分享他们的见解。Looker 提供了一整套丰富的工具用于在其他应用程序中嵌入这些功能,并提供 API 来将数据与其他应用程序集成。 +[Looker](https://looker.com) 是一个数据平台和商业智能工具,支持 50 多种数据库方言,包括 ClickHouse。Looker 作为 SaaS 平台和自托管的版本可用。用户可以通过浏览器使用 Looker 探索数据、构建可视化和仪表板、安排报告,并与同事分享见解。Looker 提供丰富的工具,将这些功能嵌入到其他应用程序中,以及一个 API 用于将数据集成到其他应用程序。 -特点: +功能: -- 使用 LookML 进行简单灵活的开发,该语言支持策划的 - [数据建模](https://looker.com/platform/data-modeling),为报告编写者和最终用户提供支持。 -- 通过 Looker 的 [数据操作](https://looker.com/platform/actions) 进行强大的工作流集成。 +- 使用 LookML 轻松而灵活的开发,这是一种支持策划 [数据建模](https://looker.com/platform/data-modeling) 的语言,以支持报告撰写者和最终用户。 +- 通过 Looker 的 [数据操作](https://looker.com/platform/actions) 实现强大的工作流集成。 -[如何在 Looker 中配置 ClickHouse](https://docs.looker.com/setup-and-management/database-config/clickhouse)。 +[如何在 Looker 中配置 ClickHouse。](https://docs.looker.com/setup-and-management/database-config/clickhouse) ### SeekTable {#seektable} -[SeekTable](https://www.seektable.com) 是一个自助式 BI 工具,用于数据探索和操作报告。它既提供云服务,也提供自托管版本。来自 SeekTable 的报告可以嵌入到任何 Web 应用中。 +[SeekTable](https://www.seektable.com) 是一款自助 BI 工具,用于数据探索和操作报告。它同时提供云服务和自托管版本。SeekTable 的报告可以嵌入到任何网络应用程序中。 -特点: +功能: -- 适合业务用户的报告构建器。 -- 强大的报告参数,用于 SQL 过滤和特定报告查询的自定义。 -- 可以通过原生 TCP/IP 端点和 HTTP(S) 接口(2 个不同的驱动程序)连接到 ClickHouse。 -- 可以在维度/度量定义中使用 ClickHouse SQL 方言的所有强大功能。 -- [Web API](https://www.seektable.com/help/web-api-integration) 用于自动报告生成。 -- 支持报告开发流程的账户数据 [备份/恢复](https://www.seektable.com/help/self-hosted-backup-restore);数据模型(立方体)/报告配置为可人读的 XML,并可以存储在版本控制系统中。 +- 适合业务用户的友好报告构建器。 +- 强大的报告参数,用于 SQL 过滤和报告特定查询的自定义。 +- 可以通过原生 TCP/IP 端点和 HTTP(S) 接口连接到 ClickHouse(两种不同的驱动)。 +- 借助 ClickHouse SQL 方言的所有强大能力,可以在维度/度量定义中使用。 +- [Web API](https://www.seektable.com/help/web-api-integration) 用于自动生成报告。 +- 支持报告开发流程的帐户数据 [备份/恢复](https://www.seektable.com/help/self-hosted-backup-restore);数据模型(立方体)/报告配置是可读的 XML,可以存储在版本控制系统中。 -SeekTable 对于个人/个体使用是[免费的](https://www.seektable.com/help/cloud-pricing)。 +SeekTable 对于个人/个人使用是 [免费的](https://www.seektable.com/help/cloud-pricing)。 -[如何在 SeekTable 中配置 ClickHouse 连接](https://www.seektable.com/help/clickhouse-pivot-table)。 +[如何在 SeekTable 中配置 ClickHouse 连接。](https://www.seektable.com/help/clickhouse-pivot-table) ### Chadmin {#chadmin} -[Chadmin](https://github.com/bun4uk/chadmin) 是一个简单的 UI,您可以在其中可视化您当前正在 ClickHouse 集群上运行的查询及其相关信息,并在需要时终止它们。 +[Chadmin](https://github.com/bun4uk/chadmin) 是一个简单的 UI,您可以在其中可视化当前正在运行的 ClickHouse 集群查询及其信息,并根据需要终止它们。 ### TABLUM.IO {#tablum_io} -[TABLUM.IO](https://tablum.io/) — 一个用于 ETL 和可视化的在线查询和分析工具。它允许连接到 ClickHouse,通过多功能 SQL 控制台查询数据,同时也可以从静态文件和第三方服务加载数据。TABLUM.IO 可以将数据结果可视化为图表和表格。 +[TABLUM.IO](https://tablum.io/) 是一个在线查询和分析工具,用于 ETL 和可视化。它允许连接到 ClickHouse,通过多功能 SQL 控制台查询数据,以及从静态文件和第三方服务加载数据。TABLUM.IO 可以将数据结果可视化为图表和表格。 -特点: +功能: - ETL:从流行数据库、本地和远程文件、API 调用加载数据。 -- 多功能 SQL 控制台,带有语法高亮和可视化查询构建器。 +- 多功能 SQL 控制台,带语法高亮和可视化查询构建器。 - 数据可视化为图表和表格。 - 数据物化和子查询。 -- 通过 Slack、Telegram 或电子邮件的数据报告。 -- 通过专有 API 的数据流水线。 -- 数据导出为 JSON、CSV、SQL、HTML 格式。 +- 向 Slack、Telegram 或电子邮件报告数据。 +- 通过专有 API 进行数据管道处理。 +- 以 JSON、CSV、SQL、HTML 格式导出数据。 - 基于 Web 的界面。 -TABLUM.IO 可以作为自托管解决方案(作为 Docker 镜像)或云中运行。 +TABLUM.IO 可以作为自托管解决方案(作为 docker 镜像)或云端运行。 许可证:[商业](https://tablum.io/pricing) 产品,提供 3 个月的免费期。 -在云中免费试用[直接体验](https://tablum.io/try)。 -在 [TABLUM.IO](https://tablum.io/) 上了解更多关于该产品的信息。 +在[云中](https://tablum.io/try)免费试用。 +了解更多关于该产品的信息,请访问 [TABLUM.IO](https://tablum.io/)。 ### CKMAN {#ckman} -[CKMAN](https://www.github.com/housepower/ckman) 是一个管理和监控 ClickHouse 集群的工具! +[CKMAN](https://www.github.com/housepower/ckman) 是一个工具,用于管理和监控 ClickHouse 集群! -特点: +功能: -- 通过浏览器界面快速便捷地自动部署集群。 -- 集群可以进行快速扩展或收缩。 -- 对集群数据进行负载均衡。 -- 在线升级集群。 -- 在页面上修改集群配置。 -- 提供集群节点和 Zookeeper 监控。 -- 监控表和分区的状态,并监控慢 SQL 语句。 -- 提供易于使用的 SQL 执行页面。 +- 通过浏览器接口快速方便地自动部署集群 +- 集群可以扩展或缩减 +- 负载均衡集群的数据 +- 在线升级集群 +- 在页面上修改集群配置 +- 提供集群节点监控和 Zookeeper 监控 +- 监控表和分区的状态,监控慢 SQL 语句 +- 提供一个易于使用的 SQL 执行页面 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/third-party/gui.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/third-party/gui.md.hash index a6b957ebe10..c3f8a572f62 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/third-party/gui.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/third-party/gui.md.hash @@ -1 +1 @@ -f43e6063d49fbc97 +2d0c11b383f029ec diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/third-party/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/third-party/index.md index 3486967eac9..beea78f75b7 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/third-party/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/third-party/index.md @@ -4,18 +4,19 @@ 'slug': '/interfaces/third-party/' 'toc_folder_title': 'Third-Party' 'title': '第三方接口' +'doc_type': 'landing-page' --- # 第三方接口 -这是一个链接集合,指向提供某种接口到 ClickHouse 的第三方工具。它可以是可视化接口、命令行接口或 API: +这是指向提供某种接口给 ClickHouse 的第三方工具的链接集合。它可以是可视化接口、命令行接口或 API: - [客户端库](../../interfaces/third-party/client-libraries.md) - [集成](../../interfaces/third-party/integrations.md) -- [图形用户界面](../../interfaces/third-party/gui.md) +- [GUI](../../interfaces/third-party/gui.md) - [代理](../../interfaces/third-party/proxy.md) :::note -支持通用 API 的通用工具,如 [ODBC](../../interfaces/odbc.md) 或 [JDBC](../../interfaces/jdbc.md),通常也可以与 ClickHouse 一起使用,但因为数量太多,未在此列出。 +支持常见 API 的通用工具,如 [ODBC](../../interfaces/odbc.md) 或 [JDBC](../../interfaces/jdbc.md),通常也可以与 ClickHouse 一起使用,但这里未列出,因为它们的数量实在太多。 ::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/third-party/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/third-party/index.md.hash index 82da9158585..79800cafb8e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/third-party/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/third-party/index.md.hash @@ -1 +1 @@ -65ea52337bab2cf0 +30294c6e25f04e3b diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/third-party/integrations.md b/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/third-party/integrations.md index 92b70085f34..1051ece553e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/third-party/integrations.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/third-party/integrations.md @@ -1,118 +1,193 @@ --- -'description': '有关将 ClickHouse 与各种第三方系统和工具集成的文档' +'description': '关于将 ClickHouse 与各种第三方系统和工具集成的文档' 'sidebar_label': '集成' 'sidebar_position': 27 'slug': '/interfaces/third-party/integrations' 'title': '第三方开发者的集成库' +'doc_type': 'reference' --- # 第三方开发者的集成库 -:::note 注意 -ClickHouse, Inc. **不**维护下面列出的工具和库,也没有进行广泛测试以确保其质量。 +:::warning 免责声明 +ClickHouse, Inc. **不** 维护以下列出的工具和库,也未进行广泛测试以确保它们的质量。 +有关官方集成,请参见 [集成页面](/integrations). ::: ## 基础设施产品 {#infrastructure-products} -- 关系数据库管理系统 - - [MySQL](https://www.mysql.com) - - [mysql2ch](https://github.com/long2ice/mysql2ch) - - [ProxySQL](https://github.com/sysown/proxysql/wiki/ClickHouse-Support) - - [clickhouse-mysql-data-reader](https://github.com/Altinity/clickhouse-mysql-data-reader) - - [horgh-replicator](https://github.com/larsnovikov/horgh-replicator) - - [PostgreSQL](https://www.postgresql.org) - - [clickhousedb_fdw](https://github.com/Percona-Lab/clickhousedb_fdw) - - [infi.clickhouse_fdw](https://github.com/Infinidat/infi.clickhouse_fdw) (使用 [infi.clickhouse_orm](https://github.com/Infinidat/infi.clickhouse_orm)) - - [pg2ch](https://github.com/mkabilov/pg2ch) - - [clickhouse_fdw](https://github.com/adjust/clickhouse_fdw) - - [MSSQL](https://en.wikipedia.org/wiki/Microsoft_SQL_Server) - - [ClickHouseMigrator](https://github.com/zlzforever/ClickHouseMigrator) -- 消息队列 - - [Kafka](https://kafka.apache.org) - - [clickhouse_sinker](https://github.com/housepower/clickhouse_sinker) (使用 [Go client](https://github.com/ClickHouse/clickhouse-go/)) - - [stream-loader-clickhouse](https://github.com/adform/stream-loader) -- 批处理 - - [Spark](https://spark.apache.org) - - [spark-clickhouse-connector](https://github.com/housepower/spark-clickhouse-connector) -- 流处理 - - [Flink](https://flink.apache.org) - - [flink-clickhouse-sink](https://github.com/ivi-ru/flink-clickhouse-sink) -- 对象存储 - - [S3](https://en.wikipedia.org/wiki/Amazon_S3) - - [clickhouse-backup](https://github.com/AlexAkulov/clickhouse-backup) -- 容器编排 - - [Kubernetes](https://kubernetes.io) - - [clickhouse-operator](https://github.com/Altinity/clickhouse-operator) -- 配置管理 - - [puppet](https://puppet.com) - - [innogames/clickhouse](https://forge.puppet.com/innogames/clickhouse) - - [mfedotov/clickhouse](https://forge.puppet.com/mfedotov/clickhouse) -- 监控 - - [Graphite](https://graphiteapp.org) - - [graphouse](https://github.com/ClickHouse/graphouse) - - [carbon-clickhouse](https://github.com/lomik/carbon-clickhouse) - - [graphite-clickhouse](https://github.com/lomik/graphite-clickhouse) - - [graphite-ch-optimizer](https://github.com/innogames/graphite-ch-optimizer) - 优化在 [*GraphiteMergeTree](/engines/table-engines/mergetree-family/graphitemergetree) 中好运用配置的过期分区,如果可以应用 [rollup configuration](../../engines/table-engines/mergetree-family/graphitemergetree.md#rollup-configuration) 里的规则 - - [Grafana](https://grafana.com/) - - [clickhouse-grafana](https://github.com/Vertamedia/clickhouse-grafana) - - [Prometheus](https://prometheus.io/) - - [clickhouse_exporter](https://github.com/f1yegor/clickhouse_exporter) - - [PromHouse](https://github.com/Percona-Lab/PromHouse) - - [clickhouse_exporter](https://github.com/hot-wifi/clickhouse_exporter) (使用 [Go client](https://github.com/kshvakov/clickhouse/)) - - [Nagios](https://www.nagios.org/) - - [check_clickhouse](https://github.com/exogroup/check_clickhouse/) - - [check_clickhouse.py](https://github.com/innogames/igmonplugins/blob/master/src/check_clickhouse.py) - - [Zabbix](https://www.zabbix.com) - - [clickhouse-zabbix-template](https://github.com/Altinity/clickhouse-zabbix-template) - - [Sematext](https://sematext.com/) - - [clickhouse integration](https://github.com/sematext/sematext-agent-integrations/tree/master/clickhouse) -- 日志 - - [rsyslog](https://www.rsyslog.com/) - - [omclickhouse](https://www.rsyslog.com/doc/master/configuration/modules/omclickhouse.html) - - [fluentd](https://www.fluentd.org) - - [loghouse](https://github.com/flant/loghouse) (用于 [Kubernetes](https://kubernetes.io)) - - [logagent](https://www.sematext.com/logagent) - - [logagent output-plugin-clickhouse](https://sematext.com/docs/logagent/output-plugin-clickhouse/) -- 地理 - - [MaxMind](https://dev.maxmind.com/geoip/) - - [clickhouse-maxmind-geoip](https://github.com/AlexeyKupershtokh/clickhouse-maxmind-geoip) -- AutoML - - [MindsDB](https://mindsdb.com/) - - [MindsDB](https://github.com/mindsdb/mindsdb) - 与 ClickHouse 集成,使 ClickHouse 的数据可用于多种 AI/ML 模型。 +

+关系数据库管理系统 + +- [MySQL](https://www.mysql.com) + - [mysql2ch](https://github.com/long2ice/mysql2ch) + - [ProxySQL](https://github.com/sysown/proxysql/wiki/ClickHouse-Support) + - [clickhouse-mysql-data-reader](https://github.com/Altinity/clickhouse-mysql-data-reader) + - [horgh-replicator](https://github.com/larsnovikov/horgh-replicator) +- [PostgreSQL](https://www.postgresql.org) + - [clickhousedb_fdw](https://github.com/Percona-Lab/clickhousedb_fdw) + - [infi.clickhouse_fdw](https://github.com/Infinidat/infi.clickhouse_fdw) (使用 [infi.clickhouse_orm](https://github.com/Infinidat/infi.clickhouse_orm)) + - [pg2ch](https://github.com/mkabilov/pg2ch) + - [clickhouse_fdw](https://github.com/adjust/clickhouse_fdw) +- [MSSQL](https://en.wikipedia.org/wiki/Microsoft_SQL_Server) + - [ClickHouseMigrator](https://github.com/zlzforever/ClickHouseMigrator) +
+ +
+消息队列 + +- [Kafka](https://kafka.apache.org) + - [clickhouse_sinker](https://github.com/housepower/clickhouse_sinker) (使用 [Go client](https://github.com/ClickHouse/clickhouse-go/)) + - [stream-loader-clickhouse](https://github.com/adform/stream-loader) +
+ +
+批处理 + +- [Spark](https://spark.apache.org) + - [spark-clickhouse-connector](https://github.com/housepower/spark-clickhouse-connector) +
+ +
+流处理 + +- [Flink](https://flink.apache.org) + - [flink-clickhouse-sink](https://github.com/ivi-ru/flink-clickhouse-sink) +
+ +
+对象存储 + +- [S3](https://en.wikipedia.org/wiki/Amazon_S3) + - [clickhouse-backup](https://github.com/AlexAkulov/clickhouse-backup) +
+ +
+容器编排 + +- [Kubernetes](https://kubernetes.io) + - [clickhouse-operator](https://github.com/Altinity/clickhouse-operator) +
+ +
+配置管理 +- [puppet](https://puppet.com) + - [innogames/clickhouse](https://forge.puppet.com/innogames/clickhouse) + - [mfedotov/clickhouse](https://forge.puppet.com/mfedotov/clickhouse) +
+ +
+监控 + +- [Graphite](https://graphiteapp.org) + - [graphouse](https://github.com/ClickHouse/graphouse) + - [carbon-clickhouse](https://github.com/lomik/carbon-clickhouse) + - [graphite-clickhouse](https://github.com/lomik/graphite-clickhouse) + - [graphite-ch-optimizer](https://github.com/innogames/graphite-ch-optimizer) - 如果 [rollup configuration](../../engines/table-engines/mergetree-family/graphitemergetree.md#rollup-configuration) 的规则可以应用,则优化 [\*GraphiteMergeTree](/engines/table-engines/mergetree-family/graphitemergetree) 中的过期分区 +- [Grafana](https://grafana.com/) + - [clickhouse-grafana](https://github.com/Vertamedia/clickhouse-grafana) +- [Prometheus](https://prometheus.io/) + - [clickhouse_exporter](https://github.com/f1yegor/clickhouse_exporter) + - [PromHouse](https://github.com/Percona-Lab/PromHouse) + - [clickhouse_exporter](https://github.com/hot-wifi/clickhouse_exporter) (使用 [Go client](https://github.com/kshvakov/clickhouse/)) +- [Nagios](https://www.nagios.org/) + - [check_clickhouse](https://github.com/exogroup/check_clickhouse/) + - [check_clickhouse.py](https://github.com/innogames/igmonplugins/blob/master/src/check_clickhouse.py) +- [Zabbix](https://www.zabbix.com) + - [clickhouse-zabbix-template](https://github.com/Altinity/clickhouse-zabbix-template) +- [Sematext](https://sematext.com/) + - [clickhouse 集成](https://github.com/sematext/sematext-agent-integrations/tree/master/clickhouse) +
+ +
+日志记录 + +- [rsyslog](https://www.rsyslog.com/) + - [omclickhouse](https://www.rsyslog.com/doc/master/configuration/modules/omclickhouse.html) +- [fluentd](https://www.fluentd.org) + - [loghouse](https://github.com/flant/loghouse) (用于 [Kubernetes](https://kubernetes.io)) +- [logagent](https://www.sematext.com/logagent) + - [logagent output-plugin-clickhouse](https://sematext.com/docs/logagent/output-plugin-clickhouse/) +
+ +
+地理 + +- [MaxMind](https://dev.maxmind.com/geoip/) + - [clickhouse-maxmind-geoip](https://github.com/AlexeyKupershtokh/clickhouse-maxmind-geoip) +
+ +
+AutoML + +- [MindsDB](https://mindsdb.com/) + - [MindsDB](https://github.com/mindsdb/mindsdb) - 与 ClickHouse 集成,使 ClickHouse 中的数据可用于多种 AI/ML 模型。 +
## 编程语言生态系统 {#programming-language-ecosystems} -- Python - - [SQLAlchemy](https://www.sqlalchemy.org) - - [sqlalchemy-clickhouse](https://github.com/cloudflare/sqlalchemy-clickhouse) (使用 [infi.clickhouse_orm](https://github.com/Infinidat/infi.clickhouse_orm)) - - [PyArrow/Pandas](https://pandas.pydata.org) - - [Ibis](https://github.com/ibis-project/ibis) -- PHP - - [Doctrine](https://www.doctrine-project.org/) - - [dbal-clickhouse](https://packagist.org/packages/friendsofdoctrine/dbal-clickhouse) -- R - - [dplyr](https://db.rstudio.com/dplyr/) - - [RClickHouse](https://github.com/IMSMWU/RClickHouse) (使用 [clickhouse-cpp](https://github.com/artpaul/clickhouse-cpp)) -- Java - - [Hadoop](http://hadoop.apache.org) - - [clickhouse-hdfs-loader](https://github.com/jaykelin/clickhouse-hdfs-loader) (使用 [JDBC](../../sql-reference/table-functions/jdbc.md)) -- Scala - - [Akka](https://akka.io) - - [clickhouse-scala-client](https://github.com/crobox/clickhouse-scala-client) -- C# - - [ADO.NET](https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/ado-net-overview) - - [ClickHouse.Ado](https://github.com/killwort/ClickHouse-Net) - - [ClickHouse.Client](https://github.com/DarkWanderer/ClickHouse.Client) - - [ClickHouse.Net](https://github.com/ilyabreev/ClickHouse.Net) - - [ClickHouse.Net.Migrations](https://github.com/ilyabreev/ClickHouse.Net.Migrations) - - [Linq To DB](https://github.com/linq2db/linq2db) -- Elixir - - [Ecto](https://github.com/elixir-ecto/ecto) - - [clickhouse_ecto](https://github.com/appodeal/clickhouse_ecto) -- Ruby - - [Ruby on Rails](https://rubyonrails.org/) - - [activecube](https://github.com/bitquery/activecube) - - [ActiveRecord](https://github.com/PNixx/clickhouse-activerecord) - - [GraphQL](https://github.com/graphql) - - [activecube-graphql](https://github.com/bitquery/activecube-graphql) +
+Python + +- [SQLAlchemy](https://www.sqlalchemy.org) + - [sqlalchemy-clickhouse](https://github.com/cloudflare/sqlalchemy-clickhouse) (使用 [infi.clickhouse_orm](https://github.com/Infinidat/infi.clickhouse_orm)) +- [PyArrow/Pandas](https://pandas.pydata.org) + - [Ibis](https://github.com/ibis-project/ibis) +
+ +
+PHP + +- [Doctrine](https://www.doctrine-project.org/) + - [dbal-clickhouse](https://packagist.org/packages/friendsofdoctrine/dbal-clickhouse) +
+ +
+R + +- [dplyr](https://db.rstudio.com/dplyr/) + - [RClickHouse](https://github.com/IMSMWU/RClickHouse) (使用 [clickhouse-cpp](https://github.com/artpaul/clickhouse-cpp)) +
+ +
+Java + +- [Hadoop](http://hadoop.apache.org) + - [clickhouse-hdfs-loader](https://github.com/jaykelin/clickhouse-hdfs-loader) (使用 [JDBC](../../sql-reference/table-functions/jdbc.md)) +
+ +
+Scala + +- [Akka](https://akka.io) + - [clickhouse-scala-client](https://github.com/crobox/clickhouse-scala-client) +
+ +
+C# + +- [ADO.NET](https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/ado-net-overview) + - [ClickHouse.Ado](https://github.com/killwort/ClickHouse-Net) + - [ClickHouse.Client](https://github.com/DarkWanderer/ClickHouse.Client) + - [ClickHouse.Net](https://github.com/ilyabreev/ClickHouse.Net) + - [ClickHouse.Net.Migrations](https://github.com/ilyabreev/ClickHouse.Net.Migrations) + - [Linq To DB](https://github.com/linq2db/linq2db) +
+ +
+Elixir + +- [Ecto](https://github.com/elixir-ecto/ecto) + - [clickhouse_ecto](https://github.com/appodeal/clickhouse_ecto) +
+ +
+Ruby + +- [Ruby on Rails](https://rubyonrails.org/) + - [activecube](https://github.com/bitquery/activecube) + - [ActiveRecord](https://github.com/PNixx/clickhouse-activerecord) +- [GraphQL](https://github.com/graphql) + - [activecube-graphql](https://github.com/bitquery/activecube-graphql) +
diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/third-party/integrations.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/third-party/integrations.md.hash index 70950006183..e3c5911a879 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/third-party/integrations.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/third-party/integrations.md.hash @@ -1 +1 @@ -3432c4470888dff6 +30abe725765b519b diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/third-party/proxy.md b/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/third-party/proxy.md index 55d8c9abd4a..25ce51b4d18 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/third-party/proxy.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/third-party/proxy.md @@ -1,13 +1,14 @@ --- -'description': '描述可用的第三方代理解决方案用于 ClickHouse' +'description': '描述可用于 ClickHouse 的第三方代理解决方案' 'sidebar_label': 'Proxies' 'sidebar_position': 29 'slug': '/interfaces/third-party/proxy' -'title': '第三方开发者的代理服务器' +'title': '来自第三方开发者的代理服务器' +'doc_type': 'reference' --- -# 来自第三方开发者的代理服务器 +# 第三方开发者的代理服务器 ## chproxy {#chproxy} @@ -15,23 +16,23 @@ 特点: -- 用户级路由和响应缓存。 +- 每用户路由和响应缓存。 - 灵活的限制。 -- 自动 SSL 证书续订。 +- 自动 SSL 证书续期。 -用 Go 实现。 +使用 Go 实现。 ## KittenHouse {#kittenhouse} -[KittenHouse](https://github.com/VKCOM/kittenhouse) 旨在充当 ClickHouse 与应用服务器之间的本地代理,以防在应用程序端缓存 INSERT 数据不便或不可能。 +[KittenHouse](https://github.com/VKCOM/kittenhouse) 旨在充当 ClickHouse 与应用服务器之间的本地代理,以便在无法或不便在应用一侧缓冲 INSERT 数据时使用。 特点: - 内存和磁盘数据缓冲。 -- 每个表的路由。 +- 每表路由。 - 负载均衡和健康检查。 -用 Go 实现。 +使用 Go 实现。 ## ClickHouse-Bulk {#clickhouse-bulk} @@ -39,8 +40,8 @@ 特点: -- 按阈值或间隔分组请求并发送。 +- 分组请求并按照阈值或时间间隔发送。 - 多个远程服务器。 - 基本身份验证。 -用 Go 实现。 +使用 Go 实现。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/third-party/proxy.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/third-party/proxy.md.hash index bbc71f9f551..97ca4d3fb36 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/third-party/proxy.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/third-party/proxy.md.hash @@ -1 +1 @@ -cb2b904d8971f99f +329afd1661d5f606 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/intro.md b/i18n/zh/docusaurus-plugin-content-docs/current/intro.md index ddbc2701804..0b07daf73b3 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/intro.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/intro.md @@ -1,8 +1,9 @@ --- 'slug': '/intro' 'sidebar_label': '什么是 ClickHouse?' -'description': 'ClickHouse® 是一个面向列的 SQL 数据库管理系统 (DBMS),用于在线分析处理 (OLAP)。它既可以作为开源软件提供,也可以作为云服务提供。' +'description': 'ClickHouse® 是一个面向列的 SQL 数据库管理系统(DBMS),用于在线分析处理(OLAP)。它同时以开源软件和云服务的形式提供。' 'title': '什么是 ClickHouse?' +'doc_type': 'guide' --- import column_example from '@site/static/images/column-oriented-example-query.png'; @@ -10,27 +11,27 @@ import row_orientated from '@site/static/images/row-oriented.gif'; import column_orientated from '@site/static/images/column-oriented.gif'; import Image from '@theme/IdealImage'; -ClickHouse® 是一个高性能的、面向列的 SQL 数据库管理系统 (DBMS),适用于在线分析处理 (OLAP)。它可作为 [开源软件](https://github.com/ClickHouse/ClickHouse) 和 [云服务](https://clickhouse.com/cloud) 提供。 +ClickHouse® 是一个高性能、列式的 SQL 数据库管理系统 (DBMS),用于在线分析处理 (OLAP)。它既可以作为 [开源软件](https://github.com/ClickHouse/ClickHouse) 提供,也可以作为 [云服务](https://clickhouse.com/cloud) 提供。 ## 什么是分析? {#what-are-analytics} -分析,也称为 OLAP(在线分析处理),是指在大规模数据集上执行复杂计算(例如聚合、字符串处理、算术)的 SQL 查询。 +分析,亦称为 OLAP(在线分析处理),指的是对庞大数据集进行复杂计算(例如,聚合、字符串处理、算术运算)的 SQL 查询。 -与只读取和写入每个查询仅几行的事务查询(或 OLTP,在线事务处理)不同,分析查询通常处理数十亿或数万亿行数据。 +与事务查询(或 OLTP,在线事务处理)不同,后者每个查询只读取和写入少量行,因此完成时间通常在毫秒内,分析查询则常常处理数十亿或数万亿行。 -在许多用例中,[分析查询必须是“实时的”](https://clickhouse.com/engineering-resources/what-is-real-time-analytics),即结果必须在一秒钟以内返回。 +在许多用例中,[分析查询必须是“实时的”](https://clickhouse.com/engineering-resources/what-is-real-time-analytics),即在一秒钟以内返回结果。 -## 行式 vs 列式存储 {#row-oriented-vs-column-oriented-storage} +## 行式存储 vs. 列式存储 {#row-oriented-vs-column-oriented-storage} -这样的性能水平只能通过正确的数据“方向”来实现。 +如此高的性能只能通过正确的数据“方向”来实现。 -数据库要么以 [行式存储,或者列式存储](https://clickhouse.com/engineering-resources/what-is-columnar-database)。 +数据库可以 [行式或列式存储](https://clickhouse.com/engineering-resources/what-is-columnar-database) 数据。 -在行式数据库中,连续的表行依次顺序存储。此布局允许快速检索行,因为每行的列值被一起存储。 +在行式数据库中,连续的表行是一个接一个按顺序存储的。这种布局使得快速检索行成为可能,因为每行的列值是一起存储的。 -ClickHouse 是一个面向列的数据库。在此类系统中,表作为列的集合存储,即每列的值顺序存储在一起。这种布局使恢复单行变得更加困难(因为行值之间存在空隙),但列操作,例如过滤或聚合,比行式数据库要快得多。 +ClickHouse 是一个列式数据库。在这种系统中,表作为列的集合存储,即每列的值依次存储在一起。这种布局使得恢复单行变得更加困难(因为行值之间存在间隙),但类似过滤或聚合这样的列操作比行式数据库快得多。 -差异可以通过一个示例查询来解释,该查询在 1 亿行的 [现实世界匿名 web 分析数据](/getting-started/example-datasets/metrica) 上运行: +这个差异通过一个查询示例能更好地解释,该查询操作超过 1 亿行的 [真实世界匿名网络分析数据](/getting-started/example-datasets/metrica): ```sql SELECT MobilePhoneModel, COUNT() AS c @@ -46,46 +47,46 @@ ORDER BY c DESC LIMIT 8; ``` -您可以在 [ClickHouse SQL Playground](https://sql.clickhouse.com?query=U0VMRUNUIE1vYmlsZVBob25lTW9kZWwsIENPVU5UKCkgQVMgYyAKRlJPTSBtZXRyaWNhLmhpdHMgCldIRVJFIAogICAgICBSZWdpb25JRCA9IDIyOSAKICBBTkQgRXZlbnREYXRlID49ICcyMDEzLTA3LTAxJyAKICBBTkQgRXZlbnREYXRlIDw9ICcyMDEzLTA3LTMxJyAKICBBTkQgTW9iaWxlUGhvbmUgIT0gMCAKICBBTkQgTW9iaWxlUGhvbmVNb2RlbCBub3QgaW4gWycnLCAnaVBhZCddIApHUk9VUCBCWSBNb2JpbGVQaG9uZU1vZGVsCk9SREVSIEJZIGMgREVTQyAKTElNSVQgODs&chart=eyJ0eXBlIjoicGllIiwiY29uZmlnIjp7InhheGlzIjoiTW9iaWxlUGhvbmVNb2RlbCIsInlheGlzIjoiYyJ9fQ&run_query=true) 上运行此查询,该查询选择和过滤了 [100 多个现有列中的几个](https://sql.clickhouse.com/?query=U0VMRUNUIG5hbWUKRlJPTSBzeXN0ZW0uY29sdW1ucwpXSEVSRSBkYXRhYmFzZSA9ICdtZXRyaWNhJyBBTkQgdGFibGUgPSAnaGl0cyc7&tab=results&run_query=true),在毫秒内返回结果: +您可以在 [ClickHouse SQL Playground](https://sql.clickhouse.com?query=U0VMRUNUIE1vYmlsZVBob25lTW9kZWwsIENPVU5UKCkgQVMgYyAKRlJPTSBtZXRyaWNhLmhpdHMgCldIRVJFIAogICAgICBSZWdpb25JRCA9IDIyOSAKICBBTkQgRXZlbnREYXRlID49ICcyMDEzLTA3LTAxJyAKICBBTkQgRXZlbnREYXRlIDw9ICcyMDEzLTA3LTMxJyAKICBBTkQgTW9iaWxlUGhvbmUgIT0gMCAKICBBTkQgTW9iaWxlUGhvbmVNb2RlbCBub3QgaW4gWycnLCAnaVBhZCddIApHUk9VUCBCWSBNb2JpbGVQaG9uZU1vZGVsCk9SREVSIEJZIGMgREVTQyAKTElNSVQgODs&chart=eyJ0eXBlIjoicGllIiwiY29uZmlnIjp7InhheGlzIjoiTW9iaWxlUGhvbmVNb2RlbCIsInhleGlzIjoiYyJ9fQ&run_query=true) 上运行此查询,该查询选择并过滤 [仅从超过 100 个现有列中](https://sql.clickhouse.com/?query=U0VMRUNUIG5hbWUKRlJPTSBzeXN0ZW0uY29sdW1ucwpXSEVSRSBkYXRhYmFzZSA9ICdtZXRyaWNhJyBBTkQgdGFibGUgPSAnaGl0cyc7&tab=results&run_query=true) 的列,返回结果的时间在毫秒内: - + -正如您在上图的统计部分所看到的,该查询在 92 毫秒内处理了 1 亿行,吞吐量约为 3 亿行,或者不到每秒 7 GB。 +如上图的统计部分所示,该查询在 92 毫秒内处理了 1 亿行,吞吐量约为每秒超过 10 亿行或每秒近 7 GB 数据传输。 **行式 DBMS** -在行式数据库中,即使上面的查询仅处理现有列中的几个,系统仍然需要从磁盘加载其他现有列的数据到内存中。这是因为数据存储在称为 [块](https://en.wikipedia.org/wiki/Block_(data_storage)) 的块中(通常是固定大小,例如 4 KB 或 8 KB)。块是从磁盘读取到内存的最小数据单元。当应用程序或数据库请求数据时,操作系统的磁盘 I/O 子系统从磁盘读取所需的块。即使只需要块的一部分,整个块也会被读入内存(这是由于磁盘和文件系统的设计): +在行式数据库中,即使上述查询只处理了少量现有列,系统仍然需要从磁盘加载其他现有列的数据到内存。原因是数据以被称为 [块](https://en.wikipedia.org/wiki/Block_(data_storage)) 的块存储在磁盘上(通常为固定大小,例如 4 KB 或 8 KB)。块是从磁盘读取到内存的最小数据单位。当应用程序或数据库请求数据时,操作系统的磁盘 I/O 子系统会从磁盘读取所需的块。即使只需要块的一部分,整个块也会被读入内存(这是由于磁盘和文件系统设计所致): **列式 DBMS** -由于每列的值在磁盘上是顺序存储的,因此在运行上述查询时不会加载不必要的数据。 -由于块级存储和从磁盘到内存的传输与分析查询的数据访问模式对齐,因此仅读取查询所需的列数据,从而避免了对未使用数据的不必要 I/O。这与行式存储相比,[速度快得多](https://benchmark.clickhouse.com/),因为整行(包括不相关的列)都被读取: +由于每列的值按顺序一个接一个地存储在磁盘上,因此在运行上述查询时不会加载不必要的数据。 +由于按块存储和从磁盘到内存的传输与分析查询的数据访问模式相一致,仅从磁盘读取查询所需的列,从而避免了对未使用数据的不必要 I/O。与行式存储相比,这 [要快得多](https://benchmark.clickhouse.com/),在行式存储中,整个行(包括不相关的列)都会被读取: -## 数据复制和完整性 {#data-replication-and-integrity} +## 数据复制与完整性 {#data-replication-and-integrity} -ClickHouse 使用异步多主复制方案,以确保数据在多个节点上冗余存储。在写入任何可用副本后,所有剩余副本在后台检索其副本。系统在不同副本上维护相同的数据。在大多数故障后,恢复是自动进行的,复杂情况时则为半自动。 +ClickHouse 使用异步多主复制方案,以确保数据在多个节点上冗余存储。在写入任何可用副本后,所有剩余副本会在后台获取其副本。系统在不同副本间保持相同的数据。大多数故障后的恢复是自动执行的,复杂情况下则为半自动执行。 ## 基于角色的访问控制 {#role-based-access-control} -ClickHouse 使用 SQL 查询实现用户帐户管理,并允许进行基于角色的访问控制配置,类似于 ANSI SQL 标准和流行的关系数据库管理系统中找到的配置。 +ClickHouse 实现了基于 SQL 查询的用户账户管理,并允许配置基于角色的访问控制,类似于 ANSI SQL 标准和流行关系数据库管理系统中的配置。 ## SQL 支持 {#sql-support} -ClickHouse 支持基于 SQL 的 [声明性查询语言](/sql-reference),在许多情况下与 ANSI SQL 标准相同。支持的查询子句包括 [GROUP BY](/sql-reference/statements/select/group-by)、[ORDER BY](/sql-reference/statements/select/order-by)、[FROM](/sql-reference/statements/select/from) 中的子查询、[JOIN](/sql-reference/statements/select/join) 子句、[IN](/sql-reference/operators/in) 操作符、[窗口函数](/sql-reference/window-functions) 和标量子查询。 +ClickHouse 支持 [基于 SQL 的声明式查询语言](/sql-reference),在许多情况下与 ANSI SQL 标准是相同的。支持的查询子句包括 [GROUP BY](/sql-reference/statements/select/group-by)、[ORDER BY](/sql-reference/statements/select/order-by)、[FROM](/sql-reference/statements/select/from)中的子查询、[JOIN](/sql-reference/statements/select/join) 子句、[IN](/sql-reference/operators/in) 运算符、[窗口函数](/sql-reference/window-functions) 和标量子查询。 ## 近似计算 {#approximate-calculation} -ClickHouse 提供了一些方法来在性能和准确性之间进行权衡。例如,它的一些聚合函数大致计算不同值的数量、中位数和分位数。此外,可以在数据样本上运行查询以快速计算近似结果。最后,可以使用有限的键运行聚合,而不是对所有键进行聚合。根据键的分布情况,这可以提供一个合理准确的结果,使用的资源远少于精确计算。 +ClickHouse 提供以性能换取准确性的方法。例如,它的一些聚合函数约算特定值计数、中位数和分位数。此外,可以在数据的样本上运行查询以快速计算近似结果。最后,聚合可以在有限数量的键上运行,而不是对所有键进行聚合。根据键的分布不均程度,这可以提供一个合理准确的结果,且所需的资源远低于精确计算。 ## 自适应连接算法 {#adaptive-join-algorithms} -ClickHouse 自适应选择连接算法,它首先使用快速哈希连接,如果有多个大型表,则退回到合并连接。 +ClickHouse 自适应选择连接算法:它从快速的散列连接开始,如果存在多个大型表,则回退到合并连接。 ## 优越的查询性能 {#superior-query-performance} ClickHouse 以极快的查询性能而闻名。 -要了解 ClickHouse 为什么如此快速,请参阅 [ClickHouse 为什么快?](/concepts/why-clickhouse-is-so-fast.md) 指南。 +要了解 ClickHouse 为什么如此快速,请参阅 [ClickHouse 为什么快?](/concepts/why-clickhouse-is-so-fast.mdx) 指南。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/intro.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/intro.md.hash index cea0727ea58..a71e2c5b870 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/intro.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/intro.md.hash @@ -1 +1 @@ -5a6818c76e3f49bc +d836a58b4d05f77d diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/introduction-index.md b/i18n/zh/docusaurus-plugin-content-docs/current/introduction-index.md index 96844710626..7bab996ea07 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/introduction-index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/introduction-index.md @@ -3,14 +3,15 @@ 'title': '介绍' 'description': '介绍的登录页面' 'pagination_next': null +'doc_type': 'landing-page' --- -欢迎来到 ClickHouse!请查看下面的页面,以了解如何快速上手 ClickHouse - 这是最快、最资源高效的实时数据仓库和开源数据库。 +欢迎来到 ClickHouse!请查看以下页面,以了解如何快速启动和运行 ClickHouse - 这个最快、最资源高效的实时数据仓库和开源数据库。 | 页面 | 描述 | |------------------------------------------------|--------------------------------------------------------------------| -| [What is ClickHouse?](about-us/intro.mdx) | 了解更多关于 ClickHouse 的信息。 | -| [Quick Start](quick-start.mdx) | 快速入门指南,帮助您迅速开始使用。 | -| [Advanced Tutorial](tutorial.md) | 熟悉基础知识?让我们做一些更有趣的事情。 | -| [Install](getting-started/install/install.mdx) | 了解几种安装 ClickHouse 的不同方式。 | -| [Deployment modes](deployment-modes.md) | 本指南探讨了四种主要的部署和使用 ClickHouse 的方式。 | +| [What is ClickHouse?](intro) | 了解有关 ClickHouse 的更多信息。 | +| [Quick Start](/get-started/quick-start) | 快速入门指南,让您迅速启动并运行。 | +| [Advanced Tutorial](tutorial.md) | 对基础知识感到满意了吗?让我们做一些更有趣的事情。 | +| [Install](getting-started/install/install.mdx) | 了解您可以安装 ClickHouse 的各种方式。 | +| [Deployment modes](deployment-modes.md) | 本指南探讨了部署和使用 ClickHouse 的四种主要方式。 | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/introduction-index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/introduction-index.md.hash index fa303f7278c..66f9413b646 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/introduction-index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/introduction-index.md.hash @@ -1 +1 @@ -3b59897ea50f266a +b55f261bfb1c2412 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/academic_overview.mdx b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/academic_overview.mdx index f6b0e862e94..248487d887e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/academic_overview.mdx +++ b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/academic_overview.mdx @@ -1,10 +1,11 @@ --- 'slug': '/academic_overview' 'title': '架构概述' -'description': '我们 2024 VLDB 论文的文档版本' +'description': '我们2024年VLDB论文的文档版本' 'keywords': - 'architecture' 'show_related_blogs': true +'doc_type': 'guide' --- import useBrokenLinks from "@docusaurus/useBrokenLinks"; @@ -30,395 +31,396 @@ export function Anchor(props) { return ; } -这是我们[VLDB 2024](https://www.vldb.org/pvldb/vol17/p3731-schulze.pdf)科学论文的网页版。我们还[在博客中](https://clickhouse.com/blog/first-clickhouse-research-paper-vldb-lightning-fast-analytics-for-everyone)讨论了它的背景和发展历程,并推荐观看 ClickHouse 首席技术官和创始人 Alexey Milovidov 在 VLDB 2024 的演讲: +这是我们 [VLDB 2024 科学论文](https://www.vldb.org/pvldb/vol17/p3731-schulze.pdf) 的网页版。我们还 [在博客中](https://clickhouse.com/blog/first-clickhouse-research-paper-vldb-lightning-fast-analytics-for-everyone) 介绍了它的背景和发展历程,并建议观看 ClickHouse CTO 和创始人 Alexey Milovidov 的 VLDB 2024 演讲: ## 摘要 {#abstract} -在过去几十年里,存储和分析的数据量急剧增加。各个行业和领域的企业开始依赖这些数据来改进产品、评估表现并做出影响业务的决策。然随着数据量日益成为互联网规模,企业需要以具有成本效益和可扩展的方式管理历史数据和新数据,同时使用大量并发查询进行分析,并期望实时延迟(例如,取决于用例,一秒钟以内)。 +在过去的几十年里,存储和分析的数据量呈指数增长。各行业和领域的企业开始依赖这些数据来改善产品、评估绩效和做出与业务相关的重要决策。然而,随着数据量越来越大,企业需要以经济有效、可扩展的方式管理历史数据和新数据,同时使用大量的并发查询分析数据,并期望实现实时延迟(例如,根据用例的不同,低于一秒)。 -本文概述了 ClickHouse,这是一种流行的开源 OLAP 数据库,旨在对具有高 ingest 速率的 PB 级大型数据集进行高性能分析。其存储层结合了一种基于传统日志结构合并(LSM)树的数据格式和用于后台历史数据连续转换(如聚合、归档)的新技术。查询使用便捷的 SQL 方言编写,并由一流的向量化查询执行引擎处理,支持可选的代码编译。ClickHouse 积极使用修剪技术,以避免在查询中评估无关数据。其他数据管理系统可以在表函数、表引擎或数据库引擎级别进行集成。现实世界的基准测试表明,ClickHouse 是市场上速度最快的分析数据库之一。 -## 1 引言 {#1-introduction} +本文概述了 ClickHouse,一种流行的开源 OLAP 数据库,旨在处理高性能分析,适用于具有高摄取率的 PB 级数据集。其存储层结合了基于传统日志结构合并(LSM)树的数据格式与用于历史数据持续转换的新技术(例如聚合、归档)背景下的。查询使用方便的 SQL 方言编写,并由最先进的向量化查询执行引擎处理,并支持可选的代码编译。ClickHouse 大量使用剪枝技术,以避免在查询中评估不相关的数据。其他数据管理系统可以在表函数、^^table engine^^ 或数据库引擎级别进行集成。实际基准测试表明,ClickHouse 是市场上速度最快的分析数据库之一。 +## 1 引言 {#1-introduction} -本文描述了 ClickHouse,一种专为具有万亿行和数百列的表上的高性能分析查询而设计的列式 OLAP 数据库。ClickHouse 于2009年[启动](https://clickhou.se/evolution),最初作为 web 规模日志文件数据的过滤和聚合操作符,并于2016年开源。[图 1](#page-1-0) 说明了本文中描述的主要功能何时被引入 ClickHouse。 +本文描述了 ClickHouse,一种设计用于处理高性能分析查询的列式 OLAP 数据库,适用于行数达到数万亿和列数达到数百的表。ClickHouse 于 2009 年 [启动](https://clickhou.se/evolution),最初作为大规模 Web 日志数据的过滤和聚合运算符,并于 2016 年开源。 [图 1](#page-1-0) 描述了本文中介绍的主要功能首次引入 ClickHouse 的时间。 -ClickHouse 旨在解决现代分析数据管理的五个关键挑战: +ClickHouse 的设计旨在应对现代分析数据管理的五个关键挑战: -1. **巨大的数据集和高 ingest 速率**。许多数据驱动的应用程序,如网络分析、金融和电子商务,其特征是数据量巨大且不断增长。为了处理巨大的数据集,分析数据库不仅必须提供有效的索引和压缩策略,还必须允许跨多个节点(扩展)进行数据分布,因为单个服务器的存储限制在几十 TB。此外,最新数据通常比历史数据对实时洞察更为关键。因此,分析数据库必须能够以一致的高速度或突发方式插入新数据,并能够持续“降低优先级”(例如,聚合,归档)历史数据,而不降低并行报告查询的速度。 +1. **巨大的数据集和高摄取率**。许多数据驱动的应用程序,如网络分析、金融和电子商务,通常具有持续增长的巨大数据量。为了处理巨大的数据集,分析数据库不仅必须提供有效的索引和压缩策略,还应允许数据分布在多个节点之间(水平扩展),因为单台服务器的存储限制通常在几十 TB。 此外,最近的数据对实时洞察更为相关,这使得分析数据库必须能够以一致的高速度或以突发的方式摄取新数据,同时在不减慢并行报告查询的情况下,持续“低优先级处理”(例如聚合、归档)历史数据。 -2. **许多并发查询,并期望低延迟**。查询一般可以分为 ad-hoc(例如探索性数据分析)和定期(例如周期性仪表板查询)。用例越具互动性,期望的查询延迟就越低,这导致了查询优化和执行中的挑战。定期查询还提供了适应工作负载的物理数据库布局的机会。因此,数据库应提供修剪技术,允许优化频繁查询。根据查询优先级,数据库还必须授予对共享系统资源(例如 CPU、内存、磁盘和网络 I/O)的平等或优先访问,即使在大量查询同时运行的情况下。 +2. **许多并发查询并期望低延迟**。查询通常可以分为临时查询(例如探索性数据分析)或周期性查询(例如定期仪表板查询)。用例越互动,查询的延迟期望就越低,这就导致了查询优化和执行中的挑战。周期性查询还提供了一种机会,可以根据工作负载调整物理数据库布局。因此,数据库应提供剪枝技术,以优化频繁查询。根据查询优先级,数据库必须进一步保障对共享系统资源(如 CPU、内存、磁盘和网络 I/O)的平等或优先访问,即使大量查询同时运行。 -3. **多种数据存储、存储位置和格式**。为了与现有数据架构集成,现代分析数据库应表现出高程度的开放性,以读取和写入任何系统、位置或格式的外部数据。 +3. **多样化的数据存储、存储位置和格式**。为了与现有的数据架构集成,现代分析数据库应表现出高程度的开放性,以在任何系统、位置或格式中读取和写入外部数据。 -4. **方便的查询语言和性能自我检查支持**。OLAP 数据库的实际使用提出了额外的“软”要求。例如,用户通常更希望用一种表现力强的 SQL 方言与数据库进行交互,而不是使用小众编程语言,这种 SQL 方言应支持嵌套数据类型和广泛的常规、聚合和窗口函数。分析数据库还应提供复杂的工具,以自我检查系统或单个查询的性能。 +4. **一种便捷的查询语言,支持性能内省**。OLAP 数据库的实际使用提出了额外的“软”需求。例如,用户通常更喜欢使用一种具表现力的 SQL 方言与数据库接口,而不是专门的编程语言,支持嵌套数据类型和广泛的常规、聚合和窗口函数。分析数据库还应提供复杂的工具,以对系统或单个查询的性能进行内省。 -5. **行业级的稳健性和多功能部署**。由于商品硬件不可靠,数据库必须提供数据复制,以抵抗节点故障。此外,数据库应能在任何硬件上运行,从旧的笔记本电脑到强大的服务器。最后,为了避免 JVM 程序中的垃圾回收开销并实现裸金属性能(例如 SIMD),数据库理想情况下以目标平台的本机二进制形式部署。 +5. **行业级的鲁棒性和多样的部署**。由于商品硬件的可靠性较差,数据库必须提供数据复制以应对节点故障。此外,数据库应在任何硬件上运行,从旧笔记本电脑到强大的服务器。最后,为避免在基于 JVM 的程序中产生垃圾收集的开销并实现裸金属性能(例如 SIMD),数据库理想上作为目标平台的本机二进制文件进行部署。 - + -图 1:ClickHouse 时间线。 +图 1: ClickHouse 时间线。 ## 2 架构 {#2-architecture} - + -图 2:ClickHouse 数据库引擎的高层架构。 +图 2: ClickHouse 数据库引擎的高层架构示意图。 -如[图 2](#page-2-0)所示,ClickHouse 引擎分为三个主要层:查询处理层(在第 [4](#page-6-0) 节中描述),存储层(第 [3](#page-1-1) 节),和集成层(第 [5](#page-9-0) 节)。除此之外,访问层管理用户会话和通过不同协议与应用程序的通信。有关线程、缓存、基于角色的访问控制、备份和连续监控的正交组件。ClickHouse 建立在 C++ 上,是一个单一的、静态链接的二进制文件,没有依赖关系。 +正如 [图 2](#page-2-0) 所示,ClickHouse 引擎分为三个主要层次:查询处理层(在第 [4 节](#page-6-0) 中描述)、存储层(第 [3 节](#page-1-1))和集成层(第 [5 节](#page-9-0))。此外,访问层管理用户会话和通过不同协议与应用程序的通信。还有正交组件用于线程管理、缓存、基于角色的访问控制、备份和持续监控。ClickHouse 使用 C++ 构建,作为一个没有依赖关系的单一静态链接二进制文件。 -查询处理遵循传统的解析 incoming 查询、构建和优化逻辑和物理查询计划、执行等范式。ClickHouse 使用类似于 MonetDB/X100 [\[11\]](#page-12-0) 的向量化执行模型,并结合机会性代码编译 [\[53\]](#page-13-0)。查询可以用丰富的 SQL 方言、PRQL [\[76\]](#page-13-1) 或 Kusto 的 KQL [\[50\]](#page-13-2) 编写。 +查询处理遵循传统的范式,解析传入的查询,构建和优化逻辑和物理查询计划,并执行。ClickHouse 使用类似 MonetDB/X100 [\[11\]](#page-12-0) 的向量化执行模型,并结合机会式代码编译 [\[53\]](#page-13-0)。查询可以用功能丰富的 SQL 方言、PRQL [\[76\]](#page-13-1),或 Kusto 的 KQL [\[50\]](#page-13-2) 编写。 -存储层由不同的表引擎组成,封装了表数据的格式和位置。表引擎分为三类:第一类是 MergeTree* 表引擎家族,它代表了 ClickHouse 中的主要持久化格式。基于 LSM 树的思路 [\[60\]](#page-13-3),表按水平方式分割成已排序的部分,并由后台过程不断合并。每个 MergeTree* 表引擎在其输入部分合并行的方式上有所不同。例如,行可以被聚合或替换,如果它们过时。 +存储层由不同的表引擎组成,这些引擎封装了表数据的格式和位置。表引擎分为三类:第一类是 ^^MergeTree^^*系列表引擎,代表了 ClickHouse 中的主要持久性格式。基于 LSM 树的理念 [\[60\]](#page-13-3),表被拆分成水平、已排序的 ^^parts^^,并由后台进程持续合并。这些 ^^MergeTree^^* 表引擎在合并输入的 ^^parts^^ 行的方式上有所不同。例如,行可以被聚合或替换,若是过时的。 -第二类是特殊目的的表引擎,用于加速或分配查询执行。此类引擎包括称为字典的内存键值表引擎。一个[字典](https://clickhou.se/dictionaries)缓存周期性执行对内部或外部数据源的查询结果。这在容许数据陈旧的场景中显著减少了访问延迟。其他类型的特殊目的表引擎包括用于临时表的纯内存引擎和用于透明数据分片的 Distributed 表引擎(见下文)。 +第二类是特殊用途的表引擎,用于加速或分布查询执行。这一类包括内存中的键值表引擎,称为字典。[字典](https://clickhou.se/dictionaries) 缓存定期执行的内部或外部数据源的查询结果。这显著降低了在可以容忍数据陈旧的场景中的访问延迟。其他特殊用途表引擎的例子包括用于临时表的纯内存引擎和用于透明数据分片的 ^^Distributed table^^ 引擎(见下文)。 -第三类表引擎是虚拟表引擎,用于与外部系统(如关系数据库(例如 PostgreSQL、MySQL)、发布/订阅系统(例如 Kafka、RabbitMQ [\[24\]](#page-12-1))或键/值存储(例如 Redis))进行双向数据交换。虚拟引擎还可以与数据湖(例如 Iceberg、DeltaLake、Hudi [\[36\]](#page-12-2))或对象存储中的文件(例如 AWS S3、Google GCP)进行交互。 +第三类表引擎是用于与外部系统(如关系数据库(例如 PostgreSQL、MySQL)、发布/订阅系统(例如 Kafka、RabbitMQ [\[24\]](#page-12-1))或键值存储(例如 Redis))进行双向数据交换的虚拟表引擎。虚拟引擎还可以与数据湖(例如 Iceberg、DeltaLake、Hudi [\[36\]](#page-12-2))或对象存储中的文件(例如 AWS S3、Google GCP)进行交互。 -ClickHouse 支持跨多个集群节点对表的分片和复制,以实现可伸缩性和可用性。分片将表按照分片表达式划分为一组表分片。各个分片是相互独立的表,通常位于不同的节点上。客户端可以直接读取和写入分片,即将其视为单独的表,或使用 Distributed 特殊表引擎,该引擎提供所有表分片的全局视图。分片的主要目的是处理超过单个节点容量的数据集(通常是几十 TB 的数据)。分片的另一个用途是将表的读写负载分配到多个节点上,即负载平衡。与之正交的是,分片可以在多个节点之间复制,以抵抗节点故障。为此,每个 MergeTree* 表引擎都有一个相应的 ReplicatedMergeTree* 引擎,它使用基于 Raft 共识的多主协调方案 [\[59\]](#page-13-4)(通过 [Keeper](https://clickhou.se/keeper) 实现,它是用 C++ 编写的 Apache Zookeeper 的替代品)来保证每个分片时刻具有配置数量的副本。第 3.6 节详细讨论了复制机制。作为一个示例,图 2 显示了一个包含两个副本的表,每个副本复制到两个节点上。 +ClickHouse 支持在多个 ^^cluster^^ 节点之间对表进行分片和复制,以实现可扩展性和可用性。分片根据分片表达式将表分割为一组表分片。各个分片是相互独立的表,通常位于不同的节点上。客户端可以直接读写分片,即将其视为独立的表,或使用 Distributed 特殊的 ^^table engine^^,它提供对所有表分片的全局视图。分片的主要目的在于处理超过单个节点容量(通常为几十 TB 数据)的数据集。分片的另一个用途是将表的读写负载分配到多个节点上,即负载均衡。与之正交的是,^^shard^^ 可以在多个节点上复制,以容忍节点故障。为此,每个 Merge-Tree* ^^table engine^^ 都有一个相应的 ReplicatedMergeTree* 引擎,该引擎使用基于 Raft 共识的多主协调方案 [\[59\]](#page-13-4)(由 [Keeper](https://clickhou.se/keeper) 实现,一个用 C++ 编写的可以替代 Apache Zookeeper 的工具)来确保每个 ^^shard^^ 在任何时候都有一个可配置数量的副本。第 [3.6 节](#page-5-0) 将详细讨论复制机制。作为示例,[图 2](#page-2-0) 显示了一个具有两个分片的表,每个分片复制到两个节点。 -最后,ClickHouse 数据库引擎可以在本地、云、自主或进程内模式下运行。在本地模式中,用户将 ClickHouse 本地设置为单服务器或具有分片和/或复制的多节点集群。客户端通过原生协议、MySQL 协议、PostgreSQL 的二进制协议或 HTTP REST API 与数据库通信。云模式由 ClickHouse Cloud 代表,这是一个全托管和自动扩展的 DBaaS 产品。虽然本文重点介绍本地模式,但我们计划在后续出版物中描述 ClickHouse Cloud 的架构。[独立模式](https://clickhou.se/local-fastest-tool) 将 ClickHouse 转变为用于分析和转换文件的命令行工具,使其成为 Unix 工具(如 cat 和 grep)的 SQL 基础替代品。虽然这不需要任何先前配置,但独立模式仅限于单个服务器。最近,开发了一种名为 chDB 的进程内模式 [\[15\]](#page-12-3),用于 Jupyter notebooks [\[37\]](#page-12-4) 和 Pandas 数据框的交互式数据分析用例 [\[61\]](#page-13-5)。受 DuckDB [\[67\]](#page-13-6) 的启发,[chDB](https://clickhou.se/chdb-rocket-engine) 将 ClickHouse 嵌入高性能 OLAP 引擎到宿主进程中。与其他模式相比,这允许在数据库引擎和应用程序之间有效地传递源数据和结果数据,而无需复制,因为它们在同一个地址空间中运行。 +最后,ClickHouse 数据库引擎可以在本地、云、独立或进程内模式下运行。在本地模式中,用户将 ClickHouse 本地设置为单个服务器或多节点 ^^cluster^^,并具有分片和/或复制。客户端通过本机、MySQL、PostgreSQL 的二进制协议或 HTTP REST API 与数据库通信。云模式由 ClickHouse Cloud 表示,这是一个完全托管且可自动扩展的 DBaaS 产品。虽然本文重点介绍本地模式,但我们计划在后续出版物中描述 ClickHouse Cloud 的架构。[独立模式](https://clickhou.se/local-fastest-tool) 将 ClickHouse 转变为一个用于分析和转换文件的命令行工具,使其成为 Unix 工具(例如 cat 和 grep)的基于 SQL 的替代方案。虽然这无需先前的配置,但独立模式仅限于单个服务器。最近,开发了一种名为 chDB [\[15\]](#page-12-3) 的进程内模式,用于与 Jupyter notebooks [\[37\]](#page-12-4) 和 Pandas 数据帧 [\[61\]](#page-13-5) 等互动数据分析用例。受 DuckDB [\[67\]](#page-13-6) 启发,[chDB](https://clickhou.se/chdb-rocket-engine) 将 ClickHouse 嵌入作为高性能 OLAP 引擎到宿主进程中。与其他模式相比,这允许在数据库引擎和应用程序之间高效传递源数据和结果数据,而无需复制,因为它们在相同的地址空间中运行。 ## 3 存储层 {#3-storage-layer} -本节讨论 MergeTree* 表引擎作为 ClickHouse 的本机存储格式。我们描述其磁盘上的表示,并讨论 ClickHouse 中的三种数据修剪技术。之后,我们呈现合并策略,这些策略在不影响并行插入的情况下持续转换数据。最后,我们解释如何实现更新和删除,以及数据去重、数据复制和 ACID 合规性。 +本节讨论 ^^MergeTree^^* 表引擎作为 ClickHouse 的本机存储格式。我们描述它们的磁盘表示,并讨论 ClickHouse 中的三种数据剪枝技术。随后,我们展示了合并策略,这些策略在不影响并发插入的情况下持续转换数据。最后,我们解释如何实现更新和删除,以及数据去重、数据复制和 ACID 合规性。 ### 3.1 磁盘格式 {#3-1-on-disk-format} -MergeTree* 表引擎中的每个表都被组织为一组不可变的表部分。每当插入一组行到表中时,就会创建一个部分。部分是自包含的,因为它们包含了解释其内容所需的所有元数据,无需额外查找中央目录。为了保持每个表的部分数量较低,后台合并任务会定期将多个较小的部分合并为一个较大的部分,直到达到可配置的部分大小(默认为 150 GB)。由于部分按表的主键列排序(见第 [3.2](#page-3-0) 节),因此使用高效的 k-way 合并排序 [\[40\]](#page-12-5) 进行合并。源部分标记为非活动,并最终在其引用计数降至零时被删除,即不再有查询从中读取。 +每个 ^^MergeTree^^* ^^table engine^^ 中的表被组织为不可变的表 ^^parts^^ 的集合。每当一组行被插入到表中时,就会创建一个 ^^part^^。^^Parts^^ 是自包含的,因为它们包括解释其内容所需的所有元数据,无需对集中式目录进行额外查找。为了保持每个表的 ^^parts^^ 数量较低,后台合并作业定期将多个较小的 ^^parts^^ 合并为一个更大的 ^^part^^,直到达到一个可配置的分片大小(默认 150 GB)。由于 ^^parts^^ 是按表的 ^^primary key^^ 列(请参见第 [3.2 节](#page-3-0))排序的,因此合并时使用高效的 k-way 合并排序 [\[40\]](#page-12-5)。源 ^^parts^^ 被标记为不活跃,并在引用计数降至零时最终被删除,即没有查询再从中读取。 -行可以以两种模式插入:在同步插入模式下,每个 INSERT 语句创建一个新的部分并将其追加到表中。为了最小化合并的开销,数据库客户端被鼓励批量插入元组,例如一次插入 20,000 行。然而,如果数据应以实时方式进行分析,则客户端的批处理导致的延迟通常是不可接受的。例如,可观察性用例通常涉及数千个监控代理持续发送小量事件和指标数据。这种场景可以利用异步插入模式,在该模式中,ClickHouse 将来自多个 incoming INSERT 的行缓冲到同一表中,并仅在缓冲区大小超过可配置阈值或超时到期后才创建新的部分。 +行可以通过两种模式插入:在同步插入模式中,每个 INSERT 语句创建一个新 ^^part^^ 并将其附加到表中。为了减少合并的开销,数据库客户端鼓励批量插入元组,例如一次插入 20,000 行。然而,如果数据需要实时分析,客户端批处理所导致的延迟往往是不可接受的。例如,观察性用例通常涉及成千上万的监视代理持续发送少量事件和度量数据。这种场景可以利用异步插入模式,在该模式中,ClickHouse 将来自同一表的多个传入 INSERT 的行进行缓冲,仅在缓冲区大小超过可配置阈值或超时时间到期后创建新 ^^part^^。 - + -图 3:MergeTree*-引擎表的插入和合并。 +图 3: ^^MergeTree^^*-引擎表的插入和合并。 -[图 3](#page-2-1) 显示对 MergeTree*-引擎表的四次同步插入和两次异步插入。两次合并将活动部分的数量从最初的五个减少到两个。 +[图 3](#page-2-1) 显示了对 ^^MergeTree^^*-引擎表的四次同步插入和两次异步插入。两次合并将活动的 ^^parts^^ 数量从最初的五减少到两个。 -与 LSM 树 [\[58\]](#page-13-7) 及其在各种数据库中的实现 [\[13,](#page-12-6) [26,](#page-12-7) [56\]](#page-13-8) 相比,ClickHouse 将所有部分视为平等的,而不是将其按照层级组织。因此,合并不再限于同层中的部分。由于这也放弃了部分的隐式时间顺序,因此需要基于 tombstones 的替代机制来实现更新和删除(见第 [3.4](#page-4-0) 节)。ClickHouse 直接将插入写入磁盘,而其他基于 LSM 树的存储通常使用预写日志(见第 [3.7](#page-5-1) 节)。 +与 LSM 树 [\[58\]](#page-13-7) 及其在各种数据库中的实现 [\[13,](#page-12-6) [26,](#page-12-7) [56\]](#page-13-8) 相比,ClickHouse 将所有 ^^parts^^ 视为平等,而不是将它们安排成层次结构。因此,合并不再局限于同一层级中的 ^^parts^^。由于这也放弃了 ^^parts^^ 的隐式时间顺序,因此需要不基于墓碑的替代机制来实现更新和删除(参见第 [3.4 节](#page-4-0))。ClickHouse 直接将插入写入磁盘,而其他基于 LSM 树的存储通常会使用预写日志(请参见第 [3.7 节](#page-5-1))。 -一个部分对应于磁盘上的一个目录,包含每列一个文件。作为优化,小部分的列(小于 10 MB,默认为)连续存储在一个文件中,以增加读写的空间局部性。部分的行进一步逻辑上分为8192条记录一组,称为 granules。一个 granule 代表 ClickHouse 中由扫描和索引查找运算符处理的最小不可分割的数据单元。然而,对磁盘数据的读写并不是以 granule 级别进行,而是以块的粒度进行,块将同一列中相邻的多个 granular 组合在一起。新块的形成基于可配置的字节大小(默认 1 MB),即,一个块中的 granule 数量是可变的,具体取决于列的数据类型和分布。块进一步被压缩,以减小其大小和 I/O 成本。默认情况下,ClickHouse 使用 LZ4 [\[75\]](#page-13-9) 作为通用压缩算法,但用户也可以指定像 Gorilla [\[63\]](#page-13-10) 或 FPC [\[12\]](#page-12-8) 之类的专用编码器用于浮点数据。压缩算法也可以串联使用。例如,首先可以使用 delta 编码 [\[23\]](#page-12-9) 来减少数值中的逻辑冗余,然后执行重型压缩,最后使用 AES 编码器加密数据。块在从磁盘加载到内存时按需解压缩。为了在压缩情况下实现对单个 granular 的快速随机访问,ClickHouse 还为每列存储一个映射,将每个 granule id 与其所在压缩块在列文件中的偏移量和 granule 在未压缩块中的偏移量关联起来。 +一个 ^^part^^ 对应于磁盘上的一个目录,其中包含每列一个文件。作为优化,较小的 ^^part^^(默认小于 10 MB)中的列被连续存储在一个文件中,以增加读取和写入的空间局部性。一个 ^^part^^ 的行进一步逻辑上分为 8192 条记录的组,称为粒度(granules)。一个 ^^granule^^ 代表 ClickHouse 中扫描和索引查找运算符处理的最小不可分割数据单元。然而,磁盘数据的读取和写入并不是在 ^^granule^^ 层面上进行的,而是在块的粒度上进行的,这些块将多粒度相邻的集合包含在一个列中。新块的形成基于每个 ^^block^^ 的可配置字节大小(默认 1 MB),即 ^^block^^ 中的 ^^granules^^ 数量是可变的,取决于列的数据类型和分布。此外,块进一步被压缩,以减小其大小和 I/O 成本。默认情况下,ClickHouse 使用 LZ4 [\[75\]](#page-13-9) 作为通用压缩算法,但用户还可以指定专门的编解码器,如 Gorilla [\[63\]](#page-13-10) 或 FPC [\[12\]](#page-12-8) 用于浮点数据。压缩算法还可以连锁。例如,可以先使用增量编码 [\[23\]](#page-12-9) 减少数值的逻辑冗余,然后执行重压缩,最后使用 AES 编解码器加密数据。块在从磁盘加载到内存时会即时解压缩。为了在压缩的情况下快速随机访问单个粒度,ClickHouse 还为每一列存储一个映射,关联每个 ^^granule^^ id 与其所在的压缩 ^^block^^ 在列文件中的偏移位置和 ^^granule^^ 在未压缩 ^^block^^ 中的偏移位置。 -列还可以使用两种特殊包装数据类型进行字典编码 [\[2,](#page-12-10) [77,](#page-13-11) [81\]](#page-13-12) ,或被设为 Nullable:LowCardinality(T) 用整数 id 替换原始列值,从而显著减少数据存储开销针对具有少量唯一值的数据。Nullable(T) 为列 T 添加一个内部位图,表示列值是否为 NULL。 +列还可以使用两个特殊的包装数据类型进行 ^^dictionary^^ 编码 [\[2,](#page-12-10) [77,](#page-13-11) [81\]](#page-13-12) ,或设置为 Nullable。LowCardinality(T) 通过整数 id 替换原始列值,从而显著减少对于具有少量唯一值的数据的存储开销。Nullable(T) 为列 T 添加了一个内部位图,表示列值是否为 NULL。 -最后,表可以使用任意分区表达式进行范围、哈希或轮询分区。为了启用分区修剪,ClickHouse 还存储每个分区的分区表达式的最小值和最大值。用户可以选择创建更高级的列统计信息(例如,HyperLogLog [\[30\]](#page-12-11) 或 t-digest [\[28\]](#page-12-12) 统计信息),这也提供基数估算。 -### 3.2 数据修剪 {#3-2-data-pruning} +最后,可以使用任意分区表达式对表进行范围、哈希或轮询分区。为了实现分区剪枝,ClickHouse 还存储每个分区的分区表达式的最小值和最大值。用户可以选择创建更高级的列统计信息(例如 HyperLogLog [\[30\]](#page-12-11) 或 t-digest [\[28\]](#page-12-12) 统计),也可提供基数估计。 +### 3.2 数据剪枝 {#3-2-data-pruning} -在大多数用例中,仅仅为了回答一个查询而扫描 PB 级别的数据太慢且费用高。ClickHouse 支持三种数据修剪技术,可以在搜索期间跳过大多数行,从而显著加快查询速度。 +在大多数用例中,仅扫描 PB 级的数据来回答单个查询是太慢且昂贵的。ClickHouse 支持三种数据剪枝技术,可以在搜索期间跳过大多数行,因此显著加速查询。 -首先,用户可以为表定义一个 **主键索引**。主键列决定了每个部分内行的排序顺序,即索引是局部聚集的。ClickHouse 还为每个部分存储从每个 granule 第一行的主键列值到 granule id 的映射,即索引是稀疏的 [\[31\]](#page-12-13)。得到的数据结构通常小到足以保持完全在内存中,例如,仅需 1000 条条目便可索引 810 万行。主键的主要目的是使用二进制搜索而不是顺序扫描评估频繁过滤的列的等于和范围谓词(第 [4.4](#page-7-0) 节)。局部排序还可以利用于部分合并和查询优化,例如基于排序的聚合或在主键列形成排序列的前缀时,从物理执行计划中删除排序运算符。 +首先,用户可以为表定义一个 **^^primary key^^ 索引**。^^primary key^^ 列定义了每个 part 内行的排序顺序,即该索引在本地聚集。ClickHouse 还为每一个 part 存储从每个 ^^granule^^ 的第一行的 ^^primary key^^ 列值到 ^^granule^^ id 的映射,即该索引是稀疏的 [\[31\]](#page-12-13)。生成的数据结构通常足够小,可以保持完全在内存中,例如,仅需 1000 条条目即可为 810 万行建立索引。^^primary key^^ 的主要目的在于使用二进制搜索平衡常用的过滤列的相等性和范围谓词,而不是顺序扫描(第 [4.4 节](#page-7-0))。另外,当 ^^primary key^^ 列形成排序列的前缀时,还可以利用本地排序来优化 part 合并和查询优化,例如基于排序的聚合或将排序运算符从物理执行计划中移除。 -[图 4](#page-3-1) 显示了针对具有页面印象统计的表的列 EventTime 的主键索引。可以通过在主键索引中进行二进制搜索找到与查询中范围谓词匹配的 granules,而不是顺序扫描 EventTime。 +[图 4](#page-3-1) 显示了一个针对页面印象统计表中 EventTime 列的 ^^primary key^^ 索引。匹配查询中范围谓词的粒度可以通过对 ^^primary key^^ 索引进行二进制搜索来找到,而无需顺序扫描 EventTime。 - + -图 4:使用主键索引评估过滤器。 +图 4: 使用 ^^primary key^^ 索引评估过滤器。 -其次,用户可以创建 **表投影**,即包含与主表相同行但按不同主键排序的表的替代版本 [\[71\]](#page-13-13)。投影允许加速对不同于主表主键的列进行过滤的查询,但会增加插入、合并和空间消耗的开销。默认情况下,投影仅从新插入到主表的部分惰性填充,而不从现有部分填充,除非用户将投影完全物化。查询优化器根据估算的 I/O 成本在从主表读取或从投影读取之间选择。如果某一部分没有投影,查询执行将回退到对应的主表部分。 +其次,用户可以创建 **表投影**,即表的替代版本,其中的行按照不同的 ^^primary key^^ [\[71\]](#page-13-13) 排序。投影允许加速不同于主表的 ^^primary key^^ 的列的过滤查询,但在插入、合并和空间消耗上增加了开销。默认情况下,投影仅从新插入主表的 ^^parts^^ 中惰性填充,而不会从现有的 ^^parts^^ 中填充,除非用户将该 ^^projection^^ 完全物化。查询优化器会根据估计的 I/O 成本在主表和 ^^projection^^ 之间进行选择。如果某个 part 的投影不存在,查询执行将恢复到相应的主表部分。 -第三,**跳过索引**提供轻量级的投影替代方案。跳过索引的思想是在多个连续的 granules 级别存储少量元数据,从而避免扫描无关行。跳过索引可以为任意索引表达式创建,并使用可配置的粒度,即跳过索引块中的 granule 数量。可用的跳过索引类型包括:1. 最小-最大索引 [\[51\]](#page-13-14),存储每个索引块的索引表达式的最小值和最大值。该索引类型对具有小绝对范围的局部聚集数据(例如,松散排序数据)非常有效。 2. 集合索引,存储可配置数量的唯一索引块值。这些索引最适用于具有小型局部基数的数据,即“聚集在一起”的值。 3. 布隆过滤器索引 [\[9\]](#page-12-14) 为行、标记或 n-gram 值构建,具有可配置的假阳性率。这些索引支持文本搜索 [\[73\]](#page-13-15),但与最小-最大和集合索引不同,它们不能用于范围或负谓词。 -### 3.3 合并时数据转换 {#3-3-merge-time-data-transformation} +第三,**跳过索引** 提供了替代投影的轻量级方法。跳过索引的思想是在多个连续的粒度层次上存储少量元数据,从而避免扫描不相关的行。可以为任意索引表达式创建跳过索引,并使用可配置的粒度,即在 ^^skipping index^^ 块中的粒度数量。可用的 ^^skipping index^^ 类型包括:1. 最小-最大索引 [\[51\]](#page-13-14),为每个索引 ^^block^^ 存储索引表达式的最小值和最大值。此索引类型在局部集聚的数据上效果很好,具有较小的绝对范围,例如松散排序的数据。2. 集合索引,存储可配置数量的唯一索引 ^^block^^ 值。这些索引最好用于具有小局部基数的数据,即“聚集在一起”的值。3. 布隆过滤器索引 [\[9\]](#page-12-14),用于行、标记或 n-gram 值,具有可配置的假阳性率。这些索引支持文本搜索 [\[73\]](#page-13-15),但与最小-最大和集合索引不同,不能用于范围或负谓词。 +### 3.3 合并时的数据转换 {#3-3-merge-time-data-transformation} -商业智能和可观察性用例通常需要处理以不断高的速率或以突发形式生成的数据。此外,最近生成的数据通常在有意义的实时洞察中比历史数据更为相关。这类用例要求数据库能够维持高数据 ingest 速率,同时通过聚合或数据老化等技术持续减少历史数据的量。ClickHouse 允许使用不同的合并策略对现有数据进行持续增量转换。合并时的数据转换并不妨碍 INSERT 语句的性能,但不能保证表中永远不包含不必要的(例如过时或未聚合的)值。如有必要,可以通过在 SELECT 语句中指定关键字 FINAL 在查询时应用所有合并时转换。 +商业智能和可观察性用例经常需要处理以持续高速度或突发模式生成的数据。此外,最近生成的数据通常对于有意义的实时洞察比历史数据更为相关。这种用例要求数据库在持续降低历史数据量的同时保持高数据摄取率,使用聚合或数据老化等技术。ClickHouse 允许使用不同的合并策略对现有数据进行持续增量转换。合并时的数据转换不影响 INSERT 语句的性能,但不能保证表中从不包含不需要的(例如过期或未聚合的)值。如有必要,所有合并时的转换可以在查询时间通过在 SELECT 语句中指定关键字 FINAL 来应用。 -**替换合并**仅保留基于其包含部分的创建时间戳的元组最新版本,较旧版本会被删除。如果元组具有相同的主键列值,则视为相等。为了明确控制保留哪个元组,还可以指定一个特殊版本列进行比较。替换合并通常用作合并时更新机制(通常在更新频繁的用例中),或用作插入时去重的替代方案(第 [3.5](#page-5-2) 节)。 +**替换合并** 仅保留基于其所含 part 的创建时间戳插入的最新版本的元组,较旧的版本将被删除。如果它们具有相同的 ^^primary key^^ 列值,则元组被视为等效。为了明确控制保留哪个元组,还可以指定一个特殊的版本列进行比较。替换合并通常用作合并时的更新机制(通常在更新频繁的用例中),或作为插入时数据去重的替代方案(第 [3.5 节](#page-5-2))。 -**聚合合并**将具有相同主键列值的行折叠为一行聚合行。非主键列必须处于持有汇总值的部分的聚合状态。两个部分聚合状态(例如 avg() 的和和计数)合并为一个新的部分聚合状态。聚合合并通常用于物化视图,而不是正常表。物化视图基于对源表的转换查询填充。与其他数据库不同,ClickHouse 不定期用源表的整个内容刷新物化视图。物化视图相对于新插入源表部分的转换查询增量更新。 +**聚合合并** 将具有相同的 ^^primary key^^ 列值的行折叠为一行聚合行。非 ^^primary key^^ 列必须处于持有摘要值的部分聚合状态中。两个部分聚合状态,例如用于 avg() 的总和和计数,将组合成一个新的部分聚合状态。聚合合并通常在物化视图中使用,而不是普通表中。物化视图是基于针对源表的转换查询填充的。与其他数据库不同的是,ClickHouse 不会定期使用源表的整个内容刷新物化视图。物化视图会在向源表插入新 part 时逐步更新转换查询的结果。 -[图 5](#page-4-1) 显示了在一个包含页面印象统计的表上定义的物化视图。对于插入到源表的新部分,转换查询按区域分组计算最大和平均延迟,并将结果插入物化视图中。聚合函数 avg() 和 max() 使用 -State 扩展返回部分聚合状态,而不是实际结果。为物化视图定义的聚合合并持续组合不同部分中的部分聚合状态。为了获得最终结果,用户使用 avg() 和 max() 及其 -Merge 扩展整合物化视图中的部分聚合状态。 +[图 5](#page-4-1) 显示了一个在页面印象统计表上定义的 ^^materialized view^^。对于插入到源表中的新 ^^parts^^,转换查询计算最大和平均延迟,并按区域分组,将结果插入 ^^materialized view^^ 中。聚合函数 avg() 和 max() 具有扩展 -State 返回部分聚合状态,而不是实际结果。为 ^^materialized view^^ 定义的聚合合并持续在不同 ^^parts^^ 中组合部分聚合状态。为了获得最终结果,用户使用 avg() 和 max() 的 -Merge 扩展示例汇总 ^^materialized view^^ 中的部分聚合状态。 - + -图 5:物化视图中聚合合并。 +图 5: 物化视图中的聚合合并。 -**生存时间(TTL)合并**为历史数据提供老化。与删除和聚合合并不同,TTL 合并一次仅处理一个部分。TTL 合并由触发器和操作组成的规则定义。触发器是为每一行计算时间戳的表达式,该时间戳与 TTL 合并运行时的时间进行比较。虽然这允许用户以行粒度控制操作,但我们发现仅检查所有行是否满足给定条件并在整个部分上运行操作是足够的。可能的操作包括 1. 将部分移动到另一个卷(例如,更便宜且更慢的存储),2. 重新压缩部分(例如,用更重的编解码器),3. 删除部分,和 4. 汇总,即使用分组密钥和聚合函数聚合行。 +**^^TTL^^(生存时间)合并** 为历史数据提供老化。与删除和聚合合并不同,^^TTL^^ 合并一次仅处理一个 part。^^TTL^^ 合并是基于触发器和操作的规则定义的。触发器是计算每行的时间戳的表达式,它与运行 ^^TTL^^ 合并的时间进行比较。虽然这允许用户在行粒度上控制操作,但我们发现检查所有行是否满足给定条件并对整个 part 执行操作是足够的。可能的操作包括 1. 将 part 移动到另一个卷(例如,较便宜且较慢的存储),2. 重新压缩 part(例如,使用更重的编解码器),3. 删除 part,以及 4. 汇总,即使用分组键和聚合函数对行进行聚合。 -作为示例,考虑在[清单 1](#page-4-2)中的日志表定义。ClickHouse 将把时间戳列值大于一周的部分移动到缓慢但便宜的 S3 对象存储。 +例如,在 [清单 1](#page-4-2) 中考虑日志表的定义。ClickHouse 将把时间戳列值早于一周的 ^^parts^^ 移动到缓慢但廉价的 S3 对象存储。 ``` 1 CREATE TABLE tab ( ts DateTime , msg String ) 2 ENGINE MergeTree PRIMARY KEY ts 3 TTL ( ts + INTERVAL 1 WEEK ) TO VOLUME 's3 ' ``` -清单 1:在一周后将部分移动到对象存储。 +清单 1: 一周后将 part 移动到对象存储。 ### 3.4 更新和删除 {#3-4-updates-and-deletes} -MergeTree* 表引擎的设计更偏向于仅添加负载,但某些用例需要偶尔修改现有数据,例如为了合规。存在两种更新或删除数据的方法,这两种方法均不会阻止并行插入。 +^^MergeTree^^* 表引擎的设计倾向于附加式工作负载,但某些用例需要偶尔修改现有数据,例如为了遵守法规。更新或删除数据有两种方法,但都不会 ^^block^^ 并行插入。 -**变更**在原地重写表的所有部分。为了防止表(或删除)或列(或更新)暂时增加大小,这一操作是非原子的,即并行 SELECT 语句可能会同时读取已变更和未变更的部分。变更保证在操作结束时数据被实际更改。删除变更仍然非常昂贵,因为它们重写了所有部分中的所有列。 +**突变** 以就地的方式重写表的所有 ^^parts^^。为了防止泄露(delete)的表或列(update)在大小上暂时翻倍,这一操作是非原子的,即并行 SELECT 语句可能读取突变和未突变的 ^^parts^^。突变保证在操作结束时数据会物理改变。删除突变仍然是昂贵的,因为它们会重写所有 ^^parts^^ 中的所有列。 -作为替代方案,**轻量级删除**仅更新一个内部位图列,指示一行是否被删除。ClickHouse 通过在 SELECT 查询中对位图列添加额外过滤器,以排除删除的行。删除的行仅在未来的某个不特定时间通过定期合并物理删除。根据列计数,轻量级删除可能比变更快得多,但 SELECT 的速度会较慢。 +作为替代方案,**轻量级删除** 只是更新一个内部位图列,以表明某一行是否被删除。ClickHouse 会对 SELECT 查询进行修正,增加对位图列的额外过滤,以排除删除的行。删除的行仅在未来的某个时间通过常规合并物理删除。根据列数,轻量级删除的速度可能远快于突变,但代价是 SELECT 要慢。 -在同一张表上执行的更新和删除操作应该被认为是困难且需要串行处理,以避免逻辑冲突。 +对同一表执行的更新和删除操作被预期为罕见并被序列化,以避免逻辑冲突。 ### 3.5 幂等插入 {#3-5-idempotent-inserts} -在实践中,经常发生的问题是客户端如何处理在将数据发送到服务器以插入到表中后发生的连接超时。在这种情况下,客户端很难区分数据是否成功插入。传统上,通过从客户端重新发送数据到服务器,并依赖主键或唯一约束来拒绝重复插入,这个问题得以解决。数据库快速执行所需的点查找,使用基于二叉树的索引结构 [\[39,](#page-12-15) [68\]](#page-13-16)、基数树 [\[45\]](#page-13-17) 或哈希表 [\[29\]](#page-12-16)。由于这些数据结构对每个元组进行索引,因此在大数据集和高 ingest 速率下,存储和更新开销变得不可承受。 +实践中经常出现的问题是客户端在向服务器发送数据插入表后如何处理连接超时。在这种情况下,客户端很难分辨数据是否成功插入。该问题通常通过从客户端重新发送数据到服务器来解决,并依赖于 ^^primary key^^ 或唯一约束来拒绝重复插入。数据库通过基于二叉树的索引结构 [\[39,](#page-12-15) [68\]](#page-13-16)、基数树 [\[45\]](#page-13-17) 或哈希表 [\[29\]](#page-12-16) 快速执行所需的点查找。由于这些数据结构为每个元组建立索引,因此它们的存储和更新开销在处理大型数据集和高摄取率时变得不堪重负。 -ClickHouse 提供了一种轻量级的替代方案,基于每次插入最终创建一个部分这一事实。更具体地说,服务器维护最近插入的 N 个部分的哈希(例如 N=100),并忽略已知哈希的部分重新插入。对未复制和复制的表的哈希分别存储在 Keeper 中。因此,插入变得幂等,即客户端可以在超时后简单地重新发送相同的行批次,假定服务器会处理去重。为了更好地控制去重过程,客户端可以选择提供一个可作为部分哈希的插入令牌。虽然基于哈希的去重会带来与哈希新行相关的开销,但存储和比较哈希的成本微乎其微。 +ClickHouse 提供了一种更轻量级的替代方案,基于每次插入最终创建一个 part 的事实。更具体地说,服务器维护最近插入的 N 个 ^^parts^^ 的哈希(例如 N=100),并忽略已知哈希的 ^^parts^^ 的重新插入。非复制表和复制表的哈希分别存储于本地和 Keeper 中。因此,插入操作变得幂等,即客户端可以在超时后简单地重新发送相同的行批,并假设服务器会处理去重。为了更好地控制去重过程,客户端还可以选择提供一个作为 part 哈希的插入令牌。虽然基于哈希的去重会带来与对新行进行哈希相关的开销,但存储和比较哈希的成本微不足道。 ### 3.6 数据复制 {#3-6-data-replication} -复制是高可用性的先决条件(容忍节点故障),同时也用于负载均衡和零停机升级 [\[14\]](#page-12-17)。在 ClickHouse 中,复制基于表状态的概念,表状态由一组表分片(第 [3.1 章](#page-2-2))和表元数据(如列名和类型)组成。节点使用三种操作来推进表的状态:1. 插入将新的分片添加到状态中,2. 合并会将新的分片添加到状态中并删去现有的分片,3. 变更和 DDL 语句根据具体操作添加分片、删除分片和/或更改表元数据。操作在单个节点上本地执行,并作为状态转换序列记录在全局复制日志中。 +复制是高可用性(对节点故障的容忍)的前提条件,但它也用于负载均衡和零停机时间的升级 [\[14\]](#page-12-17)。在 ClickHouse 中,复制基于表状态的概念,表状态由一组表 ^^parts^^(章节 [3.1)](#page-2-2) 和表元数据(如列名和类型)组成。节点使用三种操作来推进表的状态:1. 插入操作为状态添加新的部分,2. 合并操作将添加新的部分并从状态中删除现有的 ^^parts^^,3. 变更和 DDL 语句根据具体操作添加 ^^parts^^、和/或删除 ^^parts^^,和/或更改表元数据。操作在单个节点上进行本地执行,并记录为全局复制日志中的状态转换序列。 -复制日志由通常三个 ClickHouse Keeper 进程的集群维护,这些进程使用 Raft 共识算法 [\[59\]](#page-13-4) 为 ClickHouse 节点集群提供分布式和容错的协调层。所有集群节点最初指向复制日志中的相同位置。当节点执行本地插入、合并、变更和 DDL 语句时,复制日志在所有其他节点上异步重放。因此,复制表最终只有最终一致性,即节点在收敛到最新状态时可能暂时读取到旧的表状态。前述大多数操作可以选择在节点达到法定人数(例如,节点的多数或所有节点)采用新的状态之前以同步方式执行。 +复制日志由通常包含三个 ClickHouse Keeper 进程的集群维护,这些进程使用 Raft 共识算法 [\[59\]](#page-13-4) 提供对 ClickHouse 节点集群的分布式和容错协调层。所有 ^^cluster^^ 节点最初指向复制日志的相同位置。当节点执行本地插入、合并、变更和 DDL 语句时,复制日志在所有其他节点上异步重放。因此,复制表仅在最终一致性上保持一致,即节点可以暂时读取旧的表状态,同时逐步收敛到最新状态。上述大多数操作也可以选择在一个法定人数节点(例如大多数节点或所有节点)采用新状态之前以同步方式执行。 -例如, [图 6](#page-5-3) 显示了一个最初为空的复制表,它位于三个 ClickHouse 节点的集群中。节点 1 首先接收两个插入语句,并将它们记录在保存在 Keeper 集群中的复制日志中(1 2)。接下来,节点 2 通过获取第一个日志条目(3)并从节点 1 下载新分片(4)来重放它,而节点 3 则重放两个日志条目(3 4 5 6)。最后,节点 3 将这两个分片合并为一个新分片,删除输入分片,并在复制日志中记录合并条目(7)。 +作为示例,[图 6](#page-5-3) 显示了在三个 ClickHouse 节点的 ^^cluster^^ 中的一个最初为空的复制表。节点 1 首先接收两个插入语句,并在 Keeper 集群中将其记录到复制日志中( 1 2 )。接下来,节点 2 通过获取第一个日志条目( 3 )并从节点 1 下载新部分( 4 )来重放第一个日志条目,而节点 3 则重放两个日志条目( 3 4 5 6 )。最后,节点 3 合并两个 ^^parts^^ 到一个新部分,删除输入 ^^parts^^,并在复制日志中记录合并条目( 7 )。 -图 6:三节点集群中的复制。 +图 6:三个节点的 ^^cluster^^ 中的复制。 -为了加速同步,有三种优化:首先,新添加到集群的节点不会从头重放复制日志,而是直接复制写入最近复制日志条目的节点的状态。其次,合并通过在本地重复执行或从另一个节点获取结果分片进行重放。具体行为是可配置的,可以平衡 CPU 使用和网络 I/O。例如,跨数据中心复制通常更倾向于本地合并,以最小化操作成本。第三,节点并行重放相互独立的复制日志条目。这包括,例如,连续插入到同一个表的新分片的获取,或对不同表的操作。 +为了加速同步,存在三种优化:首先,添加到 ^^cluster^^ 中的新节点是从头重放复制日志,而是简单地复制写入最后一个复制日志条目的节点的状态。其次,通过在本地重复合并或从另一个节点获取结果部分来重放合并。确切行为是可配置的,允许平衡 CPU 消耗和网络 I/O。例如,跨数据中心的复制通常更喜欢本地合并以最小化操作成本。第三,节点在并行重放相互独立的复制日志条目。这包括例如连续插入同一表的新 ^^parts^^ 的提取,或对不同表的操作。 -### 3.7 ACID 兼容性 {#3-7-acid-compliance} +### 3.7 ACID 合规性 {#3-7-acid-compliance} -为了最大限度地提高并发读写操作的性能,ClickHouse 尽可能避免锁定。查询在查询开始时对所有涉及表中的所有分片的快照执行。这确保了由并行 INSERT 或合并插入的新分片(第 [3.1 章](#page-2-2))不会参与执行。为了防止分片同时被修改或删除(第 [3.4 章](#page-4-0)),处理的分片的引用计数在查询持续期间内递增。形式上,这对应于由基于版本的分片实现的快照隔离的 MVCC 变体 [\[6\]](#page-12-18)。因此,除非在快照捕获时的并发写入仅影响单个分片,否则语句通常不符合 ACID。 +为了最大化并发读写操作的性能,ClickHouse 尽可能避免锁定。查询是针对在查询开始时创建的所有 ^^parts^^ 的快照执行的。这确保了通过并行 INSERT 或合并(章节 [3.1)](#page-2-2) 插入的新 ^^parts^^ 不参与执行。为了防止 ^^parts^^ 同时被修改或删除(章节 [3.4)](#page-4-0),处理的 ^^parts^^ 的引用计数在查询持续期间被增加。从形式上讲,这对应于通过基于版本的 ^^parts^^ 实现的快照隔离的 MVCC 变体 [\[6\]](#page-12-18)。结果是,除非在快照拍摄时每个影响只有单个部分的罕见情况下,声明通常不符合 ACID 标准。 -在实践中,ClickHouse 的许多写密集型决策应用程序甚至容忍在断电的情况下丢失新数据的小风险。数据库通过默认不强制将新插入分片提交(fsync)到磁盘来利用这一点,允许内核批量写入,以牺牲原子性为代价。 +实际上,大多数 ClickHouse 的重写决策使用案例即使在停电的情况下也容忍丢失新数据的风险。数据库利用这一点,默认情况下不强制将新插入的 ^^parts^^ 提交(fsync)到磁盘,允许内核以放弃 ^^atomicity^^ 的代价批量写入。 ## 4 查询处理层 {#4-query-processing-layer} -图 7:跨 SIMD 单元、核心和节点的并行化。 +图 7:在 SIMD 单元、核心和节点之间的并行化。 -正如 [图 7](#page-6-1) 所示,ClickHouse 在数据元素、数据块和表分片的层面上并行化查询。多个数据元素可以在运算符内部同时使用 SIMD 指令进行处理。在单个节点上,查询引擎同时在多个线程中执行运算符。ClickHouse 使用与 MonetDB/X100 相同的矢量化模型 [\[11\]](#page-12-0),即运算符生成、传递和消费多个行(数据块)而不是单行,以最小化虚拟函数调用的开销。如果源表被拆分为不相交的表分片,则多个节点可以同时扫描这些分片。因此,所有硬件资源得到充分利用,查询处理可以通过添加节点和添加核心进行水平和垂直扩展。 +如 [图 7](#page-6-1) 所示,ClickHouse 在数据元素、数据块和表分片的层面上对查询进行并行化。可以使用 SIMD 指令在运算符内同时处理多个数据元素。在单个节点上,查询引擎在多个线程中同时执行操作符。ClickHouse 使用与 MonetDB/X100 [\[11\]](#page-12-0) 相同的向量化模型,即操作符生成、传递和消费多行(数据块),而不是单行,以最小化虚拟函数调用的开销。如果源表被分割成不重叠的表分片,多个节点可以同时扫描分片。因此,所有硬件资源都得到了充分利用,查询处理可以通过添加节点和通过添加核心进行水平和垂直扩展。 -本节的其余部分将首先详细描述数据元素、数据块和分片粒度的并行处理。接着,我们将介绍一些关键优化,以最大限度地提高查询性能。最后,我们将讨论 ClickHouse 如何在存在并发查询的情况下管理共享系统资源。 +本节的其余部分首先更详细地描述在数据元素、数据块和 ^^shard^^ 粒度上的并行处理。然后,我们介绍一些关键优化,以最大化查询性能。最后,我们讨论 ClickHouse 如何在存在同时查询的情况下管理共享系统资源。 ### 4.1 SIMD 并行化 {#4-1-simd-parallelization} -在运算符之间传递多个行为矢量化创造了机会。矢量化可以基于手动编写的内嵌函数 [\[64,](#page-13-18) [80\]](#page-13-19) 或编译器的自动矢量化 [\[25\]](#page-12-19)。受益于矢量化的代码被编译为不同的计算内核。例如,查询运算符的内部热循环可以通过非矢量化内核、自动矢量化的 AVX2 内核和手动矢量化的 AVX-512 内核来实现。运行时根据 cpuid 指令选择最快的内核 [选项](https://clickhou.se/cpu-dispatch)。这种方法使 ClickHouse 能够在如 15 年前的系统上运行(要求最低为 SSE 4.2),同时在最近的硬件上仍能提供显著的加速。 +在操作符之间传递多行数据创建了向量化的机会。向量化可以基于手动编写的内联函数 [\[64,](#page-13-18) [80\]](#page-13-19) 或编译器自动向量化 [\[25\]](#page-12-19)。受益于向量化的代码被编译为不同的计算内核。例如,查询操作符的内热循环可以用非向量化内核、自动向量化的 AVX2 内核和手动向量化的 AVX-512 内核来实现。运行时基于 cpuid 指令选择最快的内核 [选择](https://clickhou.se/cpu-dispatch)。这一方法使得 ClickHouse 可以在最老可支持 15 年的系统上运行(最低要求 SSE 4.2),同时在新硬件上依然提供显著的速度提升。 ### 4.2 多核并行化 {#4-2-multi-core-parallelization} -图 8:一个包含三个通道的物理运算符计划。 +图 8:具有三个通道的物理操作计划。 -ClickHouse 遵循传统方法 [\[31\]](#page-12-13),将 SQL 查询转换为一个物理计划运算符的有向图。运算符计划的输入由读取原生数据或任何支持的第三方格式(见第 [5 章](#page-9-0))的数据源运算符表示。同样,一个特殊的排出运算符将结果转换为所需的输出格式。物理运算符计划在查询编译时根据可配置的最大工作线程数(默认情况下为核心数)和源表大小展开为独立的执行通道。通道将要由并行运算符处理的数据分解为不重叠的范围。为了最大限度地提高并行处理的机会,通道的合并尽可能推迟。 +ClickHouse 遵循传统方法 [\[31\]](#page-12-13) 将 SQL 查询转化为物理计划操作符的有向图。操作符计划的输入通过特殊的源操作符表示,这些操作符以原生或任何受支持的第三方格式读取数据(见章节 [5)](#page-9-0)。同样,特殊的接收操作符将结果转换为所需的输出格式。物理操作符计划在查询编译时根据可配置的工作线程最大数(默认为核心数)和源表大小展成独立的执行通道。通道将要被并行操作符处理的数据分解为不重叠的范围。为了最大化并行处理的机会,通道应尽可能晚地合并。 -例如,[图 8](#page-7-1) 中的节点 1 的框显示了一个典型的 OLAP 查询的运算符图,该查询针对带有页面印象统计数据的表。在第一个阶段,源表的三个不相交范围同时被过滤。重分区交换运算符动态路由结果块在第一个和第二个阶段之间,以保持处理线程的均匀使用。如果扫描的范围具有显著不同的选择性,通道可能在第一个阶段后变得不平衡。在第二个阶段,经过过滤的行按区域 ID 进行分组。聚合运算符维护本地结果组,以区域 ID 作为分组列并按组的总和和计数作为 avg() 的部分聚合状态。本地聚合结果最终通过 GroupStateMerge 运算符合并为全局聚合结果。这个运算符还是一个管道中断器,即在聚合结果完全计算出来之前,第三个阶段无法开始。在第三个阶段,结果组首先通过分发交换运算符分成三个相等大小的不相交分区,然后按 AvgLatency 排序。排序分为三个步骤:首先,ChunkSort 运算符对每个分区的各个块进行排序。其次,StreamSort 运算符维护一个本地排序结果,该结果与使用 2-way 合并排序的新排序块合并。最后,MergeSort 运算符使用 k-way 排序将本地结果合并以获得最终结果。 +例如,[图 8](#page-7-1) 中节点 1 的框展示了针对具有页面展示统计信息的表的典型 OLAP 查询的操作符图。在第一阶段,源表的三个不重叠范围同时被过滤。一个重分发交换操作符动态地在第一和第二阶段之间路由结果块,以保持处理线程的均匀利用。如果扫描的范围的选择性有显著不同,则通道在第一阶段后可能会变得不均衡。在第二阶段,存活下来的行按照 RegionID 进行分组。聚合操作符维护以 RegionID 作为分组列和每组和计数作为 avg() 的部分聚合状态的本地结果组。最终,本地聚合结果通过 GroupStateMerge 操作符合并为全局聚合结果。该操作符也是一个管道断路器,即在完全计算聚合结果之前,第三阶段只能启动。一旦结果组被计算出来,首先使用重分发交换操作符(Distribute exchange operator)将它们分为三个大小相等的不重叠分区,然后根据 AvgLatency 进行排序。排序分为三个步骤:首先,ChunkSort 操作符对每个分区的单独块进行排序。其次,StreamSort 操作符维护本地排序结果,并使用二路合并排序将其与传入的已排序块合并。最后,MergeSort 操作符使用 k 路排序合并本地结果以获得最终结果。 -运算符是状态机,通过输入和输出端口互相连接。运算符的三种可能状态是 need-chunk、ready 和 done。要从 need-chunk 转换到 ready,需要将一个块放入运算符的输入端口。要从 ready 转换到 done,运算符处理输入块并生成输出块。要从 done 转换到 need-chunk,输出块将从运算符的输出端口中移除。在两个连接的运算符中,第一个和第三个状态之间的转换只能在一个合并步骤中执行。源运算符(排出运算符)仅具有 ready 和 done 状态(need-chunk 和 done)。 +操作符是状态机,通过输入和输出端口相互连接。操作符的三个可能状态是需要块(need-chunk)、准备好(ready)和完成(done)。要从需要块切换到准备好,需要在操作者的输入端口放置一个块。要从准备好切换到完成,操作符处理输入块并生成输出块。要从完成切换到需要块,需要将输出块从操作符的输出端口移除。连接的两个操作符中的第一次和第三次状态转换只能在结合步骤中执行。源操作符(接收操作符)只有准备好和完成状态(需要块和完成状态)。 -工作线程持续遍历物理运算符计划并执行状态转换。为了保持 CPU 缓存的高效,计划包含提示,以便相同的线程应该在同一通道中处理连续的运算符。并行处理发生在一阶段内横向并发(例如,在 [图 8](#page-7-1) 中,聚合运算符并行执行)和在未被管道中断器分隔的阶段之间的纵向(例如,在 [图 8](#page-7-1) 中,处于同一通道的过滤和聚合运算符可以同时运行)。为了避免新查询启动时的过度和不足订阅,或并发查询完成时的情况,可以在查询执行过程中在一个和查询启动时指定的查询的最大工作线程数量之间动态更改并行度(见第 [4.5 章](#page-9-1))。 +工作线程不断遍历物理操作计划并执行状态转换。为了保持 CPU 缓存热,计划包含提示,即同一个线程应该在同一通道中处理连续的操作符。并行处理既发生在阶段内跨不重叠输入(例如,在 [图 8](#page-7-1) 中聚合操作符并发执行),也发生在不被管道断路器分隔的阶段之间(例如,在 [图 8](#page-7-1) 中同一通道中的过滤器和聚合操作符可以同时运行)。为了避免在新查询启动时或并发查询完成时的过度和不足订阅,可在查询执行时将并行度在一个和查询开始时指定的最大工作线程数量之间修改(见章节 [4.5)](#page-9-1)。 -运算符还可以以两种方式在运行时进一步影响查询执行。首先,运算符可以动态创建和连接新运算符。这主要用于在内存消耗超过可配置阈值时切换到外部聚合、排序或连接算法,而不是取消查询。其次,运算符可以请求工作线程移动到异步队列。这在等待远程数据时更有效地使用工作线程。 +操作符可以进一步在运行时以两种方式影响查询执行。首先,操作符可以动态地创建和连接新操作符。主要用于在内存消耗超过可配置阈值时切换到外部聚合、排序或连接算法,而不是取消查询。其次,操作符可以请求工作线程进入异步队列。当等待远程数据时,这提供了更有效的工作线程使用。 -ClickHouse 的查询执行引擎和切片驱动的并行性 [\[44\]](#page-12-20) 有相似之处,即通道通常在不同的核心 / NUMA 插座上执行,工作线程可以从其他通道窃取任务。此外,没有中央调度组件;相反,工作线程通过持续遍历运算符计划来单独选择任务。与切片驱动的并行性不同,ClickHouse 将最大的并行度融入计划,并使用比默认切片大小(约 100,000 行)大得多的范围来对源表进行分片。虽然在某些情况下这可能导致停顿(例如,当不同通道中的过滤运算符的运行时间相差很大时),但我们发现自由使用例如重分区等交换运算符至少可以避免这种不平衡在阶段之间累积。 +ClickHouse 的查询执行引擎和基于分块的并行性 [\[44\]](#page-12-20) 相似,因为通道通常在不同的核心/NUMA 插槽上执行,并且工作线程可以从其他通道窃取任务。此外,没有中央调度组件;相反,工作线程通过不断遍历操作符计划单独选择任务。与基于分块的并行性不同,ClickHouse 将最大并行度嵌入计划中,并使用更大的范围来划分源表,而不是约 100,000 行的默认分块大小。虽然这在某些情况下可能导致停滞(例如,当不同通道中的过滤器操作符的运行时间差异很大时),但我们发现自由使用诸如重分发操作符的操作可以至少避免此类不平衡在阶段之间累积。 ### 4.3 多节点并行化 {#4-3-multi-node-parallelization} -如果查询的源表是分片的,则接收查询的节点(发起节点)上的查询优化器尝试在其他节点上尽可能多地执行工作。来自其他节点的结果可以在查询计划的不同点中集成。根据查询,远程节点可以选择 1. 将原始源表列流式传输到发起节点,2. 过滤源列并发送存活的行,3. 执行过滤和聚合步骤,并发送局部结果组的部分聚合状态,或 4. 完整运行查询,包括过滤、聚合和排序。 +如果查询的源表被分片,接收查询的节点(发起节点)上的查询优化器会尽可能在其他节点上执行更多的工作。来自其他节点的结果可以集成到查询计划的不同点。根据查询,远程节点可以 1. 将原始源表列流式传输到发起节点,2. 过滤源列并发送幸存的行,3. 执行过滤和聚合步骤,并发送具有部分聚合状态的本地结果组,或 4. 运行整个查询,包括过滤、聚合和排序。 -[图 8](#page-7-1) 中的节点 2 ... N 显示了在持有命中的表分片的其他节点上执行的计划片段。这些节点过滤和分组本地数据,并将结果发送到发起节点。在节点 1 上的 GroupStateMerge 运算符在最终对结果组进行排序之前合并本地和远程结果。 +[图 8](#page-7-1) 中的节点 2 ... N 显示了在持有点击表碎片的其他节点上执行的计划片段。这些节点过滤和分组本地数据,然后将结果发送到发起节点。节点 1 上的 GroupStateMerge 操作符合并本地和远程结果,最后将结果组排序。 ### 4.4 整体性能优化 {#4-4-holistic-performance-optimization} -本节介绍在查询执行的不同阶段应用的一些关键性能优化。 +本节介绍了在不同查询执行阶段应用的若干关键性能优化。 -**查询优化**。第一组优化是在从查询的抽象语法树(AST)获得的语义查询表示之上应用的。这类优化的示例包括常量折叠(例如,concat(lower('a'),upper('b')) 变为 'aB'),从某些聚合函数中提取标量(例如,sum(a*2) 变为 2 * sum(a))、消除公共子表达式,以及将等式过滤的析取变换为 IN 列表(例如,x=c OR x=d 变为 x IN (c,d))。经过优化的语义查询表示随后被转换为逻辑运算符计划。在逻辑计划之上进行的优化包括过滤下推、函数评估和排序步骤的重排序,具体取决于哪个步骤的成本更高。最后,逻辑查询计划被转换为物理运算符计划。该转换可以利用所涉及表引擎的特性。例如,在 MergeTree*-表引擎的情况下,如果 ORDER BY 列构成主键的前缀,则可以按磁盘顺序读取数据,并且可以从计划中移除排序运算符。此外,如果聚合中的分组列构成主键的前缀,ClickHouse 可以使用排序聚合 [\[33\]](#page-12-21),即可以直接对已排序的输入中的相同值的聚合运行进行聚合。与哈希聚合相比,排序聚合显著减少了内存占用,聚合值可以在运行处理后立即传递给下一个运算符。 +**查询优化**。第一组优化是在从查询的 AST 获得的语义查询表示上应用的。这类优化的示例包括常量折叠(例如,concat(lower('a'),upper('b')) 变为 'aB')、从某些聚合函数中提取标量(例如,sum(a*2) 变为 2 * sum(a))、公共子表达式消除,以及将等式过滤器的析取转换为 IN 列表(例如,x=c 或 x=d 变为 x IN (c,d))。优化后的语义查询表示随后被转换为逻辑操作符计划。在逻辑计划上的优化包括过滤下推、重新排序函数评估和排序步骤,具体取决于哪个估计的开销更高。最后,逻辑查询计划被转换为物理操作符计划。该转换可以利用涉及的表引擎的特性。例如,在 ^^MergeTree^^*-^^table engine^^ 的情况下,如果 ORDER BY 列构成 ^^primary key^^ 的前缀,则数据可以按磁盘顺序读取,并且可以从计划中删除排序操作符。此外,如果聚合中的分组列构成 ^^primary key^^ 的前缀,则 ClickHouse 可以使用排序聚合 [\[33\]](#page-12-21),即直接在已排序输入中聚合相同值的运行。与哈希聚合相比,排序聚合在内存使用方面显著减少,并且聚合值可以在处理完一轮后立即传递给下一个操作符。 -**查询编译**。ClickHouse 采用了基于 LLVM 的 [查询编译](https://clickhou.se/jit) 来动态地融合邻近的计划运算符 [\[38,](#page-12-22) [53\]](#page-13-0)。例如,表达式 a * b + c + 1 可以组合成一个运算符,而不是三个运算符。除了表达式外,ClickHouse 还使用编译来同时评估多个聚合函数(即用于 GROUP BY)以及多于一个排序键的排序。查询编译减少了虚拟调用的数量,将数据保持在寄存器或 CPU 缓存中,并帮助分支预测,因为需执行的代码更少。此外,运行时编译启用了一整套丰富的优化,如逻辑优化和在编译器中实现的窥视优化,并能访问最快的本地 CPU 指令。仅当相同的常规、聚合或排序表达式被不同查询执行超过可配置的次数时,才会启动编译。已编译的查询运算符被缓存并可以在将来的查询中重用。 +**查询编译**。ClickHouse 使用 [基于 LLVM 的查询编译](https://clickhou.se/jit) 动态融合相邻的计划操作符 [\[38,](#page-12-22) [53\]](#page-13-0)。例如,表达式 a * b + c + 1 可以合并为一个单一的操作符,而不是三个操作符。除了表达式,ClickHouse 还利用编译来同时评估多个聚合函数(即,针对 GROUP BY),以及针对使用多个排序键的排序。查询编译减少了虚拟调用的数量,将数据保存在寄存器或 CPU 缓存中,并帮助分支预测,因为需要执行的代码较少。此外,运行时编译使得能够实现丰富的优化集,例如编译器中实现的逻辑优化和窥视点优化,并可以访问最快的本地可用 CPU 指令。当相同的常规、聚合或排序表达式被不同查询执行超过可配置的次数时,才会启动编译。编译的查询操作符会被缓存,可以被未来的查询重用。[7] -**主键索引评估**。如果条件的合取范式中的过滤子句的某个子集构成主键列的前缀,ClickHouse 会使用主键索引评估 WHERE 条件。主键索引从左到右在 lexicographically 排序的键值范围上进行分析。与主键列对应的过滤子句使用三元逻辑进行评估——它们全为真、全为假或对范围内的值为混合真/假。在后者的情况下,该范围被拆分为子范围,并进行递归分析。对于过滤条件中的函数还存在其他优化。首先,函数具有描述其单调性的特征,例如,toDayOfMonth(date) 在一个月内是分段单调的。单调性特征允许推断一个函数是否在已排序的输入键值范围内产生排序结果。其次,有些函数可以计算给定函数结果的原像。这用于通过将键列值与原像进行比较,替换常数的比较与键列上的函数调用。例如,toYear(k) = 2024 可以被替换为 k >= 2024-01-01 && k < 2025-01-01。 +**^^Primary key^^ 索引评估**。如果条件的合取范式中的过滤子句子集构成 ^^primary key^^ 列的前缀,则 ClickHouse 使用 ^^primary key^^ 索引评估 WHERE 条件。^^primary key^^ 索引从按字典序排序的键值范围的左侧向右侧分析。与 ^^primary key^^ 列对应的过滤子句使用三元逻辑进行评估——对于范围内的值,它们都为真、都为假,或混合真/假。在后者的情况下,范围被拆分为子范围,并递归分析。过滤条件中的函数也存在额外的优化。首先,函数具有描述其单调性的特征,例如,toDayOfMonth(date) 在一个月中是分段单调。单调性特征允许推断函数在排序输入键值范围上产生排序结果。其次,一些函数可以计算给定函数结果的原像。这用于通过比较键列值和原像来替换与键列的函数调用常量比较。例如,toYear(k) = 2024 可以被替换为 k >= 2024-01-01 && k < 2025-01-01。 -**数据跳过**。ClickHouse 尽量避免在查询运行时读取数据,使用第 [3.2 章](#page-3-0) 中介绍的数据结构。此外,针对不同列的过滤条件根据经验法则和(可选的)列统计信息按估计选择性递减的顺序依次进行评估。只有包含至少一个匹配行的数据块会传递到下一个谓词。这逐步减少了从谓词到谓词的读取数据量和计算数量。该优化仅在至少存在一个高选择性谓词时应用;否则,查询的延迟将相对不如并行评估所有谓词的情况。 +**数据跳过**。ClickHouse 尝试使用在章节 [3.2.](#page-3-0) 中介绍的数据结构在查询运行时避免数据读取。此外,根据启发式和(可选的)列统计,按降序估计选择性依次评估对不同列的过滤器。仅包含至少一行匹配行的数据块将传递到下一个谓词。这逐渐减少了每个谓词读取的数据量和要执行的计算数量。该优化仅在至少存在一个高选择性的谓词时应用;否则,查询的延迟将较之并行评估所有谓词而恶化。 -**哈希表**。哈希表是聚合和哈希连接的基本数据结构。选择正确类型的哈希表对性能至关重要。ClickHouse [实例化](https://clickhou.se/hashtables) 不同的哈希表(截至 2024 年 3 月已有超过 30 种),基于通用哈希表模板,其中哈希函数、分配器、单元类型和调整大小策略为变体点。根据分组列的数据类型、估计的哈希表基数和其他因素,为每个查询运算符单独选择最快的哈希表。为哈希表实施的进一步优化包括: +**哈希表**。哈希表是聚合和哈希连接的基本数据结构。选择合适类型的哈希表对于性能至关重要。ClickHouse 从通用哈希表模板实例化多种哈希表(截至 2024 年 3 月超过 30 种),其哈希函数、分配器、单元类型和调整大小策略作为变异点。根据分组列的数据类型、估计的哈希表基数和其他因素,选择每个查询操作符的最快哈希表。针对哈希表实施的进一步优化包括: - 带有 256 个子表的两级布局(基于哈希的第一个字节)以支持巨大的键集, -- 字符串哈希表 [\[79\]](#page-13-20),不同字符串长度的哈希函数有四个子表, -- 当只有少量键时,使用键直接作为桶索引(即不哈希)查找表, -- 对比较昂贵的值(例如字符串、AST)采用嵌入哈希以加快冲突解决, -- 根据运行时统计数据预测大小创建哈希表,避免不必要的调整大小, -- 在一个内存块上分配多个具有相同创建/销毁生命周期的小哈希表, -- 通过每个哈希映射和每个单元的版本计数器快速清除哈希表以供重用, +- 具有四个子表和不同哈希函数的字符串哈希表 [\[79\]](#page-13-20),适用于不同字符串长度, +- 当键数较少时,查找表直接使用键作为桶索引(即,不进行哈希), +- 对于比较成本较高的值(例如字符串、AST),内嵌哈希以加快碰撞解决速度, +- 根据运行时统计信息预测的大小创建哈希表,以避免不必要的调整大小, +- 在单个内存块上分配多个具有相同创建/销毁生命周期的小哈希表, +- 使用每个哈希图和每个单元版本计数器进行哈希表的即时清除以供重用, - 使用 CPU 预取(__builtin_prefetch)加速哈希键后值的检索。 -**连接**。由于 ClickHouse 最初仅支持基本的连接,因此许多用例历史上 resorted to denormalized tables。如今,数据库 [提供](https://clickhou.se/joins) SQL 中所有的连接类型(内连接、左/右/全外连接、交叉连接、生效连接),以及不同的连接算法,如哈希连接(naïve、grace)、排序-合并连接和索引连接,用于具有快速键值查找(通常是字典)的表引擎。 +**连接**。由于 ClickHouse 最初只粗略支持连接,因此许多使用案例历史上诉诸于非规范化表。如今,数据库 [提供](https://clickhou.se/joins) SQL 中的所有连接类型(内部、左/右/全外部、交叉、时效),以及不同的连接算法,如哈希连接(天真的,格雷斯)、排序-合并连接和用于具有快速键值查找的表引擎的索引连接(通常是字典)。 -由于连接是最耗资源的数据库操作之一,因此提供经典连接算法的并行变体至关重要,理想情况下具有可配置的空间/时间权衡。对于哈希连接,ClickHouse 实现了来自 [\[7\]](#page-12-23) 的非阻塞共享分区算法。例如,[图 9](#page-8-3) 中的查询计算用户在页面命中统计表之间如何移动。连接的构建阶段分为三条通道,覆盖源表的三个不相交范围。使用分区哈希表而不是全局哈希表。工人线程确定构建侧每个输入行的目标分区,通过计算哈希函数的模。访问哈希表分区通过 Gather 交换运算符同步。探测阶段按类似方式查找输入元组的目标分区。虽然此算法为每个元组引入了两个额外的哈希计算,但根据哈希表分区的数量显著减少了构建阶段的锁争用。 +由于连接是数据库操作中最昂贵的,因此为经典的连接算法提供并行版本非常重要,理想情况下具备可配置的空间/时间权衡。对于哈希连接,ClickHouse 实现了来自 [\[7\]](#page-12-23) 的非阻塞共享分区算法。例如, [图 9](#page-8-3) 中的查询通过在页面点击统计表上进行自连接计算用户如何在 URL 之间移动。连接的构建阶段被分为三个通道,覆盖源表的三个不重叠范围。使用分区哈希表,而不是全局哈希表。工人线程通常通过计算哈希函数的模来确定构建端每个输入行的目标分区。对哈希表分区的访问通过 Gather 交换操作符同步。探测阶段以类似方式查找其输入元组的目标分区。虽然该算法为每个元组引入了两个额外的哈希计算,但它极大地减少了构建阶段的锁争用,具体取决于哈希表分区的数量。 图 9:具有三个哈希表分区的并行哈希连接。 + ### 4.5 工作负载隔离 {#4-5-workload-isolation} -ClickHouse 提供并发控制、内存使用限制和 I/O 调度,使用户能够将查询隔离到工作负载类。通过为特定工作负载类设置共享资源(CPU 核心、DRAM、磁盘和网络 I/O)的限制,它确保这些查询不会影响其他关键业务查询。 +ClickHouse 提供并发控制、内存使用限制和 I/O 调度,允许用户将查询隔离到工作负载类中。通过对特定工作负载类的共享资源(CPU 核心、DRAM、磁盘和网络 I/O)设置限制,确保这些查询不会影响其他关键业务查询。 -并发控制防止在同时有大量查询的情况下出现线程超额订阅。具体来说,每个查询的工作线程数量会根据与可用 CPU 核心数量的指定比例动态调整。 +并发控制在有许多并发查询的场景中防止线程的过度订阅。更具体地说,基于可用 CPU 核心数量和指定比例动态调整每个查询的工作线程数。 -ClickHouse 跟踪在服务器、用户和查询级别的内存分配字节大小,从而可以设置灵活的内存使用限制。内存超分配使查询可以使用超出保证内存的额外可用内存,同时确保其他查询的内存限制。此外,可以限制聚合、排序和连接子句的内存使用,当超出内存限制时会将其回退到外部算法。 +ClickHouse 在服务器、用户和查询级别跟踪内存分配的字节大小,从而允许设置灵活的内存使用限制。内存过度承诺使查询能够使用超出保证内存的额外空闲内存,同时确保其他查询的内存限制。此外,可以限制用于聚合、排序和连接子句的内存使用,当超出内存限制时,可能导致回退到外部算法。 -最后,I/O 调度允许用户根据最大带宽、进行中的请求和策略(例如 FIFO、SFC [\[32\]](#page-12-24))限制工作负载类的本地和远程磁盘访问。 +最后,I/O 调度允许用户根据最大带宽、并发请求和策略(例如 FIFO,SFC [\[32\]](#page-12-24))限制工作负载类的本地和远程磁盘访问。 ### 5 集成层 {#5-integration-layer} -实时决策应用程序通常依赖于多位置中的高效低延迟访问数据。有两种方法可以在 OLAP 数据库中提供外部数据。通过基于推送的数据访问,第三方组件将数据库与外部数据存储连接。例如,专门的 ETL(提取-转换-加载)工具通过将远程数据推送到目标系统来实现这一点。在拉取模型中,数据库本身连接到远程数据源并将数据拉取到本地表中进行查询或导出数据到远程系统。尽管基于推送的方法更加多样和常见,但它们具有更大的架构占用和可扩展性瓶颈。相比之下,数据库中的远程连接提供了有趣的能力,例如本地和远程数据之间的连接,同时保持整体架构简单,并减少洞察时间。 +实时决策应用程序通常依赖于对多个位置数据的高效和低延迟访问。有两种方法可以将外部数据提供给 OLAP 数据库。通过基于推送的数据访问,第三方组件将数据库与外部数据存储连接起来。专门的提取-转换-加载(ETL)工具就是这样的一个例子,它将远程数据推送到目标系统。在基于拉取的模型中,数据库本身连接到远程数据源,并将数据提取到本地表或将数据导出到远程系统。虽然基于推送的方法更具灵活性和更常见,但它们会产生更大的架构占用和可扩展性瓶颈。相比之下,数据库中的远程连接提供了有趣的能力,例如在本地和远程数据之间进行连接,同时保持整体架构简单,减少洞察所需的时间。 -本节其余部分探讨 ClickHouse 中的基于拉取的数据集成方法,旨在访问远程位置的数据。我们注意到 SQL 数据库中的远程连接概念并不新鲜。例如,SQL/MED 标准 [\[35\]](#page-12-25),于 2001 年引入,并自 2011 年起由 PostgreSQL 实施 [\[65\]](#page-13-21),建议将外部数据包装器作为管理外部数据的统一接口。与其他数据存储和存储格式的最大互操作性是 ClickHouse 的设计目标之一。截至 2024 年 3 月,ClickHouse 据我们所知提供了所有分析数据库中最多的内置数据集成选项。 +本节的其余部分探讨了 ClickHouse 中的基于拉取的数据集成方法,旨在访问远程位置的数据。我们注意到 SQL 数据库中的远程连接思想并不新鲜。例如, SQL/MED 标准 [\[35\]](#page-12-25),于 2001 年引入,自 2011 年以来已在 PostgreSQL 中实现 [\[65\]](#page-13-21),提出了外部数据包装器作为管理外部数据的统一接口。与其他数据存储和存储格式的最大互操作性是 ClickHouse 的设计目标之一。截至 2024 年 3 月,ClickHouse 提供了我们所知的所有分析数据库中最多的内置数据集成选项。 -外部连接。ClickHouse 提供了 [50+](https://clickhou.se/query-integrations) 种集成表函数和引擎,以便与外部系统和存储位置连接,包括 ODBC、MySQL、PostgreSQL、SQLite、Kafka、Hive、MongoDB、Redis、S3/GCP/Azure 对象存储和各种数据湖。我们进一步将它们细分为以下附加图所示的类别(不属于原始 vldb 论文)。 +外部连接。ClickHouse 提供 [50+](https://clickhou.se/query-integrations) 积分表函数和引擎,用于与外部系统和存储位置的连接,包括 ODBC、MySQL、PostgreSQL、SQLite、Kafka、Hive、MongoDB、Redis、S3/GCP/Azure 对象存储和各种数据湖。我们进一步将它们分为如下图所示的类别(不是原始 vldb 论文的一部分)。 -附加图:ClickBench 的互操作选项。 +奖金图:ClickBench 的互操作性选项。 -通过集成 **表函数** 临时访问。表函数可以在 SELECT 查询的 FROM 子句中被调用,以读取远程数据进行探索性的临时查询。或者,它们可用于通过 INSERT INTO TABLE FUNCTION 语句将数据写入远程存储。 +通过集成 **表函数** 进行临时访问。表函数可以在 SELECT 查询的 FROM 子句中被调用,以读取远程数据以进行探索性临时查询。或者,它们可以用于通过 INSERT INTO TABLE FUNCTION 语句将数据写入远程存储。 -持久访问。有三种方法可以与远程数据存储和处理系统创建永久连接。 +持久性访问。创建与远程数据存储和处理系统的永久连接有三种方法。 -首先,集成 **表引擎** 将远程数据源(例如 MySQL 表)表示为持久的本地表。用户使用 CREATE TABLE AS 语法存储表定义,结合 SELECT 查询和表函数。可以指定自定义模式,例如,仅引用远程列的子集,或者使用模式推断自动确定列名和等效的 ClickHouse 类型。我们进一步区分被动和主动的运行时行为:被动表引擎将查询转发到远程系统,并使用结果填充本地代理表。相比之下,主动表引擎定期从远程系统拉取数据,或订阅远程更改,例如,通过 PostgreSQL 的逻辑复制协议。因此,本地表包含远程表的完整副本。 +首先,集成 **表引擎** 将远程数据源(如 MySQL 表)表示为持久的本地表。用户使用 CREATE TABLE AS 语法结合 SELECT 查询和表函数存储表定义。可以指定自定义架构,例如,仅引用远程列的子集,或使用架构推理自动确定列名称和相应的 ClickHouse 类型。我们进一步区分被动和主动的运行时行为:被动表引擎将查询转发到远程系统,并用结果填充本地代理表。相反,主动表引擎定期从远程系统提取数据或订阅远程更改,例如,通过 PostgreSQL 的逻辑复制协议。因此,本地表包含远程表的完整副本。 -第二,集成 **数据库引擎** 将远程数据存储中的表模式的所有表映射到 ClickHouse。与前者不同,它们通常要求远程数据存储是关系型数据库,并且额外提供有限的 DDL 语句支持。 +其次,集成 **数据库引擎** 在 ClickHouse 中映射远程数据存储中表架构的所有表。与前者不同,它们通常要求远程数据存储为关系数据库,并且提供对 DDL 语句的有限支持。 -第三,**字典** 可以使用针对几乎所有可能数据源的任意查询填充,配合相应的集成表函数或引擎。由于数据是以恒定的时间间隔从远程存储拉取,因此运行时行为是主动的。 +第三,**字典** 可以使用针对此前几乎所有可能数据源的任意查询填充,这些数据源具有相应的集成表函数或引擎。运行时行为是主动的,因为数据以固定时间间隔从远程存储中提取。 -数据格式。为了与第三方系统交互,现代分析型数据库还必须能够处理任何格式的数据。除了其原生格式外,ClickHouse 还支持 [90+](https://clickhou.se/query-formats) 种格式,包括 CSV、JSON、Parquet、Avro、ORC、Arrow 和 Protobuf。每种格式可以是输入格式(ClickHouse 可以读取)、输出格式(ClickHouse 可以导出)或两者兼有。一些面向分析的格式(如 Parquet)也与查询处理集成,即优化器可以利用嵌入的统计信息,并在压缩数据上直接评估过滤条件。 +数据格式。为了与第三方系统进行交互,现代分析数据库还必须能够处理以任何格式的数据。除了其原生格式外,ClickHouse 还支持 [90+](https://clickhou.se/query-formats) 种格式,包括 CSV、JSON、Parquet、Avro、ORC、Arrow 和 Protobuf。每种格式可以是输入格式(ClickHouse 可以读取)、输出格式(ClickHouse 可以导出),或两者皆是。一些面向分析的格式如 Parquet 还与查询处理集成,即优化器可以利用嵌入的统计信息,并在压缩数据上直接评估过滤器。 -兼容性接口。除其原生的二进制 wire 协议和 HTTP 外,客户端还可以通过 MySQL 或 PostgreSQL wire-protocol 兼容接口与 ClickHouse 交互。这一兼容性特性对于启用来自专有应用程序(例如某些商业智能工具)的访问非常有用,因为这些供应商尚未实现原生的 ClickHouse 连接。 +兼容性接口。除了其原生的二进制通信协议和 HTTP,客户端还可以通过与 MySQL 或 PostgreSQL 其他协议兼容的接口与 ClickHouse 进行交互。这种兼容性特性对于启用来自专有应用程序的访问(例如,某些商业智能工具),其中供应商尚未实现本地 ClickHouse 连接非常有用。 -## 6 性能作为特性 {#6-performance-as-a-feature} +## 6 性能作为一个特性 {#6-performance-as-a-feature} 本节介绍了用于性能分析的内置工具,并使用真实世界和基准查询评估性能。 ### 6.1 内置性能分析工具 {#6-1-built-in-performance-analysis-tools} -有多种工具可用于调查单个查询或后台操作中的性能瓶颈。用户通过基于系统表的统一接口与所有工具进行交互。 +有一系列工具可以用来调查单个查询或后台操作中的性能瓶颈。用户通过基于系统表的统一接口与所有工具进行交互。 -**服务器和查询指标**。服务器级统计数据,如活动部分计数、网络吞吐量和缓存命中率,辅以每个查询统计数据,例如读取的块数或索引使用统计。指标在可配置的时间间隔内同步(根据请求)或异步计算。 +**服务器和查询指标**。服务器级统计数据,例如活动部分计数、网络吞吐量和缓存命中率,补充每个查询的统计数据,如读取的块数或索引使用统计。指标在可配置的间隔内同步(应请求)或异步计算。 -**采样分析器**。使用采样分析器可以收集服务器线程的调用栈。结果可以选择性地导出到外部工具,如火焰图可视化工具。 +**采样分析器**。可以使用采样分析器收集服务器线程的调用堆栈。结果可以选择性地导出到外部工具,如 flamegraph 可视化工具。 -**OpenTelemetry 集成**。OpenTelemetry 是一个用于跨多个数据处理系统跟踪数据行的开放标准 [\[8\]](#page-12-26)。ClickHouse 可以为所有查询处理步骤生成具有可配置粒度的 OpenTelemetry 日志跨度,并从其他系统收集和分析 OpenTelemetry 日志跨度。 +**OpenTelemetry 集成**。OpenTelemetry 是一种用于跨多个数据处理系统跟踪数据行的开放标准 [\[8\]](#page-12-26)。ClickHouse 可以为所有查询处理步骤生成可配置粒度的 OpenTelemetry 日志跨度,并收集和分析来自其他系统的 OpenTelemetry 日志跨度。 -**解释查询**。与其他数据库一样,SELECT 查询可以用 EXPLAIN 作为前缀,为查询的 AST、逻辑和物理运算符计划以及执行时间行为提供详细洞察。 +**解释查询**。与其他数据库一样,SELECT 查询可以用 EXPLAIN 作为前缀,以获得关于查询的 AST、逻辑和物理操作计划以及执行时间行为的详细见解。 ### 6.2 基准测试 {#6-2-benchmarks} -尽管基准测试因其不现实而受到批评 [\[10,\](#page-12-27) [52,\](#page-13-22) [66,\](#page-13-23) [74\]](#page-13-24),但它仍然有助于识别数据库的优缺点。接下来,我们讨论如何使用基准测试来评估 ClickHouse 的性能。 +尽管基准测试因不够现实而受到批评 [\[10,](#page-12-27) [52,](#page-13-22) [66,](#page-13-23) [74\]](#page-13-24),但它仍然有助于识别数据库的优缺点。在接下来的章节中,我们讨论了如何使用基准测试评估 ClickHouse 的性能。 #### 6.2.1 非规范化表 {#6-2-1-denormalized-tables} -在历史上,针对非规范化事实表的过滤和聚合查询代表了ClickHouse的主要用例。我们报告了ClickBench的运行时间,这是一个典型的工作负载,模拟了在点击流和流量分析中使用的临时和定期报告查询。基准测试由43个查询组成,针对一个拥有1亿个匿名页面点击的数据表,这些数据来自网络上最大的分析平台之一。线上仪表盘 [\[17\]](#page-12-28) 显示了截至2024年6月对超过45个商业和研究数据库的测量结果(冷/热运行时间、数据导入时间、磁盘大小)。结果由独立贡献者提交,基于公开可用的数据集和查询 [\[16\]](#page-12-29)。查询测试了顺序和索引扫描访问路径,并常常暴露出CPU、IO或内存绑定的关系运算符。 +对非规范化事实表的过滤和聚合查询历来是 ClickHouse 的主要使用案例。我们报告了 ClickBench 的运行时间,这是一种典型的工作负载,模拟了在点击流和流量分析中使用的临时和定期报告查询。基准测试由 43 个查询组成,这些查询针对一个包含 1 亿个匿名页面点击的表,该表来源于网络上最大的分析平台之一。一个在线仪表板 [\[17\]](#page-12-28) 显示截至 2024 年 6 月对 45 个商业和研究数据库的测量(冷/热运行时间,数据导入时间,磁盘大小)。结果由独立贡献者根据公开可用的数据集和查询 [\[16\]](#page-12-29) 提交。这些查询测试了顺序和索引扫描访问路径,并常常暴露出 CPU、IO 或内存绑定的关系操作符。 -[图10](#page-10-0) 显示了在常用于分析的数据库中顺序执行所有ClickBench查询的总相对冷和热运行时间。测量是在一个单节点的AWS EC2 c6a.4xlarge实例上进行的,该实例具有16个vCPU、32 GB RAM和5000 IOPS/1000 MiB/s磁盘。类似系统用于Redshift ([ra3.4xlarge](https://clickhou.se/redshift-sizes),12个vCPU,96 GB RAM)和Snowfake ([warehouse size S](https://clickhou.se/snowflake-sizes):2x8 vCPU,2x16 GB RAM)。物理数据库设计仅轻度调优,例如,我们指定主键,但不更改单列的压缩,不创建投影或跳过索引。我们还在每次冷查询运行之前刷新Linux页面缓存,但不调整数据库或操作系统的参数。对于每个查询,数据库中最快的运行时间作为基准。其他数据库的相对查询运行时间计算为(+10)/(_+10)。数据库的总相对运行时间是每个查询比例的几何平均值。尽管研究数据库Umbra [\[54\]](#page-13-25)实现了最佳的总体热运行时间,但ClickHouse在热和冷运行时间上超越了所有其他生产级数据库。 +[图 10](#page-10-0) 显示了在分析中常用的数据库中顺序执行所有 ClickBench 查询的总相对冷和热运行时间。测量是在单节点 AWS EC2 c6a.4xlarge 实例(16 个 vCPU,32 GB RAM,5000 IOPS / 1000 MiB/s 磁盘)上进行的。与 Redshift([ra3.4xlarge](https://clickhou.se/redshift-sizes),12 个 vCPU,96 GB RAM)和 Snowfake([仓库大小 S](https://clickhou.se/snowflake-sizes):2x8 vCPU,2x16 GB RAM)相比,使用了可比系统。物理数据库设计仅轻微调整,例如,我们指定了主键,但不更改单个列的压缩、创建投影或跳过索引。我们还在每次冷查询运行之前刷新 Linux 页面缓存,但不调整数据库或操作系统的控制参数。对于每个查询,使用数据库中最快的运行时间作为基准。其他数据库的相对查询运行时间计算为 ( + 10)/(_ + 10)。数据库的总相对运行时间是每个查询比率的几何平均值。虽然研究数据库 Umbra [\[54\]](#page-13-25) 实现了最佳的整体热运行时间,但 ClickHouse 在热和冷运行时间方面的表现超过了所有其他生产级数据库。 -图10:ClickBench的相对冷和热运行时间。 +图 10: ClickBench 的相对冷和热运行时间。 -为了随时间跟踪SELECT的性能在更为多样的工作负载中,我们 [使用](https://clickhou.se/performance-over-years) 了一种名为VersionsBench的四个基准的组合 [\[19\]](#page-12-30)。该基准每月执行一次,当发布新版本时,以评估其性能 [\[20\]](#page-12-31) 并识别可能降低性能的代码更改:单个基准包括:1. ClickBench(如上所述),2. 15个MgBench [\[21\]](#page-12-32) 查询,3. 针对一个具有6亿行的非规范化星型模式基准 [\[57\]](#page-13-26)事实表的13个查询。4. 针对 [NYC Taxi Rides](https://clickhou.se/nyc-taxi-rides-benchmark) 的4个查询,包含34亿行 [\[70\]](#page-13-27)。 +为了跟踪 SELECT 在更具多样性的工作负载中的性能变化,我们 [使用](https://clickhou.se/performance-over-years) 四个基准组合称为 VersionsBench [\[19\]](#page-12-30)。这一基准每月执行一次,当发布新版本时评估其性能 [\[20\]](#page-12-31) 并识别可能导致性能下降的代码变更:单个基准包括:1. ClickBench(如上所述),2. 15 个 MgBench [\[21\]](#page-12-32) 查询,3. 针对包含 6 亿行的非规范化星型架构基准 [\[57\]](#page-13-26) 的 13 个查询。4. 针对 [NYC Taxi Rides](https://clickhou.se/nyc-taxi-rides-benchmark) 的 4 个查询,涉及 34 亿行 [\[70\]](#page-13-27)。 -[图11](#page-10-5) 显示了在2018年3月到2024年3月之间77个ClickHouse版本的VersionsBench运行时间的发展。为了补偿单个查询相对运行时间的差异,我们使用几何平均值对运行时间进行归一化,以最小查询运行时间的比例作为权重。过去六年中,VersionBench的性能提高了1.72倍。长期支持(LTS)版本的发布日期标记在x轴上。尽管在某些时期性能暂时下降,但LTS版本通常具有与前一个LTS版本可比拟或更好的性能。2022年8月的显著改善是由第 [4.4节](#page-7-0) 中描述的逐列过滤评估技术引起的。 +[图 11](#page-10-5) 显示了 2018 年 3 月到 2024 年 3 月之间 77 个 ClickHouse 版本的 VersionsBench 运行时间的发展。为了补偿单个查询相对运行时间的差异,我们使用几何平均数进行归一化,权重是所有版本中最小查询运行时间的比率。VersionBench 的性能在过去六年中提高了 1.72 倍。长期支持(LTS)版本的发布日期标记在 x 轴上。尽管在某些时期性能暂时下降,但 LTS 版本通常具有与之前的 LTS 版本相当或更好的性能。2022 年 8 月的显著改进是由于在 [4.4](#page-7-0) 节中描述的按列过滤评估技术造成的。 -图11:VersionsBench 2018-2024的相对热运行时间。 +图 11: VersionsBench 2018-2024 的相对热运行时间。 #### 6.2.2 规范化表 {#6-2-2-normalized-tables} -在经典的数据仓库中,数据通常使用星型或雪花模式建模。我们呈现TPCH查询(规模因子100)的运行时间,但注意到规范化表是ClickHouse的一个新兴用例。[图12](#page-10-6) 显示基于第 [4.4节](#page-7-0) 中描述的并行哈希连接算法的TPC-H查询的热运行时间。测量是在一个单节点的AWS EC2 c6i.16xlarge实例上进行的,具有64个vCPU、128 GB RAM和5000 IOPS/1000 MiB/s磁盘。记录了五次运行中最快的一次。作为参考,我们在一个规模相当的Snowfake系统中进行了相同的测量(仓库大小L,8x8 vCPU,8x16 GB RAM)。表中排除了11个查询的结果:查询Q2、Q4、Q13、Q17以及Q20-22包含在ClickHouse v24.6时尚不支持的相关子查询。查询Q7-Q9和Q19依赖于用于连接的扩展计划级优化,例如连接重排序和连接谓词下推(在ClickHouse v24.6中均缺失),以实现可行的运行时间。计划于2024年实现自动子查询去相关化及更好的连接优化器支持 [\[18\]](#page-12-33)。在其余的11个查询中,5个(6个)查询在ClickHouse中执行得更快(Snowfake)。正如前所述的优化被认为对性能至关重要 [\[27\]](#page-12-34),我们预计一旦实施,它们将进一步改善这些查询的运行时间。 +在经典仓库中,数据通常使用星型或雪花架构建模。我们呈现了 TPC-H 查询(缩放因子 100)的运行时间,但指出规范化表是 ClickHouse 的新兴使用案例。[图 12](#page-10-6) 显示了基于 [4.4](#page-7-0) 节中描述的并行哈希连接算法的 TPC-H 查询的热运行时间。测量是在单节点 AWS EC2 c6i.16xlarge 实例(64 个 vCPU,128 GB RAM,5000 IOPS / 1000 MiB/s 磁盘)上进行的。记录了五次运行中的最快时间。作为参考,我们在可比大小的 Snowfake 系统(仓库大小 L, 8x8 vCPU,8x16 GB RAM)中进行了相同的测量。十一条查询的结果从表格中排除:查询 Q2、Q4、Q13、Q17 和 Q20-22 包含 ClickHouse v24.6 不支持的相关子查询。查询 Q7-Q9 和 Q19 依赖于连接的扩展计划级优化,例如连接重排序和连接谓词下推(在 ClickHouse v24.6 中均缺失),以实现可行的运行时间。计划在 2024 年实施自动子查询去相关和更好的连接优化器支持 [\[18\]](#page-12-33)。在剩余的 11 个查询中,5 个(6 个)查询在 ClickHouse 中执行得更快(Snowfake)。如前所述,这些优化被认为对性能至关重要 [\[27\]](#page-12-34),预计它们在实施后将进一步改善这些查询的运行时间。 -图12:TPC-H查询的热运行时间(秒)。 +图 12: TPC-H 查询的热运行时间(以秒为单位)。 ## 7 相关工作 {#7-related-work} -分析数据库在最近几十年受到了广泛的学术和商业关注 [\[1\]](#page-12-35)。早期的系统如Sybase IQ [\[48\]](#page-13-28)、Teradata [\[72\]](#page-13-29)、Vertica [\[42\]](#page-12-36)和Greenplum [\[47\]](#page-13-30)的特点是昂贵的批量ETL作业和由于其本地性质造成的有限弹性。在2010年代初,云本地数据仓库和数据库即服务(DBaaS)的出现,如Snowfake [\[22\]](#page-12-37)、BigQuery [\[49\]](#page-13-31)和Redshift [\[4\]](#page-12-38),在降低组织分析成本和复杂性的同时,受益于高可用性和自动资源扩展。最近,分析执行内核(如Photon [\[5\]](#page-12-39)和Velox [\[62\]](#page-13-32))提供了用于不同分析、流媒体和机器学习应用的协同修改数据处理。 +在最近几十年里,分析数据库引起了学术界和商业界的极大关注 [\[1\]](#page-12-35)。早期系统如 Sybase IQ [\[48\]](#page-13-28)、Teradata [\[72\]](#page-13-29)、Vertica [\[42\]](#page-12-36) 和 Greenplum [\[47\]](#page-13-30) 的特点是昂贵的批量 ETL 作业和由于其本地性质而受到的有限弹性。2010 年代初,云原生数据仓库和数据库即服务(DBaaS)产品如 Snowfake [\[22\]](#page-12-37)、BigQuery [\[49\]](#page-13-31) 和 Redshift [\[4\]](#page-12-38) 的出现显著降低了组织分析的成本和复杂性,同时受益于高可用性和自动资源扩展。最近,分析执行内核(例如 Photon [\[5\]](#page-12-39) 和 Velox [\[62\]](#page-13-32))为不同的分析、流处理和机器学习应用提供了共同修改的数据处理。 -与ClickHouse在目标和设计原则上最相似的数据库是Druid [\[78\]](#page-13-33)和Pinot [\[34\]](#page-12-40)。这两个系统的目标是实时分析,具有高数据摄取速率。与ClickHouse类似,表被分割成称为段的水平部分。虽然ClickHouse持续合并较小的部分,并可选地使用第 [3.3节](#page-4-3) 中的技术减少数据量,但在Druid和Pinot中,部分保持永不可变。此外,Druid和Pinot需要专门的节点来创建、修改和搜索表,而ClickHouse则为这些任务使用单体二进制。 +在目标和设计原则上,与 ClickHouse 最相似的数据库是 Druid [\[78\]](#page-13-33) 和 Pinot [\[34\]](#page-12-40)。这两个系统均以高数据摄取率为目标进行实时分析。与 ClickHouse 相似,表被分成称为分段的水平 ^^parts^^。虽然 ClickHouse 不断合并较小的 ^^parts^^ 并可以选择使用 [3.3](#page-4-3) 节中的技术减少数据量,但 Druid 和 Pinot 中的 ^^parts^^ 永远是不可变的。此外,Druid 和 Pinot 需要专门的节点来创建、修改和搜索表,而 ClickHouse 使用单一二进制程序来执行这些任务。 -Snowfake [\[22\]](#page-12-37) 是一个基于共享磁盘架构的流行专有云数据仓库。它将表划分为微分区的方法与ClickHouse中的部分概念相似。Snowfake使用混合PAX页面 [\[3\]](#page-12-41) 进行持久化,而ClickHouse的存储格式则严格为列式。Snowfake还强调本地缓存和通过自动创建的轻量级索引的 数据修剪 [\[31,](#page-12-13) [51\]](#page-13-14) 作为良好性能的来源。与ClickHouse中的主键类似,用户还可以选择创建聚簇索引,以共同定位具有相同值的数据。 +Snowfake [\[22\]](#page-12-37) 是一个基于共享磁盘架构的流行专有云数据仓库。其将表划分为微分区的方法与 ClickHouse 中的 ^^parts^^ 概念类似。Snowfake 使用混合 PAX 页 [\[3\]](#page-12-41) 进行持久化,而 ClickHouse 的存储格式则严格为列式。Snowfake 还强调使用自动创建的轻量级索引 [\[31,](#page-12-13) [51\]](#page-13-14) 进行本地缓存和数据修剪,以实现良好的性能。类似于 ClickHouse 中的主键,用户还可以选择创建聚簇索引以将具有相同值的数据放在一起。 -Photon [\[5\]](#page-12-39)和Velox [\[62\]](#page-13-32)是设计为作为复杂数据管理系统组件使用的查询执行引擎。这两个系统将查询计划作为输入,然后在本地节点上针对Parquet(Photon)或Arrow(Velox)文件执行查询 [\[46\]](#page-13-34)。ClickHouse能够消耗和生成这些通用格式的数据,但更倾向于其本地文件格式进行存储。虽然Velox和Photon并不优化查询计划(Velox执行基本的表达式优化),但它们利用运行时适应性技术,例如根据数据特征动态切换计算内核。同样,ClickHouse中的计划操作符 +Photon [\[5\]](#page-12-39) 和 Velox [\[62\]](#page-13-32) 是旨在用作复杂数据管理系统组件的查询执行引擎。这两个系统将查询计划作为输入传递,然后在本地节点上执行 Parquet(Photon)或 Arrow(Velox)文件 [\[46\]](#page-13-34)。ClickHouse 能够消耗和生成这些通用格式的数据,但更倾向于其本地文件格式进行存储。尽管 Velox 和 Photon 不会优化查询计划(Velox 进行基本的表达式优化),但它们利用运行时自适应技术,例如根据数据特征动态切换计算内核。同样,ClickHouse 中的计划操作符 -可以在运行时创建其他操作符,主要是基于查询内存消耗切换到外部聚合或连接操作符。Photon论文指出代码生成设计 [\[38,](#page-12-22) [41,](#page-12-42) [53\]](#page-13-0) 较难开发和调试,而解释型矢量化设计 [\[11\]](#page-12-0) 则较为简单。Velox的(实验性)代码生成支持构建并链接由运行时生成的C++代码所产生的共享库,而ClickHouse直接与LLVM的按需编译API进行交互。 +可以在运行时创建其他操作符,主要是根据查询内存消耗切换到外部聚合或连接操作符。Photon 论文指出,生成代码的设计 [\[38,](#page-12-22) [41,](#page-12-42) [53\]](#page-13-0) 比解释的矢量化设计 [\[11\]](#page-12-0) 更难开发和调试。Velox 中对代码生成的(实验性)支持构建和链接从运行时生成的 C++ 代码生成的共享库,而 ClickHouse 是直接与 LLVM 的请求编译 API 进行交互。 -DuckDB [\[67\]](#page-13-6) 也旨在被主机进程嵌入,但还提供查询优化和事务。它被设计用于混合偶尔OLTP语句的OLAP查询。因此,DuckDB选择了DataBlocks [\[43\]](#page-12-43) 存储格式,该格式采用轻量级压缩方法,例如保持顺序的字典或参考框架 [\[2\]](#page-12-10),以在混合工作负载中获得良好性能。相比之下,ClickHouse被优化为仅附加用例,即没有或很少更新和删除。块是使用重型技术(如LZ4)进行压缩的,假设用户会宽松地使用数据修剪来加速频繁的查询,并且I/O成本在其余查询中大于解压缩成本。DuckDB还提供基于Hyper的MVCC方案 [\[55\]](#page-13-35) 的可串行化事务,而ClickHouse仅提供快照隔离。 -## 8 结论与展望 {#8-conclusion-and-outlook} +DuckDB [\[67\]](#page-13-6) 也旨在被主机进程嵌入,但此外提供查询优化和事务。它被设计用于 OLAP 查询混合偶尔的 OLTP 语句。DuckDB 因此选择了 DataBlocks [\[43\]](#page-12-43) 存储格式,该格式采用轻量压缩方法,例如保持顺序字典或参考框架 [\[2\]](#page-12-10) 在混合工作负载中实现良好的性能。相比之下,ClickHouse 针对仅追加的用例进行了优化,即几乎不或很少进行更新和删除。块使用重型技术(如 LZ4)进行压缩,假设用户会大量使用数据修剪来加快频繁查询,而 I/O 成本在剩余查询的解压缩成本中占主导地位。DuckDB 还提供基于 Hyper 的 MVCC 方案 [\[55\]](#page-13-35) 的可序列化事务,而 ClickHouse 仅提供快照隔离。 +## 8 结论和展望 {#8-conclusion-and-outlook} -我们介绍了ClickHouse的架构,一个开源的高性能OLAP数据库。ClickHouse以写优化的存储层和最先进的矢量化查询引擎为基础,实现了对PB级数据集的实时分析,具有高摄取率。通过在后台以异步方式合并和转换数据,ClickHouse有效地解耦了数据维护和并行插入。其存储层通过稀疏主索引、跳过索引和投影表实现了激进的数据修剪。我们描述了ClickHouse对更新和删除的实现、幂等插入以及跨节点的数据复制以实现高可用性。查询处理层使用丰富的技术对查询进行优化,并在所有服务器和集群资源之间并行执行。集成表引擎和函数提供了一种便捷的方式,可以与其他数据管理系统和数据格式无缝互动。通过基准测试,我们证明ClickHouse是在市场上最快的分析数据库之一,并且我们展示了ClickHouse在多年来的真实部署中对典型查询性能的显著改善。 +我们介绍了 ClickHouse 的架构,这是一款开源的高性能 OLAP 数据库。凭借写优化的存储层和最先进的矢量化查询引擎作为基础,ClickHouse 能够对 PB 级数据集进行实时分析,具有高摄取率。通过在后台异步合并和转换数据,ClickHouse 高效地解耦了数据维护和并行插入。其存储层利用稀疏主索引、跳过索引和 ^^projection^^ 表实现了积极的数据修剪。我们描述了 ClickHouse 对更新和删除的实现、幂等性插入以及跨节点的数据复制以实现高可用性。查询处理层利用丰富的技术优化查询,并在所有服务器和 ^^cluster^^ 资源中实现并行执行。集成表引擎和函数提供了一种方便的方式,以无缝地与其他数据管理系统和数据格式进行交互。通过基准测试,我们展示了 ClickHouse 是市场上最快的分析数据库之一,并展示了 ClickHouse 在实际部署中典型查询性能的显著改善。 -所有计划于2024年推出的功能和增强功能可以在公开路线图上找到 [\[18\]](#page-12-33)。计划的改进包括对用户事务的支持、PromQL [\[69\]](#page-13-36) 作为替代查询语言、用于半结构化数据的新数据类型(例如JSON)、更好的连接计划级优化,以及实施轻量级更新以补充轻量级删除。 +计划于 2024 年实施的所有功能和增强功能可以在公共路线图中找到 [\[18\]](#page-12-33)。计划的改进包括对用户事务的支持、PromQL [\[69\]](#page-13-36) 作为替代查询语言、用于半结构化数据(例如 JSON)的新数据类型、连接的更好的计划级优化,以及轻量级更新的实现以补充轻量级删除。 ## 致谢 {#acknowledgements} -根据版本24.6,SELECT * FROM system.contributors 返回1994名对ClickHouse做出贡献的个人。我们要感谢ClickHouse Inc.的整个工程团队和ClickHouse卓越的开源社区,感谢他们在共同构建此数据库方面的辛勤工作和奉献精神。 +根据版本 24.6,SELECT * FROM system.contributors 返回了 1994 名为 ClickHouse 贡献的个人。我们要感谢 ClickHouse Inc. 的整个工程团队和 ClickHouse 的出色开源社区,感谢他们在共同构建这个数据库中的辛勤工作和奉献。 ## REFERENCES {#references} -- [1] Daniel Abadi, Peter Boncz, Stavros Harizopoulos, Stratos Idreaos, 和 Samuel Madden. 2013. 现代列式数据库系统的设计与实现. https://doi.org/10.1561/9781601987556 -- [2] Daniel Abadi, Samuel Madden, 和 Miguel Ferreira. 2006. 在列式数据库系统中集成压缩和执行. 在2006年ACM SIGMOD国际数据管理大会(SIGMOD '06)论文集. 671–682. https://doi.org/10.1145/1142473.1142548 -- [3] Anastassia Ailamaki, David J. DeWitt, Mark D. Hill, 和 Marios Skounakis. 2001. 为缓存性能织造关系. 在第27届国际大型数据库会议(VLDB '01)论文集. Morgan Kaufmann Publishers Inc., San Francisco, CA, USA, 169–180. -- [4] Nikos Armenatzoglou, Sanuj Basu, Naga Bhanoori, Mengchu Cai, Naresh Chainani, Kiran Chinta, Venkatraman Govindaraju, Todd J. Green, Monish Gupta, Sebastian Hillig, Eric Hotinger, Yan Leshinksy, Jintian Liang, Michael McCreedy, Fabian Nagel, Ippokratis Pandis, Panos Parchas, Rahul Pathak, Orestis Polychroniou, Foyzur Rahman, Gaurav Saxena, Gokul Soundararajan, Sriram Subramanian, 和 Doug Terry. 2022. Amazon Redshift 重新发明. 在2022年国际数据管理大会(费城,PA,USA)(SIGMOD '22)论文集. 计算机协会,纽约,NY,USA, 2205–2217. https://doi.org/10.1145/3514221.3526045 -- [5] Alexander Behm, Shoumik Palkar, Utkarsh Agarwal, Timothy Armstrong, David Cashman, Ankur Dave, Todd Greenstein, Shant Hovsepian, Ryan Johnson, Arvind Sai Krishnan, Paul Leventis, Ala Luszczak, Prashanth Menon, Mostafa Mokhtar, Gene Pang, Sameer Paranjpye, Greg Rahn, Bart Samwel, Tom van Bussel, Herman van Hovell, Maryann Xue, Reynold Xin, 和 Matei Zaharia. 2022. Photon: 面向湖屋系统的快速查询引擎 (SIGMOD '22). 计算机协会,纽约,NY,USA, 2326–2339. [https://doi.org/10.1145/3514221.](https://doi.org/10.1145/3514221.3526054) [3526054](https://doi.org/10.1145/3514221.3526054) -- [6] Philip A. Bernstein 和 Nathan Goodman. 1981. 分布式数据库系统中的并发控制. ACM Computing Survey 13, 2 (1981), 185–221. https://doi.org/10.1145/356842.356846 -- [7] Spyros Blanas, Yinan Li, 和 Jignesh M. Patel. 2011. 为多核CPU设计和评估主记忆哈希连接算法. 在2011年ACM SIGMOD国际数据管理大会(雅典,希腊)(SIGMOD '11)论文集. 计算机协会,纽约,NY,USA, 37–48. https://doi.org/10.1145/1989323.1989328 +- [1] Daniel Abadi, Peter Boncz, Stavros Harizopoulos, Stratos Idreaos, and Samuel Madden. 2013. 现代列式数据库系统的设计与实现. https://doi.org/10.1561/9781601987556 +- [2] Daniel Abadi, Samuel Madden, and Miguel Ferreira. 2006. 在列式数据库系统中集成压缩和执行. 在2006年ACM SIGMOD国际数据管理会议论文集中(SIGMOD '06). 671–682. https://doi.org/10.1145/1142473.1142548 +- [3] Anastassia Ailamaki, David J. DeWitt, Mark D. Hill, and Marios Skounakis. 2001. 编织关系以提高缓存性能. 在第27届国际大型数据库会议(VLDB '01)论文集中. Morgan Kaufmann Publishers Inc., San Francisco, CA, USA, 169–180. +- [4] Nikos Armenatzoglou, Sanuj Basu, Naga Bhanoori, Mengchu Cai, Naresh Chainani, Kiran Chinta, Venkatraman Govindaraju, Todd J. Green, Monish Gupta, Sebastian Hillig, Eric Hotinger, Yan Leshinksy, Jintian Liang, Michael McCreedy, Fabian Nagel, Ippokratis Pandis, Panos Parchas, Rahul Pathak, Orestis Polychroniou, Foyzur Rahman, Gaurav Saxena, Gokul Soundararajan, Sriram Subramanian, and Doug Terry. 2022. 亚马逊Redshift的重塑. 在2022年国际数据管理会议论文集中(费城,宾夕法尼亚州,美国)(SIGMOD '22). 计算机协会, 纽约,纽约,美国, 2205–2217. https://doi.org/10.1145/3514221.3526045 +- [5] Alexander Behm, Shoumik Palkar, Utkarsh Agarwal, Timothy Armstrong, David Cashman, Ankur Dave, Todd Greenstein, Shant Hovsepian, Ryan Johnson, Arvind Sai Krishnan, Paul Leventis, Ala Luszczak, Prashanth Menon, Mostafa Mokhtar, Gene Pang, Sameer Paranjpye, Greg Rahn, Bart Samwel, Tom van Bussel, Herman van Hovell, Maryann Xue, Reynold Xin, and Matei Zaharia. 2022. Photon:湖仓系统的快速查询引擎(SIGMOD '22). 计算机协会, 纽约,纽约,美国, 2326–2339. [https://doi.org/10.1145/3514221.](https://doi.org/10.1145/3514221.3526054) [3526054](https://doi.org/10.1145/3514221.3526054) +- [6] Philip A. Bernstein and Nathan Goodman. 1981. 分布式数据库系统中的并发控制. ACM计算机调查 13, 2 (1981), 185–221. https://doi.org/10.1145/356842.356846 +- [7] Spyros Blanas, Yinan Li, and Jignesh M. Patel. 2011. 设计和评估多核CPU的主存哈希连接算法. 在2011年ACM SIGMOD国际数据管理会议论文集中(雅典,希腊)(SIGMOD '11). 计算机协会, 纽约,纽约,美国, 37–48. https://doi.org/10.1145/1989323.1989328 - [8] Daniel Gomez Blanco. 2023. 实用的OpenTelemetry. Springer Nature. -- [9] Burton H. Bloom. 1970. 允许错误的哈希编码中的空间/时间权衡. Commun. ACM 13, 7 (1970), 422–426. [https://doi.org/10.1145/362686.](https://doi.org/10.1145/362686.362692) [362692](https://doi.org/10.1145/362686.362692) -- [10] Peter Boncz, Thomas Neumann, 和 Orri Erling. 2014. TPC-H 分析:从一个有影响力的基准中获取隐藏的信息与经验教训. 在性能特征化与基准测试. 61–76. [https://doi.org/10.1007/978-3-319-](https://doi.org/10.1007/978-3-319-04936-6_5) [04936-6_5](https://doi.org/10.1007/978-3-319-04936-6_5) -- [11] Peter Boncz, Marcin Zukowski, 和 Niels Nes. 2005. MonetDB/X100: 超级管道化查询执行. 在CIDR. -- [12] Martin Burtscher 和 Paruj Ratanaworabhan. 2007. 双精度浮点数据的高吞吐量压缩. 在数据压缩会议(DCC). 293–302. https://doi.org/10.1109/DCC.2007.44 -- [13] Jef Carpenter 和 Eben Hewitt. 2016. Cassandra: Definitive Guide (第2版). O'Reilly Media, Inc. -- [14] Bernadette Charron-Bost, Fernando Pedone, 和 André Schiper (Eds.). 2010. 复制:理论与实践. Springer-Verlag. +- [9] Burton H. Bloom. 1970. 可允许错误的哈希编码中的空间/时间权衡. Commun. ACM 13, 7 (1970), 422–426. [https://doi.org/10.1145/362686.](https://doi.org/10.1145/362686.362692) [362692](https://doi.org/10.1145/362686.362692) +- [10] Peter Boncz, Thomas Neumann, and Orri Erling. 2014. TPC-H分析:从有影响力基准获取的隐藏消息和经验教训. 在性能特征和基准测试中. 61–76. [https://doi.org/10.1007/978-3-319-](https://doi.org/10.1007/978-3-319-04936-6_5) [04936-6_5](https://doi.org/10.1007/978-3-319-04936-6_5) +- [11] Peter Boncz, Marcin Zukowski, and Niels Nes. 2005. MonetDB/X100: 超级流水线查询执行. 在CIDR. +- [12] Martin Burtscher and Paruj Ratanaworabhan. 2007. 双精度浮点数据的高吞吐量压缩. 在数据压缩会议(DCC). 293–302. https://doi.org/10.1109/DCC.2007.44 +- [13] Jef Carpenter and Eben Hewitt. 2016. Cassandra: 权威指南(第2版). O'Reilly Media,Inc. +- [14] Bernadette Charron-Bost, Fernando Pedone, and André Schiper(编)。2010. 复制:理论与实践. Springer-Verlag. - [15] chDB. 2024. chDB - 嵌入式OLAP SQL引擎. 取自2024-06-20 https://github.com/chdb-io/chdb -- [16] ClickHouse. 2024. ClickBench: 面向分析数据库的基准测试. 取自2024-06-20 https://github.com/ClickHouse/ClickBench -- [17] ClickHouse. 2024. ClickBench: 比较测量. 取自2024-06-20 https://benchmark.clickhouse.com -- [18] ClickHouse. 2024. ClickHouse 2024路线图 (GitHub). 取自2024-06-20 https://github.com/ClickHouse/ClickHouse/issues/58392 +- [16] ClickHouse. 2024. ClickBench:用于分析数据库的基准测试. 取自2024-06-20 https://github.com/ClickHouse/ClickBench +- [17] ClickHouse. 2024. ClickBench:对比测量. 取自2024-06-20 https://benchmark.clickhouse.com +- [18] ClickHouse. 2024. ClickHouse 2024路线图(GitHub). 取自2024-06-20 https://github.com/ClickHouse/ClickHouse/issues/58392 - [19] ClickHouse. 2024. ClickHouse版本基准测试. 取自2024-06-20 https://github.com/ClickHouse/ClickBench/tree/main/versions - [20] ClickHouse. 2024. ClickHouse版本基准测试结果. 取自2024-06-20 https://benchmark.clickhouse.com/versions/ - [21] Andrew Crotty. 2022. MgBench. 取自2024-06-20 [https://github.com/](https://github.com/andrewcrotty/mgbench) [andrewcrotty/mgbench](https://github.com/andrewcrotty/mgbench) -- [22] Benoit Dageville, Thierry Cruanes, Marcin Zukowski, Vadim Antonov, Artin Avanes, Jon Bock, Jonathan Claybaugh, Daniel Engovatov, Martin Hentschel, Jiansheng Huang, Allison W. Lee, Ashish Motivala, Abdul Q. Munir, Steven Pelley, Peter Povinec, Greg Rahn, Spyridon Triantafyllis, 和 Philipp Unterbrunner. 2016. Snowflake弹性数据仓库. 在2016年国际数据管理会议(旧金山,加利福尼亚,USA)(SIGMOD '16)论文集. 计算机协会,纽约,NY,USA, 215–226. [https:](https://doi.org/10.1145/2882903.2903741) [//doi.org/10.1145/2882903.2903741](https://doi.org/10.1145/2882903.2903741) -- [23] Patrick Damme, Annett Ungethüm, Juliana Hildebrandt, Dirk Habich, 和 Wolfgang Lehner. 2019. 从全面的实验调查到针对轻量级整数压缩算法的基于成本的选择策略. ACM Trans. Database Syst. 44, 3, 第9篇 (2019), 46页. https://doi.org/10.1145/3323991 -- [24] Philippe Dobbelaere 和 Kyumars Sheykh Esmaili. 2017. Kafka与RabbitMQ:两种行业参考发布/订阅实现的比较研究:行业论文 (DEBS '17). 计算机协会,纽约,NY,USA, 227–238. https://doi.org/10.1145/3093742.3093908 -- [25] LLVM documentation. 2024. LLVM中的自动矢量化. 取自2024-06-20 https://llvm.org/docs/Vectorizers.html -- [26] Siying Dong, Andrew Kryczka, Yanqin Jin, 和 Michael Stumm. 2021. RocksDB:为大型应用程序服务的键值存储的开发优先级演变. ACM Transactions on Storage 17, 4, 第26篇 (2021), 32页. https://doi.org/10.1145/3483840 -- [27] Markus Dreseler, Martin Boissier, Tilmann Rabl, 和 Matthias Ufacker. 2020. 定量化TPC-H阻塞点及其优化. Proc. VLDB Endow. 13, 8 (2020), 1206–1220. https://doi.org/10.14778/3389133.3389138 -- [28] Ted Dunning. 2021. t-digest:有效估计分布. 软件影响 7 (2021). https://doi.org/10.1016/j.simpa.2020.100049 -- [29] Martin Faust, Martin Boissier, Marvin Keller, David Schwalb, Holger Bischof, Katrin Eisenreich, Franz Färber, 和 Hasso Plattner. 2016. 在SAP HANA中使用哈希索引进行的足迹减少和唯一性强制. 在数据库和专家系统应用. 137–151. [https://doi.org/10.1007/978-3-319-44406-](https://doi.org/10.1007/978-3-319-44406-2_11) [2_11](https://doi.org/10.1007/978-3-319-44406-2_11) -- [30] Philippe Flajolet, Eric Fusy, Olivier Gandouet, 和 Frederic Meunier. 2007. HyperLogLog:近似最优基数估计算法的分析. 在AofA:算法分析,Vol. DMTCS Proceedings vol. AH, 2007年算法分析会议 (AofA 07). 离散数学与理论计算机科学, 137–156. https://doi.org/10.46298/dmtcs.3545 -- [31] Hector Garcia-Molina, Jefrey D. Ullman, 和 Jennifer Widom. 2009. 数据库系统 - 完整的书籍 (第2版). -- [32] Pawan Goyal, Harrick M. Vin, 和 Haichen Chen. 1996. 启动时间公平排队:集成服务分组交换网络的调度算法. 26, 4 (1996), 157–168. https://doi.org/10.1145/248157.248171 +- [22] Benoit Dageville, Thierry Cruanes, Marcin Zukowski, Vadim Antonov, Artin Avanes, Jon Bock, Jonathan Claybaugh, Daniel Engovatov, Martin Hentschel, Jiansheng Huang, Allison W. Lee, Ashish Motivala, Abdul Q. Munir, Steven Pelley, Peter Povinec, Greg Rahn, Spyridon Triantafyllis, and Philipp Unterbrunner. 2016. The Snowfake弹性数据仓库. 在2016年国际数据管理会议论文集中(旧金山,加州,美国)(SIGMOD '16). 计算机协会, 纽约,纽约,美国, 215–226. [https:](https://doi.org/10.1145/2882903.2903741) [//doi.org/10.1145/2882903.2903741](https://doi.org/10.1145/2882903.2903741) +- [23] Patrick Damme, Annett Ungethüm, Juliana Hildebrandt, Dirk Habich, and Wolfgang Lehner. 2019. 从全面实验调查到基于成本的轻量级整数压缩算法选择策略. ACM Trans. 数据库系统 44, 3, 文章9 (2019), 46页. https://doi.org/10.1145/3323991 +- [24] Philippe Dobbelaere and Kyumars Sheykh Esmaili. 2017. Kafka与RabbitMQ的比较研究:行业论文(DEBS '17). 计算机协会, 纽约,纽约,美国, 227–238. https://doi.org/10.1145/3093742.3093908 +- [25] LLVM文档. 2024. LLVM中的自动向量化. 取自2024-06-20 https://llvm.org/docs/Vectorizers.html +- [26] Siying Dong, Andrew Kryczka, Yanqin Jin, and Michael Stumm. 2021. RocksDB:为大规模应用服务的键值存储的发展优先级. ACM存储交易 17, 4, 文章26 (2021), 32页. https://doi.org/10.1145/3483840 +- [27] Markus Dreseler, Martin Boissier, Tilmann Rabl, and Matthias Ufacker. 2020. 量化TPC-H瓶颈及其优化. Proc. VLDB Endow. 13, 8 (2020), 1206–1220. https://doi.org/10.14778/3389133.3389138 +- [28] Ted Dunning. 2021. t-digest:分布的高效估计. 软件影响 7 (2021). https://doi.org/10.1016/j.simpa.2020.100049 +- [29] Martin Faust, Martin Boissier, Marvin Keller, David Schwalb, Holger Bischof, Katrin Eisenreich, Franz Färber, and Hasso Plattner. 2016. 在SAP HANA中使用哈希索引减少足迹和强制唯一性. 在数据库和专家系统应用中. 137–151. [https://doi.org/10.1007/978-3-319-44406-](https://doi.org/10.1007/978-3-319-44406-2_11) [2_11](https://doi.org/10.1007/978-3-319-44406-2_11) +- [30] Philippe Flajolet, Eric Fusy, Olivier Gandouet, and Frederic Meunier. 2007. HyperLogLog:对近似最优基数估计算法的分析. 在AofA:算法分析,卷DMTCS论文卷,2007年算法分析会议(AofA 07). 离散数学和理论计算机科学, 137–156. https://doi.org/10.46298/dmtcs.3545 +- [31] Hector Garcia-Molina, Jefrey D. Ullman, and Jennifer Widom. 2009. 数据库系统 - 完整书籍(第2版). +- [32] Pawan Goyal, Harrick M. Vin, and Haichen Chen. 1996. 启动时间公平排队:一种集成服务分组交换网络的调度算法. 26, 4 (1996), 157–168. https://doi.org/10.1145/248157.248171 - [33] Goetz Graefe. 1993. 大型数据库的查询评估技术. ACM Comput. Surv. 25, 2 (1993), 73–169. https://doi.org/10.1145/152610.152611 -- [34] Jean-François Im, Kishore Gopalakrishna, Subbu Subramaniam, Mayank Shrivastava, Adwait Tumbde, Xiaotian Jiang, Jennifer Dai, Seunghyun Lee, Neha Pawar, Jialiang Li, 和 Ravi Aringunram. 2018. Pinot:530百万用户的实时OLAP. 在2018年国际数据管理会议(休斯顿,TX,USA)(SIGMOD '18)论文集. 计算机协会,纽约,NY,USA, 583–594. https://doi.org/10.1145/3183713.3190661 -- [35] ISO/IEC 9075-9:2001 2001. 信息技术——数据库语言——SQL——第9部分:外部数据管理(SQL/MED). 标准. 国际标准化组织. -- [36] Paras Jain, Peter Kraft, Conor Power, Tathagata Das, Ion Stoica, 和 Matei Zaharia. 2023. 分析和比较湖屋存储系统. CIDR. -- [37] Project Jupyter. 2024. Jupyter Notebook. 取自2024-06-20 [https:](https://jupyter.org/) [//jupyter.org/](https://jupyter.org/) -- [38] Timo Kersten, Viktor Leis, Alfons Kemper, Thomas Neumann, Andrew Pavlo, 和 Peter Boncz. 2018. 您总是想知道的关于编译和矢量化查询的所有信息,但又害怕问. Proc. VLDB Endow. 11, 13 (2018年9月), 2209–2222. https://doi.org/10.14778/3275366.3284966 -- [39] Changkyu Kim, Jatin Chhugani, Nadathur Satish, Eric Sedlar, Anthony D. Nguyen, Tim Kaldewey, Victor W. Lee, Scott A. Brandt, 和 Pradeep Dubey. 2010. FAST:现代CPU和GPU上的快速架构敏感树搜索. 在2010年ACM SIGMOD国际数据管理大会(印第安纳波利斯,印第安纳,USA)(SIGMOD '10)论文集. 计算机协会,纽约,NY,USA, 339–350. https://doi.org/10.1145/1807167.1807206 -- [40] Donald E. Knuth. 1973. 计算机程序设计的艺术,第III卷:排序与搜索. Addison-Wesley. -- [41] André Kohn, Viktor Leis, 和 Thomas Neumann. 2018. 编译查询的自适应执行. 在2018 IEEE第34届国际数据工程会议(ICDE). 197–208. https://doi.org/10.1109/ICDE.2018.00027 -- [42] Andrew Lamb, Matt Fuller, Ramakrishna Varadarajan, Nga Tran, Ben Vandiver, Lyric Doshi, 和 Chuck Bear. 2012. Vertica分析数据库:C-Store 7年后. Proc. VLDB Endow. 5, 12 (2012年8月), 1790–1801. [https://doi.org/10.](https://doi.org/10.14778/2367502.2367518) [14778/2367502.2367518](https://doi.org/10.14778/2367502.2367518) -- [43] Harald Lang, Tobias Mühlbauer, Florian Funke, Peter A. Boncz, Thomas Neumann, 和 Alfons Kemper. 2016. 数据块:使用矢量化和编译的压缩存储上的混合OLTP和OLAP. 在2016年国际数据管理会议(旧金山,加利福尼亚,USA)(SIGMOD '16)论文集. 计算机协会,纽约,NY,USA, 311–326. https://doi.org/10.1145/2882903.2882925 -- [44] Viktor Leis, Peter Boncz, Alfons Kemper, 和 Thomas Neumann. 2014. 基于块的并行性:一个NUMA感知的查询评估框架,适用于多核时代. 在2014年ACM SIGMOD国际数据管理大会(Snowbird,犹他州,USA)(SIGMOD '14)论文集. 计算机协会,纽约,NY,USA, 743–754. [https://doi.org/10.1145/2588555.](https://doi.org/10.1145/2588555.2610507) [2610507](https://doi.org/10.1145/2588555.2610507) -- [45] Viktor Leis, Alfons Kemper, 和 Thomas Neumann. 2013. 自适应基数树:为主存数据库提供的ARTful索引. 在2013 IEEE第29届国际数据工程会议(ICDE). 38–49. [https://doi.org/10.1109/ICDE.](https://doi.org/10.1109/ICDE.2013.6544812) [2013.6544812](https://doi.org/10.1109/ICDE.2013.6544812) -- [46] Chunwei Liu, Anna Pavlenko, Matteo Interlandi, 和 Brandon Haynes. 2023. 深入探讨分析数据库管理系统的常见开放格式. 16, 11 (2023年7月), 3044–3056. https://doi.org/10.14778/3611479.3611507 -- [47] Zhenghua Lyu, Huan Hubert Zhang, Gang Xiong, Gang Guo, Haozhou Wang, Jinbao Chen, Asim Praveen, Yu Yang, Xiaoming Gao, Alexandra Wang, Wen Lin, Ashwin Agrawal, Junfeng Yang, Hao Wu, Xiaoliang Li, Feng Guo, Jiang Wu, Jesse Zhang, 和 Venkatesh Raghavan. 2021. Greenplum:一个用于事务和分析工作负载的混合数据库 (SIGMOD '21). 计算机协会,纽约,NY,USA, 2530–2542. [https:](https://doi.org/10.1145/3448016.3457562) [//doi.org/10.1145/3448016.3457562](https://doi.org/10.1145/3448016.3457562) -- [48] Roger MacNicol 和 Blaine French. 2004. Sybase IQ Multiplex - 为分析而设计. 在第三十届国际大型数据库会议(多伦多,加拿大)(VLDB '04)论文集. VLDB Endowment, 1227–1230. -- [49] Sergey Melnik, Andrey Gubarev, Jing Jing Long, Geofrey Romer, Shiva Shivakumar, Matt Tolton, Theo Vassilakis, Hossein Ahmadi, Dan Delorey, Slava Min, Mosha Pasumansky, 和 Jef Shute. 2020. Dremel:十年互联网规模的交互式SQL分析. Proc. VLDB Endow. 13, 12 (2020年8月), 3461–3472. https://doi.org/10.14778/3415478.3415568 +- [34] Jean-François Im, Kishore Gopalakrishna, Subbu Subramaniam, Mayank Shrivastava, Adwait Tumbde, Xiaotian Jiang, Jennifer Dai, Seunghyun Lee, Neha Pawar, Jialiang Li, and Ravi Aringunram. 2018. Pinot:针对530万用户的实时OLAP. 在2018年国际数据管理会议论文集中(休斯顿,德克萨斯州,美国)(SIGMOD '18). 计算机协会, 纽约,纽约,美国, 583–594. https://doi.org/10.1145/3183713.3190661 +- [35] ISO/IEC 9075-9:2001 2001. 信息技术 — 数据库语言 — SQL — 第9部分:外部数据的管理 (SQL/MED). 标准. 国际标准化组织. +- [36] Paras Jain, Peter Kraft, Conor Power, Tathagata Das, Ion Stoica, and Matei Zaharia. 2023. 分析和比较湖仓存储系统. CIDR. +- [37] Jupyter项目. 2024. Jupyter笔记本. 取自2024-06-20 [https:](https://jupyter.org/) [//jupyter.org/](https://jupyter.org/) +- [38] Timo Kersten, Viktor Leis, Alfons Kemper, Thomas Neumann, Andrew Pavlo, and Peter Boncz. 2018. 关于编译和向量化查询的所有你想知道的但不敢问的问题. Proc. VLDB Endow. 11, 13 (2018年9月), 2209–2222. https://doi.org/10.14778/3275366.3284966 +- [39] Changkyu Kim, Jatin Chhugani, Nadathur Satish, Eric Sedlar, Anthony D. Nguyen, Tim Kaldewey, Victor W. Lee, Scott A. Brandt, and Pradeep Dubey. 2010. FAST:现代CPU和GPU上的快速架构敏感树搜索. 在2010年ACM SIGMOD国际数据管理会议论文集中(印第安纳波利斯,印第安纳州,美国)(SIGMOD '10). 计算机协会, 纽约,纽约,美国, 339–350. https://doi.org/10.1145/1807167.1807206 +- [40] Donald E. Knuth. 1973. 计算机程序设计艺术,卷III:排序与搜索. Addison-Wesley. +- [41] André Kohn, Viktor Leis, and Thomas Neumann. 2018. 编译查询的自适应执行. 在2018年IEEE第34届数据工程国际会议(ICDE). 197–208. https://doi.org/10.1109/ICDE.2018.00027 +- [42] Andrew Lamb, Matt Fuller, Ramakrishna Varadarajan, Nga Tran, Ben Vandiver, Lyric Doshi, and Chuck Bear. 2012. Vertica分析数据库:7年后的C-Store. Proc. VLDB Endow. 5, 12 (2012年8月), 1790–1801. [https://doi.org/10.](https://doi.org/10.14778/2367502.2367518) [14778/2367502.2367518](https://doi.org/10.14778/2367502.2367518) +- [43] Harald Lang, Tobias Mühlbauer, Florian Funke, Peter A. Boncz, Thomas Neumann, and Alfons Kemper. 2016. 数据块:在压缩存储上使用向量化和编译的混合OLTP和OLAP. 在2016年国际数据管理会议论文集中(旧金山,加州,美国)(SIGMOD '16). 计算机协会, 纽约,纽约,美国, 311–326. https://doi.org/10.1145/2882903.2882925 +- [44] Viktor Leis, Peter Boncz, Alfons Kemper, and Thomas Neumann. 2014. 基于块驱动的并行性:为多核时代的NUMA感知查询评估框架. 在2014年ACM SIGMOD国际数据管理会议论文集中(雪鸟,犹他州,美国)(SIGMOD '14). 计算机协会, 纽约,纽约,美国, 743–754. [https://doi.org/10.1145/2588555.](https://doi.org/10.1145/2588555.2610507) [2610507](https://doi.org/10.1145/2588555.2610507) +- [45] Viktor Leis, Alfons Kemper, and Thomas Neumann. 2013. 自适应基数树:适用于主存数据库的ARTful索引. 在2013年IEEE第29届数据工程国际会议(ICDE). 38–49. [https://doi.org/10.1109/ICDE.](https://doi.org/10.1109/ICDE.2013.6544812) [2013.6544812](https://doi.org/10.1109/ICDE.2013.6544812) +- [46] Chunwei Liu, Anna Pavlenko, Matteo Interlandi, and Brandon Haynes. 2023. 深入探讨分析DBMS的常见开放格式. 16, 11 (2023年7月), 3044–3056. https://doi.org/10.14778/3611479.3611507 +- [47] Zhenghua Lyu, Huan Hubert Zhang, Gang Xiong, Gang Guo, Haozhou Wang, Jinbao Chen, Asim Praveen, Yu Yang, Xiaoming Gao, Alexandra Wang, Wen Lin, Ashwin Agrawal, Junfeng Yang, Hao Wu, Xiaoliang Li, Feng Guo, Jiang Wu, Jesse Zhang, and Venkatesh Raghavan. 2021. Greenplum:一种用于事务和分析工作负载的混合数据库(SIGMOD '21). 计算机协会, 纽约,纽约,美国, 2530–2542. [https:](https://doi.org/10.1145/3448016.3457562) [//doi.org/10.1145/3448016.3457562](https://doi.org/10.1145/3448016.3457562) +- [48] Roger MacNicol and Blaine French. 2004. Sybase IQ Multiplex - 为分析而设计. 在第三十届国际大型数据库会议论文集 - 第30卷(多伦多,加拿大)(VLDB '04). VLDB基金会, 1227–1230. +- [49] Sergey Melnik, Andrey Gubarev, Jing Jing Long, Geofrey Romer, Shiva Shivakumar, Matt Tolton, Theo Vassilakis, Hossein Ahmadi, Dan Delorey, Slava Min, Mosha Pasumansky, and Jef Shute. 2020. Dremel:十年来的交互式SQL分析在Web规模上. Proc. VLDB Endow. 13, 12 (2020年8月), 3461–3472. https://doi.org/10.14778/3415478.3415568 - [50] Microsoft. 2024. Kusto查询语言. 取自2024-06-20 [https:](https://github.com/microsoft/Kusto-Query-Language) [//github.com/microsoft/Kusto-Query-Language](https://github.com/microsoft/Kusto-Query-Language) -- [51] Guido Moerkotte. 1998. 小的物化聚合:用于数据仓库的轻量级索引结构. 在第24届国际大型数据库会议(VLDB '98)论文集. 476–487. -- [52] Jalal Mostafa, Sara Wehbi, Suren Chilingaryan, 和 Andreas Kopmann. 2022. SciTS:科学实验和工业物联网中的时间序列数据库基准. 在第34届科学与统计数据库管理国际会议(SSDBM '22)论文集. 第12篇. [https:](https://doi.org/10.1145/3538712.3538723) [//doi.org/10.1145/3538712.3538723](https://doi.org/10.1145/3538712.3538723) -- [53] Thomas Neumann. 2011. 有效编译现代硬件的有效查询计划. Proc. VLDB Endow. 4, 9 (2011年6月), 539–550. [https://doi.org/10.14778/](https://doi.org/10.14778/2002938.2002940) [2002938.2002940](https://doi.org/10.14778/2002938.2002940) -- [54] Thomas Neumann 和 Michael J. Freitag. 2020. Umbra:具有内存性能的基于磁盘的系统. 在第10届创新数据系统研究会议, CIDR 2020, 阿姆斯特丹,荷兰, 2020年1月12-15, 在线会议记录. www.cidrdb.org. [http://cidrdb.org/cidr2020/papers/p29-neumann](http://cidrdb.org/cidr2020/papers/p29-neumann)[cidr20.pdf](http://cidrdb.org/cidr2020/papers/p29-neumann-cidr20.pdf) -- [55] Thomas Neumann, Tobias Mühlbauer, 和 Alfons Kemper. 2015. 快速可序列化的多版本并发控制用于主内存数据库系统. 在2015年ACM SIGMOD国际数据管理大会(墨尔本,维多利亚州,澳大利亚)(SIGMOD '15)论文集. 计算机协会,纽约,NY,USA, 677–689. [https://doi.org/10.1145/2723372.](https://doi.org/10.1145/2723372.2749436) [2749436](https://doi.org/10.1145/2723372.2749436) +- [51] Guido Moerkotte. 1998. 小的物化聚合:一种轻量级的数据仓库索引结构. 在第24届国际大型数据库会议论文集(VLDB '98). 476–487. +- [52] Jalal Mostafa, Sara Wehbi, Suren Chilingaryan, and Andreas Kopmann. 2022. SciTS:用于科学实验和工业物联网的时间序列数据库基准测试. 在第34届国际科学与统计数据库管理会议论文集(SSDBM '22). 文章12. [https:](https://doi.org/10.1145/3538712.3538723) [//doi.org/10.1145/3538712.3538723](https://doi.org/10.1145/3538712.3538723) +- [53] Thomas Neumann. 2011. 为现代硬件高效编译高效查询计划. Proc. VLDB Endow. 4, 9 (2011年6月), 539–550. [https://doi.org/10.14778/](https://doi.org/10.14778/2002938.2002940) [2002938.2002940](https://doi.org/10.14778/2002938.2002940) +- [54] Thomas Neumann and Michael J. Freitag. 2020. Umbra:一种具有内存性能的基于磁盘的系统. 在第10届创新数据系统研究会议,CIDR 2020, 荷兰阿姆斯特丹,2020年1月12-15日,在线论文集. www.cidrdb.org. [http://cidrdb.org/cidr2020/papers/p29-neumann](http://cidrdb.org/cidr2020/papers/p29-neumann-cidr20.pdf)[cidr20.pdf](http://cidrdb.org/cidr2020/papers/p29-neumann-cidr20.pdf) +- [55] Thomas Neumann, Tobias Mühlbauer, and Alfons Kemper. 2015. 针对主存数据库系统的快速可序列化多版本并发控制. 在2015年ACM SIGMOD国际数据管理会议论文集中(墨尔本,维多利亚州,澳大利亚)(SIGMOD '15). 计算机协会, 纽约,纽约,美国, 677–689. [https://doi.org/10.1145/2723372.](https://doi.org/10.1145/2723372.2749436) [2749436](https://doi.org/10.1145/2723372.2749436) - [56] LevelDB on GitHub. 2024. LevelDB. 取自2024-06-20 [https://github.](https://github.com/google/leveldb) [com/google/leveldb](https://github.com/google/leveldb) -- [57] Patrick O'Neil, Elizabeth O'Neil, Xuedong Chen, 和 Stephen Revilak. 2009. 星型架构基准和增强事实表索引. 在性能评估与基准测试. Springer Berlin Heidelberg, 237–252. [https:](https://doi.org/10.1007/978-3-642-10424-4_17) [//doi.org/10.1007/978-3-642-10424-4_17](https://doi.org/10.1007/978-3-642-10424-4_17) -- [58] Patrick E. O'Neil, Edward Y. C. Cheng, Dieter Gawlick, 和 Elizabeth O'Neil. 1996. 日志结构合并树(LSM树). Acta Informatica 33 (1996), 351–385. https://doi.org/10.1007/s002360050048 -- [59] Diego Ongaro 和 John Ousterhout. 2014. 寻找一个可理解的共识算法. 在2014年USENIX会议及USENIX年会技术会议(USENIX ATC'14)论文集. 305–320. [https://doi.org/doi/10.](https://doi.org/doi/10.5555/2643634.2643666) [5555/2643634.2643666](https://doi.org/doi/10.5555/2643634.2643666) -- [60] Patrick O'Neil, Edward Cheng, Dieter Gawlick, 和 Elizabeth O'Neil. 1996. 日志结构合并树(LSM树). Acta Inf. 33, 4 (1996), 351–385. [https:](https://doi.org/10.1007/s002360050048) [//doi.org/10.1007/s002360050048](https://doi.org/10.1007/s002360050048) +- [57] Patrick O'Neil, Elizabeth O'Neil, Xuedong Chen, and Stephen Revilak. 2009. 星型架构基准测试与增强事实表索引. 在性能评估和基准测试中. Springer Berlin Heidelberg, 237–252. [https:](https://doi.org/10.1007/978-3-642-10424-4_17) [//doi.org/10.1007/978-3-642-10424-4_17](https://doi.org/10.1007/978-3-642-10424-4_17) +- [58] Patrick E. O'Neil, Edward Y. C. Cheng, Dieter Gawlick, and Elizabeth J. O'Neil. 1996. 日志结构合并树(LSM-tree). Acta Informatica 33 (1996), 351–385. https://doi.org/10.1007/s002360050048 +- [59] Diego Ongaro and John Ousterhout. 2014. 寻找易于理解的一致性算法. 在2014年USENIX会议上的USENIX年度技术会议论文集中(USENIX ATC'14). 305–320. [https://doi.org/doi/10.](https://doi.org/doi/10.5555/2643634.2643666) [5555/2643634.2643666](https://doi.org/doi/10.5555/2643634.2643666) +- [60] Patrick O'Neil, Edward Cheng, Dieter Gawlick, and Elizabeth O'Neil. 1996. 日志结构合并树(LSM-Tree). Acta Inf. 33, 4 (1996), 351–385. [https:](https://doi.org/10.1007/s002360050048) [//doi.org/10.1007/s002360050048](https://doi.org/10.1007/s002360050048) - [61] Pandas. 2024. Pandas数据框. 取自2024-06-20 [https://pandas.](https://pandas.pydata.org/) [pydata.org/](https://pandas.pydata.org/) -- [62] Pedro Pedreira, Orri Erling, Masha Basmanova, Kevin Wilfong, Laith Sakka, Krishna Pai, Wei He, 和 Biswapesh Chattopadhyay. 2022. Velox: Meta的统一执行引擎. Proc. VLDB Endow. 15, 12 (2022年8月), 3372–3384. [https:](https://doi.org/10.14778/3554821.3554829) [//doi.org/10.14778/3554821.3554829](https://doi.org/10.14778/3554821.3554829) -- [63] Tuomas Pelkonen, Scott Franklin, Justin Teller, Paul Cavallaro, Qi Huang, Justin Meza, 和 Kaushik Veeraraghavan. 2015. Gorilla:一个快速、可扩展的内存时间序列数据库. Proceedings of the VLDB Endowment 8, 12 (2015), 1816–1827. https://doi.org/10.14778/2824032.2824078 -- [64] Orestis Polychroniou, Arun Raghavan, 和 Kenneth A. Ross. 2015. 重新思考内存数据库的SIMD矢量化. 在2015年ACM SIGMOD国际数据管理大会(SIGMOD '15)论文集. 1493–1508. https://doi.org/10.1145/2723372.2747645 +- [62] Pedro Pedreira, Orri Erling, Masha Basmanova, Kevin Wilfong, Laith Sakka, Krishna Pai, Wei He, and Biswapesh Chattopadhyay. 2022. Velox:Meta的统一执行引擎. Proc. VLDB Endow. 15, 12 (2022年8月), 3372–3384. [https:](https://doi.org/10.14778/3554821.3554829) [//doi.org/10.14778/3554821.3554829](https://doi.org/10.14778/3554821.3554829) +- [63] Tuomas Pelkonen, Scott Franklin, Justin Teller, Paul Cavallaro, Qi Huang, Justin Meza, and Kaushik Veeraraghavan. 2015. Gorilla:一个快速、可扩展的内存中时间序列数据库. 数据库论文集 8, 12 (2015), 1816–1827. https://doi.org/10.14778/2824032.2824078 +- [64] Orestis Polychroniou, Arun Raghavan, and Kenneth A. Ross. 2015. 重新思考内存数据库的SIMD向量化. 在2015年ACM SIGMOD国际数据管理会议论文集中(SIGMOD '15). 1493–1508. https://doi.org/10.1145/2723372.2747645 - [65] PostgreSQL. 2024. PostgreSQL - 外部数据包装器. 取自2024-06-20 https://wiki.postgresql.org/wiki/Foreign_data_wrappers -- [66] Mark Raasveldt, Pedro Holanda, Tim Gubner, 和 Hannes Mühleisen. 2018. 公平基准测试被认为困难:数据库性能测试中的常见陷阱. 在数据库系统测试研讨会论文集(休斯敦,TX,USA)(DBTest'18). 第2篇, 6页. https://doi.org/10.1145/3209950.3209955 -- [67] Mark Raasveldt 和 Hannes Mühleisen. 2019. DuckDB:一个可嵌入的分析数据库 (SIGMOD '19). 计算机协会,纽约,NY,USA, 1981–1984. https://doi.org/10.1145/3299869.3320212 -- [68] Jun Rao 和 Kenneth A. Ross. 1999. 针对主内存决策支持的缓存意识索引. 在第25届国际大型数据库会议(VLDB '99)论文集. 旧金山,加利福尼亚,USA, 78–89. -- [69] Navin C. Sabharwal 和 Piyush Kant Pandey. 2020. 使用Prometheus查询语言(PromQL). 在监控微服务和容器化应用程序. https://doi.org/10.1007/978-1-4842-6216-0_5 -- [70] Todd W. Schneider. 2022. 纽约市出租车和雇佣车辆数据. 取自2024-06-20 https://github.com/toddwschneider/nyc-taxi-data -- [71] Mike Stonebraker, Daniel J. Abadi, Adam Batkin, Xuedong Chen, Mitch Cherniack, Miguel Ferreira, Edmond Lau, Amerson Lin, Sam Madden, Elizabeth O'Neil, Pat O'Neil, Alex Rasin, Nga Tran, 和 Stan Zdonik. 2005. C-Store:一个列式数据库管理系统. 在第31届国际大型数据库会议(VLDB '05)论文集. 553–564. +- [66] Mark Raasveldt, Pedro Holanda, Tim Gubner, and Hannes Mühleisen. 2018. 公平基准测试显得棘手:数据库性能测试中的常见陷阱. 在数据库系统测试研讨会论文集中(休斯顿,德克萨斯州,美国)(DBTest'18). 文章2, 6页. https://doi.org/10.1145/3209950.3209955 +- [67] Mark Raasveldt and Hannes Mühleisen. 2019. DuckDB:一种可嵌入的分析数据库(SIGMOD '19). 计算机协会, 纽约,纽约,美国, 1981–1984. https://doi.org/10.1145/3299869.3320212 +- [68] Jun Rao and Kenneth A. Ross. 1999. 面向决策支持的缓存意识索引在主存中的应用. 在第25届国际大型数据库会议论文集中(VLDB '99). 旧金山,加州,美国, 78–89. +- [69] Navin C. Sabharwal and Piyush Kant Pandey. 2020. 使用Prometheus查询语言(PromQL). 在监控微服务和容器化应用中. https://doi.org/10.1007/978-1-4842-6216-0_5 +- [70] Todd W. Schneider. 2022. 纽约市出租车和用车数据. 取自2024-06-20 https://github.com/toddwschneider/nyc-taxi-data +- [71] Mike Stonebraker, Daniel J. Abadi, Adam Batkin, Xuedong Chen, Mitch Cherniack, Miguel Ferreira, Edmond Lau, Amerson Lin, Sam Madden, Elizabeth O'Neil, Pat O'Neil, Alex Rasin, Nga Tran, and Stan Zdonik. 2005. C-Store:一种列式数据库管理系统. 在第31届国际大型数据库会议论文集中(VLDB '05). 553–564. - [72] Teradata. 2024. Teradata数据库. 取自2024-06-20 [https://www.](https://www.teradata.com/resources/datasheets/teradata-database) [teradata.com/resources/datasheets/teradata-database](https://www.teradata.com/resources/datasheets/teradata-database) -- [73] Frederik Transier. 2010. 内存文本搜索引擎的算法与数据结构. 博士学位论文. https://doi.org/10.5445/IR/1000015824 -- [74] Adrian Vogelsgesang, Michael Haubenschild, Jan Finis, Alfons Kemper, Viktor Leis, Tobias Muehlbauer, Thomas Neumann, 和 Manuel Then. 2018. 真实:基准测试未能代表真实世界. 在数据库系统测试研讨会论文集(休斯敦,TX,USA)(DBTest'18). 第1篇, 6页. https://doi.org/10.1145/3209950.3209952 +- [73] Frederik Transier. 2010. 面向内存文本搜索引擎的算法和数据结构. 博士学位论文. https://doi.org/10.5445/IR/1000015824 +- [74] Adrian Vogelsgesang, Michael Haubenschild, Jan Finis, Alfons Kemper, Viktor Leis, Tobias Muehlbauer, Thomas Neumann, and Manuel Then. 2018. 真实:基准测试如何无法代表现实世界. 在数据库系统测试研讨会论文集中(休斯顿,德克萨斯州,美国)(DBTest'18). 文章1, 6页. https://doi.org/10.1145/3209950.3209952 - [75] LZ4网站. 2024. LZ4. 取自2024-06-20 https://lz4.org/ -- [76] PRQL网站. 2024. PRQL. 取自2024-06-20 https://prql-lang.org [77] Till Westmann, Donald Kossmann, Sven Helmer, 和 Guido Moerkotte. 2000. 压缩数据库的实现与性能. SIGMOD Rec. -- 29, 3 (2000年9月), 55–67. https://doi.org/10.1145/362084.362137 [78] Fangjin Yang, Eric Tschetter, Xavier Léauté, Nelson Ray, Gian Merlino, 和 Deep Ganguli. 2014. Druid:一个实时分析数据存储. 在2014年ACM SIGMOD国际数据管理大会(Snowbird,犹他州,USA)(SIGMOD '14)论文集. 计算机协会,纽约,NY,USA, 157–168. https://doi.org/10.1145/2588555.2595631 -- [79] Tianqi Zheng, Zhibin Zhang, 和 Xueqi Cheng. 2020. SAHA:一个用于分析数据库的字符串自适应哈希表. 应用科学 10, 6 (2020). [https:](https://doi.org/10.3390/app10061915) [//doi.org/10.3390/app10061915](https://doi.org/10.3390/app10061915) -- [80] Jingren Zhou 和 Kenneth A. Ross. 2002. 使用SIMD指令实现数据库操作. 在2002年ACM SIGMOD国际数据管理大会(SIGMOD '02)论文集. 145–156. [https://doi.org/10.](https://doi.org/10.1145/564691.564709) [1145/564691.564709](https://doi.org/10.1145/564691.564709) -- [81] Marcin Zukowski, Sandor Heman, Niels Nes, 和 Peter Boncz. 2006. 超标量RAM-CPU缓存压缩. 在第22届国际数据工程会议(ICDE '06)论文集. 59. [https://doi.org/10.1109/ICDE.](https://doi.org/10.1109/ICDE.2006.150) [2006.150](https://doi.org/10.1109/ICDE.2006.150) +- [76] PRQL网站. 2024. PRQL. 取自2024-06-20 https://prql-lang.org [77] Till Westmann, Donald Kossmann, Sven Helmer, and Guido Moerkotte. 2000. 压缩数据库的实现与性能. SIGMOD Rec. +- 29, 3 (2000年9月), 55–67. https://doi.org/10.1145/362084.362137 [78] Fangjin Yang, Eric Tschetter, Xavier Léauté, Nelson Ray, Gian Merlino, and Deep Ganguli. 2014. Druid:实时分析数据存储. 在2014年ACM SIGMOD国际数据管理会议论文集中(雪鸟,犹他州,美国)(SIGMOD '14). 计算机协会, 纽约,纽约,美国, 157–168. https://doi.org/10.1145/2588555.2595631 +- [79] Tianqi Zheng, Zhibin Zhang, and Xueqi Cheng. 2020. SAHA:一种适应性字符串哈希表用于分析数据库. 应用科学 10, 6 (2020). [https:](https://doi.org/10.3390/app10061915) [//doi.org/10.3390/app10061915](https://doi.org/10.3390/app10061915) +- [80] Jingren Zhou and Kenneth A. Ross. 2002. 使用SIMD指令实现数据库操作. 在2002年ACM SIGMOD国际数据管理会议论文集中(SIGMOD '02). 145–156. [https://doi.org/10.](https://doi.org/10.1145/564691.564709) [1145/564691.564709](https://doi.org/10.1145/564691.564709) +- [81] Marcin Zukowski, Sandor Heman, Niels Nes, and Peter Boncz. 2006. 超标量RAM-CPU缓存压缩. 在第22届国际数据工程会议论文集(ICDE '06). 59. [https://doi.org/10.1109/ICDE.](https://doi.org/10.1109/ICDE.2006.150) [2006.150](https://doi.org/10.1109/ICDE.2006.150) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/academic_overview.mdx.hash b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/academic_overview.mdx.hash index c6231e75f5a..f9900b9ad43 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/academic_overview.mdx.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/academic_overview.mdx.hash @@ -1 +1 @@ -f2deb5b1e66424c3 +7658176f76a19a65 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/index.md index 3b1ed9a157e..10e6c4f7171 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/index.md @@ -1,21 +1,22 @@ --- 'slug': '/managing-data/core-concepts' 'title': '核心概念' -'description': '学习 ClickHouse 工作的核心概念' +'description': '了解 ClickHouse 的工作核心概念' 'keywords': - 'concepts' - 'part' - 'partition' - 'primary index' +'doc_type': 'guide' --- -在本节文档中,您将学习一些 ClickHouse 工作原理的核心概念。 +在本节文档中,您将了解 ClickHouse 工作的一些核心概念。 -| 页面 | 描述 | -|----------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| [表部分](/parts) | 了解 ClickHouse 中的表部分是什么。 | -| [表分区](/partitions) | 了解表分区是什么及其用途。 | -| [表部分合并](/merges) | 了解表部分合并是什么及其用途。 | -| [表分片和副本](/shards) | 了解表分片和副本是什么及其用途。 | -| [主索引](/primary-indexes) | 介绍 ClickHouse 的稀疏主索引以及它如何帮助在查询执行期间高效跳过不必要的数据。解释如何构建和使用该索引,提供示例和观察其效果的工具。链接到针对高级用例和最佳实践的深入探讨。 | -| [架构概述](/academic_overview) | 基于我们的 VLDB 2024 学术论文,对 ClickHouse 架构所有组件的简洁学术概述。 | +| 页面 | 描述 | +|----------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| [表的分区片段](./parts.md) | 了解 ClickHouse 中的表的分区片段是什么。 | +| [表的分区](./partitions.mdx) | 了解表的分区是什么以及它们的用途。 | +| [表的分区片段合并](./merges.mdx) | 了解表的分区片段合并是什么以及它们的用途。 | +| [表的分片和副本](./shards.mdx) | 了解表的分片和副本是什么以及它们的用途。 | +| [主索引](./primary-indexes.mdx) | 介绍 ClickHouse 的稀疏主索引以及它如何帮助有效跳过查询执行过程中不必要的数据。解释了索引的构建和使用方式,并提供了观察其效果的示例和工具。链接到有关高级用例和最佳实践的深度探讨。 | +| [架构概述](./academic_overview.mdx) | 基于我们在 VLDB 2024 科学论文中的研究,对 ClickHouse 架构中所有组件的简要学术概述。 | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/index.md.hash index 72a78db1956..47280354c42 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/index.md.hash @@ -1 +1 @@ -ce29e976ad08c8fd +5b9c6b589391f612 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/merges.md b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/merges.md deleted file mode 100644 index 2abf58c323b..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/merges.md +++ /dev/null @@ -1,185 +0,0 @@ ---- -'slug': '/merges' -'title': '分区合并' -'description': '在 ClickHouse 中,什么是分区合并' -'keywords': -- 'merges' ---- - -import merges_01 from '@site/static/images/managing-data/core-concepts/merges_01.png'; -import merges_02 from '@site/static/images/managing-data/core-concepts/merges_02.png'; -import merges_03 from '@site/static/images/managing-data/core-concepts/merges_03.png'; -import merges_04 from '@site/static/images/managing-data/core-concepts/merges_04.png'; -import merges_05 from '@site/static/images/managing-data/core-concepts/merges_05.png'; -import merges_06 from '@site/static/images/managing-data/core-concepts/merges_06.png'; -import merges_07 from '@site/static/images/managing-data/core-concepts/merges_07.png'; -import merges_dashboard from '@site/static/images/managing-data/core-concepts/merges-dashboard.gif'; -import Image from '@theme/IdealImage'; - -## ClickHouse 中的分区合并是什么? {#what-are-part-merges-in-clickhouse} - -
- -ClickHouse [快速](/concepts/why-clickhouse-is-so-fast) 不仅在查询时表现快速,在插入时也表现出色,这得益于其 [存储层](https://www.vldb.org/pvldb/vol17/p3731-schulze.pdf),该层的操作类似于 [LSM 树](https://en.wikipedia.org/wiki/Log-structured_merge-tree): - -① 插入(到来自 [MergeTree 引擎](/engines/table-engines/mergetree-family) 的表中)会创建排序的、不可变的 [数据部分](/parts)。 - -② 所有数据处理都卸载到 **后台分区合并** 中。 - -这使得数据写入变得轻量且 [高效](/concepts/why-clickhouse-is-so-fast#storage-layer-concurrent-inserts-are-isolated-from-each-other)。 - -为了控制每个表的部分数量并实现上述②,ClickHouse 在后台不断将较小的部分合并成较大的部分([按分区](/partitions#per-partition-merges)),直到它们的压缩大小达到大约 [~150 GB](/operations/settings/merge-tree-settings#max_bytes_to_merge_at_max_space_in_pool)。 - -下图概述了这个后台合并过程: - - - -
- -每进行一次额外的合并,部分的 `merge level` 就会增加一。`0`级别表示该部分是新的,尚未被合并。合并成较大部分的部分会被标记为 [非活动](/operations/system-tables/parts),并在 [可配置的](/operations/settings/merge-tree-settings#old_parts_lifetime) 时间后(默认8分钟)最终被删除。随着时间的推移,这会创建一个 **树形** 的合并部分。因此称之为 [merge tree](/engines/table-engines/mergetree-family) 表。 - -## 监控合并 {#monitoring-merges} - -在 [什么是表部分](/parts) 的示例中,我们 [显示了](/parts#monitoring-table-parts) ClickHouse 如何在 [parts](/operations/system-tables/parts) 系统表中跟踪所有表部分。我们使用以下查询来检索示例表每个活动部分的合并级别和存储的行数: -```sql -SELECT - name, - level, - rows -FROM system.parts -WHERE (database = 'uk') AND (`table` = 'uk_price_paid_simple') AND active -ORDER BY name ASC; -``` - -[先前文档中的](/parts#monitoring-table-parts)查询结果显示示例表有四个活动部分,每个部分均来自最初插入部分的单次合并: -```response - ┌─name────────┬─level─┬────rows─┐ -1. │ all_0_5_1 │ 1 │ 6368414 │ -2. │ all_12_17_1 │ 1 │ 6442494 │ -3. │ all_18_23_1 │ 1 │ 5977762 │ -4. │ all_6_11_1 │ 1 │ 6459763 │ - └─────────────┴───────┴─────────┘ -``` - -现在运行 [查询](https://sql.clickhouse.com/?query=U0VMRUNUCiAgICBuYW1lLAogICAgbGV2ZWwsCiAgICByb3dzCkZST00gc3lzdGVtLnBhcnRzCldIRVJFIChkYXRhYmFzZSA9ICd1aycpIEFORCAoYHRhYmxlYCA9ICd1a19wcmljZV9wYWlkX3NpbXBsZScpIEFORCBhY3RpdmUKT1JERVIgQlkgbmFtZSBBU0M7&run_query=true&tab=results) 后显示这四个部分已经合并成一个最终部分(只要表中没有进一步的插入): - -```response - ┌─name───────┬─level─┬─────rows─┐ -1. │ all_0_23_2 │ 2 │ 25248433 │ - └────────────┴───────┴──────────┘ -``` - -在 ClickHouse 24.10 中,内置的 [监控仪表盘](https://presentations.clickhouse.com/2024-release-24.10/index.html#17) 添加了新的 [合并仪表盘](https://clickhouse.com/blog/common-issues-you-can-solve-using-advanced-monitoring-dashboards)。通过 `/merges` HTTP 处理程序在 OSS 和 Cloud 中都可用,我们可以用它来可视化示例表的所有部分合并: - - - -
- -上述记录的仪表盘捕捉了整个过程,从初始数据插入到最终合并成一个部分: - -① 活动部分的数量。 - -② 部分合并,以框的形式可视化(大小反映部分的大小)。 - -③ [写放大](https://en.wikipedia.org/wiki/Write_amplification)。 - -## 并发合并 {#concurrent-merges} - -单个 ClickHouse 服务器使用多个后台 [合并线程](/operations/server-configuration-parameters/settings#background_pool_size) 来执行并发分区合并: - - - -
- -每个合并线程执行一个循环: - -① 决定下一个要合并的部分,并将这些部分加载到内存中。 - -② 在内存中将部分合并成一个更大的部分。 - -③ 将合并后的部分写入磁盘。 - -回到 ① - -请注意,增加 CPU 核心数和 RAM 大小可以提高后台合并的吞吐量。 - -## 内存优化合并 {#memory-optimized-merges} - -ClickHouse 不一定会一次将所有要合并的部分加载到内存中,如 [之前的示例](/merges#concurrent-merges) 所示。根据多个 [因素](https://github.com/ClickHouse/ClickHouse/blob/bf37120c925ed846ae5cd72cd51e6340bebd2918/src/Storages/MergeTree/MergeTreeSettings.cpp#L210),并为了减少内存消耗(牺牲合并速度),所谓的 [垂直合并](https://github.com/ClickHouse/ClickHouse/blob/bf37120c925ed846ae5cd72cd51e6340bebd2918/src/Storages/MergeTree/MergeTreeSettings.cpp#L209) 按块的块加载和合并部分,而不是一次性合并。 - -## 合并机制 {#merge-mechanics} - -下图说明了 ClickHouse 中单个后台 [合并线程](/merges#concurrent-merges) 如何合并部分(默认情况下,不进行 [垂直合并](/merges#memory-optimized-merges)): - - - -
- -部分合并分几个步骤进行: - -**① 解压缩和加载**:要合并的部分的 [压缩二进制列文件](/parts#what-are-table-parts-in-clickhouse) 被解压缩并加载到内存中。 - -**② 合并**:数据被合并成更大的列文件。 - -**③ 索引**:为合并的列文件生成新的 [稀疏主索引](/guides/best-practices/sparse-primary-indexes)。 - -**④ 压缩与存储**:新列文件和索引被 [压缩](/sql-reference/statements/create/table#column_compression_codec) 并存储在一个新的 [目录](/parts#what-are-table-parts-in-clickhouse) 中,代表合并的数据部分。 - -部分中的额外 [元数据](/parts),如二级数据跳过索引、列统计信息、校验和和最小最大索引,也基于合并的列文件重新创建。为了简化,我们省略了这些细节。 - -步骤②的机制取决于使用的特定 [MergeTree 引擎](/engines/table-engines/mergetree-family),因为不同的引擎以不同的方式处理合并。例如,行可以被聚合或替换,如果过时。如前所述,这种方法 **将所有数据处理卸载到后台合并中**,通过保持写操作轻量且高效,实现 **超快速的插入**。 - -接下来,我们将简要概述 MergeTree 家族中特定引擎的合并机制。 - - -### 标准合并 {#standard-merges} - -下图说明了标准 [MergeTree](/engines/table-engines/mergetree-family/mergetree) 表中部分是如何合并的: - - - -
- -上图中的 DDL 语句创建了一个 `MergeTree` 表,排序键为 `(town, street)`,这意味着磁盘上的数据是按这些列排序的,并相应生成稀疏主索引。 - -① 解压的、预排序的表列被 ② 合并,同时保持表的全局排序顺序,该顺序由表的排序键定义, ③ 生成新的稀疏主索引, ④ 合并后的列文件和索引被压缩并存储为新的数据部分在磁盘上。 - -### 替换合并 {#replacing-merges} - -[ReplacingMergeTree](/engines/table-engines/mergetree-family/replacingmergetree) 表中的部分合并的工作方式类似于 [标准合并](/merges#standard-merges),但仅保留每行的最新版本,丢弃旧版本: - - - -
- -上图中的 DDL 语句创建了一个排序键为 `(town, street, id)` 的 `ReplacingMergeTree` 表,这意味着磁盘上的数据是按这些列排序的,并相应生成稀疏主索引。 - -② 合并的过程与标准 `MergeTree` 表类似,合并解压的、预排序的列,同时保持全局排序顺序。 - -但是,`ReplacingMergeTree` 会删除具有相同排序键的重复行,仅保留根据其包含部分的创建时间戳确定的最新行。 - -
- -### 求和合并 {#summing-merges} - -在 [SummingMergeTree](/engines/table-engines/mergetree-family/summingmergetree) 表中的部分合并时,数值数据会自动汇总: - - - -
- -上图中的 DDL 语句定义了一个以 `town` 为排序键的 `SummingMergeTree` 表,这意味着磁盘上的数据是按此列排序的,并相应生成稀疏主索引。 - -在 ② 合并步骤中,ClickHouse 用一行替换所有具有相同排序键的行,同时对数值列的值进行求和。 - -### 聚合合并 {#aggregating-merges} - -上面的 `SummingMergeTree` 表例是 [AggregatingMergeTree](/engines/table-engines/mergetree-family/aggregatingmergetree) 表的一个特化变体,允许在部分合并过程中应用任何 [90+](https://sql-reference/aggregate-functions/reference) 聚合函数,从而实现 [自动增量数据转换](https://www.youtube.com/watch?v=QDAJTKZT8y4): - - - -
- -上图中的 DDL 语句创建了一个以 `town` 为排序键的 `AggregatingMergeTree` 表,确保磁盘上的数据是按此列排序的,并相应生成稀疏主索引。 - -在 ② 合并过程中,ClickHouse 用一行替换所有具有相同排序键的行,存储 [部分聚合状态](https://clickhouse.com/blog/clickhouse_vs_elasticsearch_mechanics_of_count_aggregations#-multi-core-parallelization)(例如,`avg()` 的 `sum` 和 `count`)。这些状态确保通过增量后台合并获得准确的结果。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/merges.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/merges.md.hash deleted file mode 100644 index fb0ba6133c5..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/merges.md.hash +++ /dev/null @@ -1 +0,0 @@ -e105bfe483848177 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/merges.mdx b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/merges.mdx new file mode 100644 index 00000000000..4d2705798fa --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/merges.mdx @@ -0,0 +1,185 @@ +--- +'slug': '/merges' +'title': '部分合并' +'description': '在 ClickHouse 中,什么是部分合并' +'keywords': +- 'merges' +'doc_type': 'guide' +--- + +import merges_01 from '@site/static/images/managing-data/core-concepts/merges_01.png'; +import merges_02 from '@site/static/images/managing-data/core-concepts/merges_02.png'; +import merges_03 from '@site/static/images/managing-data/core-concepts/merges_03.png'; +import merges_04 from '@site/static/images/managing-data/core-concepts/merges_04.png'; +import merges_05 from '@site/static/images/managing-data/core-concepts/merges_05.png'; +import merges_06 from '@site/static/images/managing-data/core-concepts/merges_06.png'; +import merges_07 from '@site/static/images/managing-data/core-concepts/merges_07.png'; +import merges_dashboard from '@site/static/images/managing-data/core-concepts/merges-dashboard.gif'; +import Image from '@theme/IdealImage'; + +## ClickHouse 中的部分合并是什么? {#what-are-part-merges-in-clickhouse} + +
+ +ClickHouse [快速](/concepts/why-clickhouse-is-so-fast) 不仅在查询方面表现出色,在插入数据方面也同样如此,这要归功于其 [存储层](https://www.vldb.org/pvldb/vol17/p3731-schulze.pdf),该层的工作方式类似于 [LSM 树](https://en.wikipedia.org/wiki/Log-structured_merge-tree): + +① 插入(到 [MergeTree 引擎](/engines/table-engines/mergetree-family) 系列的表中)会创建排序的、不可变的 [数据部分](/parts)。 + +② 所有数据处理都卸载到 **后台部分合并**。 + +这使得数据写入变得轻量且 [高效](/concepts/why-clickhouse-is-so-fast#storage-layer-concurrent-inserts-are-isolated-from-each-other)。 + +为了控制每个表的 ^^部分^^ 数量,并实现上述的 ②,ClickHouse 持续在后台将较小的 ^^部分^^ 合并成较大的 ^^部分^^,直到它们达到大约 [~150 GB](/operations/settings/merge-tree-settings#max_bytes_to_merge_at_max_space_in_pool) 的压缩大小(按分区进行合并) 。 + +以下图示画出了这个后台合并过程: + + + +
+ +每次额外合并时,部分的 `merge level` 增加一个级别。 `0` 级别表示该部分是新建的,并且尚未合并。被合并到较大 ^^部分^^ 中的 ^^部分^^ 被标记为 [非活动](/operations/system-tables/parts),并在经过 [可配置](/operations/settings/merge-tree-settings#old_parts_lifetime) 的时间后(默认 8 分钟)最终删除。随着时间的推移,这创建了一个 **合并部分的树**。因此称之为 [合并树](/engines/table-engines/mergetree-family) 表。 + +## 监控合并 {#monitoring-merges} + +在 [部分的定义](/parts) 示例中,我们 [展示](/parts#monitoring-table-parts) 了 ClickHouse 如何跟踪 [parts](/operations/system-tables/parts) 系统表中的所有表 ^^部分^^。我们使用以下查询来检索示例表每个活动部分的合并级别和存储行数: +```sql +SELECT + name, + level, + rows +FROM system.parts +WHERE (database = 'uk') AND (`table` = 'uk_price_paid_simple') AND active +ORDER BY name ASC; +``` + +[之前文档中的](/parts#monitoring-table-parts) 查询结果显示,示例表有四个活动 ^^部分^^,每个部分来自最初插入 ^^部分^^ 的单次合并: +```response + ┌─name────────┬─level─┬────rows─┐ +1. │ all_0_5_1 │ 1 │ 6368414 │ +2. │ all_12_17_1 │ 1 │ 6442494 │ +3. │ all_18_23_1 │ 1 │ 5977762 │ +4. │ all_6_11_1 │ 1 │ 6459763 │ + └─────────────┴───────┴─────────┘ +``` + +通过 [运行](https://sql.clickhouse.com/?query=U0VMRUNUCiAgICBuYW1lLAogICAgbGV2ZWwsCiAgICByb3dzCkZST00gc3lzdGVtLnBhcnRzCldIRVJFIChkYXRhYmFzZSA9ICd1aycpIEFORCAoYHRhYmxlYCA9ICd1a19wcmljZV9wYWlkX3NpbXBsZScpIEFORCBhY3RpdmUKT1JERVIgQlkgbmFtZSBBU0M7&run_query=true&tab=results) 查询,现在显示这四个 ^^部分^^ 已合并为一个最终部分(前提是没有进一步插入到该表): + +```response + ┌─name───────┬─level─┬─────rows─┐ +1. │ all_0_23_2 │ 2 │ 25248433 │ + └────────────┴───────┴──────────┘ +``` + +在 ClickHouse 24.10 中,新增了一个 [合并仪表板](https://presentations.clickhouse.com/2024-release-24.10/index.html#17) 到内置的 [监控仪表板](https://clickhouse.com/blog/common-issues-you-can-solve-using-advanced-monitoring-dashboards)。通过 /merges HTTP 处理器可在 OSS 和云端使用,我们可以使用它来可视化示例表的所有部分合并: + + + +
+ +上述记录的仪表板捕捉了整个过程,从初始数据插入到最终合并为一个部分: + +① 活动 ^^部分^^ 的数量。 + +② 部分合并,以方框的形式可视化(大小反映部分大小)。 + +③ [写入放大](https://en.wikipedia.org/wiki/Write_amplification)。 + +## 并发合并 {#concurrent-merges} + +单个 ClickHouse 服务器使用多个后台 [合并线程](/operations/server-configuration-parameters/settings#background_pool_size) 来执行并发部分合并: + + + +
+ +每个合并线程执行一个循环: + +① 决定接下来合并哪 ^^部分^^,并将这些 ^^部分^^ 加载到内存中。 + +② 将内存中的 ^^部分^^ 合并为一个更大的部分。 + +③ 将合并后的部分写入磁盘。 + +返回到 ① + +请注意,增加 CPU 核心数量和 RAM 大小可以增加后台合并的吞吐量。 + +## 内存优化合并 {#memory-optimized-merges} + +ClickHouse 并不一定会一次性将所有待合并的 ^^部分^^ 加载到内存中,如 [前面的示例](/merges#concurrent-merges) 所示。基于多个 [因素](https://github.com/ClickHouse/ClickHouse/blob/bf37120c925ed846ae5cd72cd51e6340bebd2918/src/Storages/MergeTree/MergeTreeSettings.cpp#L210),为了减少内存消耗(牺牲合并速度),所谓的 [垂直合并](https://github.com/ClickHouse/ClickHouse/blob/bf37120c925ed846ae5cd72cd51e6340bebd2918/src/Storages/MergeTree/MergeTreeSettings.cpp#L209) 以块的形式加载并合并 ^^部分^^ ,而不是一次性完成。 + +## 合并机制 {#merge-mechanics} + +下图展示了一个在 ClickHouse 中的后台 [合并线程](/merges#concurrent-merges) 如何合并 ^^部分^^(默认情况下,不使用 [垂直合并](/merges#memory-optimized-merges)): + + + +
+ +部分合并的执行分为几个步骤: + +**① 解压缩与加载**:要合并的 ^^部分^^ 中的 [压缩二进制列文件](/parts#what-are-table-parts-in-clickhouse) 被解压缩并加载到内存中。 + +**② 合并**:数据被合并到更大的列文件中。 + +**③ 索引**:为合并后的列文件生成一个新的 [稀疏主键索引](/guides/best-practices/sparse-primary-indexes)。 + +**④ 压缩与存储**:新的列文件和索引被 [压缩](/sql-reference/statements/create/table#column_compression_codec) 并保存到一个新的 [目录](/parts#what-are-table-parts-in-clickhouse),表示合并后的数据部分。 + +来自数据部分的其他 [元数据](/parts),如二级数据跳过索引、列统计、校验和和最小值-最大值索引,也根据合并后的列文件重新创建。为了简化,我们省略了这些细节。 + +步骤 ② 的机制取决于使用的具体 [MergeTree 引擎](/engines/table-engines/mergetree-family),因为不同引擎处理合并的方式不同。例如,如果行过时,可能会聚合或替换行。如前所述,这种方法 **将所有数据处理卸载到后台合并中**,从而通过保持写操作轻量和高效来实现 **超快的插入**。 + +接下来,我们将简要概述 ^^MergeTree^^ 系列中特定引擎的合并机制。 + +### 标准合并 {#standard-merges} + +下图展示了标准 [MergeTree](/engines/table-engines/mergetree-family/mergetree) 表中 ^^部分^^ 的合并过程: + + + +
+ +上图中的 DDL 语句创建了一个 `MergeTree` 表,其 ^^排序键^^ 为 `(town, street)`,这意味着磁盘上的数据按这些列排序,生成相应的稀疏主键索引。 + +① 解压缩的预排序表列被 ② 以保留表的全局排序顺序为前提进行合并,该顺序由表的 ^^排序键^^ 定义,③ 生成一个新的稀疏主键索引,最后 ④ 将合并后的列文件和索引压缩并作为新的数据部分存储到磁盘上。 + +### 替换合并 {#replacing-merges} + +在 [ReplacingMergeTree](/engines/table-engines/mergetree-family/replacingmergetree) 表中的部分合并工作方式类似于 [标准合并](/merges#standard-merges),但只保留每行的最新版本,丢弃旧版本: + + + +
+ +上图中的 DDL 语句创建了一个 `ReplacingMergeTree` 表,其 ^^排序键^^ 为 `(town, street, id)`,这意味着磁盘上的数据按这些列排序,并生成相应的稀疏主键索引。 + +合并过程中的 ② 步骤与标准 `MergeTree` 表类似,合并解压缩的预排序列,同时保持全局排序顺序。 + +但是,`ReplacingMergeTree` 删除具有相同 ^^排序键^^ 的重复行,仅保留基于其包含部分的创建时间戳的最新行。 + +
+ +### 汇总合并 {#summing-merges} + +在 [SummingMergeTree](/engines/table-engines/mergetree-family/summingmergetree) 表中,数值数据在 ^^部分^^ 合并过程中会自动汇总: + + + +
+ +上图中的 DDL 语句定义了一个 `SummingMergeTree` 表,`town` 为 ^^排序键^^,这意味着磁盘上的数据按该列排序,并相应地创建一个稀疏主键索引。 + +在合并的 ② 步骤中,ClickHouse 用一行替换所有具有相同 ^^排序键^^ 的行,并对数值列的值进行求和。 + +### 聚合合并 {#aggregating-merges} + +上面的 `SummingMergeTree` 表示例是 [AggregatingMergeTree](/engines/table-engines/mergetree-family/aggregatingmergetree) 表的一个专门变体,允许通过在部分合并过程中应用任何 [90+](/sql-reference/aggregate-functions/reference) 个聚合函数来实现 [自动增量数据转换](https://www.youtube.com/watch?v=QDAJTKZT8y4): + + + +
+ +上图中的 DDL 语句创建了一个 `AggregatingMergeTree` 表,`town` 为 ^^排序键^^,确保数据在磁盘上按此列排序,并生成相应的稀疏主键索引。 + +在合并的 ② 步骤中,ClickHouse 用一行替换所有具有相同 ^^排序键^^ 的行,存储 [部分聚合状态](https://clickhouse.com/blog/clickhouse_vs_elasticsearch_mechanics_of_count_aggregations#-multi-core-parallelization)(例如,对于 `avg()` 的 `sum` 和 `count`)。这些状态通过增量后台合并确保了结果的准确性。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/merges.mdx.hash b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/merges.mdx.hash new file mode 100644 index 00000000000..0d49498d05a --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/merges.mdx.hash @@ -0,0 +1 @@ +5886a82cca397d35 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/partitions.md b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/partitions.md deleted file mode 100644 index 8277168c3a0..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/partitions.md +++ /dev/null @@ -1,319 +0,0 @@ ---- -'slug': '/partitions' -'title': '表分区' -'description': '在 ClickHouse 中,什么是表分区' -'keywords': -- 'partitions' -- 'partition by' ---- - -import partitions from '@site/static/images/managing-data/core-concepts/partitions.png'; -import merges_with_partitions from '@site/static/images/managing-data/core-concepts/merges_with_partitions.png'; -import partition_pruning from '@site/static/images/managing-data/core-concepts/partition-pruning.png'; -import Image from '@theme/IdealImage'; - -## ClickHouse中的表分区是什么? {#what-are-table-partitions-in-clickhouse} - -
- -分区将[数据部分](/parts)组织到[MergeTree引擎系列](/engines/table-engines/mergetree-family)中的表中,形成有序的逻辑单元,这是一种以概念上有意义的方式组织数据的方法,并与特定标准(如时间范围、类别或其他关键属性)对齐。这些逻辑单元使数据更容易管理、查询和优化。 - -### 分区依据 {#partition-by} - -在通过[PARTITION BY子句](/engines/table-engines/mergetree-family/custom-partitioning-key)定义表时,可以启用分区。此子句可以包含任何列上的SQL表达式,其结果将定义某一行属于哪个分区。 - -为此,我们通过添加一个 `PARTITION BY toStartOfMonth(date)`子句来[增强](https://sql.clickhouse.com/?query=U0hPVyBDUkVBVEUgVEFCTEUgdWsudWtfcHJpY2VfcGFpZF9zaW1wbGVfcGFydGl0aW9uZWQ&run_query=true&tab=results) [表部分是什么](/parts)的示例表,该子句根据物业销售的月份组织表的数据部分: - -```sql -CREATE TABLE uk.uk_price_paid_simple_partitioned -( - date Date, - town LowCardinality(String), - street LowCardinality(String), - price UInt32 -) -ENGINE = MergeTree -ORDER BY (town, street) -PARTITION BY toStartOfMonth(date); -``` - -您可以在我们的ClickHouse SQL Playground中[查询此表](https://sql.clickhouse.com/?query=U0VMRUNUICogRlJPTSB1ay51a19wcmljZV9wYWlkX3NpbXBsZV9wYXJ0aXRpb25lZA&run_query=true&tab=results)。 - -### 磁盘上的结构 {#structure-on-disk} - -每当一组行被插入到表中时,ClickHouse不会创建(至少)一个包含所有插入行的单一数据部分(如[这里所述](/parts)),而是为每个插入行中唯一的分区键值创建一个新的数据部分: - - - -
- -ClickHouse服务器首先根据示例插入中4行的分区键值 `toStartOfMonth(date)`来拆分行。 -然后,对于每个识别出的分区,这些行按[常规](/parts)进行处理,执行多个顺序步骤(① 排序,② 拆分为列,③ 压缩,④ 写入磁盘)。 - -请注意,启用分区后,ClickHouse会自动为每个数据部分创建[MinMax索引](https://github.com/ClickHouse/ClickHouse/blob/dacc8ebb0dac5bbfce5a7541e7fc70f26f7d5065/src/Storages/MergeTree/IMergeTreeDataPart.h#L341)。这些索引只是用于分区键表达式中的每个表列的文件,包含该列在数据部分中的最小值和最大值。 - -### 每个分区合并 {#per-partition-merges} - -启用分区后,ClickHouse仅会[合并](/merges)分区内的数据部分,而不会跨分区合并。我们为上面的示例表简单绘制如下: - - - -
- -如上图所示,属于不同分区的部分永远不会被合并。如果选择一个高基数的分区键,则分布在数千个分区上的部分将永远不是合并候选,超出预配置的限制,导致可怕的 `Too many parts` 错误。解决这个问题的方法很简单:选择一个基数在[1000到10000之间](https://github.com/ClickHouse/ClickHouse/blob/ffc5b2c56160b53cf9e5b16cfb73ba1d956f7ce4/src/Storages/MergeTree/MergeTreeDataWriter.cpp#L121)的合理分区键。 - -## 监控分区 {#monitoring-partitions} - -您可以使用[虚拟列](/engines/table-engines#table_engines-virtual_columns) `_partition_value`查询我们示例表的所有现有唯一分区列表: - -```sql runnable -SELECT DISTINCT _partition_value AS partition -FROM uk.uk_price_paid_simple_partitioned -ORDER BY partition ASC; -``` - -另外,ClickHouse在[system.parts](/operations/system-tables/parts)系统表中跟踪所有表的所有部分和分区,以下查询[返回](https://sql.clickhouse.com/?query=U0VMRUNUCiAgICBwYXJ0aXRpb24sCiAgICBjb3VudCgpIEFTIHBhcnRzLAogICAgc3VtKHJvd3MpIEFTIHJvd3MKRlJPTSBzeXN0ZW0ucGFydHMKV0hFUkUgKGRhdGFiYXNlID0gJ3VrJykgQU5EIChgdGFibGVgID0gJ3VrX3ByaWNlX3BhaWRfc2ltcGxlX3BhcnRpdGlvbmVkJykgQU5EIGFjdGl2ZQpHUk9VUCBCWSBwYXJ0aXRpb24KT1JERVIgQlkgcGFydGl0aW9uIEFTQzs&run_query=true&tab=results)关于我们上面的示例表的所有分区列表,以及每个分区中的当前活动部分和行总数: - -```sql runnable -SELECT - partition, - count() AS parts, - sum(rows) AS rows -FROM system.parts -WHERE (database = 'uk') AND (`table` = 'uk_price_paid_simple_partitioned') AND active -GROUP BY partition -ORDER BY partition ASC; -``` - -## 表分区的用途是什么? {#what-are-table-partitions-used-for} - -### 数据管理 {#data-management} - -在ClickHouse中,分区主要是一项数据管理功能。通过基于分区表达式逻辑组织数据,每个分区可以独立管理。例如,上述示例表中的分区方案使得场景得以实现,只有过去12个月的数据会保留在主表中,利用[TTL规则](/guides/developer/ttl)自动删除旧数据(请参见DDL语句中添加的最后一行): - -```sql -CREATE TABLE uk.uk_price_paid_simple_partitioned -( - date Date, - town LowCardinality(String), - street LowCardinality(String), - price UInt32 -) -ENGINE = MergeTree -PARTITION BY toStartOfMonth(date) -ORDER BY (town, street) -TTL date + INTERVAL 12 MONTH DELETE; -``` -由于该表由 `toStartOfMonth(date)`分区,满足TTL条件的整个分区([表部分](/parts)的集合)将被删除,从而使清理操作更高效,而[不必重写部分](/sql-reference/statements/alter#mutations)。 - -同样,不是删除旧数据,而是可以将其自动高效地移动到更具成本效益的[存储层](/integrations/s3#storage-tiers)中: - -```sql -CREATE TABLE uk.uk_price_paid_simple_partitioned -( - date Date, - town LowCardinality(String), - street LowCardinality(String), - price UInt32 -) -ENGINE = MergeTree -PARTITION BY toStartOfMonth(date) -ORDER BY (town, street) -TTL date + INTERVAL 12 MONTH TO VOLUME 'slow_but_cheap'; -``` - -### 查询优化 {#query-optimization} - -分区可以帮助提高查询性能,但这在很大程度上依赖于访问模式。如果查询仅针对少数几个分区(理想情况下是一个),性能可能会有所改善。这通常只有在分区键不在主键中,并且您正在按其过滤时才有用,如下面示例查询所示。 - -```sql runnable -SELECT MAX(price) AS highest_price -FROM uk.uk_price_paid_simple_partitioned -WHERE date >= '2020-12-01' - AND date <= '2020-12-31' - AND town = 'LONDON'; -``` - -该查询在上述示例表上运行并[计算](https://sql.clickhouse.com/?query=U0VMRUNUIE1BWChwcmljZSkgQVMgaGlnaGVzdF9wcmljZQpGUk9NIHVrLnVrX3ByaWNlX3BhaWRfc2ltcGxlX3BhcnRpdGlvbmVkCldIRVJFIGRhdGUgPj0gJzIwMjAtMTItMDEnCiAgQU5EIGRhdGUgPD0gJzIwMjAtMTItMzEnCiAgQU5EIHRvd24gPSAnTE9ORE9OJzs&run_query=true&tab=results)出2020年12月在伦敦所有已售物业的最高价格,按照同时使用表的分区键中的一个列(`date`)和主键中的一个列(`town`)进行过滤(`date`并不是主键的一部分)。 - -ClickHouse通过应用一系列剪枝技术来处理该查询,以避免评估不相关的数据: - - - -
- -① **分区剪枝**:[MinMax索引](/partitions#what-are-table-partitions-in-clickhouse)用于忽略整个不符合查询对表分区键中使用的列的过滤条件的分区(部分集合)。 - -② **粒度剪枝**:对于步骤①之后的剩余数据部分,使用其[主索引](/guides/best-practices/sparse-primary-indexes)忽略所有逻辑上与查询对表主键中使用的列的过滤条件不匹配的[粒度](/guides/best-practices/sparse-primary-indexes#data-is-organized-into-granules-for-parallel-data-processing)(行块)。 - -我们可以通过[检查](https://sql.clickhouse.com/?query=RVhQTEFJTiBpbmRleGVzID0gMQpTRUxFQ1QgTUFYKHByaWNlKSBBUyBoaWdoZXN0X3ByaWNlCkZST00gdWsudWtfcHJpY2VfcGFpZF9zaW1wbGVfcGFydGl0aW9uZWQKV0hFUkUgZGF0ZSA-PSAnMjAyMC0xMi0wMScKICBBTkQgZGF0ZSA8PSAnMjAyMC0xMi0zMScKICBBTkQgdG93biA9ICdMT05ET04nOw&run_query=true&tab=results)我们上面示例查询的物理查询执行计划,通过[EXPLAIN](/sql-reference/statements/explain)子句: - -```sql style="fontSize:13px" -EXPLAIN indexes = 1 -SELECT MAX(price) AS highest_price -FROM uk.uk_price_paid_simple_partitioned -WHERE date >= '2020-12-01' - AND date <= '2020-12-31' - AND town = 'LONDON'; - - - ┌─explain──────────────────────────────────────────────────────────────────────────────────────────────────────┐ - 1. │ Expression ((Project names + Projection)) │ - 2. │ Aggregating │ - 3. │ Expression (Before GROUP BY) │ - 4. │ Expression │ - 5. │ ReadFromMergeTree (uk.uk_price_paid_simple_partitioned) │ - 6. │ Indexes: │ - 7. │ MinMax │ - 8. │ Keys: │ - 9. │ date │ -10. │ Condition: and((date in (-Inf, 18627]), (date in [18597, +Inf))) │ -11. │ Parts: 1/436 │ -12. │ Granules: 11/3257 │ -13. │ Partition │ -14. │ Keys: │ -15. │ toStartOfMonth(date) │ -16. │ Condition: and((toStartOfMonth(date) in (-Inf, 18597]), (toStartOfMonth(date) in [18597, +Inf))) │ -17. │ Parts: 1/1 │ -18. │ Granules: 11/11 │ -19. │ PrimaryKey │ -20. │ Keys: │ -21. │ town │ -22. │ Condition: (town in ['LONDON', 'LONDON']) │ -23. │ Parts: 1/1 │ -24. │ Granules: 1/11 │ - └──────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ -``` - -上面的输出显示: - -① 分区剪枝:EXPLAIN输出的第7到18行显示,ClickHouse首先使用`date`字段的[MinMax索引](/partitions#what-are-table-partitions-in-clickhouse)来识别3257个现有[粒度](/guides/best-practices/sparse-primary-indexes#data-is-organized-into-granules-for-parallel-data-processing)(行块)中的11个,它们存储在436个现有活动数据部分中的1个中,这些数据部分包含匹配查询的`date`过滤条件的行。 - -② 粒度剪枝:EXPLAIN输出的第19到24行表明,ClickHouse随后使用步骤①中标识的数据部分的[主索引](/guides/best-practices/sparse-primary-indexes)(在`town`字段上创建)进一步将粒度数量(可能也包含匹配查询的`town`过滤条件的行)从11减少到1。这在我们进一步上面的查询运行中打印的ClickHouse客户端输出中也得到了反映: - -```response -... Elapsed: 0.006 sec. Processed 8.19 thousand rows, 57.34 KB (1.36 million rows/s., 9.49 MB/s.) -Peak memory usage: 2.73 MiB. -``` - -这意味着ClickHouse在6毫秒内扫描和处理了1个粒度([8192](/operations/settings/merge-tree-settings#index_granularity)行块),以计算查询结果。 - -### 分区主要是数据管理功能 {#partitioning-is-primarily-a-data-management-feature} - -请注意,在所有分区上查询通常比在未分区表上运行相同的查询会更慢。 - -有了分区,数据通常分布在更多的数据部分上,这通常导致ClickHouse扫描和处理大量数据。 - -我们可以通过在[表部分是什么](/parts)示例表(未启用分区)和我们上面的当前示例表(启用分区)上运行相同查询来证明这一点。这两个表[包含](https://sql.clickhouse.com/?query=U0VMRUNUCiAgICB0YWJsZSwKICAgIHN1bShyb3dzKSBBUyByb3dzCkZST00gc3lzdGVtLnBhcnRzCldIRVJFIChkYXRhYmFzZSA9ICd1aycpIEFORCAoYHRhYmxlYCBJTiBbJ3VrX3ByaWNlX3BhaWRfc2ltcGxlJywgJ3VrX3ByaWNlX3BhaWRfc2ltcGxlX3BhcnRpdGlvbmVkJ10pIEFORCBhY3RpdmUKR1JPVVAgQlkgdGFibGU7&run_query=true&tab=results)相同的数据和行数: - -```sql runnable -SELECT - table, - sum(rows) AS rows -FROM system.parts -WHERE (database = 'uk') AND (table IN ['uk_price_paid_simple', 'uk_price_paid_simple_partitioned']) AND active -GROUP BY table; -``` - -然而,启用了分区的表[具有](https://sql.clickhouse.com/?query=U0VMRUNUCiAgICB0YWJsZSwKICAgIGNvdW50KCkgQVMgcGFydHMKRlJPTSBzeXN0ZW0ucGFydHMKV0hFUkUgKGRhdGFiYXNlID0gJ3VrJykgQU5EIChgdGFibGVgIElOIFsndWtfcHJpY2VfcGFpZF9zaW1wbGUnLCAndWtfcHJpY2VfcGFpZF9zaW1wbGVfcGFydGl0aW9uZWQnXSkgQU5EIGFjdGl2ZQpHUk9VUCBCWSB0YWJsZTs&run_query=true&tab=results)更多的活动[data parts](/parts),因为,如上所述,ClickHouse仅在分区内[合并](/parts)数据部分,而不跨分区合并: - -```sql runnable -SELECT - table, - count() AS parts -FROM system.parts -WHERE (database = 'uk') AND (table IN ['uk_price_paid_simple', 'uk_price_paid_simple_partitioned']) AND active -GROUP BY table; - -``` -如上所示,分区表 `uk_price_paid_simple_partitioned` 拥有超过600个分区,因此有306个活动数据部分。而对于我们的未分区表 `uk_price_paid_simple`,所有[初始](/parts)数据部分都可以通过后台合并合并为单个活动部分。 - - -当我们[检查](https://sql.clickhouse.com/?query=RVhQTEFJTiBpbmRleGVzID0gMQpTRUxFQ1QgTUFYKHByaWNlKSBBUyBoaWdoZXN0X3ByaWNlCkZST00gdWsudWtfcHJpY2VfcGFpZF9zaW1wbGVfcGFydGl0aW9uZWQKV0hFUkUgdG93biA9ICdMT05ET04nOw&run_query=true&tab=results)上面示例查询的物理查询执行计划时,使用[EXPLAIN](/sql-reference/statements/explain)子句,针对分区表的查询未使用分区过滤,下面输出的第19和20行中可以看到,ClickHouse识别出671个现有[粒度](/guides/best-practices/sparse-primary-indexes#data-is-organized-into-granules-for-parallel-data-processing)(行块),分布在436个现有活动数据部分上,这些部分可能包含匹配查询过滤的行,因此将被查询引擎扫描和处理: - -```sql -EXPLAIN indexes = 1 -SELECT MAX(price) AS highest_price -FROM uk.uk_price_paid_simple_partitioned -WHERE town = 'LONDON'; - - - ┌─explain─────────────────────────────────────────────────────────┐ - 1. │ Expression ((Project names + Projection)) │ - 2. │ Aggregating │ - 3. │ Expression (Before GROUP BY) │ - 4. │ Expression │ - 5. │ ReadFromMergeTree (uk.uk_price_paid_simple_partitioned) │ - 6. │ Indexes: │ - 7. │ MinMax │ - 8. │ Condition: true │ - 9. │ Parts: 436/436 │ -10. │ Granules: 3257/3257 │ -11. │ Partition │ -12. │ Condition: true │ -13. │ Parts: 436/436 │ -14. │ Granules: 3257/3257 │ -15. │ PrimaryKey │ -16. │ Keys: │ -17. │ town │ -18. │ Condition: (town in ['LONDON', 'LONDON']) │ -19. │ Parts: 431/436 │ -20. │ Granules: 671/3257 │ - └─────────────────────────────────────────────────────────────────┘ -``` - -对于相同的示例查询在未分区表上运行的物理查询执行计划[显示](https://sql.clickhouse.com/?query=RVhQTEFJTiBpbmRleGVzID0gMQpTRUxFQ1QgTUFYKHByaWNlKSBBUyBoaWdoZXN0X3ByaWNlCkZST00gdWsudWtfcHJpY2VfcGFpZF9zaW1wbGUKV0hFUkUgdG93biA9ICdMT05ET04nOw&run_query=true&tab=results),输出的第11和12行中可以看到,ClickHouse识别出241个现有行块,在表的单个活动数据部分中,这些行块可能包含匹配查询过滤的行: - -```sql -EXPLAIN indexes = 1 -SELECT MAX(price) AS highest_price -FROM uk.uk_price_paid_simple -WHERE town = 'LONDON'; - - - ┌─explain───────────────────────────────────────────────┐ - 1. │ Expression ((Project names + Projection)) │ - 2. │ Aggregating │ - 3. │ Expression (Before GROUP BY) │ - 4. │ Expression │ - 5. │ ReadFromMergeTree (uk.uk_price_paid_simple) │ - 6. │ Indexes: │ - 7. │ PrimaryKey │ - 8. │ Keys: │ - 9. │ town │ -10. │ Condition: (town in ['LONDON', 'LONDON']) │ -11. │ Parts: 1/1 │ -12. │ Granules: 241/3083 │ - └───────────────────────────────────────────────────────┘ -``` - -对于[运行](https://sql.clickhouse.com/?query=U0VMRUNUIE1BWChwcmljZSkgQVMgaGlnaGVzdF9wcmljZQpGUk9NIHVrLnVrX3ByaWNlX3BhaWRfc2ltcGxlX3BhcnRpdGlvbmVkCldIRVJFIHRvd24gPSAnTE9ORE9OJzs&run_query=true&tab=results)分区版本表的查询,ClickHouse在90毫秒内扫描和处理了671个行块(约550万行): - -```sql -SELECT MAX(price) AS highest_price -FROM uk.uk_price_paid_simple_partitioned -WHERE town = 'LONDON'; - -┌─highest_price─┐ -│ 594300000 │ -- 594.30 million -└───────────────┘ - -1 row in set. Elapsed: 0.090 sec. Processed 5.48 million rows, 27.95 MB (60.66 million rows/s., 309.51 MB/s.) -Peak memory usage: 163.44 MiB. -``` - - -而对于[运行](https://sql.clickhouse.com/?query=U0VMRUNUIE1BWChwcmljZSkgQVMgaGlnaGVzdF9wcmljZQpGUk9NIHVrLnVrX3ByaWNlX3BhaWRfc2ltcGxlCldIRVJFIHRvd24gPSAnTE9ORE9OJzs&run_query=true&tab=results)未分区表的查询,ClickHouse在12毫秒内扫描和处理了241个行块(约200万行): - -```sql -SELECT MAX(price) AS highest_price -FROM uk.uk_price_paid_simple -WHERE town = 'LONDON'; - -┌─highest_price─┐ -│ 594300000 │ -- 594.30 million -└───────────────┘ - -1 row in set. Elapsed: 0.012 sec. Processed 1.97 million rows, 9.87 MB (162.23 million rows/s., 811.17 MB/s.) -Peak memory usage: 62.02 MiB. -``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/partitions.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/partitions.md.hash deleted file mode 100644 index 7f1397e780a..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/partitions.md.hash +++ /dev/null @@ -1 +0,0 @@ -30676c0a129cf1a0 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/partitions.mdx b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/partitions.mdx new file mode 100644 index 00000000000..6d6f594d91e --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/partitions.mdx @@ -0,0 +1,315 @@ +--- +'slug': '/partitions' +'title': '表分区' +'description': '在 ClickHouse 中,表分区是什么' +'keywords': +- 'partitions' +- 'partition by' +'doc_type': 'guide' +--- + +import partitions from '@site/static/images/managing-data/core-concepts/partitions.png'; +import merges_with_partitions from '@site/static/images/managing-data/core-concepts/merges_with_partitions.png'; +import partition_pruning from '@site/static/images/managing-data/core-concepts/partition-pruning.png'; +import Image from '@theme/IdealImage'; + +## 在 ClickHouse 中,表分区是什么? {#what-are-table-partitions-in-clickhouse} + +
+ +分区将表的 [数据部分](/parts) 组织成有序的逻辑单元,这些单元在 [MergeTree 引擎系列](/engines/table-engines/mergetree-family) 中是有概念意义的,符合特定标准,例如时间范围、类别或其他关键属性。这些逻辑单元使得数据更容易管理、查询和优化。 + +### 按分区 {#partition-by} + +在通过 [PARTITION BY 子句](/engines/table-engines/mergetree-family/custom-partitioning-key) 初始定义表时,可以启用分区。该子句可以包含任何列的 SQL 表达式,其结果将定义行所属的分区。 + +为了说明这一点,我们 [增强](https://sql.clickhouse.com/?query=U0hPVyBDUkVBVEUgVEFCTEUgdWsudWtfcHJpY2VfcGFpZF9zaW1wbGVfcGFydGl0aW9uZWQ&run_query=true&tab=results) 查询示例表,在其中添加 `PARTITION BY toStartOfMonth(date)` 子句,这将基于房产销售的月份组织表的数据部分: + +```sql +CREATE TABLE uk.uk_price_paid_simple_partitioned +( + date Date, + town LowCardinality(String), + street LowCardinality(String), + price UInt32 +) +ENGINE = MergeTree +ORDER BY (town, street) +PARTITION BY toStartOfMonth(date); +``` + +你可以在我们的 ClickHouse SQL Playground 中 [查询该表](https://sql.clickhouse.com/?query=U0VMRUNUICogRlJPTSB1ay51a19wcmljZV9wYWlkX3NpbXBsZV9wYXJ0aXRpb25lZA&run_query=true&tab=results)。 + +### 磁盘上的结构 {#structure-on-disk} + +每当一组行插入到表中时,ClickHouse 不会创建一个包含所有插入行的单一数据部分(如 [这里所述](/parts)),而是为插入行中每个唯一的分区键值创建一个新的数据部分: + + + +
+ +ClickHouse 服务器首先根据分区键值 `toStartOfMonth(date)` 将插入的示例行(如上图中草图所示的 4 行)进行拆分。 +然后,对于每个已识别的分区,这些行会按 [常规](/parts) 进行处理,执行几个顺序步骤(① 排序,② 拆分成列,③ 压缩,④ 写入磁盘)。 + +请注意,启用分区后,ClickHouse 会自动为每个数据部分创建 [MinMax 索引](https://github.com/ClickHouse/ClickHouse/blob/dacc8ebb0dac5bbfce5a7541e7fc70f26f7d5065/src/Storages/MergeTree/IMergeTreeDataPart.h#L341)。这些索引是用于分区键表达式的每个表列的文件,包含该列在数据部分内的最小值和最大值。 + +### 每个分区的合并 {#per-partition-merges} + +启用分区后,ClickHouse 只会在分区内 [合并](/merges) 数据部分,而不会跨分区合并。我们为上面的示例表进行草图: + + + +
+ +如上图所示,属于不同分区的部分是不会合并的。如果选择了高基数的分区键,那么分散在数千个分区中的部分将永远不会成为合并候选——超过预配置的限制并导致让人头疼的 `Too many ^^parts^^` 错误。解决这个问题很简单:选择一个基数在 [1000 到 10000 之间的合理分区键](https://github.com/ClickHouse/ClickHouse/blob/ffc5b2c56160b53cf9e5b16cfb73ba1d956f7ce4/src/Storages/MergeTree/MergeTreeDataWriter.cpp#L121)。 + +## 监控分区 {#monitoring-partitions} + +你可以通过使用虚拟列 [/_partition_value](/engines/table-engines#table_engines-virtual_columns) 来 [查询](https://sql.clickhouse.com/?query=U0VMRUNUIERJU1RJTkNUIF9wYXJ0aXRpb25fdmFsdWUgQVMgcGFydGl0aW9uCkZST00gdWsudWtfcHJpY2VfcGFpZF9zaW1wbGVfcGFydGl0aW9uZWQKT1JERVIgQlkgcGFydGl0aW9uIEFTQw&run_query=true&tab=results) 我们示例表中所有现有唯一分区的列表: + +```sql runnable +SELECT DISTINCT _partition_value AS partition +FROM uk.uk_price_paid_simple_partitioned +ORDER BY partition ASC; +``` + +另外,ClickHouse 在 [system.parts](/operations/system-tables/parts) 系统表中跟踪所有表的所有部分和分区,以下查询 [返回](https://sql.clickhouse.com/?query=U0VMRUNUCiAgICBwYXJ0aXRpb24sCiAgICBjb3VudCgpIEFTIHBhcnRzLAogICAgc3VtKHJvd3MpIEFTIHJvd3MKRlJPTSBzeXN0ZW0ucGFydHMKV0hFUkUgKGRhdGFiYXNlID0gJ3VrJykgQU5EIChgdGFibGVgID0gJ3VrX3ByaWNlX3BhaWRfc2ltcGxlX3BhcnRpdGlvbmVkJykgQU5EIGFjdGl2ZQpHUk9VUCBCWSBwYXJ0aXRpb24KT1JERVIgQlkgcGFydGl0aW9uIEFTQzs&run_query=true&tab=results) 我们上面的示例表中所有分区的列表,此外还有当前活动部分的数量和每个分区的这些部分中的行总数: + +```sql runnable +SELECT + partition, + count() AS parts, + sum(rows) AS rows +FROM system.parts +WHERE (database = 'uk') AND (`table` = 'uk_price_paid_simple_partitioned') AND active +GROUP BY partition +ORDER BY partition ASC; +``` + +## 表分区的用途是什么? {#what-are-table-partitions-used-for} + +### 数据管理 {#data-management} + +在 ClickHouse 中,分区主要是一种数据管理功能。通过根据分区表达式逻辑组织数据,每个分区可以独立管理。例如,上述示例表中的分区方案能够实现只在主表中保留过去 12 个月的数据,通过自动删除旧数据来实现 [TTL 规则](/guides/developer/ttl)(见已添加的 DDL 语句的最后一行): + +```sql +CREATE TABLE uk.uk_price_paid_simple_partitioned +( + date Date, + town LowCardinality(String), + street LowCardinality(String), + price UInt32 +) +ENGINE = MergeTree +PARTITION BY toStartOfMonth(date) +ORDER BY (town, street) +TTL date + INTERVAL 12 MONTH DELETE; +``` +由于表是通过 `toStartOfMonth(date)` 分区的,满足 TTL 条件的整个分区([表部分](/parts) 的集合)将被删除,从而使得清理操作更高效,[而无需重写部分](/sql-reference/statements/alter#mutations)。 + +类似地,不必删除旧数据,它可以被自动和高效地移动到更具成本效益的 [存储层级](/integrations/s3#storage-tiers): + +```sql +CREATE TABLE uk.uk_price_paid_simple_partitioned +( + date Date, + town LowCardinality(String), + street LowCardinality(String), + price UInt32 +) +ENGINE = MergeTree +PARTITION BY toStartOfMonth(date) +ORDER BY (town, street) +TTL date + INTERVAL 12 MONTH TO VOLUME 'slow_but_cheap'; +``` + +### 查询优化 {#query-optimization} + +分区可以帮助查询性能,但这在很大程度上依赖于访问模式。如果查询只针对少数几个分区(理想情况下是一个),性能可能会有所提高。通常只有在分区键不在主键中,并且你按它进行过滤时,这才是有用的,如以下示例查询所示。 + +```sql runnable +SELECT MAX(price) AS highest_price +FROM uk.uk_price_paid_simple_partitioned +WHERE date >= '2020-12-01' + AND date <= '2020-12-31' + AND town = 'LONDON'; +``` + +该查询在我们上面的示例表上运行,并 [计算](https://sql.clickhouse.com/?query=U0VMRUNUIE1BWChwcmljZSkgQVMgaGlnaGVzdF9wcmljZQpGUk9NIHVrLnVrX3ByaWNlX3BhaWRfc2ltcGxlX3BhcnRpdGlvbmVkCldIRVJFIGRhdGUgPj0gJzIwMjAtMTItMDEnCiAgQU5EIGRhdGUgPD0gJzIwMjAtMTItMzEnCiAgQU5EIHRvd24gPSAnTE9ORE9OJzs&run_query=true&tab=results) 2020 年 12 月在伦敦售出的所有房产的最高价格,通过在同时使用表的分区键中的列(`date`)和表的主键中使用的列(`town`)进行过滤(并且 `date` 不是主键的一部分)。 + +ClickHouse 通过应用一系列修剪技术来处理该查询,以避免评估不相关的数据: + + + +
+ +① **分区修剪**:使用 [MinMax 索引](/partitions#what-are-table-partitions-in-clickhouse) 来忽略逻辑上无法与查询的列过滤条件相匹配的整个分区(部分集合)。 + +② **颗粒修剪**:在第 ① 步骤后的剩余数据部分中,使用它们的 [主索引](/guides/best-practices/sparse-primary-indexes) 来忽略所有逻辑上无法与查询的主键列过滤条件相匹配的 [颗粒](/guides/best-practices/sparse-primary-indexes#data-is-organized-into-granules-for-parallel-data-processing)(行块)。 + +我们可以通过 [检查](https://sql.clickhouse.com/?query=RVhQTEFJTiBpbmRleGVzID0gMQpTRUxFQ1QgTUFYKHByaWNlKSBBUyBoaWdoZXN0X3ByaWNlCkZST00gdWsudWtfcHJpY2VfcGFpZF9zaW1wbGVfcGFydGl0aW9uZWQKV0hFUkUgZGF0ZSA-PSAnMjAyMC0xMi0wMScKICBBTkQgZGF0ZSA8PSAnMjAyMC0xMi0zMScKICBBTkQgdG93biA9ICdMT05ET04nOw&run_query=true&tab=results) 我们上面的示例查询的物理查询执行计划,通过 [EXPLAIN](/sql-reference/statements/explain) 子句: + +```sql style="fontSize:13px" +EXPLAIN indexes = 1 +SELECT MAX(price) AS highest_price +FROM uk.uk_price_paid_simple_partitioned +WHERE date >= '2020-12-01' + AND date <= '2020-12-31' + AND town = 'LONDON'; + + ┌─explain──────────────────────────────────────────────────────────────────────────────────────────────────────┐ + 1. │ Expression ((Project names + Projection)) │ + 2. │ Aggregating │ + 3. │ Expression (Before GROUP BY) │ + 4. │ Expression │ + 5. │ ReadFromMergeTree (uk.uk_price_paid_simple_partitioned) │ + 6. │ Indexes: │ + 7. │ MinMax │ + 8. │ Keys: │ + 9. │ date │ +10. │ Condition: and((date in (-Inf, 18627]), (date in [18597, +Inf))) │ +11. │ Parts: 1/436 │ +12. │ Granules: 11/3257 │ +13. │ Partition │ +14. │ Keys: │ +15. │ toStartOfMonth(date) │ +16. │ Condition: and((toStartOfMonth(date) in (-Inf, 18597]), (toStartOfMonth(date) in [18597, +Inf))) │ +17. │ Parts: 1/1 │ +18. │ Granules: 11/11 │ +19. │ PrimaryKey │ +20. │ Keys: │ +21. │ town │ +22. │ Condition: (town in ['LONDON', 'LONDON']) │ +23. │ Parts: 1/1 │ +24. │ Granules: 1/11 │ + └──────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ +``` + +上述输出显示: + +① 分区修剪:EXPLAIN 输出的第 7 到 18 行显示,ClickHouse 首先使用 `date` 字段的 [MinMax 索引](/partitions#what-are-table-partitions-in-clickhouse) 来识别 3257 个现有 [颗粒](/guides/best-practices/sparse-primary-indexes#data-is-organized-into-granules-for-parallel-data-processing) 中的 11 个(行块),这些颗粒存储在 436 个现有的活跃数据部分中,包含与查询的 `date` 过滤条件匹配的行。 + +② 颗粒修剪:EXPLAIN 输出的第 19 到 24 行指示,ClickHouse 然后使用步骤 ① 中标识的数据部分的 [主索引](/guides/best-practices/sparse-primary-indexes)(在 `town` 字段上创建)进一步减少颗粒的数量(包含可能也与查询的 `town` 过滤条件相匹配的行)从 11 个减少到 1 个。这也在我们上面为查询运行打印的 ClickHouse 客户端输出中反映出来: + +```response +... Elapsed: 0.006 sec. Processed 8.19 thousand rows, 57.34 KB (1.36 million rows/s., 9.49 MB/s.) +Peak memory usage: 2.73 MiB. +``` + +这意味着 ClickHouse 在 6 毫秒内扫描并处理了 1 个颗粒([8192](/operations/settings/merge-tree-settings#index_granularity) 行),以计算查询结果。 + +### 分区主要是一种数据管理功能 {#partitioning-is-primarily-a-data-management-feature} + +请注意,跨所有分区的查询通常比在非分区表上运行相同的查询要慢。 + +通过分区,数据通常在更多的数据部分之间分布,这通常会导致 ClickHouse 扫描和处理更大数量的数据。 + +我们可以通过同时在 [What are table parts](/parts) 示例表(未启用分区)和我们上述示例表(启用分区)上运行相同的查询来演示这一点。这两个表 [包含](https://sql.clickhouse.com/?query=U0VMRUNUCiAgICB0YWJsZSwKICAgIHN1bShyb3dzKSBBUyByb3dzCkZST00gc3lzdGVtLnBhcnRzCldIRVJFIChkYXRhYmFzZSA9ICd1aycpIEFORCAoYHRhYmxlYCBJTiBbJ3VrX3ByaWNlX3BhaWRfc2ltcGxlJywgJ3VrX3ByaWNlX3BhaWRfc2ltcGxlX3BhcnRpdGlvbmVkJ10pIEFORCBhY3RpdmUKR1JPVVAgQlkgdGFibGU7&run_query=true&tab=results) 相同的数据和行数: + +```sql runnable +SELECT + table, + sum(rows) AS rows +FROM system.parts +WHERE (database = 'uk') AND (table IN ['uk_price_paid_simple', 'uk_price_paid_simple_partitioned']) AND active +GROUP BY table; +``` + +但是,启用分区的表 [具有](https://sql.clickhouse.com/?query=U0VMRUNUCiAgICB0YWJsZSwKICAgIGNvdW50KCkgQVMgcGFydHMKRlJPTSBzeXN0ZW0ucGFydHMKV0hFUkUgKGRhdGFiYXNlID0gJ3VrJykgQU5EIChgdGFibGVgIElOICsndWtfcHJpY2VfcGFpZF9zaW1wbGUnLCAndWtfcHJpY2VfcGFpZF9zaW1wbGVfcGFydGl0aW9uZWQnXSkgQU5EIGFjdGl2ZQpHUk9VUCBCWSB0YWJsZTs&run_query=true&tab=results) 更多的活动 [数据部分](/parts),因为,如上所述,ClickHouse 只能 [合并](/parts) 属于分区内的数据部分,而不能跨分区合并: + +```sql runnable +SELECT + table, + count() AS parts +FROM system.parts +WHERE (database = 'uk') AND (table IN ['uk_price_paid_simple', 'uk_price_paid_simple_partitioned']) AND active +GROUP BY table; + +``` +如上文所示,分区表 `uk_price_paid_simple_partitioned` 有超过 600 个分区,因此有 600 306 个活跃数据部分。而我们的非分区表 `uk_price_paid_simple` 所有 [初始](/parts) 数据部分都可以通过后台合并合并为一个活跃部分。 + +当我们 [检查](https://sql.clickhouse.com/?query=RVhQTEFJTiBpbmRleGVzID0gMQpTRUxFQ1QgTUFYKHByaWNlKSBBUyBoaWdoZXN0X3ByaWNlCkZST00gdWsudWtfcHJpY2VfcGFpZF9zaW1wbGVfcGFydGl0aW9uZWQKV0hFUkUgdG93biA9ICdMT05ET04nOw&run_query=true&tab=results) 我们从上面示例查询的物理查询执行计划,使用 [EXPLAIN](/sql-reference/statements/explain) 子句,运行时没有分区过滤在分区表上,我们可以看到,在输出的第 19 和 20 行,ClickHouse 识别出 671 个现有的 [颗粒](/guides/best-practices/sparse-primary-indexes#data-is-organized-into-granules-for-parallel-data-processing)(行块),分散在 436 个现有的活跃数据部分中,这些部分可能包含与查询过滤条件匹配的行,因此将被查询引擎扫描和处理: + +```sql +EXPLAIN indexes = 1 +SELECT MAX(price) AS highest_price +FROM uk.uk_price_paid_simple_partitioned +WHERE town = 'LONDON'; + + ┌─explain─────────────────────────────────────────────────────────┐ + 1. │ Expression ((Project names + Projection)) │ + 2. │ Aggregating │ + 3. │ Expression (Before GROUP BY) │ + 4. │ Expression │ + 5. │ ReadFromMergeTree (uk.uk_price_paid_simple_partitioned) │ + 6. │ Indexes: │ + 7. │ MinMax │ + 8. │ Condition: true │ + 9. │ Parts: 436/436 │ +10. │ Granules: 3257/3257 │ +11. │ Partition │ +12. │ Condition: true │ +13. │ Parts: 436/436 │ +14. │ Granules: 3257/3257 │ +15. │ PrimaryKey │ +16. │ Keys: │ +17. │ town │ +18. │ Condition: (town in ['LONDON', 'LONDON']) │ +19. │ Parts: 431/436 │ +20. │ Granules: 671/3257 │ + └─────────────────────────────────────────────────────────────────┘ +``` + +运行在没有分区的表上的同一查询的物理查询执行计划 [显示](https://sql.clickhouse.com/?query=RVhQTEFJTiBpbmRleGVzID0gMQpTRUxFQ1QgTUFYKHByaWNlKSBBUyBoaWdoZXN0X3ByaWNlCkZST00gdWsudWtfcHJpY2VfcGFpZF9zaW1wbGUKV0hFUkUgdG93biA9ICdMT05ET04nOw&run_query=true&tab=results) 在输出的第 11 和 12 行,ClickHouse 识别出 241 个现有的行块,存在于表的单个活跃数据部分中,这些行块可能包含与查询过滤条件匹配的行: + +```sql +EXPLAIN indexes = 1 +SELECT MAX(price) AS highest_price +FROM uk.uk_price_paid_simple +WHERE town = 'LONDON'; + + ┌─explain───────────────────────────────────────────────┐ + 1. │ Expression ((Project names + Projection)) │ + 2. │ Aggregating │ + 3. │ Expression (Before GROUP BY) │ + 4. │ Expression │ + 5. │ ReadFromMergeTree (uk.uk_price_paid_simple) │ + 6. │ Indexes: │ + 7. │ PrimaryKey │ + 8. │ Keys: │ + 9. │ town │ +10. │ Condition: (town in ['LONDON', 'LONDON']) │ +11. │ Parts: 1/1 │ +12. │ Granules: 241/3083 │ + └───────────────────────────────────────────────────────┘ +``` + +对于 [在分区版本的表上运行](https://sql.clickhouse.com/?query=U0VMRUNUIE1BWChwcmljZSkgQVMgaGlnaGVzdF9wcmljZQpGUk9NIHVrLnVrX3ByaWNlX3BhaWRfc2ltcGxlX3BhcnRpdGlvbmVkCldIRVJFIHRvd24gPSAnTE9ORE9OJzs&run_query=true&tab=results) 查询,ClickHouse 在 90 毫秒内扫描和处理了 671 个行块(约 550 万行): + +```sql +SELECT MAX(price) AS highest_price +FROM uk.uk_price_paid_simple_partitioned +WHERE town = 'LONDON'; + +┌─highest_price─┐ +│ 594300000 │ -- 594.30 million +└───────────────┘ + +1 row in set. Elapsed: 0.090 sec. Processed 5.48 million rows, 27.95 MB (60.66 million rows/s., 309.51 MB/s.) +Peak memory usage: 163.44 MiB. +``` + +而对于 [在未分区表上运行](https://sql.clickhouse.com/?query=U0VMRUNUIE1BWChwcmljZSkgQVMgaGlnaGVzdF9wcmljZQpGUk9NIHVrLnVrX3ByaWNlX3BhaWRfc2ltcGxlCldIRVJFIHRvd24gPSAnTE9ORE9OJzs&run_query=true&tab=results) 查询,ClickHouse 在 12 毫秒内扫描和处理了 241 个块(约 200 万行): + +```sql +SELECT MAX(price) AS highest_price +FROM uk.uk_price_paid_simple +WHERE town = 'LONDON'; + +┌─highest_price─┐ +│ 594300000 │ -- 594.30 million +└───────────────┘ + +1 row in set. Elapsed: 0.012 sec. Processed 1.97 million rows, 9.87 MB (162.23 million rows/s., 811.17 MB/s.) +Peak memory usage: 62.02 MiB. +``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/partitions.mdx.hash b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/partitions.mdx.hash new file mode 100644 index 00000000000..b0fec93bda5 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/partitions.mdx.hash @@ -0,0 +1 @@ +d84d4bb5104b216a diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/parts.md b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/parts.md index cd8dffbef75..43c5fd6e4c8 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/parts.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/parts.md @@ -1,22 +1,23 @@ --- 'slug': '/parts' 'title': '表分区片段' -'description': '在 ClickHouse 中数据分区片段是什么' +'description': 'ClickHouse中的数据部分是什么' 'keywords': - 'part' +'doc_type': 'reference' --- import merges from '@site/static/images/managing-data/core-concepts/merges.png'; import part from '@site/static/images/managing-data/core-concepts/part.png'; import Image from '@theme/IdealImage'; -## ClickHouse中的表分片是什么? {#what-are-table-parts-in-clickhouse} +## 在 ClickHouse 中,表分区是什么? {#what-are-table-parts-in-clickhouse} -
+
-ClickHouse中每个表的数据在磁盘上以不可变的 `data parts` 集合组织,属于 [MergeTree 引擎家族](/engines/table-engines/mergetree-family)。 +ClickHouse [MergeTree 引擎系列](/engines/table-engines/mergetree-family) 中每个表的数据在磁盘上组织为不可变的 `data parts` 集合。 -为了说明这一点,我们使用 [这个](https://sql.clickhouse.com/?query=U0hPVyBDUkVBVEUgVEFCTEUgdWsudWtfcHJpY2VfcGFpZF9zaW1wbGU&run_query=true&tab=results) 表(改编自 [英国物业价格数据集](/getting-started/example-datasets/uk-price-paid)),该表跟踪英国出售房产的日期、城镇、街道和价格: +为了说明这一点,我们使用 [此](https://sql.clickhouse.com/?query=U0hPVyBDUkVBVEUgVEFCTEUgdWsudWtfcHJpY2VfcGFpZF9zaW1wbGU&run_query=true&tab=results) 表(改编自 [英国房产价格数据集](/getting-started/example-datasets/uk-price-paid)),跟踪在英国售出房产的日期、城镇、街道和价格: ```sql CREATE TABLE uk.uk_price_paid_simple @@ -32,39 +33,39 @@ ORDER BY (town, street); 您可以在我们的 ClickHouse SQL Playground 中 [查询此表](https://sql.clickhouse.com/?query=U0VMRUNUICogRlJPTSB1ay51a19wcmljZV9wYWlkX3NpbXBsZTs&run_query=true&tab=results)。 -每当一组行插入到表中时,就会创建一个数据部分。以下图示展现了这一过程: +当一组行插入到表中时,会创建一个数据分区。以下图示说明了这一点: - + -
+
-当 ClickHouse 服务器处理上面图中绘制的插入 4 行数据(例如,通过 [INSERT INTO 语句](/sql-reference/statements/insert-into))时,它执行几个步骤: +当 ClickHouse 服务器处理上面图中勾勒的 4 行示例插入(例如,通过 [INSERT INTO 语句](/sql-reference/statements/insert-into))时,它会执行几个步骤: -① **排序**:行按表的排序键 `(town, street)` 排序,并为排序后的行生成一个 [稀疏主索引](/guides/best-practices/sparse-primary-indexes)。 +① **排序**:行按表的 ^^sorting key^^ `(town, street)` 进行排序,并为排序后的行生成一个 [稀疏主索引](/guides/best-practices/sparse-primary-indexes)。 -② **拆分**:排序后的数据被拆分成列。 +② **拆分**:排序后的数据被拆分为列。 -③ **压缩**:每列被 [压缩](https://clickhouse.com/blog/optimize-clickhouse-codecs-compression-schema)。 +③ **压缩**:每一列被 [压缩](https://clickhouse.com/blog/optimize-clickhouse-codecs-compression-schema)。 -④ **写入磁盘**:压缩后的列以二进制列文件的形式保存在一个新的目录中,该目录表示插入的数据部分。稀疏主索引也会被压缩并存储在同一目录中。 +④ **写入磁盘**:压缩后的列作为二进制列文件保存在一个新目录中,该目录表示插入的数据分区。稀疏主索引也被压缩并存储在同一目录中。 -根据表的具体引擎,除了排序之外,可能还进行其他转换 [may](/operations/settings/settings)。 +根据表的具体引擎,排序期间还可能发生其他转换 [可能](/operations/settings/settings)。 -数据部分是自包含的,包括解释内容所需的所有元数据,而无需依赖中央目录。除了稀疏主索引外,部分还包含其他元数据,例如次级 [数据跳过索引](/optimize/skipping-indexes)、[列统计信息](https://clickhouse.com/blog/clickhouse-release-23-11#column-statistics-for-prewhere)、校验和、最小-最大索引(如果使用了 [分区](/partitions)),以及 [更多](https://github.com/ClickHouse/ClickHouse/blob/a065b11d591f22b5dd50cb6224fab2ca557b4989/src/Storages/MergeTree/MergeTreeData.h#L104)。 +数据 ^^parts^^ 是自包含的,包括解释其内容所需的所有元数据,无需中央目录。除了稀疏主索引,^^parts^^ 还包含其他元数据,例如次要 [数据跳过索引](/optimize/skipping-indexes)、[列统计信息](https://clickhouse.com/blog/clickhouse-release-23-11#column-statistics-for-prewhere)、校验和、最小-最大索引(如果使用了 [分区](/partitions))以及 [更多](https://github.com/ClickHouse/ClickHouse/blob/a065b11d591f22b5dd50cb6224fab2ca557b4989/src/Storages/MergeTree/MergeTreeData.h#L104)。 -## 部分合并 {#part-merges} +## 分区合并 {#part-merges} -为了管理每个表的部分数量,[后台合并](/merges) 任务会定期将较小的部分合并成较大的部分,直到它们达到 [可配置的](/operations/settings/merge-tree-settings#max_bytes_to_merge_at_max_space_in_pool) 压缩大小(通常约为 150 GB)。合并后的部分标记为非活动,并在经过 [可配置的](/operations/settings/merge-tree-settings#old_parts_lifetime) 时间间隔后被删除。随着时间的推移,这一过程创建了合并部分的层次结构,这就是为什么称之为 MergeTree 表: +为了管理每个表的 ^^parts^^ 数量,[后台合并](/merges) 任务会定期将较小的 ^^parts^^ 合并为较大的 ^^parts^^,直到它们达到可配置的 [压缩大小](/operations/settings/merge-tree-settings#max_bytes_to_merge_at_max_space_in_pool)(通常约为 150 GB)。合并后的 ^^parts^^ 被标记为非活动,并在 [可配置](/operations/settings/merge-tree-settings#old_parts_lifetime) 时间间隔后被删除。随着时间的推移,该过程创建了一个合并的 ^^parts^^ 层次结构,这就是为什么它被称为 ^^MergeTree^^ 表: - + -
+
-为了最小化初始部分的数量以及合并的开销,建议数据库客户端 [encouraged](https://clickhouse.com/blog/asynchronous-data-inserts-in-clickhouse#data-needs-to-be-batched-for-optimal-performance) 批量插入元组,例如一次插入 20,000 行,或者使用 [异步插入模式](https://clickhouse.com/blog/asynchronous-data-inserts-in-clickhouse),在该模式下,ClickHouse 将来自多个插入的行缓冲到同一表中,只有在缓冲区大小超过可配置阈值或超时到期后,才创建一个新部分。 +为了最小化初始 ^^parts^^ 的数量和合并的开销,数据库客户端被 [鼓励](https://clickhouse.com/blog/asynchronous-data-inserts-in-clickhouse#data-needs-to-be-batched-for-optimal-performance) 要么批量插入元组,例如一次 20,000 行,要么使用 [异步插入模式](https://clickhouse.com/blog/asynchronous-data-inserts-in-clickhouse),在该模式下 ClickHouse 会将来自多个传入 INSERT 的行缓冲到同一表中,并仅在缓冲区大小超过可配置阈值或超时到期后创建新分区。 -## 监控表分片 {#monitoring-table-parts} +## 监控表分区 {#monitoring-table-parts} -您可以通过使用虚拟列 [_part](/engines/table-engines#table_engines-virtual_columns) 来 [查询](https://sql.clickhouse.com/?query=U0VMRUNUIF9wYXJ0CkZST00gdWsudWtfcHJpY2VfcGFpZF9zaW1wbGUKR1JPVVAgQlkgX3BhcnQKT1JERVIgQlkgX3BhcnQgQVNDOw&run_query=true&tab=results) 我们示例表的所有当前活动部分列表: +您可以通过使用 [虚拟列](/engines/table-engines#table_engines-virtual_columns) `_part` 来 [查询](https://sql.clickhouse.com/?query=U0VMRUNUIF9wYXJ0CkZST00gdWsudWtfcHJpY2VfcGFpZF9zaW1wbGUKR1JPVVAgQlkgX3BhcnQKT1JERVIgQlkgX3BhcnQgQVNDOw&run_query=true&tab=results) 我们示例表中所有当前存在的活动 ^^parts^^ 列表: ```sql SELECT _part @@ -79,9 +80,9 @@ ORDER BY _part ASC; 4. │ all_6_11_1 │ └─────────────┘ ``` -上面的查询检索了磁盘上目录的名称,每个目录代表表的一个活动数据部分。这些目录名称的组成部分具有特定含义,感兴趣的用户可以在 [这里](https://github.com/ClickHouse/ClickHouse/blob/f90551824bb90ade2d8a1d8edd7b0a3c0a459617/src/Storages/MergeTree/MergeTreeData.h#L130) 查阅相关文档以进一步探索。 +上述查询检索磁盘上的目录名称,每个目录代表表的一个活动数据分区。这些目录名称的组件具有特定含义,对于有兴趣进一步探索的人可以在 [这里](https://github.com/ClickHouse/ClickHouse/blob/f90551824bb90ade2d8a1d8edd7b0a3c0a459617/src/Storages/MergeTree/MergeTreeData.h#L130) 找到相关文档。 -另外,ClickHouse 跟踪所有表的所有部分的信息,可以在 [system.parts](/operations/system-tables/parts) 系统表中找到,以下查询 [返回](https://sql.clickhouse.com/?query=U0VMRUNUCiAgICBuYW1lLAogICAgbGV2ZWwsCiAgICByb3dzCkZST00gc3lzdGVtLnBhcnRzCldIRVJFIChkYXRhYmFzZSA9ICd1aycpIEFORCAoYHRhYmxlYCA9ICd1a19wcmljZV9wYWlkX3NpbXBsZScpIEFORCBhY3RpdmUKT1JERVIgQlkgbmFtZSBBU0M7&run_query=true&tab=results) 我们示例表的所有当前活动部分、它们的合并级别以及存储在这些部分中的行数: +或者,ClickHouse 会在 [system.parts](/operations/system-tables/parts) 系统表中跟踪所有表的所有 ^^parts^^ 的信息,以下查询 [返回](https://sql.clickhouse.com/?query=U0VMRUNUCiAgICBuYW1lLAogICAgbGV2ZWwsCiAgICByb3dzCkZST00gc3lzdGVtLnBhcnRzCldIRVJFIChkYXRhYmFzZSA9ICd1aycpIEFORCAoYHRhYmxlYCA9ICd1a19wcmljZV9wYWlkX3NpbXBsZScpIEFORCBhY3RpdmUKT1JERVIgQlkgbmFtZSBBU0M7&run_query=true&tab=results) 我们示例表中所有当前活动 ^^parts^^ 的列表、它们的合并级别以及存储在这些 ^^parts^^ 中的行数: ```sql SELECT @@ -92,7 +93,6 @@ FROM system.parts WHERE (database = 'uk') AND (`table` = 'uk_price_paid_simple') AND active ORDER BY name ASC; - ┌─name────────┬─level─┬────rows─┐ 1. │ all_0_5_1 │ 1 │ 6368414 │ 2. │ all_12_17_1 │ 1 │ 6442494 │ @@ -100,4 +100,4 @@ ORDER BY name ASC; 4. │ all_6_11_1 │ 1 │ 6459763 │ └─────────────┴───────┴─────────┘ ``` -每次对部分进行额外合并时,合并级别增加一。级别为 0 表示这是一个尚未合并的新部分。 +每次在分区上进行额外合并时,合并级别递增 1。级别 0 表示这是一个尚未合并的新分区。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/parts.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/parts.md.hash index 61823895410..d20ef14b0bf 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/parts.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/parts.md.hash @@ -1 +1 @@ -ce126a79efdd3d0d +a08bc4ea684ddba2 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/primary-indexes.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/primary-indexes.md.hash deleted file mode 100644 index 7d58f91f86f..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/primary-indexes.md.hash +++ /dev/null @@ -1 +0,0 @@ -5414067e02f51b59 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/primary-indexes.md b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/primary-indexes.mdx similarity index 56% rename from i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/primary-indexes.md rename to i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/primary-indexes.mdx index ac5d5a82a33..97ea0ad3859 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/primary-indexes.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/primary-indexes.mdx @@ -1,11 +1,12 @@ --- 'slug': '/primary-indexes' 'title': '主键索引' -'description': 'ClickHouse中的稀疏主键索引是如何工作的' +'description': '在 ClickHouse 中,稀疏主键索引是如何工作的' 'keywords': - 'sparse primary index' - 'primary index' - 'index' +'doc_type': 'guide' --- import visual01 from '@site/static/images/managing-data/core-concepts/primary-index-light_01.gif'; @@ -14,71 +15,67 @@ import visual03 from '@site/static/images/managing-data/core-concepts/primary-in import Image from '@theme/IdealImage'; :::tip 寻找高级索引细节? -此页面介绍了 ClickHouse 的稀疏主索引,它是如何构建的、如何工作的,以及它如何帮助加速查询。 +本页面介绍了 ClickHouse 的稀疏主索引,它是如何构建的,如何工作以及它如何加速查询。 有关高级索引策略和更深入的技术细节,请参见 [主索引深入探讨](/guides/best-practices/sparse-primary-indexes)。 ::: - -## ClickHouse 中稀疏主索引是如何工作的? {#how-does-the-sparse-primary-index-work-in-clickHouse} +## ClickHouse 中稀疏主索引如何工作? {#how-does-the-sparse-primary-index-work-in-clickHouse}
-ClickHouse 中的稀疏主索引用于有效识别 [粒度](https://clickhouse.com/docs/guides/best-practices/sparse-primary-indexes#data-is-organized-into-granules-for-parallel-data-processing)——可能包含与查询条件匹配的数据的行块——这些行块基于表的主键列。接下来的部分,我们将解释如何从这些列中的值构建此索引。 +ClickHouse 中的稀疏主索引帮助有效识别 [granules](https://clickhouse.com/docs/guides/best-practices/sparse-primary-indexes#data-is-organized-into-granules-for-parallel-data-processing)—可能包含匹配查询条件的数据行块,这些条件基于表的 ^^主键^^ 列。在下一节中,我们将解释如何从这些列中的值构建该索引。 -### 稀疏主索引的创建 {#sparse-primary-index-creation} +### 稀疏主索引创建 {#sparse-primary-index-creation} -为了说明稀疏主索引是如何构建的,我们将使用 [uk_price_paid_simple](https://clickhouse.com/docs/parts) 表并配合一些动画。 +为了说明稀疏主索引是如何构建的,我们使用 [uk_price_paid_simple](https://clickhouse.com/docs/parts) 表并配合一些动画演示。 -作为 [提醒](https://clickhouse.com/docs/parts),在我们的 ① 示例表中,主键是 (town, street),② 插入的数据 ③ 存储在磁盘上,按照主键列值排序并压缩,分别存储在每列的文件中: +作为一个 [提醒](https://clickhouse.com/docs/parts),在我们的 ① 示例表中,其 ^^主键^^ 为 (town, street),② 插入的数据是 ③ 存储在磁盘上,按 ^^主键^^ 列值排序并压缩,分别存储在每列的文件中:

-处理时,每列的数据被 ④ 逻辑地划分为粒度——每个粒度覆盖 8,192 行——这些是 ClickHouse 数据处理机制最小的单位。 +在处理过程中,每列的数据被 ④ 逻辑上划分为 granules——每个 granule 覆盖 8,192 行——这是 ClickHouse 的数据处理机制所使用的最小单位。 -这种粒度结构也是使主索引 **稀疏** 的原因:ClickHouse 不会为每一行索引,而是仅存储每个粒度中一行的主键值——特别是第一行的主键值。这会导致每个粒度只有一个索引条目: +这种 ^^granule^^ 结构也正是使主索引 **稀疏** 的原因:ClickHouse 仅从每个 ^^granule^^ 中存储一行的 ^^主键^^ 值——具体来说,就是第一行。这导致每个 ^^granule^^ 只有一个索引条目:

-由于其稀疏性,主索引小到足以完全装入内存,从而使得在主键列上的谓词查询能够快速过滤。接下来我们将展示它如何帮助加速这类查询。 - +由于其稀疏性,主索引足够小,可以完全放入内存中,从而使基于 ^^主键^^ 列的查询谓词的快速过滤成为可能。在下一节中,我们将展示它如何加速这些查询。 -### 主索引的使用 {#primary-index-usage} +### 主索引使用 {#primary-index-usage} -我们通过另一个动画简要说明稀疏主索引是如何用于查询加速的: +我们用另一个动画简要说明稀疏主索引如何用于查询加速:

-① 示例查询在两个主键列上包含一个谓词: `town = 'LONDON' AND street = 'OXFORD STREET'`。 +① 示例查询包含对两个 ^^主键^^ 列的谓词:`town = 'LONDON' AND street = 'OXFORD STREET'`。 ② 为了加速查询,ClickHouse 将表的主索引加载到内存中。 -③ 然后,它扫描索引条目以识别哪些粒度可能包含匹配谓词的行——换句话说,哪些粒度无法被跳过。 - -④ 这些可能相关的粒度随后被加载并在内存中与查询所需的其他列的相应粒度一起进行 [处理](/optimize/query-parallelism)。 +③ 然后扫描索引条目,以识别哪些 granules 可能包含匹配谓词的行——换句话说,哪些 granules 不能被跳过。 +④ 这些潜在相关的 granules 随后被加载并 [处理](/optimize/query-parallelism) 到内存中,以及查询所需的其他列的相应 granules。 ## 监控主索引 {#monitoring-primary-indexes} -表中的每个 [数据部分](/parts) 都有自己的主索引。我们可以使用 [mergeTreeIndex](/sql-reference/table-functions/mergeTreeIndex) 表函数检查这些索引的内容。 +表中的每个 [数据部分](/parts) 都有其自己的主索引。我们可以使用 [mergeTreeIndex](/sql-reference/table-functions/mergeTreeIndex) 表函数检查这些索引的内容。 以下查询列出了我们示例表中每个数据部分的主索引条目数量: ```sql SELECT part_name, - max(mark_number) as entries + max(mark_number) AS entries FROM mergeTreeIndex('uk', 'uk_price_paid_simple') GROUP BY part_name; ``` - ```txt ┌─part_name─┬─entries─┐ 1. │ all_2_2_0 │ 914 │ @@ -87,11 +84,11 @@ GROUP BY part_name; └───────────┴─────────┘ ``` -这个查询显示了当前数据部分的主索引中的前 10 个条目。请注意,这些部分在后台会持续 [合并](/merges) 为更大的部分: +此查询显示了当前一个数据 ^^parts^^ 的主索引的前 10 个条目。请注意,这些 ^^parts^^ 在后台持续被 [合并](/merges) 成更大的 ^^parts^^: ```sql SELECT - mark_number + 1 as entry, + mark_number + 1 AS entry, town, street FROM mergeTreeIndex('uk', 'uk_price_paid_simple') @@ -100,7 +97,6 @@ ORDER BY mark_number ASC LIMIT 10; ``` - ```txt ┌─entry─┬─town───────────┬─street───────────┐ 1. │ 1 │ ABBOTS LANGLEY │ ABBEY DRIVE │ @@ -116,7 +112,7 @@ LIMIT 10; └───────┴────────────────┴──────────────────┘ ``` -最后,我们使用 [EXPLAIN](/sql-reference/statements/explain) 子句查看所有数据部分的主索引如何被使用,以跳过无法包含匹配示例查询谓词的行的粒度。这些粒度会被排除在加载和处理之外: +最后,我们使用 [EXPLAIN](/sql-reference/statements/explain) 子句查看所有数据 ^^parts^^ 的主索引如何用于跳过无法包含匹配示例查询谓词的行的 granules。这些 granules 被排除在加载和处理之外: ```sql EXPLAIN indexes = 1 SELECT @@ -127,7 +123,6 @@ WHERE town = 'LONDON' AND street = 'OXFORD STREET'; ``` - ```txt ┌─explain────────────────────────────────────────────────────────────────────────────────────────────────────┐ 1. │ Expression ((Project names + Projection)) │ @@ -146,17 +141,15 @@ WHERE └────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ ``` +请注意,上面的 EXPLAIN 输出中的第 13 行显示,从所有数据 ^^parts^^ 中,只有 3 个 granules 被主索引分析选择用于处理,剩余的 granules 被完全跳过。 -注意,EXPLAIN 输出中的第 13 行显示,跨所有数据部分仅有 3 个粒度被主索引分析选择用于处理。其余的粒度完全被跳过。 - -我们还可以通过简单地运行查询观察到大多数数据被跳过: +我们还可以通过简单地运行查询来观察到大部分数据被跳过: ```sql SELECT max(price) FROM uk.uk_price_paid_simple WHERE (town = 'LONDON') AND (street = 'OXFORD STREET'); ``` - ```txt ┌─max(price)─┐ 1. │ 263100000 │ -- 263.10 million @@ -166,7 +159,7 @@ WHERE (town = 'LONDON') AND (street = 'OXFORD STREET'); Peak memory usage: 13.00 MiB. ``` -如上所示,在示例表中大约 3000 万行中,仅处理了大约 25,000 行: +如上所示,示例表中约 3000 万行中,仅处理了约 25,000 行: ```sql SELECT count() FROM uk.uk_price_paid_simple; ``` @@ -179,19 +172,18 @@ SELECT count() FROM uk.uk_price_paid_simple; ## 关键要点 {#key-takeaways} -* **稀疏主索引** 帮助 ClickHouse 跳过不必要的数据,通过识别哪些粒度可能包含与主键列的查询条件匹配的行。 +* **稀疏主索引** 帮助 ClickHouse 跳过不必要的数据,通过识别哪些 granules 可能包含匹配 ^^主键^^ 列查询条件的行来实现。 -* 每个索引仅存储 **每个粒度的第一行** 的主键值(一个粒度默认有 8,192 行),使其足够紧凑以放入内存中。 +* 每个索引仅存储 **每个 ^^granule^^ 的第一行** 的 ^^主键^^ 值(默认情况下一个 ^^granule^^ 有 8,192 行),使其紧凑到足以放入内存中。 -* **MergeTree 表** 中的 **每个数据部分** 都有 **自己的主索引**,在查询执行时独立使用。 +* 每个 ^^MergeTree^^ 表中的 **每个数据部分** 都有其 **自己的主索引**,在查询执行过程中独立使用。 -* 在查询期间,索引使 ClickHouse 能够 **跳过粒度**,减少 I/O 和内存使用,同时加速性能。 +* 在查询过程中,索引允许 ClickHouse **跳过 granules**,减少 I/O 和内存使用,同时加速性能。 * 您可以使用 `mergeTreeIndex` 表函数 **检查索引内容**,并使用 `EXPLAIN` 子句监控索引使用情况。 +## 在哪里找到更多信息 {#where-to-find-more-information} -## 哪里可以找到更多信息 {#where-to-find-more-information} - -要更深入了解 ClickHouse 中稀疏主索引的工作原理,包括它们与传统数据库索引的区别以及使用它们的最佳实践,请查看我们详细的索引 [深入探讨](/guides/best-practices/sparse-primary-indexes)。 +若要深入了解 ClickHouse 中稀疏主索引的工作原理,包括它们与传统数据库索引的不同以及最佳实践,请查看我们的详细索引 [深入探讨](/guides/best-practices/sparse-primary-indexes)。 -如果您对 ClickHouse 如何以高度并行的方式处理由主索引扫描选择的数据感兴趣,请查看查询并行性指南 [这里](/optimize/query-parallelism)。 +如果您对 ClickHouse 如何以高度并行的方式处理主索引扫描选择的数据感兴趣,请查看查询并行性指南 [在这里](/optimize/query-parallelism)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/primary-indexes.mdx.hash b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/primary-indexes.mdx.hash new file mode 100644 index 00000000000..f207cc50a34 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/primary-indexes.mdx.hash @@ -0,0 +1 @@ +6e27074a5cb11f8b diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/shards.md b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/shards.md deleted file mode 100644 index 73e9301b338..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/shards.md +++ /dev/null @@ -1,119 +0,0 @@ ---- -'slug': '/shards' -'title': '表分片和副本' -'description': '在 ClickHouse 中,表分片和副本是什么' -'keywords': -- 'shard' -- 'shards' -- 'sharding' -- 'replica' -- 'replicas' ---- - -import image_01 from '@site/static/images/managing-data/core-concepts/shards_01.png' -import image_02 from '@site/static/images/managing-data/core-concepts/shards_02.png' -import image_03 from '@site/static/images/managing-data/core-concepts/shards_03.png' -import image_04 from '@site/static/images/managing-data/core-concepts/shards_04.png' -import image_05 from '@site/static/images/managing-data/core-concepts/shards_replicas_01.png' -import Image from '@theme/IdealImage'; - -
-:::note -此主题不适用于 ClickHouse Cloud,其中 [Parallel Replicas](/docs/deployment-guides/parallel-replicas) 像传统的无共享 ClickHouse 集群中的多个分片一样工作,而对象存储则 [取代](https://clickhouse.com/blog/clickhouse-cloud-boosts-performance-with-sharedmergetree-and-lightweight-updates#shared-object-storage-for-data-availability) 副本,确保高可用性和容错性。 -::: - -## ClickHouse 中的表分片是什么? {#what-are-table-shards-in-clickhouse} - -在传统的 [shared-nothing](https://en.wikipedia.org/wiki/Shared-nothing_architecture) ClickHouse 集群中,当 ① 数据量太大而无法在单台服务器上处理,或 ② 单台服务器处理数据的速度太慢时,会使用分片。在下图中,显示了第 ① 种情况,其中 [uk_price_paid_simple](/parts) 表超出了单台机器的容量: - - - -
- -在这种情况下,数据可以以表分片的形式分散在多个 ClickHouse 服务器上: - - - -
- -每个分片保存数据的子集,并作为常规的 ClickHouse 表独立查询。然而,查询将仅处理该子集,这可能是根据数据分布而合适的用例。通常,一个 [distributed table](/docs/engines/table-engines/special/distributed)(通常按服务器)提供了完整数据集的统一视图。它并不存储数据,而是将 **SELECT** 查询转发到所有分片,组装结果,并将 **INSERTS** 定向到各分片,以均匀分布数据。 - -## 分布式表创建 {#distributed-table-creation} - -为了说明 **SELECT** 查询转发和 **INSERT** 路由,我们考虑在两台 ClickHouse 服务器上跨两个分片拆分的 [What are table parts](/parts) 示例表。首先,我们展示创建相应 **Distributed table** 的 DDL 语句: - - -```sql -CREATE TABLE uk.uk_price_paid_simple_dist ON CLUSTER test_cluster -( - date Date, - town LowCardinality(String), - street LowCardinality(String), - price UInt32 -) -ENGINE = Distributed('test_cluster', 'uk', 'uk_price_paid_simple', rand()) -``` - -`ON CLUSTER` 子句使 DDL 语句成为一个 [distributed DDL statement](/docs/sql-reference/distributed-ddl),指示 ClickHouse 在 `test_cluster` [集群定义](/docs/architecture/horizontal-scaling#replication-and-sharding-configuration) 中列出的所有服务器上创建表。分布式 DDL 需要在 [集群架构](/docs/architecture/horizontal-scaling#architecture-diagram) 中添加一个 [Keeper](https://clickhouse.com/clickhouse/keeper) 组件。 - -对于 [distributed engine parameters](/docs/engines/table-engines/special/distributed#distributed-parameters),我们指定集群名称 (`test_cluster`)、分片目标表的数据库名称 (`uk`)、分片目标表的名称 (`uk_price_paid_simple`),以及 **分片键** 用于 INSERT 路由。在这个例子中,我们使用 [rand](/sql-reference/functions/random-functions#rand) 函数随机分配行到分片。然而,任何表达式—甚至复杂的表达式—都可以用作分片键,具体取决于用例。下一部分阐明了 INSERT 路由的工作原理。 - -## INSERT 路由 {#insert-routing} - -下面的图示说明了 ClickHouse 中向分布式表进行 INSERT 的处理方式: - - - -
- -① 针对分布式表的 INSERT(带有单行)被发送到托管该表的 ClickHouse 服务器,可以是直接发送或通过负载均衡器。 - -② 针对 INSERT 的每一行(在我们的例子中只有一行),ClickHouse 评估分片键(此处为 rand()),将结果对分片服务器的数量取模,并将其用作目标服务器 ID(ID 从 0 开始并递增)。然后,该行被转发并 ③ 插入到相应服务器的表分片中。 - -下一部分解释 SELECT 转发的工作原理。 - -## SELECT 转发 {#select-forwarding} - -该图显示了 ClickHouse 中使用分布式表处理 SELECT 查询的方式: - - - -
- -① 针对分布式表的 SELECT 聚合查询被发送到相应的 ClickHouse 服务器,可以是直接发送或通过负载均衡器。 - -② 分布式表将查询转发给所有托管目标表分片的服务器,其中每个 ClickHouse 服务器并行计算本地聚合结果。 - -然后,托管最初目标分布式表的 ClickHouse 服务器 ③ 收集所有本地结果, ④ 将其合并为最终的全局结果,并 ⑤ 将其返回给查询发起者。 - -## ClickHouse 中的表副本是什么? {#what-are-table-replicas-in-clickhouse} - -ClickHouse 中的复制确保 **数据完整性** 和 **故障切换**,通过在多个服务器上维护 **分片数据的副本**。由于硬件故障是不可避免的,复制通过确保每个分片有多个副本来防止数据丢失。写入可以直接或通过 [distributed table](#distributed-table-creation) 定向到任何副本,该表为操作选择一个副本。更改会自动传播到其他副本。在故障或维护情况下,数据在其他副本上仍然可用,一旦故障主机恢复,它会自动同步以保持最新。 - -请注意,复制需要在 [集群架构](/docs/architecture/horizontal-scaling#architecture-diagram) 中添加 [Keeper](https://clickhouse.com/clickhouse/keeper) 组件。 - -以下图示说明了一个由六个服务器组成的 ClickHouse 集群,其中之前介绍的两个表分片 `Shard-1` 和 `Shard-2` 各有三个副本。查询被发送到此集群: - - - -
- -查询处理的工作原理类似于没有副本的设置,只有来自每个分片的一个副本执行查询。 - -> 副本不仅确保数据完整性和故障切换,还通过允许多个查询在不同副本上并行运行来提高查询处理吞吐量。 - -① 针对分布式表的查询被发送到相应的 ClickHouse 服务器,可以是直接发送或通过负载均衡器。 - -② 分布式表将查询转发给每个分片的一个副本,其中每个托管所选副本的 ClickHouse 服务器并行计算本地查询结果。 - -剩余的处理与没有副本的设置 [相同](#select-forwarding),并未在上面的图中显示。托管最初目标分布式表的 ClickHouse 服务器收集所有本地结果,将其合并为最终的全局结果,并将其返回给查询发送者。 - -请注意,ClickHouse 允许为 ② 配置查询转发策略。默认情况下—与上面的图示相反—分布式表如果可用,将优先选择本地副本,但可以使用其他负载均衡 [策略](/docs/operations/settings/settings#load_balancing)。 - -## 哪里可以找到更多信息 {#where-to-find-more-information} - -有关表分片和副本的更多详细信息,请查阅我们的 [deployment and scaling guide](/docs/architecture/horizontal-scaling)。 - -我们还强烈推荐这段教程视频,深入探讨 ClickHouse 的分片和副本: - - diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/shards.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/shards.md.hash deleted file mode 100644 index 0591633b8e0..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/shards.md.hash +++ /dev/null @@ -1 +0,0 @@ -f51723a733dda5af diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/shards.mdx b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/shards.mdx new file mode 100644 index 00000000000..81c5f785d14 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/shards.mdx @@ -0,0 +1,119 @@ +--- +'slug': '/shards' +'title': '表分片和副本' +'description': '在 ClickHouse 中,表分片和副本是什么' +'keywords': +- 'shard' +- 'shards' +- 'sharding' +- 'replica' +- 'replicas' +'doc_type': 'guide' +--- + +import image_01 from '@site/static/images/managing-data/core-concepts/shards_01.png' +import image_02 from '@site/static/images/managing-data/core-concepts/shards_02.png' +import image_03 from '@site/static/images/managing-data/core-concepts/shards_03.png' +import image_04 from '@site/static/images/managing-data/core-concepts/shards_04.png' +import image_05 from '@site/static/images/managing-data/core-concepts/shards_replicas_01.png' +import Image from '@theme/IdealImage'; + +
+:::note +此主题不适用于 ClickHouse Cloud,在这里,[Parallel Replicas](/docs/deployment-guides/parallel-replicas) 类似于传统无共享 ClickHouse 集群中的多个分片,而对象存储则[替代](https://clickhouse.com/blog/clickhouse-cloud-boosts-performance-with-sharedmergetree-and-lightweight-updates#shared-object-storage-for-data-availability) 副本,以确保高可用性和容错性。 +::: + +## ClickHouse 中的表分片是什么? {#what-are-table-shards-in-clickhouse} + +在传统的 [shared-nothing](https://en.wikipedia.org/wiki/Shared-nothing_architecture) ClickHouse 集群中,当 ① 数据对于单个服务器来说过大或 ② 单个服务器处理数据过慢时,会使用分片。下图展示了案例 ①,`[uk_price_paid_simple](/parts)` 表的数据超出了单台机器的容量: + + + +
+ +在这种情况下,数据可以以表分片的形式分布在多个 ClickHouse 服务器上: + + + +
+ +每个 ^^shard^^ 保留数据的一个子集,并作为一个常规的 ClickHouse 表独立查询。然而,查询只会处理该子集,这可能取决于数据分布的有效用例。通常,一个 [distributed table](/docs/engines/table-engines/special/distributed)(通常按服务器)提供对整个数据集的统一视图。它本身不存储数据,而是将 **SELECT** 查询转发给所有分片,汇总结果并将 **INSERT** 路由,以便均匀分配数据。 + +## 分布式表创建 {#distributed-table-creation} + +为了说明 **SELECT** 查询转发和 **INSERT** 路由,我们考虑在两个 ClickHouse 服务器上分拆的 [What are table parts](/parts) 示例表。首先,我们展示创建相应的 **^^Distributed table^^** 的 DDL 语句: + +```sql +CREATE TABLE uk.uk_price_paid_simple_dist ON CLUSTER test_cluster +( + date Date, + town LowCardinality(String), + street LowCardinality(String), + price UInt32 +) +ENGINE = Distributed('test_cluster', 'uk', 'uk_price_paid_simple', rand()) +``` + +`ON CLUSTER` 子句使 DDL 语句成为 [distributed DDL statement](/docs/sql-reference/distributed-ddl),指示 ClickHouse 在 `test_cluster` [集群定义](/architecture/replication/#configure-clickhouse-servers) 列出的所有服务器上创建表。分布式 DDL 需要 [Keeper](https://clickhouse.com/clickhouse/keeper) 组件在 [集群架构](/architecture/horizontal-scaling) 中。 + +对于 [distributed engine parameters](/docs/engines/table-engines/special/distributed#distributed-parameters),我们指定 ^^cluster^^ 名称(`test_cluster`)、目标分片表的数据库名称(`uk`)、目标分片表的名称(`uk_price_paid_simple`)和 **sharding key** 用于 INSERT 路由。在这个示例中,我们使用 [rand](/sql-reference/functions/random-functions#rand) 函数随机分配行到分片。然而,任何表达式——甚至复杂表达式——都可以用作分片键,这取决于用例。下一节将说明 INSERT 路由的工作原理。 + +## INSERT 路由 {#insert-routing} + +下图展示了在 ClickHouse 中插入 ^^distributed table^^ 如何处理: + + + +
+ +① 目标 ^^distributed table^^ 的 INSERT(单行)被发送到托管该表的 ClickHouse 服务器,可以直接发送或通过负载均衡器。 + +② 对于 INSERT 中的每一行(在我们的示例中只有一行),ClickHouse 评估分片键(这里是 rand()),并将结果对 ^^shard^^ 服务器的数量取模,并以此作为目标服务器 ID(ID 从 0 开始并增加 1)。然后,该行被转发并 ③ 插入到相应服务器的表 ^^shard^^ 中。 + +下一节将解释 SELECT 转发的工作原理。 + +## SELECT 转发 {#select-forwarding} + +下图展示了如何在 ClickHouse 中使用 ^^distributed table^^ 处理 SELECT 查询: + + + +
+ +① 针对 ^^distributed table^^ 的 SELECT 聚合查询被发送到相应的 ClickHouse 服务器,可以直接发送或通过负载均衡器。 + +② ^^Distributed table^^ 将查询转发给所有托管目标表分片的服务器,每个 ClickHouse 服务器并行计算其本地聚合结果。 + +然后,托管最初目标的 ^^distributed table^^ 的 ClickHouse 服务器 ③ 收集所有本地结果, ④ 将它们合并为最终的全局结果,并 ⑤ 返回给查询发送方。 + +## ClickHouse 中的表副本是什么? {#what-are-table-replicas-in-clickhouse} + +ClickHouse 中的复制确保 **数据完整性** 和 **故障转移**,通过在多台服务器上维护 **^^shard^^ 数据的副本**。由于硬件故障是不可避免的,复制通过确保每个 ^^shard^^ 有多个副本来防止数据丢失。写入可以直接或通过 [distributed table](#distributed-table-creation) 定向到任何 ^^replica^^,该表选择用于该操作的 ^^replica^^。更改会自动传播到其他副本。遇到故障或维护时,数据仍然可以在其他副本上访问,一旦故障主机恢复,它会自动同步以保持更新。 + +请注意,复制在 [集群架构](/architecture/horizontal-scaling) 中需要一个 [Keeper](https://clickhouse.com/clickhouse/keeper) 组件。 + +下图展示了一个包含六台服务器的 ClickHouse ^^cluster^^,之前介绍的两个表分片 `Shard-1` 和 `Shard-2` 每个都有三个副本。查询被发送到该 ^^cluster^^: + + + +
+ +查询处理的工作方式与没有副本的设置相似,只有每个 ^^shard^^ 的单个 ^^replica^^ 执行查询。 + +> 副本不仅确保数据完整性和故障转移,还通过允许多个查询在不同副本上并行运行来提高查询处理吞吐量。 + +① 目标 ^^distributed table^^ 的查询被发送到相应的 ClickHouse 服务器,可以直接发送或通过负载均衡器。 + +② ^^Distributed table^^ 将查询转发给每个 ^^shard^^ 的一个 ^^replica^^,每个托管所选 ^^replica^^ 的 ClickHouse 服务器并行计算其本地查询结果。 + +其余部分的工作与没有副本的设置 [相同](#select-forwarding),并在上图中未显示。托管最初目标的 ^^distributed table^^ 的 ClickHouse 服务器收集所有本地结果,将它们合并为最终的全局结果,并将结果返回给查询发送方。 + +请注意,ClickHouse 允许为 ② 配置查询转发策略。默认情况下——与上图不同——如果可用,^^distributed table^^ [更倾向于](/docs/operations/settings/settings#prefer_localhost_replica) 本地 ^^replica^^,但可以使用其他负载均衡的 [策略](/docs/operations/settings/settings#load_balancing)。 + +## 哪里可以找到更多信息 {#where-to-find-more-information} + +有关表分片和副本的更多细节,除了这个高层次的介绍,请查看我们的 [部署和扩展指南](/docs/architecture/horizontal-scaling)。 + +我们还强烈推荐这个教程视频,以深入了解 ClickHouse 的分片和副本: + + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/shards.mdx.hash b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/shards.mdx.hash new file mode 100644 index 00000000000..49b845ad028 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/core-concepts/shards.mdx.hash @@ -0,0 +1 @@ +35957103ed149f22 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/deleting-data/delete_mutations.md b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/deleting-data/delete_mutations.md deleted file mode 100644 index c3239c8fa3e..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/deleting-data/delete_mutations.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -'slug': '/managing-data/delete_mutations' -'sidebar_label': 'Delete Mutations' -'title': '删除突变' -'hide_title': false -'description': '页面描述删除突变 - ALTER 查询通过删除操作来操控表数据' ---- - -import DeleteMutations from '@site/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/delete.md'; - -Delete mutations refers to `ALTER` 查询,通过删除操作来操纵表数据。最显著的查询是 `ALTER TABLE DELETE` 等。执行此类查询会生成数据片段的新变异版本。这意味着这些语句会触发对所有在变异之前插入的数据的整个数据片段的重写,这将导致大量的写请求。 - -:::info -对于删除操作,您可以通过使用专用的表引擎,例如 [ReplacingMergeTree](/guides/replacing-merge-tree) 或 [CollapsingMergeTree](/engines/table-engines/mergetree-family/collapsingmergetree),来避免这些大量的写请求,而不是使用默认的 MergeTree 表引擎。 -::: - - diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/deleting-data/delete_mutations.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/deleting-data/delete_mutations.md.hash deleted file mode 100644 index bc93f5ec859..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/deleting-data/delete_mutations.md.hash +++ /dev/null @@ -1 +0,0 @@ -0e247327bfc3c3a9 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/deleting-data/delete_mutations.mdx b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/deleting-data/delete_mutations.mdx new file mode 100644 index 00000000000..2fc61631318 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/deleting-data/delete_mutations.mdx @@ -0,0 +1,18 @@ +--- +'slug': '/managing-data/delete_mutations' +'sidebar_label': '删除变更' +'title': '删除变更' +'hide_title': false +'description': '页面描述删除变更 - ALTER 查询通过删除操作操纵表数据' +'doc_type': 'reference' +--- + +import DeleteMutations from '@site/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/delete.md'; + +Delete mutations refers to `ALTER` 查询,旨在通过删除操作来操纵表数据。最显著的例子是 `ALTER TABLE DELETE` 等查询。执行这些查询将生成数据部分的新变异版本。这意味着,诸如此类的语句会引发对所有在变异之前插入的数据的整个数据部分进行重写,这将转化为大量的写请求。 + +:::info +对于删除操作,您可以通过使用专用的表引擎,如 [ReplacingMergeTree](/guides/replacing-merge-tree) 或 [CollapsingMergeTree](/engines/table-engines/mergetree-family/collapsingmergetree),来避免产生大量的写请求,而不是使用默认的 MergeTree 表引擎。 +::: + + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/deleting-data/delete_mutations.mdx.hash b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/deleting-data/delete_mutations.mdx.hash new file mode 100644 index 00000000000..0dc11a9c0a5 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/deleting-data/delete_mutations.mdx.hash @@ -0,0 +1 @@ +e3e2ac2b9ea268cb diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/deleting-data/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/deleting-data/index.md index ab7d97b6362..dd86e35c34f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/deleting-data/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/deleting-data/index.md @@ -7,14 +7,15 @@ - 'truncate' - 'drop' - 'lightweight delete' +'doc_type': 'guide' --- 在本节文档中,我们将探讨如何在 ClickHouse 中删除数据。 -| 页面 | 描述 | -|-------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------| -| [概述](/deletes/overview) | 提供有关在 ClickHouse 中删除数据的各种方法的概述。 | -| [轻量级删除](/guides/developer/lightweight-delete) | 了解如何使用轻量级删除来删除数据。 | +| 页面 | 描述 | +|-------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------| +| [概述](./overview) | 提供了有关在 ClickHouse 中删除数据的各种方法的概述。 | +| [轻量级删除](/guides/developer/lightweight-delete) | 了解如何使用轻量级删除来删除数据。 | | [删除突变](/managing-data/delete_mutations) | 了解删除突变。 | -| [截断表](/managing-data/truncate) | 了解如何使用截断,允许从表或数据库中删除数据,同时保持其存在性。 | -| [删除分区](/managing-data/drop_partition) | 了解在 ClickHouse 中删除分区的相关内容。 | +| [截断表](../truncate) | 了解如何使用截断,这允许删除表或数据库中的数据,同时保留其存在性。 | +| [删除分区](../drop_partition) | 了解在 ClickHouse 中删除分区。 | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/deleting-data/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/deleting-data/index.md.hash index 1f22851894c..c2375f5c20e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/deleting-data/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/deleting-data/index.md.hash @@ -1 +1 @@ -dab8bb1f98c61306 +a24f45860144d404 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/deleting-data/overview.md b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/deleting-data/overview.md deleted file mode 100644 index e714efbda6c..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/deleting-data/overview.md +++ /dev/null @@ -1,75 +0,0 @@ ---- -'slug': '/deletes/overview' -'title': '删除概览' -'description': '如何在 ClickHouse 中删除数据' -'keywords': -- 'delete' -- 'truncate' -- 'drop' -- 'lightweight delete' ---- - -在 ClickHouse 中,有几种删除数据的方法,每种方法都有其自身的优点和性能特征。您应该根据您的数据模型和计划删除的数据量选择适当的方法。 - -| 方法 | 语法 | 何时使用 | -| --- | --- | --- | -| [轻量级删除](/guides/developer/lightweight-delete) | `DELETE FROM [table]` | 在删除少量数据时使用。行会立即从所有后续的 SELECT 查询中过滤掉,但最初只能在内部标记为已删除,而不会立即从磁盘中移除。 | -| [删除变更](/sql-reference/statements/alter/delete) | `ALTER TABLE [table] DELETE` | 当数据必须立即从磁盘中删除(例如出于合规性)时使用。对 SELECT 性能有负面影响。 | -| [截断表](/sql-reference/statements/truncate) | `TRUNCATE TABLE [db.table]` | 高效地移除表中的所有数据。 | -| [删除分区](/sql-reference/statements/alter/partition#drop-partitionpart) | `DROP PARTITION` | 高效地移除分区中的所有数据。 | - -以下是 ClickHouse 中删除数据的不同方式的概要: - -## 轻量级删除 {#lightweight-deletes} - -轻量级删除使行立即被标记为已删除,因此可以自动从所有后续的 `SELECT` 查询中过滤掉。这些已删除行的实际移除在自然合并周期中发生,因此产生的 I/O 较少。因此,在未指定的时间内,数据实际上可能并未从存储中删除,只是标记为已删除。如果需要确保数据被删除,请考虑上述变更命令。 - -```sql --- delete all data from 2018 with a lightweight delete. Not recommended. -DELETE FROM posts WHERE toYear(CreationDate) = 2018 -``` - -使用轻量级的 `DELETE` 语句删除大量数据也可能对 `SELECT` 查询性能产生负面影响。该命令也不兼容具有投影的表。 - -请注意,在操作中使用了变更来 [标记已删除的行](/sql-reference/statements/delete#how-lightweight-deletes-work-internally-in-clickhouse)(添加 `_row_exists` 列),因此会产生一些 I/O。 - -一般而言,如果可以容忍已删除数据在磁盘上的存在(例如在不合规的情况下),应优先选择轻量级删除。如果需要删除所有数据,则仍应避免这种方法。 - -有关 [轻量级删除](/guides/developer/lightweight-delete) 的更多信息。 - -## 删除变更 {#delete-mutations} - -删除变更可以通过 `ALTER TABLE ... DELETE` 命令发出,例如 - -```sql --- delete all data from 2018 with a mutation. Not recommended. -ALTER TABLE posts DELETE WHERE toYear(CreationDate) = 2018 -``` - -这些可以以同步方式(如果为非复制时默认为)或异步方式执行(由 [mutations_sync](/operations/settings/settings#mutations_sync) 设置确定)。这些操作非常 IO 密集,重写所有匹配 `WHERE` 表达式的部分。此过程没有原子性 - 部分在准备好时会被变更部分替换,开始执行的 `SELECT` 查询将看到已经变更的部分的数据以及尚未变更的部分的数据。用户可以通过 [systems.mutations](/operations/system-tables/mutations#monitoring-mutations) 表跟踪进度状态。这些是 I/O 密集型操作,应谨慎使用,因为它们会影响集群的 `SELECT` 性能。 - -有关 [删除变更](/sql-reference/statements/alter/delete) 的更多信息。 - -## 截断表 {#truncate-table} - -如果需要删除表中的所有数据,请使用如下所示的 `TRUNCATE TABLE` 命令。这是一个轻量级操作。 - -```sql -TRUNCATE TABLE posts -``` - -有关 [TRUNCATE TABLE](/sql-reference/statements/truncate) 的更多信息。 - -## 删除分区 {#drop-partition} - -如果您为数据指定了自定义分区键,可以高效地删除分区。避免高基数的分区。 - -```sql -ALTER TABLE posts (DROP PARTITION '2008') -``` - -有关 [DROP PARTITION](/sql-reference/statements/alter/partition) 的更多信息。 - -## 更多资源 {#more-resources} - -- [在 ClickHouse 中处理更新和删除](https://clickhouse.com/blog/handling-updates-and-deletes-in-clickhouse) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/deleting-data/overview.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/deleting-data/overview.md.hash deleted file mode 100644 index 899478655a9..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/deleting-data/overview.md.hash +++ /dev/null @@ -1 +0,0 @@ -66a3bed82e8b494e diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/deleting-data/overview.mdx b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/deleting-data/overview.mdx new file mode 100644 index 00000000000..ff9e5f40ea4 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/deleting-data/overview.mdx @@ -0,0 +1,76 @@ +--- +'slug': '/deletes/overview' +'title': '删除概述' +'description': '如何在 ClickHouse 中删除数据' +'keywords': +- 'delete' +- 'truncate' +- 'drop' +- 'lightweight delete' +'doc_type': 'guide' +--- + +在 ClickHouse 中,有几种方法可以删除数据,每种方法都有其自身的优点和性能特征。您应根据数据模型和您打算删除的数据量选择适当的方法。 + +| 方法 | 语法 | 何时使用 | +| --- | --- | --- | +| [轻量级删除](/guides/developer/lightweight-delete) | `DELETE FROM [table]` | 用于删除少量数据时。行会立即在后续的所有 SELECT 查询中被过滤掉,但最初仅内部标记为删除,并未从磁盘中移除。 | +| [删除突变](/sql-reference/statements/alter/delete) | `ALTER TABLE [table] DELETE` | 当数据必须立即从磁盘中删除时使用(例如,为了合规)。对 SELECT 性能有负面影响。 | +| [截断表](/sql-reference/statements/truncate) | `TRUNCATE TABLE [db.table]` | 高效地从表中移除所有数据。 | +| [删除分区](/sql-reference/statements/alter/partition#drop-partitionpart) | `DROP PARTITION` | 高效地从一个分区中移除所有数据。 | + +下面是 ClickHouse 中删除数据的不同方法的总结: + +## 轻量级删除 {#lightweight-deletes} + +轻量级删除使行被立即标记为已删除,从而在后续的所有 `SELECT` 查询中可以自动滤除这些行。这些被删除行的后续移除发生在自然合并周期内,因此减少了 I/O。因此,可能会在不确定的时间段内,数据实际上并未从存储中删除,仅被标记为已删除。如果您需要保证数据被删除,请考虑上述的突变命令。 + +```sql +-- delete all data from 2018 with a lightweight delete. Not recommended. +DELETE FROM posts WHERE toYear(CreationDate) = 2018 +``` + +使用轻量级 `DELETE` 语句删除大量数据也可能会对 `SELECT` 查询性能产生负面影响。该命令也不与具有投影的表兼容。 + +请注意,在操作中使用了突变来[标记已删除的行](/sql-reference/statements/delete#how-lightweight-deletes-work-internally-in-clickhouse)(添加一个 `_row_exists` 列),因此会产生一些 I/O。 + +一般来说,如果可以容忍被删除数据在磁盘上的存在(例如在非合规情况下),则应优先选择轻量级删除而不是突变。如果需要删除所有数据,则仍应避免此方法。 + +阅读更多关于 [轻量级删除](/guides/developer/lightweight-delete)。 + +## 删除突变 {#delete-mutations} + +可以通过 `ALTER TABLE ... DELETE` 命令发出删除突变,例如: + +```sql +-- delete all data from 2018 with a mutation. Not recommended. +ALTER TABLE posts DELETE WHERE toYear(CreationDate) = 2018 +``` + +这些可以同步执行(如果没有副本则默认如此)或异步执行(由 [mutations_sync](/operations/settings/settings#mutations_sync) 设置决定)。这些操作非常耗费 I/O,会重写与 `WHERE` 表达式匹配的所有分区片段。此过程没有原子性 - 部分在准备好时会被替换为突变部分,而在突变过程中开始执行的 `SELECT` 查询将看到已突变的部分数据以及尚未突变的部分数据。用户可以通过 [systems.mutations](/operations/system-tables/mutations#monitoring-mutations) 表跟踪进度状态。这些是 I/O 密集型操作,应谨慎使用,因为它们会影响集群的 `SELECT` 性能。 + +阅读更多关于 [删除突变](/sql-reference/statements/alter/delete)。 + +## 截断表 {#truncate-table} + +如果需要删除表中的所有数据,请使用下面的 `TRUNCATE TABLE` 命令。这是一个轻量级操作。 + +```sql +TRUNCATE TABLE posts +``` + +阅读更多关于 [TRUNCATE TABLE](/sql-reference/statements/truncate)。 + +## 删除分区 {#drop-partition} + +如果您为数据指定了自定义分区键,可以高效地删除分区。避免高基数分区。 + +```sql +ALTER TABLE posts (DROP PARTITION '2008') +``` + +阅读更多关于 [DROP PARTITION](/sql-reference/statements/alter/partition)。 + +## 更多资源 {#more-resources} + +- [处理 ClickHouse 中的更新和删除](https://clickhouse.com/blog/handling-updates-and-deletes-in-clickhouse) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/deleting-data/overview.mdx.hash b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/deleting-data/overview.mdx.hash new file mode 100644 index 00000000000..d8101ea6cd6 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/deleting-data/overview.mdx.hash @@ -0,0 +1 @@ +486003a7ee7f30f5 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/drop_partition.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/drop_partition.md.hash deleted file mode 100644 index 435e2feb0a6..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/drop_partition.md.hash +++ /dev/null @@ -1 +0,0 @@ -d74a385b61ea3804 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/drop_partition.md b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/drop_partition.mdx similarity index 57% rename from i18n/zh/docusaurus-plugin-content-docs/current/managing-data/drop_partition.md rename to i18n/zh/docusaurus-plugin-content-docs/current/managing-data/drop_partition.mdx index 77fc75a1b8b..652aedf5294 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/drop_partition.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/drop_partition.mdx @@ -3,14 +3,15 @@ 'sidebar_label': 'Drop Partition' 'title': '删除分区' 'hide_title': false -'description': '页面描述 drop partitions' +'description': '页面描述删除分区' +'doc_type': 'reference' --- ## 背景 {#background} -在通过 `PARTITION BY` 子句最初定义表时,可以指定分区。该子句可以包含任何列的 SQL 表达式,其结果将定义行发送到哪个分区。 +在通过 `PARTITION BY` 子句初始定义表时指定分区。此子句可以包含对任何列的 SQL 表达式,其结果将定义行发送到哪个分区。 -数据片段在磁盘上与每个分区逻辑上关联,并且可以单独查询。以下示例中,我们使用表达式 `toYear(CreationDate)` 按年对 `posts` 表进行分区。当行插入到 ClickHouse 时,将对每行评估该表达式,并在结果分区存在时将其路由到该分区(如果该行是某年的第一行,则该分区将被创建)。 +数据片段在逻辑上与磁盘上的每个分区相关联,可以单独查询。以下示例中,我们使用表达式 `toYear(CreationDate)` 按年对 `posts` 表进行分区。当行插入到 ClickHouse 中时,将针对每行评估此表达式,并在存在的情况下将其路由到结果分区(如果该行是某年的第一行,则将创建该分区)。 ```sql CREATE TABLE posts @@ -27,19 +28,19 @@ ORDER BY (PostTypeId, toDate(CreationDate), CreationDate) PARTITION BY toYear(CreationDate) ``` -阅读关于设置分区表达式的章节 [如何设置分区表达式](/sql-reference/statements/alter/partition/#how-to-set-partition-expression)。 +阅读关于设置分区表达式的部分 [如何设置分区表达式](/sql-reference/statements/alter/partition/#how-to-set-partition-expression)。 -在 ClickHouse 中,用户应主要将分区视为数据管理特性,而不是查询优化技术。通过基于键逻辑地分离数据,每个分区可以独立操作,例如删除。这允许用户在时间或 [过期数据/高效从集群中删除](/sql-reference/statements/alter/partition) 的情况下高效地在 [存储层级](/integrations/s3#storage-tiers) 之间移动分区及其子集。 +在 ClickHouse 中,用户应主要将分区视为数据管理功能,而不是查询优化技术。通过根据关键字逻辑地分离数据,每个分区都可以独立操作,例如删除。这使得用户可以在时间或 [过期数据/从集群有效删除](/sql-reference/statements/alter/partition) 之间有效地移动分区及其子集,进而在 [存储层](/integrations/s3#storage-tiers) 之间移动。 ## 删除分区 {#drop-partitions} -`ALTER TABLE ... DROP PARTITION` 提供了一种成本高效的方式来删除整个分区。 +`ALTER TABLE ... DROP PARTITION` 提供了一种具有成本效益的方式来删除整个分区。 ```sql ALTER TABLE table_name [ON CLUSTER cluster] DROP PARTITION|PART partition_expr ``` -此查询将该分区标记为非活动并完全删除数据,约需 10 分钟。该查询是复制的——它在所有副本上删除数据。 +此查询将分区标记为非活动状态并完全删除数据,约需 10 分钟。该查询是复制的 – 它在所有副本上删除数据。 在下面的示例中,我们通过删除相关分区来移除 2008 年的帖子。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/drop_partition.mdx.hash b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/drop_partition.mdx.hash new file mode 100644 index 00000000000..e5eb947e2ed --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/drop_partition.mdx.hash @@ -0,0 +1 @@ +ad59dc928c63dbb6 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/truncate.md b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/truncate.md index 8384da768b6..0fa107d74c3 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/truncate.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/truncate.md @@ -3,11 +3,12 @@ 'sidebar_label': '截断 TABLE' 'title': '截断 TABLE' 'hide_title': false -'description': '截断允许从一个 TABLE 或 DATABASE 中删除数据,同时保留它们的存在。' +'description': '截断允许从一个 TABLE 或 DATABASE 中移除数据,同时保持它们的存在。' +'doc_type': 'reference' --- import Truncate from '@site/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/truncate.md'; -Truncate 允许从表或数据库中移除数据,同时保留其存在。这是一个无法逆转的轻量级操作。 +Truncate 允许从表或数据库中删除数据,同时保持其存在。这是一个轻量级操作,无法撤销。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/truncate.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/truncate.md.hash index 903daf43682..9979affe8c1 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/truncate.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/truncate.md.hash @@ -1 +1 @@ -496219c29b755a09 +026b2a84a12d3db3 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/updating-data/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/updating-data/index.md index b248297b152..c9bfb5a3ec2 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/updating-data/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/updating-data/index.md @@ -5,13 +5,14 @@ 'keywords': - 'update' - 'updating data' +'doc_type': 'landing-page' --- 在本节文档中,您将学习如何更新您的数据。 -| 页面 | 描述 | -|---------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------| -| [概述](/updating-data/overview) | 提供 ClickHouse 和 OLTP 数据库之间更新数据的差异概述,以及在 ClickHouse 中可用的各种更新方法。 | -| [更新突变](/managing-data/update_mutations) | 学习如何使用更新突变进行更新。 | -| [轻量级更新](/guides/developer/lightweight-update) | 学习如何使用轻量级更新进行更新。 | -| [ReplacingMergeTree](/guides/replacing-merge-tree) | 学习如何使用 ReplacingMergeTree 进行更新。 | +| 页面 | 描述 | +|------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------| +| [概述](/updating-data/overview) | 提供 ClickHouse 和 OLTP 数据库在更新数据方面的差异概述,以及在 ClickHouse 中可用的各种方法。 | +| [更新变更](/managing-data/update_mutations) | 学习如何使用更新变更进行更新。 | +| [轻量级更新](/docs/sql-reference/statements/update) | 学习如何使用轻量级更新进行更新。 | +| [ReplacingMergeTree](/guides/replacing-merge-tree) | 学习如何使用 ReplacingMergeTree 进行更新。 | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/updating-data/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/updating-data/index.md.hash index 9ee0ff58e3d..47fa693ff5b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/updating-data/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/updating-data/index.md.hash @@ -1 +1 @@ -6526afa2c1915f40 +525e7ab757f470ea diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/updating-data/overview.md b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/updating-data/overview.md deleted file mode 100644 index 60b3be7ff4d..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/updating-data/overview.md +++ /dev/null @@ -1,126 +0,0 @@ ---- -'slug': '/updating-data/overview' -'title': '概述' -'description': '如何在 ClickHouse 中更新数据' -'keywords': -- 'update' -- 'updating data' ---- - -## 在 ClickHouse 和 OLTP 数据库中更新数据的差异 {#differences-between-updating-data-in-clickhouse-and-oltp-databases} - -在处理更新时,由于其底层设计哲学和目标用例的不同,ClickHouse 和 OLTP 数据库显著不同。例如,PostgreSQL 是一种面向行的、符合 ACID 的关系数据库,支持强大的事务性更新和删除操作,通过多版本并发控制(MVCC)等机制确保数据一致性和完整性。这使得在高并发环境中进行安全可靠的修改成为可能。 - -相反,ClickHouse 是一种针对读密集型分析和高吞吐量附加操作优化的列式数据库。虽然它本身支持就地更新和删除,但必须谨慎使用以避免高 I/O。另一种选择是重新构造表,将删除和更新转换为附加操作,在这些操作中,它们被异步处理并/或在读取时处理,从而反映出对高吞吐量数据摄取和高效查询性能的关注,而非实时数据操作。 - -## 在 ClickHouse 中更新数据的方法 {#methods-to-update-data-in-clickhouse} - -在 ClickHouse 中有几种更新数据的方法,每种方法都有其自身的优点和性能特征。你应该根据数据模型和你打算更新的数据量选择合适的方法。 - -对于这两种操作,如果提交的突变数量持续超过在某个时间间隔内在后台处理的突变数量,则必须应用的未物化突变队列将继续增长。这将最终导致 `SELECT` 查询性能的下降。 - -总而言之,更新操作应谨慎进行,并应通过 `system.mutations` 表密切跟踪突变队列。请不要像在 OLTP 数据库中那样频繁地发出更新。如果你有频繁更新的需求,请参见 [ReplacingMergeTree](/engines/table-engines/mergetree-family/replacingmergetree)。 - -| 方法 | 语法 | 适用场景 | -|----------------------------------------------------------------------------------------------|--------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| [更新突变](/sql-reference/statements/alter/update) | `ALTER TABLE [table] UPDATE` | 当数据必须立即更新到磁盘时(例如,为了合规性)。会对 `SELECT` 性能产生负面影响。 | -| [轻量级更新](/guides/developer/lightweight-update) | `ALTER TABLE [table] UPDATE` | 通过 `SET apply_mutations_on_fly = 1;` 启用。用于更新少量数据时。行在所有后续 `SELECT` 查询中立即返回更新的数据,但最初仅在磁盘上被内部标记为更新。 | -| [ReplacingMergeTree](/engines/table-engines/mergetree-family/replacingmergetree) | `ENGINE = ReplacingMergeTree` | 当更新大量数据时使用。该表引擎针对合并时的数据去重进行了优化。 | -| [CollapsingMergeTree](/engines/table-engines/mergetree-family/collapsingmergetree) | `ENGINE = CollapsingMergeTree(Sign)` | 当频繁更新单个行,或在需要维护随时间变化的对象最新状态的场景中使用。例如,跟踪用户活动或文章统计。 | - -下面是更新 ClickHouse 中数据的不同方式的总结: - -## 更新突变 {#update-mutations} - -更新突变可以通过 `ALTER TABLE ... UPDATE` 命令发出,例如: - -```sql -ALTER TABLE posts_temp - (UPDATE AnswerCount = AnswerCount + 1 WHERE AnswerCount = 0) -``` -这些操作非常消耗 I/O,会重写所有匹配 `WHERE` 表达式的部分。该过程没有原子性 - 当突变部分准备好后,就会用突变部分替换,而在突变过程中开始执行的 `SELECT` 查询将看到已经突变的部分和尚未突变的部分的数据。用户可以通过 [systems.mutations](/operations/system-tables/mutations) 表跟踪进度。这些是 I/O 密集型操作,应谨慎使用,因为它们可能会影响集群 `SELECT` 性能。 - -阅读更多关于 [更新突变](/sql-reference/statements/alter/update)。 - -## 轻量级更新 {#lightweight-updates} - -轻量级更新提供了一种机制,可以更新行,使其立即更新,并且后续的 `SELECT` 查询将自动返回更改的值(这会产生额外开销并减慢查询)。这有效地解决了正常突变的原子性限制。以下是一个示例: - -```sql -SET apply_mutations_on_fly = 1; - -SELECT ViewCount -FROM posts -WHERE Id = 404346 - -┌─ViewCount─┐ -│ 26762 │ -└───────────┘ - -1 row in set. Elapsed: 0.115 sec. Processed 59.55 million rows, 238.25 MB (517.83 million rows/s., 2.07 GB/s.) -Peak memory usage: 113.65 MiB. - --increment count -ALTER TABLE posts - (UPDATE ViewCount = ViewCount + 1 WHERE Id = 404346) - -SELECT ViewCount -FROM posts -WHERE Id = 404346 - -┌─ViewCount─┐ -│ 26763 │ -└───────────┘ - -1 row in set. Elapsed: 0.149 sec. Processed 59.55 million rows, 259.91 MB (399.99 million rows/s., 1.75 GB/s.) -``` - -请注意,对于轻量级更新,仍然会使用突变来更新数据;只是在 `SELECT` 查询时不会立即实现并应用。它仍会作为异步过程在后台应用,并会带来与突变相同的重负载,因此是 I/O 密集型操作,应谨慎使用。此操作可以使用的表达式也有限(有关详细信息,请参见 [这里](/guides/developer/lightweight-update#support-for-subqueries-and-non-deterministic-functions))。 - -阅读更多关于 [轻量级更新](/guides/developer/lightweight-update)。 - -## Collapsing Merge Tree {#collapsing-merge-tree} - -基于更新代价高昂,但可以利用插入来执行更新的想法,[`CollapsingMergeTree`](/engines/table-engines/mergetree-family/collapsingmergetree) 表引擎可以与 `sign` 列结合使用,作为告诉 ClickHouse 通过折叠(删除)一对 `1` 和 `-1` 的行来更新特定行的方法。 -如果 `-1` 插入到 `sign` 列中,将删除整行。 -如果 `1` 插入到 `sign` 列中,ClickHouse 将保留该行。 -要更新的行根据创建表时在 `ORDER BY ()` 语句中使用的排序键进行识别。 - -```sql -CREATE TABLE UAct -( - UserID UInt64, - PageViews UInt8, - Duration UInt8, - Sign Int8 -- A special column used with the CollapsingMergeTree table engine -) -ENGINE = CollapsingMergeTree(Sign) -ORDER BY UserID - -INSERT INTO UAct VALUES (4324182021466249494, 5, 146, 1) -INSERT INTO UAct VALUES (4324182021466249494, 5, 146, -1) -- sign = -1 signals to update the state of this row -INSERT INTO UAct VALUES (4324182021466249494, 6, 185, 1) -- the row is replaced with the new state - -SELECT - UserID, - sum(PageViews * Sign) AS PageViews, - sum(Duration * Sign) AS Duration -FROM UAct -GROUP BY UserID -HAVING sum(Sign) > 0 - -┌──────────────UserID─┬─PageViews─┬─Duration─┐ -│ 4324182021466249494 │ 6 │ 185 │ -└─────────────────────┴───────────┴──────────┘ -``` - -:::note -上述更新方法要求用户在客户端维护状态。 -虽然从 ClickHouse 的角度来看,这是最有效的,但在大规模操作时可能会很复杂。 - -我们建议阅读关于 [`CollapsingMergeTree`](/engines/table-engines/mergetree-family/collapsingmergetree) 的文档,以获得更全面的概述。 -::: - -## 更多资源 {#more-resources} - -- [在 ClickHouse 中处理更新和删除](https://clickhouse.com/blog/handling-updates-and-deletes-in-clickhouse) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/updating-data/overview.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/updating-data/overview.md.hash deleted file mode 100644 index b5a01e8d16b..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/updating-data/overview.md.hash +++ /dev/null @@ -1 +0,0 @@ -afba248a4550b773 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/updating-data/overview.mdx b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/updating-data/overview.mdx new file mode 100644 index 00000000000..59db0369430 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/updating-data/overview.mdx @@ -0,0 +1,137 @@ +--- +'slug': '/updating-data/overview' +'title': '概述' +'description': '如何在 ClickHouse 中更新数据' +'keywords': +- 'update' +- 'updating data' +'doc_type': 'guide' +--- + +## ClickHouse与OLTP数据库中更新数据的区别 {#differences-between-updating-data-in-clickhouse-and-oltp-databases} + +在处理更新时,ClickHouse与OLTP数据库在其基础设计理念和目标使用案例上有显著区别。例如,PostgreSQL作为一种面向行的、符合ACID的关系型数据库,支持强大且事务性的更新和删除操作,通过多版本并发控制(MVCC)等机制确保数据的一致性和完整性。这允许在高并发环境中进行安全可靠的修改。 + +相反,ClickHouse是一个面向列的数据库,针对重读分析和高吞吐量追加操作进行了优化。尽管它确实原生支持原地更新和删除,但需要谨慎使用,以避免高I/O。或者,可以对表进行重构,将删除和更新转换为追加操作,在此过程中以异步方式处理,并/或在读取时处理,从而反映出对高吞吐量数据摄取和有效查询性能的重点,而不是实时数据操作。 + +## 在ClickHouse中更新数据的方法 {#methods-to-update-data-in-clickhouse} + +在ClickHouse中有几种更新数据的方法,每种方法都有其自身的优点和性能特征。您应该根据您的数据模型和打算更新的数据量选择适当的方法。 + +对于这两种操作,如果提交的变更数量持续超过在某个时间区间内后台处理的变更数量,则必须应用的非物化变更队列将继续增长。这将导致最终的 `SELECT` 查询性能下降。 + +总之,更新操作应谨慎发出,并且应通过 `system.mutations` 表密切跟踪变更队列。不要像在OLTP数据库中那样频繁发布更新。如果您有频繁更新的需求,查看 [ReplacingMergeTree](/engines/table-engines/mergetree-family/replacingmergetree)。 +| 方法 | 语法 | 使用时机 | +|------------------------------------------------------------------------------------------|-----------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| [Update mutation](/sql-reference/statements/alter/update) | `ALTER TABLE [table] UPDATE` | 当数据必须立即更新到磁盘时使用(例如,为了合规性)。对`SELECT`性能有负面影响。 | +| [Lightweight updates](/sql-reference/statements/update) | `UPDATE [table] SET ... WHERE` | 用于更新少量数据(最多约10% 的表)。创建补丁部分以实现即时可见性,而无需重写整个列。虽然对`SELECT`查询增加了额外开销,但具有可预测的延迟。目前实验性。 | +| [On-the-fly updates](/guides/developer/on-the-fly-mutations) | `ALTER TABLE [table] UPDATE` | 启用`SET apply_mutations_on_fly = 1;`。在更新少量数据时使用。行会立即在随后的`SELECT`查询中返回更新后的数据,但最初仅在磁盘上被内部标记为已更新。 | +| [ReplacingMergeTree](/engines/table-engines/mergetree-family/replacingmergetree) | `ENGINE = ReplacingMergeTree` | 当更新大量数据时使用。此表引擎针对合并时的数据去重进行了优化。 | +| [CollapsingMergeTree](/engines/table-engines/mergetree-family/collapsingmergetree) | `ENGINE = CollapsingMergeTree(Sign)` | 当频繁更新单行,或在需要维护随时间变化的对象最新状态的场景中使用。例如,跟踪用户活动或文章统计。 | + +## 更新变更 {#update-mutations} + +更新变更可以通过 `ALTER TABLE ... UPDATE` 命令发出,例如: + +```sql +ALTER TABLE posts_temp + (UPDATE AnswerCount = AnswerCount + 1 WHERE AnswerCount = 0) +``` +这些操作极其占用I/O,重写所有与 `WHERE` 表达式匹配的部分。此过程没有原子性——只要部分准备好,就会立即用变更部分替换。这意味着在变更期间开始执行的 `SELECT` 查询将同时看到已经变更的部分和尚未变更的部分的数据。用户可以通过 [systems.mutations](/operations/system-tables/mutations) 表跟踪进度状态。这些是I/O密集型操作,应谨慎使用,因为它们可能会影响集群的 `SELECT` 性能。 + +了解更多关于 [update mutations](/sql-reference/statements/alter/update)。 + +## 轻量级更新 {#lightweight-updates} + +轻量级更新是ClickHouse的一个特性,通过“补丁部分”更新行——这些特殊的数据部分仅包含更新的列和行,而不是像传统的变更那样重写整个列。轻量级更新的主要特性包括: + +- 使用标准的 `UPDATE` 语法,并立即创建补丁部分,而不必等待合并 +- 更新的值在通过补丁应用时在 `SELECT` 查询中立即可见,但在随后的合并中才会物理化 +- 为小规模更新(最多约10% 的表)设计,具有可预测的延迟 +- 对需要应用补丁的 `SELECT` 查询增加了额外开销,但避免重写整个列 + +详细信息请参见 ["轻量级更新语句"](/sql-reference/statements/update)。 + +## 即时更新 {#on-the-fly-updates} + +即时更新提供了一种机制,用于更新行,使其立即更新,随后的 `SELECT` 查询将自动返回更改后的值(这会产生额外开销,导致查询变慢)。这有效地解决了常规变更的原子性限制。以下是示例: + +```sql +SET apply_mutations_on_fly = 1; + +SELECT ViewCount +FROM posts +WHERE Id = 404346 + +┌─ViewCount─┐ +│ 26762 │ +└───────────┘ + +1 row in set. Elapsed: 0.115 sec. Processed 59.55 million rows, 238.25 MB (517.83 million rows/s., 2.07 GB/s.) +Peak memory usage: 113.65 MiB. + +-increment count +ALTER TABLE posts + (UPDATE ViewCount = ViewCount + 1 WHERE Id = 404346) + +SELECT ViewCount +FROM posts +WHERE Id = 404346 + +┌─ViewCount─┐ +│ 26763 │ +└───────────┘ + +1 row in set. Elapsed: 0.149 sec. Processed 59.55 million rows, 259.91 MB (399.99 million rows/s., 1.75 GB/s.) +``` + +请注意,对于即时更新,仍然使用变更来更新数据;只是在 `SELECT` 查询中不会立即物化,而是在后台作为异步过程应用。它仍将在后台应用,产生与变更相同的额外开销,因此是一个应谨慎使用的I/O密集型操作。此操作中可以使用的表达式也有限(有关详细信息,请参见 [这里](/guides/developer/on-the-fly-mutations#support-for-subqueries-and-non-deterministic-functions))。 + +了解更多关于 [即时更新](/guides/developer/on-the-fly-mutations)。 + +## `CollapsingMergeTree` {#collapsing-merge-tree} + +基于这样的理念:更新成本高昂,但插入可以利用来执行更新,[`CollapsingMergeTree`](/engines/table-engines/mergetree-family/collapsingmergetree) 表引擎可以和一个 `sign` 列一起使用,以告知ClickHouse通过合并(删除)一对带有 `1` 和 `-1` 的行来更新特定行。 +如果 `-1` 被插入到 `sign` 列中,整行将被删除。 +如果 `1` 被插入到 `sign` 列中,ClickHouse将保留该行。 +待更新的行是基于创建表时 `ORDER BY ()` 语句中使用的排序键进行识别的。 + +```sql +CREATE TABLE UAct +( + UserID UInt64, + PageViews UInt8, + Duration UInt8, + Sign Int8 -- A special column used with the CollapsingMergeTree table engine +) +ENGINE = CollapsingMergeTree(Sign) +ORDER BY UserID + +INSERT INTO UAct VALUES (4324182021466249494, 5, 146, 1) +INSERT INTO UAct VALUES (4324182021466249494, 5, 146, -1) -- sign = -1 signals to update the state of this row +INSERT INTO UAct VALUES (4324182021466249494, 6, 185, 1) -- the row is replaced with the new state + +SELECT + UserID, + sum(PageViews * Sign) AS PageViews, + sum(Duration * Sign) AS Duration +FROM UAct +GROUP BY UserID +HAVING sum(Sign) > 0 + +┌──────────────UserID─┬─PageViews─┬─Duration─┐ +│ 4324182021466249494 │ 6 │ 185 │ +└─────────────────────┴───────────┴──────────┘ +``` + +:::note +上述更新方法要求用户在客户端维护状态。 +尽管从ClickHouse的角度来看这是最有效的方案,但在大规模操作时可能会复杂。 + +我们建议阅读 +关于 [`CollapsingMergeTree`](/engines/table-engines/mergetree-family/collapsingmergetree) 的文档,以获得更全面的概述。 +::: + +## 更多资源 {#more-resources} + +- [在ClickHouse中处理更新和删除](https://clickhouse.com/blog/handling-updates-and-deletes-in-clickhouse) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/updating-data/overview.mdx.hash b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/updating-data/overview.mdx.hash new file mode 100644 index 00000000000..d9fd9eafd57 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/updating-data/overview.mdx.hash @@ -0,0 +1 @@ +b343857c2eef0f64 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/updating-data/update_mutations.md b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/updating-data/update_mutations.md deleted file mode 100644 index 0b02fd9c799..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/updating-data/update_mutations.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -'slug': '/managing-data/update_mutations' -'sidebar_label': '更新变更' -'title': '更新变更' -'hide_title': false -'description': '页面描述更新变更 - ALTER 查询通过更新操作表数据' ---- - -import UpdateMutations from '@site/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/update.md'; - -更新突变是指通过更新操作 manipulates 表数据的 `ALTER` 查询。最显著的是,像 `ALTER TABLE UPDATE` 这样的查询。执行此类查询会生成数据片段的新突变版本。这意味着,这些语句会触发对所有在突变之前插入的数据的整个数据片段的重写,从而导致大量的写请求。 - -:::info -对于更新,您可以通过使用专用的表引擎,如 [ReplacingMergeTree](/guides/replacing-merge-tree) 或 [CollapsingMergeTree](/engines/table-engines/mergetree-family/collapsingmergetree),来避免这些大量的写请求,而不是使用默认的 MergeTree 表引擎。 -::: - - diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/updating-data/update_mutations.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/updating-data/update_mutations.md.hash deleted file mode 100644 index 2937e40697c..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/updating-data/update_mutations.md.hash +++ /dev/null @@ -1 +0,0 @@ -ff809d0ee42e42ed diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/updating-data/update_mutations.mdx b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/updating-data/update_mutations.mdx new file mode 100644 index 00000000000..84d2d2909ad --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/updating-data/update_mutations.mdx @@ -0,0 +1,18 @@ +--- +'slug': '/managing-data/update_mutations' +'sidebar_label': '更新突变' +'title': '更新突变' +'hide_title': false +'description': '页面描述更新突变 - ALTER 查询通过更新操作来操纵表数据' +'doc_type': 'reference' +--- + +import UpdateMutations from '@site/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/update.md'; + +Update mutations refers to `ALTER` 查询,通过更新来操作表数据。最显著的是,类似于 `ALTER TABLE UPDATE` 的查询。执行此类查询将产生数据片段的新变更版本。这意味着这些语句将触发对所有在变更前插入的数据的整个数据片段进行重写,从而导致大量的写请求。 + +:::info +对于更新,您可以通过使用专业的表引擎来避免这些大量的写请求,例如 [ReplacingMergeTree](/guides/replacing-merge-tree) 或 [CollapsingMergeTree](/engines/table-engines/mergetree-family/collapsingmergetree),而不是使用默认的 MergeTree 表引擎。 +::: + + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/updating-data/update_mutations.mdx.hash b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/updating-data/update_mutations.mdx.hash new file mode 100644 index 00000000000..16af7ea82c6 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/managing-data/updating-data/update_mutations.mdx.hash @@ -0,0 +1 @@ +a25dc8da152dc464 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/materialized-view/incremental-materialized-view.md b/i18n/zh/docusaurus-plugin-content-docs/current/materialized-view/incremental-materialized-view.md index b4439519610..cc793ab965c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/materialized-view/incremental-materialized-view.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/materialized-view/incremental-materialized-view.md @@ -1,12 +1,13 @@ --- 'slug': '/materialized-view/incremental-materialized-view' 'title': '增量物化视图' -'description': '如何使用增量物化视图来加速查询' +'description': '如何使用增量物化视图来加快查询速度' 'keywords': - 'incremental materialized views' - 'speed up queries' - 'query optimization' 'score': 10000 +'doc_type': 'guide' --- import materializedViewDiagram from '@site/static/images/materialized-view/materialized-view-diagram.png'; @@ -14,21 +15,21 @@ import Image from '@theme/IdealImage'; ## 背景 {#background} -增量物化视图(Materialized Views)允许用户将计算成本从查询时转移到插入时,从而加快 `SELECT` 查询的速度。 +增量物化视图(Materialized Views)允许用户将计算成本从查询时间转移到插入时间,从而加快 `SELECT` 查询的速度。 -与像 Postgres 这样的事务性数据库不同,ClickHouse 的物化视图只是一个触发器,在数据块插入表时运行查询。该查询的结果被插入到第二个“目标”表中。如果更多行被插入,结果将再次发送到目标表,在那里,中间结果将被更新和合并。这个合并的结果相当于在所有原始数据上运行该查询。 +与事务性数据库(如 Postgres)不同,ClickHouse 的物化视图只是一个触发器,当数据块插入到表中时,会运行一个查询。该查询的结果将插入到第二个“目标”表中。如果插入更多行,结果将再次发送到目标表,其中中间结果将被更新和合并。这个合并后的结果相当于对所有原始数据运行查询。 -物化视图的主要动机是插入到目标表中的结果代表对行的聚合、过滤或转换的结果。这些结果通常是原始数据的较小表示(在聚合的情况下是部分草图)。这一点,加上从目标表读取结果的查询简单,确保查询时间比在原始数据上执行相同计算时快,将计算(因此查询延迟)从查询时间转移到插入时间。 +物化视图的主要动机是插入到目标表中的结果代表对行进行聚合、过滤或转换的结果。这些结果通常是原始数据的较小表示(在聚合的情况下是部分快照)。这种方法确保读取目标表结果的查询简单,从而确保查询时间比对原始数据执行相同计算时要快,将计算(因此查询延迟)从查询时间转移到插入时间。 -ClickHouse 中的物化视图会在数据流入其基础表时实时更新,运作方式更类似于持续更新的索引。这与其他数据库形成对比,在其他数据库中,物化视图通常是查询的静态快照,必须刷新(类似于 ClickHouse 的 [可刷新物化视图](/sql-reference/statements/create/view#refreshable-materialized-view))。 +ClickHouse 中的物化视图会在数据流入其基础表时实时更新,功能更像是不断更新的索引。这与其他数据库形成对比,在这些数据库中,物化视图通常是必须被刷新的查询的静态快照(类似于 ClickHouse 的 [可刷新的物化视图](/sql-reference/statements/create/view#refreshable-materialized-view))。 - + ## 示例 {#example} -作为示例,我们将使用在 ["模式设计"](/data-modeling/schema-design) 中记录的 Stack Overflow 数据集。 +作为示例,我们将使用在 ["模式设计"](/data-modeling/schema-design) 中文档化的 Stack Overflow 数据集。 -假设我们想要获取每个帖子的每日点赞和点踩数。 +假设我们想要获取每篇帖子的每天点赞和点踩数。 ```sql CREATE TABLE votes @@ -48,7 +49,7 @@ INSERT INTO votes SELECT * FROM s3('https://datasets-documentation.s3.eu-west-3. 0 rows in set. Elapsed: 29.359 sec. Processed 238.98 million rows, 2.13 GB (8.14 million rows/s., 72.45 MB/s.) ``` -由于 [`toStartOfDay`](/sql-reference/functions/date-time-functions#tostartofday) 函数的存在,这在 ClickHouse 中是一个相当简单的查询: +得益于 [`toStartOfDay`](/sql-reference/functions/date-time-functions#toStartOfDay) 函数,这在 ClickHouse 中是一个相当简单的查询: ```sql SELECT toStartOfDay(CreationDate) AS day, @@ -76,11 +77,11 @@ LIMIT 10 Peak memory usage: 363.22 MiB. ``` -这个查询由于 ClickHouse 的性能已经很快了,但我们能不能做得更好? +这个查询在 ClickHouse 中已经很快,但我们能做到更好吗? -如果我们想在插入时间使用物化视图来计算这个,我们需要一个表来接收结果。该表应仅保留每日 1 行。如果接收到对现有日期的更新,则应将其他列合并到现有日期的行中。为了实现这种增量状态的合并,必须为其他列存储部分状态。 +如果我们想在插入时间通过物化视图计算这个,我们需要一个表来接收结果。这个表应该只保留每天 1 行。如果收到现有日期的更新,其他列应该合并到现有日期的行中。为了让这些增量状态合并,必须为其他列存储部分状态。 -这在 ClickHouse 中需要一种特殊的引擎类型:[SummingMergeTree](/engines/table-engines/mergetree-family/summingmergetree)。它将所有具有相同排序键的行替换为一行,该行包含数值列的汇总值。以下表将合并任何具有相同日期的行,汇总任何数值列: +这需要 ClickHouse 中一种特殊的引擎类型:[SummingMergeTree](/engines/table-engines/mergetree-family/summingmergetree)。它将所有具有相同排序键的行替换为一行,其中包含数字列的总和。以下表格会合并任何具有相同日期的行,求和任何数值列: ```sql CREATE TABLE up_down_votes_per_day @@ -93,7 +94,7 @@ ENGINE = SummingMergeTree ORDER BY Day ``` -为了演示我们的物化视图,假设我们的投票表是空的,尚未接收任何数据。我们的物化视图在插入到 `votes` 中的数据上执行上述 `SELECT`,将结果发送到 `up_down_votes_per_day`: +为了演示我们的物化视图,假设我们的投票表是空的,尚未接收到任何数据。我们的物化视图会对插入到 `votes` 中的数据执行上述 `SELECT`,结果发送到 `up_down_votes_per_day`: ```sql CREATE MATERIALIZED VIEW up_down_votes_per_day_mv TO up_down_votes_per_day AS @@ -104,9 +105,9 @@ FROM votes GROUP BY Day ``` -这里的 `TO` 子句是关键,指明结果将发送到的地方,即 `up_down_votes_per_day`。 +`TO` 子句在这里是关键,表示结果将发送到 `up_down_votes_per_day`。 -我们可以从之前的插入中重新填充我们的投票表: +我们可以从早先的插入中重新填充我们的投票表: ```sql INSERT INTO votes SELECT toUInt32(Id) AS Id, toInt32(PostId) AS PostId, VoteTypeId, CreationDate, UserId, BountyAmount @@ -116,7 +117,7 @@ FROM s3('https://datasets-documentation.s3.eu-west-3.amazonaws.com/stackoverflow Peak memory usage: 283.49 MiB. ``` -完成后,我们可以确认我们的 `up_down_votes_per_day` 的大小 – 我们应该有每个日期 1 行: +完成后,我们可以确认 `up_down_votes_per_day` 的大小 - 每天应有 1 行: ```sql SELECT count() @@ -128,12 +129,12 @@ FINAL └─────────┘ ``` -通过存储查询的结果,我们将行数从 2.38 亿(在 `votes` 中)有效减少到 5000。然而,关键在于,如果新的投票被插入到 `votes` 表中,新的值将被发送到 `up_down_votes_per_day` 的相应日期,并将异步在后台自动合并 – 保持每个日期仅一行。`up_down_votes_per_day` 因此将始终保持小且最新。 +我们已经有效地将这里的行数从 2.38 亿(在 `votes` 中)减少到 5000,存储了查询的结果。然而,关键是如果新的投票插入到 `votes` 表中,新值将被发送到 `up_down_votes_per_day` 的相应日期,并将在后台异步自动合并 - 只保留每天的一行。因此,`up_down_votes_per_day` 始终保持小且最新。 -由于行的合并是异步的,当用户查询时,某天可能会有不止一条投票。为了确保任何未合并的行在查询时间被合并,我们有两个选项: +由于行的合并是异步的,当用户查询时,可能会出现每天多个投票。为了确保在查询时合并任何未完成的行,我们有两个选项: -- 在表名上使用 `FINAL` 修饰符。我们在上面的计数查询中做了这个。 -- 按照我们最终表中使用的排序键进行聚合,即 `CreationDate` 并汇总指标。通常,这种方法更高效且灵活(该表可以用于其他用途),但前者对于某些查询可能更简单。我们在下面展示了两者: +- 在表名上使用 `FINAL` 修饰符。我们为上面的计数查询使用了此方法。 +- 按照我们最终表中使用的排序键进行聚合,即 `CreationDate` 及对度量进行求和。通常,这样更有效且灵活(该表可以用于其他用途),但前者对于某些查询可能更简单。我们下面展示了两者: ```sql SELECT @@ -170,17 +171,17 @@ LIMIT 10 Peak memory usage: 567.61 KiB. ``` -这样将我们的查询从 0.133s 提速到 0.004s – 超过 25 倍的提升! +这使我们查询的时间从 0.133s 加速到 0.004s – 提高了超过 25 倍的性能! :::important 重要提示: `ORDER BY` = `GROUP BY` -在大多数情况下,物化视图转换的 `GROUP BY` 子句中使用的列,应该与目标表中使用的 `ORDER BY` 子句保持一致,如果使用 `SummingMergeTree` 或 `AggregatingMergeTree` 表引擎。这些引擎依赖于 `ORDER BY` 列在后台合并操作中合并具有相同值的行。`GROUP BY` 和 `ORDER BY` 列之间的不对齐可能导致查询性能低效、合并不理想,甚至数据不一致。 +在大多数情况下,物化视图转换中的 `GROUP BY` 子句使用的列应与目标表的 `ORDER BY` 子句中使用的列一致,特别是在使用 `SummingMergeTree` 或 `AggregatingMergeTree` 表引擎时。这些引擎依赖 `ORDER BY` 列在后台合并操作时合并具有相同值的行。`GROUP BY` 和 `ORDER BY` 列的不匹配可能导致查询性能低效、合并不佳,甚至数据不一致。 ::: ### 更复杂的示例 {#a-more-complex-example} -上述示例使用物化视图来计算并维护每日的两个总和。总和表示维护部分状态的最简单聚合形式 - 当新值到达时,我们只需将其加到现有值上。然而,ClickHouse 的物化视图可以用于任何聚合类型。 +上面的示例使用物化视图来计算和维护每天的两个总和。总和是维护部分状态的最简单聚合形式 - 当新值到来时,我们可以简单地将其添加到现有值中。然而,ClickHouse 的物化视图可以用于任何聚合类型。 -假设我们希望为每一天计算一些帖子的统计数据:`Score` 的 99.9 百分位数和 `CommentCount` 的平均值。计算这个的查询可能如下所示: +假设我们希望计算每一天的帖子统计信息:`Score` 的 99.9 百分位数和 `CommentCount` 的平均值。计算此内容的查询可能如下所示: ```sql SELECT @@ -209,15 +210,15 @@ LIMIT 10 Peak memory usage: 658.84 MiB. ``` -与之前一样,我们可以创建一个物化视图,该视图在我们向 `posts` 表中插入新帖子时执行上述查询。 +与之前一样,我们可以创建一个物化视图,在新的帖子插入到我们的 `posts` 表时执行上述查询。 -为了举例说明,并为了避免从 S3 加载帖子数据,我们将创建一个与 `posts` 具有相同模式的重复表 `posts_null`。然而,这个表不会存储任何数据,仅在插入行时被物化视图使用。为了防止数据存储,我们可以使用 [`Null` 表引擎类型](/engines/table-engines/special/null)。 +为了示例并避免从 S3 加载帖子数据,我们将创建一个与 `posts` 具有相同模式的重复表 `posts_null`。然而,此表不会存储任何数据,仅在插入行时被物化视图使用。为了防止存储数据,我们可以使用 [`Null` 表引擎类型](/engines/table-engines/special/null)。 ```sql CREATE TABLE posts_null AS posts ENGINE = Null ``` -Null 表引擎是一种强大的优化 - 可以把它看作是 `/dev/null`。我们的物化视图将在 `posts_null` 表接收行时计算并存储我们的摘要统计信息 - 它只是一个触发器。然而,原始数据不会被存储。在我们的情况下,我们可能仍然想存储原始帖子,但此方法可以在避免存储原始数据的开销的同时计算聚合。 +Null 表引擎是一种强大的优化 - 把它看作是 `/dev/null`。我们的物化视图将在我们的 `posts_null` 表在插入时接收行时计算并存储我们的摘要统计信息 - 它只是一个触发器。然而,原始数据将不会被存储。虽然在这种情况下,我们可能仍希望存储原始帖子,但这种方法可以在避免原始数据存储开销的同时计算聚合。 因此,物化视图变为: @@ -230,11 +231,11 @@ FROM posts_null GROUP BY Day ``` -请注意,我们在聚合函数的末尾附加了后缀 `State`。这确保了返回函数的聚合状态,而不是最终结果。它将包含额外信息,以允许此部分状态与其他状态合并。例如,在平均情况下,这将包括列的计数和总和。 +请注意,我们在聚合函数的末尾附加了后缀 `State`。这确保返回聚合函数的聚合状态,而不是最终结果。这将包含额外信息,允许该部分状态与其他状态合并。例如,在平均值的情况下,这将包括计数和列的总和。 -> 部分聚合状态对于计算正确结果是必要的。例如,为了计算平均值,仅仅对子范围的平均值进行平均会产生不正确的结果。 +> 部分聚合状态是计算正确结果所必须的。例如,在计算平均值时,仅仅对范围的平均值求平均会导致错误的结果。 -我们现在创建这个视图的目标表 `post_stats_per_day`,它存储这些部分聚合状态: +我们现在为此视图创建目标表 `post_stats_per_day`,该表存储这些部分聚合状态: ```sql CREATE TABLE post_stats_per_day @@ -247,9 +248,9 @@ ENGINE = AggregatingMergeTree ORDER BY Day ``` -虽然之前的 `SummingMergeTree` 足以存储计数,但对于其他函数,我们需要更高级的引擎类型:[`AggregatingMergeTree`](/engines/table-engines/mergetree-family/aggregatingmergetree)。为了确保 ClickHouse 知道将存储聚合状态,我们定义 `Score_quantiles` 和 `AvgCommentCount` 为 `AggregateFunction` 类型,指定部分状态的函数源及其源列的类型。与 `SummingMergeTree` 一样,具有相同 `ORDER BY` 键值的行将被合并(在上述示例中为 `Day`)。 +虽然之前的 `SummingMergeTree` 足以存储计数,但对于其他函数我们需要更高级的引擎类型:[`AggregatingMergeTree`](/engines/table-engines/mergetree-family/aggregatingmergetree)。为了确保 ClickHouse 知道将存储聚合状态,我们将 `Score_quantiles` 和 `AvgCommentCount` 定义为 `AggregateFunction` 类型,指定部分状态的函数来源及其源列的类型。与 `SummingMergeTree` 一样,具有相同 `ORDER BY` 键值的行将被合并(在上述示例中为 `Day`)。 -要通过我们的物化视图填充 `post_stats_per_day`,我们可以简单地将所有行从 `posts` 插入到 `posts_null`: +要通过我们的物化视图填充 `post_stats_per_day`,我们只需将 `posts` 中的所有行插入到 `posts_null` 中: ```sql INSERT INTO posts_null SELECT * FROM posts @@ -257,9 +258,9 @@ INSERT INTO posts_null SELECT * FROM posts 0 rows in set. Elapsed: 13.329 sec. Processed 119.64 million rows, 76.99 GB (8.98 million rows/s., 5.78 GB/s.) ``` -> 在生产中,您可能会将物化视图附加到 `posts` 表。我们在这里使用 `posts_null` 来演示空表。 +> 在生产中,您可能会将物化视图附加到 `posts` 表。我们这里使用 `posts_null` 是为了演示空表。 -我们的最终查询需要为我们的函数使用 `Merge` 后缀(因为列存储部分聚合状态): +我们的最终查询需要使用 `Merge` 后缀来表示我们的函数(因为列存储部分聚合状态): ```sql SELECT @@ -272,17 +273,17 @@ ORDER BY Day DESC LIMIT 10 ``` -请注意,我们在这里使用 `GROUP BY` 而不使用 `FINAL`。 +请注意,我们在这里使用了 `GROUP BY` 而不是使用 `FINAL`。 ## 其他应用 {#other-applications} -以上主要关注如何使用物化视图增量更新数据的部分聚合,从而将计算从查询时间转移到插入时间。除了这种常见用例外,物化视图还有其他多种应用。 +上述主要着重于利用物化视图增量更新数据的部分聚合,从而将计算从查询转移到插入时间。除了这个常见用例外,物化视图还有许多其他应用。 ### 过滤和转换 {#filtering-and-transformation} -在某些情况下,我们可能希望在插入时仅插入某些行和列。在这种情况下,我们的 `posts_null` 表可以接收插入,使用 `SELECT` 查询在插入到 `posts` 表前过滤行。例如,假设我们希望转换 `posts` 表中的 `Tags` 列。该列包含以管道分隔的标签名称列表。通过将这些转换为数组,我们可以更方便地按单独的标签值进行聚合。 +在某些情况下,我们可能希望在插入时仅插入行和列的子集。在这种情况下,我们的 `posts_null` 表可以接收插入,使用一个 `SELECT` 查询在插入到 `posts` 表之前过滤行。例如,假设我们希望转换 `posts` 表中的 `Tags` 列。它包含以管道分隔的标签名称列表。通过将其转换为数组,我们可以更容易地按单个标签值进行聚合。 -> 我们可以在执行 `INSERT INTO SELECT` 时进行此转换。物化视图允许我们将此逻辑封装在 ClickHouse DDL 中,并保持我们的 `INSERT` 简单,对新行应用转换。 +> 我们可以在运行 `INSERT INTO SELECT` 时执行此转换。物化视图允许我们在 ClickHouse DDL 中封装此逻辑,并保持我们的 `INSERT` 简单,将转换应用于任何新行。 我们的物化视图用于此转换如下所示: @@ -293,7 +294,7 @@ CREATE MATERIALIZED VIEW posts_mv TO posts AS ### 查找表 {#lookup-table} -用户在选择 ClickHouse 排序键时应考虑其访问模式。频繁出现在过滤和聚合子句中的列应被使用。这对于访问模式更多样化、无法用一组列封装的场景可能会造成一定限制。例如,考虑以下 `comments` 表: +用户在选择 ClickHouse 排序键时应考虑其访问模式。应使用在过滤和聚合子句中频繁使用的列。这在用户具有更不一样的访问模式,无法封装在一组列中时可能会有限制。例如,考虑以下的 `comments` 表: ```sql CREATE TABLE comments @@ -312,9 +313,9 @@ ORDER BY PostId 0 rows in set. Elapsed: 46.357 sec. Processed 90.38 million rows, 11.14 GB (1.95 million rows/s., 240.22 MB/s.) ``` -这里的排序键优化该表以支持按 `PostId` 的查询过滤。 +此处的排序键优化了按 `PostId` 过滤的查询。 -假设用户希望按特定的 `UserId` 进行过滤,并计算他们的平均 `Score`: +假设用户希望过滤特定的 `UserId` 并计算其平均 `Score`: ```sql SELECT avg(Score) @@ -329,9 +330,9 @@ WHERE UserId = 8592047 Peak memory usage: 217.08 MiB. ``` -虽然快速(对 ClickHouse 来说数据很小),但我们可以看到这需要从处理的行数来看进行全表扫描 - 9038 万。对于更大的数据集,我们可以使用物化视图来查找排序键值 `PostId` 以过滤列 `UserId`。然后可以使用这些值进行高效查找。 +虽然速度很快(对于 ClickHouse 来说数据很小),但从处理的行数可以看出,这需要进行全表扫描 - 9038 万。对于更大的数据集,我们可以使用物化视图查找我们的排序键值 `PostId` 来过滤列 `UserId`。然后可以使用这些值来执行有效的查找。 -在这个示例中,我们的物化视图可以非常简单,仅在插入时从 `comments` 选择 `PostId` 和 `UserId`。这些结果被发送到一个名为 `comments_posts_users` 的表,该表按 `UserId` 排序。我们在下面创建 `Comments` 表的空版本,并使用此表填充我们的视图和 `comments_posts_users` 表: +在这个示例中,我们的物化视图可以非常简单,仅在插入时选择 `comments` 中的 `PostId` 和 `UserId`。这些结果反过来会发送到一个按 `UserId` 排序的表 `comments_posts_users`。我们在下面创建 `Comments` 表的空版本,并利用它来填充我们的视图和 `comments_posts_users` 表: ```sql CREATE TABLE comments_posts_users ( @@ -339,7 +340,6 @@ CREATE TABLE comments_posts_users ( UserId Int32 ) ENGINE = MergeTree ORDER BY UserId - CREATE TABLE comments_null AS comments ENGINE = Null @@ -351,7 +351,7 @@ INSERT INTO comments_null SELECT * FROM comments 0 rows in set. Elapsed: 5.163 sec. Processed 90.38 million rows, 17.25 GB (17.51 million rows/s., 3.34 GB/s.) ``` -我们可以在子查询中使用此视图以加速我们之前的查询: +我们现在可以在子查询中使用这个视图来加速我们之前的查询: ```sql SELECT avg(Score) @@ -369,29 +369,30 @@ WHERE PostId IN ( 1 row in set. Elapsed: 0.012 sec. Processed 88.61 thousand rows, 771.37 KB (7.09 million rows/s., 61.73 MB/s.) ``` -### 链接 {#chaining} +### 链接 / 级联物化视图 {#chaining} -物化视图可以串联使用,使复杂的工作流程得以建立。要获取实际示例,我们建议阅读这个 [博客文章](https://clickhouse.com/blog/chaining-materialized-views)。 +物化视图可以链式(或级联)使用,允许建立复杂的工作流。 +更多信息,请参见指南 ["级联物化视图"](https://clickhouse.com/docs/guides/developer/cascading-materialized-views)。 -## 物化视图和 JOINs {#materialized-views-and-joins} +## 物化视图和 JOIN {#materialized-views-and-joins} -:::note 可刷新物化视图 -以下仅适用于增量物化视图。可刷新物化视图会在全目标数据集上定期执行其查询,并完全支持 JOIN。考虑在可以容忍结果新鲜度降低的情况下使用它们进行复杂的 JOIN。 +:::note 可刷新的物化视图 +以下内容仅适用于增量物化视图。可刷新的物化视图定期对完整目标数据集执行其查询,并完全支持 JOIN。如果可以容忍结果新鲜度的降低,请考虑在复杂 JOIN 中使用它们。 ::: -ClickHouse 中的增量物化视图完全支持 `JOIN` 操作,但有一个关键限制:**物化视图仅在源表(查询中的最左侧表)插入时触发。** 在 JOIN 中的右侧表即使其数据发生变化也不会触发更新。当构建 **增量** 物化视图时,这种行为特别重要,因为数据在插入时被聚合或转换。 +ClickHouse 中的增量物化视图完全支持 `JOIN` 操作,但有一个关键限制:**物化视图仅在源表(查询中最左侧的表)插入时触发。** JOIN 中的右侧表不会触发更新,即使它们的数据发生变化。在构建 **增量** 物化视图时,这种行为尤为重要,因为数据是在插入时被聚合或转换的。 -当使用 `JOIN` 定义增量物化视图时,`SELECT` 查询中的最左表行为为源。当新行插入到该表时,ClickHouse *仅* 使用这些新插入的行执行物化视图查询。在此执行期间,JOIN 中的右侧表的所有数据被完全读取,但对此表的更改不会触发视图。 +当使用 `JOIN` 定义增量物化视图时,`SELECT` 查询中的最左侧表作为源。当向此表插入新行时,ClickHouse *仅* 用这些新插入的行执行物化视图查询。JOIN 中的右侧表在此执行期间被完整读取,但对它们的更改单独不会触发视图。 -这种行为使得物化视图中的 JOIN 类似于对静态维度数据的快照连接。 +这种行为使得物化视图中的 JOIN 与对静态维度数据的快照连接类似。 -这对于将数据与参考或维度表进行丰富化非常有效。然而,任何对右侧表的更新(例如,用户元数据)将不会回溯更新物化视图。要查看更新的数据,必须在源表中插入新的行。 +这非常适合用引用或维度表来丰富数据。然而,对右侧表(例如用户元数据)的任何更新将不会追溯性地更新物化视图。要查看更新的数据,必须在源表中到达新插入数据。 ### 示例 {#materialized-views-and-joins-example} -让我们通过使用 [Stack Overflow 数据集](/data-modeling/schema-design) 来逐步了解一个具体示例。我们将使用物化视图计算**每个用户的每日徽章**,包括来自 `users` 表的用户显示名称。 +让我们用 [Stack Overflow 数据集](/data-modeling/schema-design) 走过一个具体的示例。我们将使用物化视图计算 **每个用户的每日徽章**,包括来自 `users` 表的用户显示名称。 -作为提醒,我们的表结构如下: +提醒一下,我们的表模式是: ```sql CREATE TABLE badges @@ -422,14 +423,14 @@ ENGINE = MergeTree ORDER BY Id; ``` -我们假设我们的 `users` 表已经填充: +我们假设 `users` 表已预填充: ```sql INSERT INTO users SELECT * FROM s3('https://datasets-documentation.s3.eu-west-3.amazonaws.com/stackoverflow/parquet/users.parquet'); ``` -物化视图及其关联的目标表定义如下: +物化视图及其关联目标表的定义如下: ```sql CREATE TABLE daily_badges_by_user @@ -458,7 +459,7 @@ GROUP BY Day, b.UserId, u.DisplayName; ``` :::note 分组和排序对齐 -物化视图中的 `GROUP BY` 子句必须包括 `DisplayName`、`UserId` 和 `Day` 以匹配 `SummingMergeTree` 目标表中的 `ORDER BY`。这确保行被正确聚合和合并。遗漏任何这些都会导致不正确的结果或低效的合并。 +物化视图中的 `GROUP BY` 子句必须包括 `DisplayName`、`UserId` 和 `Day`,以匹配 `SummingMergeTree` 目标表中的 `ORDER BY`。这确保了行被正确聚合和合并。遗漏其中任何一项可能导致结果不正确或合并效率低下。 ::: 如果我们现在填充徽章,视图将被触发 - 填充我们的 `daily_badges_by_user` 表。 @@ -492,7 +493,7 @@ WHERE DisplayName = 'gingerwizard' 8 rows in set. Elapsed: 0.018 sec. Processed 32.77 thousand rows, 642.14 KB (1.86 million rows/s., 36.44 MB/s.) ``` -现在,如果该用户获得一个新徽章并插入一行,我们的视图将会更新: +现在,如果该用户获得了新徽章并插入了一行,我们的视图将被更新: ```sql INSERT INTO badges VALUES (53505058, 2936484, 'gingerwizard', now(), 'Gold', 0); @@ -519,10 +520,10 @@ WHERE DisplayName = 'gingerwizard' ``` :::warning -请注意此处插入的延迟。插入的用户行将与整 个 `users` 表连接,显著影响插入性能。我们在以下 [“在过滤和连接中使用源表”](/materialized-view/incremental-materialized-view#using-source-table-in-filters-and-joins-in-materialized-views) 中提出解决方法。 +注意此处插入的延迟。插入的用户行与整个 `users` 表连接,显著影响插入性能。我们在下面的 ["在过滤和连接中使用源表"](/materialized-view/incremental-materialized-view#using-source-table-in-filters-and-joins-in-materialized-views) 中提出了一些解决方法。 ::: -相反,如果我们为新用户插入徽章,然后插入用户的行,我们的物化视图将无法捕获用户的指标。 +相反,如果我们为新用户插入徽章,然后插入该用户的行,我们的物化视图将无法捕获用户的指标。 ```sql INSERT INTO badges VALUES (53505059, 23923286, 'Good Answer', now(), 'Bronze', 0); @@ -538,7 +539,7 @@ WHERE DisplayName = 'brand_new_user'; 0 rows in set. Elapsed: 0.017 sec. Processed 32.77 thousand rows, 644.32 KB (1.98 million rows/s., 38.94 MB/s.) ``` -在这种情况下,视图仅在徽章插入时执行,而用户行不存在。如果我们再次为该用户插入徽章,则会插入一行,如预期: +在这种情况下,该视图仅在徽章插入时执行,而在用户行存在之前执行。如果我们再为该用户插入一个徽章,将插入一行,符合预期: ```sql INSERT INTO badges VALUES (53505060, 23923286, 'Teacher', now(), 'Bronze', 0); @@ -555,29 +556,29 @@ WHERE DisplayName = 'brand_new_user' 1 row in set. Elapsed: 0.018 sec. Processed 32.77 thousand rows, 644.48 KB (1.87 million rows/s., 36.72 MB/s.) ``` -然而,请注意这个结果是不正确的。 +但请注意,该结果是错误的。 ### 物化视图中 JOIN 的最佳实践 {#join-best-practices} -- **使用最左侧表作为触发器。** 仅 `SELECT` 语句左侧的表会触发物化视图。右侧表的更改不会触发更新。 +- **将最左侧表用作触发器。** 只有 `SELECT` 语句左侧的表会触发物化视图。右侧表的更改不会触发更新。 -- **预插入连接的数据。** 确保连接表中的数据在将行插入源表之前已经存在。JOIN 在插入时进行评估,因此丢失的数据将导致不匹配的行或空值。 +- **预插入连接的数据。** 确保在将行插入源表之前,连接表中的数据存在。JOIN 在插入时求值,因此缺失数据将导致不匹配的行或 null。 -- **限制从连接中提取的列。** 仅选择连接表中所需的列,以最小化内存使用并减少插入时延迟(见下文)。 +- **限制从连接中提取的列。** 仅选择连接表中所需的列,以最小化内存使用和减少插入时延迟(见下)。 -- **评估插入时性能。** JOIN 增加插入成本,特别是当右侧表很大时。使用代表生产数据的基准进行插入速率的基准测试。 +- **评估插入时性能。** JOIN 会增加插入成本,特别是在右侧表很大的情况下。使用代表性的生产数据基准测试插入速率。 -- **对于简单查找更优先使用字典。** 使用 [字典](/dictionary) 进行键值查找(例如,用户 ID 到姓名)以避免代价高昂的 JOIN 操作。 +- **简单查找时优先选择字典。** 使用 [字典](/dictionary) 进行键值查找(例如,用户 ID 到名称)以避免昂贵的 JOIN 操作。 -- **对齐 `GROUP BY` 和 `ORDER BY` 以提高合并效率。** 当使用 `SummingMergeTree` 或 `AggregatingMergeTree` 时,确保 `GROUP BY` 与目标表中的 `ORDER BY` 子句匹配,以允许高效的行合并。 +- **对齐 `GROUP BY ` 和 `ORDER BY ` 以提高合并效率。** 使用 `SummingMergeTree` 或 `AggregatingMergeTree` 时,确保 `GROUP BY` 与目标表中的 `ORDER BY` 子句匹配,以允许有效的行合并。 -- **使用显式的列别名。** 当表具有重叠的列名时,使用别名以防止歧义并确保目标表中的结果正确。 +- **使用显式列别名。** 当表具有重叠的列名称时,使用别名以防止歧义,并确保在目标表中得到正确结果。 -- **考虑插入量和频率。** 在适中的插入负载情况下,JOIN 表现较好。对于高吞吐量的摄入,考虑使用暂存表、预连接或其他方法,如字典和 [可刷新物化视图](/materialized-view/refreshable-materialized-view)。 +- **考虑插入量和频率。** 在适度插入负载的情况下,JOIN 效果良好。对于高吞吐量数据的摄取,考虑使用暂存表、预连接或其他方法,如字典和 [可刷新的物化视图](/materialized-view/refreshable-materialized-view)。 ### 在过滤和连接中使用源表 {#using-source-table-in-filters-and-joins-in-materialized-views} -在 ClickHouse 中使用物化视图时,了解在物化视图查询执行期间源表的处理方式是很重要的。具体而言,物化视图查询中的源表被插入的数据块替换。这种行为如果未被正确理解,可能导致一些意想不到的结果。 +在 ClickHouse 中使用物化视图时,重要的是要理解在物化视图查询执行期间源表是如何被处理的。特别是,物化视图查询中的源表会被插入的数据块替换。如果不理解这种行为,可能会导致一些意外的结果。 #### 示例场景 {#example-scenario} @@ -595,7 +596,6 @@ AS SELECT count(*) AS c0 FROM t0 LEFT JOIN ( SELECT * FROM t0 ) AS x ON t0.c0 = x.c0; - CREATE MATERIALIZED VIEW mvw2 TO mvw2_inner AS SELECT count(*) AS c0 FROM t0 @@ -620,17 +620,17 @@ SELECT * FROM mvw2; #### 解释 {#explanation} -在上述示例中,我们有两个物化视图 `mvw1` 和 `mvw2`,它们执行相似的操作,但在引用源表 `t0` 的方式上略有不同。 +在上述示例中,我们有两个物化视图 `mvw1` 和 `mvw2`,它们执行类似的操作,但在引用源表 `t0` 的方式上有细微差别。 -在 `mvw1` 中,表 `t0` 在 JOIN 的右侧的 `(SELECT * FROM t0)` 子查询中被直接引用。当数据插入到 `t0` 时,物化视图的查询使用插入的数据块替换 `t0` 执行。这意味着 JOIN 操作仅在新插入的行上执行,而不是在整个表上。 +在 `mvw1` 中,表 `t0` 直接在 JOIN 的右侧的 `(SELECT * FROM t0)` 子查询中引用。当数据插入 `t0` 中时,物化视图的查询将使用插入的数据块执行,该数据块替换了 `t0`。这意味着 JOIN 操作仅在新插入的行上进行,而不是在整个表上。 -在与 `vt0` 连接的第二种情况下,视图从 `t0` 中读取所有数据。这确保了 JOIN 操作考虑了 `t0` 中的所有行,而不仅仅是新插入的数据块。 +在第二种情况下,连接 `vt0` 时,视图读取 `t0` 中的所有数据。这确保了 JOIN 操作考虑 `t0` 中的所有行,而不仅仅是新插入的数据块。 -关键差异在于 ClickHouse 如何处理物化视图查询中的源表。当物化视图因插入而触发时,源表(在这里是 `t0`)被插入的数据块替换。这种行为可以用于查询优化,但也需要谨慎处理,以避免意外结果。 +关键的区别在于 ClickHouse 如何处理物化视图查询中的源表。当物化视图因插入而触发时,源表(在本例中为 `t0`)被插入的数据块替换。可以利用这种行为来优化查询,但也需要仔细考虑以避免意外结果。 -### 用例及注意事项 {#use-cases-and-caveats} +### 用例和注意事项 {#use-cases-and-caveats} -在实践中,您可以利用此行为来优化只需处理源表数据子集的物化视图。例如,您可以使用子查询在将源表与其他表连接之前过滤源表。这可以帮助减少物化视图处理的数据量并提高性能。 +在实践中,您可以利用此行为优化仅需处理源表数据子集的物化视图。例如,您可以使用子查询在将源表与其他表连接之前过滤源表。这可以帮助减少物化视图处理的数据量,并提高性能。 ```sql CREATE TABLE t0 (id UInt32, value String) ENGINE = MergeTree() ORDER BY id; @@ -646,11 +646,11 @@ JOIN (SELECT * FROM t1 WHERE t1.id IN (SELECT id FROM t0)) AS t1 ON t0.id = t1.id; ``` -在这个示例中,从 `IN (SELECT id FROM t0)` 子查询构建的集合仅包含新插入的行,可以帮助针对其过滤 `t1`。 +在此示例中,由 `IN (SELECT id FROM t0)` 子查询构建的集合仅包含新插入的行,这可以帮助过滤 `t1`。 -#### Stack Overflow 示例 {#example-with-stack-overflow} +#### 与 Stack Overflow 的示例 {#example-with-stack-overflow} -考虑我们之前的物化视图示例,以计算 **每个用户的每日徽章**,包括来自 `users` 表的用户显示名称。 +考虑我们之前的物化视图示例 (/materialized-view/incremental-materialized-view#example) 以计算 **每个用户的每日徽章**,包括来自 `users` 表的用户显示名称。 ```sql CREATE MATERIALIZED VIEW daily_badges_by_user_mv TO daily_badges_by_user @@ -666,7 +666,7 @@ LEFT JOIN users AS u ON b.UserId = u.Id GROUP BY Day, b.UserId, u.DisplayName; ``` -此视图对 `badges` 表的插入延迟产生了显著影响,例如: +这个视图对 `badges` 表的插入延迟产生了显著影响,例如: ```sql INSERT INTO badges VALUES (53505058, 2936484, 'gingerwizard', now(), 'Gold', 0); @@ -674,7 +674,7 @@ INSERT INTO badges VALUES (53505058, 2936484, 'gingerwizard', now(), 'Gold', 0); 1 row in set. Elapsed: 7.517 sec. ``` -利用上述方法,我们可以优化此视图。我们将通过插入徽章行中的用户 ID 来向 `users` 表添加过滤: +使用上述方法,我们可以优化此视图。我们将使用插入徽章行中的用户 ID 对 `users` 表进行过滤: ```sql CREATE MATERIALIZED VIEW daily_badges_by_user_mv TO daily_badges_by_user @@ -703,7 +703,7 @@ GROUP BY u.DisplayName ``` -这样一来,不仅加速了初始徽章插入: +这不仅加快了初始徽章插入: ```sql INSERT INTO badges SELECT * @@ -713,7 +713,7 @@ FROM s3('https://datasets-documentation.s3.eu-west-3.amazonaws.com/stackoverflow Peak memory usage: 1.99 GiB. ``` -还确保未来的徽章插入也高效: +而且还意味着未来的徽章插入也很高效: ```sql INSERT INTO badges VALUES (53505058, 2936484, 'gingerwizard', now(), 'Gold', 0); @@ -721,15 +721,15 @@ INSERT INTO badges VALUES (53505058, 2936484, 'gingerwizard', now(), 'Gold', 0); 1 row in set. Elapsed: 0.583 sec. ``` -在上述操作中,仅为用户 ID `2936484` 从用户表中检索了一行。此查找也通过 `Id` 的表排序键进行了优化。 +在上述操作中,仅为用户 ID `2936484` 从用户表检索了一行。这个查找也通过 `Id` 的表排序键进行了优化。 ## 物化视图和联合 {#materialized-views-and-unions} -`UNION ALL` 查询通常用于将来自多个源表的数据合并为一个结果集。 +`UNION ALL` 查询通常用于将多个源表的数据组合到单个结果集中。 -虽然增量物化视图不直接支持 `UNION ALL`,但是可以通过为每个 `SELECT` 分支创建一个单独的物化视图并将其结果写入一个共享的目标表来实现相同的结果。 +虽然增量物化视图不直接支持 `UNION ALL`,但您可以通过为每个 `SELECT` 分支创建一个单独的物化视图并将其结果写入共享目标表来实现相同的结果。 -在我们的示例中,我们将使用 Stack Overflow 数据集。考虑以下 `badges` 和 `comments` 表,它们分别表示用户获得的徽章和他们对帖子的评论: +作为例子,我们将使用 Stack Overflow 数据集。考虑以下的 `badges` 和 `comments` 表,分别表示用户获得的徽章以及他们对帖子所做的评论: ```sql CREATE TABLE stackoverflow.comments @@ -758,7 +758,7 @@ ENGINE = MergeTree ORDER BY UserId ``` -可以使用以下 `INSERT INTO` 命令填充这些表: +这些可以通过以下 `INSERT INTO` 命令填充: ```sql INSERT INTO stackoverflow.badges SELECT * @@ -767,7 +767,7 @@ INSERT INTO stackoverflow.comments SELECT * FROM s3('https://datasets-documentation.s3.eu-west-3.amazonaws.com/stackoverflow/parquet/comments/*.parquet') ``` -假设我们想创建一个用户活动的统一视图,显示每个用户的最后活动,通过合并这两个表: +假设我们希望创建一个用户活动的统一视图,显示每个用户的最后活动,通过组合这两个表: ```sql SELECT @@ -796,7 +796,7 @@ ORDER BY last_activity DESC LIMIT 10 ``` -假设我们有一个目标表来接收该查询的结果。请注意使用了 [AggregatingMergeTree](/engines/table-engines/mergetree-family/aggregatingmergetree) 表引擎和 [AggregateFunction](/sql-reference/data-types/aggregatefunction),以确保结果正确合并: +假设我们有一个目标表来接收此查询的结果。注意使用 [AggregatingMergeTree](/engines/table-engines/mergetree-family/aggregatingmergetree) 表引擎和 [AggregateFunction](/sql-reference/data-types/aggregatefunction) 以确保结果正确合并: ```sql CREATE TABLE user_activity @@ -810,7 +810,7 @@ ENGINE = AggregatingMergeTree ORDER BY UserId ``` -希望此表在对 `badges` 或 `comments` 插入新行时更新,解决此问题的简单方法可能是尝试使用先前的联合查询创建一个物化视图: +希望这个表在向 `badges` 或 `comments` 中插入新行时更新,简单的方法可能是尝试根据前面的联合查询创建一个物化视图: ```sql CREATE MATERIALIZED VIEW user_activity_mv TO user_activity AS @@ -839,7 +839,7 @@ GROUP BY UserId ORDER BY last_activity DESC ``` -虽然在语法上是有效的,但它会产生意外的结果 - 该视图只会触发对 `comments` 表的插入。例如: +虽然这在语法上是有效的,但会产生意想不到的结果 - 视图仅会触发对 `comments` 表的插入。例如: ```sql INSERT INTO comments VALUES (99999999, 23121, 1, 'The answer is 42', now(), 2936484, 'gingerwizard'); @@ -860,7 +860,7 @@ GROUP BY UserId 1 row in set. Elapsed: 0.005 sec. ``` -对 `badges` 表的插入将不会触发视图更新,导致 `user_activity` 不会接收更新: +对 `badges` 表的插入将不会触发视图,导致 `user_activity` 无法接收更新: ```sql INSERT INTO badges VALUES (53505058, 2936484, 'gingerwizard', now(), 'Gold', 0); @@ -906,7 +906,7 @@ FROM stackoverflow.badges GROUP BY UserId; ``` -现在,无论插入到哪个表都将得到正确的结果。例如,如果我们插入到 `comments` 表: +现在向任一表插入新行都会产生正确的结果。例如,如果我们向 `comments` 表中插入: ```sql INSERT INTO comments VALUES (99999999, 23121, 1, 'The answer is 42', now(), 2936484, 'gingerwizard'); @@ -927,7 +927,7 @@ GROUP BY UserId; 1 row in set. Elapsed: 0.006 sec. ``` -同样,插入 `badges` 表的操作也会反映在 `user_activity` 表中: +同样,对 `badges` 表的插入也会在 `user_activity` 表中反映出来: ```sql INSERT INTO badges VALUES (53505058, 2936484, 'gingerwizard', now(), 'Gold', 0); @@ -948,13 +948,13 @@ GROUP BY UserId 1 row in set. Elapsed: 0.006 sec. ``` -## 并行与顺序处理 {#materialized-views-parallel-vs-sequential} +## 并行与串行处理 {#materialized-views-parallel-vs-sequential} -如前例所示,一个表可以作为多个物化视图的源。它们的执行顺序取决于设置 [`parallel_view_processing`](/operations/settings/settings#parallel_view_processing)。 +如前一示例所示,表可以作为多个物化视图的源。执行这些视图的顺序取决于设置 [`parallel_view_processing`](/operations/settings/settings#parallel_view_processing)。 -默认情况下,此设置等于 `0` (`false`),这意味着物化视图按 `uuid` 顺序顺序执行。 +默认情况下,该设置等于 `0`(`false`),意味着物化视图按 `uuid` 顺序顺序执行。 -例如,考虑以下 `source` 表和 3 个物化视图,每个视图向一个 `target` 表发送行: +例如,考虑以下 `source` 表和 3 个物化视图,每个视图将行发送到一个 `target` 表: ```sql CREATE TABLE source @@ -999,9 +999,9 @@ AS SELECT FROM source; ``` -请注意,每个视图在将其行插入到 `target` 表之前延迟 1 秒,同时还包括其名称和插入时间。 +请注意,每个视图在将其行插入目标表之前会暂停 1 秒,同时还附加了它们的名称和插入时间。 -将行插入到表 `source` 需要约 3 秒,每个视图依次执行: +向 `source` 表插入一行需时约 3 秒,每个视图顺序执行: ```sql INSERT INTO source VALUES ('test') @@ -1009,7 +1009,7 @@ INSERT INTO source VALUES ('test') 1 row in set. Elapsed: 3.786 sec. ``` -我们可以通过 `SELECT` 确认来自每一行的信息: +我们可以通过 `SELECT` 确认每行的到达: ```sql SELECT @@ -1028,7 +1028,7 @@ ORDER BY now ASC 3 rows in set. Elapsed: 0.015 sec. ``` -这与视图的 `uuid` 对齐: +这与视图的 `uuid` 一致: ```sql SELECT @@ -1047,7 +1047,7 @@ ORDER BY uuid ASC 3 rows in set. Elapsed: 0.004 sec. ``` -相反,考虑如果启用 `parallel_view_processing=1` 时会发生什么。在启用此选项时,视图并行执行,不保证行到达目标表的顺序: +相反,考虑如果插入一行并启用 `parallel_view_processing=1` 后会发生什么。在启用此项时,视图并行执行,因此不会保证行到达目标表的顺序: ```sql TRUNCATE target; @@ -1073,40 +1073,39 @@ ORDER BY now ASC 3 rows in set. Elapsed: 0.004 sec. ``` -尽管我们从每个视图到达行的顺序是相同的,但这并不是保证的 - 正如每行的插入时间相似所示。此外还要注意插入性能的提高。 +尽管我们从每个视图到达行的顺序相同,但这并不保证 - 如每行的插入时间相似所示。另外请注意,插入性能有所提高。 ### 何时使用并行处理 {#materialized-views-when-to-use-parallel} -启用 `parallel_view_processing=1` 可以显著提高插入吞吐量,尤其是当多个物化视图附加到同一表时,如上所示。然而,了解权衡是很重要的: +启用 `parallel_view_processing=1` 可以显著提高插入吞吐量,如上所示,特别是在多个物化视图附加到单个表时。然而,理解其权衡非常重要: -- **增加插入压力**:所有物化视图同时执行,增加了 CPU 和内存使用。如果每个视图执行沉重的计算或 JOIN,这可能会导致系统过载。 -- **需要严格的执行顺序**:在某些少见的工作流程中,如果视图执行顺序很重要(例如,链式依赖),并行执行可能会导致不一致状态或竞争条件。虽然可以设计解决此问题,但这种设置是脆弱的,可能会在未来版本中失效。 +- **增加插入压力**:所有物化视图同时执行,增加CPU和内存使用。如果每个视图执行大量计算或 JOIN,这可能超载系统。 +- **需要严格的执行顺序**:在视图执行顺序很重要的少数工作流中(例如,链式依赖),并行执行可能导致不一致状态或竞争条件。虽然有可能在这方面进行设计,但这种设置较为脆弱,可能随未来版本破坏。 -:::note 历史默认值和稳定性 -顺序执行长期以来一直是默认选项,部分原因是错误处理的复杂性。在历史上,一个物化视图中的失败可能会阻止其他视图执行。较新版本通过对每个块隔离故障来改善这一点,但顺序执行仍提供了更清晰的故障语义。 +:::note 历史默认设置与稳定性 +顺序执行长期以来是默认设置,部分原因是错误处理的复杂性。历史上,单个物化视图的故障可能阻止其他物化视图的执行。新版本通过对每个数据块隔离故障来改善这一点,但顺序执行仍提供了更清晰的故障语义。 ::: -一般来说,当: - -- 您有多个独立的物化视图 -- 您的目标是最大化插入性能 -- 您了解系统的处理并发视图执行的容量时,可以启用 `parallel_view_processing=1`。 +一般而言,在以下情况下启用 `parallel_view_processing=1`: -当: +- 您拥有多个独立的物化视图 +- 您希望最大化插入性能 +- 您意识到系统能够处理并发视图执行的能力 -- 物化视图之间存在依赖关系时 -- 您要求可预测、有序的执行 -- 您正在调试或审计插入行为并希望进行确定性重放时,请禁用此选项。 +在以下情况下禁用它: +- 物化视图相互依赖 +- 您需要可预测的、有序执行 +- 您正在调试或审计插入行为,需要确定性回放 -## 物化视图和公共表表达式 (CTE) {#materialized-views-common-table-expressions-ctes} +## 物化视图和公共表表达式(CTE) {#materialized-views-common-table-expressions-ctes} -**非递归** 公共表表达式 (CTE) 在物化视图中受支持。 +**非递归** 公共表表达式(CTE)在物化视图中得到支持。 -:::note 公共表表达式 **不是** 被物化 -ClickHouse 不会物化 CTE;相反,它会直接将 CTE 定义替换到查询中,这可能导致相同表达式的多次评估(如果 CTE 被多次使用)。 +:::note 公共表表达式 **不是** 物化的 +ClickHouse 不会物化 CTE;而是直接将 CTE 定义替换为查询中,这可能导致对相同表达式的多次评估(如果 CTE 被多次使用)。 ::: -考虑以下示例,该示例计算每种帖子类型的每日活动。 +考虑以下示例,它计算每种帖子类型的每日活动。 ```sql CREATE TABLE daily_post_activity @@ -1143,7 +1142,7 @@ FROM filtered_posts GROUP BY Day, PostTypeId; ``` -虽然 CTE 在这里严格来说是不必要的,但为了示例目的,视图会按预期工作: +虽然这里严格没有必要使用 CTE,但作为示例,视图按预期工作: ```sql INSERT INTO posts @@ -1182,10 +1181,10 @@ LIMIT 10 Peak memory usage: 989.53 KiB. ``` -在 ClickHouse 中,CTE 被内联,这意味着它们在优化期间会有效地被复制到查询中,**而不** 是被物化。这意味着: +在 ClickHouse 中,CTE 是内联的,这意味着它们在优化时有效地被复制粘贴到查询中,而 **不** 进行物化。这意味着: -- 如果您的 CTE 引用与源表(即物化视图附加到的表)不同的表,并且在 `JOIN` 或 `IN` 子句中使用,它将表现得像子查询或连接,而不是触发器。 -- 物化视图仍然仅在主要源表插入时触发,但 CTE 会在每次插入时重新执行,这可能导致不必要的开销,特别是当引用的表很大时。 +- 如果您的 CTE 引用的表与物化视图附加的源表不同(即,该物化视图附加到的表),并在 `JOIN` 或 `IN` 子句中使用,它将表现得像子查询或连接,而不是触发器。 +- 物化视图仍然仅在主源表插入时触发,但 CTE 将在每次插入时重新执行,这可能导致不必要的开销,尤其是如果引用的表很大的话。 例如, @@ -1196,6 +1195,6 @@ WITH recent_users AS ( SELECT * FROM stackoverflow.posts WHERE OwnerUserId IN (SELECT Id FROM recent_users) ``` -在该情况下,用户 CTE 会在每次插入到帖子时重新评估,而物化视图不会在新用户插入时更新 - 仅在帖子时更新。 +在此情况下,`users` CTE 在每次插入 `posts` 时都会重新评估,并且物化视图在插入新用户时不会更新 - 仅在插入帖子时才会更新。 -一般来说,对于在物化视图附加的源表上操作的逻辑使用 CTE,或者确保引用的表很小且不太可能导致性能瓶颈。或者,考虑 [与物化视图的 JOIN 相同的优化](/materialized-view/incremental-materialized-view#join-best-practices)。 +一般来说,使用 CTE 处理与物化视图附加到的同一源表的数据,或者确保引用的表很小且不太可能导致性能瓶颈。或者,考虑 [物化视图 JOIN 的相同优化](/materialized-view/incremental-materialized-view#join-best-practices)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/materialized-view/incremental-materialized-view.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/materialized-view/incremental-materialized-view.md.hash index 89a0474115f..a827290a353 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/materialized-view/incremental-materialized-view.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/materialized-view/incremental-materialized-view.md.hash @@ -1 +1 @@ -b9c7b458c4782226 +4ba6951a40e4c80f diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/materialized-view/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/materialized-view/index.md index 282512ccda6..37791b5c67c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/materialized-view/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/materialized-view/index.md @@ -8,12 +8,12 @@ - 'query optimization' - 'refreshable' - 'incremental' +'doc_type': 'landing-page' --- -| 页面 | 描述 | -|----------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| [增量物化视图](/materialized-view/incremental-materialized-view) | 允许用户将计算成本从查询时间转移到插入时间,从而使 `SELECT` 查询更快。 | -| [可刷新物化视图](/materialized-view/refreshable-materialized-view) | 在概念上类似于增量物化视图,但要求定期在完整数据集上执行查询 - 其结果存储在目标表中以供查询。 | - +| 页面 | 描述 | +|-------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| [增量物化视图](/materialized-view/incremental-materialized-view) | 允许用户将计算成本从查询时间转移到插入时间,从而加快 `SELECT` 查询的速度。 | +| [可刷新物化视图](/materialized-view/refreshable-materialized-view) | 概念上类似于增量物化视图,但需要定期对完整数据集执行查询——其结果存储在目标表中以供查询。 | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/materialized-view/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/materialized-view/index.md.hash index 1b09a32add0..14d133dbabf 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/materialized-view/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/materialized-view/index.md.hash @@ -1 +1 @@ -411e5208a8030227 +8234ceb83a6c5042 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/materialized-view/refreshable-materialized-view.md b/i18n/zh/docusaurus-plugin-content-docs/current/materialized-view/refreshable-materialized-view.md index a85bcaf8450..09b74d6d0ab 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/materialized-view/refreshable-materialized-view.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/materialized-view/refreshable-materialized-view.md @@ -1,39 +1,40 @@ --- 'slug': '/materialized-view/refreshable-materialized-view' -'title': '可刷新物化视图' -'description': '如何使用物化视图来加快 查询' +'title': '可刷新的物化视图' +'description': '如何使用物化视图来加速查询' 'keywords': - 'refreshable materialized view' - 'refresh' - 'materialized views' - 'speed up queries' - 'query optimization' +'doc_type': 'guide' --- import refreshableMaterializedViewDiagram from '@site/static/images/materialized-view/refreshable-materialized-view-diagram.png'; import Image from '@theme/IdealImage'; -[可刷新的物化视图](/sql-reference/statements/create/view#refreshable-materialized-view) 在概念上与传统 OLTP 数据库中的物化视图类似,存储指定查询的结果以便于快速检索,从而减少重复执行资源密集型查询的需要。与 ClickHouse 的 [增量物化视图](/materialized-view/incremental-materialized-view) 不同,这需要定期在完整数据集上执行查询 - 其结果存储在目标表中以供查询。理论上,这个结果集应该小于原始数据集,从而使后续查询能够更快地执行。 +[可刷新的物化视图](/sql-reference/statements/create/view#refreshable-materialized-view) 在概念上类似于传统 OLTP 数据库中的物化视图,存储指定查询的结果以便于快速检索,从而减少反复执行资源密集型查询的需求。与 ClickHouse 的[增量物化视图](/materialized-view/incremental-materialized-view)不同,这需要定期在整个数据集上执行查询 - 其结果存储在目标表中以供查询。理论上,这个结果集应该比原始数据集小,从而使后续查询执行得更快。 -下图说明了可刷新的物化视图是如何工作的: +下图解释了可刷新的物化视图的工作原理: -您还可以查看以下视频: +您还可以观看以下视频: -## 何时使用可刷新的物化视图? {#when-should-refreshable-materialized-views-be-used} +## 何时应使用可刷新的物化视图? {#when-should-refreshable-materialized-views-be-used} -ClickHouse 的增量物化视图功能强大,并且通常比可刷新的物化视图所使用的方法更具扩展性,特别是在需要对单个表执行聚合操作的情况下。通过仅在每个数据块插入时计算聚合,并在最终表中合并增量状态,查询仅在数据的一个子集上执行。这种方法可扩展到潜在的 PB 级数据,通常是首选方法。 +ClickHouse 的增量物化视图功能强大,并且通常比可刷新的物化视图使用的方案扩展性更佳,尤其是当需要对单个表进行聚合时。通过仅在每个数据块插入时计算聚合,并在最终表中合并增量状态,查询仅在数据的子集上执行。这种方法可以扩展到 PB 的数据量,并通常是首选方法。 -然而,有些用例并不需要或不适合这种增量处理。一些问题与增量方法不兼容或不需要实时更新,周期性重建更为合适。例如,您可能希望定期在完整数据集上执行视图的完全重新计算,因为它使用了复杂的连接,而这与增量方法不兼容。 +然而,在某些用例中,这一增量过程并非总是必要或适用。有些问题要么与增量方法不兼容,要么不需要实时更新,而是更适合定期重建。例如,您可能希望定期对全数据集执行完整的视图重新计算,因为它使用了复杂的连接,这与增量方法不兼容。 -> 可刷新的物化视图可以运行批处理过程,执行诸如反规范化之类的任务。可以在可刷新的物化视图之间创建依赖关系,使一个视图依赖于另一个视图的结果,并且仅在其完成后执行。这可以替代计划工作流或简单的 DAG,例如 [dbt](https://www.getdbt.com/) 作业。要了解有关如何在可刷新的物化视图之间设置依赖关系的更多信息,请参见 [创建视图](/sql-reference/statements/create/view#refresh-dependencies) 的 `Dependencies` 部分。 +> 可刷新的物化视图可以运行批处理流程执行诸如去规范化的任务。可以在可刷新的物化视图之间创建依赖关系,使得一个视图依赖于另一个视图的结果,只有在完成后才会执行。这可以替代计划工作流程或简单的 DAG,例如 [dbt](https://www.getdbt.com/) 作业。要了解有关如何在可刷新的物化视图之间设置依赖关系的更多信息,请访问 [CREATE VIEW](/sql-reference/statements/create/view#refresh-dependencies) 的 `Dependencies` 部分。 ## 如何刷新可刷新的物化视图? {#how-do-you-refresh-a-refreshable-materialized-view} -可刷新的物化视图会在创建时定义的间隔上自动刷新。 +可刷新的物化视图会在创建时定义的间隔内自动刷新。 例如,以下物化视图每分钟刷新一次: ```sql @@ -48,10 +49,10 @@ REFRESH EVERY 1 MINUTE TO table_name AS SYSTEM REFRESH VIEW table_name_mv; ``` -您还可以取消、停止或启动视图。 -有关更多详细信息,请参见 [管理可刷新的物化视图](/sql-reference/statements/system#refreshable-materialized-views) 文档。 +您还可以取消、停止或启动一个视图。 +有关更多详细信息,请参阅 [管理可刷新的物化视图](/sql-reference/statements/system#refreshable-materialized-views) 文档。 -## 最近一次刷新可刷新的物化视图是什么时候? {#when-was-a-refreshable-materialized-view-last-refreshed} +## 可刷新的物化视图上次刷新是什么时候? {#when-was-a-refreshable-materialized-view-last-refreshed} 要查找可刷新的物化视图上次刷新的时间,您可以查询 [`system.view_refreshes`](/operations/system-tables/view_refreshes) 系统表,如下所示: @@ -77,7 +78,7 @@ ALTER TABLE table_name_mv MODIFY REFRESH EVERY 30 SECONDS; ``` -完成后,您可以使用 [最近一次刷新可刷新的物化视图是什么时候?](/materialized-view/refreshable-materialized-view#when-was-a-refreshable-materialized-view-last-refreshed) 查询以检查频率是否已更新: +完成后,您可以使用 [可刷新的物化视图上次刷新是什么时候?](/materialized-view/refreshable-materialized-view#when-was-a-refreshable-materialized-view-last-refreshed) 查询来检查刷新频率是否已更新: ```text ┌─database─┬─view─────────────┬─status────┬───last_success_time─┬───last_refresh_time─┬───next_refresh_time─┬─read_rows─┬─written_rows─┐ @@ -89,7 +90,7 @@ MODIFY REFRESH EVERY 30 SECONDS; `APPEND` 功能允许您将新行添加到表的末尾,而不是替换整个视图。 -此功能的一个用途是在某个时间点捕获值的快照。例如,假设我们有一个 `events` 表,由来自 [Kafka](https://kafka.apache.org/)、 [Redpanda](https://www.redpanda.com/) 或其他流数据平台的消息流填充。 +此功能的一个用法是在某个时点捕获值的快照。例如,假设我们有一个 `events` 表,由来自 [Kafka](https://kafka.apache.org/)、[Redpanda](https://www.redpanda.com/) 或其他流数据平台的消息流填充。 ```sql SELECT * @@ -112,7 +113,7 @@ Query id: 7662bc39-aaf9-42bd-b6c7-bc94f2881036 └─────────────────────┴──────┴───────┘ ``` -该数据集在 `uuid` 列中有 `4096` 个值。我们可以编写以下查询来查找出现总数最高的那些: +该数据集在 `uuid` 列中有 `4096` 个值。我们可以编写以下查询以查找计数最高的值: ```sql SELECT @@ -137,7 +138,7 @@ LIMIT 10 └──────┴─────────┘ ``` -假设我们想要每 10 秒捕获一次每个 `uuid` 的计数,并将其存储在一个名为 `events_snapshot` 的新表中。 `events_snapshot` 的模式如下所示: +假设我们想每 10 秒捕获一次每个 `uuid` 的计数,并将其存储在一个名为 `events_snapshot` 的新表中。`events_snapshot` 的架构如下: ```sql CREATE TABLE events_snapshot ( @@ -149,7 +150,7 @@ ENGINE = MergeTree ORDER BY uuid; ``` -然后,我们可以创建一个可刷新的物化视图来填充此表: +然后我们可以创建一个可刷新的物化视图以填充这个表: ```sql CREATE MATERIALIZED VIEW events_snapshot_mv @@ -162,7 +163,7 @@ FROM events GROUP BY ALL; ``` -接下来,我们可以查询 `events_snapshot` 来获取特定 `uuid` 随时间变化的计数: +然后我们可以查询 `events_snapshot` 以获取特定 `uuid` 随时间变化的计数: ```sql SELECT * @@ -185,13 +186,13 @@ FORMAT PrettyCompactMonoBlock ## 示例 {#examples} -现在让我们看一下如何使用可刷新的物化视图和一些示例数据集。 +现在我们来看一些如何使用可刷新的物化视图的示例数据集。 ### Stack Overflow {#stack-overflow} -[反规范化数据指南](/data-modeling/denormalization) 显示了使用 Stack Overflow 数据集反规范化数据的各种技术。我们将数据填充到以下表中: `votes`、`users`、`badges`、`posts` 和 `postlinks`。 +[去规范化数据指南](/data-modeling/denormalization)展示了使用 Stack Overflow 数据集进行去规范化的各种技术。我们向以下表中填充数据:`votes`、`users`、`badges`、`posts` 和 `postlinks`。 -在该指南中,我们展示了如何使用以下查询将 `postlinks` 数据集反规范化到 `posts` 表中: +在该指南中,我们展示了如何使用以下查询将 `postlinks` 数据集去规范化到 `posts` 表中: ```sql SELECT @@ -208,11 +209,11 @@ LEFT JOIN ( ) AS postlinks ON posts_types_codecs_ordered.Id = postlinks.PostId; ``` -我们随后展示了如何一次性将这些数据插入 `posts_with_links` 表,但在生产系统中,我们希望定期运行此操作。 +然后我们展示了如何将此数据一次性插入到 `posts_with_links` 表中,但在生产系统中,我们希望定期运行此操作。 -`posts` 和 `postlinks` 表都可能会更新。因此,与其尝试使用增量物化视图实现连接,不如简单地安排此查询在设定的间隔内运行,例如每小时一次,将结果存储在 `post_with_links` 表中。 +`posts` 和 `postlinks` 表都可能会被更新。因此,与其尝试使用增量物化视图来实现这个连接,不如简单地安排这个查询在设定的时间间隔内运行,例如每小时运行一次,结果存储在 `post_with_links` 表中。 -这就是可刷新的物化视图可以派上用场的地方,我们可以通过以下查询创建一个: +这就是可刷新的物化视图的帮助所在,我们可以使用以下查询创建一个: ```sql CREATE MATERIALIZED VIEW posts_with_links_mv @@ -231,17 +232,17 @@ LEFT JOIN ( ) AS postlinks ON posts_types_codecs_ordered.Id = postlinks.PostId; ``` -该视图将立即执行,并在之后的每小时按配置执行,以确保源表的更新得以反映。重要的是,当查询重新运行时,结果集会原子性和透明地更新。 +视图会立即执行,并且会根据配置每小时执行一次,以确保对源表的更新得到反映。重要的是,当查询重新运行时,结果集会以原子方式和透明地更新。 :::note -此处的语法与增量物化视图相同,只是我们添加了 [`REFRESH`](/sql-reference/statements/create/view#refreshable-materialized-view) 子句: +此处的语法与增量物化视图相同,只是我们包含了 [`REFRESH`](/sql-reference/statements/create/view#refreshable-materialized-view) 子句: ::: ### IMDb {#imdb} -在 [dbt 和 ClickHouse 集成指南](/integrations/dbt#dbt) 中,我们使用以下表填充了 IMDb 数据集: `actors`、`directors`、`genres`、`movie_directors`、`movies` 和 `roles`。 +在 [dbt 和 ClickHouse 集成指南](/integrations/dbt) 中,我们使用以下表填充了 IMDb 数据集:`actors`、`directors`、`genres`、`movie_directors`、`movies` 和 `roles`。 -然后,我们可以编写以下查询来计算每个演员的摘要,按电影出场次数排序。 +然后我们可以编写以下查询,以根据电影出场次数对每位演员进行总结。 ```sql SELECT @@ -280,10 +281,10 @@ LIMIT 5; Peak memory usage: 1.38 GiB. ``` -返回结果的时间不长,但假设我们希望它更快,并且计算成本更低。 -假设该数据集也受到持续更新的影响 - 不断有电影上映,新演员和导演也不断涌现。 +返回结果并不会花太长时间,但假设我们希望它更快且计算成本更低。 +假设该数据集也在不断更新 - 新电影不断发布,新的演员和导演也不断出现。 -现在是可刷新的物化视图的时机,所以我们首先为结果创建一个目标表: +现在是可刷新的物化视图的时候,所以让我们首先为结果创建一个目标表: ```sql CREATE TABLE imdb.actor_summary @@ -334,7 +335,7 @@ GROUP BY id ORDER BY num_movies DESC; ``` -该视图将立即执行,并在之后的每分钟按配置执行,以确保源表的更新被反映。我们先前用于获取演员摘要的查询在语法上变得更简单,速度也显着提高! +视图会立即执行,并会根据配置每分钟执行一次,以确保对源表的更新得到反映。我们之前的查询以获取演员的摘要变得在语法上更简单,并且速度显著提升! ```sql SELECT * @@ -355,7 +356,7 @@ LIMIT 5 5 rows in set. Elapsed: 0.007 sec. ``` -假设我们添加了一位新演员 “Clicky McClickHouse” 到我们的源数据,恰好出现在许多电影中! +假设我们向源数据中添加了一位新演员 "Clicky McClickHouse",他刚好在很多电影中出现过! ```sql INSERT INTO imdb.actors VALUES (845466, 'Clicky', 'McClickHouse', 'M'); @@ -368,7 +369,7 @@ FROM imdb.movies LIMIT 10000, 910; ``` -不到 60 秒后,我们的目标表已更新,以反映 Clicky 出色的演技: +不到 60 秒后,我们的目标表已更新,以反映 Clicky 出色的演出情况: ```sql SELECT * diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/materialized-view/refreshable-materialized-view.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/materialized-view/refreshable-materialized-view.md.hash index d1a2a956358..21487ccfb12 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/materialized-view/refreshable-materialized-view.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/materialized-view/refreshable-materialized-view.md.hash @@ -1 +1 @@ -1a91ae2a986d89a8 +dc4dccc565d6cb76 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/migrations/bigquery/equivalent-concepts.md b/i18n/zh/docusaurus-plugin-content-docs/current/migrations/bigquery/equivalent-concepts.md deleted file mode 100644 index 521c54b2780..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/migrations/bigquery/equivalent-concepts.md +++ /dev/null @@ -1,480 +0,0 @@ ---- -'title': 'BigQuery 与 ClickHouse Cloud' -'slug': '/migrations/bigquery/biquery-vs-clickhouse-cloud' -'description': 'BigQuery 如何与 ClickHouse Cloud 不同' -'keywords': -- 'BigQuery' -'show_related_blogs': true ---- - -import bigquery_1 from '@site/static/images/migrations/bigquery-1.png'; -import Image from '@theme/IdealImage'; - - -# BigQuery 与 ClickHouse Cloud:相同和不同的概念 - -## 资源组织 {#resource-organization} - -ClickHouse Cloud 中资源的组织方式类似于 [BigQuery的资源层次结构](https://cloud.google.com/bigquery/docs/resource-hierarchy)。我们根据下方显示的 ClickHouse Cloud 资源层次结构图描述具体的差异: - - - -### 组织 {#organizations} - -与 BigQuery 类似,组织是 ClickHouse Cloud 资源层次结构中的根节点。您在 ClickHouse Cloud 帐户中设置的第一个用户将自动分配到由用户拥有的组织。该用户可以邀请其他用户加入组织。 - -### BigQuery 项目与 ClickHouse Cloud 服务 {#bigquery-projects-vs-clickhouse-cloud-services} - -在组织内,您可以创建与 BigQuery 项目大致相当的服务,因为 ClickHouse Cloud 中存储的数据与服务相关联。在 ClickHouse Cloud 中有 [几种可用的服务类型](/cloud/manage/cloud-tiers)。每个 ClickHouse Cloud 服务部署在特定区域,并包括: - -1. 一组计算节点(目前,开发级服务为 2 个节点,生产级服务为 3 个节点)。对于这些节点,ClickHouse Cloud [支持垂直和水平扩展](/manage/scaling#how-scaling-works-in-clickhouse-cloud),包括手动和自动扩展。 -2. 一个对象存储文件夹,服务在其中存储所有数据。 -3. 一个端点(或通过 ClickHouse Cloud UI 控制台创建的多个端点)- 您用来连接到服务的服务 URL(例如,`https://dv2fzne24g.us-east-1.aws.clickhouse.cloud:8443`) - -### BigQuery 数据集与 ClickHouse Cloud 数据库 {#bigquery-datasets-vs-clickhouse-cloud-databases} - -ClickHouse 将表逻辑上分组到数据库中。与 BigQuery 数据集类似,ClickHouse 数据库是组织和控制访问表数据的逻辑容器。 - -### BigQuery 文件夹 {#bigquery-folders} - -ClickHouse Cloud 目前没有与 BigQuery 文件夹类似的概念。 - -### BigQuery 插槽保留和配额 {#bigquery-slot-reservations-and-quotas} - -与 BigQuery 插槽保留类似,您可以 [配置 ClickHouse Cloud 中的垂直和水平自动扩展](/manage/scaling#configuring-vertical-auto-scaling)。对于垂直自动扩展,您可以设置服务计算节点的内存和 CPU 核心的最小和最大大小。然后,服务将根据需要在这些范围内进行扩展。这些设置也可在初始服务创建流程中使用。服务中的每个计算节点大小相同。您可以使用 [水平扩展](/manage/scaling#manual-horizontal-scaling) 更改服务中的计算节点数量。 - -此外,与 BigQuery 配额类似,ClickHouse Cloud 提供并发控制、内存使用限制和 I/O 调度,使用户能够将查询隔离到工作负载类别中。通过对特定工作负载类别设定共享资源(CPU 核心、DRAM、磁盘和网络 I/O)的限制,可以确保这些查询不会影响其他关键业务查询。在并发查询数量较多的场景中,并发控制可以防止线程过度订阅。 - -ClickHouse 在服务器、用户和查询级别跟踪内存分配的字节大小,从而允许灵活的内存使用限制。内存超分配使查询能够使用保证内存之外的额外空闲内存,同时确保其他查询的内存限制。此外,还可以限制聚合、排序和连接子句的内存使用,当超过内存限制时允许回退到外部算法。 - -最后,I/O 调度允许用户根据最大带宽、进行中的请求和策略限制工作负载类别的本地和远程磁盘访问。 - -### 权限 {#permissions} - -ClickHouse Cloud [在两个地方控制用户访问](/cloud/security/cloud-access-management),通过 [云控制台](/cloud/get-started/sql-console) 和数据库。控制台访问通过 [clickhouse.cloud](https://console.clickhouse.cloud) 用户界面进行管理。数据库访问通过数据库用户帐户和角色进行管理。此外,控制台用户可以在数据库中被授予角色,从而使控制台用户能够通过我们的 [SQL 控制台](/integrations/sql-clients/sql-console) 与数据库进行交互。 - -## 数据类型 {#data-types} - -ClickHouse 在数值方面提供了更细粒度的精度。例如,BigQuery 提供了数值类型 [`INT64`, `NUMERIC`, `BIGNUMERIC` 和 `FLOAT64`](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#numeric_types)。将这些与 ClickHouse 进行对比,后者为十进制、浮点数和整数提供了多种精度类型。利用这些数据类型,ClickHouse 用户可以优化存储和内存开销,从而提高查询速度并降低资源消耗。以下是每个 BigQuery 类型对应的 ClickHouse 类型: - -| BigQuery | ClickHouse | -|----------|------------| -| [ARRAY](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#array_type) | [Array(t)](/sql-reference/data-types/array) | -| [NUMERIC](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#decimal_types) | [Decimal(P, S), Decimal32(S), Decimal64(S), Decimal128(S)](/sql-reference/data-types/decimal) | -| [BIG NUMERIC](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#decimal_types) | [Decimal256(S)](/sql-reference/data-types/decimal) | -| [BOOL](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#boolean_type) | [Bool](/sql-reference/data-types/boolean) | -| [BYTES](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#bytes_type) | [FixedString](/sql-reference/data-types/fixedstring) | -| [DATE](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#date_type) | [Date32](/sql-reference/data-types/date32) (范围更窄) | -| [DATETIME](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#datetime_type) | [DateTime](/sql-reference/data-types/datetime), [DateTime64](/sql-reference/data-types/datetime64) (范围窄,精度更高) | -| [FLOAT64](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#floating_point_types) | [Float64](/sql-reference/data-types/float) | -| [GEOGRAPHY](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#geography_type) | [Geo 数据类型](/sql-reference/data-types/float) | -| [INT64](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#integer_types) | [UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256](/sql-reference/data-types/int-uint) | -| [INTERVAL](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#integer_types) | NA - [作为表达式支持](/sql-reference/data-types/special-data-types/interval#usage-remarks) 或 [通过函数](/sql-reference/functions/date-time-functions#addyears) | -| [JSON](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#json_type) | [JSON](/integrations/data-formats/json/inference) | -| [STRING](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#string_type) | [String (bytes)](/sql-reference/data-types/string) | -| [STRUCT](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#constructing_a_struct) | [Tuple](/sql-reference/data-types/tuple), [Nested](/sql-reference/data-types/nested-data-structures/nested) | -| [TIME](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#time_type) | [DateTime64](/sql-reference/data-types/datetime64) | -| [TIMESTAMP](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#timestamp_type) | [DateTime64](/sql-reference/data-types/datetime64) | - -在面对 ClickHouse 类型的多个选项时,请考虑数据的实际范围并选择最低要求。同时,还应考虑利用 [适当的编解码器](https://clickhouse.com/blog/optimize-clickhouse-codecs-compression-schema) 进行进一步压缩。 - -## 查询加速技术 {#query-acceleration-techniques} - -### 主键和外键以及主索引 {#primary-and-foreign-keys-and-primary-index} - -在 BigQuery 中,表可以有 [主键和外键约束](https://cloud.google.com/bigquery/docs/information-schema-table-constraints)。通常,主键和外键用于关系型数据库中以确保数据完整性。主键值通常对于每一行都是唯一且不能为 `NULL`。每个行中的外键值必须存在于主键表的主键列中或为 `NULL`。在 BigQuery 中,这些约束并不强制执行,但查询优化器可以利用此信息更好地优化查询。 - -在 ClickHouse 中,表也可以有一个主键。与 BigQuery 类似,ClickHouse 不强制主键列值的唯一性。不同于 BigQuery,表中的数据在磁盘上是按照主键列的 [排序存储](/guides/best-practices/sparse-primary-indexes#optimal-compression-ratio-of-data-files)。查询优化器利用这种排序来防止重新排序,以最小化连接的内存使用,并为限制子句启用短路。与 BigQuery 不同,ClickHouse 会基于主键列值自动创建 [(稀疏)主索引](/guides/best-practices/sparse-primary-indexes#an-index-design-for-massive-data-scales)。此索引用于加速所有包含主键列过滤器的查询。当前,ClickHouse 不支持外键约束。 - -## 二级索引(只在 ClickHouse 中可用) {#secondary-indexes-only-available-in-clickhouse} - -除了从表的主键列值生成的主索引外,ClickHouse 允许您在主键之外的列上创建二级索引。ClickHouse 提供了多种类型的二级索引,每种适用于不同类型的查询: - -- **布隆过滤器索引**: - - 用于加速具有相等条件的查询(例如,=, IN)。 - - 使用概率数据结构确定某值是否存在于数据块中。 -- **令牌布隆过滤器索引**: - - 类似于布隆过滤器索引,但用于标记字符串,适合全文搜索查询。 -- **最小-最大索引**: - - 为每个数据部分维护一个列的最小值和最大值。 - - 有助于跳过读取不在指定范围内的数据部分。 - -## 搜索索引 {#search-indexes} - -与 BigQuery 的 [搜索索引](https://cloud.google.com/bigquery/docs/search-index) 类似,ClickHouse 可以为字符串值的列创建 [全文索引](/engines/table-engines/mergetree-family/invertedindexes)。 - -## 向量索引 {#vector-indexes} - -BigQuery 最近推出了 [向量索引](https://cloud.google.com/bigquery/docs/vector-index) 作为预 GA 特性。同样,ClickHouse 对 [加速向量搜索用例的索引](/engines/table-engines/mergetree-family/annindexes) 提供实验支持。 - -## 分区 {#partitioning} - -与 BigQuery 类似,ClickHouse 通过将表划分为更小、更可管理的部分(称为分区)来使用表分区提高大表的性能和可管理性。我们在此 [详细描述 ClickHouse 的分区](/engines/table-engines/mergetree-family/custom-partitioning-key)。 - -## 聚类 {#clustering} - -通过聚类,BigQuery 根据几个指定列的值自动对表数据进行排序并将其放置在最佳大小的块中。聚类提高了查询性能,使 BigQuery 可以更好地估计运行查询的成本。通过聚类列,查询还可以消除对不必要数据的扫描。 - -在 ClickHouse 中,数据是根据表的主键列自动 [在磁盘上聚类](/guides/best-practices/sparse-primary-indexes#optimal-compression-ratio-of-data-files),并在逻辑上组织成可以被查询利用主索引数据结构快速定位或修剪的块。 - -## 物化视图 {#materialized-views} - -BigQuery 和 ClickHouse 都支持物化视图——基于变换查询对基础表的结果进行预计算,以提高性能和效率。 - -## 查询物化视图 {#querying-materialized-views} - -BigQuery 物化视图可以直接查询或用于优化器处理对基础表的查询。如果基础表的更改可能使物化视图无效,则数据直接从基础表中读取。如果基础表的更改不使物化视图无效,则剩余数据从物化视图中读取,而只有更改部分从基础表中读取。 - -在 ClickHouse 中,物化视图只能直接查询。然而,与 BigQuery(物化视图会在对基础表的更改后自动在 5 分钟内刷新,但不能更频繁于 [每 30 分钟](https://cloud.google.com/bigquery/docs/materialized-views-manage#refresh))相比,物化视图始终与基础表处于同步状态。 - -**更新物化视图** - -BigQuery 定期通过对基础表运行视图的转换查询来完全刷新物化视图。在刷新之间,BigQuery 将物化视图的数据与基础表的新数据结合,以提供一致的查询结果,同时仍然使用物化视图。 - -在 ClickHouse 中,物化视图是增量更新的。这种增量更新机制提供了高可扩展性和低计算成本:增量更新的物化视图专门为基础表包含数十亿或数万亿行的场景而设计。ClickHouse 并不需要反复查询不断增长的基础表来刷新物化视图,而是简单地计算新插入的基础表行的部分结果。这个部分结果在后台与之前计算的部分结果增量合并。与从整个基础表反复刷新的计算成本相比,这显著降低了计算成本。 - -## 事务 {#transactions} - -与 ClickHouse 相比,BigQuery 支持在单个查询内或在使用会话时跨多个查询进行多语句事务。多语句事务使您能够对一个或多个表执行变更操作,如插入或删除行,并以原子方式提交或回滚更改。多语句事务是 [ClickHouse 在 2024 年的 roadmap](https://github.com/ClickHouse/ClickHouse/issues/58392)。 - -## 聚合函数 {#aggregate-functions} - -与 BigQuery 相比,ClickHouse 提供显著更多内置聚合函数: - -- BigQuery 提供 [18 种聚合函数](https://cloud.google.com/bigquery/docs/reference/standard-sql/aggregate_functions) 和 [4 种近似聚合函数](https://cloud.google.com/bigquery/docs/reference/standard-sql/approximate_aggregate_functions)。 -- ClickHouse 拥有超过 [150 种预建聚合函数](/sql-reference/aggregate-functions/reference),以及强大的 [聚合组合器](/sql-reference/aggregate-functions/combinators) 用于 [扩展](https://www.youtube.com/watch?v=7ApwD0cfAFI) 预建聚合函数的行为。例如,您可以通过调用带有 [-Array 后缀](/sql-reference/aggregate-functions/combinators#-array) 的函数将超过 150 种预建聚合函数应用于数组,而不是表行。使用带有 [-Map 后缀](/sql-reference/aggregate-functions/combinators#-map) 的函数,您可以将任何聚合函数应用于映射中。而使用带有 [-ForEach 后缀](/sql-reference/aggregate-functions/combinators#-foreach) 的函数,您可以将任何聚合函数应用于嵌套数组。 - -## 数据源和文件格式 {#data-sources-and-file-formats} - -与 BigQuery 相比,ClickHouse 支持显著更多的文件格式和数据源: - -- ClickHouse 原生支持从几乎任何数据源加载超过 90 种文件格式的数据 -- BigQuery 支持 5 种文件格式和 19 种数据源 - -## SQL 语言特性 {#sql-language-features} - -ClickHouse 提供标准 SQL,带有许多扩展和改进,使其对分析任务更友好。例如,ClickHouse SQL [支持 Lambda 函数](/sql-reference/functions/overview#arrow-operator-and-lambda) 和高阶函数,因此您无需在应用变换时将数组展开。这是与其他系统如 BigQuery 相比的一大优势。 - -## 数组 {#arrays} - -与 BigQuery 的 8 种数组函数相比,ClickHouse 拥有超过 80 种 [内置数组函数](/sql-reference/functions/array-functions) 来优雅简单地建模和解决各种问题。 - -ClickHouse 中的典型设计模式是使用 [`groupArray`](/sql-reference/aggregate-functions/reference/grouparray) 聚合函数将表的特定行值(暂时)转换为一个数组。然后可以通过数组函数方便地处理该数组,最后通过 [`arrayJoin`](/sql-reference/functions/array-join) 聚合函数将结果转换回单个表行。 - -由于 ClickHouse SQL 支持 [高阶 Lambda 函数](/sql-reference/functions/overview#arrow-operator-and-lambda),许多高级数组操作可以通过简单调用其中一个高阶内置数组函数实现,而不必像在 BigQuery 中常需的那样临时将数组转换回表 [过滤](https://cloud.google.com/bigquery/docs/arrays#filtering_arrays) 或 [压缩](https://cloud.google.com/bigquery/docs/arrays#zipping_arrays) 数组。在 ClickHouse 中,这些操作只是高阶函数 [`arrayFilter`](/sql-reference/functions/array-functions#arrayfilterfunc-arr1-) 和 [`arrayZip`](/sql-reference/functions/array-functions#arrayzip) 的简单函数调用。 - -接下来,我们提供 BigQuery 到 ClickHouse 数组操作的映射: - -| BigQuery | ClickHouse | -|----------|------------| -| [ARRAY_CONCAT](https://cloud.google.com/bigquery/docs/reference/standard-sql/array_functions#array_concat) | [arrayConcat](/sql-reference/functions/array-functions#arrayconcat) | -| [ARRAY_LENGTH](https://cloud.google.com/bigquery/docs/reference/standard-sql/array_functions#array_length) | [length](/sql-reference/functions/array-functions#length) | -| [ARRAY_REVERSE](https://cloud.google.com/bigquery/docs/reference/standard-sql/array_functions#array_reverse) | [arrayReverse](/sql-reference/functions/array-functions#arrayreverse) | -| [ARRAY_TO_STRING](https://cloud.google.com/bigquery/docs/reference/standard-sql/array_functions#array_to_string) | [arrayStringConcat](/sql-reference/functions/splitting-merging-functions#arraystringconcat) | -| [GENERATE_ARRAY](https://cloud.google.com/bigquery/docs/reference/standard-sql/array_functions#generate_array) | [range](/sql-reference/functions/array-functions#rangeend-rangestart--end--step) | - -**为子查询中的每一行创建一个元素的数组** - -_BigQuery_ - -[ARRAY 函数](https://cloud.google.com/bigquery/docs/reference/standard-sql/array_functions#array) - -```sql -SELECT ARRAY - (SELECT 1 UNION ALL - SELECT 2 UNION ALL - SELECT 3) AS new_array; - -/*-----------* - | new_array | - +-----------+ - | [1, 2, 3] | - *-----------*/ -``` - -_ClickHouse_ - -[groupArray](/sql-reference/aggregate-functions/reference/grouparray) 聚合函数 - -```sql -SELECT groupArray(*) AS new_array -FROM -( - SELECT 1 - UNION ALL - SELECT 2 - UNION ALL - SELECT 3 -) - ┌─new_array─┐ -1. │ [1,2,3] │ - └───────────┘ -``` - -**将数组转换为一组行** - -_BigQuery_ - -[`UNNEST`](https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax#unnest_operator) 操作符 - -```sql -SELECT * -FROM UNNEST(['foo', 'bar', 'baz', 'qux', 'corge', 'garply', 'waldo', 'fred']) - AS element -WITH OFFSET AS offset -ORDER BY offset; - -/*----------+--------* - | element | offset | - +----------+--------+ - | foo | 0 | - | bar | 1 | - | baz | 2 | - | qux | 3 | - | corge | 4 | - | garply | 5 | - | waldo | 6 | - | fred | 7 | - *----------+--------*/ -``` - -_ClickHouse_ - -[ARRAY JOIN](/sql-reference/statements/select/array-join) 子句 - -```sql -WITH ['foo', 'bar', 'baz', 'qux', 'corge', 'garply', 'waldo', 'fred'] AS values -SELECT element, num-1 AS offset -FROM (SELECT values AS element) AS subquery -ARRAY JOIN element, arrayEnumerate(element) AS num; - -/*----------+--------* - | element | offset | - +----------+--------+ - | foo | 0 | - | bar | 1 | - | baz | 2 | - | qux | 3 | - | corge | 4 | - | garply | 5 | - | waldo | 6 | - | fred | 7 | - *----------+--------*/ -``` - -**返回日期数组** - -_BigQuery_ - -[GENERATE_DATE_ARRAY](https://cloud.google.com/bigquery/docs/reference/standard-sql/array_functions#generate_date_array) 函数 - -```sql -SELECT GENERATE_DATE_ARRAY('2016-10-05', '2016-10-08') AS example; - -/*--------------------------------------------------* - | example | - +--------------------------------------------------+ - | [2016-10-05, 2016-10-06, 2016-10-07, 2016-10-08] | - *--------------------------------------------------*/ -``` - -[range](/sql-reference/functions/array-functions#rangeend-rangestart--end--step) + [arrayMap](/sql-reference/functions/array-functions#arraymapfunc-arr1-) 函数 - -_ClickHouse_ - -```sql -SELECT arrayMap(x -> (toDate('2016-10-05') + x), range(toUInt32((toDate('2016-10-08') - toDate('2016-10-05')) + 1))) AS example - - ┌─example───────────────────────────────────────────────┐ -1. │ ['2016-10-05','2016-10-06','2016-10-07','2016-10-08'] │ - └───────────────────────────────────────────────────────┘ -``` - -**返回时间戳数组** - -_BigQuery_ - -[GENERATE_TIMESTAMP_ARRAY](https://cloud.google.com/bigquery/docs/reference/standard-sql/array_functions#generate_timestamp_array) 函数 - -```sql -SELECT GENERATE_TIMESTAMP_ARRAY('2016-10-05 00:00:00', '2016-10-07 00:00:00', - INTERVAL 1 DAY) AS timestamp_array; - -/*--------------------------------------------------------------------------* - | timestamp_array | - +--------------------------------------------------------------------------+ - | [2016-10-05 00:00:00+00, 2016-10-06 00:00:00+00, 2016-10-07 00:00:00+00] | - *--------------------------------------------------------------------------*/ -``` - -_ClickHouse_ - -[range](/sql-reference/functions/array-functions#rangeend-rangestart--end--step) + [arrayMap](/sql-reference/functions/array-functions#arraymapfunc-arr1-) 函数 - -```sql -SELECT arrayMap(x -> (toDateTime('2016-10-05 00:00:00') + toIntervalDay(x)), range(dateDiff('day', toDateTime('2016-10-05 00:00:00'), toDateTime('2016-10-07 00:00:00')) + 1)) AS timestamp_array - -Query id: b324c11f-655b-479f-9337-f4d34fd02190 - - ┌─timestamp_array─────────────────────────────────────────────────────┐ -1. │ ['2016-10-05 00:00:00','2016-10-06 00:00:00','2016-10-07 00:00:00'] │ - └─────────────────────────────────────────────────────────────────────┘ -``` - -**过滤数组** - -_BigQuery_ - -需要通过 [`UNNEST`](https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax#unnest_operator) 操作符临时将数组转换回表 - -```sql -WITH Sequences AS - (SELECT [0, 1, 1, 2, 3, 5] AS some_numbers - UNION ALL SELECT [2, 4, 8, 16, 32] AS some_numbers - UNION ALL SELECT [5, 10] AS some_numbers) -SELECT - ARRAY(SELECT x * 2 - FROM UNNEST(some_numbers) AS x - WHERE x < 5) AS doubled_less_than_five -FROM Sequences; - -/*------------------------* - | doubled_less_than_five | - +------------------------+ - | [0, 2, 2, 4, 6] | - | [4, 8] | - | [] | - *------------------------*/ -``` - -_ClickHouse_ - -[arrayFilter](/sql-reference/functions/array-functions#arrayfilterfunc-arr1-) 函数 - -```sql -WITH Sequences AS - ( - SELECT [0, 1, 1, 2, 3, 5] AS some_numbers - UNION ALL - SELECT [2, 4, 8, 16, 32] AS some_numbers - UNION ALL - SELECT [5, 10] AS some_numbers - ) -SELECT arrayMap(x -> (x * 2), arrayFilter(x -> (x < 5), some_numbers)) AS doubled_less_than_five -FROM Sequences; - ┌─doubled_less_than_five─┐ -1. │ [0,2,2,4,6] │ - └────────────────────────┘ - ┌─doubled_less_than_five─┐ -2. │ [] │ - └────────────────────────┘ - ┌─doubled_less_than_five─┐ -3. │ [4,8] │ - └────────────────────────┘ -``` - -**压缩数组** - -_BigQuery_ - -需要通过 [`UNNEST`](https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax#unnest_operator) 操作符临时将数组转换回表 - -```sql -WITH - Combinations AS ( - SELECT - ['a', 'b'] AS letters, - [1, 2, 3] AS numbers - ) -SELECT - ARRAY( - SELECT AS STRUCT - letters[SAFE_OFFSET(index)] AS letter, - numbers[SAFE_OFFSET(index)] AS number - FROM Combinations - CROSS JOIN - UNNEST( - GENERATE_ARRAY( - 0, - LEAST(ARRAY_LENGTH(letters), ARRAY_LENGTH(numbers)) - 1)) AS index - ORDER BY index - ); - -/*------------------------------* - | pairs | - +------------------------------+ - | [{ letter: "a", number: 1 }, | - | { letter: "b", number: 2 }] | - *------------------------------*/ -``` - -_ClickHouse_ - -[arrayZip](/sql-reference/functions/array-functions#arrayzip) 函数 - -```sql -WITH Combinations AS - ( - SELECT - ['a', 'b'] AS letters, - [1, 2, 3] AS numbers - ) -SELECT arrayZip(letters, arrayResize(numbers, length(letters))) AS pairs -FROM Combinations; - ┌─pairs─────────────┐ -1. │ [('a',1),('b',2)] │ - └───────────────────┘ -``` - -**聚合数组** - -_BigQuery_ - -要求通过 [`UNNEST`](https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax#unnest_operator) 操作符将数组转换回表 - -```sql -WITH Sequences AS - (SELECT [0, 1, 1, 2, 3, 5] AS some_numbers - UNION ALL SELECT [2, 4, 8, 16, 32] AS some_numbers - UNION ALL SELECT [5, 10] AS some_numbers) -SELECT some_numbers, - (SELECT SUM(x) - FROM UNNEST(s.some_numbers) AS x) AS sums -FROM Sequences AS s; - -/*--------------------+------* - | some_numbers | sums | - +--------------------+------+ - | [0, 1, 1, 2, 3, 5] | 12 | - | [2, 4, 8, 16, 32] | 62 | - | [5, 10] | 15 | - *--------------------+------*/ -``` - -_ClickHouse_ - -[arraySum](/sql-reference/functions/array-functions#arraysum), [arrayAvg](/sql-reference/functions/array-functions#arrayavg), ... 函数,或任何现有的 90 多种聚合函数名称作为 [arrayReduce](/sql-reference/functions/array-functions#arrayreduce) 函数的参数 - -```sql -WITH Sequences AS - ( - SELECT [0, 1, 1, 2, 3, 5] AS some_numbers - UNION ALL - SELECT [2, 4, 8, 16, 32] AS some_numbers - UNION ALL - SELECT [5, 10] AS some_numbers - ) -SELECT - some_numbers, - arraySum(some_numbers) AS sums -FROM Sequences; - ┌─some_numbers──┬─sums─┐ -1. │ [0,1,1,2,3,5] │ 12 │ - └───────────────┴──────┘ - ┌─some_numbers──┬─sums─┐ -2. │ [2,4,8,16,32] │ 62 │ - └───────────────┴──────┘ - ┌─some_numbers─┬─sums─┐ -3. │ [5,10] │ 15 │ - └──────────────┴──────┘ -``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/migrations/bigquery/equivalent-concepts.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/migrations/bigquery/equivalent-concepts.md.hash deleted file mode 100644 index b59768e7828..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/migrations/bigquery/equivalent-concepts.md.hash +++ /dev/null @@ -1 +0,0 @@ -79246fc4f650dd91 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/migrations/bigquery/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/migrations/bigquery/index.md deleted file mode 100644 index 1eab465b0b8..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/migrations/bigquery/index.md +++ /dev/null @@ -1,18 +0,0 @@ ---- -'slug': '/migrations/bigquery' -'title': 'BigQuery' -'pagination_prev': null -'pagination_next': null -'description': 'BigQuery 迁移部分的登录页面' -'keywords': -- 'BigQuery' -- 'migration' ---- - -在本节文档中,了解 BigQuery 和 ClickHouse Cloud 之间的相似性和差异,以及您可能想要迁移的原因和如何进行迁移。 - -| 页面 | 描述 | -|-----------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------| -| [BigQuery vs ClickHouse Cloud](./equivalent-concepts.md) | ClickHouse Cloud 中资源的组织方式与 BigQuery 的资源层次结构相似。我们在本文中描述了具体的差异。 | -| [从 BigQuery 迁移到 ClickHouse Cloud](./migrating-to-clickhouse-cloud.md) | 了解您可能想要从 BigQuery 迁移到 ClickHouse Cloud 的原因。 | -| [加载数据](./loading-data.md) | 指导您如何将数据从 BigQuery 迁移到 ClickHouse。 | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/migrations/bigquery/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/migrations/bigquery/index.md.hash deleted file mode 100644 index 48baa776104..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/migrations/bigquery/index.md.hash +++ /dev/null @@ -1 +0,0 @@ -c8db0d830d6a8857 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/migrations/bigquery/loading-data.md b/i18n/zh/docusaurus-plugin-content-docs/current/migrations/bigquery/loading-data.md deleted file mode 100644 index f88fc0ad204..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/migrations/bigquery/loading-data.md +++ /dev/null @@ -1,135 +0,0 @@ ---- -'sidebar_label': '加载数据' -'title': '从 BigQuery 加载数据到 ClickHouse' -'slug': '/migrations/bigquery/loading-data' -'description': '如何从 BigQuery 加载数据到 ClickHouse' -'keywords': -- 'migrate' -- 'migration' -- 'migrating' -- 'data' -- 'etl' -- 'elt' -- 'BigQuery' ---- - -_此指南适用于 ClickHouse Cloud 和自托管的 ClickHouse v23.5+。_ - -本指南展示了如何将数据从 [BigQuery](https://cloud.google.com/bigquery) 迁移到 ClickHouse。 - -我们首先将一个表导出到 [Google 对象存储 (GCS)](https://cloud.google.com/storage),然后将该数据导入到 [ClickHouse Cloud](https://clickhouse.com/cloud)。这些步骤需要对每个您希望从 BigQuery 导出到 ClickHouse 的表进行重复。 - -## 导出数据到 ClickHouse 需要多长时间? {#how-long-will-exporting-data-to-clickhouse-take} - -从 BigQuery 导出数据到 ClickHouse 的时间取决于您数据集的大小。作为比较,使用本指南将 [4TB 公共以太坊数据集](https://cloud.google.com/blog/products/data-analytics/ethereum-bigquery-public-dataset-smart-contract-analytics) 从 BigQuery 导出到 ClickHouse 大约需要一小时。 - -| 表 | 行数 | 导出文件数量 | 数据大小 | BigQuery 导出 | 槽时间 | ClickHouse 导入 | -| ------------------------------------------------------------------------------------------------- | ------------- | -------------- | --------- | --------------- | --------------- | ----------------- | -| [blocks](https://github.com/ClickHouse/examples/blob/main/ethereum/schemas/blocks.md) | 16,569,489 | 73 | 14.53GB | 23 秒 | 37 分钟 | 15.4 秒 | -| [transactions](https://github.com/ClickHouse/examples/blob/main/ethereum/schemas/transactions.md) | 1,864,514,414 | 5169 | 957GB | 1 分 38 秒 | 1 天 8小时 | 18 分 5 秒 | -| [traces](https://github.com/ClickHouse/examples/blob/main/ethereum/schemas/traces.md) | 6,325,819,306 | 17,985 | 2.896TB | 5 分 46 秒 | 5 天 19 小时 | 34 分 55 秒 | -| [contracts](https://github.com/ClickHouse/examples/blob/main/ethereum/schemas/contracts.md) | 57,225,837 | 350 | 45.35GB | 16 秒 | 1 小时 51 分 | 39.4 秒 | -| 总计 | 82.6 亿 | 23,577 | 3.982TB | 8 分 3 秒 | > 6 天 5 小时 | 53 分 45 秒 | - -## 1. 将表数据导出到 GCS {#1-export-table-data-to-gcs} - -在此步骤中,我们使用 [BigQuery SQL 工作区](https://cloud.google.com/bigquery/docs/bigquery-web-ui) 执行我们的 SQL 命令。下面,我们将名为 `mytable` 的 BigQuery 表导出到 GCS 存储桶,使用 [`EXPORT DATA`](https://cloud.google.com/bigquery/docs/reference/standard-sql/other-statements) 语句。 - -```sql -DECLARE export_path STRING; -DECLARE n INT64; -DECLARE i INT64; -SET i = 0; - --- We recommend setting n to correspond to x billion rows. So 5 billion rows, n = 5 -SET n = 100; - -WHILE i < n DO - SET export_path = CONCAT('gs://mybucket/mytable/', i,'-*.parquet'); - EXPORT DATA - OPTIONS ( - uri = export_path, - format = 'PARQUET', - overwrite = true - ) - AS ( - SELECT * FROM mytable WHERE export_id = i - ); - SET i = i + 1; -END WHILE; -``` - -在上述查询中,我们将 BigQuery 表导出为 [Parquet 数据格式](https://parquet.apache.org/)。我们在 `uri` 参数中也使用了 `*` 字符。这确保了如果导出的数据超过 1GB,输出将被分片到多个文件中,文件名后缀数字递增。 - -这种方法具有多种优势: - -- Google 允许每天将最多 50TB 的数据免费导出到 GCS。用户仅需为 GCS 存储付费。 -- 导出会自动生成多个文件,将每个文件限制为最多 1GB 的表数据。这对 ClickHouse 有利,因为这使得导入可以并行化。 -- Parquet 作为一种面向列的格式,代表了更好的交换格式,因为它固有地被压缩,并且对 BigQuery 导出和 ClickHouse 查询速度更快。 - -## 2. 从 GCS 导入数据到 ClickHouse {#2-importing-data-into-clickhouse-from-gcs} - -一旦导出完成,我们可以将这些数据导入到 ClickHouse 表中。您可以使用 [ClickHouse SQL 控制台](/integrations/sql-clients/sql-console) 或 [`clickhouse-client`](/interfaces/cli) 执行以下命令。 - -首先,您必须 [在 ClickHouse 中创建表](/sql-reference/statements/create/table): - -```sql --- If your BigQuery table contains a column of type STRUCT, you must enable this setting --- to map that column to a ClickHouse column of type Nested -SET input_format_parquet_import_nested = 1; - -CREATE TABLE default.mytable -( - `timestamp` DateTime64(6), - `some_text` String -) -ENGINE = MergeTree -ORDER BY (timestamp); -``` - -创建表后,如果您的集群中有多个 ClickHouse 副本,则启用设置 `parallel_distributed_insert_select` 以加快导出速度。如果您只有一个 ClickHouse 节点,则可以跳过此步骤: - -```sql -SET parallel_distributed_insert_select = 1; -``` - -最后,我们可以使用 [`INSERT INTO SELECT` 命令](/sql-reference/statements/insert-into#inserting-the-results-of-select) 将数据从 GCS 插入到我们的 ClickHouse 表中,该命令基于 `SELECT` 查询的结果将数据插入表中。 - -为了检索要 `INSERT` 的数据,我们可以使用 [s3Cluster 函数](/sql-reference/table-functions/s3Cluster) 从我们的 GCS 存储桶检索数据,因为 GCS 与 [Amazon S3](https://aws.amazon.com/s3/) 互操作。如果您只有一个 ClickHouse 节点,可以使用 [s3 表函数](/sql-reference/table-functions/s3) 而不是 `s3Cluster` 函数。 - -```sql -INSERT INTO mytable -SELECT - timestamp, - ifNull(some_text, '') as some_text -FROM s3Cluster( - 'default', - 'https://storage.googleapis.com/mybucket/mytable/*.parquet.gz', - '', - '' -); -``` - -在上述查询中使用的 `ACCESS_ID` 和 `SECRET` 是与您的 GCS 存储桶关联的 [HMAC 密钥](https://cloud.google.com/storage/docs/authentication/hmackeys)。 - -:::note 使用 `ifNull` 导出可空列 -在上述查询中,我们使用 [`ifNull` 函数](/sql-reference/functions/functions-for-nulls#ifnull) 处理 `some_text` 列,以在将数据插入 ClickHouse 表时使用默认值。您也可以在 ClickHouse 中将列设置为 [`Nullable`](/sql-reference/data-types/nullable),但这不推荐,因为可能会对性能产生负面影响。 - -或者,您可以 `SET input_format_null_as_default=1`,那么任何缺失或 NULL 值将被相应列的默认值替换,如果这些默认值被指定。 -::: - -## 3. 测试数据导出是否成功 {#3-testing-successful-data-export} - -要测试您的数据是否正确插入,只需在新表上运行 `SELECT` 查询: - -```sql -SELECT * FROM mytable limit 10; -``` - -要导出更多的 BigQuery 表,只需对每个其他表重复上述步骤。 - -## 进一步阅读和支持 {#further-reading-and-support} - -除了本指南,我们还推荐阅读我们的博客文章,展示了 [如何使用 ClickHouse 加速 BigQuery 以及如何处理增量导入](https://clickhouse.com/blog/clickhouse-bigquery-migrating-data-for-realtime-queries)。 - -如果您在将数据从 BigQuery 转移到 ClickHouse 时遇到问题,请随时通过 support@clickhouse.com 与我们联系。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/migrations/bigquery/loading-data.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/migrations/bigquery/loading-data.md.hash deleted file mode 100644 index 833c979dc8b..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/migrations/bigquery/loading-data.md.hash +++ /dev/null @@ -1 +0,0 @@ -0368316b0ed16a7f diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/migrations/bigquery/migrating-to-clickhouse-cloud.md b/i18n/zh/docusaurus-plugin-content-docs/current/migrations/bigquery/migrating-to-clickhouse-cloud.md deleted file mode 100644 index c58d805c07a..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/migrations/bigquery/migrating-to-clickhouse-cloud.md +++ /dev/null @@ -1,537 +0,0 @@ ---- -'title': '从 BigQuery 迁移到 ClickHouse Cloud' -'slug': '/migrations/bigquery/migrating-to-clickhouse-cloud' -'description': '如何将您的数据从 BigQuery 迁移到 ClickHouse Cloud' -'keywords': -- 'BigQuery' -'show_related_blogs': true ---- - -import bigquery_2 from '@site/static/images/migrations/bigquery-2.png'; -import bigquery_3 from '@site/static/images/migrations/bigquery-3.png'; -import bigquery_4 from '@site/static/images/migrations/bigquery-4.png'; -import bigquery_5 from '@site/static/images/migrations/bigquery-5.png'; -import bigquery_6 from '@site/static/images/migrations/bigquery-6.png'; -import bigquery_7 from '@site/static/images/migrations/bigquery-7.png'; -import bigquery_8 from '@site/static/images/migrations/bigquery-8.png'; -import bigquery_9 from '@site/static/images/migrations/bigquery-9.png'; -import bigquery_10 from '@site/static/images/migrations/bigquery-10.png'; -import bigquery_11 from '@site/static/images/migrations/bigquery-11.png'; -import bigquery_12 from '@site/static/images/migrations/bigquery-12.png'; -import Image from '@theme/IdealImage'; - -## 为什么选择 ClickHouse Cloud 而不是 BigQuery? {#why-use-clickhouse-cloud-over-bigquery} - -TLDR: 因为 ClickHouse 在现代数据分析中比 BigQuery 更快、更便宜且更强大: - - - -## 从 BigQuery 加载数据到 ClickHouse Cloud {#loading-data-from-bigquery-to-clickhouse-cloud} - -### 数据集 {#dataset} - -作为示例数据集以展示从 BigQuery 迁移到 ClickHouse Cloud 的典型过程,我们使用 Stack Overflow 数据集,其详细信息见 [这里](/getting-started/example-datasets/stackoverflow)。该数据集包含了自 2008 年至 2024 年 4 月期间发生在 Stack Overflow 上的每一个 `post`、`vote`、`user`、`comment` 和 `badge`。此数据的 BigQuery 架构如下所示: - - - -对于希望将此数据集填充到 BigQuery 实例中以测试迁移步骤的用户,我们已在 GCS 存储桶中提供了这些表的数据,DDL 命令用于在 BigQuery 中创建和加载表可在 [这里](https://pastila.nl/?003fd86b/2b93b1a2302cfee5ef79fd374e73f431#hVPC52YDsUfXg2eTLrBdbA==) 获取。 - -### 迁移数据 {#migrating-data} - -从 BigQuery 到 ClickHouse Cloud 的数据迁移分为两种主要工作负载类型: - -- **初始批量加载与定期更新** - 必须迁移初始数据集,并在设定的时间间隔(例如,每天)进行定期更新。这里的更新是通过重新发送已更改的行来处理的,通常根据可用于比较的列(例如日期)进行识别。删除则通过对数据集进行完整的定期重载来处理。 -- **实时复制或 CDC** - 必须迁移初始数据集。对该数据集的更改必须在 ClickHouse 中近实时反映,最多可接受几秒的延迟。这实际上是一个 [变更数据捕获 (CDC) 过程](https://en.wikipedia.org/wiki/Change_data_capture),其中 BigQuery 中的表必须与 ClickHouse 同步,即 BigQuery 表中的插入、更新和删除必须应用到 ClickHouse 中的等效表中。 - -#### 通过 Google Cloud Storage (GCS) 批量加载 {#bulk-loading-via-google-cloud-storage-gcs} - -BigQuery 支持将数据导出到 Google 的对象存储 (GCS)。对于我们的示例数据集: - -1. 将 7 个表导出到 GCS。相关命令可在 [这里](https://pastila.nl/?014e1ae9/cb9b07d89e9bb2c56954102fd0c37abd#0Pzj52uPYeu1jG35nmMqRQ==) 查看。 - -2. 将数据导入到 ClickHouse Cloud。为此,我们可以使用 [gcs 表函数](/sql-reference/table-functions/gcs)。DDL 和导入查询可在 [这里](https://pastila.nl/?00531abf/f055a61cc96b1ba1383d618721059976#Wf4Tn43D3VCU5Hx7tbf1Qw==) 获取。请注意,由于 ClickHouse Cloud 实例由多个计算节点组成,因此我们用 [s3Cluster 表函数](/sql-reference/table-functions/s3Cluster) 替代 `gcs` 表函数。此函数也可以与 gcs 存储桶一起使用,并且 [利用 ClickHouse Cloud 服务的所有节点](https://clickhouse.com/blog/supercharge-your-clickhouse-data-loads-part1#parallel-servers) 来并行加载数据。 - - - -这种方法有许多优势: - -- BigQuery 的导出功能支持用于导出数据子集的过滤器。 -- BigQuery 支持导出到 [Parquet、Avro、JSON 和 CSV](https://cloud.google.com/bigquery/docs/exporting-data) 格式及几种 [压缩类型](https://cloud.google.com/bigquery/docs/exporting-data) - 这些都被 ClickHouse 支持。 -- GCS 支持 [对象生命周期管理](https://cloud.google.com/storage/docs/lifecycle),允许在特定时间段后删除已经导出并导入到 ClickHouse 的数据。 -- [Google 允许每天免费导出最多 50TB 数据到 GCS](https://cloud.google.com/bigquery/quotas#export_jobs)。用户只需为 GCS 存储付费。 -- 导出会自动生成多个文件,每个文件的最大表数据为 1GB。这对 ClickHouse 有利,因为它允许导入并行化。 - -在尝试以下示例之前,我们建议用户查看 [导出所需的权限](https://cloud.google.com/bigquery/docs/exporting-data#required_permissions) 和 [位置推荐](https://cloud.google.com/bigquery/docs/exporting-data#data-locations) 以最大化导出和导入性能。 - -### 通过调度查询进行实时复制或 CDC {#real-time-replication-or-cdc-via-scheduled-queries} - -变更数据捕获 (CDC) 是将两个数据库之间的表保持同步的过程。如果要在接近实时的情况下处理更新和删除,这显然更复杂。一种方法是简单地使用 BigQuery 的 [调度查询功能](https://cloud.google.com/bigquery/docs/scheduling-queries) 来安排定期导出。假如您可以接受插入数据到 ClickHouse 的一些延迟,这种方法很容易实现和维护。一个示例见 [这篇博文](https://clickhouse.com/blog/clickhouse-bigquery-migrating-data-for-realtime-queries#using-scheduled-queries)。 - -## 设计模式 {#designing-schemas} - -Stack Overflow 数据集中包含多个相关表。我们建议首先关注迁移主表。这并不一定是最大的表,而是您预计将接收最多分析查询的表。这样可以让您熟悉 ClickHouse 的主要概念。随着更多表的添加,这张表可能需要重新建模以充分利用 ClickHouse 的特性,并获得最佳性能。我们在 [数据建模文档](/data-modeling/schema-design#next-data-modeling-techniques) 中探讨了这一建模过程。 - -遵循此原则,我们关注主要的 `posts` 表。其 BigQuery 架构如下所示: - -```sql -CREATE TABLE stackoverflow.posts ( - id INTEGER, - posttypeid INTEGER, - acceptedanswerid STRING, - creationdate TIMESTAMP, - score INTEGER, - viewcount INTEGER, - body STRING, - owneruserid INTEGER, - ownerdisplayname STRING, - lasteditoruserid STRING, - lasteditordisplayname STRING, - lasteditdate TIMESTAMP, - lastactivitydate TIMESTAMP, - title STRING, - tags STRING, - answercount INTEGER, - commentcount INTEGER, - favoritecount INTEGER, - conentlicense STRING, - parentid STRING, - communityowneddate TIMESTAMP, - closeddate TIMESTAMP -); -``` - -### 优化类型 {#optimizing-types} - -应用 [这里描述的过程](/data-modeling/schema-design) 将得到如下架构: - -```sql -CREATE TABLE stackoverflow.posts -( - `Id` Int32, - `PostTypeId` Enum('Question' = 1, 'Answer' = 2, 'Wiki' = 3, 'TagWikiExcerpt' = 4, 'TagWiki' = 5, 'ModeratorNomination' = 6, 'WikiPlaceholder' = 7, 'PrivilegeWiki' = 8), - `AcceptedAnswerId` UInt32, - `CreationDate` DateTime, - `Score` Int32, - `ViewCount` UInt32, - `Body` String, - `OwnerUserId` Int32, - `OwnerDisplayName` String, - `LastEditorUserId` Int32, - `LastEditorDisplayName` String, - `LastEditDate` DateTime, - `LastActivityDate` DateTime, - `Title` String, - `Tags` String, - `AnswerCount` UInt16, - `CommentCount` UInt8, - `FavoriteCount` UInt8, - `ContentLicense`LowCardinality(String), - `ParentId` String, - `CommunityOwnedDate` DateTime, - `ClosedDate` DateTime -) -ENGINE = MergeTree -ORDER BY tuple() -COMMENT 'Optimized types' -``` - -我们可以通过简单的 [`INSERT INTO SELECT`](/sql-reference/statements/insert-into) 将数据填充到此表中,使用 [`gcs` 表函数](/sql-reference/table-functions/gcs) 从 gcs 读取导出数据。请注意,在 ClickHouse Cloud 上,您还可以使用与 gcs 兼容的 [`s3Cluster` 表函数](/sql-reference/table-functions/s3Cluster) 在多个节点上并行加载: - -```sql -INSERT INTO stackoverflow.posts SELECT * FROM gcs( 'gs://clickhouse-public-datasets/stackoverflow/parquet/posts/*.parquet', NOSIGN); -``` - -我们在新架构中不保留任何 null 值。上述插入会将这些值隐式转换为其各自类型的默认值 - 整数为 0,字符串为空值。ClickHouse 还会自动将任何数值转换为目标精度。 - -## ClickHouse 主键有何不同? {#how-are-clickhouse-primary-keys-different} - -如 [这里所述](/migrations/bigquery),与 BigQuery 一样,ClickHouse 对表的主键列值不强制唯一。 - -与 BigQuery 中的聚类类似,ClickHouse 表的数据按主键列的顺序存储在磁盘上。这种排序被查询优化器利用,以防止重新排序,最小化连接的内存使用,并启用限制子句的短路。与 BigQuery 不同,ClickHouse 会根据主键列值自动创建 [(稀疏)主索引](/guides/best-practices/sparse-primary-indexes)。此索引用于加速所有包含主键列过滤条件的查询。具体来说: - -- 内存和磁盘效率在 ClickHouse 常用的规模上至关重要。数据通过称为 parts 的块写入 ClickHouse 表中,并且在后台应用合并 parts 的规则。在 ClickHouse 中,每个 part 都有自己的主索引。当 parts 被合并时,合并后的 part 的主索引也会合并。请注意,这些索引并不是为每一行构建的。相反,对于一个 part,主索引每组行只有一个索引条目 - 这种技术称为稀疏索引。 -- 稀疏索引之所以可行,是因为 ClickHouse 按指定的键在磁盘上存储一个 part 的行。与直接定位单行(如基于 B 树 的索引)不同,稀疏主索引能够通过对索引条目执行二分搜索快速(查找)识别可能匹配查询的行组。找到的潜在匹配行组将以并行方式流入 ClickHouse 引擎以找到匹配项。这种索引设计使主索引可以较小(完全符合主内存),同时仍大大加快查询执行时间,特别是在数据分析用例中典型的范围查询。有关更多详细信息,我们建议 [这篇深入指南](/guides/best-practices/sparse-primary-indexes)。 - - - -在 ClickHouse 中选择的主键不仅决定索引,还决定数据在磁盘上的写入顺序。因此,它会显著影响压缩级别,这反过来可能会影响查询性能。导致大多数列值按连续顺序写入的排序键,将允许所选的压缩算法(和编码)更有效地压缩数据。 - -> 表中的所有列将根据指定的排序键的值进行排序,无论它们是否包含在键本身中。例如,如果使用 `CreationDate` 作为键,则所有其他列中的值的顺序将与 `CreationDate` 列中的值的顺序相对应。可以指定多个排序键 - 这将与 `SELECT` 查询中的 `ORDER BY` 子句具有相同的语义。 - -### 选择排序键 {#choosing-an-ordering-key} - -有关选择排序键的考虑和步骤,以帖子表为例,请参见 [这里](/data-modeling/schema-design#choosing-an-ordering-key)。 - -## 数据建模技术 {#data-modeling-techniques} - -我们建议从 BigQuery 迁移的用户阅读 [ClickHouse 数据建模指南](/data-modeling/schema-design)。该指南使用相同的 Stack Overflow 数据集,并探讨了使用 ClickHouse 特性的多种方法。 - -### 分区 {#partitions} - -BigQuery 用户对表分区的概念会比较熟悉,这种方法通过将表划分为更小、更可管理的 pieces 来提高大型数据库的性能和可管理性。这种分区可以通过指定列(例如日期)的范围、定义的列表或通过哈希键实现。这允许管理员根据特定标准(如日期范围或地理位置)组织数据。 - -分区有助于提高查询性能,通过允许通过分区剪裁实现更快的数据访问和更高效的索引。此外,它还支持维护任务,例如备份和数据清理,因为可以对单个分区而不是整个表进行操作。此外,分区还可以显著提高 BigQuery 数据库的可扩展性,将负载分配到多个分区。 - -在 ClickHouse 中,分区是在首次通过 [`PARTITION BY`](/engines/table-engines/mergetree-family/custom-partitioning-key) 子句定义表时指定的。该子句可以包含任何列的 SQL 表达式,其结果将定义行发送到哪一个分区。 - - - -数据部分在磁盘上与每个分区逻辑关联,并且可单独查询。对于下面的示例,我们使用表达式 [`toYear(CreationDate)`](/sql-reference/functions/date-time-functions#toyear) 按年份对帖子表进行分区。当行插入到 ClickHouse 时,将对每行评估此表达式 - 然后将行路由到结果分区,形成属于该分区的新数据部分。 - -```sql -CREATE TABLE posts -( - `Id` Int32 CODEC(Delta(4), ZSTD(1)), - `PostTypeId` Enum8('Question' = 1, 'Answer' = 2, 'Wiki' = 3, 'TagWikiExcerpt' = 4, 'TagWiki' = 5, 'ModeratorNomination' = 6, 'WikiPlaceholder' = 7, 'PrivilegeWiki' = 8), - `AcceptedAnswerId` UInt32, - `CreationDate` DateTime64(3, 'UTC'), -... - `ClosedDate` DateTime64(3, 'UTC') -) -ENGINE = MergeTree -ORDER BY (PostTypeId, toDate(CreationDate), CreationDate) -PARTITION BY toYear(CreationDate) -``` - -#### 应用 {#applications} - -ClickHouse 中的分区与 BigQuery 中的应用类似,但有一些细微差别。具体来说: - -- **数据管理** - 在 ClickHouse 中,用户主要应将分区视为数据管理特性,而不是查询优化技术。通过基于键逻辑分隔数据,每个分区可以独立操作,例如删除。这允许用户高效地移动分区及其子集在 [存储层](/integrations/s3#storage-tiers) 之间随时间变化或 [过期数据/高效地从集群中删除](/sql-reference/statements/alter/partition)。例如,下面的操作可以删除 2008 年的帖子: - -```sql -SELECT DISTINCT partition -FROM system.parts -WHERE `table` = 'posts' - -┌─partition─┐ -│ 2008 │ -│ 2009 │ -│ 2010 │ -│ 2011 │ -│ 2012 │ -│ 2013 │ -│ 2014 │ -│ 2015 │ -│ 2016 │ -│ 2017 │ -│ 2018 │ -│ 2019 │ -│ 2020 │ -│ 2021 │ -│ 2022 │ -│ 2023 │ -│ 2024 │ -└───────────┘ - -17 rows in set. Elapsed: 0.002 sec. - -ALTER TABLE posts -(DROP PARTITION '2008') - -Ok. - -0 rows in set. Elapsed: 0.103 sec. -``` - -- **查询优化** - 虽然分区可以协助提升查询性能,但这在很大程度上取决于访问模式。如果查询仅针对少数几个分区(理想情况下是一个),性能可能会有所改善。这通常只有在分区键未在主键中,而且您正在进行过滤时才有用。然而,需要覆盖多个分区的查询可能比不使用分区的性能更差(因为由于分区可能会导致更多的 parts)。如果分区键已经是在主键中的早期条目,则单一分区的目标也可能不会显著提升。对于每个分区的值都是唯一的情况,可以使用分区来 [优化 `GROUP BY` 查询](/engines/table-engines/mergetree-family/custom-partitioning-key#group-by-optimisation-using-partition-key)。但是,用户通常应确保主键经过优化,仅在访问模式访问特定可预测子集的情况下才考虑将分区用作查询优化技术,例如按天分区,而大多数查询都在最后一天。 - -#### 建议 {#recommendations} - -用户应将分区视为一种数据管理技术。它适用于处理时序数据时,当数据需要从集群中过期时,例如,最旧的分区可以 [直接删除](/sql-reference/statements/alter/partition#drop-partitionpart)。 - -重要提示:确保您的分区键表达式不会导致高基数集,即应避免创建超过 100 个分区。例如,不要通过高基数列(如客户端标识符或名称)对数据进行分区。相反,将客户端标识符或名称作为 `ORDER BY` 表达式中的第一列。 - -> 在内部,ClickHouse [为插入数据创建 parts](/guides/best-practices/sparse-primary-indexes#clickhouse-index-design)。随着更多数据的插入,parts 的数量会增加。为了防止 parts 数量过高,从而影响查询性能(因为需要阅读更多文件),parts 在后台异步过程中合并。如果 parts 的数量超过 [预配置的限制](/operations/settings/merge-tree-settings#parts_to_throw_insert),则 ClickHouse 会在插入时抛出异常,即 ["太多 parts" 错误](/knowledgebase/exception-too-many-parts)。这在正常操作下不应发生,仅会在 ClickHouse 配置不当或错误使用(例如,插入过多小批量数据)时发生。因为每个分区是独立地创建 parts,所以增加分区数会增加 parts 数量,即它是分区数的倍数。因此,高基数的分区键可能导致此错误,应避免使用。 - -## 物化视图与投影 {#materialized-views-vs-projections} - -ClickHouse 的投影概念允许用户为表指定多个 `ORDER BY` 子句。 - -在 [ClickHouse 数据建模](/data-modeling/schema-design) 中,我们探讨了如何使用物化视图在 ClickHouse 中预计算聚合、转换行并优化查询以应对不同的访问模式。对于后者,我们 [提供了一个示例](/materialized-view/incremental-materialized-view#lookup-table),其中物化视图将行发送至目标表,其排序键不同于接收插入的原始表。 - -例如,考虑以下查询: - -```sql -SELECT avg(Score) -FROM comments -WHERE UserId = 8592047 - - ┌──────────avg(Score)─┐ - │ 0.18181818181818182 │ - └─────────────────────┘ - -1 row in set. Elapsed: 0.040 sec. Processed 90.38 million rows, 361.59 MB (2.25 billion rows/s., 9.01 GB/s.) -Peak memory usage: 201.93 MiB. -``` - -这个查询需要扫描所有 9000 万行(尽管速度很快),因为 `UserId` 不是排序键。之前,我们通过物化视图作为 `PostId` 的查找表来解决此问题。相同的问题也可以通过投影解决。以下命令为 `ORDER BY user_id` 添加了一个投影。 - -```sql -ALTER TABLE comments ADD PROJECTION comments_user_id ( -SELECT * ORDER BY UserId -) - -ALTER TABLE comments MATERIALIZE PROJECTION comments_user_id -``` - -请注意,我们必须先创建投影,然后再使其物化。后一个命令会导致数据在磁盘上以两种不同的顺序存储。投影也可以在创建数据时定义,如下所示,并会在插入数据时自动维护。 - -```sql -CREATE TABLE comments -( - `Id` UInt32, - `PostId` UInt32, - `Score` UInt16, - `Text` String, - `CreationDate` DateTime64(3, 'UTC'), - `UserId` Int32, - `UserDisplayName` LowCardinality(String), - PROJECTION comments_user_id - ( - SELECT * - ORDER BY UserId - ) -) -ENGINE = MergeTree -ORDER BY PostId -``` - -如果通过 `ALTER` 命令创建投影,则在发出 `MATERIALIZE PROJECTION` 命令时,创建过程是异步的。用户可以通过以下查询确认此操作的进度,等待 `is_done=1`。 - -```sql -SELECT - parts_to_do, - is_done, - latest_fail_reason -FROM system.mutations -WHERE (`table` = 'comments') AND (command LIKE '%MATERIALIZE%') - - ┌─parts_to_do─┬─is_done─┬─latest_fail_reason─┐ -1. │ 1 │ 0 │ │ - └─────────────┴─────────┴────────────────────┘ - -1 row in set. Elapsed: 0.003 sec. -``` - -如果我们重复上述查询,可以看到性能显著提高,但额外的存储需求也随之增加。 - -```sql -SELECT avg(Score) -FROM comments -WHERE UserId = 8592047 - - ┌──────────avg(Score)─┐ -1. │ 0.18181818181818182 │ - └─────────────────────┘ - -1 row in set. Elapsed: 0.008 sec. Processed 16.36 thousand rows, 98.17 KB (2.15 million rows/s., 12.92 MB/s.) -Peak memory usage: 4.06 MiB. -``` - -通过 [`EXPLAIN` 命令](/sql-reference/statements/explain),我们还确认了该投影用于处理此查询: - -```sql -EXPLAIN indexes = 1 -SELECT avg(Score) -FROM comments -WHERE UserId = 8592047 - - ┌─explain─────────────────────────────────────────────┐ - 1. │ Expression ((Projection + Before ORDER BY)) │ - 2. │ Aggregating │ - 3. │ Filter │ - 4. │ ReadFromMergeTree (comments_user_id) │ - 5. │ Indexes: │ - 6. │ PrimaryKey │ - 7. │ Keys: │ - 8. │ UserId │ - 9. │ Condition: (UserId in [8592047, 8592047]) │ -10. │ Parts: 2/2 │ -11. │ Granules: 2/11360 │ - └─────────────────────────────────────────────────────┘ - -11 rows in set. Elapsed: 0.004 sec. -``` - -### 何时使用投影 {#when-to-use-projections} - -投影是新用户非常喜欢的功能,因为它们在插入数据时会被自动维护。此外,查询可以仅发送到一个表,在这个表中尽可能地利用投影来加速响应时间。 - - - -与此形成对比的是物化视图,在这种情况下,用户必须选择适当的优化目标表,或者重写它们的查询,具体取决于过滤条件。这对用户应用提出了更高的要求,并增加了客户端的复杂性。 - -尽管有这些优势,投影也有一些固有的局限性,用户应当知晓,并因此在使用时应谨慎: - -- 投影不允许为源表和(隐藏)目标表使用不同的 TTL。物化视图允许不同的 TTL。 -- 投影 [当前不支持 `optimize_read_in_order`](https://clickhouse.com/blog/clickhouse-faster-queries-with-projections-and-primary-indexes) 用于(隐藏)目标表。 -- 轻量级更新和删除不支持具有投影的表。 -- 物化视图可以链接:一个物化视图的目标表可以是另一个物化视图的源表,依此类推。投影则不支持此功能。 -- 投影不支持连接;物化视图支持。 -- 投影不支持过滤器(`WHERE` 子句);物化视图支持。 - -我们建议在以下情况下使用投影: - -- 需要对数据进行完全重排序。尽管投影中的表达式理论上可以使用 `GROUP BY`,但物化视图在维护聚合方面更加有效。查询优化器也更可能利用使用简单重排序的投影,即 `SELECT * ORDER BY x`。用户可以在该表达式中选择列的子集,以减小存储占用。 -- 用户能接受增加的存储占用和写入数据两次带来的开销。测试对插入速度的影响,并 [评估存储开销](/data-compression/compression-in-clickhouse)。 - -## 在 ClickHouse 中重写 BigQuery 查询 {#rewriting-bigquery-queries-in-clickhouse} - -以下提供了比较 BigQuery 和 ClickHouse 的示例查询。此列表旨在展示如何利用 ClickHouse 特性显著简化查询。这里的示例使用完整的 Stack Overflow 数据集(截至 2024 年 4 月)。 - -**用户(有超过 10 个问题)中获得最多浏览量的:** - -_BigQuery_ - - - -_ClickHouse_ - -```sql -SELECT - OwnerDisplayName, - sum(ViewCount) AS total_views -FROM stackoverflow.posts -WHERE (PostTypeId = 'Question') AND (OwnerDisplayName != '') -GROUP BY OwnerDisplayName -HAVING count() > 10 -ORDER BY total_views DESC -LIMIT 5 - - ┌─OwnerDisplayName─┬─total_views─┐ -1. │ Joan Venge │ 25520387 │ -2. │ Ray Vega │ 21576470 │ -3. │ anon │ 19814224 │ -4. │ Tim │ 19028260 │ -5. │ John │ 17638812 │ - └──────────────────┴─────────────┘ - -5 rows in set. Elapsed: 0.076 sec. Processed 24.35 million rows, 140.21 MB (320.82 million rows/s., 1.85 GB/s.) -Peak memory usage: 323.37 MiB. -``` - -**哪些标签获得的浏览量最多:** - -_BigQuery_ - -
- - - -_ClickHouse_ - -```sql --- ClickHouse -SELECT - arrayJoin(arrayFilter(t -> (t != ''), splitByChar('|', Tags))) AS tags, - sum(ViewCount) AS views -FROM stackoverflow.posts -GROUP BY tags -ORDER BY views DESC -LIMIT 5 - - - ┌─tags───────┬──────views─┐ -1. │ javascript │ 8190916894 │ -2. │ python │ 8175132834 │ -3. │ java │ 7258379211 │ -4. │ c# │ 5476932513 │ -5. │ android │ 4258320338 │ - └────────────┴────────────┘ - -5 rows in set. Elapsed: 0.318 sec. Processed 59.82 million rows, 1.45 GB (188.01 million rows/s., 4.54 GB/s.) -Peak memory usage: 567.41 MiB. -``` - -## 聚合函数 {#aggregate-functions} - -在可能的情况下,用户应利用 ClickHouse 的聚合函数。下面,我们展示了 [`argMax` 函数](/sql-reference/aggregate-functions/reference/argmax) 用于计算每年的最受欢迎问题。 - -_BigQuery_ - - - - - -_ClickHouse_ - -```sql --- ClickHouse -SELECT - toYear(CreationDate) AS Year, - argMax(Title, ViewCount) AS MostViewedQuestionTitle, - max(ViewCount) AS MaxViewCount -FROM stackoverflow.posts -WHERE PostTypeId = 'Question' -GROUP BY Year -ORDER BY Year ASC -FORMAT Vertical - - -Row 1: -────── -Year: 2008 -MostViewedQuestionTitle: How to find the index for a given item in a list? -MaxViewCount: 6316987 - -Row 2: -────── -Year: 2009 -MostViewedQuestionTitle: How do I undo the most recent local commits in Git? -MaxViewCount: 13962748 - -... - -Row 16: -─────── -Year: 2023 -MostViewedQuestionTitle: How do I solve "error: externally-managed-environment" every time I use pip 3? -MaxViewCount: 506822 - -Row 17: -─────── -Year: 2024 -MostViewedQuestionTitle: Warning "Third-party cookie will be blocked. Learn more in the Issues tab" -MaxViewCount: 66975 - -17 rows in set. Elapsed: 0.225 sec. Processed 24.35 million rows, 1.86 GB (107.99 million rows/s., 8.26 GB/s.) -Peak memory usage: 377.26 MiB. -``` - -## 条件和数组 {#conditionals-and-arrays} - -条件和数组函数显著简化查询。以下查询计算从 2022 年到 2023 年标签(出现次数超过 10000 次)的百分比最大增幅。请注意,得益于条件、数组函数以及在 `HAVING` 和 `SELECT` 子句中重用别名,以下 ClickHouse 查询十分简洁。 - -_BigQuery_ - - - -_ClickHouse_ - -```sql -SELECT - arrayJoin(arrayFilter(t -> (t != ''), splitByChar('|', Tags))) AS tag, - countIf(toYear(CreationDate) = 2023) AS count_2023, - countIf(toYear(CreationDate) = 2022) AS count_2022, - ((count_2023 - count_2022) / count_2022) * 100 AS percent_change -FROM stackoverflow.posts -WHERE toYear(CreationDate) IN (2022, 2023) -GROUP BY tag -HAVING (count_2022 > 10000) AND (count_2023 > 10000) -ORDER BY percent_change DESC -LIMIT 5 - -┌─tag─────────┬─count_2023─┬─count_2022─┬──────percent_change─┐ -│ next.js │ 13788 │ 10520 │ 31.06463878326996 │ -│ spring-boot │ 16573 │ 17721 │ -6.478189718413183 │ -│ .net │ 11458 │ 12968 │ -11.644046884639112 │ -│ azure │ 11996 │ 14049 │ -14.613139725247349 │ -│ docker │ 13885 │ 16877 │ -17.72826924216389 │ -└─────────────┴────────────┴────────────┴─────────────────────┘ - -5 rows in set. Elapsed: 0.096 sec. Processed 5.08 million rows, 155.73 MB (53.10 million rows/s., 1.63 GB/s.) -Peak memory usage: 410.37 MiB. -``` - -这就是我们为从 BigQuery 迁移的用户提供的基本指南。我们建议从 BigQuery 迁移的用户阅读 [ClickHouse 的数据建模指南](/data-modeling/schema-design) 以了解更多高级 ClickHouse 特性。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/migrations/bigquery/migrating-to-clickhouse-cloud.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/migrations/bigquery/migrating-to-clickhouse-cloud.md.hash deleted file mode 100644 index d3ee2a4b9c9..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/migrations/bigquery/migrating-to-clickhouse-cloud.md.hash +++ /dev/null @@ -1 +0,0 @@ -ff0f3402f5cada3e diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/migrations/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/migrations/index.md deleted file mode 100644 index 91595988411..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/migrations/index.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -'slug': 'migrations' -'title': '迁移' -'pagination_prev': null -'pagination_next': null -'description': '迁移部分的登录页面' ---- - -| 页面 | 描述 | -|-------------------------------------------------------------------|--------------------------------| -| [BigQuery](bigquery/index.md) | BigQuery 的迁移指南 | -| [Snowflake](./snowflake.md) | Snowflake 的迁移指南 | -| [PostgreSQL](postgres/index.md) | PostgreSQL 的迁移指南 | -| [MySQL](../integrations/data-ingestion/dbms/mysql/index.md) | MySQL 的迁移指南 | -| [Redshift](../integrations/data-ingestion/redshift/index.md) | Redshift 的迁移指南 | -| [DynamoDB](../integrations/data-ingestion/dbms/dynamodb/index.md) | DynamoDB 的迁移指南 | -| [Rockset](../integrations/migration/rockset.md) | Rockset 的迁移指南 | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/migrations/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/migrations/index.md.hash deleted file mode 100644 index 9871abba660..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/migrations/index.md.hash +++ /dev/null @@ -1 +0,0 @@ -9a4ec4aa2ec4bbec diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/migrations/postgres/appendix.md b/i18n/zh/docusaurus-plugin-content-docs/current/migrations/postgres/appendix.md deleted file mode 100644 index 9b99c1592ca..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/migrations/postgres/appendix.md +++ /dev/null @@ -1,192 +0,0 @@ ---- -'slug': '/migrations/postgresql/appendix' -'title': '附录' -'keywords': -- 'postgres' -- 'postgresql' -- 'data types' -- 'types' -'description': '与迁移自 PostgreSQL 相关的附加信息' ---- - -import postgresReplicas from '@site/static/images/integrations/data-ingestion/dbms/postgres-replicas.png'; -import Image from '@theme/IdealImage'; - -## Postgres与ClickHouse:相应的概念和不同之处 {#postgres-vs-clickhouse-equivalent-and-different-concepts} - -来自OLTP系统的用户,习惯于ACID事务,应当意识到ClickHouse在不完全提供这些事务的情况下,为了性能做出了刻意的妥协。如果充分理解ClickHouse的语义,可以实现高持久性保证和高写入吞吐量。我们在下面强调了一些关键概念,用户在从Postgres切换到ClickHouse之前应该熟悉这些。 - -### 分片与副本 {#shards-vs-replicas} - -分片和复制是用于超越单个Postgres实例进行扩展的两种策略,当存储和/或计算成为性能瓶颈时使用。在Postgres中,分片涉及将大型数据库拆分成多个、更易于管理的小部分,分布在多个节点上。然而,Postgres并不原生支持分片。相反,分片可以通过使用如[Citus](https://www.citusdata.com/)的扩展来实现,此时Postgres变成一个能够进行水平扩展的分布式数据库。这种方法允许Postgres通过在多台机器之间分散负载来处理更高的事务速率和更大的数据集。分片可以是基于行或模式,以便为工作负载类型(例如事务性或分析性)提供灵活性。分片可能会在数据管理和查询执行方面引入显著的复杂性,因为它需要在多个机器之间进行协调和一致性保证。 - -与分片不同,副本是包含来自主节点的全部或部分数据的额外Postgres实例。创建副本的原因多种多样,包括增强读取性能和高可用性(HA)场景。物理复制是Postgres的一个原生功能,涉及将整个数据库或其重要部分复制到另一台服务器,包括所有数据库、表和索引。这包括通过TCP/IP将WAL片段从主节点流式传输到副本。相比之下,逻辑复制则是一种更高层次的抽象,基于`INSERT`、`UPDATE`和`DELETE`操作流式传输变化。尽管物理复制能够实现相同的结果,但逻辑复制为目标特定表和操作、数据变换以及支持不同Postgres版本提供了更大的灵活性。 - -**相对而言,ClickHouse的分片和副本是与数据分布和冗余相关的两个关键概念**。ClickHouse的副本可以被视为与Postgres副本相似,尽管复制是最终一致的,并没有主节点的概念。与Postgres不同,ClickHouse原生支持分片。 - -一个分片是你的表数据的一部分。你总是至少有一个分片。在多个服务器之间分片数据可以用来分担负载,特别是在单台服务器的容量被超过时,通过将所有分片用来并行运行查询。用户可以手动为表在不同服务器上创建分片,并直接向它们插入数据。或者,可以使用分布式表,通过定义分片键来确定数据的路由。分片键可以是随机的或哈希函数的输出。重要的是,一个分片可以包含多个副本。 - -一个副本是你数据的副本。ClickHouse总是至少有一个副本的数据,因此最小副本数量为一个。添加第二个副本提供了容错能力,并可能为处理更多查询提供额外的计算能力([并行副本](https://clickhouse.com/blog/clickhouse-release-23-03#parallel-replicas-for-utilizing-the-full-power-of-your-replicas-nikita-mikhailov)也可用于为单个查询分配计算,从而降低延迟)。副本是通过[ReplicatedMergeTree表引擎](/engines/table-engines/mergetree-family/replication)实现的,该引擎使ClickHouse能够在不同服务器之间保持多个数据副本的同步。复制是物理的:仅在节点之间传输压缩的部分,而不是查询。 - -总之,副本是提供冗余和可靠性(并可能进行分布式处理)的数据副本,而分片是允许分布式处理和负载均衡的数据子集。 - -> ClickHouse Cloud使用单一复制的数据,存储在S3上,并配有多个计算副本。数据对每个副本节点可用,每个节点都有一个本地SSD缓存。这仅依赖于通过ClickHouse Keeper的元数据复制。 - -## 最终一致性 {#eventual-consistency} - -ClickHouse使用ClickHouse Keeper(C++版的ZooKeeper实现,亦可使用ZooKeeper)来管理其内部复制机制,主要专注于元数据存储和确保最终一致性。Keeper用于在分布式环境中为每个插入分配唯一的顺序编号。这对于维护操作之间的顺序和一致性至关重要。这个框架还处理后台操作,如合并和变更,确保这些工作的分配,同时保证它们在所有副本中以相同的顺序执行。除了元数据,Keeper还充当一个全面的控制中心,负责复制,包括跟踪存储数据部分的校验和,并在副本之间充当分布式通知系统。 - -ClickHouse的复制过程(1)在数据插入到任何副本时开始。此数据在其原始插入形式下(2)写入磁盘,并附上其校验和。写入后,副本(3)尝试在Keeper中注册这一新数据部分,通过分配唯一的块编号并记录新部分的详细信息。其他副本在(4)检测到复制日志中的新条目后,(5)通过内部HTTP协议下载相应的数据部分,并与ZooKeeper中列出的校验和进行验证。该方法确保尽管处理速度或潜在延迟不同,所有副本最终持有一致且最新的数据。此外,系统能够同时处理多个操作,优化数据管理过程,并允许系统可扩展性和对硬件差异的鲁棒性。 - - - -请注意,ClickHouse Cloud使用的[云优化复制机制](https://clickhouse.com/blog/clickhouse-cloud-boosts-performance-with-sharedmergetree-and-lightweight-updates)适应了其存储与计算架构的分离。通过将数据存储在共享对象存储中,数据自动对所有计算节点可用,而无需在节点之间物理复制数据。相反,Keeper仅用于在计算节点之间共享元数据(哪些数据存储在共享对象存储中)。 - -PostgreSQL采用的复制策略与ClickHouse不同,主要使用流式复制,包括一个主副本模型,在该模型中,数据从主节点持续流式传输到一个或多个副本节点。这种复制类型确保了近实时的一致性,并且是同步的或异步的,使管理员能够控制可用性和一致性之间的平衡。与ClickHouse不同,PostgreSQL依赖WAL(写前日志)与逻辑复制和解码,将数据对象和变化在节点间流式传输。这种在PostgreSQL中的方法更简单,但在高度分布的环境中可能无法提供ClickHouse通过其复杂的Keeper使用实现的同样级别的可扩展性和容错能力。 - -## 用户影响 {#user-implications} - -在ClickHouse中,肮脏读取的可能性——用户可以将数据写入一个副本,然后从另一个副本读取可能未被复制的数据——来自于其通过Keeper管理的最终一致性复制模型。该模型强调在分布式系统中追求性能和可扩展性,使副本能够独立操作并异步同步。因此,取决于复制延迟以及变化传播所需的时间,新插入的数据可能不会立即在所有副本中可见。 - -相比之下,PostgreSQL的流式复制模型通常可以通过采用同步复制选项来防止肮脏读取,在此情况下,主节点在确认至少有一个副本收到数据后再提交事务。这确保了一旦事务提交,便有保证数据在另一个副本中可用。在主故障的情况下,副本将确保查询看到已提交的数据,从而维持更严格的一致性水平。 - -## 推荐 {#recommendations} - -新接触ClickHouse的用户应了解这些差异,这将在复制环境中表现出来。通常,最终一致性在分析数十亿,甚至数万亿数据点时是足够的——在这些情况下,指标要么更加稳定,要么估算是足够的,因为新数据以高速度持续插入。 - -如果需要提高读取的一致性,有几种选项可用。两个示例都要求增加复杂性或开销——降低查询性能并使ClickHouse的扩展变得更具挑战性。**我们建议仅在绝对必要时采用这些方法。** - -## 一致路由 {#consistent-routing} - -为了克服最终一致性的一些限制,用户可以确保客户端路由到相同的副本。这在多个用户查询ClickHouse且结果应在请求之间是确定性时非常有用。虽然结果可能会随新数据的插入而有所不同,但应确保查询相同的副本,以确保一致的视图。 - -这可以通过几种方法实现,具体取决于你的架构和使用的是ClickHouse OSS还是ClickHouse Cloud。 - -## ClickHouse Cloud {#clickhouse-cloud} - -ClickHouse Cloud使用单一复制的数据,存储在S3上,并配有多个计算副本。数据对每个副本节点可用,每个节点都有一个本地SSD缓存。为了确保一致的结果,用户只需确保路由到相同节点的一致性。 - -与ClickHouse Cloud服务的节点之间的通信通过代理进行。HTTP和原生协议连接将在保持打开期间路由到相同节点。在大多数客户端的HTTP 1.1连接中,这取决于Keep-Alive窗口。这可以在 大多数客户端(例如Node Js)上进行配置。这还需要服务器端配置,通常设置为比客户端高,并在ClickHouse Cloud中设置为10秒。 - -为确保连接之间(例如,在使用连接池或连接过期时)的一致路由,用户可以确保使用相同的连接(对于原生更容易)或请求暴露粘性端点。这为集群中的每个节点提供了一组端点,从而使客户端能够确保查询被确定性路由。 - -> 联系支持以获取粘性端点的访问权限。 - -## ClickHouse OSS {#clickhouse-oss} - -在OSS中实现这种行为取决于你的分片和副本拓扑,以及你是否使用[分布式表](/engines/table-engines/special/distributed)进行查询。 - -当你只有一个分片和副本(由于ClickHouse垂直扩展,通常是这种情况)时,用户在客户层选择节点,并直接查询一个副本,以确保这是确定性的选择。 - -虽然没有分布式表的多分片和副本的拓扑也是可能的,但这些高级部署通常具有自己的路由基础设施。因此,我们假设具有多个分片的部署使用分布式表(分布式表可用于单分片部署,但通常不必要)。 - -在这种情况下,用户应确保根据属性(例如`session_id`或`user_id`)执行一致的节点路由。设置[`prefer_localhost_replica=0`](/operations/settings/settings#prefer_localhost_replica)和[`load_balancing=in_order`](/operations/settings/settings#load_balancing)应在[查询中设置](/operations/settings/query-level)。这将确保优先使用同一分片的本地副本,其他副本按配置中列出进行优先选择 - 若错误数量相同,则在错误较高的情况下将随机选择进行故障转移。[ `load_balancing=nearest_hostname`](/operations/settings/settings#load_balancing)也可用作这种确定性分片选择的替代方案。 - -> 创建分布式表时,用户将指定一个集群。此集群定义在config.xml中,将列出分片(及其副本) - 因此允许用户控制从每个节点中使用的顺序。使用此方法,用户可以确保选择是确定性的。 - -## 顺序一致性 {#sequential-consistency} - -在特殊情况下,用户可能需要顺序一致性。 - -数据库中的顺序一致性是索引操作在数据库上以某种顺序执行,并且这种顺序在与数据库交互的所有进程中是一致的。这意味着每个操作似乎在其调用和完成之间瞬间生效,并且所有操作被任何进程观察到的顺序达成一致。 - -从用户的角度来看,这通常表现为需将数据写入ClickHouse,并在读取数据时,确保返回最新插入的行。 -这可以通过几种方式实现(按偏好顺序): - -1. **读/写到同一节点** - 如果使用的是原生协议或通过HTTP [会话进行读/写](/interfaces/http#default-database),则应连接到同一副本:在这种情况下,你是直接从正在写入的节点读取,因此你的读取将始终是一致的。 -1. **手动同步副本** - 如果你写入一个副本并从另一个副本读取,则可以在读取之前执行`SYSTEM SYNC REPLICA LIGHTWEIGHT`。 -1. **启用顺序一致性** - 通过查询设置[`select_sequential_consistency = 1`](/operations/settings/settings#select_sequential_consistency)。在OSS中,还必须指定设置`insert_quorum = 'auto'`。 - -
- -有关启用这些设置的更多详情,请参阅[此处](/cloud/reference/shared-merge-tree#consistency)。 - -> 使用顺序一致性将对ClickHouse Keeper施加更大的负载。结果可能意味着插入和读取速度变慢。ClickHouse Cloud中作为主表引擎使用的SharedMergeTree,顺序一致性[产生的开销较少且可更好地扩展](/cloud/reference/shared-merge-tree#consistency)。OSS用户应谨慎使用这种方法,并测量Keeper负载。 - -## 事务(ACID)支持 {#transactional-acid-support} - -从PostgreSQL迁移的用户可能会习惯于其对ACID(原子性、一致性、隔离性、持久性)属性的强大支持,使其成为事务数据库的可靠选择。PostgreSQL中的原子性确保每个事务被视为一个单一的单位,要么完全成功,要么完全回滚,防止部分更新。一致性通过强制执行约束、触发器和规则来维持,确保所有数据库事务导致有效状态。PostgreSQL支持从已提交读取到可串行化的隔离级别,允许对并发事务的更改可见性进行细粒度控制。最后,通过写前日志(WAL)实现持久性,确保一旦事务被提交,即使在系统故障事件中也依然如此。 - -这些属性是作为真实来源的OLTP数据库的共同特征。 - -虽然功能强大,但这也伴随着固有的限制,使得PB规模的挑战。ClickHouse在这些属性上做出了妥协,以提供快速的分析查询,同时维持高写入吞吐量。 - -在[有限配置下](/guides/developer/transactional) ClickHouse提供ACID属性 - 通常是在使用非复制实例的MergeTree表引擎时,仅有一个分区。用户不应期望在这些情况之外有这些属性,并确保这些不是必须的要求。 - -## 压缩 {#compression} - -ClickHouse的列式存储意味着与Postgres相比,压缩通常会显著更好。以下是在比较这两个数据库中所有Stack Overflow表的存储需求时的说明: - -```sql title="Query (Postgres)" -SELECT - schemaname, - tablename, - pg_total_relation_size(schemaname || '.' || tablename) AS total_size_bytes, - pg_total_relation_size(schemaname || '.' || tablename) / (1024 * 1024 * 1024) AS total_size_gb -FROM - pg_tables s -WHERE - schemaname = 'public'; -``` - -```sql title="Query (ClickHouse)" -SELECT - `table`, - formatReadableSize(sum(data_compressed_bytes)) AS compressed_size -FROM system.parts -WHERE (database = 'stackoverflow') AND active -GROUP BY `table` -``` - -```response title="Response" -┌─table───────┬─compressed_size─┐ -│ posts │ 25.17 GiB │ -│ users │ 846.57 MiB │ -│ badges │ 513.13 MiB │ -│ comments │ 7.11 GiB │ -│ votes │ 1.28 GiB │ -│ posthistory │ 40.44 GiB │ -│ postlinks │ 79.22 MiB │ -└─────────────┴─────────────────┘ -``` - -有关优化和测量压缩的更多详细信息,请参阅[此处](/data-compression/compression-in-clickhouse)。 - -## 数据类型映射 {#data-type-mappings} - -下表显示了Postgres的等效ClickHouse数据类型。 - -| Postgres 数据类型 | ClickHouse 类型 | -| --- | --- | -| `DATE` | [Date](/sql-reference/data-types/date) | -| `TIMESTAMP` | [DateTime](/sql-reference/data-types/datetime) | -| `REAL` | [Float32](/sql-reference/data-types/float) | -| `DOUBLE` | [Float64](/sql-reference/data-types/float) | -| `DECIMAL, NUMERIC` | [Decimal](/sql-reference/data-types/decimal) | -| `SMALLINT` | [Int16](/sql-reference/data-types/int-uint) | -| `INTEGER` | [Int32](/sql-reference/data-types/int-uint) | -| `BIGINT` | [Int64](/sql-reference/data-types/int-uint) | -| `SERIAL` | [UInt32](/sql-reference/data-types/int-uint) | -| `BIGSERIAL` | [UInt64](/sql-reference/data-types/int-uint) | -| `TEXT, CHAR, BPCHAR` | [String](/sql-reference/data-types/string) | -| `INTEGER` | Nullable([Int32](/sql-reference/data-types/int-uint)) | -| `ARRAY` | [Array](/sql-reference/data-types/array) | -| `FLOAT4` | [Float32](/sql-reference/data-types/float) | -| `BOOLEAN` | [Bool](/sql-reference/data-types/boolean) | -| `VARCHAR` | [String](/sql-reference/data-types/string) | -| `BIT` | [String](/sql-reference/data-types/string) | -| `BIT VARYING` | [String](/sql-reference/data-types/string) | -| `BYTEA` | [String](/sql-reference/data-types/string) | -| `NUMERIC` | [Decimal](/sql-reference/data-types/decimal) | -| `GEOGRAPHY` | [Point](/sql-reference/data-types/geo#point), [Ring](/sql-reference/data-types/geo#ring), [Polygon](/sql-reference/data-types/geo#polygon), [MultiPolygon](/sql-reference/data-types/geo#multipolygon) | -| `GEOMETRY` | [Point](/sql-reference/data-types/geo#point), [Ring](/sql-reference/data-types/geo#ring), [Polygon](/sql-reference/data-types/geo#polygon), [MultiPolygon](/sql-reference/data-types/geo#multipolygon) | -| `INET` | [IPv4](/sql-reference/data-types/ipv4), [IPv6](/sql-reference/data-types/ipv6) | -| `MACADDR` | [String](/sql-reference/data-types/string) | -| `CIDR` | [String](/sql-reference/data-types/string) | -| `HSTORE` | [Map(K, V)](/sql-reference/data-types/map), [Map](/sql-reference/data-types/map)(K,[Variant](/sql-reference/data-types/variant)) | -| `UUID` | [UUID](/sql-reference/data-types/uuid) | -| `ARRAY` | [ARRAY(T)](/sql-reference/data-types/array) | -| `JSON*` | [String](/sql-reference/data-types/string), [Variant](/sql-reference/data-types/variant), [Nested](/sql-reference/data-types/nested-data-structures/nested#nestedname1-type1-name2-type2-), [Tuple](/sql-reference/data-types/tuple) | -| `JSONB` | [String](/sql-reference/data-types/string) | - -*\* ClickHouse对JSON的生产支持正在开发中。当前,用户可以将JSON映射为String,并使用[JSON函数](/sql-reference/functions/json-functions),或将JSON直接映射到[Tuples](/sql-reference/data-types/tuple)和[Nested](/sql-reference/data-types/nested-data-structures/nested),如果结构是可预测的。有关JSON的更多信息,请[点击此处](/integrations/data-formats/json/overview)。* diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/migrations/postgres/appendix.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/migrations/postgres/appendix.md.hash deleted file mode 100644 index f885a115c33..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/migrations/postgres/appendix.md.hash +++ /dev/null @@ -1 +0,0 @@ -8aebde03171e3d55 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/migrations/postgres/data-modeling-techniques.md b/i18n/zh/docusaurus-plugin-content-docs/current/migrations/postgres/data-modeling-techniques.md deleted file mode 100644 index 207fc0cceb1..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/migrations/postgres/data-modeling-techniques.md +++ /dev/null @@ -1,262 +0,0 @@ ---- -'slug': '/migrations/postgresql/data-modeling-techniques' -'title': '数据建模技术' -'description': '用于从 PostgreSQL 迁移到 ClickHouse 的数据建模' -'keywords': -- 'postgres' -- 'postgresql' -'show_related_blogs': true ---- - -import postgres_b_tree from '@site/static/images/migrations/postgres-b-tree.png'; -import postgres_sparse_index from '@site/static/images/migrations/postgres-sparse-index.png'; -import postgres_partitions from '@site/static/images/migrations/postgres-partitions.png'; -import postgres_projections from '@site/static/images/migrations/postgres-projections.png'; -import Image from '@theme/IdealImage'; - -> 这是关于从 PostgreSQL 迁移到 ClickHouse 的指南的 **第 3 部分**。通过一个实际示例,它演示了如果从 PostgreSQL 迁移,如何在 ClickHouse 中建模数据。 - -我们建议从 PostgreSQL 迁移的用户阅读 [ClickHouse 中数据建模的指南](/data-modeling/schema-design)。本指南使用相同的 Stack Overflow 数据集,并探索多种使用 ClickHouse 特性的方式。 - -## ClickHouse 中的主(排序)键 {#primary-ordering-keys-in-clickhouse} - -来自 OLTP 数据库的用户通常会寻找 ClickHouse 中的等效概念。在注意到 ClickHouse 支持 `PRIMARY KEY` 语法后,用户可能会倾向于使用与其源 OLTP 数据库相同的键来定义其表模式。这是不合适的。 - -### ClickHouse 主键有何不同? {#how-are-clickhouse-primary-keys-different} - -要理解为什么在 ClickHouse 中使用 OLTP 主键不合适,用户需要了解 ClickHouse 索引的基本知识。我们以 Postgres 为例,但这些一般概念适用于其他 OLTP 数据库。 - -- Postgres 主键在定义上是每行唯一的。使用 [B-tree 结构](/guides/best-practices/sparse-primary-indexes#an-index-design-for-massive-data-scales) 可以通过此键有效查找单行。虽然 ClickHouse 可以优化单行值的查找,但分析工作负载通常需要读取几个列,但对于很多行。过滤器通常需要识别 **一部分行**,在其上执行聚合。 -- 内存和磁盘效率对于 ClickHouse 通常使用的规模至关重要。数据以称为部分的块写入 ClickHouse 表,并在后台应用合并部分的规则。在 ClickHouse 中,每个部分都有自己的主索引。当部分被合并时,合并部分的主索引也会合并。与 Postgres 不同,这些索引并不是为每一行构建的。相反,一个部分的主索引为每组行有一个索引条目 - 这种技术称为 **稀疏索引**。 -- **稀疏索引** 是可能的,因为 ClickHouse 将部分的行在磁盘上按指定键的顺序存储。与直接定位单行(如基于 B-Tree 的索引)不同,稀疏主索引允许它快速(通过对索引条目进行二分查找)识别可能匹配查询的行组。定位的可能匹配行组随后会并行流入 ClickHouse 引擎以找到匹配项。这种索引设计允许主索引较小(完全适合主内存),同时仍显著加速查询执行时间,尤其是对于数据分析用例中典型的范围查询。 - -有关更多详细信息,我们推荐这份 [深入指南](/guides/best-practices/sparse-primary-indexes)。 - - - - - -在 ClickHouse 中选择的键不仅会决定索引,还会决定数据在磁盘上写入的顺序。因此,它可以显著影响压缩级别,这反过来又会影响查询性能。导致大多数列的值按连续顺序写入的排序键将允许所选的压缩算法(和编解码器)更有效地压缩数据。 - -> 表中的所有列将根据指定排序键的值进行排序,无论它们是否包含在键中。例如,如果 `CreationDate` 被用作键,则所有其他列中的值的顺序将与 `CreationDate` 列中的值的顺序相对应。可以指定多个排序键 - 这将具有与 `SELECT` 查询中的 `ORDER BY` 子句相同的语义。 - -### 选择排序键 {#choosing-an-ordering-key} - -有关选择排序键的考虑和步骤,使用 `posts` 表作为示例,请见 [这里](/data-modeling/schema-design#choosing-an-ordering-key)。 - -在使用实时复制与 CDC 时,还需考虑其他约束,参考此 [文档](/integrations/clickpipes/postgres/ordering_keys) 以获取如何使用 CDC 自定义排序键的技术。 - -## 分区 {#partitions} - -Postgres 用户将熟悉通过将表分为更小、更易于管理的部分,称为分区,来增强大数据库性能和可管理性的表分区概念。这种分区可以通过在指定列上使用范围(例如,日期)、定义的列表或通过键的哈希来实现。这使管理员能够根据特定标准(如日期范围或地理位置)组织数据。分区通过允许更快的数据访问,帮助提高查询性能,通过分区修剪和更有效的索引。它还帮助维护任务,如备份和数据清除,因为可以对单个分区进行操作,而不是整个表。此外,分区可以通过将负载分散到多个分区来显著提高 PostgreSQL 数据库的可扩展性。 - -在 ClickHouse 中,分区在通过 `PARTITION BY` 子句最初定义表时指定。该子句可以包含任何列上的 SQL 表达式,其结果将定义行被发送到哪个分区。 - - - -数据部分在磁盘上与每个分区逻辑关联,可以单独查询。以下示例中,我们使用表达式 `toYear(CreationDate)` 按年份对 `posts` 表进行分区。当行插入 ClickHouse 时,此表达式将针对每行进行评估,并在存在时路由到结果分区(如果该行是年份的第一个,则将创建该分区)。 - -```sql - CREATE TABLE posts -( - `Id` Int32 CODEC(Delta(4), ZSTD(1)), - `PostTypeId` Enum8('Question' = 1, 'Answer' = 2, 'Wiki' = 3, 'TagWikiExcerpt' = 4, 'TagWiki' = 5, 'ModeratorNomination' = 6, 'WikiPlaceholder' = 7, 'PrivilegeWiki' = 8), - `AcceptedAnswerId` UInt32, - `CreationDate` DateTime64(3, 'UTC'), -... - `ClosedDate` DateTime64(3, 'UTC') -) -ENGINE = MergeTree -ORDER BY (PostTypeId, toDate(CreationDate), CreationDate) -PARTITION BY toYear(CreationDate) -``` - -有关分区的完整描述,请参见 ["表分区"](/partitions)。 - -### 分区的应用 {#applications-of-partitions} - -ClickHouse 中的分区与 Postgres 中的应用相似,但有一些细微差异。更具体地说: - -- **数据管理** - 在 ClickHouse 中,用户应主要将分区视为数据管理功能,而不是查询优化技术。通过根据关键字逻辑上分离数据,每个分区可以独立操作,例如删除。这允许用户在时间上有效地在 [存储层](/integrations/s3#storage-tiers) 之间移动分区,从而移动子集,或通过 [有效地从集群中过期或删除数据](/sql-reference/statements/alter/partition)。在下面的示例中,我们移除 2008 年的帖子。 - -```sql -SELECT DISTINCT partition -FROM system.parts -WHERE `table` = 'posts' - -┌─partition─┐ -│ 2008 │ -│ 2009 │ -│ 2010 │ -│ 2011 │ -│ 2012 │ -│ 2013 │ -│ 2014 │ -│ 2015 │ -│ 2016 │ -│ 2017 │ -│ 2018 │ -│ 2019 │ -│ 2020 │ -│ 2021 │ -│ 2022 │ -│ 2023 │ -│ 2024 │ -└───────────┘ - -17 rows in set. Elapsed: 0.002 sec. - -ALTER TABLE posts -(DROP PARTITION '2008') - -Ok. - -0 rows in set. Elapsed: 0.103 sec. -``` - -- **查询优化** - 尽管分区可以帮助提高查询性能,但这在很大程度上取决于访问模式。如果查询仅针对少数几个分区(理想情况下是一个),性能可以得到提升。通常情况下,仅在分区键不在主键中并且您通过它进行过滤的情况下,这才有用。然而,需要覆盖许多分区的查询可能性能会比不使用分区的情况更差(因为可能会产生更多分区片段)。如果分区键已经是主键中的一个早期条目,面向单个分区的好处将变得微乎其微甚至不存在。分区还可以用于 [优化 GROUP BY 查询](/engines/table-engines/mergetree-family/custom-partitioning-key#group-by-optimisation-using-partition-key),如果每个分区中的值是唯一的。然而,通常情况下,用户应确保主键被优化,仅在访问模式访问特定可预测的子集的特殊情况下考虑分区,例如按天分区,并且大多数查询是在最后一天。 - -### 分区的建议 {#recommendations-for-partitions} - -用户应将分区视为一种数据管理技术。在处理时间序列数据时,当需要从集群中过期数据时,它是理想的。例如,最旧的分区可以 [简单地被删除](/sql-reference/statements/alter/partition#drop-partitionpart)。 - -**重要事项:** 确保您的分区键表达式不会导致高基数集,即应该避免创建超过 100 个分区。例如,不要通过高基数列(如客户标识符或姓名)对数据进行分区。相反,在 `ORDER BY` 表达式中将客户标识符或姓名设置为第一列。 - -> 内部,ClickHouse [创建分区](/guides/best-practices/sparse-primary-indexes#clickhouse-index-design) 用于插入的数据。随着更多数据的插入,部分数量增加。为了防止过多的部分,这会降低查询性能(需要读取更多文件),部分在后台异步进程中合并。如果部分数量超过预配置的限制,则 ClickHouse 将在插入时抛出异常 - 作为“部分过多”错误。在正常操作下,这不应发生,仅在 ClickHouse 配置不当或使用不当时(例如,许多小插入)会发生。 - -> 由于每个分区内部隔离地创建部分,因此增加分区数量会导致部分数量增加,即它是分区数量的倍数。因此,高基数分区键可能导致此错误,应该避免使用。 - -## 物化视图与投影 {#materialized-views-vs-projections} - -Postgres 允许在单个表上创建多个索引,以优化多种访问模式。这种灵活性使管理员和开发人员能够根据特定查询和操作需求调整数据库性能。ClickHouse 的投影概念尽管与此不完全相同,但允许用户为一个表指定多个 `ORDER BY` 子句。 - -在 ClickHouse [数据建模文档](/data-modeling/schema-design) 中,我们探讨了如何在 ClickHouse 中使用物化视图来预计算聚合、转换行和优化不同访问模式的查询。 - -对于这些,展示了 [一个示例](/materialized-view/incremental-materialized-view#lookup-table),物化视图将行发送到目标表,该表的排序键与接收插入的原始表不同。 - -例如,考虑以下查询: - -```sql -SELECT avg(Score) -FROM comments -WHERE UserId = 8592047 - - ┌──────────avg(Score)─┐ -1. │ 0.18181818181818182 │ - └─────────────────────┘ - -1 row in set. Elapsed: 0.040 sec. Processed 90.38 million rows, 361.59 MB (2.25 billion rows/s., 9.01 GB/s.) -Peak memory usage: 201.93 MiB. -``` - -该查询需要扫描所有 9000 万行(虽然速度很快),因为 `UserId` 并不是排序键。之前,我们使用物化视图作为 `PostId` 的查找解决了这个问题。通过 [投影](/data-modeling/projections) 可以解决同样的问题。下面的命令为 `ORDER BY user_id` 添加了一个投影。 - -```sql -ALTER TABLE comments ADD PROJECTION comments_user_id ( -SELECT * ORDER BY UserId -) - -ALTER TABLE comments MATERIALIZE PROJECTION comments_user_id -``` - -注意,我们必须先创建投影,然后使其物化。后一条命令会导致数据在磁盘上以不同顺序存储两次。投影也可以在数据创建时定义,如下所示,并将在数据插入时自动维护。 - -```sql -CREATE TABLE comments -( - `Id` UInt32, - `PostId` UInt32, - `Score` UInt16, - `Text` String, - `CreationDate` DateTime64(3, 'UTC'), - `UserId` Int32, - `UserDisplayName` LowCardinality(String), - PROJECTION comments_user_id - ( - SELECT * - ORDER BY UserId - ) -) -ENGINE = MergeTree -ORDER BY PostId -``` - -如果通过 `ALTER` 创建投影,则在发出 `MATERIALIZE PROJECTION` 命令时创建是异步的。用户可以使用以下查询确认此操作的进度,等待 `is_done=1`。 - -```sql -SELECT - parts_to_do, - is_done, - latest_fail_reason -FROM system.mutations -WHERE (`table` = 'comments') AND (command LIKE '%MATERIALIZE%') - - ┌─parts_to_do─┬─is_done─┬─latest_fail_reason─┐ -1. │ 1 │ 0 │ │ - └─────────────┴─────────┴────────────────────┘ - -1 row in set. Elapsed: 0.003 sec. -``` - -如果我们重复上述查询,可以看到性能显著提高,代价是额外的存储。 - -```sql -SELECT avg(Score) -FROM comments -WHERE UserId = 8592047 - - ┌──────────avg(Score)─┐ -1. │ 0.18181818181818182 │ - └─────────────────────┘ - -1 row in set. Elapsed: 0.008 sec. Processed 16.36 thousand rows, 98.17 KB (2.15 million rows/s., 12.92 MB/s.) -Peak memory usage: 4.06 MiB. -``` - -使用 `EXPLAIN` 命令,我们还确认了投影被用于服务此查询: - -```sql -EXPLAIN indexes = 1 -SELECT avg(Score) -FROM comments -WHERE UserId = 8592047 - - ┌─explain─────────────────────────────────────────────┐ - 1. │ Expression ((Projection + Before ORDER BY)) │ - 2. │ Aggregating │ - 3. │ Filter │ - 4. │ ReadFromMergeTree (comments_user_id) │ - 5. │ Indexes: │ - 6. │ PrimaryKey │ - 7. │ Keys: │ - 8. │ UserId │ - 9. │ Condition: (UserId in [8592047, 8592047]) │ -10. │ Parts: 2/2 │ -11. │ Granules: 2/11360 │ - └─────────────────────────────────────────────────────┘ - -11 rows in set. Elapsed: 0.004 sec. -``` - -### 何时使用投影 {#when-to-use-projections} - -投影对于新用户来说是一个吸引人的特性,因为它们在插入数据时会自动维护。此外,查询可以简单地发送到单个表,在可能的情况下利用投影以加快响应时间。 - - - -这与物化视图形成对比,物化视图要求用户选择适当的优化目标表或根据过滤器重写查询。这在用户应用中增加了更大的复杂性,并增加了客户端的复杂性。 - -尽管有这些优势,投影也有一些 [固有限制](/data-modeling/projections#when-to-use-projections),用户应该意识到,因此应谨慎使用。 - -我们建议在以下情况下使用投影: - -- 需要完全重新排序数据。虽然投影中的表达式可以理论上使用 `GROUP BY`,但物化视图更有效地维护聚合。查询优化器也更可能利用使用简单重新排序的投影,即 `SELECT * ORDER BY x`。用户可以在该表达式中选择列的子集,以减少存储占用。 -- 用户对相关的存储占用和重复写入数据的开销感到满意。测试插入速度的影响,并 [评估存储开销](/data-compression/compression-in-clickhouse)。 - -## 反规范化 {#denormalization} - -由于 Postgres 是关系型数据库,其数据模型通常高度 [规范化](https://en.wikipedia.org/wiki/Database_normalization),通常涉及数百个表。在 ClickHouse 中,反规范化有时可以优化 JOIN 性能。 - -您可以参考这份 [指南](/data-modeling/denormalization),显示了在 ClickHouse 中反规范化 Stack Overflow 数据集的好处。 - -这结束了我们为从 Postgres 迁移到 ClickHouse 的用户提供的基本指南。我们建议从 Postgres 迁移的用户阅读 [ClickHouse 中数据建模的指南](/data-modeling/schema-design),以了解有关 ClickHouse 高级功能的更多信息。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/migrations/postgres/data-modeling-techniques.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/migrations/postgres/data-modeling-techniques.md.hash deleted file mode 100644 index 0735aa951fb..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/migrations/postgres/data-modeling-techniques.md.hash +++ /dev/null @@ -1 +0,0 @@ -d3b274257da9b4d8 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/migrations/postgres/dataset.md b/i18n/zh/docusaurus-plugin-content-docs/current/migrations/postgres/dataset.md deleted file mode 100644 index d749527f2e8..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/migrations/postgres/dataset.md +++ /dev/null @@ -1,188 +0,0 @@ ---- -'slug': '/migrations/postgresql/dataset' -'title': '迁移数据' -'description': '示例数据集从 PostgreSQL 迁移到 ClickHouse' -'keywords': -- 'Postgres' -'show_related_blogs': true ---- - -import postgres_stackoverflow_schema from '@site/static/images/migrations/postgres-stackoverflow-schema.png'; -import Image from '@theme/IdealImage'; - -> 这是关于将 PostgreSQL 迁移到 ClickHouse 的指南的 **第 1 部分**。通过一个实用示例,它展示了如何使用实时复制 (CDC) 方法高效地执行迁移。涵盖的许多概念同样适用于从 PostgreSQL 到 ClickHouse 的手动批量数据转移。 - -## 数据集 {#dataset} - -作为展示从 Postgres 到 ClickHouse 的典型迁移的示例数据集,我们使用 Stack Overflow 数据集,该数据集的详细信息可在 [这里](/getting-started/example-datasets/stackoverflow) 找到。它包含自 2008 年至 2024 年 4 月期间 Stack Overflow 上发生的每个 `post`、`vote`、`user`、`comment` 和 `badge`。该数据的 PostgreSQL 模式如下所示: - - - -*用于在 PostgreSQL 中创建表的 DDL 命令可在 [这里](https://pastila.nl/?001c0102/eef2d1e4c82aab78c4670346acb74d83#TeGvJWX9WTA1V/5dVVZQjg==) 获得。* - -该模式虽然不一定是最优的,但利用了多个流行的 PostgreSQL 特性,包括主键、外键、分区和索引。 - -我们将把这些概念迁移到它们的 ClickHouse 等价物。 - -对于希望将此数据集填充到 PostgreSQL 实例以测试迁移步骤的用户,我们提供了以 `pg_dump` 格式下载的数据,DDL 和后续数据加载命令如下: - -```bash - -# users -wget https://datasets-documentation.s3.eu-west-3.amazonaws.com/stackoverflow/pdump/2024/users.sql.gz -gzip -d users.sql.gz -psql < users.sql - - -# posts -wget https://datasets-documentation.s3.eu-west-3.amazonaws.com/stackoverflow/pdump/2024/posts.sql.gz -gzip -d posts.sql.gz -psql < posts.sql - - -# posthistory -wget https://datasets-documentation.s3.eu-west-3.amazonaws.com/stackoverflow/pdump/2024/posthistory.sql.gz -gzip -d posthistory.sql.gz -psql < posthistory.sql - - -# comments -wget https://datasets-documentation.s3.eu-west-3.amazonaws.com/stackoverflow/pdump/2024/comments.sql.gz -gzip -d comments.sql.gz -psql < comments.sql - - -# votes -wget https://datasets-documentation.s3.eu-west-3.amazonaws.com/stackoverflow/pdump/2024/votes.sql.gz -gzip -d votes.sql.gz -psql < votes.sql - - -# badges -wget https://datasets-documentation.s3.eu-west-3.amazonaws.com/stackoverflow/pdump/2024/badges.sql.gz -gzip -d badges.sql.gz -psql < badges.sql - - -# postlinks -wget https://datasets-documentation.s3.eu-west-3.amazonaws.com/stackoverflow/pdump/2024/postlinks.sql.gz -gzip -d postlinks.sql.gz -psql < postlinks.sql -``` - -对于 ClickHouse 来说,该数据集规模较小,但对 Postgres 来说则相当庞大。上述内容代表了涵盖 2024 年前三个月的一个子集。 - -> 尽管我们的示例结果使用完整数据集来显示 Postgres 和 ClickHouse 之间的性能差异,但下面文档中的所有步骤在功能上与较小的子集是完全相同的。希望将完整数据集加载到 Postgres 的用户可见 [这里](https://pastila.nl/?00d47a08/1c5224c0b61beb480539f15ac375619d#XNj5vX3a7ZjkdiX7In8wqA==)。由于上述模式施加的外键约束,PostgreSQL 的完整数据集仅包含满足引用完整性的行。如果需要,没有这些约束的 [Parquet 版本](/getting-started/example-datasets/stackoverflow) 可以直接加载到 ClickHouse 中。 - -## 数据迁移 {#migrating-data} - -### 实时复制 (CDC) {#real-time-replication-or-cdc} - -请参考此 [指南](/integrations/clickpipes/postgres) 来设置 PostgreSQL 的 ClickPipes。该指南涵盖了多种类型的源 Postgres 实例。 - -使用 ClickPipes 或 PeerDB 的 CDC 方法,PostgreSQL 数据库中的每个表会自动在 ClickHouse 中复制。 - -为了处理近实时的更新和删除,ClickPipes 使用 [ReplacingMergeTree](/engines/table-engines/mergetree-family/replacingmergetree) 引擎将 Postgres 表映射到 ClickHouse,该引擎专门设计用于处理 ClickHouse 中的更新和删除。您可以在 [这里](/integrations/clickpipes/postgres/deduplication#how-does-data-get-replicated) 找到有关数据如何通过 ClickPipes 复制到 ClickHouse 的更多信息。重要的是要注意,使用 CDC 进行的复制在 ClickHouse 中在复制更新或删除操作时会创建重复的行。请参见使用 [FINAL](https://clickhouse.com/docs/sql-reference/statements/select/from#final-modifier) 修饰符的 [技术](/integrations/clickpipes/postgres/deduplication#deduplicate-using-final-keyword) 来处理 ClickHouse 中的这些问题。 - -我们来看看如何使用 ClickPipes 在 ClickHouse 中创建 `users` 表。 - -```sql -CREATE TABLE users -( - `id` Int32, - `reputation` String, - `creationdate` DateTime64(6), - `displayname` String, - `lastaccessdate` DateTime64(6), - `aboutme` String, - `views` Int32, - `upvotes` Int32, - `downvotes` Int32, - `websiteurl` String, - `location` String, - `accountid` Int32, - `_peerdb_synced_at` DateTime64(9) DEFAULT now64(), - `_peerdb_is_deleted` Int8, - `_peerdb_version` Int64 -) -ENGINE = ReplacingMergeTree(_peerdb_version) -PRIMARY KEY id -ORDER BY id; -``` - -一旦设置完成,ClickPipes 就会开始将所有数据从 PostgreSQL 迁移到 ClickHouse。根据网络和部署的规模,这对于 Stack Overflow 数据集来说只需几分钟。 - -### 手动批量加载带定期更新 {#initial-bulk-load-with-periodic-updates} - -使用手动方法,可以通过以下方式实现数据集的初始批量加载: - -- **表函数** - 使用 ClickHouse 中的 [Postgres 表函数](/sql-reference/table-functions/postgresql) 从 Postgres `SELECT` 数据并将其 `INSERT` 到 ClickHouse 表中。相关于数百 GB 数据集的批量加载。 -- **导出** - 导出为中间格式,例如 CSV 或 SQL 脚本文件。这些文件可以通过 `INSERT FROM INFILE` 子句从客户端加载到 ClickHouse,或者使用对象存储及其相关功能,如 s3、gcs。 - -从 PostgreSQL 手动加载数据时,您需要首先在 ClickHouse 中创建表。请参考此 [数据建模文档](/data-modeling/schema-design#establish-initial-schema),该文档同样使用 Stack Overflow 数据集来优化 ClickHouse 中的表模式。 - -PostgreSQL 和 ClickHouse 之间的数据类型可能不同。为了确定每个表列的等效类型,我们可以使用 `DESCRIBE` 命令与 [Postgres 表函数](/sql-reference/table-functions/postgresql)。以下命令描述了 PostgreSQL 中的 `posts` 表,请根据您的环境进行修改: - -```sql title="Query" -DESCRIBE TABLE postgresql(':', 'postgres', 'posts', '', '') -SETTINGS describe_compact_output = 1 -``` - -有关 PostgreSQL 与 ClickHouse 之间的数据类型映射的概述,请参见 [附录文档](/migrations/postgresql/appendix#data-type-mappings)。 - -优化此模式的类型的步骤与从其他来源(例如 S3 上的 Parquet)加载数据时的步骤是相同的。按照此 [使用 Parquet 的替代指南](/data-modeling/schema-design) 中描述的过程可得出以下模式: - -```sql title="Query" -CREATE TABLE stackoverflow.posts -( - `Id` Int32, - `PostTypeId` Enum('Question' = 1, 'Answer' = 2, 'Wiki' = 3, 'TagWikiExcerpt' = 4, 'TagWiki' = 5, 'ModeratorNomination' = 6, 'WikiPlaceholder' = 7, 'PrivilegeWiki' = 8), - `AcceptedAnswerId` UInt32, - `CreationDate` DateTime, - `Score` Int32, - `ViewCount` UInt32, - `Body` String, - `OwnerUserId` Int32, - `OwnerDisplayName` String, - `LastEditorUserId` Int32, - `LastEditorDisplayName` String, - `LastEditDate` DateTime, - `LastActivityDate` DateTime, - `Title` String, - `Tags` String, - `AnswerCount` UInt16, - `CommentCount` UInt8, - `FavoriteCount` UInt8, - `ContentLicense`LowCardinality(String), - `ParentId` String, - `CommunityOwnedDate` DateTime, - `ClosedDate` DateTime -) -ENGINE = MergeTree -ORDER BY tuple() -COMMENT 'Optimized types' -``` - -我们可以通过简单的 `INSERT INTO SELECT` 填充这一表,读取 PostgresSQL 中的数据并插入到 ClickHouse 中: - -```sql title="Query" -INSERT INTO stackoverflow.posts SELECT * FROM postgresql(':', 'postgres', 'posts', '', '') -0 rows in set. Elapsed: 146.471 sec. Processed 59.82 million rows, 83.82 GB (408.40 thousand rows/s., 572.25 MB/s.) -``` - -增量加载可以进行调度。如果 Postgres 表仅接收插入且存在递增的 id 或时间戳,用户可以使用上述表函数方法加载增量,例如可以对 `SELECT` 应用 `WHERE` 子句。此方法也可以用于支持更新,如果保证这些更新是同一列的更新。支持删除将需要完整重新加载,这在表增长时可能难以实现。 - -我们演示使用 `CreationDate` 的初始加载和增量加载(我们假设如果行被更新则会更新此字段)。 - -```sql --- initial load -INSERT INTO stackoverflow.posts SELECT * FROM postgresql('', 'postgres', 'posts', 'postgres', '', 'postgres', 'posts', 'postgres', ' ( SELECT (max(CreationDate) FROM stackoverflow.posts) -``` - -> ClickHouse 将向 PostgreSQL 服务器推送简单的 `WHERE` 子句,例如 `=`、`!=`、`>`、`>=`、`<`、`<=` 和 IN。因此,通过确保在用于识别更改集的列上存在索引,可以提高增量加载的效率。 - -> 在使用查询复制时,检测 UPDATE 操作的一种可能方法是使用 [`XMIN` 系统列](https://www.postgresql.org/docs/9.1/ddl-system-columns.html)(事务 ID)作为水印——该列的变化表示变化,因此可以应用到目标表。采用此方法的用户应注意 `XMIN` 值可能会循环,比较需要完整表扫描,从而使跟踪变化变得更复杂。 - -[点击这里查看第 2 部分](./rewriting-queries.md) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/migrations/postgres/dataset.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/migrations/postgres/dataset.md.hash deleted file mode 100644 index 278ad6df762..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/migrations/postgres/dataset.md.hash +++ /dev/null @@ -1 +0,0 @@ -25c63176ca4ff5ad diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/migrations/postgres/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/migrations/postgres/index.md.hash deleted file mode 100644 index 38dcb70f52e..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/migrations/postgres/index.md.hash +++ /dev/null @@ -1 +0,0 @@ -bfc206ae695478ee diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/migrations/postgres/overview.md b/i18n/zh/docusaurus-plugin-content-docs/current/migrations/postgres/overview.md deleted file mode 100644 index cda45aad18b..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/migrations/postgres/overview.md +++ /dev/null @@ -1,48 +0,0 @@ ---- -'slug': '/migrations/postgresql/overview' -'title': '从 PostgreSQL 迁移到 ClickHouse' -'description': '从 PostgreSQL 迁移到 ClickHouse 的指南' -'keywords': -- 'postgres' -- 'postgresql' -- 'migrate' -- 'migration' ---- - -## 为什么选择 ClickHouse 而不是 Postgres? {#why-use-clickhouse-over-postgres} - -TLDR: 因为 ClickHouse 旨在进行快速分析,特别是 `GROUP BY` 查询,作为一个 OLAP 数据库,而 Postgres 是一个用于事务工作负载的 OLTP 数据库。 - -OLTP,或在线事务处理数据库,旨在管理事务信息。这些数据库的主要目标(Postgres 是经典示例)是确保工程师可以将一组更新提交到数据库,并确信它将——整体上——成功或失败。这些带有 ACID 属性的事务保证是 OLTP 数据库的主要关注点,并且是 Postgres 的巨大优势。鉴于这些要求,当 OLTP 数据库用于对大数据集的分析查询时,通常会遇到性能限制。 - -OLAP,或在线分析处理数据库,旨在满足这些需求——管理分析工作负载。这些数据库的主要目标是确保工程师能够高效地查询和汇总大量数据集。实时 OLAP 系统如 ClickHouse 允许在数据实时获取的过程中进行这些分析。 - -有关 ClickHouse 和 PostgreSQL 更深入的比较,请参见 [这里](/migrations/postgresql/appendix#postgres-vs-clickhouse-equivalent-and-different-concepts)。 - -要查看 ClickHouse 和 Postgres 在分析查询中的潜在性能差异,请参见 [Rewriting PostgreSQL Queries in ClickHouse](/migrations/postgresql/rewriting-queries)。 - -## 迁移策略 {#migration-strategies} - -从 PostgreSQL 迁移到 ClickHouse 的正确策略取决于您的用例、基础设施和数据要求。一般而言,实时变更数据捕获 (CDC) 是大多数现代用例的最佳方法,而手动批量加载后跟定期更新适用于更简单的场景或一次性迁移。 - -以下部分描述了两种主要的迁移策略:**实时 CDC** 和 **手动批量加载 + 定期更新**。 - -### 实时复制 (CDC) {#real-time-replication-cdc} - -变更数据捕获 (CDC) 是保持两个数据库之间表同步的过程。这是从 PostgreSQL 迁移的最有效方法,但同时更复杂,因为它在近实时的情况下处理从 PostgreSQL 到 ClickHouse 的插入、更新和删除。它非常适合实时分析很重要的用例。 - -实时变更数据捕获 (CDC) 可以通过使用 [ClickPipes](/integrations/clickpipes/postgres/deduplication) 在 ClickHouse 中实现,如果您使用的是 ClickHouse Cloud,或者在本地运行 ClickHouse 的情况下可以使用 [PeerDB](https://github.com/PeerDB-io/peerdb)。这些解决方案处理实时数据同步的复杂性,包括初始加载,通过捕获来自 PostgreSQL 的插入、更新和删除并将其复制到 ClickHouse 中。此方法确保 ClickHouse 中的数据始终新鲜准确,无需手动干预。 - -### 手动批量加载 + 定期更新 {#manual-bulk-load-periodic-updates} - -在某些情况下,更简单的方法,如手动批量加载后跟定期更新,可能就足够了。该策略适用于一次性迁移或不要求实时复制的情况。它涉及通过直接 SQL `INSERT` 命令或导出和导入 CSV 文件将数据从 PostgreSQL 批量加载到 ClickHouse。在初始迁移完成后,您可以通过定期从 PostgreSQL 同步更改来定期更新 ClickHouse 中的数据。 - -批量加载过程简单灵活,但缺点是没有实时更新。一旦初始数据加载到 ClickHouse 中,更新不会立即反映,因此您必须安排定期更新以同步 PostgreSQL 中的更改。这种方法适用于对时间不太敏感的用例,但它引入了 PostgreSQL 数据更改与这些更改在 ClickHouse 中出现之间的延迟。 - -### 选择哪种策略? {#which-strategy-to-choose} - -对于大多数需要在 ClickHouse 中获得新鲜、最新数据的应用程序,推荐使用通过 ClickPipes 进行的实时 CDC 方法。它提供了持续的数据同步,设置和维护工作量最小。另一方面,手动批量加载与定期更新的组合是适合更简单的一次性迁移或实时更新不重要的工作负载的可行选项。 - ---- - -**[在这里开始 PostgreSQL 迁移指南](/migrations/postgresql/dataset).** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/migrations/postgres/overview.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/migrations/postgres/overview.md.hash deleted file mode 100644 index 7a3166ebed3..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/migrations/postgres/overview.md.hash +++ /dev/null @@ -1 +0,0 @@ -0217ea4b3022b12b diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/migrations/postgres/rewriting-queries.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/migrations/postgres/rewriting-queries.md.hash deleted file mode 100644 index ba9e8e42d91..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/migrations/postgres/rewriting-queries.md.hash +++ /dev/null @@ -1 +0,0 @@ -e3b6af026fea1f81 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/migrations/snowflake.md b/i18n/zh/docusaurus-plugin-content-docs/current/migrations/snowflake.md deleted file mode 100644 index 276de8302de..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/migrations/snowflake.md +++ /dev/null @@ -1,111 +0,0 @@ ---- -'sidebar_label': 'Snowflake' -'sidebar_position': 20 -'slug': '/migrations/snowflake' -'description': '从 Snowflake 迁移到 ClickHouse' -'keywords': -- 'Snowflake' -'title': '从 Snowflake 迁移到 ClickHouse' -'show_related_blogs': true ---- - -import migrate_snowflake_clickhouse from '@site/static/images/migrations/migrate_snowflake_clickhouse.png'; -import Image from '@theme/IdealImage'; - - -# 从 Snowflake 迁移到 ClickHouse - -本指南展示如何将数据从 Snowflake 迁移到 ClickHouse。 - -在 Snowflake 和 ClickHouse 之间迁移数据需要使用对象存储,例如 S3,作为传输的中间存储。迁移过程还依赖于使用 Snowflake 的 `COPY INTO` 命令和 ClickHouse 的 `INSERT INTO SELECT`。 - -## 1. 从 Snowflake 导出数据 {#1-exporting-data-from-snowflake} - - - -从 Snowflake 导出数据需要使用外部阶段,如上图所示。 - -假设我们想导出一个具有以下模式的 Snowflake 表: - -```sql -CREATE TABLE MYDATASET ( - timestamp TIMESTAMP, - some_text varchar, - some_file OBJECT, - complex_data VARIANT, -) DATA_RETENTION_TIME_IN_DAYS = 0; -``` - -要将此表的数据移动到 ClickHouse 数据库,我们首先需要将数据复制到外部阶段。在复制数据时,我们建议使用 Parquet 作为中间格式,因为它允许共享类型信息,保持精度,压缩效果良好,并原生支持分析中常见的嵌套结构。 - -在下面的示例中,我们在 Snowflake 中创建一个命名的文件格式以表示 Parquet 及所需的文件选项。然后,我们指定哪个桶将包含我们复制的数据集。最后,我们将数据集复制到该桶。 - -```sql -CREATE FILE FORMAT my_parquet_format TYPE = parquet; - --- Create the external stage that specifies the S3 bucket to copy into -CREATE OR REPLACE STAGE external_stage -URL='s3://mybucket/mydataset' -CREDENTIALS=(AWS_KEY_ID='' AWS_SECRET_KEY='') -FILE_FORMAT = my_parquet_format; - --- Apply "mydataset" prefix to all files and specify a max file size of 150mb --- The `header=true` parameter is required to get column names -COPY INTO @external_stage/mydataset from mydataset max_file_size=157286400 header=true; -``` - -对于大约 5TB 数据的数据集,最大文件大小为 150MB,并使用位于同一 AWS `us-east-1` 区域的 2X-Large Snowflake 仓库,数据复制到 S3 存储桶大约需要 30 分钟。 - -## 2. 导入到 ClickHouse {#2-importing-to-clickhouse} - -一旦数据在中间对象存储中备案,ClickHouse 的函数,如 [s3 表函数](/sql-reference/table-functions/s3),可以用于将数据插入到表中,如下所示。 - -这个示例使用 AWS S3 的 [s3 表函数](/sql-reference/table-functions/s3),但可以使用 Google Cloud Storage 的 [gcs 表函数](/sql-reference/table-functions/gcs) 和 Azure Blob Storage 的 [azureBlobStorage 表函数](/sql-reference/table-functions/azureBlobStorage)。 - -假设以下表的目标模式: - -```sql -CREATE TABLE default.mydataset -( - `timestamp` DateTime64(6), - `some_text` String, - `some_file` Tuple(filename String, version String), - `complex_data` Tuple(name String, description String), -) -ENGINE = MergeTree -ORDER BY (timestamp) -``` - -然后我们可以使用 `INSERT INTO SELECT` 命令将数据从 S3 插入到 ClickHouse 表: - -```sql -INSERT INTO mydataset -SELECT - timestamp, - some_text, - JSONExtract( - ifNull(some_file, '{}'), - 'Tuple(filename String, version String)' - ) AS some_file, - JSONExtract( - ifNull(complex_data, '{}'), - 'Tuple(filename String, description String)' - ) AS complex_data, -FROM s3('https://mybucket.s3.amazonaws.com/mydataset/mydataset*.parquet') -SETTINGS input_format_null_as_default = 1, -- Ensure columns are inserted as default if values are null -input_format_parquet_case_insensitive_column_matching = 1 -- Column matching between source data and target table should be case insensitive -``` - -:::note 关于嵌套列结构的说明 -原始 Snowflake 表模式中的 `VARIANT` 和 `OBJECT` 列默认将输出为 JSON 字符串,这需要我们在将其插入 ClickHouse 时进行转换。 - -嵌套结构如 `some_file` 在复制时被 Snowflake 转换为 JSON 字符串。导入此数据时需要在 ClickHouse 中插入时使用 [JSONExtract 函数](/sql-reference/functions/json-functions#jsonextract) 将这些结构转换为元组,如上所示。 -::: - -## 3. 测试数据导出是否成功 {#3-testing-successful-data-export} - -要测试您的数据是否正确插入,只需对新表运行 `SELECT` 查询: - -```sql -SELECT * FROM mydataset limit 10; -``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/migrations/snowflake.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/migrations/snowflake.md.hash deleted file mode 100644 index 2f78d3d6fd2..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/migrations/snowflake.md.hash +++ /dev/null @@ -1 +0,0 @@ -71ed21011ea3ae94 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/native-protocol/basics.md b/i18n/zh/docusaurus-plugin-content-docs/current/native-protocol/basics.md index f2d00b7ec05..43179182fac 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/native-protocol/basics.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/native-protocol/basics.md @@ -3,6 +3,7 @@ 'sidebar_position': 1 'title': '基础' 'description': '原生协议基础' +'doc_type': 'guide' --- import Tabs from '@theme/Tabs'; @@ -14,26 +15,26 @@ import TabItem from '@theme/TabItem'; :::note 客户端协议参考正在进行中。 -大多数示例仅为 Go 语言。 +大多数示例仅在 Go 中提供。 ::: 本文档描述了 ClickHouse TCP 客户端的二进制协议。 ## Varint {#varint} -对于长度、数据包代码和其他情况,使用 *无符号 varint* 编码。 +对于长度、数据包代码和其他情况使用 *无符号 varint* 编码。 使用 [binary.PutUvarint](https://pkg.go.dev/encoding/binary#PutUvarint) 和 [binary.ReadUvarint](https://pkg.go.dev/encoding/binary#ReadUvarint)。 :::note -*有符号* varint 未被使用。 +*有符号* varint 不被使用。 ::: ## 字符串 {#string} -可变长度字符串编码为 *(长度, 值)*,其中 *长度* 是 [varint](#varint),*值* 是 utf8 字符串。 +可变长度的字符串编码为 *(长度, 值)*,其中 *长度* 为 [varint](#varint),*值* 为 utf8 字符串。 :::important -验证长度以防止内存溢出: +验证长度以防止 OOM: `0 ≤ len < MAX` ::: @@ -116,7 +117,7 @@ data := []byte{ ## 整数 {#integers} :::tip -ClickHouse 使用 **小端** 存储固定大小的整数。 +ClickHouse 使用 **小端** 方式表示固定大小的整数。 ::: ### Int32 {#int32} @@ -151,4 +152,4 @@ fmt.Println(d) // 1000 ## 布尔值 {#boolean} -布尔值由单个字节表示,`1` 是 `true`,`0` 是 `false`。 +布尔值由单个字节表示,`1` 为 `true`,`0` 为 `false`。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/native-protocol/basics.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/native-protocol/basics.md.hash index 03d7fa6abde..f4829db2ba6 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/native-protocol/basics.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/native-protocol/basics.md.hash @@ -1 +1 @@ -2512e7a00e16e4f2 +1f25ac09485122ed diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/native-protocol/client.md b/i18n/zh/docusaurus-plugin-content-docs/current/native-protocol/client.md index 0bbfbf41a64..6820ee1c3c3 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/native-protocol/client.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/native-protocol/client.md @@ -1,126 +1,126 @@ --- 'slug': '/native-protocol/client' 'sidebar_position': 2 -'title': '原生客户端数据包' -'description': '原生协议客户端' +'title': '本地客户端数据包' +'description': '本地协议客户端' +'doc_type': 'reference' --- # 客户端数据包 -| 值 | 名称 | 描述 | -|------|-------------------|------------------------| -| 0 | [Hello](#hello) | 客户端握手开始 | -| 1 | [Query](#query) | 查询请求 | -| 2 | [Data](#data) | 包含数据的块 | -| 3 | [Cancel](#cancel) | 取消查询 | -| 4 | [Ping](#ping) | Ping 请求 | -| 5 | TableStatus | 表状态请求 | +| value | name | description | +|-------|-------------------|------------------------| +| 0 | [Hello](#hello) | 客户端握手开始 | +| 1 | [Query](#query) | 查询请求 | +| 2 | [Data](#data) | 带有数据的块 | +| 3 | [Cancel](#cancel) | 取消查询 | +| 4 | [Ping](#ping) | Ping 请求 | +| 5 | TableStatus | 表状态请求 | `Data` 可以被压缩。 ## Hello {#hello} -例如,我们是支持 `54451` 协议版本的 `Go Client` v1.10,并希望连接到 `default` 数据库,使用 `default` 用户和 `secret` 密码。 +例如,我们是 `Go Client` v1.10,支持 `54451` 协议版本,并希望连接到 `default` 数据库,使用 `default` 用户和 `secret` 密码。 -| 字段 | 类型 | 值 | 描述 | -|-------------------|---------|----------------------|----------------------------| -| client_name | String | `"Go Client"` | 客户端实现名称 | -| version_major | UVarInt | `1` | 客户端主版本 | -| version_minor | UVarInt | `10` | 客户端次版本 | -| protocol_version | UVarInt | `54451` | TCP 协议版本 | -| database | String | `"default"` | 数据库名称 | -| username | String | `"default"` | 用户名 | -| password | String | `"secret"` | 密码 | +| field | type | value | description | +|------------------|---------|---------------|----------------------------| +| client_name | String | `"Go Client"` | 客户端实现名称 | +| version_major | UVarInt | `1` | 客户端主版本 | +| version_minor | UVarInt | `10` | 客户端次版本 | +| protocol_version | UVarInt | `54451` | TCP 协议版本 | +| database | String | `"default"` | 数据库名称 | +| username | String | `"default"` | 用户名 | +| password | String | `"secret"` | 密码 | ### 协议版本 {#protocol-version} 协议版本是客户端的 TCP 协议版本。 -通常它等于最新的兼容服务器修订版,但不应与之混淆。 +通常它等于最新兼容的服务器版本,但不应与其混淆。 ### 默认值 {#defaults} -所有值应**显式设置**,服务器端没有默认值。在客户端,使用 `"default"` 数据库、`"default"` 用户名和 `""`(空字符串)密码作为默认值。 +所有值应 **明确设置**,服务器端没有默认值。 +在客户端,使用 `"default"` 数据库、`"default"` 用户名和 `""`(空字符串)作为默认值。 ## 查询 {#query} -| 字段 | 类型 | 值 | 描述 | -|-----------------|----------------------------|--------------|---------------------------| -| query_id | String | `1ff-a123` | 查询 ID,可以是 UUIDv4 | -| client_info | [ClientInfo](#client-info) | 参见类型 | 有关客户端的数据 | -| settings | [Settings](#settings) | 参见类型 | 设置列表 | -| secret | String | `secret` | 服务器间密钥 | -| [stage](#stage) | UVarInt | `2` | 执行直到查询阶段 | -| compression | UVarInt | `0` | 禁用=0,启用=1 | -| body | String | `SELECT 1` | 查询文本 | +| field | type | value | description | +|-----------------|----------------------------|------------|---------------------------| +| query_id | String | `1ff-a123` | 查询 ID,可以是 UUIDv4 | +| client_info | [ClientInfo](#client-info) | 见类型 | 有关客户端的数据 | +| settings | [Settings](#settings) | 见类型 | 设置列表 | +| secret | String | `secret` | 服务器间秘密 | +| [stage](#stage) | UVarInt | `2` | 在查询阶段执行 | +| compression | UVarInt | `0` | 禁用=0,启用=1 | +| body | String | `SELECT 1` | 查询文本 | ### 客户端信息 {#client-info} -| 字段 | 类型 | 描述 | -|-------------------|-----------------|-------------------------------| +| field | type | description | +|-------------------|-----------------|--------------------------------| | query_kind | byte | None=0, Initial=1, Secondary=2 | -| initial_user | String | 初始用户 | -| initial_query_id | String | 初始查询 ID | -| initial_address | String | 初始地址 | -| initial_time | Int64 | 初始时间 | -| interface | byte | TCP=1, HTTP=2 | -| os_user | String | 操作系统用户 | -| client_hostname | String | 客户端主机名 | -| client_name | String | 客户端名称 | -| version_major | UVarInt | 客户端主版本 | -| version_minor | UVarInt | 客户端次版本 | -| protocol_version | UVarInt | 客户端协议版本 | -| quota_key | String | 配额键 | -| distributed_depth | UVarInt | 分布深度 | -| version_patch | UVarInt | 客户端补丁版本 | -| otel | Bool | 跟踪字段是否存在 | -| trace_id | FixedString(16) | 跟踪 ID | +| initial_user | String | 初始用户 | +| initial_query_id | String | 初始查询 ID | +| initial_address | String | 初始地址 | +| initial_time | Int64 | 初始时间 | +| interface | byte | TCP=1, HTTP=2 | +| os_user | String | 操作系统用户 | +| client_hostname | String | 客户端主机名 | +| client_name | String | 客户端名称 | +| version_major | UVarInt | 客户端主版本 | +| version_minor | UVarInt | 客户端次版本 | +| protocol_version | UVarInt | 客户端协议版本 | +| quota_key | String | 配额键 | +| distributed_depth | UVarInt | 分布深度 | +| version_patch | UVarInt | 客户端补丁版本 | +| otel | Bool | 追踪字段是否存在 | +| trace_id | FixedString(16) | 追踪 ID | | span_id | FixedString(8) | Span ID | -| trace_state | String | 跟踪状态 | -| trace_flags | Byte | 跟踪标志 | - +| trace_state | String | 追踪状态 | +| trace_flags | Byte | 追踪标志 | ### 设置 {#settings} -| 字段 | 类型 | 值 | 描述 | -|-----------|--------|-------------------|--------------------------| -| key | String | `send_logs_level` | 设置的键 | -| value | String | `trace` | 设置的值 | -| important | Bool | `true` | 是否可以被忽略 | +| field | type | value | description | +|-----------|--------|-------------------|-----------------------| +| key | String | `send_logs_level` | 设置的键 | +| value | String | `trace` | 设置的值 | +| important | Bool | `true` | 可以忽略与否 | -编码为列表,空键和值表示列表结束。 +以列表编码,空键和空值表示列表的结束。 ### 阶段 {#stage} -| 值 | 名称 | 描述 | -|------|--------------------|----------------------------------------| -| 0 | FetchColumns | 仅提取列类型 | -| 1 | WithMergeableState | 直到可合并状态 | -| 2 | Complete | 直到完全完整(应该是默认) | - +| value | name | description | +|-------|--------------------|---------------------------------------------| +| 0 | FetchColumns | 仅获取列类型 | +| 1 | WithMergeableState | 直到可合并状态 | +| 2 | Complete | 直到完全完整(应为默认) | ## 数据 {#data} -| 字段 | 类型 | 描述 | -|---------|---------------------|---------------------------| -| info | BlockInfo | 编码的块信息 | -| columns | UVarInt | 列计数 | -| rows | UVarInt | 行计数 | -| columns | [[]Column](#column) | 包含数据的列 | +| field | type | description | +|---------|---------------------|--------------------| +| info | BlockInfo | 编码块信息 | +| columns | UVarInt | 列计数 | +| rows | UVarInt | 行计数 | +| columns | [[]Column](#column) | 带数据的列 | ### 列 {#column} -| 字段 | 类型 | 值 | 描述 | -|-------|--------|------------------|------------------------| -| name | String | `foo` | 列名 | -| type | String | `DateTime64(9)` | 列类型 | -| data | bytes | ~ | 列数据 | +| field | type | value | description | +|-------|--------|-----------------|-------------| +| name | String | `foo` | 列名称 | +| type | String | `DateTime64(9)` | 列类型 | +| data | bytes | ~ | 列数据 | ## 取消 {#cancel} -无数据包体。服务器应取消查询。 +没有数据包主体。服务器应取消查询。 ## Ping {#ping} -无数据包体。服务器应 [用 pong 响应](./server.md#pong)。 +没有数据包主体。服务器应 [以 pong 响应](./server.md#pong)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/native-protocol/client.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/native-protocol/client.md.hash index f8edcec9ca9..243469a7818 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/native-protocol/client.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/native-protocol/client.md.hash @@ -1 +1 @@ -69cb03141cf5644a +fe3174331b83d851 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/native-protocol/columns.md b/i18n/zh/docusaurus-plugin-content-docs/current/native-protocol/columns.md index 988ab533b54..bab7ac49ee1 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/native-protocol/columns.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/native-protocol/columns.md @@ -2,19 +2,20 @@ 'slug': '/native-protocol/columns' 'sidebar_position': 4 'title': '列类型' -'description': '原生协议的列类型' +'description': '本机协议的列类型' +'doc_type': 'reference' --- # 列类型 -请参阅 [数据类型](/sql-reference/data-types/) 以获取一般参考。 +参见 [数据类型](/sql-reference/data-types/) 以获取一般参考。 ## 数值类型 {#numeric-types} :::tip -数值类型编码与小端 CPU(如 AMD64 或 ARM64)的内存布局相匹配。 +数值类型编码与 AMD64 或 ARM64 等小端 CPU 的内存布局相匹配。 这使得实现非常高效的编码和解码成为可能。 @@ -22,7 +23,7 @@ ### 整数 {#integers} -以小端格式的 Int 和 UInt 的 8、16、32、64、128 或 256 位字符串。 +Int 和 UInt 的字符串,长度为 8、16、32、64、128 或 256 位,以小端方式表示。 ### 浮点数 {#floats} @@ -30,34 +31,33 @@ Float32 和 Float64 采用 IEEE 754 二进制表示。 ## 字符串 {#string} -仅为字符串数组,即 (len, value)。 +仅为字符串数组,即(len,value)。 -## FixedString(N) {#fixedstringn} +## 固定字符串(N) {#fixedstringn} N 字节序列的数组。 ## IP {#ip} -IPv4 是 `UInt32` 数值类型的别名,表示为 UInt32。 +IPv4 是 `UInt32` 数值类型的别名,以 UInt32 表示。 -IPv6 是 `FixedString(16)` 的别名,直接表示为二进制。 +IPv6 是 `FixedString(16)` 的别名,直接以二进制表示。 ## 元组 {#tuple} -元组仅仅是列的数组。例如,Tuple(String, UInt8) 只是两个列 -连续编码。 +元组只是列的数组。例如,Tuple(String, UInt8) 只是连续编码的两个列。 ## 映射 {#map} -`Map(K, V)` 由三列组成:`Offsets ColUInt64, Keys K, Values V`。 +`Map(K, V)` 由三个列组成:`Offsets ColUInt64, Keys K, Values V`。 -`Keys` 和 `Values` 列中的行数由 `Offsets` 中的最后一个值决定。 +`Keys` 和 `Values` 列中的行数为 `Offsets` 的最后一个值。 ## 数组 {#array} `Array(T)` 由两列组成:`Offsets ColUInt64, Data T`。 -`Data` 列中的行数由 `Offsets` 中的最后一个值决定。 +`Data` 中的行数为 `Offsets` 的最后一个值。 ## 可空 {#nullable} @@ -78,10 +78,10 @@ IPv6 是 `FixedString(16)` 的别名,直接表示为二进制。 `Int8` 或 `Int16` 的别名,但每个整数映射到某个 `String` 值。 -## 低基数 {#low-cardinality} +## `LowCardinality` 类型 {#low-cardinality} `LowCardinality(T)` 由 `Index T, Keys K` 组成, -其中 `K` 是(UInt8、UInt16、UInt32、UInt64)中的一个,取决于 `Index` 的大小。 +其中 `K` 是 (UInt8, UInt16, UInt32, UInt64) 的一种,具体取决于 `Index` 的大小。 ```go // Index (i.e. dictionary) column contains unique values, Keys column contains @@ -96,6 +96,6 @@ IPv6 是 `FixedString(16)` 的别名,直接表示为二进制。 // of chosen type should be able to represent any index of Index element. ``` -## 布尔 {#bool} +## 布尔值 {#bool} -`UInt8` 的别名,其中 `0` 表示 false,`1` 表示 true。 +`UInt8` 的别名,其中 `0` 为假,`1` 为真。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/native-protocol/columns.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/native-protocol/columns.md.hash index c3a79333cb4..06d868f77dd 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/native-protocol/columns.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/native-protocol/columns.md.hash @@ -1 +1 @@ -64f727430cc37549 +eec8ba626bceb5d8 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/native-protocol/hash.md b/i18n/zh/docusaurus-plugin-content-docs/current/native-protocol/hash.md index dfc4568dfe8..d29fa418253 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/native-protocol/hash.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/native-protocol/hash.md @@ -2,29 +2,30 @@ 'slug': '/native-protocol/hash' 'sidebar_position': 5 'title': 'CityHash' -'description': '本地协议哈希' +'description': '原生协议哈希' +'doc_type': 'reference' --- # CityHash -ClickHouse 使用 **之前的一个** 版本的 [CityHash from Google](https://github.com/google/cityhash)。 +ClickHouse 使用 **先前的** 版本 [CityHash from Google](https://github.com/google/cityhash)。 :::info -CityHash 在我们将其添加到 ClickHouse 之后更改了算法。 +CityHash 在我们将其添加到 ClickHouse 后更改了算法。 -CityHash 文档特别指出,用户不应依赖特定的哈希值,不应将其保存或用作分片键。 +CityHash 文档特别指出,用户不应该依赖特定的哈希值,并且不应该将其保存在任何地方或用作分片键。 -但是由于我们将此功能暴露给用户,我们不得不修复 CityHash 的版本(为 1.0.2)。现在我们保证在 SQL 中可用的 CityHash 函数的行为不会更改。 +但是,由于我们将该功能开放给用户,因此我们必须固定 CityHash 的版本(为 1.0.2)。现在,我们保证 SQL 中可用的 CityHash 函数的行为不会改变。 — Alexey Milovidov ::: :::note 注意 -谷歌的 CityHash 当前版本与 ClickHouse 的 `cityHash64` 变体 [不同](https://github.com/ClickHouse/ClickHouse/issues/8354)。 +谷歌的 CityHash 当前版本 [与](https://github.com/ClickHouse/ClickHouse/issues/8354) ClickHouse 的 `cityHash64` 变体不同。 -不要使用 `farmHash64` 来获取谷歌的 CityHash 值! [FarmHash](https://opensource.googleblog.com/2014/03/introducing-farmhash.html) 是 CityHash 的继任者,但它们并不完全兼容。 +不要使用 `farmHash64` 来获取谷歌的 CityHash 值![FarmHash](https://opensource.googleblog.com/2014/03/introducing-farmhash.html) 是 CityHash 的 successor,但它们并不完全兼容。 | 字符串 | ClickHouse64 | CityHash64 | FarmHash64 | |------------------------------------------------------------|----------------------|---------------------|----------------------| @@ -33,10 +34,10 @@ CityHash 文档特别指出,用户不应依赖特定的哈希值,不应将 ::: -另见 [Introducing CityHash](https://opensource.googleblog.com/2011/04/introducing-cityhash.html) 了解创建的描述和原因。简而言之,这是一个 **非加密** 哈希,比 [MurmurHash](http://en.wikipedia.org/wiki/MurmurHash) 更快,但更复杂。 +另请参见 [Introducing CityHash](https://opensource.googleblog.com/2011/04/introducing-cityhash.html) 获取描述和创建原因。TL;DR **非加密** 哈希比 [MurmurHash](http://en.wikipedia.org/wiki/MurmurHash) 更快,但更复杂。 ## 实现 {#implementations} ### Go {#go} -您可以使用 [go-faster/city](https://github.com/go-faster/city) Go 包,它实现了两种变体。 +您可以使用 [go-faster/city](https://github.com/go-faster/city) Go 包,该包实现了两种变体。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/native-protocol/hash.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/native-protocol/hash.md.hash index d1033b34c14..ffb946bac24 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/native-protocol/hash.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/native-protocol/hash.md.hash @@ -1 +1 @@ -f255dfafe7067bce +373a765a00bc1b69 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/native-protocol/server.md b/i18n/zh/docusaurus-plugin-content-docs/current/native-protocol/server.md index 3fa43d4e586..e27c3a97a23 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/native-protocol/server.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/native-protocol/server.md @@ -2,135 +2,134 @@ 'slug': '/native-protocol/server' 'sidebar_position': 3 'title': '服务器数据包' -'description': '本地协议服务器' +'description': '原生协议服务器' +'doc_type': 'reference' --- # 服务器数据包 -| 值 | 名称 | 描述 | -|--------|----------------------------------|--------------------------------------------------------------| -| 0 | [Hello](#hello) | 服务器握手响应 | -| 1 | 数据 | 与 [client data](./client.md#data) 相同 | -| 2 | [Exception](#exception) | 查询处理异常 | -| 3 | [Progress](#progress) | 查询进度 | -| 4 | [Pong](#pong) | Ping 响应 | -| 5 | [EndOfStream](#end-of-stream) | 所有数据包已传输 | -| 6 | [ProfileInfo](#profile-info) | 性能数据 | -| 7 | Totals | 总值 | -| 8 | Extremes | 极端值(最小值、最大值) | -| 9 | TablesStatusResponse | 对 TableStatus 请求的响应 | -| 10 | [Log](#log) | 查询系统日志 | -| 11 | TableColumns | 列描述 | -| 12 | UUIDs | 唯一部分 ID 的列表 | -| 13 | ReadTaskRequest | 字符串(UUID)描述需要下一个任务的请求 | -| 14 | [ProfileEvents](#profile-events) | 包含服务器的性能事件 | - -`数据`、`总值`和`极端值`可以被压缩。 +| 值 | 名称 | 描述 | +|-------|------------------------------------|---------------------------------------------------------------| +| 0 | [Hello](#hello) | 服务器握手响应 | +| 1 | Data | 与 [客户端数据](./client.md#data) 相同 | +| 2 | [Exception](#exception) | 查询处理异常 | +| 3 | [Progress](#progress) | 查询进度 | +| 4 | [Pong](#pong) | Ping 响应 | +| 5 | [EndOfStream](#end-of-stream) | 所有数据包已传输 | +| 6 | [ProfileInfo](#profile-info) | 性能分析数据 | +| 7 | Totals | 总值 | +| 8 | Extremes | 极端值(最小值,最大值) | +| 9 | TablesStatusResponse | 对 TableStatus 请求的响应 | +| 10 | [Log](#log) | 查询系统日志 | +| 11 | TableColumns | 列描述 | +| 12 | UUIDs | 唯一部分 ID 列表 | +| 13 | ReadTaskRequest | 字符串(UUID)描述请求需要的下一个任务 | +| 14 | [ProfileEvents](#profile-events) | 来自服务器的性能事件数据包 | + +`Data`、`Totals` 和 `Extremes` 可以被压缩。 ## Hello {#hello} -对 [client hello](./client.md#hello) 的响应。 - -| 字段 | 类型 | 值 | 描述 | -|--------------|----------|------------------|--------------------------| -| 名称 | 字符串 | `Clickhouse` | 服务器名称 | -| 主要版本 | UVarInt | `21` | 服务器主要版本 | -| 次要版本 | UVarInt | `12` | 服务器次要版本 | -| 修订版 | UVarInt | `54452` | 服务器修订版 | -| 时区 | 字符串 | `Europe/Moscow` | 服务器时区 | -| 显示名称 | 字符串 | `Clickhouse` | 服务器在 UI 中的名称 | -| 补丁版本 | UVarInt | `3` | 服务器补丁版本 | +对 [客户端 hello](./client.md#hello) 的响应。 +| 字段 | 类型 | 值 | 描述 | +|--------------|----------|------------------|-----------------------| +| name | String | `Clickhouse` | 服务器名称 | +| version_major| UVarInt | `21` | 服务器主版本 | +| version_minor| UVarInt | `12` | 服务器次版本 | +| revision | UVarInt | `54452` | 服务器修订号 | +| tz | String | `Europe/Moscow` | 服务器时区 | +| display_name | String | `Clickhouse` | 用户界面的服务器名称 | +| version_patch| UVarInt | `3` | 服务器补丁版本 | ## Exception {#exception} 查询处理期间的服务器异常。 -| 字段 | 类型 | 值 | 描述 | -|------------|---------|----------------------------------------|---------------------------| -| 代码 | Int32 | `60` | 见 [ErrorCodes.cpp][codes]。 | -| 名称 | 字符串 | `DB::Exception` | 服务器主版本 | -| 消息 | 字符串 | `DB::Exception: 表 X 不存在` | 服务器次要版本 | -| 堆栈跟踪 | 字符串 | ~ | C++ 堆栈跟踪 | -| 嵌套 | 布尔 | `true` | 更多错误 | +| 字段 | 类型 | 值 | 描述 | +|--------------|-----------|------------------------------------|-----------------------------| +| code | Int32 | `60` | 参见 [ErrorCodes.cpp][codes]。 | +| name | String | `DB::Exception` | 服务器主要版本 | +| message | String | `DB::Exception: Table X doesn't exist` | 服务器次版本 | +| stack_trace | String | ~ | C++ 堆栈跟踪 | +| nested | Bool | `true` | 更多错误 | -在`嵌套`为`false`之前,可以是连续的异常列表。 +可以是连续的异常列表,直到 `nested` 为 `false`。 [codes]: https://clickhouse.com/codebrowser/ClickHouse/src/Common/ErrorCodes.cpp.html "错误代码列表" ## Progress {#progress} -查询执行进度由服务器定期报告。 +由服务器定期报告的查询执行进度。 :::tip -报告的进度为 **增量**。对于总数,在客户端累加。 +进度以 **增量** 的形式报告。对于总计,请在客户端进行累积。 ::: -| 字段 | 类型 | 值 | 描述 | -|------------|----------|-----------|----------------------| -| 行数 | UVarInt | `65535` | 行数 | -| 字节数 | UVarInt | `871799` | 字节数 | -| 总行数 | UVarInt | `0` | 总行数 | -| 从客户端写入的行 | UVarInt | `0` | 从客户端写入的行 | -| 从客户端写入的字节 | UVarInt | `0` | 从客户端写入的字节 | +| 字段 | 类型 | 值 | 描述 | +|--------------|----------|----------|-----------------------| +| rows | UVarInt | `65535` | 行数 | +| bytes | UVarInt | `871799` | 字节数 | +| total_rows | UVarInt | `0` | 总行数 | +| wrote_rows | UVarInt | `0` | 客户端发送的行数 | +| wrote_bytes | UVarInt | `0` | 客户端发送的字节数 | ## Pong {#pong} -对 [client ping](./client.md#ping) 的响应,没有数据包体。 +对 [客户端 ping](./client.md#ping) 的响应,没有数据包正文。 -## 数据流结束 {#end-of-stream} +## End of stream {#end-of-stream} -不会再发送 **数据** 数据包,查询结果已从服务器完全流式传输到客户端。 +将不再发送 **Data** 数据包,查询结果已完全从服务器流向客户端。 -没有数据包体。 +没有数据包正文。 ## Profile info {#profile-info} -| 字段 | 类型 | -|-------------------------------|----------| -| 行数 | UVarInt | -| 块数 | UVarInt | -| 字节数 | UVarInt | -| 应用限制 | 布尔 | -| 限制前的行数 | UVarInt | -| 限制前计算的行数 | 布尔 | +| 字段 | 类型 | +|-----------------------------|-----------| +| rows | UVarInt | +| blocks | UVarInt | +| bytes | UVarInt | +| applied_limit | Bool | +| rows_before_limit | UVarInt | +| calculated_rows_before_limit| Bool | ## Log {#log} -**数据块**,包含服务器日志。 +**数据块**包含服务器日志。 :::tip -编码为 **数据块** 的列,但从未被压缩。 +编码为 **数据块** 的列,但永远不会被压缩。 ::: -| 列 | 类型 | -|------------|----------| -| 时间 | DateTime | -| 微秒时间 | UInt32 | -| 主机名 | 字符串 | -| 查询 ID | 字符串 | -| 线程 ID | UInt64 | -| 优先级 | Int8 | -| 来源 | 字符串 | -| 文本 | 字符串 | +| 列名 | 类型 | +|------------|-----------| +| time | DateTime | +| time_micro | UInt32 | +| host_name | String | +| query_id | String | +| thread_id | UInt64 | +| priority | Int8 | +| source | String | +| text | String | ## Profile events {#profile-events} -**数据块**,包含性能事件。 +**数据块**包含性能事件。 :::tip -编码为 **数据块** 的列,但从未被压缩。 +编码为 **数据块** 的列,但永远不会被压缩。 -`值` 类型为 `UInt64` 或 `Int64`,取决于服务器修订版。 +`value` 类型为 `UInt64` 或 `Int64`,具体取决于服务器修订号。 ::: - -| 列 | 类型 | -|--------------|-----------------| -| 主机名 | 字符串 | -| 当前时间 | DateTime | -| 线程 ID | UInt64 | -| 类型 | Int8 | -| 名称 | 字符串 | -| 值 | UInt64 或 Int64 | +| 列名 | 类型 | +|------------|--------------------| +| host_name | String | +| current_time| DateTime | +| thread_id | UInt64 | +| type | Int8 | +| name | String | +| value | UInt64 或 Int64 | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/native-protocol/server.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/native-protocol/server.md.hash index 1e87a7c5da3..037b4fc0c74 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/native-protocol/server.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/native-protocol/server.md.hash @@ -1 +1 @@ -db21c8793bfc92ab +ef8d3c6cca3146d1 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/_troubleshooting.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/_troubleshooting.md index 3c52fc2549e..55d8a523be5 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/_troubleshooting.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/_troubleshooting.md @@ -1,31 +1,26 @@ ---- -null -... ---- - -[//]: # (This file is included in FAQ > Troubleshooting) +[//]: # (此文件包含在 FAQ > 故障排除) - [安装](#troubleshooting-installation-errors) - [连接到服务器](#troubleshooting-accepts-no-connections) - [查询处理](#troubleshooting-does-not-process-queries) -- [查询处理效率](#troubleshooting-too-slow) +- [查询处理的效率](#troubleshooting-too-slow) ## 安装 {#troubleshooting-installation-errors} -### 您无法通过 Apt-get 从 ClickHouse 仓库获取 Deb 包 {#you-cannot-get-deb-packages-from-clickhouse-repository-with-apt-get} +### 您无法通过 apt-get 从 ClickHouse 存储库获取 deb 包 {#you-cannot-get-deb-packages-from-clickhouse-repository-with-apt-get} - 检查防火墙设置。 -- 如果由于某种原因无法访问该仓库,请按照 [安装指南](../getting-started/install.md) 中的描述下载包,并使用 `sudo dpkg -i ` 命令手动安装它们。您还需要 `tzdata` 包。 +- 如果由于任何原因无法访问存储库,请按照 [安装指南](../getting-started/install.md) 中的说明下载软件包,并使用 `sudo dpkg -i ` 命令手动安装它们。您还需要 `tzdata` 软件包。 -### 您无法通过 Apt-get 更新 ClickHouse 仓库中的 Deb 包 {#you-cannot-update-deb-packages-from-clickhouse-repository-with-apt-get} +### 您无法通过 apt-get 更新 ClickHouse 存储库中的 deb 包 {#you-cannot-update-deb-packages-from-clickhouse-repository-with-apt-get} - 该问题可能发生在 GPG 密钥更改时。 -请使用 [设置](../getting-started/install.md#setup-the-debian-repository) 页面中的手册更新仓库配置。 +请使用 [设置](../getting-started/install.md#setup-the-debian-repository) 页面上的手册更新存储库配置。 ### 您在使用 `apt-get update` 时收到不同的警告 {#you-get-different-warnings-with-apt-get-update} -- 完成的警告信息为以下之一: +- 完整的警告消息是以下之一: ```bash N: Skipping acquire of configured file 'main/binary-i386/Packages' as repository 'https://packages.clickhouse.com/deb stable InRelease' doesn't support architecture 'i386' @@ -55,22 +50,22 @@ sudo apt-get clean sudo apt-get autoclean ``` -### 您无法通过 Yum 获取软件包,因为签名错误 {#you-cant-get-packages-with-yum-because-of-wrong-signature} +### 您无法通过 yum 获取软件包,因为签名错误 {#you-cant-get-packages-with-yum-because-of-wrong-signature} -可能的问题:缓存不正确,可能在 2022-09 更新 GPG 密钥后损坏。 +可能的问题:缓存错误,可能在 2022-09 更新 GPG 密钥后损坏。 -解决方案是清除 Yum 的缓存和库目录: +解决方案是清理 yum 的缓存和 lib 目录: ```bash sudo find /var/lib/yum/repos/ /var/cache/yum/ -name 'clickhouse-*' -type d -exec rm -rf {} + sudo rm -f /etc/yum.repos.d/clickhouse.repo ``` -之后,请遵循 [安装指南](../getting-started/install.md#from-rpm-packages) +之后请遵循 [安装指南](../getting-started/install.md#from-rpm-packages) ### 您无法运行 Docker 容器 {#you-cant-run-docker-container} -您执行简单的 `docker run clickhouse/clickhouse-server`,并出现类似于以下的堆栈跟踪崩溃: +您正在运行简单的 `docker run clickhouse/clickhouse-server`,它崩溃并显示类似以下的堆栈跟踪: ```bash $ docker run -it clickhouse/clickhouse-server @@ -93,18 +88,18 @@ Poco::Exception. Code: 1000, e.code() = 0, System exception: cannot start thread (version 24.10.1.2812 (official build)) ``` -原因是 Docker 守护进程版本低于 `20.10.10`。解决方法是升级它,或者运行 `docker run [--privileged | --security-opt seccomp=unconfined]`。后者具有安全隐患。 +原因是 docker daemon 版本低于 `20.10.10`。修复方法是升级它,或者运行 `docker run [--privileged | --security-opt seccomp=unconfined]`。后者涉及安全隐患。 ## 连接到服务器 {#troubleshooting-accepts-no-connections} 可能的问题: - 服务器未运行。 -- 意外或错误的配置参数。 +- 配置参数不正确或意外。 ### 服务器未运行 {#server-is-not-running} -**检查服务器是否正在运行** +**检查服务器是否运行** 命令: @@ -127,19 +122,19 @@ $ sudo service clickhouse-server start - ` Application: starting up.` — 服务器已启动。 - ` Application: Ready for connections.` — 服务器正在运行并准备接受连接。 -如果 `clickhouse-server` 因配置错误启动失败,您应看到带有错误描述的 `` 字符串。例如: +如果 `clickhouse-server` 启动失败并出现配置错误,您应该看到 `` 字符串以及错误描述。例如: ```text 2019.01.11 15:23:25.549505 [ 45 ] {} ExternalDictionaries: Failed reloading 'event2id' external dictionary: Poco::Exception. Code: 1000, e.code() = 111, e.displayText() = Connection refused, e.what() = Connection refused ``` -如果您在文件末尾未看到错误,请从以下字符串开始查看整个文件: +如果您在文件末尾没有看到错误,请从字符串开始浏览整个文件: ```text Application: starting up. ``` -如果您尝试在服务器上启动第二个 `clickhouse-server` 实例,您将看到以下日志: +如果您尝试在服务器上启动第二个实例的 `clickhouse-server`,您会看到以下日志: ```text 2019.01.11 15:25:11.151730 [ 1 ] {} : Starting ClickHouse 19.1.0 with revision 54413 @@ -157,7 +152,7 @@ Revision: 54413 **查看 system.d 日志** -如果在 `clickhouse-server` 日志中找不到任何有用的信息,或者没有任何日志,您可以使用以下命令查看 `system.d` 日志: +如果在 `clickhouse-server` 日志中没有找到任何有用的信息,或者没有日志,您可以使用以下命令查看 `system.d` 日志: ```bash $ sudo journalctl -u clickhouse-server @@ -169,7 +164,7 @@ $ sudo journalctl -u clickhouse-server $ sudo -u clickhouse /usr/bin/clickhouse-server --config-file /etc/clickhouse-server/config.xml ``` -此命令以交互应用程序的标准参数启动服务器。在此模式下,`clickhouse-server` 会将所有事件消息打印到控制台。 +此命令以交互应用程序的标准自动启动脚本参数启动服务器。在此模式下,`clickhouse-server` 会在控制台中打印所有事件消息。 ### 配置参数 {#configuration-parameters} @@ -177,13 +172,13 @@ $ sudo -u clickhouse /usr/bin/clickhouse-server --config-file /etc/clickhouse-se - Docker 设置。 - 如果您在 IPv6 网络中的 Docker 中运行 ClickHouse,请确保设置 `network=host`。 + 如果您在 IPv6 网络中运行 ClickHouse,请确保设置了 `network=host`。 - 端点设置。 检查 [listen_host](../operations/server-configuration-parameters/settings.md#listen_host) 和 [tcp_port](../operations/server-configuration-parameters/settings.md#tcp_port) 设置。 - ClickHouse 服务器默认仅接受本地连接。 + 默认情况下,ClickHouse 服务器仅接受 localhost 连接。 - HTTP 协议设置。 @@ -193,10 +188,10 @@ $ sudo -u clickhouse /usr/bin/clickhouse-server --config-file /etc/clickhouse-se 检查: - - [tcp_port_secure](../operations/server-configuration-parameters/settings.md#tcp_port_secure) 设置。 - - [SSL 证书](../operations/server-configuration-parameters/settings.md#openssl) 的设置。 + - [tcp_port_secure](../operations/server-configuration-parameters/settings.md#tcp_port_secure) 设置。 + - [SSL 证书](../operations/server-configuration-parameters/settings.md#openssl) 的设置。 - 连接时使用适当的参数。例如,在使用 `clickhouse_client` 时使用 `port_secure` 参数。 + 连接时使用正确的参数。例如,使用 `clickhouse_client` 的 `port_secure` 参数。 - 用户设置。 @@ -204,7 +199,7 @@ $ sudo -u clickhouse /usr/bin/clickhouse-server --config-file /etc/clickhouse-se ## 查询处理 {#troubleshooting-does-not-process-queries} -如果 ClickHouse 无法处理查询,它会向客户端发送错误描述。在 `clickhouse-client` 中,您将在控制台中收到错误描述。如果您使用 HTTP 接口,ClickHouse 会在响应体中发送错误描述。例如: +如果 ClickHouse 无法处理查询,它会将错误描述发送给客户端。在 `clickhouse-client` 中,您将在控制台中获得错误描述。如果您使用 HTTP 接口,ClickHouse 会在响应正文中发送错误描述。例如: ```bash $ curl 'http://localhost:8123/' --data-binary "SELECT a" @@ -213,10 +208,10 @@ Code: 47, e.displayText() = DB::Exception: Unknown identifier: a. Note that ther 如果您以 `stack-trace` 参数启动 `clickhouse-client`,ClickHouse 会返回带有错误描述的服务器堆栈跟踪。 -您可能会看到有关连接中断的消息。在这种情况下,您可以重复查询。如果每次执行查询时连接都会中断,请检查服务器日志中的错误。 +您可能会看到关于连接中断的消息。在这种情况下,您可以重复查询。如果每次执行查询时连接都断开,请检查服务器日志中的错误。 -## 查询处理效率 {#troubleshooting-too-slow} +## 查询处理的效率 {#troubleshooting-too-slow} -如果您发现 ClickHouse 的工作速度太慢,您需要分析服务器资源和网络的负载以优化您的查询。 +如果您发现 ClickHouse 工作得太慢,您需要对服务器资源和网络的负载进行分析,以优化您的查询。 -您可以使用 clickhouse-benchmark 工具来分析查询。它显示每秒处理的查询数量、每秒处理的行数以及查询处理时间的百分位数。 +您可以使用 clickhouse-benchmark 工具来对查询进行分析。它显示每秒处理的查询数量、每秒处理的行数以及查询处理时间的百分位数。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/_troubleshooting.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/_troubleshooting.md.hash index fb2125cae69..3a63387b42b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/_troubleshooting.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/_troubleshooting.md.hash @@ -1 +1 @@ -5f9cc103b6f78559 +21d6e9c6c6d0612e diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/allocation-profiling-old.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/allocation-profiling-old.md new file mode 100644 index 00000000000..4d6fc773e6a --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/allocation-profiling-old.md @@ -0,0 +1,224 @@ +--- +'description': '页面详细介绍 ClickHouse 中的分配分析' +'sidebar_label': '版本 25.9 之前的分配分析' +'slug': '/operations/allocation-profiling-old' +'title': '版本 25.9 之前的分配分析' +'doc_type': 'reference' +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + + +# 25.9 之前版本的分配分析 + +ClickHouse 使用 [jemalloc](https://github.com/jemalloc/jemalloc) 作为其全局分配器。 Jemalloc 附带一些用于分配采样和分析的工具。 +为了让分配分析更加方便,提供了 `SYSTEM` 命令以及 Keeper 中的 4 个字母命令(4LW)。 + +## 采样分配和刷新堆分析 {#sampling-allocations-and-flushing-heap-profiles} + +如果您想要在 `jemalloc` 中进行分配采样和分析,您需要使用环境变量 `MALLOC_CONF` 启动带有分析功能的 ClickHouse/Keeper: + +```sh +MALLOC_CONF=background_thread:true,prof:true +``` + +`jemalloc` 将采样分配并在内部存储信息。 + +您可以通过运行以下命令来通知 `jemalloc` 刷新当前分析: + + + + +```sql +SYSTEM JEMALLOC FLUSH PROFILE +``` + + + + +```sh +echo jmfp | nc localhost 9181 +``` + + + + +默认情况下,堆分析文件将生成在 `/tmp/jemalloc_clickhouse._pid_._seqnum_.heap`,其中 `_pid_` 是 ClickHouse 的 PID,而 `_seqnum_` 是当前堆分析的全局序列号。 +对于 Keeper,默认文件为 `/tmp/jemalloc_keeper._pid_._seqnum_.heap`,并遵循相同规则。 + +可以通过将 `prof_prefix` 选项附加到 `MALLOC_CONF` 环境变量来定义不同的位置。 +例如,如果您希望在 `/data` 文件夹中生成文件名前缀为 `my_current_profile` 的分析文件,您可以使用以下环境变量启动 ClickHouse/Keeper: + +```sh +MALLOC_CONF=background_thread:true,prof:true,prof_prefix:/data/my_current_profile +``` + +生成的文件将附加到前缀 PID 和序列号。 + +## 分析堆分析 {#analyzing-heap-profiles} + +生成堆分析后,需要进行分析。 +为此,可以使用 `jemalloc` 的工具 [jeprof](https://github.com/jemalloc/jemalloc/blob/dev/bin/jeprof.in)。可以通过多种方式安装它: +- 使用系统的包管理器 +- 克隆 [jemalloc 仓库](https://github.com/jemalloc/jemalloc) 并从根文件夹运行 `autogen.sh`。这将为您提供在 `bin` 文件夹中的 `jeprof` 脚本 + +:::note +`jeprof` 使用 `addr2line` 来生成堆栈跟踪,这可能会非常慢。 +如果是这种情况,建议安装工具的 [替代实现](https://github.com/gimli-rs/addr2line)。 + +```bash +git clone https://github.com/gimli-rs/addr2line.git --depth=1 --branch=0.23.0 +cd addr2line +cargo build --features bin --release +cp ./target/release/addr2line path/to/current/addr2line +``` +::: + +使用 `jeprof` 从堆分析中生成的格式有很多种。 +建议运行 `jeprof --help` 获取关于工具的用法和各种选项的信息。 + +一般来说,`jeprof` 命令的用法如下: + +```sh +jeprof path/to/binary path/to/heap/profile --output_format [ > output_file] +``` + +如果您想要比较两个分析之间发生的分配,可以设置 `base` 参数: + +```sh +jeprof path/to/binary --base path/to/first/heap/profile path/to/second/heap/profile --output_format [ > output_file] +``` + +### 示例 {#examples} + +- 如果您想生成一个文本文件,每个过程写在一行: + +```sh +jeprof path/to/binary path/to/heap/profile --text > result.txt +``` + +- 如果您想生成一个带有调用图的 PDF 文件: + +```sh +jeprof path/to/binary path/to/heap/profile --pdf > result.pdf +``` + +### 生成火焰图 {#generating-flame-graph} + +`jeprof` 允许您生成用于构建火焰图的折叠堆栈。 + +您需要使用 `--collapsed` 参数: + +```sh +jeprof path/to/binary path/to/heap/profile --collapsed > result.collapsed +``` + +之后,您可以使用多种不同的工具来可视化折叠堆栈。 + +最流行的是 [FlameGraph](https://github.com/brendangregg/FlameGraph),其中包含名为 `flamegraph.pl` 的脚本: + +```sh +cat result.collapsed | /path/to/FlameGraph/flamegraph.pl --color=mem --title="Allocation Flame Graph" --width 2400 > result.svg +``` + +另一种有趣的工具是 [speedscope](https://www.speedscope.app/),它允许您以更交互的方式分析收集到的堆栈。 + +## 在运行时控制分配分析器 {#controlling-allocation-profiler-during-runtime} + +如果带分析功能启动 ClickHouse/Keeper,支持在运行时禁用/启用分配分析的额外命令。 +使用这些命令,仅分析特定时间段的难度更小。 + +要禁用分析器: + + + + +```sql +SYSTEM JEMALLOC DISABLE PROFILE +``` + + + + +```sh +echo jmdp | nc localhost 9181 +``` + + + + +要启用分析器: + + + + +```sql +SYSTEM JEMALLOC ENABLE PROFILE +``` + + + + +```sh +echo jmep | nc localhost 9181 +``` + + + + +还可以通过设置 `prof_active` 选项来控制分析器的初始状态,默认情况下该选项是启用的。 +例如,如果您希望在启动时不采样分配,而只在之后才采样,您可以启用分析器。您可以使用以下环境变量启动 ClickHouse/Keeper: + +```sh +MALLOC_CONF=background_thread:true,prof:true,prof_active:false +``` + +可以在之后启用分析器。 + +## 分析器的附加选项 {#additional-options-for-profiler} + +`jemalloc` 有许多不同的与分析器相关的选项。可以通过修改 `MALLOC_CONF` 环境变量来控制它们。 +例如,分配采样之间的间隔可以使用 `lg_prof_sample` 控制。 +如果您希望每 N 字节转储堆分析,可以使用 `lg_prof_interval` 启用它。 + +建议查看 `jemalloc` 的 [参考页面](https://jemalloc.net/jemalloc.3.html) 以获取完整的选项列表。 + +## 其他资源 {#other-resources} + +ClickHouse/Keeper 以多种方式公开 `jemalloc` 相关指标。 + +:::warning 警告 +请注意,这些指标之间未进行同步,值可能会有漂移。 +::: + +### 系统表 `asynchronous_metrics` {#system-table-asynchronous_metrics} + +```sql +SELECT * +FROM system.asynchronous_metrics +WHERE metric LIKE '%jemalloc%' +FORMAT Vertical +``` + +[参考](/operations/system-tables/asynchronous_metrics) + +### 系统表 `jemalloc_bins` {#system-table-jemalloc_bins} + +包含通过 jemalloc 分配器在不同大小类(bins)中完成的内存分配的信息,汇总自所有区域。 + +[参考](/operations/system-tables/jemalloc_bins) + +### Prometheus {#prometheus} + +所有来自 `asynchronous_metrics` 的 `jemalloc` 相关指标也通过 ClickHouse 和 Keeper 的 Prometheus 端点公开。 + +[参考](/operations/server-configuration-parameters/settings#prometheus) + +### Keeper 中的 `jmst` 4LW 命令 {#jmst-4lw-command-in-keeper} + +Keeper 支持 `jmst` 4LW 命令,该命令返回 [基本分配器统计信息](https://github.com/jemalloc/jemalloc/wiki/Use-Case%3A-Basic-Allocator-Statistics): + +```sh +echo jmst | nc localhost 9181 +``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/allocation-profiling-old.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/allocation-profiling-old.md.hash new file mode 100644 index 00000000000..8a43fc856a4 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/allocation-profiling-old.md.hash @@ -0,0 +1 @@ +e9845a87091dcdb1 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/allocation-profiling.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/allocation-profiling.md index 9dcaa73d0da..6eb9c9198c6 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/allocation-profiling.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/allocation-profiling.md @@ -3,62 +3,222 @@ 'sidebar_label': '分配分析' 'slug': '/operations/allocation-profiling' 'title': '分配分析' +'doc_type': 'guide' --- import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; -# 分配配置文件 +# 分配分析 -ClickHouse 使用 [jemalloc](https://github.com/jemalloc/jemalloc) 作为其全局分配器,并提供了一些用于分配采样和分析的工具。 -为便于分配分析, `SYSTEM` 命令与 Keeper 中的 4LW 命令一起提供。 +ClickHouse使用 [jemalloc](https://github.com/jemalloc/jemalloc) 作为其全局分配器。 Jemalloc提供了一些用于分配采样和分析的工具。 +为了使分配分析更方便,ClickHouse和Keeper允许您使用配置、查询设置、`SYSTEM`命令和Keeper中的四字母命令(4LW)控制采样。 +此外,样本可以收集到 `system.trace_log` 表中的 `JemallocSample` 类型下。 -## 采样分配和刷新堆配置文件 {#sampling-allocations-and-flushing-heap-profiles} +:::note -如果我们想要在 `jemalloc` 中进行分配采样和分析,我们需要通过启用环境变量 `MALLOC_CONF` 来启动 ClickHouse/Keeper。 +本指南适用于版本25.9及以上。 +对于较旧版本,请查看 [25.9之前版本的分配分析](/operations/allocation-profiling-old.md)。 -```sh -MALLOC_CONF=background_thread:true,prof:true +::: + +## 采样分配 {#sampling-allocations} + +如果您想在 `jemalloc` 中进行采样和分析分配,您需要启动ClickHouse/Keeper,并启用配置 `jemalloc_enable_global_profiler`。 + +```xml + + 1 + +``` + +`jemalloc` 将采样分配并将信息存储在内部。 + +您还可以通过使用 `jemalloc_enable_profiler` 设置为每个查询启用分配。 + +:::warning 警告 +由于ClickHouse是一个分配密集型应用,jemalloc采样可能会造成性能开销。 +::: + +## 在 `system.trace_log` 中存储 jemalloc 样本 {#storing-jemalloc-samples-in-system-trace-log} + +您可以将所有 jemalloc 样本存储在 `system.trace_log` 中的 `JemallocSample` 类型下。 +要全局启用,您可以使用配置 `jemalloc_collect_global_profile_samples_in_trace_log`。 + +```xml + + 1 + +``` + +:::warning 警告 +由于ClickHouse是一个分配密集型应用,将所有样本收集到system.trace_log中可能会导致高负载。 +::: + +您还可以通过使用 `jemalloc_collect_profile_samples_in_trace_log` 设置为每个查询启用此功能。 + +### 使用 `system.trace_log` 分析查询的内存使用示例 {#example-analyzing-memory-usage-trace-log} + +首先,我们需要运行启用 jemalloc 分析器的查询,并将样本收集到 `system.trace_log` 中: + +```sql +SELECT * +FROM numbers(1000000) +ORDER BY number DESC +SETTINGS max_bytes_ratio_before_external_sort = 0 +FORMAT `Null` +SETTINGS jemalloc_enable_profiler = 1, jemalloc_collect_profile_samples_in_trace_log = 1 + +Query id: 8678d8fe-62c5-48b8-b0cd-26851c62dd75 + +Ok. + +0 rows in set. Elapsed: 0.009 sec. Processed 1.00 million rows, 8.00 MB (108.58 million rows/s., 868.61 MB/s.) +Peak memory usage: 12.65 MiB. +``` + +:::note +如果ClickHouse使用 `jemalloc_enable_global_profiler` 启动,则无需启用 `jemalloc_enable_profiler`。 +`jemalloc_collect_global_profile_samples_in_trace_log` 和 `jemalloc_collect_profile_samples_in_trace_log` 也相同。 +::: + +我们将刷新 `system.trace_log`: + +```sql +SYSTEM FLUSH LOGS trace_log +``` +并查询以获取我们每个时间点运行的查询的内存使用情况: +```sql +WITH per_bucket AS +( + SELECT + event_time_microseconds AS bucket_time, + sum(size) AS bucket_sum + FROM system.trace_log + WHERE trace_type = 'JemallocSample' + AND query_id = '8678d8fe-62c5-48b8-b0cd-26851c62dd75' + GROUP BY bucket_time +) +SELECT + bucket_time, + sum(bucket_sum) OVER ( + ORDER BY bucket_time ASC + ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW + ) AS cumulative_size, + formatReadableSize(cumulative_size) AS cumulative_size_readable +FROM per_bucket +ORDER BY bucket_time +``` + +我们还可以找到内存使用率最高的时间点: + +```sql +SELECT + argMax(bucket_time, cumulative_size), + max(cumulative_size) +FROM +( + WITH per_bucket AS + ( + SELECT + event_time_microseconds AS bucket_time, + sum(size) AS bucket_sum + FROM system.trace_log + WHERE trace_type = 'JemallocSample' + AND query_id = '8678d8fe-62c5-48b8-b0cd-26851c62dd75' + GROUP BY bucket_time + ) + SELECT + bucket_time, + sum(bucket_sum) OVER ( + ORDER BY bucket_time ASC + ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW + ) AS cumulative_size, + formatReadableSize(cumulative_size) AS cumulative_size_readable + FROM per_bucket + ORDER BY bucket_time +) +``` + +我们可以使用该结果查看在该时间点时最活跃的分配来自哪里: + +```sql +SELECT + concat( + '\n', + arrayStringConcat( + arrayMap( + (x, y) -> concat(x, ': ', y), + arrayMap(x -> addressToLine(x), allocation_trace), + arrayMap(x -> demangle(addressToSymbol(x)), allocation_trace) + ), + '\n' + ) + ) AS symbolized_trace, + sum(s) AS per_trace_sum +FROM +( + SELECT + ptr, + sum(size) AS s, + argMax(trace, event_time_microseconds) AS allocation_trace + FROM system.trace_log + WHERE trace_type = 'JemallocSample' + AND query_id = '8678d8fe-62c5-48b8-b0cd-26851c62dd75' + AND event_time_microseconds <= '2025-09-04 11:56:21.737139' + GROUP BY ptr + HAVING s > 0 +) +GROUP BY ALL +ORDER BY per_trace_sum ASC ``` -`jemalloc` 将对分配进行采样并在内部存储该信息。 +## 刷新堆分析 {#flushing-heap-profiles} -我们可以通过运行以下命令来告诉 `jemalloc` 刷新当前配置文件: +默认情况下,堆分析文件将生成在 `/tmp/jemalloc_clickhouse._pid_._seqnum_.heap`,其中 `_pid_` 是ClickHouse的PID,`_seqnum_` 是当前堆分析的全局序列号。 +对于Keeper,默认文件为 `/tmp/jemalloc_keeper._pid_._seqnum_.heap`,并遵循相同的规则。 + +您可以通过运行以下命令来告诉 `jemalloc` 刷新当前分析: + +```sql +SYSTEM JEMALLOC FLUSH PROFILE +``` - SYSTEM JEMALLOC FLUSH PROFILE +它将返回刷新分析的文件位置。 - - echo jmfp | nc localhost 9181 + +```sh +echo jmfp | nc localhost 9181 +``` -默认情况下,堆配置文件将生成在 `/tmp/jemalloc_clickhouse._pid_._seqnum_.heap` 目录,其中 `_pid_` 是 ClickHouse 的 PID,`_seqnum_` 是当前堆配置文件的全局序列号。 -对于 Keeper,默认文件为 `/tmp/jemalloc_keeper._pid_._seqnum_.heap`,规则相同。 +可以通过附加 `MALLOC_CONF` 环境变量并使用 `prof_prefix` 选项来定义不同的位置。 +例如,如果您想在 `/data` 文件夹中生成文件名前缀为 `my_current_profile` 的分析,可以使用以下环境变量启动ClickHouse/Keeper: -可以通过将 `MALLOC_CONF` 环境变量与 `prof_prefix` 选项一起附加来定义不同的位置。 -例如,如果我们想在 `/data` 文件夹中生成配置文件,且文件名前缀为 `my_current_profile`,我们可以使用以下环境变量启动 ClickHouse/Keeper: ```sh -MALLOC_CONF=background_thread:true,prof:true,prof_prefix:/data/my_current_profile +MALLOC_CONF=prof_prefix:/data/my_current_profile ``` -生成的文件将附加 PID 和序列号到前缀中。 -## 分析堆配置文件 {#analyzing-heap-profiles} +生成的文件将附加到前缀PID和序列号。 -在生成堆配置文件后,我们需要对其进行分析。 -为此,我们需要使用 `jemalloc` 的工具 [jeprof](https://github.com/jemalloc/jemalloc/blob/dev/bin/jeprof.in),该工具可以通过多种方式安装: -- 使用系统的包管理器安装 `jemalloc` -- 克隆 [jemalloc 仓库](https://github.com/jemalloc/jemalloc) 并在根目录下运行 autogen.sh,这将为您提供 `bin` 文件夹中的 `jeprof` 脚本 +## 分析堆分析 {#analyzing-heap-profiles} + +在生成堆分析后,需要进行分析。 +为此,可以使用 `jemalloc` 的工具 [jeprof](https://github.com/jemalloc/jemalloc/blob/dev/bin/jeprof.in)。它可以通过多种方式安装: +- 通过系统的包管理器 +- 克隆 [jemalloc仓库](https://github.com/jemalloc/jemalloc) 并从根文件夹运行 `autogen.sh`。这将提供您在 `bin` 文件夹中的 `jeprof` 脚本 :::note -`jeprof` 使用 `addr2line` 来生成栈跟踪,可能会非常慢。 -如果是这种情况,我们建议安装该工具的 [替代实现](https://github.com/gimli-rs/addr2line)。 +`jeprof` 使用 `addr2line` 来生成堆栈跟踪,这可能非常慢。 +如果是这种情况,建议安装 [该工具的替代实现](https://github.com/gimli-rs/addr2line)。 ```bash git clone https://github.com/gimli-rs/addr2line.git --depth=1 --branch=0.23.0 @@ -66,32 +226,35 @@ cd addr2line cargo build --features bin --release cp ./target/release/addr2line path/to/current/addr2line ``` + +另外,`llvm-addr2line` 也能很好地工作。 + ::: -使用 `jeprof` 从堆配置文件生成不同格式的文件是有很多种选择的。 -我们建议运行 `jeprof --help` 检查用法和该工具提供的多种不同选项。 +使用 `jeprof` 从堆分析中生成有许多不同格式。 +建议运行 `jeprof --help` 以获取有关用法和工具提供的各种选项的信息。 -通常,`jeprof` 命令的格式如下: +一般来说,`jeprof` 命令的使用如下: ```sh jeprof path/to/binary path/to/heap/profile --output_format [ > output_file] ``` -如果我们想比较两个配置文件之间发生了哪些分配,可以设置基参数: +如果您想比较两个分析之间发生了哪些分配,可以设置 `base` 参数: ```sh jeprof path/to/binary --base path/to/first/heap/profile path/to/second/heap/profile --output_format [ > output_file] ``` -例如: +### 示例 {#examples} -- 如果我们想生成一个文本文件,每个过程占一行: +- 如果您想生成一个文本文件,每个过程写在一行: ```sh jeprof path/to/binary path/to/heap/profile --text > result.txt ``` -- 如果我们想生成一个包含调用图的 PDF 文件: +- 如果您想生成一个包含调用图的 PDF 文件: ```sh jeprof path/to/binary path/to/heap/profile --pdf > result.pdf @@ -99,81 +262,38 @@ jeprof path/to/binary path/to/heap/profile --pdf > result.pdf ### 生成火焰图 {#generating-flame-graph} -`jeprof` 允许我们生成以折叠栈构建火焰图。 +`jeprof` 允许您生成用于构建火焰图的折叠堆栈。 -我们需要使用 `--collapsed` 参数: +您需要使用 `--collapsed` 参数: ```sh jeprof path/to/binary path/to/heap/profile --collapsed > result.collapsed ``` -之后,我们可以使用许多不同工具来可视化折叠的栈。 +之后,您可以使用许多不同的工具来可视化折叠堆栈。 -最流行的工具是 [FlameGraph](https://github.com/brendangregg/FlameGraph),它包含一个名为 `flamegraph.pl` 的脚本: +最流行的是 [FlameGraph](https://github.com/brendangregg/FlameGraph),它包含一个名为 `flamegraph.pl` 的脚本: ```sh cat result.collapsed | /path/to/FlameGraph/flamegraph.pl --color=mem --title="Allocation Flame Graph" --width 2400 > result.svg ``` -另一个有趣的工具是 [speedscope](https://www.speedscope.app/),它允许您以更交互的方式分析收集到的栈。 - -## 运行时控制分配分析器 {#controlling-allocation-profiler-during-runtime} - -如果 ClickHouse/Keeper 在启用分析器的情况下启动,它们支持在运行时禁用/启用分配分析的附加命令。 -使用这些命令,可以更轻松地分析特定的时间间隔。 - -禁用分析器: - - - - - SYSTEM JEMALLOC DISABLE PROFILE - - - - - echo jmdp | nc localhost 9181 - - - - -启用分析器: - - - - - SYSTEM JEMALLOC ENABLE PROFILE - - - - - echo jmep | nc localhost 9181 - - - - -还可以通过设置 `prof_active` 选项来控制分析器的初始状态,该选项默认是启用的。 -例如,如果我们不想在启动期间采样分配,只想在启用分析器后进行采样,我们可以使用以下环境变量启动 ClickHouse/Keeper: -```sh -MALLOC_CONF=background_thread:true,prof:true,prof_active:false -``` - -并在后面的某个时间启用分析器。 +另一个有趣的工具是 [speedscope](https://www.speedscope.app/),它允许您以更交互的方式分析收集的堆栈。 -## 分析器的附加选项 {#additional-options-for-profiler} +## 分析器的其他选项 {#additional-options-for-profiler} -`jemalloc` 提供了许多与分析器相关的选项,可以通过修改 `MALLOC_CONF` 环境变量来控制。 -例如,可以使用 `lg_prof_sample` 控制分配样本之间的间隔。 -如果您想在每 N 字节时转储堆配置文件,可以使用 `lg_prof_interval` 启用它。 +`jemalloc` 有许多不同的与分析器相关的选项。可以通过修改 `MALLOC_CONF` 环境变量来控制它们。 +例如,可以通过 `lg_prof_sample` 控制分配样本之间的间隔。 +如果您想在每 N 字节时转储堆分析,可以使用 `lg_prof_interval` 开启此功能。 -我们建议查看 `jemalloc` 的 [参考页面](https://jemalloc.net/jemalloc.3.html) 以获取这些选项。 +建议查看 `jemalloc` 的 [参考页面](https://jemalloc.net/jemalloc.3.html),以获取完整的选项列表。 ## 其他资源 {#other-resources} -ClickHouse/Keeper 以多种方式暴露与 `jemalloc` 相关的度量。 +ClickHouse/Keeper以多种方式暴露与 `jemalloc` 相关的指标。 :::warning 警告 -需注意,这些度量之间没有同步,值可能会漂移。 +需要注意的是,这些指标之间均未同步,值可能会漂移。 ::: ### 系统表 `asynchronous_metrics` {#system-table-asynchronous_metrics} @@ -181,7 +301,7 @@ ClickHouse/Keeper 以多种方式暴露与 `jemalloc` 相关的度量。 ```sql SELECT * FROM system.asynchronous_metrics -WHERE metric ILIKE '%jemalloc%' +WHERE metric LIKE '%jemalloc%' FORMAT Vertical ``` @@ -189,21 +309,20 @@ FORMAT Vertical ### 系统表 `jemalloc_bins` {#system-table-jemalloc_bins} -包含通过 jemalloc 分配器在不同大小类别(bins)中进行的内存分配的信息,这些信息是在所有区域汇总的。 +包含来自所有区域按不同大小类别(Bins)通过jemalloc分配器进行的内存分配的信息。 [参考](/operations/system-tables/jemalloc_bins) ### Prometheus {#prometheus} -所有源自 `asynchronous_metrics` 的 `jemalloc` 相关指标也通过 ClickHouse 和 Keeper 中的 Prometheus 端点暴露。 +所有来自 `asynchronous_metrics` 的 `jemalloc` 相关指标也通过ClickHouse和Keeper的Prometheus端点暴露。 [参考](/operations/server-configuration-parameters/settings#prometheus) -### Keeper 中的 `jmst` 4LW 命令 {#jmst-4lw-command-in-keeper} +### `jmst` 4LW 命令在 Keeper 中 {#jmst-4lw-command-in-keeper} -Keeper 支持 `jmst` 4LW 命令,返回 [基本分配器统计信息](https://github.com/jemalloc/jemalloc/wiki/Use-Case%3A-Basic-Allocator-Statistics)。 +Keeper支持 `jmst` 4LW 命令,该命令返回 [基本分配器统计信息](https://github.com/jemalloc/jemalloc/wiki/Use-Case%3A-Basic-Allocator-Statistics): -示例: ```sh echo jmst | nc localhost 9181 ``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/allocation-profiling.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/allocation-profiling.md.hash index e2507067c07..03c7c08bf8f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/allocation-profiling.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/allocation-profiling.md.hash @@ -1 +1 @@ -97c9511e49f24027 +84f109707be8494a diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/analyzer.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/analyzer.md index aee23956935..43f0faa6c8b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/analyzer.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/analyzer.md @@ -1,30 +1,36 @@ --- -'description': '页面详细信息关于 ClickHouse 查询分析器' +'description': '页面详细介绍 ClickHouse 查询分析器' 'keywords': - 'analyzer' 'sidebar_label': '分析器' 'slug': '/operations/analyzer' 'title': '分析器' +'doc_type': 'reference' --- # 分析器 -## 已知不兼容性 {#known-incompatibilities} +在 ClickHouse 版本 `24.3` 中,新的查询分析器默认启用。 +您可以在[这里](/guides/developer/understanding-query-execution-with-the-analyzer#analyzer)阅读关于其工作原理的更多细节。 -在ClickHouse版本 `24.3` 中,新的查询分析器默认启用。 -尽管修复了大量错误并引入了新的优化,它也引入了一些会破坏ClickHouse行为的变更。请阅读以下变更以确定如何为新的分析器重写查询。 +## 已知的不兼容性 {#known-incompatibilities} + +尽管修复了大量错误并引入了新的优化,但它也在 ClickHouse 的行为中引入了一些重大变化。请阅读以下更改,以确定如何重写您的查询以适应新的分析器。 ### 无效查询不再被优化 {#invalid-queries-are-no-longer-optimized} -之前的查询规划基础设施在查询验证步骤之前应用AST级别的优化。 -优化可以重写初始查询,使其变为有效且可以执行。 +以前的查询规划基础设施在查询验证步骤之前进行了 AST 级别的优化。 +优化可以将初始查询重写为有效且可执行的。 在新的分析器中,查询验证发生在优化步骤之前。 -这意味着先前可以执行的无效查询现在不再受到支持。 -在这种情况下,查询必须手动修复。 +这意味着以前可以执行的无效查询现在不再受支持。 +在这种情况下,必须手动修复查询。 + +#### 示例 1 {#example-1} -**示例 1:** +以下查询在投影列表中使用列 `number`,而在聚合后仅可用 `toString(number)`。 +在旧分析器中,`GROUP BY toString(number)` 被优化为 `GROUP BY number,`,使查询有效。 ```sql SELECT number @@ -32,10 +38,10 @@ FROM numbers(1) GROUP BY toString(number) ``` -以下查询在投影列表中使用列 `number`,而在聚合后仅可用 `toString(number)`。 -在旧分析器中,`GROUP BY toString(number)` 被优化为 `GROUP BY number,`,使查询有效。 +#### 示例 2 {#example-2} -**示例 2:** +同样的问题出现在此查询中。列 `number` 在与其他键聚合后被使用。 +以前的查询分析器通过将 `HAVING` 子句中的 `number > 5` 过滤器移动到 `WHERE` 子句来修复此查询。 ```sql SELECT @@ -46,10 +52,8 @@ GROUP BY n HAVING number > 5 ``` -在此查询中也出现了相同的问题:在使用另一个键聚合后,列 `number` 被使用。 -之前的查询分析器通过将 `number > 5` 过滤器从 `HAVING` 子句移动到 `WHERE` 子句来修复此查询。 +要修复查询,您应该将所有适用于非聚合列的条件移动到 `WHERE` 部分,以符合标准 SQL 语法: -要修复查询,您应该将所有适用于非聚合列的条件移动到 `WHERE` 部分,以符合标准SQL语法: ```sql SELECT number % 2 AS n, @@ -59,17 +63,20 @@ WHERE number > 5 GROUP BY n ``` -### CREATE VIEW 具有无效查询 {#create-view-with-invalid-query} +### 用无效查询创建视图 {#create-view-with-invalid-query} 新的分析器始终执行类型检查。 -之前,可以创建一个具有无效 `SELECT` 查询的 `VIEW`。在首次 `SELECT` 或 `INSERT`(在 `MATERIALIZED VIEW` 的情况下)时会失败。 +以前,可以使用无效的 `SELECT` 查询创建 `VIEW`。 +然后在第一次 `SELECT` 或 `INSERT`(在 `MATERIALIZED VIEW` 的情况下)时失败。 -现在,不再可以创建这样的 `VIEW`。 +现在不再可能以这种方式创建 `VIEW`。 -**示例:** +#### 示例 {#example-view} ```sql -CREATE TABLE source (data String) ENGINE=MergeTree ORDER BY tuple(); +CREATE TABLE source (data String) +ENGINE=MergeTree +ORDER BY tuple(); CREATE VIEW some_view AS SELECT JSONExtract(data, 'test', 'DateTime64(3)') @@ -78,30 +85,31 @@ FROM source; ### `JOIN` 子句的已知不兼容性 {#known-incompatibilities-of-the-join-clause} -#### 使用投影中的列进行连接 {#join-using-column-from-projection} +#### 使用投影中的列进行 `JOIN` {#join-using-column-from-projection} -默认情况下,不能使用 `SELECT` 列表中的别名作为 `JOIN USING` 键。 +默认情况下,不能将 `SELECT` 列表中的别名用作 `JOIN USING` 键。 -一个新的设置 `analyzer_compatibility_join_using_top_level_identifier`,启用时,会改变 `JOIN USING` 的行为,以优先基于 `SELECT` 查询的投影列表中的表达式来解析标识符,而不是直接使用左表中的列。 +新的设置 `analyzer_compatibility_join_using_top_level_identifier` 在启用时,改变了 `JOIN USING` 的行为,以优先根据 `SELECT` 查询的投影列表中的表达式解析标识符,而不是直接使用左表中的列。 -**示例:** +例如: ```sql SELECT a + 1 AS b, t2.s -FROM Values('a UInt64, b UInt64', (1, 1)) AS t1 -JOIN Values('b UInt64, s String', (1, 'one'), (2, 'two')) t2 +FROM VALUES('a UInt64, b UInt64', (1, 1)) AS t1 +JOIN VALUES('b UInt64, s String', (1, 'one'), (2, 'two')) t2 USING (b); ``` -当 `analyzer_compatibility_join_using_top_level_identifier` 设置为 `true` 时,连接条件被解释为 `t1.a + 1 = t2.b`,与早期版本的行为相匹配。因此,结果将是 `2, 'two'`。 -当该设置为 `false` 时,连接条件默认为 `t1.b = t2.b`,查询将返回 `2, 'one'`。 -如果 `b` 不在 `t1` 中,则查询将因错误而失败。 +将 `analyzer_compatibility_join_using_top_level_identifier` 设置为 `true` 时,连接条件被解释为 `t1.a + 1 = t2.b`,与早期版本的行为保持一致。 +结果将是 `2, 'two'`。 +当设置为 `false` 时,连接条件默认为 `t1.b = t2.b`,查询将返回 `2, 'one'`。 +如果 `b` 不在 `t1` 中,查询将失败并出现错误。 #### 使用 `JOIN USING` 和 `ALIAS`/`MATERIALIZED` 列的行为变化 {#changes-in-behavior-with-join-using-and-aliasmaterialized-columns} -在新的分析器中,在涉及 `ALIAS` 或 `MATERIALIZED` 列的 `JOIN USING` 查询中,使用 `*` 默认会在结果集中包括这些列。 +在新的分析器中,在涉及 `ALIAS` 或 `MATERIALIZED` 列的 `JOIN USING` 查询中使用 `*` 会默认将这些列包含在结果集中。 -**示例:** +例如: ```sql CREATE TABLE t1 (id UInt64, payload ALIAS sipHash64(id)) ENGINE = MergeTree ORDER BY id; @@ -114,31 +122,32 @@ SELECT * FROM t1 FULL JOIN t2 USING (payload); ``` -在新的分析器中,此查询的结果将包括来自两个表的 `payload` 列和 `id`。相比之下,之前的分析器仅在启用了特定设置(`asterisk_include_alias_columns` 或 `asterisk_include_materialized_columns`)时才会包括这些 `ALIAS` 列,且列可能按不同顺序出现。 +在新的分析器中,此查询的结果将包括 `payload` 列以及来自两个表的 `id`。 +相比之下,之前的分析器仅在启用特定设置(`asterisk_include_alias_columns` 或 `asterisk_include_materialized_columns`)的情况下才会包括这些 `ALIAS` 列,并且列可能会以不同的顺序出现。 -为了确保一致且预期的结果,尤其是在将旧查询迁移到新分析器时,建议在 `SELECT` 子句中明确指定列,而不是使用 `*`。 +为了确保一致和预期的结果,特别是在将旧查询迁移到新的分析器时,建议在 `SELECT` 子句中明确指定列,而不是使用 `*`。 -#### 在 `USING` 子句中处理列的类型修饰符 {#handling-of-type-modifiers-for-columns-in-using-clause} +#### 处理 `USING` 子句中列的类型修饰符 {#handling-of-type-modifiers-for-columns-in-using-clause} -在新的分析器版本中,确定 `USING` 子句中指定的列的共同超类型的规则已标准化,以产生更可预测的结果,特别是在处理诸如 `LowCardinality` 和 `Nullable` 的类型修饰符时。 +在新的分析器版本中,确定 `USING` 子句中指定的列的公共超类型的规则已标准化,以产生更可预测的结果,特别是在处理类型修饰符如 `LowCardinality` 和 `Nullable` 时。 -- `LowCardinality(T)` 和 `T`:当类型为 `LowCardinality(T)` 的列与类型为 `T` 的列连接时,结果的共同超类型将为 `T`,有效地丢弃 `LowCardinality` 修饰符。 +- `LowCardinality(T)` 和 `T`:当一个类型为 `LowCardinality(T)` 的列与一个类型为 `T` 的列连接时,结果的公共超类型将是 `T`,有效丢弃 `LowCardinality` 修饰符。 +- `Nullable(T)` 和 `T`:当一个类型为 `Nullable(T)` 的列与一个类型为 `T` 的列连接时,结果的公共超类型将是 `Nullable(T)`,确保可空属性得以保留。 -- `Nullable(T)` 和 `T`:当类型为 `Nullable(T)` 的列与类型为 `T` 的列连接时,结果的共同超类型将为 `Nullable(T)`,确保 nullable 属性得到保留。 - -**示例:** +例如: ```sql -SELECT id, toTypeName(id) FROM Values('id LowCardinality(String)', ('a')) AS t1 -FULL OUTER JOIN Values('id String', ('b')) AS t2 +SELECT id, toTypeName(id) +FROM VALUES('id LowCardinality(String)', ('a')) AS t1 +FULL OUTER JOIN VALUES('id String', ('b')) AS t2 USING (id); ``` -在此查询中,`id` 的共同超类型被确定为 `String`,丢弃了来自 `t1` 的 `LowCardinality` 修饰符。 +在此查询中,`id` 的公共超类型被确定为 `String`,丢弃了来自 `t1` 的 `LowCardinality` 修饰符。 ### 投影列名变化 {#projection-column-names-changes} -在计算投影名称时,不会替换别名。 +在计算投影名时,别名不会被替换。 ```sql SELECT @@ -165,11 +174,9 @@ FORMAT PrettyCompact ### 不兼容的函数参数类型 {#incompatible-function-arguments-types} 在新的分析器中,类型推断发生在初始查询分析期间。 -这一变化意味着类型检查在短路评估之前进行;因此,`if` 的函数参数必须始终具有共同超类型。 - -**示例:** +此更改意味着类型检查在短路评估之前进行;因此,`if` 函数的参数必须始终具有公共超类型。 -以下查询失败,提示 `对于类型 Array(UInt8)、String,没有超类型,因为它们中的一些是 Array 而其他不是`: +例如,以下查询会失败并出现 `There is no supertype for types Array(UInt8), String because some of them are Array and some of them are not`: ```sql SELECT toTypeName(if(0, [2, 3, 4], 'String')) @@ -177,18 +184,18 @@ SELECT toTypeName(if(0, [2, 3, 4], 'String')) ### 异构集群 {#heterogeneous-clusters} -新的分析器显著改变了集群内服务器之间的通信协议。因此,无法在具有不同 `enable_analyzer` 设置值的服务器上运行分布式查询。 +新的分析器显著改变了集群中服务器之间的通信协议。因此,无法在具有不同 `enable_analyzer` 设置值的服务器上运行分布式查询。 -### 变更由之前的分析器解释 {#mutations-are-interpreted-by-previous-analyzer} +### 变更由先前的分析器解释 {#mutations-are-interpreted-by-previous-analyzer} -变更仍使用旧分析器。 +变更仍然使用旧的分析器。 这意味着某些新的 ClickHouse SQL 特性无法在变更中使用。例如,`QUALIFY` 子句。 -状态可以在 [这里](https://github.com/ClickHouse/ClickHouse/issues/61563) 检查。 +可以在[这里](https://github.com/ClickHouse/ClickHouse/issues/61563)检查状态。 ### 不支持的特性 {#unsupported-features} -新分析器当前不支持的特性列表: +新的分析器目前不支持的特性列表如下: - Annoy 索引。 -- 假设索引。正在进行中的工作 [在这里](https://github.com/ClickHouse/ClickHouse/pull/48381)。 -- 窗口视图不受支持。未来没有支持它的计划。 +- Hypothesis 索引。正在进行中的工作[在这里](https://github.com/ClickHouse/ClickHouse/pull/48381)。 +- 不支持窗口视图。未来没有计划支持。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/analyzer.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/analyzer.md.hash index a260ff8a438..ba8b026bd46 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/analyzer.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/analyzer.md.hash @@ -1 +1 @@ -c6180477900dac75 +6bc061c2f2e4373d diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/backup.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/backup.md index 748dcb448f0..663558358b1 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/backup.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/backup.md @@ -1,9 +1,10 @@ --- -'description': '关于备份和恢复 ClickHouse 数据库和表的指南' +'description': '为备份和恢复 CLICKHOUSE 数据库和 TABLE 的指南' 'sidebar_label': '备份和恢复' 'sidebar_position': 10 'slug': '/operations/backup' 'title': '备份和恢复' +'doc_type': 'guide' --- @@ -33,26 +34,26 @@ BACKUP|RESTORE ``` :::note ALL -在 ClickHouse 的 23.4 版本之前,`ALL` 只能适用于 `RESTORE` 命令。 +在 ClickHouse 23.4 之前,`ALL` 仅适用于 `RESTORE` 命令。 ::: ## 背景 {#background} -虽然 [复制](../engines/table-engines/mergetree-family/replication.md) 提供了硬件故障的保护,但并不能防止人为错误:意外删除数据、删除错误的表或在错误的集群上删除表,以及导致数据处理不正确或数据损坏的软件漏洞。在许多情况下,这类错误会影响所有副本。ClickHouse 内置了防止某些类型错误的保障措施——例如,默认情况下 [你无法仅删除包含超过 50 Gb 数据的 MergeTree 类引擎的表](/operations/settings/settings#max_table_size_to_drop)。然而,这些保障措施并不涵盖所有可能的情况,并且可能会被绕过。 +虽然 [复制](../engines/table-engines/mergetree-family/replication.md) 提供了对硬件故障的保护,但却无法防止人为错误:数据的意外删除、错误表的删除或错误集群上的表的删除,以及导致数据处理不正确或数据损坏的软件错误。在许多情况下,这样的错误会影响所有副本。ClickHouse 内置了防止某些类型错误的保护措施——例如,默认情况下 [你不能仅仅删除一个包含超过 50 Gb 数据的 MergeTree 类引擎的表](/operations/settings/settings#max_table_size_to_drop)。但是,这些保护措施并不能涵盖所有可能的情况,并且可以被规避。 为了有效减轻可能的人为错误,你应该提前仔细准备备份和恢复数据的策略。 -每个公司可用的资源和业务需求不同,因此没有适用于所有情况的 ClickHouse 备份和恢复的通用解决方案。对一千兆数据有效的解决方案,可能不适用于数十个拍字节的数据。存在多种可能的方法,各自有优缺点,下面将进行讨论。使用几种方法而不仅仅是一种,来补偿它们的各种缺点是一个好主意。 +每个公司的资源和业务需求各不相同,因此没有普适的 ClickHouse 备份和恢复解决方案适用于每种情况。对于一吉字节的数据有效的方法可能不适用于数十 PB 的数据。有多种可能的方案,每种方案都有其优缺点,下面将进行讨论。最好使用多种方法,而不是仅仅依赖一种,以补偿它们的各种缺陷。 :::note -请记住,如果你备份了什么东西但从未尝试恢复,那么当你实际需要时,恢复可能无法正常工作(或者至少会比企业可容忍的时间更长)。因此,无论你选择哪种备份方法,请确保也自动化恢复过程,并定期在备用的 ClickHouse 集群上进行练习。 +请记住,如果你备份了某些东西但从未尝试过恢复,那么在真正需要时恢复可能不会正常工作(或者至少会比业务所能容忍的时间更长)。所以无论你选择哪种备份方法,确保将恢复过程自动化,并定期在备用 ClickHouse 集群上进行练习。 ::: ## 备份到本地磁盘 {#backup-to-a-local-disk} ### 配置备份目标 {#configure-a-backup-destination} -在下面的示例中,你将看到备份目标指定为 `Disk('backups', '1.zip')`。为了准备目标,在 `/etc/clickhouse-server/config.d/backup_disk.xml` 中添加一个文件,指定备份目标。例如,该文件定义了名为 `backups` 的磁盘,然后将该磁盘添加到 **backups > allowed_disk** 列表中: +在下面的示例中,备份目标指定为 `Disk('backups', '1.zip')`。要准备目标,请在 `/etc/clickhouse-server/config.d/backup_disk.xml` 中添加一个文件,指定备份目标。例如,该文件定义了一个名为 `backups` 的磁盘,然后将该磁盘添加到 **backups > allowed_disk** 列表中: ```xml @@ -76,46 +77,46 @@ BACKUP|RESTORE ### 参数 {#parameters} -备份可以是完整的或增量的,可以包含表(包括物化视图、投影和字典)和数据库。备份可以是同步的(默认)或异步的。可以压缩备份。备份可以设有密码保护。 +备份可以是完整的或增量的,可以包含表(包括物化视图、投影和字典)和数据库。备份可以是同步的(默认)或异步的。它们可以被压缩。备份可以设置密码保护。 -BACKUP 和 RESTORE 语句接受数据库和表名称的列表、一个目标(或源)、选项和设置: -- 备份的目标,或恢复的源。这基于之前定义的磁盘。例如 `Disk('backups', 'filename.zip')` +BACKUP 和 RESTORE 语句接受数据库和表名称列表、目标(或源)、选项和设置: +- 备份的目标或恢复的来源。这是基于之前定义的磁盘。例如 `Disk('backups', 'filename.zip')` - ASYNC:异步备份或恢复 - PARTITIONS:要恢复的分区列表 - SETTINGS: - - `id`:备份或恢复操作的 id,随机生成 UUID,若未手动指定则使用。若已有同一 `id` 的操作在运行,则抛出异常。 - - [`compression_method`](/sql-reference/statements/create/table#column_compression_codec) 和 compression_level - - `password` 用于磁盘上的文件 - - `base_backup`:此源的前一个备份的目标。例如,`Disk('backups', '1.zip')` - - `use_same_s3_credentials_for_base_backup`:基础备份是否应从查询中继承凭据。仅对 `S3` 有效。 - - `use_same_password_for_base_backup`:基础备份存档是否应从查询中继承密码。 - - `structure_only`:如果启用,仅允许备份或恢复 CREATE 语句,而不包括表的数据 - - `storage_policy`:恢复表的存储策略。请参见 [使用多个块设备进行数据存储](../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-multiple-volumes)。此设置仅适用于 `RESTORE` 命令。所指定的存储策略仅适用于来自 `MergeTree` 家族的引擎的表。 - - `s3_storage_class`:用于 S3 备份的存储类。例如,`STANDARD` - - `azure_attempt_to_create_container`:使用 Azure Blob Storage 时,指定的容器在不存在时是否尝试创建。默认值:true。 - - [核心设置](/operations/settings/settings) 也可在此处使用 + - `id`:备份或恢复操作的标识符。如果未设置或为空,则将使用随机生成的 UUID。如果将其显式设置为非空字符串,则应每次都不同。此 `id` 用于查找 `system.backups` 表中与特定备份或恢复操作相关的行。 + - [`compression_method`](/sql-reference/statements/create/table#column_compression_codec) 和 compression_level + - 磁盘上的文件 `password` + - `base_backup`:此源的上一个备份的目标。例如,`Disk('backups', '1.zip')` + - `use_same_s3_credentials_for_base_backup`:基于查询的基础备份是否应继承凭证。仅适用于 `S3`。 + - `use_same_password_for_base_backup`:基础备份归档是否应继承查询的密码。 + - `structure_only`:启用后,仅允许备份或恢复 CREATE 语句而不包括表的数据 + - `storage_policy`:恢复的表的存储策略。请参见 [使用多个块设备进行数据存储](../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-multiple-volumes)。此设置仅适用于 `RESTORE` 命令。指定的存储策略仅适用于 `MergeTree` 家族中的引擎的表。 + - `s3_storage_class`:用于 S3 备份的存储类。例如,`STANDARD` + - `azure_attempt_to_create_container`:使用 Azure Blob 存储时,如果指定的容器不存在,是否尝试创建。默认:true。 + - [核心设置](/operations/settings/settings) 也可以在这里使用 ### 使用示例 {#usage-examples} -备份并恢复一个表: +备份然后恢复一个表: ```sql BACKUP TABLE test.table TO Disk('backups', '1.zip') ``` -相应的恢复: +对应的恢复: ```sql RESTORE TABLE test.table FROM Disk('backups', '1.zip') ``` :::note -如果表 `test.table` 包含数据,上述 RESTORE 将失败,你必须先删除该表才能测试 RESTORE,或者使用设置 `allow_non_empty_tables=true`: +如果表 `test.table` 包含数据,上述 RESTORE 会失败,你需要删除该表才能测试 RESTORE,或使用设置 `allow_non_empty_tables=true`: ```sql RESTORE TABLE test.table FROM Disk('backups', '1.zip') SETTINGS allow_non_empty_tables=true ``` ::: -表可以以新名称恢复或备份: +表可以使用新名称恢复或备份: ```sql RESTORE TABLE test.table AS test.table2 FROM Disk('backups', '1.zip') ``` @@ -126,18 +127,18 @@ BACKUP TABLE test.table3 AS test.table4 TO Disk('backups', '2.zip') ### 增量备份 {#incremental-backups} -通过指定 `base_backup` 可以进行增量备份。 +增量备份可以通过指定 `base_backup` 来进行。 :::note -增量备份依赖于基础备份。基础备份必须保持可用,以便能够从增量备份中恢复。 +增量备份依赖于基础备份。必须保持基础备份可用,以便能够从增量备份恢复。 ::: -增量存储新数据。设置 `base_backup` 会导致自上一个备份起的数据存储到 `Disk('backups', 'incremental-a.zip')`: +增量存储新数据。设置 `base_backup` 会导致自上一个备份以来的数据存储到 `Disk('backups', 'd.zip')` 中,存储到 `Disk('backups', 'incremental-a.zip')` 中: ```sql BACKUP TABLE test.table TO Disk('backups', 'incremental-a.zip') SETTINGS base_backup = Disk('backups', 'd.zip') ``` -从增量备份和 base_backup 恢复所有数据到新表 `test.table2`: +从增量备份和 `base_backup` 中恢复所有数据到新表 `test.table2`: ```sql RESTORE TABLE test.table AS test.table2 FROM Disk('backups', 'incremental-a.zip'); @@ -145,7 +146,7 @@ RESTORE TABLE test.table AS test.table2 ### 为备份分配密码 {#assign-a-password-to-the-backup} -写入磁盘的备份可以对文件应用密码: +写入磁盘的备份可以为文件应用密码: ```sql BACKUP TABLE test.table TO Disk('backups', 'password-protected.zip') @@ -161,7 +162,7 @@ RESTORE TABLE test.table ### 压缩设置 {#compression-settings} -如果你想指定压缩方法或级别: +如果您希望指定压缩方法或级别: ```sql BACKUP TABLE test.table TO Disk('backups', 'filename.zip') @@ -169,36 +170,36 @@ BACKUP TABLE test.table ``` ### 恢复特定分区 {#restore-specific-partitions} -如果需要恢复与表相关的特定分区,可以指定这些分区。要从备份恢复分区 1 和 4: +如果需要恢复与某个表相关的特定分区,可以指定这些分区。要恢复备份中的分区 1 和 4: ```sql RESTORE TABLE test.table PARTITIONS '2', '3' FROM Disk('backups', 'filename.zip') ``` -### 将备份作为 tar 存档 {#backups-as-tar-archives} +### 作为 tar 存档的备份 {#backups-as-tar-archives} -备份也可以存储为 tar 存档。其功能与 zip 相同,只是不支持密码。 +备份也可以存储为 tar 存档。功能与 zip 相同,只是密码不受支持。 -将备份写入 tar: +将备份写为 tar: ```sql BACKUP TABLE test.table TO Disk('backups', '1.tar') ``` -相应的恢复: +对应的恢复: ```sql RESTORE TABLE test.table FROM Disk('backups', '1.tar') ``` -要更改压缩方法,应将正确的文件后缀附加到备份名称。即要用 gzip 压缩 tar 存档: +要更改压缩方法,应将正确的文件后缀附加到备份名称上。即要使用 gzip 压缩 tar 存档: ```sql BACKUP TABLE test.table TO Disk('backups', '1.tar.gz') ``` -支持的压缩文件后缀为 `tar.gz`、`.tgz`、`tar.bz2`、`tar.lzma`、`.tar.zst`、`.tzst` 和 `.tar.xz`。 +支持的压缩文件后缀为 `tar.gz`、`.tgz` `tar.bz2`、`tar.lzma`、`.tar.zst`、`.tzst` 和 `.tar.xz`。 ### 检查备份状态 {#check-the-status-of-backups} -备份命令返回一个 `id` 和 `status`,并且该 `id` 可用于获取备份的状态。这对于检查长时间 ASYNC 备份的进度非常有用。下面的示例显示在尝试覆盖已有备份文件时发生的失败: +备份命令返回 `id` 和 `status`,并且该 `id` 可以用于获取备份的状态。这对检查长时间 ASYNC 备份的进度非常有用。下面的示例显示了尝试覆盖现有备份文件时发生的失败: ```sql BACKUP TABLE helloworld.my_first_table TO Disk('backups', '1.zip') ASYNC ``` @@ -214,7 +215,7 @@ BACKUP TABLE helloworld.my_first_table TO Disk('backups', '1.zip') ASYNC SELECT * FROM system.backups -where id='7678b0b3-f519-4e6e-811f-5a0781a4eb52' +WHERE id='7678b0b3-f519-4e6e-811f-5a0781a4eb52' FORMAT Vertical ``` ```response @@ -235,7 +236,7 @@ end_time: 2022-08-30 09:21:46 1 row in set. Elapsed: 0.002 sec. ``` -与 `system.backups` 表一起,所有备份和恢复操作也在系统日志表 [backup_log](../operations/system-tables/backup_log.md) 中跟踪: +除了 `system.backups` 表外,所有备份和恢复操作也记录在系统日志表 [backup_log](../operations/system-tables/backup_log.md) 中: ```sql SELECT * FROM system.backup_log @@ -286,7 +287,7 @@ bytes_read: 0 ## 配置备份/恢复以使用 S3 端点 {#configuring-backuprestore-to-use-an-s3-endpoint} -要将备份写入 S3 存储桶,你需要三种信息: +要将备份写入 S3 存储桶,你需要三项信息: - S3 端点, 例如 `https://mars-doc-test.s3.amazonaws.com/backup-S3/` - 访问密钥 ID, @@ -295,10 +296,10 @@ bytes_read: 0 例如 `Abc+123` :::note -创建 S3 存储桶的过程请参见 [将 S3 对象存储用作 ClickHouse 磁盘](/integrations/data-ingestion/s3/index.md#configuring-s3-for-clickhouse-use),保存策略后再返回此文档,无需配置 ClickHouse 以使用 S3 存储桶。 +创建 S3 存储桶的过程在 [将 S3 对象存储用作 ClickHouse 磁盘](/integrations/data-ingestion/s3/index.md#configuring-s3-for-clickhouse-use) 中进行了介绍,保存政策后返回此文档,无需配置 ClickHouse 使用 S3 存储桶。 ::: -备份的目标将如下指定: +备份的目标将像这样指定: ```sql S3('/', '', '') @@ -323,7 +324,7 @@ LIMIT 1000 ### 创建基础(初始)备份 {#create-a-base-initial-backup} -增量备份需要一个基础备份来开始,本示例将稍后用作基础备份。S3 目标的第一个参数是 S3 端点,后面是用于此备份的桶内目录。在本例中,目录名为 `my_backup`。 +增量备份需要一个 _基础_ 备份作为起点,此示例将在后面作为基础备份使用。S3 目标的第一个参数是 S3 端点,后跟用于此备份的存储桶内的目录。在此示例中,该目录名为 `my_backup`。 ```sql BACKUP TABLE data TO S3('https://mars-doc-test.s3.amazonaws.com/backup-S3/my_backup', 'ABC123', 'Abc+123') @@ -337,7 +338,7 @@ BACKUP TABLE data TO S3('https://mars-doc-test.s3.amazonaws.com/backup-S3/my_bac ### 添加更多数据 {#add-more-data} -增量备份是基于基础备份和当前内容之间的差异填充的。在进行增量备份之前,添加更多数据: +增量备份是通过计算基础备份和被备份表当前内容之间的差异来填充的。在进行增量备份之前添加更多数据: ```sql INSERT INTO data SELECT * @@ -346,7 +347,7 @@ LIMIT 100 ``` ### 进行增量备份 {#take-an-incremental-backup} -此备份命令类似于基础备份,但添加了 `SETTINGS base_backup` 和基础备份的位置。请注意,增量备份的目标不是与基础相同的目录,而是同一端点下不同的目标目录。基础备份在 `my_backup`,增量将写入 `my_incremental`: +此备份命令与基础备份类似,但增加了 `SETTINGS base_backup` 和基础备份的位置。请注意,增量备份的目标不是与基础相同的目录,而是同一端点下存储桶内的不同目标目录。基础备份在 `my_backup` 中,增量将写入 `my_incremental`: ```sql BACKUP TABLE data TO S3('https://mars-doc-test.s3.amazonaws.com/backup-S3/my_incremental', 'ABC123', 'Abc+123') SETTINGS base_backup = S3('https://mars-doc-test.s3.amazonaws.com/backup-S3/my_backup', 'ABC123', 'Abc+123') ``` @@ -356,9 +357,9 @@ BACKUP TABLE data TO S3('https://mars-doc-test.s3.amazonaws.com/backup-S3/my_inc │ f6cd3900-850f-41c9-94f1-0c4df33ea528 │ BACKUP_CREATED │ └──────────────────────────────────────┴────────────────┘ ``` -### 从增量备份中恢复 {#restore-from-the-incremental-backup} +### 从增量备份恢复 {#restore-from-the-incremental-backup} -此命令将增量备份恢复到新表 `data3`。请注意,当恢复增量备份时,基础备份也包含在内。恢复时仅指定增量备份: +此命令将增量备份恢复到新表 `data3` 中。请注意,当恢复增量备份时,基础备份也会被包含在内。只需在恢复时指定增量备份: ```sql RESTORE TABLE data AS data3 FROM S3('https://mars-doc-test.s3.amazonaws.com/backup-S3/my_incremental', 'ABC123', 'Abc+123') ``` @@ -371,7 +372,7 @@ RESTORE TABLE data AS data3 FROM S3('https://mars-doc-test.s3.amazonaws.com/back ### 验证计数 {#verify-the-count} -原始表 `data` 中有两次插入,一次为 1,000 行,一次为 100 行,总共 1,100。验证恢复的表有 1,100 行: +原始表 `data` 中有两个插入,一个包含 1,000 行,另一个包含 100 行,总共 1,100 行。验证恢复的表有 1,100 行: ```sql SELECT count() FROM data3 @@ -383,7 +384,7 @@ FROM data3 ``` ### 验证内容 {#verify-the-content} -这将比较原始表 `data` 与恢复的表 `data3` 的内容: +这将比较原始表 `data` 和恢复的表 `data3` 的内容: ```sql SELECT throwIf(( SELECT groupArray(tuple(*)) @@ -395,7 +396,7 @@ SELECT throwIf(( ``` ## 使用 S3 磁盘进行备份/恢复 {#backuprestore-using-an-s3-disk} -也可以通过在 ClickHouse 存储配置中配置 S3 磁盘来 `BACKUP`/`RESTORE` 到 S3。通过在 `/etc/clickhouse-server/config.d` 中添加一个文件来配置磁盘: +通过在 ClickHouse 存储配置中配置 S3 磁盘,还可以将 `BACKUP`/`RESTORE` 目标设置为 S3。可以通过在 `/etc/clickhouse-server/config.d` 中添加文件这样配置磁盘: ```xml @@ -425,7 +426,7 @@ SELECT throwIf(( ``` -然后像往常一样进行 `BACKUP`/`RESTORE`: +然后按常规方式进行 `BACKUP`/`RESTORE`: ```sql BACKUP TABLE data TO Disk('s3_plain', 'cloud_backup'); @@ -434,38 +435,38 @@ RESTORE TABLE data AS data_restored FROM Disk('s3_plain', 'cloud_backup'); :::note 但请记住: -- 该磁盘不应用于 `MergeTree` 本身,仅用于 `BACKUP`/`RESTORE` -- 如果你的表由 S3 存储支持且磁盘类型不同,则它不会使用 `CopyObject` 调用将部分复制到目标存储桶,而是下载并上传,这非常低效。对于这种用例,最好使用 `BACKUP ... TO S3()` 语法。 +- 此磁盘不应用于 `MergeTree` 本身,仅用于 `BACKUP`/`RESTORE` +- 如果你的表基于 S3 存储并且磁盘类型不同,它不会使用 `CopyObject` 调用将分片复制到目标存储桶,而是下载并上传它们,这非常低效。对于这种用例,最好使用 `BACKUP ... TO S3()` 语法。 ::: ## 使用命名集合 {#using-named-collections} -命名集合可以用于 `BACKUP/RESTORE` 参数。示例请见 [这里](./named-collections.md#named-collections-for-backups)。 +可以使用命名集合作为 `BACKUP/RESTORE` 参数。请参见 [这里](./named-collections.md#named-collections-for-backups) 获取示例。 ## 替代方案 {#alternatives} -ClickHouse 在磁盘上存储数据,有许多方法可以备份磁盘。这些是在过去使用的一些替代方案,可能适合你的环境。 +ClickHouse 将数据存储在磁盘上,有很多方法可以备份磁盘。这些是过去使用过的一些替代方案,可能很适合你的环境。 -### 在其他地方复制源数据 {#duplicating-source-data-somewhere-else} +### 将源数据复制到其他地方 {#duplicating-source-data-somewhere-else} -通常,导入 ClickHouse 的数据是通过某种持久队列传递的,比如 [Apache Kafka](https://kafka.apache.org)。在这种情况下,可以配置一个额外的订阅者集合,这些订阅者将读取相同的数据流,同时在写入 ClickHouse 的时候将其存储在其他冷存储中。大多数公司已经有一些推荐的冷存储,可能是对象存储或 [HDFS](https://hadoop.apache.org/docs/stable/hadoop-project-dist/hadoop-hdfs/HdfsDesign.html) 这样的分布式文件系统。 +通常,传输到 ClickHouse 的数据通过某种持久队列交付,例如 [Apache Kafka](https://kafka.apache.org)。在这种情况下,可以配置一组额外的订阅者,在写入 ClickHouse 的同时读取相同的数据流并将其存储在冷存储中。大多数公司已经有一些默认推荐的冷存储,可以是对象存储或 [HDFS](https://hadoop.apache.org/docs/stable/hadoop-project-dist/hadoop-hdfs/HdfsDesign.html) 这样的分布式文件系统。 ### 文件系统快照 {#filesystem-snapshots} -一些本地文件系统提供快照功能(例如,[ZFS](https://en.wikipedia.org/wiki/ZFS)),但它们可能不是服务实时查询的最佳选择。一个可能的解决方案是使用这种文件系统创建附加副本,并将其排除在用于 `SELECT` 查询的 [Distributed](../engines/table-engines/special/distributed.md) 表之外。此类副本上的快照将无法被任何修改数据的查询访问。作为额外好处,这些副本可能具有额外的硬件配置,每个服务器连接更多磁盘,从而具有成本效益。 +某些本地文件系统提供快照功能(例如,[ZFS](https://en.wikipedia.org/wiki/ZFS)),但它们可能不是提供实时查询的最佳选择。一种可能的解决方案是创建使用这种文件系统的额外副本,并将其排除在用于 `SELECT` 查询的 [Distributed](../engines/table-engines/special/distributed.md) 表之外。这些副本上的快照将无法被任何修改数据的查询访问。作为额外好处,这些副本可能具有连接更多磁盘的特殊硬件配置,从而具有成本效益。 对于较小的数据量,简单的 `INSERT INTO ... SELECT ...` 到远程表也可能有效。 -### 处理分区 {#manipulations-with-parts} +### 与分区的操作 {#manipulations-with-parts} -ClickHouse 允许使用 `ALTER TABLE ... FREEZE PARTITION ...` 查询创建表分区的本地副本。这是通过对 `/var/lib/clickhouse/shadow/` 文件夹的硬链接实现的,因此通常不会为旧数据占用额外的磁盘空间。创建的文件副本不由 ClickHouse 服务器处理,因此你可以将它们留在那里:你将会有一个简单的备份,无需任何额外的外部系统,但它仍然容易受到硬件问题的影响。出于这个原因,最好将它们远程复制到另一个位置,然后删除本地副本。分布式文件系统和对象存储仍然是不错的选择,但正常的附加文件服务器只要容量足够也可能有效(在这种情况下,传输将通过网络文件系统或[rsync](https://en.wikipedia.org/wiki/Rsync) 进行)。 -可以通过 `ALTER TABLE ... ATTACH PARTITION ...` 从备份中恢复数据 +ClickHouse 允许使用 `ALTER TABLE ... FREEZE PARTITION ...` 查询创建表分区的本地副本。这是通过对 `/var/lib/clickhouse/shadow/` 文件夹的硬链接来实现的,因此通常不会占用额外的磁盘空间。创建的文件副本不受 ClickHouse 服务器的管理,因此你可以把它们留在那里:你将拥有一个不需要任何其他外部系统的简单备份,但仍然会面临硬件问题。因此,将其远程复制到其他位置然后删除本地副本更好。分布式文件系统和对象存储仍然是很好的选择,但具有足够容量的普通附加文件服务器也可能有效(在这种情况下,传输将通过网络文件系统或可能通过 [rsync](https://en.wikipedia.org/wiki/Rsync) 进行)。 +数据可以通过 `ALTER TABLE ... ATTACH PARTITION ...` 从备份中恢复。 -有关与分区操作相关的查询的更多信息,请参见 [ALTER 文档](/sql-reference/statements/alter/partition)。 +有关与分区操作相关的查询的更多信息,请参阅 [ALTER 文档](/sql-reference/statements/alter/partition)。 -有一个第三方工具可用于自动化此方法:[clickhouse-backup](https://github.com/AlexAkulov/clickhouse-backup)。 +有一个第三方工具可以自动化此方法:[clickhouse-backup](https://github.com/AlexAkulov/clickhouse-backup)。 -## 设置以禁止并发备份/恢复 {#settings-to-disallow-concurrent-backuprestore} +## 禁止并发备份/恢复的设置 {#settings-to-disallow-concurrent-backuprestore} 要禁止并发备份/恢复,可以分别使用以下设置。 @@ -478,19 +479,19 @@ ClickHouse 允许使用 `ALTER TABLE ... FREEZE PARTITION ...` 查询创建表 ``` -默认情况下,这两个的值为 true,因此默认允许并发备份/恢复。 -当这些设置在集群上为false时,同一时间,仅允许在集群上运行1个备份/恢复。 +两者的默认值均为 true,因此默认情况下允许并发备份/恢复。 +当这些设置在集群上为 false 时,集群上仅允许运行 1 个备份/恢复操作。 ## 配置备份/恢复以使用 AzureBlobStorage 端点 {#configuring-backuprestore-to-use-an-azureblobstorage-endpoint} -要将备份写入 AzureBlobStorage 容器,你需要以下信息: -- AzureBlobStorage 端点连接字符串 / URL, +要将备份写入 AzureBlobStorage 容器,您需要以下信息: +- AzureBlobStorage 端点连接字符串/网址, - 容器, - 路径, -- 账户名称(如果指定 URL) -- 账户密钥(如果指定 URL) +- 账户名称(如果指定了网址) +- 账户密钥(如果指定了网址) -备份的目标将如下指定: +备份的目标将像这样指定: ```sql AzureBlobStorage('/', '', '', '', '') @@ -505,16 +506,16 @@ RESTORE TABLE data AS data_restored FROM AzureBlobStorage('DefaultEndpointsProto ## 备份系统表 {#backup-up-system-tables} -系统表也可以包含在你的备份和恢复工作流中,但其包含取决于具体用例。 +系统表也可以包含在你的备份和恢复工作流中,但它们的包含取决于你的特定用例。 ### 备份日志表 {#backing-up-log-tables} -存储历史数据的系统表,例如带有 _log 后缀的那些(例如,`query_log`、`part_log`),可以像任何其他表一样备份和恢复。如果你的用例依赖于分析历史数据,例如,使用 query_log 跟踪查询性能或调试问题,建议在备份策略中包括这些表。然而,如果不需要这些表的历史数据,可以排除它们以节省备份存储空间。 +存储历史数据的系统表,例如后缀为 _log 的表(如 `query_log`、`part_log`),可以像任何其他表一样进行备份和恢复。如果你的用例依赖于分析历史数据——例如,使用 query_log 跟踪查询性能或调试问题——建议将这些表包含在你的备份策略中。然而,如果不需要这些表的历史数据,则可以将其排除以节省备份存储空间。 ### 备份访问管理表 {#backing-up-access-management-tables} -与访问管理相关的系统表,如用户、角色、行策略、设置配置文件和配额,在备份和恢复操作中会受到特别处理。当这些表包含在备份中时,它们的内容会导出到一个特殊的 `accessXX.txt` 文件中,该文件封装了创建和配置访问实体的等效 SQL 语句。在恢复时,恢复过程会解释这些文件并重新应用 SQL 命令以重建用户、角色和其他配置。 +与访问管理相关的系统表,例如用户、角色、行策略、设置配置文件和配额,在备份和恢复操作期间会得到特殊处理。当这些表包含在备份中时,其内容将导出到一个特殊的 `accessXX.txt` 文件中,封装了创建和配置访问实体所需的等效 SQL 语句。在恢复时,恢复过程将解释这些文件,并重新应用 SQL 命令以重新创建用户、角色和其他配置。 此功能确保 ClickHouse 集群的访问控制配置可以作为集群整体设置的一部分进行备份和恢复。 -注意:此功能仅适用于通过 SQL 命令管理的配置(称为 ["SQL驱动的访问控制和帐户管理"](/operations/access-rights#enabling-access-control))。在 ClickHouse 服务器配置文件中定义的访问配置(例如 `users.xml`)不包括在备份中,并且无法通过此方法恢复。 +注意:此功能仅适用于通过 SQL 命令管理的配置(称为 ["SQL驱动的访问控制和账户管理"](/operations/access-rights#enabling-access-control))。在 ClickHouse 服务器配置文件中定义的访问配置(例如 `users.xml`)不包括在备份中,且无法通过此方法恢复。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/backup.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/backup.md.hash index 83c2ba2d991..e48e7126e22 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/backup.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/backup.md.hash @@ -1 +1 @@ -414cdf91f5ec93d0 +af5e7413226755c2 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/caches.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/caches.md index be01ec0fa67..070ae285ba5 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/caches.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/caches.md @@ -1,35 +1,38 @@ --- -'description': '在执行查询时,ClickHouse使用不同的缓存。' -'sidebar_label': 'Caches' +'description': '在执行查询时,ClickHouse 使用不同的缓存。' +'sidebar_label': '缓存' 'sidebar_position': 65 'slug': '/operations/caches' 'title': '缓存类型' +'keywords': +- 'cache' +'doc_type': 'reference' --- # 缓存类型 -在执行查询时,ClickHouse 使用不同的缓存。 +在执行查询时,ClickHouse 使用不同的缓存来加速查询并减少对磁盘的读写需求。 -主要缓存类型: +主要的缓存类型有: -- `mark_cache` — 用于 [MergeTree](../engines/table-engines/mergetree-family/mergetree.md) 家族的表引擎所使用的标记缓存。 -- `uncompressed_cache` — 用于 [MergeTree](../engines/table-engines/mergetree-family/mergetree.md) 家族的表引擎所使用的未压缩数据缓存。 -- 操作系统页面缓存(间接使用,用于实际数据的文件)。 +- `mark_cache` — [`MergeTree`](../engines/table-engines/mergetree-family/mergetree.md) 家族的表引擎使用的 [marks](/development/architecture#merge-tree) 缓存。 +- `uncompressed_cache` — [`MergeTree`](../engines/table-engines/mergetree-family/mergetree.md) 家族的表引擎使用的未压缩数据缓存。 +- 操作系统页面缓存(间接使用,用于实际数据文件)。 -其他缓存类型: +还有一系列其他缓存类型: - DNS 缓存。 -- [正则表达式](../interfaces/formats.md#data-format-regexp) 缓存。 +- [Regexp](../interfaces/formats.md#data-format-regexp) 缓存。 - 编译表达式缓存。 -- [向量相似度索引](../engines/table-engines/mergetree-family/annindexes.md) 缓存。 -- [Avro 格式](../interfaces/formats.md#data-format-avro) 模式缓存。 -- [字典](../sql-reference/dictionaries/index.md) 数据缓存。 +- [Vector similarity index](../engines/table-engines/mergetree-family/annindexes.md) 缓存。 +- [Avro format](../interfaces/formats.md#data-format-avro) 模式缓存。 +- [Dictionaries](../sql-reference/dictionaries/index.md) 数据缓存。 - 模式推断缓存。 -- 针对 S3、Azure、本地及其他磁盘的 [文件系统缓存](storing-data.md)。 -- [用户空间页面缓存](/operations/userspace-page-cache) -- [查询缓存](query-cache.md)。 -- [查询条件缓存](query-condition-cache.md)。 +- [Filesystem cache](storing-data.md) 通过 S3、Azure、Local 和其他磁盘。 +- [Userspace page cache](/operations/userspace-page-cache) +- [Query cache](query-cache.md)。 +- [Query condition cache](query-condition-cache.md)。 - 格式模式缓存。 -要删除其中一个缓存,请使用 [SYSTEM DROP ... CACHE](../sql-reference/statements/system.md) 语句。 +如果您希望出于性能调整、故障排除或数据一致性原因来删除其中一个缓存,可以使用 [`SYSTEM DROP ... CACHE`](../sql-reference/statements/system.md) 语句。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/caches.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/caches.md.hash index 23323631e5f..3c00086718e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/caches.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/caches.md.hash @@ -1 +1 @@ -4203ef32be81436a +39efd11db8e145ef diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/cluster-discovery.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/cluster-discovery.md index 1eee8e606c5..7c43df82787 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/cluster-discovery.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/cluster-discovery.md @@ -1,8 +1,9 @@ --- -'description': 'Documentation for cluster discovery in ClickHouse' +'description': 'ClickHouse 中集群发现的 Documentation' 'sidebar_label': '集群发现' 'slug': '/operations/cluster-discovery' 'title': '集群发现' +'doc_type': 'guide' --- @@ -10,12 +11,12 @@ ## 概述 {#overview} -ClickHouse 的集群发现功能通过允许节点自动发现并注册自己,简化了集群配置,而无需在配置文件中进行明确的定义。这在手动定义每个节点变得繁琐的情况下尤其有益。 +ClickHouse 的集群发现功能通过允许节点自动发现并注册自己,简化了集群配置,而无需在配置文件中显式定义。这在手动定义每个节点变得繁琐的情况下特别有用。 :::note -集群发现是一个实验性功能,未来版本可能会更改或删除。 -要启用此功能,请在配置文件中包含 `allow_experimental_cluster_discovery` 设置: +集群发现是一个实验性功能,可能会在未来版本中更改或删除。 +要启用它,请在配置文件中包含 `allow_experimental_cluster_discovery` 设置: ```xml @@ -30,7 +31,7 @@ ClickHouse 的集群发现功能通过允许节点自动发现并注册自己, ### 传统手动配置 {#traditional-manual-configuration} -在 ClickHouse 中,传统上需要手动在配置中指定每个分片和副本: +在 ClickHouse 中,传统上需要手动在配置中指定集群中的每个分片和副本: ```xml @@ -62,7 +63,7 @@ ClickHouse 的集群发现功能通过允许节点自动发现并注册自己, ### 使用集群发现 {#using-cluster-discovery} -使用集群发现,而不是明确地定义每个节点,您只需在 ZooKeeper 中指定一个路径。在该路径下注册的所有节点将会被自动发现并添加到集群中。 +通过集群发现,你只需在 ZooKeeper 中指定一个路径,而无需显式定义每个节点。所有在 ZooKeeper 中该路径下注册的节点将被自动发现并添加到集群中。 ```xml @@ -88,7 +89,7 @@ ClickHouse 的集群发现功能通过允许节点自动发现并注册自己, ``` -如果您想为特定节点指定一个分片编号,可以在 `` 部分中包含 `` 标签: +如果你想为特定节点指定一个分片号,可以在 `` 部分中包含 `` 标签: 对于 `node1` 和 `node2`: @@ -110,8 +111,8 @@ ClickHouse 的集群发现功能通过允许节点自动发现并注册自己, ### 观察者模式 {#observer-mode} -配置为观察者模式的节点不会将自己注册为副本。 -它们仅会观察并发现集群中其他活动的副本,而不会主动参与。 +在观察者模式下配置的节点不会将自己注册为副本。 +它们将仅观察并发现集群中其他活动的副本,而不积极参与。 要启用观察者模式,请在 `` 部分中包含 `` 标签: ```xml @@ -123,7 +124,7 @@ ClickHouse 的集群发现功能通过允许节点自动发现并注册自己, ### 集群发现 {#discovery-of-clusters} -有时,您可能需要添加和移除的不仅仅是集群中的主机,而是集群本身。您可以使用 `` 节点来为多个集群指定根路径: +有时你可能需要添加和删除的不仅仅是集群中的主机,还有集群本身。你可以使用 `` 节点和多个集群的根路径: ```xml @@ -138,7 +139,7 @@ ClickHouse 的集群发现功能通过允许节点自动发现并注册自己, 在这种情况下,当其他主机使用路径 `/clickhouse/discovery/some_new_cluster` 注册时,将添加一个名为 `some_new_cluster` 的集群。 -您可以同时使用这两种功能,主机可以在集群 `my_cluster` 中注册自己,同时发现其他集群: +你可以同时使用这两个功能,主机可以在集群 `my_cluster` 中注册自己并发现其他任何集群: ```xml @@ -157,17 +158,17 @@ ClickHouse 的集群发现功能通过允许节点自动发现并注册自己, ``` 限制: -- 您不能在同一个 `remote_servers` 子树中同时使用 `` 和 ``。 +- 你不能在同一 `remote_servers` 子树中同时使用 `` 和 ``。 - `` 只能与 `` 一起使用。 -- Keeper 中路径的最后部分被用作集群名称,而在注册时名称是从 XML 标签中获取的。 +- Keeper 的路径最后一部分用作集群名称,而注册时名称是从 XML 标签中获取的。 ## 用例和限制 {#use-cases-and-limitations} -当节点从指定的 ZooKeeper 路径添加或移除时,它们会自动被发现或从集群中移除,而无需进行配置更改或服务器重启。 +随着节点从指定的 ZooKeeper 路径添加或删除,它们会被自动发现或从集群中删除,而无需进行配置更改或服务器重启。 -然而,变化仅影响集群配置,不影响数据或现有的数据库和表。 +然而,变化只影响集群配置,而不影响数据或现有的数据库和表。 -考虑以下三个节点的集群示例: +考虑以下一个由 3 个节点组成的集群示例: ```xml @@ -198,7 +199,7 @@ ORDER BY event_time PARTITION BY toYYYYMM(event_time); INSERT INTO event_table ... ``` -然后,我们通过在配置文件的 `remote_servers` 部分中使用相同的条目,向集群添加一个新节点,启动一个新节点: +然后,我们向集群添加一个新节点,启动一个在配置文件中与 `remote_servers` 部分相同项的新节点: ```response ┌─cluster─┬─shard_num─┬─shard_weight─┬─replica_num─┬─host_name────┬─host_address─┬─port─┬─is_local─┬─user─┬─is_active─┐ @@ -209,7 +210,7 @@ INSERT INTO event_table ... └─────────┴───────────┴──────────────┴─────────────┴──────────────┴──────────────┴──────┴──────────┴──────┴───────────┘ ``` -第四个节点参与集群,但表 `event_table` 仍然只存在于前三个节点上: +第四个节点参与了集群,但表 `event_table` 仍然只存在于前三个节点上: ```sql SELECT hostname(), database, table FROM clusterAllReplicas(default, system.tables) WHERE table = 'event_table' FORMAT PrettyCompactMonoBlock @@ -221,4 +222,4 @@ SELECT hostname(), database, table FROM clusterAllReplicas(default, system.table └──────────────┴──────────┴─────────────┘ ``` -如果您需要在所有节点上复制表,可以使用 [Replicated](../engines/database-engines/replicated.md) 数据库引擎作为集群发现的替代方案。 +如果你需要在所有节点上复制表,可以使用 [Replicated](../engines/database-engines/replicated.md) 数据库引擎替代集群发现。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/cluster-discovery.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/cluster-discovery.md.hash index 32f225c1fb8..f2cf50ba90d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/cluster-discovery.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/cluster-discovery.md.hash @@ -1 +1 @@ -562abb5137cf3095 +b03ea3bcbbc8039f diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/configuration-files.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/configuration-files.md index 10bca863451..579a69a1efc 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/configuration-files.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/configuration-files.md @@ -4,40 +4,40 @@ 'sidebar_position': 50 'slug': '/operations/configuration-files' 'title': '配置文件' +'doc_type': 'guide' --- :::note -请注意,基于 XML 的设置配置文件和配置文件目前不支持 ClickHouse Cloud。因此,在 ClickHouse Cloud 中,您不会找到 config.xml 文件。相反,您应该使用 SQL 命令通过设置配置文件来管理设置。 +基于XML的设置文件和配置文件不支持ClickHouse Cloud。因此,在ClickHouse Cloud中,您不会找到config.xml文件。相反,您应该使用SQL命令通过设置文件来管理设置。 -有关详细信息,请参见 ["配置设置"](/manage/settings) +有关更多详细信息,请参见["配置设置"](/manage/settings) ::: -ClickHouse 服务器可以使用 XML 或 YAML 语法的配置文件进行配置。 -在大多数安装类型中,ClickHouse 服务器以 `/etc/clickhouse-server/config.xml` 作为默认配置文件运行,但也可以在服务器启动时使用命令行选项 `--config-file` 或 `-C` 手动指定配置文件的位置。 -附加配置文件可以相对于主配置文件放置在 `config.d/` 目录中,例如放置在 `/etc/clickhouse-server/config.d/` 目录中。 -在配置应用于 ClickHouse 服务器之前,该目录中的文件与主配置文件在预处理步骤中合并。 -配置文件按照字母顺序合并。 -为了简化更新和改善模块化,最佳实践是保持默认的 `config.xml` 文件不变,并将额外的自定义放置在 `config.d/` 中。 -ClickHouse keeper 的配置位于 `/etc/clickhouse-keeper/keeper_config.xml`。 -因此,附加文件需要放置在 `/etc/clickhouse-keeper/keeper_config.d/` 中。 +ClickHouse服务器可以使用XML或YAML语法的配置文件进行配置。 +在大多数安装类型中,ClickHouse服务器默认使用`/etc/clickhouse-server/config.xml`作为配置文件,但也可以在服务器启动时使用命令行选项`--config-file`或`-C`手动指定配置文件的位置。 +额外的配置文件可以放置在相对于主配置文件的`config.d/`目录中,例如放在`/etc/clickhouse-server/config.d/`目录中。 +该目录中的文件与主配置在配置应用到ClickHouse服务器之前的预处理步骤中合并。 +配置文件按字母顺序合并。 +为了简化更新并改善模块化,最佳实践是保持默认`config.xml`文件不被修改,并将额外的自定义放入`config.d/`中。 +ClickHouse keeper的配置位于`/etc/clickhouse-keeper/keeper_config.xml`。 +类似地,Keeper的额外配置文件需要放置在`/etc/clickhouse-keeper/keeper_config.d/`中。 -可以混合使用 XML 和 YAML 配置文件,例如,您可以拥有主配置文件 `config.xml` 和附加配置文件 `config.d/network.xml`、`config.d/timezone.yaml` 和 `config.d/keeper.yaml`。 -在单个配置文件中混合 XML 和 YAML 是不支持的。 -XML 配置文件应使用 `...` 作为顶级标签。 -在 YAML 配置文件中,`clickhouse:` 是可选的,如果缺少,解析器会自动插入。 +可以混合使用XML和YAML配置文件,例如,您可以有一个主配置文件`config.xml`和额外的配置文件`config.d/network.xml`、`config.d/timezone.yaml`和`config.d/keeper.yaml`。 +不支持在单个配置文件中混合XML和YAML。 +XML配置文件应使用`...`作为顶部标签。 +在YAML配置文件中,`clickhouse:`是可选的,如果缺失,解析器会自动插入。 ## 合并配置 {#merging} -两个配置文件(通常是主配置文件和来自 `config.d/` 的另一个配置文件)合并的方式如下: +两个配置文件(通常是主配置文件和`config.d/`中的另一个配置文件)按如下方式合并: -- 如果节点(即通向元素的路径)在两个文件中都出现且没有属性 `replace` 或 `remove`,则它包含在合并的配置文件中,并包含并递归合并两个节点的子节点。 -- 如果两个节点中的一个包含属性 `replace`,则它包含在合并的配置文件中,但仅包含具有属性 `replace` 的节点的子节点。 -- 如果两个节点中的一个包含属性 `remove`,则该节点不包含在合并的配置文件中(如果已存在,则将其删除)。 +- 如果某个节点(即通往某个元素的路径)在两个文件中都存在且没有属性`replace`或`remove`,则它将包含在合并的配置文件中,并且两个节点的子节点将被递归地包含和合并。 +- 如果两个节点中的一个包含`replace`属性,则它将包含在合并的配置文件中,但只包含具有`replace`属性的节点的子节点。 +- 如果两个节点中的一个包含`remove`属性,则该节点不会包含在合并的配置文件中(如果已经存在,则将其删除)。 -示例: +例如,给定两个配置文件: -```xml - +```xml title="config.xml" 1 @@ -53,8 +53,7 @@ XML 配置文件应使用 `...` 作为顶级标签。 和 -```xml - +```xml title="config.d/other_config.xml" 4 @@ -68,7 +67,7 @@ XML 配置文件应使用 `...` 作为顶级标签。 ``` -生成合并的配置文件: +合并后的配置文件将是: ```xml @@ -82,11 +81,11 @@ XML 配置文件应使用 `...` 作为顶级标签。 ``` -### 通过环境变量和 ZooKeeper 节点的替换 {#from_env_zk} +### 通过环境变量和ZooKeeper节点的替换 {#from_env_zk} -要指定元素的值应由环境变量的值替换,可以使用属性 `from_env`。 +要指定元素的值应被环境变量的值替换,可以使用属性`from_env`。 -示例,假设 `$MAX_QUERY_SIZE = 150000`: +例如,环境变量`$MAX_QUERY_SIZE = 150000`: ```xml @@ -98,7 +97,7 @@ XML 配置文件应使用 `...` 作为顶级标签。 ``` -这等于 +合并后的配置将是: ```xml @@ -110,7 +109,7 @@ XML 配置文件应使用 `...` 作为顶级标签。 ``` -使用 `from_zk`(ZooKeeper 节点)也是可能的: +使用`from_zk`(ZooKeeper节点)也可以实现相同的效果: ```xml @@ -127,7 +126,7 @@ XML 配置文件应使用 `...` 作为顶级标签。 9005 ``` -这等于 +合并后的配置如下: ```xml @@ -137,11 +136,11 @@ XML 配置文件应使用 `...` 作为顶级标签。 #### 默认值 {#default-values} -带有 `from_env` 或 `from_zk` 属性的元素可以额外具有属性 `replace="1"`(后者必须出现在 `from_env`/`from_zk` 之前)。 +带有`from_env`或`from_zk`属性的元素可以额外具有属性`replace="1"`(后者必须出现在`from_env`/`from_zk`之前)。 在这种情况下,元素可以定义一个默认值。 -如果设置,元素将采用环境变量或 ZooKeeper 节点的值,否则采用默认值。 +如果设置了,元素将采用环境变量或ZooKeeper节点的值,否则将采用默认值。 -前面的示例但假设 `MAX_QUERY_SIZE` 未设置: +重复之前的示例,但假设`MAX_QUERY_SIZE`未设定: ```xml @@ -153,7 +152,7 @@ XML 配置文件应使用 `...` 作为顶级标签。 ``` -结果: +合并后的配置: ```xml @@ -167,13 +166,12 @@ XML 配置文件应使用 `...` 作为顶级标签。 ## 使用文件内容进行替换 {#substitution-with-file-content} -还可以通过文件内容替换配置的部分。可以通过两种方式完成: - -- *值替换*:如果元素具有属性 `incl`,其值将被引用文件的内容替换。默认情况下,含有替换内容的文件路径为 `/etc/metrika.xml`。可以在服务器配置中的 [include_from](../operations/server-configuration-parameters/settings.md#include_from) 元素中更改。替代值在此文件中的 `/clickhouse/substitution_name` 元素中指定。如果在 `incl` 中指定的替代不存在,将记录在日志中。为了防止 ClickHouse 记录缺失的替代,请指定属性 `optional="true"`(例如,设置 [宏](../operations/server-configuration-parameters/settings.md#macros))。 +也可以通过文件内容替换配置的部分。这可以通过两种方式实现: -- *替换元素*:如果您想用替代替换整个元素,请使用 `include` 作为元素名称。元素名称 `include` 可以与属性 `from_zk = "/path/to/node"` 结合使用。在这种情况下,该元素的值将由 `/path/to/node` 的 ZooKeeper 节点的内容替换。如果您将整个 XML 子树存储为 ZooKeeper 节点,它将完全插入到源元素中。 +- *替换值*:如果某个元素具有属性`incl`,则其值将被引用文件的内容替换。默认情况下,替换的文件路径为`/etc/metrika.xml`。可以在服务器配置中的[`include_from`](../operations/server-configuration-parameters/settings.md#include_from)元素中更改此路径。替换值在这个文件的`/clickhouse/substitution_name`元素中指定。如果`incl`中指定的替换不存在,则会记录在日志中。要阻止ClickHouse记录缺失的替换,请指定属性`optional="true"`(例如,设置[宏](../operations/server-configuration-parameters/settings.md#macros))。 +- *替换元素*:如果要用替换替换整个元素,请使用`include`作为元素名称。元素名称`include`可以与属性`from_zk="/path/to/node"`结合使用。在这种情况下,元素的值由`/path/to/node`的ZooKeeper节点的内容替换。如果您将整个XML子树存储为ZooKeeper节点,它将完全插入到源元素中。 -示例: +下面是此示例的显示: ```xml @@ -188,17 +186,17 @@ XML 配置文件应使用 `...` 作为顶级标签。 ``` -如果您希望合并替代内容与现有配置,而不是追加,可以使用属性 `merge="true"`,例如:``。在这种情况下,现有配置将与替代内容合并,现有的配置设置将被替代值替换。 +如果您想将替换内容与现有配置合并而不是追加,可以使用属性`merge="true"`。例如:``。在这种情况下,现有配置将与替换中的内容合并,并且现有的配置设置将被替换中的值替代。 ## 加密和隐藏配置 {#encryption} -您可以使用对称加密来加密配置元素,例如,明文密码或私钥。 -为此,首先配置 [加密编码器](../sql-reference/statements/create/table.md#encryption-codecs),然后将属性 `encrypted_by` 及其值设置为要加密的元素的加密编码器的名称。 +您可以使用对称加密来加密配置元素,例如明文密码或私钥。 +为此,首先配置[加密编解码器](../sql-reference/statements/create/table.md#encryption-codecs),然后为要加密的元素添加属性`encrypted_by`,其值为加密编解码器的名称。 -与属性 `from_zk`、`from_env` 和 `incl`,或元素 `include` 不同,预处理文件中不执行替换(即对加密值的解密)。 -解密仅在服务器进程运行时发生。 +与属性`from_zk`、`from_env`和`incl`或元素`include`不同,在预处理文件中不执行替换(即解密加密值)。 +解密仅在服务器进程的运行时发生。 -示例: +例如: ```xml @@ -217,7 +215,8 @@ XML 配置文件应使用 `...` 作为顶级标签。 ``` -属性 [from_env](#from_env_zk) 和 [from_zk](#from_env_zk) 也可以适用于 ```encryption_codecs```: +属性[`from_env`](#from_env_zk)和[`from_zk`](#from_env_zk)也可以应用于`encryption_codecs`: + ```xml @@ -252,9 +251,9 @@ XML 配置文件应使用 `...` 作为顶级标签。 ``` -加密密钥和加密值可以在任意配置文件中定义。 +加密密钥和加密值可以在任何配置文件中定义。 -示例 `config.xml`: +给出的示例`config.xml`如下: ```xml @@ -268,7 +267,7 @@ XML 配置文件应使用 `...` 作为顶级标签。 ``` -示例 `users.xml`: +给出的示例`users.xml`如下: ```xml @@ -283,9 +282,7 @@ XML 配置文件应使用 `...` 作为顶级标签。 ``` -要加密一个值,您可以使用(示例)程序 `encrypt_decrypt`: - -示例: +要加密一个值,您可以使用(示例)程序`encrypt_decrypt`: ```bash ./encrypt_decrypt /etc/clickhouse-server/config.xml -e AES_128_GCM_SIV abcd @@ -295,10 +292,10 @@ XML 配置文件应使用 `...` 作为顶级标签。 961F000000040000000000EEDDEF4F453CFE6457C4234BD7C09258BD651D85 ``` -即使是加密的配置元素,已加密的元素仍然出现在预处理的配置文件中。 -如果这对您的 ClickHouse 部署造成问题,我们建议两个替代方案:将预处理文件的文件权限设置为 600 或使用属性 `hide_in_preprocessed`。 +即使有加密的配置元素,加密的元素仍然会出现在预处理的配置文件中。 +如果这对您的ClickHouse部署构成问题,则有两种替代方案:要么将预处理文件的文件权限设置为600,要么使用属性`hide_in_preprocessed`。 -示例: +例如: ```xml @@ -313,17 +310,17 @@ XML 配置文件应使用 `...` 作为顶级标签。 ## 用户设置 {#user-settings} -`config.xml` 文件可以指定一个包含用户设置、配置文件和配额的单独配置。到此配置的相对路径在 `users_config` 元素中设置。默认情况下,它是 `users.xml`。如果省略 `users_config`,则用户设置、配置文件和配额直接在 `config.xml` 中指定。 +`config.xml`文件可以指定带有用户设置、配置文件和配额的单独配置。此配置的相对路径在`users_config`元素中设置。默认情况下,设置为`users.xml`。如果省略`users_config`,则用户设置、配置文件和配额直接在`config.xml`中指定。 -用户配置可以拆分为类似 `config.xml` 和 `config.d/` 的单独文件。 -目录名称被定义为 `users_config` 设置,后面不带 `.xml` 后缀并连接 `.d`。 -目录 `users.d` 是默认使用的,因为 `users_config` 默认为 `users.xml`。 +用户配置可以分成类似于`config.xml`和`config.d/`的单独文件。 +目录名称被定义为`users_config`设置,后接`.d`而不是`.xml`后缀。 +默认使用目录`users.d`,因为`users_config`默认为`users.xml`。 -请注意,配置文件首先 [合并](#merging),考虑到设置,并在那之后处理包含。 +请注意,配置文件将首先根据设置进行[合并](#merging),然后再处理包含。 -## XML 示例 {#example} +## XML示例 {#example} -例如,您可以为每个用户拥有单独的配置文件,如下所示: +例如,您可以为每个用户有一个单独的配置文件,如下所示: ```bash $ cat /etc/clickhouse-server/users.d/alice.xml @@ -344,23 +341,27 @@ $ cat /etc/clickhouse-server/users.d/alice.xml ``` -## YAML 示例 {#example-1} +## YAML示例 {#example-1} -在这里,您可以看到以 YAML 格式编写的默认配置:[config.yaml.example](https://github.com/ClickHouse/ClickHouse/blob/master/programs/server/config.yaml.example)。 +在这里,您可以看到YAML格式编写的默认配置:[`config.yaml.example`](https://github.com/ClickHouse/ClickHouse/blob/master/programs/server/config.yaml.example)。 -在 YAML 和 XML 格式的 ClickHouse 配置之间存在一些差异。以下是以 YAML 格式编写配置的一些提示。 +在ClickHouse配置方面,YAML和XML格式之间存在一些差异。 +下面提供了以YAML格式编写配置的提示。 + +具有文本值的XML标签用YAML键值对表示 -具有文本值的 XML 标签在 YAML 中表示为键值对: ```yaml key: value ``` -对应的 XML: +相应的XML: + ```xml value ``` -嵌套的 XML 节点在 YAML 中表示为映射: +嵌套的XML节点用YAML映射表示: + ```yaml map_key: key1: val1 @@ -368,7 +369,8 @@ map_key: key3: val3 ``` -对应的 XML: +相应的XML: + ```xml val1 @@ -377,7 +379,8 @@ map_key: ``` -要多次创建相同的 XML 标签,请使用 YAML 序列: +要多次创建相同的XML标签,可以使用YAML序列: + ```yaml seq_key: - val1 @@ -388,7 +391,8 @@ seq_key: key3: val5 ``` -对应的 XML: +相应的XML: + ```xml val1 val2 @@ -403,7 +407,8 @@ seq_key: ``` -要提供 XML 属性,您可以使用带有 `@` 前缀的属性键。请注意,`@` 是 YAML 标准保留的,因此必须用双引号括起来: +要提供XML属性,您可以使用带有`@`前缀的属性键。请注意,`@`是YAML标准保留的,因此必须用双引号括起来: + ```yaml map: "@attr1": value1 @@ -411,14 +416,16 @@ map: key: 123 ``` -对应的 XML: +相应的XML: + ```xml 123 ``` -在 YAML 序列中也可以使用属性: +在YAML序列中也可以使用属性: + ```yaml seq: - "@attr1": value1 @@ -427,26 +434,29 @@ seq: - abc ``` -对应的 XML: +相应的XML: + ```xml 123 abc ``` -上述语法不允许将带有 XML 属性的 XML 文本节点表示为 YAML。这个特殊情况可以使用 `#text` 属性键实现: +上述语法不允许以YAML的形式表示具有XML属性的XML文本节点。这种特殊情况可以使用`#text`属性键来实现: + ```yaml map_key: "@attr1": value1 "#text": value2 ``` -对应的 XML: +相应的XML: + ```xml value2 ``` ## 实现细节 {#implementation-details} -对于每个配置文件,服务器在启动时还会生成 `file-preprocessed.xml` 文件。这些文件包含所有已完成的替换和覆盖,供参考使用。如果配置文件中使用了 ZooKeeper 替换,但服务器启动时没有可用的 ZooKeeper,服务器将从预处理文件加载配置。 +对于每个配置文件,服务器启动时还会生成`file-preprocessed.xml`文件。这些文件包含所有已完成的替换和重写,供信息使用。如果在配置文件中使用了ZooKeeper替换,但在服务器启动时ZooKeeper不可用,则服务器会从预处理文件加载配置。 -服务器跟踪配置文件中的更改,以及在执行替换和覆盖时使用的文件和 ZooKeeper 节点,并实时重新加载用户和集群的设置。这意味着您可以修改集群、用户及其设置,而无需重新启动服务器。 +服务器跟踪配置文件中的更改,以及在执行替换和重写时使用的文件和ZooKeeper节点,并动态重新加载用户和集群的设置。这意味着您可以在不重启服务器的情况下修改集群、用户及其设置。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/configuration-files.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/configuration-files.md.hash index ce484b51310..cd9bc73bd87 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/configuration-files.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/configuration-files.md.hash @@ -1 +1 @@ -99f70be0d698ed2a +fe3c9e22115a4f6a diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/external-authenticators/http.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/external-authenticators/http.md index 511985ee7fd..68af16bf172 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/external-authenticators/http.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/external-authenticators/http.md @@ -1,18 +1,19 @@ --- -'description': 'Http 的文档' +'description': 'Http的文档' 'slug': '/operations/external-authenticators/http' 'title': 'HTTP' +'doc_type': 'reference' --- import SelfManaged from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_self_managed_only_no_roadmap.md'; -HTTP服务器可以用来验证ClickHouse用户。HTTP认证只能被用作对在 `users.xml` 或本地访问控制路径中定义的现有用户的外部认证器。目前,仅支持使用GET方法的[基本](https://datatracker.ietf.org/doc/html/rfc7617)认证方案。 +HTTP 服务器可用于认证 ClickHouse 用户。HTTP 认证只能作为现有用户的外部认证器,这些用户在 `users.xml` 或本地访问控制路径中定义。当前支持使用 GET 方法的 [Basic](https://datatracker.ietf.org/doc/html/rfc7617) 认证方案。 -## HTTP认证服务器定义 {#http-auth-server-definition} +## HTTP 认证服务器定义 {#http-auth-server-definition} -要定义HTTP认证服务器,必须在 `config.xml` 中添加 `http_authentication_servers` 部分。 +要定义 HTTP 认证服务器,必须向 `config.xml` 添加 `http_authentication_servers` 部分。 **示例** ```xml @@ -38,32 +39,32 @@ HTTP服务器可以用来验证ClickHouse用户。HTTP认证只能被用作对 ``` -请注意,您可以在 `http_authentication_servers` 部分内定义多个HTTP服务器,使用不同的名称。 +请注意,您可以在 `http_authentication_servers` 部分内使用不同的名称定义多个 HTTP 服务器。 **参数** -- `uri` - 用于进行认证请求的URI +- `uri` - 用于发起认证请求的 URI -在与服务器通信所使用的套接字上的超时(以毫秒为单位): -- `connection_timeout_ms` - 默认: 1000 ms。 -- `receive_timeout_ms` - 默认: 1000 ms。 -- `send_timeout_ms` - 默认: 1000 ms。 +与服务器通信所用套接字的超时(以毫秒为单位): +- `connection_timeout_ms` - 默认:1000 毫秒。 +- `receive_timeout_ms` - 默认:1000 毫秒。 +- `send_timeout_ms` - 默认:1000 毫秒。 重试参数: -- `max_tries` - 进行认证请求的最大尝试次数。默认: 3 -- `retry_initial_backoff_ms` - 重试的初始退避间隔。默认: 50 ms -- `retry_max_backoff_ms` - 最大退避间隔。默认: 1000 ms +- `max_tries` - 发起认证请求的最大尝试次数。默认:3 +- `retry_initial_backoff_ms` - 重试时的初始回退间隔。默认:50 毫秒 +- `retry_max_backoff_ms` - 最大回退间隔。默认:1000 毫秒 转发头: -该部分定义了哪些头将从客户端请求头转发到外部HTTP认证器。 +该部分定义哪些头部将从客户端请求头转发到外部 HTTP 认证器。请注意,头部将在不区分大小写的情况下与配置的头部进行匹配,但将原样转发,即不加修改。 -### 在 `users.xml` 中启用HTTP认证 {#enabling-http-auth-in-users-xml} +### 在 `users.xml` 中启用 HTTP 认证 {#enabling-http-auth-in-users-xml} -为了启用用户的HTTP认证,指定 `http_authentication` 部分,而不是用户定义中的 `password` 或类似部分。 +为了为用户启用 HTTP 认证,请在用户定义中指定 `http_authentication` 部分,而不是 `password` 或类似的部分。 参数: -- `server` - 在主 `config.xml` 文件中配置的HTTP认证服务器的名称,如前所述。 -- `scheme` - HTTP认证方案。目前仅支持 `Basic`。默认: Basic +- `server` - 在主 `config.xml` 文件中配置的 HTTP 认证服务器的名称,如上所述。 +- `scheme` - HTTP 认证方案。目前仅支持 `Basic`。默认:Basic 示例(放入 `users.xml` 中): ```xml @@ -80,18 +81,18 @@ HTTP服务器可以用来验证ClickHouse用户。HTTP认证只能被用作对 ``` :::note -请注意,HTTP认证不能与任何其他认证机制一起使用。与 `http_authentication` 共同存在的任何其他部分,例如 `password`,将迫使ClickHouse关闭。 +请注意,HTTP 认证不能与任何其他认证机制一起使用。如果存在 `password` 等其他部分与 `http_authentication` 同时出现,会导致 ClickHouse 关闭。 ::: -### 使用SQL启用HTTP认证 {#enabling-http-auth-using-sql} +### 使用 SQL 启用 HTTP 认证 {#enabling-http-auth-using-sql} -当ClickHouse中启用[SQL驱动的访问控制和账户管理](/operations/access-rights#access-control-usage)时,通过HTTP认证识别的用户也可以使用SQL语句创建。 +当在 ClickHouse 中启用 [SQL 驱动的访问控制和帐户管理](/operations/access-rights#access-control-usage) 时,也可以使用 SQL 语句创建通过 HTTP 认证识别的用户。 ```sql CREATE USER my_user IDENTIFIED WITH HTTP SERVER 'basic_server' SCHEME 'Basic' ``` -...或者,不显式定义方案时,`Basic` 为默认值 +...或者,`Basic` 是默认值,如果没有明确的方案定义 ```sql CREATE USER my_user IDENTIFIED WITH HTTP SERVER 'basic_server' @@ -99,4 +100,4 @@ CREATE USER my_user IDENTIFIED WITH HTTP SERVER 'basic_server' ### 传递会话设置 {#passing-session-settings} -如果来自HTTP认证服务器的响应体具有JSON格式并包含 `settings` 子对象,ClickHouse将尝试将其键:值对解析为字符串值,并将其设置为已认证用户的当前会话的会话设置。如果解析失败,将忽略来自服务器的响应体。 +如果 HTTP 认证服务器的响应体具有 JSON 格式并包含 `settings` 子对象,ClickHouse 将尝试将其键值对解析为字符串值,并将其设置为经过认证用户当前会话的会话设置。如果解析失败,将忽略来自服务器的响应体。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/external-authenticators/http.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/external-authenticators/http.md.hash index e7398108098..46a806b4a36 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/external-authenticators/http.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/external-authenticators/http.md.hash @@ -1 +1 @@ -4751e24cad5c7de5 +a6690902118478ee diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/external-authenticators/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/external-authenticators/index.md index 889afcbd652..daa7969f018 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/external-authenticators/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/external-authenticators/index.md @@ -1,10 +1,11 @@ --- -'description': '关于 ClickHouse 支持的外部认证方法的概述' +'description': '关于 ClickHouse 支持的外部身份验证方法的概述' 'pagination_next': 'operations/external-authenticators/kerberos' -'sidebar_label': '外部用户认证和目录' +'sidebar_label': '外部用户验证器和目录' 'sidebar_position': 48 'slug': '/operations/external-authenticators/' -'title': '外部用户认证和目录' +'title': '外部用户验证器和目录' +'doc_type': 'reference' --- import SelfManaged from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_self_managed_only_no_roadmap.md'; @@ -13,9 +14,9 @@ import SelfManaged from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_s ClickHouse 支持使用外部服务进行用户身份验证和管理。 -支持以下外部验证器和目录: +支持以下外部身份验证器和目录: -- [LDAP](/operations/external-authenticators/ldap#ldap-external-authenticator) [验证器](./ldap.md#ldap-external-authenticator) 和 [目录](./ldap.md#ldap-external-user-directory) -- Kerberos [验证器](/operations/external-authenticators/kerberos#kerberos-as-an-external-authenticator-for-existing-users) +- [LDAP](/operations/external-authenticators/ldap#ldap-external-authenticator) [身份验证器](./ldap.md#ldap-external-authenticator) 和 [目录](./ldap.md#ldap-external-user-directory) +- Kerberos [身份验证器](/operations/external-authenticators/kerberos#kerberos-as-an-external-authenticator-for-existing-users) - [SSL X.509 认证](/operations/external-authenticators/ssl-x509) -- HTTP [验证器](./http.md) +- HTTP [身份验证器](./http.md) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/external-authenticators/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/external-authenticators/index.md.hash index f03d0e48fc7..d320faa3612 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/external-authenticators/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/external-authenticators/index.md.hash @@ -1 +1 @@ -73e851fd199a5fbd +ac7b41974e348175 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/external-authenticators/kerberos.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/external-authenticators/kerberos.md index 6a6bbea4cec..4370045868f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/external-authenticators/kerberos.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/external-authenticators/kerberos.md @@ -1,7 +1,8 @@ --- -'description': '现有且正确配置的 ClickHouse 用户可以通过 Kerberos 身份验证协议进行身份验证。' +'description': '现有并正确配置的 ClickHouse 用户可以通过 Kerberos 认证协议进行身份验证。' 'slug': '/operations/external-authenticators/kerberos' 'title': 'Kerberos' +'doc_type': 'reference' --- import SelfManaged from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_self_managed_only_no_roadmap.md'; @@ -11,28 +12,28 @@ import SelfManaged from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_s -现有的并正确配置的 ClickHouse 用户可以通过 Kerberos 认证协议进行身份验证。 +现有并正确配置的 ClickHouse 用户可以通过 Kerberos 认证协议进行身份验证。 -目前,Kerberos 只能作为现有用户(在 `users.xml` 或本地访问控制路径中定义)的一种外部认证方法。这些用户只能使用 HTTP 请求,并且必须能够使用 GSS-SPNEGO 机制进行身份验证。 +目前,Kerberos 只能用作对在 `users.xml` 中或本地访问控制路径中定义的现有用户的外部验证器。这些用户只能使用 HTTP 请求,并且必须能够使用 GSS-SPNEGO 机制进行身份验证。 -为此,系统中必须配置 Kerberos,并且必须在 ClickHouse 配置中启用。 +对于这种方法,必须在系统中配置 Kerberos,并在 ClickHouse 配置中启用它。 ## 在 ClickHouse 中启用 Kerberos {#enabling-kerberos-in-clickhouse} -要启用 Kerberos,应在 `config.xml` 中包含 `kerberos` 部分。此部分可以包含其他参数。 +要启用 Kerberos,应该在 `config.xml` 中包含 `kerberos` 部分。此部分可以包含附加参数。 -#### 参数: {#parameters} +#### 参数 {#parameters} -- `principal` - 规范的服务主体名称,在接收安全上下文时将被获取和使用。 - - 此参数是可选的,如果省略,将使用默认主体。 +- `principal` - 将在接受安全上下文时获取并使用的标准服务主体名称。 + - 此参数是可选的,如果省略,则将使用默认主体。 -- `realm` - 一个领域,将用于将身份验证限制为只有当发起者的领域与其匹配的请求。 - - 此参数是可选的,如果省略,将不应用额外的领域过滤。 +- `realm` - 用于限制身份验证的领域,仅限于发起者的领域与其匹配的请求。 + - 此参数是可选的,如果省略,则不会应用基于领域的额外过滤。 -- `keytab` - 服务密钥表文件的路径。 - - 此参数是可选的,如果省略,服务密钥表文件的路径必须在 `KRB5_KTNAME` 环境变量中设置。 +- `keytab` - 服务 keytab 文件的路径。 + - 此参数是可选的,如果省略,则必须在 `KRB5_KTNAME` 环境变量中设置服务 keytab 文件的路径。 -示例(放入 `config.xml`): +示例(进入 `config.xml`): ```xml @@ -64,33 +65,33 @@ import SelfManaged from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_s ``` :::note -您只能定义一个 `kerberos` 部分。存在多个 `kerberos` 部分将迫使 ClickHouse 禁用 Kerberos 认证。 +您只能定义一个 `kerberos` 部分。存在多个 `kerberos` 部分将强制 ClickHouse 禁用 Kerberos 认证。 ::: :::note -`principal` 和 `realm` 部分不能同时指定。两个部分同时存在将迫使 ClickHouse 禁用 Kerberos 认证。 +`principal` 和 `realm` 部分不能同时指定。两个部分同时存在将强制 ClickHouse 禁用 Kerberos 认证。 ::: -## Kerberos 作为现有用户的外部认证方法 {#kerberos-as-an-external-authenticator-for-existing-users} +## Kerberos 作为现有用户的外部验证器 {#kerberos-as-an-external-authenticator-for-existing-users} -Kerberos 可以作为验证本地定义用户(在 `users.xml` 或本地访问控制路径中定义的用户)身份的一种方法。目前,**仅**可以通过 HTTP 接口进行 *kerberized* 请求(通过 GSS-SPNEGO 机制)。 +Kerberos 可用作验证本地定义用户身份(在 `users.xml` 中定义的用户或在本地访问控制路径中的用户)的方法。目前,仅通过 HTTP 接口的请求可以进行 *kerberized*(通过 GSS-SPNEGO 机制)。 -Kerberos 主体名称格式通常遵循以下模式: +Kerberos 主体名称格式通常遵循此模式: - *primary/instance@REALM* -其中 */instance* 部分可以出现零次或多次。**发起者的规范主体名称的 *primary* 部分应与用于身份验证的 kerberized 用户名匹配,以使身份验证成功**。 +主体的 */instance* 部分可以出现零次或多次。 **发起者标准主体名称的 *primary* 部分预计与进行身份验证的 kerberized 用户名匹配**。 ### 在 `users.xml` 中启用 Kerberos {#enabling-kerberos-in-users-xml} -要为用户启用 Kerberos 身份验证,请在用户定义中指定 `kerberos` 部分,而不是 `password` 或类似部分。 +为了为用户启用 Kerberos 认证,在用户定义中指定 `kerberos` 部分,而不是 `password` 或类似部分。 参数: -- `realm` - 一个领域,将用于将身份验证限制为只有当发起者的领域与其匹配的请求。 - - 此参数是可选的,如果省略,将不应用额外的领域过滤。 +- `realm` - 将用于限制身份验证的领域,仅限于发起者的领域与其匹配的请求。 + - 此参数是可选的,如果省略,则不会应用基于领域的额外过滤。 -示例(放入 `users.xml`): +示例(进入 `users.xml`): ```xml @@ -108,22 +109,22 @@ Kerberos 主体名称格式通常遵循以下模式: ``` :::note -请注意,Kerberos 身份验证无法与其他任何身份验证机制一起使用。存在其他任何部分(如 `password`)与 `kerberos` 并存将迫使 ClickHouse 关闭。 +请注意,Kerberos 认证不能与任何其他认证机制同时使用。存在诸如 `password` 等任何其他部分与 `kerberos` 共同存在将强制 ClickHouse 关闭。 ::: :::info 提醒 -请注意, 现在,一旦用户 `my_user` 使用 `kerberos`,则必须如前所述在主 `config.xml` 文件中启用 Kerberos。 +请注意,现在,一旦用户 `my_user` 使用 `kerberos`,必须在主 `config.xml` 文件中启用 Kerberos,如前所述。 ::: ### 使用 SQL 启用 Kerberos {#enabling-kerberos-using-sql} -当 ClickHouse 中启用了 [基于 SQL 的访问控制和账户管理](/operations/access-rights#access-control-usage) 时,使用 Kerberos 识别的用户也可以通过 SQL 语句进行创建。 +当在 ClickHouse 中启用 [SQL 驱动的访问控制和帐户管理](/operations/access-rights#access-control-usage) 时,可以使用 SQL 语句创建通过 Kerberos 识别的用户。 ```sql CREATE USER my_user IDENTIFIED WITH kerberos REALM 'EXAMPLE.COM' ``` -...或者,不带领域过滤: +...或者,不进行领域过滤: ```sql CREATE USER my_user IDENTIFIED WITH kerberos diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/external-authenticators/kerberos.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/external-authenticators/kerberos.md.hash index 012b08492d7..c15010aac33 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/external-authenticators/kerberos.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/external-authenticators/kerberos.md.hash @@ -1 +1 @@ -9b831a753e28161f +7be1283afd438d43 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/external-authenticators/ldap.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/external-authenticators/ldap.md index b164758a77d..4d0bafe0298 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/external-authenticators/ldap.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/external-authenticators/ldap.md @@ -2,22 +2,23 @@ 'description': '配置 ClickHouse 的 LDAP 认证指南' 'slug': '/operations/external-authenticators/ldap' 'title': 'LDAP' +'doc_type': 'reference' --- import SelfManaged from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_self_managed_only_no_roadmap.md'; -LDAP 服务器可以用来验证 ClickHouse 用户。有两种不同的方法可以实现这一点: +可以使用 LDAP 服务器来验证 ClickHouse 用户。有两种不同的方法来实现这一点: -- 使用 LDAP 作为现有用户的外部验证器,这些用户定义在 `users.xml` 或本地访问控制路径中。 -- 使用 LDAP 作为外部用户目录,并允许在 LDAP 服务器上存在的本地未定义用户进行身份验证。 +- 使用 LDAP 作为现有用户的外部身份验证者,这些用户在 `users.xml` 或本地访问控制路径中定义。 +- 将 LDAP 作为外部用户目录,并允许在 LDAP 服务器上存在的未在本地定义的用户进行身份验证。 对于这两种方法,必须在 ClickHouse 配置中定义一个内部命名的 LDAP 服务器,以便配置的其他部分可以引用它。 ## LDAP 服务器定义 {#ldap-server-definition} -要定义 LDAP 服务器,您必须在 `config.xml` 中添加 `ldap_servers` 部分。 +要定义 LDAP 服务器,必须在 `config.xml` 中添加 `ldap_servers` 部分。 **示例** @@ -56,44 +57,44 @@ LDAP 服务器可以用来验证 ClickHouse 用户。有两种不同的方法可 ``` -请注意,您可以在 `ldap_servers` 部分中使用不同的名称定义多个 LDAP 服务器。 +请注意,可以在 `ldap_servers` 部分内使用不同的名称定义多个 LDAP 服务器。 **参数** -- `host` — LDAP 服务器的主机名或 IP,此参数是必需的,不能为空。 -- `port` — LDAP 服务器端口,默认为 `636`(如果 `enable_tls` 设置为 `true`),否则为 `389`。 -- `bind_dn` — 用于构造绑定所需 DN 的模板。 - - 结果 DN 将通过在每次身份验证尝试中用实际用户名替换模板中的所有 `{user_name}` 子字符串来构造。 -- `user_dn_detection` — 包含用于检测已绑定用户实际用户 DN 的 LDAP 搜索参数的部分。 - - 这主要用于在服务器为 Active Directory 时的搜索过滤器中的进一步角色映射。结果用户 DN 将在替换 `{user_dn}` 子字符串时使用。默认情况下,用户 DN 被设置为等于绑定 DN,但一旦执行搜索,它将被更新为实际检测到的用户 DN 值。 - - `base_dn` — 用于构造 LDAP 搜索基本 DN 的模板。 - - 结果的 DN 将通过在 LDAP 搜索期间用实际用户名和绑定 DN 替换模板中所有的 `{user_name}` 和 `{bind_dn}` 子字符串来构造。 - - `scope` — LDAP 搜索的范围。 - - 可接受的值为:`base`,`one_level`,`children`,`subtree`(默认)。 - - `search_filter` — 用于构造 LDAP 搜索的搜索过滤器的模板。 - - 结果过滤器将通过在 LDAP 搜索期间用实际用户名、绑定 DN 和基础 DN 替换模板中所有的 `{user_name}`、`{bind_dn}` 和 `{base_dn}` 子字符串来构造。 - - 注意,特殊字符必须在 XML 中正确转义。 -- `verification_cooldown` — 在成功绑定尝试之后的一段时间(以秒为单位),在此时间段内,用户将被视为已成功验证,所有后续请求无需联系 LDAP 服务器。 - - 指定 `0`(默认值)以禁用缓存,并强制每个身份验证请求都联系 LDAP 服务器。 -- `enable_tls` — 触发使用与 LDAP 服务器的安全连接的标志。 - - 对于纯文本的 `ldap://` 协议,请指定 `no`(不推荐)。 - - 对于 SSL/TLS `ldaps://` 协议,请指定 `yes`(推荐,默认)。 - - 对于旧版 StartTLS 协议(纯文本 `ldap://` 协议,升级为 TLS),请指定 `starttls`。 +- `host` — LDAP 服务器主机名或 IP,此参数是必需的,不能留空。 +- `port` — LDAP 服务器端口,如果 `enable_tls` 设置为 `true`,默认为 `636`,否则为 `389`。 +- `bind_dn` — 用于构造绑定的 DN 的模板。 + - 在每次身份验证尝试中,结果的 DN 将通过用实际用户名替换模板中的所有 `{user_name}` 子字符串来构造。 +- `user_dn_detection` — 带有 LDAP 搜索参数的部分,用于检测已绑定用户的实际用户 DN。 + - 这主要用于在服务器为 Active Directory 时进行进一步的角色映射的搜索过滤器。结果用户 DN 将在允许替换 `{user_dn}` 子字符串时使用。默认情况下,用户 DN 设置为等于绑定 DN,但一旦执行搜索,它将被更新为实际检测到的用户 DN 值。 + - `base_dn` — 用于构造 LDAP 搜索的基础 DN 的模板。 + - 结果的 DN 将通过用实际用户名和绑定 DN 替换模板中的所有 `{user_name}` 和 `{bind_dn}` 子字符串来构造。 + - `scope` — LDAP 搜索的范围。 + - 可接受的值有:`base`、`one_level`、`children`、`subtree`(默认)。 + - `search_filter` — 用于构造 LDAP 搜索的搜索过滤器的模板。 + - 结果过滤器将通过用实际用户名、绑定 DN 和基础 DN 替换模板中的所有 `{user_name}`、`{bind_dn}` 和 `{base_dn}` 子字符串来构造。 + - 请注意,特殊字符必须在 XML 中正确转义。 +- `verification_cooldown` — 在成功的绑定尝试后,假定用户在不联系 LDAP 服务器的情况下对所有连续请求成功身份验证的时间段,以秒为单位。 + - 指定 `0`(默认)来禁用缓存,并强制在每个身份验证请求中联系 LDAP 服务器。 +- `enable_tls` — 一个触发使用安全连接到 LDAP 服务器的标志。 + - 对于明文 `ldap://` 协议,请指定 `no`(不推荐)。 + - 对于 SSL/TLS `ldaps://` 协议,请指定 `yes`(推荐,默认)。 + - 对于遗留 StartTLS 协议(明文 `ldap://` 协议,升级到 TLS),请指定 `starttls`。 - `tls_minimum_protocol_version` — SSL/TLS 的最低协议版本。 - - 可接受的值为:`ssl2`,`ssl3`,`tls1.0`,`tls1.1`,`tls1.2`(默认)。 + - 可接受的值有:`ssl2`、`ssl3`、`tls1.0`、`tls1.1`、`tls1.2`(默认)。 - `tls_require_cert` — SSL/TLS 对等证书验证行为。 - - 可接受的值为:`never`,`allow`,`try`,`demand`(默认)。 -- `tls_cert_file` — 证书文件的路径。 -- `tls_key_file` — 证书密钥文件的路径。 -- `tls_ca_cert_file` — CA 证书文件的路径。 + - 可接受的值有:`never`、`allow`、`try`、`demand`(默认)。 +- `tls_cert_file` — 证书文件路径。 +- `tls_key_file` — 证书密钥文件路径。 +- `tls_ca_cert_file` — CA 证书文件路径。 - `tls_ca_cert_dir` — 包含 CA 证书的目录路径。 -- `tls_cipher_suite` — 允许的密码套件(以 OpenSSL 记法表示)。 +- `tls_cipher_suite` — 允许的密码套件(以 OpenSSL 记法)。 -## LDAP 外部验证器 {#ldap-external-authenticator} +## LDAP 外部身份验证器 {#ldap-external-authenticator} -可以使用远程 LDAP 服务器作为对本地定义用户(在 `users.xml` 或本地访问控制路径中定义的用户)验证密码的方法。要实现这一点,请在用户定义的 `password` 或类似部分中指定之前定义的 LDAP 服务器名称。 +可以使用远程 LDAP 服务器作为验证本地定义用户(在 `users.xml` 或本地访问控制路径中定义的用户)密码的一种方法。为此,请在用户定义中指定先前定义的 LDAP 服务器名称,而不是 `password` 或类似部分。 -在每次登录尝试中,ClickHouse 会尝试使用提供的凭据“绑定”到 LDAP 服务器上由 `bind_dn` 参数定义的指定 DN,如果成功,用户将被视为已验证。这通常被称为“简单绑定”方法。 +在每次登录尝试中,ClickHouse 试图使用提供的凭据“绑定”到由 `bind_dn` 参数在 [LDAP 服务器定义](#ldap-server-definition) 中定义的指定 DN,如果成功,则考虑该用户已验证。这通常被称为“简单绑定”方法。 **示例** @@ -112,9 +113,9 @@ LDAP 服务器可以用来验证 ClickHouse 用户。有两种不同的方法可 ``` -请注意,用户 `my_user` 引用 `my_ldap_server`。这个 LDAP 服务器必须如前所述在主要的 `config.xml` 文件中进行配置。 +请注意,用户 `my_user` 指的是 `my_ldap_server`。此 LDAP 服务器必须如前所述在主 `config.xml` 文件中配置。 -当启用 SQL 驱动的 [访问控制和账户管理](/operations/access-rights#access-control-usage) 时,可以使用 [CREATE USER](/sql-reference/statements/create/user) 语句创建通过 LDAP 服务器验证的用户。 +当启用 SQL 驱动的 [访问控制和账户管理](/operations/access-rights#access-control-usage) 时,可以使用 [CREATE USER](/sql-reference/statements/create/user) 语句创建由 LDAP 服务器验证的用户。 查询: @@ -124,13 +125,13 @@ CREATE USER my_user IDENTIFIED WITH ldap SERVER 'my_ldap_server'; ## LDAP 外部用户目录 {#ldap-external-user-directory} -除了本地定义的用户外,远程 LDAP 服务器还可以用作用户定义的来源。要实现这一点,请在 `config.xml` 文件的 `users_directories` 部分中的 `ldap` 部分中指定之前定义的 LDAP 服务器名称(请参见 [LDAP 服务器定义](#ldap-server-definition))。 +除了本地定义的用户外,远程 LDAP 服务器还可以用作用户定义的来源。为此,请在 `config.xml` 文件的 `users_directories` 部分内的 `ldap` 部分中指定先前定义的 LDAP 服务器名称(见 [LDAP 服务器定义](#ldap-server-definition))。 -在每次登录尝试中,ClickHouse 会尝试在本地查找用户定义并按常规方式进行身份验证。如果未定义用户,ClickHouse 将假定定义存在于外部 LDAP 目录中,并将尝试使用提供的凭据在 LDAP 服务器上对指定 DN 进行“绑定”。如果成功,用户将被视为存在且已验证。用户将被分配来自 `roles` 部分中指定列表的角色。此外,如果 `role_mapping` 部分也配置了,LDAP “搜索”可以执行,并且结果可以被转换并视为角色名称,然后分配给用户。这一切意味着 SQL 驱动的 [访问控制和账户管理](/operations/access-rights#access-control-usage) 已启用,并且角色通过 [CREATE ROLE](/sql-reference/statements/create/role) 语句创建。 +在每次登录尝试中,ClickHouse 试图在本地查找用户定义并按常规进行身份验证。如果未定义该用户,ClickHouse 将假设该定义存在于外部 LDAP 目录中,并将尝试使用提供的凭据“绑定”到 LDAP 服务器上的指定 DN。如果成功,该用户将被视为存在并已验证。将从 `roles` 部分指定的列表中为该用户分配角色。此外,可以执行 LDAP “搜索”,并将结果转换并视为角色名称,然后分配给用户,如果 `role_mapping` 部分也已配置。这都意味着启用了 SQL 驱动的 [访问控制和账户管理](/operations/access-rights#access-control-usage),并且使用 [CREATE ROLE](/sql-reference/statements/create/role) 语句创建角色。 **示例** -插入 `config.xml`。 +进入 `config.xml`。 ```xml @@ -167,22 +168,22 @@ CREATE USER my_user IDENTIFIED WITH ldap SERVER 'my_ldap_server'; ``` -请注意,在 `user_directories` 部分中的 `ldap` 部分中提到的 `my_ldap_server` 必须是一个在 `config.xml` 中配置过并且被定义的 LDAP 服务器(见 [LDAP 服务器定义](#ldap-server-definition))。 +请注意,`user_directories` 部分中的 `ldap` 部分引用的 `my_ldap_server` 必须是之前定义的在 `config.xml` 中配置的 LDAP 服务器(见 [LDAP 服务器定义](#ldap-server-definition))。 **参数** -- `server` — 在上述 `ldap_servers` 配置部分中定义的 LDAP 服务器名称之一。此参数是必需的,不能为空。 -- `roles` — 列出将分配给从 LDAP 服务器获取的每个用户的本地定义角色的部分。 - - 如果在此处未指定角色或在角色映射期间未分配角色(如下所述),用户将在身份验证后将无法执行任何操作。 -- `role_mapping` — 包含 LDAP 搜索参数和映射规则的部分。 - - 当用户进行身份验证时,同时仍然绑定到 LDAP,会使用 `search_filter` 和登录用户的名称执行 LDAP 搜索。在该搜索期间找到的每个条目的指定属性值都会被提取。对于每个具有指定前缀的属性值,将去掉前缀,剩余的值将成为在 ClickHouse 中预先定义的本地角色的名称,预计这些角色已经通过 [CREATE ROLE](/sql-reference/statements/create/role) 语句创建。 - - 可以在同一 `ldap` 部分中定义多个 `role_mapping` 部分。它们都会被应用。 - - `base_dn` — 用于构造 LDAP 搜索的基本 DN 的模板。 - - 结果的 DN 将通过在每次 LDAP 搜索期间用实际用户名、绑定 DN 和用户 DN 替换模板中的所有 `{user_name}`、`{bind_dn}` 和 `{user_dn}` 子字符串来构造。 - - `scope` — LDAP 搜索的范围。 - - 可接受的值为:`base`,`one_level`,`children`,`subtree`(默认)。 - - `search_filter` — 用于构造 LDAP 搜索的搜索过滤器的模板。 - - 结果的过滤器将通过在每次 LDAP 搜索中用实际用户名、绑定 DN、用户 DN 和基础 DN 替换模板中的所有 `{user_name}`、`{bind_dn}`、`{user_dn}` 和 `{base_dn}` 子字符串来构造。 - - 注意,特殊字符必须在 XML 中正确转义。 - - `attribute` — LDAP 搜索将返回其值的属性名称。默认为 `cn`。 - - `prefix` — 期望在 LDAP 搜索返回的原始字符串列表中的每个字符串前面出现的前缀。前缀将从原始字符串中去掉,结果字符串将被视为本地角色名称。默认为空。 +- `server` — 上述 `ldap_servers` 配置部分中定义的 LDAP 服务器名称之一。此参数是必需的,不能留空。 +- `roles` — 包含将分配给从 LDAP 服务器检索的每个用户的本地定义角色列表的部分。 + - 如果在这里未指定角色或在角色映射期间未分配角色(如下),用户在身份验证后将无法执行任何操作。 +- `role_mapping` — 带有 LDAP 搜索参数和映射规则的部分。 + - 当用户进行身份验证时,仍然绑定到 LDAP,将使用 `search_filter` 和登录用户的名称执行 LDAP 搜索。在搜索过程中找到的每个条目的指定属性的值将被提取。对于每个具有指定前缀的属性值,前缀将被移除,其余的值将成为在 ClickHouse 中定义的本地角色的名称,该角色预计在之前由 [CREATE ROLE](/sql-reference/statements/create/role) 语句创建。 + - 可以在同一 `ldap` 部分中定义多个 `role_mapping` 部分。所有这些将被应用。 + - `base_dn` — 用于构造 LDAP 搜索的基础 DN 的模板。 + - 结果的 DN 将通过用实际用户名、绑定 DN 和用户 DN 替换模板中的所有 `{user_name}`、`{bind_dn}` 和 `{user_dn}` 子字符串来构造。 + - `scope` — LDAP 搜索的范围。 + - 可接受的值有:`base`、`one_level`、`children`、`subtree`(默认)。 + - `search_filter` — 用于构造 LDAP 搜索的搜索过滤器的模板。 + - 结果过滤器将通过用实际用户名、绑定 DN、用户 DN 和基础 DN 替换模板中的所有 `{user_name}`、`{bind_dn}`、`{user_dn}` 和 `{base_dn}` 子字符串来构造。 + - 请注意,特殊字符必须在 XML 中正确转义。 + - `attribute` — LDAP 搜索将返回的属性名称。默认是 `cn`。 + - `prefix` — 预期出现在 LDAP 搜索返回的字符串原始列表中每个字符串前面的前缀。前缀将从原始字符串中移除,结果字符串将视为本地角色名称。默认是空。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/external-authenticators/ldap.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/external-authenticators/ldap.md.hash index 5a18e08f450..80a4841e885 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/external-authenticators/ldap.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/external-authenticators/ldap.md.hash @@ -1 +1 @@ -7e5f73e17ecc4ef3 +aaf84a786e5627fa diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/external-authenticators/ssl-x509.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/external-authenticators/ssl-x509.md index 7c500ceb5d5..3c61f5b7983 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/external-authenticators/ssl-x509.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/external-authenticators/ssl-x509.md @@ -1,16 +1,17 @@ --- 'description': 'Ssl X509 的文档' 'slug': '/operations/external-authenticators/ssl-x509' -'title': 'SSL X.509 证书身份验证' +'title': 'SSL X.509 证书认证' +'doc_type': 'reference' --- import SelfManaged from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_self_managed_only_no_roadmap.md'; -[SSL 'strict' 选项](../server-configuration-parameters/settings.md#openssl) 启用对传入连接的强制证书验证。在这种情况下,仅能建立与受信任证书的连接。与不受信任证书的连接将被拒绝。因此,证书验证可以唯一地认证传入连接。`Common Name` 或 `subjectAltName 扩展` 字段用于识别连接的用户。`subjectAltName 扩展` 支持在服务器配置中使用一个通配符 '*'。这允许将多个证书与同一用户关联。此外,证书的重新颁发和撤销不会影响 ClickHouse 配置。 +[SSL '严格' 选项](../server-configuration-parameters/settings.md#openssl) 启用对传入连接的强制证书验证。在这种情况下,仅允许与受信任证书的连接被建立。与不受信任证书的连接将被拒绝。因此,证书验证可以唯一地验证传入连接。证书的 `Common Name` 或 `subjectAltName 扩展` 字段用于识别连接的用户。 `subjectAltName 扩展` 在服务器配置中支持使用一个通配符 '*'。这允许将多个证书与同一个用户关联。此外,证书的重新签发和吊销不影响 ClickHouse 配置。 -要启用 SSL 证书认证,必须在设置文件 `users.xml` 中为每个 ClickHouse 用户指定一份 `Common Name` 或 `Subject Alt Name` 的列表: +要启用 SSL 证书身份验证,必须在设置文件 `users.xml` 中为每个 ClickHouse 用户指定一组 `Common Name` 或 `Subject Alt Name`: **示例** ```xml @@ -42,4 +43,4 @@ import SelfManaged from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_s ``` -为了使 SSL [`信任链`](https://en.wikipedia.org/wiki/Chain_of_trust) 正常工作,确保 [`caConfig`](../server-configuration-parameters/settings.md#openssl) 参数配置正确也非常重要。 +为了使 SSL [`信任链`](https://en.wikipedia.org/wiki/Chain_of_trust) 正常工作,确保 [`caConfig`](../server-configuration-parameters/settings.md#openssl) 参数配置正确也很重要。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/external-authenticators/ssl-x509.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/external-authenticators/ssl-x509.md.hash index 3cf1df5b693..d01b9852e61 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/external-authenticators/ssl-x509.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/external-authenticators/ssl-x509.md.hash @@ -1 +1 @@ -c3ebaee30cac7b6e +d60ad9eb820d0173 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/monitoring.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/monitoring.md index 0aa9e5f9283..b85101d321d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/monitoring.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/monitoring.md @@ -1,5 +1,5 @@ --- -'description': '您可以监控硬件资源的使用情况以及 ClickHouse 服务器指标。' +'description': '您可以监控硬件资源的利用率以及 ClickHouse 服务器指标。' 'keywords': - 'monitoring' - 'observability' @@ -10,6 +10,7 @@ 'sidebar_position': 45 'slug': '/operations/monitoring' 'title': '监控' +'doc_type': 'reference' --- import Image from '@theme/IdealImage'; @@ -18,47 +19,47 @@ import Image from '@theme/IdealImage'; # 监控 :::note -本指南中概述的监控数据可在 ClickHouse Cloud 中访问。除了通过以下描述的内置仪表板显示之外,基本和高级性能指标也可以直接在主服务控制台中查看。 +本指南中概述的监控数据可在 ClickHouse Cloud 中访问。除了通过下面描述的内置仪表板显示之外,基础和高级性能指标也可以直接在主服务控制台中查看。 ::: 您可以监控: -- 硬件资源的使用率。 +- 硬件资源的利用率。 - ClickHouse 服务器指标。 -## 内置高级可观测性仪表板 {#built-in-advanced-observability-dashboard} +## 内置高级可观察性仪表板 {#built-in-advanced-observability-dashboard} -ClickHouse 具有内置的高级可观测性仪表板功能,可通过 `$HOST:$PORT/dashboard` 访问(需要用户名和密码),显示以下指标: +ClickHouse 配备了内置的高级可观察性仪表板功能,可以通过 `$HOST:$PORT/dashboard` 访问(需要用户名和密码),显示以下指标: - 查询/秒 -- CPU 使用率(核心) +- CPU 使用率(核心数) - 正在运行的查询 -- 正在进行的合并 -- 选定字节/秒 +- 正在运行的合并 +- 选择的字节/秒 - IO 等待 - CPU 等待 - 操作系统 CPU 使用率(用户空间) - 操作系统 CPU 使用率(内核) - 从磁盘读取 - 从文件系统读取 -- 内存(跟踪) +- 内存(已追踪) - 插入的行/秒 -- 总 MergeTree 分片 -- 分区的最大分片数量 +- 总 MergeTree 部件 +- 分区的最大部件 -## 资源使用率 {#resource-utilization} +## 资源利用率 {#resource-utilization} -ClickHouse 还会自动监控硬件资源的状态,例如: +ClickHouse 还监控硬件资源的状态,如: - 处理器的负载和温度。 -- 存储系统、RAM 和网络的利用率。 +- 存储系统、内存和网络的利用率。 -这些数据收集在 `system.asynchronous_metric_log` 表中。 +这些数据会收集到 `system.asynchronous_metric_log` 表中。 ## ClickHouse 服务器指标 {#clickhouse-server-metrics} -ClickHouse 服务器内置了自我状态监控的工具。 +ClickHouse 服务器具有嵌入式工具用于自我状态监控。 要跟踪服务器事件,请使用服务器日志。请参阅配置文件中的 [logger](../operations/server-configuration-parameters/settings.md#logger) 部分。 @@ -69,10 +70,10 @@ ClickHouse 收集: 您可以在 [system.metrics](/operations/system-tables/metrics)、[system.events](/operations/system-tables/events) 和 [system.asynchronous_metrics](/operations/system-tables/asynchronous_metrics) 表中找到指标。 -您可以配置 ClickHouse 将指标导出到 [Graphite](https://github.com/graphite-project)。请参阅 ClickHouse 服务器配置文件中的 [Graphite 部分](../operations/server-configuration-parameters/settings.md#graphite)。在配置指标导出之前,您应该按照其官方 [指南](https://graphite.readthedocs.io/en/latest/install.html) 设置 Graphite。 +您可以配置 ClickHouse 将指标导出到 [Graphite](https://github.com/graphite-project)。请参阅 ClickHouse 服务器配置文件中的 [Graphite 部分](../operations/server-configuration-parameters/settings.md#graphite)。在配置指标导出之前,您应通过遵循他们的官方 [指南](https://graphite.readthedocs.io/en/latest/install.html) 设置 Graphite。 -您可以配置 ClickHouse 将指标导出到 [Prometheus](https://prometheus.io)。请参阅 ClickHouse 服务器配置文件中的 [Prometheus 部分](../operations/server-configuration-parameters/settings.md#prometheus)。在配置指标导出之前,您应该按照其官方 [指南](https://prometheus.io/docs/prometheus/latest/installation/) 设置 Prometheus。 +您可以配置 ClickHouse 将指标导出到 [Prometheus](https://prometheus.io)。请参阅 ClickHouse 服务器配置文件中的 [Prometheus 部分](../operations/server-configuration-parameters/settings.md#prometheus)。在配置指标导出之前,您应通过遵循他们的官方 [指南](https://prometheus.io/docs/prometheus/latest/installation/) 设置 Prometheus。 -此外,您还可以通过 HTTP API 监控服务器的可用性。向 `/ping` 发送 `HTTP GET` 请求。如果服务器可用,它会响应 `200 OK`。 +此外,您还可以通过 HTTP API 监控服务器的可用性。发送 `HTTP GET` 请求到 `/ping`。如果服务器可用,它将响应 `200 OK`。 -要监控集群配置中的服务器,您应设置 [max_replica_delay_for_distributed_queries](../operations/settings/settings.md#max_replica_delay_for_distributed_queries) 参数,并使用 HTTP 资源 `/replicas_status`。对 `/replicas_status` 的请求会返回 `200 OK`,如果副本可用且没有落后于其他副本。如果副本延迟,它会返回 `503 HTTP_SERVICE_UNAVAILABLE`,并提供有关差距的信息。 +要监控集群配置中的服务器,您应设置 [max_replica_delay_for_distributed_queries](../operations/settings/settings.md#max_replica_delay_for_distributed_queries) 参数,并使用 HTTP 资源 `/replicas_status`。对 `/replicas_status` 的请求返回 `200 OK` 如果副本可用且没有落后于其他副本。如果副本延迟,将返回 `503 HTTP_SERVICE_UNAVAILABLE`,并提供有关延迟的信息。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/monitoring.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/monitoring.md.hash index 34c99d24c95..48cfa169d68 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/monitoring.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/monitoring.md.hash @@ -1 +1 @@ -0f0c4429ed0111da +41efb25377ee481d diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/named-collections.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/named-collections.md index 4acfe90d59e..c24718ddaea 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/named-collections.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/named-collections.md @@ -1,9 +1,10 @@ --- -'description': 'Documentation for 命名集合' +'description': 'Documentation for Named collections' 'sidebar_label': '命名集合' 'sidebar_position': 69 'slug': '/operations/named-collections' 'title': '命名集合' +'doc_type': 'reference' --- import CloudNotSupportedBadge from '@theme/badges/CloudNotSupportedBadge'; @@ -12,15 +13,14 @@ import CloudNotSupportedBadge from '@theme/badges/CloudNotSupportedBadge'; 命名集合提供了一种存储键值对集合的方法,用于配置与外部源的集成。您可以将命名集合与字典、表、表函数和对象存储一起使用。 -命名集合可以通过 DDL 或配置文件进行配置,并在 ClickHouse 启动时应用。它们简化了对象的创建以及隐藏不具备管理权限用户的凭据。 +命名集合可以通过 DDL 或配置文件进行配置,并在 ClickHouse 启动时应用。它们简化了对象的创建,并隐藏凭据对没有管理访问权限的用户。 -命名集合中的键必须与相应函数、表引擎、数据库等的参数名称匹配。在下面的示例中,参数列表与每种类型相关联。 +命名集合中的键必须与相应函数、表引擎、数据库等的参数名称匹配。在下面的示例中,参数列表链接到每种类型。 -在命名集合中设置的参数可以在 SQL 中被覆盖,下面的示例中显示了这一点。可以使用 `[NOT] OVERRIDABLE` 关键字和 XML 属性及/或配置选项 `allow_named_collection_override_by_default` 来限制此功能。 +在命名集合中设置的参数可以在 SQL 中被覆盖,这在下面的示例中有所展示。可以使用 `[NOT] OVERRIDABLE` 关键字和 XML 属性以及/或配置选项 `allow_named_collection_override_by_default` 来限制此能力。 :::warning -如果允许覆盖,则没有管理权限的用户可能能够找出您试图隐藏的凭据。 -如果您使用命名集合的目的就是为了这个,您应该禁用 `allow_named_collection_override_by_default`(默认启用)。 +如果允许覆盖,可能导致没有管理访问权限的用户推测您试图隐藏的凭据。如果您出于该目的使用命名集合,则应禁用 `allow_named_collection_override_by_default`(默认为启用)。 ::: ## 在系统数据库中存储命名集合 {#storing-named-collections-in-the-system-database} @@ -36,13 +36,13 @@ url = 'https://connection.url/' 在上面的示例中: - * `key_1` 始终可以被覆盖。 - * `key_2` 永远不能被覆盖。 - * `url` 是否可以被覆盖取决于 `allow_named_collection_override_by_default` 的值。 +* `key_1` 总是可以被覆盖。 +* `key_2` 永远不可以被覆盖。 +* `url` 可以根据 `allow_named_collection_override_by_default` 的值选择是否可以被覆盖。 ### 使用 DDL 创建命名集合的权限 {#permissions-to-create-named-collections-with-ddl} -要使用 DDL 管理命名集合,用户必须具备 `named_collection_control` 权限。可以通过在 `/etc/clickhouse-server/users.d/` 中添加文件来分配该权限。示例中为用户 `default` 赋予了 `access_management` 和 `named_collection_control` 权限: +要使用 DDL 管理命名集合,用户必须拥有 `named_collection_control` 特权。这可以通过将文件添加到 `/etc/clickhouse-server/users.d/` 来分配。示例中给用户 `default` 同时赋予了 `access_management` 和 `named_collection_control` 特权: ```xml title='/etc/clickhouse-server/users.d/user_default.xml' @@ -59,17 +59,16 @@ url = 'https://connection.url/' ``` :::tip -在上面的示例中,`password_sha256_hex` 值是密码 SHA256 哈希的十六进制表示。用户 `default` 的此配置具有属性 `replace=true`,因为默认配置中设置了明文 `password`,并且不能同时为用户设置明文和 sha256 hex 密码。 +在上面的示例中,`password_sha256_hex` 的值是密码的 SHA256 哈希值的十六进制表示。用户 `default` 的这个配置具有属性 `replace=true`,因为默认配置具有设置为明文的 `password`,并且不可能同时为用户设置明文和 SHA256 十六进制密码。 ::: ### 命名集合的存储 {#storage-for-named-collections} -命名集合可以存储在本地磁盘或 ZooKeeper/Keeper 中。默认使用本地存储。 -它们还可以使用与 [磁盘加密](storing-data#encrypted-virtual-file-system) 相同的算法进行加密存储,其中默认使用 `aes_128_ctr`。 +命名集合可以存储在本地磁盘或 ZooKeeper/Keeper 中。默认情况下使用本地存储。它们也可以使用与 [磁盘加密](storing-data#encrypted-virtual-file-system) 中使用的相同算法进行加密存储,其中默认使用 `aes_128_ctr`。 -要配置命名集合存储,您需要指定一个 `type`。这可以是 `local` 或 `keeper`/`zookeeper`。对于加密存储,您可以使用 `local_encrypted` 或 `keeper_encrypted`/`zookeeper_encrypted`。 +要配置命名集合存储,您需要指定 `type`。这可以是 `local` 或 `keeper`/`zookeeper`。对于加密存储,可以使用 `local_encrypted` 或 `keeper_encrypted`/`zookeeper_encrypted`。 -要使用 ZooKeeper/Keeper,我们还需要在配置文件中为 `named_collections_storage` 部分设置一个 `path` (在 ZooKeeper/Keeper 中,命名集合将存储的位置)。以下示例使用加密和 ZooKeeper/Keeper: +使用 ZooKeeper/Keeper 时,我们还需要在配置文件中为 `named_collections_storage` 部分设置一个 `path`(在 ZooKeeper/Keeper 中命名集合将存储的路径)。以下示例使用加密和 ZooKeeper/Keeper: ```xml @@ -82,7 +81,7 @@ url = 'https://connection.url/' ``` -可选配置参数 `update_timeout_ms` 默认等于 `5000`。 +可选的配置参数 `update_timeout_ms` 默认为 `5000`。 ## 在配置文件中存储命名集合 {#storing-named-collections-in-configuration-files} @@ -102,33 +101,33 @@ url = 'https://connection.url/' 在上面的示例中: - * `key_1` 始终可以被覆盖。 - * `key_2` 永远不能被覆盖。 - * `url` 是否可以被覆盖取决于 `allow_named_collection_override_by_default` 的值。 +* `key_1` 总是可以被覆盖。 +* `key_2` 永远不可以被覆盖。 +* `url` 可以根据 `allow_named_collection_override_by_default` 的值选择是否可以被覆盖。 ## 修改命名集合 {#modifying-named-collections} -使用 DDL 查询创建的命名集合可以用 DDL 修改或删除。使用 XML 文件创建的命名集合可以通过编辑或删除相应的 XML 文件进行管理。 +通过 DDL 查询创建的命名集合可以通过 DDL 被修改或删除。通过 XML 文件创建的命名集合可以通过编辑或删除相应的 XML 进行管理。 ### 修改 DDL 命名集合 {#alter-a-ddl-named-collection} -更改或添加集合 `collection2` 的 `key1` 和 `key3` 键 -(这不会更改这些键的 `overridable` 标志的值): +更改或添加集合 `collection2` 的 `key1` 和 `key3`: +(这不会改变这些键的 `overridable` 标志的值): ```sql ALTER NAMED COLLECTION collection2 SET key1=4, key3='value3' ``` -更改或添加 `key1` 并允许其始终被覆盖: +更改或添加键 `key1` 并允许其始终被覆盖: ```sql ALTER NAMED COLLECTION collection2 SET key1=4 OVERRIDABLE ``` -从 `collection2` 中移除 `key2`: +从 `collection2` 中删除键 `key2`: ```sql ALTER NAMED COLLECTION collection2 DELETE key2 ``` -更改或添加 `key1` 并删除集合 `collection2` 的 `key3`: +更改或添加键 `key1` 并删除集合 `collection2` 的键 `key3`: ```sql ALTER NAMED COLLECTION collection2 SET key1=4, DELETE key3 ``` @@ -139,14 +138,14 @@ ALTER NAMED COLLECTION collection2 DELETE key1; ALTER NAMED COLLECTION collection2 SET key1=4; ``` -### 删除 DDL 命名集合 `collection2`: {#drop-the-ddl-named-collection-collection2} +### 删除 DDL 命名集合 `collection2`: {#drop-the-ddl-named-collection-collection2} ```sql DROP NAMED COLLECTION collection2 ``` ## 访问 S3 的命名集合 {#named-collections-for-accessing-s3} -参数描述请参见 [s3 表函数](../sql-reference/table-functions/s3.md)。 +参数描述见 [s3 表函数](../sql-reference/table-functions/s3.md)。 ### DDL 示例 {#ddl-example-1} @@ -175,7 +174,7 @@ url = 'https://s3.us-east-1.amazonaws.com/yourbucket/mydata/' ### s3() 函数和 S3 表命名集合示例 {#s3-function-and-s3-table-named-collection-examples} -以下两个示例均使用相同的命名集合 `s3_mydata`: +以下两个示例使用相同命名集合 `s3_mydata`: #### s3() 函数 {#s3-function} @@ -186,7 +185,7 @@ SELECT * FROM numbers(10000); ``` :::tip -上述 `s3()` 函数的第一个参数是集合的名称 `s3_mydata`。如果没有命名集合,访问密钥 ID、秘密、格式和 URL 都将每次调用 `s3()` 函数时传递。 +上面 `s3()` 函数的第一个参数是集合的名称 `s3_mydata`。如果没有命名集合,则访问密钥 ID、密钥、格式和 URL 将在每次调用 `s3()` 函数时传递。 ::: #### S3 表 {#s3-table} @@ -206,7 +205,7 @@ SELECT * FROM s3_engine_table LIMIT 3; ## 访问 MySQL 数据库的命名集合 {#named-collections-for-accessing-mysql-database} -参数描述请参见 [mysql](../sql-reference/table-functions/mysql.md)。 +参数描述见 [mysql](../sql-reference/table-functions/mysql.md)。 ### DDL 示例 {#ddl-example-2} @@ -241,7 +240,7 @@ replace_query = 1 ### mysql() 函数、MySQL 表、MySQL 数据库和字典命名集合示例 {#mysql-function-mysql-table-mysql-database-and-dictionary-named-collection-examples} -以下四个示例使用相同的命名集合 `mymysql`: +以下四个示例使用相同命名集合 `mymysql`: #### mysql() 函数 {#mysql-function} @@ -253,7 +252,7 @@ SELECT count() FROM mysql(mymysql, table = 'test'); └─────────┘ ``` :::note -命名集合没有指定 `table` 参数,因此在函数调用中指定为 `table = 'test'`。 +命名集合未指定 `table` 参数,因此在函数调用中指定为 `table = 'test'`。 ::: #### MySQL 表 {#mysql-table} @@ -302,12 +301,12 @@ SELECT dictGet('dict', 'B', 2); ## 访问 PostgreSQL 数据库的命名集合 {#named-collections-for-accessing-postgresql-database} -参数描述请参见 [postgresql](../sql-reference/table-functions/postgresql.md)。此外,还有别名: +参数描述见 [postgresql](../sql-reference/table-functions/postgresql.md)。此外,还有别名: -- `username` 用于 `user` -- `db` 用于 `database`。 +- `username` 对应 `user` +- `db` 对应 `database`。 -参数 `addresses_expr` 在集合中用于替代 `host:port`。由于还有其他可选参数:`host`、`hostname`、`port`,该参数是可选的。以下伪代码解释优先级: +参数 `addresses_expr` 在集合中用于替代 `host:port`。该参数是可选的,因为还有其他可选参数:`host`、`hostname`、`port`。以下伪代码解释了优先级: ```sql CASE @@ -344,7 +343,7 @@ schema = 'test_schema' ``` -### 使用 PostgreSQL 函数的命名集合示例 {#example-of-using-named-collections-with-the-postgresql-function} +### 使用命名集合与 PostgreSQL 函数的示例 {#example-of-using-named-collections-with-the-postgresql-function} ```sql SELECT * FROM postgresql(mypg, table = 'test'); @@ -353,8 +352,6 @@ SELECT * FROM postgresql(mypg, table = 'test'); │ 2 │ two │ │ 1 │ one │ └───┴─────┘ - - SELECT * FROM postgresql(mypg, table = 'test', schema = 'public'); ┌─a─┐ @@ -364,7 +361,7 @@ SELECT * FROM postgresql(mypg, table = 'test', schema = 'public'); └───┘ ``` -### 使用 PostgreSQL 引擎的数据库的命名集合示例 {#example-of-using-named-collections-with-database-with-engine-postgresql} +### 使用命名集合与 PostgreSQL 引擎的数据库的示例 {#example-of-using-named-collections-with-database-with-engine-postgresql} ```sql CREATE TABLE mypgtable (a Int64) ENGINE = PostgreSQL(mypg, table = 'test', schema = 'public'); @@ -379,10 +376,10 @@ SELECT * FROM mypgtable; ``` :::note -PostgreSQL 在创建表时从命名集合中复制数据。对集合的更改不会影响现有表。 +PostgreSQL 在创建表时从命名集合复制数据。集合中的更改不会影响现有表。 ::: -### 使用 PostgreSQL 引擎的数据库的命名集合示例 {#example-of-using-named-collections-with-database-with-engine-postgresql-1} +### 使用命名集合与 PostgreSQL 引擎的数据库的示例 {#example-of-using-named-collections-with-database-with-engine-postgresql-1} ```sql CREATE DATABASE mydatabase ENGINE = PostgreSQL(mypg); @@ -394,7 +391,7 @@ SHOW TABLES FROM mydatabase └──────┘ ``` -### 使用源为 POSTGRESQL 的字典的命名集合示例 {#example-of-using-named-collections-with-a-dictionary-with-source-postgresql} +### 使用命名集合与数据源为 POSTGRESQL 的字典的示例 {#example-of-using-named-collections-with-a-dictionary-with-source-postgresql} ```sql CREATE DICTIONARY dict (a Int64, b String) @@ -412,7 +409,7 @@ SELECT dictGet('dict', 'b', 2); ## 访问远程 ClickHouse 数据库的命名集合 {#named-collections-for-accessing-a-remote-clickhouse-database} -参数描述请参见 [remote](../sql-reference/table-functions/remote.md/#parameters)。 +参数描述见 [remote](../sql-reference/table-functions/remote.md/#parameters)。 配置示例: @@ -440,9 +437,9 @@ secure = 1 ``` -`secure` 在连接中不是必需的,因为使用 `remoteSecure`,但可以用于字典。 +`secure` 在连接中并不需要因为 `remoteSecure`,但它可以用于字典。 -### 使用 `remote`/`remoteSecure` 函数的命名集合示例 {#example-of-using-named-collections-with-the-remoteremotesecure-functions} +### 使用命名集合与 `remote`/`remoteSecure` 函数的示例 {#example-of-using-named-collections-with-the-remoteremotesecure-functions} ```sql SELECT * FROM remote(remote1, table = one); @@ -463,7 +460,7 @@ SELECT * FROM remote(remote1, database = default, table = test); └───┴───┘ ``` -### 使用源为 ClickHouse 的字典的命名集合示例 {#example-of-using-named-collections-with-a-dictionary-with-source-clickhouse} +### 使用命名集合与数据源为 ClickHouse 的字典的示例 {#example-of-using-named-collections-with-a-dictionary-with-source-clickhouse} ```sql CREATE DICTIONARY dict(a Int64, b String) @@ -480,7 +477,7 @@ SELECT dictGet('dict', 'b', 1); ## 访问 Kafka 的命名集合 {#named-collections-for-accessing-kafka} -参数描述请参见 [Kafka](../engines/table-engines/integrations/kafka.md)。 +参数描述见 [Kafka](../engines/table-engines/integrations/kafka.md)。 ### DDL 示例 {#ddl-example-3} @@ -509,9 +506,9 @@ kafka_max_block_size = '1048576'; ``` -### 使用 Kafka 表的命名集合示例 {#example-of-using-named-collections-with-a-kafka-table} +### 使用命名集合与 Kafka 表的示例 {#example-of-using-named-collections-with-a-kafka-table} -以下两个示例均使用相同的命名集合 `my_kafka_cluster`: +以下两个示例使用相同命名集合 `my_kafka_cluster`: ```sql CREATE TABLE queue @@ -535,7 +532,7 @@ SETTINGS kafka_num_consumers = 4, ## 备份的命名集合 {#named-collections-for-backups} -参数描述请参见 [备份和恢复](./backup.md)。 +参数的描述见 [备份和恢复](./backup.md)。 ### DDL 示例 {#ddl-example-4} @@ -545,9 +542,21 @@ BACKUP TABLE default.test to S3(named_collection_s3_backups, 'directory') ### XML 示例 {#xml-example-4} +```xml + + + + https://my-s3-bucket.s3.amazonaws.com/backup-S3/ + ABC123 + Abc+123 + + + +``` + ## 访问 MongoDB 表和字典的命名集合 {#named-collections-for-accessing-mongodb-table-and-dictionary} -参数描述请参见 [mongodb](../sql-reference/table-functions/mongodb.md)。 +参数描述见 [mongodb](../sql-reference/table-functions/mongodb.md)。 ### DDL 示例 {#ddl-example-5} @@ -600,5 +609,5 @@ SELECT dictGet('dict', 'b', 2); ``` :::note -命名集合指定了 `my_collection` 作为集合名称。在函数调用中,它被 `collection = 'my_dict'` 覆盖以选择另一个集合。 +命名集合为集合名称指定了 `my_collection`。在函数调用中,它被 `collection = 'my_dict'` 覆盖,用于选择另一集合。 ::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/named-collections.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/named-collections.md.hash index 7b73dd9002a..e612e1d5a97 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/named-collections.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/named-collections.md.hash @@ -1 +1 @@ -00cde5157258a30f +f8812f55195b78e6 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/opentelemetry.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/opentelemetry.md index 204dba56dd6..a461fb42206 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/opentelemetry.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/opentelemetry.md @@ -1,46 +1,47 @@ --- -'description': 'OpenTelemetry 在 ClickHouse 中进行分布式跟踪和指标收集的指南' -'sidebar_label': '使用 OpenTelemetry 进行 ClickHouse 跟踪' +'description': '关于在 ClickHouse 中使用 OpenTelemetry 进行分布式跟踪和指标收集的指南' +'sidebar_label': '使用 OpenTelemetry 跟踪 ClickHouse' 'sidebar_position': 62 'slug': '/operations/opentelemetry' -'title': '使用 OpenTelemetry 进行 ClickHouse 跟踪' +'title': '使用 OpenTelemetry 跟踪 ClickHouse' +'doc_type': 'guide' --- -[OpenTelemetry](https://opentelemetry.io/) 是一个用于从分布式应用程序收集跟踪和指标的开放标准。 ClickHouse 对 OpenTelemetry 有一定的支持。 +[OpenTelemetry](https://opentelemetry.io/) 是一个用于从分布式应用程序收集跟踪和指标的开放标准。ClickHouse 对 OpenTelemetry 有一定的支持。 -## 将跟踪上下文提供给 ClickHouse {#supplying-trace-context-to-clickhouse} +## 向 ClickHouse 提供 trace 上下文 {#supplying-trace-context-to-clickhouse} -ClickHouse 接受跟踪上下文 HTTP 头,如 [W3C 推荐](https://www.w3.org/TR/trace-context/) 中所述。它还接受通过 ClickHouse 服务器之间或客户端与服务器之间通信所使用的本地协议传递的跟踪上下文。对于手动测试,可以使用 `--opentelemetry-traceparent` 和 `--opentelemetry-tracestate` 标志将符合跟踪上下文推荐的头提供给 `clickhouse-client`。 +ClickHouse 接受 trace 上下文 HTTP 头,如 [W3C 推荐](https://www.w3.org/TR/trace-context/) 所述。它还接受通过用于 ClickHouse 服务器之间或客户端与服务器之间通信的原生协议传递的 trace 上下文。对于手动测试,符合 Trace Context 推荐的 trace 上下文头可以通过 `--opentelemetry-traceparent` 和 `--opentelemetry-tracestate` 选项提供给 `clickhouse-client`。 -如果未提供父级跟踪上下文,或提供的跟踪上下文不符合上述 W3C 标准,ClickHouse 可以以由 [opentelemetry_start_trace_probability](/operations/settings/settings#opentelemetry_start_trace_probability) 设置控制的概率开始新的跟踪。 +如果没有提供父 trace 上下文,或提供的 trace 上下文不符合上述 W3C 标准,ClickHouse 可以以由 [opentelemetry_start_trace_probability](/operations/settings/settings#opentelemetry_start_trace_probability) 设置控制的概率启动新的 trace。 -## 传递跟踪上下文 {#propagating-the-trace-context} +## 传播 trace 上下文 {#propagating-the-trace-context} -在以下情况下,跟踪上下文会传递给下游服务: +以下情况下,trace 上下文将传播到下游服务: -* 对远程 ClickHouse 服务器的查询,例如使用 [Distributed](../engines/table-engines/special/distributed.md) 表引擎时。 +* 向远程 ClickHouse 服务器的查询,例如使用 [Distributed](../engines/table-engines/special/distributed.md) 表引擎时。 -* [url](../sql-reference/table-functions/url.md) 表函数。跟踪上下文信息通过 HTTP 头发送。 +* [url](../sql-reference/table-functions/url.md) 表函数。trace 上下文信息通过 HTTP 头发送。 ## 跟踪 ClickHouse 本身 {#tracing-the-clickhouse-itself} -ClickHouse 为每个查询以及某些查询执行阶段(例如查询规划或分布式查询)创建 `trace spans`。 +ClickHouse 为每个查询及某些查询执行阶段(如查询规划或分布式查询)创建 `trace spans`。 -为了有用,跟踪信息必须导出到支持 OpenTelemetry 的监控系统,例如 [Jaeger](https://jaegertracing.io/) 或 [Prometheus](https://prometheus.io/)。ClickHouse 避免依赖特定的监控系统,而是通过系统表提供跟踪数据。符合 [标准](https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/overview.md#span) 的 OpenTelemetry 跟踪跨度信息存储在 [system.opentelemetry_span_log](../operations/system-tables/opentelemetry_span_log.md) 表中。 +为了更有用,跟踪信息必须导出到支持 OpenTelemetry 的监控系统中,例如 [Jaeger](https://jaegertracing.io/) 或 [Prometheus](https://prometheus.io/)。ClickHouse 避免对特定监控系统的依赖,而是通过系统表提供跟踪数据。根据标准所需的 OpenTelemetry trace span 信息 [要求](https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/overview.md#span) 存储在 [system.opentelemetry_span_log](../operations/system-tables/opentelemetry_span_log.md) 表中。 -该表必须在服务器配置中启用,详见默认配置文件 `config.xml` 中的 `opentelemetry_span_log` 元素。默认情况下它是启用的。 +该表必须在服务器配置中启用,请参见默认配置文件 `config.xml` 中的 `opentelemetry_span_log` 元素。默认情况下已启用。 -标签或属性作为两个并行数组保存,其中包含键和值。使用 [ARRAY JOIN](../sql-reference/statements/select/array-join.md) 来处理它们。 +标签或属性作为两个并行数组保存,包含键和值。使用 [ARRAY JOIN](../sql-reference/statements/select/array-join.md) 来处理它们。 ## 日志查询设置 {#log-query-settings} -设置 [log_query_settings](settings/settings.md) 允许在查询执行期间记录查询设置的更改。当启用时,对查询设置所做的任何修改将记录在 OpenTelemetry 跨度日志中。此功能在生产环境中特别有用,用于跟踪可能影响查询性能的配置更改。 +设置 [log_query_settings](settings/settings.md) 允许记录查询执行期间对查询设置的更改。当启用时,任何对查询设置所做的修改将记录在 OpenTelemetry span 日志中。此功能在生产环境中特别有用,可以跟踪可能影响查询性能的配置更改。 ## 与监控系统的集成 {#integration-with-monitoring-systems} -目前,还没有可以将 ClickHouse 的跟踪数据导出到监控系统的现成工具。 +目前,没有现成的工具可以将 ClickHouse 的跟踪数据导出到监控系统。 -对于测试,可以使用基于 [system.opentelemetry_span_log](../operations/system-tables/opentelemetry_span_log.md) 表的 [URL](../engines/table-engines/special/url.md) 引擎设置物化视图进行导出,这将把到达的日志数据推送到跟踪收集器的 HTTP 端点。例如,要将最小的跨度数据以 Zipkin v2 JSON 格式推送到运行在 `http://localhost:9411` 的 Zipkin 实例: +对于测试,可以使用基于 [system.opentelemetry_span_log](../operations/system-tables/opentelemetry_span_log.md) 表的 [URL](../engines/table-engines/special/url.md) 引擎设置物化视图进行导出,这可以将到达的日志数据推送到 trace 收集器的 HTTP 端点。例如,将最小的 span 数据推送到运行在 `http://localhost:9411` 的 Zipkin 实例,采用 Zipkin v2 JSON 格式: ```sql CREATE MATERIALIZED VIEW default.zipkin_spans @@ -49,7 +50,7 @@ SETTINGS output_format_json_named_tuples_as_objects = 1, output_format_json_array_of_rows = 1 AS SELECT lower(hex(trace_id)) AS traceId, - case when parent_span_id = 0 then '' else lower(hex(parent_span_id)) end AS parentId, + CASE WHEN parent_span_id = 0 THEN '' ELSE lower(hex(parent_span_id)) END AS parentId, lower(hex(span_id)) AS id, operation_name AS name, start_time_us AS timestamp, @@ -61,7 +62,7 @@ SELECT FROM system.opentelemetry_span_log ``` -在错误发生的情况下,发生错误的日志数据部分将被静默丢失。如果数据未到达,请检查服务器日志以获取错误消息。 +如果发生任何错误,发生错误的日志数据部分将会悄然丢失。如果数据没有到达,请检查服务器日志以获得错误消息。 ## 相关内容 {#related-content} diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/opentelemetry.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/opentelemetry.md.hash index 72006af0ee2..b5d1afe9d67 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/opentelemetry.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/opentelemetry.md.hash @@ -1 +1 @@ -1c68d837cdeea5da +9e4f48f26ec8b9f1 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/optimizing-performance/profile-guided-optimization.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/optimizing-performance/profile-guided-optimization.md index 11640a785f5..ea24e9eb2c4 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/optimizing-performance/profile-guided-optimization.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/optimizing-performance/profile-guided-optimization.md @@ -4,27 +4,28 @@ 'sidebar_position': 54 'slug': '/operations/optimizing-performance/profile-guided-optimization' 'title': '性能指导优化' +'doc_type': 'guide' --- import SelfManaged from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_self_managed_only_no_roadmap.md'; -# Profiling 引导优化 +# Profile guided optimization -Profiling 引导优化 (PGO) 是一种编译器优化技术,程序根据运行时配置文件进行优化。 +Profile-Guided Optimization (PGO) 是一种编译器优化技术,通过运行时分析程序的性能来优化程序。 -根据测试,PGO 有助于提升 ClickHouse 的性能。根据测试,我们在 ClickBench 测试套件中看到 QPS 有高达 15% 的提升。更详细的结果可以在 [这里](https://pastebin.com/xbue3HMU) 找到。性能收益取决于您的典型工作负载 - 您可能会得到更好或更差的结果。 +根据测试,PGO 有助于提高 ClickHouse 的性能。根据测试结果,我们在 ClickBench 测试套件中观察到 QPS 最高可提高 15%。更详细的结果可以在 [这里](https://pastebin.com/xbue3HMU) 找到。性能收益取决于您的典型工作负载 - 您可能会获得更好的或更差的结果。 -关于 ClickHouse 中 PGO 的更多信息,您可以阅读相应的 GitHub [问题](https://github.com/ClickHouse/ClickHouse/issues/44567)。 +关于 ClickHouse 中 PGO 的更多信息,您可以在相关的 GitHub [issue](https://github.com/ClickHouse/ClickHouse/issues/44567) 中阅读。 -## 如何构建带 PGO 的 ClickHouse? {#how-to-build-clickhouse-with-pgo} +## 如何使用 PGO 构建 ClickHouse? {#how-to-build-clickhouse-with-pgo} -PGO 有两种主要类型: [Instrumentation](https://clang.llvm.org/docs/UsersManual.html#using-sampling-profilers) 和 [Sampling](https://clang.llvm.org/docs/UsersManual.html#using-sampling-profilers)(也称为 AutoFDO)。在本指南中描述了 ClickHouse 的 Instrumentation PGO。 +PGO 主要有两种类型:[Instrumentation](https://clang.llvm.org/docs/UsersManual.html#using-sampling-profilers) 和 [Sampling](https://clang.llvm.org/docs/UsersManual.html#using-sampling-profilers)(也称为 AutoFDO)。本指南描述了在 ClickHouse 中使用 Instrumentation PGO。 -1. 以 Instrumented 模式构建 ClickHouse。在 Clang 中,可以通过将 `-fprofile-generate` 选项传递给 `CXXFLAGS` 来完成。 -2. 在样本工作负载上运行被插装的 ClickHouse。在这里,您需要使用您通常的工作负载。一个可行的方法是使用 [ClickBench](https://github.com/ClickHouse/ClickBench) 作为样本工作负载。由于插装模式下的 ClickHouse 可能运行较慢,因此请做好准备,不要在性能关键的环境中运行被插装的 ClickHouse。 -3. 再次使用 `-fprofile-use` 编译器标志和从上一步收集的配置文件重新编译 ClickHouse。 +1. 用器件模式构建 ClickHouse。在 Clang 中,可以通过传递 `-fprofile-generate` 选项给 `CXXFLAGS` 来实现。 +2. 在样本工作负载上运行器件 ClickHouse。在这里,您需要使用您的常规工作负载。可以使用 [ClickBench](https://github.com/ClickHouse/ClickBench) 作为样本工作负载。ClickHouse 的器件模式可能运行较慢,因此要做好心理准备,并且不要在性能关键的环境中运行器件 ClickHouse。 +3. 再次使用 `-fprofile-use` 编译器标志和前一步收集的配置文件重新编译 ClickHouse。 -有关如何应用 PGO 的更详细指南,请参见 Clang [文档](https://clang.llvm.org/docs/UsersManual.html#profile-guided-optimization)。 +关于如何应用 PGO 的更详细指南在 Clang [documentation](https://clang.llvm.org/docs/UsersManual.html#profile-guided-optimization) 中。 如果您打算直接从生产环境中收集样本工作负载,我们建议尝试使用 Sampling PGO。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/optimizing-performance/profile-guided-optimization.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/optimizing-performance/profile-guided-optimization.md.hash index 45c17866961..c3d2a0fbd9a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/optimizing-performance/profile-guided-optimization.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/optimizing-performance/profile-guided-optimization.md.hash @@ -1 +1 @@ -6ad38f260a58ae0c +8fca7bc9d2b14d07 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/optimizing-performance/sampling-query-profiler.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/optimizing-performance/sampling-query-profiler.md index ebd025167c0..01e925b96de 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/optimizing-performance/sampling-query-profiler.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/optimizing-performance/sampling-query-profiler.md @@ -1,9 +1,10 @@ --- -'description': 'ClickHouse 中抽样查询分析器工具的文档' +'description': 'ClickHouse 中采样查询分析器工具的文档' 'sidebar_label': '查询分析' 'sidebar_position': 54 'slug': '/operations/optimizing-performance/sampling-query-profiler' -'title': '抽样查询分析器' +'title': '采样查询分析器' +'doc_type': 'reference' --- import SelfManaged from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_self_managed_only_no_roadmap.md'; @@ -11,11 +12,11 @@ import SelfManaged from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_s # 采样查询分析器 -ClickHouse 运行采样分析器,允许分析查询执行。使用分析器,您可以找到在查询执行期间使用最频繁的源代码例程。您可以跟踪 CPU 时间和包括空闲时间在内的实际经过时间。 +ClickHouse 运行采样分析器,允许分析查询执行。使用分析器可以找到在查询执行过程中使用最频繁的源代码例程。您可以跟踪 CPU 时间和总时钟时间,包括空闲时间。 -查询分析器在 ClickHouse Cloud 中自动启用,您可以按如下方式运行示例查询 +查询分析器在 ClickHouse Cloud 中自动启用,您可以按如下方式运行示例查询: -:::note 如果您在 ClickHouse Cloud 中运行以下查询,请确保将 `FROM system.trace_log` 更改为 `FROM clusterAllReplicas(default, system.trace_log)` 以从集群的所有节点选择 +:::note 如果您在 ClickHouse Cloud 中运行以下查询,请确保将 `FROM system.trace_log` 更改为 `FROM clusterAllReplicas(default, system.trace_log)` 以从集群的所有节点中选择 ::: ```sql @@ -34,13 +35,13 @@ SETTINGS allow_introspection_functions = 1 - 设置服务器配置的 [trace_log](../../operations/server-configuration-parameters/settings.md#trace_log) 部分。 - 该部分配置了包含分析器功能结果的 [trace_log](/operations/system-tables/trace_log) 系统表。它默认配置。请记住,该表中的数据仅对运行中的服务器有效。服务器重启后,ClickHouse 不会清理该表,所有存储的虚拟内存地址可能会变得无效。 + 此部分配置包含分析器功能结果的 [trace_log](/operations/system-tables/trace_log) 系统表。默认情况下已配置。请记住,此表中的数据仅对正在运行的服务器有效。服务器重启后,ClickHouse 不会清理该表,所有存储的虚拟内存地址可能变得无效。 - 设置 [query_profiler_cpu_time_period_ns](../../operations/settings/settings.md#query_profiler_cpu_time_period_ns) 或 [query_profiler_real_time_period_ns](../../operations/settings/settings.md#query_profiler_real_time_period_ns) 设置。这两个设置可以同时使用。 - 这些设置允许您配置分析器定时器。由于这些是会话设置,您可以获得整个服务器、单个用户或用户配置文件、交互会话和每个单独查询的不同采样频率。 + 这些设置允许您配置分析器计时器。由于这些是会话设置,您可以为整个服务器、各个用户或用户配置、您的交互式会话以及每个单独的查询获得不同的采样频率。 -默认的采样频率为每秒一个样本,同时启用 CPU 和实际定时器。该频率可以收集关于 ClickHouse 集群的足够信息。同时,使用该频率时,分析器不会影响 ClickHouse 服务器的性能。如果您需要分析每个单独的查询,建议使用更高的采样频率。 +默认采样频率为每秒一个样本,并且启用了 CPU 和实际计时器。此频率允许收集有关 ClickHouse 集群的足够信息。同时,使用此频率时,分析器不会影响 ClickHouse 服务器的性能。如果您需要分析每个单独的查询,请尝试使用更高的采样频率。 要分析 `trace_log` 系统表: @@ -48,24 +49,24 @@ SETTINGS allow_introspection_functions = 1 - 通过 [allow_introspection_functions](../../operations/settings/settings.md#allow_introspection_functions) 设置允许内省函数。 - 出于安全原因,内省函数默认是禁用的。 + 出于安全原因,内省函数默认情况下是禁用的。 -- 使用 `addressToLine`、`addressToLineWithInlines`、`addressToSymbol` 和 `demangle` [内省函数](../../sql-reference/functions/introspection.md) 获取 ClickHouse 代码中的函数名称及其位置。要获取某个查询的分析结果,您需要从 `trace_log` 表中汇总数据。您可以按单个函数或整个堆栈跟踪汇总数据。 +- 使用 `addressToLine`、`addressToLineWithInlines`、`addressToSymbol` 以及 `demangle` [内省函数](../../sql-reference/functions/introspection.md) 获取 ClickHouse 代码中函数名称及其位置。要获取某个查询的配置文件,您需要聚合来自 `trace_log` 表的数据。您可以按单个函数或整个堆栈跟踪聚合数据。 如果您需要可视化 `trace_log` 信息,可以尝试 [flamegraph](/interfaces/third-party/gui#clickhouse-flamegraph) 和 [speedscope](https://github.com/laplab/clickhouse-speedscope)。 ## 示例 {#example} -在此示例中,我们: +在本示例中,我们: -- 按查询标识符和当前日期过滤 `trace_log` 数据。 +- 通过查询标识符和当前日期过滤 `trace_log` 数据。 -- 按堆栈跟踪汇总。 +- 通过堆栈跟踪进行聚合。 - 使用内省函数,我们将获得以下报告: - - 符号名称和相应的源代码函数。 - - 这些函数的源代码位置。 + - 符号名称和对应的源代码函数。 + - 这些函数的源代码位置。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/optimizing-performance/sampling-query-profiler.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/optimizing-performance/sampling-query-profiler.md.hash index 870e251c13f..53f233fd579 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/optimizing-performance/sampling-query-profiler.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/optimizing-performance/sampling-query-profiler.md.hash @@ -1 +1 @@ -4a4afb1d451e7059 +4246ecee300ead34 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/performance-test.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/performance-test.md index 67ab33ad86a..02faa23533f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/performance-test.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/performance-test.md @@ -1,9 +1,10 @@ --- -'description': '使用 ClickHouse 进行硬件性能测试和基准测试的指南' +'description': '使用 ClickHouse 测试和基准测试硬件性能的指南' 'sidebar_label': '测试硬件' 'sidebar_position': 54 'slug': '/operations/performance-test' 'title': '如何使用 ClickHouse 测试您的硬件' +'doc_type': 'guide' --- import SelfManaged from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_self_managed_only_no_roadmap.md'; @@ -27,6 +28,6 @@ chmod a+x ./hardware.sh ./hardware.sh ``` -3. 复制输出并发送至 feedback@clickhouse.com +3. 复制输出并发送到 feedback@clickhouse.com -所有结果都发布在这里: https://clickhouse.com/benchmark/hardware/ +所有结果都发布在这里: https://clickhouse.com/benchmark/hardware/ diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/performance-test.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/performance-test.md.hash index d9a9e00f8fb..2f1152096b1 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/performance-test.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/performance-test.md.hash @@ -1 +1 @@ -e584133967b119c1 +90db74cd394533f7 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/query-cache.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/query-cache.md index f184bb28867..934ec395d20 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/query-cache.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/query-cache.md @@ -4,39 +4,37 @@ 'sidebar_position': 65 'slug': '/operations/query-cache' 'title': '查询缓存' +'doc_type': 'guide' --- # 查询缓存 -查询缓存允许仅计算一次 `SELECT` 查询,并直接从缓存中服务后续相同查询的执行。 -根据查询的类型,这可以显著减少 ClickHouse 服务器的延迟和资源消耗。 +查询缓存允许只计算一次 `SELECT` 查询,并直接从缓存中服务后续相同查询的执行。根据查询类型,这可以显著减少 ClickHouse 服务器的延迟和资源消耗。 ## 背景、设计和限制 {#background-design-and-limitations} -查询缓存通常可以视为具有事务一致性或不一致性。 +查询缓存通常可以分为事务一致和不一致的两种。 -- 在事务一致性缓存中,当 `SELECT` 查询的结果发生变化或可能发生变化时,数据库会使缓存的查询结果失效(丢弃)。 - 在 ClickHouse 中,更改数据的操作包括对表的插入/更新/删除或合并。事务一致性缓存特别适合 OLTP 数据库,例如 +- 在事务一致的缓存中,如果 `SELECT` 查询的结果发生变化或可能发生变化,数据库会使缓存的查询结果失效(丢弃)。在 ClickHouse 中,更改数据的操作包括对表的插入/更新/删除或合并操作。事务一致的缓存特别适合 OLTP 数据库,例如 [MySQL](https://dev.mysql.com/doc/refman/5.6/en/query-cache.html)(在 v8.0 后移除了查询缓存)和 [Oracle](https://docs.oracle.com/database/121/TGDBA/tune_result_cache.htm)。 -- 在事务不一致性缓存中,可以接受查询结果的轻微不准确性,假设所有缓存条目在一定期限后会过期(例如 1 分钟),并且在此期间基础数据变化很小。 - 这种方法总体上更适合 OLAP 数据库。一个使用事务不一致性缓存的示例是,同时由多个用户访问的报告工具中的每小时销售报告。销售数据通常变化缓慢,数据库只需要计算报告一次(由第一次 `SELECT` 查询表示)。后续查询可以直接从查询缓存中提供。在这个例子中,合理的有效期可以是 30 分钟。 +- 在事务不一致的缓存中,查询结果的轻微不准确是可以接受的,前提是所有缓存条目都有一个有效期,超过这一期后将过期(例如 1 分钟),而且在此期间底层数据变化很小。这种方法总体上更适合 OLAP 数据库。作为一个足够的事务不一致缓存的示例,考虑在报告工具中的每小时销售报告,该报告被多个用户同时访问。销售数据的变化通常很慢,以至于数据库只需要计算一次报告(由第一次 `SELECT` 查询表示)。后续的查询可以直接从查询缓存中获取。在这个例子中,一个合理的有效期可以是 30 分钟。 -传统上,不一致性缓存由与数据库互动的客户端工具或代理包(例如 -[chproxy](https://www.chproxy.org/configuration/caching/))提供。因此,相同的缓存逻辑和配置通常被重复实现。随着 ClickHouse 查询缓存的推出,缓存逻辑迁移到服务器端。这降低了维护工作量,并避免了冗余。 +事务不一致缓存通常由客户端工具或代理包(例如 +[chproxy](https://www.chproxy.org/configuration/caching/))与数据库进行交互提供。因此,相同的缓存逻辑和配置通常是重复的。随着 ClickHouse 查询缓存的出现,缓存逻辑转移到服务器端。这减少了维护工作并避免了冗余。 -## 配置设置及使用 {#configuration-settings-and-usage} +## 配置设置和使用 {#configuration-settings-and-usage} :::note -在 ClickHouse Cloud 中,您必须使用 [查询级别设置](/operations/settings/query-level) 来编辑查询缓存设置。当前不支持编辑 [配置级别设置](/operations/configuration-files)。 +在 ClickHouse Cloud 中,您必须使用 [查询级设置](/operations/settings/query-level) 来编辑查询缓存设置。当前不支持编辑 [配置级设置](/operations/configuration-files)。 ::: :::note -[clickhouse-local](utilities/clickhouse-local.md) 一次运行单个查询。由于查询结果缓存没有意义,因此在 clickhouse-local 中禁用了查询结果缓存。 +[clickhouse-local](utilities/clickhouse-local.md) 一次运行单个查询。由于查询结果缓存没有意义,因此在 clickhouse-local 中禁用查询结果缓存。 ::: -设置 [use_query_cache](/operations/settings/settings#use_query_cache) 可控制当前会话的特定查询或所有查询是否应使用查询缓存。例如,查询的第一次执行 +设置 [use_query_cache](/operations/settings/settings#use_query_cache) 可用于控制当前会话中特定查询或所有查询是否应使用查询缓存。例如,查询的第一次执行 ```sql SELECT some_expensive_calculation(column_1, column_2) @@ -44,13 +42,13 @@ FROM table SETTINGS use_query_cache = true; ``` -将会将查询结果存储在查询缓存中。后续相同查询的执行(同样带有参数 `use_query_cache = true`)将从缓存中读取计算结果并立即返回。 +将结果存储在查询缓存中。后续相同查询的执行(参数 `use_query_cache = true`)将从缓存中读取已计算的结果并立即返回。 :::note -设置 `use_query_cache` 及所有其他与查询缓存相关的设置仅对独立的 `SELECT` 语句生效。特别是,由 `CREATE VIEW AS SELECT [...] SETTINGS use_query_cache = true` 创建的视图的 `SELECT` 结果不会被缓存,除非此 `SELECT` 语句使用 `SETTINGS use_query_cache = true` 执行。 +设置 `use_query_cache` 及所有其他与查询缓存相关的设置仅对独立的 `SELECT` 语句有效。特别是,使用 `CREATE VIEW AS SELECT [...] SETTINGS use_query_cache = true` 创建的视图的 `SELECT` 的结果不会被缓存,除非该 `SELECT` 语句使用 `SETTINGS use_query_cache = true` 运行。 ::: -可以使用设置 [enable_writes_to_query_cache](/operations/settings/settings#enable_writes_to_query_cache) 和 [enable_reads_from_query_cache](/operations/settings/settings#enable_reads_from_query_cache)(默认为 `true`)更详细地配置缓存的使用方式。前者设置控制查询结果是否存储在缓存中,而后者设置决定数据库是否应尝试从缓存中检索查询结果。例如,以下查询只会被被动地使用缓存,即尝试从中读取,但不将结果存储在其中: +可以使用设置 [enable_writes_to_query_cache](/operations/settings/settings#enable_writes_to_query_cache) 和 [enable_reads_from_query_cache](/operations/settings/settings#enable_reads_from_query_cache) (默认均为 `true`)更详细地配置缓存的使用。前者设置控制是否将查询结果存储在缓存中,而后者设置决定数据库是否应该尝试从缓存中检索查询结果。例如,以下查询将被动使用缓存,即尝试从中读取但不将其结果存储到其中: ```sql SELECT some_expensive_calculation(column_1, column_2) @@ -58,17 +56,17 @@ FROM table SETTINGS use_query_cache = true, enable_writes_to_query_cache = false; ``` -为了最大程度地控制,通常建议仅在特定查询中提供设置 `use_query_cache`、`enable_writes_to_query_cache` 和 `enable_reads_from_query_cache`。也可以在用户或配置文件级别启用缓存(例如,通过 `SET use_query_cache = true`),但应注意,此时所有 `SELECT` 查询可能返回缓存结果。 +为了获得最大的控制,通常建议仅在特定查询中提供设置 `use_query_cache`、`enable_writes_to_query_cache` 和 `enable_reads_from_query_cache`。也可以通过 `SET use_query_cache = true` 在用户或配置文件级别启用缓存,但应记住,这样所有 `SELECT` 查询可能会返回缓存结果。 -查询缓存可以使用语句 `SYSTEM DROP QUERY CACHE` 清除。查询缓存的内容显示在系统表 [system.query_cache](system-tables/query_cache.md) 中。自数据库启动以来的查询缓存命中和未命中次数作为事件 "QueryCacheHits" 和 "QueryCacheMisses" 显示在系统表 [system.events](system-tables/events.md) 中。这两个计数器仅在 `use_query_cache = true` 设置下运行的 `SELECT` 查询中更新,其他查询不会影响 "QueryCacheMisses"。系统表 [system.query_log](system-tables/query_log.md) 中的字段 `query_cache_usage` 显示每个执行的查询其结果是否被写入或从查询缓存中读取。系统表 [system.asynchronous_metrics](system-tables/asynchronous_metrics.md) 中的异步指标 "QueryCacheEntries" 和 "QueryCacheBytes" 显示查询缓存当前包含多少条目/字节。 +可以使用语句 `SYSTEM DROP QUERY CACHE` 清除查询缓存。查询缓存的内容在系统表 [system.query_cache](system-tables/query_cache.md) 中显示。查询缓存命中的次数和未命中的次数自数据库启动以来作为事件 "QueryCacheHits" 和 "QueryCacheMisses" 显示在系统表 [system.events](system-tables/events.md) 中。这两个计数器仅在设置为 `use_query_cache = true` 的 `SELECT` 查询中更新,其他查询不影响 "QueryCacheMisses"。系统表 [system.query_log](system-tables/query_log.md) 中的字段 `query_cache_usage` 显示每个执行的查询是否将查询结果写入或从查询缓存中读取。系统表 [system.metrics](system-tables/metrics.md) 中的指标 `QueryCacheEntries` 和 `QueryCacheBytes` 显示查询缓存当前包含多少条目/字节。 -查询缓存每个 ClickHouse 服务器进程存在一次。然而,由于默认情况下,不同用户之间不共享缓存结果。这可以更改(见下文),但出于安全原因,不建议这样做。 +查询缓存在每个 ClickHouse 服务器进程中存在一次。然而,缓存结果默认不在用户之间共享。这可以更改(见下文),但出于安全原因,不建议这样做。 -查询结果在查询缓存中的引用是基于查询的 [抽象语法树 (AST)](https://en.wikipedia.org/wiki/Abstract_syntax_tree)。这意味着缓存对大小写是无关的,例如 `SELECT 1` 和 `select 1` 被视为相同的查询。为了使匹配更自然,与查询缓存相关的所有查询级别设置都从 AST 中删除。 +查询结果在查询缓存中的引用是通过其查询的 [抽象语法树 (AST)](https://en.wikipedia.org/wiki/Abstract_syntax_tree) 实现的。这意味着缓存对大小写不敏感,例如 `SELECT 1` 和 `select 1` 被视为相同的查询。为了使匹配更加自然,与查询缓存相关的所有查询级设置从 AST 中移除。 -如果查询由于异常或用户取消而中止,则不会将条目写入查询缓存。 +如果查询由于异常或用户取消而中止,则不会在查询缓存中写入条目。 -可以使用不同的 [服务器配置选项](/operations/server-configuration-parameters/settings#query_cache) 配置查询缓存的大小(以字节为单位)、最大缓存条目数量以及单个缓存条目的最大大小(以字节和记录为单位)。 +查询缓存的大小(以字节为单位)、最大缓存条目数和单个缓存条目的最大大小(以字节和记录数表示)可以使用不同的 [服务器配置选项](/operations/server-configuration-parameters/settings#query_cache) 进行配置。 ```xml @@ -79,9 +77,7 @@ SETTINGS use_query_cache = true, enable_writes_to_query_cache = false; ``` -也可以使用 [设置配置文件](settings/settings-profiles.md) 和 [设置约束](settings/constraints-on-settings.md) 限制单个用户的缓存使用。例如,您可以限制用户在查询缓存中分配的最大内存量(以字节为单位)和最大的存储查询结果数量。为此,首先在 `users.xml` 的用户配置文件中提供配置 -[query_cache_max_size_in_bytes](/operations/settings/settings#query_cache_max_size_in_bytes) 和 -[query_cache_max_entries](/operations/settings/settings#query_cache_max_entries),然后使这两个设置为只读: +也可以使用 [设置配置文件](settings/settings-profiles.md) 和 [设置约束](settings/constraints-on-settings.md) 来限制个别用户的缓存使用情况。更具体地说,可以限制用户在查询缓存中分配的最大内存量(以字节为单位)和存储的查询结果的最大数量。为此,首先在 `users.xml` 中的用户配置文件中提供配置 [query_cache_max_size_in_bytes](/operations/settings/settings#query_cache_max_size_in_bytes) 和 [query_cache_max_entries](/operations/settings/settings#query_cache_max_entries),然后将这两个设置设为只读: ```xml @@ -103,8 +99,7 @@ SETTINGS use_query_cache = true, enable_writes_to_query_cache = false; ``` -要定义查询必须至少运行多长时间才能使结果缓存,可以使用设置 -[query_cache_min_query_duration](/operations/settings/settings#query_cache_min_query_duration)。例如,查询的结果 +要定义查询至少必须运行多长时间才能使其结果缓存,可以使用设置 [query_cache_min_query_duration](/operations/settings/settings#query_cache_min_query_duration)。例如,查询的结果 ```sql SELECT some_expensive_calculation(column_1, column_2) @@ -112,13 +107,13 @@ FROM table SETTINGS use_query_cache = true, query_cache_min_query_duration = 5000; ``` -仅在查询运行超过 5 秒时才会被缓存。还可以指定查询需要运行多少次,直到其结果被缓存 - 为此使用设置 [query_cache_min_query_runs](/operations/settings/settings#query_cache_min_query_runs)。 +仅在查询运行超过 5 秒时才会被缓存。也可以指定查询需要运行多少次以便缓存其结果 - 为此使用设置 [query_cache_min_query_runs](/operations/settings/settings#query_cache_min_query_runs)。 -查询缓存中的条目在一定时间后变得过时(生存时间)。默认情况下,此期限为 60 秒,但可以使用设置 [query_cache_ttl](/operations/settings/settings#query_cache_ttl) 在会话、配置文件或查询级别指定其他值。查询缓存会“懒惰”地逐出条目,即,当条目变得过时时,不会立即从缓存中删除。相反,当新条目要插入查询缓存时,数据库会检查缓存是否有足够的可用空间。如果没有,数据库会尝试删除所有过期条目。如果缓存仍然没有足够的可用空间,则不插入新条目。 +查询缓存中的条目在一定时间后变得过期(生存时间)。默认情况下,这一时期为 60 秒,但可以通过设置 [query_cache_ttl](/operations/settings/settings#query_cache_ttl) 在会话、配置文件或查询级别上指定不同的值。查询缓存懒惰地驱逐条目,即当条目变得过期时,它不会立即从缓存中删除。相反,当要将新条目插入查询缓存时,数据库会检查缓存中是否有足够的可用空间。如果没有,数据库将尝试删除所有过期条目。如果缓存仍然没有足够的可用空间,则不插入新条目。 -查询缓存中的条目默认是压缩的。这减少了总体内存消耗,但导致写入/读取查询缓存时速度较慢。要禁用压缩,请使用设置 [query_cache_compress_entries](/operations/settings/settings#query_cache_compress_entries)。 +查询缓存中的条目默认是压缩的。这降低了整体内存消耗,但以写入到查询缓存和从查询缓存读取会变慢为代价。要禁用压缩,请使用设置 [query_cache_compress_entries](/operations/settings/settings#query_cache_compress_entries)。 -有时保留同一查询的多个结果缓存是有用的。可以通过使用设置 [query_cache_tag](/operations/settings/settings#query_cache_tag) 来实现,该设置充当查询缓存条目的标签(或命名空间)。查询缓存认为带有不同标签的相同查询的结果是不同的。 +有时,保留相同查询的多个结果缓存是有用的。这可以通过使用设置 [query_cache_tag](/operations/settings/settings#query_cache_tag) 来实现,该设置充当查询缓存条目的标签(或命名空间)。查询缓存将具有不同标签的相同查询的结果视为不同的。 创建三个不同查询缓存条目的示例: @@ -130,36 +125,33 @@ SELECT 1 SETTINGS use_query_cache = true, query_cache_tag = 'tag 2'; 要仅从查询缓存中删除带有标签 `tag` 的条目,可以使用语句 `SYSTEM DROP QUERY CACHE TAG 'tag'`。 -ClickHouse 以 [max_block_size](/operations/settings/settings#max_block_size) 行的块读取表数据。由于过滤、聚合等,结果块通常比 'max_block_size' 小得多,但也有一些情况它们会大得多。设置 [query_cache_squash_partial_results](/operations/settings/settings#query_cache_squash_partial_results)(默认启用)控制在插入查询结果缓存之前,结果块是被压缩(如果它们很小)还是拆分(如果它们很大)为 'max_block_size' 大小的块。这会降低写入查询缓存的性能,但提高缓存条目的压缩率,并在稍后从查询缓存中提供查询结果时提供更自然的块粒度。 - -因此,查询缓存对每个查询存储多个(部分)结果块。尽管这种行为是一个合适的默认设置,但可以使用设置 [query_cache_squash_partial_results](/operations/settings/settings#query_cache_squash_partial_results) 抑制该行为。 - -此外,具有非确定性函数的查询结果默认是不被缓存的。这类函数包括 -- 用于访问字典的函数:[`dictGet()`](/sql-reference/functions/ext-dict-functions#dictget-dictgetordefault-dictgetornull) 等。 -- [用户定义函数](../sql-reference/statements/create/function.md) 在其 XML 定义中没有标签 `true`, -- 返回当前日期或时间的函数:[`now()`](../sql-reference/functions/date-time-functions.md#now), - [`today()`](../sql-reference/functions/date-time-functions.md#today), - [`yesterday()`](../sql-reference/functions/date-time-functions.md#yesterday) 等, -- 返回随机值的函数:[`randomString()`](../sql-reference/functions/random-functions.md#randomString), - [`fuzzBits()`](../sql-reference/functions/random-functions.md#fuzzBits) 等, -- 结果依赖于用于查询处理的内部块的大小和顺序的函数: - [`nowInBlock()`](../sql-reference/functions/date-time-functions.md#nowInBlock) 等, - [`rowNumberInBlock()`](../sql-reference/functions/other-functions.md#rowNumberInBlock), - [`runningDifference()`](../sql-reference/functions/other-functions.md#runningDifference), - [`blockSize()`](../sql-reference/functions/other-functions.md#blockSize) 等, -- 依赖于环境的函数:[`currentUser()`](../sql-reference/functions/other-functions.md#currentUser), - [`queryID()`](/sql-reference/functions/other-functions#queryid), +ClickHouse 以 [max_block_size](/operations/settings/settings#max_block_size) 行的数据块读取表数据。由于过滤、聚合等,结果块通常比 "max_block_size" 小,但在某些情况下,它们可能会大得多。设置 [query_cache_squash_partial_results](/operations/settings/settings#query_cache_squash_partial_results)(默认启用)控制结果块在插入查询结果缓存之前是被压缩(如果它们很小)还是分割成 "max_block_size" 大小的块。虽然这会降低写入查询缓存的性能,但会提高缓存条目的压缩率,并在之后从查询缓存提供查询结果时提供更自然的块粒度。 + +因此,查询缓存为每个查询存储多个(部分)结果块。虽然这种行为是一个良好的默认设置,但可以使用设置 [query_cache_squash_partial_results](/operations/settings/settings#query_cache_squash_partial_results) 来抑制。 + +此外,使用非确定性函数的查询结果默认情况下不会被缓存。这些函数包括: +- 访问字典的函数: [`dictGet()`](/sql-reference/functions/ext-dict-functions#dictget-dictgetordefault-dictgetornull) 等。 +- 在其 XML 定义中没有标签 `true` 的 [用户定义函数](../sql-reference/statements/create/function.md)。 +- 返回当前日期或时间的函数: [`now()`](../sql-reference/functions/date-time-functions.md#now), + [`today()`](../sql-reference/functions/date-time-functions.md#today), + [`yesterday()`](../sql-reference/functions/date-time-functions.md#yesterday) 等。 +- 返回随机值的函数: [`randomString()`](../sql-reference/functions/random-functions.md#randomString), + [`fuzzBits()`](../sql-reference/functions/random-functions.md#fuzzBits) 等。 +- 结果依赖于查询处理所使用的内部块的大小和顺序的函数: [`nowInBlock()`](../sql-reference/functions/date-time-functions.md#nowInBlock) 等, + [`rowNumberInBlock()`](../sql-reference/functions/other-functions.md#rowNumberInBlock), + [`runningDifference()`](../sql-reference/functions/other-functions.md#runningDifference), + [`blockSize()`](../sql-reference/functions/other-functions.md#blockSize) 等。 +- 依赖于环境的函数: [`currentUser()`](../sql-reference/functions/other-functions.md#currentUser), + [`queryID()`](/sql-reference/functions/other-functions#queryid), [`getMacro()`](../sql-reference/functions/other-functions.md#getMacro) 等。 -要强制缓存具有非确定性函数结果的查询,请使用设置 -[query_cache_nondeterministic_function_handling](/operations/settings/settings#query_cache_nondeterministic_function_handling)。 +要强制缓存非确定性函数查询的结果,请使用设置 [query_cache_nondeterministic_function_handling](/operations/settings/settings#query_cache_nondeterministic_function_handling)。 -涉及系统表(例如 [system.processes](system-tables/processes.md)` 或 -[information_schema.tables](system-tables/information_schema.md))的查询结果默认不被缓存。要强制缓存包含系统表结果的查询,可以使用设置 [query_cache_system_table_handling](/operations/settings/settings#query_cache_system_table_handling)。 +涉及系统表的查询结果(例如 [system.processes](system-tables/processes.md) 或 +[information_schema.tables](system-tables/information_schema.md))默认情况下不会被缓存。要强制缓存涉及系统表查询的结果,请使用设置 [query_cache_system_table_handling](/operations/settings/settings#query_cache_system_table_handling)。 -最后,由于安全原因,查询缓存中的条目不会在用户之间共享。例如,用户 A 不得能够通过以另一用户 B 的身份运行相同查询而绕过表上的行策略,而该用户 B 没有这样政策。然而,如果必要,可以通过提供设置 -[query_cache_share_between_users](/operations/settings/settings#query_cache_share_between_users) 将缓存条目标记为其他用户可访问(即共享)。 +最后,由于安全原因,查询缓存中的条目不在用户之间共享。例如,用户 A 不能通过执行与另一用户 B 相同的查询来绕过表上的行策略,而用户 B 不存在这样的策略。但是,如果需要,可以通过提供设置 [query_cache_share_between_users](/operations/settings/settings#query_cache_share_between_users) 来标记缓存条目可被其他用户访问(即共享)。 ## 相关内容 {#related-content} -- 博客: [介绍 ClickHouse 查询缓存](https://clickhouse.com/blog/introduction-to-the-clickhouse-query-cache-and-design) +- 博客:[介绍 ClickHouse 查询缓存](https://clickhouse.com/blog/introduction-to-the-clickhouse-query-cache-and-design) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/query-cache.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/query-cache.md.hash index 0a732e141ec..a48c88379fe 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/query-cache.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/query-cache.md.hash @@ -1 +1 @@ -694a4fc2044bbb5c +7f2478491ef9d3fe diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/query-condition-cache.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/query-condition-cache.md index a2938348dc3..1de84d5a572 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/query-condition-cache.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/query-condition-cache.md @@ -1,43 +1,48 @@ --- -'description': '在 ClickHouse 中使用和配置查询条件缓存功能的指南' -'sidebar_label': 'Query Condition Cache' +'description': '在ClickHouse中使用和配置查询条件缓存功能的指南' +'sidebar_label': '查询条件缓存' 'sidebar_position': 64 'slug': '/operations/query-condition-cache' 'title': '查询条件缓存' +'doc_type': 'guide' --- # 查询条件缓存 -许多现实世界的工作负载涉及对相同或几乎相同数据的重复查询(例如,之前存在的数据加上新数据)。 -ClickHouse提供了多种优化技术以优化此类查询模式。 -一种可能性是通过使用索引结构(例如主键索引、跳过索引、投影)或预计算(物化视图)来调整物理数据布局。 -另一种可能性是使用ClickHouse的 [查询缓存](query-cache.md) 来避免重复的查询评估。 -第一种方法的缺点是需要数据库管理员的手动干预和监控。 -第二种方法可能返回陈旧的结果(因为查询缓存在事务上不一致),根据用例的不同,这可能是可接受的,也可能不可接受。 +:::note +查询条件缓存仅在 [enable_analyzer](https://clickhouse.com/docs/operations/settings/settings#enable_analyzer) 设置为 true 时有效,该值为默认值。 +::: + +许多实际工作负载涉及对相同或几乎相同数据的重复查询(例如,先前存在的数据加上新数据)。 +ClickHouse 提供了多种优化技术来优化这些查询模式。 +一种可能性是使用索引结构(例如,主键索引、跳过索引、投影)或预计算(物化视图)来调整物理数据布局。 +另一种可能性是使用 ClickHouse 的 [查询缓存](query-cache.md) 来避免重复查询评估。 +第一种方法的缺点在于需要数据库管理员手动干预和监控。 +第二种方法可能返回过时的结果(因为查询缓存在事务上并不一致),这可能根据具体用例是可以接受的,也可能不可接受。 查询条件缓存为这两个问题提供了优雅的解决方案。 -它基于这样的思想:在相同数据上评估过滤条件(例如,`WHERE col = 'xyz'`)将始终返回相同的结果。 -更具体地说,查询条件缓存会记住每个评估过的过滤器和每个粒度(= 默认情况下为8192行的块)中是否没有行满足过滤条件。 -该信息以单个比特记录:0比特表示没有行匹配过滤条件,而1比特表示至少存在一行匹配。 -在前一种情况下,ClickHouse可以在过滤评估期间跳过相应的粒度;在后一种情况下,必须加载和评估该粒度。 +它的基础理念是,在相同数据上评估一个过滤条件(例如,`WHERE col = 'xyz'`)将始终返回相同的结果。 +更具体地说,查询条件缓存会记住每个评估的过滤器和每个颗粒(= 默认情况下为8192行的区块)是否在颗粒中没有行满足过滤条件。 +该信息被记录为一个单一的位:0位表示没有行匹配过滤,而1位则表示至少存在一个匹配的行。 +在前一种情况下,ClickHouse 可以在过滤评估期间跳过相应的颗粒;在后一种情况下,必须加载并评估该颗粒。 -当满足以下三个先决条件时,查询条件缓存是有效的: -- 首先,工作负载必须重复评估相同的过滤条件。这在查询多次重复时自然发生,但也可能发生在两个查询共享相同过滤器的情况下,例如 `SELECT product FROM products WHERE quality > 3` 和 `SELECT vendor, count() FROM products WHERE quality > 3`。 -- 第二,大多数数据是不可变的,即在查询之间不发生变化。这在ClickHouse中通常是这样,因为部分数据是不可变的,并且仅通过INSERT创建。 -- 第三,过滤器是选择性,即只有相对较少的行满足过滤条件。满足过滤条件的行越少,将记录的比特0的粒度越多(没有匹配的行),后续过滤评估中可以“修剪”的数据就越多。 +查询条件缓存在满足三个前提的情况下是有效的: +- 首先,工作负载必须反复评估相同的过滤条件。如果查询被多次重复,这将自然发生,但如果两个查询共享相同的过滤器,也可能发生,例如 `SELECT product FROM products WHERE quality > 3` 和 `SELECT vendor, count() FROM products WHERE quality > 3`。 +- 第二,大部分数据是不可变的,即在查询之间不会改变。由于分片是不可变的,并且仅通过 INSERT 创建,这在 ClickHouse 中通常是正确的。 +- 第三,过滤器是选择性的,即只有相对少数的行满足过滤条件。满足过滤条件的行越少,记录位0(没有匹配行)的颗粒就越多,从而可以在后续的过滤评估中“剪枝”更多数据。 ## 内存消耗 {#memory-consumption} -由于查询条件缓存每个过滤条件和粒度仅存储一个比特,因此它仅消耗很少的内存。 -查询条件缓存的最大大小可以通过服务器设置 [`query_condition_cache_size`](server-configuration-parameters/settings.md#query_condition_cache_size) 配置(默认:100 MB)。 -100 MB的缓存大小对应于100 * 1024 * 1024 * 8 = 838,860,800条目。 -由于每个条目代表一个标记(默认8192行),因此缓存可以覆盖单个列最多6,871,947,673,600(6.8万亿)行。 -在实践中,过滤器是在多个列上评估的,因此这个数字需要除以过滤的列数。 +由于查询条件缓存每个过滤条件和颗粒仅存储一个单一的位,因此它消耗的内存仅很少。 +查询条件缓存的最大大小可以通过服务器设置 [`query_condition_cache_size`](server-configuration-parameters/settings.md#query_condition_cache_size) 进行配置(默认:100 MB)。 +100 MB 的缓存大小对应于 100 * 1024 * 1024 * 8 = 838,860,800 条目。 +由于每个条目代表一个标记(默认情况下为8192行),因此缓存可以覆盖多达 6,871,947,673,600(6.8万亿)行的单列。 +在实践中,过滤在多个列上进行评估,因此该数字需要除以被过滤列的数量。 -## 配置设置和用途 {#configuration-settings-and-usage} +## 配置设置和使用 {#configuration-settings-and-usage} -设置 [use_query_condition_cache](settings/settings#use_query_condition_cache) 控制特定查询或当前会话的所有查询是否应利用查询条件缓存。 +设置 [use_query_condition_cache](settings/settings#use_query_condition_cache) 控制当前会话的特定查询或所有查询是否应利用查询条件缓存。 例如,查询的第一次执行 @@ -48,24 +53,24 @@ WHERE col1 = 'x' SETTINGS use_query_condition_cache = true; ``` -将存储不满足谓词的表范围。 -同样带有参数 `use_query_condition_cache = true` 的后续执行将利用查询条件缓存来扫描更少的数据。 +将存储不满足谓词的表的范围。 +相同查询的后续执行(同样带有参数 `use_query_condition_cache = true`)将利用查询条件缓存以减少扫描的数据量。 ## 管理 {#administration} -查询条件缓存在ClickHouse重启之间不会保留。 +查询条件缓存在 ClickHouse 重启之间不会保留。 要清除查询条件缓存,请运行 [`SYSTEM DROP QUERY CONDITION CACHE`](../sql-reference/statements/system.md#drop-query-condition-cache)。 -缓存的内容显示在系统表 [system.query_condition_cache](system-tables/query_condition_cache.md) 中。 -要计算当前查询条件缓存的大小(以MB为单位),请运行 `SELECT formatReadableSize(sum(entry_size)) FROM system.query_condition_cache`。 -如果您想检查单个过滤条件,可以查看 `system.query_condition_cache` 中的字段 `condition`。 -请注意,只有在查询以启用设置 [query_condition_cache_store_conditions_as_plaintext](settings/settings#query_condition_cache_store_conditions_as_plaintext) 的情况下,字段才会被填充。 +缓存的内容在系统表 [system.query_condition_cache](system-tables/query_condition_cache.md) 中显示。 +要计算查询条件缓存当前的大小(以 MB 为单位),请运行 `SELECT formatReadableSize(sum(entry_size)) FROM system.query_condition_cache`。 +如果您想调查单个过滤条件,可以检查 `system.query_condition_cache` 中的字段 `condition`。 +请注意,仅当查询在启用设置 [query_condition_cache_store_conditions_as_plaintext](settings/settings#query_condition_cache_store_conditions_as_plaintext) 下运行时,该字段才会被填充。 -自数据库启动以来查询条件缓存的命中数和未命中数显示为系统表 [system.events](system-tables/events.md) 中的事件 "QueryConditionCacheHits" 和 "QueryConditionCacheMisses"。 -这两个计数器仅在使用设置 `use_query_condition_cache = true` 的 `SELECT` 查询中更新,其它查询不会影响 "QueryCacheMisses"。 +自数据库启动以来的查询条件缓存命中和未命中的数量显示为系统表 [system.events](system-tables/events.md) 中的事件 "QueryConditionCacheHits" 和 "QueryConditionCacheMisses"。 +这两个计数器仅在带有设置 `use_query_condition_cache = true` 的 `SELECT` 查询中更新,其他查询不影响 "QueryCacheMisses"。 ## 相关内容 {#related-content} -- 博客:[介绍查询条件缓存](https://clickhouse.com/blog/introducing-the-clickhouse-query-condition-cache) -- [谓词缓存:面向云数据仓库的查询驱动二级索引(Schmidt等,2024)](https://doi.org/10.1145/3626246.3653395) +- 博客: [介绍查询条件缓存](https://clickhouse.com/blog/introducing-the-clickhouse-query-condition-cache) +- [谓词缓存:云数据仓库的查询驱动二级索引(Schmidt 等,2024)](https://doi.org/10.1145/3626246.3653395) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/query-condition-cache.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/query-condition-cache.md.hash index a66427f3eb1..7eec77366ff 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/query-condition-cache.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/query-condition-cache.md.hash @@ -1 +1 @@ -283bad4e8ae1c1bb +9ff13951a39138a5 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/quotas.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/quotas.md index 1c95ba9489e..39273897dd8 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/quotas.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/quotas.md @@ -4,23 +4,23 @@ 'sidebar_position': 51 'slug': '/operations/quotas' 'title': '配额' +'doc_type': 'guide' --- -:::note Quotas in ClickHouse Cloud -在 ClickHouse Cloud 中支持配额,但必须使用 [DDL 语法](/sql-reference/statements/create/quota) 创建。下面文档中的 XML 配置方法 **不支持**。 +:::note ClickHouse Cloud 中的配额 +ClickHouse Cloud 支持配额,但必须使用 [DDL 语法](/sql-reference/statements/create/quota) 创建。下面记录的 XML 配置方法 **不受支持**。 ::: -配额允许你限制一段时间内的资源使用或跟踪资源的使用情况。 -配额在用户配置中设置,通常为 'users.xml'。 +配额允许您限制在一段时间内的资源使用情况或跟踪资源的使用情况。配额在用户配置中设置,通常为 'users.xml'。 -系统还具有限制单个查询复杂度的功能。请参见 [查询复杂度限制](../operations/settings/query-complexity.md) 部分。 +系统还具有限制单个查询复杂性功能。请参见 [查询复杂性限制](../operations/settings/query-complexity.md) 部分。 -与查询复杂度限制相对,配额: +与查询复杂性限制相比,配额: -- 对在一段时间内可以运行的查询集施加限制,而不是限制单个查询。 -- 计算分布式查询处理所有远程服务器上消耗的资源。 +- 限制在一段时间内可以运行的查询集,而不是限制单个查询。 +- 考虑在所有远程服务器上进行分布式查询处理时消耗的资源。 -让我们看看 'users.xml' 文件中定义配额的部分。 +让我们看看定义配额的 'users.xml' 文件段落。 ```xml @@ -44,8 +44,7 @@ ``` -默认情况下,配额跟踪每小时的资源消耗,而不限制使用。 -每个时间段计算的资源消耗将在每次请求后输出到服务器日志中。 +默认情况下,配额跟踪每小时的资源消耗,没有限制使用。每个时间段计算的资源消耗会在每次请求后输出到服务器日志。 ```xml @@ -57,10 +56,12 @@ 1000 100 100 + 5000000 100 1000000000 100000000000 900 + 5 @@ -71,15 +72,17 @@ 10000 1000 5000000000 + 160000000000 500000000000 + 16000000000000 7200 ``` -对于 'statbox' 配额,每小时和每 24 小时(86,400 秒)设置限制。时间间隔的计算从一个实现定义的固定时刻开始。换句话说,24 小时的时间间隔并不一定从午夜开始。 +对于 'statbox' 配额,每小时和每 24 小时(86,400 秒)设置限制。时间间隔的计算从一个实现定义的固定时间点开始。换句话说,24 小时的间隔不一定从午夜开始。 -当时间间隔结束时,所有收集的值会被清除。在下一个小时,配额计算将重新开始。 +当时间间隔结束时,所有收集的值会被清空。下一个小时的配额计算将重新开始。 以下是可以限制的数量: @@ -93,13 +96,21 @@ `result_rows` – 作为结果返回的总行数。 -`read_rows` – 从表中读取以在所有远程服务器上运行查询的源行总数。 +`result_bytes` - 作为结果返回的总字节数。 -`execution_time` – 查询执行的总时间,以秒为单位(墙时)。 +`read_rows` – 从表中读取的用于在所有远程服务器上运行查询的源行总数。 -如果在至少一个时间间隔内超过限制,会抛出包含超出限制的文本的异常,说明哪个限制被超出了,在哪个时间间隔,以及何时开始新的时间间隔(可以再次发送查询时)。 +`read_bytes` - 从表中读取的用于在所有远程服务器上运行查询的总字节数。 -配额可以使用 “配额键” 功能独立报告多个键的资源。以下是这一点的示例: +`written_bytes` - 写入操作的总字节数。 + +`execution_time` – 查询执行的总时间,以秒为单位(实际时间)。 + +`failed_sequential_authentications` - 发生的顺序认证错误的总数。 + +如果至少在一个时间间隔内超过限制,将抛出异常,文本中将说明超出限制的内容、对应的时间间隔,以及新的时间间隔何时开始(何时可以再次发送查询)。 + +配额可以使用“配额键”功能独立报告多个键的资源。以下是一个示例: ```xml @@ -116,12 +127,12 @@ ``` -配额在配置的 'users' 部分分配给用户。请参见“访问权限”部分。 +配额分配给配置的 'users' 部分的用户。请参见“访问权限”部分。 -对于分布式查询处理,累积的总量存储在请求者服务器上。因此,如果用户转到另一台服务器,则那里的配额将 “重新开始”。 +对于分布式查询处理,累积的数量存储在请求服务器上。因此,如果用户转到另一服务器,则该服务器上的配额将“重新开始”。 -当服务器重新启动时,配额将被重置。 +当服务器重启时,配额将被重置。 -## Related Content {#related-content} +## 相关内容 {#related-content} -- 博客: [使用 ClickHouse 构建单页应用程序](https://clickhouse.com/blog/building-single-page-applications-with-clickhouse-and-http) +- 博客: [使用 ClickHouse 构建单页面应用](https://clickhouse.com/blog/building-single-page-applications-with-clickhouse-and-http) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/quotas.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/quotas.md.hash index fbe1600061c..1c9eed58496 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/quotas.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/quotas.md.hash @@ -1 +1 @@ -afc97dba2940c0f2 +5147c1a9a993556f diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/server-configuration-parameters/_server_settings_outside_source.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/server-configuration-parameters/_server_settings_outside_source.md index 4fb1424b907..49f7dcc8c91 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/server-configuration-parameters/_server_settings_outside_source.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/server-configuration-parameters/_server_settings_outside_source.md @@ -1,17 +1,12 @@ ---- -null -... ---- - ## asynchronous_metric_log {#asynchronous_metric_log} 在 ClickHouse Cloud 部署中默认启用。 -如果该设置在您的环境中默认未启用,具体取决于 ClickHouse 的安装方式,您可以按照以下说明启用或禁用它。 +如果在您的环境中默认未启用此设置,您可以根据 ClickHouse 的安装方式,按照以下说明启用或禁用它。 **启用** -要手动打开异步指标日志历史收集 [`system.asynchronous_metric_log`](../../operations/system-tables/asynchronous_metric_log.md),请创建 `/etc/clickhouse-server/config.d/asynchronous_metric_log.xml`,内容如下: +要手动开启异步指标日志历史记录收集 [`system.asynchronous_metric_log`](../../operations/system-tables/asynchronous_metric_log.md),请创建 `/etc/clickhouse-server/config.d/asynchronous_metric_log.xml` 并包含以下内容: ```xml @@ -30,7 +25,7 @@ null **禁用** -要禁用 `asynchronous_metric_log` 设置,您需要创建以下文件 `/etc/clickhouse-server/config.d/disable_asynchronous_metric_log.xml`,内容如下: +要禁用 `asynchronous_metric_log` 设置,您需创建以下文件 `/etc/clickhouse-server/config.d/disable_asynchronous_metric_log.xml` 并包含以下内容: ```xml @@ -39,23 +34,23 @@ null ## auth_use_forwarded_address {#auth_use_forwarded_address} -对通过代理连接的客户端使用原始地址进行身份验证。 +通过代理连接的客户端使用原始地址进行身份验证。 :::note -此设置应谨慎使用,因为转发的地址很容易被伪造——接受这种身份验证的服务器不应直接访问,而应通过受信任的代理进行访问。 +此设置应谨慎使用,因为转发的地址很容易被伪造 - 接受此类身份验证的服务器不应直接访问,而应通过受信任的代理访问。 ::: ## backups {#backups} 备份设置,用于写入 `BACKUP TO File()`。 -以下设置可以通过子标签进行配置: +可以通过子标签配置以下设置: -| 设置 | 描述 | 默认 | -|-------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------| -| `allowed_path` | 使用 `File()` 时要备份到的路径。必须设置此设置才能使用 `File`。路径可以相对于实例目录,也可以是绝对路径。 | `true` | -| `remove_backup_files_after_failure` | 如果 `BACKUP` 命令失败,ClickHouse 将尝试删除在失败前已复制到备份的文件,否则它将保留已复制的文件不变。 | `true` | +| Setting | Description | Default | +|-------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------| +| `allowed_path` | 使用 `File()` 时的备份路径。此设置必须设置才能使用 `File`。路径可以相对于实例目录,也可以是绝对路径。 | `true` | +| `remove_backup_files_after_failure` | 如果 `BACKUP` 命令失败,ClickHouse 将尝试移除在失败之前已复制到备份的文件,否则它将保留已复制的文件不变。 | `true` | -此设置的默认配置为: +此设置默认配置如下: ```xml @@ -65,21 +60,27 @@ null ``` ## bcrypt_workfactor {#bcrypt_workfactor} -bcrypt_password 身份验证类型的工作因子,它使用 [Bcrypt 算法](https://wildlyinaccurate.com/bcrypt-choosing-a-work-factor/)。 +`bcrypt_password` 身份验证类型的工作因子,使用的是 [Bcrypt 算法](https://wildlyinaccurate.com/bcrypt-choosing-a-work-factor/)。工作因子定义了计算哈希和验证密码所需的计算量和时间。 ```xml 12 ``` + +:::warning +对于高频身份验证的应用程序, +考虑使用其他身份验证方法,因为 +bcrypt 在较高工作因子下的计算开销较大。 +::: ## table_engines_require_grant {#table_engines_require_grant} -如果设置为 true,则用户需要获得授权以使用特定引擎创建表,例如 `GRANT TABLE ENGINE ON TinyLog to user`。 +如果设置为 true,用户要求获取授权才能使用特定引擎创建表,例如 `GRANT TABLE ENGINE ON TinyLog to user`。 :::note -默认情况下,为了向后兼容,使用特定表引擎创建表会忽略授权,但您可以通过将其设置为 true 来更改此行为。 +默认情况下,为了向后兼容,使用特定表引擎创建表时会忽略授权,但是您可以通过将此设置为 true 来改变此行为。 ::: ## builtin_dictionaries_reload_interval {#builtin_dictionaries_reload_interval} -重新加载内置字典的间隔时间(以秒为单位)。 +在重新加载内置字典之前的秒数间隔。 ClickHouse 每 x 秒重新加载内置字典。这使得可以在不重启服务器的情况下“动态”编辑字典。 @@ -115,19 +116,19 @@ ClickHouse 每 x 秒重新加载内置字典。这使得可以在不重启服务 - `min_part_size` – 数据分片的最小大小。 - `min_part_size_ratio` – 数据分片大小与表大小的比例。 - `method` – 压缩方法。可接受的值:`lz4`,`lz4hc`,`zstd`,`deflate_qpl`。 -- `level` – 压缩级别。请参见 [Codecs](/sql-reference/statements/create/table#general-purpose-codecs)。 +- `level` – 压缩级别。参见 [Codecs](/sql-reference/statements/create/table#general-purpose-codecs)。 :::note -您可以配置多个 `` 部分。 +可以配置多个 `` 部分。 ::: -**满足条件时的操作**: +**条件满足时的操作**: -- 如果数据分片匹配设定的条件,ClickHouse 将使用指定的压缩方法。 +- 如果数据分片满足设置的条件,ClickHouse 将使用指定的压缩方法。 - 如果数据分片匹配多个条件集,ClickHouse 将使用第一个匹配的条件集。 :::note -如果没有条件满足数据分片,ClickHouse 将使用 `lz4` 压缩。 +如果数据分片没有满足条件,ClickHouse 将使用 `lz4` 压缩。 ::: **示例** @@ -144,9 +145,9 @@ ClickHouse 每 x 秒重新加载内置字典。这使得可以在不重启服务 ``` ## encryption {#encryption} -配置一个命令以获取用于 [encryption codecs](/sql-reference/statements/create/table#encryption-codecs) 的密钥。密钥(或多个密钥)应写入环境变量或设置在配置文件中。 +配置一个命令以获取用于 [加密编解码器](/sql-reference/statements/create/table#encryption-codecs) 的密钥。密钥(或多个密钥)应写入环境变量或在配置文件中设置。 -密钥可以是长度为 16 字节的十六进制字符串或字符串。 +密钥可以是 hex 或长度为 16 字节的字符串。 **示例** @@ -161,10 +162,10 @@ ClickHouse 每 x 秒重新加载内置字典。这使得可以在不重启服务 ``` :::note -不推荐将密钥存储在配置文件中。这并不安全。您可以将密钥移到安全磁盘上的单独配置文件中,并将该配置文件的符号链接放入 `config.d/` 文件夹中。 +不建议将密钥存储在配置文件中。这不安全。您可以将密钥移动到安全磁盘上的单独配置文件中,并在 `config.d/` 文件夹中放置该配置文件的符号链接。 ::: -从配置加载,当密钥为十六进制时: +从配置加载,当密钥为 hex 时: ```xml @@ -174,7 +175,7 @@ ClickHouse 每 x 秒重新加载内置字典。这使得可以在不重启服务 ``` -从环境变量加载密钥: +从环境变量中加载密钥: ```xml @@ -184,9 +185,9 @@ ClickHouse 每 x 秒重新加载内置字典。这使得可以在不重启服务 ``` -其中 `current_key_id` 设置当前的加密密钥,所有指定的密钥都可用于解密。 +这里 `current_key_id` 设置当前加密密钥,并且所有指定的密钥可以用于解密。 -这些方法可以应用于多个密钥: +每种方法都可以用于多个密钥: ```xml @@ -198,7 +199,7 @@ ClickHouse 每 x 秒重新加载内置字典。这使得可以在不重启服务 ``` -其中 `current_key_id` 显示当前的加密密钥。 +这里 `current_key_id` 显示当前的加密密钥。 此外,用户可以添加必须为 12 字节长的 nonce(默认情况下,加密和解密过程使用由零字节组成的 nonce): @@ -210,7 +211,7 @@ ClickHouse 每 x 秒重新加载内置字典。这使得可以在不重启服务 ``` -或者可以设置为十六进制: +或者可以设置为 hex: ```xml @@ -220,7 +221,7 @@ ClickHouse 每 x 秒重新加载内置字典。这使得可以在不重启服务 ``` :::note -上述所有内容均适用于 `aes_256_gcm_siv`(但密钥必须为 32 字节长)。 +上述所有内容可适用于 `aes_256_gcm_siv`(但密钥必须为 32 字节长)。 ::: ## error_log {#error_log} @@ -228,7 +229,7 @@ ClickHouse 每 x 秒重新加载内置字典。这使得可以在不重启服务 **启用** -要手动打开错误历史记录收集 [`system.error_log`](../../operations/system-tables/error_log.md),请创建 `/etc/clickhouse-server/config.d/error_log.xml`,内容如下: +要手动开启错误历史记录收集 [`system.error_log`](../../operations/system-tables/error_log.md),请创建 `/etc/clickhouse-server/config.d/error_log.xml` 并包含以下内容: ```xml @@ -247,7 +248,7 @@ ClickHouse 每 x 秒重新加载内置字典。这使得可以在不重启服务 **禁用** -要禁用 `error_log` 设置,您需要创建以下文件 `/etc/clickhouse-server/config.d/disable_error_log.xml`,内容如下: +要禁用 `error_log` 设置,您需创建以下文件 `/etc/clickhouse-server/config.d/disable_error_log.xml` 并包含以下内容: ```xml @@ -274,7 +275,7 @@ ClickHouse 每 x 秒重新加载内置字典。这使得可以在不重启服务 配置核心转储文件大小的软限制。 :::note -硬限制通过系统工具配置。 +硬限制通过系统工具配置 ::: **示例** @@ -286,7 +287,7 @@ ClickHouse 每 x 秒重新加载内置字典。这使得可以在不重启服务 ``` ## default_profile {#default_profile} -默认设置配置文件。设置配置文件位于设置 `user_config` 指定的文件中。 +默认设置配置文件。设置配置文件位于 `user_config` 设置指定的文件中。 **示例** @@ -295,15 +296,15 @@ ClickHouse 每 x 秒重新加载内置字典。这使得可以在不重启服务 ``` ## dictionaries_config {#dictionaries_config} -字典的配置文件路径。 +字典配置文件的路径。 路径: - 指定绝对路径或相对于服务器配置文件的路径。 - 路径可以包含通配符 * 和 ?。 -另请参阅: -- "[字典](../../sql-reference/dictionaries/index.md)". +另见: +- "[字典](../../sql-reference/dictionaries/index.md)"。 **示例** @@ -312,15 +313,15 @@ ClickHouse 每 x 秒重新加载内置字典。这使得可以在不重启服务 ``` ## user_defined_executable_functions_config {#user_defined_executable_functions_config} -可执行用户定义函数的配置文件路径。 +用户定义可执行函数的配置文件路径。 路径: - 指定绝对路径或相对于服务器配置文件的路径。 - 路径可以包含通配符 * 和 ?。 -另请参阅: -- "[可执行用户定义函数](/sql-reference/functions/udf#executable-user-defined-functions).". +另见: +- "[可执行用户定义函数](/sql-reference/functions/udf#executable-user-defined-functions)"。 **示例** @@ -329,7 +330,7 @@ ClickHouse 每 x 秒重新加载内置字典。这使得可以在不重启服务 ``` ## format_schema_path {#format_schema_path} -输入数据的模式目录的路径,例如 [CapnProto](../../interfaces/formats.md#capnproto) 格式的模式。 +输入数据模式的目录路径,例如 [CapnProto](../../interfaces/formats.md#capnproto) 格式的模式。 **示例** @@ -339,21 +340,21 @@ ClickHouse 每 x 秒重新加载内置字典。这使得可以在不重启服务 ``` ## graphite {#graphite} -发送数据到 [Graphite](https://github.com/graphite-project)。 +将数据发送到 [Graphite](https://github.com/graphite-project)。 设置: - `host` – Graphite 服务器。 -- `port` – Graphite 服务器上的端口。 -- `interval` – 发送间隔(以秒为单位)。 -- `timeout` – 发送数据的超时时间(以秒为单位)。 -- `root_path` – 密钥的前缀。 -- `metrics` – 从 [system.metrics](/operations/system-tables/metrics) 表发送数据。 -- `events` – 发送自 [system.events](/operations/system-tables/events) 表积累的时间段内的数据增量。 -- `events_cumulative` – 从 [system.events](/operations/system-tables/events) 表发送累积数据。 -- `asynchronous_metrics` – 从 [system.asynchronous_metrics](/operations/system-tables/asynchronous_metrics) 表发送数据。 +- `port` – Graphite 服务器的端口。 +- `interval` – 发送的时间间隔,以秒为单位。 +- `timeout` – 发送数据的超时,以秒为单位。 +- `root_path` – 键的前缀。 +- `metrics` – 从 [system.metrics](/operations/system-tables/metrics) 表中发送数据。 +- `events` – 从 [system.events](/operations/system-tables/events) 表中发送在此时间段内累积的增量数据。 +- `events_cumulative` – 从 [system.events](/operations/system-tables/events) 表中发送累积数据。 +- `asynchronous_metrics` – 从 [system.asynchronous_metrics](/operations/system-tables/asynchronous_metrics) 表中发送数据。 -可以配置多个 `` 条款。例如,可以利用此功能在不同时间间隔发送不同的数据。 +您可以配置多个 `` 子句。例如,您可以使用此方法以不同时间间隔发送不同的数据。 **示例** @@ -372,9 +373,9 @@ ClickHouse 每 x 秒重新加载内置字典。这使得可以在不重启服务 ``` ## graphite_rollup {#graphite_rollup} -Graphite 数据稀疏设置。 +为 Graphite 压缩数据的设置。 -有关更多详细信息,请参见 [GraphiteMergeTree](../../engines/table-engines/mergetree-family/graphitemergetree.md)。 +有关更多详细信息,请参阅 [GraphiteMergeTree](../../engines/table-engines/mergetree-family/graphitemergetree.md)。 **示例** @@ -399,7 +400,7 @@ Graphite 数据稀疏设置。 ``` ## google_protos_path {#google_protos_path} -定义包含 Protobuf 类型原型文件的目录。 +定义包含 Protobuf 类型的 proto 文件的目录。 示例: @@ -408,32 +409,34 @@ Graphite 数据稀疏设置。 ``` ## http_handlers {#http_handlers} -允许使用自定义 HTTP 处理程序。要添加新的 HTTP 处理程序,只需添加 ``。 -规则从上到下检查,并且第一个匹配将运行处理程序。 +允许使用自定义 HTTP 处理程序。 +要添加新的 http 处理程序,只需添加一个新的 ``。 +规则按从上到下的顺序检查, +第一个匹配的规则将运行处理程序。 -以下设置可以通过子标签进行配置: +以下设置可以通过子标签配置: -| 子标签 | 定义 | -|---------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `url` | 要匹配请求 URL,您可以使用 'regex:' 前缀来使用正则匹配(可选) | -| `methods` | 要匹配请求方法,您可以使用逗号分隔多个方法匹配(可选) | -| `headers` | 要匹配请求头,匹配每个子元素(子元素名称是头部名称),您可以使用 'regex:' 前缀来使用正则匹配(可选) | -| `handler` | 请求处理程序 | -| `empty_query_string` | 检查 URL 中没有查询字符串 | +| Sub-tags | Definition | +|----------------------|---------------------------------------------------------------------------------------------------------------------------------------------------| +| `url` | 要匹配请求 URL,您可以使用 'regex:' 前缀进行正则匹配(可选) | +| `methods` | 要匹配请求方法,您可以使用逗号分隔多个方法匹配(可选) | +| `headers` | 要匹配请求头,匹配每个子元素(子元素名称是头名称),您可以使用 'regex:' 前缀进行正则匹配(可选) | +| `handler` | 请求处理程序 | +| `empty_query_string` | 检查 URL 中没有查询字符串 | -`handler` 包含以下设置,可以通过子标签进行配置: +`handler` 包含以下设置,可以通过子标签配置: -| 子标签 | 定义 | -|---------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `url` | 重定向位置 | -| `type` | 支持的类型:static、dynamic_query_handler、predefined_query_handler、redirect | -| `status` | 与 static 类型一起使用,响应状态代码 | -| `query_param_name` | 与 dynamic_query_handler 类型一起使用,从 HTTP 请求参数中提取并执行与 `` 值对应的值 | -| `query` | 与 predefined_query_handler 类型一起使用,当调用处理程序时执行查询 | -| `content_type` | 与 static 类型一起使用,响应内容类型 | -| `response_content` | 与 static 类型一起使用,发送到客户端的响应内容,当使用前缀 'file://' 或 'config://' 时,从文件或配置中查找内容并发送给客户端 | +| Sub-tags | Definition | +|--------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `url` | 重定向位置 | +| `type` | 支持的类型:static, dynamic_query_handler, predefined_query_handler, redirect | +| `status` | 与 static 类型一起使用,响应状态代码 | +| `query_param_name` | 与 dynamic_query_handler 类型一起使用,从 HTTP 请求参数中提取和执行与 `` 值对应的值 | +| `query` | 与 predefined_query_handler 类型一起使用,在调用处理程序时执行查询 | +| `content_type` | 与 static 类型一起使用,响应内容类型 | +| `response_content` | 与 static 类型一起使用,发送到客户端的响应内容,当使用前缀 'file://' 或 'config://' 时,从文件或配置中查找内容并发送给客户端 | -除了规则列表,您还可以指定 ``,它指定启用所有默认处理程序。 +除了规则列表外,您还可以指定 ``,它指定启用所有默认处理程序。 示例: @@ -470,7 +473,8 @@ Graphite 数据稀疏设置。 ``` ## http_server_default_response {#http_server_default_response} -访问 ClickHouse HTTP(s) 服务器时默认显示的页面。默认值为 "Ok."(末尾有换行符) +访问 ClickHouse HTTP(s) 服务器时默认显示的页面。 +默认值为 "Ok."(末尾带换行)。 **示例** @@ -483,7 +487,8 @@ Graphite 数据稀疏设置。 ``` ## http_options_response {#http_options_response} -用于在 `OPTIONS` HTTP 请求中添加响应头。`OPTIONS` 方法用于发起 CORS 预检请求。 +用于在 `OPTIONS` HTTP 请求中向响应添加头信息。 +`OPTIONS` 方法用于生成 CORS 预检请求。 有关更多信息,请参见 [OPTIONS](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/OPTIONS)。 @@ -514,7 +519,7 @@ Graphite 数据稀疏设置。 HSTS 的过期时间(以秒为单位)。 :::note -值为 `0` 意味着 ClickHouse 禁用 HSTS。如果您设置一个正数值,则 HSTS 将启用,max-age 为您设置的数字。 +值为 `0` 表示 ClickHouse 禁用 HSTS。如果您设置为正数,则启用 HSTS,并且 max-age 是您设置的数字。 ::: **示例** @@ -524,10 +529,10 @@ HSTS 的过期时间(以秒为单位)。 ``` ## mlock_executable {#mlock_executable} -启动后执行 `mlockall` 以降低首次查询的延迟,并防止在高 IO 负载下使 ClickHouse 可执行文件被换出。 +启动后执行 `mlockall` 以降低初始查询延迟,并在高 IO 负载下防止 ClickHouse 可执行文件被换出。 :::note -推荐启用此选项,但将导致启动时间增加至几秒。请记住,此设置在没有 "CAP_IPC_LOCK" 权限时无效。 +推荐启用此选项,但将导致启动时间增加数秒。请注意,此设置在没有 "CAP_IPC_LOCK" 权限的情况下无法使用。 ::: **示例** @@ -537,7 +542,7 @@ HSTS 的过期时间(以秒为单位)。 ``` ## include_from {#include_from} -包含替换的文件路径。支持 XML 和 YAML 格式。 +包含替代项的文件路径。支持 XML 和 YAML 格式。 有关更多信息,请参见 "[配置文件](/operations/configuration-files)"。 @@ -548,10 +553,11 @@ HSTS 的过期时间(以秒为单位)。 ``` ## interserver_listen_host {#interserver_listen_host} -限制可以在 ClickHouse 服务器之间交换数据的主机。如果使用 Keeper,则相同的限制将应用于不同 Keeper 实例之间的通信。 +限制可以在 ClickHouse 服务器之间交换数据的主机。 +如果使用 Keeper,则同样的限制将适用于不同 Keeper 实例间的通信。 :::note -默认情况下,该值等于 [`listen_host`](#listen_host) 设置。 +默认情况下,其值等于 [`listen_host`](#listen_host) 设置。 ::: **示例** @@ -563,10 +569,10 @@ HSTS 的过期时间(以秒为单位)。 类型: -默认: +默认值: ## interserver_http_port {#interserver_http_port} -ClickHouse 服务器之间交换数据的端口。 +用于在 ClickHouse 服务器之间交换数据的端口。 **示例** @@ -575,11 +581,11 @@ ClickHouse 服务器之间交换数据的端口。 ``` ## interserver_http_host {#interserver_http_host} -其他服务器可以使用的访问此服务器的主机名。 +其他服务器可以用来访问此服务器的主机名。 -如果省略,则按 `hostname -f` 命令的相同方式定义。 +如果省略,则按与 `hostname -f` 命令相同的方式定义。 -有助于脱离特定的网络接口。 +适用于从特定网络接口断开。 **示例** @@ -588,7 +594,7 @@ ClickHouse 服务器之间交换数据的端口。 ``` ## interserver_https_port {#interserver_https_port} -ClickHouse 服务器之间通过 `HTTPS` 交换数据的端口。 +用于通过 `HTTPS` 在 ClickHouse 服务器之间交换数据的端口。 **示例** @@ -597,7 +603,7 @@ ClickHouse 服务器之间通过 `HTTPS` 交换数据的端口。 ``` ## interserver_https_host {#interserver_https_host} -类似于 [`interserver_http_host`](#interserver_http_host),不过此主机名可供其他服务器通过 `HTTPS` 访问此服务器。 +类似于 [`interserver_http_host`](#interserver_http_host),但此主机名可供其他服务器通过 `HTTPS` 访问此服务器。 **示例** @@ -606,27 +612,27 @@ ClickHouse 服务器之间通过 `HTTPS` 交换数据的端口。 ``` ## interserver_http_credentials {#interserver_http_credentials} -用于在 [复制](../../engines/table-engines/mergetree-family/replication.md) 过程中连接到其他服务器的用户名和密码。此外,服务器使用这些凭据对其他副本进行身份验证。 -因此 `interserver_http_credentials` 必须在集群中的所有副本中相同。 +用于 [复制](../../engines/table-engines/mergetree-family/replication.md) 时连接到其他服务器的用户名和密码。此外,服务器还使用这些凭证对其他副本进行身份验证。 +因此,`interserver_http_credentials` 必须在集群中所有副本中保持一致。 :::note - 默认情况下,如果省略 `interserver_http_credentials` 部分,则在复制过程中不使用身份验证。 -- `interserver_http_credentials` 设置与 ClickHouse 客户端凭据 [配置](../../interfaces/cli.md#configuration_files) 无关。 -- 这些凭据适用于通过 `HTTP` 和 `HTTPS` 的复制。 +- `interserver_http_credentials` 设置与 ClickHouse 客户端凭证 [配置](../../interfaces/cli.md#configuration_files) 无关。 +- 这些凭证适用于通过 `HTTP` 和 `HTTPS` 进行复制。 ::: -以下设置可以通过子标签进行配置: +可以通过子标签配置以下设置: - `user` — 用户名。 - `password` — 密码。 -- `allow_empty` — 如果为 `true`,则允许其他副本在设置凭据的情况下连接而无需身份验证。如果为 `false`,则拒绝未经身份验证的连接。默认:`false`。 -- `old` — 包含在凭据轮换期间使用的旧 `user` 和 `password`。可以指定多个 `old` 部分。 +- `allow_empty` — 如果 `true`,则允许其他副本在设置凭证的情况下无身份验证连接。如果为 `false`,则拒绝没有身份验证的连接。默认值:`false`。 +- `old` — 包含凭证轮换期间使用的旧 `user` 和 `password`。可以指定多个 `old` 部分。 -**凭据轮换** +**凭证轮换** -ClickHouse 支持动态的 interserver 凭据轮换,无需同时停止所有副本以更新其配置。凭据可以分几步更改。 +ClickHouse 支持动态的跨服务器凭证轮换,而无须同时停止所有副本以更新其配置。凭证可以分几步进行更改。 -要启用身份验证,请将 `interserver_http_credentials.allow_empty` 设置为 `true` 并添加凭据。这允许带身份验证和不带身份验证的连接。 +要启用身份验证,将 `interserver_http_credentials.allow_empty` 设置为 `true` 并添加凭证。这允许进行身份验证的连接和没有身份验证的连接。 ```xml @@ -636,9 +642,9 @@ ClickHouse 支持动态的 interserver 凭据轮换,无需同时停止所有 ``` -配置所有副本后,将 `allow_empty` 设置为 `false` 或删除此设置。这使得使用新凭据进行身份验证成为强制性。 +配置所有副本后,将 `allow_empty` 设置为 `false` 或删除该设置。这样将使新凭证的身份验证成为强制。 -要更改现有凭据,将用户名和密码移至 `interserver_http_credentials.old` 部分,并用新值更新 `user` 和 `password`。此时,服务器使用新凭据连接到其他副本,并接受用新凭据或旧凭据的连接。 +要更改现有凭证,将用户名和密码移动到 `interserver_http_credentials.old` 部分,并用新值更新 `user` 和 `password`。此时,服务器将使用新凭证连接到其他副本,并接受使用新凭证或旧凭证的连接。 ```xml @@ -655,38 +661,38 @@ ClickHouse 支持动态的 interserver 凭据轮换,无需同时停止所有 ``` -当新凭据应用于所有副本后,可以删除旧凭据。 +当所有副本都应用新凭证后,旧凭证可以删除。 ## ldap_servers {#ldap_servers} -在此处列出 LDAP 服务器及其连接参数,以: -- 将它们作为具有 'ldap' 身份验证机制的专用本地用户的身份验证者,而不是 'password' +在此列出 LDAP 服务器及其连接参数,以: +- 将它们用作具有指定“ldap”身份验证机制的专用本地用户的身份验证器,而不是“password” - 将它们用作远程用户目录。 -以下设置可以通过子标签进行配置: - -| 设置 | 描述 | -|---------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `host` | LDAP 服务器主机名或 IP,此参数是必需的,不能为空。 | -| `port` | LDAP 服务器端口,如果 `enable_tls` 设置为 true,则默认为 636,否则为 389。 | -| `bind_dn` | 用于构造绑定 DN 的模板。在每次身份验证尝试期间,结果 DN 将通过替换模板中的所有 `\{user_name\}` 子字符串与实际用户名构造。 | -| `user_dn_detection` | 用于检测绑定用户实际用户 DN 的 LDAP 搜索参数部分。这主要在 Active Directory 中使用于搜索过滤器,进行进一步的角色映射。结果用户 DN 将在允许替换的地方使用 `\{user_dn\}` 子字符串。默认情况下,用户 DN 设置为与绑定 DN 相等,但搜索执行后,它将更新为实际检测到的用户 DN 值。 | -| `verification_cooldown` | 在成功绑定尝试后,用户将在此期间假定已成功验证,期间将不联系 LDAP 服务器。指定 `0`(默认为此值)以禁用缓存,并强制在每次身份验证请求时联系 LDAP 服务器。 | -| `enable_tls` | 触发与 LDAP 服务器建立安全连接的标志。为明文(`ldap://`)协议指定 `no`(不推荐)。为通过 SSL/TLS(`ldaps://`)协议(推荐,默认为此值)指定 `yes`。为传统的 StartTLS 协议(明文(`ldap://`)协议,升级为 TLS)指定 `starttls`。 | -| `tls_minimum_protocol_version` | SSL/TLS 的最低协议版本。接受的值有:`ssl2`,`ssl3`,`tls1.0`,`tls1.1`,`tls1.2`(默认为此值)。 | -| `tls_require_cert` | SSL/TLS 对等证书验证行为。接受的值有:`never`,`allow`,`try`,`demand`(默认为此值)。 | -| `tls_cert_file` | 证书文件的路径。 | -| `tls_key_file` | 证书密钥文件的路径。 | -| `tls_ca_cert_file` | CA 证书文件的路径。 | -| `tls_ca_cert_dir` | 包含 CA 证书的目录的路径。 | -| `tls_cipher_suite` | 允许的密码套件(以 OpenSSL 表示法)。 | - -设置 `user_dn_detection` 可以通过子标签进行配置: - -| 设置 | 描述 | -|----------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `base_dn` | 用于构造 LDAP 搜索的基本 DN 的模板。在 LDAP 搜索期间,结果 DN 将通过替换模板中的所有 `\{user_name\}` 和 `\{bind_dn\}` 子字符串与实际用户名和绑定 DN 构造。 | -| `scope` | LDAP 搜索的范围。接受的值有:`base`,`one_level`,`children`,`subtree`(默认为此值)。 | -| `search_filter`| 用于构造 LDAP 搜索的搜索过滤器的模板。结果过滤器将通过替换模板中的所有 `\{user_name\}`,`\{bind_dn\}` 和 `\{base_dn\}` 子字符串与实际用户名、绑定 DN 和基本 DN 构造。注意,特殊字符必须在 XML 中正确转义。 | +可以通过子标签配置以下设置: + +| Setting | Description | +|--------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `host` | LDAP 服务器主机名或 IP,此参数是必需的且不能为空。 | +| `port` | LDAP 服务器端口,如果 `enable_tls` 设置为 true,默认是 636,否则为 389。 | +| `bind_dn` | 用于构建绑定时的 DN 的模板。在每次身份验证尝试期间,结果 DN 将通过替换模板中所有 `\{user_name\}` 子字符串来构造实际用户名。 | +| `user_dn_detection` | 用于检测绑定用户实际用户 DN 的 LDAP 搜索参数部分。这主要用于在服务器为 Active Directory 时用于后续角色映射的搜索过滤器。生成的用户 DN 将在允许的地方替换 `\{user_dn\}` 子字符串。默认情况下,用户 DN 设置为等于绑定 DN,但在执行搜索后,它将使用实际检测到的用户 DN 值进行更新。 | +| `verification_cooldown` | 成功绑定后的一段时间(以秒为单位),在此期间,用户将被假定为所有连续请求成功通过身份验证,而无需联系 LDAP 服务器。设置为 `0`(默认)以禁用缓存,并强制在每次身份验证请求时联系 LDAP 服务器。 | +| `enable_tls` | 触发与 LDAP 服务器建立安全连接的标志。设置为 `no` 表示纯文本 (`ldap://`) 协议(不推荐)。设置为 `yes` 表示使用 SSL/TLS 的 LDAP (`ldaps://`) 协议(推荐,默认)。设置为 `starttls` 表示使用传统的 StartTLS 协议(纯文本 (`ldap://`) 协议,升级为 TLS)。 | +| `tls_minimum_protocol_version` | SSL/TLS 的最低协议版本。接受的值包括:`ssl2`,`ssl3`,`tls1.0`,`tls1.1`,`tls1.2`(默认)。 | +| `tls_require_cert` | SSL/TLS 对等证书验证行为。接受的值包括:`never`,`allow`,`try`,`demand`(默认)。 | +| `tls_cert_file` | 证书文件路径。 | +| `tls_key_file` | 证书密钥文件路径。 | +| `tls_ca_cert_file` | CA 证书文件路径。 | +| `tls_ca_cert_dir` | 包含 CA 证书的目录路径。 | +| `tls_cipher_suite` | 允许的加密套件(以 OpenSSL 表示法)。 | + +设置 `user_dn_detection` 可以通过子标签配置: + +| Setting | Description | +|-----------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `base_dn` | 用于构建 LDAP 搜索的基本 DN 的模板。在 LDAP 搜索中,结果 DN 将通过替换模板中的所有 `\{user_name\}` 和 '\{bind_dn\}' 子字符串来构造。 | +| `scope` | LDAP 搜索的作用域。接受的值包括:`base`,`one_level`,`children`,`subtree`(默认)。 | +| `search_filter` | 用于构建 LDAP 搜索的搜索过滤器模板。生成的过滤器将在 LDAP 搜索期间通过替换模板中所有 `\{user_name\}`, `\{bind_dn\}`,和 `\{base_dn\}` 子字符串来构造。请注意,特殊字符必须在 XML 中正确转义。 | 示例: @@ -707,7 +713,7 @@ ClickHouse 支持动态的 interserver 凭据轮换,无需同时停止所有 ``` -示例(典型 Active Directory,配置了用户 DN 检测以进行进一步的角色映射): +示例(典型的 Active Directory,配置了用户 DN 检测以进行后续角色映射): ```xml @@ -723,7 +729,7 @@ ClickHouse 支持动态的 interserver 凭据轮换,无需同时停止所有 ``` ## listen_host {#listen_host} -请求的来源主机限制。如果您希望服务器回答所有请求,请指定 `::`。 +限制请求来源的主机。如果您希望服务器回应所有请求,请指定 `::`。 示例: @@ -733,7 +739,7 @@ ClickHouse 支持动态的 interserver 凭据轮换,无需同时停止所有 ``` ## listen_try {#listen_try} -如果在尝试监听时 IPv6 或 IPv4 网络不可用,服务器将不会退出。 +如果 IPv6 或 IPv4 网络在尝试监听时不可用,服务器将不会退出。 **示例** @@ -742,7 +748,7 @@ ClickHouse 支持动态的 interserver 凭据轮换,无需同时停止所有 ``` ## listen_reuse_port {#listen_reuse_port} -允许多个服务器在同一地址:端口上监听。请求将由操作系统随机路由到一个服务器。启用此设置不推荐。 +允许多个服务器监听同一地址:端口。请求将由操作系统随机路由到某个服务器。建议不要启用此设置。 **示例** @@ -752,18 +758,18 @@ ClickHouse 支持动态的 interserver 凭据轮换,无需同时停止所有 类型: -默认: +默认值: ## listen_backlog {#listen_backlog} -监听套接字的排队(待处理连接的队列大小)。默认值 `4096` 与 linux [5.4+](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=19f92a030ca6d772ab44b22ee6a01378a8cb32d4) 的值相同。 +监听套接字的 backlog(待处理连接的队列大小)。默认值 `4096` 与 linux [5.4+](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=19f92a030ca6d772ab44b22ee6a01378a8cb32d4) 的值相同。 -通常这个值不需要更改,因为: -- 默认值足够大, -- 服务器具有单独的线程来接受客户端连接。 +通常不需要更改此值,因为: +- 默认值已足够大, +- 服务器为接受客户端连接提供了独立线程。 -因此,即使您有非零的 `TcpExtListenOverflows`(来自 `nstat`),且该计数器在 ClickHouse 服务器上增长,也并不意味着这个值需要增加,因为: -- 通常,如果 `4096` 不够,这表明 ClickHouse 存在一些内部扩展问题,因此最好报告问题。 -- 这并不意味着服务器可以在稍后处理更多连接(即使可以,在那时客户端可能已消失或断开连接)。 +因此即使 `TcpExtListenOverflows` (来自 `nstat`)非零,并且该计数器在 ClickHouse 服务器上增长,也并不意味着需要增加此值,因为: +- 通常,如果 `4096` 不够,这表明存在某种内部 ClickHouse 扩展问题,因此最好报告一个问题。 +- 这并不意味着服务器将来可以处理更多连接(即使可以,届时客户端可能已离开或断开连接)。 **示例** @@ -776,65 +782,69 @@ ClickHouse 支持动态的 interserver 凭据轮换,无需同时停止所有 **键**: -| 键 | 描述 | -|---------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `level` | 日志级别。可接受的值:`none`(关闭日志)、`fatal`、`critical`、`error`、`warning`、`notice`、`information`、`debug`、`trace`、`test` | -| `log` | 日志文件的路径。 | -| `errorlog` | 错误日志文件的路径。 | -| `size` | 轮转策略:日志文件的最大大小(以字节为单位)。一旦日志文件大小超过此阈值,将重命名并归档,并创建新的日志文件。 | -| `count` | 轮转策略:Clickhouse 保留的历史日志文件的最大数量。 | -| `stream_compress` | 使用 LZ4 压缩日志消息。设置为 `1` 或 `true` 以启用。 | -| `console` | 不将日志消息写入日志文件,而是直接在控制台中打印。设置为 `1` 或 `true` 以启用。如果 Clickhouse 不是以守护进程模式运行,则默认值为 `1`,否则为 `0`。 | -| `console_log_level` | 控制台输出的日志级别。默认为 `level`。 | -| `formatting` | 控制台输出的日志格式。目前仅支持 `json` | -| `use_syslog` | 将日志输出转发到 syslog。 | -| `syslog_level` | 记录到 syslog 的日志级别。 | +| 键 | 描述 | +|------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `level` | 日志级别。可接受的值:`none`(关闭日志记录),`fatal`,`critical`,`error`,`warning`,`notice`,`information`,`debug`,`trace`,`test` | +| `log` | 日志文件的路径。 | +| `errorlog` | 错误日志文件的路径。 | +| `size` | 轮换策略:日志文件的最大大小(以字节为单位)。一旦日志文件大小超过该阈值,它将被重命名并存档,并创建一个新的日志文件。 | +| `count` | 轮换策略:ClickHouse最多保留多少个历史日志文件。 | +| `stream_compress` | 使用 LZ4 压缩日志消息。设置为 `1` 或 `true` 以启用。 | +| `console` | 启用控制台日志记录。设置为 `1` 或 `true` 以启用。如果 ClickHouse 不在守护进程模式下运行,默认值为 `1`,否则为 `0`。 | +| `console_log_level` | 控制台输出的日志级别。默认为 `level`。 | +| `formatting.type` | 控制台输出的日志格式。目前仅支持 `json` | +| `use_syslog` | 同时将日志输出转发到 syslog。 | +| `syslog_level` | 日志到 syslog 的日志级别。 | +| `async` | 当 `true`(默认)时,日志将异步记录(每个输出通道一个后台线程)。否则它将在调用 LOG 的线程内记录。 | +| `async_queue_max_size` | 使用异步日志记录时,保持在等候刷新队列中的消息最大数量。多余的消息将被丢弃。 | +| `startup_level` | 启动级别用于设置服务器启动时根日志记录器的级别。启动后,日志级别将恢复到 `level` 设置。 | +| `shutdown_level` | 关闭级别用于设置服务器关闭时根日志记录器的级别。 | **日志格式说明符** -`log` 和 `errorLog` 路径中的文件名支持以下格式说明符,目录部分不支持它们。 - -“示例”栏显示与 `2023-07-06 18:32:07` 的输出。 - -| 说明符 | 描述 | 示例 | -|------------|-------------------------------------------------------------------------------------------------------------------------------|----------------------| -| `%%` | 字面 % | `%` | -| `%n` | 换行符 | | -| `%t` | 水平制表符 | | -| `%Y` | 年份,以十进制数字表示,例如 2017 | `2023` | -| `%y` | 年份的最后 2 位数字,以十进制数字表示(范围 [00,99]) | `23` | -| `%C` | 年份的前 2 位数字,以十进制数字表示(范围 [00,99]) | `20` | -| `%G` | 四位数 [ISO 8601 周基础年](https://en.wikipedia.org/wiki/ISO_8601#Week_dates),即包含指定周的年份。通常与 `%V` 一起使用 | `2023` | -| `%g` | ISO 8601 周基础年的最后 2 位数字,表示包含指定周的年度。 | `23` | -| `%b` | 缩写的月份名称,例如:Oct(地域相关) | `Jul` | -| `%h` | 同义词 %b | `Jul` | -| `%B` | 完整的月份名称,例如:October(地域相关) | `July` | -| `%m` | 月份,以十进制数字表示(范围 [01,12]) | `07` | -| `%U` | 按十进制数字表示的年份的周数(以周日为第一天)(范围 [00,53]) | `27` | -| `%W` | 按十进制数字表示的年份的周数(以周一为第一天)(范围 [00,53]) | `27` | -| `%V` | ISO 8601 周数(范围 [01,53]) | `27` | -| `%j` | 一年中的天数,以十进制数字表示(范围 [001,366]) | `187` | -| `%d` | 月中的天数,以零填充的十进制数字表示(范围 [01,31])。单个数字前面加零。 | `06` | -| `%e` | 月中的天数,以空格填充的十进制数字表示(范围 [1,31])。单个数字前面加空格。 | `  6` | -| `%a` | 缩写的星期几名称,例如:Fri(地域相关) | `Thu` | -| `%A` | 完整的星期几名称,例如:Friday(地域相关) | `Thursday` | -| `%w` | 星期几的整数数字(以周日为 0)(范围 [0-6]) | `4` | -| `%u` | 星期几的十进制数字(ISO 8601 格式),以周一为 1(范围 [1-7]) | `4` | -| `%H` | 以十进制数字表示的小时,24 小时制(范围 [00-23]) | `18` | -| `%I` | 以十进制数字表示的小时,12 小时制(范围 [01,12]) | `06` | -| `%M` | 以十进制数字表示的分钟(范围 [00,59]) | `32` | -| `%S` | 以十进制数字表示的秒(范围 [00,60]) | `07` | -| `%c` | 标准日期和时间字符串,例如:Sun Oct 17 04:41:13 2010(地域相关) | `Thu Jul 6 18:32:07 2023` | -| `%x` | 本地化的日期表示(地域相关) | `07/06/23` | -| `%X` | 本地化的时间表示,例如:18:40:20 或 6:40:20 PM(地域相关) | `18:32:07` | -| `%D` | 短格式 MM/DD/YY 日期,相当于 %m/%d/%y | `07/06/23` | -| `%F` | 短格式 YYYY-MM-DD 日期,相当于 %Y-%m-%d | `2023-07-06` | -| `%r` | 本地化的 12 小时制时间(地域相关) | `06:32:07 PM` | -| `%R` | 相当于 "%H:%M" | `18:32` | -| `%T` | 相当于 "%H:%M:%S"(ISO 8601 时间格式) | `18:32:07` | -| `%p` | 本地化的上午或下午标志(地域相关) | `PM` | -| `%z` | ISO 8601 格式的 UTC 偏移(例如 -0430),如果没有时区信息则无字符 | `+0800` | -| `%Z` | 本地依赖的时区名称或缩写,如果没有时区信息则无字符 | `Z AWST ` | +`log` 和 `errorLog` 路径中的文件名支持以下格式说明符用于生成的文件名(目录部分不支持它们)。 + +“示例”列显示输出为 `2023-07-06 18:32:07`。 + +| 说明符 | 描述 | 示例 | +|-------------|--------------------------------------------------------------------------------------------------------------------|---------------------------| +| `%%` | 字面上的 % | `%` | +| `%n` | 换行符 | | +| `%t` | 水平制表符 | | +| `%Y` | 以十进制数字表示的年份,例如 2017 | `2023` | +| `%y` | 以十进制数字表示的年份最后两位数字(范围 [00,99]) | `23` | +| `%C` | 以十进制数字表示的年份前两位数字(范围 [00,99]) | `20` | +| `%G` | 四位数的 [ISO 8601 基于周的年份](https://en.wikipedia.org/wiki/ISO_8601#Week_dates),即包含指定周的年份。通常仅与 `%V` 一起使用 | `2023` | +| `%g` | 以十进制数字表示的 [ISO 8601 基于周的年份](https://en.wikipedia.org/wiki/ISO_8601#Week_dates),即包含指定周的年份。 | `23` | +| `%b` | 缩写的月份名称,例如 Oct(依赖于区域设置) | `Jul` | +| `%h` | %b 的同义词 | `Jul` | +| `%B` | 完整的月份名称,例如 October(依赖于区域设置) | `July` | +| `%m` | 以十进制数字表示的月份(范围 [01,12]) | `07` | +| `%U` | 以十进制数字表示的年份周数(以星期日为一周的第一天)(范围 [00,53]) | `27` | +| `%W` | 以十进制数字表示的年份周数(以星期一为一周的第一天)(范围 [00,53]) | `27` | +| `%V` | ISO 8601 周数(范围 [01,53]) | `27` | +| `%j` | 以十进制数字表示的年份中的日数(范围 [001,366]) | `187` | +| `%d` | 以零填充的十进制数表示的月份中的日(范围 [01,31])。单个数字前有零。 | `06` | +| `%e` | 以空格填充的十进制数表示的月份中的日(范围 [1,31])。单个数字前有空格。 | `  6` | +| `%a` | 缩写的星期几名称,例如 Fri(依赖于区域设置) | `Thu` | +| `%A` | 完整的星期几名称,例如 Friday(依赖于区域设置) | `Thursday` | +| `%w` | 以整数表示的星期几,星期日为 0(范围 [0-6]) | `4` | +| `%u` | 以十进制数表示的星期几,其中星期一为 1(ISO 8601 格式)(范围 [1-7]) | `4` | +| `%H` | 以十进制数表示的小时,24小时制(范围 [00-23]) | `18` | +| `%I` | 以十进制数表示的小时,12小时制(范围 [01,12]) | `06` | +| `%M` | 以十进制数表示的分钟(范围 [00,59]) | `32` | +| `%S` | 以十进制数表示的秒数(范围 [00,60]) | `07` | +| `%c` | 标准日期和时间字符串,例如 Sun Oct 17 04:41:13 2010(依赖于区域设置) | `Thu Jul 6 18:32:07 2023` | +| `%x` | 本地化的日期表示(依赖于区域设置) | `07/06/23` | +| `%X` | 本地化的时间表示,例如 18:40:20 或 6:40:20 PM(依赖于区域设置) | `18:32:07` | +| `%D` | 短的 MM/DD/YY 日期,相当于 %m/%d/%y | `07/06/23` | +| `%F` | 短的 YYYY-MM-DD 日期,相当于 %Y-%m-%d | `2023-07-06` | +| `%r` | 本地化的 12 小时制时间(依赖于区域设置) | `06:32:07 PM` | +| `%R` | 相当于 "%H:%M" | `18:32` | +| `%T` | 相当于 "%H:%M:%S"(ISO 8601 时间格式) | `18:32:07` | +| `%p` | 本地化的上午或下午标识(依赖于区域设置) | `PM` | +| `%z` | ISO 8601 格式的 UTC 偏移(例如 -0430),如果没有时区信息则不显示任何字符 | `+0800` | +| `%Z` | 本地化的时区名称或缩写,如果没有时区信息则不显示任何字符 | `Z AWST ` | **示例** @@ -849,7 +859,7 @@ ClickHouse 支持动态的 interserver 凭据轮换,无需同时停止所有 ``` -只在控制台中打印日志消息: +仅在控制台打印日志消息: ```xml @@ -858,9 +868,9 @@ ClickHouse 支持动态的 interserver 凭据轮换,无需同时停止所有 ``` -**每级别覆盖** +**每级覆盖** -单个日志名称的日志级别可以被覆盖。例如,静音所有 "Backup" 和 "RBAC" 日志的消息。 +可以重写单个日志名称的日志级别。例如,您可以静音日志名称为 "Backup" 和 "RBAC" 的所有消息。 ```xml @@ -879,7 +889,7 @@ ClickHouse 支持动态的 interserver 凭据轮换,无需同时停止所有 **syslog** -将日志消息额外写入 syslog: +将日志消息额外写入到 syslog: ```xml @@ -893,18 +903,18 @@ ClickHouse 支持动态的 interserver 凭据轮换,无需同时停止所有 ``` -`` 的键: +用于 `` 的键: -| 键 | 描述 | -|-------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `address` | Syslog 的地址,格式为 `host\[:port\]`。如果省略,则使用本地守护程序。 | -| `hostname` | 发送日志的主机名称(可选)。 | -| `facility` | Syslog [设施关键字](https://en.wikipedia.org/wiki/Syslog#Facility)。必须大写并带有 "LOG_" 前缀,例如 `LOG_USER`、`LOG_DAEMON`、`LOG_LOCAL3` 等。如果指定了 `address`,默认值为 `LOG_USER`,否则为 `LOG_DAEMON`。 | -| `format` | 日志消息格式。可能的值:`bsd` 和 `syslog`。 | +| 键 | 描述 | +|------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `address` | 格式为 `host\[:port\]` 的 syslog 地址。如果省略,则使用本地守护进程。 | +| `hostname` | 发送日志的主机名(可选)。 | +| `facility` | syslog [设施关键字](https://en.wikipedia.org/wiki/Syslog#Facility)。必须使用大写字母并带有 "LOG_" 前缀,例如 `LOG_USER`,`LOG_DAEMON`,`LOG_LOCAL3` 等。如果指定了 `address`,默认值为 `LOG_USER`,否则为 `LOG_DAEMON`。 | +| `format` | 日志消息格式。可能的值:`bsd` 和 `syslog`。 | **日志格式** -您可以指定将在控制台日志中输出的日志格式。目前仅支持 JSON。 +您可以指定将在控制台日志中输出的日志格式。目前,仅支持 JSON。 **示例** @@ -925,12 +935,14 @@ ClickHouse 支持动态的 interserver 凭据轮换,无需同时停止所有 } ``` -要启用 JSON 日志支持,请使用以下代码片段: +要启用 JSON 日志支持,请使用以下代码段: ```xml json + + date_time thread_name @@ -948,7 +960,7 @@ ClickHouse 支持动态的 interserver 凭据轮换,无需同时停止所有 **重命名 JSON 日志的键** -可以通过更改 `` 标签内部的标签值来修改键名。例如,要将 `DATE_TIME` 更改为 `MY_DATE_TIME`,您可以使用 `MY_DATE_TIME`。 +通过更改 `` 标签中的标签值可以修改键名称。例如,要将 `DATE_TIME` 更改为 `MY_DATE_TIME`,可以使用 `MY_DATE_TIME`。 **省略 JSON 日志的键** @@ -957,15 +969,15 @@ ClickHouse 支持动态的 interserver 凭据轮换,无需同时停止所有 发送崩溃报告到 ClickHouse 核心开发团队的设置。 -在预生产环境中启用此功能特别受欢迎。 +在预生产环境中启用此功能尤为重要。 键: -| 键 | 描述 | -|-------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------| -| `enabled` | 布尔标志以启用该功能,默认为 `true`。设置为 `false` 以避免发送崩溃报告。 | -| `send_logical_errors` | `LOGICAL_ERROR` 类似于 `assert`,它是 ClickHouse 中的一个错误。此布尔标志启用此异常的发送(默认:`true`)。 | -| `endpoint` | 您可以覆盖发送崩溃报告的端点 URL。 | +| 键 | 描述 | +|-----------------------|----------------------------------------------------------------------------------------------------------------| +| `enabled` | 布尔标志以启用该功能,默认值为 `true`。设置为 `false` 以避免发送崩溃报告。 | +| `send_logical_errors` | `LOGICAL_ERROR` 好比一个 `assert`,它是 ClickHouse 的错误。此布尔标志启用发送此异常(默认值:`true`)。 | +| `endpoint` | 您可以覆盖发送崩溃报告的端点 URL。 | **推荐用法** @@ -976,9 +988,9 @@ ClickHouse 支持动态的 interserver 凭据轮换,无需同时停止所有 ``` ## ssh_server {#ssh_server} -主机密钥的公共部分将在第一次连接时写入 SSH 客户端的 known_hosts 文件。 +主机密钥的公钥部分将在第一次连接时写入 SSH 客户端的 known_hosts 文件。 -主机密钥配置默认情况下是无效的。 +主机密钥配置默认是不活动的。 取消注释主机密钥配置,并提供相应 ssh 密钥的路径以激活它们: 示例: @@ -992,7 +1004,7 @@ ClickHouse 支持动态的 interserver 凭据轮换,无需同时停止所有 ``` ## tcp_ssh_port {#tcp_ssh_port} -允许用户通过 PTY 使用嵌入式客户端以交互方式连接和执行查询的 SSH 服务器的端口。 +允许用户通过 PTY 使用嵌入式客户端交互执行查询的 SSH 服务器的端口。 示例: @@ -1015,7 +1027,7 @@ ClickHouse 支持动态的 interserver 凭据轮换,无需同时停止所有 ``` -### 磁盘配置 {#configuration-of-disks} +### Configuration of disks {#configuration-of-disks} `disks` 的配置遵循以下结构: @@ -1038,46 +1050,46 @@ ClickHouse 支持动态的 interserver 凭据轮换,无需同时停止所有 ``` -上述子标签定义 `disks` 的以下设置: +上述子标签为 `disks` 定义了以下设置: -| 设置 | 描述 | -|-----------------------|----------------------------------------------------------------------------------------------| -| `` | 磁盘的名称,必须是唯一的。 | -| `path` | 服务器数据将存储的路径(`data` 和 `shadow` 目录)。应该以 `/` 结尾。 | -| `keep_free_space_bytes` | 磁盘上保留的空闲空间大小。 | +| 设置 | 描述 | +|------------------------|------------------------------------------------------------------------------------------------| +| `` | 磁盘的名称,应该是唯一的。 | +| `path` | 服务器数据将存储到的路径(`data` 和 `shadow` 目录)。应以 `/` 结尾 | +| `keep_free_space_bytes`| 磁盘上保留的空闲空间大小。 | :::note 磁盘的顺序无关紧要。 ::: -### 策略配置 {#configuration-of-policies} - -上述子标签定义 `policies` 的以下设置: - -| 设置 | 描述 | -|----------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `policy_name_N` | 策略名称。策略名称必须唯一。 | -| `volume_name_N` | 卷名称。卷名称必须唯一。 | -| `disk` | 位于卷内的磁盘。 | -| `max_data_part_size_bytes` | 可以位于此卷中的任何磁盘上的数据块的最大大小。如果合并结果导致块大小超过 `max_data_part_size_bytes`,则该块将写入下一个卷。基本上此功能允许您将新的/小的数据块存储在热(SSD)卷中,当它们达到较大的大小时再移动到冷(HDD)卷。如果策略只有一个卷,请勿使用此选项。 | -| `move_factor` | 卷上可用空闲空间的份额。如果空间变少,数据将开始转移到下一个卷(如果存在)。在转移过程中,块按大小从大到小(降序)进行排序,并选择总大小足以满足 `move_factor` 条件的块,如果所有块的总大小不足,则会移动所有块。 | -| `perform_ttl_move_on_insert` | 禁用插入时移动过期 TTL 的数据。默认情况下(如果启用),如果我们插入一段数据,该数据根据生命周期规则已经过期,则该数据立即移动到移动规则指定的卷/磁盘上。如果目标卷/磁盘速度较慢(例如 S3),这可能会显著降低插入速度。如果禁用,过期数据部分将写入默认卷,然后立即移动到规则中指定的过期 TTL 卷中。 | -| `load_balancing` | 磁盘平衡策略,`round_robin` 或 `least_used`。 | -| `least_used_ttl_ms` | 设置更新所有磁盘上可用空间的超时时间(以毫秒为单位)(`0` - 始终更新,`-1` - 从不更新,默认值为 `60000`)。注意,如果磁盘仅被 ClickHouse 使用,并且不会在运行时动态调整文件系统,则可以使用 `-1` 值。在所有其他情况下不建议这样做,因为最终将导致空间分配不正确。 | -| `prefer_not_to_merge` | 禁用对此卷数据块的合并。注意:这可能是有害的并且可能导致速度变慢。当启用此设置时(请勿这样做),禁止对该卷的数据进行合并(这不好)。这允许控制 ClickHouse 与慢磁盘的交互。我们建议根本不要使用此选项。 | -| `volume_priority` | 定义填充卷的优先级(顺序)。值越小,优先级越高。参数值必须是自然数,并覆盖从 1 到 N 的范围(N 是指定的最大参数值),且没有间隔。 | +### Configuration of policies {#configuration-of-policies} + +上述子标签为 `policies` 定义了以下设置: + +| 设置 | 描述 | +|-------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `policy_name_N` | 策略名称。策略名称必须是唯一的。 | +| `volume_name_N` | 卷的名称。卷名称必须是唯一的。 | +| `disk` | 位于卷内的磁盘。 | +| `max_data_part_size_bytes` | 可以存在于该卷中任何磁盘上的数据块的最大大小。如果合并结果的块大小大于 `max_data_part_size_bytes`,该块将写入下一个卷。基本上,该功能允许您在热(SSD)卷上存储新的/小的块,并在它们达到大尺寸时将它们移动到冷(HDD)卷。如果策略仅包含一个卷,请不要使用此选项。 | +| `move_factor` | 卷中可用的空闲空间的份额。如果空间变少,数据将开始转移到下一个卷(如果有的话)。对于转移,块按大小从大到小(降序)排序,并选择总大小足以满足 `move_factor` 条件的块,如果所有块的总大小不足,将移动所有块。 | +| `perform_ttl_move_on_insert` | 在插入时禁用将过期 TTL 的数据移动。默认情况下(如果启用),如果我们插入的某个数据已经根据生命规则过期,它将立即移动到移动规则中指定的卷/磁盘。如果目标卷/磁盘很慢(例如 S3),这会显著减慢插入速度。如果禁用,则过期的数据部分将写入默认卷,然后立即移动到规则中指定的过期 TTL 的卷。 | +| `load_balancing` | 磁盘平衡策略,`round_robin` 或 `least_used`。 | +| `least_used_ttl_ms` | 设置更新所有磁盘上可用空间的超时(以毫秒为单位)(`0` - 始终更新,`-1` - 从不更新,默认值为 `60000`)。注意,如果磁盘仅被 ClickHouse 使用且不会被文件系统动态调整大小,则可以使用 `-1` 值。在所有其他情况下,不建议使用,因为最终会导致空间分配不正确。 | +| `prefer_not_to_merge` | 禁用合并此卷上的数据部分。注意:这可能会有害,并可能导致性能下降。当启用此设置时(不要这样做),禁止对该卷上的数据进行合并(这是不好的)。这允许控制 ClickHouse 如何与慢磁盘进行交互。我们建议根本不要使用此设置。 | +| `volume_priority` | 定义填写卷的优先级(顺序)。值越小,优先级越高。参数值必须是自然数,并覆盖从 1 到 N 的范围(N 为指定的最大参数值),且没有间隔。 | 对于 `volume_priority`: - 如果所有卷都有此参数,则按指定顺序优先排序。 -- 如果只有 _某些_ 卷有此参数,没有此参数的卷的优先级最低。那些有此参数的卷根据标签值优先排序,其余的优先级根据配置文件中对彼此的描述顺序确定。 -- 如果 _没有_ 卷赋予此参数,则它们的顺序由配置文件中的描述顺序决定。 +- 如果只有 _某些_ 卷有此参数,则没有此参数的卷优先级最低。有此参数的卷根据标签值优先,其他卷的优先级根据配置文件中的描述顺序确定。 +- 如果 _没有_ 卷被赋予该参数,则其顺序由配置文件中的描述顺序确定。 - 卷的优先级可能不相同。 ## macros {#macros} -参数替换用于复制的表。 +复制表的参数替换。 -如果不使用复制表,可以省略此部分。 +如果没有使用复制表,则可以省略。 -有关更多信息,请参见 [创建复制表](../../engines/table-engines/mergetree-family/replication.md#creating-replicated-tables) 部分。 +有关更多信息,请参阅 [创建复制表](../../engines/table-engines/mergetree-family/replication.md#creating-replicated-tables) 部分。 **示例** @@ -1086,12 +1098,11 @@ ClickHouse 支持动态的 interserver 凭据轮换,无需同时停止所有 ``` ## replica_group_name {#replica_group_name} -数据库 Replicated 的副本组名称。 +复制数据库的副本组名称。 -由 Replicated 数据库创建的集群将由同一组中的副本组成。 -DDL 查询只会等待同一组中的副本。 +由复制数据库创建的集群将由同一组中的副本组成。DDL 查询将仅等待同一组中的副本。 -默认是空的。 +默认为空。 **示例** @@ -1100,7 +1111,7 @@ DDL 查询只会等待同一组中的副本。 ``` ## remap_executable {#remap_executable} -用于使用大页重新分配机器代码(“文本”的)内存的设置。 +用于使用大页重新分配机器代码(“文本”的设置)。 :::note 此功能高度实验性。 @@ -1126,7 +1137,7 @@ DDL 查询只会等待同一组中的副本。 ``` ## max_session_timeout {#max_session_timeout} -最大会话超时,以秒为单位。 +最大会话超时时间,以秒为单位。 示例: @@ -1135,9 +1146,9 @@ DDL 查询只会等待同一组中的副本。 ``` ## merge_tree {#merge_tree} -用于 [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) 表的细致调整。 +对[MergeTree](../../engines/table-engines/mergetree-family/mergetree.md)中表格的微调。 -有关更多信息,请参见 MergeTreeSettings.h 头文件。 +有关更多信息,请参阅 MergeTreeSettings.h 头文件。 **示例** @@ -1148,11 +1159,11 @@ DDL 查询只会等待同一组中的副本。 ``` ## metric_log {#metric_log} -默认情况下被禁用。 +默认情况下是禁用的。 **启用** -要手动开启指标历史收集 [`system.metric_log`](../../operations/system-tables/metric_log.md),请创建 `/etc/clickhouse-server/config.d/metric_log.xml`,内容如下: +要手动开启指标历史收集 [`system.metric_log`](../../operations/system-tables/metric_log.md),创建 `/etc/clickhouse-server/config.d/metric_log.xml` 并使用以下内容: ```xml @@ -1171,7 +1182,7 @@ DDL 查询只会等待同一组中的副本。 **禁用** -要禁用 `metric_log` 设置,您应创建以下文件 `/etc/clickhouse-server/config.d/disable_metric_log.xml`,内容如下: +要禁用 `metric_log` 设置,您需要创建以下文件 `/etc/clickhouse-server/config.d/disable_metric_log.xml` 并使用以下内容: ```xml @@ -1180,43 +1191,11 @@ DDL 查询只会等待同一组中的副本。 ``` -## latency_log {#latency_log} - -默认情况下被禁用。 - -**启用** - -要手动开启延迟历史收集 [`system.latency_log`](../../operations/system-tables/latency_log.md),请创建 `/etc/clickhouse-server/config.d/latency_log.xml`,内容如下: - -```xml - - - system -

ymmc?G0#3M59UMy@WQ({ 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%0DF+yQiHQIm0EFCaMMg_wPrGdXA%^tIz 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/vC#%2dJ2v;m*70 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 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/images/mysql3.png b/i18n/zh/docusaurus-plugin-content-docs/current/interfaces/images/mysql3.png deleted file mode 100644 index 407504bb9efd97065ef9333735197db568df4a8f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 221229 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

latency_log
- 7500 - 1000 - 1048576 - 8192 - 524288 - false - - -``` - -**禁用** - -要禁用 `latency_log` 设置,您应创建以下文件 `/etc/clickhouse-server/config.d/disable_latency_log.xml`,内容如下: - -```xml - - - -``` ## replicated_merge_tree {#replicated_merge_tree} -用于 [ReplicatedMergeTree](../../engines/table-engines/mergetree-family/mergetree.md) 表的细致调整。此设置优先级更高。 +对 [ReplicatedMergeTree](../../engines/table-engines/mergetree-family/mergetree.md) 中表格的微调。此设置具有更高优先级。 -有关更多信息,请参见 MergeTreeSettings.h 头文件。 +有关更多信息,请参阅 MergeTreeSettings.h 头文件。 **示例** @@ -1253,32 +1232,32 @@ DDL 查询只会等待同一组中的副本。 SSL 客户端/服务器配置。 -通过 `libpoco` 库提供对 SSL 的支持。可用的配置选项在 [SSLManager.h](https://github.com/ClickHouse-Extras/poco/blob/master/NetSSL_OpenSSL/include/Poco/Net/SSLManager.h) 中进行了说明。默认值可以在 [SSLManager.cpp](https://github.com/ClickHouse-Extras/poco/blob/master/NetSSL_OpenSSL/src/SSLManager.cpp) 中找到。 +SSL 的支持由 `libpoco` 库提供。可用的配置选项在 [SSLManager.h](https://github.com/ClickHouse-Extras/poco/blob/master/NetSSL_OpenSSL/include/Poco/Net/SSLManager.h) 中进行了说明。默认值可以在 [SSLManager.cpp](https://github.com/ClickHouse-Extras/poco/blob/master/NetSSL_OpenSSL/src/SSLManager.cpp) 中找到。 服务器/客户端设置的密钥: -| 选项 | 描述 | 默认值 | -|-------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------| -| `privateKeyFile` | PEM 证书的私钥文件的路径。文件可以同时包含密钥和证书。 | | -| `certificateFile` | PEM 格式的客户端/服务器证书文件的路径。如果 `privateKeyFile` 包含证书,则可以省略它。 | | -| `caConfig` | 包含受信任 CA 证书的文件或目录的路径。如果这指向一个文件,它必须是 PEM 格式,可以包含多个 CA 证书。如果这指向一个目录,则必须包含每个 CA 证书一个 .pem 文件。这些文件名通过 CA 主体名称哈希值查找。有关详细信息,请参见 [SSL_CTX_load_verify_locations](https://www.openssl.org/docs/man3.0/man3/SSL_CTX_load_verify_locations.html) 的手册页。 | | -| `verificationMode` | 检查节点证书的方式。详细信息在 [Context](https://github.com/ClickHouse-Extras/poco/blob/master/NetSSL_OpenSSL/include/Poco/Net/Context.h) 类的描述中。可能的值为:`none`、`relaxed`、`strict`、`once`。 | `relaxed` | -| `verificationDepth` | 验证链的最大长度。如果证书链长度超过设置的值,验证将失败。 | `9` | -| `loadDefaultCAFile` | 是否使用 OpenSSL 的内置 CA 证书。ClickHouse 假设内置 CA 证书在 `/etc/ssl/cert.pem` 文件(或 `/etc/ssl/certs` 目录)中,或者在通过环境变量 `SSL_CERT_FILE`(或 `SSL_CERT_DIR`)指定的文件(或目录)中。 | `true` | -| `cipherList` | 支持的 OpenSSL 加密方式。 | `ALL:!ADH:!LOW:!EXP:!MD5:!3DES:@STRENGTH` | -| `cacheSessions` | 启用或禁用会话缓存。必须与 `sessionIdContext` 一起使用。可接受的值:`true`、`false`。 | `false` | -| `sessionIdContext` | 服务器附加到每个生成标识符的唯一随机字符集。字符串的长度不得超过 `SSL_MAX_SSL_SESSION_ID_LENGTH`。此参数始终推荐使用,因为它有助于避免在服务器缓存会话时以及客户端请求缓存时的问题。 | `$\{application.name\}` | -| `sessionCacheSize` | 服务器缓存的最大会话数。值为 `0` 表示无限会话。 | [1024\*20](https://github.com/ClickHouse/boringssl/blob/master/include/openssl/ssl.h#L1978) | -| `sessionTimeout` | 服务器上缓存会话的时间(以小时为单位)。 | `2` | -| `extendedVerification` | 如果启用,则验证证书的 CN 或 SAN 是否与对等主机名匹配。 | `false` | -| `requireTLSv1` | 要求建立 TLSv1 连接。可接受的值:`true`、`false`。 | `false` | -| `requireTLSv1_1` | 要求建立 TLSv1.1 连接。可接受的值:`true`、`false`。 | `false` | -| `requireTLSv1_2` | 要求建立 TLSv1.2 连接。可接受的值:`true`、`false`。 | `false` | -| `fips` | 激活 OpenSSL FIPS 模式。如果库的 OpenSSL 版本支持 FIPS,才支持此选项。 | `false` | -| `privateKeyPassphraseHandler` | 请求访问私钥的密码短语的类(PrivateKeyPassphraseHandler 子类)。例如:``、`KeyFileHandler`、`test`、``。 | `KeyConsoleHandler` | -| `invalidCertificateHandler` | 验证无效证书的类(CertificateHandler 的子类)。例如:` RejectCertificateHandler `。 | `RejectCertificateHandler` | -| `disableProtocols` | 不允许使用的协议。 | | -| `preferServerCiphers` | 客户端首选的服务器密码。 | `false` | +| 选项 | 描述 | 默认值 | +|-------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------| +| `privateKeyFile` | PEM 证书的私钥文件路径。该文件可以同时包含密钥和证书。 | | +| `certificateFile` | PEM 格式的客户端/服务器证书文件路径。如果 `privateKeyFile` 包含证书,则可以省略此项。 | | +| `caConfig` | 包含受信任 CA 证书的文件或目录路径。如果指向文件,则必须为 PEM 格式,并且可以包含多个 CA 证书。如果指向目录,则必须为每个 CA 证书包含一个 .pem 文件。文件名通过 CA 主体名称的哈希值查找。详细信息可以在 [SSL_CTX_load_verify_locations](https://www.openssl.org/docs/man3.0/man3/SSL_CTX_load_verify_locations.html) 的手册页中找到。 | | +| `verificationMode` | 检查节点证书的方法。详细信息请参见 [Context](https://github.com/ClickHouse-Extras/poco/blob/master/NetSSL_OpenSSL/include/Poco/Net/Context.h) 类的描述。可能的值:`none`、`relaxed`、`strict`、`once`。 | `relaxed` | +| `verificationDepth` | 验证链的最大长度。如果证书链长度超过设置值,则验证将失败。 | `9` | +| `loadDefaultCAFile` | 是否使用 OpenSSL 的内置 CA 证书。ClickHouse 假定内置的 CA 证书位于文件 `/etc/ssl/cert.pem`(或目录 `/etc/ssl/certs`),或在环境变量 `SSL_CERT_FILE`(或 `SSL_CERT_DIR`)指定的文件(或目录)中。 | `true` | +| `cipherList` | 支持的 OpenSSL 加密方式。 | `ALL:!ADH:!LOW:!EXP:!MD5:!3DES:@STRENGTH` | +| `cacheSessions` | 启用或禁用会话缓存。必须与 `sessionIdContext` 结合使用。可接受的值:`true`、`false`。 | `false` | +| `sessionIdContext` | 一组唯一的随机字符,服务器将其附加到每个生成的标识符中。字符串的长度不得超过 `SSL_MAX_SSL_SESSION_ID_LENGTH`。始终推荐使用此参数,因为它有助于避免服务器缓存会话和客户端请求缓存时的问题。 | `$\{application.name\}` | +| `sessionCacheSize` | 服务器缓存的会话最大数量。值为 `0` 意味着无限制会话。 | [1024\*20](https://github.com/ClickHouse/boringssl/blob/master/include/openssl/ssl.h#L1978) | +| `sessionTimeout` | 服务器上缓存会话的时间(小时)。 | `2` | +| `extendedVerification` | 如果启用,验证证书 CN 或 SAN 是否与对等主机名匹配。 | `false` | +| `requireTLSv1` | 要求建立 TLSv1 连接。可接受的值:`true`、`false`。 | `false` | +| `requireTLSv1_1` | 要求建立 TLSv1.1 连接。可接受的值:`true`、`false`。 | `false` | +| `requireTLSv1_2` | 要求建立 TLSv1.2 连接。可接受的值:`true`、`false`。 | `false` | +| `fips` | 激活 OpenSSL FIPS 模式。仅在库的 OpenSSL 版本支持 FIPS 的情况下有效。 | `false` | +| `privateKeyPassphraseHandler` | 请求访问私钥的密码短语的类(PrivateKeyPassphraseHandler 子类)。例如:``、`KeyFileHandler`、`test`、``。 | `KeyConsoleHandler` | +| `invalidCertificateHandler` | 验证无效证书的类(CertificateHandler 的子类)。例如:` RejectCertificateHandler ` 。 | `RejectCertificateHandler` | +| `disableProtocols` | 不允许使用的协议。 | | +| `preferServerCiphers` | 客户端优选的服务器密码。 | `false` | **设置示例:** @@ -1311,7 +1290,7 @@ SSL 客户端/服务器配置。 ``` ## part_log {#part_log} -记录与 [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) 相关联的事件。比如,添加或合并数据。您可以使用日志来模拟合并算法并比较它们的特性。您可以可视化合并过程。 +记录与 [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) 相关的事件。例如,添加或合并数据。您可以使用日志模拟合并算法并比较其特性。您可以通过可视化合并过程。 查询记录在 [system.part_log](/operations/system-tables/part_log) 表中,而不是在单独的文件中。您可以在 `table` 参数中配置此表的名称(见下文)。 @@ -1333,10 +1312,10 @@ SSL 客户端/服务器配置。 ``` ## path {#path} -包含数据的目录的路径。 +包含数据的目录路径。 :::note -尾部斜杠是必须的。 +尾随斜杠是强制的。 ::: **示例** @@ -1366,16 +1345,16 @@ SSL 客户端/服务器配置。 ``` ## prometheus {#prometheus} -公开指标数据以供 [Prometheus](https://prometheus.io) 抓取。 +暴露用于从 [Prometheus](https://prometheus.io) 抓取的指标数据。 设置: -- `endpoint` – Prometheus 服务器抓取指标的 HTTP 端点。以 '/' 开头。 +- `endpoint` – Prometheus 服务器抓取指标的 HTTP 端点。从 '/' 开始。 - `port` – `endpoint` 的端口。 -- `metrics` – 公开来自 [system.metrics](/operations/system-tables/metrics) 表的指标。 -- `events` – 公开来自 [system.events](/operations/system-tables/events) 表的指标。 -- `asynchronous_metrics` – 公开来自 [system.asynchronous_metrics](/operations/system-tables/asynchronous_metrics) 表的当前指标值。 -- `errors` - 公开自上次服务器重启以来按错误代码发生的错误数量。这些信息也可以从 [system.errors](/operations/system-tables/errors) 获取。 +- `metrics` – 从 [system.metrics](/operations/system-tables/metrics) 表中暴露指标。 +- `events` – 从 [system.events](/operations/system-tables/events) 表中暴露指标。 +- `asynchronous_metrics` – 从 [system.asynchronous_metrics](/operations/system-tables/asynchronous_metrics) 表中暴露当前指标值。 +- `errors` - 暴露自上次服务器重启以来按错误代码发生的错误数量。此信息也可以从 [system.errors](/operations/system-tables/errors) 中获得。 **示例** @@ -1403,13 +1382,13 @@ curl 127.0.0.1:9363/metrics ``` ## query_log {#query_log} -使用 [log_queries=1](../../operations/settings/settings.md) 设置记录查询的设置。 +记录通过 [log_queries=1](../../operations/settings/settings.md) 设置接收到的查询的设置。 -查询记录在 [system.query_log](/operations/system-tables/query_log) 表中,而不是在单独的文件中。您可以在 `table` 参数中更改表的名称(见下文)。 +查询记录在 [system.query_log](/operations/system-tables/query_log) 表中,而不是在单独的文件中。您可以在 `table` 参数中更改此表的名称(见下文)。 -如果表不存在,ClickHouse 会创建它。如果在更新 ClickHouse 服务器时查询日志的结构发生变化,则旧结构的表将被重命名,并自动创建新表。 +如果表不存在,ClickHouse 将创建它。如果在更新 ClickHouse 服务器时查询日志的结构发生变化,则旧结构的表将被重命名,并自动创建新表。 **示例** @@ -1431,7 +1410,7 @@ curl 127.0.0.1:9363/metrics **启用** -要手动开启 [`system.query_metric_log`](../../operations/system-tables/query_metric_log.md) 的指标历史收集,请创建 `/etc/clickhouse-server/config.d/query_metric_log.xml`,内容如下: +要手动启用度量历史收集 [`system.query_metric_log`](../../operations/system-tables/query_metric_log.md),请创建 `/etc/clickhouse-server/config.d/query_metric_log.xml` 文件,内容如下: ```xml @@ -1450,7 +1429,7 @@ curl 127.0.0.1:9363/metrics **禁用** -要禁用 `query_metric_log` 设置,您应该创建以下文件 `/etc/clickhouse-server/config.d/disable_query_metric_log.xml`,内容如下: +要禁用 `query_metric_log` 设置,您应创建以下文件 `/etc/clickhouse-server/config.d/disable_query_metric_log.xml`,内容如下: ```xml @@ -1463,18 +1442,18 @@ curl 127.0.0.1:9363/metrics [查询缓存](../query-cache.md) 配置。 -以下设置可用: +可用的设置如下: -| 设置 | 描述 | 默认值 | -|---------------------------|---------------------------------------------------------------------------------------------|-----------------| -| `max_size_in_bytes` | 最大缓存大小(以字节为单位)。`0` 表示查询缓存被禁用。 | `1073741824` | -| `max_entries` | 缓存中存储的 `SELECT` 查询结果的最大数目。 | `1024` | -| `max_entry_size_in_bytes` | 可以保存在缓存中的 `SELECT` 查询结果的最大字节数。 | `1048576` | -| `max_entry_size_in_rows` | 可以保存在缓存中的 `SELECT` 查询结果的最大行数。 | `30000000` | +| 设置 | 描述 | 默认值 | +|---------------------------|--------------------------------------------------------------------------------|------------------| +| `max_size_in_bytes` | 最大缓存大小(以字节为单位)。`0` 表示禁用查询缓存。 | `1073741824` | +| `max_entries` | 缓存中存储的 `SELECT` 查询结果的最大数量。 | `1024` | +| `max_entry_size_in_bytes` | `SELECT` 查询结果在缓存中保存最大字节数。 | `1048576` | +| `max_entry_size_in_rows` | `SELECT` 查询结果在缓存中保存的最大行数。 | `30000000` | :::note -- 更改后的设置会立即生效。 -- 查询缓存的数据分配在 DRAM 中。如果内存紧张,请确保为 `max_size_in_bytes` 设置一个较小的值或完全禁用查询缓存。 +- 改变的设置会立即生效。 +- 查询缓存的数据分配在 DRAM 中。如果内存紧张,请确保将 `max_size_in_bytes` 设置为较小值或完全禁用查询缓存。 ::: **示例** @@ -1489,13 +1468,13 @@ curl 127.0.0.1:9363/metrics ``` ## query_thread_log {#query_thread_log} -用于记录通过 [log_query_threads=1](/operations/settings/settings#log_query_threads) 设置接收的查询线程的设置。 +记录通过 [log_query_threads=1](/operations/settings/settings#log_query_threads) 设置接收到的查询线程的设置。 -查询记录在 [system.query_thread_log](/operations/system-tables/query_thread_log) 表中,而不是在单独的文件中。您可以在 `table` 参数中更改表的名称(见下文)。 +查询记录在 [system.query_thread_log](/operations/system-tables/query_thread_log) 表中,而不是在单独的文件中。您可以在 `table` 参数中更改此表的名称(见下文)。 -如果表不存在,ClickHouse 会创建它。如果在更新 ClickHouse 服务器时查询线程日志的结构发生变化,则旧结构的表将被重命名,并自动创建新表。 +如果表不存在,ClickHouse 将创建它。如果在更新 ClickHouse 服务器时查询线程日志的结构发生变化,则旧结构的表将被重命名,并自动创建新表。 **示例** @@ -1513,13 +1492,13 @@ curl 127.0.0.1:9363/metrics ``` ## query_views_log {#query_views_log} -用于记录依赖于通过 [log_query_views=1](/operations/settings/settings#log_query_views) 设置接收的查询视图(实时、物化等)的设置。 +记录依赖于通过 [log_query_views=1](/operations/settings/settings#log_query_views) 设置接收到的查询的视图(实时的、物化的等)的设置。 -查询记录在 [system.query_views_log](/operations/system-tables/query_views_log) 表中,而不是在单独的文件中。您可以在 `table` 参数中更改表的名称(见下文)。 +查询记录在 [system.query_views_log](/operations/system-tables/query_views_log) 表中,而不是在单独的文件中。您可以在 `table` 参数中更改此表的名称(见下文)。 -如果表不存在,ClickHouse 会创建它。如果在更新 ClickHouse 服务器时查询视图日志的结构发生变化,则旧结构的表将被重命名,并自动创建新表。 +如果表不存在,ClickHouse 将创建它。如果在更新 ClickHouse 服务器时查询视图日志的结构发生变化,则旧结构的表将被重命名,并自动创建新表。 **示例** @@ -1543,9 +1522,9 @@ curl 127.0.0.1:9363/metrics 此外: -| 设置 | 描述 | 默认值 | -|--------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------| -| `level` | 最大消息级别(默认 `Trace`),将存储在表中。 | `Trace` | +| 设置 | 描述 | 默认值 | +|---------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------| +| `level` | 记录在表中的最大消息级别(默认为 `Trace`)。 | `Trace` | **示例** @@ -1567,11 +1546,11 @@ curl 127.0.0.1:9363/metrics ``` ## trace_log {#trace_log} -用于记录操作的 [trace_log](/operations/system-tables/trace_log) 系统表的设置。 +用于 [trace_log](/operations/system-tables/trace_log) 系统表操作的设置。 -默认服务器配置文件 `config.xml` 包含以下设置部分: +默认的服务器配置文件 `config.xml` 中包含以下设置部分: ```xml @@ -1611,11 +1590,11 @@ curl 127.0.0.1:9363/metrics ``` ## crash_log {#crash_log} -用于记录 `BACKUP` 和 `RESTORE` 操作的 [crash_log](../../operations/system-tables/crash-log.md) 系统表的设置。 +用于 [crash_log](../../operations/system-tables/crash_log.md) 系统表操作的设置。 -默认服务器配置文件 `config.xml` 包含以下设置部分: +默认的服务器配置文件 `config.xml` 中包含以下设置部分: ```xml @@ -1631,12 +1610,13 @@ curl 127.0.0.1:9363/metrics ``` ## custom_cached_disks_base_directory {#custom_cached_disks_base_directory} -此设置指定自定义(从 SQL 创建的)缓存磁盘的缓存路径。 -`custom_cached_disks_base_directory` 对自定义磁盘的优先级高于 `filesystem_caches_path`(在 `filesystem_caches_path.xml` 中找到),如果前者缺失,则使用后者。 -文件系统缓存设置路径必须位于该目录内部,否则将抛出异常,阻止磁盘创建。 +此设置指定自定义(由 SQL 创建的)缓存磁盘的缓存路径。 +`custom_cached_disks_base_directory` 对自定义磁盘的优先级高于 `filesystem_caches_path`(在 `filesystem_caches_path.xml` 中),如果前者不存在,则使用后者。 +文件系统缓存设置路径必须位于该目录内,否则将引发异常,阻止磁盘创建。 :::note -这不会影响在为其升级服务器的旧版本上创建的磁盘。在这种情况下,不会抛出异常,以便服务器能够成功启动。 +这不会影响在较旧版本上创建的磁盘,该版本是通过升级服务器得到的。 +在这种情况下,将不会抛出异常,以允许服务器成功启动。 ::: 示例: @@ -1667,7 +1647,7 @@ curl 127.0.0.1:9363/metrics ``` -## blog_storage_log {#blog_storage_log} +## blob_storage_log {#blob_storage_log} 用于 [`blob_storage_log`](../system-tables/blob_storage_log.md) 系统表的设置。 @@ -1686,7 +1666,9 @@ curl 127.0.0.1:9363/metrics ``` ## query_masking_rules {#query_masking_rules} -基于正则表达式的规则,将在存储到服务器日志之前应用于查询以及所有日志消息,[`system.query_log`](/operations/system-tables/query_log)、[`system.text_log`](/operations/system-tables/text_log)、[`system.processes`](/operations/system-tables/processes) 表以及发送到客户端的日志。这有助于防止 SQL 查询中的敏感数据泄漏,例如名字、电子邮件、个人标识符或信用卡号码。 +基于正则表达式的规则,这些规则将在将查询以及所有日志消息存储到服务器日志中之前应用于它们, +[`system.query_log`](/operations/system-tables/query_log)、[`system.text_log`](/operations/system-tables/text_log)、[`system.processes`](/operations/system-tables/processes) 表,以及发送给客户端的日志。这可以防止 +从 SQL 查询中泄漏敏感数据,例如姓名、电子邮件、个人标识符或信用卡号码到日志中。 **示例** @@ -1703,19 +1685,19 @@ curl 127.0.0.1:9363/metrics **配置字段**: | 设置 | 描述 | -|----------|--------------------------------------------------------------------------| -| `name` | 规则的名称(可选) | -| `regexp` | 兼容 RE2 的正则表达式(强制) | -| `replace`| 敏感数据的替代字符串(可选,默认 - 六个星号) | +|-----------|--------------------------------------------------------------------------| +| `name` | 规则名称(可选) | +| `regexp` | 兼容 RE2 的正则表达式(强制) | +| `replace` | 敏感数据的替换字符串(可选,默认 - 六个星号) | -掩码规则应用于整个查询(以防止泄漏来自格式错误/不可解析查询的敏感数据)。 +掩码规则应用于整个查询(防止因为格式错误/无法解析的查询而泄漏敏感数据)。 -[`system.events`](/operations/system-tables/events) 表有一个计数器 `QueryMaskingRulesMatch`,记录查询掩码规则匹配的总数。 +[`system.events`](/operations/system-tables/events) 表有计数器 `QueryMaskingRulesMatch`,包含查询掩码规则匹配的总数。 -对于分布式查询,每个服务器必须单独配置,否则传递给其他节点的子查询将不带掩码存储。 +对于分布式查询,每个服务器必须单独配置,否则传递给其他节点的子查询将不进行掩码处理。 ## remote_servers {#remote_servers} -用于 [Distributed](../../engines/table-engines/special/distributed.md) 表引擎和 `cluster` 表函数所使用的集群的配置。 +[Distributed](../../engines/table-engines/special/distributed.md) 表引擎和 `cluster` 表函数使用的集群配置。 **示例** @@ -1734,12 +1716,12 @@ curl 127.0.0.1:9363/metrics 允许在与 URL 相关的存储引擎和表函数中使用的主机列表。 -当使用 `\` xml 标签添加主机时: -- 必须按 URL 中的方式准确指定,因为名称在 DNS 解析之前会被检查。例如:`clickhouse.com` -- 如果在 URL 中明确指定了端口,则会将 host:port 整体检查。例如:`clickhouse.com:80` -- 如果未指定端口,则允许主机的任何端口。例如:如果指定 `clickhouse.com`,则允许 `clickhouse.com:20`(FTP)、`clickhouse.com:80`(HTTP)、`clickhouse.com:443`(HTTPS)等。 -- 如果主机以 IP 地址指定,则按 URL 中指定的方式进行检查。例如:[2a02:6b8:a::a]。 -- 如果有重定向且支持重定向已启用,则每个重定向(位置字段)都会进行检查。 +添加带有 `` xml 标签的主机时: +- 应该按 URL 中的指定格式准确指定,因为名称在 DNS 解析之前会进行检查。例如:`clickhouse.com` +- 如果在 URL 中明确指定了端口,则会整体检查 host:port。例如:`clickhouse.com:80` +- 如果未在端口中指定主机,则允许该主机的任何端口。例如:如果指定了 `clickhouse.com` ,则允许 `clickhouse.com:20`(FTP)、`clickhouse.com:80`(HTTP)、`clickhouse.com:443`(HTTPS)等。 +- 如果主机作为 IP 地址指定,则检查 URL 中的规定格式。例如:[2a02:6b8:a::a]。 +- 如果存在重定向并且启用了重定向支持,则检查每个重定向(位置字段)。 例如: @@ -1752,9 +1734,9 @@ curl 127.0.0.1:9363/metrics 服务器的时区。 -指定为 IANA 标识符,用于 UTC 时区或地理位置(例如,Africa/Abidjan)。 +指定为 IANA 的 UTC 时区或地理位置标识符(例如,Africa/Abidjan)。 -时区在将 DateTime 字段输出到文本格式(在屏幕上或文件中打印)以及从字符串获取 DateTime 时,对于字符串和日期时间格式之间的转换是必需的。此外,如果未在输入参数中接收时区,则在与时间和日期相关的函数中使用时区。 +时区对于在 DateTime 字段输出到文本格式(在屏幕上或文件中打印时)和从字符串获取 DateTime 时的字符串和 DateTime 格式之间的转换是必要的。此外,如果没有在输入参数中接收时区,则在处理时间和日期的函数中也会使用该时区。 **示例** @@ -1767,7 +1749,7 @@ curl 127.0.0.1:9363/metrics - [session_timezone](../settings/settings.md#session_timezone) ## tcp_port {#tcp_port} -通过 TCP 协议与客户端通信的端口。 +与客户端通过 TCP 协议进行通信的端口。 **示例** @@ -1776,7 +1758,7 @@ curl 127.0.0.1:9363/metrics ``` ## tcp_port_secure {#tcp_port_secure} -用于与客户端安全通信的 TCP 端口。与 [OpenSSL](#openssl) 设置一起使用。 +与客户端安全通信的 TCP 端口。与 [OpenSSL](#openssl) 设置一起使用。 **默认值** @@ -1785,7 +1767,7 @@ curl 127.0.0.1:9363/metrics ``` ## mysql_port {#mysql_port} -通过 MySQL 协议与客户端通信的端口。 +与客户端通过 MySQL 协议进行通信的端口。 :::note - 正整数指定要监听的端口号 @@ -1799,7 +1781,7 @@ curl 127.0.0.1:9363/metrics ``` ## postgresql_port {#postgresql_port} -通过 PostgreSQL 协议与客户端通信的端口。 +与客户端通过 PostgreSQL 协议进行通信的端口。 :::note - 正整数指定要监听的端口号 @@ -1811,13 +1793,19 @@ curl 127.0.0.1:9363/metrics ```xml 9005 ``` +## mysql_require_secure_transport {#mysql_require_secure_transport} + +如果设置为 true,则需要通过 [mysql_port](#mysql_port) 与客户端进行安全通信。将拒绝使用 `--ssl-mode=none` 选项进行的连接。与 [OpenSSL](#openssl) 设置一起使用。 +## postgresql_require_secure_transport {#postgresql_require_secure_transport} + +如果设置为 true,则需要通过 [postgresql_port](#postgresql_port) 与客户端进行安全通信。将拒绝使用 `sslmode=disable` 选项进行的连接。与 [OpenSSL](#openssl) 设置一起使用。 ## tmp_path {#tmp_path} -在本地文件系统上存储用于处理大查询的临时数据的路径。 +在本地文件系统上存储处理大查询的临时数据的路径。 :::note - 只能使用一个选项来配置临时数据存储:`tmp_path`、`tmp_policy`、`temporary_data_in_cache`。 -- 尾部斜杠是必须的。 +- 尾随斜杠是强制的。 ::: **示例** @@ -1827,7 +1815,7 @@ curl 127.0.0.1:9363/metrics ``` ## url_scheme_mappers {#url_scheme_mappers} -用于将简写或符号 URL 前缀转换为完整 URL 的配置。 +翻译缩写或符号 URL 前缀为完整 URL 的配置。 示例: @@ -1877,11 +1865,11 @@ curl 127.0.0.1:9363/metrics ``` ## users_config {#users_config} -包含以下内容的文件路径: +包含的文件路径: - 用户配置。 - 访问权限。 -- 设置配置文件。 +- 设置配置。 - 配额设置。 **示例** @@ -1893,15 +1881,15 @@ curl 127.0.0.1:9363/metrics 访问控制系统中的可选改进设置。 -| 设置 | 描述 | 默认值 | -|----------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------| -| `users_without_row_policies_can_read_rows` | 设置没有权限行策略的用户是否仍然可以使用 `SELECT` 查询读取行。例如,如果有两个用户 A 和 B,并且只为 A 定义了行策略,则如果此设置为 true,用户 B 将看到所有行。如果此设置为 false,用户 B 将不看到任何行。 | `true` | -| `on_cluster_queries_require_cluster_grant` | 设置 `ON CLUSTER` 查询是否需要 `CLUSTER` 授权。 | `true` | -| `select_from_system_db_requires_grant` | 设置 `SELECT * FROM system.` 是否需要任何授权并可以由任何用户执行。如果设置为 true,则此查询需要 `GRANT SELECT ON system.
`,就像非系统表一样。例外情况:一些系统表(`tables`、`columns`、`databases` 以及一些常量表如 `one`、`contributors`)仍然对所有人可访问;并且如果授予了 `SHOW` 权限(例如 `SHOW USERS`),则相应的系统表(即 `system.users`)将可访问。 | `true` | -| `select_from_information_schema_requires_grant` | 设置 `SELECT * FROM information_schema.
` 是否需要任何授权并可以由任何用户执行。如果设置为 true,则此查询需要 `GRANT SELECT ON information_schema.
`,就像普通表一样。 | `true` | -| `settings_constraints_replace_previous` | 设置某个设置的配置文件中的约束是否会取消对该设置之前约束(在其他配置文件中定义)的操作,包括新约束未设置的字段。它还启用 `changeable_in_readonly` 约束类型。 | `true` | -| `table_engines_require_grant` | 设置使用特定表引擎创建表是否需要授权。 | `false` | -| `role_cache_expiration_time_seconds` | 设置角色在角色缓存中存储的最后访问后的秒数。 | `600` | +| 设置 | 描述 | 默认值 | +|---------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------| +| `users_without_row_policies_can_read_rows` | 设置没有权限行策略的用户是否可以通过 `SELECT` 查询读取行。例如,如果有两个用户 A 和 B,并且仅为 A 定义了行策略,则如果此设置为 true,用户 B 将看到所有行。如果此设置为 false,用户 B 将看不到任何行。 | `true` | +| `on_cluster_queries_require_cluster_grant` | 设置 `ON CLUSTER` 查询是否需要 `CLUSTER` 权限。 | `true` | +| `select_from_system_db_requires_grant` | 设置 `SELECT * FROM system.
` 是否需要任何权限,并且可以被任何用户执行。如果设置为 true,则此查询需要 `GRANT SELECT ON system.
`,与普通表相同。例外情况:一些系统表(`tables`、`columns`、`databases` 和一些常量表,如 `one`、`contributors`)仍然可以被所有人访问;如果授予了 `SHOW` 权限(例如 `SHOW USERS`),则相应的系统表(即 `system.users`)将可访问。 | `true` | +| `select_from_information_schema_requires_grant` | 设置 `SELECT * FROM information_schema.
` 是否需要任何权限,并且可以被任何用户执行。如果设置为 true,则此查询需要 `GRANT SELECT ON information_schema.
`,与普通表相同。 | `true` | +| `settings_constraints_replace_previous` | 设置某个设置的设置配置文件中的约束是否会取消其他配置文件中对该设置的先前约束的操作,包括新约束未设置的字段。它还启用了 `changeable_in_readonly` 约束类型。 | `true` | +| `table_engines_require_grant` | 设置创建具有特定表引擎的表是否需要权限。 | `false` | +| `role_cache_expiration_time_seconds` | 设置角色在角色缓存中存储的最后访问时间的秒数。 | `600` | 示例: @@ -1932,33 +1920,49 @@ curl 127.0.0.1:9363/metrics 7500 ``` +## dead_letter_queue {#dead_letter_queue} + +“dead_letter_queue” 系统表的设置。 + + + +默认设置为: + +```xml + + system +
dead_letter
+ toYYYYMM(event_date) + 7500 + +``` ## zookeeper {#zookeeper} -包含允许 ClickHouse 与 [ZooKeeper](http://zookeeper.apache.org/) 集群交互的设置。ClickHouse 在使用副本表时使用 ZooKeeper 存储副本的元数据。如果不使用副本表,则可以省略该参数部分。 +包含允许 ClickHouse 与 [ZooKeeper](http://zookeeper.apache.org/) 集群交互的设置。ClickHouse 使用 ZooKeeper 存储复制表的副本的元数据。如果未使用复制表,则可以省略此参数部分。 -可以通过子标签配置以下设置: +可通过子标签配置以下设置: -| 设置 | 描述 | -|-----------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `node` | ZooKeeper 端点。您可以设置多个端点。例如:`example_host2181`。`index` 属性指定尝试连接到 ZooKeeper 集群时的节点顺序。 | -| `session_timeout_ms` | 客户端会话的最大超时(以毫秒为单位)。 | -| `operation_timeout_ms` | 单个操作的最大超时(以毫秒为单位)。 | -| `root` (可选) | 用作 ClickHouse 服务器使用的 znodes 根目录的 znode。 | -| `fallback_session_lifetime.min` (可选) | 当主节点不可用(负载均衡)时,备用节点的 ZooKeeper 会话的最小生命期限制(以秒为单位)。默认值:3小时。 | -| `fallback_session_lifetime.max` (可选) | 当主节点不可用(负载均衡)时,备用节点的 ZooKeeper 会话的最大生命期限制(以秒为单位)。默认值:6小时。 | -| `identity` (可选) | ZooKeeper 访问请求的 znodes 所需的用户和密码。 | -| `use_compression` (可选) | 如果设置为 true,则在 Keeper 协议中启用压缩。 | - -另外还有 `zookeeper_load_balancing` 设置(可选),让您选择 ZooKeeper 节点选择的算法: - -| 算法名称 | 描述 | -|----------------------------|--------------------------------------------------------------------------------------------------------------------------------| -| `random` | 随机选择其中一个 ZooKeeper 节点。 | -| `in_order` | 选择第一个 ZooKeeper 节点,如果不可用,则选择第二个,以此类推。 | -| `nearest_hostname` | 选择一个与服务器主机名最相近的 ZooKeeper 节点,主机名按名称前缀进行比较。 | -| `hostname_levenshtein_distance` | 与 `nearest_hostname` 相似,但以 levenshtein 距离方式比较主机名。 | -| `first_or_random` | 选择第一个 ZooKeeper 节点,如果不可用,则随机选择剩余的 ZooKeeper 节点。 | -| `round_robin` | 选择第一个 ZooKeeper 节点,如果发生重新连接,则选择下一个。 | +| 设置 | 描述 | +|-------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `node` | ZooKeeper 端点。可以设置多个端点。例如 `example_host2181`。`index` 属性指定在尝试连接到 ZooKeeper 集群时节点的顺序。 | +| `session_timeout_ms` | 客户端会话的最大超时,单位为毫秒。 | +| `operation_timeout_ms` | 单个操作的最大超时,单位为毫秒。 | +| `root` (可选) | 用作 ClickHouse 服务器使用的 znode 的根节点。 | +| `fallback_session_lifetime.min` (可选) | 在主节点不可用时,回退节点的 ZooKeeper 会话的最小生存时间(负载均衡)。以秒为单位。默认:3小时。 | +| `fallback_session_lifetime.max` (可选) | 在主节点不可用时,回退节点的 ZooKeeper 会话的最大生存时间(负载均衡)。以秒为单位。默认:6小时。 | +| `identity` (可选) | ZooKeeper 访问请求的 znode 所需的用户和密码。 | +| `use_compression` (可选) | 如果设置为 true,则启用 Keeper 协议中的压缩。 | + +还有 `zookeeper_load_balancing` 设置(可选),让您选择 ZooKeeper 节点选择的算法: + +| 算法名称 | 描述 | +|----------------------------|------------------------------------------------------------------------------------------------------------------------------| +| `random` | 随机选择一个 ZooKeeper 节点。 | +| `in_order` | 选择第一个可用的 ZooKeeper 节点,如果不可用则选择第二个,以此类推。 | +| `nearest_hostname` | 选择与服务器主机名最相似的 ZooKeeper 节点,主机名通过名称前缀进行比较。 | +| `hostname_levenshtein_distance` | 与 nearest_hostname 一样,但以 levenshtein 距离的方式进行主机名比较。 | +| `first_or_random` | 选择第一个 ZooKeeper 节点,如果不可用则随机选择剩余的 ZooKeeper 节点。 | +| `round_robin` | 选择第一个 ZooKeeper 节点,如果需要重新连接则选择下一个。 | **示例配置** @@ -1987,46 +1991,45 @@ curl 127.0.0.1:9363/metrics - [Replication](../../engines/table-engines/mergetree-family/replication.md) - [ZooKeeper Programmer's Guide](http://zookeeper.apache.org/doc/current/zookeeperProgrammers.html) -- [ClickHouse 与 ZooKeeper 之间的可选安全通信](/operations/ssl-zookeeper) +- [ClickHouse 与 Zookeeper 之间的可选安全通信](/operations/ssl-zookeeper) ## use_minimalistic_part_header_in_zookeeper {#use_minimalistic_part_header_in_zookeeper} -ZooKeeper 中数据部分头的存储方法。此设置仅适用于 [`MergeTree`](/engines/table-engines/mergetree-family) 家族。可以指定: +ZooKeeper 中数据部分头的存储方法。此设置仅适用于 [`MergeTree`](/engines/table-engines/mergetree-family) 家族。可以在以下位置指定: -**在 `config.xml` 文件的 [merge_tree](#merge_tree) 部分全局配置** +**在 `config.xml` 文件的 [merge_tree](#merge_tree) 部分中全局设置** -ClickHouse 将为服务器上的所有表使用该设置。您可以随时更改该设置。现有表在设置更改时会改变其行为。 +ClickHouse 将对服务器上的所有表使用此设置。可以随时更改此设置。现有表在设置更改时会更改其行为。 -**为每个表** +**对于每个表** -创建表时,指定相应的 [引擎设置](../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-creating-a-table)。即使全局设置发生更改,具有此设置的现有表的行为也不会改变。 +创建表时,指定相应的 [引擎设置](../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-creating-a-table)。现有表的此设置的行为不会改变,即使全局设置更改。 -**可能的值** +**可能值** -- `0` — 功能已关闭。 -- `1` — 功能已开启。 +- `0` — 功能关闭。 +- `1` — 功能开启。 -如果 [`use_minimalistic_part_header_in_zookeeper = 1`](#use_minimalistic_part_header_in_zookeeper),则 [replicated](../../engines/table-engines/mergetree-family/replication.md) 表使用单个 `znode` 紧凑地存储数据部分的头。如果表包含许多列,此存储方法显著减少存储在 ZooKeeper 中的数据量。 +如果 [`use_minimalistic_part_header_in_zookeeper = 1`](#use_minimalistic_part_header_in_zookeeper),则 [replicated](../../engines/table-engines/mergetree-family/replication.md) 表以紧凑的方式使用单个 `znode` 存储数据部分的头。如果表包含许多列,此存储方法显著减少存储在 ZooKeeper 中的数据量。 :::note -在应用 `use_minimalistic_part_header_in_zookeeper = 1` 后,您无法将 ClickHouse 服务器降级到不支持此设置的版本。在集群中的服务器上升级 ClickHouse 时请小心。不要同时升级所有服务器。最好在测试环境中或仅在集群的少数服务器上测试 ClickHouse 的新版本。 +应用 `use_minimalistic_part_header_in_zookeeper = 1` 后,您不能将 ClickHouse 服务器降级到不支持此设置的版本。在对集群中的服务器升级 ClickHouse 时要小心。不要一次升级所有服务器。最好在测试环境中或在集群中的少数几台服务器上测试新版本的 ClickHouse。 -已经使用此设置存储的数据部分头无法恢复到其先前(非紧凑)表示形式。 +已经以此设置存储的数据部分头无法恢复为其先前(非紧凑)表示形式。 ::: ## distributed_ddl {#distributed_ddl} -管理在集群上执行 [distributed ddl 查询](../../sql-reference/distributed-ddl.md) (`CREATE`, `DROP`, `ALTER`, `RENAME`)。 -仅当 [ZooKeeper](/operations/server-configuration-parameters/settings#zookeeper) 启用时有效。 +管理在集群上执行 [distributed ddl queries](../../sql-reference/distributed-ddl.md)(`CREATE`、`DROP`、`ALTER`、`RENAME`)。仅在启用 [ZooKeeper](/operations/server-configuration-parameters/settings#zookeeper) 的情况下工作。 -配置 `` 中的设置包括: +`` 内的可配置设置包括: -| 设置 | 描述 | 默认值 | -|---------------------|---------------------------------------------------------------------------------------------------------------------------|---------------------------------| -| `path` | DDL 查询的 `task_queue` 在 Keeper 中的路径 | | -| `profile` | 用于执行 DDL 查询的配置文件 | | -| `pool_size` | 同时可以运行的 `ON CLUSTER` 查询数量 | | -| `max_tasks_in_queue` | 队列中可以存在的最大任务数。 | `1,000` | -| `task_max_lifetime` | 如果节点的年龄超过此值,则删除节点。 | `7 * 24 * 60 * 60`(一周的秒数)| -| `cleanup_delay_period` | 在接收到新节点事件后,如果上次清理在 `cleanup_delay_period` 秒之前未执行,则开始清理。 | `60` 秒 | +| 设置 | 描述 | 默认值 | +|--------------------------|-----------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------| +| `path` | Keeper 中用于 DDL 查询的 `task_queue` 路径 | | +| `profile` | 执行 DDL 查询时使用的配置文件 | | +| `pool_size` | 可以同时运行多少个 `ON CLUSTER` 查询 | | +| `max_tasks_in_queue` | 队列中可以存在的最大任务数量。 | `1,000` | +| `task_max_lifetime` | 如果节点的寿命超过此值,则删除节点。 | `7 * 24 * 60 * 60`(一周的秒数) | +| `cleanup_delay_period` | 在接收到新节点事件后,清理将在上次清理未早于 `cleanup_delay_period` 秒钟后开始。 | `60` 秒 | **示例** @@ -2064,14 +2067,14 @@ ClickHouse 服务器存储由 SQL 命令创建的用户和角色配置的文件 - [访问控制和帐户管理](/operations/access-rights#access-control-usage) ## allow_plaintext_password {#allow_plaintext_password} -设置是否允许明文密码类型(不安全)。 +设置是否允许明文密码类型(不安全)。 ```xml 1 ``` ## allow_no_password {#allow_no_password} -设置是否允许不安全的无密码类型。 +设置是否允许不安全的无密码密码类型。 ```xml 1 @@ -2085,7 +2088,7 @@ ClickHouse 服务器存储由 SQL 命令创建的用户和角色配置的文件 ``` ## default_session_timeout {#default_session_timeout} -默认会话超时,以秒为单位。 +默认会话超时,单位为秒。 ```xml 60 @@ -2106,13 +2109,13 @@ ClickHouse 服务器存储由 SQL 命令创建的用户和角色配置的文件 ## user_directories {#user_directories} 配置文件的部分,包含以下设置: -- 带有预定义用户的配置文件路径。 -- 存储通过 SQL 命令创建的用户的文件夹路径。 -- 存储和复制通过 SQL 命令创建的用户的 ZooKeeper 节点路径(实验性)。 +- 与预定义用户的配置文件路径。 +- 通过 SQL 命令创建的用户存储的文件夹路径。 +- 通过 SQL 命令创建的用户存储和复制的 ZooKeeper 节点路径(实验性)。 -如果指定了该部分,则 [users_config](/operations/server-configuration-parameters/settings#users_config) 和 [access_control_path](../../operations/server-configuration-parameters/settings.md#access_control_path) 的路径将不再使用。 +如果指定此部分,将不会使用来自 [users_config](/operations/server-configuration-parameters/settings#users_config) 和 [access_control_path](../../operations/server-configuration-parameters/settings.md#access_control_path) 的路径。 -`user_directories` 部分可以包含任意数量的项,项的顺序意味着它们的优先级(项越高,优先级越高)。 +`user_directories` 部分可以包含任意数量的项目,项目的顺序表示优先级(项目越高,优先级越高)。 **示例** @@ -2127,7 +2130,7 @@ ClickHouse 服务器存储由 SQL 命令创建的用户和角色配置的文件 ``` -用户、角色、行政策、配额和配置文件也可以存储在 ZooKeeper 中: +用户、角色、行策略、配额和配置文件也可以存储在 ZooKeeper 中: ```xml @@ -2140,14 +2143,14 @@ ClickHouse 服务器存储由 SQL 命令创建的用户和角色配置的文件 ``` -您还可以定义 `memory` 部分——意味着仅在内存中存储信息,而不写入磁盘,以及 `ldap` 部分——意味着在 LDAP 服务器上存储信息。 +您还可以定义 `memory` 部分——表示仅在内存中存储信息,而不写入磁盘;以及 `ldap` 部分——表示在 LDAP 服务器上存储信息。 -要添加一个 LDAP 服务器作为未在本地定义的用户的远程用户目录,请定义一个带有以下设置的单个 `ldap` 部分: +要将 LDAP 服务器添加为未在本地定义的用户的远程用户目录,请定义一个具有以下设置的单一 `ldap` 部分: -| 设置 | 描述 | -|---------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `server` | 在 `ldap_servers` 配置部分中定义的 LDAP 服务器名称之一。此参数是必需的,不能为空。 | -| `roles` | 包含从 LDAP 服务器检索的每个用户将被分配的本地定义角色列表的部分。如果未指定任何角色,用户在身份验证后将无法执行任何操作。如果在身份验证时列出的角色中有任何未在本地定义,则身份验证尝试将失败,就好像提供的密码不正确。 | +| 设置 | 描述 | +|---------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `server` | 定义在 `ldap_servers` 配置部分中的 LDAP 服务器名称之一。此参数是必需的,并且不能为空。 | +| `roles` | 列出将分配给从 LDAP 服务器检索到的每个用户的本地定义角色的部分。如果没有指定角色,用户在身份验证后将无法执行任何操作。如果在身份验证时列出的任何角色在本地未定义,身份验证尝试将失败,仿佛提供的密码不正确。 | **示例** @@ -2162,7 +2165,7 @@ ClickHouse 服务器存储由 SQL 命令创建的用户和角色配置的文件 ``` ## top_level_domains_list {#top_level_domains_list} -定义一个自定义顶级域名列表,以添加每个条目的格式为 `/path/to/file`。 +定义要添加的自定义顶级域的列表,每个条目的格式为 `/path/to/file`。 例如: @@ -2174,27 +2177,27 @@ ClickHouse 服务器存储由 SQL 命令创建的用户和角色配置的文件 另请参见: - 函数 [`cutToFirstSignificantSubdomainCustom`](../../sql-reference/functions/url-functions.md/#cuttofirstsignificantsubdomaincustom) 及其变体, - 接受一个自定义 TLD 列表名称,返回包含顶级子域的域的一部分,直到第一个显著的子域。 + 它接受自定义 TLD 列表名称,返回包含顶级子域的域部分,直到第一个重要子域。 ## proxy {#proxy} -定义 HTTP 和 HTTPS 请求的代理服务器,当前支持 S3 存储、S3 表函数和 URL 函数。 +定义 HTTP 和 HTTPS 请求的代理服务器,目前支持 S3 存储、S3 表函数和 URL 函数。 -有三种定义代理服务器的方法: +定义代理服务器有三种方法: - 环境变量 - 代理列表 - 远程代理解析器。 -对于特定主机也支持绕过代理服务器,使用 `no_proxy`。 +使用 `no_proxy` 也支持为特定主机绕过代理服务器。 **环境变量** -`http_proxy` 和 `https_proxy` 环境变量允许您为给定协议指定一个代理服务器。如果在您的系统中设置,它应该可以无缝工作。 +`http_proxy` 和 `https_proxy` 环境变量允许您为给定协议指定代理服务器。如果在您的系统上设置,它应该可以无缝工作。 -这是最简单的方法,如果给定协议只有一个代理服务器,并且该代理服务器不会改变。 +这是最简单的方法,如果给定协议只有一个代理服务器,并且该代理服务器不变。 **代理列表** -此方法允许您为某个协议指定一个或多个代理服务器。如果定义多个代理服务器,ClickHouse 将以轮询方式使用不同的代理,平衡服务器之间的负载。如果某个协议有多个代理服务器且代理服务器列表没有变化,这是最简单的方法。 +此方法允许您为协议指定一个或多个代理服务器。如果定义了多个代理服务器,ClickHouse 将以轮询方式使用不同的代理,负载在服务器之间均衡分配。如果有多个代理服务器适用于协议,并且代理服务器列表没有变化,这是最简单的方法。 **配置模板** @@ -2209,29 +2212,29 @@ ClickHouse 服务器存储由 SQL 命令创建的用户和角色配置的文件 ``` -选择下面标签中的父字段以查看它们的子字段: +选择下方选项卡中的父字段以查看其子字段: -| 字段 | 描述 | -|-----------|---------------------------------| -| `` | 一个或多个 HTTP 代理的列表 | -| `` | 一个或多个 HTTPS 代理的列表 | +| 字段 | 描述 | +|-----------|-------------------------------------| +| `` | 一个或多个 HTTP 代理的列表 | +| `` | 一个或多个 HTTPS 代理的列表 | - + -| 字段 | 描述 | -|---------|----------------------| -| `` | 代理的 URI | +| 字段 | 描述 | +|--------|-------------------------| +| `` | 代理的 URI | **远程代理解析器** -代理服务器可能会动态更改。在这种情况下,您可以定义解析器的端点。ClickHouse 向该端点发送空的 GET 请求,远程解析器应返回代理主机。ClickHouse 将使用它根据以下模板形成代理 URI:`\{proxy_scheme\}://\{proxy_host\}:{proxy_port}` +可能会动态更改代理服务器。在这种情况下,可以定义解析器的端点。ClickHouse 向该端点发送一个空的 GET 请求,远程解析器应返回代理主机。ClickHouse 将使用它形成代理 URI,使用以下模板: `\{proxy_scheme\}://\{proxy_host\}:{proxy_port}` **配置模板** @@ -2258,65 +2261,64 @@ ClickHouse 服务器存储由 SQL 命令创建的用户和角色配置的文件 ``` -选择下面标签中的父字段以查看它们的子字段: +选择下方选项卡中的父字段以查看其子字段: -| 字段 | 描述 | -|-----------|---------------------------------| -| `` | 一个或多个解析器的列表* | -| `` | 一个或多个解析器的列表* | +| 字段 | 描述 | +|-----------|----------------------------------| +| `` | 一个或多个解析器的列表* | +| `` | 一个或多个解析器的列表* | - + -| 字段 | 描述 | -|-------------|----------------------------------------| -| `` | 解析器的端点及其他详细信息 | +| 字段 | 描述 | +|---------------|------------------------------------------------| +| `` | 解析器的端点和其他详细信息 | :::note -您可以有多个 `` 元素,但仅使用给定协议第一个 ``。该协议的任何其他 `` 元素将被忽略。这意味着负载均衡(如有需要)应由远程解析器实现。 +您可以有多个 `` 元素,但仅使用给定协议的第一个 ``。该协议的任何其他 `` 元素将被忽略。这意味着负载均衡(如有需要)应由远程解析器实现。 ::: -| 字段 | 描述 | -|---------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `` | 代理解析器的 URI | -| `` | 最终代理 URI 的协议。这可以是 `http` 或 `https`。 | -| `` | 代理解析器的端口号 | -| `` | ClickHouse 应缓存解析器的值的时间(以秒为单位)。将此值设置为 `0` 将导致 ClickHouse 每个 HTTP 或 HTTPS 请求联系解析器。 | +| 字段 | 描述 | +|---------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `` | 代理解析器的 URI | +| `` | 最终代理 URI 的协议。可以是 `http` 或 `https`。 | +| `` | 代理解析器的端口号 | +| `` | ClickHouse 应缓存来自解析器的值的秒数。将此值设置为 `0` 将导致 ClickHouse 在每个 HTTP 或 HTTPS 请求时联系解析器。 | **优先级** -代理设置的优先级由以下顺序决定: - -| 顺序 | 设置 | -|-------|------------------------| -| 1. | 远程代理解析器 | -| 2. | 代理列表 | -| 3. | 环境变量 | +代理设置按以下顺序确定: -ClickHouse 将检查请求协议的最高优先级解析器类型。如果未定义,将检查下一个优先级解析器类型,直到达到环境解析器。这也允许混合使用解析器类型。 +| 顺序 | 设置 | +|------|------------------------| +| 1. | 远程代理解析器 | +| 2. | 代理列表 | +| 3. | 环境变量 | +ClickHouse 将检查请求协议的最高优先级解析器类型。如果未定义,它将检查下一个最高优先级解析器类型,直到达到环境解析器。这也允许混合使用解析器类型。 ## disable_tunneling_for_https_requests_over_http_proxy {#disable_tunneling_for_https_requests_over_http_proxy} -默认情况下,隧道(即 `HTTP CONNECT`)用于通过 `HTTP` 代理进行 `HTTPS` 请求。此设置可用于禁用该功能。 +默认情况下,隧道(即 `HTTP CONNECT`)用于通过 `HTTP` 代理发起 `HTTPS` 请求。此设置可用于禁用它。 **no_proxy** -默认情况下,所有请求将通过代理。为了对特定主机禁用代理,必须设置 `no_proxy` 变量。 -它可以在 `` 子句中设置,适用于列表和远程解析器,也可以作为环境变量设置,适用于环境解析器。 -支持 IP 地址、域、子域以及 `'*'` 通配符以进行全面绕过。前导点与 curl 一样被去掉。 +默认情况下,所有请求将通过代理。为了禁用特定主机的代理,必须设置 `no_proxy` 变量。 +它可以在代理子句中设置用于列表和远程解析器,以及作为环境解析器的环境变量。它支持 IP 地址、域、子域和 `'*'` 通配符进行完全绕过。前导点就像 curl 一样被剥离。 **示例** -以下配置绕过对 `clickhouse.cloud` 及其所有子域(例如 `auth.clickhouse.cloud`)的代理请求。对于 GitLab 也是如此,即使它有前导点。 `gitlab.com` 和 `about.gitlab.com` 都会绕过代理。 +以下配置绕过对 `clickhouse.cloud` 及其所有子域(例如 `auth.clickhouse.cloud`)的代理请求。 +对于 GitLab 也是如此,即使它有前导点。 `gitlab.com` 和 `about.gitlab.com` 都将绕过代理。 ```xml @@ -2332,7 +2334,7 @@ ClickHouse 将检查请求协议的最高优先级解析器类型。如果未定 ``` ## workload_path {#workload_path} -用于存储所有 `CREATE WORKLOAD` 和 `CREATE RESOURCE` 查询的目录。默认情况下在服务器工作目录下使用 `/workload/` 文件夹。 +用于存储所有 `CREATE WORKLOAD` 和 `CREATE RESOURCE` 查询的目录。默认情况下使用服务器工作目录下的 `/workload/` 文件夹。 **示例** @@ -2341,11 +2343,11 @@ ClickHouse 将检查请求协议的最高优先级解析器类型。如果未定 ``` **另请参见** -- [工作负载层次](/operations/workload-scheduling.md#workloads) +- [工作负载层次结构](/operations/workload-scheduling.md#workloads) - [workload_zookeeper_path](#workload_zookeeper_path) ## workload_zookeeper_path {#workload_zookeeper_path} -用于存储所有 `CREATE WORKLOAD` 和 `CREATE RESOURCE` 查询的 ZooKeeper 节点的路径。为了保持一致,所有 SQL 定义作为此单个 znode 的值进行存储。默认情况下不使用 ZooKeeper,定义存储在 [磁盘](#workload_path) 上。 +用于存储所有 `CREATE WORKLOAD` 和 `CREATE RESOURCE` 查询的 ZooKeeper 节点路径。为确保一致性,所有 SQL 定义都存储为此单个 znode 的值。默认情况下不使用 ZooKeeper,定义存储在 [disk](#workload_path) 上。 **示例** @@ -2354,5 +2356,5 @@ ClickHouse 将检查请求协议的最高优先级解析器类型。如果未定 ``` **另请参见** -- [工作负载层次](/operations/workload-scheduling.md#workloads) +- [工作负载层次结构](/operations/workload-scheduling.md#workloads) - [workload_path](#workload_path) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/server-configuration-parameters/_server_settings_outside_source.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/server-configuration-parameters/_server_settings_outside_source.md.hash index aa4efbbc485..506d7e98ff9 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/server-configuration-parameters/_server_settings_outside_source.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/server-configuration-parameters/_server_settings_outside_source.md.hash @@ -1 +1 @@ -55c88676dfc88a92 +6979434814ae3c2f diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/server-configuration-parameters/_snippets/_system-log-parameters.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/server-configuration-parameters/_snippets/_system-log-parameters.md index 8bc2eee9afd..34f7071a8c9 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/server-configuration-parameters/_snippets/_system-log-parameters.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/server-configuration-parameters/_snippets/_system-log-parameters.md @@ -1,22 +1,17 @@ ---- -null -... ---- - 以下设置可以通过子标签进行配置: -| 设置 | 描述 | 默认值 | 注意 | -|-------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------|-----------------------------------------------------------------------------------------------------------------------| -| `database` | 数据库的名称。 | | | -| `table` | 系统表的名称。 | | | -| `engine` | [MergeTree 引擎定义](../../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-creating-a-table) 用于系统表。 | | 如果定义了 `partition_by` 或 `order_by`,则不能使用。如果未指定,默认选择 `MergeTree`。 | -| `partition_by` | [自定义分区键](../../../engines/table-engines/mergetree-family/custom-partitioning-key.md) 用于系统表。 | | 如果为系统表指定了 `engine`,则 `partition_by` 参数应直接在 'engine' 中指定。 | -| `ttl` | 指定表的 [TTL](/engines/table-engines/mergetree-family/mergetree#table_engine-mergetree-ttl)。 | | 如果为系统表指定了 `engine`,则 `ttl` 参数应直接在 'engine' 中指定。 | -| `order_by` | [自定义排序键](../../../engines/table-engines/mergetree-family/mergetree.md#order_by) 用于系统表。不可在定义了 `engine` 的情况下使用。 | | 如果为系统表指定了 `engine`,则 `order_by` 参数应直接在 'engine' 中指定。 | -| `storage_policy` | 用于表的存储策略名称(可选)。 | | 如果为系统表指定了 `engine`,则 `storage_policy` 参数应直接在 'engine' 中指定。 | -| `settings` | 控制 MergeTree 行为的 [附加参数](../../../engines/table-engines/mergetree-family/mergetree.md/#settings)(可选)。 | | 如果为系统表指定了 `engine`,则 `settings` 参数应直接在 'engine' 中指定。 | -| `flush_interval_milliseconds` | 从内存缓冲区刷新数据到表的时间间隔。 | `7500` | | -| `max_size_rows` | 日志的最大行数。当未刷新日志的数量达到最大值时,日志会被转储到磁盘。 | `1048576` | | -| `reserved_size_rows` | 为日志预分配的内存大小(行数)。 | `8192` | | -| `buffer_size_rows_flush_threshold` | 行数的阈值。如果达到该阈值,将在后台启动日志刷新到磁盘的操作。 | `max_size_rows / 2` | | -| `flush_on_crash` | 设置在崩溃情况下日志是否应转储到磁盘。 | `false` | | +| 设置 | 描述 | 默认值 | 备注 | +|------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------|--------------------------------------------------------------------------------------------------------------| +| `database` | 数据库的名称。 | | | +| `table` | 系统表的名称。 | | | +| `engine` | [MergeTree 引擎定义](../../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-creating-a-table)用于系统表。 | | 如果定义了 `partition_by` 或 `order_by`,则无法使用。如果未指定,则默认选择 `MergeTree` | +| `partition_by` | 系统表的[自定义分区键](../../../engines/table-engines/mergetree-family/custom-partitioning-key.md)。 | | 如果为系统表指定了 `engine`,则 `partition_by` 参数应直接在 'engine' 中指定。 | +| `ttl` | 指定表的[生存时间 (TTL)](/engines/table-engines/mergetree-family/mergetree#table_engine-mergetree-ttl)。 | | 如果为系统表指定了 `engine`,则 `ttl` 参数应直接在 'engine' 中指定。 | +| `order_by` | 系统表的[自定义排序键](../../../engines/table-engines/mergetree-family/mergetree.md#order_by)。无法在定义了 `engine` 的情况下使用。 | | 如果为系统表指定了 `engine`,则 `order_by` 参数应直接在 'engine' 中指定。 | +| `storage_policy` | 要用于表的存储策略名称(可选)。 | | 如果为系统表指定了 `engine`,则 `storage_policy` 参数应直接在 'engine' 中指定。 | +| `settings` | 控制 MergeTree 行为的[附加参数](../../../engines/table-engines/mergetree-family/mergetree.md/#settings)(可选)。 | | 如果为系统表指定了 `engine`,则 `settings` 参数应直接在 'engine' 中指定。 | +| `flush_interval_milliseconds` | 从内存缓冲区刷新数据到表的间隔。 | `7500` | | +| `max_size_rows` | 日志的最大行数。当未刷新日志的数量达到最大值时,日志将被转储到磁盘。 | `1048576` | | +| `reserved_size_rows` | 日志的预分配内存大小(行数)。 | `8192` | | +| `buffer_size_rows_flush_threshold` | 行数的阈值。如果达到阈值,将在后台启动将日志刷新到磁盘的操作。 | `max_size_rows / 2` | | +| `flush_on_crash` | 设置在崩溃时是否应将日志转储到磁盘。 | `false` | | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/server-configuration-parameters/settings.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/server-configuration-parameters/settings.md index 7e8f1f48986..9b9f0b59d60 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/server-configuration-parameters/settings.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/server-configuration-parameters/settings.md @@ -1,11 +1,12 @@ --- -'description': '本节包含服务器设置的描述,即无法在会话或查询级别更改的设置。' +'description': '本节包含服务器设置的描述,即不能在会话或查询级别更改的设置。' 'keywords': - 'global server settings' 'sidebar_label': '服务器设置' 'sidebar_position': 57 'slug': '/operations/server-configuration-parameters/settings' 'title': '服务器设置' +'doc_type': 'reference' --- import Tabs from '@theme/Tabs'; @@ -16,24 +17,29 @@ import SettingsInfoBlock from '@theme/SettingsInfoBlock/SettingsInfoBlock'; # 服务器设置 -本部分包含服务器设置的描述。这些设置无法在会话或查询级别更改。 +本节包含服务器设置的描述。这些是不能在会话或查询级别更改的设置。 -有关 ClickHouse 中配置文件的更多信息,请参见 [""配置文件""](/operations/configuration-files)。 +有关 ClickHouse 中配置文件的更多信息,请参见["配置文件"](/operations/configuration-files)。 + +其他设置描述在""[设置](/operations/settings/overview)""节中。在学习设置之前,建议您先阅读[配置文件](/operations/configuration-files)部分,并注意替换的使用(`incl` 和 `optional` 属性)。 + +## abort_on_logical_error {#abort_on_logical_error} + +在 LOGICAL_ERROR 异常时使服务器崩溃。仅适用于专家。 -其他设置在 ""[设置](/operations/settings/overview)"" 部分进行了描述。在研究设置之前,我们建议先阅读 [配置文件](/operations/configuration-files) 部分,并注意替换的使用(`incl` 和 `optional` 属性)。 ## access_control_improvements {#access_control_improvements} -用于访问控制系统的可选改进的设置。 +对访问控制系统的可选改进的设置。 -| 设置 | 描述 | 默认 | -|------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------| -| `users_without_row_policies_can_read_rows` | 设置没有宽松行级访问控制策略的用户是否仍可以使用 `SELECT` 查询读取行。例如,如果有两个用户 A 和 B,而行级政策仅为 A 定义,那么如果此设置为真,用户 B 将看到所有行。如果此设置为假,则用户 B 将看不到任何行。 | `true` | -| `on_cluster_queries_require_cluster_grant` | 设置 `ON CLUSTER` 查询是否需要 `CLUSTER` 授权。 | `true` | -| `select_from_system_db_requires_grant` | 设置 `SELECT * FROM system.` 是否需要任何授权,可以由任何用户执行。如果设置为 true,则该查询需要 `GRANT SELECT ON system.
`,就像对待非系统表一样。例外情况:一些系统表(`tables`、`columns`、`databases` 以及一些常量表,如 `one`、`contributors`)仍然对所有人可访问;如果授予了 `SHOW` 权限(例如 `SHOW USERS`),则相应的系统表(即 `system.users`)将可访问。 | `true` | -| `select_from_information_schema_requires_grant` | 设置 `SELECT * FROM information_schema.
` 是否需要任何授权,可以由任何用户执行。如果设置为 true,则该查询需要 `GRANT SELECT ON information_schema.
`,就像对待普通表一样。 | `true` | -| `settings_constraints_replace_previous` | 设置某些设置的设置配置文件中的约束是否会取消对该设置的先前约束(在其他配置文件中定义)的操作,包括未被新约束设置的字段。它还启用 `changeable_in_readonly` 约束类型。 | `true` | -| `table_engines_require_grant` | 设置创建具有特定表引擎的表是否需要授权。 | `false` | -| `role_cache_expiration_time_seconds` | 设置角色在角色缓存中存储的最后访问后经过的秒数。 | `600` | +| 设置 | 描述 | 默认值 | +|-----------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------| +| `users_without_row_policies_can_read_rows` | 设置没有允许行策略的用户是否仍然可以使用 `SELECT` 查询读取行。例如,如果有两个用户 A 和 B,并且仅为 A 定义了一行策略,则如果该设置为 true,用户 B 将看到所有行。如果该设置为 false,用户 B 将看不到任何行。 | `true` | +| `on_cluster_queries_require_cluster_grant` | 设置 `ON CLUSTER` 查询是否需要 `CLUSTER` 授权。 | `true` | +| `select_from_system_db_requires_grant` | 设置 `SELECT * FROM system.
` 是否需要任何授权,并且可以由任何用户执行。如果设置为 true,则该查询需要 `GRANT SELECT ON system.
`,就像对非系统表一样。例外情况:一些系统表(如 `tables`、`columns`、`databases` 和一些常量表如 `one`、`contributors`)仍然可以被所有人访问;如果授予了 `SHOW` 权限(例如 `SHOW USERS`),那么相应的系统表(即 `system.users`)也将可访问。 | `true` | +| `select_from_information_schema_requires_grant` | 设置 `SELECT * FROM information_schema.
` 是否需要任何授权,并且可以由任何用户执行。如果设置为 true,则该查询需要 `GRANT SELECT ON information_schema.
`,就像普通表一样。 | `true` | +| `settings_constraints_replace_previous` | 设置某设置的设置文件中的约束是否取消对该设置的先前约束(在其他文件中定义)的行为,包括未被新约束设置的字段。它还启用了 `changeable_in_readonly` 约束类型。 | `true` | +| `table_engines_require_grant` | 设置是否使用特定表引擎创建表需要授权。 | `false` | +| `role_cache_expiration_time_seconds` | 设置角色存储在角色缓存中的最大访问时间(秒)。 | `600` | 示例: @@ -48,40 +54,46 @@ import SettingsInfoBlock from '@theme/SettingsInfoBlock/SettingsInfoBlock'; 600 ``` + ## access_control_path {#access_control_path} -ClickHouse 服务器存储由 SQL 命令创建的用户和角色配置的文件夹路径。 +ClickHouse 服务器存储通过 SQL 命令创建的用户和角色配置的文件夹路径。 -**另请参见** +**另见** + +- [访问控制和账户管理](/operations/access-rights#access-control-usage) -- [访问控制和帐户管理](/operations/access-rights#access-control-usage) ## aggregate_function_group_array_action_when_limit_is_reached {#aggregate_function_group_array_action_when_limit_is_reached} -当 groupArray 中达到最大数组元素大小时执行的操作:`throw` 异常,或 `discard` 多余的值 +在 groupArray 中超出最大数组元素大小时执行的操作:`throw` 异常或 `discard` 额外值。 + ## aggregate_function_group_array_max_element_size {#aggregate_function_group_array_max_element_size} -groupArray 函数的最大数组元素大小(以字节为单位)。此限制在序列化时检查,帮助避免大型状态大小。 +groupArray 函数的最大数组元素大小(以字节为单位)。此限制在序列化时检查,以帮助避免大型状态大小。 + ## allow_feature_tier {#allow_feature_tier} -控制用户是否可以更改与不同功能级别相关的设置。 +控制用户是否可以更改与不同功能级别有关的设置。 -- `0` - 允许对任何设置进行更改(实验性、测试版、生产版)。 -- `1` - 仅允许对测试版和生产功能设置进行更改。对实验性设置的更改会被拒绝。 -- `2` - 仅允许对生产设置进行更改。对实验性或测试版设置的更改会被拒绝。 +- `0` - 允许对任何设置进行更改(实验、测试、生产)。 +- `1` - 仅允许对测试和生产功能设置进行更改。对实验性设置的更改被拒绝。 +- `2` - 仅允许对生产设置进行更改。对实验或测试设置的更改被拒绝。 这相当于对所有 `EXPERIMENTAL` / `BETA` 功能设置只读约束。 :::note -值为 `0` 表示可以更改所有设置。 +值为 `0` 意味着可以更改所有设置。 ::: + ## allow_implicit_no_password {#allow_implicit_no_password} -禁止创建没有密码的用户,除非明确指定 'IDENTIFIED WITH no_password'。 +禁止创建没有密码的用户,除非显式指定 'IDENTIFIED WITH no_password'。 ```xml 1 ``` + ## allow_no_password {#allow_no_password} 设置是否允许不安全的无密码类型。 @@ -89,6 +101,7 @@ ClickHouse 服务器存储由 SQL 命令创建的用户和角色配置的文件 ```xml 1 ``` + ## allow_plaintext_password {#allow_plaintext_password} 设置是否允许明文密码类型(不安全)。 @@ -96,47 +109,58 @@ ClickHouse 服务器存储由 SQL 命令创建的用户和角色配置的文件 ```xml 1 ``` + ## allow_use_jemalloc_memory {#allow_use_jemalloc_memory} 允许使用 jemalloc 内存。 + +## allowed_disks_for_table_engines {#allowed_disks_for_table_engines} + +允许与 Iceberg 配合使用的磁盘列表。 + ## async_insert_queue_flush_on_shutdown {#async_insert_queue_flush_on_shutdown} -如果为真,则在优雅关闭时刷新异步插入队列 +如果为 true,则在优雅关闭时刷新异步插入队列。 + ## async_insert_threads {#async_insert_threads} -解析和插入数据的最大线程数。零表示禁用异步模式 +实际解析和插入数据的最大线程数。零表示禁用异步模式。 + ## async_load_databases {#async_load_databases} 异步加载数据库和表。 -- 如果 `true`,所有使用 `Ordinary`、`Atomic` 和 `Replicated` 引擎的非系统数据库将在 ClickHouse 服务器启动后异步加载。请参见 `system.asynchronous_loader` 表、`tables_loader_background_pool_size` 和 `tables_loader_foreground_pool_size` 服务器设置。任何尝试访问尚未加载的表的查询将会等待该表启动。如果加载作业失败,查询将抛出错误(而不是在 `async_load_databases = false` 的情况下关闭整个服务器)。至少一个查询等待的表将以更高的优先级加载。DDL 查询将在该数据库启动之前等待该数据库。考虑设置 `max_waiting_queries` 来限制等待查询的总数。 -- 如果 `false`,则在服务器启动时加载所有数据库。 +- 如果为 `true`,在 ClickHouse 服务器启动后,所有具有 `Ordinary`、`Atomic` 和 `Replicated` 引擎的非系统数据库将异步加载。请参阅 `system.asynchronous_loader` 表、`tables_loader_background_pool_size` 和 `tables_loader_foreground_pool_size` 服务器设置。任何尝试访问尚未加载的表的查询将会等待确切的表启动。如果加载作业失败,查询将重新抛出错误(而不是在 `async_load_databases = false` 的情况下关闭整个服务器)。至少有一个查询在等待的表将以更高的优先级加载。对数据库的 DDL 查询将等待确切的数据库启动。还可以考虑设置 `max_waiting_queries` 的限制以限制总等待查询的数量。 +- 如果为 `false`,则在服务器启动时加载所有数据库。 **示例** ```xml true ``` + ## async_load_system_database {#async_load_system_database} -异步加载系统表。如果 `system` 数据库中有大量日志表和分区片段,这将很有用。独立于 `async_load_databases` 设置。 +异步加载系统表。如果 `system` 数据库中有大量日志表和分片,这将很有帮助。独立于 `async_load_databases` 设置。 -- 如果设置为 `true`,使用 `Ordinary`、`Atomic` 和 `Replicated` 引擎的所有系统数据库将在 ClickHouse 服务器启动后异步加载。请参见 `system.asynchronous_loader` 表、`tables_loader_background_pool_size` 和 `tables_loader_foreground_pool_size` 服务器设置。任何试图访问一个尚未加载的系统表的查询将会等待该表启动。至少一个查询正在等待的表将以更高的优先级加载。还考虑设置 `max_waiting_queries` 设置来限制总的等待查询数。 -- 如果设置为 `false`,则系统数据库会在服务器启动之前加载。 +- 如果设置为 `true`,在 ClickHouse 服务器启动后,所有具有 `Ordinary`、`Atomic` 和 `Replicated` 引擎的系统数据库将异步加载。请参见 `system.asynchronous_loader` 表、`tables_loader_background_pool_size` 和 `tables_loader_foreground_pool_size` 服务器设置。任何尝试访问尚未加载的系统表的查询将会等待确切的表启动。至少一个查询在等待的表将以更高的优先级加载。还可以考虑设置 `max_waiting_queries` 设置以限制总等待查询的数量。 +- 如果设置为 `false`,在服务器启动之前加载系统数据库。 **示例** ```xml true ``` + ## asynchronous_heavy_metrics_update_period_s {#asynchronous_heavy_metrics_update_period_s} 更新重异步指标的周期(以秒为单位)。 + ## asynchronous_insert_log {#asynchronous_insert_log} -[asynchronous_insert_log](/operations/system-tables/asynchronous_insert_log) 系统表的设置,用于记录异步插入。 +[asynchronous_insert_log](/operations/system-tables/asynchronous_insert_log) 系统表的设置,用于日志记录异步插入。 @@ -157,15 +181,16 @@ ClickHouse 服务器存储由 SQL 命令创建的用户和角色配置的文件 ``` + ## asynchronous_metric_log {#asynchronous_metric_log} -在 ClickHouse Cloud 部署中默认启用。 +默认情况下在 ClickHouse Cloud 部署中启用。 -如果在您的环境中此设置未默认启用,则可以根据 ClickHouse 的安装方式遵循以下说明来启用或禁用它。 +如果您所在环境中未默认启用此设置,具体取决于 ClickHouse 的安装方式,您可以按以下说明启用或禁用它。 **启用** -要手动打开异步指标日志历史记录收集 [`system.asynchronous_metric_log`](../../operations/system-tables/asynchronous_metric_log.md),请创建 `/etc/clickhouse-server/config.d/asynchronous_metric_log.xml`,内容如下: +要手动打开异步指标日志历史记录收集 [`system.asynchronous_metric_log`](../../operations/system-tables/asynchronous_metric_log.md),创建 `/etc/clickhouse-server/config.d/asynchronous_metric_log.xml`,内容如下: ```xml @@ -184,99 +209,117 @@ ClickHouse 服务器存储由 SQL 命令创建的用户和角色配置的文件 **禁用** -要禁用 `asynchronous_metric_log` 设置,您应创建以下文件 `/etc/clickhouse-server/config.d/disable_asynchronous_metric_log.xml`,内容如下: +要禁用 `asynchronous_metric_log` 设置,您应该创建以下文件 `/etc/clickhouse-server/config.d/disable_asynchronous_metric_log.xml`,内容如下: ```xml ``` + ## asynchronous_metrics_enable_heavy_metrics {#asynchronous_metrics_enable_heavy_metrics} 启用重异步指标的计算。 + ## asynchronous_metrics_update_period_s {#asynchronous_metrics_update_period_s} 更新异步指标的周期(以秒为单位)。 + ## auth_use_forwarded_address {#auth_use_forwarded_address} -对通过代理连接的客户端使用原始地址进行身份验证。 +对通过代理连接的客户端使用源地址进行身份验证。 :::note -使用此设置时应格外谨慎,因为转发地址容易被伪造 - 接受此类身份验证的服务器不应直接访问,而应仅通过受信任的代理访问。 +该设置应小心使用,因为转发地址很容易被伪造 - 直接访问接受此类身份验证的服务器是不应当的,而应仅通过可信的代理访问。 ::: + ## background_buffer_flush_schedule_pool_size {#background_buffer_flush_schedule_pool_size} -用于后台执行 [Buffer-engine tables](/engines/table-engines/special/buffer) 刷新操作的最大线程数。 +将用于在后台执行 [Buffer-engine tables](/engines/table-engines/special/buffer) 刷新操作的最大线程数。 + ## background_common_pool_size {#background_common_pool_size} -用于后台执行各种操作(主要是垃圾收集)的 [*MergeTree-engine](/engines/table-engines/mergetree-family) 表的最大线程数。 +将用于在后台对各种操作(主要是垃圾收集)执行的最大线程数,用于 [*MergeTree-engine](/engines/table-engines/mergetree-family) 表。 + ## background_distributed_schedule_pool_size {#background_distributed_schedule_pool_size} -用于执行分布式发送的最大线程数。 +将用于执行分布式发送的最大线程数。 + ## background_fetches_pool_size {#background_fetches_pool_size} -从另一个副本中获取数据片段的最大线程数,用于后台中的 [*MergeTree-engine](/engines/table-engines/mergetree-family) 表。 +将用于从另一副本获取数据部分的最大线程数,用于 [*MergeTree-engine](/engines/table-engines/mergetree-family) 表。 + ## background_merges_mutations_concurrency_ratio {#background_merges_mutations_concurrency_ratio} -设置线程数与可以同时执行的后台合并和变更的数量之间的比例。 +设置线程数与可以并发执行的后台合并和变更数量之间的比率。 -例如,如果比率等于 2 并且 [`background_pool_size`](/operations/server-configuration-parameters/settings#background_pool_size) 设置为 16,则 ClickHouse 可以同时执行 32 个后台合并。这是可能的,因为后台操作可以被暂停和推迟。这是为了给小合并提供更高的执行优先级。 +例如,如果此比率等于 2,并且 [`background_pool_size`](/operations/server-configuration-parameters/settings#background_pool_size) 设置为 16,则 ClickHouse 可以同时执行 32 次后台合并。这是可能的,因为后台操作可以被挂起和推迟。这是为了给小型合并更高的执行优先级。 :::note -您只能在运行时增加此比率。要降低比率,您必须重新启动服务器。 +您只能在运行时增加此比率。要降低它,必须重新启动服务器。 -与 [`background_pool_size`](/operations/server-configuration-parameters/settings#background_pool_size) 设置相同,[`background_merges_mutations_concurrency_ratio`](/operations/server-configuration-parameters/settings#background_merges_mutations_concurrency_ratio) 可以从 `default` 配置文件应用以保持向后兼容性。 +与 [`background_pool_size`](/operations/server-configuration-parameters/settings#background_pool_size) 设置相同,[`background_merges_mutations_concurrency_ratio`](/operations/server-configuration-parameters/settings#background_merges_mutations_concurrency_ratio) 可以从 `default` 配置文件中应用,以保持向后兼容。 ::: + ## background_merges_mutations_scheduling_policy {#background_merges_mutations_scheduling_policy} -规定如何对后台合并和变更进行调度的策略。可能的值为:`round_robin` 和 `shortest_task_first`。 +对后台合并和变更的调度执行策略。可能的值为:`round_robin` 和 `shortest_task_first`。 -用于选择由后台线程池执行的下一个合并或变更的算法。策略可以在运行时更改,而无需重新启动服务器。 -可以从 `default` 配置文件应用,以保持向后兼容性。 +算法用于选择由后台线程池执行的下一个合并或变更。策略可以在运行时更改,而无需重新启动服务器。可以从 `default` 配置文件中应用,以保持向后兼容。 可能的值: -- `round_robin` — 每个并发合并和变更按轮询顺序执行,以确保无饥饿操作。由于较小的合并块较少,其完成速度会比较大的合并快。 -- `shortest_task_first` — 始终优先执行较小的合并或变更。合并和变更根据其结果大小分配优先级。较小的合并严格优先于较大的合并。该策略确保尽可能快速地合并小片段,但在大量 `INSERT` 操作过载的分区中,可能会导致较大合并的无限期饥饿。 +- `round_robin` - 每个并发合并和变更以轮换顺序执行,以确保不会饿死操作。较小的合并通常会比较大的合并完成得更快,因为它们需要合并的块较少。 +- `shortest_task_first` - 始终执行较小的合并或变更。合并和变更根据其结果大小分配优先级。较小的合并优先于较大的合并。此策略可确保小部分的快速合并,但可能导致严重的分区中较大合并的长期饥饿。 + ## background_message_broker_schedule_pool_size {#background_message_broker_schedule_pool_size} -用于执行消息流的后台操作的最大线程数。 +将用于为消息流执行后台操作的最大线程数。 + ## background_move_pool_size {#background_move_pool_size} -用于后台中将数据片段移动到另一个磁盘或卷的最大线程数,用于 *MergeTree-engine 表。 +将用于将数据部分移至另一个磁盘或卷的最大线程数,用于 *MergeTree-engine 表,在后台进行。 + ## background_pool_size {#background_pool_size} -设置执行 MergeTree 引擎表的后台合并和变更的线程数。 +设置用于执行 MergeTree 引擎表的后台合并和变更的线程数。 :::note -- 此设置也可以在服务器启动时从 `default` 配置文件配置,以保持与 ClickHouse 服务器启动时的向后兼容性。 +- 此设置也可以在服务器启动时从 `default` 配置文件计算,以确保向后兼容。 - 您只能在运行时增加线程数。 -- 要降低线程数,您必须重新启动服务器。 +- 要降低线程数,必须重新启动服务器。 - 通过调整此设置,您可以管理 CPU 和磁盘负载。 ::: :::danger -较小的池大小会利用较少的 CPU 和磁盘资源,但后台进程的推进速度较慢,这可能最终会影响查询性能。 +较小的池大小会减少 CPU 和磁盘资源的使用,但后台进程的推进速度较慢,这可能最终影响查询性能。 ::: -在更改之前,请查看相关的 MergeTree 设置,例如: -- [`number_of_free_entries_in_pool_to_lower_max_size_of_merge`](../../operations/settings/merge-tree-settings.md#number_of_free_entries_in_pool_to_lower_max_size_of_merge). -- [`number_of_free_entries_in_pool_to_execute_mutation`](../../operations/settings/merge-tree-settings.md#number_of_free_entries_in_pool_to_execute_mutation). +在更改之前,请还查看与合并树相关的其他设置,例如: +- [`number_of_free_entries_in_pool_to_lower_max_size_of_merge`](../../operations/settings/merge-tree-settings.md#number_of_free_entries_in_pool_to_lower_max_size_of_merge)。 +- [`number_of_free_entries_in_pool_to_execute_mutation`](../../operations/settings/merge-tree-settings.md#number_of_free_entries_in_pool_to_execute_mutation)。 +- [`number_of_free_entries_in_pool_to_execute_optimize_entire_partition`](/operations/settings/merge-tree-settings#number_of_free_entries_in_pool_to_execute_optimize_entire_partition) **示例** ```xml 16 ``` + +## background_schedule_pool_max_parallel_tasks_per_type_ratio {#background_schedule_pool_max_parallel_tasks_per_type_ratio} + +池中可以同时执行相同类型的任务的最大线程比率。 + ## background_schedule_pool_size {#background_schedule_pool_size} -用于持续执行复制表、Kafka 流和 DNS 缓存更新的一些轻量级定期操作的最大线程数。 +将用于不断执行一些轻量级定期操作的最大线程数,这些操作适用于复制表、Kafka 流和 DNS 缓存更新。 + ## backup_log {#backup_log} -设置用于 [backup_log](../../operations/system-tables/backup_log.md) 系统表以记录 `BACKUP` 和 `RESTORE` 操作。 +用于[backup_log](../../operations/system-tables/backup_log.md) 系统表的设置,用于记录 `BACKUP` 和 `RESTORE` 操作。 @@ -297,21 +340,23 @@ ClickHouse 服务器存储由 SQL 命令创建的用户和角色配置的文件 ``` + ## backup_threads {#backup_threads} 执行 `BACKUP` 请求的最大线程数。 + ## backups {#backups} 执行 `BACKUP TO File()` 时使用的备份设置。 以下设置可以通过子标签进行配置: -| 设置 | 描述 | 默认 | -|---------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------| -| `allowed_path` | 使用 `File()` 时备份的路径。必须设置此设置以使用 `File`。该路径可以相对于实例目录,也可以是绝对路径。 | `true` | -| `remove_backup_files_after_failure` | 如果 `BACKUP` 命令失败,ClickHouse 将尝试在失败之前删除已复制到备份的文件;否则将保留已复制的文件。 | `true` | +| 设置 | 描述 | 默认值 | +|-------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------| +| `allowed_path` | 使用 `File()` 备份的路径。此设置必须设置才能使用 `File`。路径可以相对于实例目录,或者可以是绝对路径。 | `true` | +| `remove_backup_files_after_failure` | 如果 `BACKUP` 命令失败,ClickHouse 将尝试删除已复制到备份中的文件,或者在失败之前,它将保持已复制的文件不变。 | `true` | -此设置默认配置为: +默认情况下,此设置配置为: ```xml @@ -319,22 +364,29 @@ ClickHouse 服务器存储由 SQL 命令创建的用户和角色配置的文件 true ``` + ## backups_io_thread_pool_queue_size {#backups_io_thread_pool_queue_size} -可以在备份 IO 线程池上调度的最大作业数。建议由于当前的 S3 备份逻辑保持此队列无限制。 +可以在备份 IO 线程池中调度的最大作业数。由于当前 S3 备份逻辑,建议将此队列保持为无限制。 :::note -值为 `0`(默认)表示无限制。 +值 `0`(默认)意味着无限制。 ::: + ## bcrypt_workfactor {#bcrypt_workfactor} -使用 [Bcrypt algorithm](https://wildlyinaccurate.com/bcrypt-choosing-a-work-factor/) 的 bcrypt_password 身份验证类型的工作因子。 +使用 [Bcrypt 算法](https://wildlyinaccurate.com/bcrypt-choosing-a-work-factor/) 的 `bcrypt_password` 身份验证类型的工作因子。工作因子定义计算哈希和验证密码所需的计算量和时间。 ```xml 12 ``` -## blog_storage_log {#blog_storage_log} + +:::warning +对于高频身份验证的应用程序,请考虑使用其他身份验证方法,因为 bcrypt 在更高的工作因子下的计算开销。 +::: + +## blob_storage_log {#blob_storage_log} [`blob_storage_log`](../system-tables/blob_storage_log.md) 系统表的设置。 @@ -351,61 +403,48 @@ ClickHouse 服务器存储由 SQL 命令创建的用户和角色配置的文件 event_date + INTERVAL 30 DAY ``` + ## builtin_dictionaries_reload_interval {#builtin_dictionaries_reload_interval} -重新加载内置字典前的时间间隔(以秒为单位)。 +重载内置字典的时间间隔(以秒为单位)。 -ClickHouse 每 x 秒重新加载内置字典。这使得在不重新启动服务器的情况下“动态”编辑字典成为可能。 +ClickHouse 每 x 秒重新加载内置字典。这使得在不重新启动服务器的情况下"动态"编辑字典成为可能。 **示例** ```xml 3600 ``` + ## cache_size_to_ram_max_ratio {#cache_size_to_ram_max_ratio} -设置缓存大小对 RAM 最大比例。允许在低内存系统上降低缓存大小。 +设置缓存大小与 RAM 最大比率。在低内存系统上允许降低缓存大小。 + ## cannot_allocate_thread_fault_injection_probability {#cannot_allocate_thread_fault_injection_probability} 用于测试目的。 -## cgroup_memory_watcher_hard_limit_ratio {#cgroup_memory_watcher_hard_limit_ratio} - - -指定根据 cgroups 的服务器进程的内存消耗“硬”阈值,达到该阈值后,服务器的最大内存消耗将调整为阈值值。 -请参见设置: -- [`cgroups_memory_usage_observer_wait_time`](/operations/server-configuration-parameters/settings#cgroups_memory_usage_observer_wait_time) -- [`cgroup_memory_watcher_soft_limit_ratio`](/operations/server-configuration-parameters/settings#cgroup_memory_watcher_soft_limit_ratio) -## cgroup_memory_watcher_soft_limit_ratio {#cgroup_memory_watcher_soft_limit_ratio} - - -指定根据 cgroups 的服务器进程的内存消耗的“软”阈值,达到该阈值后会清除 jemalloc 中的 arena。 - -请参见设置: -- [`cgroups_memory_usage_observer_wait_time`](/operations/server-configuration-parameters/settings#cgroups_memory_usage_observer_wait_time) -- [`cgroup_memory_watcher_hard_limit_ratio`](/operations/server-configuration-parameters/settings#cgroup_memory_watcher_hard_limit_ratio) ## cgroups_memory_usage_observer_wait_time {#cgroups_memory_usage_observer_wait_time} -调整服务器最大允许内存消耗的时间间隔(以秒为单位),根据 cgroups 的相应阈值进行调整。 +服务器的最大允许内存消耗在 cgroups 中的阈值调整的持续时间(以秒为单位)。 要禁用 cgroup 观察者,请将此值设置为 `0`。 -请参见设置: -- [`cgroup_memory_watcher_hard_limit_ratio`](/operations/server-configuration-parameters/settings#cgroup_memory_watcher_hard_limit_ratio) -- [`cgroup_memory_watcher_soft_limit_ratio`](/operations/server-configuration-parameters/settings#cgroup_memory_watcher_soft_limit_ratio)。 ## compiled_expression_cache_elements_size {#compiled_expression_cache_elements_size} -设置 [compiled expressions](../../operations/caches.md) 的缓存大小(以元素为单位)。 +设置 [已编译表达式](../../operations/caches.md) 的缓存大小(以元素为单位)。 + ## compiled_expression_cache_size {#compiled_expression_cache_size} -设置 [compiled expressions](../../operations/caches.md) 的缓存大小(以字节为单位)。 +设置 [已编译表达式](../../operations/caches.md) 的缓存大小(以字节为单位)。 + ## compression {#compression} -用于 [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) 引擎表的数据压缩设置。 +适用于 [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) 引擎表的数据压缩设置。 :::note -我们建议在刚开始使用 ClickHouse 时不要更改此设置。 +建议在您刚开始使用 ClickHouse 时不要更改此设置。 ::: **配置模板**: @@ -426,8 +465,8 @@ ClickHouse 每 x 秒重新加载内置字典。这使得在不重新启动服务 - `min_part_size` – 数据部分的最小大小。 - `min_part_size_ratio` – 数据部分大小与表大小的比率。 -- `method` – 压缩方法。可接受值:`lz4`、`lz4hc`、`zstd`、`deflate_qpl`。 -- `level` – 压缩级别。请参阅 [Codecs](/sql-reference/statements/create/table#general-purpose-codecs)。 +- `method` – 压缩方法。可接受的值:`lz4`、`lz4hc`、`zstd`、`deflate_qpl`。 +- `level` – 压缩级别。请参见 [Codecs](/sql-reference/statements/create/table#general-purpose-codecs)。 :::note 您可以配置多个 `` 部分。 @@ -439,7 +478,7 @@ ClickHouse 每 x 秒重新加载内置字典。这使得在不重新启动服务 - 如果数据部分符合多个条件集,ClickHouse 将使用第一个匹配的条件集。 :::note -如果数据部分没有满足条件,ClickHouse 将使用 `lz4` 压缩。 +如果数据部分不满足条件,ClickHouse 将使用 `lz4` 压缩。 ::: **示例** @@ -454,36 +493,40 @@ ClickHouse 每 x 秒重新加载内置字典。这使得在不重新启动服务 ``` + ## concurrent_threads_scheduler {#concurrent_threads_scheduler} - -对 `concurrent_threads_soft_limit_num` 和 `concurrent_threads_soft_limit_ratio_to_cores` 所指定的 CPU 时隙的调度策略。用于管理有限的 CPU 时隙在并发查询之间的分配的算法。调度程序可在运行时更改,而无需重新启动服务器。 + +对 `concurrent_threads_soft_limit_num` 和 `concurrent_threads_soft_limit_ratio_to_cores` 指定的 CPU 槽调度的执行策略。用于治理在并发查询中分配有限数量的 CPU 槽的算法。调度程序可以在运行时更改,而不需要重新启动服务器。 可能的值: -- `round_robin` — 每个设置 `use_concurrency_control` = 1 的查询最多分配 `max_threads` 个 CPU 时隙。每个线程一个时隙。在竞争时,CPU 时隙将按轮询分配给查询。请注意,第一个时隙无条件分配,这可能导致不公平性,并在查询数较多且高 `max_threads` 的情况下提高查询延迟。 -- `fair_round_robin` — 每个设置 `use_concurrency_control` = 1 的查询最多分配 `max_threads - 1` 个 CPU 时隙。`round_robin` 的变化,不需要为每个查询的第一个线程分配 CPU 时隙。这样,`max_threads` = 1 的查询不需要任何时隙,并且不会不公平地分配所有时隙。没有无条件授予的时隙。 +- `round_robin` - 每个设置 `use_concurrency_control` = 1 的查询分配最多 `max_threads` 个 CPU 槽。每个线程一个槽。如果出现争用,CPU 槽以轮换方式授予查询。请注意,第一个槽是无条件授予的,这可能导致不公平和增加具有高 `max_threads` 的查询的延迟。 +- `fair_round_robin` - 每个设置 `use_concurrency_control` = 1 的查询分配最多 `max_threads - 1` 个 CPU 槽。此轮换的变体不要求每个查询的第一个线程占用一个 CPU 槽。这样,具有 `max_threads` = 1 的查询不需要任何槽,并且无法不公平地分配所有槽。没有槽是无条件授予的。 + ## concurrent_threads_soft_limit_num {#concurrent_threads_soft_limit_num} -运行所有查询时,允许的查询处理线程的最大数量,排除从远程服务器检索数据的线程。这不是硬限制。如果达到限制,查询仍然会至少获取一个线程进行运行。如果在执行期间有更多线程可用,查询可以升级到所需的线程数。 +允许所有查询运行的最大查询处理线程数,不包括从远程服务器获取数据的线程。这不是硬限制。如果达到该限制,查询仍将获得至少一个线程来运行。查询可以在执行过程中升级到所需的线程数,如果有更多线程可用。 :::note -值为 `0`(默认)表示无限制。 +值为 `0` (默认值)表示无限制。 ::: + ## concurrent_threads_soft_limit_ratio_to_cores {#concurrent_threads_soft_limit_ratio_to_cores} -与 [`concurrent_threads_soft_limit_num`](#concurrent_threads_soft_limit_num) 相同,但与核心的比例。 +与 [`concurrent_threads_soft_limit_num`](#concurrent_threads_soft_limit_num) 相同,但与核心的比率。 + ## config_reload_interval_ms {#config_reload_interval_ms} - -ClickHouse 多久将重新加载配置并检查新更改。 +ClickHouse 将多长时间重新加载配置并检查新更改。 + ## core_dump {#core_dump} -配置核心转储文件大小的软限制。 +配置 core dump 文件大小的软限制。 :::note -硬限制由系统工具配置。 +硬限制通过系统工具配置。 ::: **示例** @@ -493,9 +536,55 @@ ClickHouse 多久将重新加载配置并检查新更改。 1073741824 ``` + +## cpu_slot_preemption {#cpu_slot_preemption} + + +定义 CPU 资源(主线程和工作线程)的工作负载调度方式。 + +- 如果为 `true`(推荐),根据实际消耗的 CPU 时间进行计算。将为竞争工作负载分配公平数量的 CPU 时间。为有限时间分配的插槽在到期后需要重新请求。如果 CPU 资源超载,请求插槽可能会阻塞线程执行,即可能发生抢占。这确保了 CPU 时间的公平性。 +- 如果为 `false`(默认),则根据分配的 CPU 槽数量进行计算。将为竞争工作负载分配公平数量的 CPU 槽。线程启动时分配一个插槽,持续保持,直到线程结束执行。为查询执行分配的线程数可能仅从 1 增加到 `max_threads`,而不能减少。这对长时间运行的查询更有利,可能导致短查询的 CPU 资源不足。 + +**示例** + +```xml +true +``` + +**另见** +- [工作负载调度](/operations/workload-scheduling.md) + +## cpu_slot_preemption_timeout_ms {#cpu_slot_preemption_timeout_ms} + + +它定义了一个工作线程在抢占期间可以等待多少毫秒,即在等待授予另一个 CPU 槽期间。如果在此超时后线程无法获得新的 CPU 槽,则将退出,并且查询动态地降低并发执行线程的数量。请注意,主线程永远不会下调,但可以无限期抢占。仅在启用 `cpu_slot_preemption` 且为工作线程定义 CPU 资源时才有意义。 + +**示例** + +```xml +1000 +``` + +**另见** +- [工作负载调度](/operations/workload-scheduling.md) + +## cpu_slot_quantum_ns {#cpu_slot_quantum_ns} + + +它定义了线程在获得 CPU 槽后可以消耗多少 CPU 纳秒,并在此之前应请求另一个 CPU 槽。仅在启用 `cpu_slot_preemption` 且为主线程或工作线程定义 CPU 资源时才有意义。 + +**示例** + +```xml +10000000 +``` + +**另见** +- [工作负载调度](/operations/workload-scheduling.md) + ## crash_log {#crash_log} -用于 [crash_log](../../operations/system-tables/crash-log.md) 系统表操作的设置。 +[crash_log](../../operations/system-tables/crash_log.md) 系统表操作的设置。 @@ -513,14 +602,17 @@ ClickHouse 多久将重新加载配置并检查新更改。 false ``` + ## custom_cached_disks_base_directory {#custom_cached_disks_base_directory} -此设置指定自定义(通过 SQL 创建的)缓存磁盘的缓存路径。 -`custom_cached_disks_base_directory` 对自定义磁盘的优先级高于 `filesystem_caches_path`(在 `filesystem_caches_path.xml` 中),如果前者不存在,则使用后者。 -文件系统缓存设置路径必须位于该目录内,否则会抛出异常,阻止磁盘的创建。 +此设置指定用于自定义(从 SQL 创建的)缓存磁盘的缓存路径。 +`custom_cached_disks_base_directory` 对自定义磁盘优先于 `filesystem_caches_path`(在 `filesystem_caches_path.xml` 中找到)。 +如果前者不存在,将使用后者。 +文件系统缓存设置路径必须位于该目录内, +否则将抛出异常以阻止磁盘创建。 :::note -这不会影响在服务器升级的旧版本上创建的磁盘。 +这不会影响为其升级了服务器的旧版本创建的磁盘。 在这种情况下,不会抛出异常,以允许服务器成功启动。 ::: @@ -529,9 +621,10 @@ ClickHouse 多久将重新加载配置并检查新更改。 ```xml /var/lib/clickhouse/caches/ ``` + ## custom_settings_prefixes {#custom_settings_prefixes} -[custom settings](/operations/settings/query-level#custom_settings) 的前缀列表。前缀必须用逗号分隔。 +[自定义设置](/operations/settings/query-level#custom_settings) 的前缀列表。前缀必须用逗号分隔。 **示例** @@ -539,59 +632,84 @@ ClickHouse 多久将重新加载配置并检查新更改。 custom_ ``` -**另请参见** +**另见** - [自定义设置](/operations/settings/query-level#custom_settings) + ## database_atomic_delay_before_drop_table_sec {#database_atomic_delay_before_drop_table_sec} -在此期间,可以使用 [`UNDROP`](/sql-reference/statements/undrop.md) 语句恢复已删除的表。如果 `DROP TABLE` 以 `SYNC` 修饰符运行,则该设置将被忽略。 -此设置的默认值为 `480`(8 分钟)。 +删除表的过程中,可以使用 [`UNDROP`](/sql-reference/statements/undrop.md) 语句恢复被删除的表的延迟。如果 `DROP TABLE` 以 `SYNC` 修饰符运行,则此设置将被忽略。 +该设置的默认值为 `480`(8分钟)。 + ## database_catalog_drop_error_cooldown_sec {#database_catalog_drop_error_cooldown_sec} -在表删除失败的情况下,ClickHouse 将在重试操作之前等待此超时。 +在删除表失败的情况下,ClickHouse 将在重试操作之前等待此超时。 + ## database_catalog_drop_table_concurrency {#database_catalog_drop_table_concurrency} -用于删除表的线程池的大小。 +用于删除表的线程池大小。 + ## database_catalog_unused_dir_cleanup_period_sec {#database_catalog_unused_dir_cleanup_period_sec} 清理 `store/` 目录中的垃圾的任务参数。 -设置任务的调度周期。 +设置该任务的调度周期。 :::note -值为 `0` 表示“从不”。默认值对应于 1 天。 +值 `0` 表示"从不"。默认值对应于 1 天。 ::: + ## database_catalog_unused_dir_hide_timeout_sec {#database_catalog_unused_dir_hide_timeout_sec} 清理 `store/` 目录中的垃圾的任务参数。 -如果某个子目录未被 clickhouse-server 使用,并且在 [`database_catalog_unused_dir_hide_timeout_sec`](/operations/server-configuration-parameters/settings#database_catalog_unused_dir_hide_timeout_sec) 秒内未做修改,则该任务将“隐藏”该目录,通过移除所有访问权限来实现。它也适用于 clickhouse-server 不希望在 `store/` 目录中看到的目录。 +如果某个子目录未被 clickhouse-server 使用,并且该目录在过去的 [`database_catalog_unused_dir_hide_timeout_sec`](/operations/server-configuration-parameters/settings#database_catalog_unused_dir_hide_timeout_sec) 秒内未被修改,则该任务将通过 +删除所有访问权限来"隐藏"该目录。它也适用于 clickhouse-server 不希望在 `store/` 中看到的目录。 :::note -值为 `0` 表示“立即”。 +值 `0` 表示"立即"。 ::: ## database_catalog_unused_dir_rm_timeout_sec {#database_catalog_unused_dir_rm_timeout_sec} -清理 `store/` 目录中的垃圾的任务参数。 -如果某个子目录未被 clickhouse-server 使用,并且该目录先前已被“隐藏”(请参见 [database_catalog_unused_dir_hide_timeout_sec](/operations/server-configuration-parameters/settings#database_catalog_unused_dir_hide_timeout_sec)),并且在 [`database_catalog_unused_dir_rm_timeout_sec`](/operations/server-configuration-parameters/settings#database_catalog_unused_dir_rm_timeout_sec) 秒内没有做修改,该任务将删除此目录。 -它也适用于 clickhouse-server 不希望在 `store/` 目录中看到的目录。 +清理 `store/` 目录垃圾的任务参数。 +如果某个子目录未被 clickhouse-server 使用,并且之前处于 "隐藏" 状态 +(参见 [database_catalog_unused_dir_hide_timeout_sec](/operations/server-configuration-parameters/settings#database_catalog_unused_dir_hide_timeout_sec)) +并且该目录在过去的 +[`database_catalog_unused_dir_rm_timeout_sec`]/operations/server-configuration-parameters/settings#database_catalog_unused_dir_rm_timeout_sec) 秒内未被修改,任务将会删除此目录。 +它也适用于 clickhouse-server 预计不会在 `store/` 内部看到的目录。 :::note -值为 `0` 表示“从不”。默认值对应于 30 天。 +值为 `0` 意味着 "从不"。默认值对应于 30 天。 ::: ## database_replicated_allow_detach_permanently {#database_replicated_allow_detach_permanently} -允许在复制数据库中永久分离表。 +允许在副本数据库中永久分离表 +## dead_letter_queue {#dead_letter_queue} + +用于 "dead_letter_queue" 系统表的设置。 + + + +默认设置为: + +```xml + + system +
dead_letter
+ toYYYYMM(event_date) + 7500 + +``` ## default_database {#default_database} 默认数据库名称。 ## default_password_type {#default_password_type} -设置在像 `CREATE USER u IDENTIFIED BY 'p'` 这样的查询中自动设置的密码类型。 +设置在 `CREATE USER u IDENTIFIED BY 'p'` 查询中自动设置的密码类型。 -接受的值为: +接受的值有: - `plaintext_password` - `sha256_password` - `double_sha1_password` @@ -602,7 +720,7 @@ ClickHouse 多久将重新加载配置并检查新更改。 ``` ## default_profile {#default_profile} -默认设置配置文件。设置配置文件位于设置 `user_config` 指定的文件中。 +默认设置配置文件。设置配置文件位于 `user_config` 设置指定的文件中。 **示例** @@ -631,21 +749,21 @@ ZooKeeper 中表的路径。 ``` ## default_session_timeout {#default_session_timeout} -默认会话超时,以秒为单位。 +默认会话超时时间,以秒为单位。 ```xml 60 ``` ## dictionaries_config {#dictionaries_config} -字典配置文件的路径。 +字典的配置文件路径。 路径: -- 指定绝对路径或相对于服务器配置文件的路径。 -- 路径可以包含通配符 * 和 ?。 +- 指定绝对路径或相对服务器配置文件的路径。 +- 路径可以包含通配符 \* 和 ?。 -另见: +另请参见: - "[Dictionaries](../../sql-reference/dictionaries/index.md)". **示例** @@ -658,12 +776,12 @@ ZooKeeper 中表的路径。 字典的懒加载。 -- 如果为 `true`,则每个字典在首次使用时加载。如果加载失败,使用该字典的函数会抛出异常。 -- 如果为 `false`,则服务器在启动时加载所有字典。 +- 如果 `true`,则每个字典在第一次使用时加载。如果加载失败,使用字典的函数将抛出异常。 +- 如果 `false`,则服务器在启动时加载所有字典。 :::note -服务器将在启动时等待所有字典加载完成,然后才能接收任何连接 -(例外情况:如果 [`wait_dictionaries_load_at_startup`](/operations/server-configuration-parameters/settings#wait_dictionaries_load_at_startup) 被设置为 `false`)。 +服务器在启动时将等待,直到所有字典完成加载,然后才能接收任何连接 +(例外:如果 [`wait_dictionaries_load_at_startup`](/operations/server-configuration-parameters/settings#wait_dictionaries_load_at_startup) 设置为 `false`)。 ::: **示例** @@ -673,28 +791,28 @@ ZooKeeper 中表的路径。 ``` ## dictionary_background_reconnect_interval {#dictionary_background_reconnect_interval} -启用 `background_reconnect` 的失败的 MySQL 和 Postgres 字典的重连尝试间隔(以毫秒为单位)。 +启用 `background_reconnect` 的失败 MySQL 和 Postgres 字典重连尝试的间隔(以毫秒为单位)。 ## disable_insertion_and_mutation {#disable_insertion_and_mutation} -禁用所有插入/更改/删除查询。此设置在需要只读节点以防止插入和变更影响读取性能时启用。 +禁用所有插入/更改/删除查询。如果需要只读节点以防止插入和更改影响读取性能,则将启用此设置。 ## disable_internal_dns_cache {#disable_internal_dns_cache} -禁用内部 DNS 缓存。推荐在基础设施频繁变化的系统(如 Kubernetes)中操作 ClickHouse。 +禁用内部 DNS 缓存。建议在基础设施经常变更的系统(如 Kubernetes)中运行 ClickHouse 时使用。 ## disable_tunneling_for_https_requests_over_http_proxy {#disable_tunneling_for_https_requests_over_http_proxy} -默认情况下,隧道(即 `HTTP CONNECT`)用于通过 `HTTP` 代理进行 `HTTPS` 请求。此设置可用于禁用它。 +默认情况下,使用隧道(即 `HTTP CONNECT`)通过 `HTTP` 代理进行 `HTTPS` 请求。可以使用此设置禁用它。 **no_proxy** -默认情况下,所有请求将通过代理。为了禁用特定主机的代理,必须设置 `no_proxy` 变量。 -它可以在 `` 子句中为列表和远程解析器设置,也可以作为环境变量为环境解析器设置。 -它支持 IP 地址、域名、子域名和 `'*'` 通配符以供完全绕过。前导点按 curl 的做法被去掉。 +默认情况下,所有请求将通过代理。为了对特定主机禁用代理,必须设置 `no_proxy` 变量。 +可以在 `` 子句中为列出和远程解析器设定,并作为环境变量用于环境解析器。 +它支持 IP 地址、域、子域和 `'*'` 通配符进行完全绕过。前导点将被去除,像 curl 一样。 **示例** -下面的配置绕过对 `clickhouse.cloud` 及其所有子域(例如,`auth.clickhouse.cloud`)的代理请求。 -同样适用于 GitLab,即使它有一个前导点。`gitlab.com` 和 `about.gitlab.com` 都会绕过代理。 +以下配置绕过对 `clickhouse.cloud` 及其所有子域(例如,`auth.clickhouse.cloud`)的代理请求。 +同样适用于 GitLab,尽管它有一个前导点。`gitlab.com` 和 `about.gitlab.com` 将绕过代理。 ```xml @@ -710,45 +828,47 @@ ZooKeeper 中表的路径。 ``` ## disk_connections_soft_limit {#disk_connections_soft_limit} -超过此限制的连接具有显著更短的生存时间。该限制适用于磁盘连接。 +超过此限制的连接有明显更短的生存时间。限制适用于磁盘连接。 ## disk_connections_store_limit {#disk_connections_store_limit} -超过此限制的连接在使用后被重置。设置为 0 以关闭连接缓存。该限制适用于磁盘连接。 +超过此限制的连接使用后会重置。设置为 0 以关闭连接缓存。限制适用于磁盘连接。 ## disk_connections_warn_limit {#disk_connections_warn_limit} - 如果正在使用的连接数量高于此限制,则会将警告消息记录到日志。该限制适用于磁盘连接。 +如果正在使用的连接数量超过此限制,将在日志中写入警告消息。限制适用于磁盘连接。 ## display_secrets_in_show_and_select {#display_secrets_in_show_and_select} 启用或禁用在 `SHOW` 和 `SELECT` 查询中显示表、数据库、表函数和字典的秘密。 -希望查看秘密的用户还必须具有 -[`format_display_secrets_in_show_and_select` 格式设置](../settings/formats#format_display_secrets_in_show_and_select) -开启,以及 -[`displaySecretsInShowAndSelect`](/sql-reference/statements/grant#displaysecretsinshowandselect) 权限。 +希望查看秘密的用户还必须 +启用 [`format_display_secrets_in_show_and_select` 格式设置](../settings/formats#format_display_secrets_in_show_and_select) +并拥有 [`displaySecretsInShowAndSelect`](/sql-reference/statements/grant#displaysecretsinshowandselect) 特权。 可能的值: - `0` — 禁用。 - `1` — 启用。 +## distributed_cache_apply_throttling_settings_from_client {#distributed_cache_apply_throttling_settings_from_client} + +缓存服务器是否应应用从客户端接收到的限流设置。 ## distributed_cache_keep_up_free_connections_ratio {#distributed_cache_keep_up_free_connections_ratio} -Active 连接的软限制,分布式缓存将尝试保持自由。 当自由连接的数量低于 distributed_cache_keep_up_free_connections_ratio * max_connections 时,将关闭最旧活动的连接,直到数量超过限制。 +分布式缓存将尝试保持空闲的活动连接数量的软限制。当空闲连接数量低于 distributed_cache_keep_up_free_connections_ratio * max_connections 时,将关闭活动最老的连接,直到数量超过限制。 ## distributed_ddl {#distributed_ddl} -管理在集群上执行 [distributed ddl 查询](../../sql-reference/distributed-ddl.md)(`CREATE`、`DROP`、`ALTER`、`RENAME`)。 -仅在启用 [ZooKeeper](/operations/server-configuration-parameters/settings#zookeeper) 时有效。 +管理在集群上执行 [分布式 ddl 查询](../../sql-reference/distributed-ddl.md) (`CREATE`, `DROP`, `ALTER`, `RENAME`)。 +仅在启用 [ZooKeeper](/operations/server-configuration-parameters/settings#zookeeper) 的情况下工作。 `` 中的可配置设置包括: -| 设置 | 描述 | 默认值 | -|------------------------|-----------------------------------------------------------------------------------------------------------------------------|--------------------------------------| -| `path` | Keeper 中用于 DDL 查询的 `task_queue` 路径 | | -| `profile` | 用于执行 DDL 查询的配置文件 | | -| `pool_size` | 可以同时运行多少个 `ON CLUSTER` 查询 | | -| `max_tasks_in_queue` | 队列中可以存在的最大任务数。 | `1,000` | -| `task_max_lifetime` | 如果节点的年龄超过此值则删除节点。 | `7 * 24 * 60 * 60`(一周的秒数) | -| `cleanup_delay_period` | 如果最后一次清理在 `cleanup_delay_period` 秒之前未进行,则在接收到新节点事件后开始清理。 | `60` 秒 | +| 设置 | 描述 | 默认值 | +|------------------------|-----------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------| +| `path` | DDL 查询的 `task_queue` 在 Keeper 中的路径 | | +| `profile` | 用于执行 DDL 查询的配置文件 | | +| `pool_size` | 同时可以运行多少个 `ON CLUSTER` 查询 | | +| `max_tasks_in_queue` | 队列中可以存在的最大任务数量。 | `1,000` | +| `task_max_lifetime` | 如果节点的年龄超过此值,则删除节点。 | `7 * 24 * 60 * 60` (一周的秒数) | +| `cleanup_delay_period` | 在接收到新节点事件后,清理在上次清理未发生超过 `cleanup_delay_period` 秒后开始。 | `60` 秒 | **示例** @@ -779,27 +899,33 @@ ZooKeeper 中表的路径。 ``` ## dns_allow_resolve_names_to_ipv4 {#dns_allow_resolve_names_to_ipv4} -允许将名称解析为 IPv4 地址。 +允许解析名字为 ipv4 地址。 ## dns_allow_resolve_names_to_ipv6 {#dns_allow_resolve_names_to_ipv6} -允许将名称解析为 IPv6 地址。 +允许解析名字为 ipv6 地址。 ## dns_cache_max_entries {#dns_cache_max_entries} 内部 DNS 缓存最大条目数。 ## dns_cache_update_period {#dns_cache_update_period} -内部 DNS 缓存更新时间(以秒为单位)。 +内部 DNS 缓存更新周期(以秒为单位)。 ## dns_max_consecutive_failures {#dns_max_consecutive_failures} -主机名 DNS 解析失败的最大次数,在此之后将主机名从 ClickHouse DNS 缓存中删除。 +在将主机名从 ClickHouse DNS 缓存中删除之前,解析主机名的最大 DNS 失败次数。 +## drop_distributed_cache_pool_size {#drop_distributed_cache_pool_size} + +用于删除分布式缓存的线程池大小。 +## drop_distributed_cache_queue_size {#drop_distributed_cache_queue_size} + +用于删除分布式缓存的线程池队列大小。 ## enable_azure_sdk_logging {#enable_azure_sdk_logging} -启用 Azure sdk 的日志记录 +启用来自 Azure sdk 的日志记录。 ## encryption {#encryption} -配置用于 [encryption codecs](/sql-reference/statements/create/table#encryption-codecs) 的密钥获取命令。密钥(或密钥)应该写入环境变量或在配置文件中设置。 +配置用于 [encryption codecs](/sql-reference/statements/create/table#encryption-codecs) 的密钥获取命令。密钥(或密钥)应写入环境变量或在配置文件中设置。 -密钥可以是十六进制或长度为 16 字节的字符串。 +密钥可以是十六进制或者长度为 16 字节的字符串。 **示例** @@ -814,10 +940,10 @@ ZooKeeper 中表的路径。 ``` :::note -不推荐在配置文件中存储密钥。这并不安全。您可以将密钥移动到安全磁盘上的单独配置文件中,并将该配置文件的符号链接放入 `config.d/` 文件夹中。 +不建议在配置文件中存储密钥。这不安全。您可以将密钥移动到安全磁盘的单独配置文件中,并将该配置文件的符号链接放入 `config.d/` 文件夹中。 ::: -从配置中加载,当密钥为十六进制时: +从配置加载,当密钥是十六进制时: ```xml @@ -837,9 +963,9 @@ ZooKeeper 中表的路径。 ``` -在这里,`current_key_id` 设置用于加密的当前密钥,所有指定的密钥都可以用于解密。 +此处 `current_key_id` 设置用于加密的当前密钥,所有指定的密钥可用于解密。 -这些方法都可以应用于多个密钥: +这些方法中的每一个都可以应用于多个密钥: ```xml @@ -851,9 +977,9 @@ ZooKeeper 中表的路径。 ``` -这里的 `current_key_id` 显示为加密的当前密钥。 +此处 `current_key_id` 显示当前的加密密钥。 -此外,用户可以添加必须为 12 字节长的 nonce(默认情况下加密和解密过程使用由零字节组成的 nonce): +此外,用户可以添加需要 12 字节长度的 nonce(默认情况下加密和解密过程使用由零字节组成的 nonce): ```xml @@ -863,7 +989,7 @@ ZooKeeper 中表的路径。 ``` -或者可以以十六进制设置: +或者可以设置为十六进制: ```xml @@ -873,7 +999,7 @@ ZooKeeper 中表的路径。 ``` :::note -上述所有内容可以应用于 `aes_256_gcm_siv` (但密钥必须为 32 字节长)。 +上述所有内容均适用于 `aes_256_gcm_siv` (但密钥必须为 32 字节长)。 ::: ## error_log {#error_log} @@ -881,7 +1007,7 @@ ZooKeeper 中表的路径。 **启用** -要手动开启错误历史记录收集 [`system.error_log`](../../operations/system-tables/error_log.md),创建 `/etc/clickhouse-server/config.d/error_log.xml`,内容如下: +要手动开启错误历史收集 [`system.error_log`](../../operations/system-tables/error_log.md),请创建 `/etc/clickhouse-server/config.d/error_log.xml`,内容如下: ```xml @@ -909,9 +1035,17 @@ ZooKeeper 中表的路径。 ``` +## format_parsing_thread_pool_queue_size {#format_parsing_thread_pool_queue_size} + + +可以在解析输入时调度的最大作业数量。 + +:::note +值为 `0` 意味着无限制。 +::: ## format_schema_path {#format_schema_path} -输入数据模式所在目录的路径,例如 [CapnProto](../../interfaces/formats.md#capnproto) 格式的模式。 +输入数据模式的目录路径,例如 [CapnProto](../../interfaces/formats.md#capnproto) 格式的模式。 **示例** @@ -921,13 +1055,13 @@ ZooKeeper 中表的路径。 ``` ## global_profiler_cpu_time_period_ns {#global_profiler_cpu_time_period_ns} -全局分析器的 CPU 时钟计时器周期(以纳秒为单位)。设置为 0 以关闭 CPU 时钟全局分析器。建议在单个查询中至少设置为 10000000(每秒 100 次),或者在集群宽度分析中至少设置为 1000000000(每秒 1 次)。 +全局剖析器的 CPU 时钟计时器周期(以纳秒为单位)。设置为 0 以关闭 CPU 时钟全局剖析器。推荐值至少为 10000000(每秒 100 次)用于单个查询或 1000000000(每秒一次)用于集群范围的剖析。 ## global_profiler_real_time_period_ns {#global_profiler_real_time_period_ns} -全局分析器的实际时钟计时器周期(以纳秒为单位)。设置为 0 以关闭实际时钟全局分析器。建议在单个查询中至少设置为 10000000(每秒 100 次),或者在集群宽度分析中至少设置为 1000000000(每秒 1 次)。 +全局剖析器的实际时钟计时器周期(以纳秒为单位)。设置为 0 以关闭实际时钟全局剖析器。推荐值至少为 10000000(每秒 100 次)用于单个查询或 1000000000(每秒一次)用于集群范围的剖析。 ## google_protos_path {#google_protos_path} -定义包含 Protobuf 类型 proto 文件的目录。 +定义一个目录,包含用于 Protobuf 类型的 proto 文件。 示例: @@ -936,21 +1070,21 @@ ZooKeeper 中表的路径。 ``` ## graphite {#graphite} -发送数据到 [Graphite](https://github.com/graphite-project). +将数据发送到 [Graphite](https://github.com/graphite-project)。 设置: - `host` – Graphite 服务器。 -- `port` – Graphite 服务器上的端口。 -- `interval` – 发送间隔(以秒为单位)。 -- `timeout` – 发送数据的超时(以秒为单位)。 +- `port` – Graphite 服务器的端口。 +- `interval` – 发送间隔,以秒为单位。 +- `timeout` – 发送数据的超时时间,以秒为单位。 - `root_path` – 键的前缀。 - `metrics` – 从 [system.metrics](/operations/system-tables/metrics) 表发送数据。 -- `events` – 从 [system.events](/operations/system-tables/events) 表发送在时间段内累积的 delta 数据。 +- `events` – 从 [system.events](/operations/system-tables/events) 表发送在时间段内累积的增量数据。 - `events_cumulative` – 从 [system.events](/operations/system-tables/events) 表发送累积数据。 - `asynchronous_metrics` – 从 [system.asynchronous_metrics](/operations/system-tables/asynchronous_metrics) 表发送数据。 -您可以配置多个 `` 子句。例如,您可以使用这个来在不同的间隔发送不同的数据。 +您可以配置多个 `` 子句。例如,您可以用来在不同的间隔发送不同的数据。 **示例** @@ -969,7 +1103,7 @@ ZooKeeper 中表的路径。 ``` ## graphite_rollup {#graphite_rollup} -用于 Graphite 的数据稀疏设置。 +用于 Graphite 的数据精简设置。 有关更多详细信息,请参见 [GraphiteMergeTree](../../engines/table-engines/mergetree-family/graphitemergetree.md)。 @@ -996,10 +1130,10 @@ ZooKeeper 中表的路径。 ``` ## hsts_max_age {#hsts_max_age} -HSTS 的过期时间(以秒为单位)。 +HSTS 的过期时间,以秒为单位。 :::note -值为 `0` 表示 ClickHouse 禁用 HSTS。如果您设置一个正数,HSTS 将启用,最大年龄是您设置的数字。 +值为 `0` 意味着 ClickHouse 禁用 HSTS。如果您设置一个正数,HSTS 将启用,并且 max-age 为您设置的数字。 ::: **示例** @@ -1009,43 +1143,43 @@ HSTS 的过期时间(以秒为单位)。 ``` ## http_connections_soft_limit {#http_connections_soft_limit} -超过此限制的连接具有显著更短的生存时间。该限制适用于不属于任何磁盘或存储的 http 连接。 +超过此限制的连接有明显更短的生存时间。限制适用于不属于任何磁盘或存储的 http 连接。 ## http_connections_store_limit {#http_connections_store_limit} -超过此限制的连接在使用后被重置。设置为 0 以关闭连接缓存。该限制适用于不属于任何磁盘或存储的 http 连接。 +超过此限制的连接使用后会重置。设置为 0 以关闭连接缓存。限制适用于不属于任何磁盘或存储的 http 连接。 ## http_connections_warn_limit {#http_connections_warn_limit} - 如果正在使用的连接数量高于此限制,则会将警告消息记录到日志。该限制适用于不属于任何磁盘或存储的 http 连接。 +如果正在使用的连接数量超过此限制,将在日志中写入警告消息。限制适用于不属于任何磁盘或存储的 http 连接。 ## http_handlers {#http_handlers} 允许使用自定义 HTTP 处理程序。 -要添加新的 http 处理程序,只需新增 ``。 -规则从上到下检查,如所定义的, -第一个匹配的将运行处理程序。 +要添加新的 http 处理程序,只需添加一个新的 ``。 +规则按照定义的从上到下检查, +第一个匹配项将运行处理程序。 -以下设置可以通过子标签进行配置: +可以通过子标签配置以下设置: -| 子标签 | 定义 | -|---------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------| -| `url` | 要匹配请求 URL,您可以使用 'regex:' 前缀来使用正则匹配(可选) | -| `methods` | 要匹配请求方法,可以使用逗号分隔多个方法匹配(可选) | -| `headers` | 要匹配请求头,匹配每个子元素(子元素名称为头部名称),您可以使用 'regex:' 前缀来使用正则匹配(可选) | -| `handler` | 请求处理程序 | -| `empty_query_string`| 检查 URL 中是否没有查询字符串 | +| 子标签 | 定义 | +|----------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `url` | 要匹配请求 URL,您可以使用 'regex:' 前缀来使用正则表达式匹配(可选) | +| `methods` | 要匹配请求方法,您可以使用逗号分隔多个方法匹配(可选) | +| `headers` | 要匹配请求头,匹配每个子元素(子元素名称是头名称),您可以使用 'regex:' 前缀来使用正则表达式匹配(可选) | +| `handler` | 请求处理程序 | +| `empty_query_string` | 检查 URL 中是否没有查询字符串 | `handler` 包含以下设置,可以通过子标签进行配置: -| 子标签 | 定义 | -|---------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------| -| `url` | 重定向位置 | -| `type` | 支持的类型:static、dynamic_query_handler、predefined_query_handler、redirect | -| `status` | 与 static 类型一起使用,响应状态码 | -| `query_param_name` | 与 dynamic_query_handler 类型一起使用,提取并执行与 HTTP 请求参数中的 `` 值相对应的值 | -| `query` | 与 predefined_query_handler 类型一起使用,当调用处理程序时执行查询 | -| `content_type` | 与 static 类型一起使用,响应内容类型 | -| `response_content` | 与 static 类型一起使用,发送给客户端的响应内容,当使用前缀 'file://' 或 'config://' 时,从文件或配置中查找内容并发送给客户端 | +| 子标签 | 定义 | +|----------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `url` | 重定向的位置 | +| `type` | 支持的类型:static、dynamic_query_handler、predefined_query_handler、redirect | +| `status` | 与静态类型一起使用,响应状态代码 | +| `query_param_name` | 与 dynamic_query_handler 类型一起使用,从 HTTP 请求参数中提取并执行与 `` 值相对应的值 | +| `query` | 与 predefined_query_handler 类型一起使用,调用处理程序时执行查询 | +| `content_type` | 与静态类型一起使用,响应内容类型 | +| `response_content` | 与静态类型一起使用,发送到客户端的响应内容,当使用前缀 'file://' 或 'config://' 时,从文件或配置中查找内容发送到客户端 | -除了规则列表之外,您还可以指定 ``,它指定启用所有默认处理程序。 +您可以指定默认处理程序的 `` 列表,以启用所有默认处理程序。 示例: @@ -1083,7 +1217,7 @@ HSTS 的过期时间(以秒为单位)。 ## http_options_response {#http_options_response} 用于在 `OPTIONS` HTTP 请求中添加响应头。 -`OPTIONS` 方法在进行 CORS 预检请求时使用。 +`OPTIONS` 方法用于发出 CORS 预检请求。 有关更多信息,请参见 [OPTIONS](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/OPTIONS)。 @@ -1111,12 +1245,12 @@ HSTS 的过期时间(以秒为单位)。 ``` ## http_server_default_response {#http_server_default_response} -访问 ClickHouse HTTP(s) 服务器时默认显示的页面。 -默认值为 "Ok."(行尾带换行符) +在访问 ClickHouse HTTP(s) 服务器时默认显示的页面。 +默认值为 "Ok."(末尾带换行符) **示例** -访问 `http://localhost: http_port` 时会打开 `https://tabix.io/`。 +访问 `http://localhost: http_port` 时打开 `https://tabix.io/`。 ```xml @@ -1125,13 +1259,13 @@ HSTS 的过期时间(以秒为单位)。 ``` ## iceberg_catalog_threadpool_pool_size {#iceberg_catalog_threadpool_pool_size} -冰山目录的后台线程池大小 +冰山目录的后台池大小 ## iceberg_catalog_threadpool_queue_size {#iceberg_catalog_threadpool_queue_size} 可以推入冰山目录池的任务数量 ## iceberg_metadata_files_cache_max_entries {#iceberg_metadata_files_cache_max_entries} -冰山元数据文件缓存的最大条目数。零表示禁用。 +冰山元数据文件缓存的最大条目数。零表示禁用。 ## iceberg_metadata_files_cache_policy {#iceberg_metadata_files_cache_policy} 冰山元数据缓存策略名称。 @@ -1140,20 +1274,20 @@ HSTS 的过期时间(以秒为单位)。 冰山元数据缓存的最大大小(以字节为单位)。零表示禁用。 ## iceberg_metadata_files_cache_size_ratio {#iceberg_metadata_files_cache_size_ratio} -在冰山元数据缓存中受保护队列的大小(在 SLRU 策略的情况下),相对于缓存的总大小。 +冰山元数据缓存中受保护队列的大小(在 SLRU 策略的情况下),相对于缓存的总大小。 ## ignore_empty_sql_security_in_create_view_query {#ignore_empty_sql_security_in_create_view_query} -如果为 true,ClickHouse 不会在 `CREATE VIEW` 查询中为空的 SQL 安全语句写入默认值。 +如果为 true,ClickHouse 在 `CREATE VIEW` 查询中不写入空 SQL 安全语句的默认值。 :::note -此设置仅在迁移期间是必要的,并将在 24.4 中变得过时。 +此设置仅在迁移期间是必要的,并将在 24.4 中变得过时 ::: ## include_from {#include_from} -包含替代项的文件的路径。支持 XML 和 YAML 格式。 +替换文件的路径。支持 XML 和 YAML 格式。 -有关更多信息,请参见 "[Configuration files](/operations/configuration-files)" 部分。 +有关更多信息,请参见 “[Configuration files](/operations/configuration-files)” 部分。 **示例** @@ -1166,37 +1300,37 @@ HSTS 的过期时间(以秒为单位)。 ## index_mark_cache_size {#index_mark_cache_size} -索引标记缓存的最大大小。 +最大索引标记的缓存大小。 :::note 值为 `0` 表示禁用。 -此设置可以在运行时修改,并会立即生效。 +该设置可以在运行时修改,并将立即生效。 ::: ## index_mark_cache_size_ratio {#index_mark_cache_size_ratio} -在二级索引标记缓存中受保护队列的大小(在 SLRU 策略的情况下),相对于缓存的总大小。 +二级索引标记缓存中受保护队列的大小(在 SLRU 策略的情况下),相对于缓存的总大小。 ## index_uncompressed_cache_policy {#index_uncompressed_cache_policy} 二级索引未压缩缓存策略名称。 ## index_uncompressed_cache_size {#index_uncompressed_cache_size} -`MergeTree` 索引未压缩块的缓存的最大大小。 +`MergeTree` 索引未压缩块的最大缓存大小。 :::note 值为 `0` 表示禁用。 -此设置可以在运行时修改,并会立即生效。 +该设置可以在运行时修改,并将立即生效。 ::: ## index_uncompressed_cache_size_ratio {#index_uncompressed_cache_size_ratio} -在二级索引未压缩缓存中受保护队列的大小(在 SLRU 策略的情况下),相对于缓存的总大小。 +二级索引未压缩缓存中受保护队列的大小(在 SLRU 策略的情况下),相对于缓存的总大小。 ## interserver_http_credentials {#interserver_http_credentials} -用于在 [复制](../../engines/table-engines/mergetree-family/replication.md) 时连接到其他服务器的用户名和密码。此外,服务器使用这些凭据验证其他副本。 -因此,`interserver_http_credentials` 必须在集群中的所有副本中相同。 +在 [复制](../../engines/table-engines/mergetree-family/replication.md) 期间,用于连接到其他服务器的用户名和密码。此外,服务器使用这些凭据来验证其他副本。 +因此 `interserver_http_credentials` 必须对集群中的所有副本相同。 :::note - 默认情况下,如果省略 `interserver_http_credentials` 部分,则在复制期间不使用身份验证。 @@ -1204,18 +1338,18 @@ HSTS 的过期时间(以秒为单位)。 - 这些凭据适用于通过 `HTTP` 和 `HTTPS` 进行复制。 ::: -以下设置可以通过子标签进行配置: +可以通过子标签配置以下设置: - `user` — 用户名。 - `password` — 密码。 -- `allow_empty` — 如果为 `true`,则允许其他副本在设置凭据的情况下无身份验证连接。如果为 `false`,则拒绝无身份验证连接。默认:`false`。 -- `old` — 包含在凭据轮换期间使用过的旧 `user` 和 `password`。可以指定多个 `old` 部分。 +- `allow_empty` — 如果为 `true`,则其他副本可以在设置凭据的情况下无需身份验证连接。如果为 `false`,则拒绝未经身份验证的连接。默认值:`false`。 +- `old` — 包含在凭据轮换期间使用的旧 `user` 和 `password`。可以指定多个 `old` 部分。 **凭据轮换** -ClickHouse 支持动态的 interserver 凭据轮换,而无需同时停止所有副本以更新它们的配置。凭据可以分几个步骤进行更改。 +ClickHouse 支持动态的 interserver 凭据轮换,而无需同时停止所有副本以更新其配置。凭据可以分步更改。 -要启用身份验证,请将 `interserver_http_credentials.allow_empty` 设置为 `true` 并添加凭据。这允许带有和不带身份验证的连接。 +要启用身份验证,将 `interserver_http_credentials.allow_empty` 设置为 `true` 并添加凭据。这允许带身份验证和不带身份验证的连接。 ```xml @@ -1225,9 +1359,9 @@ ClickHouse 支持动态的 interserver 凭据轮换,而无需同时停止所 ``` -在配置所有副本后,将 `allow_empty` 设置为 `false` 或移除此设置。这使得使用新凭据的身份验证成为强制。 +在配置所有副本后,将 `allow_empty` 设置为 `false` 或者删除此设置。这使得使用新凭据强制身份验证。 -要更改现有凭据,请将用户名和密码移动到 `interserver_http_credentials.old` 部分,并用新值更新 `user` 和 `password`。此时,服务器使用新凭据连接到其他副本,并接受新旧凭据的连接。 +要更改现有凭据,将用户名和密码移动到 `interserver_http_credentials.old` 部分,并使用新值更新 `user` 和 `password`。此时服务器使用新凭据连接到其他副本,并接受使用新或旧凭据的连接。 ```xml @@ -1244,14 +1378,14 @@ ClickHouse 支持动态的 interserver 凭据轮换,而无需同时停止所 ``` -当新凭据应用于所有副本后,可以删除旧凭据。 +当新凭据应用到所有副本时,可以删除旧凭据。 ## interserver_http_host {#interserver_http_host} -其他服务器可以用来访问此服务器的主机名。 +其他服务器可用于访问此服务器的主机名。 -如果省略,它的定义与 `hostname -f` 命令相同。 +如果省略,将采用与 `hostname -f` 命令相同的定义。 -有助于摆脱特定网络界面。 +适合摆脱特定网络接口。 **示例** @@ -1260,7 +1394,7 @@ ClickHouse 支持动态的 interserver 凭据轮换,而无需同时停止所 ``` ## interserver_http_port {#interserver_http_port} -ClickHouse 服务器之间交换数据的端口。 +用于在 ClickHouse 服务器之间交换数据的端口。 **示例** @@ -1269,7 +1403,7 @@ ClickHouse 服务器之间交换数据的端口。 ``` ## interserver_https_host {#interserver_https_host} -类似于 [`interserver_http_host`](#interserver_http_host),只是此主机名可以被其他服务器用来通过 `HTTPS` 访问此服务器。 +类似于 [`interserver_http_host`](#interserver_http_host),不过这个主机名可供其他服务器通过 `HTTPS` 访问此服务器。 **示例** @@ -1278,7 +1412,7 @@ ClickHouse 服务器之间交换数据的端口。 ``` ## interserver_https_port {#interserver_https_port} -ClickHouse 服务器之间通过 `HTTPS` 交换数据的端口。 +用于通过 `HTTPS` 在 ClickHouse 服务器之间交换数据的端口。 **示例** @@ -1287,11 +1421,11 @@ ClickHouse 服务器之间通过 `HTTPS` 交换数据的端口。 ``` ## interserver_listen_host {#interserver_listen_host} -在 ClickHouse 服务器之间交换数据的主机限制。 -如果使用 Keeper,则在不同的 Keeper 实例之间也将应用相同的限制。 +限制可以在 ClickHouse 服务器之间交换数据的主机。 +如果使用 Keeper,则该限制将适用于不同 Keeper 实例之间的通信。 :::note -默认情况下,该值等于 [`listen_host`](#listen_host) 设置。 +默认情况下,值与 [`listen_host`](#listen_host) 设置相等。 ::: **示例** @@ -1303,91 +1437,84 @@ ClickHouse 服务器之间通过 `HTTPS` 交换数据的端口。 类型: -默认值: +默认: ## io_thread_pool_queue_size {#io_thread_pool_queue_size} -可以在 I/O 线程池中调度的最大作业数量。 +可以在 IO 线程池上调度的最大作业数量。 :::note -值为 `0` 表示无限制。 +值为 `0` 意味着无限制。 ::: -## keep_alive_timeout {#keep_alive_timeout} +## jemalloc_collect_global_profile_samples_in_trace_log {#jemalloc_collect_global_profile_samples_in_trace_log} - -ClickHouse 等待 HTTP 协议的传入请求的秒数,然后关闭连接。 +将 jemalloc 的采样分配存储在 system.trace_log 中。 +## jemalloc_enable_background_threads {#jemalloc_enable_background_threads} -**示例** +启用 jemalloc 后台线程。Jemalloc 使用后台线程来清理未使用的内存页。禁用它可能导致性能下降。 +## jemalloc_enable_global_profiler {#jemalloc_enable_global_profiler} -```xml -10 -``` -## keeper_multiread_batch_size {#keeper_multiread_batch_size} +为所有线程启用 jemalloc 的分配剖析器。Jemalloc 将采样分配和所有采样分配的去分配。 +可以使用系统命令 SYSTEM JEMALLOC FLUSH PROFILE 进行配置分析。 +样本也可以使用配置 jemalloc_collect_global_profile_samples_in_trace_log 或查询设置 jemalloc_collect_profile_samples_in_trace_log 存储在 system.trace_log 中。 +参见 [Allocation Profiling](/operations/allocation-profiling)。 +## jemalloc_flush_profile_interval_bytes {#jemalloc_flush_profile_interval_bytes} -支持批处理的 [Zoo]Keeper 的 MultiRead 请求的最大批量大小。如果设置为 0,则禁用批处理。仅在 ClickHouse Cloud 中可用。 -## latency_log {#latency_log} +在全局峰值内存占用增加到 jemalloc_flush_profile_interval_bytes 后,将进行 jemalloc 剖析刷新。 +## jemalloc_flush_profile_on_memory_exceeded {#jemalloc_flush_profile_on_memory_exceeded} -默认情况下禁用。 +在发生总内存超限错误时将进行 jemalloc 剖析刷新。 +## jemalloc_max_background_threads_num {#jemalloc_max_background_threads_num} -**启用** +要创建的 jemalloc 后台线程的最大数量,设置为 0 使用 jemalloc 的默认值。 +## keep_alive_timeout {#keep_alive_timeout} -要手动开启延迟历史记录收集 [`system.latency_log`](../../operations/system-tables/latency_log.md),创建 `/etc/clickhouse-server/config.d/latency_log.xml`,内容如下: + +ClickHouse 在关闭连接之前,等待 HTTP 协议的传入请求的秒数。 + +**示例** ```xml - - - system - latency_log
- 7500 - 1000 - 1048576 - 8192 - 524288 - false -
-
+10 ``` +## keeper_hosts {#keeper_hosts} -**禁用** - -要禁用 `latency_log` 设置,您应该创建以下文件 `/etc/clickhouse-server/config.d/disable_latency_log.xml`,内容如下: +动态设置。包含 ClickHouse 可以潜在连接的一组 [Zoo]Keeper 主机。不会公开来自 ```` 的信息。 +## keeper_multiread_batch_size {#keeper_multiread_batch_size} -```xml - - - -``` -## ldap_servers {#ldap_servers} + +支持批处理的多读请求到 [Zoo]Keeper 的最大批处理大小。如果设置为 0,则禁用批处理。仅在 ClickHouse Cloud 中可用。 +## ldap_servers {#ldap_servers} -在此列出 LDAP 服务器及其连接参数,以: -- 将其用作具有“ldap”身份验证机制的专用本地用户的身份验证器,而非“password” -- 将其用作远程用户目录。 +在此列出 LDAP 服务器及其连接参数,以便: +- 用作专用本地用户的身份验证者,这些用户指定了 "ldap" 认证机制,而不是 "password" +- 用作远程用户目录。 -可以通过子标签配置以下设置: +以下设置可以通过子标签进行配置: -| 设置 | 描述 | -|--------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `host` | LDAP 服务器主机名或 IP,此参数是必填的,不能为空。 | -| `port` | LDAP 服务器端口,如果 `enable_tls` 设置为 true,则默认为 636,否则默认为 389。 | -| `bind_dn` | 用于构造绑定的 DN 的模板。在每次身份验证尝试期间,结果 DN 将通过替换模板中的所有 `\{user_name\}` 子字符串为实际用户名构建。 | -| `user_dn_detection` | 具有 LDAP 搜索参数的部分,检测绑定用户的实际用户 DN。这主要在服务器为 Active Directory 时用于进一步角色映射的搜索过滤器。替换 `\{user_dn\}` 子字符串时将使用结果用户 DN。默认情况下,用户 DN 设置为等于绑定 DN,但一旦执行搜索,将用实际检测到的用户 DN 值进行更新。 | -| `verification_cooldown` | 在成功的绑定尝试后,期间(以秒为单位),用户将被认为在所有连续请求中成功通过身份验证,在此期间无需联系 LDAP 服务器。指定 `0`(默认)以禁用缓存并强制在每个身份验证请求时联系 LDAP 服务器。 | -| `enable_tls` | 触发与 LDAP 服务器的安全连接的标志。指定 `no` 使用明文(`ldap://`)协议(不推荐)。指定 `yes` 使用 SSL/TLS 保护的 LDAP(`ldaps://`)协议(推荐,默认)。指定 `starttls` 使用旧版 StartTLS 协议(明文(`ldap://`)协议,升级到 TLS)。 | -| `tls_minimum_protocol_version` | SSL/TLS 的最低协议版本。接受的值包括:`ssl2`,`ssl3`,`tls1.0`,`tls1.1`,`tls1.2`(默认)。 | -| `tls_require_cert` | SSL/TLS 对等证书验证行为。接受的值包括:`never`,`allow`,`try`,`demand`(默认)。 | -| `tls_cert_file` | 证书文件的路径。 | -| `tls_key_file` | 证书密钥文件的路径。 | -| `tls_ca_cert_file` | CA 证书文件的路径。 | -| `tls_ca_cert_dir` | 包含 CA 证书的目录的路径。 | -| `tls_cipher_suite` | 允许的密码套件(以 OpenSSL 符号表示)。 | - -`user_dn_detection` 的设置可以通过子标签进行配置: - -| 设置 | 描述 | -|------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `base_dn` | 用于构造 LDAP 搜索的基本 DN 的模板。在 LDAP 搜索期间,将通过替换模板中的所有 `\{user_name\}` 和 '\{bind_dn\}' 子字符串为实际用户名和绑定 DN 来构造结果 DN。 | -| `scope` | LDAP 搜索的范围。接受的值包括:`base`,`one_level`,`children`,`subtree`(默认)。 | -| `search_filter` | 用于构造 LDAP 搜索的搜索过滤器的模板。在 LDAP 搜索期间,将通过替换模板中的所有 `\{user_name\}`, `\{bind_dn\}` 和 `\{base_dn\}` 子字符串为实际用户名、绑定 DN 和基本 DN 来构造结果过滤器。注意,特殊字符必须在 XML 中正确转义。 | +| 设置 | 描述 | +|--------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `host` | LDAP 服务器的主机名或 IP,此参数是必需的,不能为空。 | +| `port` | LDAP 服务器端口,如果 `enable_tls` 设置为 true,默认是 636,否则为 389。 | +| `bind_dn` | 用于构建绑定的 DN 的模板。在每次身份验证尝试中,生成的 DN 将通过用实际用户名替换模板中的所有 `\{user_name\}` 子字符串来构造。 | +| `user_dn_detection` | 包含 LDAP 搜索参数的部分,用于检测已绑定用户的实际用户 DN。这主要在 Active Directory 服务器的搜索过滤器中用于进一步的角色映射。生成的用户 DN 将在允许替换 `\{user_dn\}` 子字符串时使用。默认情况下,用户 DN 设置为等于绑定 DN,但一旦执行搜索,它将被实际检测到的用户 DN 值更新。 | +| `verification_cooldown` | 成功绑定尝试后的一段时间(以秒为单位),在该时间段内,用户将被假定为成功认证,用于所有后续请求,而无需联系 LDAP 服务器。指定 `0`(默认值)来禁用缓存,并强制在每次身份验证请求时联系 LDAP 服务器。 | +| `enable_tls` | 触发与 LDAP 服务器的安全连接的标志。指定 `no` 以使用明文 (`ldap://`) 协议(不推荐)。指定 `yes` 以使用基于 SSL/TLS 的 LDAP (`ldaps://`) 协议(推荐,默认)。指定 `starttls` 以使用旧版 StartTLS 协议(明文(`ldap://`)协议,升级到 TLS)。 | +| `tls_minimum_protocol_version` | SSL/TLS 的最低协议版本。接受的值包括:`ssl2`、`ssl3`、`tls1.0`、`tls1.1`、`tls1.2`(默认)。 | +| `tls_require_cert` | SSL/TLS 对等证书验证行为。接受的值包括:`never`、`allow`、`try`、`demand`(默认)。 | +| `tls_cert_file` | 证书文件的路径。 | +| `tls_key_file` | 证书密钥文件的路径。 | +| `tls_ca_cert_file` | CA 证书文件的路径。 | +| `tls_ca_cert_dir` | 包含 CA 证书的目录的路径。 | +| `tls_cipher_suite` | 允许的密码套件(以 OpenSSL 表示法)。 | + +设置 `user_dn_detection` 可以通过子标签进行配置: + +| 设置 | 描述 | +|---------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `base_dn` | 用于构建 LDAP 搜索的基本 DN 的模板。在 LDAP 搜索过程中,生成的 DN 通过替换模板中所有 `\{user_name\}` 和 `\{bind_dn\}` 子字符串与实际用户名和绑定 DN 构建。 | +| `scope` | LDAP 搜索的范围。接受的值包括:`base`、`one_level`、`children`、`subtree`(默认)。 | +| `search_filter`| 用于构建 LDAP 搜索的搜索过滤器的模板。在 LDAP 搜索过程中,生成的过滤器通过替换模板中所有 `\{user_name\}`、`\{bind_dn\}` 和 `\{base_dn\}` 子字符串与实际用户名、绑定 DN 和基本 DN 构建。请注意,特殊字符必须在 XML 中正确转义。 | 示例: @@ -1408,7 +1535,7 @@ ClickHouse 等待 HTTP 协议的传入请求的秒数,然后关闭连接。 ``` -示例(典型的 Active Directory,已配置用户 DN 检测以进行进一步角色映射): +示例(典型的 Active Directory,配置了用户 DN 检测以方便进一步的角色映射): ```xml @@ -1422,29 +1549,29 @@ ClickHouse 等待 HTTP 协议的传入请求的秒数,然后关闭连接。 no ``` -## license_key {#license_key} +## license_key {#license_key} -ClickHouse 企业版的许可证密钥 -## listen_backlog {#listen_backlog} +ClickHouse 企业版的许可密钥 +## listen_backlog {#listen_backlog} -监听套接字的回退(待处理连接的队列大小)。默认值 `4096` 与 Linux [5.4+](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=19f92a030ca6d772ab44b22ee6a01378a8cb32d4)的值相同。 +监听套接字的回放(挂起连接的队列大小)。默认值 `4096` 等于 linux [5.4+](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=19f92a030ca6d772ab44b22ee6a01378a8cb32d4)) 的值。 -通常无需更改此值,因为: -- 默认值足够大, -- 服务器有单独的线程来接收客户端连接。 +通常情况下,此值无需更改,因为: +- 默认值足够大, +- 为接受客户的连接,服务器有单独的线程。 -因此,即使您有 `TcpExtListenOverflows` (来自 `nstat`)非零,这个计数器在 ClickHouse 服务器上增长,也不意味着需要增加此值,因为: -- 通常,如果 `4096` 不够,这表明存在某些内部的 ClickHouse 扩展问题,因此最好报告问题。 -- 这并不意味着服务器将来可以处理更多连接(即使它能够,在那时客户端可能已经消失或断开连接)。 +因此,即使你的 `TcpExtListenOverflows`(来自 `nstat`)非零,并且该计数器在 ClickHouse 服务器上增加,这并不意味着需要增加该值,因为: +- 通常,如果 `4096` 不够,它显示了某些内部 ClickHouse 扩展问题,因此最好报告一个问题。 +- 这并不意味着服务器可以处理更多的连接(即使可以,在那时客户也可能已经离开或断开连接)。 **示例** ```xml 4096 ``` -## listen_host {#listen_host} +## listen_host {#listen_host} -请求可以来自的主机的限制。如果您希望服务器响应所有请求,请指定 `::`。 +限制请求可以来自的主机。如果你希望服务器回答所有请求,请指定 `::`。 示例: @@ -1452,9 +1579,9 @@ ClickHouse 企业版的许可证密钥 ::1 127.0.0.1 ``` -## listen_reuse_port {#listen_reuse_port} +## listen_reuse_port {#listen_reuse_port} -允许多个服务器在同一地址:端口上监听。请求将由操作系统随机路由到服务器。建议不要启用此设置。 +允许多个服务器监听相同的地址:端口。请求将由操作系统随机路由到一个服务器。启用此设置不推荐。 **示例** @@ -1465,7 +1592,7 @@ ClickHouse 企业版的许可证密钥 类型: 默认: -## listen_try {#listen_try} +## listen_try {#listen_try} 如果在尝试监听时 IPv6 或 IPv4 网络不可用,服务器将不会退出。 @@ -1474,77 +1601,81 @@ ClickHouse 企业版的许可证密钥 ```xml 0 ``` -## load_marks_threadpool_pool_size {#load_marks_threadpool_pool_size} +## load_marks_threadpool_pool_size {#load_marks_threadpool_pool_size} -用于标记加载的后台池的大小 -## load_marks_threadpool_queue_size {#load_marks_threadpool_queue_size} +用于加载标记的后台池大小 +## load_marks_threadpool_queue_size {#load_marks_threadpool_queue_size} -可以推入预取池的任务数 -## logger {#logger} +可以推送到预取池的任务数量 +## logger {#logger} 日志消息的位置和格式。 **键**: -| 键 | 描述 | -|-----------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `level` | 日志级别。可接受的值:`none`(关闭日志),`fatal`,`critical`,`error`,`warning`,`notice`,`information`,`debug`,`trace`,`test` | -| `log` | 日志文件的路径。 | -| `errorlog` | 错误日志文件的路径。 | -| `size` | 轮换策略:日志文件的最大大小(字节)。一旦日志文件大小超过此阈值,将被重命名并归档,并创建一个新的日志文件。 | -| `count` | 轮换策略:Clickhouse 最多保留多少个历史日志文件。 | -| `stream_compress` | 使用 LZ4 压缩日志消息。设置为 `1` 或 `true` 启用。 | -| `console` | 不将日志消息写入日志文件,而是将其打印到控制台。设置为 `1` 或 `true` 启用。如果 Clickhouse 不以守护进程模式运行,则默认值为 `1`,否则为 `0`。 | -| `console_log_level` | 控制台输出的日志级别。默认为 `level`。 | -| `formatting` | 控制台输出的日志格式。目前,仅支持 `json` | -| `use_syslog` | 还将日志输出转发到 syslog。 | -| `syslog_level` | 记录到 syslog 的日志级别。 | +| 键 | 描述 | +|------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `level` | 日志级别。可接受的值:`none`(关闭日志),`fatal`、`critical`、`error`、`warning`、`notice`、`information`、`debug`、`trace`、`test` | +| `log` | 日志文件的路径。 | +| `errorlog` | 错误日志文件的路径。 | +| `size` | 旋转策略:日志文件最大大小(以字节为单位)。一旦日志文件大小超过此阈值,它将被重命名并归档,并创建一个新的日志文件。 | +| `count` | 旋转策略:Clickhouse 最多保留多少历史日志文件。 | +| `stream_compress` | 使用 LZ4 压缩日志消息。设置为 `1` 或 `true` 以启用。 | +| `console` | 启用控制台日志记录。设置为 `1` 或 `true` 以启用。如果 Clickhouse 不以守护进程模式运行,则默认为 `1`,否则为 `0`。 | +| `console_log_level` | 控制台输出的日志级别。默认为 `level`。 | +| `formatting.type` | 控制台输出的日志格式。目前仅支持 `json` | +| `use_syslog` | 也将日志输出转发到 syslog。 | +| `syslog_level` | 发送到 syslog 的日志级别。 | +| `async` | 当设置为 `true`(默认)时,日志将异步发生(每个输出通道一个后台线程)。否则,它将在调用 LOG 的线程内记录 | +| `async_queue_max_size` | 使用异步日志时,等待刷新的最大消息数。额外消息将被丢弃 | +| `startup_level` | 启动级别用于在服务器启动时设置根记录器级别。启动后,日志级别将恢复为 `level` 设置 | +| `shutdown_level` | 关闭级别用于在服务器关闭时设置根记录器级别。 | **日志格式说明符** -`log` 和 `errorLog` 路径中的文件名支持以下格式说明符以生成文件名(目录部分不支持它们)。 - -“示例”列显示输出在 `2023-07-06 18:32:07` 的结果。 - -| 说明符 | 描述 | 示例 | -|-------------|---------------------------------------------------------------------------------------------------------------------|-------------------------| -| `%%` | 字面百分号 | `%` | -| `%n` | 新行字符 | | -| `%t` | 水平制表符 | | -| `%Y` | 年,以十进制数表示,例如 2017 | `2023` | -| `%y` | 年的最后两位数字(范围 [00,99]) | `23` | -| `%C` | 年的前两位数字(范围 [00,99]) | `20` | -| `%G` | 四位数 [ISO 8601 基于周的年份](https://en.wikipedia.org/wiki/ISO_8601#Week_dates),即包含指定周的年份。通常仅与 `%V` 一起使用 | `2023` | -| `%g` | 最后两位 [ISO 8601 基于周的年份](https://en.wikipedia.org/wiki/ISO_8601#Week_dates),即包含指定周的年份。 | `23` | -| `%b` | 缩写月份名称,例如 Oct(依赖于区域设置) | `Jul` | -| `%h` | %b 的同义词 | `Jul` | -| `%B` | 完整的月份名称,例如 October(依赖于区域设置) | `July` | -| `%m` | 月份,以十进制数表示(范围 [01,12]) | `07` | -| `%U` | 一年中的周,以十进制数字表示(周日为一周的第一天)(范围 [00,53]) | `27` | -| `%W` | 一年中的周,以十进制数字表示(周一为一周的第一天)(范围 [00,53]) | `27` | -| `%V` | ISO 8601 周数(范围 [01,53]) | `27` | -| `%j` | 一年中的天数,以十进制数字表示(范围 [001,366]) | `187` | -| `%d` | 月中的天数,以零填充的十进制数字表示(范围 [01,31])。单个数字前加零。 | `06` | -| `%e` | 月中的天数,以空格填充的十进制数字表示(范围 [1,31])。单个数字前加空格。 | `  6` | -| `%a` | 缩写的星期名,例如 Fri(依赖于区域设置) | `Thu` | -| `%A` | 完整的星期名,例如 Friday(依赖于区域设置) | `Thursday` | -| `%w` | 星期几的整数,周日为 0(范围 [0-6]) | `4` | -| `%u` | 星期几的十进制数字,周一为 1(ISO 8601 格式)(范围 [1-7]) | `4` | -| `%H` | 24 小时制的小时数,以十进制数字表示(范围 [00-23]) | `18` | -| `%I` | 12 小时制的小时数,以十进制数字表示(范围 [01,12]) | `06` | -| `%M` | 分钟数,以十进制数字表示(范围 [00,59]) | `32` | -| `%S` | 秒数,以十进制数字表示(范围 [00,60]) | `07` | -| `%c` | 标准日期和时间字符串,例如 Sun Oct 17 04:41:13 2010(依赖于区域设置) | `Thu Jul 6 18:32:07 2023` | -| `%x` | 本地化日期表示(依赖于区域设置) | `07/06/23` | -| `%X` | 本地化时间表示,例如 18:40:20 或 6:40:20 PM(依赖于区域设置) | `18:32:07` | -| `%D` | 短格式 MM/DD/YY 日期,相当于 %m/%d/%y | `07/06/23` | -| `%F` | 短格式 YYYY-MM-DD 日期,相当于 %Y-%m-%d | `2023-07-06` | -| `%r` | 本地化的 12 小时制时间(依赖于区域设置) | `06:32:07 PM` | -| `%R` | 相当于 "%H:%M" | `18:32` | -| `%T` | 相当于 "%H:%M:%S"(ISO 8601 时间格式) | `18:32:07` | -| `%p` | 本地化的 a.m. 或 p.m. 表示(依赖于区域设置) | `PM` | -| `%z` | 以 ISO 8601 格式的 UTC 偏移(例如 -0430),或者如果没有时区信息,则没有字符 | `+0800` | -| `%Z` | 依赖于区域设置的时区名称或缩写,或者如果没有时区信息,则没有字符 | `Z AWST ` | +`log` 和 `errorLog` 路径中的文件名支持以下格式说明符,用于生成的文件名(目录部分不支持它们)。 + +“示例” 列显示 `2023-07-06 18:32:07` 的输出。 + +| 说明符 | 描述 | 示例 | +|-----------|--------------------------------------------------------------------------------------------------------|------------------------| +| `%%` | 字面 % | `%` | +| `%n` | 新行字符 | | +| `%t` | 水平制表符 | | +| `%Y` | 四位数年份,以十进制数字表示,例如 2017 | `2023` | +| `%y` | 年份的最后两位数字,以十进制数字表示(范围 [00,99]) | `23` | +| `%C` | 年份的前两位数字,以十进制数字表示(范围 [00,99]) | `20` | +| `%G` | 四位数 [ISO 8601 周为基础的年份](https://en.wikipedia.org/wiki/ISO_8601#Week_dates),即包含指定周的年份。通常仅在与 `%V` 一起使用时有用 | `2023` | +| `%g` | 年份的最后两位数字的 [ISO 8601 周为基准的年份](https://en.wikipedia.org/wiki/ISO_8601#Week_dates),即包含指定周的年份。 | `23` | +| `%b` | 缩写的月份名称,例如 Oct(与区域设定相关) | `Jul` | +| `%h` | %b 的同义词 | `Jul` | +| `%B` | 完整的月份名称,例如 October(与区域设定有关) | `July` | +| `%m` | 以十进制数字表示的月份(范围 [01,12]) | `07` | +| `%U` | 以十进制数字表示的年份周(星期天是周的第一天)(范围 [00,53]) | `27` | +| `%W` | 以十进制数字表示的年份周(星期一是周的第一天)(范围 [00,53]) | `27` | +| `%V` | ISO 8601 周号(范围 [01,53]) | `27` | +| `%j` | 以十进制数字表示的年份中的天数(范围 [001,366]) | `187` | +| `%d` | 以零填充的十进制数字表示的月份中的天数(范围 [01,31])。单个数字前面填充零。 | `06` | +| `%e` | 以空格填充的十进制数字表示的月份中的天数(范围 [1,31])。单个数字前面填充空格。 | `  6` | +| `%a` | 缩写的星期几名称,例如 Fri(与区域设定相关) | `Thu` | +| `%A` | 完整的星期几名称,例如 Friday(与区域设定相关) | `Thursday` | +| `%w` | 星期几作为整数,其中星期天为 0(范围 [0-6]) | `4` | +| `%u` | 星期几作为十进制数字,其中星期一为 1(ISO 8601 格式)(范围 [1-7]) | `4` | +| `%H` | 以十进制数字表示的小时,24 小时制(范围 [00-23]) | `18` | +| `%I` | 以十进制数字表示的小时,12 小时制(范围 [01,12]) | `06` | +| `%M` | 以十进制数字表示的分钟(范围 [00,59]) | `32` | +| `%S` | 以十进制数字表示的秒数(范围 [00,60]) | `07` | +| `%c` | 标准日期和时间字符串,例如 Sun Oct 17 04:41:13 2010(与区域设定相关) | `Thu Jul 6 18:32:07 2023` | +| `%x` | 本地化日期表示(与区域设定相关) | `07/06/23` | +| `%X` | 本地化时间表示,例如 18:40:20 或 6:40:20 PM(与区域设定相关) | `18:32:07` | +| `%D` | 短格式 MM/DD/YY 日期,相当于 %m/%d/%y | `07/06/23` | +| `%F` | 短格式 YYYY-MM-DD 日期,相当于 %Y-%m-%d | `2023-07-06` | +| `%r` | 本地化的 12 小时制时间(与区域设定相关) | `06:32:07 PM` | +| `%R` | 等同于 "%H:%M" | `18:32` | +| `%T` | 等同于 "%H:%M:%S"(ISO 8601 时间格式) | `18:32:07` | +| `%p` | 本地化的上午或下午标识(与区域设定相关) | `PM` | +| `%z` | ISO 8601 格式的 UTC 偏移(例如 -0430),或如果未提供时区信息则不显示字符 | `+0800` | +| `%Z` | 与区域相关的时区名称或缩写,如果时区信息不可用则不显示字符 | `Z AWST` | **示例** @@ -1559,7 +1690,7 @@ ClickHouse 企业版的许可证密钥 ``` -仅在控制台中打印日志消息: +要仅在控制台打印日志消息: ```xml @@ -1570,7 +1701,7 @@ ClickHouse 企业版的许可证密钥 **每级覆盖** -可以覆盖单个日志名称的日志级别。例如,要静音所有 "Backup" 和 "RBAC" 日志记录器的消息。 +个别日志名称的日志级别可以被覆盖。例如,要静音所有 "Backup" 和 "RBAC" 日志记录器的消息。 ```xml @@ -1589,7 +1720,7 @@ ClickHouse 企业版的许可证密钥 **syslog** -另外写入日志消息到 syslog: +要将日志消息额外写入 syslog: ```xml @@ -1605,20 +1736,20 @@ ClickHouse 企业版的许可证密钥 `` 的键: -| 键 | 描述 | -|------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `address` | syslog 的地址,格式为 `host\[:port\]`。如果省略,则使用本地守护程序。 | -| `hostname` | 发送日志的主机名称(可选)。 | -| `facility` | syslog [设施关键字](https://en.wikipedia.org/wiki/Syslog#Facility)。必须以大写字母表示,并以 "LOG_" 前缀开头,例如 `LOG_USER`,`LOG_DAEMON`,`LOG_LOCAL3` 等。如果指定了 `address`,则默认为 `LOG_USER`,否则为 `LOG_DAEMON`。 | -| `format` | 日志消息格式。可能的值有:`bsd` 和 `syslog`。 | +| 键 | 描述 | +|--------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `address` | syslog 的地址,格式为 `host\[:port\]`。如果省略,则使用本地守护进程。 | +| `hostname` | 发送日志的主机名称(可选)。 | +| `facility` | syslog [设施关键字](https://en.wikipedia.org/wiki/Syslog#Facility)。必须大写并以 "LOG_" 前缀开头,例如 `LOG_USER`、`LOG_DAEMON`、`LOG_LOCAL3` 等。如果指定了 `address`,默认值为 `LOG_USER`,否则为 `LOG_DAEMON`。 | +| `format` | 日志消息格式。可能的值:`bsd` 和 `syslog.` | **日志格式** -可以指定将在控制台日志中输出的日志格式。目前,只支持 JSON。 +可以指定将在控制台日志中输出的日志格式。目前,仅支持 JSON。 **示例** -这是输出 JSON 日志的示例: +以下是 JSON 日志的输出示例: ```json { @@ -1641,6 +1772,8 @@ ClickHouse 企业版的许可证密钥 json + + date_time thread_name @@ -1658,175 +1791,186 @@ ClickHouse 企业版的许可证密钥 **重命名 JSON 日志的键** -可以通过更改 `` 标签内的标签值来修改键名称。例如,要将 `DATE_TIME` 更改为 `MY_DATE_TIME`,可以使用 `MY_DATE_TIME`。 +可以通过更改 `` 标签内的标签值来修改键名称。例如,要将 `DATE_TIME` 改为 `MY_DATE_TIME`,可以使用 `MY_DATE_TIME`。 **省略 JSON 日志的键** -可以通过注释掉属性来省略日志属性。例如,如果您不希望日志打印 `query_id`,可以注释掉 `` 标签。 -## macros {#macros} +可以通过注释掉属性来省略日志属性。例如,如果不希望日志打印 `query_id`,可以注释掉 `` 标签。 +## macros {#macros} -复制表的参数替换。 +用于复制表的参数替代。 -如果不使用复制表,可以省略。 +如果不使用复制表,则可以省略。 -有关更多信息,请参见[创建复制表](../../engines/table-engines/mergetree-family/replication.md#creating-replicated-tables)部分。 +有关更多信息,请参见 [创建复制表](../../engines/table-engines/mergetree-family/replication.md#creating-replicated-tables) 部分。 **示例** ```xml ``` -## mark_cache_policy {#mark_cache_policy} +## mark_cache_policy {#mark_cache_policy} 标记缓存策略名称。 -## mark_cache_prewarm_ratio {#mark_cache_prewarm_ratio} +## mark_cache_prewarm_ratio {#mark_cache_prewarm_ratio} -在预热期间填充的标记缓存总大小的比例。 -## mark_cache_size {#mark_cache_size} +在预热过程中填充标记缓存的总大小比例。 +## mark_cache_size {#mark_cache_size} -标记缓存的最大大小(`MergeTree`家族表的索引)。 +标记缓存的最大大小(`MergeTree`(/engines/table-engines/mergetree-family) 家族的索引)。 :::note 此设置可以在运行时修改,并将立即生效。 ::: -## mark_cache_size_ratio {#mark_cache_size_ratio} +## mark_cache_size_ratio {#mark_cache_size_ratio} -标记缓存中受保护队列的大小(在 SLRU 策略下)相对于缓存的总大小。 -## max_active_parts_loading_thread_pool_size {#max_active_parts_loading_thread_pool_size} +标记缓存中受保护队列的大小(在 SLRU 策略的情况下),相对于缓存的总大小。 +## max_active_parts_loading_thread_pool_size {#max_active_parts_loading_thread_pool_size} -启动时加载活动数据部分(活动的)集合的线程数。 -## max_authentication_methods_per_user {#max_authentication_methods_per_user} +为启动时加载活动数据部分集(活动部分)所使用的线程数。 +## max_authentication_methods_per_user {#max_authentication_methods_per_user} -用户可以创建或更改的最大身份验证方法数量。 -更改此设置不会影响现有用户。如果创建/更改身份验证相关的查询超出此设置中指定的限制,则会失败。 -非身份验证创建/更改查询将成功。 +可以创建或修改为的用户的最大身份验证方法数。 +更改此设置不会影响现有用户。如果超出此设置所指定的限制,将导致与身份验证相关的创建/修改查询失败。 +非身份验证的创建/修改查询将成功。 :::note 值为 `0` 表示无限制。 ::: -## max_backup_bandwidth_for_server {#max_backup_bandwidth_for_server} +## max_backup_bandwidth_for_server {#max_backup_bandwidth_for_server} -服务器上所有备份的最大读取速度(以字节每秒为单位)。零表示无限制。 -## max_backups_io_thread_pool_free_size {#max_backups_io_thread_pool_free_size} +服务器上所有备份的最大读取速度(以字节每秒计)。零表示无限制。 +## max_backups_io_thread_pool_free_size {#max_backups_io_thread_pool_free_size} -如果备份 IO 线程池中 **空闲** 线程的数量超过 `max_backup_io_thread_pool_free_size`,ClickHouse 将释放空闲线程占用的资源,并减少池的大小。如果必要,可以再次创建线程。 -## max_backups_io_thread_pool_size {#max_backups_io_thread_pool_size} +如果备份 IO 线程池中 **闲置** 线程的数量超过 `max_backup_io_thread_pool_free_size`,ClickHouse 将释放被闲置线程占用的资源并减少池大小。如果需要,可以再次创建线程。 +## max_backups_io_thread_pool_size {#max_backups_io_thread_pool_size} -ClickHouse 使用备份 IO 线程池中的线程执行 S3 备份 IO 操作。`max_backups_io_thread_pool_size` 限制池中的最大线程数量。 -## max_build_vector_similarity_index_thread_pool_size {#max_build_vector_similarity_index_thread_pool_size} +ClickHouse 使用备份 IO 线程池中的线程进行 S3 备份 IO 操作。`max_backups_io_thread_pool_size` 限制池中的最大线程数。 +## max_build_vector_similarity_index_thread_pool_size {#max_build_vector_similarity_index_thread_pool_size} -用于构建向量索引的最大线程数量。 +用于构建向量索引的最大线程数。 :::note -值为 `0` 表示使用所有核心。 +值为 `0` 表示所有核心。 ::: -## max_concurrent_insert_queries {#max_concurrent_insert_queries} +## max_concurrent_insert_queries {#max_concurrent_insert_queries} -限制同时插入查询的总数量。 +并发插入查询的总数限制。 :::note - -值为 `0`(默认值)表示无限制。 +值为 `0`(默认)表示无限制。 此设置可以在运行时修改,并将立即生效。已经在运行的查询将保持不变。 ::: -## max_concurrent_queries {#max_concurrent_queries} +## max_concurrent_queries {#max_concurrent_queries} -限制同时执行查询的总数量。请注意,还必须考虑对 `INSERT` 和 `SELECT` 查询的限制,以及用户的最大查询数量。 +并发执行查询的总数限制。请注意,`INSERT` 和 `SELECT` 查询的限制,以及用户的最大查询数也必须考虑。 -另见: +另请参见: - [`max_concurrent_insert_queries`](/operations/server-configuration-parameters/settings#max_concurrent_insert_queries) - [`max_concurrent_select_queries`](/operations/server-configuration-parameters/settings#max_concurrent_select_queries) - [`max_concurrent_queries_for_all_users`](/operations/settings/settings#max_concurrent_queries_for_all_users) :::note - -值为 `0`(默认值)表示无限制。 +值为 `0`(默认)表示无限制。 此设置可以在运行时修改,并将立即生效。已经在运行的查询将保持不变。 ::: -## max_concurrent_select_queries {#max_concurrent_select_queries} +## max_concurrent_select_queries {#max_concurrent_select_queries} -限制同时执行的选择查询的总数量。 +并发选择查询的总数限制。 :::note - -值为 `0`(默认值)表示无限制。 +值为 `0`(默认)表示无限制。 此设置可以在运行时修改,并将立即生效。已经在运行的查询将保持不变。 ::: -## max_connections {#max_connections} +## max_connections {#max_connections} 最大服务器连接数。 -## max_database_num_to_throw {#max_database_num_to_throw} +## max_database_num_to_throw {#max_database_num_to_throw} -如果数据库数量大于此值,服务器将引发异常。值为 0 表示无限制。 -## max_database_num_to_warn {#max_database_num_to_warn} +如果数据库数量大于此值,服务器将抛出异常。0 表示没有限制。 +## max_database_num_to_warn {#max_database_num_to_warn} -如果附加的数据库数量超过指定值,ClickHouse 服务器将向 `system.warnings` 表添加警告信息。 +如果附加的数据库数量超过指定值,ClickHouse 服务器将向 `system.warnings` 表添加警告消息。 **示例** ```xml 50 ``` -## max_database_replicated_create_table_thread_pool_size {#max_database_replicated_create_table_thread_pool_size} +## max_database_replicated_create_table_thread_pool_size {#max_database_replicated_create_table_thread_pool_size} -在 DatabaseReplicated 中恢复副本时创建表的线程数量。零表示线程的数量等于核心的数量。 -## max_dictionary_num_to_throw {#max_dictionary_num_to_throw} +在 DatabaseReplicated 中进行副本恢复时创建表的线程数。零表示线程数等于核心数量。 +## max_dictionary_num_to_throw {#max_dictionary_num_to_throw} -如果字典的数量超过此值,服务器将引发异常。 +如果字典的数量超过此值,服务器将抛出异常。 -仅计算数据库引擎的表: +仅统计数据库引擎的表: - Atomic - Ordinary - Replicated - Lazy :::note -值为 `0` 表示无限制。 +值为 `0` 表示没有限制。 ::: **示例** + ```xml 400 ``` -## max_dictionary_num_to_warn {#max_dictionary_num_to_warn} +## max_dictionary_num_to_warn {#max_dictionary_num_to_warn} -如果附加的字典数量超过指定值,ClickHouse 服务器将向 `system.warnings` 表添加警告信息。 +如果附加的字典数量超过指定值,ClickHouse 服务器将向 `system.warnings` 表添加警告消息。 **示例** ```xml 400 ``` -## max_entries_for_hash_table_stats {#max_entries_for_hash_table_stats} +## max_distributed_cache_read_bandwidth_for_server {#max_distributed_cache_read_bandwidth_for_server} + +服务器从分布式缓存读取的最大总速度(以字节每秒计)。零表示无限制。 +## max_distributed_cache_write_bandwidth_for_server {#max_distributed_cache_write_bandwidth_for_server} -在聚合期间收集的哈希表统计信息所允许的条目数量 +服务器向分布式缓存写入的最大总速度(以字节每秒计)。零表示无限制。 +## max_entries_for_hash_table_stats {#max_entries_for_hash_table_stats} + +允许在聚合期间收集的哈希表统计信息的条目数量。 ## max_fetch_partition_thread_pool_size {#max_fetch_partition_thread_pool_size} -用于 ALTER TABLE FETCH PARTITION 的线程数量。 +ALTER TABLE FETCH PARTITION 的线程数。 +## max_format_parsing_thread_pool_free_size {#max_format_parsing_thread_pool_free_size} + + +保持在解析输入的线程池中等待的最大闲置线程数。 +## max_format_parsing_thread_pool_size {#max_format_parsing_thread_pool_size} + + +用于解析输入的最大线程总数。 ## max_io_thread_pool_free_size {#max_io_thread_pool_free_size} -如果 IO 线程池中的 **空闲** 线程数量超过 `max_io_thread_pool_free_size`,ClickHouse 将释放空闲线程占用的资源,并减少池的大小。如果必要,可以再次创建线程。 +如果 IO 线程池中的 **闲置** 线程数超过 `max_io_thread_pool_free_size`,ClickHouse 将释放被闲置线程占用的资源并减少池的大小。如果必要,可以再次创建线程。 ## max_io_thread_pool_size {#max_io_thread_pool_size} -ClickHouse 使用 IO 线程池中的线程执行某些 IO 操作(例如,与 S3 交互)。`max_io_thread_pool_size` 限制池中的最大线程数量。 +ClickHouse 使用 IO 线程池中的线程来执行一些 IO 操作(例如,与 S3 交互)。`max_io_thread_pool_size` 限制池中的最大线程数。 ## max_keep_alive_requests {#max_keep_alive_requests} - -通过单个保持活动连接处理的请求的最大数量,直到 ClickHouse 服务器关闭该连接。 +通过单个持久连接的最大请求数,直到 ClickHouse 服务器将其关闭。 **示例** @@ -1836,39 +1980,62 @@ ClickHouse 使用 IO 线程池中的线程执行某些 IO 操作(例如,与 ## max_local_read_bandwidth_for_server {#max_local_read_bandwidth_for_server} -本地读取的最大速度,以字节每秒为单位。 +本地读取的最大速度,以字节/秒为单位。 :::note -值为 `0` 表示无限制。 +值为 `0` 意味着无限制。 ::: ## max_local_write_bandwidth_for_server {#max_local_write_bandwidth_for_server} -本地写入的最大速度,以字节每秒为单位。 +本地写入的最大速度,以字节/秒为单位。 :::note -值为 `0` 表示无限制。 +值为 `0` 意味着无限制。 ::: ## max_materialized_views_count_for_table {#max_materialized_views_count_for_table} -附加到表上的物化视图数量的限制。 +附加到表的物化视图数量的限制。 :::note -这里只考虑直接依赖的视图,而在一个视图上创建另一个视图不在此考虑之内。 +这里只考虑直接依赖的视图,创建一个视图的基础上另一个视图不在此统计内。 ::: ## max_merges_bandwidth_for_server {#max_merges_bandwidth_for_server} -服务器上所有合并的最大读取速度,以字节每秒为单位。值为零表示无限制。 +服务器上所有合并操作的最大读取速度,以字节/秒为单位。零表示无限制。 ## max_mutations_bandwidth_for_server {#max_mutations_bandwidth_for_server} -服务器上所有变更的最大读取速度,以字节每秒为单位。值为零表示无限制。 +服务器上所有变更操作的最大读取速度,以字节/秒为单位。零表示无限制。 +## max_named_collection_num_to_throw {#max_named_collection_num_to_throw} + + +如果命名集合的数量超过此值,服务器将抛出异常。 + +:::note +值为 `0` 意味着没有限制。 +::: + +**示例** +```xml +400 +``` +## max_named_collection_num_to_warn {#max_named_collection_num_to_warn} + + +如果命名集合的数量超过指定的值,ClickHouse 服务器将在 `system.warnings` 表中添加警告消息。 + +**示例** + +```xml +400 +``` ## max_open_files {#max_open_files} 打开文件的最大数量。 :::note -我们建议在 macOS 中使用此选项,因为 `getrlimit()` 函数返回了不正确的值。 +我们建议在 macOS 上使用此选项,因为 `getrlimit()` 函数返回的值不正确。 ::: **示例** @@ -1879,15 +2046,15 @@ ClickHouse 使用 IO 线程池中的线程执行某些 IO 操作(例如,与 ## max_os_cpu_wait_time_ratio_to_drop_connection {#max_os_cpu_wait_time_ratio_to_drop_connection} -考虑丢弃连接的操作系统 CPU 等待(OSCPUWaitMicroseconds 指标)和繁忙(OSCPUVirtualTimeMicroseconds 指标)时间之间的最大比率。使用最小和最大比率之间的线性插值来计算概率,该概率在此点上为 1。 -有关详细信息,请参见 [控制服务器 CPU 超负载的行为](/operations/settings/server-overload)。 +考虑到丢弃连接的最大操作系统 CPU 等待 (OSCPUWaitMicroseconds 指标) 与繁忙 (OSCPUVirtualTimeMicroseconds 指标) 的比率。使用最小和最大比率之间的线性插值来计算概率,此时概率为 1。 +有关更多详细信息,请参见 [在服务器 CPU 超载时控制行为](/operations/settings/server-overload)。 ## max_outdated_parts_loading_thread_pool_size {#max_outdated_parts_loading_thread_pool_size} -启动时用于加载非活动数据部分(过时部分)的线程数量。 +在启动时加载非活动数据部分(过时部分)的线程数。 ## max_part_num_to_warn {#max_part_num_to_warn} -如果活动部分的数量超过指定值,clickhouse 服务器将向 `system.warnings` 表中添加警告消息。 +如果活动部分的数量超过指定的值,ClickHouse 服务器将在 `system.warnings` 表中添加警告消息。 **示例** @@ -1899,13 +2066,13 @@ ClickHouse 使用 IO 线程池中的线程执行某些 IO 操作(例如,与 删除分区的限制。 -如果 [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) 表的大小超过 [`max_partition_size_to_drop`](#max_partition_size_to_drop) (以字节为单位),则无法通过 [DROP PARTITION](../../sql-reference/statements/alter/partition.md#drop-partitionpart) 查询删除分区。 -此设置不需要重新启动 ClickHouse 服务器即可应用。禁用限制的另一种方法是创建 `/flags/force_drop_table` 文件。 +如果 [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) 表的大小超过 [`max_partition_size_to_drop`](#max_partition_size_to_drop) (以字节为单位),则无法使用 [DROP PARTITION](../../sql-reference/statements/alter/partition.md#drop-partitionpart) 查询来删除分区。 +此设置不要求重启 ClickHouse 服务器即可生效。另一种禁用限制的方法是创建 `/flags/force_drop_table` 文件。 :::note -值为 `0` 表示可以无限制地删除分区。 +值为 `0` 意味着可以不受任何限制地删除分区。 -此限制不限制删除表和截断表,请参见 [max_table_size_to_drop](/operations/settings/settings#max_table_size_to_drop) +此限制不限制删除表和截断表,详见 [max_table_size_to_drop](/operations/settings/settings#max_table_size_to_drop) ::: **示例** @@ -1915,11 +2082,11 @@ ClickHouse 使用 IO 线程池中的线程执行某些 IO 操作(例如,与 ``` ## max_parts_cleaning_thread_pool_size {#max_parts_cleaning_thread_pool_size} -用于同时删除非活动数据部分的线程数量。 +用于并发移除非活动数据部分的线程数。 ## max_pending_mutations_execution_time_to_warn {#max_pending_mutations_execution_time_to_warn} -如果任何待处理的变更超过指定值(以秒为单位),clickhouse 服务器将向 `system.warnings` 表中添加警告消息。 +如果任何待处理的变更超过指定的秒数,ClickHouse 服务器将在 `system.warnings` 表中添加警告消息。 **示例** @@ -1929,7 +2096,7 @@ ClickHouse 使用 IO 线程池中的线程执行某些 IO 操作(例如,与 ## max_pending_mutations_to_warn {#max_pending_mutations_to_warn} -如果待处理变更的数量超过指定值,clickhouse 服务器将向 `system.warnings` 表中添加警告消息。 +如果待处理的变更数量超过指定的值,ClickHouse 服务器将在 `system.warnings` 表中添加警告消息。 **示例** @@ -1939,46 +2106,46 @@ ClickHouse 使用 IO 线程池中的线程执行某些 IO 操作(例如,与 ## max_prefixes_deserialization_thread_pool_free_size {#max_prefixes_deserialization_thread_pool_free_size} -如果前缀反序列化线程池中的 **空闲** 线程数量超过 `max_prefixes_deserialization_thread_pool_free_size` , ClickHouse 将释放占用空闲线程的资源并减少池大小。如有必要,可以重新创建线程。 +如果前缀反序列化线程池中的 **闲置** 线程数量超过 `max_prefixes_deserialization_thread_pool_free_size`,ClickHouse 将释放被闲置线程占用的资源并减少池的大小。如果必要,可以再次创建线程。 ## max_prefixes_deserialization_thread_pool_size {#max_prefixes_deserialization_thread_pool_size} -ClickHouse 使用来自前缀反序列化线程池的线程以并行方式读取 MergeTree 中宽部分文件前缀的列和子列的元数据。 `max_prefixes_deserialization_thread_pool_size` 限制池中的最大线程数量。 +ClickHouse 使用来自前缀反序列化线程池的线程来并行读取 MergeTree 中的列和子列的文件前缀的元数据。`max_prefixes_deserialization_thread_pool_size` 限制池中的最大线程数量。 ## max_remote_read_network_bandwidth_for_server {#max_remote_read_network_bandwidth_for_server} -读取时,通过网络交换数据的最大速度,以字节每秒为单位。 +读取时通过网络的数据交换最大速度,以字节/秒为单位。 :::note -值为 `0` (默认)表示无限制。 +值为 `0`(默认)意味着没有限制。 ::: ## max_remote_write_network_bandwidth_for_server {#max_remote_write_network_bandwidth_for_server} -写入时,通过网络交换数据的最大速度,以字节每秒为单位。 +写入时通过网络的数据交换最大速度,以字节/秒为单位。 :::note -值为 `0` (默认)表示无限制。 +值为 `0`(默认)意味着没有限制。 ::: ## max_replicated_fetches_network_bandwidth_for_server {#max_replicated_fetches_network_bandwidth_for_server} -通过网络交换数据的最大速度,以字节每秒为单位,用于复制获取。值为零表示无限制。 +通过网络的数据交换最大速度,以字节/秒为单位用于复制抓取。零表示没有限制。 ## max_replicated_sends_network_bandwidth_for_server {#max_replicated_sends_network_bandwidth_for_server} -通过网络交换数据的最大速度,以字节每秒为单位,用于复制发送。值为零表示无限制。 +通过网络的数据交换最大速度,以字节/秒为单位用于复制发送。零表示没有限制。 ## max_replicated_table_num_to_throw {#max_replicated_table_num_to_throw} -如果复制表的数量大于此值,服务器将抛出异常。 +如果复制表的数量超过此值,服务器将抛出异常。 -仅计入数据库引擎的表: +仅计算数据库引擎的表: - Atomic - Ordinary - Replicated - Lazy :::note -值为 `0` 表示没有限制。 +值为 `0` 意味着没有限制。 ::: **示例** @@ -1991,26 +2158,26 @@ ClickHouse 使用来自前缀反序列化线程池的线程以并行方式读取 服务器允许使用的最大内存量,以字节为单位。 :::note -服务器的最大内存消耗受到 `max_server_memory_usage_to_ram_ratio` 设置的进一步限制。 +服务器的最大内存消耗还受到 `max_server_memory_usage_to_ram_ratio` 设置的限制。 ::: -作为特例,值为 `0` (默认)表示服务器可以使用所有可用内存(不包括 `max_server_memory_usage_to_ram_ratio` 强加的进一步限制)。 +作为特例,值为 `0`(默认)意味着服务器可以使用所有可用内存(不包括 `max_server_memory_usage_to_ram_ratio` 所施加的进一步限制)。 ## max_server_memory_usage_to_ram_ratio {#max_server_memory_usage_to_ram_ratio} -服务器允许使用的最大内存量,以所有可用内存的比例表示。 +服务器允许使用的最大内存量,以相对于所有可用内存的比例表示。 -例如,值为 `0.9` (默认)表示服务器可以使用 90% 的可用内存。 +例如,值为 `0.9`(默认)意味着服务器可以使用可用内存的 90%。 -允许在低内存系统上降低内存使用。 -在内存和交换空间有限的主机上,可能需要将 [`max_server_memory_usage_to_ram_ratio`](#max_server_memory_usage_to_ram_ratio) 设置大于 1。 +允许在低内存系统上降低内存使用量。 +在 RAM 和交换空间较少的主机上,您可能需要将 [`max_server_memory_usage_to_ram_ratio`](#max_server_memory_usage_to_ram_ratio) 设置为大于 1。 :::note -服务器的最大内存消耗受到 `max_server_memory_usage` 设置的进一步限制。 +服务器的最大内存消耗还受到 `max_server_memory_usage` 设置的限制。 ::: ## max_session_timeout {#max_session_timeout} -最大会话超时时间,以秒为单位。 +最大会话超时,以秒为单位。 示例: @@ -2020,7 +2187,7 @@ ClickHouse 使用来自前缀反序列化线程池的线程以并行方式读取 ## max_table_num_to_throw {#max_table_num_to_throw} -如果表的数量大于此值,服务器将抛出异常。 +如果表的数量超过此值,服务器将抛出异常。 以下表不计入: - view @@ -2028,14 +2195,14 @@ ClickHouse 使用来自前缀反序列化线程池的线程以并行方式读取 - dictionary - system -仅计入数据库引擎的表: +仅计算数据库引擎的表: - Atomic - Ordinary - Replicated - Lazy :::note -值为 `0` 表示没有限制。 +值为 `0` 意味着没有限制。 ::: **示例** @@ -2045,7 +2212,7 @@ ClickHouse 使用来自前缀反序列化线程池的线程以并行方式读取 ## max_table_num_to_warn {#max_table_num_to_warn} -如果附加的表数量超过指定值,clickhouse 服务器将向 `system.warnings` 表中添加警告消息。 +如果附加的表数量超过指定的值,ClickHouse 服务器将在 `system.warnings` 表中添加警告消息。 **示例** @@ -2057,12 +2224,12 @@ ClickHouse 使用来自前缀反序列化线程池的线程以并行方式读取 删除表的限制。 -如果 [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) 表的大小超过 `max_table_size_to_drop` (以字节为单位),则无法通过 [`DROP`](../../sql-reference/statements/drop.md) 查询或 [`TRUNCATE`](../../sql-reference/statements/truncate.md) 查询删除它。 +如果 [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) 表的大小超过 `max_table_size_to_drop` (以字节为单位),则无法使用 [`DROP`](../../sql-reference/statements/drop.md) 查询或 [`TRUNCATE`](../../sql-reference/statements/truncate.md) 查询来删除它。 :::note -值为 `0` 表示可以无限制地删除所有表。 +值为 `0` 意味着可以毫无限制地删除所有表。 -此设置不需要重新启动 ClickHouse 服务器来应用。禁用限制的另一种方法是创建 `/flags/force_drop_table` 文件。 +此设置不要求重启 ClickHouse 服务器即可生效。另一种方法是创建 `/flags/force_drop_table` 文件来禁用限制。 ::: **示例** @@ -2073,11 +2240,11 @@ ClickHouse 使用来自前缀反序列化线程池的线程以并行方式读取 ## max_temporary_data_on_disk_size {#max_temporary_data_on_disk_size} -可用于外部聚合、连接或排序的最大存储量。 -超出此限制的查询将因异常而失败。 +可用于外部聚合、连接或排序的存储的最大量。 +超过此限制的查询将失败并抛出异常。 :::note -值为 `0` 表示无限制。 +值为 `0` 意味着无限制。 ::: 另请参见: @@ -2086,7 +2253,7 @@ ClickHouse 使用来自前缀反序列化线程池的线程以并行方式读取 ## max_thread_pool_free_size {#max_thread_pool_free_size} -如果全局线程池中的 **空闲** 线程数量大于 [`max_thread_pool_free_size`](/operations/server-configuration-parameters/settings#max_thread_pool_free_size),ClickHouse 将释放某些线程所占用的资源并减少池的大小。如有必要,可以重新创建线程。 +如果全局线程池中的 **闲置** 线程数大于 [`max_thread_pool_free_size`](/operations/server-configuration-parameters/settings#max_thread_pool_free_size),则 ClickHouse 将释放某些线程占用的资源,并减少池的大小。如果需要,可以再次创建线程。 **示例** @@ -2096,7 +2263,7 @@ ClickHouse 使用来自前缀反序列化线程池的线程以并行方式读取 ## max_thread_pool_size {#max_thread_pool_size} -ClickHouse 使用全局线程池中的线程来处理查询。如果没有空闲线程来处理查询,则在池中创建一个新线程。 `max_thread_pool_size` 限制池中的最大线程数量。 +ClickHouse 使用全局线程池中的线程来处理查询。如果没有闲置线程处理查询,则会在池中创建新线程。`max_thread_pool_size` 限制池中的最大线程数。 **示例** @@ -2105,20 +2272,20 @@ ClickHouse 使用全局线程池中的线程来处理查询。如果没有空闲 ``` ## max_unexpected_parts_loading_thread_pool_size {#max_unexpected_parts_loading_thread_pool_size} -启动时用于加载非活动数据部分(意外部分)的线程数量。 +加载非活动数据部分(意外部分)时的线程数。 ## max_view_num_to_throw {#max_view_num_to_throw} -如果视图的数量大于此值,服务器将抛出异常。 +如果视图的数量超过此值,服务器将抛出异常。 -仅计入数据库引擎的表: +仅计算数据库引擎的表: - Atomic - Ordinary - Replicated - Lazy :::note -值为 `0` 表示没有限制。 +值为 `0` 意味着没有限制。 ::: **示例** @@ -2128,7 +2295,7 @@ ClickHouse 使用全局线程池中的线程来处理查询。如果没有空闲 ## max_view_num_to_warn {#max_view_num_to_warn} -如果附加的视图数量超过指定值,clickhouse 服务器将向 `system.warnings` 表中添加警告消息。 +如果附加的视图数量超过指定的值,ClickHouse 服务器将在 `system.warnings` 表中添加警告消息。 **示例** @@ -2138,11 +2305,11 @@ ClickHouse 使用全局线程池中的线程来处理查询。如果没有空闲 ## max_waiting_queries {#max_waiting_queries} -并发等待查询的总数量限制。 -在所需的表异步加载时,等待查询的执行将被阻塞(请参见 [`async_load_databases`](/operations/server-configuration-parameters/settings#async_load_databases)。 +并发等待查询的总数限制。 +在所需表异步加载时,等待查询的执行将被阻塞(见 [`async_load_databases`](/operations/server-configuration-parameters/settings#async_load_databases)。 :::note -在检查以下设置所控制的限制时,不计算等待查询: +当检查以下设置控制的限制时,等待查询不被计入: - [`max_concurrent_queries`](/operations/server-configuration-parameters/settings#max_concurrent_queries) - [`max_concurrent_insert_queries`](/operations/server-configuration-parameters/settings#max_concurrent_insert_queries) @@ -2150,30 +2317,30 @@ ClickHouse 使用全局线程池中的线程来处理查询。如果没有空闲 - [`max_concurrent_queries_for_user`](/operations/settings/settings#max_concurrent_queries_for_user) - [`max_concurrent_queries_for_all_users`](/operations/settings/settings#max_concurrent_queries_for_all_users) -此更正是为了避免在服务器启动后立即达到这些限制。 +此修正是为了避免在服务器启动后立即达到这些限制。 ::: :::note -值为 `0` (默认)表示无限制。 +值为 `0`(默认)意味着没有限制。 -此设置可以在运行时修改,并将立即生效。已在运行的查询将保持不变。 +此设置可以在运行时进行修改,并会立即生效。已运行的查询将保持不变。 ::: ## memory_worker_correct_memory_tracker {#memory_worker_correct_memory_tracker} -背景内存工作器是否应该根据来自外部来源(如 jemalloc 和 cgroups)的信息校正内部内存跟踪器。 +后台内存工作线程是否应该根据来自外部源(如 jemalloc 和 cgroups)的信息来校正内部内存跟踪器。 ## memory_worker_period_ms {#memory_worker_period_ms} -后台内存工作器的滴答周期,该工作器根据内存使用量来修正内存跟踪器的内存使用情况并清理未使用的页面。如果设置为 0,将根据内存使用来源使用默认值。 +校正内存使用情况并在更高内存使用期间清理未使用页面的后台内存工作线程的滴答周期。如果设置为 0,将根据内存使用源使用默认值。 ## memory_worker_use_cgroup {#memory_worker_use_cgroup} -使用当前 cgroup 内存使用信息来修正内存跟踪。 +使用当前 cgroup 内存使用信息来校正内存跟踪。 ## merge_tree {#merge_tree} -[MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) 中表的细调。 +用于 [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) 表的精细调优。 -具体信息请参见 MergeTreeSettings.h 头文件。 +有关更多信息,请参阅 MergeTreeSettings.h 头文件。 **示例** @@ -2185,18 +2352,18 @@ ClickHouse 使用全局线程池中的线程来处理查询。如果没有空闲 ## merge_workload {#merge_workload} -用于调节资源在合并和其他工作负载之间的利用和共享。指定的值作为所有后台合并的 `workload` 设置值。可以被合并树设置覆盖。 +用于调节合并和其他工作负载之间资源的利用和共享。指定的值作为所有后台合并的 `workload` 设置值。可以被合并树设置覆盖。 -**另请参见** -- [工作负载调度](/operations/workload-scheduling.md) +**另请参阅** +- [Workload Scheduling](/operations/workload-scheduling.md) ## merges_mutations_memory_usage_soft_limit {#merges_mutations_memory_usage_soft_limit} -设置进行合并和变更操作允许使用的 RAM 限制。 -如果 ClickHouse 达到设定的限制,则不会安排任何新的后台合并或变更操作,但将继续执行已安排的任务。 +设置用于执行合并和变更操作的最大内存限制。 +如果 ClickHouse 达到设定的限制,将不会调度任何新的后台合并或变更操作,但会继续执行已调度的任务。 :::note -值为 `0` 表示无限制。 +值为 `0` 意味着无限制。 ::: **示例** @@ -2209,17 +2376,17 @@ ClickHouse 使用全局线程池中的线程来处理查询。如果没有空闲 默认的 `merges_mutations_memory_usage_soft_limit` 值计算为 `memory_amount * merges_mutations_memory_usage_to_ram_ratio`。 -**另请参见:** +**另请参阅:** - [max_memory_usage](/operations/settings/settings#max_memory_usage) - [merges_mutations_memory_usage_soft_limit](/operations/server-configuration-parameters/settings#merges_mutations_memory_usage_soft_limit) ## metric_log {#metric_log} -默认情况下禁用。 +默认禁用。 **启用** -要手动启用指标历史记录收集 [`system.metric_log`](../../operations/system-tables/metric_log.md),请创建 `/etc/clickhouse-server/config.d/metric_log.xml` ,内容如下: +要手动启用指标历史收集 [`system.metric_log`](../../operations/system-tables/metric_log.md),请创建 `/etc/clickhouse-server/config.d/metric_log.xml`,内容如下: ```xml @@ -2238,7 +2405,7 @@ ClickHouse 使用全局线程池中的线程来处理查询。如果没有空闲 **禁用** -要禁用 `metric_log` 设置,您应该创建以下文件 `/etc/clickhouse-server/config.d/disable_metric_log.xml`,内容如下: +要禁用 `metric_log` 设置,您应创建以下文件 `/etc/clickhouse-server/config.d/disable_metric_log.xml`,内容如下: ```xml @@ -2250,15 +2417,15 @@ ClickHouse 使用全局线程池中的线程来处理查询。如果没有空闲 ## min_os_cpu_wait_time_ratio_to_drop_connection {#min_os_cpu_wait_time_ratio_to_drop_connection} -考虑丢弃连接的操作系统 CPU 等待(OSCPUWaitMicroseconds 指标)和繁忙(OSCPUVirtualTimeMicroseconds 指标)时间之间的最小比率。使用最小和最大比率之间的线性插值来计算概率,该概率在此点上为 0。 -有关详细信息,请参见 [控制服务器 CPU 超负载的行为](/operations/settings/server-overload)。 +考虑丢弃连接的操作系统 CPU 等待 (OSCPUWaitMicroseconds 指标) 和繁忙 (OSCPUVirtualTimeMicroseconds 指标) 时间的最小比率。使用最小和最大比率之间的线性插值来计算概率,此时概率为 0。 +有关更多详细信息,请参见 [在服务器 CPU 超载时控制行为](/operations/settings/server-overload)。 ## mlock_executable {#mlock_executable} -在启动后执行 `mlockall` ,以降低首次查询的延迟并防止 clickhouse 可执行文件在高 IO 负载下被换出。 +在启动后执行 `mlockall` 以降低首次查询延迟,并防止在高 IO 负载下将 ClickHouse 可执行文件分页出。 :::note -建议启用此选项,但会导致启动时间增加至数秒。 -请记住,这个设置在没有 "CAP_IPC_LOCK" 权限的情况下不会起作用。 +建议启用此选项,但将导致启动时间增加最多几秒。 +请注意,此设置在没有 "CAP_IPC_LOCK" 能力时无法工作。 ::: **示例** @@ -2269,35 +2436,32 @@ ClickHouse 使用全局线程池中的线程来处理查询。如果没有空闲 ## mmap_cache_size {#mmap_cache_size} -设置映射文件的缓存大小(以字节为单位)。此设置可以避免频繁的打开/关闭调用(由于随后的页面错误而非常昂贵),并可以在多个线程和查询中重用映射。设置值是映射区域的数量(通常等于映射文件的数量)。 +该设置有助于避免频繁的打开/关闭调用(由于后续的缺页错误而极其耗时),并重用来自多个线程和查询的映射。设置值是映射区域的数量(通常等于映射文件的数量)。 -可以在以下系统表中监控映射文件中的数据量,并具有以下指标: +可以在以下系统表中监控映射文件中的数据量,并获取以下指标: -| 系统表 | 指标 | -|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------| -| [`system.metrics`](/operations/system-tables/metrics) 和 [`system.metric_log`](/operations/system-tables/metric_log) | `MMappedFiles` 和 `MMappedFileBytes` | -| [`system.asynchronous_metrics_log`](/operations/system-tables/asynchronous_metric_log) | `MMapCacheCells` | -| [`system.events`](/operations/system-tables/events), [`system.processes`](/operations/system-tables/processes), [`system.query_log`](/operations/system-tables/query_log), [`system.query_thread_log`](/operations/system-tables/query_thread_log), [`system.query_views_log`](/operations/system-tables/query_views_log) | `CreatedReadBufferMMap`、`CreatedReadBufferMMapFailed`、`MMappedFileCacheHits`、`MMappedFileCacheMisses` | +- `MMappedFiles`/`MMappedFileBytes`/`MMapCacheCells` 在 [`system.metrics`](/operations/system-tables/metrics),[`system.metric_log`](/operations/system-tables/metric_log) +- `CreatedReadBufferMMap`/`CreatedReadBufferMMapFailed`/`MMappedFileCacheHits`/`MMappedFileCacheMisses` 在 [`system.events`](/operations/system-tables/events),[`system.processes`](/operations/system-tables/processes),[`system.query_log`](/operations/system-tables/query_log),[`system.query_thread_log`](/operations/system-tables/query_thread_log),[`system.query_views_log`](/operations/system-tables/query_views_log) :::note -映射文件中的数据量不会直接消耗内存,并且在查询或服务器内存使用中不会被计算——因为这部分内存可以像操作系统页面缓存一样被丢弃。在 MergeTree 系列表中删除旧部分时,缓存会自动被丢弃(文件关闭),也可以通过 `SYSTEM DROP MMAP CACHE` 查询手动丢弃。 +映射文件中的数据量不会直接消耗内存且不会计入查询或服务器内存使用情况,因为这块内存可以像操作系统页面缓存那样被丢弃。该缓存会在 MergeTree 表中删除旧部分时自动丢弃(文件关闭),也可以通过 `SYSTEM DROP MMAP CACHE` 查询手动丢弃。 -此设置可以在运行时修改,并将立即生效。 +此设置可以在运行时进行修改,并会立即生效。 ::: ## mutation_workload {#mutation_workload} -用于调节资源在变更和其他工作负载之间的利用和共享。指定的值作为所有后台变更的 `workload` 设置值。可以被合并树设置覆盖。 +用于调节变更和其他工作负载之间资源的利用和共享。指定的值作为所有后台变更的 `workload` 设置值。可以被合并树设置覆盖。 -**另请参见** -- [工作负载调度](/operations/workload-scheduling.md) +**另请参阅** +- [Workload Scheduling](/operations/workload-scheduling.md) ## mysql_port {#mysql_port} -通过 MySQL 协议与客户端通信的端口。 +使用 MySQL 协议与客户端进行通信的端口。 :::note - 正整数指定要监听的端口号 -- 空值用于禁用通过 MySQL 协议与客户端的通信。 +- 空值用于禁用与客户端通过 MySQL 协议的通信。 ::: **示例** @@ -2305,36 +2469,39 @@ ClickHouse 使用全局线程池中的线程来处理查询。如果没有空闲 ```xml 9004 ``` +## mysql_require_secure_transport {#mysql_require_secure_transport} + +如果设置为 true,则需要与客户端通过 [mysql_port](#mysql_port) 进行安全通信。连接选项 `--ssl-mode=none` 将被拒绝。与 [OpenSSL](#openssl) 设置一起使用。 ## openSSL {#openssl} -SSL 客户端/服务器配置。 +SSL客户端/服务器配置。 -SSL 的支持由 `libpoco` 库提供。可用的配置选项在 [SSLManager.h](https://github.com/ClickHouse-Extras/poco/blob/master/NetSSL_OpenSSL/include/Poco/Net/SSLManager.h) 中解释。默认值可以在 [SSLManager.cpp](https://github.com/ClickHouse-Extras/poco/blob/master/NetSSL_OpenSSL/src/SSLManager.cpp) 中找到。 +支持SSL的是`libpoco`库。可用的配置选项在[SSLManager.h](https://github.com/ClickHouse-Extras/poco/blob/master/NetSSL_OpenSSL/include/Poco/Net/SSLManager.h)中进行了解释。默认值可以在[SSLManager.cpp](https://github.com/ClickHouse-Extras/poco/blob/master/NetSSL_OpenSSL/src/SSLManager.cpp)中找到。 服务器/客户端设置的密钥: -| 选项 | 描述 | 默认值 | -|-----------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------| -| `privateKeyFile` | 包含 PEM 证书的私钥文件的路径。该文件可以同时包含密钥和证书。 | | -| `certificateFile` | PEM 格式的客户端/服务器证书文件的路径。如果 `privateKeyFile` 包含证书,您可以省略此项。 | | -| `caConfig` | 包含受信任 CA 证书的文件或目录的路径。如果指向一个文件,则该文件必须是 PEM 格式,并且可以包含多个 CA 证书。如果指向一个目录,则必须为每个 CA 证书包含一个 .pem 文件。文件名根据 CA 主体名称哈希值进行查找。详细信息请参见 [SSL_CTX_load_verify_locations](https://www.openssl.org/docs/man3.0/man3/SSL_CTX_load_verify_locations.html) 的手册页。 | | -| `verificationMode` | 检查节点证书的方法。详细信息请参见 [Context](https://github.com/ClickHouse-Extras/poco/blob/master/NetSSL_OpenSSL/include/Poco/Net/Context.h) 类的描述。可能的值:`none`、`relaxed`、`strict`、`once`。 | `relaxed` | -| `verificationDepth` | 验证链的最大长度。如果证书链的长度超过设置值,验证将失败。 | `9` | -| `loadDefaultCAFile` | 是否使用OpenSSL的内置 CA 证书。ClickHouse 假设内置 CA 证书位于文件 `/etc/ssl/cert.pem`(或目录 `/etc/ssl/certs`)中,或在环境变量 `SSL_CERT_FILE`(或 `SSL_CERT_DIR`)指定的文件(或目录)中。 | `true` | -| `cipherList` | 支持的 OpenSSL 加密。 | `ALL:!ADH:!LOW:!EXP:!MD5:!3DES:@STRENGTH` | -| `cacheSessions` | 启用或禁用会话缓存。必须与 `sessionIdContext` 一起使用。可接受的值:`true`、`false`。 | `false` | -| `sessionIdContext` | 一组唯一的随机字符,服务器附加到每个生成的标识符。字符串的长度不得超过 `SSL_MAX_SSL_SESSION_ID_LENGTH`。强烈推荐使用此参数,因为它有助于避免服务器缓存会话和客户端请求缓存时出现的问题。 | `$\{application.name\}` | -| `sessionCacheSize` | 服务器缓存的最大会话数。值为 `0` 表示无限制会话。 | [1024\*20](https://github.com/ClickHouse/boringssl/blob/master/include/openssl/ssl.h#L1978) | -| `sessionTimeout` | 服务器上缓存会话的时间(小时)。 | `2` | -| `extendedVerification` | 如果启用,则验证证书 CN 或 SAN 是否与对等主机名匹配。 | `false` | -| `requireTLSv1` | 要求使用 TLSv1 连接。可接受的值:`true`、`false`。 | `false` | -| `requireTLSv1_1` | 要求使用 TLSv1.1 连接。可接受的值:`true`、`false`。 | `false` | -| `requireTLSv1_2` | 要求使用 TLSv1.2 连接。可接受的值:`true`、`false`。 | `false` | -| `fips` | 激活 OpenSSL FIPS 模式。如果库的 OpenSSL 版本支持 FIPS,将支持此模式。 | `false` | -| `privateKeyPassphraseHandler` | 请求访问私钥所需的密码短语的类(PrivateKeyPassphraseHandler 子类)。例如: ``、`KeyFileHandler`、`test`、``。 | `KeyConsoleHandler` | -| `invalidCertificateHandler` | 验证无效证书的类(CertificateHandler 的子类)。例如: ` RejectCertificateHandler ` 。 | `RejectCertificateHandler` | -| `disableProtocols` | 不允许使用的协议。 | | -| `preferServerCiphers` | 客户端首选的服务器密码。 | `false` | +| 选项 | 描述 | 默认值 | +|-------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------| +| `privateKeyFile` | 包含PEM证书的秘密密钥的文件路径。该文件可以同时包含密钥和证书。 | | +| `certificateFile` | 客户端/服务器证书文件的PEM格式路径。如果`privateKeyFile`中包含证书,则可以省略此项。 | | +| `caConfig` | 包含受信任CA证书的文件或目录路径。如果指向一个文件,则该文件必须是PEM格式,并可以包含多个CA证书。如果指向一个目录,则必须包含每个CA证书的一个.pem文件。文件名通过CA主体名称哈希值查找。详细信息可以在[SSL_CTX_load_verify_locations](https://www.openssl.org/docs/man3.0/man3/SSL_CTX_load_verify_locations.html)的手册页中找到。 | | +| `verificationMode` | 检查节点证书的方法。详细信息在[Context](https://github.com/ClickHouse-Extras/poco/blob/master/NetSSL_OpenSSL/include/Poco/Net/Context.h)类的描述中。可能的值:`none`、`relaxed`、`strict`、`once`。 | `relaxed` | +| `verificationDepth` | 验证链的最大长度。如果证书链长度超过设定值,验证将失败。 | `9` | +| `loadDefaultCAFile` | 是否使用OpenSSL的内置CA证书。ClickHouse假设内置CA证书在文件`/etc/ssl/cert.pem`(或目录`/etc/ssl/certs`)中,或者在环境变量`SSL_CERT_FILE`(或`SSL_CERT_DIR`)指定的文件(或目录)中。 | `true` | +| `cipherList` | 支持的OpenSSL加密方式。 | `ALL:!ADH:!LOW:!EXP:!MD5:!3DES:@STRENGTH` | +| `cacheSessions` | 启用或禁用会话缓存。必须与`sessionIdContext`结合使用。可接受的值:`true`、`false`。 | `false` | +| `sessionIdContext` | 服务器附加到每个生成标识符的唯一随机字符集。字符串长度不得超过`SSL_MAX_SSL_SESSION_ID_LENGTH`。此参数始终建议使用,因为它有助于避免服务器缓存会话和客户端请求缓存时出现的问题。 | `$\{application.name\}` | +| `sessionCacheSize` | 服务器缓存的最大会话数。值为`0`表示无限会话。 | [1024\*20](https://github.com/ClickHouse/boringssl/blob/master/include/openssl/ssl.h#L1978) | +| `sessionTimeout` | 在服务器上缓存会话的时间(小时)。 | `2` | +| `extendedVerification` | 如果启用,验证证书的CN或SAN是否与对等主机名匹配。 | `false` | +| `requireTLSv1` | 要求连接使用TLSv1。可接受的值:`true`、`false`。 | `false` | +| `requireTLSv1_1` | 要求连接使用TLSv1.1。可接受的值:`true`、`false`。 | `false` | +| `requireTLSv1_2` | 要求连接使用TLSv1.2。可接受的值:`true`、`false`。 | `false` | +| `fips` | 激活OpenSSL FIPS模式。如果库的OpenSSL版本支持FIPS,则受支持。 | `false` | +| `privateKeyPassphraseHandler` | 请求访问私钥的密码的类(PrivateKeyPassphraseHandler子类)。例如:``、`KeyFileHandler`、`test`、``。 | `KeyConsoleHandler` | +| `invalidCertificateHandler` | 用于验证无效证书的类(CertificateHandler的子类)。例如:` RejectCertificateHandler `。 | `RejectCertificateHandler` | +| `disableProtocols` | 不允许使用的协议。 | | +| `preferServerCiphers` | 客户端偏好的服务器加密方式。 | `false` | **设置示例:** @@ -2367,7 +2534,7 @@ SSL 的支持由 `libpoco` 库提供。可用的配置选项在 [SSLManager.h](h ``` ## opentelemetry_span_log {#opentelemetry_span_log} -[`opentelemetry_span_log`](../system-tables/opentelemetry_span_log.md) 系统表的设置。 +[`opentelemetry_span_log`](../system-tables/opentelemetry_span_log.md)系统表的设置。 @@ -2391,33 +2558,54 @@ SSL 的支持由 `libpoco` 库提供。可用的配置选项在 [SSLManager.h](h ``` ## os_cpu_busy_time_threshold {#os_cpu_busy_time_threshold} -操作系统 CPU 繁忙时间的阈值(以微秒为单位,OSCPUVirtualTimeMicroseconds 指标),用于认为 CPU 正在进行一些有用的工作,如果繁忙时间低于此值,则不会被认为 CPU 过载。 +考虑CPU在执行有用工作时,OS CPU繁忙时间(OSCPUVirtualTimeMicroseconds指标)的阈值,如果繁忙时间低于该值则不考虑CPU过载。 +## os_threads_nice_value_distributed_cache_tcp_handler {#os_threads_nice_value_distributed_cache_tcp_handler} + +分布式缓存TCP处理器的线程的Linux优先级值。较低的值意味着更高的CPU优先级。 + +需要CAP_SYS_NICE能力,否则无效。 + +可能值:-20至19。 +## os_threads_nice_value_merge_mutate {#os_threads_nice_value_merge_mutate} + +合并和变异线程的Linux优先级值。较低的值意味着更高的CPU优先级。 + +需要CAP_SYS_NICE能力,否则无效。 + +可能值:-20至19。 +## os_threads_nice_value_zookeeper_client_send_receive {#os_threads_nice_value_zookeeper_client_send_receive} + +ZooKeeper客户端中发送和接收线程的Linux优先级值。较低的值意味着更高的CPU优先级。 + +需要CAP_SYS_NICE能力,否则无效。 + +可能值:-20至19。 ## page_cache_free_memory_ratio {#page_cache_free_memory_ratio} -保持在用户空间页面缓存中空闲的内存限制的比例。类似于 Linux 的 min_free_kbytes 设置。 +从用户空间页面缓存保持空闲的内存限制的比例。类似于Linux的min_free_kbytes设置。 ## page_cache_history_window_ms {#page_cache_history_window_ms} -释放的内存可以被用户空间页面缓存使用之前的延迟。 +释放的内存可供用户空间页面缓存使用的延迟。 ## page_cache_max_size {#page_cache_max_size} -用户空间页面缓存的最大大小。设置为 0 以禁用缓存。如果大于 page_cache_min_size,缓存大小将在此范围内持续调整,以使用大部分可用内存,同时保持总内存使用低于限制(max_server_memory_usage[_to_ram_ratio])。 +用户空间页面缓存的最大大小。设置为0禁用缓存。如果大于page_cache_min_size,缓存大小将在此范围内连续调整,以使用大部分可用内存,同时保持总内存使用低于限制(max_server_memory_usage[_to_ram_ratio])。 ## page_cache_min_size {#page_cache_min_size} 用户空间页面缓存的最小大小。 ## page_cache_policy {#page_cache_policy} -用户空间页面缓存策略名称。 +用户空间页面缓存策略的名称。 ## page_cache_shards {#page_cache_shards} -在此数量分片上划分用户空间页面缓存,以减少互斥量争用。实验性质,不太可能提高性能。 +在多个分片上划分用户空间页面缓存以减少互斥锁争用。实验性,可能不会提高性能。 ## page_cache_size_ratio {#page_cache_size_ratio} -用户空间页面缓存中受保护队列的大小相对于缓存的总大小。 +用户空间页面缓存中被保护队列的大小相对于缓存的总大小。 ## part_log {#part_log} -记录与 [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) 相关的事件。例如,添加或合并数据。您可以使用日志来模拟合并算法并比较其特性。您可以可视化合并过程。 +与[MergeTree](../../engines/table-engines/mergetree-family/mergetree.md)相关的事件的日志记录。例如,添加或合并数据。您可以使用日志模拟合并算法并比较其特性。您可以可视化合并过程。 -查询记录在 [system.part_log](/operations/system-tables/part_log) 表中,而不是在单独的文件中。您可以在 `table` 参数中配置此表的名称(见下文)。 +查询记录在[system.part_log](/operations/system-tables/part_log)表中,而不是在单独的文件中。您可以在`table`参数中配置此表的名称(见下文)。 @@ -2437,16 +2625,13 @@ SSL 的支持由 `libpoco` 库提供。可用的配置选项在 [SSLManager.h](h ``` ## parts_kill_delay_period {#parts_kill_delay_period} - -用于 SharedMergeTree 完全移除部分的周期。仅在 ClickHouse Cloud 中可用。 +完全移除SharedMergeTree部件的周期。仅在ClickHouse Cloud中可用。 ## parts_kill_delay_period_random_add {#parts_kill_delay_period_random_add} - -从 0 到 x 秒均匀分布的值添加到 kill_delay_period,以避免过多请求对 ZooKeeper 造成的效应,并在表数量非常大的情况下后续出现的 DoS。仅在 ClickHouse Cloud 中可用。 +为kill_delay_period添加均匀分布的值,范围从0到x秒,以避免雷电集群效应,并且在表数量非常大时避免ZooKeeper的后续拒绝服务。仅在ClickHouse Cloud中可用。 ## parts_killer_pool_size {#parts_killer_pool_size} - -清理共享合并树过时线程的线程数。仅在 ClickHouse Cloud 中可用。 +用于清理过期共享合并树线程的线程。仅在ClickHouse Cloud中可用。 ## path {#path} 包含数据的目录的路径。 @@ -2462,11 +2647,11 @@ SSL 的支持由 `libpoco` 库提供。可用的配置选项在 [SSLManager.h](h ``` ## postgresql_port {#postgresql_port} -通过 PostgreSQL 协议与客户端通信的端口。 +通过PostgreSQL协议与客户端通信的端口。 :::note -- 正整数指定监听的端口号 -- 空值用于禁用通过 MySQL 协议与客户端通信。 +- 正整数指定要监听的端口号 +- 空值用于禁用通过PostgreSQL协议与客户端的通信。 ::: **示例** @@ -2474,41 +2659,44 @@ SSL 的支持由 `libpoco` 库提供。可用的配置选项在 [SSLManager.h](h ```xml 9005 ``` +## postgresql_require_secure_transport {#postgresql_require_secure_transport} + +如果设置为true,则要求客户端通过[postgresql_port](#postgresql_port)进行安全通信。将拒绝使用选项`sslmode=disable`的连接。与[OpenSSL](#openssl)设置一起使用。 ## prefetch_threadpool_pool_size {#prefetch_threadpool_pool_size} -用于远程对象存储的预取的后台池的大小。 +远程对象存储的预获取的后台池的大小。 ## prefetch_threadpool_queue_size {#prefetch_threadpool_queue_size} -可以推送到预取池中的任务数。 +可以推送到预获取池的任务数量。 ## prefixes_deserialization_thread_pool_thread_pool_queue_size {#prefixes_deserialization_thread_pool_thread_pool_queue_size} -可以在前缀反序列化线程池中调度的最大作业数。 +可以在前缀反序列化线程池上调度的最大作业数量。 :::note -值为 `0` 表示无限制。 +值为`0`表示无限制。 ::: ## prepare_system_log_tables_on_startup {#prepare_system_log_tables_on_startup} -如果为 true,ClickHouse 会在启动之前创建所有配置的 `system.*_log` 表。如果某些启动脚本依赖于这些表,这可能会很有帮助。 +如果为true,ClickHouse将在启动前创建所有配置的`system.*_log`表。如果一些启动脚本依赖于这些表,这可能会很有帮助。 ## primary_index_cache_policy {#primary_index_cache_policy} 主索引缓存策略名称。 ## primary_index_cache_prewarm_ratio {#primary_index_cache_prewarm_ratio} -在预热期间要填充的标记缓存的总大小的比例。 +在预热期间填充的标记缓存的总大小比例。 ## primary_index_cache_size {#primary_index_cache_size} -主索引的最大缓存大小(MergeTree 表系列的索引)。 +用于主索引的缓存的最大大小(MergeTree系列表的索引)。 ## primary_index_cache_size_ratio {#primary_index_cache_size_ratio} -主索引缓存中受保护队列的大小(在 SLRU 策略的情况下)相对于缓存的总大小。 +主索引缓存中被保护队列的大小(在使用SLRU策略的情况下)相对于缓存的总大小。 ## process_query_plan_packet {#process_query_plan_packet} -此设置允许读取 QueryPlan 数据包。当 serialize_query_plan 启用时,此数据包会在分布式查询中发送。 -默认情况下禁用以避免可能由查询计划二进制反序列化中的错误引起的安全问题。 +此设置允许读取QueryPlan数据包。该数据包在启用了serialize_query_plan时为分布式查询发送。 +默认情况下禁用,以避免由查询计划二进制反序列化中的错误可能引发的安全问题。 **示例** @@ -2517,7 +2705,7 @@ SSL 的支持由 `libpoco` 库提供。可用的配置选项在 [SSLManager.h](h ``` ## processors_profile_log {#processors_profile_log} -[`processors_profile_log`](../system-tables/processors_profile_log.md) 系统表的设置。 +[`processors_profile_log`](../system-tables/processors_profile_log.md)系统表的设置。 @@ -2537,16 +2725,16 @@ SSL 的支持由 `libpoco` 库提供。可用的配置选项在 [SSLManager.h](h ``` ## prometheus {#prometheus} -暴露供 [Prometheus](https://prometheus.io) 抓取的度量数据。 +暴露指标数据以便从[Prometheus](https://prometheus.io)抓取。 设置: -- `endpoint` – 用于 Prometheus 服务器抓取度量的 HTTP 端点。以 '/' 开头。 -- `port` – `endpoint` 的端口。 -- `metrics` – 从 [system.metrics](/operations/system-tables/metrics) 表中暴露度量。 -- `events` – 从 [system.events](/operations/system-tables/events) 表中暴露度量。 -- `asynchronous_metrics` – 从 [system.asynchronous_metrics](/operations/system-tables/asynchronous_metrics) 表中暴露当前度量值。 -- `errors` - 暴露自上次服务器重启以来按错误代码发生的错误数量。此信息也可以从 [system.errors](/operations/system-tables/errors) 获取。 +- `endpoint` – Prometheus服务器抓取指标的HTTP端点。以'/'开头。 +- `port` – `endpoint`的端口。 +- `metrics` – 暴露来自[system.metrics](/operations/system-tables/metrics)表的指标。 +- `events` – 暴露来自[system.events](/operations/system-tables/events)表的指标。 +- `asynchronous_metrics` – 暴露来自[system.asynchronous_metrics](/operations/system-tables/asynchronous_metrics)表的当前指标值。 +- `errors` - 暴露自上次服务器重启以来发生的错误数量以及错误代码。此信息也可以从[system.errors](/operations/system-tables/errors)中获得。 **示例** @@ -2568,30 +2756,30 @@ SSL 的支持由 `libpoco` 库提供。可用的配置选项在 [SSLManager.h](h ``` -检查(将 `127.0.0.1` 替换为您的 ClickHouse 服务器的 IP 地址或主机名): +检查(将`127.0.0.1`替换为您的ClickHouse服务器的IP地址或主机名): ```bash curl 127.0.0.1:9363/metrics ``` ## proxy {#proxy} -为 HTTP 和 HTTPS 请求定义代理服务器,目前受 S3 存储、S3 表函数和 URL 函数支持。 +为HTTP和HTTPS请求定义代理服务器,目前由S3存储、S3表函数和URL函数支持。 -定义代理服务器有三种方式: +有三种方法可以定义代理服务器: - 环境变量 - 代理列表 - 远程代理解析器。 -通过使用 `no_proxy` 也支持为特定主机绕过代理服务器。 +支持使用`no_proxy`绕过特定主机的代理服务器。 **环境变量** -`http_proxy` 和 `https_proxy` 环境变量允许您为给定协议指定代理服务器。如果您在系统上设置了它,应该可以无缝使用。 +`http_proxy`和`https_proxy`环境变量允许您为给定协议指定代理服务器。如果您在系统中设置了它,它应该能够无缝工作。 -这是最简单的方法,如果给定协议只有一个代理服务器并且该代理服务器不变。 +这是最简单的方法,如果给定协议仅有一个代理服务器且该代理服务器不会变化。 **代理列表** -此方法允许您为协议指定一个或多个代理服务器。如果定义了多个代理服务器,ClickHouse 将以轮询方式使用不同的代理,以在服务器之间平衡负载。如果协议有多个代理服务器且代理服务器列表不变,这是最简单的方法。 +这种方法允许您为一个协议指定一个或多个代理服务器。如果定义了多个代理服务器,ClickHouse将在轮询的基础上使用不同的代理,以在服务器之间均衡负载。如果一个协议有多个代理服务器且代理服务器列表不变,这是一种最简单的方法。 **配置模板** @@ -2606,29 +2794,29 @@ curl 127.0.0.1:9363/metrics
``` -在下面的选项卡中选择一个父字段以查看它们的子字段: +在下面的选项卡中选择父字段以查看其子级: -| 字段 | 描述 | -|-----------|-------------------------------------| -| `` | 一个或多个 HTTP 代理的列表 | -| `` | 一个或多个 HTTPS 代理的列表 | +| 字段 | 描述 | +|-----------|----------------------------------| +| `` | 一个或多个HTTP代理的列表 | +| `` | 一个或多个HTTPS代理的列表 | - + -| 字段 | 描述 | -|---------|-----------------------| -| `` | 代理的 URI | +| 字段 | 描述 | +|---------|----------------------| +| `` | 代理的URI | **远程代理解析器** -代理服务器可能会动态更改。在这种情况下,您可以定义解析者的端点。ClickHouse 向该端点发送空的 GET 请求,远程解析器应返回代理主机。ClickHouse 将使用以下模板形成代理 URI:`\{proxy_scheme\}://\{proxy_host\}:{proxy_port}` +代理服务器可能会动态更改。在这种情况下,您可以定义解析器的端点。ClickHouse向该端点发送一个空的GET请求,远程解析器应该返回代理主机。ClickHouse将使用以下模板形成代理URI:`\{proxy_scheme\}://\{proxy_host\}:{proxy_port}` **配置模板** @@ -2655,71 +2843,68 @@ curl 127.0.0.1:9363/metrics
``` -在下面的选项卡中选择一个父字段以查看它们的子字段: +在下面的选项卡中选择父字段以查看其子级: -| 字段 | 描述 | -|---------|------------------------------| -| `` | 一个或多个解析器的列表* | -| `` | 一个或多个解析器的列表* | +| 字段 | 描述 | +|----------|---------------------------| +| `` | 一个或多个解析器的列表* | +| `` | 一个或多个解析器的列表* | - + -| 字段 | 描述 | -|-------------|-------------------------------------------------| -| `` | 解析器的端点和其他详细信息 | +| 字段 | 描述 | +|-------------|---------------------------------------| +| `` | 解析器的端点及其他详细信息 | :::note -可以有多个 `` 元素,但仅使用给定协议的第一个 -``。该协议的任何其他 `` 元素将被忽略。这意味着负载均衡 -(如果需要)应该由远程解析器实现。 +您可以有多个``元素,但只使用给定协议的第一个``。该协议的任何其他``元素将被忽略。这意味着负载均衡(如有需要)应由远程解析器实现。 ::: | 字段 | 描述 | -|---------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `` | 代理解析器的 URI | -| `` | 最终代理 URI 的协议。可以是 `http` 或 `https`。 | -| `` | 代理解析器的端口号 | -| `` | ClickHouse 应缓存解析器的值的时间(以秒为单位)。将此值设置为 `0` 会导致 ClickHouse 针对每个 HTTP 或 HTTPS 请求联系解析器。 | +|---------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `` | 代理解析器的URI | +| `` | 最终代理URI的协议。可以是`http`或`https`。 | +| `` | 代理解析器的端口号 | +| `` | 解析器返回的值应被ClickHouse缓存的时间(以秒为单位)。将此值设置为`0`将导致ClickHouse在每次HTTP或HTTPS请求时都与解析器联系。 | **优先级** -代理设置的确定顺序如下: +代理设置按以下顺序确定: + +| 顺序 | 设置 | +|-------|--------------------| +| 1. | 远程代理解析器 | +| 2. | 代理列表 | +| 3. | 环境变量 | -| 顺序 | 设置 | -|-------|------------------------| -| 1. | 远程代理解析器 | -| 2. | 代理列表 | -| 3. | 环境变量 | +ClickHouse将检查请求协议的最高优先级解析器类型。如果未定义,它将检查下一个最高优先级的解析器类型,直到达到环境解析器。这也允许使用解析器类型的混合。 -ClickHouse 会检查请求协议的最高优先级解析器类型。如果未定义, -它将检查下一个最高优先级的解析器类型,直到找到环境解析器。 -这还允许使用混合解析器类型。 ## query_cache {#query_cache} -[查询缓存](../query-cache.md) 配置。 +[查询缓存](../query-cache.md)配置。 -可用的设置如下: +可用的设置: -| 设置 | 描述 | 默认值 | -|---------------------------|--------------------------------------------------------------------------------|--------------| -| `max_size_in_bytes` | 最大缓存大小(以字节为单位)。`0` 表示查询缓存被禁用。 | `1073741824` | -| `max_entries` | 存储在缓存中的 `SELECT` 查询结果的最大数量。 | `1024` | -| `max_entry_size_in_bytes` | 可保存到缓存中的 `SELECT` 查询结果的最大字节数。 | `1048576` | -| `max_entry_size_in_rows` | 可保存到缓存中的 `SELECT` 查询结果的最大行数。 | `30000000` | +| 设置 | 描述 | 默认值 | +|---------------------------|--------------------------------------------------------------------------------|---------------| +| `max_size_in_bytes` | 最大缓存大小(字节)。`0`表示查询缓存被禁用。 | `1073741824` | +| `max_entries` | 缓存中存储的`SELECT`查询结果的最大数量。 | `1024` | +| `max_entry_size_in_bytes` | 要保存到缓存中的`SELECT`查询结果的最大大小(字节)。 | `1048576` | +| `max_entry_size_in_rows` | 要保存到缓存中的`SELECT`查询结果的最大行数。 | `30000000` | :::note -- 更改的设置会立即生效。 -- 查询缓存的数据分配在 DRAM 中。如果内存紧张,请确保设置较小的 `max_size_in_bytes` 值或完全禁用查询缓存。 +- 更改的设置立即生效。 +- 查询缓存的数据在DRAM中分配。如果内存稀缺,请确保为`max_size_in_bytes`设置较小的值或完全禁用查询缓存。 ::: **示例** @@ -2740,20 +2925,20 @@ ClickHouse 会检查请求协议的最高优先级解析器类型。如果未定 查询条件缓存的最大大小。 :::note -此设置可以在运行时修改,并将立即生效。 +此设置可以在运行时修改并会立即生效。 ::: ## query_condition_cache_size_ratio {#query_condition_cache_size_ratio} -查询条件缓存中受保护队列的大小(在 SLRU 策略的情况下)相对于缓存的总大小。 +查询条件缓存中被保护队列的大小(在使用SLRU策略的情况下)相对于缓存的总大小。 ## query_log {#query_log} -使用 [log_queries=1](../../operations/settings/settings.md) 设置记录收到的查询。 +用于记录通过[log_queries=1](../../operations/settings/settings.md)设置接收到的查询。 -查询记录在 [system.query_log](/operations/system-tables/query_log) 表中,而不是在单独的文件中。您可以修改 `table` 参数中的表名称(见下文)。 +查询记录在[system.query_log](/operations/system-tables/query_log)表中,而不是在单独的文件中。您可以在`table`参数中更改此表的名称(见下文)。 -如果表不存在,ClickHouse 将创建它。如果在更新 ClickHouse 服务器时查询日志的结构发生变化,则旧结构的表会被重命名,并自动创建一个新表。 +如果表不存在,ClickHouse将创建它。如果在ClickHouse服务器更新时查询日志的结构发生变化,旧结构的表将被重命名,并自动创建新表。 **示例** @@ -2771,8 +2956,9 @@ ClickHouse 会检查请求协议的最高优先级解析器类型。如果未定 ``` ## query_masking_rules {#query_masking_rules} -基于正则表达式的规则,将在存储到服务器日志、[`system.query_log`](/operations/system-tables/query_log)、[`system.text_log`](/operations/system-tables/text_log)、[`system.processes`](/operations/system-tables/processes) 表以及发送到客户端的日志消息之前应用。这可以防止 -SQL 查询中的敏感数据泄露,如名称、电子邮件、个人标识符或信用卡号码等。 +基于正则表达式的规则,这些规则将在将查询和所有日志消息存储在服务器日志中之前应用,包括 +[`system.query_log`](/operations/system-tables/query_log)、[`system.text_log`](/operations/system-tables/text_log)、[`system.processes`](/operations/system-tables/processes)表和发送到客户端的日志。这允许防止 +SQL查询中的敏感数据泄漏,例如姓名、电子邮件、个人标识符或信用卡号码。 **示例** @@ -2788,25 +2974,25 @@ SQL 查询中的敏感数据泄露,如名称、电子邮件、个人标识符 **配置字段**: -| 设置 | 描述 | -|-----------|-------------------------------------------------------------------------------| -| `name` | 规则名称(可选) | -| `regexp` | 兼容 RE2 的正则表达式(强制) | -| `replace` | 敏感数据的替代字符串(可选,默认为六个星号) | +| 设置 | 描述 | +|-----------|---------------------------------------------------------------------------| +| `name` | 规则的名称(可选) | +| `regexp` | 兼容RE2的正则表达式(强制) | +| `replace` | 敏感数据的替代字符串(可选,默认 - 六个星号) | -掩码规则应用于整个查询(以防止来自格式错误/无法解析查询的敏感数据泄露)。 +掩码规则应用于整个查询(以防止敏感数据从格式错误/不可解析的查询中泄漏)。 -[`system.events`](/operations/system-tables/events) 表具有计数器 `QueryMaskingRulesMatch`,其具有查询掩码规则匹配的总数。 +[`system.events`](/operations/system-tables/events)表具有计数器`QueryMaskingRulesMatch`,它的值是查询掩码规则匹配的总数。 + +对于分布式查询,每个服务器都必须单独配置,否则,传递给其他节点的子查询将被存储而不进行掩码。 -对于分布式查询,每个服务器必须单独进行配置,否则传递给其他 -节点的子查询将不带掩码存储。 ## query_metric_log {#query_metric_log} -默认禁用。 +默认情况下禁用。 **启用** -要手动开启度量历史收集 [`system.query_metric_log`](../../operations/system-tables/query_metric_log.md),请创建 `/etc/clickhouse-server/config.d/query_metric_log.xml`,并使用以下内容: +要手动打开[`system.query_metric_log`](../../operations/system-tables/query_metric_log.md)的度量历史记录收集,请创建`/etc/clickhouse-server/config.d/query_metric_log.xml`,并包含以下内容: ```xml @@ -2825,7 +3011,7 @@ SQL 查询中的敏感数据泄露,如名称、电子邮件、个人标识符 **禁用** -要禁用 `query_metric_log` 设置,您应创建以下文件 `/etc/clickhouse-server/config.d/disable_query_metric_log.xml`,并使用以下内容: +若要禁用`query_metric_log`设置,您应创建以下文件`/etc/clickhouse-server/config.d/disable_query_metric_log.xml`,并包含以下内容: ```xml @@ -2836,13 +3022,13 @@ SQL 查询中的敏感数据泄露,如名称、电子邮件、个人标识符 ## query_thread_log {#query_thread_log} -设置日志记录收到的查询线程,使用 [log_query_threads=1](/operations/settings/settings#log_query_threads) 设置。 +用于记录通过[log_query_threads=1](/operations/settings/settings#log_query_threads)设置接收到的查询线程的设置。 -查询记录在 [system.query_thread_log](/operations/system-tables/query_thread_log) 表中,而不是在单独的文件中。您可以修改 `table` 参数中的表名称(见下文)。 +查询记录在[system.query_thread_log](/operations/system-tables/query_thread_log)表中,而不是在单独的文件中。您可以在`table`参数中更改此表的名称(见下文)。 -如果表不存在,ClickHouse 将创建它。如果在更新 ClickHouse 服务器时查询线程日志的结构发生变化,则旧结构的表会被重命名,并自动创建一个新表。 +如果表不存在,ClickHouse将创建它。如果在ClickHouse服务器更新时查询线程日志的结构发生变化,旧结构的表将被重命名,并自动创建新表。 **示例** @@ -2860,13 +3046,13 @@ SQL 查询中的敏感数据泄露,如名称、电子邮件、个人标识符 ``` ## query_views_log {#query_views_log} -设置日志记录视图(实时、物化等),依赖于使用 [log_query_views=1](/operations/settings/settings#log_query_views) 接收的查询。 +用于记录视图(实时的、物化的等)的设置,依赖于接收到的 [log_query_views=1](/operations/settings/settings#log_query_views) 设置。 -查询记录在 [system.query_views_log](/operations/system-tables/query_views_log) 表中,而不是在单独的文件中。您可以修改 `table` 参数中的表名称(见下文)。 +查询记录在 [system.query_views_log](/operations/system-tables/query_views_log) 表中,而不是在单独的文件中。您可以通过 `table` 参数更改表的名称(见下文)。 -如果表不存在,ClickHouse 将创建它。如果在更新 ClickHouse 服务器时查询视图日志的结构发生变化,则旧结构的表会被重命名,并自动创建一个新表。 +如果表不存在,ClickHouse 将创建它。如果查询视图日志的结构在更新 ClickHouse 服务器时发生了变化,则旧结构的表会被重命名,并自动创建一个新表。 **示例** @@ -2884,7 +3070,7 @@ SQL 查询中的敏感数据泄露,如名称、电子邮件、个人标识符 ``` ## remap_executable {#remap_executable} -设置使用大页面重新分配机器代码(“文本”的内存)。 +用于重新分配内存以处理机器代码(“文本”)的设置,使用大页。 :::note 此功能高度实验性。 @@ -2897,7 +3083,7 @@ SQL 查询中的敏感数据泄露,如名称、电子邮件、个人标识符 ``` ## remote_servers {#remote_servers} -由 [Distributed](../../engines/table-engines/special/distributed.md) 表引擎和 `cluster` 表函数使用的集群配置。 +用于配置 [Distributed](../../engines/table-engines/special/distributed.md) 表引擎和 `cluster` 表函数使用的集群。 **示例** @@ -2905,7 +3091,7 @@ SQL 查询中的敏感数据泄露,如名称、电子邮件、个人标识符 ``` -有关 `incl` 属性的值,请参阅 “[配置文件](/operations/configuration-files)” 部分。 +有关 `incl` 属性的值,请参见 “[配置文件](/operations/configuration-files)” 部分。 **另见** @@ -2916,12 +3102,12 @@ SQL 查询中的敏感数据泄露,如名称、电子邮件、个人标识符 允许在与 URL 相关的存储引擎和表函数中使用的主机列表。 -在使用 `\` XML 标签添加主机时: -- 必须与 URL 中的名称完全一致,因为在 DNS 解析之前会进行检查。例如:`clickhouse.com` -- 如果在 URL 中明确指定了端口,则对主机:端口作为整体进行检查。例如:`clickhouse.com:80` -- 如果指定的主机没有端口,则允许主机的任何端口。例如:如果指定了 `clickhouse.com`,则 `clickhouse.com:20`(FTP)、`clickhouse.com:80`(HTTP)、`clickhouse.com:443`(HTTPS)等都允许。 -- 如果主机指定为 IP 地址,则按 URL 中指定的方式进行检查。例如:[2a02:6b8:a::a]。 -- 如果有重定向并且启用重定向支持,则检查每个重定向(位置字段)。 +通过 `\` XML 标签添加主机时: +- 必须完全按照 URL 中的格式指定,因为名称在 DNS 解析前会被检查。例如:`clickhouse.com` +- 如果在 URL 中明确指定了端口,则整个 host:port 会被检查。例如:`clickhouse.com:80` +- 如果不带端口指定主机,则允许该主机的任何端口。例如:如果指定 `clickhouse.com`,则 `clickhouse.com:20`(FTP)、`clickhouse.com:80`(HTTP)、`clickhouse.com:443`(HTTPS)等都是允许的。 +- 如果主机指定为 IP 地址,则根据 URL 中指定的格式进行检查。例如:`[2a02:6b8:a::a]`。 +- 如果存在重定向并且启用了对重定向的支持,则检查每个重定向(位置字段)。 例如: @@ -2946,16 +3132,16 @@ DDL 查询只会等待同一组中的副本。 ``` ## replicated_fetches_http_connection_timeout {#replicated_fetches_http_connection_timeout} -用于部分获取请求的 HTTP 连接超时。如果未明确设置则从默认配置文件 `http_connection_timeout` 继承。 +获取分区请求的 HTTP 连接超时。 如果未明确设置,则继承自默认配置文件 `http_connection_timeout`。 ## replicated_fetches_http_receive_timeout {#replicated_fetches_http_receive_timeout} -获取部分请求的 HTTP 接收超时。如果未明确设置则从默认配置文件 `http_receive_timeout` 继承。 +获取分区请求的 HTTP 接收超时。 如果未明确设置,则继承自默认配置文件 `http_receive_timeout`。 ## replicated_fetches_http_send_timeout {#replicated_fetches_http_send_timeout} -用于部分获取请求的 HTTP 发送超时。如果未明确设置则从默认配置文件 `http_send_timeout` 继承。 +获取分区请求的 HTTP 发送超时。 如果未明确设置,则继承自默认配置文件 `http_send_timeout`。 ## replicated_merge_tree {#replicated_merge_tree} -[ReplicatedMergeTree](../../engines/table-engines/mergetree-family/mergetree.md) 中表的微调。该设置具有更高的优先级。 +[ReplicatedMergeTree](../../engines/table-engines/mergetree-family/mergetree.md) 中表的微调设置。 此设置具有更高的优先级。 有关更多信息,请参见 MergeTreeSettings.h 头文件。 @@ -2968,7 +3154,16 @@ DDL 查询只会等待同一组中的副本。 ``` ## restore_threads {#restore_threads} -执行 RESTORE 请求的最大线程数。 +执行 RESTORE 请求的最大线程数量。 +## s3_max_redirects {#s3_max_redirects} + +允许的 S3 重定向跳数的最大数量。 +## s3_retry_attempts {#s3_retry_attempts} + +Aws::Client::RetryStrategy 的设置,Aws::Client 会自己重试,0 意味着不重试。 +## s3queue_disable_streaming {#s3queue_disable_streaming} + +即使表已创建并且附加了物化视图,也禁用 S3Queue 中的流处理。 ## s3queue_log {#s3queue_log} `s3queue_log` 系统表的设置。 @@ -2987,17 +3182,17 @@ DDL 查询只会等待同一组中的副本。 ``` ## send_crash_reports {#send_crash_reports} -用于向 ClickHouse 核心开发者团队发送崩溃报告的设置。 +发送崩溃报告到 ClickHouse 核心开发团队的设置。 -在生产前环境中启用此功能,尤其受到高度重视。 +在生产前环境中启用此功能非常重要。 键: -| 键 | 描述 | -|-----------------------|----------------------------------------------------------------------------------------------------------------------------------| -| `enabled` | 启用此功能的布尔标志,默认为 `true`。设置为 `false` 以避免发送崩溃报告。 | -| `send_logical_errors` | `LOGICAL_ERROR` 就像一个 `assert`,这是 ClickHouse 中的一个 bug。此布尔标志启用发送此异常(默认值:`true`)。 | -| `endpoint` | 您可以覆盖发送崩溃报告的端点 URL。 | +| 键 | 描述 | +|------------------------|-------------------------------------------------------------------------------------------------------------------------------| +| `enabled` | 启用此功能的布尔标志,默认为 `true`。设置为 `false` 以避免发送崩溃报告。 | +| `send_logical_errors` | `LOGICAL_ERROR` 类似于 `assert`,是 ClickHouse 中的一个错误。此布尔标志启用发送该异常(默认:`true`)。 | +| `endpoint` | 可以覆盖发送崩溃报告的端点 URL。 | **推荐用法** @@ -3009,24 +3204,27 @@ DDL 查询只会等待同一组中的副本。 ## series_keeper_path {#series_keeper_path} -Keeper 中带有自动递增数字的路径,由 `generateSerialID` 函数生成。每个系列将是该路径下的一个节点。 +Keeper 中的路径,带有由 `generateSerialID` 函数生成的自增编号。每个序列将是该路径下的一个节点。 ## show_addresses_in_stack_traces {#show_addresses_in_stack_traces} 如果设置为 true,将在堆栈跟踪中显示地址。 ## shutdown_wait_backups_and_restores {#shutdown_wait_backups_and_restores} -如果设置为 true,ClickHouse 将等待正在运行的备份和恢复完成后再关闭。 +如果设置为 true,ClickHouse 将在关闭之前等待正在运行的备份和恢复完成。 ## shutdown_wait_unfinished {#shutdown_wait_unfinished} 等待未完成查询的延迟(以秒为单位)。 ## shutdown_wait_unfinished_queries {#shutdown_wait_unfinished_queries} -如果设置为 true,ClickHouse 将等待正在运行的查询完成后再关闭。 +如果设置为 true,ClickHouse 将在关闭之前等待正在运行的查询完成。 +## skip_binary_checksum_checks {#skip_binary_checksum_checks} + +跳过 ClickHouse 二进制校验和完整性检查。 ## ssh_server {#ssh_server} -主机密钥的公共部分将在 SSH 客户端第一次连接时写入 known_hosts 文件。 +主机密钥的公钥部分将写入 SSH 客户端侧的 known_hosts 文件中,首次连接时。 -主机密钥配置默认情况下未激活。 +主机密钥配置默认情况下是非活动的。 取消注释主机密钥配置,并提供相应 SSH 密钥的路径以激活它们: 示例: @@ -3040,10 +3238,10 @@ Keeper 中带有自动递增数字的路径,由 `generateSerialID` 函数生 ``` ## startup_mv_delay_ms {#startup_mv_delay_ms} -调试参数,用于模拟物化视图创建延迟。 +调试参数以模拟物化视图创建延迟。 ## storage_configuration {#storage_configuration} -允许存储的多磁盘配置。 +允许多磁盘存储配置。 存储配置遵循以下结构: @@ -3059,7 +3257,7 @@ Keeper 中带有自动递增数字的路径,由 `generateSerialID` 函数生 ``` ### Configuration of disks {#configuration-of-disks} -`disks` 的配置遵循下面给出的结构: +`disks` 的配置遵循下列结构: ```xml @@ -3080,77 +3278,83 @@ Keeper 中带有自动递增数字的路径,由 `generateSerialID` 函数生 ``` -上述子标签定义了 `disks` 的以下设置: +上述子标签为 `disks` 定义了以下设置: -| 设置 | 描述 | -|-------------------------|--------------------------------------------------------------------------------------------------| -| `` | 磁盘的名称,必须唯一。 | -| `path` | 存储服务器数据的路径(`data` 和 `shadow` 目录)。应该以 `/` 结尾。 | -| `keep_free_space_bytes` | 磁盘上保留的自由空间的大小。 | +| 设置 | 描述 | +|------------------------|------------------------------------------------------------------------------------------------| +| `` | 磁盘的名称,应该是唯一的。 | +| `path` | 服务器数据将存储的路径(`data` 和 `shadow` 目录)。应该以 `/` 结尾。 | +| `keep_free_space_bytes`| 保留磁盘上的空闲空间大小。 | :::note -磁盘的顺序不重要。 +磁盘的顺序无关紧要。 ::: ### Configuration of policies {#configuration-of-policies} -上述子标签定义了 `policies` 的以下设置: - -| 设置 | 描述 | -|-----------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `policy_name_N` | 政策的名称。政策名称必须唯一。 | -| `volume_name_N` | 卷的名称。卷名称必须唯一。 | -| `disk` | 位于卷内的磁盘。 | -| `max_data_part_size_bytes` | 此卷中可存在任何磁盘上的数据块的最大大小。如果合并结果预计的块大小大于 max_data_part_size_bytes,该块将写入下一个卷。基本上,此功能允许您在热(SSD)卷上存储新的/较小的块,并在它们达到较大规模时将它们移动到冷(HDD)卷。如果政策仅有一个卷,则不要使用此选项。 | -| `move_factor` | 卷上可用自由空间的份额。如果空间减少,数据将开始转移到下一个卷(如果存在)。为了进行转移,块按大小从大到小(降序)排序,并选择总大小足以满足 `move_factor` 条件的块,如果所有块的总大小不足,则移动所有块。 | -| `perform_ttl_move_on_insert` | 禁用插入时移动过期生存时间的数据显示。默认情况下(如果启用),如果我们插入根据移除生命规则已经过期的数据,则它会立即移动到指定的目标卷/磁盘。这可能会显著减慢插入速度,特别是在目标卷/磁盘较慢(例如 S3)的情况下。如果禁用,则过期的数据部分将被写入默认卷,然后立即移动到指定的过期生存时间规则的卷中。 | -| `load_balancing` | 磁盘平衡策略,可以是 `round_robin` 或 `least_used`。 | -| `least_used_ttl_ms` | 设置更新所有磁盘上可用空间的超时(以毫秒为单位)(`0` - 始终更新,`-1` - 从不更新,默认值为 `60000`)。请注意,如果磁盘仅由 ClickHouse 使用,并且不会受到文件系统动态调整的影响,您可以使用 `-1` 值。在所有其他情况下,不推荐使用此值,因为这最终会导致不正确的空间分配。 | -| `prefer_not_to_merge` | 禁用在该卷上的数据合并。注意:这可能有害并导致性能下降。当启用此设置时(请勿这样做),将禁止在此卷上合并数据(这很糟糕)。这允许控制 ClickHouse 如何与较慢的磁盘交互。我们建议根本不使用此选项。 | -| `volume_priority` | 定义填充卷的优先级(顺序)。数值越小,优先级越高。参数值应为自然数字,并覆盖从 1 到 N(N 为指定的最大参数值)的范围,没有间隔。 | +上述子标签为 `policies` 定义了以下设置: + +| 设置 | 描述 | +|----------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `policy_name_N` | 策略名称。策略名称必须是唯一的。 | +| `volume_name_N` | 卷名称。卷名称必须是唯一的。 | +| `disk` | 位于卷内的磁盘。 | +| `max_data_part_size_bytes` | 该卷中任何磁盘上可以存在的数据块的最大大小。如果合并结果的块大小预期大于 `max_data_part_size_bytes`,则该块将写入下一个卷。基本上,此功能允许您在热(SSD)卷上存储新的/小块,然后在它们达到较大尺寸时将它们移动到冷(HDD)卷。如果策略只有一个卷,则请勿使用此选项。 | +| `move_factor` | 卷上可用的空闲空间的份额。如果空间减少,数据将开始转移到下一个卷(如果有)。在传输中,块根据大小从大到小(降序)排序,并选择总大小足以满足 `move_factor` 条件的块,如果所有块的总大小不足,则所有块将被移动。 | +| `perform_ttl_move_on_insert` | 禁用在插入时移动过期 TTL 的数据。默认情况下(如果启用),如果我们插入的数据已根据生存时间移动规则过期,则它会立即移动到指定的卷/磁盘。如果目标卷/磁盘较慢(例如 S3),则这会显著减慢插入速度。如果禁用,过期数据部分将写入默认卷,然后立即移动到指定的过期 TTL 的规则中。 | +| `load_balancing` | 磁盘平衡策略,`round_robin` 或 `least_used`。 | +| `least_used_ttl_ms` | 设置超时(以毫秒为单位),以更新所有磁盘的可用空间(`0` - 始终更新,`-1` - 从不更新,默认值为 `60000`)。注意,如果仅通过 ClickHouse 使用磁盘,并且不会受到文件系统动态调整的影响,则可以使用 `-1` 值。在所有其他情况下,这不推荐使用,因为最终会导致空间分配不正确。 | +| `prefer_not_to_merge` | 禁用在该卷上合并数据块的功能。注意:这可能会导致性能下降并造成问题。当启用此设置时(请勿启用此项),会禁止在该卷上合并数据(这不好)。这可以控制 ClickHouse 如何与慢速磁盘交互。我们推荐根本不使用此设置。 | +| `volume_priority` | 定义填充卷的优先级(顺序)。值越小,优先级越高。参数值必须是自然数并覆盖从 1 到 N(N 是指定的最大参数值)之间的范围,且无缺口。 | 对于 `volume_priority`: -- 如果所有卷都有此参数,则按指定顺序优先。 -- 如果只有某些卷具有此参数,则没有此参数的卷优先级最低。具有此参数的会根据标签值进行优先排序,其余的优先级则由在配置文件中相对彼此的描述顺序决定。 -- 如果没有卷给此参数,则其顺序由配置文件中的描述顺序决定。 +- 如果所有卷都有此参数,则按指定顺序进行优先级排序。 +- 如果只有 _某些_ 卷有此参数,则没有该参数的卷的优先级最低。具有此参数的卷根据标签值进行优先排序,其余的优先级则根据配置文件中相对描述的顺序确定。 +- 如果 _没有_ 卷提供此参数,则其顺序由配置文件中的描述顺序决定。 - 卷的优先级可能不相同。 ## storage_connections_soft_limit {#storage_connections_soft_limit} -超出此限制的连接生命时间显著缩短。限制适用于存储连接。 +超出此限制的连接的存活时间显著缩短。该限制适用于存储连接。 ## storage_connections_store_limit {#storage_connections_store_limit} -超出此限制的连接在使用之后将重置。设置为 0 将关闭连接缓存。限制适用于存储连接。 +超出此限制的连接在使用后会重置。设置为 0 禁用连接缓存。该限制适用于存储连接。 ## storage_connections_warn_limit {#storage_connections_warn_limit} -如果使用中的连接数高于此限制,则警告消息将写入日志。限制适用于存储连接。 +如果使用中的连接数量高于此限制,会将警告消息写入日志。该限制适用于存储连接。 ## storage_metadata_write_full_object_key {#storage_metadata_write_full_object_key} -以 VERSION_FULL_OBJECT_KEY 格式写入磁盘元数据文件。 +以 VERSION_FULL_OBJECT_KEY 格式写入磁盘元数据文件。默认启用。此设置已弃用。 ## storage_shared_set_join_use_inner_uuid {#storage_shared_set_join_use_inner_uuid} -如果启用,在创建 SharedSet 和 SharedJoin 时将生成内部 UUID。仅限 ClickHouse Cloud。 +如果启用,则在创建 SharedSet 和 SharedJoin 时生成内部 UUID。仅适用于 ClickHouse Cloud。 ## table_engines_require_grant {#table_engines_require_grant} -如果设置为 true,用户需要获得授权才能创建具有特定引擎的表,例如 `GRANT TABLE ENGINE ON TinyLog to user`。 +如果设置为 true,则用户需要获得授权才能创建具有特定引擎的表,例如 `GRANT TABLE ENGINE ON TinyLog to user`。 :::note -默认情况下,为了向后兼容,创建带有特定表引擎的表会忽略授权,但是您可以通过将其设置为 true 来更改此行为。 +默认情况下,为了向后兼容,创建带有特定表引擎的表会忽略授权,但您可以通过将此设置为 true 来改变此行为。 ::: ## tables_loader_background_pool_size {#tables_loader_background_pool_size} -设置在后台池中执行异步加载作业的线程数。当服务器启动后如果没有等待加载表的查询,则使用后台池异步加载表。如果表的数量很多,建议保持后台池中线程数量较低。这将为并发查询执行保留 CPU 资源。 +设置在后台池中执行异步加载作业的线程数量。后台池用于在服务器启动后异步加载表,当没有查询等待该表时。如果表的数量很多,保持后台池中的线程数量较低将是有利的。这样可以为并发查询执行保留 CPU 资源。 :::note -值为 `0` 表示将使用所有可用 CPU。 +值为 `0` 意味着将使用所有可用 CPU。 ::: ## tables_loader_foreground_pool_size {#tables_loader_foreground_pool_size} -设置在前台池中执行加载作业的线程数。前台池用于在服务器开始监听端口之前的同步加载表,以及加载等待的表。前台池的优先级高于后台池。这意味着在前台池中有作业运行时,后台池中不会开始任何作业。 +设置在前台池中执行加载作业的线程数量。前台池用于在服务器开始监听端口之前同步加载表以及加载需要等待的表。前台池的优先级高于后台池。这意味着在前台池中有作业运行时,后台池中不会开始作业。 :::note -值为 `0` 表示将使用所有可用 CPU。 +值为 `0` 意味着将使用所有可用 CPU。 ::: +## tcp_close_connection_after_queries_num {#tcp_close_connection_after_queries_num} + +每个 TCP 连接允许的最大查询数量,在此之后关闭连接。设置为 0 以允许无限制查询。 +## tcp_close_connection_after_queries_seconds {#tcp_close_connection_after_queries_seconds} + +TCP 连接的最大生存时间(以秒为单位),在此之后关闭连接。设置为 0 以允许无限制连接生存时间。 ## tcp_port {#tcp_port} 用于通过 TCP 协议与客户端通信的端口。 @@ -3162,7 +3366,7 @@ Keeper 中带有自动递增数字的路径,由 `generateSerialID` 函数生 ``` ## tcp_port_secure {#tcp_port_secure} -用于与客户端进行安全通信的 TCP 端口。与 [OpenSSL](#openssl) 设置一起使用。 +用于与客户端安全通信的 TCP 端口。与 [OpenSSL](#openssl) 设置一起使用。 **默认值** @@ -3171,7 +3375,7 @@ Keeper 中带有自动递增数字的路径,由 `generateSerialID` 函数生 ``` ## tcp_ssh_port {#tcp_ssh_port} -用于 SSH 服务器的端口,允许用户通过嵌入式客户端以交互方式连接和执行查询。 +SSH 服务器的端口,允许用户连接并通过嵌入式客户端以交互方式执行查询。 示例: @@ -3180,17 +3384,17 @@ Keeper 中带有自动递增数字的路径,由 `generateSerialID` 函数生 ``` ## temporary_data_in_cache {#temporary_data_in_cache} -有了这个选项,临时数据将在特定磁盘的缓存中存储。 -在此部分中,您应指定类型为 `cache` 的磁盘名称。 -在这种情况下,缓存和临时数据将共享相同的空间,并且可以将磁盘缓存逐出以创建临时数据。 +使用此选项,临时数据将存储在特定磁盘的缓存中。 +在此部分,您应该指定类型为 `cache` 的磁盘名称。 +在这种情况下,缓存和临时数据将共享同一空间,并且磁盘缓存可以被驱逐以创建临时数据。 :::note -只能使用一个选项来配置临时数据存储: `tmp_path` ,`tmp_policy`, `temporary_data_in_cache`。 +只能使用一个选项来配置临时数据存储:`tmp_path`,`tmp_policy`,`temporary_data_in_cache`。 ::: **示例** -`local_disk` 的缓存和临时数据将存储在文件系统上由 `tiny_local_cache` 管理的 `/tiny_local_cache` 中。 +`local_disk` 的缓存和临时数据将存储在文件系统的 `/tiny_local_cache` 中,由 `tiny_local_cache` 管理。 ```xml @@ -3219,17 +3423,20 @@ Keeper 中带有自动递增数字的路径,由 `generateSerialID` 函数生 ``` +## temporary_data_in_distributed_cache {#temporary_data_in_distributed_cache} + +在分布式缓存中存储临时数据。 ## text_log {#text_log} -用于记录文本消息的 [text_log](/operations/system-tables/text_log) 系统表的设置。 +用于记录文本消息的 [text_log](/operations/system-tables/text_log) 系统表设置。 此外: -| 设置 | 描述 | 默认值 | -|--------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------| -| `level` | 最大消息级别(默认 `Trace`)将被存储在表中。 | `Trace` | +| 设置 | 描述 | 默认值 | +|--------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------| +| `level`| 最大消息级别(默认 `Trace`),将被存储在表中。 | `Trace` | **示例** @@ -3252,10 +3459,10 @@ Keeper 中带有自动递增数字的路径,由 `generateSerialID` 函数生 ## thread_pool_queue_size {#thread_pool_queue_size} -可以在全局线程池中调度的最大作业数。增加队列大小会导致更大的内存使用。建议保持该值等于 [`max_thread_pool_size`](/operations/server-configuration-parameters/settings#max_thread_pool_size)。 +全局线程池中可以调度的最大作业数量。增加队列大小会导致更高的内存使用。建议将此值设置为 [`max_thread_pool_size`](/operations/server-configuration-parameters/settings#max_thread_pool_size)。 :::note -值为 `0` 表示无限。 +值为 `0` 意味着无限制。 ::: **示例** @@ -3263,19 +3470,31 @@ Keeper 中带有自动递增数字的路径,由 `generateSerialID` 函数生 ```xml 12000 ``` +## threadpool_local_fs_reader_pool_size {#threadpool_local_fs_reader_pool_size} + +在 `local_filesystem_read_method = 'pread_threadpool'` 时,从本地文件系统读取的线程池中的线程数量。 +## threadpool_local_fs_reader_queue_size {#threadpool_local_fs_reader_queue_size} + +可以在本地文件系统读取线程池中调度的最大作业数量。 +## threadpool_remote_fs_reader_pool_size {#threadpool_remote_fs_reader_pool_size} + +在 `remote_filesystem_read_method = 'threadpool'` 时,从远程文件系统读取的线程池中线程数量。 +## threadpool_remote_fs_reader_queue_size {#threadpool_remote_fs_reader_queue_size} + +可以在远程文件系统读取线程池中调度的最大作业数量。 ## threadpool_writer_pool_size {#threadpool_writer_pool_size} -向对象存储发送写请求的后台池的大小。 +写入请求到对象存储的后台池大小。 ## threadpool_writer_queue_size {#threadpool_writer_queue_size} -可以推入后台池的写请求任务数。 +可以推入对象存储的写请求后台池的任务数。 ## throw_on_unknown_workload {#throw_on_unknown_workload} -定义对带有查询设置 'workload' 的未知 WORKLOAD 的访问行为。 +定义访问设置为 'workload' 的未知工作负载时的行为。 -- 如果为 `true`,将从尝试访问未知工作负载的查询中抛出 RESOURCE_ACCESS_DENIED 异常。这对于在建立了 WORKLOAD 层次结构并包含 WORKLOAD 默认的所有查询强制执行资源调度很有用。 -- 如果为 `false`(默认),对于指向未知 WORKLOAD 的查询在没有资源调度的情况下提供无限访问。这在设置 WORKLOAD 层次结构期间很重要,在添加 WORKLOAD 默认之前。 +- 如果 `true`,将从尝试访问未知工作负载的查询中抛出 RESOURCE_ACCESS_DENIED 异常。对所有在建立 WORKLOAD 层次结构并包含 WORKLOAD 默认后,强制执行资源调度十分有用。 +- 如果 `false`(默认),提供对未定义工作负载的查询无限制访问,而不进行资源调度。这在设置 WORKLOAD 层次结构,以便在添加 WORKLOAD 默认之前是重要的。 **示例** @@ -3284,14 +3503,14 @@ Keeper 中带有自动递增数字的路径,由 `generateSerialID` 函数生 ``` **另见** -- [Workload Scheduling](/operations/workload-scheduling.md) +- [工作负载调度](/operations/workload-scheduling.md) ## timezone {#timezone} 服务器的时区。 -指定为 UTC 时区或地理位置的 IANA 标识符(例如,Africa/Abidjan)。 +指定为 IANA 的 UTC 时区或地理位置标识符(例如,Africa/Abidjan)。 -时区在将 DateTime 字段输出到文本格式(打印到屏幕或文件)时以及从字符串获取 DateTime 时,必要用于在字符串和 DateTime 格式之间的转换。此外,在未接收输入参数中的时区时,时区在处理时间和日期的函数中使用。 +时区在将字符串和 DateTime 格式之间转换时是必需的,当 DateTime 字段以文本格式(在屏幕上或文件中打印)输出,并且在从字符串获取 DateTime 时。此外,当未在输入参数中接收时,时区在使用时间和日期的函数中使用。 **示例** @@ -3304,10 +3523,10 @@ Keeper 中带有自动递增数字的路径,由 `generateSerialID` 函数生 - [session_timezone](../settings/settings.md#session_timezone) ## tmp_path {#tmp_path} -在本地文件系统上存储临时数据的路径,用于处理大查询。 +在本地文件系统上存储临时数据的路径,以用于处理大查询。 :::note -- 只能使用一个选项来配置临时数据存储: `tmp_path` ,`tmp_policy`, `temporary_data_in_cache`。 +- 只能使用一个选项来配置临时数据存储:`tmp_path`,`tmp_policy`,`temporary_data_in_cache`。 - 尾部斜杠是强制性的。 ::: @@ -3318,17 +3537,27 @@ Keeper 中带有自动递增数字的路径,由 `generateSerialID` 函数生 ``` ## tmp_policy {#tmp_policy} -带有临时数据的存储策略。有关更多信息,请参阅 [MergeTree Table Engine](/engines/table-engines/mergetree-family/mergetree) 文档。 + +用于存储临时数据的策略。所有以 `tmp` 前缀的文件将在启动时被删除。 + +:::note +对将对象存储用作 `tmp_policy` 的建议: +- 在每个服务器上使用单独的 `bucket:path` +- 使用 `metadata_type=plain` +- 您可能还希望为此存储桶设置 TTL +::: :::note -- 只能使用一个选项来配置临时数据存储: `tmp_path` ,`tmp_policy`, `temporary_data_in_cache`。 +- 只能使用一个选项来配置临时数据存储:`tmp_path`,`tmp_policy`,`temporary_data_in_cache`。 - `move_factor`、`keep_free_space_bytes`、`max_data_part_size_bytes` 被忽略。 -- 策略应只有一个 *local* 磁盘的 *一个卷*。 +- 策略应该正好有 *一个卷*。 + +有关更多信息,请参见 [MergeTree 表引擎](/engines/table-engines/mergetree-family/mergetree) 文档。 ::: **示例** -当 `/disk1` 满时,临时数据将存储在 `/disk2` 上。 +当 `/disk1` 已满时,临时数据将存储在 `/disk2` 中。 ```xml @@ -3363,7 +3592,7 @@ Keeper 中带有自动递增数字的路径,由 `generateSerialID` 函数生 ``` ## top_level_domains_list {#top_level_domains_list} -定义要添加的自定义顶级域的列表,每个条目的格式为 `/path/to/file`。 +定义要添加的自定义顶级域名的列表,其中每个条目的格式为 `/path/to/file`。 例如: @@ -3374,28 +3603,29 @@ Keeper 中带有自动递增数字的路径,由 `generateSerialID` 函数生 ``` 另见: -- 函数 [`cutToFirstSignificantSubdomainCustom`](../../sql-reference/functions/url-functions.md/#cuttofirstsignificantsubdomaincustom) 及其变体,接受自定义 TLD 列表名称,返回包含顶级子域的域的部分,直到第一个重要子域。 +- 函数 [`cutToFirstSignificantSubdomainCustom`](../../sql-reference/functions/url-functions.md/#cuttofirstsignificantsubdomaincustom) 及其变体, + 接受自定义 TLD 列表名称,返回包含顶级子域的域名部分,直到第一个显著子域。 ## total_memory_profiler_sample_max_allocation_size {#total_memory_profiler_sample_max_allocation_size} -以小于或等于指定值的概率收集随机分配。0 意味着禁用。您可能希望将 'max_untracked_memory' 设置为 0,以使该阈值按预期工作。 +收集大小小于或等于指定值的随机分配,概率等于 `total_memory_profiler_sample_probability`。值为 0 时禁用。您可能希望将 'max_untracked_memory' 设置为 0,使此阈值按预期工作。 ## total_memory_profiler_sample_min_allocation_size {#total_memory_profiler_sample_min_allocation_size} -以大于或等于指定值的概率收集随机分配。0 意味着禁用。您可能希望将 'max_untracked_memory' 设置为 0,以使该阈值按预期工作。 +收集大小大于或等于指定值的随机分配,概率等于 `total_memory_profiler_sample_probability`。值为 0 时禁用。您可能希望将 'max_untracked_memory' 设置为 0,使此阈值按预期工作。 ## total_memory_profiler_step {#total_memory_profiler_step} -每当服务器内存使用量大于每个步骤的字节数时,内存分析器将收集分配的堆栈跟踪。零表示禁用内存分析器。低于几兆字节的值将减慢服务器。 +每当服务器内存使用量大于每个字节数的下一个步骤时,内存分析器将收集分配堆栈跟踪。零表示禁用内存分析器。值低于几兆字节将减慢服务器。 ## total_memory_tracker_sample_probability {#total_memory_tracker_sample_probability} -允许收集随机分配和取消分配,并以 `trace_type` 等于 `MemorySample` 的形式将其写入 [system.trace_log](../../operations/system-tables/trace_log.md) 系统表,具有指定的概率。该概率适用于每个分配或取消分配,与分配的大小无关。注意,采样仅在未跟踪内存超出未跟踪内存限制时发生(默认值为 `4` MiB)。如果 [total_memory_profiler_step](/operations/server-configuration-parameters/settings#total_memory_profiler_step) 降低,则可以降低此限制。您可以将 `total_memory_profiler_step` 设置为 `1` 以进行更精细的采样。 +允许收集随机分配和去分配,并将其写入 [system.trace_log](../../operations/system-tables/trace_log.md) 系统表,`trace_type` 等于 `MemorySample` ,其指定的概率。概率适用于每个分配或去分配,而不考虑分配的大小。请注意,采样仅在未跟踪的内存量超过未跟踪内存限制时发生(默认值为 `4` MiB)。如果 [total_memory_profiler_step](/operations/server-configuration-parameters/settings#total_memory_profiler_step) 降低,则可以降低该值。您可以将其设置为 `total_memory_profiler_step` 为 `1` 以进行额外细致的采样。 -可能值: +可能的值: -- 正整数。 -- `0` — 禁用在 `system.trace_log` 系统表中写入随机分配和取消分配。 +- 正的双精度。 +- `0` — 禁用在 `system.trace_log` 系统表中写入随机分配和去分配。 ## trace_log {#trace_log} -[trace_log](/operations/system-tables/trace_log) 系统表操作的设置。 +用于 [trace_log](/operations/system-tables/trace_log) 系统表操作的设置。 @@ -3420,23 +3650,23 @@ Keeper 中带有自动递增数字的路径,由 `generateSerialID` 函数生 ## uncompressed_cache_size {#uncompressed_cache_size} -用于 MergeTree 系列表引擎的未压缩数据的最大大小(以字节为单位)。 +MergeTree 家族表引擎使用的未压缩数据的最大大小(以字节为单位)。 -服务器有一个共享缓存。内存根据需要分配。如果启用选项 `use_uncompressed_cache` ,则使用此缓存。 +服务器共享一个缓存。根据需求进行内存分配。启用 `use_uncompressed_cache` 选项时,将使用该缓存。 -未压缩缓存对于非常短的查询在个别情况下是有利的。 +未压缩缓存在单个情况下对非常短的查询是有利的。 :::note -值为 `0` 表示禁用。 +值为 `0` 意味着禁用。 -此设置可以在运行时修改,并将立即生效。 +此设置可以在运行时修改,并会立即生效。 ::: ## uncompressed_cache_size_ratio {#uncompressed_cache_size_ratio} -相对于缓存总大小,在未压缩缓存中受保护队列的大小(在 SLRU 策略中)。 +未压缩缓存中保护队列的大小(在 SLRU 策略下)相对于缓存的总大小。 ## url_scheme_mappers {#url_scheme_mappers} -将缩略或符号 URL 前缀转换为完整 URL 的配置。 +用于将缩短的或符号的 URL 前缀转换为完整 URL 的配置。 示例: @@ -3455,27 +3685,27 @@ Keeper 中带有自动递增数字的路径,由 `generateSerialID` 函数生 ``` ## use_minimalistic_part_header_in_zookeeper {#use_minimalistic_part_header_in_zookeeper} -ZooKeeper 中数据部分头的存储方式。此设置仅适用于 [`MergeTree`](/engines/table-engines/mergetree-family) 系列。可以按如下方式指定: +在 ZooKeeper 中存储数据部分头的方式。此设置仅适用于 [`MergeTree`](/engines/table-engines/mergetree-family) 系列。可以全局指定: -**全局设置在 `config.xml` 文件的 [merge_tree](#merge_tree) 部分** +**全面应用于 `config.xml` 文件的 [merge_tree](#merge_tree) 部分** -ClickHouse 对服务器上的所有表使用该设置。您可以随时更改该设置。当设置更改时,现有表的行为将发生变化。 +ClickHouse 为服务器上的所有表使用该设置。您可以随时更改该设置。当设置发生变化时,现有表的行为也会发生变化。 -**对于每个表** +**适用于每个表** -在创建表时,请指定相应的 [engine setting](../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-creating-a-table)。即使全局设置更改,具有此设置的现有表的行为也不会改变。 +创建表时,指定相应的 [引擎设置](../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-creating-a-table)。现有表的行为不会因此设置而改变,即使全局设置发生变化。 -**可能值** +**可能的值** -- `0` — 功能关闭。 -- `1` — 功能开启。 +- `0` — 功能已关闭。 +- `1` — 功能已开启。 -如果 [`use_minimalistic_part_header_in_zookeeper = 1`](#use_minimalistic_part_header_in_zookeeper),则 [replicated](../../engines/table-engines/mergetree-family/replication.md) 表使用单个 `znode` 紧凑存储数据部分的头。如果表包含多个列,则此存储方式显著减少了存储在 Zookeeper 中的数据量。 +如果 [`use_minimalistic_part_header_in_zookeeper = 1`](#use_minimalistic_part_header_in_zookeeper),则 [replicated](../../engines/table-engines/mergetree-family/replication.md) 表将通过使用单个 `znode` 紧凑地存储数据部分的头。如果表包含许多列,此存储方法显著减少存储在 ZooKeeper 中的数据量。 :::note -在应用 `use_minimalistic_part_header_in_zookeeper = 1` 后,您无法将 ClickHouse 服务器降级到不支持此设置的版本。在升级集群服务器上的 ClickHouse 时,请小心。不要一次性升级所有服务器。在测试环境中或仅在集群的少数几台服务器上测试新版本的 ClickHouse 更为安全。 +应用 `use_minimalistic_part_header_in_zookeeper = 1` 后,您无法将 ClickHouse 服务器降级到不支持此设置的版本。在集群的服务器上升级 ClickHouse 时需谨慎。请勿一次性升级所有服务器。建议在测试环境或者仅在集群的几台服务器上测试新版本的 ClickHouse。 -已经使用此设置存储的数据部分头无法恢复到其先前的(非紧凑)表示形式。 +已使用此设置存储的数据部分头不能恢复到以前的(非紧凑)表示形式。 ::: ## user_defined_executable_functions_config {#user_defined_executable_functions_config} @@ -3484,10 +3714,10 @@ ClickHouse 对服务器上的所有表使用该设置。您可以随时更改该 路径: - 指定绝对路径或相对于服务器配置文件的路径。 -- 路径可以包含通配符 \* 和 ?。 +- 路径可以包含通配符 * 和 ?。 另见: -- "[Executable User Defined Functions](/sql-reference/functions/udf#executable-user-defined-functions)。" +- "[可执行用户定义函数](/sql-reference/functions/udf#executable-user-defined-functions)。" **示例** @@ -3496,7 +3726,7 @@ ClickHouse 对服务器上的所有表使用该设置。您可以随时更改该 ``` ## user_defined_path {#user_defined_path} -用户定义文件的目录。用于 SQL 用户定义函数 [SQL User Defined Functions](/sql-reference/functions/udf)。 +用户定义文件的目录。用于 SQL 用户定义函数 [SQL 用户定义函数](/sql-reference/functions/udf)。 **示例** @@ -3505,14 +3735,14 @@ ClickHouse 对服务器上的所有表使用该设置。您可以随时更改该 ``` ## user_directories {#user_directories} -配置文件的部分,包含设置: +包含以下设置的配置文件部分: - 预定义用户的配置文件路径。 - 存储由 SQL 命令创建的用户的文件夹路径。 - 存储和复制由 SQL 命令创建的用户的 ZooKeeper 节点路径(实验性)。 -如果该部分被指定,则将不使用 [users_config](/operations/server-configuration-parameters/settings#users_config) 和 [access_control_path](../../operations/server-configuration-parameters/settings.md#access_control_path) 中的路径。 +如果指定了此部分,则将不使用 [users_config](/operations/server-configuration-parameters/settings#users_config) 和 [access_control_path](../../operations/server-configuration-parameters/settings.md#access_control_path) 中的路径。 -`user_directories` 部分可以包含任意数量的项,项的顺序表示优先级(项越高,优先级越高)。 +`user_directories` 部分可以包含任意数量的项目,项目的顺序表示它们的优先级(项目越高,优先级越高)。 **示例** @@ -3540,14 +3770,14 @@ ClickHouse 对服务器上的所有表使用该设置。您可以随时更改该 ``` -您还可以定义 `memory` 部分 —— 仅表示在内存中存储信息,而不写入磁盘,以及 `ldap` 部分 —— 表示在 LDAP 服务器上存储信息。 +您还可以定义部分 `memory` — 意味着仅在内存中存储信息,不写入磁盘,以及 `ldap` — 意味着在 LDAP 服务器上存储信息。 -要将 LDAP 服务器作为远程用户目录添加到未在本地定义的用户中,请定义一个包含以下设置的单个 `ldap` 部分: +要将 LDAP 服务器添加为远程用户目录,以存储未在本地定义的用户,请定义单个 `ldap` 部分,并设置以下内容: -| 设置 | 描述 | -|---------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `server` | 定义在 `ldap_servers` 配置部分中的 LDAP 服务器名称之一。此参数是强制性的,不能为空。 | -| `roles` | 含有从 LDAP 服务器检索的每个用户将被赋予的本地定义角色列表的部分。如果没有指定角色,用户在身份验证后将无法执行任何操作。如果在身份验证时列出的任何角色不在本地定义,则身份验证尝试将失败,就像提供的密码不正确一样。 | +| 设置 | 描述 | +|------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `server` | 在 `ldap_servers` 配置部分中定义的 LDAP 服务器名称之一。此参数是必需的,不能为空。 | +| `roles` | 一个包含将分配给从 LDAP 服务器检索到的每个用户的本地定义角色的列表的部分。如果未指定角色,则用户在身份验证后将无法执行任何操作。如果在身份验证时列出的任何角色未在本地定义,则身份验证尝试将失败,像是提供的密码不正确。 | **示例** @@ -3562,7 +3792,7 @@ ClickHouse 对服务器上的所有表使用该设置。您可以随时更改该 ``` ## user_files_path {#user_files_path} -用户文件目录。用于表函数 [file()](../../sql-reference/table-functions/file.md)、[fileCluster()](../../sql-reference/table-functions/fileCluster.md)。 +用户文件的目录。用于表函数 [file()](../../sql-reference/table-functions/file.md)、[fileCluster()](../../sql-reference/table-functions/fileCluster.md)。 **示例** @@ -3571,7 +3801,7 @@ ClickHouse 对服务器上的所有表使用该设置。您可以随时更改该 ``` ## user_scripts_path {#user_scripts_path} -用户脚本文件的目录。用于可执行用户定义函数 [Executable User Defined Functions](/sql-reference/functions/udf#executable-user-defined-functions)。 +用户脚本文件的目录。用于可执行的用户定义函数 [可执行用户定义函数](/sql-reference/functions/udf#executable-user-defined-functions)。 **示例** @@ -3598,42 +3828,40 @@ ClickHouse 对服务器上的所有表使用该设置。您可以随时更改该 ``` ## validate_tcp_client_information {#validate_tcp_client_information} -确定在接收查询数据包时是否启用客户端信息验证。 +确定在接收到查询数据包时是否启用客户端信息验证。 -默认情况下,设置为 `false`: +默认情况下,它是 `false`: ```xml false ``` ## vector_similarity_index_cache_max_entries {#vector_similarity_index_cache_max_entries} -向量相似度索引的缓存大小,以条目计。零表示禁用。 +向量相似性索引的缓存大小(以条目计)。零表示禁用。 ## vector_similarity_index_cache_policy {#vector_similarity_index_cache_policy} -向量相似度索引的缓存策略名称。 +向量相似性索引缓存策略名称。 ## vector_similarity_index_cache_size {#vector_similarity_index_cache_size} -向量相似度索引的缓存大小。零表示禁用。 +向量相似性索引的缓存大小。零表示禁用。 :::note 此设置可以在运行时修改,并将立即生效。 ::: ## vector_similarity_index_cache_size_ratio {#vector_similarity_index_cache_size_ratio} -向量相似度索引缓存中受保护队列的大小(在使用SLRU策略的情况下),相对于缓存的总大小。 +向量相似性索引缓存中受保护队列的大小(在 SLRU 策略下)相对于缓存的总大小。 ## wait_dictionaries_load_at_startup {#wait_dictionaries_load_at_startup} 此设置允许指定当 `dictionaries_lazy_load` 为 `false` 时的行为。 (如果 `dictionaries_lazy_load` 为 `true`,此设置将不影响任何内容。) -如果 `wait_dictionaries_load_at_startup` 为 `false`,则服务器将在启动时开始加载所有字典,并将在加载期间接收连接。 -当在查询中首次使用字典时,如果字典尚未加载,则查询将在字典加载完成之前等待。 -将 `wait_dictionaries_load_at_startup` 设置为 `false` 可以加快 ClickHouse 启动,但某些查询的执行速度可能会变慢 -(因为它们将不得不等待某些字典加载)。 +如果 `wait_dictionaries_load_at_startup` 为 `false`,则服务器会在启动时开始加载所有字典,并且在加载期间将接收连接。 +当查询首次使用字典时,如果字典尚未加载,查询将会等待字典加载完成。 +将 `wait_dictionaries_load_at_startup` 设置为 `false` 可以让 ClickHouse 启动更快,但某些查询可能会执行得更慢(因为它们将不得不等待某些字典加载)。 -如果 `wait_dictionaries_load_at_startup` 为 `true`,则服务器将在启动时等待 -直到所有字典完成加载(无论成功与否)后再接收任何连接。 +如果 `wait_dictionaries_load_at_startup` 为 `true`,那么服务器将在启动时等待所有字典完成加载(无论成功与否)后再接收任何连接。 **示例** @@ -3642,7 +3870,7 @@ ClickHouse 对服务器上的所有表使用该设置。您可以随时更改该 ``` ## workload_path {#workload_path} -用作所有 `CREATE WORKLOAD` 和 `CREATE RESOURCE` 查询存储的目录。默认情况下使用服务器工作目录下的 `/workload/` 文件夹。 +用作存储所有 `CREATE WORKLOAD` 和 `CREATE RESOURCE` 查询的目录。默认情况下使用服务器工作目录下的 `/workload/` 文件夹。 **示例** @@ -3651,11 +3879,11 @@ ClickHouse 对服务器上的所有表使用该设置。您可以随时更改该 ``` **另见** -- [工作负载层次结构](/operations/workload-scheduling.md#workloads) +- [工作负载层次](/operations/workload-scheduling.md#workloads) - [workload_zookeeper_path](#workload_zookeeper_path) ## workload_zookeeper_path {#workload_zookeeper_path} -存储所有 `CREATE WORKLOAD` 和 `CREATE RESOURCE` 查询的 ZooKeeper 节点的路径。为了一致性,所有 SQL 定义都存储为这个单一 znode 的值。默认情况下,不使用 ZooKeeper,定义存储在 [disk](#workload_path)。 +用于存储所有 `CREATE WORKLOAD` 和 `CREATE RESOURCE` 查询的 ZooKeeper 节点路径。为了确保一致性,所有 SQL 定义都作为此单一 znode 的值存储。默认情况下不使用 ZooKeeper,定义存储在 [disk](#workload_path)。 **示例** @@ -3664,35 +3892,35 @@ ClickHouse 对服务器上的所有表使用该设置。您可以随时更改该 ``` **另见** -- [工作负载层次结构](/operations/workload-scheduling.md#workloads) +- [工作负载层次](/operations/workload-scheduling.md#workloads) - [workload_path](#workload_path) ## zookeeper {#zookeeper} -包含允许 ClickHouse 与 [ZooKeeper](http://zookeeper.apache.org/) 集群交互的设置。当使用复制表时,ClickHouse 使用 ZooKeeper 存储副本的元数据。如果不使用复制表,则可以省略此参数部分。 - -以下设置可以通过子标签配置: +包含允许 ClickHouse 与 [ZooKeeper](http://zookeeper.apache.org/) 集群交互的设置。ClickHouse 在使用复制表时使用 ZooKeeper 存储副本的元数据。如果未使用复制表,则可以省略此参数部分。 -| 设置 | 描述 | -|----------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `node` | ZooKeeper 端点。您可以设置多个端点。例如:`example_host2181`。`index` 属性指定在尝试连接到 ZooKeeper 集群时的节点顺序。 | -| `session_timeout_ms` | 客户端会话的最大超时,以毫秒为单位。 | -| `operation_timeout_ms` | 单个操作的最大超时,以毫秒为单位。 | -| `root`(可选) | 用作 ClickHouse 服务器使用的 znodes 的根的 znode。 | -| `fallback_session_lifetime.min`(可选) | 当主节点不可用时,转向节点的 ZooKeeper 会话的最小生存时间限制(负载均衡)。以秒为单位。默认:3 小时。 | -| `fallback_session_lifetime.max`(可选) | 当主节点不可用时,转向节点的 ZooKeeper 会话的最大生存时间限制(负载均衡)。以秒为单位。默认:6 小时。 | -| `identity`(可选) | ZooKeeper 访问请求的 znodes 所需的用户和密码。 | -| `use_compression`(可选) | 如果设置为 true,则在 Keeper 协议中启用压缩。 | - -还有 `zookeeper_load_balancing` 设置(可选),它允许您选择 ZooKeeper 节点选择的算法: +可以通过子标签配置以下设置: -| 算法名称 | 描述 | -|------------------------------|------------------------------------------------------------------------------------------------------------------------| -| `random` | 随机选择一个 ZooKeeper 节点。 | -| `in_order` | 选择第一个 ZooKeeper 节点,如果不可用则选择第二个,以此类推。 | -| `nearest_hostname` | 选择与服务器主机名最相似的 ZooKeeper 节点,主机名与名称前缀进行比较。 | -| `hostname_levenshtein_distance` | 就像 nearest_hostname,但它以 levenshtein 距离方式比较主机名。 | -| `first_or_random` | 选择第一个 ZooKeeper 节点,如果不可用则随机选择剩余的 ZooKeeper 节点中的一个。 | -| `round_robin` | 选择第一个 ZooKeeper 节点,如果发生重新连接,则选择下一个。 | +| 设置 | 描述 | +|-------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `node` | ZooKeeper 端点。您可以设置多个端点。例如,`example_host2181`。`index` 属性指定尝试连接到 ZooKeeper 集群时的节点顺序。 | +| `session_timeout_ms` | 客户端会话的最大超时(以毫秒为单位)。 | +| `operation_timeout_ms` | 单个操作的最大超时(以毫秒为单位)。 | +| `root`(可选) | 用作 ClickHouse 服务器使用的 znodes 根的 znode。 | +| `fallback_session_lifetime.min`(可选) | 在主服务器不可用时,备用节点的 ZooKeeper 会话的最小生命周期限制(负载均衡)。以秒为单位设置。默认:3 小时。 | +| `fallback_session_lifetime.max`(可选) | 在主服务器不可用时,备用节点的 ZooKeeper 会话的最大生命周期限制(负载均衡)。以秒为单位设置。默认:6 小时。 | +| `identity`(可选) | ZooKeeper 访问请求的 znodes 所需的用户和密码。 | +| `use_compression`(可选) | 如果设置为 true,则启用 Keeper 协议中的压缩。 | + +还有 `zookeeper_load_balancing` 设置(可选),允许您选择 ZooKeeper 节点选择的算法: + +| 算法名称 | 描述 | +|-----------------------------|------------------------------------------------------------------------------------------------------------------------| +| `random` | 随机选择一个 ZooKeeper 节点。 | +| `in_order` | 选择第一个 ZooKeeper 节点,如果不可用则选择第二个,以此类推。 | +| `nearest_hostname` | 选择与服务器主机名最相似的 ZooKeeper 节点,主机名通过名称前缀进行比较。 | +| `hostname_levenshtein_distance` | 类似于 nearest_hostname,但以 levenshtein 距离方式比较主机名。 | +| `first_or_random` | 选择第一个 ZooKeeper 节点,如果不可用则随机选择剩余的一个 ZooKeeper 节点。 | +| `round_robin` | 选择第一个 ZooKeeper 节点,如果重新连接,则选择下一个节点。 | **示例配置** @@ -3721,4 +3949,4 @@ ClickHouse 对服务器上的所有表使用该设置。您可以随时更改该 - [复制](../../engines/table-engines/mergetree-family/replication.md) - [ZooKeeper 程序员指南](http://zookeeper.apache.org/doc/current/zookeeperProgrammers.html) -- [ClickHouse 和 Zookeeper 之间的可选安全通信](/operations/ssl-zookeeper) +- [ClickHouse 与 Zookeeper 之间的可选安全通信](/operations/ssl-zookeeper) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/server-configuration-parameters/settings.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/server-configuration-parameters/settings.md.hash index d15653d83a3..955c058ca3b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/server-configuration-parameters/settings.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/server-configuration-parameters/settings.md.hash @@ -1 +1 @@ -d201487d238c5d0f +d5f784efbdaad48c diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/composable-protocols.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/composable-protocols.md index 212f83d7972..7a8586ee781 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/composable-protocols.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/composable-protocols.md @@ -1,9 +1,10 @@ --- -'description': '可组合协议允许更灵活地配置 TCP 访问 ClickHouse 服务器。' +'description': '可组合协议允许更灵活地配置对ClickHouse服务器的TCP访问。' 'sidebar_label': '可组合协议' 'sidebar_position': 64 'slug': '/operations/settings/composable-protocols' 'title': '可组合协议' +'doc_type': 'reference' --- @@ -11,11 +12,11 @@ ## 概述 {#overview} -可组合协议允许更灵活地配置对 ClickHouse 服务器的 TCP 访问。此配置可以与常规配置共存或替代。 +可组合协议允许对ClickHouse服务器的TCP访问进行更灵活的配置。该配置可以与传统配置共存或替代它。 ## 配置可组合协议 {#composable-protocols-section-is-denoted-as-protocols-in-configuration-xml} -可组合协议可以在 XML 配置文件中配置。协议部分用 `protocols` 标签在 XML 配置文件中表示: +可组合协议可以在XML配置文件中进行配置。协议部分由`protocols`标签在XML配置文件中表示: ```xml @@ -25,7 +26,7 @@ ### 配置协议层 {#basic-modules-define-protocol-layers} -您可以使用基本模块定义协议层。例如,要定义 HTTP 层,您可以向 `protocols` 部分添加一个新的基本模块: +您可以使用基本模块定义协议层。例如,要定义HTTP层,您可以向`protocols`部分添加一个新的基本模块: ```xml @@ -39,26 +40,26 @@ ``` 模块可以根据以下内容进行配置: -- `plain_http` - 可以被另一个层引用的名称 +- `plain_http` - 可以被其他层引用的名称 - `type` - 表示将实例化以处理数据的协议处理程序。 - 它有以下预定义的协议处理程序集: - * `tcp` - 本地 ClickHouse 协议处理程序 - * `http` - HTTP ClickHouse 协议处理程序 - * `tls` - TLS 加密层 - * `proxy1` - PROXYv1 层 - * `mysql` - MySQL 兼容协议处理程序 - * `postgres` - PostgreSQL 兼容协议处理程序 - * `prometheus` - Prometheus 协议处理程序 - * `interserver` - ClickHouse 服务器间处理程序 + 它具有以下预定义的协议处理程序集: + * `tcp` - 原生ClickHouse协议处理程序 + * `http` - HTTP ClickHouse协议处理程序 + * `tls` - TLS加密层 + * `proxy1` - PROXYv1层 + * `mysql` - MySQL兼容协议处理程序 + * `postgres` - PostgreSQL兼容协议处理程序 + * `prometheus` - Prometheus协议处理程序 + * `interserver` - ClickHouse跨服务器处理程序 :::note -`gRPC` 协议处理程序未为 `Composable protocols` 实现 +`gRPC`协议处理程序未为`可组合协议`实现 ::: - + ### 配置端点 {#endpoint-ie-listening-port-is-denoted-by-port-and-optional-host-tags} -端点(监听端口)用 `` 和可选的 `` 标签表示。 -例如,要在之前添加的 HTTP 层上配置一个端点,我们可以按如下方式修改我们的配置: +端点(监听端口)由``和可选的``标签表示。 +例如,要配置前面添加的HTTP层上的端点,我们可以如下修改我们的配置: ```xml @@ -75,12 +76,11 @@ ``` -如果省略 `` 标签,则使用根配置中的 ``。 +如果省略``标签,则使用根配置中的``。 ### 配置层序列 {#layers-sequence-is-defined-by-impl-tag-referencing-another-module} -层序列由 `` 标签定义,并引用另一个模块。 -例如,要在我们的 plain_http 模块上配置一个 TLS 层,我们可以进一步按如下方式修改我们的配置: +层序列通过``标签定义,并引用另一个模块。例如,要在我们的plain_http模块之上配置一个TLS层,我们可以进一步修改我们的配置如下: ```xml @@ -103,7 +103,7 @@ ### 将端点附加到层 {#endpoint-can-be-attached-to-any-layer} -端点可以附加到任何层。例如,我们可以为 HTTP(端口 8123)和 HTTPS(端口 8443)定义端点: +端点可以附加到任何层。例如,我们可以为HTTP(端口8123)和HTTPS(端口8443)定义端点: ```xml @@ -124,9 +124,9 @@ ``` -### 定义附加端点 {#additional-endpoints-can-be-defined-by-referencing-any-module-and-omitting-type-tag} +### 定义额外的端点 {#additional-endpoints-can-be-defined-by-referencing-any-module-and-omitting-type-tag} -可以通过引用任何模块并省略 `` 标签定义附加端点。例如,我们可以为 `plain_http` 模块定义 `another_http` 端点,如下所示: +可以通过引用任何模块并省略``标签定义额外的端点。例如,我们可以为`plain_http`模块定义`another_http`端点,如下所示: ```xml @@ -153,9 +153,9 @@ ``` -### 指定附加层参数 {#some-modules-can-contain-specific-for-its-layer-parameters} +### 指定额外的层参数 {#some-modules-can-contain-specific-for-its-layer-parameters} -某些模块可以包含附加层参数。例如,TLS 层允许指定私钥(`privateKeyFile`)和证书文件(`certificateFile`),具体如下: +某些模块可以包含特定于其层的附加参数。例如,TLS层允许指定私钥(`privateKeyFile`)和证书文件(`certificateFile`),如下所示: ```xml diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/composable-protocols.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/composable-protocols.md.hash index 899a1b6fc42..a5da7c5bee4 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/composable-protocols.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/composable-protocols.md.hash @@ -1 +1 @@ -66666415a3b36e26 +bd084a80c6769673 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/constraints-on-settings.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/constraints-on-settings.md index 9d09359ac88..b2cacc5a0ce 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/constraints-on-settings.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/constraints-on-settings.md @@ -4,18 +4,19 @@ 'sidebar_position': 62 'slug': '/operations/settings/constraints-on-settings' 'title': '对设置的约束' +'doc_type': 'reference' --- -# 设置约束 +# 对设置的约束 ## 概述 {#overview} -在 ClickHouse 中,设置上的“约束”是指可以分配给设置的限制和规则。这些约束可以应用于维护数据库的稳定性、安全性和可预测性行为。 +在 ClickHouse 中,"对设置的约束" 指的是可以赋予设置的限制和规则。这些约束可以用于维护数据库的稳定性、安全性和可预测性行为。 ## 定义约束 {#defining-constraints} -设置上的约束可以在 `user.xml` 配置文件的 `profiles` 部分定义。它们禁止用户通过 [`SET`](/sql-reference/statements/set) 语句更改某些设置。 +对设置的约束可以在 `user.xml` 配置文件的 `profiles` 部分定义。它们禁止用户通过 [`SET`](/sql-reference/statements/set) 语句更改某些设置。 约束的定义如下: @@ -56,25 +57,25 @@ 如果用户试图违反这些约束,将抛出异常,并且设置保持不变。 -## 约束的类型 {#types-of-constraints} +## 约束类型 {#types-of-constraints} ClickHouse 支持几种类型的约束: - `min` - `max` - `disallowed` -- `readonly`(别名为 `const`) +- `readonly`(别名 `const`) - `changeable_in_readonly` -`min` 和 `max` 约束指定数值设置的上下限,并且可以彼此结合使用。 +`min` 和 `max` 约束指定数值设置的上下界,并且可以组合使用。 -`disallowed` 约束可以用于指定特定的值,这些值不应允许用于特定的设置。 +`disallowed` 约束用于指定特定的值,这些值不应该被允许用于特定的设置。 -`readonly` 或 `const` 约束指定用户无法更改相应的设置。 +`readonly` 或 `const` 约束指定用户根本不能更改相应的设置。 -`changeable_in_readonly` 约束类型允许用户在 `min`/`max` 范围内更改设置,即使 `readonly` 设置为 `1`,否则在 `readonly=1` 模式下不允许更改设置。 +`changeable_in_readonly` 约束类型允许用户在 `readonly` 设置为 `1` 的情况下在 `min`/`max` 范围内更改设置,否则在 `readonly=1` 模式下不允许更改设置。 :::note -`changeable_in_readonly` 仅在启用 `settings_constraints_replace_previous` 时受支持: +`changeable_in_readonly` 仅在启用 `settings_constraints_replace_previous` 的情况下支持: ```xml @@ -83,18 +84,18 @@ ClickHouse 支持几种类型的约束: ``` ::: -## 多个约束配置文件 {#multiple-constraint-profiles} +## 多重约束配置文件 {#multiple-constraint-profiles} -如果用户有多个活动的配置文件,则约束会合并。合并过程取决于 `settings_constraints_replace_previous`: -- **true**(推荐):在合并期间替换相同设置的约束,以便使用最后一个约束,并忽略所有先前的约束。这包括在新约束中未设置的字段。 -- **false**(默认):以某种方式合并相同设置的约束,每个未设置的约束类型来自先前的配置文件,而每个设置的约束类型由新配置文件的值替换。 +如果一个用户同时激活多个配置文件,那么约束会被合并。合并过程依赖于 `settings_constraints_replace_previous`: +- **true**(推荐):同一设置的约束在合并过程中被替换,最后的约束被使用,所有先前的约束被忽略。这包括在新约束中未设置的字段。 +- **false**(默认):同一设置的约束以这种方式合并:每一种未设置的约束来自先前的配置文件,而每一种已设置的约束则由新配置文件中的值替换。 ## 只读模式 {#read-only} -只读模式由 `readonly` 设置启用,不应与 `readonly` 约束类型混淆: +只读模式由 `readonly` 设置启用,不要与 `readonly` 约束类型混淆: - `readonly=0`:没有只读限制。 -- `readonly=1`:仅允许读取查询,无法更改设置,除非设置了 `changeable_in_readonly`。 -- `readonly=2`:仅允许读取查询,但可以更改设置,除了 `readonly` 设置本身。 +- `readonly=1`:仅允许读查询,除非设置 `changeable_in_readonly`,否则无法更改设置。 +- `readonly=2`:仅允许读查询,但可以更改设置,除了 `readonly` 设置本身。 ### 示例 {#example-read-only} @@ -119,7 +120,7 @@ ClickHouse 支持几种类型的约束: ``` -以下查询将全部抛出异常: +以下查询将抛出异常: ```sql SET max_memory_usage=20000000001; @@ -134,18 +135,18 @@ Code: 452, e.displayText() = DB::Exception: Setting force_index_by_date should n ``` :::note -`default` 配置文件的处理方式是独特的:为 `default` 配置文件定义的所有约束成为默认约束,因此它们限制所有用户,直到为那些用户显式覆盖这些约束。 +`default` 配置文件的处理是独特的:为 `default` 配置文件定义的所有约束都成为默认约束,因此它们限制所有用户,直到明确为这些用户覆盖。 ::: ## MergeTree 设置的约束 {#constraints-on-merge-tree-settings} -可以为 [merge tree settings](merge-tree-settings.md) 设置约束。这些约束在创建具有 MergeTree 引擎的表时或更改其存储设置时应用。 +可以为 [merge tree 设置](merge-tree-settings.md) 设置约束。当创建带有 MergeTree 引擎的表或其存储设置被更改时,这些约束会生效。 -引用合并树设置时,合并树设置的名称必须以 `merge_tree_` 前缀开头,在 `` 部分中。 +在 `` 部分引用 MergeTree 设置时,设置名称必须带上 `merge_tree_` 前缀。 ### 示例 {#example-mergetree} -您可以禁止使用显式指定的 `storage_policy` 创建新表。 +您可以禁止显式指定 `storage_policy` 创建新表。 ```xml diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/constraints-on-settings.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/constraints-on-settings.md.hash index 679b45b9ff1..8a02f2d614d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/constraints-on-settings.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/constraints-on-settings.md.hash @@ -1 +1 @@ -053e384ab56cd6a0 +44c42224738ecb61 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/index.md index 7410ff1f64d..bcc8fa102d4 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/index.md @@ -3,6 +3,7 @@ 'sidebar_position': 1 'slug': '/operations/settings/' 'title': '设置' +'doc_type': 'landing-page' --- + + +| 页面 | 描述 | +|-----|-----| +| [设置概览](/operations/settings/overview) | 设置的概览页面。 | +| [查询权限](/operations/settings/permissions-for-queries) | 查询权限的设置。 | +| [查询复杂性限制](/operations/settings/query-complexity) | 限制查询复杂性的设置。 | +| [设置配置文件](/operations/settings/settings-profiles) | 一组以相同名称分组的设置。 | +| [设置约束](/operations/settings/constraints-on-settings) | 设置约束可以在`user.xml`配置文件的`profiles`部分定义,禁止用户通过`SET`查询更改某些设置。 | +| [用户和角色设置](/operations/settings/settings-users) | 配置用户和角色的设置。 | +| [组合协议](/operations/settings/composable-protocols) | 组合协议允许更灵活地配置对ClickHouse服务器的TCP访问。 | +| [格式设置](/operations/settings/formats) | 控制输入和输出格式的设置。 | +| [内存过度分配](/operations/settings/memory-overcommit) | 一种实验性技术,旨在允许为查询设置更灵活的内存限制。 | +| [MergeTree表设置](/operations/settings/merge-tree-settings) | MergeTree的设置,位于`system.merge_tree_settings`中。 | +| [查询级会话设置](/operations/settings/query-level) | 查询级别的设置。 | +| [服务器过载](/operations/settings/server-overload) | 控制服务器CPU过载时的行为。 | +| [会话设置](/operations/settings/settings) | 在``system.settings``表中找到的设置。 | +| [TCP连接限制](/operations/settings/tcp-connection-limits) | TCP连接限制。 | + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/index.md.hash index 8d3fd9e269f..d72e75c70f7 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/index.md.hash @@ -1 +1 @@ -9b2744c128125647 +583f61183e867f6f diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/memory-overcommit.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/memory-overcommit.md index 7ef6e07161b..d82ac0a167e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/memory-overcommit.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/memory-overcommit.md @@ -1,27 +1,33 @@ --- 'description': '一种实验性技术,旨在允许为查询设置更灵活的内存限制。' 'slug': '/operations/settings/memory-overcommit' -'title': '内存过量承诺' +'title': '内存超分配' +'doc_type': 'reference' --- -# 内存过度分配 +# 内存超分配 -内存过度分配是一种实验性技术,旨在允许为查询设置更灵活的内存限制。 +内存超分配是一种实验性技术,旨在允许为查询设置更灵活的内存限制。 -该技术的想法是引入一些设置,表示查询可以使用的保证内存量。当启用内存过度分配并达到内存限制时,ClickHouse 将选择最过度分配的查询并尝试通过终止该查询释放内存。 +这种技术的想法是引入能够表示查询可以使用的保证内存量的设置。 +当启用内存超分配且达到内存限制时,ClickHouse 将选择最超分配的查询,并尝试通过终止该查询来释放内存。 -当达到内存限制时,任何查询在尝试分配新内存时都会等待一段时间。如果超时过去并且内存被释放,查询将继续执行。否则,将抛出异常并终止查询。 +当达到内存限制时,任何查询在尝试分配新内存时都会等待一段时间。 +如果超时已过且内存被释放,则查询继续执行。 +否则,将抛出异常并终止该查询。 -停止或杀死查询的选择由全局或用户过度分配跟踪器执行,具体取决于达到的内存限制。如果过度分配跟踪器无法选择要停止的查询,则会抛出 MEMORY_LIMIT_EXCEEDED 异常。 +停止或终止查询的选择由全局或用户超分配跟踪器执行,具体取决于达到的内存限制。 +如果超分配跟踪器无法选择要停止的查询,则将抛出 MEMORY_LIMIT_EXCEEDED 异常。 -## 用户过度分配跟踪器 {#user-overcommit-tracker} +## 用户超分配跟踪器 {#user-overcommit-tracker} -用户过度分配跟踪器会在用户的查询列表中找到过度分配比例最大的查询。查询的过度分配比例计算为已分配字节数除以 `memory_overcommit_ratio_denominator_for_user` 设置的值。 +用户超分配跟踪器在用户的查询列表中找到超分配比率最大的查询。 +查询的超分配比率是通过已分配字节数除以设置 `memory_overcommit_ratio_denominator_for_user` 的值来计算的。 -如果查询的 `memory_overcommit_ratio_denominator_for_user` 等于零,过度分配跟踪器不会选择此查询。 +如果查询的 `memory_overcommit_ratio_denominator_for_user` 等于零,则超分配跟踪器不会选择此查询。 -等待超时由 `memory_usage_overcommit_max_wait_microseconds` 设置。 +等待超时时间由设置 `memory_usage_overcommit_max_wait_microseconds` 设定。 **示例** @@ -29,10 +35,11 @@ SELECT number FROM numbers(1000) GROUP BY number SETTINGS memory_overcommit_ratio_denominator_for_user=4000, memory_usage_overcommit_max_wait_microseconds=500 ``` -## 全局过度分配跟踪器 {#global-overcommit-tracker} +## 全局超分配跟踪器 {#global-overcommit-tracker} -全局过度分配跟踪器会在所有查询的列表中找到过度分配比例最大的查询。在这种情况下,过度分配比例计算为已分配字节数除以 `memory_overcommit_ratio_denominator` 设置的值。 +全局超分配跟踪器在所有查询的列表中找到超分配比率最大的查询。 +在这种情况下,超分配比率是通过已分配字节数除以设置 `memory_overcommit_ratio_denominator` 的值来计算的。 -如果查询的 `memory_overcommit_ratio_denominator` 等于零,过度分配跟踪器不会选择此查询。 +如果查询的 `memory_overcommit_ratio_denominator` 等于零,则超分配跟踪器不会选择此查询。 -等待超时由配置文件中的 `memory_usage_overcommit_max_wait_microseconds` 参数设置。 +等待超时时间由配置文件中的参数 `memory_usage_overcommit_max_wait_microseconds` 设定。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/memory-overcommit.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/memory-overcommit.md.hash index 24b472f548a..9a5c000c6c5 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/memory-overcommit.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/memory-overcommit.md.hash @@ -1 +1 @@ -529be35f0a245391 +a49847ee81e73d49 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/merge-tree-settings.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/merge-tree-settings.md index 7b82b00b458..d84218d7239 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/merge-tree-settings.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/merge-tree-settings.md @@ -2,6 +2,7 @@ 'description': '在 `system.merge_tree_settings` 中的 MergeTree 设置' 'slug': '/operations/settings/merge-tree-settings' 'title': 'MergeTree 表设置' +'doc_type': 'reference' --- import ExperimentalBadge from '@theme/badges/ExperimentalBadge'; @@ -9,11 +10,11 @@ import BetaBadge from '@theme/badges/BetaBadge'; import SettingsInfoBlock from '@theme/SettingsInfoBlock/SettingsInfoBlock'; import VersionHistory from '@theme/VersionHistory/VersionHistory'; -系统表 `system.merge_tree_settings` 显示了全局设置的 MergeTree 设置。 +系统表 `system.merge_tree_settings` 显示全局设置的 MergeTree 设置。 -MergeTree 设置可以在服务器配置文件的 `merge_tree` 部分设置,也可以在 `CREATE TABLE` 语句的 `SETTINGS` 子句中单独为每个 `MergeTree` 表指定。 +可以在服务器配置文件的 `merge_tree` 部分中设置 MergeTree 设置,或者在 `CREATE TABLE` 语句的 `SETTINGS` 子句中为每个 `MergeTree` 表单独指定。 -定制设置 `max_suspicious_broken_parts` 的示例: +自定义设置 `max_suspicious_broken_parts` 的示例: 在服务器配置文件中配置所有 `MergeTree` 表的默认值: @@ -44,44 +45,49 @@ ALTER TABLE tab MODIFY SETTING max_suspicious_broken_parts = 100; ALTER TABLE tab RESET SETTING max_suspicious_broken_parts; ``` ## MergeTree settings {#mergetree-settings} - ## adaptive_write_buffer_initial_size {#adaptive_write_buffer_initial_size} -自适应写入缓冲区的初始大小 +自适应写缓冲区的初始大小 ## add_implicit_sign_column_constraint_for_collapsing_engine {#add_implicit_sign_column_constraint_for_collapsing_engine} -如果为真,则为 CollapsingMergeTree 或 VersionedCollapsingMergeTree 表的 `sign` 列添加隐式约束,以仅允许有效值(`1` 和 `-1`)。 +如果为真,则为 CollapsingMergeTree 或 VersionedCollapsingMergeTree 表的 `sign` 列添加隐式约束,仅允许有效值 (`1` 和 `-1`)。 ## add_minmax_index_for_numeric_columns {#add_minmax_index_for_numeric_columns} -启用时,会为表的所有数值列添加最小-最大(跳过)索引。 +启用时,将为表的所有数值列添加最小-最大(跳过)索引。 ## add_minmax_index_for_string_columns {#add_minmax_index_for_string_columns} -启用时,会为表的所有字符串列添加最小-最大(跳过)索引。 +启用时,将为表的所有字符串列添加最小-最大(跳过)索引。 +## allow_coalescing_columns_in_partition_or_order_key {#allow_coalescing_columns_in_partition_or_order_key} + + + +启用时,允许在 CoalescingMergeTree 表中使用合并列作为分区或排序键。 ## allow_experimental_replacing_merge_with_cleanup {#allow_experimental_replacing_merge_with_cleanup} -允许使用 `is_deleted` 列的 ReplacingMergeTree 的实验性清理合并。启用时,允许使用 `OPTIMIZE ... FINAL CLEANUP` 手动将分区中的所有部分合并为单一部分,并删除任何已删除行。 +允许对带有 `is_deleted` 列的 ReplacingMergeTree 进行实验性清理合并。启用后,允许使用 `OPTIMIZE ... FINAL CLEANUP` 手动将分区中的所有部分合并为单个部分,并删除任何已删除的行。 -还允许通过设置 `min_age_to_force_merge_seconds`、`min_age_to_force_merge_on_partition_only` 和 `enable_replacing_merge_with_cleanup_for_min_age_to_force_merge` 在后台自动进行此类合并。 +还允许通过设置 `min_age_to_force_merge_seconds`、`min_age_to_force_merge_on_partition_only` 和 `enable_replacing_merge_with_cleanup_for_min_age_to_force_merge` 在后台自动执行这样的合并。 ## allow_experimental_reverse_key {#allow_experimental_reverse_key} -启用在 MergeTree 排序键中支持降序排序。此设置对于时间序列分析和 Top-N 查询特别有用,允许数据按逆时间顺序存储,以优化查询性能。 +启用对 MergeTree 排序键的降序排序支持。此设置在时间序列分析和 Top-N 查询中特别有用,允许数据按逆时间顺序存储以优化查询性能。 -启用 `allow_experimental_reverse_key` 后,您可以在 MergeTree 表的 `ORDER BY` 子句中定义降序排序。这使得在降序查询中可以使用更有效的 `ReadInOrder` 优化,而不是 `ReadInReverseOrder`。 +启用 `allow_experimental_reverse_key` 后,可以在 MergeTree 表的 `ORDER BY` 子句中定义降序排序。这使得在降序查询时可以使用更高效的 `ReadInOrder` 优化,而不是 `ReadInReverseOrder`。 **示例** @@ -98,41 +104,47 @@ SETTINGS allow_experimental_reverse_key = 1; SELECT * FROM example WHERE key = 'xxx' ORDER BY time DESC LIMIT 10; ``` -通过在查询中使用 `ORDER BY time DESC`,应用了 `ReadInOrder`。 +通过在查询中使用 `ORDER BY time DESC`,将应用 `ReadInOrder`。 -**默认值:** false +**默认值:** false ## allow_floating_point_partition_key {#allow_floating_point_partition_key} -允许浮点数作为分区键。 +启用允许浮点数作为分区键。 可能的值: -- `0` — 不允许浮点分区键。 -- `1` — 允许浮点分区键。 +- `0` — 不允许使用浮点数分区键。 +- `1` — 允许使用浮点数分区键。 ## allow_nullable_key {#allow_nullable_key} 允许 Nullable 类型作为主键。 +## allow_part_offset_column_in_projections {#allow_part_offset_column_in_projections} + + + +允许在投影选择查询中使用 `_part_offset` 列。 ## allow_reduce_blocking_parts_task {#allow_reduce_blocking_parts_task} -减少共享合并树表的阻塞部分的后台任务。仅在 ClickHouse Cloud 中可用 +减少共享合并树表的阻塞部分的后台任务。 +仅在 ClickHouse Cloud 中 ## allow_remote_fs_zero_copy_replication {#allow_remote_fs_zero_copy_replication} - + -请勿在生产中使用此设置,因为它尚未准备好。 +在生产中不要使用此设置,因为尚未准备好。 ## allow_summing_columns_in_partition_or_order_key {#allow_summing_columns_in_partition_or_order_key} -启用时,允许在 SummingMergeTree 表中的求和列用于分区或排序键。 +启用时,允许在 SummingMergeTree 表中将求和列用于分区或排序键。 ## allow_suspicious_indices {#allow_suspicious_indices} -拒绝具有相同表达式的主索引/辅助索引和排序键。 +拒绝具有相同表达式的主/次索引和排序键 ## allow_vertical_merges_from_compact_to_wide_parts {#allow_vertical_merges_from_compact_to_wide_parts} @@ -140,35 +152,36 @@ SELECT * FROM example WHERE key = 'xxx' ORDER BY time DESC LIMIT 10; ## always_fetch_merged_part {#always_fetch_merged_part} -如果为真,则此副本从不合并部分,而是始终从其他副本下载合并后的部分。 +如果为真,则该副本永远不会合并部分,并始终从其他副本下载合并部分。 可能的值: - true, false ## always_use_copy_instead_of_hardlinks {#always_use_copy_instead_of_hardlinks} -在变更/替换/分离等操作中始终复制数据而不是硬链接。 +在变更/替换/分离等操作期间始终复制数据,而不是使用硬链接。 ## apply_patches_on_merge {#apply_patches_on_merge} -如果为真,则在合并时应用补丁部分。 +如果为真,则在合并时将应用补丁部分。 ## assign_part_uuids {#assign_part_uuids} -启用时,将为每个新部分分配唯一的部分标识符。在启用之前,请检查所有副本是否支持 UUID 版本 4。 +启用时,将为每个新部分分配唯一部分标识符。 +启用前,请检查所有副本是否支持 UUID 版本 4。 ## async_block_ids_cache_update_wait_ms {#async_block_ids_cache_update_wait_ms} -每次插入迭代将等待 async_block_ids_cache 更新的时间。 +每次插入迭代将等待异步 block_ids_cache 更新的时间。 ## async_insert {#async_insert} -如果为真,则来自 INSERT 查询的数据存储在队列中,稍后在后台刷新到表中。 +如果为真,INSERT 查询中的数据将存储在队列中,并在后台刷新到表中。 ## background_task_preferred_step_execution_time_ms {#background_task_preferred_step_execution_time_ms} -合并或变更一步的目标执行时间。如果一步所需时间较长,则可以超出此时间。 +合并或变更一步的目标执行时间。如果一步花费的时间过长,可以超出此限制。 ## cache_populated_by_fetch {#cache_populated_by_fetch} @@ -176,11 +189,11 @@ SELECT * FROM example WHERE key = 'xxx' ORDER BY time DESC LIMIT 10; 此设置仅适用于 ClickHouse Cloud。 ::: -当禁用 `cache_populated_by_fetch`(默认设置)时,仅当执行需要这些部分的查询时,新数据部分才会加载到缓存中。 +当 `cache_populated_by_fetch` 被禁用(默认设置)时,仅当运行需要这些部分的查询时,新的数据部分才会加载到缓存中。 -如果启用,`cache_populated_by_fetch` 将导致所有节点将新数据部分从存储加载到其缓存中,而无需查询作为触发此操作的条件。 +如果启用,`cache_populated_by_fetch` 将导致所有节点在不需要查询触发此操作的情况下,从存储中将新数据部分加载到其缓存中。 -**另请参见** +**另见** - [ignore_cold_parts_seconds](/operations/settings/settings#ignore_cold_parts_seconds) - [prefer_warmed_unmerged_parts_seconds](/operations/settings/settings#prefer_warmed_unmerged_parts_seconds) @@ -193,14 +206,14 @@ SELECT * FROM example WHERE key = 'xxx' ORDER BY time DESC LIMIT 10; 此设置仅适用于 ClickHouse Cloud。 ::: -如果不为空,则仅与此正则表达式匹配的文件在获取后会预热到缓存中(如果启用 `cache_populated_by_fetch`)。 +如果不为空,则仅会在抓取后进行预热的文件符合此正则表达式(如果启用 `cache_populated_by_fetch`)。 ## check_delay_period {#check_delay_period} -过时设置,不执行任何操作。 +已过时设置,无任何作用。 ## check_sample_column_is_correct {#check_sample_column_is_correct} -启用在表创建时检查采样列或采样表达式的数据类型是否正确。数据类型必须为无符号的 +在表创建时启用,对采样列或采样表达式的数据类型进行检查。数据类型必须是无符号 [整数类型](/sql-reference/data-types/int-uint):`UInt8`、`UInt16`、`UInt32`、`UInt64`。 可能的值: @@ -209,67 +222,66 @@ SELECT * FROM example WHERE key = 'xxx' ORDER BY time DESC LIMIT 10; 默认值:`true`。 -默认情况下,ClickHouse 服务器在表创建时检查采样列或采样表达式的数据类型。如果您已经有带有不正确采样表达式的表,并且不希望服务器在启动时引发异常,请将 `check_sample_column_is_correct` 设置为 `false`。 +默认情况下,ClickHouse 服务器在表创建时检查采样列或采样表达式的数据类型。如果您已经有表的采样表达式不正确,并且不希望服务器在启动时引发异常,请将 `check_sample_column_is_correct` 设置为 `false`。 ## clean_deleted_rows {#clean_deleted_rows} -过时设置,不执行任何操作。 +已过时设置,无任何作用。 ## cleanup_delay_period {#cleanup_delay_period} -清理旧队列日志、块哈希和部分的最小时间。 +清理旧队列日志、块哈希和部分的最小周期。 ## cleanup_delay_period_random_add {#cleanup_delay_period_random_add} -将从 0 到 x 秒的均匀分布值添加到 cleanup_delay_period,以避免骤然集中效应和随后的 ZooKeeper 的拒绝服务。 +从 0 到 x 秒均匀分布的值添加到 cleanup_delay_period,以避免雷击效应和后续的 ZooKeeper DoS(当表的数量非常多时)。 ## cleanup_thread_preferred_points_per_iteration {#cleanup_thread_preferred_points_per_iteration} -后台清理的首选批量大小(点是抽象的,但 1 点大约相当于 1 个插入的块)。 +后台清理的首选批量大小(点是抽象的,每个点大致相当于一个插入块)。 ## cleanup_threads {#cleanup_threads} - -用于清理过时线程的线程。仅在 ClickHouse Cloud 中可用。 +已过时设置,无任何作用。 ## columns_and_secondary_indices_sizes_lazy_calculation {#columns_and_secondary_indices_sizes_lazy_calculation} -在第一次请求时懒惰地计算列和辅助索引大小,而不是在表初始化时。 +首选在首次请求时惰性计算列和副索引的大小,而不是在表初始化时计算。 ## columns_to_prewarm_mark_cache {#columns_to_prewarm_mark_cache} -要预热标记缓存的列列表(如果启用)。为空表示所有列。 +预热标记缓存的列列表(如果启用)。为空表示所有列 ## compact_parts_max_bytes_to_buffer {#compact_parts_max_bytes_to_buffer} -仅在 ClickHouse Cloud 中可用。紧凑部分中单个条带中写入的最大字节数。 +仅在 ClickHouse Cloud 中可用。在紧凑部分写入的单个条带的最大字节数。 ## compact_parts_max_granules_to_buffer {#compact_parts_max_granules_to_buffer} -仅在 ClickHouse Cloud 中可用。紧凑部分中单个条带中写入的最大粒度数。 +仅在 ClickHouse Cloud 中可用。在紧凑部分写入的单个条带的最大粒度数。 ## compact_parts_merge_max_bytes_to_prefetch_part {#compact_parts_merge_max_bytes_to_prefetch_part} -仅在 ClickHouse Cloud 中可用。合并期间读取的紧凑部分的最大大小,读取到内存中。 +仅在 ClickHouse Cloud 中可用。在合并期间整体读取的紧凑部分的最大大小。 ## compatibility_allow_sampling_expression_not_in_primary_key {#compatibility_allow_sampling_expression_not_in_primary_key} -允许创建一个主键中不包含采样表达式的表。这仅在暂时允许与错误表一起运行服务器以实现向后兼容时需要。 +允许创建主键中不包含采样表达式的表。此设置仅在向后兼容性方面临时允许在错误表上运行服务器。 ## compress_marks {#compress_marks} -标记支持压缩,减少标记文件大小并加快网络传输。 +标记支持压缩,减少标记文件大小并加速网络传输。 ## compress_primary_key {#compress_primary_key} -主键支持压缩,减少主键文件大小并加快网络传输。 +主键支持压缩,减少主键文件大小并加速网络传输。 ## concurrent_part_removal_threshold {#concurrent_part_removal_threshold} -仅在不活跃数据部分数量至少为此时,激活并发部分移除(见 ‘max_part_removal_threads’)。 +仅当非活动数据部分的数量至少达到此值时,才激活并发部分删除(参见 'max_part_removal_threads')。 ## deduplicate_merge_projection_mode {#deduplicate_merge_projection_mode} -是否允许为非经典的 MergeTree 创建投影,即不是(Replicated, Shared)MergeTree。忽略选项仅出于兼容性,这可能导致不正确的答案。否则,如果允许,合并投影时是什么操作,是删除还是重建。因此经典的 MergeTree 将忽略此设置。它还控制 `OPTIMIZE DEDUPLICATE`,但对所有 MergeTree 家族成员都有影响。与选项 `lightweight_mutation_projection_mode` 类似, 它也是分级的。 +是否允许为非经典 MergeTree 创建投影,即不是 (Replicated, Shared) MergeTree。忽略选项是出于兼容性,可能导致错误的答案。否则,如果允许,合并投影时的操作是删除还是重建。因此经典的 MergeTree 将忽略此设置。它也控制 `OPTIMIZE DEDUPLICATE`,对所有 MergeTree 家族成员生效。类似于选项 `lightweight_mutation_projection_mode`,它也是部分级别。 可能的值: - `ignore` @@ -280,28 +292,28 @@ SELECT * FROM example WHERE key = 'xxx' ORDER BY time DESC LIMIT 10; -指定如果在表声明中没有为特定列定义压缩编解码器,则使用的默认压缩编解码器。 +指定在表声明中未定义的情况下使用的默认压缩编解码器。 列的压缩编解码器选择顺序: -1. 在表声明中为列定义的压缩编解码器 -2. 在 `default_compression_codec` 中定义的压缩编解码器(此设置) -3. 在 `compression` 设置中定义的默认压缩编解码器 +1. 表声明中定义的列的压缩编解码器 +2. `default_compression_codec` 中定义的压缩编解码器(此设置) +3. `compression` 设置中定义的默认压缩编解码器 默认值:空字符串(未定义)。 ## detach_not_byte_identical_parts {#detach_not_byte_identical_parts} -在合并或变更后,如果其不与其他副本上的数据部分字节相同,则启用或禁用副本上数据部分的分离。如果禁用,则会移除数据部分。如果您希望稍后分析此类部分,请启用此设置。 +启用或禁用在合并或变更后,如果副本上的数据部分与其他副本上的数据部分不完全相同,则从副本中分离该数据部分。如果禁用,则删除数据部分。如果希望稍后分析此类部分,请激活此设置。 -该设置适用于启用 -[数据复制](/engines/table-engines/mergetree-family/replacingmergetree)的 `MergeTree` 表。 +此设置适用于启用 +[数据复制](/engines/table-engines/mergetree-family/replacingmergetree) 的 `MergeTree` 表。 可能的值: -- `0` — 部分会被移除。 -- `1` — 部分会被分离。 +- `0` — 部分已删除。 +- `1` — 部分已分离。 ## detach_old_local_parts_when_cloning_replica {#detach_old_local_parts_when_cloning_replica} -在修复丢失的副本时,不移除旧的本地部分。 +在修复丢失副本时,不删除旧的本地部分。 可能的值: - `true` @@ -309,22 +321,32 @@ SELECT * FROM example WHERE key = 'xxx' ORDER BY time DESC LIMIT 10; ## disable_detach_partition_for_zero_copy_replication {#disable_detach_partition_for_zero_copy_replication} -禁用零拷贝复制的 DETACH PARTITION 查询。 +禁用针对零复制复制的 DETACH PARTITION 查询。 ## disable_fetch_partition_for_zero_copy_replication {#disable_fetch_partition_for_zero_copy_replication} -禁用零拷贝复制的 FETCH PARTITION 查询。 +禁用针对零复制复制的 FETCH PARTITION 查询。 ## disable_freeze_partition_for_zero_copy_replication {#disable_freeze_partition_for_zero_copy_replication} -禁用零拷贝复制的 FREEZE PARTITION 查询。 +禁用针对零复制复制的 FREEZE PARTITION 查询。 ## disk {#disk} -存储磁盘的名称。可以替代存储策略指定。 +存储磁盘的名称。可以代替存储策略指定。 +## dynamic_serialization_version {#dynamic_serialization_version} + + + +动态数据类型的序列化版本。兼容性所需。 + +可能的值: +- `v1` +- `v2` +- `v3` ## enable_block_number_column {#enable_block_number_column} -启用为每行持久化列 _block_number。 +为每行启用持久化列 _block_number。 ## enable_block_offset_column {#enable_block_offset_column} @@ -332,7 +354,7 @@ SELECT * FROM example WHERE key = 'xxx' ORDER BY time DESC LIMIT 10; ## enable_index_granularity_compression {#enable_index_granularity_compression} -如果可能,则在内存中压缩索引粒度的值。 +如果可能,压缩内存中的索引粒度值。 ## enable_max_bytes_limit_for_min_age_to_force_merge {#enable_max_bytes_limit_for_min_age_to_force_merge} @@ -345,14 +367,14 @@ SELECT * FROM example WHERE key = 'xxx' ORDER BY time DESC LIMIT 10; ## enable_mixed_granularity_parts {#enable_mixed_granularity_parts} -启用或禁用过渡以通过 `index_granularity_bytes` 设置控制粒度大小。在 19.11 版本之前,只有 `index_granularity` 设置用于限制粒度大小。`index_granularity_bytes` 设置改善了 ClickHouse 在选择来自大行(数十和数百兆字节)表的数据时的性能。如果您有大行的表,可以为该表启用此设置,以提高 `SELECT` 查询的提效。 +启用或禁用使用 `index_granularity_bytes` 设置控制粒度大小的过渡。在版本 19.11 之前,只有设置 `index_granularity` 用于限制粒度大小。设置 `index_granularity_bytes` 可提高在从包含大行的表中选择数据时的 ClickHouse 性能(数十到数百兆字节)。如果您有大行的表,可以为这些表启用此设置,以提高 `SELECT` 查询的效率。 ## enable_replacing_merge_with_cleanup_for_min_age_to_force_merge {#enable_replacing_merge_with_cleanup_for_min_age_to_force_merge} -是否在将分区合并为单一部分时对 ReplacingMergeTree 使用清理合并。要求启用 `allow_experimental_replacing_merge_with_cleanup`、`min_age_to_force_merge_seconds` 和 `min_age_to_force_merge_on_partition_only`。 +在将分区合并为单个部分时,是否使用清理合并对于 ReplacingMergeTree。需要启用 `allow_experimental_replacing_merge_with_cleanup`、`min_age_to_force_merge_seconds` 和 `min_age_to_force_merge_on_partition_only`。 可能的值: - `true` @@ -360,7 +382,7 @@ SELECT * FROM example WHERE key = 'xxx' ORDER BY time DESC LIMIT 10; ## enable_the_endpoint_id_with_zookeeper_name_prefix {#enable_the_endpoint_id_with_zookeeper_name_prefix} -为复制的合并树表启用带有 Zookeeper 名称前缀的端点 ID。 +启用带有 Zookeeper 名称前缀的端点 ID 以用于复制合并树表。 ## enable_vertical_merge_algorithm {#enable_vertical_merge_algorithm} @@ -369,22 +391,53 @@ SELECT * FROM example WHERE key = 'xxx' ORDER BY time DESC LIMIT 10; -如果在分区操作查询(`ATTACH/MOVE/REPLACE PARTITION`)的目标表上启用了此设置,则源表和目标表之间的索引和投影必须是相同的。否则,目标表可以具有源表的索引和投影的超集。 +如果此设置在分区操作查询(`ATTACH/MOVE/REPLACE PARTITION`)的目标表上启用,则源表和目标表之间的索引和投影必须相同。否则,目标表可以具有源表索引和投影的超集。 ## exclude_deleted_rows_for_part_size_in_merge {#exclude_deleted_rows_for_part_size_in_merge} -如果启用,将在选择合并部分时,使用估计的实际数据部分大小(即,排除通过 `DELETE FROM` 已删除的行)。请注意,这种行为仅在此设置启用后执行的 `DELETE FROM` 影响的数据部分触发。 +启用时,将在选择合并部分时使用数据部分的实际大小(即,不包括通过 `DELETE FROM` 已删除的行)。请注意,此行为仅在在启用此设置后执行的 `DELETE FROM` 影响的数据部分上触发。 可能的值: - `true` - `false` -**另请参见** +**另见** - [load_existing_rows_count_for_old_parts](#load_existing_rows_count_for_old_parts) 设置 +## exclude_materialize_skip_indexes_on_merge {#exclude_materialize_skip_indexes_on_merge} + + + +在合并期间排除提供的逗号分隔的跳过索引列表,不会构建和存储它们。如果 +[materialize_skip_indexes_on_merge](#materialize_skip_indexes_on_merge) 为 false,则没有影响。 + +被排除的跳过索引仍然可以通过显式的 [MATERIALIZE INDEX](/sql-reference/statements/alter/skipping-index.md/#materialize-index) 查询或在插入期间根据 [materialize_skip_indexes_on_insert](/operations/settings/settings.md/#materialize_skip_indexes_on_insert) 会话设置构建和存储。 + +示例: + +```sql +CREATE TABLE tab +( +a UInt64, +b UInt64, +INDEX idx_a a TYPE minmax, +INDEX idx_b b TYPE set(3) +) +ENGINE = MergeTree ORDER BY tuple() SETTINGS exclude_materialize_skip_indexes_on_merge = 'idx_a'; + +INSERT INTO tab SELECT number, number / 50 FROM numbers(100); -- setting has no effect on INSERTs + +-- idx_a will be excluded from update during background or explicit merge via OPTIMIZE TABLE FINAL + +-- can exclude multiple indexes by providing a list +ALTER TABLE tab MODIFY SETTING exclude_materialize_skip_indexes_on_merge = 'idx_a, idx_b'; + +-- default setting, no indexes excluded from being updated during merge +ALTER TABLE tab MODIFY SETTING exclude_materialize_skip_indexes_on_merge = ''; +``` ## execute_merges_on_single_replica_time_threshold {#execute_merges_on_single_replica_time_threshold} -当此设置的值大于零时,仅单个副本立即开始合并,其他副本最多等待该时段下载结果,而不是进行本地合并。如果选择的副本在此段时间内未完成合并,则回退到标准行为。 +当此设置的值大于零时,仅一个副本立即启动合并,而其他副本最多等待该时长以下载结果,而不是在本地进行合并。如果所选择的副本在该时段内未完成合并,则会回退到标准行为。 可能的值: - 任何正整数。 @@ -399,34 +452,34 @@ SELECT * FROM example WHERE key = 'xxx' ORDER BY time DESC LIMIT 10; ## finished_mutations_to_keep {#finished_mutations_to_keep} -要保留的关于已完成变更的记录数量。如果为零,则保留所有记录。 +保留多少已完成的变更记录。如果为零,则保留所有。 ## force_read_through_cache_for_merges {#force_read_through_cache_for_merges} -强制在合并时通过文件系统缓存读取数据。 +强制合并时通过文件系统缓存读取。 ## fsync_after_insert {#fsync_after_insert} -对每个插入的部分执行 fsync。这会显著降低插入性能,不建议与宽部分一起使用。 +对每个插入的部分进行 fsync。显著降低插入性能,不建议在宽部分中使用。 ## fsync_part_directory {#fsync_part_directory} -对所有部分操作后(写入、重命名等)执行 fsync。 +在所有部分操作(写入、重命名等)后,对部分目录进行 fsync。 ## in_memory_parts_enable_wal {#in_memory_parts_enable_wal} -过时设置,不执行任何操作。 +已过时设置,无任何作用。 ## in_memory_parts_insert_sync {#in_memory_parts_insert_sync} -过时设置,不执行任何操作。 +已过时设置,无任何作用。 ## inactive_parts_to_delay_insert {#inactive_parts_to_delay_insert} -如果某个表单个分区中的不活跃部分数量超过 `inactive_parts_to_delay_insert` 值,则 `INSERT` 会被人工放慢。 +如果表中单个分区的非活动部分数量超过 `inactive_parts_to_delay_insert` 值,则 `INSERT` 被人造放慢。 :::tip -当服务器无法快速清理部分时,这很有用。 +当服务器无法迅速清理部分时,它是有用的。 ::: 可能的值: @@ -434,39 +487,39 @@ SELECT * FROM example WHERE key = 'xxx' ORDER BY time DESC LIMIT 10; ## inactive_parts_to_throw_insert {#inactive_parts_to_throw_insert} -如果某个分区中的不活跃部分数量超过 `inactive_parts_to_throw_insert` 值, `INSERT` 将中断并产生以下错误: +如果单个分区中非活动部分的数量超过 `inactive_parts_to_throw_insert` 值,则 `INSERT` 将因以下错误中断: -> "不活跃部分过多(N)。部分清理处理显著慢于插入" 异常。 +> "非活动部分太多(N)。部分清理的处理速度明显慢于插入。" 异常。 可能的值: - 任何正整数。 ## index_granularity {#index_granularity} -索引标记之间的最大数据行数。即多少行对应一个主键值。 +索引标记之间的数据行的最大数量。即一个主键值对应多少行。 ## index_granularity_bytes {#index_granularity_bytes} -字节为单位的数据粒度的最大大小。 +字节中数据粒度的最大大小。 要仅通过行数限制粒度大小,请设置为 `0`(不推荐)。 ## initialization_retry_period {#initialization_retry_period} -表初始化的重试时间,单位为秒。 +表初始化的重试周期,以秒为单位。 ## kill_delay_period {#kill_delay_period} -过时设置,不执行任何操作。 +已过时设置,无任何作用。 ## kill_delay_period_random_add {#kill_delay_period_random_add} -过时设置,不执行任何操作。 +已过时设置,无任何作用。 ## kill_threads {#kill_threads} -过时设置,不执行任何操作。 +已过时设置,无任何作用。 ## lightweight_mutation_projection_mode {#lightweight_mutation_projection_mode} -默认情况下,轻量级删除 `DELETE` 不适用于具有投影的表。这是因为投影中的行可能会受到 `DELETE` 操作的影响。所以默认值为 `throw`。然而,此选项可以更改此行为。通过将值设置为 `drop` 或 `rebuild`,删除将在投影上工作。`drop` 将删除投影,因此在当前查询中可能很快,但在未来查询中可能会很慢,因为没有附加的投影。`rebuild` 将重建投影,这可能会影响当前查询的性能,但可能会加快未来查询的速度。一个好处是这些选项只会在部分级别上工作,这意味着未受影响的部分中的投影将保持完整,而不会触发任何类似删除或重建的操作。 +默认情况下,轻量级删除 `DELETE` 对具有投影的表无效。这是因为投影中的行可能受到 `DELETE` 操作的影响。因此,默认值将为 `throw`。但是,此选项可以更改行为。使用值 `drop` 或 `rebuild` 时,将可以与投影一起工作。`drop` 将删除投影,这样在当前查询中可能会很快,但在未来查询中会很慢,因为没有附加投影。`rebuild` 将重建投影,这可能会影响当前查询的性能,但可能会加速未来查询。好的一点是,这些选项仅在部分级别上工作,这意味着在未触及的部分中的投影将保持完好,而不会触发任何操作,例如删除或重建。 可能的值: - `throw` @@ -475,78 +528,82 @@ SELECT * FROM example WHERE key = 'xxx' ORDER BY time DESC LIMIT 10; ## load_existing_rows_count_for_old_parts {#load_existing_rows_count_for_old_parts} -如果与 [exclude_deleted_rows_for_part_size_in_merge](#exclude_deleted_rows_for_part_size_in_merge) 一起启用,则将在表启动时计算现有数据部分的已删除行数。请注意,这可能会减慢表加载的启动时间。 +如果与 [exclude_deleted_rows_for_part_size_in_merge](#exclude_deleted_rows_for_part_size_in_merge) 一起启用,则将在表启动期间计算现有数据部分的已删除行数。请注意,这可能使启动表加载变慢。 可能的值: - `true` - `false` -**另请参见** +**另见** - [exclude_deleted_rows_for_part_size_in_merge](#exclude_deleted_rows_for_part_size_in_merge) 设置 ## lock_acquire_timeout_for_background_operations {#lock_acquire_timeout_for_background_operations} -用于后台操作,如合并、变更等。 在失败获取表锁之前的时间(以秒为单位)。 +用于后台操作(如合并、变更等)。在未能获取表锁之前的秒数。 ## marks_compress_block_size {#marks_compress_block_size} -标记压缩块大小,实际要压缩的块的大小。 +标记压缩块大小,实际压缩的块大小。 ## marks_compression_codec {#marks_compression_codec} -标记所使用的压缩编码,标记足够小且被缓存,因此默认压缩为 ZSTD(3)。 +标记所使用的压缩编码,标记很小且被缓存,因此默认压缩为 ZSTD(3)。 ## materialize_skip_indexes_on_merge {#materialize_skip_indexes_on_merge} -启用时,合并构建并存储跳过索引以便于新部分的生成。否则,它们可以通过显式的 MATERIALIZE INDEX 创建/存储。 +启用时,合并会为新部分构建并存储跳过索引。 +否则,可以通过显式的 [MATERIALIZE INDEX](/sql-reference/statements/alter/skipping-index.md/#materialize-index) 查询或 [在插入期间](/operations/settings/settings.md/#materialize_skip_indexes_on_insert) 创建/存储。 + +另见 [exclude_materialize_skip_indexes_on_merge](#exclude_materialize_skip_indexes_on_merge),以进行更精细的控制。 ## materialize_ttl_recalculate_only {#materialize_ttl_recalculate_only} -仅在 MATERIALIZE TTL 时重新计算 TTL 信息。 +仅在 MATERIALIZE TTL 时重新计算 ttl 信息。 ## max_avg_part_size_for_too_many_parts {#max_avg_part_size_for_too_many_parts} -根据 `parts_to_delay_insert` 和 `parts_to_throw_insert` 的 "过多部分" 检查仅在相关分区的平均部分大小不大于指定的阈值时有效。如果大于指定的阈值,则不会延迟或拒绝 INSERT。这允许在单台服务器上拥有数百 TB 的单个表,只要部分成功合并为更大的部分。这不会影响不活跃部分或总部分的阈值。 +根据 `parts_to_delay_insert` 和 `parts_to_throw_insert` 的“太多部分”检查将仅在平均部分大小(在相关分区中)不大于指定阈值时激活。如果大于指定阈值,则 INSERTs 不会被延迟或拒绝。这允许在单个服务器上的单个表中拥有数百 TB 的数据,只要部分已成功合并到更大的部分。这不影响非活动部分或总部分的阈值。 ## max_bytes_to_merge_at_max_space_in_pool {#max_bytes_to_merge_at_max_space_in_pool} -可合并为一部分的最大总部分大小(以字节为单位),如果有足够的资源可用。大致对应自动后台合并创建的最大可能部分大小。(0 表示禁用合并) +要合并为一个部分的最大总部分大小(以字节为单位),前提是有足够的可用资源。大致对应于自动后台合并创建的最大可能部分大小。(0 表示禁用合并) 可能的值: - 任何非负整数。 -合并调度程序定期分析分区中的部分数量和大小,如果池中有足够的空闲资源,则启动后台合并。合并将持续直到源部分的总大小大于 `max_bytes_to_merge_at_max_space_in_pool`。 +合并调度程序定期分析分区中部分的大小和数量,如果池中有足够的可用资源,则开始后台合并。合并发生的时机是源部分的总大小超过 `max_bytes_to_merge_at_max_space_in_pool`。 -由 [OPTIMIZE FINAL](/sql-reference/statements/optimize) 启动的合并忽略 `max_bytes_to_merge_at_max_space_in_pool` (仅考虑可用磁盘空间)。 +通过 [OPTIMIZE FINAL](/sql-reference/statements/optimize) 发起的合并会忽略 `max_bytes_to_merge_at_max_space_in_pool`(仅考虑可用的磁盘空间)。 ## max_bytes_to_merge_at_min_space_in_pool {#max_bytes_to_merge_at_min_space_in_pool} -可合并为一部分的最大总部分大小(以字节为单位),与后台池中的最低资源可用。 +如果在后台池中可用资源最小的情况下,要合并为一个部分的最大总部分大小(以字节为单位)。 可能的值: - 任何正整数。 -`max_bytes_to_merge_at_min_space_in_pool` 定义了尽管可用磁盘空间不足,但仍可合并的部分的最大总大小(在池中)。这对于减少小部分的数量和 `Too many parts` 错误的发生是必要的。 -合并使用合并部分大小的两倍来记录磁盘空间。 -因此,在可用磁盘空间不足的情况下,可能出现可用空间的情况,但该空间已经被正在进行的大型合并预定,其他合并无法启动,随着每次插入小部分数量增加。 +`max_bytes_to_merge_at_min_space_in_pool` 定义了尽管缺乏可用磁盘空间(在池中),仍可合并的最大总部分大小。这是为了减少小部分的数量和“太多部分”错误的机会。 +合并在合并的部分的总大小上加倍已占用的磁盘空间。 +因此,在可用磁盘空间很少的情况下,可能会出现存在可用空间的情况,但该空间已经被正在进行的大型合并占用,从而导致其他合并无法启动,插入时小部分的数量不断增加。 ## max_cleanup_delay_period {#max_cleanup_delay_period} -清理旧队列日志、块哈希和部分的最长时间。 +清理旧队列日志、块哈希和部分的最大周期。 ## max_compress_block_size {#max_compress_block_size} -在写入表之前压缩的未经压缩数据块的最大大小。您也可以在全局设置中指定此设置(请参见 [max_compress_block_size](/operations/settings/merge-tree-settings#max_compress_block_size) 设置)。在创建表时指定的值会覆盖此设置的全局值。 +在压缩以写入表之前未压缩数据块的最大大小。您还可以在全局设置中指定此设置(请参见 [max_compress_block_size](/operations/settings/merge-tree-settings#max_compress_block_size) 设置)。在创建表时指定的值将覆盖该设置的全局值。 ## max_concurrent_queries {#max_concurrent_queries} -与 MergeTree 表相关联的最大并发执行查询数。查询仍然会受到其他 `max_concurrent_queries` 设置的限制。 +与 MergeTree 表相关的最大并发执行查询数。 +查询仍将受其他 `max_concurrent_queries` 设置的限制。 可能的值: - 正整数。 -- `0` — 无限制。 +- `0` — 没有限制。 默认值:`0`(无限制)。 @@ -558,7 +615,8 @@ SELECT * FROM example WHERE key = 'xxx' ORDER BY time DESC LIMIT 10; ## max_delay_to_insert {#max_delay_to_insert} -在计算 `INSERT` 延迟时使用的值(单位为秒),如果单个分区中活动部分的数量超过 [parts_to_delay_insert](#parts_to_delay_insert) 值。 +当单个分区中的活动部分数量超过 +[parts_to_delay_insert](#parts_to_delay_insert) 值时,用于计算 `INSERT` 延迟的秒数值。 可能的值: - 任何正整数。 @@ -570,10 +628,9 @@ max_k = parts_to_throw_insert - parts_to_delay_insert k = 1 + parts_count_in_partition - parts_to_delay_insert delay_milliseconds = pow(max_delay_to_insert * 1000, k / max_k) ``` -例如,如果分区有 299 个活动部分,而 parts_to_throw_insert = 300, parts_to_delay_insert = 150, max_delay_to_insert = 1, `INSERT` 被延迟为 `pow( 1 * 1000, (1 + 299 - 150) / (300 - 150) ) = 1000` -毫秒。 +例如,如果一个分区有 299 个活动部分,且 parts_to_throw_insert = 300,parts_to_delay_insert = 150,max_delay_to_insert = 1,那么 `INSERT` 将延迟 `pow( 1 * 1000, (1 + 299 - 150) / (300 - 150) ) = 1000` 毫秒。 -从 23.1 版本开始,公式已更改为: +从版本 23.1 开始,公式已更改为: ```code allowed_parts_over_threshold = parts_to_throw_insert - parts_to_delay_insert @@ -581,23 +638,25 @@ parts_over_threshold = parts_count_in_partition - parts_to_delay_insert + 1 delay_milliseconds = max(min_delay_to_insert_ms, (max_delay_to_insert * 1000) * parts_over_threshold / allowed_parts_over_threshold) ``` -例如,如果分区有 224 个活动部分,而 parts_to_throw_insert = 300, parts_to_delay_insert = 150, max_delay_to_insert = 1, min_delay_to_insert_ms = 10, `INSERT` 被延迟为 `max( 10, 1 * 1000 * (224 - 150 + 1) / (300 - 150) ) = 500` 毫秒。 +例如,如果一个分区有 224 个活动部分,且 parts_to_throw_insert = 300,parts_to_delay_insert = 150,max_delay_to_insert = 1,min_delay_to_insert_ms = 10,那么 `INSERT` 将延迟 `max( 10, 1 * 1000 * (224 - 150 + 1) / (300 - 150) ) = 500` 毫秒。 ## max_delay_to_mutate_ms {#max_delay_to_mutate_ms} -如果有很多未完成的变更,则 MergeTree 表的最大变更延迟(以毫秒为单位)。 +如果存在大量未完成变更的最大延迟时间(以毫秒为单位)。 ## max_digestion_size_per_segment {#max_digestion_size_per_segment} + -构建 GIN 索引时每个段的最大字节数。 +已过时设置,无任何作用。 ## max_file_name_length {#max_file_name_length} -要保留如此大小的文件名而不进行哈希的最大长度。仅在启用设置 `replace_long_file_name_to_hash` 时生效。此设置的值不包括文件扩展名的长度。因此,建议将其设置在最大文件名长度(通常为 255 字节)以下,并留有一些间隙以避免文件系统错误。 +保持文件名不被哈希化的最大长度。仅在启用设置 `replace_long_file_name_to_hash` 时生效。 +该设置的值不包括文件扩展名的长度。因此,建议将其设置为低于最大文件名长度(通常为 255 字节)并留有一定的间隔以避免文件系统错误。 ## max_files_to_modify_in_alter_columns {#max_files_to_modify_in_alter_columns} -如果用于修改(删除、添加)的文件数大于此设置,则不应用 ALTER。 +如果待修改(删除、添加)的文件数量大于该设置,则不应用 ALTER。 可能的值: @@ -607,7 +666,7 @@ delay_milliseconds = max(min_delay_to_insert_ms, (max_delay_to_insert * 1000) ## max_files_to_remove_in_alter_columns {#max_files_to_remove_in_alter_columns} -如果文件数大于此设置,则不适用删除的 ALTER。 +如果待删除的文件数量大于该设置,则不应用 ALTER。 可能的值: - 任何正整数。 @@ -615,48 +674,51 @@ delay_milliseconds = max(min_delay_to_insert_ms, (max_delay_to_insert * 1000) -可以并行刷新(合并时)的最大流(列)的数量(类似于 max_insert_delayed_streams_for_parallel_write)。仅适用于垂直合并。 +可以并行刷新(用于合并的列)最大流的数量(合并的最大 insert 延迟流)。仅适用于垂直合并。 ## max_merge_selecting_sleep_ms {#max_merge_selecting_sleep_ms} -在尝试重新选择要合并的部分时,等待的最大时间。如果设置过小,将导致背景任务池中频繁触发选择任务,从而对大型集群中的 zookeeper 发出大量请求。 +在未选择到任何部分后,尝试再次选择部分以合并之前的最大等待时间。较低的设置将会在后台调度池中频繁触发选择任务,从而导致在大规模集群中大量请求到 ZooKeeper。 ## max_number_of_merges_with_ttl_in_pool {#max_number_of_merges_with_ttl_in_pool} -当池中存在超过指定数量的带有 TTL 条目的合并时,不为新的带有 TTL 的合并分配线程。这是为了为常规合并保留空闲线程,并避免 "Too many parts"。 +当池中存在超过指定数量的 TTL 条目的合并时,不分配新的带 TTL 的合并。这是为了为常规合并留出空闲线程,避免“部分太多”等问题。 ## max_number_of_mutations_for_replica {#max_number_of_mutations_for_replica} -限制每个副本的部分变更数量。零表示每个副本对变更的数量没有限制(执行仍可能受其他设置的限制)。 +限制每个副本的部分变更数量为指定的数量。零表示每个副本的变更数量没有限制(执行仍可能受到其他设置的约束)。 ## max_part_loading_threads {#max_part_loading_threads} -过时设置,不执行任何操作。 +已过时设置,无任何作用。 ## max_part_removal_threads {#max_part_removal_threads} -过时设置,不执行任何操作。 +已过时设置,无任何作用。 ## max_partitions_to_read {#max_partitions_to_read} -限制在一次查询中可以访问的分区的最大数量。 +限制一次查询中可以访问的最大分区数。 -在创建表时指定的设置值可以通过查询级设置覆盖。 +在创建表时指定的设置值可以通过 +查询级别设置进行覆盖。 可能的值: - 任何正整数。 -您还可以在查询/会话/配置级别指定查询复杂性设置 [max_partitions_to_read](/operations/settings/settings#max_partitions_to_read)。 +您也可以在查询/会话/配置文件级别指定查询复杂度设置 [max_partitions_to_read](/operations/settings/settings#max_partitions_to_read)。 ## max_parts_in_total {#max_parts_in_total} -如果表的所有分区中活动部分的总数超过 `max_parts_in_total` 值, `INSERT` 将被中断,并出现 `Too many parts (N)` 异常。 +如果表的所有分区中的活跃部分总数超过 +`max_parts_in_total`值,`INSERT`将中断并抛出`过多部分 (N)` 异常。 可能的值: - 任何正整数。 -表中的大量部分会降低 ClickHouse 查询的性能并增加 ClickHouse 的启动时间。这通常是设计不当(选择分区策略时的错误 - 分区过小)的结果。 +表中部分数量过多会降低 ClickHouse 查询的性能并增加 ClickHouse 启动时间。通常这都是由于设计不当(选择分区策略时出现错误 - 分区过小)。 ## max_parts_to_merge_at_once {#max_parts_to_merge_at_once} -可以一次合并的最大部分数(0 - 禁用)。不影响 OPTIMIZE FINAL 查询。 +一次可以合并的最大部分数量(0 - 禁用)。不影响 +OPTIMIZE FINAL 查询。 ## max_postpone_time_for_failed_mutations_ms {#max_postpone_time_for_failed_mutations_ms} @@ -665,284 +727,301 @@ delay_milliseconds = max(min_delay_to_insert_ms, (max_delay_to_insert * 1000) -对失败的复制提取的最大推迟时间。 + +失败的复制获取的最大推迟时间。 ## max_postpone_time_for_failed_replicated_merges_ms {#max_postpone_time_for_failed_replicated_merges_ms} -对失败的复制合并的最大推迟时间。 + +失败的复制合并的最大推迟时间。 ## max_postpone_time_for_failed_replicated_tasks_ms {#max_postpone_time_for_failed_replicated_tasks_ms} -失败的复制任务的最大推迟时间。如果任务不是抓取、合并或变更,则使用该值。 + +失败的复制任务的最大推迟时间。该值在任务不是获取、合并或变更时使用。 ## max_projections {#max_projections} -最大合并树投影数。 +最大 MergeTree 投影的数量。 ## max_replicated_fetches_network_bandwidth {#max_replicated_fetches_network_bandwidth} -限制每秒以字节为单位的 [replicated](../../engines/table-engines/mergetree-family/replication.md) 抓取的数据交换的最大速度。此设置适用于特定表,与适用于服务器的 [`max_replicated_fetches_network_bandwidth_for_server`](/operations/settings/merge-tree-settings#max_replicated_fetches_network_bandwidth) 设置不同。 +限制每秒以字节为单位进行 [复制](../../engines/table-engines/mergetree-family/replication.md) 获取的数据交换最大速度。该设置适用于特定表,与 [`max_replicated_fetches_network_bandwidth_for_server`](/operations/settings/merge-tree-settings#max_replicated_fetches_network_bandwidth) 设置不同,该设置适用于服务器。 -您可以限制服务器网络和特定表的网络,但为此表级设置的值应小于服务器级设置的值。否则,服务器仅考虑 `max_replicated_fetches_network_bandwidth_for_server` 设置。 +您可以同时限制服务器网络和特定表的网络,但为此表级设置的值应小于服务器级设置的值。否则,服务器只考虑 `max_replicated_fetches_network_bandwidth_for_server` 设置。 -该设置并未完全准确遵循。 +该设置的遵循并不十分准确。 可能的值: - 正整数。 -- `0` — 无限。 +- `0` — 不限制。 -默认值:`0`。 +默认值: `0`. -**用法** +**用途** -可以在将数据复制到新节点以添加或替换时用于限制速度。 +可用于在将数据复制到新节点时限速。 ## max_replicated_logs_to_keep {#max_replicated_logs_to_keep} -如果存在非活动副本,ClickHouse Keeper 日志中可以保留的记录数。超过此数字,将会丢失一个非活动副本。 +在 ClickHouse Keeper 日志中,是否允许有多少条记录,如果有非活跃副本。非活跃副本在超过该数量时会变为丢失。 可能的值: - 任何正整数。 ## max_replicated_merges_in_queue {#max_replicated_merges_in_queue} -ReplicatedMergeTree 队列中允许的合并和变更部分的任务数量。 +在 ReplicatedMergeTree 队列中同时允许合并和变更部分的任务数量。 ## max_replicated_merges_with_ttl_in_queue {#max_replicated_merges_with_ttl_in_queue} -ReplicatedMergeTree 队列中允许的与 TTL 相关的合并部分任务数量。 +在 ReplicatedMergeTree 队列中同时允许具有 TTL 的合并任务的数量。 ## max_replicated_mutations_in_queue {#max_replicated_mutations_in_queue} -ReplicatedMergeTree 队列中允许的变更部分的任务数量。 +在 ReplicatedMergeTree 队列中同时允许变更部分的任务数量。 ## max_replicated_sends_network_bandwidth {#max_replicated_sends_network_bandwidth} -限制每秒以字节为单位的 [replicated](/engines/table-engines/mergetree-family/replacingmergetree) 发送的数据交换的最大速度。此设置适用于特定表,与适用于服务器的 [`max_replicated_sends_network_bandwidth_for_server`](/operations/settings/merge-tree-settings#max_replicated_sends_network_bandwidth) 设置不同。 +限制每秒以字节为单位进行 [复制](../../engines/table-engines/mergetree-family/replacingmergetree) 发送的数据交换最大速度。该设置适用于特定表,与 [`max_replicated_sends_network_bandwidth_for_server`](/operations/settings/merge-tree-settings#max_replicated_sends_network_bandwidth) 设置不同,该设置适用于服务器。 -您可以限制服务器网络和特定表的网络,但为此表级设置的值应小于服务器级设置的值。否则,服务器仅考虑 `max_replicated_sends_network_bandwidth_for_server` 设置。 +您可以同时限制服务器网络和特定表的网络,但为此表级设置的值应小于服务器级设置的值。否则,服务器只考虑 `max_replicated_sends_network_bandwidth_for_server` 设置。 -该设置并未完全准确遵循。 +该设置的遵循并不十分准确。 可能的值: - 正整数。 -- `0` — 无限。 +- `0` — 不限制。 -**用法** +**用途** -可以在将数据复制到新节点以添加或替换时用于限制速度。 +可用于在将数据复制到新节点时限速。 ## max_suspicious_broken_parts {#max_suspicious_broken_parts} -如果单个分区中的损坏部分数量超过 `max_suspicious_broken_parts` 值,则拒绝自动删除。 +如果单个分区中损坏的部分数量超过 +`max_suspicious_broken_parts` 值,则自动删除被拒绝。 可能的值: - 任何正整数。 ## max_suspicious_broken_parts_bytes {#max_suspicious_broken_parts_bytes} -所有损坏部分的最大大小,如果超过则拒绝自动删除。 +所有损坏部分的最大大小,若超过则拒绝自动删除。 可能的值: - 任何正整数。 +## max_uncompressed_bytes_in_patches {#max_uncompressed_bytes_in_patches} + + + + +所有补丁部分中的最大未压缩数据大小(字节)。如果所有补丁部分中的数据量超过此值,轻量级更新将被拒绝。 +0 - 不限制。 ## merge_max_block_size {#merge_max_block_size} - + -从合并的部分读取到内存中的行数。 +从合并部分读取到内存的行数。 可能的值: - 任何正整数。 -合并从部分中以 `merge_max_block_size` 行的块读取行,然后合并并将结果写入新部分。读取的块存放在 RAM 中,因而 `merge_max_block_size` 会影响合并所需 RAM 的大小。因此,对于非常宽的行的表,合并可能会消耗大量 RAM(如果平均行大小为 100kb,则在合并 10 个部分时,(100kb * 10 * 8192) = ~ 8GB 的 RAM)。通过减少 `merge_max_block_size`,可以减少合并所需的 RAM,但会降低合并速度。 +合并从部分中以 `merge_max_block_size` 行的块读取行,然后合并并将结果写入新部分。读取块存放在RAM中,因此 `merge_max_block_size` 会影响合并所需的RAM大小。 +因此,对于行非常宽的表,合并可能消耗大量RAM(如果平均行大小为100kb,则合并10部分时,(100kb * 10 * 8192) = ~ 8GB的RAM)。通过减少 `merge_max_block_size`,可以减少合并所需的RAM量,但会减慢合并速度。 ## merge_max_block_size_bytes {#merge_max_block_size_bytes} -合并操作应形成的块的字节数。默认值与 `index_granularity_bytes` 相同。 +合并操作应该形成的块大小(字节)。默认值与 `index_granularity_bytes` 相同。 ## merge_max_bytes_to_prewarm_cache {#merge_max_bytes_to_prewarm_cache} -仅在 ClickHouse Cloud 中可用。合并过程中预热缓存的部分(紧凑型或打包型)的最大大小。 + +仅在 ClickHouse Cloud 中可用。 最大部分(紧凑或打包)的大小,以在合并期间预热缓存。 ## merge_selecting_sleep_ms {#merge_selecting_sleep_ms} -在没有选定部分后尝试再次选择部分以进行合并之前的最小等待时间。较低的设置将导致在大型集群中频繁触发后台调度池中的选择任务,这会导致大量对 Zookeeper 的请求。 +在尝试再次选择要合并的部分之前等待的最短时间。如果选择任务的设置较低,会在背景调度池中频繁触发,从而在大规模集群中导致大量请求到 Zookeeper。 ## merge_selecting_sleep_slowdown_factor {#merge_selecting_sleep_slowdown_factor} -当没有可以合并的部分时,合并选择任务的睡眠时间乘以该因子,当分配了合并任务时则除以该因子。 +当没有可以合并的部分时,合并选择任务的睡眠时间乘以此因子,当分配了合并时则被除以该因子。 ## merge_selector_algorithm {#merge_selector_algorithm} -用于选择部分进行合并分配的算法。 +用于选择合并分配部分的算法。 ## merge_selector_base {#merge_selector_base} - -影响分配合并的写放大(专家级设置,如不理解其作用请勿更改)。适用于简单和随机简单合并选择器。 +影响所分配合并的写放大(专家级设置,如果不理解其作用,请勿更改)。适用于 Simple 和 StochasticSimple 合并选择器。 ## merge_selector_blurry_base_scale_factor {#merge_selector_blurry_base_scale_factor} -控制逻辑在分区中相对于部分数量的启动时机。因子越大,反应就越滞后。 +控制逻辑在分区中的部分数量相对何时启动。因子越大,反应越滞后。 ## merge_selector_enable_heuristic_to_remove_small_parts_at_right {#merge_selector_enable_heuristic_to_remove_small_parts_at_right} -启用选择合并部分的启发式方法,从范围的右侧移除其大小小于指定比例(0.01)的部分。适用于简单和随机简单合并选择器。 +启用启发式选择部分进行合并,该方法从范围的右侧移除部分,如果其大小小于指定比例(0.01)与总大小的比率。适用于 Simple 和 StochasticSimple 合并选择器。 ## merge_selector_window_size {#merge_selector_window_size} -一次查看的部分数量。 +一次查看多少部分。 ## merge_total_max_bytes_to_prewarm_cache {#merge_total_max_bytes_to_prewarm_cache} -仅在 ClickHouse Cloud 中可用。合并过程中预热缓存的部分的最大总字节数。 + +仅在 ClickHouse Cloud 中可用。 最大部分总大小,以在合并期间预热缓存。 ## merge_tree_clear_old_broken_detached_parts_ttl_timeout_seconds {#merge_tree_clear_old_broken_detached_parts_ttl_timeout_seconds} -过时设置,未执行任何操作。 +过时设置,无任何作用。 ## merge_tree_clear_old_parts_interval_seconds {#merge_tree_clear_old_parts_interval_seconds} -设置 ClickHouse 执行旧部分、WAL 和变更的清理的秒数间隔。 +设置 ClickHouse 执行旧部分、WAL 和变更的清理的时间间隔(以秒为单位)。 可能的值: - 任何正整数。 ## merge_tree_clear_old_temporary_directories_interval_seconds {#merge_tree_clear_old_temporary_directories_interval_seconds} -设置 ClickHouse 执行旧临时目录清理的秒数间隔。 +设置 ClickHouse 执行旧临时目录清理的时间间隔(以秒为单位)。 可能的值: - 任何正整数。 ## merge_tree_enable_clear_old_broken_detached {#merge_tree_enable_clear_old_broken_detached} -过时设置,未执行任何操作。 +过时设置,无任何作用。 ## merge_with_recompression_ttl_timeout {#merge_with_recompression_ttl_timeout} -在重复带有重新压缩 TTL 的合并之前的最小延迟(秒)。 +在重复使用重新压缩 TTL 进行合并之前的最小延迟(秒)。 ## merge_with_ttl_timeout {#merge_with_ttl_timeout} -在重复带有删除 TTL 的合并之前的最小延迟(秒)。 +在重复使用删除 TTL 进行合并之前的最小延迟(秒)。 ## merge_workload {#merge_workload} -用于调节合并与其他工作负载之间的资源利用和共享。指定的值被用作此表的后台合并的 `workload` 设置值。如果未指定(空字符串),则使用服务器设置 `merge_workload`。 -**另请参见** +用于调节资源在合并与其他工作负载之间的利用和共享。指定的值用作该表的背景合并的 `workload` 设置值。如果未指定(空字符串),则使用服务器设置 `merge_workload`。 + +**另见** - [工作负载调度](/operations/workload-scheduling.md) ## min_absolute_delay_to_close {#min_absolute_delay_to_close} -关闭、停止服务请求并在状态检查时不返回 Ok 的最小绝对延迟。 +关闭的最小绝对延迟,停止服务请求并在状态检查时不返回正常。 ## min_age_to_force_merge_on_partition_only {#min_age_to_force_merge_on_partition_only} -是否应仅在整个分区上应用 `min_age_to_force_merge_seconds`,而不是在子集上。 +是否 `min_age_to_force_merge_seconds` 仅应应用于整个分区,而不是子集上。 -默认情况下,忽略设置 `max_bytes_to_merge_at_max_space_in_pool`(请参阅 `enable_max_bytes_limit_for_min_age_to_force_merge`)。 +默认情况下,忽略设置 `max_bytes_to_merge_at_max_space_in_pool`(参见 `enable_max_bytes_limit_for_min_age_to_force_merge`)。 可能的值: - true, false ## min_age_to_force_merge_seconds {#min_age_to_force_merge_seconds} -如果范围内的每个部分均超过 `min_age_to_force_merge_seconds` 的值,则合并部分。 +在范围内的每个部分的年龄都超过 `min_age_to_force_merge_seconds` 值时进行部分合并。 -默认情况下,忽略设置 `max_bytes_to_merge_at_max_space_in_pool`(请参阅 `enable_max_bytes_limit_for_min_age_to_force_merge`)。 +默认情况下,忽略设置 `max_bytes_to_merge_at_max_space_in_pool` +(参见 `enable_max_bytes_limit_for_min_age_to_force_merge`)。 可能的值: - 正整数。 ## min_bytes_for_compact_part {#min_bytes_for_compact_part} -过时设置,未执行任何操作。 +过时设置,无任何作用。 ## min_bytes_for_full_part_storage {#min_bytes_for_full_part_storage} -仅在 ClickHouse Cloud 中可用。用于完整类型存储的数据部分的最小未压缩大小,而不是打包类型。 +仅在 ClickHouse Cloud 中可用。用于将完整类型的存储用于数据部分的最小未压缩大小,而不是打包。 ## min_bytes_for_wide_part {#min_bytes_for_wide_part} -可以存储在 `Wide` 格式中的数据部分的最小字节/行数。可以设置一个、两个或都不设置这些设置。 +可以存储的宽格式数据部分的最小字节/行数。您可以设置这两个或都不设置。 ## min_bytes_to_prewarm_caches {#min_bytes_to_prewarm_caches} -预热标记缓存和新部分主索引缓存的最小大小(未压缩字节)。 + +用于预热新部分的标记缓存和主索引缓存的最小大小(未压缩字节)。 ## min_bytes_to_rebalance_partition_over_jbod {#min_bytes_to_rebalance_partition_over_jbod} -设置平衡时的最小字节数,以使新的大型部分能够在 [JBOD](https://en.wikipedia.org/wiki/Non-RAID_drive_architectures) 磁盘上分配。 +设置在将新大部分分配在卷磁盘 [JBOD](https://en.wikipedia.org/wiki/Non-RAID_drive_architectures) 上进行平衡时启用的最小字节数。 可能的值: - 正整数。 - `0` — 禁用平衡。 -**用法** +**用途** -`min_bytes_to_rebalance_partition_over_jbod` 设置的值不应小于 [max_bytes_to_merge_at_max_space_in_pool](/operations/settings/merge-tree-settings#max_bytes_to_merge_at_max_space_in_pool) 的值/ 1024。否则,ClickHouse 将抛出异常。 +`min_bytes_to_rebalance_partition_over_jbod` 设置的值不得小于 +[max_bytes_to_merge_at_max_space_in_pool](/operations/settings/merge-tree-settings#max_bytes_to_merge_at_max_space_in_pool) / 1024的值。否则,ClickHouse 会抛出异常。 ## min_compress_block_size {#min_compress_block_size} -写入下一个标记时进行压缩所需的未压缩数据块的最小大小。也可以在全局设置中指定此设置(请参阅 [min_compress_block_size](/operations/settings/merge-tree-settings#min_compress_block_size) 设置)。创建表时指定的值将覆盖该设置的全局值。 +进行下一个标记时写入所需的未压缩数据块的最小大小。您也可以在全局设置中指定此设置(请参见 [min_compress_block_size](/operations/settings/merge-tree-settings#min_compress_block_size) 设置)。在创建表时指定的值会覆盖此设置的全局值。 ## min_compressed_bytes_to_fsync_after_fetch {#min_compressed_bytes_to_fsync_after_fetch} -获取后进行 fsync 的最小压缩字节数(0 - 禁用)。 +获取后执行 fsync 的压缩字节最小数量(0 - 禁用)。 ## min_compressed_bytes_to_fsync_after_merge {#min_compressed_bytes_to_fsync_after_merge} -合并后进行 fsync 的最小压缩字节数(0 - 禁用)。 +合并后执行 fsync 的压缩字节最小数量(0 - 禁用)。 ## min_delay_to_insert_ms {#min_delay_to_insert_ms} -合并树表中插入数据的最小延迟(毫秒),如果单个分区中有很多未合并的部分。 +如果单一分区中未合并部分较多,插入 MergeTree 表数据的最小延迟(以毫秒为单位)。 ## min_delay_to_mutate_ms {#min_delay_to_mutate_ms} -合并树表中变更的最小延迟(毫秒),如果存在大量未完成的变更。 +如果有较多尚未完成的变更,变更 MergeTree 表的最小延迟(以毫秒为单位)。 ## min_free_disk_bytes_to_perform_insert {#min_free_disk_bytes_to_perform_insert} -插入数据所需的磁盘空间中的最小可用字节数。如果可用的空闲字节数少于 `min_free_disk_bytes_to_perform_insert`,则将抛出异常,且不执行插入。请注意,此设置: -- 考虑了 `keep_free_space_bytes` 设置。 -- 不考虑将通过 `INSERT` 操作写入的数据量。 -- 仅在指定的字节数为正(非零)时检查。 +执行插入所需的磁盘空间中应保持空闲的最小字节数。如果可用的空闲字节数少于 `min_free_disk_bytes_to_perform_insert` ,则抛出异常并且不执行插入。请注意此设置: +- 考虑到 `keep_free_space_bytes` 设置。 +- 不考虑 `INSERT` 操作将写入的数据量。 +- 仅在指定了正(非零)字节数时进行检查。 可能的值: - 任何正整数。 :::note -如果同时指定了 `min_free_disk_bytes_to_perform_insert` 和 `min_free_disk_ratio_to_perform_insert`,ClickHouse 将计算允许在更大空闲内存中执行插入的值。 +如果同时指定了 `min_free_disk_bytes_to_perform_insert` 和 `min_free_disk_ratio_to_perform_insert`, ClickHouse 将在能在更大数量的空闲内存上执行插入的值上进行计数。 ::: ## min_free_disk_ratio_to_perform_insert {#min_free_disk_ratio_to_perform_insert} -执行 `INSERT` 所需的最小可用与总磁盘空间比率。必须是介于 0 和 1 之间的浮点值。请注意,此设置: -- 考虑了 `keep_free_space_bytes` 设置。 -- 不考虑将通过 `INSERT` 操作写入的数据量。 -- 仅在指定的比率为正(非零)时检查。 +执行 `INSERT` 的最小空闲与总磁盘空间的比率。必须是 0 到 1 之间的浮点值。请注意此设置: +- 考虑到 `keep_free_space_bytes` 设置。 +- 不考虑 `INSERT` 操作将写入的数据量。 +- 仅在指定了正(非零)比率的情况下进行检查。 可能的值: -- 浮点数,0.0 - 1.0 +- 浮点,0.0 - 1.0 -请注意,如果同时指定了 `min_free_disk_ratio_to_perform_insert` 和 `min_free_disk_bytes_to_perform_insert`,ClickHouse 将计算允许在更大空闲内存中执行插入的值。 +请注意,如果同时指定了 `min_free_disk_ratio_to_perform_insert` 和 `min_free_disk_bytes_to_perform_insert`, ClickHouse 将在能在更大数量的空闲内存上执行插入的值上进行计数。 ## min_index_granularity_bytes {#min_index_granularity_bytes} -允许的数据颗粒的最小字节数。 +最小允许的数据粒度大小(以字节为单位)。 -提供了对意外创建具有非常低 `index_granularity_bytes` 的表的保护措施。 +提供一种保护机制,防止意外创建 `index_granularity_bytes` 过低的表。 ## min_marks_to_honor_max_concurrent_queries {#min_marks_to_honor_max_concurrent_queries} -应用 [max_concurrent_queries](#max_concurrent_queries) 设置时,查询读取的最小标记数量。 +查询读取的最小标记数量,以应用 [max_concurrent_queries](#max_concurrent_queries) 设置。 :::note 查询仍将受到其他 `max_concurrent_queries` 设置的限制。 @@ -950,7 +1029,7 @@ ReplicatedMergeTree 队列中允许的变更部分的任务数量。 可能的值: - 正整数。 -- `0` — 禁用(不对任何查询应用 `max_concurrent_queries` 限制)。 +- `0` — 禁用(不对查询施加 `max_concurrent_queries` 限制)。 **示例** @@ -960,155 +1039,215 @@ ReplicatedMergeTree 队列中允许的变更部分的任务数量。 ## min_merge_bytes_to_use_direct_io {#min_merge_bytes_to_use_direct_io} -执行合并操作所需的最小数据量,用于直接 I/O 访问存储磁盘。当合并数据部分时,ClickHouse 计算所有要合并的数据的总存储量。如果该容量超过 `min_merge_bytes_to_use_direct_io` 字节,ClickHouse 将通过直接 I/O 接口(`O_DIRECT` 选项)来读取和写入数据。如果 `min_merge_bytes_to_use_direct_io = 0`,则禁用直接 I/O。 +进行合并操作所需的最小数据量,以便使用对存储磁盘的直接 I/O 访问。在合并数据部分时, ClickHouse 计算即将合并的所有数据的总体存储量。如果该量超过 `min_merge_bytes_to_use_direct_io` 字节, ClickHouse 将使用直接 I/O 接口(`O_DIRECT` 选项)读取和写入数据。如果 `min_merge_bytes_to_use_direct_io = 0`,则禁用直接 I/O。 ## min_parts_to_merge_at_once {#min_parts_to_merge_at_once} -合并选择器可以一次选择合并的最小数据部分数量(专家级设置,如不理解其作用请勿更改)。0 - 禁用。适用于简单和随机简单合并选择器。 +合并选择器可以一次选择的最小数据部分数量(专家级设置,如果不理解其作用,请勿更改)。0 - 禁用。适用于 Simple 和 StochasticSimple 合并选择器。 ## min_relative_delay_to_close {#min_relative_delay_to_close} -来自其他副本的最小延迟,以关闭、停止服务请求并在状态检查时不返回 Ok。 +关闭的最小相对延迟,停止服务请求并在状态检查时不返回正常。 ## min_relative_delay_to_measure {#min_relative_delay_to_measure} -仅在绝对延迟不小于该值的情况下计算相对副本延迟。 +仅在绝对延迟不小于该值时计算相对副本延迟。 ## min_relative_delay_to_yield_leadership {#min_relative_delay_to_yield_leadership} -过时设置,未执行任何操作。 +过时设置,无任何作用。 ## min_replicated_logs_to_keep {#min_replicated_logs_to_keep} -在 ZooKeeper 日志中保留大约这些数量的最后记录,即使它们是过时的。它对表的工作没有影响:仅用于在清理之前诊断 ZooKeeper 日志。 +在 ZooKeeper 日志中保留大约此数量的最后记录,即使它们已经过时。它不影响表的工作:仅用于在清理之前诊断 ZooKeeper 日志。 可能的值: - 任何正整数。 ## min_rows_for_compact_part {#min_rows_for_compact_part} -过时设置,未执行任何操作。 +过时设置,无任何作用。 ## min_rows_for_full_part_storage {#min_rows_for_full_part_storage} -仅在 ClickHouse Cloud 中可用。使用完整类型存储的数据部分的最小行数,而不是打包类型。 +仅在 ClickHouse Cloud 中可用。使用完整类型的存储来代替打包数据部分的最小行数。 ## min_rows_for_wide_part {#min_rows_for_wide_part} -以宽格式创建部分而不是紧凑部分的最小行数。 +创建宽格式部分的最小行数,而不是紧凑格式。 ## min_rows_to_fsync_after_merge {#min_rows_to_fsync_after_merge} 合并后执行 fsync 的最小行数(0 - 禁用)。 ## mutation_workload {#mutation_workload} -用于调节变更与其他工作负载之间的资源利用和共享。指定的值被用作此表的后台变更的 `workload` 设置值。如果未指定(空字符串),则使用服务器设置 `mutation_workload`。 -**另请参见** +用于调节资源在变更和其他工作负载之间的利用和共享。指定的值用作该表的背景变更的 `workload` 设置值。如果未指定(空字符串),则使用服务器设置 `mutation_workload`。 + +**另见** - [工作负载调度](/operations/workload-scheduling.md) ## non_replicated_deduplication_window {#non_replicated_deduplication_window} -非复制 [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) 表中最近插入的块的数量,用于存储 hash 和检查重复项。 +在非复制 [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) 表中,存储哈希和检查重复项的最近插入块的数量。 可能的值: - 任何正整数。 - `0`(禁用去重)。 -使用的去重机制与复制表相似(请参阅 [replicated_deduplication_window](#replicated_deduplication_window) 设置)。创建部分的哈希和写入到磁盘上的本地文件中。 +去重机制被采用,类似于复制表(见 [replicated_deduplication_window](#replicated_deduplication_window) 设置)。 +创建部分的哈希值写入磁盘的本地文件。 ## notify_newest_block_number {#notify_newest_block_number} -通知共享连接或共享集合的最新块编号。仅在 ClickHouse Cloud 中可用。 + +向 SharedJoin 或 SharedSet 通知最新块号。仅在 ClickHouse Cloud 中可用。 ## number_of_free_entries_in_pool_to_execute_mutation {#number_of_free_entries_in_pool_to_execute_mutation} -当池中的可用空闲条目少于指定数量时,不执行部分变更。这样做是为了留出空闲线程用于常规合并,避免 "Too many parts" 错误。 +当池中的空闲条目少于指定数量时,不要执行部分变更。这样可以为常规合并留出空闲线程,避免“部分过多”错误。 可能的值: - 任何正整数。 -**用法** +**用途** -`number_of_free_entries_in_pool_to_execute_mutation` 设置的值应小于 [background_pool_size](/operations/server-configuration-parameters/settings.md/#background_pool_size) 和 [background_merges_mutations_concurrency_ratio](/operations/server-configuration-parameters/settings.md/#background_merges_mutations_concurrency_ratio) 的值。否则,ClickHouse 将抛出异常。 +`number_of_free_entries_in_pool_to_execute_mutation` 设置的值应小于 [background_pool_size](/operations/server-configuration-parameters/settings.md/#background_pool_size) 和 [background_merges_mutations_concurrency_ratio](/operations/server-configuration-parameters/settings.md/#background_merges_mutations_concurrency_ratio) 的值。否则, ClickHouse 将抛出异常。 ## number_of_free_entries_in_pool_to_execute_optimize_entire_partition {#number_of_free_entries_in_pool_to_execute_optimize_entire_partition} -当池中的可用空闲条目少于指定数量时,不在后台执行优化整个分区的任务(当设置 `min_age_to_force_merge_seconds` 并启用 `min_age_to_force_merge_on_partition_only` 时生成此任务)。这样做是为了留出空闲线程用于常规合并,避免 "Too many parts" 错误。 +当池中的空闲条目少于指定数量时,不要在后台执行优化整个分区(当设置了 `min_age_to_force_merge_seconds` 并启用 `min_age_to_force_merge_on_partition_only` 时生成的任务)。这样可以为常规合并留出空闲线程,避免“部分过多”错误。 可能的值: - 正整数。 -`number_of_free_entries_in_pool_to_execute_optimize_entire_partition` 设置的值应小于 [background_pool_size](/operations/server-configuration-parameters/settings.md/#background_pool_size) 和 [background_merges_mutations_concurrency_ratio](/operations/server-configuration-parameters/settings.md/#background_merges_mutations_concurrency_ratio) 的值。否则,ClickHouse 将抛出异常。 +`number_of_free_entries_in_pool_to_execute_optimize_entire_partition` 设置的值应小于 [background_pool_size](/operations/server-configuration-parameters/settings.md/#background_pool_size) 和 [background_merges_mutations_concurrency_ratio](/operations/server-configuration-parameters/settings.md/#background_merges_mutations_concurrency_ratio) 的值。否则, ClickHouse 将抛出异常。 ## number_of_free_entries_in_pool_to_lower_max_size_of_merge {#number_of_free_entries_in_pool_to_lower_max_size_of_merge} -当池(或复制队列)中的可用空闲条目少于指定数量时,开始降低处理(或放入队列的)合并的最大大小。这是为了允许小型合并进行处理,不填充池以进行长时间运行的合并。 +当池中少于指定的空闲条目数(或复制队列)时,开始降低处理(或排队)过程中的最大合并大小。 +这样可以允许小规模合并处理,而不填满池中的长期运行合并。 可能的值: - 任何正整数。 ## number_of_mutations_to_delay {#number_of_mutations_to_delay} -如果表中至少存在那么多未完成的变更,则人工减慢表的变更速度。若设为 0 则禁用。 +如果表中至少有这么多未完成的变更,人工慢下变更的速度。设置为 0 则禁用此选项。 ## number_of_mutations_to_throw {#number_of_mutations_to_throw} -如果表中至少存在那么多未完成的变更,则抛出 "Too many mutations" 异常。若设为 0 则禁用。 +如果表中至少有这么多未完成的变更,则抛出“变更过多”的异常。设置为 0 则禁用此选项。 ## number_of_partitions_to_consider_for_merge {#number_of_partitions_to_consider_for_merge} -仅在 ClickHouse Cloud 中可用。我们将考虑合并的最多 N 个分区。随机加权选择的分区,其中权重是可以合并的该分区中的数据部分数量。 + +仅在 ClickHouse Cloud 中可用。考虑合并的前 N 个分区。根据可以合并的部分数据量以随机加权的方式选择分区。 +## object_serialization_version {#object_serialization_version} + + + + +JSON 数据类型的序列化版本。需要兼容性。 + +可能的值: +- `v1` +- `v2` +- `v3` + +仅 `v3` 版本支持更改共享数据序列化版本。 +## object_shared_data_buckets_for_compact_part {#object_shared_data_buckets_for_compact_part} + + + + +紧凑部分 JSON 共享数据序列化的桶数。适用于 `map_with_buckets` 和 `advanced` 共享数据序列化。 +## object_shared_data_buckets_for_wide_part {#object_shared_data_buckets_for_wide_part} + + + + +宽部分 JSON 共享数据序列化的桶数。适用于 `map_with_buckets` 和 `advanced` 共享数据序列化。 +## object_shared_data_serialization_version {#object_shared_data_serialization_version} + + + + +JSON 数据类型内部共享数据的序列化版本。 + +可能的值: +- `map` - 以 `Map(String, String)` 形式存储共享数据 +- `map_with_buckets` - 将共享数据存储为几个单独的 `Map(String, String)` 列。使用桶可以改善从共享数据读取单个路径的性能。 +- `advanced` - 设计用于显著提高从共享数据读取单个路径的性能的共享数据特定序列化方式。 +请注意,此序列化增加了磁盘上共享数据的存储大小,因为我们存储了大量额外信息。 + +`map_with_buckets` 和 `advanced` 序列化的桶数由设置 +[object_shared_data_buckets_for_compact_part](#object_shared_data_buckets_for_compact_part) / [object_shared_data_buckets_for_wide_part](#object_shared_data_buckets_for_wide_part) 来决定。 +## object_shared_data_serialization_version_for_zero_level_parts {#object_shared_data_serialization_version_for_zero_level_parts} + + + + +此设置允许为在插入期间创建的零级部分指定不同的共享数据的序列化版本。建议不要对零级部分使用 `advanced` 共享数据序列化,因为这会显著增加插入时间。 ## old_parts_lifetime {#old_parts_lifetime} -存储非活动部分的时间(以秒为单位),以保护数据不因服务器自发重启而丢失。 +存储非活跃部分以防止在服务器自发重启期间数据丢失的时间(以秒为单位)。 可能的值: - 任何正整数。 -在将几个部分合并为一个新部分后,ClickHouse 将原始部分标记为非活动,仅在 `old_parts_lifetime` 秒后删除。非活动部分在不被当前查询使用时被移除,即如果部分的 `refcount` 为 1。 +在将几个部分合并为新部分后, ClickHouse 将原始部分标记为非活跃,并仅在 `old_parts_lifetime` 秒后删除它们。 +如果非活跃部分未被当前查询使用,即其部分的 `refcount` 为 1,则移除该部分。 -在启动时,ClickHouse 会检查部分的完整性。如果合并部分损坏,ClickHouse 将把非活动部分返回到活动列表,稍后再次合并它们。然后,损坏的部分被重命名(添加前缀 `broken_`)并移动到 `detached` 文件夹。如果合并部分未损坏,那么原始非活动部分将被重命名(添加前缀 `ignored_`)并移动到 `detached` 文件夹。 +新部分在一段时间内只存在于服务器的RAM中(OS缓存),因此没有为新部分调用 `fsync`。如果服务器自发重启,新部分可能会丢失或损坏。为了保护数据,非活跃部分不会立即删除。 -默认的 `dirty_expire_centisecs` 值(Linux 内核设置)是 30 秒(写入数据仅存储在 RAM 中的最大时间),但在磁盘系统负载过重时,数据写入很晚。经过实验,选择了 480 秒作为 `old_parts_lifetime` 的值,在此期间新部分确保被写入磁盘。 +在启动期间, ClickHouse 会检查部分的完整性。如果已合并的部分损坏, ClickHouse 会将非活跃部分返回到活动列表,随后再次对其进行合并。然后,将损坏的部分重命名(添加 `broken_` 前缀)并移动到 `detached` 文件夹。如果合并的部分未损坏,则将原始非活跃部分重命名(添加 `ignored_` 前缀)并移动到 `detached` 文件夹。 + +默认 `dirty_expire_centisecs` 的值(Linux 内核设置)是 30秒(写入数据仅存储在RAM中的最大时间),但在磁盘系统负载较重的情况下,数据可能会写得更晚。通过实验,选择了480秒的 `old_parts_lifetime` 值,在此期间,新部分会被保证写入磁盘。 ## optimize_row_order {#optimize_row_order} -控制在插入时是否应优化行的顺序,以提高新插入表部分的可压缩性。 +控制在插入期间是否应优化行顺序,以改善新插入表部分的可压缩性。 -仅对普通的 MergeTree 引擎表有效。对专用 MergeTree 引擎表(例如 CollapsingMergeTree)无效。 +仅对普通的 MergeTree 引擎表有效。对特殊的 MergeTree 引擎表(例如 CollapsingMergeTree)没有任何作用。 -MergeTree 表使用 [压缩编码器](/sql-reference/statements/create/table#column_compression_codec) 进行压缩,压缩编解码器(如 LZ4 和 ZSTD)如果数据有模式,则可以达到最大压缩率。长重复的相同值通常能很好地压缩。 +MergeTree 表是(可选)使用 [压缩编解码器](/sql-reference/statements/create/table#column_compression_codec) 进行压缩的。 +通用压缩编解码器,如 LZ4 和 ZSTD,可以在数据暴露出模式的情况下实现最大压缩率。相同值的长运行通常压缩效果很好。 -如果启用此设置,ClickHouse 会尝试以一种行顺序来存储新插入部分中的数据,使得新表部分各列之间长值重复的数量最小。换句话说,较少的等值运行意味着单个运行较长且压缩效果良好。 +如果启用此设置, ClickHouse 会尝试以最小化新插入部分中跨列的相同值运行的数量的顺序存储数据。 +换句话说,较少的相同值运行意味着单个运行较长,且压缩效果较好。 -在查找最佳行顺序时是计算不可行的(NP 难),因此,ClickHouse 使用启发式方法迅速查找仍能提高压缩率的行顺序。 +寻找最佳的行顺序在计算上是不可行的(NP 难题)。 +因此, ClickHouse 使用启发式算法快速找到一个行顺序,该行顺序依然改善了原始行顺序的压缩率。
-查找行顺序的启发式方法 +寻找行顺序的启发式方法 -通常,可以自由地对表(或表的一部分)进行打乱,因为 SQL 认为不同的行顺序的相同表(部分)是等效的。 +通常可以自由地洗牌表(或表部分)的行,因为 SQL 将相同表(表部分)以不同的行顺序视为等效。 -当为表定义了主键时,这种打乱的自由度受到限制。在 ClickHouse 中,主键 `C1, C2, ..., CN` 强制要求表行按列 `C1`、`C2`、... `Cn` 排序([聚集索引](https://en.wikipedia.org/wiki/Database_index#Clustered))。因此,行只能在行的 "等价类" 内进行打乱,即在主键列中具有相同值的行。直觉是,具有高基数的主键(比如涉及 `DateTime64` 时间戳列的主键)会导致许多小的等价类。相反,具有低基数主键的表则创建少量且大的等价类。没有主键的表是一个极端情况,代表一个跨度所有行的单一等价类。 +当为表定义主键时,这种洗牌行的自由度会受到限制。在 ClickHouse 中,主键 `C1, C2, ..., CN` 强制要求表行按列 `C1`, `C2`, ... `Cn` 排序([聚集索引](https://en.wikipedia.org/wiki/Database_index#Clustered))。 +结果,行只能在行的“等价类”内进行洗牌,即在其主键列中具有相同值的行。 +直观地说,高基数的主键(例如涉及 `DateTime64` 时间戳列的主键)会导致许多小的等价类。类似地,较低基数主键的表会创建少量且较大的等价类。没有主键的表代表了一个跨越所有行的单一等价类的极端情况。 -等价类越少,越大,重新打乱行的自由度就越高。 +等价类越少、越大,重洗行时的自由度就越高。 -应用于查找每个等价类内最佳行顺序的启发式方法由 D. Lemire, O. Kaser 提出的 [调换列以缩小索引](https://doi.org/10.1016/j.ins.2011.02.002),基于按非主键列的升序基数对每个等价类中的行进行排序。 +应用于每个等价类内的最佳行顺序的启发式方法由 D. Lemire、O. Kaser 在 [Reordering columns for smaller indexes](https://doi.org/10.1016/j.ins.2011.02.002) 提出,并基于按非主键列的升序基数对每个等价类中的行进行排序。 -它执行两个步骤: -1. 根据主键列中的行值找到所有等价类。 -2. 对每个等价类,计算(通常估计)非主键列的基数。 -3. 对于每个等价类,按升序非主键列基数的顺序对行进行排序。 +它执行三个步骤: +1. 根据主键列的行值查找所有等价类。 +2. 对每个等价类,计算(通常是估计)非主键列的基数。 +3. 对于每个等价类,按非主键列基数的升序对行进行排序。
-如果启用,插入操作将增加额外的 CPU 成本,以分析和优化新数据的行顺序。根据数据特征,INSERT 操作预计将花费 30% 到 50% 的时间。 -LZ4 或 ZSTD 的压缩率平均提高 20% 到 40%。 +如果启用,则插入操作会产生额外的 CPU 成本,用于分析和优化新数据的行顺序。根据数据特征,预计 INSERT 操作将花费我们30-50%的时间。 +LZ4 或 ZSTD 的压缩率平均提高了 20-40%。 -此设置最适合没有主键或具有低基数主键的表,即只有少量不同主键值的表。具有高基数主键的表(例如涉及 `DateTime64` 类型的时间戳列的)预计不会受益于此设置。 +此设置对没有主键或低基数主键的表效果最佳,即只有有限的主键值的表。 +涉及 `DateTime64` 类型时间戳的高基数主键,预计不会从此设置中受益。 ## part_moves_between_shards_delay_seconds {#part_moves_between_shards_delay_seconds} @@ -1120,79 +1259,79 @@ LZ4 或 ZSTD 的压缩率平均提高 20% 到 40%。 -移动部分之间的分片的实验性/不完整功能。未考虑分片表达式。 +实验性/未完成的功能,用于在分片之间移动部分。不考虑分片表达式。 ## parts_to_delay_insert {#parts_to_delay_insert} -如果单个分区中的活动部分数量超过 `parts_to_delay_insert` 值,则人工放慢 `INSERT` 操作。 +如果单个分区中的活跃部分数量超过 `parts_to_delay_insert` 值,则 `INSERT` 会被人为延迟。 可能的值: - 任何正整数。 -ClickHouse 会人为延长 `INSERT` 操作(增加 'sleep'),以便后台合并进程可以比添加的速度更快地合并部分。 +ClickHouse 人为地延长 `INSERT` 的执行时间(添加“睡眠”),以便后台合并进程可以比添加的部分更快地合并部分。 ## parts_to_throw_insert {#parts_to_throw_insert} -如果单个分区中的活动部分数量超过 `parts_to_throw_insert` 值,则 `INSERT` 被打断,并抛出 `Too many parts (N). Merges are processing significantly slower than inserts` 异常。 +如果单个分区中的活跃部分数量超过 `parts_to_throw_insert` 值,则 `INSERT` 会被中断,并抛出 `Too many parts (N). Merges are processing significantly slower than inserts` 异常。 可能的值: - 任何正整数。 -为了达到 `SELECT` 查询的最佳性能,必须尽量减少处理的部分数量,参见 [Merge Tree](/development/architecture#merge-tree)。 +为了实现 `SELECT` 查询的最大性能,有必要最小化处理的部分数量,参见 [Merge Tree](/development/architecture#merge-tree)。 -在 23.6 版本之前,此设置被设置为 300。您可以设置更高的不同值,它会减少出现 `Too many parts` 错误的概率,但同时 `SELECT` 性能可能会降低。此外,如果合并出现问题(例如,由于磁盘空间不足),您会比使用原始 300 发现得更晚。 +在版本 23.6 之前,此设置默认为 300。您可以设置更高的不同值,以降低 `Too many parts` 错误的概率,但同时 `SELECT` 性能可能下降。此外,如果出现合并问题(例如,由于磁盘空间不足),您会比原来的 300 方案更晚注意到。 ## prefer_fetch_merged_part_size_threshold {#prefer_fetch_merged_part_size_threshold} -如果部分的大小总和超过此阈值,并且从复制日志条目创建的时间大于 `prefer_fetch_merged_part_time_threshold`,则更倾向于从副本中提取合并部分,而不是在本地进行合并。这是为了加速非常长的合并。 +如果部分大小的总和超过此阈值,并且自复制日志条目创建以来的时间大于 `prefer_fetch_merged_part_time_threshold`,则更倾向于从副本中获取合并部分,而不是在本地进行合并。这是为了加快非常长的合并过程。 可能的值: - 任何正整数。 ## prefer_fetch_merged_part_time_threshold {#prefer_fetch_merged_part_time_threshold} -如果从复制日志(ClickHouse Keeper 或 ZooKeeper)条目创建后的时间超过该阈值,并且部分的大小总和超过 `prefer_fetch_merged_part_size_threshold`,则更倾向于从副本中提取合并部分,而不是在本地进行合并。这是为了加速非常长的合并。 +如果自复制日志(ClickHouse Keeper 或 ZooKeeper)条目创建以来的时间超过此阈值,并且部分大小的总和大于 `prefer_fetch_merged_part_size_threshold`,则更倾向于从副本中获取合并部分,而不是在本地进行合并。这是为了加快非常长的合并过程。 可能的值: - 任何正整数。 ## prewarm_mark_cache {#prewarm_mark_cache} -如果为真,标记缓存将通过在插入、合并、抓取和服务器启动时保存标记到标记缓存来进行预热。 +如果为真,则通过在插入、合并、抓取和服务器启动时将标记保存到标记缓存来预热标记缓存。 ## prewarm_primary_key_cache {#prewarm_primary_key_cache} -如果为真,主索引缓存将通过在插入、合并、抓取和服务器启动时保存标记到标记缓存来进行预热。 +如果为真,则主键索引缓存将通过在插入、合并、抓取和服务器启动时将标记保存到标记缓存来预热。 ## primary_key_compress_block_size {#primary_key_compress_block_size} -主压缩块大小,用于压缩的实际块大小。 +主键压缩块的大小,即要压缩的实际块大小。 ## primary_key_compression_codec {#primary_key_compression_codec} -主使用的压缩编码,主键较小并已缓存,因此默认压缩为 ZSTD(3)。 +主键使用的压缩编码,主键的大小足够小且缓存,因此默认压缩为 ZSTD(3)。 ## primary_key_lazy_load {#primary_key_lazy_load} -首次使用时加载主键而不是在表初始化时加载。在存在大量表的情况下,可以节省内存。 +在第一次使用时将主键加载到内存中,而不是在表初始化时。这可以在表数量较多的情况下节省内存。 ## primary_key_ratio_of_unique_prefix_values_to_skip_suffix_columns {#primary_key_ratio_of_unique_prefix_values_to_skip_suffix_columns} -如果数据部分中主键列的某个值变化的比例至少达到此比率,则跳过将后续列加载到内存中。这使得通过不加载无用的主键列来节省内存使用。 +如果主键数据部分的某列的值至少在此比例的次数中发生变化,则跳过将下一个列加载到内存。这允许通过不加载无用的主键列来节省内存使用。 ## ratio_of_defaults_for_sparse_serialization {#ratio_of_defaults_for_sparse_serialization} -列中 _default_ 值与 _all_ 值的最小比例。设置此值会使列以稀疏序列化的方式存储。 +列中 _default_ 值与 _all_ 值数量的最小比例。设置此值会导致列使用稀疏序列化进行存储。 -如果某列是稀疏的(大多数是零),ClickHouse 可以以稀疏格式进行编码,并自动优化计算 - 数据在查询时不需要完全解压。要启用这种稀疏序列化,请将 `ratio_of_defaults_for_sparse_serialization` 设置为小于 1.0。如果该值大于或等于 1.0,则列将始终使用正常的完整序列化进行写入。 +如果列是稀疏的(主要包含零),ClickHouse 可以以稀疏格式对其进行编码,并自动优化计算 - 查询期间不需要对数据进行完全解压缩。要启用这种稀疏序列化,请将 `ratio_of_defaults_for_sparse_serialization` 设置为小于 1.0。如果值大于或等于 1.0,则将始终使用正常的完全序列化进行写入。 -可能的值: +可能值: -- 在 `0` 和 `1` 之间的浮点数以启用稀疏序列化 -- `1.0`(或更大)如果您不想使用稀疏序列化 +- 在 `0` 和 `1` 之间的浮点数,启用稀疏序列化 +- `1.0`(或更高),如果您不想使用稀疏序列化 **示例** -注意以下表中的 `s` 列在 95% 的行中都是空字符串。在 `my_regular_table` 中,我们不使用稀疏序列化,而在 `my_sparse_table` 中,我们将 `ratio_of_defaults_for_sparse_serialization` 设置为 0.95: +请注意,以下表中的 `s` 列在 95% 的行中是空字符串。在 `my_regular_table` 中,我们不使用稀疏序列化,而在 `my_sparse_table` 中我们将 `ratio_of_defaults_for_sparse_serialization` 设置为 0.95: ```sql CREATE TABLE my_regular_table @@ -1228,7 +1367,7 @@ FROM numbers(10000000); ``` -注意 `my_sparse_table` 中的 `s` 列在磁盘上使用的存储空间更少: +请注意,`my_sparse_table` 中的 `s` 列在磁盘上使用的存储空间更少: ```sql SELECT table, name, data_compressed_bytes, data_uncompressed_bytes FROM system.columns @@ -1244,14 +1383,14 @@ WHERE table LIKE 'my_%_table'; └──────────────────┴──────┴───────────────────────┴─────────────────────────┘ ``` -您可以通过查看 `system.parts_columns` 表的 `serialization_kind` 列来验证某列是否使用稀疏编码: +您可以通过查看 `system.parts_columns` 表的 `serialization_kind` 列来验证列是否使用稀疏编码: ```sql SELECT column, serialization_kind FROM system.parts_columns WHERE table LIKE 'my_sparse_table'; ``` -您可以查看 `s` 的哪些部分是使用稀疏序列化存储的: +您可以查看哪些 `s` 部分是以稀疏序列化方式存储的: ```response ┌─column─┬─serialization_kind─┐ @@ -1283,293 +1422,286 @@ WHERE table LIKE 'my_sparse_table'; -仅在 ClickHouse Cloud 中可用。未丢弃/替换任何范围后,尝试再次减少阻塞部分前的最小等待时间。较低的设置会频繁触发后台调度池中的任务,从而导致在大规模集群中出现大量请求到 zookeeper。 - +仅在 ClickHouse Cloud 中可用。在没有丢弃/替换范围的情况下,尝试再次减少阻塞部分的最小等待时间。较低的设置会频繁触发背景_schedule_pool 中的任务,这会导致在大规模集群中向 ZooKeeper 发出大量请求。 ## refresh_parts_interval {#refresh_parts_interval} -如果大于零 - 刷新来自底层文件系统的数据部分列表,以检查数据是否在内部已经更新。仅当表位于只读磁盘上时(这意味着这是一个只读副本,而数据由另一个副本写入)才能设置。 - +如果大于零,则从基础文件系统刷新数据部分的列表,以检查数据是否在后台更新。仅在表位于只读磁盘上时可以设置(这意味着这是一个只读副本,而数据由另一个副本进行写入)。 ## remote_fs_execute_merges_on_single_replica_time_threshold {#remote_fs_execute_merges_on_single_replica_time_threshold} -当该设置的值大于零时,只有单个副本在合并部分存储在共享存储上并且启用了 `allow_remote_fs_zero_copy_replication` 时,立即启动合并。 +当此设置的值大于零时,仅有一个副本会立即启动合并,前提是合并部分在共享存储中。 :::note 零拷贝复制尚未准备好用于生产 -在 ClickHouse 22.8 及更高版本中,默认情况下禁用零拷贝复制。 +在 ClickHouse 版本 22.8 和更高版本中,零拷贝复制默认被禁用。 -不建议在生产中使用此功能。 +不建议在生产环境中使用此功能。 ::: 可能的值: - 任何正整数。 - ## remote_fs_zero_copy_path_compatible_mode {#remote_fs_zero_copy_path_compatible_mode} 在转换过程中以兼容模式运行零拷贝。 - ## remote_fs_zero_copy_zookeeper_path {#remote_fs_zero_copy_zookeeper_path} -零拷贝表独立信息的 ZooKeeper 路径。 - +用于零拷贝表的 ZooKeeper 路径,无表信息。 ## remove_empty_parts {#remove_empty_parts} -在被 TTL、突变或合并算法修剪后,移除空部分。 - +在通过 TTL、突变或合并算法修剪后删除空部分。 ## remove_rolled_back_parts_immediately {#remove_rolled_back_parts_immediately} -不完整实验功能的设置。 - +不完整实验特性的设置。 ## remove_unused_patch_parts {#remove_unused_patch_parts} -在后台移除应用于所有活动部分的补丁部分。 - +在后台删除所有活跃部分所应用的补丁部分。 ## replace_long_file_name_to_hash {#replace_long_file_name_to_hash} 如果列的文件名过长(超过 'max_file_name_length' 字节),则将其替换为 SipHash128。 - ## replicated_can_become_leader {#replicated_can_become_leader} -如果为 true,则此节点上的复制作副本将尝试获得领导权。 +如果为真,此节点上的复制表副本将尝试获取领导权。 可能的值: - `true` - `false` - ## replicated_deduplication_window {#replicated_deduplication_window} - + + -ClickHouse Keeper 存储的用于检查重复项的最近插入块的数量的哈希值。 +ClickHouse Keeper 存储的最近插入的块数量,用于检查重复项的哈希值。 可能的值: - 任何正整数。 -- 0(禁用去重)。 +- 0(禁用去重) -`Insert` 命令会创建一个或多个块(部分)。对于[插入去重](../../engines/table-engines/mergetree-family/replication.md),在写入复制作表时,ClickHouse 会将创建部分的哈希值写入 ClickHouse Keeper。哈希值仅存储最新的 `replicated_deduplication_window` 块。最旧的哈希值会从 ClickHouse Keeper 中移除。 - -较大的 `replicated_deduplication_window` 会降低 `Inserts` 的速度,因为需要比较更多条目。哈希值是根据字段名称、类型和插入部分数据(字节流)组成计算的。 +`Insert` 命令创建一个或多个块(部分)。对于 [insert deduplication](../../engines/table-engines/mergetree-family/replication.md),在写入复制表时,ClickHouse 将已创建部分的哈希值写入 ClickHouse Keeper。哈希值仅存储最近的 `replicated_deduplication_window` 块。最旧的哈希值会从 ClickHouse Keeper 中删除。 +对于 `replicated_deduplication_window` 的较大值会减缓 `Inserts` 的速度,因为需要比较更多的条目。哈希值是通过字段名称和类型的组合以及插入部分的数据(字节流)计算得出的。 ## replicated_deduplication_window_for_async_inserts {#replicated_deduplication_window_for_async_inserts} -ClickHouse Keeper 存储的用于检查重复项的最近异步插入块的数量的哈希值。 +最近异步插入块的数量,ClickHouse Keeper 用于检查重复项的哈希值。 可能的值: - 任何正整数。 -- 0(禁用异步插入的去重)。 +- 0(禁用 async_inserts 的去重) -[异步插入](/operations/settings/settings#async_insert)命令将被缓存到一个或多个块(部分)。对于[插入去重](/engines/table-engines/mergetree-family/replication),在写入复制作表时,ClickHouse 会将每个插入的哈希值写入 ClickHouse Keeper。哈希值仅存储最新的 `replicated_deduplication_window_for_async_inserts` 块。最旧的哈希值会从 ClickHouse Keeper 中移除。 -较大的 `replicated_deduplication_window_for_async_inserts` 会降低 `异步插入` 的速度,因为需要比较更多条目。 -哈希值是根据字段名称、类型和插入(字节流)数据的组成计算的。 +[Async Insert](/operations/settings/settings#async_insert) 命令将在一个或多个块(部分)中缓存。在写入复制表时,ClickHouse 将每个插入的哈希值写入 ClickHouse Keeper。哈希值仅存储最近的 `replicated_deduplication_window_for_async_inserts` 块。最旧的哈希值会从 ClickHouse Keeper 中删除。 +较高的 `replicated_deduplication_window_for_async_inserts` 值会减缓 `Async Inserts` 的速度,因为需要比较更多的条目。哈希值是通过字段名称和类型的组合以及插入的数据(字节流)计算得出的。 ## replicated_deduplication_window_seconds {#replicated_deduplication_window_seconds} - + + -ClickHouse Keeper 中移除插入块的哈希值的秒数。 +在 ClickHouse Keeper 中删除插入块的哈希值的秒数。 可能的值: - 任何正整数。 -与[replicated_deduplication_window](#replicated_deduplication_window)相似,`replicated_deduplication_window_seconds` 指定存储用于插入去重的块的哈希值的时间。超过 `replicated_deduplication_window_seconds` 的哈希值将从 ClickHouse Keeper 中移除,即使它们少于 `replicated_deduplication_window`。 - -该时间是相对于最近记录的时间,而不是墙面时间。如果它是唯一的记录,它将永远存储。 +类似于 [replicated_deduplication_window](#replicated_deduplication_window),`replicated_deduplication_window_seconds` 指定存储插入去重的块哈希值的时间。哈希值在大于 `replicated_deduplication_window_seconds` 后会从 ClickHouse Keeper 中删除,即使它们小于 `replicated_deduplication_window`。 +时间是相对于最近记录的时间,而不是墙面时间。如果它是唯一的记录,它将永远存储。 ## replicated_deduplication_window_seconds_for_async_inserts {#replicated_deduplication_window_seconds_for_async_inserts} -ClickHouse Keeper 中移除异步插入哈希值的秒数。 +在 ClickHouse Keeper 中删除异步插入哈希值的秒数。 可能的值: - 任何正整数。 -与[replicated_deduplication_window_for_async_inserts](#replicated_deduplication_window_for_async_inserts)相似,`replicated_deduplication_window_seconds_for_async_inserts` 指定存储用于异步插入去重的块的哈希值的时间。超过 `replicated_deduplication_window_seconds_for_async_inserts` 的哈希值将从 ClickHouse Keeper 中移除,即使它们少于 `replicated_deduplication_window_for_async_inserts`。 - -该时间是相对于最近记录的时间,而不是墙面时间。如果它是唯一的记录,它将永远存储。 +类似于 [replicated_deduplication_window_for_async_inserts](#replicated_deduplication_window_for_async_inserts),`replicated_deduplication_window_seconds_for_async_inserts` 指定存储异步插入去重的块哈希值的时间。哈希值在大于 `replicated_deduplication_window_seconds_for_async_inserts` 后会从 ClickHouse Keeper 中删除,即使它们小于 `replicated_deduplication_window_for_async_inserts`。 +时间是相对于最近记录的时间,而不是墙面时间。如果它是唯一的记录,它将永远存储。 ## replicated_fetches_http_connection_timeout {#replicated_fetches_http_connection_timeout} -过期设置,不执行任何操作。 - +过时的设置,不执行任何操作。 ## replicated_fetches_http_receive_timeout {#replicated_fetches_http_receive_timeout} -过期设置,不执行任何操作。 - +过时的设置,不执行任何操作。 ## replicated_fetches_http_send_timeout {#replicated_fetches_http_send_timeout} -过期设置,不执行任何操作。 - +过时的设置,不执行任何操作。 ## replicated_max_mutations_in_one_entry {#replicated_max_mutations_in_one_entry} -在一个 MUTATE_PART 条目中可以合并的最大突变命令数(0 表示无限制)。 - +可以合并在一个 MUTATE_PART 条目中执行的最大突变命令数量(0 表示无限制) ## replicated_max_parallel_fetches {#replicated_max_parallel_fetches} -过期设置,不执行任何操作。 - +过时的设置,不执行任何操作。 ## replicated_max_parallel_fetches_for_host {#replicated_max_parallel_fetches_for_host} -过期设置,不执行任何操作。 - +过时的设置,不执行任何操作。 ## replicated_max_parallel_fetches_for_table {#replicated_max_parallel_fetches_for_table} -过期设置,不执行任何操作。 - +过时的设置,不执行任何操作。 ## replicated_max_parallel_sends {#replicated_max_parallel_sends} -过期设置,不执行任何操作。 - +过时的设置,不执行任何操作。 ## replicated_max_parallel_sends_for_table {#replicated_max_parallel_sends_for_table} -过期设置,不执行任何操作。 - +过时的设置,不执行任何操作。 ## replicated_max_ratio_of_wrong_parts {#replicated_max_ratio_of_wrong_parts} -如果错误部分与总部分的比例小于此,允许开始。 +如果错误部分与总部分数量的比例小于此值 - 允许启动。 + +可能的值: +- 浮点数,0.0 - 1.0 +## search_orphaned_parts_disks {#search_orphaned_parts_disks} + + + +ClickHouse 在任何 ATTACH 或 CREATE 表时扫描所有磁盘以查找孤立部分,以确保不会遗漏未定义(未包含在策略中的)磁盘上的数据部分。孤立部分源于潜在不安全的存储重新配置,例如,如果某个磁盘被排除在存储策略之外。 +此设置通过磁盘的特征限制搜索范围。 可能的值: -- 浮点数,0.0 - 1.0。 +- any - 范围不受限制。 +- local - 范围仅限于本地磁盘。 +- none - 空范围,不进行搜索。 +## serialization_info_version {#serialization_info_version} + + +写入 `serialization.json` 时使用的序列化信息版本。此设置在集群升级时是兼容性所必需的。 + +可能的值: +- `DEFAULT` + +- `WITH_TYPES` +使用新格式写入,并允许每种类型的序列化版本。这使得像 `string_serialization_version` 这样的设置生效。 + +在滚动升级期间,将此设置为 `DEFAULT`,以使新服务器生成与旧服务器兼容的数据部分。升级完成后,切换到 `WITH_TYPES` 以启用每种类型的序列化版本。 ## shared_merge_tree_create_per_replica_metadata_nodes {#shared_merge_tree_create_per_replica_metadata_nodes} -启用在 ZooKeeper 中为每个副本创建 /metadata 和 /columns 节点。仅在 ClickHouse Cloud 中可用。 - +启用在 ZooKeeper 中为每个副本创建 /metadata 和 /columns 节点。 +仅在 ClickHouse Cloud 中可用。 ## shared_merge_tree_disable_merges_and_mutations_assignment {#shared_merge_tree_disable_merges_and_mutations_assignment} -停止共享合并树的合并分配。仅在 ClickHouse Cloud 中可用。 +停止为共享合并树分配合并。仅在 ClickHouse Cloud 中可用。 +## shared_merge_tree_empty_partition_lifetime {#shared_merge_tree_empty_partition_lifetime} + + +如果分区没有部分,则该分区将在 Keeper 中存储多少秒。 +## shared_merge_tree_enable_automatic_empty_partitions_cleanup {#shared_merge_tree_enable_automatic_empty_partitions_cleanup} + + + +启用对空分区的 Keeper 条目的清理。 ## shared_merge_tree_enable_coordinated_merges {#shared_merge_tree_enable_coordinated_merges} -启用协调合并策略。 - +启用协同合并策略。 ## shared_merge_tree_enable_keeper_parts_extra_data {#shared_merge_tree_enable_keeper_parts_extra_data} -启用在虚拟部分中写入属性并在 Keeper 中提交块。 - +启用将属性写入虚拟部分并在 Keeper 中提交块。 ## shared_merge_tree_enable_outdated_parts_check {#shared_merge_tree_enable_outdated_parts_check} -启用过期部分检查。仅在 ClickHouse Cloud 中可用。 - +启用过时部分检查。仅在 ClickHouse Cloud 中可用。 ## shared_merge_tree_idle_parts_update_seconds {#shared_merge_tree_idle_parts_update_seconds} -在共享合并树中,不被 ZooKeeper 监视触发的部分更新的间隔(以秒为单位)。仅在 ClickHouse Cloud 中可用。 - +在共享合并树中,未通过 ZooKeeper 监视触发的部分更新的间隔时间(以秒为单位)。仅在 ClickHouse Cloud 中可用。 ## shared_merge_tree_initial_parts_update_backoff_ms {#shared_merge_tree_initial_parts_update_backoff_ms} 部分更新的初始退避。仅在 ClickHouse Cloud 中可用。 - ## shared_merge_tree_interserver_http_connection_timeout_ms {#shared_merge_tree_interserver_http_connection_timeout_ms} -服务器间 HTTP 连接的超时。仅在 ClickHouse Cloud 中可用。 - +服务器间 HTTP 连接的超时,仅在 ClickHouse Cloud 中可用。 ## shared_merge_tree_interserver_http_timeout_ms {#shared_merge_tree_interserver_http_timeout_ms} -服务器间 HTTP 通信的超时。仅在 ClickHouse Cloud 中可用。 - +服务器间 HTTP 通信的超时,仅在 ClickHouse Cloud 中可用。 ## shared_merge_tree_leader_update_period_random_add_seconds {#shared_merge_tree_leader_update_period_random_add_seconds} -在共享合并树领导者更新周期中添加均匀分布的 0 到 x 秒的值,以避免冲击效应。仅在 ClickHouse Cloud 中可用。 - +在共享合并树的 leader_update_period 上均匀分布添加 0 到 x 秒的值,以避免雷声效应。仅在 ClickHouse Cloud 中可用。 ## shared_merge_tree_leader_update_period_seconds {#shared_merge_tree_leader_update_period_seconds} -重新检查部分更新的领导权的最长时间。仅在 ClickHouse Cloud 中可用。 - +重新检查部分更新领导的最大周期。仅在 ClickHouse Cloud 中可用。 ## shared_merge_tree_max_outdated_parts_to_process_at_once {#shared_merge_tree_max_outdated_parts_to_process_at_once} -领导者尝试确认移除的最大过期部分数量,一次 HTTP 请求中。仅在 ClickHouse Cloud 中可用。 - +一次 HTTP 请求中,领导者将尝试确认要删除的最大过时部分数量。仅在 ClickHouse Cloud 中可用。 ## shared_merge_tree_max_parts_update_backoff_ms {#shared_merge_tree_max_parts_update_backoff_ms} 部分更新的最大退避。仅在 ClickHouse Cloud 中可用。 - ## shared_merge_tree_max_parts_update_leaders_in_total {#shared_merge_tree_max_parts_update_leaders_in_total} -最大的部分更新领导者数量。仅在 ClickHouse Cloud 中可用。 - +最大部分更新领导者的数量。仅在 ClickHouse Cloud 中可用。 ## shared_merge_tree_max_parts_update_leaders_per_az {#shared_merge_tree_max_parts_update_leaders_per_az} -每个可用区的最大部分更新领导者数量。仅在 ClickHouse Cloud 中可用。 - +最大部分更新领导者的数量。仅在 ClickHouse Cloud 中可用。 ## shared_merge_tree_max_replicas_for_parts_deletion {#shared_merge_tree_max_replicas_for_parts_deletion} -参与部分删除(杀手线程)的最大副本数量。仅在 ClickHouse Cloud 中可用。 - +参与部分删除的最大副本(杀手线程)。仅在 ClickHouse Cloud 中可用。 ## shared_merge_tree_max_replicas_to_merge_parts_for_each_parts_range {#shared_merge_tree_max_replicas_to_merge_parts_for_each_parts_range} -每个部分范围尝试分配潜在冲突合并的最大副本数量(允许避免合并分配中的冗余冲突)。0 表示禁用。仅在 ClickHouse Cloud 中可用。 - +尝试分配潜在冲突合并的最大副本数量(允许避免合并分配中的冗余冲突)。 0 表示禁用。仅在 ClickHouse Cloud 中可用。 ## shared_merge_tree_max_suspicious_broken_parts {#shared_merge_tree_max_suspicious_broken_parts} -对于 SMT 的最大破损部分,如果超过,拒绝自动分离。 - +SMT 最大损坏部分数量,如果超过 - 拒绝自动分离。 ## shared_merge_tree_max_suspicious_broken_parts_bytes {#shared_merge_tree_max_suspicious_broken_parts_bytes} -最大破损部分总大小,如果超过,拒绝自动分离。 - +SMT 最大损坏部分的总字节数,如果超过 - 拒绝自动分离。 ## shared_merge_tree_memo_ids_remove_timeout_seconds {#shared_merge_tree_memo_ids_remove_timeout_seconds} -我们存储插入记忆化 ID 的时间,以避免在插入重试期间发生错误操作。仅在 ClickHouse Cloud 中可用。 - +我们存储插入记忆 ID 的时间,以避免在重试插入期间进行错误操作。仅在 ClickHouse Cloud 中可用。 ## shared_merge_tree_merge_coordinator_election_check_period_ms {#shared_merge_tree_merge_coordinator_election_check_period_ms} @@ -1577,63 +1709,55 @@ ClickHouse Keeper 中移除异步插入哈希值的秒数。 合并协调器选举线程运行之间的时间。 - ## shared_merge_tree_merge_coordinator_factor {#shared_merge_tree_merge_coordinator_factor} -协调线程延迟的时间变化因子。 - +用于延迟协调器线程的时间变化因子。 ## shared_merge_tree_merge_coordinator_fetch_fresh_metadata_period_ms {#shared_merge_tree_merge_coordinator_fetch_fresh_metadata_period_ms} -合并协调器多久应与 ZooKeeper 同步以获取新元数据。 - +合并协调器与 ZooKeeper 同步以获取新元数据的频率。 ## shared_merge_tree_merge_coordinator_max_merge_request_size {#shared_merge_tree_merge_coordinator_max_merge_request_size} -协调器可以一次向 MergerMutator 请求的合并数量。 - +协调器可以一次请求的合并数量。 ## shared_merge_tree_merge_coordinator_max_period_ms {#shared_merge_tree_merge_coordinator_max_period_ms} -合并协调器线程运行之间的最长时间。 - +合并协调器线程运行之间的最大时间。 ## shared_merge_tree_merge_coordinator_merges_prepare_count {#shared_merge_tree_merge_coordinator_merges_prepare_count} -协调器应准备并分配给工作线程的合并条目数量。 - +协调器应该准备并在工作者中分配的合并条目数量。 ## shared_merge_tree_merge_coordinator_min_period_ms {#shared_merge_tree_merge_coordinator_min_period_ms} -合并协调器线程运行之间的最小时间。 - +合并协调员线程运行之间的最小时间。 ## shared_merge_tree_merge_worker_fast_timeout_ms {#shared_merge_tree_merge_worker_fast_timeout_ms} -如果需要在立即操作后更新其状态,合并工作线程将使用的超时。 - +合并工作线程在需要立即更新其状态后使用的超时。 ## shared_merge_tree_merge_worker_regular_timeout_ms {#shared_merge_tree_merge_worker_regular_timeout_ms} @@ -1641,230 +1765,241 @@ ClickHouse Keeper 中移除异步插入哈希值的秒数。 合并工作线程运行之间的时间。 +## shared_merge_tree_outdated_parts_group_size {#shared_merge_tree_outdated_parts_group_size} + + +在进行过时部分清理时,有多少副本将进入同一个汇合哈希组。 +仅在 ClickHouse Cloud 中可用。 ## shared_merge_tree_partitions_hint_ratio_to_reload_merge_pred_for_mutations {#shared_merge_tree_partitions_hint_ratio_to_reload_merge_pred_for_mutations} -当 `/` 的比例高于设置时,将重新加载合并谓词。仅在 ClickHouse Cloud 中可用。 - +当 `/` 的比率高于设置时,将在合并/突变选择任务中重新加载合并谓词。仅在 ClickHouse Cloud 中可用。 ## shared_merge_tree_parts_load_batch_size {#shared_merge_tree_parts_load_batch_size} -一次调度的获取部分元数据作业数量。仅在 ClickHouse Cloud 中可用。 - +一次调度的取件部分元数据作业数量。仅在 ClickHouse Cloud 中可用。 ## shared_merge_tree_postpone_next_merge_for_locally_merged_parts_ms {#shared_merge_tree_postpone_next_merge_for_locally_merged_parts_ms} -在不启动包含此部分的新合并的情况下,保持本地合并部分的时间。为其他副本提供机会获取该部分并启动此合并。仅在 ClickHouse Cloud 中可用。 - +在本地合并部分后,保持多长时间才能启动包含此部分的新合并。给其他副本一个机会抓取该部分并启动此合并。 +仅在 ClickHouse Cloud 中可用。 ## shared_merge_tree_postpone_next_merge_for_locally_merged_parts_rows_threshold {#shared_merge_tree_postpone_next_merge_for_locally_merged_parts_rows_threshold} -本地合并后,推迟分配下一个合并的部分的最小大小(以行数为单位)。仅在 ClickHouse Cloud 中可用。 - +本部分的最小大小(以行数计),以推迟在本地合并后立即分配下一个合并。仅在 ClickHouse Cloud 中可用。 ## shared_merge_tree_range_for_merge_window_size {#shared_merge_tree_range_for_merge_window_size} -在不启动包含此部分的新合并的情况下,保持本地合并部分的时间。为其他副本提供机会获取该部分并启动此合并。仅在 ClickHouse Cloud 中可用。 - +在本地合并部分后,保持多长时间才能启动包含此部分的新合并。给其他副本一个机会抓取该部分并启动此合并。 +仅在 ClickHouse Cloud 中可用。 ## shared_merge_tree_read_virtual_parts_from_leader {#shared_merge_tree_read_virtual_parts_from_leader} -在可能的情况下从领导者读取虚拟部分。仅在 ClickHouse Cloud 中可用。 - +在可能的情况下,从领导者读取虚拟部分。仅在 ClickHouse Cloud 中可用。 ## shared_merge_tree_try_fetch_part_in_memory_data_from_replicas {#shared_merge_tree_try_fetch_part_in_memory_data_from_replicas} -如果启用,所有副本尝试从其他副本中获取部分内存数据(如主键、分区信息等)。 +如果启用,所有副本将尝试从其他已有该部分的副本中获取内存数据(如主键、分区信息等)。 +## shared_merge_tree_update_replica_flags_delay_ms {#shared_merge_tree_update_replica_flags_delay_ms} + + +副本将根据后台调度多长时间尝试重新加载其标志。 ## shared_merge_tree_use_metadata_hints_cache {#shared_merge_tree_use_metadata_hints_cache} -启用请求来自其他副本的内存缓存中的文件系统缓存提示。仅在 ClickHouse Cloud 中可用。 - +启用从其他副本的内存缓存请求文件系统缓存提示。仅在 ClickHouse Cloud 中可用。 ## shared_merge_tree_use_outdated_parts_compact_format {#shared_merge_tree_use_outdated_parts_compact_format} - - - -对过时部分使用紧凑格式:减少对 Keeper 的负载,改善对过时部分的处理。仅在 ClickHouse Cloud 中可用。 + + +对过时部分使用紧凑格式:减少对 Keeper 的负载,提高过时部分的处理。仅在 ClickHouse Cloud 中可用。 ## shared_merge_tree_use_too_many_parts_count_from_virtual_parts {#shared_merge_tree_use_too_many_parts_count_from_virtual_parts} -如果启用,过多部分计数将依赖于 Keeper 中的共享数据,而不是本地副本状态。仅在 ClickHouse Cloud 中可用。 +如果启用,过多部分计数将依赖于 Keeper 的共享数据,而不是本地副本状态。仅在 ClickHouse Cloud 中可用。 +## shared_merge_tree_virtual_parts_discovery_batch {#shared_merge_tree_virtual_parts_discovery_batch} + + + + +应该打包在批处理中的分区发现数量。 ## simultaneous_parts_removal_limit {#simultaneous_parts_removal_limit} -如果存在大量过期部分,清理线程将在一次迭代中尝试删除最多 `simultaneous_parts_removal_limit` 个部分。 -将 `simultaneous_parts_removal_limit` 设置为 `0` 意味着无限制。 - +如果有大量过时部分,清理线程将尝试在一个迭代中删除最多 `simultaneous_parts_removal_limit` 部分。 +将 `simultaneous_parts_removal_limit` 设置为 `0` 表示无限制。 ## sleep_before_commit_local_part_in_replicated_table_ms {#sleep_before_commit_local_part_in_replicated_table_ms} 用于测试。请勿更改。 - ## sleep_before_loading_outdated_parts_ms {#sleep_before_loading_outdated_parts_ms} 用于测试。请勿更改。 - ## storage_policy {#storage_policy} 存储磁盘策略的名称。 +## string_serialization_version {#string_serialization_version} + + + +控制顶级 `String` 列的序列化格式。 + +此设置仅在 `serialization_info_version` 设置为 "with_types" 时有效。 +启用时,顶级 `String` 列将使用单独的 `.size` 子列进行序列化,存储字符串长度,而不是内联。这允许真正的 `.size` 子列并可以提高压缩效率。 +嵌套的 `String` 类型(例如,内部在 `Nullable`、`LowCardinality`、`Array` 或 `Map`)不受影响,除非它们出现在 `Tuple` 中。 + +可能的值: + +- `DEFAULT` — 使用带内联大小的标准序列化格式。 +- `WITH_SIZE_STREAM` — 为顶级 `String` 列使用单独的大小流。 ## table_disk {#table_disk} -这是表磁盘,路径/端点应指向表数据,而不是数据库数据。仅可为 s3_plain/s3_plain_rewritable/web 设置。 - +这是表磁盘,路径/端点应指向表数据,而不是数据库数据。仅能为 s3_plain/s3_plain_rewritable/web 设置。 ## temporary_directories_lifetime {#temporary_directories_lifetime} -保持 tmp_- 目录的秒数。您不应降低此值,因为合并和突变可能无法在此设置的低值下工作。 - +临时目录的存储时间(以秒为单位)。您不应降低此值,因为合并和突变可能无法正常工作,尤其是在该设置值较低的情况下。 ## try_fetch_recompressed_part_timeout {#try_fetch_recompressed_part_timeout} -在启动合并与重压缩之前的超时(以秒为单位)。在此期间,ClickHouse 尝试从分配该合并的副本中获取重新压缩的部分。 +启动合并并进行重新压缩的超时(以秒为单位)。在此期间,ClickHouse 会尝试从分配了此合并的副本中抓取重新压缩的部分。 -在大多数情况下,重新压缩运行缓慢,因此我们在超时之前不会启动重压缩的合并,并尝试从分配该合并的副本中获取重新压缩的部分。 +在大多数情况下,重新压缩速度较慢,因此在此超时之前我们不会启动合并并尝试从分配了此合并的副本中抓取重新压缩的部分。 可能的值: - 任何正整数。 - ## ttl_only_drop_parts {#ttl_only_drop_parts} -控制当该部分中所有行根据其 `TTL` 设置过期时,MergeTree 表中数据部分是否完全丢弃。 +控制在 MergeTree 表中,当该部分的所有行根据其 `TTL` 设置已过期时,数据部分是否完全删除。 -当 `ttl_only_drop_parts` 被禁用(默认情况下),仅根据其 TTL 设置过期的行被移除。 - -当 `ttl_only_drop_parts` 启用时,如果该部分中所有行根据其 `TTL` 设置过期,则整个部分将被丢弃。 +当 `ttl_only_drop_parts` 禁用(默认为)时,仅删除根据其 TTL 设置过期的行。 +当 `ttl_only_drop_parts` 启用时,如果该部分的所有行根据其 `TTL` 设置过期,则整个部分会被删除。 ## use_adaptive_write_buffer_for_dynamic_subcolumns {#use_adaptive_write_buffer_for_dynamic_subcolumns} -允许在写入动态子列时使用自适应写入缓冲区以减少内存使用。 - +在写入动态子列时允许使用自适应写入缓冲区,以减少内存使用。 ## use_async_block_ids_cache {#use_async_block_ids_cache} -如果为 true,则缓存异步插入的哈希值。 +如果为真,我们缓存异步插入的哈希值。 可能的值: - `true` - `false` -一个包含多个异步插入的块将生成多个哈希值。当某些插入重复时,Keeper 仅在一个 RPC 中返回一个重复的哈希值,这将导致不必要的 RPC 重试。此缓存将监视 Keeper 中的哈希值路径。如果在 Keeper 中监视到更新,缓存将尽快更新,以便我们能够在内存中筛选重复的插入。 - +一个块包含多个异步插入将生成多个哈希值。 +当某些插入重复时,Keeper 将在一个 RPC 中仅返回一个重复的哈希值,这将导致不必要的 RPC 重试。 +此缓存将监视 Keeper 中的哈希值路径。如果在 Keeper 中监视到更新,缓存将尽快更新,以便能够在内存中过滤重复的插入。 ## use_compact_variant_discriminators_serialization {#use_compact_variant_discriminators_serialization} -启用变体数据类型中鉴别符的紧凑模式二进制序列化。此模式允许在存在大多数只有一个变体或许多 NULL 值时,显著减少存储鉴别符所需的内存。 - +启用在 Variant 数据类型中的指示符的紧凑二进制序列化模式。 +此模式允许在大部分为单一变体或大量 NULL 值的情况下,显著减少存储指示符所需的内存。 ## use_const_adaptive_granularity {#use_const_adaptive_granularity} -始终对整个部分使用恒定粒度。它使得可以在内存中压缩索引粒度的值。在面对极大工作负载和稀薄表时可能非常有用。 - +始终对整个部分使用恒定粒度。这使得可以在内存中压缩索引粒度的值。对于极大的工作负载(具有稀少表)可能会有所帮助。 ## use_metadata_cache {#use_metadata_cache} -过期设置,不执行任何操作。 - +过时的设置,不执行任何操作。 ## use_minimalistic_checksums_in_zookeeper {#use_minimalistic_checksums_in_zookeeper} -在 ZooKeeper 中使用小格式(几十字节)的部分检查和普通格式(几十 KB)相比。启用之前请检查所有副本是否支持新格式。 - +在 ZooKeeper 中为部分哈希值使用小格式(数十字节),而不是普通格式(数十 KB)。在启用之前,请检查所有副本是否支持新格式。 ## use_minimalistic_part_header_in_zookeeper {#use_minimalistic_part_header_in_zookeeper} -ZooKeeper 中数据部分头的存储方法。如果启用,ZooKeeper 存储更少的数据。详细信息,请参见[此处](/operations/server-configuration-parameters/settings#use_minimalistic_part_header_in_zookeeper)。 - +ZooKeeper 中的数据部分头部的存储方法。如果启用,ZooKeeper 将存储更少的数据。有关详细信息,请参见 [这里](/operations/server-configuration-parameters/settings#use_minimalistic_part_header_in_zookeeper)。 ## use_primary_key_cache {#use_primary_key_cache} -对于主索引使用缓存,而不是将所有索引保存在内存中。这对于非常大的表可能会很有用。 - +使用主键索引的缓存,而不是将所有索引保存在内存中。这对于非常大的表可能会很有用。 ## vertical_merge_algorithm_min_bytes_to_activate {#vertical_merge_algorithm_min_bytes_to_activate} -激活垂直合并算法所需的最小(近似)未压缩大小(以字节为单位)。 - +合并部分可激活垂直合并算法的最小(近似)未压缩字节大小。 ## vertical_merge_algorithm_min_columns_to_activate {#vertical_merge_algorithm_min_columns_to_activate} -激活垂直合并算法所需的最小非 PK 列数。 - +激活垂直合并算法的最小非主键列数。 ## vertical_merge_algorithm_min_rows_to_activate {#vertical_merge_algorithm_min_rows_to_activate} -激活垂直合并算法所需的最小(近似)合并部分的行数总和。 +合并部分可激活垂直合并算法的最小(近似)行数总和。 +## vertical_merge_optimize_lightweight_delete {#vertical_merge_optimize_lightweight_delete} + + +如果为真,轻量级删除将在垂直合并时进行优化。 ## vertical_merge_remote_filesystem_prefetch {#vertical_merge_remote_filesystem_prefetch} -如果为 true,则在合并过程中使用远程文件系统的预取数据。 - +如果为真,在合并期间会为下一个列从远程文件系统预取数据。 ## wait_for_unique_parts_send_before_shutdown_ms {#wait_for_unique_parts_send_before_shutdown_ms} -在关闭之前,表将等待一段所需时间,以便其他副本获取唯一部分(仅存在于当前副本)(0表示禁用)。 - +在关闭之前,表将等待所需的时间,以便唯一部分(仅存在于当前副本上)被其他副本获取(0表示禁用)。 ## write_ahead_log_bytes_to_fsync {#write_ahead_log_bytes_to_fsync} -过期设置,不执行任何操作。 - +过时的设置,没有任何作用。 ## write_ahead_log_interval_ms_to_fsync {#write_ahead_log_interval_ms_to_fsync} -过期设置,不执行任何操作。 - +过时的设置,没有任何作用。 ## write_ahead_log_max_bytes {#write_ahead_log_max_bytes} -过期设置,不执行任何操作。 - +过时的设置,没有任何作用。 ## write_final_mark {#write_final_mark} -过期设置,不执行任何操作。 - +过时的设置,没有任何作用。 ## write_marks_for_substreams_in_compact_parts {#write_marks_for_substreams_in_compact_parts} - - + + -启用每个子流写入标记,而不是在压缩部分中每列写入标记。它能够有效地从数据部分读取单个子列。 +启用在紧凑部分中为每个子流写入标记,而不是为每列写入标记。这使得能够高效地从数据部分读取各个子列。 +例如,列 `t Tuple(a String, b UInt32, c Array(Nullable(UInt32)))` 在以下子流中序列化: +- `t.a` 用于元组元素 `a` 的字符串数据 +- `t.b` 用于元组元素 `b` 的 UInt32 数据 +- `t.c.size0` 用于元组元素 `c` 的数组大小 +- `t.c.null` 用于元组元素 `c` 的嵌套数组元素的空值映射 +- `t.c` 用于元组元素 `c` 的嵌套数组元素的 UInt32 数据 + +启用此设置时,我们将为这五个子流中的每一个写入一个标记,这意味着我们可以在需要时单独从粒度中读取每个子流的数据。例如,如果我们想读取子列 `t.c`,我们将只读取子流 `t.c.size0`、`t.c.null` 和 `t.c` 的数据,而不会读取子流 `t.a` 和 `t.b` 的数据。当此设置禁用时,我们将只为顶级列 `t` 写入一个标记,这意味着即使我们只需要某些子流的数据,我们也会始终从粒度中读取整个列的数据。 ## zero_copy_concurrent_part_removal_max_postpone_ratio {#zero_copy_concurrent_part_removal_max_postpone_ratio} -为获得更小的独立范围而推迟移除的顶级部分的最大百分比。建议不要更改。 - +最大待推迟移除的顶级部分百分比,以获得更小的独立范围。建议不要更改。 ## zero_copy_concurrent_part_removal_max_split_times {#zero_copy_concurrent_part_removal_max_split_times} -最大递归深度,将独立的过期部分范围拆分为较小的子范围。建议不要更改。 - +将过时部分范围分割为更小子范围的最大递归深度。建议不要更改。 ## zero_copy_merge_mutation_min_parts_size_sleep_before_lock {#zero_copy_merge_mutation_min_parts_size_sleep_before_lock} -如果启用零拷贝复制,则在尝试根据合并或突变的部分大小进行锁定之前,随机休眠一段时间。 - +如果启用了零拷贝复制,合并或突变前将根据部分大小随机延迟一定时间尝试锁定。 ## zero_copy_merge_mutation_min_parts_size_sleep_no_scale_before_lock {#zero_copy_merge_mutation_min_parts_size_sleep_no_scale_before_lock} -如果启用零拷贝复制,则在尝试进行合并或突变的锁定之前,随机休眠最长 500 毫秒。 - +如果启用了零拷贝复制,合并或突变前将随机延迟最多 500 毫秒尝试锁定。 ## zookeeper_session_expiration_check_period {#zookeeper_session_expiration_check_period} diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/merge-tree-settings.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/merge-tree-settings.md.hash index fe530f2234b..b13a348616d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/merge-tree-settings.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/merge-tree-settings.md.hash @@ -1 +1 @@ -ecaec2d5eaf362a1 +548ad465c14d8959 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/overview.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/overview.md index 378adc769c2..8a23fc58a98 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/overview.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/overview.md @@ -1,8 +1,9 @@ --- -'description': '设置的概述页面。' +'description': '设置的概览页面。' 'sidebar_position': 1 'slug': '/operations/settings/overview' -'title': '设置概述' +'title': '设置概览' +'doc_type': 'reference' --- @@ -11,35 +12,33 @@ ## 概述 {#overview} :::note -基于 XML 的设置配置文件和 [配置文件](/operations/configuration-files) 当前不 -支持 ClickHouse Cloud。要为你的 ClickHouse Cloud -服务指定设置,你必须使用 [SQL 驱动的设置配置文件](/operations/access-rights#settings-profiles-management)。 +基于 XML 的设置配置文件和 [配置文件](/operations/configuration-files) 目前不支持 ClickHouse Cloud。要为您的 ClickHouse Cloud 服务指定设置,您必须使用 [SQL 驱动的设置配置文件](/operations/access-rights#settings-profiles-management)。 ::: -ClickHouse 的设置主要分为两个组: +ClickHouse 设置主要分为两大类: - 全局服务器设置 - 会话设置 -两者的主要区别在于,全局服务器设置适用于 ClickHouse 服务器的所有实例,而会话设置则适用于用户会话或甚至单个查询。 +两者的主要区别在于,全球服务器设置适用于整个 ClickHouse 服务器,而会话设置适用于用户会话,甚至单个查询。 ## 查看非默认设置 {#see-non-default-settings} -要查看哪些设置已从默认值更改,你可以查询 `system.settings` 表: +要查看哪些设置已从其默认值更改,您可以查询 `system.settings` 表: ```sql SELECT name, value FROM system.settings WHERE changed ``` -如果没有设置从默认值更改,ClickHouse 将不返回任何内容。 +如果没有设置从其默认值更改,则 ClickHouse 将不会返回任何内容。 -要检查特定设置的值,你可以在查询中指定该设置的 `name`: +要检查特定设置的值,您可以在查询中指定设置的 `name`: ```sql SELECT name, value FROM system.settings WHERE name = 'max_threads' ``` -这将返回类似以下内容: +这将返回类似于以下内容: ```response ┌─name────────┬─value─────┐ @@ -51,7 +50,5 @@ SELECT name, value FROM system.settings WHERE name = 'max_threads' ## 进一步阅读 {#further-reading} -- 请参阅 [全局服务器设置](/operations/server-configuration-parameters/settings.md) 以了解如何在全局服务器级别配置你的 - ClickHouse 服务器。 -- 请参阅 [会话设置](/operations/settings/settings-query-level.md) 以了解如何在会话级别配置你的 ClickHouse - 服务器。 +- 查看 [全局服务器设置](/operations/server-configuration-parameters/settings.md),以了解更多关于在全局服务器级别配置您的 ClickHouse 服务器的信息。 +- 查看 [会话设置](/operations/settings/settings-query-level.md),以了解更多关于在会话级别配置您的 ClickHouse 服务器的信息。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/overview.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/overview.md.hash index f7b7f748ade..8ff62b5c5ee 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/overview.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/overview.md.hash @@ -1 +1 @@ -6513dbda8774564b +f54b017dccc4330c diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/permissions-for-queries.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/permissions-for-queries.md index d3954cb012e..dbc11d7e836 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/permissions-for-queries.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/permissions-for-queries.md @@ -1,72 +1,71 @@ --- 'description': '查询权限的设置。' -'sidebar_label': '查询权限' +'sidebar_label': '查询的权限' 'sidebar_position': 58 'slug': '/operations/settings/permissions-for-queries' -'title': '查询权限' +'title': '查询的权限' +'doc_type': 'reference' --- # 查询权限 -ClickHouse中的查询可以分为几种类型: +在 ClickHouse 中,查询可以分为几种类型: -1. 读数据查询: `SELECT`,`SHOW`,`DESCRIBE`,`EXISTS`。 -2. 写数据查询: `INSERT`,`OPTIMIZE`。 -3. 更改设置查询: `SET`,`USE`。 -4. [DDL](https://en.wikipedia.org/wiki/Data_definition_language) 查询: `CREATE`,`ALTER`,`RENAME`,`ATTACH`,`DETACH`,`DROP`,`TRUNCATE`。 -5. `KILL QUERY`。 +1. 读取数据查询: `SELECT`、`SHOW`、`DESCRIBE`、`EXISTS`。 +2. 写入数据查询: `INSERT`、`OPTIMIZE`。 +3. 更改设置查询: `SET`、`USE`。 +4. [DDL](https://en.wikipedia.org/wiki/Data_definition_language) 查询: `CREATE`、`ALTER`、`RENAME`、`ATTACH`、`DETACH`、`DROP`、`TRUNCATE`。 +5. `KILL QUERY`。 以下设置根据查询类型调节用户权限: ## readonly {#readonly} -限制对读数据、写数据和更改设置查询的权限。 +限制读取数据、写入数据和更改设置查询的权限。 -当设置为1时,允许: +当设置为 1 时,允许: -- 所有类型的读查询(如 SELECT 和等效查询)。 +- 所有类型的读取查询(如 SELECT 及其等效查询)。 - 仅修改会话上下文的查询(如 USE)。 -当设置为2时,允许上述权限外: +当设置为 2 时,允许上述操作加上: - SET 和 CREATE TEMPORARY TABLE :::tip - 像 EXISTS,DESCRIBE,EXPLAIN,SHOW PROCESSLIST 等查询等效于 SELECT,因为它们只是从系统表中选择数据。 + 查询如 EXISTS、DESCRIBE、EXPLAIN、SHOW PROCESSLIST 等等等效于 SELECT,因为它们只是从系统表中选择数据。 ::: 可能的值: -- 0 — 允许读、写和更改设置查询。 -- 1 — 仅允许读数据查询。 -- 2 — 允许读数据和更改设置查询。 +- 0 — 允许读取、写入和更改设置查询。 +- 1 — 仅允许读取数据查询。 +- 2 — 允许读取数据和更改设置查询。 -默认值:0 +默认值: 0 :::note -在设置 `readonly = 1` 后,用户不能在当前会话中更改 `readonly` 和 `allow_ddl` 设置。 +在将 `readonly = 1` 设置后,用户无法在当前会话中更改 `readonly` 和 `allow_ddl` 设置。 -在使用 [HTTP 接口](../../interfaces/http.md) 的 `GET` 方法时,`readonly = 1` 会自动设置。要修改数据,请使用 `POST` 方法。 +在使用 [HTTP 接口](../../interfaces/http.md) 中的 `GET` 方法时,`readonly = 1` 会自动设置。要修改数据,请使用 `POST` 方法。 -设置 `readonly = 1` 禁止用户更改设置。有一种方法可以禁止用户仅更改特定设置。还有一种方法可以在 `readonly = 1` 限制下允许更改特定设置。有关详细信息,请参见 [设置约束](../../operations/settings/constraints-on-settings.md)。 +设置 `readonly = 1` 禁止用户更改设置。有一种方法可以禁止用户仅更改特定设置。还可以在 `readonly = 1` 限制下允许更改特定设置。有关详细信息,请参见 [设置约束](../../operations/settings/constraints-on-settings.md)。 ::: - ## allow_ddl {#allow_ddl} -允许或禁止 [DDL](https://en.wikipedia.org/wiki/Data_definition_language) 查询。 +允许或拒绝 [DDL](https://en.wikipedia.org/wiki/Data_definition_language) 查询。 可能的值: - 0 — 不允许 DDL 查询。 - 1 — 允许 DDL 查询。 -默认值:1 +默认值: 1 :::note -如果当前会话的 `allow_ddl = 0`,则无法运行 `SET allow_ddl = 1`。 +如果当前会话中 `allow_ddl = 0`,则无法运行 `SET allow_ddl = 1`。 ::: - :::note KILL QUERY -`KILL QUERY` 可以与任何组合的 readonly 和 allow_ddl 设置一起执行。 +可以使用任意组合的 readonly 和 allow_ddl 设置执行 `KILL QUERY`。 ::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/permissions-for-queries.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/permissions-for-queries.md.hash index 773b05b095f..e2cc11d078c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/permissions-for-queries.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/permissions-for-queries.md.hash @@ -1 +1 @@ -6ccf321c605a5d73 +78e00c5f1369681a diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/query-complexity.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/query-complexity.md index 248d7f89b28..fc865b3f5c7 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/query-complexity.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/query-complexity.md @@ -1,9 +1,10 @@ --- -'description': '设置限制查询复杂性。' -'sidebar_label': '查询复杂性限制' +'description': '限制查询复杂度的设置。' +'sidebar_label': '查询复杂度的限制' 'sidebar_position': 59 'slug': '/operations/settings/query-complexity' -'title': '查询复杂性限制' +'title': '查询复杂度的限制' +'doc_type': 'reference' --- @@ -11,94 +12,94 @@ ## 概述 {#overview} -作为[设置](/operations/settings/overview)的一部分,ClickHouse 提供了对查询复杂性施加限制的能力。这有助于防止潜在的资源密集型查询,确保更安全和更可预测的执行,特别是在使用用户界面时。 +作为[设置](/operations/settings/overview)的一部分,ClickHouse 提供了对查询复杂性施加限制的功能。这有助于防止潜在的资源密集型查询,确保执行更加安全和可预测,尤其是在使用用户界面时。 -几乎所有限制仅适用于 `SELECT` 查询,并且对于分布式查询处理,限制是在每个服务器上分别应用的。 +几乎所有的限制仅适用于 `SELECT` 查询,对于分布式查询处理,限制是分别在每个服务器上应用的。 -ClickHouse 通常在数据部分完全处理后才检查限制,而不是在检查每一行的限制。这可能导致在处理部分时违反限制的情况发生。 +ClickHouse 通常在数据部分完全处理后才检查限制,而不是对每一行进行限制检查。这可能导致在处理部分时违反限制的情况。 ## `overflow_mode` 设置 {#overflow_mode_setting} -大多数限制也有一个 `overflow_mode` 设置,用于定义超过限制时会发生什么,它可以取两个值中的一个: +大多数限制都有一个 `overflow_mode` 设置,定义了超出限制时的处理方式,并可以取两个值之一: - `throw`:抛出异常(默认)。 -- `break`:停止执行查询并返回部分结果,就好像源数据用完了一样。 +- `break`:停止执行查询并返回部分结果,仿佛源数据已用尽。 ## `group_by_overflow_mode` 设置 {#group_by_overflow_mode_settings} -`group_by_overflow_mode` 设置还有一个值 `any`: -- `any`:继续聚合进入集合的键,但不添加新的键到集合中。 +`group_by_overflow_mode` 设置还具有值 `any`: +- `any`:继续对进入集合的键进行聚合,但不为集合添加新键。 ## 设置列表 {#relevant-settings} -以下设置用于应用查询复杂性的限制。 +以下设置用于施加查询复杂性限制。 :::note -对“某物最大数量”的限制可以取值为 `0`,这意味着“无限制”。 +“最大某物数量”的限制可以取值 `0`,这意味着“无限制”。 ::: -| 设置 | 简短说明 | -|------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------| -| [`max_memory_usage`](/operations/settings/settings#max_memory_usage) | 为在单个服务器上运行查询而使用的最大 RAM 数量。 | -| [`max_memory_usage_for_user`](/operations/settings/settings#max_memory_usage_for_user) | 为在单个服务器上运行用户查询而使用的最大 RAM 数量。 | -| [`max_rows_to_read`](/operations/settings/settings#max_rows_to_read) | 在运行查询时从表中可以读取的最大行数。 | -| [`max_bytes_to_read`](/operations/settings/settings#max_bytes_to_read) | 在运行查询时可以从表中读取的最大字节数(未压缩数据)。 | -| [`read_overflow_mode_leaf`](/operations/settings/settings#read_overflow_mode_leaf) | 设置在读取的数据量超过一个叶片限制时发生的情况 | -| [`max_rows_to_read_leaf`](/operations/settings/settings#max_rows_to_read_leaf) | 在运行分布式查询时可以从叶节点的本地表中读取的最大行数 | -| [`max_bytes_to_read_leaf`](/operations/settings/settings#max_bytes_to_read_leaf) | 在运行分布式查询时可以从叶节点的本地表中读取的最大字节数(未压缩数据)。 | -| [`read_overflow_mode_leaf`](/docs/operations/settings/settings#read_overflow_mode_leaf) | 设置在读取的数据量超过一个叶片限制时发生的情况。 | -| [`max_rows_to_group_by`](/operations/settings/settings#max_rows_to_group_by) | 从聚合中接收到的唯一键的最大数量。 | -| [`group_by_overflow_mode`](/operations/settings/settings#group_by_overflow_mode) | 设置当聚合的唯一键数量超过限制时发生的情况 | -| [`max_bytes_before_external_group_by`](/operations/settings/settings#max_bytes_before_external_group_by) | 启用或禁用在外部内存中执行 `GROUP BY` 子句。 | -| [`max_bytes_ratio_before_external_group_by`](/operations/settings/settings#max_bytes_ratio_before_external_group_by) | 允许用于 `GROUP BY` 的可用内存比例。一旦达到该比例,将使用外部内存进行聚合。 | -| [`max_bytes_before_external_sort`](/operations/settings/settings#max_bytes_before_external_sort) | 启用或禁用在外部内存中执行 `ORDER BY` 子句。 | -| [`max_bytes_ratio_before_external_sort`](/operations/settings/settings#max_bytes_ratio_before_external_sort) | 允许用于 `ORDER BY` 的可用内存比例。一旦达到该比例,将使用外部排序。 | -| [`max_rows_to_sort`](/operations/settings/settings#max_rows_to_sort) | 排序之前的最大行数。允许在排序时限制内存消耗。 | -| [`max_bytes_to_sort`](/operations/settings/settings#max_rows_to_sort) | 排序之前的最大字节数。 | -| [`sort_overflow_mode`](/operations/settings/settings#sort_overflow_mode) | 设置在排序之前接收到的行数超过限制之一时会发生的情况。 | -| [`max_result_rows`](/operations/settings/settings#max_result_rows) | 限制结果中的行数。 | -| [`max_result_bytes`](/operations/settings/settings#max_result_bytes) | 限制结果大小(未压缩)以字节计算。 | -| [`result_overflow_mode`](/operations/settings/settings#result_overflow_mode) | 设置结果量超过限制之一时执行的操作。 | -| [`max_execution_time`](/operations/settings/settings#max_execution_time) | 最大查询执行时间(以秒为单位)。 | -| [`timeout_overflow_mode`](/operations/settings/settings#timeout_overflow_mode) | 设置查询运行超出 `max_execution_time` 或估计运行时间超出 `max_estimated_execution_time` 时的处理方式。 | -| [`max_execution_time_leaf`](/operations/settings/settings#max_execution_time_leaf) | 在语义上类似于 `max_execution_time` ,但仅应用于分布式或远程查询的叶节点。 | -| [`timeout_overflow_mode_leaf`](/operations/settings/settings#timeout_overflow_mode_leaf) | 设置当叶节点中的查询运行超出 `max_execution_time_leaf` 时发生的情况。 | -| [`min_execution_speed`](/operations/settings/settings#min_execution_speed) | 每秒的最小执行速度(以行数为单位)。 | -| [`min_execution_speed_bytes`](/operations/settings/settings#min_execution_speed_bytes) | 每秒最小执行字节数。 | -| [`max_execution_speed`](/operations/settings/settings#max_execution_speed) | 每秒最大执行行数。 | -| [`max_execution_speed_bytes`](/operations/settings/settings#max_execution_speed_bytes) | 每秒最大执行字节数。 | -| [`timeout_before_checking_execution_speed`](/operations/settings/settings#timeout_before_checking_execution_speed) | 在指定的秒数过期后检查执行速度是否过慢(不低于 `min_execution_speed`)。 | -| [`max_estimated_execution_time`](/operations/settings/settings#max_estimated_execution_time) | 最大查询估计执行时间(以秒为单位)。 | -| [`max_columns_to_read`](/operations/settings/settings#max_columns_to_read) | 在单个查询中可以从表中读取的最大列数。 | -| [`max_temporary_columns`](/operations/settings/settings#max_temporary_columns) | 在运行查询时必须同时保留在 RAM 中的最大临时列数,包括常量列。 | -| [`max_temporary_non_const_columns`](/operations/settings/settings#max_temporary_non_const_columns) | 在运行查询时必须同时保留的最大临时列数,但不包括常量列。 | -| [`max_subquery_depth`](/operations/settings/settings#max_subquery_depth) | 设置如果查询的嵌套子查询超过指定数量时会发生的情况。 | -| [`max_ast_depth`](/operations/settings/settings#max_ast_depth) | 查询语法树的最大嵌套深度。 | -| [`max_ast_elements`](/operations/settings/settings#max_ast_elements) | 查询语法树中的最大元素数量。 | -| [`max_rows_in_set`](/operations/settings/settings#max_rows_in_set) | 从子查询创建的 IN 子句数据集中的最大行数。 | -| [`max_bytes_in_set`](/operations/settings/settings#max_bytes_in_set) | 从子查询创建的 IN 子句中使用的集合的最大字节数(未压缩数据)。 | -| [`set_overflow_mode`](/operations/settings/settings#max_bytes_in_set) | 设置当数据量超过限制之一时将发生的情况。 | -| [`max_rows_in_distinct`](/operations/settings/settings#max_rows_in_distinct) | 使用 DISTINCT 时不同的最大行数。 | -| [`max_bytes_in_distinct`](/operations/settings/settings#max_bytes_in_distinct) | 在使用 DISTINCT 时哈希表状态在内存中使用的最大字节数(未压缩字节)。 | -| [`distinct_overflow_mode`](/operations/settings/settings#distinct_overflow_mode) | 设置当数据量超过限制之一时将发生的情况。 | -| [`max_rows_to_transfer`](/operations/settings/settings#max_rows_to_transfer) | 在执行 GLOBAL IN/JOIN 部分时,可以传递到远程服务器或保存到临时表的最大大小(以行数为单位)。 | -| [`max_bytes_to_transfer`](/operations/settings/settings#max_bytes_to_transfer) | 在执行 GLOBAL IN/JOIN 部分时,可以传递到远程服务器或保存到临时表的最大字节数(未压缩数据)。 | -| [`transfer_overflow_mode`](/operations/settings/settings#transfer_overflow_mode) | 设置当数据量超过限制之一时将发生的情况。 | -| [`max_rows_in_join`](/operations/settings/settings#max_rows_in_join) | 限制用于连接表时哈希表中的行数。 | -| [`max_bytes_in_join`](/operations/settings/settings#max_bytes_in_join) | 用于连接表的哈希表的最大字节数。 | -| [`join_overflow_mode`](/operations/settings/settings#join_overflow_mode) | 定义当任何以下连接限制达到时 ClickHouse 执行的操作。 | -| [`max_partitions_per_insert_block`](/operations/settings/settings#max_partitions_per_insert_block) | 限制单个插入块中的最大分区数,如果块包含过多分区,则会抛出异常。 | -| [`throw_on_max_partitions_per_insert_block`](/operations/settings/settings#throw_on_max_partitions_per_insert_block) | 控制达到 `max_partitions_per_insert_block` 时的行为。 | -| [`max_temporary_data_on_disk_size_for_user`](/operations/settings/settings#throw_on_max_partitions_per_insert_block) | 所有同时运行的用户查询的临时文件在磁盘上消耗的最大数据量(以字节为单位)。 | -| [`max_temporary_data_on_disk_size_for_query`](/operations/settings/settings#max_temporary_data_on_disk_size_for_query) | 所有同时运行的查询的临时文件在磁盘上消耗的最大数据量(以字节为单位)。 | -| [`max_sessions_for_user`](/operations/settings/settings#max_sessions_for_user) | 每个经过身份验证的用户最多可以同时与 ClickHouse 服务器进行的会话数量。 | -| [`max_partitions_to_read`](/operations/settings/settings#max_partitions_to_read) | 限制在单个查询中可以访问的最大分区数。 | - -## 废弃设置 {#obsolete-settings} +| 设置 | 简短描述 | +|----------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------| +| [`max_memory_usage`](/operations/settings/settings#max_memory_usage) | 在单个服务器上运行查询时可使用的最大 RAM 数量。 | +| [`max_memory_usage_for_user`](/operations/settings/settings#max_memory_usage_for_user) | 在单个服务器上运行用户查询时可使用的最大 RAM 数量。 | +| [`max_rows_to_read`](/operations/settings/settings#max_rows_to_read) | 运行查询时从表中可以读取的最大行数。 | +| [`max_bytes_to_read`](/operations/settings/settings#max_bytes_to_read) | 运行查询时从表中可以读取的最大字节数(未压缩的数据)。 | +| [`read_overflow_mode_leaf`](/operations/settings/settings#read_overflow_mode_leaf) | 设置读取的数据量超过某个叶子限制时发生的情况。 | +| [`max_rows_to_read_leaf`](/operations/settings/settings#max_rows_to_read_leaf) | 运行分布式查询时,从叶子节点本地表中可以读取的最大行数。 | +| [`max_bytes_to_read_leaf`](/operations/settings/settings#max_bytes_to_read_leaf) | 运行分布式查询时,从叶子节点本地表中可以读取的最大字节数(未压缩的数据)。 | +| [`read_overflow_mode_leaf`](/docs/operations/settings/settings#read_overflow_mode_leaf) | 设置读取的数据量超过某个叶子限制时发生的情况。 | +| [`max_rows_to_group_by`](/operations/settings/settings#max_rows_to_group_by) | 从聚合接收到的唯一键的最大数量。 | +| [`group_by_overflow_mode`](/operations/settings/settings#group_by_overflow_mode) | 设置聚合唯一键的数量超过限制时发生的情况。 | +| [`max_bytes_before_external_group_by`](/operations/settings/settings#max_bytes_before_external_group_by) | 启用或禁用在外部内存中执行 `GROUP BY` 子句。 | +| [`max_bytes_ratio_before_external_group_by`](/operations/settings/settings#max_bytes_ratio_before_external_group_by) | 允许用于 `GROUP BY` 的可用内存比例。一旦达到该比例,将使用外部内存进行聚合。 | +| [`max_bytes_before_external_sort`](/operations/settings/settings#max_bytes_before_external_sort) | 启用或禁用在外部内存中执行 `ORDER BY` 子句。 | +| [`max_bytes_ratio_before_external_sort`](/operations/settings/settings#max_bytes_ratio_before_external_sort) | 允许用于 `ORDER BY` 的可用内存比例。一旦达到该比例,将使用外部排序。 | +| [`max_rows_to_sort`](/operations/settings/settings#max_rows_to_sort) | 排序前的最大行数。允许在排序时限制内存消耗。 | +| [`max_bytes_to_sort`](/operations/settings/settings#max_rows_to_sort) | 排序前的最大字节数。 | +| [`sort_overflow_mode`](/operations/settings/settings#sort_overflow_mode) | 设置在排序前接收到的行数超过限制的情况下发生的情况。 | +| [`max_result_rows`](/operations/settings/settings#max_result_rows) | 限制结果中的行数。 | +| [`max_result_bytes`](/operations/settings/settings#max_result_bytes) | 限制结果大小(未压缩)的字节数。 | +| [`result_overflow_mode`](/operations/settings/settings#result_overflow_mode) | 设置当结果的大小超过限制时该怎么做。 | +| [`max_execution_time`](/operations/settings/settings#max_execution_time) | 查询的最大执行时间(秒)。 | +| [`timeout_overflow_mode`](/operations/settings/settings#timeout_overflow_mode) | 设置当查询运行时间超过 `max_execution_time` 或估计运行时间超过 `max_estimated_execution_time` 时该怎么做。 | +| [`max_execution_time_leaf`](/operations/settings/settings#max_execution_time_leaf) | 语义上类似于 `max_execution_time`,但仅应用于分布式或远程查询的叶子节点。 | +| [`timeout_overflow_mode_leaf`](/operations/settings/settings#timeout_overflow_mode_leaf) | 设置当叶子节点中的查询运行时间超过 `max_execution_time_leaf` 时发生的情况。 | +| [`min_execution_speed`](/operations/settings/settings#min_execution_speed) | 每秒的最小执行速度(行数)。 | +| [`min_execution_speed_bytes`](/operations/settings/settings#min_execution_speed_bytes) | 每秒的最小执行字节数。 | +| [`max_execution_speed`](/operations/settings/settings#max_execution_speed) | 每秒的最大执行行数。 | +| [`max_execution_speed_bytes`](/operations/settings/settings#max_execution_speed_bytes) | 每秒的最大执行字节数。 | +| [`timeout_before_checking_execution_speed`](/operations/settings/settings#timeout_before_checking_execution_speed) | 在指定的时间(秒)过期后,检查执行速度是否不太慢(不低于 `min_execution_speed`)。 | +| [`max_estimated_execution_time`](/operations/settings/settings#max_estimated_execution_time) | 最大查询估计执行时间(秒)。 | +| [`max_columns_to_read`](/operations/settings/settings#max_columns_to_read) | 在单个查询中可以从表中读取的最大列数。 | +| [`max_temporary_columns`](/operations/settings/settings#max_temporary_columns) | 在运行查询时必须同时保存在 RAM 中的最大临时列数,包括常量列。 | +| [`max_temporary_non_const_columns`](/operations/settings/settings#max_temporary_non_const_columns) | 在运行查询时必须同时保存在 RAM 中的最大临时列数,但不计算常量列。 | +| [`max_subquery_depth`](/operations/settings/settings#max_subquery_depth) | 设置如果查询具有超出指定数量的嵌套子查询时发生的情况。 | +| [`max_ast_depth`](/operations/settings/settings#max_ast_depth) | 查询语法树的最大嵌套深度。 | +| [`max_ast_elements`](/operations/settings/settings#max_ast_elements) | 查询语法树中元素的最大数量。 | +| [`max_rows_in_set`](/operations/settings/settings#max_rows_in_set) | 从子查询创建的 IN 子句中数据集的最大行数。 | +| [`max_bytes_in_set`](/operations/settings/settings#max_bytes_in_set) | 从子查询创建的 IN 子句中使用的最大字节数(未压缩的数据)。 | +| [`set_overflow_mode`](/operations/settings/settings#max_bytes_in_set) | 设置当数据量超过限制时发生的情况。 | +| [`max_rows_in_distinct`](/operations/settings/settings#max_rows_in_distinct) | 使用 DISTINCT 时不同的最大行数。 | +| [`max_bytes_in_distinct`](/operations/settings/settings#max_bytes_in_distinct) | 使用 DISTINCT 时哈希表所用状态的最大字节数(未压缩字节)。 | +| [`distinct_overflow_mode`](/operations/settings/settings#distinct_overflow_mode) | 设置当数据量超过限制时发生的情况。 | +| [`max_rows_to_transfer`](/operations/settings/settings#max_rows_to_transfer) | 当执行 GLOBAL IN/JOIN 部分时可以传递给远程服务器或保存到临时表的最大大小(行数)。 | +| [`max_bytes_to_transfer`](/operations/settings/settings#max_bytes_to_transfer) | 当执行 GLOBAL IN/JOIN 部分时可以传递给远程服务器或保存到临时表的最大字节数(未压缩的数据)。 | +| [`transfer_overflow_mode`](/operations/settings/settings#transfer_overflow_mode) | 设置当数据量超过限制时发生的情况。 | +| [`max_rows_in_join`](/operations/settings/settings#max_rows_in_join) | 限制在连接表时用于哈希表的行数。 | +| [`max_bytes_in_join`](/operations/settings/settings#max_bytes_in_join) | 连接表时用于哈希表的最大字节数。 | +| [`join_overflow_mode`](/operations/settings/settings#join_overflow_mode) | 定义当达到以下连接限制时 ClickHouse 执行的操作。 | +| [`max_partitions_per_insert_block`](/operations/settings/settings#max_partitions_per_insert_block) | 限制单个插入块中的最大分区数量,如果块包含过多的分区,则抛出异常。 | +| [`throw_on_max_partitions_per_insert_block`](/operations/settings/settings#throw_on_max_partitions_per_insert_block) | 允许您控制达到 `max_partitions_per_insert_block` 时的行为。 | +| [`max_temporary_data_on_disk_size_for_user`](/operations/settings/settings#throw_on_max_partitions_per_insert_block) | 所有并发运行的用户查询在磁盘上由临时文件消耗的最大数据量(字节)。 | +| [`max_temporary_data_on_disk_size_for_query`](/operations/settings/settings#max_temporary_data_on_disk_size_for_query) | 所有并发运行的查询在磁盘上由临时文件消耗的最大数据量(字节)。 | +| [`max_sessions_for_user`](/operations/settings/settings#max_sessions_for_user) | 每个经过身份验证的用户对 ClickHouse 服务器的最大并发会话数。 | +| [`max_partitions_to_read`](/operations/settings/settings#max_partitions_to_read) | 限制单个查询中可以访问的最大分区数量。 | + +## 弃用的设置 {#obsolete-settings} :::note -以下设置已废弃 +以下设置已弃用 ::: ### max_pipeline_depth {#max-pipeline-depth} -最大管道深度。它对应于每个数据块在查询处理期间经过的转换数量。在单个服务器的限制内计数。如果管道深度更大,则会抛出异常。 +最大管道深度。对应于每个数据块在查询处理过程中经过的转换数量。限制在单个服务器的范围内计数。如果管道深度更大,则会抛出异常。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/query-complexity.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/query-complexity.md.hash index 1e6b916bc20..54eb6bbaabb 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/query-complexity.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/query-complexity.md.hash @@ -1 +1 @@ -129e0382f565aa59 +f00c55b32344ff2e diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/server-overload.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/server-overload.md index 819d7c41699..6b440f7366b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/server-overload.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/server-overload.md @@ -1,8 +1,9 @@ --- -'description': '控制服务器CPU过载时的行为。' +'description': '控制服务器 CPU 过载时的行为。' 'sidebar_label': '服务器过载' 'slug': '/operations/settings/server-overload' 'title': '服务器过载' +'doc_type': 'reference' --- @@ -10,27 +11,32 @@ ## 概述 {#overview} -有时,服务器可能因不同原因而变得过载。为了确定当前的 CPU 过载情况, -ClickHouse 服务器计算 CPU 等待时间(`OSCPUWaitMicroseconds` 指标)与忙碌时间 -(`OSCPUVirtualTimeMicroseconds` 指标)的比率。当服务器超出某个比率过载时, -丢弃某些查询或甚至拒绝连接请求是有意义的,以避免进一步增加负载。 +有时服务器可能因各种原因变得过载。为了确定当前的 CPU 过载情况,ClickHouse 服务器计算 CPU 等待时间(`OSCPUWaitMicroseconds` 指标)与忙碌时间(`OSCPUVirtualTimeMicroseconds` 指标)的比值。当服务器的过载超过某个比率时,舍弃一些查询或者甚至丢弃连接请求是有意义的,以免进一步增加负载。 -有一个服务器设置 `os_cpu_busy_time_threshold`,它控制考虑 CPU -正在进行一些有用工作的最小忙碌时间。如果当前的 `OSCPUVirtualTimeMicroseconds` 指标值低于此值, -则假定 CPU 过载为 0。 +有一个服务器设置 `os_cpu_busy_time_threshold` 控制考虑 CPU 从事某些有用工作的最小忙碌时间。如果当前的 `OSCPUVirtualTimeMicroseconds` 指标值低于此值,则假定 CPU 过载为 0。 ## 拒绝查询 {#rejecting-queries} -拒绝查询的行为由查询级别设置 `min_os_cpu_wait_time_ratio_to_throw` 和 -`max_os_cpu_wait_time_ratio_to_throw` 控制。如果这些设置被设置且 `min_os_cpu_wait_time_ratio_to_throw` 小于 -`max_os_cpu_wait_time_ratio_to_throw`,那么查询将被拒绝,并抛出 `SERVER_OVERLOADED` 错误, -如果过载比率至少为 `min_os_cpu_wait_time_ratio_to_throw`,则会以某种概率发生这种情况。 -该概率由最小和最大比率之间的线性插值确定。例如,如果 `min_os_cpu_wait_time_ratio_to_throw = 2`, -`max_os_cpu_wait_time_ratio_to_throw = 6`,且 `cpu_overload = 4`,则查询将以 `0.5` 的概率被拒绝。 +拒绝查询的行为由查询级别设置 `min_os_cpu_wait_time_ratio_to_throw` 和 `max_os_cpu_wait_time_ratio_to_throw` 控制。如果这些设置被配置且 `min_os_cpu_wait_time_ratio_to_throw` 小于 `max_os_cpu_wait_time_ratio_to_throw`,那么在过载比率至少达到 `min_os_cpu_wait_time_ratio_to_throw` 的情况下查询会被拒绝,并且抛出 `SERVER_OVERLOADED` 错误。拒绝的概率通过最小和最大比率之间的线性插值确定。例如,如果 `min_os_cpu_wait_time_ratio_to_throw = 2`,`max_os_cpu_wait_time_ratio_to_throw = 6`,且 `cpu_overload = 4`,那么查询将以 `0.5` 的概率被拒绝。 -## 拒绝连接 {#dropping-connections} +## 丢弃连接 {#dropping-connections} -拒绝连接由服务器级别设置 `min_os_cpu_wait_time_ratio_to_drop_connection` 和 -`max_os_cpu_wait_time_ratio_to_drop_connection` 控制。这些设置可以在不重启服务器的情况下更改。 -这些设置的理念与拒绝查询的理念相似。唯一的区别在于,如果服务器过载, -连接尝试将从服务器端被拒绝。 +丢弃连接由服务器级别设置 `min_os_cpu_wait_time_ratio_to_drop_connection` 和 `max_os_cpu_wait_time_ratio_to_drop_connection` 控制。这些设置可以在不重启服务器的情况下进行更改。这些设置背后的理念与拒绝查询的类似。唯一的区别在于,如果服务器过载,连接尝试将从服务器端被拒绝。 + +## 资源过载警告 {#resource-overload-warnings} + +当服务器过载时,ClickHouse 还会将 CPU 和内存过载警告记录到 `system.warnings` 表中。您可以通过服务器配置自定义这些阈值。 + +**示例** + +```xml + + + 0.9 + 0.8 + 600 + 0.9 + 0.8 + 600 + +``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/server-overload.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/server-overload.md.hash index f8de378e175..9e7c25c837d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/server-overload.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/server-overload.md.hash @@ -1 +1 @@ -a8dcf1a437fd7e45 +4acd702631b1381d diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/settings-formats.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/settings-formats.md index 2085917a896..46c42351067 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/settings-formats.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/settings-formats.md @@ -4,6 +4,7 @@ 'slug': '/operations/settings/formats' 'toc_max_heading_level': 2 'description': '控制输入和输出格式的设置。' +'doc_type': 'reference' --- import ExperimentalBadge from '@theme/badges/ExperimentalBadge'; @@ -12,40 +13,41 @@ import SettingsInfoBlock from '@theme/SettingsInfoBlock/SettingsInfoBlock'; import VersionHistory from '@theme/VersionHistory/VersionHistory'; -这些设置是从 [源](https://github.com/ClickHouse/ClickHouse/blob/master/src/Core/FormatFactorySettings.h) 自动生成的。 +这些设置是从 [source](https://github.com/ClickHouse/ClickHouse/blob/master/src/Core/FormatFactorySettings.h) 自动生成的。 ## allow_special_bool_values_inside_variant {#allow_special_bool_values_inside_variant} -允许从特殊文本布尔值(如 "on"、"off"、"enable"、"disable" 等)解析布尔值到变体类型中。 +允许从特殊文本布尔值(如“on”、“off”、“enable”、“disable”等)中解析Variant类型内的布尔值。 ## bool_false_representation {#bool_false_representation} -在 TSV/CSV/Vertical/Pretty 格式中表示假布尔值的文本。 +在TSV/CSV/垂直/漂亮格式中表示假布尔值的文本。 ## bool_true_representation {#bool_true_representation} -在 TSV/CSV/Vertical/Pretty 格式中表示真布尔值的文本。 +在TSV/CSV/垂直/漂亮格式中表示真布尔值的文本。 ## column_names_for_schema_inference {#column_names_for_schema_inference} -用于在没有列名的格式中进行模式推导的列名列表。格式为: 'column1,column2,column3,...' +用于在没有列名的格式中进行模式推断的列名列表。格式:'column1,column2,column3,...' ## cross_to_inner_join_rewrite {#cross_to_inner_join_rewrite} -如果在 WHERE 部分有连接表达式,则使用内连接替代逗号/交叉连接。值: 0 - 不重写,1 - 尽可能应用于逗号/交叉,2 - 强制重写所有逗号连接,cross - 如果可能。 +如果在WHERE部分存在连接表达式,则使用内连接而不是逗号/交叉连接。值:0 - 不重写,1 - 如果可能则应用于逗号/交叉,2 - 强制重写所有逗号连接,cross - 如果可能 ## date_time_64_output_format_cut_trailing_zeros_align_to_groups_of_thousands {#date_time_64_output_format_cut_trailing_zeros_align_to_groups_of_thousands} -动态修剪 datetime64 值的尾随零,以调整输出规模到 [0, 3, 6],对应于 '秒'、'毫秒' 和 '微秒'。 +动态修剪datetime64值的尾随零,以将输出规模调整为 [0, 3, 6], +对应"秒"、"毫秒"和"微秒" ## date_time_input_format {#date_time_input_format} -允许选择文本表示的日期和时间的解析器。 +允许选择日期和时间文本表示的解析器。 该设置不适用于 [日期和时间函数](../../sql-reference/functions/date-time-functions.md)。 @@ -53,141 +55,146 @@ import VersionHistory from '@theme/VersionHistory/VersionHistory'; - `'best_effort'` — 启用扩展解析。 - ClickHouse 可以解析基本的 `YYYY-MM-DD HH:MM:SS` 格式和所有 [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) 日期和时间格式。例如,`'2018-06-08T01:02:03.000Z'`。 + ClickHouse可以解析基本的 `YYYY-MM-DD HH:MM:SS` 格式和所有 [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) 日期和时间格式。例如,`'2018-06-08T01:02:03.000Z'`。 + +- `'best_effort_us'` — 类似于 `best_effort` (关于 [parseDateTimeBestEffortUS](../../sql-reference/functions/type-conversion-functions#parsedatetimebesteffortus) 的区别) - `'basic'` — 使用基本解析器。 - ClickHouse 仅能解析基本的 `YYYY-MM-DD HH:MM:SS` 或 `YYYY-MM-DD` 格式。例如,`2019-08-20 10:18:56` 或 `2019-08-20`。 + ClickHouse只能够解析基本的 `YYYY-MM-DD HH:MM:SS` 或 `YYYY-MM-DD` 格式。例如,`2019-08-20 10:18:56` 或 `2019-08-20`。 -Cloud 默认值: `'best_effort'`。 +云的默认值:`'best_effort'`。 另见: -- [DateTime 数据类型。](../../sql-reference/data-types/datetime.md) -- [用于处理日期和时间的函数。](../../sql-reference/functions/date-time-functions.md) +- [日期时间数据类型。](../../sql-reference/data-types/datetime.md) +- [处理日期和时间的函数。](../../sql-reference/functions/date-time-functions.md) ## date_time_output_format {#date_time_output_format} -允许选择不同日期和时间文本表示的输出格式。 +允许选择日期和时间文本表示的不同输出格式。 可能的值: - `simple` - 简单输出格式。 - ClickHouse 输出日期和时间为 `YYYY-MM-DD hh:mm:ss` 格式。例如,`2019-08-20 10:18:56`。计算是根据数据类型的时区(如果存在)或服务器时区进行的。 + ClickHouse输出日期和时间为 `YYYY-MM-DD hh:mm:ss` 格式。例如,`2019-08-20 10:18:56`。计算是根据数据类型的时区(如果存在)或服务器时区进行的。 -- `iso` - ISO 输出格式。 +- `iso` - ISO输出格式。 - ClickHouse 输出日期和时间为 [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) `YYYY-MM-DDThh:mm:ssZ` 格式。例如,`2019-08-20T10:18:56Z`。注意,输出为 UTC(`Z` 意味着 UTC)。 + ClickHouse以 [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) `YYYY-MM-DDThh:mm:ssZ` 格式输出日期和时间。例如,`2019-08-20T10:18:56Z`。请注意,输出为UTC(`Z`表示UTC)。 -- `unix_timestamp` - Unix 时间戳输出格式。 +- `unix_timestamp` - Unix时间戳输出格式。 - ClickHouse 输出日期和时间为 [Unix 时间戳](https://en.wikipedia.org/wiki/Unix_time) 格式。例如 `1566285536`。 + ClickHouse以 [Unix时间戳](https://en.wikipedia.org/wiki/Unix_time) 格式输出日期和时间。例如 `1566285536`。 另见: -- [DateTime 数据类型。](../../sql-reference/data-types/datetime.md) -- [用于处理日期和时间的函数。](../../sql-reference/functions/date-time-functions.md) +- [日期时间数据类型。](../../sql-reference/data-types/datetime.md) +- [处理日期和时间的函数。](../../sql-reference/functions/date-time-functions.md) ## date_time_overflow_behavior {#date_time_overflow_behavior} -定义当 [Date](../../sql-reference/data-types/date.md)、[Date32](../../sql-reference/data-types/date32.md)、[DateTime](../../sql-reference/data-types/datetime.md)、[DateTime64](../../sql-reference/data-types/datetime64.md) 或整数值被转换为 Date、Date32、DateTime 或 DateTime64 但无法在结果类型中表示时的行为。 +定义当 [Date](../../sql-reference/data-types/date.md)、[Date32](../../sql-reference/data-types/date32.md)、[DateTime](../../sql-reference/data-types/datetime.md)、[DateTime64](../../sql-reference/data-types/datetime64.md) 或整数转换为Date、Date32、DateTime或DateTime64但该值无法在结果类型中表示时的行为。 可能的值: -- `ignore` — 悄无声息地忽略溢出。结果未定义。 -- `throw` — 在溢出时抛出异常。 -- `saturate` — 饱和结果。如果该值小于目标类型可以表示的最小值,则结果选择为最小可表示值。如果该值大于目标类型可以表示的最大值,则结果选择为最大可表示值。 +- `ignore` — 安静地忽略溢出。结果未定义。 +- `throw` — 如果溢出则抛出异常。 +- `saturate` — 饱和结果。如果值小于目标类型所能表示的最小值,则结果选择为可表示的最小值。如果值大于目标类型所能表示的最大值,则结果选择为可表示的最大值。 -默认值: `ignore`。 +默认值:`ignore`。 ## dictionary_use_async_executor {#dictionary_use_async_executor} -在多个线程中执行读取字典源的管道。仅支持具有本地 CLICKHOUSE 源的字典。 +在多个线程中执行读取字典源的管道。仅支持具有本地CLICKHOUSE源的字典。 ## errors_output_format {#errors_output_format} -将错误写入文本输出的方法。 +写入错误到文本输出的方法。 ## exact_rows_before_limit {#exact_rows_before_limit} -启用时,ClickHouse 将为 rows_before_limit_at_least 统计提供确切值,但代价是必须完全读取限制之前的数据。 +启用时,ClickHouse将在rows_before_limit_at_least统计数据中提供确切值,但代价是必须完全读取限制前的数据。 ## format_avro_schema_registry_url {#format_avro_schema_registry_url} -对于 AvroConfluent 格式:Confluent Schema 注册表 URL。 +对于AvroConfluent格式:Confluent Schema Registry URL。 ## format_binary_max_array_size {#format_binary_max_array_size} -RowBinary 格式中允许的最大数组大小。防止在数据损坏的情况下分配大量内存。0 意味着没有限制。 +RowBinary格式中Array的最大允许大小。防止在数据损坏的情况下分配大量内存。0表示没有限制。 ## format_binary_max_string_size {#format_binary_max_string_size} -RowBinary 格式中允许的最大字符串大小。防止在数据损坏的情况下分配大量内存。0 意味着没有限制。 +RowBinary格式中String的最大允许大小。防止在数据损坏的情况下分配大量内存。0表示没有限制。 ## format_capn_proto_enum_comparising_mode {#format_capn_proto_enum_comparising_mode} -将 ClickHouse Enum 和 CapnProto Enum 映射的方式。 + + +如何映射ClickHouse ENUM和CapnProto ENUM。 ## format_capn_proto_use_autogenerated_schema {#format_capn_proto_use_autogenerated_schema} -当 format_schema 未设置时,使用自动生成的 CapnProto 模式。 +在未设置format_schema时使用自动生成的CapnProto模式。 ## format_csv_allow_double_quotes {#format_csv_allow_double_quotes} - - -如果设置为 true,允许双引号中的字符串。 +如果设置为true,允许使用双引号的字符串。 ## format_csv_allow_single_quotes {#format_csv_allow_single_quotes} - - -如果设置为 true,允许单引号中的字符串。 +如果设置为true,允许使用单引号的字符串。 ## format_csv_delimiter {#format_csv_delimiter} - - -在 CSV 数据中被视为分隔符的字符。如果设置为字符串,则该字符串的长度必须为 1。 +被视为CSV数据中分隔符的字符。如果设置为字符串,则字符串的长度必须为1。 ## format_csv_null_representation {#format_csv_null_representation} -CSV 格式中的自定义 NULL 表示。 +CSV格式中自定义NULL表示。 ## format_custom_escaping_rule {#format_custom_escaping_rule} -字段转义规则(用于 CustomSeparated 格式)。 +字段转义规则(用于CustomSeparated格式)。 ## format_custom_field_delimiter {#format_custom_field_delimiter} -字段之间的分隔符(用于 CustomSeparated 格式)。 +字段之间的分隔符(用于CustomSeparated格式)。 ## format_custom_result_after_delimiter {#format_custom_result_after_delimiter} -结果集后的后缀(用于 CustomSeparated 格式)。 +结果集之后的后缀(用于CustomSeparated格式)。 ## format_custom_result_before_delimiter {#format_custom_result_before_delimiter} -结果集之前的前缀(用于 CustomSeparated 格式)。 +结果集之前的前缀(用于CustomSeparated格式)。 ## format_custom_row_after_delimiter {#format_custom_row_after_delimiter} -最后一列字段后的分隔符(用于 CustomSeparated 格式)。 +最后一列字段后的分隔符(用于CustomSeparated格式)。 ## format_custom_row_before_delimiter {#format_custom_row_before_delimiter} -第一列字段之前的分隔符(用于 CustomSeparated 格式)。 + + +第一列字段前的分隔符(用于CustomSeparated格式)。 ## format_custom_row_between_delimiter {#format_custom_row_between_delimiter} -行之间的分隔符(用于 CustomSeparated 格式)。 + + +行之间的分隔符(用于CustomSeparated格式)。 ## format_display_secrets_in_show_and_select {#format_display_secrets_in_show_and_select} -启用或禁用在表、数据库、表函数和字典的 `SHOW` 和 `SELECT` 查询中显示机密信息。 +启用或禁用在表、数据库、表函数和字典的 `SHOW` 和 `SELECT` 查询中显示机密。 -希望查看机密信息的用户还必须拥有 -[`display_secrets_in_show_and_select` 服务器设置](../server-configuration-parameters/settings#display_secrets_in_show_and_select) 打开并具有 +希望查看机密的用户还必须具有 +[`display_secrets_in_show_and_select` 服务器设置](../server-configuration-parameters/settings#display_secrets_in_show_and_select) +已打开,并且具有 [`displaySecretsInShowAndSelect`](/sql-reference/statements/grant#displaysecretsinshowandselect) 权限。 可能的值: @@ -196,198 +203,225 @@ CSV 格式中的自定义 NULL 表示。 - 1 — 启用。 ## format_json_object_each_row_column_for_object_name {#format_json_object_each_row_column_for_object_name} -该列用于存储/写入 [JSONObjectEachRow](/interfaces/formats/JSONObjectEachRow) 格式中的对象名称。列类型应为字符串。如果值为空,则将使用默认名称 `row_{i}` 作为对象名称。 +将用于存储/写入 [JSONObjectEachRow](/interfaces/formats/JSONObjectEachRow) 格式中对象名称的列名。 +列类型应该是String。如果值为空,将使用默认名称 `row_{i}` 作为对象名称。 ## format_protobuf_use_autogenerated_schema {#format_protobuf_use_autogenerated_schema} -当 format_schema 未设置时,使用自动生成的 Protobuf。 +在未设置format_schema时使用自动生成的Protobuf。 ## format_regexp {#format_regexp} -正则表达式(用于 Regexp 格式)。 + + +正则表达式(用于Regexp格式)。 ## format_regexp_escaping_rule {#format_regexp_escaping_rule} -字段转义规则(用于 Regexp 格式)。 +字段转义规则(用于Regexp格式)。 ## format_regexp_skip_unmatched {#format_regexp_skip_unmatched} -跳过未被正则表达式匹配的行(用于 Regexp 格式)。 +跳过正则表达式未匹配的行(用于Regexp格式)。 ## format_schema {#format_schema} -当您使用需要模式定义的格式时,此参数很有用,例如 [Cap'n Proto](https://capnproto.org/) 或 [Protobuf](https://developers.google.com/protocol-buffers/)。值根据格式而定。 +此参数在使用需要模式定义的格式时非常有用,例如 [Cap'n Proto](https://capnproto.org/) 或 [Protobuf](https://developers.google.com/protocol-buffers/)。值依赖于格式。 +## format_schema_message_name {#format_schema_message_name} + +定义在 `format_schema` 中所需消息的名称。 +为了与遗留 `format_schema` 格式(`file_name:message_name`)保持兼容: +- 如果未指定 `format_schema_message_name`,则消息名称从遗留 `format_schema` 值的 `message_name` 部分推断。 +- 如果在使用遗留格式时指定了 `format_schema_message_name`,则会引发错误。 +## format_schema_source {#format_schema_source} + + + +定义 `format_schema` 的来源。 +可能的值: +- 'file' (默认):`format_schema` 是位于 `format_schemas` 目录中的模式文件的名称。 +- 'string':`format_schema` 是模式的文字内容。 +- 'query':`format_schema` 是用于检索模式的查询。 +当将 `format_schema_source` 设置为 'query' 时,适用以下条件: +- 查询必须返回确切一个值:一行带有单个字符串列。 +- 查询的结果被视为模式内容。 +- 此结果在 `format_schemas` 目录中本地缓存。 +- 可以使用命令清除本地缓存:`SYSTEM DROP FORMAT SCHEMA CACHE FOR Files`。 +- 一旦缓存,相同的查询不会再次执行以获取模式,直到明确清除缓存。 +- 除本地缓存文件外,Protobuf消息也在内存中缓存。即使清除本地缓存文件,也必须使用 `SYSTEM DROP FORMAT SCHEMA CACHE [FOR Protobuf]` 来完全刷新模式。 +- 运行查询 `SYSTEM DROP FORMAT SCHEMA CACHE` 可以一次性清除缓存文件和Protobuf消息模式的缓存。 ## format_template_resultset {#format_template_resultset} -用于存储结果集格式字符串的文件路径(用于 Template 格式)。 +用于包含结果集格式字符串的文件的路径(用于模板格式)。 ## format_template_resultset_format {#format_template_resultset_format} -用于结果集的格式字符串(用于 Template 格式)。 +结果集的格式字符串(用于模板格式)。 ## format_template_row {#format_template_row} -存储行格式字符串的文件路径(用于 Template 格式)。 +用于包含行格式字符串的文件的路径(用于模板格式)。 ## format_template_row_format {#format_template_row_format} -行的格式字符串(用于 Template 格式)。 +行的格式字符串(用于模板格式)。 ## format_template_rows_between_delimiter {#format_template_rows_between_delimiter} -行之间的分隔符(用于 Template 格式)。 +行之间的分隔符(用于模板格式)。 ## format_tsv_null_representation {#format_tsv_null_representation} - - -TSV 格式中的自定义 NULL 表示。 +TSV格式中的自定义NULL表示。 ## input_format_allow_errors_num {#input_format_allow_errors_num} -设置读取文本格式(CSV、TSV 等)时可接受的最大错误数。 +设置从文本格式(CSV、TSV等)读取时允许的最大错误数量。 -默认值为 0。 +默认值为0。 -始终与 `input_format_allow_errors_ratio` 配对使用。 +始终与 `input_format_allow_errors_ratio` 一起使用。 -如果在读取行时发生错误,但错误计数器仍然小于 `input_format_allow_errors_num`,ClickHouse 会忽略该行并继续处理下一行。 +如果在读取行时发生错误,但错误计数器仍小于 `input_format_allow_errors_num`,ClickHouse将忽略该行并继续下一个。 -如果同时超过 `input_format_allow_errors_num` 和 `input_format_allow_errors_ratio`,ClickHouse 将抛出异常。 +如果同时超过 `input_format_allow_errors_num` 和 `input_format_allow_errors_ratio`,ClickHouse将抛出异常。 ## input_format_allow_errors_ratio {#input_format_allow_errors_ratio} -设置读取文本格式(CSV、TSV 等)时允许的最大错误百分比。 -错误的百分比被设定为介于 0 和 1 的浮点数。 +设置在从文本格式(CSV、TSV等)读取时允许的最大错误百分比。 +错误的百分比被设置为0到1之间的浮点数。 -默认值为 0。 +默认值为0。 -始终与 `input_format_allow_errors_num` 配对使用。 +始终与 `input_format_allow_errors_num` 一起使用。 -如果在读取行时发生错误,但错误计数器仍然小于 `input_format_allow_errors_ratio`,ClickHouse 会忽略该行并继续处理下一行。 +如果在读取行时发生错误,但错误计数器仍小于 `input_format_allow_errors_ratio`,ClickHouse将忽略该行并继续下一个。 -如果同时超过 `input_format_allow_errors_num` 和 `input_format_allow_errors_ratio`,ClickHouse 将抛出异常。 +如果同时超过 `input_format_allow_errors_num` 和 `input_format_allow_errors_ratio`,ClickHouse将抛出异常。 ## input_format_allow_seeks {#input_format_allow_seeks} -在读取 ORC/Parquet/Arrow 输入格式时允许跳跃。 +允许在读取ORC/Parquet/Arrow输入格式时进行查找。 -默认启用。 +默认情况下启用。 ## input_format_arrow_allow_missing_columns {#input_format_arrow_allow_missing_columns} -在读取 Arrow 输入格式时允许缺失列。 +在读取Arrow输入格式时允许缺少列。 ## input_format_arrow_case_insensitive_column_matching {#input_format_arrow_case_insensitive_column_matching} -在匹配 Arrow 列与 CH 列时忽略大小写。 +忽略大小写,匹配箭头列与CH列。 ## input_format_arrow_skip_columns_with_unsupported_types_in_schema_inference {#input_format_arrow_skip_columns_with_unsupported_types_in_schema_inference} -在格式 Arrow 的模式推导过程中跳过不支持的类型的列。 +在Arrow格式的模式推断中跳过具有不支持类型的列。 ## input_format_avro_allow_missing_fields {#input_format_avro_allow_missing_fields} -对于 Avro/AvroConfluent 格式:当在模式中找不到字段时,使用默认值而不是抛出错误。 + + +对于Avro/AvroConfluent格式:当在模式中找不到字段时,使用默认值而不是错误。 ## input_format_avro_null_as_default {#input_format_avro_null_as_default} -对于 Avro/AvroConfluent 格式:在 null 和非 Nullable 列的情况下插入默认值。 + + +对于Avro/AvroConfluent格式:在null和非Nullable列的情况下插入默认值。 ## input_format_binary_decode_types_in_binary_format {#input_format_binary_decode_types_in_binary_format} -在 RowBinaryWithNamesAndTypes 输入格式中以二进制格式读取数据类型,而不是类型名称。 +在RowBinaryWithNamesAndTypes输入格式中读取数据类型,而不是读取类型名称。 ## input_format_binary_read_json_as_string {#input_format_binary_read_json_as_string} -在 RowBinary 输入格式中将 [JSON](../../sql-reference/data-types/newjson.md) 数据类型的值读取为 JSON [String](../../sql-reference/data-types/string.md) 值。 + + +在RowBinary输入格式中,将 [JSON](../../sql-reference/data-types/newjson.md) 数据类型的值作为JSON [String](../../sql-reference/data-types/string.md) 值读取。 ## input_format_bson_skip_fields_with_unsupported_types_in_schema_inference {#input_format_bson_skip_fields_with_unsupported_types_in_schema_inference} -在格式 BSON 的模式推导过程中跳过不支持的类型的字段。 +在BSON格式的模式推断中跳过具有不支持类型的字段。 ## input_format_capn_proto_skip_fields_with_unsupported_types_in_schema_inference {#input_format_capn_proto_skip_fields_with_unsupported_types_in_schema_inference} -在格式 CapnProto 的模式推导过程中跳过不支持的类型的列。 +在CapnProto格式的模式推断中跳过具有不支持类型的列。 ## input_format_csv_allow_cr_end_of_line {#input_format_csv_allow_cr_end_of_line} -如果设置为 true,则 \\r 将被允许在行末不跟随。 + + +如果设置为true,则 \\r 将被允许出现在行末,且后面不跟随 ## input_format_csv_allow_variable_number_of_columns {#input_format_csv_allow_variable_number_of_columns} -在 CSV 输入中忽略额外的列(如果文件中有比预期更多的列),并将 CSV 输入中缺失的字段视为默认值。 +在CSV输入中忽略额外列(如果文件中列数多于预期),并将缺失字段视为默认值。 ## input_format_csv_allow_whitespace_or_tab_as_delimiter {#input_format_csv_allow_whitespace_or_tab_as_delimiter} - - -允许在 CSV 字符串中使用空格和制表符(\\t)作为字段分隔符。 +允许在CSV字符串中使用空格和制表符(\\t)作为字段分隔符。 ## input_format_csv_arrays_as_nested_csv {#input_format_csv_arrays_as_nested_csv} -在从 CSV 读取 Array 时,期望其元素已在嵌套 CSV 中序列化,然后放入字符串中。例如:\"[\"\"Hello\"\", \"\"world\"\", \"\"42\"\"\"\" TV\"\"]\"。可以省略数组周围的括号。 +读取Array时,期望其元素在嵌套CSV中被序列化,然后放入字符串中。例如:“[\"Hello\", \"world\", \"42\"]”。数组周围的括号可以省略。 ## input_format_csv_deserialize_separate_columns_into_tuple {#input_format_csv_deserialize_separate_columns_into_tuple} - - -如果设置为 true,则可以将以 CSV 格式书写的独立列反序列化为元组列。 +如果设置为true,则CSV格式的分隔列可以反序列化为Tuple列。 ## input_format_csv_detect_header {#input_format_csv_detect_header} -自动检测 CSV 格式中名称和类型的头。 +自动检测CSV格式中的带名称和类型的标题。 ## input_format_csv_empty_as_default {#input_format_csv_empty_as_default} -将 CSV 输入中的空字段视为默认值。 +将CSV输入中的空字段视为默认值。 ## input_format_csv_enum_as_number {#input_format_csv_enum_as_number} -在 CSV 格式中将插入的枚举值视为枚举索引。 +在CSV格式中将插入的枚举值视为枚举索引。 ## input_format_csv_skip_first_lines {#input_format_csv_skip_first_lines} -跳过 CSV 格式数据开头指定数量的行。 +跳过CSV格式数据开头指定的行数。 ## input_format_csv_skip_trailing_empty_lines {#input_format_csv_skip_trailing_empty_lines} -跳过 CSV 格式中的尾部空行。 +跳过CSV格式中的尾随空行。 ## input_format_csv_trim_whitespaces {#input_format_csv_trim_whitespaces} -修剪 CSV 字符串开头和结尾的空格和制表符(\\t)字符。 +修剪CSV字符串开头和结尾的空格和制表符(\\t)字符。 ## input_format_csv_try_infer_numbers_from_strings {#input_format_csv_try_infer_numbers_from_strings} -如果启用,在模式推导期间,ClickHouse 将尝试从字符串字段推断数字。如果 CSV 数据包含带引号的 UInt64 数字,这可能很有用。 +如果启用,在模式推断期间ClickHouse将尝试从字符串字段推断数字。 +如果CSV数据包含带引号的UInt64数字,这可能很有用。 -默认禁用。 +默认情况下禁用。 ## input_format_csv_try_infer_strings_from_quoted_tuples {#input_format_csv_try_infer_strings_from_quoted_tuples} -将输入数据中带引号的元组视为字符串类型的值。 +在输入数据中将引号元组解释为String类型的值。 ## input_format_csv_use_best_effort_in_schema_inference {#input_format_csv_use_best_effort_in_schema_inference} -在 CSV 格式的模式推导中使用一些技巧和启发式。 +在CSV格式中使用一些调整和启发式方法来推断模式。 ## input_format_csv_use_default_on_bad_values {#input_format_csv_use_default_on_bad_values} -允许在 CSV 字段反序列化失败时将默认值设置到列中。 +在CSV字段反序列化失败的情况下允许将默认值设置为列。 ## input_format_custom_allow_variable_number_of_columns {#input_format_custom_allow_variable_number_of_columns} -忽略 CustomSeparated 输入中的额外列(如果文件中有比预期更多的列),并将 CustomSeparated 输入中缺失的字段视为默认值。 +在CustomSeparated输入中忽略额外列(如果文件中列数多于预期),并将缺失字段视为默认值。 ## input_format_custom_detect_header {#input_format_custom_detect_header} -自动检测 CustomSeparated 格式中名称和类型的头。 +自动检测CustomSeparated格式中的带名称和类型的标题。 ## input_format_custom_skip_trailing_empty_lines {#input_format_custom_skip_trailing_empty_lines} - - -跳过 CustomSeparated 格式中的尾部空行。 +在CustomSeparated格式跳过尾随空行。 ## input_format_defaults_for_omitted_fields {#input_format_defaults_for_omitted_fields} -在执行 `INSERT` 查询时,用相应列的默认值替换省略的输入列值。此选项适用于 [JSONEachRow](/interfaces/formats/JSONEachRow)(和其他 JSON 格式)、[CSV](/interfaces/formats/CSV)、[TabSeparated](/interfaces/formats/TabSeparated)、[TSKV](/interfaces/formats/TSKV)、[Parquet](/interfaces/formats/Parquet)、[Arrow](/interfaces/formats/Arrow)、[Avro](/interfaces/formats/Avro)、[ORC](/interfaces/formats/ORC) 和具有 `WithNames`/`WithNamesAndTypes` 后缀的格式。 +在执行 `INSERT` 查询时,将省略输入列值替换为相应列的默认值。此选项适用于 [JSONEachRow](/interfaces/formats/JSONEachRow)(和其他JSON格式)、[CSV](/interfaces/formats/CSV)、[TabSeparated](/interfaces/formats/TabSeparated)、[TSKV](/interfaces/formats/TSKV)、[Parquet](/interfaces/formats/Parquet)、[Arrow](/interfaces/formats/Arrow)、[Avro](/interfaces/formats/Avro)、[ORC](/interfaces/formats/ORC)、[Native](/interfaces/formats/Native) 格式和带有 `WithNames`/`WithNamesAndTypes` 后缀的格式。 :::note -启用此选项后,扩展表元数据将从服务器发送到客户端。这会消耗额外的服务器计算资源并可能降低性能。 +启用此选项时,扩展表元数据将从服务器发送到客户端。这会消耗额外的服务器计算资源,并可能降低性能。 ::: 可能的值: @@ -396,24 +430,24 @@ TSV 格式中的自定义 NULL 表示。 - 1 — 启用。 ## input_format_force_null_for_omitted_fields {#input_format_force_null_for_omitted_fields} -强制使用 null 值初始化省略的字段。 +强制使用null值初始化省略的字段。 ## input_format_hive_text_allow_variable_number_of_columns {#input_format_hive_text_allow_variable_number_of_columns} -在 Hive Text 输入中忽略额外的列(如果文件中有比预期更多的列),并将 Hive Text 输入中缺失的字段视为默认值。 +在Hive文本输入中忽略额外列(如果文件中列数多于预期),并将缺失字段视为默认值。 ## input_format_hive_text_collection_items_delimiter {#input_format_hive_text_collection_items_delimiter} -Hive 文本文件中集合(数组或映射)项目之间的分隔符。 +Hive文本文件中集合(数组或映射)项之间的分隔符。 ## input_format_hive_text_fields_delimiter {#input_format_hive_text_fields_delimiter} -Hive 文本文件中字段之间的分隔符。 +Hive文本文件中字段之间的分隔符。 ## input_format_hive_text_map_keys_delimiter {#input_format_hive_text_map_keys_delimiter} -Hive 文本文件中映射键/值对之间的分隔符。 +Hive文本文件中键/值对之间的分隔符。 ## input_format_import_nested_json {#input_format_import_nested_json} -启用或禁用插入包含嵌套对象的 JSON 数据。 +启用或禁用插入带有嵌套对象的JSON数据。 支持的格式: @@ -426,30 +460,32 @@ Hive 文本文件中映射键/值对之间的分隔符。 另见: -- [嵌套结构的使用](/integrations/data-formats/json/other-formats#accessing-nested-json-objects) 与 `JSONEachRow` 格式。 +- [使用嵌套结构](/integrations/data-formats/json/other-formats#accessing-nested-json-objects) 使用`JSONEachRow`格式。 ## input_format_ipv4_default_on_conversion_error {#input_format_ipv4_default_on_conversion_error} -在 IPv4 反序列化过程中,在转换错误时将使用默认值而不是抛出异常。 +IPv4的反序列化将在转换错误时使用默认值,而不是抛出异常。 -默认禁用。 +默认情况下禁用。 ## input_format_ipv6_default_on_conversion_error {#input_format_ipv6_default_on_conversion_error} -在 IPv6 反序列化过程中,在转换错误时将使用默认值而不是抛出异常。 +IPV6的反序列化将在转换错误时使用默认值,而不是抛出异常。 -默认禁用。 +默认情况下禁用。 ## input_format_json_compact_allow_variable_number_of_columns {#input_format_json_compact_allow_variable_number_of_columns} -在 JSONCompact/JSONCompactEachRow 输入格式中允许行中有可变数量的列。忽略比预期更多列的额外列,并将缺失的列视为默认值。 +允许在JSONCompact/JSONCompactEachRow输入格式的行中使用可变数量的列。 +在列数多于预期的行中忽略额外列,并将缺失列视为默认值。 -默认禁用。 +默认情况下禁用。 ## input_format_json_defaults_for_missing_elements_in_named_tuple {#input_format_json_defaults_for_missing_elements_in_named_tuple} -在分析命名元组时,为 JSON 对象中缺失的元素插入默认值。此设置仅在启用 `input_format_json_named_tuples_as_objects` 时有效。 +在解析命名元组时,为JSON对象中缺失的元素插入默认值。 +此设置仅在启用 `input_format_json_named_tuples_as_objects` 时有效。 -默认启用。 +默认情况下启用。 ## input_format_json_empty_as_default {#input_format_json_empty_as_default} -启用时,将 JSON 中的空输入字段替换为默认值。对于复杂的默认表达式,`input_format_defaults_for_omitted_fields` 也必须启用。 +启用时,将JSON中空输入字段替换为默认值。对于复杂的默认表达式,`input_format_defaults_for_omitted_fields` 也必须启用。 可能的值: @@ -457,15 +493,45 @@ Hive 文本文件中映射键/值对之间的分隔符。 + 1 — 启用。 ## input_format_json_ignore_unknown_keys_in_named_tuple {#input_format_json_ignore_unknown_keys_in_named_tuple} -忽略命名元组的 JSON 对象中的未知键。 +忽略命名元组的JSON对象中未知键。 -默认启用。 +默认情况下启用。 ## input_format_json_ignore_unnecessary_fields {#input_format_json_ignore_unnecessary_fields} -忽略不必要的字段并不解析它们。启用此选项不会对无效格式或重复字段的 JSON 字符串抛出异常。 +忽略不必要的字段而不进行解析。启用此设置可能不会对格式无效或有重复字段的json字符串引发异常。 +## input_format_json_infer_array_of_dynamic_from_array_of_different_types {#input_format_json_infer_array_of_dynamic_from_array_of_different_types} + +如果启用,在模式推断期间ClickHouse将使用Array(Dynamic)类型处理值具有不同数据类型的JSON数组。 + +示例: + +```sql +SET input_format_json_infer_array_of_dynamic_from_array_of_different_types=1; +DESC format(JSONEachRow, '{"a" : [42, "hello", [1, 2, 3]]}'); +``` + +```response +┌─name─┬─type───────────┐ +│ a │ Array(Dynamic) │ +└──────┴────────────────┘ +``` + +```sql +SET input_format_json_infer_array_of_dynamic_from_array_of_different_types=0; +DESC format(JSONEachRow, '{"a" : [42, "hello", [1, 2, 3]]}'); +``` + +```response +┌─name─┬─type─────────────────────────────────────────────────────────────┐ +│ a │ Tuple(Nullable(Int64), Nullable(String), Array(Nullable(Int64))) │ +└──────┴──────────────────────────────────────────────────────────────────┘ +``` + +默认情况下启用。 ## input_format_json_infer_incomplete_types_as_strings {#input_format_json_infer_incomplete_types_as_strings} -允许在模式推导期间将 JSON 键仅包含 `Null`/`{}`/`[]` 时使用字符串类型。 在 JSON 格式中,任何值都可以作为字符串读取,我们可以避免在模式推导期间造成的错误,例如 `无法通过前 25000 行数据确定列 'column_name' 的类型,很可能该列仅包含 Null 或空数组/映射`。 +允许在模式推断期间对于JSON数据样本中仅包含 `Null`/`{}`/`[]` 的键使用String类型。 +在JSON格式中,任何值都可以作为String读取,我们可以避免在模式推断期间出现类似“无法通过前25000行数据确定字段'column_name'的类型,很可能该字段仅包含Null或空数组/映射”的错误。 示例: @@ -486,18 +552,23 @@ SELECT * FROM format(JSONEachRow, '{"obj" : {"a" : [1,2,3], "b" : "hello", "c" : └────────────────────────────────┘ ``` -默认启用。 +默认情况下启用。 +## input_format_json_map_as_array_of_tuples {#input_format_json_map_as_array_of_tuples} + +将map列反序列化为JSON元组的数组。 + +默认情况下禁用。 ## input_format_json_max_depth {#input_format_json_max_depth} -JSON 字段的最大深度。这不是一个严格的限制,不必精确应用。 +JSON中字段的最大深度。这不是严格限制,并不一定要精确应用。 ## input_format_json_named_tuples_as_objects {#input_format_json_named_tuples_as_objects} -将命名元组列解析为 JSON 对象。 +将命名元组列解析为JSON对象。 -默认启用。 +默认情况下启用。 ## input_format_json_read_arrays_as_strings {#input_format_json_read_arrays_as_strings} -允许在 JSON 输入格式中将 JSON 数组解析为字符串。 +允许在JSON输入格式中将JSON数组解析为字符串。 示例: @@ -513,25 +584,25 @@ SELECT arr, toTypeName(arr), JSONExtractArrayRaw(arr)[3] from format(JSONEachRow └───────────────────────┴─────────────────┴───────────────────────────────────────────┘ ``` -默认启用。 +默认情况下启用。 ## input_format_json_read_bools_as_numbers {#input_format_json_read_bools_as_numbers} -允许在 JSON 输入格式中将布尔值解析为数字。 +允许在JSON输入格式中将布尔值解析为数字。 -默认启用。 +默认情况下启用。 ## input_format_json_read_bools_as_strings {#input_format_json_read_bools_as_strings} -允许在 JSON 输入格式中将布尔值解析为字符串。 +允许在JSON输入格式中将布尔值解析为字符串。 -默认启用。 +默认情况下启用。 ## input_format_json_read_numbers_as_strings {#input_format_json_read_numbers_as_strings} -允许在 JSON 输入格式中将数字解析为字符串。 +允许在JSON输入格式中将数字解析为字符串。 -默认启用。 +默认情况下启用。 ## input_format_json_read_objects_as_strings {#input_format_json_read_objects_as_strings} -允许在 JSON 输入格式中将 JSON 对象解析为字符串。 +允许在JSON输入格式中将JSON对象解析为字符串。 示例: @@ -550,15 +621,16 @@ SELECT * FROM test; └────┴──────────────────────────┴────────────┘ ``` -默认启用。 +默认情况下启用。 ## input_format_json_throw_on_bad_escape_sequence {#input_format_json_throw_on_bad_escape_sequence} -如果 JSON 字符串中包含不良转义序列,则抛出异常。如果禁用,不良转义序列将原样保留在数据中。 +如果JSON字符串包含不良转义序列,则抛出异常。如果禁用,不良转义序列将原样保留在数据中。 -默认启用。 +默认情况下启用。 ## input_format_json_try_infer_named_tuples_from_objects {#input_format_json_try_infer_named_tuples_from_objects} -如果启用,在模式推导期间 ClickHouse 将尝试从 JSON 对象中推导命名元组。结果命名元组将包含来自样本数据的所有对应 JSON 对象中的所有元素。 +如果启用,在模式推断期间ClickHouse将尝试从JSON对象推断命名元组。 +生成的命名元组将包含来自样本数据中所有对应JSON对象的所有元素。 示例: @@ -575,50 +647,53 @@ DESC format(JSONEachRow, '{"obj" : {"a" : 42, "b" : "Hello"}}, {"obj" : {"a" : 4 └──────┴────────────────────────────────────────────────────────────────────────────────────────────────────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┘ ``` -默认启用。 +默认情况下启用。 ## input_format_json_try_infer_numbers_from_strings {#input_format_json_try_infer_numbers_from_strings} -如果启用,在模式推导期间,ClickHouse 将尝试从字符串字段推断数字。 如果 JSON 数据包含带引号的 UInt64 数字,这可能很有用。 +如果启用,在模式推断期间ClickHouse将尝试从字符串字段推断数字。 +如果JSON数据包含带引号的UInt64数字,这可能很有用。 -默认禁用。 +默认情况下禁用。 ## input_format_json_use_string_type_for_ambiguous_paths_in_named_tuples_inference_from_objects {#input_format_json_use_string_type_for_ambiguous_paths_in_named_tuples_inference_from_objects} -在命名元组推导过程中,如果 JSON 对象中的路径不明确则使用字符串类型代替异常。 +在命名元组推断中的JSON对象的模糊路径情况下,使用String类型而不是抛出异常。 ## input_format_json_validate_types_from_metadata {#input_format_json_validate_types_from_metadata} -对于 JSON/JSONCompact/JSONColumnsWithMetadata 输入格式,如果此设置设置为 1,则输入数据中的元数据类型将与表中对应列的类型进行比较。 +对于JSON/JSONCompact/JSONColumnsWithMetadata输入格式,如果该设置设置为1, +将比较输入数据的元数据中的类型与表中对应列的类型。 -默认启用。 +默认情况下启用。 ## input_format_max_block_size_bytes {#input_format_max_block_size_bytes} -限制在输入格式解析数据时形成的块的大小,单位为字节。用于基于行的输入格式,当块在 ClickHouse 端形成时。 -0 意味着没有字节限制。 +限制在输入格式中解析数据时形成的块的大小(以字节为单位)。在基于行的输入格式中使用,当在ClickHouse端形成块时。 +0表示字节上没有限制。 ## input_format_max_bytes_to_read_for_schema_inference {#input_format_max_bytes_to_read_for_schema_inference} -自动模式推导时要读取的最大字节数。 +进行自动模式推断时可读取的最大字节数据量。 ## input_format_max_rows_to_read_for_schema_inference {#input_format_max_rows_to_read_for_schema_inference} -自动模式推导时要读取的最大行数。 +进行自动模式推断时可读取的最大数据行数。 ## input_format_msgpack_number_of_columns {#input_format_msgpack_number_of_columns} -插入的 MsgPack 数据中的列数。用于从数据中进行自动模式推导。 +插入的MsgPack数据中的列数。用于从数据中进行自动模式推断。 ## input_format_mysql_dump_map_column_names {#input_format_mysql_dump_map_column_names} -在 MySQL 转储中的表和 ClickHouse 表的列按名称匹配。 +根据名称匹配MySQL转储中的表列和ClickHouse表中的列。 ## input_format_mysql_dump_table_name {#input_format_mysql_dump_table_name} -从中读取数据的 MySQL 转储中的表名。 +MySQL转储中要读取数据的表名称。 ## input_format_native_allow_types_conversion {#input_format_native_allow_types_conversion} -在 Native 输入格式中允许数据类型转换。 +允许在Native输入格式中进行数据类型转换。 ## input_format_native_decode_types_in_binary_format {#input_format_native_decode_types_in_binary_format} -在 Native 输入格式中以二进制格式读取数据类型,而不是类型名称。 +在Native输入格式中读取数据类型,而不是读取类型名称。 ## input_format_null_as_default {#input_format_null_as_default} -启用或禁用 [NULL](/sql-reference/syntax#literals) 字段使用 [默认值](/sql-reference/statements/create/table#default_values) 初始化,如果这些字段的数据类型不是 [nullable](/sql-reference/data-types/nullable)。如果列类型非可空且此设置禁用,插入 `NULL` 将导致异常。如果列类型可空,则 `NULL` 值将原样插入,而不论此设置。 +启用或禁用使用 [NULL](/sql-reference/syntax#literals) 字段的 [默认值](/sql-reference/statements/create/table#default_values) 进行初始化,如果这些字段的数据类型不是 [nullable](/sql-reference/data-types/nullable)。 +如果列类型不是nullable,并且该设置禁用,则插入 `NULL` 会导致异常。如果列类型是nullable,则 `NULL` 值将按原样插入,而与此设置无关。 此设置适用于大多数输入格式。 @@ -626,64 +701,108 @@ DESC format(JSONEachRow, '{"obj" : {"a" : 42, "b" : "Hello"}}, {"obj" : {"a" : 4 可能的值: -- 0 — 将 `NULL` 插入到非可空列会导致异常。 -- 1 — `NULL` 字段使用默认列值初始化。 +- 0 — 将 `NULL` 插入非nullable列导致异常。 +- 1 — `NULL` 字段用默认列值初始化。 ## input_format_orc_allow_missing_columns {#input_format_orc_allow_missing_columns} -在读取 ORC 输入格式时允许缺失的列。 +在读取ORC输入格式时允许缺少列。 ## input_format_orc_case_insensitive_column_matching {#input_format_orc_case_insensitive_column_matching} + + 在匹配 ORC 列与 CH 列时忽略大小写。 ## input_format_orc_dictionary_as_low_cardinality {#input_format_orc_dictionary_as_low_cardinality} + + 在读取 ORC 文件时,将 ORC 字典编码列视为 LowCardinality 列。 ## input_format_orc_filter_push_down {#input_format_orc_filter_push_down} -在读取 ORC 文件时,基于 WHERE/PREWHERE 表达式、最小/最大统计或 ORC 元数据中的布隆过滤器,跳过整个条带或行组。 + + +在读取 ORC 文件时,根据 WHERE/PREWHERE 表达式、最小/最大统计信息或 ORC 元数据中的布隆过滤器跳过整个条带或行组。 ## input_format_orc_reader_time_zone_name {#input_format_orc_reader_time_zone_name} -ORC 行读取器的时区名称,默认的 ORC 行读取器时区为 GMT。 + + +ORC 行读取器的时区名称,默认 ORC 行读取器的时区为 GMT。 ## input_format_orc_row_batch_size {#input_format_orc_row_batch_size} + + 读取 ORC 条带时的批处理大小。 ## input_format_orc_skip_columns_with_unsupported_types_in_schema_inference {#input_format_orc_skip_columns_with_unsupported_types_in_schema_inference} -在格式 ORC 的模式推导过程中跳过不支持的类型的列。 + + +在 ORC 格式的模式推断过程中跳过具有不支持类型的列。 ## input_format_orc_use_fast_decoder {#input_format_orc_use_fast_decoder} + + 使用更快的 ORC 解码器实现。 ## input_format_parquet_allow_geoparquet_parser {#input_format_parquet_allow_geoparquet_parser} -使用 geo 列解析器将 Array(UInt8) 转换为 Point/Linestring/Polygon/MultiLineString/MultiPolygon 类型。 + + +使用地理列解析器将 Array(UInt8) 转换为 Point/Linestring/Polygon/MultiLineString/MultiPolygon 类型。 ## input_format_parquet_allow_missing_columns {#input_format_parquet_allow_missing_columns} -在读取 Parquet 输入格式时允许缺失的列。 + + +在读取 Parquet 输入格式时允许缺少列。 ## input_format_parquet_bloom_filter_push_down {#input_format_parquet_bloom_filter_push_down} -在读取 Parquet 文件时,基于 WHERE 表达式和 Parquet 元数据中的布隆过滤器,跳过整个行组。 + + +在读取 Parquet 文件时,根据 WHERE 表达式和 Parquet 元数据中的布隆过滤器跳过整个行组。 ## input_format_parquet_case_insensitive_column_matching {#input_format_parquet_case_insensitive_column_matching} + + 在匹配 Parquet 列与 CH 列时忽略大小写。 +## input_format_parquet_enable_json_parsing {#input_format_parquet_enable_json_parsing} + + + +在读取 Parquet 文件时,将 JSON 列解析为 ClickHouse JSON 列。 ## input_format_parquet_enable_row_group_prefetch {#input_format_parquet_enable_row_group_prefetch} -在 parquet 解析期间启用行组预取。目前,只有单线程解析可以预取。 + + +在 Parquet 解析过程中启用行组预取。目前,只有单线程解析可以进行预取。 ## input_format_parquet_filter_push_down {#input_format_parquet_filter_push_down} -读取 Parquet 文件时,根据 WHERE/PREWHERE 表达式和 Parquet 元数据中的最小/最大统计信息跳过整个行组。 +在读取 Parquet 文件时,根据 WHERE/PREWHERE 表达式和 Parquet 元数据中的最小/最大统计信息跳过整个行组。 ## input_format_parquet_local_file_min_bytes_for_seek {#input_format_parquet_local_file_min_bytes_for_seek} -本地读取(文件)所需的最小字节数,以进行寻址,而不是使用忽略模式读取 Parquet 输入格式。 +进行本地读取(文件)以执行查找所需的最小字节数,而不是在 Parquet 输入格式中忽略读取。 ## input_format_parquet_max_block_size {#input_format_parquet_max_block_size} - + Parquet 阅读器的最大块大小。 +## input_format_parquet_memory_high_watermark {#input_format_parquet_memory_high_watermark} + + + +Parquet 阅读器 v3 的近似内存限制。限制可以并行读取的行组或列的数量。当在一个查询中读取多个文件时,限制是这些文件的总内存使用量。 +## input_format_parquet_memory_low_watermark {#input_format_parquet_memory_low_watermark} + + + +如果内存使用量低于阈值,则更积极地调度预取。这在通过网络读取许多小布隆过滤器时可能会很有用。 +## input_format_parquet_page_filter_push_down {#input_format_parquet_page_filter_push_down} + + + +使用列索引中的最小/最大值跳过页面。 ## input_format_parquet_prefer_block_bytes {#input_format_parquet_prefer_block_bytes} @@ -691,36 +810,63 @@ Parquet 阅读器的最大块大小。 Parquet 阅读器输出的平均块字节数。 ## input_format_parquet_preserve_order {#input_format_parquet_preserve_order} -从 Parquet 文件读取时避免重新排序行。通常会使速度变慢。 + + +在从 Parquet 文件读取时避免重新排序行。不推荐,因为行的排序通常不保证,查询管道的其他部分可能会破坏它。请改用 `ORDER BY _row_number`。 ## input_format_parquet_skip_columns_with_unsupported_types_in_schema_inference {#input_format_parquet_skip_columns_with_unsupported_types_in_schema_inference} -在 Parquet 格式的模式推断中跳过具有不支持类型的列。 + + +在 Parquet 格式的模式推断过程中跳过具有不支持类型的列。 ## input_format_parquet_use_native_reader {#input_format_parquet_use_native_reader} -读取 Parquet 文件时,使用本机阅读器而不是箭头阅读器。 + + +使用原生 Parquet 阅读器 v1。这是相对快速但未完成的实现。已弃用。 +## input_format_parquet_use_native_reader_v3 {#input_format_parquet_use_native_reader_v3} + + + +使用 Parquet 阅读器 v3。实验性。 +## input_format_parquet_use_offset_index {#input_format_parquet_use_offset_index} + + + +在不使用页面过滤的情况下,稍微调整从 Parquet 文件读取页面的方式。 ## input_format_protobuf_flatten_google_wrappers {#input_format_protobuf_flatten_google_wrappers} -为常规非嵌套列启用 Google 包装器,例如 google.protobuf.StringValue 'str' 对于字符串列 'str'。对于 Nullable 列,空包装器被识别为默认值,缺失则被视为 null。 + + +启用 Google wrappers 用于常规非嵌套列,例如 google.protobuf.StringValue 'str' 用于字符串列 'str'。对于 Nullable 列,空的 wrappers 被识别为默认值,缺失则作为 null。 +## input_format_protobuf_oneof_presence {#input_format_protobuf_oneof_presence} + + + +通过在特殊列中设置枚举值指示 protobuf oneof 的哪些字段被找到。 ## input_format_protobuf_skip_fields_with_unsupported_types_in_schema_inference {#input_format_protobuf_skip_fields_with_unsupported_types_in_schema_inference} -在 Protobuf 格式的模式推断中跳过具有不支持类型的字段。 + + +在 Protobuf 格式的模式推断过程中跳过具有不支持类型的字段。 ## input_format_record_errors_file_path {#input_format_record_errors_file_path} -读取文本格式(CSV、TSV)时用于记录错误的文件路径。 +用于记录读取文本格式(CSV, TSV)时错误的文件路径。 ## input_format_skip_unknown_fields {#input_format_skip_unknown_fields} -启用或禁用跳过插入额外数据。 + + +启用或禁用跳过多余数据的插入。 -写入数据时,如果输入数据包含在目标表中不存在的列,ClickHouse 会抛出异常。如果启用了跳过,ClickHouse 将不插入额外数据,并且不抛出异常。 +在插入数据时,如果输入数据包含在目标表中不存在的列,ClickHouse 会抛出异常。如果启用跳过,ClickHouse 不会插入多余数据,也不会抛出异常。 支持的格式: - [JSONEachRow](/interfaces/formats/JSONEachRow)(和其他 JSON 格式) - [BSONEachRow](/interfaces/formats/BSONEachRow)(和其他 JSON 格式) -- [TSKV](/interfaces/formats/TSKV) -- 所有后缀为 WithNames/WithNamesAndTypes 的格式 -- [MySQLDump](/interfaces/formats/MySQLDump) -- [Native](/interfaces/formats/Native) +- [TSKV](/interfaces/formats/TSKV) +- 所有带有 WithNames/WithNamesAndTypes 后缀的格式 +- [MySQLDump](/interfaces/formats/MySQLDump) +- [Native](/interfaces/formats/Native) 可能的值: @@ -728,28 +874,40 @@ Parquet 阅读器输出的平均块字节数。 - 1 — 启用。 ## input_format_try_infer_dates {#input_format_try_infer_dates} -如果启用,ClickHouse 会尝试从字符串字段推断类型 `Date`,用于文本格式的模式推断。如果输入数据中某列的所有字段均成功解析为日期,则结果类型为 `Date`;如果至少有一个字段未解析为日期,则结果类型为 `String`。 + + +如果启用,ClickHouse 将尝试从模式推断文本格式中的字符串字段推断类型 `Date`。如果输入数据中列的所有字段都成功解析为日期,则结果类型将为 `Date`;如果至少有一个字段未解析为日期,则结果类型将为 `String`。 默认启用。 ## input_format_try_infer_datetimes {#input_format_try_infer_datetimes} -如果启用,ClickHouse 会尝试从字符串字段推断类型 `DateTime64`,用于文本格式的模式推断。如果输入数据中某列的所有字段均成功解析为日期时间,则结果类型为 `DateTime64`;如果至少有一个字段未解析为日期时间,则结果类型为 `String`。 + + +如果启用,ClickHouse 将尝试从模式推断文本格式中的字符串字段推断类型 `DateTime64`。如果输入数据中列的所有字段都成功解析为日期时间,则结果类型将为 `DateTime64`;如果至少有一个字段未解析为日期时间,则结果类型将为 `String`。 默认启用。 ## input_format_try_infer_datetimes_only_datetime64 {#input_format_try_infer_datetimes_only_datetime64} -当启用 input_format_try_infer_datetimes 时,仅推断 DateTime64 而不推断 DateTime 类型。 + + +当 input_format_try_infer_datetimes 启用时,仅推断 DateTime64 而不推断 DateTime 类型。 ## input_format_try_infer_exponent_floats {#input_format_try_infer_exponent_floats} -在文本格式的模式推断中(除 JSON 外)尝试推断指数表示的浮点数(在 JSON 中,指数数字始终被推断)。 + + +尝试在文本格式的模式推断过程中推断以指数表示的浮点数(除 JSON 外,因为在 JSON 中,指数数字总是被推断)。 ## input_format_try_infer_integers {#input_format_try_infer_integers} -如果启用,ClickHouse 会尝试推断整数而不是浮点数,用于文本格式的模式推断。如果输入数据中某列的所有数字都是整数,则结果类型为 `Int64`;如果至少有一个数字是浮点数,则结果类型为 `Float64`。 + + +如果启用,ClickHouse 将尝试在文本格式的模式推断中推断整型而不是浮点型。如果输入数据中列的所有数字都是整数,则结果类型将为 `Int64`;如果至少有一个数字是浮点数,则结果类型将为 `Float64`。 默认启用。 ## input_format_try_infer_variants {#input_format_try_infer_variants} -如果启用,ClickHouse 会尝试在模式推断中推断类型 [`Variant`](../../sql-reference/data-types/variant.md),当列/数组元素有多个可能类型时。 + + +如果启用,ClickHouse 将尝试在文本格式的模式推断中推断类型 [`Variant`](../../sql-reference/data-types/variant.md),当列/数组元素有多种可能类型时。 可能的值: @@ -757,42 +915,66 @@ Parquet 阅读器输出的平均块字节数。 - 1 — 启用。 ## input_format_tsv_allow_variable_number_of_columns {#input_format_tsv_allow_variable_number_of_columns} -在 TSV 输入中忽略额外列(如果文件的列数超出预期),并将 TSV 输入中缺失的字段视为默认值。 + + +忽略 TSV 输入中的额外列(如果文件中的列超过预期),并将 TSV 输入中的缺失字段视为默认值。 ## input_format_tsv_crlf_end_of_line {#input_format_tsv_crlf_end_of_line} -如果设置为 true,文件函数将以 \\r\\n 而不是 \\n 读取 TSV 格式。 + + +如果设置为 true,则文件功能将读取带有 \\r\\n 的 TSV 格式,而不是 \\n。 ## input_format_tsv_detect_header {#input_format_tsv_detect_header} -自动检测 TSV 格式中的名称和类型的头部。 + + +自动检测 TSV 格式中的列名和类型的头。 ## input_format_tsv_empty_as_default {#input_format_tsv_empty_as_default} + + 将 TSV 输入中的空字段视为默认值。 ## input_format_tsv_enum_as_number {#input_format_tsv_enum_as_number} -将 TSV 格式中插入的枚举值视为枚举索引。 + + +将 TSV 格式中的插入的枚举值视为枚举索引。 ## input_format_tsv_skip_first_lines {#input_format_tsv_skip_first_lines} -跳过 TSV 格式数据开头的指定行数。 + + +跳过 TSV 格式数据开头指定数量的行。 ## input_format_tsv_skip_trailing_empty_lines {#input_format_tsv_skip_trailing_empty_lines} + + 跳过 TSV 格式中的尾部空行。 ## input_format_tsv_use_best_effort_in_schema_inference {#input_format_tsv_use_best_effort_in_schema_inference} -在 TSV 格式中使用一些技巧和启发式来推断模式。 + + +使用一些技巧和启发式方法在 TSV 格式中推断模式。 ## input_format_values_accurate_types_of_literals {#input_format_values_accurate_types_of_literals} -对于 Values 格式:在使用模板解析和解释表达式时,检查文字的实际类型以避免可能的溢出和精度问题。 + + +对于 Values 格式:在解析和解释使用模板的表达式时,检查文字的实际类型以避免可能的溢出和精度问题。 ## input_format_values_deduce_templates_of_expressions {#input_format_values_deduce_templates_of_expressions} -对于 Values 格式:如果字段无法通过流解析器解析,则运行 SQL 解析器,推导 SQL 表达式的模板,尝试使用模板解析所有行,然后解释所有行的表达式。 + + +对于 Values 格式:如果字段无法通过流式解析器解析,则运行 SQL 解析器,推导 SQL 表达式的模板,尝试使用模板解析所有行,然后解释所有行的表达式。 ## input_format_values_interpret_expressions {#input_format_values_interpret_expressions} -对于 Values 格式:如果字段无法通过流解析器解析,则运行 SQL 解析器并尝试将其解释为 SQL 表达式。 + + +对于 Values 格式:如果字段无法通过流式解析器解析,则运行 SQL 解析器并尝试将其解释为 SQL 表达式。 ## input_format_with_names_use_header {#input_format_with_names_use_header} -启用或禁用插入数据时检查列顺序。 + + +启用或禁用在插入数据时检查列的顺序。 -为了提高插入性能,如果您确定输入数据的列顺序与目标表相同,建议禁用此检查。 +为了提高插入性能,我们建议在确定输入数据的列顺序与目标表相同的情况下禁用此检查。 支持的格式: @@ -802,8 +984,7 @@ Parquet 阅读器输出的平均块字节数。 - [TabSeparatedWithNamesAndTypes](/interfaces/formats/TabSeparatedWithNamesAndTypes) - [JSONCompactEachRowWithNames](/interfaces/formats/JSONCompactEachRowWithNames) - [JSONCompactEachRowWithNamesAndTypes](/interfaces/formats/JSONCompactEachRowWithNamesAndTypes) -- [JSONCompactStringsEachRowWithNames](/interfaces/formats/JSONCompactStringsEachRowWithNames) -- [JSONCompactStringsEachRowWithNamesAndTypes](/interfaces/formats/JSONCompactStringsEachRowWithNamesAndTypes) +- [JSONCompactStringsEachRowWithNames](/interfaces/formats/JSONCompactStringsEachRowWithNamesAndTypes) - [RowBinaryWithNames](/interfaces/formats/RowBinaryWithNames) - [RowBinaryWithNamesAndTypes](/interfaces/formats/RowBinaryWithNamesAndTypes) - [CustomSeparatedWithNames](/interfaces/formats/CustomSeparatedWithNames) @@ -815,7 +996,9 @@ Parquet 阅读器输出的平均块字节数。 - 1 — 启用。 ## input_format_with_types_use_header {#input_format_with_types_use_header} -控制格式解析器是否应检查输入数据中的数据类型是否与目标表中的数据类型匹配。 + + +控制格式解析器是否应检查输入数据的类型与目标表中的数据类型是否匹配。 支持的格式: @@ -832,88 +1015,130 @@ Parquet 阅读器输出的平均块字节数。 - 1 — 启用。 ## insert_distributed_one_random_shard {#insert_distributed_one_random_shard} -启用或禁用在没有分布密钥时随机分片插入到 [Distributed](/engines/table-engines/special/distributed) 表中。 + + +启用或禁用在没有分布式键时随机分片插入 [Distributed](/engines/table-engines/special/distributed) 表。 -默认情况下,当将数据插入多个分片的 `Distributed` 表时,如果没有提供分布密钥,ClickHouse 服务器将拒绝任何插入请求。当 `insert_distributed_one_random_shard = 1` 时,允许插入并将数据随机转发到所有分片中。 +默认情况下,当向具有多个分片的 `Distributed` 表插入数据时,如果没有分布式键,ClickHouse 服务器将拒绝任何插入请求。当 `insert_distributed_one_random_shard = 1` 时,允许插入,并将数据随机转发到所有分片。 可能的值: -- 0 — 如果有多个分片且未提供分布密钥,则拒绝插入。 -- 1 — 当没有提供分布密钥时,在所有可用分片中随机进行插入。 +- 0 — 如果有多个分片且未给出分布式键,则拒绝插入。 +- 1 — 在未给出分布式键时,在所有可用分片之间随机进行插入。 ## interval_output_format {#interval_output_format} -允许选择不同的输出格式,用于间隔类型的文本表示。 + + +允许选择间隔类型文本表示的不同输出格式。 可能的值: -- `kusto` - KQL 风格的输出格式。 +- `kusto` - KQL 样式输出格式。 - ClickHouse 以 [KQL 格式](https://learn.microsoft.com/en-us/dotnet/standard/base-types/standard-timespan-format-strings#the-constant-c-format-specifier) 输出间隔。例如,`toIntervalDay(2)` 将格式化为 `2.00:00:00`。请注意,对于长度可变的间隔类型(即 `IntervalMonth` 和 `IntervalYear`),会考虑每个间隔的平均秒数。 + ClickHouse 以 [KQL 格式](https://learn.microsoft.com/en-us/dotnet/standard/base-types/standard-timespan-format-strings#the-constant-c-format-specifier) 输出间隔。例如,`toIntervalDay(2)` 将格式化为 `2.00:00:00`。请注意,对于长度不等的间隔类型(例如 `IntervalMonth` 和 `IntervalYear`),会考虑每个间隔的平均秒数。 - `numeric` - 数字输出格式。 - ClickHouse 输出间隔的底层数字表示。例如,`toIntervalDay(2)` 将格式化为 `2`。 + ClickHouse 以其底层的数字表示输出间隔。例如,`toIntervalDay(2)` 将格式化为 `2`。 另请参见: - [Interval](../../sql-reference/data-types/special-data-types/interval.md) +## json_type_escape_dots_in_keys {#json_type_escape_dots_in_keys} + + + +启用后,在解析期间将转义 JSON 键中的点。 ## output_format_arrow_compression_method {#output_format_arrow_compression_method} -Arrow 输出格式的压缩方法。支持的编解码器:lz4_frame、zstd、none(未压缩) + + +Arrow 输出格式的压缩方法。支持的编解码器:lz4_frame, zstd, none(未压缩) ## output_format_arrow_fixed_string_as_fixed_byte_array {#output_format_arrow_fixed_string_as_fixed_byte_array} -对于 FixedString 列,使用 Arrow FIXED_SIZE_BINARY 类型而不是 Binary。 + + +对于 FixedString 列,使用 Arrow FIXED_SIZE_BINARY 类型,而不是 Binary。 ## output_format_arrow_low_cardinality_as_dictionary {#output_format_arrow_low_cardinality_as_dictionary} -启用输出低基数类型作为字典 Arrow 类型。 + + +将输出 LowCardinality 类型作为字典 Arrow 类型。 ## output_format_arrow_string_as_string {#output_format_arrow_string_as_string} -对于字符串列,使用 Arrow String 类型而不是 Binary。 + + +对于字符串列,使用 Arrow 字符串类型,而不是 Binary。 ## output_format_arrow_use_64_bit_indexes_for_dictionary {#output_format_arrow_use_64_bit_indexes_for_dictionary} -在 Arrow 格式中始终使用 64 位整数作为字典索引。 + + +始终使用 64 位整数作为 Arrow 格式中的字典索引。 ## output_format_arrow_use_signed_indexes_for_dictionary {#output_format_arrow_use_signed_indexes_for_dictionary} -在 Arrow 格式中为字典索引使用带符号整数。 + + +在 Arrow 格式中为字典索引使用有符号整数。 ## output_format_avro_codec {#output_format_avro_codec} -输出时使用的压缩编解码器。可能的值:'null'、'deflate'、'snappy'、'zstd'。 + + +用于输出的压缩编解码器。可能的值:'null', 'deflate', 'snappy', 'zstd'。 ## output_format_avro_rows_in_file {#output_format_avro_rows_in_file} + + 文件中的最大行数(如果存储允许)。 ## output_format_avro_string_column_pattern {#output_format_avro_string_column_pattern} -对于 Avro 格式:选择为 AVRO 字符串的字符串列的正则表达式。 + +用于 Avro 格式:选择为 AVRO 字符串的字符串列的正则表达式。 ## output_format_avro_sync_interval {#output_format_avro_sync_interval} -以字节为单位的同步间隔。 + + +同步间隔(以字节为单位)。 ## output_format_binary_encode_types_in_binary_format {#output_format_binary_encode_types_in_binary_format} + + 在 RowBinaryWithNamesAndTypes 输出格式中以二进制格式写入数据类型,而不是类型名称。 ## output_format_binary_write_json_as_string {#output_format_binary_write_json_as_string} -在 RowBinary 输出格式中将 [JSON](../../sql-reference/data-types/newjson.md) 数据类型的值作为 JSON [String](../../sql-reference/data-types/string.md) 值写入。 + + +在 RowBinary 输出格式中,将 [JSON](../../sql-reference/data-types/newjson.md) 数据类型的值写为 JSON [String](../../sql-reference/data-types/string.md) 值。 ## output_format_bson_string_as_string {#output_format_bson_string_as_string} -对于字符串列,使用 BSON String 类型而不是 Binary。 + + +对于字符串列,使用 BSON 字符串类型,而不是 Binary。 ## output_format_csv_crlf_end_of_line {#output_format_csv_crlf_end_of_line} -如果设置为 true,CSV 格式中的行末将为 \\r\\n 而不是 \\n。 + + +如果设置为 true,CSV 格式的行结束将为 \\r\\n,而不是 \\n。 ## output_format_csv_serialize_tuple_into_separate_columns {#output_format_csv_serialize_tuple_into_separate_columns} -如果设置为 true,则 CSV 格式中的元组将被序列化为单独的列(即,它们在元组中的嵌套将丢失)。 + + +如果设置为 true,则 CSV 格式中的元组被序列化为单独的列(即它们在元组中的嵌套关系丢失)。 ## output_format_decimal_trailing_zeros {#output_format_decimal_trailing_zeros} -打印 Decimal 值时输出尾随零。例如,1.230000 而不是 1.23。 + + +打印十进制值时输出尾随零。例如,1.230000 而不是 1.23。 默认禁用。 ## output_format_json_array_of_rows {#output_format_json_array_of_rows} -启用能够将所有行输出为 JSON 数组,以 [JSONEachRow](/interfaces/formats/JSONEachRow) 格式。 + + +启用将所有行作为 JSON 数组输出的能力,格式为 [JSONEachRow](/interfaces/formats/JSONEachRow)。 可能的值: -- 1 — ClickHouse 将所有行作为数组输出,每行在 `JSONEachRow` 格式中。 +- 1 — ClickHouse 将所有行输出为数组,每行为 `JSONEachRow` 格式。 - 0 — ClickHouse 将每行单独输出为 `JSONEachRow` 格式。 **启用设置的查询示例** @@ -953,42 +1178,100 @@ SELECT number FROM numbers(3) FORMAT JSONEachRow; ``` ## output_format_json_escape_forward_slashes {#output_format_json_escape_forward_slashes} -控制 JSON 输出格式中字符串输出的转义正斜杠。这用于与 JavaScript 兼容。请不要与始终转义的反斜杠混淆。 + +控制 JSON 输出格式中字符串输出的正斜杠转义。这是为了与 JavaScript 兼容。与总是被转义的反斜杠混淆。 + 默认启用。 +## output_format_json_map_as_array_of_tuples {#output_format_json_map_as_array_of_tuples} + + + +将映射列序列化为 JSON 元组数组。 + +默认禁用。 ## output_format_json_named_tuples_as_objects {#output_format_json_named_tuples_as_objects} + + 将命名元组列序列化为 JSON 对象。 默认启用。 ## output_format_json_pretty_print {#output_format_json_pretty_print} -启用时,复杂数据类型如 Tuple/Array/Map 在 JSON 输出格式中的 'data' 部分将以美化格式打印。 + + +此设置确定在使用 JSON 输出格式时,嵌套结构(例如元组、映射和数组)在 `data` 数组中如何显示。 + +例如,输出将不再是: + +```json +"data": +[ + { + "tuple": {"a":1,"b":2,"c":3}, + "array": [1,2,3], + "map": {"a":1,"b":2,"c":3} + } +], +``` + +而是格式化为: + +```json +"data": +[ + { + "tuple": { + "a": 1, + "b": 2, + "c": 3 + }, + "array": [ + 1, + 2, + 3 + ], + "map": { + "a": 1, + "b": 2, + "c": 3 + } + } +], +``` 默认启用。 ## output_format_json_quote_64bit_floats {#output_format_json_quote_64bit_floats} -控制在 JSON* 格式中输出时 64 位 [浮点数](../../sql-reference/data-types/float.md) 的引号。 + + +控制在 JSON* 格式中输出 64 位 [浮点数](../../sql-reference/data-types/float.md) 时的引号。 默认禁用。 ## output_format_json_quote_64bit_integers {#output_format_json_quote_64bit_integers} -控制在 [JSON](/interfaces/formats/JSON) 格式输出时 64 位或更大 [整数](../../sql-reference/data-types/int-uint.md)(如 `UInt64` 或 `Int128`)的引号。 + -此类整数通常被引号包围。此行为与大多数 JavaScript 实现兼容。 +控制在 [JSON](/interfaces/formats/JSON) 格式中输出 64 位或更大 [整数](../../sql-reference/data-types/int-uint.md)(如 `UInt64` 或 `Int128`)时的引号。 +该整数默认用引号括起来。这种行为与大多数 JavaScript 实现兼容。 可能的值: - 0 — 整数不带引号输出。 -- 1 — 整数带引号输出。 +- 1 — 整数用引号括起来。 ## output_format_json_quote_decimals {#output_format_json_quote_decimals} + + 控制在 JSON 输出格式中小数的引号。 默认禁用。 ## output_format_json_quote_denormals {#output_format_json_quote_denormals} -启用 [JSON](/interfaces/formats/JSON) 输出格式中的 `+nan`、`-nan`、`+inf`、`-inf` 输出。 + + +启用在 [JSON](/interfaces/formats/JSON) 输出格式中输出 `+nan`、`-nan`、`+inf`、`-inf`。 可能的值: @@ -1007,7 +1290,7 @@ SELECT number FROM numbers(3) FORMAT JSONEachRow; └────┴────────┴──────────┴────────┴──────┘ ``` -当 `output_format_json_quote_denormals = 0` 时,查询返回输出中的 `null` 值: +当 `output_format_json_quote_denormals = 0` 时,查询返回的输出中的值为 `null`: ```sql SELECT area/period FROM account_orders FORMAT JSON; @@ -1084,17 +1367,23 @@ SELECT area/period FROM account_orders FORMAT JSON; ``` ## output_format_json_skip_null_value_in_named_tuples {#output_format_json_skip_null_value_in_named_tuples} -序列化命名元组列作为 JSON 对象时跳过键值对中的 null 值。仅在 output_format_json_named_tuples_as_objects 为 true 时有效。 + + +在将命名元组列序列化为 JSON 对象时,跳过具有 null 值的键值对。仅在 output_format_json_named_tuples_as_objects 为 true 时有效。 ## output_format_json_validate_utf8 {#output_format_json_validate_utf8} -控制 JSON 输出格式中的 UTF-8 序列的验证,某些格式如 JSON/JSONCompact/JSONColumnsWithMetadata 始终验证 UTF-8。 + + +控制在 JSON 输出格式中对 UTF-8 序列的验证,不影响格式 JSON/JSONCompact/JSONColumnsWithMetadata,它们始终验证 UTF-8。 默认禁用。 ## output_format_markdown_escape_special_characters {#output_format_markdown_escape_special_characters} -启用时,在 Markdown 中转义特殊字符。 + + +启用后,在 Markdown 中转义特殊字符。 -[Common Mark](https://spec.commonmark.org/0.30/#example-12) 定义了以下特殊字符,可以通过反斜杠转义: +[Common Mark](https://spec.commonmark.org/0.30/#example-12) 定义以下特殊字符可以被转义: ``` ! " # $ % & ' ( ) * + , - . / : ; < = > ? @ [ \ ] ^ _ ` { | } ~ @@ -1106,94 +1395,174 @@ SELECT area/period FROM account_orders FORMAT JSON; + 1 — 启用。 ## output_format_msgpack_uuid_representation {#output_format_msgpack_uuid_representation} -以 MsgPack 格式输出 UUID 的方式。 + + +在 MsgPack 格式中输出 UUID 的方式。 ## output_format_native_encode_types_in_binary_format {#output_format_native_encode_types_in_binary_format} -在 Native 输出格式中以二进制格式写入数据类型,而不是类型名称。 + + +在原生输出格式中以二进制格式写入数据类型,而不是类型名称。 +## output_format_native_use_flattened_dynamic_and_json_serialization {#output_format_native_use_flattened_dynamic_and_json_serialization} + + + +以扁平格式(将所有类型/路径作为单独的子列)写入 [JSON](../../sql-reference/data-types/newjson.md) 和 [Dynamic](../../sql-reference/data-types/dynamic.md) 列的数据。 ## output_format_native_write_json_as_string {#output_format_native_write_json_as_string} -将 [JSON](../../sql-reference/data-types/newjson.md) 列的数据写为包含 JSON 字符串的 [String](../../sql-reference/data-types/string.md) 列,而不是默认本机 JSON 序列化。 + + +以 [String](../../sql-reference/data-types/string.md) 列的形式写入 [JSON](../../sql-reference/data-types/newjson.md) 列的数据,其中包含 JSON 字符串,而不是默认的原生 JSON 序列化。 +## output_format_orc_compression_block_size {#output_format_orc_compression_block_size} + + + +ORC 输出格式中压缩块的字节大小。 ## output_format_orc_compression_method {#output_format_orc_compression_method} -ORC 输出格式的压缩方法。支持的编解码器:lz4、snappy、zlib、zstd、none(未压缩) + + +ORC 输出格式的压缩方法。支持的编解码器:lz4, snappy, zlib, zstd, none(未压缩)。 ## output_format_orc_dictionary_key_size_threshold {#output_format_orc_dictionary_key_size_threshold} + + 对于 ORC 输出格式中的字符串列,如果不同值的数量超过非空行总数的这一比例,则关闭字典编码。否则启用字典编码。 ## output_format_orc_row_index_stride {#output_format_orc_row_index_stride} -ORC 输出格式中的目标行索引步幅。 +ORC 输出格式中目标行索引步幅。 ## output_format_orc_string_as_string {#output_format_orc_string_as_string} -对于字符串列,使用 ORC String 类型而不是 Binary。 + + +对于字符串列,使用 ORC 字符串类型,而不是 Binary。 ## output_format_orc_writer_time_zone_name {#output_format_orc_writer_time_zone_name} -ORC 编写器的时区名称,默认 ORC 编写器的时区为 GMT。 + + +ORC 写入器的时区名称,默认 ORC 写入器的时区为 GMT。 ## output_format_parquet_batch_size {#output_format_parquet_batch_size} -每多少行检查页面大小。如果列的平均值大小超过几个 KB,请考虑减少。 + + +检查每这多少行的页面大小。如果您的列的平均值大小超过几个 KB,请考虑减少该值。 ## output_format_parquet_bloom_filter_bits_per_value {#output_format_parquet_bloom_filter_bits_per_value} -用于 parquet bloom 过滤器中每个不同值的近似位数。估计的假阳性率: - * 6 bits - 10% - * 10.5 bits - 1% - * 16.9 bits - 0.1% - * 26.4 bits - 0.01% - * 41 bits - 0.001% + + +在 Parquet 布隆过滤器中为每个不同值使用的近似位数。估计的假阳性率: + * 6 位 - 10% + * 10.5 位 - 1% + * 16.9 位 - 0.1% + * 26.4 位 - 0.01% + * 41 位 - 0.001% ## output_format_parquet_bloom_filter_flush_threshold_bytes {#output_format_parquet_bloom_filter_flush_threshold_bytes} -在 parquet 文件中放置 bloom 过滤器的位置。Bloom 过滤器将以大约此大小的组写入。特别地: - * 如果 0,则每个行组的 bloom 过滤器会立即在行组后写入, - * 如果大于所有 bloom 过滤器的总大小,则所有行组的 bloom 过滤器将积累在内存中,然后在文件末尾附近一起写入, - * 否则,bloom 过滤器将在内存中积累,并在总大小超过此值时写出。 + + +在 Parquet 文件中放置布隆过滤器的位置。布隆过滤器将以大约此大小的组写入。特别是: + * 如果为 0,每个行组的布隆过滤器会立即写在行组之后。 + * 如果大于所有布隆过滤器的总大小,所有行组的布隆过滤器将存储在内存中,然后一起在文件的末尾附近写入。 + * 否则,布隆过滤器将在内存中累积,并在其总大小超过此值时写出。 ## output_format_parquet_compliant_nested_types {#output_format_parquet_compliant_nested_types} -在 parquet 文件模式中,对于列表元素使用名称 'element' 而不是 'item'。这是 Arrow 库实现的一个历史工件。通常可以提高兼容性,但与一些旧版本的 Arrow 可能不兼容。 + + +在 Parquet 文件模式中,为列表元素使用名称 'element' 而不是 'item'。这是 Arrow 库实现的历史遗留物。通常可以增加兼容性,除非与某些旧版本的 Arrow。 ## output_format_parquet_compression_method {#output_format_parquet_compression_method} -Parquet 输出格式的压缩方法。支持的编解码器:snappy、lz4、brotli、zstd、gzip、none(未压缩)。 + + +Parquet 输出格式的压缩方法。支持的编解码器:snappy, lz4, brotli, zstd, gzip, none(未压缩)。 ## output_format_parquet_data_page_size {#output_format_parquet_data_page_size} -压缩前每个页面的目标大小(以字节为单位)。 + + +以字节为单位的目标页面大小,在压缩之前。 +## output_format_parquet_date_as_uint16 {#output_format_parquet_date_as_uint16} + + + +将日期值写为普通的 16 位数字(以 UInt16 读取),而不是转换为 32 位 parquet DATE 类型(以 Date32 读取)。 ## output_format_parquet_datetime_as_uint32 {#output_format_parquet_datetime_as_uint32} -将 DateTime 值作为原始 Unix 时间戳写入(以 UInt32 读取),而不是转换为毫秒(以 DateTime64(3) 读取)。 + + +将 DateTime 值写为原始 unix 时间戳(以 UInt32 读取),而不是转换为毫秒(以 DateTime64(3) 读取)。 +## output_format_parquet_enum_as_byte_array {#output_format_parquet_enum_as_byte_array} + + + +使用 parquet 物理类型:BYTE_ARRAY 和逻辑类型:ENUM 编写枚举。 ## output_format_parquet_fixed_string_as_fixed_byte_array {#output_format_parquet_fixed_string_as_fixed_byte_array} -对于 FixedString 列,使用 Parquet FIXED_LENGTH_BYTE_ARRAY 类型而不是 Binary。 + + +对于 FixedString 列,使用 Parquet FIXED_LENGTH_BYTE_ARRAY 类型,而不是 Binary。 +## output_format_parquet_geometadata {#output_format_parquet_geometadata} + + + +允许在 parquet 元数据中写入有关地理列的信息,并以 WKB 格式编码列。 +## output_format_parquet_max_dictionary_size {#output_format_parquet_max_dictionary_size} + + + +如果字典大小超过这一字节数,则切换到不使用字典的编码。设置为 0 以禁用字典编码。 ## output_format_parquet_parallel_encoding {#output_format_parquet_parallel_encoding} -以多个线程进行 Parquet 编码。这要求使用 output_format_parquet_use_custom_encoder。 + + +在多个线程中进行 Parquet 编码。需要 output_format_parquet_use_custom_encoder。 ## output_format_parquet_row_group_size {#output_format_parquet_row_group_size} + + 目标行组大小(以行数为单位)。 ## output_format_parquet_row_group_size_bytes {#output_format_parquet_row_group_size_bytes} -目标行组大小(以字节为单位),压缩前。 + + +目标行组大小(以字节为单位),在压缩之前。 ## output_format_parquet_string_as_string {#output_format_parquet_string_as_string} -对于字符串列,使用 Parquet String 类型而不是 Binary。 + + +对于字符串列,使用 Parquet 字符串类型,而不是 Binary。 ## output_format_parquet_use_custom_encoder {#output_format_parquet_use_custom_encoder} + + 使用更快的 Parquet 编码器实现。 ## output_format_parquet_version {#output_format_parquet_version} + + 输出格式的 Parquet 格式版本。支持的版本:1.0、2.4、2.6 和 2.latest(默认)。 ## output_format_parquet_write_bloom_filter {#output_format_parquet_write_bloom_filter} -在 parquet 文件中写入 bloom 过滤器。需要使用 output_format_parquet_use_custom_encoder = true。 + + +在 Parquet 文件中写入布隆过滤器。需要 output_format_parquet_use_custom_encoder = true。 ## output_format_parquet_write_page_index {#output_format_parquet_write_page_index} -将列索引和偏移索引(即每个数据页面的统计信息,可用于读取时进行过滤推断)写入 parquet 文件。 + + +在 Parquet 文件中写入列索引和偏移索引(即有关每个数据页面的统计信息,可用于读取时的过滤器下推)。 ## output_format_pretty_color {#output_format_pretty_color} -在漂亮格式中使用 ANSI 转义序列。0 - 禁用,1 - 启用,'auto' - 如果是终端则启用。 + + +在 Pretty 格式中使用 ANSI 转义序列。0 - 禁用,1 - 启用,'auto' - 在终端中启用。 ## output_format_pretty_display_footer_column_names {#output_format_pretty_display_footer_column_names} -如果行数很多,则在页脚中显示列名。 + + +当表行数很多时,在页脚中显示列名。 可能的值: -- 0 — 不在页脚中显示列名。 +- 0 — 页脚中不显示列名。 - 1 — 如果行数大于或等于由 [output_format_pretty_display_footer_column_names_min_rows](#output_format_pretty_display_footer_column_names_min_rows) 设置的阈值(默认 50),则在页脚中显示列名。 **示例** @@ -1218,137 +1587,164 @@ SELECT *, toTypeName(*) FROM (SELECT * FROM system.numbers LIMIT 1000); ``` ## output_format_pretty_display_footer_column_names_min_rows {#output_format_pretty_display_footer_column_names_min_rows} -设置当启用 [output_format_pretty_display_footer_column_names](#output_format_pretty_display_footer_column_names) 时,显示列名的页脚的最小行数。 + + +设置在启用 [output_format_pretty_display_footer_column_names](#output_format_pretty_display_footer_column_names) 的情况下,显示包含列名的页脚的最小行数。 ## output_format_pretty_fallback_to_vertical {#output_format_pretty_fallback_to_vertical} -如果启用,并且表宽而短,漂亮格式将像垂直格式那样输出。 -请参见 `output_format_pretty_fallback_to_vertical_max_rows_per_chunk` 和 `output_format_pretty_fallback_to_vertical_min_table_width` 以详细调整该行为。 + + +如果启用且表宽但短,Pretty 格式将像纵向格式那样输出。 +有关此行为的详细调优,请参见 `output_format_pretty_fallback_to_vertical_max_rows_per_chunk` 和 `output_format_pretty_fallback_to_vertical_min_table_width`。 ## output_format_pretty_fallback_to_vertical_max_rows_per_chunk {#output_format_pretty_fallback_to_vertical_max_rows_per_chunk} -仅在块中的记录数不超过指定值时,才会触发回退到垂直格式(请参阅 `output_format_pretty_fallback_to_vertical`)。 + + +仅在块中的记录数不超过指定值时,才会激活纵向格式的回退(请参见 `output_format_pretty_fallback_to_vertical`)。 ## output_format_pretty_fallback_to_vertical_min_columns {#output_format_pretty_fallback_to_vertical_min_columns} -仅在列数大于指定值时,才会触发回退到垂直格式(请参阅 `output_format_pretty_fallback_to_vertical`)。 + + +仅在列数大于指定值时,才会激活纵向格式的回退(请参见 `output_format_pretty_fallback_to_vertical`)。 ## output_format_pretty_fallback_to_vertical_min_table_width {#output_format_pretty_fallback_to_vertical_min_table_width} -仅在表中列的总长度至少为指定值,或者至少一个值包含换行符时,才会触发回退到垂直格式(请参阅 `output_format_pretty_fallback_to_vertical`)。 + + +仅在表中列的长度总和至少为指定值,或至少有一个值包含换行符时,才会激活纵向格式的回退(请参见 `output_format_pretty_fallback_to_vertical`)。 ## output_format_pretty_glue_chunks {#output_format_pretty_glue_chunks} -如果在漂亮格式中呈现的数据来自多个块,即使经过延迟,但下一个块的列宽与上一个块相同,则使用 ANSI 转义序列返回到上一行并覆盖上一个块的页脚,以继续与新块的数据一起输出。这使结果在视觉上更令人愉悦。 + + +如果以 Pretty 格式渲染的数据分为多个块,即使在延迟后,但是下一个块与之前的列宽相同,使用 ANSI 转义序列回到上一行并覆盖前一个块的页脚,以继续新块的数据。这使得结果在视觉上更加美观。 0 - 禁用,1 - 启用,'auto' - 如果是终端则启用。 ## output_format_pretty_grid_charset {#output_format_pretty_grid_charset} -打印网格边框的字符集。可用字符集:ASCII、UTF-8(默认)。 + + +打印网格边框的字符集。可用的字符集:ASCII、UTF-8(默认字符集)。 ## output_format_pretty_highlight_digit_groups {#output_format_pretty_highlight_digit_groups} -如果启用且输出为终端,则突出显示每千位数、百万位数等对应的每位数字。 + + +如果启用且输出为终端,则将每个与千位、百万等对应的数字加下划线高亮显示。 ## output_format_pretty_highlight_trailing_spaces {#output_format_pretty_highlight_trailing_spaces} -如果启用且输出为终端,则以灰色突出显示尾随空格,并加亮显示。 + + +如果启用且输出为终端,则使用灰色和下划线高亮显示尾随空格。 ## output_format_pretty_max_column_name_width_cut_to {#output_format_pretty_max_column_name_width_cut_to} -如果列名过长,将其裁剪到该长度。 -如果列名长于 `output_format_pretty_max_column_name_width_cut_to` 加上 `output_format_pretty_max_column_name_width_min_chars_to_cut`,则会被裁剪。 + + +如果列名过长,则将其裁剪至该长度。 +如果列名长度超过 `output_format_pretty_max_column_name_width_cut_to` 加 `output_format_pretty_max_column_name_width_min_chars_to_cut`,则会裁剪该列名。 ## output_format_pretty_max_column_name_width_min_chars_to_cut {#output_format_pretty_max_column_name_width_min_chars_to_cut} -如果列名过长,裁剪的最小字符数。 -如果列名长于 `output_format_pretty_max_column_name_width_cut_to` 加上 `output_format_pretty_max_column_name_width_min_chars_to_cut`,则会被裁剪。 + + +如果列名过长,则裁剪的最小字符数。 +如果列名长度超过 `output_format_pretty_max_column_name_width_cut_to` 加 `output_format_pretty_max_column_name_width_min_chars_to_cut`,则会裁剪该列名。 ## output_format_pretty_max_column_pad_width {#output_format_pretty_max_column_pad_width} -在漂亮格式中对列中所有值进行填充的最大宽度。 + + +在 Pretty 格式中填充列中所有值的最大宽度。 ## output_format_pretty_max_rows {#output_format_pretty_max_rows} -漂亮格式的行限制。 + + +Pretty 格式的行数限制。 ## output_format_pretty_max_value_width {#output_format_pretty_max_value_width} -在漂亮格式中显示的最大值宽度。如果更大则将被裁剪。 -值 0 表示 - 从不裁剪。 + + +在 Pretty 格式中显示的值的最大宽度。如果超出限制,则会裁剪。 +值为 0 表示 - 永不裁剪。 ## output_format_pretty_max_value_width_apply_for_single_value {#output_format_pretty_max_value_width_apply_for_single_value} -仅在块不是单个值时裁剪值(请参见 `output_format_pretty_max_value_width`)。否则将其全部输出,这对于 `SHOW CREATE TABLE` 查询很有用。 + + +仅在块中不是单个值时裁剪值(请参见 `output_format_pretty_max_value_width` 设置)。否则完全输出,这对 `SHOW CREATE TABLE` 查询非常有用。 ## output_format_pretty_multiline_fields {#output_format_pretty_multiline_fields} -如果启用,漂亮格式将在表格单元内呈现多行字段,以保持表格轮廓。 -如果不启用,字段将按原样呈现,可能会扭曲表格(保持关闭的一个优点是复制粘贴多行值会更容易)。 + + +如果启用,Pretty 格式将在表单元格内呈现多行字段,以保留表的轮廓。 +如果未启用,它们将按原样呈现,可能导致表的形状不美观(关闭它的一个好处是更容易复制粘贴多行值)。 ## output_format_pretty_row_numbers {#output_format_pretty_row_numbers} -为漂亮输出格式的每一行添加行号。 + + +为 Pretty 输出格式的每一行添加行号。 ## output_format_pretty_single_large_number_tip_threshold {#output_format_pretty_single_large_number_tip_threshold} -如果块由一个超过该值的单一数字组成(不包括 0),则在表的右侧打印可读的数字提示。 + + +如果块由一个超过该值的单个数字组成(不包括 0),则在表的右侧打印可读的数字提示。 ## output_format_pretty_squash_consecutive_ms {#output_format_pretty_squash_consecutive_ms} -在写入之前等待下一个块的指定毫秒数,并将其压缩到前一个块。这避免了频繁输出过小的块,但仍然允许以流式方式显示数据。 + + +等待下一个块的时间最多为指定的毫秒数,并在写入之前将其压缩到之前的块中。 +这可以避免频繁输出太小的块,但仍允许以流式方式显示数据。 ## output_format_pretty_squash_max_wait_ms {#output_format_pretty_squash_max_wait_ms} -如果上一次输出以来经过的时间超过指定的毫秒数,则在漂亮格式中输出待处理块。 + + +如果自上一次输出以来已超过指定的毫秒数,则以 Pretty 格式输出待处理块。 ## output_format_protobuf_nullables_with_google_wrappers {#output_format_protobuf_nullables_with_google_wrappers} -在使用 Google wrappers 序列化 Nullable 列时,将默认值序列化为空包装。如果关闭,默认值和 null 值将不会被序列化。 +在使用 Google 包装器序列化 Nullable 列时,将默认值序列化为空包装器。如果关闭,则不序列化默认值和空值。 ## output_format_schema {#output_format_schema} -自动生成的模式文件保存路径,格式为 [Cap'n Proto](/interfaces/formats/CapnProto) 或 [Protobuf](/interfaces/formats/Protobuf)。 +生成的架构将保存到 [Cap'n Proto](/interfaces/formats/CapnProto) 或 [Protobuf](/interfaces/formats/Protobuf) 格式的文件路径。 ## output_format_sql_insert_include_column_names {#output_format_sql_insert_include_column_names} - - 在 INSERT 查询中包含列名。 ## output_format_sql_insert_max_batch_size {#output_format_sql_insert_max_batch_size} - - 单个 INSERT 语句中的最大行数。 ## output_format_sql_insert_quote_names {#output_format_sql_insert_quote_names} -用 '`' 字符引号列名。 +用 '`' 字符引用列名。 ## output_format_sql_insert_table_name {#output_format_sql_insert_table_name} -输出的 INSERT 查询中的表名。 +输出 INSERT 查询中的表名。 ## output_format_sql_insert_use_replace {#output_format_sql_insert_use_replace} -使用 REPLACE 语句,而不是 INSERT。 +使用 REPLACE 语句而不是 INSERT。 ## output_format_tsv_crlf_end_of_line {#output_format_tsv_crlf_end_of_line} - - -如果设置为 true,TSV 格式的行结束符将是 \\r\\n,而不是 \\n。 +如果设置为 true,则 TSV 格式的行结束符为 \\r\\n,而不是 \\n。 ## output_format_values_escape_quote_with_quote {#output_format_values_escape_quote_with_quote} 如果为 true,则用 '' 转义 ',否则用 \\' 引号。 ## output_format_write_statistics {#output_format_write_statistics} - - -以合适的输出格式写入关于读取行、字节、时间消耗的统计信息。 +以适当的输出格式写入有关读取行、字节、经过时间的统计信息。 默认启用。 ## precise_float_parsing {#precise_float_parsing} - - -优先使用更精确(但较慢)的浮点解析算法。 +优先使用更精确(但更慢)的浮点解析算法。 ## regexp_dict_allow_hyperscan {#regexp_dict_allow_hyperscan} - - -允许使用 Hyperscan 库的 regexp_tree 字典。 +允许 regexp_tree 字典使用 Hyperscan 库。 ## regexp_dict_flag_case_insensitive {#regexp_dict_flag_case_insensitive} -对 regexp_tree 字典使用不区分大小写的匹配。在单个表达式中可以用 (?i) 和 (?-i) 覆盖。 +对 regexp_tree 字典使用不区分大小写的匹配。可以在单独的表达式中用 (?i) 和 (?-i) 重写。 ## regexp_dict_flag_dotall {#regexp_dict_flag_dotall} -允许 '.' 匹配 regexp_tree 字典中的换行符。 +允许 '.' 匹配换行符,适用于 regexp_tree 字典。 ## rows_before_aggregation {#rows_before_aggregation} -启用后,ClickHouse 将提供 rows_before_aggregation 统计信息的确切值,表示聚合之前读取的行数。 +启用时,ClickHouse 将提供确切的 rows_before_aggregation 统计信息,表示聚合之前读取的行数。 ## schema_inference_hints {#schema_inference_hints} - - -用于没有模式的格式的模式推断提示的列名和类型列表。 +在没有架构的格式中用于提示架构推断的列名和类型列表。 示例: @@ -1365,25 +1761,29 @@ z IPv4 ``` :::note -如果 `schema_inference_hints` 格式不正确,或者有拼写错误或数据类型错误等,整个 schema_inference_hints 将被忽略。 +如果 `schema_inference_hints` 格式不正确,或者有错字或错误的数据类型等,整个 schema_inference_hints 将被忽略。 ::: ## schema_inference_make_columns_nullable {#schema_inference_make_columns_nullable} - + -控制在模式推断中推断出的类型是否为 `Nullable`。 -如果启用,此时所有推断类型将为 `Nullable`;如果禁用,推断类型永远不会是 `Nullable`;如果设置为 `auto`,则只有当列在解析过程中包含 `NULL` 的示例或文件元数据包含列的可为空性的信息时,推断类型才会为 `Nullable`。 +控制在架构推断中将推断类型设置为 `Nullable`。 +可能的值: + * 0 - 推断的类型将永远不会是 `Nullable`(使用 input_format_null_as_default 控制在这种情况下如何处理空值), + * 1 - 所有推断的类型将是 `Nullable`, + * 2 或 `auto` - 仅当列在解析时的样本中包含 `NULL`,或文件元数据包含有关列空值的信息时,推断的类型才会是 `Nullable`, + * 3 - 如果格式具有文件元数据,则推断的类型的空值将匹配文件元数据(例如 Parquet);否则始终为 Nullable(例如 CSV)。 ## schema_inference_make_json_columns_nullable {#schema_inference_make_json_columns_nullable} -控制在模式推断中推断出的 JSON 类型是否为 `Nullable`。 -如果此设置与 schema_inference_make_columns_nullable 一起启用,则推断的 JSON 类型将为 `Nullable`。 +控制在架构推断中将推断的 JSON 类型设置为 `Nullable`。 +如果此设置与 schema_inference_make_columns_nullable 一起启用,推断的 JSON 类型将为 `Nullable`。 ## schema_inference_mode {#schema_inference_mode} -模式推断的模式。'default' - 假设所有文件具有相同的模式,模式可以从任何文件中推断;'union' - 文件可以具有不同的模式,结果模式应该是所有文件模式的并集。 +架构推断的模式。'default' - 假设所有文件具有相同的架构,架构可以从任何文件推断;'union' - 文件可以具有不同的架构,结果架构应是所有文件架构的并集。 ## show_create_query_identifier_quoting_rule {#show_create_query_identifier_quoting_rule} @@ -1398,9 +1798,9 @@ z IPv4 -启用时,在将 JSON 对象解析为 JSON 类型时,会忽略重复的路径,并仅插入第一个,而不是引发异常。 +启用后,在将 JSON 对象解析为 JSON 类型时,将忽略重复路径,仅插入第一个而不是引发异常。 ## validate_experimental_and_suspicious_types_inside_nested_types {#validate_experimental_and_suspicious_types_inside_nested_types} -验证在嵌套类型(如 Array/Map/Tuple)中使用实验性和可疑类型的情况。 +验证在嵌套类型(如 Array/Map/Tuple)内部使用实验性和可疑类型的情况。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/settings-formats.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/settings-formats.md.hash index 12c404c029d..c4e090099f1 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/settings-formats.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/settings-formats.md.hash @@ -1 +1 @@ -bf7da9a0ca44fc04 +12fc93dbd586bf45 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/settings-profiles.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/settings-profiles.md index 28333c2b4aa..fe6c2a1ba7e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/settings-profiles.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/settings-profiles.md @@ -1,23 +1,24 @@ --- -'description': '一组按相同名称分组的设置集合。' +'description': '一组在同一名称下分组的设置。' 'sidebar_label': '设置配置文件' 'sidebar_position': 61 'slug': '/operations/settings/settings-profiles' 'title': '设置配置文件' +'doc_type': 'reference' --- # 设置配置文件 -设置配置文件是以相同名称分组的设置集合。 +设置配置文件是一组按相同名称分组的设置集合。 :::note -ClickHouse 还支持 [SQL驱动的工作流](/operations/access-rights#access-control-usage) 来管理设置配置文件。我们推荐使用它。 +ClickHouse 还支持 [基于 SQL 的工作流](/operations/access-rights#access-control-usage) 来管理设置配置文件。我们建议使用它。 ::: -该配置文件可以拥有任意名称。您可以为不同用户指定相同的配置文件。在设置配置文件中最重要的内容是 `readonly=1`,这确保了只读访问。 +配置文件可以有任何名称。您可以为不同的用户指定相同的配置文件。您在设置配置文件中最重要的内容是 `readonly=1`,这确保了只读访问。 -设置配置文件可以相互继承。要使用继承,请在配置文件中列出的其他设置之前指明一个或多个 `profile` 设置。当一个设置在不同的配置文件中被定义时,将使用最后定义的设置。 +设置配置文件可以相互继承。要使用继承,请在配置文件中列出的其他设置之前指明一个或多个 `profile` 设置。如果在不同的配置文件中定义了一个设置,则使用最后定义的设置。 要应用配置文件中的所有设置,请设置 `profile` 设置。 @@ -79,6 +80,6 @@ SET profile = 'web' 该示例指定了两个配置文件:`default` 和 `web`。 -`default` 配置文件具有特殊用途:它必须始终存在,并在服务器启动时应用。换句话说,`default` 配置文件包含默认设置。 +`default` 配置文件有一个特殊目的:它必须始终存在,并在启动服务器时应用。换句话说,`default` 配置文件包含默认设置。 -`web` 配置文件是一个普通配置文件,可以通过 `SET` 查询或在 HTTP 查询中使用 URL 参数来设置。 +`web` 配置文件是一个常规配置文件,可以通过 `SET` 查询或通过 HTTP 查询中的 URL 参数进行设置。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/settings-profiles.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/settings-profiles.md.hash index e4d93481d24..38a933bdf85 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/settings-profiles.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/settings-profiles.md.hash @@ -1 +1 @@ -8ca4fc405b26d73d +51f80e027d6f5f1c diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/settings-query-level.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/settings-query-level.md index 72428353726..1ffa3c4f064 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/settings-query-level.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/settings-query-level.md @@ -3,37 +3,37 @@ 'sidebar_label': '查询级会话设置' 'slug': '/operations/settings/query-level' 'title': '查询级会话设置' +'doc_type': 'reference' --- ## 概述 {#overview} -有多种方法可以使用特定设置来运行语句。设置是分层配置的,每个后续层会重新定义先前的设置值。 +有多种方法可以使用特定设置运行语句。设置分层配置,每个后续层重新定义之前的设置值。 ## 优先级顺序 {#order-of-priority} -定义设置的优先级顺序如下: +定义设置的优先级顺序为: -1. 将设置直接应用于用户,或在设置配置文件中 +1. 直接将设置应用于用户或在设置配置文件中 - SQL(推荐) - 将一个或多个 XML 或 YAML 文件添加到 `/etc/clickhouse-server/users.d` 2. 会话设置 - - 从 ClickHouse Cloud SQL 控制台或在交互模式下使用 `clickhouse client` 发送 `SET setting=value`。同样,您可以在 HTTP 协议中使用 ClickHouse 会话。为此,您需要指定 `session_id` HTTP 参数。 + - 从 ClickHouse Cloud SQL 控制台或 `clickhouse client` 的交互模式发送 `SET setting=value`。同样,可以在 HTTP 协议中使用 ClickHouse 会话。为此,需要指定 `session_id` HTTP 参数。 3. 查询设置 - - 在非交互模式下启动 `clickhouse client` 时,设置启动参数 `--setting=value`。 + - 在非交互模式下启动 `clickhouse client`,设置启动参数 `--setting=value`。 - 使用 HTTP API 时,传递 CGI 参数(`URL?setting_1=value&setting_2=value...`)。 - 在 SELECT 查询的 [SETTINGS](../../sql-reference/statements/select/index.md#settings-in-select-query) - 子句中定义设置。设置值仅适用于该查询,查询执行后恢复为默认值或先前值。 + 子句中定义设置。设置值仅应用于该查询,并在查询执行后重置为默认或之前的值。 +## 将设置转换为默认值 {#converting-a-setting-to-its-default-value} -## 将设置恢复为默认值 {#converting-a-setting-to-its-default-value} - -如果您更改了设置并希望将其恢复为默认值,请将值设置为 `DEFAULT`。语法如下: +如果更改设置并希望将其恢复为默认值,请将值设置为 `DEFAULT`。语法如下: ```sql SET setting_name = DEFAULT @@ -73,7 +73,7 @@ SELECT value FROM system.settings where name='async_insert'; ## 自定义设置 {#custom_settings} -除了常见的 [settings](/operations/settings/settings.md) 之外,用户可以定义自定义设置。 +除了常见的 [settings](/operations/settings/settings.md) 外,用户可以定义自定义设置。 自定义设置名称必须以预定义前缀之一开头。这些前缀的列表必须在服务器配置文件中的 [custom_settings_prefixes](../../operations/server-configuration-parameters/settings.md#custom_settings_prefixes) 参数中声明。 @@ -95,11 +95,11 @@ SELECT getSetting('custom_a'); ## 示例 {#examples} -这些示例均将 `async_insert` 设置的值设置为 `1`,并展示如何检查运行中的系统中的设置。 +这些示例都将 `async_insert` 设置的值设置为 `1`,并显示如何检查正在运行的系统中的设置。 ### 使用 SQL 直接将设置应用于用户 {#using-sql-to-apply-a-setting-to-a-user-directly} -这将创建用户 `ingester`,并设置 `async_inset = 1`: +这会创建用户 `ingester`,并将设置 `async_insert = 1`: ```sql CREATE USER ingester @@ -125,14 +125,14 @@ SHOW ACCESS ``` ### 使用 SQL 创建设置配置文件并分配给用户 {#using-sql-to-create-a-settings-profile-and-assign-to-a-user} -这将创建配置文件 `log_ingest`,并设置 `async_inset = 1`: +这会创建配置文件 `log_ingest`,并将设置 `async_insert = 1`: ```sql CREATE SETTINGS PROFILE log_ingest SETTINGS async_insert = 1 ``` -这将创建用户 `ingester`,并将设置配置文件 `log_ingest` 分配给该用户: +这会创建用户 `ingester` 并将该用户分配至设置配置文件 `log_ingest`: ```sql CREATE USER ingester @@ -141,7 +141,6 @@ IDENTIFIED WITH sha256_hash BY '7e099f39b84ea79559b3e85ea046804e63725fd1f46b37f2 SETTINGS PROFILE log_ingest ``` - ### 使用 XML 创建设置配置文件和用户 {#using-xml-to-create-a-settings-profile-and-user} ```xml title=/etc/clickhouse-server/users.d/users.xml @@ -195,7 +194,7 @@ SHOW ACCESS └────────────────────────────────────────────────────────────────────────────────────┘ ``` -### 将设置分配给会话 {#assign-a-setting-to-a-session} +### 为会话分配设置 {#assign-a-setting-to-a-session} ```sql SET async_insert =1; @@ -220,4 +219,4 @@ VALUES (...) ## 另请参见 {#see-also} - 查看 [Settings](/operations/settings/settings.md) 页面以获取 ClickHouse 设置的描述。 -- [Global server settings](/operations/server-configuration-parameters/settings.md) +- [全局服务器设置](/operations/server-configuration-parameters/settings.md) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/settings-query-level.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/settings-query-level.md.hash index bd1762727dc..6e5015f2a9c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/settings-query-level.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/settings-query-level.md.hash @@ -1 +1 @@ -60d9ee252c56939f +d58709a1b10811cc diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/settings-users.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/settings-users.md index 5e91a325607..f474fe14d10 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/settings-users.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/settings-users.md @@ -1,18 +1,19 @@ --- -'description': '配置用户和角色的设置。' +'description': '用于配置用户和角色的设置。' 'sidebar_label': '用户设置' 'sidebar_position': 63 'slug': '/operations/settings/settings-users' 'title': '用户和角色设置' +'doc_type': 'reference' --- -# 用户与角色设置 +# 用户和角色设置 -`users` 部分位于 `users.xml` 配置文件中,包含用户设置。 +`users.xml` 配置文件的 `users` 部分包含用户设置。 :::note -ClickHouse 还支持 [SQL 驱动工作流](/operations/access-rights#access-control-usage) 来管理用户。我们建议使用它。 +ClickHouse 还支持 [基于 SQL 的工作流](/operations/access-rights#access-control-usage) 来管理用户。我们推荐使用它。 ::: `users` 部分的结构: @@ -69,48 +70,48 @@ ClickHouse 还支持 [SQL 驱动工作流](/operations/access-rights#access-cont 密码可以以明文或 SHA256(十六进制格式)指定。 -- 要以明文指派密码(**不推荐**),请将其放入 `password` 元素中。 +- 要以明文分配密码(**不推荐**),请将其放在 `password` 元素中。 例如,`qwerty`。密码可以留空。
-- 要使用其 SHA256 哈希指派密码,请将其放入 `password_sha256_hex` 元素中。 +- 要使用其 SHA256 哈希分配密码,请将其放在 `password_sha256_hex` 元素中。 例如,`65e84be33532fb784c48129675f9eff3a682b27168c0ea744b2cf58ee02337c5`。 - 从 shell 生成密码的示例: + 从 Shell 生成密码的示例: ```bash PASSWORD=$(base64 < /dev/urandom | head -c8); echo "$PASSWORD"; echo -n "$PASSWORD" | sha256sum | tr -d '-' ``` - 结果的第一行是密码,第二行是相应的 SHA256 哈希。 + 结果的第一行是密码。第二行是相应的 SHA256 哈希。 -- 为了与 MySQL 客户端兼容,密码可以以双 SHA1 哈希指定。将其放入 `password_double_sha1_hex` 元素中。 +- 为了与 MySQL 客户端兼容,密码可以指定为双 SHA1 哈希。将其放在 `password_double_sha1_hex` 元素中。 例如,`08b4a0f1de6ad37da17359e592c8d74788a83eb0`。 - 从 shell 生成密码的示例: + 从 Shell 生成密码的示例: ```bash PASSWORD=$(base64 < /dev/urandom | head -c8); echo "$PASSWORD"; echo -n "$PASSWORD" | sha1sum | tr -d '-' | xxd -r -p | sha1sum | tr -d '-' ``` - 结果的第一行是密码,第二行是相应的双 SHA1 哈希。 + 结果的第一行是密码。第二行是相应的双 SHA1 哈希。 ### username/ssh-key {#user-sshkey} 此设置允许使用 SSH 密钥进行身份验证。 -给定一把 SSH 密钥(由 `ssh-keygen` 生成),例如 +给定生成的 SSH 密钥(通过 `ssh-keygen` 生成)如下: ```text ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDNf0r6vRl24Ix3tv2IgPmNPO2ATa2krvt80DdcTatLj john@example.com ``` -`ssh_key` 元素的期望格式是 +`ssh_key` 元素应为 ```xml ssh-ed25519 @@ -118,11 +119,11 @@ ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDNf0r6vRl24Ix3tv2IgPmNPO2ATa2krvt80DdcTatLj ``` -将 `ssh-ed25519` 替换为 `ssh-rsa` 或 `ecdsa-sha2-nistp256` 以支持其他算法。 +将 `ssh-ed25519` 替换为 `ssh-rsa` 或 `ecdsa-sha2-nistp256`,以使用其他支持的算法。 ### access_management {#access_management-user-setting} -此设置启用或禁用对用户使用 SQL 驱动的 [访问控制和帐户管理](/operations/access-rights#access-control-usage)。 +此设置启用或禁用用户的 SQL 驱动的 [访问控制和帐户管理](/operations/access-rights#access-control-usage)。 可能的值: @@ -133,8 +134,8 @@ ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDNf0r6vRl24Ix3tv2IgPmNPO2ATa2krvt80DdcTatLj ### grants {#grants-user-setting} -此设置允许授予某个用户任何权限。 -列表中的每个元素应为不指定任何受让人的 `GRANT` 查询。 +此设置允许授予所选用户任何权限。 +列表中的每个元素应为没有指定任何受赠人的 `GRANT` 查询。 示例: @@ -148,11 +149,11 @@ ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDNf0r6vRl24Ix3tv2IgPmNPO2ATa2krvt80DdcTatLj ``` -此设置无法与 `dictionaries`、`access_management`、`named_collection_control`、`show_named_collections_secrets` 和 `allow_databases` 设置同时指定。 +此设置不能与 `dictionaries`、`access_management`、`named_collection_control`、`show_named_collections_secrets` 和 `allow_databases` 设置同时指定。 ### user_name/networks {#user-namenetworks} -允许连接到 ClickHouse 服务器的用户的网络列表。 +用户可以从中连接到 ClickHouse 服务器的网络列表。 列表中的每个元素可以具有以下形式之一: @@ -164,15 +165,15 @@ ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDNf0r6vRl24Ix3tv2IgPmNPO2ATa2krvt80DdcTatLj 示例:`example01.host.ru`。 - 为了检查访问,执行 DNS 查询,并将所有返回的 IP 地址与对等地址进行比较。 + 为检查访问,将执行 DNS 查询,所有返回的 IP 地址将与对等地址进行比较。 - `` — 主机名的正则表达式。 示例:`^example\d\d-\d\d-\d\.host\.ru$` - 为了检查访问,将对等地址执行 [DNS PTR 查询](https://en.wikipedia.org/wiki/Reverse_DNS_lookup),然后应用指定的正则表达式。接下来,会对 PTR 查询的结果执行另一个 DNS 查询,将所有接收到的地址与对等地址进行比较。我们强烈建议正则表达式以 $ 结尾。 + 为检查访问,将对对等地址执行 [DNS PTR 查询](https://en.wikipedia.org/wiki/Reverse_DNS_lookup),然后应用指定的正则表达式。接着,会对 PTR 查询的结果执行另一个 DNS 查询,所有接收到的地址将与对等地址进行比较。我们强烈建议正则表达式以 $ 结尾。 -所有 DNS 请求的结果在服务器重启之前会被缓存。 +所有 DNS 请求的结果会缓存,直到服务器重启。 **示例** @@ -183,7 +184,7 @@ ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDNf0r6vRl24Ix3tv2IgPmNPO2ATa2krvt80DdcTatLj ``` :::note -除非您拥有正确配置的防火墙,否则从任何网络开放访问是不安全的,或者服务器没有直接连接到互联网。 +从任何网络开放访问是不安全的,除非您正确配置了防火墙或服务器不直接连接到互联网。 ::: 要仅允许来自本地主机的访问,请指定: @@ -199,17 +200,18 @@ ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDNf0r6vRl24Ix3tv2IgPmNPO2ATa2krvt80DdcTatLj ### user_name/quota {#user-namequota} -配额允许您在一段时间内跟踪或限制资源使用。配额在 `users.xml` 配置文件的 `quotas` 部分中配置。 +配额允许您跟踪或限制一段时间内的资源使用情况。配额在 `users.xml` 配置文件的 `quotas` +部分中配置。 -您可以为用户分配一组配额。有关配额配置的详细描述,请参见 [配额](/operations/quotas)。 +您可以为用户分配一组配额。有关配额配置的详细说明,请参见 [配额](/operations/quotas)。 ### user_name/databases {#user-namedatabases} -在此部分中,您可以限制 ClickHouse 为当前用户的 `SELECT` 查询返回的行,从而实现基本的行级安全性。 +在此部分中,您可以限制 ClickHouse 返回给当前用户的 `SELECT` 查询的行,从而实现基本的行级安全。 **示例** -以下配置强制用户 `user1` 只能看到 `table1` 中 `id` 字段值为 1000 的行,作为 `SELECT` 查询结果。 +以下配置强制用户 `user1` 只能在 `SELECT` 查询中看到 `table1` 的 `id` 字段值为 1000 的行。 ```xml @@ -223,7 +225,7 @@ ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDNf0r6vRl24Ix3tv2IgPmNPO2ATa2krvt80DdcTatLj ``` -`filter` 可以是任何结果为 [UInt8](../../sql-reference/data-types/int-uint.md) 类型值的表达式。它通常包含比较和逻辑运算符。对于此用户,`database_name.table1` 中 `filter` 结果为 0 的行不返回。过滤与 `PREWHERE` 操作不兼容,并禁用 `WHERE→PREWHERE` 优化。 +`filter` 可以是任何结果为 [UInt8](../../sql-reference/data-types/int-uint.md) 型值的表达式。它通常包含比较和逻辑运算符。对于此用户,来自 `database_name.table1` 的 `filter` 结果为 0 的行将不返回。过滤与 `PREWHERE` 操作不兼容,并禁用 `WHERE→PREWHERE` 优化。 ## 角色 {#roles} @@ -243,7 +245,7 @@ ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDNf0r6vRl24Ix3tv2IgPmNPO2ATa2krvt80DdcTatLj ``` -这些角色也可以授予 `users` 部分中的用户: +这些角色也可以授予 `users` 部分的用户: ```xml diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/settings-users.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/settings-users.md.hash index d75699facd4..8cd6ce0db7d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/settings-users.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/settings-users.md.hash @@ -1 +1 @@ -d4911a62e4ab46e5 +b1104c354dd15e09 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/settings.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/settings.md index 24a57c82353..4633be427d3 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/settings.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/settings.md @@ -3,7 +3,8 @@ 'sidebar_label': '会话设置' 'slug': '/operations/settings/settings' 'toc_max_heading_level': 2 -'description': '在``system.settings`` 表中找到的设置。' +'description': '在 ``system.settings`` 表中找到的设置。' +'doc_type': 'reference' --- import ExperimentalBadge from '@theme/badges/ExperimentalBadge'; @@ -13,18 +14,18 @@ import SettingsInfoBlock from '@theme/SettingsInfoBlock/SettingsInfoBlock'; import VersionHistory from '@theme/VersionHistory/VersionHistory'; -所有以下设置在表 [system.settings](/docs/operations/system-tables/settings) 中也可用。这些设置是从 [source](https://github.com/ClickHouse/ClickHouse/blob/master/src/Core/Settings.cpp) 自动生成的。 +以下所有设置也可在表 [system.settings](/docs/operations/system-tables/settings) 中找到。这些设置是自动生成的,来自 [source](https://github.com/ClickHouse/ClickHouse/blob/master/src/Core/Settings.cpp)。 ## add_http_cors_header {#add_http_cors_header} -写入添加 http CORS 头。 +写入添加 HTTP CORS 头。 ## additional_result_filter {#additional_result_filter} -一个额外的过滤器表达式,应用于 `SELECT` 查询的结果。 -该设置不适用于任何子查询。 +应用于 `SELECT` 查询结果的附加过滤表达式。 +此设置不应用于任何子查询。 **示例** @@ -58,7 +59,7 @@ SETTINGS additional_result_filter = 'x != 2' -一个额外的过滤器表达式,在从指定表读取后应用。 +在从指定表读取后应用的附加过滤表达式。 **示例** @@ -92,10 +93,10 @@ SETTINGS additional_table_filters = {'table_1': 'x != 2'} -启用或禁用在查询中重写所有聚合函数,并为其添加 [-OrNull](/sql-reference/aggregate-functions/combinators#-ornull) 后缀。为兼容 SQL 标准启用它。 -它通过查询重写实现(类似于 [count_distinct_implementation](#count_distinct_implementation) 设置),以获取分布式查询的一致结果。 +启用或禁用在查询中重写所有聚合函数,为它们添加 [-OrNull](/sql-reference/aggregate-functions/combinators#-ornull) 后缀。为了兼容 SQL 标准,请启用此选项。 +它是通过查询重写实现的(类似于 [count_distinct_implementation](#count_distinct_implementation) 设置),以便为分布式查询获取一致的结果。 -可能的值: +可能值: - 0 — 禁用。 - 1 — 启用。 @@ -107,7 +108,7 @@ SETTINGS additional_table_filters = {'table_1': 'x != 2'} SELECT SUM(-1), MAX(0) FROM system.one WHERE 0; ``` -在 `aggregate_functions_null_for_empty = 0` 时,它将产生: +在 `aggregate_functions_null_for_empty = 0` 时,它会产生: ```text ┌─SUM(-1)─┬─MAX(0)─┐ │ 0 │ 0 │ @@ -126,21 +127,21 @@ SELECT SUM(-1), MAX(0) FROM system.one WHERE 0; -在主键顺序聚合期间累积的块的最大字节数。较小的块大小允许并行化聚合的最终合并阶段。 +按照主键顺序聚合时块的最大字节大小。较小的块大小可以在聚合的最终合并阶段实现更大的并行性。 ## aggregation_memory_efficient_merge_threads {#aggregation_memory_efficient_merge_threads} -用于合并中间聚合结果的线程数量,以内存高效模式运行。当更大时,消耗的内存更多。0 表示 - 与 'max_threads' 相同。 +用于以内存高效模式合并中间聚合结果的线程数量。更大时,消耗更多内存。0 表示 - 同 'max_threads'。 ## allow_aggregate_partitions_independently {#allow_aggregate_partitions_independently} -当分区键适合分组依据键时,启用在单独线程上独立聚合分区。当分区数量接近核心数量且分区大小大致相同的情况下,这种做法是有益的。 +当分区键适合分组键时,启用在单独线程上独立聚合分区。当分区数量接近核心数量且分区大小大致相等时,这是有益的。 ## allow_archive_path_syntax {#allow_archive_path_syntax} @@ -151,50 +152,50 @@ SELECT SUM(-1), MAX(0) FROM system.one WHERE 0; -文件/S3 引擎/表函数将解析路径为 '::' 作为 ` :: `,如果存档具有正确的扩展名。 +文件/S3 引擎/表函数将解析路径为 '::' 作为 ` :: `,前提是归档具有正确的扩展名。 ## allow_asynchronous_read_from_io_pool_for_merge_tree {#allow_asynchronous_read_from_io_pool_for_merge_tree} -使用后台 I/O 池从 MergeTree 表中读取。此设置可能会提高 I/O 密集查询的性能。 +使用后台 I/O 池从 MergeTree 表中读取。此设置可以提高 I/O 绑定查询的性能。 ## allow_changing_replica_until_first_data_packet {#allow_changing_replica_until_first_data_packet} -如果启用,在竞态请求中,我们可以在接收到第一个数据包之前开始新的连接,即使我们已经取得了一些进展 -(但进展未更新至 `receive_data_timeout` 超时),否则我们将在第一次取得进展后禁用更改副本。 +如果启用,在加速请求中,我们可以在接收第一个数据包之前建立新的连接,即使我们已经取得了一些进展 +(但进展没有更新到 `receive_data_timeout` 超时),否则在第一次取得进展后我们禁用更改副本。 ## allow_create_index_without_type {#allow_create_index_without_type} -允许没有类型的 CREATE INDEX 查询。查询将被忽略。为适应 SQL 兼容性测试而设置。 +允许没有 TYPE 的 CREATE INDEX 查询。查询将被忽略。用于 SQL 兼容性测试。 ## allow_custom_error_code_in_throwif {#allow_custom_error_code_in_throwif} -启用在函数 throwIf() 中使用自定义错误代码。如果为 true,抛出的异常可能具有意外的错误代码。 +在函数 throwIf() 中启用自定义错误代码。如果为真,抛出的异常可能具有意外的错误代码。 ## allow_ddl {#allow_ddl} -如果设置为 true,用户将被允许执行 DDL 查询。 +如果设置为 true,则用户可以执行 DDL 查询。 ## allow_deprecated_database_ordinary {#allow_deprecated_database_ordinary} -允许创建具有已弃用的普通引擎的数据库。 +允许创建具有已废弃普通引擎的数据库。 ## allow_deprecated_error_prone_window_functions {#allow_deprecated_error_prone_window_functions} @@ -205,7 +206,7 @@ SELECT SUM(-1), MAX(0) FROM system.one WHERE 0; -允许使用已弃用的高错误概率窗口函数(neighbor, runningAccumulate, runningDifferenceStartingWithFirstValue, runningDifference)。 +允许使用已废弃的易出错窗口函数(邻近、runningAccumulate、runningDifferenceStartingWithFirstValue、runningDifference)。 ## allow_deprecated_snowflake_conversion_functions {#allow_deprecated_snowflake_conversion_functions} @@ -216,24 +217,24 @@ SELECT SUM(-1), MAX(0) FROM system.one WHERE 0; -函数 `snowflakeToDateTime`, `snowflakeToDateTime64`, `dateTimeToSnowflake` 和 `dateTime64ToSnowflake` 已弃用,默认为禁用。 -请使用函数 `snowflakeIDToDateTime`, `snowflakeIDToDateTime64`, `dateTimeToSnowflakeID` 和 `dateTime64ToSnowflakeID`。 +函数 `snowflakeToDateTime`、`snowflakeToDateTime64`、`dateTimeToSnowflake` 和 `dateTime64ToSnowflake` 已被废弃并默认禁用。 +请改用函数 `snowflakeIDToDateTime`、`snowflakeIDToDateTime64`、`dateTimeToSnowflakeID` 和 `dateTime64ToSnowflakeID`。 -要重新启用已弃用的函数(例如,在过渡期间),请将此设置设置为 `true`。 +要重新启用已废弃的函数(例如,在过渡期间),请将此设置设置为 `true`。 ## allow_deprecated_syntax_for_merge_tree {#allow_deprecated_syntax_for_merge_tree} -允许使用已弃用的引擎定义语法创建 *MergeTree 表。 +允许使用已废弃引擎定义语法创建 *MergeTree 表。 ## allow_distributed_ddl {#allow_distributed_ddl} -如果设置为 true,用户将被允许执行分布式 DDL 查询。 +如果设置为 true,则用户可以执行分布式 DDL 查询。 ## allow_drop_detached {#allow_drop_detached} @@ -241,13 +242,24 @@ SELECT SUM(-1), MAX(0) FROM system.one WHERE 0; 允许执行 ALTER TABLE ... DROP DETACHED PART[ITION] ... 查询。 +## allow_dynamic_type_in_join_keys {#allow_dynamic_type_in_join_keys} + + + + + + + + + +允许在 JOIN 键中使用动态类型。添加兼容性。由于与其他类型的比较可能导致意外结果,不推荐在 JOIN 键中使用动态类型。 ## allow_execute_multiif_columnar {#allow_execute_multiif_columnar} -允许执行 multiIf 函数的列式操作。 +允许以列式模式执行 multiIf 函数。 ## allow_experimental_analyzer {#allow_experimental_analyzer} @@ -258,7 +270,7 @@ SELECT SUM(-1), MAX(0) FROM system.one WHERE 0; -允许新的查询分析器。 +允许新查询分析器。 ## allow_experimental_codecs {#allow_experimental_codecs} @@ -267,23 +279,23 @@ SELECT SUM(-1), MAX(0) FROM system.one WHERE 0; -如果设置为 true,允许指定实验性压缩编解码器(但我们还没有这些,且此选项没有任何作用)。 +如果设置为 true,允许指定实验性压缩编解码器(但我们还没有这些,且此选项无效)。 ## allow_experimental_correlated_subqueries {#allow_experimental_correlated_subqueries} - + - + - + 允许执行相关子查询。 ## allow_experimental_database_glue_catalog {#allow_experimental_database_glue_catalog} - + @@ -309,7 +321,7 @@ SELECT SUM(-1), MAX(0) FROM system.one WHERE 0; 允许实验性数据库引擎 DataLakeCatalog,catalog_type = 'hms'。 ## allow_experimental_database_iceberg {#allow_experimental_database_iceberg} - + @@ -328,10 +340,10 @@ SELECT SUM(-1), MAX(0) FROM system.one WHERE 0; -允许创建数据库 Engine=MaterializedPostgreSQL(...)。 +允许创建数据库,使用 Engine=MaterializedPostgreSQL(...)。 ## allow_experimental_database_unity_catalog {#allow_experimental_database_unity_catalog} - + @@ -354,18 +366,20 @@ SELECT SUM(-1), MAX(0) FROM system.one WHERE 0; -允许实验性的 delta-kernel-rs 实现。 -## allow_experimental_dynamic_type {#allow_experimental_dynamic_type} +允许实验性 delta-kernel-rs 实现。 +## allow_experimental_delta_lake_writes {#allow_experimental_delta_lake_writes} + - + + - + -允许创建 [Dynamic](../../sql-reference/data-types/dynamic.md) 数据类型。 +启用 delta-kernel 写入功能。 ## allow_experimental_full_text_index {#allow_experimental_full_text_index} @@ -376,9 +390,9 @@ SELECT SUM(-1), MAX(0) FROM system.one WHERE 0; - + -如果设置为 true,允许使用实验性全文索引。 +如果设置为 true,允许使用实验性文本索引。 ## allow_experimental_funnel_functions {#allow_experimental_funnel_functions} @@ -397,7 +411,7 @@ SELECT SUM(-1), MAX(0) FROM system.one WHERE 0; 启用实验性哈希函数。 -## allow_experimental_inverted_index {#allow_experimental_inverted_index} +## allow_experimental_iceberg_compaction {#allow_experimental_iceberg_compaction} @@ -405,8 +419,12 @@ SELECT SUM(-1), MAX(0) FROM system.one WHERE 0; -如果设置为 true,允许使用实验性倒排索引。 -## allow_experimental_join_condition {#allow_experimental_join_condition} + + + + +允许明确使用 'OPTIMIZE' 对于 iceberg 表。 +## allow_experimental_insert_into_iceberg {#allow_experimental_insert_into_iceberg} @@ -416,9 +434,9 @@ SELECT SUM(-1), MAX(0) FROM system.one WHERE 0; - + -支持对同时涉及左右表列的非等条件的连接,例如 `t1.y < t2.y`。 +允许对 iceberg 执行 `insert` 查询。 ## allow_experimental_join_right_table_sorting {#allow_experimental_join_right_table_sorting} @@ -431,18 +449,7 @@ SELECT SUM(-1), MAX(0) FROM system.one WHERE 0; -如果设置为 true,并且满足 `join_to_sort_minimum_perkey_rows` 和 `join_to_sort_maximum_table_rows` 的条件,通过键重新排列右表,以提高左表或内连接的性能。 -## allow_experimental_json_type {#allow_experimental_json_type} - - - - - - - - - -允许创建 [JSON](../../sql-reference/data-types/newjson.md) 数据类型。 +如果设置为 true,并且满足 `join_to_sort_minimum_perkey_rows` 和 `join_to_sort_maximum_table_rows` 的条件,那么按键对右边表重新排序以提高左连接或内连接的性能。 ## allow_experimental_kafka_offsets_storage_in_keeper {#allow_experimental_kafka_offsets_storage_in_keeper} @@ -455,7 +462,7 @@ SELECT SUM(-1), MAX(0) FROM system.one WHERE 0; -允许实验性功能在 ClickHouse Keeper 中存储 Kafka 相关的偏移量。当启用时,可以将 ClickHouse Keeper 路径和副本名称指定给 Kafka 表引擎。结果是使用一种新型存储引擎来代替常规 Kafka 引擎,主要在 ClickHouse Keeper 中存储已提交的偏移量。 +允许实验性功能将与 Kafka 相关的偏移存储在 ClickHouse Keeper 中。当启用时,可以将 ClickHouse Keeper 路径和副本名称指定给 Kafka 表引擎。因此,不使用常规的 Kafka 引擎,而是使用一种新类型的存储引擎,主要在 ClickHouse Keeper 中存储已提交的偏移量。 ## allow_experimental_kusto_dialect {#allow_experimental_kusto_dialect} @@ -468,20 +475,7 @@ SELECT SUM(-1), MAX(0) FROM system.one WHERE 0; -启用 Kusto 查询语言(KQL) - SQL 的一种替代品。 -## allow_experimental_lightweight_update {#allow_experimental_lightweight_update} - - - - - - - - - - - -允许使用轻量级更新。 +启用 Kusto 查询语言 (KQL) - SQL 的替代品。 ## allow_experimental_live_view {#allow_experimental_live_view} @@ -490,12 +484,12 @@ SELECT SUM(-1), MAX(0) FROM system.one WHERE 0; -允许创建已弃用的实时视图。 +允许创建已废弃的 LIVE VIEW。 可能的值: -- 0 — 禁用实时视图。 -- 1 — 启用实时视图。 +- 0 — 禁用对实时视图的工作。 +- 1 — 启用对实时视图的工作。 ## allow_experimental_materialized_postgresql_table {#allow_experimental_materialized_postgresql_table} @@ -513,7 +507,7 @@ SELECT SUM(-1), MAX(0) FROM system.one WHERE 0; -启用自然语言处理的实验性函数。 +启用实验性自然语言处理函数。 ## allow_experimental_object_type {#allow_experimental_object_type} @@ -522,7 +516,7 @@ SELECT SUM(-1), MAX(0) FROM system.one WHERE 0; -允许过时的对象数据类型。 +允许使用过时的对象数据类型。 ## allow_experimental_parallel_reading_from_replicas {#allow_experimental_parallel_reading_from_replicas} @@ -531,7 +525,7 @@ SELECT SUM(-1), MAX(0) FROM system.one WHERE 0; -使用每个分片的 `max_parallel_replicas` 数量的副本进行 SELECT 查询执行。读取是并行的并动态协调。0 - 禁用,1 - 启用,遇到故障时静默禁用,2 - 启用,遇到故障时抛出异常。 +允许从每个分片中使用最多 `max_parallel_replicas` 个副本执行 SELECT 查询。读取是并行化和动态协调的。0 - 禁用,1 - 启用,在失败时无声禁用,2 - 启用,在失败时抛出异常。 ## allow_experimental_prql_dialect {#allow_experimental_prql_dialect} @@ -544,7 +538,20 @@ SELECT SUM(-1), MAX(0) FROM system.one WHERE 0; -启用 PRQL - SQL 的一种替代品。 +启用 PRQL - SQL 的替代品。 +## allow_experimental_qbit_type {#allow_experimental_qbit_type} + + + + + + + + + + + +允许创建 [QBit](../../sql-reference/data-types/qbit.md) 数据类型。 ## allow_experimental_query_deduplication {#allow_experimental_query_deduplication} @@ -553,7 +560,7 @@ SELECT SUM(-1), MAX(0) FROM system.one WHERE 0; -基于部分 UUID 的 SELECT 查询的实验性数据去重。 +实验性数据去重,用于基于部分 UUID 的 SELECT 查询。 ## allow_experimental_statistics {#allow_experimental_statistics} @@ -566,7 +573,20 @@ SELECT SUM(-1), MAX(0) FROM system.one WHERE 0; -允许使用 [statistics](../../engines/table-engines/mergetree-family/mergetree.md/#table_engine-mergetree-creating-a-table) 来优化查询,并 [操纵统计信息](../../engines/table-engines/mergetree-family/mergetree.md/#column-statistics)。 +允许定义具有 [统计信息](../../engines/table-engines/mergetree-family/mergetree.md/#table_engine-mergetree-creating-a-table) 的列,并且能够 [操作统计信息](../../engines/table-engines/mergetree-family/mergetree.md/#column-statistics)。 +## allow_experimental_time_series_aggregate_functions {#allow_experimental_time_series_aggregate_functions} + + + + + + + + + + + +实验性 timeSeries* 聚合函数,用于 Prometheus 类似的时间序列重采样、速率和差异计算。 ## allow_experimental_time_series_table {#allow_experimental_time_series_table} @@ -579,10 +599,10 @@ SELECT SUM(-1), MAX(0) FROM system.one WHERE 0; -允许创建使用 [TimeSeries](../../engines/table-engines/integrations/time-series.md) 表引擎的表。可能值: -- 0 — 禁用 [TimeSeries](../../engines/table-engines/integrations/time-series.md) 表引擎。 -- 1 — 启用 [TimeSeries](../../engines/table-engines/integrations/time-series.md) 表引擎。 -## allow_experimental_ts_to_grid_aggregate_function {#allow_experimental_ts_to_grid_aggregate_function} +允许创建具有 [TimeSeries](../../engines/table-engines/integrations/time-series.md) 表引擎的表。可能的值: +- 0 — [TimeSeries](../../engines/table-engines/integrations/time-series.md) 表引擎被禁用。 +- 1 — [TimeSeries](../../engines/table-engines/integrations/time-series.md) 表引擎被启用。 +## allow_experimental_time_time64_type {#allow_experimental_time_time64_type} @@ -592,21 +612,32 @@ SELECT SUM(-1), MAX(0) FROM system.one WHERE 0; - + + +允许创建 [Time](../../sql-reference/data-types/time.md) 和 [Time64](../../sql-reference/data-types/time64.md) 数据类型。 +## allow_experimental_window_view {#allow_experimental_window_view} + + -实验性 tsToGrid 聚合函数,用于类 Prometheus 的时间序列重采样。云专用。 -## allow_experimental_variant_type {#allow_experimental_variant_type} + - +启用窗口视图。尚不成熟。 +## allow_experimental_ytsaurus_dictionary_source {#allow_experimental_ytsaurus_dictionary_source} + + + + + + - + -允许创建 [Variant](../../sql-reference/data-types/variant.md) 数据类型。 -## allow_experimental_vector_similarity_index {#allow_experimental_vector_similarity_index} +实验性字典来源,用于与 YTsaurus 集成。 +## allow_experimental_ytsaurus_table_engine {#allow_experimental_ytsaurus_table_engine} @@ -616,10 +647,10 @@ SELECT SUM(-1), MAX(0) FROM system.one WHERE 0; - + -允许实验性向量相似度索引。 -## allow_experimental_window_view {#allow_experimental_window_view} +实验性表引擎,用于与 YTsaurus 集成。 +## allow_experimental_ytsaurus_table_function {#allow_experimental_ytsaurus_table_function} @@ -627,7 +658,11 @@ SELECT SUM(-1), MAX(0) FROM system.one WHERE 0; -启用窗口视图。还不够成熟。 + + + + +实验性表引擎,用于与 YTsaurus 集成。 ## allow_general_join_planning {#allow_general_join_planning} @@ -638,7 +673,7 @@ SELECT SUM(-1), MAX(0) FROM system.one WHERE 0; -允许更一般的连接规划算法,可以处理更复杂的条件,但仅适用于哈希连接。如果哈希连接未启用,则使用常规连接规划算法,而不考虑此设置的值。 +允许使用更通用的连接规划算法,可以处理更复杂的条件,但仅适用于哈希连接。如果未启用哈希连接,则将使用传统的连接规划算法,而不考虑此设置的值。 ## allow_get_client_http_header {#allow_get_client_http_header} @@ -649,26 +684,26 @@ SELECT SUM(-1), MAX(0) FROM system.one WHERE 0; -允许使用函数 `getClientHTTPHeader`,它允许获取当前 HTTP 请求头的值。出于安全原因,此功能默认未启用,因为某些头,例如 `Cookie`,可能包含敏感信息。请注意,`X-ClickHouse-*` 和 `Authentication` 头始终受到限制,不能通过此功能获取。 +允许使用 `getClientHTTPHeader` 函数来获取当前 HTTP 请求标题的值。出于安全原因,默认未启用此功能,因为某些标题(例如 `Cookie`)可能包含敏感信息。请注意,`X-ClickHouse-*` 和 `Authentication` 标头始终受到限制,无法通过此函数获取。 ## allow_hyperscan {#allow_hyperscan} -允许使用使用 Hyperscan 库的函数。禁用以避免潜在的长编译时间和过度资源使用。 +允许使用 Hyperscan 库的函数。禁用以避免可能较长的编译时间和过多的资源占用。 ## allow_introspection_functions {#allow_introspection_functions} -启用或禁用查询分析的 [自省函数](../../sql-reference/functions/introspection.md)。 +启用或禁用用于查询剖析的 [内省函数](../../sql-reference/functions/introspection.md)。 -可能的值: +可能值: -- 1 — 启用自省函数。 -- 0 — 禁用自省函数。 +- 1 — 启用内省函数。 +- 0 — 禁用内省函数。 **另见** @@ -684,21 +719,21 @@ SELECT SUM(-1), MAX(0) FROM system.one WHERE 0; -允许 CREATE MATERIALIZED VIEW 使用引用不存在的表或列的 SELECT 查询。它仍然必须在语法上有效。不适用于可刷新的物化视图。如果 MV 模式需要从 SELECT 查询推断(即,如果 CREATE 没有列列表且没有 TO 表),则不适用。可用于在其源表之前创建 MV。 +允许使用引用不存在表或列的 SELECT 查询创建物化视图(MATERIALIZED VIEW)。它仍然必须在语法上有效。该选项不适用于可刷新的 MV。如果 MV 架构需要从 SELECT 查询推断(即 CREATE 缺少列列表且没有 TO 表),则不会使用。可以在其源表之前创建 MV。 ## allow_named_collection_override_by_default {#allow_named_collection_override_by_default} -允许默认覆盖命名集合的字段。 +允许默认命名集合字段的重写。 ## allow_non_metadata_alters {#allow_non_metadata_alters} -允许执行不仅影响表元数据的更改,还影响磁盘上的数据。 +允许执行影响的不仅仅是表元数据的调整,而是还影响磁盘上的数据。 ## allow_nonconst_timezone_arguments {#allow_nonconst_timezone_arguments} @@ -709,16 +744,19 @@ SELECT SUM(-1), MAX(0) FROM system.one WHERE 0; -允许在某些时间相关函数中使用非常量时区参数,例如 toTimeZone(),fromUnixTimestamp*(),snowflakeToDateTime*()。 +允许某些时间相关函数(如 toTimeZone()、fromUnixTimestamp*()、snowflakeToDateTime*())中的非常量时区参数。 +此设置仅存在于兼容性原因。在 ClickHouse 中,时区是数据类型的属性,因此是列的属性。 +启用此设置容易给人错觉,认为列中的不同值可以具有不同的时区。 +因此,请勿启用此设置。 ## allow_nondeterministic_mutations {#allow_nondeterministic_mutations} -用户级设置,允许在复制表上使用非确定性函数进行变更,例如 `dictGet`。 +用户级设置,允许复制表上的变更使用非确定性函数如 `dictGet`。 -考虑到,例如,字典可能在节点之间不同步,因此,默认情况下,不允许在复制表上执行从中提取值的变更。启用此设置允许这种行为,用户有责任确保使用的数据在所有节点间同步。 +考虑到例如字典可以在节点之间不同步,默认情况下不允许从中提取值的变更在复制表上进行。启用此设置允许这种行为,由用户负责确保所使用的数据在所有节点之间保持同步。 **示例** @@ -740,9 +778,9 @@ SELECT SUM(-1), MAX(0) FROM system.one WHERE 0; -允许在分片键中使用非确定性函数(如 `rand` 或 `dictGet`,因为后者在更新时有一些注意事项)。 +允许在分片键中使用非确定性函数(如 `rand` 或 `dictGet`,因为后者在更新上有一些陷阱)。 -可能的值: +可能值: - 0 — 不允许。 - 1 — 允许。 @@ -756,7 +794,7 @@ SELECT SUM(-1), MAX(0) FROM system.one WHERE 0; -允许或限制在比较函数 `equal/less/greater/etc` 中使用不可比较类型(如 JSON/对象/聚合函数)。 +允许或限制在比较函数 `equal/less/greater/etc` 中使用不可比较的类型(如 JSON/对象/聚合函数)。 ## allow_not_comparable_types_in_order_by {#allow_not_comparable_types_in_order_by} @@ -767,21 +805,21 @@ SELECT SUM(-1), MAX(0) FROM system.one WHERE 0; -允许或限制在 ORDER BY 键中使用不可比较类型(如 JSON/对象/聚合函数)。 +允许或限制在 ORDER BY 键中使用不可比较的类型(如 JSON/对象/聚合函数)。 ## allow_prefetched_read_pool_for_local_filesystem {#allow_prefetched_read_pool_for_local_filesystem} -如果所有部分都在本地文件系统上,优先使用预取线程池。 +如果所有部分都位于本地文件系统,则优先考虑预取线程池。 ## allow_prefetched_read_pool_for_remote_filesystem {#allow_prefetched_read_pool_for_remote_filesystem} -如果所有部分都在远程文件系统上,优先使用预取线程池。 +如果所有部分均位于远程文件系统,则优先考虑预取线程池。 ## allow_push_predicate_ast_for_distributed_subqueries {#allow_push_predicate_ast_for_distributed_subqueries} @@ -792,14 +830,14 @@ SELECT SUM(-1), MAX(0) FROM system.one WHERE 0; -允许在启用分析器的情况下在分布式子查询的 AST 级别推送谓词。 +允许在启用分析器的分布式子查询的 AST 级别推出谓词。 ## allow_push_predicate_when_subquery_contains_with {#allow_push_predicate_when_subquery_contains_with} -允许在子查询包含 WITH 子句时推送谓词。 +允许在子查询包含 WITH 子句时推出谓词。 ## allow_reorder_prewhere_conditions {#allow_reorder_prewhere_conditions} @@ -810,7 +848,7 @@ SELECT SUM(-1), MAX(0) FROM system.one WHERE 0; -在从 WHERE 移动条件到 PREWHERE 时,允许重新排序以优化过滤。 +移动 WHERE 的条件到 PREWHERE 时,允许重新排序以优化过滤。 ## allow_settings_after_format_in_insert {#allow_settings_after_format_in_insert} @@ -821,7 +859,7 @@ SELECT SUM(-1), MAX(0) FROM system.one WHERE 0; -控制在 INSERT 查询中是否允许在 `FORMAT` 之后使用 `SETTINGS`。不建议使用此选项,因为这可能会将 `SETTINGS` 的部分内容解释为值。 +控制在 `INSERT` 查询中是否允许在 `FORMAT` 后面使用 `SETTINGS`。不建议使用此选项,因为这可能将部分 `SETTINGS` 解释为值。 示例: @@ -829,20 +867,20 @@ SELECT SUM(-1), MAX(0) FROM system.one WHERE 0; INSERT INTO FUNCTION null('foo String') SETTINGS max_threads=1 VALUES ('bar'); ``` -但以下查询将仅在 `allow_settings_after_format_in_insert` 为 true 时工作: +但以下查询将仅在 `allow_settings_after_format_in_insert` 为真时有效: ```sql SET allow_settings_after_format_in_insert=1; INSERT INTO FUNCTION null('foo String') VALUES ('bar') SETTINGS max_threads=1; ``` -可能的值: +可能值: -- 0 — 不允许。 +- 0 — 禁止。 - 1 — 允许。 :::note -仅在您的用例依赖于旧语法时,使用此设置以实现向后兼容性。 +仅在如果您的用例依赖于旧语法的情况下使用此设置以保持向后兼容性。 ::: ## allow_simdjson {#allow_simdjson} @@ -850,7 +888,7 @@ INSERT INTO FUNCTION null('foo String') VALUES ('bar') SETTINGS max_threads=1; -如果可用 AVX2 指令,则允许在 'JSON*' 函数中使用 simdjson 库。如果禁用,将使用 rapidjson。 +允许在 'JSON*' 函数中使用 simdjson 库,如果 AVX2 指令可用。禁用后将使用 rapidjson。 ## allow_statistics_optimize {#allow_statistics_optimize} @@ -881,7 +919,7 @@ INSERT INTO FUNCTION null('foo String') VALUES ('bar') SETTINGS max_threads=1; -在 CREATE TABLE 语句中允许创建 FixedString(n) 类型的列,其中 n > 256。长度 >= 256 的 FixedString 是可疑的,并且很可能表明误用。 +在 CREATE TABLE 语句中,允许创建 FixedString(n) 类型的列,其中 n > 256。长度 >= 256 的 FixedString 是可疑的,并且很可能表示误用。 ## allow_suspicious_indices {#allow_suspicious_indices} @@ -892,24 +930,24 @@ INSERT INTO FUNCTION null('foo String') VALUES ('bar') SETTINGS max_threads=1; -拒绝具有相同表达式的主/次索引和排序键。 +拒绝具有相同表达式的主键/辅助索引和排序键。 ## allow_suspicious_low_cardinality_types {#allow_suspicious_low_cardinality_types} -允许或限制与固定大小为 8 字节或更小的数据类型使用 [LowCardinality](../../sql-reference/data-types/lowcardinality.md):数值数据类型和 `FixedString(8_bytes_or_less)`。 +允许或限制使用 [LowCardinality](../../sql-reference/data-types/lowcardinality.md) 与大小固定为 8 字节或更小的数据类型:数值数据类型和 `FixedString(8_bytes_or_less)`。 -对于小的固定值,使用 `LowCardinality` 通常效率较低,因为 ClickHouse 为每一行存储数值索引。结果可能导致: +对于小的固定值,使用 `LowCardinality` 通常效率不高,因为 ClickHouse 为每一行存储一个数值索引。结果: -- 磁盘空间使用增加。 -- RAM 使用增加,具体取决于字典大小。 -- 由于额外的编码/解码操作,某些函数的工作速度可能变慢。 +- 磁盘空间使用可能增加。 +- RAM 消耗可能更高,取决于字典的大小。 +- 某些函数由于额外的编码/解码操作可能会运行得更慢。 -基于所有前述原因,在 [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) 引擎表中的合并时间可能会增长。 +MergeTree 引擎表的合并时间可能因上述所有原因而增加。 -可能的值: +可能值: - 1 — 不限制使用 `LowCardinality`。 - 0 — 限制使用 `LowCardinality`。 @@ -923,7 +961,7 @@ INSERT INTO FUNCTION null('foo String') VALUES ('bar') SETTINGS max_threads=1; -允许可疑的 `PRIMARY KEY`/`ORDER BY` 用于 MergeTree(即 SimpleAggregateFunction)。 +允许可疑的 `PRIMARY KEY`/`ORDER BY` 用于 MergeTree(例如 SimpleAggregateFunction)。 ## allow_suspicious_ttl_expressions {#allow_suspicious_ttl_expressions} @@ -967,14 +1005,14 @@ INSERT INTO FUNCTION null('foo String') VALUES ('bar') SETTINGS max_threads=1; -在 CREATE TABLE 语句中允许指定与相似变体类型(例如具有不同数值或日期类型)的 Variant 类型。启用该设置可能在处理具有相似类型的值时引入一些歧义。 +在 CREATE TABLE 语句中,允许指定具有相似变体类型(例如,不同的数值或日期类型)的 Variant 类型。启用此设置可能在处理相似类型值时引入一些模糊性。 ## allow_unrestricted_reads_from_keeper {#allow_unrestricted_reads_from_keeper} -允许从 system.zookeeper 表中进行不受限(不带条件的路径)读取,这可能很方便,但对 zookeeper 来说并不安全。 +允许无条件地从 system.zookeeper 表中读取,这可能很方便,但对 zookeeper 来说并不安全。 ## alter_move_to_space_execute_async {#alter_move_to_space_execute_async} @@ -988,13 +1026,13 @@ INSERT INTO FUNCTION null('foo String') VALUES ('bar') SETTINGS max_threads=1; -启用或禁用显示已成功应用于分区和部分的操作的信息。 +启用或禁用成功应用于分区和部分的操作的信息显示。 适用于 [ATTACH PARTITION|PART](/sql-reference/statements/alter/partition#attach-partitionpart) 和 [FREEZE PARTITION](/sql-reference/statements/alter/partition#freeze-partition)。 -可能的值: +可能值: -- 0 — 禁用详细输出。 -- 1 — 启用详细输出。 +- 0 — 禁用详细信息。 +- 1 — 启用详细信息。 **示例** @@ -1024,18 +1062,18 @@ ALTER TABLE test FREEZE SETTINGS alter_partition_verbose_result = 1; -允许设置等待通过 [ALTER](../../sql-reference/statements/alter/index.md), [OPTIMIZE](../../sql-reference/statements/optimize.md) 或 [TRUNCATE](../../sql-reference/statements/truncate.md) 查询在副本上执行的操作。 +允许设置在 [ALTER](../../sql-reference/statements/alter/index.md)、[OPTIMIZE](../../sql-reference/statements/optimize.md) 或 [TRUNCATE](../../sql-reference/statements/truncate.md) 查询上在副本上等待执行的操作。 -可能的值: +可能值: -- 0 — 不等待。 -- 1 — 等待自己的执行。 -- 2 — 等待所有人的执行。 +- `0` — 不等待。 +- `1` — 等待自身执行。 +- `2` — 等待所有人。 -云默认值: `0`。 +云默认值:`1`。 :::note -`alter_sync` 仅适用于 `Replicated` 表,对非 `Replicated` 表的更改没有任何作用。 +`alter_sync` 仅适用于 `Replicated` 表,对非 `Replicated` 表的调整无效。 ::: ## alter_update_mode {#alter_update_mode} @@ -1049,7 +1087,7 @@ ALTER TABLE test FREEZE SETTINGS alter_partition_verbose_result = 1; 用于具有 `UPDATE` 命令的 `ALTER` 查询的模式。 -可能的值: +可能值: - `heavy` - 运行常规变更。 - `lightweight` - 如果可能,运行轻量级更新,否则运行常规变更。 - `lightweight_force` - 如果可能,运行轻量级更新,否则抛出异常。 @@ -1059,7 +1097,18 @@ ALTER TABLE test FREEZE SETTINGS alter_partition_verbose_result = 1; -如果一个表的索引中有空间填充曲线,例如 `ORDER BY mortonEncode(x, y)` 或 `ORDER BY hilbertEncode(x, y)`,并且查询对其参数有条件,例如 `x >= 10 AND x <= 20 AND y >= 20 AND y <= 30`,则使用空间填充曲线进行索引分析。 +如果表的索引中具有空间填充曲线,例如 `ORDER BY mortonEncode(x, y)` 或 `ORDER BY hilbertEncode(x, y)`,并且查询对其参数有条件,例如 `x >= 10 AND x <= 20 AND y >= 20 AND y <= 30`,则使用空间填充曲线进行索引分析。 +## analyzer_compatibility_allow_compound_identifiers_in_unflatten_nested {#analyzer_compatibility_allow_compound_identifiers_in_unflatten_nested} + + + + + + + + + +允许将复合标识符添加到嵌套。这是一个兼容性设置,因为它会改变查询结果。当禁用时,`SELECT a.b.c FROM table ARRAY JOIN a` 不起作用,且 `SELECT a FROM table` 不包括 `a.b.c` 列到 `Nested a` 结果中。 ## analyzer_compatibility_join_using_top_level_identifier {#analyzer_compatibility_join_using_top_level_identifier} @@ -1070,7 +1119,7 @@ ALTER TABLE test FREEZE SETTINGS alter_partition_verbose_result = 1; -强制在 JOIN USING 中从投影解析标识符(例如,在 `SELECT a + 1 AS b FROM t1 JOIN t2 USING (b)` 中,将执行通过 `t1.a + 1 = t2.b` 连接,而不是 `t1.b = t2.b`)。 +强制从投影中解析 JOIN USING 中的标识符(例如,在 `SELECT a + 1 AS b FROM t1 JOIN t2 USING (b)` 中,将通过 `t1.a + 1 = t2.b` 进行连接,而不是 `t1.b = t2.b`)。 ## any_join_distinct_right_table_keys {#any_join_distinct_right_table_keys} @@ -1081,26 +1130,26 @@ ALTER TABLE test FREEZE SETTINGS alter_partition_verbose_result = 1; -启用 ClickHouse 服务器在 `ANY INNER|LEFT JOIN` 操作中的遗留行为。 +在 `ANY INNER|LEFT JOIN` 操作中启用传统的 ClickHouse 服务器行为。 :::note -仅在您的用例依赖于遗留 `JOIN` 行为时使用该设置以实现向后兼容性。 +仅在您的用例依赖于旧 `JOIN` 行为的情况下使用此设置以保持向后兼容性。 ::: -启用遗留行为时: +启用传统行为时: -- `t1 ANY LEFT JOIN t2` 和 `t2 ANY RIGHT JOIN t1` 操作的结果不相等,因为 ClickHouse 使用许多对一的左到右表键映射逻辑。 -- `ANY INNER JOIN` 操作的结果包含左表中的所有行,如同 `SEMI LEFT JOIN` 操作的结果。 +- `t1 ANY LEFT JOIN t2` 和 `t2 ANY RIGHT JOIN t1` 操作的结果不相等,因为 ClickHouse 使用许多对一个左到右表键映射的逻辑。 +- `ANY INNER JOIN` 操作的结果包含来自左表的所有行,就像 `SEMI LEFT JOIN` 操作一样。 -禁用遗留行为时: +禁用传统行为时: -- `t1 ANY LEFT JOIN t2` 和 `t2 ANY RIGHT JOIN t1` 操作的结果相等,因为 ClickHouse 使用在 `ANY RIGHT JOIN` 操作中提供一种对多的键映射逻辑。 -- `ANY INNER JOIN` 操作的结果包含来自左表和右表的每个键的一行。 +- `t1 ANY LEFT JOIN t2` 和 `t2 ANY RIGHT JOIN t1` 操作的结果相等,因为 ClickHouse 使用提供多个键映射的逻辑。 +- `ANY INNER JOIN` 操作的结果从左表和右表各包含一行每个键。 -可能的值: +可能值: -- 0 — 禁用遗留行为。 -- 1 — 启用遗留行为。 +- 0 — 禁用传统行为。 +- 1 — 启用传统行为。 另见: @@ -1111,14 +1160,14 @@ ALTER TABLE test FREEZE SETTINGS alter_partition_verbose_result = 1; -启用过滤出通过轻量级 DELETE 删除的行。如果禁用,则查询仍可以读取那些行。这对于调试和“撤消删除”场景很有用。 +启用过滤掉通过轻量级 DELETE 删除的行。如果禁用,查询将能够读取那些行。这对于调试和“取消删除”场景很有用。 ## apply_mutations_on_fly {#apply_mutations_on_fly} -如果为 true,则未在数据部分中物化的变更(UPDATE 和 DELETE)将在 SELECT 时应用。 +如果为真,则在 SELECT 时应用尚未在数据部分中物化的变更(UPDATE 和 DELETE)。 ## apply_patch_parts {#apply_patch_parts} @@ -1129,7 +1178,18 @@ ALTER TABLE test FREEZE SETTINGS alter_partition_verbose_result = 1; -如果为 true,则将在 SELECT 时应用补丁部分(表示轻量级更新)。 +如果为真,则在 SELECT 时应用补丁部分(表示轻量级更新)。 +## apply_patch_parts_join_cache_buckets {#apply_patch_parts_join_cache_buckets} + + + + + + + + + +加入模式中应用补丁部分的临时缓存中的桶数。 ## apply_settings_from_server {#apply_settings_from_server} @@ -1142,20 +1202,20 @@ ALTER TABLE test FREEZE SETTINGS alter_partition_verbose_result = 1; 客户端是否应该接受来自服务器的设置。 -这仅影响在客户端上执行的操作,特别是解析 INSERT 输入数据和格式化查询结果。大多数查询执行在服务器上进行,且不受此设置的影响。 +这仅影响在客户端中执行的操作,特别是解析 INSERT 输入数据和格式化查询结果。大多数查询执行发生在服务器上,并不受此设置的影响。 -通常,此设置应在用户配置文件中设置(users.xml 或 `ALTER USER` 类的查询),而不是通过客户端(客户端命令行参数,`SET` 查询或 `SELECT` 查询的 `SETTINGS` 部分)。通过客户端可以更改为 false,但无法更改为 true(因为如果用户配置文件中设置了 `apply_settings_from_server = false`,则服务器将不会发送设置)。 +通常应该在用户配置文件(users.xml 或 `ALTER USER` 等查询)中设置此设置,而不是通过客户端(客户端命令行参数、`SET` 查询或 `SELECT` 查询的 `SETTINGS` 部分)。通过客户端可以将其更改为 false,但无法更改为 true(因为如果用户配置文件中具有 `apply_settings_from_server = false`,则服务器不会发送设置)。 -请注意,最初(24.12)有一个服务器设置(`send_settings_to_client`),但后来它被此客户端设置替代,目的是为了更好的可用性。 +请注意,最初(24.12)有一个服务器设置(`send_settings_to_client`),但后来被此客户端设置取代,以改善可用性。 ## asterisk_include_alias_columns {#asterisk_include_alias_columns} -在通配符查询(`SELECT *`)时包括 [ALIAS](../../sql-reference/statements/create/table.md/#alias) 列。 +为通配符查询(`SELECT *`)包括 [ALIAS](../../sql-reference/statements/create/table.md/#alias) 列。 -可能的值: +可能值: - 0 - 禁用 - 1 - 启用 @@ -1165,9 +1225,9 @@ ALTER TABLE test FREEZE SETTINGS alter_partition_verbose_result = 1; -在通配符查询(`SELECT *`)时包括 [MATERIALIZED](/sql-reference/statements/create/view#materialized-view) 列。 +为通配符查询 (`SELECT *`) 包括 [MATERIALIZED](/sql-reference/statements/create/view#materialized-view) 列。 -可能的值: +可能值: - 0 - 禁用 - 1 - 启用 @@ -1177,7 +1237,7 @@ ALTER TABLE test FREEZE SETTINGS alter_partition_verbose_result = 1; -如果为 true,INSERT 查询的数据将存储在队列中,稍后在后台刷新到表中。如果 wait_for_async_insert 为 false,INSERT 查询几乎会立即处理,否则客户端将在数据刷新到表中之前等待。 +如果为真,来自 INSERT 查询的数据将存储在队列中,并在后台刷新到表中。如果 wait_for_async_insert 为假,INSERT 查询几乎会立即被处理,否则客户端将等待直到数据被刷新到表中。 ## async_insert_busy_timeout_decrease_rate {#async_insert_busy_timeout_decrease_rate} @@ -1188,7 +1248,7 @@ ALTER TABLE test FREEZE SETTINGS alter_partition_verbose_result = 1; -自适应异步插入超时时间减少的指数增长率。 +自适应异步插入超时降低的指数增长率。 ## async_insert_busy_timeout_increase_rate {#async_insert_busy_timeout_increase_rate} @@ -1199,7 +1259,7 @@ ALTER TABLE test FREEZE SETTINGS alter_partition_verbose_result = 1; -自适应异步插入超时时间增加的指数增长率。 +自适应异步插入超时增加的指数增长率。 ## async_insert_busy_timeout_max_ms {#async_insert_busy_timeout_max_ms} @@ -1210,369 +1270,316 @@ ALTER TABLE test FREEZE SETTINGS alter_partition_verbose_result = 1; -自首次出现数据以来每个查询收集数据的最大等待时间。 -## async_insert_busy_timeout_min_ms {#async_insert_busy_timeout_min_ms} - - +自第一次数据出现以来每个查询的最大等待时间。 +## async_insert_busy_timeout_min_ms {#async_insert_busy_timeout_min_ms} - - -如果通过 async_insert_use_adaptive_busy_timeout 启用自我调整,则自首次出现数据以来每个查询收集数据的最小等待时间。它也作为自适应算法的初始值。 -## async_insert_deduplicate {#async_insert_deduplicate} - +如果通过 async_insert_use_adaptive_busy_timeout 启用自动调整,则在第一个数据出现后,每次查询收集数据之前要等待的最短时间。它也作为自适应算法的初始值。 +## async_insert_deduplicate {#async_insert_deduplicate} 对于在复制表中的异步 INSERT 查询,指定应执行插入块的去重。 -## async_insert_max_data_size {#async_insert_max_data_size} - +## async_insert_max_data_size {#async_insert_max_data_size} +每个查询收集的未经解析的数据的最大字节大小,在插入之前。 - - - -在插入之前,每个查询收集的未解析数据的最大字节大小。 -## async_insert_max_query_number {#async_insert_max_query_number} - - +## async_insert_max_query_number {#async_insert_max_query_number} -在插入之前的最大插入查询数量。 -## async_insert_poll_timeout_ms {#async_insert_poll_timeout_ms} - +在插入之前的最大插入查询数。仅在设置 [`async_insert_deduplicate`](#async_insert_deduplicate) 为 1 时生效。 +## async_insert_poll_timeout_ms {#async_insert_poll_timeout_ms} +从异步插入队列轮询数据的超时。 +## async_insert_use_adaptive_busy_timeout {#async_insert_use_adaptive_busy_timeout} - - -从异步插入队列轮询数据的超时。 -## async_insert_use_adaptive_busy_timeout {#async_insert_use_adaptive_busy_timeout} + +如果设置为 true,则对异步插入使用自适应繁忙超时。 +## async_query_sending_for_remote {#async_query_sending_for_remote} +在执行远程查询时,启用异步连接创建和查询发送。 + +默认启用。 +## async_socket_for_remote {#async_socket_for_remote} - + -如果设置为 true,则使用自适应忙时超时进行异步插入。 -## async_query_sending_for_remote {#async_query_sending_for_remote} +在执行远程查询时,启用从套接字异步读取。 +默认启用。 +## azure_allow_parallel_part_upload {#azure_allow_parallel_part_upload} +使用多个线程进行 Azure 多部分上传。 +## azure_check_objects_after_upload {#azure_check_objects_after_upload} - - -在执行远程查询时启用异步连接创建和查询发送。 + -默认情况下启用。 -## async_socket_for_remote {#async_socket_for_remote} +检查每个上传的对象在 Azure Blob 存储中确保上传成功。 +## azure_connect_timeout_ms {#azure_connect_timeout_ms} + - +Azure 磁盘主机的连接超时。 +## azure_create_new_file_on_insert {#azure_create_new_file_on_insert} +在每次插入 Azure 引擎表时启用或禁用创建新文件。 - +## azure_ignore_file_doesnt_exist {#azure_ignore_file_doesnt_exist} -在执行远程查询时启用从套接字进行异步读取。 + -默认情况下启用。 -## azure_allow_parallel_part_upload {#azure_allow_parallel_part_upload} +在读取某些键时,如果文件不存在则忽略文件的缺失。 - +可能的值: +- 1 — `SELECT` 返回空结果。 +- 0 — `SELECT` 抛出异常。 - +## azure_list_object_keys_size {#azure_list_object_keys_size} -使用多个线程进行 Azure 多部分上传。 -## azure_check_objects_after_upload {#azure_check_objects_after_upload} +批量返回的最大文件数量,由 ListObject 请求返回。 - +## azure_max_blocks_in_multipart_upload {#azure_max_blocks_in_multipart_upload} - + -检查在 Azure Blob 存储中每个已上传对象,以确保上传成功 -## azure_create_new_file_on_insert {#azure_create_new_file_on_insert} +Azure 多部分上传的最大块数。 - +## azure_max_get_burst {#azure_max_get_burst} -启用或禁用在 Azure 引擎表中每次插入时创建新文件 -## azure_ignore_file_doesnt_exist {#azure_ignore_file_doesnt_exist} + - +在触及每秒请求限制之前,可以同时发出的最大请求数。默认(0)等于 `azure_max_get_rps`。 - +## azure_max_get_rps {#azure_max_get_rps} -读取某些键时,如果文件不存在则忽略缺失的文件。 + -可能的值: -- 1 — `SELECT` 返回空结果。 -- 0 — `SELECT` 抛出异常。 -## azure_list_object_keys_size {#azure_list_object_keys_size} +在输出限流之前,Azure GET 请求每秒的限制。零表示无限制。 - +## azure_max_inflight_parts_for_one_file {#azure_max_inflight_parts_for_one_file} -在 ListObject 请求中可以返回的最大文件数 -## azure_max_blocks_in_multipart_upload {#azure_max_blocks_in_multipart_upload} + - +在多部分上传请求中,单个文件的最大并发加载部分数。0 表示无限制。 - +## azure_max_put_burst {#azure_max_put_burst} -Azure 多部分上传中块的最大数量。 -## azure_max_inflight_parts_for_one_file {#azure_max_inflight_parts_for_one_file} + - +在触及每秒请求限制之前,可以同时发出的最大请求数。默认(0)等于 `azure_max_put_rps`。 - +## azure_max_put_rps {#azure_max_put_rps} -多部分上传请求中一个文件可以并发加载的最大部分数量。 0 表示无限制。 -## azure_max_single_part_copy_size {#azure_max_single_part_copy_size} + - +在输出限流之前,Azure PUT 请求每秒的限制。零表示无限制。 - +## azure_max_redirects {#azure_max_redirects} -使用单部分复制到 Azure Blob 存储的对象的最大大小。 -## azure_max_single_part_upload_size {#azure_max_single_part_upload_size} +允许的 Azure 重定向跳数的最大数量。 - +## azure_max_single_part_copy_size {#azure_max_single_part_copy_size} -使用单部分上传到 Azure Blob 存储的对象的最大大小。 -## azure_max_single_read_retries {#azure_max_single_read_retries} +使用单部分复制到 Azure Blob 存储的最大对象大小。 - +## azure_max_single_part_upload_size {#azure_max_single_part_upload_size} -在单个 Azure Blob 存储读取期间的最大重试次数。 -## azure_max_unexpected_write_error_retries {#azure_max_unexpected_write_error_retries} +使用单部分上传到 Azure Blob 存储的最大对象大小。 - +## azure_max_single_read_retries {#azure_max_single_read_retries} - +单个 Azure Blob 存储读取的最大重试次数。 -在 Azure Blob 存储写入期间遇到意外错误时的最大重试次数 -## azure_max_upload_part_size {#azure_max_upload_part_size} +## azure_max_unexpected_write_error_retries {#azure_max_unexpected_write_error_retries} - + - +在 Azure Blob 存储写入期间遇到意外错误时的最大重试次数。 -在 Azure Blob 存储的多部分上传过程中要上传的部分的最大大小。 -## azure_min_upload_part_size {#azure_min_upload_part_size} +## azure_max_upload_part_size {#azure_max_upload_part_size} - +在向 Azure Blob 存储进行多部分上传期间的最大部分大小。 - +## azure_min_upload_part_size {#azure_min_upload_part_size} -在 Azure Blob 存储的多部分上传过程中要上传的部分的最小大小。 -## azure_sdk_max_retries {#azure_sdk_max_retries} +在向 Azure Blob 存储进行多部分上传期间的最小部分大小。 - +## azure_request_timeout_ms {#azure_request_timeout_ms} - +向/从 Azure 发送和接收数据的空闲超时。如果单个 TCP 读取或写入调用阻塞超过此时间,则失败。 -Azure SDK 中的最大重试次数 -## azure_sdk_retry_initial_backoff_ms {#azure_sdk_retry_initial_backoff_ms} +## azure_sdk_max_retries {#azure_sdk_max_retries} - +Azure SDK 中的最大重试次数。 - +## azure_sdk_retry_initial_backoff_ms {#azure_sdk_retry_initial_backoff_ms} -Azure SDK 中重试之间的最小退避时间 -## azure_sdk_retry_max_backoff_ms {#azure_sdk_retry_max_backoff_ms} +Azure SDK 中重试之间的最小退避时间(毫秒)。 - +## azure_sdk_retry_max_backoff_ms {#azure_sdk_retry_max_backoff_ms} - +Azure SDK 中重试之间的最大退避时间(毫秒)。 -Azure SDK 中重试之间的最大退避时间 -## azure_skip_empty_files {#azure_skip_empty_files} +## azure_sdk_use_native_client {#azure_sdk_use_native_client} - +对 Azure SDK 使用 ClickHouse 原生 HTTP 客户端。 - +## azure_skip_empty_files {#azure_skip_empty_files} 启用或禁用在 S3 引擎中跳过空文件。 可能的值: -- 0 — 如果空文件与请求的格式不兼容,`SELECT` 会抛出异常。 -- 1 — 空文件的 `SELECT` 返回空结果。 -## azure_strict_upload_part_size {#azure_strict_upload_part_size} - - - - +- 0 — 如果空文件与请求格式不兼容,`SELECT` 抛出异常。 +- 1 — `SELECT` 返回空结果。 -在 Azure Blob 存储的多部分上传过程中要上传的部分的确切大小。 -## azure_throw_on_zero_files_match {#azure_throw_on_zero_files_match} +## azure_strict_upload_part_size {#azure_strict_upload_part_size} - +在向 Azure Blob 存储进行多部分上传期间上传部分的确切大小。 - +## azure_throw_on_zero_files_match {#azure_throw_on_zero_files_match} -如果根据 glob 扩展规则匹配到的文件数为零,则抛出错误。 +如果根据通配符扩展规则匹配零文件则抛出错误。 可能的值: - 1 — `SELECT` 抛出异常。 - 0 — `SELECT` 返回空结果。 -## azure_truncate_on_insert {#azure_truncate_on_insert} - - -启用或禁用在 Azure 引擎表中插入前截断数据。 -## azure_upload_part_size_multiply_factor {#azure_upload_part_size_multiply_factor} +## azure_truncate_on_insert {#azure_truncate_on_insert} - +启用或禁用在 Azure 引擎表中插入之前进行截断。 - +## azure_upload_part_size_multiply_factor {#azure_upload_part_size_multiply_factor} -上传到 Azure Blob 存储时,每次从单次写入上传 azure_multiply_parts_count_threshold 部分时,将 azure_min_upload_part_size 乘以此因子。 -## azure_upload_part_size_multiply_parts_count_threshold {#azure_upload_part_size_multiply_parts_count_threshold} +每当从单次写入到 Azure Blob 存储上传 azure_multiply_parts_count_threshold 部分时,将 azure_min_upload_part_size 乘以此因子。 - +## azure_upload_part_size_multiply_parts_count_threshold {#azure_upload_part_size_multiply_parts_count_threshold} - +每当此数字的部分上传到 Azure Blob 存储时,azure_min_upload_part_size 会被 azure_upload_part_size_multiply_factor 乘以。 -每次向 Azure Blob 存储上传该数量的部分时,azure_min_upload_part_size 会乘以 azure_upload_part_size_multiply_factor。 -## backup_restore_batch_size_for_keeper_multi {#backup_restore_batch_size_for_keeper_multi} +## azure_use_adaptive_timeouts {#azure_use_adaptive_timeouts} - +当设置为 `true` 时,所有 Azure 请求的前两次尝试在较低的发送和接收超时下进行。设置为 `false` 时,所有尝试均在相同的超时下进行。 -在备份或恢复期间对 [Zoo]Keeper 发出的多请求的最大批量大小 -## backup_restore_batch_size_for_keeper_multiread {#backup_restore_batch_size_for_keeper_multiread} +## backup_restore_batch_size_for_keeper_multi {#backup_restore_batch_size_for_keeper_multi} - +在备份或恢复期间,向 [Zoo]Keeper 发送的多请求的最大批大小。 -在备份或恢复期间对 [Zoo]Keeper 发出的多读取请求的最大批量大小 -## backup_restore_failure_after_host_disconnected_for_seconds {#backup_restore_failure_after_host_disconnected_for_seconds} +## backup_restore_batch_size_for_keeper_multiread {#backup_restore_batch_size_for_keeper_multiread} - +在备份或恢复期间多读请求向 [Zoo]Keeper 发送的最大批大小。 - +## backup_restore_failure_after_host_disconnected_for_seconds {#backup_restore_failure_after_host_disconnected_for_seconds} -如果主机在 BACKUP ON CLUSTER 或 RESTORE ON CLUSTER 操作期间未能在这个时间段内在 ZooKeeper 中重新创建其临时的“存活”节点,则整个备份或恢复将被视为失败。 -该值应大于主机在故障后重新连接到 ZooKeeper 的任何合理时间。 -零表示无限制。 -## backup_restore_finish_timeout_after_error_sec {#backup_restore_finish_timeout_after_error_sec} +如果在 BACKUP ON CLUSTER 或 RESTORE ON CLUSTER 操作期间,主机在此时间段内未能在 ZooKeeper 中重建其短暂的“存活”节点,则整个备份或恢复将被视为失败。此值应大于主机在故障后重新连接到 ZooKeeper 的任何合理时间。零表示无限制。 - +## backup_restore_finish_timeout_after_error_sec {#backup_restore_finish_timeout_after_error_sec} - +发起者应等待多长时间,以便其他主机对“错误”节点做出反应并停止其在当前 BACKUP ON CLUSTER 或 RESTORE ON CLUSTER 操作中的工作。 -发起者在当前 BACKUP ON CLUSTER 或 RESTORE ON CLUSTER 操作中等待其他主机对“错误”节点做出反应并停止其工作的时间。 -## backup_restore_keeper_fault_injection_probability {#backup_restore_keeper_fault_injection_probability} +## backup_restore_keeper_fault_injection_probability {#backup_restore_keeper_fault_injection_probability} - +在备份或恢复期间,对 keeper 请求的故障注入的近似概率。有效值在 [0.0f, 1.0f] 的区间内。 -备份或恢复期间 Keeper 请求的故障注入的近似概率。有效值在区间 [0.0f, 1.0f] 内 -## backup_restore_keeper_fault_injection_seed {#backup_restore_keeper_fault_injection_seed} +## backup_restore_keeper_fault_injection_seed {#backup_restore_keeper_fault_injection_seed} - +0 - 随机种子,其他情况为设置值。 -0 - 随机种子, 否则为设置值 -## backup_restore_keeper_max_retries {#backup_restore_keeper_max_retries} +## backup_restore_keeper_max_retries {#backup_restore_keeper_max_retries} - +在进行 BACKUP 或 RESTORE 操作期间,ZooKeeper 操作的最大重试次数。应足够大,以便整个操作不会因为暂时的 ZooKeeper 故障而失败。 - +## backup_restore_keeper_max_retries_while_handling_error {#backup_restore_keeper_max_retries_while_handling_error} -在备份或恢复操作中 [Zoo]Keeper 操作的最大重试次数。 -应该足够大,以便整个操作不会因临时 [Zoo]Keeper 故障而失败。 -## backup_restore_keeper_max_retries_while_handling_error {#backup_restore_keeper_max_retries_while_handling_error} +在处理 BACKUP ON CLUSTER 或 RESTORE ON CLUSTER 操作错误时,ZooKeeper 操作的最大重试次数。 - +## backup_restore_keeper_max_retries_while_initializing {#backup_restore_keeper_max_retries_while_initializing} - +在初始化 BACKUP ON CLUSTER 或 RESTORE ON CLUSTER 操作期间,ZooKeeper 操作的最大重试次数。 -在处理 BACKUP ON CLUSTER 或 RESTORE ON CLUSTER 操作的错误时 [Zoo]Keeper 操作的最大重试次数。 -## backup_restore_keeper_max_retries_while_initializing {#backup_restore_keeper_max_retries_while_initializing} +## backup_restore_keeper_retry_initial_backoff_ms {#backup_restore_keeper_retry_initial_backoff_ms} - +在备份或恢复期间,ZooKeeper 操作的初始退避超时。 - +## backup_restore_keeper_retry_max_backoff_ms {#backup_restore_keeper_retry_max_backoff_ms} -在初始化 BACKUP ON CLUSTER 或 RESTORE ON CLUSTER 操作期间 [Zoo]Keeper 操作的最大重试次数。 -## backup_restore_keeper_retry_initial_backoff_ms {#backup_restore_keeper_retry_initial_backoff_ms} +在备份或恢复期间,ZooKeeper 操作的最大退避超时。 - +## backup_restore_keeper_value_max_size {#backup_restore_keeper_value_max_size} -备份或恢复期间 [Zoo]Keeper 操作的初始退避超时 -## backup_restore_keeper_retry_max_backoff_ms {#backup_restore_keeper_retry_max_backoff_ms} +在备份期间,ZooKeeper 节点的最大数据大小。 - +## backup_restore_s3_retry_attempts {#backup_restore_s3_retry_attempts} -备份或恢复期间 [Zoo]Keeper 操作的最大退避超时 -## backup_restore_keeper_value_max_size {#backup_restore_keeper_value_max_size} +覆盖 Aws::Client::RetryStrategy 的设置,Aws::Client 自行进行重试,0 意味着没有重试。仅适用于备份/恢复。 - +## backup_restore_s3_retry_initial_backoff_ms {#backup_restore_s3_retry_initial_backoff_ms} -备份期间 [Zoo]Keeper 节点的数据的最大大小 -## backup_restore_s3_retry_attempts {#backup_restore_s3_retry_attempts} +在备份和恢复期间,第一次重试尝试之前的初始退避延迟(毫秒)。每个后续重试将延迟指数增加,直到达到 `backup_restore_s3_retry_max_backoff_ms` 指定的最大值。 - +## backup_restore_s3_retry_jitter_factor {#backup_restore_s3_retry_jitter_factor} - +在备份和恢复操作期间,应用于 Aws::Client::RetryStrategy 的重试退避延迟的抖动因子。计算出的退避延迟乘以一个随机因子,范围在 [1.0, 1.0 + jitter] 之间,最大为 `backup_restore_s3_retry_max_backoff_ms`。必须在 [0.0, 1.0] 的区间内。 -Aws::Client::RetryStrategy 的设置, Aws::Client 会自行进行重试,0 表示不重试。仅在备份/恢复期间生效。 -## cache_warmer_threads {#cache_warmer_threads} +## backup_restore_s3_retry_max_backoff_ms {#backup_restore_s3_retry_max_backoff_ms} - +在备份和恢复操作期间,重试之间的最大延迟(毫秒)。 - +## cache_warmer_threads {#cache_warmer_threads} -仅在 ClickHouse Cloud 中生效。用于在启用 [cache_populated_by_fetch](merge-tree-settings.md/#cache_populated_by_fetch) 的情况下,后台线程的数量,以推测性地将新数据部分下载到文件缓存中。零表示禁用。 -## calculate_text_stack_trace {#calculate_text_stack_trace} + - +仅在 ClickHouse Cloud 中有效。在启用 [cache_populated_by_fetch](merge-tree-settings.md/#cache_populated_by_fetch) 时,后台线程的数量用于投机性下载新数据部分到文件缓存。零表示禁用。 -在查询执行过程中如果出现异常,则计算文本堆栈跟踪。这是默认设置。它需要符号查找,可能会在执行大量错误查询时减慢模糊测试。正常情况下,不应该禁用此选项。 -## cancel_http_readonly_queries_on_client_close {#cancel_http_readonly_queries_on_client_close} +## calculate_text_stack_trace {#calculate_text_stack_trace} - +在查询执行期间发生异常时计算文本堆栈跟踪。这是默认值。它需要符号查找,可能会在执行大量错误查询时减慢模糊测试。在正常情况下,您不应该禁用此选项。 -当客户端关闭连接而不等待响应时,取消 HTTP 只读查询(例如 SELECT)。 +## cancel_http_readonly_queries_on_client_close {#cancel_http_readonly_queries_on_client_close} -云默认值:`1`。 -## cast_ipv4_ipv6_default_on_conversion_error {#cast_ipv4_ipv6_default_on_conversion_error} +在客户端关闭连接而不等待响应时,取消 HTTP 只读查询(例如 SELECT)。 - +云默认值:`0`。 - +## cast_ipv4_ipv6_default_on_conversion_error {#cast_ipv4_ipv6_default_on_conversion_error} -CAST 操作符转换为 IPv4,CAST 操作符转换为 IPV6 类型,toIPv4、toIPv6 函数将在转换错误时返回默认值,而不是抛出异常。 -## cast_keep_nullable {#cast_keep_nullable} +CAST 操作符转向 IPv4、CAST 操作符转向 IPV6 类型,toIPv4、toIPv6 函数将在转换错误时返回默认值,而不是抛出异常。 - +## cast_keep_nullable {#cast_keep_nullable} 启用或禁用在 [CAST](/sql-reference/functions/type-conversion-functions#cast) 操作中保留 `Nullable` 数据类型。 -启用此设置后,`CAST` 函数的参数为 `Nullable` 时,结果也会转换为 `Nullable` 类型。当禁用此设置时,结果始终符合目标类型。 +当设置为启用并且 `CAST` 函数的参数为 `Nullable` 时,结果也转化为 `Nullable` 类型。当设置为禁用时,结果始终具有确切的目标类型。 可能的值: - -- 0 — `CAST` 的结果具有完全指定的目标类型。 -- 1 — 如果参数类型为 `Nullable`,则 `CAST` 结果转换为 `Nullable(DestinationDataType)`。 +- 0 — `CAST` 结果有确切的目标类型。 +- 1 — 如果参数类型为 `Nullable`,则 `CAST` 结果转化为 `Nullable(DestinationDataType)`。 **示例** -以下查询的结果为完全符合目标数据类型: +以下查询结果具有确切的目标数据类型: ```sql SET cast_keep_nullable = 0; @@ -1587,7 +1594,7 @@ SELECT CAST(toNullable(toInt32(0)) AS Int32) as x, toTypeName(x); └───┴───────────────────────────────────────────────────┘ ``` -以下查询在目标数据类型上产生 `Nullable` 修饰: +以下查询结果在目标数据类型上有 `Nullable` 修改: ```sql SET cast_keep_nullable = 1; @@ -1602,178 +1609,182 @@ SELECT CAST(toNullable(toInt32(0)) AS Int32) as x, toTypeName(x); └───┴───────────────────────────────────────────────────┘ ``` -**另请参见** +**另见** - [CAST](/sql-reference/functions/type-conversion-functions#cast) 函数 -## cast_string_to_dynamic_use_inference {#cast_string_to_dynamic_use_inference} - +## cast_string_to_date_time_mode {#cast_string_to_date_time_mode} - + -在字符串到动态转换时使用类型推断 -## cast_string_to_variant_use_inference {#cast_string_to_variant_use_inference} +允许在从字符串转换时选择日期和时间的文本表示解析器。 - +可能的值: +- `'best_effort'` — 启用扩展解析。 - + ClickHouse 可以解析基本的 `YYYY-MM-DD HH:MM:SS` 格式以及所有 [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) 日期和时间格式。例如,`'2018-06-08T01:02:03.000Z'`。 -在字符串到变体转换时使用类型推断。 -## check_query_single_value_result {#check_query_single_value_result} +- `'best_effort_us'` — 类似于 `best_effort`(请查看 [parseDateTimeBestEffortUS](../../sql-reference/functions/type-conversion-functions#parsedatetimebesteffortus) 中的区别)。 - +- `'basic'` — 使用基本解析器。 -定义 [CHECK TABLE](/sql-reference/statements/check-table) 查询的结果细节级别,适用于 `MergeTree` 家族引擎。 + ClickHouse 只能够解析基本的 `YYYY-MM-DD HH:MM:SS` 或 `YYYY-MM-DD` 格式。例如,`2019-08-20 10:18:56` 或 `2019-08-20`。 -可能的值: +另见: +- [DateTime 数据类型。](../../sql-reference/data-types/datetime.md) +- [用于处理日期和时间的函数。](../../sql-reference/functions/date-time-functions.md) -- 0 — 查询显示表的每个独立数据部分的检查状态。 -- 1 — 查询显示总体表检查状态。 -## check_referential_table_dependencies {#check_referential_table_dependencies} +## cast_string_to_dynamic_use_inference {#cast_string_to_dynamic_use_inference} -检查 DDL 查询(例如 DROP TABLE 或 RENAME)是否不会破坏引用依赖关系 -## check_table_dependencies {#check_table_dependencies} +在字符串到动态转换期间使用类型推断。 + +## cast_string_to_variant_use_inference {#cast_string_to_variant_use_inference} -检查 DDL 查询(例如 DROP TABLE 或 RENAME)是否不会破坏依赖关系 -## checksum_on_read {#checksum_on_read} +在字符串到变体转换期间使用类型推断。 - +## check_query_single_value_result {#check_query_single_value_result} -在读取时验证校验和。此设置默认启用,并且在生产环境中应始终启用。请不要期望禁用此设置会有任何好处。此设置仅适用于 MergeTree 家族的表。对于其他表引擎以及通过网络接收数据时,始终会验证校验和。 -## cloud_mode {#cloud_mode} +定义 `MergeTree` 系列引擎的 [CHECK TABLE](/sql-reference/statements/check-table) 查询结果的详细程度。 - +可能的值: +- 0 — 查询显示每个数据部分的检查状态。 +- 1 — 查询显示一般的表检查状态。 -云模式 -## cloud_mode_database_engine {#cloud_mode_database_engine} +## check_referential_table_dependencies {#check_referential_table_dependencies} - +检查 DDL 查询(如 DROP TABLE 或 RENAME)不会破坏引用依赖关系。 - +## check_table_dependencies {#check_table_dependencies} + +检查 DDL 查询(如 DROP TABLE 或 RENAME)不会破坏依赖关系。 + +## checksum_on_read {#checksum_on_read} -云中允许的数据库引擎。1 - 将 DDL 重写为使用 Replicated 数据库,2 - 将 DDL 重写为使用 Shared 数据库 -## cloud_mode_engine {#cloud_mode_engine} +在读取时验证校验和。默认启用,并且在生产中应始终启用。请不要期望禁用此设置会有任何好处。它仅可用于实验和基准测试。该设置仅适用于 MergeTree 系列的表。对于其他表引擎和通过网络接收数据时,始终验证校验和。 + +## cloud_mode {#cloud_mode} + +云模式。 + +## cloud_mode_database_engine {#cloud_mode_database_engine} +云中允许的数据库引擎。 1 - 重写 DDL 使用复制数据库,2 - 重写 DDL 使用共享数据库。 + +## cloud_mode_engine {#cloud_mode_engine} + 云中允许的引擎系列。 -- 0 - 允许所有 -- 1 - 将 DDL 重写为使用 *ReplicatedMergeTree -- 2 - 将 DDL 重写为使用 SharedMergeTree -- 3 - 将 DDL 重写为使用 SharedMergeTree,除非显式传递了远程磁盘 +- 0 - 允许一切。 +- 1 - 重写 DDL 使用 *ReplicatedMergeTree。 +- 2 - 重写 DDL 使用 SharedMergeTree。 +- 3 - 重写 DDL 使用 SharedMergeTree,除非明确传递了指定的远程磁盘。 + +UInt64以最小化公共部分。 -UInt64 以最小化公有部分 -## cluster_for_parallel_replicas {#cluster_for_parallel_replicas} +## cluster_for_parallel_replicas {#cluster_for_parallel_replicas} -当前服务器所在分片的集群 -## collect_hash_table_stats_during_aggregation {#collect_hash_table_stats_during_aggregation} +当前服务器所在分片的集群。 + +## cluster_function_process_archive_on_multiple_nodes {#cluster_function_process_archive_on_multiple_nodes} -启用收集哈希表统计以优化内存分配 -## collect_hash_table_stats_during_joins {#collect_hash_table_stats_during_joins} +如果设置为 `true`,则提高在集群函数中处理档案的性能。若在早期版本中使用带档案的集群函数,则应将其设置为 `false` 以确保兼容性并避免在升级到 25.7+ 时的错误。 + +## collect_hash_table_stats_during_aggregation {#collect_hash_table_stats_during_aggregation} + +启用收集哈希表统计数据以优化内存分配。 + +## collect_hash_table_stats_during_joins {#collect_hash_table_stats_during_joins} - +启用收集哈希表统计数据以优化内存分配。 -启用收集哈希表统计以优化内存分配 -## compatibility {#compatibility} +## compatibility {#compatibility} -`compatibility` 设置使 ClickHouse 使用先前版本的默认设置,先前版本作为设置提供。 +`compatibility` 设置使 ClickHouse 使用之前版本 ClickHouse 的默认设置,之前版本作为设置提供。 -如果设置为非默认值,则遵循这些设置(只有未修改的设置才受 `compatibility` 设置的影响)。 +如果设置为非默认值,则会遵循这些设置(仅未修改的设置会受到 `compatibility` 设置的影响)。 -此设置接受 ClickHouse 版本号作为字符串,例如 `22.3`、`22.8`。空值表示禁用此设置。 +该设置接受字符串格式的 ClickHouse 版本号,如 `22.3`、`22.8`。空值表示禁用此设置。 -默认情况下禁用。 +默认禁用。 -:::note -在 ClickHouse Cloud 中,兼容性设置必须由 ClickHouse Cloud 支持设置。 请 [提交案例](https://clickhouse.cloud/support) 以进行设置。 +:::note +在 ClickHouse Cloud 中,兼容性设置必须由 ClickHouse Cloud 支持设置。请 [开立工单](https://clickhouse.cloud/support) 进行设置。 ::: -## compatibility_ignore_auto_increment_in_create_table {#compatibility_ignore_auto_increment_in_create_table} - +## compatibility_ignore_auto_increment_in_create_table {#compatibility_ignore_auto_increment_in_create_table} -如果为真,则忽略列声明中的 AUTO_INCREMENT 关键字,否则返回错误。它简化了从 MySQL 的迁移。 -## compatibility_ignore_collation_in_create_table {#compatibility_ignore_collation_in_create_table} +如果为 true,则在列声明中忽略 AUTO_INCREMENT 关键字,否则返回错误。它简化了从 MySQL 的迁移。 - +## compatibility_ignore_collation_in_create_table {#compatibility_ignore_collation_in_create_table} -兼容性忽略在创建表时的排序 -## compile_aggregate_expressions {#compile_aggregate_expressions} +在创建表时的兼容性忽略排序规则。 - +## compile_aggregate_expressions {#compile_aggregate_expressions} -启用或禁用聚合函数的 JIT 编译为本机代码。启用此设置可以提高性能。 +启用或禁用将聚合函数 JIT 编译为本地代码。启用此设置可以提高性能。 可能的值: +- 0 — 无需 JIT 编译即可完成聚合。 +- 1 — 使用 JIT 编译完成聚合。 -- 0 — 聚合不使用 JIT 编译。 -- 1 — 聚合使用 JIT 编译。 - -**另请参见** - +**另见** - [min_count_to_compile_aggregate_expression](#min_count_to_compile_aggregate_expression) -## compile_expressions {#compile_expressions} + +## compile_expressions {#compile_expressions} - +将某些标量函数和运算符编译为本地代码。 -将一些标量函数和运算符编译为本机代码。 -## compile_sort_description {#compile_sort_description} +## compile_sort_description {#compile_sort_description} - +将排序描述编译为本地代码。 -编译排序描述为本机代码。 -## connect_timeout {#connect_timeout} +## connect_timeout {#connect_timeout} 如果没有副本,则连接超时。 -## connect_timeout_with_failover_ms {#connect_timeout_with_failover_ms} + +## connect_timeout_with_failover_ms {#connect_timeout_with_failover_ms} - +在集群定义中使用“分片”和“副本”部分时,连接到远程服务器的超时时间(毫秒)。如果连接不成功,将尝试多次连接到不同的副本。 -当在集群定义中使用“shard”和“replica”部分时,连接到远程服务器的超时(以毫秒为单位)的分布式表引擎。 -如果不成功,将尝试连接到多个副本。 -## connect_timeout_with_failover_secure_ms {#connect_timeout_with_failover_secure_ms} +## connect_timeout_with_failover_secure_ms {#connect_timeout_with_failover_secure_ms} - +选择第一个健康副本的连接超时(安全连接)。 -选择第一个健康副本的连接超时(用于安全连接)。 -## connection_pool_max_wait_ms {#connection_pool_max_wait_ms} - - +## connection_pool_max_wait_ms {#connection_pool_max_wait_ms} -连接池满时连接的等待时间(以毫秒为单位)。 +连接池满时等待获取连接的时间(毫秒)。 可能的值: - - 正整数。 - 0 — 无限超时。 -## connections_with_failover_max_tries {#connections_with_failover_max_tries} - +## connections_with_failover_max_tries {#connections_with_failover_max_tries} -分布式表引擎对每个副本的最大连接尝试次数。 -## convert_query_to_cnf {#convert_query_to_cnf} +用于分布式表引擎的每个副本的最大连接尝试次数。 - +## convert_query_to_cnf {#convert_query_to_cnf} -设置为 `true` 时,`SELECT` 查询将转换为合取范式(CNF)。在一些场景中,将查询重写为 CNF 可能会更快执行(请查看 [Github issue](https://github.com/ClickHouse/ClickHouse/issues/11749) 获得解释)。 +当设置为 `true` 时,`SELECT` 查询将转换为合取范式(CNF)。在某些情况下,将查询重写为 CNF 可能执行得更快(可以查看这个 [Github 问题](https://github.com/ClickHouse/ClickHouse/issues/11749) 进行解释)。 -例如,以下 `SELECT` 查询没有被修改(默认行为): +例如,注意以下 `SELECT` 查询未被修改(默认行为): ```sql EXPLAIN SYNTAX @@ -1803,7 +1814,7 @@ SETTINGS convert_query_to_cnf = false; └────────────────────────────────────────────────────────────────┘ ``` -将 `convert_query_to_cnf` 设置为 `true`,看看有什么变化: +让我们将 `convert_query_to_cnf` 设置为 `true` 看看有什么变化: ```sql EXPLAIN SYNTAX @@ -1817,7 +1828,7 @@ WHERE ((x >= 1) AND (x <= 5)) OR ((x >= 10) AND (x <= 15)) SETTINGS convert_query_to_cnf = true; ``` -注意 `WHERE` 子句被重写为 CNF,但结果集保持不变 - 布尔逻辑没有改变: +注意 `WHERE` 子句被重写为 CNF,但结果集保持不变 - 布尔逻辑未改变: ```response ┌─explain───────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ @@ -1833,185 +1844,154 @@ SETTINGS convert_query_to_cnf = true; └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ ``` -可能的值:true, false -## count_distinct_implementation {#count_distinct_implementation} +可能的值:true, false。 - +## correlated_subqueries_substitute_equivalent_expressions {#correlated_subqueries_substitute_equivalent_expressions} -指定应使用哪些 `uniq*` 函数来执行 [COUNT(DISTINCT ...)](/sql-reference/aggregate-functions/reference/count) 构造。 +使用过滤表达式推断等效表达式,并在创建 CROSS JOIN 时替换这些表达式。 -可能的值: +## count_distinct_implementation {#count_distinct_implementation} +指定应使用哪一个 `uniq*` 函数来执行 [COUNT(DISTINCT ...)](/sql-reference/aggregate-functions/reference/count) 结构。 + +可能的值: - [uniq](/sql-reference/aggregate-functions/reference/uniq) - [uniqCombined](/sql-reference/aggregate-functions/reference/uniqcombined) - [uniqCombined64](/sql-reference/aggregate-functions/reference/uniqcombined64) - [uniqHLL12](/sql-reference/aggregate-functions/reference/uniqhll12) - [uniqExact](/sql-reference/aggregate-functions/reference/uniqexact) -## count_distinct_optimization {#count_distinct_optimization} - +## count_distinct_optimization {#count_distinct_optimization} -将计算不同计数重写为分组的子查询 -## create_if_not_exists {#create_if_not_exists} +将计数不同重写为分组的子查询。 - +## count_matches_stop_at_empty_match {#count_matches_stop_at_empty_match} - + -默认启用 `CREATE` 语句的 `IF NOT EXISTS`。如果此设置或 `IF NOT EXISTS` 被指定且提供的表名已存在,则不会抛出异常。 -## create_index_ignore_unique {#create_index_ignore_unique} +一旦 `countMatches` 函数中的模式匹配零长度时停止计数。 - +## create_if_not_exists {#create_if_not_exists} -在创建唯一索引时忽略 UNIQUE 关键字。用于 SQL 兼容性测试。 -## create_replicated_merge_tree_fault_injection_probability {#create_replicated_merge_tree_fault_injection_probability} + - +默认启用 `CREATE` 语句的 `IF NOT EXISTS`。如果此设置或 `IF NOT EXISTS` 被指定且提供名称的表已存在,则不会抛出异常。 -在创建表时,在 ZooKeeper 中创建元数据后进行故障注入的概率 -## create_table_empty_primary_key_by_default {#create_table_empty_primary_key_by_default} +## create_index_ignore_unique {#create_index_ignore_unique} - +在 CREATE UNIQUE INDEX 中忽略 UNIQUE 关键字。用于 SQL 兼容性测试。 -允许在排序 BY 和主键未指定时创建 *MergeTree 表的空主键 -## cross_join_min_bytes_to_compress {#cross_join_min_bytes_to_compress} +## create_replicated_merge_tree_fault_injection_probability {#create_replicated_merge_tree_fault_injection_probability} - +在创建表格时,在 ZooKeeper 中创建元数据之后故障注入的概率。 - +## create_table_empty_primary_key_by_default {#create_table_empty_primary_key_by_default} -CROSS JOIN 中要压缩的块的最小字节大小。零值表示禁用此阈值。只有当两者中的任一个阈值(按行或按字节)达到时,该块才会被压缩。 -## cross_join_min_rows_to_compress {#cross_join_min_rows_to_compress} +允许在未指定 ORDER BY 和 PRIMARY KEY 的情况下创建 *MergeTree 表,并且主键为空。 - +## cross_join_min_bytes_to_compress {#cross_join_min_bytes_to_compress} - +在 CROSS JOIN 中压缩的最小块大小。零值表示禁用此阈值。当达到行或字节中的任何两个阈值时,将压缩此块。 -CROSS JOIN 中压缩块的最小行数。零值表示禁用此阈值。只有当两者中的任一个阈值(按行或按字节)达到时,该块才会被压缩。 -## data_type_default_nullable {#data_type_default_nullable} +## cross_join_min_rows_to_compress {#cross_join_min_rows_to_compress} - +在 CROSS JOIN 中压缩块的最小行数。零值表示禁用此阈值。当达到行或字节中的任何两个阈值时,将压缩此块。 -允许在列定义中没有显式修饰符 [NULL 或 NOT NULL](/sql-reference/statements/create/table#null-or-not-null-modifiers) 的数据类型将被 [Nullable](/sql-reference/data-types/nullable)。 +## data_type_default_nullable {#data_type_default_nullable} -可能的值: +允许没有显式修饰符 [NULL 或 NOT NULL](/sql-reference/statements/create/table#null-or-not-null-modifiers) 的数据类型在列定义中为 [Nullable](/sql-reference/data-types/nullable)。 +可能的值: - 1 — 列定义中的数据类型默认设置为 `Nullable`。 - 0 — 列定义中的数据类型默认设置为非 `Nullable`。 -## database_atomic_wait_for_drop_and_detach_synchronously {#database_atomic_wait_for_drop_and_detach_synchronously} - +## database_atomic_wait_for_drop_and_detach_synchronously {#database_atomic_wait_for_drop_and_detach_synchronously} -对所有 `DROP` 和 `DETACH` 查询添加修饰符 `SYNC`。 +为所有 `DROP` 和 `DETACH` 查询添加修饰符 `SYNC`。 可能的值: - -- 0 — 查询将延迟执行。 +- 0 — 查询将在延迟下执行。 - 1 — 查询将立即执行。 -## database_replicated_allow_explicit_uuid {#database_replicated_allow_explicit_uuid} - +## database_replicated_allow_explicit_uuid {#database_replicated_allow_explicit_uuid} -0 - 不允许为复制数据库中的表显式指定 UUID。1 - 允许。2 - 允许,但忽略指定的 UUID,并生成随机的 UUID。 -## database_replicated_allow_heavy_create {#database_replicated_allow_heavy_create} - - +0 - 不允许在复制数据库的表中显式指定 UUID。1 - 允许。2 - 允许,但忽略指定的 UUID 并生成一个随机的 UUID。 - +## database_replicated_allow_heavy_create {#database_replicated_allow_heavy_create} -允许在复制数据库引擎中执行需长时间运行的 DDL 查询(CREATE AS SELECT 和 POPULATE)。请注意,这可能会长时间阻塞 DDL 队列。 -## database_replicated_allow_only_replicated_engine {#database_replicated_allow_only_replicated_engine} +允许在复制数据库引擎中运行长时间的 DDL 查询(CREATE AS SELECT 和 POPULATE)。请注意,它可能会长时间阻塞 DDL 队列。 - +## database_replicated_allow_only_replicated_engine {#database_replicated_allow_only_replicated_engine} -允许在使用复制引擎的数据库中仅创建 Replicated 表 -## database_replicated_allow_replicated_engine_arguments {#database_replicated_allow_replicated_engine_arguments} +在复制的数据库中仅允许创建 Replicated 表。 - +## database_replicated_allow_replicated_engine_arguments {#database_replicated_allow_replicated_engine_arguments} -0 - 不允许显式指定复制数据库中的 *MergeTree 表的 ZooKeeper 路径和副本名称。1 - 允许。2 - 允许,但忽略指定的路径,使用默认路径。3 - 允许并且不记录警告。 -## database_replicated_always_detach_permanently {#database_replicated_always_detach_permanently} +0 - 不允许在复制数据库中为 *MergeTree 表显式指定 ZooKeeper 路径和副本名称。1 - 允许。2 - 允许,但忽略指定的路径,并使用默认路径。3 - 允许,并且不记录警告。 - +## database_replicated_always_detach_permanently {#database_replicated_always_detach_permanently} -如果数据库引擎为 Replicated,则将 DETACH TABLE 执行为 DETACH TABLE PERMANENTLY。 -## database_replicated_enforce_synchronous_settings {#database_replicated_enforce_synchronous_settings} +如果数据库引擎是 Replicated,则将 DETACH TABLE 执行为 DETACH TABLE PERMANENTLY。 - +## database_replicated_enforce_synchronous_settings {#database_replicated_enforce_synchronous_settings} -强制对某些查询进行同步等待(另请参见 database_atomic_wait_for_drop_and_detach_synchronously、mutations_sync、alter_sync)。不建议启用这些设置。 -## database_replicated_initial_query_timeout_sec {#database_replicated_initial_query_timeout_sec} +强制某些查询(另请参见 database_atomic_wait_for_drop_and_detach_synchronously、mutations_sync、alter_sync)同步等待。建议不要启用这些设置。 - +## database_replicated_initial_query_timeout_sec {#database_replicated_initial_query_timeout_sec} -设置初始 DDL 查询在复制数据库处理之前 DDL 队列条目时应等待的时间(以秒为单位)。 +设置初始 DDL 查询在复制数据库处理之前的 DDL 队列条目时的等待时间(秒)。 可能的值: - - 正整数。 -- 0 — 无限制。 -## decimal_check_overflow {#decimal_check_overflow} +- 0 — 无限期。 - +## decimal_check_overflow {#decimal_check_overflow} -检查十进制算术/比较操作的溢出 -## deduplicate_blocks_in_dependent_materialized_views {#deduplicate_blocks_in_dependent_materialized_views} +检查十进制运算/比较操作的溢出。 - +## deduplicate_blocks_in_dependent_materialized_views {#deduplicate_blocks_in_dependent_materialized_views} -启用或禁用对从 Replicated\* 表接收数据的物化视图的去重检查。 +启用或禁用对接收来自 Replicated\* 表数据的物化视图的去重检查。 可能的值: +0 — 禁用。 +1 — 启用。 - 0 — 禁用。 - 1 — 启用。 +启用时,ClickHouse 会在依赖于 Replicated\* 表的物化视图中执行块的去重。此设置对于确保当由于故障重试插入操作时,物化视图不包含重复数据非常有用。 -用法 - -默认情况下,物化视图不会执行去重,而是在源表中完成。 -如果由于源表的去重而跳过了一块 INSERT,则不会插入到附加的物化视图中。这种行为是为了使高度聚合的数据插入物化视图成为可能,在这种情况下,插入的块在物化视图聚合后是相同的,但来自源表的不同插入。 -同时,这种行为会“打破” INSERT 的幂等性。如果主表中的 INSERT 成功,而物化视图的 INSERT 失败(例如,由于与 ClickHouse Keeper 的通信失败),客户端将收到错误并可以重试操作。但是,物化视图不会接收第二次插入,因为它会被主(源)表中的去重丢弃。设置 `deduplicate_blocks_in_dependent_materialized_views` 允许更改此行为。在重试时,物化视图将接收重复插入,并自行执行去重检查, -忽略源表的检查结果,并插入因第一次故障而丢失的行。 -## default_materialized_view_sql_security {#default_materialized_view_sql_security} - - +**另见** +- [在重试中处理 NULL 的处理](/guides/developer/deduplicating-inserts-on-retries#insert-deduplication-with-materialized-views) - +## default_materialized_view_sql_security {#default_materialized_view_sql_security} -允许在创建物化视图时设置 SQL SECURITY 选项的默认值。[有关 SQL 安全的更多信息](../../sql-reference/statements/create/view.md/#sql_security)。 +允许在创建物化视图时设置 SQL SECURITY 选项的默认值。 [有关 SQL 安全性的更多信息](../../sql-reference/statements/create/view.md/#sql_security)。 默认值为 `DEFINER`。 -## default_max_bytes_in_join {#default_max_bytes_in_join} - +## default_max_bytes_in_join {#default_max_bytes_in_join} -如果需要限制,但未设置 `max_bytes_in_join`,则右侧表的最大大小。 -## default_normal_view_sql_security {#default_normal_view_sql_security} +如果需要限制而未设置 `max_bytes_in_join`,则右侧表的最大大小。 - +## default_normal_view_sql_security {#default_normal_view_sql_security} -允许在创建常规视图时设置默认的 `SQL SECURITY` 选项。[有关 SQL 安全的更多信息](../../sql-reference/statements/create/view.md/#sql_security)。 +允许在创建普通视图时设置默认 `SQL SECURITY` 选项。 [有关 SQL 安全性的更多信息](../../sql-reference/statements/create/view.md/#sql_security)。 默认值为 `INVOKER`。 -## default_table_engine {#default_table_engine} - - - +## default_table_engine {#default_table_engine} 在 `CREATE` 语句中未设置 `ENGINE` 时使用的默认表引擎。 可能的值: +- 代表任何有效表引擎名称的字符串。 -- 一个字符串,表示任何有效的表引擎名称 - -云默认值: `SharedMergeTree`。 +云默认值:`SharedMergeTree`。 **示例** @@ -2031,7 +2011,7 @@ SELECT name, value, changed FROM system.settings WHERE name = 'default_table_eng └──────────────────────┴───────┴─────────┘ ``` -在这个示例中,任何新表如果未指定 `Engine`,将使用 `Log` 表引擎: +在此示例中,任何未指定 `Engine` 的新表将使用 `Log` 表引擎: 查询: @@ -2056,13 +2036,12 @@ SHOW CREATE TABLE my_table; ENGINE = Log └──────────────────────────────────────────────────────────────────────────┘ ``` -## default_temporary_table_engine {#default_temporary_table_engine} - +## default_temporary_table_engine {#default_temporary_table_engine} -与 [default_table_engine](#default_table_engine) 相同,但适用于临时表。 +与 [default_table_engine](#default_table_engine) 相同,但用于临时表。 -在这个示例中,任何新的临时表如果未指定 `Engine`,将使用 `Log` 表引擎: +在此示例中,任何未指定 `Engine` 的新临时表将使用 `Log` 表引擎: 查询: @@ -2091,75 +2070,176 @@ ENGINE = Log ``` ## default_view_definer {#default_view_definer} + + + + -允许在创建视图时设置默认的 `DEFINER` 选项。[有关 SQL 安全的更多信息](../../sql-reference/statements/create/view.md/#sql_security)。 +允许在创建视图时设置默认的 `DEFINER` 选项。 [关于 SQL 安全性更多信息](../../sql-reference/statements/create/view.md/#sql_security)。 默认值为 `CURRENT_USER`。 +## delta_lake_enable_engine_predicate {#delta_lake_enable_engine_predicate} + + + + + + + + + +启用 delta-kernel 内部数据修剪。 +## delta_lake_enable_expression_visitor_logging {#delta_lake_enable_expression_visitor_logging} + + + + + + + + + +启用 DeltaLake 表达式访问者的测试级别日志。这些日志可能会过于冗长,即使对于测试日志也是如此。 +## delta_lake_insert_max_bytes_in_data_file {#delta_lake_insert_max_bytes_in_data_file} + + + + + + + + + +定义 delta lake 中单个插入数据文件的字节限制。 +## delta_lake_insert_max_rows_in_data_file {#delta_lake_insert_max_rows_in_data_file} + + + + + + + + + +定义 delta lake 中单个插入数据文件的行限制。 +## delta_lake_log_metadata {#delta_lake_log_metadata} + + + + + + + + + +启用将 delta lake 元数据文件记录到系统表中。 +## delta_lake_snapshot_version {#delta_lake_snapshot_version} + + + + + + + + + +要读取的 delta lake 快照版本。值 -1 表示读取最新版本(值 0 是有效的快照版本)。 +## delta_lake_throw_on_engine_predicate_error {#delta_lake_throw_on_engine_predicate_error} + + + + + + + + + +如果在 delta-kernel 中分析扫描谓词时发生错误,则启用抛出异常。 ## describe_compact_output {#describe_compact_output} + + -如果为真,则仅在 DESCRIBE 查询的结果中包含列名和类型 +如果为 true,则只包括列名和类型到 DESCRIBE 查询的结果中。 ## describe_extend_object_types {#describe_extend_object_types} + + -在 DESCRIBE 查询中推断类型为对象的列的具体类型 +推断 DESCRIBE 查询中 Object 类型列的具体类型。 ## describe_include_subcolumns {#describe_include_subcolumns} + + -启用描述 [DESCRIBE](../../sql-reference/statements/describe-table.md) 查询的子列。例如, [Tuple](../../sql-reference/data-types/tuple.md) 的成员或 [Map](/sql-reference/data-types/map#reading-subcolumns-of-map)、 [Nullable](../../sql-reference/data-types/nullable.md/#finding-null) 或 [Array](../../sql-reference/data-types/array.md/#array-size) 数据类型的子列。 +启用在 [DESCRIBE](../../sql-reference/statements/describe-table.md) 查询中描述子列。例如,元组中的成员或字典、Nullable 或数组数据类型的子列。 可能的值: -- 0 — 子列未包含在 `DESCRIBE` 查询中。 -- 1 — 子列包含在 `DESCRIBE` 查询中。 +- 0 — 不包括子列在 `DESCRIBE` 查询中。 +- 1 — 包括子列在 `DESCRIBE` 查询中。 **示例** -请参见 [DESCRIBE](../../sql-reference/statements/describe-table.md) 语句的示例。 +查看 [DESCRIBE](../../sql-reference/statements/describe-table.md) 语句的示例。 ## describe_include_virtual_columns {#describe_include_virtual_columns} + + -如果为真,则表中的虚拟列将包含在 DESCRIBE 查询的结果中 +如果为 true,表的虚拟列将包括在 DESCRIBE 查询的结果中。 ## dialect {#dialect} + + -将使用哪个方言来解析查询 +将用于解析查询的方言。 ## dictionary_validate_primary_key_type {#dictionary_validate_primary_key_type} + + + + -验证字典的主键类型。默认情况下,简单布局的 ID 类型将被隐式转换为 UInt64。 +验证字典的主键类型。对于简单布局,默认 id 类型将隐式转换为 UInt64。 ## distinct_overflow_mode {#distinct_overflow_mode} + + -设置数据量超过其中一个限制时发生的情况。 +设置当数据量超过其中一个限制时发生的事情。 可能的值: -- `throw`: 抛出一个异常(默认)。 -- `break`: 停止执行查询并返回部分结果,就像源数据耗尽一样。 +- `throw`:抛出异常(默认)。 +- `break`:停止执行查询并返回部分结果,就像源数据用尽了一样。 ## distributed_aggregation_memory_efficient {#distributed_aggregation_memory_efficient} + + 是否启用分布式聚合的节省内存模式。 ## distributed_background_insert_batch {#distributed_background_insert_batch} + + -启用/禁用批量发送插入数据。 +启用/禁用插入数据以批量发送。 -启用批量发送时, [Distributed](../../engines/table-engines/special/distributed.md) 表引擎尝试将多份插入数据作为一次操作发送,而不是分别发送。批量发送通过更好地利用服务器和网络资源来提高集群性能。 +当启用批量发送时,[Distributed](../../engines/table-engines/special/distributed.md) 表引擎尝试在一次操作中发送多个插入数据的文件,而不是单独发送。批量发送通过更好地利用服务器和网络资源提高集群性能。 可能的值: @@ -2167,31 +2247,37 @@ ENGINE = Log - 0 — 禁用。 ## distributed_background_insert_max_sleep_time_ms {#distributed_background_insert_max_sleep_time_ms} + + -[Distributed](../../engines/table-engines/special/distributed.md) 表引擎发送数据的最大时间间隔。限制 [distributed_background_insert_sleep_time_ms](#distributed_background_insert_sleep_time_ms) 设置中所设立的时间的指数增长。 +[Distributed](../../engines/table-engines/special/distributed.md) 表引擎发送数据的最大间隔。限制 [distributed_background_insert_sleep_time_ms](#distributed_background_insert_sleep_time_ms) 设置中设定的间隔的指数增长。 可能的值: -- 一个正整数(以毫秒为单位)。 +- 正整数毫秒数。 ## distributed_background_insert_sleep_time_ms {#distributed_background_insert_sleep_time_ms} + + -[Distributed](../../engines/table-engines/special/distributed.md) 表引擎发送数据的基础时间间隔。在发生错误时,实际的间隔成倍增长。 +[Distributed](../../engines/table-engines/special/distributed.md) 表引擎发送数据的基数间隔。实际的间隔在发生错误时会指数增长。 可能的值: -- 一个正整数(以毫秒为单位)。 +- 正整数毫秒数。 ## distributed_background_insert_split_batch_on_failure {#distributed_background_insert_split_batch_on_failure} + + -启用/禁用在故障时分割批次。 +启用/禁用在失败时拆分批次。 -有时将特定批次发送到远程分片可能会失败,因为在之后的某些复杂管道(即带有 `GROUP BY` 的 `MATERIALIZED VIEW`)中出现 “内存限制 exceeded” 或类似错误。在这种情况下,重试将没有帮助(这将造成分布式发送被阻塞),但逐个发送该批次中的文件可能会成功 INSERT。 +有时将特定批次发送到远程分片可能会失败,因为在其后的某些复杂管道(例如带有 `GROUP BY` 的 `MATERIALIZED VIEW`)中可能由于 `Memory limit exceeded` 等类似错误而导致。在这种情况下,重试将无济于事(这将阻止分布式发送),但逐个发送该批次中的文件可能会成功进行 INSERT。 -因此,将此设置安装为 `1` 将禁用对此类批次的分批(即临时禁用失败批次的 `distributed_background_insert_batch`)。 +因此,将该设置安装为 `1` 将禁用这些批次的批量处理(即临时禁用失败批次的 `distributed_background_insert_batch`)。 可能的值: @@ -2199,86 +2285,172 @@ ENGINE = Log - 0 — 禁用。 :::note -此设置还会影响损坏的批次(这可能是由于服务器(机器)的异常终止以及 [Distributed](../../engines/table-engines/special/distributed.md) 表引擎没有执行 `fsync_after_insert`/`fsync_directories`)。 +此设置也会影响由于服务器异常终止(机器)而导致的损坏批次(并且对于 [Distributed](../../engines/table-engines/special/distributed.md) 表引擎没有 `fsync_after_insert`/`fsync_directories`)。 ::: :::note -您不应依赖于自动批次分割,因为这可能会影响性能。 +您不应依赖自动批量拆分,因为这可能会损害性能。 ::: ## distributed_background_insert_timeout {#distributed_background_insert_timeout} + + + + +分布式插入查询的超时。该设置仅在启用 insert_distributed_sync 时使用。零值表示没有超时。 +## distributed_cache_alignment {#distributed_cache_alignment} + + + + + -插入查询到分布式的超时。仅在启用 insert_distributed_sync 时使用。零值表示没有超时。 + + + + +仅在 ClickHouse Cloud 中有效。用于测试目的的设置,请勿更改。 ## distributed_cache_bypass_connection_pool {#distributed_cache_bypass_connection_pool} + + + + -仅在 ClickHouse Cloud 中生效。允许绕过分布式缓存连接池 +仅在 ClickHouse Cloud 中有效。允许绕过分布式缓存连接池。 +## distributed_cache_connect_backoff_max_ms {#distributed_cache_connect_backoff_max_ms} + + + + + + + + + + + +仅在 ClickHouse Cloud 中有效。创建分布式缓存连接的最大回退毫秒数。 +## distributed_cache_connect_backoff_min_ms {#distributed_cache_connect_backoff_min_ms} + + + + + + + + + + + +仅在 ClickHouse Cloud 中有效。创建分布式缓存连接的最小回退毫秒数。 ## distributed_cache_connect_max_tries {#distributed_cache_connect_max_tries} - - -仅在 ClickHouse Cloud 中生效。如果连接失败,则重新连接到分布式缓存的尝试次数 + + + + + + +仅在 ClickHouse Cloud 中有效。如果连接不成功,尝试连接到分布式缓存的次数。 +## distributed_cache_credentials_refresh_period_seconds {#distributed_cache_credentials_refresh_period_seconds} + + + + + + + + + + + +仅在 ClickHouse Cloud 中有效。凭据刷新的周期。 ## distributed_cache_data_packet_ack_window {#distributed_cache_data_packet_ack_window} + + + + -仅在 ClickHouse Cloud 中有效。用于在单个分布式缓存读取请求中发送 ACK 的数据包序列窗口。 +仅在 ClickHouse Cloud 中有效。在单个分布式缓存读取请求中发送数据包 ACK 的窗口。 ## distributed_cache_discard_connection_if_unread_data {#distributed_cache_discard_connection_if_unread_data} + + + + -仅在 ClickHouse Cloud 中有效。如果某些数据未被读取,则丢弃连接。 +仅在 ClickHouse Cloud 中有效。如果有未读数据则丢弃连接。 ## distributed_cache_fetch_metrics_only_from_current_az {#distributed_cache_fetch_metrics_only_from_current_az} + + + + -仅在 ClickHouse Cloud 中有效。仅从当前可用区获取 system.distributed_cache_metrics, system.distributed_cache_events 中的指标。 +仅在 ClickHouse Cloud 中有效。仅从当前可用区域提取 system.distributed_cache_metrics 和 system.distributed_cache_events 的指标。 ## distributed_cache_log_mode {#distributed_cache_log_mode} + + + + -仅在 ClickHouse Cloud 中有效。提供写入 system.distributed_cache_log 的模式。 +仅在 ClickHouse Cloud 中有效。对于系统.logs 记录的写入模式。 ## distributed_cache_max_unacked_inflight_packets {#distributed_cache_max_unacked_inflight_packets} + + + + -仅在 ClickHouse Cloud 中有效。单个分布式缓存读取请求中的最大未确认的在途数据包数量。 +仅在 ClickHouse Cloud 中有效。单个分布式缓存读取请求中的最大未确认的在途数据包数。 ## distributed_cache_min_bytes_for_seek {#distributed_cache_min_bytes_for_seek} + + + + 仅在 ClickHouse Cloud 中有效。进行分布式缓存查找的最小字节数。 @@ -2286,106 +2458,146 @@ ENGINE = Log + + + + -仅在 ClickHouse Cloud 中有效。定义当达到池限制时分布式缓存连接的行为。 -## distributed_cache_read_alignment {#distributed_cache_read_alignment} +仅在 ClickHouse Cloud 中有效。确定在达到连接池限制时分布式缓存连接的行为。 +## distributed_cache_prefer_bigger_buffer_size {#distributed_cache_prefer_bigger_buffer_size} - - -仅在 ClickHouse Cloud 中有效。用于测试目的的设置,请勿更改。 + + + + + + +仅在 ClickHouse Cloud 中有效。与 filesystem_cache_prefer_bigger_buffer_size 相同,适用于分布式缓存。 ## distributed_cache_read_only_from_current_az {#distributed_cache_read_only_from_current_az} + + + + -仅在 ClickHouse Cloud 中有效。允许仅从当前可用区读取。如果禁用,将从所有可用区的所有缓存服务器读取。 +仅在 ClickHouse Cloud 中有效。仅允许从当前可用区域读取。如果禁用,将从所有可用区域的所有缓存服务器读取。 ## distributed_cache_read_request_max_tries {#distributed_cache_read_request_max_tries} - - -仅在 ClickHouse Cloud 中有效。如果请求失败,尝试进行分布式缓存请求的次数。 + + + + + + +仅在 ClickHouse Cloud 中有效。如果分布式缓存请求不成功,尝试的次数。 ## distributed_cache_receive_response_wait_milliseconds {#distributed_cache_receive_response_wait_milliseconds} + + + + -仅在 ClickHouse Cloud 中有效。等待时间(以毫秒为单位),以接收来自分布式缓存请求的数据。 +仅在 ClickHouse Cloud 中有效。等待从分布式缓存请求接收数据的毫秒数。 ## distributed_cache_receive_timeout_milliseconds {#distributed_cache_receive_timeout_milliseconds} + + + + -仅在 ClickHouse Cloud 中有效。等待时间(以毫秒为单位),以接收来自分布式缓存的任何响应。 +仅在 ClickHouse Cloud 中有效。等待接收任何类型响应的毫秒数。 ## distributed_cache_throw_on_error {#distributed_cache_throw_on_error} + + + + -仅在 ClickHouse Cloud 中有效。在与分布式缓存通信期间重新抛出发生的异常或从分布式缓存接收到的异常。否则在出现错误时会跳过分布式缓存。 +仅在 ClickHouse Cloud 中有效。在与分布式缓存通信时重新抛出发生的异常或从分布式缓存接收到的异常。否则,退回到错误时跳过分布式缓存。 ## distributed_cache_wait_connection_from_pool_milliseconds {#distributed_cache_wait_connection_from_pool_milliseconds} + + + + -仅在 ClickHouse Cloud 中有效。如果 distributed_cache_pool_behaviour_on_limit 设置为 wait,等待从连接池接收连接的时间(以毫秒为单位)。 +仅在 ClickHouse Cloud 中有效。如果 distributed_cache_pool_behaviour_on_limit 设置为 wait,等待从连接池获得连接的毫秒数。 ## distributed_connections_pool_size {#distributed_connections_pool_size} + + -允许与远程服务器建立的最大并发连接数,以便为单个 分布式表 中的所有查询进行分布式处理。我们建议设置的值不少于集群中的服务器数量。 +用于与远程服务器进行分布式处理的所有查询的最大并发连接数。我们建议设置的值不少于集群中服务器的数量。 ## distributed_ddl_entry_format_version {#distributed_ddl_entry_format_version} + + -分布式 DDL(在集群上)查询的兼容性版本。 +分布式 DDL(ON CLUSTER)查询的兼容版本。 ## distributed_ddl_output_mode {#distributed_ddl_output_mode} + + 设置分布式 DDL 查询结果的格式。 可能的值: -- `throw` — 返回所有主机上查询执行状态的结果集。如果查询在某些主机上失败,则将重新抛出第一个异常。如果查询在某些主机上尚未完成并且 [distributed_ddl_task_timeout](#distributed_ddl_task_timeout) 超过,则会抛出 `TIMEOUT_EXCEEDED` 异常。 -- `none` — 类似于 throw,但分布式 DDL 查询不返回结果集。 -- `null_status_on_timeout` — 如果在相应的主机上查询尚未完成,则在结果集的一些行中返回 `NULL` 作为执行状态,而不是抛出 `TIMEOUT_EXCEEDED`。 -- `never_throw` — 如果查询在某些主机上失败,则不抛出 `TIMEOUT_EXCEEDED`,也不重新抛出异常。 -- `none_only_active` - 类似于 `none`,但不等待 `Replicated` 数据库的非活动副本。注意:使用此模式无法判断某条查询未在某个副本上执行并将在后台执行。 +- `throw` — 返回执行状态的结果集,适用于查询已完成的所有主机。如果某些主机上的查询失败,则将重新抛出第一次异常。如果某些主机上的查询尚未完成并且超过了 [distributed_ddl_task_timeout](#distributed_ddl_task_timeout),则将抛出 `TIMEOUT_EXCEEDED` 异常。 +- `none` — 与抛出类似,但分布式 DDL 查询返回结果集为空。 +- `null_status_on_timeout` — 在结果集中的某些行返回 `NULL` 作为执行状态,而不是在相应主机没有完成查询时抛出 `TIMEOUT_EXCEEDED`。 +- `never_throw` — 如果某些主机上的查询失败则不抛出 `TIMEOUT_EXCEEDED`,也不重新抛出异常。 +- `none_only_active` - 类似于 `none`,但不等待 `Replicated` 数据库的非活动副本。注意:在这种模式下无法确定查询没有在某些副本上执行,并且将在后台执行。 - `null_status_on_timeout_only_active` — 类似于 `null_status_on_timeout`,但不等待 `Replicated` 数据库的非活动副本。 - `throw_only_active` — 类似于 `throw`,但不等待 `Replicated` 数据库的非活动副本。 -Cloud 默认值:`none`。 +云端默认值:`throw`。 ## distributed_ddl_task_timeout {#distributed_ddl_task_timeout} + + -设置集群中所有主机的 DDL 查询响应的超时时间。如果在所有主机上未执行 DDL 请求,响应将包含超时错误,请求将以异步方式执行。负值表示无限制。 +设置来自集群中所有主机的 DDL 查询响应超时。如果在所有主机上没有执行 DDL 请求,则响应将包含超时错误,请求将以异步模式执行。负值表示无限制。 可能的值: @@ -2394,18 +2606,20 @@ Cloud 默认值:`none`。 - 负整数 — 无限超时。 ## distributed_foreground_insert {#distributed_foreground_insert} + + -启用或禁用将数据同步插入到 [Distributed](/engines/table-engines/special/distributed) 表中。 +启用或禁用对 [Distributed](/engines/table-engines/special/distributed) 表的同步数据插入。 -默认情况下,当往 `Distributed` 表中插入数据时,ClickHouse 服务器以后台模式将数据发送到集群节点。当 `distributed_foreground_insert=1` 时,数据将以同步方式处理,只有在所有数据都保存到所有分片上时(如果 `internal_replication` 为真,则每个分片至少有一个副本),`INSERT` 操作才会成功。 +默认情况下,当将数据插入到 `Distributed` 表时,ClickHouse 服务器会在后台模式下将数据发送到集群节点。当 `distributed_foreground_insert=1` 时,数据以同步方式处理,只有在所有分片上的所有数据都保存后(如果 `internal_replication` 为 true,则每个分片至少一个副本)`INSERT` 操作才会成功。 可能的值: -- 0 — 数据以后台模式插入。 -- 1 — 数据以同步模式插入。 +- `0` — 数据在后台模式下插入。 +- `1` — 数据以同步模式插入。 -Cloud 默认值:`1`。 +云端默认值:`0`。 **另见** @@ -2413,15 +2627,17 @@ Cloud 默认值:`1`。 - [管理分布式表](/sql-reference/statements/system#managing-distributed-tables) ## distributed_group_by_no_merge {#distributed_group_by_no_merge} + + -在分布式查询处理中,不要合并来自不同服务器的聚合状态,在确定不同分片上有不同的键时可以使用此项。 +在分布式查询处理中,未能合并来自不同服务器的聚合状态,如果可以确认在不同的分片上有不同的键,可以使用此设置。 可能的值: - `0` — 禁用(最终查询处理在发起节点上完成)。 -- `1` - 不要合并来自不同服务器的聚合状态进行分布式查询处理(查询完全在分片上处理,发起者仅作为数据代理),在确定不同分片上有不同的键时可以使用。 -- `2` - 与 `1` 相同,但在发起者上应用 `ORDER BY` 和 `LIMIT`(当查询完全在远程节点上处理时不可能,例如对于 `distributed_group_by_no_merge=1`)。 +- `1` - 不合并来自不同服务器的聚合状态进行分布式查询处理(查询在分片上完全处理,发起节点仅代理数据),如果确认在不同分片上有不同的键,则可以使用此设置。 +- `2` - 与 `1` 相同,但在发起节点上应用 `ORDER BY` 和 `LIMIT`(当查询在远程节点完全处理时,如 `distributed_group_by_no_merge=1`,则无法执行)。 **示例** @@ -2453,22 +2669,30 @@ FORMAT PrettyCompactMonoBlock ``` ## distributed_insert_skip_read_only_replicas {#distributed_insert_skip_read_only_replicas} + + + + -允许在将数据插入分布式时跳过只读副本的 INSERT 查询。 +启用跳过只读副本的 INSERT 查询到 Distributed。 可能的值: -- 0 — INSERT 按照通常方式执行,如果请求到只读副本则会失败。 -- 1 — 发起者将跳过只读副本,然后将数据发送到分片。 +- 0 — INSERT 行为如常,如果将转发到只读副本,则会失败。 +- 1 — 发起者在将数据发送到分片之前会跳过只读副本。 ## distributed_plan_default_reader_bucket_count {#distributed_plan_default_reader_bucket_count} + + + + 分布式查询的默认并行读取任务数量。任务在副本之间分配。 @@ -2476,69 +2700,119 @@ FORMAT PrettyCompactMonoBlock + + + + + + 分布式 shuffle-hash-join 的默认桶数量。 ## distributed_plan_execute_locally {#distributed_plan_execute_locally} + + + + + + 在本地运行分布式查询计划的所有任务。用于测试和调试。 ## distributed_plan_force_exchange_kind {#distributed_plan_force_exchange_kind} + + -在分布式查询阶段之间强制指定类型的 Exchange 操作符。 +强制分布式查询阶段之间的指定类型交换操作符。 + +可能的值: + + - '' - 不强制任何类型的交换操作符,允许优化器选择, + - 'Persisted' - 使用对象存储中的临时文件, + - 'Streaming' - 在网络上传输交换数据。 +## distributed_plan_force_shuffle_aggregation {#distributed_plan_force_shuffle_aggregation} + + + + + + + + + + + +在分布式查询计划中使用 Shuffle 聚合策略,而不是 PartialAggregation + Merge。 +## distributed_plan_max_rows_to_broadcast {#distributed_plan_max_rows_to_broadcast} + + + + + + + + + + + +在分布式查询计划中,广播连接所使用的最大行数,而不是 shuffle 连接。 +## distributed_plan_optimize_exchanges {#distributed_plan_optimize_exchanges} + + + + -可能的值: - - '' - 不强制任何类型的 Exchange 操作符,让优化器自行选择, - - 'Persisted' - 使用对象存储中的临时文件, - - 'Streaming' - 在网络上流交换数据。 -## distributed_plan_optimize_exchanges {#distributed_plan_optimize_exchanges} - + -移除分布式查询计划中不必要的交换。禁用它以用于调试。 +在分布式查询计划中移除不必要的交换。对于调试,请禁用它。 ## distributed_product_mode {#distributed_product_mode} + + 更改 [分布式子查询](../../sql-reference/operators/in.md) 的行为。 -当查询包含分布式表的乘积时,即当针对分布式表的查询包含非 GLOBAL 子查询时,ClickHouse 应用此设置。 +ClickHouse 在查询包含分布式表的乘积时应用此设置,即当分布式表的查询包含对该分布式表的非全局子查询时。 限制: - 仅适用于 IN 和 JOIN 子查询。 -- 仅当 FROM 部分使用包含多个分片的分布式表时。 -- 如果子查询涉及的分布式表包含多个分片。 +- 仅在 FROM 部分使用包含多个分片的分布式表时适用。 +- 如果子查询涉及包含多个分片的分布式表。 - 不用于表值 [remote](../../sql-reference/table-functions/remote.md) 函数。 可能的值: -- `deny` — 默认值。禁止使用这些类型的子查询(返回 "禁止双重分布式IN/JOIN子查询" 异常)。 -- `local` — 将子查询中的数据库和表替换为目标服务器(分片)的本地表,保留正常的 `IN`/`JOIN`。 -- `global` — 将 `IN`/`JOIN` 查询替换为 `GLOBAL IN`/`GLOBAL JOIN`。 +- `deny` — 默认值。禁止使用这些类型的子查询(返回“禁止双重分布的 in/JOIN 子查询”异常)。 +- `local` — 在子查询中将数据库和表替换为目标服务器(分片)的本地表,保留正常的`IN`/`JOIN`。 +- `global` — 用 `GLOBAL IN`/`GLOBAL JOIN` 替换 `IN`/`JOIN` 查询。 - `allow` — 允许使用这些类型的子查询。 ## distributed_push_down_limit {#distributed_push_down_limit} + + -启用或禁用 [LIMIT](#limit) 在每个分片上分别应用。 +启用或禁用在每个分片上单独应用 [LIMIT](#limit)。 这将避免: -- 在网络上传输额外的行; -- 在发起者上处理限制后的行。 +- 通过网络发送额外的行; +- 在发起节点处理超出限制的行。 -从 21.9 版本开始,您不能再获得不准确的结果,因为 `distributed_push_down_limit` 仅在满足以下至少一个条件时改变查询执行: +从 21.9 版本开始,您不再会获得不准确的结果,因为 `distributed_push_down_limit` 仅在满足至少一个条件时才会改变查询执行: - [distributed_group_by_no_merge](#distributed_group_by_no_merge) > 0。 -- 查询 **没有** `GROUP BY` / `DISTINCT` / `LIMIT BY`,但有 `ORDER BY` / `LIMIT`。 -- 查询 **有** `GROUP BY` / `DISTINCT` / `LIMIT BY` 以及 `ORDER BY` / `LIMIT` 并且: +- 查询 **没有** `GROUP BY`/`DISTINCT`/`LIMIT BY`,但它有 `ORDER BY`/`LIMIT`。 +- 查询 **有** `GROUP BY`/`DISTINCT`/`LIMIT BY` 带有 `ORDER BY`/`LIMIT` 以及: - [optimize_skip_unused_shards](#optimize_skip_unused_shards) 被启用。 - [optimize_distributed_group_by_sharding_key](#optimize_distributed_group_by_sharding_key) 被启用。 @@ -2554,12 +2828,14 @@ FORMAT PrettyCompactMonoBlock - [optimize_distributed_group_by_sharding_key](#optimize_distributed_group_by_sharding_key) ## distributed_replica_error_cap {#distributed_replica_error_cap} + + -- 类型:无符号整数 +- 类型:无符号整型 - 默认值:1000 -每个副本的错误数量被限制在此值,防止单个副本累积过多错误。 +每个副本的错误计数限制在此值,不允许单个副本累积过多错误。 另见: @@ -2569,12 +2845,14 @@ FORMAT PrettyCompactMonoBlock - [distributed_replica_max_ignored_errors](#distributed_replica_max_ignored_errors) ## distributed_replica_error_half_life {#distributed_replica_error_half_life} + + - 类型:秒 -- 默认值:60 秒 +- 默认值:60秒 -控制分布式表中错误被清零的速度。如果某个副本在一段时间内不可用,累计 5 个错误,并且 distributed_replica_error_half_life 设置为 1 秒,则该副本将在最后一个错误发生后 3 秒被视为正常。 +控制分布式表中错误归零的速度。如果某个副本在一段时间内不可用,累积 5 个错误,并且 distributed_replica_error_half_life 设置为 1 秒,则在最后一个错误后的 3 秒内,该副本被视为正常。 另见: @@ -2584,12 +2862,14 @@ FORMAT PrettyCompactMonoBlock - [distributed_replica_max_ignored_errors](#distributed_replica_max_ignored_errors) ## distributed_replica_max_ignored_errors {#distributed_replica_max_ignored_errors} + + -- 类型:无符号整数 +- 类型:无符号整型 - 默认值:0 -在选择副本时将被忽略的错误数量(根据 `load_balancing` 算法)。 +在选择副本时将忽略的错误数(根据 `load_balancing` 算法)。 另见: @@ -2599,86 +2879,167 @@ FORMAT PrettyCompactMonoBlock - [distributed_replica_error_half_life](#distributed_replica_error_half_life) ## do_not_merge_across_partitions_select_final {#do_not_merge_across_partitions_select_final} + + -在 select final 中仅在一个分区中合并部分。 +在 select final 中仅在一个分区合并部分。 ## empty_result_for_aggregation_by_constant_keys_on_empty_set {#empty_result_for_aggregation_by_constant_keys_on_empty_set} + + -在对空集按常数键聚合时返回空结果。 +在空集合上按常量键进行聚合时返回空结果。 ## empty_result_for_aggregation_by_empty_set {#empty_result_for_aggregation_by_empty_set} + + -在对空集进行无键聚合时返回空结果。 +在空集合上无键进行聚合时返回空结果。 ## enable_adaptive_memory_spill_scheduler {#enable_adaptive_memory_spill_scheduler} + + + + + + + + +在适应性条件下触发处理程序将数据溢出到外部存储。目前支持 grace join。 +## enable_add_distinct_to_in_subqueries {#enable_add_distinct_to_in_subqueries} + + + -触发处理器自适应地将数据溢出到外部存储。目前支持优雅连接。 + + + + +在 `IN` 子查询中启用 `DISTINCT`。这是一个权衡设置:启用它可以大大减少传输给分布式 IN 子查询的临时表的大小,并显著加快分片间的数据传输,因为只确保唯一值被发送。 +然而,启用此设置在每个节点上增加了额外的合并工作,因为必须执行去重(DISTINCT)。当网络传输成为瓶颈且额外的合并成本可接受时使用此设置。 ## enable_blob_storage_log {#enable_blob_storage_log} + + + + + + 将有关 blob 存储操作的信息写入 system.blob_storage_log 表。 ## enable_deflate_qpl_codec {#enable_deflate_qpl_codec} + + -如果启用,DEFLATE_QPL 编解码器可用于压缩列。 +如果启用,可以使用 DEFLATE_QPL 编解码器压缩列。 ## enable_early_constant_folding {#enable_early_constant_folding} -启用查询优化,我们分析函数和子查询的结果,如果其中有常量则重写查询。 + + + + +启用查询优化,其中我们分析函数和子查询结果,如果存在常量则重写查询。 ## enable_extended_results_for_datetime_functions {#enable_extended_results_for_datetime_functions} -启用或禁用返回类型结果: -- `Date32` 具有扩展范围(与 `Date` 类型相比)用于函数 [toStartOfYear](../../sql-reference/functions/date-time-functions.md/#tostartofyear), [toStartOfISOYear](../../sql-reference/functions/date-time-functions.md/#tostartofisoyear), [toStartOfQuarter](../../sql-reference/functions/date-time-functions.md/#tostartofquarter), [toStartOfMonth](../../sql-reference/functions/date-time-functions.md/#tostartofmonth), [toLastDayOfMonth](../../sql-reference/functions/date-time-functions.md/#tolastdayofmonth), [toStartOfWeek](../../sql-reference/functions/date-time-functions.md/#tostartofweek), [toLastDayOfWeek](../../sql-reference/functions/date-time-functions.md/#tolastdayofweek) 和 [toMonday](../../sql-reference/functions/date-time-functions.md/#tomonday)。 -- `DateTime64` 具有扩展范围(与 `DateTime` 类型相比)用于函数 [toStartOfDay](../../sql-reference/functions/date-time-functions.md/#tostartofday), [toStartOfHour](../../sql-reference/functions/date-time-functions.md/#tostartofhour), [toStartOfMinute](../../sql-reference/functions/date-time-functions.md/#tostartofminute), [toStartOfFiveMinutes](../../sql-reference/functions/date-time-functions.md/#tostartoffiveminutes), [toStartOfTenMinutes](../../sql-reference/functions/date-time-functions.md/#tostartoftenminutes), [toStartOfFifteenMinutes](../../sql-reference/functions/date-time-functions.md/#tostartoffifteenminutes) 和 [timeSlot](../../sql-reference/functions/date-time-functions.md/#timeslot)。 + + + + +启用或禁用返回扩展范围的 `Date32` 类型(与 `Date` 类型相比)或扩展范围的 `DateTime64`(与 `DateTime` 类型相比)的结果。 可能的值: -- 0 — 函数对所有类型的参数返回 `Date` 或 `DateTime`。 -- 1 — 函数对 `Date32` 或 `DateTime64` 参数返回 `Date32` 或 `DateTime64`,对其他情况返回 `Date` 或 `DateTime`。 +- `0` — 对所有类型的参数,函数返回 `Date` 或 `DateTime`。 +- `1` — 函数对 `Date32` 或 `DateTime64` 参数返回 `Date32` 或 `DateTime64`,而其他情况返回 `Date` 或 `DateTime`。 + +下表展示了该设置对各种日期时间函数的行为。 + +| 函数 | `enable_extended_results_for_datetime_functions = 0` | `enable_extended_results_for_datetime_functions = 1` | +|----------|---------------------------------------------------|---------------------------------------------------| +| `toStartOfYear` | 返回 `Date` 或 `DateTime` | 返回 `Date`/`DateTime` 对于 `Date`/`DateTime` 输入
返回 `Date32`/`DateTime64` 对于 `Date32`/`DateTime64` 输入 | +| `toStartOfISOYear` | 返回 `Date` 或 `DateTime` | 返回 `Date`/`DateTime` 对于 `Date`/`DateTime` 输入
返回 `Date32`/`DateTime64` 对于 `Date32`/`DateTime64` 输入 | +| `toStartOfQuarter` | 返回 `Date` 或 `DateTime` | 返回 `Date`/`DateTime` 对于 `Date`/`DateTime` 输入
返回 `Date32`/`DateTime64` 对于 `Date32`/`DateTime64` 输入 | +| `toStartOfMonth` | 返回 `Date` 或 `DateTime` | 返回 `Date`/`DateTime` 对于 `Date`/`DateTime` 输入
返回 `Date32`/`DateTime64` 对于 `Date32`/`DateTime64` 输入 | +| `toStartOfWeek` | 返回 `Date` 或 `DateTime` | 返回 `Date`/`DateTime` 对于 `Date`/`DateTime` 输入
返回 `Date32`/`DateTime64` 对于 `Date32`/`DateTime64` 输入 | +| `toLastDayOfWeek` | 返回 `Date` 或 `DateTime` | 返回 `Date`/`DateTime` 对于 `Date`/`DateTime` 输入
返回 `Date32`/`DateTime64` 对于 `Date32`/`DateTime64` 输入 | +| `toLastDayOfMonth` | 返回 `Date` 或 `DateTime` | 返回 `Date`/`DateTime` 对于 `Date`/`DateTime` 输入
返回 `Date32`/`DateTime64` 对于 `Date32`/`DateTime64` 输入 | +| `toMonday` | 返回 `Date` 或 `DateTime` | 返回 `Date`/`DateTime` 对于 `Date`/`DateTime` 输入
返回 `Date32`/`DateTime64` 对于 `Date32`/`DateTime64` 输入 | +| `toStartOfDay` | 返回 `DateTime`
*注意:对于 1970-2149 范围以外的值,结果错误* | 返回 `DateTime` 对于 `Date`/`DateTime` 输入
返回 `DateTime64` 对于 `Date32`/`DateTime64` 输入 | +| `toStartOfHour` | 返回 `DateTime`
*注意:对于 1970-2149 范围以外的值,结果错误* | 返回 `DateTime` 对于 `Date`/`DateTime` 输入
返回 `DateTime64` 对于 `Date32`/`DateTime64` 输入 | +| `toStartOfFifteenMinutes` | 返回 `DateTime`
*注意:对于 1970-2149 范围以外的值,结果错误* | 返回 `DateTime` 对于 `Date`/`DateTime` 输入
返回 `DateTime64` 对于 `Date32`/`DateTime64` 输入 | +| `toStartOfTenMinutes` | 返回 `DateTime`
*注意:对于 1970-2149 范围以外的值,结果错误* | 返回 `DateTime` 对于 `Date`/`DateTime` 输入
返回 `DateTime64` 对于 `Date32`/`DateTime64` 输入 | +| `toStartOfFiveMinutes` | 返回 `DateTime`
*注意:对于 1970-2149 范围以外的值,结果错误* | 返回 `DateTime` 对于 `Date`/`DateTime` 输入
返回 `DateTime64` 对于 `Date32`/`DateTime64` 输入 | +| `toStartOfMinute` | 返回 `DateTime`
*注意:对于 1970-2149 范围以外的值,结果错误* | 返回 `DateTime` 对于 `Date`/`DateTime` 输入
返回 `DateTime64` 对于 `Date32`/`DateTime64` 输入 | +| `timeSlot` | 返回 `DateTime`
*注意:对于 1970-2149 范围以外的值,结果错误* | 返回 `DateTime` 对于 `Date`/`DateTime` 输入
返回 `DateTime64` 对于 `Date32`/`DateTime64` 输入 | ## enable_filesystem_cache {#enable_filesystem_cache} + + -为远程文件系统使用缓存。此设置不会打开/关闭磁盘的缓存(必须通过磁盘配置完成),但允许在某些查询中绕过缓存。 +为远程文件系统使用缓存。此设置不会打开/关闭磁盘的缓存(必须通过磁盘配置完成),但允许在某些查询中绕过缓存(如果有意)。 ## enable_filesystem_cache_log {#enable_filesystem_cache_log} + + 允许记录每个查询的文件系统缓存日志。 ## enable_filesystem_cache_on_write_operations {#enable_filesystem_cache_on_write_operations} + + -在写操作时写入缓存。要使此设置实际生效,必须在磁盘配置中也进行添加。 +启用或禁用 `write-through` 缓存。如果设置为 `false`,则在写操作中禁用 `write-through` 缓存。如果设置为 `true`,则只有在服务器配置的缓存磁盘配置部分中开启 `cache_on_write_operations` 时,才启用 `write-through` 缓存。 +有关更多详细信息,请参阅["使用本地缓存"](/operations/storing-data#using-local-cache)。 ## enable_filesystem_read_prefetches_log {#enable_filesystem_read_prefetches_log} + + -在查询期间记录到 system.filesystem 的预取日志。仅应在测试或调试期间使用,通常不建议默认开启。 +在查询期间记录系统.filesystem prefetch_log。仅应在测试或调试中使用,不建议默认开启。 ## enable_global_with_statement {#enable_global_with_statement} + + + + + + 将 WITH 语句传播到 UNION 查询和所有子查询。 ## enable_hdfs_pread {#enable_hdfs_pread} + + -启用或禁用 HDFS 文件的预读取。默认情况下,使用 `hdfsPread`。如果禁用,则将使用 `hdfsRead` 和 `hdfsSeek` 来读取 HDFS 文件。 + + + + +启用或禁用 HDFS 文件的 pread。默认情况下使用 `hdfsPread`。如果禁用,将使用 `hdfsRead` 和 `hdfsSeek` 来读取 hdfs 文件。 ## enable_http_compression {#enable_http_compression} + + -启用或禁用在 HTTP 请求的响应中进行数据压缩。 +启用或禁用对 HTTP 请求的响应进行数据压缩。 -有关更多信息,请参阅 [HTTP 接口描述](../../interfaces/http.md)。 +有关更多信息,请阅读 [HTTP 接口描述](../../interfaces/http.md)。 可能的值: @@ -2686,32 +3047,66 @@ FORMAT PrettyCompactMonoBlock - 1 — 启用。 ## enable_job_stack_trace {#enable_job_stack_trace} - -在作业结果异常时输出作业创建者的堆栈跟踪。 + + + + + + + +当作业结果发生异常时输出作业创建者的堆栈跟踪。默认情况下禁用,以避免性能开销。 +## enable_join_runtime_filters {#enable_join_runtime_filters} + + + + + + + + + + + +通过在运行时从右侧收集的 JOIN 键集过滤左侧。 ## enable_lightweight_delete {#enable_lightweight_delete} -启用针对 mergetree 表的轻量级 DELETE 变更。 +启用轻量级 DELETE 变更以用于 mergetree 表。 +## enable_lightweight_update {#enable_lightweight_update} + + + + + + + +允许使用轻量级更新。 ## enable_memory_bound_merging_of_aggregation_results {#enable_memory_bound_merging_of_aggregation_results} -启用内存限制合并策略以进行聚合。 +启用内存限制的聚合合并策略。 ## enable_multiple_prewhere_read_steps {#enable_multiple_prewhere_read_steps} -在 WHERE 中转移多个条件到 PREWHERE,如果有多个条件通过 AND 组合,则从磁盘读取和过滤需分多步进行。 + + +将更多条件从 WHERE 移动到 PREWHERE,并在存在多个 AND 条件时以多个步骤从磁盘读取和过滤。 ## enable_named_columns_in_function_tuple {#enable_named_columns_in_function_tuple} -在功能 tuple() 中生成名称唯一的元组,可以将其视为无引号标识符。 + + +在 function tuple() 中生成命名元组,当所有名称都是唯一的并且可以被视为未引用的标识符时。 ## enable_optimize_predicate_expression {#enable_optimize_predicate_expression} -在 `SELECT` 查询中开启谓词下推。 + + +在 `SELECT` 查询中启用谓词下推。 谓词下推可以显著减少分布式查询的网络流量。 @@ -2720,16 +3115,16 @@ FORMAT PrettyCompactMonoBlock - 0 — 禁用。 - 1 — 启用。 -使用案例 +用法 考虑以下查询: 1. `SELECT count() FROM test_table WHERE date = '2018-10-10'` 2. `SELECT count() FROM (SELECT * FROM test_table) WHERE date = '2018-10-10'` -如果 `enable_optimize_predicate_expression = 1`,那么这两个查询的执行时间相等,因为 ClickHouse 在处理子查询时应用 `WHERE`。 +如果 `enable_optimize_predicate_expression = 1`,那么这两个查询的执行时间是相等的,因为 ClickHouse 在处理子查询时对其应用了 `WHERE`。 -如果 `enable_optimize_predicate_expression = 0`,则第二个查询的执行时间会更长,因为 `WHERE` 子句将应用于子查询完成后的所有数据。 +如果 `enable_optimize_predicate_expression = 0`,则第二个查询的执行时间会明显更长,因为 `WHERE` 子句在子查询完成后应用于所有数据。 ## enable_optimize_predicate_expression_to_final_subquery {#enable_optimize_predicate_expression_to_final_subquery} @@ -2739,7 +3134,7 @@ FORMAT PrettyCompactMonoBlock -启用或禁用使用 `ORDER BY ALL` 语法进行排序,详见 [ORDER BY](../../sql-reference/statements/select/order-by.md)。 +启用或禁用带有 `ORDER BY ALL` 语法的排序,详见 [ORDER BY](../../sql-reference/statements/select/order-by.md)。 可能的值: @@ -2769,21 +3164,32 @@ SELECT * FROM TAB ORDER BY ALL SETTINGS enable_order_by_all = 0; │ 10 │ 20 │ 30 │ └────┴────┴─────┘ ``` +## enable_parallel_blocks_marshalling {#enable_parallel_blocks_marshalling} + + + + + +仅影响分布式查询。如果启用,块将在管道线程上进行(反)序列化和(解)压缩(即在默认并行度以上)在发送给发起者之前/之后。 ## enable_parsing_to_custom_serialization {#enable_parsing_to_custom_serialization} -如果为 true,则数据可以直接解析为具有自定义序列化(例如 Sparse)的列,根据从表中获得的序列化提示进行处理。 + + +如果为真,则数据可以直接解析为具有自定义序列化(例如 Sparse)的列,按照从表中获得的序列化提示。 ## enable_positional_arguments {#enable_positional_arguments} -启用或禁用对 [GROUP BY](/sql-reference/statements/select/group-by), [LIMIT BY](../../sql-reference/statements/select/limit-by.md), [ORDER BY](../../sql-reference/statements/select/order-by.md) 语句的支持位置参数。 + + +启用或禁用支持位置参数用于 [GROUP BY](/sql-reference/statements/select/group-by)、[LIMIT BY](../../sql-reference/statements/select/limit-by.md)、[ORDER BY](../../sql-reference/statements/select/order-by.md) 语句。 可能的值: - 0 — 不支持位置参数。 -- 1 — 支持位置参数:可以用列号代替列名。 +- 1 — 支持位置参数:可以使用列编号代替列名。 **示例** @@ -2806,31 +3212,86 @@ SELECT * FROM positional_arguments ORDER BY 2,3; │ 10 │ 20 │ 30 │ └─────┴─────┴───────┘ ``` +## enable_producing_buckets_out_of_order_in_aggregation {#enable_producing_buckets_out_of_order_in_aggregation} + + + + + +允许内存高效聚合(见 `distributed_aggregation_memory_efficient`)生成无序的桶。 +这可能在聚合桶大小不均衡时提高性能,让副本在处理一些较小的桶时仍然可以将具有更大 id 的桶发送给发起者。 +缺点是可能会增加内存使用。 ## enable_reads_from_query_cache {#enable_reads_from_query_cache} -如果启用,`SELECT` 查询的结果将从 [查询缓存](../query-cache.md) 中检索。 +如果启用,`SELECT` 查询的结果将从 [查询缓存](../query-cache.md) 中获取。 可能的值: -- 0 - 禁用。 -- 1 - 启用。 +- 0 - 禁用 +- 1 - 启用 ## enable_s3_requests_logging {#enable_s3_requests_logging} -启用非常详细的 S3 请求日志。仅对调试有意义。 +启用 S3 请求的详细日志记录。仅用于调试。 ## enable_scalar_subquery_optimization {#enable_scalar_subquery_optimization} -如果设置为 true,将阻止标量子查询(反序列化) 大的标量值并可能避免多次运行同一子查询。 + + +如果设为真,防止标量子查询(反)序列化大型标量值,有可能避免多次运行相同的子查询。 +## enable_scopes_for_with_statement {#enable_scopes_for_with_statement} + + + + + +如果禁用,父级 WITH 子句中的声明将在当前作用域中表现出相同的作用域。 + +请注意,这是一个兼容性设置,旨在允许运行一些旧分析器能够执行的无效查询。 +## enable_shared_storage_snapshot_in_query {#enable_shared_storage_snapshot_in_query} + + + + + +如果启用,单个查询内的所有子查询将共享每个表的相同 StorageSnapshot。 +这确保了在整个查询中对数据的一致视图,即使是同一表被访问多次。 + +对于数据部分的内部一致性很重要的查询,这是必需的。示例: + +```sql +SELECT + count() +FROM events +WHERE (_part, _part_offset) IN ( + SELECT _part, _part_offset + FROM events + WHERE user_id = 42 +) +``` + +没有这个设置,外部和内部查询可能会在不同的数据快照上操作,导致结果不正确。 + +:::note +启用该设置会禁用在规划阶段完成后从快照中移除不必要的数据部分的优化。 +因此,长时间运行的查询可能会在整个过程中持有过时的部分,延迟部分清理并增加存储压力。 + +该设置当前仅适用于 MergeTree 家族的表。 +::: + +可能的值: + +- 0 - 禁用 +- 1 - 启用 ## enable_sharing_sets_for_mutations {#enable_sharing_sets_for_mutations} -允许为同一变更的不同任务共享为 IN 子查询构建的集合对象。这将减少内存使用和 CPU 消耗。 +允许在相同变更的不同任务之间共享为 IN 子查询构建的集合对象。这样可以减少内存使用和 CPU 消耗。 ## enable_software_prefetch_in_aggregation {#enable_software_prefetch_in_aggregation} @@ -2840,19 +3301,23 @@ SELECT * FROM positional_arguments ORDER BY 2,3; -允许使用大小不同的多个数组进行 ARRAY JOIN。当此设置启用时,数组将调整大小以匹配最长的数组。 +允许与大小不同的多个数组进行 ARRAY JOIN。当启用此设置时,数组将调整为最长的数组。 ## enable_url_encoding {#enable_url_encoding} -允许在 [URL](../../engines/table-engines/special/url.md) 引擎表中启用/禁用 URI 路径的解码/编码。 + + +允许在 [URL](../../engines/table-engines/special/url.md) 引擎表中启用/禁用对 uri 路径的解码/编码。 默认情况下禁用。 ## enable_vertical_final {#enable_vertical_final} -如果启用,在 FINAL 阶段通过将行标记为已删除并在后续阶段过滤它们来删除重复行,而不是合并行。 + + +如果启用,在 FINAL 期间通过将行标记为删除并稍后过滤它们来移除重复行,而不是合并行。 ## enable_writes_to_query_cache {#enable_writes_to_query_cache} @@ -2861,34 +3326,38 @@ SELECT * FROM positional_arguments ORDER BY 2,3; 可能的值: -- 0 - 禁用。 -- 1 - 启用。 +- 0 - 禁用 +- 1 - 启用 ## enable_zstd_qat_codec {#enable_zstd_qat_codec} -如果启用,ZSTD_QAT 编解码器可用于压缩列。 + + +如果启用,可以使用 ZSTD_QAT 编解码器来压缩列。 ## enforce_strict_identifier_format {#enforce_strict_identifier_format} + + 如果启用,仅允许包含字母数字字符和下划线的标识符。 ## engine_file_allow_create_multiple_files {#engine_file_allow_create_multiple_files} -启用或禁用在文件引擎表中每次插入时创建新文件(如果格式的后缀为 (`JSON`, `ORC`, `Parquet`, 等)。如果启用,每次插入时将根据以下模式创建新文件: +启用或禁用在文件引擎表中每次插入时创建新文件,如果格式有后缀(`JSON`、`ORC`、`Parquet` 等)。如果启用,每次插入将创建一个新文件,名称遵循以下模式: -`data.Parquet` -> `data.1.Parquet` -> `data.2.Parquet`。 +`data.Parquet` -> `data.1.Parquet` -> `data.2.Parquet`,以此类推。 可能的值: - 0 — `INSERT` 查询将新数据附加到文件末尾。 -- 1 — `INSERT` 查询将创建新文件。 +- 1 — `INSERT` 查询将创建一个新文件。 ## engine_file_empty_if_not_exists {#engine_file_empty_if_not_exists} -允许在没有文件的情况下从文件引擎表中选择数据。 +允许从没有文件的文件引擎表中选择数据。 可能的值: - 0 — `SELECT` 抛出异常。 @@ -2900,13 +3369,13 @@ SELECT * FROM positional_arguments ORDER BY 2,3; 启用或禁用在 [File](../../engines/table-engines/special/file.md) 引擎表中跳过空文件。 可能的值: -- 0 — 如果空文件与请求的格式不兼容,则 `SELECT` 抛出异常。 +- 0 — 如果空文件与请求格式不兼容,`SELECT` 抛出异常。 - 1 — 对于空文件,`SELECT` 返回空结果。 ## engine_file_truncate_on_insert {#engine_file_truncate_on_insert} -启用或禁用在 [File](../../engines/table-engines/special/file.md) 引擎表中插入前截断。 +启用或禁用在 [File](../../engines/table-engines/special/file.md) 引擎表中插入时截断。 可能的值: - 0 — `INSERT` 查询将新数据附加到文件末尾。 @@ -2918,75 +3387,109 @@ SELECT * FROM positional_arguments ORDER BY 2,3; 启用或禁用在 [URL](../../engines/table-engines/special/url.md) 引擎表中跳过空文件。 可能的值: -- 0 — 如果空文件与请求的格式不兼容,则 `SELECT` 抛出异常。 +- 0 — 如果空文件与请求格式不兼容,`SELECT` 抛出异常。 - 1 — 对于空文件,`SELECT` 返回空结果。 ## except_default_mode {#except_default_mode} -在 EXCEPT 查询中设置默认模式。可能的值:空字符串、'ALL'、'DISTINCT'。如果为空,未指定模式的查询将抛出异常。 +设置 EXCEPT 查询中的默认模式。可能的值:空字符串、'ALL'、'DISTINCT'。如果为空,则没有模式的查询将抛出异常。 +## exclude_materialize_skip_indexes_on_insert {#exclude_materialize_skip_indexes_on_insert} + + + +在 INSERT 期间排除指定的跳过索引不被构建和存储。被排除的跳过索引仍将在 [合并期间](merge-tree-settings.md/#materialize_skip_indexes_on_merge)被构建和存储,或者通过显式的 [MATERIALIZE INDEX](/sql-reference/statements/alter/skipping-index.md/#materialize-index) 查询来构建。 + +如果 [materialize_skip_indexes_on_insert](#materialize_skip_indexes_on_insert) 为 false,则无效。 + +示例: + +```sql +CREATE TABLE tab +( + a UInt64, + b UInt64, + INDEX idx_a a TYPE minmax, + INDEX idx_b b TYPE set(3) +) +ENGINE = MergeTree ORDER BY tuple(); + +SET exclude_materialize_skip_indexes_on_insert='idx_a'; -- idx_a will be not be updated upon insert +--SET exclude_materialize_skip_indexes_on_insert='idx_a, idx_b'; -- neither index would be updated on insert + +INSERT INTO tab SELECT number, number / 50 FROM numbers(100); -- only idx_b is updated + +-- since it is a session setting it can be set on a per-query level +INSERT INTO tab SELECT number, number / 50 FROM numbers(100, 100) SETTINGS exclude_materialize_skip_indexes_on_insert='idx_b'; + +ALTER TABLE tab MATERIALIZE INDEX idx_a; -- this query can be used to explicitly materialize the index + +SET exclude_materialize_skip_indexes_on_insert = DEFAULT; -- reset setting to default +``` +## execute_exists_as_scalar_subquery {#execute_exists_as_scalar_subquery} + + + + + +将非相关的 EXISTS 子查询作为标量子查询执行。对于标量子查询,使用缓存,并且常量折叠适用于结果。 ## external_storage_connect_timeout_sec {#external_storage_connect_timeout_sec} -连接超时时间(单位:秒)。当前仅支持 MySQL。 +连接超时(秒)。目前仅支持 MySQL。 ## external_storage_max_read_bytes {#external_storage_max_read_bytes} - - -表使用外部引擎时应刷新历史数据的最大字节数限制。当前仅支持 MySQL 表引擎、数据库引擎和字典。如果设置为 0,则禁用此设置。 +限制外部引擎表在刷新历史数据时的最大字节数。当前仅支持 MySQL 表引擎、数据库引擎和字典。如果等于 0,则该设置无效。 ## external_storage_max_read_rows {#external_storage_max_read_rows} - - -表使用外部引擎时应刷新历史数据的最大行数限制。当前仅支持 MySQL 表引擎、数据库引擎和字典。如果设置为 0,则禁用此设置。 +限制外部引擎表在刷新历史数据时的最大行数。当前仅支持 MySQL 表引擎、数据库引擎和字典。如果等于 0,则该设置无效。 ## external_storage_rw_timeout_sec {#external_storage_rw_timeout_sec} - - -读/写超时时间(单位:秒)。当前仅支持 MySQL。 +读取/写入超时(秒)。目前仅支持 MySQL。 ## external_table_functions_use_nulls {#external_table_functions_use_nulls} - - 定义 [mysql](../../sql-reference/table-functions/mysql.md)、[postgresql](../../sql-reference/table-functions/postgresql.md) 和 [odbc](../../sql-reference/table-functions/odbc.md) 表函数如何使用 Nullable 列。 可能的值: -- 0 — 表函数显式使用 Nullable 列。 +- 0 — 表函数明确使用 Nullable 列。 - 1 — 表函数隐式使用 Nullable 列。 -**使用** +**用法** -如果设置为 `0`,则表函数不创建 Nullable 列,而是插入默认值(而不是 NULL)。这同样适用于数组中的 NULL 值。 +如果设置为 `0`,表函数不会生成 Nullable 列,并在 NULL 处插入默认值。这也适用于数组中的 NULL 值。 ## external_table_strict_query {#external_table_strict_query} - - -如果设置为 true,则不允许将表达式转换为外部表查询的局部过滤器。 +如果设置为 true,则禁止将表达式转化为外部表查询的本地过滤器。 ## extract_key_value_pairs_max_pairs_per_row {#extract_key_value_pairs_max_pairs_per_row} -`extractKeyValuePairs` 函数可以生成的最大配对数。作为防止占用过多内存的保护措施。 + + +通过 `extractKeyValuePairs` 函数生成的最大对数。作为防止过多内存消耗的保障措施。 ## extremes {#extremes} -是否计算极值(查询结果列中的最小值和最大值)。接受 0 或 1。默认值 0(禁用)。 -有关更多信息,请参阅 "极值" 部分。 + + +是否计算极值(查询结果中列的最小值和最大值)。接受 0 或 1。默认值为 0(禁用)。更多信息,请参见“极值”部分。 ## fallback_to_stale_replicas_for_distributed_queries {#fallback_to_stale_replicas_for_distributed_queries} -如果没有可用的更新数据,则强制查询访问过期副本。参见 [复制](../../engines/table-engines/mergetree-family/replication.md)。 +如果更新的数据不可用,则强制查询切换到过期副本。请参见 [复制](../../engines/table-engines/mergetree-family/replication.md)。 -ClickHouse 从过期副本中选择最相关的数据。 +ClickHouse 会从过期的表副本中选择最相关的。 -在执行从指向复制表的分布式表的 `SELECT` 时使用。 +在进行 `SELECT` 从指向复制表的分布式表时使用。 -默认值为 1(启用)。 +默认为 1(启用)。 ## filesystem_cache_boundary_alignment {#filesystem_cache_boundary_alignment} -文件系统缓存边界对齐。此设置仅应用于非磁盘读取(例如,远程表引擎 / 表函数的缓存,但不适用于 MergeTree 表的存储配置)。值为 0 意味着没有对齐。 + + +文件系统缓存边界对齐。此设置仅应用于非磁盘读取(例如,远程表引擎/表函数的缓存,不适用于 MergeTree 表的存储配置)。值 0 表示无对齐。 ## filesystem_cache_enable_background_download_during_fetch {#filesystem_cache_enable_background_download_during_fetch} @@ -2995,7 +3498,7 @@ ClickHouse 从过期副本中选择最相关的数据。 -仅在 ClickHouse Cloud 中有效。等待时间以锁定缓存以进行空间保留在文件系统缓存中。 +仅在 ClickHouse Cloud 中有效。锁定缓存以进行空间保留的等待时间。 ## filesystem_cache_enable_background_download_for_metadata_files_in_packed_storage {#filesystem_cache_enable_background_download_for_metadata_files_in_packed_storage} @@ -3004,94 +3507,54 @@ ClickHouse 从过期副本中选择最相关的数据。 -仅在 ClickHouse Cloud 中有效。等待时间以锁定缓存以进行空间保留在文件系统缓存中。 +仅在 ClickHouse Cloud 中有效。锁定缓存以进行空间保留的等待时间。 ## filesystem_cache_max_download_size {#filesystem_cache_max_download_size} - - 单个查询可以下载的最大远程文件系统缓存大小。 ## filesystem_cache_name {#filesystem_cache_name} - - - - -用于无状态表引擎或数据湖的文件系统缓存名称 +用于无状态表引擎或数据湖的文件系统缓存名称。 ## filesystem_cache_prefer_bigger_buffer_size {#filesystem_cache_prefer_bigger_buffer_size} - - - - -如果启用了文件系统缓存,优先使用更大的缓存缓冲区以避免写入小文件段,这会降低缓存性能。另一方面,启用此设置可能会增加内存使用量。 +如果启用文件系统缓存,则优先选择更大的缓冲区大小,以避免写入小文件段,这会降低缓存性能。另一方面,启用此设置可能会增加内存使用。 ## filesystem_cache_reserve_space_wait_lock_timeout_milliseconds {#filesystem_cache_reserve_space_wait_lock_timeout_milliseconds} - - + - - - -文件系统缓存中为空间预留锁定的等待时间 +锁定缓存以进行空间保留的等待时间。 ## filesystem_cache_segments_batch_size {#filesystem_cache_segments_batch_size} - - -从缓存中读取缓冲区请求的单个文件段的批次大小限制。值过小会导致对缓存的过度请求,值过大可能会减慢缓存的驱逐 +限制读取缓冲区可以从缓存请求的单个批次的文件段的大小。过低的值会导致对缓存的请求过多,过大的值可能会减慢从缓存中逐出。 ## filesystem_cache_skip_download_if_exceeds_per_query_cache_write_limit {#filesystem_cache_skip_download_if_exceeds_per_query_cache_write_limit} - - - - - - -如果超过查询缓存大小,则跳过从远程文件系统的下载 +如果超过查询缓存大小,则跳过从远程文件系统的下载。 ## filesystem_prefetch_max_memory_usage {#filesystem_prefetch_max_memory_usage} - - - - 预取的最大内存使用量。 ## filesystem_prefetch_step_bytes {#filesystem_prefetch_step_bytes} - - - - -预取的步长(以字节为单位)。零表示 `auto` - 将自动推断最佳预取步长,但可能不是100%最佳。实际值可能有所不同,因为设置了 filesystem_prefetch_min_bytes_for_single_read_task +预取步骤(字节)。零表示 `auto` - 预取步骤的最佳值将自动推断,但可能不是 100% 最佳。实际值可能会有所不同,因为设置了 filesystem_prefetch_min_bytes_for_single_read_task。 ## filesystem_prefetch_step_marks {#filesystem_prefetch_step_marks} - - - - -预取的步长(以标记为单位)。零表示 `auto` - 将自动推断最佳预取步长,但可能不是100%最佳。实际值可能有所不同,因为设置了 filesystem_prefetch_min_bytes_for_single_read_task +预取步骤(标记)。零表示 `auto` - 大约最佳预取步骤将被自动推断,但可能不是 100% 最佳。实际值可能会有所不同,因为设置了 filesystem_prefetch_min_bytes_for_single_read_task。 ## filesystem_prefetches_limit {#filesystem_prefetches_limit} - - - - -预取的最大数量。零表示无限。如果你想限制预取数量,建议设置 `filesystem_prefetches_max_memory_usage` +最大预取次数。零表示无限。如果想要限制预取次数,建议设置 `filesystem_prefetches_max_memory_usage`。 ## final {#final} - - -自动将 [FINAL](../../sql-reference/statements/select/from.md/#final-modifier) 修饰符应用于查询中的所有表,适用于 [FINAL](../../sql-reference/statements/select/from.md/#final-modifier) 的表,包括连接的表和子查询中的表,以及分布式表。 +自动对查询中所有表应用 [FINAL](../../sql-reference/statements/select/from.md/#final-modifier) 修饰符,对适用的表(包括连接表和子查询中的表)以及分布式表。 可能的值: @@ -3133,20 +3596,18 @@ SELECT * FROM test; ``` ## flatten_nested {#flatten_nested} - - 设置 [nested](../../sql-reference/data-types/nested-data-structures/index.md) 列的数据格式。 可能的值: -- 1 — 嵌套列展平为单独的数组。 -- 0 — 嵌套列保持为单个元组数组。 +- 1 — 嵌套列被展平为单独的数组。 +- 0 — 嵌套列保留为单一的元组数组。 **用法** -如果设置为 `0`,可以使用任意级别的嵌套。 +如果设置为 `0`,则可以使用任意级别的嵌套。 **示例** @@ -3199,18 +3660,14 @@ SETTINGS index_granularity = 8192 │ ``` ## force_aggregate_partitions_independently {#force_aggregate_partitions_independently} - - -强制在适用时使用优化,但启发式决策未使用 +强制在适用时使用优化,但启发式决定不使用。 ## force_aggregation_in_order {#force_aggregation_in_order} - - -此设置由服务器本身用于支持分布式查询。不要手动更改,因为这会破坏正常操作。(在分布式聚合期间强制在远程节点上按顺序使用聚合)。 +该设置由服务器本身使用以支持分布式查询。请勿手动更改,因为这会破坏正常操作。(强制在分布式聚合期间在远程节点上按顺序使用聚合)。 ## force_data_skipping_indices {#force_data_skipping_indices} 如果未使用传递的数据跳过索引,则禁用查询执行。 @@ -3239,33 +3696,25 @@ SELECT * FROM data_01515 WHERE d1 = 0 AND assumeNotNull(d1_null) = 0 SETTINGS fo ``` ## force_grouping_standard_compatibility {#force_grouping_standard_compatibility} - - - - -使 GROUPING 函数在参数未用作聚合键时返回 1 +使 GROUPING 函数在参数未用作聚合键时返回 1。 ## force_index_by_date {#force_index_by_date} - - -如果索引不能按日期使用,则禁用查询执行。 +如果无法按日期索引,则禁用查询执行。 -适用于 MergeTree 系列的表。 +适用于 MergeTree 家族的表。 -如果 `force_index_by_date=1`,ClickHouse 将检查查询是否有可以用于限制数据范围的日期键条件。如果没有合适的条件,它将抛出异常。然而,它不会检查该条件是否减少了要读取的数据量。例如,条件 `Date != ' 2000-01-01 '` 是可接受的,即使它匹配表中的所有数据(即,运行查询需要全表扫描)。有关 MergeTree 表中数据范围的更多信息,请参阅 [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md)。 +如果 `force_index_by_date=1`,ClickHouse 将检查查询是否具有可以用来限制数据范围的日期键条件。如果没有合适的条件,它将抛出异常。然而,它不会检查条件是否减少了要读取的数据量。例如,条件 `Date != ' 2000-01-01 '` 是可接受的,即使它匹配了表中的所有数据(即,运行查询要求进行完全扫描)。有关 MergeTree 表中的数据范围的更多信息,请参见 [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md)。 ## force_optimize_projection {#force_optimize_projection} - - -启用或禁用在 `SELECT` 查询中强制使用 [projections](../../engines/table-engines/mergetree-family/mergetree.md/#projections),当启用投影优化时(请参见 [optimize_use_projections](#optimize_use_projections) 设置)。 +启用或禁用在启用投影优化时 `SELECT` 查询强制使用 [投影](../../engines/table-engines/mergetree-family/mergetree.md/#projections)。 可能的值: @@ -3273,125 +3722,107 @@ SELECT * FROM data_01515 WHERE d1 = 0 AND assumeNotNull(d1_null) = 0 SETTINGS fo - 1 — 投影优化是强制性的。 ## force_optimize_projection_name {#force_optimize_projection_name} -如果设置为非空字符串,则检查此投影在查询中至少被使用一次。 +如果设置为非空字符串,则检查此投影是否至少在查询中使用一次。 可能的值: -- 字符串:在查询中使用的投影名称 +- 字符串:在查询中使用的投影名称。 ## force_optimize_skip_unused_shards {#force_optimize_skip_unused_shards} - - -如果启用了 [optimize_skip_unused_shards](#optimize_skip_unused_shards) 且不能跳过未使用的分片,则启用或禁用查询执行。如果跳过不可用且启用此设置,则将抛出异常。 +启用或禁用查询执行,如果 [optimize_skip_unused_shards](#optimize_skip_unused_shards) 启用且无法跳过未使用的分片。如果无法跳过且启用了该设置,将抛出异常。 可能的值: - 0 — 禁用。ClickHouse 不会抛出异常。 -- 1 — 启用。只有当表具有分片键时,才禁用查询执行。 -- 2 — 启用。无论表的分片键是否定义,查询执行都被禁用。 +- 1 — 启用。仅当表具有分片键时,禁用查询执行。 +- 2 — 启用。无论表是否已定义分片键,均禁用查询执行。 ## force_optimize_skip_unused_shards_nesting {#force_optimize_skip_unused_shards_nesting} - - -控制 [`force_optimize_skip_unused_shards`](#force_optimize_skip_unused_shards)(因此仍然需要 [`force_optimize_skip_unused_shards`](#force_optimize_skip_unused_shards))取决于分布式查询的嵌套级别(例如,当你有一个 `Distributed` 表指向另一个 `Distributed` 表时)。 +控制 [`force_optimize_skip_unused_shards`](#force_optimize_skip_unused_shards)(因此仍然需要 [`force_optimize_skip_unused_shards`](#force_optimize_skip_unused_shards))取决于分布式查询的嵌套级别(例如,当你有 `Distributed` 表指向另一个 `Distributed` 表时)。 可能的值: -- 0 - 禁用,`force_optimize_skip_unused_shards` 始终生效。 -- 1 — 仅在第一级启用 `force_optimize_skip_unused_shards`。 -- 2 — 在第二级及以下启用 `force_optimize_skip_unused_shards`。 +- 0 - 禁用,`force_optimize_skip_unused_shards` 始终有效。 +- 1 — 仅对第一层启用 `force_optimize_skip_unused_shards`。 +- 2 — 对第二层启用 `force_optimize_skip_unused_shards`。 ## force_primary_key {#force_primary_key} - - 如果无法按主键索引,则禁用查询执行。 -适用于 MergeTree 系列的表。 +适用于 MergeTree 家族的表。 -如果 `force_primary_key=1`,ClickHouse 将检查查询是否具有可以用于限制数据范围的主键条件。如果没有合适的条件,它将抛出异常。然而,它不会检查该条件是否减少了要读取的数据量。有关 MergeTree 表中数据范围的更多信息,请参阅 [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md)。 +如果 `force_primary_key=1`,ClickHouse 将检查查询是否具有可以用来限制数据范围的主键条件。如果没有合适的条件,它将抛出异常。然而,它不会检查条件是否减少了要读取的数据量。有关 MergeTree 表中的数据范围的更多信息,请参见 [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md)。 ## force_remove_data_recursively_on_drop {#force_remove_data_recursively_on_drop} - - -在 DROP 查询时递归删除数据。避免出现“目录不为空”错误,但可能会静默删除分离的数据 +在 DROP 查询中递归地删除数据。避免“目录不空”错误,但可能会默默删除已分离的数据。 ## formatdatetime_e_with_space_padding {#formatdatetime_e_with_space_padding} - - - - -格式化程序 '%e' 在函数 'formatDateTime' 中打印单日期以带前导空格的形式,例如 ' 2' 而不是 '2'。 -## formatdatetime_f_prints_scale_number_of_digits {#formatdatetime_f_prints_scale_number_of_digits} - - - - - +格式化函数 'formatDateTime' 中的格式器 '%e' 输出一位数的日期时,前面带有空格,例如 ' 2' 而不是 '2'。 +## formatdatetime_f_prints_scale_number_of_digits {#formatdatetime_f_prints_scale_number_of_digits} + -格式化程序 '%f' 在函数 'formatDateTime' 中仅打印 DateTime64 的规模数字,而不是固定的 6 位数字。 +格式化函数 'formatDateTime' 中的格式器 '%f' 仅根据 DateTime64 的规模打印数字,而不是固定的 6 位数字。 ## formatdatetime_f_prints_single_zero {#formatdatetime_f_prints_single_zero} - - - - -格式化程序 '%f' 在函数 'formatDateTime' 中标记如果格式化值没有小数秒,则打印单零而不是六个零。 +格式化函数 'formatDateTime' 中的格式器 '%f' 如果格式化值没有小数秒,打印单个零而不是六个零。 ## formatdatetime_format_without_leading_zeros {#formatdatetime_format_without_leading_zeros} - - -格式化程序 '%c'、'%l' 和 '%k' 在函数 'formatDateTime' 中打印月份和小时时没有前导零。 +格式化函数 'formatDateTime' 中的格式器 '%c'、'%l' 和 '%k' 以无前导零的形式打印月份和小时。 ## formatdatetime_parsedatetime_m_is_month_name {#formatdatetime_parsedatetime_m_is_month_name} - - - - -格式化程序 '%M' 在函数 'formatDateTime' 和 'parseDateTime' 中打印/解析月份名称而不是分钟。 +格式化函数 'formatDateTime' 和 'parseDateTime' 中的格式器 '%M' 打印/解析月份名称而不是分钟。 ## fsync_metadata {#fsync_metadata} + +启用或禁用在写入 `.sql` 文件时的 [fsync](http://pubs.opengroup.org/onlinepubs/9699919799/functions/fsync.html)。默认为启用。 - +如果服务器有数百万个持续创建和销毁的小表,禁用它是合理的。 +## function_date_trunc_return_type_behavior {#function_date_trunc_return_type_behavior} -在写 `.sql` 文件时启用或禁用 [fsync](http://pubs.opengroup.org/onlinepubs/9699919799/functions/fsync.html)。默认启用。 + -如果服务器拥有数百万个持续创建和销毁的小表,则将其禁用是有意义的。 -## function_implementation {#function_implementation} + -选择特定目标或变体的函数实现(实验性)。如果为空,则启用所有。 -## function_json_value_return_type_allow_complex {#function_json_value_return_type_allow_complex} +允许更改 `dateTrunc` 函数结果类型的行为。 + +可能的值: +- 0 - 当第二个参数为 `DateTime64/Date32` 时,返回类型为 `DateTime64/Date32`,与第一个参数中的时间单位无关。 +- 1 - 对于 `Date32`,结果始终为 `Date`。对于 `DateTime64`,如果时间单位为 `second` 及更高,结果为 `DateTime`。 +## function_implementation {#function_implementation} +选择特定目标或变体(实验性)的函数实现。如果为空则启用所有实现。 +## function_json_value_return_type_allow_complex {#function_json_value_return_type_allow_complex} -控制 json_value 函数是否允许返回复杂类型(例如:struct、array、map)。 +控制 json_value 函数是否允许返回复杂类型(例如:结构、数组、映射)。 ```sql SELECT JSON_VALUE('{"hello":{"world":"!"}}', '$.hello') settings function_json_value_return_type_allow_complex=true @@ -3409,11 +3840,9 @@ SELECT JSON_VALUE('{"hello":{"world":"!"}}', '$.hello') settings function_json_v - false — 不允许。 ## function_json_value_return_type_allow_nullable {#function_json_value_return_type_allow_nullable} - - -控制 json_VALUE 函数在值不存在时是否允许返回 `NULL`。 +控制 JSON_VALUE 函数在值不存在时是否允许返回 `NULL`。 ```sql SELECT JSON_VALUE('{"hello":"world"}', '$.b') settings function_json_value_return_type_allow_nullable=true; @@ -3431,12 +3860,8 @@ SELECT JSON_VALUE('{"hello":"world"}', '$.b') settings function_json_value_retur - false — 不允许。 ## function_locate_has_mysql_compatible_argument_order {#function_locate_has_mysql_compatible_argument_order} - - - - 控制函数 [locate](../../sql-reference/functions/string-search-functions.md/#locate) 中参数的顺序。 @@ -3444,360 +3869,264 @@ SELECT JSON_VALUE('{"hello":"world"}', '$.b') settings function_json_value_retur 可能的值: - 0 — 函数 `locate` 接受参数 `(haystack, needle[, start_pos])`。 -- 1 — 函数 `locate` 接受参数 `(needle, haystack, [, start_pos])`(MySQL 兼容行为) +- 1 — 函数 `locate` 接受参数 `(needle, haystack, [, start_pos])`(与 MySQL 兼容的行为)。 ## function_range_max_elements_in_block {#function_range_max_elements_in_block} - - -设置函数 [range](/sql-reference/functions/array-functions#rangeend-rangestart--end--step) 生成的数据量的安全阈值。定义每个数据块(块中每行的数组大小总和)生成的函数的最大值。 +设置函数 [range](/sql-reference/functions/array-functions#range) 生成的数据量的安全阈值。定义每个数据块生成的最大值数量(每块每行数组大小的总和)。 可能的值: - 正整数。 -**另请参见** +**另见** -- [max_block_size](#max_block_size) -- [min_insert_block_size_rows](#min_insert_block_size_rows) +- [`max_block_size`](#max_block_size) +- [`min_insert_block_size_rows`](#min_insert_block_size_rows) ## function_sleep_max_microseconds_per_block {#function_sleep_max_microseconds_per_block} - - - - -函数 `sleep` 在每个块中允许的最大微秒数。如果用户用更大的值调用它,则会抛出异常。这是一个安全阈值。 +函数 `sleep` 允许每块暂停的最大微秒数。如果用户使用更大的值调用它,抛出异常。这是一个安全阈值。 ## function_visible_width_behavior {#function_visible_width_behavior} - - - - -`visibleWidth` 行为的版本。0 - 仅计算代码点的数量;1 - 正确计算零宽度和组合字符,将全宽字符计算为二个,估算制表符宽度,计算删除字符。 +`visibleWidth` 行为的版本。0 - 仅计算代码点数量;1 - 正确计算零宽字符和组合字符,将全宽字符计为两个,估算制表符宽度,计算删除字符。 ## geo_distance_returns_float64_on_float64_arguments {#geo_distance_returns_float64_on_float64_arguments} - - - - -如果 `geoDistance`、`greatCircleDistance`、`greatCircleAngle` 函数的四个参数都是 Float64,则返回 Float64,并在内部计算时使用双精度。在以前的 ClickHouse 版本中,这些函数始终返回 Float32。 +如果传递给 `geoDistance`、`greatCircleDistance`、`greatCircleAngle` 函数的四个参数都是 Float64,则返回 Float64,并以双精度进行内部计算。在之前的 ClickHouse 版本中,这些函数始终返回 Float32。 ## geotoh3_argument_order {#geotoh3_argument_order} - - - - 函数 'geoToH3' 如果设置为 'lon_lat' 则接受 (lon, lat),如果设置为 'lat_lon' 则接受 (lat, lon)。 ## glob_expansion_max_elements {#glob_expansion_max_elements} - - -允许的最大地址数量(适用于外部存储、表函数等)。 +允许的最大地址数(对于外部存储、表函数等)。 ## grace_hash_join_initial_buckets {#grace_hash_join_initial_buckets} - - -初始的 grace hash join 桶的数量 +初始的宽松哈希连接桶数。 ## grace_hash_join_max_buckets {#grace_hash_join_max_buckets} - - -grace hash join 桶的数量限制 +宽松哈希连接桶的数量限制。 ## group_by_overflow_mode {#group_by_overflow_mode} - - -设置当聚合的唯一键的数量超过限制时发生的情况: -- `throw`:抛出异常 -- `break`:停止执行查询并返回部分结果 -- `any`:继续聚合已进入集合的键,但不添加新键到集合中。 +设置当聚合的唯一键数量超过限制时会发生的情况: +- `throw`: 抛出异常 +- `break`: 停止执行查询并返回部分结果 +- `any`: 继续聚合已进入集合的键,但不向集合中添加新键。 -使用 'any' 值可以运行 GROUP BY 的近似值。这个近似值的质量取决于数据的统计性质。 +使用 'any' 值让您运行 GROUP BY 的近似。此近似的质量依赖于数据的统计特性。 ## group_by_two_level_threshold {#group_by_two_level_threshold} - - -从多少数量的键开始,二级聚合开始。0 - 未设定阈值。 +从多少个键开始,两级聚合开始。0 - 未设置阈值。 ## group_by_two_level_threshold_bytes {#group_by_two_level_threshold_bytes} - - -从聚合状态的字节大小开始,开始使用二级聚合。0 - 未设定阈值。两级聚合在至少触发一个阈值时使用。 +从多少字节的聚合状态大小开始,开始使用两级聚合。0 - 不设定阈值。触发至少一个阈值时使用两级聚合。 ## group_by_use_nulls {#group_by_use_nulls} - - -改变 [GROUP BY 子句](/sql-reference/statements/select/group-by) 处理聚合键类型的方式。 -当使用 `ROLLUP`、`CUBE` 或 `GROUPING SETS` 谓词时,某些聚合键可能不会用于生成某些结果行。 -根据此设置,填充这些键的列的默认值或 `NULL`。 +更改 [GROUP BY 子句](/sql-reference/statements/select/group-by) 如何对聚合键的类型进行处理。 +当使用 `ROLLUP`、`CUBE` 或 `GROUPING SETS` 指定器时,一些聚合键可能不会被用于生成某些结果行。 +这些键对应的列根据此设置用默认值或 `NULL` 填充。 可能的值: - 0 — 使用聚合键类型的默认值来生成缺失值。 -- 1 — ClickHouse 以 SQL 标准所述的相同方式执行 `GROUP BY`。聚合键的类型转换为 [Nullable](/sql-reference/data-types/nullable)。在未使用聚合键的行中,对于相应聚合键的列填充 [NULL](/sql-reference/syntax#null)。 +- 1 — ClickHouse 按照 SQL 标准的方式执行 `GROUP BY`。聚合键的类型被转换为 [Nullable](/sql-reference/data-types/nullable)。对于未使用的行,对应聚合键的列填充 [NULL](/sql-reference/syntax#null)。 -另请参见: +另见: - [GROUP BY 子句](/sql-reference/statements/select/group-by) ## h3togeo_lon_lat_result_order {#h3togeo_lon_lat_result_order} - - - - 函数 'h3ToGeo' 返回 (lon, lat) 如果为 true,否则返回 (lat, lon)。 ## handshake_timeout_ms {#handshake_timeout_ms} - - -在握手期间接收来自副本的 Hello 数据包的超时时间(以毫秒为单位)。 +握手期间接收 Hello 数据包的超时时间(毫秒)。 ## hdfs_create_new_file_on_insert {#hdfs_create_new_file_on_insert} - - -启用或禁用在 HDFS 引擎表中每次插入时创建新文件。如果启用,则在每次插入时,将创建一个新的 HDFS 文件,名称类似于以下模式: +启用或禁用在 HDFS 引擎表中的每次插入时创建新文件。如果启用,在每次插入时将创建一个新 HDFS 文件,其名称类似于以下模式: -初始: `data.Parquet.gz` -> `data.1.Parquet.gz` -> `data.2.Parquet.gz`,等。 +初始:`data.Parquet.gz` -> `data.1.Parquet.gz` -> `data.2.Parquet.gz` 等等。 可能的值: -- 0 — `INSERT` 查询将新数据添加到文件末尾。 -- 1 — `INSERT` 查询将创建新文件。 -## hdfs_ignore_file_doesnt_exist {#hdfs_ignore_file_doesnt_exist} - +- 0 — `INSERT` 查询将新数据附加到文件末尾。 +- 1 — `INSERT` 查询创建一个新文件。 +## hdfs_ignore_file_doesnt_exist {#hdfs_ignore_file_doesnt_exist} - - -在读取某些键时,如果文件不存在,忽略文件的缺失。 +在读取某些键时,如果文件不存在,则忽略文件不存在的情况。 可能的值: - 1 — `SELECT` 返回空结果。 - 0 — `SELECT` 抛出异常。 -## hdfs_replication {#hdfs_replication} - +## hdfs_replication {#hdfs_replication} 创建 hdfs 文件时可以指定实际的复制数量。 -## hdfs_skip_empty_files {#hdfs_skip_empty_files} - +## hdfs_skip_empty_files {#hdfs_skip_empty_files} 启用或禁用在 [HDFS](../../engines/table-engines/integrations/hdfs.md) 引擎表中跳过空文件。 可能的值: -- 0 — 如果空文件与请求的格式不兼容,则 `SELECT` 抛出异常。 -- 1 — 对于空文件,`SELECT` 返回空结果。 -## hdfs_throw_on_zero_files_match {#hdfs_throw_on_zero_files_match} - +- 0 — 如果空文件与请求的格式不兼容,`SELECT` 抛出异常。 +- 1 — 空文件的 `SELECT` 返回空结果。 +## hdfs_throw_on_zero_files_match {#hdfs_throw_on_zero_files_match} - - -如果根据 glob 扩展规则匹配了零文件,则抛出错误。 +如果根据 glob 扩展规则匹配到零个文件则抛出错误。 可能的值: - 1 — `SELECT` 抛出异常。 - 0 — `SELECT` 返回空结果。 -## hdfs_truncate_on_insert {#hdfs_truncate_on_insert} - +## hdfs_truncate_on_insert {#hdfs_truncate_on_insert} -启用或禁用在 hdfs 引擎表中插入前截断。如果禁用,则在尝试插入时如果 HDFS 中已存在文件,将抛出异常。 +启用或禁用在 hdfs 引擎表中插入之前进行截断。如果禁用,如果 HDFS 中已存在文件,则在尝试插入时将抛出异常。 可能的值: -- 0 — `INSERT` 查询将新数据添加到文件末尾。 +- 0 — `INSERT` 查询将新数据附加到文件末尾。 - 1 — `INSERT` 查询用新数据替换文件的现有内容。 -## hedged_connection_timeout_ms {#hedged_connection_timeout_ms} - +## hedged_connection_timeout_ms {#hedged_connection_timeout_ms} - - -Hedged 请求时建立与副本的连接超时 -## hnsw_candidate_list_size_for_search {#hnsw_candidate_list_size_for_search} - - - +为 Hedged 请求建立与副本的连接的超时。 +## hnsw_candidate_list_size_for_search {#hnsw_candidate_list_size_for_search} - - -搜索向量相似度索引时的动态候选者列表的大小,也称为 'ef_search'。 -## hsts_max_age {#hsts_max_age} - +搜索向量相似度索引时动态候选列表的大小,也称为 'ef_search'。 +## hsts_max_age {#hsts_max_age} - +HSTS 的过期时间。 0 表示禁用 HSTS。 -HSTS 的过期时间。0表示禁用 HSTS。 ## http_connection_timeout {#http_connection_timeout} - - - - HTTP 连接超时(以秒为单位)。 可能的值: - 任何正整数。 - 0 - 禁用(无限超时)。 -## http_headers_progress_interval_ms {#http_headers_progress_interval_ms} - +## http_headers_progress_interval_ms {#http_headers_progress_interval_ms} - +在每个指定间隔内不要更频繁地发送 HTTP 头 X-ClickHouse-Progress。 -在每个指定的间隔内,勿更频繁地发送 HTTP 头 X-ClickHouse-Progress。 ## http_make_head_request {#http_make_head_request} +`http_make_head_request` 设置允许在从 HTTP 读取数据时执行 `HEAD` 请求,以检索要读取的文件的信息,例如其大小。由于默认启用,因此在服务器不支持 `HEAD` 请求的情况下,可能希望禁用此设置。 - - - -`http_make_head_request` 设置允许在从 HTTP 读取数据时执行 `HEAD` 请求,以检索要读取的文件的信息,例如文件大小。默认情况下启用,在服务器不支持 `HEAD` 请求的情况下,可能希望禁用此设置。 ## http_max_field_name_size {#http_max_field_name_size} +HTTP 头中字段名称的最大长度。 - - - -HTTP 头中字段名称的最大长度 ## http_max_field_value_size {#http_max_field_value_size} +HTTP 头中字段值的最大长度。 - - - -HTTP 头中字段值的最大长度 ## http_max_fields {#http_max_fields} +HTTP 头中的最大字段数量。 - - - -HTTP 头中字段的最大数量 ## http_max_multipart_form_data_size {#http_max_multipart_form_data_size} +对 multipart/form-data 内容大小的限制。此设置不能从 URL 参数解析,应该在用户配置文件中设置。请注意,在查询执行开始之前,会解析内容并在内存中创建外部表。这是唯一对该阶段有效的限制(最大内存使用量和最大执行时间的限制在读取 HTTP 表单数据时没有效果)。 - - - -对 multipart/form-data 内容大小的限制。此设置不能从 URL 参数解析,应该在用户配置文件中设置。请注意,内容是在查询执行开始之前解析的,并在内存中创建外部表。这是对该阶段唯一有效的限制(对最大内存使用和最大执行时间的限制在读取 HTTP 表单数据时没有效果)。 ## http_max_request_param_data_size {#http_max_request_param_data_size} +对用作预定义 HTTP 请求中查询参数的请求数据的大小的限制。 - - - -用于预定义 HTTP 请求中作为查询参数的请求数据大小的限制。 ## http_max_tries {#http_max_tries} - - - - 通过 http 读取的最大尝试次数。 -## http_max_uri_size {#http_max_uri_size} - - - +## http_max_uri_size {#http_max_uri_size} 设置 HTTP 请求的最大 URI 长度。 可能的值: - 正整数。 -## http_native_compression_disable_checksumming_on_decompress {#http_native_compression_disable_checksumming_on_decompress} - - - +## http_native_compression_disable_checksumming_on_decompress {#http_native_compression_disable_checksumming_on_decompress} -启用或禁用从客户端解压缩 HTTP POST 数据时的校验和验证。仅用于 ClickHouse 原生压缩格式(不适用于 `gzip` 或 `deflate`)。 +启用或禁用在从客户端解压 HTTP POST 数据时的校验和验证。仅用于 ClickHouse 原生压缩格式(不使用 `gzip` 或 `deflate`)。 -有关更多信息,请阅读 [HTTP 接口描述](../../interfaces/http.md)。 +有关更多信息,请阅读 [HTTP 接口说明](../../interfaces/http.md)。 可能的值: - 0 — 禁用。 - 1 — 启用。 -## http_receive_timeout {#http_receive_timeout} - +## http_receive_timeout {#http_receive_timeout} - - HTTP 接收超时(以秒为单位)。 @@ -3806,58 +4135,41 @@ HTTP 接收超时(以秒为单位)。 - 任何正整数。 - 0 - 禁用(无限超时)。 -## http_response_buffer_size {#http_response_buffer_size} - +## http_response_buffer_size {#http_response_buffer_size} - +在向客户端发送 HTTP 响应或刷新到磁盘(当 http_wait_end_of_query 启用时)之前要缓冲的字节数。 -在向客户端发送 HTTP 响应或刷新到磁盘(当启用 http_wait_end_of_query 时)之前在服务器内存中缓冲的字节数。 ## http_response_headers {#http_response_headers} - - - - -允许添加或覆盖服务器在成功查询结果中将返回的 HTTP 头。这仅影响 HTTP 接口。 +允许添加或覆盖服务器在成功查询结果的响应中返回的 HTTP 头。这只影响 HTTP 接口。 -如果头已经默认设置,则提供的值将覆盖它。 -如果头未默认设置,则将其添加到头列表中。 -由服务器默认设置并未被此设置覆盖的头将保持不变。 +如果头已经默认设置,提供的值将覆盖它。如果头没有默认设置,它将被添加到头列表中。由服务器默认设置而未被此设置覆盖的头将保留。 -该设置允许将头设置为常量值。目前没有方法将头设置为动态计算的值。 +该设置允许你将头设置为常量值。目前还没有办法将头设置为动态计算的值。 -名称或值不得包含 ASCII 控制字符。 +名称和值都不能包含 ASCII 控制字符。 -如果实现了一个允许用户修改设置但同时基于返回的头做出决定的 UI 应用程序,建议将此设置限制为只读。 - -示例: `SET http_response_headers = '{"Content-Type": "image/png"}'` -## http_retry_initial_backoff_ms {#http_retry_initial_backoff_ms} +如果你实现了允许用户修改设置的 UI 应用程序,同时根据返回的头做出决策,建议将此设置限制为只读。 +示例:`SET http_response_headers = '{"Content-Type": "image/png"}'` +## http_retry_initial_backoff_ms {#http_retry_initial_backoff_ms} - +重试通过 http 读取时的最小回退毫秒数。 -重试通过 http 读取时的回退最小毫秒数 ## http_retry_max_backoff_ms {#http_retry_max_backoff_ms} +重试通过 http 读取时的最大回退毫秒数。 - - - -重试通过 http 读取时的回退最大毫秒数 ## http_send_timeout {#http_send_timeout} - - - - HTTP 发送超时(以秒为单位)。 @@ -3868,87 +4180,114 @@ HTTP 发送超时(以秒为单位)。 - 0 - 禁用(无限超时)。 :::note -仅适用于默认配置文件。更改需要服务器重启才能生效。 +仅适用于默认配置文件。需要重新启动服务器才能使更改生效。 ::: + ## http_skip_not_found_url_for_globs {#http_skip_not_found_url_for_globs} +对具有 HTTP_NOT_FOUND 错误的 glob 跳过 URL。 +## http_wait_end_of_query {#http_wait_end_of_query} + +在服务器端启用 HTTP 响应缓冲。 + +## http_write_exception_in_output_format {#http_write_exception_in_output_format} -对于 HTTP_NOT_FOUND 错误,跳过glob URLs -## http_wait_end_of_query {#http_wait_end_of_query} + +在输出格式中写入异常以生成有效输出。适用于 JSON 和 XML 格式。 +## http_zlib_compression_level {#http_zlib_compression_level} - +设置对 HTTP 请求的响应中数据压缩的级别,如果 [enable_http_compression = 1](#enable_http_compression)。 -启用服务器端的 HTTP 响应缓冲。 -## http_write_exception_in_output_format {#http_write_exception_in_output_format} +可能的值:数字 1 到 9。 +## iceberg_delete_data_on_drop {#iceberg_delete_data_on_drop} + - + +在删除时是否删除所有 iceberg 文件。 +## iceberg_insert_max_bytes_in_data_file {#iceberg_insert_max_bytes_in_data_file} - + -在输出格式中写入异常以产生有效的输出。适用于 JSON 和 XML 格式。 -## http_zlib_compression_level {#http_zlib_compression_level} + +插入操作中 iceberg parquet 数据文件的最大字节数。 +## iceberg_insert_max_rows_in_data_file {#iceberg_insert_max_rows_in_data_file} - + -如果 [enable_http_compression = 1](#enable_http_compression),则设置对 HTTP 请求响应中数据的压缩级别。 + -可能的值: 1 到 9 的数字。 -## iceberg_snapshot_id {#iceberg_snapshot_id} +插入操作中 iceberg parquet 数据文件的最大行数。 +## iceberg_metadata_compression_method {#iceberg_metadata_compression_method} + - + +压缩 `.metadata.json` 文件的方法。 +## iceberg_metadata_log_level {#iceberg_metadata_log_level} - + -使用特定快照 ID 查询 Iceberg 表。 -## iceberg_timestamp_ms {#iceberg_timestamp_ms} + + +控制 Iceberg 表的元数据日志记录级别到 system.iceberg_metadata_log。通常此设置可以为调试目的进行修改。 +可能的值: +- none - 无元数据日志。 +- metadata - 根 metadata.json 文件。 +- manifest_list_metadata - 上述所有 + 来自与快照对应的 avro 清单列表的元数据。 +- manifest_list_entry - 上述所有 + avro 清单列表条目。 +- manifest_file_metadata - 上述所有 + 来源于已遍历的 avro 清单文件的元数据。 +- manifest_file_entry - 上述所有 + 已遍历的 avro 清单文件条目。 +## iceberg_snapshot_id {#iceberg_snapshot_id} + +使用特定快照 ID 查询 Iceberg 表。 - +## iceberg_timestamp_ms {#iceberg_timestamp_ms} -查询 Iceberg 表,使用在特定时间戳下的快照。 -## idle_connection_timeout {#idle_connection_timeout} + + +使用在特定时间戳时的快照查询 Iceberg 表。 - +## idle_connection_timeout {#idle_connection_timeout} -在指定秒数后关闭空闲 TCP 连接的超时。 +在指定时间(以秒为单位)后关闭空闲 TCP 连接的超时。 可能的值: -- 正整数(0 - 立即关闭,0秒后)。 +- 正整数(0 - 立即关闭,0 秒后)。 + ## ignore_cold_parts_seconds {#ignore_cold_parts_seconds} - - -仅在 ClickHouse Cloud 中生效。在 SELECT 查询中排除新数据部分,直到它们被预热(见 [cache_populated_by_fetch](merge-tree-settings.md/#cache_populated_by_fetch))或达到指定的秒数。仅适用于 Replicated-/SharedMergeTree。 +仅在 ClickHouse Cloud 中生效。将新数据片排除在 SELECT 查询之外,直到它们被预热(请参见 [cache_populated_by_fetch](merge-tree-settings.md/#cache_populated_by_fetch))或此多秒钟旧。仅适用于 Replicated-/SharedMergeTree。 + ## ignore_data_skipping_indices {#ignore_data_skipping_indices} -如果查询使用指定的数据跳过索引,则忽略它们。 +如果查询中使用指定的数据跳过索引,则忽略这些索引。 考虑以下示例: @@ -3976,7 +4315,7 @@ SELECT * FROM data WHERE x = 1 AND y = 1 SETTINGS ignore_data_skipping_indices=' SELECT * FROM data WHERE x = 1 AND y = 2 SETTINGS ignore_data_skipping_indices='xy_idx'; ``` -不忽略任何索引的查询: +查询未忽略任何索引: ```sql EXPLAIN indexes = 1 SELECT * FROM data WHERE x = 1 AND y = 2; @@ -4030,143 +4369,109 @@ Expression ((Projection + Before ORDER BY)) ``` 适用于 MergeTree 系列的表。 -## ignore_drop_queries_probability {#ignore_drop_queries_probability} - +## ignore_drop_queries_probability {#ignore_drop_queries_probability} - - -如果启用,服务器将以指定的概率忽略所有 DROP 表查询(对于 Memory 和 JOIN 引擎,替换 DROP 为 TRUNCATE)。用于测试目的 -## ignore_materialized_views_with_dropped_target_table {#ignore_materialized_views_with_dropped_target_table} - +如果启用,服务器将忽略具有指定概率的所有 DROP 表查询(对于 Memory 和 JOIN 引擎,将 DROP 替换为 TRUNCATE)。用于测试目的。 +## ignore_materialized_views_with_dropped_target_table {#ignore_materialized_views_with_dropped_target_table} - - -在推送到视图时忽略具有已删除目标表的物化视图 -## ignore_on_cluster_for_replicated_access_entities_queries {#ignore_on_cluster_for_replicated_access_entities_queries} - +在推送到视图期间忽略有目标表被删除的物化视图。 +## ignore_on_cluster_for_replicated_access_entities_queries {#ignore_on_cluster_for_replicated_access_entities_queries} - +忽略复制访问实体管理查询的 ON CLUSTER 子句。 -忽略用于管理复制访问实体查询的 ON CLUSTER 子句。 ## ignore_on_cluster_for_replicated_named_collections_queries {#ignore_on_cluster_for_replicated_named_collections_queries} - - - - -忽略用于管理复制命名集合查询的 ON CLUSTER 子句。 -## ignore_on_cluster_for_replicated_udf_queries {#ignore_on_cluster_for_replicated_udf_queries} - +忽略复制命名集合管理查询的 ON CLUSTER 子句。 +## ignore_on_cluster_for_replicated_udf_queries {#ignore_on_cluster_for_replicated_udf_queries} - +忽略复制 UDF 管理查询的 ON CLUSTER 子句。 -忽略用于管理复制 UDF 查询的 ON CLUSTER 子句。 ## implicit_select {#implicit_select} - - - - -允许在不使用前导 SELECT 关键字的情况下编写简单的 SELECT 查询,这样可以简单用于计算器样式的用法,例如 `1 + 2` 成为有效查询。 - -在 `clickhouse-local` 中,它默认启用并可以显式禁用。 -## implicit_table_at_top_level {#implicit_table_at_top_level} +允许在不带前导 SELECT 关键字的情况下编写简单的 SELECT 查询,这使得计算器风格的用法变得简单,例如 `1 + 2` 成为有效查询。 +在 `clickhouse-local` 中默认启用,并可以明确禁用。 +## implicit_table_at_top_level {#implicit_table_at_top_level} -如果不为空,顶层不带 FROM 的查询将从该表中读取,而不是 system.one。 +如果不为空,顶层没有 FROM 的查询将从此表读取,而不是 system.one。 + +这在 clickhouse-local 用于输入数据处理。该设置可以由用户明确设置,但不打算用于此类用途。 -这在 clickhouse-local 中用于输入数据处理。 -此设置可以由用户显式设置,但并不打算用于这种类型的使用。 +子查询不受此设置的影响(无论是标量、FROM 还是 IN 子查询)。UNION、INTERSECT、EXCEPT 链的顶层 SELECT 会统一处理并受此设置影响,无论其在括号中分组如何。此设置对视图和分布式查询的影响未指定。 -子查询不受此设置的影响(无论是标量、FROM 还是 IN 子查询)。 -在 UNION、INTERSECT、EXCEPT 链的顶层处的 SELECT 被统一对待并受此设置影响,无论它们在括号中的分组如何。 -此设置如何影响视图和分布式查询并未指定。 +该设置接受表名(然后从当前数据库解析表)或以 'database.table' 形式的限定名称。数据库和表名都必须未加引号 - 仅允许简单标识符。 -该设置接受一个表名(然后从当前数据库解析表)或以 'database.table' 形式的限定名称。 -数据库和表名称必须未加引号 - 只能使用简单标识符。 ## implicit_transaction {#implicit_transaction} - - -如果启用并且还没有处于事务中,则将查询包装在完整事务中(开始 + 提交或回滚) -## input_format_parallel_parsing {#input_format_parallel_parsing} - +如果启用且尚未在事务中,则将查询包装在完整事务中(开始 + 提交或回滚)。 +## input_format_parallel_parsing {#input_format_parallel_parsing} -启用或禁用有序并行解析数据格式。仅支持 [TSV](../../interfaces/formats.md/#tabseparated)、[TSKV](../../interfaces/formats.md/#tskv)、[CSV](../../interfaces/formats.md/#csv) 和 [JSONEachRow](../../interfaces/formats.md/#jsoneachrow) 格式。 +启用或禁用数据格式的顺序保持并行解析。仅支持 [TSV](../../interfaces/formats.md/#tabseparated)、[TSKV](../../interfaces/formats.md/#tskv)、[CSV](../../interfaces/formats.md/#csv) 和 [JSONEachRow](../../interfaces/formats.md/#jsoneachrow) 格式。 可能的值: - 1 — 启用。 -- 0 — 禁用。 -## insert_allow_materialized_columns {#insert_allow_materialized_columns} - - - - - -如果设置启用,允许在 INSERT 中使用物化列。 -## insert_deduplicate {#insert_deduplicate} +- 0 — 禁用。 +## insert_allow_materialized_columns {#insert_allow_materialized_columns} +如果设置启用,允许在 INSERT 中使用物化列。 - +## insert_deduplicate {#insert_deduplicate} -启用或禁用 `INSERT` 的块去重(适用于 Replicated* 表)。 +启用或禁用 `INSERT` 的块去重(对于 Replicated* 表)。 可能的值: - 0 — 禁用。 - 1 — 启用。 -默认情况下,通过 `INSERT` 语句插入到复制表的块会进行去重(请参见 [数据复制](../../engines/table-engines/mergetree-family/replication.md))。 -对于复制表,默认情况下,每个分区只有最近的 100 个块会被去重(请参见 [replicated_deduplication_window](merge-tree-settings.md/#replicated_deduplication_window)、[replicated_deduplication_window_seconds](merge-tree-settings.md/#replicated_deduplication_window_seconds))。 -对于非复制表,请参见 [non_replicated_deduplication_window](merge-tree-settings.md/#non_replicated_deduplication_window)。 +默认情况下,通过 `INSERT` 语句插入到复制表中的块会被去重(请参阅 [数据复制](../../engines/table-engines/mergetree-family/replication.md))。对于复制表,默认情况下,每个分区仅去重最近的 100 个块(请参阅 [replicated_deduplication_window](merge-tree-settings.md/#replicated_deduplication_window)、[replicated_deduplication_window_seconds](merge-tree-settings.md/#replicated_deduplication_window_seconds))。对于未复制的表,请参见 [non_replicated_deduplication_window](merge-tree-settings.md/#non_replicated_deduplication_window)。 + ## insert_deduplication_token {#insert_deduplication_token} -该设置允许用户提供自己在 MergeTree/ReplicatedMergeTree 中的去重语义。 -例如,通过在每个 INSERT 语句中提供唯一值,用户可以避免重复插入的数据被去重。 +该设置允许用户在 MergeTree/ReplicatedMergeTree 中提供自己的去重语义。例如,通过在每个 INSERT 语句中提供一个唯一值,用户可以避免重复插入的数据被去重。 可能的值: - 任何字符串 -`insert_deduplication_token` 仅在不为空时用于去重。 +`insert_deduplication_token` 仅在非空时用于去重。 -对于复制表,默认情况下,每个分区只有最近的 100 个插入会被去重(请参见 [replicated_deduplication_window](merge-tree-settings.md/#replicated_deduplication_window)、[replicated_deduplication_window_seconds](merge-tree-settings.md/#replicated_deduplication_window_seconds))。 -对于非复制表,请参见 [non_replicated_deduplication_window](merge-tree-settings.md/#non_replicated_deduplication_window)。 +对于复制表,默认情况下,每个分区仅去重最近的 100 个插入(请参阅 [replicated_deduplication_window](merge-tree-settings.md/#replicated_deduplication_window)、[replicated_deduplication_window_seconds](merge-tree-settings.md/#replicated_deduplication_window_seconds))。对于未复制的表,请参见 [non_replicated_deduplication_window](merge-tree-settings.md/#non_replicated_deduplication_window)。 :::note -`insert_deduplication_token` 在分区级别有效(和 `insert_deduplication` 校验和相同)。多个分区可以具有相同的 `insert_deduplication_token`。 +`insert_deduplication_token` 在分区级别上工作(与 `insert_deduplication` 校验和相同)。多个分区可以具有相同的 `insert_deduplication_token`。 ::: 示例: @@ -4196,105 +4501,99 @@ SELECT * FROM test_table │ 1 │ └───┘ ``` -## insert_keeper_fault_injection_probability {#insert_keeper_fault_injection_probability} - +## insert_keeper_fault_injection_probability {#insert_keeper_fault_injection_probability} -在插入过程中,keeper 请求的失败的近似概率。有效值范围为 [0.0f, 1.0f] -## insert_keeper_fault_injection_seed {#insert_keeper_fault_injection_seed} - +插入时 keeper 请求的故障概率。有效值在区间 [0.0f, 1.0f] 之间。 +## insert_keeper_fault_injection_seed {#insert_keeper_fault_injection_seed} - +0 - 随机种子,否则为设置值。 -0 - 随机种子,否则为设置的值 ## insert_keeper_max_retries {#insert_keeper_max_retries} -该设置设定了在插入到副本 MergeTree 时 ClickHouse Keeper(或 ZooKeeper)请求的最大重试次数。只有由于网络错误、Keeper 会话超时或请求超时而导致的 Keeper 请求才会被考虑进行重试。 +该设置设置在插入到复制 MergeTree 时 ClickHouse Keeper(或 ZooKeeper)请求的最大重试次数。仅考虑因网络错误、Keeper 会话超时或请求超时而失败的 Keeper 请求。 可能的值: - 正整数。 - 0 — 禁用重试。 -云默认值: `20`。 +云默认值:`20`。 -Keeper 请求的重试在某个超时后进行。超时由以下设置控制: `insert_keeper_retry_initial_backoff_ms`, `insert_keeper_retry_max_backoff_ms`。第一次重试在 `insert_keeper_retry_initial_backoff_ms` 超时后进行。后续的超时将按照如下计算: +Keeper 请求的重试在一定超时后进行。超时由以下设置控制:`insert_keeper_retry_initial_backoff_ms`、`insert_keeper_retry_max_backoff_ms`。第一次重试在 `insert_keeper_retry_initial_backoff_ms` 超时后进行。后续超时将按照以下方式计算: ``` timeout = min(insert_keeper_retry_max_backoff_ms, latest_timeout * 2) ``` -例如,如果 `insert_keeper_retry_initial_backoff_ms=100`, `insert_keeper_retry_max_backoff_ms=10000` 和 `insert_keeper_max_retries=8`,则超时将为 `100, 200, 400, 800, 1600, 3200, 6400, 10000`。 +例如,如果 `insert_keeper_retry_initial_backoff_ms=100`,`insert_keeper_retry_max_backoff_ms=10000`,`insert_keeper_max_retries=8`,则超时将为 `100, 200, 400, 800, 1600, 3200, 6400, 10000`。 -除了容错机制外,重试还致力于提供更好的用户体验——它们可以避免在 INSERT 执行时返回错误,例如在 Keeper 因升级而重启时。 -## insert_keeper_retry_initial_backoff_ms {#insert_keeper_retry_initial_backoff_ms} +除了容错,重试旨在提供更好的用户体验 - 例如,允许在 INSERT 执行期间避免返回错误,如果 Keeper 由于升级而重新启动。 - +## insert_keeper_retry_initial_backoff_ms {#insert_keeper_retry_initial_backoff_ms} -在 INSERT 查询执行过程中,重试失败的 Keeper 请求的初始超时(以毫秒为单位)。 +执行 INSERT 查询时重试失败的 Keeper 请求的初始超时(以毫秒为单位)。 可能的值: - 正整数。 - 0 — 无超时。 -## insert_keeper_retry_max_backoff_ms {#insert_keeper_retry_max_backoff_ms} - +## insert_keeper_retry_max_backoff_ms {#insert_keeper_retry_max_backoff_ms} -在 INSERT 查询执行过程中,重试失败的 Keeper 请求的最大超时(以毫秒为单位)。 +执行 INSERT 查询时重试失败的 Keeper 请求的最大超时(以毫秒为单位)。 可能的值: - 正整数。 - 0 — 最大超时没有限制。 -## insert_null_as_default {#insert_null_as_default} - +## insert_null_as_default {#insert_null_as_default} -启用或禁用在不 [nullable](/sql-reference/data-types/nullable) 数据类型的列中插入 [default values](/sql-reference/statements/create/table#default_values) 代替 [NULL](/sql-reference/syntax)。如果列类型为非可空类型且此设置被禁用,则插入 `NULL` 会引发异常。如果列类型为可空类型,则无论此设置如何, `NULL` 值将原样插入。 +启用或禁用在非 [nullable](/sql-reference/data-types/nullable) 数据类型的列中插入 [默认值](/sql-reference/statements/create/table#default_values) 而不是 [NULL](/sql-reference/syntax#null)。如果列类型非空且此设置禁用,则插入 `NULL` 会导致异常。如果列类型可为空,则无论此设置如何,`NULL` 值都是原样插入的。 -此设置适用于 [INSERT ... SELECT](../../sql-reference/statements/insert-into.md/#inserting-the-results-of-select) 查询。注意 `SELECT` 子查询可以与 `UNION ALL` 子句连接。 +此设置适用于 [INSERT ... SELECT](../../sql-reference/statements/insert-into.md/#inserting-the-results-of-select) 查询。请注意,`SELECT` 子查询可以与 `UNION ALL` 子句连接。 可能的值: -- 0 — 向非可空列插入 `NULL` 会引发异常。 -- 1 — 将默认列值插入而不是 `NULL`。 -## insert_quorum {#insert_quorum} +- 0 — 在非空列中插入 `NULL` 导致异常。 +- 1 — 插入默认列值而不是 `NULL`。 - +## insert_quorum {#insert_quorum} :::note -此设置不适用于 SharedMergeTree,请参阅 [SharedMergeTree consistency](/cloud/reference/shared-merge-tree#consistency) 以获取更多信息。 +此设置不适用于 SharedMergeTree,更多信息请参见 [SharedMergeTree 一致性](/cloud/reference/shared-merge-tree#consistency)。 ::: -启用法定人数写入。 +启用 quorum 写入。 -- 如果 `insert_quorum < 2`,则禁用法定人数写入。 -- 如果 `insert_quorum >= 2`,则启用法定人数写入。 -- 如果 `insert_quorum = 'auto'`,则使用大多数数量(`number_of_replicas / 2 + 1`)作为法定人数。 +- 如果 `insert_quorum < 2`,则禁用 quorum 写入。 +- 如果 `insert_quorum >= 2`,则启用 quorum 写入。 +- 如果 `insert_quorum = 'auto'`,则使用多数数(`number_of_replicas / 2 + 1`)作为 quorum 数。 -法定人数写入 +quorum 写入 -只有当 ClickHouse 成功将数据正确写入 `insert_quorum` 个副本时, `INSERT` 才会成功,在 `insert_quorum_timeout` 内。如果出于任何原因,成功写入的副本的数量没有达到 `insert_quorum`,则写入将被视为失败,ClickHouse 将从所有已写入数据的副本中删除插入的块。 +`INSERT` 仅在 ClickHouse 成功地将数据写入到 `insert_quorum` 的副本中,并在 `insert_quorum_timeout` 内成功完成时才成功。如果由于任何原因,成功写入的副本数量未达到 `insert_quorum`,则视为写入失败,ClickHouse 将从所有已写入数据的副本中删除插入的块。 -当 `insert_quorum_parallel` 被禁用时,法定人数中的所有副本是一致的,即它们包含所有先前 `INSERT` 查询的数据(`INSERT` 序列是线性的)。在读取使用 `insert_quorum` 写入的数据时,如果 `insert_quorum_parallel` 被禁用,可以使用 [select_sequential_consistency](#select_sequential_consistency) 将 `SELECT` 查询的顺序一致性打开。 +当 `insert_quorum_parallel` 被禁用时,quorum 中的所有副本都保持一致,即它们包含所有先前 `INSERT` 查询的数据(`INSERT` 序列是线性化的)。在读取使用 `insert_quorum` 和 `insert_quorum_parallel` 禁用时写入的数据时,可以通过使用 [select_sequential_consistency](#select_sequential_consistency) 开启 `SELECT` 查询的顺序一致性。 ClickHouse 会生成异常: - 如果查询时可用副本的数量少于 `insert_quorum`。 -- 当 `insert_quorum_parallel` 被禁用并尝试写入数据时,如果先前的块尚未插入到 `insert_quorum` 的副本中。用户在前一个 `INSERT` 使用 `insert_quorum` 完成之前尝试对同一表执行另一个 `INSERT` 查询时,可能会发生这种情况。 +- 禁用 `insert_quorum_parallel` 时,如果尝试在上一个块尚未在 `insert_quorum` 的副本中插入时写入数据。这种情况可能发生在用户尝试在上一个带有 `insert_quorum` 的查询完成之前对同一表执行另一个 `INSERT` 查询时。 另请参见: - [insert_quorum_timeout](#insert_quorum_timeout) - [insert_quorum_parallel](#insert_quorum_parallel) - [select_sequential_consistency](#select_sequential_consistency) + ## insert_quorum_parallel {#insert_quorum_parallel} @@ -4302,10 +4601,10 @@ ClickHouse 会生成异常: :::note -此设置不适用于 SharedMergeTree,请参阅 [SharedMergeTree consistency](/cloud/reference/shared-merge-tree#consistency) 以获取更多信息。 +此设置不适用于 SharedMergeTree,更多信息请参见 [SharedMergeTree 一致性](/cloud/reference/shared-merge-tree#consistency)。 ::: -启用或禁用法定人数 `INSERT` 查询的并行性。如果启用,可以在先前的查询尚未完成时发送额外的 `INSERT` 查询。如果禁用,则拒绝对同一表的额外写入。 +启用或禁用 quorum `INSERT` 查询的并行性。如果启用,可以在先前查询尚未完成的情况下发送额外的 `INSERT` 查询。如果禁用,将拒绝对同一表的额外写入。 可能的值: @@ -4317,26 +4616,24 @@ ClickHouse 会生成异常: - [insert_quorum](#insert_quorum) - [insert_quorum_timeout](#insert_quorum_timeout) - [select_sequential_consistency](#select_sequential_consistency) -## insert_quorum_timeout {#insert_quorum_timeout} - +## insert_quorum_timeout {#insert_quorum_timeout} -写入法定人数超时时间(以毫秒为单位)。如果超时已过去且尚未发生写入,ClickHouse 将生成异常,客户端必须重复查询以将同一块写入同一或任意其他副本。 +以毫秒为单位的对 quorum 写入的超时。如果超时已过而尚未进行任何写入,ClickHouse 将生成异常,客户必须重复查询以将同一块写入同一或其他副本。 另请参见: - [insert_quorum](#insert_quorum) - [insert_quorum_parallel](#insert_quorum_parallel) - [select_sequential_consistency](#select_sequential_consistency) -## insert_shard_id {#insert_shard_id} - +## insert_shard_id {#insert_shard_id} -如果不是 `0`,则指定要同步插入数据的 [Distributed](/engines/table-engines/special/distributed) 表的分片。 +如果不为 `0`,则指定将数据同步插入的 [Distributed](/engines/table-engines/special/distributed) 表的分片。 如果 `insert_shard_id` 值不正确,服务器将抛出异常。 -要获取 `requested_cluster` 中的分片数量,您可以检查服务器配置或使用以下查询: +要获取 `requested_cluster` 上的分片数量,您可以检查服务器配置或使用以下查询: ```sql SELECT uniq(shard_num) FROM system.clusters WHERE cluster = 'requested_cluster'; @@ -4347,7 +4644,7 @@ SELECT uniq(shard_num) FROM system.clusters WHERE cluster = 'requested_cluster'; - 0 — 禁用。 - 从 `1` 到相应的 [Distributed](/engines/table-engines/special/distributed) 表的 `shards_num` 的任何数字。 -**例子** +**示例** 查询: @@ -4374,16 +4671,31 @@ SELECT * FROM x_dist ORDER BY number ASC; │ 4 │ └────────┘ ``` + ## interactive_delay {#interactive_delay} - +检查请求执行是否已被取消并发送进度的间隔(以微秒为单位)。 -检查请求执行是否已被取消以及发送进度的间隔,单位为微秒。 ## intersect_default_mode {#intersect_default_mode} - +设置 INTERSECT 查询的默认模式。可能的值:空字符串、'ALL'、'DISTINCT'。如果为空,未指定模式的查询将抛出异常。 + +## jemalloc_collect_profile_samples_in_trace_log {#jemalloc_collect_profile_samples_in_trace_log} + + + + + +在追踪日志中收集 jemalloc 分配和释放样本。 + +## jemalloc_enable_profiler {#jemalloc_enable_profiler} + + + + + +为查询启用 jemalloc 个人分析器。jemalloc 将采样分配及所有已采样分配的释放。可以使用 SYSTEM JEMALLOC FLUSH PROFILE 刷新配置,这可以用于分配分析。样本也可以使用配置 jemalloc_collect_global_profile_samples_in_trace_log 存储在 system.trace_log 中,或使用查询设置 jemalloc_collect_profile_samples_in_trace_log。有关更多信息,请参阅 [分配分析](/operations/allocation-profiling)。 -在 INTERSECT 查询中设置默认模式。可能的值:空字符串,'ALL', 'DISTINCT'。如果为空,未指定模式的查询将抛出异常。 ## join_algorithm {#join_algorithm} @@ -4392,111 +4704,111 @@ SELECT * FROM x_dist ORDER BY number ASC; 指定使用哪个 [JOIN](../../sql-reference/statements/select/join.md) 算法。 -可以指定多个算法,并将根据种类/严格性和表引擎选择可用的算法以供特定查询使用。 +可以指定多个算法,并且会根据类型/严格性和表引擎为特定查询选择可用的算法。 可能的值: - grace_hash - [Grace hash join](https://en.wikipedia.org/wiki/Hash_join#Grace_hash_join) 被使用。Grace hash 提供了一种算法选项,可以在保持内存使用限制的同时提供高效的复杂连接。 + 使用 [Grace hash join](https://en.wikipedia.org/wiki/Hash_join#Grace_hash_join)。Grace hash 提供了一种算法选项,能够在限制内存使用时提高复杂连接的性能。 -Grace join 的第一阶段读取右表,并根据关键列的哈希值将其划分为 N 个桶(最初, N 为 `grace_hash_join_initial_buckets`)。这样做的目的是确保每个桶可以独立处理。第一个桶中的行被添加到内存哈希表中,而其他行则保存在磁盘上。如果哈希表的大小超过内存限制(例如,由 [`max_bytes_in_join`](/operations/settings/settings#max_bytes_in_join) 设置),则增加桶的数量并重新分配每行的桶。任何不属于当前桶的行都会被冲洗并重新分配。 + 配置哈希桶的个数(N),根据关键列的哈希值将右表分割成 N 个桶。每个桶可以独立处理。第一阶段会读取右表并分割,若哈希表超出内存限制(例如,由 [`max_bytes_in_join`](/operations/settings/settings#max_bytes_in_join) 限制),则增大桶的个数并重新分配每行。 -支持 `INNER/LEFT/RIGHT/FULL ALL/ANY JOIN`。 + 支持 `INNER/LEFT/RIGHT/FULL ALL/ANY JOIN`。 - hash - [Hash join algorithm](https://en.wikipedia.org/wiki/Hash_join) 被使用。这是最通用的实现,支持所有种类和严格性及多个连接键在 `JOIN ON` 部分通过 `OR` 组合。 + 使用 [Hash join algorithm](https://en.wikipedia.org/wiki/Hash_join)。最通用的实现,支持所有的类型和严格性、多个用 `OR` 结合的连接键的组合。 -使用 `hash` 算法时, `JOIN` 的右侧部分被加载到 RAM 中。 + 使用 `hash` 算法时,连接的右侧部分会上传到内存。 - parallel_hash - `hash` 连接的一种变体,将数据分为桶,并同时构建多个哈希表以加速该过程。 + `hash` 连接的一种变体,将数据分割成多个桶并同时构建多个哈希表,以加快此过程。 -使用 `parallel_hash` 算法时, `JOIN` 的右侧部分被加载到 RAM 中。 + 使用 `parallel_hash` 算法时,连接的右侧部分会上传到内存。 - partial_merge - 一种 [sort-merge algorithm](https://en.wikipedia.org/wiki/Sort-merge_join) 的变体,其中只有右表是完全排序的。 + [sort-merge algorithm](https://en.wikipedia.org/wiki/Sort-merge_join) 的变体,只有右表是完全排序的。 -`RIGHT JOIN` 和 `FULL JOIN` 仅支持 `ALL` 严格性(不支持 `SEMI`, `ANTI`, `ANY` 和 `ASOF`)。 + 仅支持 `RIGHT JOIN` 和 `FULL JOIN`,且必须采用 `ALL` 的严格性(不支持 `SEMI`、`ANTI`、`ANY` 和 `ASOF`)。 -使用 `partial_merge` 算法时,ClickHouse 对数据进行排序并将其转储到磁盘。ClickHouse 中的 `partial_merge` 算法与经典实现略有不同。首先,ClickHouse 按连接键将右表按块排序并为已排序的块创建 min-max 索引。然后,它按 `join key` 排序左表的部分,并与右表进行连接。min-max 索引也用于跳过不需要的右表块。 + ClickHouse 会按连接键的顺序对右表进行排序,然后将其转储到磁盘,以保证 order 和 min-max 索引的块排序。左侧的数据会被分块排序后,将其与右侧表进行 join。在此操作的过程中,也利用 min-max 索引以跳过右边无需的块。 - direct - 该算法可在右表的存储支持键值请求时应用。 + 此算法可以在右表存储支持键值请求时应用。 - `direct` 算法使用左表的行作为键在右表中执行查找。仅支持特殊存储,如 [Dictionary](/engines/table-engines/special/dictionary) 或 [EmbeddedRocksDB](../../engines/table-engines/integrations/embedded-rocksdb.md),且仅支持 `LEFT` 和 `INNER` JOIN。 + 此 `direct` 算法会使用来自左表的行作为键,在右表中进行查找。仅支持特殊存储,如 [Dictionary](/engines/table-engines/special/dictionary) 或 [EmbeddedRocksDB](../../engines/table-engines/integrations/embedded-rocksdb.md),并仅支持 `LEFT` 和 `INNER` JOIN。 - auto - 当设置为 `auto` 时,会先尝试 `hash` 连接,并在违反内存限制时动态切换到其他算法。 + 设置为 `auto` 时,首先尝试使用 `hash` 进行连接,并在内存限制被违反时动态切换到其他算法。 - full_sorting_merge - 对连接表执行全排序的 [Sort-merge algorithm](https://en.wikipedia.org/wiki/Sort-merge_join)。 + [Sort-merge algorithm](https://en.wikipedia.org/wiki/Sort-merge_join) 在加入之前对连接的表进行完全排序。 - prefer_partial_merge - ClickHouse 始终尝试使用 `partial_merge` 连接,如果不可能,则使用 `hash`。*已弃用*,与 `partial_merge,hash` 相同。 + ClickHouse 始终尝试使用 `partial_merge` 连接,如果不可能,则使用 `hash`。*不推荐使用,与 `partial_merge,hash` 相同。 - default (deprecated) - 过时的值,请不要再使用。 - 与 `direct,hash` 相同,即尝试先使用 direct 连接,然后使用 hash 连接(按此顺序)。 -## join_any_take_last_row {#join_any_take_last_row} + 遗留值,请勿再使用。与 `direct,hash` 相同,也就是说,尝试使用 direct join 和 hash join(按此顺序)。 - +## join_any_take_last_row {#join_any_take_last_row} -更改 `ANY` 严格性连接操作的行为。 +更改 `ANY` 严格性的连接操作行为。 :::note -此设置仅适用于 [Join](../../engines/table-engines/special/join.md) 引擎表的 `JOIN` 操作。 +此设置仅适用于与 [Join](../../engines/table-engines/special/join.md) 引擎表的 `JOIN` 操作。 ::: 可能的值: -- 0 — 如果右表有多条匹配行,则只连接找到的第一条。 -- 1 — 如果右表有多条匹配行,则只连接找到的最后一条。 +- 0 — 如果右表有多个匹配行,则仅连接找到的第一条。 +- 1 — 如果右表有多个匹配行,则连接找到的最后一条。 另请参见: -- [JOIN clause](/sql-reference/statements/select/join) -- [Join table engine](../../engines/table-engines/special/join.md) +- [JOIN 子句](/sql-reference/statements/select/join) +- [Join 表引擎](../../engines/table-engines/special/join.md) - [join_default_strictness](#join_default_strictness) -## join_default_strictness {#join_default_strictness} - +## join_default_strictness {#join_default_strictness} 为 [JOIN 子句](/sql-reference/statements/select/join) 设置默认严格性。 可能的值: -- `ALL` — 如果右表有多条匹配行,ClickHouse 会从匹配行中创建一个 [Cartesian product](https://en.wikipedia.org/wiki/Cartesian_product)。这是标准 SQL 中的正常 `JOIN` 行为。 -- `ANY` — 如果右表有多条匹配行,则只连接找到的第一条。如果右表仅有一条匹配行,则 `ANY` 和 `ALL` 的结果相同。 -- `ASOF` — 用于不确定匹配的序列连接。 -- `空字符串` — 如果查询中未指定 `ALL` 或 `ANY`,ClickHouse 将抛出异常。 -## join_on_disk_max_files_to_merge {#join_on_disk_max_files_to_merge} +- `ALL` — 如果右表有多个匹配行,ClickHouse 会从匹配行中创建一个 [笛卡尔积](https://en.wikipedia.org/wiki/Cartesian_product)。这是标准 SQL 的正常 `JOIN` 行为。 +- `ANY` — 如果右表有多个匹配行,则仅连接找到的第一条。如果右表仅有一行匹配,则 `ANY` 和 `ALL` 的结果是相同的。 +- `ASOF` — 用于连接具有不确定匹配的序列。 +- 空字符串 — 如果查询中未指定 `ALL` 或 `ANY`,ClickHouse 将抛出异常。 - +## join_on_disk_max_files_to_merge {#join_on_disk_max_files_to_merge} -限制在执行磁盘上的 MergeJoin 操作时并行排序允许的文件数量。 +限制在 MergeJoin 操作时允许在磁盘上并行排序的文件数量。 -该设置的值越大,使用的 RAM 越多,而所需的磁盘 I/O 越少。 +设置的值越大,使用的 RAM 越多,磁盘 I/O 需求越少。 可能的值: -- 从 2 开始的任何正整数。 +- 任何正整数,起始值为 2。 + ## join_output_by_rowlist_perkey_rows_threshold {#join_output_by_rowlist_perkey_rows_threshold} -在右表中每个键的平均行数的下限,以确定在哈希连接中是否按行列表输出。 + + +右表中每个键的平均行数的下限,以确定在哈希连接中是否按行列表输出。 + ## join_overflow_mode {#join_overflow_mode} -定义当达到以下任一连接限制时 ClickHouse 执行的操作: +定义 ClickHouse 在达到以下任意连接限制时执行的操作: - [max_bytes_in_join](/operations/settings/settings#max_bytes_in_join) - [max_rows_in_join](/operations/settings/settings#max_rows_in_join) @@ -4504,14 +4816,32 @@ Grace join 的第一阶段读取右表,并根据关键列的哈希值将其划 可能的值: - `THROW` — ClickHouse 抛出异常并中断操作。 -- `BREAK` — ClickHouse 中断操作但不抛出异常。 +- `BREAK` — ClickHouse 中断操作而不抛出异常。 -默认值: `THROW`。 +默认值:`THROW`。 **另请参见** -- [JOIN clause](/sql-reference/statements/select/join) -- [Join table engine](/engines/table-engines/special/join) +- [JOIN 子句](/sql-reference/statements/select/join) +- [Join 表引擎](/engines/table-engines/special/join) + +## join_runtime_bloom_filter_bytes {#join_runtime_bloom_filter_bytes} + + + + + + + +作为 JOIN 运行时过滤器使用的布隆过滤器的大小(以字节为单位)(请参见 enable_join_runtime_filters 设置)。 + +## join_runtime_bloom_filter_hash_functions {#join_runtime_bloom_filter_hash_functions} + + + + + +作为 JOIN 运行时过滤器使用的布隆过滤器中的哈希函数数量(请参见 enable_join_runtime_filters 设置)。 ## join_to_sort_maximum_table_rows {#join_to_sort_maximum_table_rows} @@ -4520,7 +4850,7 @@ Grace join 的第一阶段读取右表,并根据关键列的哈希值将其划 -右表中的最大行数,以确定是否在左或内连接中通过键对右表进行重新排列。 +右表中的最大行数,用于确定在左连接或内连接中是否按键重新排列右表。 ## join_to_sort_minimum_perkey_rows {#join_to_sort_minimum_perkey_rows} @@ -4529,17 +4859,17 @@ Grace join 的第一阶段读取右表,并根据关键列的哈希值将其划 -右表中每个键的平均行数的下限,以确定在左或内连接中是否通过键对右表进行重新排列。此设置确保不对稀疏表键应用优化。 +右表中每个键的平均行数的下限,用于确定在左连接或内连接中是否按键重新排列右表。此设置确保优化不应用于稀疏表键。 ## join_use_nulls {#join_use_nulls} -设置 [JOIN](../../sql-reference/statements/select/join.md) 行为的类型。在合并表时,可能会出现空单元格。ClickHouse 根据此设置以不同方式填充它们。 +设置[JOIN](../../sql-reference/statements/select/join.md)行为的类型。在合并表时,可能会出现空单元格。ClickHouse根据此设置以不同的方式填充它们。 可能的值: - 0 — 空单元格用相应字段类型的默认值填充。 -- 1 — `JOIN` 的行为与标准 SQL 相同。相应字段的类型转换为 [Nullable](/sql-reference/data-types/nullable),空单元格用 [NULL](/sql-reference/syntax) 填充。 +- 1 — `JOIN`的行为与标准SQL相同。相应字段的类型被转换为[Nullable](/sql-reference/data-types/nullable),并且空单元格用[NULL](/sql-reference/syntax)填充。 ## joined_subquery_requires_alias {#joined_subquery_requires_alias} @@ -4547,80 +4877,97 @@ Grace join 的第一阶段读取右表,并根据关键列的哈希值将其划 强制连接子查询和表函数具有别名以进行正确的名称限定。 ## kafka_disable_num_consumers_limit {#kafka_disable_num_consumers_limit} -禁用针对可用 CPU 核心数量的 kafka_num_consumers 限制。 + + +禁用依赖于可用CPU核心数量的kafka_num_consumers限制。 ## kafka_max_wait_ms {#kafka_max_wait_ms} -从 [Kafka](/engines/table-engines/integrations/kafka) 读取消息之前的等待时间(以毫秒为单位)。 + + +从[Kafka](/engines/table-engines/integrations/kafka)读取消息前的等待时间(以毫秒为单位)。 可能的值: - 正整数。 - 0 — 无限超时。 -另请参见: +另见: - [Apache Kafka](https://kafka.apache.org/) ## keeper_map_strict_mode {#keeper_map_strict_mode} -在 KeeperMap 操作期间执行额外检查。例如,在尝试插入已存在的键时抛出异常。 + + +在KeeperMap操作中强制执行额外检查。例如:在插入已存在键时抛出异常。 ## keeper_max_retries {#keeper_max_retries} -一般 Keeper 操作的最大重试次数。 +通用keeper操作的最大重试次数。 ## keeper_retry_initial_backoff_ms {#keeper_retry_initial_backoff_ms} -一般 Keeper 操作的初始回退超时。 + + +通用keeper操作的初始退避超时时间。 ## keeper_retry_max_backoff_ms {#keeper_retry_max_backoff_ms} -一般 Keeper 操作的最大回退超时。 + + +通用keeper操作的最大退避超时时间。 ## least_greatest_legacy_null_behavior {#least_greatest_legacy_null_behavior} -如果启用,函数 'least' 和 'greatest' 如果其任一参数为 NULL 则返回 NULL。 +如果启用,函数'least'和'greatest'在其参数之一为NULL时返回NULL。 ## legacy_column_name_of_tuple_literal {#legacy_column_name_of_tuple_literal} -在大型元组文字中列出其列名的所有元素名称,而不是哈希。此设置仅用于兼容性原因。在将集群从低于 21.7 的版本滚动更新到更高版本时,设置为 'true' 是有意义的。 +将大型元组文字的所有元素名称列在它们的列名称中,而不是哈希。此设置仅出于兼容性原因存在。在将集群从低于21.7版本逐步更新到更高版本时,将其设置为'true'是有意义的。 ## lightweight_delete_mode {#lightweight_delete_mode} -作为轻量级删除一部分执行的内部更新查询模式。 + + +轻量级删除的一种内部更新查询模式。 可能的值: -- `alter_update` - 运行创建重负载变更的 `ALTER UPDATE` 查询。 -- `lightweight_update` - 如果可能运行轻量级更新,否则运行 `ALTER UPDATE`。 -- `lightweight_update_force` - 如果可能运行轻量级更新,否则抛出异常。 +- `alter_update` - 运行创建较重突变的`ALTER UPDATE`查询。 +- `lightweight_update` - 在可能的情况下运行轻量级更新,否则运行`ALTER UPDATE`。 +- `lightweight_update_force` - 若可能则运行轻量级更新,否则抛出异常。 ## lightweight_deletes_sync {#lightweight_deletes_sync} -与 [`mutations_sync`](#mutations_sync) 相同,但仅控制轻量级删除的执行。 + + +与[`mutations_sync`](#mutations_sync)相同,但仅控制轻量级删除的执行。 可能的值: -- 0 - 变更异步执行。 -- 1 - 查询在当前服务器上等待轻量级删除完成。 -- 2 - 查询等待所有副本(如果存在)上的轻量级删除完成。 +| 值 | 描述 | +|------|--------------------------------------------------------------------------------------------------------------------------------------------------| +| `0` | 突变异步执行。 | +| `1` | 查询等待当前服务器上的轻量级删除完成。 | +| `2` | 查询等待所有副本(如果存在)的轻量级删除完成。 | +| `3` | 查询仅等待活动副本。仅支持`SharedMergeTree`。对于`ReplicatedMergeTree`,它的行为与`mutations_sync = 2`相同。 | -**另请参见** +**另见** - [ALTER 查询的同步性](../../sql-reference/statements/alter/index.md/#synchronicity-of-alter-queries) -- [变更](../../sql-reference/statements/alter/index.md/#mutations) +- [突变](../../sql-reference/statements/alter/index.md/#mutations) ## limit {#limit} -设置从查询结果获取的最大行数。它调整由 [LIMIT](/sql-reference/statements/select/limit) 子句设置的值,因此查询中指定的限制不能超过由此设置设置的限制。 +设置从查询结果中获取的最大行数。它会调整由[LIMIT](/sql-reference/statements/select/limit)子句设置的值,以确保查询中指定的限制不能超过该设置所设定的限制。 可能的值: @@ -4632,21 +4979,23 @@ Grace join 的第一阶段读取右表,并根据关键列的哈希值将其划 -在秒为单位的心跳间隔,以指示实时查询仍然活着。 +心跳间隔(以秒为单位),以指示实时查询存活。 ## load_balancing {#load_balancing} + + 指定用于分布式查询处理的副本选择算法。 -ClickHouse 支持以下选择副本的算法: +ClickHouse支持以下副本选择算法: - [随机](#load_balancing-random)(默认) -- [最近的主机名](#load_balancing-nearest_hostname) -- [主机名编辑距离](#load_balancing-hostname_levenshtein_distance) +- [最近主机名](#load_balancing-nearest_hostname) +- [主机名的levenshtein距离](#load_balancing-hostname_levenshtein_distance) - [按顺序](#load_balancing-in_order) - [第一个或随机](#load_balancing-first_or_random) - [轮询](#load_balancing-round_robin) -另请参见: +另见: - [distributed_replica_max_ignored_errors](#distributed_replica_max_ignored_errors) ### 随机(默认) {#load_balancing-random} @@ -4655,28 +5004,28 @@ ClickHouse 支持以下选择副本的算法: load_balancing = random ``` -每个副本的错误数量被计数。查询被发送到错误最少的副本,如果有多个副本,则发送到其中任何一个。 -缺点:未考虑服务器邻近性;如果副本有不同的数据,您也会得到不同的数据。 -### 最近的主机名 {#load_balancing-nearest_hostname} +为每个副本计算错误数量。查询发送到错误最少的副本,如果有多个这样的副本,则发送到任意一个。 +缺点:不考虑服务器的接近性;如果副本具有不同的数据,您将获得不同的数据。 +### 最近主机名 {#load_balancing-nearest_hostname} ```sql load_balancing = nearest_hostname ``` -每个副本的错误数量被计数。每 5 分钟,错误数量被整体除以 2。这样,错误数量是基于最近时间的指数平滑计算的。如果有一个副本的错误数量最少(即最近在其他副本上发生了错误),查询将发送到该副本。如果有多个副本的错误数量相同,查询将发送到配置文件中主机名与服务器主机名最相似的副本(在相同位置有不同字符数量,最多等于两个主机名的最小长度)。 +为每个副本计算错误数量。每5分钟,错误数量会被整除以2。因此,错误数量是根据近期时间计算的,带有指数平滑。如果只有一个副本具有最少的错误(即最近在其他副本上发生了错误),查询会发送到该副本。如果有多个副本具有相同数量的最少错误,则查询发送到与配置文件中服务器的主机名最相似的副本(在相同位置不同字符的数量,直到两个主机名的最小长度)。 -例如,example01-01-1 和 example01-01-2 在一个位置不同,而 example01-01-1 和 example01-02-2 在两个位置不同。 -这种方法可能看起来简单,但是它不需要网络拓扑的外部数据,也不比较 IP 地址,这在我们的 IPv6 地址中会很复杂。 +例如,example01-01-1和example01-01-2在一个位置不同,而example01-01-1和example01-02-2在两个位置不同。 +这种方法可能看起来原始,但它不需要网络拓扑的外部数据,并且不比较IP地址,这对于我们的IPv6地址来说是复杂的。 -因此,如果存在等效副本,首选名称相似度最高的副本。 -我们还可以假设在没有故障的情况下,向同一服务器发送查询时,分布式查询也将发送到相同的服务器。因此,即使副本中放置了不同的数据,查询返回的结果仍然大致相同。 -### 主机名编辑距离 {#load_balancing-hostname_levenshtein_distance} +因此,如果存在等效副本,按名称最接近的副本会被优先选择。 +我们还可以假设,当向同一个服务器发送查询时,在没有失败的情况下,分布式查询也会发到相同的服务器上。因此,即使副本上放置了不同的数据,查询也会返回大致相同的结果。 +### 主机名的levenshtein距离 {#load_balancing-hostname_levenshtein_distance} ```sql load_balancing = hostname_levenshtein_distance ``` -与 `nearest_hostname` 类似,但它以 [编辑距离](https://en.wikipedia.org/wiki/Levenshtein_distance) 的方式比较主机名。例如: +与`nearest_hostname`相似,但以[levenshtein距离](https://en.wikipedia.org/wiki/Levenshtein_distance)的方式比较主机名。例如: ```text example-clickhouse-0-0 ample-clickhouse-0-0 @@ -4694,64 +5043,68 @@ example-clickhouse-0-0 example-clickhouse-12-0 load_balancing = in_order ``` -具有相同错误数量的副本以配置中指定的顺序访问。 -当确切知道哪个副本更可取时,此方法是合适的。 +访问具有相同错误数的副本的顺序与它们在配置中的说明顺序相同。 +此方法适用于确切知道哪个副本更可取的情况。 ### 第一个或随机 {#load_balancing-first_or_random} ```sql load_balancing = first_or_random ``` -该算法选择设置中的第一个副本或随机副本,如果第一个不可用。在交叉复制作拓扑设置中有效,但在其他配置中没有用。 +此算法选择集合中的第一个副本,如果第一个不可用,则选择随机副本。在交叉复制拓扑设置中有效,但在其他配置中无用。 -`first_or_random` 算法解决了 `in_order` 算法的问题。通过 `in_order`,如果一个副本关闭,下一个副本将承受双重负担,而其他副本处理常规流量。当使用 `first_or_random` 算法时,负载将在仍然可用的副本之间均匀分配。 +`first_or_random`算法解决了`in_order`算法的问题。使用`in_order`时,如果一个副本宕机,接下来的副本会负担双重负载,而其余副本处理正常的流量。使用`first_or_random`算法时,负载在仍然可用的副本之间均匀分配。 -可以使用设置 `load_balancing_first_offset` 明确指定第一个副本。这使得在副本之间重新平衡查询工作负载具有更大的控制权。 +可以通过使用设置`load_balancing_first_offset`显式定义第一个副本。这使得在副本之间重新平衡查询负载有了更多的控制。 ### 轮询 {#load_balancing-round_robin} ```sql load_balancing = round_robin ``` -该算法在错误数量相同的副本之间使用轮询策略(仅计入具有 `round_robin` 策略的查询)。 +此算法采用轮询策略在具有相同错误数的副本间进行分配(只有使用`round_robin`策略的查询才被计算)。 ## load_balancing_first_offset {#load_balancing_first_offset} -在使用 FIRST_OR_RANDOM 负载均衡策略时,首选将查询发送到哪个副本。 +在使用FIRST_OR_RANDOM负载均衡策略时,优先发送查询的副本。 ## load_marks_asynchronously {#load_marks_asynchronously} -异步加载 MergeTree 标记。 + + +异步加载MergeTree标记。 ## local_filesystem_read_method {#local_filesystem_read_method} -从本地文件系统读取数据的方法之一:read、pread、mmap、io_uring、pread_threadpool。 + -'io_uring' 方法是实验性的,不适用于 Log、TinyLog、StripeLog、File、Set 和 Join 等在并发读取和写入时具有追加文件的表。 -如果您在互联网上阅读有关 'io_uring' 的各种文章,请不要被其迷惑。除非是在大量小 IO 请求的情况下,这种读取文件方法并不是更好的方法,而这在 ClickHouse 中并不是这种情况。没有理由启用 'io_uring'。 +从本地文件系统读取数据的方法:read, pread, mmap, io_uring, pread_threadpool。 + +'io_uring'方法为实验性,且在存在并发读取和写入的情况下,不能用于Log, TinyLog, StripeLog, File, Set和Join等表。 +如果您在互联网上查看关于'io_uring'的各种文章,请不要被其所蒙蔽。它并不是读取文件的更好方法,除非在大量小IO请求的情况下,而这在ClickHouse中并不适用。没有理由启用'io_uring'。 ## local_filesystem_read_prefetch {#local_filesystem_read_prefetch} -在从本地文件系统读取数据时应使用预提取。 +在从本地文件系统读取数据时应使用预读取。 ## lock_acquire_timeout {#lock_acquire_timeout} -定义锁定请求等待失败的时间(以秒为单位)。 +定义锁定请求在失败之前等待的秒数。 -锁定超时用于在执行带有表的读/写操作时防止死锁。当超时到期且锁定请求失败时,ClickHouse 服务器会抛出异常 "锁定尝试超时!可能已避免死锁。客户端应重试。",错误代码为 `DEADLOCK_AVOIDED`。 +锁定超时旨在在执行读/写表操作时防止死锁。当超时到期并且锁定请求失败时,ClickHouse服务器抛出异常“锁定尝试超时!可能已避免死锁。客户端应重试。”错误代码为`DEADLOCK_AVOIDED`。 可能的值: - 正整数(以秒为单位)。 -- 0 — 无锁定超时。 +- 0 — 没有锁定超时。 ## log_comment {#log_comment} -指定 [system.query_log](../system-tables/query_log.md) 表的 `log_comment` 字段的值及服务器日志的注释文本。 +指定[system.query_log](../system-tables/query_log.md)表中`log_comment`字段的值以及服务器日志的注释文本。 -它可以用于提高服务器日志的可读性。此外,它有助于从运行 [clickhouse-test](../../development/tests.md) 后在 `system.query_log` 中选择与测试相关的查询。 +它可以用来提高服务器日志的可读性。此外,它有助于选择与测试相关的查询,从而可以在运行[clickhouse-test](../../development/tests.md)后从`system.query_log`中筛选。 可能的值: -- 任何长度不超过 [max_query_size](#max_query_size) 的字符串。如果超过了 max_query_size,服务器将抛出异常。 +- 任何不超过[max_query_size](#max_query_size)的字符串。如果超出max_query_size,服务器将抛出异常。 -**例子** +**示例** 查询: @@ -4774,7 +5127,7 @@ SELECT type, query FROM system.query_log WHERE log_comment = 'log_comment test' -允许将格式化查询记录到 [system.query_log](../../operations/system-tables/query_log.md) 系统表中(填充 `formatted_query` 列到 [system.query_log](../../operations/system-tables/query_log.md))。 +允许将格式化查询记录到[system.query_log](../../operations/system-tables/query_log.md)系统表中(填充[`formatted_query`](../../operations/system-tables/query_log.md)列)。 可能的值: @@ -4784,20 +5137,20 @@ SELECT type, query FROM system.query_log WHERE log_comment = 'log_comment test' -将处理器在执行/等待数据期间花费的时间写入 `system.processors_profile_log` 表。 +记录处理器在执行/等待数据期间花费的时间到`system.processors_profile_log`表。 -另请参见: +另见: - [`system.processors_profile_log`](../../operations/system-tables/processors_profile_log.md) - [`EXPLAIN PIPELINE`](../../sql-reference/statements/explain.md/#explain-pipeline) ## log_profile_events {#log_profile_events} -将查询性能统计信息记录到 query_log、query_thread_log 和 query_views_log 中。 +将查询性能统计信息记录到query_log、query_thread_log和query_views_log中。 ## log_queries {#log_queries} 设置查询日志记录。 -使用此设置发送到 ClickHouse 的查询将根据 [query_log](../../operations/server-configuration-parameters/settings.md/#query_log) 服务器配置参数中的规则进行记录。 +根据[query_log](../../operations/server-configuration-parameters/settings.md/#query_log)服务器配置参数中的规则,借助此设置发送到ClickHouse的查询将被记录。 示例: @@ -4808,24 +5161,28 @@ log_queries=1 -如果查询长度超过指定的阈值(以字节为单位),则在写入查询日志时切割查询。还限制普通文本日志中打印的查询长度。 +如果查询长度超过指定阈值(以字节为单位),则在写入查询日志时截断查询。同时限制普通文本日志中打印查询的长度。 ## log_queries_min_query_duration_ms {#log_queries_min_query_duration_ms} -如果启用(非零),则执行速度快于此设置值的查询将不会被记录(您可以将其视为 [MySQL Slow Query Log](https://dev.mysql.com/doc/refman/5.7/slow-query-log.html) 的 `long_query_time`),这基本上意味着您将不会在以下表中找到它们: + + +如果启用(非零),则比该设置值快的查询将不会被记录(可以将其视为[MySQL慢查询日志](https://dev.mysql.com/doc/refman/5.7/slow-query-log.html)的`long_query_time`),这基本上意味着您在以下表中找不到它们: - `system.query_log` - `system.query_thread_log` -只有以下类型的查询会进入日志: +只有以下类型的查询将进入日志: - `QUERY_FINISH` - `EXCEPTION_WHILE_PROCESSING` - 类型:毫秒 -- 默认值:0(任何查询)。 +- 默认值:0(任何查询) ## log_queries_min_type {#log_queries_min_type} -`query_log` 最小类型的日志。 + + +`query_log`记录的最小类型。 可能的值: - `QUERY_START` (`=1`) @@ -4833,28 +5190,30 @@ log_queries=1 - `EXCEPTION_BEFORE_START` (`=3`) - `EXCEPTION_WHILE_PROCESSING` (`=4`) -可以用来限制哪些条目会进入 `query_log`,例如如果您只对错误感兴趣,则可以使用 `EXCEPTION_WHILE_PROCESSING`: +可以用来限制哪些实体将进入`query_log`,比如如果您只对错误感兴趣,可以使用`EXCEPTION_WHILE_PROCESSING`: ```text log_queries_min_type='EXCEPTION_WHILE_PROCESSING' ``` ## log_queries_probability {#log_queries_probability} -允许用户以指定概率仅随机写入 [query_log](../../operations/system-tables/query_log.md)、[query_thread_log](../../operations/system-tables/query_thread_log.md) 和 [query_views_log](../../operations/system-tables/query_views_log.md) 系统表中的一部分查询。这有助于在每秒查询量大时减少负载。 + + +允许用户将查询写入[query_log](../../operations/system-tables/query_log.md)、[query_thread_log](../../operations/system-tables/query_thread_log.md)和[query_views_log](../../operations/system-tables/query_views_log.md)系统表中,仅根据指定概率随机选择一部分查询。这有助于减少每秒查询量大的负载。 可能的值: - 0 — 查询不记录在系统表中。 -- 0 到 1 之间的正浮点数。例如,如果设置值为 `0.5`,大约一半的查询将记录在系统表中。 -- 1 — 所有查询都记录在系统表中。 +- 正浮点数,范围在[0..1]内。例如,如果设置值为`0.5`,则大约一半的查询将记录在系统表中。 +- 1 — 所有查询记录在系统表中。 ## log_query_settings {#log_query_settings} -将查询设置记录到 query_log 和 OpenTelemetry span 日志中。 +将查询设置记录到query_log和OpenTelemetry跨度日志中。 ## log_query_threads {#log_query_threads} 设置查询线程日志记录。 -查询线程记录到 [system.query_thread_log](../../operations/system-tables/query_thread_log.md) 表中。仅当 [log_queries](#log_queries) 为真时,使用此设置启动的 ClickHouse 查询线程将根据 [query_thread_log](/operations/server-configuration-parameters/settings#query_thread_log) 服务器配置参数中的规则进行记录。 +查询线程记录到[system.query_thread_log](../../operations/system-tables/query_thread_log.md)表中。当[log_queries](#log_queries)为true时,此设置有效。通过ClickHouse运行的查询线程在此设置下将根据[query_thread_log](/operations/server-configuration-parameters/settings#query_thread_log)服务器配置参数中的规则被记录。 可能的值: @@ -4872,7 +5231,7 @@ log_query_threads=1 设置查询视图日志记录。 -当 ClickHouse 运行的查询与此设置启用时关联的视图(物化视图或实时视图)会在 [query_views_log](/operations/server-configuration-parameters/settings#query_views_log) 服务器配置参数中记录。 +当ClickHouse以此设置启用的方式运行查询时,如果有关联的视图(物化或实时视图),则会在[query_views_log](/operations/server-configuration-parameters/settings#query_views_log)服务器配置参数中记录。 示例: @@ -4883,21 +5242,21 @@ log_query_views=1 -允许或限制在 [Native](../../interfaces/formats.md/#native) 格式中使用 [LowCardinality](../../sql-reference/data-types/lowcardinality.md) 数据类型。 +允许或限制在[NATIVE](../../interfaces/formats.md/#native)格式中使用[LowCardinality](../../sql-reference/data-types/lowcardinality.md)数据类型。 -如果限制使用 `LowCardinality`,ClickHouse 服务器将在 `SELECT` 查询中将 `LowCardinality` 列转换为普通列,并在 `INSERT` 查询中将普通列转换为 `LowCardinality` 列。 +如果限制使用`LowCardinality`,ClickHouse服务器会在`SELECT`查询中将`LowCardinality`列转换为普通列,并在`INSERT`查询中将普通列转换为`LowCardinality`列。 -此设置主要用于不支持 `LowCardinality` 数据类型的第三方客户端。 +此设置主要针对不支持`LowCardinality`数据类型的第三方客户端。 可能的值: -- 1 — 不限制使用 `LowCardinality`。 -- 0 — 限制使用 `LowCardinality`。 +- 1 — 不限制使用`LowCardinality`。 +- 0 — 限制使用`LowCardinality`。 ## low_cardinality_max_dictionary_size {#low_cardinality_max_dictionary_size} -设置可以写入存储文件系统的 [LowCardinality](../../sql-reference/data-types/lowcardinality.md) 数据类型共享全局字典的最大行数。此设置防止字典无限增长而出现内存问题。 ClickHouse 将以普通方法写入因最大字典大小限制而无法编码的所有数据。 +设置可写入存储文件系统的[LowCardinality](../../sql-reference/data-types/lowcardinality.md)数据类型的共享全局字典的最大行数。此设置防止在字典无限增长的情况下出现内存问题。所有由于最大字典大小限制而无法编码的数据,ClickHouse将以普通方式写入。 可能的值: @@ -4906,9 +5265,9 @@ log_query_views=1 -启用或禁用对数据部分使用单个字典。 +打开或关闭为数据部分使用单个字典。 -默认情况下,ClickHouse 服务器监控字典的大小,如果字典溢出,则服务器开始写入下一个字典。要禁止为数据部分创建多个字典,请设置 `low_cardinality_use_single_dictionary_for_part = 1`。 +默认情况下,ClickHouse服务器监视字典的大小,如果字典溢出,则服务器开始写入下一个字典。要禁止为数据部分创建多个字典,请设置`low_cardinality_use_single_dictionary_for_part = 1`。 可能的值: @@ -4918,316 +5277,206 @@ log_query_views=1 - - - - -当查询优先级机制被应用时(参见设置 `priority`),低优先级查询会等待高优先级查询完成。此设置指定等待的持续时间。 +当采用查询优先级机制时(参见设置`priority`),低优先级查询在高优先级查询完成之前等待。此设置指定了等待的持续时间。 ## make_distributed_plan {#make_distributed_plan} - - - - 生成分布式查询计划。 ## materialize_skip_indexes_on_insert {#materialize_skip_indexes_on_insert} - - +如果INSERT构建并存储跳过索引。如果禁用,则跳过索引仅在[合并](merge-tree-settings.md/#materialize_skip_indexes_on_merge)或通过显式[MATERIALIZE INDEX](/sql-reference/statements/alter/skipping-index.md/#materialize-index)构建和存储。 - - - -如果INSERT操作构建并存储跳过索引。如果禁用,跳过索引将在合并时构建和存储或通过显式 MATERIALIZE INDEX。 +另见[exclude_materialize_skip_indexes_on_insert](#exclude_materialize_skip_indexes_on_insert)。 ## materialize_statistics_on_insert {#materialize_statistics_on_insert} - - - - - - -如果INSERT操作构建并插入统计数据。如果禁用,统计信息将在合并时构建和存储或通过显式 MATERIALIZE STATISTICS。 +如果INSERT构建并插入统计信息。如果禁用,则统计信息将在合并期间或通过显式MATERIALIZE STATISTICS构建和存储。 ## materialize_ttl_after_modify {#materialize_ttl_after_modify} - - - - -在ALTER MODIFY TTL 查询后,对旧数据应用生存时间(TTL)。 +应用旧数据的TTL,后跟ALTER MODIFY TTL查询。 ## materialized_views_ignore_errors {#materialized_views_ignore_errors} +允许忽略MATERIALIZED VIEW的错误,无论MV仍将原始块传递给表。 +## materialized_views_squash_parallel_inserts {#materialized_views_squash_parallel_inserts} + - - -允许忽略物化视图的错误,并将原始块传递到表中,而不管物化视图的情况。 +压缩来自平行插入的单个INSERT查询到物化视图目标表的插入,减少生成的部分数量。 +如果设置为false并且`parallel_view_processing`启用,INSERT查询将为每个`max_insert_thread`在目标表中生成部分。 ## max_analyze_depth {#max_analyze_depth} - - - - 解释器执行的最大分析次数。 ## max_ast_depth {#max_ast_depth} - - - - -查询语法树的最大嵌套深度。如果超出,则抛出异常。 +查询语法树的最大嵌套深度。如果超过,则抛出异常。 :::note -此时,这个检查只在解析之后而非解析期间进行。 -这意味着在解析期间可以生成一个过深的语法树, -但查询将失败。 +目前,它在解析期间未进行检查,而是在解析完查询后进行检查。 +这意味着在解析过程中可能会创建一个过深的语法树,但查询会失败。 ::: ## max_ast_elements {#max_ast_elements} - - - - -查询语法树中元素的最大数量。如果超出,则抛出异常。 +查询语法树中元素的最大数量。如果超过,则抛出异常。 :::note -此时,这个检查只在解析之后而非解析期间进行。 -这意味着在解析期间可以生成一个过深的语法树, -但查询将失败。 +目前,它在解析期间未进行检查,而是在解析完查询后进行检查。 +这意味着在解析过程中可能会创建一个过深的语法树,但查询会失败。 ::: ## max_autoincrement_series {#max_autoincrement_series} - - - - -由 `generateSeriesID` 函数创建的序列的最大数量。 +由`generateSeriesID`函数创建的系列数的限制。 -由于每个序列代表 Keeper 中的一个节点,建议不超过几百万个序列。 +由于每个系列表示Keeper中的一个节点,建议不超过几百万个系列。 ## max_backup_bandwidth {#max_backup_bandwidth} - - - - -特定备份的最大读取速度(字节/秒)。零表示无限制。 +特定备份在服务器上每秒的最大读取速度(以字节为单位)。零表示无限制。 ## max_block_size {#max_block_size} +在ClickHouse中,数据是通过块处理的,块是列部分的集合。单个块的内部处理周期高效,但处理每个块时会产生明显的开销。 +`max_block_size`设置指示从表加载数据时单个块中包含的推荐最大行数。大小为`max_block_size`的块不会始终从表中加载:如果ClickHouse确定需要检索的数据较少,则会处理较小的块。 - - -在 ClickHouse 中,数据通过块处理,块是一组列部分。单个块的内部处理周期是高效的,但处理每个块时会产生明显的成本。 - -`max_block_size` 设置指示在从表加载数据时,单个块中应包含的最大行数。大小为 `max_block_size` 的块并不总是从表中加载:如果 ClickHouse 确定需要检索的数据量较少,则处理较小的块。 - -块大小不应太小,以避免在处理每个块时产生明显的成本。也不应太大,以确保在处理第一个块后带有 LIMIT 子句的查询快速执行。设置 `max_block_size` 时,目标应避免在多个线程中提取大量列时消耗过多内存,并尽量保持一定的缓存局部性。 +块大小不应太小,以避免在处理每个块时产生明显的开销。它也不应太大,以确保在处理第一个块后,带有LIMIT子句的查询可以快速执行。在设置`max_block_size`时,目标应是避免在多线程中提取大量列时消耗过多内存,并保持至少一些缓存局部性。 ## max_bytes_before_external_group_by {#max_bytes_before_external_group_by} +云的默认值:每个副本内存量的一半。 +启用或禁用在外部内存中执行`GROUP BY`子句。 +(参见[在外部内存中的GROUP BY](/sql-reference/statements/select/group-by#group-by-in-external-memory)) - - -云默认值:每个副本内存量的一半。 - -使能或禁用在外部内存中执行 `GROUP BY` 子句。 -(参见 [外部内存中的 GROUP BY](/sql-reference/statements/select/group-by#group-by-in-external-memory)) - -可能值: +可能的值: -- 单个 [GROUP BY](/sql-reference/statements/select/group-by) 操作可以使用的最大 RAM 量(字节)。 -- `0` — 禁用外部内存中的 `GROUP BY`。 +- 单个[GROUP BY](/sql-reference/statements/select/group-by)操作可以使用的最大RAM量(以字节为单位)。 +- `0` — 在外部内存中禁用`GROUP BY`。 :::note -如果在 GROUP BY 操作期间的内存使用超过此字节阈值, -则激活“外部聚合”模式(溢出数据到磁盘)。 +如果GROUP BY操作期间的内存使用超过该阈值(以字节为单位),则激活“外部聚合”模式(将数据溢出到磁盘)。 -推荐值是可用系统内存的一半。 +推荐值为可用系统内存的一半。 ::: ## max_bytes_before_external_sort {#max_bytes_before_external_sort} +云的默认值:每个副本内存量的一半。 +启用或禁用在外部内存中执行`ORDER BY`子句。参见[ORDER BY实现细节](../../sql-reference/statements/select/order-by.md#implementation-details) +如果ORDER BY操作期间的内存使用超过该阈值(以字节为单位),则激活“外部排序”模式(将数据溢出到磁盘)。 - - -云默认值:每个副本内存量的一半。 - -使能或禁用在外部内存中执行 `ORDER BY` 子句。查看 [ORDER BY 实现细节](../../sql-reference/statements/select/order-by.md#implementation-details) -如果 ORDER BY 操作期间的内存使用超过此字节阈值,则激活“外部排序”模式(溢出数据到磁盘)。 - -可能值: +可能的值: -- 单个 [ORDER BY](../../sql-reference/statements/select/order-by) 操作可以使用的最大 RAM 量(字节)。 - 推荐值是可用系统内存的一半。 -- `0` — 禁用外部内存中的 `ORDER BY`。 +- 单个[ORDER BY](../../sql-reference/statements/select/order-by.md)操作可以使用的最大RAM量(以字节为单位)。 + 推荐值为可用系统内存的一半 +- `0` — 在外部内存中禁用`ORDER BY`。 ## max_bytes_before_remerge_sort {#max_bytes_before_remerge_sort} - - - - -在带有 LIMIT 的 ORDER BY 情况下,当内存使用高于指定阈值时,在最终合并之前执行附加的块合并步骤,以确保仅保留顶部 LIMIT 行。 +在ORDER BY与LIMIT的情况下,当内存使用高于指定阈值时,在最终合并之前执行额外的合并步骤,以仅保持顶级LIMIT行。 ## max_bytes_in_distinct {#max_bytes_in_distinct} - - - - -使用 DISTINCT 时,哈希表的状态的最大字节数(以未压缩字节计算)。 +用于DISTINCT时,状态在内存中最大使用的字节数(以未压缩字节为单位),通过哈希表使用。 ## max_bytes_in_join {#max_bytes_in_join} +表连接时使用的哈希表的最大字节数。 +此设置适用于[SELECT ... JOIN](/sql-reference/statements/select/join)操作和[Join表引擎](/engines/table-engines/special/join)。 - - -在连接表时使用的哈希表的最大字节数。 - -此设置适用于 [SELECT ... JOIN](/sql-reference/statements/select/join) -操作和 [Join 表引擎](/engines/table-engines/special/join)。 - -如果查询包含连接,ClickHouse 会检查此设置的每个中间结果。 +如果查询包含连接,ClickHouse会检查每个中间结果的此设置。 -当达到限制时,ClickHouse 可以执行不同的操作。使用 [join_overflow_mode](/operations/settings/settings#join_overflow_mode) 设置来选择操作。 +当达到限制时,ClickHouse可以执行不同的一步。使用[join_overflow_mode](/operations/settings/settings#join_overflow_mode)设置来选择行动方案。 -可能值: +可能的值: - 正整数。 - 0 — 禁用内存控制。 ## max_bytes_in_set {#max_bytes_in_set} - - - - -从子查询创建的 IN 子句中使用的集合的最大字节数(未压缩数据)。 +由子查询创建的IN子句中的集合使用的最大字节数(未压缩数据)。 ## max_bytes_ratio_before_external_group_by {#max_bytes_ratio_before_external_group_by} - - - - -允许用于 `GROUP BY` 的可用内存比例。一旦达到此比例, -将使用外部内存进行聚合。 +允许用于`GROUP BY`的可用内存的比率。一旦达到,将使用外部内存进行聚合。 -例如,如果设置为 `0.6`,`GROUP BY` 将允许在执行开始时使用可用内存的 60%(对于服务器/用户/合并), -之后将开始使用外部聚合。 +例如,设置为`0.6`,`GROUP BY`将允许在执行开始时使用60%的可用内存(用于服务器/用户/合并),之后将开始使用外部聚合。 ## max_bytes_ratio_before_external_sort {#max_bytes_ratio_before_external_sort} - - - - -允许用于 `ORDER BY` 的可用内存比例。一旦达到此比例, -将使用外部排序。 - -例如,如果设置为 `0.6`,`ORDER BY` 将允许在执行开始时使用可用内存的 60%(对于服务器/用户/合并), -之后将开始使用外部排序。 -## max_bytes_to_read {#max_bytes_to_read} +允许用于`ORDER BY`的可用内存的比率。一旦达到,将使用外部排序。 +例如,设置为`0.6`,`ORDER BY`将允许在执行开始时使用60%的可用内存(用于服务器/用户/合并),之后将开始使用外部排序。 +注意,`max_bytes_before_external_sort`仍然会被尊重,只有当排序块大于`max_bytes_before_external_sort`时,才会进行溢出到磁盘。 +## max_bytes_to_read {#max_bytes_to_read} - - -执行查询时可以从表中读取的最大字节数(未压缩数据)。 -此限制适用于每个处理过的数据块,只适用于最深的表表达式,并且在从远程服务器读取时,仅在远程服务器上检查。 +执行查询时从表中可以读取的最大字节数(未压缩数据)。 +对每个处理的数据块进行限制,仅适用于最深的表表达式,并且在从远程服务器读取时,仅对远程服务器进行检查。 ## max_bytes_to_read_leaf {#max_bytes_to_read_leaf} +在运行分布式查询时,从叶节点的本地表中可以读取的最大字节数(未压缩数据)。虽然分布式查询可以向每个分片(叶)发出多个子查询 - 但此限制仅在叶节点的读取阶段进行检查,并将在根节点的结果合并阶段被忽略。 +例如,集群由两个分片组成,每个分片包含100字节数据。一个计划从两个表中读取所有数据的分布式查询,如果设置为`max_bytes_to_read=150`将会失败,因为总共会有200字节的数据。设置为`max_bytes_to_read_leaf=150`的查询将会成功,因为叶节点最多将读取100字节。 - - -在执行分布式查询时可以从叶节点的本地表中读取的最大字节数(未压缩数据)。虽然分布式查询可以针对每个分片(叶子)发出多个子查询 - 但是这个限制只会在叶节点的读取阶段检查,在合并结果的根节点阶段将被忽略。 - -例如,一个集群包含 2 个分片,每个分片包含 100 字节的数据。一个声称要从两个表中读取所有数据的分布式查询,如果设置为 `max_bytes_to_read=150` 将失败,因为总计为 200 字节。一个针对 `max_bytes_to_read_leaf=150` 的查询将成功,因叶节点最多只读取 100 字节。 - -此限制适用于每个处理过的数据块。 +限制针对每个处理的数据块进行检查。 :::note -此设置在 `prefer_localhost_replica=1` 时不稳定。 +此设置在`prefer_localhost_replica=1`时不稳定。 ::: ## max_bytes_to_sort {#max_bytes_to_sort} - - - - -在排序之前的最大字节数。如果要处理的未压缩字节数超过指定的数量,`ORDER BY` 操作的行为将由 `sort_overflow_mode` 决定,默认设置为 `throw`。 +在排序之前的最大字节数。如果需要处理的未压缩字节数超过指定数量,则`ORDER BY`操作的行为将由`sort_overflow_mode`确定,默认设置为`throw`。 ## max_bytes_to_transfer {#max_bytes_to_transfer} - - - - -在执行 GLOBAL IN/JOIN 部分时,可以传递到远程服务器或保存在临时表中的最大字节数(未压缩数据)。 +当执行GLOBAL IN/JOIN部分时,可以传递给远程服务器或保存在临时表中的最大字节数(未压缩数据)。 ## max_columns_to_read {#max_columns_to_read} - - - - -可以从表中在单个查询中读取的最大列数。 -如果查询需要读取的列数超过指定的数量,则会抛出异常。 +可以在单个查询中从表中读取的最大列数。 +如果一个查询需要读取超过指定数量的列,则会抛出异常。 :::tip -此设置可用于防止过于复杂的查询。 +此设置有助于防止过于复杂的查询。 ::: -`0` 值表示无限制。 +`0`值表示无限制。 ## max_compress_block_size {#max_compress_block_size} - - - - -在写入表之前对未压缩数据块的最大大小。默认值为 1,048,576(1 MiB)。指定较小的块大小一般会导致压缩率略微降低,由于缓存局部性,压缩和解压缩速度会略微增加,同时内存消耗也会减少。 +为了写入表,压缩前未压缩数据块的最大大小。默认值为1,048,576(1 MiB)。指定较小的块大小通常会导致压缩比略有降低,压缩和解压缩速度略有提高,因为缓存局部性较好,并且内存消耗降低。 :::note -这是一个专家级设置,如果你刚开始使用 ClickHouse,建议不要更改此设置。 +这是一个专家级设置,如果您刚开始使用ClickHouse,不要更改它。 ::: -不要将压缩块(由字节组成的内存块)与用于查询处理的块(来自表的一组行)混淆。 +不要将用于压缩的块(一个由字节组成的内存块)与查询处理块(表中的一组行)混淆。 ## max_concurrent_queries_for_all_users {#max_concurrent_queries_for_all_users} +如果此设置的值小于或等于当前正在处理的查询数量,则抛出异常。 +示例:可以将`max_concurrent_queries_for_all_users`设置为99,所有用户的数据库管理员可以将其设置为100,以便在服务器过载时也能够运行查询进行调查。 - - -如果此设置的值小于或等于当前并发处理的查询数量,则抛出异常。 - -示例:将 `max_concurrent_queries_for_all_users` 设置为 99,以便所有用户使用,而数据库管理员可以将其设置为 100,以便在服务器过载时执行调查查询。 - -为一个查询或用户修改设置不会影响其他查询。 +对单个查询或用户的设置修改不会影响其他查询。 -可能值: +可能的值: - 正整数。 -- 0 — 无限制。 +- 0 — 没有限制。 **示例** @@ -5235,21 +5484,17 @@ log_query_views=1 99 ``` -**另请参见** +**另见** - [max_concurrent_queries](/operations/server-configuration-parameters/settings#max_concurrent_queries) ## max_concurrent_queries_for_user {#max_concurrent_queries_for_user} - - - - 每个用户同时处理的查询的最大数量。 -可能值: +可能的值: - 正整数。 -- 0 — 无限制。 +- 0 — 没有限制。 **示例** @@ -5258,94 +5503,70 @@ log_query_views=1 ``` ## max_distributed_connections {#max_distributed_connections} - - - - -每个查询对单个分布式表与远程服务器的最大同时连接数。建议设置的值不少于集群中的服务器数量。 - -以下参数仅在创建分布式表(和启动服务器)时使用,因此在运行时没有理由更改它们。 +用于分布式处理单个查询到单个Distributed表的远程服务器的最大同时连接数。我们建议将值设置为不低于集群中服务器的数量。 ## max_distributed_depth {#max_distributed_depth} - - -限制 [Distributed](../../engines/table-engines/special/distributed.md) 表的递归查询的最大深度。 +限制递归查询的最大深度,适用于 [Distributed](../../engines/table-engines/special/distributed.md) 表。 -如果超过此值,服务器将抛出异常。 +如果超过该值,服务器将抛出异常。 -可能值: +可能的值: - 正整数。 - 0 — 无限深度。 ## max_download_buffer_size {#max_download_buffer_size} - - -每个线程的并行下载(例如,对于 URL 引擎)的最大缓冲区大小。 +每个线程用于并行下载的最大缓冲区大小(例如,用于 URL 引擎)。 ## max_download_threads {#max_download_threads} - - -下载数据的最大线程数(例如,针对 URL 引擎)。 +下载数据的最大线程数(例如,用于 URL 引擎)。 ## max_estimated_execution_time {#max_estimated_execution_time} - - - - -查询预估的最大执行时间(秒)。在每个数据块上检查, -当 [`timeout_before_checking_execution_speed`](/operations/settings/settings#timeout_before_checking_execution_speed) 到期时。 +查询估算的最大执行时间(以秒为单位)。在 [`timeout_before_checking_execution_speed`](/operations/settings/settings#timeout_before_checking_execution_speed) 过期时检查每个数据块。 ## max_execution_speed {#max_execution_speed} - - -每秒执行的最大行数。当 [`timeout_before_checking_execution_speed`](/operations/settings/settings#timeout_before_checking_execution_speed) 到期时,在每个数据块上检查。如果执行速度过高,则执行速度将降低。 +每秒执行的最大行数。在 [`timeout_before_checking_execution_speed`](/operations/settings/settings#timeout_before_checking_execution_speed) 过期时检查每个数据块。如果执行速度过快,将降低执行速度。 ## max_execution_speed_bytes {#max_execution_speed_bytes} - - -每秒执行的最大字节数。当 [`timeout_before_checking_execution_speed`](/operations/settings/settings#timeout_before_checking_execution_speed) 到期时,在每个数据块上检查。如果执行速度过高,则执行速度将降低。 +每秒执行的最大字节数。在 [`timeout_before_checking_execution_speed`](/operations/settings/settings#timeout_before_checking_execution_speed) 过期时检查每个数据块。如果执行速度过快,将降低执行速度。 ## max_execution_time {#max_execution_time} - - -查询的最大执行时间(秒)。 +查询的最大执行时间(以秒为单位)。 -`max_execution_time` 参数可能有些复杂。它相对于当前查询执行速度的插值操作(这一行为由 [`timeout_before_checking_execution_speed`](/operations/settings/settings#timeout_before_checking_execution_speed) 控制)。 +`max_execution_time` 参数可能有点难以理解。 +它根据当前查询的执行速度进行插值操作(这种行为由 [`timeout_before_checking_execution_speed`](/operations/settings/settings#timeout_before_checking_execution_speed) 控制)。 -ClickHouse 将中断查询,如果预计的执行时间超过指定的 `max_execution_time`。默认情况下,`timeout_before_checking_execution_speed` 被设置为 10 秒。这意味着在查询执行 10 秒后,ClickHouse 将开始估算总执行时间。例如,如果 `max_execution_time` 设置为 3600 秒(1 小时),如果预计的时间超过 3600 秒的限制,ClickHouse 将终止该查询。如果您将 `timeout_before_checking_execution_speed` 设置为 0,ClickHouse 将基于时钟时间作为 `max_execution_time`。 +如果预计执行时间超过指定的 `max_execution_time`,ClickHouse 将中断查询。默认情况下,`timeout_before_checking_execution_speed` 设置为 10 秒。这意味着在查询执行了 10 秒后,ClickHouse 将开始估计总执行时间。如果例如 `max_execution_time` 设置为 3600 秒(1 小时),如果预计时间超过这个 3600 秒的限制,ClickHouse 将终止该查询。如果您将 `timeout_before_checking_execution_speed` 设置为 0,ClickHouse 将以时钟时间作为 `max_execution_time` 的基础。 -如果查询运行时间超过指定的秒数,则行为将由 `timeout_overflow_mode` 决定,默认设置为 `throw`。 +如果查询运行时间超过指定秒数,则行为将由 `timeout_overflow_mode` 确定,默认设置为 `throw`。 :::note -超时只会在数据处理的特定位置进行检查,查询只能在这些位置停止。 -目前无法在合并聚合状态或查询分析期间停止,实际运行时间将高于此设置的值。 +超时检查仅在数据处理的指定位置可以停止查询。 +目前无法在聚合状态合并或查询分析期间停止,实际运行时间将高于此设置的值。 ::: ## max_execution_time_leaf {#max_execution_time_leaf} - - -语义上类似于 [`max_execution_time`](#max_execution_time),但仅适用于分布式或远程查询的叶节点。 +在语义上与 [`max_execution_time`](#max_execution_time) 相似,但仅适用于分布式或远程查询的叶节点。 -例如,如果我们想在叶节点上将执行时间限制为 `10s`,而在初始节点上没有限制,而不是在嵌套子查询的设置中有 `max_execution_time`: +例如,如果我们想将叶节点上的执行时间限制为 `10s`,但不对初始节点限制,而不在嵌套子查询设置中设置 `max_execution_time`: ```sql SELECT count() @@ -5360,46 +5581,36 @@ FROM cluster(cluster, view(SELECT * FROM t)) SETTINGS max_execution_time_leaf = ``` ## max_expanded_ast_elements {#max_expanded_ast_elements} - - -扩展别名和星号后查询语法树的最大节点数。 +查询语法树扩展后节点的最大数量。 ## max_fetch_partition_retries_count {#max_fetch_partition_retries_count} - - -从另一主机提取分区时的重试次数。 +从另一个主机获取分区时的重试次数。 ## max_final_threads {#max_final_threads} - - -设置具有 [FINAL](/sql-reference/statements/select/from#final-modifier) 修饰符的 `SELECT` 查询的数据读取阶段的最大并行线程数。 +设置 `SELECT` 查询数据读取阶段的最大并行线程数,适用于 [FINAL](/sql-reference/statements/select/from#final-modifier) 修饰符。 -可能值: +可能的值: - 正整数。 -- 0 或 1 — 禁用。`SELECT` 查询将在单个线程中执行。 +- 0 或 1 — 禁用。`SELECT` 查询在单线程中执行。 ## max_http_get_redirects {#max_http_get_redirects} - - -允许的最大 HTTP GET 重定向跳数。确保采取额外的安全措施,以防止恶意服务器将您的请求重定向到意外服务。\n\n 当外部服务器重定向到另一个地址,而该地址看似属于公司的基础设施时,就会出现这种情况,通过向内部服务器发送 HTTP 请求,您可以从内部网络请求内部 API,绕过身份验证,甚至查询其他服务,如 Redis 或 Memcached。当您没有内部基础设施(包括在本地主机上运行的东西)或您信任服务器时,允许重定向是安全的。尽管请记住,如果 URL 使用 HTTP 而非 HTTPS,您将不仅需要信任远程服务器,还需要信任您的 ISP 及中间路径上的每个网络。 +允许的最大 HTTP GET 重定向跳转次数。确保采取额外的安全措施,以防恶意服务器将您的请求重定向到意外服务。\n\n在外部服务器重定向到另一个地址时,即使该地址看似是公司基础设施内部的,通过向内部服务器发送 HTTP 请求,您可能会请求来自内部网络的内部 API,绕过身份验证,甚至查询其他服务,如 Redis 或 Memcached。当您没有内部基础设施(包括在本地主机上运行的东西),或者您信任服务器时,允许重定向是安全的。不过请记住,如果 URL 使用 HTTP 而不是 HTTPS,您不仅需要信任远程服务器,还需要信任您的 ISP 以及中间的每一个网络。 ## max_hyperscan_regexp_length {#max_hyperscan_regexp_length} - - 定义 [hyperscan 多匹配函数](/sql-reference/functions/string-search-functions#multimatchany) 中每个正则表达式的最大长度。 -可能值: +可能的值: - 正整数。 - 0 - 长度不受限制。 @@ -5432,18 +5643,16 @@ SELECT multiMatchAny('abcd', ['ab','bcd','c','d']) SETTINGS max_hyperscan_regexp Exception: Regexp length too large. ``` -**另请参见** +**另见** - [max_hyperscan_regexp_total_length](#max_hyperscan_regexp_total_length) ## max_hyperscan_regexp_total_length {#max_hyperscan_regexp_total_length} - - -设置每个 [hyperscan多匹配函数](/sql-reference/functions/string-search-functions#multimatchany) 中所有正则表达式的最大总长度。 +设置每个 [hyperscan 多匹配函数](/sql-reference/functions/string-search-functions#multimatchany) 中所有正则表达式的最大总长度。 -可能值: +可能的值: - 正整数。 - 0 - 长度不受限制。 @@ -5476,102 +5685,92 @@ SELECT multiMatchAny('abcd', ['ab','bc','c','d']) SETTINGS max_hyperscan_regexp_ Exception: Total regexp lengths too large. ``` -**另请参见** +**另见** - [max_hyperscan_regexp_length](#max_hyperscan_regexp_length) ## max_insert_block_size {#max_insert_block_size} + +用于插入表的块大小(以行数为单位)。 +此设置仅适用于服务器形成块的情况。 +例如,通过 HTTP 接口进行的 INSERT,服务器解析数据格式并形成指定大小的块。 +但使用 clickhouse-client 时,客户端自己解析数据,服务器上的 `max_insert_block_size` 设置不影响插入块的大小。 +在使用 INSERT SELECT 时,该设置也没有作用,因为数据是使用在 SELECT 后形成的相同块插入的。 - - -插入到表中的区块大小(以行数计)。此设置仅在服务器形成块的情况下适用。例如,对于通过 HTTP 接口的 INSERT,服务器解析数据格式并形成指定大小的块。但是,当使用 clickhouse-client 时,客户端自己解析数据,服务器上的 'max_insert_block_size' 设置不影响插入块的大小。使用 INSERT SELECT 时,该设置也没有用,因为数据使用 SELECT 后形成的相同块插入。 - -默认值略高于 `max_block_size`。这样做的原因是某些表引擎(`*MergeTree`)会为每个插入的块在磁盘上形成一部分数据,这是一种相对较大的实体。同时,`*MergeTree` 表在插入期间会对数据进行排序,足够大的块大小允许在 RAM 中对更多数据进行排序。 +默认值略大于 `max_block_size`。原因是某些表引擎(`*MergeTree`)对每个插入的块在磁盘上形成一个数据部分,这是一个相当大的实体。同样,`*MergeTree` 表在插入时对数据进行排序,足够大的块大小允许在内存中排序更多数据。 ## max_insert_delayed_streams_for_parallel_write {#max_insert_delayed_streams_for_parallel_write} - - -延迟最终部分刷新上的最大流(列)数。默认值 - 自动(在底层存储支持并行写时为 100,否则禁用) +延迟最终部分刷新操作的最大流数(列)。默认值 - 自动(如果基础存储支持并行写入,则为 100,其他情况禁用)。 ## max_insert_threads {#max_insert_threads} - - 执行 `INSERT SELECT` 查询的最大线程数。 -可能值: +可能的值: -- 0(或 1) — `INSERT SELECT` 不进行并行执行。 -- 正整数。大于 1。 +- 0(或 1) — `INSERT SELECT` 不支持并行执行。 +- 正整数,大于 1。 -云默认值:从 `2` 到 `4`,根据服务规模不同而不同。 +云默认值: +- 8 GiB 内存的节点为 `1` +- 16 GiB 内存的节点为 `2` +- 更大的节点为 `4` -并行 `INSERT SELECT` 仅在 `SELECT` 部分并行执行时有效,参见 [max_threads](#max_threads) 设置。 -较高的值将导致更高的内存使用。 -## max_joined_block_size_rows {#max_joined_block_size_rows} +并行 `INSERT SELECT` 仅在 `SELECT` 部分并行执行时有效,请参见 [`max_threads`](#max_threads) 设置。 +更高的值将导致更高的内存使用。 +## max_joined_block_size_bytes {#max_joined_block_size_bytes} + + + +JOIN 结果的最大块大小(以字节为单位)(如果连接算法支持)。0 表示无限制。 +## max_joined_block_size_rows {#max_joined_block_size_rows} -JOIN 结果的最大块大小(如果连接算法支持此功能)。0 表示无限制。 +JOIN 结果的最大块大小(以行数为单位)(如果连接算法支持)。0 表示无限制。 ## max_limit_for_vector_search_queries {#max_limit_for_vector_search_queries} - - - - - - - - -LIMIT 大于此设置的 SELECT 查询无法使用向量相似度索引。帮助防止在向量相似度索引中发生内存溢出。 +对于 LIMIT 大于此设置的 SELECT 查询,无法使用向量相似度索引。帮助防止向量相似度索引中的内存溢出。 ## max_live_view_insert_blocks_before_refresh {#max_live_view_insert_blocks_before_refresh} - - -限制插入块的最大数量,超过该数量后,合并块将被丢弃并重新执行查询。 +限制插入块的最大数量,在此之后可合并的块被丢弃并重新执行查询。 ## max_local_read_bandwidth {#max_local_read_bandwidth} - - -本地读取的最大速度(字节/秒)。 +本地读取的最大速度(以字节为单位)。 ## max_local_write_bandwidth {#max_local_write_bandwidth} - - -本地写入的最大速度(字节/秒)。 +本地写入的最大速度(以字节为单位)。 ## max_memory_usage {#max_memory_usage} - - -云默认值:取决于副本上的内存量。 +云默认值:取决于副本的 RAM 数量。 -在单台服务器上执行查询时可使用的最大 RAM 量。 -`0` 的值表示无限制。 +在单个服务器上运行查询时可以使用的最大 RAM 量。 +值为 `0` 表示无限制。 -此设置不考虑可用内存的大小或机器的总内存量。此限制适用于单个服务器上的单个查询。 +此设置并不考虑可用内存的容量或机器上的总内存容量。限制适用于单个服务器上的单个查询。 您可以使用 `SHOW PROCESSLIST` 查看每个查询的当前内存消耗。 -每个查询的峰值内存消耗被跟踪并记录到日志中。 +每个查询的峰值内存消耗会被跟踪并记录到日志中。 -对于以下聚合函数的状态,内存使用量不会完全跟踪: +以下聚合函数的状态的内存使用未完全跟踪: - `min` - `max` - `any` @@ -5579,320 +5778,260 @@ LIMIT 大于此设置的 SELECT 查询无法使用向量相似度索引。帮助 - `argMin` - `argMax` -内存消耗也受到 [`max_memory_usage_for_user`](/operations/settings/settings#max_memory_usage_for_user) -和 [`max_server_memory_usage`](/operations/server-configuration-parameters/settings#max_server_memory_usage) 参数的限制。 +内存消耗还受以下参数 [`max_memory_usage_for_user`](/operations/settings/settings#max_memory_usage_for_user) 和 [`max_server_memory_usage`](/operations/server-configuration-parameters/settings#max_server_memory_usage) 的限制。 ## max_memory_usage_for_user {#max_memory_usage_for_user} - - -在单台服务器上执行用户查询时可使用的最大 RAM 量。零表示无限制。 +在单个服务器上运行用户查询时可以使用的最大 RAM 量。值为 0 表示无限制。 -默认情况下,该数值没有限制(`max_memory_usage_for_user = 0`)。 +默认情况下,数量不受限制(`max_memory_usage_for_user = 0`)。 -另请参见 [`max_memory_usage`](/operations/settings/settings#max_memory_usage) 的描述。 +另见 [`max_memory_usage`](/operations/settings/settings#max_memory_usage) 的描述。 -例如,如果您希望将 `max_memory_usage_for_user` 设置为 `clickhouse_read` 用户的 1000 字节,可以使用以下语句 +例如,如果您想将 `max_memory_usage_for_user` 设置为 1000 字节给名为 `clickhouse_read` 的用户,您可以使用以下语句: ```sql ALTER USER clickhouse_read SETTINGS max_memory_usage_for_user = 1000; ``` -您可以通过注销客户端后重新登录,然后使用 `getSetting` 函数来验证设置是否生效: +您可以通过注销客户端,再次登录,然后使用 `getSetting` 函数验证其是否生效: ```sql SELECT getSetting('max_memory_usage_for_user'); ``` ## max_network_bandwidth {#max_network_bandwidth} - - -限制每秒通过网络交换的数据速度(字节)。此设置适用于每个查询。 +限制网络数据交换的速度(以字节为单位)。此设置适用于每个查询。 -可能值: +可能的值: - 正整数。 - 0 — 禁用带宽控制。 ## max_network_bandwidth_for_all_users {#max_network_bandwidth_for_all_users} - - -限制每秒通过网络交换的数据速度(字节)。此设置适用于服务器上同时运行的所有查询。 +限制网络数据交换的速度(以字节为单位)。此设置适用于所有并发运行的查询。 -可能值: +可能的值: - 正整数。 -- 0 — 禁用数据速度控制。 +- 0 — 禁用数据速率控制。 ## max_network_bandwidth_for_user {#max_network_bandwidth_for_user} - - -限制每秒通过网络交换的数据速度(字节)。此设置适用于由单个用户执行的所有并发查询。 +限制网络数据交换速度(以字节为单位)。此设置适用于所有单个用户执行的并发查询。 -可能值: +可能的值: - 正整数。 -- 0 — 禁用数据速度控制。 +- 0 — 禁用数据速率控制。 ## max_network_bytes {#max_network_bytes} - - -限制在执行查询时通过网络接收或传输的数据量(字节)。此设置适用于每个独立查询。 +限制执行查询时通过网络接收或传输的数据量(以字节为单位)。此设置适用于每个单独查询。 -可能值: +可能的值: - 正整数。 - 0 — 禁用数据量控制。 ## max_number_of_partitions_for_independent_aggregation {#max_number_of_partitions_for_independent_aggregation} - - -表中适用优化的最大分区数。 +在表中可应用优化的最大分区数。 ## max_os_cpu_wait_time_ratio_to_throw {#max_os_cpu_wait_time_ratio_to_throw} - - - - -考虑拒绝查询的操作系统 CPU 等待与繁忙时间的最大比率(OSCPUWaitMicroseconds 指标和 OSCPUVirtualTimeMicroseconds 指标之间的比率)。使用最小和最大比率之间的线性插值得到概率,当到达此点时,概率为 1。 +在 OSCPUWaitMicroseconds 指标和 OSCPUVirtualTimeMicroseconds 指标之间考虑拒绝查询的最大比率。使用最小和最大比率之间的线性插值计算概率,在这一点上概率为 1。 ## max_parallel_replicas {#max_parallel_replicas} - - - - -在执行查询时,每个分片的最大副本数量。 +执行查询时每个分片的最大副本数。 -可能值: +可能的值: - 正整数。 **附加信息** -此选项将根据使用的设置生成不同的结果。 +此选项将根据使用的设置产生不同的结果。 :::note -如果涉及到连接或子查询,并且所有表不符合某些要求,则此设置将生成不正确的结果。有关更多详细信息,请参见 [Distributed Subqueries 和 max_parallel_replicas](/operations/settings/settings#max_parallel_replicas)。 +当涉及连接或子查询时,此设置将产生不正确的结果,并且所有表不满足某些要求。有关详细信息,请参阅 [Distributed Subqueries and max_parallel_replicas](/operations/settings/settings#max_parallel_replicas)。 ::: -### 使用 `SAMPLE` 键的并行处理 +### 使用 `SAMPLE` 键进行并行处理 -如果在多个服务器上并行执行查询,可以更快地处理查询。但在以下情况下,查询性能可能会下降: +如果在多个服务器上并行执行查询,查询可能会更快处理。但是,在以下情况下查询性能可能会下降: - 采样键在分区键中的位置不允许有效的范围扫描。 -- 向表中添加采样键使得根据其他列的过滤效率降低。 -- 采样键是一个计算成本高昂的表达式。 -- 集群延迟分布有长尾,因此查询更多服务器会增加总体查询延迟。 -### 使用 [parallel_replicas_custom_key](#parallel_replicas_custom_key) 的并行处理 +- 将采样键添加到表会使通过其他列进行过滤的效率降低。 +- 采样键是一个计算开销大的表达式。 +- 集群延迟分布具有较长尾巴,因此查询更多服务器会增加整体延迟。 +### 使用 [parallel_replicas_custom_key](#parallel_replicas_custom_key) 进行并行处理 -此设置对于任何复制表都是有用的。 +此设置适用于任何复制表。 ## max_parser_backtracks {#max_parser_backtracks} - - - - -解析器的最大回溯次数(在递归下降解析过程中尝试不同的替代方案的次数)。 +最大解析器回溯次数(在递归下降解析过程中尝试不同选择的次数)。 ## max_parser_depth {#max_parser_depth} - - -限制递归下降解析器中的最大递归深度。用于控制堆栈大小。 +限制递归下降解析器的最大递归深度。允许控制堆栈大小。 -可能值: +可能的值: - 正整数。 -- 0 — 递归深度无限制。 +- 0 — 递归深度不限。 ## max_parsing_threads {#max_parsing_threads} - - - - -用于解析支持并行解析的输入格式数据的最大线程数。默认情况下,将自动确定该值。 +解析支持并行解析的输入格式数据的最大线程数。默认情况下,自动确定。 ## max_partition_size_to_drop {#max_partition_size_to_drop} - - -在查询时删除分区的限制。值为 0 意味着您可以无限制地删除分区。 +查询时删除分区的限制。值 `0` 表示可以删除分区而没有任何限制。 云默认值:1 TB。 :::note -此查询设置将覆盖其服务器设置等效项,请参见 [max_partition_size_to_drop](/operations/server-configuration-parameters/settings#max_partition_size_to_drop)。 +此查询设置会覆盖其服务器设置等效项,请参见 [max_partition_size_to_drop](/operations/server-configuration-parameters/settings#max_partition_size_to_drop) ::: ## max_partitions_per_insert_block {#max_partitions_per_insert_block} - - - - -限制单个插入块中最大分区数量,如果块包含过多分区,则抛出异常。 +限制单个插入块中的最大分区数,如果块包含过多的分区,将抛出异常。 - 正整数。 -- `0` — 分区数无限制。 +- `0` — 分区数量无限制。 **详细信息** -在插入数据时,ClickHouse 会计算插入块中的分区数。如果分区数量超过 `max_partitions_per_insert_block`,ClickHouse 会根据 `throw_on_max_partitions_per_insert_block` 条件要么记录警告,要么抛出异常。异常文本如下: +插入数据时,ClickHouse 会计算插入块中的分区数。如果分区数大于 `max_partitions_per_insert_block`,ClickHouse 将根据 `throw_on_max_partitions_per_insert_block` 记录警告或抛出异常。异常的文本如下: -> “单个 INSERT 块分区过多( `partitions_count` 片段,限制为 ' + toString(max_partitions) + )。该限制由 'max_partitions_per_insert_block' 参数控制。过多的分区是一个常见误解,它将导致严重的负性能影响,包括服务器启动缓慢、INSERT 查询缓慢和 SELECT 查询缓慢。建议的表总分区数应低于 1000..10000。请注意,分区的目的并不是为了加速 SELECT 查询(ORDER BY 键足以使范围查询快速)。分区的目的在于数据操作(DROP PARTITION 等)。” +> "单个 INSERT 块的分区数过多(`partitions_count` 分区,限制为 " + toString(max_partitions) + ")。 + 该限制由 'max_partitions_per_insert_block' 设置控制。 + 大量分区是一个常见的误解。它将导致严重的负性能影响,包括服务器启动缓慢、INSERT 查询缓慢和 SELECT 查询缓慢。建议的表分区总数应少于 1000 至 10000。请注意,分区并不是为了加速 SELECT 查询(ORDER BY 键足以使范围查询快速)。 + 分区用于数据操作(DROP PARTITION 等)。" :::note -此设置是一个安全阈值,因为使用过多的分区是一个常见误解。 +该设置是一个安全阈值,因为使用大量分区是一种常见的误解。 ::: ## max_partitions_to_read {#max_partitions_to_read} - - -限制在单个查询中可以访问的最大分区数量。 +限制在单个查询中可以访问的最大分区数。 -在创建表时指定的设置值可以通过查询级别设置来覆盖。 +在创建表时指定的设置值可以通过查询级别设置覆盖。 -可能值: +可能的值: -- 正整数。 -- `-1` - 无限(默认值) +- 正整数 +- `-1` - 无限制(默认) :::note -您也可以在表设置中指定 MergeTree 设置 [`max_partitions_to_read`](/operations/settings/settings#max_partitions_to_read)。 +您还可以在表的设置中指定 MergeTree 设置 [`max_partitions_to_read`](/operations/settings/settings#max_partitions_to_read)。 ::: ## max_parts_to_move {#max_parts_to_move} - - - - -限制在一个查询中可以移动的部分数量。零表示无限制。 +限制在一个查询中可以移动的部分的数量。零表示无限制。 ## max_query_size {#max_query_size} - - -可由 SQL 解析器解析的查询字符串的最大字节数。 -INSERT 查询的 VALUES 子句中的数据由单独的流解析器处理(占用 O(1) RAM),不会受到此限制的影响。 +SQL 解析器解析的查询字符串的最大字节数。 +INSERT 查询中的 VALUES 子句中的数据由单独的流解析器处理(消耗 O(1) 的 RAM),不受此限制的影响。 :::note -`max_query_size` 不能在 SQL 查询中设置(例如,`SELECT now() SETTINGS max_query_size=10000`),因为 ClickHouse 需要分配一个缓冲区来解析查询,而这个缓冲区的大小由 `max_query_size` 设置决定,该值必须在查询执行之前配置。 +`max_query_size` 不能在 SQL 查询中设置(例如,`SELECT now() SETTINGS max_query_size=10000`),因为 ClickHouse 需要分配一个缓冲区来解析查询,而此缓冲区的大小由 `max_query_size` 设置决定,该设置必须在执行查询之前配置。 ::: ## max_read_buffer_size {#max_read_buffer_size} - - -从文件系统读取的缓冲区的最大大小。 +从文件系统读取的缓冲区的最大大小。 ## max_read_buffer_size_local_fs {#max_read_buffer_size_local_fs} - - -从本地文件系统读取的缓冲区的最大大小。如果设置为 0,那么将使用 max_read_buffer_size。 +从本地文件系统读取的缓冲区的最大大小。如果设置为 0,则将使用 max_read_buffer_size。 ## max_read_buffer_size_remote_fs {#max_read_buffer_size_remote_fs} - - -从远程文件系统读取的缓冲区的最大大小。如果设置为 0,那么将使用 max_read_buffer_size。 +从远程文件系统读取的缓冲区的最大大小。如果设置为 0,则将使用 max_read_buffer_size。 ## max_recursive_cte_evaluation_depth {#max_recursive_cte_evaluation_depth} - - - - - - 递归 CTE 评估深度的最大限制。 ## max_remote_read_network_bandwidth {#max_remote_read_network_bandwidth} - - -读取时网络数据交换的最大速度(字节/秒)。 +读取时网络数据交换的最大速度(以字节为单位)。 ## max_remote_write_network_bandwidth {#max_remote_write_network_bandwidth} - - -写入时网络数据交换的最大速度(字节/秒)。 +写入时网络数据交换的最大速度(以字节为单位)。 ## max_replica_delay_for_distributed_queries {#max_replica_delay_for_distributed_queries} -禁用延迟副本以进行分布式查询。请参见 [Replication](../../engines/table-engines/mergetree-family/replication.md)。 +对于分布式查询,禁用滞后副本。请参见 [Replication](../../engines/table-engines/mergetree-family/replication.md)。 -设置以秒为单位的时间。如果副本的延迟大于或等于设置的值,则不使用该副本。 +设置以秒为单位。如果副本的滞后时间大于或等于设定值,则不使用该副本。 可能的值: - 正整数。 -- 0 — 不检查副本延迟。 +- 0 — 不检查副本的滞后时间。 -要防止使用任何具有非零延迟的副本,请将此参数设置为 1。 +要防止使用任何滞后时间不为零的副本,请将此参数设置为 1。 -在执行 `SELECT` 从指向复制表的分布式表时使用此参数。 +在执行从指向复制表的分布式表的 `SELECT` 时使用。 ## max_result_bytes {#max_result_bytes} -限制结果大小(未压缩)的字节数。如果处理数据块时达到阈值,则查询将停止,但不会截断结果的最后一个块,因此结果大小可能大于阈值。 +限制结果大小(以字节为单位,未经压缩)。如果处理数据块时达到阈值,查询将停止,但不会截断结果的最后一个块,因此结果大小可能超过阈值。 **注意事项** -此阈值考虑内存中的结果大小。 -即使结果大小较小,它也可能引用内存中的较大数据结构, -表示 LowCardinality 列的字典和 AggregateFunction 列的 Arena, -因此尽管结果大小较小,该阈值仍可能被超出。 +内存中的结果大小被纳入此阈值。 +即使结果大小很小,它仍可以引用内存中的更大数据结构,代表低基数列的字典和聚合函数列的区域,因此尽管结果大小较小,阈值仍可能被超出。 :::warning -该设置较为底层,应谨慎使用 +该设置相对低级,应谨慎使用。 ::: ## max_result_rows {#max_result_rows} @@ -5900,34 +6039,31 @@ INSERT 查询的 VALUES 子句中的数据由单独的流解析器处理(占 云默认值:`0`。 -限制结果中的行数。对子查询进行检查,并在运行分布式查询的不同服务器上进行检查。 -当值为 `0` 时不施加限制。 +限制结果中的行数。对于子查询和在远程服务器上运行分布式查询的一部分时也进行检查。 +当值为 `0` 时不应用限制。 -如果处理数据块时达到阈值,查询将停止,但 -不截断结果的最后一个块,因此结果大小可能大于阈值。 +如果处理数据块时达到阈值,查询将停止,但不会截断结果的最后一个块,因此结果大小可能大于阈值。 ## max_rows_in_distinct {#max_rows_in_distinct} -使用 DISTINCT 时最大不同的行数。 +使用 DISTINCT 时不同的最大行数。 ## max_rows_in_join {#max_rows_in_join} -限制用于连接表的哈希表中的行数。 +限制连接表时使用的哈希表中的行数。 -该设置适用于 [SELECT ... JOIN](/sql-reference/statements/select/join) -操作和 [Join](/engines/table-engines/special/join) 表引擎。 +此设置适用于 [SELECT ... JOIN](/sql-reference/statements/select/join) 操作和 [Join](/engines/table-engines/special/join) 表引擎。 -如果查询包含多个连接,ClickHouse 会检查此设置以获得每个中间结果。 +如果查询包含多个连接,ClickHouse 将对每个中间结果检查此设置。 -在达到限制时,ClickHouse 可以采取不同的操作。使用 -[`join_overflow_mode`](/operations/settings/settings#join_overflow_mode) 设置来选择操作。 +当达到限制时,ClickHouse 可以执行不同的操作。使用 [`join_overflow_mode`](/operations/settings/settings#join_overflow_mode) 设置选择操作。 可能的值: - 正整数。 -- `0` — 无限制的行数。 +- `0` — 行数无限制。 ## max_rows_in_set {#max_rows_in_set} @@ -5937,9 +6073,7 @@ INSERT 查询的 VALUES 子句中的数据由单独的流解析器处理(占 - - -在连接之前,在各连接表之间按行集过滤的最大集合大小。 +用于在连接之前基于彼此行集过滤连接表的最大集的大小。 可能的值: @@ -5949,46 +6083,44 @@ INSERT 查询的 VALUES 子句中的数据由单独的流解析器处理(占 -从聚合中接收的唯一键的最大数量。此设置允许您限制聚合时的内存消耗。 +从聚合中接收到的唯一键的最大数量。此设置允许您限制聚合时的内存消耗。 -如果在 GROUP BY 中生成的聚合行数(唯一的 GROUP BY 键)超过指定数量,则行为将由 -'group_by_overflow_mode' 确定,该模式默认值为 `throw`,但也可以切换到近似 GROUP BY 模式。 +如果在 GROUP BY 期间生成的行(唯一 GROUP BY 键)超过指定数量,则行为将由 'group_by_overflow_mode' 确定,默认设置为 `throw`,但也可以切换到近似 GROUP BY 模式。 ## max_rows_to_read {#max_rows_to_read} -在运行查询时可以从表中读取的最大行数。 -该限制对每个处理的数据块都进行检查,仅适用于最深的表表达式,并且在从远程服务器读取时,仅在远程服务器上进行检查。 +运行查询时从表中可以读取的最大行数。 +对每个处理的数据块都进行检查的限制,仅适用于最深的表表达式,并在从远程服务器读取时,仅在远程服务器上进行检查。 ## max_rows_to_read_leaf {#max_rows_to_read_leaf} -在运行分布式查询时,能从叶子节点的本地表中读取的最大行数。虽然分布式查询可以对每个分片(叶子)发出多个子查询——但此限制只在读取阶段检查,并在根节点的结果合并阶段忽略。 +在运行分布式查询时,从叶节点的本地表中可以读取的最大行数。虽然分布式查询可以对每个分片(叶)发出多个子查询,但此限制仅在叶节点的读取阶段进行检查,并在根节点合并结果阶段被忽略。 -例如,一个集群由 2 个分片构成,且每个分片包含一张有 100 行的表。假定分布式查询需要读取来自两张表的所有数据且设置为 `max_rows_to_read=150`,则会失败,因为总共有 200 行。查询设置为 `max_rows_to_read_leaf=150` 则会成功,因为叶节点最多会读取 100 行。 +例如,一个集群由 2 个分片组成,每个分片包含一个 100 行的表。预期从两个表中读取所有数据的分布式查询,如果设置为 `max_rows_to_read=150`,将会失败,因为总共将有 200 行。查询 `max_rows_to_read_leaf=150` 将会成功,因为叶节点最多将读取 100 行。 -该限制对每个处理的数据块进行检查。 +对每个处理的数据块进行检查。 :::note -该设置在 `prefer_localhost_replica=1` 时不稳定。 +此设置与 `prefer_localhost_replica=1` 一起使用时不稳定。 ::: ## max_rows_to_sort {#max_rows_to_sort} -排序前的最大行数。这允许您限制排序时的内存消耗。 -如果在 ORDER BY 操作中需要处理的记录数超过指定数量,则 -行为将由 `sort_overflow_mode` 决定,默认值设置为 `throw`。 +排序前的最大行数。这允许您在排序时限制内存消耗。 +如果ORDER BY操作需要处理的记录数超过指定数量,则行为将由 `sort_overflow_mode` 确定,默认设置为 `throw`。 ## max_rows_to_transfer {#max_rows_to_transfer} -在执行 GLOBAL IN/JOIN 部分时,可以传递到远程服务器或保存到临时表中的最大大小(以行计)。 +在执行 GLOBAL IN/JOIN 部分时,传递给远程服务器或保存到临时表的最大大小(以行数为单位)。 ## max_sessions_for_user {#max_sessions_for_user} -每个经过身份验证的用户与 ClickHouse 服务器的最大并发会话数。 +每个已认证用户与 ClickHouse 服务器的最大同时会话数。 示例: @@ -6022,91 +6154,95 @@ INSERT 查询的 VALUES 子句中的数据由单独的流解析器处理(占 可能的值: - 正整数 -- `0` - 无限制并发会话(默认) +- `0` - 无限数量的同时会话(默认) ## max_size_to_preallocate_for_aggregation {#max_size_to_preallocate_for_aggregation} -在聚合之前,总共允许在所有哈希表中预分配的元素数量。 + + +在聚合之前,所有哈希表中允许预分配的元素的总数。 ## max_size_to_preallocate_for_joins {#max_size_to_preallocate_for_joins} -在连接之前,总共允许在所有哈希表中预分配的元素数量。 + + +在连接之前,所有哈希表中允许预分配的元素的总数。 ## max_streams_for_merge_tree_reading {#max_streams_for_merge_tree_reading} -如果不为零,限制 MergeTree 表的读取流数。 +如果不为零,限制 MergeTree 表的读取流数量。 ## max_streams_multiplier_for_merge_tables {#max_streams_multiplier_for_merge_tables} -在从 Merge 表中读取时请求更多流。流将分配到合并表将使用的表中。这允许在线程之间更均匀地分配工作,并在合并表的大小不同的情况下尤为有用。 +在从合并表读取时请求更多流。流将分布在合并表将使用的表上。这允许更均匀地分配线程间的工作,并在合并表之间尺寸不同的情况下特别有帮助。 ## max_streams_to_max_threads_ratio {#max_streams_to_max_threads_ratio} -允许您使用的源多于线程数——以便在线程之间更均匀地分配工作。假定这是一个临时解决方案,因为将来可能会使源数等于线程数,但每个源会动态选择可用工作。 +允许您使用的来源数超过线程数——以更均匀地分配线程之间的工作。假设这是一个临时解决方案,因为将来将能够使源的数量等于线程数量,但对于每个源动态选择可用的工作。 ## max_subquery_depth {#max_subquery_depth} -如果查询的嵌套子查询数量超过指定数量,则抛出异常。 +如果查询的嵌套子查询数超过指定数量,则抛出异常。 :::tip -这允许您进行合理性检查,以防止集群的用户编写过于复杂的查询。 +这可以帮助您进行合理检查,以保护集群中的用户,以免编写过于复杂的查询。 ::: ## max_table_size_to_drop {#max_table_size_to_drop} -删除表的查询时间限制。值为 0 的意思是您可以删除所有表而没有任何限制。 +查询时删除表的限制。值 `0` 表示可以删除所有表而没有任何限制。 云默认值:1 TB。 :::note -该查询设置会覆盖其服务器设置的等价项,请参见 [max_table_size_to_drop](/operations/server-configuration-parameters/settings#max_table_size_to_drop) +此查询设置会覆盖其服务器设置等效项,请参见 [max_table_size_to_drop](/operations/server-configuration-parameters/settings#max_table_size_to_drop)。 ::: ## max_temporary_columns {#max_temporary_columns} -在运行查询时,同时必须保留在内存中的临时列的最大数量,包括常量列。如果查询在中间计算的过程中生成的临时列超过指定的数量,则会抛出异常。 +在运行查询时需要同时保留在内存中的临时列的最大数量,包括常量列。如果查询由于中间计算生成的临时列超过指定数量,则将抛出异常。 :::tip -该设置有助于防止过于复杂的查询。 +此设置有助于防止过于复杂的查询。 ::: -`0` 值意味着无限制。 +`0` 值表示无限制。 ## max_temporary_data_on_disk_size_for_query {#max_temporary_data_on_disk_size_for_query} -所有并发运行的查询中,临时文件在磁盘上消耗的最大数据量(以字节为单位)。 +所有并发运行查询的临时文件在磁盘上消耗的数据的最大字节数。 可能的值: - 正整数。 -- `0` — 无限(默认) +- `0` — 无限制(默认)。 ## max_temporary_data_on_disk_size_for_user {#max_temporary_data_on_disk_size_for_user} -所有并发运行的用户查询中,临时文件在磁盘上消耗的最大数据量(以字节为单位)。 +所有并发运行的用户查询的临时文件在磁盘上消耗的数据的最大字节数。 可能的值: - 正整数。 -- `0` — 无限(默认) +- `0` — 无限制(默认)。 ## max_temporary_non_const_columns {#max_temporary_non_const_columns} -与 `max_temporary_columns` 类似,在运行查询时,同时必须保留在内存中的临时列的最大数量,但不包括常量列。 +与 `max_temporary_columns` 类似,在运行查询时需要同时保留在内存中的临时列的最大数量,但不计算常量列。 :::note -常量列在运行查询时相对频繁地形成,但它们几乎不需要计算资源。 +在运行查询时,常量列会相对频繁地产生,但它们几乎不需要计算资源。 ::: ## max_threads {#max_threads} @@ -6114,89 +6250,95 @@ INSERT 查询的 VALUES 子句中的数据由单独的流解析器处理(占 查询处理线程的最大数量,不包括从远程服务器检索数据的线程(请参见 'max_distributed_connections' 参数)。 -该参数适用于并行进行查询处理管道相同阶段的线程。 -例如,在从表中读取时,如果可能同时评估包含函数的表达、筛选 WHERE 以及对 GROUP BY 进行预聚合,使用至少 'max_threads' 数量的线程,则会使用 'max_threads'。 +此参数适用于在查询处理管道中并行执行相同阶段的线程。 +例如,在从表中读取时,如果可以使用至少 'max_threads' 数量的线程并行评估函数的表达式、使用 WHERE 进行筛选和为 GROUP BY 进行预聚合,则将使用 'max_threads'。 + +对于因 LIMIT 快速完成的查询,可以设置较低的 'max_threads'。例如,如果必要数量的条目位于每个块中,且 max_threads = 8,则将检索 8 个块,尽管只需读取一个就够了。 -对于因 LIMIT 而快速完成的查询,您可以设置较低的 'max_threads'。例如,如果所需的条目位于每个块中,并且 max_threads = 8,则会检索 8 个块,尽管只需读取一个就足够了。 +`max_threads` 值越小,消耗的内存越少。 -`max_threads` 值越小,消耗的内存就越少。 +云默认值:`auto(3)`。 ## max_threads_for_indexes {#max_threads_for_indexes} -处理索引的最大线程数量。 +处理索引的最大线程数。 ## max_untracked_memory {#max_untracked_memory} -小的分配和释放在线程本地变量中分组,只有当 (绝对值) 超过指定值时才进行跟踪或分析。如果值高于 'memory_profiler_step',则有效降低到 'memory_profiler_step'。 +小的分配和解除分配被归为线程局部变量,仅在其绝对值超过指定值时才进行跟踪或分析。如果该值高于 'memory_profiler_step',它将有效地降低到 'memory_profiler_step'。 ## memory_overcommit_ratio_denominator {#memory_overcommit_ratio_denominator} -表示在全局级别达到硬限制时的软内存限制。 -此值用于计算查询的超额分配比例。 -为零表示跳过查询。 -阅读有关 [memory overcommit](memory-overcommit.md) 的更多信息。 + + +它表示当全局级别的硬限制达到时的软内存限制。 +此值用于计算查询的过量使用比率。 +零表示跳过查询。 +有关 [内存过量使用](memory-overcommit.md) 的更多信息。 ## memory_overcommit_ratio_denominator_for_user {#memory_overcommit_ratio_denominator_for_user} -表示在用户级别达到硬限制时的软内存限制。 -此值用于计算查询的超额分配比例。 -为零表示跳过查询。 -阅读有关 [memory overcommit](memory-overcommit.md) 的更多信息。 + + +它表示当用户级别的硬限制达到时的软内存限制。 +此值用于计算查询的过量使用比率。 +零表示跳过查询。 +有关 [内存过量使用](memory-overcommit.md) 的更多信息。 + ## memory_profiler_sample_max_allocation_size {#memory_profiler_sample_max_allocation_size} -以 `memory_profiler_sample_probability` 的概率收集小于或等于指定值的随机分配。0表示禁用。您可能希望将 'max_untracked_memory' 设置为 0,以使此阈值按预期工作。 +收集大小小于或等于指定值的随机分配,其概率等于 `memory_profiler_sample_probability`。0 表示禁用。您可能希望将 'max_untracked_memory' 设置为 0,以使此阈值按预期工作。 ## memory_profiler_sample_min_allocation_size {#memory_profiler_sample_min_allocation_size} -以 `memory_profiler_sample_probability` 的概率收集大于或等于指定值的随机分配。0表示禁用。您可能希望将 'max_untracked_memory' 设置为 0,以使此阈值按预期工作。 +收集大小大于或等于指定值的随机分配,其概率等于 `memory_profiler_sample_probability`。0 表示禁用。您可能希望将 'max_untracked_memory' 设置为 0,以使此阈值按预期工作。 ## memory_profiler_sample_probability {#memory_profiler_sample_probability} -收集随机分配和释放,并将它们写入 system.trace_log,标记为 'MemorySample' trace_type。该概率对于每个分配/释放都是适用的,而不取决于分配的大小(可以通过 `memory_profiler_sample_min_allocation_size` 和 `memory_profiler_sample_max_allocation_size` 进行更改)。请注意,只有在未追踪内存超过 'max_untracked_memory' 时,才会进行采样。您可能希望将 'max_untracked_memory' 设置为 0,以实现更细粒度的采样。 +收集随机分配和释放,并将其写入 system.trace_log,跟踪类型为 'MemorySample'。该概率适用于每个分配/释放,无论分配的大小如何(可以通过 `memory_profiler_sample_min_allocation_size` 和 `memory_profiler_sample_max_allocation_size` 进行更改)。请注意,只有当未跟踪内存的数量超过 'max_untracked_memory' 时,才会进行采样。您可能希望将 'max_untracked_memory' 设置为 0 以实现更细粒度的采样。 ## memory_profiler_step {#memory_profiler_step} -设置内存分析器的步长。每当查询内存使用量超过每个下一步字节数时,内存分析器将收集分配的堆栈跟踪并将其写入 [trace_log](/operations/system-tables/trace_log)。 +设置内存分析器的步骤。每当查询内存使用量超过以字节为单位的每个后续步骤时,内存分析器将收集分配堆栈跟踪并将其写入 [trace_log](/operations/system-tables/trace_log)。 -可能的值: +可能值: -- 正整数字节数。 +- 一个正整数的字节数。 - 0 表示关闭内存分析器。 ## memory_tracker_fault_probability {#memory_tracker_fault_probability} -用于测试 `exception safety` - 每次您分配内存时,根据指定的概率抛出异常。 +用于测试 `exception safety` - 每次分配内存时按指定概率抛出异常。 ## memory_usage_overcommit_max_wait_microseconds {#memory_usage_overcommit_max_wait_microseconds} -在用户级别,当出现内存超额分配时,线程等待释放内存的最大时间。 -如果超时到期且内存未释放,则抛出异常。 -阅读有关 [memory overcommit](memory-overcommit.md) 的更多信息。 +在用户级别内存过度分配的情况下,线程等待内存释放的最长时间。如果达到超时而内存未释放,将抛出异常。了解更多关于 [memory overcommit](memory-overcommit.md) 的信息。 ## merge_table_max_tables_to_look_for_schema_inference {#merge_table_max_tables_to_look_for_schema_inference} -在创建没有显式模式的 `Merge` 表或使用 `merge` 表函数时,推断模式作为不超过指定数量匹配表的联合。 -如果表的数量更大,则模式将从前面指定的数量的表中推断。 + + +在创建 `Merge` 表时没有显式架构或者使用 `merge` 表函数时,推导出不超过指定数量匹配表的联合架构。如果表的数量更大,则只从前面指定数量的表中推导架构。 ## merge_tree_coarse_index_granularity {#merge_tree_coarse_index_granularity} -在搜索数据时,ClickHouse 检查索引文件中的数据标记。如果 ClickHouse 发现所需键位于某个范围内,它将把该范围分割成 `merge_tree_coarse_index_granularity` 子范围并递归地在那里搜索所需键。 +在搜索数据时,ClickHouse 会检查索引文件中的数据标记。如果 ClickHouse 发现所需的键在某个范围内,它会将该范围划分为 `merge_tree_coarse_index_granularity` 个子范围,并在其中递归搜索所需的键。 -可能的值: +可能值: - 任何正偶数。 ## merge_tree_compact_parts_min_granules_to_multibuffer_read {#merge_tree_compact_parts_min_granules_to_multibuffer_read} @@ -6205,96 +6347,104 @@ INSERT 查询的 VALUES 子句中的数据由单独的流解析器处理(占 -仅在 ClickHouse Cloud 中生效。用于支持并行读取和预读取的 MergeTree 表紧凑部分的条带中 granule 的数量。如果从远程文件系统读取,使用多缓冲读取会增加读取请求的数量。 +仅在 ClickHouse Cloud 中生效。MergeTree 表的紧凑部分条带中使用多缓冲读取器的最小粒度数,该读取器支持并行读取和预取。在从远程文件系统读取时,使用多缓冲读取器会增加读取请求的数量。 ## merge_tree_determine_task_size_by_prewhere_columns {#merge_tree_determine_task_size_by_prewhere_columns} -是否仅使用预过滤列的大小来确定读取任务的大小。 +是否仅使用 prewhere 列的大小来确定读取任务的大小。 ## merge_tree_max_bytes_to_use_cache {#merge_tree_max_bytes_to_use_cache} -如果 ClickHouse 应该在一个查询中读取超过 `merge_tree_max_bytes_to_use_cache` 字节的数据,则不使用未压缩块的缓存。 +如果 ClickHouse 在一个查询中应读取超过 `merge_tree_max_bytes_to_use_cache` 字节,则不使用未压缩块的缓存。 -未压缩块的缓存存储提取用于查询的数据。ClickHouse 使用该缓存加速对重复小查询的响应。该设置保护缓存不被大量读取数据的查询冲击。[uncompressed_cache_size](/operations/server-configuration-parameters/settings#uncompressed_cache_size) 服务器设置定义未压缩块缓存的大小。 +未压缩块缓存存储为查询提取的数据。ClickHouse 使用此缓存以加快对重复小查询的响应。此设置保护缓存免受读取大量数据的查询破坏。[uncompressed_cache_size](/operations/server-configuration-parameters/settings#uncompressed_cache_size) 服务器设置定义未压缩块的缓存大小。 -可能的值: +可能值: - 任何正整数。 ## merge_tree_max_rows_to_use_cache {#merge_tree_max_rows_to_use_cache} -如果 ClickHouse 应该在一个查询中读取超过 `merge_tree_max_rows_to_use_cache` 行,则不使用未压缩块的缓存。 +如果 ClickHouse 在一个查询中应读取超过 `merge_tree_max_rows_to_use_cache` 行,则不使用未压缩块的缓存。 -未压缩块的缓存存储提取用于查询的数据。ClickHouse 使用该缓存加速对重复小查询的响应。该设置保护缓存不被大量读取数据的查询冲击。[uncompressed_cache_size](/operations/server-configuration-parameters/settings#uncompressed_cache_size) 服务器设置定义未压缩块缓存的大小。 +未压缩块缓存存储为查询提取的数据。ClickHouse 使用此缓存以加快对重复小查询的响应。此设置保护缓存免受读取大量数据的查询破坏。[uncompressed_cache_size](/operations/server-configuration-parameters/settings#uncompressed_cache_size) 服务器设置定义未压缩块的缓存大小。 -可能的值: +可能值: - 任何正整数。 ## merge_tree_min_bytes_for_concurrent_read {#merge_tree_min_bytes_for_concurrent_read} -如果从 [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) 引擎表的一个文件读取的字节数超过 `merge_tree_min_bytes_for_concurrent_read`,则 ClickHouse 尝试在多个线程中同时读取此文件。 +如果从一个 [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) 引擎表中读取的字节数超过 `merge_tree_min_bytes_for_concurrent_read`,则 ClickHouse 尝试在多个线程中并发读取该文件。 -可能的值: +可能值: - 正整数。 ## merge_tree_min_bytes_for_concurrent_read_for_remote_filesystem {#merge_tree_min_bytes_for_concurrent_read_for_remote_filesystem} -读取来自远程文件系统的 [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) 引擎时,在并行化读取之前从一个文件读取的最小字节数。我们不建议使用此设置。 + -可能的值: +从一个文件中读取的最小字节数,才能在读取远程文件系统时, [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) 引擎可以并行化读取。我们不建议使用此设置。 + +可能值: - 正整数。 ## merge_tree_min_bytes_for_seek {#merge_tree_min_bytes_for_seek} -如果要读取的两个数据块在一个文件中的字节数小于 `merge_tree_min_bytes_for_seek`,则 ClickHouse 会顺序读取包含这两个块的文件范围,从而避免额外的寻址。 +如果在一个文件中要读取的两个数据块之间的距离小于 `merge_tree_min_bytes_for_seek` 字节,则 ClickHouse 顺序读取包含这两个块的文件范围,从而避免额外的寻道。 -可能的值: +可能值: - 任何正整数。 ## merge_tree_min_bytes_per_task_for_remote_reading {#merge_tree_min_bytes_per_task_for_remote_reading} + + 每个任务要读取的最小字节数。 ## merge_tree_min_read_task_size {#merge_tree_min_read_task_size} - + -任务大小的硬下限(即使 granule 数量少且可用线程数量多,我们也不会分配更小的任务)。 + + +任务大小的硬下限(即使粒度数量较低,且可用线程数量较高,我们也不会分配较小的任务)。 ## merge_tree_min_rows_for_concurrent_read {#merge_tree_min_rows_for_concurrent_read} -如果要从 [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) 表的一个文件中读取的行数超过 `merge_tree_min_rows_for_concurrent_read`,则 ClickHouse 尝试在多个线程中执行并发读取。 +如果要从一个 [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) 表的文件中读取超过 `merge_tree_min_rows_for_concurrent_read` 行,则 ClickHouse 尝试在多个线程中对该文件进行并发读取。 -可能的值: +可能值: - 正整数。 ## merge_tree_min_rows_for_concurrent_read_for_remote_filesystem {#merge_tree_min_rows_for_concurrent_read_for_remote_filesystem} -在从远程文件系统读取 [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) 引擎表的一个文件之前,读取的行数最小值。我们不建议使用此设置。 + -可能的值: +从一个文件读取的最小行数,才能在读取远程文件系统时,[MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) 引擎可以并行化读取。我们不建议使用此设置。 + +可能值: - 正整数。 ## merge_tree_min_rows_for_seek {#merge_tree_min_rows_for_seek} -如果要读取的两个数据块在一个文件中的行数小于 `merge_tree_min_rows_for_seek`,则 ClickHouse 不会在文件中寻址,而是顺序读取数据。 +如果在一个文件中要读取的两个数据块之间的距离小于 `merge_tree_min_rows_for_seek` 行,则 ClickHouse 不会在文件中寻道,而是顺序读取数据。 -可能的值: +可能值: - 任何正整数。 ## merge_tree_read_split_ranges_into_intersecting_and_non_intersecting_injection_probability {#merge_tree_read_split_ranges_into_intersecting_and_non_intersecting_injection_probability} @@ -6303,33 +6453,38 @@ INSERT 查询的 VALUES 子句中的数据由单独的流解析器处理(占 -用于测试 `PartsSplitter` - 每次从 MergeTree 读取时,按指定概率将读取范围拆分为相交和不相交的插入。 +用于测试 `PartsSplitter` - 每次从 MergeTree 读取时,将读取范围分成重叠和不重叠,在指定概率下进行。 +## merge_tree_storage_snapshot_sleep_ms {#merge_tree_storage_snapshot_sleep_ms} + + + + + +在创建 MergeTree 表的存储快照时,注入人工延迟(以毫秒为单位)。仅用于测试和调试目的。 + +可能值: +- 0 - 无延迟(默认) +- N - 延迟(以毫秒为单位) ## merge_tree_use_const_size_tasks_for_remote_reading {#merge_tree_use_const_size_tasks_for_remote_reading} -是否在从远程表读取时使用固定大小的任务。 +是否使用固定大小的任务来从远程表读取。 ## merge_tree_use_deserialization_prefixes_cache {#merge_tree_use_deserialization_prefixes_cache} - - -启用从 MergeTree 中宽部分读取时文件前缀的列元数据缓存。 +启用从远程磁盘读取 MergeTree 时,文件前缀的列元数据缓存。 ## merge_tree_use_prefixes_deserialization_thread_pool {#merge_tree_use_prefixes_deserialization_thread_pool} - - -启用在 MergeTree 的宽部分中进行并行前缀读取的线程池。该线程池的大小由服务器设置 `max_prefixes_deserialization_thread_pool_size` 控制。 +启用对 MergeTree 中宽部分的前缀读取的线程池进行并行化。该线程池的大小由服务器设置 `max_prefixes_deserialization_thread_pool_size` 控制。 ## merge_tree_use_v1_object_and_dynamic_serialization {#merge_tree_use_v1_object_and_dynamic_serialization} - - -启用后,MergeTree 中将使用 JSON 和动态类型的 V1 序列化版本,而不是 V2。更改此设置仅在服务器重启后生效。 +启用时,将在 MergeTree 中使用 JSON 和动态类型的 V1 序列化版本,而不是 V2。更改此设置只在服务器重启后生效。 ## metrics_perf_events_enabled {#metrics_perf_events_enabled} @@ -6337,16 +6492,16 @@ INSERT 查询的 VALUES 子句中的数据由单独的流解析器处理(占 如果启用,则在查询执行过程中将测量某些性能事件。 ## metrics_perf_events_list {#metrics_perf_events_list} -由逗号分隔的性能指标列表,在查询执行过程中会测量这些指标。为空表示所有事件。请参见源中的 PerfEventInfo 以获取可用事件。 +以逗号分隔的性能指标列表,将在查询执行期间进行测量。为空表示所有事件。有关可用事件的信息,请参阅源中的 PerfEventInfo。 ## min_bytes_to_use_direct_io {#min_bytes_to_use_direct_io} 使用直接 I/O 访问存储磁盘所需的最小数据量。 -ClickHouse 在从表中读取数据时使用此设置。如果要读取的所有数据的总存储量超过 `min_bytes_to_use_direct_io` 字节,则 ClickHouse 使用 `O_DIRECT` 选项从存储磁盘读取数据。 +ClickHouse 在从表中读取数据时使用此设置。如果要读取的所有数据的总存储量超过 `min_bytes_to_use_direct_io` 字节,则 ClickHouse 将使用 `O_DIRECT` 选项从存储磁盘读取数据。 -可能的值: +可能值: - 0 — 禁用直接 I/O。 - 正整数。 @@ -6354,142 +6509,131 @@ ClickHouse 在从表中读取数据时使用此设置。如果要读取的所有 -这是一个实验性设置。设置读取大文件而不复制数据从内核到用户空间所需的最小内存量。建议的阈值约为 64MB,因为 [mmap/munmap](https://en.wikipedia.org/wiki/Mmap) 较慢。对于大文件只有在数据存在于页面缓存中时,才有意义。 +这是一个实验性设置。设置读取大文件而不从内核复制数据到用户空间所需的最小内存量。推荐阈值约为 64 MB,因为 [mmap/munmap](https://en.wikipedia.org/wiki/Mmap) 速度较慢。它仅在大文件时有意义,并且仅在数据位于页面缓存中时才有效。 -可能的值: +可能值: - 正整数。 -- 0 — 大文件仅通过复制数据从内核到用户空间读取。 +- 0 — 大文件仅通过从内核复制数据到用户空间读取。 ## min_chunk_bytes_for_parallel_parsing {#min_chunk_bytes_for_parallel_parsing} -- 类型:无符号整型 +- 类型:无符号整数 - 默认值:1 MiB -每个线程将并行解析的最小块大小(以字节为单位)。 +每个线程并行解析的最小块大小(以字节为单位)。 ## min_compress_block_size {#min_compress_block_size} -针对 [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) 表。在处理查询时,为了减少延迟,如果下一个标记的大小至少为 `min_compress_block_size`,则在写入时压缩块。默认值为 65,536。 +对于 [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) 表。为了减少处理查询的延迟,当写入下一个标记时,如果其大小至少为 `min_compress_block_size`,则会压缩块。默认值为 65,536。 -如果未压缩数据的实际大小小于 `max_compress_block_size`,则此块的大小不小于该值,且不小于一个标记所需的数据量。 +如果未压缩数据的实际大小小于 `max_compress_block_size`,则块的实际大小不小于该值,并且至少不小于一个标记的数据量。 -我们看一个例子。假设在创建表时将 `index_granularity` 设置为 8192。 +让我们看一个例子。假设在创建表时将 `index_granularity` 设置为 8192。 -我们写入一个 UInt32 类型的列(每个值 4 字节)。当写入 8192 行时,总共有 32 KB 的数据。由于 `min_compress_block_size = 65,536`,因此每两个标记形成一个压缩块。 +我们正在写入 UInt32 类型的列(每个值 4 字节)。写入 8192 行时,总共 32 KB 的数据。由于 min_compress_block_size = 65,536,每两个标记将形成一个压缩块。 -我们写入一个字符串类型的 URL 列(每个值的平均大小为 60 字节)。当写入 8192 行时,平均的数据量略少于 500 KB。因为这大于 65,536,所以每个标记形成一个压缩块。在这种情况下,读取单个标记范围内的数据时,不会额外解压缩。 +我们正在写入一个字符串类型的 URL 列(平均每值 60 字节)。写入 8192 行时,平均将略低于 500 KB 的数据。由于这大于 65,536,将为每个标记形成一个压缩块。在这种情况下,从磁盘读取单个标记范围时,不会解压缩额外的数据。 :::note -这是一个专家级别的设置,如果您刚开始使用 ClickHouse,不应该更改它。 +这是一个专家级设置,如果您刚开始使用 ClickHouse,则不应更改它。 ::: ## min_count_to_compile_aggregate_expression {#min_count_to_compile_aggregate_expression} -启动 JIT 编译所需的最少相同聚合表达式数量。仅在启用 [compile_aggregate_expressions](#compile_aggregate_expressions) 设置时有效。 +开始 JIT 编译的最小相同聚合表达式数量。仅在启用 [compile_aggregate_expressions](#compile_aggregate_expressions) 设置时有效。 -可能的值: +可能值: - 正整数。 -- 0 — 始终 JIT 编译相同的聚合表达式。 +- 0 — 相同的聚合表达式始终 JIT 编译。 ## min_count_to_compile_expression {#min_count_to_compile_expression} -执行相同表达式之前的最小计数。 +执行同一表达式之前的最小计数,以便进行编译。 ## min_count_to_compile_sort_description {#min_count_to_compile_sort_description} -在 JIT 编译之前相同排序描述的数量。 +在 JIT 编译之前需要的相同排序描述的数量。 ## min_execution_speed {#min_execution_speed} -每秒的最小执行速度(以行计)。在 [`timeout_before_checking_execution_speed`](/operations/settings/settings#timeout_before_checking_execution_speed) 到期时,会检查每个数据块。如果执行速度较低,则会抛出异常。 +每秒最低执行速度(以行计)。在 [`timeout_before_checking_execution_speed`](/operations/settings/settings#timeout_before_checking_execution_speed) 到期时检查每个数据块。如果执行速度较低,则会抛出异常。 ## min_execution_speed_bytes {#min_execution_speed_bytes} -每秒的最小执行字节数。会在 [`timeout_before_checking_execution_speed`](/operations/settings/settings#timeout_before_checking_execution_speed) 到期时检查每个数据块。如果执行速度较低,则会抛出异常。 -## min_external_sort_block_bytes {#min_external_sort_block_bytes} - - - - - -外部排序的最小块大小(以字节为单位),需转储到磁盘,以避免过多文件。 +每秒最低执行字节数(以字节计)。在 [`timeout_before_checking_execution_speed`](/operations/settings/settings#timeout_before_checking_execution_speed) 到期时检查每个数据块。如果执行速度较低,则会抛出异常。 ## min_external_table_block_size_bytes {#min_external_table_block_size_bytes} - - -将传递给外部表的块压缩到指定的字节大小,如果块不够大。 +如果块不够大,则将传递给外部表的块压缩到指定的字节大小。 ## min_external_table_block_size_rows {#min_external_table_block_size_rows} - - -将传递给外部表的块压缩到指定的行大小,如果块不够大。 +如果块不够大,则将传递给外部表的块压缩到指定的行数。 ## min_free_disk_bytes_to_perform_insert {#min_free_disk_bytes_to_perform_insert} -执行插入所需的最小空闲磁盘空间(以字节为单位)。 +执行插入操作所需的最小可用磁盘空间字节数。 ## min_free_disk_ratio_to_perform_insert {#min_free_disk_ratio_to_perform_insert} -执行插入所需的最小空闲磁盘空间比例。 +执行插入操作所需的最小可用磁盘空间比例。 ## min_free_disk_space_for_temporary_data {#min_free_disk_space_for_temporary_data} -写入在外部排序和聚合中使用的临时数据时所需保持的最小磁盘空间。 +写入用于外部排序和聚合的临时数据时所需的最小磁盘空间。 ## min_hit_rate_to_use_consecutive_keys_optimization {#min_hit_rate_to_use_consecutive_keys_optimization} -进行连续键优化以维持启用的缓存的最小命中率。 +在聚合中用于连续键优化的缓存的最小命中率,以保持其启用。 ## min_insert_block_size_bytes {#min_insert_block_size_bytes} -设置通过 `INSERT` 查询插入到表中的块的最小字节数。较小的块会被压缩为更大的块。 +设置可以通过 `INSERT` 查询插入到表中的块的最小字节数。较小的块会被压缩成较大的块。 -可能的值: +可能值: - 正整数。 - 0 — 禁用压缩。 ## min_insert_block_size_bytes_for_materialized_views {#min_insert_block_size_bytes_for_materialized_views} -通过 `INSERT` 查询插入到表中的块的最小字节数。较小的块会被压缩为更大的块。此设置仅适用于插入到 [物化视图](../../sql-reference/statements/create/view.md) 中的块。通过调整此设置,可以控制在推送到物化视图时的块压缩,避免过多的内存使用。 +设置可以通过 `INSERT` 查询插入到表中的块的最小字节数。较小的块会被压缩成较大的块。此设置仅适用于插入到 [物化视图](../../sql-reference/statements/create/view.md) 的块。通过调整此设置,您可以控制推送到物化视图时的块压缩,并避免过度使用内存。 -可能的值: +可能值: - 任何正整数。 - 0 — 禁用压缩。 -**另请参见** +**另见** - [min_insert_block_size_bytes](#min_insert_block_size_bytes) ## min_insert_block_size_rows {#min_insert_block_size_rows} -通过 `INSERT` 查询插入到表中的块的最小行数。较小的块会被压缩为更大的块。 +设置可以通过 `INSERT` 查询插入到表中的块的最小行数。较小的块会被压缩成较大的块。 -可能的值: +可能值: - 正整数。 - 0 — 禁用压缩。 ## min_insert_block_size_rows_for_materialized_views {#min_insert_block_size_rows_for_materialized_views} -通过 `INSERT` 查询插入到表中的块的最小行数。较小的块会被压缩为更大的块。此设置仅适用于插入到 [物化视图](../../sql-reference/statements/create/view.md) 中的块。通过调整此设置,可以控制在推送到物化视图时的块压缩,避免过多的内存使用。 +设置可以通过 `INSERT` 查询插入到表中的块的最小行数。较小的块会被压缩成较大的块。此设置仅适用于插入到 [物化视图](../../sql-reference/statements/create/view.md) 的块。通过调整此设置,您可以控制推送到物化视图时的块压缩,并避免过度使用内存。 -可能的值: +可能值: - 任何正整数。 - 0 — 禁用压缩。 -**另请参见** +**另见** - [min_insert_block_size_rows](#min_insert_block_size_rows) ## min_joined_block_size_bytes {#min_joined_block_size_bytes} @@ -6498,185 +6642,165 @@ ClickHouse 在从表中读取数据时使用此设置。如果要读取的所有 -JOIN 结果的最小块大小(如果连接算法支持)。0 表示无限制。 +JOIN 输入和输出块的最小块大小(以字节为单位)(如果连接算法支持)。小块将被压缩。0 表示无限制。 +## min_joined_block_size_rows {#min_joined_block_size_rows} + + + + + +JOIN 输入和输出块的最小行数(如果连接算法支持)。小块将被压缩。0 表示无限制。 ## min_os_cpu_wait_time_ratio_to_throw {#min_os_cpu_wait_time_ratio_to_throw} -操作系统 CPU 等待(OSCPUWaitMicroseconds 指标)和繁忙(OSCPUVirtualTimeMicroseconds 指标)时间之间的最小比率,以考虑拒绝查询。使用最小和最大比率之间的线性插值来计算概率,该点的概率为 0。 +考虑拒绝查询的操作系统 CPU 等待(OSCPUWaitMicroseconds 指标)和繁忙(OSCPUVirtualTimeMicroseconds 指标)时间的最小比例。使用线性插值在最小和最大比率之间计算概率,该点时概率为 0。 +## min_outstreams_per_resize_after_split {#min_outstreams_per_resize_after_split} + + + + + +指定在生成管道过程中执行拆分时,`Resize` 或 `StrictResize` 处理器的最小输出流数量。如果生成的流数少于此值,拆分操作将不会发生。 +### 什么是 Resize 节点 +`Resize` 节点是查询管道中的处理器,负责调整流经管道的数据流数量。它可以增加或减少流的数量,以平衡多个线程或处理器之间的工作负载。例如,如果查询需要更多并行性,则 `Resize` 节点可以将单个流拆分为多个流。相反,可以将多个流合并为更少的流,以整合数据处理。 + +`Resize` 节点确保数据在流之间均匀分配,保持数据块的结构。这有助于优化资源利用率并提高查询性能。 +### 为什么需要拆分 Resize 节点 +在管道执行过程中,中央集线的 `Resize` 节点的 ExecutingGraph::Node::status_mutex 受到高度争用,尤其是在高核心数环境中,这种争用导致: +1. ExecutingGraph::updateNode 的延迟增加,直接影响查询性能。 +2. 在自旋锁争用中,因浪费了过多的 CPU 周期 (native_queued_spin_lock_slowpath),降低了效率。 +3. CPU 利用率降低,限制并行性和吞吐量。 +### 如何拆分 Resize 节点 +1. 检查输出流的数量,以确保可以执行拆分:每个拆分处理器的输出流数量满足或超过 `min_outstreams_per_resize_after_split` 阈值。 +2. 将 `Resize` 节点划分为具有相同端口数量的小型 `Resize` 节点,每个节点处理一部分输入和输出流。 +3. 每组独立处理,减少锁争用。 +### 拆分具有任意输入/输出的 Resize 节点 +在某些情况下,当输入/输出无法被拆分的 `Resize` 节点数量整除时,一些输入被连接到 `NullSource`,而一些输出连接到 `NullSink`。这允许拆分发生,而不影响整体数据流。 +### 设置的目的 +`min_outstreams_per_resize_after_split` 设置确保 `Resize` 节点的拆分是有意义的,避免了生成太少的流,这可能导致低效的并行处理。通过强制实施输出流的最小数量,此设置有助于在涉及流拆分和合并的场景中优化查询执行,在并行性和开销之间保持平衡。 +### 禁用此设置 +要禁用 `Resize` 节点的拆分,请将此设置设置为 0。这将防止在生成管道时拆分 `Resize` 节点,允许它们保留原始结构,而不会拆分成更小的节点。 ## mongodb_throw_on_unsupported_query {#mongodb_throw_on_unsupported_query} -如果启用,当无法构建 MongoDB 查询时,MongoDB 表将返回错误。否则,ClickHouse 将读取完整表并在本地处理。如果 'allow_experimental_analyzer=0',则此选项不适用。 +如果启用,当无法构建 MongoDB 查询时,MongoDB 表将返回错误。否则,ClickHouse 将读取整个表并在本地处理它。当 'allow_experimental_analyzer=0' 时,此选项不适用。 ## move_all_conditions_to_prewhere {#move_all_conditions_to_prewhere} -将所有可行的条件从 WHERE 移动到 PREWHERE。 +将所有可行条件从 WHERE 移动到 PREWHERE。 ## move_primary_key_columns_to_end_of_prewhere {#move_primary_key_columns_to_end_of_prewhere} -将包含主键列的 PREWHERE 条件移动到 AND 链的末尾。这些条件在主键分析过程中可能会被考虑,因此不会对 PREWHERE 过滤贡献太多。 +将包含主键列的 PREWHERE 条件移动到 AND 链的末尾。这些条件在主键分析中可能会被考虑,因此不会对 PREWHERE 过滤产生很大贡献。 ## multiple_joins_try_to_keep_original_names {#multiple_joins_try_to_keep_original_names} -在多个连接重写时,不要向顶级表达式列表添加别名。 +在多个连接重写时,不在顶层表达式列表中添加别名。 ## mutations_execute_nondeterministic_on_initiator {#mutations_execute_nondeterministic_on_initiator} - - - - -如果为真,则在触发器上执行恒定的非确定性函数(例如函数 `now()`),并在 `UPDATE` 和 `DELETE` 查询中替换为文字。这有助于在使用恒定非确定性函数执行变更时保持副本中的数据同步。默认值:`false`。 +如果为真常量非确定性函数(例如函数 `now()`)在发起者上执行并在 `UPDATE` 和 `DELETE` 查询中替换为文字。这有助于在执行常量非确定性函数的突变时保持副本中的数据同步。默认值:`false`。 ## mutations_execute_subqueries_on_initiator {#mutations_execute_subqueries_on_initiator} - - - - -如果为真,则标量子查询在触发器上执行,并在 `UPDATE` 和 `DELETE` 查询中替换为文字。默认值:`false`。 +如果为真标量子查询在发起者上执行,并在 `UPDATE` 和 `DELETE` 查询中替换为文字。默认值:`false`。 ## mutations_max_literal_size_to_replace {#mutations_max_literal_size_to_replace} - - - - -在 `UPDATE` 和 `DELETE` 查询中要替换的序列化文字的最大大小(以字节为单位)。仅在上述两个设置中至少有一个启用时生效。默认值:16384(16 KiB)。 +在 `UPDATE` 和 `DELETE` 查询中要替换的序列化文字的最大字节大小。仅在启用上述两个设置中的至少一个时生效。默认值:16384(16 KiB)。 ## mutations_sync {#mutations_sync} +允许以同步方式执行 `ALTER TABLE ... UPDATE|DELETE|MATERIALIZE INDEX|MATERIALIZE PROJECTION|MATERIALIZE COLUMN|MATERIALIZE STATISTICS` 查询([突变](../../sql-reference/statements/alter/index.md/#mutations))。 +可能值: - - -允许在同步方式下执行 `ALTER TABLE ... UPDATE|DELETE|MATERIALIZE INDEX|MATERIALIZE PROJECTION|MATERIALIZE COLUMN|MATERIALIZE STATISTICS` 查询 ([mutations](../../sql-reference/statements/alter/index.md/#mutations))。 - -可能的值: - -- 0 - 变更异步执行。 -- 1 - 查询等待当前服务器上所有变更完成。 -- 2 - 查询等待所有副本(如果存在)的所有变更完成。 +| 值 | 描述 | +|-------|-----------------------------------------------------------------------------------------------------------------------------------------------------| +| `0` | 突变异步执行。 | +| `1` | 查询等待当前服务器上的所有突变完成。 | +| `2` | 查询等待所有副本上的所有突变完成(如果存在)。 | +| `3` | 查询只等待活动副本。仅支持 `SharedMergeTree`。对于 `ReplicatedMergeTree`,它的行为与 `mutations_sync = 2` 相同。| ## mysql_datatypes_support_level {#mysql_datatypes_support_level} -定义 MySQL 类型如何转换为相应的 ClickHouse 类型。以逗号分隔的列表,可以是 `decimal`、`datetime64`、`date2Date32` 或 `date2String` 的任何组合。 -- `decimal`:将 `NUMERIC` 和 `DECIMAL` 类型转换为 `Decimal`,当精度允许时。 -- `datetime64`:将 `DATETIME` 和 `TIMESTAMP` 类型转换为 `DateTime64`,而不是 `DateTime`,当精度不为 `0` 时。 -- `date2Date32`:将 `DATE` 转换为 `Date32`,而不是 `Date`。优先于 `date2String`。 -- `date2String`:将 `DATE` 转换为 `String`,而不是 `Date`。被 `datetime64` 覆盖。 +定义 MySQL 类型如何转换为相应的 ClickHouse 类型。以逗号分隔的列表,可以为 `decimal`、`datetime64`、`date2Date32` 或 `date2String` 的任意组合。 +- `decimal`:在精度允许时,将 `NUMERIC` 和 `DECIMAL` 类型转换为 `Decimal`。 +- `datetime64`:在精度不为 `0` 时,将 `DATETIME` 和 `TIMESTAMP` 类型转换为 `DateTime64` 而不是 `DateTime`。 +- `date2Date32`:将 `DATE` 转换为 `Date32` 而不是 `Date`。优先于 `date2String`。 +- `date2String`:将 `DATE` 转换为 `String` 而不是 `Date`。被 `datetime64` 重写。 ## mysql_map_fixed_string_to_text_in_show_columns {#mysql_map_fixed_string_to_text_in_show_columns} - - - - -启用后,ClickHouse 的 [FixedString](../../sql-reference/data-types/fixedstring.md) 数据类型将在 [SHOW COLUMNS](../../sql-reference/statements/show.md/#show_columns) 中显示为 `TEXT`。 +如果启用,[FixedString](../../sql-reference/data-types/fixedstring.md) ClickHouse 数据类型将显示为 [SHOW COLUMNS](../../sql-reference/statements/show.md/#show_columns)中的 `TEXT`。 -仅在通过 MySQL 线协议连接时有效。 +仅在通过 MySQL 线协议建立连接时有效。 - 0 - 使用 `BLOB`。 - 1 - 使用 `TEXT`。 ## mysql_map_string_to_text_in_show_columns {#mysql_map_string_to_text_in_show_columns} - - - - -启用后,ClickHouse 的 [String](../../sql-reference/data-types/string.md) 数据类型将在 [SHOW COLUMNS](../../sql-reference/statements/show.md/#show_columns) 中显示为 `TEXT`。 +如果启用,[String](../../sql-reference/data-types/string.md) ClickHouse 数据类型将显示为 [SHOW COLUMNS](../../sql-reference/statements/show.md/#show_columns)中的 `TEXT`。 -仅在通过 MySQL 线协议连接时有效。 +仅在通过 MySQL 线协议建立连接时有效。 - 0 - 使用 `BLOB`。 - 1 - 使用 `TEXT`。 ## mysql_max_rows_to_insert {#mysql_max_rows_to_insert} - - -MySQL 存储引擎批量插入的最大行数。 +MySQL 存储引擎的 MySQL 批量插入中最大行数。 ## network_compression_method {#network_compression_method} +客户端/服务器和服务器/服务器通信的压缩编解码器。 +可能值: - - -设置用于服务器之间以及服务器与 [clickhouse-client](../../interfaces/cli.md) 之间通信的数据压缩方法。 - -可能的值: - -- `LZ4` — 设置 LZ4 压缩方法。 -- `ZSTD` — 设置 ZSTD 压缩方法。 +- `NONE` — 无压缩。 +- `LZ4` — 使用 LZ4 编解码器。 +- `LZ4HC` — 使用 LZ4HC 编解码器。 +- `ZSTD` — 使用 ZSTD 编解码器。 -**另请参见** +**另见** - [network_zstd_compression_level](#network_zstd_compression_level) ## network_zstd_compression_level {#network_zstd_compression_level} +调整 ZSTD 压缩级别。仅在将 [network_compression_method](#network_compression_method) 设置为 `ZSTD` 时使用。 - - - -调整 ZSTD 压缩级别。仅在 [network_compression_method](#network_compression_method) 设置为 `ZSTD` 时使用。 - -可能的值: +可能值: - 从 1 到 15 的正整数。 ## normalize_function_names {#normalize_function_names} - - - - -将函数名称规范化为其规范名称。 +将函数名称规范化为其标准名称。 ## number_of_mutations_to_delay {#number_of_mutations_to_delay} - - - - -如果变更表中包含至少这么多未完成的变更,人工减慢表的变更速度。0 - 禁用。 +如果被突变的表包含至少那么多未完成的突变,请人为减缓表的突变。0 - 禁用。 ## number_of_mutations_to_throw {#number_of_mutations_to_throw} - - - - -如果变更表中包含至少这么多未完成的变更,则抛出“变更过多...”异常。0 - 禁用。 +如果被突变的表包含至少那么多未完成的突变,则抛出 'Too many mutations ...' 异常。0 - 禁用。 ## odbc_bridge_connection_pool_size {#odbc_bridge_connection_pool_size} - - - - -ODBC 桥每个连接设置字符串的连接池大小。 +ODBC 桥中每个连接设置字符串的连接池大小。 ## odbc_bridge_use_connection_pooling {#odbc_bridge_use_connection_pooling} +在 ODBC 桥中使用连接池。如果设置为 false,则每次都会创建新连接。 +## offset {#offset} +设置在开始返回查询结果之前要跳过的行数。它调整由 [OFFSET](/sql-reference/statements/select/offset) 子句设置的偏移量,使这两个值相加。 - - -在 ODBC 桥中使用连接池。如果设置为 false,则每次都会创建一个新连接。 -## offset {#offset} - - - - - -设置在开始返回查询行之前要跳过的行数。它调整由 [OFFSET](/sql-reference/statements/select/offset) 子句设置的偏移量,以便这两个值相加。 - -可能的值: +可能值: - 0 — 不跳过任何行。 - 正整数。 @@ -6708,80 +6832,66 @@ SELECT * FROM test LIMIT 10 OFFSET 100; ``` ## opentelemetry_start_trace_probability {#opentelemetry_start_trace_probability} - - -设置 ClickHouse 可以为执行的查询启动跟踪的概率(如果没有提供父 [trace context](https://www.w3.org/TR/trace-context/))。 +设置 ClickHouse 在执行查询时可以启动跟踪的概率(前提是没有提供父级 [跟踪上下文](https://www.w3.org/TR/trace-context/))。 -可能的值: +可能值: -- 0 — 禁用所有执行查询的跟踪(如果没有提供父跟踪上下文)。 -- 在 [0..1] 范围内的正浮点数。例如,如果设置值为 `0.5`,ClickHouse 可以平均对一半的查询启动跟踪。 +- 0 — 禁用所有执行查询的跟踪(如果没有提供父级跟踪上下文)。 +- 在 [0..1] 范围内的正浮点数。例如,如果设置值为 `0.5`,则 ClickHouse 可以平均启动一半查询的跟踪。 - 1 — 启用所有执行查询的跟踪。 -## opentelemetry_trace_processors {#opentelemetry_trace_processors} - - +## opentelemetry_trace_cpu_scheduling {#opentelemetry_trace_cpu_scheduling} -收集 OpenTelemetry 的处理程序跨度。 -## optimize_aggregation_in_order {#optimize_aggregation_in_order} - + +为工作负载抢占式 CPU 调度收集 OpenTelemetry 跨度。 +## opentelemetry_trace_processors {#opentelemetry_trace_processors} -启用 [GROUP BY](/sql-reference/statements/select/group-by) 优化,以便在 [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) 表中按照相应顺序聚合数据。 +收集 OpenTelemetry 跨度以获取处理器。 +## optimize_aggregation_in_order {#optimize_aggregation_in_order} -可能的值: +启用在 [SELECT](../../sql-reference/statements/select/index.md) 查询中的 [GROUP BY](/sql-reference/statements/select/group-by) 优化,以便在 [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) 表中按相应顺序聚合数据。 + +可能值: - 0 — 禁用 `GROUP BY` 优化。 - 1 — 启用 `GROUP BY` 优化。 -**另请参见** +**另见** - [GROUP BY 优化](/sql-reference/statements/select/group-by#group-by-optimization-depending-on-table-sorting-key) ## optimize_aggregators_of_group_by_keys {#optimize_aggregators_of_group_by_keys} +消除在 SELECT 部分的 GROUP BY 键的 min/max/any/anyLast 聚合器。 - - - -消除 SELECT 部分 GROUP BY 键的 min/max/any/anyLast 聚合器。 ## optimize_and_compare_chain {#optimize_and_compare_chain} - - - - -填充常量比较,以及 AND 链以增强过滤能力。支持运算符 `<`、`<=`、`>`、`>=`、`=` 及其混合。例如,`(a < b) AND (b < c) AND (c < 5)` 将变成 `(a < b) AND (b < c) AND (c < 5) AND (b < 5) AND (a < 5)`。 +在 AND 链中填充常量比较以增强过滤能力。支持运算符 `<`, `<=`, `>`, `>=`, `=` 及其混合。例如,`(a < b) AND (b < c) AND (c < 5)` 将变为 `(a < b) AND (b < c) AND (c < 5) AND (b < 5) AND (a < 5)`。 ## optimize_append_index {#optimize_append_index} - - -使用 [constraints](../../sql-reference/statements/create/table.md/#constraints) 以附加索引条件。默认值为 `false`。 +使用 [constraints](../../sql-reference/statements/create/table.md/#constraints) 来附加索引条件。默认值为 `false`。 可能的值: -- true,false +- true, false ## optimize_arithmetic_operations_in_aggregate_functions {#optimize_arithmetic_operations_in_aggregate_functions} - - 将算术运算移出聚合函数。 ## optimize_count_from_files {#optimize_count_from_files} - - 启用或禁用从不同输入格式的文件中计算行数的优化。适用于表函数/引擎 `file`/`s3`/`url`/`hdfs`/`azureBlobStorage`。 @@ -6792,20 +6902,16 @@ SELECT * FROM test LIMIT 10 OFFSET 100; - 1 — 优化启用。 ## optimize_distinct_in_order {#optimize_distinct_in_order} - - -如果某些 DISTINCT 列形成排序的前缀,则启用 DISTINCT 优化。例如,MergeTree 中的排序键前缀或 ORDER BY 语句。 +如果 DISTINCT 中的一些列形成排序的前缀,则启用 DISTINCT 优化。例如,merge tree 中的排序键前缀或 ORDER BY 语句。 ## optimize_distributed_group_by_sharding_key {#optimize_distributed_group_by_sharding_key} - - -优化 `GROUP BY sharding_key` 查询,通过避免在触发器服务器上进行昂贵的聚合(这将减少触发器服务器上查询的内存使用)。 +通过避免在发起服务器上进行成本高昂的聚合,优化 `GROUP BY sharding_key` 查询(这将减少发起服务器上查询的内存使用)。 -支持以下类型的查询(及其组合): +支持以下类型的查询(及其所有组合): - `SELECT DISTINCT [..., ]sharding_key[, ...] FROM dist` - `SELECT ... FROM dist GROUP BY sharding_key[, ...]` @@ -6813,7 +6919,7 @@ SELECT * FROM test LIMIT 10 OFFSET 100; - `SELECT ... FROM dist GROUP BY sharding_key[, ...] LIMIT 1` - `SELECT ... FROM dist GROUP BY sharding_key[, ...] LIMIT 1 BY x` -以下类型的查询不支持(某些查询的支持可能稍后添加): +不支持以下类型的查询(可能稍后会增加对某些查询的支持): - `SELECT ... GROUP BY sharding_key[, ...] WITH TOTALS` - `SELECT ... GROUP BY sharding_key[, ...] WITH ROLLUP` @@ -6825,47 +6931,42 @@ SELECT * FROM test LIMIT 10 OFFSET 100; - 0 — 禁用。 - 1 — 启用。 -另请参见: +另见: - [distributed_group_by_no_merge](#distributed_group_by_no_merge) - [distributed_push_down_limit](#distributed_push_down_limit) - [optimize_skip_unused_shards](#optimize_skip_unused_shards) :::note -现在它需要 `optimize_skip_unused_shards`(原因在于,某一天这可能会默认启用,而只有在数据通过分布式表插入时才能正确工作,即数据根据 sharding_key 分布)。 +现在需要 `optimize_skip_unused_shards`(原因是将来可能默认启用,如果数据是通过分布式表插入的,也就是说数据根据 sharding_key 分布,则将正常工作)。 ::: -## optimize_extract_common_expressions {#optimize_extract_common_expressions} - - +## optimize_empty_string_comparisons {#optimize_empty_string_comparisons} + +将 col = '' 或 '' = col 的表达式转换为 empty(col),并将 col != '' 或 '' != col 转换为 notEmpty(col),仅当 col 的类型为 String 或 FixedString 时。 +## optimize_extract_common_expressions {#optimize_extract_common_expressions} - + -允许从 WHERE、PREWHERE、ON、HAVING 和 QUALIFY 表达式中的析取中提取公共表达式。逻辑表达式如 `(A AND B) OR (A AND C)` 可以重写为 `A AND (B OR C)`,这可能有助于利用: -- 在简单过滤表达式中使用索引 -- 交叉到内部连接优化 +允许从 WHERE、PREWHERE、ON、HAVING 和 QUALIFY 表达式中的析取中提取共同表达式。逻辑表达式如 `(A AND B) OR (A AND C)` 可以重写为 `A AND (B OR C)`,这可能有助于利用: +- 简单过滤表达式中的索引 +- 交叉到内部连接的优化 ## optimize_functions_to_subcolumns {#optimize_functions_to_subcolumns} - - +启用或禁用通过将某些函数转换为读取子列的优化。这减少了读取的数据量。 - - - -启用或禁用通过将某些函数转换为读取子列进行优化。这可以减少要读取的数据量。 - -可以转换的这些函数: +以下函数可以被转换: - [length](/sql-reference/functions/array-functions#length) 读取 [size0](../../sql-reference/data-types/array.md/#array-size) 子列。 - [empty](/sql-reference/functions/array-functions#empty) 读取 [size0](../../sql-reference/data-types/array.md/#array-size) 子列。 -- [notEmpty](/sql-reference/functions/array-functions#notempty) 读取 [size0](../../sql-reference/data-types/array.md/#array-size) 子列。 -- [isNull](/sql-reference/functions/functions-for-nulls#isnull) 读取 [null](../../sql-reference/data-types/nullable.md/#finding-null) 子列。 -- [isNotNull](/sql-reference/functions/functions-for-nulls#isnotnull) 读取 [null](../../sql-reference/data-types/nullable.md/#finding-null) 子列。 +- [notEmpty](/sql-reference/functions/array-functions#notEmpty) 读取 [size0](../../sql-reference/data-types/array.md/#array-size) 子列。 +- [isNull](/sql-reference/functions/functions-for-nulls#isNull) 读取 [null](../../sql-reference/data-types/nullable.md/#finding-null) 子列。 +- [isNotNull](/sql-reference/functions/functions-for-nulls#isNotNull) 读取 [null](../../sql-reference/data-types/nullable.md/#finding-null) 子列。 - [count](/sql-reference/aggregate-functions/reference/count) 读取 [null](../../sql-reference/data-types/nullable.md/#finding-null) 子列。 - [mapKeys](/sql-reference/functions/tuple-map-functions#mapkeys) 读取 [keys](/sql-reference/data-types/map#reading-subcolumns-of-map) 子列。 - [mapValues](/sql-reference/functions/tuple-map-functions#mapvalues) 读取 [values](/sql-reference/data-types/map#reading-subcolumns-of-map) 子列。 @@ -6876,75 +6977,45 @@ SELECT * FROM test LIMIT 10 OFFSET 100; - 1 — 优化启用。 ## optimize_group_by_constant_keys {#optimize_group_by_constant_keys} - - - - -优化 GROUP BY,当块中的所有键都是常量时。 +当块中的所有键都是常量时优化 GROUP BY。 ## optimize_group_by_function_keys {#optimize_group_by_function_keys} - - -消除 GROUP BY 部分的其他键的函数。 +在 GROUP BY 部分消除其他键的函数。 ## optimize_if_chain_to_multiif {#optimize_if_chain_to_multiif} - - -将 if(cond1, then1, if(cond2, ...)) 链替换为 multiIf。当前这对数值类型没有益处。 +将 `if(cond1, then1, if(cond2, ...))` 链替换为 multiIf。目前对于数值类型没有好处。 ## optimize_if_transform_strings_to_enum {#optimize_if_transform_strings_to_enum} - - -将 If 和 Transform 中的字符串类型参数替换为枚举。默认情况下禁用,因为这样可能导致分布式查询中的不一致变化,从而导致失败。 +在 If 和 Transform 中将字符串类型参数替换为枚举。默认禁用,因为这可能会导致分布式查询中的不一致变化,进而导致失败。 ## optimize_injective_functions_in_group_by {#optimize_injective_functions_in_group_by} - - - - - - -在 GROUP BY 部分用其参数替换注入函数。 +在 GROUP BY 部分中用其参数替换注射函数。 ## optimize_injective_functions_inside_uniq {#optimize_injective_functions_inside_uniq} - - - - -删除 uniq*() 函数内部一个参数的注入函数。 +删除 uniq*() 函数内部的单个参数注射函数。 ## optimize_min_equality_disjunction_chain_length {#optimize_min_equality_disjunction_chain_length} - - - - -用于优化的表达式 `expr = x1 OR ... expr = xN` 的最小长度。 +表达式 `expr = x1 OR ... expr = xN` 的最小长度以进行优化。 ## optimize_min_inequality_conjunction_chain_length {#optimize_min_inequality_conjunction_chain_length} - - - - -用于优化的表达式 `expr <> x1 AND ... expr <> xN` 的最小长度。 +表达式 `expr <> x1 AND ... expr <> xN` 的最小长度以进行优化。 ## optimize_move_to_prewhere {#optimize_move_to_prewhere} - - -启用或禁用在 [SELECT](../../sql-reference/statements/select/index.md) 查询中自动优化 [PREWHERE](../../sql-reference/statements/select/prewhere.md)。 +启用或禁用在 [SELECT](../../sql-reference/statements/select/index.md) 查询中自动 [PREWHERE](../../sql-reference/statements/select/prewhere.md) 优化。 仅适用于 [*MergeTree](../../engines/table-engines/mergetree-family/index.md) 表。 @@ -6954,51 +7025,39 @@ SELECT * FROM test LIMIT 10 OFFSET 100; - 1 — 自动 `PREWHERE` 优化启用。 ## optimize_move_to_prewhere_if_final {#optimize_move_to_prewhere_if_final} - - -启用或禁用在带有 [FINAL](/sql-reference/statements/select/from#final-modifier) 修饰符的 [SELECT](../../sql-reference/statements/select/index.md) 查询中自动优化 [PREWHERE](../../sql-reference/statements/select/prewhere.md)。 +启用或禁用在带有 [FINAL](/sql-reference/statements/select/from#final-modifier) 修饰符的 [SELECT](../../sql-reference/statements/select/index.md) 查询中自动 [PREWHERE](../../sql-reference/statements/select/prewhere.md) 优化。 仅适用于 [*MergeTree](../../engines/table-engines/mergetree-family/index.md) 表。 可能的值: -- 0 — 在带有 `FINAL` 修饰符的 `SELECT` 查询中自动优化 `PREWHERE` 被禁用。 -- 1 — 在带有 `FINAL` 修饰符的 `SELECT` 查询中自动优化 `PREWHERE` 被启用。 +- 0 — 在带有 `FINAL` 修饰符的 `SELECT` 查询中自动 `PREWHERE` 优化禁用。 +- 1 — 在带有 `FINAL` 修饰符的 `SELECT` 查询中自动 `PREWHERE` 优化启用。 -**另请参见** +**另见** - [optimize_move_to_prewhere](#optimize_move_to_prewhere) 设置。 ## optimize_multiif_to_if {#optimize_multiif_to_if} - - -将具有唯一条件的 'multiIf' 替换为 'if'。 +将仅具有一个条件的 'multiIf' 替换为 'if'。 ## optimize_normalize_count_variants {#optimize_normalize_count_variants} - - - - -重写在语义上等同于 count() 的聚合函数为 count()。 +将语义上等同于 count() 的聚合函数重写为 count()。 ## optimize_on_insert {#optimize_on_insert} - - - - -启用或禁用在插入之前进行数据转换,就像在此块上执行了一次合并(根据表引擎)。 +启用或禁用在插入前对数据进行转换,仿佛在该块上进行了合并(根据表引擎)。 可能的值: @@ -7007,7 +7066,7 @@ SELECT * FROM test LIMIT 10 OFFSET 100; **示例** -启用和禁用之间的差异: +启用和禁用之间的区别: 查询: @@ -7046,91 +7105,79 @@ SELECT * FROM test2; └─────────────┘ ``` -注意,此设置会影响 [物化视图](/sql-reference/statements/create/view#materialized-view) 的行为。 +注意,此设置会影响 [Materialized view](/sql-reference/statements/create/view#materialized-view) 的行为。 ## optimize_or_like_chain {#optimize_or_like_chain} - - -优化多个 OR LIKE 的查询为 multiMatchAny。此优化在某些情况下不应默认启用,因为它会破坏索引分析。 -## optimize_read_in_order {#optimize_read_in_order} +将多个 OR LIKE 优化为 multiMatchAny。此优化不应默认启用,因为它在某些情况下会违反索引分析。 +## optimize_qbit_distance_function_reads {#optimize_qbit_distance_function_reads} + + + +将 `QBit` 数据类型的距离函数替换为等效函数,仅从存储中读取计算所需的列。 +## optimize_read_in_order {#optimize_read_in_order} -启用在 [SELECT](../../sql-reference/statements/select/index.md) 查询中对 [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) 表读取数据的 [ORDER BY](/sql-reference/statements/select/order-by#optimization-of-data-reading) 优化。 +在 [SELECT](../../sql-reference/statements/select/index.md) 查询中启用 [ORDER BY](/sql-reference/statements/select/order-by#optimization-of-data-reading) 优化,以从 [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) 表中读取数据。 可能的值: - 0 — `ORDER BY` 优化禁用。 - 1 — `ORDER BY` 优化启用。 -**另请参见** +**另见** -- [ORDER BY 子句](/sql-reference/statements/select/order-by#optimization-of-data-reading) +- [ORDER BY Clause](/sql-reference/statements/select/order-by#optimization-of-data-reading) ## optimize_read_in_window_order {#optimize_read_in_window_order} - - - - -在窗口子句中启用 ORDER BY 优化,以按相应顺序读取 MergeTree 表中的数据。 +启用窗口子句中的 ORDER BY 优化,以在 MergeTree 表中以相应顺序读取数据。 ## optimize_redundant_functions_in_order_by {#optimize_redundant_functions_in_order_by} - - - - -从 ORDER BY 移除函数,如果其参数也在 ORDER BY 中。 +从 ORDER BY 中移除函数,如果其参数也在 ORDER BY 中。 ## optimize_respect_aliases {#optimize_respect_aliases} - - - - -如果设置为 true,则将遵循 WHERE/GROUP BY/ORDER BY 中的别名,这将有助于分区修剪/二级索引/优化聚合顺序/优化读取顺序/优化琐碎计数。 +如果设置为 true,将尊重 WHERE/GROUP BY/ORDER BY 中的别名,以帮助进行分区修剪/二级索引/optimize_aggregation_in_order/optimize_read_in_order/optimize_trivial_count。 ## optimize_rewrite_aggregate_function_with_if {#optimize_rewrite_aggregate_function_with_if} - - -重写带有 if 表达式的聚合函数作为参数,当逻辑上等效时。例如,`avg(if(cond, col, null))` 可以重写为 `avgOrNullIf(cond, col)`。这可能会提高性能。 +当逻辑上等价时,将带有 if 表达式的聚合函数重写为参数。例如,`avg(if(cond, col, null))` 可以重写为 `avgOrNullIf(cond, col)`。这可能提高性能。 :::note -仅在分析器(`enable_analyzer = 1`)支持下。 +仅在启用分析器时支持(`enable_analyzer = 1`)。 ::: ## optimize_rewrite_array_exists_to_has {#optimize_rewrite_array_exists_to_has} - - -在逻辑上等效时将 arrayExists() 函数重写为 has()。例如,arrayExists(x -> x = 1, arr) 可以重写为 has(arr, 1)。 -## optimize_rewrite_sum_if_to_count_if {#optimize_rewrite_sum_if_to_count_if} - - +将数组存在函数重写为 has(),当逻辑上等价时。例如,arrayExists(x -> x = 1, arr) 可以重写为 has(arr, 1)。 +## optimize_rewrite_regexp_functions {#optimize_rewrite_regexp_functions} + +将正则表达式相关函数重写为更简单和更高效的形式。 +## optimize_rewrite_sum_if_to_count_if {#optimize_rewrite_sum_if_to_count_if} + + -当逻辑上等效时,将 sumIf() 和 sum(if()) 函数重写为 countIf() 函数。 +当逻辑上等价时,将 sumIf() 和 sum(if()) 函数重写为 countIf() 函数。 ## optimize_skip_merged_partitions {#optimize_skip_merged_partitions} - - -如果只有一个级别大于 0 的分区且没有过期 TTL,则启用或禁用 [OPTIMIZE TABLE ... FINAL](../../sql-reference/statements/optimize.md) 查询的优化。 +启用或禁用针对 [OPTIMIZE TABLE ... FINAL](../../sql-reference/statements/optimize.md) 查询的优化,如果只有一个级别 > 0 的部分,并且没有过期的 TTL。 - `OPTIMIZE TABLE ... FINAL SETTINGS optimize_skip_merged_partitions=1` -默认情况下,即使只有一个分区也会重写 `OPTIMIZE TABLE ... FINAL` 查询。 +默认情况下,即使只有一个部分,`OPTIMIZE TABLE ... FINAL` 查询也会重写这一部分。 可能的值: @@ -7138,11 +7185,9 @@ SELECT * FROM test2; - 0 - 禁用优化。 ## optimize_skip_unused_shards {#optimize_skip_unused_shards} - - -启用或禁用对具有 sharding key 条件的 [SELECT](../../sql-reference/statements/select/index.md) 查询跳过未使用的分片(假设数据是通过 sharding key 分布的,否则查询的结果不正确)。 +启用或禁用在 `WHERE/PREWHERE` 中具有分片键条件的 [SELECT](../../sql-reference/statements/select/index.md) 查询中跳过未使用的分片(假设数据是根据分片键分布的,否则查询将产生不正确的结果)。 可能的值: @@ -7150,33 +7195,21 @@ SELECT * FROM test2; - 1 — 启用。 ## optimize_skip_unused_shards_limit {#optimize_skip_unused_shards_limit} +达到限制时,分片键值的限制,关闭 `optimize_skip_unused_shards`。 - - - -sharding key 值的数量限制,如果达到这个限制则关闭 `optimize_skip_unused_shards`。 - -过多的值可能需要大量处理,而好处可疑,因为如果你在 `IN (...)` 中有大量值,查询基本上会被发送到所有分片。 +过多的值可能需要大量处理,而收益值得怀疑,因为如果您在 `IN (...)` 中有大量值,那么查询很可能无论如何都会发送到所有的分片。 ## optimize_skip_unused_shards_nesting {#optimize_skip_unused_shards_nesting} - - - - -控制 [`optimize_skip_unused_shards`](#optimize_skip_unused_shards)(因此仍然需要 [`optimize_skip_unused_shards`](#optimize_skip_unused_shards))依赖于分布式查询的嵌套级别(在你有 `Distributed` 表查询另一个 `Distributed` 表的情况下)。 +控制 [`optimize_skip_unused_shards`](#optimize_skip_unused_shards)(因此仍然需要 [`optimize_skip_unused_shards`](#optimize_skip_unused_shards))取决于分布式查询的嵌套级别(假设您有 `Distributed` 表查找另一个 `Distributed` 表)。 可能的值: - 0 — 禁用,`optimize_skip_unused_shards` 始终有效。 -- 1 — 仅在第一层启用 `optimize_skip_unused_shards`。 -- 2 — 启用 `optimize_skip_unused_shards` 直至第二层。 +- 1 — 仅对第一层启用 `optimize_skip_unused_shards`。 +- 2 — 允许 `optimize_skip_unused_shards` 直到第二层。 ## optimize_skip_unused_shards_rewrite_in {#optimize_skip_unused_shards_rewrite_in} - - - - -对于远程分片重写查询中的 IN,以排除不属于分片的值(需要 optimize_skip_unused_shards)。 +在查询中重写 IN 以排除不属于该分片的值(需要 optimize_skip_unused_shards)。 可能的值: @@ -7184,34 +7217,22 @@ sharding key 值的数量限制,如果达到这个限制则关闭 `optimize_sk - 1 — 启用。 ## optimize_sorting_by_input_stream_properties {#optimize_sorting_by_input_stream_properties} - - - - 根据输入流的排序属性优化排序。 ## optimize_substitute_columns {#optimize_substitute_columns} - - - - -使用 [constraints](../../sql-reference/statements/create/table.md/#constraints) 进行列替换。默认值为 `false`。 +使用 [constraints](../../sql-reference/statements/create/table.md/#constraints) 来替换列。默认值为 `false`。 可能的值: -- true,false +- true, false ## optimize_syntax_fuse_functions {#optimize_syntax_fuse_functions} - - - - -启用将具有相同参数的聚合函数融合。它重写查询,其中包含至少两个具有相同参数的 [sum](/sql-reference/aggregate-functions/reference/sum)、[count](/sql-reference/aggregate-functions/reference/count) 或 [avg](/sql-reference/aggregate-functions/reference/avg) 聚合函数为 [sumCount](/sql-reference/aggregate-functions/reference/sumcount)。 +启用通过相同参数融合聚合函数。它重写查询中至少包含两个具有相同参数的聚合函数的查询,来自 [sum](/sql-reference/aggregate-functions/reference/sum), [count](/sql-reference/aggregate-functions/reference/count) 或 [avg](/sql-reference/aggregate-functions/reference/avg) 重写为 [sumCount](/sql-reference/aggregate-functions/reference/sumcount)。 可能的值: -- 0 — 不融合相同参数的函数。 -- 1 — 融合相同参数的函数。 +- 0 — 不融合具有相同参数的函数。 +- 1 — 融合具有相同参数的函数。 **示例** @@ -7235,13 +7256,11 @@ FROM fuse_tbl ``` ## optimize_throw_if_noop {#optimize_throw_if_noop} - - -启用或禁用在 [OPTIMIZE](../../sql-reference/statements/optimize.md) 查询未执行合并时抛出异常。 +启用或禁用如果 [OPTIMIZE](../../sql-reference/statements/optimize.md) 查询没有执行合并,则抛出异常。 -默认情况下,即使没有执行任何操作,`OPTIMIZE` 也会成功返回。此设置使你可以区分这些情况并在异常消息中得到原因。 +默认情况下,`OPTIMIZE` 即使没有进行任何操作也会成功返回。此设置使您能够区分这些情况,并在异常消息中获取原因。 可能的值: @@ -7249,22 +7268,16 @@ FROM fuse_tbl - 0 — 禁用抛出异常。 ## optimize_time_filter_with_preimage {#optimize_time_filter_with_preimage} - - + col >= '2023-01-01' AND col <= '2023-12-31'`)"}]}]}/> - - col >= '2023-01-01' AND col <= '2023-12-31'`"}]}]}/> - -通过将函数转换为等效比较而优化 Date 和 DateTime 谓词,而不进行转换(例如 `toYear(col) = 2023 -> col >= '2023-01-01' AND col <= '2023-12-31'`)。 +通过将函数转换为等效比较来优化日期和日期时间谓词,而不进行转换(例如 `toYear(col) = 2023 -> col >= '2023-01-01' AND col <= '2023-12-31'`)。 ## optimize_trivial_approximate_count_query {#optimize_trivial_approximate_count_query} - - -对支持此类估计的存储的琐碎计数优化使用近似值,例如 EmbeddedRocksDB。 +对于支持这种估算的存储,使用近似值来优化简单计数,例如 EmbeddedRocksDB。 可能的值: @@ -7272,117 +7285,91 @@ FROM fuse_tbl - 1 — 优化启用。 ## optimize_trivial_count_query {#optimize_trivial_count_query} - - - - -启用或禁用对琐碎查询 `SELECT count() FROM table` 的优化,使用来自 MergeTree 的元数据。如果需要使用行级安全性,则禁用此设置。 +启用或禁用使用来自 MergeTree 的元数据优化简单查询 `SELECT count() FROM table`。如果您需要使用行级安全性,请禁用此设置。 可能的值: - 0 — 优化禁用。 - 1 — 优化启用。 -另请参见: +另见: - [optimize_functions_to_subcolumns](#optimize_functions_to_subcolumns) ## optimize_trivial_insert_select {#optimize_trivial_insert_select} - - - - -优化琐碎的 'INSERT INTO table SELECT ... FROM TABLES' 查询。 +优化简单的 'INSERT INTO table SELECT ... FROM TABLES' 查询。 ## optimize_uniq_to_count {#optimize_uniq_to_count} - - - - -在子查询具有 distinct 或 group by 子句时,将 uniq 及其变体(不包括 uniqUpTo)重写为 count。 +将 uniq 及其变体(除 uniqUpTo 外)重写为 count,如果子查询有 distinct 或 group by 子句。 ## optimize_use_implicit_projections {#optimize_use_implicit_projections} - +自动选择隐式投影来执行 SELECT 查询。 +## optimize_use_projection_filtering {#optimize_use_projection_filtering} -自动选择隐式投影以执行 SELECT 查询。 -## optimize_use_projections {#optimize_use_projections} - + +启用使用投影在执行 SELECT 查询时过滤部分范围,即使在选择查询时未选中投影。 +## optimize_use_projections {#optimize_use_projections} - - -启用或禁用在处理 `SELECT` 查询时对 [projections](../../engines/table-engines/mergetree-family/mergetree.md/#projections) 的优化。 +启用或禁用在处理 `SELECT` 查询时的 [projection](../../engines/table-engines/mergetree-family/mergetree.md/#projections) 优化。 可能的值: -- 0 — 禁用投影优化。 -- 1 — 启用投影优化。 +- 0 — 投影优化禁用。 +- 1 — 投影优化启用。 ## optimize_using_constraints {#optimize_using_constraints} - - - - 使用 [constraints](../../sql-reference/statements/create/table.md/#constraints) 进行查询优化。默认值为 `false`。 可能的值: -- true,false -## os_thread_priority {#os_thread_priority} +- true, false +## os_threads_nice_value_materialized_view {#os_threads_nice_value_materialized_view} + + - +Linux 物化视图线程的优先级值。较低的值意味着更高的 CPU 优先级。 -设置执行查询的线程的优先级([nice](https://en.wikipedia.org/wiki/Nice_(Unix)))。操作系统调度程序在选择每个可用 CPU 内核上运行的下一个线程时会考虑此优先级。 +需要 CAP_SYS_NICE 权限,否则不会生效。 -:::note -要使用此设置,您需要设置 `CAP_SYS_NICE` 权限。`clickhouse-server` 包在安装期间会设置该权限。某些虚拟环境不允许您设置 `CAP_SYS_NICE` 权限。在这种情况下,`clickhouse-server` 会在启动时显示相关信息。 -::: +可能的值: -20 到 19。 +## os_threads_nice_value_query {#os_threads_nice_value_query} -可能的值: + -- 您可以在 `[-20, 19]` 范围内设置值。 + -较低的值表示更高的优先级。优先级较低的线程执行频率高于优先级较高的线程。高值适用于长时间运行的非交互式查询,因为它允许它们在短的交互式查询到达时快速放弃资源。 -## output_format_compression_level {#output_format_compression_level} +Linux 查询处理线程的优先级值。较低的值意味着更高的 CPU 优先级。 +需要 CAP_SYS_NICE 权限,否则不会生效。 +可能的值: -20 到 19。 +## output_format_compression_level {#output_format_compression_level} - - -如果查询输出被压缩,则为默认压缩级别。当 `SELECT` 查询包含 `INTO OUTFILE` 或写入表函数 `file`、`url`、`hdfs`、`s3` 或 `azureBlobStorage` 时,该设置生效。 +如果查询输出被压缩,则默认压缩级别。当 `SELECT` 查询具有 `INTO OUTFILE` 时或写入表函数 `file`、`url`、`hdfs`、`s3` 或 `azureBlobStorage` 时应用此设置。 可能的值:从 `1` 到 `22`。 ## output_format_compression_zstd_window_log {#output_format_compression_zstd_window_log} - - +可以在输出压缩方法为 `zstd` 时使用。如果大于 `0`,此设置明确设置压缩窗口大小(2 的幂),并启用 zstd 压缩的长范围模式。这可以帮助实现更好的压缩率。 - - - -当输出压缩方法为 `zstd` 时可使用。如果大于 `0`,则此设置明确设置压缩窗口大小(2 的幂)并启用 zstd 压缩的长范围模式。这有助于实现更好的压缩比。 - -可能的值:非负数。请注意,如果值太小或太大,`zstdlib` 将抛出异常。典型值范围为 `20`(窗口大小 = `1MB`)至 `30`(窗口大小 = `1GB`)。 +可能的值:非负数。请注意,如果值过小或过大,`zstdlib` 将抛出异常。典型值为从 `20`(窗口大小 = `1MB`)到 `30`(窗口大小 = `1GB`)。 ## output_format_parallel_formatting {#output_format_parallel_formatting} - - - - 启用或禁用数据格式的并行格式化。仅支持 [TSV](../../interfaces/formats.md/#tabseparated)、[TSKV](../../interfaces/formats.md/#tskv)、[CSV](../../interfaces/formats.md/#csv) 和 [JSONEachRow](../../interfaces/formats.md/#jsoneachrow) 格式。 可能的值: @@ -7391,304 +7378,241 @@ FROM fuse_tbl - 0 — 禁用。 ## page_cache_block_size {#page_cache_block_size} - - - - -在用户空间页缓存中存储的文件块大小(以字节为单位)。所有通过缓存的读取将向上舍入为此大小的倍数。 +存储在用户空间页缓存中的文件块大小,以字节为单位。所有通过缓存的读取将被舍入为该大小的倍数。 -可以根据每个查询级别进行调整,但具有不同块大小的缓存条目无法重复使用。更改此设置实际上会使缓存中的现有条目失效。 +此设置可以在每个查询级别进行调整,但具有不同块大小的缓存条目不能重用。改变此设置实际上会使缓存中现有条目失效。 -较高的值,如 1 MiB 适用于高吞吐量的查询,而较低的值,如 64 KiB 适用于低延迟的点查询。 +较高的值,如 1 MiB 适用于高吞吐量查询,而较低的值,如 64 KiB 适用于低延迟的点查询。 ## page_cache_inject_eviction {#page_cache_inject_eviction} - - - - -用户空间页缓存有时会随机失效某些页面。用于测试目的。 +用户空间页缓存有时会随机失效某些页面。用于测试。 ## page_cache_lookahead_blocks {#page_cache_lookahead_blocks} - - +在用户空间页缓存缺失时,从底层存储一次读取最多此数量的连续块,如果它们也不在缓存中。每个块是 page_cache_block_size 字节。 - - - -在用户空间页缓存未命中时,如果相应块也不在缓存中,则从底层存储一次读取多达这一数量的连续块。每个块的大小为 page_cache_block_size 字节。 - -较高的值适合高吞吐量查询,而低延迟的点查询在无需提前读取的情况下效果更佳。 +较高的值适用于高吞吐量查询,而低延迟的点查询在没有预读取的情况下会更好。 ## parallel_distributed_insert_select {#parallel_distributed_insert_select} - - - + 启用并行分布式 `INSERT ... SELECT` 查询。 -如果我们执行 `INSERT INTO distributed_table_a SELECT ... FROM distributed_table_b` 查询,并且两个表使用相同的集群,且两个表都是 [replicated](../../engines/table-engines/mergetree-family/replication.md) 或非复制的,则该查询在每个分片上都在本地处理。 +如果我们执行 `INSERT INTO distributed_table_a SELECT ... FROM distributed_table_b` 查询并且两个表使用相同的集群,并且两个表都是 [replicated](../../engines/table-engines/mergetree-family/replication.md) 或非复制的,那么此查询将在每个分片上本地处理。 可能的值: -- 0 — 禁用。 -- 1 — `SELECT` 将在分布式引擎的底层表的每个分片上执行。 -- 2 — `SELECT` 和 `INSERT` 将在分布式引擎的每个分片上执行到/从底层表。 -## parallel_hash_join_threshold {#parallel_hash_join_threshold} - +- `0` — 禁用。 +- `1` — `SELECT` 将在分布式引擎的基础表的每个分片上执行。 +- `2` — `SELECT` 和 `INSERT` 将在分布式引擎的基础表的每个分片上执行。 +使用此设置需要将 `enable_parallel_replicas` 设置为 `1`。 +## parallel_hash_join_threshold {#parallel_hash_join_threshold} +当应用基于哈希的连接算法时,此阈值帮助决定使用 `hash` 还是 `parallel_hash`(仅在可用右表大小估计的情况下)。 - - - -当应用基于哈希的连接算法时,此阈值有助于决定使用 `hash` 还是 `parallel_hash`(仅在右表大小估计可用时)。 -当我们知道右表大小小于该阈值时使用前者。 +前者在我们知道右表大小低于阈值时使用。 ## parallel_replica_offset {#parallel_replica_offset} - - -这是内部设置,不应直接使用,表示“并行副本”模式的实现细节。此设置将由分布式查询的发起服务器自动设置,以用于参与查询处理的副本索引。 +这是一个内部设置,不应直接使用,表示“并行副本”模式的实现细节。此设置将由发起服务器自动为分布式查询设置为参与查询处理的副本索引。 ## parallel_replicas_allow_in_with_subquery {#parallel_replicas_allow_in_with_subquery} - - - - - - - - -如果为真,IN 子查询将在每个后续副本上执行。 +如果为真,IN 的子查询将在每个跟随副本上执行。 ## parallel_replicas_connect_timeout_ms {#parallel_replicas_connect_timeout_ms} - - - - - - -在使用并行副本执行查询期间,连接到远程副本的超时时间(以毫秒为单位)。如果超时时间到,则对应的副本将不用于查询执行。 +查询执行时连接到远程副本的超时时间(以毫秒为单位)。如果超时,则不使用相应副本进行查询执行。 ## parallel_replicas_count {#parallel_replicas_count} - - - - -这是内部设置,不应直接使用,表示“并行副本”模式的实现细节。此设置将由分布式查询的发起服务器自动设置,用于参与查询处理的并行副本数量。 +这是一个内部设置,不应直接使用,表示“并行副本”模式的实现细节。此设置将由发起服务器自动为分布式查询设置为参与查询处理的并行副本数量。 ## parallel_replicas_custom_key {#parallel_replicas_custom_key} -可以用于在特定表中拆分副本工作的任意整数表达式。 -该值可以是任何整数表达式。 +可以用于在特定表之间划分副本工作的任意整数表达式。 +值可以是任何整数表达式。 -简单表达式使用主键更为理想。 +简单的使用主键的表达式更受欢迎。 -如果该设置用于由单个分片和多个副本组成的集群,则这些副本将被转换为虚拟分片。 -否则,它将按 `SAMPLE` 键的行为,使用每个分片的多个副本。 +如果在由单个分片和多个副本组成的集群上使用此设置,则这些副本将转换为虚拟分片。 +否则,它将与 `SAMPLE` 键的行为相同,它将使用每个分片的多个副本。 ## parallel_replicas_custom_key_range_lower {#parallel_replicas_custom_key_range_lower} - - -允许过滤类型为 `range` 的查询在副本之间均匀地分配工作,基于自定义范围 `[parallel_replicas_custom_key_range_lower, INT_MAX]`。 +允许过滤器类型 `range` 基于自定义范围 `[parallel_replicas_custom_key_range_lower, INT_MAX]` 在副本之间均匀划分工作。 -与 [parallel_replicas_custom_key_range_upper](#parallel_replicas_custom_key_range_upper) 结合使用时,它允许过滤器在范围 `[parallel_replicas_custom_key_range_lower, parallel_replicas_custom_key_range_upper]` 上均匀地分配副本之间的工作。 - -注意:此设置不会导致在查询处理期间过滤任何额外的数据,而是更改范围过滤器在 `[0, INT_MAX]` 范围上进行并行处理时的切分点。 +与 [parallel_replicas_custom_key_range_upper](#parallel_replicas_custom_key_range_upper) 一起使用时,可以使过滤器对范围 `[parallel_replicas_custom_key_range_lower, parallel_replicas_custom_key_range_upper]` 平均分配工作。 +注意:此设置不会在查询处理期间造成额外的数据过滤,而是更改了范围过滤器在进行并行处理时将范围 `[0, INT_MAX]` 划分的点。 ## parallel_replicas_custom_key_range_upper {#parallel_replicas_custom_key_range_upper} - - -允许过滤类型为 `range` 的查询在副本之间均匀地分配工作,基于自定义范围 `[0, parallel_replicas_custom_key_range_upper]`。值为0将禁用上限,将其设置为自定义键表达式的最大值。 +允许过滤器类型 `range` 基于自定义范围 `[0, parallel_replicas_custom_key_range_upper]` 在副本之间均匀划分工作。值为 0 禁用上限,将其设置为自定义键表达式的最大值。 -与 [parallel_replicas_custom_key_range_lower](#parallel_replicas_custom_key_range_lower) 结合使用时,它允许过滤器在范围 `[parallel_replicas_custom_key_range_lower, parallel_replicas_custom_key_range_upper]` 上均匀地分配副本之间的工作。 - -注意:此设置不会导致在查询处理期间过滤任何额外的数据,而是更改范围过滤器在 `[0, INT_MAX]` 范围上进行并行处理时的切分点。 +与 [parallel_replicas_custom_key_range_lower](#parallel_replicas_custom_key_range_lower) 一起使用时,可以使过滤器对范围 `[parallel_replicas_custom_key_range_lower, parallel_replicas_custom_key_range_upper]` 平均分配工作。 +注意:此设置不会在查询处理期间造成额外的数据过滤,而是更改了范围过滤器在进行并行处理时将范围 `[0, INT_MAX]` 划分的点。 ## parallel_replicas_for_cluster_engines {#parallel_replicas_for_cluster_engines} - - -用其 -Cluster 替代表函数引擎。 - +将表函数引擎替换为其 -Cluster 替代品。 ## parallel_replicas_for_non_replicated_merge_tree {#parallel_replicas_for_non_replicated_merge_tree} - - -如果为真,ClickHouse 将对非复制的 MergeTree 表也使用并行副本算法。 - +如果为真,ClickHouse 将对非复制的 MergeTree 表使用并行副本算法。 ## parallel_replicas_index_analysis_only_on_coordinator {#parallel_replicas_index_analysis_only_on_coordinator} - - -只在副本协调者上进行索引分析,跳过其他副本。仅在启用 parallel_replicas_local_pla 时有效。 - +仅在副本协调器上执行索引分析,其他副本则省略。仅在启用 parallel_replicas_local_plan 时有效。 ## parallel_replicas_insert_select_local_pipeline {#parallel_replicas_insert_select_local_pipeline} - - -在使用并行副本的分布式 INSERT SELECT 时使用本地管道。 - +在分布式 INSERT SELECT 中的并行副本中使用本地管道。 ## parallel_replicas_local_plan {#parallel_replicas_local_plan} - - 为本地副本构建本地计划。 - ## parallel_replicas_mark_segment_size {#parallel_replicas_mark_segment_size} - - -分片在虚拟上划分为段,以便在副本之间进行并行读取。该设置控制这些段的大小。建议在充分理解的情况下再更改此设置。值应在范围 [128; 16384] 内。 - +部分虚拟地划分为要在副本之间分发的段。此设置控制这些段的大小。在完全确定您在做什么之前,不建议更改。值应在 [128; 16384] 范围内。 ## parallel_replicas_min_number_of_rows_per_replica {#parallel_replicas_min_number_of_rows_per_replica} - - -限制查询中使用的副本数量为(预估读取行数 / min_number_of_rows_per_replica)。最大值仍然受 'max_parallel_replicas' 的限制。 - +限制查询中使用的副本数量为(估计读取行数 / min_number_of_rows_per_replica)。最大值仍然受 'max_parallel_replicas' 的限制。 ## parallel_replicas_mode {#parallel_replicas_mode} - - -用于指定自定义键的并行副本的过滤器类型。默认值 - 对自定义键使用模运算,范围 - 使用自定义键的范围过滤器,使用自定义键的所有可能值类型。 - +用于具有自定义键的并行副本的过滤器类型。默认值 - 使用自定义键的模运算,范围 - 对自定义键使用范围过滤器,使用自定义键值类型的所有可能值。 ## parallel_replicas_only_with_analyzer {#parallel_replicas_only_with_analyzer} - - -启用分析器才能使用并行副本。如果禁用分析器,查询执行将回退到本地执行,即使启用了从副本的并行读取。不支持在未启用分析器的情况下使用并行副本。 - +必须启用分析器才能使用并行副本。在禁用分析器时,查询执行回落到本地执行,即使启用了从副本并行读取。禁用分析器不支持使用并行副本。 ## parallel_replicas_prefer_local_join {#parallel_replicas_prefer_local_join} - +如果为真,并且 JOIN 可以使用并行副本算法执行,并且右 JOIN 部分的所有存储都是 *MergeTree,则将使用本地 JOIN,而不是 GLOBAL JOIN。 +## parallel_replicas_support_projection {#parallel_replicas_support_projection} -如果为真,当JOIN可以使用并行副本算法执行,并且右侧JOIN部分的所有存储都是 *MergeTree,将使用本地JOIN而不是全局JOIN。 + +可以在并行副本中应用投影的优化。仅在启用 parallel_replicas_local_plan 且 aggregation_in_order 不激活时有效。 ## parallel_view_processing {#parallel_view_processing} -启用同时推送到附加视图,而不是顺序推送。 - +启用同步推送到附加视图,而不是顺序推送。 ## parallelize_output_from_storages {#parallelize_output_from_storages} -并行化从存储的读取步骤的输出。如果可能,在从存储读取之后允许查询处理的并行化。 - +并行化从存储的读取步骤的输出。如果可能,它允许在从存储读取后立即并行化查询处理。 ## parsedatetime_e_requires_space_padding {#parsedatetime_e_requires_space_padding} - - -函数 'parseDateTime' 中的格式符 '%e' 期望单个数字的日期有空格填充,例如 ' 2' 被接受,但 '2' 会引发错误。 - +格式化器 `%e` 在函数 'parseDateTime' 中期望单数字的日期为填充空格,例如,接受 ' 2',但 '2' 会引发错误。 ## parsedatetime_parse_without_leading_zeros {#parsedatetime_parse_without_leading_zeros} - - -函数 'parseDateTime' 中的格式符 '%c'、'%l' 和 '%k' 对月份和小时进行解析时不带前导零。 - +格式化器 `%c`、`%l` 和 `%k` 在函数 'parseDateTime' 中解析月份和小时时不使用前导零。 ## partial_merge_join_left_table_buffer_bytes {#partial_merge_join_left_table_buffer_bytes} -如果不为0,则在部分合并连接中将左表块组合为更大的块。每个连接线程使用最多2倍指定内存。 - +如果不为 0,在部分合并连接中将左表块组合为较大的块。它每个连接线程最多使用指定内存的 2 倍。 ## partial_merge_join_rows_in_right_blocks {#partial_merge_join_rows_in_right_blocks} -限制在部分合并连接算法中右侧连接数据块的大小,以进行 [JOIN](../../sql-reference/statements/select/join.md) 查询。 +限制在部分合并连接算法中用于 [JOIN](../../sql-reference/statements/select/join.md) 查询的右侧连接数据块的大小。 -ClickHouse 服务器: +ClickHouse 服务器: -1. 将右侧连接数据拆分为最大指定行数的块。 -2. 以其最小值和最大值为每个块创建索引。 +1. 将右侧连接数据分成最多指定行数的块。 +2. 用每个块的最小和最大值为其建立索引。 3. 如果可能,将准备好的块卸载到磁盘。 -可能值: +可能的值: -- 任何正整数。建议值范围:[1000, 100000]。 +- 任何正整数。推荐的值范围: \[1000, 100000\]。 ## partial_result_on_first_cancel {#partial_result_on_first_cancel} -允许查询在取消后返回部分结果。 +允许在取消后返回部分结果。 ## parts_to_delay_insert {#parts_to_delay_insert} -如果目标表在单个分区中包含至少这么多的活动分片,则人工减慢对表的插入速度。 + + +如果目标表在单个分区中至少包含如此多的活动部分,则人为地减慢插入到表的速度。 ## parts_to_throw_insert {#parts_to_throw_insert} -如果目标表的单个分区中活动分片超过该数字,则抛出'碎片太多...'异常。 + + +如果目标表的单个分区中活动部分超过此数量,则抛出 'Too many parts ...' 异常。 + +## per_part_index_stats {#per_part_index_stats} + + + + + + 记录每部分的索引统计信息 ## periodic_live_view_refresh {#periodic_live_view_refresh} -强制在指定间隔后定期刷新实时视图。 + + +在该间隔后强制刷新定期更新的物化视图。 ## poll_interval {#poll_interval} -在服务器的查询等待循环中阻塞指定的秒数。 + + +在服务器上阻塞查询等待循环,持续指定的秒数。 ## postgresql_connection_attempt_timeout {#postgresql_connection_attempt_timeout} @@ -7696,11 +7620,14 @@ ClickHouse 服务器: -连接到 PostgreSQL 端点的单次尝试的连接超时(以秒为单位)。该值作为连接 URL 的 `connect_timeout` 参数传递。 +单次尝试连接 PostgreSQL 端点的超时时间(秒)。 +该值作为连接 URL 的 `connect_timeout` 参数传递。 ## postgresql_connection_pool_auto_close_connection {#postgresql_connection_pool_auto_close_connection} -在将连接返回到池之前关闭连接。 + + +在将连接返回到连接池之前关闭连接。 ## postgresql_connection_pool_retries {#postgresql_connection_pool_retries} @@ -7708,15 +7635,19 @@ ClickHouse 服务器: -PostgreSQL 表引擎和数据库引擎的连接池推送/弹出重试次数。 +PostgreSQL 表引擎和数据库引擎的连接池推送/获取重试次数。 ## postgresql_connection_pool_size {#postgresql_connection_pool_size} + + PostgreSQL 表引擎和数据库引擎的连接池大小。 ## postgresql_connection_pool_wait_timeout {#postgresql_connection_pool_wait_timeout} -在 PostgreSQL 表引擎和数据库引擎的空池中推送/弹出连接超时。默认情况下在空池内将被阻塞。 + + +PostgreSQL 表引擎和数据库引擎的空连接池推送/获取超时。默认情况下,在空池上将阻塞。 ## postgresql_fault_injection_probability {#postgresql_fault_injection_probability} @@ -7724,22 +7655,22 @@ PostgreSQL 表引擎和数据库引擎的连接池大小。 -内部(用于复制)的 PostgreSQL 查询失败的概率。有效值在区间 [0.0f, 1.0f] 内。 +内部(用于复制)PostgreSQL 查询失败的近似概率。有效值在区间 [0.0f, 1.0f] 之间。 ## prefer_column_name_to_alias {#prefer_column_name_to_alias} -启用或禁用在查询表达式和子句中使用原始列名而不是别名。当别名与列名相同时,这一点尤其重要,见 [表达式别名](/sql-reference/syntax#notes-on-usage)。启用此设置可以使 ClickHouse 的别名语法规则与大多数其他数据库引擎更兼容。 +启用或禁用在查询表达式和子句中使用原始列名而不是别名。尤其是在别名与列名相同的情况下,这一设置尤其重要,见 [表达式别名](/sql-reference/syntax#notes-on-usage)。启用该设置可使 ClickHouse 中的别名语法规则与大多数其他数据库引擎更加兼容。 -可能值: +可能的值: -- 0 — 用别名替换列名。 -- 1 — 列名不被替换为别名。 +- 0 — 列名将被别名替换。 +- 1 — 列名不被别名替换。 **示例** -启用和禁用之间的差异: +已启用和已禁用之间的差异: 查询: @@ -7776,7 +7707,7 @@ SELECT avg(number) AS number, max(number) FROM numbers(10); -偏好外部排序的最大块字节,减少合并过程中的内存使用。 +偏好用于外部排序的最大块字节,减少合并过程中的内存使用。 ## prefer_global_in_and_join {#prefer_global_in_and_join} @@ -7784,38 +7715,38 @@ SELECT avg(number) AS number, max(number) FROM numbers(10); 启用将 `IN`/`JOIN` 操作符替换为 `GLOBAL IN`/`GLOBAL JOIN`。 -可能值: +可能的值: -- 0 — 禁用。`IN`/`JOIN` 操作符不会被替换为 `GLOBAL IN`/`GLOBAL JOIN`。 +- 0 — 禁用。`IN`/`JOIN` 操作符不被替换为 `GLOBAL IN`/`GLOBAL JOIN`。 - 1 — 启用。`IN`/`JOIN` 操作符被替换为 `GLOBAL IN`/`GLOBAL JOIN`。 -**使用** +**用法** -虽然 `SET distributed_product_mode=global` 可以改变分布式表的查询行为,但不适合本地表或来自外部资源的表。这时 `prefer_global_in_and_join` 设置就发挥作用了。 +尽管 `SET distributed_product_mode=global` 可以改变分布式表的查询行为,但它不适用于本地表或外部资源中的表。这就是 `prefer_global_in_and_join` 设置发挥作用的地方。 -例如,我们有服务节点的查询,这些节点包含不适合分发的本地表。在分布式处理过程中,我们需要通过 `GLOBAL` 关键字动态地分散它们的数据 — `GLOBAL IN`/`GLOBAL JOIN`。 +例如,我们有服务节点查询本地表,这些表并不适合分发。在分布式处理时,我们需要动态分散这些数据,使用 `GLOBAL` 关键词 — `GLOBAL IN`/`GLOBAL JOIN`。 -`prefer_global_in_and_join` 的另一个用例是访问由外部引擎创建的表。该设置可以帮助减少在连接这些表时对外部源的调用次数:每次查询只需一次调用。 +`prefer_global_in_and_join` 的另一个用例是访问由外部引擎创建的表。该设置有助于在连接此类表时减少对外部资源的调用次数:每个查询仅进行一次调用。 -**另请参见:** +**另外请参见:** -- 关于如何使用 `GLOBAL IN`/`GLOBAL JOIN` 的更多信息,请参见 [分布式子查询](/sql-reference/operators/in#distributed-subqueries)。 +- [分布式子查询](/sql-reference/operators/in#distributed-subqueries),了解如何使用 `GLOBAL IN`/`GLOBAL JOIN` ## prefer_localhost_replica {#prefer_localhost_replica} -启用/禁用在处理分布式查询时优先使用本地主机副本。 +启用/禁用在处理分布式查询时优先使用本地地址副本。 -可能值: +可能的值: -- 1 — 如果存在,ClickHouse 总是将查询发送到本地主机副本。 -- 0 — ClickHouse 使用 [load_balancing](#load_balancing) 设置指定的负载均衡策略。 +- 1 — 如果存在,ClickHouse 将始终将查询发送到本地地址副本。 +- 0 — ClickHouse 使用 [load_balancing](#load_balancing) 设置指定的负载平衡策略。 :::note -如果您在没有 [parallel_replicas_custom_key](#parallel_replicas_custom_key) 的情况下使用 [max_parallel_replicas](#max_parallel_replicas),请禁用此设置。 -如果设置了 [parallel_replicas_custom_key](#parallel_replicas_custom_key),只有在它用于包含多个副本的多个分片的集群时,才能禁用此设置。 -如果用于单个分片和多个副本的集群,禁用此设置将产生负面影响。 +如果您使用 [max_parallel_replicas](#max_parallel_replicas) 而不使用 [parallel_replicas_custom_key](#parallel_replicas_custom_key),则禁用此设置。 +如果设置了 [parallel_replicas_custom_key](#parallel_replicas_custom_key),仅在多个副本的多个分片包含的集群上禁用此设置。 +在包含单个分片和多个副本的集群上使用此设置将产生负面影响。 ::: ## prefer_warmed_unmerged_parts_seconds {#prefer_warmed_unmerged_parts_seconds} @@ -7824,27 +7755,33 @@ SELECT avg(number) AS number, max(number) FROM numbers(10); -仅在 ClickHouse Cloud 中生效。如果合并的部分距离现在不超过这个秒数,并且尚未预热(参见 [cache_populated_by_fetch](merge-tree-settings.md/#cache_populated_by_fetch)),但它的所有源部分都可用且预热,则 SELECT 查询将从这些部分中读取。仅适用于 Replicated-/SharedMergeTree。注意,这仅检查缓存预热器是否处理了该部分;如果该部分是由其他东西提取到缓存的,它仍会被视为冷缓存,直到缓存预热器处理它;如果它已被预热,随后从缓存中驱逐,则仍会被视为温缓存。 +仅对 ClickHouse Cloud 有效。 如果合并的部分小于这一秒数且未预热(参见 [cache_populated_by_fetch](merge-tree-settings.md/#cache_populated_by_fetch)),但其所有源部分可用且已预热,则 SELECT 查询将从这些部分读取。 仅适用于 Replicated-/SharedMergeTree。 请注意,这仅检查 CacheWarmer 是否处理了该部分;如果该部分已由其他内容加载到缓存中,则在 CacheWarmer 处理之前,它仍将被视为冷部分;如果它已被预热,然后从缓存中驱逐,将仍被视为热部分。 ## preferred_block_size_bytes {#preferred_block_size_bytes} -此设置调整查询处理的数据块大小,并表示对更粗略的 'max_block_size' 设置的额外微调。如果列较大且具有 'max_block_size' 行,则块大小可能会大于指定字节数,其大小将被降低以实现更好的 CPU 缓存局部性。 + + +该设置调整查询处理的数据块大小,并对粗略的 `max_block_size` 设置进行额外微调。如果列很大且具有 `max_block_size` 行,则块大小可能大于指定的字节数,其大小将被降低以提高 CPU 缓存局部性。 ## preferred_max_column_in_block_size_bytes {#preferred_max_column_in_block_size_bytes} -限制在读取时块中列的最大大小。帮助减少缓存未命中计数。应该接近 L2 缓存大小。 + + +读取时块内最大列大小的限制。 有助于减少缓存未命中的次数。 应该接近 L2 缓存大小。 ## preferred_optimize_projection_name {#preferred_optimize_projection_name} 如果设置为非空字符串,ClickHouse 将尝试在查询中应用指定的投影。 -可能值: +可能的值: -- 字符串:首选投影的名称。 +- 字符串:首选投影的名称 ## prefetch_buffer_size {#prefetch_buffer_size} -预取缓冲区从文件系统读取的最大大小。 + + +从文件系统读取的预取缓冲区的最大大小。 ## print_pretty_type_names {#print_pretty_type_names} @@ -7852,7 +7789,7 @@ SELECT avg(number) AS number, max(number) FROM numbers(10); -允许在 `DESCRIBE` 查询和 `toTypeName()` 函数中以美观的方式打印深度嵌套的类型名称并带有缩进。 +允许在 `DESCRIBE` 查询和 `toTypeName()` 函数中以漂亮的方式打印深层嵌套的类型名称并进行缩进。 示例: @@ -7885,7 +7822,35 @@ a Tuple( ## priority {#priority} -查询的优先级。1 - 最高,较高值 - 较低优先级;0 - 不使用优先级。 + + +查询的优先级。1 - 最高,较高的数值 - 较低的优先级;0 - 不使用优先级。 + +## promql_database {#promql_database} + + + + + +指定 'promql' 方言使用的数据库名称。空字符串表示当前数据库。 + +## promql_evaluation_time {#promql_evaluation_time} + + + + + + + +设置将与 promql 方言一起使用的评估时间。 'auto' 表示当前时间。 + +## promql_table {#promql_table} + + + + + +指定 'promql' 方言使用的时间序列表的名称。 ## push_external_roles_in_interserver_queries {#push_external_roles_in_interserver_queries} @@ -7893,108 +7858,139 @@ a Tuple( -启用在执行查询时将用户角色从发起者推送到其他节点。 +在执行查询时启用将用户角色从发起方推送到其他节点。 ## query_cache_compress_entries {#query_cache_compress_entries} -压缩 [查询缓存](../query-cache.md) 中的条目。以牺牲插入到缓存中的速度来减少查询缓存的内存消耗。 + -可能值: +压缩 [查询缓存](../query-cache.md) 中的条目。 以减小查询缓存的内存消耗,但代价是插入/读取速度变慢。 + +可能的值: - 0 - 禁用 - 1 - 启用 ## query_cache_max_entries {#query_cache_max_entries} -当前用户可以存储在 [查询缓存](../query-cache.md) 中的查询结果的最大数量。0 表示无限制。 + -可能值: +当前用户可以在 [查询缓存](../query-cache.md) 中存储的查询结果的最大数量。0 表示无限制。 + +可能的值: - 正整数 >= 0。 ## query_cache_max_size_in_bytes {#query_cache_max_size_in_bytes} -当前用户在 [查询缓存](../query-cache.md) 中可以分配的最大内存量(以字节为单位)。0 表示无限制。 + -可能值: +当前用户可以在 [查询缓存](../query-cache.md) 中分配的最大内存(以字节为单位)。0 表示无限制。 + +可能的值: - 正整数 >= 0。 ## query_cache_min_query_duration {#query_cache_min_query_duration} -存储查询结果在 [查询缓存](../query-cache.md) 中所需的最小持续时间(以毫秒为单位)。 + -可能值: +查询需要运行的最小持续时间(毫秒),才能将其结果存储在 [查询缓存](../query-cache.md) 中。 + +可能的值: - 正整数 >= 0。 ## query_cache_min_query_runs {#query_cache_min_query_runs} -`SELECT` 查询必须运行的最小次数,才能将其结果存储在 [查询缓存](../query-cache.md) 中。 + -可能值: +必须运行的 `SELECT` 查询的最小次数,才能将其结果存储在 [查询缓存](../query-cache.md) 中。 + +可能的值: - 正整数 >= 0。 ## query_cache_nondeterministic_function_handling {#query_cache_nondeterministic_function_handling} -控制 [查询缓存](../query-cache.md) 如何处理包含非确定性函数(如 `rand()` 或 `now()`)的 `SELECT` 查询。 + -可能值: +控制 [查询缓存](../query-cache.md) 如何处理带有非确定性函数的 `SELECT` 查询,如 `rand()` 或 `now()`。 + +可能的值: - `'throw'` - 抛出异常并不缓存查询结果。 - `'save'` - 缓存查询结果。 -- `'ignore'` - 不缓存查询结果并且不抛出异常。 +- `'ignore'` - 不缓存查询结果也不抛出异常。 ## query_cache_share_between_users {#query_cache_share_between_users} -如果启用,缓存的 `SELECT` 查询结果可以被其他用户读取。由于安全原因,不建议启用此设置。 + + +如果启用,缓存的 `SELECT` 查询结果可以被其他用户读取。 +出于安全原因,不建议启用此设置。 -可能值: +可能的值: - 0 - 禁用 - 1 - 启用 ## query_cache_squash_partial_results {#query_cache_squash_partial_results} -将部分结果块压缩为大小为 [max_block_size](#max_block_size) 的块。降低插入到 [查询缓存](../query-cache.md) 的性能,但提高缓存条目的压缩能力(参见 [query_cache_compress-entries](#query_cache_compress_entries))。 + + +将部分结果块压缩为 [max_block_size](#max_block_size) 的大小。 减少插入到 [查询缓存](../query-cache.md) 的性能,但提高了缓存条目的可压缩性(见 [query_cache_compress-entries](#query_cache_compress_entries))。 -可能值: +可能的值: - 0 - 禁用 - 1 - 启用 ## query_cache_system_table_handling {#query_cache_system_table_handling} -控制 [查询缓存](../query-cache.md) 如何处理针对系统表的 `SELECT` 查询,即数据库 `system.*` 和 `information_schema.*` 中的表。 + -可能值: + + +控制 [查询缓存](../query-cache.md)如何处理针对系统表的 `SELECT` 查询,即数据库 `system.*` 和 `information_schema.*` 中的表。 + +可能的值: - `'throw'` - 抛出异常并不缓存查询结果。 - `'save'` - 缓存查询结果。 -- `'ignore'` - 不缓存查询结果并且不抛出异常。 +- `'ignore'` - 不缓存查询结果也不抛出异常。 ## query_cache_tag {#query_cache_tag} -充当 [查询缓存](../query-cache.md) 条目的标签的字符串。相同的查询具有不同的标签时,查询缓存会将其视为不同的查询。 + -可能值: +作为 [查询缓存](../query-cache.md) 条目的标签的字符串。 具有不同标签的相同查询被查询缓存视为不同查询。 + +可能的值: -- 任何字符串。 +- 任何字符串 ## query_cache_ttl {#query_cache_ttl} -在此时间(以秒为单位)之后,[查询缓存](../query-cache.md) 中的条目变为过期。 + + +在此时间(秒)后,[查询缓存](../query-cache.md) 中的条目变为过时。 -可能值: +可能的值: - 正整数 >= 0。 ## query_condition_cache_store_conditions_as_plaintext {#query_condition_cache_store_conditions_as_plaintext} -存储 [查询条件缓存](/operations/query-condition-cache) 过滤条件为明文。如果启用,system.query_condition_cache 显示逐字的过滤条件,这使得调试缓存问题更容易。默认禁用,因为明文过滤条件可能会暴露敏感信息。 + -可能值: + + +以纯文本格式存储 [查询条件缓存](/operations/query-condition-cache) 的过滤条件。 +如果启用,system.query_condition_cache 显示逐字过滤条件,这使得调试缓存问题更加容易。 +默认情况下禁用,因为纯文本过滤条件可能会暴露敏感信息。 + +可能的值: - 0 - 禁用 - 1 - 启用 @@ -8005,13 +8001,13 @@ a Tuple( -收集单个查询的 [query_metric_log](../../operations/system-tables/query_metric_log.md) 的间隔(以毫秒为单位)。 +收集每个查询的 [query_metric_log](../../operations/system-tables/query_metric_log.md) 的间隔(毫秒)。 -如果设置为负值,将采用 [query_metric_log setting](/operations/server-configuration-parameters/settings#query_metric_log) 中的 `collect_interval_milliseconds` 值,或如果不存在则默认值为1000。 +如果设置为任何负值,将使用 [query_metric_log 设置](/operations/server-configuration-parameters/settings#query_metric_log) 中的 `collect_interval_milliseconds` 取值,如果没有,则默认为1000。 要禁用单个查询的收集,将 `query_metric_log_interval` 设置为 0。 -默认值:-1。 +默认值: -1 ## query_plan_aggregation_in_order {#query_plan_aggregation_in_order} @@ -8019,24 +8015,33 @@ a Tuple( -切换查询计划级别的按顺序聚合优化。仅在设置 [query_plan_enable_optimizations](#query_plan_enable_optimizations) 为1时生效。 +切换按顺序聚合的查询计划级优化。 +仅在设置 [`query_plan_enable_optimizations`](#query_plan_enable_optimizations) 为 1 时生效。 :::note -这是一个专家级设置,仅供开发人员调试使用。该设置可能会在未来以不向后兼容的方式更改或被移除。 +这是一个专家级设置,仅供开发人员调试使用。该设置在未来可能会以不向后兼容的方式发生更改或被移除。 ::: -可能值: +可能的值: - 0 - 禁用 - 1 - 启用 +## query_plan_convert_any_join_to_semi_or_anti_join {#query_plan_convert_any_join_to_semi_or_anti_join} + + + + + +允许将 ANY JOIN 转换为 SEMI 或 ANTI JOIN,如果 JOIN 后的过滤器始终对未匹配或匹配的行评估为 false。 + ## query_plan_convert_join_to_in {#query_plan_convert_join_to_in} -允许将 JOIN 转换为只有左表绑定的 IN 子查询。如果与非-ANY JOIN(例如默认的 ALL JOIN)一起使用,可能会导致结果错误。 +允许将 `JOIN` 转换为带 `IN` 的子查询,如果输出列仅与左表相关。 可能导致非 ANY JOIN 的错误结果(例如,ALL JOIN,后者是默认情况)。 ## query_plan_convert_outer_join_to_inner_join {#query_plan_convert_outer_join_to_inner_join} @@ -8044,47 +8049,73 @@ a Tuple( -允许将 OUTER JOIN 转换为 INNER JOIN 如果 JOIN 后的过滤器总是过滤默认值。 +如果 JOIN 后的过滤器始终过滤默认值,则允许将 `OUTER JOIN` 转换为 `INNER JOIN`。 + +## query_plan_direct_read_from_text_index {#query_plan_direct_read_from_text_index} + + + + + +允许在查询计划中仅使用倒排索引执行全文搜索过滤。 + +## query_plan_display_internal_aliases {#query_plan_display_internal_aliases} + + + + + +在 EXPLAIN PLAN 中显示内部别名(如 __table1),而不是原始查询中指定的那些。 ## query_plan_enable_multithreading_after_window_functions {#query_plan_enable_multithreading_after_window_functions} -启用在评估窗口函数后进行多线程处理,以允许并行流处理。 + + +启用在评估窗口函数后进行多线程处理以允许并行流处理。 ## query_plan_enable_optimizations {#query_plan_enable_optimizations} + + 切换查询计划级别的查询优化。 :::note -这是一个专家级设置,仅供开发人员调试使用。该设置可能会在未来以不向后兼容的方式更改或被移除。 +这是一个专家级设置,仅供开发人员调试使用。该设置在未来可能会以不向后兼容的方式发生更改或被移除。 ::: -可能值: +可能的值: -- 0 - 禁用查询计划级别的所有优化。 -- 1 - 启用查询计划级别的优化(但单个优化仍可以通过其各自的设置禁用)。 +- 0 - 禁用查询计划级别的所有优化 +- 1 - 启用查询计划级别的优化(但个别优化仍可以通过其个别设置禁用)。 ## query_plan_execute_functions_after_sorting {#query_plan_execute_functions_after_sorting} -切换查询计划级别的优化,将表达式移动到排序步骤之后。仅在设置 [query_plan_enable_optimizations](#query_plan_enable_optimizations) 为1时生效。 + + +切换查询计划级别的优化,将表达式移动到排序步骤后面。 +仅在设置 [`query_plan_enable_optimizations`](#query_plan_enable_optimizations) 为 1 时生效。 :::note -这是一个专家级设置,仅供开发人员调试使用。该设置可能会在未来以不向后兼容的方式更改或被移除。 +这是一个专家级设置,仅供开发人员调试使用。该设置在未来可能会以不向后兼容的方式发生更改或被移除。 ::: -可能值: +可能的值: - 0 - 禁用 - 1 - 启用 ## query_plan_filter_push_down {#query_plan_filter_push_down} -切换查询计划级别的优化,将过滤器向下移动至执行计划中。仅在设置 [query_plan_enable_optimizations](#query_plan_enable_optimizations) 为1时生效。 + + +切换查询计划级别的优化,该优化将过滤器向下移动到执行计划中。 +仅在设置 [query_plan_enable_optimizations](#query_plan_enable_optimizations) 为 1 时生效。 :::note -这是一个专家级设置,仅供开发人员调试使用。该设置可能会在未来以不向后兼容的方式更改或被移除。 +这是一个专家级设置,仅供开发人员调试使用。该设置在未来可能会以不向后兼容的方式发生更改或被移除。 ::: -可能值: +可能的值: - 0 - 禁用 - 1 - 启用 @@ -8095,28 +8126,32 @@ a Tuple( -如果连接键包含两个表的主键前缀,则对 JOIN 应用分片。支持哈希、并行哈希和全排序合并算法。通常不会加速查询,但可能降低内存消耗。 +如果连接键包含两个表的主键前缀,则在连接时应用分片。 支持散列、平行散列和全排序合并算法。 通常不会加速查询,但可能会降低内存消耗。 ## query_plan_join_swap_table {#query_plan_join_swap_table} -确定JOIN中应该哪一侧是构建表(也称为内表,插入到哈希表中的表)在查询计划中。该设置仅支持具有 `JOIN ON` 子句的 "ALL" 连接严格性。可能的值是: -- 'auto': 让计划器决定使用哪个表作为构建表。 -- 'false': 永远不交换表(右表为构建表)。 -- 'true': 始终交换表(左表为构建表)。 + + +确定连接的一侧应成为构建表(也称为内侧,在哈希连接中将其插入哈希表中的表)在查询计划中。 此设置仅支持使用 `JOIN ON` 子句的 `ALL` 连接严格性。可能的值: + +- 'auto': 让规划器决定使用哪个表作为构建表。 +- 'false': 绝不交换表(右表是构建表)。 +- 'true': 始终交换表(左表是构建表)。 ## query_plan_lift_up_array_join {#query_plan_lift_up_array_join} -切换查询计划级别的优化,提升 ARRAY JOIN 在执行计划中的位置。仅在设置 [query_plan_enable_optimizations](#query_plan_enable_optimizations) 为1时生效。 +切换查询计划级别的优化,将 ARRAY JOIN 提升到执行计划中。 +仅在设置 [query_plan_enable_optimizations](#query_plan_enable_optimizations) 为 1 时生效。 :::note -这是一个专家级设置,仅供开发人员调试使用。该设置可能会在未来以不向后兼容的方式更改或被移除。 +这是一个专家级设置,仅供开发人员调试使用。该设置在未来可能会以不向后兼容的方式发生更改或被移除。 ::: -可能值: +可能的值: - 0 - 禁用 - 1 - 启用 @@ -8125,13 +8160,14 @@ a Tuple( -切换查询计划级别的优化,将查询计划中较大的子树提升到联合中,以启用进一步优化。仅在设置 [query_plan_enable_optimizations](#query_plan_enable_optimizations) 为1时生效。 +切换查询计划级别的优化,将更大的子树移动到联合中,以启用进一步的优化。 +仅在设置 [`query_plan_enable_optimizations`](#query_plan_enable_optimizations) 为 1 时生效。 :::note -这是一个专家级设置,仅供开发人员调试使用。该设置可能会在未来以不向后兼容的方式更改或被移除。 +这是一个专家级设置,仅供开发人员调试使用。该设置在未来可能会以不向后兼容的方式发生更改或被移除。 ::: -可能值: +可能的值: - 0 - 禁用 - 1 - 启用 @@ -8142,151 +8178,226 @@ a Tuple( -控制查询计划允许使用懒惰物化优化的最大限制值。如果为零,则没有限制。 +控制允许使用查询计划进行懒惰物化优化的最大限制值。如果为零,则没有限制。 ## query_plan_max_optimizations_to_apply {#query_plan_max_optimizations_to_apply} -限制应用于查询计划的优化总数,请参阅设置 [query_plan_enable_optimizations](#query_plan_enable_optimizations)。用于避免复杂查询的长时间优化时间。在 EXPLAIN PLAN 查询中,在达到此限制后停止应用优化并返回原始计划。对于常规查询执行,如果实际应用的优化数量超过此设置,将抛出异常。 + + +限制应用于查询计划的优化总数,详细信息见设置 [query_plan_enable_optimizations](#query_plan_enable_optimizations)。 +有助于避免复杂查询的长期优化时间。 +在 EXPLAIN PLAN 查询中,达到此限制后停止应用优化,并按原样返回计划。 +对于常规查询执行,如果实际应用的优化数量超过此设置,将抛出异常。 :::note -这是一个专家级设置,仅供开发人员调试使用。该设置可能会在未来以不向后兼容的方式更改或被移除。 +这是一个专家级设置,仅供开发人员调试使用。该设置在未来可能会以不向后兼容的方式发生更改或被移除。 ::: +## query_plan_max_step_description_length {#query_plan_max_step_description_length} + + + + + +EXPLAIN PLAN 中步骤描述的最大长度。 + ## query_plan_merge_expressions {#query_plan_merge_expressions} -切换查询计划级别的优化,合并连续的过滤器。仅在设置 [query_plan_enable_optimizations](#query_plan_enable_optimizations) 为1时生效。 + + +切换查询计划级别的优化,合并连续的过滤器。 +仅在设置 [query_plan_enable_optimizations](#query_plan_enable_optimizations) 为 1 时生效。 :::note -这是一个专家级设置,仅供开发人员调试使用。该设置可能会在未来以不向后兼容的方式更改或被移除。 +这是一个专家级设置,仅供开发人员调试使用。该设置在未来可能会以不向后兼容的方式发生更改或被移除。 ::: -可能值: +可能的值: - 0 - 禁用 - 1 - 启用 ## query_plan_merge_filter_into_join_condition {#query_plan_merge_filter_into_join_condition} -允许将过滤器合并到JOIN条件中,并将 CROSS JOIN 转换为 INNER JOIN。 + + + + +允许将过滤器合并到 `JOIN` 条件中,并将 `CROSS JOIN` 转换为 `INNER`。 ## query_plan_merge_filters {#query_plan_merge_filters} -允许合并查询计划中的过滤器。 + + + + +允许在查询计划中合并过滤器。 + +## query_plan_optimize_join_order_limit {#query_plan_optimize_join_order_limit} + + + + + +在相同子查询内优化连接顺序。 当前仅支持非常有限的情况。 +值是要优化的最大表数。 ## query_plan_optimize_lazy_materialization {#query_plan_optimize_lazy_materialization} -使用查询计划实现懒惰物化优化。 + + + + +使用查询计划进行懒惰物化优化。 ## query_plan_optimize_prewhere {#query_plan_optimize_prewhere} -允许将过滤器下推到支持存储的 PREWHERE 表达式。 + + + + +允许将过滤器向下推送到支持的存储的 PREWHERE 表达式。 ## query_plan_push_down_limit {#query_plan_push_down_limit} -切换查询计划级别的优化,将 LIMIT 下推到执行计划中。仅在设置 [query_plan_enable_optimizations](#query_plan_enable_optimizations) 为1时生效。 + + +切换查询计划级别的优化,将 LIMIT 向下移动到执行计划中。 +仅在设置 [query_plan_enable_optimizations](#query_plan_enable_optimizations) 为 1 时生效。 :::note -这是一个专家级设置,仅供开发人员调试使用。该设置可能会在未来以不向后兼容的方式更改或被移除。 +这是一个专家级设置,仅供开发人员调试使用。该设置在未来可能会以不向后兼容的方式发生更改或被移除。 ::: -可能值: +可能的值: - 0 - 禁用 - 1 - 启用 ## query_plan_read_in_order {#query_plan_read_in_order} -切换查询计划级别的按顺序读取优化。仅在设置 [query_plan_enable_optimizations](#query_plan_enable_optimizations) 为1时生效。 + + +切换按顺序读取优化的查询计划级别的优化。 +仅在设置 [`query_plan_enable_optimizations`](#query_plan_enable_optimizations) 为 1 时生效。 :::note -这是一个专家级设置,仅供开发人员调试使用。该设置可能会在未来以不向后兼容的方式更改或被移除。 +这是一个专家级设置,仅供开发人员调试使用。该设置在未来可能会以不向后兼容的方式发生更改或被移除。 ::: -可能值: +可能的值: - 0 - 禁用 - 1 - 启用 ## query_plan_remove_redundant_distinct {#query_plan_remove_redundant_distinct} -切换查询计划级别的优化,移除冗余的 DISTINCT 步骤。仅在设置 [query_plan_enable_optimizations](#query_plan_enable_optimizations) 为1时生效。 + + + + +切换查询计划级别的优化,删除冗余的 DISTINCT 步骤。 +仅在设置 [`query_plan_enable_optimizations`](#query_plan_enable_optimizations) 为 1 时生效。 :::note -这是一个专家级设置,仅供开发人员调试使用。该设置可能会在未来以不向后兼容的方式更改或被移除。 +这是一个专家级设置,仅供开发人员调试使用。该设置在未来可能会以不向后兼容的方式发生更改或被移除。 ::: -可能值: +可能的值: - 0 - 禁用 - 1 - 启用 ## query_plan_remove_redundant_sorting {#query_plan_remove_redundant_sorting} -切换查询计划级别的优化,移除冗余的排序步骤,例如在子查询中。仅在设置 [query_plan_enable_optimizations](#query_plan_enable_optimizations) 为1时生效。 + + + + +切换查询计划级别的优化,删除冗余的排序步骤,例如在子查询中。 +仅在设置 [`query_plan_enable_optimizations`](#query_plan_enable_optimizations) 为 1 时生效。 :::note -这是一个专家级设置,仅供开发人员调试使用。该设置可能会在未来以不向后兼容的方式更改或被移除。 +这是一个专家级设置,仅供开发人员调试使用。该设置在未来可能会以不向后兼容的方式发生更改或被移除。 ::: -可能值: +可能的值: - 0 - 禁用 - 1 - 启用 ## query_plan_reuse_storage_ordering_for_window_functions {#query_plan_reuse_storage_ordering_for_window_functions} -切换查询计划级别的优化,当对窗口函数进行排序时使用存储排序。仅在设置 [query_plan_enable_optimizations](#query_plan_enable_optimizations) 为1时生效。 + + +切换查询计划级别的优化,在排序窗口函数时使用存储排序。 +仅在设置 [`query_plan_enable_optimizations`](#query_plan_enable_optimizations) 为 1 时生效。 :::note -这是一个专家级设置,仅供开发人员调试使用。该设置可能会在未来以不向后兼容的方式更改或被移除。 +这是一个专家级设置,仅供开发人员调试使用。该设置在未来可能会以不向后兼容的方式发生更改或被移除。 ::: -可能值: +可能的值: - 0 - 禁用 - 1 - 启用 ## query_plan_split_filter {#query_plan_split_filter} + + :::note -这是一个专家级设置,仅供开发人员调试使用。该设置可能会在未来以不向后兼容的方式更改或被移除。 +这是一个专家级设置,仅供开发人员调试使用。该设置在未来可能会以不向后兼容的方式发生更改或被移除。 ::: -切换查询计划级别的优化,将过滤器分割为表达式。仅在设置 [query_plan_enable_optimizations](#query_plan_enable_optimizations) 为1时生效。 +切换查询计划级别的优化,将过滤器拆分为表达式。 +仅在设置 [query_plan_enable_optimizations](#query_plan_enable_optimizations) 为 1 时生效。 -可能值: +可能的值: - 0 - 禁用 - 1 - 启用 ## query_plan_try_use_vector_search {#query_plan_try_use_vector_search} -切换查询计划级别的优化,尝试使用向量相似性索引。仅在设置 [query_plan_enable_optimizations](#query_plan_enable_optimizations) 为1时生效。 + + + + +切换查询计划级别的优化,尝试使用向量相似度索引。 +仅在设置 [`query_plan_enable_optimizations`](#query_plan_enable_optimizations) 为 1 时生效。 :::note -这是一个专家级设置,仅供开发人员调试使用。该设置可能会在未来以不向后兼容的方式更改或被移除。 +这是一个专家级设置,仅供开发人员调试使用。该设置在未来可能会以不向后兼容的方式发生更改或被移除。 ::: -可能值: +可能的值: - 0 - 禁用 - 1 - 启用 ## query_plan_use_new_logical_join_step {#query_plan_use_new_logical_join_step} -在查询计划中使用新的逻辑连接步骤。 + + + + +在查询计划中使用逻辑连接步骤。 +注意: 设置 `query_plan_use_new_logical_join_step` 已被弃用,请使用 `query_plan_use_logical_join_step` 替代。 ## query_profiler_cpu_time_period_ns {#query_profiler_cpu_time_period_ns} -设置 [查询分析器](../../operations/optimizing-performance/sampling-query-profiler.md) CPU 时钟计时器的周期。该计时器仅计数 CPU 时间。 + -可能值: +设置 [查询分析器](../../operations/optimizing-performance/sampling-query-profiler.md) 的 CPU 时钟计时器周期。该计时器仅计算 CPU 时间。 -- 一个正整数的纳秒数。 +可能的值: + +- 正整数(以纳秒为单位)。 - 推荐的值: + 推荐值: - - 10000000(每秒100次)纳秒及以上用于单个查询。 + - 10000000(每秒 100 次)纳秒及以上用于单个查询。 - 1000000000(每秒一次)用于集群范围的分析。 - 0 用于关闭计时器。 @@ -8295,114 +8406,130 @@ a Tuple( 另请参见: -- 系统表 [trace_log](/operations/system-tables/trace_log)。 +- 系统表 [trace_log](/operations/system-tables/trace_log) + ## query_profiler_real_time_period_ns {#query_profiler_real_time_period_ns} -设置 [query profiler](../../operations/optimizing-performance/sampling-query-profiler.md) 的实时时钟计时器的周期。实时时钟计时器计算墙钟时间。 +设置 [查询分析器](../../operations/optimizing-performance/sampling-query-profiler.md) 的真实时钟计时器周期。真实时钟计时器计算实际时间。 可能的值: -- 正整数,以纳秒为单位。 +- 正整数(以纳秒为单位)。 推荐值: - - 单个查询使用 10000000(每秒 100 次)纳秒及以下。 - - 集群范围内的分析使用 1000000000(每秒一次)。 + - 10000000(每秒 100 次)纳秒及以下用于单个查询。 + - 1000000000(每秒一次)用于集群范围的分析。 -- 0 表示关闭计时器。 +- 0 用于关闭计时器。 **在 ClickHouse Cloud 中暂时禁用。** 另请参见: - 系统表 [trace_log](/operations/system-tables/trace_log) + ## queue_max_wait_ms {#queue_max_wait_ms} -请求队列中的等待时间,如果并发请求数量超过最大值。 +请求队列的等待时间,如果并发请求的数量超过最大值。 + ## rabbitmq_max_wait_ms {#rabbitmq_max_wait_ms} -从 RabbitMQ 读取之前的等待时间。 +从 RabbitMQ 读取的等待时间,直到重试。 + ## read_backoff_max_throughput {#read_backoff_max_throughput} -在读取缓慢的情况下减少线程数的设置。当读取带宽低于指定字节数每秒时,统计事件。 +在读取缓慢时减少线程数量的设置。 计数事件,当读取带宽低于该数量字节/秒时。 + ## read_backoff_min_concurrency {#read_backoff_min_concurrency} -在读取缓慢的情况下尝试保持最小线程数的设置。 +在读取缓慢时尝试保持最小线程数量的设置。 + ## read_backoff_min_events {#read_backoff_min_events} -在读取缓慢的情况下减少线程数的设置。在达到一定事件数量后,将减少线程数。 +在读取缓慢时减少线程数量的设置。 触发减少线程数量的事件数。 + ## read_backoff_min_interval_between_events_ms {#read_backoff_min_interval_between_events_ms} -在读取缓慢的情况下减少线程数的设置。如果前一个事件经过的时间少于特定时间,则不考虑该事件。 +在读取缓慢时减少线程数量的设置。 如果前一个事件经过的时间少于一定时间,则不关注该事件。 + ## read_backoff_min_latency_ms {#read_backoff_min_latency_ms} -在读取缓慢的情况下减少线程数的设置。仅关注至少花费该时间的读取。 +在读取缓慢时减少线程数量的设置。 仅关注至少花费如此多时间的读取。 + ## read_from_filesystem_cache_if_exists_otherwise_bypass_cache {#read_from_filesystem_cache_if_exists_otherwise_bypass_cache} -允许在被动模式下使用文件系统缓存 - 利用现有的缓存条目,但不向缓存中添加更多条目。如果您为重型临时查询设置此设置,并将其关闭用于短实时查询,这将有助于避免因重型查询而导致的缓存抖动,并改善系统整体效率。 +允许在被动模式下使用文件系统缓存 - 从现有缓存条目中受益,但不再将新的条目放入缓存中。 如果您为重型临时查询设置此设置,并为短实时查询保持禁用,这将避免过重查询导致的缓存颠簸,并提高整体系统效率。 + ## read_from_page_cache_if_exists_otherwise_bypass_cache {#read_from_page_cache_if_exists_otherwise_bypass_cache} -在被动模式下使用用户空间页缓存,类似于 read_from_filesystem_cache_if_exists_otherwise_bypass_cache。 +以被动模式使用用户空间页面缓存,类似于 read_from_filesystem_cache_if_exists_otherwise_bypass_cache。 + ## read_in_order_two_level_merge_threshold {#read_in_order_two_level_merge_threshold} -在按主键顺序多线程读取期间运行初步合并步骤所需读取的最小部分数。 +在按主键顺序读取时,运行初步合并步骤所需读取的最小部分数量。 + ## read_in_order_use_buffering {#read_in_order_use_buffering} -在按主键顺序读取时合并之前使用缓冲。这增加了查询执行的并行性。 +在按主键顺序读取时,在合并之前使用缓存。它增加了查询执行的并行性。 + ## read_in_order_use_virtual_row {#read_in_order_use_virtual_row} -在按主键或其单调函数格式读取时使用虚拟行。在搜索多个部分时非常有用,因为仅会涉及相关部分。 +在按主键或其单调函数顺序读取时使用虚拟行。 当遍历多个部分时,这很有用,因为只会触及相关部分。 + ## read_overflow_mode {#read_overflow_mode} -当超出限制时该怎么办。 +超出限制时该如何处理。 + ## read_overflow_mode_leaf {#read_overflow_mode_leaf} -设置读取的数据量超过某一叶子限制时发生的事情。 +设置当读取的数据量超过其中一个叶子限制时会发生什么。 可能的选项: -- `throw`:抛出异常(默认)。 -- `break`:停止执行查询并返回部分结果。 +- `throw`: 抛出异常(默认)。 +- `break`: 停止执行查询并返回部分结果。 ## read_priority {#read_priority} -从本地文件系统或远程文件系统读取数据的优先级。仅支持本地文件系统的 'pread_threadpool' 方法和远程文件系统的 `threadpool` 方法。 +从本地文件系统或远程文件系统读取数据的优先级。仅支持用于本地文件系统的 'pread_threadpool' 方法和用于远程文件系统的 `threadpool` 方法。 + ## read_through_distributed_cache {#read_through_distributed_cache} @@ -8411,161 +8538,182 @@ a Tuple( -仅在 ClickHouse Cloud 中生效。允许从分布式缓存中读取。 +仅在 ClickHouse Cloud 中有效。允许从分布式缓存中读取。 + ## readonly {#readonly} -0 - 无只读限制。 1 - 仅允许读请求,以及更改显式允许的设置。 2 - 仅允许读请求,以及更改设置,除了 'readonly' 设置。 +0 - 没有只读限制。 1 - 仅允许读取请求,以及改变显式允许的设置。 2 - 仅允许读取请求,以及改变设置,但不包括 'readonly' 设置。 + ## receive_data_timeout_ms {#receive_data_timeout_ms} -接收数据的连接超时,用于接收第一个数据包或来自副本的正进展包。 +接收来自副本的第一段数据或带有正向进程的数据包的连接超时。 + ## receive_timeout {#receive_timeout} -从网络接收数据的超时(以秒为单位)。如果在此间隔内未收到字节,则抛出异常。如果您在客户端设置此设置,则相应连接端上的 'send_timeout' 也将设置在服务器上。 +从网络接收数据的超时,单位为秒。如果在此时间段内未接收到字节,则会抛出异常。如果在客户端设置了该设置,相应的服务器连接端口的套接字'send_timeout'也将被设置。 + ## regexp_max_matches_per_row {#regexp_max_matches_per_row} -设置每行单个正则表达式的最大匹配次数。使用它来防止在 [extractAllGroupsHorizontal](/sql-reference/functions/string-search-functions#extractallgroupshorizontal) 函数中使用贪婪正则表达式时的内存过载。 +设置每行单个正则表达式的最大匹配数。可用于在使用贪婪正则表达式的 [extractAllGroupsHorizontal](/sql-reference/functions/string-search-functions#extractallgroupshorizontal) 函数中防止内存过载。 可能的值: - 正整数。 + ## reject_expensive_hyperscan_regexps {#reject_expensive_hyperscan_regexps} -拒绝在使用 hyperscan 时可能代价高昂的模式(由于 NFA 状态爆炸)。 +拒绝在使用 hyperscan 时评估可能会很昂贵的模式(由于 NFA 状态膨胀)。 + ## remerge_sort_lowered_memory_bytes_ratio {#remerge_sort_lowered_memory_bytes_ratio} -如果重新合并后的内存使用未按此比例减少,则将禁用重新合并。 +如果在重新合并后内存使用量未降低到该比率,则将禁用重新合并。 + ## remote_filesystem_read_method {#remote_filesystem_read_method} 从远程文件系统读取数据的方法之一:read、threadpool。 + ## remote_filesystem_read_prefetch {#remote_filesystem_read_prefetch} -在从远程文件系统读取数据时是否应该使用预取。 +在从远程文件系统读取数据时应使用预取。 + ## remote_fs_read_backoff_max_tries {#remote_fs_read_backoff_max_tries} -最大带回尝试次数。 +最大读取尝试次数(带有回退)。 + ## remote_fs_read_max_backoff_ms {#remote_fs_read_max_backoff_ms} 尝试从远程磁盘读取数据时的最大等待时间。 + ## remote_read_min_bytes_for_seek {#remote_read_min_bytes_for_seek} -远程读取(url、s3)进行查找所需的最小字节数,而不是忽略读取。 +进行寻址所需的远程读取 (url, s3) 的最少字节,代替使用 ignore 读取。 + ## rename_files_after_processing {#rename_files_after_processing} - **类型:** 字符串 - **默认值:** 空字符串 -此设置允许为通过 `file` 表函数处理的文件指定重命名模式。当选项设置为成功处理文件时,所有通过 `file` 表函数读取的文件将根据指定的模式和占位符重命名。 +此设置允许指定由 `file` 表函数处理的文件的重命名模式。当选项被设置时,所有通过 `file` 表函数读取的文件将在处理成功时根据指定的模式和占位符重命名。 + ### 占位符 -- `%a` — 完整的原始文件名(例如 "sample.csv")。 -- `%f` — 无扩展名的原始文件名(例如 "sample")。 -- `%e` — 带点的原始文件扩展名(例如 ".csv")。 +- `%a` — 完整的原始文件名(例如,“sample.csv”)。 +- `%f` — 不带扩展名的原始文件名(例如,“sample”)。 +- `%e` — 带点的原始文件扩展名(例如,“.csv”)。 - `%t` — 时间戳(以微秒为单位)。 - `%%` — 百分号 ("%")。 + ### 示例 - 选项: `--rename_files_after_processing="processed_%f_%t%e"` - 查询: `SELECT * FROM file('sample.csv')` +如果读取 `sample.csv` 成功,文件将被重命名为 `processed_sample_1683473210851438.csv`。 -如果成功读取 `sample.csv`,文件将重命名为 `processed_sample_1683473210851438.csv`。 ## replace_running_query {#replace_running_query} -在使用 HTTP 接口时,可以传递 'query_id' 参数。这是充当查询标识符的任意字符串。 -如果此时同一用户的查询中已存在相同 'query_id' 的查询,则行为取决于 'replace_running_query' 参数。 +在使用 HTTP 接口时,可以传递 'query_id' 参数。这个参数是任何作为查询标识符的字符串。如果同一用户的同一 'query_id' 的查询已在运行,行为将取决于 'replace_running_query' 参数。 -`0`(默认) – 抛出异常(不允许运行已有相同 'query_id' 的查询)。 +`0`(默认) – 抛出异常(如果同一 'query_id' 的查询已在运行,则不允许查询运行)。 `1` – 取消旧查询并开始运行新查询。 -将此参数设置为 1 以实现分割条件的建议。在输入下一个字符后,如果旧查询尚未完成,则应取消。 +将此参数设置为 1,以实现对分段条件的建议。在输入下一个字符后,如果旧查询尚未完成,应该取消它。 + ## replace_running_query_max_wait_ms {#replace_running_query_max_wait_ms} -当 [replace_running_query](#replace_running_query) 设置处于活动状态时,运行相同 `query_id` 的查询完成的等待时间。 +当 [replace_running_query](#replace_running_query) 设置处于活动状态时,等待相同 `query_id` 的查询完成的等待时间。 可能的值: - 正整数。 -- 0 - 抛出异常,不允许在服务器已执行相同 `query_id` 的查询时运行新查询。 +- 0 — 在服务器中执行相同 `query_id` 的新查询时抛出异常。 + ## replication_wait_for_inactive_replica_timeout {#replication_wait_for_inactive_replica_timeout} -指定等待非活动副本执行 [ALTER](../../sql-reference/statements/alter/index.md)、[OPTIMIZE](../../sql-reference/statements/optimize.md) 或 [TRUNCATE](../../sql-reference/statements/truncate.md) 查询多长时间(以秒为单位)。 +指定等待非活动副本执行 [`ALTER`](../../sql-reference/statements/alter/index.md)、[`OPTIMIZE`](../../sql-reference/statements/optimize.md) 或 [`TRUNCATE`](../../sql-reference/statements/truncate.md) 查询的时间(以秒为单位)。 可能的值: -- 0 - 不等待。 -- 负整数 - 等待无限时间。 -- 正整数 - 等待的秒数。 +- `0` — 不等待。 +- 负整数 — 等待无限时间。 +- 正整数 — 等待的秒数。 + ## restore_replace_external_dictionary_source_to_null {#restore_replace_external_dictionary_source_to_null} -在恢复时将外部字典源替换为 Null。用于测试目的。 +在恢复时将外部字典源替换为 Null。对测试有用。 + ## restore_replace_external_engines_to_null {#restore_replace_external_engines_to_null} -仅用于测试目的。将所有外部引擎替换为 Null,以避免启动外部连接。 +用于测试目的。将所有外部引擎替换为 Null,以避免启动外部连接。 + ## restore_replace_external_table_functions_to_null {#restore_replace_external_table_functions_to_null} -仅用于测试目的。将所有外部表函数替换为 Null,以避免启动外部连接。 +用于测试目的。将所有外部表函数替换为 Null,以避免启动外部连接。 + ## restore_replicated_merge_tree_to_shared_merge_tree {#restore_replicated_merge_tree_to_shared_merge_tree} -在恢复期间将表引擎从 Replicated*MergeTree 替换为 Shared*MergeTree。 +在 RESTORE 期间将表引擎从 Replicated*MergeTree 替换为 Shared*MergeTree。 + ## result_overflow_mode {#result_overflow_mode} -云默认值: `throw` +Cloud 默认值: `throw` -如果结果的量超过某一限制,则设置该怎么办。 +设置结果量超过其中一个限制时的处理方式。 可能的值: - `throw`:抛出异常(默认)。 -- `break`:停止执行查询并返回部分结果,仿佛源数据已用尽。 +- `break`:停止执行查询并返回部分结果,仿佛源数据已经耗尽。 -使用 'break' 类似于使用 LIMIT。 `Break` 仅在块级别中中断执行。这意味着返回的行数大于 [`max_result_rows`](/operations/settings/settings#max_result_rows),是 [`max_block_size`](/operations/settings/settings#max_block_size) 的倍数,并且取决于 [`max_threads`](/operations/settings/settings#max_threads)。 +使用 'break' 类似于使用 LIMIT。`Break` 仅在块级别中中断执行。这意味着返回的行数大于 +[`max_result_rows`](/operations/settings/settings#max_result_rows)、[`max_block_size`](/operations/settings/settings#max_block_size) 的倍数,并取决于 [`max_threads`](/operations/settings/settings#max_threads)。 **示例** @@ -8581,94 +8729,120 @@ FORMAT Null; ```text title="Result" 6666 rows in set. ... ``` + ## rewrite_count_distinct_if_with_count_distinct_implementation {#rewrite_count_distinct_if_with_count_distinct_implementation} -允许您使用 [count_distinct_implementation](#count_distinct_implementation) 设置重写 `countDistinctIf` 。 +允许您将 `countDistcintIf` 重写为 [count_distinct_implementation](#count_distinct_implementation) 设置。 可能的值: - true — 允许。 -- false — 禁止。 +- false — 不允许。 + +## rewrite_in_to_join {#rewrite_in_to_join} + + + + + + + +重写表达式,例如 'x IN subquery' 为 JOIN。这可能对于优化整个查询的连接重排序有用。 + ## s3_allow_multipart_copy {#s3_allow_multipart_copy} -允许在 S3 中进行分块复制。 +允许在 S3 中进行多部分复制。 + ## s3_allow_parallel_part_upload {#s3_allow_parallel_part_upload} -使用多个线程进行 s3 分块上传。这可能会导致略微更高的内存使用。 +为 S3 多部分上传使用多个线程。可能会导致稍微更高的内存使用。 + ## s3_check_objects_after_upload {#s3_check_objects_after_upload} -对每个已上传对象执行头请求,以确保上传成功。 +使用头请求检查每个已上传对象以确保上传成功。 + ## s3_connect_timeout_ms {#s3_connect_timeout_ms} -S3 磁盘主机的连接超时。 +来自 s3 磁盘的主机的连接超时。 + ## s3_create_new_file_on_insert {#s3_create_new_file_on_insert} -在 s3 引擎表中,每次插入时启用或禁用创建新文件。如果启用,每次插入将创建一个新的 S3 对象,其键类似于以下模式: +启用或禁用在每次插入到 s3 引擎表时创建一个新文件。如果启用,则每次插入都会创建一个新的 S3 对象,其键类似于以下模式: -初始: `data.Parquet.gz` -> `data.1.Parquet.gz` -> `data.2.Parquet.gz` 等等。 +初始: `data.Parquet.gz` -> `data.1.Parquet.gz` -> `data.2.Parquet.gz` 等等。 可能的值: -- 0 — `INSERT` 查询创建新文件,或如果文件已存在且未设置 s3_truncate_on_insert,则失败。 -- 1 — `INSERT` 查询在每次插入时使用后缀(从第二个开始)创建新文件,前提是未设置 s3_truncate_on_insert。 +- 0 — `INSERT` 查询创建一个新文件,或者在文件已存在且未设置 s3_truncate_on_insert 时失败。 +- 1 — `INSERT` 查询在每次插入时创建一个新文件,使用后缀(从第二个开始),如果 s3_truncate_on_insert 未设置。 + +更多详细信息 [在这里](/integrations/s3#inserting-data)。 -有关更多详细信息,请参见 [这里](/integrations/s3#inserting-data)。 ## s3_disable_checksum {#s3_disable_checksum} -在将文件发送到 S3 时不计算校验和。这通过避免对文件进行过多的处理来加快写入速度。由于 MergeTree 表中的数据仍由 ClickHouse 进行校验和,因此这在大多数情况下是安全的,并且当通过 HTTPS 访问 S3 时,TLS 层已经在网络传输中提供了完整性。虽然在 S3 上额外的校验和可以提供深层防御。 +向 S3 发送文件时不计算校验和。这通过避免文件上的过度处理传递来加速写入。这大体上是安全的,因为 MergeTree 表的数据是由 ClickHouse 检查的,并且当以 HTTPS 访问 S3 时,TLS 层在通过网络传输时已经提供了完整性。虽然在 S3 上进行额外的校验和提供了深层防御。 + ## s3_ignore_file_doesnt_exist {#s3_ignore_file_doesnt_exist} -如果读取某些键时文件不存在,则忽略缺失。 + + +如果在读取某些键时文件不存在,则忽略文件缺失。 可能的值: - 1 — `SELECT` 返回空结果。 - 0 — `SELECT` 抛出异常。 + ## s3_list_object_keys_size {#s3_list_object_keys_size} -通过 ListObject 请求可以批量返回的最大文件数量。 +ListObject 请求中批量返回的最大文件数。 + ## s3_max_connections {#s3_max_connections} 每个服务器的最大连接数。 + ## s3_max_get_burst {#s3_max_get_burst} -在达到每秒请求限制之前同时发出的最大请求数。默认情况下(0)等于 `s3_max_get_rps`。 +在达到每秒请求限制之前可以同时发出的最大请求数。默认值为 (0) 等于 `s3_max_get_rps`。 + ## s3_max_get_rps {#s3_max_get_rps} -对 S3 GET 请求的每秒速率进行限制,然后进行限流。零表示无限制。 +在达到限制之前的 S3 GET 请求每秒速率限制。零表示无限制。 + ## s3_max_inflight_parts_for_one_file {#s3_max_inflight_parts_for_one_file} -在分块上传请求中,要并发加载的最大部分数。0 表示无限制。 +在多部分上传请求中同时加载的部分的最大数量。0表示无限制。 + ## s3_max_part_number {#s3_max_part_number} @@ -8676,115 +8850,133 @@ S3 磁盘主机的连接超时。 S3 上传部分的最大部分编号。 + ## s3_max_put_burst {#s3_max_put_burst} -在达到每秒请求限制之前同时发出的最大请求数。默认情况下(0)等于 `s3_max_put_rps`。 +在达到每秒请求限制之前可以同时发出的最大请求数。默认值为 (0) 等于 `s3_max_put_rps`。 + ## s3_max_put_rps {#s3_max_put_rps} -对 S3 PUT 请求的每秒速率进行限制,然后进行限流。零表示无限制。 -## s3_max_redirects {#s3_max_redirects} - - +在达到限制之前的 S3 PUT 请求每秒速率限制。零表示无限制。 -允许的 S3 重定向跳转的最大数量。 ## s3_max_single_operation_copy_size {#s3_max_single_operation_copy_size} -S3 中单次操作复制的最大大小。此设置仅在 s3_allow_multipart_copy 为 true 时使用。 +S3 中单次操作复制的最大大小。仅在 s3_allow_multipart_copy 为 true 的情况下使用此设置。 + ## s3_max_single_part_upload_size {#s3_max_single_part_upload_size} -使用单次上传到 S3 的对象的最大大小。 +使用单个部分上传到 S3 的对象的最大大小。 + ## s3_max_single_read_retries {#s3_max_single_read_retries} -在单次 S3 读取过程中最大的重试次数。 +单次 S3 读取期间的最大重试次数。 + ## s3_max_unexpected_write_error_retries {#s3_max_unexpected_write_error_retries} -在 S3 写入时遇到意外错误时的最大重试次数。 +在 S3 写入期间发生意外错误时的最大重试次数。 + ## s3_max_upload_part_size {#s3_max_upload_part_size} -在 multipart 上传到 S3 时的最大部分大小。 +多部分上传至 S3 的最大部分大小。 + ## s3_min_upload_part_size {#s3_min_upload_part_size} -在 multipart 上传到 S3 时的最小部分大小。 +多部分上传至 S3 的最小部分大小。 + ## s3_request_timeout_ms {#s3_request_timeout_ms} -与 S3 发送和接收数据的空闲超时。如果单个 TCP 读取或写入调用阻塞超过此时间,则失败。 -## s3_retry_attempts {#s3_retry_attempts} - - +向 S3 发送和接收数据的空闲超时。如果单次 TCP 读取或写入调用阻塞时间超过此时长,则失败。 -用于 Aws::Client::RetryStrategy 的设置,Aws::Client 自行进行重试,0 表示不重试。 ## s3_skip_empty_files {#s3_skip_empty_files} -在 [S3](../../engines/table-engines/integrations/s3.md) 引擎表中启用或禁用跳过空文件。 + + +启用或禁用在 [S3](../../engines/table-engines/integrations/s3.md) 引擎表中跳过空文件。 可能的值: -- 0 — 如果空文件与请求格式不兼容,`SELECT` 将抛出异常。 +- 0 — 如果空文件与请求的格式不兼容,`SELECT` 将抛出异常。 - 1 — 对于空文件,`SELECT` 返回空结果。 + ## s3_slow_all_threads_after_network_error {#s3_slow_all_threads_after_network_error} -设置为 `true` 时,在某个 S3 请求因可重试的网络错误而失败后,所有执行 S3 请求的线程将在一段时间内减慢。 -设置为 `false` 时,每个执行 S3 请求的线程在网络错误时使用独立的退避时间。 + + +设置为 `true` 时,任何单个 S3 请求遇到可重试网络错误(例如套接字超时)后,所有执行 S3 请求的线程都会变慢。设置为 `false` 时,每个线程独立处理 S3 请求的回退。 + +## s3_slow_all_threads_after_retryable_error {#s3_slow_all_threads_after_retryable_error} + + + + + +设置为 `true` 时,任何单个 S3 请求遇到可重试 S3 错误(例如 'Slow Down')后,所有执行 S3 请求的线程都会变慢。设置为 `false` 时,每个线程独立处理 S3 请求的回退。 + ## s3_strict_upload_part_size {#s3_strict_upload_part_size} -在 multipart 上传到 S3 时确切的部分大小(某些实现不支持可变大小的部分)。 +在对 S3 进行多部分上传时,上传部分的确切大小(某些实现不支持可变大小部分)。 + ## s3_throw_on_zero_files_match {#s3_throw_on_zero_files_match} -当 ListObjects 请求无法匹配任何文件时抛出错误。 +当 ListObjects 请求无法匹配到文件时抛出错误。 + ## s3_truncate_on_insert {#s3_truncate_on_insert} -启用或禁用在 S3 引擎表中的插入前截断。如果禁用,在尝试插入时,如果 S3 对象已存在,则将抛出异常。 +启用或禁用在 S3 引擎表中进行插入前的截断。如果禁用,在插入尝试时,如果 S3 对象已存在,将抛出异常。 可能的值: -- 0 — `INSERT` 查询创建新文件,或如果文件已存在而未设置 s3_create_new_file_on_insert,则失败。 +- 0 — `INSERT` 查询创建一个新文件,或者在文件已存在且未设置 s3_create_new_file_on_insert 时失败。 - 1 — `INSERT` 查询用新数据替换文件的现有内容。 -有关更多详细信息,请参见 [这里](/integrations/s3#inserting-data)。 +更多详细信息 [在这里](/integrations/s3#inserting-data)。 + ## s3_upload_part_size_multiply_factor {#s3_upload_part_size_multiply_factor} -每当从单次写入到 S3 上传的 s3_multiply_parts_count_threshold 部分时,将 s3_min_upload_part_size 乘以此因子。 +在从单个写入 S3 上传了 s3_multiply_parts_count_threshold 个部分时,每次将 s3_min_upload_part_size 乘以该因子。 + ## s3_upload_part_size_multiply_parts_count_threshold {#s3_upload_part_size_multiply_parts_count_threshold} -每次上传到 S3 的部分数量达到此数时,将 s3_min_upload_part_size 乘以 s3_upload_part_size_multiply_factor。 +每次上传到 S3 的部分数达到该数字时,s3_min_upload_part_size 乘以 s3_upload_part_size_multiply_factor。 + ## s3_use_adaptive_timeouts {#s3_use_adaptive_timeouts} -设置为 `true` 时,所有 S3 请求前两个尝试都以较低的发送和接收超时进行。 -设置为 `false` 时,所有尝试都以相同的超时进行。 +设置为 `true` 时,所有 S3 请求的前两次尝试都在低发送和接收超时中进行。设置为 `false` 时,所有尝试都在相同的超时时间内进行。 + ## s3_validate_request_settings {#s3_validate_request_settings} @@ -8792,20 +8984,22 @@ S3 中单次操作复制的最大大小。此设置仅在 s3_allow_multipart_cop 启用 S3 请求设置验证。 - 可能的值: - 1 — 验证设置。 - 0 — 不验证设置。 + ## s3queue_default_zookeeper_path {#s3queue_default_zookeeper_path} S3Queue 引擎的默认 zookeeper 路径前缀。 + ## s3queue_enable_logging_to_s3queue_log {#s3queue_enable_logging_to_s3queue_log} 启用写入 system.s3queue_log。可以通过表设置覆盖该值。 + ## s3queue_migrate_old_metadata_to_buckets {#s3queue_migrate_old_metadata_to_buckets} @@ -8813,111 +9007,121 @@ S3Queue 引擎的默认 zookeeper 路径前缀。 将 S3Queue 表的旧元数据结构迁移到新结构。 + ## schema_inference_cache_require_modification_time_for_url {#schema_inference_cache_require_modification_time_for_url} -在进行最后修改时间验证(对于带有 Last-Modified 标头的 URL)时从缓存使用架构。 +在 URL 的最后修改时间验证中使用缓存中的模式(对于带有 Last-Modified 头的 URL)。 + ## schema_inference_use_cache_for_azure {#schema_inference_use_cache_for_azure} -在使用 Azure 表函数时在架构推断中使用缓存。 +在使用 Azure 表函数时,使用模式推断中的缓存。 + ## schema_inference_use_cache_for_file {#schema_inference_use_cache_for_file} -在使用文件表函数时在架构推断中使用缓存。 +在使用文件表函数时,使用模式推断中的缓存。 + ## schema_inference_use_cache_for_hdfs {#schema_inference_use_cache_for_hdfs} -在使用 HDFS 表函数时在架构推断中使用缓存。 +在使用 HDFS 表函数时,使用模式推断中的缓存。 + ## schema_inference_use_cache_for_s3 {#schema_inference_use_cache_for_s3} -在使用 S3 表函数时在架构推断中使用缓存。 +在使用 S3 表函数时,使用模式推断中的缓存。 + ## schema_inference_use_cache_for_url {#schema_inference_use_cache_for_url} -在使用 URL 表函数时在架构推断中使用缓存。 +在使用 URL 表函数时,使用模式推断中的缓存。 + ## secondary_indices_enable_bulk_filtering {#secondary_indices_enable_bulk_filtering} -启用索引的批量过滤算法。预计总是更好,但我们有此设置以便兼容和控制。 +启用索引的批量过滤算法。预计总是更好,但我们保留此设置以便于兼容性和控制。 + ## select_sequential_consistency {#select_sequential_consistency} :::note -此设置在 SharedMergeTree 和 ReplicatedMergeTree 之间的行为不同,更多信息请参见 [SharedMergeTree 一致性](/cloud/reference/shared-merge-tree#consistency)。 +此设置在 SharedMergeTree 和 ReplicatedMergeTree 之间的行为不同,详情请参阅 [SharedMergeTree 一致性](/cloud/reference/shared-merge-tree#consistency)。 ::: -启用或禁用 `SELECT` 查询的顺序一致性。需要禁用 `insert_quorum_parallel`(默认启用)。 +启用或禁用 `SELECT` 查询的顺序一致性。要求禁用 `insert_quorum_parallel`(默认启用)。 可能的值: - 0 — 禁用。 - 1 — 启用。 -使用 +用法 -启用顺序一致性时,ClickHouse 允许客户端仅对所有之前执行的 `INSERT` 查询包含数据的副本执行 `SELECT` 查询。如果客户端引用部分副本,ClickHouse 将生成异常。SELECT 查询将不包括尚未写入副本 quorum 的数据。 +当启用顺序一致性时,ClickHouse 仅允许客户端对来自所有先前使用 `insert_quorum` 执行的 `INSERT` 查询的副本执行 `SELECT` 查询。如果客户端引用了部分副本,ClickHouse 将生成异常。SELECT 查询将不包括尚未写入副本仲裁的副本中的数据。 -当 `insert_quorum_parallel` 启用时(默认为启用),则 `select_sequential_consistency` 不起作用。这是因为并行 `INSERT` 查询可以写入不同的副本 quorum,因此没有保证单个副本会接收到所有写入。 +当启用 `insert_quorum_parallel`(默认值)时,`select_sequential_consistency` 不起作用。这是因为并行的 `INSERT` 查询可以写入不同集合的法定副本,因此无法保证单个副本会接收所有写入。 另请参见: - [insert_quorum](#insert_quorum) - [insert_quorum_timeout](#insert_quorum_timeout) - [insert_quorum_parallel](#insert_quorum_parallel) + ## send_logs_level {#send_logs_level} -要向客户端发送具有指定最低级别的服务器文本日志。有效值:'trace', 'debug', 'information', 'warning', 'error', 'fatal', 'none'。 +发送带有指定最低级别的服务器文本日志到客户端。有效值:'trace','debug','information','warning','error','fatal','none'。 + ## send_logs_source_regexp {#send_logs_source_regexp} -发送与指定正则表达式匹配的日志源名称的服务器文本日志。空意味着所有源。 -## send_progress_in_http_headers {#send_progress_in_http_headers} +发送带有指定正则表达式以匹配日志源名称的服务器文本日志。空表示所有来源。 - +## send_progress_in_http_headers {#send_progress_in_http_headers} -启用或禁用在 `clickhouse-server` 响应中包含 `X-ClickHouse-Progress` HTTP 响应头。 +启用或禁用 `clickhouse-server` 响应中的 `X-ClickHouse-Progress` HTTP 响应头。 -有关更多信息,请参见 [HTTP 接口描述](../../interfaces/http.md)。 +有关更多信息,请参阅 [HTTP 接口描述](../../interfaces/http.md)。 可能的值: - 0 — 禁用。 - 1 — 启用。 + ## send_timeout {#send_timeout} - +在网络中发送数据的超时,单位为秒。如果客户端需要发送一些数据但在此时间段内无法发送任何字节,则会抛出异常。如果在客户端设置了此设置,则套接字的'receive_timeout'也将设置在服务器上相应的连接端。 -向网络发送数据的超时(以秒为单位)。如果客户端需要发送数据,但在此间隔内无法发送任何字节,则抛出异常。如果您在客户端设置此设置,则相应连接端上的 'receive_timeout' 也将在服务器上设置。 ## serialize_query_plan {#serialize_query_plan} -序列化用于分布式处理的查询计划。 +序列化查询计划以便于分布式处理。 + ## session_timezone {#session_timezone} 设置当前会话或查询的隐式时区。 -隐式时区是应用于没有显式指定时区的 DateTime/DateTime64 类型值的时区。 -此设置优先于全局配置的(服务器级别)隐式时区。 -值为 ''(空字符串)意味着当前会话或查询的隐式时区等于 [服务器时区](../server-configuration-parameters/settings.md/#timezone)。 +隐式时区应用于没有显式指定时区的 DateTime/DateTime64 类型的值。 +该设置优先于全局配置的(服务器级)隐式时区。 +空字符串值表示当前会话或查询的隐式时区等于 [服务器时区](../server-configuration-parameters/settings.md/#timezone)。 您可以使用函数 `timeZone()` 和 `serverTimeZone()` 获取会话时区和服务器时区。 可能的值: -- 来自 `system.time_zones` 的任意时区名称,例如 `Europe/Berlin`、`UTC` 或 `Zulu`。 +- 任何 `system.time_zones` 中的时区名称,例如 `Europe/Berlin`、`UTC` 或 `Zulu`。 示例: @@ -8933,7 +9137,7 @@ SELECT timeZone(), serverTimeZone() SETTINGS session_timezone = 'Asia/Novosibirs "Asia/Novosibirsk","Europe/Berlin" ``` -将会话时区 'America/Denver' 分配给未显式指定时区的内部 DateTime: +将会话时区 'America/Denver' 分配给内含的没有显式指定时区的 DateTime: ```sql SELECT toDateTime64(toDateTime64('1999-12-12 23:23:23.123', 3), 3, 'Europe/Zurich') SETTINGS session_timezone = 'America/Denver' FORMAT TSV @@ -8942,7 +9146,7 @@ SELECT toDateTime64(toDateTime64('1999-12-12 23:23:23.123', 3), 3, 'Europe/Zuric ``` :::warning -并非所有解析 DateTime/DateTime64 的函数均尊重 `session_timezone`。这可能导致细微错误。 +并非所有解析 DateTime/DateTime64 的函数都遵循 `session_timezone`。这可能会导致微妙的错误。 请参见以下示例和说明。 ::: @@ -8958,84 +9162,98 @@ SELECT *, timeZone() FROM test_tz WHERE d = '2000-01-01 00:00:00' SETTINGS sessi └─────────────────────┴──────────────────┘ ``` -这一现象是由于不同的解析流程造成的: +这是由于不同的解析管道造成的: -- `toDateTime()` 在第一条 `SELECT` 查询中未显式给出时区,遵循设置的 `session_timezone` 和全局时区。 -- 在第二个查询中,从字符串解析 DateTime,并继承现有列 `d` 的类型和时区。因此,设置 `session_timezone` 和全局时区不会得到遵循。 +- 第一个 `SELECT` 查询中不带显式给出的时区的 `toDateTime()` 尊重 `session_timezone` 和全局时区。 +- 在第二个查询中,从字符串解析的 DateTime 继承现有列 `d` 的类型和时区。因此,设置 `session_timezone` 和全局时区将不被遵循。 **另请参见** - [timezone](../server-configuration-parameters/settings.md/#timezone) -## set_overflow_mode {#set_overflow_mode} - +## set_overflow_mode {#set_overflow_mode} -设置数据量超过某一限制时发生的事情。 +设置当数据量超过某个限制时的处理方式。 可能的值: - `throw`:抛出异常(默认)。 -- `break`:停止执行查询并返回部分结果,仿佛源数据已用尽。 +- `break`:停止执行查询并返回部分结果,就好像源数据已经耗尽。 + ## shared_merge_tree_sync_parts_on_partition_operations {#shared_merge_tree_sync_parts_on_partition_operations} -在 SMT 表中进行 MOVE | REPLACE | ATTACH 分区操作后自动同步数据部分集。仅限云。 -## short_circuit_function_evaluation {#short_circuit_function_evaluation} +在 SMT 表中 MOVE|REPLACE|ATTACH 分区操作后自动同步数据部分的集合。仅限 Cloud。 - +## short_circuit_function_evaluation {#short_circuit_function_evaluation} -允许根据 [短路方案](https://en.wikipedia.org/wiki/Short-circuit_evaluation) 计算 [if](../../sql-reference/functions/conditional-functions.md/#if)、[multiIf](../../sql-reference/functions/conditional-functions.md/#multiif)、[and](/sql-reference/functions/logical-functions#and) 和 [or](/sql-reference/functions/logical-functions#or) 函数。这有助于优化这些函数中复杂表达式的执行并防止可能的异常(例如,在未预期的情况下除以零)。 +允许根据短路方案优化执行这些函数的复杂表达式,并防止可能的异常(例如在意外情况下的除零)。 可能的值: -- `enable` — 启用适用于短路的函数的短路函数评估(可能抛出异常或计算繁重)。 -- `force_enable` — 为所有函数启用短路函数评估。 +- `enable` — 为适合的函数启用短路函数评估(可能抛出异常或计算负担重)。 +- `force_enable` — 对所有函数启用短路函数评估。 - `disable` — 禁用短路函数评估。 + ## short_circuit_function_evaluation_for_nulls {#short_circuit_function_evaluation_for_nulls} -优化当任一参数为 NULL 时返回 NULL 的函数评估。当函数参数中的 NULL 值所占的比例超过 short_circuit_function_evaluation_for_nulls_threshold 时,系统会跳过逐行评估该函数。相反,它立即对所有行返回 NULL,从而避免不必要的计算。 +优化在任何参数为 NULL 时返回 NULL 的函数的评估。当函数参数中 NULL 值的百分比超过 short_circuit_function_evaluation_for_nulls_threshold 时,系统将跳过逐行评估该函数。相反,该行将立即返回 NULL,避免不必要的计算。 + ## short_circuit_function_evaluation_for_nulls_threshold {#short_circuit_function_evaluation_for_nulls_threshold} -NULL 值的比率阈值,仅在所有参数中非 NULL 值的行上执行具有 Nullable 参数的函数。当包含 NULL 值的行数与总行数的比例超过此阈值时,将不会评估包含 NULL 值的行。 + + +仅在所有参数中都包含非 NULL 值的行上执行带有 Nullable 参数的函数的 NULL 值比率阈值。当包含 NULL 值的行数占总行数的比例超过此阈值时,将不评估这些包含 NULL 值的行。 + +## show_data_lake_catalogs_in_system_tables {#show_data_lake_catalogs_in_system_tables} + + + + + +启用在系统表中显示数据湖目录。 + ## show_table_uuid_in_table_create_query_if_not_nil {#show_table_uuid_in_table_create_query_if_not_nil} -设置 `SHOW TABLE` 查询显示。 +设置 `SHOW TABLE` 查询的显示。 可能的值: - 0 — 查询将不显示表 UUID。 -- 1 — 查询将显示表 UUID。 +- 1 — 查询将显示表 UUID。 + ## single_join_prefer_left_table {#single_join_prefer_left_table} - +在单个 JOIN 情况下,如遇标识符歧义时,优先选择左侧表。 -在单次 JOIN 中,如果标识符模糊则优先选择左表。 ## skip_redundant_aliases_in_udf {#skip_redundant_aliases_in_udf} -在用户定义函数中不使用(替换)冗余别名,以简化其用法。 + + +在用户定义的函数中不使用(替代)多余的别名,以简化其使用。 可能的值: -- 1 — 在 UDF 中跳过(替换)别名。 -- 0 — 在 UDF 中不跳过(替换)别名。 +- 1 — 在 UDF 中跳过(替代)别名。 +- 0 — 不在 UDF 中跳过(替代)别名。 **示例** -启用和禁用之间的区别: +启用与禁用之间的差异: 查询: @@ -9066,23 +9284,22 @@ EXPLAIN SYNTAX SELECT test_03274(4 + 2); ```text SELECT ((4 + 2) + 1, ((4 + 2) + 1) + 2) ``` -## skip_unavailable_shards {#skip_unavailable_shards} - +## skip_unavailable_shards {#skip_unavailable_shards} -启用或禁用无声跳过不可用的分片。 +启用或禁用静默跳过不可用的分片。 -如果所有副本不可用,则认为分片不可用。副本在以下情况下不可用: +如果所有副本均不可用,则分片被视为不可用。副本不可用的情况包括: -- ClickHouse 无法以任何原因连接到副本。 +- ClickHouse 无法因任何原因连接到副本。 - 连接到副本时,ClickHouse 会进行多次尝试。如果所有尝试都失败,则该副本被视为不可用。 + 在连接到副本时,ClickHouse 会进行多次尝试。如果所有尝试均失败,则该副本被视为不可用。 -- 副本无法通过 DNS 解析。 +- 无法通过 DNS 解析副本。 - 如果无法通过 DNS 解析副本的主机名,这可能表示以下情况: + 如果无法通过 DNS 解析副本的主机名,可能表示以下几种情况: - - 副本的主机没有 DNS 记录。这可能发生在动态 DNS 的系统中,例如 [Kubernetes](https://kubernetes.io),在该系统中,节点在停机期间可能无法解析,这并不是错误。 + - 副本主机没有 DNS 记录。这可能发生在动态 DNS 系统中,例如 [Kubernetes](https://kubernetes.io),在此期间节点可能无法解析,并且这不是错误。 - 配置错误。ClickHouse 配置文件包含错误的主机名。 @@ -9090,98 +9307,117 @@ SELECT ((4 + 2) + 1, ((4 + 2) + 1) + 2) - 1 — 启用跳过。 - 如果分片不可用,ClickHouse 根据部分数据返回结果,而不报告节点可用性问题。 + 如果一个分片不可用,ClickHouse 返回基于部分数据的结果,不报告节点可用性问题。 - 0 — 禁用跳过。 - 如果分片不可用,ClickHouse 抛出异常。 + 如果一个分片不可用,ClickHouse 抛出异常。 + ## sleep_after_receiving_query_ms {#sleep_after_receiving_query_ms} -在 TCPHandler 中接收查询后等待的时间。 +在 TCPHandler 中接收查询后睡眠的时间。 + ## sleep_in_send_data_ms {#sleep_in_send_data_ms} -在 TCPHandler 中发送数据时的等待时间。 +在 TCPHandler 中发送数据时的睡眠时间。 + ## sleep_in_send_tables_status_ms {#sleep_in_send_tables_status_ms} -在 TCPHandler 中发送表状态响应时的等待时间。 +在 TCPHandler 中发送表状态响应时的睡眠时间。 + ## sort_overflow_mode {#sort_overflow_mode} -设置在排序之前收到的行数超过某一限制时发生的事情。 + + +设置在排序前接收到的行数超过某个限制时发生的情况。 可能的值: - `throw`:抛出异常。 - `break`:停止执行查询并返回部分结果。 + +## split_intersecting_parts_ranges_into_layers_final {#split_intersecting_parts_ranges_into_layers_final} + + + + + +在 FINAL 优化期间将相交的部分范围拆分成层。 + ## split_parts_ranges_into_intersecting_and_non_intersecting_final {#split_parts_ranges_into_intersecting_and_non_intersecting_final} -在FINAL优化期间,将分片范围分为相交和不相交 -## splitby_max_substrings_includes_remaining_string {#splitby_max_substrings_includes_remaining_string} +在 FINAL 优化期间将部分范围拆分为相交和不相交部分。 - +## splitby_max_substrings_includes_remaining_string {#splitby_max_substrings_includes_remaining_string} -控制函数 [splitBy*()](../../sql-reference/functions/splitting-merging-functions.md) 的参数 `max_substrings` > 0 时,是否将剩余字符串包含在结果数组的最后一个元素中。 +控制带有参数 `max_substrings` > 0 的函数 [splitBy*()](../../sql-reference/functions/splitting-merging-functions.md) 是否将在结果数组的最后一个元素中包含剩余字符串。 可能的值: -- `0` - 剩余字符串将不会包含在结果数组的最后一个元素中。 -- `1` - 剩余字符串将包含在结果数组的最后一个元素中。这是Spark的[`split()`](https://spark.apache.org/docs/3.1.2/api/python/reference/api/pyspark.sql.functions.split.html)函数和Python的['string.split()'](https://docs.python.org/3/library/stdtypes.html#str.split)方法的行为。 +- `0` - 剩余字符串不会包含在结果数组的最后一个元素中。 +- `1` - 剩余字符串将包括在结果数组的最后一个元素中。这是 Spark 的 [`split()`](https://spark.apache.org/docs/3.1.2/api/python/reference/api/pyspark.sql.functions.split.html) 函数和 Python 的 ['string.split()'](https://docs.python.org/3/library/stdtypes.html#str.split) 方法的行为。 + ## stop_refreshable_materialized_views_on_startup {#stop_refreshable_materialized_views_on_startup} -在服务器启动时,防止调度可刷新的物化视图,就像使用SYSTEM STOP VIEWS一样。之后可以使用`SYSTEM START VIEWS`或`SYSTEM START VIEW `手动启动它们。这也适用于新创建的视图。对不可刷新的物化视图没有影响。 +在服务器启动时,防止安排可刷新的物化视图,仿佛使用 SYSTEM STOP VIEWS。您可以在此后手动启动它们,使用 `SYSTEM START VIEWS` 或 `SYSTEM START VIEW `。这也适用于新创建的视图。对不可刷新的物化视图没有影响。 + ## storage_file_read_method {#storage_file_read_method} -从存储文件读取数据的方法,可以是`read`,`pread`,`mmap`之一。mmap方法不适用于clickhouse-server(它是为clickhouse-local设计的)。 +从存储文件读取数据的方法之一:`read`、`pread`、`mmap`。mmap 方法不适用于 clickhouse-server(它用于 clickhouse-local)。 + ## storage_system_stack_trace_pipe_read_timeout_ms {#storage_system_stack_trace_pipe_read_timeout_ms} -从管道读取信息的最大时间,以接收查询`system.stack_trace`表中线程的信息。此设置用于测试目的,不应由用户更改。 +从管道读取信息以接收线程信息的最大时间,在查询 `system.stack_trace` 表时。此设置用于测试目的,不应由用户更改。 + ## stream_flush_interval_ms {#stream_flush_interval_ms} -在超时情况下,或当线程生成[ max_insert_block_size](#max_insert_block_size)行时对流式表有效。 +对具有流动性的表,在超时情况下,或者当线程生成 [max_insert_block_size](#max_insert_block_size) 行时起作用。 -默认值为7500。 +默认值为 7500。 + +值越小,数据越频繁地刷新到表中。将该值设置得过低会导致性能下降。 -值越小,数据越频繁地被刷新到表中。设置值过低会导致性能下降。 ## stream_like_engine_allow_direct_select {#stream_like_engine_allow_direct_select} -允许对于Kafka、RabbitMQ、FileLog、Redis Streams和NATS引擎使用直接的SELECT查询。如果存在附加的物化视图,即使启用此设置,SELECT查询也是不允许的。 +允许对 Kafka、RabbitMQ、FileLog、Redis Streams 和 NATS 引擎进行直接 SELECT 查询。如果有附加的物化视图,即使启用了此设置也不允许进行 SELECT 查询。 + ## stream_like_engine_insert_queue {#stream_like_engine_insert_queue} -当流式引擎从多个队列读取时,用户需要在写入时选择一个队列进行插入。由Redis Streams和NATS使用。 -## stream_poll_timeout_ms {#stream_poll_timeout_ms} +当流状引擎从多个队列中读取时,用户需要在写入时选择一个队列进行插入。由 Redis Streams 和 NATS 使用。 - +## stream_poll_timeout_ms {#stream_poll_timeout_ms} -从/到流式存储轮询数据的超时。 +从/到流存储轮询数据的超时。 ## system_events_show_zero_values {#system_events_show_zero_values} -允许从[`system.events`](../../operations/system-tables/events.md)中选择零值事件。 +允许从 [`system.events`](../../operations/system-tables/events.md) 中选择零值事件。 -一些监控系统要求将所有指标值传递给它们,甚至当指标值为零时。 +一些监控系统要求在每个检查点将所有指标值传递给它们,即使指标值为零。 可能的值: @@ -9215,142 +9451,175 @@ SELECT * FROM system.events WHERE event='QueryMemoryLimitExceeded'; │ QueryMemoryLimitExceeded │ 0 │ Number of times when memory limit exceeded for query. │ └──────────────────────────┴───────┴───────────────────────────────────────────────────────┘ ``` + +## table_engine_read_through_distributed_cache {#table_engine_read_through_distributed_cache} + + + + + + + +仅在 ClickHouse Cloud 中有效。允许通过表引擎 / 表函数 (s3, azure 等) 从分布式缓存读取。 + ## table_function_remote_max_addresses {#table_function_remote_max_addresses} -设置从模式生成的[remote](../../sql-reference/table-functions/remote.md)函数的最大地址数。 +设置通过 [remote](../../sql-reference/table-functions/remote.md) 函数从模式生成的最大地址数量。 可能的值: - 正整数。 + ## tcp_keep_alive_timeout {#tcp_keep_alive_timeout} -在TCP开始发送保活探测之前,连接需要保持空闲的时间(秒数) +连接需要保持空闲的秒数,才会开始发送 TCP 保活探测。 + ## temporary_data_in_cache_reserve_space_wait_lock_timeout_milliseconds {#temporary_data_in_cache_reserve_space_wait_lock_timeout_milliseconds} - + + +为临时数据在文件系统缓存中锁定空间预留的等待时间。 -锁定缓存以便为临时数据在文件系统缓存中保留空间的等待时间 ## temporary_files_codec {#temporary_files_codec} -设置用于磁盘上排序和连接操作的临时文件的压缩编码。 +设置在磁盘上的排序和连接操作中使用的临时文件的压缩编解码器。 可能的值: -- LZ4 — 采用[LZ4](https://en.wikipedia.org/wiki/LZ4_(compression_algorithm))压缩。 -- NONE — 不使用压缩。 +- LZ4 — 应用 [LZ4](https://en.wikipedia.org/wiki/LZ4_(compression_algorithm)) 压缩。 +- NONE — 不应用压缩。 + +## text_index_use_bloom_filter {#text_index_use_bloom_filter} + + + + + +用于测试目的,启用或禁用在文本索引中使用布隆过滤器。 + ## throw_if_deduplication_in_dependent_materialized_views_enabled_with_async_insert {#throw_if_deduplication_in_dependent_materialized_views_enabled_with_async_insert} -当设置`deduplicate_blocks_in_dependent_materialized_views`与`async_insert`同时启用时,在INSERT查询时引发异常。它保证了正确性,因为这些功能无法共存。 +当设置 `deduplicate_blocks_in_dependent_materialized_views` 与 `async_insert` 一起启用时,在 INSERT 查询时抛出异常。它保证了正确性,因为这两个功能不能一起工作。 + ## throw_if_no_data_to_insert {#throw_if_no_data_to_insert} -允许或禁止空INSERT,默认启用(在空插入时引发错误)。仅适用于使用[`clickhouse-client`](/interfaces/cli)或使用[gRPC接口](/interfaces/grpc)的INSERT操作。 +允许或禁止空 INSERT,默认启用(在空插入时抛出错误)。仅适用于使用 [`clickhouse-client`](/interfaces/cli) 或使用 [gRPC 接口](/interfaces/grpc) 的 INSERT。 + ## throw_on_error_from_cache_on_write_operations {#throw_on_error_from_cache_on_write_operations} -在写操作缓存(INSERT,合并)时忽略来自缓存的错误。 +在写操作(INSERT, 合并)时忽略缓存中的错误。 + ## throw_on_max_partitions_per_insert_block {#throw_on_max_partitions_per_insert_block} -允许控制达到`max_partitions_per_insert_block`时的行为。 +允许控制达到 `max_partitions_per_insert_block` 时的行为。 可能的值: -- `true` - 当插入块达到`max_partitions_per_insert_block`时,引发异常。 -- `false` - 当达到`max_partitions_per_insert_block`时,记录警告。 +- `true` - 当插入块达到 `max_partitions_per_insert_block` 时,抛出异常。 +- `false` - 当达到 `max_partitions_per_insert_block` 时记录警告。 :::tip -如果您尝试了解更改[`max_partitions_per_insert_block`](/operations/settings/settings#max_partitions_per_insert_block)对用户的影响,这可能会很有用。 +如果您试图理解更改 [`max_partitions_per_insert_block`](/operations/settings/settings#max_partitions_per_insert_block) 对用户的影响,这可能会很有用。 ::: + ## throw_on_unsupported_query_inside_transaction {#throw_on_unsupported_query_inside_transaction} -如果在事务内部使用不支持的查询,则引发异常 +如果在事务内部使用不支持的查询则抛出异常。 + ## timeout_before_checking_execution_speed {#timeout_before_checking_execution_speed} -在指定的时间(秒数)过后,检查执行速度是否过慢(不低于`min_execution_speed`)。 +在指定的秒数到期后检查执行速度是否太慢(不低于 `min_execution_speed`)。 + ## timeout_overflow_mode {#timeout_overflow_mode} -设置当查询运行时间超过`max_execution_time`或估计运行时间超过`max_estimated_execution_time`时要怎么做。 +设置查询运行时间超过 `max_execution_time` 或预估运行时间超过 `max_estimated_execution_time` 时该如何处理。 可能的值: - `throw`: 抛出异常(默认)。 -- `break`: 停止执行查询并返回部分结果,仿佛源数据用完了。 +- `break`: 停止执行查询并返回部分结果,就像源数据用尽一样。 + ## timeout_overflow_mode_leaf {#timeout_overflow_mode_leaf} -设置当叶子节点中的查询运行时间超过`max_execution_time_leaf`时发生的情况。 +设置当叶子节点中的查询运行时间超过 `max_execution_time_leaf` 时发生什么。 可能的值: - `throw`: 抛出异常(默认)。 -- `break`: 停止执行查询并返回部分结果,仿佛源数据用完了。 +- `break`: 停止执行查询并返回部分结果,就像源数据用尽一样。 + ## totals_auto_threshold {#totals_auto_threshold} -`totals_mode = 'auto'`的阈值。 -请参见“WITH TOTALS修饰符”部分。 +`totals_mode = 'auto'` 的阈值。请参见 "WITH TOTALS 修饰符" 一节。 + ## totals_mode {#totals_mode} -在存在HAVING时,以及在存在max_rows_to_group_by和group_by_overflow_mode = 'any'时,如何计算TOTALS。 -请参见“WITH TOTALS修饰符”部分。 +在存在 HAVING 的情况下以及当 `max_rows_to_group_by` 和 `group_by_overflow_mode = 'any'` 存在时,如何计算 TOTALS。请参见 "WITH TOTALS 修饰符" 一节。 + ## trace_profile_events {#trace_profile_events} -启用或禁用在更新配置事件时收集堆栈跟踪,连同配置事件的名称和增量的值,并将它们发送到[trace_log](/operations/system-tables/trace_log)。 +启用或禁用在每次更新配置文件事件时收集堆栈跟踪及配置文件事件的名称和增量值,并将它们发送到 [trace_log](/operations/system-tables/trace_log)。 可能的值: -- 1 — 启用配置事件的跟踪。 -- 0 — 禁用配置事件的跟踪。 +- 1 — 启用配置文件事件跟踪。 +- 0 — 禁用配置文件事件跟踪。 + ## transfer_overflow_mode {#transfer_overflow_mode} -设置当数据量超过某个限制时的行为。 +设置当数据量超过某个限制时会发生什么。 可能的值: - `throw`: 抛出异常(默认)。 -- `break`: 停止执行查询并返回部分结果,仿佛源数据用完了。 +- `break`: 停止执行查询并返回部分结果,就像源数据用尽一样。 + ## transform_null_in {#transform_null_in} -启用[NULL](/sql-reference/syntax#null)值在[IN](../../sql-reference/operators/in.md)操作符中的相等性。 +启用 [NULL](/sql-reference/syntax#null) 值在 [IN](../../sql-reference/operators/in.md) 操作符中的相等性比较。 -默认情况下,`NULL`值不能进行比较,因为`NULL`表示未定义的值。因此,比较`expr = NULL`必须始终返回`false`。通过此设置,`NULL = NULL`在`IN`操作符中返回`true`。 +默认情况下,`NULL` 值无法进行比较,因为 `NULL` 代表未定义的值。因此,比较 `expr = NULL` 必须始终返回 `false`。使用此设置时,`NULL = NULL` 在 `IN` 操作符中返回 `true`。 可能的值: -- 0 — 在`IN`操作符中比较`NULL`值返回`false`。 -- 1 — 在`IN`操作符中比较`NULL`值返回`true`。 +- 0 — 在 `IN` 操作符中比较 `NULL` 值返回 `false`。 +- 1 — 在 `IN` 操作符中比较 `NULL` 值返回 `true`。 **示例** -考虑`null_in`表: +考虑 `null_in` 表: ```text ┌──idx─┬─────i─┐ @@ -9391,30 +9660,34 @@ SELECT idx, i FROM null_in WHERE i IN (1, NULL) SETTINGS transform_null_in = 1; **另见** -- [IN操作符中的NULL处理](/sql-reference/operators/in#null-processing) +- [IN 操作符中的 NULL 处理](/sql-reference/operators/in#null-processing) + ## traverse_shadow_remote_data_paths {#traverse_shadow_remote_data_paths} -在查询system.remote_data_paths时,遍历冻结数据(影子目录)以外的实际表数据。 +遍历冻结数据(影子目录)以及实际表数据时的查询 `system.remote_data_paths`。 + ## union_default_mode {#union_default_mode} -设置合并`SELECT`查询结果的模式。此设置仅在与[UNION](../../sql-reference/statements/select/union.md)共享时使用,而不显式指定`UNION ALL`或`UNION DISTINCT`。 +设置 `SELECT` 查询结果组合的模式。仅在与 [UNION](../../sql-reference/statements/select/union.md) 共享时使用,且未显式指定 `UNION ALL` 或 `UNION DISTINCT`。 可能的值: -- `'DISTINCT'` — ClickHouse在合并查询结果时输出去重行。 -- `'ALL'` — ClickHouse输出合并查询结果的所有行,包括重复行。 -- `''` — ClickHouse在与`UNION`一起使用时生成异常。 +- `'DISTINCT'` — ClickHouse 在合并查询时输出去重后的行。 +- `'ALL'` — ClickHouse 输出合并查询时的所有行,包括重复行。 +- `''` — 如果与 `UNION` 一起使用,将生成异常。 + +请在 [UNION](../../sql-reference/statements/select/union.md) 中查看示例。 -请参见[UNION](../../sql-reference/statements/select/union.md)中的示例。 ## unknown_packet_in_send_data {#unknown_packet_in_send_data} -发送未知数据包而不是第N个数据数据包 +发送未知数据包代替第 N 个数据包。 + ## update_parallel_mode {#update_parallel_mode} @@ -9424,208 +9697,247 @@ SELECT idx, i FROM null_in WHERE i IN (1, NULL) SETTINGS transform_null_in = 1; 确定并发更新查询的行为。 可能的值: -- `sync` - 按顺序运行所有`UPDATE`查询。 -- `auto` - 仅按顺序运行在一个查询中更新的列与另一个查询中的表达式所用列之间有关联的`UPDATE`查询。 +- `sync` - 顺序运行所有 `UPDATE` 查询。 +- `auto` - 仅顺序运行在一个查询中更新的列与另一个查询中的表达式使用的列之间存在依赖关系的 `UPDATE` 查询。 - `async` - 不同步更新查询。 + ## update_sequential_consistency {#update_sequential_consistency} -如果为真,在执行更新之前将部分集合更新到最新版本。 +如果为真,则在执行更新前将部分集更新至最新版本。 + ## use_async_executor_for_materialized_views {#use_async_executor_for_materialized_views} -使用异步且可能是多线程的执行物化视图查询,可以加速在INSERT期间的视图处理,但也会消耗更多内存。 +使用异步和可能的多线程执行物化视图查询,可以在插入期间加速视图处理,但也会消耗更多内存。 + ## use_cache_for_count_from_files {#use_cache_for_count_from_files} -启用在表函数`file`/`s3`/`url`/`hdfs`/`azureBlobStorage`中计算行数时的缓存。 +启用在表函数 `file`/`s3`/`url`/`hdfs`/`azureBlobStorage` 中从文件计数时的行数缓存。 默认启用。 + ## use_client_time_zone {#use_client_time_zone} - +使用客户端时区解释 DateTime 字符串值,而不是采用服务器时区。 -使用客户端时区解释DateTime字符串值,而不是采用服务器时区。 ## use_compact_format_in_distributed_parts_names {#use_compact_format_in_distributed_parts_names} -在后台(`distributed_foreground_insert`)INSERT到使用`Distributed`引擎的表时,使用紧凑格式存储块。 +在 `Distributed` 引擎的表中,后台 (`distributed_foreground_insert`) INSERT 存储块时使用紧凑格式。 可能的值: -- 0 — 使用`user[:password]@host:port#default_database`目录格式。 -- 1 — 使用`[shard{shard_index}[_replica{replica_index}]]`目录格式。 +- 0 — 使用 `user[:password]@host:port#default_database` 目录格式。 +- 1 — 使用 `[shard{shard_index}[_replica{replica_index}]]` 目录格式。 :::note -- 设置`use_compact_format_in_distributed_parts_names=0`时,来自集群定义的更改不会应用于后台INSERT。 -- 设置`use_compact_format_in_distributed_parts_names=1`时,改变集群定义中节点的顺序,将改变`shard_index` / `replica_index`,请注意。 +- 当 `use_compact_format_in_distributed_parts_names=0` 时,集群定义中的更改将不应用于后台 INSERT。 +- 当 `use_compact_format_in_distributed_parts_names=1` 时,更改集群定义中的节点顺序将更改 `shard_index`/`replica_index`,请注意。 + ::: + ## use_concurrency_control {#use_concurrency_control} -遵循服务器的并发控制(详见全局服务器设置`concurrent_threads_soft_limit_num`和`concurrent_threads_soft_limit_ratio_to_cores`)。如果禁用,允许使用更大量的线程,即使服务器超载(不推荐正常使用,主要用于测试)。 +遵守服务器的并发控制(见 `concurrent_threads_soft_limit_num` 和 `concurrent_threads_soft_limit_ratio_to_cores` 全局服务器设置)。如果禁用,则允许使用更多线程,即使服务器过载(不建议在正常使用中,主要用于测试)。 + ## use_hedged_requests {#use_hedged_requests} -启用远程查询的hedged请求逻辑。它允许为查询与不同副本建立多个连接。 -当现有与副本的连接在`hedged_connection_timeout`内未建立或在`receive_data_timeout`内没有接收到数据时,启用新连接。查询使用第一个发送非空进度数据包(或数据数据包,如果`allow_changing_replica_until_first_data_packet`)的连接;其他连接将被取消。支持`max_parallel_replicas > 1`的查询。 +为远程查询启用 hedged 请求逻辑。它允许为查询建立与不同副本的多个连接。 +如果在 `hedged_connection_timeout` 内未建立与副本的现有连接,或者在 `receive_data_timeout` 内未收到数据,则启用新连接。查询使用发送非空进度数据包(或数据包,如果 `allow_changing_replica_until_first_data_packet`)的第一个连接;其他连接将被取消。支持 `max_parallel_replicas > 1` 的查询。 默认启用。 -在Cloud上默认禁用。 +云中的默认值: `1` + ## use_hive_partitioning {#use_hive_partitioning} -启用时,ClickHouse将检测文件样式表引擎[File](/sql-reference/table-functions/file#hive-style-partitioning)/[S3](/sql-reference/table-functions/s3#hive-style-partitioning)/[URL](/sql-reference/table-functions/url#hive-style-partitioning)/[HDFS](/sql-reference/table-functions/hdfs#hive-style-partitioning)/[AzureBlobStorage](/sql-reference/table-functions/azureBlobStorage#hive-style-partitioning)中的路径中的Hive样式分区(`/name=value/`),并允许在查询中使用分区列作为虚拟列。这些虚拟列的名称与分区路径中的名称相同,但以`_`开头。 +当启用时,ClickHouse 将在类似文件的表引擎 [File](/sql-reference/table-functions/file#hive-style-partitioning)/[S3](/sql-reference/table-functions/s3#hive-style-partitioning)/[URL](/sql-reference/table-functions/url#hive-style-partitioning)/[HDFS](/sql-reference/table-functions/hdfs#hive-style-partitioning)/[AzureBlobStorage](/sql-reference/table-functions/azureBlobStorage#hive-style-partitioning) 的路径中检测类似 Hive 的分区 (`/name=value/`),并允许在查询中使用分区列作为虚拟列。这些虚拟列将具有与分区路径中相同的名称,但以 `_` 开头。 + ## use_iceberg_metadata_files_cache {#use_iceberg_metadata_files_cache} -如果启用,冰山表函数和冰山存储可以利用冰山元数据文件缓存。 +如果开启,冰山表函数和冰山存储可能利用冰山元数据文件缓存。 可能的值: - 0 - 禁用 - 1 - 启用 + ## use_iceberg_partition_pruning {#use_iceberg_partition_pruning} - +使用冰山表的分区修剪。 -用于冰山表的冰山分区修剪 ## use_index_for_in_with_subqueries {#use_index_for_in_with_subqueries} - +如果 IN 操作符的右侧有子查询或表表达式,则尝试使用索引。 -如果在IN操作符的右侧有子查询或表表达式,则尝试使用索引进行过滤。 ## use_index_for_in_with_subqueries_max_values {#use_index_for_in_with_subqueries_max_values} -使用表索引进行过滤的IN操作符右侧集合的最大大小。它可以避免由于为大查询准备额外数据结构而导致的性能下降和内存使用增加。零意味着没有限制。 +IN 操作符右侧集合的最大大小,以使用表索引进行过滤。它可以避免由于准备大型查询所需的额外数据结构而导致的性能下降和更高内存使用。零意味着没有限制。 + +## use_join_disjunctions_push_down {#use_join_disjunctions_push_down} + + + +启用将 JOIN 条件中与 OR 连接的部分下推到相应输入端(“部分下推”)。 +这允许存储引擎更早过滤,从而可以减少读取的数据量。 +该优化保持语义的,但仅在每个顶层 OR 分支至少对目标侧贡献一个确定性谓词时应用。 + ## use_json_alias_for_old_object_type {#use_json_alias_for_old_object_type} -启用时,将使用`JSON`数据类型别名以创建旧的[Object('json')](../../sql-reference/data-types/json.md)类型,而不是新的[JSON](../../sql-reference/data-types/newjson.md)类型。 +启用时,将使用 `JSON` 数据类型别名创建旧 [Object('json')](../../sql-reference/data-types/json.md) 类型,而不是新的 [JSON](../../sql-reference/data-types/newjson.md) 类型。 + +## use_legacy_to_time {#use_legacy_to_time} + + + + + +当启用时,允许使用遗留的 toTime 函数,该函数将带时间的日期转换为某个固定日期,同时保留时间。 +否则,使用新的 toTime 函数,它将不同类型的数据转换为时间类型。 +旧的遗留函数在任何情况下也可以无条件访问,作为 toTimeWithFixedDate。 + ## use_page_cache_for_disks_without_file_cache {#use_page_cache_for_disks_without_file_cache} - +对没有启用文件系统缓存的远程磁盘使用用户空间页缓存。 -对于未启用文件系统缓存的远程磁盘,使用用户空间页面缓存。 ## use_page_cache_with_distributed_cache {#use_page_cache_with_distributed_cache} - +在使用分布式缓存时使用用户空间页缓存。 -在使用分布式缓存时使用用户空间页面缓存。 ## use_query_cache {#use_query_cache} - - -如果启用,`SELECT`查询可以利用[查询缓存](../query-cache.md)。参数[enable_reads_from_query_cache](#enable_reads_from_query_cache)和[enable_writes_to_query_cache](#enable_writes_to_query_cache)更详细地控制缓存的使用。 +如果开启,`SELECT` 查询可能利用 [查询缓存](../query-cache.md)。参数 [enable_reads_from_query_cache](#enable_reads_from_query_cache) 和 [enable_writes_to_query_cache](#enable_writes_to_query_cache) 更详细地控制缓存的使用。 可能的值: - 0 - 禁用 - 1 - 启用 + ## use_query_condition_cache {#use_query_condition_cache} - - -启用[查询条件缓存](/operations/query-condition-cache)。该缓存存储不满足`WHERE`子句条件的数据部分中的粒度范围,并在后续查询中重复使用该信息作为临时索引。 +启用 [查询条件缓存](/operations/query-condition-cache)。缓存存储不满足 `WHERE` 子句条件的数据部分中的聚合范围,并在后续查询中重用这些信息作为临时索引。 可能的值: - 0 - 禁用 - 1 - 启用 -## use_skip_indexes {#use_skip_indexes} - +## use_roaring_bitmap_iceberg_positional_deletes {#use_roaring_bitmap_iceberg_positional_deletes} + + + +使用 roaring 位图进行冰山的定位删除。 + +## use_skip_indexes {#use_skip_indexes} -在执行查询期间使用数据跳过索引。 +在查询执行期间使用数据跳过索引。 可能的值: - 0 — 禁用。 - 1 — 启用。 + ## use_skip_indexes_if_final {#use_skip_indexes_if_final} - + -控制在执行带有FINAL修饰符的查询时,是否使用跳过索引。 +控制在执行带有 FINAL 修饰符的查询时是否使用跳过索引。 -默认情况下,这个设置是禁用的,因为跳过索引可能会排除包含最新数据的行(粒度),这可能导致不正确的结果。启用时,即使带有FINAL修饰符也会应用跳过索引,可能提高性能,但有错过最近更新的风险。 +跳过索引可能排除包含最新数据的行(颗粒),这可能导致带有 FINAL 修饰符的查询结果不正确。当此设置启用时,即使在使用 FINAL 修饰符的情况下,也会应用跳过索引,从而可能提高性能,但存在遗漏最近更新的风险。此设置应与设置 use_skip_indexes_if_final_exact_mode 同步启用(默认启用)。 可能的值: - 0 — 禁用。 - 1 — 启用。 + ## use_skip_indexes_if_final_exact_mode {#use_skip_indexes_if_final_exact_mode} - + + +控制当跳过索引返回的颗粒在较新部分中扩展时,在执行带有 FINAL 修饰符的查询时返回正确的结果。 + +使用跳过索引可能排除包含最新数据的行(颗粒),这可能导致结果不正确。此设置可以确保通过扫描与跳过索引返回的范围重叠的较新部分返回正确的结果。仅在应用程序对基于跳过索引查找的近似结果无所谓的情况下,才应禁用此设置。 + +可能的值: + +- 0 — 禁用。 +- 1 — 启用。 + +## use_skip_indexes_on_data_read {#use_skip_indexes_on_data_read} - + -控制查询执行中,跳过索引返回的粒度是否在新部分中展开,以返回正确的结果。 +在数据读取过程中启用使用数据跳过索引。 -使用跳过索引可能会排除包含最新数据的行(粒度),这可能导致不正确的结果。该设置可以确保通过扫描与跳过索引返回的范围重叠的新部分,返回正确的结果。 +启用时,跳过索引会在读取每个数据颗粒时动态评估,而不是在查询执行开始前提前分析。这可以减少查询启动延迟。 可能的值: - 0 — 禁用。 - 1 — 启用。 + ## use_structure_from_insertion_table_in_table_functions {#use_structure_from_insertion_table_in_table_functions} - +使用插入表的结构,而不是从数据推断的模式。可能的值: 0 - 禁用,1 - 启用,2 - 自动。 -使用插入表的结构,而不是从数据推断模式。可能的值:0 - 禁用,1 - 启用,2 - 自动 ## use_uncompressed_cache {#use_uncompressed_cache} -是否使用未压缩块的缓存。接受0或1。默认情况下,0(禁用)。 -使用未压缩缓存(仅针对MergeTree家族中的表)可以显著降低延迟并提高处理大量短查询的吞吐量。对于频繁发送短请求的用户启用此设置。还需注意[uncompressed_cache_size](/operations/server-configuration-parameters/settings#uncompressed_cache_size)配置参数(仅在配置文件中设置) - 未压缩缓存块的大小。默认为8 GiB。未压缩缓存根据需要填充,最少使用的数据会被自动删除。 +是否使用未压缩块的缓存。接受 0 或 1。默认情况下,0(禁用)。 +使用未压缩缓存(仅适用于 MergeTree 家族中的表)可以显著降低延迟并提高处理大量短查询时的吞吐量。对频繁发送短请求的用户启用此设置。还请注意配置参数 [uncompressed_cache_size](/operations/server-configuration-parameters/settings#uncompressed_cache_size)(仅在配置文件中设置)– 未压缩缓存块的大小。默认情况下为 8 GiB。未压缩缓存根据需要填充,并自动删除使用最少的数据。 + +对于至少读取一定量数据(百万行或更多)的查询,未压缩缓存会自动禁用,以节省真正小查询所需的空间。这意味着您可以将 'use_uncompressed_cache' 设置始终设置为 1。 -对于读取至少一定数据量(百万行或更多)的查询,自动禁用未压缩缓存以节省真正小查询的空间。这意味着您可以始终将'使用未压缩缓存'设置为1。 ## use_variant_as_common_type {#use_variant_as_common_type} - - -允许将`Variant`类型用作[if](../../sql-reference/functions/conditional-functions.md/#if)/[multiIf](../../sql-reference/functions/conditional-functions.md/#multiif)/[array](../../sql-reference/functions/array-functions.md)/[map](../../sql-reference/functions/tuple-map-functions.md)函数的返回类型,当参数类型没有共同类型时。 +允许在没有公共类型的情况下使用 `Variant` 类型作为 [if](../../sql-reference/functions/conditional-functions.md/#if)/[multiIf](../../sql-reference/functions/conditional-functions.md/#multiIf)/[array](../../sql-reference/functions/array-functions.md)/[map](../../sql-reference/functions/tuple-map-functions.md) 函数的结果类型。 示例: @@ -9702,105 +10014,119 @@ SELECT map('a', range(number), 'b', number, 'c', 'str_' || toString(number)) as │ {'a':[0,1],'b':2,'c':'str_2'} │ └───────────────────────────────┘ ``` + ## use_with_fill_by_sorting_prefix {#use_with_fill_by_sorting_prefix} -ORDER BY子句中与WITH FILL列前面的列形成排序前缀。排序前缀中具有不同值的行独立填充 +在 ORDER BY 子句中排在 WITH FILL 列之前的列形成排序前缀。排序前缀中具有不同值的行会独立填充。 + ## validate_enum_literals_in_operators {#validate_enum_literals_in_operators} - +如果启用,验证操作符中如 `IN`、`NOT IN`、`==`、`!=` 的枚举字面量与枚举类型的一致性,如果字面量不是有效的枚举值,则抛出异常。 -如果启用,在`IN`,`NOT IN`,`==`,`!=`等操作符中验证枚举字面值是否与枚举类型一致,并且如果字面值不是有效的枚举值,则引发异常。 ## validate_mutation_query {#validate_mutation_query} - +在接受变更查询之前进行验证。变更在后台执行,运行无效查询将导致变更被卡住,需要手动干预。 -接受变更查询之前验证它们。变更将在后台执行,运行无效查询将导致变更卡住,需要手动干预。 +只有在遇到不向后兼容的 bug 时才更改此设置。 -仅在您遇到向后不兼容的错误时更改此设置。 ## validate_polygons {#validate_polygons} - - -启用或禁用在[pointInPolygon](/sql-reference/functions/geo/coordinates#pointinpolygon)函数中抛出异常,如果多边形是自相交或自切线。 +启用或禁用在 [pointInPolygon](/sql-reference/functions/geo/coordinates#pointinpolygon) 函数中抛出异常,如果多边形自相交或自切。 可能的值: -- 0 — 禁用抛出异常。`pointInPolygon`接受无效多边形,并可能为它们返回不正确的结果。 +- 0 — 禁用抛出异常。`pointInPolygon` 接受无效的多边形,并返回可能不正确的结果。 - 1 — 启用抛出异常。 -## vector_search_filter_strategy {#vector_search_filter_strategy} - +## vector_search_filter_strategy {#vector_search_filter_strategy} - - -如果向量搜索查询有WHERE子句,则此设置决定是先评估(预过滤)还是先检查向量相似度索引(后过滤)。可能的值: -- 'auto' - 后过滤(具体语义可能会在未来更改)。 -- 'postfilter' - 使用向量相似度索引识别最近邻,然后应用其他过滤器。 -- 'prefilter' - 先评估其他过滤器,然后执行暴力搜索以识别邻居。 -## vector_search_postfilter_multiplier {#vector_search_postfilter_multiplier} +如果向量搜索查询具有 WHERE 子句,此设置决定是先评估该子句(预过滤)还是首先检查向量相似度索引(后过滤)。可能的值: +- 'auto' - 后过滤(确切语义可能在未来改变)。 +- 'postfilter' - 使用向量相似度索引确定最近邻,然后应用其他过滤条件。 +- 'prefilter' - 先评估其他过滤条件,然后执行暴力搜索以识别邻近点。 - +## vector_search_index_fetch_multiplier {#vector_search_index_fetch_multiplier} - +将从向量相似度索引中获取的最近邻数量乘以该数字。仅在后过滤与其他谓词组合或设置 'vector_search_with_rescoring = 1' 时适用。 + +## vector_search_with_rescoring {#vector_search_with_rescoring} + + + +如果 ClickHouse 对使用向量相似度索引的查询执行重新评分。 +不进行重新评分时,向量相似度索引直接返回包含最佳匹配的行。 +进行重新评分时,行被推断到颗粒级,颗粒中的所有行将再次被检查。 +在大多数情况下,重新评分仅对准确性有微小帮助,但会显著降低向量搜索查询的性能。 +注意:没有重新评分且启用并行副本的查询可能会回退至重新评分。 -在对其他谓词执行后过滤之前,从向量相似度索引获取的最近邻居乘以此数字。 ## wait_changes_become_visible_after_commit_mode {#wait_changes_become_visible_after_commit_mode} -等待已提交的更改在最新快照中真正可见 +等待已提交的更改在最新快照中实际可见。 + ## wait_for_async_insert {#wait_for_async_insert} - +如果为真,则等待异步插入处理完成。 -如果为真,等待异步插入处理 ## wait_for_async_insert_timeout {#wait_for_async_insert_timeout} - +等待异步插入处理的超时。 -等待异步插入处理的超时 ## wait_for_window_view_fire_signal_timeout {#wait_for_window_view_fire_signal_timeout} -在事件时间处理过程中等待窗口视图触发信号的超时 +等待事件时间处理中窗口视图触发信号的超时。 + ## window_view_clean_interval {#window_view_clean_interval} -窗口视图的清理间隔,以秒为单位,用于释放过时数据。 +窗口视图的清理间隔,单位为秒,以释放过时的数据。 + ## window_view_heartbeat_interval {#window_view_heartbeat_interval} -以秒为单位的心跳间隔,用于指示监视查询处于活动状态。 +心跳间隔,单位为秒,以指示监视查询仍处于活动状态。 + ## workload {#workload} - +资源访问所使用的工作负载名称。 + +## write_full_path_in_iceberg_metadata {#write_full_path_in_iceberg_metadata} + + + + + + + +将完整路径(包括 s3://)写入冰山元数据文件。 -用于访问资源的工作负载名称 ## write_through_distributed_cache {#write_through_distributed_cache} @@ -9809,9 +10135,20 @@ ORDER BY子句中与WITH FILL列前面的列形成排序前缀。排序前缀中 -仅在ClickHouse Cloud中生效。允许写入分布式缓存(写入s3也将通过分布式缓存进行)。 +仅在 ClickHouse Cloud 中有效。允许写入分布式缓存(写入 s3 也将通过分布式缓存完成)。 + +## write_through_distributed_cache_buffer_size {#write_through_distributed_cache_buffer_size} + + + + + + + +仅在 ClickHouse Cloud 中有效。设置写透分布式缓存的缓冲区大小。如果为 0,将使用如果没有分布式缓存将使用的缓冲区大小。 + ## zstd_window_log_max {#zstd_window_log_max} -允许您选择ZSTD的最大窗口日志(它不会用于MergeTree家族) +允许选择 ZSTD 的最大窗口日志(不适用于 MergeTree 家族)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/settings.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/settings.md.hash index e905c547659..a2f24063f37 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/settings.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/settings.md.hash @@ -1 +1 @@ -76fc6a415d5d8041 +7f8aaf3a4db8bd01 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/tcp-connection-limits.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/tcp-connection-limits.md new file mode 100644 index 00000000000..33bfc259310 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/tcp-connection-limits.md @@ -0,0 +1,34 @@ +--- +'description': 'TCP 连接限制。' +'sidebar_label': 'TCP 连接限制' +'slug': '/operations/settings/tcp-connection-limits' +'title': 'TCP 连接限制' +'doc_type': 'reference' +--- + + +# TCP 连接限制 + +## 概述 {#overview} + +您可能会发现 ClickHouse 的 TCP 连接(即通过 [命令行客户端](https://clickhouse.com/docs/interfaces/cli))在执行一定数量的查询或持续时间后自动断开。 +断开后,不会自动重新连接(除非通过其他方式触发,例如在命令行客户端发送另一个查询)。 + +连接限制通过设置服务器选项 `tcp_close_connection_after_queries_num`(用于查询限制)或 `tcp_close_connection_after_queries_seconds`(用于持续时间限制)为大于 0 的值来启用。 +如果同时启用了两个限制,则当任一限制首先触发时,连接将关闭。 + +当触碰限制并断开时,客户端会收到 `TCP_CONNECTION_LIMIT_REACHED` 异常,并且 **导致断开的查询将不会被处理**。 + +## 查询限制 {#query-limits} + +假设 `tcp_close_connection_after_queries_num` 设置为 N,则连接允许 N 次成功查询。然后在查询 N + 1 时,客户端将断开连接。 + +每个处理的查询都会计入查询限制。因此,当连接命令行客户端时,可能会有一个自动的初始系统警告查询,这会计入限制。 + +当 TCP 连接处于空闲状态(即,在一段时间内没有处理查询,具体时间由会话设置 `poll_interval` 指定)时,到目前为止计入的查询数量将重置为 0。 +这意味着在单个连接中查询的总数可以超过 `tcp_close_connection_after_queries_num`,如果出现空闲状态。 + +## 持续时间限制 {#duration-limits} + +连接持续时间从客户端连接时开始计算。 +在经过 `tcp_close_connection_after_queries_seconds` 秒后,客户端在第一个查询时会断开连接。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/tcp-connection-limits.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/tcp-connection-limits.md.hash new file mode 100644 index 00000000000..8ba693a2a53 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/settings/tcp-connection-limits.md.hash @@ -0,0 +1 @@ +8c7d6662a69987f3 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/ssl-zookeeper.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/ssl-zookeeper.md index 6efb1e331ef..773a1edbb2d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/ssl-zookeeper.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/ssl-zookeeper.md @@ -1,18 +1,19 @@ --- -'description': '配置 ClickHouse 与 ZooKeeper 之间安全的 SSL/TLS 通信的指南' +'description': '配置 ClickHouse 和 ZooKeeper 之间安全的 SSL/TLS 通信的指南' 'sidebar_label': '与 Zookeeper 的安全通信' 'sidebar_position': 45 'slug': '/operations/ssl-zookeeper' 'title': '与 Zookeeper 的可选安全通信' +'doc_type': 'guide' --- import SelfManaged from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_self_managed_only_automated.md'; -# 可选的 ClickHouse 和 Zookeeper 之间的安全通信 +# 可选的 ClickHouse 与 Zookeeper 之间的安全通信 -您应该为通过 SSL 与 ClickHouse 客户端的通信指定 `ssl.keyStore.location`、`ssl.keyStore.password` 以及 `ssl.trustStore.location`、`ssl.trustStore.password`。这些选项自 Zookeeper 版本 3.5.2 起可用。 +您应该为通过 SSL 与 ClickHouse 客户端的通信指定 `ssl.keyStore.location`、`ssl.keyStore.password` 以及 `ssl.trustStore.location`、`ssl.trustStore.password`。这些选项在 Zookeeper 版本 3.5.2 中可用。 您可以将 `zookeeper.crt` 添加到受信任的证书中。 @@ -21,7 +22,7 @@ sudo cp zookeeper.crt /usr/local/share/ca-certificates/zookeeper.crt sudo update-ca-certificates ``` -`config.xml` 中的客户端部分将如下所示: +`config.xml` 中的客户端部分看起来如下: ```xml @@ -37,7 +38,7 @@ sudo update-ca-certificates ``` -使用一些集群和宏将 Zookeeper 添加到 ClickHouse 配置中: +将 Zookeeper 添加到 ClickHouse 配置中,并指定某个集群和宏: ```xml @@ -51,30 +52,30 @@ sudo update-ca-certificates ``` -启动 `clickhouse-server`。在日志中您应该看到: +启动 `clickhouse-server`。在日志中您应该会看到: ```text ZooKeeper: initialized, hosts: secure://localhost:2281 ``` -前缀 `secure://` 表示连接是通过 SSL 保护的。 +前缀 `secure://` 表示连接是通过 SSL 进行安全的。 -要确保流量被加密,请在安全端口上运行 `tcpdump`: +为了确保流量被加密,请在安全端口上运行 `tcpdump`: ```bash tcpdump -i any dst port 2281 -nnXS ``` -并在 `clickhouse-client` 中查询: +并在 `clickhouse-client` 中执行查询: ```sql SELECT * FROM system.zookeeper WHERE path = '/'; ``` -在未加密的连接中,您会在 `tcpdump` 输出中看到类似于以下内容: +在未加密的连接中,您将在 `tcpdump` 输出中看到类似这样的内容: ```text ..../zookeeper/quota. ``` -在加密连接中,您不应该看到这些。 +在加密的连接中,您不应该看到这些内容。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/ssl-zookeeper.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/ssl-zookeeper.md.hash index e9608a865a7..771715a5a13 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/ssl-zookeeper.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/ssl-zookeeper.md.hash @@ -1 +1 @@ -1931934f864d53a6 +ee097eaef9141778 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/startup-scripts.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/startup-scripts.md index fbc252a899a..42c7992ff6d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/startup-scripts.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/startup-scripts.md @@ -1,8 +1,9 @@ --- -'description': '在 ClickHouse 中配置和使用 SQL 启动脚本的指南,用于自动创建模式和迁移' +'description': '有关在 ClickHouse 中配置和使用 SQL 启动脚本以自动创建和迁移架构的指南' 'sidebar_label': '启动脚本' 'slug': '/operations/startup-scripts' 'title': '启动脚本' +'doc_type': 'guide' --- @@ -13,7 +14,7 @@ ClickHouse 可以在启动期间从服务器配置运行任意 SQL 查询。这 ```xml - false + false CREATE ROLE OR REPLACE test_role @@ -29,10 +30,10 @@ ClickHouse 可以在启动期间从服务器配置运行任意 SQL 查询。这 ``` -ClickHouse 按照指定的顺序依次执行 `startup_scripts` 中的所有查询。如果任何查询失败,后续查询的执行不会中断。但是,如果 `throw_on_error` 被设置为 true,服务器将在脚本执行期间发生错误时不会启动。 +ClickHouse 按照指定的顺序依次执行 `startup_scripts` 中的所有查询。如果任何查询失败,后续查询的执行不会中断。然而,如果将 `throw_on_error` 设置为 true,则在脚本执行期间发生错误时,服务器将不会启动。 您可以在配置中指定条件查询。在这种情况下,只有当条件查询返回值 `1` 或 `true` 时,相应的查询才会执行。 :::note -如果条件查询返回值不是 `1` 或 `true`,则结果将被解释为 `false`,相应的查询将不会被执行。 +如果条件查询返回的值不是 `1` 或 `true`,结果将被解释为 `false`,相应的查询将不会执行。 ::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/startup-scripts.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/startup-scripts.md.hash index 0248b4125c9..6e4a34458c6 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/startup-scripts.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/startup-scripts.md.hash @@ -1 +1 @@ -64202aee3cfbf5f0 +e864354927eee100 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/storing-data.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/storing-data.md index 7ffcc351986..a3892124dd2 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/storing-data.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/storing-data.md @@ -1,38 +1,48 @@ --- 'description': 'highlight-next-line 的文档' -'sidebar_label': '存储数据的外部磁盘' +'sidebar_label': '用于存储数据的外部磁盘' 'sidebar_position': 68 'slug': '/operations/storing-data' -'title': '存储数据的外部磁盘' +'title': '用于存储数据的外部磁盘' +'doc_type': 'guide' --- -在 ClickHouse 中处理的数据通常存储在本地文件系统中——在与 ClickHouse 服务器相同的机器上。这需要大容量的磁盘,这可能会很昂贵。为了避免这种情况,您可以远程存储数据。支持各种存储: +在 ClickHouse 中处理的数据通常存储在运行 ClickHouse 服务器的机器的本地文件系统中。这需要大容量的磁盘,这可能会很昂贵。为了避免本地存储数据,支持多种存储选项: 1. [Amazon S3](https://aws.amazon.com/s3/) 对象存储。 -2. [Azure Blob Storage](https://azure.microsoft.com/en-us/products/storage/blobs)。 +2. [Azure Blob 存储](https://azure.microsoft.com/en-us/products/storage/blobs)。 3. 不支持:Hadoop 分布式文件系统 ([HDFS](https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-hdfs/HdfsDesign.html)) -:::note ClickHouse 还支持外部表引擎,这与本页上描述的外部存储选项不同,因为它们允许读取以某种通用文件格式(如 Parquet)存储的数据,而在本页面中,我们描述的是 ClickHouse 的 `MergeTree` 系列或 `Log` 系列表的存储配置。 -1. 要与存储在 `Amazon S3` 磁盘上的数据进行交互,请使用 [S3](/engines/table-engines/integrations/s3.md) 表引擎。 -2. 要与存储在 Azure Blob Storage 中的数据进行交互,请使用 [AzureBlobStorage](/engines/table-engines/integrations/azureBlobStorage.md) 表引擎。 -3. 不支持:与存储在 Hadoop 分布式文件系统中的数据进行交互 — [HDFS](/engines/table-engines/integrations/hdfs.md) 表引擎。 -::: +
+ +:::note +ClickHouse 还支持外部表引擎,这与本页描述的外部存储选项不同,因为它们允许读取存储在某些通用文件格式(如 Parquet)中的数据。在本页上,我们描述 ClickHouse `MergeTree` 家族或 `Log` 家族表的存储配置。 +1. 使用存储在 `Amazon S3` 磁盘上的数据,请使用 [S3](/engines/table-engines/integrations/s3.md) 表引擎。 +2. 使用存储在 Azure Blob 存储中的数据,请使用 [AzureBlobStorage](/engines/table-engines/integrations/azureBlobStorage.md) 表引擎。 +3. 使用存储在 Hadoop 分布式文件系统中的数据(不支持),请使用 [HDFS](/engines/table-engines/integrations/hdfs.md) 表引擎。 +::: ## 配置外部存储 {#configuring-external-storage} -[MergeTree](/engines/table-engines/mergetree-family/mergetree.md) 和 [Log](/engines/table-engines/log-family/log.md) 系列表引擎可以将数据存储到 `S3`、`AzureBlobStorage`、`HDFS`(不支持)中,分别使用类型为 `s3`、`azure_blob_storage`、`hdfs`(不支持)的磁盘。 +[`MergeTree`](/engines/table-engines/mergetree-family/mergetree.md) 和 [`Log`](/engines/table-engines/log-family/log.md) +家族表引擎可以使用类型为 `s3`、`azure_blob_storage`、`hdfs`(不支持)的磁盘将数据存储到 `S3`、`AzureBlobStorage`、`HDFS`(不支持)。 磁盘配置要求: -1. `type` 区块,等于 `s3`、`azure_blob_storage`、`hdfs`(不支持)、`local_blob_storage`、`web` 中的一个。 + +1. 一个 `type` 部分,等于 `s3`、`azure_blob_storage`、`hdfs`(不支持)、`local_blob_storage`、`web` 之一。 2. 特定外部存储类型的配置。 -从 24.1 版本的 ClickHouse 开始,可以使用新的配置选项。 -需要指定: -1. `type` 等于 `object_storage` -2. `object_storage_type`,等于 `s3`、`azure_blob_storage`(或从 `24.3` 开始仅为 `azure`)、`hdfs`(不支持)、`local_blob_storage`(或从 `24.3` 开始仅为 `local`)、`web`。 -可选地,可以指定 `metadata_type`(默认等于 `local`),但它也可以设置为 `plain`、`web`,并且从 `24.4` 开始,可以设置为 `plain_rewritable`。 -使用 `plain` 元数据类型的描述请参见 [plain storage section](/operations/storing-data#plain-storage),`web` 元数据类型只能与 `web` 对象存储类型一起使用,`local` 元数据类型将元数据文件存储在本地(每个元数据文件包含映射到对象存储中的文件及其附加元信息)。 +从 24.1 版本的 clickhouse 开始,可能使用新的配置选项。 +它需要指定: + +1. 一个 `type` 等于 `object_storage` +2. `object_storage_type`,等于 `s3`、`azure_blob_storage`(或者从 `24.3` 开始只使用 `azure`)、`hdfs`(不支持)、`local_blob_storage`(或者从 `24.3` 开始只使用 `local`)、`web` 之一。 + +
+ +可选地,可以指定 `metadata_type`(默认等于 `local`),但也可以设置为 `plain`、`web`,而且从 `24.4` 开始,`plain_rewritable`。`plain` 元数据类型的使用在 [plain storage section](/operations/storing-data#plain-storage) 中描述,`web` 元数据类型仅可与 `web` 对象存储类型一起使用,`local` 元数据类型将元数据文件本地存储(每个元数据文件包含对对象存储中文件的映射和一些关于它们的附加元信息)。 + +例如: -例如,配置选项 ```xml s3 @@ -41,7 +51,8 @@ ``` -等于配置(来自 `24.1`): +等同于以下配置(来自 `24.1` 版本): + ```xml object_storage @@ -52,7 +63,8 @@ ``` -配置 +以下配置: + ```xml s3_plain @@ -61,7 +73,8 @@ ``` -等于 +等同于: + ```xml object_storage @@ -73,6 +86,7 @@ ``` 完整的存储配置示例如下: + ```xml @@ -96,7 +110,8 @@ ``` -从 24.1 版本的 ClickHouse 开始,它也可以如下所示: +从 24.1 版本开始,它也可以如下所示: + ```xml @@ -122,7 +137,8 @@ ``` -为了使特定类型的存储成为所有 `MergeTree` 表的默认选项,请将以下部分添加到配置文件中: +要使特定类型的存储成为所有 `MergeTree` 表的默认选项,请在配置文件中添加以下部分: + ```xml @@ -131,7 +147,7 @@ ``` -如果您想仅为特定表配置特定的存储策略,可以在创建表时在设置中定义它: +如果您想为特定表配置特定的存储策略,可以在创建表时通过设置定义它: ```sql CREATE TABLE test (a Int32, b String) @@ -139,19 +155,18 @@ ENGINE = MergeTree() ORDER BY a SETTINGS storage_policy = 's3'; ``` -您也可以使用 `disk` 代替 `storage_policy`。在这种情况下,配置文件中不需要有 `storage_policy` 区块,仅有 `disk` 区块就足够了。 +您还可以使用 `disk` 替代 `storage_policy`。在这种情况下,配置文件中不需要有 `storage_policy` 部分,`disk` 部分就足够了。 ```sql CREATE TABLE test (a Int32, b String) ENGINE = MergeTree() ORDER BY a SETTINGS disk = 's3'; ``` - ## 动态配置 {#dynamic-configuration} -还有一种可能性是在配置文件中指定存储配置,而无需预定义磁盘,但可以在 `CREATE`/`ATTACH` 查询设置中进行配置。 +还可以在配置文件中指定没有预定义磁盘的存储配置,但可以在 `CREATE`/`ATTACH` 查询设置中配置。 -以下示例查询基于上述动态磁盘配置并显示如何使用本地磁盘缓存存储在 URL 中的表数据。 +以下示例查询建立在以上动态磁盘配置的基础上,并展示如何使用本地磁盘缓存从 URL 存储的表中的数据。 ```sql ATTACH TABLE uk_price_paid UUID 'cf712b4f-2ca8-435c-ac23-c4393efe52f7' @@ -203,7 +218,7 @@ ATTACH TABLE uk_price_paid UUID 'cf712b4f-2ca8-435c-ac23-c4393efe52f7' ) ENGINE = MergeTree ORDER BY (postcode1, postcode2, addr1, addr2) - -- highlight-start +-- highlight-start SETTINGS disk = disk( type=cache, max_size='1Gi', @@ -213,16 +228,16 @@ ORDER BY (postcode1, postcode2, addr1, addr2) endpoint='https://raw.githubusercontent.com/ClickHouse/web-tables-demo/main/web/' ) ); - -- highlight-end +-- highlight-end ``` -在下面突出显示的设置中,请注意 `type=web` 的磁盘嵌套在 `type=cache` 的磁盘内。 +在下面突出显示的设置中,请注意类型为 `web` 的磁盘嵌套在类型为 `cache` 的磁盘内。 :::note -示例使用 `type=web`,但任何磁盘类型都可以被配置为动态,即使是本地磁盘。本地磁盘要求路径参数在服务器配置参数 `custom_local_disks_base_directory` 之内,该参数没有默认值,因此在使用本地磁盘时也要设置此参数。 +示例使用了 `type=web`,但任何磁盘类型都可以配置为动态,包括本地磁盘。本地磁盘需要一个路径参数,以便处于服务器配置参数 `custom_local_disks_base_directory` 内部,该参数没有默认值,因此在使用本地磁盘时也要设置此参数。 ::: -基于配置的配置和 SQL 定义的配置也是可能的: +基于配置的配置与 SQL 定义的配置也可行: ```sql ATTACH TABLE uk_price_paid UUID 'cf712b4f-2ca8-435c-ac23-c4393efe52f7' @@ -269,57 +284,59 @@ ORDER BY (postcode1, postcode2, addr1, addr2) ``` - ### 使用 S3 存储 {#s3-storage} - -必需参数: - -- `endpoint` — S3 端点 URL 以 `path` 或 `virtual hosted` [样式](https://docs.aws.amazon.com/AmazonS3/latest/dev/VirtualHosting.html)。端点 URL 应该包含一个存储数据的桶和根路径。 -- `access_key_id` — S3 访问密钥 ID。 -- `secret_access_key` — S3 秘密访问密钥。 - -可选参数: - -- `region` — S3 区域名称。 -- `support_batch_delete` — 它控制检查是否支持批量删除。当使用 Google Cloud Storage(GCS)时,将其设置为 `false`,因为 GCS 不支持批量删除,防止检查将防止日志中的错误消息。 -- `use_environment_credentials` — 如果存在,从环境变量 AWS_ACCESS_KEY_ID 和 AWS_SECRET_ACCESS_KEY 以及 AWS_SESSION_TOKEN 读取 AWS 凭据。默认值为 `false`。 -- `use_insecure_imds_request` — 如果设置为 `true`,S3 客户端将使用不安全的 IMDS 请求来获取来自 Amazon EC2 元数据的凭据。默认值为 `false`。 -- `expiration_window_seconds` — 检查基于过期的凭据是否过期的宽限期。可选,默认值为 `120`。 -- `proxy` — S3 端点的代理配置。`proxy` 块内的每个 `uri` 元素应包含一个代理 URL。 -- `connect_timeout_ms` — 套接字连接超时时间(毫秒)。默认值为 `10 秒`。 -- `request_timeout_ms` — 请求超时时间(毫秒)。默认值为 `5 秒`。 -- `retry_attempts` — 在请求失败时的重试次数。默认值为 `10`。 -- `single_read_retries` — 在读取过程中连接丢失时的重试次数。默认值为 `4`。 -- `min_bytes_for_seek` — 使用查找操作而非顺序读取的最小字节数。默认值为 `1 Mb`。 -- `metadata_path` — 在本地文件系统上存储 S3 元数据文件的路径。默认值为 `/var/lib/clickhouse/disks//`。 -- `skip_access_check` — 如果为 true,则不会在磁盘启动时执行磁盘访问检查。默认值为 `false`。 -- `header` — 向给定端点的请求中添加指定的 HTTP 头。可选,可以多次指定。 -- `server_side_encryption_customer_key_base64` — 如果指定,将设置访问带有 SSE-C 加密的 S3 对象所需的头。 -- `server_side_encryption_kms_key_id` - 如果指定,将设置访问带有 [SSE-KMS 加密](https://docs.aws.amazon.com/AmazonS3/latest/userguide/UsingKMSEncryption.html) 的 S3 对象所需的头。如果指定空字符串,将使用 AWS 管理的 S3 密钥。可选。 -- `server_side_encryption_kms_encryption_context` - 如果与 `server_side_encryption_kms_key_id` 一起指定,将为 SSE-KMS 设置给定的加密上下文头。可选。 -- `server_side_encryption_kms_bucket_key_enabled` - 如果与 `server_side_encryption_kms_key_id` 一起指定,将设置启用 SSE-KMS 的 S3 桶密钥的头。可选,值可以是 `true` 或 `false`,默认保持为空(符合桶级设置)。 -- `s3_max_put_rps` — 在节流之前的每秒最大 PUT 请求速率。默认值为 `0`(无限制)。 -- `s3_max_put_burst` — 在达到每秒请求限制之前,可以同时发出最大请求数。默认值(`0` 值)等于 `s3_max_put_rps`。 -- `s3_max_get_rps` — 节流之前的每秒最大 GET 请求速率。默认值为 `0`(无限制)。 -- `s3_max_get_burst` — 在达到每秒请求限制之前,可以同时发出最大请求数。默认值(`0` 值)等于 `s3_max_get_rps`。 -- `read_resource` — 用于 [调度](/operations/workload-scheduling.md) 此磁盘的读取请求的资源名称。默认值为空字符串(此磁盘未启用 IO 调度)。 -- `write_resource` — 用于 [调度](/operations/workload-scheduling.md) 此磁盘的写入请求的资源名称。默认值为空字符串(此磁盘未启用 IO 调度)。 -- `key_template` — 定义生成对象键的格式。默认情况下,Clickhouse 从 `endpoint` 选项中获取 `root path` 并添加随机生成的后缀。该后缀是具有 3 个随机符号的目录和一个 29 个随机符号的文件名。通过该选项,您可以完全控制对象键的生成方式。一些使用场景要求在对象键的前缀或中间包含随机符号。例如:`[a-z]{3}-prefix-random/constant-part/random-middle-[a-z]{3}/random-suffix-[a-z]{29}`。该值使用 [`re2`](https://github.com/google/re2/wiki/Syntax) 进行解析。仅支持该语法的某些子集。在使用该选项之前,检查您的首选格式是否被支持。如果 ClickHouse 无法根据 `key_template` 的值生成密钥,则磁盘不会初始化。它需要启用特性标志 [storage_metadata_write_full_object_key](/operations/storing-data#s3-storage)。它禁止在 `endpoint` 选项中声明 `root path`。需要定义选项 `key_compatibility_prefix`。 -- `key_compatibility_prefix` — 当使用选项 `key_template` 时,此选项是必需的。为了能够读取存储在元数据文件中的对象密钥,这些密钥的元数据版本低于 `VERSION_FULL_OBJECT_KEY`,应在此处设置 `endpoint` 选项中的先前 `root path`。 - +#### 必需参数 {#required-parameters-s3} + +| 参数 | 描述 | +|---------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `endpoint` | S3 端点 URL,采用 `path` 或 `virtual hosted` [样式](https://docs.aws.amazon.com/AmazonS3/latest/dev/VirtualHosting.html)。应包括存储数据的存储桶和根路径。 | +| `access_key_id` | 用于身份验证的 S3 访问密钥 ID。 | +| `secret_access_key` | 用于身份验证的 S3 秘密访问密钥。 | +#### 可选参数 {#optional-parameters-s3} + +| 参数 | 描述 | 默认值 | +|------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------| +| `region` | S3 区域名称。 | - | +| `support_batch_delete` | 控制是否检查批量删除支持。在使用 Google Cloud Storage (GCS) 时设置为 `false`,因为 GCS 不支持批量删除。 | `true` | +| `use_environment_credentials` | 从环境变量中读取 AWS 凭证:`AWS_ACCESS_KEY_ID`、`AWS_SECRET_ACCESS_KEY` 和 `AWS_SESSION_TOKEN`(如果存在)。 | `false` | +| `use_insecure_imds_request` | 如果为 `true`,在从 Amazon EC2 元数据获取凭证时使用不安全的 IMDS 请求。 | `false` | +| `expiration_window_seconds` | 检查基于到期的凭证是否已过期的宽限期(以秒为单位)。 | `120` | +| `proxy` | S3 端点的代理配置。`proxy` 块中的每个 `uri` 元素应包含一个代理 URL。 | - | +| `connect_timeout_ms` | 以毫秒为单位的套接字连接超时。 | `10000`(10秒) | +| `request_timeout_ms` | 以毫秒为单位的请求超时。 | `5000`(5秒) | +| `retry_attempts` | 失败请求的重试次数。 | `10` | +| `single_read_retries` | 在读取期间连接掉线的重试次数。 | `4` | +| `min_bytes_for_seek` | 使用跳过操作而不是顺序读取的最小字节数。 | `1 MB` | +| `metadata_path` | 用于存储 S3 元数据文件的本地文件系统路径。 | `/var/lib/clickhouse/disks//` | +| `skip_access_check` | 如果为 `true`,在启动期间跳过磁盘访问检查。 | `false` | +| `header` | 向请求添加指定的 HTTP 头。可以多次指定。 | - | +| `server_side_encryption_customer_key_base64` | 访问 S3 对象时需要的 SSE-C 加密的头。 | - | +| `server_side_encryption_kms_key_id` | 访问 S3 对象时需要的 [SSE-KMS 加密](https://docs.aws.amazon.com/AmazonS3/latest/userguide/UsingKMSEncryption.html) 的头。空字符串使用 AWS 管理的 S3 密钥。 | - | +| `server_side_encryption_kms_encryption_context` | SSE-KMS 的加密上下文头(与 `server_side_encryption_kms_key_id` 一起使用)。 | - | +| `server_side_encryption_kms_bucket_key_enabled` | 启用针对 SSE-KMS 的 S3 存储桶密钥(与 `server_side_encryption_kms_key_id` 一起使用)。 | 与存储桶级设置匹配 | +| `s3_max_put_rps` | 在限流之前每秒最大 PUT 请求数。 | `0`(无限制) | +| `s3_max_put_burst` | 在达到 RPS 限制之前同时最大 PUT 请求数。 | 与 `s3_max_put_rps` 相同 | +| `s3_max_get_rps` | 在限流之前每秒最大 GET 请求数。 | `0`(无限制) | +| `s3_max_get_burst` | 在达到 RPS 限制之前同时最大 GET 请求数。 | 与 `s3_max_get_rps` 相同 | +| `read_resource` | [调度](/operations/workload-scheduling.md) 读取请求的资源名称。 | 空字符串(禁用) | +| `write_resource` | [调度](/operations/workload-scheduling.md) 写入请求的资源名称。 | 空字符串(禁用) | +| `key_template` | 使用 [re2](https://github.com/google/re2/wiki/Syntax) 语法定义对象密钥生成格式。要求 `storage_metadata_write_full_object_key` 标志。不与 `endpoint` 中的 `root path` 兼容。要求 `key_compatibility_prefix`。 | - | +| `key_compatibility_prefix` | 必须与 `key_template` 一起使用。指定用于读取较旧元数据版本的 `endpoint` 中的先前 `root path`。 | - | +| `read_only` | 仅允许从磁盘读取。 | - | :::note -Google Cloud Storage (GCS) 也可以使用 `s3` 类型支持。请参见 [GCS 备份的 MergeTree](/integrations/gcs)。 +Google Cloud Storage (GCS) 也支持使用类型 `s3`。请参见 [基于 GCS 的 MergeTree](/integrations/gcs)。 ::: +### 使用简单存储 {#plain-storage} -### 使用 Plain 存储 {#plain-storage} - -在 `22.10` 中引入了新的磁盘类型 `s3_plain`,它提供了一次性写入存储。配置参数与 `s3` 磁盘类型相同。 -与 `s3` 磁盘类型不同,它以原样存储数据,例如,它使用正常文件名(与 ClickHouse 在本地磁盘上存储文件的方式相同),而不是随机生成的 blob 名称,并且不在本地存储任何元数据,例如,它是从 `s3` 中派生的。 +在 `22.10` 中引入了新的磁盘类型 `s3_plain`,提供了一次性写入存储。其配置参数与 `s3` 磁盘类型相同。 +与 `s3` 磁盘类型不同,它以原样存储数据。换句话说, +它使用正常的文件名(与 ClickHouse 在本地磁盘上存储文件的方式相同),并且不在本地存储任何元数据。例如,它源自 `s3` 上的数据。 -这种磁盘类型允许保留表的静态版本,因为它不允许对现有数据执行合并,也不允许插入新数据。 -这种磁盘类型的用例是在上面创建备份,可以通过 `BACKUP TABLE data TO Disk('plain_disk_name', 'backup_name')` 来完成。之后,您可以执行 `RESTORE TABLE data AS data_restored FROM Disk('plain_disk_name', 'backup_name')` 或使用 `ATTACH TABLE data (...) ENGINE = MergeTree() SETTINGS disk = 'plain_disk_name'`。 +这种磁盘类型允许保留表的静态版本,因为它不允许对现有数据执行合并,也不允许插入新数据。这种磁盘类型的用例是创建备份,可以通过 `BACKUP TABLE data TO Disk('plain_disk_name', 'backup_name')` 完成。随后,您可以执行 `RESTORE TABLE data AS data_restored FROM Disk('plain_disk_name', 'backup_name')` +或使用 `ATTACH TABLE data (...) ENGINE = MergeTree() SETTINGS disk = 'plain_disk_name'`。 配置: + ```xml s3_plain @@ -328,9 +345,10 @@ Google Cloud Storage (GCS) 也可以使用 `s3` 类型支持。请参见 [GCS ``` -从 `24.1` 开始,可以通过 `plain` 元数据类型配置任何对象存储磁盘(`s3`、`azure`、`hdfs`(不支持)、`local`)。 +从 `24.1` 开始,您可以使用 `plain` 元数据类型配置任何对象存储磁盘(`s3`、`azure`、`hdfs`(不支持)、`local`)。 配置: + ```xml object_storage @@ -340,17 +358,18 @@ Google Cloud Storage (GCS) 也可以使用 `s3` 类型支持。请参见 [GCS 1 ``` +### 使用 S3 可重写存储 {#s3-plain-rewritable-storage} -### 使用 S3 Plain 可重写存储 {#s3-plain-rewritable-storage} - -在 `24.4` 中引入了新的磁盘类型 `s3_plain_rewritable`。 -与 `s3_plain` 磁盘类型类似,它不需要额外的存储来存放元数据文件;相反,元数据存储在 S3 中。 -与 `s3_plain` 磁盘类型不同,`s3_plain_rewritable` 允许执行合并并支持 INSERT 操作。 +在 `24.4` 中引入了一种新的磁盘类型 `s3_plain_rewritable`。 +与 `s3_plain` 磁盘类型类似,它不需要额外的元数据文件存储。相反,元数据存储在 S3 中。 +与 `s3_plain` 磁盘类型不同,`s3_plain_rewritable` 允许执行合并 +并支持 `INSERT` 操作。 不支持表的 [Mutations](/sql-reference/statements/alter#mutations) 和复制。 -这种磁盘类型的用例是非复制的 `MergeTree` 表。尽管 `s3` 磁盘类型适用于非复制 MergeTree 表,但是如果您不需要表的本地元数据,并且愿意接受有限的操作集,则可以选择 `s3_plain_rewritable` 磁盘类型。例如,这对系统表可能是有用的。 +这种磁盘类型的用例是针对非复制的 `MergeTree` 表。尽管 `s3` 磁盘类型适合非复制的 `MergeTree` 表,但如果您不需要表的本地元数据并且愿意接受有限的操作集,则可以选择 `s3_plain_rewritable` 磁盘类型。这可能对系统表等非常有用。 配置: + ```xml s3_plain_rewritable @@ -359,7 +378,8 @@ Google Cloud Storage (GCS) 也可以使用 `s3` 类型支持。请参见 [GCS ``` -等于 +等价于 + ```xml object_storage @@ -370,13 +390,13 @@ Google Cloud Storage (GCS) 也可以使用 `s3` 类型支持。请参见 [GCS ``` -从 `24.5` 开始,可以使用 `plain_rewritable` 元数据类型配置任何对象存储磁盘(`s3`、`azure`、`local`)。 - -### 使用 Azure Blob Storage {#azure-blob-storage} +从 `24.5` 开始,您可以使用 `plain_rewritable` 元数据类型配置任何对象存储磁盘(`s3`、`azure`、`local`)。 +### 使用 Azure Blob 存储 {#azure-blob-storage} -`MergeTree` 系列表引擎可以使用类型为 `azure_blob_storage` 的磁盘将数据存储到 [Azure Blob Storage](https://azure.microsoft.com/en-us/services/storage/blobs/) 中。 +`MergeTree` 家族表引擎可以使用类型为 `azure_blob_storage` 的磁盘将数据存储到 [Azure Blob 存储](https://azure.microsoft.com/en-us/services/storage/blobs/)。 配置标记: + ```xml ... @@ -395,44 +415,53 @@ Google Cloud Storage (GCS) 也可以使用 `s3` 类型支持。请参见 [GCS ... ``` - -连接参数: -* `storage_account_url` - **必需**,Azure Blob Storage 账户 URL,如 `http://account.blob.core.windows.net` 或 `http://azurite1:10000/devstoreaccount1`。 -* `container_name` - 目标容器名称,默认为 `default-container`。 -* `container_already_exists` - 如果设置为 `false`,则在存储账户中创建新的容器 `container_name`;如果设置为 `true`,则磁盘直接连接到容器;如果未设置,则磁盘连接到账户,检查容器 `container_name` 是否存在,如果尚不存在,则创建它。 - -身份验证参数(磁盘将尝试所有可用方法 **和** 管理身份凭证): -* `connection_string` - 通过连接字符串进行身份验证。 -* `account_name` 和 `account_key` - 通过共享密钥进行身份验证。 - -限制参数(主要用于内部使用): -* `s3_max_single_part_upload_size` - 限制单个块上传到 Blob Storage 的大小。 -* `min_bytes_for_seek` - 限制可搜索区域的大小。 -* `max_single_read_retries` - 限制从 Blob Storage 读取数据块的尝试次数。 -* `max_single_download_retries` - 限制从 Blob Storage 下载可读取缓冲区的尝试次数。 -* `thread_pool_size` - 限制 `IDiskRemote` 实例化的线程数量。 -* `s3_max_inflight_parts_for_one_file` - 限制可以同时运行的单个对象的 PUT 请求数量。 - -其他参数: -* `metadata_path` - 在本地文件系统上存储 Blob Storage 元数据文件的路径。默认值为 `/var/lib/clickhouse/disks//`。 -* `skip_access_check` - 如果为 true,则不会在磁盘启动时执行磁盘访问检查。默认值为 `false`。 -* `read_resource` — 用于 [调度](/operations/workload-scheduling.md) 此磁盘的读取请求的资源名称。默认值为空字符串(此磁盘未启用 IO 调度)。 -* `write_resource` — 用于 [调度](/operations/workload-scheduling.md) 此磁盘的写入请求的资源名称。默认值为空字符串(此磁盘未启用 IO 调度)。 -* `metadata_keep_free_space_bytes` - 要保留的免费元数据磁盘空间的数量。 - -工作配置的示例可以在集成测试目录中找到(例如,请参阅 [test_merge_tree_azure_blob_storage](https://github.com/ClickHouse/ClickHouse/blob/master/tests/integration/test_merge_tree_azure_blob_storage/configs/config.d/storage_conf.xml) 或 [test_azure_blob_storage_zero_copy_replication](https://github.com/ClickHouse/ClickHouse/blob/master/tests/integration/test_azure_blob_storage_zero_copy_replication/configs/config.d/storage_conf.xml))。 - -:::note 零拷贝复制尚未准备好投入生产 -在 ClickHouse 版本 22.8 及更高版本中,默认情况下禁用零拷贝复制。 不建议在生产中使用此功能。 +#### 连接参数 {#azure-blob-storage-connection-parameters} + +| 参数 | 描述 | 默认值 | +|----------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------| +| `storage_account_url`(必需) | Azure Blob 存储帐户 URL。例如:`http://account.blob.core.windows.net` 或 `http://azurite1:10000/devstoreaccount1`。 | - | +| `container_name` | 目标容器名称。 | `default-container` | +| `container_already_exists` | 控制容器创建行为:
- `false`:创建新容器
- `true`:直接连接到现有容器
- 未设置:检查容器是否存在,如有必要则创建 | - | + +身份验证参数(磁盘将尝试所有可用方法 **和** 托管身份凭证): + +| 参数 | 描述 | +|-------------------|-------------------------------------------| +| `connection_string` | 用于通过连接字符串进行身份验证。 | +| `account_name` | 用于通过共享密钥进行身份验证(与 `account_key` 一起使用)。 | +| `account_key` | 用于通过共享密钥进行身份验证(与 `account_name` 一起使用)。 | +#### 限制参数 {#azure-blob-storage-limit-parameters} + +| 参数 | 描述 | +|--------------------------------------|-----------------------------------------------------------------------| +| `s3_max_single_part_upload_size` | 上传到 Blob 存储的单个块的最大大小。 | +| `min_bytes_for_seek` | 可寻址区域的最小大小。 | +| `max_single_read_retries` | 从 Blob 存储读取数据块的最大尝试次数。 | +| `max_single_download_retries` | 从 Blob 存储下载可读缓冲区的最大尝试次数。 | +| `thread_pool_size` | 用于 `IDiskRemote` 实例化的最大线程数。 | +| `s3_max_inflight_parts_for_one_file` | 单个对象的最大并发 PUT 请求数。 | +#### 其他参数 {#azure-blob-storage-other-parameters} + +| 参数 | 描述 | 默认值 | +|-------------------------------------|---------------------------------------------------------------------|------------------------------------------| +| `metadata_path` | 用于存储 Blob 存储元数据文件的本地文件系统路径。 | `/var/lib/clickhouse/disks//` | +| `skip_access_check` | 如果为 `true`,在启动时跳过磁盘访问检查。 | `false` | +| `read_resource` | [调度](/operations/workload-scheduling.md) 读取请求的资源名称。 | 空字符串(禁用) | +| `write_resource` | [调度](/operations/workload-scheduling.md) 写入请求的资源名称。 | 空字符串(禁用) | +| `metadata_keep_free_space_bytes` | 要保留的自由元数据磁盘空间量。 | - | + +可以在集成测试目录中找到工作配置的示例(例如,查看 [test_merge_tree_azure_blob_storage](https://github.com/ClickHouse/ClickHouse/blob/master/tests/integration/test_merge_tree_azure_blob_storage/configs/config.d/storage_conf.xml) 或 [test_azure_blob_storage_zero_copy_replication](https://github.com/ClickHouse/ClickHouse/blob/master/tests/integration/test_azure_blob_storage_zero_copy_replication/configs/config.d/storage_conf.xml))。 + +:::note 零拷贝复制尚未准备好用于生产 +在 ClickHouse 版本 22.8 及更高版本中,默认情况下禁用零拷贝复制。建议不要在生产中使用此功能。 ::: - ## 使用 HDFS 存储(不支持) {#using-hdfs-storage-unsupported} 在此示例配置中: - 磁盘类型为 `hdfs`(不支持) -- 数据位于 `hdfs://hdfs1:9000/clickhouse/` +- 数据托管在 `hdfs://hdfs1:9000/clickhouse/` -顺便说一句,HDFS 不受支持,因此使用它时可能会遇到问题。如果出现任何问题,请随时提交拉取请求进行修复。 +顺便说一下,HDFS 不受支持,因此在使用它时可能会出现问题。如果有任何问题,请随时提交拉取请求进行修复。 ```xml @@ -464,13 +493,12 @@ Google Cloud Storage (GCS) 也可以使用 `s3` 类型支持。请参见 [GCS ``` -请记住,HDFS 可能在某些极端情况下无法正常工作。 - +请注意,HDFS 在某些边缘情况下可能会出现故障。 ### 使用数据加密 {#encrypted-virtual-file-system} -您可以加密存储在 [S3](/engines/table-engines/mergetree-family/mergetree.md/#table_engine-mergetree-s3) 或 [HDFS](#using-hdfs-storage-unsupported)(不支持)外部磁盘上的数据,或在本地磁盘上。要启用加密模式,在配置文件中必须定义一个类型为 `encrypted` 的磁盘,并选择一个将保存数据的磁盘。`encrypted` 磁盘会对所有写入的文件进行动态加密,当您从 `encrypted` 磁盘读取文件时,它会自动解密。因此,您可以像使用普通磁盘一样使用 `encrypted` 磁盘。 +您可以加密存储在 [S3](/engines/table-engines/mergetree-family/mergetree.md/#table_engine-mergetree-s3) 或 [HDFS](#using-hdfs-storage-unsupported)(不支持)外部磁盘上的数据,或在本地磁盘上加密数据。要启用加密模式,您必须在配置文件中定义类型为 `encrypted` 的磁盘,并选择将保存数据的磁盘。`encrypted` 磁盘会实时对所有写入的文件进行加密,当您从 `encrypted` 磁盘读取文件时,它会自动解密。因此,您可以像使用普通磁盘一样使用 `encrypted` 磁盘。 -磁盘配置示例: +以下是磁盘配置的示例: ```xml @@ -487,22 +515,23 @@ Google Cloud Storage (GCS) 也可以使用 `s3` 类型支持。请参见 [GCS ``` -例如,当 ClickHouse 将某个表中的数据写入 `store/all_1_1_0/data.bin` 到 `disk1` 时,实际上该文件将沿路径 `/path1/store/all_1_1_0/data.bin` 写入物理磁盘。 - -当将同一文件写入 `disk2` 时,它实际上将以加密模式写入位于物理磁盘路径 `/path1/path2/store/all_1_1_0/data.bin` 的物理磁盘。 - -必需参数: +例如,当 ClickHouse 将某个表的数据写入文件 `store/all_1_1_0/data.bin` 到 `disk1` 时,实际上该文件将写入到物理磁盘路径 `/path1/store/all_1_1_0/data.bin`。 -- `type` — `encrypted`。否则将不会创建加密磁盘。 -- `disk` — 数据存储的磁盘类型。 -- `key` — 用于加密和解密的密钥。类型:[Uint64](/sql-reference/data-types/int-uint.md)。您可以使用 `key_hex` 参数将密钥编码为十六进制形式。 - 您可以使用 `id` 属性指定多个密钥(请参见下面的示例)。 +将同一文件写入 `disk2` 时,它实际上将以加密模式写入物理磁盘路径 `/path1/path2/store/all_1_1_0/data.bin`。 +### 必需参数 {#required-parameters-encrypted-disk} -可选参数: +| 参数 | 类型 | 描述 | +|---------------|----------|-------------------------------------------------------------------------------------------------------------------------------------| +| `type` | 字符串 | 必须设置为 `encrypted` 以创建加密磁盘。 | +| `disk` | 字符串 | 用于底层存储的磁盘类型。 | +| `key` | Uint64 | 用于加密和解密的密钥。可以使用 `key_hex` 以十六进制给出。可以通过 `id` 属性指定多个密钥。 | +### 可选参数 {#optional-parameters-encrypted-disk} -- `path` — 在磁盘上保存数据的位置的路径。如果未指定,则数据将保存在根目录中。 -- `current_key_id` — 用于加密的密钥。所有指定的密钥可用于解密,您始终可以在访问以前加密的数据时切换到另一个密钥。 -- `algorithm` — [算法](/sql-reference/statements/create/table#encryption-codecs) 用于加密。可能的值有:`AES_128_CTR`、`AES_192_CTR` 或 `AES_256_CTR`。默认值:`AES_128_CTR`。密钥长度取决于算法:`AES_128_CTR` — 16 字节,`AES_192_CTR` — 24 字节,`AES_256_CTR` — 32 字节。 +| 参数 | 类型 | 默认值 | 描述 | +|-----------------------|----------|---------------|------------------------------------------------------------------------------------------------------------------------------------| +| `path` | 字符串 | 根目录 | 将保存数据的磁盘上的位置。 | +| `current_key_id` | 字符串 | - | 用于加密的密钥 ID。所有指定的密钥都可以用于解密。 | +| `algorithm` | 枚举 | `AES_128_CTR` | 加密算法。选项:
- `AES_128_CTR`(16 字节密钥)
- `AES_192_CTR`(24 字节密钥)
- `AES_256_CTR`(32 字节密钥) | 磁盘配置示例: @@ -526,15 +555,14 @@ Google Cloud Storage (GCS) 也可以使用 `s3` 类型支持。请参见 [GCS ``` - ### 使用本地缓存 {#using-local-cache} -从版本 22.3 开始,可以在存储配置中配置本地缓存。 -在 22.3 - 22.7 版本中,仅支持 `s3` 磁盘类型的缓存。在版本 >= 22.8 中,任何磁盘类型均支持缓存:S3、Azure、本地、加密等。 -在版本 >= 23.5 中,仅支持远程磁盘类型的缓存:S3、Azure、HDFS(不支持)。 +从版本 22.3 开始,可以在存储配置中配置磁盘上的本地缓存。 +在版本 22.3 - 22.7 中,缓存仅支持 `s3` 磁盘类型。对于版本 >= 22.8,缓存支持任何磁盘类型:S3、Azure、本地、加密等。 +对于版本 >= 23.5,缓存仅支持远程磁盘类型:S3、Azure、HDFS(不支持)。 缓存使用 `LRU` 缓存策略。 -对于版本 22.8 及更高版本的配置示例: +版本 22.8 及以上的配置示例: ```xml @@ -564,7 +592,7 @@ Google Cloud Storage (GCS) 也可以使用 `s3` 类型支持。请参见 [GCS ``` -对于版本早于 22.8 的配置示例: +版本 22.8 以下的配置示例: ```xml @@ -592,113 +620,92 @@ Google Cloud Storage (GCS) 也可以使用 `s3` 类型支持。请参见 [GCS 文件缓存 **磁盘配置设置**: -这些设置应在磁盘配置部分中定义。 - -- `path` - 缓存目录的路径。默认:无,此设置为强制性。 - -- `max_size` - 缓存的最大大小(以字节或可读格式),例如 `ki,Mi,Gi 等`,示例 `10Gi`(此格式从 `22.10` 版本开始工作)。当达到限制时,缓存文件将根据缓存逐出策略被逐出。默认:无,此设置为强制性。 - -- `cache_on_write_operations` - 允许启用 `write-through` 缓存(在任何写入操作时缓存数据:`INSERT` 查询、后台合并)。默认:`false`。通过设置在查询中禁用 `write-through` 缓存设置 `enable_filesystem_cache_on_write_operations`(仅在启用了缓存配置设置和相应查询设置时,数据才会被缓存)。 - -- `enable_filesystem_query_cache_limit` - 允许限制在每个查询中下载的缓存大小(取决于用户设置 `max_query_cache_size`)。默认:`false`。 - -- `enable_cache_hits_threshold` - 定义某些数据需要读取多少次后才会被缓存的数字。默认:`false`。您可以通过 `cache_hits_threshold` 定义此阈值。默认值:0,例如数据在第一次读取尝试时被缓存。 - -- `enable_bypass_cache_with_threshold` - 允许在请求的读取范围超过阈值时完全跳过缓存。默认:`false`。此阈值可以由 `bypass_cache_threashold` 定义。默认值:268435456(`256Mi`)。 - -- `max_file_segment_size` - 单个缓存文件的最大大小(以字节或可读格式(`ki、Mi、Gi 等`,示例 `10Gi`)。默认:8388608(`8Mi`)。 - -- `max_elements` - 缓存文件数量的限制。默认:10000000。 - -- `load_metadata_threads` - 启动时用于加载缓存元数据的线程数量。默认:16。 - -文件缓存 **查询/配置文件设置**: - -其中一些设置将在查询/配置文件中禁用默认启用的缓存功能。例如,您可以在磁盘配置中启用缓存并在查询/配置文件设置 `enable_filesystem_cache` 下将其禁用为 `false`。此外,如果将磁盘配置中的 `cache_on_write_operations` 设置为 `true`,则表示启用了 "写穿" 缓存。但如果您需要在特定查询中禁用此总体设置,则将设置 `enable_filesystem_cache_on_write_operations` 设置为 `false` 意味着将为特定查询/配置文件禁用写操作缓存。 - -- `enable_filesystem_cache` - 允许在查询中禁用缓存,即使存储策略已配置为 `cache` 磁盘类型。默认:`true`。 - -- `read_from_filesystem_cache_if_exists_otherwise_bypass_cache` - 允许在查询中仅使用缓存(如果缓存已存在),否则查询数据将不会写入本地缓存存储。默认:`false`。 - -- `enable_filesystem_cache_on_write_operations` - 启用 `write-through` 缓存。此设置仅在缓存配置中启用了 `cache_on_write_operations` 设置时有效。默认:`false`。云默认值:`true`。 - -- `enable_filesystem_cache_log` - 启用记录到 `system.filesystem_cache_log` 表。提供查询的缓存使用的详细视图。可以针对特定查询启用或在配置文件中启用。默认:`false`。 - -- `max_query_cache_size` - 限制可以写入本地缓存存储的缓存大小。需要在缓存配置中启用 `enable_filesystem_query_cache_limit`。默认:`false`。 - -- `skip_download_if_exceeds_query_cache` - 允许更改 `max_query_cache_size` 设置的行为。默认:`true`。如果打开此设置,在查询期间达到缓存下载限制,则不会再下载缓存到缓存存储。如果关闭此设置,在查询期间达到缓存下载限制后,缓存仍将通过逐出当前查询内先前下载的数据的成本进行写入,例如,第二种行为允许在保持查询缓存限制的同时保持 `最近最少使用` 的行为。 - -**警告** -缓存配置设置和缓存查询设置对应于最新的 ClickHouse 版本,对于早期版本可能不支持某些功能。 - -缓存 **系统表**: - -- `system.filesystem_cache` - 显示缓存当前状态的系统表。 - -- `system.filesystem_cache_log` - 显示每个查询详细的缓存使用情况的系统表。需要将 `enable_filesystem_cache_log` 设置为 `true`。 +这些设置应在磁盘配置部分定义。 + +| 参数 | 类型 | 默认值 | 描述 | +|----------------------------------------|---------|------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `path` | 字符串 | - | **必需**。缓存将存储在的目录路径。 | +| `max_size` | 大小 | - | **必需**。最大缓存大小,以字节或可读格式(例如, `10Gi`)。当达到限制时,文件将使用 LRU 策略驱逐。支持 `ki`、`Mi`、`Gi` 格式(自 v22.10 起)。 | +| `cache_on_write_operations` | 布尔值 | `false` | 为 `INSERT` 查询和后台合并启用写通过缓存。可以通过 `enable_filesystem_cache_on_write_operations` per 查询覆盖。 | +| `enable_filesystem_query_cache_limit` | 布尔值 | `false` | 启用基于 `max_query_cache_size` 的每查询缓存大小限制。 | +| `enable_cache_hits_threshold` | 布尔值 | `false` | 启用后,数据仅在被读取多次后被缓存。 | +| `cache_hits_threshold` | 整数 | `0` | 缓存数据所需的读取次数(需要 `enable_cache_hits_threshold`)。 | +| `enable_bypass_cache_with_threshold` | 布尔值 | `false` | 跳过大型读取范围的缓存。 | +| `bypass_cache_threshold` | 大小 | `256Mi` | 触发缓存绕过的读取范围大小(需要 `enable_bypass_cache_with_threshold`)。 | +| `max_file_segment_size` | 大小 | `8Mi` | 单个缓存文件的最大大小,以字节或可读格式。 | +| `max_elements` | 整数 | `10000000` | 最大缓存文件数量。 | +| `load_metadata_threads` | 整数 | `16` | 启动时加载缓存元数据的线程数。 | + +> **注意**:大小值支持 `ki`、`Mi`、`Gi` 等单位(例如, `10Gi`)。 +## 文件缓存查询/配置设置 {#file-cache-query-profile-settings} + +| 设置 | 类型 | 默认值 | 描述 | +|-----------------------------------------------------------|---------|-------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------| +| `enable_filesystem_cache` | 布尔值 | `true` | 每个查询启用/禁用缓存使用,即使使用 `cache` 磁盘类型。 | +| `read_from_filesystem_cache_if_exists_otherwise_bypass_cache` | 布尔值 | `false` | 启用时,仅在数据存在时使用缓存;新数据不会被缓存。 | +| `enable_filesystem_cache_on_write_operations` | 布尔值 | `false`(云:`true`) | 启用写通过缓存。需要缓存配置中设置 `cache_on_write_operations`。 | +| `enable_filesystem_cache_log` | 布尔值 | `false` | 启用详细的缓存使用日志记录到 `system.filesystem_cache_log`。 | +| `max_query_cache_size` | 大小 | `false` | 每查询的最大缓存大小。需要缓存配置中设置 `enable_filesystem_query_cache_limit`。 | +| `skip_download_if_exceeds_query_cache` | 布尔值 | `true` | 控制达到 `max_query_cache_size` 时的行为:
- `true`:停止下载新数据
- `false`:驱逐旧数据以为新数据腾出空间 | + +:::warning +缓存配置设置和缓存查询设置与最新的 ClickHouse 版本对应,对于早期版本可能不被支持。 +::: +#### 缓存系统表 {#cache-system-tables-file-cache} -缓存 **命令**: +| 表名 | 描述 | 要求 | +|---------------------------|--------------------------------------------------|-----------------------------------------| +| `system.filesystem_cache` | 显示当前文件系统缓存的状态。 | 无 | +| `system.filesystem_cache_log` | 提供每个查询的详细缓存使用统计信息。 | 需要 `enable_filesystem_cache_log = true` | +#### 缓存命令 {#cache-commands-file-cache} +##### `SYSTEM DROP FILESYSTEM CACHE () (ON CLUSTER)` -- `ON CLUSTER` {#system-drop-filesystem-cache-on-cluster} -- `SYSTEM DROP FILESYSTEM CACHE () (ON CLUSTER)` -- 仅在不提供 `` 时支持 `ON CLUSTER` +此命令仅在未提供 `` 时支持。 +##### `SHOW FILESYSTEM CACHES` {#show-filesystem-caches} -- `SHOW FILESYSTEM CACHES` -- 显示服务器上配置的文件系统缓存列表。(对于版本小于或等于 `22.8` 的命令名为 `SHOW CACHES`) +显示在服务器上配置的文件系统缓存列表。 +(对于版本小于或等于 `22.8`,该命令命名为 `SHOW CACHES`) -```sql +```sql title="Query" SHOW FILESYSTEM CACHES ``` -结果: - -```text +```text title="Response" ┌─Caches────┐ │ s3_cache │ └───────────┘ ``` +##### `DESCRIBE FILESYSTEM CACHE ''` {#describe-filesystem-cache} -- `DESCRIBE FILESYSTEM CACHE ''` - 显示特定缓存的缓存配置和一些一般统计信息。可以从 `SHOW FILESYSTEM CACHES` 命令中获取缓存名称。(对于版本小于或等于 `22.8` 的命令名为 `DESCRIBE CACHE`) +显示特定缓存的缓存配置及一些常规统计信息。 +缓存名称可以通过 `SHOW FILESYSTEM CACHES` 命令获取。(对于版本小于或等于 `22.8`,该命令命名为 `DESCRIBE CACHE`) -```sql +```sql title="Query" DESCRIBE FILESYSTEM CACHE 's3_cache' ``` -```text +```text title="Response" ┌────max_size─┬─max_elements─┬─max_file_segment_size─┬─boundary_alignment─┬─cache_on_write_operations─┬─cache_hits_threshold─┬─current_size─┬─current_elements─┬─path───────┬─background_download_threads─┬─enable_bypass_cache_with_threshold─┐ │ 10000000000 │ 1048576 │ 104857600 │ 4194304 │ 1 │ 0 │ 3276 │ 54 │ /s3_cache/ │ 2 │ 0 │ └─────────────┴──────────────┴───────────────────────┴────────────────────┴───────────────────────────┴──────────────────────┴──────────────┴──────────────────┴────────────┴─────────────────────────────┴────────────────────────────────────┘ ``` -缓存当前指标: - -- `FilesystemCacheSize` - -- `FilesystemCacheElements` - -缓存异步指标: - -- `FilesystemCacheBytes` - -- `FilesystemCacheFiles` - -缓存配置文件事件: - -- `CachedReadBufferReadFromSourceBytes`、`CachedReadBufferReadFromCacheBytes` - -- `CachedReadBufferReadFromSourceMicroseconds`、`CachedReadBufferReadFromCacheMicroseconds` - -- `CachedReadBufferCacheWriteBytes`、`CachedReadBufferCacheWriteMicroseconds` - -- `CachedWriteBufferCacheWriteBytes`、`CachedWriteBufferCacheWriteMicroseconds` - +| 当前缓存指标 | 异步缓存指标 | 缓存配置事件 | +|-----------------------|------------------------|------------------------------------------------------------------------| +| `FilesystemCacheSize` | `FilesystemCacheBytes` | `CachedReadBufferReadFromSourceBytes`, `CachedReadBufferReadFromCacheBytes` | +| `FilesystemCacheElements` | `FilesystemCacheFiles` | `CachedReadBufferReadFromSourceMicroseconds`, `CachedReadBufferReadFromCacheMicroseconds` | +| | | `CachedReadBufferCacheWriteBytes`, `CachedReadBufferCacheWriteMicroseconds` | +| | | `CachedWriteBufferCacheWriteBytes`, `CachedWriteBufferCacheWriteMicroseconds` | ### 使用静态 Web 存储(只读) {#web-storage} -这是一个只读磁盘。其数据仅被读取且从未修改。通过 `ATTACH TABLE` 查询将新表加载到此磁盘中(见以下示例)。实际上不使用本地磁盘,每个 `SELECT` 查询将导致发出 `http` 请求以获取所需数据。表数据的所有修改都将引发异常,即〜,以下类型的查询是不允许的:[CREATE TABLE](/sql-reference/statements/create/table.md)、[ALTER TABLE](/sql-reference/statements/alter/index.md)、[RENAME TABLE](/sql-reference/statements/rename#rename-table)、[DETACH TABLE](/sql-reference/statements/detach.md)和 [TRUNCATE TABLE](/sql-reference/statements/truncate.md)。 -Web 存储可用于只读目的。一个示例用法是用于托管示例数据或迁移数据。 -有一个工具 `clickhouse-static-files-uploader`,它为给定表准备数据目录(`SELECT data_paths FROM system.tables WHERE name = 'table_name'`)。对于您需要的每个表,您将获得一个文件目录。这些文件可以上传到例如静态文件的 Web 服务器。经过此准备,您可以通过 `DiskWeb` 将此表加载到任何 ClickHouse 服务器中。 +这是一个只读磁盘。其数据仅被读取而从未被修改。通过 `ATTACH TABLE` 查询将新表加载到此磁盘中(见下例)。实际上不使用本地磁盘,每个 `SELECT` 查询将导致执行 `http` 请求以获取所需数据。对表数据的所有修改都会导致异常,即不允许以下类型的查询:[`CREATE TABLE`](/sql-reference/statements/create/table.md), [`ALTER TABLE`](/sql-reference/statements/alter/index.md), [`RENAME TABLE`](/sql-reference/statements/rename#rename-table), [`DETACH TABLE`](/sql-reference/statements/detach.md) 和 [`TRUNCATE TABLE`](/sql-reference/statements/truncate.md)。 +Web 存储可用于只读目的。一个示例用法是托管示例数据或用于迁移数据。这里有一个工具 `clickhouse-static-files-uploader`,用于为给定表准备数据目录(`SELECT data_paths FROM system.tables WHERE name = 'table_name'`)。 +对于您需要的每个表,您将获得一个文件目录。这些文件可以上传到例如静态文件的 Web 服务器。在此准备工作后,您可以通过 `DiskWeb` 将此表加载到任何 ClickHouse 服务器。 在此示例配置中: - 磁盘类型为 `web` -- 数据托管在 `http://nginx:80/test1/` -- 使用了本地存储的缓存 +- 数据托管在 `http://nginx:80/test1/` +- 使用本地存储的缓存 ```xml @@ -736,14 +743,12 @@ Web 存储可用于只读目的。一个示例用法是用于托管示例数据 ``` :::tip -如果不期望 Web 数据集被常规使用,则可以在查询中暂时配置存储,请参阅 [动态配置](#dynamic-configuration) 并跳过编辑配置文件。 -::: +如果不预期经常使用 Web 数据集,可以在查询中临时配置存储,参见 [动态配置](#dynamic-configuration),跳过编辑配置文件。 -:::tip -一个 [演示数据集](https://github.com/ClickHouse/web-tables-demo) 被托管在 GitHub 上。要为 Web 存储准备您自己的表,请参阅工具 [clickhouse-static-files-uploader](/operations/utilities/static-files-disk-uploader) +在 GitHub 上托管了一个 [演示数据集](https://github.com/ClickHouse/web-tables-demo)。要为 Web 存储准备自己的表,请参见工具 [clickhouse-static-files-uploader](/operations/utilities/static-files-disk-uploader)。 ::: -在这个 `ATTACH TABLE` 查询中,提供的 `UUID` 与数据的目录名称匹配,端点是原始 GitHub 内容的 URL。 +在此 `ATTACH TABLE` 查询中提供的 `UUID` 与数据的目录名称匹配,端点是原始 GitHub 内容的 URL。 ```sql -- highlight-next-line @@ -774,7 +779,7 @@ ORDER BY (postcode1, postcode2, addr1, addr2) -- highlight-end ``` -一个准备好的测试用例。您需要向配置中添加此配置: +一个准备好的测试用例。您需要将此配置添加到配置中: ```xml @@ -944,33 +949,34 @@ ORDER BY (CounterID, EventDate, intHash32(UserID)) SAMPLE BY intHash32(UserID) SETTINGS storage_policy='web'; ``` +#### 必需参数 {#static-web-storage-required-parameters} -必需参数: - -- `type` — `web`。否则将不会创建磁盘。 -- `endpoint` — 以 `path` 格式给出的端点 URL。端点 URL 必须包含用于存储数据的根路径,即这些数据被上传的路径。 - -可选参数: - -- `min_bytes_for_seek` — 使用查找操作而非顺序读取的最小字节数。默认值:`1` Mb。 -- `remote_fs_read_backoff_threashold` — 尝试读取远程磁盘数据时的最大等待时间。默认值:`10000` 秒。 -- `remote_fs_read_backoff_max_tries` — 以退避方式读取的最大尝试次数。默认值:`5`。 +| 参数 | 描述 | +|-----------|--------------------------------------------------------------------------------------------------------------------| +| `type` | `web`。否则不会创建磁盘。 | +| `endpoint`| 以 `path` 格式给出的端点 URL。端点 URL 必须包含存储数据的根路径,即它们上传的位置。 | +#### 可选参数 {#optional-parameters-web} -如果查询因异常 `DB:Exception Unreachable URL` 失败,则可以尝试调整设置:[http_connection_timeout](/operations/settings/settings.md/#http_connection_timeout)、[http_receive_timeout](/operations/settings/settings.md/#http_receive_timeout)、[keep_alive_timeout](/operations/server-configuration-parameters/settings#keep_alive_timeout)。 +| 参数 | 描述 | 默认值 | +|---------------------------------------|-----------------------------------------------------------------------|--------------| +| `min_bytes_for_seek` | 使用随机读取操作所需的最小字节数 | `1` MB | +| `remote_fs_read_backoff_threashold` | 尝试从远程磁盘读取数据时的最大等待时间 | `10000` 秒 | +| `remote_fs_read_backoff_max_tries` | 读取时的最大重试次数 | `5` | -要获取上传的文件,请运行: -`clickhouse static-files-disk-uploader --metadata-path --output-dir
`(`--metadata-path` 可在查询 `SELECT data_paths FROM system.tables WHERE name = 'table_name'` 中找到)。 +如果查询失败并出现异常 `DB:Exception Unreachable URL`,则可以尝试调整设置:[http_connection_timeout](/operations/settings/settings.md/#http_connection_timeout)、[http_receive_timeout](/operations/settings/settings.md/#http_receive_timeout)、[keep_alive_timeout](/operations/server-configuration-parameters/settings#keep_alive_timeout)。 -通过 `endpoint` 加载文件时,必须加载到 `/store/` 路径,但配置中只能包含 `endpoint`。 +要获取要上传的文件,请运行: +`clickhouse static-files-disk-uploader --metadata-path --output-dir `(`--metadata-path` 可以在查询中找到 `SELECT data_paths FROM system.tables WHERE name = 'table_name'`)。 -如果当服务器启动表时无法访问磁盘加载的 URL,则会捕获所有错误。如果在这种情况下发生错误,则可以通过 `DETACH TABLE table_name` -> `ATTACH TABLE table_name` 重新加载表(使其可见)。如果在服务器启动时成功加载了元数据,则表将立即可用。 +通过 `endpoint` 加载文件时,必须加载到 `/store/` 路径中,但配置中只需包含 `endpoint`。 -使用 [http_max_single_read_retries](/operations/storing-data#web-storage) 设置限制在单次 HTTP 读取期间的最大重试次数。 +如果在服务器启动表时加载到磁盘时 URL 无法访问,则所有错误都将被捕获。如果在这种情况下发生错误,则可以通过 `DETACH TABLE table_name` -> `ATTACH TABLE table_name` 重新加载(变为可见)表。如果在服务器启动时成功加载了元数据,则表会立即可用。 -### 零拷贝复制(未准备好投入生产) {#zero-copy} +使用 [http_max_single_read_retries](/operations/storing-data#web-storage) 设置限制单次 HTTP 读取期间的最大重试次数。 +### 零拷贝复制(尚未准备好用于生产) {#zero-copy} -零拷贝复制是可能的,但不建议使用 `S3` 和 `HDFS`(不支持)磁盘。零拷贝复制意味着如果数据存储在多个机器上并需要同步,则仅复制元数据(数据部分的路径),而不复制数据本身。 +零拷贝复制是可能的,但不推荐,使用 `S3` 和 `HDFS`(不支持)磁盘。零拷贝复制意味着,如果数据存储在多个机器上并需要同步,则仅复制元数据(数据部分的路径),而不复制数据本身。 -:::note 零拷贝复制尚未准备好投入生产 -在 ClickHouse 版本 22.8 及更高版本中,默认情况下禁用零拷贝复制。不建议在生产中使用此功能。 +:::note 零拷贝复制尚未准备好用于生产 +自 ClickHouse 版本 22.8 及更高版本中,零拷贝复制默认禁用。此功能不推荐用于生产使用。 ::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/storing-data.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/storing-data.md.hash index 92d063983cb..11d059b31e4 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/storing-data.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/storing-data.md.hash @@ -1 +1 @@ -e47e540a8b61535d +423fe56b4e7b5c2b diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/asynchronous_insert_log.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/asynchronous_insert_log.md index b168fd0dbaa..d70a86aa145 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/asynchronous_insert_log.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/asynchronous_insert_log.md @@ -1,10 +1,11 @@ --- -'description': '系统表包含有关异步插入的信息。每个条目代表一个缓冲到异步插入查询中的插入查询.' +'description': '系统表包含有关异步插入的信息。每个条目代表缓冲到异步 INSERT 查询中的 INSERT 查询。' 'keywords': - 'system table' - 'asynchronous_insert_log' 'slug': '/operations/system-tables/asynchronous_insert_log' 'title': 'system.asynchronous_insert_log' +'doc_type': 'reference' --- import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_system_table_cloud.md'; @@ -14,34 +15,34 @@ import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/curre -包含关于异步插入的信息。每个条目代表一个缓冲到异步插入查询中的插入查询。 +包含有关异步插入的信息。每个条目代表一个缓冲到异步插入查询的插入查询。 -要开始日志记录,请在 [asynchronous_insert_log](../../operations/server-configuration-parameters/settings.md#asynchronous_insert_log) 部分配置参数。 +要开始记录,请在 [asynchronous_insert_log](../../operations/server-configuration-parameters/settings.md#asynchronous_insert_log) 部分配置参数。 -数据刷新周期在 [asynchronous_insert_log](../../operations/server-configuration-parameters/settings.md#asynchronous_insert_log) 服务器设置部分的 `flush_interval_milliseconds` 参数中设置。要强制刷新,请使用 [SYSTEM FLUSH LOGS](/sql-reference/statements/system#flush-logs) 查询。 +数据的冲刷周期在 [asynchronous_insert_log](../../operations/server-configuration-parameters/settings.md#asynchronous_insert_log) 服务器设置部分的 `flush_interval_milliseconds` 参数中设置。要强制冲刷,请使用 [SYSTEM FLUSH LOGS](/sql-reference/statements/system#flush-logs) 查询。 -ClickHouse 不会自动删除表中的数据。有关更多详细信息,请参阅 [Introduction](/operations/system-tables/overview#system-tables-introduction)。 +ClickHouse 不会自动删除表中的数据。有关更多详细信息,请参见 [Introduction](/operations/system-tables/overview#system-tables-introduction)。 -列: +列: - `hostname` ([LowCardinality(String)](../../sql-reference/data-types/string.md)) — 执行查询的服务器的主机名。 - `event_date` ([Date](../../sql-reference/data-types/date.md)) — 异步插入发生的日期。 - `event_time` ([DateTime](../../sql-reference/data-types/datetime.md)) — 异步插入完成执行的日期和时间。 -- `event_time_microseconds` ([DateTime64](../../sql-reference/data-types/datetime64.md)) — 异步插入完成执行的日期和时间(微秒精度)。 +- `event_time_microseconds` ([DateTime64](../../sql-reference/data-types/datetime64.md)) — 异步插入完成执行的日期和时间,精确到微秒。 - `query` ([String](../../sql-reference/data-types/string.md)) — 查询字符串。 - `database` ([String](../../sql-reference/data-types/string.md)) — 表所在数据库的名称。 -- `table` ([String](../../sql-reference/data-types/string.md)) — 表名称。 +- `table` ([String](../../sql-reference/data-types/string.md)) — 表名。 - `format` ([String](/sql-reference/data-types/string.md)) — 格式名称。 - `query_id` ([String](../../sql-reference/data-types/string.md)) — 初始查询的 ID。 -- `bytes` ([UInt64](/sql-reference/data-types/int-uint#integer-ranges)) — 插入字节数。 +- `bytes` ([UInt64](/sql-reference/data-types/int-uint#integer-ranges)) — 插入的字节数。 - `exception` ([String](../../sql-reference/data-types/string.md)) — 异常消息。 - `status` ([Enum8](../../sql-reference/data-types/enum.md)) — 视图的状态。值: - - `'Ok' = 1` — 插入成功。 - - `'ParsingError' = 2` — 解析数据时的异常。 - - `'FlushError' = 3` — 刷新数据时的异常。 -- `flush_time` ([DateTime](../../sql-reference/data-types/datetime.md)) — 刷新发生的日期和时间。 -- `flush_time_microseconds` ([DateTime64](../../sql-reference/data-types/datetime64.md)) — 刷新发生的日期和时间(微秒精度)。 -- `flush_query_id` ([String](../../sql-reference/data-types/string.md)) — 刷新查询的 ID。 + - `'Ok' = 1` — 插入成功。 + - `'ParsingError' = 2` — 解析数据时发生异常。 + - `'FlushError' = 3` — 冲刷数据时发生异常。 +- `flush_time` ([DateTime](../../sql-reference/data-types/datetime.md)) — 冲刷发生的日期和时间。 +- `flush_time_microseconds` ([DateTime64](../../sql-reference/data-types/datetime64.md)) — 冲刷发生的日期和时间,精确到微秒。 +- `flush_query_id` ([String](../../sql-reference/data-types/string.md)) — 冲刷查询的 ID。 **示例** @@ -71,7 +72,7 @@ flush_time_microseconds: 2023-06-08 10:08:55.139676 flush_query_id: cd2c1e43-83f5-49dc-92e4-2fbc7f8d3716 ``` -**另请参阅** +**另见** -- [system.query_log](../../operations/system-tables/query_log) — 描述 `query_log` 系统表的内容,该表包含有关查询执行的通用信息。 -- [system.asynchronous_inserts](/operations/system-tables/asynchronous_inserts) — 此表包含队列中待处理的异步插入的信息。 +- [system.query_log](../../operations/system-tables/query_log) — 描述 `query_log` 系统表的信息,该表包含有关查询执行的常见信息。 +- [system.asynchronous_inserts](/operations/system-tables/asynchronous_inserts) — 此表包含有关队列中待处理异步插入的信息。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/asynchronous_insert_log.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/asynchronous_insert_log.md.hash index b0f682e7c54..47b8bdb1bbd 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/asynchronous_insert_log.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/asynchronous_insert_log.md.hash @@ -1 +1 @@ -22eba99c4871de22 +1c50a45a1217c861 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/asynchronous_inserts.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/asynchronous_inserts.md index 4ccf8c0695a..2e144e652c7 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/asynchronous_inserts.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/asynchronous_inserts.md @@ -5,6 +5,7 @@ - 'asynchronous_inserts' 'slug': '/operations/system-tables/asynchronous_inserts' 'title': 'system.asynchronous_inserts' +'doc_type': 'reference' --- import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_system_table_cloud.md'; @@ -17,12 +18,12 @@ import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/curre - `query` ([String](../../sql-reference/data-types/string.md)) — 查询字符串。 - `database` ([String](../../sql-reference/data-types/string.md)) — 表所在数据库的名称。 -- `table` ([String](../../sql-reference/data-types/string.md)) — 表名。 +- `table` ([String](../../sql-reference/data-types/string.md)) — 表名称。 - `format` ([String](/sql-reference/data-types/string.md)) — 格式名称。 -- `first_update` ([DateTime64](../../sql-reference/data-types/datetime64.md)) — 微秒级分辨率的第一次插入时间。 -- `total_bytes` ([UInt64](/sql-reference/data-types/int-uint#integer-ranges)) — 排队等待的总字节数。 -- `entries.query_id` ([Array(String)](../../sql-reference/data-types/array.md)) - 等待队列中插入的查询 ID 数组。 -- `entries.bytes` ([Array(UInt64)](../../sql-reference/data-types/array.md)) - 等待队列中每个插入查询的字节数组。 +- `first_update` ([DateTime64](../../sql-reference/data-types/datetime64.md)) — 第一次插入时间,精确到微秒。 +- `total_bytes` ([UInt64](/sql-reference/data-types/int-uint#integer-ranges)) — 队列中等待的字节总数。 +- `entries.query_id` ([Array(String)](../../sql-reference/data-types/array.md)) - 等待在队列中的插入查询的查询 ID 数组。 +- `entries.bytes` ([Array(UInt64)](../../sql-reference/data-types/array.md)) - 等待在队列中的每个插入查询的字节数组。 **示例** @@ -47,7 +48,7 @@ entries.query_id: ['b46cd4c4-0269-4d0b-99f5-d27668c6102e'] entries.bytes: [133223] ``` -**参见** +**另见** -- [system.query_log](/operations/system-tables/query_log) — 描述 `query_log` 系统表的内容,该表包含有关查询执行的常见信息。 +- [system.query_log](/operations/system-tables/query_log) — 描述 `query_log` 系统表的内容,该系统表包含有关查询执行的常见信息。 - [system.asynchronous_insert_log](/operations/system-tables/asynchronous_insert_log) — 此表包含有关执行的异步插入的信息。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/asynchronous_inserts.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/asynchronous_inserts.md.hash index 43f7938587d..691f46201ea 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/asynchronous_inserts.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/asynchronous_inserts.md.hash @@ -1 +1 @@ -c1c7ea4b1f8ef284 +a4f67650ede6a42a diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/asynchronous_loader.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/asynchronous_loader.md index 8957f28ea61..ebc5fec81cc 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/asynchronous_loader.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/asynchronous_loader.md @@ -1,10 +1,11 @@ --- -'description': '系统表包含有关最近异步作业的信息和状态(例如,正在加载的表)。该表为每个作业包含一行。' +'description': '系统表包含关于最近的异步作业的信息和状态(例如,正在加载的表)。该表为每个作业包含一行.' 'keywords': - 'system table' - 'asynchronous_loader' 'slug': '/operations/system-tables/asynchronous_loader' 'title': 'system.asynchronous_loader' +'doc_type': 'reference' --- import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_system_table_cloud.md'; @@ -14,7 +15,7 @@ import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/curre -包含最近异步作业(例如表加载)的信息和状态。该表为每个作业包含一行。可以使用工具 `utils/async_loader_graph` 来可视化该表的信息。 +包含最近异步作业(例如,表加载)的信息和状态。该表为每个作业包含一行。可以使用工具 `utils/async_loader_graph` 来可视化该表中的信息。 示例: @@ -27,36 +28,36 @@ FORMAT Vertical 列: -- `job` (`String`)- 作业名称(可能不是唯一的)。 -- `job_id` (`UInt64`)- 作业的唯一 ID。 -- `dependencies` (`Array(UInt64)`)- 该作业之前应该完成的作业 ID 列表。 -- `dependencies_left` (`UInt64`)- 当前剩余的依赖项数量。 -- `status` (`Enum`)- 作业的当前加载状态: +- `job` (`String`) - 作业名称(可能不是唯一的)。 +- `job_id` (`UInt64`) - 作业的唯一 ID。 +- `dependencies` (`Array(UInt64)`) - 应在此作业之前完成的作业 ID 列表。 +- `dependencies_left` (`UInt64`) - 当前尚未完成的依赖项数量。 +- `status` (`Enum`) - 作业的当前加载状态: `PENDING`: 加载作业尚未开始。 - `OK`: 加载作业已执行且成功。 + `OK`: 加载作业已执行并成功完成。 `FAILED`: 加载作业已执行但失败。 - `CANCELED`: 加载作业因移除或依赖失败将不会执行。 - -待处理的作业可能处于以下状态之一: -- `is_executing` (`UInt8`)- 作业当前正在被工作线程执行。 -- `is_blocked` (`UInt8`)- 作业在等待其依赖项完成。 -- `is_ready` (`UInt8`)- 作业已准备好执行并在等待工作线程。 -- `elapsed` (`Float64`)- 从执行开始到现在经过的秒数。如果作业尚未开始,则为零。如果作业完成,则为总执行时间。 - -每个作业都有一个与之相关联的池,并在该池中启动。每个池具有恒定的优先级和可变的最大工作线程数。优先级更高(`priority` 值更低)的作业将优先运行。任何优先级较低的作业在至少有一个优先级较高的作业准备或正在执行时都不会启动。可以通过优先安排来提升作业的优先级(但不能降低)。例如,如果传入的查询需要该表,则加载表和启动的作业将被优先安排。在执行过程中也可以优先安排作业,但作业不会从其 `execution_pool` 移动到新分配的 `pool`。该作业使用 `pool` 来创建新作业以避免优先级反转。已经启动的作业不会被优先级更高的作业抢占,并在启动后始终完成执行。 -- `pool_id` (`UInt64`)- 当前分配给作业的池 ID。 -- `pool` (`String`)- `pool_id` 池的名称。 -- `priority` (`Int64`)- `pool_id` 池的优先级。 -- `execution_pool_id` (`UInt64`)- 作业执行所在的池 ID。在执行开始前等于最初分配的池。 -- `execution_pool` (`String`)- `execution_pool_id` 池的名称。 -- `execution_priority` (`Int64`)- `execution_pool_id` 池的优先级。 - -- `ready_seqno` (`Nullable(UInt64)`)- 对于已准备好的作业不为 null。工作线程从其池的准备队列中拉取下一个要执行的作业。如果有多个准备好的作业,则选择 `ready_seqno` 值最低的作业。 -- `waiters` (`UInt64`)- 等待该作业的线程数。 -- `exception` (`Nullable(String)`)- 对于失败和取消的作业不为 null。保存查询执行期间引发的错误消息或导致取消此作业及其依赖链的错误信息。 - -作业生命周期中的时间瞬间: -- `schedule_time` (`DateTime64`)- 作业被创建并调度执行的时间(通常连同所有依赖项)。 -- `enqueue_time` (`Nullable(DateTime64)`)- 作业准备好并被加入到其池的准备队列的时间。如果作业尚未准备好,则为 null。 -- `start_time` (`Nullable(DateTime64)`)- 工作线程从准备队列解除作业并开始执行的时间。如果作业尚未开始,则为 null。 -- `finish_time` (`Nullable(DateTime64)`)- 作业执行完成的时间。如果作业尚未完成,则为 null。 + `CANCELED`: 由于删除或依赖项失败,加载作业将不会被执行。 + +一个待处理的作业可能处于以下状态之一: +- `is_executing` (`UInt8`) - 作业当前正在由工作线程执行。 +- `is_blocked` (`UInt8`) - 作业在等待其依赖项完成。 +- `is_ready` (`UInt8`) - 作业准备好执行,正在等待工作线程。 +- `elapsed` (`Float64`) - 自执行开始以来已经过的秒数。如果作业尚未开始,则为零。如果作业完成,则为总执行时间。 + +每个作业都有一个与之相关联的池,并在该池中启动。每个池都有一个固定的优先级和一个可变的最大工作线程数量。更高的优先级(较低的 `priority` 值)作业会优先运行。在至少存在一个更高优先级的作业准备好或正在执行的情况下,不会启动优先级较低的作业。作业优先级可以提升(但不能降低),通过优先处理它。例如,如果即将到来的查询需要此表,则表加载和启动的作业将会被优先处理。在执行期间,也可以优先处理作业,但作业不会从其 `execution_pool` 移动到新分配的 `pool`。该作业使用 `pool` 创建新作业以避免优先级反转。已经开始的作业不会被更高优先级的作业抢占,并且在启动后始终完整运行至完成。 +- `pool_id` (`UInt64`) - 当前分配给作业的池的 ID。 +- `pool` (`String`) - `pool_id` 池的名称。 +- `priority` (`Int64`) - `pool_id` 池的优先级。 +- `execution_pool_id` (`UInt64`) - 该作业执行所在池的 ID。执行开始前初始分配的池的 ID。 +- `execution_pool` (`String`) - `execution_pool_id` 池的名称。 +- `execution_priority` (`Int64`) - `execution_pool_id` 池的优先级。 + +- `ready_seqno` (`Nullable(UInt64)`) - 对于准备好的作业不为 null。工作线程从其池的准备队列中提取下一个将要执行的作业。如果有多个准备好的作业,则选择 `ready_seqno` 值最低的作业。 +- `waiters` (`UInt64`) - 等待此作业的线程数量。 +- `exception` (`Nullable(String)`) - 对于失败和取消的作业不为 null。保存查询执行期间引发的错误消息或导致取消此作业的错误及其依赖项失败链中的作业名称。 + +作业生命周期中的时间点: +- `schedule_time` (`DateTime64`) - 作业被创建并安排执行的时间(通常是与其所有依赖项一起)。 +- `enqueue_time` (`Nullable(DateTime64)`) - 作业准备就绪并被加入其池的准备队列的时间。如果作业尚未准备,则为 null。 +- `start_time` (`Nullable(DateTime64)`) - 工作线程从准备队列中取出作业并开始执行的时间。如果作业尚未开始,则为 null。 +- `finish_time` (`Nullable(DateTime64)`) - 作业执行完成的时间。如果作业尚未完成,则为 null。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/asynchronous_loader.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/asynchronous_loader.md.hash index 68c37b090e1..298c8bb4fb9 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/asynchronous_loader.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/asynchronous_loader.md.hash @@ -1 +1 @@ -dec667c44de79298 +3a8461adaedd235a diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/asynchronous_metric_log.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/asynchronous_metric_log.md index e55e6fbe68c..4485e11c98b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/asynchronous_metric_log.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/asynchronous_metric_log.md @@ -1,19 +1,20 @@ --- -'description': '系统表包含 `system.asynchronous_metrics` 的历史值,这些值每个时间间隔(默认每秒一次)保存一次。' +'description': '系统表包含 `system.asynchronous_metrics` 的历史值,这些值每个时间间隔(默认一秒钟)保存一次' 'keywords': - 'system table' - 'asynchronous_metric_log' 'slug': '/operations/system-tables/asynchronous_metric_log' 'title': 'system.asynchronous_metric_log' +'doc_type': 'reference' --- import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_system_table_cloud.md'; -包含 `system.asynchronous_metrics` 的历史值,这些值每个时间间隔(默认一秒)保存一次。默认情况下启用。 +包含 `system.asynchronous_metrics` 的历史值,这些值每个时间间隔保存一次(默认每秒一次)。默认启用。 -列: +列: - `hostname` ([LowCardinality(String)](../../sql-reference/data-types/string.md)) — 执行查询的服务器的主机名。 - `event_date` ([Date](../../sql-reference/data-types/date.md)) — 事件日期。 @@ -53,8 +54,8 @@ metric: AsynchronousHeavyMetricsCalculationTimeSpent value: 0 ``` -**另见** +**另请参阅** -- [asynchronous_metric_log 设置](../../operations/server-configuration-parameters/settings.md#asynchronous_metric_log) — 启用和禁用设置。 +- [asynchronous_metric_log 设置](../../operations/server-configuration-parameters/settings.md#asynchronous_metric_log) — 启用和禁用该设置。 - [system.asynchronous_metrics](../system-tables/asynchronous_metrics.md) — 包含定期在后台计算的指标。 -- [system.metric_log](../system-tables/metric_log.md) — 包含来自表 `system.metrics` 和 `system.events` 的指标值历史,定期刷新到磁盘。 +- [system.metric_log](../system-tables/metric_log.md) — 包含来自 `system.metrics` 和 `system.events` 表的指标值历史,定期刷新到磁盘。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/asynchronous_metric_log.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/asynchronous_metric_log.md.hash index 4a23b3d847d..f3163f8f387 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/asynchronous_metric_log.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/asynchronous_metric_log.md.hash @@ -1 +1 @@ -ff7fa4eac624fd77 +ce62ae1e9445cb11 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/asynchronous_metrics.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/asynchronous_metrics.md index 6789005a8b0..f8054c20604 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/asynchronous_metrics.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/asynchronous_metrics.md @@ -1,27 +1,27 @@ --- -'description': '系统表,包含在后台定期计算的指标。例如,使用中的RAM数量。' +'description': '系统表包含定期在后台计算的指标。例如,使用的RAM数量。' 'keywords': - 'system table' - 'asynchronous_metrics' 'slug': '/operations/system-tables/asynchronous_metrics' 'title': 'system.asynchronous_metrics' +'doc_type': 'reference' --- import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_system_table_cloud.md'; - # system.asynchronous_metrics -包含在后台定期计算的指标。例如,RAM 的使用量。 +包含定期在后台计算的指标。例如,已使用的内存量。 列: - `metric` ([String](../../sql-reference/data-types/string.md)) — 指标名称。 - `value` ([Float64](../../sql-reference/data-types/float.md)) — 指标值。 -- `description` ([String](../../sql-reference/data-types/string.md)) - 指标描述 +- `description` ([String](../../sql-reference/data-types/string.md) - 指标描述) **示例** @@ -44,472 +44,445 @@ SELECT * FROM system.asynchronous_metrics LIMIT 10 └─────────────────────────────────────────┴────────────┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ ``` - + ## 指标描述 {#metric-descriptions} ### AsynchronousHeavyMetricsCalculationTimeSpent {#asynchronousheavymetricscalculationtimespent} -计算异步重指标(与表相关)的花费时间(秒)。(这是异步指标的开销)。 +计算异步重(与表相关)指标所花费的时间(以秒为单位)(这是异步指标的开销)。 ### AsynchronousHeavyMetricsUpdateInterval {#asynchronousheavymetricsupdateinterval} -重指标(与表相关)的更新间隔。 +重(与表相关)指标的更新间隔 ### AsynchronousMetricsCalculationTimeSpent {#asynchronousmetricscalculationtimespent} -计算异步指标的花费时间(秒)。(这是异步指标的开销)。 +计算异步指标所花费的时间(以秒为单位)(这是异步指标的开销)。 ### AsynchronousMetricsUpdateInterval {#asynchronousmetricsupdateinterval} -指标更新间隔。 +指标更新间隔 ### BlockActiveTime_*name* {#blockactivetime_name} -块设备排队的 IO 请求所花费的时间(秒)。这是一个系统范围的指标,它包括主机上所有进程,而不仅仅是 clickhouse-server。来源:`/sys/block`。请参阅 https://www.kernel.org/doc/Documentation/block/stat.txt +块设备的 IO 请求排队的时间(以秒为单位)。这是一个系统范围的指标,包括主机机器上的所有进程,而不仅仅是 clickhouse-server。来源:`/sys/block`。见 https://www.kernel.org/doc/Documentation/block/stat.txt ### BlockDiscardBytes_*name* {#blockdiscardbytes_name} -块设备上丢弃的字节数。这些操作对 SSD 相关。ClickHouse 不使用丢弃操作,但系统上的其他进程可以使用。这是一个系统范围的指标,它包括主机上所有进程,而不仅仅是 clickhouse-server。来源:`/sys/block`。请参阅 https://www.kernel.org/doc/Documentation/block/stat.txt +在块设备上丢弃的字节数。这些操作与 SSD 相关。ClickHouse 不使用丢弃操作,但系统上的其他进程可以使用。此指标是系统范围的,包括主机机器上的所有进程,而不仅仅是 clickhouse-server。来源:`/sys/block`。见 https://www.kernel.org/doc/Documentation/block/stat.txt ### BlockDiscardMerges_*name* {#blockdiscardmerges_name} -从块设备请求的丢弃操作的数量,并由操作系统 IO 调度器合并在一起。这些操作对 SSD 相关。ClickHouse 不使用丢弃操作,但系统上的其他进程可以使用。这是一个系统范围的指标,它包括主机上所有进程,而不仅仅是 clickhouse-server。来源:`/sys/block`。请参阅 https://www.kernel.org/doc/Documentation/block/stat.txt +请求从块设备进行的丢弃操作的数量,并由操作系统 IO 调度程序合并在一起。这些操作与 SSD 相关。ClickHouse 不使用丢弃操作,但系统上的其他进程可以使用。此指标是系统范围的,包括主机机器上的所有进程,而不仅仅是 clickhouse-server。来源:`/sys/block`。见 https://www.kernel.org/doc/Documentation/block/stat.txt ### BlockDiscardOps_*name* {#blockdiscardops_name} -从块设备请求的丢弃操作的数量。这些操作对 SSD 相关。ClickHouse 不使用丢弃操作,但系统上的其他进程可以使用。这是一个系统范围的指标,它包括主机上所有进程,而不仅仅是 clickhouse-server。来源:`/sys/block`。请参阅 https://www.kernel.org/doc/Documentation/block/stat.txt +请求从块设备进行的丢弃操作的数量。这些操作与 SSD 相关。ClickHouse 不使用丢弃操作,但系统上的其他进程可以使用。此指标是系统范围的,包括主机机器上的所有进程,而不仅仅是 clickhouse-server。来源:`/sys/block`。见 https://www.kernel.org/doc/Documentation/block/stat.txt ### BlockDiscardTime_*name* {#blockdiscardtime_name} -从块设备请求的丢弃操作花费的时间(秒),所有操作的总和。这些操作对 SSD 相关。ClickHouse 不使用丢弃操作,但系统上的其他进程可以使用。这是一个系统范围的指标,它包括主机上所有进程,而不仅仅是 clickhouse-server。来源:`/sys/block`。请参阅 https://www.kernel.org/doc/Documentation/block/stat.txt +花费在从块设备请求的丢弃操作中的时间(以秒为单位),对所有操作求和。这些操作与 SSD 相关。ClickHouse 不使用丢弃操作,但系统上的其他进程可以使用。此指标是系统范围的,包括主机机器上的所有进程,而不仅仅是 clickhouse-server。来源:`/sys/block`。见 https://www.kernel.org/doc/Documentation/block/stat.txt ### BlockInFlightOps_*name* {#blockinflightops_name} -此值计算已发出的 IO 请求的数量,但尚未完成。它不包括在队列中的 IO 请求,但尚未发给设备驱动程序。这是一个系统范围的指标,它包括主机上所有进程,而不仅仅是 clickhouse-server。来源:`/sys/block`。请参阅 https://www.kernel.org/doc/Documentation/block/stat.txt +此值计算已向设备驱动程序发出的 I/O 请求数量,但尚未完成。它不包括尚未向设备驱动程序发出的 IO 请求。此指标是系统范围的,包括主机机器上的所有进程,而不仅仅是 clickhouse-server。来源:`/sys/block`。见 https://www.kernel.org/doc/Documentation/block/stat.txt ### BlockQueueTime_*name* {#blockqueuetime_name} -此值计算在此块设备上等待的 IO 请求的毫秒数。如果有多个 IO 请求在等待,则此值将增加,计算为毫秒数与等待请求数的乘积。这是一个系统范围的指标,它包括主机上所有进程,而不仅仅是 clickhouse-server。来源:`/sys/block`。请参阅 https://www.kernel.org/doc/Documentation/block/stat.txt +此值计算 IO 请求在该块设备上等待的毫秒数。如果有多个 IO 请求等待,此值将增加,作为等待的请求数量与毫秒数的乘积。此指标是系统范围的,包括主机机器上的所有进程,而不仅仅是 clickhouse-server。来源:`/sys/block`。见 https://www.kernel.org/doc/Documentation/block/stat.txt ### BlockReadBytes_*name* {#blockreadbytes_name} -从块设备读取的字节数。由于使用了 OS 页缓存,可能低于从文件系统读取的字节数,保存了 IO。这是一个系统范围的指标,它包括主机上所有进程,而不仅仅是 clickhouse-server。来源:`/sys/block`。请参阅 https://www.kernel.org/doc/Documentation/block/stat.txt +从块设备读取的字节数。由于使用了 OS 页面缓存,读取的字节数可能低于从文件系统读取的字节数,这可以节省 IO。此指标是系统范围的,包括主机机器上的所有进程,而不仅仅是 clickhouse-server。来源:`/sys/block`。见 https://www.kernel.org/doc/Documentation/block/stat.txt ### BlockReadMerges_*name* {#blockreadmerges_name} -从块设备请求的读取操作数量,并由操作系统 IO 调度器合并在一起。这是一个系统范围的指标,它包括主机上所有进程,而不仅仅是 clickhouse-server。来源:`/sys/block`。请参阅 https://www.kernel.org/doc/Documentation/block/stat.txt +请求从块设备进行的读取操作的数量,并由 OS IO 调度程序合并在一起。此指标是系统范围的,包括主机机器上的所有进程,而不仅仅是 clickhouse-server。来源:`/sys/block`。见 https://www.kernel.org/doc/Documentation/block/stat.txt ### BlockReadOps_*name* {#blockreadops_name} -从块设备请求的读取操作数量。这是一个系统范围的指标,它包括主机上所有进程,而不仅仅是 clickhouse-server。来源:`/sys/block`。请参阅 https://www.kernel.org/doc/Documentation/block/stat.txt +请求从块设备进行的读取操作的数量。此指标是系统范围的,包括主机机器上的所有进程,而不仅仅是 clickhouse-server。来源:`/sys/block`。见 https://www.kernel.org/doc/Documentation/block/stat.txt ### BlockReadTime_*name* {#blockreadtime_name} -从块设备请求的读取操作花费的时间(秒),所有操作的总和。这是一个系统范围的指标,它包括主机上所有进程,而不仅仅是 clickhouse-server。来源:`/sys/block`。请参阅 https://www.kernel.org/doc/Documentation/block/stat.txt +花费在从块设备请求的读取操作中的时间(以秒为单位),对所有操作求和。此指标是系统范围的,包括主机机器上的所有进程,而不仅仅是 clickhouse-server。来源:`/sys/block`。见 https://www.kernel.org/doc/Documentation/block/stat.txt ### BlockWriteBytes_*name* {#blockwritebytes_name} -写入块设备的字节数。由于使用了 OS 页缓存,可能低于写入文件系统的字节数。因为写入块设备可能在对应的写入文件系统后发生,所以可能发生写透缓存。这是一个系统范围的指标,它包括主机上所有进程,而不仅仅是 clickhouse-server。来源:`/sys/block`。请参阅 https://www.kernel.org/doc/Documentation/block/stat.txt +写入到块设备的字节数。由于使用了 OS 页面缓存,写入的字节数可能低于写入文件系统的字节数。由于写入通过缓存的写入,块设备上的写入可能发生在对应的写入到文件系统之前。此指标是系统范围的,包括主机机器上的所有进程,而不仅仅是 clickhouse-server。来源:`/sys/block`。见 https://www.kernel.org/doc/Documentation/block/stat.txt ### BlockWriteMerges_*name* {#blockwritemerges_name} -从块设备请求的写入操作数量,并由操作系统 IO 调度器合并在一起。这是一个系统范围的指标,它包括主机上所有进程,而不仅仅是 clickhouse-server。来源:`/sys/block`。请参阅 https://www.kernel.org/doc/Documentation/block/stat.txt +请求从块设备进行的写入操作的数量,并由 OS IO 调度程序合并在一起。此指标是系统范围的,包括主机机器上的所有进程,而不仅仅是 clickhouse-server。来源:`/sys/block`。见 https://www.kernel.org/doc/Documentation/block/stat.txt ### BlockWriteOps_*name* {#blockwriteops_name} -从块设备请求的写入操作数量。这是一个系统范围的指标,它包括主机上所有进程,而不仅仅是 clickhouse-server。来源:`/sys/block`。请参阅 https://www.kernel.org/doc/Documentation/block/stat.txt +请求从块设备进行的写入操作的数量。此指标是系统范围的,包括主机机器上的所有进程,而不仅仅是 clickhouse-server。来源:`/sys/block`。见 https://www.kernel.org/doc/Documentation/block/stat.txt ### BlockWriteTime_*name* {#blockwritetime_name} -从块设备请求的写入操作花费的时间(秒),所有操作的总和。这是一个系统范围的指标,它包括主机上所有进程,而不仅仅是 clickhouse-server。来源:`/sys/block`。请参阅 https://www.kernel.org/doc/Documentation/block/stat.txt +花费在从块设备请求的写入操作中的时间(以秒为单位),对所有操作求和。此指标是系统范围的,包括主机机器上的所有进程,而不仅仅是 clickhouse-server。来源:`/sys/block`。见 https://www.kernel.org/doc/Documentation/block/stat.txt ### CPUFrequencyMHz_*name* {#cpufrequencymhz_name} -CPU 的当前频率,单位为 MHz。大多数现代 CPU 根据电源节省和涡轮增压动态调整频率。 -### CompiledExpressionCacheBytes {#compiledexpressioncachebytes} - -用于 JIT 编译代码缓存的总字节数。 -### CompiledExpressionCacheCount {#compiledexpressioncachecount} - -JIT 编译代码缓存中的总条目数。 +CPU 的当前频率,以 MHz 为单位。大多数现代 CPU 会动态调整频率以节省电力和增加 Turbo 加速。 ### DictionaryMaxUpdateDelay {#dictionarymaxlastsuccessfulupdatetime} -字典更新的最大延迟(秒)。 +字典更新的最大延迟(以秒为单位)。 ### DictionaryTotalFailedUpdates {#dictionaryloadfailed} -自最后一次成功加载以来,在所有字典中的错误数量。 +自上次成功加载以来所有字典中的错误数量。 ### DiskAvailable_*name* {#diskavailable_name} -磁盘上的可用字节数(虚拟文件系统)。远程文件系统可能显示出像 16 EiB 这样的大值。 +磁盘上的可用字节(虚拟文件系统)。远程文件系统可以显示如 16 EiB 等较大值。 ### DiskTotal_*name* {#disktotal_name} -磁盘的总大小(字节)(虚拟文件系统)。远程文件系统可能显示出像 16 EiB 这样的大值。 +磁盘的总大小(以字节为单位)(虚拟文件系统)。远程文件系统可以显示如 16 EiB 等较大值。 ### DiskUnreserved_*name* {#diskunreserved_name} -磁盘上的可用字节数(虚拟文件系统),且没有为合并、获取和移动保留的空间。远程文件系统可能显示出像 16 EiB 这样的大值。 +磁盘上的可用字节(虚拟文件系统),不包括合并、提取和移动的保留空间。远程文件系统可以显示如 16 EiB 等较大值。 ### DiskUsed_*name* {#diskused_name} -磁盘上已使用的字节数(虚拟文件系统)。远程文件系统不总是提供此信息。 +磁盘上已使用的字节数(虚拟文件系统)。远程文件系统并不总是提供此信息。 ### FilesystemCacheBytes {#filesystemcachebytes} -在 `cache` 虚拟文件系统中的总字节数。此缓存驻留在磁盘上。 +`cache` 虚拟文件系统中的总字节数。此缓存保留在磁盘上。 ### FilesystemCacheFiles {#filesystemcachefiles} -在 `cache` 虚拟文件系统中缓存的文件段总数。此缓存驻留在磁盘上。 +`cache` 虚拟文件系统中缓存的文件段的总数。此缓存保留在磁盘上。 ### FilesystemLogsPathAvailableBytes {#filesystemlogspathavailablebytes} -在挂载 ClickHouse 日志路径的卷上可用的字节数。如果此值接近零,您应当调整配置文件中的日志轮换设置。 +ClickHouse 日志路径挂载的卷上的可用字节。如果该值接近零,您应该调整配置文件中的日志轮换。 ### FilesystemLogsPathAvailableINodes {#filesystemlogspathavailableinodes} -在挂载 ClickHouse 日志路径的卷上可用的 i节点数量。 +ClickHouse 日志路径挂载的卷上可用的 inode 数量。 ### FilesystemLogsPathTotalBytes {#filesystemlogspathtotalbytes} -挂载 ClickHouse 日志路径的卷的大小(字节)。建议日志至少有 10 GB。 +ClickHouse 日志路径挂载的卷的大小(以字节为单位)。建议日志至少要有 10 GB。 ### FilesystemLogsPathTotalINodes {#filesystemlogspathtotalinodes} -在挂载 ClickHouse 日志路径的卷上的 i节点总数。 +ClickHouse 日志路径挂载的卷上的 inode 总数。 ### FilesystemLogsPathUsedBytes {#filesystemlogspathusedbytes} -挂载 ClickHouse 日志路径的卷上已使用的字节数。 +ClickHouse 日志路径挂载的卷上已使用的字节数。 ### FilesystemLogsPathUsedINodes {#filesystemlogspathusedinodes} -在挂载 ClickHouse 日志路径的卷上已使用的 i节点数量。 +ClickHouse 日志路径挂载的卷上已使用的 inode 数量。 ### FilesystemMainPathAvailableBytes {#filesystemmainpathavailablebytes} -在挂载主 ClickHouse 路径的卷上可用的字节数。 +主 ClickHouse 路径挂载的卷上的可用字节数。 ### FilesystemMainPathAvailableINodes {#filesystemmainpathavailableinodes} -在挂载主 ClickHouse 路径的卷上可用的 i节点数量。如果接近零,这表明配置错误,即使磁盘未满,您也会收到“设备上没有剩余空间”的错误。 +主 ClickHouse 路径挂载的卷上可用的 inode 数量。如果此值接近零,则表示配置错误,您即使在磁盘未满的情况下也会收到“设备上没有剩余空间”的错误。 ### FilesystemMainPathTotalBytes {#filesystemmainpathtotalbytes} -挂载主 ClickHouse 路径的卷的大小(字节)。 +主 ClickHouse 路径挂载的卷的大小(以字节为单位)。 ### FilesystemMainPathTotalINodes {#filesystemmainpathtotalinodes} -挂载主 ClickHouse 路径的卷上 i节点的总数量。如果少于 2500 万,表明配置错误。 +主 ClickHouse 路径挂载的卷上 inode 的总数。如果少于 2500 万,则表示配置错误。 ### FilesystemMainPathUsedBytes {#filesystemmainpathusedbytes} -在挂载主 ClickHouse 路径的卷上已使用的字节数。 +主 ClickHouse 路径挂载的卷上已使用的字节数。 ### FilesystemMainPathUsedINodes {#filesystemmainpathusedinodes} -在挂载主 ClickHouse 路径的卷上已使用的 i节点数量。该值通常对应于文件数量。 +主 ClickHouse 路径挂载的卷上已使用的 inode 数量。此值主要对应于文件数。 ### HTTPThreads {#httpthreads} -HTTP 接口服务器中的线程数量(不含 TLS)。 +HTTP 接口服务器中的线程数量(不带 TLS)。 ### InterserverThreads {#interserverthreads} -副本通信协议服务器中的线程数量(不含 TLS)。 +副本通信协议服务器中的线程数量(不带 TLS)。 ### Jitter {#jitter} -计算异步指标的线程被调度唤醒的时间与实际唤醒时间之间的差异。总体系统延迟和响应性的 Proxy 指标。 +用于计算异步指标的线程被调度唤醒的时间与实际被唤醒的时间之间的差异。整体系统延迟和响应性的代理指标。 ### LoadAverage*N* {#loadaveragen} -整个系统负载,经过 1 分钟的指数平滑平均。负载表示当前正在 CPU 上运行的进程(操作系统内核的调度实体)或等待 IO 的线程数,或准备运行但未被调度的线程数量。该数字包括所有进程,而不仅仅是 clickhouse-server。当系统负载过重时,许多进程准备运行但等待 CPU 或 IO,此值可能大于 CPU 核心数。 -### MMapCacheCells {#mmapcachecells} - -使用 `mmap` 打开的文件数量(在内存中映射)。这用于设置 `local_filesystem_read_method` 为 `mmap` 的查询。使用 `mmap` 打开的文件会保存在缓存中,以避免代价高昂的 TLB 刷新。 -### MarkCacheBytes {#markcachebytes} - -标记缓存的总大小(字节)。 -### MarkCacheFiles {#markcachefiles} - -标记缓存中缓存的标记文件总数。 +整个系统的负载,经过 1 分钟的指数平滑平均。负载表示当前在 CPU 上运行或等待 IO 或准备运行但此时未被调度的所有进程(操作系统内核的调度实体)的线程数。这个数字包括所有进程,而不仅仅是 clickhouse-server。如果系统过载,并且许多进程准备运行但正在等待 CPU 或 IO,数字可以大于 CPU 核心数。 ### MaxPartCountForPartition {#maxpartcountforpartition} -MergeTree 系列所有分区中每个分区的最大部分数。大于 300 的值表明配置错误、超载或大量数据加载。 +在所有 MergeTree 家族表的所有分区中,每个分区的最大部分数。大于 300 的值表示配置错误、过载或大量数据加载。 ### MemoryCode {#memorycode} -为服务器进程的机器代码页面映射的虚拟内存量(字节)。 +为服务器进程的机器代码页面映射的虚拟内存量(以字节为单位)。 ### MemoryDataAndStack {#memorydataandstack} -为栈使用和分配内存映射的虚拟内存量(字节)。是否包含每个线程的栈和大多数通过 `mmap` 系统调用分配的内存尚不明确。该指标仅为完整性原因而存在。我建议使用 `MemoryResident` 指标进行监控。 +为栈使用和分配内存而映射的虚拟内存量(以字节为单位)。尚不清楚它是否包括每个线程的栈和大多数通过 'mmap' 系统调用分配的内存。此指标仅存在于完整性原因。建议使用 `MemoryResident` 指标进行监控。 ### MemoryResidentMax {#memoryresidentmax} -服务器进程使用的最大物理内存量(字节)。 +服务器进程使用的最大物理内存量(以字节为单位)。 ### MemoryResident {#memoryresident} -服务器进程使用的物理内存量(字节)。 +服务器进程使用的物理内存量(以字节为单位)。 ### MemoryShared {#memoryshared} -服务器进程使用的内存量,同时被其他进程共享(字节)。ClickHouse 不使用共享内存,但 OS 可能出于自身原因标记一些内存为共享。监控此指标的意义不大,仅为完整性原因而存在。 +服务器进程使用的内存量,同时也被其他进程共享(以字节为单位)。ClickHouse 不使用共享内存,但某些内存可能由于操作系统的原因被标记为共享。此指标不太有意义,存在仅出于完整性原因。 ### MemoryVirtual {#memoryvirtual} -服务器进程分配的虚拟地址空间大小(字节)。虚拟地址空间的大小通常大于物理内存消耗,不应作为内存消耗的估算。这一指标的值很大是完全正常的,只有技术意义。 +服务器进程分配的虚拟地址空间的大小(以字节为单位)。虚拟地址空间的大小通常大大大于物理内存消耗,不应作为内存消耗的估计。此指标的大值是完全正常的,仅具有技术意义。 ### MySQLThreads {#mysqlthreads} MySQL 兼容协议服务器中的线程数量。 ### NetworkReceiveBytes_*name* {#networkreceivebytes_name} -通过网络接口接收的字节数。这是一个系统范围的指标,它包括主机上所有进程,而不仅仅是 clickhouse-server。 +通过网络接口接收的字节数。这是一个系统范围的指标,包括主机上的所有进程,而不仅仅是 clickhouse-server。 ### NetworkReceiveDrop_*name* {#networkreceivedrop_name} -在网络接口接收数据时丢弃的字节数。这是一个系统范围的指标,它包括主机上所有进程,而不仅仅是 clickhouse-server。 +数据包在通过网络接口接收时丢失的字节数。这是一个系统范围的指标,包括主机上的所有进程,而不仅仅是 clickhouse-server。 ### NetworkReceiveErrors_*name* {#networkreceiveerrors_name} -通过网络接口接收数据时发生错误的次数。这是一个系统范围的指标,它包括主机上所有进程,而不仅仅是 clickhouse-server。 +通过网络接口接收时发生错误的次数。这是一个系统范围的指标,包括主机上的所有进程,而不仅仅是 clickhouse-server。 ### NetworkReceivePackets_*name* {#networkreceivepackets_name} -通过网络接口接收的网络数据包数量。这是一个系统范围的指标,它包括主机上所有进程,而不仅仅是 clickhouse-server。 +通过网络接口接收的网络数据包的数量。这是一个系统范围的指标,包括主机上的所有进程,而不仅仅是 clickhouse-server。 ### NetworkSendBytes_*name* {#networksendbytes_name} -通过网络接口发送的字节数。这是一个系统范围的指标,它包括主机上所有进程,而不仅仅是 clickhouse-server。 +通过网络接口发送的字节数。这是一个系统范围的指标,包括主机上的所有进程,而不仅仅是 clickhouse-server。 ### NetworkSendDrop_*name* {#networksenddrop_name} -在通过网络接口发送数据时丢弃的次数。这是一个系统范围的指标,它包括主机上所有进程,而不仅仅是 clickhouse-server。 +数据包在通过网络接口发送时丢失的次数。这是一个系统范围的指标,包括主机上的所有进程,而不仅仅是 clickhouse-server。 ### NetworkSendErrors_*name* {#networksenderrors_name} -在通过网络接口发送数据时发生错误(例如 TCP 重传)的次数。这是一个系统范围的指标,它包括主机上所有进程,而不仅仅是 clickhouse-server。 +在通过网络接口发送时发生错误(例如 TCP 重传)的次数。这是一个系统范围的指标,包括主机上的所有进程,而不仅仅是 clickhouse-server。 ### NetworkSendPackets_*name* {#networksendpackets_name} -通过网络接口发送的网络数据包数量。这是一个系统范围的指标,它包括主机上所有进程,而不仅仅是 clickhouse-server。 +通过网络接口发送的网络数据包的数量。这是一个系统范围的指标,包括主机上的所有进程,而不仅仅是 clickhouse-server。 ### NumberOfDatabases {#numberofdatabases} 服务器上的数据库总数。 ### NumberOfDetachedByUserParts {#numberofdetachedbyuserparts} -用户通过 `ALTER TABLE DETACH` 查询从 MergeTree 表中分离的部分的总数(与意外、损坏或被忽略的部分相对)。服务器不关心分离的部分,可以删除它们。 +由用户通过 `ALTER TABLE DETACH` 查询从 MergeTree 表中分离的部分总数(与意外、损坏或被忽略的部分相对)。服务器不关心分离的部分,它们可以被移除。 ### NumberOfDetachedParts {#numberofdetachedparts} -从 MergeTree 表中分离的部分的总数。用户可以通过 `ALTER TABLE DETACH` 查询分离部分,或服务器本身因部分损坏、意外或不需要而分离部分。服务器不关心分离的部分,可以删除它们。 +从 MergeTree 表中分离的部分总数。部分可以通过用户用 `ALTER TABLE DETACH` 查询分离,也可以由服务器本身在部分损坏、意外或不需要时进行分离。服务器不关心分离的部分,它们可以被移除。 ### NumberOfTables {#numberoftables} -服务器上所有数据库中表的总数,排除那些无法包含 MergeTree 表的数据库。排除的数据库引擎是那些按需生成表集的,例如 `Lazy`、`MySQL`、`PostgreSQL`、`SQlite`。 +跨服务器上的数据库的总表数,不包括不能包含 MergeTree 表的数据库。被排除的数据库引擎是按需生成表集的,例如 `Lazy`、`MySQL`、`PostgreSQL`、`SQlite`。 ### OSContextSwitches {#oscontextswitches} -系统在主机上经历的上下文切换数量。这是一个系统范围的指标,它包括主机上所有进程,而不仅仅是 clickhouse-server。 +系统在主机上经历的上下文切换的数量。这是一个系统范围的指标,包括主机上的所有进程,而不仅仅是 clickhouse-server。 ### OSGuestNiceTime {#osguestnicetime} -在 Linux 内核控制下为来宾操作系统运行虚拟 CPU 所花费的时间的比例,当来宾设置为更高的优先级时(见 `man procfs`)。这是一个系统范围的指标,它包括主机上所有进程,而不仅仅是 clickhouse-server。此指标与 ClickHouse 无关,但仍然存在以便完整性。单个 CPU 核心的值将在 [0..1] 的区间内。所有 CPU 核心的值计算为它们的总和 [0..num cores]。 +在 Linux 内核控制下运行的来宾操作系统的虚拟 CPU 中运行所花费的时间比率,当来宾的优先级设置更高时(见 `man procfs`)。这是一个系统范围的指标,包括主机上的所有进程,而不仅仅是 clickhouse-server。此指标与 ClickHouse 无关,但仍然存在以实现完整性。单个 CPU 核心的值将在 [0..1] 的范围内。所有 CPU 核心的值是跨它们的总和 [0..核心数] 计算的。 ### OSGuestNiceTimeCPU_*N* {#osguestnicetimecpu_n} -在 Linux 内核控制下为来宾操作系统运行虚拟 CPU 所花费的时间的比例,当来宾设置为更高的优先级时(见 `man procfs`)。这是一个系统范围的指标,它包括主机上所有进程,而不仅仅是 clickhouse-server。此指标与 ClickHouse 无关,但仍然存在以便完整性。单个 CPU 核心的值将在 [0..1] 的区间内。所有 CPU 核心的值计算为它们的总和 [0..num cores]。 +在 Linux 内核控制下运行的来宾操作系统的虚拟 CPU 中运行所花费的时间比率,当来宾的优先级设置更高时(见 `man procfs`)。这是一个系统范围的指标,包括主机上的所有进程,而不仅仅是 clickhouse-server。此指标与 ClickHouse 无关,但仍然存在以实现完整性。单个 CPU 核心的值将在 [0..1] 的范围内。所有 CPU 核心的值是跨它们的总和 [0..核心数] 计算的。 ### OSGuestNiceTimeNormalized {#osguestnicetimenormalized} -该值类似于 `OSGuestNiceTime`,但是除以 CPU 核心数量,以便在 [0..1] 区间内进行度量,而不考虑核心数量。这使您能够在集群中的多个服务器之间平均此指标的值,即使核心数量不均匀,仍然获得平均资源利用率指标。 +该值类似于 `OSGuestNiceTime`,但除以 CPU 核心的数量,以便在 [0..1] 的范围内进行测量,而不考虑核心的数量。这允许您在集群中平均此指标的值,即使核心数量不均匀,仍可获得平均资源利用率指标。 ### OSGuestTime {#osguesttime} -在 Linux 内核控制下为来宾操作系统运行虚拟 CPU 所花费的时间的比例(见 `man procfs`)。这是一个系统范围的指标,它包括主机上所有进程,而不仅仅是 clickhouse-server。此指标与 ClickHouse 无关,但仍然存在以便完整性。单个 CPU 核心的值将在 [0..1] 的区间内。所有 CPU 核心的值计算为它们的总和 [0..num cores]。 +在 Linux 内核控制下运行的来宾操作系统中运行虚拟 CPU 所花费的时间比率(见 `man procfs`)。这是一个系统范围的指标,包括主机上的所有进程,而不仅仅是 clickhouse-server。此指标与 ClickHouse 无关,但仍然存在以实现完整性。单个 CPU 核心的值将在 [0..1] 的范围内。所有 CPU 核心的值是跨它们的总和 [0..核心数] 计算的。 ### OSGuestTimeCPU_*N* {#osguesttimecpu_n} -在 Linux 内核控制下为来宾操作系统运行虚拟 CPU 所花费的时间的比例(见 `man procfs`)。这是一个系统范围的指标,它包括主机上所有进程,而不仅仅是 clickhouse-server。此指标与 ClickHouse 无关,但仍然存在以便完整性。单个 CPU 核心的值将在 [0..1] 的区间内。所有 CPU 核心的值计算为它们的总和 [0..num cores]。 +在 Linux 内核控制下运行的来宾操作系统中运行虚拟 CPU 所花费的时间比率(见 `man procfs`)。这是一个系统范围的指标,包括主机上的所有进程,而不仅仅是 clickhouse-server。此指标与 ClickHouse 无关,但仍然存在以实现完整性。单个 CPU 核心的值将在 [0..1] 的范围内。所有 CPU 核心的值是跨它们的总和 [0..核心数] 计算的。 ### OSGuestTimeNormalized {#osguesttimenormalized} -该值类似于 `OSGuestTime`,但是除以 CPU 核心数量,以便在 [0..1] 区间内进行度量,而不考虑核心数量。这使您能够在集群中的多个服务器之间平均此指标的值,即使核心数量不均匀,仍然获得平均资源利用率指标。 +该值类似于 `OSGuestTime`,但除以 CPU 核心的数量,以便在 [0..1] 的范围内进行测量,而不考虑核心的数量。这允许您在集群中平均此指标的值,即使核心数量不均匀,仍可获得平均资源利用率指标。 ### OSIOWaitTime {#osiowaittime} - CPU 核心未运行代码但操作系统内核未在该 CPU 上运行其他任何进程,因为这些进程在等待 IO 的比例。 这是一个系统范围的指标,它包括主机上所有进程,而不仅仅是 clickhouse-server。 单个 CPU 核心的值将在 [0..1] 的区间内。 所有 CPU 核心的值计算为它们的总和 [0..num cores]。 +CPU 核心未运行代码而操作系统内核未在此 CPU 上运行其他进程的时间比率,因为进程在等待 IO。这是一个系统范围的指标,包括主机上的所有进程,而不仅仅是 clickhouse-server。单个 CPU 核心的值将在 [0..1] 的范围内。所有 CPU 核心的值是跨它们的总和 [0..核心数] 计算的。 ### OSIOWaitTimeCPU_*N* {#osiowaittimecpu_n} - CPU 核心未运行代码但操作系统内核未在该 CPU 上运行其他任何进程,因为这些进程在等待 IO 的比例。 这是一个系统范围的指标,它包括主机上所有进程,而不仅仅是 clickhouse-server。 单个 CPU 核心的值将在 [0..1] 的区间内。 所有 CPU 核心的值计算为它们的总和 [0..num cores]。 +CPU 核心未运行代码而操作系统内核未在此 CPU 上运行其他进程的时间比率,因为进程在等待 IO。这是一个系统范围的指标,包括主机上的所有进程,而不仅仅是 clickhouse-server。单个 CPU 核心的值将在 [0..1] 的范围内。所有 CPU 核心的值是跨它们的总和 [0..核心数] 计算的。 ### OSIOWaitTimeNormalized {#osiowaittimenormalized} -该值类似于 `OSIOWaitTime`,但是除以 CPU 核心数量,以便在 [0..1] 区间内进行度量,而不考虑核心数量。这使您能够在集群中的多个服务器之间平均此指标的值,即使核心数量不均匀,仍然获得平均资源利用率指标。 +该值类似于 `OSIOWaitTime`,但除以 CPU 核心的数量,以便在 [0..1] 的范围内进行测量,而不考虑核心的数量。这允许您在集群中平均此指标的值,即使核心数量不均匀,仍可获得平均资源利用率指标。 ### OSIdleTime {#osidletime} -CPU 核心在操作系统内核的角度下处于闲置状态(甚至不准备运行等待 IO 的进程)的比例。这是一个系统范围的指标,它包括主机上所有进程,而不仅仅是 clickhouse-server。这不包括 CPU 因 CPU 内部原因(内存负载、管道延迟、分支误预测、运行其他 SMT 核心)而未充分利用的时间。单个 CPU 核心的值将在 [0..1] 的区间内。所有 CPU 核心的值计算为它们的总和 [0..num cores]。 +CPU 核心处于空闲状态(甚至没有准备好运行等待 IO 的进程)从操作系统内核的观点来看花费的时间比率。这是一个系统范围的指标,包括主机上的所有进程,而不仅仅是 clickhouse-server。该值不包括 CPU 未充分利用的时间,这是由于 CPU 内部的原因(内存负载、流水线停滞、分支误预测、运行其他 SMT 核心)。单个 CPU 核心的值将在 [0..1] 的范围内。所有 CPU 核心的值是跨它们的总和 [0..核心数] 计算的。 ### OSIdleTimeCPU_*N* {#osidletimecpu_n} -CPU 核心在操作系统内核的角度下处于闲置状态(甚至不准备运行等待 IO 的进程)的比例。这是一个系统范围的指标,它包括主机上所有进程,而不仅仅是 clickhouse-server。这不包括 CPU 因 CPU 内部原因(内存负载、管道延迟、分支误预测、运行其他 SMT 核心)而未充分利用的时间。单个 CPU 核心的值将在 [0..1] 的区间内。所有 CPU 核心的值计算为它们的总和 [0..num cores]。 +CPU 核心处于空闲状态(甚至没有准备好运行等待 IO 的进程)从操作系统内核的观点来看花费的时间比率。这是一个系统范围的指标,包括主机上的所有进程,而不仅仅是 clickhouse-server。该值不包括 CPU 未充分利用的时间,这是由于 CPU 内部的原因(内存负载、流水线停滞、分支误预测、运行其他 SMT 核心)。单个 CPU 核心的值将在 [0..1] 的范围内。所有 CPU 核心的值是跨它们的总和 [0..核心数] 计算的。 ### OSIdleTimeNormalized {#osidletimenormalized} -该值类似于 `OSIdleTime`,但是除以 CPU 核心数量,以便在 [0..1] 区间内进行度量,而不考虑核心数量。这使您能够在集群中的多个服务器之间平均此指标的值,即使核心数量不均匀,仍然获得平均资源利用率指标。 +该值类似于 `OSIdleTime`,但除以 CPU 核心的数量,以便在 [0..1] 的范围内进行测量,而不考虑核心的数量。这允许您在集群中平均此指标的值,即使核心数量不均匀,仍可获得平均资源利用率指标。 ### OSInterrupts {#osinterrupts} -主机上的中断数量。这是一个系统范围的指标,它包括主机上所有进程,而不仅仅是 clickhouse-server。 +主机上的中断数量。这是一个系统范围的指标,包括主机上的所有进程,而不仅仅是 clickhouse-server。 ### OSIrqTime {#osirqtime} -用于运行硬件中断请求的 CPU 平均占用时间。 这是一个系统范围的指标,它包括主机上所有进程,而不仅仅是 clickhouse-server。 该指标的高值可能指示硬件配置错误或非常高的网络负载。 单个 CPU 核心的值将在 [0..1] 的区间内。 所有 CPU 核心的值计算为它们的总和 [0..num cores]。 +用于在 CPU 上运行硬件中断请求所花费的时间比率。这是一个系统范围的指标,包括主机上的所有进程,而不仅仅是 clickhouse-server。此指标的高值可能表示硬件配置不当或网络负载非常高。单个 CPU 核心的值将在 [0..1] 的范围内。所有 CPU 核心的值是跨它们的总和 [0..核心数] 计算的。 ### OSIrqTimeCPU_*N* {#osirqtimecpu_n} -用于运行硬件中断请求的 CPU 平均占用时间。 这是一个系统范围的指标,它包括主机上所有进程,而不仅仅是 clickhouse-server。 该指标的高值可能指示硬件配置错误或非常高的网络负载。 单个 CPU 核心的值将在 [0..1] 的区间内。 所有 CPU 核心的值计算为它们的总和 [0..num cores]。 +用于在 CPU 上运行硬件中断请求所花费的时间比率。这是一个系统范围的指标,包括主机上的所有进程,而不仅仅是 clickhouse-server。此指标的高值可能表示硬件配置不当或网络负载非常高。单个 CPU 核心的值将在 [0..1] 的范围内。所有 CPU 核心的值是跨它们的总和 [0..核心数] 计算的。 ### OSIrqTimeNormalized {#osirqtimenormalized} -该值类似于 `OSIrqTime`,但是除以 CPU 核心数量,以便在 [0..1] 区间内进行度量,而不考虑核心数量。这使您能够在集群中的多个服务器之间平均此指标的值,即使核心数量不均匀,仍然获得平均资源利用率指标。 +该值类似于 `OSIrqTime`,但除以 CPU 核心的数量,以便在 [0..1] 的范围内进行测量,而不考虑核心的数量。这允许您在集群中平均此指标的值,即使核心数量不均匀,仍可获得平均资源利用率指标。 ### OSMemoryAvailable {#osmemoryavailable} -可供程序使用的内存量(字节)。这与 `OSMemoryFreePlusCached` 指标极为相似。这是一个系统范围的指标,它包括主机上所有进程,而不仅仅是 clickhouse-server。 +可供程序使用的内存量(以字节为单位)。这与 `OSMemoryFreePlusCached` 指标非常相似。这是一个系统范围的指标,包括主机上的所有进程,而不仅仅是 clickhouse-server。 ### OSMemoryBuffers {#osmemorybuffers} -操作系统内核缓冲区使用的内存量(字节)。这通常应较小,较大值可能表明操作系统配置错误。这是一个系统范围的指标,它包括主机上所有进程,而不仅仅是 clickhouse-server。 +操作系统内核缓冲区使用的内存量(以字节为单位)。这通常应该很小,较大的值可能表示操作系统配置不当。这是一个系统范围的指标,包括主机上的所有进程,而不仅仅是 clickhouse-server。 ### OSMemoryCached {#osmemorycached} -操作系统页缓存使用的内存量(字节)。通常,几乎所有可用内存被操作系统页缓存使用 - 该指标的高值是正常且预期的。这是一个系统范围的指标,它包括主机上所有进程,而不仅仅是 clickhouse-server。 +操作系统页面缓存使用的内存量(以字节为单位)。通常,几乎所有可用内存都被操作系统页面缓存使用 - 此指标的高值是正常和预期的。这是一个系统范围的指标,包括主机上的所有进程,而不仅仅是 clickhouse-server。 ### OSMemoryFreePlusCached {#osmemoryfreepluscached} -主机系统上可用的空闲内存加上操作系统页缓存内存(字节)。此内存可供程序使用。该值与 `OSMemoryAvailable` 非常相似。这是一个系统范围的指标,它包括主机上所有进程,而不仅仅是 clickhouse-server。 +主机系统中未使用的内存加上操作系统页面缓存内存(以字节为单位)。此内存可供程序使用。该值应与 `OSMemoryAvailable` 非常相似。这是一个系统范围的指标,包括主机上的所有进程,而不仅仅是 clickhouse-server。 ### OSMemoryFreeWithoutCached {#osmemoryfreewithoutcached} -主机系统上可用的空闲内存(字节)。这不包括操作系统页缓存使用的内存(字节)。页缓存内存也可供程序使用,因此可以让该指标的值产生一些混淆。请改用 `OSMemoryAvailable` 指标。此外,我们还提供 `OSMemoryFreePlusCached` 指标,应该与 OSMemoryAvailable 有一定相似性。另请参阅 https://www.linuxatemyram.com/。这是一个系统范围的指标,它包括主机上所有进程,而不仅仅是 clickhouse-server。 +主机系统中未使用的内存量(以字节为单位)。这不包括操作系统页面缓存使用的内存(以字节为单位)。页面缓存内存也可供程序使用,因此此指标的值可能会令人困惑。请改为查看 `OSMemoryAvailable` 指标。为方便起见,我们还提供 `OSMemoryFreePlusCached` 指标,该指标应与 OSMemoryAvailable 相似。另请参见 https://www.linuxatemyram.com/。这是一个系统范围的指标,包括主机上的所有进程,而不仅仅是 clickhouse-server。 ### OSMemoryTotal {#osmemorytotal} -主机系统的总内存量(字节)。 +主机系统中的总内存量(以字节为单位)。 ### OSNiceTime {#osnicetime} -CPU 核心运行用户空间代码并具有更高优先级的时间比例。这是一个系统范围的指标,它包括主机上所有进程,而不仅仅是 clickhouse-server。单个 CPU 核心的值将在 [0..1] 的区间内。所有 CPU 核心的值计算为它们的总和 [0..num cores]。 +CPU 核心运行用户空间代码的时间比率,具有更高的优先级。这是一个系统范围的指标,包括主机上的所有进程,而不仅仅是 clickhouse-server。单个 CPU 核心的值将在 [0..1] 的范围内。所有 CPU 核心的值是跨它们的总和 [0..核心数] 计算的。 ### OSNiceTimeCPU_*N* {#osnicetimecpu_n} -CPU 核心运行用户空间代码并具有更高优先级的时间比例。这是一个系统范围的指标,它包括主机上所有进程,而不仅仅是 clickhouse-server。单个 CPU 核心的值将在 [0..1] 的区间内。所有 CPU 核心的值计算为它们的总和 [0..num cores]。 +CPU 核心运行用户空间代码的时间比率,具有更高的优先级。这是一个系统范围的指标,包括主机上的所有进程,而不仅仅是 clickhouse-server。单个 CPU 核心的值将在 [0..1] 的范围内。所有 CPU 核心的值是跨它们的总和 [0..核心数] 计算的。 ### OSNiceTimeNormalized {#osnicetimenormalized} -该值类似于 `OSNiceTime`,但是除以 CPU 核心数量,以便在 [0..1] 区间内进行度量,而不考虑核心数量。这使您能够在集群中的多个服务器之间平均此指标的值,即使核心数量不均匀,仍然获得平均资源利用率指标。 +该值类似于 `OSNiceTime`,但除以 CPU 核心的数量,以便在 [0..1] 的范围内进行测量,而不考虑核心的数量。这允许您在集群中平均此指标的值,即使核心数量不均匀,仍可获得平均资源利用率指标。 ### OSOpenFiles {#osopenfiles} -主机上打开的文件总数。这是一个系统范围的指标,它包括主机上所有进程,而不仅仅是 clickhouse-server。 +主机上的打开文件总数。这是一个系统范围的指标,包括主机上的所有进程,而不仅仅是 clickhouse-server。 ### OSProcessesBlocked {#osprocessesblocked} -等待 I/O 完成而被阻塞的线程数(`man procfs`)。这是一个系统范围的指标,它包括主机上所有进程,而不仅仅是 clickhouse-server。 +被阻塞等待 I/O 完成的线程数量(`man procfs`)。这是一个系统范围的指标,包括主机上的所有进程,而不仅仅是 clickhouse-server。 ### OSProcessesCreated {#osprocessescreated} -创建的进程数量。这是一个系统范围的指标,它包括主机上所有进程,而不仅仅是 clickhouse-server。 +创建的进程数量。这是一个系统范围的指标,包括主机上的所有进程,而不仅仅是 clickhouse-server。 ### OSProcessesRunning {#osprocessesrunning} -操作系统中可运行的(正在运行或准备运行的)线程数量。这是一个系统范围的指标,它包括主机上所有进程,而不仅仅是 clickhouse-server。 +操作系统中可运行(正在运行或准备运行)线程的数量。这是一个系统范围的指标,包括主机上的所有进程,而不仅仅是 clickhouse-server。 ### OSSoftIrqTime {#ossoftirqtime} -在 CPU 上运行软件中断请求所花费的时间比例。这是一个系统范围的指标,它包括主机上所有进程,而不仅仅是 clickhouse-server。该指标的高值可能指示系统上运行的软件效率低下。单个 CPU 核心的值将在 [0..1] 的区间内。所有 CPU 核心的值计算为它们的总和 [0..num cores]。 +用于在 CPU 上运行软件中断请求所花费的时间比率。这是一个系统范围的指标,包括主机上的所有进程,而不仅仅是 clickhouse-server。此指标的高值可能表示系统上运行不高效的软件。单个 CPU 核心的值将在 [0..1] 的范围内。所有 CPU 核心的值是跨它们的总和 [0..核心数] 计算的。 ### OSSoftIrqTimeCPU_*N* {#ossoftirqtimecpu_n} -在 CPU 上运行软件中断请求所花费的时间比例。这是一个系统范围的指标,它包括主机上所有进程,而不仅仅是 clickhouse-server。该指标的高值可能指示系统上运行的软件效率低下。单个 CPU 核心的值将在 [0..1] 的区间内。所有 CPU 核心的值计算为它们的总和 [0..num cores]。 - +用于在 CPU 上运行软件中断请求所花费的时间比率。这是一个系统范围的指标,包括主机上的所有进程,而不仅仅是 clickhouse-server。此指标的高值可能表示系统上运行不高效的软件。单个 CPU 核心的值将在 [0..1] 的范围内。所有 CPU 核心的值是跨它们的总和 [0..核心数] 计算的。 ### OSSoftIrqTimeNormalized {#ossoftirqtimenormalized} -该值类似于 `OSSoftIrqTime`,但被处理为 CPU 核心数量的商,以便在 [0..1] 区间内测量,而不管核心数量。这使您能够在集群中的多个服务器之间对该指标的值进行平均,即使核心数量不均匀,仍然可以得到平均资源利用率指标。 +该值类似于 `OSSoftIrqTime`,但除以 CPU 核心的数量,以便在 [0..1] 的范围内进行测量,而不考虑核心的数量。这允许您在集群中平均此指标的值,即使核心数量不均匀,仍可获得平均资源利用率指标。 ### OSStealTime {#osstealtime} -在虚拟化环境中,CPU 消耗在其他操作系统中的时间比例。这是一个系统范围的指标,包括主机机器上的所有进程,而不仅仅是 clickhouse-server。并非所有虚拟化环境都提供该指标,实际上大多数都没有。单个 CPU 核心的值将处于 [0..1] 区间内。所有 CPU 核心的值通过求和计算得出 [0..num cores]。 +在虚拟化环境中,CPU 花费在其他操作系统上的时间比率。这是一个系统范围的指标,包括主机上的所有进程,而不仅仅是 clickhouse-server。并非所有虚拟化环境都提供此指标,而大多数都不提供。单个 CPU 核心的值将在 [0..1] 的范围内。所有 CPU 核心的值是跨它们的总和 [0..核心数] 计算的。 ### OSStealTimeCPU_*N* {#osstealtimecpu_n} -在虚拟化环境中,CPU 消耗在其他操作系统中的时间比例。这是一个系统范围的指标,包括主机机器上的所有进程,而不仅仅是 clickhouse-server。并非所有虚拟化环境都提供该指标,实际上大多数都没有。单个 CPU 核心的值将处于 [0..1] 区间内。所有 CPU 核心的值通过求和计算得出 [0..num cores]。 +CPU在虚拟化环境中花费在其他操作系统上的时间比例。这是一个系统范围的指标,包括主机上的所有进程,而不仅仅是clickhouse-server。并不是每个虚拟化环境都提供这个指标,大多数都不提供。单个CPU核心的值将在区间[0..1]内。所有CPU核心的值是通过对它们进行求和计算得出的[0..num cores]。 ### OSStealTimeNormalized {#osstealtimenormalized} -该值类似于 `OSStealTime`,但被处理为 CPU 核心数量的商,以便在 [0..1] 区间内测量,而不管核心数量。这使您能够在集群中的多个服务器之间对该指标的值进行平均,即使核心数量不均匀,仍然可以得到平均资源利用率指标。 +该值与`OSStealTime`类似,但除以要测量的CPU核心数量,使其在[0..1]区间内,无论核心数量如何。这使您可以在集群中跨多个服务器平均此指标的值,即使核心数量不均匀,仍然可以获得平均资源利用率指标。 ### OSSystemTime {#ossystemtime} -CPU 核心运行操作系统内核(系统)代码的时间比例。这是一个系统范围的指标,包括主机机器上的所有进程,而不仅仅是 clickhouse-server。单个 CPU 核心的值将处于 [0..1] 区间内。所有 CPU 核心的值通过求和计算得出 [0..num cores]。 +CPU核心运行操作系统内核(系统)代码的时间比例。这是一个系统范围的指标,包括主机上的所有进程,而不仅仅是clickhouse-server。单个CPU核心的值将在区间[0..1]内。所有CPU核心的值是通过对它们进行求和计算得出的[0..num cores]。 ### OSSystemTimeCPU_*N* {#ossystemtimecpu_n} -CPU 核心运行操作系统内核(系统)代码的时间比例。这是一个系统范围的指标,包括主机机器上的所有进程,而不仅仅是 clickhouse-server。单个 CPU 核心的值将处于 [0..1] 区间内。所有 CPU 核心的值通过求和计算得出 [0..num cores]。 +CPU核心运行操作系统内核(系统)代码的时间比例。这是一个系统范围的指标,包括主机上的所有进程,而不仅仅是clickhouse-server。单个CPU核心的值将在区间[0..1]内。所有CPU核心的值是通过对它们进行求和计算得出的[0..num cores]。 ### OSSystemTimeNormalized {#ossystemtimenormalized} -该值类似于 `OSSystemTime`,但被处理为 CPU 核心数量的商,以便在 [0..1] 区间内测量,而不管核心数量。这使您能够在集群中的多个服务器之间对该指标的值进行平均,即使核心数量不均匀,仍然可以得到平均资源利用率指标。 +该值与`OSSystemTime`类似,但除以CPU核心的数量,以便在[0..1]区间内测量,无论核心数量如何。这允许您在集群中跨多个服务器平均此指标的值,即使核心数量不均匀,仍然可以获得平均资源利用率指标。 ### OSThreadsRunnable {#osthreadsrunnable} -被操作系统内核调度器视为可运行的线程总数。 +操作系统内核调度程序认为的“可运行”线程的总数。 ### OSThreadsTotal {#osthreadstotal} -被操作系统内核调度器视为线程的总数。 +操作系统内核调度程序认为的线程总数。 ### OSUptime {#osuptime} -主机服务器(运行 ClickHouse 的机器)的正常运行时间,单位为秒。 +主机服务器(运行ClickHouse的机器)的正常运行时间,以秒为单位。 ### OSUserTime {#osusertime} -CPU 核心运行用户空间代码的时间比例。这是一个系统范围的指标,包括主机机器上的所有进程,而不仅仅是 clickhouse-server。这也包括因 CPU 内部原因(内存加载、流水线停顿、分支预测错误、运行另一个 SMT 核心)导致的 CPU 低利用率的时间。单个 CPU 核心的值将处于 [0..1] 区间内。所有 CPU 核心的值通过求和计算得出 [0..num cores]。 +CPU核心运行用户空间代码的时间比例。这是一个系统范围的指标,包括主机上的所有进程,而不仅仅是clickhouse-server。这还包括CPU由于CPU内部原因(内存加载、管道停顿、分支预测错误、运行另一个SMT核心)而未充分利用的时间。单个CPU核心的值将在区间[0..1]内。所有CPU核心的值是通过对它们进行求和计算得出的[0..num cores]。 ### OSUserTimeCPU_*N* {#osusertimecpu_n} -CPU 核心运行用户空间代码的时间比例。这是一个系统范围的指标,包括主机机器上的所有进程,而不仅仅是 clickhouse-server。这也包括因 CPU 内部原因(内存加载、流水线停顿、分支预测错误、运行另一个 SMT 核心)导致的 CPU 低利用率的时间。单个 CPU 核心的值将处于 [0..1] 区间内。所有 CPU 核心的值通过求和计算得出 [0..num cores]。 +CPU核心运行用户空间代码的时间比例。这是一个系统范围的指标,包括主机上的所有进程,而不仅仅是clickhouse-server。这还包括CPU由于CPU内部原因(内存加载、管道停顿、分支预测错误、运行另一个SMT核心)而未充分利用的时间。单个CPU核心的值将在区间[0..1]内。所有CPU核心的值是通过对它们进行求和计算得出的[0..num cores]。 ### OSUserTimeNormalized {#osusertimenormalized} -该值类似于 `OSUserTime`,但被处理为 CPU 核心数量的商,以便在 [0..1] 区间内测量,而不管核心数量。这使您能够在集群中的多个服务器之间对该指标的值进行平均,即使核心数量不均匀,仍然可以得到平均资源利用率指标。 +该值与`OSUserTime`类似,但除以CPU核心的数量,以便在[0..1]区间内测量,无论核心数量如何。这允许您在集群中跨多个服务器平均此指标的值,即使核心数量不均匀,仍然可以获得平均资源利用率指标。 ### PostgreSQLThreads {#postgresqlthreads} -PostgreSQL 兼容协议服务器中的线程数量。 -### QueryCacheBytes {#querycachebytes} - -查询缓存的总大小(以字节为单位)。 -### QueryCacheEntries {#querycacheentries} - -查询缓存中的条目总数。 +PostgreSQL兼容协议服务器中的线程数量。 ### ReplicasMaxAbsoluteDelay {#replicasmaxabsolutedelay} -最新复制部分与尚未复制的最新数据部分之间的最大差值(以秒为单位),跨 Replicated 表。非常高的值表明某个副本没有数据。 +最新复制部分与仍需复制的最新数据部分之间的最大秒数差。高值表示没有数据的副本。 ### ReplicasMaxInsertsInQueue {#replicasmaxinsertsinqueue} -跨 Replicated 表的队列中 INSERT 操作的最大数量(尚待复制)。 +在复制表中,队列(仍需复制)中的最大INSERT操作数量。 ### ReplicasMaxMergesInQueue {#replicasmaxmergesinqueue} -跨 Replicated 表的队列中合并操作的最大数量(尚待应用)。 +在复制表中,队列(仍需应用)中的最大合并操作数量。 ### ReplicasMaxQueueSize {#replicasmaxqueuesize} -跨 Replicated 表的最大队列大小(以操作数量计算,如获取、合并)。 +在复制表中的最大队列大小(以get、merge等操作的数量计算)。 ### ReplicasMaxRelativeDelay {#replicasmaxrelativedelay} -副本延迟与同一表中最新副本的延迟之间的最大差异,跨 Replicated 表。 +副本延迟与同一表最新副本的延迟之间的最大差异,跨复制表。 ### ReplicasSumInsertsInQueue {#replicassuminsertsinqueue} -跨 Replicated 表的队列中 INSERT 操作的总和(尚待复制)。 +在复制表中,队列(仍需复制)中的INSERT操作总和。 ### ReplicasSumMergesInQueue {#replicassummergesinqueue} -跨 Replicated 表的队列中合并操作的总和(尚待应用)。 +在复制表中,队列(仍需应用)中的合并操作总和。 ### ReplicasSumQueueSize {#replicassumqueuesize} -跨 Replicated 表的总队列大小(以操作数量计算,如获取、合并)。 +在复制表中的总队列大小(以get、merge等操作的数量计算)。 ### TCPThreads {#tcpthreads} -TCP 协议(无 TLS)服务器中的线程数量。 +TCP协议服务器中的线程数量(不带TLS)。 ### Temperature_*N* {#temperature_n} -对应设备的温度,单位为 ℃。传感器可能会返回不现实的值。来源:`/sys/class/thermal` +相应设备的温度,单位为℃。传感器可能返回不现实的值。来源:`/sys/class/thermal` ### Temperature_*name* {#temperature_name} -由对应硬件监控器和相应传感器报告的温度,单位为 ℃。传感器可能会返回不现实的值。来源:`/sys/class/hwmon` +相应硬件监控器和相应传感器报告的温度,单位为℃。传感器可能返回不现实的值。来源:`/sys/class/hwmon` ### TotalBytesOfMergeTreeTables {#totalbytesofmergetreetables} -所有 MergeTree 家族表中存储的字节总量(已压缩,包括数据和索引)。 +MergeTree系列所有表中存储的总字节数(压缩后,包括数据和索引)。 ### TotalPartsOfMergeTreeTables {#totalpartsofmergetreetables} -所有 MergeTree 家族表中数据部分的总数量。大于 10,000 的数字将对服务器启动时间产生负面影响,并可能表明分区键的选择不合理。 +MergeTree系列所有表中数据部分的总数量。超过10000的数字会对服务器启动时间产生负面影响,并可能表明分区键的选择不合理。 ### TotalPrimaryKeyBytesInMemory {#totalprimarykeybytesinmemory} -主键值在内存中使用的总量(以字节为单位,仅计算活跃部分)。 +主键值所占用的总内存(以字节为单位)(仅考虑活动部分)。 ### TotalPrimaryKeyBytesInMemoryAllocated {#totalprimarykeybytesinmemoryallocated} -为主键值保留的总内存量(以字节为单位,仅计算活跃部分)。 +为主键值保留的总内存(以字节为单位)(仅考虑活动部分)。 ### TotalRowsOfMergeTreeTables {#totalrowsofmergetreetables} -所有 MergeTree 家族表中存储的行(记录)总数。 -### UncompressedCacheBytes {#uncompressedcachebytes} - -未压缩缓存的总大小(以字节为单位)。未压缩缓存通常不会提高性能,应该尽量避免使用。 -### UncompressedCacheCells {#uncompressedcachecells} - -未压缩缓存中的总条目数。每个条目代表一个解压的块数据。未压缩缓存通常不会提高性能,应该尽量避免使用。 +MergeTree系列所有表中存储的总行数(记录)。 ### Uptime {#uptime} -服务器的正常运行时间,单位为秒。包括服务器初始化期间的时间,直到接受连接。 +服务器的正常运行时间,单位为秒。包括服务器在接受连接之前初始化所花费的时间。 ### jemalloc.active {#jemallocactive} -低级内存分配器(jemalloc)的内部指标。请参见 https://jemalloc.net/jemalloc.3.html +低级内存分配器(jemalloc)的内部指标。请参阅 https://jemalloc.net/jemalloc.3.html ### jemalloc.allocated {#jemallocallocated} -低级内存分配器(jemalloc)的内部指标。请参见 https://jemalloc.net/jemalloc.3.html +低级内存分配器(jemalloc)的内部指标。请参阅 https://jemalloc.net/jemalloc.3.html ### jemalloc.arenas.all.dirty_purged {#jemallocarenasalldirty_purged} -低级内存分配器(jemalloc)的内部指标。请参见 https://jemalloc.net/jemalloc.3.html +低级内存分配器(jemalloc)的内部指标。请参阅 https://jemalloc.net/jemalloc.3.html ### jemalloc.arenas.all.muzzy_purged {#jemallocarenasallmuzzy_purged} -低级内存分配器(jemalloc)的内部指标。请参见 https://jemalloc.net/jemalloc.3.html +低级内存分配器(jemalloc)的内部指标。请参阅 https://jemalloc.net/jemalloc.3.html ### jemalloc.arenas.all.pactive {#jemallocarenasallpactive} -低级内存分配器(jemalloc)的内部指标。请参见 https://jemalloc.net/jemalloc.3.html +低级内存分配器(jemalloc)的内部指标。请参阅 https://jemalloc.net/jemalloc.3.html ### jemalloc.arenas.all.pdirty {#jemallocarenasallpdirty} -低级内存分配器(jemalloc)的内部指标。请参见 https://jemalloc.net/jemalloc.3.html +低级内存分配器(jemalloc)的内部指标。请参阅 https://jemalloc.net/jemalloc.3.html ### jemalloc.arenas.all.pmuzzy {#jemallocarenasallpmuzzy} -低级内存分配器(jemalloc)的内部指标。请参见 https://jemalloc.net/jemalloc.3.html +低级内存分配器(jemalloc)的内部指标。请参阅 https://jemalloc.net/jemalloc.3.html ### jemalloc.background_thread.num_runs {#jemallocbackground_threadnum_runs} -低级内存分配器(jemalloc)的内部指标。请参见 https://jemalloc.net/jemalloc.3.html +低级内存分配器(jemalloc)的内部指标。请参阅 https://jemalloc.net/jemalloc.3.html ### jemalloc.background_thread.num_threads {#jemallocbackground_threadnum_threads} -低级内存分配器(jemalloc)的内部指标。请参见 https://jemalloc.net/jemalloc.3.html +低级内存分配器(jemalloc)的内部指标。请参阅 https://jemalloc.net/jemalloc.3.html ### jemalloc.background_thread.run_intervals {#jemallocbackground_threadrun_intervals} -低级内存分配器(jemalloc)的内部指标。请参见 https://jemalloc.net/jemalloc.3.html +低级内存分配器(jemalloc)的内部指标。请参阅 https://jemalloc.net/jemalloc.3.html ### jemalloc.epoch {#jemallocepoch} -jemalloc (Jason Evans 的内存分配器)统计信息的内部增量更新编号,用于所有其他 `jemalloc` 指标。 +jemalloc的统计信息的内部增量更新号,用于所有其他`jemalloc`指标。 ### jemalloc.mapped {#jemallocmapped} -低级内存分配器(jemalloc)的内部指标。请参见 https://jemalloc.net/jemalloc.3.html +低级内存分配器(jemalloc)的内部指标。请参阅 https://jemalloc.net/jemalloc.3.html ### jemalloc.metadata {#jemallocmetadata} -低级内存分配器(jemalloc)的内部指标。请参见 https://jemalloc.net/jemalloc.3.html +低级内存分配器(jemalloc)的内部指标。请参阅 https://jemalloc.net/jemalloc.3.html ### jemalloc.metadata_thp {#jemallocmetadata_thp} -低级内存分配器(jemalloc)的内部指标。请参见 https://jemalloc.net/jemalloc.3.html +低级内存分配器(jemalloc)的内部指标。请参阅 https://jemalloc.net/jemalloc.3.html ### jemalloc.resident {#jemallocresident} -低级内存分配器(jemalloc)的内部指标。请参见 https://jemalloc.net/jemalloc.3.html +低级内存分配器(jemalloc)的内部指标。请参阅 https://jemalloc.net/jemalloc.3.html ### jemalloc.retained {#jemallocretained} -低级内存分配器(jemalloc)的内部指标。请参见 https://jemalloc.net/jemalloc.3.html +低级内存分配器(jemalloc)的内部指标。请参阅 https://jemalloc.net/jemalloc.3.html ### jemalloc.prof.active {#jemallocprofactive} -低级内存分配器(jemalloc)的内部指标。请参见 https://jemalloc.net/jemalloc.3.html +低级内存分配器(jemalloc)的内部指标。请参阅 https://jemalloc.net/jemalloc.3.html -**另请参见** +**参见** -- [Monitoring](../../operations/monitoring.md) — ClickHouse 监控的基本概念。 +- [Monitoring](../../operations/monitoring.md) — ClickHouse监控的基本概念。 - [system.metrics](/operations/system-tables/metrics) — 包含即时计算的指标。 -- [system.events](/operations/system-tables/events) — 包含发生过的一些事件。 -- [system.metric_log](/operations/system-tables/metric_log) — 包含 `system.metrics` 和 `system.events` 表中指标值的历史记录。 +- [system.events](/operations/system-tables/events) — 包含发生的一些事件。 +- [system.metric_log](/operations/system-tables/metric_log) — 包含来自`system.metrics`和`system.events`表的指标值历史记录。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/asynchronous_metrics.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/asynchronous_metrics.md.hash index efff05ecf45..68861e7fad7 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/asynchronous_metrics.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/asynchronous_metrics.md.hash @@ -1 +1 @@ -846e66dc7bde1be4 +bde32e52cad41a37 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/azure_queue_settings.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/azure_queue_settings.md index 72f6e06c43a..e51303a050a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/azure_queue_settings.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/azure_queue_settings.md @@ -1,13 +1,15 @@ --- -'description': '系统表,包含有关 AzureQueue 表设置的信息。可通过服务器版本 `24.10` 获取。' +'description': '系统表,包含有关AzureQueue表设置的信息。从服务器版本 `24.10` 开始可用。' 'keywords': - 'system table' - 'azure_queue_settings' 'slug': '/operations/system-tables/azure_queue_settings' 'title': 'system.azure_queue_settings' +'doc_type': 'reference' --- -包含有关 [AzureQueue](../../engines/table-engines/integrations/azure-queue.md) 表的设置的信息。可从 `24.10` 服务器版本开始使用。 +包含有关 [AzureQueue](../../engines/table-engines/integrations/azure-queue.md) 表设置的信息。 +在 `24.10` 服务器版本中可用。 列: @@ -15,9 +17,9 @@ - `table` ([String](../../sql-reference/data-types/string.md)) — 数据库名。 - `name` ([String](../../sql-reference/data-types/string.md)) — 设置名称。 - `value` ([String](../../sql-reference/data-types/string.md)) — 设置值。 -- `changed` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) — 设置是否在配置中显式定义或显式更改。 +- `changed` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) — 设置是否在配置中被显式定义或显式更改。 - `description` ([String](../../sql-reference/data-types/string.md)) — 设置描述。 -- `alterable` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) — 显示设置是否可以通过 `ALTER TABLE ... MODIFY SETTING` 更改。 - - `0` — 当前用户可以更改该设置。 - - `1` — 当前用户不能更改该设置。 +- `alterable` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) — 显示是否可以通过 `ALTER TABLE ... MODIFY SETTING` 更改设置。 + - `0` — 当前用户可以更改该设置。 + - `1` — 当前用户不能更改该设置。 - `type` ([String](../../sql-reference/data-types/string.md)) — 设置类型(实现特定的字符串值)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/azure_queue_settings.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/azure_queue_settings.md.hash index a9b5e6e8fa9..e4096f1af61 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/azure_queue_settings.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/azure_queue_settings.md.hash @@ -1 +1 @@ -9c766ee376b3be1b +69d31d6092e18470 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/backup_log.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/backup_log.md index e931f3a120b..075de854681 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/backup_log.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/backup_log.md @@ -1,10 +1,11 @@ --- -'description': '系统表,包含有关 `BACKUP` 和 `RESTORE` 操作的信息的日志条目。' +'description': '系统表包含有关 `BACKUP` 和 `RESTORE` 操作的信息的日志条目。' 'keywords': - 'system table' - 'backup_log' 'slug': '/operations/system-tables/backup_log' 'title': 'system.backup_log' +'doc_type': 'reference' --- import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_system_table_cloud.md'; @@ -14,33 +15,33 @@ import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/curre -包含关于 `BACKUP` 和 `RESTORE` 操作的信息的日志条目。 +包含有关 `BACKUP` 和 `RESTORE` 操作的信息的日志条目。 列: -- `hostname` ([LowCardinality(String)](../../sql-reference/data-types/string.md)) — 执行查询的服务器主机名。 +- `hostname` ([LowCardinality(String)](../../sql-reference/data-types/string.md)) — 执行查询的服务器的主机名。 - `event_date` ([Date](../../sql-reference/data-types/date.md)) — 条目的日期。 - `event_time` ([DateTime](../../sql-reference/data-types/datetime.md)) — 条目的日期和时间。 -- `event_time_microseconds` ([DateTime64](../../sql-reference/data-types/datetime64.md)) — 条目的时间(微秒精度)。 +- `event_time_microseconds` ([DateTime64](../../sql-reference/data-types/datetime64.md)) — 带有微秒精度的条目时间。 - `id` ([String](../../sql-reference/data-types/string.md)) — 备份或恢复操作的标识符。 - `name` ([String](../../sql-reference/data-types/string.md)) — 备份存储的名称(`FROM` 或 `TO` 子句的内容)。 - `status` ([Enum8](../../sql-reference/data-types/enum.md)) — 操作状态。可能的值: - - `'CREATING_BACKUP'` - - `'BACKUP_CREATED'` - - `'BACKUP_FAILED'` - - `'RESTORING'` - - `'RESTORED'` - - `'RESTORE_FAILED'` -- `error` ([String](../../sql-reference/data-types/string.md)) — 失败操作的错误消息(成功操作返回空字符串)。 + - `'CREATING_BACKUP'` + - `'BACKUP_CREATED'` + - `'BACKUP_FAILED'` + - `'RESTORING'` + - `'RESTORED'` + - `'RESTORE_FAILED'` +- `error` ([String](../../sql-reference/data-types/string.md)) — 失败操作的错误消息(成功操作为空字符串)。 - `start_time` ([DateTime](../../sql-reference/data-types/datetime.md)) — 操作的开始时间。 - `end_time` ([DateTime](../../sql-reference/data-types/datetime.md)) — 操作的结束时间。 -- `num_files` ([UInt64](/sql-reference/data-types/int-uint#integer-ranges)) — 备份中存储的文件数量。 -- `total_size` ([UInt64](/sql-reference/data-types/int-uint#integer-ranges)) — 备份中存储的文件的总大小。 -- `num_entries` ([UInt64](/sql-reference/data-types/int-uint#integer-ranges)) — 备份中的条目数量,即如果备份以文件夹形式存储,则为文件夹中的文件数量;如果备份以归档形式存储,则为归档中的文件数量。如果是增量备份或包含空文件或重复文件,则与 `num_files` 不同。以下始终成立:`num_entries <= num_files`。 +- `num_files` ([UInt64](/sql-reference/data-types/int-uint#integer-ranges)) — 存储在备份中的文件数量。 +- `total_size` ([UInt64](/sql-reference/data-types/int-uint#integer-ranges)) — 存储在备份中的文件总大小。 +- `num_entries` ([UInt64](/sql-reference/data-types/int-uint#integer-ranges)) — 备份中的条目数量,即如果备份存储为文件夹,则文件夹内的文件数量;如果备份存储为归档,则归档内的文件数量。在增量备份或包含空文件或重复文件时,`num_entries` 不等于 `num_files`。以下始终成立:`num_entries <= num_files`。 - `uncompressed_size` ([UInt64](/sql-reference/data-types/int-uint#integer-ranges)) — 备份的未压缩大小。 -- `compressed_size` ([UInt64](/sql-reference/data-types/int-uint#integer-ranges)) — 备份的压缩大小。如果备份不是以归档形式存储,则等于 `uncompressed_size`。 -- `files_read` ([UInt64](/sql-reference/data-types/int-uint#integer-ranges)) — 恢复操作期间读取的文件数量。 -- `bytes_read` ([UInt64](/sql-reference/data-types/int-uint#integer-ranges)) — 恢复操作期间读取的文件的总大小。 +- `compressed_size` ([UInt64](/sql-reference/data-types/int-uint#integer-ranges)) — 备份的压缩大小。如果备份未存储为归档,则等于 `uncompressed_size`。 +- `files_read` ([UInt64](/sql-reference/data-types/int-uint#integer-ranges)) — 在恢复操作中读取的文件数量。 +- `bytes_read` ([UInt64](/sql-reference/data-types/int-uint#integer-ranges)) — 在恢复操作中读取的文件的总大小。 **示例** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/backup_log.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/backup_log.md.hash index e9fe1afb4b4..597c812266e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/backup_log.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/backup_log.md.hash @@ -1 +1 @@ -e18611f7d7c0f8cb +86876ca4d2d931c0 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/blob_storage_log.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/blob_storage_log.md index d810b20a0d3..bf900dd4feb 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/blob_storage_log.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/blob_storage_log.md @@ -1,44 +1,45 @@ --- -'description': '系统表包含记录条目,旨在提供有关各种 blob 存储操作的信息,例如上传和删除。' +'description': '系统表包含有关各种 blob 存储操作(如上传和删除)的日志条目信息。' 'keywords': - 'system table' - 'blob_storage_log' 'slug': '/operations/system-tables/blob_storage_log' 'title': 'system.blob_storage_log' +'doc_type': 'reference' --- import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_system_table_cloud.md'; -包含关于各种BLOB存储操作(如上传和删除)的日志条目。 +包含有关各种 blob 存储操作(例如上传和删除)的日志条目。 列: -- `hostname` ([LowCardinality(String)](../../sql-reference/data-types/string.md)) — 执行查询的服务器的主机名。 +- `hostname` ([LowCardinality(String)](../../sql-reference/data-types/string.md)) — 执行查询的服务器主机名。 - `event_date` ([Date](../../sql-reference/data-types/date.md)) — 事件的日期。 - `event_time` ([DateTime](../../sql-reference/data-types/datetime.md)) — 事件的时间。 -- `event_time_microseconds` ([DateTime64](../../sql-reference/data-types/datetime64.md)) — 事件的时间,精确到微秒。 +- `event_time_microseconds` ([DateTime64](../../sql-reference/data-types/datetime64.md)) — 事件的时间,微秒精度。 - `event_type` ([Enum8](../../sql-reference/data-types/enum.md)) — 事件的类型。可能的值: - - `'Upload'` - - `'Delete'` - - `'MultiPartUploadCreate'` - - `'MultiPartUploadWrite'` - - `'MultiPartUploadComplete'` - - `'MultiPartUploadAbort'` -- `query_id` ([String](../../sql-reference/data-types/string.md)) — 与事件相关的查询标识符(如有)。 + - `'Upload'` + - `'Delete'` + - `'MultiPartUploadCreate'` + - `'MultiPartUploadWrite'` + - `'MultiPartUploadComplete'` + - `'MultiPartUploadAbort'` +- `query_id` ([String](../../sql-reference/data-types/string.md)) — 与事件相关的查询的标识符(如果有)。 - `thread_id` ([UInt64](/sql-reference/data-types/int-uint#integer-ranges)) — 执行操作的线程标识符。 - `thread_name` ([String](../../sql-reference/data-types/string.md)) — 执行操作的线程名称。 - `disk_name` ([LowCardinality(String)](../../sql-reference/data-types/lowcardinality.md)) — 关联磁盘的名称。 - `bucket` ([String](../../sql-reference/data-types/string.md)) — 桶的名称。 - `remote_path` ([String](../../sql-reference/data-types/string.md)) — 远程资源的路径。 -- `local_path` ([String](../../sql-reference/data-types/string.md)) — 本地系统上元数据文件的路径,该文件引用远程资源。 -- `data_size` ([UInt32](/sql-reference/data-types/int-uint#integer-ranges)) — 与上传事件相关的数据大小。 -- `error` ([String](../../sql-reference/data-types/string.md)) — 与事件相关的错误消息(如有)。 +- `local_path` ([String](../../sql-reference/data-types/string.md)) — 本地系统上指向元数据文件的路径,该文件引用了远程资源。 +- `data_size` ([UInt32](/sql-reference/data-types/int-uint#integer-ranges)) — 参与上传事件的数据大小。 +- `error` ([String](../../sql-reference/data-types/string.md)) — 与事件相关的错误消息(如果有)。 **示例** -假设一个BLOB存储操作上传了一个文件,并且记录了一条事件: +假设 blob 存储操作上传一个文件,并记录了一条事件: ```sql SELECT * FROM system.blob_storage_log WHERE query_id = '7afe0450-504d-4e4b-9a80-cd9826047972' ORDER BY event_date, event_time_microseconds \G @@ -62,8 +63,8 @@ data_size: 259 error: ``` -在这个例子中,上传操作与ID为`7afe0450-504d-4e4b-9a80-cd9826047972`的`INSERT`查询相关。 本地元数据文件 `store/654/6549e8b3-d753-4447-8047-d462df6e6dbe/tmp_insert_all_1_1_0/checksums.txt` 引用存储在 `bucket1` 的磁盘 `disk_s3` 上的远程路径 `rrr/kxo/tbnqtrghgtnxkzgtcrlutwuslgawe`,文件大小为259字节。 +在此示例中,上传操作与 ID 为 `7afe0450-504d-4e4b-9a80-cd9826047972` 的 `INSERT` 查询相关联。 本地元数据文件 `store/654/6549e8b3-d753-4447-8047-d462df6e6dbe/tmp_insert_all_1_1_0/checksums.txt` 指向桶 `bucket1` 中磁盘 `disk_s3` 的远程路径 `rrr/kxo/tbnqtrghgtnxkzgtcrlutwuslgawe`,数据大小为 259 字节。 **另见** -- [外部磁盘存储数据](../../operations/storing-data.md) +- [存储数据的外部磁盘](../../operations/storing-data.md) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/blob_storage_log.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/blob_storage_log.md.hash index 64e451b4c89..ae3ee27876c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/blob_storage_log.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/blob_storage_log.md.hash @@ -1 +1 @@ -4a23ded55b0d2b6e +cc9a4f4e49551724 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/build_options.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/build_options.md index 3f1858fcc76..31d64e014ae 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/build_options.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/build_options.md @@ -5,14 +5,15 @@ 'keywords': - 'system table' - 'build_options' +'doc_type': 'reference' --- 包含有关 ClickHouse 服务器构建选项的信息。 列: -- `name` (String) — 构建选项的名称,例如 `USE_ODBC` -- `value` (String) — 构建选项的值,例如 `1` +- `name`(字符串) — 构建选项的名称,例如 `USE_ODBC` +- `value`(字符串) — 构建选项的值,例如 `1` **示例** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/build_options.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/build_options.md.hash index 4ec8b0c13f6..0db97f53589 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/build_options.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/build_options.md.hash @@ -1 +1 @@ -2deb74ebe6ba1f0c +7054c206547eb579 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/clusters.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/clusters.md index 2e9480dfb7d..8d61f9f3a27 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/clusters.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/clusters.md @@ -1,10 +1,11 @@ --- -'description': '系统表包含关于配置文件中可用的集群以及定义在其中的服务器的信息。' +'description': '系统表包含有关配置文件中可用的集群和其中定义的服务器的信息。' 'keywords': - 'system table' - 'clusters' 'slug': '/operations/system-tables/clusters' 'title': 'system.clusters' +'doc_type': 'reference' --- 包含有关配置文件中可用集群及其服务器的信息。 @@ -12,22 +13,22 @@ 列: - `cluster` ([String](../../sql-reference/data-types/string.md)) — 集群名称。 -- `shard_num` ([UInt32](../../sql-reference/data-types/int-uint.md)) — 集群中的分片编号,从 1 开始。由于集群修改可能会改变。 +- `shard_num` ([UInt32](../../sql-reference/data-types/int-uint.md)) — 集群中的分片编号,从 1 开始。可能因集群修改而改变。 - `shard_name` ([String](../../sql-reference/data-types/string.md)) — 集群中分片的名称。 -- `shard_weight` ([UInt32](../../sql-reference/data-types/int-uint.md)) — 在写入数据时分片的相对权重。 +- `shard_weight` ([UInt32](../../sql-reference/data-types/int-uint.md)) — 写入数据时分片的相对权重。 - `replica_num` ([UInt32](../../sql-reference/data-types/int-uint.md)) — 分片中的副本编号,从 1 开始。 - `host_name` ([String](../../sql-reference/data-types/string.md)) — 配置中指定的主机名。 - `host_address` ([String](../../sql-reference/data-types/string.md)) — 从 DNS 获得的主机 IP 地址。 - `port` ([UInt16](../../sql-reference/data-types/int-uint.md)) — 用于连接到服务器的端口。 -- `is_local` ([UInt8](../../sql-reference/data-types/int-uint.md)) — 表示主机是否为本地的标志。 -- `user` ([String](../../sql-reference/data-types/string.md)) — 用于连接到服务器的用户名称。 +- `is_local` ([UInt8](../../sql-reference/data-types/int-uint.md)) — 指示主机是否为本地的标志。 +- `user` ([String](../../sql-reference/data-types/string.md)) — 连接到服务器的用户名。 - `default_database` ([String](../../sql-reference/data-types/string.md)) — 默认数据库名称。 -- `errors_count` ([UInt32](../../sql-reference/data-types/int-uint.md)) — 此主机未能达到副本的次数。 -- `slowdowns_count` ([UInt32](../../sql-reference/data-types/int-uint.md)) — 在通过对冲请求建立连接时导致更改副本的慢速次数。 -- `estimated_recovery_time` ([UInt32](../../sql-reference/data-types/int-uint.md)) — 副本错误计数归零前剩余的秒数,且被视为恢复正常。 -- `database_shard_name` ([String](../../sql-reference/data-types/string.md)) — `Replicated` 数据库分片的名称(对于属于 `Replicated` 数据库的集群)。 -- `database_replica_name` ([String](../../sql-reference/data-types/string.md)) — `Replicated` 数据库副本的名称(对于属于 `Replicated` 数据库的集群)。 -- `is_active` ([Nullable(UInt8)](../../sql-reference/data-types/int-uint.md)) — `Replicated` 数据库副本的状态(对于属于 `Replicated` 数据库的集群):1 表示“副本在线”,0 表示“副本离线”,`NULL` 表示“未知”。 +- `errors_count` ([UInt32](../../sql-reference/data-types/int-uint.md)) — 此主机未能到达副本的次数。 +- `slowdowns_count` ([UInt32](../../sql-reference/data-types/int-uint.md)) — 由于在通过对冲请求建立连接时导致更改副本的慢响应次数。 +- `estimated_recovery_time` ([UInt32](../../sql-reference/data-types/int-uint.md)) — 副本错误计数归零,视为正常所需的剩余秒数。 +- `database_shard_name` ([String](../../sql-reference/data-types/string.md)) — `Replicated` 数据库分片的名称(用于属于 `Replicated` 数据库的集群)。 +- `database_replica_name` ([String](../../sql-reference/data-types/string.md)) — `Replicated` 数据库副本的名称(用于属于 `Replicated` 数据库的集群)。 +- `is_active` ([Nullable(UInt8)](../../sql-reference/data-types/int-uint.md)) — `Replicated` 数据库副本的状态(用于属于 `Replicated` 数据库的集群):1 表示“副本在线”,0 表示“副本离线”,`NULL` 表示“未知”。 - `name` ([String](../../sql-reference/data-types/string.md)) - 集群的别名。 **示例** @@ -82,7 +83,7 @@ database_replica_name: is_active: NULL ``` -**参见** +**另见** - [表引擎 Distributed](../../engines/table-engines/special/distributed.md) - [distributed_replica_error_cap 设置](../../operations/settings/settings.md#distributed_replica_error_cap) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/clusters.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/clusters.md.hash index 22c6cce2b54..38b5694cddf 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/clusters.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/clusters.md.hash @@ -1 +1 @@ -968147f78495acf1 +a154339f47137471 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/codecs.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/codecs.md new file mode 100644 index 00000000000..1e0da4c2cd5 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/codecs.md @@ -0,0 +1,48 @@ +--- +'description': '系统表包含有关队列中编解码器的信息。' +'keywords': +- 'system table' +- 'codecs' +- 'compression' +'slug': '/operations/system-tables/codecs' +'title': 'system.codecs' +'doc_type': 'reference' +--- + +包含有关压缩和加密编解码器的信息。 + +您可以使用此表获取有关可用压缩和加密编解码器的信息。 + +`system.codecs` 表包含以下列(列类型以括号显示): + +- `name` ([String](../../sql-reference/data-types/string.md)) — 编解码器名称。 +- `method_byte` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) — 表示压缩文件中的编解码器的字节。 +- `is_compression` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) — 如果此编解码器压缩某些内容,则为真。否则它可能只是有助于压缩的变换。 +- `is_generic_compression` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) — 编解码器是像 lz4,zstd 等通用压缩算法。 +- `is_encryption` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) — 编解码器对数据进行加密。 +- `is_timeseries_codec` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) — 编解码器用于浮点时间序列数据。 +- `is_experimental` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) — 编解码器为实验性。 +- `description` ([String](../../sql-reference/data-types/string.md)) — 对编解码器的高级描述。 + +**示例** + +查询: + +```sql +SELECT * FROM system.codecs WHERE name='LZ4' +``` + +结果: + +```text +Row 1: +────── +name: LZ4 +method_byte: 130 +is_compression: 1 +is_generic_compression: 1 +is_encryption: 0 +is_timeseries_codec: 0 +is_experimental: 0 +description: Extremely fast; good compression; balanced speed and efficiency. +``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/codecs.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/codecs.md.hash new file mode 100644 index 00000000000..61ada7f43e1 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/codecs.md.hash @@ -0,0 +1 @@ +a8e41db730997e79 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/columns.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/columns.md index d99d711942d..d6007fd9c84 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/columns.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/columns.md @@ -1,41 +1,42 @@ --- -'description': '系统表,包含所有表中列的信息' +'description': '系统表包含所有表的列的信息' 'keywords': - 'system table' - 'columns' 'slug': '/operations/system-tables/columns' 'title': 'system.columns' +'doc_type': 'reference' --- 包含所有表中列的信息。 -您可以使用此表获取与 [DESCRIBE TABLE](../../sql-reference/statements/describe-table.md) 查询类似的信息,但可以一次性获取多个表的信息。 +您可以使用此表获取类似于 [DESCRIBE TABLE](../../sql-reference/statements/describe-table.md) 查询的信息,但可以一次获取多个表的信息。 -来自 [临时表](../../sql-reference/statements/create/table.md#temporary-tables) 的列仅在创建它们的会话中可见。它们的 `database` 字段为空。 +[临时表](../../sql-reference/statements/create/table.md#temporary-tables) 的列仅在创建它们的会话中可见。它们的 `database` 字段为空。 `system.columns` 表包含以下列(列类型在括号中显示): - `database` ([String](../../sql-reference/data-types/string.md)) — 数据库名称。 -- `table` ([String](../../sql-reference/data-types/string.md)) — 表名称。 -- `name` ([String](../../sql-reference/data-types/string.md)) — 列名称。 +- `table` ([String](../../sql-reference/data-types/string.md)) — 表名。 +- `name` ([String](../../sql-reference/data-types/string.md)) — 列名。 - `type` ([String](../../sql-reference/data-types/string.md)) — 列类型。 -- `position` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 表中列的序号,从 1 开始。 -- `default_kind` ([String](../../sql-reference/data-types/string.md)) — 默认值的表达式类型(`DEFAULT`,`MATERIALIZED`,`ALIAS`),如果未定义则为空字符串。 -- `default_expression` ([String](../../sql-reference/data-types/string.md)) — 默认值的表达式,如果未定义则为空字符串。 -- `data_compressed_bytes` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 压缩数据的大小(以字节为单位)。 -- `data_uncompressed_bytes` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 解压缩数据的大小(以字节为单位)。 -- `marks_bytes` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 标记的大小(以字节为单位)。 -- `comment` ([String](../../sql-reference/data-types/string.md)) — 列的注释,如果未定义则为空字符串。 +- `position` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 列在表中的序号,从 1 开始。 +- `default_kind` ([String](../../sql-reference/data-types/string.md)) — 默认值的表达式类型(`DEFAULT`、`MATERIALIZED`、`ALIAS`),如果未定义,则为空字符串。 +- `default_expression` ([String](../../sql-reference/data-types/string.md)) — 默认值的表达式,如果未定义,则为空字符串。 +- `data_compressed_bytes` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 压缩数据的大小,以字节为单位。 +- `data_uncompressed_bytes` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 解压缩数据的大小,以字节为单位。 +- `marks_bytes` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 标记的大小,以字节为单位。 +- `comment` ([String](../../sql-reference/data-types/string.md)) — 列的注释,如果未定义,则为空字符串。 - `is_in_partition_key` ([UInt8](../../sql-reference/data-types/int-uint.md)) — 指示列是否在分区表达式中的标志。 - `is_in_sorting_key` ([UInt8](../../sql-reference/data-types/int-uint.md)) — 指示列是否在排序键表达式中的标志。 - `is_in_primary_key` ([UInt8](../../sql-reference/data-types/int-uint.md)) — 指示列是否在主键表达式中的标志。 - `is_in_sampling_key` ([UInt8](../../sql-reference/data-types/int-uint.md)) — 指示列是否在采样键表达式中的标志。 - `compression_codec` ([String](../../sql-reference/data-types/string.md)) — 压缩编解码器名称。 -- `character_octet_length` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 二进制数据、字符数据、文本数据和图像的最大字节长度。在 ClickHouse 中,仅对 `FixedString` 数据类型有意义。否则,返回 `NULL` 值。 -- `numeric_precision` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 近似数字数据、精确数字数据、整数数据或货币数据的准确性。在 ClickHouse 中,它为整数类型的位宽和 `Decimal` 类型的十进制精度。否则,返回 `NULL` 值。 -- `numeric_precision_radix` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 数制的基数是近似数字数据、精确数字数据、整数数据或货币数据的准确性。在 ClickHouse 中,对于整数类型为 2,对于 `Decimal` 类型为 10。否则,返回 `NULL` 值。 -- `numeric_scale` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 近似数字数据、精确数字数据、整数数据或货币数据的规模。在 ClickHouse 中仅对 `Decimal` 类型有意义。否则,返回 `NULL` 值。 -- `datetime_precision` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — `DateTime64` 数据类型的十进制精度。对于其他数据类型,返回 `NULL` 值。 +- `character_octet_length` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 二进制数据、字符数据或文本数据和图像的最大长度(以字节为单位)。在 ClickHouse 中仅对 `FixedString` 数据类型有效。否则将返回 `NULL` 值。 +- `numeric_precision` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 近似数值数据、精确数值数据、整数数据或货币数据的精度。在 ClickHouse 中,它是整数类型的位宽,以及 `Decimal` 类型的十进制精度。否则将返回 `NULL` 值。 +- `numeric_precision_radix` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 数字系统的基数,以表示近似数值数据、精确数值数据、整数数据或货币数据的精度。在 ClickHouse 中,整数类型为 2,而 `Decimal` 类型为 10。否则将返回 `NULL` 值。 +- `numeric_scale` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 近似数值数据、精确数值数据、整数数据或货币数据的刻度。在 ClickHouse 中,仅对 `Decimal` 类型有意义。否则将返回 `NULL` 值。 +- `datetime_precision` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — `DateTime64` 数据类型的十进制精度。对于其他数据类型,将返回 `NULL` 值。 **示例** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/columns.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/columns.md.hash index d4cce2ab029..fe398069d07 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/columns.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/columns.md.hash @@ -1 +1 @@ -651de91bbd21cb20 +29f25c3bc76b67bb diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/contributors.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/contributors.md index 014babc5513..1e904fce27c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/contributors.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/contributors.md @@ -5,13 +5,14 @@ - 'contributors' 'slug': '/operations/system-tables/contributors' 'title': 'system.contributors' +'doc_type': 'reference' --- 包含有关贡献者的信息。顺序在查询执行时是随机的。 列: -- `name` (字符串) — 来自 git log 的贡献者(作者)名称。 +- `name` (String) — 来自 git log 的贡献者(作者)姓名。 **示例** @@ -34,7 +35,7 @@ SELECT * FROM system.contributors LIMIT 10 └──────────────────┘ ``` -要在表中查找您自己,请使用以下查询: +要在表中找到您自己,请使用查询: ```sql SELECT * FROM system.contributors WHERE name = 'Olga Khvostikova' diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/contributors.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/contributors.md.hash index 830f078e7c3..c4771b9b328 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/contributors.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/contributors.md.hash @@ -1 +1 @@ -168e9d37c8f98e24 +d8a3b4adbb498029 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/crash-log.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/crash-log.md index 6701213cea1..37c1a4fb57b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/crash-log.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/crash-log.md @@ -1,42 +1,43 @@ --- -'description': '系统表包含有关致命错误的堆栈跟踪信息。' +'description': '系统表包含关于严重错误的堆栈跟踪信息。' 'keywords': - 'system table' - 'crash_log' 'slug': '/operations/system-tables/crash-log' 'title': 'system.crash_log' +'doc_type': 'reference' --- import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_system_table_cloud.md'; -包含有关致命错误的堆栈跟踪的信息。该表在数据库中默认不存在,仅在发生致命错误时创建。 +包含关于致命错误的堆栈跟踪的信息。该表默认情况下在数据库中不存在,仅在发生致命错误时创建。 -列: +列: - `hostname` ([LowCardinality(String)](../../sql-reference/data-types/string.md)) — 执行查询的服务器的主机名。 -- `event_date` ([DateTime](../../sql-reference/data-types/datetime.md)) — 事件日期。 -- `event_time` ([DateTime](../../sql-reference/data-types/datetime.md)) — 事件时间。 -- `timestamp_ns` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 事件的时间戳,以纳秒为单位。 +- `event_date` ([DateTime](../../sql-reference/data-types/datetime.md)) — 事件的日期。 +- `event_time` ([DateTime](../../sql-reference/data-types/datetime.md)) — 事件的时间。 +- `timestamp_ns` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 事件的时间戳(以纳秒为单位)。 - `signal` ([Int32](../../sql-reference/data-types/int-uint.md)) — 信号编号。 -- `thread_id` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 线程ID。 -- `query_id` ([String](../../sql-reference/data-types/string.md)) — 查询ID。 +- `thread_id` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 线程 ID。 +- `query_id` ([String](../../sql-reference/data-types/string.md)) — 查询 ID。 - `trace` ([Array](../../sql-reference/data-types/array.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 崩溃时的堆栈跟踪。每个元素是 ClickHouse 服务器进程内部的虚拟内存地址。 -- `trace_full` ([Array](../../sql-reference/data-types/array.md)([String](../../sql-reference/data-types/string.md))) — 崩溃时的堆栈跟踪。每个元素包含 ClickHouse 服务器进程内部调用的方法。 +- `trace_full` ([Array](../../sql-reference/data-types/array.md)([String](../../sql-reference/data-types/string.md))) — 崩溃时的堆栈跟踪。每个元素包含 ClickHouse 服务器进程内部的一个被调用方法。 - `version` ([String](../../sql-reference/data-types/string.md)) — ClickHouse 服务器版本。 - `revision` ([UInt32](../../sql-reference/data-types/int-uint.md)) — ClickHouse 服务器修订版本。 - `build_id` ([String](../../sql-reference/data-types/string.md)) — 编译器生成的 BuildID。 **示例** -查询: +查询: ```sql SELECT * FROM system.crash_log ORDER BY event_time DESC LIMIT 1; ``` -结果(不完整): +结果(不完整): ```text Row 1: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/crash-log.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/crash-log.md.hash index d1b41ce565c..93574b0f784 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/crash-log.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/crash-log.md.hash @@ -1 +1 @@ -76e079c0f9c21ff2 +c8395da5d0b5ad90 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/crash_log.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/crash_log.md new file mode 100644 index 00000000000..f008503bb97 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/crash_log.md @@ -0,0 +1,60 @@ +--- +'description': '系统表包含有关致命错误的堆栈跟踪信息。' +'keywords': +- 'system table' +- 'crash_log' +'slug': '/operations/system-tables/crash_log' +'title': 'system.crash_log' +'doc_type': 'reference' +--- + +import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_system_table_cloud.md'; + + + +包含有关致命错误的堆栈跟踪信息。此表在数据库中默认不存在,仅在发生致命错误时创建。 + +列: + +- `hostname` ([LowCardinality(String)](../../sql-reference/data-types/string.md)) — 执行查询的服务器的主机名。 +- `event_date` ([DateTime](../../sql-reference/data-types/datetime.md)) — 事件日期。 +- `event_time` ([DateTime](../../sql-reference/data-types/datetime.md)) — 事件时间。 +- `timestamp_ns` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 以纳秒为单位的事件时间戳。 +- `signal` ([Int32](../../sql-reference/data-types/int-uint.md)) — 信号编号。 +- `thread_id` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 线程 ID。 +- `query_id` ([String](../../sql-reference/data-types/string.md)) — 查询 ID。 +- `trace` ([Array](../../sql-reference/data-types/array.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 崩溃时的堆栈跟踪。每个元素都是 ClickHouse 服务器进程内的虚拟内存地址。 +- `trace_full` ([Array](../../sql-reference/data-types/array.md)([String](../../sql-reference/data-types/string.md))) — 崩溃时的堆栈跟踪。每个元素包含 ClickHouse 服务器进程内调用的方法。 +- `version` ([String](../../sql-reference/data-types/string.md)) — ClickHouse 服务器版本。 +- `revision` ([UInt32](../../sql-reference/data-types/int-uint.md)) — ClickHouse 服务器修订号。 +- `build_id` ([String](../../sql-reference/data-types/string.md)) — 编译器生成的 BuildID。 + +**示例** + +查询: + +```sql +SELECT * FROM system.crash_log ORDER BY event_time DESC LIMIT 1; +``` + +结果(不完全): + +```text +Row 1: +────── +hostname: clickhouse.eu-central1.internal +event_date: 2020-10-14 +event_time: 2020-10-14 15:47:40 +timestamp_ns: 1602679660271312710 +signal: 11 +thread_id: 23624 +query_id: 428aab7c-8f5c-44e9-9607-d16b44467e69 +trace: [188531193,...] +trace_full: ['3. DB::(anonymous namespace)::FunctionFormatReadableTimeDelta::executeImpl(std::__1::vector >&, std::__1::vector > const&, unsigned long, unsigned long) const @ 0xb3cc1f9 in /home/username/work/ClickHouse/build/programs/clickhouse',...] +version: ClickHouse 20.11.1.1 +revision: 54442 +build_id: +``` + +**另见** +- [trace_log](../../operations/system-tables/trace_log.md) 系统表 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/crash_log.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/crash_log.md.hash new file mode 100644 index 00000000000..68192e975e3 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/crash_log.md.hash @@ -0,0 +1 @@ +8d7ad7a0e770e51d diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/current-roles.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/current-roles.md index 989f0ac8de3..bcc10364ca8 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/current-roles.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/current-roles.md @@ -5,12 +5,13 @@ - 'current_roles' 'slug': '/operations/system-tables/current-roles' 'title': 'system.current_roles' +'doc_type': 'reference' --- -包含当前用户的活动角色。 `SET ROLE` 会更改此表的内容。 +包含当前用户的活动角色。 `SET ROLE` 更改此表的内容。 列: - - `role_name` ([String](../../sql-reference/data-types/string.md))) — 角色名称。 - - `with_admin_option` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) — 表示 `current_role` 是否为具有 `ADMIN OPTION` 特权的角色的标志。 - - `is_default` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) — 表示 `current_role` 是否为默认角色的标志。 +- `role_name` ([String](../../sql-reference/data-types/string.md))) — 角色名称。 +- `with_admin_option` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) — 显示 `current_role` 是否具有 `ADMIN OPTION` 权限的标志。 +- `is_default` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) — 显示 `current_role` 是否为默认角色的标志。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/current-roles.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/current-roles.md.hash index 30150c652a1..9dad6d2b218 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/current-roles.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/current-roles.md.hash @@ -1 +1 @@ -2bf88fa0236fcf42 +94baa62370179828 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/current_roles.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/current_roles.md new file mode 100644 index 00000000000..a1c294942e2 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/current_roles.md @@ -0,0 +1,17 @@ +--- +'description': '系统表包含当前用户的活动角色。' +'keywords': +- 'system table' +- 'current_roles' +'slug': '/operations/system-tables/current_roles' +'title': 'system.current_roles' +'doc_type': 'reference' +--- + +包含当前用户的活动角色。 `SET ROLE` 更改此表的内容。 + +列: + +- `role_name` ([String](../../sql-reference/data-types/string.md))) — 角色名称。 +- `with_admin_option` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) — 表示 `current_role` 是否是具有 `ADMIN OPTION` 权限的角色的标志。 +- `is_default` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) — 表示 `current_role` 是否是默认角色的标志。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/current_roles.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/current_roles.md.hash new file mode 100644 index 00000000000..b1d2919b1ac --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/current_roles.md.hash @@ -0,0 +1 @@ +e3f4e44f2b781d9f diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/dashboards.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/dashboards.md index 8e21de869bc..e7ab4cd17b5 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/dashboards.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/dashboards.md @@ -1,5 +1,5 @@ --- -'description': '包含通过 HTTP 接口访问的 `/dashboard` 页面使用的查询,便于监控和故障排除。' +'description': '包含通过 HTTP 接口访问的 `/dashboard` 页面使用的查询。用于监控和故障排除。' 'keywords': - 'system table' - 'dashboards' @@ -7,12 +7,13 @@ - 'troubleshooting' 'slug': '/operations/system-tables/dashboards' 'title': 'system.dashboards' +'doc_type': 'reference' --- -包含通过 [HTTP 接口](/interfaces/http.md) 访问的 `/dashboard` 页面使用的查询。此表对于监控和故障排除非常有用。该表每个仪表板中的图表都有一行。 +包含通过 [HTTP 接口](/interfaces/http.md) 访问的 `/dashboard` 页面使用的查询。 该表对监控和故障排除很有用。 表中为仪表板中的每个图表包含一行。 :::note -`/dashboard` 页面不仅可以呈现来自 `system.dashboards` 的查询,还可以呈现来自任何具有相同模式的表的查询。这对创建自定义仪表板非常有用。 +`/dashboard` 页面不仅可以渲染来自 `system.dashboards` 的查询,还可以渲染任何具有相同模式的表中的查询。 这对于创建自定义仪表板非常有用。 ::: 示例: @@ -69,4 +70,4 @@ ORDER BY t WITH FILL STEP {rounding:UInt32} - `dashboard` (`String`) - 仪表板名称。 - `title` (`String`) - 图表标题。 -- `query` (`String`) - 用于获取要显示数据的查询。 +- `query` (`String`) - 用于获取要显示的数据的查询。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/dashboards.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/dashboards.md.hash index 6006154c848..8e7836eaaf0 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/dashboards.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/dashboards.md.hash @@ -1 +1 @@ -9cc069ace02663d2 +57518b85cc64ad1d diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/data_skipping_indices.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/data_skipping_indices.md index b56964bbda8..9f35cce752b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/data_skipping_indices.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/data_skipping_indices.md @@ -1,10 +1,11 @@ --- -'description': '系统表包含有关所有表中现有数据跳过索引的信息.' +'description': '系统表包含有关所有表中现有数据跳过索引的信息。' 'keywords': - 'system table' - 'data_skipping_indices' 'slug': '/operations/system-tables/data_skipping_indices' 'title': 'system.data_skipping_indices' +'doc_type': 'reference' --- 包含有关所有表中现有数据跳过索引的信息。 @@ -17,10 +18,10 @@ - `type` ([String](../../sql-reference/data-types/string.md)) — 索引类型。 - `type_full` ([String](../../sql-reference/data-types/string.md)) — 来自创建语句的索引类型表达式。 - `expr` ([String](../../sql-reference/data-types/string.md)) — 索引计算的表达式。 -- `granularity` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 块中粒度的数量。 -- `data_compressed_bytes` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 压缩数据的大小,以字节为单位。 -- `data_uncompressed_bytes` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 解压缩数据的大小,以字节为单位。 -- `marks_bytes` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 标记的大小,以字节为单位。 +- `granularity` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 块中的粒度数量。 +- `data_compressed_bytes` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 压缩数据的大小(以字节为单位)。 +- `data_uncompressed_bytes` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 解压缩数据的大小(以字节为单位)。 +- `marks_bytes` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 标记的大小(以字节为单位)。 **示例** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/data_skipping_indices.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/data_skipping_indices.md.hash index 017fb4d6c31..adf1de96e76 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/data_skipping_indices.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/data_skipping_indices.md.hash @@ -1 +1 @@ -f46193801b180bb4 +6139f882ff732f49 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/data_type_families.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/data_type_families.md index cc4ad34431f..f9e3962a803 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/data_type_families.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/data_type_families.md @@ -1,19 +1,20 @@ --- -'description': '系统表包含有关支持的数据类型的信息' +'description': '系统表包含关于支持的数据类型的信息' 'keywords': - 'system table' - 'data_type_families' 'slug': '/operations/system-tables/data_type_families' 'title': 'system.data_type_families' +'doc_type': 'reference' --- -包含关于支持的 [数据类型](../../sql-reference/data-types/index.md) 的信息。 +包含有关支持的 [数据类型](../../sql-reference/data-types/index.md) 的信息。 列: - `name` ([String](../../sql-reference/data-types/string.md)) — 数据类型名称。 -- `case_insensitive` ([UInt8](../../sql-reference/data-types/int-uint.md)) — 显示是否可以在查询中不区分大小写地使用数据类型名称的属性。例如,`Date` 和 `date` 都是有效的。 -- `alias_to` ([String](../../sql-reference/data-types/string.md)) — `name` 的别名所对应的数据类型名称。 +- `case_insensitive` ([UInt8](../../sql-reference/data-types/int-uint.md)) — 显示在查询中是否可以不区分大小写地使用数据类型名称的属性。例如,`Date` 和 `date` 都是有效的。 +- `alias_to` ([String](../../sql-reference/data-types/string.md)) — `name` 的别名所指的数据类型名称。 **示例** @@ -36,6 +37,6 @@ SELECT * FROM system.data_type_families WHERE alias_to = 'String' └────────────┴──────────────────┴──────────┘ ``` -**另见** +**另请参阅** -- [语法](../../sql-reference/syntax.md) — 关于支持的语法的信息。 +- [语法](../../sql-reference/syntax.md) — 有关支持的语法的信息。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/data_type_families.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/data_type_families.md.hash index c19cd06e124..b085b52dde5 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/data_type_families.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/data_type_families.md.hash @@ -1 +1 @@ -73a758d7dba3ad59 +f37c3bad660bc9c4 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/database_engines.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/database_engines.md index 44dfe2165c1..17fba8161e4 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/database_engines.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/database_engines.md @@ -5,11 +5,12 @@ - 'database_engines' 'slug': '/operations/system-tables/database_engines' 'title': 'system.database_engines' +'doc_type': 'reference' --- 包含服务器支持的数据库引擎列表。 -该表包含以下列(列类型在括号中显示): +该表包含以下列(列类型以括号表示): - `name` (String) — 数据库引擎的名称。 @@ -18,7 +19,7 @@ ```sql SELECT * FROM system.database_engines -WHERE name in ('Atomic', 'Lazy', 'Ordinary') +WHERE name IN ('Atomic', 'Lazy', 'Ordinary') ``` ```text diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/database_engines.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/database_engines.md.hash index 98f76fbcd2a..c20989571f9 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/database_engines.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/database_engines.md.hash @@ -1 +1 @@ -2f487f54afcd691a +b8f82dca37f7b588 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/database_replicas.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/database_replicas.md new file mode 100644 index 00000000000..a084f6b24af --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/database_replicas.md @@ -0,0 +1,56 @@ +--- +'description': '系统表包含关于复制数据库的信息和状态。' +'keywords': +- 'system table' +- 'database_replicas' +'slug': '/operations/system-tables/database_replicas' +'title': 'system.database_replicas' +'doc_type': 'reference' +--- + +包含每个副本数据库副本的信息。 + +列: + +- `database` ([String](../../sql-reference/data-types/string.md)) — 所在的副本数据库名称。 + +- `is_readonly` ([UInt8](../../sql-reference/data-types/int-uint.md)) - 数据库副本是否处于只读模式。 + 如果配置中没有 Zookeeper/ClickHouse Keeper 的部分,则启用此模式。 + +- `is_session_expired` ([UInt8](../../sql-reference/data-types/int-uint.md)) - 与 ClickHouse Keeper 的会话已过期。基本上与 `is_readonly` 相同。 + +- `max_log_ptr` ([UInt32](../../sql-reference/data-types/int-uint.md)) - 一般活动日志中的最大条目编号。 + +- `zookeeper_path` ([String](../../sql-reference/data-types/string.md)) - 在 ClickHouse Keeper 中数据库数据的路径。 + +- `replica_name` ([String](../../sql-reference/data-types/string.md)) - 在 ClickHouse Keeper 中的副本名称。 + +- `replica_path` ([String](../../sql-reference/data-types/string.md)) - 在 ClickHouse Keeper 中副本数据的路径。 + +- `zookeeper_exception` ([String](../../sql-reference/data-types/string.md)) - 从 ClickHouse Keeper 获取信息时发生错误时的最后异常消息。 + +- `total_replicas` ([UInt32](../../sql-reference/data-types/int-uint.md)) - 此数据库已知副本的总数。 + +- `log_ptr` ([UInt32](../../sql-reference/data-types/int-uint.md)) - 副本复制到其执行队列的最大活动日志条目编号,加一。 + +**示例** + +```sql +SELECT * FROM system.database_replicas FORMAT Vertical; +``` + +```text +Row 1: +────── +database: db_2 +is_readonly: 0 +max_log_ptr: 2 +replica_name: replica1 +replica_path: /test/db_2/replicas/shard1|replica1 +zookeeper_path: /test/db_2 +shard_name: shard1 +log_ptr: 2 +total_replicas: 1 +zookeeper_exception: +is_session_expired: 0 +``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/database_replicas.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/database_replicas.md.hash new file mode 100644 index 00000000000..b1042063e4b --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/database_replicas.md.hash @@ -0,0 +1 @@ +c065cdbc2f11bab0 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/databases.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/databases.md index cf862ca8d4f..7ad437f0125 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/databases.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/databases.md @@ -5,9 +5,10 @@ - 'databases' 'slug': '/operations/system-tables/databases' 'title': 'system.databases' +'doc_type': 'reference' --- -包含有关当前用户可用的数据库的信息。 +包含当前用户可用的数据库的信息。 列: @@ -16,11 +17,11 @@ - `data_path` ([String](../../sql-reference/data-types/string.md)) — 数据路径。 - `metadata_path` ([String](../../sql-reference/data-types/enum.md)) — 元数据路径。 - `uuid` ([UUID](../../sql-reference/data-types/uuid.md)) — 数据库 UUID。 -- `comment` ([String](../../sql-reference/data-types/enum.md)) — 数据库备注。 +- `comment` ([String](../../sql-reference/data-types/enum.md)) — 数据库注释。 - `engine_full` ([String](../../sql-reference/data-types/enum.md)) — 数据库引擎的参数。 - `database` ([String](../../sql-reference/data-types/string.md)) – `name` 的别名。 -此系统表中的 `name` 列用于实现 `SHOW DATABASES` 查询。 +该系统表的 `name` 列用于实现 `SHOW DATABASES` 查询。 **示例** @@ -30,7 +31,7 @@ CREATE DATABASE test; ``` -检查用户所有可用的数据库。 +检查用户可用的所有数据库。 ```sql SELECT * FROM system.databases; diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/databases.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/databases.md.hash index 35b8301abcc..fdd38a5adb3 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/databases.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/databases.md.hash @@ -1 +1 @@ -04405a26b2d01225 +390120acea3ef5c5 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/dead_letter_queue.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/dead_letter_queue.md new file mode 100644 index 00000000000..5db67415b44 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/dead_letter_queue.md @@ -0,0 +1,129 @@ +--- +'description': '系统表包含关于通过流式引擎接收并解析时出错的消息的信息。' +'keywords': +- 'system table' +- 'dead_letter_queue' +'slug': '/operations/system-tables/dead_letter_queue' +'title': 'system.dead_letter_queue' +'doc_type': 'reference' +--- + +包含通过流处理引擎接收并解析错误的消息信息。目前针对 Kafka 和 RabbitMQ 实现。 + +通过为引擎特定的 `handle_error_mode` 设置指定 `dead_letter_queue` 来启用日志记录。 + +数据的刷新周期在 [dead_letter_queue](../../operations/server-configuration-parameters/settings.md#dead_letter_queue) 服务器设置部分的 `flush_interval_milliseconds` 参数中设置。要强制刷新,请使用 [SYSTEM FLUSH LOGS](/sql-reference/statements/system#flush-logs) 查询。 + +ClickHouse 不会自动删除表中的数据。更多详细信息请参见 [Introduction](../../operations/system-tables/overview.md#system-tables-introduction)。 + +列: + +- `table_engine` ([Enum8](../../sql-reference/data-types/enum.md)) - 流类型。可能的值:`Kafka` 和 `RabbitMQ`。 +- `event_date` ([Date](../../sql-reference/data-types/date.md)) - 消息消费日期。 +- `event_time` ([DateTime](../../sql-reference/data-types/datetime.md)) - 消息消费的日期和时间。 +- `event_time_microseconds` ([DateTime64](../../sql-reference/data-types/datetime64.md)) - 消息消费时间,具有微秒精度。 +- `database` ([LowCardinality(String)](../../sql-reference/data-types/string.md)) - 流表所属的 ClickHouse 数据库。 +- `table` ([LowCardinality(String)](../../sql-reference/data-types/string.md)) - ClickHouse 表名。 +- `error` ([String](../../sql-reference/data-types/string.md)) - 错误文本。 +- `raw_message` ([String](../../sql-reference/data-types/string.md)) - 消息正文。 +- `kafka_topic_name` ([String](../../sql-reference/data-types/string.md)) - Kafka 主题名称。 +- `kafka_partition` ([UInt64](../../sql-reference/data-types/int-uint.md)) - 主题的 Kafka 分区。 +- `kafka_offset` ([UInt64](../../sql-reference/data-types/int-uint.md)) - 消息的 Kafka 偏移量。 +- `kafka_key` ([String](../../sql-reference/data-types/string.md)) - 消息的 Kafka 键。 +- `rabbitmq_exchange_name` ([String](../../sql-reference/data-types/string.md)) - RabbitMQ 交换名称。 +- `rabbitmq_message_id` ([String](../../sql-reference/data-types/string.md)) - RabbitMQ 消息 ID。 +- `rabbitmq_message_timestamp` ([DateTime](../../sql-reference/data-types/datetime.md)) - RabbitMQ 消息时间戳。 +- `rabbitmq_message_redelivered` ([UInt8](../../sql-reference/data-types/int-uint.md)) - RabbitMQ 重新投递标志。 +- `rabbitmq_message_delivery_tag` ([UInt64](../../sql-reference/data-types/int-uint.md)) - RabbitMQ 投递标签。 +- `rabbitmq_channel_id` ([String](../../sql-reference/data-types/string.md)) - RabbitMQ 通道 ID。 + +**示例** + +查询: + +```sql +SELECT * FROM system.dead_letter_queue LIMIT 1 \G; +``` + +结果: + +```text +Row 1: +────── +table_engine: Kafka +event_date: 2025-05-01 +event_time: 2025-05-01 10:34:53 +event_time_microseconds: 2025-05-01 10:34:53.910773 +database: default +table: kafka +error: Cannot parse input: expected '\t' before: 'qwertyuiop': (at row 1) +: +Row 1: +Column 0, name: key, type: UInt64, ERROR: text "qwertyuiop" is not like UInt64 +raw_message: qwertyuiop +kafka_topic_name: TSV_dead_letter_queue_err_1746095689 +kafka_partition: 0 +kafka_offset: 0 +kafka_key: +rabbitmq_exchange_name: +rabbitmq_message_id: +rabbitmq_message_timestamp: 1970-01-01 00:00:00 +rabbitmq_message_redelivered: 0 +rabbitmq_message_delivery_tag: 0 +rabbitmq_channel_id: + +Row 2: +────── +table_engine: Kafka +event_date: 2025-05-01 +event_time: 2025-05-01 10:34:53 +event_time_microseconds: 2025-05-01 10:34:53.910944 +database: default +table: kafka +error: Cannot parse input: expected '\t' before: 'asdfghjkl': (at row 1) +: +Row 1: +Column 0, name: key, type: UInt64, ERROR: text "asdfghjkl" is not like UInt64 +raw_message: asdfghjkl +kafka_topic_name: TSV_dead_letter_queue_err_1746095689 +kafka_partition: 0 +kafka_offset: 0 +kafka_key: +rabbitmq_exchange_name: +rabbitmq_message_id: +rabbitmq_message_timestamp: 1970-01-01 00:00:00 +rabbitmq_message_redelivered: 0 +rabbitmq_message_delivery_tag: 0 +rabbitmq_channel_id: + +Row 3: +────── +table_engine: Kafka +event_date: 2025-05-01 +event_time: 2025-05-01 10:34:53 +event_time_microseconds: 2025-05-01 10:34:53.911092 +database: default +table: kafka +error: Cannot parse input: expected '\t' before: 'zxcvbnm': (at row 1) +: +Row 1: +Column 0, name: key, type: UInt64, ERROR: text "zxcvbnm" is not like UInt64 +raw_message: zxcvbnm +kafka_topic_name: TSV_dead_letter_queue_err_1746095689 +kafka_partition: 0 +kafka_offset: 0 +kafka_key: +rabbitmq_exchange_name: +rabbitmq_message_id: +rabbitmq_message_timestamp: 1970-01-01 00:00:00 +rabbitmq_message_redelivered: 0 +rabbitmq_message_delivery_tag: 0 +rabbitmq_channel_id: + (test.py:78, dead_letter_queue_test) + +``` + +**另请参阅** + +- [Kafka](/engines/table-engines/integrations/kafka.md) - Kafka 引擎 +- [system.kafka_consumers](/operations/system-tables/kafka_consumers.md) — 描述 `kafka_consumers` 系统表的信息,该表包含有关 Kafka 消费者的统计和错误信息。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/dead_letter_queue.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/dead_letter_queue.md.hash new file mode 100644 index 00000000000..e6635baa359 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/dead_letter_queue.md.hash @@ -0,0 +1 @@ +d52d250fecb274e9 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/delta_metadata_log.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/delta_metadata_log.md new file mode 100644 index 00000000000..34b154e0312 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/delta_metadata_log.md @@ -0,0 +1,52 @@ +--- +'description': '系统表包含关于从 Delta Lake 表中读取的元数据文件的信息。每个条目代表一个根元数据 JSON 文件。' +'keywords': +- 'system table' +- 'delta_lake_metadata_log' +'slug': '/operations/system-tables/delta_lake_metadata_log' +'title': 'system.delta_lake_metadata_log' +'doc_type': 'reference' +--- + +import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_system_table_cloud.md'; + + +# system.delta_lake_metadata_log + +`system.delta_lake_metadata_log` 表记录了 ClickHouse 读取 Delta Lake 表的元数据访问和解析事件。它提供关于每个元数据文件的详细信息,这对于调试、审计以及理解 Delta 表的结构演变非常有用。 + +## Purpose {#purpose} + +此表记录了从 Delta Lake 表读取的每个元数据文件。它帮助用户追踪 ClickHouse 如何解释 Delta 表元数据,并诊断与模式演变、快照解析或查询计划相关的问题。 + +:::note +此表主要用于调试目的。 +:::note + +## Columns {#columns} +| 名称 | 类型 | 描述 | +|----------------|-----------|--------------------------------------------------------------------------------------------| +| `event_date` | [Date](../../sql-reference/data-types/date.md) | 日志文件的日期。 | +| `event_time` | [DateTime](../../sql-reference/data-types/datetime.md) | 事件的时间戳。 | +| `query_id` | [String](../../sql-reference/data-types/string.md) | 触发元数据读取的查询 ID。 | +| `table_path` | [String](../../sql-reference/data-types/string.md) | Delta Lake 表的路径。 | +| `file_path` | [String](../../sql-reference/data-types/string.md) | 根元数据 JSON 文件的路径。 | +| `content` | [String](../../sql-reference/data-types/string.md) | JSON 格式的内容(来自 .json 的原始元数据)。 | + + + +## Controlling log verbosity {#controlling-log-verbosity} + +您可以使用 [`delta_lake_log_metadata`](../../operations/settings/settings.md#delta_lake_log_metadata) 设置来控制哪些元数据事件被记录。 + +要记录当前查询中使用的所有元数据: + +```sql +SELECT * FROM my_delta_table SETTINGS delta_lake_log_metadata = 1; + +SYSTEM FLUSH LOGS delta_lake_metadata_log; + +SELECT * +FROM system.delta_lake_metadata_log +WHERE query_id = '{previous_query_id}'; +``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/delta_metadata_log.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/delta_metadata_log.md.hash new file mode 100644 index 00000000000..14e7152307c --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/delta_metadata_log.md.hash @@ -0,0 +1 @@ +f6362421529caeba diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/detached_parts.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/detached_parts.md index 536873cadb0..065f9d3b7a4 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/detached_parts.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/detached_parts.md @@ -1,16 +1,17 @@ --- -'description': '系统表包含有关 MergeTree 表的分离片段的信息' +'description': '系统表包含关于MergeTree表的分区片段的信息' 'keywords': - 'system table' - 'detached_parts' 'slug': '/operations/system-tables/detached_parts' 'title': 'system.detached_parts' +'doc_type': 'reference' --- -包含有关 [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) 表的分离部分的信息。 `reason` 列指定了分离部分的原因。 +包含有关 [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) 表的分离部分的信息。`reason` 列指定了部分被分离的原因。 -对于用户分离的部分,原因为空。这些部分可以使用 [ALTER TABLE ATTACH PARTITION\|PART](/sql-reference/statements/alter/partition#attach-partitionpart) 命令附加。 +对于用户分离的部分,原因为空。此类部分可以通过 [ALTER TABLE ATTACH PARTITION\|PART](/sql-reference/statements/alter/partition#attach-partitionpart) 命令附加。 有关其他列的描述,请参见 [system.parts](../../operations/system-tables/parts.md)。 -如果部分名称无效,某些列的值可能为 `NULL`。这些部分可以使用 [ALTER TABLE DROP DETACHED PART](/sql-reference/statements/alter/view) 删除。 +如果部分名称无效,则某些列的值可能为 `NULL`。此类部分可以通过 [ALTER TABLE DROP DETACHED PART](/sql-reference/statements/alter/partition#drop-detached-partitionpart) 命令删除。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/detached_parts.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/detached_parts.md.hash index 29219b1a3ce..6f9832fb18b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/detached_parts.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/detached_parts.md.hash @@ -1 +1 @@ -a1109ae1a34842fb +7bfb096e0a7a8f59 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/detached_tables.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/detached_tables.md index 355e3ade3c0..fd40112d6be 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/detached_tables.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/detached_tables.md @@ -1,25 +1,26 @@ --- -'description': '系统表包含有关每个 detached 表的信息。' +'description': '系统表包含关于每个 detached 表的信息。' 'keywords': - 'system table' - 'detached_tables' 'slug': '/operations/system-tables/detached_tables' 'title': 'system.detached_tables' +'doc_type': 'reference' --- 包含每个已分离表的信息。 列: -- `database` ([String](../../sql-reference/data-types/string.md)) — 表所在数据库的名称。 +- `database` ([String](../../sql-reference/data-types/string.md)) — 表所在的数据库名称。 -- `table` ([String](../../sql-reference/data-types/string.md)) — 表名称。 +- `table` ([String](../../sql-reference/data-types/string.md)) — 表名。 -- `uuid` ([UUID](../../sql-reference/data-types/uuid.md)) — 表的 uuid(原子数据库)。 +- `uuid` ([UUID](../../sql-reference/data-types/uuid.md)) — 表的 UUID(原子数据库)。 - `metadata_path` ([String](../../sql-reference/data-types/string.md)) - 文件系统中表元数据的路径。 -- `is_permanently` ([UInt8](../../sql-reference/data-types/int-uint.md)) - 标志指示该表已被永久性分离。 +- `is_permanently` ([UInt8](../../sql-reference/data-types/int-uint.md)) - 标志指示该表已被永久分离。 **示例** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/detached_tables.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/detached_tables.md.hash index e0aa3ed0827..e25209ec295 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/detached_tables.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/detached_tables.md.hash @@ -1 +1 @@ -be139cf273cb816d +aeeee99a89180129 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/dictionaries.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/dictionaries.md index 724ed07ec22..e240fc4c525 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/dictionaries.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/dictionaries.md @@ -1,10 +1,11 @@ --- -'description': '系统表包含有关字典的信息' +'description': '系统表包含关于字典的信息' 'keywords': - 'system table' - 'dictionaries' 'slug': '/operations/system-tables/dictionaries' 'title': 'system.dictionaries' +'doc_type': 'reference' --- import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_system_table_cloud.md'; @@ -15,37 +16,37 @@ import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/curre 列: -- `database` ([String](../../sql-reference/data-types/string.md)) — 包含由 DDL 查询创建的字典的数据库名称。其他字典为空字符串。 +- `database` ([String](../../sql-reference/data-types/string.md)) — 包含通过 DDL 查询创建的字典的数据库名称。其他字典为一个空字符串。 - `name` ([String](../../sql-reference/data-types/string.md)) — [字典名称](../../sql-reference/dictionaries/index.md)。 - `uuid` ([UUID](../../sql-reference/data-types/uuid.md)) — 字典 UUID。 - `status` ([Enum8](../../sql-reference/data-types/enum.md)) — 字典状态。可能的值: - - `NOT_LOADED` — 字典未加载,因为未使用。 - - `LOADED` — 字典成功加载。 - - `FAILED` — 由于错误无法加载字典。 - - `LOADING` — 字典正在加载。 - - `LOADED_AND_RELOADING` — 字典已成功加载,正在重新加载(常见原因:[SYSTEM RELOAD DICTIONARY](/sql-reference/statements/system#reload-dictionaries) 查询、超时、字典配置已改变)。 - - `FAILED_AND_RELOADING` — 因错误无法加载字典,正在加载。 + - `NOT_LOADED` — 字典未加载,因为未被使用。 + - `LOADED` — 字典成功加载。 + - `FAILED` — 由于错误无法加载字典。 + - `LOADING` — 字典正在加载中。 + - `LOADED_AND_RELOADING` — 字典成功加载,并且正在重新加载中(频繁原因:[SYSTEM RELOAD DICTIONARY](/sql-reference/statements/system#reload-dictionaries) 查询、超时、字典配置已更改)。 + - `FAILED_AND_RELOADING` — 由于错误未能加载字典,现在正在加载。 - `origin` ([String](../../sql-reference/data-types/string.md)) — 描述字典的配置文件路径。 -- `type` ([String](../../sql-reference/data-types/string.md)) — 字典分配类型。 [在内存中存储字典](/sql-reference/dictionaries#storing-dictionaries-in-memory)。 +- `type` ([String](../../sql-reference/data-types/string.md)) — 字典分配的类型。 [在内存中存储字典](/sql-reference/dictionaries#storing-dictionaries-in-memory)。 - `key.names` ([Array](../../sql-reference/data-types/array.md)([String](../../sql-reference/data-types/string.md))) — 字典提供的 [键名称](/operations/system-tables/dictionaries) 数组。 - `key.types` ([Array](../../sql-reference/data-types/array.md)([String](../../sql-reference/data-types/string.md))) — 字典提供的相应 [键类型](/sql-reference/dictionaries#dictionary-key-and-fields) 数组。 - `attribute.names` ([Array](../../sql-reference/data-types/array.md)([String](../../sql-reference/data-types/string.md))) — 字典提供的 [属性名称](/sql-reference/dictionaries#dictionary-key-and-fields) 数组。 - `attribute.types` ([Array](../../sql-reference/data-types/array.md)([String](../../sql-reference/data-types/string.md))) — 字典提供的相应 [属性类型](/sql-reference/dictionaries#dictionary-key-and-fields) 数组。 -- `bytes_allocated` ([UInt64](/sql-reference/data-types/int-uint#integer-ranges)) — 为字典分配的 RAM 数量。 -- `query_count` ([UInt64](/sql-reference/data-types/int-uint#integer-ranges)) — 自字典加载或自最后一次成功重启以来的查询数量。 +- `bytes_allocated` ([UInt64](/sql-reference/data-types/int-uint#integer-ranges)) — 为字典分配的 RAM 量。 +- `query_count` ([UInt64](/sql-reference/data-types/int-uint#integer-ranges)) — 自字典加载以来或自上次成功重启以来的查询数量。 - `hit_rate` ([Float64](../../sql-reference/data-types/float.md)) — 对于缓存字典,值在缓存中的使用百分比。 -- `found_rate` ([Float64](../../sql-reference/data-types/float.md)) — 找到值的使用百分比。 -- `element_count` ([UInt64](/sql-reference/data-types/int-uint#integer-ranges)) — 存储在字典中的项目数量。 -- `load_factor` ([Float64](../../sql-reference/data-types/float.md)) — 字典中填充的百分比(对于哈希字典,哈希表中填充的百分比)。 -- `source` ([String](../../sql-reference/data-types/string.md)) — 描述字典的数据源的文本 [data source](../../sql-reference/dictionaries/index.md#dictionary-sources)。 -- `lifetime_min` ([UInt64](/sql-reference/data-types/int-uint#integer-ranges)) — 字典在内存中的最小 [生存时间](/sql-reference/dictionaries#refreshing-dictionary-data-using-lifetime),之后 ClickHouse 尝试重新加载字典(如果设置了 `invalidate_query`,则仅在其发生变化时)。以秒为单位设置。 -- `lifetime_max` ([UInt64](/sql-reference/data-types/int-uint#integer-ranges)) — 字典在内存中的最大 [生存时间](/sql-reference/dictionaries#refreshing-dictionary-data-using-lifetime),之后 ClickHouse 尝试重新加载字典(如果设置了 `invalidate_query`,则仅在其发生变化时)。以秒为单位设置。 +- `found_rate` ([Float64](../../sql-reference/data-types/float.md)) — 值被找到的使用百分比。 +- `element_count` ([UInt64](/sql-reference/data-types/int-uint#integer-ranges)) — 存储在字典中的项数。 +- `load_factor` ([Float64](../../sql-reference/data-types/float.md)) — 字典中的填充百分比(对于哈希字典,哈希表中的填充百分比)。 +- `source` ([String](../../sql-reference/data-types/string.md)) — 描述字典的 [数据源](../../sql-reference/dictionaries/index.md#dictionary-sources) 的文本。 +- `lifetime_min` ([UInt64](/sql-reference/data-types/int-uint#integer-ranges)) — 内存中字典的最小 [生存时间](/sql-reference/dictionaries#refreshing-dictionary-data-using-lifetime),在此之后 ClickHouse 尝试重新加载字典(如果设置了 `invalidate_query`,则仅在字典已更改时)。以秒为单位设置。 +- `lifetime_max` ([UInt64](/sql-reference/data-types/int-uint#integer-ranges)) — 内存中字典的最大 [生存时间](/sql-reference/dictionaries#refreshing-dictionary-data-using-lifetime),在此之后 ClickHouse 尝试重新加载字典(如果设置了 `invalidate_query`,则仅在字典已更改时)。以秒为单位设置。 - `loading_start_time` ([DateTime](../../sql-reference/data-types/datetime.md)) — 加载字典的开始时间。 - `last_successful_update_time` ([DateTime](../../sql-reference/data-types/datetime.md)) — 加载或更新字典的结束时间。帮助监控字典源的一些问题并调查原因。 - `error_count` ([UInt64](/sql-reference/data-types/int-uint#integer-ranges)) - 自上次成功加载以来的错误数量。帮助监控字典源的一些问题并调查原因。 - `loading_duration` ([Float32](../../sql-reference/data-types/float.md)) — 字典加载的持续时间。 -- `last_exception` ([String](../../sql-reference/data-types/string.md)) — 在创建或重新加载字典时出现的错误文本,如果字典无法创建。 -- `comment` ([String](../../sql-reference/data-types/string.md)) — 关于字典的评论文本。 +- `last_exception` ([String](../../sql-reference/data-types/string.md)) — 创建或重新加载字典时发生的错误文本,如果字典无法创建。 +- `comment` ([String](../../sql-reference/data-types/string.md)) — 字典的备注文本。 **示例** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/dictionaries.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/dictionaries.md.hash index ac5355103e8..68a34f69fda 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/dictionaries.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/dictionaries.md.hash @@ -1 +1 @@ -03b077e6403ebf52 +47880d44b75e010e diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/dimensional_metrics.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/dimensional_metrics.md new file mode 100644 index 00000000000..2c819167a9c --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/dimensional_metrics.md @@ -0,0 +1,57 @@ +--- +'description': '这个表包含可以即时计算并以 Prometheus 格式导出的维度指标。它始终是最新的。' +'keywords': +- 'system table' +- 'dimensional_metrics' +'slug': '/operations/system-tables/dimensional_metrics' +'title': 'system.dimensional_metrics' +'doc_type': 'reference' +--- + +import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_system_table_cloud.md'; + + +# dimensional_metrics {#dimensional_metrics} + + + +该表包含可以瞬时计算和以 Prometheus 格式导出的维度指标。它始终是最新的。 + +列: + +- `metric` ([String](../../sql-reference/data-types/string.md)) — 指标名称。 +- `value` ([Int64](../../sql-reference/data-types/int-uint.md)) — 指标值。 +- `description` ([String](../../sql-reference/data-types/string.md)) — 指标描述。 +- `labels` ([Map(String, String)](../../sql-reference/data-types/map.md)) — 指标标签。 +- `name` ([String](../../sql-reference/data-types/string.md)) — `metric` 的别名。 + +**示例** + +您可以使用如下查询导出所有维度指标的 Prometheus 格式。 +```sql +SELECT + metric AS name, + toFloat64(value) AS value, + description AS help, + labels, + 'gauge' AS type +FROM system.dimensional_metrics +FORMAT Prometheus +``` + +## Metric descriptions {#metric_descriptions} + +### merge_failures {#merge_failures} +自启动以来所有失败合并的数量。 + +### startup_scripts_failure_reason {#startup_scripts_failure_reason} +按错误类型指示启动脚本故障。启动脚本失败时设置为 1,并标记上错误名称。 + +### merge_tree_parts {#merge_tree_parts} +合并树数据部分的数量,按部分状态、部分类型以及是否为投影部分标记。 + +**另请参阅** +- [system.asynchronous_metrics](/operations/system-tables/asynchronous_metrics) — 包含定期计算的指标。 +- [system.events](/operations/system-tables/events) — 包含发生的多个事件。 +- [system.metric_log](/operations/system-tables/metric_log) — 包含来自 `system.metrics` 和 `system.events` 的指标值历史。 +- [Monitoring](../../operations/monitoring.md) — ClickHouse 监控的基础概念。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/dimensional_metrics.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/dimensional_metrics.md.hash new file mode 100644 index 00000000000..bc4f5cb4f1f --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/dimensional_metrics.md.hash @@ -0,0 +1 @@ +351a7755d560ee4e diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/disks.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/disks.md index e1e6a21622d..b3a239d52cb 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/disks.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/disks.md @@ -1,26 +1,27 @@ --- -'description': '系统表包含关于在服务器配置中定义的磁盘的信息' +'description': '系统表,包含在服务器配置中定义的磁盘信息' 'keywords': - 'system table' - 'disks' 'slug': '/operations/system-tables/disks' 'title': 'system.disks' +'doc_type': 'reference' --- import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_system_table_cloud.md'; -包含关于在 [服务器配置](../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-multiple-volumes_configure) 中定义的磁盘的信息。 +包含在 [服务器配置](../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-multiple-volumes_configure) 中定义的磁盘信息。 列: - `name` ([String](../../sql-reference/data-types/string.md)) — 服务器配置中磁盘的名称。 - `path` ([String](../../sql-reference/data-types/string.md)) — 文件系统中挂载点的路径。 - `free_space` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 磁盘上的可用空间(以字节为单位)。 -- `total_space` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 磁盘容量(以字节为单位)。 -- `unreserved_space` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 未被保留的可用空间(`free_space` 减去当前正在进行的合并、插入和其他磁盘写操作所占用的保留空间大小)。 -- `keep_free_space` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 磁盘上应保持的可用空间量(以字节为单位)。在磁盘配置的 `keep_free_space_bytes` 参数中定义。 +- `total_space` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 磁盘的总容量(以字节为单位)。 +- `unreserved_space` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 未被保留的可用空间(`free_space` 减去因合并、插入及其他当前正在进行的磁盘写入操作而占用的保留空间的大小)。 +- `keep_free_space` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 磁盘上应保持的可用空间(以字节为单位)。在磁盘配置的 `keep_free_space_bytes` 参数中定义。 **示例** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/disks.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/disks.md.hash index ed5cfb48e4d..97c362c3026 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/disks.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/disks.md.hash @@ -1 +1 @@ -3147749cd0102862 +a4a77102b387b02c diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/distributed_ddl_queue.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/distributed_ddl_queue.md index 51c0b6c842f..29b476a9dc4 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/distributed_ddl_queue.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/distributed_ddl_queue.md @@ -1,19 +1,20 @@ --- -'description': '系统表包含有关在集群上执行的分布式 ddl 查询(使用 ON CLUSTER 子句的查询)的信息。' +'description': '系统表包含关于在集群上执行的分布式 ddl 查询(使用 ON CLUSTER 子句的查询)的信息。' 'keywords': - 'system table' - 'distributed_ddl_queue' 'slug': '/operations/system-tables/distributed_ddl_queue' 'title': 'system.distributed_ddl_queue' +'doc_type': 'reference' --- -包含关于在集群中执行的 [分布式 DDL 查询 (ON CLUSTER 子句)](../../sql-reference/distributed-ddl.md) 的信息。 +包含关于在集群上执行的 [分布式 DDL 查询 (ON CLUSTER 子句)](../../sql-reference/distributed-ddl.md) 的信息。 列: -- `entry` ([String](../../sql-reference/data-types/string.md)) — 查询 ID。 +- `entry` ([String](../../sql-reference/data-types/string.md)) — 查询ID。 - `entry_version` ([Nullable(UInt8)](../../sql-reference/data-types/int-uint.md)) - 条目的版本 -- `initiator_host` ([Nullable(String)](../../sql-reference/data-types/string.md)) - 发起 DDL 操作的主机 +- `initiator_host` ([Nullable(String)](../../sql-reference/data-types/string.md)) - 发起 DDL 操作的主机 - `initiator_port` ([Nullable(UInt16)](../../sql-reference/data-types/int-uint.md)) - 发起者使用的端口 - `cluster` ([String](../../sql-reference/data-types/string.md)) — 集群名称。 - `query` ([String](../../sql-reference/data-types/string.md)) — 执行的查询。 @@ -21,11 +22,11 @@ - `query_create_time` ([DateTime](../../sql-reference/data-types/datetime.md)) — 查询创建时间。 - `host` ([String](../../sql-reference/data-types/string.md)) — 主机名 - `port` ([UInt16](../../sql-reference/data-types/int-uint.md)) — 主机端口。 -- `status` ([Enum8](../../sql-reference/data-types/enum.md)) — 查询状态。 +- `status` ([Enum8](../../sql-reference/data-types/enum.md)) — 查询的状态。 - `exception_code` ([Enum8](../../sql-reference/data-types/enum.md)) — 异常代码。 - `exception_text` ([Nullable(String)](../../sql-reference/data-types/string.md)) - 异常消息 - `query_finish_time` ([DateTime](../../sql-reference/data-types/datetime.md)) — 查询完成时间。 -- `query_duration_ms` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 查询执行持续时间(以毫秒为单位)。 +- `query_duration_ms` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 查询执行的持续时间(以毫秒为单位)。 **示例** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/distributed_ddl_queue.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/distributed_ddl_queue.md.hash index ce06dce79b4..c9e42183e6c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/distributed_ddl_queue.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/distributed_ddl_queue.md.hash @@ -1 +1 @@ -92ffdfad55d3b166 +bf8df3208d6e84c2 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/distribution_queue.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/distribution_queue.md index ff3a59f8aa3..fbcc871d065 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/distribution_queue.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/distribution_queue.md @@ -1,33 +1,34 @@ --- -'description': '系统表包含关于本地文件的信息,这些文件在等待被发送到分片。' +'description': '系统表,包含关于在队列中等待发送到分片的本地文件的信息。' 'keywords': - 'system table' - 'distribution_queue' 'slug': '/operations/system-tables/distribution_queue' 'title': 'system.distribution_queue' +'doc_type': 'reference' --- -包含有关本地文件的信息,这些文件在等待发送到分片。这些本地文件包含通过异步模式向分布式表插入新数据而创建的新分片。 +包含有关在队列中待发送到分片的本地文件的信息。这些本地文件包含通过异步模式向分布式表插入新数据而创建的新分区。 -列: +列: -- `database` ([String](../../sql-reference/data-types/string.md)) — 数据库的名称。 +- `database` ([String](../../sql-reference/data-types/string.md)) — 数据库名称。 -- `table` ([String](../../sql-reference/data-types/string.md)) — 表的名称。 +- `table` ([String](../../sql-reference/data-types/string.md)) — 表名称。 - `data_path` ([String](../../sql-reference/data-types/string.md)) — 本地文件所在文件夹的路径。 -- `is_blocked` ([UInt8](../../sql-reference/data-types/int-uint.md)) — 标志指示发送本地文件到服务器是否被阻塞。 +- `is_blocked` ([UInt8](../../sql-reference/data-types/int-uint.md)) — 标志,指示是否阻止将本地文件发送到服务器。 -- `error_count` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 错误数量。 +- `error_count` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 错误的数量。 -- `data_files` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 文件夹中的本地文件数量。 +- `data_files` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 文件夹中本地文件的数量。 -- `data_compressed_bytes` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 本地文件中压缩数据的大小(以字节为单位)。 +- `data_compressed_bytes` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 本地文件中压缩数据的大小,以字节为单位。 -- `broken_data_files` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 已标记为损坏的文件数量(由于错误)。 +- `broken_data_files` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 被标记为损坏的文件数量(由于错误)。 -- `broken_data_compressed_bytes` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 损坏文件中压缩数据的大小(以字节为单位)。 +- `broken_data_compressed_bytes` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 损坏文件中压缩数据的大小,以字节为单位。 - `last_exception` ([String](../../sql-reference/data-types/string.md)) — 关于发生的最后一个错误的文本消息(如果有的话)。 @@ -50,6 +51,6 @@ data_compressed_bytes: 499 last_exception: ``` -**另请参见** +**另见** - [分布式表引擎](../../engines/table-engines/special/distributed.md) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/distribution_queue.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/distribution_queue.md.hash index 2a8dbede30a..87e027d8176 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/distribution_queue.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/distribution_queue.md.hash @@ -1 +1 @@ -6653f47b0c52235b +890e56b1c6e0c088 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/dns_cache.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/dns_cache.md index 2b873489f89..69750f1fbdf 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/dns_cache.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/dns_cache.md @@ -1,27 +1,26 @@ --- -'description': '系统表包含关于缓存的 DNS 记录的信息。' +'description': '系统表包含有关缓存 DNS 记录的信息。' 'keywords': - 'system table' - 'dns_cache' 'slug': '/operations/system-tables/dns_cache' 'title': 'system.dns_cache' +'doc_type': 'reference' --- import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_system_table_cloud.md'; -包含有关缓存的 DNS 记录的信息。 +包含有关缓存 DNS 记录的信息。 列: - `hostname` ([String](../../sql-reference/data-types/string.md)) — 缓存的主机名 -- `ip_address` ([String](../../sql-reference/data-types/string.md)) — 主机名的 IP 地址 +- `ip_address` ([String](../../sql-reference/data-types/string.md)) — 主机名对应的 IP 地址 - `ip_family` ([Enum](../../sql-reference/data-types/enum.md)) — IP 地址的类型,可能的值: - - 'IPv4' - - 'IPv6' - - 'UNIX_LOCAL' -- `cached_at` ([DateTime](../../sql-reference/data-types/datetime.md)) - 记录被缓存的时间 + - 'IPv4' - 'IPv6' - 'UNIX_LOCAL' +- `cached_at` ([DateTime](../../sql-reference/data-types/datetime.md)) — 记录被缓存的时间 **示例** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/dns_cache.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/dns_cache.md.hash index 485108c2b4d..ab7f84e91b5 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/dns_cache.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/dns_cache.md.hash @@ -1 +1 @@ -b5df757a32ef85f9 +947410f71e44e775 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/dropped_tables.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/dropped_tables.md index 9853720889f..3fac8e8b453 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/dropped_tables.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/dropped_tables.md @@ -1,23 +1,24 @@ --- -'description': '系统表,包含有关执行 DROP TABLE 的表的信息,但尚未执行数据清理。' +'description': '系统表,包含有关执行 DROP TABLE 的表的信息,但尚未进行数据清理' 'keywords': - 'system table' - 'dropped_tables' 'slug': '/operations/system-tables/dropped_tables' 'title': 'system.dropped_tables' +'doc_type': 'reference' --- -包含有关已执行 DROP TABLE 的表的信息,但尚未执行数据清理。 +包含有关已执行 DROP TABLE 操作但尚未进行数据清理的表的信息。 列: -- `index` ([UInt32](../../sql-reference/data-types/int-uint.md)) — 在 marked_dropped_tables 队列中的索引。 +- `index` ([UInt32](../../sql-reference/data-types/int-uint.md)) — marked_dropped_tables 队列中的索引。 - `database` ([String](../../sql-reference/data-types/string.md)) — 数据库。 - `table` ([String](../../sql-reference/data-types/string.md)) — 表名。 - `uuid` ([UUID](../../sql-reference/data-types/uuid.md)) — 表的 uuid。 -- `engine` ([String](../../sql-reference/data-types/string.md)) — 表引擎名称。 -- `metadata_dropped_path` ([String](../../sql-reference/data-types/string.md)) — 表的元数据文件在 metadata_dropped 目录中的路径。 -- `table_dropped_time` ([DateTime](../../sql-reference/data-types/datetime.md)) — 安排在何时尝试删除表数据的时间。通常是指表被删除时加上 `database_atomic_delay_before_drop_table_sec`。 +- `engine` ([String](../../sql-reference/data-types/string.md)) — 表的引擎名称。 +- `metadata_dropped_path` ([String](../../sql-reference/data-types/string.md)) — 在 metadata_dropped 目录中表元数据文件的路径。 +- `table_dropped_time` ([DateTime](../../sql-reference/data-types/datetime.md)) — 下次计划删除表数据的时间。通常是表被删除时加上 `database_atomic_delay_before_drop_table_sec`。 **示例** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/dropped_tables.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/dropped_tables.md.hash index 5aad5d30428..698f265aa2f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/dropped_tables.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/dropped_tables.md.hash @@ -1 +1 @@ -62c55045c53810a9 +a107c4a23ef4be70 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/dropped_tables_parts.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/dropped_tables_parts.md index 8db1006cc11..73e75b02371 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/dropped_tables_parts.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/dropped_tables_parts.md @@ -1,17 +1,18 @@ --- -'description': '系统表包含有关从 `system.dropped_tables` 删除的 MergeTree 表的分区片段的信息' +'description': '系统表包含关于从 `system.dropped_tables` 删除的 MergeTree 表的分区片段信息' 'keywords': - 'system table' - 'dropped_tables_parts' 'slug': '/operations/system-tables/dropped_tables_parts' 'title': 'system.dropped_tables_parts' +'doc_type': 'reference' --- -包含关于从 [system.dropped_tables](./dropped_tables.md) 删除的 [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) 表的部分信息 +包含有关从 [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) 删除的表的 [system.dropped_tables](./dropped_tables.md) 的部分信息。 -该表的模式与 [system.parts](./parts.md) 相同 +该表的模式与 [system.parts](./parts.md) 相同。 -**另请参见** +**另请参阅** - [MergeTree 家族](../../engines/table-engines/mergetree-family/mergetree.md) - [system.parts](./parts.md) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/dropped_tables_parts.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/dropped_tables_parts.md.hash index 923584d6be5..122eb4ee918 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/dropped_tables_parts.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/dropped_tables_parts.md.hash @@ -1 +1 @@ -ebf5aca3eb7f91c6 +0575270ce851cdb1 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/enabled-roles.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/enabled-roles.md index 00d4883a379..c8a0e13b67f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/enabled-roles.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/enabled-roles.md @@ -1,17 +1,18 @@ --- -'description': '系统表包含当前所有活动角色,包括当前用户的当前角色和当前角色的授权角色' +'description': '系统表,包含当前所有活动角色,包括当前用户的当前角色和授予当前角色的角色' 'keywords': - 'system table' - 'enabled_roles' 'slug': '/operations/system-tables/enabled-roles' 'title': 'system.enabled_roles' +'doc_type': 'reference' --- -包含当前所有活动角色,包括当前用户的当前角色和当前角色的授权角色。 +包含目前所有活动角色,包括当前用户的当前角色和当前角色的授予角色。 列: - `role_name` ([String](../../sql-reference/data-types/string.md))) — 角色名称。 -- `with_admin_option` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) — 显示 `enabled_role` 是否具备 `ADMIN OPTION` 权限的标志。 -- `is_current` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) — 显示 `enabled_role` 是否为当前用户的当前角色的标志。 +- `with_admin_option` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) — 显示 `enabled_role` 是否为具有 `ADMIN OPTION` 权限的角色的标志。 +- `is_current` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) — 显示 `enabled_role` 是否为当前用户当前角色的标志。 - `is_default` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) — 显示 `enabled_role` 是否为默认角色的标志。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/enabled-roles.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/enabled-roles.md.hash index b2b4c594612..2d30efc1a52 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/enabled-roles.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/enabled-roles.md.hash @@ -1 +1 @@ -657f00d8dfcf29b6 +ad532797dbe160d9 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/enabled_roles.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/enabled_roles.md new file mode 100644 index 00000000000..b700adc41a3 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/enabled_roles.md @@ -0,0 +1,18 @@ +--- +'description': '系统表包含当前时刻所有活动角色,包括当前用户的当前角色和为当前角色授予的角色' +'keywords': +- 'system table' +- 'enabled_roles' +'slug': '/operations/system-tables/enabled_roles' +'title': 'system.enabled_roles' +'doc_type': 'reference' +--- + +包含所有当前活动的角色,包括当前用户的当前角色和当前角色授予的角色。 + +列: + +- `role_name` ([String](../../sql-reference/data-types/string.md))) — 角色名称。 +- `with_admin_option` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) —指示 `enabled_role` 是否具有 `ADMIN OPTION` 特权的标志。 +- `is_current` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) —指示 `enabled_role` 是否为当前用户的当前角色的标志。 +- `is_default` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) —指示 `enabled_role` 是否为默认角色的标志。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/enabled_roles.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/enabled_roles.md.hash new file mode 100644 index 00000000000..3a9f628b8f0 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/enabled_roles.md.hash @@ -0,0 +1 @@ +8cac9641f4b9b1cb diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/error_log.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/error_log.md index 3cd99bc52d0..078274b1c13 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/error_log.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/error_log.md @@ -1,10 +1,11 @@ --- -'description': '系统表包含 `system.errors` 表中错误值的历史记录,定期刷新到磁盘。' +'description': '系统表,包含来自表 `system.errors` 的错误值历史记录,定期刷新到磁盘。' 'keywords': - 'system table' - 'error_log' 'slug': '/operations/system-tables/system-error-log' 'title': 'system.error_log' +'doc_type': 'reference' --- import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_system_table_cloud.md'; @@ -14,13 +15,13 @@ import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/curre 包含来自表 `system.errors` 的错误值历史记录,定期刷新到磁盘。 列: -- `hostname` ([LowCardinality(String)](../../sql-reference/data-types/string.md)) — 执行查询的服务器的主机名。 +- `hostname` ([LowCardinality(String)](../../sql-reference/data-types/string.md)) — 执行查询的服务器主机名。 - `event_date` ([Date](../../sql-reference/data-types/date.md)) — 事件日期。 - `event_time` ([DateTime](../../sql-reference/data-types/datetime.md)) — 事件时间。 -- `code` ([Int32](../../sql-reference/data-types/int-uint.md)) — 错误代码编号。 -- `error` ([LowCardinality(String)](../../sql-reference/data-types/string.md)) - 错误名称。 -- `value` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 该错误发生的次数。 -- `remote` ([UInt8](../../sql-reference/data-types/int-uint.md)) — 远程异常(即在某个分布式查询期间收到的异常)。 +- `code` ([Int32](../../sql-reference/data-types/int-uint.md)) — 错误的代码编号。 +- `error` ([LowCardinality(String)](../../sql-reference/data-types/string.md)) - 错误的名称。 +- `value` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 此错误发生的次数。 +- `remote` ([UInt8](../../sql-reference/data-types/int-uint.md)) — 远程异常(即在分布式查询期间接收的异常)。 **示例** @@ -40,8 +41,8 @@ value: 2 remote: 0 ``` -**另见** +**另请参阅** -- [error_log 设置](../../operations/server-configuration-parameters/settings.md#error_log) — 启用和禁用该设置。 -- [system.errors](../../operations/system-tables/errors.md) — 包含错误代码以及它们被触发的次数。 -- [监控](../../operations/monitoring.md) — ClickHouse 监控的基本概念。 +- [error_log setting](../../operations/server-configuration-parameters/settings.md#error_log) — 启用和禁用此设置。 +- [system.errors](../../operations/system-tables/errors.md) — 包含错误代码及其触发次数。 +- [Monitoring](../../operations/monitoring.md) — ClickHouse 监控的基本概念。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/error_log.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/error_log.md.hash index f0559a74778..952b23f3c63 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/error_log.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/error_log.md.hash @@ -1 +1 @@ -5096897712f65ee3 +397dc805d034c851 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/errors.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/errors.md index 2e4e9a1bfb5..c1bf45819fe 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/errors.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/errors.md @@ -1,10 +1,11 @@ --- -'description': '系统表包含错误代码及其触发次数。' +'description': '系统表,包含错误代码以及它们触发的次数。' 'keywords': - 'system table' - 'errors' 'slug': '/operations/system-tables/errors' 'title': 'system.errors' +'doc_type': 'reference' --- import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_system_table_cloud.md'; @@ -13,6 +14,8 @@ import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/curre 包含错误代码及其触发次数。 +要显示所有可能的错误代码,包括未触发的错误代码,请将设置 [system_events_show_zero_values](../settings/settings.md#system_events_show_zero_values) 设置为 1。 + 列: - `name` ([String](../../sql-reference/data-types/string.md)) — 错误的名称 (`errorCodeToName`)。 @@ -20,11 +23,11 @@ import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/curre - `value` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 此错误发生的次数。 - `last_error_time` ([DateTime](../../sql-reference/data-types/datetime.md)) — 最后一次错误发生的时间。 - `last_error_message` ([String](../../sql-reference/data-types/string.md)) — 最后一次错误的消息。 -- `last_error_trace` ([Array(UInt64)](../../sql-reference/data-types/array.md)) — 表示调用方法存储的物理地址列表的 [堆栈跟踪](https://en.wikipedia.org/wiki/Stack_trace)。 -- `remote` ([UInt8](../../sql-reference/data-types/int-uint.md)) — 远程异常(即在分布式查询期间接收到的异常)。 +- `last_error_trace` ([Array(UInt64)](../../sql-reference/data-types/array.md)) — 一个 [堆栈跟踪](https://en.wikipedia.org/wiki/Stack_trace),表示调用方法存储的物理地址列表。 +- `remote` ([UInt8](../../sql-reference/data-types/int-uint.md)) — 远程异常(即在一次分布式查询中收到的异常)。 :::note -某些错误的计数器可能在查询成功执行期间增加。除非您确定相应的错误不会是误报,否则不建议将此表用于服务器监控目的。 +某些错误的计数器可能在成功的查询执行期间增加。除非您确定相应的错误不可能是误报,否则不推荐将此表用于服务器监控目的。 ::: **示例** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/errors.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/errors.md.hash index 675fa14e9af..a97f70a6ee6 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/errors.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/errors.md.hash @@ -1 +1 @@ -ce588dee92f86f3e +d688ba4fb7ae2ea3 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/events.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/events.md index 8d94398dde0..81e3e9e565d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/events.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/events.md @@ -1,22 +1,23 @@ --- -'description': '系统表,包含关于系统中发生的事件数量的信息。' +'description': '系统表,包含有关系统中发生的事件数量的信息。' 'keywords': - 'system table' - 'events' 'slug': '/operations/system-tables/events' 'title': 'system.events' +'doc_type': 'reference' --- import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_system_table_cloud.md'; -包含系统中发生的事件数量的信息。例如,在该表中,您可以找到自 ClickHouse 服务器启动以来处理的 `SELECT` 查询的数量。 +包含系统中发生事件的数量的信息。例如,在该表中,您可以找出自 ClickHouse 服务器启动以来处理了多少个 `SELECT` 查询。 列: - `event` ([String](../../sql-reference/data-types/string.md)) — 事件名称。 -- `value` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 发生的事件数量。 +- `value` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 发生事件的数量。 - `description` ([String](../../sql-reference/data-types/string.md)) — 事件描述。 - `name` ([String](../../sql-reference/data-types/string.md)) — `event` 的别名。 @@ -38,9 +39,9 @@ SELECT * FROM system.events LIMIT 5 └───────────────────────────────────────┴───────┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ ``` -**另见** +**另请参阅** - [system.asynchronous_metrics](/operations/system-tables/asynchronous_metrics) — 包含定期计算的指标。 - [system.metrics](/operations/system-tables/metrics) — 包含即时计算的指标。 -- [system.metric_log](/operations/system-tables/metric_log) — 包含来自表 `system.metrics` 和 `system.events` 的指标值历史。 +- [system.metric_log](/operations/system-tables/metric_log) — 包含来自 `system.metrics` 和 `system.events` 表的指标值历史。 - [监控](../../operations/monitoring.md) — ClickHouse 监控的基本概念。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/events.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/events.md.hash index 23861ded44c..745730bc631 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/events.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/events.md.hash @@ -1 +1 @@ -5b247c5cd04ea6a4 +63b77eb5240d6d11 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/functions.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/functions.md index d2f1ee9fb8d..04c680f1679 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/functions.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/functions.md @@ -5,25 +5,26 @@ - 'functions' 'slug': '/operations/system-tables/functions' 'title': 'system.functions' +'doc_type': 'reference' --- -包含关于普通函数和聚合函数的信息。 +包含关于常规和聚合函数的信息。 列: - `name` ([String](../../sql-reference/data-types/string.md)) – 函数的名称。 - `is_aggregate` ([UInt8](../../sql-reference/data-types/int-uint.md)) — 函数是否为聚合函数。 -- `case_insensitive` ([UInt8](../../sql-reference/data-types/int-uint.md)) - 函数名称是否可以不区分大小写使用。 -- `alias_to` ([String](../../sql-reference/data-types/string.md)) - 如果函数名称是别名,则为原始函数名称。 -- `create_query` ([String](../../sql-reference/data-types/enum.md)) - 未使用。 -- `origin` ([Enum8](../../sql-reference/data-types/string.md)) - 未使用。 -- `description` ([String](../../sql-reference/data-types/string.md)) - 对函数所做操作的高级描述。 -- `syntax` ([String](../../sql-reference/data-types/string.md)) - 函数的签名。 -- `arguments` ([String](../../sql-reference/data-types/string.md)) - 函数接受的参数。 -- `returned_value` ([String](../../sql-reference/data-types/string.md)) - 函数返回的值。 -- `examples` ([String](../../sql-reference/data-types/string.md)) - 函数的示例用法。 -- `introduced_in` ([String](../../sql-reference/data-types/string.md)) - 函数首次引入的 ClickHouse 版本。 -- `categories` ([String](../../sql-reference/data-types/string.md)) - 函数的类别。 +- `case_insensitive`,([UInt8](../../sql-reference/data-types/int-uint.md)) - 函数名称是否可以不区分大小写使用。 +- `alias_to`,([String](../../sql-reference/data-types/string.md)) - 原始函数名称,如果函数名称是别名。 +- `create_query`,([String](../../sql-reference/data-types/enum.md)) - 未使用。 +- `origin`,([Enum8](../../sql-reference/data-types/string.md)) - 未使用。 +- `description`,([String](../../sql-reference/data-types/string.md)) - 函数执行的高级描述。 +- `syntax`,([String](../../sql-reference/data-types/string.md)) - 函数的签名。 +- `arguments`,([String](../../sql-reference/data-types/string.md)) - 函数接受的参数。 +- `returned_value`,([String](../../sql-reference/data-types/string.md)) - 函数返回的值。 +- `examples`,([String](../../sql-reference/data-types/string.md)) - 函数的示例用法。 +- `introduced_in`,([String](../../sql-reference/data-types/string.md)) - 函数首次引入的 ClickHouse 版本。 +- `categories`,([String](../../sql-reference/data-types/string.md)) - 函数的类别。 **示例** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/functions.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/functions.md.hash index 38762febd9b..2340256fe30 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/functions.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/functions.md.hash @@ -1 +1 @@ -519462d8ae9c4272 +f8916a5e635fbf9e diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/grants.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/grants.md index 8344bb03c16..018dfbeafc4 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/grants.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/grants.md @@ -1,13 +1,14 @@ --- -'description': '系统表显示授予 ClickHouse 用户账户的权限。' +'description': '系统表显示授予哪些权限给 ClickHouse 用户账户。' 'keywords': - 'system table' - 'grants' 'slug': '/operations/system-tables/grants' 'title': 'system.grants' +'doc_type': 'reference' --- -授予 ClickHouse 用户帐户的权限。 +以下是授予 ClickHouse 用户帐户的权限。 列: - `user_name` ([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md))) — 用户名。 @@ -16,14 +17,14 @@ - `access_type` ([Enum8](../../sql-reference/data-types/enum.md)) — ClickHouse 用户帐户的访问参数。 -- `database` ([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md))) — 数据库的名称。 +- `database` ([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md))) — 数据库名称。 -- `table` ([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md))) — 表的名称。 +- `table` ([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md))) — 表名称。 -- `column` ([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md))) — 授予访问权限的列的名称。 +- `column` ([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md))) — 授予访问权限的列名称。 -- `is_partial_revoke` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) — 逻辑值。它显示是否撤销了一些权限。可能的值: - - `0` — 此行描述一个授权。 - - `1` — 此行描述部分撤销。 +- `is_partial_revoke` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) — 逻辑值。它表明是否撤销了一些权限。可能的值: + - `0` — 该行描述了一个授予。 + - `1` — 该行描述了部分撤销。 -- `grant_option` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) — 权限以 `WITH GRANT OPTION` 授予,详见 [GRANT](../../sql-reference/statements/grant.md#granting-privilege-syntax)。 +- `grant_option` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) — 授予的权限 `WITH GRANT OPTION`,请参阅 [GRANT](../../sql-reference/statements/grant.md#granting-privilege-syntax)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/grants.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/grants.md.hash index ec4626bebf5..a4eaae23f9c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/grants.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/grants.md.hash @@ -1 +1 @@ -21ad3859acd649a7 +90d3a79c2deec40d diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/graphite_retentions.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/graphite_retentions.md index d7aae59d16f..a40adde9187 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/graphite_retentions.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/graphite_retentions.md @@ -1,22 +1,23 @@ --- -'description': '系统表包含有关参数 `graphite_rollup` 的信息,这些参数用于具有 `GraphiteMergeTree` 类型引擎的表中。' +'description': '系统表包含关于参数 `graphite_rollup` 的信息,这些参数用于 `GraphiteMergeTree` 类型引擎的表中。' 'keywords': - 'system table' - 'graphite_retentions' 'slug': '/operations/system-tables/graphite_retentions' 'title': 'system.graphite_retentions' +'doc_type': 'reference' --- -包含有关参数 [graphite_rollup](../../operations/server-configuration-parameters/settings.md#graphite) 的信息,这些参数用于具有 [\*GraphiteMergeTree](../../engines/table-engines/mergetree-family/graphitemergetree.md) 引擎的表中。 +包含有关参数 [graphite_rollup](../../operations/server-configuration-parameters/settings.md#graphite) 的信息,这些参数用于具有 [\*GraphiteMergeTree](../../engines/table-engines/mergetree-family/graphitemergetree.md) 引擎的表。 列: -- `config_name` (字符串) - `graphite_rollup` 参数名称。 -- `regexp` (字符串) - 指标名称的模式。 -- `function` (字符串) - 聚合函数的名称。 -- `age` (UInt64) - 数据的最小年龄(秒)。 -- `precision` (UInt64) - 定义数据年龄的精确度(秒)。 +- `config_name` (String) - `graphite_rollup` 参数名称。 +- `regexp` (String) - 指标名称的模式。 +- `function` (String) - 聚合函数的名称。 +- `age` (UInt64) - 数据的最小年龄(以秒为单位)。 +- `precision` (UInt64) - 定义数据年龄的精确度(以秒为单位)。 - `priority` (UInt16) - 模式优先级。 -- `is_default` (UInt8) - 模式是否为默认值。 -- `Tables.database` (数组(字符串)) - 使用 `config_name` 参数的数据库表名称数组。 -- `Tables.table` (数组(字符串)) - 使用 `config_name` 参数的表名称数组。 +- `is_default` (UInt8) - 模式是否为默认。 +- `Tables.database` (Array(String)) - 使用 `config_name` 参数的数据库表的名称数组。 +- `Tables.table` (Array(String)) - 使用 `config_name` 参数的表名数组。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/graphite_retentions.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/graphite_retentions.md.hash index 97af09933e3..0286c9daf95 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/graphite_retentions.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/graphite_retentions.md.hash @@ -1 +1 @@ -5967090bda4cb244 +ed3588131810b4db diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/histogram_metrics.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/histogram_metrics.md index e057b8802ff..83a83819fd0 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/histogram_metrics.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/histogram_metrics.md @@ -1,10 +1,11 @@ --- -'description': '这个表包含可以即时计算并以 Prometheus 格式导出的直方图度量。它始终是最新的。' +'description': '这个表包含可以即时计算的直方图指标,并以 Prometheus 格式导出。它始终保持最新。' 'keywords': - 'system table' - 'histogram_metrics' -'slug': '/en/operations/system-tables/histogram_metrics' +'slug': '/operations/system-tables/histogram_metrics' 'title': 'system.histogram_metrics' +'doc_type': 'reference' --- import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_system_table_cloud.md'; @@ -14,7 +15,7 @@ import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/curre -此表包含可以即时计算并以 Prometheus 格式导出的直方图指标。它始终保持最新。 +此表包含可以即时计算并以 Prometheus 格式导出的直方图指标。它始终保持最新。替代了已弃用的 `system.latency_log`。 列: @@ -41,10 +42,10 @@ FORMAT Prometheus ## Metric descriptions {#metric_descriptions} ### keeper_response_time_ms_bucket {#keeper_response_time_ms_bucket} -Keeper的响应时间,以毫秒为单位。 +Keeper 的响应时间,单位为毫秒。 -**参见** +**另请参阅** - [system.asynchronous_metrics](/operations/system-tables/asynchronous_metrics) — 包含定期计算的指标。 -- [system.events](/operations/system-tables/events) — 包含发生的一些事件。 -- [system.metric_log](/operations/system-tables/metric_log) — 包含来自 `system.metrics` 和 `system.events` 表的指标值历史记录。 +- [system.events](/operations/system-tables/events) — 包含发生的多个事件。 +- [system.metric_log](/operations/system-tables/metric_log) — 包含表 `system.metrics` 和 `system.events` 的指标值历史。 - [Monitoring](../../operations/monitoring.md) — ClickHouse 监控的基本概念。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/histogram_metrics.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/histogram_metrics.md.hash index b5209a20533..43f7e2e72db 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/histogram_metrics.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/histogram_metrics.md.hash @@ -1 +1 @@ -78aa2ad5d51d237d +b8373bce4605c49f diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/iceberg_history.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/iceberg_history.md index 6d0a2bb6ade..081b023f60e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/iceberg_history.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/iceberg_history.md @@ -1,26 +1,27 @@ --- -'description': '系统冰山快照历史' +'description': '系统 iceberg 快照历史' 'keywords': - 'system iceberg_history' 'slug': '/operations/system-tables/iceberg_history' 'title': 'system.iceberg_history' +'doc_type': 'reference' --- # system.iceberg_history -包含冰山表的快照历史记录。 +这个系统表包含了存在于 ClickHouse 中的 Iceberg 表的快照历史。如果您在 ClickHouse 中没有任何 Iceberg 表,则该表将为空。 列: - `database` ([String](../../sql-reference/data-types/string.md)) — 表所在数据库的名称。 -- `name` ([String](../../sql-reference/data-types/string.md)) — 表名称。 +- `table` ([String](../../sql-reference/data-types/string.md)) — 表名。 -- `made_current_at` ([DateTime](../../sql-reference/data-types/uuid.md)) — 快照成为当前快照的时间。 +- `made_current_at` ([DateTime](../../sql-reference/data-types/uuid.md)) — 快照变为当前快照的时间。 -- `snapshot_id` ([Int64](../../sql-reference/data-types/int-uint.md)) — 快照ID。 +- `snapshot_id` ([Int64](../../sql-reference/data-types/int-uint.md)) — 快照 ID。 -- `parent_id` ([Int64](../../sql-reference/data-types/int-uint.md)) - 父快照的快照ID。 +- `parent_id` ([Int64](../../sql-reference/data-types/int-uint.md)) - 父快照的快照 ID。 -- `is_current_ancestor` ([Bool](../../sql-reference/data-types/boolean.md)) - 指示此快照是否为当前快照的祖先的标志。 +- `is_current_ancestor` ([Bool](../../sql-reference/data-types/boolean.md)) - 指示该快照是否为当前快照的祖先的标志。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/iceberg_history.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/iceberg_history.md.hash index 64215b37f0a..379000a0350 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/iceberg_history.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/iceberg_history.md.hash @@ -1 +1 @@ -375d502764a9b848 +38c649389ce67b72 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/iceberg_metadata_log.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/iceberg_metadata_log.md new file mode 100644 index 00000000000..0fcbf55072a --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/iceberg_metadata_log.md @@ -0,0 +1,90 @@ +--- +'description': '系统表包含从 Iceberg 表中读取的元数据文件的信息。每个条目代表一个根元数据文件、从 Avro 文件中提取的元数据,或者某个 + Avro 文件的条目。' +'keywords': +- 'system table' +- 'iceberg_metadata_log' +'slug': '/operations/system-tables/iceberg_metadata_log' +'title': 'system.iceberg_metadata_log' +'doc_type': 'reference' +--- + +import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_system_table_cloud.md'; + + +# system.iceberg_metadata_log + +`system.iceberg_metadata_log` 表记录了 ClickHouse 读取的 Iceberg 表的元数据访问和解析事件。它提供了每个处理的元数据文件或条目的详细信息,这对于调试、审计和理解 Iceberg 表结构演变非常有用。 + +## 目的 {#purpose} + +此表记录每个从 Iceberg 表读取的元数据文件和条目,包括根元数据文件、清单列表和清单条目。它帮助用户追踪 ClickHouse 如何解释 Iceberg 表的元数据,以及诊断与模式演变、文件解析或查询规划相关的问题。 + +:::note +此表主要用于调试目的。 +:::note + +## 列 {#columns} +| 名称 | 类型 | 描述 | +|----------------|-----------|------------------------------------------------------------------------------------------| +| `event_date` | [Date](../../sql-reference/data-types/date.md) | 日志条目的日期。 | +| `event_time` | [DateTime](../../sql-reference/data-types/datetime.md) | 事件的时间戳。 | +| `query_id` | [String](../../sql-reference/data-types/string.md) | 触发元数据读取的查询 ID。 | +| `content_type` | [Enum8](../../sql-reference/data-types/enum.md) | 元数据内容的类型(见下文)。 | +| `table_path` | [String](../../sql-reference/data-types/string.md) | Iceberg 表的路径。 | +| `file_path` | [String](../../sql-reference/data-types/string.md) | 根元数据 JSON 文件、Avro 清单列表或清单文件的路径。 | +| `content` | [String](../../sql-reference/data-types/string.md) | JSON 格式的内容(来自 .json 的原始元数据、Avro 元数据或 Avro 条目)。 | +| `row_in_file` | [Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md)) | 文件中的行号(如适用)。适用于 `ManifestListEntry` 和 `ManifestFileEntry` 内容类型。 | + +## `content_type` 值 {#content-type-values} + +- `None`: 无内容。 +- `Metadata`: 根元数据文件。 +- `ManifestListMetadata`: 清单列表元数据。 +- `ManifestListEntry`: 清单列表中的条目。 +- `ManifestFileMetadata`: 清单文件元数据。 +- `ManifestFileEntry`: 清单文件中的条目。 + + + +## 控制日志详细性 {#controlling-log-verbosity} + +您可以使用 [`iceberg_metadata_log_level`](../../operations/settings/settings.md#iceberg_metadata_log_level) 设置来控制记录哪些元数据事件。 + +要记录当前查询中使用的所有元数据: + +```sql +SELECT * FROM my_iceberg_table SETTINGS iceberg_metadata_log_level = 'manifest_file_entry'; + +SYSTEM FLUSH LOGS iceberg_metadata_log; + +SELECT content_type, file_path, row_in_file +FROM system.iceberg_metadata_log +WHERE query_id = '{previous_query_id}'; +``` + +要仅记录当前查询中使用的根元数据 JSON 文件: + +```sql +SELECT * FROM my_iceberg_table SETTINGS iceberg_metadata_log_level = 'metadata'; + +SYSTEM FLUSH LOGS iceberg_metadata_log; + +SELECT content_type, file_path, row_in_file +FROM system.iceberg_metadata_log +WHERE query_id = '{previous_query_id}'; +``` + +有关更多信息,请参见 [`iceberg_metadata_log_level`](../../operations/settings/settings.md#iceberg_metadata_log_level) 设置的描述。 + +### 需要注意 {#good-to-know} + +- 仅在您需要详细调查 Iceberg 表时,才在查询级别使用 `iceberg_metadata_log_level`。否则,您可能会用过多的元数据填充日志表,并体验到性能下降。 +- 该表可能包含重复条目,因为它主要用于调试,无法保证每个实体的唯一性。 +- 如果您使用的 `content_type` 比 `ManifestListMetadata` 更详细,则会禁用清单列表的 Iceberg 元数据缓存。 +- 同样,如果您使用的 `content_type` 比 `ManifestFileMetadata` 更详细,则会禁用清单文件的 Iceberg 元数据缓存。 + +## 参见 {#see-also} +- [Iceberg 表引擎](../../engines/table-engines/integrations/iceberg.md) +- [Iceberg 表函数](../../sql-reference/table-functions/iceberg.md) +- [system.iceberg_history](./iceberg_history.md) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/iceberg_metadata_log.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/iceberg_metadata_log.md.hash new file mode 100644 index 00000000000..b7f8ffe8b3c --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/iceberg_metadata_log.md.hash @@ -0,0 +1 @@ +b1d23abd490ab04d diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/index.md index c86a2c72737..04eeac1e928 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/index.md @@ -1,5 +1,5 @@ --- -'description': '关于系统表是什么以及它们为何有用的概述。' +'description': '系统表是什么以及它们为什么有用的概述。' 'keywords': - 'system tables' - 'overview' @@ -8,8 +8,130 @@ 'sidebar_position': 52 'slug': '/operations/system-tables/' 'title': '系统表' +'doc_type': 'reference' --- - +If you've spotted an error, please edit the YML frontmatter of the pages themselves. +--> + + +| 页面 | 描述 | +|-----|-----| +| [系统表概述](/operations/system-tables/overview) | 系统表是什么以及它们为什么有用的概述。 | +| [INFORMATION_SCHEMA](/operations/system-tables/information_schema) | 提供几乎标准化的与数据库管理系统无关的数据库对象元数据视图的系统数据库。 | +| [system.asynchronous_insert_log](/operations/system-tables/asynchronous_insert_log) | 包含有关异步插入的信息的系统表。每个条目代表被缓冲到异步插入查询中的插入查询。 | +| [system.asynchronous_loader](/operations/system-tables/asynchronous_loader) | 包含最近异步作业(例如,正在加载的表)的信息和状态的系统表。该表为每个作业包含一行。 | +| [system.asynchronous_metric_log](/operations/system-tables/asynchronous_metric_log) | 包含 `system.asynchronous_metrics` 的历史值的系统表,这些值每个时间间隔(默认为一秒)保存一次。 | +| [system.asynchronous_inserts](/operations/system-tables/asynchronous_inserts) | 包含有关队列中待处理异步插入的信息的系统表。 | +| [system.asynchronous_metrics](/operations/system-tables/asynchronous_metrics) | 包含在后台定期计算的指标的系统表。例如,使用的RAM的数量。 | +| [system.azure_queue_settings](/operations/system-tables/azure_queue_settings) | 包含AzureQueue表设置的信息的系统表。可从服务器版本 `24.10` 获得。 | +| [system.backup_log](/operations/system-tables/backup_log) | 包含有关 `BACKUP` 和 `RESTORE` 操作的信息的日志条目的系统表。 | +| [system.blob_storage_log](/operations/system-tables/blob_storage_log) | 包含有关各种blob存储操作(例如上传和删除)的信息的日志条目的系统表。 | +| [system.build_options](/operations/system-tables/build_options) | 包含ClickHouse服务器构建选项的信息的系统表。 | +| [system.clusters](/operations/system-tables/clusters) | 包含配置文件中可用的集群及其定义服务器的信息的系统表。 | +| [system.codecs](/operations/system-tables/codecs) | 包含队列中的编解码器的信息的系统表。 | +| [system.columns](/operations/system-tables/columns) | 包含所有表中列的信息的系统表。 | +| [system.contributors](/operations/system-tables/contributors) | 包含贡献者信息的系统表。 | +| [system.crash_log](/operations/system-tables/crash_log) | 包含导致致命错误的调用栈信息的系统表。 | +| [system.crash_log](/operations/system-tables/crash-log) | 包含导致致命错误的调用栈信息的系统表。 | +| [system.current_roles](/operations/system-tables/current-roles) | 包含当前用户的活动角色的系统表。 | +| [system.current_roles](/operations/system-tables/current_roles) | 包含当前用户的活动角色的系统表。 | +| [system.dashboards](/operations/system-tables/dashboards) | 包含用于通过HTTP接口访问的 `/dashboard` 页面使用的查询,对于监控和故障排除很有用。 | +| [system.data_skipping_indices](/operations/system-tables/data_skipping_indices) | 包含有关所有表中现有数据跳过索引的信息的系统表。 | +| [system.data_type_families](/operations/system-tables/data_type_families) | 包含支持的数据类型信息的系统表。 | +| [system.database_engines](/operations/system-tables/database_engines) | 包含服务器支持的数据库引擎列表的系统表。 | +| [system.database_replicas](/operations/system-tables/database_replicas) | 包含有关副本数据库的信息和状态的系统表。 | +| [system.databases](/operations/system-tables/databases) | 包含当前用户可用的数据库信息的系统表。 | +| [system.dead_letter_queue](/operations/system-tables/dead_letter_queue) | 包含通过流处理引擎接收到和解析错误信息的系统表。 | +| [system.delta_lake_metadata_log](/operations/system-tables/delta_lake_metadata_log) | 包含从Delta Lake表读取的元数据文件的信息的系统表。每个条目代表一个根元数据JSON文件。 | +| [system.detached_parts](/operations/system-tables/detached_parts) | 包含MergeTree表中分离部分的信息的系统表。 | +| [system.detached_tables](/operations/system-tables/detached_tables) | 包含每个分离表的信息的系统表。 | +| [system.dictionaries](/operations/system-tables/dictionaries) | 包含字典信息的系统表。 | +| [system.dimensional_metrics](/operations/system-tables/dimensional_metrics) | 此表包含可以立即计算并以Prometheus格式导出的维度指标。它始终是最新的。 | +| [system.disks](/operations/system-tables/disks) | 包含服务器配置中定义的磁盘信息的系统表。 | +| [system.distributed_ddl_queue](/operations/system-tables/distributed_ddl_queue) | 包含在集群上执行的分布式ddl查询的信息的系统表(使用ON CLUSTER子句的查询)。 | +| [system.distribution_queue](/operations/system-tables/distribution_queue) | 包含要发送到分片的队列中本地文件的信息的系统表。 | +| [system.dns_cache](/operations/system-tables/dns_cache) | 包含缓存的DNS记录的信息的系统表。 | +| [system.dropped_tables](/operations/system-tables/dropped_tables) | 包含对被执行DROP TABLE操作但尚未进行数据清理的表的信息的系统表。 | +| [system.dropped_tables_parts](/operations/system-tables/dropped_tables_parts) | 包含从 `system.dropped_tables` 删除的MergeTree表部分的信息的系统表。 | +| [system.enabled_roles](/operations/system-tables/enabled-roles) | 包含目前所有活动角色的信息的系统表,包括当前用户的当前角色和当前角色的授予角色。 | +| [system.enabled_roles](/operations/system-tables/enabled_roles) | 包含目前所有活动角色的信息的系统表,包括当前用户的当前角色和当前角色的授予角色。 | +| [system.error_log](/operations/system-tables/system-error-log) | 包含从表 `system.errors` 中周期性刷新到磁盘的错误值历史记录的系统表。 | +| [system.errors](/operations/system-tables/errors) | 包含错误代码及其触发次数的系统表。 | +| [system.events](/operations/system-tables/events) | 包含系统中发生的事件数量的信息的系统表。 | +| [system.functions](/operations/system-tables/functions) | 包含常规和聚合函数的信息的系统表。 | +| [system.grants](/operations/system-tables/grants) | 显示授予ClickHouse用户帐户的特权的系统表。 | +| [system.graphite_retentions](/operations/system-tables/graphite_retentions) | 包含在 `GraphiteMergeTree` 类型引擎中使用的参数 `graphite_rollup` 的信息的系统表。 | +| [system.histogram_metrics](/operations/system-tables/histogram_metrics) | 此表包含可以立即计算并以Prometheus格式导出的直方图指标。它始终是最新的。 | +| [system.iceberg_history](/operations/system-tables/iceberg_history) | 系统冰山快照历史。 | +| [system.iceberg_metadata_log](/operations/system-tables/iceberg_metadata_log) | 包含从Iceberg表读取的元数据文件的信息的系统表。每个条目代表一个根元数据文件、从Avro文件提取的元数据或某个Avro文件的条目。 | +| [system.jemalloc_bins](/operations/system-tables/jemalloc_bins) | 包含通过jemalloc分配器在不同大小类别(bins)中进行的内存分配的信息的系统表,聚合自所有区域。 | +| [system.kafka_consumers](/operations/system-tables/kafka_consumers) | 包含关于Kafka消费者的信息的系统表。 | +| [system.licenses](/operations/system-tables/licenses) | 包含位于ClickHouse源代码的贡献目录中的第三方库的许可证的系统表。 | +| [system.merge_tree_settings](/operations/system-tables/merge_tree_settings) | 包含有关MergeTree表设置的信息的系统表。 | +| [system.merges](/operations/system-tables/merges) | 包含当前正在进行的MergeTree家族表的合并和部分变更的信息的系统表。 | +| [system.metric_log](/operations/system-tables/metric_log) | 包含从表 `system.metrics` 和 `system.events` 中定期刷新到磁盘的指标值历史记录的系统表。 | +| [system.metrics](/operations/system-tables/metrics) | 包含可以立即计算或具有当前值的指标的系统表。 | +| [system.moves](/operations/system-tables/moves) | 包含MergeTree表中数据部分正在进行移动的信息的系统表。每个数据部分移动由一行表示。 | +| [system.mutations](/operations/system-tables/mutations) | 包含MergeTree表的变更及其进度的信息的系统表。每个变更命令由一行表示。 | +| [system.numbers_mt](/operations/system-tables/numbers_mt) | 与 `system.numbers` 类似的系统表,但读取是并行的,数字可以以任何顺序返回。 | +| [system.numbers](/operations/system-tables/numbers) | 包含名为 `number` 的单列UInt64,包含自零开始几乎所有自然数的系统表。 | +| [system.one](/operations/system-tables/one) | 包含一行及一个值为0的单列 `dummy` UInt8 的系统表。 类似于其他数据库管理系统中的 `DUAL` 表。 | +| [system.opentelemetry_span_log](/operations/system-tables/opentelemetry_span_log) | 包含有关执行查询的跟踪跨度的信息的系统表。 | +| [system.part_log](/operations/system-tables/part_log) | 包含在MergeTree家族表中与数据部分发生的事件(例如添加或合并数据)相关的信息的系统表。 | +| [system.parts](/operations/system-tables/parts) | 包含MergeTree部分的信息的系统表。 | +| [system.parts_columns](/operations/system-tables/parts_columns) | 包含MergeTree表部分及其列的信息的系统表。 | +| [system.processes](/operations/system-tables/processes) | 用于实现 `SHOW PROCESSLIST` 查询的系统表。 | +| [system.processors_profile_log](/operations/system-tables/processors_profile_log) | 包含关于处理器级别的分析信息的系统表(可以在 `EXPLAIN PIPELINE` 中找到)。 | +| [system.projection_parts_columns](/operations/system-tables/projection_parts_columns) | 包含MergeTree表投影部分中列的信息的系统表。 | +| [system.projection_parts](/operations/system-tables/projection_parts) | 包含MergeTree表投影部分的信息的系统表。 | +| [system.projections](/operations/system-tables/projections) | 包含所有表中现有投影的信息的系统表。 | +| [system.query_views_log](/operations/system-tables/query_views_log) | 包含在运行查询时执行的依赖视图的信息的系统表,例如视图类型或执行时间。 | +| [system.query_condition_cache](/operations/system-tables/query_condition_cache) | 显示查询条件缓存内容的系统表。 | +| [system.query_thread_log](/operations/system-tables/query_thread_log) | 包含执行查询的线程的信息的系统表,例如线程名称、线程开始时间和查询处理持续时间。 | +| [system.query_metric_log](/operations/system-tables/query_metric_log) | 包含从单个查询的表 `system.events` 中周期性刷新的内存和指标值历史记录的系统表。 | +| [system.query_log](/operations/system-tables/query_log) | 包含执行查询的信息的系统表,例如开始时间、处理持续时间和错误消息。 | +| [system.query_cache](/operations/system-tables/query_cache) | 显示查询缓存内容的系统表。 | +| [system.quota_usage](/operations/system-tables/quota_usage) | 包含当前用户的配额使用情况的信息的系统表,例如已用配额和剩余配额。 | +| [system.quota_limits](/operations/system-tables/quota_limits) | 包含所有配额所有时间段的最大值的信息的系统表。任意数量的行或零可以对应于一个配额。 | +| [system.quotas_usage](/operations/system-tables/quotas_usage) | 包含所有用户的配额使用情况的信息的系统表。 | +| [system.quotas](/operations/system-tables/quotas) | 包含配额信息的系统表。 | +| [system.replicas](/operations/system-tables/replicas) | 包含本地服务器上存储的副本表的信息及其状态的系统表。对于监控很有用。 | +| [system.replicated_fetches](/operations/system-tables/replicated_fetches) | 包含当前正在运行的后台获取的信息的系统表。 | +| [system.replication_queue](/operations/system-tables/replication_queue) | 包含存储在ClickHouse Keeper或ZooKeeper中的复制队列任务的信息的系统表,用于 `ReplicatedMergeTree` 家族的表。 | +| [system.resources](/operations/system-tables/resources) | 包含本地服务器上所有资源的信息的系统表,每个资源一行。 | +| [system.role_grants](/operations/system-tables/role_grants) | 包含用户和角色的角色授予的信息的系统表。 | +| [system.role_grants](/operations/system-tables/role-grants) | 包含用户和角色的角色授予的信息的系统表。 | +| [system.roles](/operations/system-tables/roles) | 包含已配置角色的信息的系统表。 | +| [system.row_policies](/operations/system-tables/row_policies) | 包含特定表的过滤器,以及应使用此行策略的角色和/或用户的列表的系统表。 | +| [system.s3_queue_settings](/operations/system-tables/s3_queue_settings) | 包含S3Queue表设置的信息的系统表。可从服务器版本 `24.10` 获得。 | +| [system.scheduler](/operations/system-tables/scheduler) | 包含本地服务器上调度节点的信息及其状态的系统表。 | +| [system.schema_inference_cache](/operations/system-tables/schema_inference_cache) | 包含所有缓存文件模式的信息的系统表。 | +| [system.server_settings](/operations/system-tables/server_settings) | 包含在 `config.xml` 中定义的服务器全局设置的信息的系统表。 | +| [system.session_log](/operations/system-tables/session_log) | 包含所有成功和失败的登录及登出事件的信息的系统表。 | +| [system.settings](/operations/system-tables/settings) | 包含当前用户的会话设置的信息的系统表。 | +| [system.settings_profile_elements](/operations/system-tables/settings_profile_elements) | 描述设置文件内容的系统表:约束、角色和适用用户、父级设置文件。 | +| [system.settings_changes](/operations/system-tables/settings_changes) | 包含先前ClickHouse版本中设置变更的信息的系统表。 | +| [system.settings_profiles](/operations/system-tables/settings_profiles) | 包含已配置的设置文件特性的系统表。 | +| [system.stack_trace](/operations/system-tables/stack_trace) | 包含所有服务器线程的调用栈的系统表。允许开发人员检查服务器状态。 | +| [system.storage_policies](/operations/system-tables/storage_policies) | 包含在服务器配置中定义的存储策略和卷的信息的系统表。 | +| [system.symbols](/operations/system-tables/symbols) | 对C++专家和ClickHouse工程师有用的系统表,包含用于检查 `clickhouse` 二进制文件的信息。 | +| [system.table_engines](/operations/system-tables/table_engines) | 包含服务器支持的表引擎及其支持功能描述的系统表。 | +| [system.tables](/operations/system-tables/tables) | 包含服务器所知的每个表的元数据的系统表。 | +| [system.text_log](/operations/system-tables/text_log) | 包含日志条目的系统表。 | +| [system.time_zones](/operations/system-tables/time_zones) | 包含ClickHouse服务器支持的时区列表的系统表。 | +| [system.trace_log](/operations/system-tables/trace_log) | 包含由采样查询分析器收集的调用栈的系统表。 | +| [system.user_processes](/operations/system-tables/user_processes) | 包含用于概览用户的内存使用情况和ProfileEvents的信息的系统表。 | +| [system.users](/operations/system-tables/users) | 包含在服务器上配置的用户帐户列表的系统表。 | +| [system.view_refreshes](/operations/system-tables/view_refreshes) | 包含有关可刷新的物化视图的信息的系统表。 | +| [system.warnings](/operations/system-tables/system_warnings) | 此表包含关于ClickHouse服务器的警告信息。 | +| [system.workloads](/operations/system-tables/workloads) | 包含本地服务器上工作负荷的信息的系统表。 | +| [system.zookeeper_log](/operations/system-tables/zookeeper_log) | 包含请求ZooKeeper服务器的参数和其响应的信息的系统表。 | +| [system.zookeeper_connection](/operations/system-tables/zookeeper_connection) | 仅在配置了ZooKeeper时存在的系统表。显示当前的ZooKeeper连接(包括辅助ZooKeeper)。 | +| [system.zookeeper_connection_log](/operations/system-tables/zookeeper_connection_log) | 显示ZooKeeper连接的历史记录(包括辅助ZooKeeper)。 | +| [system.zookeeper](/operations/system-tables/zookeeper) | 仅在配置了ClickHouse Keeper或ZooKeeper时存在的系统表。它暴露配置中定义的Keeper集群的数据。 | + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/index.md.hash index 75f0616f673..4e5db88d1c6 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/index.md.hash @@ -1 +1 @@ -a94b134eb37292da +9487c4e16c6c5df7 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/information_schema.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/information_schema.md index 6275364ef12..14a03d44fea 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/information_schema.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/information_schema.md @@ -5,9 +5,10 @@ - 'information_schema' 'slug': '/operations/system-tables/information_schema' 'title': 'INFORMATION_SCHEMA' +'doc_type': 'reference' --- -`INFORMATION_SCHEMA`(或:`information_schema`)是一个系统数据库,提供了一种(在某种程度上)标准化的、[与 DBMS 无关的视图](https://en.wikipedia.org/wiki/Information_schema),用于数据库对象的元数据。`INFORMATION_SCHEMA` 中的视图通常不如正常系统表强大,但工具可以使用它们以跨 DBMS 的方式获取基本信息。`INFORMATION_SCHEMA` 中视图的结构和内容应以向后兼容的方式演变,即只添加新功能,而不更改或删除现有功能。在内部实现方面,`INFORMATION_SCHEMA` 中的视图通常映射到正常系统表,如 [system.columns](../../operations/system-tables/columns.md)、[system.databases](../../operations/system-tables/databases.md) 和 [system.tables](../../operations/system-tables/tables.md)。 +`INFORMATION_SCHEMA`(或:`information_schema`)是一个系统数据库,它提供了一个(在某种程度上)标准化的、[与 DBMS 无关的视图](https://en.wikipedia.org/wiki/Information_schema),用于查看数据库对象的元数据。`INFORMATION_SCHEMA`中的视图通常不如普通系统表,但工具可以使用它们以跨 DBMS 的方式获取基本信息。`INFORMATION_SCHEMA`中视图的结构和内容应当以向后兼容的方式演进,即只添加新功能,但不更改或删除现有功能。在内部实现方面,`INFORMATION_SCHEMA`中的视图通常映射到普通系统表,如 [system.columns](../../operations/system-tables/columns.md)、[system.databases](../../operations/system-tables/databases.md) 和 [system.tables](../../operations/system-tables/tables.md)。 ```sql SHOW TABLES FROM INFORMATION_SCHEMA; @@ -35,7 +36,7 @@ SHOW TABLES FROM information_schema; └─────────────────────────┘ ``` -`INFORMATION_SCHEMA` 包含以下视图: +`INFORMATION_SCHEMA`包含以下视图: - [COLUMNS](#columns) - [KEY_COLUMN_USAGE](#key_column_usage) @@ -45,38 +46,38 @@ SHOW TABLES FROM information_schema; - [TABLES](#tables) - [VIEWS](#views) -还提供了不区分大小写的等效视图,例如 `INFORMATION_SCHEMA.columns`,以便与其他数据库兼容。对于这些视图中的所有列也是如此 - 提供了小写(例如 `table_name`)和大写(`TABLE_NAME`)两个变体。 +出于与其他数据库的兼容性,提供了不区分大小写的等效视图,例如 `INFORMATION_SCHEMA.columns`。同样适用于这些视图中的所有列 - 同时提供小写(例如,`table_name`)和大写(`TABLE_NAME`)变体。 ## COLUMNS {#columns} -包含从 [system.columns](../../operations/system-tables/columns.md) 系统表读取的列,以及在 ClickHouse 中不支持或没有意义(始终为 `NULL`)的列,但根据标准必须存在。 +包含从 [system.columns](../../operations/system-tables/columns.md) 系统表读取的列和在 ClickHouse 中不支持或没有意义的列(始终为 `NULL`),但必须符合标准。 列: -- `table_catalog`([String](../../sql-reference/data-types/string.md))— 表所在数据库的名称。 -- `table_schema`([String](../../sql-reference/data-types/string.md))— 表所在数据库的名称。 -- `table_name`([String](../../sql-reference/data-types/string.md))— 表名。 -- `column_name`([String](../../sql-reference/data-types/string.md))— 列名。 -- `ordinal_position`([UInt64](../../sql-reference/data-types/int-uint.md))— 列在表中的顺序位置,从 1 开始。 -- `column_default`([String](../../sql-reference/data-types/string.md))— 默认值的表达式,如果未定义则为空字符串。 -- `is_nullable`([UInt8](../../sql-reference/data-types/int-uint.md))— 表示列类型是否为 `Nullable` 的标志。 -- `data_type`([String](../../sql-reference/data-types/string.md))— 列类型。 -- `character_maximum_length`([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md)))— 二进制数据、字符数据或文本数据和图像的字节最大长度。在 ClickHouse 中仅对 `FixedString` 数据类型有意义。否则返回 `NULL` 值。 -- `character_octet_length`([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md)))— 二进制数据、字符数据或文本数据和图像的字节最大长度。在 ClickHouse 中仅对 `FixedString` 数据类型有意义。否则返回 `NULL` 值。 -- `numeric_precision`([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md)))— 近似数字数据、精确数字数据、整数数据或货币数据的精度。在 ClickHouse 中,它是整数类型的位宽和 `Decimal` 类型的十进制精度。否则返回 `NULL` 值。 -- `numeric_precision_radix`([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md)))— 数字系统的基数是近似数字数据、精确数字数据、整数数据或货币数据的精度。在 ClickHouse 中对于整数类型为 2,对于 `Decimal` 类型为 10。否则返回 `NULL` 值。 -- `numeric_scale`([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md)))— 近似数字数据、精确数字数据、整数数据或货币数据的.scale。在 ClickHouse 中仅对 `Decimal` 类型有意义。否则返回 `NULL` 值。 -- `datetime_precision`([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md)))— `DateTime64` 数据类型的十进制精度。对于其他数据类型,返回 `NULL` 值。 -- `character_set_catalog`([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md)))— `NULL`,不支持。 -- `character_set_schema`([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md)))— `NULL`,不支持。 -- `character_set_name`([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md)))— `NULL`,不支持。 -- `collation_catalog`([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md)))— `NULL`,不支持。 -- `collation_schema`([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md)))— `NULL`,不支持。 -- `collation_name`([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md)))— `NULL`,不支持。 -- `domain_catalog`([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md)))— `NULL`,不支持。 -- `domain_schema`([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md)))— `NULL`,不支持。 -- `domain_name`([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md)))— `NULL`,不支持。 -- `extra`([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md)))— `MATERIALIZED` 类型列的 `STORED GENERATED`,`ALIAS` 类型列的 `VIRTUAL GENERATED`, `DEFAULT` 类型列的 `DEFAULT_GENERATED`,或者 `NULL`。 +- `table_catalog` ([String](../../sql-reference/data-types/string.md)) — 表所在数据库的名称。 +- `table_schema` ([String](../../sql-reference/data-types/string.md)) — 表所在数据库的名称。 +- `table_name` ([String](../../sql-reference/data-types/string.md)) — 表名称。 +- `column_name` ([String](../../sql-reference/data-types/string.md)) — 列名称。 +- `ordinal_position` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 表中列的序号,从 1 开始。 +- `column_default` ([String](../../sql-reference/data-types/string.md)) — 默认值的表达式,如果未定义则为空字符串。 +- `is_nullable` ([UInt8](../../sql-reference/data-types/int-uint.md)) — 指示列类型是否为 `Nullable` 的标志。 +- `data_type` ([String](../../sql-reference/data-types/string.md)) — 列类型。 +- `character_maximum_length` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 对于二进制数据、字符数据或文本数据和图像的最大字节长度。在 ClickHouse 仅对 `FixedString` 数据类型有意义。否则,返回 `NULL` 值。 +- `character_octet_length` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 对于二进制数据、字符数据或文本数据和图像的最大字节长度。在 ClickHouse 仅对 `FixedString` 数据类型有意义。否则,返回 `NULL` 值。 +- `numeric_precision` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 近似数值数据、准确数值数据、整数数据或货币数据的精度。在 ClickHouse 中,它是整数类型的位宽和 `Decimal` 类型的十进制精度。否则,返回 `NULL` 值。 +- `numeric_precision_radix` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 数字系统的基数是近似数值数据、准确数值数据、整数数据或货币数据的精度。在 ClickHouse 中,对于整数类型为 2,`Decimal` 类型为 10。否则,返回 `NULL` 值。 +- `numeric_scale` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 近似数值数据、准确数值数据、整数数据或货币数据的刻度。在 ClickHouse 中仅对 `Decimal` 类型有意义。否则,返回 `NULL` 值。 +- `datetime_precision` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — `DateTime64` 数据类型的十进制精度。对于其他数据类型,返回 `NULL` 值。 +- `character_set_catalog` ([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md))) — `NULL`,不支持。 +- `character_set_schema` ([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md))) — `NULL`,不支持。 +- `character_set_name` ([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md))) — `NULL`,不支持。 +- `collation_catalog` ([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md))) — `NULL`,不支持。 +- `collation_schema` ([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md))) — `NULL`,不支持。 +- `collation_name` ([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md))) — `NULL`,不支持。 +- `domain_catalog` ([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md))) — `NULL`,不支持。 +- `domain_schema` ([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md))) — `NULL`,不支持。 +- `domain_name` ([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md))) — `NULL`,不支持。 +- `extra` ([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md))) — 对于 `MATERIALIZED` 类型的列为 `STORED GENERATED`,对于 `ALIAS` 类型的列为 `VIRTUAL GENERATED`,对于 `DEFAULT` 类型的列为 `DEFAULT_GENERATED`,或为 `NULL`。 **示例** @@ -147,17 +148,17 @@ domain_name: ᴺᵁᴸᴸ ## SCHEMATA {#schemata} -包含从 [system.databases](../../operations/system-tables/databases.md) 系统表中读取的列以及在 ClickHouse 中不支持或没有意义(始终为 `NULL`)的列,但根据标准必须存在。 +包含从 [system.databases](../../operations/system-tables/databases.md) 系统表读取的列,以及在 ClickHouse 中不支持或没有意义的列(始终为 `NULL`),但必须符合标准。 列: -- `catalog_name`([String](../../sql-reference/data-types/string.md))— 数据库的名称。 -- `schema_name`([String](../../sql-reference/data-types/string.md))— 数据库的名称。 -- `schema_owner`([String](../../sql-reference/data-types/string.md))— 模式所有者名称,始终为 `'default'`。 -- `default_character_set_catalog`([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md)))— `NULL`,不支持。 -- `default_character_set_schema`([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md)))— `NULL`,不支持。 -- `default_character_set_name`([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md)))— `NULL`,不支持。 -- `sql_path`([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md)))— `NULL`,不支持。 +- `catalog_name` ([String](../../sql-reference/data-types/string.md)) — 数据库的名称。 +- `schema_name` ([String](../../sql-reference/data-types/string.md)) — 数据库的名称。 +- `schema_owner` ([String](../../sql-reference/data-types/string.md)) — 模式所有者名称,始终为 `'default'`。 +- `default_character_set_catalog` ([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md))) — `NULL`,不支持。 +- `default_character_set_schema` ([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md))) — `NULL`,不支持。 +- `default_character_set_name` ([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md))) — `NULL`,不支持。 +- `sql_path` ([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md))) — `NULL`,不支持。 **示例** @@ -172,7 +173,7 @@ SELECT catalog_name, default_character_set_name, sql_path FROM information_schema.schemata -WHERE schema_name ilike 'information_schema' +WHERE schema_name ILIKE 'information_schema' LIMIT 1 FORMAT Vertical; ``` @@ -197,20 +198,20 @@ sql_path: ᴺᵁᴸᴸ 列: -- `table_catalog`([String](../../sql-reference/data-types/string.md))— 表所在数据库的名称。 -- `table_schema`([String](../../sql-reference/data-types/string.md))— 表所在数据库的名称。 -- `table_name`([String](../../sql-reference/data-types/string.md))— 表名。 -- `table_type`([String](../../sql-reference/data-types/string.md))— 表类型。可能的值: - - `BASE TABLE` - - `VIEW` - - `FOREIGN TABLE` - - `LOCAL TEMPORARY` - - `SYSTEM VIEW` -- `table_rows`([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md)))— 行的总数。如果无法确定则为 NULL。 -- `data_length`([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md)))— 磁盘上的数据大小。如果无法确定则为 NULL。 -- `index_length`([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md)))— 主键、次级索引和所有标记的总大小。 -- `table_collation`([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md)))— 表的默认校对规则。始终为 `utf8mb4_0900_ai_ci`。 -- `table_comment`([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md)))— 创建表时使用的注释。 +- `table_catalog` ([String](../../sql-reference/data-types/string.md)) — 表所在数据库的名称。 +- `table_schema` ([String](../../sql-reference/data-types/string.md)) — 表所在数据库的名称。 +- `table_name` ([String](../../sql-reference/data-types/string.md)) — 表名称。 +- `table_type` ([String](../../sql-reference/data-types/string.md)) — 表类型。可能的值: + - `BASE TABLE` + - `VIEW` + - `FOREIGN TABLE` + - `LOCAL TEMPORARY` + - `SYSTEM VIEW` +- `table_rows` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 行的总数。如果无法确定,则返回 NULL。 +- `data_length` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 磁盘上数据的大小。如果无法确定,则返回 NULL。 +- `index_length` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 主键、二级索引和所有标记的总大小。 +- `table_collation` ([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md))) — 表的默认排序规则。始终为 `utf8mb4_0900_ai_ci`。 +- `table_comment` ([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md))) — 创建表时使用的注释。 **示例** @@ -249,18 +250,18 @@ table_comment: 列: -- `table_catalog`([String](../../sql-reference/data-types/string.md))— 表所在数据库的名称。 -- `table_schema`([String](../../sql-reference/data-types/string.md))— 表所在数据库的名称。 -- `table_name`([String](../../sql-reference/data-types/string.md))— 表名。 -- `view_definition`([String](../../sql-reference/data-types/string.md))— 视图的 `SELECT` 查询。 -- `check_option`([String](../../sql-reference/data-types/string.md))— `NONE`,不检查。 -- `is_updatable`([Enum8](../../sql-reference/data-types/enum.md))— `NO`,视图不可更新。 -- `is_insertable_into`([Enum8](../../sql-reference/data-types/enum.md))— 显示创建的视图是否是 [materialized](/sql-reference/statements/create/view#materialized-view)。可能的值: - - `NO` — 创建的视图不是物化视图。 - - `YES` — 创建的视图是物化视图。 -- `is_trigger_updatable`([Enum8](../../sql-reference/data-types/enum.md))— `NO`,触发器不可更新。 -- `is_trigger_deletable`([Enum8](../../sql-reference/data-types/enum.md))— `NO`,触发器不可删除。 -- `is_trigger_insertable_into`([Enum8](../../sql-reference/data-types/enum.md))— `NO`,没有数据插入到触发器中。 +- `table_catalog` ([String](../../sql-reference/data-types/string.md)) — 表所在数据库的名称。 +- `table_schema` ([String](../../sql-reference/data-types/string.md)) — 表所在数据库的名称。 +- `table_name` ([String](../../sql-reference/data-types/string.md)) — 表名称。 +- `view_definition` ([String](../../sql-reference/data-types/string.md)) — 视图的 `SELECT` 查询。 +- `check_option` ([String](../../sql-reference/data-types/string.md)) — `NONE`,无检查。 +- `is_updatable` ([Enum8](../../sql-reference/data-types/enum.md)) — `NO`,视图不可更新。 +- `is_insertable_into` ([Enum8](../../sql-reference/data-types/enum.md)) — 显示创建的视图是否为 [materialized](/sql-reference/statements/create/view#materialized-view)。可能的值: + - `NO` — 创建的视图不是物化的。 + - `YES` — 创建的视图是物化的。 +- `is_trigger_updatable` ([Enum8](../../sql-reference/data-types/enum.md)) — `NO`,触发器不可更新。 +- `is_trigger_deletable` ([Enum8](../../sql-reference/data-types/enum.md)) — `NO`,触发器不可删除。 +- `is_trigger_insertable_into` ([Enum8](../../sql-reference/data-types/enum.md)) — `NO`,触发器中不插入数据。 **示例** @@ -304,22 +305,22 @@ is_trigger_insertable_into: NO ## KEY_COLUMN_USAGE {#key_column_usage} -包含来自 [system.tables](../../operations/system-tables/tables.md) 系统表的列,这些列受约束限制。 +包含来自 [system.tables](../../operations/system-tables/tables.md) 系统表的列,这些列受到约束的限制。 列: -- `constraint_catalog`([String](../../sql-reference/data-types/string.md))— 当前未使用。始终为 `def`。 -- `constraint_schema`([String](../../sql-reference/data-types/string.md))— 约束所属的模式(数据库)名称。 -- `constraint_name`([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md)))— 约束的名称。 -- `table_catalog`([String](../../sql-reference/data-types/string.md))— 当前未使用。始终为 `def`。 -- `table_schema`([String](../../sql-reference/data-types/string.md))— 表所属模式(数据库)的名称。 -- `table_name`([String](../../sql-reference/data-types/string.md))— 具有约束的表名称。 -- `column_name`([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md)))— 具有约束的列名称。 -- `ordinal_position`([UInt32](../../sql-reference/data-types/int-uint.md))— 当前未使用。始终为 `1`。 -- `position_in_unique_constraint`([Nullable](../../sql-reference/data-types/nullable.md)([UInt32](../../sql-reference/data-types/int-uint.md)))— 当前未使用。始终为 `NULL`。 -- `referenced_table_schema`([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md)))— 当前未使用。始终为 NULL。 -- `referenced_table_name`([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md)))— 当前未使用。始终为 NULL。 -- `referenced_column_name`([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md)))— 当前未使用。始终为 NULL。 +- `constraint_catalog` ([String](../../sql-reference/data-types/string.md)) — 当前未使用。始终为 `def`。 +- `constraint_schema` ([String](../../sql-reference/data-types/string.md)) — 约束所属的模式(数据库)的名称。 +- `constraint_name` ([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md))) — 约束的名称。 +- `table_catalog` ([String](../../sql-reference/data-types/string.md)) — 当前未使用。始终为 `def`。 +- `table_schema` ([String](../../sql-reference/data-types/string.md)) — 表所属的模式(数据库)的名称。 +- `table_name` ([String](../../sql-reference/data-types/string.md)) — 具有约束的表的名称。 +- `column_name` ([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md))) — 具有约束的列的名称。 +- `ordinal_position` ([UInt32](../../sql-reference/data-types/int-uint.md)) — 当前未使用。始终为 `1`。 +- `position_in_unique_constraint` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt32](../../sql-reference/data-types/int-uint.md))) — 当前未使用。始终为 `NULL`。 +- `referenced_table_schema` ([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md))) — 当前未使用。始终为 NULL。 +- `referenced_table_name` ([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md))) — 当前未使用。始终为 NULL。 +- `referenced_column_name` ([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md))) — 当前未使用。始终为 NULL。 **示例** @@ -363,43 +364,43 @@ referenced_column_name: ᴺᵁᴸᴸ ## REFERENTIAL_CONSTRAINTS {#referential_constraints} -包含关于外键的信息。目前返回空结果(没有行),这只是为了与像 Tableau Online 的第三方工具提供兼容性。 +包含有关外键的信息。目前返回空结果(无行),这仅足以提供与第三方工具(如 Tableau Online)的兼容性。 列: -- `constraint_catalog`([String](../../sql-reference/data-types/string.md))— 当前未使用。 -- `constraint_schema`([String](../../sql-reference/data-types/string.md))— 当前未使用。 -- `constraint_name`([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md)))— 当前未使用。 -- `unique_constraint_catalog`([String](../../sql-reference/data-types/string.md))— 当前未使用。 -- `unique_constraint_schema`([String](../../sql-reference/data-types/string.md))— 当前未使用。 -- `unique_constraint_name`([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md)))— 当前未使用。 -- `match_option`([String](../../sql-reference/data-types/string.md))— 当前未使用。 -- `update_rule`([String](../../sql-reference/data-types/string.md))— 当前未使用。 -- `delete_rule`([String](../../sql-reference/data-types/string.md))— 当前未使用。 -- `table_name`([String](../../sql-reference/data-types/string.md))— 当前未使用。 -- `referenced_table_name`([String](../../sql-reference/data-types/string.md))— 当前未使用。 +- `constraint_catalog` ([String](../../sql-reference/data-types/string.md)) — 当前未使用。 +- `constraint_schema` ([String](../../sql-reference/data-types/string.md)) — 当前未使用。 +- `constraint_name` ([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md))) — 当前未使用。 +- `unique_constraint_catalog` ([String](../../sql-reference/data-types/string.md)) — 当前未使用。 +- `unique_constraint_schema` ([String](../../sql-reference/data-types/string.md)) — 当前未使用。 +- `unique_constraint_name` ([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md))) — 当前未使用。 +- `match_option` ([String](../../sql-reference/data-types/string.md)) — 当前未使用。 +- `update_rule` ([String](../../sql-reference/data-types/string.md)) — 当前未使用。 +- `delete_rule` ([String](../../sql-reference/data-types/string.md)) — 当前未使用。 +- `table_name` ([String](../../sql-reference/data-types/string.md)) — 当前未使用。 +- `referenced_table_name` ([String](../../sql-reference/data-types/string.md)) — 当前未使用。 ## STATISTICS {#statistics} -提供有关表索引的信息。目前返回空结果(没有行),这只是为了与像 Tableau Online 的第三方工具提供兼容性。 +提供有关表索引的信息。目前返回空结果(无行),这仅足以提供与第三方工具(如 Tableau Online)的兼容性。 列: -- `table_catalog`([String](../../sql-reference/data-types/string.md))— 当前未使用。 -- `table_schema`([String](../../sql-reference/data-types/string.md))— 当前未使用。 -- `table_name`([String](../../sql-reference/data-types/string.md))— 当前未使用。 -- `non_unique`([Int32](../../sql-reference/data-types/int-uint.md))— 当前未使用。 -- `index_schema`([String](../../sql-reference/data-types/string.md))— 当前未使用。 -- `index_name`([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md)))— 当前未使用。 -- `seq_in_index`([UInt32](../../sql-reference/data-types/int-uint.md))— 当前未使用。 -- `column_name`([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md)))— 当前未使用。 -- `collation`([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md)))— 当前未使用。 -- `cardinality`([Nullable](../../sql-reference/data-types/nullable.md)([Int64](../../sql-reference/data-types/int-uint.md)))— 当前未使用。 -- `sub_part`([Nullable](../../sql-reference/data-types/nullable.md)([Int64](../../sql-reference/data-types/int-uint.md)))— 当前未使用。 -- `packed`([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md)))— 当前未使用。 -- `nullable`([String](../../sql-reference/data-types/string.md))— 当前未使用。 -- `index_type`([String](../../sql-reference/data-types/string.md))— 当前未使用。 -- `comment`([String](../../sql-reference/data-types/string.md))— 当前未使用。 -- `index_comment`([String](../../sql-reference/data-types/string.md))— 当前未使用。 -- `is_visible`([String](../../sql-reference/data-types/string.md))— 当前未使用。 -- `expression`([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md)))— 当前未使用。 +- `table_catalog` ([String](../../sql-reference/data-types/string.md)) — 当前未使用。 +- `table_schema` ([String](../../sql-reference/data-types/string.md)) — 当前未使用。 +- `table_name` ([String](../../sql-reference/data-types/string.md)) — 当前未使用。 +- `non_unique` ([Int32](../../sql-reference/data-types/int-uint.md)) — 当前未使用。 +- `index_schema` ([String](../../sql-reference/data-types/string.md)) — 当前未使用。 +- `index_name` ([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md))) — 当前未使用。 +- `seq_in_index` ([UInt32](../../sql-reference/data-types/int-uint.md)) — 当前未使用。 +- `column_name` ([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md))) — 当前未使用。 +- `collation` ([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md))) — 当前未使用。 +- `cardinality` ([Nullable](../../sql-reference/data-types/nullable.md)([Int64](../../sql-reference/data-types/int-uint.md))) — 当前未使用。 +- `sub_part` ([Nullable](../../sql-reference/data-types/nullable.md)([Int64](../../sql-reference/data-types/int-uint.md))) — 当前未使用。 +- `packed` ([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md))) — 当前未使用。 +- `nullable` ([String](../../sql-reference/data-types/string.md)) — 当前未使用。 +- `index_type` ([String](../../sql-reference/data-types/string.md)) — 当前未使用。 +- `comment` ([String](../../sql-reference/data-types/string.md)) — 当前未使用。 +- `index_comment` ([String](../../sql-reference/data-types/string.md)) — 当前未使用。 +- `is_visible` ([String](../../sql-reference/data-types/string.md)) — 当前未使用。 +- `expression` ([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md))) — 当前未使用。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/information_schema.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/information_schema.md.hash index 6c05c959210..40ec33a90e8 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/information_schema.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/information_schema.md.hash @@ -1 +1 @@ -ef16c01f7ebf113d +2b90d65d26e48dd1 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/jemalloc_bins.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/jemalloc_bins.md index 3d5616740ff..a10f19d924d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/jemalloc_bins.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/jemalloc_bins.md @@ -1,30 +1,31 @@ --- -'description': '系统表包含通过 jemalloc 分配器在不同大小类(bins)中进行的内存分配的信息,这些信息是从所有竞技场汇总而来的。' +'description': '系统表包含通过 jemalloc 分配器在不同大小类别(bins)中进行的内存分配信息,该信息来自所有领域的汇总.' 'keywords': - 'system table' - 'jemalloc_bins' 'slug': '/operations/system-tables/jemalloc_bins' 'title': 'system.jemalloc_bins' +'doc_type': 'reference' --- import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_system_table_cloud.md'; -包含通过 jemalloc 分配器在不同大小类别(箱)中进行的内存分配信息,这些信息是从所有领域中聚合而来的。 -由于 jemalloc 中的线程本地缓存,这些统计信息可能并不绝对准确。 +包含通过 jemalloc 分配器在不同大小类别(bins)中进行的内存分配的信息,这些信息是从所有领域中聚合而来的。 +由于 jemalloc 中的线程本地缓存,这些统计数据可能并不完全准确。 列: -- `index` (UInt64) — 按大小排序的箱的索引 -- `large` (Bool) — 对于大规模分配为真,对于小规模分配为假 -- `size` (UInt64) — 此箱中分配的大小 +- `index` (UInt64) — 按大小排序的 bin 索引 +- `large` (Bool) — 对于大分配为 True,对于小分配为 False +- `size` (UInt64) — 该 bin 中分配的大小 - `allocations` (UInt64) — 分配的数量 -- `deallocations` (UInt64) — 释放的数量 +- `deallocations` (UInt64) — 取消分配的数量 **示例** -查找对当前整体内存使用贡献最大分配的大小。 +查找对当前整体内存使用最有贡献的分配大小。 ```sql SELECT diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/jemalloc_bins.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/jemalloc_bins.md.hash index aa7f17cacda..ba8e206e0df 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/jemalloc_bins.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/jemalloc_bins.md.hash @@ -1 +1 @@ -72f85d03625349ae +a0488ef122c2c6b5 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/kafka_consumers.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/kafka_consumers.md index eadd558f6d6..53ea30ce0b6 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/kafka_consumers.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/kafka_consumers.md @@ -1,10 +1,11 @@ --- -'description': '系统表包含有关 Kafka 消费者的信息。' +'description': '系统表包含关于 Kafka 消费者的信息。' 'keywords': - 'system table' - 'kafka_consumers' 'slug': '/operations/system-tables/kafka_consumers' 'title': 'system.kafka_consumers' +'doc_type': 'reference' --- import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_system_table_cloud.md'; @@ -16,24 +17,24 @@ import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/curre 列: -- `database` (字符串) - Kafka 引擎表的数据库。 -- `table` (字符串) - Kafka 引擎表的名称。 -- `consumer_id` (字符串) - Kafka 消费者标识符。注意,一个表可以有多个消费者。由 `kafka_num_consumers` 参数指定。 -- `assignments.topic` (数组(字符串)) - Kafka 主题。 -- `assignments.partition_id` (数组(整型)) - Kafka 分区 ID。注意,每个分区只能分配给一个消费者。 -- `assignments.current_offset` (数组(64 位整型)) - 当前偏移量。 -- `exceptions.time` (数组(日期时间)) - 生成最近 10 个异常的时间戳。 -- `exceptions.text` (数组(字符串)) - 最近 10 个异常的文本。 -- `last_poll_time` (日期时间) - 最近一次轮询的时间戳。 -- `num_messages_read` (无符号 64 位整型) - 消费者读取的消息数量。 -- `last_commit_time` (日期时间) - 最近一次提交的时间戳。 -- `num_commits` (无符号 64 位整型) - 消费者的总提交次数。 -- `last_rebalance_time` (日期时间) - 最近一次 Kafka 重新平衡的时间戳。 -- `num_rebalance_revocations` (无符号 64 位整型) - 消费者被撤销分区的次数。 -- `num_rebalance_assignments` (无符号 64 位整型) - 消费者被分配到 Kafka 集群的次数。 -- `is_currently_used` (无符号 8 位整型) - 消费者是否在使用中。 -- `last_used` (无符号 64 位整型) - 此消费者最后一次使用的时间,单位为微秒的 unix 时间。 -- `rdkafka_stat` (字符串) - 库的内部统计信息。请参见 https://github.com/ClickHouse/librdkafka/blob/master/STATISTICS.md。将 `statistics_interval_ms` 设置为 0 以禁用,默认值为 3000(每三秒一次)。 +- `database` (String) - 带有 Kafka 引擎的表的数据库。 +- `table` (String) - 带有 Kafka 引擎的表的名称。 +- `consumer_id` (String) - Kafka 消费者标识符。请注意,一个表可以有多个消费者。由 `kafka_num_consumers` 参数指定。 +- `assignments.topic` (Array(String)) - Kafka 主题。 +- `assignments.partition_id` (Array(Int32)) - Kafka 分区 ID。请注意,一个分区只能分配给一个消费者。 +- `assignments.current_offset` (Array(Int64)) - 当前偏移量。 +- `exceptions.time` (Array(DateTime)) - 生成最近 10 个异常的时间戳。 +- `exceptions.text` (Array(String)) - 最近 10 个异常的文本。 +- `last_poll_time` (DateTime) - 最近一次投票的时间戳。 +- `num_messages_read` (UInt64) - 消费者读取的消息数量。 +- `last_commit_time` (DateTime) - 最近一次提交的时间戳。 +- `num_commits` (UInt64) - 消费者的总提交次数。 +- `last_rebalance_time` (DateTime) - 最近一次 Kafka 重新平衡的时间戳。 +- `num_rebalance_revocations` (UInt64) - 消费者被撤销其分区的次数。 +- `num_rebalance_assignments` (UInt64) - 消费者被分配到 Kafka 集群的次数。 +- `is_currently_used` (UInt8) - 消费者是否在使用中。 +- `last_used` (UInt64) - 此消费者最后一次使用的时间,单位为微秒的 Unix 时间。 +- `rdkafka_stat` (String) - 库的内部统计信息。请参见 https://github.com/ClickHouse/librdkafka/blob/master/STATISTICS.md。将 `statistics_interval_ms` 设置为 0 可禁用,默认值为 3000(每三秒一次)。 示例: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/kafka_consumers.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/kafka_consumers.md.hash index 1f1f5028db4..1bc35b5e455 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/kafka_consumers.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/kafka_consumers.md.hash @@ -1 +1 @@ -26e70231ef60dc3c +b11fecbc74eb21dc diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/latency_buckets.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/latency_buckets.md deleted file mode 100644 index 0e44776f1cc..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/latency_buckets.md +++ /dev/null @@ -1,40 +0,0 @@ ---- -'description': '系统表包含关于 `latency_log` 使用的桶边界的信息。' -'keywords': -- 'system table' -- 'latency_buckets' -'slug': '/operations/system-tables/latency_buckets' -'title': 'system.latency_buckets' ---- - - -# system.latency_buckets - -包含由 [latency_log](../../operations/system-tables/latency_log.md) 使用的桶边界。 - -**示例** - -```sql -SELECT * FROM system.latency_buckets FORMAT Vertical; -``` - -```text -Row 1: -────── -LatencyEvent_S3FirstByteReadAttempt1Microseconds: [100,1000,10000,100000,300000,500000,1000000,2000000,5000000,10000000,15000000,20000000,25000000,30000000,35000000,4294967295] -LatencyEvent_S3FirstByteWriteAttempt1Microseconds: [100,1000,10000,100000,300000,500000,1000000,2000000,5000000,10000000,15000000,20000000,25000000,30000000,35000000,4294967295] -LatencyEvent_S3FirstByteReadAttempt2Microseconds: [100,1000,10000,100000,300000,500000,1000000,2000000,5000000,10000000,15000000,20000000,25000000,30000000,35000000,4294967295] -LatencyEvent_S3FirstByteWriteAttempt2Microseconds: [100,1000,10000,100000,300000,500000,1000000,2000000,5000000,10000000,15000000,20000000,25000000,30000000,35000000,4294967295] -LatencyEvent_S3FirstByteReadAttemptNMicroseconds: [100,1000,10000,100000,300000,500000,1000000,2000000,5000000,10000000,15000000,20000000,25000000,30000000,35000000,4294967295] -LatencyEvent_S3FirstByteWriteAttemptNMicroseconds: [100,1000,10000,100000,300000,500000,1000000,2000000,5000000,10000000,15000000,20000000,25000000,30000000,35000000,4294967295] -LatencyEvent_S3ReadConnectMicroseconds: [100,1000,10000,100000,200000,300000,500000,1000000,1500000,4294967295] -LatencyEvent_S3WriteConnectMicroseconds: [100,1000,10000,100000,200000,300000,500000,1000000,1500000,4294967295] -LatencyEvent_DiskS3FirstByteReadAttempt1Microseconds: [100,1000,10000,100000,300000,500000,1000000,2000000,5000000,10000000,15000000,20000000,25000000,30000000,35000000,4294967295] -LatencyEvent_DiskS3FirstByteWriteAttempt1Microseconds: [100,1000,10000,100000,300000,500000,1000000,2000000,5000000,10000000,15000000,20000000,25000000,30000000,35000000,4294967295] -LatencyEvent_DiskS3FirstByteReadAttempt2Microseconds: [100,1000,10000,100000,300000,500000,1000000,2000000,5000000,10000000,15000000,20000000,25000000,30000000,35000000,4294967295] -LatencyEvent_DiskS3FirstByteWriteAttempt2Microseconds: [100,1000,10000,100000,300000,500000,1000000,2000000,5000000,10000000,15000000,20000000,25000000,30000000,35000000,4294967295] -LatencyEvent_DiskS3FirstByteReadAttemptNMicroseconds: [100,1000,10000,100000,300000,500000,1000000,2000000,5000000,10000000,15000000,20000000,25000000,30000000,35000000,4294967295] -LatencyEvent_DiskS3FirstByteWriteAttemptNMicroseconds: [100,1000,10000,100000,300000,500000,1000000,2000000,5000000,10000000,15000000,20000000,25000000,30000000,35000000,4294967295] -LatencyEvent_DiskS3ReadConnectMicroseconds: [100,1000,10000,100000,200000,300000,500000,1000000,1500000,4294967295] -LatencyEvent_DiskS3WriteConnectMicroseconds: [100,1000,10000,100000,200000,300000,500000,1000000,1500000,4294967295] -``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/latency_buckets.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/latency_buckets.md.hash deleted file mode 100644 index ed66b25b0b2..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/latency_buckets.md.hash +++ /dev/null @@ -1 +0,0 @@ -8069e0dcfd1792e6 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/latency_log.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/latency_log.md deleted file mode 100644 index 65d9fa0cd54..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/latency_log.md +++ /dev/null @@ -1,57 +0,0 @@ ---- -'description': '包含所有延迟桶的历史记录,定期刷新到磁盘。' -'slug': '/operations/system-tables/latency_log' -'title': 'system.latency_log' ---- - -import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_system_table_cloud.md'; - - -# latency_log - - - -包含所有延迟桶的历史记录,定期刷新到磁盘。 - -列: -- `hostname` ([LowCardinality(String)](../../sql-reference/data-types/string.md)) — 执行查询的服务器的主机名。 -- `event_date` ([Date](../../sql-reference/data-types/date.md)) — 事件日期。 -- `event_time` ([DateTime](../../sql-reference/data-types/datetime.md)) — 事件时间。 -- `event_time_microseconds` ([DateTime64](../../sql-reference/data-types/datetime64.md)) — 带有微秒分辨率的事件时间。 - -**示例** - -```sql -SELECT * FROM system.latency_log LIMIT 1 FORMAT Vertical; -``` - -```text -Row 1: -────── -hostname: clickhouse.eu-central1.internal -event_date: 2024-09-19 -event_time: 2024-09-19 17:09:17 -event_time_microseconds: 2024-09-19 17:09:17.712477 -LatencyEvent_S3FirstByteReadAttempt1Microseconds: [278,278,278,278,278,278,278,278,278,278,278,278,278,278,278,278] -LatencyEvent_S3FirstByteWriteAttempt1Microseconds: [1774,1776,1776,1776,1776,1776,1776,1776,1776,1776,1776,1776,1776,1776,1776,1776] -LatencyEvent_S3FirstByteReadAttempt2Microseconds: [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] -LatencyEvent_S3FirstByteWriteAttempt2Microseconds: [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] -LatencyEvent_S3FirstByteReadAttemptNMicroseconds: [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] -LatencyEvent_S3FirstByteWriteAttemptNMicroseconds: [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] -LatencyEvent_S3ReadConnectMicroseconds: [1,1,1,1,1,1,1,1,1,1] -LatencyEvent_S3WriteConnectMicroseconds: [329,362,362,363,363,363,363,363,363,363] -LatencyEvent_DiskS3FirstByteReadAttempt1Microseconds: [278,278,278,278,278,278,278,278,278,278,278,278,278,278,278,278] -LatencyEvent_DiskS3FirstByteWriteAttempt1Microseconds: [1774,1776,1776,1776,1776,1776,1776,1776,1776,1776,1776,1776,1776,1776,1776,1776] -LatencyEvent_DiskS3FirstByteReadAttempt2Microseconds: [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] -LatencyEvent_DiskS3FirstByteWriteAttempt2Microseconds: [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] -LatencyEvent_DiskS3FirstByteReadAttemptNMicroseconds: [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] -LatencyEvent_DiskS3FirstByteWriteAttemptNMicroseconds: [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] -LatencyEvent_DiskS3ReadConnectMicroseconds: [1,1,1,1,1,1,1,1,1,1] -LatencyEvent_DiskS3WriteConnectMicroseconds: [329,362,362,363,363,363,363,363,363,363] -``` - -**另请参见** - -- [latency_log_setting](../../operations/server-configuration-parameters/settings.md#latency_log) - 启用和禁用该设置。 -- [latency_buckets](../../operations/system-tables/latency_buckets.md) - 延迟日志桶的边界。 -- [Monitoring](../../operations/monitoring.md) - ClickHouse 监控的基本概念。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/latency_log.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/latency_log.md.hash deleted file mode 100644 index eb07ff01fb5..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/latency_log.md.hash +++ /dev/null @@ -1 +0,0 @@ -2bc3870b15bdd07e diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/licenses.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/licenses.md index 9ceb6abf4d7..94d67385657 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/licenses.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/licenses.md @@ -1,10 +1,11 @@ --- -'description': '系统表包含位于 ClickHouse 源代码的 contrib 目录中的第三方库的许可证。' +'description': '系统表包含位于 ClickHouse 源代码 contrib 目录中的第三方库的许可证。' 'keywords': - 'system table' - 'licenses' 'slug': '/operations/system-tables/licenses' 'title': 'system.licenses' +'doc_type': 'reference' --- @@ -12,11 +13,11 @@ 包含位于 ClickHouse 源代码的 [contrib](https://github.com/ClickHouse/ClickHouse/tree/master/contrib) 目录中的第三方库的许可证。 -列: +列: -- `library_name` ([String](../../sql-reference/data-types/string.md)) — 与许可证相关的库的名称。 -- `license_type` ([String](../../sql-reference/data-types/string.md)) — 许可证类型 — 例如 Apache、MIT。 -- `license_path` ([String](../../sql-reference/data-types/string.md)) — 指向包含许可证文本的文件的路径。 +- `library_name` ([String](../../sql-reference/data-types/string.md)) — 许可证所关联的库的名称。 +- `license_type` ([String](../../sql-reference/data-types/string.md)) — 许可证类型,例如 Apache,MIT。 +- `license_path` ([String](../../sql-reference/data-types/string.md)) — 包含许可证文本的文件路径。 - `license_text` ([String](../../sql-reference/data-types/string.md)) — 许可证文本。 **示例** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/licenses.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/licenses.md.hash index 5f168ab51a2..8245ba212a0 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/licenses.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/licenses.md.hash @@ -1 +1 @@ -bfbc663af22b480e +577d8566ed9ef0bf diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/merge_tree_settings.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/merge_tree_settings.md index c7dd2061d8b..ba11c33f24e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/merge_tree_settings.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/merge_tree_settings.md @@ -5,42 +5,43 @@ - 'merge_tree_settings' 'slug': '/operations/system-tables/merge_tree_settings' 'title': 'system.merge_tree_settings' +'doc_type': 'reference' --- # system.merge_tree_settings -包含有关 `MergeTree` 表设置的信息。 +包含有关`MergeTree`表设置的信息。 列: -- `name` ([字符串](../../sql-reference/data-types/string.md)) — 设置名称。 -- `value` ([字符串](../../sql-reference/data-types/string.md)) — 设置值。 -- `default` ([字符串](../../sql-reference/data-types/string.md)) — 设置默认值。 -- `changed` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) — 设置是否在配置中明确指定或明确更改。 -- `description` ([字符串](../../sql-reference/data-types/string.md)) — 设置描述。 -- `min` ([Nullable](../../sql-reference/data-types/nullable.md)([字符串](../../sql-reference/data-types/string.md))) — 设置的最小值,如果通过 [constraints](/operations/settings/constraints-on-settings) 设置了值。如果设置没有最小值,则包含 [NULL](/operations/settings/formats#input_format_null_as_default)。 -- `max` ([Nullable](../../sql-reference/data-types/nullable.md)([字符串](../../sql-reference/data-types/string.md))) — 设置的最大值,如果通过 [constraints](/operations/settings/constraints-on-settings) 设置了值。如果设置没有最大值,则包含 [NULL](/operations/settings/formats#input_format_null_as_default)。 -- `readonly` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) — 显示当前用户是否可以更改该设置: - - `0` — 当前用户可以更改该设置。 - - `1` — 当前用户无法更改该设置。 -- `type` ([字符串](../../sql-reference/data-types/string.md)) — 设置类型(实现特定的字符串值)。 -- `is_obsolete` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) - 显示设置是否已过时。 -- `tier` ([Enum8](../../sql-reference/data-types/enum.md)) — 该功能的支持级别。ClickHouse 的功能按层级组织,具体取决于其开发的当前状态和使用时的期望。值: - - `'Production'` — 该功能稳定、安全可用,并且与其他 **生产** 特性之间没有问题。 - - `'Beta'` — 该功能稳定且安全。与其他特性一起使用的结果未知,且正确性不能保证。欢迎进行测试和报告。 - - `'Experimental'` — 该功能正在开发中。仅适用于开发者和 ClickHouse 爱好者。该功能可能有效也可能无效,并且可能随时被移除。 - - `'Obsolete'` — 不再支持。要么已被移除,要么将在未来版本中被移除。 +- `name` ([String](../../sql-reference/data-types/string.md)) — 设置名称。 +- `value` ([String](../../sql-reference/data-types/string.md)) — 设置值。 +- `default` ([String](../../sql-reference/data-types/string.md)) — 设置默认值。 +- `changed` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) — 设置是否在配置中显式定义或显式更改。 +- `description` ([String](../../sql-reference/data-types/string.md)) — 设置描述。 +- `min` ([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md))) — 设置的最小值(如果通过[constraints](/operations/settings/constraints-on-settings)设置)。如果设置没有最小值,则包含[NULL](/operations/settings/formats#input_format_null_as_default)。 +- `max` ([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md))) — 设置的最大值(如果通过[constraints](/operations/settings/constraints-on-settings)设置)。如果设置没有最大值,则包含[NULL](/operations/settings/formats#input_format_null_as_default)。 +- `readonly` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) — 显示当前用户是否可以更改设置: + - `0` — 当前用户可以更改设置。 + - `1` — 当前用户无法更改设置。 +- `type` ([String](../../sql-reference/data-types/string.md)) — 设置类型(具体实现的字符串值)。 +- `is_obsolete` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) - 显示设置是否过时。 +- `tier` ([Enum8](../../sql-reference/data-types/enum.md)) — 此功能的支持级别。 ClickHouse特性按级别组织,具体取决于其开发的当前状态,以及当使用它们时可能有的期望。值: + - `'Production'` — 此功能稳定、安全使用,并且与其他**生产**功能的交互没有问题。 + - `'Beta'` — 此功能稳定且安全。与其他功能一起使用的结果不确定,正确性不能保证。欢迎测试和反馈。 + - `'Experimental'` — 此功能处于开发中。只供开发者和ClickHouse爱好者使用。此功能可能有效,也可能无效,且可能随时被移除。 + - `'Obsolete'` — 不再支持。它要么已经被移除,要么将在未来版本中被移除。 **示例** ```sql -SELECT * FROM system.merge_tree_settings LIMIT 4 FORMAT Vertical; +SELECT * FROM system.merge_tree_settings LIMIT 3 FORMAT Vertical; ``` ```response SELECT * FROM system.merge_tree_settings -LIMIT 4 +LIMIT 3 FORMAT Vertical Query id: 2580779c-776e-465f-a90c-4b7630d0bb70 @@ -87,19 +88,5 @@ type: UInt64 is_obsolete: 0 tier: Production -Row 4: -────── -name: max_digestion_size_per_segment -value: 268435456 -default: 268435456 -changed: 0 -description: Max number of bytes to digest per segment to build GIN index. -min: ᴺᵁᴸᴸ -max: ᴺᵁᴸᴸ -readonly: 0 -type: UInt64 -is_obsolete: 0 -tier: Production - -4 rows in set. Elapsed: 0.001 sec. +3 rows in set. Elapsed: 0.001 sec. ``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/merge_tree_settings.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/merge_tree_settings.md.hash index bd92653bd22..f5d43cffc4f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/merge_tree_settings.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/merge_tree_settings.md.hash @@ -1 +1 @@ -2f57605d12082b1a +3074526d61c81ea3 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/merges.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/merges.md index 1f23bbb7a83..c3b6396c5f2 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/merges.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/merges.md @@ -1,10 +1,11 @@ --- -'description': '系统表包含关于当前在MergeTree系列表中进行的合并和分区片段变更的信息。' +'description': '系统表包含关于当前在MergeTree家族中进行的合并和分区片段变更的信息。' 'keywords': - 'system table' - 'merges' 'slug': '/operations/system-tables/merges' 'title': 'system.merges' +'doc_type': 'reference' --- import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_system_table_cloud.md'; @@ -14,24 +15,24 @@ import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/curre -此表包含有关当前正在处理的合并和部件变更的信息,适用于MergeTree族表。 +包含有关当前在 MergeTree 系列表中进行的合并和部分变更的信息。 -列: +列: - `database` (String) — 表所在的数据库名称。 -- `table` (String) — 表名称。 +- `table` (String) — 表名。 - `elapsed` (Float64) — 自合并开始以来经过的时间(以秒为单位)。 -- `progress` (Float64) — 完成工作百分比,从0到1。 -- `num_parts` (UInt64) — 要合并的片段数量。 +- `progress` (Float64) — 已完成工作的百分比,从 0 到 1。 +- `num_parts` (UInt64) — 要合并的部分数量。 - `result_part_name` (String) — 合并后形成的部分名称。 -- `is_mutation` (UInt8) — 如果该过程是部件变更,则为1。 -- `total_size_bytes_compressed` (UInt64) — 合并片段中压缩数据的总大小。 +- `is_mutation` (UInt8) — 如果此过程是部分变更则为 1。 +- `total_size_bytes_compressed` (UInt64) — 合并块中压缩数据的总大小。 - `total_size_marks` (UInt64) — 合并部分中的标记总数。 - `bytes_read_uncompressed` (UInt64) — 读取的字节数,未压缩。 - `rows_read` (UInt64) — 读取的行数。 - `bytes_written_uncompressed` (UInt64) — 写入的字节数,未压缩。 - `rows_written` (UInt64) — 写入的行数。 - `memory_usage` (UInt64) — 合并过程的内存消耗。 -- `thread_id` (UInt64) — 合并过程的线程ID。 -- `merge_type` — 当前合并的类型。如果是变更,则为空。 -- `merge_algorithm` — 当前合并中使用的算法。如果是变更,则为空。 +- `thread_id` (UInt64) — 合并过程的线程 ID。 +- `merge_type` — 当前合并的类型。如果是变更则为空。 +- `merge_algorithm` — 当前合并中使用的算法。如果是变更则为空。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/merges.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/merges.md.hash index 7fed37a6d5a..10c89a5d772 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/merges.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/merges.md.hash @@ -1 +1 @@ -0c199f87fe4d08ab +d532d3dfbc27bc8c diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/metric_log.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/metric_log.md index bd74a6ff9cc..2a83aa4761e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/metric_log.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/metric_log.md @@ -5,6 +5,7 @@ - 'metric_log' 'slug': '/operations/system-tables/metric_log' 'title': 'system.metric_log' +'doc_type': 'reference' --- import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_system_table_cloud.md'; @@ -14,10 +15,10 @@ import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/curre -包含来自 `system.metrics` 和 `system.events` 表的指标值历史,定期刷新到磁盘上。 +包含来自 `system.metrics` 和 `system.events` 表的指标值历史,定期刷新到磁盘。 列: -- `hostname` ([LowCardinality(String)](../../sql-reference/data-types/string.md)) — 执行查询的服务器的主机名。 +- `hostname` ([LowCardinality(String)](../../sql-reference/data-types/string.md)) — 执行查询的服务器主机名。 - `event_date` ([Date](../../sql-reference/data-types/date.md)) — 事件日期。 - `event_time` ([DateTime](../../sql-reference/data-types/datetime.md)) — 事件时间。 - `event_time_microseconds` ([DateTime64](../../sql-reference/data-types/datetime64.md)) — 带有微秒分辨率的事件时间。 @@ -56,17 +57,17 @@ CurrentMetric_LocalThreadActive: 0 CurrentMetric_DistributedFilesToInsert: 0 ``` -**架构** -此表可以使用 XML 标签 `` 配置为不同的架构类型。默认架构类型为 `wide`,每个指标或配置事件作为单独的列存储。该架构在单列读取时具有最高的性能和效率。 +**模式** +该表可以使用 XML 标签 `` 配置为不同的模式类型。默认模式类型为 `wide`,其中每个指标或配置事件作为单独的列存储。该模式对于单列读取是最优和高效的。 -`transposed` 架构以类似 `system.asynchronous_metric_log` 的格式存储数据,其中指标和事件作为行存储。该架构在资源低的设置中非常有用,因为它在合并期间减少了资源消耗。 +`transposed` 模式以类似于 `system.asynchronous_metric_log` 的格式存储数据,其中指标和事件作为行存储。由于减少了合并期间的资源消耗,该模式对于低资源设置非常有用。 -还有一个兼容架构 `transposed_with_wide_view`,它在具有转置架构的表中存储实际数据(`system.transposed_metric_log`),并在其上使用宽架构创建一个视图。该视图查询转置表,使其在从 `wide` 架构迁移到 `transposed` 架构时非常有用。 +还存在兼容性模式 `transposed_with_wide_view`,它在具有转置模式的表(`system.transposed_metric_log`)中存储实际数据,并在其上使用宽模式创建视图。该视图查询转置表,使其在从 `wide` 模式迁移到 `transposed` 模式时非常有用。 **另见** - [metric_log 设置](../../operations/server-configuration-parameters/settings.md#metric_log) — 启用和禁用设置。 - [system.asynchronous_metrics](../../operations/system-tables/asynchronous_metrics.md) — 包含定期计算的指标。 -- [system.events](/operations/system-tables/events) — 包含发生的一系列事件。 +- [system.events](/operations/system-tables/events) — 包含发生的多个事件。 - [system.metrics](../../operations/system-tables/metrics.md) — 包含即时计算的指标。 - [监控](../../operations/monitoring.md) — ClickHouse 监控的基本概念。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/metric_log.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/metric_log.md.hash index d2171544b4f..153a4bf51aa 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/metric_log.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/metric_log.md.hash @@ -1 +1 @@ -2d761a30a02dc722 +a47df1ddfd636ff5 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/metrics.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/metrics.md index 9941e8764ff..82c5d250ffa 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/metrics.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/metrics.md @@ -1,10 +1,11 @@ --- -'description': '系统表包含可以立即计算的指标,或具有当前值的指标。' +'description': '系统表包含可以即时计算的指标或当前值。' 'keywords': - 'system table' - 'metrics' 'slug': '/operations/system-tables/metrics' 'title': 'system.metrics' +'doc_type': 'reference' --- import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_system_table_cloud.md'; @@ -14,9 +15,9 @@ import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/curre -包含可以即时计算的指标,或具有当前值的指标。例如,同时处理的查询数量或当前副本延迟。此表始终是最新的。 +包含可以立即计算的指标或具有当前值的指标。例如,同时处理的查询数量或当前副本延迟。该表始终是最新的。 -列: +列: - `metric` ([String](../../sql-reference/data-types/string.md)) — 指标名称。 - `value` ([Int64](../../sql-reference/data-types/int-uint.md)) — 指标值。 @@ -50,11 +51,11 @@ SELECT * FROM system.metrics LIMIT 10 ### AggregatorThreads {#aggregatorthreads} -聚合器线程池中的线程数量。 +Aggregator线程池中的线程数量。 ### AggregatorThreadsActive {#aggregatorthreadsactive} -聚合器线程池中正在运行任务的线程数量。 +在Aggregator线程池中运行任务的线程数量。 ### TablesLoaderForegroundThreads {#tablesloaderforegroundthreads} @@ -62,7 +63,7 @@ SELECT * FROM system.metrics LIMIT 10 ### TablesLoaderForegroundThreadsActive {#tablesloaderforegroundthreadsactive} -异步加载器前台线程池中正在运行任务的线程数量。 +在异步加载器前台线程池中运行任务的线程数量。 ### TablesLoaderBackgroundThreads {#tablesloaderbackgroundthreads} @@ -70,19 +71,19 @@ SELECT * FROM system.metrics LIMIT 10 ### TablesLoaderBackgroundThreadsActive {#tablesloaderbackgroundthreadsactive} -异步加载器后台线程池中正在运行任务的线程数量。 +在异步加载器后台线程池中运行任务的线程数量。 ### AsyncInsertCacheSize {#asyncinsertcachesize} -缓存中异步插入的哈希 ID 数量 +缓存中异步插入哈希id的数量。 ### AsynchronousInsertThreads {#asynchronousinsertthreads} -异步插入线程池中的线程数量。 +AsynchronousInsert线程池中的线程数量。 ### AsynchronousInsertThreadsActive {#asynchronousinsertthreadsactive} -异步插入线程池中正在运行任务的线程数量。 +在AsynchronousInsert线程池中运行任务的线程数量。 ### AsynchronousReadWait {#asynchronousreadwait} @@ -90,143 +91,143 @@ SELECT * FROM system.metrics LIMIT 10 ### BackgroundBufferFlushSchedulePoolSize {#backgroundbufferflushschedulepoolsize} -后台缓冲区刷新调度池中任务的数量限制 +后台缓冲区刷新调度池中任务数量的限制。 ### BackgroundBufferFlushSchedulePoolTask {#backgroundbufferflushschedulepooltask} -后台缓冲区刷新调度池中活动任务的数量。此池用于定期刷新缓冲区。 +后台缓冲区刷新调度池中活动任务的数量。该池用于定期缓冲区刷新。 ### BackgroundCommonPoolSize {#backgroundcommonpoolsize} -相关背景池中任务的数量限制 +关联后台池中的任务数量限制。 ### BackgroundCommonPoolTask {#backgroundcommonpooltask} -相关背景池中活动任务的数量 +关联后台池中活动任务的数量。 ### BackgroundDistributedSchedulePoolSize {#backgrounddistributedschedulepoolsize} -后台分布式调度池中任务的数量限制 +后台分布式调度池中任务数量的限制。 ### BackgroundDistributedSchedulePoolTask {#backgrounddistributedschedulepooltask} -后台分布式调度池中活动任务的数量。此池用于在后台进行的分布式发送。 +后台分布式调度池中活动任务的数量。该池用于在后台进行的分布式发送。 ### BackgroundFetchesPoolSize {#backgroundfetchespoolsize} -相关背景池中同时提取的限制 +关联后台池中同时提取的数量限制。 ### BackgroundFetchesPoolTask {#backgroundfetchespooltask} -相关背景池中活动提取的数量 +关联后台池中活动提取的数量。 ### BackgroundMergesAndMutationsPoolSize {#backgroundmergesandmutationspoolsize} -相关背景池中活动合并和变更的限制 +关联后台池中活动合并和变更的数量限制。 ### BackgroundMergesAndMutationsPoolTask {#backgroundmergesandmutationspooltask} -相关背景池中活动合并和变更的数量 +关联后台池中活动合并和变更的数量。 ### BackgroundMessageBrokerSchedulePoolSize {#backgroundmessagebrokerschedulepoolsize} -后台处理池中消息流的任务数量限制 +用于消息流处理的BackgroundProcessingPool中的任务数量限制。 ### BackgroundMessageBrokerSchedulePoolTask {#backgroundmessagebrokerschedulepooltask} -后台处理池中消息流的活动任务数量 +用于消息流处理的BackgroundProcessingPool中活动任务的数量。 ### BackgroundMovePoolSize {#backgroundmovepoolsize} -后台处理池中移动的任务数量限制 +用于移动的BackgroundProcessingPool中的任务数量限制。 ### BackgroundMovePoolTask {#backgroundmovepooltask} -后台处理池中活动移动任务的数量 +用于移动的BackgroundProcessingPool中的活动任务数量。 ### BackgroundSchedulePoolSize {#backgroundschedulepoolsize} -后台调度池中任务的数量限制。此池用于定期的 ReplicatedMergeTree 任务,如清理旧的数据部分、修改数据部分、复制副本重新初始化等。 +BackgroundSchedulePool中的任务数量限制。该池用于定期ReplicatedMergeTree任务,例如清理旧数据部分, 修改数据部分, 副本重新初始化等。 ### BackgroundSchedulePoolTask {#backgroundschedulepooltask} -后台调度池中活动任务的数量。此池用于定期的 ReplicatedMergeTree 任务,如清理旧的数据部分、修改数据部分、复制副本重新初始化等。 +BackgroundSchedulePool中的活动任务数量。该池用于定期ReplicatedMergeTree任务,例如清理旧数据部分, 修改数据部分, 副本重新初始化等。 ### BackupsIOThreads {#backupsiothreads} -备份 I/O 线程池中的线程数量。 +BackupsIO线程池中的线程数量。 ### BackupsIOThreadsActive {#backupsiothreadsactive} -备份 I/O 线程池中正在运行任务的线程数量。 +在BackupsIO线程池中运行任务的线程数量。 ### BackupsThreads {#backupsthreads} -备份线程的线程池中线程数量。 +用于备份的线程池中的线程数量。 ### BackupsThreadsActive {#backupsthreadsactive} -备份线程池中正在运行任务的线程数量。 +在备份线程池中运行任务的线程数量。 ### BrokenDistributedFilesToInsert {#brokendistributedfilestoinsert} -已标记为损坏的、用于异步插入到分布式表中的文件数量。此指标将从启动时的 0 开始。每个分片的文件数量被汇总。 +标记为损坏的待插入到分布式表中的文件数量。此指标将在启动时从0开始。每个分片的文件数量相加。 ### CacheDetachedFileSegments {#cachedetachedfilesegments} -存在的分离缓存文件段的数量 +现有的分离缓存文件片段的数量。 ### CacheDictionaryThreads {#cachedictionarythreads} -CacheDictionary 线程池中的线程数量。 +CacheDictionary线程池中的线程数量。 ### CacheDictionaryThreadsActive {#cachedictionarythreadsactive} -CacheDictionary 线程池中正在运行任务的线程数量。 +在CacheDictionary线程池中运行任务的线程数量。 ### CacheDictionaryUpdateQueueBatches {#cachedictionaryupdatequeuebatches} -CacheDictionaries 中更新队列中的“批次”(一组键)数量。 +CacheDictionaries中更新队列中的“批次”(一组键)数量。 ### CacheDictionaryUpdateQueueKeys {#cachedictionaryupdatequeuekeys} -CacheDictionaries 中更新队列中的键的确切数量。 +CacheDictionaries中更新队列中的键的确切数量。 ### CacheFileSegments {#cachefilesegments} -存在的缓存文件段的数量 +现有缓存文件片段的数量。 ### ContextLockWait {#contextlockwait} -等待在上下文中锁定的线程数量。这是全局锁定。 +在上下文中等待锁的线程数量。 这是全局锁。 ### DDLWorkerThreads {#ddlworkerthreads} -DDLWorker 线程池中用于 ON CLUSTER 查询的线程数量。 +用于ON CLUSTER查询的DDLWorker线程池中的线程数量。 ### DDLWorkerThreadsActive {#ddlworkerthreadsactive} -DDLWorker 线程池中正在运行任务的线程数量。 +在DDLWorker线程池中运行任务的线程数量,用于ON CLUSTER查询。 ### DatabaseCatalogThreads {#databasecatalogthreads} -DatabaseCatalog 线程池中的线程数量。 +DatabaseCatalog线程池中的线程数量。 ### DatabaseCatalogThreadsActive {#databasecatalogthreadsactive} -DatabaseCatalog 线程池中正在运行任务的线程数量。 +在DatabaseCatalog线程池中运行任务的线程数量。 ### DatabaseOnDiskThreads {#databaseondiskthreads} -DatabaseOnDisk 线程池中的线程数量。 +DatabaseOnDisk线程池中的线程数量。 ### DatabaseOnDiskThreadsActive {#databaseondiskthreadsactive} -DatabaseOnDisk 线程池中正在运行任务的线程数量。 +在DatabaseOnDisk线程池中运行任务的线程数量。 ### DelayedInserts {#delayedinserts} -由于 MergeTree 表中分区的活跃数据部分数量过多而被限制的 INSERT 查询数量。 +由于MergeTree表分区中活跃数据部分数量过多而被限制的INSERT查询数量。 ### DestroyAggregatesThreads {#destroyaggregatesthreads} @@ -234,47 +235,81 @@ DatabaseOnDisk 线程池中正在运行任务的线程数量。 ### DestroyAggregatesThreadsActive {#destroyaggregatesthreadsactive} -用于销毁聚合状态的线程池中正在运行任务的线程数量。 +在用于销毁聚合状态的线程池中运行任务的线程数量。 ### DictCacheRequests {#dictcacherequests} -飞行中到字典的数据源的请求数量。 +当前正在飞往缓存类型字典数据源的请求数量。 ### DiskObjectStorageAsyncThreads {#diskobjectstorageasyncthreads} -用于 DiskObjectStorage 的异步线程池中的线程数量。 +用于DiskObjectStorage的异步线程池中的线程数量。 ### DiskObjectStorageAsyncThreadsActive {#diskobjectstorageasyncthreadsactive} -用于 DiskObjectStorage 的异步线程池中正在运行任务的线程数量。 +在DiskObjectStorage的异步线程池中运行任务的线程数量。 ### DiskSpaceReservedForMerge {#diskspacereservedformerge} -当前正在进行的后台合并预留的磁盘空间。它略高于当前正在合并部分的总大小。 +当前正在运行的后台合并中保留的磁盘空间。它略高于当前正在合并部分的总大小。 ### DistributedFilesToInsert {#distributedfilestoinsert} -待处理的文件数量,用于异步插入到分布式表中。每个分片的文件数量被汇总。 +待处理的文件数量,以进行异步插入到分布式表中。每个分片的文件数量相加。 ### DistributedSend {#distributedsend} -连接到远程服务器的数量,这些服务器正在发送插入到分布式表中的数据。包括同步和异步模式。 +发送插入到分布式表中的数据的远程服务器连接数量。包括同步和异步模式。 ### EphemeralNode {#ephemeralnode} -ZooKeeper 中持有的临时节点数量。 +在ZooKeeper中持有的短暂节点数量。 ### FilesystemCacheElements {#filesystemcacheelements} -文件系统缓存元素(文件段) +文件系统缓存元素(文件片段) ### FilesystemCacheReadBuffers {#filesystemcachereadbuffers} -活动缓存缓冲区的数量 +活动缓存缓冲区的数量。 ### FilesystemCacheSize {#filesystemcachesize} -文件系统缓存的字节大小 +文件系统缓存的字节大小。 + +### QueryCacheBytes {#querycachebytes} + +查询缓存的总大小(以字节为单位)。 + +### QueryCacheEntries {#querycacheentries} + +查询缓存中的条目总数。 + +### UncompressedCacheBytes {#uncompressedcachebytes} + +未压缩缓存的总大小(以字节为单位)。未压缩缓存通常不会提高性能,并且应尽量避免。 + +### UncompressedCacheCells {#uncompressedcachecells} + +### CompiledExpressionCacheBytes {#compiledexpressioncachebytes} + +JIT编译代码的缓存使用的总字节数。 + +### CompiledExpressionCacheCount {#compiledexpressioncachecount} + +JIT编译代码缓存中的总条目数。 + +### MMapCacheCells {#mmapcachecells} + +使用`mmap`打开的文件数量(映射在内存中)。这对于使用设置`local_filesystem_read_method`设置为`mmap`的查询非常有用。使用`mmap`打开的文件保留在缓存中,以避免昂贵的TLB刷新。 + +### MarkCacheBytes {#markcachebytes} + +标记缓存的总大小(以字节为单位)。 + +### MarkCacheFiles {#markcachefiles} + +标记缓存中缓存的标记文件的总数。 ### GlobalThread {#globalthread} @@ -282,119 +317,119 @@ ZooKeeper 中持有的临时节点数量。 ### GlobalThreadActive {#globalthreadactive} -全局线程池中正在运行任务的线程数量。 +在全局线程池中运行任务的线程数量。 ### HTTPConnection {#httpconnection} -与 HTTP 服务器的连接数量 +与HTTP服务器的连接数量。 ### HashedDictionaryThreads {#hasheddictionarythreads} -HashedDictionary 线程池中的线程数量。 +HashedDictionary线程池中的线程数量。 ### HashedDictionaryThreadsActive {#hasheddictionarythreadsactive} -HashedDictionary 线程池中正在运行任务的线程数量。 +在HashedDictionary线程池中运行任务的线程数量。 ### IOPrefetchThreads {#ioprefetchthreads} -I/O 预取线程池中的线程数量。 +IO预取线程池中的线程数量。 ### IOPrefetchThreadsActive {#ioprefetchthreadsactive} -I/O 预取线程池中正在运行任务的线程数量。 +在IO预取线程池中运行任务的线程数量。 ### IOThreads {#iothreads} -I/O 线程池中的线程数量。 +IO线程池中的线程数量。 ### IOThreadsActive {#iothreadsactive} -I/O 线程池中正在运行任务的线程数量。 +在IO线程池中运行任务的线程数量。 ### IOUringInFlightEvents {#iouringinflightevents} -在飞行中的 io_uring SQE 的数量 +正在处理的io_uring SQE数量。 ### IOUringPendingEvents {#iouringpendingevents} -等待提交的 io_uring SQE 的数量 +等待提交的io_uring SQE数量。 ### IOWriterThreads {#iowriterthreads} -I/O 写入线程池中的线程数量。 +IO写入线程池中的线程数量。 ### IOWriterThreadsActive {#iowriterthreadsactive} -I/O 写入线程池中正在运行任务的线程数量。 +在IO写入线程池中运行任务的线程数量。 ### InterserverConnection {#interserverconnection} -从其他副本获取部分的连接数量。 +来自其他副本获取部分的连接数量。 ### KafkaAssignedPartitions {#kafkaassignedpartitions} -Kafka 表当前分配的分区数量 +Kafka表当前分配的分区数量。 ### KafkaBackgroundReads {#kafkabackgroundreads} -当前工作的后台读取数量(从 Kafka 填充物化视图) +当前正在进行的后台读取数量(从Kafka填充物化视图)。 ### KafkaConsumers {#kafkaconsumers} -活动的 Kafka 消费者数量 +活动Kafka消费者的数量。 ### KafkaConsumersInUse {#kafkaconsumersinuse} -当前由直接或后台读取使用的消费者数量 +当前直接或后台读取使用的消费者数量。 ### KafkaConsumersWithAssignment {#kafkaconsumerswithassignment} -具有某些分区分配的活跃 Kafka 消费者数量。 +当前有部分分配的活动Kafka消费者数量。 ### KafkaLibrdkafkaThreads {#kafkalibrdkafkathreads} -活动的 librdkafka 线程数量 +活动librdkafka线程数量。 ### KafkaProducers {#kafkaproducers} -创建的活动 Kafka 生产者数量 +创建的活动Kafka生产者数量。 ### KafkaWrites {#kafkawrites} -当前向 Kafka 进行的插入数量 +当前正在进行的Kafka插入数量。 ### KeeperAliveConnections {#keeperaliveconnections} -活动连接的数量 +存活连接的数量。 ### KeeperOutstandingRequests {#keeperoutstandingrequests} -待处理请求的数量 +未完成请求的数量。 ### LocalThread {#localthread} -本地线程池中的线程数量。本地线程池中的线程是从全局线程池中提取的。 +本地线程池中的线程数量。 本地线程池中的线程来自全局线程池。 ### LocalThreadActive {#localthreadactive} -本地线程池中正在运行任务的线程数量。 +在本地线程池中运行任务的线程数量。 ### MMappedAllocBytes {#mmappedallocbytes} -内存映射分配的总字节数 +mmapped分配的总字节数。 ### MMappedAllocs {#mmappedallocs} -内存映射分配的总数量 +mmapped分配的总数量。 ### MMappedFileBytes {#mmappedfilebytes} -内存映射文件区域的总大小。 +mmapped文件区域的总大小。 ### MMappedFiles {#mmappedfiles} -内存映射文件的总数量。 +mmapped文件的总数量。 ### MarksLoaderThreads {#marksloaderthreads} @@ -402,115 +437,107 @@ Kafka 表当前分配的分区数量 ### MarksLoaderThreadsActive {#marksloaderthreadsactive} -用于加载标记的线程池中正在运行任务的线程数量。 +在加载标记的线程池中运行任务的线程数量。 ### MaxDDLEntryID {#maxddlentryid} -DDLWorker 的最大处理 DDL 条目。 +DDLWorker处理的最大DDL条目。 ### MaxPushedDDLEntryID {#maxpushedddlentryid} -推送到 ZooKeeper 的最大 DDL 条目。 +推送到ZooKeeper的DDLWorker的最大DDL条目。 ### MemoryTracking {#memorytracking} -服务器分配的总内存量(字节)。 +服务器分配的总内存(以字节为单位)。 ### Merge {#merge} -正在执行的后台合并数量 +正在执行的后台合并数量。 ### MergeTreeAllRangesAnnouncementsSent {#mergetreeallrangesannouncementssent} -从远程服务器到发起服务器正在飞行的公告数量,关于数据部分集合(针对 MergeTree 表)。在远程服务器端测量。 +从远程服务器到发起服务器发送的数据部分集合的当前公告数量(适用于MergeTree表)。在远程服务器端测量。 ### MergeTreeBackgroundExecutorThreads {#mergetreebackgroundexecutorthreads} -MergeTreeBackgroundExecutor 线程池中的线程数量。 +MergeTreeBackgroundExecutor线程池中的线程数量。 ### MergeTreeBackgroundExecutorThreadsActive {#mergetreebackgroundexecutorthreadsactive} -MergeTreeBackgroundExecutor 线程池中正在运行任务的线程数量。 +在MergeTreeBackgroundExecutor线程池中运行任务的线程数量。 ### MergeTreeDataSelectExecutorThreads {#mergetreedataselectexecutorthreads} -MergeTreeDataSelectExecutor 线程池中的线程数量。 +MergeTreeDataSelectExecutor线程池中的线程数量。 ### MergeTreeDataSelectExecutorThreadsActive {#mergetreedataselectexecutorthreadsactive} -MergeTreeDataSelectExecutor 线程池中正在运行任务的线程数量。 +在MergeTreeDataSelectExecutor线程池中运行任务的线程数量。 ### MergeTreePartsCleanerThreads {#mergetreepartscleanerthreads} -MergeTree 部分清理线程池中的线程数量。 +MergeTree部分清理线程池中的线程数量。 ### MergeTreePartsCleanerThreadsActive {#mergetreepartscleanerthreadsactive} -MergeTree 部分清理线程池中正在运行任务的线程数量。 +在MergeTree部分清理线程池中运行任务的线程数量。 ### MergeTreePartsLoaderThreads {#mergetreepartsloaderthreads} -MergeTree 部分加载器线程池中的线程数量。 +MergeTree部分加载器线程池中的线程数量。 ### MergeTreePartsLoaderThreadsActive {#mergetreepartsloaderthreadsactive} -MergeTree 部分加载器线程池中正在运行任务的线程数量。 +在MergeTree部分加载器线程池中运行任务的线程数量。 ### MergeTreeReadTaskRequestsSent {#mergetreereadtaskrequestssent} -正在飞行的回调请求的当前数量,从远程服务器返回到发起服务器以选择读取任务(针对 MergeTree 表)。在远程服务器端测量。 +从远程服务器返回到发起服务器的回调请求的当前数量,以选择读取任务(适用于MergeTree表)。在远程服务器端测量。 ### Move {#move} -当前执行的移动数量 +当前执行的移动数量。 ### MySQLConnection {#mysqlconnection} -使用 MySQL 协议的客户端连接数量 +使用MySQL协议的客户端连接数量。 ### NetworkReceive {#networkreceive} -接收网络数据的线程数量。仅包括与 ClickHouse 相关的网络交互,不包括第三方库。 +从网络接收数据的线程数量。仅包括与ClickHouse相关的网络交互,不包括第三方库。 ### NetworkSend {#networksend} -发送数据到网络的线程数量。仅包括与 ClickHouse 相关的网络交互,不包括第三方库。 +向网络发送数据的线程数量。仅包括与ClickHouse相关的网络交互,不包括第三方库。 ### OpenFileForRead {#openfileforread} -打开以供读取的文件数量 +打开进行读取的文件数量。 ### OpenFileForWrite {#openfileforwrite} -打开以供写入的文件数量 +打开进行写入的文件数量。 ### ParallelFormattingOutputFormatThreads {#parallelformattingoutputformatthreads} -ParallelFormattingOutputFormatThreads 线程池中的线程数量。 +ParallelFormattingOutputFormatThreads线程池中的线程数量。 ### ParallelFormattingOutputFormatThreadsActive {#parallelformattingoutputformatthreadsactive} -ParallelFormattingOutputFormatThreads 线程池中正在运行任务的线程数量。 - -### ParallelParsingInputFormatThreads {#parallelparsinginputformatthreads} - -ParallelParsingInputFormat 线程池中的线程数量。 - -### ParallelParsingInputFormatThreadsActive {#parallelparsinginputformatthreadsactive} - -ParallelParsingInputFormat 线程池中正在运行任务的线程数量。 +在ParallelFormattingOutputFormatThreads线程池中运行任务的线程数量。 ### PartMutation {#partmutation} -变更数量(ALTER DELETE/UPDATE) +变更的数量(ALTER DELETE/UPDATE)。 ### PartsActive {#partsactive} -活跃数据部分,当前和即将进行的 SELECTs 使用。 +当前和即将到来的SELECT使用的活动数据部分。 ### PartsCommitted {#partscommitted} -已弃用。请参见 PartsActive。 +已弃用。请参见PartsActive。 ### PartsCompact {#partscompact} @@ -518,27 +545,27 @@ ParallelParsingInputFormat 线程池中正在运行任务的线程数量。 ### PartsDeleteOnDestroy {#partsdeleteondestroy} -部分已移至另一个磁盘,并应在其析构函数中删除。 +部分已移动到另一磁盘,应在自身析构函数中删除。 ### PartsDeleting {#partsdeleting} -非活动数据部分,带有身份引用计数,当前正在被清理器删除。 +不活动的数据部分,具有身份引用计数,正在被清理器删除。 ### PartsOutdated {#partsoutdated} -非活动数据部分,但仅可用于当前 SELECTs,SELECT 完成后可删除。 +不活动的数据部分,但只能由当前SELECT使用,选择完成后可以删除。 ### PartsPreActive {#partspreactive} -部分在 data_parts 中,但未用于 SELECTs。 +该部分在data_parts中,但未用于SELECT。 ### PartsPreCommitted {#partsprecommitted} -已弃用。请参见 PartsPreActive。 +已弃用。请参见PartsPreActive。 ### PartsTemporary {#partstemporary} -部分现在正在生成,未在 data_parts 列表中。 +该部分现在正在生成,不在data_parts列表中。 ### PartsWide {#partswide} @@ -546,219 +573,219 @@ ParallelParsingInputFormat 线程池中正在运行任务的线程数量。 ### PendingAsyncInsert {#pendingasyncinsert} -等待刷新状态的异步插入数量。 +等待刷新的异步插入数量。 ### PostgreSQLConnection {#postgresqlconnection} -使用 PostgreSQL 协议的客户端连接数量 +使用PostgreSQL协议的客户端连接数量。 ### Query {#query} -正在执行的查询数量 +正在执行的查询数量。 ### QueryPreempted {#querypreempted} -因“优先级”设置而停止和等待的查询数量。 +由于“优先级”设置而停止和等待的查询数量。 ### QueryThread {#querythread} -查询处理线程的数量 +查询处理线程的数量。 ### RWLockActiveReaders {#rwlockactivereaders} -持有表 RWLock 中读锁的线程数量。 +在表RWLock中持有读锁的线程数量。 ### RWLockActiveWriters {#rwlockactivewriters} -持有表 RWLock 中写锁的线程数量。 +在表RWLock中持有写锁的线程数量。 ### RWLockWaitingReaders {#rwlockwaitingreaders} -在表 RWLock 中等待读取的线程数量。 +在表RWLock上等待读取的线程数量。 ### RWLockWaitingWriters {#rwlockwaitingwriters} -在表 RWLock 中等待写入的线程数量。 +在表RWLock上等待写入的线程数量。 ### Read {#read} -正在飞行中的读取(read, pread, io_getevents 等)系统调用数量 +正在处理的读(read,pread,io_getevents等)系统调用的数量。 ### ReadTaskRequestsSent {#readtaskrequestssent} -从远程服务器返回到发起服务器的正在飞行的回调请求的当前数量,以选择读取任务(针对 s3Cluster 表函数和类似功能)。在远程服务器端测量。 +从远程服务器返回到发起服务器的回调请求的当前数量,以选择读取任务(适用于s3Cluster表函数及类似)。在远程服务器端测量。 ### ReadonlyReplica {#readonlyreplica} -由于 ZooKeeper 会话丢失后重新初始化或启动时未配置 ZooKeeper,目前处于只读状态的 Replicated 表数量。 +当前处于只读状态的Replicated表的数量,因ZooKeeper会话丢失后的重新初始化或因未配置ZooKeeper而启动。 ### RemoteRead {#remoteread} -正在飞行中的远程读取数量 +带有远程读取的读取数量。 ### ReplicatedChecks {#replicatedchecks} -检查数据部分一致性的数量 +检查一致性的部分数量。 ### ReplicatedFetch {#replicatedfetch} -从副本中提取的数据部分数量 +正在从副本提取的数据部分数量。 ### ReplicatedSend {#replicatedsend} -发送到副本的数据部分数量 +正在发送到副本的数据部分数量。 ### RestartReplicaThreads {#restartreplicathreads} -RESTART REPLICA 线程池中的线程数量。 +RESTART REPLICA线程池中的线程数量。 ### RestartReplicaThreadsActive {#restartreplicathreadsactive} -RESTART REPLICA 线程池中正在运行任务的线程数量。 +在RESTART REPLICA线程池中运行任务的线程数量。 ### RestoreThreads {#restorethreads} -用于 RESTORE 的线程池中的线程数量。 +用于RESTORE的线程池中的线程数量。 ### RestoreThreadsActive {#restorethreadsactive} -用于 RESTORE 的线程池中正在运行任务的线程数量。 +在RESTORE线程池中运行任务的线程数量。 ### Revision {#revision} -服务器的修订版。它是一个数字,每次发布或发布候选版本(除补丁发布外)都递增。 +服务器的修订号。它是每次发布或发布候选版本递增的数字,不包括补丁发布。 ### S3Requests {#s3requests} -S3 请求 +S3请求。 ### SendExternalTables {#sendexternaltables} -为外部表向远程服务器发送数据的连接数量。外部表用于实现带有分布式子查询的 GLOBAL IN 和 GLOBAL JOIN 操作符。 +发送外部表数据到远程服务器的连接数量。外部表用于实现带有分布式子查询的GLOBAL IN和GLOBAL JOIN操作符。 ### SendScalars {#sendscalars} -为标量向远程服务器发送数据的连接数量。 +发送标量数据到远程服务器的连接数量。 ### StorageBufferBytes {#storagebufferbytes} -Buffer 表中缓冲区的字节数 +缓冲表的缓冲区中的字节数。 ### StorageBufferRows {#storagebufferrows} -Buffer 表中缓冲区的行数 +缓冲表的缓冲区中的行数。 ### StorageDistributedThreads {#storagedistributedthreads} -StorageDistributed 线程池中的线程数量。 +StorageDistributed线程池中的线程数量。 ### StorageDistributedThreadsActive {#storagedistributedthreadsactive} -StorageDistributed 线程池中正在运行任务的线程数量。 +在StorageDistributed线程池中运行任务的线程数量。 ### StorageHiveThreads {#storagehivethreads} -StorageHive 线程池中的线程数量。 +StorageHive线程池中的线程数量。 ### StorageHiveThreadsActive {#storagehivethreadsactive} -StorageHive 线程池中正在运行任务的线程数量。 +在StorageHive线程池中运行任务的线程数量。 ### StorageS3Threads {#storages3threads} -StorageS3 线程池中的线程数量。 +StorageS3线程池中的线程数量。 ### StorageS3ThreadsActive {#storages3threadsactive} -StorageS3 线程池中正在运行任务的线程数量。 +在StorageS3线程池中运行任务的线程数量。 ### SystemReplicasThreads {#systemreplicasthreads} -system.replicas 线程池中的线程数量。 +system.replicas线程池中的线程数量。 ### SystemReplicasThreadsActive {#systemreplicasthreadsactive} -system.replicas 线程池中正在运行任务的线程数量。 +在system.replicas线程池中运行任务的线程数量。 ### TCPConnection {#tcpconnection} -与 TCP 服务器(使用原生接口的客户端)的连接数量,包括服务器与服务器间的分布式查询连接 +与TCP服务器的连接数量(具有原生接口的客户端),也包括服务器到服务器的分布式查询连接。 ### TablesToDropQueueSize {#tablestodropqueuesize} -等待后台数据删除的已删除表的数量。 +等待后台数据删除的已删除表数量。 ### TemporaryFilesForAggregation {#temporaryfilesforaggregation} -为外部聚合创建的临时文件数量 +为外部聚合创建的临时文件数量。 ### TemporaryFilesForJoin {#temporaryfilesforjoin} -为 JOIN 创建的临时文件数量 +为JOIN创建的临时文件数量。 ### TemporaryFilesForSort {#temporaryfilesforsort} -为外部排序创建的临时文件数量 +为外部排序创建的临时文件数量。 ### TemporaryFilesUnknown {#temporaryfilesunknown} -创建但没有已知用途的临时文件数量 +创建的具有未知目的的临时文件数量。 ### ThreadPoolFSReaderThreads {#threadpoolfsreaderthreads} -本地_filesystem_read_method=threadpool 的线程池中的线程数量。 +用于local_filesystem_read_method=threadpool的线程池中的线程数量。 ### ThreadPoolFSReaderThreadsActive {#threadpoolfsreaderthreadsactive} -本地_filesystem_read_method=threadpool 的线程池中正在运行任务的线程数量。 +在local_filesystem_read_method=threadpool线程池中运行任务的线程数量。 ### ThreadPoolRemoteFSReaderThreads {#threadpoolremotefsreaderthreads} -远程_filesystem_read_method=threadpool 的线程池中的线程数量。 +用于remote_filesystem_read_method=threadpool的线程池中的线程数量。 ### ThreadPoolRemoteFSReaderThreadsActive {#threadpoolremotefsreaderthreadsactive} -远程_filesystem_read_method=threadpool 的线程池中正在运行任务的线程数量。 +在remote_filesystem_read_method=threadpool线程池中运行任务的线程数量。 ### ThreadsInOvercommitTracker {#threadsinovercommittracker} -在 OvercommitTracker 中等待的线程数量 +在OvercommitTracker中等待的线程数量。 ### TotalTemporaryFiles {#totaltemporaryfiles} -创建的临时文件数量 +创建的临时文件数量。 ### VersionInteger {#versioninteger} -服务器版本,以单个整数表示,基数为 1000。例如,版本 11.22.33 转换为 11022033。 +服务器的版本,以单个整数表示,基数为1000。例如,版本11.22.33转换为11022033。 ### Write {#write} -正在飞行中的写入(write, pwrite, io_getevents 等)系统调用数量 +正在处理的写(write,pwrite,io_getevents等)系统调用的数量。 ### ZooKeeperRequest {#zookeeperrequest} -正在飞行中对 ZooKeeper 的请求数量。 +正在处理的ZooKeeper请求数量。 ### ZooKeeperSession {#zookeepersession} -与 ZooKeeper 的会话(连接)数量。应不超过一个,因为使用多个连接与 ZooKeeper 连接可能导致缺乏线性化(过时读取)导致的问题,ZooKeeper 一致性模型允许这种情况。 +与ZooKeeper连接的会话数量。应不超过一个,因为使用多个与ZooKeeper的连接可能由于缺乏线性化(陈旧读取)导致错误,ZooKeeper一致性模型允许出现这种情况。 ### ZooKeeperWatch {#zookeeperwatch} -ZooKeeper 中观察(事件订阅)的数量。 +ZooKeeper中的观察(事件订阅)数量。 ### ConcurrencyControlAcquired {#concurrencycontrolacquired} -获得的 CPU 槽的总数量。 +获取的CPU槽的总数量。 ### ConcurrencyControlSoftLimit {#concurrencycontrolsoftlimit} -CPU 槽的软限制值。 +CPU槽的软限制值。 -**另请参阅** +**另见** -- [system.asynchronous_metrics](/operations/system-tables/asynchronous_metrics) — 包含定期计算的指标。 -- [system.events](/operations/system-tables/events) — 包含发生的一系列事件。 -- [system.metric_log](/operations/system-tables/metric_log) — 包含来自表 `system.metrics` 和 `system.events` 的指标值历史。 -- [Monitoring](../../operations/monitoring.md) — ClickHouse 监控的基本概念。 +- [system.asynchronous_metrics](/operations/system-tables/asynchronous_metrics) — 包含周期性计算的指标。 +- [system.events](/operations/system-tables/events) — 包含发生的事件数量。 +- [system.metric_log](/operations/system-tables/metric_log) — 包含来自 `system.metrics` 和 `system.events` 表的指标值历史记录。 +- [Monitoring](../../operations/monitoring.md) — ClickHouse监控的基本概念。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/metrics.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/metrics.md.hash index 83cffe3ca5b..6bb2c4fb187 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/metrics.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/metrics.md.hash @@ -1 +1 @@ -76b81ecb00fa9d77 +13cdfac890d44ae8 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/moves.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/moves.md index 10300b9fa19..68b0987549d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/moves.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/moves.md @@ -1,34 +1,35 @@ --- -'description': '系统表包含关于MergeTree表中进行中的数据分片移动的信息。每个数据分片的移动由一行表示。' +'description': '系统表包含关于MergeTree表中正在进行的数据部分移动的信息。每个数据部分的移动由一行表示。' 'keywords': - 'system table' - 'moves' 'slug': '/operations/system-tables/moves' 'title': 'system.moves' +'doc_type': 'reference' --- # system.moves -该表包含关于进行中的 [数据分区移动](/sql-reference/statements/alter/partition#move-partitionpart) 的信息,适用于 [MergeTree](/engines/table-engines/mergetree-family/mergetree.md) 表。每个数据分区的移动用一行表示。 +该表包含有关 [MergeTree](/engines/table-engines/mergetree-family/mergetree.md) 表的正在进行的 [数据部分移动](/sql-reference/statements/alter/partition#move-partitionpart) 的信息。每个数据部分移动由一行表示。 列: -- `database` ([String](/sql-reference/data-types/string.md)) — 数据库名称。 +- `database` ([String](/sql-reference/data-types/string.md)) — 数据库的名称。 -- `table` ([String](/sql-reference/data-types/string.md)) — 包含移动数据分区的表的名称。 +- `table` ([String](/sql-reference/data-types/string.md)) — 包含正在移动的数据部分的表的名称。 -- `elapsed` ([Float64](../../sql-reference/data-types/float.md)) — 数据分区移动开始以来经过的时间(秒)。 +- `elapsed` ([Float64](../../sql-reference/data-types/float.md)) — 自数据部分移动开始以来经过的时间(以秒为单位)。 -- `target_disk_name` ([String](disks.md)) — 数据分区移动到的 [磁盘](/operations/system-tables/disks/) 名称。 +- `target_disk_name` ([String](disks.md)) — 数据部分移动到的 [磁盘](/operations/system-tables/disks/) 的名称。 - `target_disk_path` ([String](disks.md)) — 文件系统中 [磁盘](/operations/system-tables/disks/) 的挂载点路径。 -- `part_name` ([String](/sql-reference/data-types/string.md)) — 正在移动的数据分区的名称。 +- `part_name` ([String](/sql-reference/data-types/string.md)) — 正在移动的数据部分的名称。 -- `part_size` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 数据分区大小。 +- `part_size` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 数据部分大小。 -- `thread_id` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 执行移动的线程标识符。 +- `thread_id` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 执行移动的线程的标识符。 **示例** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/moves.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/moves.md.hash index 3d6378dc8b6..3836f130619 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/moves.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/moves.md.hash @@ -1 +1 @@ -b2251eb7db33cf68 +c79efa06c51b6116 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/mutations.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/mutations.md index 896e0411848..910905d0f0f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/mutations.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/mutations.md @@ -1,64 +1,65 @@ --- -'description': '系统表包含有关 MergeTree 表的变更及其进度的信息。每个变更命令由单个行表示。' +'description': '系统表包含有关 MergeTree 表及其进度的变化的信息。每个变化命令由一行表示。' 'keywords': - 'system table' - 'mutations' 'slug': '/operations/system-tables/mutations' 'title': 'system.mutations' +'doc_type': 'reference' --- # system.mutations -该表包含有关 [mutations](/sql-reference/statements/alter/index.md#mutations) 的信息,这些 mutations 适用于 [MergeTree](/engines/table-engines/mergetree-family/mergetree.md) 表及其进展。每个 mutation 命令由单个行表示。 +该表包含关于[变更]( /sql-reference/statements/alter/index.md#mutations)的[MergeTree]( /engines/table-engines/mergetree-family/mergetree.md)表及其进度的信息。每个变更命令由一行表示。 -## Columns: {#columns} +## 列: {#columns} -- `database` ([String](/sql-reference/data-types/string.md)) — 应用 mutation 的数据库名称。 +- `database` ([String](/sql-reference/data-types/string.md)) — 变更应用的数据库名称。 -- `table` ([String](/sql-reference/data-types/string.md)) — 应用 mutation 的表名称。 +- `table` ([String](/sql-reference/data-types/string.md)) — 变更应用的表名称。 -- `mutation_id` ([String](/sql-reference/data-types/string.md)) — mutation 的 ID。对于副本表,这些 ID 对应于 ClickHouse Keeper 中 `/mutations/` 目录中的 znode 名称。对于非副本表,这些 ID 对应于表的数据目录中的文件名。 +- `mutation_id` ([String](/sql-reference/data-types/string.md)) — 变更的 ID。对于复制表,这些 ID 对应于 ClickHouse Keeper 中`/mutations/`目录中的 znode 名称。对于非复制表,ID 对应于表的数据目录中的文件名。 -- `command` ([String](/sql-reference/data-types/string.md)) — mutation 命令字符串(查询中 `ALTER TABLE [db.]table` 之后的部分)。 +- `command` ([String](/sql-reference/data-types/string.md)) — 变更命令字符串(`ALTER TABLE [db.]table`后查询的部分)。 -- `create_time` ([DateTime](/sql-reference/data-types/datetime.md)) — 提交执行 mutation 命令的日期和时间。 +- `create_time` ([DateTime](/sql-reference/data-types/datetime.md)) — 变更命令提交执行的日期和时间。 -- `block_numbers.partition_id` ([Array](/sql-reference/data-types/array.md)([String](/sql-reference/data-types/string.md))) — 对于副本表的 mutations,数组包含分区的 ID(每个分区一个记录)。对于非副本表的 mutations,数组为空。 +- `block_numbers.partition_id` ([Array](/sql-reference/data-types/array.md)([String](/sql-reference/data-types/string.md))) — 对于复制表,数组包含分区的 ID(每个分区一个记录)。对于非复制表,数组为空。 -- `block_numbers.number` ([Array](/sql-reference/data-types/array.md)([Int64](/sql-reference/data-types/int-uint.md))) — 对于副本表的 mutations,数组包含每个分区的记录,带有 mutation 获取的块号。只有包含小于该块号的块的部分将在分区中被变更。 +- `block_numbers.number` ([Array](/sql-reference/data-types/array.md)([Int64](/sql-reference/data-types/int-uint.md))) — 对于复制表,数组为每个分区包含一个记录,记录显示变更获得的区块编号。只有包含小于该编号的区块的部分将会在该分区内被变更。 - 在非副本表中,所有分区的块号形成一个单一的序列。这意味着对于非副本表的 mutations,此列将包含一个记录,带有通过 mutation 获取的一个单一块号。 + 在非复制表中,所有分区的区块编号形成一个单一序列。这意味着对于非复制表的变更,该列将包含一个记录,其中记录为变更获得的单个区块编号。 -- `parts_to_do_names` ([Array](/sql-reference/data-types/array.md)([String](/sql-reference/data-types/string.md))) — 需要变更的数据部分名称的数组,以便 mutation 完成。 +- `parts_to_do_names` ([Array](/sql-reference/data-types/array.md)([String](/sql-reference/data-types/string.md))) — 需要被变更以完成变更的部分名称数组。 -- `parts_to_do` ([Int64](/sql-reference/data-types/int-uint.md)) — 需要变更的数据部分数量,以便 mutation 完成。 +- `parts_to_do` ([Int64](/sql-reference/data-types/int-uint.md)) — 需要被变更的部分数量以完成变更。 -- `is_killed` ([UInt8](/sql-reference/data-types/int-uint.md)) — 指示 mutation 是否已被终止。 **仅在 ClickHouse Cloud 中可用。** +- `is_killed` ([UInt8](/sql-reference/data-types/int-uint.md)) — 表示变更是否已被终止。**仅在 ClickHouse Cloud 中可用。** :::note -`is_killed=1` 并不一定意味着 mutation 已完全完成。可能存在一个 mutation 的状态为 `is_killed=1` 和 `is_done=0`,持续一段时间。这可能发生在另一个长时间运行的 mutation 阻塞了被终止的 mutation。这是一种正常情况。 +`is_killed=1` 并不一定意味着变更已完全终止。变更可能保持在 `is_killed=1` 和 `is_done=0` 的状态较长时间。这可能发生在另一个运行时间较长的变更阻塞了被终止的变更。这是一种正常情况。 ::: -- `is_done` ([UInt8](/sql-reference/data-types/int-uint.md)) — 指示 mutation 是否完成的标志。可能的值: - - `1` 表示 mutation 已完成, - - `0` 表示 mutation 仍在进行中。 +- `is_done` ([UInt8](/sql-reference/data-types/int-uint.md)) — 表示变更是否完成的标志。可能的值: + - `1` 表示变更已完成, + - `0` 表示变更仍在进行中。 :::note -即使 `parts_to_do = 0`,也可能由于长时间运行的 `INSERT` 查询而导致副本表的 mutation 尚未完成,该查询将创建一个新的数据部分需要被变更。 +即使 `parts_to_do = 0`,复制表的变更可能仍未完成,因为有一个长时间运行的 `INSERT` 查询,这将创建一个需要被变更的新数据部分。 ::: -如果在变更某些数据部分时出现问题,以下列提供额外信息: +如果在变更某些数据部分时出现问题,以下列将包含额外的信息: -- `latest_failed_part` ([String](/sql-reference/data-types/string.md)) — 最新未能变更的部分的名称。 +- `latest_failed_part` ([String](/sql-reference/data-types/string.md)) — 最近无法变更的部分名称。 -- `latest_fail_time` ([DateTime](/sql-reference/data-types/datetime.md)) — 最近一次部分变更失败的日期和时间。 +- `latest_fail_time` ([DateTime](/sql-reference/data-types/datetime.md)) — 最近的部分变更失败的日期和时间。 -- `latest_fail_reason` ([String](/sql-reference/data-types/string.md)) — 导致最近一次部分变更失败的异常消息。 +- `latest_fail_reason` ([String](/sql-reference/data-types/string.md)) — 导致最近部分变更失败的异常消息。 -## Monitoring Mutations {#monitoring-mutations} +## 监控变更 {#monitoring-mutations} -要跟踪 system.mutations 表的进展,请使用如下查询 — 这需要对 system.* 表的读取权限: +要跟踪 system.mutations 表的进度,可以使用如下查询 - 这需要对 system.* 表的读取权限: ```sql SELECT * FROM clusterAllReplicas('cluster_name', 'db', system.mutations) @@ -66,11 +67,11 @@ WHERE is_done=0 AND table='tmp'; ``` :::tip -将 `table='tmp'` 中的 `tmp` 替换为您所检查变更的表的名称。 +将 `table='tmp'` 中的 `tmp` 替换为您正在检查变更的表的名称。 ::: -**另请参阅** +**另见** -- [Mutations](/sql-reference/statements/alter/index.md#mutations) -- [MergeTree](/engines/table-engines/mergetree-family/mergetree.md) 表引擎 -- [ReplicatedMergeTree](/engines/table-engines/mergetree-family/replication.md) 家族 +- [变更]( /sql-reference/statements/alter/index.md#mutations) +- [MergeTree]( /engines/table-engines/mergetree-family/mergetree.md) 表引擎 +- [ReplicatedMergeTree]( /engines/table-engines/mergetree-family/replication.md) 系列 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/mutations.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/mutations.md.hash index e218109c708..712ab4a2dfe 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/mutations.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/mutations.md.hash @@ -1 +1 @@ -8788151145f6d17d +4521de530f7ed1d5 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/numbers.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/numbers.md index 895f0a0fcb9..8eac0ccf073 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/numbers.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/numbers.md @@ -1,20 +1,21 @@ --- -'description': '系统表包含一个名为 `number` 的 UInt64 列,该列包含从零开始几乎所有的自然数。' +'description': '系统表包含一个名为 `number` 的 UInt64 列,该列几乎包含从零开始的所有自然数。' 'keywords': - 'system table' - 'numbers' 'slug': '/operations/system-tables/numbers' 'title': 'system.numbers' +'doc_type': 'reference' --- # system.numbers -此表包含一个名为 `number` 的 UInt64 列,该列包含从零开始几乎所有的自然数。 +此表包含一个名为 `number` 的 UInt64 列,几乎所有自然数从零开始。 -您可以将此表用于测试,或者如果您需要进行暴力搜索时使用。 +您可以将此表用于测试,或者如果您需要进行暴力搜索。 -从此表的读取没有并行化。 +从此表的读取不是并行化的。 **示例** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/numbers.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/numbers.md.hash index d5775222878..860a57c3ff6 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/numbers.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/numbers.md.hash @@ -1 +1 @@ -7892f2dda6d78c11 +98e4076cadb4ebbf diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/numbers_mt.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/numbers_mt.md index ee54d41b8fc..27ee4447bf8 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/numbers_mt.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/numbers_mt.md @@ -1,13 +1,14 @@ --- -'description': '系统表类似于 `system.numbers` 但读取是并行的,数字可以以任何顺序返回。' +'description': '系统表与 `system.numbers` 相似,但读取是并行化的,并且数字可以以任意顺序返回。' 'keywords': - 'system table' - 'numbers_mt' 'slug': '/operations/system-tables/numbers_mt' 'title': 'system.numbers_mt' +'doc_type': 'reference' --- -与 [`system.numbers`](../../operations/system-tables/numbers.md) 相同,但读取是并行化的。数字可以以任何顺序返回。 +与 [`system.numbers`](../../operations/system-tables/numbers.md) 相同,但读取是并行化的。数字可以按任意顺序返回。 用于测试。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/numbers_mt.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/numbers_mt.md.hash index de527a86209..652f8c2d96b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/numbers_mt.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/numbers_mt.md.hash @@ -1 +1 @@ -446e87f5d16ed1ba +05f2709ee5f77142 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/one.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/one.md index d281a4109fa..1d0804319cd 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/one.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/one.md @@ -1,20 +1,21 @@ --- -'description': '系统表包含一个行和一个 `dummy` UInt8 列,值为 0。类似于其他 DBMS 中找到的 `DUAL` 表。' +'description': '系统表包含一行和一个`dummy` UInt8 列,其值为 0。类似于其他 DBMS 中的 `DUAL` 表。' 'keywords': - 'system table' - 'one' 'slug': '/operations/system-tables/one' 'title': 'system.one' +'doc_type': 'reference' --- # system.one -这个表包含一行,具有一个 `dummy` UInt8 列,其值为 0。 +该表包含一行,包含一个 `dummy` UInt8 列,其中的值为 0。 -如果 `SELECT` 查询未指定 `FROM` 子句,则使用此表。 +当 `SELECT` 查询未指定 `FROM` 子句时,将使用该表。 -这类似于其他数据库管理系统中的 `DUAL` 表。 +这类似于在其他数据库管理系统中发现的 `DUAL` 表。 **示例** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/one.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/one.md.hash index 715eeeb698d..298298492c3 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/one.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/one.md.hash @@ -1 +1 @@ -250c76f6123cf5ef +e8ebe94ffea818ca diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/opentelemetry_span_log.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/opentelemetry_span_log.md index e620961467a..4606b11e3c3 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/opentelemetry_span_log.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/opentelemetry_span_log.md @@ -1,10 +1,11 @@ --- -'description': '系统表包含关于执行查询的跟踪跨度的信息。' +'description': '系统表包含关于已执行查询的跟踪跨度的信息。' 'keywords': - 'system table' - 'opentelemetry_span_log' 'slug': '/operations/system-tables/opentelemetry_span_log' 'title': 'system.opentelemetry_span_log' +'doc_type': 'reference' --- import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_system_table_cloud.md'; @@ -14,25 +15,25 @@ import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/curre -包含有关执行的查询的 [trace spans](https://opentracing.io/docs/overview/spans/) 的信息。 +包含关于已执行查询的 [trace spans](https://opentracing.io/docs/overview/spans/) 的信息。 列: -- `trace_id` ([UUID](../../sql-reference/data-types/uuid.md)) — 执行查询的追踪 ID。 +- `trace_id` ([UUID](../../sql-reference/data-types/uuid.md)) — 已执行查询的 trace 的 ID。 - `span_id` ([UInt64](../../sql-reference/data-types/int-uint.md)) — `trace span` 的 ID。 - `parent_span_id` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 父 `trace span` 的 ID。 - `operation_name` ([String](../../sql-reference/data-types/string.md)) — 操作的名称。 - `kind` ([Enum8](../../sql-reference/data-types/enum.md)) — span 的 [SpanKind](https://opentelemetry.io/docs/reference/specification/trace/api/#spankind)。 - - `INTERNAL` — 表示 span 表示应用程序内部操作。 - - `SERVER` — 表示 span 涉及对同步 RPC 或其他远程请求的服务器端处理。 - - `CLIENT` — 表示 span 描述对某个远程服务的请求。 - - `PRODUCER` — 表示 span 描述异步请求的发起者。此父 span 通常在相应的子 CONSUMER span 结束之前结束,甚至可能在子 span 开始之前。 - - `CONSUMER` - 表示 span 描述异步 PRODUCER 请求的子请求。 + - `INTERNAL` — 表示 span 代表应用程序内部的操作。 + - `SERVER` — 表示 span 涉及同步 RPC 或其他远程请求的服务器端处理。 + - `CLIENT` — 表示 span 描述对某个远程服务的请求。 + - `PRODUCER` — 表示 span 描述异步请求的发起者。该父 span 通常会在相应的子 CONSUMER span 之前结束,甚至可能在子 span 开始之前结束。 + - `CONSUMER` — 表示 span 描述异步 PRODUCER 请求的子项。 - `start_time_us` ([UInt64](../../sql-reference/data-types/int-uint.md)) — `trace span` 的开始时间(以微秒为单位)。 - `finish_time_us` ([UInt64](../../sql-reference/data-types/int-uint.md)) — `trace span` 的结束时间(以微秒为单位)。 - `finish_date` ([Date](../../sql-reference/data-types/date.md)) — `trace span` 的结束日期。 -- `attribute.names` ([Array](../../sql-reference/data-types/array.md)([String](../../sql-reference/data-types/string.md))) — 根据 `trace span` 填充的 [Attribute](https://opentelemetry.io/docs/go/instrumentation/#attributes) 名称。它们是根据 [OpenTelemetry](https://opentelemetry.io/) 标准中的建议填写的。 -- `attribute.values` ([Array](../../sql-reference/data-types/array.md)([String](../../sql-reference/data-types/string.md))) — 根据 `trace span` 填充的属性值。它们是根据 `OpenTelemetry` 标准中的建议填写的。 +- `attribute.names` ([Array](../../sql-reference/data-types/array.md)([String](../../sql-reference/data-types/string.md))) — 依赖于 `trace span` 的 [Attribute](https://opentelemetry.io/docs/go/instrumentation/#attributes) 名称。它们根据 [OpenTelemetry](https://opentelemetry.io/) 标准中的建议进行填充。 +- `attribute.values` ([Array](../../sql-reference/data-types/array.md)([String](../../sql-reference/data-types/string.md))) — 依赖于 `trace span` 的属性值。它们根据 `OpenTelemetry` 标准中的建议进行填充。 **示例** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/opentelemetry_span_log.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/opentelemetry_span_log.md.hash index 6c5be6f2308..1c5c359151b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/opentelemetry_span_log.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/opentelemetry_span_log.md.hash @@ -1 +1 @@ -c19ea399510a421e +ae4164a9abe80cfa diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/overview.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/overview.md index 9856fb76609..8d2cf726ea6 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/overview.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/overview.md @@ -1,5 +1,5 @@ --- -'description': '系统表是什么以及它们为什么有用的概述。' +'description': '系统表是什么以及它们为何有用的概述。' 'keywords': - 'system tables' - 'overview' @@ -7,6 +7,7 @@ 'sidebar_position': 52 'slug': '/operations/system-tables/overview' 'title': '系统表概述' +'doc_type': 'reference' --- ## 系统表概述 {#system-tables-introduction} @@ -20,21 +21,21 @@ 系统表: - 位于 `system` 数据库中。 -- 仅支持读取数据。 +- 仅可用于读取数据。 - 不能被删除或修改,但可以被分离。 -大多数系统表将其数据存储在 RAM 中。ClickHouse 服务器在启动时创建这些系统表。 +大多数系统表将其数据存储在内存中。ClickHouse 服务器在启动时创建这些系统表。 -与其他系统表不同,系统日志表 [metric_log](../../operations/system-tables/metric_log.md), [query_log](../../operations/system-tables/query_log.md), [query_thread_log](../../operations/system-tables/query_thread_log.md), [trace_log](../../operations/system-tables/trace_log.md), [part_log](../../operations/system-tables/part_log.md), [crash_log](../../operations/system-tables/crash-log.md), [text_log](../../operations/system-tables/text_log.md) 和 [backup_log](../../operations/system-tables/backup_log.md) 使用 [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) 表引擎,并默认将其数据存储在文件系统中。如果从文件系统中删除一个表,ClickHouse 服务器将在下次写入数据时重新创建一个空表。如果系统表的架构在新版本中发生变化,则 ClickHouse 会重命名当前表并创建一个新表。 +与其他系统表不同,系统日志表 [metric_log](../../operations/system-tables/metric_log.md)、[query_log](../../operations/system-tables/query_log.md)、[query_thread_log](../../operations/system-tables/query_thread_log.md)、[trace_log](../../operations/system-tables/trace_log.md)、[part_log](../../operations/system-tables/part_log.md)、[crash_log](../../operations/system-tables/crash_log.md)、[text_log](../../operations/system-tables/text_log.md) 和 [backup_log](../../operations/system-tables/backup_log.md) 由 [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) 表引擎提供服务,并默认将其数据存储在文件系统中。如果从文件系统中删除一个表,ClickHouse 服务器将在下一次写入数据时再次创建一个空表。如果在新版本中系统表的模式发生变化,ClickHouse 将重命名当前表并创建一个新表。 -系统日志表可以通过在 `/etc/clickhouse-server/config.d/` 下创建与表同名的配置文件,或在 `/etc/clickhouse-server/config.xml` 中设置相应元素进行自定义。可以自定义的元素包括: +可以通过在 `/etc/clickhouse-server/config.d/` 下创建与表同名的配置文件,或在 `/etc/clickhouse-server/config.xml` 中设置相应元素,来自定义系统日志表。可以自定义的元素包括: -- `database`: 系统日志表所属的数据库。此选项现已弃用。所有系统日志表都在 `system` 数据库下。 -- `table`: 插入数据的表。 -- `partition_by`: 指定 [PARTITION BY](../../engines/table-engines/mergetree-family/custom-partitioning-key.md) 表达式。 -- `ttl`: 指定表的 [TTL](../../sql-reference/statements/alter/ttl.md) 表达式。 -- `flush_interval_milliseconds`: 刷新数据到磁盘的间隔。 -- `engine`: 提供完整的引擎表达式(以 `ENGINE =` 开头)及参数。此选项与 `partition_by` 和 `ttl` 冲突。如果一起设置,服务器将引发异常并退出。 +- `database`:系统日志表所属的数据库。此选项已弃用。所有系统日志表均位于 `system` 数据库下。 +- `table`:插入数据的表。 +- `partition_by`:指定 [PARTITION BY](../../engines/table-engines/mergetree-family/custom-partitioning-key.md) 表达式。 +- `ttl`:指定表 [TTL](../../sql-reference/statements/alter/ttl.md) 表达式。 +- `flush_interval_milliseconds`:将数据刷新到磁盘的间隔。 +- `engine`:提供带参数的完整引擎表达式(以 `ENGINE =` 开头)。此选项与 `partition_by` 和 `ttl` 冲突。如果一起设置,服务器将引发异常并退出。 示例: @@ -57,20 +58,20 @@ ``` -默认情况下,表的增长是无限的。要控制表的大小,可以使用 [TTL](/sql-reference/statements/alter/ttl) 设置来删除过时的日志记录。还可以使用 `MergeTree` 引擎表的分区功能。 +默认情况下,表的增长是无限制的。要控制表的大小,可以使用 [TTL](/sql-reference/statements/alter/ttl) 设置以删除过时的日志记录。您还可以使用 `MergeTree` 引擎表的分区功能。 -## 系统指标的来源 {#system-tables-sources-of-system-metrics} +## 系统指标来源 {#system-tables-sources-of-system-metrics} 为了收集系统指标,ClickHouse 服务器使用: -- `CAP_NET_ADMIN` 权限。 -- [procfs](https://en.wikipedia.org/wiki/Procfs)(仅限 Linux)。 +- `CAP_NET_ADMIN` 能力。 +- [procfs](https://en.wikipedia.org/wiki/Procfs)(仅在 Linux 上)。 **procfs** -如果 ClickHouse 服务器没有 `CAP_NET_ADMIN` 权限,它会尝试回退到 `ProcfsMetricsProvider`。`ProcfsMetricsProvider` 允许收集每个查询的系统指标(对于 CPU 和 I/O)。 +如果 ClickHouse 服务器没有 `CAP_NET_ADMIN` 能力,它会尝试回退到 `ProcfsMetricsProvider`。`ProcfsMetricsProvider` 允许收集每个查询的系统指标(用于 CPU 和 I/O)。 -如果系统支持并启用 procfs,ClickHouse 服务器收集以下指标: +如果系统支持并启用 procfs,ClickHouse 服务器会收集以下指标: - `OSCPUVirtualTimeMicroseconds` - `OSCPUWaitMicroseconds` @@ -81,12 +82,12 @@ - `OSWriteBytes` :::note -在从 5.14.x 开始的 Linux 内核中,`OSIOWaitMicroseconds` 默认禁用。您可以使用 `sudo sysctl kernel.task_delayacct=1` 启用它,或者在 `/etc/sysctl.d/` 中创建一个 `.conf` 文件,内容为 `kernel.task_delayacct = 1`。 +`OSIOWaitMicroseconds` 在从 5.14.x 开始的 Linux 内核中默认禁用。您可以使用 `sudo sysctl kernel.task_delayacct=1` 启用它,或通过在 `/etc/sysctl.d/` 中创建 `.conf` 文件并设置 `kernel.task_delayacct = 1`。 ::: -## ClickHouse Cloud 中的系统表 {#system-tables-in-clickhouse-cloud} +## ClickHouse Cloud中的系统表 {#system-tables-in-clickhouse-cloud} -在 ClickHouse Cloud 中,系统表提供对服务状态和性能的关键洞察,就像在自管理部署中一样。一些系统表在集群范围内运行,特别是那些从 Keeper 节点获取数据的系统表,Keeper 节点管理分布式元数据。这些表反映了集群的整体状态,并在查询单个节点时应保持一致。例如,`parts` 表应该无论从哪个节点查询都保持一致: +在 ClickHouse Cloud 中,系统表提供服务状态和性能的关键见解,与自管理部署的表现相同。一些系统表在集群级别操作,尤其是那些从 Keeper 节点获取数据的表,Keeper 节点管理分布式元数据。这些表反映集群的整体状态,并在对单个节点进行查询时应保持一致。例如,[`parts`](/operations/system-tables/parts) 表在从任何节点查询时应保持一致: ```sql SELECT hostname(), count() @@ -112,17 +113,17 @@ WHERE `table` = 'pypi' 1 row in set. Elapsed: 0.004 sec. ``` -相反,其他系统表是特定于节点的,例如内存中的表或使用 MergeTree 表引擎持久化数据的表。这对于日志和指标等数据是典型的。此持久性确保历史数据可用于分析。然而,这些特定于节点的表本质上对每个节点是唯一的。 +相反,其他系统表是节点特定的,例如,在内存中或使用 MergeTree 表引擎持久化其数据。这对于日志和指标等数据是典型的。这种持久性确保历史数据可用于分析。然而,这些节点特定的表在每个节点上本质上都是唯一的。 -一般来说,确定系统表是否特定于节点时,可以应用以下规则: +一般来说,当确定系统表是否是节点特定时,可以应用以下规则: -- 后缀为 `_log` 的系统表。 +- 带有 `_log` 后缀的系统表。 - 公开指标的系统表,例如 `metrics`、`asynchronous_metrics`、`events`。 - 公开正在进行的进程的系统表,例如 `processes`、`merges`。 -此外,系统表的新版本可能是由于升级或架构更改而创建的。这些版本使用数字后缀命名。 +此外,系统表的新版本可能由于升级或模式更改而创建。这些版本以数字后缀命名。 -例如,考虑 `system.query_log` 表,它包含节点执行的每个查询的一行: +例如,考虑 `system.query_log` 表,该表为每个由节点执行的查询包含一行: ```sql SHOW TABLES FROM system LIKE 'query_log%' @@ -146,7 +147,7 @@ SHOW TABLES FROM system LIKE 'query_log%' ### 查询多个版本 {#querying-multiple-versions} -我们可以使用 [`merge`](/sql-reference/table-functions/merge) 函数跨这些表进行查询。例如,以下查询识别向每个 `query_log` 表发出的最新查询: +我们可以使用 [`merge`](/sql-reference/table-functions/merge) 函数跨表查询。例如,下面的查询识别每个 `query_log` 表中发往目标节点的最新查询: ```sql SELECT @@ -174,23 +175,23 @@ ORDER BY most_recent DESC Peak memory usage: 28.45 MiB. ``` -:::note 不要依赖数字后缀进行排序 -虽然表上的数字后缀可以暗示数据的顺序,但绝不能依赖此顺序。因此,始终在目标特定日期范围时,使用合并表函数结合日期过滤器。 +:::note 别依赖数字后缀排序 +虽然表上的数字后缀可以暗示数据的顺序,但不应依赖于此。因此,针对特定日期范围时,始终使用合并表函数并结合日期过滤器。 ::: 重要的是,这些表仍然是 **每个节点本地的**。 ### 跨节点查询 {#querying-across-nodes} -为了全面查看整个集群,用户可以利用 [`clusterAllReplicas`](/sql-reference/table-functions/cluster) 函数结合 `merge` 函数。`clusterAllReplicas` 函数允许查询 "default" 集群中所有副本的系统表,将特定于节点的数据整合为统一结果。结合 `merge` 函数,这可以用于针对集群中特定表的所有系统数据。 +为了全面查看整个集群,用户可以利用 [`clusterAllReplicas`](/sql-reference/table-functions/cluster) 函数与 `merge` 函数结合使用。`clusterAllReplicas` 函数允许查询 "default" 集群中所有副本的系统表,将节点特定数据整合为统一结果。当与 `merge` 函数结合使用时,可以用于定向集群中特定表的所有系统数据。 -这种方法对于监控和调试集群范围的操作尤其有价值,确保用户可以有效分析其 ClickHouse Cloud 部署的健康状况和性能。 +这种方法特别有价值,用于监控和调试集群级操作,确保用户可以有效分析他们的 ClickHouse Cloud 部署的健康状态和性能。 :::note -ClickHouse Cloud 提供多个副本的集群以实现冗余和故障转移。这启用其特性,例如动态自动扩展和零停机时间升级。在某个时刻,新的节点可能正在添加到集群中或从集群中移除。要跳过这些节点,请在查询中添加 `SETTINGS skip_unavailable_shards = 1`,使用 `clusterAllReplicas`,如下面所示。 +ClickHouse Cloud 提供多个副本的集群以实现冗余和故障转移。这使其具备动态自动扩展和零停机升级等功能。在某个时刻,可能有新节点正在添加到集群或从集群中移除。要跳过这些节点,请在使用 `clusterAllReplicas` 的查询中添加 `SETTINGS skip_unavailable_shards = 1`,如下所示。 ::: -例如,考虑在查询 `query_log` 表时的差异 - 这对于分析通常是必不可少的。 +例如,考虑查询 `query_log` 表的差异 - 这通常是分析的关键。 ```sql SELECT @@ -224,7 +225,7 @@ GROUP BY host SETTINGS skip_unavailable_shards = 1 ### 跨节点和版本查询 {#querying-across-nodes-and-versions} -由于系统表版本化,这仍然不能代表集群中的完整数据。当将上述内容与 `merge` 函数结合使用时,我们获得了目标日期范围的准确结果: +由于系统表版本问题,这仍然不能代表集群中的完整数据。当将上述与 `merge` 函数结合使用时,我们获得准确的日期范围结果: ```sql SELECT @@ -245,6 +246,6 @@ GROUP BY host SETTINGS skip_unavailable_shards = 1 ## 相关内容 {#related-content} -- 博客: [系统表和 ClickHouse 内部的窗口](https://clickhouse.com/blog/clickhouse-debugging-issues-with-system-tables) -- 博客: [基本监控查询 - 第 1 部分 - INSERT 查询](https://clickhouse.com/blog/monitoring-troubleshooting-insert-queries-clickhouse) -- 博客: [基本监控查询 - 第 2 部分 - SELECT 查询](https://clickhouse.com/blog/monitoring-troubleshooting-select-queries-clickhouse) +- 博客: [系统表及 ClickHouse 内部结构的窗口](https://clickhouse.com/blog/clickhouse-debugging-issues-with-system-tables) +- 博客: [必备监控查询 - 第1部分 - INSERT 查询](https://clickhouse.com/blog/monitoring-troubleshooting-insert-queries-clickhouse) +- 博客: [必备监控查询 - 第2部分 - SELECT 查询](https://clickhouse.com/blog/monitoring-troubleshooting-select-queries-clickhouse) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/overview.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/overview.md.hash index 1f303c6aae6..bf5e88b8e9f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/overview.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/overview.md.hash @@ -1 +1 @@ -586c6ad2fa6bfd74 +69682cdb747efd75 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/part_log.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/part_log.md index e020f55f935..eb166a8ca57 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/part_log.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/part_log.md @@ -1,10 +1,11 @@ --- -'description': '系统表,包含有关在MergeTree家族表中与数据部分发生的事件的信息,例如添加或合并数据。' +'description': '系统表包含有关在MergeTree家族表中发生的数据部分事件的信息,例如添加或合并数据。' 'keywords': - 'system table' - 'part_log' 'slug': '/operations/system-tables/part_log' 'title': 'system.part_log' +'doc_type': 'reference' --- import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_system_table_cloud.md'; @@ -14,52 +15,57 @@ import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/curre -只有当指定了 [part_log](/operations/server-configuration-parameters/settings#part_log) 服务器设置时,`system.part_log` 表才会被创建。 +`system.part_log` 表仅在指定了 [part_log](/operations/server-configuration-parameters/settings#part_log) 服务器设置后创建。 -该表包含有关在 [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) 系列表中的 [数据部分](../../engines/table-engines/mergetree-family/custom-partitioning-key.md) 发生的事件的信息,例如添加或合并数据。 +该表包含有关发生在 [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) 家族表中 [数据部分](../../engines/table-engines/mergetree-family/custom-partitioning-key.md) 的事件的信息,例如添加或合并数据。 `system.part_log` 表包含以下列: - `hostname` ([LowCardinality(String)](../../sql-reference/data-types/string.md)) — 执行查询的服务器的主机名。 -- `query_id` ([String](../../sql-reference/data-types/string.md)) — 创建该数据部分的 `INSERT` 查询的标识符。 -- `event_type` ([Enum8](../../sql-reference/data-types/enum.md)) — 与数据部分发生的事件类型。可以具有以下值之一: - - `NewPart` — 插入新的数据部分。 - - `MergePartsStart` — 数据部分的合并已开始。 - - `MergeParts` — 数据部分的合并已完成。 - - `DownloadPart` — 正在下载数据部分。 - - `RemovePart` — 使用 [DETACH PARTITION](/sql-reference/statements/alter/partition#detach-partitionpart) 移除或分离数据部分。 - - `MutatePartStart` — 数据部分的变异已开始。 - - `MutatePart` — 数据部分的变异已完成。 - - `MovePart` — 将数据部分从一个磁盘移动到另一个磁盘。 -- `merge_reason` ([Enum8](../../sql-reference/data-types/enum.md)) — 事件类型为 `MERGE_PARTS` 的原因。可以具有以下值之一: - - `NotAMerge` — 当前事件的类型不是 `MERGE_PARTS`。 - - `RegularMerge` — 一些常规合并。 - - `TTLDeleteMerge` — 清理过期数据。 - - `TTLRecompressMerge` — 重新压缩数据部分。 -- `merge_algorithm` ([Enum8](../../sql-reference/data-types/enum.md)) — 事件类型为 `MERGE_PARTS` 的合并算法。可以具有以下值之一: - - `Undecided` - - `Horizontal` - - `Vertical` +- `query_id` ([String](../../sql-reference/data-types/string.md)) — 创建此数据部分的 `INSERT` 查询的标识符。 +- `event_type` ([Enum8](../../sql-reference/data-types/enum.md)) — 与数据部分发生的事件类型。可能具有以下值之一: + - `NewPart` — 插入新的数据部分。 + - `MergePartsStart` — 数据部分合并已开始。 + - `MergeParts` — 数据部分合并已完成。 + - `DownloadPart` — 下载数据部分。 + - `RemovePart` — 使用 [DETACH PARTITION](/sql-reference/statements/alter/partition#detach-partitionpart) 移除或分离数据部分。 + - `MutatePartStart` — 数据部分的变更已开始。 + - `MutatePart` — 数据部分的变更已完成。 + - `MovePart` — 将数据部分从一个磁盘移动到另一个磁盘。 +- `merge_reason` ([Enum8](../../sql-reference/data-types/enum.md)) — 事件类型为 `MERGE_PARTS` 的原因。可能具有以下值之一: + - `NotAMerge` — 当前事件的类型不是 `MERGE_PARTS`。 + - `RegularMerge` — 一些常规合并。 + - `TTLDeleteMerge` — 清理过期数据。 + - `TTLRecompressMerge` — 对数据部分进行重新压缩。 +- `merge_algorithm` ([Enum8](../../sql-reference/data-types/enum.md)) — 事件类型为 `MERGE_PARTS` 的合并算法。可能具有以下值之一: + - `Undecided` + - `Horizontal` + - `Vertical` - `event_date` ([Date](../../sql-reference/data-types/date.md)) — 事件日期。 - `event_time` ([DateTime](../../sql-reference/data-types/datetime.md)) — 事件时间。 -- `event_time_microseconds` ([DateTime64](../../sql-reference/data-types/datetime64.md)) — 带有微秒精度的事件时间。 +- `event_time_microseconds` ([DateTime64](../../sql-reference/data-types/datetime64.md)) — 具有微秒精度的事件时间。 - `duration_ms` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 持续时间。 -- `database` ([String](../../sql-reference/data-types/string.md)) — 数据部分所在数据库的名称。 -- `table` ([String](../../sql-reference/data-types/string.md)) — 数据部分所在表的名称。 -- `part_name` ([String](../../sql-reference/data-types/string.md)) — 数据部分的名称。 -- `partition_id` ([String](../../sql-reference/data-types/string.md)) — 数据部分插入的分区 ID。如果分区按 `tuple()` 划分,该列取值为 `all`。 -- `path_on_disk` ([String](../../sql-reference/data-types/string.md)) — 数据部分文件夹的绝对路径。 +- `database` ([String](../../sql-reference/data-types/string.md)) — 数据部分所在的数据库名称。 +- `table` ([String](../../sql-reference/data-types/string.md)) — 数据部分所在的表名称。 +- `table_uuid` ([UUID](../../sql-reference/data-types/uuid.md)) — 数据部分所属表的 UUID。 +- `part_name` ([String](../../sql-reference/data-types/string.md)) — 数据部分名称。 +- `partition_id` ([String](../../sql-reference/data-types/string.md)) — 数据部分插入到的分区 ID。如果分区是按 `tuple()` 划分的,列取 `all` 值。 +- `partition` ([String](../../sql-reference/data-types/string.md)) - 分区名称。 +- `part_type` ([String](../../sql-reference/data-types/string.md)) - 部件的类型。可能值:Wide 和 Compact。 +- `disk_name` ([String](../../sql-reference/data-types/string.md)) - 数据部分所在的磁盘名称。 +- `path_on_disk` ([String](../../sql-reference/data-types/string.md)) — 数据部分文件所在文件夹的绝对路径。 - `rows` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 数据部分中的行数。 - `size_in_bytes` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 数据部分的大小(以字节为单位)。 -- `merged_from` ([Array(String)](../../sql-reference/data-types/array.md)) — 当前部分合并而成的部分名称数组(合并后)。 +- `merged_from` ([Array(String)](../../sql-reference/data-types/array.md)) — 当前部分由哪些部分组成的名称数组(合并后)。 - `bytes_uncompressed` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 未压缩字节的大小。 -- `read_rows` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 合并过程中读取的行数。 -- `read_bytes` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 合并过程中读取的字节数。 -- `peak_memory_usage` ([Int64](../../sql-reference/data-types/int-uint.md)) — 在此线程上下文中分配和释放内存之间的最大差异。 -- `error` ([UInt16](../../sql-reference/data-types/int-uint.md)) — 发生错误的代码号码。 +- `read_rows` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 在合并过程中读取的行数。 +- `read_bytes` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 在合并过程中读取的字节数。 +- `peak_memory_usage` ([Int64](../../sql-reference/data-types/int-uint.md)) — 在此线程上下文中已分配和释放内存的最大差异。 +- `error` ([UInt16](../../sql-reference/data-types/int-uint.md)) — 发生错误的代码编号。 - `exception` ([String](../../sql-reference/data-types/string.md)) — 发生错误的文本消息。 +- `ProfileEvents` ([Map(String, UInt64)](../../sql-reference/data-types/map.md)) — 测量不同指标的 ProfileEvents。它们的描述可以在表 [system.events](/operations/system-tables/events) 中找到。 -在首次插入数据到 `MergeTree` 表后,会创建 `system.part_log` 表。 +在第一次插入数据到 `MergeTree` 表后创建 `system.part_log` 表。 **示例** @@ -70,27 +76,32 @@ SELECT * FROM system.part_log LIMIT 1 FORMAT Vertical; ```text Row 1: ────── -hostname: clickhouse.eu-central1.internal -query_id: 983ad9c7-28d5-4ae1-844e-603116b7de31 -event_type: NewPart -merge_reason: NotAMerge -merge_algorithm: Undecided -event_date: 2021-02-02 -event_time: 2021-02-02 11:14:28 -event_time_microseconds: 2021-02-02 11:14:28.861919 -duration_ms: 35 -database: default -table: log_mt_2 -part_name: all_1_1_0 -partition_id: all -path_on_disk: db/data/default/log_mt_2/all_1_1_0/ -rows: 115418 -size_in_bytes: 1074311 -merged_from: [] -bytes_uncompressed: 0 -read_rows: 0 -read_bytes: 0 -peak_memory_usage: 0 -error: 0 +hostname: clickhouse.eu-central1.internal +query_id: +event_type: MergeParts +merge_reason: RegularMerge +merge_algorithm: Vertical +event_date: 2025-07-19 +event_time: 2025-07-19 23:54:19 +event_time_microseconds: 2025-07-19 23:54:19.710761 +duration_ms: 2158 +database: default +table: github_events +table_uuid: 1ad33424-f5f5-402b-ac03-ec82282634ab +part_name: all_1_7_1 +partition_id: all +partition: tuple() +part_type: Wide +disk_name: default +path_on_disk: ./data/store/1ad/1ad33424-f5f5-402b-ac03-ec82282634ab/all_1_7_1/ +rows: 3285726 -- 3.29 million +size_in_bytes: 438968542 -- 438.97 million +merged_from: ['all_1_1_0','all_2_2_0','all_3_3_0','all_4_4_0','all_5_5_0','all_6_6_0','all_7_7_0'] +bytes_uncompressed: 1373137767 -- 1.37 billion +read_rows: 3285726 -- 3.29 million +read_bytes: 1429206946 -- 1.43 billion +peak_memory_usage: 303611887 -- 303.61 million +error: 0 exception: +ProfileEvents: {'FileOpen':703,'ReadBufferFromFileDescriptorRead':3824,'ReadBufferFromFileDescriptorReadBytes':439601681,'WriteBufferFromFileDescriptorWrite':592,'WriteBufferFromFileDescriptorWriteBytes':438988500,'ReadCompressedBytes':439601681,'CompressedReadBufferBlocks':6314,'CompressedReadBufferBytes':1539835748,'OpenedFileCacheHits':50,'OpenedFileCacheMisses':484,'OpenedFileCacheMicroseconds':222,'IOBufferAllocs':1914,'IOBufferAllocBytes':319810140,'ArenaAllocChunks':8,'ArenaAllocBytes':131072,'MarkCacheMisses':7,'CreatedReadBufferOrdinary':534,'DiskReadElapsedMicroseconds':139058,'DiskWriteElapsedMicroseconds':51639,'AnalyzePatchRangesMicroseconds':28,'ExternalProcessingFilesTotal':1,'RowsReadByMainReader':170857759,'WaitMarksLoadMicroseconds':988,'LoadedMarksFiles':7,'LoadedMarksCount':14,'LoadedMarksMemoryBytes':728,'Merge':2,'MergeSourceParts':14,'MergedRows':3285733,'MergedColumns':4,'GatheredColumns':51,'MergedUncompressedBytes':1429207058,'MergeTotalMilliseconds':2158,'MergeExecuteMilliseconds':2155,'MergeHorizontalStageTotalMilliseconds':145,'MergeHorizontalStageExecuteMilliseconds':145,'MergeVerticalStageTotalMilliseconds':2008,'MergeVerticalStageExecuteMilliseconds':2006,'MergeProjectionStageTotalMilliseconds':5,'MergeProjectionStageExecuteMilliseconds':4,'MergingSortedMilliseconds':7,'GatheringColumnMilliseconds':56,'ContextLock':2091,'PartsLockHoldMicroseconds':77,'PartsLockWaitMicroseconds':1,'RealTimeMicroseconds':2157475,'CannotWriteToWriteBufferDiscard':36,'LogTrace':6,'LogDebug':59,'LoggerElapsedNanoseconds':514040,'ConcurrencyControlSlotsGranted':53,'ConcurrencyControlSlotsAcquired':53} ``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/part_log.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/part_log.md.hash index 92d82201606..a9bffca0852 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/part_log.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/part_log.md.hash @@ -1 +1 @@ -e3be014568eb4e62 +8509ddda16b7f6e6 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/parts.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/parts.md index 01d1d275ea7..6e441a4cf53 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/parts.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/parts.md @@ -1,119 +1,120 @@ --- -'description': '系统表包含关于 MergeTree 的分区片段的信息' +'description': '系统表包含关于MergeTree分区片段的信息' 'keywords': - 'system table' - 'parts' 'slug': '/operations/system-tables/parts' 'title': 'system.parts' +'doc_type': 'reference' --- # system.parts -包含有关 [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) 表部分的信息。 +包含有关 [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) 表的分片的信息。 -每一行描述一个数据部分。 +每一行描述一个数据分片。 列: -- `partition` ([String](../../sql-reference/data-types/string.md)) – 分区名称。要了解什么是分区,请参阅 [ALTER](/sql-reference/statements/alter) 查询的描述。 +- `partition` ([String](../../sql-reference/data-types/string.md)) – 分区名称。要了解什么是分区,请参见 [ALTER](/sql-reference/statements/alter) 查询的描述。 格式: - - `YYYYMM` 用于按月自动分区。 - - `any_string` 在手动分区时。 + - `YYYYMM` 用于按月自动分区。 + - `any_string` 手动分区时使用。 -- `name` ([String](../../sql-reference/data-types/string.md)) – 数据部分名称。部分命名结构可用于确定数据、摄取和合并模式的许多方面。部分命名格式如下: +- `name` ([String](../../sql-reference/data-types/string.md)) – 数据分片的名称。分片命名结构可以用于确定数据、摄取和合并模式的许多方面。分片命名格式如下: ```text ____ ``` * 定义: - - `partition_id` - 标识分区键 - - `minimum_block_number` - 标识部分中的最小区块编号。 ClickHouse 始终合并连续的区块 - - `maximum_block_number` - 标识部分中的最大区块编号 - - `level` - 每次额外合并时递增1。级别为0表示这是一个尚未合并的新部分。重要的是要记住,ClickHouse中的所有部分始终是不可变的 - - `data_version` - 可选值,部分发生变更时递增(再次强调,变更的数据始终仅写入新部分,因为部分是不可变的) + - `partition_id` - 标识分区键 + - `minimum_block_number` - 标识分片中的最小块编号。ClickHouse 始终合并连续块 + - `maximum_block_number` - 标识分片中的最大块编号 + - `level` - 每次对分片进行合并时加一。级别为 0 表示这是一个尚未合并的新分片。重要的是要记住,ClickHouse 中所有分片始终是不可变的 + - `data_version` - 可选值,分片发生变化时递增(同样,由于分片是不可变的,变化的数据始终只会写入新的分片) -- `uuid` ([UUID](../../sql-reference/data-types/uuid.md)) - 数据部分的 UUID。 +- `uuid` ([UUID](../../sql-reference/data-types/uuid.md)) - 数据分片的 UUID。 -- `part_type` ([String](../../sql-reference/data-types/string.md)) — 数据部分存储格式。 +- `part_type` ([String](../../sql-reference/data-types/string.md)) — 存储数据分片的格式。 可能的值: - - `Wide` — 每列在文件系统中存储在单独的文件中。 - - `Compact` — 所有列存储在文件系统中的一个文件中。 + - `Wide` — 每个列存储在文件系统中的单独文件。 + - `Compact` — 所有列存储在文件系统中的一个文件中。 数据存储格式由 [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) 表的 `min_bytes_for_wide_part` 和 `min_rows_for_wide_part` 设置控制。 -- `active` ([UInt8](../../sql-reference/data-types/int-uint.md)) – 指示数据部分是否处于活动状态的标志。如果数据部分处于活动状态,则在表中使用。否则,被删除。合并后,非活动数据部分会保留。 +- `active` ([UInt8](../../sql-reference/data-types/int-uint.md)) – 表示数据分片是否处于活动状态的标志。如果数据分片处于活动状态,则用于表中。否则,它将被删除。合并后,非活动数据分片仍然保留。 -- `marks` ([UInt64](../../sql-reference/data-types/int-uint.md)) – 标记的数量。要获取数据部分中的行数的近似值,请将 `marks` 乘以索引粒度(通常为8192)(此提示对自适应粒度不起作用)。 +- `marks` ([UInt64](../../sql-reference/data-types/int-uint.md)) – 标记的数量。要获取数据分片中行的近似数量,将 `marks` 乘以索引粒度(通常为 8192)(此提示不适用于自适应粒度)。 - `rows` ([UInt64](../../sql-reference/data-types/int-uint.md)) – 行数。 -- `bytes_on_disk` ([UInt64](../../sql-reference/data-types/int-uint.md)) – 数据部分文件的总大小(以字节为单位)。 +- `bytes_on_disk` ([UInt64](../../sql-reference/data-types/int-uint.md)) – 数据分片文件的总大小(以字节为单位)。 -- `data_compressed_bytes` ([UInt64](../../sql-reference/data-types/int-uint.md)) – 数据部分中压缩数据的总大小。所有辅助文件(例如,带有标记的文件)不包括在内。 +- `data_compressed_bytes` ([UInt64](../../sql-reference/data-types/int-uint.md)) – 数据分片中压缩数据的总大小。所有辅助文件(例如,标记文件)不包括在内。 -- `data_uncompressed_bytes` ([UInt64](../../sql-reference/data-types/int-uint.md)) – 数据部分中未压缩数据的总大小。所有辅助文件(例如,带有标记的文件)不包括在内。 +- `data_uncompressed_bytes` ([UInt64](../../sql-reference/data-types/int-uint.md)) – 数据分片中未压缩数据的总大小。所有辅助文件(例如,标记文件)不包括在内。 -- `primary_key_size` ([UInt64](../../sql-reference/data-types/int-uint.md)) – 磁盘上 primary.idx/cidx 文件中主键值所占用的内存量(以字节为单位)。 +- `primary_key_size` ([UInt64](../../sql-reference/data-types/int-uint.md)) – 主键值在主.idx/cidx 文件中占用的内存量(以字节为单位)。 -- `marks_bytes` ([UInt64](../../sql-reference/data-types/int-uint.md)) – 带有标记的文件的大小。 +- `marks_bytes` ([UInt64](../../sql-reference/data-types/int-uint.md)) – 包含标记的文件的大小。 -- `secondary_indices_compressed_bytes` ([UInt64](../../sql-reference/data-types/int-uint.md)) – 数据部分中二级索引压缩数据的总大小。所有辅助文件(例如,带有标记的文件)不包括在内。 +- `secondary_indices_compressed_bytes` ([UInt64](../../sql-reference/data-types/int-uint.md)) – 数据分片中二级索引的压缩数据的总大小。所有辅助文件(例如,标记文件)不包括在内。 -- `secondary_indices_uncompressed_bytes` ([UInt64](../../sql-reference/data-types/int-uint.md)) – 数据部分中二级索引未压缩数据的总大小。所有辅助文件(例如,带有标记的文件)不包括在内。 +- `secondary_indices_uncompressed_bytes` ([UInt64](../../sql-reference/data-types/int-uint.md)) – 数据分片中二级索引的未压缩数据的总大小。所有辅助文件(例如,标记文件)不包括在内。 - `secondary_indices_marks_bytes` ([UInt64](../../sql-reference/data-types/int-uint.md)) – 二级索引的标记文件的大小。 -- `modification_time` ([DateTime](../../sql-reference/data-types/datetime.md)) – 数据部分目录的修改时间。这通常与数据部分创建时间相对应。 +- `modification_time` ([DateTime](../../sql-reference/data-types/datetime.md)) – 数据分片目录被修改的时间。这通常对应于数据分片创建的时间。 -- `remove_time` ([DateTime](../../sql-reference/data-types/datetime.md)) – 数据部分变为非活动状态的时间。 +- `remove_time` ([DateTime](../../sql-reference/data-types/datetime.md)) – 数据分片变为非活动状态的时间。 -- `refcount` ([UInt32](../../sql-reference/data-types/int-uint.md)) – 数据部分被使用的地方数量。值大于2表示数据部分在查询或合并中被使用。 +- `refcount` ([UInt32](../../sql-reference/data-types/int-uint.md)) – 数据分片使用的场所数量。大于 2 的值表示数据分片用于查询或合并。 -- `min_date` ([Date](../../sql-reference/data-types/date.md)) – 数据部分中日期键的最小值。 +- `min_date` ([Date](../../sql-reference/data-types/date.md)) – 数据分片中日期键的最小值。 -- `max_date` ([Date](../../sql-reference/data-types/date.md)) – 数据部分中日期键的最大值。 +- `max_date` ([Date](../../sql-reference/data-types/date.md)) – 数据分片中日期键的最大值。 -- `min_time` ([DateTime](../../sql-reference/data-types/datetime.md)) – 数据部分中日期和时间键的最小值。 +- `min_time` ([DateTime](../../sql-reference/data-types/datetime.md)) – 数据分片中日期和时间键的最小值。 -- `max_time` ([DateTime](../../sql-reference/data-types/datetime.md)) – 数据部分中日期和时间键的最大值。 +- `max_time` ([DateTime](../../sql-reference/data-types/datetime.md)) – 数据分片中日期和时间键的最大值。 -- `partition_id` ([String](../../sql-reference/data-types/string.md)) – 分区 ID。 +- `partition_id` ([String](../../sql-reference/data-types/string.md)) – 分区的 ID。 -- `min_block_number` ([UInt64](../../sql-reference/data-types/int-uint.md)) – 合并后构成当前部分的最小数据块编号。 +- `min_block_number` ([UInt64](../../sql-reference/data-types/int-uint.md)) – 合并后组成当前分片的最小数据块编号。 -- `max_block_number` ([UInt64](../../sql-reference/data-types/int-uint.md)) – 合并后构成当前部分的最大数据块编号。 +- `max_block_number` ([UInt64](../../sql-reference/data-types/int-uint.md)) – 合并后组成当前分片的最大数据块编号。 -- `level` ([UInt32](../../sql-reference/data-types/int-uint.md)) – 合并树的深度。零意味着当前部分是通过插入创建的,而不是通过合并其他部分。 +- `level` ([UInt32](../../sql-reference/data-types/int-uint.md)) – 合并树的深度。零表示当前分片是通过插入创建的,而不是通过合并其他分片。 -- `data_version` ([UInt64](../../sql-reference/data-types/int-uint.md)) – 用于确定应应用于数据部分的变更的版本号(版本高于 `data_version` 的变更)。 +- `data_version` ([UInt64](../../sql-reference/data-types/int-uint.md)) – 用于确定应应用于数据分片的变更的数字(变更的版本高于 `data_version`)。 -- `primary_key_bytes_in_memory` ([UInt64](../../sql-reference/data-types/int-uint.md)) – 主键值使用的内存量(以字节为单位)。 +- `primary_key_bytes_in_memory` ([UInt64](../../sql-reference/data-types/int-uint.md)) – 占用的主键值内存量(以字节为单位)(在 `primary_key_lazy_load=1` 和 `use_primary_key_cache=1` 的情况下将为 `0`)。 -- `primary_key_bytes_in_memory_allocated` ([UInt64](../../sql-reference/data-types/int-uint.md)) – 为主键值保留的内存量(以字节为单位)。 +- `primary_key_bytes_in_memory_allocated` ([UInt64](../../sql-reference/data-types/int-uint.md)) – 为主键值分配的内存量(以字节为单位)(在 `primary_key_lazy_load=1` 和 `use_primary_key_cache=1` 的情况下将为 `0`)。 -- `is_frozen` ([UInt8](../../sql-reference/data-types/int-uint.md)) – 表示存在分区数据备份的标志。1表示备份存在。0表示备份不存在。有关更多细节,请参见 [FREEZE PARTITION](/sql-reference/statements/alter/partition#freeze-partition) +- `is_frozen` ([UInt8](../../sql-reference/data-types/int-uint.md)) – 表示存在分区数据备份的标志。1,备份存在。0,备份不存在。有关更多详细信息,请参见 [FREEZE PARTITION](/sql-reference/statements/alter/partition#freeze-partition) - `database` ([String](../../sql-reference/data-types/string.md)) – 数据库名称。 - `table` ([String](../../sql-reference/data-types/string.md)) – 表名称。 -- `engine` ([String](../../sql-reference/data-types/string.md)) – 表引擎名称(不带参数)。 +- `engine` ([String](../../sql-reference/data-types/string.md)) – 没有参数的表引擎名称。 -- `path` ([String](../../sql-reference/data-types/string.md)) – 数据部分文件夹的绝对路径。 +- `path` ([String](../../sql-reference/data-types/string.md)) – 数据分片文件夹的绝对路径。 -- `disk_name` ([String](../../sql-reference/data-types/string.md)) – 存储数据部分的磁盘名称。 +- `disk_name` ([String](../../sql-reference/data-types/string.md)) – 存储数据分片的磁盘名称。 -- `hash_of_all_files` ([String](../../sql-reference/data-types/string.md)) – [sipHash128](/sql-reference/functions/hash-functions#siphash128) 的压缩文件的哈希值。 +- `hash_of_all_files` ([String](../../sql-reference/data-types/string.md)) – [sipHash128](/sql-reference/functions/hash-functions#sipHash128) 的压缩文件的哈希值。 -- `hash_of_uncompressed_files` ([String](../../sql-reference/data-types/string.md)) – [sipHash128](/sql-reference/functions/hash-functions#siphash128) 的未压缩文件(带有标记的文件、索引文件等)的哈希值。 +- `hash_of_uncompressed_files` ([String](../../sql-reference/data-types/string.md)) – [sipHash128](/sql-reference/functions/hash-functions#sipHash128) 的未压缩文件的哈希值(标记文件、索引文件等)。 -- `uncompressed_hash_of_compressed_files` ([String](../../sql-reference/data-types/string.md)) – 异常情况下就像未压缩的数据的 [sipHash128](/sql-reference/functions/hash-functions#siphash128) 的压缩文件。 +- `uncompressed_hash_of_compressed_files` ([String](../../sql-reference/data-types/string.md)) – [sipHash128](/sql-reference/functions/hash-functions#sipHash128) 的压缩文件数据如同未压缩。 - `delete_ttl_info_min` ([DateTime](../../sql-reference/data-types/datetime.md)) — [TTL DELETE 规则](../../engines/table-engines/mergetree-family/mergetree.md/#table_engine-mergetree-ttl) 的日期和时间键的最小值。 @@ -122,7 +123,7 @@ - `move_ttl_info.expression` ([Array](../../sql-reference/data-types/array.md)([String](../../sql-reference/data-types/string.md))) — 表达式数组。每个表达式定义一个 [TTL MOVE 规则](../../engines/table-engines/mergetree-family/mergetree.md/#table_engine-mergetree-ttl)。 :::note -`move_ttl_info.expression` 数组主要用于向后兼容,现在检查 `TTL MOVE` 规则的最简单方法是使用 `move_ttl_info.min` 和 `move_ttl_info.max` 字段。 +`move_ttl_info.expression` 数组主要出于向后兼容性而保留,现在检查 `TTL MOVE` 规则的最简单方法是使用 `move_ttl_info.min` 和 `move_ttl_info.max` 字段。 ::: - `move_ttl_info.min` ([Array](../../sql-reference/data-types/array.md)([DateTime](../../sql-reference/data-types/datetime.md))) — 日期和时间值数组。每个元素描述一个 [TTL MOVE 规则](../../engines/table-engines/mergetree-family/mergetree.md/#table_engine-mergetree-ttl) 的最小键值。 @@ -185,7 +186,7 @@ move_ttl_info.min: [] move_ttl_info.max: [] ``` -**另见** +**另请参见** - [MergeTree 家族](../../engines/table-engines/mergetree-family/mergetree.md) - [列和表的 TTL](../../engines/table-engines/mergetree-family/mergetree.md/#table_engine-mergetree-ttl) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/parts.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/parts.md.hash index 4842c58dcc7..e694c349f7a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/parts.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/parts.md.hash @@ -1 +1 @@ -68c292b5c2042328 +177ca753030e9410 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/parts_columns.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/parts_columns.md index caac68906b1..ace5404e250 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/parts_columns.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/parts_columns.md @@ -1,96 +1,97 @@ --- -'description': '系统表包含有关MergeTree表的分区片段和列的信息。' +'description': '系统表,包含MergeTree表的分区片段和列的信息。' 'keywords': - 'system table' - 'parts_columns' 'slug': '/operations/system-tables/parts_columns' 'title': 'system.parts_columns' +'doc_type': 'reference' --- # system.parts_columns -包含关于[MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) 表的分片和列的信息。 +包含有关 [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) 表的部分和列的信息。 -每一行描述一个数据分片。 +每一行描述一个数据部分。 -列: +列: -- `partition` ([String](../../sql-reference/data-types/string.md)) — 分区名称。要了解什么是分区,请参见[ALTER](/sql-reference/statements/alter) 查询的描述。 +- `partition` ([String](../../sql-reference/data-types/string.md)) — 分区名称。要了解分区是什么,请参见 [ALTER](/sql-reference/statements/alter) 查询的描述。 格式: - - `YYYYMM` 表示按月自动分区。 - - `any_string` 表示手动分区。 + - `YYYYMM` 用于按月自动分区。 + - `any_string` 用于手动分区。 -- `name` ([String](../../sql-reference/data-types/string.md)) — 数据分片的名称。 +- `name` ([String](../../sql-reference/data-types/string.md)) — 数据部分的名称。 -- `part_type` ([String](../../sql-reference/data-types/string.md)) — 数据分片存储格式。 +- `part_type` ([String](../../sql-reference/data-types/string.md)) — 存储数据部分的格式。 可能的值: - - `Wide` — 每一列存储在文件系统中的单独文件中。 - - `Compact` — 所有列存储在文件系统中的一个文件中。 + - `Wide` — 每列在文件系统中的一个独立文件中存储。 + - `Compact` — 所有列在文件系统中的一个文件中存储。 - 数据存储格式由[MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) 表的 `min_bytes_for_wide_part` 和 `min_rows_for_wide_part` 设置控制。 + 数据存储格式由 [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) 表的 `min_bytes_for_wide_part` 和 `min_rows_for_wide_part` 设置控制。 -- `active` ([UInt8](../../sql-reference/data-types/int-uint.md)) — 指示数据分片是否处于活动状态的标志。如果数据分片处于活动状态,它将被用于表中。否则,将被删除。在合并后,非活动的数据分片仍然存在。 +- `active` ([UInt8](../../sql-reference/data-types/int-uint.md)) — 表示数据部分是否处于活动状态的标志。如果数据部分处于活动状态,则用于表中。否则,将被删除。在合并后,非活动数据部分仍然存在。 -- `marks` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 标记的数量。要获得数据分片中大致的行数,请将 `marks` 乘以索引粒度(通常为 8192)(此提示不适用于自适应粒度)。 +- `marks` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 标记的数量。要获取数据部分中的大致行数,请将 `marks` 乘以索引粒度(通常是 8192)(此提示不适用于自适应粒度)。 - `rows` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 行数。 -- `bytes_on_disk` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 数据分片文件的总大小(以字节为单位)。 +- `bytes_on_disk` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 所有数据部分文件的总大小(以字节为单位)。 -- `data_compressed_bytes` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 数据分片中压缩数据的总大小。所有辅助文件(例如,带有标记的文件)不包括在内。 +- `data_compressed_bytes` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 数据部分中压缩数据的总大小。所有辅助文件(例如,标记文件)不包括在内。 -- `data_uncompressed_bytes` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 数据分片中未压缩数据的总大小。所有辅助文件(例如,带有标记的文件)不包括在内。 +- `data_uncompressed_bytes` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 数据部分中未压缩数据的总大小。所有辅助文件(例如,标记文件)不包括在内。 -- `marks_bytes` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 带有标记的文件的大小。 +- `marks_bytes` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 标记文件的大小。 -- `modification_time` ([DateTime](../../sql-reference/data-types/datetime.md)) — 数据分片目录的修改时间。这通常对应于数据分片创建的时间。 +- `modification_time` ([DateTime](../../sql-reference/data-types/datetime.md)) — 数据部分目录修改的时间。这通常对应于数据部分创建的时间。 -- `remove_time` ([DateTime](../../sql-reference/data-types/datetime.md)) — 数据分片变为非活动状态的时间。 +- `remove_time` ([DateTime](../../sql-reference/data-types/datetime.md)) — 数据部分变为非活动状态的时间。 -- `refcount` ([UInt32](../../sql-reference/data-types/int-uint.md)) — 数据分片使用的位置数量。大于 2 的值表示数据分片在查询或合并中被使用。 +- `refcount` ([UInt32](../../sql-reference/data-types/int-uint.md)) — 数据部分使用的位置数量。大于 2 的值表示数据部分在查询或合并中使用。 -- `min_date` ([Date](../../sql-reference/data-types/date.md)) — 数据分片中日期键的最小值。 +- `min_date` ([Date](../../sql-reference/data-types/date.md)) — 数据部分中日期键的最小值。 -- `max_date` ([Date](../../sql-reference/data-types/date.md)) — 数据分片中日期键的最大值。 +- `max_date` ([Date](../../sql-reference/data-types/date.md)) — 数据部分中日期键的最大值。 -- `partition_id` ([String](../../sql-reference/data-types/string.md)) — 分区 ID。 +- `partition_id` ([String](../../sql-reference/data-types/string.md)) — 分区的 ID。 -- `min_block_number` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 合并后当前分片所组成的数据分片的最小数量。 +- `min_block_number` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 合并后构成当前部分的数据部分的最小数量。 -- `max_block_number` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 合并后当前分片所组成的数据分片的最大数量。 +- `max_block_number` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 合并后构成当前部分的数据部分的最大数量。 -- `level` ([UInt32](../../sql-reference/data-types/int-uint.md)) — 合并树的深度。零表示当前分片是通过插入创建的而不是通过合并其他分片创建的。 +- `level` ([UInt32](../../sql-reference/data-types/int-uint.md)) — 合并树的深度。零表示当前部分是通过插入创建,而不是通过合并其他部分。 -- `data_version` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 用于确定哪些变更应应用于数据分片的数字(版本高于 `data_version` 的变更)。 +- `data_version` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 用于确定应应用于数据部分的哪些变更(版本高于 `data_version` 的变更)。 -- `primary_key_bytes_in_memory` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 主键值使用的内存量(以字节为单位)。 +- `primary_key_bytes_in_memory` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 主键值占用的内存量(以字节为单位)。 - `primary_key_bytes_in_memory_allocated` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 为主键值保留的内存量(以字节为单位)。 -- `database` ([String](../../sql-reference/data-types/string.md)) — 数据库的名称。 +- `database` ([String](../../sql-reference/data-types/string.md)) — 数据库名称。 -- `table` ([String](../../sql-reference/data-types/string.md)) — 表的名称。 +- `table` ([String](../../sql-reference/data-types/string.md)) — 表名称。 -- `engine` ([String](../../sql-reference/data-types/string.md)) — 表引擎的名称,不带参数。 +- `engine` ([String](../../sql-reference/data-types/string.md)) — 不带参数的表引擎名称。 -- `disk_name` ([String](../../sql-reference/data-types/string.md)) — 存储数据分片的磁盘名称。 +- `disk_name` ([String](../../sql-reference/data-types/string.md)) — 存储数据部分的磁盘名称。 -- `path` ([String](../../sql-reference/data-types/string.md)) — 包含数据分片文件的文件夹的绝对路径。 +- `path` ([String](../../sql-reference/data-types/string.md)) — 数据部分文件夹的绝对路径。 -- `column` ([String](../../sql-reference/data-types/string.md)) — 列的名称。 +- `column` ([String](../../sql-reference/data-types/string.md)) — 列名称。 - `type` ([String](../../sql-reference/data-types/string.md)) — 列类型。 -- `column_position` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 列在表中的序号,从 1 开始。 +- `column_position` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 从 1 开始的列在表中的顺序位置。 -- `default_kind` ([String](../../sql-reference/data-types/string.md)) — 默认值的表达式类型(`DEFAULT`,`MATERIALIZED`,`ALIAS`),如果未定义,则为空字符串。 +- `default_kind` ([String](../../sql-reference/data-types/string.md)) — 默认值的表达式类型(`DEFAULT`,`MATERIALIZED`,`ALIAS`),如果未定义则为空字符串。 -- `default_expression` ([String](../../sql-reference/data-types/string.md)) — 默认值的表达式,如果未定义,则为空字符串。 +- `default_expression` ([String](../../sql-reference/data-types/string.md)) — 默认值的表达式,如果未定义则为空字符串。 - `column_bytes_on_disk` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 列的总大小(以字节为单位)。 @@ -98,7 +99,7 @@ - `column_data_uncompressed_bytes` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 列中未压缩数据的总大小(以字节为单位)。 -- `column_marks_bytes` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 带有标记的列的大小(以字节为单位)。 +- `column_marks_bytes` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 包含标记的列的大小(以字节为单位)。 - `bytes` ([UInt64](../../sql-reference/data-types/int-uint.md)) — `bytes_on_disk` 的别名。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/parts_columns.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/parts_columns.md.hash index 5eb8d8c148d..7eaea0e7c5e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/parts_columns.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/parts_columns.md.hash @@ -1 +1 @@ -6a8aec81fed552ae +714cb03d464b409d diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/processes.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/processes.md index 7f4f1f65063..59c91cc88d9 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/processes.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/processes.md @@ -5,6 +5,7 @@ - 'processes' 'slug': '/operations/system-tables/processes' 'title': 'system.processes' +'doc_type': 'reference' --- import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_system_table_cloud.md'; @@ -18,17 +19,17 @@ import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/curre 列: -- `user` (String) – 发起查询的用户。请注意,对于分布式处理,查询是以 `default` 用户的身份发送到远程服务器的。该字段包含特定查询的用户名,而不是该查询所启动的查询的用户名。 -- `address` (String) – 请求发起时的 IP 地址。分布式处理同样适用。要跟踪分布式查询最初是从哪里发起的,请查看查询请求者服务器上的 `system.processes` 。 -- `elapsed` (Float64) – 自请求执行开始以来经过的时间(以秒为单位)。 -- `read_rows` (UInt64) – 从表中读取的行数。对于分布式处理,在请求者服务器上,这是所有远程服务器的总和。 -- `read_bytes` (UInt64) – 从表中读取的未压缩字节数。对于分布式处理,在请求者服务器上,这是所有远程服务器的总和。 -- `total_rows_approx` (UInt64) – 应该读取的总行数的估算。对于分布式处理,在请求者服务器上,这是所有远程服务器的总和。在请求处理期间,当新源被确定需要处理时,这个值可能会被更新。 -- `memory_usage` (Int64) – 请求使用的 RAM 量。它可能不包括某些类型的专用内存。请参见 [max_memory_usage](/operations/settings/settings#max_memory_usage) 设置。 -- `query` (String) – 查询文本。对于 `INSERT`,它不包括待插入的数据。 +- `user` (String) – 执行查询的用户。请记住,对于分布式处理,查询是以 `default` 用户的身份发送到远程服务器的。该字段包含特定查询的用户名,而不是此查询发起的查询的用户名。 +- `address` (String) – 请求发起的 IP 地址。分布式处理时相同。要追踪分布式查询最初是从哪里发起的,请查看查询请求者服务器上的 `system.processes`。 +- `elapsed` (Float64) – 从请求执行开始到现在的时间(以秒为单位)。 +- `read_rows` (UInt64) – 从表中读取的行数。对于分布式处理,在请求者服务器上,这对应于所有远程服务器的总和。 +- `read_bytes` (UInt64) – 从表中读取的未压缩字节数。对于分布式处理,在请求者服务器上,这对应于所有远程服务器的总和。 +- `total_rows_approx` (UInt64) – 应该读取的总行数的近似值。对于分布式处理,在请求者服务器上,这对应于所有远程服务器的总和。在请求处理期间,当新的待处理源变得可知时,它可能会被更新。 +- `memory_usage` (Int64) – 请求使用的 RAM 量。可能不包括某些类型的专用内存。请参见 [max_memory_usage](/operations/settings/settings#max_memory_usage) 设置。 +- `query` (String) – 查询文本。对于 `INSERT`,它不包括要插入的数据。 - `query_id` (String) – 查询 ID(如果已定义)。 - `is_cancelled` (UInt8) – 查询是否被取消。 -- `is_all_data_sent` (UInt8) – 所有数据是否已发送到客户端(换句话说,查询在服务器上已完成)。 +- `is_all_data_sent` (UInt8) – 是否已将所有数据发送到客户端(换句话说,查询已在服务器上完成)。 ```sql SELECT * FROM system.processes LIMIT 10 FORMAT Vertical; diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/processes.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/processes.md.hash index 9ca22684bd7..770ee8a4929 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/processes.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/processes.md.hash @@ -1 +1 @@ -845f895a6a7f9243 +65b7005b8374203c diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/processors_profile_log.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/processors_profile_log.md index ace0c5c09a4..68314d80b2b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/processors_profile_log.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/processors_profile_log.md @@ -1,11 +1,12 @@ --- -'description': '系统表包含关于处理器级别的分析信息(可以在 `EXPLAIN PIPELINE` 中找到)' +'description': '系统表包含处理器级别的性能分析信息(可以在 `EXPLAIN PIPELINE` 中找到)' 'keywords': - 'system table' - 'processors_profile_log' - 'EXPLAIN PIPELINE' 'slug': '/operations/system-tables/processors_profile_log' 'title': 'system.processors_profile_log' +'doc_type': 'reference' --- import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_system_table_cloud.md'; @@ -15,28 +16,28 @@ import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/curre -该表包含处理器级别的分析信息(可以在 [`EXPLAIN PIPELINE`](../../sql-reference/statements/explain.md#explain-pipeline) 中找到该信息)。 +此表包含处理器级别的分析(可在 [`EXPLAIN PIPELINE`](../../sql-reference/statements/explain.md#explain-pipeline)中找到)。 列: - `hostname` ([LowCardinality(String)](../../sql-reference/data-types/string.md)) — 执行查询的服务器的主机名。 - `event_date` ([Date](../../sql-reference/data-types/date.md)) — 事件发生的日期。 - `event_time` ([DateTime](../../sql-reference/data-types/datetime.md)) — 事件发生的日期和时间。 -- `event_time_microseconds` ([DateTime64](../../sql-reference/data-types/datetime64.md)) — 事件发生时的微秒精度的日期和时间。 -- `id` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 处理器的 ID -- `parent_ids` ([Array(UInt64)](../../sql-reference/data-types/array.md)) — 父处理器的 IDs -- `plan_step` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 创建该处理器的查询计划步骤的 ID。如果处理器不是从任何步骤添加的,则该值为零。 -- `plan_group` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 如果处理器是由查询计划步骤创建的,则为处理器的组。组是从同一查询计划步骤添加的处理器的逻辑分区。组仅用于美化 EXPLAIN PIPELINE 结果。 +- `event_time_microseconds` ([DateTime64](../../sql-reference/data-types/datetime64.md)) — 事件发生的日期和时间(精确到微秒)。 +- `id` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 处理器的 ID。 +- `parent_ids` ([Array(UInt64)](../../sql-reference/data-types/array.md)) — 上级处理器的 IDs。 +- `plan_step` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 创建此处理器的查询计划步骤的 ID。如果处理器不是从任何步骤添加,则值为零。 +- `plan_group` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 如果处理器是由查询计划步骤创建,则为处理器的组。组是从相同查询计划步骤添加的处理器的逻辑分区。组仅用于美化 EXPLAIN PIPELINE 结果的输出。 - `initial_query_id` ([String](../../sql-reference/data-types/string.md)) — 初始查询的 ID(用于分布式查询执行)。 -- `query_id` ([String](../../sql-reference/data-types/string.md)) — 查询的 ID +- `query_id` ([String](../../sql-reference/data-types/string.md)) — 查询的 ID。 - `name` ([LowCardinality(String)](../../sql-reference/data-types/lowcardinality.md)) — 处理器的名称。 -- `elapsed_us` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 该处理器执行的微秒数。 -- `input_wait_elapsed_us` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 该处理器等待数据(来自其他处理器)的微秒数。 -- `output_wait_elapsed_us` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 该处理器因输出端口已满而等待的微秒数。 -- `input_rows` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 被处理器消耗的行数。 -- `input_bytes` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 被处理器消耗的字节数。 -- `output_rows` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 由处理器生成的行数。 -- `output_bytes` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 由处理器生成的字节数。 +- `elapsed_us` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 此处理器执行的微秒数。 +- `input_wait_elapsed_us` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 此处理器等待数据(来自其他处理器)的微秒数。 +- `output_wait_elapsed_us` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 此处理器因输出端口已满而等待的微秒数。 +- `input_rows` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 处理器消费的行数。 +- `input_bytes` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 处理器消费的字节数。 +- `output_rows` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 处理器生成的行数。 +- `output_bytes` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 处理器生成的字节数。 **示例** 查询: @@ -83,12 +84,12 @@ ORDER BY name ASC └─────────────────────────┴────────────┴───────────────────────┴────────────────────────┘ ``` -在这里你可以看到: +在这里您可以看到: -- `ExpressionTransform` 正在执行 `sleep(1)` 函数,因此它的 `work` 将耗时 1e6,所以 `elapsed_us` > 1e6。 -- `SourceFromSingleChunk` 需要等待,因为 `ExpressionTransform` 在执行 `sleep(1)` 时不接受任何数据,因此它将处于 `PortFull` 状态 1e6 微秒,因此 `output_wait_elapsed_us` > 1e6。 -- `LimitsCheckingTransform`/`NullSource`/`LazyOutputFormat` 需要等待,直到 `ExpressionTransform` 执行 `sleep(1)` 来处理结果,因此 `input_wait_elapsed_us` > 1e6。 +- `ExpressionTransform` 正在执行 `sleep(1)` 函数,因此它的 `work` 将消耗 1e6 微秒,所以 `elapsed_us` > 1e6。 +- `SourceFromSingleChunk` 需要等待,因为 `ExpressionTransform` 在执行 `sleep(1)` 时不接受任何数据,因此它将在 `PortFull` 状态下等待 1e6 微秒,因此 `output_wait_elapsed_us` > 1e6。 +- `LimitsCheckingTransform`/`NullSource`/`LazyOutputFormat` 需要等待直到 `ExpressionTransform` 执行 `sleep(1)` 以处理结果,因此 `input_wait_elapsed_us` > 1e6。 -**另见** +**参见** - [`EXPLAIN PIPELINE`](../../sql-reference/statements/explain.md#explain-pipeline) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/processors_profile_log.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/processors_profile_log.md.hash index 4e653d5d5a5..733f8eb77ae 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/processors_profile_log.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/processors_profile_log.md.hash @@ -1 +1 @@ -7cba132ef84c617f +120a32b3c19352ee diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/projection_parts.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/projection_parts.md new file mode 100644 index 00000000000..f65f4cfad4d --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/projection_parts.md @@ -0,0 +1,82 @@ +--- +'description': '系统表包含关于 MergeTree 家族表的投影部分的信息。' +'keywords': +- 'system table' +- 'projection_parts' +'slug': '/operations/system-tables/projection_parts' +'title': 'system.projection_parts' +'doc_type': 'reference' +--- + + +# system.projection_parts + +此表包含有关 MergeTree 家族表的投影部分的信息。 + +## Columns {#columns} + +| Column | Description | Type | +|-----------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------| +| `partition` | 分区名称。 | String | +| `name` | 数据部分的名称。 | String | +| `part_type` | 数据部分存储格式。可能值:宽格式(每列一个文件)和紧凑格式(所有列一个文件)。 | String | +| `parent_name` | 源(父)数据部分的名称。 | String | +| `parent_uuid` | 源(父)数据部分的 UUID。 | UUID | +| `parent_part_type` | 源(父)数据部分存储格式。 | String | +| `active` | 指示数据部分是否处于活动状态的标志。如果数据部分是活动的,则它在一个表中使用。否则,它即将被删除。非活动数据部分在合并和变更操作后出现。 | UInt8 | +| `marks` | 标记数量。要获取数据部分中近似的行数,请将标记乘以索引粒度(通常为 8192)(此提示不适用于自适应粒度)。 | UInt64 | +| `rows` | 行数。 | UInt64 | +| `bytes_on_disk` | 所有数据部分文件的总大小(以字节为单位)。 | UInt64 | +| `data_compressed_bytes` | 数据部分中压缩数据的总大小。所有辅助文件(例如,标记文件)不包括在内。 | UInt64 | +| `data_uncompressed_bytes` | 数据部分中未压缩数据的总大小。所有辅助文件(例如,标记文件)不包括在内。 | UInt64 | +| `marks_bytes` | 包含标记的文件的大小。 | UInt64 | +| `parent_marks` | 源(父)部分中的标记数量。 | UInt64 | +| `parent_rows` | 源(父)部分中的行数。 | UInt64 | +| `parent_bytes_on_disk` | 所有源(父)数据部分文件的总大小(以字节为单位)。 | UInt64 | +| `parent_data_compressed_bytes` | 源(父)数据部分中压缩数据的总大小。 | UInt64 | +| `parent_data_uncompressed_bytes` | 源(父)数据部分中未压缩数据的总大小。 | UInt64 | +| `parent_marks_bytes` | 源(父)数据部分中包含标记的文件的大小。 | UInt64 | +| `modification_time` | 数据部分目录的修改时间。这通常对应于数据部分创建的时间。 | DateTime | +| `remove_time` | 数据部分变为非活动状态的时间。 | DateTime | +| `refcount` | 数据部分使用的地方数量。大于 2 的值表示数据部分在查询或合并中被使用。 | UInt32 | +| `min_date` | 数据部分中日期键的最小值。 | Date | +| `max_date` | 数据部分中日期键的最大值。 | Date | +| `min_time` | 数据部分中日期和时间键的最小值。 | DateTime | +| `max_time` | 数据部分中日期和时间键的最大值。 | DateTime | +| `partition_id` | 分区的 ID。 | String | +| `min_block_number` | 合并后构成当前部分的数据部分的最小数量。 | Int64 | +| `max_block_number` | 合并后构成当前部分的数据部分的最大数量。 | Int64 | +| `level` | 合并树的深度。零表示当前部分是由插入而不是通过合并其他部分创建的。 | UInt32 | +| `data_version` | 用于确定哪些变更应应用于数据部分的编号(版本高于 data_version 的变更)。 | UInt64 | +| `primary_key_bytes_in_memory` | 主键值使用的内存量(以字节为单位)。 | UInt64 | +| `primary_key_bytes_in_memory_allocated` | 为主键值保留的内存量(以字节为单位)。 | UInt64 | +| `is_frozen` | 表示分区数据备份是否存在的标志。1,备份存在。0,备份不存在。 | UInt8 | +| `database` | 数据库名称。 | String | +| `table` | 表名称。 | String | +| `engine` | 表引擎的名称(不含参数)。 | String | +| `disk_name` | 存储数据部分的磁盘名称。 | String | +| `path` | 数据部分文件的文件夹的绝对路径。 | String | +| `hash_of_all_files` | 压缩文件的 sipHash128。 | String | +| `hash_of_uncompressed_files` | 未压缩文件的 sipHash128(带标记的文件、索引文件等)。 | String | +| `uncompressed_hash_of_compressed_files` | 压缩文件中数据的 sipHash128,就像它们是未压缩的一样。 | String | +| `delete_ttl_info_min` | TTL DELETE 规则的日期和时间键的最小值。 | DateTime | +| `delete_ttl_info_max` | TTL DELETE 规则的日期和时间键的最大值。 | DateTime | +| `move_ttl_info.expression` | 表达式数组。每个表达式定义一个 TTL MOVE 规则。 | Array(String) | +| `move_ttl_info.min` | 日期和时间值数组。每个元素描述 TTL MOVE 规则的最小键值。 | Array(DateTime) | +| `move_ttl_info.max` | 日期和时间值数组。每个元素描述 TTL MOVE 规则的最大键值。 | Array(DateTime) | +| `default_compression_codec` | 用于压缩此数据部分的编解码器的名称(当列没有显式编解码器时)。 | String | +| `recompression_ttl_info.expression` | TTL 表达式。 | Array(String) | +| `recompression_ttl_info.min` | 本部分内计算的 TTL 表达式的最小值。用于了解我们是否至少有一行具有过期的 TTL。 | Array(DateTime) | +| `recompression_ttl_info.max` | 本部分内计算的 TTL 表达式的最大值。用于了解我们是否所有行都具有过期的 TTL。 | Array(DateTime) | +| `group_by_ttl_info.expression` | TTL 表达式。 | Array(String) | +| `group_by_ttl_info.min` | 本部分内计算的 TTL 表达式的最小值。用于了解我们是否至少有一行具有过期的 TTL。 | Array(DateTime) | +| `group_by_ttl_info.max` | 本部分内计算的 TTL 表达式的最大值。用于了解我们是否所有行都具有过期的 TTL。 | Array(DateTime) | +| `rows_where_ttl_info.expression` | TTL 表达式。 | Array(String) | +| `rows_where_ttl_info.min` | 本部分内计算的 TTL 表达式的最小值。用于了解我们是否至少有一行具有过期的 TTL。 | Array(DateTime) | +| `rows_where_ttl_info.max` | 本部分内计算的 TTL 表达式的最大值。用于了解我们是否所有行都具有过期的 TTL。 | Array(DateTime) | +| `is_broken` | 投影部分是否损坏。 | UInt8 | +| `exception_code` | 说明投影部分损坏状态的异常消息。 | Int32 | +| `exception` | 说明投影部分损坏状态的异常代码。 | String | +| `bytes` | bytes_on_disk 的别名。 | UInt64 | +| `marks_size` | marks_bytes 的别名。 | UInt64 | +| `part_name` | name 的别名。 | String | | ALIAS | name | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/projection_parts.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/projection_parts.md.hash new file mode 100644 index 00000000000..f511b1e2515 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/projection_parts.md.hash @@ -0,0 +1 @@ +e3c92626b90db7ac diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/projection_parts_columns.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/projection_parts_columns.md new file mode 100644 index 00000000000..5351a8a3067 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/projection_parts_columns.md @@ -0,0 +1,70 @@ +--- +'description': '系统表包含关于 MergeTree 系列表投影部分列的信息' +'keywords': +- 'system table' +- 'projection_parts_columns' +'slug': '/operations/system-tables/projection_parts_columns' +'title': 'system.projection_parts_columns' +'doc_type': 'reference' +--- + + +# system.projection_parts_columns + +该表包含有关 MergeTree 家族表的投影部分中列的信息。 + +## Columns {#columns} + +| Column | Description | Type | +|-----------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------|--------------------| +| `partition` | 分区名称。 | String | +| `name` | 数据部分的名称。 | String | +| `part_type` | 存储数据部分的格式。 | String | +| `parent_name` | 源(父)数据部分的名称。 | String | +| `parent_uuid` | 源(父)数据部分的 UUID。 | UUID | +| `parent_part_type` | 源(父)数据部分的存储格式。 | String | +| `active` | 表示数据部分是否处于活动状态的标志 | UInt8 | +| `marks` | 标记数量。 | UInt64 | +| `rows` | 行数。 | UInt64 | +| `bytes_on_disk` | 所有数据部分文件的总大小(以字节为单位)。 | UInt64 | +| `data_compressed_bytes` | 数据部分中压缩数据的总大小。所有辅助文件(例如,标记文件)不包括在内。 | UInt64 | +| `data_uncompressed_bytes` | 数据部分中未压缩数据的总大小。所有辅助文件(例如,标记文件)不包括在内。 | UInt64 | +| `marks_bytes` | 带有标记的文件的大小。 | UInt64 | +| `parent_marks` | 源(父)部分中的标记数量。 | UInt64 | +| `parent_rows` | 源(父)部分中的行数。 | UInt64 | +| `parent_bytes_on_disk` | 所有源(父)数据部分文件的总大小(以字节为单位)。 | UInt64 | +| `parent_data_compressed_bytes` | 源(父)数据部分中压缩数据的总大小。 | UInt64 | +| `parent_data_uncompressed_bytes` | 源(父)数据部分中未压缩数据的总大小。 | UInt64 | +| `parent_marks_bytes` | 源(父)数据部分中带有标记的文件的大小。 | UInt64 | +| `modification_time` | 数据部分目录被修改的时间。这通常与数据部分创建时间相对应。 | DateTime | +| `remove_time` | 数据部分变为非活动状态的时间。 | DateTime | +| `refcount` | 使用数据部分的位置数量。大于 2 的值表示数据部分在查询或合并中被使用。 | UInt32 | +| `min_date` | 如果该值包含在分区键中,则为日期列的最小值。 | Date | +| `max_date` | 如果该值包含在分区键中,则为日期列的最大值。 | Date | +| `min_time` | 如果该值包含在分区键中,则为日期时间列的最小值。 | DateTime | +| `max_time` | 如果该值包含在分区键中,则为日期时间列的最大值。 | DateTime | +| `partition_id` | 分区的 ID。 | String | +| `min_block_number` | 合并后组成当前部分的数据部分的最小数量。 | Int64 | +| `max_block_number` | 合并后组成当前部分的数据部分的最大数量。 | Int64 | +| `level` | 合并树的深度。零表示当前部分是通过插入而不是通过合并其他部分创建的。 | UInt32 | +| `data_version` | 用于确定哪些变更应该应用于数据部分的号码(版本高于 data_version 的变更)。 | UInt64 | +| `primary_key_bytes_in_memory` | 主键值所占用的内存量(以字节为单位)。 | UInt64 | +| `primary_key_bytes_in_memory_allocated` | 为主键值保留的内存量(以字节为单位)。 | UInt64 | +| `database` | 数据库的名称。 | String | +| `table` | 表的名称。 | String | +| `engine` | 表引擎的名称,不带参数。 | String | +| `disk_name` | 存储数据部分的磁盘名称。 | String | +| `path` | 数据部分文件的绝对路径。 | String | +| `column` | 列的名称。 | String | +| `type` | 列类型。 | String | +| `column_position` | 表中列的序数位置,从 1 开始。 | UInt64 | +| `default_kind` | 默认值的表达式类型(DEFAULT,MATERIALIZED,ALIAS),如果未定义则为空字符串。 | String | +| `default_expression` | 默认值的表达式,如果未定义则为空字符串。 | String | +| `column_bytes_on_disk` | 列的总大小(以字节为单位)。 | UInt64 | +| `column_data_compressed_bytes` | 列中压缩数据的总大小(以字节为单位)。 | UInt64 | +| `column_data_uncompressed_bytes` | 列中未压缩数据的总大小(以字节为单位)。 | UInt64 | +| `column_marks_bytes` | 带有标记的列的大小(以字节为单位)。 | UInt64 | +| `column_modification_time` | 列最后一次被修改的时间。 | Nullable(DateTime) | +| `bytes` | bytes_on_disk 的别名 | UInt64 | +| `marks_size` | marks_bytes 的别名 | UInt64 | +| `part_name` | name 的别名 | String | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/projection_parts_columns.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/projection_parts_columns.md.hash new file mode 100644 index 00000000000..376d3283c8f --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/projection_parts_columns.md.hash @@ -0,0 +1 @@ +fe7fcde00f3039a6 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/projections.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/projections.md index 2bd7ea28bf7..12bdd1e016d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/projections.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/projections.md @@ -1,10 +1,11 @@ --- -'description': '系统表包含有关所有表中现有投影的信息。' +'description': '系统表,包含有关所有表中现有投影的信息。' 'keywords': - 'system table' - 'projections' 'slug': '/operations/system-tables/projections' 'title': 'system.projections' +'doc_type': 'reference' --- diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/projections.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/projections.md.hash index dfe63a7fdda..7e5332a7c93 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/projections.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/projections.md.hash @@ -1 +1 @@ -68cee1c17444cee7 +e784df396cf4099f diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/query_cache.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/query_cache.md index 65d5d54468d..94dcb5a7161 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/query_cache.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/query_cache.md @@ -5,6 +5,7 @@ - 'query_cache' 'slug': '/operations/system-tables/query_cache' 'title': 'system.query_cache' +'doc_type': 'reference' --- import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_system_table_cloud.md'; @@ -22,10 +23,10 @@ import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/curre - `query_id` ([String](../../sql-reference/data-types/string.md)) — 查询的 ID。 - `result_size` ([UInt64](/sql-reference/data-types/int-uint#integer-ranges)) — 查询缓存条目的大小。 - `tag` ([LowCardinality(String)](../../sql-reference/data-types/lowcardinality.md)) — 查询缓存条目的标签。 -- `stale` ([UInt8](../../sql-reference/data-types/int-uint.md)) — 查询缓存条目是否过期。 +- `stale` ([UInt8](../../sql-reference/data-types/int-uint.md)) — 查询缓存条目是否已过期。 - `shared` ([UInt8](../../sql-reference/data-types/int-uint.md)) — 查询缓存条目是否在多个用户之间共享。 - `compressed` ([UInt8](../../sql-reference/data-types/int-uint.md)) — 查询缓存条目是否被压缩。 -- `expires_at` ([DateTime](../../sql-reference/data-types/datetime.md)) — 查询缓存条目何时变为过期。 +- `expires_at` ([DateTime](../../sql-reference/data-types/datetime.md)) — 查询缓存条目变为过期的时间。 - `key_hash` ([UInt64](/sql-reference/data-types/int-uint#integer-ranges)) — 查询字符串的哈希值,用作查找查询缓存条目的键。 **示例** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/query_cache.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/query_cache.md.hash index c7226583315..a95670067c3 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/query_cache.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/query_cache.md.hash @@ -1 +1 @@ -f0807aaf072eb746 +f210220a89c74907 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/query_condition_cache.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/query_condition_cache.md index 9550b764c3f..377a0f09e27 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/query_condition_cache.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/query_condition_cache.md @@ -5,6 +5,7 @@ - 'query_condition_cache' 'slug': '/operations/system-tables/query_condition_cache' 'title': 'system.query_condition_cache' +'doc_type': 'reference' --- import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_system_table_cloud.md'; @@ -19,10 +20,10 @@ import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/curre 列: - `table_uuid` ([String](../../sql-reference/data-types/string.md)) — 表的 UUID。 -- `part_name` ([String](../../sql-reference/data-types/string.md)) — 分片名称。 -- `condition` ([String](/sql-reference/data-types/string.md)) — 哈希过滤条件。仅在设置 query_condition_cache_store_conditions_as_plaintext = true 时设置。 -- `condition_hash` ([String](/sql-reference/data-types/string.md)) — 过滤条件的哈希值。 -- `entry_size` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 条目的大小(字节)。 +- `part_name` ([String](../../sql-reference/data-types/string.md)) — 分片的名称。 +- `condition` ([String](/sql-reference/data-types/string.md)) — 哈希筛选条件。只有当设置 query_condition_cache_store_conditions_as_plaintext = true 时才会设置。 +- `condition_hash` ([UInt64](/sql-reference/data-types/int-uint.md)) — 筛选条件的哈希值。 +- `entry_size` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 条目的字节大小。 - `matching_marks` ([String](../../sql-reference/data-types/string.md)) — 匹配标记。 **示例** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/query_condition_cache.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/query_condition_cache.md.hash index 4dd67fd2440..6efd779a4bb 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/query_condition_cache.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/query_condition_cache.md.hash @@ -1 +1 @@ -a1546471c971716a +26d0d75d6313f1b4 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/query_log.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/query_log.md index 491b018fad4..90c20b3b1ec 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/query_log.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/query_log.md @@ -1,10 +1,11 @@ --- -'description': '系统表包含有关执行的查询的信息,例如,开始时间,处理持续时间,错误消息。' +'description': '系统表包含关于执行的查询的信息,例如,开始时间,处理持续时间,错误消息。' 'keywords': - 'system table' - 'query_log' 'slug': '/operations/system-tables/query_log' 'title': 'system.query_log' +'doc_type': 'reference' --- import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_system_table_cloud.md'; @@ -14,127 +15,127 @@ import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/curre -包含有关执行查询的信息,例如,开始时间、处理持续时间和错误消息。 - -:::note -此表不包含 `INSERT` 查询的摄取数据。 -::: +存储有关执行查询的元数据和统计信息,例如开始时间、持续时间、错误消息、资源使用情况以及其他执行细节。它不存储查询结果。 您可以在服务器配置的 [query_log](../../operations/server-configuration-parameters/settings.md#query_log) 部分更改查询日志记录的设置。 -您可以通过设置 [log_queries = 0](/operations/settings/settings#log_queries) 禁用查询日志记录。我们不建议关闭日志记录,因为此表中的信息对于解决问题非常重要。 +您可以通过设置 [log_queries = 0](/operations/settings/settings#log_queries) 来禁用查询日志记录。我们不建议关闭日志记录,因为此表中的信息对于解决问题很重要。 数据的刷新周期在 [query_log](../../operations/server-configuration-parameters/settings.md#query_log) 服务器设置部分的 `flush_interval_milliseconds` 参数中设置。要强制刷新,请使用 [SYSTEM FLUSH LOGS](/sql-reference/statements/system#flush-logs) 查询。 -ClickHouse 不会自动删除表中的数据。有关更多详细信息,请参见 [简介](/operations/system-tables/overview#system-tables-introduction)。 +ClickHouse 不会自动删除表中的数据。有关更多细节,请参见 [Introduction](/operations/system-tables/overview#system-tables-introduction)。 -`system.query_log` 表记录两种类型的查询: +`system.query_log` 表注册了两种类型的查询: -1. 直接由客户端运行的初始查询。 -2. 由其他查询发起的子查询(用于分布式查询执行)。对于此类查询,关于父查询的信息显示在 `initial_*` 列中。 +1. 客户端直接运行的初始查询。 +2. 由其他查询发起的子查询(用于分布式查询执行)。对于这些类型的查询,父查询的信息显示在 `initial_*` 列中。 -根据查询的状态(参见 `type` 列),每个查询会在 `query_log` 表中创建一到两行: +每个查询在 `query_log` 表中创建一到两行,具体取决于查询的状态(参见 `type` 列): -1. 如果查询执行成功,将创建两行,分别为 `QueryStart` 和 `QueryFinish` 类型。 -2. 如果在查询处理期间发生错误,将创建两个事件,分别为 `QueryStart` 和 `ExceptionWhileProcessing` 类型。 -3. 如果在启动查询之前发生错误,将创建一个类型为 `ExceptionBeforeStart` 的单个事件。 +1. 如果查询执行成功,创建两行,类型为 `QueryStart` 和 `QueryFinish`。 +2. 如果查询处理期间发生错误,创建两条事件,类型为 `QueryStart` 和 `ExceptionWhileProcessing`。 +3. 如果在启动查询之前发生错误,则创建一条事件,类型为 `ExceptionBeforeStart`。 -您可以使用 [log_queries_probability](/operations/settings/settings#log_queries_probability) 设置来减少记录在 `query_log` 表中的查询数量。 +您可以使用 [log_queries_probability](/operations/settings/settings#log_queries_probability) 设置减少在 `query_log` 表中注册的查询数量。 -您可以使用 [log_formatted_queries](/operations/settings/settings#log_formatted_queries) 设置将格式化查询记录到 `formatted_query` 列中。 +您可以使用 [log_formatted_queries](/operations/settings/settings#log_formatted_queries) 设置将格式化查询记录到 `formatted_query` 列。 -列: +## Columns {#columns} - `hostname` ([LowCardinality(String)](../../sql-reference/data-types/string.md)) — 执行查询的服务器的主机名。 - `type` ([Enum8](../../sql-reference/data-types/enum.md)) — 执行查询时发生的事件类型。值: - - `'QueryStart' = 1` — 查询执行成功开始。 - - `'QueryFinish' = 2` — 查询执行成功结束。 - - `'ExceptionBeforeStart' = 3` — 查询执行开始前的异常。 - - `'ExceptionWhileProcessing' = 4` — 查询执行期间的异常。 + - `'QueryStart' = 1` — 查询执行成功开始。 + - `'QueryFinish' = 2` — 查询执行成功结束。 + - `'ExceptionBeforeStart' = 3` — 查询执行之前的异常。 + - `'ExceptionWhileProcessing' = 4` — 查询执行期间的异常。 - `event_date` ([Date](../../sql-reference/data-types/date.md)) — 查询开始日期。 - `event_time` ([DateTime](../../sql-reference/data-types/datetime.md)) — 查询开始时间。 -- `event_time_microseconds` ([DateTime64](../../sql-reference/data-types/datetime64.md)) — 查询开始时间(微秒精度)。 +- `event_time_microseconds` ([DateTime64](../../sql-reference/data-types/datetime64.md)) — 查询开始时间以微秒精度表示。 - `query_start_time` ([DateTime](../../sql-reference/data-types/datetime.md)) — 查询执行开始时间。 -- `query_start_time_microseconds` ([DateTime64](../../sql-reference/data-types/datetime64.md)) — 查询执行开始时间(微秒精度)。 -- `query_duration_ms` ([UInt64](/sql-reference/data-types/int-uint#integer-ranges)) — 查询执行持续时间(毫秒)。 -- `read_rows` ([UInt64](/sql-reference/data-types/int-uint#integer-ranges)) — 从参与查询的所有表和表函数中读取的总行数。包括常规子查询、`IN` 和 `JOIN` 的子查询。对于分布式查询,`read_rows` 包括所有副本读取的总行数。每个副本发送它的 `read_rows` 值,查询的服务器发起者汇总所有接收和本地值。缓存量不影响此值。 -- `read_bytes` ([UInt64](/sql-reference/data-types/int-uint#integer-ranges)) — 从参与查询的所有表和表函数中读取的总字节数。包括常规子查询、`IN` 和 `JOIN` 的子查询。对于分布式查询,`read_bytes` 包括所有副本读取的总字节数。每个副本发送它的 `read_bytes` 值,查询的服务器发起者汇总所有接收和本地值。缓存量不影响此值。 +- `query_start_time_microseconds` ([DateTime64](../../sql-reference/data-types/datetime64.md)) — 查询执行开始时间以微秒精度表示。 +- `query_duration_ms` ([UInt64](/sql-reference/data-types/int-uint#integer-ranges)) — 查询执行的持续时间(毫秒)。 +- `read_rows` ([UInt64](/sql-reference/data-types/int-uint#integer-ranges)) — 从所有参与查询的表和表函数中读取的总行数。包括常规子查询、`IN` 和 `JOIN` 的子查询。对于分布式查询,`read_rows` 包括所有副本读取的总行数。每个副本发送其 `read_rows` 值,查询的服务器发起者汇总所有接收到的和本地的值。缓存量不影响此值。 +- `read_bytes` ([UInt64](/sql-reference/data-types/int-uint#integer-ranges)) — 从所有参与查询的表和表函数中读取的字节总数。包括常规子查询、`IN` 和 `JOIN` 的子查询。对于分布式查询,`read_bytes` 包括所有副本读取的字节总数。每个副本发送其 `read_bytes` 值,查询的服务器发起者汇总所有接收到的和本地的值。缓存量不影响此值。 - `written_rows` ([UInt64](/sql-reference/data-types/int-uint#integer-ranges)) — 对于 `INSERT` 查询,写入的行数。对于其他查询,列值为 0。 - `written_bytes` ([UInt64](/sql-reference/data-types/int-uint#integer-ranges)) — 对于 `INSERT` 查询,写入的字节数(未压缩)。对于其他查询,列值为 0。 -- `result_rows` ([UInt64](/sql-reference/data-types/int-uint#integer-ranges)) — `SELECT` 查询结果的行数,或 `INSERT` 查询中的行数。 -- `result_bytes` ([UInt64](/sql-reference/data-types/int-uint#integer-ranges)) — 用于存储查询结果的RAM字节体积。 -- `memory_usage` ([UInt64](/sql-reference/data-types/int-uint#integer-ranges)) — 查询的内存消耗。 +- `result_rows` ([UInt64](/sql-reference/data-types/int-uint#integer-ranges)) — `SELECT` 查询结果中的行数,或 `INSERT` 查询中的行数。 +- `result_bytes` ([UInt64](/sql-reference/data-types/int-uint#integer-ranges)) — 用于存储查询结果的RAM字节量。 +- `memory_usage` ([UInt64](/sql-reference/data-types/int-uint#integer-ranges)) — 查询消耗的内存。 - `current_database` ([String](../../sql-reference/data-types/string.md)) — 当前数据库的名称。 - `query` ([String](../../sql-reference/data-types/string.md)) — 查询字符串。 -- `formatted_query` ([String](../../sql-reference/data-types/string.md)) — 格式化的查询字符串。 -- `normalized_query_hash` ([UInt64](/sql-reference/data-types/int-uint#integer-ranges)) — 数值哈希值,对于仅按字面值不同的查询是相同的。 +- `formatted_query` ([String](../../sql-reference/data-types/string.md)) — 格式化查询字符串。 +- `normalized_query_hash` ([UInt64](/sql-reference/data-types/int-uint#integer-ranges)) — 数字哈希值,对于只通过文字值不同的查询是相同的。 - `query_kind` ([LowCardinality(String)](../../sql-reference/data-types/lowcardinality.md)) — 查询的类型。 - `databases` ([Array](../../sql-reference/data-types/array.md)([LowCardinality(String)](../../sql-reference/data-types/lowcardinality.md))) — 查询中存在的数据库名称。 - `tables` ([Array](../../sql-reference/data-types/array.md)([LowCardinality(String)](../../sql-reference/data-types/lowcardinality.md))) — 查询中存在的表名称。 - `columns` ([Array](../../sql-reference/data-types/array.md)([LowCardinality(String)](../../sql-reference/data-types/lowcardinality.md))) — 查询中存在的列名称。 - `partitions` ([Array](../../sql-reference/data-types/array.md)([LowCardinality(String)](../../sql-reference/data-types/lowcardinality.md))) — 查询中存在的分区名称。 -- `projections` ([String](../../sql-reference/data-types/string.md)) — 查询执行期间使用的投影名称。 +- `projections` ([String](../../sql-reference/data-types/string.md)) — 查询执行过程中使用的投影名称。 - `views` ([Array](../../sql-reference/data-types/array.md)([LowCardinality(String)](../../sql-reference/data-types/lowcardinality.md))) — 查询中存在的(物化或实时)视图名称。 - `exception_code` ([Int32](../../sql-reference/data-types/int-uint.md)) — 异常代码。 - `exception` ([String](../../sql-reference/data-types/string.md)) — 异常消息。 -- `stack_trace` ([String](../../sql-reference/data-types/string.md)) — [堆栈跟踪](https://en.wikipedia.org/wiki/Stack_trace)。如果查询成功完成,则为一个空字符串。 +- `stack_trace` ([String](../../sql-reference/data-types/string.md)) — [堆栈跟踪](https://en.wikipedia.org/wiki/Stack_trace)。如果查询成功完成,则为空字符串。 - `is_initial_query` ([UInt8](../../sql-reference/data-types/int-uint.md)) — 查询类型。可能的值: - - 1 — 查询由客户端发起。 - - 0 — 查询由另一个查询作为分布式查询执行的一部分发起。 + - 1 — 查询由客户端发起。 + - 0 — 查询由另一个查询发起,作为分布式查询执行的一部分。 - `user` ([String](../../sql-reference/data-types/string.md)) — 发起当前查询的用户名称。 -- `query_id` ([String](../../sql-reference/data-types/string.md)) — 查询的 ID。 -- `address` ([IPv6](../../sql-reference/data-types/ipv6.md)) — 发起查询的IP地址。 -- `port` ([UInt16](../../sql-reference/data-types/int-uint.md)) — 发起查询的客户端端口。 +- `query_id` ([String](../../sql-reference/data-types/string.md)) — 查询的ID。 +- `address` ([IPv6](../../sql-reference/data-types/ipv6.md)) — 用于发起查询的IP地址。 +- `port` ([UInt16](../../sql-reference/data-types/int-uint.md)) — 用于发起查询的客户端端口。 - `initial_user` ([String](../../sql-reference/data-types/string.md)) — 运行初始查询的用户名称(用于分布式查询执行)。 - `initial_query_id` ([String](../../sql-reference/data-types/string.md)) — 初始查询的ID(用于分布式查询执行)。 -- `initial_address` ([IPv6](../../sql-reference/data-types/ipv6.md)) — 父查询发起时的IP地址。 +- `initial_address` ([IPv6](../../sql-reference/data-types/ipv6.md)) — 启动父查询的IP地址。 - `initial_port` ([UInt16](../../sql-reference/data-types/int-uint.md)) — 用于发起父查询的客户端端口。 - `initial_query_start_time` ([DateTime](../../sql-reference/data-types/datetime.md)) — 初始查询开始时间(用于分布式查询执行)。 -- `initial_query_start_time_microseconds` ([DateTime64](../../sql-reference/data-types/datetime64.md)) — 初始查询开始时间(微秒精度,用于分布式查询执行)。 +- `initial_query_start_time_microseconds` ([DateTime64](../../sql-reference/data-types/datetime64.md)) — 初始查询开始时间以微秒精度表示(用于分布式查询执行)。 - `interface` ([UInt8](../../sql-reference/data-types/int-uint.md)) — 查询发起的接口。可能的值: - - 1 — TCP。 - - 2 — HTTP。 + - 1 — TCP。 + - 2 — HTTP。 - `os_user` ([String](../../sql-reference/data-types/string.md)) — 运行 [clickhouse-client](../../interfaces/cli.md) 的操作系统用户名。 -- `client_hostname` ([String](../../sql-reference/data-types/string.md)) — 运行 [clickhouse-client](../../interfaces/cli.md) 或其他 TCP 客户端的客户端计算机的主机名。 -- `client_name` ([String](../../sql-reference/data-types/string.md)) — [clickhouse-client](../../interfaces/cli.md) 或其他 TCP 客户端名称。 -- `client_revision` ([UInt32](../../sql-reference/data-types/int-uint.md)) — [clickhouse-client](../../interfaces/cli.md) 或其他 TCP 客户端的版本。 -- `client_version_major` ([UInt32](../../sql-reference/data-types/int-uint.md)) — [clickhouse-client](../../interfaces/cli.md) 或其他 TCP 客户端的主要版本。 -- `client_version_minor` ([UInt32](../../sql-reference/data-types/int-uint.md)) — [clickhouse-client](../../interfaces/cli.md) 或其他 TCP 客户端的次要版本。 -- `client_version_patch` ([UInt32](../../sql-reference/data-types/int-uint.md)) — [clickhouse-client](../../interfaces/cli.md) 或其他 TCP 客户端版本的修补程序组件。 -- `script_query_number` ([UInt32](../../sql-reference/data-types/int-uint.md)) — 含有多个查询的脚本中查询的编号 [clickhouse-client](../../interfaces/cli.md)。 -- `script_line_number` ([UInt32](../../sql-reference/data-types/int-uint.md)) — 含有多个查询的脚本中查询开始的行号 [clickhouse-client](../../interfaces/cli.md)。 -- `http_method` (UInt8) — 发起查询的 HTTP 方法。可能的值: - - 0 — 查询是从 TCP 接口发起的。 - - 1 — 使用了 `GET` 方法。 - - 2 — 使用了 `POST` 方法。 -- `http_user_agent` ([String](../../sql-reference/data-types/string.md)) — HTTP 查询中传递的 HTTP 头 `UserAgent`。 -- `http_referer` ([String](../../sql-reference/data-types/string.md)) — 在 HTTP 查询中传递的 HTTP 头 `Referer`(包含发起查询的页面的绝对或部分地址)。 -- `forwarded_for` ([String](../../sql-reference/data-types/string.md)) — 在 HTTP 查询中传递的 HTTP 头 `X-Forwarded-For`。 +- `client_hostname` ([String](../../sql-reference/data-types/string.md)) — 运行 [clickhouse-client](../../interfaces/cli.md) 或其他TCP客户端的客户端计算机的主机名。 +- `client_name` ([String](../../sql-reference/data-types/string.md)) — [clickhouse-client](../../interfaces/cli.md) 或其他TCP客户端名称。 +- `client_revision` ([UInt32](../../sql-reference/data-types/int-uint.md)) — [clickhouse-client](../../interfaces/cli.md) 或其他TCP客户端的修订版本。 +- `client_version_major` ([UInt32](../../sql-reference/data-types/int-uint.md)) — [clickhouse-client](../../interfaces/cli.md) 或其他TCP客户端的主要版本。 +- `client_version_minor` ([UInt32](../../sql-reference/data-types/int-uint.md)) — [clickhouse-client](../../interfaces/cli.md) 或其他TCP客户端的次要版本。 +- `client_version_patch` ([UInt32](../../sql-reference/data-types/int-uint.md)) — [clickhouse-client](../../interfaces/cli.md) 或其他TCP客户端版本的补丁组件。 +- `script_query_number` ([UInt32](../../sql-reference/data-types/int-uint.md)) — 在包含多个查询的脚本中对 [clickhouse-client](../../interfaces/cli.md) 的查询编号。 +- `script_line_number` ([UInt32](../../sql-reference/data-types/int-uint.md)) — 在包含多个查询的脚本中查询开始的行号。 +- `http_method` (UInt8) — 发起查询的HTTP方法。可能的值: + - 0 — 查询是从TCP接口发起的。 + - 1 — 使用了 `GET` 方法。 + - 2 — 使用了 `POST` 方法。 +- `http_user_agent` ([String](../../sql-reference/data-types/string.md)) — 在HTTP查询中传递的HTTP头 `UserAgent`。 +- `http_referer` ([String](../../sql-reference/data-types/string.md)) — 在HTTP查询中传递的HTTP头 `Referer`(包含发起查询的页面的绝对或部分地址)。 +- `forwarded_for` ([String](../../sql-reference/data-types/string.md)) — 在HTTP查询中传递的HTTP头 `X-Forwarded-For`。 - `quota_key` ([String](../../sql-reference/data-types/string.md)) — 在 [quotas](../../operations/quotas.md) 设置中指定的 `quota key`(见 `keyed`)。 - `revision` ([UInt32](../../sql-reference/data-types/int-uint.md)) — ClickHouse 修订版。 -- `ProfileEvents` ([Map(String, UInt64)](../../sql-reference/data-types/map.md)) — 测量不同指标的 ProfileEvents。它们的描述可以在表 [system.events](/operations/system-tables/events) 中找到。 -- `Settings` ([Map(String, String)](../../sql-reference/data-types/map.md)) — 客户端运行查询时更改的设置。要启用对设置更改的日志记录,请将 `log_query_settings` 参数设置为 1。 +- `ProfileEvents` ([Map(String, UInt64)](../../sql-reference/data-types/map.md)) — 测量不同指标的ProfileEvents。它们的描述可以在表 [system.events](/operations/system-tables/events) 中找到。 +- `Settings` ([Map(String, String)](../../sql-reference/data-types/map.md)) — 当客户端运行查询时更改的设置。要启用对设置更改的日志记录,请将 `log_query_settings` 参数设置为 1。 - `log_comment` ([String](../../sql-reference/data-types/string.md)) — 日志评论。可以设置为不超过 [max_query_size](../../operations/settings/settings.md#max_query_size) 的任意字符串。如果未定义,则为空字符串。 -- `thread_ids` ([Array(UInt64)](../../sql-reference/data-types/array.md)) — 参与查询执行的线程 ID。这些线程可能不会同时运行。 -- `peak_threads_usage` ([UInt64](/sql-reference/data-types/int-uint.md)) — 执行查询的同时线程的最大数量。 +- `thread_ids` ([Array(UInt64)](../../sql-reference/data-types/array.md)) — 参与查询执行的线程ID。这些线程可能不是同时运行的。 +- `peak_threads_usage` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 执行查询时的最大并发线程数。 - `used_aggregate_functions` ([Array(String)](../../sql-reference/data-types/array.md)) — 在查询执行过程中使用的 `aggregate functions` 的规范名称。 - `used_aggregate_function_combinators` ([Array(String)](../../sql-reference/data-types/array.md)) — 在查询执行过程中使用的 `aggregate functions combinators` 的规范名称。 - `used_database_engines` ([Array(String)](../../sql-reference/data-types/array.md)) — 在查询执行过程中使用的 `database engines` 的规范名称。 - `used_data_type_families` ([Array(String)](../../sql-reference/data-types/array.md)) — 在查询执行过程中使用的 `data type families` 的规范名称。 -- `used_dictionaries` ([Array(String)](../../sql-reference/data-types/array.md)) — 在查询执行过程中使用的 `dictionaries` 的规范名称。对于通过 XML 文件配置的字典,这是字典的名称,对于通过 SQL 语句创建的字典,规范名称是完全限定的对象名称。 +- `used_dictionaries` ([Array(String)](../../sql-reference/data-types/array.md)) — 在查询执行过程中使用的 `dictionaries` 的规范名称。对于使用XML文件配置的字典而言,这是字典的名称;而对于通过SQL语句创建的字典,其规范名称为完全限定的对象名称。 - `used_formats` ([Array(String)](../../sql-reference/data-types/array.md)) — 在查询执行过程中使用的 `formats` 的规范名称。 - `used_functions` ([Array(String)](../../sql-reference/data-types/array.md)) — 在查询执行过程中使用的 `functions` 的规范名称。 - `used_storages` ([Array(String)](../../sql-reference/data-types/array.md)) — 在查询执行过程中使用的 `storages` 的规范名称。 - `used_table_functions` ([Array(String)](../../sql-reference/data-types/array.md)) — 在查询执行过程中使用的 `table functions` 的规范名称。 +- `used_executable_user_defined_functions` ([Array(String)](../../sql-reference/data-types/array.md)) — 在查询执行过程中使用的 `executable user defined functions` 的规范名称。 +- `used_sql_user_defined_functions` ([Array(String)](../../sql-reference/data-types/array.md)) — 在查询执行过程中使用的 `sql user defined functions` 的规范名称。 - `used_privileges` ([Array(String)](../../sql-reference/data-types/array.md)) - 在查询执行期间成功检查的权限。 - `missing_privileges` ([Array(String)](../../sql-reference/data-types/array.md)) - 在查询执行期间缺失的权限。 - `query_cache_usage` ([Enum8](../../sql-reference/data-types/enum.md)) — 查询执行期间 [query cache](../query-cache.md) 的使用情况。值: - - `'Unknown'` = 状态未知。 - - `'None'` = 查询结果既未写入查询缓存,也未从查询缓存中读取。 - - `'Write'` = 查询结果被写入查询缓存。 - - `'Read'` = 查询结果从查询缓存中读取。 + - `'Unknown'` = 状态未知。 + - `'None'` = 查询结果既未写入查询缓存,也未从查询缓存读取。 + - `'Write'` = 查询结果已写入查询缓存。 + - `'Read'` = 查询结果已从查询缓存读取。 + +## Examples {#examples} -**示例** +**基本示例** ```sql SELECT * FROM system.query_log WHERE type = 'QueryFinish' ORDER BY query_start_time DESC LIMIT 1 FORMAT Vertical; @@ -209,11 +210,27 @@ used_formats: [] used_functions: [] used_storages: [] used_table_functions: [] +used_executable_user_defined_functions:[] +used_sql_user_defined_functions: [] used_privileges: [] missing_privileges: [] query_cache_usage: None ``` -**参见** +**云示例** + +在 ClickHouse Cloud 中,`system.query_log` 是每个节点的本地;要查看所有条目,必须通过 [`clusterAllReplicas`](/sql-reference/table-functions/cluster) 查询。 + +例如,要聚合“默认”集群中每个副本的 query_log 行,可以写: + +```sql +SELECT * +FROM clusterAllReplicas('default', system.query_log) +WHERE event_time >= now() - toIntervalHour(1) +LIMIT 10 +SETTINGS skip_unavailable_shards = 1; +``` + +**另见** -- [system.query_thread_log](/operations/system-tables/query_thread_log) — 该表包含有关每个查询执行线程的信息。 +- [system.query_thread_log](/operations/system-tables/query_thread_log) — 此表包含有关每个查询执行线程的信息。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/query_log.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/query_log.md.hash index 6d895acdfc9..4c8eb12d93f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/query_log.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/query_log.md.hash @@ -1 +1 @@ -c14818d67ee57f16 +288d4c76d58f7aa0 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/query_metric_log.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/query_metric_log.md index 6155720271f..25975f716a0 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/query_metric_log.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/query_metric_log.md @@ -1,10 +1,11 @@ --- -'description': '系统表,包含来自表 `system.events` 的个别查询的内存和指标值的历史记录,定期刷新到磁盘。' +'description': '系统表,包含来自表 `system.events` 的每个查询的内存和指标值的历史记录,定期刷新到磁盘。' 'keywords': - 'system table' - 'query_metric_log' 'slug': '/operations/system-tables/query_metric_log' 'title': 'system.query_metric_log' +'doc_type': 'reference' --- import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_system_table_cloud.md'; @@ -14,16 +15,16 @@ import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/curre -包含来自 `system.events` 表的个别查询的内存和指标值的历史记录,定期刷新到磁盘。 +包含来自表 `system.events` 的单个查询的内存和指标值的历史记录,定期刷新到磁盘上。 -一旦查询开始,数据将在 `query_metric_log_interval` 毫秒(默认设置为 1000) 的周期性间隔内收集。如果查询持续时间超过 `query_metric_log_interval`,则在查询完成时也会收集数据。 +查询开始后,数据会以 `query_metric_log_interval` 毫秒(默认为 1000)为周期进行收集。如果查询持续时间超过 `query_metric_log_interval`,则在查询完成时也会收集数据。 列: - `query_id` ([String](../../sql-reference/data-types/string.md)) — 查询的 ID。 - `hostname` ([LowCardinality(String)](../../sql-reference/data-types/string.md)) — 执行查询的服务器的主机名。 - `event_date` ([Date](../../sql-reference/data-types/date.md)) — 事件日期。 - `event_time` ([DateTime](../../sql-reference/data-types/datetime.md)) — 事件时间。 -- `event_time_microseconds` ([DateTime64](../../sql-reference/data-types/datetime64.md)) — 具有微秒分辨率的事件时间。 +- `event_time_microseconds` ([DateTime64](../../sql-reference/data-types/datetime64.md)) — 带有微秒分辨率的事件时间。 **示例** @@ -54,6 +55,6 @@ ProfileEvent_FailedSelectQuery: 0 - [query_metric_log 设置](../../operations/server-configuration-parameters/settings.md#query_metric_log) — 启用和禁用该设置。 - [query_metric_log_interval](../../operations/settings/settings.md#query_metric_log_interval) - [system.asynchronous_metrics](../../operations/system-tables/asynchronous_metrics.md) — 包含定期计算的指标。 -- [system.events](/operations/system-tables/events) — 包含发生的大量事件。 -- [system.metrics](../../operations/system-tables/metrics.md) — 包含即时计算的指标。 -- [监控](../../operations/monitoring.md) — ClickHouse 监控的基本概念。 +- [system.events](/operations/system-tables/events) — 包含发生的多个事件。 +- [system.metrics](../../operations/system-tables/metrics.md) — 包含瞬时计算的指标。 +- [Monitoring](../../operations/monitoring.md) — ClickHouse 监控的基本概念。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/query_metric_log.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/query_metric_log.md.hash index 990d43b1669..2b67338ee48 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/query_metric_log.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/query_metric_log.md.hash @@ -1 +1 @@ -0193943b7227c990 +9f4c1e36b4244b58 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/query_thread_log.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/query_thread_log.md index 33e18d7a64f..c4b889ca936 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/query_thread_log.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/query_thread_log.md @@ -1,10 +1,11 @@ --- -'description': '系统表包含有关执行查询的线程的信息,例如,线程名称,线程开始时间,查询处理持续时间。' +'description': '系统表包含有关执行查询的线程的信息,例如,线程名称,线程开始时间,以及查询处理的持续时间。' 'keywords': - 'system table' - 'query_thread_log' 'slug': '/operations/system-tables/query_thread_log' 'title': 'system.query_thread_log' +'doc_type': 'reference' --- import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_system_table_cloud.md'; @@ -14,67 +15,67 @@ import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/curre -包含执行查询的线程信息,例如,线程名称、线程开始时间、查询处理持续时间。 +包含有关执行查询的线程的信息,例如线程名称、线程开始时间、查询处理的持续时间。 -要启动日志记录: +要开始记录日志: 1. 在 [query_thread_log](/operations/server-configuration-parameters/settings#query_thread_log) 部分配置参数。 2. 将 [log_query_threads](/operations/settings/settings#log_query_threads) 设置为 1。 -数据的刷新周期在 [query_thread_log](/operations/server-configuration-parameters/settings#query_thread_log) 服务器设置部分的 `flush_interval_milliseconds` 参数中设置。要强制刷新,请使用 [SYSTEM FLUSH LOGS](/sql-reference/statements/system#flush-logs) 查询。 +数据的冲刷周期在 [query_thread_log](/operations/server-configuration-parameters/settings#query_thread_log) 服务器设置部分的 `flush_interval_milliseconds` 参数中设置。要强制冲刷,请使用 [SYSTEM FLUSH LOGS](/sql-reference/statements/system#flush-logs) 查询。 ClickHouse 不会自动删除表中的数据。有关更多详细信息,请参见 [Introduction](/operations/system-tables/overview#system-tables-introduction)。 -您可以使用 [log_queries_probability](/operations/settings/settings#log_queries_probability) 设置来减少在 `query_thread_log` 表中注册的查询数量。 +您可以使用 [log_queries_probability](/operations/settings/settings#log_queries_probability) 设置来减少记录在 `query_thread_log` 表中的查询数量。 列: - `hostname` ([LowCardinality(String)](../../sql-reference/data-types/string.md)) — 执行查询的服务器的主机名。 -- `event_date` ([Date](../../sql-reference/data-types/date.md)) — 线程完成查询执行的日期。 -- `event_time` ([DateTime](../../sql-reference/data-types/datetime.md)) — 线程完成查询执行的日期和时间。 -- `event_time_microseconds` ([DateTime](../../sql-reference/data-types/datetime.md)) — 线程完成查询执行的日期和时间,精确到微秒。 +- `event_date` ([Date](../../sql-reference/data-types/date.md)) — 线程完成执行查询的日期。 +- `event_time` ([DateTime](../../sql-reference/data-types/datetime.md)) — 线程完成执行查询的日期和时间。 +- `event_time_microseconds` ([DateTime](../../sql-reference/data-types/datetime.md)) — 线程完成执行查询的日期和时间,精确到微秒。 - `query_start_time` ([DateTime](../../sql-reference/data-types/datetime.md)) — 查询执行的开始时间。 - `query_start_time_microseconds` ([DateTime64](../../sql-reference/data-types/datetime64.md)) — 查询执行的开始时间,精确到微秒。 - `query_duration_ms` ([UInt64](/sql-reference/data-types/int-uint#integer-ranges)) — 查询执行的持续时间。 - `read_rows` ([UInt64](/sql-reference/data-types/int-uint#integer-ranges)) — 读取的行数。 - `read_bytes` ([UInt64](/sql-reference/data-types/int-uint#integer-ranges)) — 读取的字节数。 -- `written_rows` ([UInt64](/sql-reference/data-types/int-uint#integer-ranges)) — 对于 `INSERT` 查询,写入的行数。对于其他查询,该列的值为 0。 -- `written_bytes` ([UInt64](/sql-reference/data-types/int-uint#integer-ranges)) — 对于 `INSERT` 查询,写入的字节数。对于其他查询,该列的值为 0。 -- `memory_usage` ([Int64](../../sql-reference/data-types/int-uint.md)) — 上下文中分配的内存与释放的内存之间的差额。 -- `peak_memory_usage` ([Int64](../../sql-reference/data-types/int-uint.md)) — 上下文中分配的内存与释放的内存之间的最大差额。 -- `thread_name` ([String](../../sql-reference/data-types/string.md)) — 线程名称。 +- `written_rows` ([UInt64](/sql-reference/data-types/int-uint#integer-ranges)) — 对于 `INSERT` 查询,写入的行数。对于其他查询,列值为 0。 +- `written_bytes` ([UInt64](/sql-reference/data-types/int-uint#integer-ranges)) — 对于 `INSERT` 查询,写入的字节数。对于其他查询,列值为 0。 +- `memory_usage` ([Int64](../../sql-reference/data-types/int-uint.md)) — 在此线程上下文中分配和释放内存的差额。 +- `peak_memory_usage` ([Int64](../../sql-reference/data-types/int-uint.md)) — 在此线程上下文中分配和释放内存的最大差额。 +- `thread_name` ([String](../../sql-reference/data-types/string.md)) — 线程的名称。 - `thread_id` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 操作系统线程 ID。 -- `master_thread_id` ([UInt64](/sql-reference/data-types/int-uint#integer-ranges)) — 初始线程的操作系统 ID。 +- `master_thread_id` ([UInt64](/sql-reference/data-types/int-uint#integer-ranges)) — 操作系统初始线程的初始 ID。 - `query` ([String](../../sql-reference/data-types/string.md)) — 查询字符串。 - `is_initial_query` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) — 查询类型。可能的值: - - 1 — 查询由客户端发起。 - - 0 — 查询由另一个查询为分布式查询执行发起。 -- `user` ([String](../../sql-reference/data-types/string.md)) — 发起当前查询的用户名称。 + - 1 — 查询由客户端发起。 + - 0 — 查询由另一个查询发起以执行分布式查询。 +- `user` ([String](../../sql-reference/data-types/string.md)) — 发起当前查询的用户姓名。 - `query_id` ([String](../../sql-reference/data-types/string.md)) — 查询的 ID。 - `address` ([IPv6](../../sql-reference/data-types/ipv6.md)) — 用于发起查询的 IP 地址。 - `port` ([UInt16](/sql-reference/data-types/int-uint#integer-ranges)) — 用于发起查询的客户端端口。 -- `initial_user` ([String](../../sql-reference/data-types/string.md)) — 运行初始查询的用户名称(用于分布式查询执行)。 +- `initial_user` ([String](../../sql-reference/data-types/string.md)) — 运行初始查询的用户姓名(用于分布式查询执行)。 - `initial_query_id` ([String](../../sql-reference/data-types/string.md)) — 初始查询的 ID(用于分布式查询执行)。 -- `initial_address` ([IPv6](../../sql-reference/data-types/ipv6.md)) — 父查询启动的 IP 地址。 +- `initial_address` ([IPv6](../../sql-reference/data-types/ipv6.md)) — 父查询启动时使用的 IP 地址。 - `initial_port` ([UInt16](/sql-reference/data-types/int-uint#integer-ranges)) — 用于发起父查询的客户端端口。 - `interface` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) — 查询发起的接口。可能的值: - - 1 — TCP。 - - 2 — HTTP。 + - 1 — TCP。 + - 2 — HTTP。 - `os_user` ([String](../../sql-reference/data-types/string.md)) — 运行 [clickhouse-client](../../interfaces/cli.md) 的操作系统用户名。 -- `client_hostname` ([String](../../sql-reference/data-types/string.md)) — 运行 [clickhouse-client](../../interfaces/cli.md) 或其他 TCP 客户端的客户端机器的主机名。 -- `client_name` ([String](../../sql-reference/data-types/string.md)) — [clickhouse-client](../../interfaces/cli.md) 或其他 TCP 客户端名称。 -- `client_revision` ([UInt32](../../sql-reference/data-types/int-uint.md)) — [clickhouse-client](../../interfaces/cli.md) 或其他 TCP 客户端的修订版。 -- `client_version_major` ([UInt32](../../sql-reference/data-types/int-uint.md)) — [clickhouse-client](../../interfaces/cli.md) 或其他 TCP 客户端的主要版本。 -- `client_version_minor` ([UInt32](../../sql-reference/data-types/int-uint.md)) — [clickhouse-client](../../interfaces/cli.md) 或其他 TCP 客户端的次要版本。 -- `client_version_patch` ([UInt32](../../sql-reference/data-types/int-uint.md)) — [clickhouse-client](../../interfaces/cli.md) 或其他 TCP 客户端版本的修补组件。 +- `client_hostname` ([String](../../sql-reference/data-types/string.md)) — 运行 [clickhouse-client](../../interfaces/cli.md) 或其他 TCP 客户端的客户端计算机的主机名。 +- `client_name` ([String](../../sql-reference/data-types/string.md)) — [clickhouse-client](../../interfaces/cli.md) 或其他 TCP 客户端的名称。 +- `client_revision` ([UInt32](../../sql-reference/data-types/int-uint.md)) — [clickhouse-client](../../interfaces/cli.md) 或其他 TCP 客户端的修订版本。 +- `client_version_major` ([UInt32](../../sql-reference/data-types/int-uint.md)) — [clickhouse-client](../../interfaces/cli.md) 或其他 TCP 客户端的主版本。 +- `client_version_minor` ([UInt32](../../sql-reference/data-types/int-uint.md)) — [clickhouse-client](../../interfaces/cli.md) 或其他 TCP 客户端的次版本。 +- `client_version_patch` ([UInt32](../../sql-reference/data-types/int-uint.md)) — [clickhouse-client](../../interfaces/cli.md) 或其他 TCP 客户端版本的补丁组件。 - `http_method` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) — 发起查询的 HTTP 方法。可能的值: - - 0 — 查询是从 TCP 接口启动的。 - - 1 — 使用了 `GET` 方法。 - - 2 — 使用了 `POST` 方法。 -- `http_user_agent` ([String](../../sql-reference/data-types/string.md)) — 在 HTTP 请求中传递的 `UserAgent` 头信息。 -- `quota_key` ([String](../../sql-reference/data-types/string.md)) — 在 [quotas](../../operations/quotas.md) 设置中指定的“配额键”(参见 `keyed`)。 -- `revision` ([UInt32](../../sql-reference/data-types/int-uint.md)) — ClickHouse 修订版。 -- `ProfileEvents` ([Map(String, UInt64)](../../sql-reference/data-types/array.md)) — 衡量此线程不同指标的 ProfileEvents。它们的描述可以在表 [system.events](/operations/system-tables/events) 中找到。 + - 0 — 查询是从 TCP 接口启动的。 + - 1 — 使用了 `GET` 方法。 + - 2 — 使用了 `POST` 方法。 +- `http_user_agent` ([String](../../sql-reference/data-types/string.md)) — 在 HTTP 请求中传递的 `UserAgent` 头。 +- `quota_key` ([String](../../sql-reference/data-types/string.md)) — 在 [quotas](../../operations/quotas.md) 设置中指定的"配额键"(见 `keyed`)。 +- `revision` ([UInt32](../../sql-reference/data-types/int-uint.md)) — ClickHouse 修订版本。 +- `ProfileEvents` ([Map(String, UInt64)](../../sql-reference/data-types/array.md)) — 测量此线程的不同指标的 ProfileEvents。它们的描述可以在表 [system.events](/operations/system-tables/events) 中找到。 **示例** @@ -126,7 +127,7 @@ revision: 54440 ProfileEvents: {'Query':1,'SelectQuery':1,'ReadCompressedBytes':36,'CompressedReadBufferBlocks':1,'CompressedReadBufferBytes':10,'IOBufferAllocs':1,'IOBufferAllocBytes':89,'ContextLock':15,'RWLockAcquiredReadLocks':1} ``` -**另见** +**另请参见** -- [system.query_log](/operations/system-tables/query_log) — 描述 `query_log` 系统表的内容,该表包含关于查询执行的常见信息。 -- [system.query_views_log](/operations/system-tables/query_views_log) — 该表包含在查询过程中执行的每个视图的信息。 +- [system.query_log](/operations/system-tables/query_log) — 描述 `query_log` 系统表的内容,该表包含有关查询执行的通用信息。 +- [system.query_views_log](/operations/system-tables/query_views_log) — 该表包含在查询期间执行的每个视图的信息。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/query_thread_log.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/query_thread_log.md.hash index 90ab85668ca..4b29fe13560 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/query_thread_log.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/query_thread_log.md.hash @@ -1 +1 @@ -6b02912c50f1e872 +e83b31fa5c9b830e diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/query_views_log.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/query_views_log.md index 339371339d0..9825d0dcb29 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/query_views_log.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/query_views_log.md @@ -1,10 +1,11 @@ --- -'description': '系统表,包含执行查询时所执行的依赖视图的信息,例如,视图类型或执行时间。' +'description': '系统表包含有关执行查询时运行的依赖视图的信息,例如视图类型或执行时间。' 'keywords': - 'system table' - 'query_views_log' 'slug': '/operations/system-tables/query_views_log' 'title': 'system.query_views_log' +'doc_type': 'reference' --- import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_system_table_cloud.md'; @@ -14,7 +15,7 @@ import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/curre -包含在运行查询时执行的依赖视图的信息,例如视图类型或执行时间。 +包含有关运行查询时执行的依赖视图的信息,例如视图类型或执行时间。 要开始记录: @@ -23,40 +24,40 @@ import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/curre 数据的刷新周期在 [query_views_log](../../operations/server-configuration-parameters/settings.md#query_views_log) 服务器设置部分的 `flush_interval_milliseconds` 参数中设置。要强制刷新,请使用 [SYSTEM FLUSH LOGS](/sql-reference/statements/system#flush-logs) 查询。 -ClickHouse 不会自动删除表中的数据。详细信息请参见 [Introduction](/operations/system-tables/overview#system-tables-introduction)。 +ClickHouse 不会自动从表中删除数据。有关更多详细信息,请参见 [Introduction](/operations/system-tables/overview#system-tables-introduction)。 您可以使用 [log_queries_probability](/operations/settings/settings#log_queries_probability) 设置来减少在 `query_views_log` 表中注册的查询数量。 列: - `hostname` ([LowCardinality(String)](../../sql-reference/data-types/string.md)) — 执行查询的服务器的主机名。 -- `event_date` ([Date](../../sql-reference/data-types/date.md)) — 上一个视图事件发生的日期。 -- `event_time` ([DateTime](../../sql-reference/data-types/datetime.md)) — 视图执行结束的日期和时间。 -- `event_time_microseconds` ([DateTime](../../sql-reference/data-types/datetime.md)) — 视图执行结束的日期和时间,微秒精度。 -- `view_duration_ms` ([UInt64](/sql-reference/data-types/int-uint#integer-ranges)) — 视图执行的持续时间(其阶段的总和),以毫秒为单位。 +- `event_date` ([Date](../../sql-reference/data-types/date.md)) — 最后一个视图事件发生的日期。 +- `event_time` ([DateTime](../../sql-reference/data-types/datetime.md)) — 视图完成执行的日期和时间。 +- `event_time_microseconds` ([DateTime](../../sql-reference/data-types/datetime.md)) — 视图完成执行的日期和时间,精确到微秒。 +- `view_duration_ms` ([UInt64](/sql-reference/data-types/int-uint#integer-ranges)) — 视图执行的持续时间(其阶段的总和),单位为毫秒。 - `initial_query_id` ([String](../../sql-reference/data-types/string.md)) — 初始查询的 ID(用于分布式查询执行)。 - `view_name` ([String](../../sql-reference/data-types/string.md)) — 视图的名称。 - `view_uuid` ([UUID](../../sql-reference/data-types/uuid.md)) — 视图的 UUID。 - `view_type` ([Enum8](../../sql-reference/data-types/enum.md)) — 视图的类型。值: - - `'Default' = 1` — [默认视图](/sql-reference/statements/create/view#normal-view)。不应出现在此日志中。 - - `'Materialized' = 2` — [物化视图](/sql-reference/statements/create/view#materialized-view)。 - - `'Live' = 3` — [实时视图](../../sql-reference/statements/create/view.md#live-view)。 + - `'Default' = 1` — [默认视图](/sql-reference/statements/create/view#normal-view)。不应出现在此日志中。 + - `'Materialized' = 2` — [物化视图](/sql-reference/statements/create/view#materialized-view)。 + - `'Live' = 3` — [实时视图](../../sql-reference/statements/create/view.md#live-view)。 - `view_query` ([String](../../sql-reference/data-types/string.md)) — 视图执行的查询。 - `view_target` ([String](../../sql-reference/data-types/string.md)) — 视图目标表的名称。 - `read_rows` ([UInt64](/sql-reference/data-types/int-uint#integer-ranges)) — 读取的行数。 - `read_bytes` ([UInt64](/sql-reference/data-types/int-uint#integer-ranges)) — 读取的字节数。 - `written_rows` ([UInt64](/sql-reference/data-types/int-uint#integer-ranges)) — 写入的行数。 - `written_bytes` ([UInt64](/sql-reference/data-types/int-uint#integer-ranges)) — 写入的字节数。 -- `peak_memory_usage` ([Int64](../../sql-reference/data-types/int-uint.md)) — 在此视图上下文中,已分配和已释放内存之间的最大差值。 -- `ProfileEvents` ([Map(String, UInt64)](../../sql-reference/data-types/array.md)) — 测量不同指标的 ProfileEvents。它们的描述可以在表 [system.events](/operations/system-tables/events) 中找到。 +- `peak_memory_usage` ([Int64](../../sql-reference/data-types/int-uint.md)) — 在该视图上下文中,分配和释放的内存之间的最大差异。 +- `ProfileEvents` ([Map(String, UInt64)](../../sql-reference/data-types/array.md)) — 测量不同指标的 ProfileEvents。其描述可以在 [system.events](/operations/system-tables/events) 表中找到。 - `status` ([Enum8](../../sql-reference/data-types/enum.md)) — 视图的状态。值: - - `'QueryStart' = 1` — 视图执行成功开始。不应出现。 - - `'QueryFinish' = 2` — 视图执行成功结束。 - - `'ExceptionBeforeStart' = 3` — 视图执行开始前的异常。 - - `'ExceptionWhileProcessing' = 4` — 视图执行中的异常。 -- `exception_code` ([Int32](../../sql-reference/data-types/int-uint.md)) — 异常代码。 + - `'QueryStart' = 1` — 成功开始视图执行。不应出现。 + - `'QueryFinish' = 2` — 成功结束视图执行。 + - `'ExceptionBeforeStart' = 3` — 视图执行开始前的异常。 + - `'ExceptionWhileProcessing' = 4` — 视图执行期间的异常。 +- `exception_code` ([Int32](../../sql-reference/data-types/int-uint.md)) — 异常的代码。 - `exception` ([String](../../sql-reference/data-types/string.md)) — 异常消息。 -- `stack_trace` ([String](../../sql-reference/data-types/string.md)) — [堆栈跟踪](https://en.wikipedia.org/wiki/Stack_trace)。如果查询成功完成,则为空字符串。 +- `stack_trace` ([String](../../sql-reference/data-types/string.md)) — [堆栈跟踪](https://en.wikipedia.org/wiki/Stack_trace)。如果查询成功完成,则为一个空字符串。 **示例** @@ -94,7 +95,7 @@ exception: stack_trace: ``` -**另请参见** +**另见** -- [system.query_log](/operations/system-tables/query_log) — 描述 `query_log` 系统表的内容,其中包含有关查询执行的常规信息。 +- [system.query_log](/operations/system-tables/query_log) — 描述 `query_log` 系统表的内容,该表包含有关查询执行的常见信息。 - [system.query_thread_log](/operations/system-tables/query_thread_log) — 此表包含有关每个查询执行线程的信息。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/query_views_log.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/query_views_log.md.hash index e7d3f0941dd..5f6c39d8790 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/query_views_log.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/query_views_log.md.hash @@ -1 +1 @@ -c00d2cfa6bd26799 +8e66282772fb4cd2 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/quota_limits.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/quota_limits.md index ab8fd1dc6b7..1ef8f439f31 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/quota_limits.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/quota_limits.md @@ -1,23 +1,24 @@ --- -'description': '系统表,包含有关所有配额的所有时间段的最大值的信息。任意数量的行或零可以对应于一个配额。' +'description': '系统表包含有关所有配额所有时间段最大值的信息。任何数量的行或零都可以对应一个配额。' 'keywords': - 'system table' - 'quota_limits' 'slug': '/operations/system-tables/quota_limits' 'title': 'system.quota_limits' +'doc_type': 'reference' --- # system.quota_limits -包含有关所有配额所有时间间隔的最大值的信息。可以对应于一个配额的行数可以是任意数量或零。 +包含所有配额的所有时间间隔的最大值的信息。任意数量的行或零可对应于一个配额。 列: - `quota_name` ([String](../../sql-reference/data-types/string.md)) — 配额名称。 -- `duration` ([UInt32](../../sql-reference/data-types/int-uint.md)) — 用于计算资源消耗的时间间隔长度,以秒为单位。 -- `is_randomized_interval` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) — 逻辑值。它指示时间间隔是否是随机的。如果间隔未随机化,则总是从相同的时间开始。例如,1分钟的间隔总是从整数分钟开始(即可以在11:20:00开始,但绝不会在11:20:01开始),一天的间隔总是从UTC的午夜开始。如果间隔是随机的,则第一个间隔在随机时间开始,后续间隔一个接一个开始。值: - - `0` — 间隔未随机化。 - - `1` — 间隔已随机化。 +- `duration` ([UInt32](../../sql-reference/data-types/int-uint.md)) — 计算资源消耗的时间间隔长度,以秒为单位。 +- `is_randomized_interval` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) — 逻辑值。它用于指示间隔是否是随机的。如果不是随机的,间隔总是从相同的时间开始。例如,1分钟的间隔总是从整数分钟开始(即它可以在11:20:00开始,但绝不会在11:20:01开始),一天的间隔总是从UTC零点开始。如果间隔是随机的,第一个间隔在随机时间开始,随后的间隔依次开始。值: + - `0` — 间隔不是随机的。 + - `1` — 间隔是随机的。 - `max_queries` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 最大查询数。 - `max_query_selects` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 最大选择查询数。 - `max_query_inserts` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 最大插入查询数。 @@ -25,5 +26,5 @@ - `max_result_rows` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 最大结果行数。 - `max_result_bytes` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 用于存储查询结果的最大RAM字节数。 - `max_read_rows` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 从所有参与查询的表和表函数中读取的最大行数。 -- `max_read_bytes` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 从所有参与查询的表和表函数中读取的最大字节数。 -- `max_execution_time` ([Nullable](../../sql-reference/data-types/nullable.md)([Float64](../../sql-reference/data-types/float.md))) — 查询的最大执行时间,以秒为单位。 +- `max_read_bytes` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 从所有参与查询的表和表函数读取的最大字节数。 +- `max_execution_time` ([Nullable](../../sql-reference/data-types/nullable.md)([Float64](../../sql-reference/data-types/float.md))) — 查询执行时间的最大值,以秒为单位。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/quota_limits.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/quota_limits.md.hash index be4d6491489..1a182514540 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/quota_limits.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/quota_limits.md.hash @@ -1 +1 @@ -4efabf297c867e8d +95e22664048510e2 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/quota_usage.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/quota_usage.md index 723ce4f7afe..f0ceeaa7b1c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/quota_usage.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/quota_usage.md @@ -1,43 +1,44 @@ --- -'description': '系统表包含有关当前用户的配额使用情况的信息,例如已使用的配额和剩余的配额。' +'description': '系统表包含关于当前用户配额使用的详细信息,例如已经使用了多少配额以及剩余多少配额。' 'keywords': - 'system table' - 'quota_usage' 'slug': '/operations/system-tables/quota_usage' 'title': 'system.quota_usage' +'doc_type': 'reference' --- import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_system_table_cloud.md'; -当前用户的配额使用情况:已使用多少和剩余多少。 +当前用户的配额使用情况:使用了多少,剩余多少。 列: - `quota_name` ([String](../../sql-reference/data-types/string.md)) — 配额名称。 -- `quota_key`([String](../../sql-reference/data-types/string.md)) — 键值。例如,如果 keys = \[`ip address`\],则 `quota_key` 可能具有值 '192.168.1.1'。 -- `start_time`([Nullable](../../sql-reference/data-types/nullable.md)([DateTime](../../sql-reference/data-types/datetime.md))) — 计算资源消耗的开始时间。 -- `end_time`([Nullable](../../sql-reference/data-types/nullable.md)([DateTime](../../sql-reference/data-types/datetime.md))) — 计算资源消耗的结束时间。 -- `duration` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 计算资源消耗的时间间隔长度,以秒为单位。 -- `queries` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 此间隔内的请求总数。 -- `query_selects` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 此间隔内的 select 请求总数。 -- `query_inserts` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 此间隔内的 insert 请求总数。 -- `max_queries` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 最大请求数。 +- `quota_key` ([String](../../sql-reference/data-types/string.md)) — 键值。例如,如果 keys = \[`ip address`\],`quota_key` 可能值为 '192.168.1.1'。 +- `start_time` ([Nullable](../../sql-reference/data-types/nullable.md)([DateTime](../../sql-reference/data-types/datetime.md))) — 计算资源消耗的开始时间。 +- `end_time` ([Nullable](../../sql-reference/data-types/nullable.md)([DateTime](../../sql-reference/data-types/datetime.md))) — 计算资源消耗的结束时间。 +- `duration` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 计算资源消耗的时间间隔长,单位为秒。 +- `queries` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 在此时间间隔内的请求总数。 +- `query_selects` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 在此时间间隔内的选择请求总数。 +- `query_inserts` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 在此时间间隔内的插入请求总数。 +- `max_queries` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 最大请求数量。 - `errors` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 抛出异常的查询数量。 -- `max_errors` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 最大错误数。 -- `result_rows` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 作为结果给出的总行数。 +- `max_errors` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 最大错误数量。 +- `result_rows` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 结果中给出的总行数。 - `max_result_rows` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 最大结果行数。 -- `result_bytes` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 用于存储查询结果的内存量(以字节为单位)。 -- `max_result_bytes` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 用于存储查询结果的最大内存量(以字节为单位)。 +- `result_bytes` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 用于存储查询结果的RAM容量,单位为字节。 +- `max_result_bytes` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 用于存储查询结果的最大RAM容量,单位为字节。 - `read_rows` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 为在所有远程服务器上运行查询而从表中读取的源行的总数。 -- `max_read_rows` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 从所有参与查询的表和表函数中读取的最大行数。 -- `read_bytes` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 从所有参与查询的表和表函数中读取的总字节数。 -- `max_read_bytes` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 从所有表和表函数中读取的最大字节数。 -- `failed_sequential_authentications` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/float.md))) — 连续身份验证失败的总计数。如果用户在超过 `failed_sequential_authentications` 阈值之前输入了正确的密码,则计数器将重置。 +- `max_read_rows` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 从所有参与查询的表和表函数读取的最大行数。 +- `read_bytes` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 从所有参与查询的表和表函数读取的字节总数。 +- `max_read_bytes` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 从所有表和表函数读取的最大字节数。 +- `failed_sequential_authentications` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/float.md))) — 连续身份验证失败的总次数。如果用户在超过 `failed_sequential_authentications` 阈值之前输入了正确的密码,则计数器将被重置。 - `max_failed_sequential_authentications` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/float.md))) — 最大连续身份验证失败次数。 -- `execution_time` ([Nullable](../../sql-reference/data-types/nullable.md)([Float64](../../sql-reference/data-types/float.md))) — 查询的总执行时间(以秒为单位,墙钟时间)。 +- `execution_time` ([Nullable](../../sql-reference/data-types/nullable.md)([Float64](../../sql-reference/data-types/float.md))) — 查询的总执行时间,单位为秒(实际时间)。 - `max_execution_time` ([Nullable](../../sql-reference/data-types/nullable.md)([Float64](../../sql-reference/data-types/float.md))) — 查询执行时间的最大值。 -## 另请参见 {#see-also} +## 另请参阅 {#see-also} -- [SHOW QUOTA](/sql-reference/statements/show#show-quota) +- [SHOW QUOTA](/sql-reference/statements/show#show-quota)) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/quota_usage.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/quota_usage.md.hash index b02b22b8cdd..18ef13ef809 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/quota_usage.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/quota_usage.md.hash @@ -1 +1 @@ -21104c203665f275 +227b0491a524b2dd diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/quotas.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/quotas.md index eb4dab740d6..eabaabf34f3 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/quotas.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/quotas.md @@ -6,30 +6,31 @@ - 'quota' 'slug': '/operations/system-tables/quotas' 'title': 'system.quotas' +'doc_type': 'reference' --- # system.quotas -包含有关 [quotas](../../operations/system-tables/quotas.md) 的信息。 +包含有关 [配额](../../operations/system-tables/quotas.md) 的信息。 -列: +列: - `name` ([String](../../sql-reference/data-types/string.md)) — 配额名称。 - `id` ([UUID](../../sql-reference/data-types/uuid.md)) — 配额 ID。 -- `storage`([String](../../sql-reference/data-types/string.md)) — 配额的存储。可能的值: "users.xml",如果配额在 users.xml 文件中配置,"disk" 如果配额通过 SQL 查询配置。 -- `keys` ([Array](../../sql-reference/data-types/array.md)([Enum8](../../sql-reference/data-types/enum.md))) — 键指定配额的共享方式。如果两个连接使用相同的配额和键,则它们共享相同数量的资源。值: - - `[]` — 所有用户共享相同的配额。 - - `['user_name']` — 使用相同用户名的连接共享相同的配额。 - - `['ip_address']` — 来自相同 IP 的连接共享相同的配额。 - - `['client_key']` — 使用相同键的连接共享相同的配额。键必须由客户端明确提供。当使用 [clickhouse-client](../../interfaces/cli.md) 时,通过 `--quota_key` 参数传递键值,或在客户端配置文件中使用 `quota_key` 参数。当使用 HTTP 接口时,使用 `X-ClickHouse-Quota` 头。 - - `['user_name', 'client_key']` — 使用相同 `client_key` 的连接共享相同的配额。如果客户端未提供键,则配额按 `user_name` 跟踪。 - - `['client_key', 'ip_address']` — 使用相同 `client_key` 的连接共享相同的配额。如果客户端未提供键,则配额按 `ip_address` 跟踪。 -- `durations` ([Array](../../sql-reference/data-types/array.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 时间间隔长度(以秒为单位)。 -- `apply_to_all` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) — 逻辑值。显示配额适用于哪些用户。值: - - `0` — 配额适用于 `apply_to_list` 中指定的用户。 - - `1` — 配额适用于所有用户,除了 `apply_to_except` 中列出的用户。 -- `apply_to_list` ([Array](../../sql-reference/data-types/array.md)([String](../../sql-reference/data-types/string.md))) — 配额应适用的用户名/[roles](../../guides/sre/user-management/index.md#role-management) 列表。 -- `apply_to_except` ([Array](../../sql-reference/data-types/array.md)([String](../../sql-reference/data-types/string.md))) — 配额不应适用的用户名/角色列表。 +- `storage` ([String](../../sql-reference/data-types/string.md)) — 配额的存储。可能的值:如果在 users.xml 文件中配置了配额,则为 "users.xml";如果通过 SQL 查询配置了配额,则为 "disk"。 +- `keys` ([Array](../../sql-reference/data-types/array.md)([Enum8](../../sql-reference/data-types/enum.md))) — 关键字指定配额应如何共享。如果两个连接使用相同的配额和关键字,则它们共享相同数量的资源。值: + - `[]` — 所有用户共享相同的配额。 + - `['user_name']` — 同一用户名的连接共享相同的配额。 + - `['ip_address']` — 来自同一 IP 的连接共享相同的配额。 + - `['client_key']` — 具有相同关键字的连接共享相同的配额。关键字必须由客户端明确提供。当使用 [clickhouse-client](../../interfaces/cli.md) 时,在 `--quota_key` 参数中传递关键字值,或在客户端配置文件中使用 `quota_key` 参数。当使用 HTTP 接口时,使用 `X-ClickHouse-Quota` 头。 + - `['user_name', 'client_key']` — 具有相同 `client_key` 的连接共享相同的配额。如果客户端没有提供关键字,则配额是为 `user_name` 进行跟踪。 + - `['client_key', 'ip_address']` — 具有相同 `client_key` 的连接共享相同的配额。如果客户端没有提供关键字,则配额是为 `ip_address` 进行跟踪。 +- `durations` ([Array](../../sql-reference/data-types/array.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 以秒为单位的时间间隔长度。 +- `apply_to_all` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) — 逻辑值。它显示配额适用于哪些用户。值: + - `0` — 配额适用于在 `apply_to_list` 中指定的用户。 + - `1` — 配额适用于除 `apply_to_except` 中列出之外的所有用户。 +- `apply_to_list` ([Array](../../sql-reference/data-types/array.md)([String](../../sql-reference/data-types/string.md))) — 应适用于配额的用户名/[角色](../../guides/sre/user-management/index.md#role-management) 列表。 +- `apply_to_except` ([Array](../../sql-reference/data-types/array.md)([String](../../sql-reference/data-types/string.md))) — 不应适用配额的用户名/角色列表。 ## 另见 {#see-also} diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/quotas.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/quotas.md.hash index cb01f38c5da..620c8eecc69 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/quotas.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/quotas.md.hash @@ -1 +1 @@ -32882b8b9d41443e +bfad2c502975b3a3 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/quotas_usage.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/quotas_usage.md index c023f4fc815..ea7b6c9504d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/quotas_usage.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/quotas_usage.md @@ -1,11 +1,12 @@ --- -'description': '系统表包含有关所有用户配额使用的信息。' +'description': '系统表包含所有用户的配额使用情况的信息。' 'keywords': - 'system table' - 'quotas_usage' - 'quota' 'slug': '/operations/system-tables/quotas_usage' 'title': 'system.quotas_usage' +'doc_type': 'reference' --- import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_system_table_cloud.md'; @@ -23,28 +24,28 @@ import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/curre - `is_current` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) — 当前用户的配额使用情况。 - `start_time` ([Nullable](../../sql-reference/data-types/nullable.md)([DateTime](../../sql-reference/data-types/datetime.md)))) — 计算资源消耗的开始时间。 - `end_time` ([Nullable](../../sql-reference/data-types/nullable.md)([DateTime](../../sql-reference/data-types/datetime.md)))) — 计算资源消耗的结束时间。 -- `duration` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt32](../../sql-reference/data-types/int-uint.md))) — 计算资源消耗的时间区间长度,以秒为单位。 -- `queries` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 此时间区间内的请求总数。 +- `duration` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt32](../../sql-reference/data-types/int-uint.md))) — 计算资源消耗的时间间隔长度,单位为秒。 +- `queries` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 该时间段内的总请求数。 - `max_queries` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 最大请求数。 -- `query_selects` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 此时间区间内的 SELECT 请求总数。 -- `max_query_selects` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 最大 SELECT 请求数。 -- `query_inserts` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 此时间区间内的 INSERT 请求总数。 -- `max_query_inserts` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 最大 INSERT 请求数。 -- `errors` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 抛出异常的查询数量。 +- `query_selects` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 该时间段内的总选择请求数。 +- `max_query_selects` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 最大选择请求数。 +- `query_inserts` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 该时间段内的总插入请求数。 +- `max_query_inserts` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 最大插入请求数。 +- `errors` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 抛出异常的查询次数。 - `max_errors` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 最大错误数。 -- `result_rows` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 作为结果返回的总行数。 -- `max_result_rows` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 从表中读取的源行最大数。 -- `result_bytes` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 用于存储查询结果的内存量(以字节为单位)。 +- `result_rows` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 作为结果提供的总行数。 +- `max_result_rows` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 从表中读取的源行的最大数量。 +- `result_bytes` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 用于存储查询结果的字节数。 - `max_result_bytes` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 用于存储查询结果的最大内存量(以字节为单位)。 -- `read_rows` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md)))) — 在所有远程服务器上运行查询时,从表中读取的源行总数。 -- `max_read_rows` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 从所有表和参与查询的表函数中读取的最大行数。 -- `read_bytes` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 从所有参与查询的表和表函数中读取的字节总数。 +- `read_rows` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md)))) — 为在所有远程服务器上运行查询而从表中读取的总源行数。 +- `max_read_rows` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 从参与查询的所有表和表函数中读取的最大行数。 +- `read_bytes` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 从参与查询的所有表和表函数中读取的总字节数。 - `max_read_bytes` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 从所有表和表函数中读取的最大字节数。 - `failed_sequential_authentications` ([Nullable](../../sql-reference/data-types/nullable.md)([Float64](../../sql-reference/data-types/float.md))) — 连续身份验证失败的总次数。如果用户在超过 `failed_sequential_authentications` 阈值之前输入了正确的密码,则计数器将重置。 - `max_failed_sequential_authentications` ([Nullable](../../sql-reference/data-types/nullable.md)([Float64](../../sql-reference/data-types/float.md))) — 最大连续身份验证失败次数。 -- `execution_time` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/float.md))) — 查询的总执行时间,以秒为单位(墙钟时间)。 +- `execution_time` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/float.md))) — 查询的总执行时间,单位为秒(墙钟时间)。 - `max_execution_time` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/float.md))) — 查询执行时间的最大值。 -## See Also {#see-also} +## 另见 {#see-also} - [SHOW QUOTA](/sql-reference/statements/show#show-quota)) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/quotas_usage.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/quotas_usage.md.hash index 197c172beee..057d4e108b1 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/quotas_usage.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/quotas_usage.md.hash @@ -1 +1 @@ -6bf862184701ebcc +3ea381f4a88bf0cb diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/replicas.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/replicas.md index 5daf9c487f6..6d10f22d137 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/replicas.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/replicas.md @@ -1,16 +1,17 @@ --- -'description': '系统表,包含关于在本地服务器上驻留的副本表的信息和状态。对监控非常有用。' +'description': '系统表包含关于和状态的 replicated tables 在本地服务器上。对于监控非常有用。' 'keywords': - 'system table' - 'replicas' 'slug': '/operations/system-tables/replicas' 'title': 'system.replicas' +'doc_type': 'reference' --- # system.replicas -包含本地服务器上复制表的信息和状态。此表可用于监控。该表为每个 Replicated\* 表包含一行。 +包含本地服务器上复制表的信息和状态。该表可用于监控。该表为每个 Replicated\* 表包含一行。 示例: @@ -68,42 +69,42 @@ replica_is_active: {'r1':1,'r2':1} - `table` (`String`) - 表名称 - `engine` (`String`) - 表引擎名称 - `is_leader` (`UInt8`) - 副本是否为领导者。 - 多个副本可以同时为领导者。可以使用 `merge_tree` 设置 `replicated_can_become_leader` 防止副本成为领导者。领导者负责调度后台合并。 - 请注意,写入可以在任何可用副本上执行,只要该副本在 ZK 中有会话,无论其是否为领导者。 + 多个副本可以同时是领导者。可以通过 `merge_tree` 设置 `replicated_can_become_leader` 来阻止副本成为领导者。领导者负责调度后台合并。 + 注意,写入可以在任何可用且在 ZK 中有会话的副本上执行,而不管它是否为领导者。 - `can_become_leader` (`UInt8`) - 副本是否可以成为领导者。 - `is_readonly` (`UInt8`) - 副本是否处于只读模式。 - 如果配置中没有包含 ClickHouse Keeper 的部分,如果在重新初始化 ClickHouse Keeper 中的会话时发生未知错误,或者在 ClickHouse Keeper 中重新初始化会话时,此模式将开启。 + 如果配置中没有包含 ClickHouse Keeper 的部分,如果在重新初始化 ClickHouse Keeper 中的会话时发生未知错误,以及在 ClickHouse Keeper 中重新初始化会话时,则会开启此模式。 - `is_session_expired` (`UInt8`) - 与 ClickHouse Keeper 的会话已过期。基本上与 `is_readonly` 相同。 -- `future_parts` (`UInt32`) - 尚未完成的 INSERT 或合并将产生的数据部分数量。 -- `parts_to_check` (`UInt32`) - 等待验证的数据部分数量。如果怀疑某个分片可能损坏,则会将其放入验证队列。 +- `future_parts` (`UInt32`) - 将作为尚未完成的 INSERT 或合并的结果出现的数据部分数量。 +- `parts_to_check` (`UInt32`) - 等待验证的数据部分数量。如果怀疑某个部分可能损坏,则该部分放入验证队列中。 - `zookeeper_path` (`String`) - ClickHouse Keeper 中表数据的路径。 -- `replica_name` (`String`) - ClickHouse Keeper 中副本的名称。相同表的不同副本有不同的名称。 -- `replica_path` (`String`) - ClickHouse Keeper 中副本数据的路径。同 zookeeper_path/replicas/replica_path 的拼接。 -- `columns_version` (`Int32`) - 表结构的版本号。指示执行了多少次 ALTER。如果副本的版本不同,则表示某些副本尚未执行所有 ALTER。 -- `queue_size` (`UInt32`) - 等待执行的操作队列的大小。操作包括插入数据块、合并和其他某些操作。通常与 `future_parts` 一致。 -- `inserts_in_queue` (`UInt32`) - 需要进行的块数据插入数量。插入通常会相对快速地进行复制。如果此数字较大,则说明存在问题。 -- `merges_in_queue` (`UInt32`) - 等待进行的合并数量。有时合并很耗时,因此此值可能在很长时间内大于零。 -- `part_mutations_in_queue` (`UInt32`) - 等待进行的变更数量。 -- `queue_oldest_time` (`DateTime`) - 如果 `queue_size` 大于 0,显示最旧的操作何时添加到队列。 -- `inserts_oldest_time` (`DateTime`) - 见 `queue_oldest_time` -- `merges_oldest_time` (`DateTime`) - 见 `queue_oldest_time` -- `part_mutations_oldest_time` (`DateTime`) - 见 `queue_oldest_time` +- `replica_name` (`String`) - ClickHouse Keeper 中的副本名称。相同表的不同副本具有不同的名称。 +- `replica_path` (`String`) - ClickHouse Keeper 中副本数据的路径。与连接 'zookeeper_path/replicas/replica_path' 相同。 +- `columns_version` (`Int32`) - 表结构的版本号。指示 ALTER 操作执行的次数。如果副本具有不同的版本,表示某些副本尚未进行所有 ALTER。 +- `queue_size` (`UInt32`) - 等待执行操作的队列大小。操作包括插入数据块、合并和某些其他操作。通常与 `future_parts` 一致。 +- `inserts_in_queue` (`UInt32`) - 需要进行的数据块插入数量。插入通常复制的相当迅速。如果这个数字很大,意味着出现了问题。 +- `merges_in_queue` (`UInt32`) - 等待进行的合并数量。有时合并非常耗时,因此该值可能会长时间大于零。 +- `part_mutations_in_queue` (`UInt32`) - 等待进行的突变数量。 +- `queue_oldest_time` (`DateTime`) - 如果 `queue_size` 大于 0,显示最早操作被添加到队列的时间。 +- `inserts_oldest_time` (`DateTime`) - 参见 `queue_oldest_time` +- `merges_oldest_time` (`DateTime`) - 参见 `queue_oldest_time` +- `part_mutations_oldest_time` (`DateTime`) - 参见 `queue_oldest_time` -接下来的 4 列仅在与 ZK 有活动会话时才会有非零值。 +接下来的 4 列仅在与 ZK 有活动会话的情况下具有非零值。 -- `log_max_index` (`UInt64`) - 通用活动日志中的最大条目号。 -- `log_pointer` (`UInt64`) - 副本已复制到执行队列的通用活动日志的最大条目号加一。如果 `log_pointer` 远小于 `log_max_index`,则说明存在问题。 -- `last_queue_update` (`DateTime`) - 队列最后一次更新的时间。 -- `absolute_delay` (`UInt64`) - 当前副本的延迟(以秒为单位)。 +- `log_max_index` (`UInt64`) - 一般活动日志中最大条目编号。 +- `log_pointer` (`UInt64`) - 副本复制到其执行队列的活动日志中最大条目编号,加一。如果 `log_pointer` 远小于 `log_max_index`,则有问题。 +- `last_queue_update` (`DateTime`) - 上次更新队列的时间。 +- `absolute_delay` (`UInt64`) - 当前副本的延迟,单位为秒。 - `total_replicas` (`UInt8`) - 此表的已知副本总数。 -- `active_replicas` (`UInt8`) - 具有 ClickHouse Keeper 会话的此表副本数量(即,正常工作的副本数量)。 -- `lost_part_count` (`UInt64`) - 自表创建以来,所有副本在表中丢失的数据部分数量。该值在 ClickHouse Keeper 中持久保存,并且只能增加。 -- `last_queue_update_exception` (`String`) - 当队列包含损坏条目时的情况。这在 ClickHouse 在版本间打破向后兼容性时尤为重要,因为新版本写入的日志条目无法被旧版本解析。 -- `zookeeper_exception` (`String`) - 从 ClickHouse Keeper 获取信息时发生错误的最后异常消息。 -- `replica_is_active` ([Map(String, UInt8)](../../sql-reference/data-types/map.md)) — 副本名称与副本是否活动之间的映射。 +- `active_replicas` (`UInt8`) - 此表在 ClickHouse Keeper 中有会话的副本数量(即正常工作的副本数量)。 +- `lost_part_count` (`UInt64`) - 自表创建以来,所有副本中丢失的数据部分数量。该值保存在 ClickHouse Keeper 中,只会增加。 +- `last_queue_update_exception` (`String`) - 当队列包含损坏的条目时。尤其重要,当 ClickHouse 在版本之间打破向后兼容性,并且新版本写入的日志条目不能被旧版本解析时。 +- `zookeeper_exception` (`String`) - 最后一次异常消息,如果在从 ClickHouse Keeper 获取信息时发生错误。 +- `replica_is_active` ([Map(String, UInt8)](../../sql-reference/data-types/map.md)) — 副本名称与副本是否处于活动状态之间的映射。 -如果请求所有列,表的性能可能会稍慢,因为每一行都需要从 ClickHouse Keeper 进行多次读取。 -如果不请求最后 4 列(log_max_index, log_pointer, total_replicas, active_replicas),表的性能则会很快。 +如果您请求所有列,表的性能可能会稍慢,因为每一行都需要执行多次与 ClickHouse Keeper 的读取。 +如果您不请求最后 4 列(log_max_index,log_pointer,total_replicas,active_replicas),表的性能会更快。 例如,您可以这样检查一切是否正常: @@ -137,4 +138,4 @@ WHERE OR active_replicas < total_replicas ``` -如果此查询未返回任何内容,则表示一切正常。 +如果此查询不返回任何内容,则表示一切正常。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/replicas.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/replicas.md.hash index a8bb3c99c5e..2a9f4a32a67 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/replicas.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/replicas.md.hash @@ -1 +1 @@ -3477473f7779d40d +88a2185cde0b3d78 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/replicated_fetches.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/replicated_fetches.md index 572a46e13a8..5cc9c39e72a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/replicated_fetches.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/replicated_fetches.md @@ -1,10 +1,11 @@ --- -'description': '系统表包含关于当前正在运行的后台提取的信息。' +'description': '系统表包含有关当前正在运行的后台提取的信息。' 'keywords': - 'system table' - 'replicated_fetches' 'slug': '/operations/system-tables/replicated_fetches' 'title': 'system.replicated_fetches' +'doc_type': 'reference' --- import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_system_table_cloud.md'; @@ -14,7 +15,7 @@ import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/curre -包含当前正在运行的后台获取的相关信息。 +包含有关当前正在运行的后台拉取的信息。 列: @@ -22,13 +23,13 @@ import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/curre - `table` ([String](../../sql-reference/data-types/string.md)) — 表的名称。 -- `elapsed` ([Float64](../../sql-reference/data-types/float.md)) — 自显示当前运行的后台获取开始以来经过的时间(以秒为单位)。 +- `elapsed` ([Float64](../../sql-reference/data-types/float.md)) — 自当前正在运行的后台拉取开始以来的经过时间(以秒为单位)。 - `progress` ([Float64](../../sql-reference/data-types/float.md)) — 完成工作的百分比,从 0 到 1。 -- `result_part_name` ([String](../../sql-reference/data-types/string.md)) — 作为显示当前运行的后台获取结果形成的部分的名称。 +- `result_part_name` ([String](../../sql-reference/data-types/string.md)) — 作为当前正在运行的后台拉取结果形成的部分的名称。 -- `result_part_path` ([String](../../sql-reference/data-types/string.md)) — 作为显示当前运行的后台获取结果形成的部分的绝对路径。 +- `result_part_path` ([String](../../sql-reference/data-types/string.md)) — 作为当前正在运行的后台拉取结果形成的部分的绝对路径。 - `partition_id` ([String](../../sql-reference/data-types/string.md)) — 分区的 ID。 @@ -46,7 +47,7 @@ import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/curre - `URI` ([String](../../sql-reference/data-types/string.md)) — 统一资源标识符。 -- `to_detached` ([UInt8](../../sql-reference/data-types/int-uint.md)) — 标志指示当前运行的后台获取是否使用 `TO DETACHED` 表达式执行。 +- `to_detached` ([UInt8](../../sql-reference/data-types/int-uint.md)) — 标志指示当前正在运行的后台拉取是否使用 `TO DETACHED` 表达式执行。 - `thread_id` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 线程标识符。 @@ -77,6 +78,6 @@ to_detached: 0 thread_id: 54 ``` -**另见** +**另请参见** - [管理 ReplicatedMergeTree 表](../../sql-reference/statements/system.md/#managing-replicatedmergetree-tables) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/replicated_fetches.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/replicated_fetches.md.hash index 49aa35bcde0..019f8148a90 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/replicated_fetches.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/replicated_fetches.md.hash @@ -1 +1 @@ -f819f3c22cabf515 +6c4fc11645c3b3b3 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/replication_queue.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/replication_queue.md index 52eea8be3a8..911715f016d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/replication_queue.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/replication_queue.md @@ -1,69 +1,70 @@ --- -'description': '系统表包含关于存储在 ClickHouse Keeper 或 ZooKeeper 中的副本队列任务的信息,适用于 `ReplicatedMergeTree` - 系列的表。' +'description': '系统表包含来自 ClickHouse Keeper 或 ZooKeeper 的复制队列中关于 `ReplicatedMergeTree` + 家族表的任务信息。' 'keywords': - 'system table' - 'replication_queue' 'slug': '/operations/system-tables/replication_queue' 'title': 'system.replication_queue' +'doc_type': 'reference' --- # system.replication_queue -包含来自 ClickHouse Keeper 或 ZooKeeper 的复制队列中的任务信息,适用于 `ReplicatedMergeTree` 家族的表。 +包含来自 `ReplicatedMergeTree` 家族中表的复制队列的任务信息,这些信息存储在 ClickHouse Keeper 或 ZooKeeper 中。 列: -- `database` ([String](../../sql-reference/data-types/string.md)) — 数据库的名称。 +- `database` ([String](../../sql-reference/data-types/string.md)) — 数据库的名称。 -- `table` ([String](../../sql-reference/data-types/string.md)) — 表的名称。 +- `table` ([String](../../sql-reference/data-types/string.md)) — 表的名称。 -- `replica_name` ([String](../../sql-reference/data-types/string.md)) — ClickHouse Keeper 中的副本名称。同一表的不同副本具有不同的名称。 +- `replica_name` ([String](../../sql-reference/data-types/string.md)) — 在 ClickHouse Keeper 中的副本名称。同一表的不同副本有不同的名称。 -- `position` ([UInt32](../../sql-reference/data-types/int-uint.md)) — 队列中任务的位置。 +- `position` ([UInt32](../../sql-reference/data-types/int-uint.md)) — 队列中任务的位置。 -- `node_name` ([String](../../sql-reference/data-types/string.md)) — ClickHouse Keeper 中的节点名称。 +- `node_name` ([String](../../sql-reference/data-types/string.md)) — 在 ClickHouse Keeper 中的节点名称。 -- `type` ([String](../../sql-reference/data-types/string.md)) — 队列中任务的类型,之一: +- `type` ([String](../../sql-reference/data-types/string.md)) — 队列中任务的类型,可能是: - - `GET_PART` — 从另一个副本获取部分。 - - `ATTACH_PART` — 附加部分,可能来自我们自己的副本(如果在 `detached` 文件夹中找到)。你可以将其视为带有一些优化的 `GET_PART`,因为它们几乎是相同的。 - - `MERGE_PARTS` — 合并部分。 - - `DROP_RANGE` — 删除指定范围内指定分区的部分。 - - `CLEAR_COLUMN` — 注意:已弃用。从指定分区中删除特定列。 - - `CLEAR_INDEX` — 注意:已弃用。从指定分区中删除特定索引。 - - `REPLACE_RANGE` — 删除某个范围的部分并用新部分替换它们。 - - `MUTATE_PART` — 对部分应用一个或多个变更。 - - `ALTER_METADATA` — 根据全局的 /metadata 和 /columns 路径应用修改。 + - `GET_PART` — 从另一个副本获取分片。 + - `ATTACH_PART` — 附加分片,可能来自我们自己的副本(如在 `detached` 文件夹中找到)。你可以把它看作是带有某些优化的 `GET_PART`,因为它们几乎是相同的。 + - `MERGE_PARTS` — 合并分片。 + - `DROP_RANGE` — 删除指定范围内指定分区的分片。 + - `CLEAR_COLUMN` — 注意:已弃用。从指定分区中删除特定列。 + - `CLEAR_INDEX` — 注意:已弃用。从指定分区中删除特定索引。 + - `REPLACE_RANGE` — 删除某个范围的分片并用新的分片替换它们。 + - `MUTATE_PART` — 对分片应用一个或多个变更。 + - `ALTER_METADATA` — 根据全局 /metadata 和 /columns 路径应用修改。 -- `create_time` ([DateTime](../../sql-reference/data-types/datetime.md)) — 提交任务执行的日期和时间。 +- `create_time` ([DateTime](../../sql-reference/data-types/datetime.md)) — 提交执行任务的日期和时间。 -- `required_quorum` ([UInt32](../../sql-reference/data-types/int-uint.md)) — 等待任务完成并确认的副本数量。此列仅对 `GET_PARTS` 任务相关。 +- `required_quorum` ([UInt32](../../sql-reference/data-types/int-uint.md)) — 等待任务完成并确认的副本数量。此列仅与 `GET_PARTS` 任务相关。 -- `source_replica` ([String](../../sql-reference/data-types/string.md)) — 源副本的名称。 +- `source_replica` ([String](../../sql-reference/data-types/string.md)) — 源副本的名称。 -- `new_part_name` ([String](../../sql-reference/data-types/string.md)) — 新部分的名称。 +- `new_part_name` ([String](../../sql-reference/data-types/string.md)) — 新分片的名称。 -- `parts_to_merge` ([Array](../../sql-reference/data-types/array.md) ([String](../../sql-reference/data-types/string.md)) — 要合并或更新的部分名称。 +- `parts_to_merge` ([Array](../../sql-reference/data-types/array.md) ([String](../../sql-reference/data-types/string.md))) — 要合并或更新的分片名称。 -- `is_detach` ([UInt8](../../sql-reference/data-types/int-uint.md)) — 标志指示 `DETACH_PARTS` 任务是否在队列中。 +- `is_detach` ([UInt8](../../sql-reference/data-types/int-uint.md)) — 标志指示 `DETACH_PARTS` 任务是否在队列中。 -- `is_currently_executing` ([UInt8](../../sql-reference/data-types/int-uint.md)) — 标志指示特定任务是否正在执行。 +- `is_currently_executing` ([UInt8](../../sql-reference/data-types/int-uint.md)) — 标志指示是否正在执行特定任务。 -- `num_tries` ([UInt32](../../sql-reference/data-types/int-uint.md)) — 完成任务的失败尝试次数。 +- `num_tries` ([UInt32](../../sql-reference/data-types/int-uint.md)) — 完成任务的失败尝试次数。 -- `last_exception` ([String](../../sql-reference/data-types/string.md)) — 关于最后发生的错误的文本消息(如果有)。 +- `last_exception` ([String](../../sql-reference/data-types/string.md)) — 关于最后一次发生的错误的文本消息(如果有)。 -- `last_attempt_time` ([DateTime](../../sql-reference/data-types/datetime.md)) — 最近一次尝试任务的日期和时间。 +- `last_attempt_time` ([DateTime](../../sql-reference/data-types/datetime.md)) — 最后一次尝试执行任务的日期和时间。 -- `num_postponed` ([UInt32](../../sql-reference/data-types/int-uint.md)) — 动作被推迟的次数。 +- `num_postponed` ([UInt32](../../sql-reference/data-types/int-uint.md)) — 操作被推迟的次数。 -- `postpone_reason` ([String](../../sql-reference/data-types/string.md)) — 任务被推迟的原因。 +- `postpone_reason` ([String](../../sql-reference/data-types/string.md)) — 任务被推迟的原因。 -- `last_postpone_time` ([DateTime](../../sql-reference/data-types/datetime.md)) — 最近一次推迟任务的日期和时间。 +- `last_postpone_time` ([DateTime](../../sql-reference/data-types/datetime.md)) — 最后一次推迟任务的日期和时间。 -- `merge_type` ([String](../../sql-reference/data-types/string.md)) — 当前合并的类型。如果是变更则为空。 +- `merge_type` ([String](../../sql-reference/data-types/string.md)) — 当前合并的类型。如果是变更则为空。 **示例** @@ -95,6 +96,6 @@ postpone_reason: last_postpone_time: 1970-01-01 03:00:00 ``` -**另请参阅** +**另见** - [管理 ReplicatedMergeTree 表](/sql-reference/statements/system#managing-replicatedmergetree-tables) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/replication_queue.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/replication_queue.md.hash index 0d297f506d4..07b190594c5 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/replication_queue.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/replication_queue.md.hash @@ -1 +1 @@ -a4ec3eb44ab90af3 +20501ec8490746e5 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/resources.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/resources.md index 82c0a959092..0cb7639c3fc 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/resources.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/resources.md @@ -1,16 +1,17 @@ --- -'description': '系统表包含有关本地服务器上资源的信息,每个资源有一行.' +'description': '系统表包含关于本地服务器上资源的信息,每个资源有一行.' 'keywords': - 'system table' - 'resources' 'slug': '/operations/system-tables/resources' 'title': 'system.resources' +'doc_type': 'reference' --- # system.resources -包含有关位于本地服务器上的 [resources](/operations/workload-scheduling.md#workload_entity_storage) 的信息。该表为每个资源包含一行。 +包含有关[资源](/operations/workload-scheduling.md#workload_entity_storage)的信息,这些资源驻留在本地服务器上。该表为每个资源包含一行。 示例: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/resources.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/resources.md.hash index a8f409410ec..6fc49fd814e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/resources.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/resources.md.hash @@ -1 +1 @@ -b5c4e3dc36d4c0ad +a7b3d7bbaeedb241 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/role-grants.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/role-grants.md index 13091a53c37..f4795cf6485 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/role-grants.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/role-grants.md @@ -5,6 +5,7 @@ - 'role_grants' 'slug': '/operations/system-tables/role-grants' 'title': 'system.role_grants' +'doc_type': 'reference' --- @@ -18,12 +19,12 @@ - `role_name` ([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md))) — 角色名称。 -- `granted_role_name` ([String](../../sql-reference/data-types/string.md)) — 授予 `role_name` 角色的角色名称。要将一个角色授予另一个角色,请使用 `GRANT role1 TO role2`。 +- `granted_role_name` ([String](../../sql-reference/data-types/string.md)) — 授予给 `role_name` 角色的角色名称。要将一个角色授予另一个角色,使用 `GRANT role1 TO role2`。 -- `granted_role_is_default` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) — 显示 `granted_role` 是否是默认角色的标志。可能的值: - - 1 — `granted_role` 是默认角色。 - - 0 — `granted_role` 不是默认角色。 +- `granted_role_is_default` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) — 表示 `granted_role` 是否是默认角色的标志。可能的值: + - 1 — `granted_role` 是默认角色。 + - 0 — `granted_role` 不是默认角色。 -- `with_admin_option` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) — 显示 `granted_role` 是否具有 [ADMIN OPTION](/sql-reference/statements/grant#admin-option) 权限的标志。可能的值: - - 1 — 该角色具有 `ADMIN OPTION` 权限。 - - 0 — 该角色没有 `ADMIN OPTION` 权限。 +- `with_admin_option` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) — 表示 `granted_role` 是否是具有 [ADMIN OPTION](/sql-reference/statements/grant#admin-option) 特权的角色的标志。可能的值: + - 1 — 角色具有 `ADMIN OPTION` 特权。 + - 0 — 角色没有 `ADMIN OPTION` 特权。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/role-grants.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/role-grants.md.hash index 9267f40c351..e2f8ad692e6 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/role-grants.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/role-grants.md.hash @@ -1 +1 @@ -4735299fe95f0e3a +49da21955d912a4e diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/role_grants.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/role_grants.md new file mode 100644 index 00000000000..1aadce463cc --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/role_grants.md @@ -0,0 +1,30 @@ +--- +'description': '系统表包含用户和角色的角色授权。' +'keywords': +- 'system table' +- 'role_grants' +'slug': '/operations/system-tables/role_grants' +'title': 'system.role_grants' +'doc_type': 'reference' +--- + + +# system.role_grants + +包含用户和角色的角色授权。要向此表中添加条目,请使用 `GRANT role TO user`。 + +列: + +- `user_name` ([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md))) — 用户名。 + +- `role_name` ([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md))) — 角色名称。 + +- `granted_role_name` ([String](../../sql-reference/data-types/string.md)) — 授予 `role_name` 角色的角色名称。要将一个角色授予另一个角色,请使用 `GRANT role1 TO role2`。 + +- `granted_role_is_default` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) — 显示 `granted_role` 是否为默认角色的标志。可能的值: + - 1 — `granted_role` 是默认角色。 + - 0 — `granted_role` 不是默认角色。 + +- `with_admin_option` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) — 显示 `granted_role` 是否为具有 [ADMIN OPTION](/sql-reference/statements/grant#admin-option) 权限的角色的标志。可能的值: + - 1 — 该角色具有 `ADMIN OPTION` 权限。 + - 0 — 该角色没有 `ADMIN OPTION` 权限。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/role_grants.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/role_grants.md.hash new file mode 100644 index 00000000000..05e9945cf57 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/role_grants.md.hash @@ -0,0 +1 @@ +3847f86aa09e7c14 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/roles.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/roles.md index 25f0034026a..0998b7db202 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/roles.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/roles.md @@ -1,23 +1,24 @@ --- -'description': '系统表包含关于已配置角色的信息。' +'description': '系统表,包含有关已配置角色的信息。' 'keywords': - 'system table' - 'roles' 'slug': '/operations/system-tables/roles' 'title': 'system.roles' +'doc_type': 'reference' --- # system.roles -包含有关配置的 [roles](../../guides/sre/user-management/index.md#role-management) 的信息。 +包含关于配置的 [roles](../../guides/sre/user-management/index.md#role-management) 的信息。 列: - `name` ([String](../../sql-reference/data-types/string.md)) — 角色名称。 - `id` ([UUID](../../sql-reference/data-types/uuid.md)) — 角色 ID。 -- `storage` ([String](../../sql-reference/data-types/string.md)) — 角色存储的路径。 在 `access_control_path` 参数中配置。 +- `storage` ([String](../../sql-reference/data-types/string.md)) — 角色存储的路径。配置在 `access_control_path` 参数中。 -## 另请参阅 {#see-also} +## 另见 {#see-also} - [SHOW ROLES](/sql-reference/statements/show#show-roles) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/roles.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/roles.md.hash index 9b85b8d5176..88ebb153869 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/roles.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/roles.md.hash @@ -1 +1 @@ -4e3caa25c4a2cfbb +5778b5ea87db7bc5 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/row_policies.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/row_policies.md index 73e3f654a69..d30e9360e99 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/row_policies.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/row_policies.md @@ -5,6 +5,7 @@ - 'row_policies' 'slug': '/operations/system-tables/row_policies' 'title': 'system.row_policies' +'doc_type': 'reference' --- @@ -15,27 +16,27 @@ 列: - `name` ([String](../../sql-reference/data-types/string.md)) — 行策略的名称。 -- `short_name` ([String](../../sql-reference/data-types/string.md)) — 行策略的短名称。行策略的名称是复合的,例如:myfilter ON mydb.mytable。这里 "myfilter ON mydb.mytable" 是行策略的名称,"myfilter" 是它的短名称。 +- `short_name` ([String](../../sql-reference/data-types/string.md)) — 行策略的简短名称。行策略的名称是复合的,例如:myfilter ON mydb.mytable。在这里,“myfilter ON mydb.mytable”是行策略的名称,“myfilter”是它的简短名称。 - `database` ([String](../../sql-reference/data-types/string.md)) — 数据库名称。 -- `table` ([String](../../sql-reference/data-types/string.md)) — 表名称。如果是数据库的策略则为空。 +- `table` ([String](../../sql-reference/data-types/string.md)) — 表名称。如果是数据库的策略,则为空。 -- `id` ([UUID](../../sql-reference/data-types/uuid.md)) — 行策略 ID。 +- `id` ([UUID](../../sql-reference/data-types/uuid.md)) — 行策略的 ID。 -- `storage` ([String](../../sql-reference/data-types/string.md)) — 存储行策略的目录名称。 +- `storage` ([String](../../sql-reference/data-types/string.md)) — 行策略存储的目录名称。 - `select_filter` ([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md))) — 用于过滤行的条件。 -- `is_restrictive` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) — 表示行策略是否限制对行的访问,见 [CREATE ROW POLICY](/sql-reference/statements/create/row-policy)。值: - - `0` — 行策略是使用 `AS PERMISSIVE` 子句定义的。 - - `1` — 行策略是使用 `AS RESTRICTIVE` 子句定义的。 +- `is_restrictive` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) — 显示行策略是否限制对行的访问,参见 [CREATE ROW POLICY](/sql-reference/statements/create/row-policy)。值: + - `0` — 行策略是,与 `AS PERMISSIVE` 子句一起定义。 + - `1` — 行策略是,与 `AS RESTRICTIVE` 子句一起定义。 -- `apply_to_all` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) — 表示该行策略适用于所有角色和/或用户。 +- `apply_to_all` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) — 显示此行策略适用于所有角色和/或用户。 -- `apply_to_list` ([Array](../../sql-reference/data-types/array.md)([String](../../sql-reference/data-types/string.md))) — 应用该行策略的角色和/或用户列表。 +- `apply_to_list` ([Array](../../sql-reference/data-types/array.md)([String](../../sql-reference/data-types/string.md))) — 适用行策略的角色和/或用户列表。 -- `apply_to_except` ([Array](../../sql-reference/data-types/array.md)([String](../../sql-reference/data-types/string.md))) — 行策略适用于所有角色和/或用户,但不包括列出的角色和/或用户。 +- `apply_to_except` ([Array](../../sql-reference/data-types/array.md)([String](../../sql-reference/data-types/string.md))) — 此行策略适用于所有角色和/或用户,但不包括列出的角色和/或用户。 ## See Also {#see-also} diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/row_policies.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/row_policies.md.hash index 0d52f67e3ed..a99ad7bf6ee 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/row_policies.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/row_policies.md.hash @@ -1 +1 @@ -1462c1a6adfef2ed +d85ddaf06a5236a0 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/s3_queue_settings.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/s3_queue_settings.md index 17e3591a7c3..6eeabafe406 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/s3_queue_settings.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/s3_queue_settings.md @@ -1,26 +1,27 @@ --- -'description': '系统表包含关于 S3Queue 表设置的信息。从服务器版本 `24.10` 开始可用。' +'description': '系统表包含有关 S3Queue 表设置的信息。可从服务器版本 `24.10` 获取。' 'keywords': - 'system table' - 's3_queue_settings' 'slug': '/operations/system-tables/s3_queue_settings' 'title': 'system.s3_queue_settings' +'doc_type': 'reference' --- # system.s3_queue_settings -包含有关 [S3Queue](../../engines/table-engines/integrations/s3queue.md) 表的设置的信息。从服务器版本 `24.10` 开始可用。 +包含有关[S3Queue](../../engines/table-engines/integrations/s3queue.md) 表的设置的信息。自服务器版本 `24.10` 起可用。 列: -- `database` ([String](../../sql-reference/data-types/string.md)) — 表名称。 -- `table` ([String](../../sql-reference/data-types/string.md)) — 数据库名称。 +- `database` ([String](../../sql-reference/data-types/string.md)) — 表名。 +- `table` ([String](../../sql-reference/data-types/string.md)) — 数据库名。 - `name` ([String](../../sql-reference/data-types/string.md)) — 设置名称。 - `value` ([String](../../sql-reference/data-types/string.md)) — 设置值。 -- `changed` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) — 设置是否在配置中明确定义或被显式更改。 +- `changed` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) — 设置是否在配置中显式定义或显式更改。 - `description` ([String](../../sql-reference/data-types/string.md)) — 设置描述。 -- `alterable` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) — 显示设置是否可以通过 `ALTER TABLE ... MODIFY SETTING` 进行更改。 - - `0` — 当前用户可以更改该设置。 - - `1` — 当前用户不能更改该设置。 -- `type` ([String](../../sql-reference/data-types/string.md)) — 设置类型(实现特定字符串值)。 +- `alterable` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) — 显示设置是否可以通过 `ALTER TABLE ... MODIFY SETTING` 更改。 + - `0` — 当前用户可以更改设置。 + - `1` — 当前用户无法更改设置。 +- `type` ([String](../../sql-reference/data-types/string.md)) — 设置类型(特定于实现的字符串值)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/s3_queue_settings.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/s3_queue_settings.md.hash index 0d7944fd1f5..c3f1af8a4a0 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/s3_queue_settings.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/s3_queue_settings.md.hash @@ -1 +1 @@ -24de0de56d826d66 +d60984804273ae60 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/scheduler.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/scheduler.md index 70d0a1bb3b7..4f60e01fca5 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/scheduler.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/scheduler.md @@ -1,10 +1,11 @@ --- -'description': '系统表,包含有关本地服务器上调度节点的信息和状态。' +'description': '系统表,包含关于本地服务器上调度节点的信息和状态。' 'keywords': - 'system table' - 'scheduler' 'slug': '/operations/system-tables/scheduler' 'title': 'system.scheduler' +'doc_type': 'reference' --- import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_system_table_cloud.md'; @@ -14,8 +15,8 @@ import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/curre -包含有关本地服务器上[调度节点](/operations/workload-scheduling.md/#hierarchy)的信息和状态。 -此表可用于监控。该表为每个调度节点包含一行。 +包含有关本地服务器上驻留的[scheduling nodes](/operations/workload-scheduling.md/#hierarchy)的信息和状态。 +该表可用于监控。表中为每个调度节点包含一行。 示例: @@ -63,25 +64,25 @@ tokens: ᴺᵁᴸᴸ - `path` (`String`) - 在该资源调度层次结构中调度节点的路径 - `type` (`String`) - 调度节点的类型。 - `weight` (`Float64`) - 节点的权重,由`fair`类型的父节点使用。 -- `priority` (`Int64`) - 节点的优先级,由'priority'类型的父节点使用(值越低,优先级越高)。 -- `is_active` (`UInt8`) - 此节点当前是否处于活动状态 - 有资源请求待出队且约束条件满足。 +- `priority` (`Int64`) - 节点的优先级,由'priority'类型的父节点使用(较低的值意味着更高的优先级)。 +- `is_active` (`UInt8`) - 此节点当前是否处于活动状态 - 是否有待解除排队的资源请求,并且约束条件已满足。 - `active_children` (`UInt64`) - 处于活动状态的子节点数量。 -- `dequeued_requests` (`UInt64`) - 从该节点出队的资源请求总数。 -- `canceled_requests` (`UInt64`) - 从该节点取消的资源请求总数。 -- `dequeued_cost` (`UInt64`) - 从该节点出队的所有请求的成本总和(例如,以字节为单位的大小)。 -- `canceled_cost` (`UInt64`) - 从该节点取消的所有请求的成本总和(例如,以字节为单位的大小)。 -- `busy_periods` (`UInt64`) - 此节点的总去激活次数。 -- `vruntime` (`Nullable(Float64)`) - 仅针对`fair`节点的子节点。用于SFQ算法以最大最小公平方式选择下一个要处理的子节点的虚拟运行时间。 -- `system_vruntime` (`Nullable(Float64)`) - 仅针对`fair`节点。显示上一个已处理资源请求的`vruntime`的虚拟运行时间。在子节点激活期间用作`vruntime`的新值。 -- `queue_length` (`Nullable(UInt64)`) - 仅针对`fifo`节点。当前队列中驻留的资源请求数量。 -- `queue_cost` (`Nullable(UInt64)`) - 仅针对`fifo`节点。队列中所有请求的成本总和(例如,以字节为单位的大小)。 -- `budget` (`Nullable(Int64)`) - 仅针对`fifo`节点。可用于新资源请求的“成本单位”数量。在资源请求的估计成本和实际成本不一致的情况下可能会出现(例如,在读/写失败后)。 -- `is_satisfied` (`Nullable(UInt8)`) - 仅针对约束节点(例如`inflight_limit`)。如果该节点的所有约束条件都满足,则等于`1`。 -- `inflight_requests` (`Nullable(Int64)`) - 仅针对`inflight_limit`节点。从该节点出队的资源请求数量,这些请求当前处于消费状态。 -- `inflight_cost` (`Nullable(Int64)`) - 仅针对`inflight_limit`节点。从该节点出队的所有资源请求的成本总和(例如,字节),这些请求当前处于消费状态。 -- `max_requests` (`Nullable(Int64)`) - 仅针对`inflight_limit`节点。导致约束违反的`inflight_requests`的上限。 -- `max_cost` (`Nullable(Int64)`) - 仅针对`inflight_limit`节点。导致约束违反的`inflight_cost`的上限。 -- `max_speed` (`Nullable(Float64)`) - 仅针对`bandwidth_limit`节点。每秒的带宽上限,以令牌计。 -- `max_burst` (`Nullable(Float64)`) - 仅针对`bandwidth_limit`节点。在令牌桶节流器中可用的`tokens`上限。 -- `throttling_us` (`Nullable(Int64)`) - 仅针对`bandwidth_limit`节点。此节点处于节流状态的微秒总数。 -- `tokens` (`Nullable(Float64)`) - 仅针对`bandwidth_limit`节点。在令牌桶节流器中当前可用的令牌数量。 +- `dequeued_requests` (`UInt64`) - 从此节点解除排队的资源请求总数。 +- `canceled_requests` (`UInt64`) - 从此节点取消的资源请求总数。 +- `dequeued_cost` (`UInt64`) - 从此节点解除排队的所有请求的成本之和(例如,字节大小)。 +- `canceled_cost` (`UInt64`) - 从此节点取消的所有请求的成本之和(例如,字节大小)。 +- `busy_periods` (`UInt64`) - 此节点的总停用次数。 +- `vruntime` (`Nullable(Float64)`) - 仅适用于`fair`节点的子节点。节点的虚拟运行时间,由SFQ算法在最大最小公平的方式中选择下一个要处理的子节点。 +- `system_vruntime` (`Nullable(Float64)`) - 仅适用于`fair`节点。显示最后处理的资源请求的`vruntime`的虚拟运行时间。在子节点激活过程中,作为`vruntime`的新值使用。 +- `queue_length` (`Nullable(UInt64)`) - 仅适用于`fifo`节点。当前队列中驻留的资源请求数量。 +- `queue_cost` (`Nullable(UInt64)`) - 仅适用于`fifo`节点。队列中所有请求的成本之和(例如,字节大小)。 +- `budget` (`Nullable(Int64)`) - 仅适用于`fifo`节点。新资源请求的可用“成本单位”数量。在估计的资源请求成本与实际成本不一致的情况下(例如,发生读/写失败时)可能会出现。 +- `is_satisfied` (`Nullable(UInt8)`) - 仅适用于约束节点(例如,`inflight_limit`)。如果此节点的所有约束都已满足,则等于`1`。 +- `inflight_requests` (`Nullable(Int64)`) - 仅适用于`inflight_limit`节点。从此节点解除排队的、当前处于消费状态的资源请求数量。 +- `inflight_cost` (`Nullable(Int64)`) - 仅适用于`inflight_limit`节点。从此节点解除排队的、当前处于消费状态的所有资源请求的成本之和(例如,字节)。 +- `max_requests` (`Nullable(Int64)`) - 仅适用于`inflight_limit`节点。导致约束违反的`inflight_requests`的上限。 +- `max_cost` (`Nullable(Int64)`) - 仅适用于`inflight_limit`节点。导致约束违反的`inflight_cost`的上限。 +- `max_speed` (`Nullable(Float64)`) - 仅适用于`bandwidth_limit`节点。每秒令牌的带宽上限。 +- `max_burst` (`Nullable(Float64)`) - 仅适用于`bandwidth_limit`节点。令牌桶限速器中可用的`tokens`的上限。 +- `throttling_us` (`Nullable(Int64)`) - 仅适用于`bandwidth_limit`节点。此节点处于限速状态的总微秒数。 +- `tokens` (`Nullable(Float64)`) - 仅适用于`bandwidth_limit`节点。令牌桶限速器中当前可用的令牌数量。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/scheduler.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/scheduler.md.hash index ef20defd876..05d66efe91d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/scheduler.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/scheduler.md.hash @@ -1 +1 @@ -796d7f09bf3f2071 +57a91bf77b3f42c1 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/schema_inference_cache.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/schema_inference_cache.md index 902a1b05ae0..2f91d834320 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/schema_inference_cache.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/schema_inference_cache.md @@ -5,6 +5,7 @@ - 'schema_inference_cache' 'slug': '/operations/system-tables/schema_inference_cache' 'title': 'system.schema_inference_cache' +'doc_type': 'reference' --- import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_system_table_cloud.md'; @@ -14,14 +15,14 @@ import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/curre -包含所有缓存文件模式的信息。 +包含有关所有缓存文件模式的信息。 列: -- `storage` ([String](/sql-reference/data-types/string.md)) — 存储名称:File、URL、S3 或 HDFS。 +- `storage` ([String](/sql-reference/data-types/string.md)) — 存储名称:File, URL, S3 或 HDFS。 - `source` ([String](/sql-reference/data-types/string.md)) — 文件来源。 - `format` ([String](/sql-reference/data-types/string.md)) — 格式名称。 -- `additional_format_info` ([String](/sql-reference/data-types/string.md)) - 识别模式所需的附加信息。例如,特定格式的设置。 -- `registration_time` ([DateTime](/sql-reference/data-types/datetime.md)) — 模式添加到缓存的时间戳。 +- `additional_format_info` ([String](/sql-reference/data-types/string.md)) - 识别模式所需的附加信息。例如,特定于格式的设置。 +- `registration_time` ([DateTime](/sql-reference/data-types/datetime.md)) — 模式加入缓存时的时间戳。 - `schema` ([String](/sql-reference/data-types/string.md)) - 缓存模式。 **示例** @@ -35,8 +36,7 @@ import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/curre ``` :::tip -将 `data.jsonl` 放在 `user_files_path` 目录中。 你可以通过查看 -你的 ClickHouse 配置文件来找到这个路径。 默认路径是: +将 `data.jsonl` 放置在 `user_files_path` 目录中。您可以通过查看您的 ClickHouse 配置文件来找到此目录。默认值为: ```sql /var/lib/clickhouse/user_files/ ``` @@ -75,6 +75,5 @@ registration_time: 2022-12-29 17:49:52 schema: id Nullable(Float64), age Nullable(Float64), name Nullable(String), hobbies Array(Nullable(String)) ``` - -**另见** -- [从输入数据自动推断模式](/interfaces/schema-inference.md) +**另请参见** +- [来自输入数据的自动模式推断](/interfaces/schema-inference.md) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/schema_inference_cache.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/schema_inference_cache.md.hash index f2a8151259e..4783c68158d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/schema_inference_cache.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/schema_inference_cache.md.hash @@ -1 +1 @@ -f36a2798f5ce823c +a642a03013b3774d diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/server_settings.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/server_settings.md index e2040b5aa53..959d9644250 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/server_settings.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/server_settings.md @@ -1,10 +1,11 @@ --- -'description': '系统表包含关于服务器的全局设置的信息,这些设置在 `config.xml` 中指定。' +'description': '系统表包含有关服务器的全局设置的信息,这些设置在 `config.xml` 中指定。' 'keywords': - 'system table' - 'server_settings' 'slug': '/operations/system-tables/server_settings' 'title': 'system.server_settings' +'doc_type': 'reference' --- import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_system_table_cloud.md'; @@ -14,22 +15,22 @@ import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/curre -包含关于服务器的全局设置的信息,这些设置在 `config.xml` 中指定。目前,该表仅显示 `config.xml` 第一个层级的设置,并不支持嵌套配置(例如 [logger](../../operations/server-configuration-parameters/settings.md#logger))。 +包含关于服务器全局设置的信息,这些设置在 `config.xml` 中指定。目前,此表仅显示 `config.xml` 中第一层的设置,并不支持嵌套配置(例如 [logger](../../operations/server-configuration-parameters/settings.md#logger))。 列: - `name` ([String](../../sql-reference/data-types/string.md)) — 服务器设置名称。 - `value` ([String](../../sql-reference/data-types/string.md)) — 服务器设置值。 - `default` ([String](../../sql-reference/data-types/string.md)) — 服务器设置默认值。 -- `changed` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) — 显示某个设置是否在 `config.xml` 中指定。 +- `changed` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) — 显示设置是否在 `config.xml` 中指定。 - `description` ([String](../../sql-reference/data-types/string.md)) — 短的服务器设置描述。 -- `type` ([String](../../sql-reference/data-types/string.md)) — 服务器设置值的类型。 -- `changeable_without_restart` ([Enum8](../../sql-reference/data-types/enum.md)) — 是否可以在服务器运行时更改该设置。值: - - `'No' ` - - `'IncreaseOnly'` - - `'DecreaseOnly'` - - `'Yes'` -- `is_obsolete` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) - 显示某个设置是否已过时。 +- `type` ([String](../../sql-reference/data-types/string.md)) — 服务器设置值类型。 +- `changeable_without_restart` ([Enum8](../../sql-reference/data-types/enum.md)) — 设置在服务器运行时是否可以更改。值: + - `'No' ` + - `'IncreaseOnly'` + - `'DecreaseOnly'` + - `'Yes'` +- `is_obsolete` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) - 显示设置是否已过时。 **示例** @@ -60,7 +61,7 @@ WHERE name LIKE '%thread_pool%' ``` -使用 `WHERE changed` 可能很有用,例如当您想检查配置文件中的设置是否正确加载并且正在使用时。 +使用 `WHERE changed` 可以很有用,例如,当你想检查配置文件中的设置是否正确加载并正在使用时。 @@ -68,8 +69,8 @@ WHERE name LIKE '%thread_pool%' SELECT * FROM system.server_settings WHERE changed AND name='max_thread_pool_size' ``` -**另见** +**另请参见** -- [Settings](../../operations/system-tables/settings.md) -- [Configuration Files](../../operations/configuration-files.md) -- [Server Settings](../../operations/server-configuration-parameters/settings.md) +- [设置](../../operations/system-tables/settings.md) +- [配置文件](../../operations/configuration-files.md) +- [服务器设置](../../operations/server-configuration-parameters/settings.md) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/server_settings.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/server_settings.md.hash index 14487b520c1..39301bcc640 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/server_settings.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/server_settings.md.hash @@ -1 +1 @@ -a022d90cbcd8fc69 +d6cb79f9f52e1f7b diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/session_log.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/session_log.md index 97c42d86420..b4c6c1c4fa9 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/session_log.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/session_log.md @@ -5,6 +5,7 @@ - 'session_log' 'slug': '/operations/system-tables/session_log' 'title': 'system.session_log' +'doc_type': 'reference' --- import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_system_table_cloud.md'; @@ -14,45 +15,45 @@ import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/curre -包含有关所有成功和失败的登录和登出事件的信息。 +包含所有成功和失败的登录和登出事件的信息。 列: - `hostname` ([LowCardinality(String)](../../sql-reference/data-types/string.md)) — 执行查询的服务器的主机名。 - `type` ([Enum8](../../sql-reference/data-types/enum.md)) — 登录/登出结果。可能的值: - - `LoginFailure` — 登录错误。 - - `LoginSuccess` — 成功登录。 - - `Logout` — 从系统中登出。 -- `auth_id` ([UUID](../../sql-reference/data-types/uuid.md)) — 身份验证 ID,这是每次用户登录时自动生成的 UUID。 -- `session_id` ([String](../../sql-reference/data-types/string.md)) — 由客户端通过 [HTTP](../../interfaces/http.md) 接口传递的会话 ID。 + - `LoginFailure` — 登录错误。 + - `LoginSuccess` — 成功登录。 + - `Logout` — 从系统登出。 +- `auth_id` ([UUID](../../sql-reference/data-types/uuid.md)) — 认证 ID,这是一个每次用户登录时自动生成的 UUID。 +- `session_id` ([String](../../sql-reference/data-types/string.md)) — 通过 [HTTP](../../interfaces/http.md) 接口由客户端传递的会话 ID。 - `event_date` ([Date](../../sql-reference/data-types/date.md)) — 登录/登出日期。 - `event_time` ([DateTime](../../sql-reference/data-types/datetime.md)) — 登录/登出时间。 -- `event_time_microseconds` ([DateTime64](../../sql-reference/data-types/datetime64.md)) — 登录/登出开始时间,具有微秒精度。 +- `event_time_microseconds` ([DateTime64](../../sql-reference/data-types/datetime64.md)) — 登录/登出的起始时间,精确到微秒。 - `user` ([String](../../sql-reference/data-types/string.md)) — 用户名。 - `auth_type` ([Enum8](../../sql-reference/data-types/enum.md)) — 身份验证类型。可能的值: - - `NO_PASSWORD` - - `PLAINTEXT_PASSWORD` - - `SHA256_PASSWORD` - - `DOUBLE_SHA1_PASSWORD` - - `LDAP` - - `KERBEROS` - - `SSL_CERTIFICATE` + - `NO_PASSWORD` + - `PLAINTEXT_PASSWORD` + - `SHA256_PASSWORD` + - `DOUBLE_SHA1_PASSWORD` + - `LDAP` + - `KERBEROS` + - `SSL_CERTIFICATE` - `profiles` ([Array](../../sql-reference/data-types/array.md)([LowCardinality(String)](../../sql-reference/data-types/lowcardinality.md))) — 为所有角色和/或用户设置的配置文件列表。 - `roles` ([Array](../../sql-reference/data-types/array.md)([LowCardinality(String)](../../sql-reference/data-types/lowcardinality.md))) — 应用配置文件的角色列表。 - `settings` ([Array](../../sql-reference/data-types/array.md)([Tuple](../../sql-reference/data-types/tuple.md)([LowCardinality(String)](../../sql-reference/data-types/lowcardinality.md), [String](../../sql-reference/data-types/string.md)))) — 客户端登录/登出时更改的设置。 - `client_address` ([IPv6](../../sql-reference/data-types/ipv6.md)) — 用于登录/登出的 IP 地址。 - `client_port` ([UInt16](../../sql-reference/data-types/int-uint.md)) — 用于登录/登出的客户端端口。 - `interface` ([Enum8](../../sql-reference/data-types/enum.md)) — 登录发起的接口。可能的值: - - `TCP` - - `HTTP` - - `gRPC` - - `MySQL` - - `PostgreSQL` + - `TCP` + - `HTTP` + - `gRPC` + - `MySQL` + - `PostgreSQL` - `client_hostname` ([String](../../sql-reference/data-types/string.md)) — 运行 [clickhouse-client](../../interfaces/cli.md) 或其他 TCP 客户端的客户端机器的主机名。 -- `client_name` ([String](../../sql-reference/data-types/string.md)) — `clickhouse-client` 或其他 TCP 客户端名称。 -- `client_revision` ([UInt32](../../sql-reference/data-types/int-uint.md)) — `clickhouse-client` 或其他 TCP 客户端的修订号。 -- `client_version_major` ([UInt32](../../sql-reference/data-types/int-uint.md)) — `clickhouse-client` 或其他 TCP 客户端的主要版本。 -- `client_version_minor` ([UInt32](../../sql-reference/data-types/int-uint.md)) — `clickhouse-client` 或其他 TCP 客户端的次要版本。 +- `client_name` ([String](../../sql-reference/data-types/string.md)) — `clickhouse-client` 或其他 TCP 客户端的名称。 +- `client_revision` ([UInt32](../../sql-reference/data-types/int-uint.md)) — `clickhouse-client` 或其他 TCP 客户端的修订版。 +- `client_version_major` ([UInt32](../../sql-reference/data-types/int-uint.md)) — `clickhouse-client` 或其他 TCP 客户端的主版本。 +- `client_version_minor` ([UInt32](../../sql-reference/data-types/int-uint.md)) — `clickhouse-client` 或其他 TCP 客户端的次版本。 - `client_version_patch` ([UInt32](../../sql-reference/data-types/int-uint.md)) — `clickhouse-client` 或其他 TCP 客户端版本的补丁组件。 - `failure_reason` ([String](../../sql-reference/data-types/string.md)) — 包含登录/登出失败原因的异常消息。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/session_log.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/session_log.md.hash index 7edff081390..546350e2a11 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/session_log.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/session_log.md.hash @@ -1 +1 @@ -b8c67c10296fba0c +013904a72f3244b8 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/settings.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/settings.md index 3e500b0f68a..321218d0935 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/settings.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/settings.md @@ -1,35 +1,36 @@ --- -'description': '系统表包含关于当前用户会话设置的信息。' +'description': '系统表包含当前用户的会话设置信息。' 'keywords': - 'system table' - 'settings' 'slug': '/operations/system-tables/settings' 'title': 'system.settings' +'doc_type': 'reference' --- # system.settings -包含当前用户的会话设置的信息。 +包含当前用户会话设置的信息。 列: - `name` ([String](../../sql-reference/data-types/string.md)) — 设置名称。 - `value` ([String](../../sql-reference/data-types/string.md)) — 设置值。 -- `changed` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) — 显示该设置是否在配置中显式定义或显式更改。 -- `description` ([String](../../sql-reference/data-types/string.md)) — 设置的简短描述。 -- `min` ([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md))) — 设置的最小值(如果通过 [constraints](/operations/settings/constraints-on-settings) 设置)。如果该设置没有最小值,则包含 [NULL](/operations/settings/formats#input_format_null_as_default)。 -- `max` ([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md))) — 设置的最大值(如果通过 [constraints](/operations/settings/constraints-on-settings) 设置)。如果该设置没有最大值,则包含 [NULL](/operations/settings/formats#input_format_null_as_default)。 -- `readonly` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) — 显示当前用户是否可以更改该设置: - - `0` — 当前用户可以更改该设置。 - - `1` — 当前用户不能更改该设置。 +- `changed` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) — 显示设置是否在配置中明确定义或显式更改。 +- `description` ([String](../../sql-reference/data-types/string.md)) — 短设置描述。 +- `min` ([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md))) — 设置的最小值,如果通过 [constraints](/operations/settings/constraints-on-settings) 设置了最小值。如果该设置没有最小值,则包含 [NULL](/operations/settings/formats#input_format_null_as_default)。 +- `max` ([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md))) — 设置的最大值,如果通过 [constraints](/operations/settings/constraints-on-settings) 设置了最大值。如果该设置没有最大值,则包含 [NULL](/operations/settings/formats#input_format_null_as_default)。 +- `readonly` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) — 显示当前用户是否可以更改设置: + - `0` — 当前用户可以更改设置。 + - `1` — 当前用户不能更改设置。 - `default` ([String](../../sql-reference/data-types/string.md)) — 设置的默认值。 -- `is_obsolete` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) - 显示该设置是否已过时。 -- `tier` ([Enum8](../../sql-reference/data-types/enum.md)) — 该功能的支持级别。 ClickHouse 的功能分为不同的级别,这些级别取决于其开发的当前状态以及使用它们时可能产生的期望。值: - - `'Production'` — 功能稳定、安全使用,并且与其他 **production** 特性没有交互问题。 - - `'Beta'` — 功能稳定且安全。与其他功能一起使用时结果未知,正确性无法保证。欢迎进行测试和反馈。 - - `'Experimental'` — 功能正在开发中。仅供开发人员和 ClickHouse 爱好者使用。该功能可能有效也可能无效,并且随时可能被移除。 - - `'Obsolete'` — 不再支持。要么已经被移除,要么将在未来的版本中移除。 +- `is_obsolete` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) - 显示一个设置是否过时。 +- `tier` ([Enum8](../../sql-reference/data-types/enum.md)) — 该功能的支持级别。ClickHouse 功能分为不同的层级,依赖于其开发的当前状态和使用时的预期。值: + - `'Production'` — 该功能稳定、可安全使用并且与其他 **production** 功能没有交互问题。 + - `'Beta'` — 该功能稳定且安全。与其他功能一起使用的结果未知,并且正确性不能得到保证。欢迎进行测试和报告。 + - `'Experimental'` — 该功能正在开发中。仅供开发人员和ClickHouse爱好者使用。该功能可能有效也可能无效,并且可能在任何时候被删除。 + - `'Obsolete'` — 不再支持。要么已经删除,要么将会在未来版本中删除。 **示例** @@ -132,10 +133,10 @@ is_obsolete: 0 tier: Production ``` -使用 `WHERE changed` 可能会很有用,例如,当您想检查: +使用 `WHERE changed` 是有用的,例如,当你想检查: -- 配置文件中的设置是否正确加载并在使用中。 -- 当前会话中更改的设置。 +- 配置文件中的设置是否正确加载并正在使用。 +- 当前会话中已更改的设置。 @@ -143,9 +144,9 @@ tier: Production SELECT * FROM system.settings WHERE changed AND name='load_balancing' ``` -**另请参见** +**另见** - [Settings](/operations/system-tables/overview#system-tables-introduction) -- [查询的权限](/operations/settings/permissions-for-queries) -- [设置的约束](../../operations/settings/constraints-on-settings.md) +- [Permissions for Queries](/operations/settings/permissions-for-queries) +- [Constraints on Settings](../../operations/settings/constraints-on-settings.md) - [SHOW SETTINGS](../../sql-reference/statements/show.md#show-settings) 语句 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/settings.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/settings.md.hash index 71701d5c8b7..daaa91fc678 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/settings.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/settings.md.hash @@ -1 +1 @@ -9408ae27a9f3ebf0 +3596bc060356ac50 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/settings_changes.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/settings_changes.md index cccdd217ce6..b9dcc2230cf 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/settings_changes.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/settings_changes.md @@ -1,10 +1,11 @@ --- -'description': '系统表包含关于在之前的 ClickHouse 版本中设置更改的信息。' +'description': '系统表包含有关先前 ClickHouse 版本中设置更改的信息。' 'keywords': - 'system table' - 'settings_changes' 'slug': '/operations/system-tables/settings_changes' 'title': 'system.settings_changes' +'doc_type': 'reference' --- @@ -14,9 +15,9 @@ 列: -- `type` ([Enum](../../sql-reference/data-types/enum.md)) - 设置类型:`Core` (一般/查询设置),`MergeTree`。 +- `type` ([Enum](../../sql-reference/data-types/enum.md)) - 设置类型:`Core`(常规 / 查询设置),`MergeTree`。 - `version` ([String](../../sql-reference/data-types/string.md)) — 更改设置的 ClickHouse 版本 -- `changes` ([Array](../../sql-reference/data-types/array.md) of [Tuple](../../sql-reference/data-types/tuple.md)) — 设置更改的描述: (设置名称, 以前的值, 新的值, 更改原因) +- `changes` ([Array](../../sql-reference/data-types/array.md) of [Tuple](../../sql-reference/data-types/tuple.md)) — 设置更改的描述:(设置名称,先前值,新值,更改原因) **示例** @@ -35,7 +36,7 @@ version: 23.5 changes: [('input_format_parquet_preserve_order','1','0','Allow Parquet reader to reorder rows for better parallelism.'),('parallelize_output_from_storages','0','1','Allow parallelism when executing queries that read from file/url/s3/etc. This may reorder rows.'),('use_with_fill_by_sorting_prefix','0','1','Columns preceding WITH FILL columns in ORDER BY clause form sorting prefix. Rows with different values in sorting prefix are filled independently'),('output_format_parquet_compliant_nested_types','0','1','Change an internal field name in output Parquet file schema.')] ``` -**另见** +**另请参阅** - [Settings](/operations/system-tables/overview#system-tables-introduction) - [system.settings](settings.md) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/settings_changes.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/settings_changes.md.hash index 78949baf0bb..0112a5e7b5f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/settings_changes.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/settings_changes.md.hash @@ -1 +1 @@ -aa4066704d7ddcb2 +f23e3df5dd5baeab diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/settings_profile_elements.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/settings_profile_elements.md index 7518c4d439e..921aee1790b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/settings_profile_elements.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/settings_profile_elements.md @@ -1,10 +1,11 @@ --- -'description': '系统表,用于描述设置配置文件的内容:约束、角色和用户、该设置适用的父级设置配置文件。' +'description': '系统表,描述设置配置文件的内容:约束、角色和适用于该设置的用户、父级设置配置文件。' 'keywords': - 'system table' - 'settings_profile_elements' 'slug': '/operations/system-tables/settings_profile_elements' 'title': 'system.settings_profile_elements' +'doc_type': 'reference' --- @@ -12,27 +13,27 @@ 描述设置配置文件的内容: -- 约束条件。 -- 该设置适用的角色和用户。 +- 约束。 +- 适用的角色和用户。 - 父设置配置文件。 列: - `profile_name` ([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md))) — 设置配置文件名称。 -- `user_name` ([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md))) — 用户名称。 +- `user_name` ([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md))) — 用户名。 - `role_name` ([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md))) — 角色名称。 -- `index` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 设置配置文件元素的顺序编号。 +- `index` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 设置配置文件元素的序号。 - `setting_name` ([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md))) — 设置名称。 - `value` ([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md))) — 设置值。 -- `min` ([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md))) — 设置的最小值。如果未设置,则为 `NULL`。 +- `min` ([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md))) — 设置的最小值。未设置则为 `NULL`。 -- `max` ([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md))) — 设置的最大值。如果未设置,则为 NULL。 +- `max` ([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md))) — 设置的最大值。未设置则为 NULL。 -- `writability` ([Nullable](../../sql-reference/data-types/nullable.md)([Enum8](../../sql-reference/data-types/enum.md)('WRITABLE' = 0, 'CONST' = 1, 'CHANGEABLE_IN_READONLY' = 2))) — 设置约束的可写性类型。 +- `writability` ([Nullable](../../sql-reference/data-types/nullable.md)([Enum8](../../sql-reference/data-types/enum.md)('WRITABLE' = 0, 'CONST' = 1, 'CHANGEABLE_IN_READONLY' = 2))) — 设置约束可写性类型。 -- `inherit_profile` ([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md))) — 此设置配置文件的父配置文件。如果未设置,则为 `NULL`。设置配置文件将从其父配置文件中继承所有设置值和约束(`min`,`max`,`readonly`)。 +- `inherit_profile` ([Nullable](../../sql-reference/data-types/nullable.md)([String](../../sql-reference/data-types/string.md))) — 此设置配置文件的父配置文件。未设置则为 `NULL`。设置配置文件将从其父配置文件继承所有设置值和约束(`min`,`max`,`readonly`)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/settings_profile_elements.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/settings_profile_elements.md.hash index 09dd14eace5..600d2f16b0c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/settings_profile_elements.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/settings_profile_elements.md.hash @@ -1 +1 @@ -e5b0babf32a6205f +966f35689aac9fac diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/settings_profiles.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/settings_profiles.md index 22075ed5e8f..944da6967c6 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/settings_profiles.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/settings_profiles.md @@ -1,10 +1,11 @@ --- -'description': '系统表,包含已配置设置资料的属性。' +'description': '系统表,包含配置的设置配置文件的属性。' 'keywords': - 'system table' - 'settings_profiles' 'slug': '/operations/system-tables/settings_profiles' 'title': 'system.settings_profiles' +'doc_type': 'reference' --- @@ -17,16 +18,16 @@ - `id` ([UUID](../../sql-reference/data-types/uuid.md)) — 设置配置文件 ID。 -- `storage` ([String](../../sql-reference/data-types/string.md)) — 设置配置文件的存储路径。配置在 `access_control_path` 参数中。 +- `storage` ([String](../../sql-reference/data-types/string.md)) — 设置配置文件存储的路径。在 `access_control_path` 参数中配置。 - `num_elements` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 此配置文件在 `system.settings_profile_elements` 表中的元素数量。 -- `apply_to_all` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) — 表示设置配置文件适用于所有角色和/或用户。 +- `apply_to_all` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) — 表示该设置配置文件适用于所有角色和/或用户。 -- `apply_to_list` ([Array](../../sql-reference/data-types/array.md)([String](../../sql-reference/data-types/string.md))) — 设置配置文件应用的角色和/或用户列表。 +- `apply_to_list` ([Array](../../sql-reference/data-types/array.md)([String](../../sql-reference/data-types/string.md))) — 应用设置配置文件的角色和/或用户列表。 -- `apply_to_except` ([Array](../../sql-reference/data-types/array.md)([String](../../sql-reference/data-types/string.md))) — 此设置配置文件适用于所有角色和/或用户,除了列出的角色和/或用户之外。 +- `apply_to_except` ([Array](../../sql-reference/data-types/array.md)([String](../../sql-reference/data-types/string.md))) — 设置配置文件应用于所有角色和/或用户,但不包括列表中的角色和/或用户。 -## See Also {#see-also} +## 另请参阅 {#see-also} - [SHOW PROFILES](/sql-reference/statements/show#show-profiles) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/settings_profiles.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/settings_profiles.md.hash index 22a709f5037..86afafb26d8 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/settings_profiles.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/settings_profiles.md.hash @@ -1 +1 @@ -99929064a04c8f0b +d14787852d29f821 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/stack_trace.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/stack_trace.md index 8a55f2558aa..be87d3476ab 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/stack_trace.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/stack_trace.md @@ -5,6 +5,7 @@ - 'stack_trace' 'slug': '/operations/system-tables/stack_trace' 'title': 'system.stack_trace' +'doc_type': 'reference' --- import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_system_table_cloud.md'; @@ -16,22 +17,22 @@ import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/curre 包含所有服务器线程的堆栈跟踪。允许开发人员检查服务器状态。 -要分析堆栈帧,请使用 `addressToLine`、`addressToLineWithInlines`、`addressToSymbol` 和 `demangle` [内部检查函数](../../sql-reference/functions/introspection.md)。 +要分析堆栈帧,请使用 `addressToLine`、`addressToLineWithInlines`、`addressToSymbol` 和 `demangle` [反思函数](../../sql-reference/functions/introspection.md)。 列: - `thread_name` ([String](../../sql-reference/data-types/string.md)) — 线程名称。 - `thread_id` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 线程标识符。 -- `query_id` ([String](../../sql-reference/data-types/string.md)) — 可以用于获取来自 [query_log](../system-tables/query_log.md) 系统表中正在运行的查询详情的查询标识符。 -- `trace` ([Array(UInt64)](../../sql-reference/data-types/array.md)) — 表示调用方法存储的物理地址列表的 [堆栈跟踪](https://en.wikipedia.org/wiki/Stack_trace)。 +- `query_id` ([String](../../sql-reference/data-types/string.md)) — 查询标识符,可用于获取有关从 [query_log](../system-tables/query_log.md) 系统表运行的查询的详细信息。 +- `trace` ([Array(UInt64)](../../sql-reference/data-types/array.md)) — 一个 [堆栈跟踪](https://en.wikipedia.org/wiki/Stack_trace),表示存储调用方法的物理地址列表。 :::tip -查看知识库中的一些实用查询,包括 [如何查看当前正在运行的线程](/knowledgebase/find-expensive-queries) 和 [故障排除的有用查询](/knowledgebase/useful-queries-for-troubleshooting)。 +查看知识库以获取一些实用查询,包括 [如何查看当前运行的线程](/knowledgebase/find-expensive-queries) 和 [用于故障排除的有用查询](/knowledgebase/useful-queries-for-troubleshooting)。 ::: **示例** -启用内部检查函数: +启用反思函数: ```sql SET allow_introspection_functions = 1; @@ -99,9 +100,9 @@ res: /lib/x86_64-linux-gnu/libc-2.27.so /lib/x86_64-linux-gnu/libc-2.27.so ``` -**参见** +**另请参阅** -- [内部检查函数](../../sql-reference/functions/introspection.md) — 可用的内部检查函数及其用法。 +- [反思函数](../../sql-reference/functions/introspection.md) — 可用的反思函数以及如何使用它们。 - [system.trace_log](../system-tables/trace_log.md) — 包含由采样查询分析器收集的堆栈跟踪。 -- [arrayMap](/sql-reference/functions/array-functions#arraymapfunc-arr1-) — `arrayMap` 函数的描述和使用示例。 -- [arrayFilter](/sql-reference/functions/array-functions#arrayfilterfunc-arr1-) — `arrayFilter` 函数的描述和使用示例。 +- [arrayMap](/sql-reference/functions/array-functions#arrayMap) — `arrayMap` 函数的描述和使用示例。 +- [arrayFilter](/sql-reference/functions/array-functions#arrayFilter) — `arrayFilter` 函数的描述和使用示例。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/stack_trace.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/stack_trace.md.hash index 16c40a2d22e..1d91c3dddac 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/stack_trace.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/stack_trace.md.hash @@ -1 +1 @@ -bdc3edb3030d85e6 +b866a8b8ffb8d55c diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/storage_policies.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/storage_policies.md index 63d85e205b9..55a9ed6698a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/storage_policies.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/storage_policies.md @@ -1,33 +1,34 @@ --- -'description': '系统表包含有关在服务器配置中定义的存储策略和卷的信息。' +'description': '系统表包含有关存储策略和在服务器配置中定义的卷的信息。' 'keywords': - 'system table' - 'storage_policies' 'slug': '/operations/system-tables/storage_policies' 'title': 'system.storage_policies' +'doc_type': 'reference' --- # system.storage_policies -包含在 [服务器配置](../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-multiple-volumes_configure) 中定义的存储策略和卷的信息。 +包含关于存储策略和在 [服务器配置](../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-multiple-volumes_configure) 中定义的卷的信息。 列: - `policy_name` ([String](../../sql-reference/data-types/string.md)) — 存储策略的名称。 - `volume_name` ([String](../../sql-reference/data-types/string.md)) — 在存储策略中定义的卷名称。 -- `volume_priority` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 配置中卷的顺序号,数据按照此优先级填充卷,即数据在插入和合并过程中写入优先级较低的卷(考虑其他规则:TTL, `max_data_part_size`, `move_factor`)。 +- `volume_priority` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 配置中的卷顺序编号,数据按此优先级填充卷,即在插入和合并期间数据写入优先级较低的卷(考虑其他规则:生存时间 (TTL), `max_data_part_size`, `move_factor`)。 - `disks` ([Array(String)](../../sql-reference/data-types/array.md)) — 在存储策略中定义的磁盘名称。 -- `volume_type` ([Enum8](../../sql-reference/data-types/enum.md)) — 卷的类型。可以具有以下值之一: - - `JBOD` - - `SINGLE_DISK` - - `UNKNOWN` -- `max_data_part_size` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 可以存储在卷磁盘上的数据部分的最大大小 (0 — 没有限制)。 -- `move_factor` ([Float64](../../sql-reference/data-types/float.md)) — 空闲磁盘空间的比例。当比例超过配置参数的值时,ClickHouse 开始将数据移动到下一个卷中。 -- `prefer_not_to_merge` ([UInt8](../../sql-reference/data-types/int-uint.md)) — `prefer_not_to_merge` 设置的值。应始终为 false。当启用此设置时,您犯了一个错误。 -- `perform_ttl_move_on_insert` ([UInt8](../../sql-reference/data-types/int-uint.md)) — `perform_ttl_move_on_insert` 设置的值。 — 禁用数据部分 INSERT 时的 TTL 移动。默认情况下,如果我们插入的数据部分已过 TTL 移动规则,则该数据部分会立即转到移动规则中声明的卷/磁盘。如果目标卷/磁盘速度较慢(例如 S3),这可能会显著降低插入速度。 -- `load_balancing` ([Enum8](../../sql-reference/data-types/enum.md)) — 磁盘负载平衡策略。可以具有以下值之一: - - `ROUND_ROBIN` - - `LEAST_USED` +- `volume_type` ([Enum8](../../sql-reference/data-types/enum.md)) — 卷的类型。可以有以下值之一: + - `JBOD` + - `SINGLE_DISK` + - `UNKNOWN` +- `max_data_part_size` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 可以存储在卷磁盘上的数据部分的最大大小(0 — 无限制)。 +- `move_factor` ([Float64](../../sql-reference/data-types/float.md)) — 可用磁盘空间的比例。当比率超过配置参数的值时,ClickHouse 会开始将数据移动到下一个卷。 +- `prefer_not_to_merge` ([UInt8](../../sql-reference/data-types/int-uint.md)) — `prefer_not_to_merge` 设置的值。应始终为 false。当此设置启用时,您会犯一个错误。 +- `perform_ttl_move_on_insert` ([UInt8](../../sql-reference/data-types/int-uint.md)) — `perform_ttl_move_on_insert` 设置的值。 — 在数据部分INSERT时禁用生存时间 (TTL) 移动。默认情况下,如果我们插入已根据生存时间 (TTL) 移动规则过期的数据部分,它会立即转移到移动规则中声明的卷/磁盘。如果目标卷/磁盘速度较慢(例如 S3),这可能会显著减慢插入速度。 +- `load_balancing` ([Enum8](../../sql-reference/data-types/enum.md)) — 磁盘负载平衡策略。可以有以下值之一: + - `ROUND_ROBIN` + - `LEAST_USED` 如果存储策略包含多个卷,则每个卷的信息存储在表的单独行中。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/storage_policies.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/storage_policies.md.hash index b6bf32e3c34..e4324fda972 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/storage_policies.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/storage_policies.md.hash @@ -1 +1 @@ -3de672ad164d57c6 +8c4e6c0cee091814 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/symbols.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/symbols.md index 8b6ef3c9baf..7681df60dbb 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/symbols.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/symbols.md @@ -1,18 +1,19 @@ --- -'description': '该系统表对 C++ 专家和 ClickHouse 工程师非常有用,包含有关 `clickhouse` 二进制文件的自省信息。' +'description': '系统表对于 C++ 专家和 ClickHouse 工程师非常有用,包含有关 `clickhouse` 二进制文件的自省信息。' 'keywords': - 'system table' - 'symbols' 'slug': '/operations/system-tables/symbols' 'title': 'system.symbols' +'doc_type': 'reference' --- -包含有关 `clickhouse` 二进制文件的自省信息。访问此信息需要自省权限。 -该表仅对 C++ 专家和 ClickHouse 工程师有用。 +包含有关 `clickhouse` 二进制文件的自省信息。访问此信息需要自省权限。 +此表仅对 C++ 专家和 ClickHouse 工程师有用。 列: -- `symbol` ([String](../../sql-reference/data-types/string.md)) — 二进制中的符号名称。它是经过编译的。您可以应用 `demangle(symbol)` 来获取可读名称。 +- `symbol` ([String](../../sql-reference/data-types/string.md)) — 二进制中的符号名称。它是经过修改的。您可以应用 `demangle(symbol)` 来获取可读名称。 - `address_begin` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 符号在二进制中的起始地址。 - `address_end` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 符号在二进制中的结束地址。 - `name` ([String](../../sql-reference/data-types/string.md)) — `event` 的别名。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/symbols.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/symbols.md.hash index d27dd21296e..972829ec6bf 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/symbols.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/symbols.md.hash @@ -1 +1 @@ -0d48c0a4a4b0dd69 +d3e7cd4109500b64 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/system_warnings.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/system_warnings.md index 6fe21c54b6a..d3896b45b00 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/system_warnings.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/system_warnings.md @@ -1,10 +1,11 @@ --- -'description': '该表包含关于 clickhouse 服务器的警告消息。' +'description': '这个表包含关于 clickhouse 服务器的警告消息。' 'keywords': - 'system table' - 'warnings' 'slug': '/operations/system-tables/system_warnings' 'title': 'system.warnings' +'doc_type': 'reference' --- import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_system_table_cloud.md'; @@ -14,9 +15,9 @@ import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/curre -此表显示有关 ClickHouse 服务器的警告。相同类型的警告会合并成一个单一的警告。例如,如果附加数据库的数量 N 超过了可配置阈值 T,则会显示包含当前值 N 的单个条目,而不是 N 个单独的条目。如果当前值降至阈值以下,则该条目将从表中删除。 +该表显示有关 ClickHouse 服务器的警告。相同类型的警告会合并为单个警告。例如,如果附加数据库的数量 N 超过可配置的阈值 T,则只显示包含当前值 N 的单个条目,而不是 N 个单独的条目。如果当前值低于阈值,则该条目将从表中删除。 -该表可通过以下设置进行配置: +可以通过以下设置配置该表: - [max_table_num_to_warn](../server-configuration-parameters/settings.md#max_table_num_to_warn) - [max_database_num_to_warn](../server-configuration-parameters/settings.md#max_database_num_to_warn) @@ -25,10 +26,12 @@ import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/curre - [max_part_num_to_warn](../server-configuration-parameters/settings.md#max_part_num_to_warn) - [max_pending_mutations_to_warn](../server-configuration-parameters/settings.md#max_pending_mutations_to_warn) - [max_pending_mutations_execution_time_to_warn](/operations/server-configuration-parameters/settings#max_pending_mutations_execution_time_to_warn) +- [max_named_collection_num_to_warn](../server-configuration-parameters/settings.md#max_named_collection_num_to_warn) +- [resource_overload_warnings](/operations/settings/server-overload#resource-overload-warnings) 列: -- `message` ([String](../../sql-reference/data-types/string.md)) — 警告信息。 +- `message` ([String](../../sql-reference/data-types/string.md)) — 警告消息。 - `message_format_string` ([LowCardinality(String)](../../sql-reference/data-types/string.md)) — 用于格式化消息的格式字符串。 **示例** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/system_warnings.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/system_warnings.md.hash index d3891ede5be..f273275f5d4 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/system_warnings.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/system_warnings.md.hash @@ -1 +1 @@ -e5f16a9ba6f01480 +76e7ec767d3e2cb3 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/table_engines.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/table_engines.md index 1185e1f9565..ae5247ecc6b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/table_engines.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/table_engines.md @@ -1,35 +1,35 @@ --- -'description': '系统表,包含服务器支持的表引擎及其支持的特性描述。' +'description': '系统表,包含服务器支持的表引擎及其支持的功能的描述。' 'keywords': - 'system table' - 'table_engines' 'slug': '/operations/system-tables/table_engines' -'title': 'system.table_engine' +'title': 'system.table_engines' +'doc_type': 'reference' --- - -# system.table_engine +# system.table_engines 包含服务器支持的表引擎的描述及其功能支持信息。 -该表包含以下列(列类型用括号表示): +该表包含以下列(列类型以括号表示): - `name` (String) — 表引擎的名称。 -- `supports_settings` (UInt8) — 指示表引擎是否支持 `SETTINGS` 子句的标志。 -- `supports_skipping_indices` (UInt8) — 指示表引擎是否支持 [数据跳过索引](../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-data_skipping-indexes) 的标志。 -- `supports_ttl` (UInt8) — 指示表引擎是否支持 [生存时间 (TTL)](../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-ttl) 的标志。 -- `supports_sort_order` (UInt8) — 指示表引擎是否支持子句 `PARTITION_BY`、`PRIMARY_KEY`、`ORDER_BY` 和 `SAMPLE_BY` 的标志。 -- `supports_replication` (UInt8) — 指示表引擎是否支持 [数据复制](../../engines/table-engines/mergetree-family/replication.md) 的标志。 -- `supports_duduplication` (UInt8) — 指示表引擎是否支持数据去重的标志。 -- `supports_parallel_insert` (UInt8) — 指示表引擎是否支持并行插入(参见 [`max_insert_threads`](/operations/settings/settings#max_insert_threads) 设置)的标志。 +- `supports_settings` (UInt8) — 表示表引擎是否支持 `SETTINGS` 子句的标志。 +- `supports_skipping_indices` (UInt8) — 表示表引擎是否支持 [数据跳过索引](../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-data_skipping-indexes) 的标志。 +- `supports_ttl` (UInt8) — 表示表引擎是否支持 [生存时间 (TTL)](../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-ttl) 的标志。 +- `supports_sort_order` (UInt8) — 表示表引擎是否支持子句 `PARTITION_BY`、`PRIMARY_KEY`、`ORDER_BY` 和 `SAMPLE_BY` 的标志。 +- `supports_replication` (UInt8) — 表示表引擎是否支持 [数据复制](../../engines/table-engines/mergetree-family/replication.md) 的标志。 +- `supports_deduplication` (UInt8) — 表示表引擎是否支持数据去重的标志。 +- `supports_parallel_insert` (UInt8) — 表示表引擎是否支持并行插入(参见 [`max_insert_threads`](/operations/settings/settings#max_insert_threads) 设置)的标志。 示例: ```sql SELECT * FROM system.table_engines -WHERE name in ('Kafka', 'MergeTree', 'ReplicatedCollapsingMergeTree') +WHERE name IN ('Kafka', 'MergeTree', 'ReplicatedCollapsingMergeTree') ``` ```text @@ -40,7 +40,7 @@ WHERE name in ('Kafka', 'MergeTree', 'ReplicatedCollapsingMergeTree') └───────────────────────────────┴───────────────────┴───────────────────────────┴─────────────────────┴──────────────┴──────────────────────┴────────────────────────┴──────────────────────────┘ ``` -**另请参阅** +**另见** - MergeTree 家族 [查询子句](../../engines/table-engines/mergetree-family/mergetree.md#mergetree-query-clauses) - Kafka [设置](/engines/table-engines/integrations/kafka#creating-a-table) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/table_engines.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/table_engines.md.hash index 50da2e431a5..c76453bb070 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/table_engines.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/table_engines.md.hash @@ -1 +1 @@ -6ea4665f59843925 +c09c2ad57e721e2e diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/tables.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/tables.md index 7131b219c2e..ef89886cf12 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/tables.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/tables.md @@ -1,20 +1,21 @@ --- -'description': '系统表,包含服务器已知的每个表的元数据。' +'description': '系统表包含服务器已知的每个表的元数据。' 'keywords': - 'system table' - 'tables' 'slug': '/operations/system-tables/tables' 'title': 'system.tables' +'doc_type': 'reference' --- # system.tables -包含服务器已知的每个表的元数据。 +包含服务器所知的每个表的元数据信息。 [Detached](../../sql-reference/statements/detach.md) 表不会显示在 `system.tables` 中。 -[Temporary tables](../../sql-reference/statements/create/table.md#temporary-tables) 仅在创建它们的会话中可见于 `system.tables`。它们显示为空的 `database` 字段,并且 `is_temporary` 标志被打开。 +[Temporary tables](../../sql-reference/statements/create/table.md#temporary-tables) 仅在创建它们的会话中可见于 `system.tables`。它们的 `database` 字段为空,且 `is_temporary` 标志被开启。 列: @@ -22,17 +23,17 @@ - `name` ([String](../../sql-reference/data-types/string.md)) — 表名称。 -- `uuid` ([UUID](../../sql-reference/data-types/uuid.md)) — 表的 uuid(原子数据库)。 +- `uuid` ([UUID](../../sql-reference/data-types/uuid.md)) — 表的 UUID(原子数据库)。 -- `engine` ([String](../../sql-reference/data-types/string.md)) — 表引擎名称(不带参数)。 +- `engine` ([String](../../sql-reference/data-types/string.md)) — 表引擎名称(不含参数)。 -- `is_temporary` ([UInt8](../../sql-reference/data-types/int-uint.md)) - 表示表是否为临时的标志。 +- `is_temporary` ([UInt8](../../sql-reference/data-types/int-uint.md)) - 指示表是否为临时表的标志。 - `data_paths` ([Array](../../sql-reference/data-types/array.md)([String](../../sql-reference/data-types/string.md))) - 文件系统中表数据的路径。 - `metadata_path` ([String](../../sql-reference/data-types/string.md)) - 文件系统中表元数据的路径。 -- `metadata_modification_time` ([DateTime](../../sql-reference/data-types/datetime.md)) - 表元数据的最后修改时间。 +- `metadata_modification_time` ([DateTime](../../sql-reference/data-types/datetime.md)) - 表元数据的最新修改时间。 - `metadata_version` ([Int32](../../sql-reference/data-types/int-uint.md)) - ReplicatedMergeTree 表的元数据版本,非 ReplicatedMergeTree 表为 0。 @@ -58,29 +59,29 @@ - `storage_policy` ([String](../../sql-reference/data-types/string.md)) - 存储策略: - - [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-multiple-volumes) - - [Distributed](/engines/table-engines/special/distributed) + - [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-multiple-volumes) + - [Distributed](/engines/table-engines/special/distributed) -- `total_rows` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) - 总行数,如果可以快速确定表中确切的行数,否则为 `NULL`(包括底层的 `Buffer` 表)。 +- `total_rows` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) - 总行数,如果可以快速确定表中的确切行数,则返回该值,否则返回 `NULL`(包括底层的 `Buffer` 表)。 -- `total_bytes` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) - 总字节数,如果可以快速确定存储中表的确切字节数,则返回,否则为 `NULL`(不包括任何底层存储)。 +- `total_bytes` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) - 总字节数,如果可以快速确定表在存储中占用的确切字节数,则返回该值,否则返回 `NULL`(不包括任何底层存储)。 - - 如果表在磁盘上存储数据,则返回磁盘上使用的空间(即压缩后)。 - - 如果表在内存中存储数据,则返回内存中使用的字节的近似数量。 + - 如果表的数据存储在磁盘上,返回在磁盘上使用的空间(即压缩后的)。 + - 如果表的数据存储在内存中,返回在内存中使用的字节数的近似值。 -- `total_bytes_uncompressed` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) - 总未压缩字节数,如果可以快速确定存储中从部分校验和得到的确切字节数,否则为 `NULL`(不考虑底层存储(如果有的话))。 +- `total_bytes_uncompressed` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) - 总未压缩字节数,如果可以快速确定表在存储中的部分校验和所对应的确切字节数,则返回该值,否则返回 `NULL`(不考虑任何底层存储(如果存在))。 -- `lifetime_rows` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) - 自服务器启动以来插入的总行数(仅适用于 `Buffer` 表)。 +- `lifetime_rows` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) - 自服务器启动以来插入的总行数(仅针对 `Buffer` 表)。 -- `lifetime_bytes` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) - 自服务器启动以来插入的总字节数(仅适用于 `Buffer` 表)。 +- `lifetime_bytes` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) - 自服务器启动以来插入的总字节数(仅针对 `Buffer` 表)。 -- `comment` ([String](../../sql-reference/data-types/string.md)) - 表的备注。 +- `comment` ([String](../../sql-reference/data-types/string.md)) - 表的注释。 -- `has_own_data` ([UInt8](../../sql-reference/data-types/int-uint.md)) — 表示表本身是否在磁盘上存储一些数据或仅访问其他来源的标志。 +- `has_own_data` ([UInt8](../../sql-reference/data-types/int-uint.md)) — 指示表自身是否在磁盘上存储数据或仅访问其他来源的标志。 -- `loading_dependencies_database` ([Array](../../sql-reference/data-types/array.md)([String](../../sql-reference/data-types/string.md))) - 数据库加载依赖项(应在当前对象之前加载的对象列表)。 +- `loading_dependencies_database` ([Array](../../sql-reference/data-types/array.md)([String](../../sql-reference/data-types/string.md))) - 数据库加载依赖项(在当前对象之前应加载的对象列表)。 -- `loading_dependencies_table` ([Array](../../sql-reference/data-types/array.md)([String](../../sql-reference/data-types/string.md))) - 表加载依赖项(应在当前对象之前加载的对象列表)。 +- `loading_dependencies_table` ([Array](../../sql-reference/data-types/array.md)([String](../../sql-reference/data-types/string.md))) - 表加载依赖项(在当前对象之前应加载的对象列表)。 - `loading_dependent_database` ([Array](../../sql-reference/data-types/array.md)([String](../../sql-reference/data-types/string.md))) - 依赖加载的数据库。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/tables.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/tables.md.hash index 3fab30e037d..814b5cee00c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/tables.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/tables.md.hash @@ -1 +1 @@ -1ffe58ae0888056b +26a6aebdcd9bc1f4 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/text_log.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/text_log.md index ab65f2e2b63..ab696c47bbd 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/text_log.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/text_log.md @@ -1,10 +1,11 @@ --- -'description': '系统表包含日志条目。' +'description': '系统表,包含日志条目。' 'keywords': - 'system table' - 'text_log' 'slug': '/operations/system-tables/text_log' 'title': 'system.text_log' +'doc_type': 'reference' --- import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_system_table_cloud.md'; @@ -14,32 +15,32 @@ import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/curre -包含日志条目。写入此表的日志级别可以通过 `text_log.level` 服务器设置进行限制。 +包含日志条目。写入此表的日志级别可以限制为 `text_log.level` 服务器设置。 列: -- `hostname` ([LowCardinality(String)](../../sql-reference/data-types/string.md)) — 执行查询的服务器的 hostname。 +- `hostname` ([LowCardinality(String)](../../sql-reference/data-types/string.md)) — 执行查询的服务器的主机名。 - `event_date` (Date) — 条目的日期。 - `event_time` (DateTime) — 条目的时间。 -- `event_time_microseconds` (DateTime64) — 精确到微秒的条目时间。 +- `event_time_microseconds` (DateTime64) — 带有微秒精度的条目时间。 - `microseconds` (UInt32) — 条目的微秒数。 -- `thread_name` (String) — 记录日志的线程名称。 +- `thread_name` (String) — 进行日志记录的线程名称。 - `thread_id` (UInt64) — 操作系统线程 ID。 - `level` (`Enum8`) — 条目级别。可能的值: - - `1` 或 `'Fatal'`。 - - `2` 或 `'Critical'`。 - - `3` 或 `'Error'`。 - - `4` 或 `'Warning'`。 - - `5` 或 `'Notice'`。 - - `6` 或 `'Information'`。 - - `7` 或 `'Debug'`。 - - `8` 或 `'Trace'`。 -- `query_id` (String) — 查询的 ID。 -- `logger_name` (LowCardinality(String)) — 日志记录器的名称(即 `DDLWorker`)。 + - `1` 或 `'Fatal'`。 + - `2` 或 `'Critical'`。 + - `3` 或 `'Error'`。 + - `4` 或 `'Warning'`。 + - `5` 或 `'Notice'`。 + - `6` 或 `'Information'`。 + - `7` 或 `'Debug'`。 + - `8` 或 `'Trace'`。 +- `query_id` (String) — 查询 ID。 +- `logger_name` (LowCardinality(String)) — 日志记录器的名称(例如 `DDLWorker`)。 - `message` (String) — 消息内容。 -- `revision` (UInt32) — ClickHouse 修订版。 -- `source_file` (LowCardinality(String)) — 记录日志的源文件。 -- `source_line` (UInt64) — 记录日志的源行。 +- `revision` (UInt32) — ClickHouse 修订版本。 +- `source_file` (LowCardinality(String)) — 进行日志记录的源文件。 +- `source_line` (UInt64) — 进行日志记录的源行。 - `message_format_string` (LowCardinality(String)) — 用于格式化消息的格式字符串。 - `value1` (String) - 用于格式化消息的参数 1。 - `value2` (String) - 用于格式化消息的参数 2。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/text_log.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/text_log.md.hash index e99596aa17a..2b7f5bf20d3 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/text_log.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/text_log.md.hash @@ -1 +1 @@ -346f56ac79b5dcb4 +3b93d36973554139 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/time_zones.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/time_zones.md index d88e5edf43d..f52002e6ca0 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/time_zones.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/time_zones.md @@ -5,6 +5,7 @@ - 'time_zones' 'slug': '/operations/system-tables/time_zones' 'title': 'system.time_zones' +'doc_type': 'reference' --- diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/time_zones.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/time_zones.md.hash index 3f75a8efe4a..ca776537f5d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/time_zones.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/time_zones.md.hash @@ -1 +1 @@ -2ca78c1f154d70f3 +b29ae9766efaf5f8 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/trace_log.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/trace_log.md index 42218af2d03..f42164c9916 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/trace_log.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/trace_log.md @@ -1,10 +1,11 @@ --- -'description': '系统表包含由采样查询分析器收集的堆栈跟踪。' +'description': '系统表,包含由采样查询分析器收集的栈跟踪。' 'keywords': - 'system table' - 'trace_log' 'slug': '/operations/system-tables/trace_log' 'title': 'system.trace_log' +'doc_type': 'reference' --- import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_system_table_cloud.md'; @@ -14,41 +15,42 @@ import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/curre -包含由 [sampling query profiler](../../operations/optimizing-performance/sampling-query-profiler.md) 收集的堆栈跟踪信息。 +包含由 [sampling query profiler](../../operations/optimizing-performance/sampling-query-profiler.md) 收集的堆栈跟踪。 -当 [trace_log](../../operations/server-configuration-parameters/settings.md#trace_log) 服务器配置部分被设置时,ClickHouse 会创建此表。另请参阅设置: [query_profiler_real_time_period_ns](../../operations/settings/settings.md#query_profiler_real_time_period_ns), [query_profiler_cpu_time_period_ns](../../operations/settings/settings.md#query_profiler_cpu_time_period_ns), [memory_profiler_step](../../operations/settings/settings.md#memory_profiler_step), -[memory_profiler_sample_probability](../../operations/settings/settings.md#memory_profiler_sample_probability), [trace_profile_events](../../operations/settings/settings.md#trace_profile_events)。 +当 [trace_log](../../operations/server-configuration-parameters/settings.md#trace_log) 服务器配置部分被设置时,ClickHouse 会创建此表。另请参见设置: [query_profiler_real_time_period_ns](../../operations/settings/settings.md#query_profiler_real_time_period_ns)、[query_profiler_cpu_time_period_ns](../../operations/settings/settings.md#query_profiler_cpu_time_period_ns)、[memory_profiler_step](../../operations/settings/settings.md#memory_profiler_step)、[memory_profiler_sample_probability](../../operations/settings/settings.md#memory_profiler_sample_probability)、[trace_profile_events](../../operations/settings/settings.md#trace_profile_events)。 要分析日志,请使用 `addressToLine`、`addressToLineWithInlines`、`addressToSymbol` 和 `demangle` 反射函数。 -列: +列: -- `hostname` ([LowCardinality(String)](../../sql-reference/data-types/string.md)) — 执行查询的服务器的主机名。 -- `event_date` ([Date](../../sql-reference/data-types/date.md)) — 采样时刻的日期。 -- `event_time` ([DateTime](../../sql-reference/data-types/datetime.md)) — 采样时刻的时间戳。 -- `event_time_microseconds` ([DateTime64](../../sql-reference/data-types/datetime64.md)) — 采样时刻的时间戳,微秒精度。 -- `timestamp_ns` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 采样时刻的时间戳(纳秒)。 -- `revision` ([UInt32](../../sql-reference/data-types/int-uint.md)) — ClickHouse 服务器构建修订版本。 +- `hostname` ([LowCardinality(String)](../../sql-reference/data-types/string.md)) — 执行查询的服务器主机名。 +- `event_date` ([Date](../../sql-reference/data-types/date.md)) — 采样时的日期。 +- `event_time` ([DateTime](../../sql-reference/data-types/datetime.md)) — 采样时的时间戳。 +- `event_time_microseconds` ([DateTime64](../../sql-reference/data-types/datetime64.md)) — 带有微秒精度的采样时的时间戳。 +- `timestamp_ns` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 以纳秒为单位的采样时的时间戳。 +- `revision` ([UInt32](../../sql-reference/data-types/int-uint.md)) — ClickHouse 服务器构建修订版。 - 通过 `clickhouse-client` 连接到服务器时,您会看到类似于 `Connected to ClickHouse server version 19.18.1.` 的字符串。此字段包含 `revision` ,但不包含服务器的 `version`。 + 当通过 `clickhouse-client` 连接到服务器时,您会看到类似于 `Connected to ClickHouse server version 19.18.1.` 的字符串。该字段包含 `revision`,但不包含服务器的 `version`。 - `trace_type` ([Enum8](../../sql-reference/data-types/enum.md)) — 跟踪类型: - - `Real` 表示通过实际时间收集堆栈跟踪。 - - `CPU` 表示通过 CPU 时间收集堆栈跟踪。 - - `Memory` 表示当内存分配超过后续水印时收集分配和解除分配。 - - `MemorySample` 表示收集随机分配和解除分配。 - - `MemoryPeak` 表示收集峰值内存使用情况的更新。 - - `ProfileEvent` 表示收集配置事件的增量。 + - `Real` 代表通过墙钟时间收集堆栈跟踪。 + - `CPU` 代表通过 CPU 时间收集堆栈跟踪。 + - `Memory` 代表收集当内存分配超过后续水印时的分配和释放。 + - `MemorySample` 代表收集随机分配和释放。 + - `MemoryPeak` 代表收集峰值内存使用的更新。 + - `ProfileEvent` 代表收集配置事件的增量。 + - `JemallocSample` 代表收集 jemalloc 样本。 + - `MemoryAllocatedWithoutCheck` 代表收集重大分配 (>16MiB) 的情况,该分配忽略任何内存限制(仅限 ClickHouse 开发人员)。 - `thread_id` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 线程标识符。 -- `query_id` ([String](../../sql-reference/data-types/string.md)) — 查询标识符,可以用于获取来自 [query_log](/operations/system-tables/query_log) 系统表的查询详细信息。 -- `trace` ([Array(UInt64)](../../sql-reference/data-types/array.md)) — 采样时刻的堆栈跟踪。每个元素是 ClickHouse 服务器进程中的虚拟内存地址。 -- `size` ([Int64](../../sql-reference/data-types/int-uint.md)) - 对于 `Memory`、`MemorySample` 或 `MemoryPeak` 跟踪类型,表示分配的内存量,对于其他跟踪类型为 0。 -- `event` ([LowCardinality(String)](../../sql-reference/data-types/lowcardinality.md)) - 对于 `ProfileEvent` 跟踪类型,是更新的配置事件的名称,对于其他跟踪类型为空字符串。 -- `increment` ([UInt64](../../sql-reference/data-types/int-uint.md)) - 对于 `ProfileEvent` 跟踪类型,是配置事件的增量,对于其他跟踪类型为 0。 -- `symbols` ([Array(LowCardinality(String))](../../sql-reference/data-types/array.md)),如果启用了符号化,则包含与 `trace` 对应的解码符号名称。 -- `lines` ([Array(LowCardinality(String))](../../sql-reference/data-types/array.md)),如果启用了符号化,则包含与 `trace` 对应的带行号的文件名字符串。 +- `query_id` ([String](../../sql-reference/data-types/string.md)) — 查询标识符,可用于获取从 [query_log](/operations/system-tables/query_log) 系统表运行的查询的详细信息。 +- `trace` ([Array(UInt64)](../../sql-reference/data-types/array.md)) — 采样时的堆栈跟踪。每个元素是 ClickHouse 服务器进程内的虚拟内存地址。 +- `size` ([Int64](../../sql-reference/data-types/int-uint.md)) - 对于跟踪类型 `Memory`、`MemorySample` 或 `MemoryPeak`,表示分配的内存量,对于其他跟踪类型为 0。 +- `event` ([LowCardinality(String)](../../sql-reference/data-types/lowcardinality.md)) - 对于跟踪类型 `ProfileEvent`,是更新的配置事件的名称,对于其他跟踪类型为空字符串。 +- `increment` ([UInt64](../../sql-reference/data-types/int-uint.md)) - 对于跟踪类型 `ProfileEvent`,是配置事件的增量数量,对于其他跟踪类型为 0。 +- `symbols` ([Array(LowCardinality(String))](../../sql-reference/data-types/array.md)),如果启用了符号解析,包含与 `trace` 相对应的去混淆符号名称。 +- `lines` ([Array(LowCardinality(String))](../../sql-reference/data-types/array.md)),如果启用了符号解析,包含与 `trace` 相对应的文件名及行号的字符串。 -可以在服务器的配置文件中,`trace_log` 下的 `symbolize` 中启用或禁用符号化。 +符号解析可以在服务器的配置文件中 `trace_log` 下的 `symbolize` 中启用或禁用。 **示例** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/trace_log.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/trace_log.md.hash index d81c23193f6..06d988a5427 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/trace_log.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/trace_log.md.hash @@ -1 +1 @@ -fbe766f9d1272516 +d5eccd70c5482f0e diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/user_processes.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/user_processes.md index 5c728ecd6c4..4ccd9ebd508 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/user_processes.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/user_processes.md @@ -1,10 +1,11 @@ --- -'description': '系统表包含用户内存使用情况和ProfileEvents的概览信息。' +'description': '系统表包含对用户的内存使用情况和ProfileEvents的概述信息。' 'keywords': - 'system table' - 'user_processes' 'slug': '/operations/system-tables/user_processes' 'title': 'system.user_processes' +'doc_type': 'reference' --- import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_system_table_cloud.md'; @@ -19,9 +20,9 @@ import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/curre 列: - `user` ([String](../../sql-reference/data-types/string.md)) — 用户名。 -- `memory_usage` ([Int64](/sql-reference/data-types/int-uint#integer-ranges)) – 用户所有进程使用的内存(RAM)总和。它可能不包括某些类型的专用内存。请参见 [max_memory_usage](/operations/settings/settings#max_memory_usage) 设置。 -- `peak_memory_usage` ([Int64](/sql-reference/data-types/int-uint#integer-ranges)) — 用户的内存使用峰值。当用户没有运行查询时,它可以被重置。 -- `ProfileEvents` ([Map(String, UInt64)](../../sql-reference/data-types/map)) – 测量用户不同指标的 ProfileEvents 汇总。它们的描述可以在表 [system.events](/operations/system-tables/events) 中找到。 +- `memory_usage` ([Int64](/sql-reference/data-types/int-uint#integer-ranges)) – 用户所有进程使用的 RAM 的总和。可能不包括某些类型的专用内存。有关详细信息,请参见 [max_memory_usage](/operations/settings/settings#max_memory_usage) 设置。 +- `peak_memory_usage` ([Int64](/sql-reference/data-types/int-uint#integer-ranges)) — 用户的内存使用峰值。当用户没有运行任何查询时,可以重置该值。 +- `ProfileEvents` ([Map(String, UInt64)](../../sql-reference/data-types/map)) – 测量用户不同指标的 ProfileEvents 的摘要。有关它们的描述请参见表 [system.events](/operations/system-tables/events) ```sql SELECT * FROM system.user_processes LIMIT 10 FORMAT Vertical; diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/user_processes.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/user_processes.md.hash index ba241364a90..f0de77f950c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/user_processes.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/user_processes.md.hash @@ -1 +1 @@ -78927216dfdd855e +04fab442ae6848f9 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/users.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/users.md index b712dafad09..c982f098c0e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/users.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/users.md @@ -1,41 +1,42 @@ --- -'description': '系统表包含配置在服务器上的用户帐户列表。' +'description': '系统表包含在服务器上配置的用户帐户列表。' 'keywords': - 'system table' - 'users' 'slug': '/operations/system-tables/users' 'title': 'system.users' +'doc_type': 'reference' --- # system.users -包含在服务器上配置的 [用户账户](../../guides/sre/user-management/index.md#user-account-management) 列表。 +包含在服务器上配置的 [用户帐户](../../guides/sre/user-management/index.md#user-account-management) 列表。 列: - `name` ([String](../../sql-reference/data-types/string.md)) — 用户名。 -- `id` ([UUID](../../sql-reference/data-types/uuid.md)) — 用户 ID。 +- `id` ([UUID](../../sql-reference/data-types/uuid.md)) — 用户ID。 -- `storage` ([String](../../sql-reference/data-types/string.md)) — 用户存储的路径。在 `access_control_path` 参数中配置。 +- `storage` ([String](../../sql-reference/data-types/string.md)) — 用户存储的路径。配置在 `access_control_path` 参数中。 -- `auth_type` ([Enum8](../../sql-reference/data-types/enum.md)('no_password' = 0, 'plaintext_password' = 1, 'sha256_password' = 2, 'double_sha1_password' = 3, 'ldap' = 4, 'kerberos' = 5, 'ssl_certificate' = 6, 'bcrypt_password' = 7)) — 显示认证类型。用户识别有多种方式:无密码、明文密码、[SHA256](https://en.wikipedia.org/wiki/SHA-2) 编码的密码、[double SHA-1](https://en.wikipedia.org/wiki/SHA-1) 编码的密码或 [bcrypt](https://en.wikipedia.org/wiki/Bcrypt) 编码的密码。 +- `auth_type` ([Enum8](../../sql-reference/data-types/enum.md)('no_password' = 0, 'plaintext_password' = 1, 'sha256_password' = 2, 'double_sha1_password' = 3, 'ldap' = 4, 'kerberos' = 5, 'ssl_certificate' = 6, 'bcrypt_password' = 7)) — 显示身份验证类型。用户识别的方式有多种:无密码、明文密码、[SHA256](https://en.wikipedia.org/wiki/SHA-2) 编码密码、[双 SHA-1](https://en.wikipedia.org/wiki/SHA-1) 编码密码或 [bcrypt](https://en.wikipedia.org/wiki/Bcrypt) 编码密码。 -- `auth_params` ([String](../../sql-reference/data-types/string.md)) — 根据 `auth_type` 的 JSON 格式的认证参数。 +- `auth_params` ([String](../../sql-reference/data-types/string.md)) — 根据 `auth_type` 的 JSON 格式的身份验证参数。 -- `host_ip` ([Array](../../sql-reference/data-types/array.md)([String](../../sql-reference/data-types/string.md))) — 允许连接到 ClickHouse 服务器的主机 IP 地址。 +- `host_ip` ([Array](../../sql-reference/data-types/array.md)([String](../../sql-reference/data-types/string.md))) — 允许连接到 ClickHouse 服务器的主机的 IP 地址。 - `host_names` ([Array](../../sql-reference/data-types/array.md)([String](../../sql-reference/data-types/string.md))) — 允许连接到 ClickHouse 服务器的主机名称。 - `host_names_regexp` ([Array](../../sql-reference/data-types/array.md)([String](../../sql-reference/data-types/string.md))) — 允许连接到 ClickHouse 服务器的主机名称的正则表达式。 -- `host_names_like` ([Array](../../sql-reference/data-types/array.md)([String](../../sql-reference/data-types/string.md))) — 允许连接到 ClickHouse 服务器的主机名称,使用 LIKE 谓词设置。 +- `host_names_like` ([Array](../../sql-reference/data-types/array.md)([String](../../sql-reference/data-types/string.md))) — 使用 LIKE 谓词设置的允许连接到 ClickHouse 服务器的主机名称。 -- `default_roles_all` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) — 显示为用户默认授予的所有角色。 +- `default_roles_all` ([UInt8](/sql-reference/data-types/int-uint#integer-ranges)) — 显示为用户默认设置的所有授予角色。 - `default_roles_list` ([Array](../../sql-reference/data-types/array.md)([String](../../sql-reference/data-types/string.md))) — 默认提供的授予角色列表。 -- `default_roles_except` ([Array](../../sql-reference/data-types/array.md)([String](../../sql-reference/data-types/string.md))) — 除了列出的角色之外,所有默认授予的角色。 +- `default_roles_except` ([Array](../../sql-reference/data-types/array.md)([String](../../sql-reference/data-types/string.md))) — 所有默认设置的授予角色,排除了列出的角色。 ## 另见 {#see-also} diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/users.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/users.md.hash index c8bbdd61689..044baebb97c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/users.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/users.md.hash @@ -1 +1 @@ -54783e84c9e71887 +c596cbc4bea50772 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/view_refreshes.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/view_refreshes.md index e2a90af801b..50ab2247498 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/view_refreshes.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/view_refreshes.md @@ -1,10 +1,11 @@ --- -'description': '系统表 containing 关于 Refreshable 物化视图 的 信息.' +'description': '系统表包含关于可刷新的物化视图的信息。' 'keywords': - 'system table' - 'view_refreshes' 'slug': '/operations/system-tables/view_refreshes' 'title': 'system.view_refreshes' +'doc_type': 'reference' --- import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_system_table_cloud.md'; @@ -14,7 +15,7 @@ import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/curre -关于 [可刷新物化视图](../../sql-reference/statements/create/view.md#refreshable-materialized-view) 的信息。包含所有可刷新物化视图,无论当前是否有刷新正在进行。 +关于 [可刷新的物化视图](../../sql-reference/statements/create/view.md#refreshable-materialized-view) 的信息。包含所有可刷新的物化视图,无论是否正在进行刷新。 列: @@ -22,15 +23,15 @@ import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/curre - `view` ([String](../../sql-reference/data-types/string.md)) — 表名。 - `uuid` ([UUID](../../sql-reference/data-types/uuid.md)) — 表的 uuid(原子数据库)。 - `status` ([String](../../sql-reference/data-types/string.md)) — 刷新的当前状态。 -- `last_success_time` ([Nullable](../../sql-reference/data-types/nullable.md)([DateTime](../../sql-reference/data-types/datetime.md))) — 最后一次成功刷新开始的时间。如果自服务器启动或表创建以来没有成功刷新,则为 NULL。 -- `last_success_duration_ms` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 最后一次刷新耗时。 -- `last_refresh_time` ([Nullable](../../sql-reference/data-types/nullable.md)([DateTime](../../sql-reference/data-types/datetime.md))) — 最后一次刷新尝试完成的时间(如果已知)或开始的时间(如果未知或仍在运行)。如果自服务器启动或表创建以来没有刷新尝试,则为 NULL。 -- `last_refresh_replica` ([String](../../sql-reference/data-types/string.md)) — 如果协调已启用,则为当前(如果正在运行)或之前(如果未运行)的刷新尝试所使用的副本名称。 -- `next_refresh_time` ([Nullable](../../sql-reference/data-types/nullable.md)([DateTime](../../sql-reference/data-types/datetime.md))) — 如果状态 = Scheduled,则为计划开始下一个刷新的时间。 -- `exception` ([String](../../sql-reference/data-types/string.md)) — 如果上一次尝试失败,则返回的错误信息。 -- `retry` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 到目前为止,当前刷新有多少次失败的尝试。 -- `progress` ([Float64](../../sql-reference/data-types/float.md)) — 当前刷新的进度,在 0 和 1 之间。如果状态为 `RunningOnAnotherReplica`,则不可用。 -- `read_rows` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 当前刷新迄今读取的行数。如果状态为 `RunningOnAnotherReplica`,则不可用。 +- `last_success_time` ([Nullable](../../sql-reference/data-types/nullable.md)([DateTime](../../sql-reference/data-types/datetime.md))) — 最新成功刷新的开始时间。如果自服务器启动或表创建以来没有成功的刷新,则为 NULL。 +- `last_success_duration_ms` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt64](../../sql-reference/data-types/int-uint.md))) — 最近一次刷新的持续时间。 +- `last_refresh_time` ([Nullable](../../sql-reference/data-types/nullable.md)([DateTime](../../sql-reference/data-types/datetime.md))) — 最新刷新尝试完成(如果已知)或开始(如果未知或仍在运行)时的时间。如果自服务器启动或表创建以来没有刷新尝试,则为 NULL。 +- `last_refresh_replica` ([String](../../sql-reference/data-types/string.md)) — 如果启用了协调,则当前(如果正在运行)或之前(如果未运行)刷新尝试的副本名称。 +- `next_refresh_time` ([Nullable](../../sql-reference/data-types/nullable.md)([DateTime](../../sql-reference/data-types/datetime.md))) — 下次刷新的计划开始时间,如果状态为 Scheduled。 +- `exception` ([String](../../sql-reference/data-types/string.md)) — 如果之前的尝试失败,则为错误消息。 +- `retry` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 到目前为止,此次刷新已失败的尝试次数。 +- `progress` ([Float64](../../sql-reference/data-types/float.md)) — 当前刷新的进度,介于 0 和 1 之间。如果状态为 `RunningOnAnotherReplica`,则不可用。 +- `read_rows` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 当前刷新已读取的行数。如果状态为 `RunningOnAnotherReplica`,则不可用。 - `read_bytes` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 当前刷新期间读取的字节数。如果状态为 `RunningOnAnotherReplica`,则不可用。 - `total_rows` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 当前刷新需要读取的估计总行数。如果状态为 `RunningOnAnotherReplica`,则不可用。 - `written_rows` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 当前刷新期间写入的行数。如果状态为 `RunningOnAnotherReplica`,则不可用。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/view_refreshes.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/view_refreshes.md.hash index f14b03ea021..230c2bb2b0e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/view_refreshes.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/view_refreshes.md.hash @@ -1 +1 @@ -1858de010054b2dc +22ef66e047140726 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/workloads.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/workloads.md index 776714f49e3..b04a443a530 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/workloads.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/workloads.md @@ -1,16 +1,17 @@ --- -'description': '系统表包含本地服务器上驻留的工作负载的信息。' +'description': '系统表包含有关驻留在本地服务器上的工作负载的信息。' 'keywords': - 'system table' - 'workloads' 'slug': '/operations/system-tables/workloads' 'title': 'system.workloads' +'doc_type': 'reference' --- # system.workloads -包含有关本地服务器上 [工作负载](/operations/workload-scheduling.md#workload_entity_storage) 的信息。该表为每个工作负载包含一行。 +包含本地服务器上[工作负载](/operations/workload-scheduling.md#workload_entity_storage)的信息。该表为每个工作负载包含一行。 示例: @@ -43,5 +44,5 @@ create_query: CREATE WORKLOAD `all` 列: - `name` (`String`) - 工作负载名称。 -- `parent` (`String`) - 父工作负载名称。 +- `parent` (`String`) - 上级工作负载名称。 - `create_query` (`String`) - 工作负载的定义。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/workloads.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/workloads.md.hash index 9f9574e9d1c..2232a672b42 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/workloads.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/workloads.md.hash @@ -1 +1 @@ -ae1ce4ff2f02a8ec +1bf753ee6914ec99 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/zookeeper.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/zookeeper.md index ad286591bd1..7a7a8ddab5c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/zookeeper.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/zookeeper.md @@ -1,41 +1,46 @@ --- -'description': '系统表仅在配置了 ClickHouse Keeper 或 ZooKeeper 时存在。它暴露来自配置中定义的 Keeper 集群的数据。' +'description': '仅在配置了 ClickHouse Keeper 或 ZooKeeper 时存在的系统表。它暴露了配置中定义的 Keeper 集群的数据。' 'keywords': - 'system table' - 'zookeeper' 'slug': '/operations/system-tables/zookeeper' 'title': 'system.zookeeper' +'doc_type': 'reference' --- # system.zookeeper -表格在未配置 ClickHouse Keeper 或 ZooKeeper 的情况下是不存在的。`system.zookeeper` 表展示了配置中定义的 Keeper 集群的数据。 -查询必须在 `WHERE` 子句中设置一个 'path =' 条件或 `path IN` 条件,如下所示。这对应于您想要获取数据的子节点路径。 +该表在 ClickHouse Keeper 或 ZooKeeper 配置时才会存在。 `system.zookeeper` 表公开来自配置中定义的 Keeper 集群的数据。 +查询必须在 `WHERE` 子句中具有 `path =` 条件或设置 `path IN` 条件,如下所示。这对应于您想要获取数据的子节点的路径。 -查询 `SELECT * FROM system.zookeeper WHERE path = '/clickhouse'` 输出 `/clickhouse` 节点下所有子节点的数据。 +查询 `SELECT * FROM system.zookeeper WHERE path = '/clickhouse'` 输出 `/clickhouse` 节点上所有子节点的数据。 要输出所有根节点的数据,请写 `path = '/'`。 -如果在 'path' 中指定的路径不存在,将抛出异常。 +如果 'path' 中指定的路径不存在,将会抛出异常。 -查询 `SELECT * FROM system.zookeeper WHERE path IN ('/', '/clickhouse')` 输出 `/` 和 `/clickhouse` 节点下所有子节点的数据。 -如果在指定的 'path' 集合中存在不存在的路径,将抛出异常。 -它可用于批量进行 Keeper 路径查询。 +查询 `SELECT * FROM system.zookeeper WHERE path IN ('/', '/clickhouse')` 输出 `/` 和 `/clickhouse` 节点上所有子节点的数据。 +如果在指定的 'path' 集合中不存在路径,将会抛出异常。 +它可以用于批量执行 Keeper 路径查询。 + +查询 `SELECT * FROM system.zookeeper WHERE path = '/clickhouse' AND zookeeperName = 'auxiliary_cluster'` 输出 `auxiliary_cluster` ZooKeeper 集群中的数据。 +如果指定的 'auxiliary_cluster' 不存在,将会抛出异常。 列: - `name` (String) — 节点的名称。 - `path` (String) — 节点的路径。 - `value` (String) — 节点值。 +- `zookeeperName` (String) — 默认或辅助 ZooKeeper 集群的名称。 - `dataLength` (Int32) — 值的大小。 -- `numChildren` (Int32) — 子孙数量。 +- `numChildren` (Int32) — 后代的数量。 - `czxid` (Int64) — 创建节点的事务 ID。 -- `mzxid` (Int64) — 最后修改节点的事务 ID。 -- `pzxid` (Int64) — 最后删除或添加子孙的事务 ID。 +- `mzxid` (Int64) — 上一次更改节点的事务 ID。 +- `pzxid` (Int64) — 上一次删除或添加后代的事务 ID。 - `ctime` (DateTime) — 节点创建时间。 - `mtime` (DateTime) — 节点最后修改时间。 -- `version` (Int32) — 节点版本:节点被更改的次数。 -- `cversion` (Int32) — 添加或删除的子孙数量。 -- `aversion` (Int32) — ACL 变更的次数。 +- `version` (Int32) — 节点版本:节点更改的次数。 +- `cversion` (Int32) — 添加或移除后代的数量。 +- `aversion` (Int32) — ACL 更改的数量。 - `ephemeralOwner` (Int64) — 对于临时节点,拥有该节点的会话 ID。 示例: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/zookeeper.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/zookeeper.md.hash index bcb4f2be266..e20327cebe9 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/zookeeper.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/zookeeper.md.hash @@ -1 +1 @@ -10fb080875a37ac5 +53915220f5eb5e8f diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/zookeeper_connection.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/zookeeper_connection.md index 6857ececbe9..2566c77c1a5 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/zookeeper_connection.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/zookeeper_connection.md @@ -1,10 +1,11 @@ --- -'description': '仅在配置了 ZooKeeper 的情况下存在的系统表。显示当前与 ZooKeeper 的连接(包括辅助 ZooKeeper)。' +'description': '系统表,仅在配置了 ZooKeeper 时存在。显示当前与 ZooKeeper 的连接(包括辅助 ZooKeeper)。' 'keywords': - 'system table' - 'zookeeper_connection' 'slug': '/operations/system-tables/zookeeper_connection' 'title': 'system.zookeeper_connection' +'doc_type': 'reference' --- import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_system_table_cloud.md'; @@ -14,21 +15,21 @@ import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/curre -如果未配置 ZooKeeper,则此表不存在。 'system.zookeeper_connection' 表显示当前与 ZooKeeper 的连接(包括辅助 ZooKeeper)。每一行显示有关一个连接的信息。 +如果未配置 ZooKeeper,则此表不存在。'system.zookeeper_connection' 表显示当前与 ZooKeeper 的连接(包括辅助 ZooKeeper)。每行显示一个连接的信息。 列: - `name` ([String](../../sql-reference/data-types/string.md)) — ZooKeeper 集群的名称。 -- `host` ([String](../../sql-reference/data-types/string.md)) — ClickHouse 连接到的 ZooKeeper 节点的主机名/IP。 -- `port` ([UIn16](../../sql-reference/data-types/int-uint.md)) — ClickHouse 连接到的 ZooKeeper 节点的端口。 -- `index` ([Nullable(UInt8)](../../sql-reference/data-types/int-uint.md)) — ClickHouse 连接到的 ZooKeeper 节点的索引。该索引来自 ZooKeeper 配置。如果未连接,则此列为 NULL。 +- `host` ([String](../../sql-reference/data-types/string.md)) — ClickHouse 连接的 ZooKeeper 节点的主机名/IP。 +- `port` ([UIn16](../../sql-reference/data-types/int-uint.md)) — ClickHouse 连接的 ZooKeeper 节点的端口。 +- `index` ([Nullable(UInt8)](../../sql-reference/data-types/int-uint.md)) — ClickHouse 连接的 ZooKeeper 节点的索引。该索引来自 ZooKeeper 配置。如果未连接,则此列为 NULL。 - `connected_time` ([DateTime](../../sql-reference/data-types/datetime.md)) — 连接建立的时间。 - `session_uptime_elapsed_seconds` ([UInt64](../../sql-reference/data-types/int-uint.md)) — 自连接建立以来经过的秒数。 -- `is_expired` ([UInt8](../../sql-reference/data-types/int-uint.md)) — 当前连接是否已过期。 +- `is_expired` ([UInt8](../../sql-reference/data-types/int-uint.md)) — 当前连接是否过期。 - `keeper_api_version` ([UInt8](../../sql-reference/data-types/int-uint.md)) — Keeper API 版本。 - `client_id` ([Int64](../../sql-reference/data-types/int-uint.md)) — 连接的会话 ID。 - `xid` ([Int64](../../sql-reference/data-types/int-uint.md)) — 当前会话的 XID。 -- `enabled_feature_flags` ([Array(Enum16)](../../sql-reference/data-types/array.md)) — 启用的功能标志。仅适用于 ClickHouse Keeper。可能的值有 `FILTERED_LIST`,`MULTI_READ`,`CHECK_NOT_EXISTS`,`CREATE_IF_NOT_EXISTS`,`REMOVE_RECURSIVE`。 +- `enabled_feature_flags` ([Array(Enum16)](../../sql-reference/data-types/array.md)) — 已启用的功能标志。仅适用于 ClickHouse Keeper。可能的值有 `FILTERED_LIST`、`MULTI_READ`、`CHECK_NOT_EXISTS`、`CREATE_IF_NOT_EXISTS`、`REMOVE_RECURSIVE`。 - `availability_zone` ([String](../../sql-reference/data-types/string.md)) — 可用区。 示例: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/zookeeper_connection.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/zookeeper_connection.md.hash index 2eaf92b12f3..c37c53a54bf 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/zookeeper_connection.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/zookeeper_connection.md.hash @@ -1 +1 @@ -7ef077c2a991bc3d +1668d0d9f6194e9c diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/zookeeper_connection_log.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/zookeeper_connection_log.md new file mode 100644 index 00000000000..551dd7bf208 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/zookeeper_connection_log.md @@ -0,0 +1,60 @@ +--- +'description': '显示 ZooKeeper 连接的历史记录(包括辅助 ZooKeeper)。' +'keywords': +- 'system table' +- 'zookeeper_connection_log' +'slug': '/operations/system-tables/zookeeper_connection_log' +'title': 'system.zookeeper_connection_log' +'doc_type': 'reference' +--- + +import SystemTableCloud from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_system_table_cloud.md'; + + +# system.zookeeper_connection_log + + + +'system.zookeeper_connection_log' 表显示了 ZooKeeper 连接的历史记录(包括辅助 ZooKeeper)。每一行显示关于一个连接事件的信息。 + +:::note +该表不包含由于服务器关闭导致的断开连接事件。 +::: + +列: + +- `hostname` ([LowCardinality(String)](../../sql-reference/data-types/string.md)) — 连接到或从 ZooKeeper 断开的服务器的主机名。 +- `type` ([Enum8](../../sql-reference/data-types/enum.md)) - 事件的类型。可能的值:`Connected`, `Disconnected`。 +- `event_date` ([Date](../../sql-reference/data-types/date.md)) - 条目的日期。 +- `event_time` ([DateTime](../../sql-reference/data-types/datetime.md)) - 条目的时间。 +- `event_time_microseconds` ([Date](../../sql-reference/data-types/datetime64.md)) - 带有微秒精度的条目时间。 +- `name` ([String](../../sql-reference/data-types/string.md)) — ZooKeeper 集群的名称。 +- `host` ([String](../../sql-reference/data-types/string.md)) — ClickHouse 连接的 ZooKeeper 节点的主机名/IP。 +- `port` ([UIn16](../../sql-reference/data-types/int-uint.md)) — ClickHouse 连接的 ZooKeeper 节点的端口。 +- `index` ([UInt8](../../sql-reference/data-types/int-uint.md)) — ClickHouse 连接或断开连接的 ZooKeeper 节点的索引。索引来源于 ZooKeeper 配置。 +- `client_id` ([Int64](../../sql-reference/data-types/int-uint.md)) — 连接的会话 ID。 +- `keeper_api_version` ([UInt8](../../sql-reference/data-types/int-uint.md)) — Keeper API 版本。 +- `enabled_feature_flags` ([Array(Enum16)](../../sql-reference/data-types/array.md)) — 启用的功能标志。仅适用于 ClickHouse Keeper。可能的值有 `FILTERED_LIST`, `MULTI_READ`, `CHECK_NOT_EXISTS`, `CREATE_IF_NOT_EXISTS`, `REMOVE_RECURSIVE`。 +- `availability_zone` ([String](../../sql-reference/data-types/string.md)) — 可用区域。 +- `reason` ([String](../../sql-reference/data-types/string.md)) — 连接或断开的原因。 + +示例: + +```sql +SELECT * FROM system.zookeeper_connection_log; +``` + +```text + ┌─hostname─┬─type─────────┬─event_date─┬──────────event_time─┬────event_time_microseconds─┬─name───────────────┬─host─┬─port─┬─index─┬─client_id─┬─keeper_api_version─┬─enabled_feature_flags───────────────────────────────────────────────────────────────────────┬─availability_zone─┬─reason──────────────┐ + 1. │ node │ Connected │ 2025-05-12 │ 2025-05-12 19:49:35 │ 2025-05-12 19:49:35.713067 │ zk_conn_log_test_4 │ zoo2 │ 2181 │ 0 │ 10 │ 0 │ ['FILTERED_LIST','MULTI_READ','CHECK_NOT_EXISTS','CREATE_IF_NOT_EXISTS','REMOVE_RECURSIVE'] │ │ Initialization │ + 2. │ node │ Connected │ 2025-05-12 │ 2025-05-12 19:49:23 │ 2025-05-12 19:49:23.981570 │ default │ zoo1 │ 2181 │ 0 │ 4 │ 0 │ ['FILTERED_LIST','MULTI_READ','CHECK_NOT_EXISTS','CREATE_IF_NOT_EXISTS','REMOVE_RECURSIVE'] │ │ Initialization │ + 3. │ node │ Connected │ 2025-05-12 │ 2025-05-12 19:49:28 │ 2025-05-12 19:49:28.104021 │ default │ zoo1 │ 2181 │ 0 │ 5 │ 0 │ ['FILTERED_LIST','MULTI_READ','CHECK_NOT_EXISTS','CREATE_IF_NOT_EXISTS','REMOVE_RECURSIVE'] │ │ Initialization │ + 4. │ node │ Connected │ 2025-05-12 │ 2025-05-12 19:49:29 │ 2025-05-12 19:49:29.459251 │ zk_conn_log_test_2 │ zoo2 │ 2181 │ 0 │ 6 │ 0 │ ['FILTERED_LIST','MULTI_READ','CHECK_NOT_EXISTS','CREATE_IF_NOT_EXISTS','REMOVE_RECURSIVE'] │ │ Initialization │ + 5. │ node │ Connected │ 2025-05-12 │ 2025-05-12 19:49:29 │ 2025-05-12 19:49:29.574312 │ zk_conn_log_test_3 │ zoo3 │ 2181 │ 0 │ 7 │ 0 │ ['FILTERED_LIST','MULTI_READ','CHECK_NOT_EXISTS','CREATE_IF_NOT_EXISTS','REMOVE_RECURSIVE'] │ │ Initialization │ + 6. │ node │ Disconnected │ 2025-05-12 │ 2025-05-12 19:49:29 │ 2025-05-12 19:49:29.909890 │ default │ zoo1 │ 2181 │ 0 │ 5 │ 0 │ ['FILTERED_LIST','MULTI_READ','CHECK_NOT_EXISTS','CREATE_IF_NOT_EXISTS','REMOVE_RECURSIVE'] │ │ Config changed │ + 7. │ node │ Connected │ 2025-05-12 │ 2025-05-12 19:49:29 │ 2025-05-12 19:49:29.909895 │ default │ zoo2 │ 2181 │ 0 │ 8 │ 0 │ ['FILTERED_LIST','MULTI_READ','CHECK_NOT_EXISTS','CREATE_IF_NOT_EXISTS','REMOVE_RECURSIVE'] │ │ Config changed │ + 8. │ node │ Disconnected │ 2025-05-12 │ 2025-05-12 19:49:29 │ 2025-05-12 19:49:29.912010 │ zk_conn_log_test_2 │ zoo2 │ 2181 │ 0 │ 6 │ 0 │ ['FILTERED_LIST','MULTI_READ','CHECK_NOT_EXISTS','CREATE_IF_NOT_EXISTS','REMOVE_RECURSIVE'] │ │ Config changed │ + 9. │ node │ Connected │ 2025-05-12 │ 2025-05-12 19:49:29 │ 2025-05-12 19:49:29.912014 │ zk_conn_log_test_2 │ zoo3 │ 2181 │ 0 │ 9 │ 0 │ ['FILTERED_LIST','MULTI_READ','CHECK_NOT_EXISTS','CREATE_IF_NOT_EXISTS','REMOVE_RECURSIVE'] │ │ Config changed │ +10. │ node │ Disconnected │ 2025-05-12 │ 2025-05-12 19:49:29 │ 2025-05-12 19:49:29.912061 │ zk_conn_log_test_3 │ zoo3 │ 2181 │ 0 │ 7 │ 0 │ ['FILTERED_LIST','MULTI_READ','CHECK_NOT_EXISTS','CREATE_IF_NOT_EXISTS','REMOVE_RECURSIVE'] │ │ Removed from config │ + └──────────┴──────────────┴────────────┴─────────────────────┴────────────────────────────┴────────────────────┴──────┴──────┴───────┴───────────┴────────────────────┴─────────────────────────────────────────────────────────────────────────────────────────────┴───────────────────┴─────────────────────┘ +``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/zookeeper_connection_log.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/zookeeper_connection_log.md.hash new file mode 100644 index 00000000000..a50fb88cfc7 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/zookeeper_connection_log.md.hash @@ -0,0 +1 @@ +3a3c4a3439fb6ed8 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/zookeeper_log.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/zookeeper_log.md index 311cf3d44e9..de225d7534c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/zookeeper_log.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/zookeeper_log.md @@ -1,61 +1,62 @@ --- -'description': '系统表包含关于请求到ZooKeeper服务器的参数和它的响应的信息。' +'description': '系统表包含有关请求到 ZooKeeper 服务器的参数和其响应的信息。' 'keywords': - 'system table' - 'zookeeper_log' 'slug': '/operations/system-tables/zookeeper_log' 'title': 'system.zookeeper_log' +'doc_type': 'reference' --- # system.zookeeper_log -该表包含关于请求ZooKeeper服务器参数和其响应的信息。 +此表包含有关请求ZooKeeper服务器的参数和来自该服务器的响应的信息。 -对于请求,仅填充带有请求参数的列,其余列则填充默认值(`0`或`NULL`)。当响应到达时,响应中的数据将添加到其他列。 +对于请求,仅填写请求参数的列,其余列填充默认值(`0`或`NULL`)。当响应到达时,响应中的数据将添加到其他列中。 -带有请求参数的列: +请求参数的列: - `hostname` ([LowCardinality(String)](../../sql-reference/data-types/string.md)) — 执行查询的服务器的主机名。 -- `type` ([Enum](../../sql-reference/data-types/enum.md)) — ZooKeeper客户端中的事件类型。可以有以下值: - - `Request` — 请求已发送。 - - `Response` — 收到响应。 - - `Finalize` — 连接丢失,未收到响应。 +- `type` ([Enum](../../sql-reference/data-types/enum.md)) — ZooKeeper客户端中的事件类型。可以具有以下值之一: + - `Request` — 请求已被发送。 + - `Response` — 响应已被接收。 + - `Finalize` — 连接丢失,未收到响应。 - `event_date` ([Date](../../sql-reference/data-types/date.md)) — 事件发生的日期。 - `event_time` ([DateTime64](../../sql-reference/data-types/datetime64.md)) — 事件发生的日期和时间。 -- `address` ([IPv6](../../sql-reference/data-types/ipv6.md)) — 用于发送请求的ZooKeeper服务器的IP地址。 -- `port` ([UInt16](../../sql-reference/data-types/int-uint.md)) — 用于发送请求的ZooKeeper服务器的端口。 +- `address` ([IPv6](../../sql-reference/data-types/ipv6.md)) — 用于发起请求的ZooKeeper服务器的IP地址。 +- `port` ([UInt16](../../sql-reference/data-types/int-uint.md)) — 用于发起请求的ZooKeeper服务器的端口。 - `session_id` ([Int64](../../sql-reference/data-types/int-uint.md)) — ZooKeeper服务器为每个连接设置的会话ID。 -- `xid` ([Int32](../../sql-reference/data-types/int-uint.md)) — 会话内请求的ID。通常是一个顺序请求编号。它在请求行和配对的`response`/`finalize`行中是相同的。 -- `has_watch` ([UInt8](../../sql-reference/data-types/int-uint.md)) — 请求是否已设置[watch](https://zookeeper.apache.org/doc/r3.3.3/zookeeperProgrammers.html#ch_zkWatches)。 +- `xid` ([Int32](../../sql-reference/data-types/int-uint.md)) — 会话内请求的ID。通常这是一个顺序请求编号。请求行和配对的`response`/`finalize`行具有相同的值。 +- `has_watch` ([UInt8](../../sql-reference/data-types/int-uint.md)) — 请求是否设置了[watch](https://zookeeper.apache.org/doc/r3.3.3/zookeeperProgrammers.html#ch_zkWatches)。 - `op_num` ([Enum](../../sql-reference/data-types/enum.md)) — 请求或响应的类型。 -- `path` ([String](../../sql-reference/data-types/string.md)) — 在请求中指定的ZooKeeper节点的路径,如果请求不需要指定路径,则为空字符串。 -- `data` ([String](../../sql-reference/data-types/string.md)) — 写入ZooKeeper节点的数据(对于`SET`和`CREATE`请求——请求想要写入的内容,对于`GET`请求的响应——读取的内容)或为空字符串。 +- `path` ([String](../../sql-reference/data-types/string.md)) — 请求中指定的ZooKeeper节点的路径,如果请求不需要指定路径,则为一个空字符串。 +- `data` ([String](../../sql-reference/data-types/string.md)) — 写入ZooKeeper节点的数据(对于`SET`和`CREATE`请求 — 请求希望写入的内容,对于`GET`请求的响应 — 读取到的内容)或空字符串。 - `is_ephemeral` ([UInt8](../../sql-reference/data-types/int-uint.md)) — ZooKeeper节点是否作为[临时节点](https://zookeeper.apache.org/doc/r3.3.3/zookeeperProgrammers.html#Ephemeral+Nodes)创建。 - `is_sequential` ([UInt8](../../sql-reference/data-types/int-uint.md)) — ZooKeeper节点是否作为[顺序节点](https://zookeeper.apache.org/doc/r3.3.3/zookeeperProgrammers.html#Sequence+Nodes+--+Unique+Naming)创建。 -- `version` ([Nullable(Int32)](../../sql-reference/data-types/nullable.md)) — 请求在执行时所期望的ZooKeeper节点的版本。这对于`CHECK`、`SET`、`REMOVE`请求是支持的(如果请求不检查版本,则为`-1`,对于不支持版本检查的其他请求,则为`NULL`)。 -- `requests_size` ([UInt32](../../sql-reference/data-types/int-uint.md)) — 包含在多请求中的请求数量(这是一个特殊请求,由多个连续的普通请求组成,并以原子方式执行)。所有包含在多请求中的请求将具有相同的`xid`。 -- `request_idx` ([UInt32](../../sql-reference/data-types/int-uint.md)) — 包含在多请求中的请求编号(对于多请求——`0`,然后按顺序为`1`)。 - -带有请求响应参数的列: - -- `zxid` ([Int64](../../sql-reference/data-types/int-uint.md)) — ZooKeeper事务ID。成功执行请求后,由ZooKeeper服务器发出的序列号(如果请求未执行/返回错误/客户端不知道请求是否执行,则为`0`)。 -- `error` ([Nullable(Enum)](../../sql-reference/data-types/nullable.md)) — 错误代码。可以有多种值,以下是其中一些: - - `ZOK` — 请求已成功执行。 - - `ZCONNECTIONLOSS` — 连接丢失。 - - `ZOPERATIONTIMEOUT` — 请求执行超时已过。 - - `ZSESSIONEXPIRED` — 会话已过期。 - - `NULL` — 请求已完成。 +- `version` ([Nullable(Int32)](../../sql-reference/data-types/nullable.md)) — 请求在执行时期望的ZooKeeper节点的版本。这适用于`CHECK`、`SET`、`REMOVE`请求(如果请求不检查版本,则相关`-1`,对于不支持版本检查的其他请求,则为`NULL`)。 +- `requests_size` ([UInt32](../../sql-reference/data-types/int-uint.md)) — 包含在多请求中的请求数量(这是一个特殊请求,由几个连续的普通请求组成,并原子性执行)。所有包含在多请求中的请求将具有相同的`xid`。 +- `request_idx` ([UInt32](../../sql-reference/data-types/int-uint.md)) — 包含在多请求中的请求编号(对于多请求 — `0`,然后按顺序 `1`)。 + +请求响应参数的列: + +- `zxid` ([Int64](../../sql-reference/data-types/int-uint.md)) — ZooKeeper事务ID。ZooKeeper服务器对成功执行的请求发出的序列号(如果请求未执行/返回错误/客户端不知道请求是否执行,则为`0`)。 +- `error` ([Nullable(Enum)](../../sql-reference/data-types/nullable.md)) — 错误代码。可以具有多个值,这里只是一些示例: + - `ZOK` — 请求已成功执行。 + - `ZCONNECTIONLOSS` — 连接丢失。 + - `ZOPERATIONTIMEOUT` — 请求执行超时已过期。 + - `ZSESSIONEXPIRED` — 会话已过期。 + - `NULL` — 请求已完成。 - `watch_type` ([Nullable(Enum)](../../sql-reference/data-types/nullable.md)) — `watch`事件的类型(对于`op_num` = `Watch`的响应),对于其余响应:`NULL`。 - `watch_state` ([Nullable(Enum)](../../sql-reference/data-types/nullable.md)) — `watch`事件的状态(对于`op_num` = `Watch`的响应),对于其余响应:`NULL`。 -- `path_created` ([String](../../sql-reference/data-types/string.md)) — 创建的ZooKeeper节点的路径(对于`CREATE`请求的响应),如果节点作为`sequential`创建,则可能与`path`不同。 -- `stat_czxid` ([Int64](../../sql-reference/data-types/int-uint.md)) — 导致此ZooKeeper节点被创建的更改的`zxid`。 -- `stat_mzxid` ([Int64](../../sql-reference/data-types/int-uint.md)) — 最后修改此ZooKeeper节点的更改的`zxid`。 -- `stat_pzxid` ([Int64](../../sql-reference/data-types/int-uint.md)) — 最后修改此ZooKeeper节点子项的更改的事务ID。 -- `stat_version` ([Int32](../../sql-reference/data-types/int-uint.md)) — 此ZooKeeper节点数据的更改次数。 -- `stat_cversion` ([Int32](../../sql-reference/data-types/int-uint.md)) — 此ZooKeeper节点子项的更改次数。 +- `path_created` ([String](../../sql-reference/data-types/string.md)) — 创建的ZooKeeper节点的路径(对于`CREATE`请求的响应),如果节点以`sequential`创建,则可能与`path`不同。 +- `stat_czxid` ([Int64](../../sql-reference/data-types/int-uint.md)) — 导致该ZooKeeper节点被创建的变更的`zxid`。 +- `stat_mzxid` ([Int64](../../sql-reference/data-types/int-uint.md)) — 最后修改该ZooKeeper节点的变更的`zxid`。 +- `stat_pzxid` ([Int64](../../sql-reference/data-types/int-uint.md)) — 最后修改该ZooKeeper节点的子节点的变更的事务ID。 +- `stat_version` ([Int32](../../sql-reference/data-types/int-uint.md)) — 此ZooKeeper节点数据的变更次数。 +- `stat_cversion` ([Int32](../../sql-reference/data-types/int-uint.md)) — 此ZooKeeper节点子节点的变更次数。 - `stat_dataLength` ([Int32](../../sql-reference/data-types/int-uint.md)) — 此ZooKeeper节点数据字段的长度。 -- `stat_numChildren` ([Int32](../../sql-reference/data-types/int-uint.md)) — 此ZooKeeper节点的子项数量。 +- `stat_numChildren` ([Int32](../../sql-reference/data-types/int-uint.md)) — 此ZooKeeper节点的子节点数量。 - `children` ([Array(String)](../../sql-reference/data-types/array.md)) — 子ZooKeeper节点的列表(对于`LIST`请求的响应)。 **示例** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/zookeeper_log.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/zookeeper_log.md.hash index fd1d0097876..e72270b0312 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/zookeeper_log.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/system-tables/zookeeper_log.md.hash @@ -1 +1 @@ -e701a4e2777f1dce +5c71c106f6dee3fe diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/tips.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/tips.md index fd6f4acd1ef..9fdacd84ffa 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/tips.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/tips.md @@ -5,6 +5,7 @@ 'sidebar_position': 58 'slug': '/operations/tips' 'title': '使用建议' +'doc_type': 'guide' --- import SelfManaged from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_self_managed_only_automated.md'; @@ -13,7 +14,7 @@ import SelfManaged from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_s ## CPU Scaling Governor {#cpu-scaling-governor} -始终使用 `performance` 调节器。`on-demand` 调节器在不断高需求的情况下表现更差。 +始终使用 `performance` scaling governor。`on-demand` scaling governor 在需求持续较高时效果较差。 ```bash $ echo 'performance' | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor @@ -21,158 +22,160 @@ $ echo 'performance' | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_gov ## CPU Limitations {#cpu-limitations} -处理器可能会过热。使用 `dmesg` 查看 CPU 的时钟频率是否因为过热而被限制。 -这种限制也可以在数据中心级别进行外部设置。您可以使用 `turbostat` 在负载下监控它。 +处理器可能过热。使用 `dmesg` 查看 CPU 时钟频率是否因过热而受到限制。 +该限制还可以在数据中心级别外部设置。您可以使用 `turbostat` 监控其在负载下的表现。 ## RAM {#ram} -对于少量数据(压缩后约 200 GB),最好使用与数据量相同的内存。 -对于大量数据和处理交互(在线)查询时,您应该使用合理数量的 RAM(128 GB 或更多),以便热数据子集能够适应页面的缓存。 -即使对于每台服务器约 50 TB 的数据量,使用 128 GB 的 RAM 与 64 GB 相比,查询性能显著提高。 +对于小量数据(压缩后约 200 GB),使用与数据量相同的内存是最佳选择。 +对于大量数据且处理交互性(在线)查询时,应该使用合理数量的 RAM(128 GB 或更多),以便热数据子集能够适合页面缓存。 +即使对每台服务器约 50 TB 的数据量,使用 128 GB 的 RAM 相比于 64 GB 显著改善查询性能。 -请勿禁用过量分配。值 `cat /proc/sys/vm/overcommit_memory` 应为 0 或 1。运行 +不要禁用过度提交。值 `cat /proc/sys/vm/overcommit_memory` 应为 0 或 1。运行 ```bash $ echo 0 | sudo tee /proc/sys/vm/overcommit_memory ``` -使用 `perf top` 观察内核在内存管理中花费的时间。 -永久大页也不需要分配。 +使用 `perf top` 观察内核在内存管理上的耗时。 +永久性大页也不需要分配。 -### 使用少于 16GB 的 RAM {#using-less-than-16gb-of-ram} +### Using less than 16GB of RAM {#using-less-than-16gb-of-ram} -推荐的 RAM 数量为 32 GB 或更多。 +推荐的 RAM 量为 32 GB 或更多。 -如果您的系统 RAM 少于 16 GB,您可能会遇到各种内存异常,因为默认设置与该数量的内存不匹配。您可以在具有少量 RAM 的系统中使用 ClickHouse(低至 2 GB),但这些设置需要额外调优,且只能以较低速率接收数据。 +如果您的系统 RAM 少于 16 GB,您可能会遇到各种内存异常,因为默认设置与此 RAM 量不匹配。您可以在 RAM 较少的系统中使用 ClickHouse(最低可到 2 GB),但这些设置需要额外的调优,并且只能以较低的速率摄取数据。 -当使用少于 16GB 的 RAM 的 ClickHouse 时,我们建议如下: +使用少于 16GB RAM 的 ClickHouse 时,建议如下: -- 在 `config.xml` 中降低标记缓存的大小。可以设置为低至 500 MB,但不能设置为零。 -- 将查询处理线程的数量降低到 `1`。 -- 将 `max_block_size` 降低到 `8192`。可以低至 `1024` 的值仍然可以实用。 -- 将 `max_download_threads` 降低到 `1`。 +- 在 `config.xml` 中降低标记缓存的大小。可以设置到最低 500 MB,但不能设置为零。 +- 将查询处理线程数减少至 `1`。 +- 将 `max_block_size` 降低至 `8192`。值低至 `1024` 仍然可以运行。 +- 将 `max_download_threads` 降低至 `1`。 - 将 `input_format_parallel_parsing` 和 `output_format_parallel_formatting` 设置为 `0`。 +- 禁用写入日志表,因为它会使后台合并任务保留 RAM 以执行日志表的合并。禁用 `asynchronous_metric_log`、`metric_log`、`text_log`、`trace_log`。 -额外说明: +附加说明: - 要刷新内存分配器缓存的内存,可以运行 `SYSTEM JEMALLOC PURGE` 命令。 -- 我们不建议在低内存机器上使用 S3 或 Kafka 集成,因为它们需要大量内存用于缓冲区。 +- 我们不建议在低内存机器上使用 S3 或 Kafka 集成,因为它们需要大量内存用于缓冲。 ## Storage Subsystem {#storage-subsystem} -如果您的预算允许,请使用 SSD。 -如果不行,请使用 HDD。7200 RPM 的 SATA HDD 也可以。 +如果预算允许,使用 SSD。 +如果不行,使用 HDD。SATA HDD 7200 RPM 就可以。 -优先选择多台本地硬盘的服务器,而不是少量附带磁盘架的服务器。 -但是对于存储查询较少的归档,磁盘架将起作用。 +优先考虑具有本地硬盘的多个服务器,而不是少量附加磁盘架的服务器。 +但对于存储查询较少的归档,磁盘架将有效。 ## RAID {#raid} -使用 HDD 时,可以组合成 RAID-10、RAID-5、RAID-6 或 RAID-50。 -对于 Linux 软件 RAID 更好(使用 `mdadm`)。 -创建 RAID-10 时,选择 `far` 布局。 +使用 HDD 时,可以组合它们的 RAID-10、RAID-5、RAID-6 或 RAID-50。 +对于 Linux 而言,软件 RAID 更佳(使用 `mdadm`)。 +创建 RAID-10 时,选择 `far` 布局。 如果预算允许,选择 RAID-10。 -单独使用 LVM(没有 RAID 或 `mdadm`)也是可以的,但与之组合使用 RAID 或与 `mdadm` 结合使用的选项探索较少,且出错的机会较大(选择错误的块大小;块未对齐;选择错误的 RAID 类型;忘记清理磁盘)。如果您对使用 LVM 有信心,那么使用它是可行的。 +LVM 本身(无需 RAID 或 `mdadm`)也可以,但与之一起创建 RAID 或将其与 `mdadm` 结合使用是较少探索的选项,发生错误的机会较多(选择错误的块大小;块不对齐;选择错误的 RAID 类型;忘记清理磁盘)。如果您对使用 LVM 有信心,则没有什么不妥。 -如果您有 4 个以上的磁盘,使用 RAID-6(优选)或 RAID-50,而不是 RAID-5。 -使用 RAID-5、RAID-6 或 RAID-50 时,始终增加 stripe_cache_size,因为默认值通常不是最佳选择。 +如果您有超过 4 个磁盘,使用 RAID-6(首选)或 RAID-50,而不是 RAID-5。 +在使用 RAID-5、RAID-6 或 RAID-50 时,请始终增加 stripe_cache_size,因为默认值通常不是最佳选择。 ```bash $ echo 4096 | sudo tee /sys/block/md2/md/stripe_cache_size ``` -使用公式 `2 * num_devices * chunk_size_in_bytes / 4096` 来计算设备数量和块大小的精确数值。 +根据设备数量和块大小计算确切数字,使用公式:`2 * num_devices * chunk_size_in_bytes / 4096`。 -64 KB 的块大小对大多数 RAID 配置都是足够的。平均 clickhouse-server 写入大小约为 1 MB(1024 KB),因此建议的条带大小也为 1 MB。如果需要,块大小可以优化为 1 MB 除以 RAID 阵列中非奇偶校验磁盘的数量,以便每次写入在所有可用的非奇偶校验磁盘上并行化。 -请勿将块大小设置得过小或过大。 +64 KB 的块大小对于大多数 RAID 配置是足够的。平均 clickhouse-server 写入大小约为 1 MB(1024 KB),因此推荐的条带大小也是 1 MB。 如果需要,可以在设为 1 MB 除以 RAID 阵列中非奇偶校验磁盘数量时进行优化,这样每次写入都在所有可用的非奇偶校验磁盘之间并行处理。 +绝不要将块大小设置得过小或过大。 -您可以在 SSD 上使用 RAID-0。 -无论是否使用 RAID,始终使用复制以确保数据安全。 +您可以在 SSD 上使用 RAID-0。 +无论是否使用 RAID,总是使用复制来确保数据安全。 -启用带有长队列的 NCQ。对于 HDD,选择 mq-deadline 或 CFQ 调度器,对于 SSD,选择 noop。请勿减少 'readahead' 设置。 -对于 HDD,启用写缓存。 +启用带有长队列的 NCQ。对于 HDD,请选择 mq-deadline 或 CFQ 调度程序,对于 SSD,请选择 noop。不要降低 'readahead' 设置。 +对于 HDD,启用写入缓存。 -确保在您的操作系统中启用 [`fstrim`](https://en.wikipedia.org/wiki/Trim_(computing)),用于 NVME 和 SSD 磁盘(通常是通过定时作业或 systemd 服务实现)。 +确保 [`fstrim`](https://en.wikipedia.org/wiki/Trim_(computing)) 在您的操作系统中为 NVME 和 SSD 磁盘启用(通常是通过 cronjob 或 systemd 服务实现的)。 ## File System {#file-system} -Ext4 是最可靠的选择。设置挂载选项为 `noatime`。XFS 也表现良好。 -大多数其他文件系统也应该可以正常工作。 +Ext4 是最可靠的选项。设置挂载选项为 `noatime`。XFS 也可以很好地工作。 +大多数其他文件系统也应该工作良好。 -由于缺少硬链接,FAT-32 和 exFAT 不受支持。 +由于缺乏硬链接,FAT-32 和 exFAT 不受支持。 -请勿使用压缩文件系统,因为 ClickHouse 自行进行更好的压缩。 -不建议使用加密文件系统,因为您可以在 ClickHouse 中使用内置加密功能,从而更为优越。 +不要使用压缩文件系统,因为 ClickHouse 自行进行更好的压缩。 +不推荐使用加密文件系统,因为您可以在 ClickHouse 中使用内置加密,这更具优势。 -虽然 ClickHouse 可以在 NFS 上工作,但并不推荐。 +虽然 ClickHouse 可以通过 NFS 工作,但这不是最佳选择。 ## Linux Kernel {#linux-kernel} -请勿使用过时的 Linux 内核。 +不要使用过时的 Linux 内核。 ## Network {#network} -如果您使用 IPv6,请增加路由缓存的大小。 -3.2 之前的 Linux 内核在 IPv6 实现上存在众多问题。 +如果您正在使用 IPv6,请增加路由缓存的大小。 +3.2 之前的 Linux 内核在 IPv6 实现方面存在许多问题。 -如果可能,请使用至少 10 GB 的网络。1 Gb 也可以工作,但在使用数十 TB 数据进行修补副本或处理大量中间数据的分布式查询时会表现更差。 +如果可能,请使用至少 10 GB 的网络。1 Gb 也可以,但在修补拥有数十 TB 数据的副本或处理具有大量中间数据的分布式查询时效果会很差。 ## Huge Pages {#huge-pages} -如果您使用旧版 Linux 内核,请禁用透明大页。它干扰内存分配器,导致显著的性能下降。 -在较新版本的 Linux 内核上,透明大页是可以的。 +如果您使用的是旧的 Linux 内核,请禁用透明大页。它会干扰内存分配器,从而导致显著的性能下降。 +在较新的 Linux 内核上,透明大页是可以的。 ```bash $ echo 'madvise' | sudo tee /sys/kernel/mm/transparent_hugepage/enabled ``` -如果您希望永久修改透明大页设置,请编辑 `/etc/default/grub`,将 `transparent_hugepage=madvise` 添加到 `GRUB_CMDLINE_LINUX_DEFAULT` 选项: +如果您想永久修改透明大页设置,请编辑 `/etc/default/grub`,将 `transparent_hugepage=madvise` 添加到 `GRUB_CMDLINE_LINUX_DEFAULT` 选项中: ```bash $ GRUB_CMDLINE_LINUX_DEFAULT="transparent_hugepage=madvise ..." ``` -之后,运行 `sudo update-grub` 命令,然后重启以生效。 +之后,运行 `sudo update-grub` 命令,然后重新启动以生效。 ## Hypervisor configuration {#hypervisor-configuration} -如果您使用 OpenStack,请在 `nova.conf` 中设置 +如果您使用 OpenStack,请在 `nova.conf` 中设置 ```ini cpu_mode=host-passthrough ```。 -如果您使用 libvirt,请在 XML 配置中设置 +如果您使用 libvirt,请在 XML 配置中设置 ```xml ```。 -这对于 ClickHouse 能够通过 `cpuid` 指令获取正确的信息非常重要。 -否则,当 hypervisor 在旧 CPU 模型上运行时,您可能会遇到 `Illegal instruction` 崩溃。 +这对于 ClickHouse 能够正确获取 `cpuid` 指令的信息非常重要。 +否则,您可能会在旧 CPU 型号上运行虚拟机监控程序时遇到 `Illegal instruction` 崩溃问题。 ## ClickHouse Keeper and ZooKeeper {#zookeeper} -建议使用 ClickHouse Keeper 来替代 ZooKeeper 进行 ClickHouse 集群。有关 ClickHouse Keeper 的文档,请参见 [ClickHouse Keeper](../guides/sre/keeper/index.md) +推荐使用 ClickHouse Keeper 替代 ZooKeeper 作为 ClickHouse 集群。查看 [ClickHouse Keeper](../guides/sre/keeper/index.md) 的文档。 -如果您希望继续使用 ZooKeeper,则最好使用最新版本的 ZooKeeper——3.4.9 或更高版本。稳定 Linux 发行版中的版本可能已经过时。 +如果您想继续使用 ZooKeeper,最好使用新版本的 ZooKeeper – 3.4.9 或更高版本。稳定版 Linux 发行版中的版本可能已经过时。 -绝不要使用手动编写的脚本在不同的 ZooKeeper 集群之间传输数据,因为结果会对序列节点不正确。出于同样的原因,绝不要使用 "zkcopy" 工具:https://github.com/ksprojects/zkcopy/issues/15 +您绝不应使用手动编写的脚本在不同的 ZooKeeper 集群之间传输数据,因为对于顺序节点,结果将不正确。 +出于同样的原因,绝不要使用 "zkcopy" 实用程序:https://github.com/ksprojects/zkcopy/issues/15 -如果您想将现有的 ZooKeeper 集群拆分为两个,正确的方法是增加其副本数量,然后将其重新配置为两个独立的集群。 +如果您想将现有的 ZooKeeper 集群分成两个,正确的方法是增加其副本数量,然后将其重新配置为两个独立的集群。 -您可以在测试环境中或在数据接收率较低的环境中将 ClickHouse Keeper 与 ClickHouse 运行在同一服务器上。 -对于生产环境,我们建议为 ClickHouse 和 ZooKeeper/Keeper 使用单独的服务器,或将 ClickHouse 文件和 Keeper 文件放在不同的磁盘上。因为 ZooKeeper/Keeper 对磁盘延迟非常敏感,而 ClickHouse 可能会利用所有可用的系统资源。 +您可以在测试环境中将 ClickHouse Keeper 与 ClickHouse 运行在同一服务器上,或在摄取速率较低的环境中运行。 +对于生产环境,我们建议为 ClickHouse 和 ZooKeeper/Keeper 使用单独的服务器,或将 ClickHouse 文件和 Keeper 文件放置在单独的磁盘上。因为 ZooKeeper/Keeper 对磁盘延迟非常敏感,而 ClickHouse 可能会利用所有可用的系统资源。 -您可以在集群中拥有 ZooKeeper 观察者,但 ClickHouse 服务器不应与观察者交互。 +您可以在合奏中拥有 ZooKeeper 观察者,但 ClickHouse 服务器不应与观察者交互。 -请勿更改 `minSessionTimeout` 设置,大值可能会影响 ClickHouse 的重启稳定性。 +不要更改 `minSessionTimeout` 设置,较大的值可能会影响 ClickHouse 重启的稳定性。 -在默认设置下,ZooKeeper 就像一颗定时炸弹: +使用默认设置时,ZooKeeper 是一颗定时炸弹: -> 当使用默认配置时,ZooKeeper 服务器不会删除旧快照和日志中的文件(见 `autopurge`),这需要操作员的责任。 +> ZooKeeper 服务器不会在使用默认配置时删除旧快照和日志中的文件(见 `autopurge`),这由操作员负责。 -这个炸弹必须被拆除。 +这颗炸弹必须被引爆。 -以下 ZooKeeper (3.5.1) 配置用于大型生产环境: +以下是一个大型生产环境中使用的 ZooKeeper(3.5.1)配置: zoo.cfg: @@ -309,7 +312,7 @@ JAVA_OPTS="-Xms{{ '{{' }} cluster.get('xms','128M') {{ '}}' }} \ -XX:MaxGCPauseMillis=50" ``` -Salt 初始化: +盐初始化: ```text description "zookeeper-{{ '{{' }} cluster['name'] {{ '}}' }} centralized coordination service" @@ -342,8 +345,8 @@ end script ## Antivirus software {#antivirus-software} -如果您使用防病毒软件,请将其配置为跳过包含 ClickHouse 数据文件的文件夹(`/var/lib/clickhouse`),否则可能会降低性能,并可能在数据接收和后台合并期间出现意外错误。 +如果您使用抗病毒软件,请将其配置为跳过包含 ClickHouse 数据文件的文件夹(`/var/lib/clickhouse`),否则性能可能会下降,并且在数据摄取和后台合并期间可能会出现意外错误。 ## Related Content {#related-content} -- [刚开始使用 ClickHouse?这里有 13 条“致命错误”及其避免方法](https://clickhouse.com/blog/common-getting-started-issues-with-clickhouse) +- [开始使用 ClickHouse?以下是 13 个“致命罪”和避免它们的方法](https://clickhouse.com/blog/common-getting-started-issues-with-clickhouse) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/tips.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/tips.md.hash index 8b2770e4552..4655a31d08f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/tips.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/tips.md.hash @@ -1 +1 @@ -9e8d728d7e351119 +66522caa4205d0b5 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/update.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/update.md index aa6c6dccfde..9c3c9683a22 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/update.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/update.md @@ -1,71 +1,72 @@ --- -'description': 'Update 相关的 文档' +'description': 'Update 的文档' 'sidebar_title': 'Self-managed Upgrade' 'slug': '/operations/update' 'title': '自管理 升级' +'doc_type': 'guide' --- ## ClickHouse 升级概述 {#clickhouse-upgrade-overview} -本文件包含: +本文档包含: - 一般指南 - 推荐计划 -- 关于在您的系统上升级二进制文件的具体细节 +- 在您的系统上升级二进制文件的具体细节 ## 一般指南 {#general-guidelines} -这些说明应该能帮助您规划,并理解我们在文件后面所做建议的原因。 +以下说明应帮助您进行规划,并了解我们稍后在文档中所做推荐的原因。 -### 单独升级 ClickHouse 服务器与 ClickHouse Keeper 或 ZooKeeper {#upgrade-clickhouse-server-separately-from-clickhouse-keeper-or-zookeeper} -除非需要为 ClickHouse Keeper 或 Apache ZooKeeper 提供安全修复,否则在升级 ClickHouse 服务器时不必升级 Keeper。 升级过程中需要 Keeper 的稳定性,因此在考虑升级 Keeper 之前,请先完成 ClickHouse 服务器的升级。 +### 在升级 ClickHouse 服务器时,与 ClickHouse Keeper 或 ZooKeeper 分开进行 {#upgrade-clickhouse-server-separately-from-clickhouse-keeper-or-zookeeper} +除非需要对 ClickHouse Keeper 或 Apache ZooKeeper 进行安全修复,否则在升级 ClickHouse 服务器时,不必升级 Keeper。升级过程中需要保证 Keeper 的稳定性,因此在考虑升级 Keeper 之前,请完成 ClickHouse 服务器的升级。 -### 应尽快采用次要版本升级 {#minor-version-upgrades-should-be-adopted-often} -强烈建议始终在最新的次要版本发布后立即进行升级。 次要版本不会有破坏性更改,但会有重要的错误修复(并可能包含安全修复)。 +### 应频繁采用小版本升级 {#minor-version-upgrades-should-be-adopted-often} +强烈建议在发布新小版本后尽快升级到最新版。小版本发布没有破坏性更改,但包含重要的错误修复(可能还有安全修复)。 ### 在运行目标版本的单独 ClickHouse 服务器上测试实验性功能 {#test-experimental-features-on-a-separate-clickhouse-server-running-the-target-version} -实验性功能的兼容性随时可能以任何方式被破坏。 如果您正在使用实验性功能,请检查变更日志,并考虑在安装目标版本的单独 ClickHouse 服务器上设置并测试您对实验性功能的使用。 +实验性功能的兼容性可能随时以任何方式受到影响。如果您正在使用实验性功能,请检查变更日志,并考虑设置一个安装了目标版本的单独 ClickHouse 服务器,在那里测试您的实验性功能使用情况。 ### 降级 {#downgrades} -如果您升级后意识到新版本与您依赖的某些功能不兼容,并且如果您尚未开始使用任何新功能,您可以降级到一个近期(不到一年的)版本。 一旦使用了新功能,降级将无法生效。 +如果您升级后发现新版本与您依赖的某些功能不兼容,如果您没有开始使用任何新功能,您可能能够降级到最近的(不到一年的)版本。一旦使用了新功能,降级将不可行。 -### 集群中的多个 ClickHouse 服务器版本 {#multiple-clickhouse-server-versions-in-a-cluster} +### 集群中有多个 ClickHouse 服务器版本 {#multiple-clickhouse-server-versions-in-a-cluster} -我们努力保持一年的兼容性窗口(包括 2 个 LTS 版本)。 这意味着如果两个版本之间的差异不到一年(或之间有不到两个 LTS 版本),任何两个版本都应能在集群中协同工作。 然而,建议尽快将集群中的所有成员升级到相同的版本,因为可能会出现一些小问题(例如分布式查询的缓慢、在 ReplicatedMergeTree 中某些后台操作中的可重试错误等)。 +我们努力保持一年的兼容窗口(包括 2 个 LTS 版本)。这意味着如果两个版本之间的差异小于一年(或之间有不到两个 LTS 版本),则任何两个版本应该能够在集群中协同工作。然而,建议尽快将集群中所有成员升级到相同的版本,因为可能会出现一些小问题(例如,分布式查询的减速,ReplicatedMergeTree 中某些后台操作首次错误等)。 -我们从不建议在同一集群中运行发行日期相差超过一年的不同版本。 虽然我们不期望您会遭遇数据丢失,但集群可能会变得不可用。 如果您有超过一年版本差异,您应该预期的问题包括: +我们从不建议在同一集群中运行版本发布时间超过一年的不同版本。虽然我们不期望出现数据丢失,但集群可能会变得不可用。如果版本之间的差异超过一年,您应该预期会出现以下问题: - 集群可能无法正常工作 -- 某些(甚至所有)查询可能会因为任意错误而失败 +- 某些(甚至所有)查询可能会以任意错误失败 - 日志中可能会出现任意错误/警告 - 可能无法降级 ### 增量升级 {#incremental-upgrades} -如果当前版本和目标版本之间的差异超过一年,则建议: +如果当前版本与目标版本之间的差异超过一年,则建议: - 进行停机升级(停止所有服务器,升级所有服务器,启动所有服务器)。 -- 或者通过一个中间版本进行升级(该版本比当前版本新但少于一年)。 +- 或者通过一个中间版本进行升级(一个比当前版本新不到一年的版本)。 ## 推荐计划 {#recommended-plan} -以下是零停机 ClickHouse 升级的推荐步骤: - -1. 确保您的配置更改不在默认的 `/etc/clickhouse-server/config.xml` 文件中,而是放在 `/etc/clickhouse-server/config.d/` 中,因为 `/etc/clickhouse-server/config.xml` 在升级期间可能会被覆盖。 -2. 通读 [变更日志](/whats-new/changelog/index.md),查看破坏性更改(从目标版本回到您当前的版本)。 -3. 在升级前进行任何可以在破坏性更改中识别的更新,并列出在升级后需要进行的更改。 -4. 确定一个或多个副本,用于在每个分片的其余副本升级期间保持同步。 -5. 在要升级的副本上,逐个进行操作: - - 关闭 ClickHouse 服务器 - - 将服务器升级到目标版本 - - 启动 ClickHouse 服务器 - - 等待 Keeper 消息指示系统稳定 - - 继续下一个副本 +以下是进行零停机 ClickHouse 升级的推荐步骤: + +1. 确保您的配置更改不在默认的 `/etc/clickhouse-server/config.xml` 文件中,而是在 `/etc/clickhouse-server/config.d/` 中,因为 `/etc/clickhouse-server/config.xml` 在升级过程中可能会被覆盖。 +2. 阅读 [变更日志](/whats-new/changelog/index.md),以确认破坏性更改(从目标版本到您当前版本)。 +3. 在升级之前进行任何可以在破坏性更改中识别的更新,以及需要在升级后进行的更改列表。 +4. 确定每个分片中一个或多个副本在其余副本升级期间保持同步。 +5. 在即将升级的副本上,逐个进行: +- 关闭 ClickHouse 服务器 +- 将服务器升级到目标版本 +- 启动 ClickHouse 服务器 +- 等待 Keeper 消息以表明系统稳定 +- 继续下一个副本 6. 检查 Keeper 日志和 ClickHouse 日志中的错误 7. 将步骤 4 中识别的副本升级到新版本 -8. 参考步骤 1 到 3 中所做的更改列表,并进行升级后需要进行的更改。 +8. 查阅步骤 1 到 3 中所做的更改列表,并进行升级后需要的更改。 :::note -在运行在复制环境中的多个版本的 ClickHouse 时,会预期出现此错误消息。 当所有副本升级到相同版本时,您将停止看到这些消息。 +在复制环境中运行多个版本的 ClickHouse 时预期会出现此错误消息。当所有副本升级到相同版本后,您将不再看到这些消息。 ```text MergeFromLogEntryTask: Code: 40. DB::Exception: Checksums of parts don't match: hash of uncompressed files doesn't match. (CHECKSUM_DOESNT_MATCH) Data after merge is not @@ -73,8 +74,7 @@ byte-identical to data on another replicas. ``` ::: - -## ClickHouse 服务器二进制文件升级过程 {#clickhouse-server-binary-upgrade-process} +## ClickHouse 服务器二进制升级过程 {#clickhouse-server-binary-upgrade-process} 如果 ClickHouse 是通过 `deb` 包安装的,请在服务器上执行以下命令: @@ -84,17 +84,17 @@ $ sudo apt-get install clickhouse-client clickhouse-server $ sudo service clickhouse-server restart ``` -如果您使用其他方式安装 ClickHouse,请使用适当的更新方法。 +如果您使用其他方法安装 ClickHouse,请使用相应的更新方法。 :::note -只要没有任何时刻所有一个分片的副本都离线,您可以同时更新多个服务器。 +您可以在没有任何一个分片的所有副本都离线的瞬间同时更新多个服务器。 ::: -将旧版本的 ClickHouse 升级到特定版本: +将较旧版本的 ClickHouse 升级到特定版本: 例如: -`xx.yy.a.b` 是当前的稳定版本。 最新的稳定版本可以在 [这里](https://github.com/ClickHouse/ClickHouse/releases) 找到。 +`xx.yy.a.b` 是当前稳定版本。最新的稳定版本可在 [这里](https://github.com/ClickHouse/ClickHouse/releases) 找到。 ```bash $ sudo apt-get update diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/update.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/update.md.hash index 438e6b84513..57d87797794 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/update.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/update.md.hash @@ -1 +1 @@ -21b6a91d6676ddf7 +08b18de0947c07cd diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/userspace-page-cache.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/userspace-page-cache.md index 74004665d6e..c0d4d041207 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/userspace-page-cache.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/userspace-page-cache.md @@ -1,35 +1,36 @@ --- -'description': '缓存机制,允许在进程内存中缓存数据,而不依赖于操作系统页面缓存。' +'description': '缓存机制,允许在进程内存中缓存数据,而不是依赖于操作系统页面缓存。' 'sidebar_label': '用户空间页面缓存' 'sidebar_position': 65 'slug': '/operations/userspace-page-cache' 'title': '用户空间页面缓存' +'doc_type': 'reference' --- -# 用户空间页缓存 +# 用户空间页面缓存 ## 概述 {#overview} -> 用户空间页缓存是一种新的缓存机制,允许在进程内存中缓存数据,而不是依赖操作系统的页缓存。 +> 用户空间页面缓存是一种新的缓存机制,允许在进程内存中缓存数据,而不是依赖操作系统页面缓存。 -ClickHouse 已经提供了 [文件系统缓存](/docs/operations/storing-data) 作为在 Amazon S3、Google Cloud Storage (GCS) 或 Azure Blob Storage 等远程对象存储之上的缓存方式。用户空间页缓存的设计旨在加速远程数据的访问,当正常的操作系统缓存无法满足需求时使用。 +ClickHouse已经提供了[文件系统缓存](/docs/operations/storing-data),作为在远程对象存储(例如Amazon S3、Google Cloud Storage (GCS)或Azure Blob Storage)上进行缓存的方式。用户空间页面缓存旨在加快对远程数据的访问,当正常的操作系统缓存没有提供足够的性能时。 -它与文件系统缓存有以下不同之处: +它与文件系统缓存的不同之处在于: -| 文件系统缓存 | 用户空间页缓存 | -|-----------------------------------------------------|------------------------------------------| -| 将数据写入本地文件系统 | 仅存在于内存中 | -| 占用磁盘空间(也可以在 tmpfs 上配置) | 不依赖于文件系统 | -| 能够在服务器重启后存活 | 在服务器重启后无法存活 | -| 不会显示在服务器的内存使用中 | 会显示在服务器的内存使用中 | -| 适合本地磁盘和内存(操作系统页缓存) | **适合无磁盘服务器** | +| 文件系统缓存 | 用户空间页面缓存 | +|---------------------------------------------------------|---------------------------------------| +| 将数据写入本地文件系统 | 仅存在于内存中 | +| 占用磁盘空间(在tmpfs上也可以配置) | 独立于文件系统 | +| 在服务器重启后仍然有效 | 在服务器重启后不会保留 | +| 不会在服务器的内存使用中显示 | 在服务器的内存使用中显示 | +| 适用于磁盘和内存(操作系统页面缓存) | **适用于无磁盘服务器** | ## 配置设置和使用 {#configuration-settings-and-usage} ### 使用 {#usage} -要启用用户空间页缓存,首先需要在服务器上进行配置: +要启用用户空间页面缓存,首先在服务器上进行配置: ```bash cat config.d/page_cache.yaml @@ -37,10 +38,10 @@ page_cache_max_size: 100G ``` :::note -用户空间页缓存将使用指定量的内存,但这部分内存并不是保留的。当服务器需要其他内存时,这部分内存会被逐出。 +用户空间页面缓存将使用最多指定的内存量,但该内存量并不是保留的。当需要用于其他服务器需求时,这部分内存会被驱逐。 ::: -接下来,启用查询级别的使用: +接下来,在查询级别启用其使用: ```sql SET use_page_cache_for_disks_without_file_cache=1; @@ -48,21 +49,21 @@ SET use_page_cache_for_disks_without_file_cache=1; ### 设置 {#settings} -| 设置 | 描述 | 默认值 | -|-----------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------| -| `use_page_cache_for_disks_without_file_cache` | 对于未启用文件系统缓存的远程磁盘使用用户空间页缓存。 | `0` | -| `use_page_cache_with_distributed_cache` | 当使用分布式缓存时使用用户空间页缓存。 | `0` | -| `read_from_page_cache_if_exists_otherwise_bypass_cache` | 在被动模式下使用用户空间页缓存,类似于 [`read_from_filesystem_cache_if_exists_otherwise_bypass_cache`](/docs/operations/settings/settings#read_from_filesystem_cache_if_exists_otherwise_bypass_cache)。 | `0` | -| `page_cache_inject_eviction` | 用户空间页缓存将随机无效化一些页面。用于测试。 | `0` | -| `page_cache_block_size` | 存储在用户空间页缓存中的文件块大小,以字节为单位。所有通过缓存的读取将四舍五入到此大小的倍数。 | `1048576` | -| `page_cache_history_window_ms` | 释放的内存在被用户空间页缓存使用前的延迟时间。 | `1000` | -| `page_cache_policy` | 用户空间页缓存策略名称。 | `SLRU` | -| `page_cache_size_ratio` | 用户空间页缓存中受保护队列的大小相对于缓存总大小的比例。 | `0.5` | -| `page_cache_min_size` | 用户空间页缓存的最小大小。 | `104857600` | -| `page_cache_max_size` | 用户空间页缓存的最大大小。设置为0以禁用缓存。如果大于 page_cache_min_size,该缓存大小将持续在此范围内调整,以使用大多数可用内存,同时保持总内存使用低于限制(`max_server_memory_usage`\[`_to_ram_ratio`\])。 | `0` | -| `page_cache_free_memory_ratio` | 从用户空间页缓存中保持空闲的内存限制的比例。类似于 Linux min_free_kbytes 设置。 | `0.15` | -| `page_cache_lookahead_blocks` | 在用户空间页缓存未命中时,从底层存储中一次读取多达这一数量的连续块,如果这些块也不在缓存中。每个块大小为 page_cache_block_size 字节。 | `16` | -| `page_cache_shards` | 在这一数量的分片上划分用户空间页缓存,以减少互斥锁争用。实验性,可能不会提高性能。 | `4` | +| 设置 | 描述 | 默认值 | +|----------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------| +| `use_page_cache_for_disks_without_file_cache` | 为未启用文件系统缓存的远程磁盘使用用户空间页面缓存。 | `0` | +| `use_page_cache_with_distributed_cache` | 当使用分布式缓存时使用用户空间页面缓存。 | `0` | +| `read_from_page_cache_if_exists_otherwise_bypass_cache` | 以被动模式使用用户空间页面缓存,类似于[`read_from_filesystem_cache_if_exists_otherwise_bypass_cache`](/docs/operations/settings/settings#read_from_filesystem_cache_if_exists_otherwise_bypass_cache)。 | `0` | +| `page_cache_inject_eviction` | 用户空间页面缓存有时会随机使某些页面失效。用于测试。 | `0` | +| `page_cache_block_size` | 存储在用户空间页面缓存中的文件块大小,以字节为单位。所有通过缓存的读取将四舍五入到这个大小的倍数。 | `1048576` | +| `page_cache_history_window_ms` | 释放的内存可以被用户空间页面缓存使用的延迟时间。 | `1000` | +| `page_cache_policy` | 用户空间页面缓存策略名称。 | `SLRU` | +| `page_cache_size_ratio` | 用户空间页面缓存中受保护队列的大小相对于缓存的总大小。 | `0.5` | +| `page_cache_min_size` | 用户空间页面缓存的最小大小。 | `104857600` | +| `page_cache_max_size` | 用户空间页面缓存的最大大小。设置为0以禁用缓存。如果大于page_cache_min_size,缓存大小将在此范围内持续调整,以使用大部分可用内存,同时保持总内存使用低于限制(`max_server_memory_usage`\[`_to_ram_ratio`\])。 | `0` | +| `page_cache_free_memory_ratio` | 从用户空间页面缓存中保持空闲内存的比例。类似于Linux的min_free_kbytes设置。 | `0.15` | +| `page_cache_lookahead_blocks` | 在用户空间页面缓存未命中时,从底层存储中一次读取最多这一数量的连续块,如果它们也不在缓存中。每个块大小为page_cache_block_size字节。 | `16` | +| `page_cache_shards` | 在此数量的分片上划分用户空间页面缓存,以减少互斥量争用。实验性,可能不会提高性能。 | `4` | ## 相关内容 {#related-content} - [文件系统缓存](/docs/operations/storing-data) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/userspace-page-cache.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/userspace-page-cache.md.hash index 0cc2770f6ae..5c1f0ae97a6 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/userspace-page-cache.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/userspace-page-cache.md.hash @@ -1 +1 @@ -4261ab72aa0eefdc +7f27caef6eb51681 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/backupview.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/backupview.md index 443e017f604..398d7bde533 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/backupview.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/backupview.md @@ -2,21 +2,21 @@ 'description': 'clickhouse_backupview 的文档 {#clickhouse_backupview}' 'slug': '/operations/utilities/backupview' 'title': 'clickhouse_backupview' +'doc_type': 'reference' --- # clickhouse_backupview {#clickhouse_backupview} -Python模块,用于帮助分析通过[BACKUP](/operations/backup)命令创建的备份。 -主要目的是在不实际恢复备份的情况下获取备份中的一些信息。 +用于分析通过 [BACKUP](/operations/backup) 命令创建的备份的 Python 模块。其主要目的是允许在不实际还原备份的情况下获取一些备份信息。 -该模块提供以下功能: +该模块提供以下功能 - 枚举备份中包含的文件 -- 读取备份中的文件 -- 以可读形式获取有关数据库、表、包含在备份中的分区片段的有用信息 +- 从备份中读取文件 +- 以可读形式获取有关数据库、表、备份中包含的分区片段的有用信息 - 检查备份的完整性 -## 示例: {#example} +## 示例: {#example} ```python from clickhouse_backupview import open_backup, S3, FileInfo @@ -58,4 +58,4 @@ backup.extract_table_data(table="mydb.mytable", partition="202201", out='/tmp/my backup.extract_table_data(table="mydb.mytable", part="202201_100_200_3", out='/tmp/my_backup_1/202201_100_200_3/') ``` -有关更多示例,请参见[test](https://github.com/ClickHouse/ClickHouse/blob/master/utils/backupview/test/test.py)。 +有关更多示例,请参见 [test](https://github.com/ClickHouse/ClickHouse/blob/master/utils/backupview/test/test.py)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/backupview.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/backupview.md.hash index 1c8b241fcf0..87f8445094a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/backupview.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/backupview.md.hash @@ -1 +1 @@ -f3a92d0d330c0e11 +6b251e8bf39695ab diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/clickhouse-benchmark.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/clickhouse-benchmark.md index e541ae83219..4ea474911a0 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/clickhouse-benchmark.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/clickhouse-benchmark.md @@ -1,15 +1,16 @@ --- -'description': 'clickhouse-benchmark的文档' +'description': 'clickhouse-benchmark 的文档' 'sidebar_label': 'clickhouse-benchmark' 'sidebar_position': 61 'slug': '/operations/utilities/clickhouse-benchmark' 'title': 'clickhouse-benchmark' +'doc_type': 'reference' --- # clickhouse-benchmark -连接到 ClickHouse 服务器并重复发送指定的查询。 +连接到一个 ClickHouse 服务器并重复发送指定的查询。 **语法** @@ -29,7 +30,7 @@ $ echo "single query" | clickhouse-benchmark [keys] $ clickhouse-benchmark [keys] <<< "single query" ``` -如果要发送一组查询,请创建一个文本文件,并将每个查询放在此文件中的单独字符串上。例如: +如果您想发送一组查询,请创建一个文本文件,并将每个查询放在此文件的单独字符串中。例如: ```sql SELECT * FROM system.numbers LIMIT 10000000; @@ -42,32 +43,46 @@ SELECT 1; clickhouse-benchmark [keys] < queries_file; ``` -## 选项 {#clickhouse-benchmark-keys} +## 命令行选项 {#clickhouse-benchmark-command-line-options} -- `--query=QUERY` — 要执行的查询。如果没有传递此参数,`clickhouse-benchmark` 将从标准输入读取查询。 +- `--query=QUERY` — 要执行的查询。如果未传递此参数,`clickhouse-benchmark` 将从标准输入读取查询。 +- `--query_id=ID` — 查询 ID。 +- `--query_id_prefix=ID_PREFIX` — 查询 ID 前缀。 - `-c N`, `--concurrency=N` — `clickhouse-benchmark` 同时发送的查询数量。默认值:1。 -- `-d N`, `--delay=N` — 中间报告之间的间隔(要禁用报告,请设置为 0)。默认值:1。 -- `-h HOST`, `--host=HOST` — 服务器主机。默认值:`localhost`。对于 [比较模式](#clickhouse-benchmark-comparison-mode),可以使用多个 `-h` 选项。 +- `-C N`, `--max_concurrency=N` — 逐渐增加并发查询的数量直到指定值,为每个并发级别生成一个报告。 +- `--precise` — 启用具有加权指标的精确每隔报告。 +- `-d N`, `--delay=N` — 中间报告之间的间隔(以秒为单位)(要禁用报告请设置为 0)。默认值:1。 +- `-h HOST`, `--host=HOST` — 服务器主机。默认值:`localhost`。对于 [比较模式](#clickhouse-benchmark-comparison-mode),您可以使用多个 `-h` 键。 - `-i N`, `--iterations=N` — 查询的总数。默认值:0(无限重复)。 -- `-r`, `--randomize` — 如果有多个输入查询,则按随机顺序执行查询。 +- `-r`, `--randomize` — 如果有多个输入查询,则随机顺序执行查询。 - `-s`, `--secure` — 使用 `TLS` 连接。 -- `-t N`, `--timelimit=N` — 限制时间(秒)。当达到指定的时间限制时,`clickhouse-benchmark` 停止发送查询。默认值:0(禁用时间限制)。 -- `--port=N` — 服务器端口。默认值:9000。对于 [比较模式](#clickhouse-benchmark-comparison-mode),可以使用多个 `--port` 选项。 -- `--confidence=N` — T 检验的置信水平。可能的值:0(80%),1(90%),2(95%),3(98%),4(99%),5(99.5%)。默认值:5。在 [比较模式](#clickhouse-benchmark-comparison-mode) 中,`clickhouse-benchmark` 执行 [独立两样本 Student's t-test](https://en.wikipedia.org/wiki/Student%27s_t-test#Independent_two-sample_t-test) 来确定在选定的置信水平下,两者分布是否不同。 -- `--cumulative` — 打印累积数据而非每个间隔的数据。 +- `-t N`, `--timelimit=N` — 时间限制(以秒为单位)。当达到指定的时间限制时,`clickhouse-benchmark` 停止发送查询。默认值:0(禁用时间限制)。 +- `--port=N` — 服务器端口。默认值:9000。对于 [比较模式](#clickhouse-benchmark-comparison-mode),您可以使用多个 `--port` 键。 +- `--confidence=N` — T 检验的置信水平。可能的值:0(80%),1(90%),2(95%),3(98%),4(99%),5(99.5%)。默认值:5。在 [比较模式](#clickhouse-benchmark-comparison-mode) 中,`clickhouse-benchmark` 执行 [独立双样本 Student t 检验](https://en.wikipedia.org/wiki/Student%27s_t-test#Independent_two-sample_t-test) 以确定在所选置信水平下两个分布是否不同。 +- `--cumulative` — 打印累计数据而不是每个间隔的数据。 - `--database=DATABASE_NAME` — ClickHouse 数据库名称。默认值:`default`。 - `--user=USERNAME` — ClickHouse 用户名。默认值:`default`。 - `--password=PSWD` — ClickHouse 用户密码。默认值:空字符串。 -- `--stacktrace` — 输出堆栈跟踪。当设置此选项时,`clickhouse-benchmark` 输出异常的堆栈跟踪。 -- `--stage=WORD` — 服务器上的查询处理阶段。ClickHouse 在指定阶段停止查询处理并将答案返回给 `clickhouse-benchmark`。可能的值:`complete`,`fetch_columns`,`with_mergeable_state`。默认值:`complete`。 -- `--reconnect=N` - 控制重连行为。可能的值0(从不重连),1(每个查询重连),或 N(每 N 个查询后重连)。默认值:1。 -- `--help` — 显示帮助信息。 +- `--stacktrace` — 堆栈跟踪输出。当设置此键时,`clickhouse-benchamrk` 输出异常的堆栈跟踪。 +- `--stage=WORD` — 服务器上的查询处理阶段。ClickHouse 停止查询处理并在指定阶段返回答案给 `clickhouse-benchmark`。可能的值:`complete`,`fetch_columns`,`with_mergeable_state`。默认值:`complete`。 +- `--roundrobin` — 而不是比较不同的 `--host`/`--port` 的查询,只为每个查询随机选择一个 `--host`/`--port` 并将查询发送到它。 +- `--reconnect=N` - 控制重连行为。可能的值 0(从不重连),1(每个查询重连),或 N(每 N 次查询后重连)。默认值:0。 +- `--max-consecutive-errors=N` — 允许的连续错误数量。默认值:0。 +- `--ignore-error`,`--continue_on_errors` — 即使查询失败也继续测试。 +- `--client-side-time` — 显示包括网络通信的时间,而不是服务器端时间;请注意,对于 22.8 之前的服务器版本,我们始终显示客户端时间。 +- `--help` — 显示帮助消息。 +- `--verbose` — 增加帮助消息的详细程度。 -如果要为查询应用一些 [设置](/operations/settings/overview),将其作为键 `--= SETTING_VALUE` 传递。例如,`--max_memory_usage=1048576`。 +如果您想要为查询应用一些 [设置](/operations/settings/overview),请将其作为键 `--= SETTING_VALUE` 传递。例如,`--max_memory_usage=1048576`。 + +## 环境变量选项 {#clickhouse-benchmark-environment-variable-options} + +用户名、密码和主机可以通过环境变量 `CLICKHOUSE_USER`、`CLICKHOUSE_PASSWORD` 和 `CLICKHOUSE_HOST` 设置。 +命令行参数 `--user`、`--password` 或 `--host` 优先于环境变量。 ## 输出 {#clickhouse-benchmark-output} -默认情况下,`clickhouse-benchmark` 在每个 `--delay` 间隔报告。 +默认情况下,`clickhouse-benchmark` 会在每个 `--delay` 间隔报告。 报告示例: @@ -94,25 +109,25 @@ localhost:9000, queries 10, QPS: 6.772, RPS: 67904487.440, MiB/s: 518.070, resul 在报告中,您可以找到: -- `Queries executed:` 字段中的查询数量。 +- `查询执行数量:` 字段中的查询数量。 - 状态字符串包含(按顺序): - - ClickHouse 服务器的端点。 - - 已处理的查询数量。 - - QPS:在 `--delay` 参数指定的期间内,服务器每秒执行多少查询。 - - RPS:在 `--delay` 参数指定的期间内,服务器每秒读取多少行。 - - MiB/s:在 `--delay` 参数指定的期间内,服务器每秒读取多少迈比字节。 - - result RPS:在 `--delay` 参数指定的期间内,服务器每秒向查询结果放置多少行。 - - result MiB/s:在 `--delay` 参数指定的期间内,服务器每秒向查询结果放置多少迈比字节。 + - ClickHouse 服务器的端点。 + - 处理的查询数量。 + - QPS: 在 `--delay` 参数指定的期间内,服务器每秒执行多少查询。 + - RPS: 在 `--delay` 参数指定的期间内,服务器每秒读取多少行。 + - MiB/s: 在 `--delay` 参数指定的期间内,服务器每秒读取多少 MiB。 + - 结果 RPS: 在 `--delay` 参数指定的期间内,服务器每秒放置到查询结果中的行数。 + - 结果 MiB/s. 在 `--delay` 参数指定的期间内,服务器每秒放置到查询结果中的 MiB 数量。 - 查询执行时间的百分位数。 ## 比较模式 {#clickhouse-benchmark-comparison-mode} -`clickhouse-benchmark` 可以比较两个运行中 ClickHouse 服务器的性能。 +`clickhouse-benchmark` 可以比较两个运行中的 ClickHouse 服务器的性能。 -要使用比较模式,通过两个对的 `--host`,`--port` 选项指定两个服务器的端点。选项在参数列表中按位置匹配,第一个 `--host` 与第一个 `--port` 匹配,依此类推。`clickhouse-benchmark` 建立连接到两个服务器,然后发送查询。每个查询发送到随机选择的服务器。结果以表格形式显示。 +要使用比较模式,通过两个 `--host`、`--port` 键指定两个服务器的端点。键在参数列表中的位置对应,第一个 `--host` 与第一个 `--port` 匹配,依此类推。 `clickhouse-benchmark` 建立到两个服务器的连接,然后发送查询。每个查询均指向一个随机选择的服务器。结果以表格形式显示。 ## 示例 {#clickhouse-benchmark-example} diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/clickhouse-benchmark.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/clickhouse-benchmark.md.hash index f613cfa7b7b..8afc3358d06 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/clickhouse-benchmark.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/clickhouse-benchmark.md.hash @@ -1 +1 @@ -993a8d5951664036 +33715ccefae6a771 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/clickhouse-compressor.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/clickhouse-compressor.md index a5fefe28921..8319c695408 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/clickhouse-compressor.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/clickhouse-compressor.md @@ -2,6 +2,7 @@ 'description': 'Clickhouse Compressor 的文档' 'slug': '/operations/utilities/clickhouse-compressor' 'title': 'clickhouse-compressor' +'doc_type': 'reference' --- 简单的数据压缩和解压缩程序。 @@ -13,12 +14,12 @@ $ ./clickhouse-compressor < input_file > output_file ``` -从 LZ4 格式解压数据: +从 LZ4 格式解压缩数据: ```bash $ ./clickhouse-compressor --decompress < input_file > output_file ``` -使用 ZSTD 级别 5 压缩数据: +在级别 5 使用 ZSTD 压缩数据: ```bash $ ./clickhouse-compressor --codec 'ZSTD(5)' < input_file > output_file diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/clickhouse-compressor.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/clickhouse-compressor.md.hash index cc2193f0bf3..ec7f2c3d641 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/clickhouse-compressor.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/clickhouse-compressor.md.hash @@ -1 +1 @@ -7a5aca1d5ad5b465 +e1b0a83ae4e85f86 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/clickhouse-disks.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/clickhouse-disks.md index c7285abc13d..a09116ec7ce 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/clickhouse-disks.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/clickhouse-disks.md @@ -4,65 +4,66 @@ 'sidebar_position': 59 'slug': '/operations/utilities/clickhouse-disks' 'title': 'Clickhouse-disks' +'doc_type': 'reference' --- # Clickhouse-disks -一个为ClickHouse磁盘提供类似于文件系统操作的实用工具。它可以在交互模式和非交互模式下工作。 +一个为ClickHouse磁盘提供文件系统类操作的工具。它可以在交互模式和非交互模式下运行。 ## Program-wide options {#program-wide-options} -* `--config-file, -C` -- ClickHouse配置的路径,默认值为`/etc/clickhouse-server/config.xml`。 +* `--config-file, -C` -- ClickHouse配置文件的路径,默认为`/etc/clickhouse-server/config.xml`。 * `--save-logs` -- 将调用命令的进度记录到`/var/log/clickhouse-server/clickhouse-disks.log`。 -* `--log-level` -- 日志记录的事件类型,默认值为`none`,详细内容参见 [type](../server-configuration-parameters/settings#logger)。 -* `--disk` -- 用于`mkdir, move, read, write, remove`命令的磁盘。默认值为`default`。 -* `--query, -q` -- 可以在不启动交互模式的情况下执行的单个查询。 -* `--help, -h` -- 打印所有选项和命令及其描述。 +* `--log-level` -- 记录何种[类型](../server-configuration-parameters/settings#logger)的事件,默认为`none`。 +* `--disk` -- 用于`mkdir, move, read, write, remove`命令的磁盘。默认为`default`。 +* `--query, -q` -- 可以在不启动交互模式的情况下执行的单个查询 +* `--help, -h` -- 打印所有选项和命令及其说明 ## Lazy initialization {#lazy-initialization} -在配置中可用的所有磁盘都是懒初始化的。这意味着只有在某个命令中使用对应磁盘时,才会初始化该磁盘的对应对象。这是为了增强工具的健壮性,避免对配置中描述但未被用户使用的磁盘进行操作,这些磁盘可能在初始化时会失败。然而,启动clickhouse-disks时必须有一个磁盘被初始化。该磁盘通过命令行参数`--disk`指定(默认值为`default`)。 +所有在配置中可用的磁盘都是延迟初始化的。这意味着只有在某个命令中使用时,才会初始化相应磁盘的对象。这是为了使工具更加健壮,避免处理在配置中描述但未被用户使用的磁盘,因其在初始化时可能会失败。然而,在clickhouse-disks启动时应有一个被初始化的磁盘。这个磁盘通过命令行的参数`--disk`指定(默认值为`default`)。 ## Default Disks {#default-disks} -启动后,有两个未在配置中指定但可供初始化的磁盘。 +启动后,有两个未在配置中指定但可用于初始化的磁盘。 -1. **`local` 磁盘**:该磁盘旨在模拟启动`clickhouse-disks`实用工具的本地文件系统。其初始路径是从`clickhouse-disks`启动的目录,并且在文件系统的根目录下挂载。 +1. **`local` Disk**: 该磁盘旨在模仿启动`clickhouse-disks`工具的本地文件系统。其初始路径为启动`clickhouse-disks`的目录,并挂载在文件系统的根目录上。 -2. **`default` 磁盘**:该磁盘挂载到配置中`clickhouse/path`参数指定的本地文件系统目录(默认值为`/var/lib/clickhouse`)。其初始路径设置为`/`。 +2. **`default` Disk**: 该磁盘挂载到本地文件系统中,由配置中的`clickhouse/path`参数指定的目录(默认值为`/var/lib/clickhouse`)。其初始路径设置为`/`。 ## Clickhouse-disks state {#clickhouse-disks-state} -对于每个添加的磁盘,实用工具存储当前目录(与常规文件系统一样)。用户可以更改当前目录并在磁盘之间切换。 +对于每一个添加的磁盘,工具会存储当前目录(如同一个普通文件系统)。用户可以更改当前目录并在磁盘之间切换。 -状态反映在提示中 "`disk_name`:`path_name`" +状态通过提示符"`disk_name`:`path_name`"反映。 ## Commands {#commands} -在本文件中,所有必需的位置参数称为 ``,命名参数称为 `[--parameter value]`。所有位置参数都可以作为具有相应名称的命名参数提及。 +在这份文档中,所有必需的位置参数称为``,命名参数称为`[--parameter value]`。所有位置参数也可以以相应名称作为命名参数提及。 * `cd (change-dir, change_dir) [--disk disk] ` - 更改当前磁盘上`disk`的目录为`path`(默认值为当前磁盘)。不进行磁盘切换。 + 切换到磁盘`disk`上的路径`path`(默认值为当前磁盘)。不会发生磁盘切换。 * `copy (cp) [--disk-from disk_1] [--disk-to disk_2] `. - 递归复制数据,从磁盘`disk_1`上的`path-from`(默认值为当前磁盘(非交互模式下的`disk`参数))到磁盘`disk_2`上的`path-to`(默认值为当前磁盘(非交互模式下的`disk`参数))。 + 递归地从磁盘`disk_1`上的`path-from`(默认值为当前磁盘(在非交互模式下参数`disk`))复制数据到磁盘`disk_2`上的`path-to`(默认值为当前磁盘(在非交互模式下参数`disk`))。 * `current_disk_with_path (current, current_disk, current_path)` 打印当前状态,格式为: `Disk: "current_disk" Path: "current path on current disk"` * `help []` - 打印有关命令`command`的帮助信息。如果未指定`command`,则打印有关所有命令的信息。 + 打印关于命令`command`的帮助信息。如果未指定`command`,则打印所有命令的信息。 * `move (mv) `. - 在当前磁盘中将文件或目录从`path-from`移动到`path-to`。 + 在当前磁盘上将文件或目录从`path-from`移动到`path-to`。 * `remove (rm, delete) `. - 在当前磁盘上递归删除`path`。 + 在当前磁盘上递归移除`path`。 * `link (ln) `. 在当前磁盘上从`path-from`创建到`path-to`的硬链接。 * `list (ls) [--recursive] ` - 列出当前磁盘上`path`的文件。默认情况下为非递归。 + 列出当前磁盘上`path`的文件。默认不递归。 * `list-disks (list_disks, ls-disks, ls_disks)`. 列出磁盘名称。 * `mkdir [--recursive] ` 在当前磁盘上。 - 创建一个目录。默认情况下为非递归。 + 创建一个目录。默认不递归。 * `read (r) [--path-to path]` - 从`path-from`读取文件到`path`(如果未提供,则为`stdout`)。 + 从`path-from`读取一个文件到`path`(如果未提供则为`stdout`)。 * `switch-disk [--path path] ` - 切换到磁盘`disk`,路径为`path`(如果未指定`path`,则默认值为磁盘`disk`上的上一个路径)。 + 切换到磁盘`disk`上的路径`path`(如果未指定`path`,默认值为磁盘`disk`上的前一个路径)。 * `write (w) [--path-from path] `. - 将文件从`path`(如果未提供则为`stdin`,输入必须以 Ctrl+D 结束)写入到 `path-to`。 + 从`path`(如果未提供则为`stdin`,输入必须以Ctrl+D结束)写入文件到`path-to`。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/clickhouse-disks.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/clickhouse-disks.md.hash index 343d0f278f3..6899114e25e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/clickhouse-disks.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/clickhouse-disks.md.hash @@ -1 +1 @@ -9c002a11f4e7b9b3 +3a5245229e3cdd8d diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/clickhouse-format.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/clickhouse-format.md index ba43a8864bb..527cfec1b3b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/clickhouse-format.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/clickhouse-format.md @@ -1,7 +1,8 @@ --- -'description': '使用格式化工具处理 ClickHouse 数据格式的指南' +'description': '使用格式工具处理 ClickHouse 数据格式的指南' 'slug': '/operations/utilities/clickhouse-format' 'title': 'clickhouse-format' +'doc_type': 'reference' --- @@ -9,19 +10,20 @@ 允许格式化输入查询。 -选项: +键: -- `--help` 或 `-h` — 显示帮助信息。 -- `--query` — 格式化任何长度和复杂性的查询。 -- `--hilite` — 添加 ANSI 终端转义序列的语法高亮。 -- `--oneline` — 以单行格式输出。 -- `--max_line_length` — 格式化单行查询,长度小于指定值。 -- `--comments` — 保留输出中的注释。 -- `--quiet` 或 `-q` — 仅检查语法,成功时不输出。 +- `--help` 或 `-h` — 输出帮助信息。 +- `--query` — 格式化任何长度和复杂度的查询。 +- `--hilite` 或 `--highlight` — 使用 ANSI 终端转义序列添加语法高亮。 +- `--oneline` — 格式化为单行。 +- `--max_line_length` — 格式化为单行查询,其长度小于指定值。 +- `--comments` — 在输出中保留注释。 +- `--quiet` 或 `-q` — 仅检查语法,成功时无输出。 - `--multiquery` 或 `-n` — 允许在同一文件中包含多个查询。 - `--obfuscate` — 混淆而不是格式化。 -- `--seed ` — 确定混淆结果的任意字符串种子。 -- `--backslash` — 在格式化查询的每行末尾添加反斜杠。当您从网页或其他地方复制多行查询并希望在命令行中执行时,这非常有用。 +- `--seed ` — 任意字符串种子,决定混淆的结果。 +- `--backslash` — 在格式化查询的每行末尾添加反斜杠。当您从网络或其他地方复制多行查询并希望在命令行中执行时,这非常有用。 +- `--semicolons_inline` — 在多查询模式下,将分号写在查询的最后一行,而不是换行。 ## 示例 {#examples} diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/clickhouse-format.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/clickhouse-format.md.hash index 569b6157cd2..6009478acf4 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/clickhouse-format.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/clickhouse-format.md.hash @@ -1 +1 @@ -b2debcd5bf6a97bb +bacd0c87d4e0a850 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/clickhouse-keeper-client.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/clickhouse-keeper-client.md index 9955fe30c1b..400f97497a8 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/clickhouse-keeper-client.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/clickhouse-keeper-client.md @@ -3,28 +3,29 @@ 'sidebar_label': 'clickhouse-keeper-client' 'slug': '/operations/utilities/clickhouse-keeper-client' 'title': 'clickhouse-keeper-client 工具' +'doc_type': 'reference' --- -# clickhouse-keeper-client 实用工具 +# clickhouse-keeper-client 工具 -一个与 clickhouse-keeper 通过其原生协议进行交互的客户端应用程序。 +一个与 clickhouse-keeper 通过其原生协议交互的客户端应用程序。 -## Keys {#clickhouse-keeper-client} +## 关键字 {#clickhouse-keeper-client} -- `-q QUERY`, `--query=QUERY` — 要执行的查询。如果未传递此参数,`clickhouse-keeper-client` 将以交互模式启动。 -- `-h HOST`, `--host=HOST` — 服务器主机。默认值:`localhost`。 -- `-p N`, `--port=N` — 服务器端口。默认值:9181。 -- `-c FILE_PATH`, `--config-file=FILE_PATH` — 设置配置文件的路径以获取连接字符串。默认值:`config.xml`。 -- `--connection-timeout=TIMEOUT` — 设置连接超时时间(秒)。默认值:10s。 -- `--session-timeout=TIMEOUT` — 设置会话超时时间(秒)。默认值:10s。 -- `--operation-timeout=TIMEOUT` — 设置操作超时时间(秒)。默认值:10s。 -- `--history-file=FILE_PATH` — 设置历史文件的路径。默认值:`~/.keeper-client-history`。 -- `--log-level=LEVEL` — 设置日志级别。默认值:`information`。 -- `--no-confirmation` — 如果设置,将不要求对多个命令进行确认。默认值:交互模式下为 `false`,查询模式下为 `true`。 +- `-q QUERY`, `--query=QUERY` — 要执行的查询。如果没有传递此参数,`clickhouse-keeper-client` 将以交互模式启动。 +- `-h HOST`, `--host=HOST` — 服务器主机。默认值: `localhost`。 +- `-p N`, `--port=N` — 服务器端口。默认值: 9181 +- `-c FILE_PATH`, `--config-file=FILE_PATH` — 设置配置文件的路径以获取连接字符串。默认值: `config.xml`。 +- `--connection-timeout=TIMEOUT` — 设置连接超时(以秒为单位)。默认值: 10s。 +- `--session-timeout=TIMEOUT` — 设置会话超时(以秒为单位)。默认值: 10s。 +- `--operation-timeout=TIMEOUT` — 设置操作超时(以秒为单位)。默认值: 10s。 +- `--history-file=FILE_PATH` — 设置历史文件的路径。默认值: `~/.keeper-client-history`。 +- `--log-level=LEVEL` — 设置日志级别。默认值: `information`。 +- `--no-confirmation` — 如果设置,将不要求几个命令的确认。默认值 `false` 在交互模式下,`true` 在查询模式下。 - `--help` — 显示帮助信息。 -## Example {#clickhouse-keeper-client-example} +## 示例 {#clickhouse-keeper-client-example} ```bash ./clickhouse-keeper-client -h localhost -p 9181 --connection-timeout 30 --session-timeout 30 --operation-timeout 30 @@ -46,26 +47,26 @@ keeper foo bar 2 ``` -## Commands {#clickhouse-keeper-client-commands} +## 命令 {#clickhouse-keeper-client-commands} -- `ls '[path]'` -- 列出给定路径的节点(默认:当前工作目录) +- `ls '[path]'` -- 列出给定路径的节点(默认: cwd) - `cd '[path]'` -- 更改工作路径(默认 `.`) -- `cp '' ''` -- 复制 'src' 节点到 'dest' 路径 +- `cp '' ''` -- 将 'src' 节点复制到 'dest' 路径 - `mv '' ''` -- 将 'src' 节点移动到 'dest' 路径 - `exists ''` -- 如果节点存在返回 `1`,否则返回 `0` -- `set '' [version]` -- 更新节点的值。仅在版本匹配时更新(默认:-1) +- `set '' [version]` -- 更新节点的值。只有在版本匹配时才会更新(默认: -1) - `create '' [mode]` -- 创建具有设定值的新节点 -- `touch ''` -- 创建一个值为空字符串的新节点。如果节点已经存在,则不会抛出异常 +- `touch ''` -- 创建一个值为空字符串的新节点。如果节点已存在,则不会抛出异常 - `get ''` -- 返回节点的值 -- `rm '' [version]` -- 仅在版本匹配时删除该节点(默认:-1) +- `rm '' [version]` -- 仅在版本匹配时删除节点(默认: -1) - `rmr '' [limit]` -- 如果子树大小小于限制,则递归删除路径。需要确认(默认限制 = 100) - `flwc ` -- 执行四个字母的命令 - `help` -- 打印此消息 - `get_direct_children_number '[path]'` -- 获取特定路径下直接子节点的数量 - `get_all_children_number '[path]'` -- 获取特定路径下所有子节点的数量 - `get_stat '[path]'` -- 返回节点的状态(默认 `.`) -- `find_super_nodes '[path]'` -- 查找给定路径下子节点数量大于某个阈值的节点(默认 `.`) -- `delete_stale_backups` -- 删除用于备份的 ClickHouse 节点,这些节点现在不再活动 -- `find_big_family [path] [n]` -- 返回子树中最大家庭的前 n 个节点(默认路径 = `.`, n = 10) -- `sync ''` -- 在进程与领导者之间同步节点 +- `find_super_nodes '[path]'` -- 查找给定路径下子节点数量超过某个阈值的节点(默认 `.`) +- `delete_stale_backups` -- 删除现在不活跃的用于备份的 ClickHouse 节点 +- `find_big_family [path] [n]` -- 返回子树中具有最大家族的前 n 个节点(默认路径 = `.` 且 n = 10) +- `sync ''` -- 在进程和领导者之间同步节点 - `reconfig "" [version]` -- 重新配置 Keeper 集群。请参见 /docs/en/guides/sre/keeper/clickhouse-keeper#reconfiguration diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/clickhouse-keeper-client.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/clickhouse-keeper-client.md.hash index bc78ebc9361..e6e8a8b859c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/clickhouse-keeper-client.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/clickhouse-keeper-client.md.hash @@ -1 +1 @@ -b006f0058048ab54 +1f8bc94cfffb68df diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/clickhouse-local.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/clickhouse-local.md index 490f4a40e51..7f5a0808b6c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/clickhouse-local.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/clickhouse-local.md @@ -1,9 +1,10 @@ --- -'description': '在没有服务器的情况下使用 clickhouse-local 处理数据的指南' +'description': '使用 clickhouse-local 处理数据而不需要服务器的指南' 'sidebar_label': 'clickhouse-local' 'sidebar_position': 60 'slug': '/operations/utilities/clickhouse-local' 'title': 'clickhouse-local' +'doc_type': 'reference' --- @@ -11,53 +12,53 @@ ## 何时使用 clickhouse-local 与 ClickHouse {#when-to-use-clickhouse-local-vs-clickhouse} -`clickhouse-local` 是一个易于使用的 ClickHouse 版本,非常适合需要使用 SQL 对本地和远程文件进行快速处理的开发人员,而无需安装完整的数据库服务器。使用 `clickhouse-local`,开发人员可以直接从命令行使用 SQL 命令(使用 [ClickHouse SQL 方言](../../sql-reference/index.md)),提供了一种简单高效的方式来访问 ClickHouse 特性,而无需完整安装 ClickHouse。`clickhouse-local` 的主要好处之一是它在安装 [clickhouse-client](/operations/utilities/clickhouse-local) 时已经包含。这意味着开发人员可以迅速开始使用 `clickhouse-local`,而无需复杂的安装过程。 +`clickhouse-local` 是 ClickHouse 的易用版本,适用于需要使用 SQL 对本地和远程文件进行快速处理的开发人员,而无需安装完整的数据库服务器。使用 `clickhouse-local`,开发人员可以直接从命令行使用 SQL 命令(使用 [ClickHouse SQL 方言](../../sql-reference/index.md)),提供了一种简单而高效的方式来访问 ClickHouse 功能,而无需完整安装 ClickHouse。`clickhouse-local` 的主要好处之一是它在安装 [clickhouse-client](/operations/utilities/clickhouse-local) 时已经包含。因此,开发人员可以快速开始使用 `clickhouse-local`,无需复杂的安装过程。 -虽然 `clickhouse-local` 是一个很好的开发和测试工具,以及处理文件的工具,但它不适合用于为最终用户或应用程序提供服务。在这些情况下,建议使用开源的 [ClickHouse](/install)。ClickHouse 是一个强大的 OLAP 数据库,旨在处理大规模分析工作负载。它可以对大型数据集上的复杂查询进行快速高效的处理,使其非常适合生产环境,在这些环境中高性能至关重要。此外,ClickHouse 还提供许多功能,如复制、分片和高可用性,这些是扩展到处理大数据集和为应用程序提供服务所必需的。如果您需要处理更大的数据集或为最终用户或应用程序提供服务,建议使用开源 ClickHouse,而不是 `clickhouse-local`。 +虽然 `clickhouse-local` 是用于开发和测试目的以及处理文件的绝佳工具,但不适合用于为最终用户或应用程序提供服务。在这些情况下,建议使用开源 [ClickHouse](/install)。ClickHouse 是一个强大的 OLAP 数据库,旨在处理大规模分析工作负载。它能够对大数据集进行快速高效的复杂查询处理,非常适用于高性能至关重要的生产环境。此外,ClickHouse 提供了诸如复制、分片和高可用性等广泛功能,这些功能对于扩展以处理大数据集和服务应用程序是必不可少的。如果您需要处理更大的数据集或为最终用户和应用程序提供服务,建议使用开源 ClickHouse,而非 `clickhouse-local`。 -请阅读下面的文档,展示 `clickhouse-local` 的示例用例,例如 [查询本地文件](#query_data_in_file) 或 [读取 S3 中的 parquet 文件](#query-data-in-a-parquet-file-in-aws-s3)。 +请阅读下面的文档,以查看 `clickhouse-local` 的示例用例,例如 [查询本地文件](#query_data_in_file) 或 [读取 S3 中的 Parquet 文件](#query-data-in-a-parquet-file-in-aws-s3)。 ## 下载 clickhouse-local {#download-clickhouse-local} -`clickhouse-local` 使用相同的 `clickhouse` 二进制文件执行,该二进制文件运行 ClickHouse 服务器和 `clickhouse-client`。下载最新版本的最简单方法是使用以下命令: +`clickhouse-local` 是使用与运行 ClickHouse 服务器和 `clickhouse-client` 相同的 `clickhouse` 二进制文件执行的。下载最新版本的最简单方法是使用以下命令: ```bash curl https://clickhouse.com/ | sh ``` :::note -您刚刚下载的二进制文件可以运行各种 ClickHouse 工具和实用程序。如果您想将 ClickHouse 作为数据库服务器来运行,请查看 [快速入门](../../quick-start.mdx)。 +您刚下载的二进制文件可以运行各种 ClickHouse 工具和实用程序。如果您想将 ClickHouse 作为数据库服务器运行,请查看 [快速入门](/get-started/quick-start)。 ::: ## 使用 SQL 查询文件中的数据 {#query_data_in_file} -`clickhouse-local` 的一个常见用法是对文件运行临时查询:您不必将数据插入到表中。`clickhouse-local` 可以将文件中的数据流入一个临时表并执行您的 SQL。 +`clickhouse-local` 的一个常见用途是在文件上运行临时查询:您无需将数据插入表中。`clickhouse-local` 可以将文件中的数据流入临时表并执行您的 SQL。 -如果文件位于与 `clickhouse-local` 一样的机器上,您只需指定要加载的文件。以下 `reviews.tsv` 文件包含亚马逊产品评论的一个样本: +如果文件位于与 `clickhouse-local` 相同的机器上,您可以简单地指定要加载的文件。以下 `reviews.tsv` 文件包含了亚马逊产品评论的样本: ```bash ./clickhouse local -q "SELECT * FROM 'reviews.tsv'" ``` -此命令是以下命令的简写: +此命令是以下命令的快捷方式: ```bash ./clickhouse local -q "SELECT * FROM file('reviews.tsv')" ``` -ClickHouse 根据文件名扩展名知道文件使用制表符分隔格式。如果您需要明确指定格式,只需添加某种 [许多 ClickHouse 输入格式](../../interfaces/formats.md): +ClickHouse 根据文件名扩展名知道文件使用制表符分隔的格式。如果您需要显式指定格式,只需添加 [许多 ClickHouse 输入格式](../../interfaces/formats.md) 之一: ```bash ./clickhouse local -q "SELECT * FROM file('reviews.tsv', 'TabSeparated')" ``` -`file` 表函数创建一个表,您可以使用 `DESCRIBE` 查看推测的模式: +`file` 表函数创建一个表,您可以使用 `DESCRIBE` 查看推断的模式: ```bash ./clickhouse local -q "DESCRIBE file('reviews.tsv')" ``` :::tip -您可以在文件名中使用通配符(请参阅 [通配符替换](/sql-reference/table-functions/file.md/#globs-in-path))。 +您可以在文件名中使用通配符(请参见 [通配符替换](/sql-reference/table-functions/file.md/#globs-in-path))。 示例: @@ -87,7 +88,7 @@ review_body Nullable(String) review_date Nullable(Date) ``` -让我们找到评分最高的产品: +现在让我们找到评分最高的产品: ```bash ./clickhouse local -q "SELECT @@ -102,7 +103,7 @@ Monopoly Junior Board Game 5 ## 在 AWS S3 中查询 Parquet 文件中的数据 {#query-data-in-a-parquet-file-in-aws-s3} -如果您在 S3 中有一个文件,请使用 `clickhouse-local` 和 `s3` 表函数在就地查询文件(无须将数据插入到 ClickHouse 表中)。我们在一个公共桶中有一个名为 `house_0.parquet` 的文件,包含在英国销售的房产价格。让我们看看它有多少行: +如果您在 S3 中有一个文件,可以使用 `clickhouse-local` 和 `s3` 表函数直接查询文件(而无需将数据插入 ClickHouse 表)。我们在一个公共桶中有一个名为 `house_0.parquet` 的文件,其中包含在英国销售的房产价格。让我们看看它有多少行: ```bash ./clickhouse local -q " @@ -110,13 +111,13 @@ SELECT count() FROM s3('https://datasets-documentation.s3.eu-west-3.amazonaws.com/house_parquet/house_0.parquet')" ``` -该文件有 2.7M 行: +文件有 2.7M 行: ```response 2772030 ``` -查看 ClickHouse 从文件中推测出的模式总是很有用: +查看 ClickHouse 从文件推断出的模式总是很有用: ```bash ./clickhouse local -q "DESCRIBE s3('https://datasets-documentation.s3.eu-west-3.amazonaws.com/house_parquet/house_0.parquet')" @@ -139,7 +140,7 @@ district Nullable(String) county Nullable(String) ``` -让我们看看最贵的社区: +现在让我们看看最昂贵的社区: ```bash ./clickhouse local -q " @@ -172,33 +173,31 @@ NORTHWOOD THREE RIVERS 184 731609 ███████████ ``` :::tip -当您准备将文件插入到 ClickHouse 中时,启动一个 ClickHouse 服务器并将 `file` 和 `s3` 表函数的结果插入到一个 `MergeTree` 表中。查看 [快速入门](../../quick-start.mdx) 以获取更多细节。 +当您准备将文件插入 ClickHouse 时,启动一个 ClickHouse 服务器,并将 `file` 和 `s3` 表函数的结果插入到 `MergeTree` 表中。查看 [快速入门](/get-started/quick-start) 以获取更多详细信息。 ::: - ## 格式转换 {#format-conversions} -您可以使用 `clickhouse-local` 在不同格式之间转换数据。示例: +您可以使用 `clickhouse-local` 在不同格式之间转换数据。例如: ```bash $ clickhouse-local --input-format JSONLines --output-format CSV --query "SELECT * FROM table" < data.json > data.csv ``` -格式是根据文件扩展名自动检测的: +格式会根据文件扩展名自动检测: ```bash $ clickhouse-local --query "SELECT * FROM table" < data.json > data.csv ``` -作为简写,您可以使用 `--copy` 参数来编写: +作为快捷方式,您可以使用 `--copy` 参数来编写: ```bash $ clickhouse-local --copy < data.json > data.csv ``` +## 用法 {#usage} -## 使用 {#usage} - -默认情况下,`clickhouse-local` 可以访问同一主机上 ClickHouse 服务器的数据,并且不依赖于服务器的配置。它还支持使用 `--config-file` 参数加载服务器配置。对于临时数据,默认情况下会创建一个唯一的临时数据目录。 +默认情况下,`clickhouse-local` 具有对同一主机上 ClickHouse 服务器数据的访问权限,并且不依赖于服务器的配置。它还支持使用 `--config-file` 参数加载服务器配置。对于临时数据,默认情况下会创建一个唯一的临时数据目录。 基本用法(Linux): @@ -213,34 +212,33 @@ $ ./clickhouse local --structure "table_structure" --input-format "format_of_inc ``` :::note -`clickhouse-local` 也在通过 WSL2 支持 Windows。 +`clickhouse-local` 在 Windows 的 WSL2 上也受支持。 ::: 参数: - `-S`, `--structure` — 输入数据的表结构。 -- `--input-format` — 输入格式,默认为 `TSV`。 -- `-F`, `--file` — 数据路径,默认为 `stdin`。 -- `-q`, `--query` — 执行的查询,以 `;` 作为分隔符。可以多次指定 `--query`,例如 `--query "SELECT 1" --query "SELECT 2"`。不能与 `--queries-file` 同时使用。 -- `--queries-file` - 包含要执行的查询的文件路径。可以多次指定 `--queries-file`,例如 `--query queries1.sql --query queries2.sql`。不能与 `--query` 同时使用。 -- `--multiquery, -n` – 如果指定,可以在 `--query` 选项之后列出以分号分隔的多个查询。为了方便,也可以省略 `--query`,直接在 `--multiquery` 之后传递查询。 -- `-N`, `--table` — 输出数据存放的表名,默认为 `table`。 -- `-f`, `--format`, `--output-format` — 输出格式,默认为 `TSV`。 +- `--input-format` — 输入格式,默认是 `TSV`。 +- `-F`, `--file` — 数据路径,默认是 `stdin`。 +- `-q`, `--query` — 要执行的查询,使用 `;` 作为分隔符。`--query` 可以多次指定,例如 `--query "SELECT 1" --query "SELECT 2"`。不能与 `--queries-file` 同时使用。 +- `--queries-file` - 包含要执行的查询的文件路径。`--queries-file` 可以多次指定,例如 `--query queries1.sql --query queries2.sql`。不能与 `--query` 同时使用。 +- `--multiquery, -n` – 若指定,多个查询可以用分号分隔,并在 `--query` 选项后列出。为了方便起见,也可以省略 `--query`,并将查询直接放在 `--multiquery` 后面。 +- `-N`, `--table` — 输出数据放置的表名,默认是 `table`。 +- `-f`, `--format`, `--output-format` — 输出格式,默认是 `TSV`。 - `-d`, `--database` — 默认数据库,默认为 `_local`。 -- `--stacktrace` — 在发生异常时是否转储调试输出。 -- `--echo` — 在执行前打印查询。 -- `--verbose` — 详细说明查询执行情况。 -- `--logger.console` — 日志输出到控制台。 +- `--stacktrace` — 在异常情况下是否转储调试输出。 +- `--echo` — 执行前打印查询。 +- `--verbose` — 查询执行的更多细节。 +- `--logger.console` — 记录到控制台。 - `--logger.log` — 日志文件名。 - `--logger.level` — 日志级别。 -- `--ignore-error` — 如果查询失败,不停止处理。 -- `-c`, `--config-file` — 配置文件的路径,格式与 ClickHouse 服务器的相同,默认为空配置。 +- `--ignore-error` — 如果查询失败,则不停止处理。 +- `-c`, `--config-file` — 配置文件的路径,格式与 ClickHouse 服务器相同,默认为空配置。 - `--no-system-tables` — 不附加系统表。 -- `--help` — `clickhouse-local` 参数参考。 +- `--help` — `clickhouse-local` 的参数参考。 - `-V`, `--version` — 打印版本信息并退出。 -此外,还有每个 ClickHouse 配置变量的参数,这些参数更常用,而不是 `--config-file`。 - +此外,还有每个 ClickHouse 配置变量的参数,通常使用这些参数而不是 `--config-file`。 ## 示例 {#examples} @@ -252,7 +250,7 @@ Read 2 rows, 32.00 B in 0.000 sec., 5182 rows/sec., 80.97 KiB/sec. 3 4 ``` -前一个示例与以下内容相同: +前面的示例与以下内容相同: ```bash $ echo -e "1,2\n3,4" | clickhouse-local -n --query " @@ -308,5 +306,5 @@ Read 186 rows, 4.15 KiB in 0.035 sec., 5302 rows/sec., 118.34 KiB/sec. - [使用 clickhouse-local 提取、转换和查询本地文件中的数据](https://clickhouse.com/blog/extracting-converting-querying-local-files-with-sql-clickhouse-local) - [将数据导入 ClickHouse - 第 1 部分](https://clickhouse.com/blog/getting-data-into-clickhouse-part-1) -- [探索大规模真实数据集:ClickHouse 中的 100 多年气象记录](https://clickhouse.com/blog/real-world-data-noaa-climate-data) -- 博客:[使用 clickhouse-local 提取、转换和查询本地文件中的数据](https://clickhouse.com/blog/extracting-converting-querying-local-files-with-sql-clickhouse-local) +- [探索大规模真实数据集:ClickHouse 中的 100 多年天气记录](https://clickhouse.com/blog/real-world-data-noaa-climate-data) +- 博客: [使用 clickhouse-local 提取、转换和查询本地文件中的数据](https://clickhouse.com/blog/extracting-converting-querying-local-files-with-sql-clickhouse-local) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/clickhouse-local.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/clickhouse-local.md.hash index a38ebd2e4c7..70a3d274650 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/clickhouse-local.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/clickhouse-local.md.hash @@ -1 +1 @@ -1010354728bdf8ae +c9d59ac716c25d4a diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/clickhouse-obfuscator.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/clickhouse-obfuscator.md index e735b21b983..3b4a15e15db 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/clickhouse-obfuscator.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/clickhouse-obfuscator.md @@ -2,43 +2,44 @@ 'description': 'Clickhouse Obfuscator 的文档' 'slug': '/operations/utilities/clickhouse-obfuscator' 'title': 'clickhouse-obfuscator' +'doc_type': 'reference' --- -一个简单的表数据模糊工具。 +一个简单的表数据混淆工具。 -它读取输入表并生成输出表,保持输入的一些属性,但包含不同的数据。 -它允许发布几乎真实的生产数据,以用于基准测试。 +它读取一个输入表并生成一个输出表,保持输入的一些属性,但包含不同的数据。 +它允许发布几乎真实的生产数据用于基准测试。 -它设计为保留以下数据属性: +它旨在保持以下数据属性: - 每列和每组列的值的基数(不同值的数量); -- 条件基数:在另一个列的值条件下,一个列的不同值的数量; -- 整数的绝对值的概率分布;有符号整数的符号;浮点数的指数和符号; +- 条件基数:在另一个列值的条件下,一个列的不同值的数量; +- 整数的绝对值的概率分布;带符号整数的符号;浮点数的指数和符号; - 字符串长度的概率分布; -- 数字的零值概率;空字符串和数组,`NULL`s; +- 数字零值的概率;空字符串和数组,`NULL`; -- 使用 LZ77 和熵编码族压缩时的数据压缩比; -- 表中时间值的连续性(差异幅度);浮点值的连续性; -- `DateTime` 值的日期组件; +- 使用LZ77和熵族编解码器进行压缩时的数据压缩比; +- 表中时间值的连续性(差异大小);浮点值的连续性; +- `DateTime`值的日期组件; -- 字符串值的 UTF-8 有效性; +- 字符串值的UTF-8有效性; - 字符串值看起来自然。 -上述大多数属性对于性能测试是可行的: +上述大多数属性适用于性能测试: -读取数据、过滤、聚合和排序的速度几乎与原始数据相同,因为基数、幅度、压缩比等都得到了保留。 +读取数据、过滤、聚合和排序的速度几乎与原始数据相同,因为基数、大小、压缩比等得到了保留。 -它以确定性方式工作:你定义一个种子值,转换由输入数据和值种子决定。 -某些转换是一对一的,可以反向操作,因此你需要拥有一个较大的种子并将其保密。 +它以确定性方式工作:您定义一个种子值,转换由输入数据和种子决定。 +某些转换是一对一的,可以被反转,因此您需要有一个大的种子并将其保密。 -它使用某些加密原语来转换数据,但从加密的角度来看,它没有正确执行,因此你不应将结果视为安全,除非你有其他理由。结果可能保留一些你不想发布的数据。 +它使用一些密码学原语来转换数据,但从密码学的角度来看,它并未正确处理,因此您不应认为结果是安全的,除非您有其他理由。结果可能保留您不想发布的数据。 -它始终将 0、1、-1 数字、日期、数组长度和空标志与源数据完全一样。 -例如,你的数据表中有一列 `IsMobile`,值为 0 和 1。在转换后的数据中,它将保持相同的值。 +它始终将0、1、-1数字、日期、数组的长度和空标志精确地保留为源数据中的值。 +例如,您的表中有一个`IsMobile`列,值为0和1。在变换后的数据中,它将保持相同的值。 -因此,用户将能够准确计算出移动流量的比例。 +因此,用户将能够精确计算移动流量的比例。 -再举一个例子。当你的数据表中有一些私人数据,比如用户电子邮件时,你不想发布任何单一的电子邮件地址。 -如果你的表足够大且包含多个不同的电子邮件,并且没有任何电子邮件的频率远高于其他,则将对所有数据进行匿名化。但是如果你在一列中有少量不同值,可能会重现其中的一些。 -你应该查看该工具的工作算法,并微调其命令行参数。 +让我们再举一个例子。当您在表中有一些私密数据,如用户电子邮件,而您不想发布任何单一的电子邮件地址时。 +如果您的表足够大,并且包含多个不同的电子邮件,并且没有任何电子邮件的频率比其他电子邮件高,那么它将匿名化所有数据。但如果您在一列中有少量不同的值,它可能会再现其中一些值。 +您应该查看该工具的工作算法,并微调其命令行参数。 -此工具只在数据量至少适度(至少数千行)时工作良好。 +该工具仅适用于至少中等数量的数据(至少数千行)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/clickhouse-obfuscator.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/clickhouse-obfuscator.md.hash index bafb278c59f..69e7af6c950 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/clickhouse-obfuscator.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/clickhouse-obfuscator.md.hash @@ -1 +1 @@ -dd1b33ab1b478082 +31c1737539f475e4 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/index.md index 54d1f156a68..58124c433d6 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/index.md @@ -1,21 +1,22 @@ --- -'description': '页面列出了各种有用的 ClickHouse 工具和实用程序。' +'description': '页面列出了各种有用的 ClickHouse 工具和工具。' 'keywords': - 'tools' - 'utilities' -'sidebar_label': '工具和实用程序列表' +'sidebar_label': '工具和工具列表' 'sidebar_position': 56 'slug': '/operations/utilities/' -'title': '工具和实用程序列表' +'title': '工具和工具列表' +'doc_type': 'landing-page' --- | 工具/实用程序 | 描述 | |------|-------------| -| [clickhouse-local](../../operations/utilities/clickhouse-local.md) | 允许在不启动 ClickHouse 服务器的情况下对数据运行 SQL 查询,类似于 `awk` 的功能。 | -| [clickhouse-benchmark](../../operations/utilities/clickhouse-benchmark.md) | 使用自定义查询和设置对服务器进行负载测试。 | -| [clickhouse-format](../../operations/utilities/clickhouse-format.md) | 使输入查询格式化。 | -| [ClickHouse obfuscator](../../operations/utilities/clickhouse-obfuscator.md) | 混淆数据。 | -| [ClickHouse compressor](../../operations/utilities/clickhouse-compressor.md) | 压缩和解压数据。 | -| [clickhouse-disks](../../operations/utilities/clickhouse-disks.md) | 提供在不同 ClickHouse 磁盘之间的类文件系统操作。 | -| [clickhouse-odbc-bridge](../../operations/utilities/odbc-bridge.md) | ODBC 驱动的代理服务器。 | -| [clickhouse_backupview](../../operations/utilities/backupview.md) | 分析 ClickHouse 备份的 Python 模块。 | +|[clickhouse-local](../../operations/utilities/clickhouse-local.md) | 允许在数据上运行 SQL 查询,而无需启动 ClickHouse 服务器,类似于 `awk` 的功能。| +|[clickhouse-benchmark](../../operations/utilities/clickhouse-benchmark.md) | 使用自定义查询和设置对服务器进行负载测试。| +| [clickhouse-format](../../operations/utilities/clickhouse-format.md) | 使输入查询格式化。| +|[ClickHouse obfuscator](../../operations/utilities/clickhouse-obfuscator.md) | 混淆数据。| +|[ClickHouse compressor](../../operations/utilities/clickhouse-compressor.md) | 压缩和解压缩数据。| +| [clickhouse-disks](../../operations/utilities/clickhouse-disks.md) | 提供在不同 ClickHouse 磁盘之间对文件进行的类文件系统操作。| +| [clickhouse-odbc-bridge](../../operations/utilities/odbc-bridge.md) | ODBC 驱动程序的代理服务器。| +| [clickhouse_backupview](../../operations/utilities/backupview.md) | 用于分析 ClickHouse 备份的 Python 模块。| diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/index.md.hash index f7e06d5da0f..fc4b826221f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/index.md.hash @@ -1 +1 @@ -fa8789b266b2b263 +f3801ed3d4bc1aae diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/odbc-bridge.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/odbc-bridge.md index 58e508cbd2c..6486a1f6c58 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/odbc-bridge.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/odbc-bridge.md @@ -2,25 +2,28 @@ 'description': 'Odbc Bridge 的文档' 'slug': '/operations/utilities/odbc-bridge' 'title': 'clickhouse-odbc-bridge' +'doc_type': 'reference' --- -一个简单的 HTTP 服务器,像 ODBC 驱动一样工作。其主要动机是避免 ODBC 实现中的可能的段错误或其他故障,这些问题可能会导致整个 clickhouse-server 进程崩溃。 +像代理 ODBC 驱动程序的简单 HTTP 服务器。主要的动机是可能的段错误或 ODBC 实现中的其他错误,这可能会导致整个 clickhouse-server 进程崩溃。 该工具通过 HTTP 工作,而不是通过管道、共享内存或 TCP,因为: -- 实现起来更简单 -- 调试起来更简单 +- 实现更简单 +- 调试更简单 - jdbc-bridge 可以以相同的方式实现 -## 使用方法 {#usage} +## 用法 {#usage} -`clickhouse-server` 在 odbc 表函数和 StorageODBC 中使用此工具。 -然而,它也可以作为独立工具从命令行使用,使用以下参数在 POST 请求 URL 中: +`clickhouse-server` 在 odbc 表函数和 StorageODBC 中使用此工具。 +然而,它也可以作为独立工具从命令行使用,POST 请求 URL 中的参数如下: - `connection_string` -- ODBC 连接字符串。 -- `sample_block` -- 以 ClickHouse NamesAndTypesList 格式描述的列,名称用反引号括起来,类型用字符串表示。名称和类型用空格分隔,行用换行符分隔。 +- `sample_block` -- ClickHouse NamesAndTypesList 格式的列描述,名称用反引号括起来, + 类型作为字符串。名称和类型用空格分隔,行用 + 换行符分隔。 - `max_block_size` -- 可选参数,设置单个块的最大大小。 -查询被发送到 POST 主体中。响应以 RowBinary 格式返回。 +查询在 POST 主体中发送。响应以 RowBinary 格式返回。 -## 示例: {#example} +## 示例: {#example} ```bash $ clickhouse-odbc-bridge --http-port 9018 --daemon diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/odbc-bridge.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/odbc-bridge.md.hash index 37ec1df31b8..126219e1257 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/odbc-bridge.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/utilities/odbc-bridge.md.hash @@ -1 +1 @@ -09ce862cbc2d48aa +55c0ab33bf77d0e7 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/workload-scheduling.md b/i18n/zh/docusaurus-plugin-content-docs/current/operations/workload-scheduling.md index 4698ec6500a..dfbf9373ef8 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/workload-scheduling.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/workload-scheduling.md @@ -1,20 +1,21 @@ --- -'description': 'Documentation for Workload Scheduling' -'sidebar_label': 'Workload 计划' +'description': 'Workload Scheduling 的文档' +'sidebar_label': '工作负载调度' 'sidebar_position': 69 'slug': '/operations/workload-scheduling' -'title': 'Workload 计划' +'title': '工作负载调度' +'doc_type': 'reference' --- -当 ClickHouse 同时执行多个查询时,它们可能会使用共享资源(例如磁盘)。可以应用调度限制和策略,以调节不同工作负载之间资源的利用和共享。对于每个资源,可以配置调度层次结构。层次结构的根节点表示一个资源,而叶子节点则是队列,保存超过资源容量的请求。 +当 ClickHouse 同时执行多个查询时,它们可能会使用共享资源(例如磁盘和 CPU 核心)。可以应用调度约束和策略来调节不同工作负载之间如何使用和共享资源。对于所有资源,可以配置一个通用的调度层次结构。层次结构的根节点表示共享资源,而叶子节点是特定的工作负载,包含超过资源容量的请求。 :::note -当前 [远程磁盘 IO](#disk_config) 和 [CPU](#cpu_scheduling) 可以使用上述方法进行调度。有关灵活内存限制,请参阅 [内存过度分配](settings/memory-overcommit.md) +目前可以使用所描述的方法调度 [remote disk IO](#disk_config) 和 [CPU](#cpu_scheduling)。有关灵活的内存限制,请参见 [Memory overcommit](settings/memory-overcommit.md) ::: ## 磁盘配置 {#disk_config} -要为特定磁盘启用 IO 工作负载调度,您必须为 WRITE 和 READ 访问创建读写资源: +要为特定磁盘启用 IO 工作负载调度,您必须为 WRITE 和 READ 访问创建读取和写入资源: ```sql CREATE RESOURCE resource_name (WRITE DISK disk_name, READ DISK disk_name) @@ -23,19 +24,19 @@ CREATE RESOURCE read_resource_name (WRITE DISK write_disk_name) CREATE RESOURCE write_resource_name (READ DISK read_disk_name) ``` -资源可以用于任何数量的磁盘以进行 READ 或 WRITE 或两者均可。还有一种语法允许将资源用于所有磁盘: +该资源可以用于任何数量的磁盘,包括只读、只写或读写。可以使用一种语法,使资源适用于所有磁盘: ```sql CREATE RESOURCE all_io (READ ANY DISK, WRITE ANY DISK); ``` -表达资源所使用的磁盘的另一种方法是服务器的 `storage_configuration`: +另一种表达资源所使用的磁盘的方式是服务器的 `storage_configuration`: :::warning -使用 clickhouse 配置进行工作负载调度已被弃用。应使用 SQL 语法。 +使用 ClickHouse 配置进行工作负载调度已被弃用。应使用 SQL 语法。 ::: -要为特定磁盘启用 IO 调度,您必须在存储配置中指定 `read_resource` 和/或 `write_resource`。这告诉 ClickHouse 应该为给定磁盘的每个读写请求使用哪个资源。读写资源可以引用同一资源名称,这对本地 SSD 或 HDD 很有用。多个不同磁盘也可以引用同一资源,这对远程磁盘很有用:如果您希望能够在“生产”和“开发”工作负载之间公平划分网络带宽。 +要为特定磁盘启用 IO 调度,您必须在存储配置中指定 `read_resource` 和/或 `write_resource`。它告诉 ClickHouse 应该为给定磁盘的每个读写请求使用哪个资源。读取和写入资源可以引用相同的资源名称,这对本地 SSD 或 HDD 很有用。多个不同的磁盘也可以引用同一资源,这对于远程磁盘很有用:如果您想能够在“生产”和“开发”工作负载之间公平分配网络带宽。 示例: ```xml @@ -65,24 +66,24 @@ CREATE RESOURCE all_io (READ ANY DISK, WRITE ANY DISK); ``` -请注意,服务器配置选项优先于 SQL 定义资源的方法。 +请注意,服务器配置选项优先于 SQL 定义资源的方式。 ## 工作负载标记 {#workload_markup} -查询可以通过设置 `workload` 进行标记,以区分不同的工作负载。如果未设置 `workload`,则使用值 "default"。请注意,您可以使用设置配置文件指定其他值。如果希望用户的所有查询都使用固定的 `workload` 设置值,则可以使用设置约束使 `workload` 保持不变。 +查询可以通过设置 `workload` 来标记,以区分不同的工作负载。如果未设置 `workload`,则使用值 "default"。注意,您可以使用设置配置来指定其他值。如果希望来自用户的所有查询都标记为固定值的 `workload` 设置,可以使用设置约束使 `workload` 保持不变。 -可以为后台活动分配 `workload` 设置。合并和突变分别使用 `merge_workload` 和 `mutation_workload` 服务器设置。这些值也可以通过 `merge_workload` 和 `mutation_workload` 合并树设置为特定表重写。 +可以为后台活动分配 `workload` 设置。合并和变更使用相应的 `merge_workload` 和 `mutation_workload` 服务器设置。这些值也可以通过特定表使用 `merge_workload` 和 `mutation_workload` MergeTree 设置进行覆盖。 -让我们考虑一个具有两种不同工作负载的系统示例:“生产”和“开发”。 +让我们考虑一个具有两个不同工作负载的系统:“生产”和“开发”。 ```sql SELECT count() FROM my_table WHERE value = 42 SETTINGS workload = 'production' SELECT count() FROM my_table WHERE value = 13 SETTINGS workload = 'development' ``` -## 资源调度层次结构 {#hierarchy} +## 资源调度层次 {#hierarchy} -从调度子系统的角度来看,资源代表调度节点的层次结构。 +从调度子系统的角度来看,资源表示一个调度节点的层次结构。 ```mermaid graph TD @@ -104,19 +105,19 @@ graph TD ``` :::warning -使用 clickhouse 配置进行工作负载调度已被弃用。应使用 SQL 语法。SQL 语法会自动创建所有必要的调度节点,以下调度节点描述应被视为较低级别的实现细节, 可通过 [system.scheduler](/operations/system-tables/scheduler.md) 表访问。 +使用 ClickHouse 配置进行工作负载调度已被弃用。应使用 SQL 语法。SQL 语法会自动创建所有必要的调度节点,以下调度节点说明应视为较低级的实现细节,可以通过 [system.scheduler](/operations/system-tables/scheduler.md) 表访问。 ::: **可能的节点类型:** -* `inflight_limit`(约束) - 如果并发在途请求的数量超过 `max_requests`,或其总成本超过 `max_cost`,则会阻止;必须有一个子节点。 -* `bandwidth_limit`(约束) - 如果当前带宽超过 `max_speed`(0 表示无限制)或突发超过 `max_burst`(默认等于 `max_speed`),则会阻止;必须有一个子节点。 -* `fair`(策略) - 根据最大最小公平性选择一个子节点来处理下一个请求;子节点可以指定 `weight`(默认为 1)。 -* `priority`(策略) - 根据静态优先级(较低的值表示更高的优先级)选择下一个要处理的请求;子节点可以指定 `priority`(默认为 0)。 -* `fifo`(队列) - 能够保存超过资源容量的请求的层次结构的叶子。 +* `inflight_limit`(约束) - 如果并发的未完成请求数量超过 `max_requests`,或它们的总成本超过 `max_cost`,则会阻塞;必须有一个子节点。 +* `bandwidth_limit`(约束) - 如果当前带宽超过 `max_speed`(0表示无限制)或突发超过 `max_burst`(默认等于 `max_speed`),则会阻塞;必须有一个子节点。 +* `fair`(策略) - 根据最大最小公平性,从其子节点中选择下一个请求进行服务;子节点可以指定 `weight`(默认是1)。 +* `priority`(策略) - 根据静态优先级从其子节点中选择下一个请求进行服务(较低的值意味着更高的优先级);子节点可以指定 `priority`(默认是0)。 +* `fifo`(队列) - 持有超过资源容量的请求的层次结构叶子。 -为了能够充分利用底层资源的全部容量,您应该使用 `inflight_limit`。请注意,较低的 `max_requests` 或 `max_cost` 可能导致资源利用不足,而过高的数字可能导致调度器内部的队列为空,这反过来又会导致策略被忽视(不公平或忽略优先级)。另一方面,如果您希望保护资源不被过度利用,则应使用 `bandwidth_limit`。当 `duration` 秒内消耗的资源量超过 `max_burst + max_speed * duration` 字节时,它将限制流量。可以在同一资源上使用两个 `bandwidth_limit` 节点,以限制短时间内的峰值带宽和较长时间的平均带宽。 +为了能够充分利用基础资源,您应该使用 `inflight_limit`。注意,较低的 `max_requests` 或 `max_cost` 可能会导致资源未得到充分利用,而过高的数字可能会导致调度器内部出现空队列,从而导致子树中忽略策略(不公平或忽视优先级)。另一方面,如果您希望保护资源免受过高的利用,您应该使用 `bandwidth_limit`。当在 `duration` 秒内消耗的资源量超过 `max_burst + max_speed * duration` 字节时,它将进行节流。同一资源上的两个 `bandwidth_limit` 节点可以用于限制短时间内的峰值带宽和更长时间的平均带宽。 -以下示例显示如何定义 IO 调度层次: +以下示例展示了如何定义在图片中所示的 IO 调度层次结构: ```xml @@ -160,10 +161,10 @@ graph TD ## 工作负载分类器 {#workload_classifiers} :::warning -使用 clickhouse 配置进行工作负载调度已被弃用。应使用 SQL 语法。使用 SQL 语法时,分类器会自动创建。 +使用 ClickHouse 配置进行工作负载调度已被弃用。应使用 SQL 语法。使用 SQL 语法时会自动创建分类器。 ::: -工作负载分类器用于定义查询中指定的 `workload` 到应使用的特定资源的叶队列的映射。目前,工作负载分类是简单的:仅提供静态映射。 +工作负载分类器用于根据查询中指定的 `workload` 定义到应使用的特定资源的叶子队列的映射。目前,工作负载分类是简单的:只有静态映射可用。 示例: ```xml @@ -185,9 +186,9 @@ graph TD ``` -## 工作负载层次结构 {#workloads} +## 工作负载层次 {#workloads} -ClickHouse 提供方便的 SQL 语法来定义调度层次。所有使用 `CREATE RESOURCE` 创建的资源共享相同的层次结构,但在某些方面可能有所不同。每个使用 `CREATE WORKLOAD` 创建的工作负载为每个资源维护几个自动创建的调度节点。可以在另一个父工作负载内部创建子工作负载。以下示例定义了与上述 XML 配置完全相同的层次结构: +ClickHouse 提供了方便的 SQL 语法来定义调度层次。所有通过 `CREATE RESOURCE` 创建的资源共享相同的层次结构,但在某些方面可能不同。通过 `CREATE WORKLOAD` 创建的每个工作负载保持为每个资源自动创建的一些调度节点。子工作负载可以在另一个父工作负载内创建。以下是定义与上述 XML 配置完全相同的层次结构的示例: ```sql CREATE RESOURCE network_write (WRITE DISK s3) @@ -197,29 +198,33 @@ CREATE WORKLOAD development IN all CREATE WORKLOAD production IN all SETTINGS weight = 3 ``` -没有子节点的叶子工作负载的名称可以在查询设置 `SETTINGS workload = 'name'` 中使用。 +没有子项的叶子工作负载的名称可以在查询设置中使用 `SETTINGS workload = 'name'`。 要自定义工作负载,可以使用以下设置: -* `priority` - 同级工作负载根据静态优先级值进行处理(较低的值表示较高的优先级)。 -* `weight` - 同级工作负载具有相同的静态优先级按权重共享资源。 -* `max_io_requests` - 此工作负载中并发 IO 请求的数量限制。 -* `max_bytes_inflight` - 此工作负载中并发请求的总在途字节的限制。 -* `max_bytes_per_second` - 此工作负载的字节读或写速率限制。 -* `max_burst_bytes` - 工作负载在未被限制的情况下可以处理的最大字节数(对于每个资源独立)。 -* `max_concurrent_threads` - 此工作负载中查询的线程数限制。 - -通过工作负载设置指定的所有限制对每个资源都是独立的。例如,具有 `max_bytes_per_second = 10485760` 的工作负载在每个读取和写入资源上将有 10 MB/s 的带宽限制。如果需要读取和写入的公共限制,考虑对READ和WRITE访问使用相同的资源。 - -对于不同资源,无法指定不同的工作负载层次结构。但可以为特定资源指定不同的工作负载设置值: +* `priority` - 兄弟工作负载根据静态优先级值进行服务(较低的值意味着更高的优先级)。 +* `weight` - 拥有相同静态优先级的兄弟工作负载根据权重共享资源。 +* `max_io_requests` - 在此工作负载中并发 IO 请求的次数限制。 +* `max_bytes_inflight` - 此工作负载中并发请求的总浮动字节的限制。 +* `max_bytes_per_second` - 此工作负载的字节读取或写入速率限制。 +* `max_burst_bytes` - 此工作负载在未受到节流的情况下可处理的最大字节数(针对每个资源独立设置)。 +* `max_concurrent_threads` - 此工作负载中查询的线程数的限制。 +* `max_concurrent_threads_ratio_to_cores` - 与 `max_concurrent_threads` 相同,但归一化为可用 CPU 核心的数量。 +* `max_cpus` - 为在此工作负载中服务查询而限制的 CPU 核心数量。 +* `max_cpu_share` - 与 `max_cpus` 相同,但归一化为可用 CPU 核心的数量。 +* `max_burst_cpu_seconds` - 此工作负载在未受到由于 `max_cpus` 而节流的情况下可以消耗的最大 CPU 秒数。 + +通过工作负载设置指定的所有限制对于每个资源是独立的。例如,具有 `max_bytes_per_second = 10485760` 的工作负载在每个独立的读取和写入资源上将有 10 MB/s 的带宽限制。如果需要读取和写入的共同限制,请考虑对 READ 和 WRITE 访问使用相同的资源。 + +对于不同资源的工作负载,无法指定不同的层次结构。但是,确实可以为特定资源指定不同的工作负载设置值: ```sql CREATE OR REPLACE WORKLOAD all SETTINGS max_io_requests = 100, max_bytes_per_second = 1000000 FOR network_read, max_bytes_per_second = 2000000 FOR network_write ``` -还要注意,如果工作负载被其他工作负载引用,则无法删除工作负载或资源。要更新工作负载的定义,请使用 `CREATE OR REPLACE WORKLOAD` 查询。 +此外,请注意,如果工作负载被另一个工作负载引用,则无法删除工作负载或资源。要更新工作负载的定义,请使用 `CREATE OR REPLACE WORKLOAD` 查询。 :::note -工作负载设置会转换为适当的一组调度节点。有关较低级别的详细信息,请参阅调度节点的 [类型和选项](#hierarchy) 的描述。 +工作负载设置被转换为适当的调度节点集。有关更低级细节,请参见调度节点 [类型和选项](#hierarchy) 的描述。 ::: ## CPU 调度 {#cpu_scheduling} @@ -231,13 +236,13 @@ CREATE RESOURCE cpu (MASTER THREAD, WORKER THREAD) CREATE WORKLOAD all SETTINGS max_concurrent_threads = 100 ``` -当 ClickHouse 服务器执行多个带有 [多个线程](/operations/settings/settings.md#max_threads) 的并发查询且所有 CPU 槽位都在使用时,将达到超载状态。在超载状态中,每个释放的 CPU 槽位将根据调度策略重新调度到适当的工作负载。对于共享相同工作负载的查询,槽位使用轮询分配。对于在不同工作负载中的查询,槽位则根据工作负载指定的权重、优先级和限制进行分配。 +当 ClickHouse 服务器执行许多并发查询,并且所有 CPU 插槽都在使用时,达到超负荷状态。在超负荷状态下,释放的每个 CPU 插槽根据调度政策重新调度到适当的工作负载。对于共享同一工作负载的查询,插槽使用轮询分配。对于处于不同工作负载中的查询,插槽根据工作负载指定的权重、优先级和限制进行分配。 -CPU 时间由线程消耗,当它们未被阻塞并在 CPU 密集型任务上工作时。为了调度目的,区分了两种类型的线程: -* 主线程 - 开始工作于查询或合并或突变等后台活动的第一个线程。 -* 工作线程 - 主线程可以生成的额外线程,以处理 CPU 密集型任务。 +当线程未被阻塞并在 CPU 密集型任务上工作时,会消耗 CPU 时间。为了调度目的,将线程分为两种: +* 主线程 — 首先开始处理查询或后台活动(如合并或变更)的线程。 +* 工作线程 — 主线程可以生成的附加线程,以处理 CPU 密集型任务。 -为了更好的响应性,可能希望为主线程和工作线程使用单独的资源。在使用高 `max_threads` 查询设置值时,工作线程的数量会轻易垄断 CPU 资源。然后传入的查询将被阻塞,并等待其主线程开始执行的 CPU 槽位。为避免这种情况,可以使用以下配置: +为了提高响应速度,可能希望为主线程和工作线程使用独立资源。当使用高 `max_threads` 查询设置值时,大量工作线程可能轻易垄断 CPU 资源。然后,传入的查询应阻塞并等待 CPU 插槽,以便其主线程开始执行。为避免这种情况,可以使用以下配置: ```sql CREATE RESOURCE worker_cpu (WORKER THREAD) @@ -245,11 +250,11 @@ CREATE RESOURCE master_cpu (MASTER THREAD) CREATE WORKLOAD all SETTINGS max_concurrent_threads = 100 FOR worker_cpu, max_concurrent_threads = 1000 FOR master_cpu ``` -它将创建主线程和工作线程的单独限制。即使所有 100 个工作 CPU 槽位都忙,新的查询也不会被阻塞,直到有可用的主 CPU 槽位。它们将以一个线程开始执行。稍后,如果工作 CPU 槽位变得可用,这些查询可以扩展并生成它们的工作线程。另一方面,这种方法不会将槽位的总数绑定到 CPU 处理器的数量,运行过多的并发线程会影响性能。 +这将创建主线程和工作线程的单独限制。即使所有 100 个工作 CPU 插槽都已占用,新的查询也不会被阻塞,直到有可用的主 CPU 插槽。它们将使用一个线程开始执行。稍后,如果工作 CPU 插槽变得可用,这样的查询可以扩展并生成它们的工作线程。另一方面,这种方法并不会将总插槽数绑定到 CPU 处理器的数量,运行过多的并发线程会影响性能。 -限制主线程的并发数不会限制并发查询的数量。CPU 槽位可以在查询执行中间释放,并被其他线程重新获得。例如,具有 2 个并发主线程限制的 4 个并发查询可以全部并行执行。在这种情况下,每个查询将获得 50% 的 CPU 处理器。应使用单独的逻辑限制并发查询的数量,而目前不支持工作负载。 +限制主线程的并发性并不会限制并发查询的数量。CPU 插槽可能会在查询执行的中间被释放,并被其他线程重新获得。例如,具有 2 个并发主线程限制的 4 个并发查询可以全部并行执行。在这种情况下,每个查询将获得 CPU 处理器的 50%。应使用单独的逻辑来限制并发查询的数量,目前不支持用于工作负载。 -可以为工作负载使用单独的线程并发限制: +可以对工作负载使用单独线程并发限制: ```sql CREATE RESOURCE cpu (MASTER THREAD, WORKER THREAD) @@ -260,37 +265,132 @@ CREATE WORKLOAD analytics IN production SETTINGS max_concurrent_threads = 60, we CREATE WORKLOAD ingestion IN production ``` -此配置示例为管理员和生产提供独立的 CPU 槽位池。生产池在分析和摄取之间共享。此外,如果生产池超载,10 个释放的槽位中的 9 个将在必要时重新调度到分析查询中。摄取查询在超载期仅会获得 10 个槽位中的 1 个。这可能改善用户端查询的延迟。分析有其自己的 60 个并发线程限制,始终留出至少 40 个线程以支持摄取。当没有超载时,摄取可以使用所有 100 个线程。 +此配置示例为管理和生产提供独立的 CPU 插槽池。生产池在分析和摄取之间共享。此外,如果生产池超负荷,释放的 10 个插槽中将有 9 个转回分析查询(如果必要)。在超负荷期间,摄取查询将仅获得 10 个插槽中的 1 个。这可能改善用户可见查询的延迟。分析的并发线程限制为 60,始终留出至少 40 个线程以支持摄取。当没有超负荷时,摄取可以使用所有 100 个线程。 + +要排除查询的 CPU 调度,请将查询设置 [use_concurrency_control](/operations/settings/settings.md/#use_concurrency_control) 设置为 0。 + +目前尚不支持合并和变更的 CPU 调度。 + +为了为工作负载提供公平分配,需要在查询执行期间执行抢占和降级。当启用 `cpu_slot_preemption` 服务器设置时,启用抢占。如果启用,每个线程会定期更新其 CPU 插槽(根据 `cpu_slot_quantum_ns` 服务器设置)。这样的更新可能会在 CPU 超负荷时阻塞执行。当执行被阻塞长时间(请参见 `cpu_slot_preemption_timeout_ms` 服务器设置)时,查询会降级,并且并发运行的线程数量动态减少。注意,工作负载之间的 CPU 时间公平性得到保证,但在同一工作负载内的查询之间在某些特殊情况下可能会被违反。 + +:::warning +插槽调度提供了一种控制 [查询并发性](/operations/settings/settings.md#max_threads) 的方式,但在服务器设置 `cpu_slot_preemption` 设置为 `true` 时,才会保证公平的 CPU 时间分配;否则,公平性是根据竞争工作负载中的 CPU 插槽分配数量提供的。这并不意味着相等的 CPU 秒数,因为在没有抢占的情况下,CPU 插槽可能会无期限地被占用。线程在开始时获取插槽,完成工作时释放。 +::: + +:::note +声明 CPU 资源将禁用 [`concurrent_threads_soft_limit_num`](server-configuration-parameters/settings.md#concurrent_threads_soft_limit_num) 和 [`concurrent_threads_soft_limit_ratio_to_cores`](server-configuration-parameters/settings.md#concurrent_threads_soft_limit_ratio_to_cores) 设置的效果。相反,使用工作负载设置 `max_concurrent_threads` 来限制分配给特定工作负载的 CPU 数量。要实现以前的行为,请仅创建工作线程资源,将工作负载 `all` 的 `max_concurrent_threads` 设置为与 `concurrent_threads_soft_limit_num` 相同的值,并使用查询设置 `workload = "all"`。此配置对应于 [`concurrent_threads_scheduler`](server-configuration-parameters/settings.md#concurrent_threads_scheduler) 设置为 "fair_round_robin" 值。 +::: + +## 线程与 CPU {#threads_vs_cpus} -要将查询排除在 CPU 调度之外,请将查询设置 [use_concurrency_control](/operations/settings/settings.md/#use_concurrency_control) 设置为 0。 +有两种方法可以控制工作负载的 CPU 消耗: +* 线程数量限制:`max_concurrent_threads` 和 `max_concurrent_threads_ratio_to_cores` +* CPU 节流:`max_cpus`、`max_cpu_share` 和 `max_burst_cpu_seconds` -目前不支持合并和突变的 CPU 调度。 +第一种允许根据当前服务器负载动态控制查询生成的线程数量。它有效地降低了 `max_threads` 查询设置的要求。第二种使用令牌桶算法来节流工作负载的 CPU 消耗。它不会直接影响线程数量,但会节流工作负载中所有线程的总 CPU 消耗。 + +使用 `max_cpus` 和 `max_burst_cpu_seconds` 的令牌桶节流意味着以下内容。在任何 `delta` 秒的时间间隔内,工作负载中所有查询的总 CPU 消耗不得大于 `max_cpus * delta + max_burst_cpu_seconds` CPU 秒。这在长期内限制了平均消耗 `max_cpus`,但在短期内,可能会超过该限制。例如,给定 `max_burst_cpu_seconds = 60` 和 `max_cpus=0.001`,可以在没有节流的情况下运行 1 个线程 60 秒、2 个线程 30 秒或 60 个线程 1 秒。`max_burst_cpu_seconds` 的默认值为 1 秒。较低的值可能会导致在许多并发线程的情况下不能充分利用允许的 `max_cpus` 核心。 :::warning -槽位调度提供了一种控制 [查询并发性](/operations/settings/settings.md#max_threads) 的方法,但尚未保证公平的 CPU 时间分配。这需要进一步开发 CPU 槽位抢占,后续将进行支持。 +CPU 节流设置仅在启用 `cpu_slot_preemption` 服务器设置时有效,否则将被忽略。 +::: + +在占用 CPU 插槽时,线程可以处于以下三种主要状态之一: +* **运行中:** 实际消耗 CPU 资源。此状态所花费的时间计入 CPU 节流。 +* **准备中:** 等待 CPU 可用。未计入 CPU 节流。 +* **阻塞:** 执行 IO 操作或其他阻塞系统调用(例如,等待互斥锁)。未计入 CPU 节流。 + +让我们考虑一个结合了 CPU 节流和线程数量限制的配置示例: + +```sql +CREATE RESOURCE cpu (MASTER THREAD, WORKER THREAD) +CREATE WORKLOAD all SETTINGS max_concurrent_threads_ratio_to_cores = 2 +CREATE WORKLOAD admin IN all SETTINGS max_concurrent_threads = 2, priority = -1 +CREATE WORKLOAD production IN all SETTINGS weight = 4 +CREATE WORKLOAD analytics IN production SETTINGS max_cpu_share = 0.7, weight = 3 +CREATE WORKLOAD ingestion IN production +CREATE WORKLOAD development IN all SETTINGS max_cpu_share = 0.3 +``` + +在此示例中,我们限制所有查询的总线程数为可用 CPU 的 2 倍。管理工作负载最多限制为两个线程,无论可用 CPU 的数量如何。管理员的优先级为 -1(低于默认值 0),在需要时可以首先获得任何 CPU 插槽。当管理员未运行查询时,CPU 资源将在生产和开发工作负载之间分配。CPU 时间的保证份额基于权重(4:1):至少 80% 用于生产(如果需要),至少 20% 用于开发(如果需要)。权重形成保证,而 CPU 节流形成限制:生产没有限制,可以消耗 100%,而开发限制为 30%,即使没有来自其他工作负载的查询也会应用。当没有超负荷时,摄取可以使用所有 100 个线程。 + +:::note +如果您想最大化 ClickHouse 服务器上的 CPU 利用率,请避免对根工作负载 `all` 使用 `max_cpus` 和 `max_cpu_share`。相反,请将 `max_concurrent_threads` 设置为较高的值。例如,在具有 8 个 CPU 的系统上,将 `max_concurrent_threads = 16`。这允许 8 个线程运行 CPU 任务,而另 8 个线程可以处理 IO 操作。额外的线程将产生 CPU 压力,确保调度规则得到执行。相反,将 `max_cpus = 8` 将永远不会产生 CPU 压力,因为服务器无法超过 8 个可用的 CPU。 ::: +## 查询插槽调度 {#query_scheduling} + +要为工作负载启用查询插槽调度,请创建 QUERY 资源并设置并发查询或每秒查询数量的限制: + +```sql +CREATE RESOURCE query (QUERY) +CREATE WORKLOAD all SETTINGS max_concurrent_queries = 100, max_queries_per_second = 10, max_burst_queries = 20 +``` + +工作负载设置 `max_concurrent_queries` 限制在给定工作负载下同时可以运行的并发查询数量。这是查询 [`max_concurrent_queries_for_all_users`](/operations/settings/settings#max_concurrent_queries_for_all_users) 和服务器 [max_concurrent_queries](/operations/server-configuration-parameters/settings#max_concurrent_queries) 设置的模拟。异步插入查询和某些特定查询(如 KILL)不计入限制。 + +工作负载设置 `max_queries_per_second` 和 `max_burst_queries` 限制在工作负载中查询的数量,使用令牌桶节流。它保证在任何时间间隔 `T`内,最多有 `max_queries_per_second * T + max_burst_queries` 新查询将开始执行。 + +工作负载设置 `max_waiting_queries` 限制工作负载中等待查询的数量。当达到该限制时,服务器返回错误 `SERVER_OVERLOADED`。 + :::note -声明 CPU 资源会禁用 [`concurrent_threads_soft_limit_num`](server-configuration-parameters/settings.md#concurrent_threads_soft_limit_num) 和 [`concurrent_threads_soft_limit_ratio_to_cores`](server-configuration-parameters/settings.md#concurrent_threads_soft_limit_ratio_to_cores) 设置的效果。相反,使用工作负载设置 `max_concurrent_threads` 限制分配给特定工作负载的 CPU 数量。要实现先前的行为,仅创建 WORKER THREAD 资源,将工作负载 `all` 的 `max_concurrent_threads` 设置为与 `concurrent_threads_soft_limit_num` 相同的值,并使用 `workload = "all"` 查询设置。此配置对应于 [`concurrent_threads_scheduler`](server-configuration-parameters/settings.md#concurrent_threads_scheduler) 设置为 "fair_round_robin" 的值。 +被阻塞的查询将无限期等待,并且在所有约束满足之前不会出现在 `SHOW PROCESSLIST` 中。 ::: ## 工作负载和资源存储 {#workload_entity_storage} -所有工作负载和资源的定义以 `CREATE WORKLOAD` 和 `CREATE RESOURCE` 查询的形式持久存储在 `workload_path` 的磁盘上或在 ZooKeeper 的 `workload_zookeeper_path` 中。建议使用 ZooKeeper 存储以实现节点之间的一致性。或者,可以结合使用 `ON CLUSTER` 子句和磁盘存储。 + +所有工作负载和资源的定义以 `CREATE WORKLOAD` 和 `CREATE RESOURCE` 查询的形式持久存储在 `workload_path` 的磁盘上或在 ZooKeeper 的 `workload_zookeeper_path` 中。建议使用 ZooKeeper 存储以确保节点之间的一致性。或者可以结合使用 `ON CLUSTER` 子句和磁盘存储。 + +## 基于配置的工作负载和资源 {#config_based_workloads} + +除了基于 SQL 的定义外,工作负载和资源还可以在服务器配置文件中预定义。这在云环境中非常有用,因为某些限制是由基础设施决定的,而其他限制可以由客户修改。基于配置的实体优先于基于 SQL 的实体,且不能通过 SQL 命令进行修改或删除。 + +### 配置格式 {#config_based_workloads_format} + +```xml + + + RESOURCE s3disk_read (READ DISK s3); + RESOURCE s3disk_write (WRITE DISK s3); + WORKLOAD all SETTINGS max_io_requests = 500 FOR s3disk_read, max_io_requests = 1000 FOR s3disk_write, max_bytes_per_second = 1342177280 FOR s3disk_read, max_bytes_per_second = 3355443200 FOR s3disk_write; + WORKLOAD production IN all SETTINGS weight = 3; + + +``` + +该配置使用与 `CREATE WORKLOAD` 和 `CREATE RESOURCE` 语句相同的 SQL 语法。所有查询必须是有效的。 + +### 使用建议 {#config_based_workloads_usage_recommendations} + +对于云环境,典型的设置可能包括: + +1. 在配置中定义根工作负载和网络 IO 资源,以设置基础设施限制 +2. 将 `throw_on_unknown_workload` 设置为强制执行这些限制 +3. 创建 `CREATE WORKLOAD default IN all` 以自动将限制应用于所有查询(因为查询设置的默认值为 'default') +4. 允许用户在配置的层次结构中创建其他工作负载 + +这确保所有后台活动和查询遵守基础设施限制,同时仍允许为用户特定的调度策略提供灵活性。 + +另一种用例是在异构集群中为不同节点配置不同的配置。 ## 严格资源访问 {#strict_resource_access} -要强制所有查询遵循资源调度策略,有一个服务器设置 `throw_on_unknown_workload`。如果设置为 `true`,则每个查询都需要使用有效的 `workload` 查询设置,否则会抛出 `RESOURCE_ACCESS_DENIED` 异常。如果设置为 `false`,则此查询不使用资源调度器,即它将对任何 `RESOURCE` 获得无限制访问。 + +为了强制所有查询遵循资源调度策略,有一个服务器设置 `throw_on_unknown_workload`。如果它被设置为 `true`,则每个查询都需要使用有效的 `workload` 查询设置,否则将抛出 `RESOURCE_ACCESS_DENIED` 异常。如果设置为 `false`,则这样的查询不使用资源调度器,即会获得对任何 `RESOURCE` 的无限制访问。查询设置 'use_concurrency_control = 0' 允许查询避免 CPU 调度器并获得对 CPU 的无限制访问。要强制进行 CPU 调度,请创建设置约束,以使 'use_concurrency_control' 始终保持只读的常量值。 :::note -除非执行 `CREATE WORKLOAD default`,否则不要将 `throw_on_unknown_workload` 设置为 `true`。如果在启动期间执行未显式设置 `workload` 的查询,则可能导致服务器启动问题。 +除非执行了 `CREATE WORKLOAD default`,否则不要将 `throw_on_unknown_workload` 设置为 `true`。在启动期间执行没有显式设置 `workload` 的查询可能会导致服务器启动问题。 ::: -## 另请参见 {#see-also} - - [system.scheduler](/operations/system-tables/scheduler.md) - - [system.workloads](/operations/system-tables/workloads.md) - - [system.resources](/operations/system-tables/resources.md) - - [merge_workload](/operations/settings/merge-tree-settings.md#merge_workload) 合并树设置 - - [merge_workload](/operations/server-configuration-parameters/settings.md#merge_workload) 全局服务器设置 - - [mutation_workload](/operations/settings/merge-tree-settings.md#mutation_workload) 合并树设置 - - [mutation_workload](/operations/server-configuration-parameters/settings.md#mutation_workload) 全局服务器设置 - - [workload_path](/operations/server-configuration-parameters/settings.md#workload_path) 全局服务器设置 - - [workload_zookeeper_path](/operations/server-configuration-parameters/settings.md#workload_zookeeper_path) 全局服务器设置 +## 参见 {#see-also} +- [system.scheduler](/operations/system-tables/scheduler.md) +- [system.workloads](/operations/system-tables/workloads.md) +- [system.resources](/operations/system-tables/resources.md) +- [merge_workload](/operations/settings/merge-tree-settings.md#merge_workload) 合并树设置 +- [merge_workload](/operations/server-configuration-parameters/settings.md#merge_workload) 全局服务器设置 +- [mutation_workload](/operations/settings/merge-tree-settings.md#mutation_workload) 合并树设置 +- [mutation_workload](/operations/server-configuration-parameters/settings.md#mutation_workload) 全局服务器设置 +- [workload_path](/operations/server-configuration-parameters/settings.md#workload_path) 全局服务器设置 +- [workload_zookeeper_path](/operations/server-configuration-parameters/settings.md#workload_zookeeper_path) 全局服务器设置 +- [cpu_slot_preemption](/operations/server-configuration-parameters/settings.md#cpu_slot_preemption) 全局服务器设置 +- [cpu_slot_quantum_ns](/operations/server-configuration-parameters/settings.md#cpu_slot_quantum_ns) 全局服务器设置 +- [cpu_slot_preemption_timeout_ms](/operations/server-configuration-parameters/settings.md#cpu_slot_preemption_timeout_ms) 全局服务器设置 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/operations/workload-scheduling.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/operations/workload-scheduling.md.hash index edf9fa7ab96..442d9dcc2c4 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/operations/workload-scheduling.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/operations/workload-scheduling.md.hash @@ -1 +1 @@ -94819308b2d0eab2 +237c1a4f7117dafb diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/quick-start.mdx.hash b/i18n/zh/docusaurus-plugin-content-docs/current/quick-start.mdx.hash deleted file mode 100644 index 6db0457b5a0..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/quick-start.mdx.hash +++ /dev/null @@ -1 +0,0 @@ -225511c6f117b656 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/combinators.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/combinators.md index 368255c71b1..baf0cbea456 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/combinators.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/combinators.md @@ -1,37 +1,38 @@ --- -'description': '聚合函数组合器的Documentation' +'description': '聚合函数组合器的文档' 'sidebar_label': '组合器' 'sidebar_position': 37 'slug': '/sql-reference/aggregate-functions/combinators' 'title': '聚合函数组合器' +'doc_type': 'reference' --- # 聚合函数组合器 -聚合函数的名称可以附加一个后缀。这改变了聚合函数的工作方式。 +聚合函数的名称可以添加后缀。这样可以改变聚合函数的工作方式。 ## -If {#-if} -后缀 -If 可以附加到任何聚合函数的名称上。在这种情况下,聚合函数接受一个额外的参数——条件(Uint8 类型)。聚合函数仅处理触发条件的行。如果条件没有被触发一次,它将返回一个默认值(通常是零或空字符串)。 +后缀 -If 可以添加到任何聚合函数的名称上。在这种情况下,聚合函数接受一个额外参数——条件(Uint8 类型)。聚合函数仅处理触发条件的行。如果条件一次都未被触发,则返回默认值(通常为零或空字符串)。 -示例: `sumIf(column, cond)`、`countIf(cond)`、`avgIf(x, cond)`、`quantilesTimingIf(level1, level2)(x, cond)`、`argMinIf(arg, val, cond)` 等等。 +示例: `sumIf(column, cond)`,`countIf(cond)`,`avgIf(x, cond)`,`quantilesTimingIf(level1, level2)(x, cond)`,`argMinIf(arg, val, cond)` 等等。 -使用条件聚合函数,您可以不使用子查询和 `JOIN` 同时计算多个条件的聚合。例如,条件聚合函数可用于实现分段比较功能。 +使用条件聚合函数,您可以一并计算多个条件的聚合,而无需使用子查询和 `JOIN`。例如,条件聚合函数可用于实现分段比较功能。 ## -Array {#-array} -后缀 -Array 可以附加到任何聚合函数上。在这种情况下,聚合函数接受 'Array(T)' 类型(数组)作为参数,而不是 'T' 类型的参数。如果聚合函数接受多个参数,这些参数必须是相同长度的数组。在处理数组时,聚合函数会对所有数组元素进行像原始聚合函数一样的操作。 +后缀 -Array 可以添加到任何聚合函数上。在这种情况下,聚合函数接受 'Array(T)' 类型(数组)的参数,而不是 'T' 类型的参数。如果聚合函数接受多个参数,这些参数必须是等长的数组。在处理数组时,聚合函数的工作方式与原始聚合函数在所有数组元素上的工作方式相同。 -示例 1:`sumArray(arr)` - 对所有 'arr' 数组的所有元素进行求和。在这个例子中,可以更简单地写为:`sum(arraySum(arr))`。 +示例 1: `sumArray(arr)` - 对所有 'arr' 数组的所有元素求和。在这个例子中,更简单的写法是:`sum(arraySum(arr))`。 -示例 2:`uniqArray(arr)` – 计算所有 'arr' 数组中唯一元素的数量。这可以通过更简单的方式完成:`uniq(arrayJoin(arr))`,但并不总是可以将 'arrayJoin' 添加到查询中。 +示例 2: `uniqArray(arr)` – 计算所有 'arr' 数组中唯一元素的数量。这可以通过更简单的方式完成:`uniq(arrayJoin(arr))`,但并非总是可以将 'arrayJoin' 添加到查询中。 --If 和 -Array 可以组合使用。然而,'Array' 必须放在前面,然后是 'If'。示例:`uniqArrayIf(arr, cond)`、`quantilesTimingArrayIf(level1, level2)(arr, cond)`。由于这个顺序,'cond' 参数不会是一个数组。 +-If 和 -Array 可以结合使用。但是,'Array' 必须在前,然后是 'If'。示例: `uniqArrayIf(arr, cond)`,`quantilesTimingArrayIf(level1, level2)(arr, cond)`。由于这种顺序,'cond' 参数不会是数组。 ## -Map {#-map} -后缀 -Map 可以附加到任何聚合函数上。这会创建一个聚合函数,它将 Map 类型作为参数,并使用指定的聚合函数分别聚合映射中每个键的值。结果也为 Map 类型。 +后缀 -Map 可以添加到任何聚合函数上。这将创建一个聚合函数,该函数将 Map 类型作为参数,并使用指定的聚合函数单独聚合映射的每个键的值。结果也是 Map 类型。 **示例** @@ -64,7 +65,7 @@ GROUP BY timeslot; ## -SimpleState {#-simplestate} -如果您应用此组合器,聚合函数将返回相同的值,但类型不同。这是一个 [SimpleAggregateFunction(...)](../../sql-reference/data-types/simpleaggregatefunction.md),可以存储在表中以与 [AggregatingMergeTree](../../engines/table-engines/mergetree-family/aggregatingmergetree.md) 表一起工作。 +如果您应用此组合器,聚合函数将返回相同的值,但类型不同。这是一个 [SimpleAggregateFunction(...)](../../sql-reference/data-types/simpleaggregatefunction.md),可以存储在表中以与 [AggregatingMergeTree](../../engines/table-engines/mergetree-family/aggregatingmergetree.md) 表一起使用。 **语法** @@ -78,7 +79,7 @@ GROUP BY timeslot; **返回值** -聚合函数的值,其类型为 `SimpleAggregateFunction(...)`。 +聚合函数的 `SimpleAggregateFunction(...)` 类型值。 **示例** @@ -98,10 +99,10 @@ WITH anySimpleState(number) AS c SELECT toTypeName(c), c FROM numbers(1); ## -State {#-state} -如果您应用此组合器,聚合函数不会返回最终值(例如 [uniq](/sql-reference/aggregate-functions/reference/uniq) 函数的唯一值数量),而是返回聚合的中间状态(对于 `uniq`,这是用于计算唯一值数量的哈希表)。这是一个 `AggregateFunction(...)`,可以用于进一步处理或存储在表中以便稍后完成聚合。 +如果您应用此组合器,聚合函数不会返回结果值(例如, [uniq](/sql-reference/aggregate-functions/reference/uniq) 函数的唯一值数量),而返回聚合的中间状态(对于 `uniq` 来说,这是用于计算唯一值数量的哈希表)。这是一个 `AggregateFunction(...)`,可用于进一步处理或存储在表中以便稍后完成聚合。 :::note -请注意,-MapState 不是对相同数据的不变,因为中间状态中数据的顺序可能会改变,尽管这不会影响该数据的摄取。 +请注意,由于中间状态中数据顺序可能改变,因此 -MapState 对于相同数据并非不变,但这不会影响此数据的摄取。 ::: 要处理这些状态,使用: @@ -114,26 +115,26 @@ WITH anySimpleState(number) AS c SELECT toTypeName(c), c FROM numbers(1); ## -Merge {#-merge} -如果您应用此组合器,聚合函数将中间聚合状态作为参数,合并状态以完成聚合,并返回结果值。 +如果您应用此组合器,聚合函数将中间聚合状态作为参数,结合这些状态以完成聚合,并返回结果值。 ## -MergeState {#-mergestate} -以与 -Merge 组合器相同的方式合并中间聚合状态。然而,它不返回结果值,而是一个中间聚合状态,类似于 -State 组合器。 +以与 -Merge 组合器相同的方式合并中间聚合状态。但是,它不返回结果值,而是中间聚合状态,类似于 -State 组合器。 ## -ForEach {#-foreach} -将表的聚合函数转换为数组的聚合函数,聚合对应的数组项并返回结果数组。例如,对数组 `[1, 2]`、`[3, 4, 5]` 和 `[6, 7]` 的 `sumForEach` 在将相应的数组项相加后返回结果 `[10, 13, 5]`。 +将表的聚合函数转换为数组的聚合函数,聚合相应的数组项并返回结果数组。例如,`sumForEach` 对于数组 `[1, 2]`,`[3, 4, 5]` 和 `[6, 7]`,经过相加后返回结果 `[10, 13, 5]`。 ## -Distinct {#-distinct} -每个唯一参数组合只会聚合一次。重复的值会被忽略。 -示例: `sum(DISTINCT x)`(或 `sumDistinct(x)`)、`groupArray(DISTINCT x)`(或 `groupArrayDistinct(x)`)、`corrStable(DISTINCT x, y)`(或 `corrStableDistinct(x, y)`)等。 +每个唯一的参数组合仅聚合一次。重复的值会被忽略。 +示例: `sum(DISTINCT x)`(或 `sumDistinct(x)`),`groupArray(DISTINCT x)`(或 `groupArrayDistinct(x)`),`corrStable(DISTINCT x, y)`(或 `corrStableDistinct(x, y)`)等。 ## -OrDefault {#-ordefault} -改变聚合函数的行为。 +更改聚合函数的行为。 -如果聚合函数没有输入值,使用此组合器它将返回其返回数据类型的默认值。适用于可以接受空输入数据的聚合函数。 +如果聚合函数没有输入值,使用此组合器将返回其返回数据类型的默认值。适用于可以接受空输入数据的聚合函数。 `-OrDefault` 可以与其他组合器一起使用。 @@ -149,9 +150,9 @@ WITH anySimpleState(number) AS c SELECT toTypeName(c), c FROM numbers(1); **返回值** -如果没有任何内容可聚合,则返回聚合函数返回类型的默认值。 +如果没有要聚合的内容,则返回聚合函数返回类型的默认值。 -类型取决于使用的聚合函数。 +类型取决于所用的聚合函数。 **示例** @@ -169,7 +170,7 @@ SELECT avg(number), avgOrDefault(number) FROM numbers(0) └─────────────┴──────────────────────┘ ``` -同时 `-OrDefault` 也可以与其他组合器结合使用。当聚合函数不接受空输入时,它是有用的。 +此外,`-OrDefault` 还可以与其他组合器一起使用。当聚合函数不接受空输入时非常有用。 查询: @@ -191,9 +192,9 @@ FROM ## -OrNull {#-ornull} -改变聚合函数的行为。 +更改聚合函数的行为。 -此组合器将聚合函数的结果转换为 [Nullable](../../sql-reference/data-types/nullable.md) 数据类型。如果聚合函数没有值可计算,则返回 [NULL](/operations/settings/formats#input_format_null_as_default)。 +此组合器将聚合函数的结果转换为 [Nullable](../../sql-reference/data-types/nullable.md) 数据类型。如果聚合函数没有可计算的值,它将返回 [NULL](/operations/settings/formats#input_format_null_as_default)。 `-OrNull` 可以与其他组合器一起使用。 @@ -210,9 +211,9 @@ FROM **返回值** - 聚合函数的结果,转换为 `Nullable` 数据类型。 -- `NULL`,如果没有任何内容可聚合。 +- 如果没有要聚合的内容,则返回 `NULL`。 -类型: `Nullable(聚合函数返回类型)`。 +类型: `Nullable(aggregate function return type)`。 **示例** @@ -232,7 +233,7 @@ SELECT sumOrNull(number), toTypeName(sumOrNull(number)) FROM numbers(10) WHERE n └───────────────────┴───────────────────────────────┘ ``` -同时 `-OrNull` 也可以与其他组合器结合使用。当聚合函数不接受空输入时,它是有用的。 +此外,`-OrNull` 还可以与其他组合器一起使用。当聚合函数不接受空输入时非常有用。 查询: @@ -254,7 +255,7 @@ FROM ## -Resample {#-resample} -允许您将数据分为多个组,然后分别聚合这些组中的数据。组是通过将一列的值分割成区间来创建的。 +允许您将数据分组,然后分别对这些组中的数据进行聚合。通过将一列中的值划分为区间来创建组。 ```sql Resample(start, end, step)(, resampling_key) @@ -262,10 +263,10 @@ FROM **参数** -- `start` — `resampling_key` 值所需区间的起始值。 -- `stop` — `resampling_key` 值所需区间的结束值。整个区间不包括 `stop` 值 `[start, stop)`。 -- `step` — 将整个区间分成子区间的步长。 `aggFunction` 在每个子区间内独立执行。 -- `resampling_key` — 用于将数据分隔成区间的列。 +- `start` — `resampling_key` 值的整个所需区间的起始值。 +- `stop` — `resampling_key` 值的整个所需区间的结束值。整个区间不包括 `stop` 值 `[start, stop)`。 +- `step` — 将整个区间分隔为子区间的步长。`aggFunction` 在每个子区间独立执行。 +- `resampling_key` — 用于将数据分隔为区间的列。 - `aggFunction_params` — `aggFunction` 参数。 **返回值** @@ -287,9 +288,9 @@ FROM └────────┴─────┴──────┘ ``` -让我们获取年龄在 `[30,60)` 和 `[60,75)` 区间内的人的姓名。由于我们使用整数表示年龄,我们将在 `[30, 59]` 和 `[60,74]` 区间内获取年龄。 +让我们获取年龄在 `[30,60)` 和 `[60,75)` 区间内的人的名字。由于我们使用整数表示年龄,因此我们得到的年龄在 `[30, 59]` 和 `[60,74]` 区间内。 -要在数组中聚合姓名,我们使用 [groupArray](/sql-reference/aggregate-functions/reference/grouparray) 聚合函数。它只接受一个参数。在我们的例子中,它是 `name` 列。`groupArrayResample` 函数应使用 `age` 列按照年龄聚合姓名。为了定义所需的区间,我们将 `30, 75, 30` 参数传入 `groupArrayResample` 函数。 +为了以数组聚合名字,我们使用 [groupArray](/sql-reference/aggregate-functions/reference/grouparray) 聚合函数。它接受一个参数。在我们的例子中,它是 `name` 列。`groupArrayResample` 函数应使用 `age` 列按年龄聚合名字。为了定义所需区间,我们将 `30, 75, 30` 参数传递给 `groupArrayResample` 函数。 ```sql SELECT groupArrayResample(30, 75, 30)(name, age) FROM people @@ -303,9 +304,9 @@ SELECT groupArrayResample(30, 75, 30)(name, age) FROM people 考虑结果。 -`John` 不在样本中,因为他太年轻。其他人根据指定的年龄区间被分配。 +`John` 不在样本中,因为他太年轻。其他人根据指定的年龄区间分布。 -现在让我们计算指定年龄区间内的总人数和他们的平均工资。 +现在让我们统计指定年龄区间内的总人数和他们的平均薪水。 ```sql SELECT @@ -322,9 +323,9 @@ FROM people ## -ArgMin {#-argmin} -后缀 -ArgMin 可以附加到任何聚合函数的名称上。在这种情况下,聚合函数接受一个附加参数,应该是任何可比较的表达式。聚合函数仅处理具有指定额外表达式最小值的行。 +后缀 -ArgMin 可以添加到任何聚合函数的名称上。在这种情况下,聚合函数接受一个额外参数,该参数应该是任何可比较的表达式。聚合函数仅处理具有指定额外表达式最小值的行。 -示例: `sumArgMin(column, expr)`、`countArgMin(expr)`、`avgArgMin(x, expr)` 等等。 +示例: `sumArgMin(column, expr)`,`countArgMin(expr)`,`avgArgMin(x, expr)` 等等。 ## -ArgMax {#-argmax} diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/combinators.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/combinators.md.hash index 4595e95ec60..edb3617454e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/combinators.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/combinators.md.hash @@ -1 +1 @@ -769f566591bae304 +4659bf7b736d945a diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/grouping_function.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/grouping_function.md index ef83d45366e..d504bc9690a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/grouping_function.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/grouping_function.md @@ -1,27 +1,28 @@ --- 'description': 'GROUPING 聚合函数的文档。' 'slug': '/sql-reference/aggregate-functions/grouping_function' -'title': '分组' +'title': 'GROUPING' +'doc_type': 'reference' --- -# GROUPING +# 分组 ## GROUPING {#grouping} -[ROLLUP](../statements/select/group-by.md/#rollup-modifier) 和 [CUBE](../statements/select/group-by.md/#cube-modifier) 是 GROUP BY 的修饰符。这两者都会计算小计。ROLLUP 接受一个有序的列列表,例如 `(day, month, year)`,并在每个聚合级别计算小计,然后计算总计。CUBE 计算指定列的所有可能组合的小计。GROUPING 用于识别 ROLLUP 或 CUBE 返回的哪些行是超聚合,并指明哪些是未修改的 GROUP BY 将返回的行。 +[ROLLUP](../statements/select/group-by.md/#rollup-modifier) 和 [CUBE](../statements/select/group-by.md/#cube-modifier) 是对 GROUP BY 的修饰符。这两者都计算小计。ROLLUP 采用有序的列列表,例如 `(day, month, year)`,并在每个聚合级别计算小计,然后计算总计。CUBE 跨所有可能的列组合计算小计。GROUPING 确定 ROLLUP 或 CUBE 返回的哪些行是超级聚合,以及哪些是未修改的 GROUP BY 将返回的行。 GROUPING 函数接受多个列作为参数,并返回一个位掩码。 -- `1` 表示由 `ROLLUP` 或 `CUBE` 修饰的 `GROUP BY` 返回的行是小计。 -- `0` 表示由 `ROLLUP` 或 `CUBE` 返回的行不是小计。 +- `1` 表示由 `ROLLUP` 或 `CUBE` 修饰的 `GROUP BY` 返回的行是小计 +- `0` 表示由 `ROLLUP` 或 `CUBE` 返回的行不是小计 ## GROUPING SETS {#grouping-sets} -默认情况下,CUBE 修饰符为传递给 CUBE 的所有可能列组合计算小计。GROUPING SETS 允许您指定要计算的特定组合。 +默认情况下,CUBE 修饰符计算传递给 CUBE 的所有可能列组合的小计。GROUPING SETS 允许您指定要计算的特定组合。 -分析层次数据是使用 ROLLUP、CUBE 和 GROUPING SETS 修饰符的一个好用例。这里的示例是一个包含有关两个数据中心中安装的 Linux 发行版及其版本的数据表。按发行版、版本和位置查看数据可能是有价值的。 +分析层次数据是使用 ROLLUP、CUBE 和 GROUPING SETS 修饰符的一个良好用例。这里的示例是一个表,包含有关在两个数据中心中安装了什么 Linux 发行版及其版本的数据。按发行版、版本和位置查看数据可能是有价值的。 -### Load sample data {#load-sample-data} +### 加载示例数据 {#load-sample-data} ```sql CREATE TABLE servers ( datacenter VARCHAR(255), @@ -69,9 +70,9 @@ FROM 10 rows in set. Elapsed: 0.409 sec. ``` -### Simple queries {#simple-queries} +### 简单查询 {#simple-queries} -按发行版获取每个数据中心的服务器数量: +按发行版获取每个数据中心的服务器计数: ```sql SELECT datacenter, @@ -146,9 +147,9 @@ FROM 1 row in set. Elapsed: 0.244 sec. ``` -### Comparing multiple GROUP BY statements with GROUPING SETS {#comparing-multiple-group-by-statements-with-grouping-sets} +### 比较多个 GROUP BY 语句与 GROUPING SETS {#comparing-multiple-group-by-statements-with-grouping-sets} -在没有 CUBE、ROLLUP 或 GROUPING SETS 的情况下细分数据: +没有 CUBE、ROLLUP 或 GROUPING SETS 的数据细分: ```sql SELECT datacenter, @@ -207,7 +208,7 @@ FROM 9 rows in set. Elapsed: 0.527 sec. ``` -使用 GROUPING SETS 获取相同信息: +使用 GROUPING SETS 获取相同的信息: ```sql SELECT datacenter, @@ -245,9 +246,9 @@ GROUP BY 9 rows in set. Elapsed: 0.427 sec. ``` -### Comparing CUBE with GROUPING SETS {#comparing-cube-with-grouping-sets} +### 比较 CUBE 和 GROUPING SETS {#comparing-cube-with-grouping-sets} -下一个查询中的 CUBE,`CUBE(datacenter,distro,version)` 提供了一个可能不合理的层次结构。在两个发行版之间查看版本是没有意义的(因为 Arch 和 RHEL 没有相同的发布周期或版本命名标准)。下面的 GROUPING SETS 示例更为合适,因为它将 `distro` 和 `version` 分组在同一集合中。 +下一个查询中的 CUBE `CUBE(datacenter,distro,version)` 提供的层次结构可能没有意义。将版本在两个发行版之间进行比较没有意义(因为 Arch 和 RHEL 的版本发布时间和命名标准不同)。接下来的 GROUPING SETS 示例更合适,因为它将 `distro` 和 `version` 组合在同一集合中。 ```sql SELECT @@ -309,7 +310,7 @@ ORDER BY 39 rows in set. Elapsed: 0.355 sec. ``` :::note -上述示例中的版本在未关联到发行版时可能没有意义,如果我们跟踪的是内核版本,那可能是合理的,因为内核版本可以与任一发行版相关联。使用 GROUPING SETS,如下一个示例,可能是更好的选择。 +上述示例中的版本在未与发行版关联时可能没有意义,如果我们跟踪内核版本,可能就有意义,因为内核版本可以与任意发行版关联。使用 GROUPING SETS,如下一个示例中,可能是更好的选择。 ::: ```sql diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/grouping_function.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/grouping_function.md.hash index f6f4230a64b..1da7be86c99 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/grouping_function.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/grouping_function.md.hash @@ -1 +1 @@ -24b9849c85be09e4 +e573bd7a7b96f852 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/index.md index a0a473238f9..d2059b86303 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/index.md @@ -1,28 +1,29 @@ --- -'description': 'Aggregate Functions 的文档' +'description': '聚合函数的文档' 'sidebar_label': '聚合函数' 'sidebar_position': 33 'slug': '/sql-reference/aggregate-functions/' 'title': '聚合函数' +'doc_type': 'reference' --- # 聚合函数 -聚合函数的工作方式与数据库专家所期望的 [正常](http://www.sql-tutorial.com/sql-aggregate-functions-sql-tutorial) 方式一致。 +聚合函数按照数据库专家预期的 [正常](http://www.sql-tutorial.com/sql-aggregate-functions-sql-tutorial) 方式工作。 ClickHouse 还支持: -- [参数化聚合函数](/sql-reference/aggregate-functions/parametric-functions),除了列之外还接受其他参数。 -- [组合器](/sql-reference/aggregate-functions/combinators),可改变聚合函数的行为。 +- [参数化聚合函数](/sql-reference/aggregate-functions/parametric-functions),除了列之外接受其他参数。 +- [组合子](/sql-reference/aggregate-functions/combinators),改变聚合函数的行为。 ## NULL 处理 {#null-processing} -在聚合过程中,所有 `NULL` 参数都会被跳过。如果聚合有多个参数,它将忽略任何一行中有一个或多个参数为 NULL 的情况。 +在聚合过程中,所有 `NULL` 参数会被跳过。如果聚合有多个参数,它将忽略任何一个或多个参数为 NULL 的行。 -这个规则有一个例外,即 [`first_value`](../../sql-reference/aggregate-functions/reference/first_value.md)、[`last_value`](../../sql-reference/aggregate-functions/reference/last_value.md) 函数及其别名(分别为 `any` 和 `anyLast`)在跟随修饰符 `RESPECT NULLS` 时。比如,`FIRST_VALUE(b) RESPECT NULLS`。 +这个规则有一个例外,即函数 [`first_value`](../../sql-reference/aggregate-functions/reference/first_value.md)、[`last_value`](../../sql-reference/aggregate-functions/reference/last_value.md) 及其别名(分别为 `any` 和 `anyLast`)在后跟修饰符 `RESPECT NULLS` 的情况下。例如,`FIRST_VALUE(b) RESPECT NULLS`。 -**例子:** +**示例:** 考虑这个表: @@ -36,7 +37,7 @@ ClickHouse 还支持: └───┴──────┘ ``` -假设你需要对 `y` 列中的值进行求和: +假设你需要对 `y` 列的值进行求和: ```sql SELECT sum(y) FROM t_null_big @@ -60,9 +61,9 @@ SELECT groupArray(y) FROM t_null_big └───────────────┘ ``` -`groupArray` 不会在结果数组中包含 `NULL`。 +`groupArray` 不会将 `NULL` 包含在结果数组中。 -你可以使用 [COALESCE](../../sql-reference/functions/functions-for-nulls.md#coalesce) 将 NULL 转换为对你的用例有意义的值。例如:`avg(COALESCE(column, 0))` 将在聚合中使用列值,或者在值为 NULL 时使用零: +你可以使用 [COALESCE](../../sql-reference/functions/functions-for-nulls.md#coalesce) 将 NULL 改成在你的用例中有意义的值。例如:`avg(COALESCE(column, 0))` 将在聚合中使用列的值,或者在 NULL 的情况下使用零: ```sql SELECT @@ -77,7 +78,7 @@ FROM t_null_big └────────────────────┴─────────────────────┘ ``` -同时你可以使用 [Tuple](sql-reference/data-types/tuple.md) 来绕过 NULL 跳过行为。一个只包含 `NULL` 值的 `Tuple` 不是 `NULL`,因此聚合函数不会因为该 `NULL` 值而跳过那一行。 +你也可以使用 [Tuple](sql-reference/data-types/tuple.md) 来绕过 NULL 跳过的行为。包含唯一 `NULL` 值的 `Tuple` 并不为 `NULL`,因此聚合函数不会因为该 `NULL` 值而跳过该行。 ```sql SELECT @@ -90,7 +91,7 @@ FROM t_null_big; └───────────────┴───────────────────────────────────────┘ ``` -请注意,当列作为聚合函数的参数使用时,聚合会被跳过。例如,没有参数的 [`count`](../../sql-reference/aggregate-functions/reference/count.md) (`count()`) 或常量参数的 (`count(1)`) 将计算块中的所有行(无论 GROUP BY 列的值,因为它不是一个参数),而 `count(column)` 只会返回列不为 NULL 的行数。 +请注意,当列用作聚合函数的参数时,聚合将被跳过。例如,`count`(没有参数 `count()`)或使用常量(`count(1)`)会计算块中的所有行(与 GROUP BY 列的值无关,因为它不是参数),而 `count(column)` 将只返回列不为 NULL 的行数。 ```sql SELECT @@ -112,19 +113,19 @@ GROUP BY v └──────┴─────────┴──────────┘ ``` -这里是一个使用 `RESPECT NULLS` 的 first_value 示例,我们可以看到 NULL 输入被尊重,并且会返回读取到的第一个值,无论它是否为 NULL: +这里是一个使用 `RESPECT NULLS` 的 `first_value` 示例,我们可以看到 NULL 输入被尊重,它将返回读取的第一个值,无论它是否为 NULL: ```sql SELECT - col || '_' || ((col + 1) * 5 - 1) as range, - first_value(odd_or_null) as first, + col || '_' || ((col + 1) * 5 - 1) AS range, + first_value(odd_or_null) AS first, first_value(odd_or_null) IGNORE NULLS as first_ignore_null, first_value(odd_or_null) RESPECT NULLS as first_respect_nulls FROM ( SELECT intDiv(number, 5) AS col, - if(number % 2 == 0, NULL, number) as odd_or_null + if(number % 2 == 0, NULL, number) AS odd_or_null FROM numbers(15) ) GROUP BY col diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/index.md.hash index 1a0793044ba..72dda6beeb5 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/index.md.hash @@ -1 +1 @@ -36fb9d2d4e2e7f94 +5acf5107c7d4638e diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/parametric-functions.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/parametric-functions.md index 4d1beb32f95..1f37fb7ac75 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/parametric-functions.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/parametric-functions.md @@ -1,15 +1,16 @@ --- -'description': '针对 Parametric Aggregate Functions 的文档' +'description': '关于 Parametric Aggregate Functions 的文档' 'sidebar_label': 'Parametric' 'sidebar_position': 38 'slug': '/sql-reference/aggregate-functions/parametric-functions' 'title': '参数聚合函数' +'doc_type': 'reference' --- # 参数化聚合函数 -某些聚合函数不仅可以接受用于压缩的参数列,还可以接受一组参数 - 初始化的常量。语法使用两个括号对而不是一个。第一个用于参数,第二个用于参数列。 +某些聚合函数不仅可以接受参数列(用于压缩),还可以接受一组参数 - 用于初始化的常量。语法是使用两个括号对而不是一个。第一个用于参数,第二个用于论据。 ## histogram {#histogram} @@ -19,27 +20,27 @@ histogram(number_of_bins)(values) ``` -该函数使用 [A Streaming Parallel Decision Tree Algorithm](http://jmlr.org/papers/volume11/ben-haim10a/ben-haim10a.pdf)。直方图箱的边界随着新数据进入函数而调整。在常见情况下,箱的宽度是不相等的。 +该函数使用[A Streaming Parallel Decision Tree Algorithm](http://jmlr.org/papers/volume11/ben-haim10a/ben-haim10a.pdf)。随着新数据进入函数,直方图桶的边界会调整。在一般情况下,桶的宽度并不相等。 **参数** -`values` — [表达式](/sql-reference/syntax#expressions) 结果为输入值。 +`values` — [表达式](/sql-reference/syntax#expressions),结果为输入值。 **参数** -`number_of_bins` — 直方图中箱的数量的上限。该函数自动计算箱的数量。它尝试达到指定的箱数量,但如果失败,它将使用更少的箱。 +`number_of_bins` — 直方图中桶的数量的上限。该函数会自动计算桶的数量。它试图达到指定的桶数,但如果失败,将使用更少的桶。 **返回值** -- [数组](../../sql-reference/data-types/array.md) 的 [元组](../../sql-reference/data-types/tuple.md),格式如下: +- [数组](../../sql-reference/data-types/array.md)的[元组](../../sql-reference/data-types/tuple.md),格式如下: ``` [(lower_1, upper_1, height_1), ... (lower_N, upper_N, height_N)] ``` - - `lower` — 箱的下界。 - - `upper` — 箱的上界。 - - `height` — 箱的计算高度。 + - `lower` — 桶的下限。 + - `upper` — 桶的上限。 + - `height` — 桶的计算高度。 **示例** @@ -58,7 +59,7 @@ FROM ( └─────────────────────────────────────────────────────────────────────────┘ ``` -您可以使用 [bar](/sql-reference/functions/other-functions#bar) 函数可视化直方图,例如: +您可以使用[bar](/sql-reference/functions/other-functions#bar)函数来可视化直方图,例如: ```sql WITH histogram(5)(rand() % 100) AS hist @@ -83,11 +84,11 @@ FROM └────────┴───────┘ ``` -在这种情况下,您应该记住您不知道直方图箱的边界。 +在这种情况下,您应记住,不知道直方图桶的边界。 ## sequenceMatch {#sequencematch} -检查序列是否包含与模式匹配的事件链。 +检查序列中是否包含与模式匹配的事件链。 **语法** @@ -96,37 +97,37 @@ sequenceMatch(pattern)(timestamp, cond1, cond2, ...) ``` :::note -同时发生在同一秒钟的事件可能会以未定义的顺序出现在序列中,从而影响结果。 +同一秒钟发生的事件可能在序列中以未定义顺序排列,从而影响结果。 ::: **参数** -- `timestamp` — 被认为包含时间数据的列。典型的数据类型是 `Date` 和 `DateTime`。您还可以使用任何支持的 [UInt](../../sql-reference/data-types/int-uint.md) 数据类型。 +- `timestamp` — 被认为包含时间数据的列。典型数据类型为`Date`和`DateTime`。您还可以使用任何支持的[UInt](../../sql-reference/data-types/int-uint.md)数据类型。 -- `cond1`, `cond2` — 描述事件链的条件。数据类型:`UInt8`。您可以传递最多 32 个条件参数。该函数仅考虑在这些条件中描述的事件。如果序列包含未在条件中描述的数据,则该函数会跳过它们。 +- `cond1`, `cond2` — 描述事件链的条件。数据类型:`UInt8`。您最多可以传递32个条件参数。函数仅考虑这些条件中描述的事件。如果序列包含未在条件中描述的数据,函数会跳过它们。 **参数** -- `pattern` — 模式字符串。请参见 [模式语法](#pattern-syntax)。 +- `pattern` — 模式字符串。请参见[模式语法](#pattern-syntax)。 **返回值** -- 如果模式匹配,则返回 1。 -- 如果模式不匹配,则返回 0。 +- 1,如果模式匹配。 +- 0,如果模式不匹配。 类型:`UInt8`。 #### 模式语法 {#pattern-syntax} -- `(?N)` — 匹配位置为 `N` 的条件参数。条件编号在 `[1, 32]` 范围内。例如,`(?1)` 匹配传递给 `cond1` 参数的参数。 +- `(?N)` — 匹配位置为`N`的条件参数。条件编号在`[1, 32]`范围内。例如,`(?1)`匹配传递给`cond1`参数的论据。 -- `.*` — 匹配任意数量的事件。您无需条件参数来匹配模式的这一元素。 +- `.*` — 匹配任意数量的事件。您不需要条件参数来匹配模式的这个元素。 -- `(?t operator value)` — 设置应分隔两个事件的秒数。例如,模式 `(?1)(?t>1800)(?2)` 匹配在 1800 秒以上发生的事件。任意数量的事件可以位于这两个事件之间。您可以使用 `>=`,`>`,`<`,`<=`,`==` 运算符。 +- `(?t operator value)` — 设置两个事件之间应分开的秒数。例如,模式`(?1)(?t>1800)(?2)`匹配发生在相隔超过1800秒的事件。这两个事件之间可以有任意数量的其他事件。您可以使用`>=`、`>`、`<`、`<=`、`==`运算符。 **示例** -考虑 `t` 表中的数据: +考虑`t`表中的数据: ```text ┌─time─┬─number─┐ @@ -148,7 +149,7 @@ SELECT sequenceMatch('(?1)(?2)')(time, number = 1, number = 2) FROM t └───────────────────────────────────────────────────────────────────────┘ ``` -该函数找到编号 2 紧跟编号 1 的事件链。它跳过了它们之间的编号 3,因为该编号未被描述为事件。如果我们想在搜索示例中给定的事件链时考虑这个编号,我们应该为它建立一个条件。 +该函数找到事件链,其中编号2跟随编号1。它跳过了它们之间的编号3,因为该编号未被描述为事件。如果我们想在搜索示例给定的事件链时考虑这个编号,我们应该为其制作一个条件。 ```sql SELECT sequenceMatch('(?1)(?2)')(time, number = 1, number = 2, number = 3) FROM t @@ -160,7 +161,7 @@ SELECT sequenceMatch('(?1)(?2)')(time, number = 1, number = 2, number = 3) FROM └──────────────────────────────────────────────────────────────────────────────────────────┘ ``` -在这种情况下,该函数无法找到与模式匹配的事件链,因为编号 3 的事件发生在 1 和 2 之间。如果在同样的情况下我们检查编号 4 的条件,序列将匹配该模式。 +在这种情况下,函数无法找到与模式匹配的事件链,因为编号3的事件发生在编号1和编号2之间。如果在同一情况下我们检查编号4的条件,序列会匹配模式。 ```sql SELECT sequenceMatch('(?1)(?2)')(time, number = 1, number = 2, number = 4) FROM t @@ -172,16 +173,16 @@ SELECT sequenceMatch('(?1)(?2)')(time, number = 1, number = 2, number = 4) FROM └──────────────────────────────────────────────────────────────────────────────────────────┘ ``` -**参见** +**另见** - [sequenceCount](#sequencecount) ## sequenceCount {#sequencecount} -统计匹配模式的事件链数量。该函数搜索不重叠的事件链。在当前链匹配后,它开始搜索下一个链。 +计算与模式匹配的事件链的数量。该函数搜索不重叠的事件链。它在匹配当前链后开始搜索下一个链。 :::note -同时发生在同一秒钟的事件可能会以未定义的顺序出现在序列中,从而影响结果。 +同一秒钟发生的事件可能在序列中以未定义顺序排列,从而影响结果。 ::: **语法** @@ -192,23 +193,23 @@ sequenceCount(pattern)(timestamp, cond1, cond2, ...) **参数** -- `timestamp` — 被认为包含时间数据的列。典型的数据类型是 `Date` 和 `DateTime`。您还可以使用任何支持的 [UInt](../../sql-reference/data-types/int-uint.md) 数据类型。 +- `timestamp` — 被认为包含时间数据的列。典型数据类型为`Date`和`DateTime`。您还可以使用任何支持的[UInt](../../sql-reference/data-types/int-uint.md)数据类型。 -- `cond1`, `cond2` — 描述事件链的条件。数据类型:`UInt8`。您可以传递最多 32 个条件参数。该函数仅考虑在这些条件中描述的事件。如果序列包含未在条件中描述的数据,则该函数会跳过它们。 +- `cond1`, `cond2` — 描述事件链的条件。数据类型:`UInt8`。您最多可以传递32个条件参数。函数仅考虑这些条件中描述的事件。如果序列包含未在条件中描述的数据,函数会跳过它们。 **参数** -- `pattern` — 模式字符串。请参见 [模式语法](#pattern-syntax)。 +- `pattern` — 模式字符串。请参见[模式语法](#pattern-syntax)。 **返回值** -- 匹配的非重叠事件链的数量。 +- 匹配的不重叠事件链的数量。 类型:`UInt64`。 **示例** -考虑 `t` 表中的数据: +考虑`t`表中的数据: ```text ┌─time─┬─number─┐ @@ -221,7 +222,7 @@ sequenceCount(pattern)(timestamp, cond1, cond2, ...) └──────┴────────┘ ``` -统计编号 2 在编号 1 之后、其间有任意数量其他数字出现的次数: +计算编号2在其间有任意数量其他数字后跟随编号1的次数: ```sql SELECT sequenceCount('(?1).*(?2)')(time, number = 1, number = 2) FROM t @@ -238,7 +239,7 @@ SELECT sequenceCount('(?1).*(?2)')(time, number = 1, number = 2) FROM t 返回与模式匹配的最长事件链的事件时间戳。 :::note -同时发生在同一秒钟的事件可能会以未定义的顺序出现在序列中,从而影响结果。 +同一秒钟发生的事件可能在序列中以未定义顺序排列,从而影响结果。 ::: **语法** @@ -249,23 +250,23 @@ sequenceMatchEvents(pattern)(timestamp, cond1, cond2, ...) **参数** -- `timestamp` — 被认为包含时间数据的列。典型的数据类型是 `Date` 和 `DateTime`。您还可以使用任何支持的 [UInt](../../sql-reference/data-types/int-uint.md) 数据类型。 +- `timestamp` — 被认为包含时间数据的列。典型数据类型为`Date`和`DateTime`。您还可以使用任何支持的[UInt](../../sql-reference/data-types/int-uint.md)数据类型。 -- `cond1`, `cond2` — 描述事件链的条件。数据类型:`UInt8`。您可以传递最多 32 个条件参数。该函数仅考虑在这些条件中描述的事件。如果序列包含未在条件中描述的数据,则该函数会跳过它们。 +- `cond1`, `cond2` — 描述事件链的条件。数据类型:`UInt8`。您最多可以传递32个条件参数。函数仅考虑这些条件中描述的事件。如果序列包含未在条件中描述的数据,函数会跳过它们。 **参数** -- `pattern` — 模式字符串。请参见 [模式语法](#pattern-syntax)。 +- `pattern` — 模式字符串。请参见[模式语法](#pattern-syntax)。 **返回值** -- 匹配条件参数 (?N) 的事件链时间戳数组。数组中的位置与模式中的条件参数位置匹配 +- 匹配条件参数 (?N) 的事件链的时间戳数组。数组中的位置与模式中条件参数的位置匹配。 类型:数组。 **示例** -考虑 `t` 表中的数据: +考虑`t`表中的数据: ```text ┌─time─┬─number─┐ @@ -290,21 +291,21 @@ SELECT sequenceMatchEvents('(?1).*(?2).*(?1)(?3)')(time, number = 1, number = 2, └────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ ``` -**参见** +**另见** - [sequenceMatch](#sequencematch) ## windowFunnel {#windowfunnel} -在滑动时间窗口中搜索事件链并计算从链中发生的最大事件数量。 +在一个滑动时间窗口中搜索事件链,并计算从链中发生的最大事件数量。 -该函数根据算法工作: +该函数根据以下算法工作: -- 该函数搜索触发条件链的第一个条件的数据,并将事件计数器设置为 1。这是滑动窗口开始的时刻。 +- 函数搜索触发链中第一个条件的数据,并将事件计数器设置为1。这是滑动窗口开始的时刻。 -- 如果链中的事件在窗口内连续发生,则计数器增加。如果事件序列被打断,则计数器不增加。 +- 如果链中的事件在窗口内顺序发生,则计数器递增。如果事件序列中断,计数器则不会递增。 -- 如果数据在不同完成点有多个事件链,该函数只会输出最长链的大小。 +- 如果数据在不同的完成点有多个事件链,函数将仅输出最长链的大小。 **语法** @@ -314,35 +315,35 @@ windowFunnel(window, [mode, [mode, ... ]])(timestamp, cond1, cond2, ..., condN) **参数** -- `timestamp` — 包含时间戳的列名称。支持的数据类型有:[Date](../../sql-reference/data-types/date.md),[DateTime](/sql-reference/data-types/datetime) 和其他无符号整数类型(注意,即使时间戳支持 `UInt64` 类型,其值也不能超过 Int64 的最大值,即 2^63 - 1)。 -- `cond` — 描述事件链的条件或数据。 [UInt8](../../sql-reference/data-types/int-uint.md)。 +- `timestamp` — 包含时间戳的列的名称。支持的数据类型:[Date](../../sql-reference/data-types/date.md)、[DateTime](/sql-reference/data-types/datetime)和其他无符号整数类型(请注意,尽管时间戳支持`UInt64`类型,但其值不能超过Int64最大值,即2^63 - 1)。 +- `cond` — 描述事件链的条件或数据。[UInt8](../../sql-reference/data-types/int-uint.md)。 **参数** -- `window` — 滑动窗口的长度,即第一个和最后一个条件之间的时间间隔。`window` 的单位取决于 `timestamp` 本身并有所不同。使用表达式 `timestamp of cond1 <= timestamp of cond2 <= ... <= timestamp of condN <= timestamp of cond1 + window` 确定。 -- `mode` — 这是一个可选参数。可以设置一个或多个模式。 - - `'strict_deduplication'` — 如果相同的条件在事件序列中成立,则此类重复事件会中断进一步处理。注意:如果多个条件同时成立于同一事件,可能会出现意外情况。 - - `'strict_order'` — 不允许其他事件的干预。例如,在 `A->B->D->C` 的情况下,它在 `D` 停止寻找 `A->B->C`,最大事件级别为 2。 - - `'strict_increase'` — 仅将条件应用于时间戳严格递增的事件。 - - `'strict_once'` — 即使事件多次满足条件,也只在链中计数一次。 +- `window` — 滑动窗口的长度,即第一个条件和最后一个条件之间的时间间隔。`window`的单位取决于`timestamp`本身并有所不同。通过表达式`timestamp of cond1 <= timestamp of cond2 <= ... <= timestamp of condN <= timestamp of cond1 + window`确定。 +- `mode` — 可选参数。可以设置一个或多个模式。 + - `'strict_deduplication'` — 如果事件序列中的相同条件成立,则该重复事件将中断进一步处理。注意:如果多个条件对同一事件成立,则可能会意外工作。 + - `'strict_order'` — 不允许其他事件的干预。例如,在`A->B->D->C`的情况下,它将在`D`处停止查找`A->B->C`,最大事件级别为2。 + - `'strict_increase'` — 仅对时间戳严格递增的事件应用条件。 + - `'strict_once'` — 即使事件多次满足条件也只是计数一次。 **返回值** -在滑动时间窗口内,链中连续触发的条件的最大数量。 -所有选择中的链都进行分析。 +在滑动时间窗口中,从链中连续触发的条件的最大数量。 +选择中的所有链都会被分析。 -类型:整数。 +类型:`Integer`。 **示例** -确定一段时间是否足够用户在网上商店选择手机并购买两次。 +确定设定的时间段是否足够让用户在在线商店中选择手机并购买两次。 设置以下事件链: -1. 用户登录到他们的商店帐户 (`eventID = 1003`)。 -2. 用户搜索手机 (`eventID = 1007, product = 'phone'`)。 -3. 用户下订单 (`eventID = 1009`)。 -4. 用户再次下单 (`eventID = 1010`)。 +1. 用户登录商店账户(`eventID = 1003`)。 +2. 用户搜索手机(`eventID = 1007, product = 'phone'`)。 +3. 用户下订单(`eventID = 1009`)。 +4. 用户再次下订单(`eventID = 1010`)。 输入表: @@ -361,7 +362,7 @@ windowFunnel(window, [mode, [mode, ... ]])(timestamp, cond1, cond2, ..., condN) └────────────┴─────────┴─────────────────────┴─────────┴─────────┘ ``` -查看用户 `user_id` 在 2019 年 1 月至 2 月期间通过链的进展。 +找出用户`user_id`在2019年1月至2月期间能够在链中前进的程度。 查询: @@ -392,10 +393,10 @@ ORDER BY level ASC; ## retention {#retention} -该函数接受一组条件作为参数,条件的数量从 1 到 32,类型为 `UInt8`,指示事件是否满足某个条件。 -可以在参数中指定任何条件(如 [WHERE](/sql-reference/statements/select/where))。 +该函数接受一组条件作为参数,参数数量从1到32,类型为`UInt8`,指示事件是否满足特定条件。 +任何条件都可以作为参数指定(如[WHERE](/sql-reference/statements/select/where))。 -除第一个条件外,条件按对应用:如果第一个和第二个条件为真,则第二个的结果为真,如果第一个和第三个为真,则第三个的结果为真,等等。 +所有条件,除了第一个,以对的方式适用:如果第一个和第二个条件都为真,第二个的结果为真;如果第一个和第三个条件都为真,则第三个的结果为真,依此类推。 **语法** @@ -405,20 +406,20 @@ retention(cond1, cond2, ..., cond32); **参数** -- `cond` — 返回 `UInt8` 结果(1 或 0)的表达式。 +- `cond` — 返回`UInt8`结果(1或0)的表达式。 **返回值** -返回 1 或 0 的数组。 +1或0的数组。 -- 1 — 事件满足条件。 -- 0 — 事件未满足条件。 +- 1 — 条件为事件满足。 +- 0 — 条件未满足事件。 类型:`UInt8`。 **示例** -让我们考虑使用 `retention` 函数来确定网站流量的示例。 +我们考虑一个计算`retention`函数以确定网站流量的示例。 **1.** 创建一个表来说明示例。 @@ -479,7 +480,7 @@ SELECT * FROM retention_test └────────────┴─────┘ ``` -**2.** 使用 `retention` 函数按唯一 ID `uid` 对用户进行分组。 +**2.** 使用`retention`函数按唯一ID `uid` 对用户进行分组。 查询: @@ -515,7 +516,7 @@ ORDER BY uid ASC └─────┴─────────┘ ``` -**3.** 计算每天的网站访问总数。 +**3.** 计算每天的总网站访客数。 查询: @@ -545,20 +546,20 @@ FROM 其中: -- `r1` - 在 2020-01-01 期间访问网站的唯一访客数量(`cond1` 条件)。 -- `r2` - 在 2020-01-01 与 2020-01-02 之间的特定时间段内访问网站的唯一访客数量(`cond1` 和 `cond2` 条件)。 -- `r3` - 在 2020-01-01 和 2020-01-03 之间的特定时间段内访问网站的唯一访客数量(`cond1` 和 `cond3` 条件)。 +- `r1`- 2020年1月1日访问网站的唯一访客数量(`cond1`条件)。 +- `r2`- 在2020年1月1日至2020年1月2日期间访问网站的唯一访客数量(`cond1`和`cond2`条件)。 +- `r3`- 在2020年1月1日和2020年1月3日期间访问网站的唯一访客数量(`cond1`和`cond3`条件)。 ## uniqUpTo(N)(x) {#uniquptonx} -计算在指定限制 `N` 之前的不同参数值的数量。如果不同参数值的数量大于 `N`,则该函数返回 `N` + 1,否则计算确切值。 +计算至指定限制`N`的不同参数值的数量。如果不同参数值的数量大于`N`,则该函数返回`N` + 1,否则计算精确值。 -建议与小的 `N`(最多 10)一起使用。`N` 的最大值为 100。 +建议对小的`N`(最大到10)使用。 `N`的最大值为100。 -对于聚合函数的状态,该函数使用的内存量等于 1 + `N` 乘以一个值的字节大小。 -在处理字符串时,该函数存储一个非加密哈希值为 8 字节;对于字符串的计算是近似的。 +对于聚合函数的状态,该函数使用的内存量为1 + `N`乘以单个值的字节大小。 +处理字符串时,该函数存储8字节的非加密哈希;对字符串的计算是近似的。 -例如,如果您有一个表记录每个用户在您网站上所做的搜索查询。表中的每一行代表一个单独的搜索查询,列包括用户 ID、搜索查询和查询的时间戳。您可以使用 `uniqUpTo` 生成报告,仅显示产生至少 5 个唯一用户的关键字。 +例如,如果您有一个记录用户在您网站上每次搜索查询的表。表中的每一行代表一个单一的搜索查询,列包括用户ID、搜索查询和查询时间戳。您可以使用`uniqUpTo`生成仅显示产生至少5个唯一用户的关键字的报告。 ```sql SELECT SearchPhrase @@ -567,11 +568,11 @@ GROUP BY SearchPhrase HAVING uniqUpTo(4)(UserID) >= 5 ``` -`uniqUpTo(4)(UserID)` 计算每个 `SearchPhrase` 的唯一 `UserID` 值的数量,但最多只计数 4 个唯一值。如果某个 `SearchPhrase` 的唯一 `UserID` 值超过 4,则该函数返回 5(4 + 1)。然后 `HAVING` 子句过滤掉唯一 `UserID` 值少于 5 的 `SearchPhrase` 值。这将给您提供一个至少被 5 个唯一用户使用的搜索关键字的列表。 +`uniqUpTo(4)(UserID)`计算每个`SearchPhrase`的唯一`UserID`值的数量,但最多只计算4个唯一值。如果某个`SearchPhrase`的唯一`UserID`值超过4个,则该函数返回5(4 + 1)。然后,`HAVING`子句过滤掉唯一`UserID`值少于5的`SearchPhrase`值。这样您将得到至少5个唯一用户使用的搜索关键字列表。 ## sumMapFiltered {#summapfiltered} -该函数的行为与 [sumMap](/sql-reference/aggregate-functions/reference/summap) 相同,只是它还接受一个用于筛选的键数组作为参数。当处理高基数键时,这尤其有用。 +该函数的行为与[sumMap](/sql-reference/aggregate-functions/reference/summap)相同,但它还接受一个要过滤的键的数组作为参数。当处理高基数的键时,这尤其有用。 **语法** @@ -579,13 +580,13 @@ HAVING uniqUpTo(4)(UserID) >= 5 **参数** -- `keys_to_keep`: [数组](../data-types/array.md) 的键以供筛选。 +- `keys_to_keep`: [数组](../data-types/array.md),用于过滤的键。 - `keys`: [数组](../data-types/array.md) 的键。 - `values`: [数组](../data-types/array.md) 的值。 **返回值** -- 返回一个元组,包括排序后的键数组和对应键的值总和数组。 +- 返回两个数组的元组:已排序的键,以及对应键的总和值。 **示例** @@ -621,7 +622,7 @@ SELECT sumMapFiltered([1, 4, 8])(statusMap.status, statusMap.requests) FROM sum_ ## sumMapFilteredWithOverflow {#summapfilteredwithoverflow} -该函数的行为与 [sumMap](/sql-reference/aggregate-functions/reference/summap) 相同,只是它还接受一个用于筛选的键数组作为参数。当处理高基数键时,这尤其有用。它与 [sumMapFiltered](#summapfiltered) 函数的不同之处在于它进行带溢出的求和 - 即,对于求和,它返回与参数数据类型相同的数据类型。 +该函数的行为与[sumMap](/sql-reference/aggregate-functions/reference/summap)相同,但它还接受一个要过滤的键的数组作为参数。当处理高基数的键时,这尤其有用。它与[sumMapFiltered](#summapfiltered)函数的不同之处在于它进行溢出求和 - 即返回求和与参数数据类型相同的数据类型。 **语法** @@ -629,17 +630,17 @@ SELECT sumMapFiltered([1, 4, 8])(statusMap.status, statusMap.requests) FROM sum_ **参数** -- `keys_to_keep`: [数组](../data-types/array.md) 的键以供筛选。 +- `keys_to_keep`: [数组](../data-types/array.md) 用于过滤的键。 - `keys`: [数组](../data-types/array.md) 的键。 - `values`: [数组](../data-types/array.md) 的值。 **返回值** -- 返回一个元组,包括排序后的键数组和对应键的值总和数组。 +- 返回两个数组的元组:已排序的键,以及对应键的总和值。 **示例** -在此示例中,我们创建一个表 `sum_map`,插入一些数据,然后使用 `sumMapFilteredWithOverflow` 和 `sumMapFiltered` 以及 `toTypeName` 函数进行比较结果。在创建的表中,`requests` 的类型为 `UInt8`,`sumMapFiltered` 提升了求和值的类型至 `UInt64` 以避免溢出,而 `sumMapFilteredWithOverflow` 保持类型为 `UInt8`,这不足以存储结果 - 即溢出已发生。 +在此示例中,我们创建一个表`sum_map`,插入一些数据,然后使用`sumMapFilteredWithOverflow`和`sumMapFiltered`以及`toTypeName`函数进行结果比较。 在创建的表中,`requests`的类型为`UInt8`,而`sumMapFiltered`已将求和结果的类型提升至`UInt64`以避免溢出,而`sumMapFilteredWithOverflow`保持类型为`UInt8`,这不足以存储结果 - 即发生了溢出。 查询: @@ -685,7 +686,7 @@ SELECT sumMapFiltered([1, 4, 8])(statusMap.status, statusMap.requests) as summap 返回匹配事件链的下一个事件的值。 -_实验性函数,使用 `SET allow_experimental_funnel_functions = 1` 启用。_ +_实验性函数,使用`SET allow_experimental_funnel_functions = 1`启用。_ **语法** @@ -695,35 +696,35 @@ sequenceNextNode(direction, base)(timestamp, event_column, base_condition, event **参数** -- `direction` — 用于导航方向。 - - forward — 向前移动。 - - backward — 向后移动。 +- `direction` — 用于导航到方向。 + - forward — 向前移动。 + - backward — 向后移动。 - `base` — 用于设置基点。 - - head — 将基点设置为第一个事件。 - - tail — 将基点设置为最后一个事件。 - - first_match — 将基点设置为第一个匹配的 `event1`。 - - last_match — 将基点设置为最后一个匹配的 `event1`。 + - head — 设置基点为第一个事件。 + - tail — 设置基点为最后一个事件。 + - first_match — 设置基点为第一次匹配的`event1`。 + - last_match — 设置基点为最后一次匹配的`event1`。 **参数** -- `timestamp` — 包含时间戳的列名称。支持的数据类型:[Date](../../sql-reference/data-types/date.md),[DateTime](/sql-reference/data-types/datetime) 和其他无符号整数类型。 -- `event_column` — 包含要返回的下一个事件值的列名称。支持的数据类型:[String](../../sql-reference/data-types/string.md) 和 [Nullable(String)](../../sql-reference/data-types/nullable.md)。 +- `timestamp` — 包含时间戳的列的名称。支持的数据类型:[Date](../../sql-reference/data-types/date.md)、[DateTime](/sql-reference/data-types/datetime)和其他无符号整数类型。 +- `event_column` — 包含要返回的下一个事件的值的列的名称。支持的数据类型:[String](../../sql-reference/data-types/string.md)和[Nullable(String)](../../sql-reference/data-types/nullable.md)。 - `base_condition` — 基点必须满足的条件。 -- `event1`, `event2`, ... — 描述事件链的条件。 [UInt8](../../sql-reference/data-types/int-uint.md)。 +- `event1`、`event2`,... — 描述事件链的条件。[UInt8](../../sql-reference/data-types/int-uint.md)。 **返回值** -- `event_column[next_index]` — 如果模式匹配且存在下一个值。 +- `event_column[next_index]` — 如果模式匹配并且存在下一个值。 - `NULL` — 如果模式不匹配或下一个值不存在。 类型:[Nullable(String)](../../sql-reference/data-types/nullable.md)。 **示例** -当事件是 A->B->C->D->E 时,您想知道 B->C 后的事件,即 D。 +它可以用在事件为A->B->C->D->E时,您想知道事件B->C之后的事件D。 -查询语句搜索 A->B 之后的事件: +查询语句搜索事件A->B之后的事件: ```sql CREATE TABLE test_flow ( @@ -747,7 +748,7 @@ SELECT id, sequenceNextNode('forward', 'head')(dt, page, page = 'A', page = 'A', └────┴───────────┘ ``` -**对 `forward` 和 `head` 的行为** +**`forward`和`head`的行为** ```sql ALTER TABLE test_flow DELETE WHERE 1 = 1 settings mutations_sync = 1; @@ -776,7 +777,7 @@ SELECT id, sequenceNextNode('forward', 'head')(dt, page, page = 'Home', page = ' 1970-01-01 09:00:04 3 Basket ``` -**对 `backward` 和 `tail` 的行为** +**`backward`和`tail`的行为** ```sql SELECT id, sequenceNextNode('backward', 'tail')(dt, page, page = 'Basket', page = 'Basket', page = 'Gift') FROM test_flow GROUP BY id; @@ -797,8 +798,7 @@ SELECT id, sequenceNextNode('backward', 'tail')(dt, page, page = 'Basket', page 1970-01-01 09:00:04 3 Basket // Base point, Matched with Basket ``` - -**对 `forward` 和 `first_match` 的行为** +**`forward`和`first_match`的行为** ```sql SELECT id, sequenceNextNode('forward', 'first_match')(dt, page, page = 'Gift', page = 'Gift') FROM test_flow GROUP BY id; @@ -838,8 +838,7 @@ SELECT id, sequenceNextNode('forward', 'first_match')(dt, page, page = 'Gift', p 1970-01-01 09:00:04 3 Basket ``` - -**对 `backward` 和 `last_match` 的行为** +**`backward`和`last_match`的行为** ```sql SELECT id, sequenceNextNode('backward', 'last_match')(dt, page, page = 'Gift', page = 'Gift') FROM test_flow GROUP BY id; @@ -879,8 +878,7 @@ SELECT id, sequenceNextNode('backward', 'last_match')(dt, page, page = 'Gift', p 1970-01-01 09:00:04 3 Basket ``` - -**对 `base_condition` 的行为** +**`base_condition`的行为** ```sql CREATE TABLE test_flow_basecond diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/parametric-functions.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/parametric-functions.md.hash index 1f9cd58eee7..ae15a7d3b05 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/parametric-functions.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/parametric-functions.md.hash @@ -1 +1 @@ -21bc34c8af9fa00f +15db362a19d8da35 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/aggthrow.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/aggthrow.md index faa1aaa72a0..bfaf3959984 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/aggthrow.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/aggthrow.md @@ -1,14 +1,15 @@ --- -'description': '这个函数可以用于测试异常安全性。它将在创建时根据指定概率抛出异常。' +'description': '该函数可用于测试异常安全性。它将在创建时以指定的概率抛出异常。' 'sidebar_position': 101 'slug': '/sql-reference/aggregate-functions/reference/aggthrow' 'title': 'aggThrow' +'doc_type': 'reference' --- # aggThrow -此函数可用于测试异常安全性。它将在创建时以指定的概率抛出异常。 +该函数可用于测试异常安全性。它将在创建时以指定的概率抛出异常。 **语法** @@ -18,11 +19,11 @@ aggThrow(throw_prob) **参数** -- `throw_prob` — 创建时抛出的概率。 [Float64](../../data-types/float.md)。 +- `throw_prob` — 创建时抛出异常的概率。[Float64](../../data-types/float.md)。 **返回值** -- 一个异常: `Code: 503. DB::Exception: Aggregate function aggThrow has thrown exception successfully`。 +- 一个异常: `Code: 503. DB::Exception: Aggregate function aggThrow has thrown exception successfully`。 **示例** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/aggthrow.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/aggthrow.md.hash index 7334a8511f3..7a8dc59ca97 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/aggthrow.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/aggthrow.md.hash @@ -1 +1 @@ -f53b1b62e6a79522 +a769748a77f35e4e diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/analysis_of_variance.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/analysis_of_variance.md index db67da487b3..be813d424cd 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/analysis_of_variance.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/analysis_of_variance.md @@ -1,14 +1,15 @@ --- -'description': '提供一个针对单因素方差分析 (ANOVA test) 的统计测试。它是对几组正态分布观察值的测试,旨在找出所有组的均值是否相同。' +'description': '提供单因素方差分析的统计测试(ANOVA 测试)。这是对多个正态分布观察组进行的检验,以找出所有组的均值是否相同。' 'sidebar_position': 101 'slug': '/sql-reference/aggregate-functions/reference/analysis_of_variance' 'title': 'analysisOfVariance' +'doc_type': 'reference' --- # analysisOfVariance -提供单因素方差分析的统计检验(ANOVA检验)。它是对几个正态分布观察值组进行检验,以找出所有组是否具有相同的均值。 +提供单向方差分析的统计检验(ANOVA 测试)。它是对多个正态分布观测值组的检验,以确定所有组的均值是否相同。 **语法** @@ -16,20 +17,20 @@ analysisOfVariance(val, group_no) ``` -别名:`anova` +别名: `anova` **参数** - `val`:值。 -- `group_no`:`val`所属的组编号。 +- `group_no`:`val` 所属的组编号。 :::note -组的编号从0开始,执行检验时至少应有两个组。 -应至少有一个组的观察值数量大于一。 +组的编号从 0 开始,进行测试时至少应有两个组。 +至少应有一个组的观测值数量大于一。 ::: **返回值** -- `(f_statistic, p_value)`。[元组](../../data-types/tuple.md)([Float64](../../data-types/float.md), [Float64](../../data-types/float.md))。 +- `(f_statistic, p_value)`。 [元组](../../data-types/tuple.md)([Float64](../../data-types/float.md), [Float64](../../data-types/float.md))。 **示例** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/analysis_of_variance.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/analysis_of_variance.md.hash index 8fec34172ba..dcefcd1ab5f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/analysis_of_variance.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/analysis_of_variance.md.hash @@ -1 +1 @@ -0d776de8aabec1da +d59f8d969bc7b4e5 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/any.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/any.md index dc816e1cf58..471349a36e7 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/any.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/any.md @@ -1,22 +1,23 @@ --- -'description': '选择列的第一个遇到的值。' +'description': '选择列的第一个值。' 'sidebar_position': 102 'slug': '/sql-reference/aggregate-functions/reference/any' -'title': 'any' +'title': '任何' +'doc_type': 'reference' --- # any -选择列中遇到的第一个值。 +选择某一列的第一个遇到的值。 :::warning -由于查询可以以任意顺序执行,因此此函数的结果是非确定性的。 -如果您需要一个任意但确定的结果,请使用 [`min`](../reference/min.md) 或 [`max`](../reference/max.md) 函数。 +由于查询可以以任意顺序执行,因此该函数的结果是非确定性的。 +如果您需要任意但确定的结果,请使用函数 [`min`](../reference/min.md) 或 [`max`](../reference/max.md)。 ::: -默认情况下,此函数永远不会返回 NULL,即忽略输入列中的 NULL 值。 -但是,如果使用 `RESPECT NULLS` 修饰符,则该函数将返回第一个读取的值,无论是 NULL 还是非 NULL。 +默认情况下,函数永远不会返回 NULL,也就是说,忽略输入列中的 NULL 值。 +然而,如果函数与 `RESPECT NULLS` 修饰符一起使用,它将返回第一个读取的值,无论其是否为 NULL。 **语法** @@ -34,26 +35,26 @@ any(column) [RESPECT NULLS] - `anyValueRespectNulls`, `any_value_respect_nulls` **参数** -- `column`: 列的名称。 +- `column`: 列名。 **返回值** -遇到的第一个值。 +第一个遇到的值。 :::note -函数的返回类型与输入相同,LowCardinality 除外,这部分会被丢弃。 -这意味着如果给定输入中没有行,则它会返回该类型的默认值(整数为 0,或 Nullable() 列为 Null)。 +该函数的返回类型与输入相同,除了 LowCardinality 被丢弃。 +这意味着如果没有行作为输入,它将返回该类型的默认值(对于整数为0,或者对于 Nullable() 列为 Null)。 您可以使用 `-OrNull` [组合器](../../../sql-reference/aggregate-functions/combinators.md) 来修改此行为。 ::: **实现细节** -在某些情况下,您可以依赖执行的顺序。 -这适用于 `SELECT` 语句来自使用 `ORDER BY` 的子查询的情况。 +在某些情况下,您可以依赖执行顺序。 +这适用于 `SELECT` 来自使用 `ORDER BY` 的子查询的情况。 -当 `SELECT` 查询具有 `GROUP BY` 子句或至少一个聚合函数时,ClickHouse(与 MySQL 相比)要求 `SELECT`、`HAVING` 和 `ORDER BY` 子句中的所有表达式都必须从键或聚合函数中计算得出。 -换句话说,从表中选择的每一列必须在键中使用或在聚合函数内使用。 -要获得与 MySQL 相同的行为,您可以将其他列放入 `any` 聚合函数中。 +当一个 `SELECT` 查询具有 `GROUP BY` 子句或至少一个聚合函数时,ClickHouse(与 MySQL 不同)要求 `SELECT`、`HAVING` 和 `ORDER BY` 子句中的所有表达式必须从键或聚合函数中计算得出。 +换句话说,从表中选择的每一列必须在键中使用或在聚合函数内部使用。 +要获得类似于 MySQL 的行为,您可以将其他列放入 `any` 聚合函数中。 **示例** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/any.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/any.md.hash index f8c2a185549..6b1d983f677 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/any.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/any.md.hash @@ -1 +1 @@ -360e2877717f321b +8c2adfc422234f2b diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/anyheavy.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/anyheavy.md index f3610acec89..610573197d0 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/anyheavy.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/anyheavy.md @@ -1,14 +1,15 @@ --- -'description': '使用重型击球手算法选择一个频繁出现的值。如果在每个查询执行线程中,有一个值在一半以上的情况下出现,则返回该值。通常,结果是非确定性的。' +'description': '使用 heavy hitters 算法选择一个频繁出现的值。如果在每个查询执行线程中,有一个值出现的次数超过一半,则返回该值。通常情况下,结果是非确定性的。' 'sidebar_position': 104 'slug': '/sql-reference/aggregate-functions/reference/anyheavy' 'title': 'anyHeavy' +'doc_type': 'reference' --- # anyHeavy -选择使用 [heavy hitters](https://doi.org/10.1145/762471.762473) 算法的频繁出现值。如果在查询的每个执行线程中,有一个值出现的次数超过一半,该值将被返回。通常,结果是非确定性的。 +使用 [heavy hitters](https://doi.org/10.1145/762471.762473) 算法选择一个频繁出现的值。如果在每个查询执行线程中,有一个值出现的频率超过一半,则返回该值。通常,结果是非确定性的。 ```sql anyHeavy(column) @@ -20,7 +21,7 @@ anyHeavy(column) **示例** -以 [OnTime](../../../getting-started/example-datasets/ontime.md) 数据集为例,选择 `AirlineID` 列中的任何频繁出现的值。 +获取 [OnTime](../../../getting-started/example-datasets/ontime.md) 数据集,并选择 `AirlineID` 列中任何频繁出现的值。 ```sql SELECT anyHeavy(AirlineID) AS res diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/anyheavy.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/anyheavy.md.hash index ed2ab0f3169..cdf20b8f0a6 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/anyheavy.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/anyheavy.md.hash @@ -1 +1 @@ -5d93ccd4f5703e86 +21aed4ff14c11622 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/anylast.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/anylast.md index 966b8149a33..e222f375628 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/anylast.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/anylast.md @@ -3,6 +3,7 @@ 'sidebar_position': 105 'slug': '/sql-reference/aggregate-functions/reference/anylast' 'title': 'anyLast' +'doc_type': 'reference' --- @@ -15,8 +16,8 @@ 如果需要任意但确定的结果,请使用函数 [`min`](../reference/min.md) 或 [`max`](../reference/max.md)。 ::: -默认情况下,该函数从不返回 NULL,即忽略输入列中的 NULL 值。 -然而,如果该函数与 `RESPECT NULLS` 修饰符一起使用,则无论是否为 NULL,它都会返回读取的第一个值。 +默认情况下,该函数永远不会返回 NULL,即忽略输入列中的 NULL 值。 +但是,如果使用 `RESPECT NULLS` 修饰符调用该函数,它会返回第一个读取的值,无论是 NULL 还是非 NULL。 **语法** @@ -28,8 +29,8 @@ anyLast(column) [RESPECT NULLS] - [`last_value`](../reference/last_value.md)。 `anyLast(column) RESPECT NULLS` 的别名 -- `anyLastRespectNulls`,`anyLast_respect_nulls` -- `lastValueRespectNulls`,`last_value_respect_nulls` +- `anyLastRespectNulls`, `anyLast_respect_nulls` +- `lastValueRespectNulls`, `last_value_respect_nulls` **参数** - `column`: 列名。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/anylast.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/anylast.md.hash index 450bc77fd5e..432302fbb31 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/anylast.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/anylast.md.hash @@ -1 +1 @@ -12bb61c58e81b875 +51ab86ccb3fd4789 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/approxtopk.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/approxtopk.md index 4f8f55a5756..be09f0f6227 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/approxtopk.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/approxtopk.md @@ -1,32 +1,33 @@ --- -'description': '返回指定列中大约最频繁的值及其计数的数组。' +'description': '返回指定列中大约最频繁值及其计数的数组。' 'sidebar_position': 107 'slug': '/sql-reference/aggregate-functions/reference/approxtopk' 'title': 'approx_top_k' +'doc_type': 'reference' --- # approx_top_k -返回指定列中大约出现最频繁值及其计数的数组。结果数组按值的近似频率降序排序(而不是按值本身)。 +返回指定列中大约最频繁值及其计数的数组。结果数组按值的近似频率降序排列(而不是按值本身)。 ```sql approx_top_k(N)(column) approx_top_k(N, reserved)(column) ``` -此函数不提供保证的结果。在某些情况下,可能会发生错误,并可能返回并非最频繁的值。 +此函数无法提供保证的结果。在某些情况下,可能会发生错误,并且它可能返回并不是真正最频繁的值。 -我们建议使用`N < 10`的值;随着`N`值的增大,性能会下降。`N`的最大值为65536。 +我们建议使用 `N < 10` 的值;大 `N` 值会降低性能。最大值为 `N = 65536`。 **参数** - `N` — 要返回的元素数量。可选。默认值:10。 -- `reserved` — 定义为值保留的单元格数。如果 uniq(column) > reserved,则 topK 函数的结果将是近似的。可选。默认值:N * 3。 +- `reserved` — 定义为值保留多少个单元。如果 uniq(column) > reserved,topK 函数的结果将是近似值。可选。默认值:N * 3。 **参数** -- `column` — 计算频率的值。 +- `column` — 用于计算频率的值。 **示例** @@ -48,9 +49,9 @@ FROM VALUES('k Char, w UInt64', ('y', 1), ('y', 1), ('x', 5), ('y', 1), ('z', 10 # approx_top_count -是`approx_top_k`函数的别名。 +是 `approx_top_k` 函数的别名 -**另见** +**参见** - [topK](../../../sql-reference/aggregate-functions/reference/topk.md) - [topKWeighted](../../../sql-reference/aggregate-functions/reference/topkweighted.md) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/approxtopk.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/approxtopk.md.hash index b573873f714..dcf01b82446 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/approxtopk.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/approxtopk.md.hash @@ -1 +1 @@ -480413c24e3ab950 +f5fca488cd882ce3 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/approxtopsum.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/approxtopsum.md index 1114d8fedcd..356593778d6 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/approxtopsum.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/approxtopsum.md @@ -3,31 +3,32 @@ 'sidebar_position': 108 'slug': '/sql-reference/aggregate-functions/reference/approxtopsum' 'title': 'approx_top_sum' +'doc_type': 'reference' --- # approx_top_sum -返回指定列中大约最频繁值及其计数的数组。结果数组按值的近似频率降序排列(而不是按值本身)。此外,还考虑了值的权重。 +返回指定列中大致最频繁值及其计数的数组。结果数组按照值的近似频率降序排序(而不是按照值本身排序)。此外,还考虑了值的权重。 ```sql approx_top_sum(N)(column, weight) approx_top_sum(N, reserved)(column, weight) ``` -此函数不提供保证结果。在某些情况下,可能会发生错误,并可能返回不是最频繁值的频繁值。 +此函数并不提供保证的结果。在某些情况下,可能会发生错误,并返回并非最频繁值的频繁值。 -我们建议使用 `N < 10` 的值;使用较大的 `N` 值时性能会降低。最大值为 `N = 65536`。 +我们建议使用 `N < 10` 的值;随着较大 `N` 值的增大,性能会下降。最大值为 `N = 65536`。 **参数** - `N` — 要返回的元素数量。可选。默认值:10。 -- `reserved` — 定义为值保留的单元格数量。如果 uniq(column) > reserved,topK 函数的结果将是近似的。可选。默认值:N * 3。 +- `reserved` — 定义为值保留了多少个单元。如果 uniq(column) > reserved,topK 函数的结果将是近似的。可选。默认值:N * 3。 -**参数说明** +**参数** -- `column` — 用于计算频率的值。 -- `weight` — 权重。每个值在频率计算中被计算 `weight` 次。 [UInt64](../../../sql-reference/data-types/int-uint.md)。 +- `column` — 计算频率的值。 +- `weight` — 权重。每个值在频率计算中计入 `weight` 次。 [UInt64](../../../sql-reference/data-types/int-uint.md)。 **示例** @@ -46,7 +47,7 @@ FROM VALUES('k Char, w UInt64', ('y', 1), ('y', 1), ('x', 5), ('y', 1), ('z', 10 └─────────────────────────┘ ``` -**另请参阅** +**另见** - [topK](../../../sql-reference/aggregate-functions/reference/topk.md) - [topKWeighted](../../../sql-reference/aggregate-functions/reference/topkweighted.md) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/approxtopsum.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/approxtopsum.md.hash index 5cac356ac95..74d1591a8ae 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/approxtopsum.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/approxtopsum.md.hash @@ -1 +1 @@ -5ff2cebcaf1d8b6d +282ba8b9878e828a diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/argmax.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/argmax.md index f1bf15e79e0..8475fe14631 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/argmax.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/argmax.md @@ -3,13 +3,13 @@ 'sidebar_position': 109 'slug': '/sql-reference/aggregate-functions/reference/argmax' 'title': 'argMax' +'doc_type': 'reference' --- # argMax -计算最大 `val` 值的 `arg` 值。如果存在多个行的 `val` 值相同且为最大,则返回哪个相关的 `arg` 是不确定的。 -这两个部分 `arg` 和 `max` 的行为类似于 [聚合函数](/sql-reference/aggregate-functions/index.md),在处理过程中均会 [跳过 `Null`](/sql-reference/aggregate-functions/index.md#null-processing),并在有可用的非 `Null` 值时返回非 `Null` 值。 +计算最大 `val` 值的 `arg` 值。如果有多行具有相等的最大 `val`,则返回的相关 `arg` 不具备确定性。两个部分 `arg` 和 `max` 都作为 [聚合函数](/sql-reference/aggregate-functions/index.md) 行为,它们在处理过程中都 [跳过 `Null`](/sql-reference/aggregate-functions/index.md#null-processing),并在有可用的非 `Null` 值时返回非 `Null` 值。 **语法** @@ -24,7 +24,7 @@ argMax(arg, val) **返回值** -- 与最大 `val` 值对应的 `arg` 值。 +- 与最大 `val` 值相对应的 `arg` 值。 类型:与 `arg` 类型匹配。 @@ -66,7 +66,7 @@ ENGINE = Memory AS SELECT * FROM VALUES(('a', 1), ('b', 2), ('c', 2), (NULL, 3), (NULL, NULL), ('d', NULL)); -select * from test; +SELECT * FROM test; ┌─a────┬────b─┐ │ a │ 1 │ │ b │ 2 │ @@ -107,6 +107,6 @@ SELECT argMax(a, tuple(b)) FROM test; └─────────────────────┘ ``` -**参见** +**另见** -- [Tuple](/sql-reference/data-types/tuple.md) +- [元组](/sql-reference/data-types/tuple.md) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/argmax.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/argmax.md.hash index 660f4b6bea2..1a2bb7aceba 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/argmax.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/argmax.md.hash @@ -1 +1 @@ -dfccbe9b6ebf7853 +c8dd5af90d8c1b01 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/argmin.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/argmin.md index 0bb5f192092..f09122457ae 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/argmin.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/argmin.md @@ -1,15 +1,16 @@ --- -'description': '计算最小 `val` 值的 `arg` 值。如果有多行具有相同的 `val` 最大值,那么返回的相关 `arg` 不是确定性的。' +'description': '计算具有最小 `val` 值的 `arg` 值。如果存在多个行的 `val` 值相同且为最大值,则返回的相关 `arg` 是不确定的。' 'sidebar_position': 110 'slug': '/sql-reference/aggregate-functions/reference/argmin' 'title': 'argMin' +'doc_type': 'reference' --- # argMin -计算最小 `val` 值的 `arg` 值。如果有多行具有相同的最大 `val`,返回的相关 `arg` 是不确定的。 -`arg` 和 `min` 两个部分都作为 [聚合函数](/sql-reference/aggregate-functions/index.md) 行为,它们在处理过程中都 [跳过 `Null`](/sql-reference/aggregate-functions/index.md#null-processing),如果有非 `Null` 值可用,则返回非 `Null` 值。 +计算最小 `val` 值的 `arg` 值。如果有多行的 `val` 值相等且为最大,则返回的关联 `arg` 是不确定的。 +这两个部分 `arg` 和 `min` 的行为都像 [聚合函数](/sql-reference/aggregate-functions/index.md),在处理过程中都 [跳过 `Null`](/sql-reference/aggregate-functions/index.md#null-processing),如果有可用的非 `Null` 值,将返回非 `Null` 值。 **语法** @@ -26,7 +27,7 @@ argMin(arg, val) - 与最小 `val` 值对应的 `arg` 值。 -类型: 与 `arg` 类型匹配。 +类型:与 `arg` 类型匹配。 **示例** @@ -66,7 +67,7 @@ ENGINE = Memory AS SELECT * FROM VALUES((NULL, 0), ('a', 1), ('b', 2), ('c', 2), (NULL, NULL), ('d', NULL)); -select * from test; +SELECT * FROM test; ┌─a────┬────b─┐ │ ᴺᵁᴸᴸ │ 0 │ │ a │ 1 │ diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/argmin.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/argmin.md.hash index b70c227107b..c80a4c1654d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/argmin.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/argmin.md.hash @@ -1 +1 @@ -4bb5ee6a01fc58c5 +b825a5e9590f9e9b diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/arrayconcatagg.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/arrayconcatagg.md deleted file mode 100644 index ec8c76aa746..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/arrayconcatagg.md +++ /dev/null @@ -1,32 +0,0 @@ ---- -'description': 'array_concat_agg函数的文档' -'sidebar_position': 111 -'slug': '/sql-reference/aggregate-functions/reference/array_concat_agg' -'title': 'array_concat_agg' ---- - - -# array_concat_agg -- `groupArrayArray` 的别名。该函数对大小写不敏感。 - -**示例** - -```text -SELECT * -FROM t - -``` - -查询: - -```sql -┌ ┐ -│[1,2,3] │ -│[4,5] │ -│[6] │ -└ ┘ - -``` -┌ ─a───────────── ┌ -│ [1,2,3,4,5,6] │ -└ ─────────────── └ diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/arrayconcatagg.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/arrayconcatagg.md.hash deleted file mode 100644 index cf9abe0746b..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/arrayconcatagg.md.hash +++ /dev/null @@ -1 +0,0 @@ -52d1f8253df8d75c diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/avg.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/avg.md index 1f3f65a7c0e..5f0b61212ca 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/avg.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/avg.md @@ -3,6 +3,7 @@ 'sidebar_position': 112 'slug': '/sql-reference/aggregate-functions/reference/avg' 'title': 'avg' +'doc_type': 'reference' --- @@ -23,14 +24,14 @@ avg(x) **返回值** - 算术平均值,始终为 [Float64](../../../sql-reference/data-types/float.md)。 -- 如果输入参数 `x` 为空,返回 `NaN`。 +- 如果输入参数 `x` 为空,则返回 `NaN`。 **示例** 查询: ```sql -SELECT avg(x) FROM values('x Int8', 0, 1, 2, 3, 4, 5); +SELECT avg(x) FROM VALUES('x Int8', 0, 1, 2, 3, 4, 5); ``` 结果: @@ -48,7 +49,7 @@ SELECT avg(x) FROM values('x Int8', 0, 1, 2, 3, 4, 5); 查询: ```sql -CREATE table test (t UInt8) ENGINE = Memory; +CREATE TABLE test (t UInt8) ENGINE = Memory; ``` 获取算术平均值: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/avg.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/avg.md.hash index 4a4dbc9d84c..00d23bf6dfe 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/avg.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/avg.md.hash @@ -1 +1 @@ -59304045a9c1bca7 +0af929fd048c51a9 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/avgweighted.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/avgweighted.md index 7190ecfb8e3..a4fe9e4d94b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/avgweighted.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/avgweighted.md @@ -3,12 +3,13 @@ 'sidebar_position': 113 'slug': '/sql-reference/aggregate-functions/reference/avgweighted' 'title': 'avgWeighted' +'doc_type': 'reference' --- # avgWeighted -计算 [加权算术平均值](https://en.wikipedia.org/wiki/Weighted_arithmetic_mean)。 +计算[加权算术平均数](https://en.wikipedia.org/wiki/Weighted_arithmetic_mean)。 **语法** @@ -21,7 +22,7 @@ avgWeighted(x, weight) - `x` — 值。 - `weight` — 值的权重。 -`x` 和 `weight` 必须都是 +`x` 和 `weight` 必须都是 [整数](../../../sql-reference/data-types/int-uint.md) 或 [浮点数](../../../sql-reference/data-types/float.md), 但可以有不同的类型。 @@ -30,7 +31,7 @@ avgWeighted(x, weight) - 如果所有权重都等于 0 或提供的权重参数为空,则返回 `NaN`。 - 否则返回加权平均值。 -**返回类型** 始终为 [Float64](../../../sql-reference/data-types/float.md)。 +**返回类型**始终为 [Float64](../../../sql-reference/data-types/float.md)。 **示例** @@ -38,7 +39,7 @@ avgWeighted(x, weight) ```sql SELECT avgWeighted(x, w) -FROM values('x Int8, w Int8', (4, 1), (1, 0), (10, 2)) +FROM VALUES('x Int8, w Int8', (4, 1), (1, 0), (10, 2)) ``` 结果: @@ -55,7 +56,7 @@ FROM values('x Int8, w Int8', (4, 1), (1, 0), (10, 2)) ```sql SELECT avgWeighted(x, w) -FROM values('x Int8, w Float64', (4, 1), (1, 0), (10, 2)) +FROM VALUES('x Int8, w Float64', (4, 1), (1, 0), (10, 2)) ``` 结果: @@ -72,7 +73,7 @@ FROM values('x Int8, w Float64', (4, 1), (1, 0), (10, 2)) ```sql SELECT avgWeighted(x, w) -FROM values('x Int8, w Int8', (0, 0), (1, 0), (10, 0)) +FROM VALUES('x Int8, w Int8', (0, 0), (1, 0), (10, 0)) ``` 结果: @@ -88,7 +89,7 @@ FROM values('x Int8, w Int8', (0, 0), (1, 0), (10, 0)) 查询: ```sql -CREATE table test (t UInt8) ENGINE = Memory; +CREATE TABLE test (t UInt8) ENGINE = Memory; SELECT avgWeighted(t) FROM test ``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/avgweighted.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/avgweighted.md.hash index 16b5f6601cc..03a6780ad28 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/avgweighted.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/avgweighted.md.hash @@ -1 +1 @@ -fe08e96010b223b9 +71af0ba429830e54 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/boundrat.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/boundrat.md index 3153c62203f..8965a878195 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/boundrat.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/boundrat.md @@ -1,11 +1,12 @@ --- -'description': '聚合函数,计算一组值中最左和最右点之间的斜率。' +'description': '聚合函数,用于计算一组值中最左和最右点之间的斜率。' 'sidebar_position': 114 'slug': '/sql-reference/aggregate-functions/reference/boundingRatio' 'title': 'boundingRatio' +'doc_type': 'reference' --- -聚合函数,用于计算一组值中最左侧和最右侧点之间的斜率。 +聚合函数计算一组值中最左侧和最右侧点之间的斜率。 示例: @@ -31,7 +32,7 @@ FROM numbers(10) └────────┴───────────────────────┘ ``` -boundingRatio() 函数返回最左侧和最右侧点之间的斜率,在上述数据中,这些点是 `(0,0)` 和 `(9,13.5)`。 +boundingRatio() 函数返回最左侧和最右侧点之间的线的斜率,在上面的数据中,这些点是 `(0,0)` 和 `(9,13.5)`。 ```sql SELECT boundingRatio(number, number * 1.5) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/boundrat.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/boundrat.md.hash index e036d1af032..8580d21792b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/boundrat.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/boundrat.md.hash @@ -1 +1 @@ -c1bbc1ba5a882ddc +d1dedd223f3471d0 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/categoricalinformationvalue.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/categoricalinformationvalue.md index 652e968d0a4..3e11e664b5b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/categoricalinformationvalue.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/categoricalinformationvalue.md @@ -1,15 +1,16 @@ --- -'description': '计算每个类别的`(P(tag = 1) - P(tag = 0))(log(P(tag = 1)) - log(P(tag = 0)))` - 的值。' +'description': '计算每个类别的 `(P(tag = 1) - P(tag = 0))(log(P(tag = 1)) - log(P(tag = 0)))` + 值。' 'sidebar_position': 115 'slug': '/sql-reference/aggregate-functions/reference/categoricalinformationvalue' 'title': 'categoricalInformationValue' +'doc_type': 'reference' --- -计算每个类别的值 `(P(tag = 1) - P(tag = 0))(log(P(tag = 1)) - log(P(tag = 0)))` 。 +计算每个类别的 `(P(tag = 1) - P(tag = 0))(log(P(tag = 1)) - log(P(tag = 0)))` 的值。 ```sql categoricalInformationValue(category1, category2, ..., tag) ``` -结果表明离散(分类)特征 `[category1, category2, ...]` 如何对预测 `tag` 的值的学习模型做出贡献。 +结果表明离散(分类)特征 `[category1, category2, ...]` 如何贡献于预测 `tag` 值的学习模型。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/categoricalinformationvalue.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/categoricalinformationvalue.md.hash index d2c80e9b171..b4250370d0a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/categoricalinformationvalue.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/categoricalinformationvalue.md.hash @@ -1 +1 @@ -d30c70dc35bdbdc0 +3282064294e51af1 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/contingency.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/contingency.md index f5067f1c1ef..0295b25888f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/contingency.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/contingency.md @@ -1,14 +1,16 @@ --- -'description': '`contingency` 函数计算应急系数,一个测量表中两个列之间关联程度的值。计算过程类似于 `cramersV` 函数,但在平方根中使用不同的分母。' +'description': '`contingency` 函数计算 contingence 系数,这是一个测量表中两个列之间关联程度的值。其计算方法类似于 `cramersV` + 函数,但在平方根中使用了不同的分母。' 'sidebar_position': 116 'slug': '/sql-reference/aggregate-functions/reference/contingency' -'title': '应急情况' +'title': 'contingency' +'doc_type': 'reference' --- # contingency -`contingency` 函数计算 [contingency coefficient](https://en.wikipedia.org/wiki/Contingency_table#Cram%C3%A9r's_V_and_the_contingency_coefficient_C),这是一个衡量表中两个列之间关联性的值。该计算类似于 [the `cramersV` function](./cramersv.md),但在平方根中使用不同的分母。 +`contingency` 函数计算 [应急系数](https://en.wikipedia.org/wiki/Contingency_table#Cram%C3%A9r's_V_and_the_contingency_coefficient_C),这是一个衡量表中两个列之间关联性的值。该计算类似于 [cramersV 函数](./cramersv.md),但在取平方根时使用了不同的分母。 **语法** @@ -18,13 +20,13 @@ contingency(column1, column2) **参数** -- `column1` 和 `column2` 是要进行比较的列 +- `column1` 和 `column2` 是要比较的列 **返回值** -- 一个介于 0 和 1 之间的值。结果越大,两个列之间的关联性越强。 +- 一个介于 0 和 1 之间的值。结果越大,两个列之间的关联越紧密。 -**返回类型**始终为 [Float64](../../../sql-reference/data-types/float.md)。 +**返回类型** 始终是 [Float64](../../../sql-reference/data-types/float.md)。 **示例** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/contingency.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/contingency.md.hash index 5f6032ffe32..3ca6a2f435e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/contingency.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/contingency.md.hash @@ -1 +1 @@ -aa4d01ee79094ac7 +b2c8fc7c6db7f1ba diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/corr.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/corr.md index ea421ce4552..cb32519cbaf 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/corr.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/corr.md @@ -1,14 +1,15 @@ --- -'description': '计算皮尔逊相关系数.' +'description': '计算 Pearson 相关系数.' 'sidebar_position': 117 'slug': '/sql-reference/aggregate-functions/reference/corr' 'title': 'corr' +'doc_type': 'reference' --- # corr -计算 [Pearson 相关系数](https://en.wikipedia.org/wiki/Pearson_correlation_coefficient): +计算 [Pearson 相关系数](https://en.wikipedia.org/wiki/Pearson_correlation_coefficient): $$ \frac{\Sigma{(x - \bar{x})(y - \bar{y})}}{\sqrt{\Sigma{(x - \bar{x})^2} * \Sigma{(y - \bar{y})^2}}} @@ -16,7 +17,7 @@ $$
:::note -此函数使用数值不稳定的算法。如果您需要计算中的 [数值稳定性](https://en.wikipedia.org/wiki/Numerical_stability),请使用 [`corrStable`](../reference/corrstable.md) 函数。它速度较慢,但提供更准确的结果。 +此函数使用了一种数值不稳定的算法。如果您需要计算中的 [数值稳定性](https://en.wikipedia.org/wiki/Numerical_stability),请使用 [`corrStable`](../reference/corrstable.md) 函数。此函数较慢,但能提供更准确的结果。 ::: **语法** @@ -27,16 +28,16 @@ corr(x, y) **参数** -- `x` — 第一个变量。[(U)Int*](../../data-types/int-uint.md),[Float*](../../data-types/float.md)。 -- `y` — 第二个变量。[(U)Int*](../../data-types/int-uint.md),[Float*](../../data-types/float.md)。 +- `x` — 第一个变量。[(U)Int*](../../data-types/int-uint.md), [Float*](../../data-types/float.md). +- `y` — 第二个变量。[(U)Int*](../../data-types/int-uint.md), [Float*](../../data-types/float.md). **返回值** -- Pearson 相关系数。 [Float64](../../data-types/float.md)。 +- Pearson 相关系数。 [Float64](../../data-types/float.md). **示例** -查询: +查询: ```sql DROP TABLE IF EXISTS series; @@ -55,7 +56,7 @@ SELECT corr(x_value, y_value) FROM series; ``` -结果: +结果: ```response ┌─corr(x_value, y_value)─┐ diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/corr.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/corr.md.hash index 6d49d8884a5..8ad9264bb99 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/corr.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/corr.md.hash @@ -1 +1 @@ -f8bed560f7121358 +7992def5e0eda200 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/corrmatrix.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/corrmatrix.md index acb6e6e9063..3d28f855e02 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/corrmatrix.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/corrmatrix.md @@ -1,14 +1,15 @@ --- -'description': '计算 N 个变量的相关矩阵。' +'description': '计算 N 个变量之间的相关矩阵。' 'sidebar_position': 118 'slug': '/sql-reference/aggregate-functions/reference/corrmatrix' 'title': 'corrMatrix' +'doc_type': 'reference' --- # corrMatrix -计算 N 个变量的相关性矩阵。 +计算 N 个变量的相关矩阵。 **语法** @@ -18,11 +19,11 @@ corrMatrix(x[, ...]) **参数** -- `x` — 变量数量的参数。[(U)Int*](../../data-types/int-uint.md), [Float*](../../data-types/float.md), [Decimal](../../data-types/decimal.md)。 +- `x` — 一组可变数量的参数。[`(U)Int8/16/32/64`](../../data-types/int-uint.md)、[`Float*`](../../data-types/float.md)。 **返回值** -- 相关性矩阵。 [Array](../../data-types/array.md)([Array](../../data-types/array.md)([Float64](../../data-types/float.md)))。 +- 相关矩阵。[`Array`](../../data-types/array.md)([`Array`](../../data-types/array.md)([`Float64`](../../data-types/float.md)))。 **示例** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/corrmatrix.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/corrmatrix.md.hash index 5ff4ed28d28..ebdb9058f9f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/corrmatrix.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/corrmatrix.md.hash @@ -1 +1 @@ -8af6054c759d1085 +26ec6529f845049f diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/corrstable.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/corrstable.md index 102cab3788e..957862a4fc5 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/corrstable.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/corrstable.md @@ -1,8 +1,9 @@ --- -'description': '计算Pearson相关系数,但使用了数值稳定的算法。' +'description': '计算 Pearson 相关系数,但使用数值稳定算法。' 'sidebar_position': 119 'slug': '/sql-reference/aggregate-functions/reference/corrstable' 'title': 'corrStable' +'doc_type': 'reference' --- @@ -14,7 +15,7 @@ $$ \frac{\Sigma{(x - \bar{x})(y - \bar{y})}}{\sqrt{\Sigma{(x - \bar{x})^2} * \Sigma{(y - \bar{y})^2}}} $$ -与 [`corr`](../reference/corr.md) 函数类似,但使用了数值稳定的算法。因此,`corrStable` 比 `corr` 更慢,但产生更准确的结果。 +类似于 [`corr`](../reference/corr.md) 函数,但使用了数值稳定的算法。因此,`corrStable` 的速度比 `corr` 慢,但产生更准确的结果。 **语法** @@ -24,8 +25,8 @@ corrStable(x, y) **参数** -- `x` — 第一个变量。[(U)Int*](../../data-types/int-uint.md), [Float*](../../data-types/float.md), [Decimal](../../data-types/decimal.md)。 -- `y` — 第二个变量。[(U)Int*](../../data-types/int-uint.md), [Float*](../../data-types/float.md), [Decimal](../../data-types/decimal.md)。 +- `x` — 第一个变量。[(U)Int*](../../data-types/int-uint.md)、[Float*](../../data-types/float.md)、[Decimal](../../data-types/decimal.md)。 +- `y` — 第二个变量。[(U)Int*](../../data-types/int-uint.md)、[Float*](../../data-types/float.md)、[Decimal](../../data-types/decimal.md)。 **返回值** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/corrstable.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/corrstable.md.hash index bd0d0f60a30..650f11ec4b7 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/corrstable.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/corrstable.md.hash @@ -1 +1 @@ -a4b83d9f7b157032 +ca72e179c76df2ab diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/count.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/count.md index 82bdc6ee229..2db1a5cfafd 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/count.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/count.md @@ -3,43 +3,44 @@ 'sidebar_position': 120 'slug': '/sql-reference/aggregate-functions/reference/count' 'title': 'count' +'doc_type': 'reference' --- # count -计算行数或非空值的数量。 +计算行数或非NULL值的数量。 -ClickHouse 支持以下 `count` 语法: +ClickHouse支持以下`count`的语法: -- `count(expr)` 或 `COUNT(DISTINCT expr)`。 -- `count()` 或 `COUNT(*)`。`count()` 语法是 ClickHouse 特有的。 +- `count(expr)`或`COUNT(DISTINCT expr)`。 +- `count()`或`COUNT(*)`。`count()`语法是ClickHouse特有的。 **参数** 该函数可以接受: - 零个参数。 -- 一个 [expression](/sql-reference/syntax#expressions)。 +- 一个 [表达式](/sql-reference/syntax#expressions)。 **返回值** -- 如果函数在没有参数的情况下被调用,它将计算行数。 -- 如果传递了 [expression](/sql-reference/syntax#expressions),那么函数会计算该表达式返回非空值的次数。如果该表达式返回的是 [Nullable](../../../sql-reference/data-types/nullable.md) 类型值,则 `count` 的结果将保持为非 `Nullable`。如果该表达式在所有行中返回 `NULL`,则函数返回 0。 +- 如果函数不带参数调用,则计算行数。 +- 如果传递了[表达式](/sql-reference/syntax#expressions),则函数计算该表达式返回非NULL的次数。如果该表达式返回[Nullable](../../../sql-reference/data-types/nullable.md)类型的值,则`count`的结果保持为非`Nullable`。如果该表达式对于所有行返回`NULL`,则函数返回0。 -在两种情况下,返回值的类型为 [UInt64](../../../sql-reference/data-types/int-uint.md)。 +在这两种情况下,返回值的类型为[UInt64](../../../sql-reference/data-types/int-uint.md)。 -**详情** +**详细信息** -ClickHouse 支持 `COUNT(DISTINCT ...)` 语法。此结构的行为取决于 [count_distinct_implementation](../../../operations/settings/settings.md#count_distinct_implementation) 设置。它定义了用于执行操作的 [uniq*](/sql-reference/aggregate-functions/reference/uniq) 函数。默认值是 [uniqExact](/sql-reference/aggregate-functions/reference/uniqexact) 函数。 +ClickHouse支持`COUNT(DISTINCT ...)`语法。这种结构的行为依赖于[count_distinct_implementation](../../../operations/settings/settings.md#count_distinct_implementation)设置。该设置定义用于执行操作的[uniq*](/sql-reference/aggregate-functions/reference/uniq)函数。默认值是[uniqExact](/sql-reference/aggregate-functions/reference/uniqexact)函数。 -`SELECT count() FROM table` 查询默认使用来自 MergeTree 的元数据进行优化。如果您需要使用行级安全性,请使用 [optimize_trivial_count_query](/operations/settings/settings#optimize_trivial_count_query) 设置禁用优化。 +`SELECT count() FROM table`查询默认通过使用MergeTree中的元数据进行优化。如果需要使用行级安全性,请使用[optimize_trivial_count_query](/operations/settings/settings#optimize_trivial_count_query)设置来禁用优化。 -然而,`SELECT count(nullable_column) FROM table` 查询可以通过启用 [optimize_functions_to_subcolumns](/operations/settings/settings#optimize_functions_to_subcolumns) 设置来优化。在 `optimize_functions_to_subcolumns = 1` 的情况下,该函数仅读取 [null](../../../sql-reference/data-types/nullable.md#finding-null) 子列,而不是读取和处理整列数据。查询 `SELECT count(n) FROM table` 转换为 `SELECT sum(NOT n.null) FROM table`。 +然而,`SELECT count(nullable_column) FROM table`查询可以通过启用[optimize_functions_to_subcolumns](/operations/settings/settings#optimize_functions_to_subcolumns)设置来进行优化。通过将`optimize_functions_to_subcolumns = 1`,该函数只读取[null](../../../sql-reference/data-types/nullable.md#finding-null)子列,而不是读取和处理整个列数据。查询`SELECT count(n) FROM table`会转换为`SELECT sum(NOT n.null) FROM table`。 -**提高 COUNT(DISTINCT expr) 性能** +**提高COUNT(DISTINCT expr)性能** -如果您的 `COUNT(DISTINCT expr)` 查询很慢,考虑添加 [`GROUP BY`](/sql-reference/statements/select/group-by) 子句,因为这可以提高并行化。您还可以使用 [projection](../../../sql-reference/statements/alter/projection.md) 在目标列上创建索引,以便与 `COUNT(DISTINCT target_col)` 一起使用。 +如果你的`COUNT(DISTINCT expr)`查询速度较慢,可以考虑添加一个[`GROUP BY`](/sql-reference/statements/select/group-by)子句,因为这可以改善并行化。你也可以使用[projection](../../../sql-reference/statements/alter/projection.md)在用于`COUNT(DISTINCT target_col)`的目标列上创建索引。 **示例** @@ -77,4 +78,4 @@ SELECT count(DISTINCT num) FROM t └────────────────┘ ``` -此示例显示 `count(DISTINCT num)` 根据 `count_distinct_implementation` 设置值由 `uniqExact` 函数执行。 +此示例显示`count(DISTINCT num)`是根据`count_distinct_implementation`设置值通过`uniqExact`函数执行的。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/count.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/count.md.hash index 0274b4e3bd0..4ce69c58940 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/count.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/count.md.hash @@ -1 +1 @@ -e5238f3772fc376c +683c5041a35bb9b0 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/covarpop.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/covarpop.md index fcf04e8a628..a3ff10cb082 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/covarpop.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/covarpop.md @@ -3,6 +3,7 @@ 'sidebar_position': 121 'slug': '/sql-reference/aggregate-functions/reference/covarpop' 'title': 'covarPop' +'doc_type': 'reference' --- @@ -15,7 +16,7 @@ $$ $$ :::note -此函数使用数值不稳定的算法。如果您需要在计算中确保 [数值稳定性](https://en.wikipedia.org/wiki/Numerical_stability),请使用 [`covarPopStable`](../reference/covarpopstable.md) 函数。它的计算速度较慢,但提供了更低的计算误差。 +此函数使用了数值不稳定的算法。如果您需要计算中的 [数值稳定性](https://en.wikipedia.org/wiki/Numerical_stability),请使用 [`covarPopStable`](../reference/covarpopstable.md) 函数。它的运行速度较慢,但提供较低的计算误差。 ::: **语法** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/covarpop.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/covarpop.md.hash index 33f0aece308..45fa521ee91 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/covarpop.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/covarpop.md.hash @@ -1 +1 @@ -8685462fcaaaf123 +873401e335c63315 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/covarpopmatrix.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/covarpopmatrix.md index 5f46cd2da40..2af99dd882c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/covarpopmatrix.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/covarpopmatrix.md @@ -3,6 +3,7 @@ 'sidebar_position': 122 'slug': '/sql-reference/aggregate-functions/reference/covarpopmatrix' 'title': 'covarPopMatrix' +'doc_type': 'reference' --- @@ -18,7 +19,7 @@ covarPopMatrix(x[, ...]) **参数** -- `x` — 可变数量的参数。[(U)Int*](../../data-types/int-uint.md)、[Float*](../../data-types/float.md)、[Decimal](../../data-types/decimal.md)。 +- `x` — 变量数量的参数。[(U)Int*](../../data-types/int-uint.md), [Float*](../../data-types/float.md), [Decimal](../../data-types/decimal.md)。 **返回值** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/covarpopmatrix.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/covarpopmatrix.md.hash index fb21139c446..2a9a5bde657 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/covarpopmatrix.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/covarpopmatrix.md.hash @@ -1 +1 @@ -e9b66678106d3ab1 +0d576378b8b99a9f diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/covarpopstable.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/covarpopstable.md index 2f9d82e6bb6..f29dd600223 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/covarpopstable.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/covarpopstable.md @@ -1,20 +1,21 @@ --- -'description': '计算总体协方差的值' +'description': '计算人口协方差的值' 'sidebar_position': 123 'slug': '/sql-reference/aggregate-functions/reference/covarpopstable' 'title': 'covarPopStable' +'doc_type': 'reference' --- # covarPopStable -计算总体协方差的值: +计算人口协方差的值: $$ \frac{\Sigma{(x - \bar{x})(y - \bar{y})}}{n} $$ -它与[covarPop](../reference/covarpop.md)函数类似,但使用了数值稳定的算法。因此,`covarPopStable`比`covarPop`更慢,但产生更准确的结果。 +它与 [covarPop](../reference/covarpop.md) 函数相似,但使用数值稳定的算法。因此,`covarPopStable` 比 `covarPop` 更慢,但产生更准确的结果。 **语法** @@ -29,7 +30,7 @@ covarPop(x, y) **返回值** -- `x`和`y`之间的总体协方差。[Float64](../../data-types/float.md)。 +- `x` 和 `y` 之间的人口协方差。 [Float64](../../data-types/float.md)。 **示例** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/covarpopstable.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/covarpopstable.md.hash index 7a2a6908f37..6fdd9b2e246 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/covarpopstable.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/covarpopstable.md.hash @@ -1 +1 @@ -a5f2f66f1382bef3 +b3eac040c6282e2b diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/covarsamp.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/covarsamp.md index 2be6b664bb8..fcf201a57c2 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/covarsamp.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/covarsamp.md @@ -1,8 +1,9 @@ --- -'description': '计算 `Σ((x - x̄)(y - ȳ)) / (n - 1)` 的值' +'description': "计算值为 `\x03a3((x - x\x0305)(y - y\x0305)) / (n - 1)`" 'sidebar_position': 124 'slug': '/sql-reference/aggregate-functions/reference/covarsamp' 'title': 'covarSamp' +'doc_type': 'reference' --- @@ -11,7 +12,7 @@ 计算 `Σ((x - x̅)(y - y̅)) / (n - 1)` 的值。 :::note -此函数使用了一个数值不稳定的算法。如果您在计算中需要 [数值稳定性](https://en.wikipedia.org/wiki/Numerical_stability),请使用 [`covarSampStable`](../reference/covarsamp.md) 函数。它的计算速度较慢,但提供较低的计算误差。 +此函数使用数值不稳定的算法。如果您需要计算中的 [数值稳定性](https://en.wikipedia.org/wiki/Numerical_stability),请使用 [`covarSampStable`](../reference/covarsamp.md) 函数。它的计算速度较慢,但提供较低的计算误差。 ::: **语法** @@ -22,12 +23,12 @@ covarSamp(x, y) **参数** -- `x` — 第一个变量。[(U)Int*](../../data-types/int-uint.md)、[Float*](../../data-types/float.md)、[Decimal](../../data-types/decimal.md)。 -- `y` — 第二个变量。[(U)Int*](../../data-types/int-uint.md)、[Float*](../../data-types/float.md)、[Decimal](../../data-types/decimal.md)。 +- `x` — 第一个变量。 [(U)Int*](../../data-types/int-uint.md), [Float*](../../data-types/float.md), [Decimal](../../data-types/decimal.md)。 +- `y` — 第二个变量。 [(U)Int*](../../data-types/int-uint.md), [Float*](../../data-types/float.md), [Decimal](../../data-types/decimal.md)。 **返回值** -- `x` 和 `y` 之间的样本协方差。当 `n <= 1` 时,返回 `nan`。[Float64](../../data-types/float.md)。 +- `x` 和 `y` 之间的样本协方差。当 `n <= 1` 时,返回 `nan`。 [Float64](../../data-types/float.md)。 **示例** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/covarsamp.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/covarsamp.md.hash index 089d4dae7e8..66a529e1732 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/covarsamp.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/covarsamp.md.hash @@ -1 +1 @@ -8b8ab4f73a265a45 +1ec8d3ce3d97e53c diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/covarsampmatrix.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/covarsampmatrix.md index ce1a1fda8e0..21b568d05ab 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/covarsampmatrix.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/covarsampmatrix.md @@ -3,6 +3,7 @@ 'sidebar_position': 125 'slug': '/sql-reference/aggregate-functions/reference/covarsampmatrix' 'title': 'covarSampMatrix' +'doc_type': 'reference' --- diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/covarsampmatrix.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/covarsampmatrix.md.hash index 5fa7bd7b855..26a70e8afb1 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/covarsampmatrix.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/covarsampmatrix.md.hash @@ -1 +1 @@ -2994021ee38f9289 +441d5dda704b9dac diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/covarsampstable.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/covarsampstable.md index 8f972f86401..4bd9c03fccc 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/covarsampstable.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/covarsampstable.md @@ -1,14 +1,15 @@ --- -'description': '类似于 covarSamp,但工作速度较慢,同时提供较低的计算误差。' +'description': '类似于 covarSamp,但速度更慢,同时提供更低的计算误差。' 'sidebar_position': 126 'slug': '/sql-reference/aggregate-functions/reference/covarsampstable' 'title': 'covarSampStable' +'doc_type': 'reference' --- # covarSampStable -计算 `Σ((x - x̅)(y - y̅)) / (n - 1)` 的值。与 [covarSamp](../reference/covarsamp.md) 类似,但速度较慢,提供更低的计算误差。 +计算 `Σ((x - x̅)(y - y̅)) / (n - 1)` 的值。与 [covarSamp](../reference/covarsamp.md) 类似,但在提供更低的计算误差的同时工作速度较慢。 **语法** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/covarsampstable.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/covarsampstable.md.hash index b5d8069a1ca..ce38781836d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/covarsampstable.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/covarsampstable.md.hash @@ -1 +1 @@ -f652cac4d11dd101 +0cab4e73e8b97768 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/cramersv.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/cramersv.md index 19586d16424..a5e32402df5 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/cramersv.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/cramersv.md @@ -1,17 +1,18 @@ --- -'description': '`cramersV` 函数的结果范围从 0(对应于变量之间没有关联)到 1,并且仅当每个值完全由另一个值决定时才能达到 1。它可以被视为两个变量之间的关联作为其最大可能变化的百分比。' +'description': '`cramersV` 函数的结果范围从 0(对应于变量之间没有关联)到 1,只有在每个值完全由另一个确定时才能达到 1。它可以被视为两个变量之间的关联,以它们最大可能变异的百分比表示。' 'sidebar_position': 127 'slug': '/sql-reference/aggregate-functions/reference/cramersv' 'title': 'cramersV' +'doc_type': 'reference' --- # cramersV -[Cramer's V](https://en.wikipedia.org/wiki/Cram%C3%A9r%27s_V)(有时称为 Cramer's phi)是一个衡量表中两列之间关联性的指标。`cramersV` 函数的结果范围从 0(表示变量之间没有关联)到 1,只有当每个值完全由另一个值决定时,结果才能达到 1。它可以被视为两个变量之间的关联程度,占其最大可能变化的百分比。 +[Cramer's V](https://en.wikipedia.org/wiki/Cram%C3%A9r%27s_V)(有时称为 Cramer's phi)是衡量表中两列之间关联性的指标。`cramersV` 函数的结果范围从 0(表示变量之间没有关联)到 1,只有在每个值完全由另一个值确定时才可能达到 1。它可以被视为两个变量之间的关联程度,作为其最大可能变异的百分比。 :::note -有关 Cramer's V 的偏差修正版本,请参见:[cramersVBiasCorrected](./cramersvbiascorrected.md) +有关 Cramer's V 的偏差校正版本,请参阅: [cramersVBiasCorrected](./cramersvbiascorrected.md) ::: **语法** @@ -22,18 +23,18 @@ cramersV(column1, column2) **参数** -- `column1`: 第一个要比较的列。 -- `column2`: 第二个要比较的列。 +- `column1`:要比较的第一列。 +- `column2`:要比较的第二列。 **返回值** -- 一个值在 0(对应于列值之间没有关联)到 1(完全关联)之间。 +- 一个值在 0(表示列值之间没有关联)到 1(完全关联)之间。 -类型:始终是 [Float64](../../../sql-reference/data-types/float.md)。 +类型:始终为 [Float64](../../../sql-reference/data-types/float.md)。 **示例** -下面比较的两个列之间没有关联,因此 `cramersV` 的结果为 0: +以下比较的两列彼此之间没有关联,因此 `cramersV` 的结果为 0: 查询: @@ -58,7 +59,7 @@ FROM └────────────────┘ ``` -以下两个列之间的关联相当密切,因此 `cramersV` 的结果为较高的值: +以下的两列之间有相当紧密的关联,因此 `cramersV` 的结果是一个较高的值: ```sql SELECT diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/cramersv.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/cramersv.md.hash index 32aebf13538..11f5dac75ed 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/cramersv.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/cramersv.md.hash @@ -1 +1 @@ -5755be6a06661e77 +0234fac42640aacf diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/cramersvbiascorrected.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/cramersvbiascorrected.md index c599845fa6e..9557a1d1e2e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/cramersvbiascorrected.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/cramersvbiascorrected.md @@ -1,14 +1,15 @@ --- -'description': '计算 Cramer''s V,但使用偏差修正。' +'description': '计算 Cramer''s V,但使用偏差校正。' 'sidebar_position': 128 'slug': '/sql-reference/aggregate-functions/reference/cramersvbiascorrected' 'title': 'cramersVBiasCorrected' +'doc_type': 'reference' --- # cramersVBiasCorrected -Cramer's V 是一个衡量表中两列之间关联性的指标。[`cramersV` 函数](./cramersv.md)的结果范围从 0(对应于变量之间没有关联)到 1,只有在每个值完全由另一个值确定时,结果才能达到 1。该函数可能会受到严重偏倚,因此这个版本的 Cramer's V 使用了 [偏倚校正](https://en.wikipedia.org/wiki/Cram%C3%A9r%27s_V#Bias_correction)。 +Cramer's V 是衡量表中两个列之间关联性的度量。[`cramersV` 函数](./cramersv.md)的结果范围从 0(表示变量之间没有关联)到 1,只有当每个值完全被另一个值决定时才能达到 1。该函数可能存在严重偏差,因此这个版本的 Cramer's V 使用了 [偏差修正](https://en.wikipedia.org/wiki/Cram%C3%A9r%27s_V#Bias_correction)。 **语法** @@ -18,8 +19,8 @@ cramersVBiasCorrected(column1, column2) **参数** -- `column1`: 第一个待比较的列。 -- `column2`: 第二个待比较的列。 +- `column1`: 第一个要比较的列。 +- `column2`: 第二个要比较的列。 **返回值** @@ -29,7 +30,7 @@ cramersVBiasCorrected(column1, column2) **示例** -下面比较的两个列之间关联性较小。请注意 `cramersVBiasCorrected` 的结果小于 `cramersV` 的结果: +以下比较的两个列之间的关联性较小。注意 `cramersVBiasCorrected` 的结果小于 `cramersV` 的结果: 查询: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/cramersvbiascorrected.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/cramersvbiascorrected.md.hash index 183a1cac4e5..2c4955db6d0 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/cramersvbiascorrected.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/cramersvbiascorrected.md.hash @@ -1 +1 @@ -12a7bae975b3a81f +bcf7ef60bbcfeb86 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/deltasum.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/deltasum.md index 3a462aa8698..1b101974a8f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/deltasum.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/deltasum.md @@ -1,17 +1,18 @@ --- -'description': '对连续行之间的算术差进行求和。' +'description': '计算连续行之间的算术差的总和。' 'sidebar_position': 129 'slug': '/sql-reference/aggregate-functions/reference/deltasum' 'title': 'deltaSum' +'doc_type': 'reference' --- # deltaSum -计算连续行之间的算术差。如果差值为负,则会被忽略。 +对连续行之间的算术差值进行求和。如果差值为负,则会被忽略。 :::note -底层数据必须经过排序才能正确使用此函数。如果您希望在 [物化视图](/sql-reference/statements/create/view#materialized-view) 中使用此函数,您可能更想使用 [deltaSumTimestamp](/sql-reference/aggregate-functions/reference/deltasumtimestamp) 方法。 +底层数据必须已经排序,以确保此函数正常工作。如果您想在 [物化视图](/sql-reference/statements/create/view#materialized-view) 中使用此函数,您更可能希望使用 [deltaSumTimestamp](/sql-reference/aggregate-functions/reference/deltasumtimestamp) 方法。 ::: **语法** @@ -26,7 +27,7 @@ deltaSum(value) **返回值** -- 返回一个 `Integer` 或 `Float` 类型的算术差值。 +- 得到的算术差值,为 `Integer` 或 `Float` 类型。 **示例** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/deltasum.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/deltasum.md.hash index 163afa8858b..3800119ba89 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/deltasum.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/deltasum.md.hash @@ -1 +1 @@ -f8e60ee3a77299a1 +12e9471a5476ddce diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/deltasumtimestamp.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/deltasumtimestamp.md index ecb7bde94c4..861643963d0 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/deltasumtimestamp.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/deltasumtimestamp.md @@ -1,15 +1,16 @@ --- -'description': '添加连续行之间的差异。如果差异为负,则被忽略。' +'description': '添加连续行之间的差异。如果差异为负,则忽略它。' 'sidebar_position': 130 'slug': '/sql-reference/aggregate-functions/reference/deltasumtimestamp' 'title': 'deltaSumTimestamp' +'doc_type': 'reference' --- -添加连续行之间的差值。如果差值为负,则被忽略。 +将连续行之间的差值相加。如果差值为负,则被忽略。 -此函数主要用于 [物化视图](/sql-reference/statements/create/view#materialized-view),其存储的数据按某个时间桶对齐的时间戳排序,例如 `toStartOfMinute` 桶。由于在此类物化视图中,所有行都将具有相同的时间戳,因此在没有存储原始未舍入时间戳值的情况下,无法按正确顺序合并它们。`deltaSumTimestamp` 函数跟踪其所见值的原始 `timestamp`,以便在合并分区片段时正确计算函数的值(状态)。 +该函数主要用于存储按某个时间段对齐的时间戳顺序排列的数据的 [物化视图](/sql-reference/statements/create/view#materialized-view),例如,`toStartOfMinute` 桶。由于这样的物化视图中的行将具有相同的时间戳,因此在不存储原始的未四舍五入时间戳值的情况下,无法以正确的顺序合并它们。`deltaSumTimestamp` 函数跟踪它所见的值的原始 `timestamp`,因此在分区片段合并期间,函数的值(状态)被正确计算。 -要计算有序集合的增量和,您可以简单地使用 [deltaSum](/sql-reference/aggregate-functions/reference/deltasum) 函数。 +要计算有序集合的增量和,可以简单地使用 [deltaSum](/sql-reference/aggregate-functions/reference/deltasum) 函数。 **语法** @@ -19,14 +20,14 @@ deltaSumTimestamp(value, timestamp) **参数** -- `value` — 输入值,必须是某种 [Integer](../../data-types/int-uint.md) 类型或 [Float](../../data-types/float.md) 类型,或是 [Date](../../data-types/date.md) 或 [DateTime](../../data-types/datetime.md)。 -- `timestamp` — 用于值排序的参数,必须是某种 [Integer](../../data-types/int-uint.md) 类型或 [Float](../../data-types/float.md) 类型,或是 [Date](../../data-types/date.md) 或 [DateTime](../../data-types/datetime.md)。 +- `value` — 输入值,必须是某种 [整数](../../data-types/int-uint.md) 类型或 [浮点数](../../data-types/float.md) 类型,或 [日期](../../data-types/date.md) 或 [日期时间](../../data-types/datetime.md)。 +- `timestamp` — 用于排序值的参数,必须是某种 [整数](../../data-types/int-uint.md) 类型或 [浮点数](../../data-types/float.md) 类型,或 [日期](../../data-types/date.md) 或 [日期时间](../../data-types/datetime.md)。 **返回值** -- 连续值之间的累积差,按 `timestamp` 参数排序。 +- 按 `timestamp` 参数排序的连续值之间的累积差异。 -类型: [Integer](../../data-types/int-uint.md) 或 [Float](../../data-types/float.md) 或 [Date](../../data-types/date.md) 或 [DateTime](../../data-types/datetime.md)。 +类型: [整数](../../data-types/int-uint.md) 或 [浮点数](../../data-types/float.md) 或 [日期](../../data-types/date.md) 或 [日期时间](../../data-types/datetime.md)。 **示例** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/deltasumtimestamp.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/deltasumtimestamp.md.hash index 555fe7e2630..6e7bb26c152 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/deltasumtimestamp.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/deltasumtimestamp.md.hash @@ -1 +1 @@ -fa221afdd2d3a1e5 +210a9f37f66a932b diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/distinctdynamictypes.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/distinctdynamictypes.md index b8744e11a67..bd1e916ed97 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/distinctdynamictypes.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/distinctdynamictypes.md @@ -1,8 +1,9 @@ --- -'description': '计算存储在 Dynamic 列中的不同数据类型的列表。' +'description': '计算存储在 Dynamic 列中的不同数据类型列表。' 'sidebar_position': 215 'slug': '/sql-reference/aggregate-functions/reference/distinctdynamictypes' 'title': 'distinctDynamicTypes' +'doc_type': 'reference' --- diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/distinctdynamictypes.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/distinctdynamictypes.md.hash index db86a541171..1ba805c8c21 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/distinctdynamictypes.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/distinctdynamictypes.md.hash @@ -1 +1 @@ -d07c225b8aaa76be +271776c208ce4e09 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/distinctjsonpaths.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/distinctjsonpaths.md index 416ec99ec7e..ea8ee2af9bc 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/distinctjsonpaths.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/distinctjsonpaths.md @@ -1,8 +1,9 @@ --- -'description': '计算存储在 JSON 列中的不同路径列表。' +'description': '计算存储在 JSON 列中的不同路径的列表。' 'sidebar_position': 216 'slug': '/sql-reference/aggregate-functions/reference/distinctjsonpaths' 'title': 'distinctJSONPaths' +'doc_type': 'reference' --- @@ -89,7 +90,7 @@ SELECT distinctJSONPathsAndTypes(json) FROM test_json; **注意** -如果 JSON 声明包含指定类型的路径,即使输入数据没有这些路径的值,这些路径也将始终包含在 `distinctJSONPaths/distinctJSONPathsAndTypes` 函数的结果中。 +如果 JSON 声明包含指定类型的路径,这些路径将始终包含在 `distinctJSONPaths/distinctJSONPathsAndTypes` 函数的结果中,即使输入数据没有这些路径的值。 ```sql DROP TABLE IF EXISTS test_json; diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/distinctjsonpaths.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/distinctjsonpaths.md.hash index d47f36b956c..e67c000a0ca 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/distinctjsonpaths.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/distinctjsonpaths.md.hash @@ -1 +1 @@ -60ab65c355da045e +532357e4b867b8fd diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/entropy.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/entropy.md index e2a14d0fe55..aeef863459f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/entropy.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/entropy.md @@ -1,14 +1,15 @@ --- -'description': '计算一列值的香农熵。' +'description': '计算一列值的 Shannon entropy。' 'sidebar_position': 131 'slug': '/sql-reference/aggregate-functions/reference/entropy' -'title': 'entropy' +'title': '熵' +'doc_type': 'reference' --- # entropy -计算列值的 [Shannon 熵](https://en.wikipedia.org/wiki/Entropy_(information_theory))。 +计算列值的 [Shannon entropy](https://en.wikipedia.org/wiki/Entropy_(information_theory))。 **语法** @@ -18,17 +19,17 @@ entropy(val) **参数** -- `val` — 任何类型的值的列。 +- `val` — 任意类型的值列。 **返回值** -- Shannon 熵。 +- Shannon entropy。 类型: [Float64](../../../sql-reference/data-types/float.md)。 **示例** -查询: +查询: ```sql CREATE TABLE entropy (`vals` UInt32,`strings` String) ENGINE = Memory; @@ -38,7 +39,7 @@ INSERT INTO entropy VALUES (1, 'A'), (1, 'A'), (1,'A'), (1,'A'), (2,'B'), (2,'B' SELECT entropy(vals), entropy(strings) FROM entropy; ``` -结果: +结果: ```text ┌─entropy(vals)─┬─entropy(strings)─┐ diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/entropy.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/entropy.md.hash index 4e9cb4f2f04..51ce1c09055 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/entropy.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/entropy.md.hash @@ -1 +1 @@ -896d984e78513151 +ec859a445440482b diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/estimateCompressionRatio.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/estimateCompressionRatio.md index d0d8b1d554c..3a4ba8d29a2 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/estimateCompressionRatio.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/estimateCompressionRatio.md @@ -3,11 +3,12 @@ 'sidebar_position': 132 'slug': '/sql-reference/aggregate-functions/reference/estimateCompressionRatio' 'title': 'estimateCompressionRatio' +'doc_type': 'reference' --- ## estimateCompressionRatio {#estimatecompressionration} -估算给定列的压缩比,而无需实际压缩。 +估计给定列的压缩比,而不进行实际压缩。 **语法** @@ -17,18 +18,18 @@ estimateCompressionRatio(codec, block_size_bytes)(column) **参数** -- `column` - 任何类型的列 +- `column` - 任意类型的列 **参数** -- `codec` - 包含 [压缩编解码器](/sql-reference/statements/create/table#column_compression_codec) 的 [字符串](../../../sql-reference/data-types/string.md) 或多个以逗号分隔的编解码器的单个字符串。 +- `codec` - 包含一个 [压缩编解码器](/sql-reference/statements/create/table#column_compression_codec) 的 [String](../../../sql-reference/data-types/string.md) 或多个用逗号分隔的编解码器的字符串。 - `block_size_bytes` - 压缩数据的块大小。这类似于同时设置 [`max_compress_block_size`](../../../operations/settings/merge-tree-settings.md#max_compress_block_size) 和 [`min_compress_block_size`](../../../operations/settings/merge-tree-settings.md#min_compress_block_size)。默认值为 1 MiB (1048576 字节)。 -这两个参数都是可选的。 +两个参数都是可选的。 **返回值** -- 返回给定列的估算压缩比。 +- 返回给定列的估计压缩比。 类型: [Float64](/sql-reference/data-types/float)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/estimateCompressionRatio.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/estimateCompressionRatio.md.hash index 9ba28cf91c1..3ba6cf4d50f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/estimateCompressionRatio.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/estimateCompressionRatio.md.hash @@ -1 +1 @@ -2bd178d37335ddb9 +3f416ebe3a155ade diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/exponentialmovingaverage.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/exponentialmovingaverage.md index b9c0fd0aa2a..6a759ee99bd 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/exponentialmovingaverage.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/exponentialmovingaverage.md @@ -1,13 +1,14 @@ --- -'description': '计算在确定时间内的值的指数移动平均。' +'description': '计算在确定时间内值的指数移动平均。' 'sidebar_position': 132 'slug': '/sql-reference/aggregate-functions/reference/exponentialMovingAverage' -'title': '指数移动平均' +'title': 'exponentialMovingAverage' +'doc_type': 'reference' --- ## exponentialMovingAverage {#exponentialmovingaverage} -计算确定时间内值的指数移动平均值。 +计算在确定时间内值的指数移动平均。 **语法** @@ -15,22 +16,22 @@ exponentialMovingAverage(x)(value, timeunit) ``` -每个 `value` 对应于确定的 `timeunit`。半衰期 `x` 是指数权重减半的时间滞后。该函数返回加权平均值:时间点越旧,相应值的权重被认为越小。 +每个 `value` 对应于确定的 `timeunit`。半衰期 `x` 是指数权重衰减到一半的时间延迟。该函数返回加权平均值:时间点越旧,考虑的对应值的权重就越小。 **参数** -- `value` — 值。 [整数](../../../sql-reference/data-types/int-uint.md)、[浮点数](../../../sql-reference/data-types/float.md) 或 [十进制数](../../../sql-reference/data-types/decimal.md)。 -- `timeunit` — 时间单位。 [整数](../../../sql-reference/data-types/int-uint.md)、[浮点数](../../../sql-reference/data-types/float.md) 或 [十进制数](../../../sql-reference/data-types/decimal.md)。时间单位不是时间戳(秒),它是时间间隔的索引。可以使用 [intDiv](/sql-reference/functions/arithmetic-functions#intdiv) 计算。 +- `value` — 值。 [整数](../../../sql-reference/data-types/int-uint.md), [浮点数](../../../sql-reference/data-types/float.md) 或 [小数](../../../sql-reference/data-types/decimal.md)。 +- `timeunit` — 时间单位。[整数](../../../sql-reference/data-types/int-uint.md), [浮点数](../../../sql-reference/data-types/float.md) 或 [小数](../../../sql-reference/data-types/decimal.md)。时间单位不是时间戳(秒),而是时间间隔的索引。可以使用 [intDiv](/sql-reference/functions/arithmetic-functions#intDiv) 进行计算。 **参数** -- `x` — 半衰期。 [整数](../../../sql-reference/data-types/int-uint.md)、[浮点数](../../../sql-reference/data-types/float.md) 或 [十进制数](../../../sql-reference/data-types/decimal.md)。 +- `x` — 半衰期。 [整数](../../../sql-reference/data-types/int-uint.md), [浮点数](../../../sql-reference/data-types/float.md) 或 [小数](../../../sql-reference/data-types/decimal.md)。 **返回值** -- 返回过去 `x` 时间内值的 [指数平滑移动平均](https://en.wikipedia.org/wiki/Moving_average#Exponential_moving_average),以最新时间点为准。 +- 返回过去 `x` 时间在最新时间点的值的 [指数平滑移动平均](https://en.wikipedia.org/wiki/Moving_average#Exponential_moving_average)。 -类型: [Float64](/sql-reference/data-types/float)。 +类型:[Float64](/sql-reference/data-types/float)。 **示例** @@ -157,8 +158,6 @@ SELECT 10 AS value, toDateTime('2020-01-01') + (3600 * number) AS time FROM numbers_mt(10); - - -- Calculate timeunit using intDiv SELECT value, @@ -180,8 +179,6 @@ ORDER BY time ASC; │ 10 │ 2020-01-01 08:00:00 │ 9.98046875 │ 438296 │ │ 10 │ 2020-01-01 09:00:00 │ 9.990234375 │ 438297 │ └───────┴─────────────────────┴─────────────┴──────────┘ - - -- Calculate timeunit using toRelativeHourNum SELECT value, diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/exponentialmovingaverage.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/exponentialmovingaverage.md.hash index 46873e92857..47c44e05de1 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/exponentialmovingaverage.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/exponentialmovingaverage.md.hash @@ -1 +1 @@ -1741607536b37c00 +cd06b0c7e0ed45da diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/exponentialtimedecayedavg.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/exponentialtimedecayedavg.md index c86e5d32780..6f74159f645 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/exponentialtimedecayedavg.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/exponentialtimedecayedavg.md @@ -1,8 +1,9 @@ --- -'description': '返回时间序列在时间点 `t` 处值的指数平滑加权移动平均。' +'description': '返回时间序列在时间点 `t` 的值的指数平滑加权移动平均。' 'sidebar_position': 133 'slug': '/sql-reference/aggregate-functions/reference/exponentialTimeDecayedAvg' 'title': 'exponentialTimeDecayedAvg' +'doc_type': 'reference' --- ## exponentialTimeDecayedAvg {#exponentialtimedecayedavg} @@ -18,15 +19,15 @@ exponentialTimeDecayedAvg(x)(v, t) **参数** - `v` — 值。 [整数](../../../sql-reference/data-types/int-uint.md)、[浮点数](../../../sql-reference/data-types/float.md) 或 [十进制](../../../sql-reference/data-types/decimal.md)。 -- `t` — 时间。 [整数](../../../sql-reference/data-types/int-uint.md)、[浮点数](../../../sql-reference/data-types/float.md) 或 [十进制](../../../sql-reference/data-types/decimal.md)、[日期时间](../../data-types/datetime.md)、[DateTime64](../../data-types/datetime64.md)。 +- `t` — 时间。 [整数](../../../sql-reference/data-types/int-uint.md)、[浮点数](../../../sql-reference/data-types/float.md) 或 [十进制](../../../sql-reference/data-types/decimal.md)、[日期时间](../../data-types/datetime.md)、[日期时间64](../../data-types/datetime64.md)。 -**参数说明** +**参数** - `x` — 半衰期。 [整数](../../../sql-reference/data-types/int-uint.md)、[浮点数](../../../sql-reference/data-types/float.md) 或 [十进制](../../../sql-reference/data-types/decimal.md)。 **返回值** -- 返回时间点 `t` 的指数平滑加权移动平均值。 [Float64](../../data-types/float.md)。 +- 返回时间索引 `t` 处的指数平滑加权移动平均值。 [Float64](../../data-types/float.md)。 **示例** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/exponentialtimedecayedavg.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/exponentialtimedecayedavg.md.hash index 033cd0b6178..414d9b529b7 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/exponentialtimedecayedavg.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/exponentialtimedecayedavg.md.hash @@ -1 +1 @@ -0a6c39444ea4d793 +f2fa430de32ab2dc diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/exponentialtimedecayedcount.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/exponentialtimedecayedcount.md index 32e6ae1ea2a..7ae4d7761f8 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/exponentialtimedecayedcount.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/exponentialtimedecayedcount.md @@ -1,13 +1,14 @@ --- -'description': '返回时间序列在索引 `t` 处的累积指数衰减。' +'description': '返回时间序列中索引 `t` 的累积指数衰减。' 'sidebar_position': 134 'slug': '/sql-reference/aggregate-functions/reference/exponentialTimeDecayedCount' 'title': 'exponentialTimeDecayedCount' +'doc_type': 'reference' --- ## exponentialTimeDecayedCount {#exponentialtimedecayedcount} -返回时间序列在时间索引 `t` 上的累积指数衰减。 +返回时间序列在时间索引 `t` 处的累计指数衰减。 **语法** @@ -25,7 +26,7 @@ exponentialTimeDecayedCount(x)(t) **返回值** -- 返回给定时间点上的累积指数衰减。 [Float64](../../data-types/float.md)。 +- 返回给定时间点的累计指数衰减。 [Float64](../../data-types/float.md)。 **示例** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/exponentialtimedecayedcount.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/exponentialtimedecayedcount.md.hash index d218d9947a7..dc08f96c7b4 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/exponentialtimedecayedcount.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/exponentialtimedecayedcount.md.hash @@ -1 +1 @@ -6cb5ab3c59bdb44f +b783f772595588d2 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/exponentialtimedecayedmax.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/exponentialtimedecayedmax.md index a4489aa21a3..a3de3dbad18 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/exponentialtimedecayedmax.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/exponentialtimedecayedmax.md @@ -1,13 +1,14 @@ --- -'description': '返回在时间 `t` 计算出的指数平滑移动平均值与 `t-1` 处的最大值。' +'description': '返回时间上在索引 `t` 处计算的指数平滑移动平均值与 `t-1` 的最大值。' 'sidebar_position': 135 'slug': '/sql-reference/aggregate-functions/reference/exponentialTimeDecayedMax' 'title': 'exponentialTimeDecayedMax' +'doc_type': 'reference' --- ## exponentialTimeDecayedMax {#exponentialtimedecayedmax} -返回在时间索引 `t` 处计算的指数平滑移动平均值与 `t-1` 处的最大值。 +返回指数平滑移动平均在时间索引 `t` 处的最大值与在 `t-1` 处的最大值。 **语法** @@ -18,7 +19,7 @@ exponentialTimeDecayedMax(x)(value, timeunit) **参数** - `value` — 值。 [整数](../../../sql-reference/data-types/int-uint.md)、[浮点数](../../../sql-reference/data-types/float.md) 或 [十进制](../../../sql-reference/data-types/decimal.md)。 -- `timeunit` — 时间单位。[整数](../../../sql-reference/data-types/int-uint.md)、[浮点数](../../../sql-reference/data-types/float.md) 或 [十进制](../../../sql-reference/data-types/decimal.md),[日期时间](../../data-types/datetime.md)、[日期时间64](../../data-types/datetime64.md)。 +- `timeunit` — 时间单位。 [整数](../../../sql-reference/data-types/int-uint.md)、[浮点数](../../../sql-reference/data-types/float.md) 或 [十进制](../../../sql-reference/data-types/decimal.md), [日期时间](../../data-types/datetime.md)、[日期时间64](../../data-types/datetime64.md)。 **参数** @@ -26,7 +27,7 @@ exponentialTimeDecayedMax(x)(value, timeunit) **返回值** -- 返回在 `t` 和 `t-1` 处的指数平滑加权移动平均值的最大值。 [Float64](../../data-types/float.md)。 +- 返回在 `t` 和 `t-1` 处指数平滑加权移动平均的最大值。 [Float64](../../data-types/float.md)。 **示例** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/exponentialtimedecayedmax.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/exponentialtimedecayedmax.md.hash index 56311e16a4e..739c6b1e4da 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/exponentialtimedecayedmax.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/exponentialtimedecayedmax.md.hash @@ -1 +1 @@ -26ec397e080b3202 +4ba1acbdd9385133 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/exponentialtimedecayedsum.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/exponentialtimedecayedsum.md index bbab3135d8a..45c1cc5b2fc 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/exponentialtimedecayedsum.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/exponentialtimedecayedsum.md @@ -1,13 +1,14 @@ --- -'description': '返回指数平滑移动平均值的和,时间序列在索引 `t` 的时间上。' +'description': '返回时间序列在索引 `t` 处的指数平滑移动平均值的总和。' 'sidebar_position': 136 'slug': '/sql-reference/aggregate-functions/reference/exponentialTimeDecayedSum' 'title': 'exponentialTimeDecayedSum' +'doc_type': 'reference' --- ## exponentialTimeDecayedSum {#exponentialtimedecayedsum} -返回时间序列在索引 `t` 处的指数平滑移动平均值的总和。 +返回时间序列在时间索引 `t` 处的指数平滑移动平均值的总和。 **语法** @@ -22,7 +23,7 @@ exponentialTimeDecayedSum(x)(v, t) **参数** -- `x` — 半衰期。 [整数](../../../sql-reference/data-types/int-uint.md)、[浮点数](../../../sql-reference/data-types/float.md) 或 [十进制](../../../sql-reference/data-types/decimal.md)。 +- `x` — 值的权重衰减到 1/e 所需的时间差。 [整数](../../../sql-reference/data-types/int-uint.md)、[浮点数](../../../sql-reference/data-types/float.md) 或 [十进制](../../../sql-reference/data-types/decimal.md)。 **返回值** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/exponentialtimedecayedsum.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/exponentialtimedecayedsum.md.hash index bc61f97ccfb..8920e8b96cf 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/exponentialtimedecayedsum.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/exponentialtimedecayedsum.md.hash @@ -1 +1 @@ -63b86fde9dc7c6a8 +e083c91b7e64b344 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/first_value.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/first_value.md index e592d1f0298..fa0e3be2310 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/first_value.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/first_value.md @@ -1,19 +1,20 @@ --- -'description': '它是任何的别名,但它是为与窗口函数的兼容性而引入的,在这里有时需要处理 `NULL` 值(默认情况下,所有 ClickHouse 聚合函数会忽略 +'description': '它是任何的别名,但它是为了与窗口函数的兼容性而引入的,有时需要处理 `NULL` 值(默认情况下,所有 ClickHouse 聚合函数会忽略 NULL 值)。' 'sidebar_position': 137 'slug': '/sql-reference/aggregate-functions/reference/first_value' 'title': 'first_value' +'doc_type': 'reference' --- # first_value -它是 [`any`](../../../sql-reference/aggregate-functions/reference/any.md) 的别名,但它是为了与 [Window Functions](../../window-functions/index.md) 兼容而引入的,在某些情况下,必须处理 `NULL` 值(默认情况下,所有 ClickHouse 聚合函数会忽略 NULL 值)。 +它是 [`any`](../../../sql-reference/aggregate-functions/reference/any.md) 的别名,但它的引入是为了与 [Window Functions](../../window-functions/index.md) 兼容,有时需要处理 `NULL` 值(默认情况下,所有 ClickHouse 聚合函数会忽略 NULL 值)。 -它支持声明修饰符以尊重 NULL 值(`RESPECT NULLS`),可在 [Window Functions](../../window-functions/index.md) 和普通聚合中使用。 +它支持声明一个修饰符以尊重 NULL 值(`RESPECT NULLS`),在 [Window Functions](../../window-functions/index.md) 和普通聚合中均适用。 -与 `any` 一样,如果没有 Window Functions,结果将是随机的,如果源流未排序且返回类型与输入类型匹配(仅在输入为 Nullable 或添加了 -OrNull 组合器的情况下返回 Null)。 +与 `any` 一样,在没有 Window Functions 的情况下,如果源流未排序并且返回类型与输入类型匹配,结果将是随机的(仅在输入为 Nullable 或添加了 -OrNull 组合时返回 Null)。 ## examples {#examples} @@ -25,13 +26,13 @@ CREATE TABLE test_data ) ENGINE = Memory; -INSERT INTO test_data (a, b) Values (1,null), (2,3), (4, 5), (6,null); +INSERT INTO test_data (a, b) VALUES (1,null), (2,3), (4, 5), (6,null); ``` -### example1 {#example1} +### Example 1 {#example1} 默认情况下,NULL 值被忽略。 ```sql -select first_value(b) from test_data; +SELECT first_value(b) FROM test_data; ``` ```text @@ -40,10 +41,10 @@ select first_value(b) from test_data; └────────┘ ``` -### example2 {#example2} +### Example 2 {#example2} NULL 值被忽略。 ```sql -select first_value(b) ignore nulls from test_data +SELECT first_value(b) ignore nulls FROM test_data ``` ```text @@ -52,10 +53,10 @@ select first_value(b) ignore nulls from test_data └──────────────────────┘ ``` -### example3 {#example3} -NULL 值被接受。 +### Example 3 {#example3} +接受 NULL 值。 ```sql -select first_value(b) respect nulls from test_data +SELECT first_value(b) respect nulls FROM test_data ``` ```text @@ -64,7 +65,7 @@ select first_value(b) respect nulls from test_data └───────────────────────┘ ``` -### example4 {#example4} +### Example 4 {#example4} 使用 `ORDER BY` 的子查询稳定化结果。 ```sql SELECT diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/first_value.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/first_value.md.hash index ec403e49616..7e04fb537a3 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/first_value.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/first_value.md.hash @@ -1 +1 @@ -d7b50b5557b303c7 +d2f5109ae1e0ba90 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/flame_graph.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/flame_graph.md index 46dc54345de..146a1912141 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/flame_graph.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/flame_graph.md @@ -1,14 +1,15 @@ --- -'description': '聚合函数,它使用堆栈跟踪列表构建一个 flamegraph。' +'description': '聚合函数,用于使用堆栈跟踪列表构建 flamegraph。' 'sidebar_position': 138 'slug': '/sql-reference/aggregate-functions/reference/flame_graph' 'title': 'flameGraph' +'doc_type': 'reference' --- # flameGraph -聚合函数,使用堆栈跟踪列表构建一个 [flamegraph](https://www.brendangregg.com/flamegraphs.html)。输出一个字符串数组,可由 [flamegraph.pl utility](https://github.com/brendangregg/FlameGraph) 生成火焰图的 SVG。 +聚合函数,通过堆栈跟踪列表构建一个 [flamegraph](https://www.brendangregg.com/flamegraphs.html)。输出一个字符串数组,可以被 [flamegraph.pl utility](https://github.com/brendangregg/FlameGraph) 用于渲染 flamegraph 的 SVG。 ## Syntax {#syntax} @@ -19,17 +20,17 @@ flameGraph(traces, [size], [ptr]) ## Parameters {#parameters} - `traces` — 一个堆栈跟踪。[Array](../../data-types/array.md)([UInt64](../../data-types/int-uint.md))。 -- `size` — 内存分析的分配大小。(可选 - 默认 `1`。[UInt64](../../data-types/int-uint.md))。 -- `ptr` — 分配地址。(可选 - 默认 `0`。[UInt64](../../data-types/int-uint.md))。 +- `size` — 内存分析的分配大小。(可选 - 默认 `1`)。[UInt64](../../data-types/int-uint.md)。 +- `ptr` — 内存分配地址。(可选 - 默认 `0`)。[UInt64](../../data-types/int-uint.md)。 :::note -当 `ptr != 0` 时,flameGraph 将映射同一大小和 ptr 的分配(size > 0)和释放(size < 0)。 -只显示未释放的分配。未映射的释放被忽略。 +在 `ptr != 0` 的情况下,flameGraph 将使用相同的 size 和 ptr 将分配(size > 0)和释放(size < 0)进行映射。 +只显示未被释放的分配。未映射的释放将被忽略。 ::: ## Returned value {#returned-value} -- 一个字符串数组,可与 [flamegraph.pl utility](https://github.com/brendangregg/FlameGraph) 一起使用。[Array](../../data-types/array.md)([String](../../data-types/string.md))。 +- 一个字符串数组,用于与 [flamegraph.pl utility](https://github.com/brendangregg/FlameGraph) 一起使用。[Array](../../data-types/array.md)([String](../../data-types/string.md))。 ## Examples {#examples} @@ -76,7 +77,7 @@ SELECT SearchPhrase, COUNT(DISTINCT UserID) AS u FROM hits WHERE SearchPhrase <> - 1 - 每秒内存使用情况 ```sql -SELECT event_time, m, formatReadableSize(max(s) as m) FROM (SELECT event_time, sum(size) OVER (ORDER BY event_time) AS s FROM system.trace_log WHERE query_id = 'xxx' AND trace_type = 'MemorySample') GROUP BY event_time ORDER BY event_time; +SELECT event_time, m, formatReadableSize(max(s) AS m) FROM (SELECT event_time, sum(size) OVER (ORDER BY event_time) AS s FROM system.trace_log WHERE query_id = 'xxx' AND trace_type = 'MemorySample') GROUP BY event_time ORDER BY event_time; ``` - 2 - 找到内存使用量最大的时间点 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/flame_graph.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/flame_graph.md.hash index 585e2ba3f65..3a1a243f355 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/flame_graph.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/flame_graph.md.hash @@ -1 +1 @@ -09244a8ca633700b +e1289a2404739d47 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparray.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparray.md index 8a7b9b80f59..395dd688f11 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparray.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparray.md @@ -1,8 +1,9 @@ --- -'description': '创建参数值的数组。值可以以任何(不确定的)顺序添加到数组中。' +'description': '创建一个参数值的数组。值可以以任何(不确定的)顺序添加到数组中。' 'sidebar_position': 139 'slug': '/sql-reference/aggregate-functions/reference/grouparray' 'title': 'groupArray' +'doc_type': 'reference' --- @@ -10,11 +11,11 @@ 语法: `groupArray(x)` 或 `groupArray(max_size)(x)` -创建一个参数值的数组。值可以以任何(不确定的)顺序添加到数组中。 +创建一个包含参数值的数组。值可以以任意(不确定的)顺序添加到数组中。 -第二个版本(带有 `max_size` 参数)将结果数组的大小限制为 `max_size` 个元素。例如,`groupArray(1)(x)` 等价于 `[any (x)]`。 +第二种版本(带有 `max_size` 参数)将生成的数组的大小限制为 `max_size` 元素。例如,`groupArray(1)(x)` 等价于 `[any (x)]`。 -在某些情况下,您仍然可以依赖于执行顺序。这适用于 `SELECT` 来自于一个使用 `ORDER BY` 的子查询,如果子查询结果足够小。 +在某些情况下,您仍然可以依赖执行顺序。这适用于 `SELECT` 来自一个使用 `ORDER BY` 的子查询的情况,前提是子查询结果足够小。 **示例** @@ -33,7 +34,7 @@ SELECT * FROM default.ck; 查询: ```sql -select id, groupArray(10)(name) from default.ck group by id; +SELECT id, groupArray(10)(name) FROM default.ck GROUP BY id; ``` 结果: @@ -45,6 +46,6 @@ select id, groupArray(10)(name) from default.ck group by id; └────┴──────────────────────┘ ``` -groupArray 函数将根据上述结果移除 ᴺᵁᴸᴸ 值。 +根据上述结果,groupArray 函数将删除 ᴺᵁᴸᴸ 值。 - 别名: `array_agg`. diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparray.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparray.md.hash index 067333a401e..4fd99eced5a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparray.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparray.md.hash @@ -1 +1 @@ -0cb267fa42700e93 +adb50eb7d5878b7b diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparrayarray.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparrayarray.md index 1c4a89b289c..f9b020f930c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparrayarray.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparrayarray.md @@ -1,24 +1,25 @@ --- -'description': '将数组聚合成一个更大的包含那些数组的数组。' +'description': '将数组聚合成一个更大的数组,这些数组。' 'keywords': - 'groupArrayArray' - 'array_concat_agg' 'sidebar_position': 111 'slug': '/sql-reference/aggregate-functions/reference/grouparrayarray' 'title': 'groupArrayArray' +'doc_type': 'reference' --- # groupArrayArray -将数组聚合成一个更大的数组,这些数组的组合。 -将 [`groupArray`](/sql-reference/aggregate-functions/reference/grouparray) 函数与 [Array](/sql-reference/aggregate-functions/combinators#-array) 组合器结合使用。 +将数组聚合为一个更大的数组。 +将 [`groupArray`](/sql-reference/aggregate-functions/reference/grouparray) 函数与 [Array](/sql-reference/aggregate-functions/combinators#-array) 合并器结合使用。 别名: `array_concat_agg` **示例** -我们有数据记录用户的浏览会话。每个会话记录特定用户访问的页面序列。 +我们有捕捉用户浏览会话的数据。每个会话记录特定用户访问的页面序列。 我们可以使用 `groupArrayArray` 函数分析每个用户的页面访问模式。 ```sql title="Setup" diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparrayarray.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparrayarray.md.hash index ccf3e756282..3cd53a8e8fe 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparrayarray.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparrayarray.md.hash @@ -1 +1 @@ -996f56a81cf4505f +3eb76ec59f5f023e diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparrayinsertat.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparrayinsertat.md index 7b55a0ce454..b8ebda1deab 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparrayinsertat.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparrayinsertat.md @@ -1,8 +1,9 @@ --- -'description': '在指定位置将值插入数组中。' +'description': '在指定位置将值插入数组。' 'sidebar_position': 140 'slug': '/sql-reference/aggregate-functions/reference/grouparrayinsertat' 'title': 'groupArrayInsertAt' +'doc_type': 'reference' --- @@ -16,23 +17,23 @@ groupArrayInsertAt(default_x, size)(x, pos) ``` -如果在一个查询中有多个值被插入到同一位置,此函数的行为如下: +如果在一个查询中有多个值被插入到同一个位置,该函数的行为如下: -- 如果在单线程中执行查询,则使用插入值中的第一个值。 +- 如果在单线程中执行查询,则使用第一个插入的值。 - 如果在多线程中执行查询,则结果值是插入值中的一个未确定的值。 **参数** -- `x` — 要插入的值。 [表达式](/sql-reference/syntax#expressions),结果为 [支持的数据类型](../../../sql-reference/data-types/index.md) 中的一种。 -- `pos` — 指定元素 `x` 要插入的位置信息。数组中的索引编号从零开始。 [UInt32](/sql-reference/data-types/int-uint#integer-ranges)。 -- `default_x` — 用于替代空位置的默认值。可选参数。 [表达式](/sql-reference/syntax#expressions),结果为与 `x` 参数配置的数据类型。如果未定义 `default_x`,则使用 [默认值](/sql-reference/statements/create/table)。 +- `x` — 要插入的值。 [表达式](/sql-reference/syntax#expressions),结果为支持的数据类型之一 [supported data types](../../../sql-reference/data-types/index.md)。 +- `pos` — 要插入指定元素 `x` 的位置。数组中的索引编号从零开始。 [UInt32](/sql-reference/data-types/int-uint#integer-ranges)。 +- `default_x` — 用于替换空位置的默认值。可选参数。 [表达式](/sql-reference/syntax#expressions),结果为为 `x` 参数配置的数据类型。如果未定义 `default_x`,则使用 [默认值](/sql-reference/statements/create/table)。 - `size` — 结果数组的长度。可选参数。在使用此参数时,必须指定默认值 `default_x`。 [UInt32](/sql-reference/data-types/int-uint#integer-ranges)。 **返回值** - 包含插入值的数组。 -类型: [Array](/sql-reference/data-types/array)。 +类型:[数组](/sql-reference/data-types/array)。 **示例** @@ -78,7 +79,7 @@ SELECT groupArrayInsertAt('-', 5)(toString(number), number * 2) FROM numbers(5); └───────────────────────────────────────────────────────────────────┘ ``` -多线程插入元素到一个位置。 +多线程将元素插入到一个位置。 查询: @@ -86,7 +87,7 @@ SELECT groupArrayInsertAt('-', 5)(toString(number), number * 2) FROM numbers(5); SELECT groupArrayInsertAt(number, 0) FROM numbers_mt(10) SETTINGS max_block_size = 1; ``` -作为此查询的结果,您会得到 `[0,9]` 范围内的随机整数。例如: +作为该查询的结果,你将获得一个范围在 `[0,9]` 内的随机整数。例如: ```text ┌─groupArrayInsertAt(number, 0)─┐ diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparrayinsertat.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparrayinsertat.md.hash index d5ceaa76002..f8068ee4b94 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparrayinsertat.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparrayinsertat.md.hash @@ -1 +1 @@ -f27c8664fdbd23ed +2abd22f56196f782 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparrayintersect.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparrayintersect.md index a8534d2d4de..d0fc3bbffed 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparrayintersect.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparrayintersect.md @@ -3,12 +3,13 @@ 'sidebar_position': 141 'slug': '/sql-reference/aggregate-functions/reference/grouparrayintersect' 'title': 'groupArrayIntersect' +'doc_type': 'reference' --- # groupArrayIntersect -返回给定数组的交集(返回所有在所有给定数组中的项目)。 +返回给定数组的交集(返回在所有给定数组中的所有项目)。 **语法** @@ -22,7 +23,7 @@ groupArrayIntersect(x) **返回值** -- 包含所有数组中元素的数组。 +- 包含在所有数组中的元素的数组。 类型: [Array](../../data-types/array.md)。 @@ -41,7 +42,7 @@ groupArrayIntersect(x) 以列名作为参数的查询: ```sql -SELECT groupArrayIntersect(a) as intersection FROM numbers; +SELECT groupArrayIntersect(a) AS intersection FROM numbers; ``` 结果: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparrayintersect.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparrayintersect.md.hash index 4a00f7ef855..05946a5a686 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparrayintersect.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparrayintersect.md.hash @@ -1 +1 @@ -5c6997cbd272a4e3 +c93519bfb6a99bff diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparraylast.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparraylast.md index f4e7d70fe09..69765653a17 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparraylast.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparraylast.md @@ -3,6 +3,7 @@ 'sidebar_position': 142 'slug': '/sql-reference/aggregate-functions/reference/grouparraylast' 'title': 'groupArrayLast' +'doc_type': 'reference' --- @@ -10,20 +11,20 @@ 语法: `groupArrayLast(max_size)(x)` -创建一个包含最后一个参数值的数组。 -例如,`groupArrayLast(1)(x)` 等价于 `[anyLast (x)]`。 +创建一个包含最后参数值的数组。 +例如,`groupArrayLast(1)(x)` 相当于 `[anyLast (x)]`。 -在某些情况下,您仍然可以依赖执行顺序。这适用于来自使用 `ORDER BY` 的子查询的 `SELECT` 情况,如果子查询结果足够小。 +在某些情况下,您仍然可以依赖执行顺序。这适用于当 `SELECT` 来自一个使用 `ORDER BY` 的子查询,并且子查询结果足够小的情况。 **示例** -查询: +查询: ```sql -select groupArrayLast(2)(number+1) numbers from numbers(10) +SELECT groupArrayLast(2)(number+1) numbers FROM numbers(10) ``` -结果: +结果: ```text ┌─numbers─┐ @@ -31,10 +32,10 @@ select groupArrayLast(2)(number+1) numbers from numbers(10) └─────────┘ ``` -与 `groupArray` 相比: +与 `groupArray` 相比: ```sql -select groupArray(2)(number+1) numbers from numbers(10) +SELECT groupArray(2)(number+1) numbers FROM numbers(10) ``` ```text diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparraylast.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparraylast.md.hash index caf673b52e6..cbc3fcc9380 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparraylast.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparraylast.md.hash @@ -1 +1 @@ -a37cc05e38e1b933 +6f44c7d35f708d26 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparraymovingavg.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparraymovingavg.md index 8c8d8b5c331..1d51c13870d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparraymovingavg.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparraymovingavg.md @@ -3,6 +3,7 @@ 'sidebar_position': 144 'slug': '/sql-reference/aggregate-functions/reference/grouparraymovingavg' 'title': 'groupArrayMovingAvg' +'doc_type': 'reference' --- @@ -15,18 +16,18 @@ groupArrayMovingAvg(numbers_for_summing) groupArrayMovingAvg(window_size)(numbers_for_summing) ``` -该函数可以将窗口大小作为参数。如果未指定,则函数将窗口大小设置为列中的行数。 +该函数可以将窗口大小作为参数。如果未指定,则函数将窗口大小设为列中的行数。 **参数** -- `numbers_for_summing` — [表达式](/sql-reference/syntax#expressions),结果为数值数据类型值。 +- `numbers_for_summing` — [表达式](/sql-reference/syntax#expressions),结果为数值数据类型。 - `window_size` — 计算窗口的大小。 **返回值** - 与输入数据相同大小和类型的数组。 -该函数使用 [朝零舍入](https://en.wikipedia.org/wiki/Rounding#Rounding_towards_zero)。它会截断对于结果数据类型无意义的小数位。 +该函数使用 [向零取整](https://en.wikipedia.org/wiki/Rounding#Rounding_towards_zero)。它会截断与结果数据类型不相关的小数位。 **示例** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparraymovingavg.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparraymovingavg.md.hash index 1fe5de07267..49ca375d137 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparraymovingavg.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparraymovingavg.md.hash @@ -1 +1 @@ -b85fc7e3dfef858d +897592d607c0e5e1 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparraymovingsum.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparraymovingsum.md index e82e395371e..c3bf550dc8a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparraymovingsum.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparraymovingsum.md @@ -3,28 +3,29 @@ 'sidebar_position': 144 'slug': '/sql-reference/aggregate-functions/reference/grouparraymovingsum' 'title': 'groupArrayMovingSum' +'doc_type': 'reference' --- # groupArrayMovingSum -计算输入值的移动总和。 +计算输入值的移动和。 ```sql groupArrayMovingSum(numbers_for_summing) groupArrayMovingSum(window_size)(numbers_for_summing) ``` -该函数可以将窗口大小作为参数。如果未指定,则该函数将窗口大小设置为列中的行数。 +该函数可以将窗口大小作为参数。如果未指定,则该函数使用等于列中行数的窗口大小。 **参数** -- `numbers_for_summing` — [表达式](/sql-reference/syntax#expressions),结果为数值数据类型。 +- `numbers_for_summing` — [表达式](/sql-reference/syntax#expressions),结果为数字数据类型的值。 - `window_size` — 计算窗口的大小。 **返回值** -- 与输入数据相同大小和类型的数组。 +- 与输入数据大小和类型相同的数组。 **示例** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparraymovingsum.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparraymovingsum.md.hash index d06276c8adc..6a83fe5afe3 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparraymovingsum.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparraymovingsum.md.hash @@ -1 +1 @@ -6079f4cb02da0d59 +0a9f25776436e20b diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparraysample.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparraysample.md index 15e6c4e15d5..01068817a92 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparraysample.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparraysample.md @@ -1,14 +1,15 @@ --- -'description': '创建一个样本参数值的数组。生成数组的大小限制为 `max_size` 元素。参数值是随机选择并添加到数组中的。' +'description': '创建一个样本参数值的数组。结果数组的大小限制为 `max_size` 个元素。参数值是随机选择并添加到数组中的。' 'sidebar_position': 145 'slug': '/sql-reference/aggregate-functions/reference/grouparraysample' 'title': 'groupArraySample' +'doc_type': 'reference' --- # groupArraySample -创建一个样本参数值的数组。生成数组的大小限制为 `max_size` 元素。参数值被随机选择并添加到数组中。 +创建一个样本参数值的数组。结果数组的大小限制为 `max_size` 元素。参数值是随机选择并添加到数组中的。 **语法** @@ -18,9 +19,9 @@ groupArraySample(max_size[, seed])(x) **参数** -- `max_size` — 生成数组的最大大小。 [UInt64](../../data-types/int-uint.md)。 -- `seed` — 随机数生成器的种子。可选。 [UInt64](../../data-types/int-uint.md)。默认值: `123456`。 -- `x` — 参数(列名称或表达式)。 +- `max_size` — 结果数组的最大大小。 [UInt64](../../data-types/int-uint.md)。 +- `seed` — 随机数生成器的种子。可选。 [UInt64](../../data-types/int-uint.md)。 默认值: `123456`。 +- `x` — 参数(列名或表达式)。 **返回值** @@ -42,7 +43,7 @@ groupArraySample(max_size[, seed])(x) └────┴────────┘ ``` -以列名称作为参数的查询: +以列名作为参数的查询: ```sql SELECT groupArraySample(3)(color) as newcolors FROM colors; @@ -56,7 +57,7 @@ SELECT groupArraySample(3)(color) as newcolors FROM colors; └────────────────────────────┘ ``` -以列名称和不同种子进行的查询: +以列名和不同种子进行的查询: ```sql SELECT groupArraySample(3, 987654321)(color) as newcolors FROM colors; diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparraysample.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparraysample.md.hash index b94131e68ba..cbfabdf6828 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparraysample.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparraysample.md.hash @@ -1 +1 @@ -50edc86b5e9d9075 +21417f1db037e854 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparraysorted.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparraysorted.md index b179793fc2a..7920e8b714f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparraysorted.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparraysorted.md @@ -1,14 +1,15 @@ --- -'description': '返回一个数组,包含前 N 项,按升序排列。' +'description': '返回一个按升序排列的前 N 个项目的数组。' 'sidebar_position': 146 'slug': '/sql-reference/aggregate-functions/reference/grouparraysorted' 'title': 'groupArraySorted' +'doc_type': 'reference' --- # groupArraySorted -返回一个按升序排列的前 N 项的数组。 +返回一个按升序排列的包含前 N 个项目的数组。 ```sql groupArraySorted(N)(column) @@ -18,7 +19,7 @@ groupArraySorted(N)(column) - `N` – 要返回的元素数量。 -- `column` – 值(整数、字符串、浮点数和其他通用类型)。 +- `column` – 值(整数、字符串、浮点数及其他通用类型)。 **示例** @@ -37,7 +38,7 @@ SELECT groupArraySorted(10)(number) FROM numbers(100) 获取列中所有数字的字符串实现: ```sql -SELECT groupArraySorted(5)(str) FROM (SELECT toString(number) as str FROM numbers(5)); +SELECT groupArraySorted(5)(str) FROM (SELECT toString(number) AS str FROM numbers(5)); ``` ```text diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparraysorted.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparraysorted.md.hash index 3015f450bc5..4ca8c433d08 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparraysorted.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/grouparraysorted.md.hash @@ -1 +1 @@ -64f2d6b24e2bac9c +b6a99084a5c58d95 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupbitand.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupbitand.md index 97a862522c0..67c8ff003be 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupbitand.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupbitand.md @@ -1,14 +1,15 @@ --- -'description': '对一系列数字应用位wise `AND`。' +'description': '对一系列数字应用位与 `AND`。' 'sidebar_position': 147 'slug': '/sql-reference/aggregate-functions/reference/groupbitand' 'title': 'groupBitAnd' +'doc_type': 'reference' --- # groupBitAnd -对一系列数字应用位与 `AND` 操作。 +对一系列数值应用按位 `AND` 操作。 ```sql groupBitAnd(expr) @@ -16,7 +17,7 @@ groupBitAnd(expr) **参数** -`expr` – 产生 `UInt*` 或 `Int*` 类型的表达式。 +`expr` – 结果为 `UInt*` 或 `Int*` 类型的表达式。 **返回值** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupbitand.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupbitand.md.hash index c1a4ea9ff87..885a5a6bc5f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupbitand.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupbitand.md.hash @@ -1 +1 @@ -3a3bb71bd8094b0e +172620066c882200 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupbitmap.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupbitmap.md index dc19dd990ac..48ec260b189 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupbitmap.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupbitmap.md @@ -1,14 +1,15 @@ --- -'description': '从无符号整数列进行 Bitmap 或聚合计算,返回类型为 UInt64 的基数,如果添加后缀 -State,则返回一个位图对象' +'description': '从无符号整数列计算 Bitmap 或聚合,返回类型为 UInt64 的基数,如果添加后缀 -State,则返回一个 bitmap 对象' 'sidebar_position': 148 'slug': '/sql-reference/aggregate-functions/reference/groupbitmap' 'title': 'groupBitmap' +'doc_type': 'reference' --- # groupBitmap -Bitmap 或聚合计算来自一个无符号整数列,返回 UInt64 类型的基数,如果添加后缀 -State,则返回 [bitmap 对象](../../../sql-reference/functions/bitmap-functions.md)。 +从无符号整数列中进行位图或聚合计算,返回 UInt64 类型的基数。如果加上后缀 -State,则返回 [bitmap object](../../../sql-reference/functions/bitmap-functions.md)。 ```sql groupBitmap(expr) @@ -37,7 +38,7 @@ UserID 查询: ```sql -SELECT groupBitmap(UserID) as num FROM t +SELECT groupBitmap(UserID) AS num FROM t ``` 结果: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupbitmap.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupbitmap.md.hash index 8fa96424e3b..1fdeb3696c4 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupbitmap.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupbitmap.md.hash @@ -1 +1 @@ -a502bf4fb0c68074 +e9820f016f51eecd diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupbitmapand.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupbitmapand.md index d6a2b32ac5d..442eca94ba3 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupbitmapand.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupbitmapand.md @@ -1,11 +1,12 @@ --- -'description': '计算一个位图列的 AND,返回类型为 UInt64 的基数,如果加上后缀 -State,则返回一个位图对象。' +'description': '计算位图列的 AND,返回 UInt64 类型的基数,如果添加后缀 -State,则返回一个位图对象。' 'sidebar_position': 149 'slug': '/sql-reference/aggregate-functions/reference/groupbitmapand' 'title': 'groupBitmapAnd' +'doc_type': 'reference' --- -计算位图列的 AND 运算,返回 UInt64 类型的基数,如果添加后缀 -State,则返回 [bitmap object](../../../sql-reference/functions/bitmap-functions.md)。 +计算位图列的 AND 操作,返回 UInt64 类型的基数,如果添加后缀 -State,则返回 [bitmap object](../../../sql-reference/functions/bitmap-functions.md)。 ```sql groupBitmapAnd(expr) @@ -13,7 +14,7 @@ groupBitmapAnd(expr) **参数** -`expr` – 一个结果为 `AggregateFunction(groupBitmap, UInt*)` 类型的表达式。 +`expr` – 结果为 `AggregateFunction(groupBitmap, UInt*)` 类型的表达式。 **返回值** @@ -31,9 +32,9 @@ CREATE TABLE bitmap_column_expr_test2 ENGINE = MergeTree ORDER BY tag_id; -INSERT INTO bitmap_column_expr_test2 VALUES ('tag1', bitmapBuild(cast([1,2,3,4,5,6,7,8,9,10] as Array(UInt32)))); -INSERT INTO bitmap_column_expr_test2 VALUES ('tag2', bitmapBuild(cast([6,7,8,9,10,11,12,13,14,15] as Array(UInt32)))); -INSERT INTO bitmap_column_expr_test2 VALUES ('tag3', bitmapBuild(cast([2,4,6,8,10,12] as Array(UInt32)))); +INSERT INTO bitmap_column_expr_test2 VALUES ('tag1', bitmapBuild(cast([1,2,3,4,5,6,7,8,9,10] AS Array(UInt32)))); +INSERT INTO bitmap_column_expr_test2 VALUES ('tag2', bitmapBuild(cast([6,7,8,9,10,11,12,13,14,15] AS Array(UInt32)))); +INSERT INTO bitmap_column_expr_test2 VALUES ('tag3', bitmapBuild(cast([2,4,6,8,10,12] AS Array(UInt32)))); SELECT groupBitmapAnd(z) FROM bitmap_column_expr_test2 WHERE like(tag_id, 'tag%'); ┌─groupBitmapAnd(z)─┐ diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupbitmapand.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupbitmapand.md.hash index 5bab7343cda..ae01a3a420d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupbitmapand.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupbitmapand.md.hash @@ -1 +1 @@ -79bfb8c053875398 +7d40153cad3c2994 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupbitmapor.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupbitmapor.md index 96e6f209b4b..235b4555009 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupbitmapor.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupbitmapor.md @@ -1,14 +1,15 @@ --- -'description': '计算一个位图列的 OR,返回类型为 UInt64 的基数。如果添加后缀 -State,返回一个位图对象。这相当于 `groupBitmapMerge`。' +'description': '对位图列进行OR计算,返回类型为UInt64的基数,如果添加后缀-State,则返回一个位图对象。这等同于`groupBitmapMerge`。' 'sidebar_position': 150 'slug': '/sql-reference/aggregate-functions/reference/groupbitmapor' 'title': 'groupBitmapOr' +'doc_type': 'reference' --- # groupBitmapOr -计算位图列的 OR,返回 UInt64 类型的基数,如果添加后缀 -State,则返回一个 [位图对象](../../../sql-reference/functions/bitmap-functions.md)。这相当于 `groupBitmapMerge`。 +计算一个位图列的 OR,返回类型为 UInt64 的基数,如果添加后缀 -State, 则返回一个 [bitmap object](../../../sql-reference/functions/bitmap-functions.md)。这相当于 `groupBitmapMerge`。 ```sql groupBitmapOr(expr) @@ -34,9 +35,9 @@ CREATE TABLE bitmap_column_expr_test2 ENGINE = MergeTree ORDER BY tag_id; -INSERT INTO bitmap_column_expr_test2 VALUES ('tag1', bitmapBuild(cast([1,2,3,4,5,6,7,8,9,10] as Array(UInt32)))); -INSERT INTO bitmap_column_expr_test2 VALUES ('tag2', bitmapBuild(cast([6,7,8,9,10,11,12,13,14,15] as Array(UInt32)))); -INSERT INTO bitmap_column_expr_test2 VALUES ('tag3', bitmapBuild(cast([2,4,6,8,10,12] as Array(UInt32)))); +INSERT INTO bitmap_column_expr_test2 VALUES ('tag1', bitmapBuild(cast([1,2,3,4,5,6,7,8,9,10] AS Array(UInt32)))); +INSERT INTO bitmap_column_expr_test2 VALUES ('tag2', bitmapBuild(cast([6,7,8,9,10,11,12,13,14,15] AS Array(UInt32)))); +INSERT INTO bitmap_column_expr_test2 VALUES ('tag3', bitmapBuild(cast([2,4,6,8,10,12] AS Array(UInt32)))); SELECT groupBitmapOr(z) FROM bitmap_column_expr_test2 WHERE like(tag_id, 'tag%'); ┌─groupBitmapOr(z)─┐ diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupbitmapor.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupbitmapor.md.hash index 47c068361bc..9d04d2fb1be 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupbitmapor.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupbitmapor.md.hash @@ -1 +1 @@ -fc79572dc384961c +38692578deaba09a diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupbitmapxor.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupbitmapxor.md index 4b40f89ef4e..5b6996ffa6a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupbitmapxor.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupbitmapxor.md @@ -1,17 +1,18 @@ --- -'description': '计算一个位图列的 XOR,并返回类型为 UInt64 的基数,如果使用后缀 -State,则返回一个位图对象' +'description': '计算位图列的 XOR,并返回 UInt64 类型的基数,如果与后缀 -State 一起使用,则返回一个位图对象' 'sidebar_position': 151 'slug': '/sql-reference/aggregate-functions/reference/groupbitmapxor' 'title': 'groupBitmapXor' +'doc_type': 'reference' --- # groupBitmapXor -`groupBitmapXor` 计算位图列的 XOR,并返回 UInt64 类型的基数,如果与后缀 -State 一起使用,则返回一个 [bitmap object](../../../sql-reference/functions/bitmap-functions.md)。 +`groupBitmapXor` 计算一个位图列的异或(XOR),返回类型为 UInt64 的基数,如果带有后缀 -State 使用,则返回一个 [bitmap object](../../../sql-reference/functions/bitmap-functions.md)。 ```sql -groupBitmapOr(expr) +groupBitmapXor(expr) ``` **参数** @@ -20,7 +21,7 @@ groupBitmapOr(expr) **返回值** -UInt64 类型的值。 +返回值为 `UInt64` 类型。 **示例** @@ -34,9 +35,9 @@ CREATE TABLE bitmap_column_expr_test2 ENGINE = MergeTree ORDER BY tag_id; -INSERT INTO bitmap_column_expr_test2 VALUES ('tag1', bitmapBuild(cast([1,2,3,4,5,6,7,8,9,10] as Array(UInt32)))); -INSERT INTO bitmap_column_expr_test2 VALUES ('tag2', bitmapBuild(cast([6,7,8,9,10,11,12,13,14,15] as Array(UInt32)))); -INSERT INTO bitmap_column_expr_test2 VALUES ('tag3', bitmapBuild(cast([2,4,6,8,10,12] as Array(UInt32)))); +INSERT INTO bitmap_column_expr_test2 VALUES ('tag1', bitmapBuild(cast([1,2,3,4,5,6,7,8,9,10] AS Array(UInt32)))); +INSERT INTO bitmap_column_expr_test2 VALUES ('tag2', bitmapBuild(cast([6,7,8,9,10,11,12,13,14,15] AS Array(UInt32)))); +INSERT INTO bitmap_column_expr_test2 VALUES ('tag3', bitmapBuild(cast([2,4,6,8,10,12] AS Array(UInt32)))); SELECT groupBitmapXor(z) FROM bitmap_column_expr_test2 WHERE like(tag_id, 'tag%'); ┌─groupBitmapXor(z)─┐ diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupbitmapxor.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupbitmapxor.md.hash index 60ee0b437a4..9481acbb907 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupbitmapxor.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupbitmapxor.md.hash @@ -1 +1 @@ -c2083a59a889f35d +3090d17e2ddd96ea diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupbitor.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupbitor.md index 1065032cd4c..5c1897f6974 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupbitor.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupbitor.md @@ -1,14 +1,15 @@ --- -'description': '对一系列数字应用位运算 `OR`。' +'description': '对一系列数字应用按位 `OR`。' 'sidebar_position': 152 'slug': '/sql-reference/aggregate-functions/reference/groupbitor' 'title': 'groupBitOr' +'doc_type': 'reference' --- # groupBitOr -对一系列数字应用按位 `OR` 操作。 +对一系列数字应用按位的 `OR` 操作。 ```sql groupBitOr(expr) @@ -16,7 +17,7 @@ groupBitOr(expr) **参数** -`expr` – 结果为 `UInt*` 或 `Int*` 类型的表达式。 +`expr` – 一个结果为 `UInt*` 或 `Int*` 类型的表达式。 **返回值** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupbitor.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupbitor.md.hash index 4255651301c..db7321bd152 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupbitor.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupbitor.md.hash @@ -1 +1 @@ -ff05a328eb717b75 +3f4178ed483c975d diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupbitxor.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupbitxor.md index 6a4c72747ef..88fa2512a44 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupbitxor.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupbitxor.md @@ -1,14 +1,15 @@ --- -'description': '对一系列数字应用位运算 `XOR`。' +'description': '对一系列数字应用按位 `XOR` 。' 'sidebar_position': 153 'slug': '/sql-reference/aggregate-functions/reference/groupbitxor' 'title': 'groupBitXor' +'doc_type': 'reference' --- # groupBitXor -对一系列数字执行按位 `XOR` 操作。 +对一系列数字应用按位 `XOR` 运算。 ```sql groupBitXor(expr) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupbitxor.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupbitxor.md.hash index 889359650bc..68a89be6f72 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupbitxor.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupbitxor.md.hash @@ -1 +1 @@ -33993f564d51ee11 +2555e04544572592 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupconcat.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupconcat.md index 46791d957fb..5a4c2e590b0 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupconcat.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupconcat.md @@ -1,12 +1,13 @@ --- -'description': '从一组字符串计算一个连接的字符串,可选地通过分隔符分隔,并可选地限制最大元素数量。' +'description': '计算来自字符串组的连接字符串,选项上可以用分隔符分隔,并且可以限制最大元素的数量。' 'sidebar_label': 'groupConcat' 'sidebar_position': 363 'slug': '/sql-reference/aggregate-functions/reference/groupconcat' 'title': 'groupConcat' +'doc_type': 'reference' --- -计算从一组字符串中生成一个连接字符串,可以选择性地用分隔符分隔,和选择性地限制最多元素的数量。 +计算来自一组字符串的连接字符串,可以选择用分隔符分隔,并可选择限制最大元素数量。 **语法** @@ -14,25 +15,27 @@ groupConcat[(delimiter [, limit])](expression); ``` +别名: `group_concat` + **参数** - `expression` — 输出要连接的字符串的表达式或列名。 -- `delimiter` — 用于分隔连接值的 [字符串](../../../sql-reference/data-types/string.md)。此参数是可选的,如果未指定,将默认为空字符串或参数中的分隔符。 +- `delimiter` — 一个 [字符串](../../../sql-reference/data-types/string.md),将用于分隔连接的值。该参数是可选的,默认为空字符串或未指定时从参数中提取的分隔符。 -**参数** +**参数说明** -- `delimiter` — 用于分隔连接值的 [字符串](../../../sql-reference/data-types/string.md)。此参数是可选的,如果未指定,将默认为空字符串。 -- `limit` — 一个正的 [整数](../../../sql-reference/data-types/int-uint.md),指定要连接的最大元素数量。如果存在更多元素,将忽略多余的元素。此参数是可选的。 +- `delimiter` — 一个 [字符串](../../../sql-reference/data-types/string.md),将用于分隔连接的值。该参数是可选的,默认为空字符串(如果未指定)。 +- `limit` — 一个正的 [整数](../../../sql-reference/data-types/int-uint.md),指定要连接的最大元素数量。如果存在多个元素,则多余的元素将被忽略。该参数是可选的。 :::note -如果指定了分隔符而没有限制,则必须将其作为第一个参数。如果同时指定了分隔符和限制,则分隔符必须在限制之前。 +如果只指定了分隔符而没有限制,则分隔符必须是第一个参数。如果同时指定了分隔符和限制,则分隔符必须在限制之前。 -此外,如果将不同的分隔符指定为参数和参数,则只会使用参数中的分隔符。 +此外,如果作为参数和参数指定了不同的分隔符,则仅使用参数中的分隔符。 ::: **返回值** -- 返回一个由列或表达式连接值构成的 [字符串](../../../sql-reference/data-types/string.md)。如果组没有元素或只有空元素,并且函数未指定对空值的处理,则结果是一个 Nullable 字符串,值为空。 +- 返回由列或表达式的连接值组成的 [字符串](../../../sql-reference/data-types/string.md)。如果组没有元素或只有 null 元素,并且函数未指定对仅 null 值的处理,则结果是一个带有 null 值的 Nullable 字符串。 **示例** @@ -46,7 +49,7 @@ groupConcat[(delimiter [, limit])](expression); └────┴──────┘ ``` -1. 基本用法,无分隔符: +1. 无分隔符的基本用法: 查询: @@ -60,7 +63,7 @@ SELECT groupConcat(Name) FROM Employees; JohnJaneBob ``` -这将所有名称连接成一个连续字符串,没有任何分隔符。 +这将所有名称连接成一个没有任何分隔符的连续字符串。 2. 使用逗号作为分隔符: @@ -70,7 +73,7 @@ JohnJaneBob SELECT groupConcat(', ')(Name) FROM Employees; ``` -或者 +或 ```sql SELECT groupConcat(Name, ', ') FROM Employees; @@ -82,9 +85,9 @@ SELECT groupConcat(Name, ', ') FROM Employees; John, Jane, Bob ``` -此输出显示名称由逗号和空格分隔。 +此输出显示名称用逗号后跟一个空格分隔。 -3. 限制连接元素的数量 +3. 限制连接的元素数量 查询: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupconcat.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupconcat.md.hash index b5fcf860dd2..4818cdebc60 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupconcat.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupconcat.md.hash @@ -1 +1 @@ -803d2d30b0de9919 +e85bf256f425792f diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupuniqarray.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupuniqarray.md index c16c419a72f..109c3fb65ad 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupuniqarray.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupuniqarray.md @@ -3,6 +3,7 @@ 'sidebar_position': 154 'slug': '/sql-reference/aggregate-functions/reference/groupuniqarray' 'title': 'groupUniqArray' +'doc_type': 'reference' --- @@ -12,5 +13,5 @@ 从不同的参数值创建一个数组。内存消耗与 [uniqExact](../../../sql-reference/aggregate-functions/reference/uniqexact.md) 函数相同。 -第二个版本(带有 `max_size` 参数)限制生成的数组大小为 `max_size` 个元素。 -例如,`groupUniqArray(1)(x)` 相当于 `[any(x)]`。 +第二种版本(带有 `max_size` 参数)将结果数组的大小限制为 `max_size` 个元素。 +例如,`groupUniqArray(1)(x)` 等同于 `[any(x)]`。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupuniqarray.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupuniqarray.md.hash index 9668bad6743..ed6c0a3ed7d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupuniqarray.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/groupuniqarray.md.hash @@ -1 +1 @@ -fa7d441ba3c9614b +ad9fd89923dcf8eb diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/index.md index e035f340627..971eeec8994 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/index.md @@ -1,16 +1,17 @@ --- -'description': '聚合函数的主页,包含完整的聚合函数列表' +'description': '聚合函数的登录页面,包含聚合函数的完整列表' 'sidebar_position': 36 'slug': '/sql-reference/aggregate-functions/reference/' 'title': '聚合函数' 'toc_folder_title': 'Reference' 'toc_hidden': true +'doc_type': 'landing-page' --- # 聚合函数 -ClickHouse 支持所有标准 SQL 聚合函数 ([sum](../reference/sum.md), [avg](../reference/avg.md), [min](../reference/min.md), [max](../reference/max.md), [count](../reference/count.md)),以及一系列其他聚合函数。 +ClickHouse 支持所有标准 SQL 聚合函数 ([sum](../reference/sum.md), [avg](../reference/avg.md), [min](../reference/min.md), [max](../reference/max.md), [count](../reference/count.md)),以及广泛的其他聚合函数。 + + +| 页面 | 描述 | +|-----|-----| +| [aggThrow](/sql-reference/aggregate-functions/reference/aggthrow) | 此函数可用于测试异常安全性。它将在创建时抛出异常,概率由指定。 | +| [analysisOfVariance](/sql-reference/aggregate-functions/reference/analysis_of_variance) | 提供单因素方差分析的统计测试(ANOVA 测试)。它是对几组正态分布观察值进行测试,以确定所有组的均值是否相同。 | +| [any](/sql-reference/aggregate-functions/reference/any) | 选择列中首次出现的值。 | +| [anyHeavy](/sql-reference/aggregate-functions/reference/anyheavy) | 使用重击算法选择经常出现的值。如果在每个查询执行线程中有一个值出现的次数超过一半,则返回该值。通常,结果是非确定性的。 | +| [anyLast](/sql-reference/aggregate-functions/reference/anylast) | 选择列中最后出现的值。 | +| [approx_top_k](/sql-reference/aggregate-functions/reference/approxtopk) | 返回指定列中大约最频繁值及其计数的数组。 | +| [approx_top_sum](/sql-reference/aggregate-functions/reference/approxtopsum) | 返回指定列中大约最频繁值及其计数的数组。 | +| [argMax](/sql-reference/aggregate-functions/reference/argmax) | 计算最大 `val` 值的 `arg` 值。 | +| [argMin](/sql-reference/aggregate-functions/reference/argmin) | 计算最小 `val` 值的 `arg` 值。如果有多行具有相同的最大 `val`,则返回的相关 `arg` 不具有确定性。 | +| [groupArrayArray](/sql-reference/aggregate-functions/reference/grouparrayarray) | 将数组聚合为一个更大的数组。 | +| [avg](/sql-reference/aggregate-functions/reference/avg) | 计算算术平均值。 | +| [avgWeighted](/sql-reference/aggregate-functions/reference/avgweighted) | 计算加权算术平均值。 | +| [boundingRatio](/sql-reference/aggregate-functions/reference/boundingRatio) | 计算值组的最左和最右点之间的斜率的聚合函数。 | +| [categoricalInformationValue](/sql-reference/aggregate-functions/reference/categoricalinformationvalue) | 为每个类别计算 `(P(tag = 1) - P(tag = 0))(log(P(tag = 1)) - log(P(tag = 0)))` 的值。 | +| [contingency](/sql-reference/aggregate-functions/reference/contingency) | `contingency` 函数计算应变系数,这是一个衡量表中两个列之间关联的值。计算方式类似于 `cramersV` 函数,但是在平方根中有不同的分母。 | +| [corr](/sql-reference/aggregate-functions/reference/corr) | 计算 Pearson 相关系数。 | +| [corrMatrix](/sql-reference/aggregate-functions/reference/corrmatrix) | 计算 N 个变量的相关矩阵。 | +| [corrStable](/sql-reference/aggregate-functions/reference/corrstable) | 计算 Pearson 相关系数,但使用数值稳定的算法。 | +| [count](/sql-reference/aggregate-functions/reference/count) | 计算行数或非 NULL 值的数量。 | +| [covarPop](/sql-reference/aggregate-functions/reference/covarpop) | 计算种群协方差。 | +| [covarPopMatrix](/sql-reference/aggregate-functions/reference/covarpopmatrix) | 返回 N 个变量的种群协方差矩阵。 | +| [covarPopStable](/sql-reference/aggregate-functions/reference/covarpopstable) | 计算种群协方差的值。 | +| [covarSamp](/sql-reference/aggregate-functions/reference/covarsamp) | 计算 `Σ((x - x̅)(y - y̅)) / (n - 1)` 的值。 | +| [covarSampMatrix](/sql-reference/aggregate-functions/reference/covarsampmatrix) | 返回 N 个变量的样本协方差矩阵。 | +| [covarSampStable](/sql-reference/aggregate-functions/reference/covarsampstable) | 类似于 covarSamp,但运行速度较慢且提供更低的计算误差。 | +| [cramersV](/sql-reference/aggregate-functions/reference/cramersv) | `cramersV` 函数的结果范围从 0(对应于两个变量之间没有关联)到 1,只有当每个值完全由另一个值决定时,才能达到 1。它可以被视为两个变量之间的关联程度,占其最大可能变化的百分比。 | +| [cramersVBiasCorrected](/sql-reference/aggregate-functions/reference/cramersvbiascorrected) | 计算 Cramer's V,但使用偏差校正。 | +| [deltaSum](/sql-reference/aggregate-functions/reference/deltasum) | 求连续行之间的算术差值总和。 | +| [deltaSumTimestamp](/sql-reference/aggregate-functions/reference/deltasumtimestamp) | 添加连续行的差值。如果差值为负,则被忽略。 | +| [entropy](/sql-reference/aggregate-functions/reference/entropy) | 计算列值的 Shannon 熵。 | +| [estimateCompressionRatio](/sql-reference/aggregate-functions/reference/estimateCompressionRatio) | 在不压缩的情况下估计给定列的压缩比。 | +| [exponentialMovingAverage](/sql-reference/aggregate-functions/reference/exponentialMovingAverage) | 计算确定时间段内值的指数移动平均。 | +| [exponentialTimeDecayedAvg](/sql-reference/aggregate-functions/reference/exponentialTimeDecayedAvg) | 返回时间序列在 `t` 时刻的指数平滑加权移动平均。 | +| [exponentialTimeDecayedCount](/sql-reference/aggregate-functions/reference/exponentialTimeDecayedCount) | 返回时间序列在时间索引 `t` 的累积指数衰减。 | +| [exponentialTimeDecayedMax](/sql-reference/aggregate-functions/reference/exponentialTimeDecayedMax) | 返回在时间索引 `t` 的计算指数平滑移动平均的最大值与在 `t-1` 的值比较。 | +| [exponentialTimeDecayedSum](/sql-reference/aggregate-functions/reference/exponentialTimeDecayedSum) | 返回时间序列在时间索引 `t` 的指数平滑移动平均值之和。 | +| [first_value](/sql-reference/aggregate-functions/reference/first_value) | 是任何值的别名,但引入的原因是与窗口函数的兼容性,有时必须处理 `NULL` 值(默认情况下,所有 ClickHouse 聚合函数忽略 NULL 值)。 | +| [flameGraph](/sql-reference/aggregate-functions/reference/flame_graph) | 聚合函数使用堆栈跟踪列表构建火焰图。 | +| [groupArray](/sql-reference/aggregate-functions/reference/grouparray) | 创建参数值的数组。值可以以任何(不确定)顺序添加到数组中。 | +| [groupArrayInsertAt](/sql-reference/aggregate-functions/reference/grouparrayinsertat) | 将值插入到指定位置的数组中。 | +| [groupArrayIntersect](/sql-reference/aggregate-functions/reference/grouparrayintersect) | 返回给定数组的交集(返回所有在所有给定数组中的数组项)。 | +| [groupArrayLast](/sql-reference/aggregate-functions/reference/grouparraylast) | 创建最后参数值的数组。 | +| [groupArrayMovingSum](/sql-reference/aggregate-functions/reference/grouparraymovingsum) | 计算输入值的移动和。 | +| [groupArrayMovingAvg](/sql-reference/aggregate-functions/reference/grouparraymovingavg) | 计算输入值的移动平均。 | +| [groupArraySample](/sql-reference/aggregate-functions/reference/grouparraysample) | 创建样本参数值的数组。结果数组的大小限制为 `max_size` 元素。随机选择参数值并添加到数组中。 | +| [timeSeriesGroupArray](/sql-reference/aggregate-functions/reference/timeSeriesGroupArray) | 将时间序列按时间戳升序排序。 | +| [groupArraySorted](/sql-reference/aggregate-functions/reference/grouparraysorted) | 返回按升序排列的前 N 项数组。 | +| [groupBitAnd](/sql-reference/aggregate-functions/reference/groupbitand) | 对一系列数字应用按位 `AND`。 | +| [groupBitmap](/sql-reference/aggregate-functions/reference/groupbitmap) | 从无符号整数列进行位图或聚合计算,返回类型为 UInt64 的基数,如果加上后缀 -State,则返回位图对象。 | +| [groupBitmapAnd](/sql-reference/aggregate-functions/reference/groupbitmapand) | 计算位图列的 AND,返回类型为 UInt64 的基数,如果加上后缀 -State,则返回位图对象。 | +| [groupBitmapOr](/sql-reference/aggregate-functions/reference/groupbitmapor) | 计算位图列的 OR,返回类型为 UInt64 的基数,如果加上后缀 -State,则返回位图对象。等价于 `groupBitmapMerge`。 | +| [groupBitmapXor](/sql-reference/aggregate-functions/reference/groupbitmapxor) | 计算位图列的 XOR,并返回类型为 UInt64 的基数,如果与后缀 -State 一起使用,则返回位图对象。 | +| [groupBitOr](/sql-reference/aggregate-functions/reference/groupbitor) | 对一系列数字应用按位 `OR`。 | +| [groupBitXor](/sql-reference/aggregate-functions/reference/groupbitxor) | 对一系列数字应用按位 `XOR`。 | +| [groupUniqArray](/sql-reference/aggregate-functions/reference/groupuniqarray) | 从不同的参数值创建数组。 | +| [intervalLengthSum](/sql-reference/aggregate-functions/reference/intervalLengthSum) | 计算所有范围(数字轴上的分段)联合总长度。 | +| [kolmogorovSmirnovTest](/sql-reference/aggregate-functions/reference/kolmogorovsmirnovtest) | 对来自两个总体的样本应用 Kolmogorov-Smirnov 测试。 | +| [kurtPop](/sql-reference/aggregate-functions/reference/kurtpop) | 计算序列的峰度。 | +| [kurtSamp](/sql-reference/aggregate-functions/reference/kurtsamp) | 计算序列的样本峰度。 | +| [largestTriangleThreeBuckets](/sql-reference/aggregate-functions/reference/largestTriangleThreeBuckets) | 将 Largest-Triangle-Three-Buckets 算法应用于输入数据。 | +| [last_value](/sql-reference/aggregate-functions/reference/last_value) | 选择最后出现的值,类似于 `anyLast`,但可以接受 NULL。 | +| [mannWhitneyUTest](/sql-reference/aggregate-functions/reference/mannwhitneyutest) | 对来自两个总体的样本应用 Mann-Whitney 排名测试。 | +| [max](/sql-reference/aggregate-functions/reference/max) | 聚合函数,计算一组值中的最大值。 | +| [maxIntersections](/sql-reference/aggregate-functions/reference/maxintersections) | 聚合函数,计算一组区间相互交叉的最大次数(如果所有区间至少交叉一次)。 | +| [maxIntersectionsPosition](/sql-reference/aggregate-functions/reference/maxintersectionsposition) | 聚合函数,计算 maxIntersections 函数的出现位置。 | +| [maxMap](/sql-reference/aggregate-functions/reference/maxmap) | 根据 `key` 数组中指定的键,计算 `value` 数组中的最大值。 | +| [meanZTest](/sql-reference/aggregate-functions/reference/meanztest) | 对来自两个总体的样本应用均值 Z 测试。 | +| [median](/sql-reference/aggregate-functions/reference/median) | `median*` 函数是相应 `quantile*` 函数的别名。它们计算数值数据样本的中位数。 | +| [min](/sql-reference/aggregate-functions/reference/min) | 聚合函数,计算一组值中的最小值。 | +| [minMap](/sql-reference/aggregate-functions/reference/minmap) | 根据 `key` 数组中指定的键,计算 `value` 数组中的最小值。 | +| [quantile](/sql-reference/aggregate-functions/reference/quantile) | 计算数值数据序列的近似分位数。 | +| [quantileDD](/sql-reference/aggregate-functions/reference/quantileddsketch) | 计算带有相对误差保证的样本近似分位数。 | +| [quantileBFloat16](/sql-reference/aggregate-functions/reference/quantilebfloat16) | 计算由 bfloat16 数字组成的样本的近似分位数。 | +| [quantileDeterministic](/sql-reference/aggregate-functions/reference/quantiledeterministic) | 计算数值数据序列的近似分位数。 | +| [quantileExact Functions](/sql-reference/aggregate-functions/reference/quantileexact) | quantileExact, quantileExactLow, quantileExactHigh, quantileExactExclusive, quantileExactInclusive 函数 | +| [quantileExactWeighted](/sql-reference/aggregate-functions/reference/quantileexactweighted) | 精确计算数值数据序列的分位数,考虑到每个元素的权重。 | +| [quantileGK](/sql-reference/aggregate-functions/reference/quantileGK) | 使用 Greenwald-Khanna 算法计算数值数据序列的分位数。 | +| [quantileExactWeightedInterpolated](/sql-reference/aggregate-functions/reference/quantileExactWeightedInterpolated) | 使用线性插值计算数值数据序列的分位数,考虑到每个元素的权重。 | +| [quantileInterpolatedWeighted](/sql-reference/aggregate-functions/reference/quantileInterpolatedWeighted) | 使用线性插值计算数值数据序列的分位数,考虑到每个元素的权重。 | +| [quantiles Functions](/sql-reference/aggregate-functions/reference/quantiles) | quantiles, quantilesExactExclusive, quantilesExactInclusive, quantilesGK | +| [quantileTDigest](/sql-reference/aggregate-functions/reference/quantiletdigest) | 使用 t-digest 算法计算数值数据序列的近似分位数。 | +| [quantileTDigestWeighted](/sql-reference/aggregate-functions/reference/quantiletdigestweighted) | 使用 t-digest 算法计算数值数据序列的近似分位数。 | +| [quantileTiming](/sql-reference/aggregate-functions/reference/quantiletiming) | 以确定的精度计算数值数据序列的分位数。 | +| [quantileTimingWeighted](/sql-reference/aggregate-functions/reference/quantiletimingweighted) | 以确定的精度计算根据每个序列成员权重的数值数据序列的分位数。 | +| [rankCorr](/sql-reference/aggregate-functions/reference/rankCorr) | 计算排名相关系数。 | +| [simpleLinearRegression](/sql-reference/aggregate-functions/reference/simplelinearregression) | 执行简单(单维)线性回归。 | +| [singleValueOrNull](/sql-reference/aggregate-functions/reference/singlevalueornull) | 聚合函数 `singleValueOrNull` 用于实现子查询操作符,例如 `x = ALL (SELECT ...)`。它检查数据中是否仅存在一个唯一的非 NULL 值。 | +| [skewPop](/sql-reference/aggregate-functions/reference/skewpop) | 计算序列的偏度。 | +| [skewSamp](/sql-reference/aggregate-functions/reference/skewsamp) | 计算序列的样本偏度。 | +| [sparkbar](/sql-reference/aggregate-functions/reference/sparkbar) | 函数为值 `x` 绘制频率直方图,以及这些值在区间 `[min_x, max_x]` 上的重复率 `y`。 | +| [stddevPop](/sql-reference/aggregate-functions/reference/stddevpop) | 结果等于 varPop 的平方根。 | +| [stddevPopStable](/sql-reference/aggregate-functions/reference/stddevpopstable) | 结果等于 varPop 的平方根。与 stddevPop 不同,此函数使用数值稳定的算法。 | +| [stddevSamp](/sql-reference/aggregate-functions/reference/stddevsamp) | 结果等于 varSamp 的平方根。 | +| [stddevSampStable](/sql-reference/aggregate-functions/reference/stddevsampstable) | 结果等于 varSamp 的平方根。与此函数使用数值稳定的算法。运行速度较慢,但提供更低的计算误差。 | +| [stochasticLinearRegression](/sql-reference/aggregate-functions/reference/stochasticlinearregression) | 此函数实现随机线性回归。支持学习率、L2 正则化系数、迷你批量大小的自定义参数,并具有几种更新权重的方法(Adam、简单的 SGD、动量、Nesterov)。 | +| [stochasticLogisticRegression](/sql-reference/aggregate-functions/reference/stochasticlogisticregression) | 此函数实现随机逻辑回归。可用于二元分类问题,支持与 stochasticLinearRegression 相同的自定义参数,并以相同的方式工作。 | +| [studentTTest](/sql-reference/aggregate-functions/reference/studentttest) | 对两个总体的样本应用学生 t 测试。 | +| [sum](/sql-reference/aggregate-functions/reference/sum) | 计算总和。仅对数字有效。 | +| [studentTTestOneSample](/sql-reference/aggregate-functions/reference/studentttestonesample) | 对样本和已知总体均值应用单样本学生 t 测试。 | +| [sumCount](/sql-reference/aggregate-functions/reference/sumcount) | 同时计算数字的总和并计算行数。该函数由 ClickHouse 查询优化器使用:如果查询中有多个 `sum`、`count` 或 `avg` 函数,则可以替换为单个 `sumCount` 函数以重用计算。该函数很少需要显式使用。 | +| [sumKahan](/sql-reference/aggregate-functions/reference/sumkahan) | 使用 Kahan 补偿求和算法计算数字的总和。 | +| [sumMap](/sql-reference/aggregate-functions/reference/summap) | 根据 `key` 数组中指定的键对一个或多个 `value` 数组进行求和。返回一个元组数组:按排序顺序的键,后跟按对应键求和的值,无溢出。 | +| [sumMapWithOverflow](/sql-reference/aggregate-functions/reference/summapwithoverflow) | 根据 `key` 数组中指定的键对 `value` 数组进行求和。返回两个数组的元组:按排序顺序的键,以及按对应键求和的值。与 sumMap 函数不同,它在进行求和时允许溢出。 | +| [sumWithOverflow](/sql-reference/aggregate-functions/reference/sumwithoverflow) | 计算数字的总和,计算结果与输入参数相同的数据类型。如果总和超过该数据类型的最大值,则会出现溢出计算。 | +| [theilsU](/sql-reference/aggregate-functions/reference/theilsu) | `theilsU` 函数计算 Theils' U 不确定系数,这是一个衡量表中两个列之间关联的值。 | +| [topK](/sql-reference/aggregate-functions/reference/topk) | 返回指定列中大约最频繁值的数组。结果数组按值的近似频率降序排列(而不是值本身)。 | +| [topKWeighted](/sql-reference/aggregate-functions/reference/topkweighted) | 返回指定列中大约最频繁值的数组。结果数组按值的近似频率降序排列(而不是值本身)。此外,还考虑值的权重。 | +| [uniq](/sql-reference/aggregate-functions/reference/uniq) | 计算参数的不同值的近似数量。 | +| [uniqCombined](/sql-reference/aggregate-functions/reference/uniqcombined) | 计算不同参数值的近似数量。 | +| [uniqCombined64](/sql-reference/aggregate-functions/reference/uniqcombined64) | 计算不同参数值的近似数量。它与 uniqCombined 相同,但对所有数据类型使用 64 位哈希,而不仅仅是字符串数据类型。 | +| [uniqExact](/sql-reference/aggregate-functions/reference/uniqexact) | 计算不同参数值的确切数量。 | +| [uniqHLL12](/sql-reference/aggregate-functions/reference/uniqhll12) | 使用 HyperLogLog 算法计算不同参数值的近似数量。 | +| [uniqTheta](/sql-reference/aggregate-functions/reference/uniqthetasketch) | 使用 Theta Sketch 框架计算不同参数值的近似数量。 | +| [varPop](/sql-reference/aggregate-functions/reference/varPop) | 计算种群方差。 | +| [varPopStable](/sql-reference/aggregate-functions/reference/varpopstable) | 返回种群方差。与 varPop 不同,此函数使用数值稳定的算法。它运行速度较慢,但提供更低的计算误差。 | +| [varSamp](/sql-reference/aggregate-functions/reference/varSamp) | 计算数据集的样本方差。 | +| [varSampStable](/sql-reference/aggregate-functions/reference/varsampstable) | 计算数据集的样本方差。与 `varSamp` 不同,此函数使用数值稳定的算法。它运行速度较慢,但提供更低的计算误差。 | +| [welchTTest](/sql-reference/aggregate-functions/reference/welchttest) | 对来自两个总体的样本应用 Welch 的 t 测试。 | +| [distinctDynamicTypes](/sql-reference/aggregate-functions/reference/distinctdynamictypes) | 计算存储在动态列中的不同数据类型列表。 | +| [distinctJSONPaths](/sql-reference/aggregate-functions/reference/distinctjsonpaths) | 计算存储在 JSON 列中的不同路径列表。 | +| [timeSeriesDeltaToGrid](/sql-reference/aggregate-functions/reference/timeSeriesDeltaToGrid) | 聚合函数,计算在指定网格上的时间序列数据的类似 PromQL 的增量。 | +| [timeSeriesInstantDeltaToGrid](/sql-reference/aggregate-functions/reference/timeSeriesInstantDeltaToGrid) | 聚合函数,计算在指定网格上的时间序列数据的类似 PromQL 的瞬时增量。 | +| [timeSeriesInstantRateToGrid](/sql-reference/aggregate-functions/reference/timeSeriesInstantRateToGrid) | 聚合函数,计算在指定网格上的时间序列数据的类似 PromQL 的瞬时速率。 | +| [timeSeriesLastTwoSamples](/sql-reference/aggregate-functions/reference/timeSeriesLastTwoSamples) | 聚合函数,用于重新采样时间序列数据以进行类似 PromQL 的瞬时速率和增量计算。 | +| [timeSeriesRateToGrid](/sql-reference/aggregate-functions/reference/timeSeriesRateToGrid) | 聚合函数,计算在指定网格上的时间序列数据的类似 PromQL 的速率。 | +| [timeSeriesResampleToGridWithStaleness](/sql-reference/aggregate-functions/reference/timeSeriesResampleToGridWithStaleness) | 聚合函数,将时间序列数据重新采样到指定网格。 | +| [timeSeriesDerivToGrid](/sql-reference/aggregate-functions/reference/timeSeriesDerivToGrid) | 聚合函数,计算在指定网格上的时间序列数据的类似 PromQL 的导数。 | +| [timeSeriesPredictLinearToGrid](/sql-reference/aggregate-functions/reference/timeSeriesPredictLinearToGrid) | 聚合函数,计算在指定网格上的时间序列数据的类似 PromQL 的线性预测。 | +| [timeSeriesChangesToGrid](/sql-reference/aggregate-functions/reference/timeSeriesChangesToGrid) | 聚合函数,计算在指定网格上的时间序列数据的类似 PromQL 的变化。 | +| [timeSeriesResetsToGrid](/sql-reference/aggregate-functions/reference/timeSeriesResetsToGrid) | 聚合函数,计算在指定网格上的时间序列数据的类似 PromQL 的重置。 | +| [groupConcat](/sql-reference/aggregate-functions/reference/groupconcat) | 从一组字符串计算拼接字符串,可以选择用分隔符分隔,并可以限制元素的最大数量。 | +| [quantilePrometheusHistogram](/sql-reference/aggregate-functions/reference/quantilePrometheusHistogram) | 使用线性插值计算直方图的分位数。 | + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/index.md.hash index ee7daef0fbd..f3bdf239752 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/index.md.hash @@ -1 +1 @@ -2c8d948d6ab6aa86 +78b9581a2951d643 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/intervalLengthSum.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/intervalLengthSum.md index dba34b6390e..f08cf3b9c98 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/intervalLengthSum.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/intervalLengthSum.md @@ -1,12 +1,13 @@ --- -'description': '计算所有范围(数字轴上的段)的联合总长度。' +'description': '计算所有范围(数值轴上的段)并集的总长度。' 'sidebar_label': 'intervalLengthSum' 'sidebar_position': 155 'slug': '/sql-reference/aggregate-functions/reference/intervalLengthSum' 'title': 'intervalLengthSum' +'doc_type': 'reference' --- -计算所有范围(数值轴上的区间)的并集总长度。 +计算所有区间(数值轴上的片段)联合的总长度。 **语法** @@ -16,16 +17,16 @@ intervalLengthSum(start, end) **参数** -- `start` — 区间的起始值。 [Int32](/sql-reference/data-types/int-uint#integer-ranges), [Int64](/sql-reference/data-types/int-uint#integer-ranges), [UInt32](/sql-reference/data-types/int-uint#integer-ranges), [UInt64](/sql-reference/data-types/int-uint#integer-ranges), [Float32](/sql-reference/data-types/float), [Float64](/sql-reference/data-types/float), [DateTime](/sql-reference/data-types/datetime) 或 [Date](/sql-reference/data-types/date)。 -- `end` — 区间的结束值。 [Int32](/sql-reference/data-types/int-uint#integer-ranges), [Int64](/sql-reference/data-types/int-uint#integer-ranges), [UInt32](/sql-reference/data-types/int-uint#integer-ranges), [UInt64](/sql-reference/data-types/int-uint#integer-ranges), [Float32](/sql-reference/data-types/float), [Float64](/sql-reference/data-types/float), [DateTime](/sql-reference/data-types/datetime) 或 [Date](/sql-reference/data-types/date)。 +- `start` — 区间的起始值。可为 [Int32](/sql-reference/data-types/int-uint#integer-ranges), [Int64](/sql-reference/data-types/int-uint#integer-ranges), [UInt32](/sql-reference/data-types/int-uint#integer-ranges), [UInt64](/sql-reference/data-types/int-uint#integer-ranges), [Float32](/sql-reference/data-types/float), [Float64](/sql-reference/data-types/float), [DateTime](/sql-reference/data-types/datetime) 或 [Date](/sql-reference/data-types/date)。 +- `end` — 区间的结束值。可为 [Int32](/sql-reference/data-types/int-uint#integer-ranges), [Int64](/sql-reference/data-types/int-uint#integer-ranges), [UInt32](/sql-reference/data-types/int-uint#integer-ranges), [UInt64](/sql-reference/data-types/int-uint#integer-ranges), [Float32](/sql-reference/data-types/float), [Float64](/sql-reference/data-types/float), [DateTime](/sql-reference/data-types/datetime) 或 [Date](/sql-reference/data-types/date)。 :::note -参数必须是相同的数据类型。否则将抛出异常。 +参数必须是相同的数据类型。否则,将会抛出异常。 ::: **返回值** -- 所有范围(数值轴上的区间)并集的总长度。根据参数的类型,返回值可以是 [UInt64](/sql-reference/data-types/int-uint#integer-ranges) 或 [Float64](/sql-reference/data-types/float) 类型。 +- 所有区间(数值轴上的片段)联合的总长度。根据参数的类型,返回值可以是 [UInt64](/sql-reference/data-types/int-uint#integer-ranges) 或 [Float64](/sql-reference/data-types/float) 类型。 **示例** @@ -39,9 +40,9 @@ intervalLengthSum(start, end) └────┴───────┴─────┘ ``` -在这个例子中,使用了 Float32 类型的参数。该函数返回 Float64 类型的值。 +在此示例中,使用了 Float32 类型的参数。该函数返回 Float64 类型的值。 -结果是区间 `[1.1, 3.2]` 的长度之和(`[1.1, 2.9]` 和 `[2.5, 3.2]` 的并集)以及 `[4, 5]` +结果是区间 `[1.1, 3.2]` 的长度之和(联合了 `[1.1, 2.9]` 和 `[2.5, 3.2]`)以及 `[4, 5]`。 查询: @@ -67,7 +68,7 @@ SELECT id, intervalLengthSum(start, end), toTypeName(intervalLengthSum(start, en └────┴─────────────────────┴─────────────────────┘ ``` -在这个例子中,使用了 DateTime 类型的参数。该函数以秒为单位返回值。 +在此示例中,使用了 DateTime 类型的参数。该函数返回单位为秒的值。 查询: @@ -92,7 +93,7 @@ SELECT id, intervalLengthSum(start, end), toTypeName(intervalLengthSum(start, en └────┴────────────┴────────────┘ ``` -在这个例子中,使用了 Date 类型的参数。该函数以天为单位返回值。 +在此示例中,使用了 Date 类型的参数。该函数返回单位为天的值。 查询: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/intervalLengthSum.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/intervalLengthSum.md.hash index c594382ce72..9e9576b4271 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/intervalLengthSum.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/intervalLengthSum.md.hash @@ -1 +1 @@ -17eb3a50bbc160a0 +a469c6c4e1cad8d2 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/kolmogorovsmirnovtest.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/kolmogorovsmirnovtest.md index d6acb275700..511688eebe4 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/kolmogorovsmirnovtest.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/kolmogorovsmirnovtest.md @@ -1,15 +1,16 @@ --- -'description': '对来自两个总体的样本应用 Kolmogorov-Smirnov 检验。' +'description': '对两个总体的样本应用 Kolmogorov-Smirnov 的检验。' 'sidebar_label': 'kolmogorovSmirnovTest' 'sidebar_position': 156 'slug': '/sql-reference/aggregate-functions/reference/kolmogorovsmirnovtest' 'title': 'kolmogorovSmirnovTest' +'doc_type': 'reference' --- # kolmogorovSmirnovTest -对来自两个总体的样本应用 Kolmogorov-Smirnov 检验。 +应用Kolmogorov-Smirnov检验于两个总体的样本。 **语法** @@ -17,40 +18,39 @@ kolmogorovSmirnovTest([alternative, computation_method])(sample_data, sample_index) ``` -两个样本的值在 `sample_data` 列中。如果 `sample_index` 等于 0,则该行的值属于第一个总体的样本。否则,它属于第二个总体的样本。 -样本必须属于连续的一维概率分布。 +两个样本的值在`sample_data`列中。如果`sample_index`等于0,则该行中的值属于第一个总体的样本。否则,它属于第二个总体的样本。样本必须属于连续的、一维的概率分布。 **参数** -- `sample_data` — 样本数据。 [整数](../../../sql-reference/data-types/int-uint.md), [浮点数](../../../sql-reference/data-types/float.md)或[小数](../../../sql-reference/data-types/decimal.md)。 -- `sample_index` — 样本索引。 [整数](../../../sql-reference/data-types/int-uint.md)。 +- `sample_data` — 样本数据。[整数](../../../sql-reference/data-types/int-uint.md)、[浮点数](../../../sql-reference/data-types/float.md)或[十进制数](../../../sql-reference/data-types/decimal.md)。 +- `sample_index` — 样本索引。[整数](../../../sql-reference/data-types/int-uint.md)。 -**参数说明** +**参数** -- `alternative` — 备择假设。(可选,默认值:`'two-sided'`。) [字符串](../../../sql-reference/data-types/string.md)。 - 设 F(x) 和 G(x) 分别为第一个和第二个分布的 CDF。 - - `'two-sided'` - 零假设是样本来自同一分布,例如对于所有 x 有 `F(x) = G(x)`。 +- `alternative` — 备择假设。(可选,默认:`'two-sided'`。)[字符串](../../../sql-reference/data-types/string.md)。 + 设F(x)和G(x)分别为第一个和第二个分布的CDF。 + - `'two-sided'` + 虚无假设是样本来自同一分布,例如对于所有x,`F(x) = G(x)`。 备择假设是分布不相同。 - - `'greater'` - 零假设是第一个样本中的值 *随机地小于* 第二个样本中的值, - 例如,第一个分布的 CDF 位于第二个分布的左上方。 - 这实际上意味着对于所有 x 有 `F(x) >= G(x)`。此情况下的备择假设是至少存在一个 x,使得 `F(x) < G(x)`。 - - `'less'` - 零假设是第一个样本中的值 *随机地大于* 第二个样本中的值, - 例如,第一个分布的 CDF 位于第二个分布的右下方。 - 这实际上意味着对于所有 x 有 `F(x) <= G(x)`。此情况下的备择假设是至少存在一个 x,使得 `F(x) > G(x)`。 -- `computation_method` — 用于计算 p 值的方法。(可选,默认值:`'auto'`。) [字符串](../../../sql-reference/data-types/string.md)。 - - `'exact'` - 计算是使用检验统计量的精确概率分布进行的。计算密集且浪费,除非样本较小。 - - `'asymp'` (`'asymptotic'`) - 计算是使用近似进行的。对于大样本大小,精确和渐近的 p 值非常相似。 - - `'auto'` - 当最大样本数量少于 10,000 时,使用 `'exact'` 方法。 + - `'greater'` + 虚无假设是第一个样本中的值*随机小于*第二个样本中的值, + 例如第一个分布的CDF在第二个分布的CDF上方,即在其左侧。 + 这实际上意味着对于所有x,`F(x) >= G(x)`。并且在这种情况下,备择假设是至少存在一个x使得`F(x) < G(x)`。 + - `'less'`. + 虚无假设是第一个样本中的值*随机大于*第二个样本中的值, + 例如第一个分布的CDF在第二个分布的CDF下方,即在其右侧。 + 这实际上意味着对于所有x,`F(x) <= G(x)`。并且在这种情况下,备择假设是至少存在一个x使得`F(x) > G(x)`。 +- `computation_method` — 用于计算p值的方法。(可选,默认:`'auto'`。)[字符串](../../../sql-reference/data-types/string.md)。 + - `'exact'` - 使用精确的概率分布计算检验统计量。除了小样本外,此方法计算量大且浪费。 + - `'asymp'` (`'asymptotic'`) - 使用近似值进行计算。对于大样本,精确和渐近的p值非常相似。 + - `'auto'` - 当最大样本数量少于10'000时使用`'exact'`方法。 **返回值** -包含两个元素的 [元组](../../../sql-reference/data-types/tuple.md): +[元组](../../../sql-reference/data-types/tuple.md),包含两个元素: -- 计算的统计量。 [Float64](../../../sql-reference/data-types/float.md)。 -- 计算的 p 值。 [Float64](../../../sql-reference/data-types/float.md)。 +- 计算出的统计量。[Float64](../../../sql-reference/data-types/float.md)。 +- 计算出的p值。[Float64](../../../sql-reference/data-types/float.md)。 **示例** @@ -80,8 +80,8 @@ FROM └────────────────────────────────────────────────────┘ ``` -注意: -p 值大于 0.05(在 95% 置信水平下),因此不拒绝零假设。 +备注: +p值大于0.05(置信水平为95%),因此未拒绝虚无假设。 查询: @@ -109,9 +109,9 @@ FROM └─────────────────────────────────────────────────────────┘ ``` -注意: -p 值小于 0.05(在 95% 置信水平下),因此拒绝零假设。 +备注: +p值小于0.05(置信水平为95%),因此拒绝虚无假设。 **另见** -- [Kolmogorov-Smirnov检验](https://en.wikipedia.org/wiki/Kolmogorov%E2%80%93Smirnov_test) +- [Kolmogorov-Smirnov的检验](https://en.wikipedia.org/wiki/Kolmogorov%E2%80%93Smirnov_test) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/kolmogorovsmirnovtest.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/kolmogorovsmirnovtest.md.hash index 1e1c233173a..49991ebc16b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/kolmogorovsmirnovtest.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/kolmogorovsmirnovtest.md.hash @@ -1 +1 @@ -964e4a47bac35252 +97c83903fdac4989 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/kurtpop.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/kurtpop.md index f12f1ff2ba9..c60fe3871ed 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/kurtpop.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/kurtpop.md @@ -1,8 +1,9 @@ --- -'description': '计算序列的kurtosis。' +'description': '计算一系列的峰度。' 'sidebar_position': 157 'slug': '/sql-reference/aggregate-functions/reference/kurtpop' 'title': 'kurtPop' +'doc_type': 'reference' --- @@ -16,7 +17,7 @@ kurtPop(expr) **参数** -`expr` — [表达式](/sql-reference/syntax#expressions),返回一个数字。 +`expr` — 返回一个数字的[表达式](/sql-reference/syntax#expressions)。 **返回值** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/kurtpop.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/kurtpop.md.hash index ff88530e915..5442106f8a0 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/kurtpop.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/kurtpop.md.hash @@ -1 +1 @@ -f7665bb684dc2562 +6b49976795da8c5d diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/kurtsamp.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/kurtsamp.md index 7e8e2e3d081..0e9d8ccac08 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/kurtsamp.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/kurtsamp.md @@ -1,16 +1,17 @@ --- -'description': '计算序列的样本峰度。' +'description': '计算一个序列的样本峰度。' 'sidebar_position': 158 'slug': '/sql-reference/aggregate-functions/reference/kurtsamp' 'title': 'kurtSamp' +'doc_type': 'reference' --- # kurtSamp -计算一个序列的 [样本峰度](https://en.wikipedia.org/wiki/Kurtosis)。 +计算序列的 [样本峰度](https://en.wikipedia.org/wiki/Kurtosis)。 -如果传入的值构成其样本,则它代表了随机变量峰度的无偏估计。 +如果传入的值形成样本,则它表示随机变量峰度的无偏估计。 ```sql kurtSamp(expr) @@ -22,7 +23,7 @@ kurtSamp(expr) **返回值** -给定分布的峰度。类型 — [Float64](../../../sql-reference/data-types/float.md)。如果 `n <= 1` (`n` 为样本的大小),则该函数返回 `nan`。 +给定分布的峰度。类型 — [Float64](../../../sql-reference/data-types/float.md)。如果 `n <= 1`(`n` 是样本的大小),则该函数返回 `nan`。 **示例** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/kurtsamp.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/kurtsamp.md.hash index 97b3cdad639..b691d182375 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/kurtsamp.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/kurtsamp.md.hash @@ -1 +1 @@ -cedbe286327f4a19 +dd1d4a8b0736e31c diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/largestTriangleThreeBuckets.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/largestTriangleThreeBuckets.md index 36ed81a6656..9d54bba7de4 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/largestTriangleThreeBuckets.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/largestTriangleThreeBuckets.md @@ -1,15 +1,16 @@ --- -'description': '将 Largest-Triangle-Three-Buckets 算法应用于输入数据。' +'description': '将Largest-Triangle-Three-Buckets算法应用于输入数据。' 'sidebar_label': 'largestTriangleThreeBuckets' 'sidebar_position': 159 'slug': '/sql-reference/aggregate-functions/reference/largestTriangleThreeBuckets' 'title': 'largestTriangleThreeBuckets' +'doc_type': 'reference' --- # largestTriangleThreeBuckets -应用 [Largest-Triangle-Three-Buckets](https://skemman.is/bitstream/1946/15343/3/SS_MSthesis.pdf) 算法于输入数据。该算法用于对时间序列数据进行下采样以便于可视化。它被设计用于处理按 x 坐标排序的序列。它通过将排序后的系列划分为多个桶,然后在每个桶中寻找最大的三角形来工作。桶的数量等于结果序列中的点数。该函数将按 `x` 排序数据,然后将下采样算法应用于排序后的数据。 +应用 [Largest-Triangle-Three-Buckets](https://skemman.is/bitstream/1946/15343/3/SS_MSthesis.pdf) 算法于输入数据。该算法用于对时间序列数据进行降采样以便可视化。它被设计为在按 x 坐标排序的序列上操作。它通过将排序后的序列划分为多个桶,然后在每个桶中寻找最大的三角形来工作。桶的数量等于结果序列中的点数。该函数将会按 `x` 对数据进行排序,然后将降采样算法应用于排序后的数据。 **语法** @@ -21,10 +22,10 @@ largestTriangleThreeBuckets(n)(x, y) **参数** -- `x` — x 坐标。 [整数](../../../sql-reference/data-types/int-uint.md) , [浮点数](../../../sql-reference/data-types/float.md) , [十进制](../../../sql-reference/data-types/decimal.md) , [日期](../../../sql-reference/data-types/date.md), [Date32](../../../sql-reference/data-types/date32.md), [日期时间](../../../sql-reference/data-types/datetime.md), [DateTime64](../../../sql-reference/data-types/datetime64.md)。 -- `y` — y 坐标。 [整数](../../../sql-reference/data-types/int-uint.md) , [浮点数](../../../sql-reference/data-types/float.md) , [十进制](../../../sql-reference/data-types/decimal.md) , [日期](../../../sql-reference/data-types/date.md), [Date32](../../../sql-reference/data-types/date32.md), [日期时间](../../../sql-reference/data-types/datetime.md), [DateTime64](../../../sql-reference/data-types/datetime64.md)。 +- `x` — x 坐标。 [整数](../../../sql-reference/data-types/int-uint.md), [浮点数](../../../sql-reference/data-types/float.md), [十进制](../../../sql-reference/data-types/decimal.md), [日期](../../../sql-reference/data-types/date.md), [日期32](../../../sql-reference/data-types/date32.md), [日期时间](../../../sql-reference/data-types/datetime.md), [日期时间64](../../../sql-reference/data-types/datetime64.md)。 +- `y` — y 坐标。 [整数](../../../sql-reference/data-types/int-uint.md), [浮点数](../../../sql-reference/data-types/float.md), [十进制](../../../sql-reference/data-types/decimal.md), [日期](../../../sql-reference/data-types/date.md), [日期32](../../../sql-reference/data-types/date32.md), [日期时间](../../../sql-reference/data-types/datetime.md), [日期时间64](../../../sql-reference/data-types/datetime64.md)。 -提供的序列中会忽略 NaN,这意味着任何 NaN 值将被排除在分析之外。这样可以确保该函数仅对有效的数值数据进行操作。 +在提供的序列中会忽略 NaN,这意味着任何 NaN 值将被排除在分析之外。这确保了该函数仅在有效的数值数据上进行操作。 **参数** @@ -32,7 +33,7 @@ largestTriangleThreeBuckets(n)(x, y) **返回值** -[数组](../../../sql-reference/data-types/array.md) 的 [元组](../../../sql-reference/data-types/tuple.md) ,包含两个元素: +[数组](../../../sql-reference/data-types/array.md) 的 [元组](../../../sql-reference/data-types/tuple.md),包含两个元素: **示例** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/largestTriangleThreeBuckets.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/largestTriangleThreeBuckets.md.hash index cfc5a9917c0..a1cafa74fa2 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/largestTriangleThreeBuckets.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/largestTriangleThreeBuckets.md.hash @@ -1 +1 @@ -240a54f8f1e659cc +61429eab490f217b diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/last_value.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/last_value.md index 1619d349d40..cdb08105f59 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/last_value.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/last_value.md @@ -1,16 +1,17 @@ --- -'description': '选择最后遇到的值,类似于 `anyLast`,但可以接受 NULL。' +'description': '选择最后一个遇到的值,类似于 `anyLast`,但可以接受 NULL。' 'sidebar_position': 160 'slug': '/sql-reference/aggregate-functions/reference/last_value' 'title': 'last_value' +'doc_type': 'reference' --- # last_value -选择最近遇到的值,类似于 `anyLast`,但可以接受 NULL。 +选择最后遇到的值,类似于 `anyLast`,但可以接受 NULL。 主要应与 [Window Functions](../../window-functions/index.md) 一起使用。 -如果源流未排序,则在没有 Window Functions 的情况下,结果将是随机的。 +如果源流未排序,则没有 Window Functions 的结果将是随机的。 ## examples {#examples} @@ -22,13 +23,13 @@ CREATE TABLE test_data ) ENGINE = Memory; -INSERT INTO test_data (a, b) Values (1,null), (2,3), (4, 5), (6,null) +INSERT INTO test_data (a, b) VALUES (1,null), (2,3), (4, 5), (6,null) ``` -### example1 {#example1} -NULL 值在默认情况下将被忽略。 +### Example 1 {#example1} +NULL 值默认为被忽略。 ```sql -select last_value(b) from test_data +SELECT last_value(b) FROM test_data ``` ```text @@ -37,10 +38,10 @@ select last_value(b) from test_data └────────────────────────────┘ ``` -### example2 {#example2} +### Example 2 {#example2} NULL 值被忽略。 ```sql -select last_value(b) ignore nulls from test_data +SELECT last_value(b) ignore nulls FROM test_data ``` ```text @@ -49,10 +50,10 @@ select last_value(b) ignore nulls from test_data └────────────────────────────┘ ``` -### example3 {#example3} +### Example 3 {#example3} NULL 值被接受。 ```sql -select last_value(b) respect nulls from test_data +SELECT last_value(b) respect nulls FROM test_data ``` ```text @@ -61,8 +62,8 @@ select last_value(b) respect nulls from test_data └─────────────────────────────┘ ``` -### example4 {#example4} -使用带 `ORDER BY` 的子查询稳定结果。 +### Example 4 {#example4} +使用带有 `ORDER BY` 的子查询稳定化结果。 ```sql SELECT last_value_respect_nulls(b), diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/last_value.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/last_value.md.hash index 312094923de..ebdcb7e6b58 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/last_value.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/last_value.md.hash @@ -1 +1 @@ -fc5b514ebcf7ad16 +696b93834e6b6d21 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/mannwhitneyutest.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/mannwhitneyutest.md index 35b2c22e965..b49806c1540 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/mannwhitneyutest.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/mannwhitneyutest.md @@ -1,15 +1,16 @@ --- -'description': '对来自两个种群的样本应用 Mann-Whitney 排名测试。' +'description': '对两个总体的样本应用Mann-Whitney秩检验。' 'sidebar_label': 'mannWhitneyUTest' 'sidebar_position': 161 'slug': '/sql-reference/aggregate-functions/reference/mannwhitneyutest' 'title': 'mannWhitneyUTest' +'doc_type': 'reference' --- # mannWhitneyUTest -对来自两个种群的样本应用曼-惠特尼秩检验。 +对来自两个总体的样本应用Mann-Whitney等级检验。 **语法** @@ -17,28 +18,28 @@ mannWhitneyUTest[(alternative[, continuity_correction])](sample_data, sample_index) ``` -两个样本的值在 `sample_data` 列中。如果 `sample_index` 等于 0,则该行中的值属于第一个种群的样本。否则,它属于第二个种群的样本。 -零假设是两个种群在统计上是相等的。同时可以测试单边假设。该检验不假设数据具有正态分布。 +两个样本的值位于`sample_data`列中。如果`sample_index`等于0,则该行中的值属于第一个总体的样本。否则,它属于第二个总体的样本。 +原假设是两个总体是随机相等的。还可以检验单侧假设。此检验不假设数据具有正态分布。 **参数** -- `sample_data` — 样本数据。 [整数](../../../sql-reference/data-types/int-uint.md)、[浮点数](../../../sql-reference/data-types/float.md) 或 [小数](../../../sql-reference/data-types/decimal.md)。 -- `sample_index` — 样本索引。 [整数](../../../sql-reference/data-types/int-uint.md)。 +- `sample_data` — 样本数据。[整数](../../../sql-reference/data-types/int-uint.md)、[浮点数](../../../sql-reference/data-types/float.md)或[十进制](../../../sql-reference/data-types/decimal.md)。 +- `sample_index` — 样本索引。[整数](../../../sql-reference/data-types/int-uint.md)。 -**参数** +**选项** -- `alternative` — 替代假设。 (可选,默认: `'two-sided'`。) [字符串](../../../sql-reference/data-types/string.md)。 - - `'two-sided'`; - - `'greater'`; - - `'less'`。 -- `continuity_correction` — 如果不为 0,则在 p 值的正态近似中应用连续性修正。 (可选,默认: 1。) [UInt64](../../../sql-reference/data-types/int-uint.md)。 +- `alternative` — 备择假设。(可选,默认:`'two-sided'`。)[字符串](../../../sql-reference/data-types/string.md)。 + - `'two-sided'`; + - `'greater'`; + - `'less'`。 +- `continuity_correction` — 如果不为0,则在p值的正态近似中应用连续性修正。(可选,默认:1。)[UInt64](../../../sql-reference/data-types/int-uint.md)。 **返回值** -包含两个元素的 [元组](../../../sql-reference/data-types/tuple.md): +[元组](../../../sql-reference/data-types/tuple.md)包含两个元素: -- 计算的 U 统计量。 [Float64](../../../sql-reference/data-types/float.md)。 -- 计算的 p 值。 [Float64](../../../sql-reference/data-types/float.md)。 +- 计算出的U统计量。[Float64](../../../sql-reference/data-types/float.md)。 +- 计算出的p值。[Float64](../../../sql-reference/data-types/float.md)。 **示例** @@ -69,7 +70,7 @@ SELECT mannWhitneyUTest('greater')(sample_data, sample_index) FROM mww_ttest; └────────────────────────────────────────────────────────┘ ``` -**另请参阅** +**另见** -- [曼-惠特尼 U 检验](https://en.wikipedia.org/wiki/Mann%E2%80%93Whitney_U_test) +- [Mann–Whitney U检验](https://en.wikipedia.org/wiki/Mann%E2%80%93Whitney_U_test) - [随机排序](https://en.wikipedia.org/wiki/Stochastic_ordering) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/mannwhitneyutest.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/mannwhitneyutest.md.hash index f70de22d912..1f1aff367d3 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/mannwhitneyutest.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/mannwhitneyutest.md.hash @@ -1 +1 @@ -25794f32834e930b +45a97f8d482efc9e diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/max.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/max.md index ca25e2888b6..7e5bbb26d4a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/max.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/max.md @@ -2,10 +2,11 @@ 'description': '聚合函数,用于计算一组值中的最大值。' 'sidebar_position': 162 'slug': '/sql-reference/aggregate-functions/reference/max' -'title': 'max' +'title': '最大值' +'doc_type': 'reference' --- -聚合函数,用于计算一组值中的最大值。 +聚合函数,计算一组值中的最大值。 示例: @@ -17,7 +18,7 @@ SELECT max(salary) FROM employees; SELECT department, max(salary) FROM employees GROUP BY department; ``` -如果您需要选择两个值中的最大值的非聚合函数,请参见 `greatest`: +如果您需要非聚合函数来选择两个值中的最大值,请参见 `greatest`: ```sql SELECT greatest(a, b) FROM table; diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/max.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/max.md.hash index 5537b5a1cb7..6ee4410045a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/max.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/max.md.hash @@ -1 +1 @@ -74503a7e9ed84ab9 +aa1d7a587fe77c14 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/maxintersections.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/maxintersections.md index 7aaffe1f50a..2639b29e630 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/maxintersections.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/maxintersections.md @@ -1,16 +1,17 @@ --- -'description': '聚合函数,用于计算一组区间互相交叉的最大次数(如果所有区间至少交叉一次)。' +'description': '聚合函数,它计算一组区间彼此交叉的最大次数(如果所有区间至少交叉一次)。' 'sidebar_position': 163 'slug': '/sql-reference/aggregate-functions/reference/maxintersections' 'title': 'maxIntersections' +'doc_type': 'reference' --- # maxIntersections -聚合函数用于计算一组区间彼此相交的最大次数(如果所有区间至少相交一次)。 +聚合函数,计算一组区间彼此交叉的最大次数(如果所有区间至少交叉一次)。 -语法为: +语法如下: ```sql maxIntersections(start_column, end_column) @@ -18,13 +19,13 @@ maxIntersections(start_column, end_column) **参数** -- `start_column` – 表示每个区间开始的数字列。如果 `start_column` 为 `NULL` 或 0,则该区间将被跳过。 +- `start_column` – 表示每个区间起始位置的数值列。如果 `start_column` 为 `NULL` 或 0,则该区间将被跳过。 -- `end_column` - 表示每个区间结束的数字列。如果 `end_column` 为 `NULL` 或 0,则该区间将被跳过。 +- `end_column` - 表示每个区间结束位置的数值列。如果 `end_column` 为 `NULL` 或 0,则该区间将被跳过。 **返回值** -返回相交区间的最大数量。 +返回交叉区间的最大数量。 **示例** @@ -33,7 +34,7 @@ CREATE TABLE my_events ( start UInt32, end UInt32 ) -Engine = MergeTree +ENGINE = MergeTree ORDER BY tuple(); INSERT INTO my_events VALUES @@ -43,7 +44,7 @@ INSERT INTO my_events VALUES (3, 7); ``` -这些区间看起来如下: +这些区间如下所示: ```response 1 - 3 @@ -52,7 +53,7 @@ INSERT INTO my_events VALUES 3 - - - 7 ``` -其中三个区间有一个公共值(这个值是 `4`,但共同的值并不重要,我们测量的是相交的次数)。区间 `(1,3)` 和 `(3,7)` 共享一个端点,但在 `maxIntersections` 函数中并不被视为相交。 +其中三个区间有一个共同的值(该值为 `4`,但共同的值并不重要,我们测量的是交叉的数量)。区间 `(1,3)` 和 `(3,7)` 共享一个端点,但在 `maxIntersections` 函数中不被视为交叉。 ```sql SELECT maxIntersections(start, end) FROM my_events; @@ -63,4 +64,4 @@ SELECT maxIntersections(start, end) FROM my_events; 3 ``` -如果您有多个最大区间的出现,您可以使用 [`maxIntersectionsPosition` 函数](./maxintersectionsposition.md) 来定位这些出现的数量和位置。 +如果你有多个最大区间的出现,可以使用 [`maxIntersectionsPosition` 函数](./maxintersectionsposition.md) 来定位这些出现的数量和位置。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/maxintersections.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/maxintersections.md.hash index c818dd7d3ce..acbba476926 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/maxintersections.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/maxintersections.md.hash @@ -1 +1 @@ -cbefbcbedd4e3a5f +8d27f24e85931d72 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/maxintersectionsposition.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/maxintersectionsposition.md index fdcebb243f8..92b55bc9563 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/maxintersectionsposition.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/maxintersectionsposition.md @@ -1,14 +1,15 @@ --- -'description': '聚合函数,计算maxIntersections函数的出现位置。' +'description': '聚合函数,计算 maxIntersections 函数的出现位置。' 'sidebar_position': 164 'slug': '/sql-reference/aggregate-functions/reference/maxintersectionsposition' 'title': 'maxIntersectionsPosition' +'doc_type': 'reference' --- # maxIntersectionsPosition -聚合函数,用于计算[`maxIntersections`函数](./maxintersections.md)的出现位置。 +聚合函数,计算[`maxIntersections`函数](./maxintersections.md)出现的位置。 语法为: @@ -18,9 +19,9 @@ maxIntersectionsPosition(start_column, end_column) **参数** -- `start_column` - 表示每个区间开始的数值列。如果 `start_column` 为 `NULL` 或 0,则该区间将被跳过。 +- `start_column` – 代表每个区间开始的数值列。如果`start_column`为`NULL`或0,则该区间将被跳过。 -- `end_column` - 表示每个区间结束的数值列。如果 `end_column` 为 `NULL` 或 0,则该区间将被跳过。 +- `end_column` - 代表每个区间结束的数值列。如果`end_column`为`NULL`或0,则该区间将被跳过。 **返回值** @@ -33,7 +34,7 @@ CREATE TABLE my_events ( start UInt32, end UInt32 ) -Engine = MergeTree +ENGINE = MergeTree ORDER BY tuple(); INSERT INTO my_events VALUES @@ -52,7 +53,7 @@ INSERT INTO my_events VALUES 3 - - - 7 ``` -注意,这三个区间中都有值 4,并且从第二个区间开始: +注意,这三个区间都有值4,并且从第2个区间开始: ```sql SELECT maxIntersectionsPosition(start, end) FROM my_events; @@ -63,4 +64,4 @@ SELECT maxIntersectionsPosition(start, end) FROM my_events; 2 ``` -换句话说, `(1,6)` 行是三个交叉区间的起始位置,而 3 是交叉区间的最大数量。 +换句话说,行`(1,6)`是3个交叉区间的开始,3是交叉的区间的最大数量。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/maxintersectionsposition.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/maxintersectionsposition.md.hash index bc8769467d6..02eef7631c9 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/maxintersectionsposition.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/maxintersectionsposition.md.hash @@ -1 +1 @@ -fb3423cfe877c328 +1ede536126c874f9 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/maxmap.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/maxmap.md index d86cb326584..cddb5b0e919 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/maxmap.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/maxmap.md @@ -3,12 +3,13 @@ 'sidebar_position': 165 'slug': '/sql-reference/aggregate-functions/reference/maxmap' 'title': 'maxMap' +'doc_type': 'reference' --- # maxMap -根据在 `key` 数组中指定的键,计算 `value` 数组的最大值。 +根据 `key` 数组中指定的键计算 `value` 数组中的最大值。 **语法** @@ -23,29 +24,29 @@ maxMap(Tuple(key, value)) 别名: `maxMappedArrays` :::note -- 传递一组键和值数组的元组与分别传递两个键数组和值数组是相同的。 -- 每一行的 `key` 和 `value` 中的元素数量必须相同。 +- 传入键和值数组的元组与传入两个键和值数组是相同的。 +- 每一行的 `key` 和 `value` 的元素数量必须相同。 ::: **参数** -- `key` — 键的数组。 [Array](../../data-types/array.md). -- `value` — 值的数组。 [Array](../../data-types/array.md). +- `key` — 键数组。 [Array](../../data-types/array.md)。 +- `value` — 值数组。 [Array](../../data-types/array.md)。 **返回值** -- 返回一个包含两个数组的元组:按排序顺序排列的键,以及为相应键计算的值。 [Tuple](../../data-types/tuple.md)([Array](../../data-types/array.md), [Array](../../data-types/array.md)). +- 返回一个包含两个数组的元组:排序后的键,以及为相应键计算得到的值。 [Tuple](../../data-types/tuple.md)([Array](../../data-types/array.md), [Array](../../data-types/array.md))。 **示例** -查询: +查询: ```sql SELECT maxMap(a, b) -FROM values('a Array(Char), b Array(Int64)', (['x', 'y'], [2, 2]), (['y', 'z'], [3, 1])) +FROM VALUES('a Array(Char), b Array(Int64)', (['x', 'y'], [2, 2]), (['y', 'z'], [3, 1])) ``` -结果: +结果: ```text ┌─maxMap(a, b)───────────┐ diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/maxmap.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/maxmap.md.hash index 3cbe30daf3a..5978a0238ac 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/maxmap.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/maxmap.md.hash @@ -1 +1 @@ -a2a55caa50d4215d +1e1ab3df8a1bb774 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/meanztest.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/meanztest.md index 4844bb1876b..064df181a55 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/meanztest.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/meanztest.md @@ -1,9 +1,10 @@ --- -'description': '对两个总体的样本应用均值 z 检验。' +'description': '对来自两个群体的样本应用均值 z 检验。' 'sidebar_label': 'meanZTest' 'sidebar_position': 166 'slug': '/sql-reference/aggregate-functions/reference/meanztest' 'title': 'meanZTest' +'doc_type': 'reference' --- @@ -17,27 +18,28 @@ meanZTest(population_variance_x, population_variance_y, confidence_level)(sample_data, sample_index) ``` -两个样本的值在 `sample_data` 列中。如果 `sample_index` 等于 0,则该行中的值属于第一个总体的样本。否则,它属于第二个总体的样本。零假设是总体的均值相等。假设服从正态分布。总体可能具有不等的方差,并且方差是已知的。 +两个样本的值位于 `sample_data` 列中。如果 `sample_index` 等于 0,则该行的值属于第一个总体的样本。否则,它属于第二个总体的样本。 +原假设是总体的均值相等。假定服从正态分布。总体可能具有不等的方差,并且方差是已知的。 **参数** -- `sample_data` — 样本数据。 [整数](../../../sql-reference/data-types/int-uint.md)、[浮点数](../../../sql-reference/data-types/float.md) 或 [十进制](../../../sql-reference/data-types/decimal.md)。 +- `sample_data` — 样本数据。 [整数](../../../sql-reference/data-types/int-uint.md)、[浮点数](../../../sql-reference/data-types/float.md) 或 [小数](../../../sql-reference/data-types/decimal.md)。 - `sample_index` — 样本索引。 [整数](../../../sql-reference/data-types/int-uint.md)。 **参数** - `population_variance_x` — 总体 x 的方差。 [浮点数](../../../sql-reference/data-types/float.md)。 - `population_variance_y` — 总体 y 的方差。 [浮点数](../../../sql-reference/data-types/float.md)。 -- `confidence_level` — 为计算置信区间而设定的置信水平。 [浮点数](../../../sql-reference/data-types/float.md)。 +- `confidence_level` — 用于计算置信区间的置信水平。 [浮点数](../../../sql-reference/data-types/float.md)。 **返回值** [元组](../../../sql-reference/data-types/tuple.md),包含四个元素: -- 计算的 t 统计量。 [Float64](../../../sql-reference/data-types/float.md)。 -- 计算的 p 值。 [Float64](../../../sql-reference/data-types/float.md)。 -- 计算的置信区间下限。 [Float64](../../../sql-reference/data-types/float.md)。 -- 计算的置信区间上限。 [Float64](../../../sql-reference/data-types/float.md)。 +- 计算得出的 t 统计量。 [Float64](../../../sql-reference/data-types/float.md)。 +- 计算得出的 p 值。 [Float64](../../../sql-reference/data-types/float.md)。 +- 计算得出的置信区间下界。 [Float64](../../../sql-reference/data-types/float.md)。 +- 计算得出的置信区间上界。 [Float64](../../../sql-reference/data-types/float.md)。 **示例** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/meanztest.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/meanztest.md.hash index 911ece23f7c..6d35b9b3ada 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/meanztest.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/meanztest.md.hash @@ -1 +1 @@ -15f52a4667a8519d +629adcfebfc2d8fd diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/median.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/median.md index 61c3020e744..51106156df9 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/median.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/median.md @@ -1,14 +1,15 @@ --- -'description': '`median*` 函数是相应的 `quantile*` 函数的别名。它们计算数值数据样本的 median。' +'description': '`median*` 函数是对应的 `quantile*` 函数的别名。它们计算数值数据样本的中位数。' 'sidebar_position': 167 'slug': '/sql-reference/aggregate-functions/reference/median' -'title': 'median' +'title': '中位数' +'doc_type': 'reference' --- # median -`median*` 函数是对应的 `quantile*` 函数的别名。它们计算数值数据样本的中位数。 +`median*` 函数是相应的 `quantile*` 函数的别名。它们计算数值数据样本的中位数。 函数: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/median.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/median.md.hash index b92efe4f953..e9f3010d1d9 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/median.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/median.md.hash @@ -1 +1 @@ -9f6bfcd04ef7338f +2f929e60870d4ba6 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/min.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/min.md index 37b9fff47e0..7c84cd7c6b4 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/min.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/min.md @@ -3,9 +3,10 @@ 'sidebar_position': 168 'slug': '/sql-reference/aggregate-functions/reference/min' 'title': 'min' +'doc_type': 'reference' --- -聚合函数计算一组值中的最小值。 +计算一组值中的最小值的聚合函数。 示例: @@ -17,7 +18,7 @@ SELECT min(salary) FROM employees; SELECT department, min(salary) FROM employees GROUP BY department; ``` -如果您需要非聚合函数来选择两个值中的最小值,请参见 `least`: +如果您需要非聚合函数来选择两个值中的最小值,请参阅 `least`: ```sql SELECT least(a, b) FROM table; diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/min.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/min.md.hash index ac5605fd61f..15c94fbfad9 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/min.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/min.md.hash @@ -1 +1 @@ -7bba3b127200df38 +2b2d660e71b2796e diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/minmap.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/minmap.md index 1a41a5e0b83..ae5bb0eb91d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/minmap.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/minmap.md @@ -1,8 +1,9 @@ --- -'description': '根据 `key` 数组中指定的键计算 `value` 数组中的最小值。' +'description': '根据`key`数组中指定的键计算`value`数组的最小值。' 'sidebar_position': 169 'slug': '/sql-reference/aggregate-functions/reference/minmap' 'title': 'minMap' +'doc_type': 'reference' --- @@ -23,8 +24,8 @@ minMap(Tuple(key, value)) 别名: `minMappedArrays` :::note -- 传递键元组和值数组与传递键数组和值数组是一样的。 -- `key` 和 `value` 中的元素数量必须在每一行中相同。 +- 传递一个键元组和一个值数组与传递一个键数组和一个值数组是相同的。 +- 每一行的 `key` 和 `value` 中的元素数量必须相同。 ::: **参数** @@ -34,18 +35,18 @@ minMap(Tuple(key, value)) **返回值** -- 返回一个包含两个数组的元组:按排序顺序排列的键和针对相应键计算的值。 [Tuple](../../data-types/tuple.md)([Array](../../data-types/array.md), [Array](../../data-types/array.md))。 +- 返回两个数组的元组:按排序顺序排列的键和对应键计算得出的值。 [Tuple](../../data-types/tuple.md)([Array](../../data-types/array.md), [Array](../../data-types/array.md))。 **示例** -查询: +查询: ```sql SELECT minMap(a, b) -FROM values('a Array(Int32), b Array(Int64)', ([1, 2], [2, 2]), ([2, 3], [1, 1])) +FROM VALUES('a Array(Int32), b Array(Int64)', ([1, 2], [2, 2]), ([2, 3], [1, 1])) ``` -结果: +结果: ```text ┌─minMap(a, b)──────┐ diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/minmap.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/minmap.md.hash index 67b27d8852c..3e1cff7a0b8 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/minmap.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/minmap.md.hash @@ -1 +1 @@ -4fe3d5e43f6a5354 +4b84a3c701c6f6ac diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantile.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantile.md index 6a460f9af46..d48195191df 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantile.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantile.md @@ -1,20 +1,21 @@ --- -'description': '计算数值数据序列的近似分位数。' +'description': '计算数字数据序列的近似分位数。' 'sidebar_position': 170 'slug': '/sql-reference/aggregate-functions/reference/quantile' -'title': 'quantile' +'title': '分位数' +'doc_type': 'reference' --- # quantile -计算数字数据序列的近似 [quantile](https://en.wikipedia.org/wiki/Quantile)。 +计算数值数据序列的近似 [分位数](https://en.wikipedia.org/wiki/Quantile)。 -该函数使用 [reservoir sampling](https://en.wikipedia.org/wiki/Reservoir_sampling),其水槽大小最大为 8192,并使用随机数生成器进行采样。结果是非确定性的。要获得精确的分位数,请使用 [quantileExact](/sql-reference/aggregate-functions/reference/quantileexact#quantileexact) 函数。 +此函数采用 [水库取样](https://en.wikipedia.org/wiki/Reservoir_sampling),水库大小最多为 8192,并使用随机数生成器进行取样。结果是非确定性的。要获得精确的分位数,请使用 [quantileExact](/sql-reference/aggregate-functions/reference/quantileexact#quantileexact) 函数。 -在查询中使用多个不同级别的 `quantile*` 函数时,内部状态不会合并(即,查询的效率低于预期)。在这种情况下,请使用 [quantiles](../../../sql-reference/aggregate-functions/reference/quantiles.md#quantiles) 函数。 +在查询中使用多个 `quantile*` 函数并具有不同级别时,内部状态不会合并(也就是说,查询的效率低于它应有的效率)。在这种情况下,使用 [quantiles](../../../sql-reference/aggregate-functions/reference/quantiles.md#quantiles) 函数。 -请注意,对于空的数字序列,`quantile` 将返回 NaN,但其 `quantile*` 变体将根据变体返回 NaN 或序列类型的默认值。 +注意,对于空的数值序列,`quantile` 将返回 NaN,但其 `quantile*` 变体将根据变体返回 NaN 或该序列类型的默认值。 **语法** @@ -26,8 +27,8 @@ quantile(level)(expr) **参数** -- `level` — 分位数的级别。可选参数。介于 0 到 1 之间的常量浮点数。我们建议使用 `level` 值在 `[0.01, 0.99]` 范围内。默认值:0.5。在 `level=0.5` 时,该函数计算 [median](https://en.wikipedia.org/wiki/Median)。 -- `expr` — 基于列值的表达式,结果为数字 [data types](/sql-reference/data-types)、[Date](/sql-reference/data-types/date) 或 [DateTime](/sql-reference/data-types/datetime)。 +- `level` — 分位数的级别。可选参数。0 到 1 之间的常量浮点数。我们建议在 `[0.01, 0.99]` 范围内使用 `level` 值。默认值:0.5。在 `level=0.5` 时,函数计算 [中位数](https://en.wikipedia.org/wiki/Median)。 +- `expr` — 在列值上实现的表达式,结果为数值 [数据类型](/sql-reference/data-types),[Date](/sql-reference/data-types/date) 或 [DateTime](/sql-reference/data-types/datetime)。 **返回值** @@ -35,9 +36,9 @@ quantile(level)(expr) 类型: -- [Float64](/sql-reference/data-types/float) 适用于数字数据类型输入。 -- [Date](/sql-reference/data-types/date) 如果输入值为 `Date` 类型。 -- [DateTime](/sql-reference/data-types/datetime) 如果输入值为 `DateTime` 类型。 +- 对于数值数据类型输入,[Float64](/sql-reference/data-types/float)。 +- 如果输入值具有 `Date` 类型,则为 [Date](/sql-reference/data-types/date)。 +- 如果输入值具有 `DateTime` 类型,则为 [DateTime](/sql-reference/data-types/datetime)。 **示例** @@ -66,7 +67,7 @@ SELECT quantile(val) FROM t └───────────────┘ ``` -**另见** +**另请参阅** - [median](/sql-reference/aggregate-functions/reference/median) - [quantiles](/sql-reference/aggregate-functions/reference/quantiles#quantiles) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantile.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantile.md.hash index e6d20fb4594..81418fe184f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantile.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantile.md.hash @@ -1 +1 @@ -ca73d842a032c59e +270d743e531a4758 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantileGK.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantileGK.md index 84dd53d7fc7..32426a7d4a4 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantileGK.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantileGK.md @@ -3,12 +3,13 @@ 'sidebar_position': 175 'slug': '/sql-reference/aggregate-functions/reference/quantileGK' 'title': 'quantileGK' +'doc_type': 'reference' --- # quantileGK -计算一个数字数据序列的 [分位数](https://en.wikipedia.org/wiki/Quantile),使用 [Greenwald-Khanna](http://infolab.stanford.edu/~datar/courses/cs361a/papers/quantiles.pdf) 算法。Greenwald-Khanna 算法用于以高效方式计算数据流上的分位数。该算法由 Michael Greenwald 和 Sanjeev Khanna 于 2001 年提出。它在数据库和大数据系统中广泛使用,因为在实时处理大量数据流时需要计算精确的分位数。该算法非常高效,空间复杂度为 O(log n),每个项目的时间复杂度为 O(log log n)(其中 n 是输入的大小)。它还具有很高的准确性,以较高的概率提供近似的分位数值。 +计算数值数据序列的 [分位数](https://en.wikipedia.org/wiki/Quantile),使用 [Greenwald-Khanna](http://infolab.stanford.edu/~datar/courses/cs361a/papers/quantiles.pdf) 算法。Greenwald-Khanna 算法是一种以高度有效的方式在数据流上计算分位数的算法。它由 Michael Greenwald 和 Sanjeev Khanna 于 2001 年提出。该算法广泛应用于数据库和大数据系统中,实时计算大量数据流的准确分位数是必需的。该算法极其高效,每个元素只需 O(log n) 的空间和 O(log log n) 的时间(其中 n 是输入的大小)。它也非常准确,以高概率提供近似的分位数值。 `quantileGK` 与 ClickHouse 中的其他分位数函数不同,因为它使用户能够控制近似分位数结果的准确性。 @@ -22,19 +23,19 @@ quantileGK(accuracy, level)(expr) **参数** -- `accuracy` — 分位数的准确性。常数正整数。较大的准确度值意味着误差较小。例如,如果将准确度参数设置为 100,计算出的分位数的误差不会大于 1%,以较高的概率。计算的分位数的准确性与算法的计算复杂性之间存在权衡。较大的准确度需要更多的内存和计算资源以准确计算分位数,而较小的准确度参数则可以实现更快和更节省内存的计算,但准确性稍低。 +- `accuracy` — 分位数的准确性。常量正整数。更大的准确性值意味着更小的误差。例如,如果将 accuracy 参数设置为 100,则计算出的分位数在高概率下的误差不会超过 1%。计算出的分位数的准确性与算法的计算复杂性之间存在权衡。更大的准确性需要更多的内存和计算资源来精确计算分位数,而较小的准确性参数允许更快和更节省内存的计算,但准确性稍低。 -- `level` — 分位数的级别。可选参数。常数浮点数,范围从 0 到 1。默认值:0.5。在 `level=0.5` 时,该函数计算 [中位数](https://en.wikipedia.org/wiki/Median)。 +- `level` — 分位数的级别。可选参数。范围从 0 到 1 的常量浮点数。默认值:0.5。在 `level=0.5` 时,函数计算 [中位数](https://en.wikipedia.org/wiki/Median)。 -- `expr` — 表示列值的表达式,结果为数字 [数据类型](/sql-reference/data-types), [Date](../../../sql-reference/data-types/date.md) 或 [DateTime](../../../sql-reference/data-types/datetime.md)。 +- `expr` — 对列值的表达式,结果为数值 [数据类型](/sql-reference/data-types),[Date](../../../sql-reference/data-types/date.md) 或 [DateTime](../../../sql-reference/data-types/datetime.md)。 **返回值** -- 指定级别和准确性下的分位数。 +- 指定级别和准确性的分位数。 类型: -- 输入为数字数据类型时为 [Float64](../../../sql-reference/data-types/float.md)。 +- 如果输入数据类型为数值,则返回 [Float64](../../../sql-reference/data-types/float.md)。 - 如果输入值为 `Date` 类型,则返回 [Date](../../../sql-reference/data-types/date.md)。 - 如果输入值为 `DateTime` 类型,则返回 [DateTime](../../../sql-reference/data-types/datetime.md)。 @@ -70,7 +71,7 @@ FROM numbers(1000) └─────────────────────────────────────────┘ ``` -**参见** +**另见** - [median](/sql-reference/aggregate-functions/reference/median) - [quantiles](../../../sql-reference/aggregate-functions/reference/quantiles.md#quantiles) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantileGK.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantileGK.md.hash index a6caeecee36..a1a94c95e60 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantileGK.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantileGK.md.hash @@ -1 +1 @@ -c4456e3a90f7daf0 +62ac2c2ff15887ed diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantilebfloat16.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantilebfloat16.md index 32062b14900..39b45249d4f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantilebfloat16.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantilebfloat16.md @@ -3,16 +3,17 @@ 'sidebar_position': 171 'slug': '/sql-reference/aggregate-functions/reference/quantilebfloat16' 'title': 'quantileBFloat16' +'doc_type': 'reference' --- # quantileBFloat16Weighted -与 `quantileBFloat16` 类似,但考虑到每个序列成员的权重。 +类似于 `quantileBFloat16`,但考虑了每个序列成员的权重。 -计算由 [bfloat16](https://en.wikipedia.org/wiki/Bfloat16_floating-point_format) 数字组成的样本的近似 [分位数](https://en.wikipedia.org/wiki/Quantile)。`bfloat16` 是一种浮点数据类型,具有 1 个符号位、8 个指数位和 7 个尾数位。 -该函数将输入值转换为 32 位浮点数,并取最高的 16 位。然后计算 `bfloat16` 分位数值,并通过附加零位将结果转换为 64 位浮点数。 -该函数是一个快速的分位数估计器,相对误差不超过 0.390625%。 +计算由 [bfloat16](https://en.wikipedia.org/wiki/Bfloat16_floating-point_format) 数字组成的样本的近似 [分位数](https://en.wikipedia.org/wiki/Quantile)。`bfloat16` 是一种浮点数据类型,具有 1 位符号位,8 位指数位和 7 位尾数位。 +该函数将输入值转换为 32 位浮点数,并获取最重要的 16 位。然后计算 `bfloat16` 分位数值,并通过附加零位将结果转换为 64 位浮点数。 +该函数是一个快速的分位数估算器,具有不超过 0.390625% 的相对误差。 **语法** @@ -24,21 +25,21 @@ quantileBFloat16[(level)](expr) **参数** -- `expr` — 具有数值数据的列。 [整数](../../../sql-reference/data-types/int-uint.md)、[浮点数](../../../sql-reference/data-types/float.md)。 +- `expr` — 包含数值数据的列。 [整数](../../../sql-reference/data-types/int-uint.md), [浮点数](../../../sql-reference/data-types/float.md)。 **参数** -- `level` — 分位数级别。可选。可能的值范围为 0 到 1。默认值:0.5。 [浮点数](../../../sql-reference/data-types/float.md)。 +- `level` — 分位数的水平。可选。可能的值范围从 0 到 1。默认值:0.5。 [浮点数](../../../sql-reference/data-types/float.md)。 **返回值** -- 指定级别的近似分位数。 +- 指定水平的近似分位数。 类型:[Float64](/sql-reference/data-types/float)。 **示例** -输入表具有一个整数列和一个浮点列: +输入表具有整数和浮点列: ```text ┌─a─┬─────b─┐ @@ -62,9 +63,9 @@ SELECT quantileBFloat16(0.75)(a), quantileBFloat16(0.75)(b) FROM example_table; │ 3 │ 1 │ └───────────────────────────┴───────────────────────────┘ ``` -请注意,示例中所有浮点值在转换为 `bfloat16` 时均被截断为 1.0。 +注意,示例中的所有浮点值在转换为 `bfloat16` 时都被截断为 1.0。 -**另见** +**另请参见** - [median](/sql-reference/aggregate-functions/reference/median) - [quantiles](../../../sql-reference/aggregate-functions/reference/quantiles.md#quantiles) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantilebfloat16.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantilebfloat16.md.hash index 4f2964b7186..343f338e9ca 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantilebfloat16.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantilebfloat16.md.hash @@ -1 +1 @@ -20870d5a701ba6bd +384aef18e58c681f diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantileddsketch.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantileddsketch.md index ceb227ed159..cbee7e8b585 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantileddsketch.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantileddsketch.md @@ -1,11 +1,12 @@ --- -'description': '计算一个样本的近似分位数,并提供相对误差保证。' +'description': '计算样本的近似分位数,并提供相对误差保证。' 'sidebar_position': 171 'slug': '/sql-reference/aggregate-functions/reference/quantileddsketch' 'title': 'quantileDD' +'doc_type': 'reference' --- -计算具有相对误差保证的样本的近似 [quantile](https://en.wikipedia.org/wiki/Quantile)。它通过构建一个 [DD](https://www.vldb.org/pvldb/vol12/p2195-masson.pdf) 来工作。 +计算具有相对误差保证的样本近似 [分位数](https://en.wikipedia.org/wiki/Quantile)。它通过构建 [DD](https://www.vldb.org/pvldb/vol12/p2195-masson.pdf) 来实现。 **语法** @@ -15,23 +16,23 @@ quantileDD(relative_accuracy, [level])(expr) **参数** -- `expr` — 包含数值数据的列。 [Integer](../../../sql-reference/data-types/int-uint.md), [Float](../../../sql-reference/data-types/float.md)。 +- `expr` — 包含数值数据的列。 [整数](../../../sql-reference/data-types/int-uint.md),[浮点数](../../../sql-reference/data-types/float.md)。 **参数说明** -- `relative_accuracy` — 量化的相对精度。可能的值在 0 到 1 之间。[Float](../../../sql-reference/data-types/float.md)。草图的大小取决于数据的范围和相对精度。范围越大,相对精度越小,草图越大。草图的粗略内存大小为 `log(max_value/min_value)/relative_accuracy`。建议的值为 0.001 或更高。 +- `relative_accuracy` — 分位数的相对精度。可能的值范围在0到1之间。 [浮点数](../../../sql-reference/data-types/float.md)。草图的大小依赖于数据的范围和相对精度。范围越大,相对精度越小,草图越大。草图的粗略内存大小为 `log(max_value/min_value)/relative_accuracy`。推荐值为0.001或更高。 -- `level` — 量化的层级。可选。可能的值在 0 到 1 之间。默认值为 0.5。[Float](../../../sql-reference/data-types/float.md)。 +- `level` — 分位数的级别。可选。可能的值范围在0到1之间。默认值:0.5。 [浮点数](../../../sql-reference/data-types/float.md)。 **返回值** -- 指定层级的近似量化。 +- 指定级别的近似分位数。 -类型: [Float64](/sql-reference/data-types/float)。 +类型: [Float64](/sql-reference/data-types/float)。 **示例** -输入表具有一个整数列和一个浮点列: +输入表有一个整数列和一个浮点列: ```text ┌─a─┬─────b─┐ @@ -42,7 +43,7 @@ quantileDD(relative_accuracy, [level])(expr) └───┴───────┘ ``` -查询以计算 0.75-quantile(第三四分位数): +查询以计算0.75-分位数(第三四分位数): ```sql SELECT quantileDD(0.01, 0.75)(a), quantileDD(0.01, 0.75)(b) FROM example_table; @@ -56,7 +57,7 @@ SELECT quantileDD(0.01, 0.75)(a), quantileDD(0.01, 0.75)(b) FROM example_table; └─────────────────────────────────┴─────────────────────────────────┘ ``` -**另请参阅** +**另见** - [median](/sql-reference/aggregate-functions/reference/median) - [quantiles](../../../sql-reference/aggregate-functions/reference/quantiles.md#quantiles) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantileddsketch.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantileddsketch.md.hash index bd08e875011..e3e1a8cc00e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantileddsketch.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantileddsketch.md.hash @@ -1 +1 @@ -b9c1aadb3ae7c31e +090f84743c69d382 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantiledeterministic.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantiledeterministic.md index babc030faa2..878cb3100d2 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantiledeterministic.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantiledeterministic.md @@ -3,6 +3,7 @@ 'sidebar_position': 172 'slug': '/sql-reference/aggregate-functions/reference/quantiledeterministic' 'title': 'quantileDeterministic' +'doc_type': 'reference' --- @@ -10,9 +11,9 @@ 计算数字数据序列的近似 [分位数](https://en.wikipedia.org/wiki/Quantile)。 -此函数应用 [水库抽样](https://en.wikipedia.org/wiki/Reservoir_sampling),水库大小最多为 8192,并且使用确定性算法进行抽样。结果是确定性的。要获得精确的分位数,请使用 [quantileExact](/sql-reference/aggregate-functions/reference/quantileexact#quantileexact) 函数。 +此函数应用 [水库抽样](https://en.wikipedia.org/wiki/Reservoir_sampling),水库大小可达 8192,并且采用确定性抽样算法。结果是确定性的。要获得精确的分位数,请使用 [quantileExact](/sql-reference/aggregate-functions/reference/quantileexact#quantileexact) 函数。 -当在查询中使用多个不同级别的 `quantile*` 函数时,内部状态不会合并(即,查询效率低于最好状态)。在这种情况下,请使用 [quantiles](../../../sql-reference/aggregate-functions/reference/quantiles.md#quantiles) 函数。 +在查询中使用多个具有不同级别的 `quantile*` 函数时,内部状态不会结合(即,查询的效率低于预期)。在这种情况下,请使用 [quantiles](../../../sql-reference/aggregate-functions/reference/quantiles.md#quantiles) 函数。 **语法** @@ -24,9 +25,9 @@ quantileDeterministic(level)(expr, determinator) **参数** -- `level` — 分位数的级别。可选参数。范围为 0 到 1 的常量浮点数。我们建议使用 `[0.01, 0.99]` 范围内的 `level` 值。默认值:0.5。在 `level=0.5` 时,该函数计算 [中位数](https://en.wikipedia.org/wiki/Median)。 -- `expr` — 表达式,针对列值的结果为数字 [数据类型](/sql-reference/data-types)、[Date](../../../sql-reference/data-types/date.md) 或 [DateTime](../../../sql-reference/data-types/datetime.md)。 -- `determinator` — 在水库抽样算法中使用其哈希值代替随机数生成器的数字,以使抽样结果确定。作为 determinator,您可以使用任何确定性的正数,例如用户ID或事件ID。如果相同的 determinator 值发生得太频繁,该函数将无法正确工作。 +- `level` — 分位数级别。可选参数。0 到 1 之间的常量浮点数。我们建议使用 `[0.01, 0.99]` 范围内的 `level` 值。默认值:0.5。在 `level=0.5` 时,该函数计算 [中位数](https://en.wikipedia.org/wiki/Median)。 +- `expr` — 作用于列值的表达式,结果为数字 [数据类型](/sql-reference/data-types),[Date](../../../sql-reference/data-types/date.md) 或 [DateTime](../../../sql-reference/data-types/datetime.md)。 +- `determinator` — 在水库抽样算法中用来替代随机数生成器的数字的哈希值,以使抽样结果是确定性的。可以使用任何确定性的正数作为 determinator,例如,用户 ID 或事件 ID。如果相同的 determinator 值发生得太频繁,函数将无法正常工作。 **返回值** @@ -34,9 +35,9 @@ quantileDeterministic(level)(expr, determinator) 类型: -- 输入为数字数据类型时,返回 [Float64](../../../sql-reference/data-types/float.md)。 -- 如果输入值具有 `Date` 类型,则返回 [Date](../../../sql-reference/data-types/date.md)。 -- 如果输入值具有 `DateTime` 类型,则返回 [DateTime](../../../sql-reference/data-types/datetime.md)。 +- 输入为数字数据类型时为 [Float64](../../../sql-reference/data-types/float.md)。 +- 如果输入值为 `Date` 类型,则返回 [Date](../../../sql-reference/data-types/date.md)。 +- 如果输入值为 `DateTime` 类型,则返回 [DateTime](../../../sql-reference/data-types/datetime.md)。 **示例** @@ -65,7 +66,7 @@ SELECT quantileDeterministic(val, 1) FROM t └───────────────────────────────┘ ``` -**另见** +**参见** - [median](/sql-reference/aggregate-functions/reference/median) - [quantiles](../../../sql-reference/aggregate-functions/reference/quantiles.md#quantiles) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantiledeterministic.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantiledeterministic.md.hash index ff88a72b7fa..9c76f40db62 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantiledeterministic.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantiledeterministic.md.hash @@ -1 +1 @@ -b7710c6d49ccd08d +21496269cfd422a0 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantileexact.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantileexact.md index 44e3c0649b2..a01e4ac1523 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantileexact.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantileexact.md @@ -4,6 +4,7 @@ 'sidebar_position': 173 'slug': '/sql-reference/aggregate-functions/reference/quantileexact' 'title': 'quantileExact 函数' +'doc_type': 'reference' --- @@ -13,9 +14,9 @@ 准确计算数值数据序列的 [分位数](https://en.wikipedia.org/wiki/Quantile)。 -为了获得准确值,所有传递的值会组合成一个数组,然后对其进行部分排序。因此,该函数消耗 `O(n)` 内存,其中 `n` 是传递的值的数量。然而,对于较少的值,该函数非常高效。 +为了获得确切的值,所有传入的值会组合成一个数组,然后进行部分排序。因此,该函数消耗 `O(n)` 的内存,其中 `n` 是传入值的数量。然而,对于少量值,该函数的效率非常高。 -在查询中使用多个不同级别的 `quantile*` 函数时,内部状态不会合并(即,查询的效率不如可能的那样高)。在这种情况下,请使用 [quantiles](../../../sql-reference/aggregate-functions/reference/quantiles.md#quantiles) 函数。 +在查询中使用多个不同级别的 `quantile*` 函数时,内部状态不会合并(即,查询的效率低于理想情况)。在这种情况下,使用 [quantiles](../../../sql-reference/aggregate-functions/reference/quantiles.md#quantiles) 函数。 **语法** @@ -27,8 +28,8 @@ quantileExact(level)(expr) **参数** -- `level` — 分位数的级别。可选参数。0到1之间的常量浮点数。我们建议使用 `[0.01, 0.99]` 范围内的 `level` 值。默认值:0.5。在 `level=0.5` 时,函数计算 [中位数](https://en.wikipedia.org/wiki/Median)。 -- `expr` — 表达式,针对列值生成数值 [数据类型](/sql-reference/data-types)、[Date](../../../sql-reference/data-types/date.md) 或 [DateTime](../../../sql-reference/data-types/datetime.md)。 +- `level` — 分位数的级别。可选参数。常量浮点数,范围为 0 到 1。建议使用 `[0.01, 0.99]` 范围内的 `level` 值。默认值:0.5。在 `level=0.5` 时,函数计算 [中位数](https://en.wikipedia.org/wiki/Median)。 +- `expr` — 针对列值的表达式,结果为数值 [数据类型](/sql-reference/data-types),[Date](../../../sql-reference/data-types/date.md) 或 [DateTime](../../../sql-reference/data-types/datetime.md)。 **返回值** @@ -47,8 +48,6 @@ SELECT toTypeName(quantileExact(number::Float64)) AS `quantile_float64`, toTypeName(quantileExact(number::Int64)) AS `quantile_int64` FROM numbers(1) - - ┌─quantile─┬─quantile_int32─┬─quantile_float32─┬─quantile_float64─┬─quantile_int64─┐ 1. │ UInt64 │ Int32 │ Float32 │ Float64 │ Int64 │ └──────────┴────────────────┴──────────────────┴──────────────────┴────────────────┘ @@ -56,8 +55,8 @@ FROM numbers(1) 1 row in set. Elapsed: 0.002 sec. ``` -- 如果输入值的类型为 `Date`,则返回 [Date](../../../sql-reference/data-types/date.md)。 -- 如果输入值的类型为 `DateTime`,则返回 [DateTime](../../../sql-reference/data-types/datetime.md)。 +- 如果输入值具有 `Date` 类型,则返回 [Date](../../../sql-reference/data-types/date.md)。 +- 如果输入值具有 `DateTime` 类型,则返回 [DateTime](../../../sql-reference/data-types/datetime.md)。 **示例** @@ -77,13 +76,13 @@ SELECT quantileExact(number) FROM numbers(10) ## quantileExactLow {#quantileexactlow} -与 `quantileExact` 类似,该函数计算数值数据序列的精确 [分位数](https://en.wikipedia.org/wiki/Quantile)。 +与 `quantileExact` 类似,这个函数计算数值数据序列的确切 [分位数](https://en.wikipedia.org/wiki/Quantile)。 -为了获得准确值,所有传递的值会组合成一个数组,然后对其进行完全排序。排序 [算法](https://en.cppreference.com/w/cpp/algorithm/sort) 的复杂度为 `O(N·log(N))`,其中 `N = std::distance(first, last)` 比较。 +为了获取确切值,所有传入值组合成一个数组,并进行完全排序。排序 [算法](https://en.cppreference.com/w/cpp/algorithm/sort) 的复杂度为 `O(N·log(N))`,其中 `N = std::distance(first, last)` 比较次数。 -返回值依赖于分位数级别和选择中的元素数量,即如果级别为 0.5,则对于偶数个元素函数返回较低的中位数值,对于奇数个元素返回中中位数值。中位数的计算与 python 中使用的 [median_low](https://docs.python.org/3/library/statistics.html#statistics.median_low) 实现类似。 +返回值取决于分位数级别和选择中的元素数量,即如果级别是 0.5,则函数返回偶数个元素的下中位数值和奇数个元素的中位数值。中位数的计算方式类似于在 Python 中使用的 [median_low](https://docs.python.org/3/library/statistics.html#statistics.median_low) 实现。 -对于所有其他级别,返回与 `level * size_of_array` 对应的索引的元素。例如: +对于所有其他级别,返回与 `level * size_of_array` 相对应的索引处的元素。例如: ```sql SELECT quantileExactLow(0.1)(number) FROM numbers(10) @@ -93,7 +92,7 @@ SELECT quantileExactLow(0.1)(number) FROM numbers(10) └───────────────────────────────┘ ``` -在查询中使用多个不同级别的 `quantile*` 函数时,内部状态不会合并(即,查询的效率不如可能的那样高)。在这种情况下,请使用 [quantiles](/sql-reference/aggregate-functions/reference/quantiles) 函数。 +在查询中使用多个不同级别的 `quantile*` 函数时,内部状态不会合并(即,查询的效率低于理想情况)。在这种情况下,使用 [quantiles](/sql-reference/aggregate-functions/reference/quantiles) 函数。 **语法** @@ -105,8 +104,8 @@ quantileExactLow(level)(expr) **参数** -- `level` — 分位数的级别。可选参数。0到1之间的常量浮点数。我们建议使用 `[0.01, 0.99]` 范围内的 `level` 值。默认值:0.5。在 `level=0.5` 时,函数计算 [中位数](https://en.wikipedia.org/wiki/Median)。 -- `expr` — 表达式,针对列值生成数值 [数据类型](/sql-reference/data-types)、[Date](../../../sql-reference/data-types/date.md) 或 [DateTime](../../../sql-reference/data-types/datetime.md)。 +- `level` — 分位数的级别。可选参数。常量浮点数,范围为 0 到 1。建议使用 `[0.01, 0.99]` 范围内的 `level` 值。默认值:0.5。在 `level=0.5` 时,函数计算 [中位数](https://en.wikipedia.org/wiki/Median)。 +- `expr` — 针对列值的表达式,结果为数值 [数据类型](/sql-reference/data-types),[Date](../../../sql-reference/data-types/date.md) 或 [DateTime](../../../sql-reference/data-types/datetime.md)。 **返回值** @@ -114,9 +113,9 @@ quantileExactLow(level)(expr) 类型: -- 对于数值数据类型输入返回 [Float64](../../../sql-reference/data-types/float.md)。 -- 如果输入值的类型为 `Date`,则返回 [Date](../../../sql-reference/data-types/date.md)。 -- 如果输入值的类型为 `DateTime`,则返回 [DateTime](../../../sql-reference/data-types/datetime.md)。 +- [Float64](../../../sql-reference/data-types/float.md) 对于数值数据类型输入。 +- 如果输入值具有 `Date` 类型,则返回 [Date](../../../sql-reference/data-types/date.md)。 +- 如果输入值具有 `DateTime` 类型,则返回 [DateTime](../../../sql-reference/data-types/datetime.md)。 **示例** @@ -136,15 +135,15 @@ SELECT quantileExactLow(number) FROM numbers(10) ## quantileExactHigh {#quantileexacthigh} -与 `quantileExact` 类似,该函数计算数值数据序列的精确 [分位数](https://en.wikipedia.org/wiki/Quantile)。 +与 `quantileExact` 类似,这个函数计算数值数据序列的确切 [分位数](https://en.wikipedia.org/wiki/Quantile)。 -为了获得准确值,所有传递的值会组合成一个数组,然后对其进行完全排序。排序 [算法](https://en.cppreference.com/w/cpp/algorithm/sort) 的复杂度为 `O(N·log(N))`,其中 `N = std::distance(first, last)` 比较。 +所有传入值组合成一个数组,并进行完全排序,以获取确切值。排序 [算法](https://en.cppreference.com/w/cpp/algorithm/sort) 的复杂度为 `O(N·log(N))`,其中 `N = std::distance(first, last)` 比较次数。 -返回值依赖于分位数级别和选择中的元素数量,即如果级别为 0.5,则对于偶数个元素函数返回较高的中位数值,对于奇数个元素返回中中位数值。中位数的计算与 python 中使用的 [median_high](https://docs.python.org/3/library/statistics.html#statistics.median_high) 实现类似,对于所有其他级别,返回与 `level * size_of_array` 对应的索引的元素。 +返回值取决于分位数级别和选择中的元素数量,即如果级别是 0.5,则函数返回偶数元素的上中位数值和奇数元素的中位数值。中位数的计算方式与 Python 中使用的 [median_high](https://docs.python.org/3/library/statistics.html#statistics.median_high) 实现相似。对于所有其他级别,返回与 `level * size_of_array` 相对应的索引处的元素。 -此实现行为与当前 `quantileExact` 实现完全相同。 +该实现的行为与当前的 `quantileExact` 实现完全相同。 -在查询中使用多个不同级别的 `quantile*` 函数时,内部状态不会合并(即,查询的效率不如可能的那样高)。在这种情况下,请使用 [quantiles](../../../sql-reference/aggregate-functions/reference/quantiles.md#quantiles) 函数。 +在查询中使用多个不同级别的 `quantile*` 函数时,内部状态不会合并(即,查询的效率低于理想情况)。在这种情况下,使用 [quantiles](../../../sql-reference/aggregate-functions/reference/quantiles.md#quantiles) 函数。 **语法** @@ -156,8 +155,8 @@ quantileExactHigh(level)(expr) **参数** -- `level` — 分位数的级别。可选参数。0到1之间的常量浮点数。我们建议使用 `[0.01, 0.99]` 范围内的 `level` 值。默认值:0.5。在 `level=0.5` 时,函数计算 [中位数](https://en.wikipedia.org/wiki/Median)。 -- `expr` — 表达式,针对列值生成数值 [数据类型](/sql-reference/data-types)、[Date](../../../sql-reference/data-types/date.md) 或 [DateTime](../../../sql-reference/data-types/datetime.md)。 +- `level` — 分位数的级别。可选参数。常量浮点数,范围为 0 到 1。建议使用 `[0.01, 0.99]` 范围内的 `level` 值。默认值:0.5。在 `level=0.5` 时,函数计算 [中位数](https://en.wikipedia.org/wiki/Median)。 +- `expr` — 针对列值的表达式,结果为数值 [数据类型](/sql-reference/data-types),[Date](../../../sql-reference/data-types/date.md) 或 [DateTime](../../../sql-reference/data-types/datetime.md)。 **返回值** @@ -165,9 +164,9 @@ quantileExactHigh(level)(expr) 类型: -- 对于数值数据类型输入返回 [Float64](../../../sql-reference/data-types/float.md)。 -- 如果输入值的类型为 `Date`,则返回 [Date](../../../sql-reference/data-types/date.md)。 -- 如果输入值的类型为 `DateTime`,则返回 [DateTime](../../../sql-reference/data-types/datetime.md)。 +- [Float64](../../../sql-reference/data-types/float.md) 对于数值数据类型输入。 +- 如果输入值具有 `Date` 类型,则返回 [Date](../../../sql-reference/data-types/date.md)。 +- 如果输入值具有 `DateTime` 类型,则返回 [DateTime](../../../sql-reference/data-types/datetime.md)。 **示例** @@ -189,11 +188,11 @@ SELECT quantileExactHigh(number) FROM numbers(10) 准确计算数值数据序列的 [分位数](https://en.wikipedia.org/wiki/Quantile)。 -为了获得准确值,所有传递的值会组合成一个数组,然后对其进行部分排序。因此,该函数消耗 `O(n)` 内存,其中 `n` 是传递的值的数量。然而,对于较少的值,该函数非常高效。 +为了获得确切的值,所有传入的值组合成一个数组,然后进行部分排序。因此,该函数消耗 `O(n)` 的内存,其中 `n` 是传入值的数量。然而,对于少量值,该函数的效率非常高。 -此函数等价于 Excel 函数 [PERCENTILE.EXC](https://support.microsoft.com/en-us/office/percentile-exc-function-bbaa7204-e9e1-4010-85bf-c31dc5dce4ba),([type R6](https://en.wikipedia.org/wiki/Quantile#Estimating_quantiles_from_a_sample))。 +该函数等同于 [PERCENTILE.EXC](https://support.microsoft.com/en-us/office/percentile-exc-function-bbaa7204-e9e1-4010-85bf-c31dc5dce4ba) Excel 函数,([type R6](https://en.wikipedia.org/wiki/Quantile#Estimating_quantiles_from_a_sample))。 -在查询中使用多个不同级别的 `quantileExactExclusive` 函数时,内部状态不会合并(即,查询的效率不如可能的那样高)。在这种情况下,请使用 [quantilesExactExclusive](../../../sql-reference/aggregate-functions/reference/quantiles.md#quantilesexactexclusive) 函数。 +在查询中使用多个不同级别的 `quantileExactExclusive` 函数时,内部状态不会合并(即,查询的效率低于理想情况)。在这种情况下,使用 [quantilesExactExclusive](../../../sql-reference/aggregate-functions/reference/quantiles.md#quantilesexactexclusive) 函数。 **语法** @@ -203,11 +202,11 @@ quantileExactExclusive(level)(expr) **参数** -- `expr` — 表达式,针对列值生成数值 [数据类型](/sql-reference/data-types)、[Date](../../../sql-reference/data-types/date.md) 或 [DateTime](../../../sql-reference/data-types/datetime.md)。 +- `expr` — 针对列值的表达式,结果为数值 [数据类型](/sql-reference/data-types),[Date](../../../sql-reference/data-types/date.md) 或 [DateTime](../../../sql-reference/data-types/datetime.md)。 **参数** -- `level` — 分位数的级别。可选。可能的值: (0, 1) — 边界不包括。默认值:0.5。在 `level=0.5` 时,函数计算 [中位数](https://en.wikipedia.org/wiki/Median)。 [Float](../../../sql-reference/data-types/float.md)。 +- `level` — 分位数的级别。可选。可能的值:(0, 1) — 不包括边界。默认值:0.5。在 `level=0.5` 时,函数计算 [中位数](https://en.wikipedia.org/wiki/Median)。 [Float](../../../sql-reference/data-types/float.md)。 **返回值** @@ -215,9 +214,9 @@ quantileExactExclusive(level)(expr) 类型: -- 对于数值数据类型输入返回 [Float64](../../../sql-reference/data-types/float.md)。 -- 如果输入值的类型为 `Date`,则返回 [Date](../../../sql-reference/data-types/date.md)。 -- 如果输入值的类型为 `DateTime`,则返回 [DateTime](../../../sql-reference/data-types/datetime.md)。 +- [Float64](../../../sql-reference/data-types/float.md) 对于数值数据类型输入。 +- 如果输入值具有 `Date` 类型,则返回 [Date](../../../sql-reference/data-types/date.md)。 +- 如果输入值具有 `DateTime` 类型,则返回 [DateTime](../../../sql-reference/data-types/datetime.md)。 **示例** @@ -241,11 +240,11 @@ SELECT quantileExactExclusive(0.6)(x) FROM (SELECT number AS x FROM num); 准确计算数值数据序列的 [分位数](https://en.wikipedia.org/wiki/Quantile)。 -为了获得准确值,所有传递的值会组合成一个数组,然后对其进行部分排序。因此,该函数消耗 `O(n)` 内存,其中 `n` 是传递的值的数量。然而,对于较少的值,该函数非常高效。 +为了获得确切的值,所有传入的值组合成一个数组,然后进行部分排序。因此,该函数消耗 `O(n)` 的内存,其中 `n` 是传入值的数量。然而,对于少量值,该函数的效率非常高。 -此函数等价于 Excel 函数 [PERCENTILE.INC](https://support.microsoft.com/en-us/office/percentile-inc-function-680f9539-45eb-410b-9a5e-c1355e5fe2ed),([type R7](https://en.wikipedia.org/wiki/Quantile#Estimating_quantiles_from_a_sample))。 +该函数等同于 [PERCENTILE.INC](https://support.microsoft.com/en-us/office/percentile-inc-function-680f9539-45eb-410b-9a5e-c1355e5fe2ed) Excel 函数,([type R7](https://en.wikipedia.org/wiki/Quantile#Estimating_quantiles_from_a_sample))。 -在查询中使用多个不同级别的 `quantileExactInclusive` 函数时,内部状态不会合并(即,查询的效率不如可能的那样高)。在这种情况下,请使用 [quantilesExactInclusive](../../../sql-reference/aggregate-functions/reference/quantiles.md#quantilesexactinclusive) 函数。 +在查询中使用多个不同级别的 `quantileExactInclusive` 函数时,内部状态不会合并(即,查询的效率低于理想情况)。在这种情况下,使用 [quantilesExactInclusive](../../../sql-reference/aggregate-functions/reference/quantiles.md#quantilesexactinclusive) 函数。 **语法** @@ -255,11 +254,11 @@ quantileExactInclusive(level)(expr) **参数** -- `expr` — 表达式,针对列值生成数值 [数据类型](/sql-reference/data-types)、[Date](../../../sql-reference/data-types/date.md) 或 [DateTime](../../../sql-reference/data-types/datetime.md)。 +- `expr` — 针对列值的表达式,结果为数值 [数据类型](/sql-reference/data-types),[Date](../../../sql-reference/data-types/date.md) 或 [DateTime](../../../sql-reference/data-types/datetime.md)。 **参数** -- `level` — 分位数的级别。可选。可能的值:[0, 1] — 边界包括。默认值:0.5。在 `level=0.5` 时,函数计算 [中位数](https://en.wikipedia.org/wiki/Median)。 [Float](../../../sql-reference/data-types/float.md)。 +- `level` — 分位数的级别。可选。可能的值:[0, 1] — 包括边界。默认值:0.5。在 `level=0.5` 时,函数计算 [中位数](https://en.wikipedia.org/wiki/Median)。 [Float](../../../sql-reference/data-types/float.md)。 **返回值** @@ -267,9 +266,9 @@ quantileExactInclusive(level)(expr) 类型: -- 对于数值数据类型输入返回 [Float64](../../../sql-reference/data-types/float.md)。 -- 如果输入值的类型为 `Date`,则返回 [Date](../../../sql-reference/data-types/date.md)。 -- 如果输入值的类型为 `DateTime`,则返回 [DateTime](../../../sql-reference/data-types/datetime.md)。 +- [Float64](../../../sql-reference/data-types/float.md) 对于数值数据类型输入。 +- 如果输入值具有 `Date` 类型,则返回 [Date](../../../sql-reference/data-types/date.md)。 +- 如果输入值具有 `DateTime` 类型,则返回 [DateTime](../../../sql-reference/data-types/datetime.md)。 **示例** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantileexact.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantileexact.md.hash index deb1e4d8031..1b5edf305cc 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantileexact.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantileexact.md.hash @@ -1 +1 @@ -e1660a2c2ab3f30e +8bf5d25d7345f03f diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantileexactweighted.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantileexactweighted.md index 6ca2fe60a2b..0da72951854 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantileexactweighted.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantileexactweighted.md @@ -1,18 +1,19 @@ --- -'description': '精确计算数值数据序列的分位数,同时考虑每个元素的权重。' +'description': '准确计算数值数据序列的分位数,同时考虑每个元素的权重。' 'sidebar_position': 174 'slug': '/sql-reference/aggregate-functions/reference/quantileexactweighted' 'title': 'quantileExactWeighted' +'doc_type': 'reference' --- # quantileExactWeighted -准确计算数值数据序列的[分位数](https://en.wikipedia.org/wiki/Quantile),考虑到每个元素的权重。 +精确计算数字数据序列的[分位数](https://en.wikipedia.org/wiki/Quantile),考虑每个元素的权重。 -为了获得准确值,所有传入的值被组合成一个数组,然后进行部分排序。每个值按其权重计算,就好像它出现了`weight`次。在算法中使用了哈希表。因此,如果传入的值频繁重复,此函数消耗的内存比[quantileExact](/sql-reference/aggregate-functions/reference/quantileexact#quantileexact)要少。您可以将此函数替换`quantileExact`并指定权重为1。 +为了获得精确值,所有传入的值被组合成一个数组,然后部分排序。每个值的计数与其权重相结合,仿佛它出现了 `weight` 次。算法中使用了哈希表。因此,如果传入的值频繁重复,该函数消耗的内存比 [quantileExact](/sql-reference/aggregate-functions/reference/quantileexact#quantileexact) 更少。您可以使用此函数替代 `quantileExact` 并指定权重为 1。 -在查询中使用多个具有不同级别的`quantile*`函数时,内部状态不会合并(即,查询的效率不如预期)。在这种情况下,请使用[quantiles](../../../sql-reference/aggregate-functions/reference/quantiles.md#quantiles)函数。 +在查询中使用多个不同层级的 `quantile*` 函数时,内部状态不会合并(即,查询的效率低于预期)。在这种情况下,请使用 [quantiles](../../../sql-reference/aggregate-functions/reference/quantiles.md#quantiles) 函数。 **语法** @@ -20,23 +21,23 @@ quantileExactWeighted(level)(expr, weight) ``` -别名: `medianExactWeighted`. +别名: `medianExactWeighted`。 **参数** -- `level` — 分位数的级别。可选参数。介于0到1之间的常数浮点数。我们建议在`[0.01, 0.99]`范围内使用`level`值。默认值: 0.5。在`level=0.5`时,函数计算[中位数](https://en.wikipedia.org/wiki/Median)。 -- `expr` — 针对列值的表达式,返回数值[数据类型](/sql-reference/data-types),[日期](../../../sql-reference/data-types/date.md)或[日期时间](../../../sql-reference/data-types/datetime.md)。 -- `weight` — 序列成员的权重列。权重是值出现的次数,使用[无符号整数类型](../../../sql-reference/data-types/int-uint.md)。 +- `level` — 分位数层级。可选参数。0 到 1 之间的常数浮点数。我们建议使用的 `level` 值范围为 `[0.01, 0.99]`。默认值: 0.5。在 `level=0.5` 时,函数计算[中位数](https://en.wikipedia.org/wiki/Median)。 +- `expr` — 生成数字[数据类型](/sql-reference/data-types)的列值表达式,支持[日期](../../../sql-reference/data-types/date.md)或[日期时间](../../../sql-reference/data-types/datetime.md)。 +- `weight` — 序列成员的权重列。权重是具有[无符号整数类型](../../../sql-reference/data-types/int-uint.md)的值出现次数。 **返回值** -- 指定级别的分位数。 +- 指定层级的分位数。 类型: -- 输入为数值数据类型时为[Float64](../../../sql-reference/data-types/float.md)。 -- 输入值为`Date`类型时为[Date](../../../sql-reference/data-types/date.md)。 -- 输入值为`DateTime`类型时为[DateTime](../../../sql-reference/data-types/datetime.md)。 +- 对于输入为数字数据类型:[Float64](../../../sql-reference/data-types/float.md)。 +- 如果输入值类型为 `Date`,则返回[日期](../../../sql-reference/data-types/date.md)。 +- 如果输入值类型为 `DateTime`,则返回[日期时间](../../../sql-reference/data-types/datetime.md)。 **示例** @@ -65,7 +66,7 @@ SELECT quantileExactWeighted(n, val) FROM t └───────────────────────────────┘ ``` -**另请参见** +**另请参阅** - [median](/sql-reference/aggregate-functions/reference/median) - [quantiles](/sql-reference/aggregate-functions/reference/quantiles) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantileexactweighted.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantileexactweighted.md.hash index 6aa94087e68..ee22ef30f10 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantileexactweighted.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantileexactweighted.md.hash @@ -1 +1 @@ -f58cd712d76e18e9 +84f9d3d8c25b77a5 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantileexactweightedinterpolated.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantileexactweightedinterpolated.md index d5570f5a34f..f8f756f22e6 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantileexactweightedinterpolated.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantileexactweightedinterpolated.md @@ -3,18 +3,19 @@ 'sidebar_position': 176 'slug': '/sql-reference/aggregate-functions/reference/quantileExactWeightedInterpolated' 'title': 'quantileExactWeightedInterpolated' +'doc_type': 'reference' --- # quantileExactWeightedInterpolated -计算数值数据序列的[分位数](https://en.wikipedia.org/wiki/Quantile),使用线性插值,考虑每个元素的权重。 +计算数值数据序列的 [分位数](https://en.wikipedia.org/wiki/Quantile),使用线性插值,并考虑每个元素的权重。 -为了获得插值结果,所有传入的值被组合成一个数组,然后根据其对应的权重进行排序。分位数插值是通过构建基于权重的累积分布,采用[加权百分位法](https://en.wikipedia.org/wiki/Percentile#The_weighted_percentile_method)来执行的,然后使用权重和值进行线性插值以计算分位数。 +为了获得插值结果,将所有传入的值组合成一个数组,然后根据对应的权重进行排序。分位数插值然后使用 [加权百分位法](https://en.wikipedia.org/wiki/Percentile#The_weighted_percentile_method) 进行,通过基于权重构建累积分布,然后使用权重和数值进行线性插值来计算分位数。 -在查询中使用多个不同级别的 `quantile*` 函数时,内部状态不会合并(也就是说,查询的效率不如它本可以达到的那样)。在这种情况下,建议使用 [quantiles](../../../sql-reference/aggregate-functions/reference/quantiles.md#quantiles) 函数。 +在查询中使用多个不同级别的 `quantile*` 函数时,其内部状态不会合并(即查询的效率低于可能的效率)。在这种情况下,请使用 [quantiles](../../../sql-reference/aggregate-functions/reference/quantiles.md#quantiles) 函数。 -我们强烈推荐使用 `quantileExactWeightedInterpolated` 而不是 `quantileInterpolatedWeighted`,因为 `quantileExactWeightedInterpolated` 比 `quantileInterpolatedWeighted` 更加准确。以下是一个示例: +我们强烈建议使用 `quantileExactWeightedInterpolated` 而不是 `quantileInterpolatedWeighted`,因为 `quantileExactWeightedInterpolated` 的准确性高于 `quantileInterpolatedWeighted`。以下是一个示例: ```sql SELECT @@ -22,8 +23,6 @@ SELECT quantile(0.99)(number), quantileInterpolatedWeighted(0.99)(number, 1) FROM numbers(9) - - ┌─quantileExactWeightedInterpolated(0.99)(number, 1)─┬─quantile(0.99)(number)─┬─quantileInterpolatedWeighted(0.99)(number, 1)─┐ │ 7.92 │ 7.92 │ 8 │ └────────────────────────────────────────────────────┴────────────────────────┴───────────────────────────────────────────────┘ @@ -35,13 +34,13 @@ FROM numbers(9) quantileExactWeightedInterpolated(level)(expr, weight) ``` -别名: `medianExactWeightedInterpolated`. +别名:`medianExactWeightedInterpolated`。 **参数** -- `level` — 分位数的级别。可选参数。0 到 1 之间的常量浮点数。我们建议使用 `level` 值范围在 `[0.01, 0.99]` 内。默认值: 0.5。在 `level=0.5` 时,此函数计算[中位数](https://en.wikipedia.org/wiki/Median)。 -- `expr` — 针对列值的表达式,结果为数值型[数据类型](/sql-reference/data-types),[Date](../../../sql-reference/data-types/date.md) 或 [DateTime](../../../sql-reference/data-types/datetime.md)。 -- `weight` — 包含序列成员权重的列。权重是具有[无符号整数类型](../../../sql-reference/data-types/int-uint.md)的值出现次数。 +- `level` — 分位数的级别。可选参数。常量浮点数,范围从 0 到 1。我们建议使用范围在 `[0.01, 0.99]` 之间的 `level` 值。默认值:0.5。在 `level=0.5` 时,函数计算 [中位数](https://en.wikipedia.org/wiki/Median)。 +- `expr` — 针对列值的表达式,结果为数值 [数据类型](/sql-reference/data-types), [Date](../../../sql-reference/data-types/date.md) 或 [DateTime](../../../sql-reference/data-types/datetime.md)。 +- `weight` — 成员序列的权重列。权重是带有 [无符号整数类型](../../../sql-reference/data-types/int-uint.md) 的数值出现次数。 **返回值** @@ -49,9 +48,9 @@ quantileExactWeightedInterpolated(level)(expr, weight) 类型: -- 数值数据类型输入的[Float64](../../../sql-reference/data-types/float.md)。 -- 如果输入值具有 `Date` 类型,则返回[Date](../../../sql-reference/data-types/date.md)。 -- 如果输入值具有 `DateTime` 类型,则返回[DateTime](../../../sql-reference/data-types/datetime.md)。 +- 针对数值数据类型输入返回 [Float64](../../../sql-reference/data-types/float.md)。 +- 如果输入值具有 `Date` 类型,则返回 [Date](../../../sql-reference/data-types/date.md)。 +- 如果输入值具有 `DateTime` 类型,则返回 [DateTime](../../../sql-reference/data-types/datetime.md)。 **示例** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantileexactweightedinterpolated.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantileexactweightedinterpolated.md.hash index 50bf63fb8ca..65609c86cc2 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantileexactweightedinterpolated.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantileexactweightedinterpolated.md.hash @@ -1 +1 @@ -63c009764d9806e4 +e91911849fc2e7e7 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantileinterpolatedweighted.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantileinterpolatedweighted.md index 07c120e160c..90026373a51 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantileinterpolatedweighted.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantileinterpolatedweighted.md @@ -1,18 +1,19 @@ --- -'description': '计算数值数据序列的分位数,使用线性插值,同时考虑每个元素的权重。' +'description': '使用线性插值计算数值数据序列的分位数,考虑每个元素的权重。' 'sidebar_position': 176 'slug': '/sql-reference/aggregate-functions/reference/quantileInterpolatedWeighted' 'title': 'quantileInterpolatedWeighted' +'doc_type': 'reference' --- # quantileInterpolatedWeighted -计算数值数据序列的 [quantile](https://en.wikipedia.org/wiki/Quantile),使用线性插值,考虑每个元素的权重。 +计算使用线性插值的数值数据序列的 [分位数](https://en.wikipedia.org/wiki/Quantile),考虑每个元素的权重。 -为了获取插值,所有传递的值被组合成一个数组,然后根据它们相应的权重进行排序。量化插值接着使用 [weighted percentile method](https://en.wikipedia.org/wiki/Percentile#The_weighted_percentile_method) 通过基于权重构建累积分布,然后使用权重和数值进行线性插值来计算分位数。 +为了获得插值结果,将所有传入的值组合成一个数组,然后根据它们对应的权重进行排序。然后使用 [加权百分位法](https://en.wikipedia.org/wiki/Percentile#The_weighted_percentile_method) 进行分位数插值,通过基于权重构建累积分布,然后使用权重和数值进行线性插值以计算分位数。 -当在查询中使用多个不同层级的 `quantile*` 函数时,内部状态不会结合(也就是说,该查询的工作效率不如应有的高效)。在这种情况下,请使用 [quantiles](../../../sql-reference/aggregate-functions/reference/quantiles.md#quantiles) 函数。 +在查询中使用多个不同级别的 `quantile*` 函数时,内部状态不会合并(即,该查询的效率比可能更低)。在这种情况下,请使用 [quantiles](../../../sql-reference/aggregate-functions/reference/quantiles.md#quantiles) 函数。 **语法** @@ -20,23 +21,23 @@ quantileInterpolatedWeighted(level)(expr, weight) ``` -别名: `medianInterpolatedWeighted`. +别名:`medianInterpolatedWeighted`。 **参数** -- `level` — 分位数的层级。可选参数。范围从0到1的常量浮点数。我们建议使用 `[0.01, 0.99]` 范围内的 `level` 值。默认值:0.5。在 `level=0.5` 时,该函数计算 [median](https://en.wikipedia.org/wiki/Median)。 -- `expr` — 对列值的表达式,结果为数值 [data types](/sql-reference/data-types),[Date](../../../sql-reference/data-types/date.md) 或 [DateTime](../../../sql-reference/data-types/datetime.md)。 -- `weight` — 序列成员的权重列。权重是值出现的次数。 +- `level` — 分位数等级。可选参数。0 到 1 的常量浮点数。我们建议使用的 `level` 值范围为 `[0.01, 0.99]`。默认值:0.5。在 `level=0.5` 时,函数计算 [中位数](https://en.wikipedia.org/wiki/Median)。 +- `expr` — 基于列值的表达式,结果为数值 [数据类型](/sql-reference/data-types),[Date](../../../sql-reference/data-types/date.md) 或 [DateTime](../../../sql-reference/data-types/datetime.md)。 +- `weight` — 序列成员权重的列。权重是值出现的次数。 **返回值** -- 指定层级的分位数。 +- 指定级别的分位数。 类型: -- 对于数值数据类型输入为 [Float64](../../../sql-reference/data-types/float.md)。 -- 如果输入值具有 `Date` 类型,则为 [Date](../../../sql-reference/data-types/date.md)。 -- 如果输入值具有 `DateTime` 类型,则为 [DateTime](../../../sql-reference/data-types/datetime.md)。 +- 输入为数值数据类型时为 [Float64](../../../sql-reference/data-types/float.md)。 +- 输入值具有 `Date` 类型时为 [Date](../../../sql-reference/data-types/date.md)。 +- 输入值具有 `DateTime` 类型时为 [DateTime](../../../sql-reference/data-types/datetime.md)。 **示例** @@ -65,7 +66,7 @@ SELECT quantileInterpolatedWeighted(n, val) FROM t └──────────────────────────────────────┘ ``` -**参见** +**另请参见** - [median](/sql-reference/aggregate-functions/reference/median) - [quantiles](../../../sql-reference/aggregate-functions/reference/quantiles.md#quantiles) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantileinterpolatedweighted.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantileinterpolatedweighted.md.hash index 3762c235eb6..47660d167d3 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantileinterpolatedweighted.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantileinterpolatedweighted.md.hash @@ -1 +1 @@ -d02eab0e8c80cc89 +3d846f13f406e6b2 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantileprometheushistogram.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantileprometheushistogram.md new file mode 100644 index 00000000000..50b864e486b --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantileprometheushistogram.md @@ -0,0 +1,66 @@ +--- +'description': '使用线性插值计算直方图的分位数。' +'sidebar_position': 364 +'slug': '/sql-reference/aggregate-functions/reference/quantilePrometheusHistogram' +'title': 'quantilePrometheusHistogram' +'doc_type': 'reference' +--- + + +# quantilePrometheusHistogram + +计算直方图的[分位数](https://en.wikipedia.org/wiki/Quantile),使用线性插值,同时考虑每个直方图桶的累积值和上限。 + +为了获得插值,所有传入的值被组合成一个数组,然后根据相应桶的上限值进行排序。分位数插值的计算方式类似于 PromQL 的[histogram_quantile()](https://prometheus.io/docs/prometheus/latest/querying/functions/#histogram_quantile)函数,在经典直方图上执行线性插值,使用找到分位数位置的桶的下限和上限。 + +**语法** + +```sql +quantilePrometheusHistogram(level)(bucket_upper_bound, cumulative_bucket_value) +``` + +**参数** + +- `level` — 分位数的级别。可选参数。范围为 0 到 1 的常数浮点数。我们建议使用范围在`[0.01, 0.99]`之间的`level`值。默认值:`0.5`。在`level=0.5`时,函数计算[中位数](https://en.wikipedia.org/wiki/Median)。 + +- `bucket_upper_bound` — 直方图桶的上限。 + + - 最高桶的上限必须为`+Inf`。 + +- `cumulative_bucket_value` — 直方图桶的累积[UInt](../../../sql-reference/data-types/int-uint)或[Float64](../../../sql-reference/data-types/float.md)值。 + + - 随着桶的上限增加,值必须单调递增。 + +**返回值** + +- 指定级别的分位数。 + +类型: + +- `Float64`。 + +**示例** + +输入表: + +```text + ┌─bucket_upper_bound─┬─cumulative_bucket_value─┐ +1. │ 0 │ 6 │ +2. │ 0.5 │ 11 │ +3. │ 1 │ 14 │ +4. │ inf │ 19 │ + └────────────────────┴─────────────────────────┘ +``` + +结果: + +```text + ┌─quantilePrometheusHistogram(bucket_upper_bound, cumulative_bucket_value)─┐ +1. │ 0.35 │ + └──────────────────────────────────────────────────────────────────────────┘ +``` + +**另见** + +- [median](/sql-reference/aggregate-functions/reference/median) +- [quantiles](../../../sql-reference/aggregate-functions/reference/quantiles.md#quantiles) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantileprometheushistogram.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantileprometheushistogram.md.hash new file mode 100644 index 00000000000..b3bd3c9bdaf --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantileprometheushistogram.md.hash @@ -0,0 +1 @@ +f5fd71a4a2b0e07d diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantiles.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantiles.md index dbdf0f95f57..7f38fcae55f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantiles.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantiles.md @@ -3,26 +3,27 @@ 'sidebar_position': 177 'slug': '/sql-reference/aggregate-functions/reference/quantiles' 'title': 'quantiles 函数' +'doc_type': 'reference' --- -# quantiles 函数 +# quantiles functions ## quantiles {#quantiles} -语法:`quantiles(level1, level2, ...)(x)` +语法: `quantiles(level1, level2, ...)(x)` -所有的分位数函数也有相应的 quantiles 函数:`quantiles`, `quantilesDeterministic`, `quantilesTiming`, `quantilesTimingWeighted`, `quantilesExact`, `quantilesExactWeighted`, `quantileExactWeightedInterpolated`, `quantileInterpolatedWeighted`, `quantilesTDigest`, `quantilesBFloat16`, `quantilesDD`。这些函数在一次遍历中计算所有列出级别的分位数,并返回结果值的数组。 +所有的分位数函数也都有对应的分位数函数: `quantiles`, `quantilesDeterministic`, `quantilesTiming`, `quantilesTimingWeighted`, `quantilesExact`, `quantilesExactWeighted`, `quantileExactWeightedInterpolated`, `quantileInterpolatedWeighted`, `quantilesTDigest`, `quantilesBFloat16`, `quantilesDD`。这些函数在一次运行中计算出所有列出的级别的分位数,并返回结果值的数组。 ## quantilesExactExclusive {#quantilesexactexclusive} -准确计算数值数据序列的 [分位数](https://en.wikipedia.org/wiki/Quantile)。 +精确计算数字数据序列的 [分位数](https://en.wikipedia.org/wiki/Quantile)。 -为了获得精确值,所有传递的值都组合成一个数组,然后进行部分排序。因此,函数消耗 `O(n)` 的内存,其中 `n` 是传递的值的数量。然而,对于少量值,该函数非常有效。 +为了获取确切值,所有传入的值被合并成一个数组,然后进行部分排序。因此,该函数消耗 `O(n)` 的内存,其中 `n` 是传入值的数量。然而,对于少量值,该函数非常有效。 -该函数等同于 Excel 函数 [PERCENTILE.EXC](https://support.microsoft.com/en-us/office/percentile-exc-function-bbaa7204-e9e1-4010-85bf-c31dc5dce4ba),([类型 R6](https://en.wikipedia.org/wiki/Quantile#Estimating_quantiles_from_a_sample))。 +此函数等价于 Excel 函数 [PERCENTILE.EXC](https://support.microsoft.com/en-us/office/percentile-exc-function-bbaa7204-e9e1-4010-85bf-c31dc5dce4ba),([type R6](https://en.wikipedia.org/wiki/Quantile#Estimating_quantiles_from_a_sample))。 -与 [quantileExactExclusive](../../../sql-reference/aggregate-functions/reference/quantileexact.md#quantileexactexclusive) 相比,处理级别集合时更高效。 +与 [quantileExactExclusive](../../../sql-reference/aggregate-functions/reference/quantileexact.md#quantileexactexclusive) 相比,它在处理级别集时更高效。 **语法** @@ -32,21 +33,21 @@ quantilesExactExclusive(level1, level2, ...)(expr) **参数** -- `expr` — 对列值的表达式,结果为数值 [数据类型](/sql-reference/data-types)、[Date](../../../sql-reference/data-types/date.md) 或 [DateTime](../../../sql-reference/data-types/datetime.md)。 +- `expr` — 表示列值的表达式,结果为数字 [数据类型](/sql-reference/data-types)、[Date](../../../sql-reference/data-types/date.md) 或 [DateTime](../../../sql-reference/data-types/datetime.md)。 -**参数** +**参数说明** -- `level` — 分位数的级别。可能的值:(0, 1)— 不包括边界。[Float](../../../sql-reference/data-types/float.md)。 +- `level` — 分位数的级别。可能的值: (0, 1) — 不包括边界。 [Float](../../../sql-reference/data-types/float.md)。 **返回值** -- [Array](../../../sql-reference/data-types/array.md) 指定级别的分位数。 +- 指定级别的 [Array](../../../sql-reference/data-types/array.md) 的分位数。 数组值的类型: -- 输入为数值数据类型时为 [Float64](../../../sql-reference/data-types/float.md)。 -- 如果输入值为 `Date` 类型,则为 [Date](../../../sql-reference/data-types/date.md)。 -- 如果输入值为 `DateTime` 类型,则为 [DateTime](../../../sql-reference/data-types/datetime.md)。 +- 对于数字数据类型输入,为 [Float64](../../../sql-reference/data-types/float.md)。 +- 如果输入值具有 `Date` 类型,则为 [Date](../../../sql-reference/data-types/date.md)。 +- 如果输入值具有 `DateTime` 类型,则为 [DateTime](../../../sql-reference/data-types/datetime.md)。 **示例** @@ -68,13 +69,13 @@ SELECT quantilesExactExclusive(0.25, 0.5, 0.75, 0.9, 0.95, 0.99, 0.999)(x) FROM ## quantilesExactInclusive {#quantilesexactinclusive} -准确计算数值数据序列的 [分位数](https://en.wikipedia.org/wiki/Quantile)。 +精确计算数字数据序列的 [分位数](https://en.wikipedia.org/wiki/Quantile)。 -为了获得精确值,所有传递的值都组合成一个数组,然后进行部分排序。因此,函数消耗 `O(n)` 的内存,其中 `n` 是传递的值的数量。然而,对于少量值,该函数非常有效。 +为了获取确切值,所有传入的值被合并成一个数组,然后进行部分排序。因此,该函数消耗 `O(n)` 的内存,其中 `n` 是传入值的数量。然而,对于少量值,该函数非常有效。 -该函数等同于 Excel 函数 [PERCENTILE.INC](https://support.microsoft.com/en-us/office/percentile-inc-function-680f9539-45eb-410b-9a5e-c1355e5fe2ed),([类型 R7](https://en.wikipedia.org/wiki/Quantile#Estimating_quantiles_from_a_sample))。 +此函数等价于 Excel 函数 [PERCENTILE.INC](https://support.microsoft.com/en-us/office/percentile-inc-function-680f9539-45eb-410b-9a5e-c1355e5fe2ed),([type R7](https://en.wikipedia.org/wiki/Quantile#Estimating_quantiles_from_a_sample))。 -与 [quantileExactInclusive](../../../sql-reference/aggregate-functions/reference/quantileexact.md#quantileexactinclusive) 相比,处理级别集合时更高效。 +与 [quantileExactInclusive](../../../sql-reference/aggregate-functions/reference/quantileexact.md#quantileexactinclusive) 相比,它在处理级别集时更高效。 **语法** @@ -84,21 +85,21 @@ quantilesExactInclusive(level1, level2, ...)(expr) **参数** -- `expr` — 对列值的表达式,结果为数值 [数据类型](/sql-reference/data-types)、[Date](../../../sql-reference/data-types/date.md) 或 [DateTime](../../../sql-reference/data-types/datetime.md)。 +- `expr` — 表示列值的表达式,结果为数字 [数据类型](/sql-reference/data-types)、[Date](../../../sql-reference/data-types/date.md) 或 [DateTime](../../../sql-reference/data-types/datetime.md)。 -**参数** +**参数说明** -- `level` — 分位数的级别。可能的值:[0, 1] — 包括边界。[Float](../../../sql-reference/data-types/float.md)。 +- `level` — 分位数的级别。可能的值: [0, 1] — 包括边界。 [Float](../../../sql-reference/data-types/float.md)。 **返回值** -- [Array](../../../sql-reference/data-types/array.md) 指定级别的分位数。 +- 指定级别的 [Array](../../../sql-reference/data-types/array.md) 的分位数。 数组值的类型: -- 输入为数值数据类型时为 [Float64](../../../sql-reference/data-types/float.md)。 -- 如果输入值为 `Date` 类型,则为 [Date](../../../sql-reference/data-types/date.md)。 -- 如果输入值为 `DateTime` 类型,则为 [DateTime](../../../sql-reference/data-types/datetime.md)。 +- 对于数字数据类型输入,为 [Float64](../../../sql-reference/data-types/float.md)。 +- 如果输入值具有 `Date` 类型,则为 [Date](../../../sql-reference/data-types/date.md)。 +- 如果输入值具有 `DateTime` 类型,则为 [DateTime](../../../sql-reference/data-types/datetime.md)。 **示例** @@ -120,7 +121,7 @@ SELECT quantilesExactInclusive(0.25, 0.5, 0.75, 0.9, 0.95, 0.99, 0.999)(x) FROM ## quantilesGK {#quantilesgk} -`quantilesGK` 的工作方式与 `quantileGK` 类似,但允许我们同时计算不同级别的分位数,并返回一个数组。 +`quantilesGK` 的工作方式类似于 `quantileGK`,但允许我们同时计算不同级别的分位数并返回一个数组。 **语法** @@ -130,13 +131,13 @@ quantilesGK(accuracy, level1, level2, ...)(expr) **返回值** -- [Array](../../../sql-reference/data-types/array.md) 指定级别的分位数。 +- 指定级别的 [Array](../../../sql-reference/data-types/array.md) 的分位数。 数组值的类型: -- 输入为数值数据类型时为 [Float64](../../../sql-reference/data-types/float.md)。 -- 如果输入值为 `Date` 类型,则为 [Date](../../../sql-reference/data-types/date.md)。 -- 如果输入值为 `DateTime` 类型,则为 [DateTime](../../../sql-reference/data-types/datetime.md)。 +- 对于数字数据类型输入,为 [Float64](../../../sql-reference/data-types/float.md)。 +- 如果输入值具有 `Date` 类型,则为 [Date](../../../sql-reference/data-types/date.md)。 +- 如果输入值具有 `DateTime` 类型,则为 [DateTime](../../../sql-reference/data-types/datetime.md)。 **示例** @@ -156,8 +157,6 @@ FROM numbers(1000) ┌─quantilesGK(10, 0.25, 0.5, 0.75)(plus(number, 1))─┐ │ [156,413,659] │ └───────────────────────────────────────────────────┘ - - SELECT quantilesGK(100, 0.25, 0.5, 0.75)(number + 1) FROM numbers(1000) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantiles.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantiles.md.hash index dea796c31ea..95683ea9737 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantiles.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantiles.md.hash @@ -1 +1 @@ -324dfef57cc31f22 +f283f681f1432870 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantiletdigest.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantiletdigest.md index bef3604c63e..2a883c43aee 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantiletdigest.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantiletdigest.md @@ -1,20 +1,21 @@ --- -'description': '使用 t-digest 算法计算数值数据序列的近似分位数。' +'description': '使用t-digest算法计算数字数据序列的近似分位数。' 'sidebar_position': 178 'slug': '/sql-reference/aggregate-functions/reference/quantiletdigest' 'title': 'quantileTDigest' +'doc_type': 'reference' --- # quantileTDigest -计算数值数据序列的近似 [quantile](https://en.wikipedia.org/wiki/Quantile),使用 [t-digest](https://github.com/tdunning/t-digest/blob/master/docs/t-digest-paper/histo.pdf) 算法。 +计算一个数字数据序列的近似[分位数](https://en.wikipedia.org/wiki/Quantile),使用[t-digest](https://github.com/tdunning/t-digest/blob/master/docs/t-digest-paper/histo.pdf)算法。 -内存消耗为 `log(n)`,其中 `n` 是值的数量。结果依赖于查询的执行顺序,并且是非确定性的。 +内存消耗为 `log(n)`,其中 `n` 是值的数量。结果依赖于查询的执行顺序,且是非确定性的。 -该函数的性能低于 [quantile](/sql-reference/aggregate-functions/reference/quantile) 或 [quantileTiming](/sql-reference/aggregate-functions/reference/quantiletiming)。就状态大小与精度的比率而言,该函数要比 `quantile` 好得多。 +该函数的性能低于[quantile](/sql-reference/aggregate-functions/reference/quantile)或[quantileTiming](/sql-reference/aggregate-functions/reference/quantiletiming)的性能。在状态大小与精度的比率方面,该函数远比`quantile`更好。 -在一个查询中使用多个不同级别的 `quantile*` 函数时,内部状态不会被合并(也就是说,查询的效率低于它原本可以达到的效率)。这种情况下,请使用 [quantiles](../../../sql-reference/aggregate-functions/reference/quantiles.md#quantiles) 函数。 +当在一个查询中使用多个具有不同级别的`quantile*`函数时,内部状态不会合并(也就是说,查询的效率低于可能的效率)。在这种情况下,请使用[quantiles](../../../sql-reference/aggregate-functions/reference/quantiles.md#quantiles)函数。 **语法** @@ -26,8 +27,8 @@ quantileTDigest(level)(expr) **参数** -- `level` — 分位数级别。可选参数。范围从 0 到 1 的常量浮点数。我们建议使用范围在 `[0.01, 0.99]` 的 `level` 值。默认值:0.5。在 `level=0.5` 时,函数计算 [median](https://en.wikipedia.org/wiki/Median)。 -- `expr` — 对列值的表达式,返回数值 [data types](/sql-reference/data-types)、[Date](../../../sql-reference/data-types/date.md) 或 [DateTime](../../../sql-reference/data-types/datetime.md)。 +- `level` — 分位数的级别。可选参数。范围从 0 到 1 的常量浮点数。我们推荐使用 `[0.01, 0.99]` 范围内的 `level` 值。默认值:0.5。在 `level=0.5` 时,该函数计算[中位数](https://en.wikipedia.org/wiki/Median)。 +- `expr` — 对列值的表达式,结果为数字[数据类型](/sql-reference/data-types)、[日期](../../../sql-reference/data-types/date.md)或[日期时间](../../../sql-reference/data-types/datetime.md)。 **返回值** @@ -35,9 +36,9 @@ quantileTDigest(level)(expr) 类型: -- 对于数值数据类型输入,为 [Float64](../../../sql-reference/data-types/float.md)。 -- 如果输入值具有 `Date` 类型,则为 [Date](../../../sql-reference/data-types/date.md)。 -- 如果输入值具有 `DateTime` 类型,则为 [DateTime](../../../sql-reference/data-types/datetime.md)。 +- 输入为数字数据类型时为[Float64](../../../sql-reference/data-types/float.md)。 +- 输入值为`Date`类型时为[Date](../../../sql-reference/data-types/date.md)。 +- 输入值为`DateTime`类型时为[DateTime](../../../sql-reference/data-types/datetime.md)。 **示例** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantiletdigest.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantiletdigest.md.hash index 80b127eb456..9efcf11ab7f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantiletdigest.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantiletdigest.md.hash @@ -1 +1 @@ -a9b5545853765c97 +120643f3ace9e6d1 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantiletdigestweighted.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantiletdigestweighted.md index b27981df991..ec318f5e8ee 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantiletdigestweighted.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantiletdigestweighted.md @@ -3,21 +3,22 @@ 'sidebar_position': 179 'slug': '/sql-reference/aggregate-functions/reference/quantiletdigestweighted' 'title': 'quantileTDigestWeighted' +'doc_type': 'reference' --- # quantileTDigestWeighted -使用 [t-digest](https://github.com/tdunning/t-digest/blob/master/docs/t-digest-paper/histo.pdf) 算法计算数值数据序列的近似 [分位数](https://en.wikipedia.org/wiki/Quantile)。该函数考虑了每个序列成员的权重。最大误差为 1%。内存消耗为 `log(n)`,其中 `n` 是值的数量。 +使用[t-digest](https://github.com/tdunning/t-digest/blob/master/docs/t-digest-paper/histo.pdf)算法计算数值数据序列的近似[分位数](https://en.wikipedia.org/wiki/Quantile)。该函数考虑了每个序列成员的权重。最大错误为1%。内存消耗为`log(n)`,其中`n`是值的数量。 -该函数的性能低于 [quantile](/sql-reference/aggregate-functions/reference/quantile) 或 [quantileTiming](/sql-reference/aggregate-functions/reference/quantiletiming)。在状态大小与精度的比率方面,该函数比 `quantile` 要好得多。 +该函数的性能低于[quantile](/sql-reference/aggregate-functions/reference/quantile)或[quantileTiming](/sql-reference/aggregate-functions/reference/quantiletiming)的性能。在状态大小与精度的比率方面,该函数比`quantile`要好得多。 -结果依赖于查询运行的顺序,是非确定性的。 +结果依赖于查询的执行顺序,并且是非确定性的。 -在查询中使用多个不同水平的 `quantile*` 函数时,内部状态不会被结合(即,查询的效率低于其可以达到的效率)。在这种情况下,请使用 [quantiles](../../../sql-reference/aggregate-functions/reference/quantiles.md#quantiles) 函数。 +在查询中使用多个不同层级的`quantile*`函数时,内部状态不会被组合(即,查询的效率低于可能的效率)。在这种情况下,请使用[quantiles](../../../sql-reference/aggregate-functions/reference/quantiles.md#quantiles)函数。 :::note -使用 `quantileTDigestWeighted` [不推荐用于小数据集](https://github.com/tdunning/t-digest/issues/167#issuecomment-828650275),可能会导致显著的误差。在这种情况下,可以考虑使用 [`quantileTDigest`](../../../sql-reference/aggregate-functions/reference/quantiletdigest.md) 替代。 +使用`quantileTDigestWeighted` [不推荐用于小型数据集](https://github.com/tdunning/t-digest/issues/167#issuecomment-828650275),并可能导致显著误差。在这种情况下,请考虑使用[`quantileTDigest`](../../../sql-reference/aggregate-functions/reference/quantiletdigest.md)。 ::: **语法** @@ -26,23 +27,23 @@ quantileTDigestWeighted(level)(expr, weight) ``` -别名: `medianTDigestWeighted`。 +别名:`medianTDigestWeighted`。 **参数** -- `level` — 分位数的水平。可选参数。常量浮点数,范围从 0 到 1。我们推荐使用 `[0.01, 0.99]` 范围内的 `level` 值。默认值:0.5。在 `level=0.5` 时,该函数计算 [中位数](https://en.wikipedia.org/wiki/Median)。 -- `expr` — 对列值的表达式,结果为数值 [数据类型](/sql-reference/data-types)、[Date](../../../sql-reference/data-types/date.md) 或 [DateTime](../../../sql-reference/data-types/datetime.md)。 -- `weight` — 包含序列元素权重的列。权重是值出现的次数。 +- `level` — 分位数层级。可选参数。范围从0到1的常量浮点数。推荐使用`level`值在`[0.01, 0.99]`范围内。默认值:0.5。在`level=0.5`时,该函数计算[中位数](https://en.wikipedia.org/wiki/Median)。 +- `expr` — 针对列值的表达式,结果为数值[数据类型](/sql-reference/data-types)、[Date](../../../sql-reference/data-types/date.md)或[DateTime](../../../sql-reference/data-types/datetime.md)。 +- `weight` — 带有序列元素权重的列。权重是值出现的次数。 **返回值** -- 指定水平的近似分位数。 +- 指定层级的近似分位数。 类型: -- 对于数值数据类型输入,返回 [Float64](../../../sql-reference/data-types/float.md)。 -- 如果输入值具有 `Date` 类型,则返回 [Date](../../../sql-reference/data-types/date.md)。 -- 如果输入值具有 `DateTime` 类型,则返回 [DateTime](../../../sql-reference/data-types/datetime.md)。 +- 对于数值数据类型输入,返回[Float64](../../../sql-reference/data-types/float.md)。 +- 如果输入值为`Date`类型,则返回[Date](../../../sql-reference/data-types/date.md)。 +- 如果输入值为`DateTime`类型,则返回[DateTime](../../../sql-reference/data-types/datetime.md)。 **示例** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantiletdigestweighted.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantiletdigestweighted.md.hash index 3ad96cdc9a3..af5d70c6dac 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantiletdigestweighted.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantiletdigestweighted.md.hash @@ -1 +1 @@ -2ef83c323f4d1d86 +987698473cd8f71d diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantiletiming.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantiletiming.md index 0da4ef0ae59..37a0e0c619a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantiletiming.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantiletiming.md @@ -1,18 +1,19 @@ --- -'description': '使用确定的精度计算数字数据序列的分位数。' +'description': '使用确定的精度计算数值数据序列的分位数。' 'sidebar_position': 180 'slug': '/sql-reference/aggregate-functions/reference/quantiletiming' 'title': 'quantileTiming' +'doc_type': 'reference' --- # quantileTiming -使用确定的精度计算数值数据序列的 [分位数](https://en.wikipedia.org/wiki/Quantile)。 +通过确定的精度计算数字数据序列的 [quantile](https://en.wikipedia.org/wiki/Quantile)。 -结果是确定性的(它不依赖于查询处理顺序)。该函数经过优化,适用于描述分布的序列,例如加载网页的时间或后端响应时间。 +结果是确定性的(它不依赖于查询处理顺序)。该函数经过优化,适用于描述诸如网页加载时间或后端响应时间等分布的序列。 -当在查询中使用多个 `quantile*` 函数和不同的级别时,内部状态不会合并(即,查询的工作效率低于潜在的效率)。在这种情况下,请使用 [quantiles](../../../sql-reference/aggregate-functions/reference/quantiles.md#quantiles) 函数。 +在查询中使用多个不同级别的 `quantile*` 函数时,内部状态不会组合(也就是说,查询的效率低于可能的效率)。在这种情况下,请使用 [quantiles](../../../sql-reference/aggregate-functions/reference/quantiles.md#quantiles) 函数。 **语法** @@ -20,38 +21,38 @@ quantileTiming(level)(expr) ``` -别名: `medianTiming`。 +别名:`medianTiming`。 **参数** -- `level` — 分位数的级别。可选参数。范围从 0 到 1 的常量浮点数。我们建议使用 `level` 值在 `[0.01, 0.99]` 的范围内。默认值:0.5。在 `level=0.5` 时,该函数计算 [中位数](https://en.wikipedia.org/wiki/Median)。 +- `level` — 分位数的级别。可选参数。常量浮点数,范围为 0 到 1。我们建议使用 `[0.01, 0.99]` 范围内的 `level` 值。默认值:0.5。在 `level=0.5` 时,该函数计算 [median](https://en.wikipedia.org/wiki/Median)。 -- `expr` — 针对列值的 [表达式](/sql-reference/syntax#expressions),返回 [Float\*](../../../sql-reference/data-types/float.md) 类型的数字。 +- `expr` — [表达式](/sql-reference/syntax#expressions),对列值进行操作,返回 [Float\*](../../../sql-reference/data-types/float.md) 类型的数字。 - - 如果传递负值给函数,则行为未定义。 - - 如果值大于 30,000(页面加载时间超过 30 秒),则假定为 30,000。 + - 如果传递给函数的是负值,则行为是未定义的。 + - 如果值大于 30,000(加载时间超过 30 秒),则假定其为 30,000。 **准确性** 如果满足以下条件,则计算是准确的: - 值的总数不超过 5670。 -- 值的总数超过 5670,但页面加载时间小于 1024 毫秒。 +- 值的总数超过 5670,但页面加载时间少于 1024 毫秒。 -否则,计算结果将舍入到最接近的 16 毫秒的倍数。 +否则,计算结果将四舍五入到最接近的 16 毫秒的倍数。 :::note -在计算页面加载时间的分位数时,该函数比 [quantile](/sql-reference/aggregate-functions/reference/quantile) 更有效且更准确。 +对于计算页面加载时间的分位数,该函数比 [quantile](/sql-reference/aggregate-functions/reference/quantile) 更有效且更准确。 ::: **返回值** - 指定级别的分位数。 -类型: `Float32`。 +类型:`Float32`。 :::note -如果没有值传递给函数(使用 `quantileTimingIf` 时),将返回 [NaN](/sql-reference/data-types/float#nan-and-inf)。这样做的目的是将这些情况与导致零的情况区分开。有关排序 `NaN` 值的说明,请参见 [ORDER BY 子句](/sql-reference/statements/select/order-by)。 +如果没有值传递给该函数(使用 `quantileTimingIf` 时),将返回 [NaN](/sql-reference/data-types/float#nan-and-inf)。这样做是为了将这些情况与结果为零的情况区分开。有关排序 `NaN` 值的说明,请参见 [ORDER BY 子句](/sql-reference/statements/select/order-by)。 ::: **示例** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantiletiming.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantiletiming.md.hash index c9c9d0b3cab..56d9199f56b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantiletiming.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantiletiming.md.hash @@ -1 +1 @@ -8043685a01ca1ac4 +2b8816aa0682bb90 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantiletimingweighted.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantiletimingweighted.md index 76cf32d4f49..f4942b08b1b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantiletimingweighted.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantiletimingweighted.md @@ -1,18 +1,19 @@ --- -'description': '根据每个序列成员的权重,以确定的精度计算数字数据序列的分位数。' +'description': '根据每个序列成员的权重,用确定的精度计算数字数据序列的分位数。' 'sidebar_position': 181 'slug': '/sql-reference/aggregate-functions/reference/quantiletimingweighted' 'title': 'quantileTimingWeighted' +'doc_type': 'reference' --- # quantileTimingWeighted -使用确定的精度,根据每个序列成员的权重计算数值数据序列的 [分位数](https://en.wikipedia.org/wiki/Quantile)。 +在确定的精度下,根据每个序列成员的权重计算数字数据序列的 [分位数](https://en.wikipedia.org/wiki/Quantile)。 -结果是确定性的(不依赖于查询处理顺序)。该函数经过优化,可以与描述分布的序列一起使用,如加载网页时间或后端响应时间。 +结果是确定性的(不依赖于查询处理顺序)。该函数经过优化,用于处理描述分布的序列,如加载网页时间或后端响应时间。 -在查询中使用多个不同级别的 `quantile*` 函数时,内部状态不会合并(即,查询的工作效率低于可能的效率)。在这种情况下,请使用 [quantiles](../../../sql-reference/aggregate-functions/reference/quantiles.md#quantiles) 函数。 +当在查询中使用多个 `quantile*` 函数且有不同的级别时,内部状态不会合并(即,查询工作效率低于可能的效率)。在这种情况下,请使用 [quantiles](../../../sql-reference/aggregate-functions/reference/quantiles.md#quantiles) 函数。 **语法** @@ -24,36 +25,36 @@ quantileTimingWeighted(level)(expr, weight) **参数** -- `level` — 分位数的级别。可选参数。范围为 0 到 1 的常量浮点数。我们建议使用范围在 `[0.01, 0.99]` 之间的 `level` 值。默认值:0.5。当 `level=0.5` 时,该函数计算 [中位数](https://en.wikipedia.org/wiki/Median)。 +- `level` — 分位数的级别。可选参数。范围在 0 到 1 之间的常量浮点数。我们建议使用范围在 `[0.01, 0.99]` 之间的 `level` 值。默认值:0.5。 在 `level=0.5` 时,函数计算 [中位数](https://en.wikipedia.org/wiki/Median)。 -- `expr` — 对列值的 [表达式](/sql-reference/syntax#expressions),返回一个 [Float\*](../../../sql-reference/data-types/float.md)-类型的数字。 +- `expr` — 针对列值的 [表达式](/sql-reference/syntax#expressions),返回一个 [Float\*](../../../sql-reference/data-types/float.md) 类型的数字。 - - 如果传递给函数的是负值,则行为未定义。 - - 如果值大于 30,000(加载时间超过 30 秒),则假定为 30,000。 + - 如果传递负值给函数,行为是未定义的。 + - 如果值大于 30,000(页面加载时间超过 30 秒),则假定为 30,000。 -- `weight` — 包含序列元素权重的列。权重是值出现次数的数字。 +- `weight` — 包含序列元素权重的列。权重是数值出现次数。 -**精确度** +**准确性** -计算准确的条件为: +如果满足以下条件,则计算结果是准确的: - 值的总数不超过 5670。 - 值的总数超过 5670,但页面加载时间小于 1024ms。 -否则,计算结果将四舍五入到 16 毫秒的最接近倍数。 +否则,计算结果会四舍五入到最接近的 16 ms 的倍数。 :::note -在计算页面加载时间分位数时,该函数比 [quantile](/sql-reference/aggregate-functions/reference/quantile) 更有效且准确。 +对于计算页面加载时间的分位数,此函数比 [quantile](/sql-reference/aggregate-functions/reference/quantile) 更有效和准确。 ::: **返回值** - 指定级别的分位数。 -类型: `Float32`。 +类型:`Float32`。 :::note -如果没有值传递给函数(使用 `quantileTimingIf` 时),将返回 [NaN](/sql-reference/data-types/float#nan-and-inf)。此目的在于将这些情况与结果为零的情况区分开。有关排序 `NaN` 值的说明,请参阅 [ORDER BY 子句](/sql-reference/statements/select/order-by)。 +如果没有值传递给函数(在使用 `quantileTimingIf` 时),将返回 [NaN](/sql-reference/data-types/float#nan-and-inf)。其目的是将这些情况与结果为零的情况区分开。有关排序 `NaN` 值的说明,请参见 [ORDER BY 子句](/sql-reference/statements/select/order-by)。 ::: **示例** @@ -88,7 +89,7 @@ SELECT quantileTimingWeighted(response_time, weight) FROM t # quantilesTimingWeighted -与 `quantileTimingWeighted` 相同,但接受多个具有分位数级别的参数,并返回一个填充多个分位数值的数组。 +与 `quantileTimingWeighted` 相同,但接受多个参数的分位数级别,并返回填充多个分位数值的数组。 **示例** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantiletimingweighted.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantiletimingweighted.md.hash index 89e4d94018d..b2bb4d2432f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantiletimingweighted.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/quantiletimingweighted.md.hash @@ -1 +1 @@ -635dbedbe2514084 +87e9bb9390b68585 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/rankCorr.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/rankCorr.md index d3e4cae514b..274b118f0ad 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/rankCorr.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/rankCorr.md @@ -3,6 +3,7 @@ 'sidebar_position': 182 'slug': '/sql-reference/aggregate-functions/reference/rankCorr' 'title': 'rankCorr' +'doc_type': 'reference' --- @@ -18,14 +19,14 @@ rankCorr(x, y) **参数** -- `x` — 任意值。[Float32](/sql-reference/data-types/float) 或 [Float64](/sql-reference/data-types/float)。 -- `y` — 任意值。[Float32](/sql-reference/data-types/float) 或 [Float64](/sql-reference/data-types/float)。 +- `x` — 任意值。 [Float32](/sql-reference/data-types/float) 或 [Float64](/sql-reference/data-types/float)。 +- `y` — 任意值。 [Float32](/sql-reference/data-types/float) 或 [Float64](/sql-reference/data-types/float)。 **返回值** -- 返回 x 和 y 的秩相关系数。相关系数的值范围从 -1 到 +1。如果传入的参数少于两个,则该函数将返回异常。接近 +1 的值表示高度线性关系,当一个随机变量增加时,第二个随机变量也增加。接近 -1 的值表示高度线性关系,当一个随机变量增加时,第二个随机变量减少。接近或等于 0 的值表示两个随机变量之间没有关系。 +- 返回 x 和 y 的秩的秩相关系数。相关系数的值范围从 -1 到 +1。如果传入的参数少于两个,该函数将返回异常。接近 +1 的值表示高线性关系,意味着随着一个随机变量的增加,第二个随机变量也增加。接近 -1 的值表示高线性关系,意味着随着一个随机变量的增加,第二个随机变量减少。接近或等于 0 的值表示两个随机变量之间没有关系。 -类型:[Float64](/sql-reference/data-types/float)。 +类型: [Float64](/sql-reference/data-types/float)。 **示例** @@ -56,7 +57,6 @@ SELECT roundBankers(rankCorr(exp(number), sin(number)), 3) FROM numbers(100); │ -0.037 │ └─────────────────────────────────────────────────────┘ ``` - -**另请参阅** +**参见** - [斯皮尔曼秩相关系数](https://en.wikipedia.org/wiki/Spearman%27s_rank_correlation_coefficient) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/rankCorr.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/rankCorr.md.hash index aae00acd678..72fc6b9d920 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/rankCorr.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/rankCorr.md.hash @@ -1 +1 @@ -67f851704d79ec78 +b17f3941bbada901 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/simplelinearregression.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/simplelinearregression.md index 25d9bbbf16a..ae73a75abff 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/simplelinearregression.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/simplelinearregression.md @@ -3,6 +3,7 @@ 'sidebar_position': 183 'slug': '/sql-reference/aggregate-functions/reference/simplelinearregression' 'title': 'simpleLinearRegression' +'doc_type': 'reference' --- @@ -16,12 +17,12 @@ simpleLinearRegression(x, y) 参数: -- `x` — 含有解释变量值的列。 -- `y` — 含有因变量值的列。 +- `x` — 包含解释变量值的列。 +- `y` — 包含因变量值的列。 返回值: -结果线的常数 `(k, b)`,即 `y = k*x + b`。 +结果线 `y = k*x + b` 的常数 `(k, b)`。 **示例** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/simplelinearregression.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/simplelinearregression.md.hash index 0416514d993..9660af87058 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/simplelinearregression.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/simplelinearregression.md.hash @@ -1 +1 @@ -2f7f5c26af2a6865 +31663c8a2605a371 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/singlevalueornull.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/singlevalueornull.md index cf186ae75c2..886d421fef4 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/singlevalueornull.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/singlevalueornull.md @@ -1,8 +1,10 @@ --- -'description': '聚合函数 `singleValueOrNull` 用于实现子查询操作符,例如 `x = ALL (SELECT...)`。它检查数据中是否只有一个唯一的非NULL值。' +'description': '聚合函数 `singleValueOrNull` 用于实现子查询操作符,例如 `x = ALL (SELECT ...)`。它检查数据中是否只有一个唯一的非 + NULL 值。' 'sidebar_position': 184 'slug': '/sql-reference/aggregate-functions/reference/singlevalueornull' 'title': 'singleValueOrNull' +'doc_type': 'reference' --- @@ -19,11 +21,11 @@ singleValueOrNull(x) **参数** -- `x` — 任何 [数据类型](../../data-types/index.md) 的列(不包括 [Map](../../data-types/map.md)、[Array](../../data-types/array.md) 或 [Tuple](../../data-types/tuple),这些类型不能为 [Nullable](../../data-types/nullable.md))。 +- `x` — 任何 [数据类型](../../data-types/index.md) 的列(除了 [Map](../../data-types/map.md)、[Array](../../data-types/array.md) 或 [Tuple](../../data-types/tuple) 不能为 [Nullable](../../data-types/nullable.md) 类型)。 **返回值** -- 如果 `x` 中仅有一个唯一的非 NULL 值,则返回该唯一值。 +- 如果 `x` 中只有一个唯一的非 NULL 值,则返回该唯一值。 - 如果有零个或至少两个不同的值,则返回 `NULL`。 **示例** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/singlevalueornull.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/singlevalueornull.md.hash index fe8c8f6950c..b131bbbef12 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/singlevalueornull.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/singlevalueornull.md.hash @@ -1 +1 @@ -084fe148c1525f7f +d6fdaab4edab24dc diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/skewpop.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/skewpop.md index b8ad9d764af..b5dc5bf8a7f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/skewpop.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/skewpop.md @@ -3,6 +3,7 @@ 'sidebar_position': 185 'slug': '/sql-reference/aggregate-functions/reference/skewpop' 'title': 'skewPop' +'doc_type': 'reference' --- @@ -16,7 +17,7 @@ skewPop(expr) **参数** -`expr` — [表达式](/sql-reference/syntax#expressions) 返回一个数字。 +`expr` — 返回数字的 [表达式](/sql-reference/syntax#expressions)。 **返回值** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/skewpop.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/skewpop.md.hash index 5f5313efc93..faee6236053 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/skewpop.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/skewpop.md.hash @@ -1 +1 @@ -694fa97e723cea53 +b8590add00f4c0ac diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/skewsamp.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/skewsamp.md index f3602dd21c0..46a2d7dc95b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/skewsamp.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/skewsamp.md @@ -1,16 +1,17 @@ --- -'description': '计算一个序列的样本偏度。' +'description': '计算序列的样本偏度。' 'sidebar_position': 186 'slug': '/sql-reference/aggregate-functions/reference/skewsamp' 'title': 'skewSamp' +'doc_type': 'reference' --- # skewSamp -计算序列的 [样本偏斜度](https://en.wikipedia.org/wiki/Skewness)。 +计算一个序列的 [样本偏度](https://en.wikipedia.org/wiki/Skewness)。 -如果传递的值形成其样本,则它代表随机变量偏斜度的无偏估计。 +如果传递的值形成了其样本,则它表示随机变量偏度的无偏估计。 ```sql skewSamp(expr) @@ -22,7 +23,7 @@ skewSamp(expr) **返回值** -给定分布的偏斜度。类型 — [Float64](../../../sql-reference/data-types/float.md)。如果 `n <= 1` (`n` 是样本的大小),则该函数返回 `nan`。 +给定分布的偏度。类型 — [Float64](../../../sql-reference/data-types/float.md)。如果 `n <= 1`(`n` 是样本的大小),那么该函数返回 `nan`。 **示例** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/skewsamp.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/skewsamp.md.hash index ffd7815d4a3..2b0a26e3c70 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/skewsamp.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/skewsamp.md.hash @@ -1 +1 @@ -b94bcfde691f449f +37d9d36f5ca5b2f8 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/sparkbar.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/sparkbar.md index 8c0d42043f7..9501559c249 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/sparkbar.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/sparkbar.md @@ -1,17 +1,21 @@ --- -'description': '该函数绘制值 `x` 的频率直方图,以及这些值在区间 `[min_x, max_x]` 上的重复率 `y`。' +'description': '该功能绘制值 `x` 的频率直方图,以及在区间 `[min_x, max_x]` 内这些值的重复率 `y`。' 'sidebar_label': 'sparkbar' 'sidebar_position': 187 'slug': '/sql-reference/aggregate-functions/reference/sparkbar' 'title': 'sparkbar' +'doc_type': 'reference' --- # sparkbar -该函数为值 `x` 绘制频率直方图,以及这些值在区间 `[min_x, max_x]` 内的重复率 `y`。所有落在同一桶中的 `x` 的重复次数会被平均,因此数据应该预先进行聚合。负重复次数会被忽略。 +该函数为值 `x` 绘制频率直方图,并展示这些值在区间 `[min_x, max_x]` 内的重复率 `y`。 +对于所有落入同一桶的 `x`,其重复次数会被平均,因此数据应提前聚合。 +负重复次数将被忽略。 -如果没有指定区间,则使用最小 `x` 作为区间开始,最大 `x` 作为区间结束。否则,区间外的值会被忽略。 +如果未指定区间,则使用最小的 `x` 作为区间开始,最大 `x` 作为区间结束。 +否则,区间外的值将被忽略。 **语法** @@ -21,13 +25,13 @@ sparkbar(buckets[, min_x, max_x])(x, y) **参数** -- `buckets` — 段数。类型: [Integer](../../../sql-reference/data-types/int-uint.md)。 +- `buckets` — 段的数量。类型:[整数](../../../sql-reference/data-types/int-uint.md)。 - `min_x` — 区间开始。可选参数。 - `max_x` — 区间结束。可选参数。 -**参数说明** +**参数** -- `x` — 值的字段。 +- `x` — 具有值的字段。 - `y` — 值的频率字段。 **返回值** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/sparkbar.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/sparkbar.md.hash index 805ac4f221b..9efab7e36e1 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/sparkbar.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/sparkbar.md.hash @@ -1 +1 @@ -02b8286c6e3a7e26 +b42dec73169062c5 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/stddevpop.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/stddevpop.md index c27fb5193a1..667c3db90db 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/stddevpop.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/stddevpop.md @@ -3,6 +3,7 @@ 'sidebar_position': 188 'slug': '/sql-reference/aggregate-functions/reference/stddevpop' 'title': 'stddevPop' +'doc_type': 'reference' --- @@ -10,10 +11,10 @@ 结果等于 [varPop](../../../sql-reference/aggregate-functions/reference/varpop.md) 的平方根。 -别名: `STD`, `STDDEV_POP`。 +别名: `STD`, `STDDEV_POP`。 :::note -此函数使用数值不稳定的算法。如果您需要计算中的 [数值稳定性](https://en.wikipedia.org/wiki/Numerical_stability),请使用 [`stddevPopStable`](../reference/stddevpopstable.md) 函数。该函数运行较慢,但提供较低的计算误差。 +此函数使用了一个数值不稳定的算法。如果您在计算中需要 [数值稳定性](https://en.wikipedia.org/wiki/Numerical_stability),请使用 [`stddevPopStable`](../reference/stddevpopstable.md) 函数。它运算速度较慢,但提供更低的计算误差。 ::: **语法** @@ -24,15 +25,15 @@ stddevPop(x) **参数** -- `x`: 要查找标准差的值的总体。[(U)Int*](../../data-types/int-uint.md), [Float*](../../data-types/float.md), [Decimal*](../../data-types/decimal.md)。 +- `x`:要计算标准偏差的值的总体。 [(U)Int*](../../data-types/int-uint.md), [Float*](../../data-types/float.md), [Decimal*](../../data-types/decimal.md)。 **返回值** -- `x` 的标准差的平方根。[Float64](../../data-types/float.md)。 +- `x` 的标准偏差的平方根。 [Float64](../../data-types/float.md)。 **示例** -查询: +查询: ```sql DROP TABLE IF EXISTS test_data; @@ -49,7 +50,7 @@ SELECT FROM test_data; ``` -结果: +结果: ```response ┌────────────stddev─┐ diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/stddevpop.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/stddevpop.md.hash index 0783164b8a2..03ab5a03b7a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/stddevpop.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/stddevpop.md.hash @@ -1 +1 @@ -ebbef33fa873a88f +483f46951d232479 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/stddevpopstable.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/stddevpopstable.md index c5182d3ac9c..d67d17aee3a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/stddevpopstable.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/stddevpopstable.md @@ -1,14 +1,15 @@ --- -'description': '结果等于 varPop 的平方根。与 stddevPop 不同,此函数使用一种数值稳定的算法。' +'description': '结果等于 varPop 的平方根。与 stddevPop 不同,此函数使用数值稳定的算法。' 'sidebar_position': 189 'slug': '/sql-reference/aggregate-functions/reference/stddevpopstable' 'title': 'stddevPopStable' +'doc_type': 'reference' --- # stddevPopStable -结果等于 [varPop](../../../sql-reference/aggregate-functions/reference/varpop.md) 的平方根。与 [`stddevPop`](../reference/stddevpop.md) 不同,此函数使用数值稳定的算法。它的计算速度较慢,但提供了较低的计算误差。 +结果等于 [varPop](../../../sql-reference/aggregate-functions/reference/varpop.md) 的平方根。与 [`stddevPop`](../reference/stddevpop.md) 不同,此函数使用了数值稳定的算法。它的运行速度较慢,但提供了更低的计算误差。 **语法** @@ -18,11 +19,11 @@ stddevPopStable(x) **参数** -- `x`:用于计算标准差的值的总体。 [(U)Int*](../../data-types/int-uint.md), [Float*](../../data-types/float.md), [Decimal*](../../data-types/decimal.md)。 +- `x`:要计算标准差的值的总体。[(U)Int*](../../data-types/int-uint.md)、[Float*](../../data-types/float.md)、[Decimal*](../../data-types/decimal.md)。 **返回值** -`x` 的标准差的平方根。 [Float64](../../data-types/float.md)。 +`x` 的方差的平方根。[Float64](../../data-types/float.md)。 **示例** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/stddevpopstable.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/stddevpopstable.md.hash index 6ac6660c2f7..bd62df6eda4 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/stddevpopstable.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/stddevpopstable.md.hash @@ -1 +1 @@ -68be9972768f8086 +d7b479792d34a544 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/stddevsamp.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/stddevsamp.md index 239dc1716e2..ee27e7099dc 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/stddevsamp.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/stddevsamp.md @@ -3,6 +3,7 @@ 'sidebar_position': 190 'slug': '/sql-reference/aggregate-functions/reference/stddevsamp' 'title': 'stddevSamp' +'doc_type': 'reference' --- @@ -10,10 +11,10 @@ 结果等于 [varSamp](../../../sql-reference/aggregate-functions/reference/varsamp.md) 的平方根。 -别名: `STDDEV_SAMP`。 +别名:`STDDEV_SAMP`。 :::note -此函数使用数值不稳定的算法。如果您需要计算中的 [数值稳定性](https://en.wikipedia.org/wiki/Numerical_stability),请使用 [`stddevSampStable`](../reference/stddevsampstable.md) 函数。它运行较慢,但提供较低的计算误差。 +此函数使用一种数值不稳定的算法。如果您在计算中需要 [数值稳定性](https://en.wikipedia.org/wiki/Numerical_stability),请使用 [`stddevSampStable`](../reference/stddevsampstable.md) 函数。它的运行速度较慢,但提供更低的计算误差。 ::: **语法** @@ -24,11 +25,11 @@ stddevSamp(x) **参数** -- `x`:要查找其样本方差平方根的值。[(U)Int*](../../data-types/int-uint.md)、[Float*](../../data-types/float.md)、[Decimal*](../../data-types/decimal.md)。 +- `x`: 要找到样本方差平方根的值。[(U)Int*](../../data-types/int-uint.md)、[Float*](../../data-types/float.md)、[Decimal*](../../data-types/decimal.md)。 **返回值** -`x` 的样本方差平方根。 [Float64](../../data-types/float.md)。 +`x` 的样本方差的平方根。[Float64](../../data-types/float.md)。 **示例** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/stddevsamp.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/stddevsamp.md.hash index 235bc47978e..ad31d542bce 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/stddevsamp.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/stddevsamp.md.hash @@ -1 +1 @@ -23afe6604a83f3a6 +ad9a669c3a042d81 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/stddevsampstable.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/stddevsampstable.md index eeb48ca4140..2de3fb82c47 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/stddevsampstable.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/stddevsampstable.md @@ -1,14 +1,15 @@ --- -'description': '结果等于 varSamp 的平方根。与此函数不同的是,它使用了一个数值稳定的算法。' +'description': '结果等于 varSamp 的平方根。与此函数不同,它使用了一个数值稳定的算法。' 'sidebar_position': 191 'slug': '/sql-reference/aggregate-functions/reference/stddevsampstable' 'title': 'stddevSampStable' +'doc_type': 'reference' --- # stddevSampStable -结果等于 [varSamp](../../../sql-reference/aggregate-functions/reference/varsamp.md) 的平方根。与 [`stddevSamp`](../reference/stddevsamp.md) 不同,该函数使用数字稳定算法。虽然运行速度较慢,但它提供了更低的计算误差。 +结果等于 [varSamp](../../../sql-reference/aggregate-functions/reference/varsamp.md) 的平方根。与 [`stddevSamp`](../reference/stddevsamp.md) 不同,此函数使用数值稳定算法。它的速度较慢,但提供了更低的计算误差。 **语法** @@ -18,11 +19,11 @@ stddevSampStable(x) **参数** -- `x`: 要计算样本方差平方根的值。[(U)Int*](../../data-types/int-uint.md), [Float*](../../data-types/float.md), [Decimal*](../../data-types/decimal.md)。 +- `x`:要计算样本方差平方根的值。[(U)Int*](../../data-types/int-uint.md)、[Float*](../../data-types/float.md)、[Decimal*](../../data-types/decimal.md)。 **返回值** -`x` 的样本方差的平方根。[Float64](../../data-types/float.md)。 +`x` 的样本方差平方根。 [Float64](../../data-types/float.md)。 **示例** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/stddevsampstable.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/stddevsampstable.md.hash index 39c84b5ac73..7612b01383c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/stddevsampstable.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/stddevsampstable.md.hash @@ -1 +1 @@ -631f8b20c1f481da +c9c721bd0b82f970 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/stochasticlinearregression.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/stochasticlinearregression.md index c88cfcb4e50..c22878c7693 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/stochasticlinearregression.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/stochasticlinearregression.md @@ -1,38 +1,39 @@ --- -'description': '这个函数实现了随机线性回归。它支持学习率、L2 正则化系数、迷你批量大小的自定义参数,并具有几种更新权重的方法(Adam、简单 SGD、动量、Nesterov)。' +'description': '此功能实现了随机线性回归。它支持学习率、L2 正则化系数、迷你批量大小的自定义参数,并具有几种更新权重的方法(Adam、简单 SGD、动量、Nesterov)。' 'sidebar_position': 192 'slug': '/sql-reference/aggregate-functions/reference/stochasticlinearregression' -'title': '随机线性回归' +'title': 'stochasticLinearRegression' +'doc_type': 'reference' --- # stochasticLinearRegression {#agg_functions_stochasticlinearregression_parameters} -此函数实现了随机线性回归。它支持自定义参数,包括学习率、L2 正则化系数、迷你批量大小,并且具有几种更新权重的方法([Adam](https://en.wikipedia.org/wiki/Stochastic_gradient_descent#Adam)(默认使用)、[简单 SGD](https://en.wikipedia.org/wiki/Stochastic_gradient_descent)、[动量法](https://en.wikipedia.org/wiki/Stochastic_gradient_descent#Momentum)和[Nesterov](https://mipt.ru/upload/medialibrary/d7e/41-91.pdf))。 +此函数实现了随机线性回归。它支持自定义参数,包括学习率、L2正则化系数、小批量大小,并具有几种更新权重的方法([Adam](https://en.wikipedia.org/wiki/Stochastic_gradient_descent#Adam)(默认使用)、[简单SGD](https://en.wikipedia.org/wiki/Stochastic_gradient_descent)、[动量法](https://en.wikipedia.org/wiki/Stochastic_gradient_descent#Momentum)和[Nesterov](https://mipt.ru/upload/medialibrary/d7e/41-91.pdf))。 ### 参数 {#parameters} -有 4 个可自定义的参数。它们是按顺序传递给函数的,但并不需要传递所有四个 - 默认值将被使用,然而良好的模型需要一些参数调整。 +共有4个可自定义参数。它们顺序传递给函数,但不必传递全部四个——将使用默认值,然而要获得良好的模型需要对某些参数进行调整。 ```text stochasticLinearRegression(0.00001, 0.1, 15, 'Adam') ``` -1. `学习率` 是梯度下降步骤执行时步长的系数。过大的学习率可能导致模型的权重无限大。默认值是 `0.00001`。 -2. `l2 正则化系数` 可以帮助防止过拟合。默认值是 `0.1`。 -3. `迷你批量大小` 设置计算和汇总梯度以执行一步梯度下降的元素数量。纯随机下降使用一个元素,然而,使用小批量(大约 10 个元素)可以使梯度步骤更稳定。默认值是 `15`。 -4. `更新权重的方法`,有:`Adam`(默认)、`SGD`、`Momentum` 和 `Nesterov`。`Momentum` 和 `Nesterov` 需要更多的计算和内存,但在收敛速度和随机梯度方法的稳定性方面非常有用。 +1. `学习率` 是梯度下降步骤执行时的步长系数。过大的学习率可能导致模型权重无限大。默认值为 `0.00001`。 +2. `L2正则化系数` 这有助于防止过拟合。默认值为 `0.1`。 +3. `小批量大小` 设置计算和累加梯度以执行一次梯度下降的元素数量。纯随机下降使用一个元素,但是,使用小批量(约10个元素)使梯度步骤更加稳定。默认值为 `15`。 +4. `更新权重的方法`,包括:`Adam`(默认)、`SGD`、`动量法` 和 `Nesterov`。`动量法` 和 `Nesterov` 需要更多的计算和内存,但在收敛速度和随机梯度方法的稳定性方面是有用的。 -### 使用 {#usage} +### 使用方法 {#usage} -`stochasticLinearRegression` 分为两个步骤使用:拟合模型和预测新数据。为了拟合模型并保存其状态以供后续使用,我们使用 `-State` 组合器,它保存状态(例如模型权重)。 -要进行预测,我们使用函数 [evalMLMethod](/sql-reference/functions/machine-learning-functions#evalmlmethod),它将状态作为参数以及要进行预测的特征。 +`stochasticLinearRegression` 分两个步骤使用:拟合模型和在新数据上进行预测。为了拟合模型并保存其状态以供后续使用,我们使用 `-State` 组合器,它保存状态(例如模型权重)。 +进行预测时,我们使用函数 [evalMLMethod](/sql-reference/functions/machine-learning-functions#evalmlmethod),它将状态作为参数,并包含要预测的特征。 **1.** 拟合 -可以使用这样的查询。 +可以使用如下查询。 ```sql CREATE TABLE IF NOT EXISTS train_data @@ -47,31 +48,31 @@ stochasticLinearRegressionState(0.1, 0.0, 5, 'SGD')(target, param1, param2) AS state FROM train_data; ``` -在这里,我们还需要将数据插入 `train_data` 表中。参数的数量不是固定的,仅取决于传递给 `linearRegressionState` 的参数数量。它们必须都是数字值。 -请注意,目标值的列(我们希望学习预测的值)作为第一个参数插入。 +在这里,我们还需要将数据插入 `train_data` 表中。参数的数量不是固定的,仅取决于传递给 `linearRegressionState` 的参数数量。它们都必须是数值型。 +请注意,目标值所在的列(我们希望学习预测的值)作为第一个参数插入。 **2.** 预测 -在将状态保存到表中之后,我们可以多次使用它进行预测,甚至与其他状态合并并创建新模型,甚至更好的模型。 +在将状态保存到表中后,我们可以多次使用它进行预测,甚至可以与其他状态合并并创建新的、更好的模型。 ```sql WITH (SELECT state FROM your_model) AS model SELECT evalMLMethod(model, param1, param2) FROM test_data ``` -该查询将返回一个预测值的列。请注意,`evalMLMethod` 的第一个参数是 `AggregateFunctionState` 对象,接下来的参数是特征列。 +该查询将返回预测值列。请注意,`evalMLMethod` 的第一个参数是 `AggregateFunctionState` 对象,后面是特征的列。 -`test_data` 是像 `train_data` 的表,但可能不包含目标值。 +`test_data` 是一个与 `train_data` 类似的表,但可能不包含目标值。 -### 注意 {#notes} +### 备注 {#notes} -1. 用户可以创建这样的查询来合并两个模型: +1. 要合并两个模型,用户可以创建如下查询: `sql SELECT state1 + state2 FROM your_models` 其中 `your_models` 表包含两个模型。该查询将返回新的 `AggregateFunctionState` 对象。 -2. 如果未使用 `-State` 组合器,用户可以在不保存模型的情况下获取创建模型的权重以供自身使用。 +2. 用户可以在不使用 `-State` 组合器的情况下提取创建模型的权重,以供其自身目的。 `sql SELECT stochasticLinearRegression(0.01)(target, param1, param2) FROM train_data` - 这样的查询将拟合模型并返回其权重 - 第一组是与模型参数对应的权重,最后一个是偏置。因此,上面的查询将返回一个包含 3 个值的列。 + 这样的查询将拟合模型并返回其权重——首先是对应于模型参数的权重,最后一个是偏差。因此在上面的示例中,查询将返回一个包含3个值的列。 **另见** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/stochasticlinearregression.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/stochasticlinearregression.md.hash index 4adba0db5c4..7745d3a1650 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/stochasticlinearregression.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/stochasticlinearregression.md.hash @@ -1 +1 @@ -307be5af8f0d643e +a96c17682f160134 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/stochasticlogisticregression.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/stochasticlogisticregression.md index 131c253d8a4..2eca73aa450 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/stochasticlogisticregression.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/stochasticlogisticregression.md @@ -1,20 +1,21 @@ --- -'description': '该函数实现了随机逻辑回归。它可以用于二元分类问题,支持与 stochasticLinearRegression 相同的自定义参数,并且工作方式相同。' +'description': '这个函数实现了随机逻辑回归。它可以用于二元分类问题,支持与 stochasticLinearRegression 相同的自定义参数,并以相同的方式工作。' 'sidebar_position': 193 'slug': '/sql-reference/aggregate-functions/reference/stochasticlogisticregression' 'title': 'stochasticLogisticRegression' +'doc_type': 'reference' --- # stochasticLogisticRegression -此函数实现了随机逻辑回归。它可用于二元分类问题,支持与 stochasticLinearRegression 相同的自定义参数,并以相同的方式工作。 +此函数实现了随机逻辑回归。它可用于二分类问题,支持与stochasticLinearRegression相同的自定义参数,并以相同的方式工作。 ### 参数 {#parameters} -参数与 stochasticLinearRegression 中完全相同: -`学习速率`、`l2 正则化系数`、`小批量大小`、`权重更新方法`。 -更多信息请参见 [parameters](../reference/stochasticlinearregression.md/#parameters)。 +参数与stochasticLinearRegression中的完全相同: +`学习率`,`l2正则化系数`,`小批量大小`,`更新权重的方法`。 +有关更多信息,请参见 [参数](../reference/stochasticlinearregression.md/#parameters)。 ```text stochasticLogisticRegression(1.0, 1.0, 10, 'SGD') @@ -39,9 +40,9 @@ WITH (SELECT state FROM your_model) AS model SELECT evalMLMethod(model, param1, param2) FROM test_data ``` - 查询将返回一个概率列。请注意,`evalMLMethod` 的第一个参数是 `AggregateFunctionState` 对象,接下来的参数是特征列。 + 查询将返回一个概率列。注意,`evalMLMethod` 的第一个参数是 `AggregateFunctionState` 对象,下一个是特征的列。 - 我们还可以设置一个概率边界,将元素分配到不同的标签。 + 我们还可以设置概率界限,这将把元素分配给不同的标签。 ```sql SELECT ans < 1.1 AND ans > 0.5 FROM diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/stochasticlogisticregression.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/stochasticlogisticregression.md.hash index f7594b00755..a616573387e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/stochasticlogisticregression.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/stochasticlogisticregression.md.hash @@ -1 +1 @@ -e6f9138c135bb1da +3a7e81f560ddebf4 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/studentttest.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/studentttest.md index c4285c2a6e6..4137f9dcfb5 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/studentttest.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/studentttest.md @@ -4,12 +4,13 @@ 'sidebar_position': 194 'slug': '/sql-reference/aggregate-functions/reference/studentttest' 'title': 'studentTTest' +'doc_type': 'reference' --- # studentTTest -对来自两个总体的样本应用Student的t检验。 +对来自两个总体的样本应用学生 t 检验。 **语法** @@ -17,25 +18,25 @@ studentTTest([confidence_level])(sample_data, sample_index) ``` -两个样本的值在 `sample_data` 列中。如果 `sample_index` 等于 0,则该行中的值属于第一个总体的样本。否则,它属于第二个总体的样本。原假设是两个总体的均值相等。假设具有相等方差的正态分布。 +两个样本的值位于 `sample_data` 列。如果 `sample_index` 等于 0,则该行的值属于第一个总体的样本。否则,它属于第二个总体的样本。原假设是总体的均值相等。假设具有相等方差的正态分布。 **参数** -- `sample_data` — 样本数据。[整数](../../../sql-reference/data-types/int-uint.md), [浮点数](../../../sql-reference/data-types/float.md) 或 [十进制](../../../sql-reference/data-types/decimal.md)。 -- `sample_index` — 样本索引。[整数](../../../sql-reference/data-types/int-uint.md)。 +- `sample_data` — 样本数据。 [整数](../../../sql-reference/data-types/int-uint.md), [浮点数](../../../sql-reference/data-types/float.md) 或 [十进制](../../../sql-reference/data-types/decimal.md)。 +- `sample_index` — 样本索引。 [整数](../../../sql-reference/data-types/int-uint.md)。 -**参数说明** +**参数** -- `confidence_level` — 用于计算置信区间的置信水平。[浮点数](../../../sql-reference/data-types/float.md)。 +- `confidence_level` — 用于计算置信区间的置信水平。 [浮点数](../../../sql-reference/data-types/float.md)。 **返回值** -[元组](../../../sql-reference/data-types/tuple.md),包含两个或四个元素(如果指定了可选的 `confidence_level`): +[元组](../../../sql-reference/data-types/tuple.md)包含两个或四个元素(如果指定了可选的 `confidence_level`): -- 计算的 t 统计量。[Float64](../../../sql-reference/data-types/float.md)。 -- 计算的 p 值。[Float64](../../../sql-reference/data-types/float.md)。 -- [计算的置信区间低值。[Float64](../../../sql-reference/data-types/float.md)。] -- [计算的置信区间高值。[Float64](../../../sql-reference/data-types/float.md)。] +- 计算出的 t 统计量。 [Float64](../../../sql-reference/data-types/float.md)。 +- 计算出的 p 值。 [Float64](../../../sql-reference/data-types/float.md)。 +- [计算出的置信区间下限。 [Float64](../../../sql-reference/data-types/float.md)。] +- [计算出的置信区间上限。 [Float64](../../../sql-reference/data-types/float.md)。] **示例** @@ -68,5 +69,5 @@ SELECT studentTTest(sample_data, sample_index) FROM student_ttest; **另见** -- [Student's t-test](https://en.wikipedia.org/wiki/Student%27s_t-test) +- [学生 t 检验](https://en.wikipedia.org/wiki/Student%27s_t-test) - [welchTTest 函数](/sql-reference/aggregate-functions/reference/welchttest) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/studentttest.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/studentttest.md.hash index 333664be425..8312554e866 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/studentttest.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/studentttest.md.hash @@ -1 +1 @@ -9315b08ed36ff45a +7f925c04eb1f7da0 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/studentttestonesample.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/studentttestonesample.md new file mode 100644 index 00000000000..fea8bf76b0c --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/studentttestonesample.md @@ -0,0 +1,80 @@ +--- +'description': '对样本和已知总体均值应用单样本 Student t 检验。' +'sidebar_label': 'studentTTestOneSample' +'sidebar_position': 195 +'slug': '/sql-reference/aggregate-functions/reference/studentttestonesample' +'title': 'studentTTestOneSample' +'doc_type': 'reference' +--- + + +# studentTTestOneSample + +应用单样本 Student t 检验,以确定样本的均值是否与已知的总体均值不同。 + +假设正态分布。零假设是样本均值等于总体均值。 + +**语法** + +```sql +studentTTestOneSample([confidence_level])(sample_data, population_mean) +``` + +可选的 `confidence_level` 使得置信区间的计算成为可能。 + +**参数** + +- `sample_data` — 样本数据。整数、浮点数或小数。 +- `population_mean` — 用于测试的已知总体均值。整数、浮点数或小数(通常为常量)。 + +**参数说明** + +- `confidence_level` — 置信区间的置信水平。介于 (0, 1) 之间的浮点数。 + +注意: +- 至少需要 2 个观察值;否则结果为 `(nan, nan)`(如果请求了区间,则区间为 `nan`)。 +- 常量或接近常量的输入也会返回 `nan`,由于零(或有效为零)的标准误差。 + +**返回值** + +[元组](../../../sql-reference/data-types/tuple.md),包含两个或四个元素(如果指定了 `confidence_level`): + +- 计算出的 t 统计量。Float64。 +- 计算出的 p 值(双尾)。Float64。 +- 计算出的置信区间下限。Float64。(可选) +- 计算出的置信区间上限。Float64。(可选) + +置信区间是针对给定置信水平的样本均值。 + +**示例** + +输入表: + +```text +┌─value─┐ +│ 20.3 │ +│ 21.1 │ +│ 21.7 │ +│ 19.9 │ +│ 21.8 │ +└───────┘ +``` + +没有置信区间: + +```sql +SELECT studentTTestOneSample()(value, 20.0) FROM t; +-- or simply +SELECT studentTTestOneSample(value, 20.0) FROM t; +``` + +有置信区间(95%): + +```sql +SELECT studentTTestOneSample(0.95)(value, 20.0) FROM t; +``` + +**另见** + +- [Student t 检验](https://en.wikipedia.org/wiki/Student%27s_t-test) +- [studentTTest 函数](/sql-reference/aggregate-functions/reference/studentttest) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/studentttestonesample.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/studentttestonesample.md.hash new file mode 100644 index 00000000000..4071ded4fe1 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/studentttestonesample.md.hash @@ -0,0 +1 @@ +93fbb2bd4d0fac4c diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/sum.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/sum.md index 464cd667643..99d565b0b6d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/sum.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/sum.md @@ -3,6 +3,7 @@ 'sidebar_position': 195 'slug': '/sql-reference/aggregate-functions/reference/sum' 'title': 'sum' +'doc_type': 'reference' --- @@ -25,7 +26,7 @@ sum(num) **示例** -首先,我们创建一个表 `employees` 并向其中插入一些虚构的员工数据。 +首先,我们创建一个表 `employees` 并插入一些虚构的员工数据。 查询: @@ -47,7 +48,7 @@ INSERT INTO employees VALUES (71245, 'Anastasia Ivanovna', 89210); ``` -我们使用 `sum` 函数查询员工薪资的总额。 +我们使用 `sum` 函数查询员工工资的总额。 查询: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/sum.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/sum.md.hash index f90f9d52686..9aaf0367573 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/sum.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/sum.md.hash @@ -1 +1 @@ -07696ae7658fb72b +3e63b24e49895613 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/sumcount.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/sumcount.md index 492ef3de1ed..e9595240a9c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/sumcount.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/sumcount.md @@ -1,12 +1,13 @@ --- -'description': '同时计算数字的总和和行的数量。该函数由 ClickHouse 查询优化器使用:如果查询中存在多个 `sum`、`count` 或 `avg` - 函数,则可以用单个 `sumCount` 函数替换它们,以重用计算。该函数很少需要显式使用。' +'description': '计算数字的总和并同时计算行数。该函数由 ClickHouse 查询优化器使用:如果查询中有多个 `sum`、`count` 或 `avg` + 函数,可以替换为单个 `sumCount` 函数以重用计算。该函数很少需要显式使用。' 'sidebar_position': 196 'slug': '/sql-reference/aggregate-functions/reference/sumcount' 'title': 'sumCount' +'doc_type': 'reference' --- -计算数字的总和并同时计算行数。该函数由 ClickHouse 查询优化器使用:如果查询中有多个 `sum`、`count` 或 `avg` 函数,它们可以被替换为单个 `sumCount` 函数以重用计算。该函数通常不需要显式使用。 +计算数字的总和并同时计数行数。该函数由 ClickHouse 查询优化器使用:如果查询中有多个 `sum`、`count` 或 `avg` 函数,它们可以被替换为单个 `sumCount` 函数以重用计算。该函数很少需要显式使用。 **语法** @@ -20,7 +21,7 @@ sumCount(x) **返回值** -- 元组 `(sum, count)`,其中 `sum` 是数字的总和,`count` 是非 NULL 值的行数。 +- 元组 `(sum, count)`,其中 `sum` 是数字的总和,`count` 是具有非 NULL 值的行数。 类型: [Tuple](../../../sql-reference/data-types/tuple.md)。 @@ -29,10 +30,10 @@ sumCount(x) 查询: ```sql -CREATE TABLE s_table (x Int8) Engine = Log; +CREATE TABLE s_table (x Int8) ENGINE = Log; INSERT INTO s_table SELECT number FROM numbers(0, 20); INSERT INTO s_table VALUES (NULL); -SELECT sumCount(x) from s_table; +SELECT sumCount(x) FROM s_table; ``` 结果: @@ -43,6 +44,6 @@ SELECT sumCount(x) from s_table; └─────────────┘ ``` -**另请参见** +**另见** - [optimize_syntax_fuse_functions](../../../operations/settings/settings.md#optimize_syntax_fuse_functions) 设置。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/sumcount.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/sumcount.md.hash index d5a456e5d40..a3fbcf8e015 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/sumcount.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/sumcount.md.hash @@ -1 +1 @@ -e2c28e9ce5ebe5fa +63031934d3081d6e diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/sumkahan.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/sumkahan.md index d9d7b68550d..56f38b0f67c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/sumkahan.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/sumkahan.md @@ -1,13 +1,14 @@ --- -'description': '使用Kahan补偿求和算法计算数字的总和' +'description': '使用 Kahan 补偿求和算法计算数字的和' 'sidebar_position': 197 'slug': '/sql-reference/aggregate-functions/reference/sumkahan' 'title': 'sumKahan' +'doc_type': 'reference' --- -计算使用 [Kahan补偿求和算法](https://en.wikipedia.org/wiki/Kahan_summation_algorithm) 的数字总和。 -速度慢于 [sum](./sum.md) 函数。 -补偿仅适用于 [Float](../../../sql-reference/data-types/float.md) 类型。 +计算使用[Kahan补偿求和算法](https://en.wikipedia.org/wiki/Kahan_summation_algorithm)的数字之和。 +比[求和](./sum.md)函数慢。 +补偿仅对[Float](../../../sql-reference/data-types/float.md)类型有效。 **语法** @@ -17,21 +18,21 @@ sumKahan(x) **参数** -- `x` — 输入值,必须是 [Integer](../../../sql-reference/data-types/int-uint.md)、[Float](../../../sql-reference/data-types/float.md) 或 [Decimal](../../../sql-reference/data-types/decimal.md)。 +- `x` — 输入值,必须是[Integer](../../../sql-reference/data-types/int-uint.md)、[Float](../../../sql-reference/data-types/float.md)或[Decimal](../../../sql-reference/data-types/decimal.md)。 **返回值** -- 数字的总和,返回类型为 [Integer](../../../sql-reference/data-types/int-uint.md)、[Float](../../../sql-reference/data-types/float.md) 或 [Decimal](../../../sql-reference/data-types/decimal.md),具体取决于输入参数的类型。 +- 数字的和,其类型[Integer](../../../sql-reference/data-types/int-uint.md)、[Float](../../../sql-reference/data-types/float.md)或[Decimal](../../../sql-reference/data-types/decimal.md)取决于输入参数的类型。 **示例** -查询: +查询: ```sql SELECT sum(0.1), sumKahan(0.1) FROM numbers(10); ``` -结果: +结果: ```text ┌───────────sum(0.1)─┬─sumKahan(0.1)─┐ diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/sumkahan.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/sumkahan.md.hash index 7f5f986c45e..cab59c40b03 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/sumkahan.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/sumkahan.md.hash @@ -1 +1 @@ -1aadb8390cd63605 +8af0476fb71ecaf9 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/summap.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/summap.md index 28996b185ff..a4e810e2557 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/summap.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/summap.md @@ -1,40 +1,41 @@ --- -'description': '根据 `key` 数组中指定的键,对 `value` 数组进行求和。返回一个包含两个数组的元组:按顺序排序的键,以及对应键的求和值,确保没有溢出。' +'description': '根据 `key` 数组中指定的键,总计一个或多个 `value` 数组。返回一个数组的元组:按排序顺序排列的键,后面是相应键的总值,且没有溢出。' 'sidebar_position': 198 'slug': '/sql-reference/aggregate-functions/reference/summap' 'title': 'sumMap' +'doc_type': 'reference' --- # sumMap -根据 `key` 数组中指定的键对 `value` 数组进行求和。返回一个包含两个数组的元组:按顺序排列的键以及对应键的求和值(不溢出)。 +根据在 `key` 数组中指定的键,对一个或多个 `value` 数组进行汇总,返回一个元组数组:按排序顺序排列的键,后跟对应键的值总和且没有溢出。 **语法** -- `sumMap(key , value )` [Array type](../../data-types/array.md)。 -- `sumMap(Tuple(key , value ))` [Tuple type](../../data-types/tuple.md)。 +- `sumMap(key , value1 [, value2 , ...])` [Array type](../../data-types/array.md). +- `sumMap(Tuple(key [, value1 , value2 , ...]))` [Tuple type](../../data-types/tuple.md). -别名:`sumMappedArrays`。 +别名: `sumMappedArrays`。 -**参数** +**参数** -- `key`:键的 [Array](../../data-types/array.md)。 -- `value`:值的 [Array](../../data-types/array.md)。 +- `key`: [Array](../../data-types/array.md) 类型的键数组。 +- `value1`, `value2`, ...: [Array](../../data-types/array.md) 类型的值数组,用于按键汇总。 -传递键和值数组的元组是分别传递键数组和值数组的同义词。 +传递键和值数组的元组是单独传递键数组和值数组的同义词。 :::note -`key` 和 `value` 中的元素数量必须在每一行中相同。 +`key` 和所有 `value` 数组中的元素数量必须在每个被汇总的行中相同。 ::: -**返回值** +**返回值** -- 返回一个包含两个数组的元组:按顺序排列的键,以及对应键的求和值。 +- 返回一个元组数组:第一个数组包含按排序顺序排列的键,后跟对应键的值总和的数组。 **示例** -首先,我们创建一个名为 `sum_map` 的表,并向其中插入一些数据。键和值的数组分别存储为一个名为 `statusMap` 的 [Nested](../../data-types/nested-data-structures/index.md) 类型列,以及作为一个名为 `statusMapTuple` 的 [tuple](../../data-types/tuple.md) 类型列,以说明上述两种不同语法的使用。 +首先,我们创建一个名为 `sum_map` 的表,并插入一些数据。键和值的数组分别存储为名为 `statusMap` 的 [Nested](../../data-types/nested-data-structures/index.md) 类型列,并作为名为 `statusMapTuple` 的 [tuple](../../data-types/tuple.md) 类型列一起存储,以展示上述两种不同语法的使用。 查询: @@ -57,7 +58,7 @@ INSERT INTO sum_map VALUES ('2000-01-01', '2000-01-01 00:01:00', [6, 7, 8], [10, 10, 10], ([6, 7, 8], [10, 10, 10])); ``` -接下来,我们使用 `sumMap` 函数查询表格,同时利用数组和元组类型的语法: +接下来,我们使用 `sumMap` 函数查询该表,利用数组和元组类型语法: 查询: @@ -79,6 +80,44 @@ GROUP BY timeslot └─────────────────────┴──────────────────────────────────────────────┴────────────────────────────────┘ ``` +**带多个值数组的示例** + +`sumMap` 还支持同时聚合多个值数组。 当你有共享相同键的相关指标时,这非常有用。 + +```sql title="Query" +CREATE TABLE multi_metrics( + date Date, + browser_metrics Nested( + browser String, + impressions UInt32, + clicks UInt32 + ) +) +ENGINE = MergeTree() +ORDER BY tuple(); + +INSERT INTO multi_metrics VALUES + ('2000-01-01', ['Firefox', 'Chrome'], [100, 200], [10, 25]), + ('2000-01-01', ['Chrome', 'Safari'], [150, 50], [20, 5]), + ('2000-01-01', ['Firefox', 'Edge'], [80, 40], [8, 4]); + +SELECT + sumMap(browser_metrics.browser, browser_metrics.impressions, browser_metrics.clicks) AS result +FROM multi_metrics; +``` + +```text title="Response" +┌─result────────────────────────────────────────────────────────────────────────┐ +│ (['Chrome', 'Edge', 'Firefox', 'Safari'], [350, 40, 180, 50], [45, 4, 18, 5]) │ +└───────────────────────────────────────────────────────────────────────────────┘ +``` + +在此示例中: +- 结果元组包含三个数组 +- 第一个数组:按排序顺序排列的键(浏览器名称) +- 第二个数组:每个浏览器的总展示次数 +- 第三个数组:每个浏览器的总点击次数 + **另见** - [Map combinator for Map datatype](../combinators.md#-map) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/summap.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/summap.md.hash index f94297fab73..f126cb7049d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/summap.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/summap.md.hash @@ -1 +1 @@ -fce2c8ac7584569a +ffab069de35501ca diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/summapwithoverflow.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/summapwithoverflow.md index 7855641f329..439fa0921ad 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/summapwithoverflow.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/summapwithoverflow.md @@ -1,39 +1,40 @@ --- -'description': '根据 `key` 数组中指定的键,总计 `value` 数组。返回两个数组的元组:按排序顺序排列的键,以及为对应键汇总的值。与 sumMap - 函数的不同之处在于它可以进行带溢出的求和。' +'description': '根据 `key` 数组中指定的键,对 `value` 数组进行求和。返回一个包含两个数组的元组:按排序顺序排列的键,以及对应键的求和值。与 + sumMap 函数的不同之处在于,它进行溢出求和。' 'sidebar_position': 199 'slug': '/sql-reference/aggregate-functions/reference/summapwithoverflow' 'title': 'sumMapWithOverflow' +'doc_type': 'reference' --- # sumMapWithOverflow -根据 `key` 数组中指定的键对 `value` 数组进行求和。返回一个包含两个数组的元组:按排序顺序排列的键和对应键的求和值。它与 [sumMap](../reference/summap.md) 函数的不同之处在于,它进行溢出求和——即针对求和返回与参数数据类型相同的数据类型。 +根据`key`数组中指定的键对`value`数组进行求和。返回两个数组的元组:按排序顺序排列的键,以及对应键的求和值。它与 [sumMap](../reference/summap.md) 函数的区别在于,它以溢出方式进行求和——即返回与参数数据类型相同的数据类型进行求和。 **语法** -- `sumMapWithOverflow(key , value )` [数组类型](../../data-types/array.md)。 -- `sumMapWithOverflow(Tuple(key , value ))` [元组类型](../../data-types/tuple.md)。 +- `sumMapWithOverflow(key , value )` [Array type](../../data-types/array.md). +- `sumMapWithOverflow(Tuple(key , value ))` [Tuple type](../../data-types/tuple.md). **参数** -- `key`: [数组](../../data-types/array.md) 键。 -- `value`: [数组](../../data-types/array.md) 值。 +- `key`: [Array](../../data-types/array.md) 类型的键数组。 +- `value`: [Array](../../data-types/array.md) 类型的值数组。 -传递键值数组的元组相当于分别传递键数组和值数组。 +传递键和值数组的元组是分别传递键数组和值数组的同义词。 :::note -`key` 和 `value` 中的元素数量必须对于每一行都是相同的以进行求和。 +`key` 和 `value` 中的元素数量在每行中必须相同。 ::: **返回值** -- 返回一个包含两个数组的元组:按排序顺序排列的键和对应键的求和值。 +- 返回两个数组的元组:按排序顺序排列的键,以及对应键的求和值。 **示例** -首先,我们创建一个名为 `sum_map` 的表,并插入一些数据。键和值的数组分别存储在名为 `statusMap` 的列中,类型为 [Nested](../../data-types/nested-data-structures/index.md),并作为名为 `statusMapTuple` 的列一起存储,类型为 [tuple](../../data-types/tuple.md),以说明上述函数的两种不同语法的用法。 +首先我们创建一个名为 `sum_map` 的表,并向其中插入一些数据。键和值的数组分别作为名为 `statusMap` 的 [Nested](../../data-types/nested-data-structures/index.md) 类型列单独存储,并且作为名为 `statusMapTuple` 的 [tuple](../../data-types/tuple.md) 类型列一起存储,以说明上述函数的两种不同语法的使用。 查询: @@ -56,7 +57,7 @@ INSERT INTO sum_map VALUES ('2000-01-01', '2000-01-01 00:01:00', [6, 7, 8], [10, 10, 10], ([6, 7, 8], [10, 10, 10])); ``` -如果我们使用 `sumMap`、`sumMapWithOverflow` 的数组类型语法和 `toTypeName` 函数查询该表,则可以看到,对于 `sumMapWithOverflow` 函数,求和值数组的数据类型与参数类型相同,都是 `UInt8`(即求和是有溢出的)。对于 `sumMap`,求和值数组的数据类型已经从 `UInt8` 变为 `UInt64`,以确保不发生溢出。 +如果我们使用 `sumMap`、`sumMapWithOverflow` 和 `toTypeName` 函数查询表,我们可以看到,对于 `sumMapWithOverflow` 函数,求和值数组的数据类型与参数类型相同,均为 `UInt8`(即,求和是以溢出方式进行的)。对于 `sumMap`,求和值数组的数据类型已经从 `UInt8` 更改为 `UInt64`,以便不会发生溢出。 查询: @@ -69,7 +70,7 @@ FROM sum_map GROUP BY timeslot ``` -同样,我们可以使用元组语法得到相同的结果。 +同样,我们也可以使用元组语法获得相同的结果。 ```sql SELECT diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/summapwithoverflow.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/summapwithoverflow.md.hash index 4942ccf8229..e93593a1cce 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/summapwithoverflow.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/summapwithoverflow.md.hash @@ -1 +1 @@ -a0c78b81aaa81c12 +d41bdc93d7b14b7d diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/sumwithoverflow.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/sumwithoverflow.md index f45a30f4604..b317f8ee34d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/sumwithoverflow.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/sumwithoverflow.md @@ -1,14 +1,15 @@ --- -'description': '计算数字的总和,结果使用与输入参数相同的数据类型。如果总和超过该数据类型的最大值,则会使用溢出进行计算。' +'description': '计算数字的总和,使用与输入参数相同的数据类型作为结果。如果总和超过该数据类型的最大值,则使用溢出进行计算。' 'sidebar_position': 200 'slug': '/sql-reference/aggregate-functions/reference/sumwithoverflow' 'title': 'sumWithOverflow' +'doc_type': 'reference' --- # sumWithOverflow -计算数字的总和,使用与输入参数相同的数据类型作为结果。如果总和超过此数据类型的最大值,则以溢出方式计算。 +计算数字的总和,使用与输入参数相同的数据类型作为结果。如果总和超过该数据类型的最大值,则进行溢出计算。 仅适用于数字。 @@ -19,15 +20,15 @@ sumWithOverflow(num) ``` **参数** -- `num`: 数值列。[(U)Int*](../../data-types/int-uint.md),[Float*](../../data-types/float.md),[Decimal*](../../data-types/decimal.md)。 +- `num`: 数值列。[(U)Int*](../../data-types/int-uint.md), [Float*](../../data-types/float.md), [Decimal*](../../data-types/decimal.md)。 **返回值** -- 值的总和。[(U)Int*](../../data-types/int-uint.md),[Float*](../../data-types/float.md),[Decimal*](../../data-types/decimal.md)。 +- 数值的总和。[(U)Int*](../../data-types/int-uint.md), [Float*](../../data-types/float.md), [Decimal*](../../data-types/decimal.md)。 **示例** -首先我们创建一个表 `employees` 并插入一些虚构的员工数据。在这个例子中,我们将选择 `salary` 为 `UInt16`,这样这些值的总和可能会产生溢出。 +首先我们创建一个名为 `employees` 的表,并插入一些虚构的员工数据。在这个例子中,我们将选择 `salary` 为 `UInt16`,以便这些值的总和可能会产生溢出。 查询: @@ -50,8 +51,8 @@ SELECT FROM employees ``` -我们使用 `sum` 和 `sumWithOverflow` 函数查询员工薪水的总额,并使用 `toTypeName` 函数显示它们的类型。 -对于 `sum` 函数,结果类型为 `UInt64`,足够容纳总和,而对于 `sumWithOverflow`,结果类型保持为 `UInt16`。 +我们使用 `sum` 和 `sumWithOverflow` 函数查询员工薪资的总额,并使用 `toTypeName` 函数显示它们的类型。 +对于 `sum` 函数,结果类型为 `UInt64`,足以容纳总和,而对于 `sumWithOverflow`,结果类型保持为 `UInt16`。 查询: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/sumwithoverflow.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/sumwithoverflow.md.hash index 296f4f46e3c..1075cdd7859 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/sumwithoverflow.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/sumwithoverflow.md.hash @@ -1 +1 @@ -0579b634c240e9cb +bd0165db6743aa4d diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/theilsu.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/theilsu.md index 5664db40788..5a444a3fb01 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/theilsu.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/theilsu.md @@ -1,14 +1,15 @@ --- -'description': '`theilsU` 函数计算 Theils 的 U 不确定性系数,这是一个衡量表中两个列之间关联的值。' +'description': '`theilsU` 函数计算 Theils'' U 不确定系数,这是一个衡量表中两列之间关联的值。' 'sidebar_position': 201 'slug': '/sql-reference/aggregate-functions/reference/theilsu' 'title': 'theilsU' +'doc_type': 'reference' --- # theilsU -`theilsU` 函数计算 [Theil's U 不确定性系数](https://en.wikipedia.org/wiki/Contingency_table#Uncertainty_coefficient),该值用于衡量表中两列之间的关联程度。其值范围从 −1.0(100% 负关联,或完美反转)到 +1.0(100% 正关联,或完美一致)。值为 0.0 表示没有关联。 +`theilsU` 函数计算 [Theil's U 不确定性系数](https://en.wikipedia.org/wiki/Contingency_table#Uncertainty_coefficient),该值用于衡量表中两列之间的关联性。其值范围从 -1.0(100% 的负关联,或完全反转)到 +1.0(100% 的正关联,或完全一致)。值为 0.0 表示没有关联。 **语法** @@ -18,17 +19,17 @@ theilsU(column1, column2) **参数** -- `column1` 和 `column2` 是需要比较的列 +- `column1` 和 `column2` 是要进行比较的列 **返回值** -- 一个介于 -1 和 1 之间的值 +- 在 -1 和 1 之间的一个值 -**返回类型**始终是 [Float64](../../../sql-reference/data-types/float.md)。 +**返回类型** 始终是 [Float64](../../../sql-reference/data-types/float.md)。 **示例** -下面比较的两列之间的关联较小,因此 `theilsU` 的值为负: +下面比较的两个列之间的关联性较小,因此 `theilsU` 的值为负: ```sql SELECT diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/theilsu.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/theilsu.md.hash index e08afd39d11..a4e9c9dcb7a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/theilsu.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/theilsu.md.hash @@ -1 +1 @@ -6d8c4781d566ffe2 +67dab60fa0c6ddca diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesChangesToGrid.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesChangesToGrid.md new file mode 100644 index 00000000000..5fb28509036 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesChangesToGrid.md @@ -0,0 +1,70 @@ +--- +'description': '聚合函数,计算在指定网格上对时间序列数据的类似于 PromQL 的变化。' +'sidebar_position': 229 +'slug': '/sql-reference/aggregate-functions/reference/timeSeriesChangesToGrid' +'title': 'timeSeriesChangesToGrid' +'doc_type': 'reference' +--- + +聚合函数,将时间序列数据作为时间戳和值的对,并在由开始时间戳、结束时间戳和步长描述的规则时间网格上计算 [PromQL 类似的变化](https://prometheus.io/docs/prometheus/latest/querying/functions/#changes)。对于网格上的每个点,计算 `changes` 的样本在指定的时间窗口内考虑。 + +参数: +- `start timestamp` - 指定网格的开始 +- `end timestamp` - 指定网格的结束 +- `grid step` - 指定网格的步长(单位:秒) +- `staleness` - 指定考虑样本的最大“陈旧性”(单位:秒) + +参数: +- `timestamp` - 样本的时间戳 +- `value` - 与 `timestamp` 对应的时间序列值 + +返回值: +在指定网格上的 `changes` 值,返回为 `Array(Nullable(Float64))`。返回的数组包含每个时间网格点的一个值。如果在窗口内没有样本用于计算特定网格点的变化值,则该值为 NULL。 + +示例: +以下查询计算网格 [90, 105, 120, 135, 150, 165, 180, 195, 210, 225] 上的 `changes` 值: + +```sql +WITH + -- NOTE: the gap between 130 and 190 is to show how values are filled for ts = 180 according to window paramater + [110, 120, 130, 190, 200, 210, 220, 230]::Array(DateTime) AS timestamps, + [1, 1, 3, 5, 5, 8, 12, 13]::Array(Float32) AS values, -- array of values corresponding to timestamps above + 90 AS start_ts, -- start of timestamp grid + 90 + 135 AS end_ts, -- end of timestamp grid + 15 AS step_seconds, -- step of timestamp grid + 45 AS window_seconds -- "staleness" window +SELECT timeSeriesChangesToGrid(start_ts, end_ts, step_seconds, window_seconds)(timestamp, value) +FROM +( + -- This subquery converts arrays of timestamps and values into rows of `timestamp`, `value` + SELECT + arrayJoin(arrayZip(timestamps, values)) AS ts_and_val, + ts_and_val.1 AS timestamp, + ts_and_val.2 AS value +); +``` + +响应: + +```response + ┌─timeSeriesChangesToGrid(start_ts, end_ts, step_seconds, window_seconds)(timestamp, value)─┐ +1. │ [NULL,NULL,0,1,1,1,NULL,0,1,2] │ + └───────────────────────────────────────────────────────────────────────────────────────────┘ +``` + +也可以将多个时间戳和值样本作为相同大小的数组传递。使用数组参数的相同查询: + +```sql +WITH + [110, 120, 130, 190, 200, 210, 220, 230]::Array(DateTime) AS timestamps, + [1, 1, 3, 5, 5, 8, 12, 13]::Array(Float32) AS values, + 90 AS start_ts, + 90 + 135 AS end_ts, + 15 AS step_seconds, + 45 AS window_seconds +SELECT timeSeriesChangesToGrid(start_ts, end_ts, step_seconds, window_seconds)(timestamps, values); +``` + +:::note +此函数为实验性功能,通过设置 `allow_experimental_ts_to_grid_aggregate_function=true` 来启用。 +::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesChangesToGrid.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesChangesToGrid.md.hash new file mode 100644 index 00000000000..3dea428d1c4 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesChangesToGrid.md.hash @@ -0,0 +1 @@ +9ade3f443e4ce788 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesDeltaToGrid.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesDeltaToGrid.md new file mode 100644 index 00000000000..bef30958494 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesDeltaToGrid.md @@ -0,0 +1,70 @@ +--- +'description': '聚合函数,用于计算在指定网格上的类似 PromQL 的时间序列数据的增量。' +'sidebar_position': 221 +'slug': '/sql-reference/aggregate-functions/reference/timeSeriesDeltaToGrid' +'title': 'timeSeriesDeltaToGrid' +'doc_type': 'reference' +--- + +聚合函数,接受时间序列数据,格式为时间戳和对应值的对,并在由起始时间戳、结束时间戳和步长描述的常规时间网格上计算 [PromQL-like delta](https://prometheus.io/docs/prometheus/latest/querying/functions/#delta)。对于网格上的每个点,计算 `delta` 所需的样本将在指定的时间窗口内考虑。 + +参数: +- `start timestamp` - 指定网格的开始时间。 +- `end timestamp` - 指定网格的结束时间。 +- `grid step` - 指定网格的步长,单位为秒。 +- `staleness` - 指定考虑的样本的最大 “陈旧性”,单位为秒。陈旧性窗口是左开右闭的区间。 + +参数: +- `timestamp` - 样本的时间戳 +- `value` - 对应于 `timestamp` 的时间序列值 + +返回值: +在指定网格上的 `delta` 值,类型为 `Array(Nullable(Float64))`。返回的数组包含每个时间网格点的一个值。如果在窗口内没有足够的样本来计算特定网格点的 delta 值,则该值为 NULL。 + +示例: +以下查询在网格 [90, 105, 120, 135, 150, 165, 180, 195, 210] 上计算 `delta` 值: + +```sql +WITH + -- NOTE: the gap between 140 and 190 is to show how values are filled for ts = 150, 165, 180 according to window paramater + [110, 120, 130, 140, 190, 200, 210, 220, 230]::Array(DateTime) AS timestamps, + [1, 1, 3, 4, 5, 5, 8, 12, 13]::Array(Float32) AS values, -- array of values corresponding to timestamps above + 90 AS start_ts, -- start of timestamp grid + 90 + 120 AS end_ts, -- end of timestamp grid + 15 AS step_seconds, -- step of timestamp grid + 45 AS window_seconds -- "staleness" window +SELECT timeSeriesDeltaToGrid(start_ts, end_ts, step_seconds, window_seconds)(timestamp, value) +FROM +( + -- This subquery converts arrays of timestamps and values into rows of `timestamp`, `value` + SELECT + arrayJoin(arrayZip(timestamps, values)) AS ts_and_val, + ts_and_val.1 AS timestamp, + ts_and_val.2 AS value +); +``` + +响应: + +```response + ┌─timeSeriesDeltaToGr⋯timestamps, values)─┐ +1. │ [NULL,NULL,0,3,4.5,3.75,NULL,NULL,3.75] │ + └─────────────────────────────────────────┘ +``` + +此外,也可以将时间戳和对应值的多个样本作为同样大小的数组传递。使用数组参数的相同查询: + +```sql +WITH + [110, 120, 130, 140, 190, 200, 210, 220, 230]::Array(DateTime) AS timestamps, + [1, 1, 3, 4, 5, 5, 8, 12, 13]::Array(Float32) AS values, + 90 AS start_ts, + 90 + 120 AS end_ts, + 15 AS step_seconds, + 45 AS window_seconds +SELECT timeSeriesDeltaToGrid(start_ts, end_ts, step_seconds, window_seconds)(timestamps, values); +``` + +:::note +此函数是实验性的,通过设置 `allow_experimental_ts_to_grid_aggregate_function=true` 来启用它。 +::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesDeltaToGrid.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesDeltaToGrid.md.hash new file mode 100644 index 00000000000..7c534d927f9 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesDeltaToGrid.md.hash @@ -0,0 +1 @@ +24a12580080f1176 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesDerivToGrid.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesDerivToGrid.md new file mode 100644 index 00000000000..0bd6df2b484 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesDerivToGrid.md @@ -0,0 +1,70 @@ +--- +'description': '聚合函数,计算指定网格上的类PromQL导数,基于时间序列数据。' +'sidebar_position': 227 +'slug': '/sql-reference/aggregate-functions/reference/timeSeriesDerivToGrid' +'title': 'timeSeriesDerivToGrid' +'doc_type': 'reference' +--- + +聚合函数接受时间序列数据作为时间戳和数值的对,并计算该数据在由开始时间戳、结束时间戳和步长描述的规则时间网格上的 [PromQL 风格的导数](https://prometheus.io/docs/prometheus/latest/querying/functions/#deriv)。对于网格上的每个点,计算 `deriv` 的样本在指定的时间窗口内进行考虑。 + +参数: +- `start timestamp` - 指定网格的开始时间。 +- `end timestamp` - 指定网格的结束时间。 +- `grid step` - 指定网格的步长(以秒为单位)。 +- `staleness` - 指定考虑的样本的最大“过时”时间(以秒为单位)。过时窗口是左开右闭区间。 + +参数: +- `timestamp` - 样本的时间戳 +- `value` - 与 `timestamp` 相关的时间序列值 + +返回值: +`deriv` 值以 `Array(Nullable(Float64))` 的形式出现在指定的网格上。返回的数组包含每个时间网格点的一个值。如果在窗口内没有足够的样本来计算特定网格点的导数值,则该值为 NULL。 + +示例: +以下查询在网格 [90, 105, 120, 135, 150, 165, 180, 195, 210] 上计算 `deriv` 值: + +```sql +WITH + -- NOTE: the gap between 140 and 190 is to show how values are filled for ts = 150, 165, 180 according to window parameter + [110, 120, 130, 140, 190, 200, 210, 220, 230]::Array(DateTime) AS timestamps, + [1, 1, 3, 4, 5, 5, 8, 12, 13]::Array(Float32) AS values, -- array of values corresponding to timestamps above + 90 AS start_ts, -- start of timestamp grid + 90 + 120 AS end_ts, -- end of timestamp grid + 15 AS step_seconds, -- step of timestamp grid + 45 AS window_seconds -- "staleness" window +SELECT timeSeriesDerivToGrid(start_ts, end_ts, step_seconds, window_seconds)(timestamp, value) +FROM +( + -- This subquery converts arrays of timestamps and values into rows of `timestamp`, `value` + SELECT + arrayJoin(arrayZip(timestamps, values)) AS ts_and_val, + ts_and_val.1 AS timestamp, + ts_and_val.2 AS value +); +``` + +响应: + +```response + ┌─timeSeriesDerivToGrid(start_ts, end_ts, step_seconds, window_seconds)(timestamp, value)─┐ +1. │ [NULL,NULL,0,0.1,0.11,0.15,NULL,NULL,0.15] │ + └─────────────────────────────────────────────────────────────────────────────────────────┘ +``` + +同样,可以将时间戳和数值的多个样本作为相同大小的数组传递。使用数组参数的相同查询: + +```sql +WITH + [110, 120, 130, 140, 190, 200, 210, 220, 230]::Array(DateTime) AS timestamps, + [1, 1, 3, 4, 5, 5, 8, 12, 13]::Array(Float32) AS values, + 90 AS start_ts, + 90 + 120 AS end_ts, + 15 AS step_seconds, + 45 AS window_seconds +SELECT timeSeriesDerivToGrid(start_ts, end_ts, step_seconds, window_seconds)(timestamps, values); +``` + +:::note +此函数是实验性的,通过设置 `allow_experimental_ts_to_grid_aggregate_function=true` 启用它。 +::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesDerivToGrid.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesDerivToGrid.md.hash new file mode 100644 index 00000000000..ca450d1db6c --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesDerivToGrid.md.hash @@ -0,0 +1 @@ +7d31ef47ea875f60 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesGroupArray.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesGroupArray.md new file mode 100644 index 00000000000..65180929506 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesGroupArray.md @@ -0,0 +1,66 @@ +--- +'description': '按时间戳升序排序时间序列。' +'sidebar_position': 146 +'slug': '/sql-reference/aggregate-functions/reference/timeSeriesGroupArray' +'title': 'timeSeriesGroupArray' +'doc_type': 'reference' +--- + + +# timeSeriesGroupArray + +按时间戳升序排序时间序列。 + +**语法** + +```sql +timeSeriesGroupArray(timestamp, value) +``` + +**参数** + +- `timestamp` - 样本的时间戳 +- `value` - 与 `timestamp` 对应的时间序列值 + +**返回值** + +该函数返回一个元组数组(`timestamp`, `value`),按 `timestamp` 升序排序。 +如果同一 `timestamp` 有多个值,则该函数选择其中最大的值。 + +**示例** + +```sql +WITH + [110, 120, 130, 140, 140, 100]::Array(UInt32) AS timestamps, + [1, 6, 8, 17, 19, 5]::Array(Float32) AS values -- array of values corresponding to timestamps above +SELECT timeSeriesGroupArray(timestamp, value) +FROM +( + -- This subquery converts arrays of timestamps and values into rows of `timestamp`, `value` + SELECT + arrayJoin(arrayZip(timestamps, values)) AS ts_and_val, + ts_and_val.1 AS timestamp, + ts_and_val.2 AS value +); +``` + +响应: + +```response + ┌─timeSeriesGroupArray(timestamp, value)───────┐ +1. │ [(100,5),(110,1),(120,6),(130,8),(140,19)] │ + └──────────────────────────────────────────────┘ +``` + +还可以将多个时间戳和对应值作为相同大小的数组传递。使用数组参数的相同查询: + +```sql +WITH + [110, 120, 130, 140, 140, 100]::Array(UInt32) AS timestamps, + [1, 6, 8, 17, 19, 5]::Array(Float32) AS values -- array of values corresponding to timestamps above +SELECT timeSeriesGroupArray(timestamps, values); +``` + +:::note +此函数是实验性的,通过设置 `allow_experimental_ts_to_grid_aggregate_function=true` 启用它。 +::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesGroupArray.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesGroupArray.md.hash new file mode 100644 index 00000000000..1cd8b22de61 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesGroupArray.md.hash @@ -0,0 +1 @@ +0cdf29c54432b936 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesInstantDeltaToGrid.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesInstantDeltaToGrid.md new file mode 100644 index 00000000000..38e4ee14bb3 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesInstantDeltaToGrid.md @@ -0,0 +1,70 @@ +--- +'description': '聚合函数,用于计算在指定网格上对时间序列数据进行类似 PromQL 的 idelta。' +'sidebar_position': 222 +'slug': '/sql-reference/aggregate-functions/reference/timeSeriesInstantDeltaToGrid' +'title': 'timeSeriesInstantDeltaToGrid' +'doc_type': 'reference' +--- + +聚合函数,它将时间序列数据作为时间戳和数值的对,并在由开始时间戳、结束时间戳和步长描述的规则时间网格上计算 [PromQL-like idelta](https://prometheus.io/docs/prometheus/latest/querying/functions/#idelta)。对于网格上的每个点,在指定的时间窗口内考虑计算 `idelta` 的样本。 + +参数: +- `start timestamp` - 指定网格的开始时间。 +- `end timestamp` - 指定网格的结束时间。 +- `grid step` - 指定网格的步长(以秒为单位)。 +- `staleness` - 指定考虑的样本的最大“过时性”(以秒为单位)。过时窗口是一个左开右闭的区间。 + +参数: +- `timestamp` - 样本的时间戳 +- `value` - 与 `timestamp` 对应的时间序列的值 + +返回值: +在指定网格上的 `idelta` 值,返回为 `Array(Nullable(Float64))`。返回的数组包含每个时间网格点的一个值。如果在窗口内没有足够的样本来计算特定网格点的瞬时增量值,则该值为 NULL。 + +示例: +以下查询计算网格 [90, 105, 120, 135, 150, 165, 180, 195, 210] 上的 `idelta` 值: + +```sql +WITH + -- NOTE: the gap between 140 and 190 is to show how values are filled for ts = 150, 165, 180 according to window paramater + [110, 120, 130, 140, 190, 200, 210, 220, 230]::Array(DateTime) AS timestamps, + [1, 1, 3, 4, 5, 5, 8, 12, 13]::Array(Float32) AS values, -- array of values corresponding to timestamps above + 90 AS start_ts, -- start of timestamp grid + 90 + 120 AS end_ts, -- end of timestamp grid + 15 AS step_seconds, -- step of timestamp grid + 45 AS window_seconds -- "staleness" window +SELECT timeSeriesInstantDeltaToGrid(start_ts, end_ts, step_seconds, window_seconds)(timestamp, value) +FROM +( + -- This subquery converts arrays of timestamps and values into rows of `timestamp`, `value` + SELECT + arrayJoin(arrayZip(timestamps, values)) AS ts_and_val, + ts_and_val.1 AS timestamp, + ts_and_val.2 AS value +); +``` + +响应: + +```response + ┌─timeSeriesInsta⋯stamps, values)─┐ +1. │ [NULL,NULL,0,2,1,1,NULL,NULL,3] │ + └─────────────────────────────────┘ +``` + +还可以将多个时间戳和数值样本作为相同大小的数组传递。使用数组参数的相同查询: + +```sql +WITH + [110, 120, 130, 140, 190, 200, 210, 220, 230]::Array(DateTime) AS timestamps, + [1, 1, 3, 4, 5, 5, 8, 12, 13]::Array(Float32) AS values, + 90 AS start_ts, + 90 + 120 AS end_ts, + 15 AS step_seconds, + 45 AS window_seconds +SELECT timeSeriesInstantDeltaToGrid(start_ts, end_ts, step_seconds, window_seconds)(timestamps, values); +``` + +:::note +此函数为实验性函数,启用它需要设置 `allow_experimental_ts_to_grid_aggregate_function=true`。 +::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesInstantDeltaToGrid.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesInstantDeltaToGrid.md.hash new file mode 100644 index 00000000000..5d44eab5275 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesInstantDeltaToGrid.md.hash @@ -0,0 +1 @@ +91724e51475c6a4b diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesInstantRateToGrid.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesInstantRateToGrid.md new file mode 100644 index 00000000000..291dfa1aef0 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesInstantRateToGrid.md @@ -0,0 +1,70 @@ +--- +'description': '聚合函数,计算指定网格上时间序列数据的类似于 PromQL 的 irate.' +'sidebar_position': 223 +'slug': '/sql-reference/aggregate-functions/reference/timeSeriesInstantRateToGrid' +'title': 'timeSeriesInstantRateToGrid' +'doc_type': 'reference' +--- + +聚合函数,它接受时间序列数据(以时间戳和值的对形式)并计算该数据在由起始时间戳、结束时间戳和步长描述的规则时间网格上的[PromQL-like irate](https://prometheus.io/docs/prometheus/latest/querying/functions/#irate)。对于网格上的每一点,计算`irate`所考虑的样本在指定的时间窗口内。 + +参数: +- `start timestamp` - 指定网格的起始时间。 +- `end timestamp` - 指定网格的结束时间。 +- `grid step` - 指定网格的步长(单位:秒)。 +- `staleness` - 指定考虑样本的最大“过时性”(单位:秒)。过时性窗口是一个左开右闭的区间。 + +参数: +- `timestamp` - 样本的时间戳 +- `value` - 与`timestamp`对应的时间序列值 + +返回值: +在指定网格上的`irate`值,作为`Array(Nullable(Float64))`返回。返回的数组为每个时间网格点包含一个值。如果在窗口内没有足够的样本来计算某个网格点的瞬时速率值,该值为NULL。 + +示例: +以下查询计算网格[90, 105, 120, 135, 150, 165, 180, 195, 210]上的`irate`值: + +```sql +WITH + -- NOTE: the gap between 140 and 190 is to show how values are filled for ts = 150, 165, 180 according to window paramater + [110, 120, 130, 140, 190, 200, 210, 220, 230]::Array(DateTime) AS timestamps, + [1, 1, 3, 4, 5, 5, 8, 12, 13]::Array(Float32) AS values, -- array of values corresponding to timestamps above + 90 AS start_ts, -- start of timestamp grid + 90 + 120 AS end_ts, -- end of timestamp grid + 15 AS step_seconds, -- step of timestamp grid + 45 AS window_seconds -- "staleness" window +SELECT timeSeriesInstantRateToGrid(start_ts, end_ts, step_seconds, window_seconds)(timestamp, value) +FROM +( + -- This subquery converts arrays of timestamps and values into rows of `timestamp`, `value` + SELECT + arrayJoin(arrayZip(timestamps, values)) AS ts_and_val, + ts_and_val.1 AS timestamp, + ts_and_val.2 AS value +); +``` + +响应: + +```response + ┌─timeSeriesInstantRa⋯timestamps, values)─┐ +1. │ [NULL,NULL,0,0.2,0.1,0.1,NULL,NULL,0.3] │ + └─────────────────────────────────────────┘ +``` + +还可以将多个时间戳和值样本作为相等大小的数组传递。使用数组参数的相同查询: + +```sql +WITH + [110, 120, 130, 140, 190, 200, 210, 220, 230]::Array(DateTime) AS timestamps, + [1, 1, 3, 4, 5, 5, 8, 12, 13]::Array(Float32) AS values, + 90 AS start_ts, + 90 + 120 AS end_ts, + 15 AS step_seconds, + 45 AS window_seconds +SELECT timeSeriesInstantRateToGrid(start_ts, end_ts, step_seconds, window_seconds)(timestamps, values); +``` + +:::note +此函数是实验性的,通过设置`allow_experimental_ts_to_grid_aggregate_function=true`来启用它。 +::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesInstantRateToGrid.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesInstantRateToGrid.md.hash new file mode 100644 index 00000000000..c908ecb81ae --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesInstantRateToGrid.md.hash @@ -0,0 +1 @@ +1d392c4e4378f935 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesLastTwoSamples.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesLastTwoSamples.md new file mode 100644 index 00000000000..fddf461e0e3 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesLastTwoSamples.md @@ -0,0 +1,159 @@ +--- +'description': '用于 PromQL 类似 irate 和 idelta 计算的时间序列数据重采样的聚合函数' +'sidebar_position': 224 +'slug': '/sql-reference/aggregate-functions/reference/timeSeriesLastTwoSamples' +'title': 'timeSeriesLastTwoSamples' +'doc_type': 'reference' +--- + +聚合函数接收时间序列数据,作为时间戳和值的对,并最多保存最近的 2 个样本。 + +参数: +- `timestamp` - 样本的时间戳 +- `value` - 与 `timestamp` 对应的时间序列值 +此外,还可以将多个时间戳和值作为相同大小的数组传递。 + +返回值: +一个 `Tuple(Array(DateTime), Array(Float64))` - 一对长度为 0 到 2 的数组。第一个数组包含采样时间序列的时间戳,第二个数组包含对应的时间序列值。 + +示例: +此聚合函数旨在与物化视图和聚合表结合使用,该表存储具有网格对齐时间戳的重新采样时间序列数据。 +考虑以下原始数据示例表,以及用于存储重新采样数据的表: + +```sql +-- Table for raw data +CREATE TABLE t_raw_timeseries +( + metric_id UInt64, + timestamp DateTime64(3, 'UTC') CODEC(DoubleDelta, ZSTD), + value Float64 CODEC(DoubleDelta) +) +ENGINE = MergeTree() +ORDER BY (metric_id, timestamp); + +-- Table with data re-sampled to bigger (15 sec) time steps +CREATE TABLE t_resampled_timeseries_15_sec +( + metric_id UInt64, + grid_timestamp DateTime('UTC') CODEC(DoubleDelta, ZSTD), -- Timestamp aligned to 15 sec + samples AggregateFunction(timeSeriesLastTwoSamples, DateTime64(3, 'UTC'), Float64) +) +ENGINE = AggregatingMergeTree() +ORDER BY (metric_id, grid_timestamp); + +-- MV for populating re-sampled table +CREATE MATERIALIZED VIEW mv_resampled_timeseries TO t_resampled_timeseries_15_sec +( + metric_id UInt64, + grid_timestamp DateTime('UTC') CODEC(DoubleDelta, ZSTD), + samples AggregateFunction(timeSeriesLastTwoSamples, DateTime64(3, 'UTC'), Float64) +) +AS SELECT + metric_id, + ceil(toUnixTimestamp(timestamp + interval 999 millisecond) / 15, 0) * 15 AS grid_timestamp, -- Round timestamp up to the next grid point + initializeAggregation('timeSeriesLastTwoSamplesState', timestamp, value) AS samples +FROM t_raw_timeseries +ORDER BY metric_id, grid_timestamp; +``` + +插入一些测试数据并读取 '2024-12-12 12:00:12' 和 '2024-12-12 12:00:30' 之间的数据 +```sql +-- Insert some data +INSERT INTO t_raw_timeseries(metric_id, timestamp, value) SELECT number%10 AS metric_id, '2024-12-12 12:00:00'::DateTime64(3, 'UTC') + interval ((number/10)%100)*900 millisecond as timestamp, number%3+number%29 AS value FROM numbers(1000); + +-- Check raw data +SELECT * +FROM t_raw_timeseries +WHERE metric_id = 3 AND timestamp BETWEEN '2024-12-12 12:00:12' AND '2024-12-12 12:00:31' +ORDER BY metric_id, timestamp; +``` + +```response +3 2024-12-12 12:00:12.870 29 +3 2024-12-12 12:00:13.770 8 +3 2024-12-12 12:00:14.670 19 +3 2024-12-12 12:00:15.570 30 +3 2024-12-12 12:00:16.470 9 +3 2024-12-12 12:00:17.370 20 +3 2024-12-12 12:00:18.270 2 +3 2024-12-12 12:00:19.170 10 +3 2024-12-12 12:00:20.070 21 +3 2024-12-12 12:00:20.970 3 +3 2024-12-12 12:00:21.870 11 +3 2024-12-12 12:00:22.770 22 +3 2024-12-12 12:00:23.670 4 +3 2024-12-12 12:00:24.570 12 +3 2024-12-12 12:00:25.470 23 +3 2024-12-12 12:00:26.370 5 +3 2024-12-12 12:00:27.270 13 +3 2024-12-12 12:00:28.170 24 +3 2024-12-12 12:00:29.069 6 +3 2024-12-12 12:00:29.969 14 +3 2024-12-12 12:00:30.869 25 +``` + +查询时间戳 '2024-12-12 12:00:15' 和 '2024-12-12 12:00:30' 的最后 2 个样本: +```sql +-- Check re-sampled data +SELECT metric_id, grid_timestamp, (finalizeAggregation(samples).1 as timestamp, finalizeAggregation(samples).2 as value) +FROM t_resampled_timeseries_15_sec +WHERE metric_id = 3 AND grid_timestamp BETWEEN '2024-12-12 12:00:15' AND '2024-12-12 12:00:30' +ORDER BY metric_id, grid_timestamp; +``` + +```response +3 2024-12-12 12:00:15 (['2024-12-12 12:00:14.670','2024-12-12 12:00:13.770'],[19,8]) +3 2024-12-12 12:00:30 (['2024-12-12 12:00:29.969','2024-12-12 12:00:29.069'],[14,6]) +``` + +聚合表仅存储每个 15 秒对齐时间戳的最后 2 个值。这使得通过读取比原始表中存储的数据少得多来计算类似 PromQL 的 `irate` 和 `idelta` 成为可能。 + +```sql +-- Calculate idelta and irate from the raw data +WITH + '2024-12-12 12:00:15'::DateTime64(3,'UTC') AS start_ts, -- start of timestamp grid + start_ts + INTERVAL 60 SECOND AS end_ts, -- end of timestamp grid + 15 AS step_seconds, -- step of timestamp grid + 45 AS window_seconds -- "staleness" window +SELECT + metric_id, + timeSeriesInstantDeltaToGrid(start_ts, end_ts, step_seconds, window_seconds)(timestamp, value), + timeSeriesInstantRateToGrid(start_ts, end_ts, step_seconds, window_seconds)(timestamp, value) +FROM t_raw_timeseries +WHERE metric_id = 3 AND timestamp BETWEEN start_ts - interval window_seconds seconds AND end_ts +GROUP BY metric_id; +``` + +```response +3 [11,8,-18,8,11] [12.222222222222221,8.88888888888889,1.1111111111111112,8.88888888888889,12.222222222222221] +``` + +```sql +-- Calculate idelta and irate from the re-sampled data +WITH + '2024-12-12 12:00:15'::DateTime64(3,'UTC') AS start_ts, -- start of timestamp grid + start_ts + INTERVAL 60 SECOND AS end_ts, -- end of timestamp grid + 15 AS step_seconds, -- step of timestamp grid + 45 AS window_seconds -- "staleness" window +SELECT + metric_id, + timeSeriesInstantDeltaToGrid(start_ts, end_ts, step_seconds, window_seconds)(timestamps, values), + timeSeriesInstantRateToGrid(start_ts, end_ts, step_seconds, window_seconds)(timestamps, values) +FROM ( + SELECT + metric_id, + finalizeAggregation(samples).1 AS timestamps, + finalizeAggregation(samples).2 AS values + FROM t_resampled_timeseries_15_sec + WHERE metric_id = 3 AND grid_timestamp BETWEEN start_ts - interval window_seconds seconds AND end_ts +) +GROUP BY metric_id; +``` + +```response +3 [11,8,-18,8,11] [12.222222222222221,8.88888888888889,1.1111111111111112,8.88888888888889,12.222222222222221] +``` + +:::note +此功能仍处于实验阶段,请通过设置 `allow_experimental_ts_to_grid_aggregate_function=true` 来启用它。 +::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesLastTwoSamples.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesLastTwoSamples.md.hash new file mode 100644 index 00000000000..fb82d80eac0 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesLastTwoSamples.md.hash @@ -0,0 +1 @@ +c74128a97649ed93 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesPredictLinearToGrid.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesPredictLinearToGrid.md new file mode 100644 index 00000000000..79ff5c9ba58 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesPredictLinearToGrid.md @@ -0,0 +1,73 @@ +--- +'description': '聚合函数,用于在指定网格上对时间序列数据进行类似 PromQL 的线性预测。' +'sidebar_position': 228 +'slug': '/sql-reference/aggregate-functions/reference/timeSeriesPredictLinearToGrid' +'title': 'timeSeriesPredictLinearToGrid' +'doc_type': 'reference' +--- + +聚合函数采用时间序列数据作为时间戳和数值的配对,并根据指定的预测时间戳偏移量在常规时间网格上计算 [PromQL 风格的线性预测](https://prometheus.io/docs/prometheus/latest/querying/functions/#predict_linear)。对于网格上的每一个点,计算 `predict_linear` 所需的样本将在指定的时间窗口内考虑。 + +参数: +- `start timestamp` - 指定网格的开始时间。 +- `end timestamp` - 指定网格的结束时间。 +- `grid step` - 指定网格的步长(以秒为单位)。 +- `staleness` - 指定考虑样本的最大“陈旧性”(以秒为单位)。陈旧性窗口是一个左开右闭的区间。 +- `predict_offset` - 指定要添加到预测时间的秒数偏移。 + +参数: +- `timestamp` - 样本的时间戳 +- `value` - 与 `timestamp` 对应的时间序列值 + +返回值: +在指定网格上的 `predict_linear` 值,作为 `Array(Nullable(Float64))`。返回的数组包含每个时间网格点的一个值。如果在窗口内没有足够的样本来计算特定网格点的速率值,则该值为 NULL。 + +示例: +以下查询计算在网格 [90, 105, 120, 135, 150, 165, 180, 195, 210] 上的 `predict_linear` 值,偏移 60 秒: + +```sql +WITH + -- NOTE: the gap between 140 and 190 is to show how values are filled for ts = 150, 165, 180 according to window paramater + [110, 120, 130, 140, 190, 200, 210, 220, 230]::Array(DateTime) AS timestamps, + [1, 1, 3, 4, 5, 5, 8, 12, 13]::Array(Float32) AS values, -- array of values corresponding to timestamps above + 90 AS start_ts, -- start of timestamp grid + 90 + 120 AS end_ts, -- end of timestamp grid + 15 AS step_seconds, -- step of timestamp grid + 45 AS window_seconds, -- "staleness" window + 60 AS predict_offset -- prediction time offset +SELECT timeSeriesPredictLinearToGrid(start_ts, end_ts, step_seconds, window_seconds, predict_offset)(timestamp, value) +FROM +( + -- This subquery converts arrays of timestamps and values into rows of `timestamp`, `value` + SELECT + arrayJoin(arrayZip(timestamps, values)) AS ts_and_val, + ts_and_val.1 AS timestamp, + ts_and_val.2 AS value +); +``` + +响应: + +```response + ┌─timeSeriesPredictLinearToGrid(start_ts, end_ts, step_seconds, window_seconds, predict_offset)(timestamp, value)─┐ +1. │ [NULL,NULL,1,9.166667,11.6,16.916666,NULL,NULL,16.5] │ + └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ +``` + +同样,可以将多个时间戳和数值样本作为相同大小的数组传递。使用数组参数的相同查询: + +```sql +WITH + [110, 120, 130, 140, 190, 200, 210, 220, 230]::Array(DateTime) AS timestamps, + [1, 1, 3, 4, 5, 5, 8, 12, 13]::Array(Float32) AS values, + 90 AS start_ts, + 90 + 120 AS end_ts, + 15 AS step_seconds, + 45 AS window_seconds, + 60 AS predict_offset +SELECT timeSeriesPredictLinearToGrid(start_ts, end_ts, step_seconds, window_seconds, predict_offset)(timestamps, values); +``` + +:::note +此函数为实验性功能,通过设置 `allow_experimental_ts_to_grid_aggregate_function=true` 来启用它。 +::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesPredictLinearToGrid.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesPredictLinearToGrid.md.hash new file mode 100644 index 00000000000..9283797ab1c --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesPredictLinearToGrid.md.hash @@ -0,0 +1 @@ +0d6581ff3db2400a diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesRateToGrid.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesRateToGrid.md new file mode 100644 index 00000000000..be5ca664d73 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesRateToGrid.md @@ -0,0 +1,70 @@ +--- +'description': '聚合函数,计算在指定网格上对时间序列数据的类似 PromQL 的速率。' +'sidebar_position': 225 +'slug': '/sql-reference/aggregate-functions/reference/timeSeriesRateToGrid' +'title': 'timeSeriesRateToGrid' +'doc_type': 'reference' +--- + +聚合函数,接受时间序列数据作为时间戳和值的对,并在由开始时间戳、结束时间戳和步长描述的规则时间网格上计算 [PromQL 类似的速率](https://prometheus.io/docs/prometheus/latest/querying/functions/#rate)。对于网格上的每个点,用于计算 `rate` 的样本在指定的时间窗口内考虑。 + +参数: +- `start timestamp` - 指定网格的开始时间。 +- `end timestamp` - 指定网格的结束时间。 +- `grid step` - 指定网格的步长(以秒为单位)。 +- `staleness` - 指定考虑的样本的最大“过时”时间(以秒为单位)。过时窗口是左开右闭的区间。 + +参数: +- `timestamp` - 样本的时间戳 +- `value` - 与 `timestamp` 相关的时间序列的值 + +返回值: +在指定网格上的 `rate` 值,作为 `Array(Nullable(Float64))`。返回的数组包含网格每个时间点的一个值。如果在计算特定网格点的速率值时没有足够的样本,则该值为 NULL。 + +示例: +以下查询在网格 [90, 105, 120, 135, 150, 165, 180, 195, 210] 上计算 `rate` 值: + +```sql +WITH + -- NOTE: the gap between 140 and 190 is to show how values are filled for ts = 150, 165, 180 according to window paramater + [110, 120, 130, 140, 190, 200, 210, 220, 230]::Array(DateTime) AS timestamps, + [1, 1, 3, 4, 5, 5, 8, 12, 13]::Array(Float32) AS values, -- array of values corresponding to timestamps above + 90 AS start_ts, -- start of timestamp grid + 90 + 120 AS end_ts, -- end of timestamp grid + 15 AS step_seconds, -- step of timestamp grid + 45 AS window_seconds -- "staleness" window +SELECT timeSeriesRateToGrid(start_ts, end_ts, step_seconds, window_seconds)(timestamp, value) +FROM +( + -- This subquery converts arrays of timestamps and values into rows of `timestamp`, `value` + SELECT + arrayJoin(arrayZip(timestamps, values)) AS ts_and_val, + ts_and_val.1 AS timestamp, + ts_and_val.2 AS value +); +``` + +响应: + +```response + ┌─timeSeriesRateToGrid(start_ts, ⋯w_seconds)(timestamps, values)─┐ +1. │ [NULL,NULL,0,0.06666667,0.1,0.083333336,NULL,NULL,0.083333336] │ + └────────────────────────────────────────────────────────────────┘ +``` + +此外,还可以将多个时间戳和值样本作为相等大小的数组传递。使用数组参数的相同查询: + +```sql +WITH + [110, 120, 130, 140, 190, 200, 210, 220, 230]::Array(DateTime) AS timestamps, + [1, 1, 3, 4, 5, 5, 8, 12, 13]::Array(Float32) AS values, + 90 AS start_ts, + 90 + 120 AS end_ts, + 15 AS step_seconds, + 45 AS window_seconds +SELECT timeSeriesRateToGrid(start_ts, end_ts, step_seconds, window_seconds)(timestamps, values); +``` + +:::note +此函数为实验性功能,通过设置 `allow_experimental_ts_to_grid_aggregate_function=true` 来启用它。 +::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesRateToGrid.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesRateToGrid.md.hash new file mode 100644 index 00000000000..fd14a620c78 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesRateToGrid.md.hash @@ -0,0 +1 @@ +aa8bb2fa93e6d784 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesResampleToGridWithStaleness.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesResampleToGridWithStaleness.md new file mode 100644 index 00000000000..233a804c480 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesResampleToGridWithStaleness.md @@ -0,0 +1,72 @@ +--- +'description': '聚合函数,重新采样时间序列数据到指定的网格。' +'sidebar_position': 226 +'slug': '/sql-reference/aggregate-functions/reference/timeSeriesResampleToGridWithStaleness' +'title': 'timeSeriesResampleToGridWithStaleness' +'doc_type': 'reference' +--- + +聚合函数,将时间序列数据作为时间戳与值的对,并将这些数据重新采样到由开始时间戳、结束时间戳和步长描述的规则时间网格中。对于网格上的每个点,都选择最接近(在指定的时间窗口内)的样本。 + +别名: `timeSeriesLastToGrid`。 + +参数: +- `start timestamp` - 指定网格的开始时间 +- `end timestamp` - 指定网格的结束时间 +- `grid step` - 指定网格的步长(以秒为单位) +- `staleness window` - 指定最近样本的最大“过时”时间(以秒为单位) + +参数: +- `timestamp` - 样本的时间戳 +- `value` - 与 `timestamp` 对应的时间序列的值 + +返回值: +重新采样到指定网格的时间序列值,格式为 `Array(Nullable(Float64))`。返回的数组包含每个时间网格点的一个值。如果特定的网格点没有样本,则该值为 NULL。 + +示例: +以下查询将时间序列数据重新采样到网格 [90, 105, 120, 135, 150, 165, 180, 195, 210],通过选择每个网格点上不早于 30 秒的值: + +```sql +WITH + -- NOTE: the gap between 140 and 190 is to show how values are filled for ts = 150, 165, 180 according to staleness window paramater + [110, 120, 130, 140, 190, 200, 210, 220, 230]::Array(DateTime) AS timestamps, + [1, 1, 3, 4, 5, 5, 8, 12, 13]::Array(Float32) AS values, -- array of values corresponding to timestamps above + 90 AS start_ts, -- start of timestamp grid + 90 + 120 AS end_ts, -- end of timestamp grid + 15 AS step_seconds, -- step of timestamp grid + 30 AS window_seconds -- "staleness" window +SELECT timeSeriesResampleToGridWithStaleness(start_ts, end_ts, step_seconds, window_seconds)(timestamp, value) +FROM +( + -- This subquery converts arrays of timestamps and values into rows of `timestamp`, `value` + SELECT + arrayJoin(arrayZip(timestamps, values)) AS ts_and_val, + ts_and_val.1 AS timestamp, + ts_and_val.2 AS value +); +``` + +响应: + +```response + ┌─timeSeriesResa⋯stamp, value)─┐ +1. │ [NULL,NULL,1,3,4,4,NULL,5,8] │ + └──────────────────────────────┘ +``` + +同样可以将多个时间戳和值的样本作为相同大小的数组传递。具有数组参数的相同查询: + +```sql +WITH + [110, 120, 130, 140, 190, 200, 210, 220, 230]::Array(DateTime) AS timestamps, + [1, 1, 3, 4, 5, 5, 8, 12, 13]::Array(Float32) AS values, + 90 AS start_ts, + 90 + 120 AS end_ts, + 15 AS step_seconds, + 30 AS window_seconds +SELECT timeSeriesResampleToGridWithStaleness(start_ts, end_ts, step_seconds, window_seconds)(timestamps, values); +``` + +:::note +此函数是实验性的,通过设置 `allow_experimental_ts_to_grid_aggregate_function=true` 来启用它。 +::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesResampleToGridWithStaleness.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesResampleToGridWithStaleness.md.hash new file mode 100644 index 00000000000..bfbbbe81f46 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesResampleToGridWithStaleness.md.hash @@ -0,0 +1 @@ +960696b4e6f80480 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesResetsToGrid.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesResetsToGrid.md new file mode 100644 index 00000000000..cc698f55a9a --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesResetsToGrid.md @@ -0,0 +1,70 @@ +--- +'description': '在指定网格上计算类似PromQL的重置的聚合函数,针对时间序列数据。' +'sidebar_position': 230 +'slug': '/sql-reference/aggregate-functions/reference/timeSeriesResetsToGrid' +'title': 'timeSeriesResetsToGrid' +'doc_type': 'reference' +--- + +聚合函数,该函数将时间序列数据作为时间戳和值的对,并在由开始时间戳、结束时间戳和步长描述的规则时间网格上计算 [PromQL 类似的重置](https://prometheus.io/docs/prometheus/latest/querying/functions/#resets)。在网格上的每个点,计算 `resets` 的样本将在指定的时间窗口内考虑。 + +参数: +- `start timestamp` - 指定网格的开始 +- `end timestamp` - 指定网格的结束 +- `grid step` - 指定网格的步长(以秒为单位) +- `staleness` - 指定所考虑样本的最大“过期”时间(以秒为单位) + +参数: +- `timestamp` - 样本的时间戳 +- `value` - 与 `timestamp` 对应的时间序列的值 + +返回值: +`resets` 在指定网格上的值,作为 `Array(Nullable(Float64))`。返回的数组为每个时间网格点包含一个值。如果在计算特定网格点的重置值的窗口内没有样本,则该值为 NULL。 + +示例: +以下查询计算在网格 [90, 105, 120, 135, 150, 165, 180, 195, 210, 225] 上的 `resets` 值: + +```sql +WITH + -- NOTE: the gap between 130 and 190 is to show how values are filled for ts = 180 according to window paramater + [110, 120, 130, 190, 200, 210, 220, 230]::Array(DateTime) AS timestamps, + [1, 3, 2, 6, 6, 4, 2, 0]::Array(Float32) AS values, -- array of values corresponding to timestamps above + 90 AS start_ts, -- start of timestamp grid + 90 + 135 AS end_ts, -- end of timestamp grid + 15 AS step_seconds, -- step of timestamp grid + 45 AS window_seconds -- "staleness" window +SELECT timeSeriesResetsToGrid(start_ts, end_ts, step_seconds, window_seconds)(timestamp, value) +FROM +( + -- This subquery converts arrays of timestamps and values into rows of `timestamp`, `value` + SELECT + arrayJoin(arrayZip(timestamps, values)) AS ts_and_val, + ts_and_val.1 AS timestamp, + ts_and_val.2 AS value +); +``` + +响应: + +```response + ┌─timeSeriesResetsToGrid(start_ts, end_ts, step_seconds, window_seconds)(timestamp, value)─┐ +1. │ [NULL,NULL,0,1,1,1,NULL,0,1,2] │ + └──────────────────────────────────────────────────────────────────────────────────────────┘ +``` + +同样可以将多个时间戳和值样本作为等大小的数组传递。使用数组参数的相同查询: + +```sql +WITH + [110, 120, 130, 190, 200, 210, 220, 230]::Array(DateTime) AS timestamps, + [1, 3, 2, 6, 6, 4, 2, 0]::Array(Float32) AS values, + 90 AS start_ts, + 90 + 135 AS end_ts, + 15 AS step_seconds, + 45 AS window_seconds +SELECT timeSeriesResetsToGrid(start_ts, end_ts, step_seconds, window_seconds)(timestamps, values); +``` + +:::note +此函数是实验性的,通过设置 `allow_experimental_ts_to_grid_aggregate_function=true` 来启用它。 +::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesResetsToGrid.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesResetsToGrid.md.hash new file mode 100644 index 00000000000..17fdeeccc6c --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/timeSeriesResetsToGrid.md.hash @@ -0,0 +1 @@ +c7a22ada84d85f2c diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/topk.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/topk.md index 8c03c53af9e..d013dc60e07 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/topk.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/topk.md @@ -1,16 +1,17 @@ --- -'description': '返回指定列中大约最频繁值的数组。结果数组按值的近似频率降序排序(而不是按值本身排序)。' +'description': '返回指定列中大约最频繁值的数组。结果数组按值的近似频率降序排列(而不是按值本身)。' 'sidebar_position': 202 'slug': '/sql-reference/aggregate-functions/reference/topk' 'title': 'topK' +'doc_type': 'reference' --- # topK -返回指定列中大约最频繁值的数组。结果数组按值的近似频率降序排序(而不是按值本身)。 +返回指定列中大约最频繁值的数组。结果数组按值的近似频率降序排序(而不是按值本身排序)。 -实现了 [Filtered Space-Saving](https://doi.org/10.1016/j.ins.2010.08.024) 算法,用于分析 TopK,基于 [Parallel Space Saving](https://doi.org/10.1016/j.ins.2015.09.003) 的 reduce-and-combine 算法。 +实现了 [Filtered Space-Saving](https://doi.org/10.1016/j.ins.2010.08.024) 算法来分析 TopK,基于 [Parallel Space Saving](https://doi.org/10.1016/j.ins.2015.09.003) 的 reduce-and-combine 算法。 ```sql topK(N)(column) @@ -18,23 +19,23 @@ topK(N, load_factor)(column) topK(N, load_factor, 'counts')(column) ``` -此函数不提供保证结果。在某些情况下,可能会发生错误,返回的频繁值可能不是最频繁的值。 +该函数无法保证结果。在某些情况下,可能会发生错误,并返回不是最频繁的值的频繁值。 -我们建议使用 `N < 10` 的值;当 `N` 值较大时,性能会降低。最大值为 `N = 65536`。 +我们建议使用 `N < 10` 的值;使用较大的 `N` 值时性能会降低。`N` 的最大值为 65536。 **参数** -- `N` — 要返回的元素数量。可选。默认值:10。 -- `load_factor` — 定义为值保留多少单元。如果 uniq(column) > N * load_factor,则 topK 函数的结果将是近似的。可选。默认值:3。 +- `N` — 返回的元素数量。可选。默认值:10。 +- `load_factor` — 定义为值保留的单元格数量。如果 uniq(column) > N * load_factor,那么 topK 函数的结果将是近似值。可选。默认值:3。 - `counts` — 定义结果是否应包含近似计数和误差值。 **参数** -- `column` — 要计算频率的值。 +- `column` — 计算频率的值。 **示例** -取 [OnTime](../../../getting-started/example-datasets/ontime.md) 数据集,并选择 `AirlineID` 列中最频繁出现的三个值。 +以 [OnTime](../../../getting-started/example-datasets/ontime.md) 数据集为例,选择 `AirlineID` 列中出现频率最高的三个值。 ```sql SELECT topK(3)(AirlineID) AS res diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/topk.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/topk.md.hash index 86f9408b9e8..d2fd1928944 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/topk.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/topk.md.hash @@ -1 +1 @@ -ed4098fee73f698d +bfb6fc7326bf1e2c diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/topkweighted.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/topkweighted.md index 45b7c042737..fcc19ff47c6 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/topkweighted.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/topkweighted.md @@ -1,14 +1,15 @@ --- -'description': '返回指定列中大约最频繁值的数组。结果数组按值的近似频率降序排序(不是按值本身排序)。此外,值的权重也被考虑在内。' +'description': '返回指定列中大约最频繁值的数组。结果数组按值的近似频率降序排列(而非按照值本身)。此外,还考虑了值的权重。' 'sidebar_position': 203 'slug': '/sql-reference/aggregate-functions/reference/topkweighted' 'title': 'topKWeighted' +'doc_type': 'reference' --- # topKWeighted -返回指定列中大约最频繁值的数组。结果数组按值的近似频率降序排序(而不是按值本身排序)。此外,还考虑了值的权重。 +返回指定列中约最常见值的数组。结果数组按值的近似频率降序排列(而不是按值本身)。此外,还考虑了值的权重。 **语法** @@ -21,13 +22,13 @@ topKWeighted(N, load_factor, 'counts')(column, weight) **参数** - `N` — 要返回的元素数量。可选。默认值:10。 -- `load_factor` — 定义为值保留多少个单元格。如果 uniq(column) > N * load_factor,则 topK 函数的结果将是近似值。可选。默认值:3。 -- `counts` — 定义结果是否应包含近似计数和误差值。 +- `load_factor` — 定义为值保留的单元格数量。如果 uniq(column) > N * load_factor,则 topK 函数的结果将是近似值。可选。默认值:3。 +- `counts` — 定义结果是否应该包含近似计数和误差值。 -**参数** +**参数说明** - `column` — 值。 -- `weight` — 权重。每个值在频率计算中记为 `weight` 次。[UInt64](../../../sql-reference/data-types/int-uint.md)。 +- `weight` — 权重。每个值在频率计算中计算 `weight` 次。[UInt64](../../../sql-reference/data-types/int-uint.md)。 **返回值** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/topkweighted.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/topkweighted.md.hash index d26ee92ab24..285e6f3ceee 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/topkweighted.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/topkweighted.md.hash @@ -1 +1 @@ -7f4621527b988965 +baade3a8c34062c6 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/uniq.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/uniq.md index 42270455a17..8f81b05ae9c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/uniq.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/uniq.md @@ -3,6 +3,7 @@ 'sidebar_position': 204 'slug': '/sql-reference/aggregate-functions/reference/uniq' 'title': 'uniq' +'doc_type': 'reference' --- @@ -16,7 +17,7 @@ uniq(x[, ...]) **参数** -该函数接受可变数量的参数。参数可以是 `Tuple`、`Array`、`Date`、`DateTime`、`String` 或数字类型。 +该函数接受可变数量的参数。参数可以是 `Tuple`、`Array`、`Date`、`DateTime`、`String` 或数值类型。 **返回值** @@ -26,11 +27,11 @@ uniq(x[, ...]) 函数: -- 为聚合中的所有参数计算哈希,然后在计算中使用它。 +- 对聚合中的所有参数计算哈希值,然后在计算中使用它。 -- 使用自适应采样算法。对于计算状态,该函数使用最多 65536 个元素哈希值的样本。该算法非常准确,并且在 CPU 上非常高效。当查询包含多个此类函数时,使用 `uniq` 几乎与使用其他聚合函数一样快。 +- 使用自适应采样算法。对于计算状态,该函数使用元素哈希值的样本,最多为 65536。该算法非常准确,并且在 CPU 上非常高效。当查询包含多个这样的函数时,使用 `uniq` 的速度几乎与其他聚合函数相当。 -- 提供确定性的结果(它不依赖于查询处理顺序)。 +- 提供确定性的结果(不依赖于查询处理顺序)。 我们建议在几乎所有场景中使用此函数。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/uniq.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/uniq.md.hash index bc8eac3b00a..f2eb6f1238b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/uniq.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/uniq.md.hash @@ -1 +1 @@ -500ab849c14d77c1 +83673f3fd1687427 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/uniqcombined.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/uniqcombined.md index 088fa35d62c..1ca4cae9649 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/uniqcombined.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/uniqcombined.md @@ -3,6 +3,7 @@ 'sidebar_position': 205 'slug': '/sql-reference/aggregate-functions/reference/uniqcombined' 'title': 'uniqCombined' +'doc_type': 'reference' --- @@ -14,12 +15,12 @@ uniqCombined(HLL_precision)(x[, ...]) ``` -`uniqCombined` 函数是计算不同值数量的良好选择。 +`uniqCombined` 函数是计算不同值数量的好选择。 **参数** -- `HLL_precision`: [HyperLogLog](https://en.wikipedia.org/wiki/HyperLogLog) 中单元格数量的以2为基数的对数。可选,您可以使用 `uniqCombined(x[, ...])` 的形式调用该函数。`HLL_precision` 的默认值为 17,这实际上占用了 96 KiB 的空间(2^17 单元格,每个 6 位)。 -- `X`:可变数量的参数。参数可以是 `Tuple`,`Array`,`Date`,`DateTime`,`String` 或数字类型。 +- `HLL_precision`: [HyperLogLog](https://en.wikipedia.org/wiki/HyperLogLog) 中单元格数量的以2为底的对数。可选,您可以将此函数用作 `uniqCombined(x[, ...])`。`HLL_precision` 的默认值为 17,这实际上占用 96 KiB 的空间(2^17 个单元格,每个 6 位)。 +- `X`:可变数量的参数。参数可以是 `Tuple`、`Array`、`Date`、`DateTime`、`String` 或数字类型。 **返回值** @@ -29,22 +30,22 @@ uniqCombined(HLL_precision)(x[, ...]) `uniqCombined` 函数: -- 对所有参数计算哈希值(对于 `String` 使用64位哈希,其他类型使用32位),然后用于计算。 -- 使用三种算法的组合:数组、哈希表和具有误差校正表的 HyperLogLog。 - - 对于少量不同元素,使用数组。 - - 当集合大小较大时,使用哈希表。 - - 对于大量元素,使用 HyperLogLog,它将占用固定数量的内存。 -- 提供确定性的结果(不依赖于查询处理顺序)。 +- 为聚合中的所有参数计算一个哈希(对于 `String` 类型是 64 位哈希,其他类型则为 32 位),然后在计算中使用它。 +- 使用三种算法的组合:数组、哈希表和带有错误修正表的 HyperLogLog。 + - 对于少量不同元素,使用数组。 + - 当集合大小较大时,使用哈希表。 + - 对于数量更多的元素,使用 HyperLogLog,它将占用固定的内存量。 +- 提供确定性的结果(它不依赖于查询处理顺序)。 :::note -由于对非 `String` 类型使用 32 位哈希,因此对于数量大大超过 `UINT_MAX` 的基数,结果将有很高的误差(在几百亿的不同值之后,误差会迅速增加),因此在这种情况下您应该使用 [uniqCombined64](/sql-reference/aggregate-functions/reference/uniqcombined64)。 +由于对非 `String` 类型使用 32 位哈希,因此对于显著大于 `UINT_MAX` 的基数,结果的误差将非常高(误差会在数十亿个不同值后迅速增加),因此在这种情况下,您应该使用 [uniqCombined64](/sql-reference/aggregate-functions/reference/uniqcombined64)。 ::: 与 [uniq](/sql-reference/aggregate-functions/reference/uniq) 函数相比,`uniqCombined` 函数: - 消耗的内存少几倍。 -- 计算的准确性高几倍。 -- 通常性能稍低。在某些场景下,`uniqCombined` 的性能可能优于 `uniq`,例如,当有大量聚合状态通过网络传输的分布式查询时。 +- 计算精度高几倍。 +- 通常性能略低。在某些情况下,`uniqCombined` 可以比 `uniq` 更好,例如在分布式查询中,网络上传输大量聚合状态的情况。 **示例** @@ -62,9 +63,9 @@ SELECT uniqCombined(number) FROM numbers(1e6); └──────────────────────┘ ``` -请参见 [uniqCombined64](/sql-reference/aggregate-functions/reference/uniqcombined64) 的示例部分,了解在处理更大输入时 `uniqCombined` 和 `uniqCombined64` 之间的区别。 +请参阅 [uniqCombined64](/sql-reference/aggregate-functions/reference/uniqcombined64) 的示例部分,以了解 `uniqCombined` 和 `uniqCombined64` 对于更大输入的区别。 -**另请参阅** +**另见** - [uniq](/sql-reference/aggregate-functions/reference/uniq) - [uniqCombined64](/sql-reference/aggregate-functions/reference/uniqcombined64) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/uniqcombined.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/uniqcombined.md.hash index 5b82fa50b03..07e80bc3f1b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/uniqcombined.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/uniqcombined.md.hash @@ -1 +1 @@ -d78a95107c82d6c5 +864e3bf190e8b1f9 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/uniqcombined64.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/uniqcombined64.md index 1956f3fb1ac..9499fcdb769 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/uniqcombined64.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/uniqcombined64.md @@ -1,14 +1,15 @@ --- -'description': '计算不同参数值的近似数量。它与 uniqCombined 相同,但对所有数据类型使用 64 位哈希,而不仅仅是对字符串数据类型使用。' +'description': '计算不同参数值的近似数量。它与 uniqCombined 相同,但对所有数据类型使用 64 位哈希,而不仅仅是对字符串数据类型。' 'sidebar_position': 206 'slug': '/sql-reference/aggregate-functions/reference/uniqcombined64' 'title': 'uniqCombined64' +'doc_type': 'reference' --- # uniqCombined64 -计算不同参数值的近似数量。它与 [uniqCombined](/sql-reference/aggregate-functions/reference/uniqcombined) 相同,但对所有数据类型使用 64 位哈希,而不仅仅是对字符串数据类型使用。 +计算不同参数值的近似数量。它与 [uniqCombined](/sql-reference/aggregate-functions/reference/uniqcombined) 相同,但对所有数据类型使用64位哈希,而不仅仅对字符串数据类型使用。 ```sql uniqCombined64(HLL_precision)(x[, ...]) @@ -16,8 +17,8 @@ uniqCombined64(HLL_precision)(x[, ...]) **参数** -- `HLL_precision`: [HyperLogLog](https://en.wikipedia.org/wiki/HyperLogLog) 中单元格数量的以 2 为底的对数。可选地,您可以将函数用作 `uniqCombined64(x[, ...])`。`HLL_precision` 的默认值为 17,这有效地表示 96 KiB 的空间(2^17 个单元,每个 6 位)。 -- `X`: 可变数量的参数。参数可以是 `Tuple`、`Array`、`Date`、`DateTime`、`String` 或数值类型。 +- `HLL_precision`: [HyperLogLog](https://en.wikipedia.org/wiki/HyperLogLog) 中单元格数量的以2为底的对数。可选地,您可以将此函数用作 `uniqCombined64(x[, ...])`。`HLL_precision` 的默认值为17,相当于96 KiB的空间(2^17个单元格,每个单元格6位)。 +- `X`: 可变数量的参数。参数可以是 `Tuple`、`Array`、`Date`、`DateTime`、`String` 或数字类型。 **返回值** @@ -26,25 +27,25 @@ uniqCombined64(HLL_precision)(x[, ...]) **实现细节** `uniqCombined64` 函数: -- 为聚合中的所有参数计算一个哈希(所有数据类型的 64 位哈希),然后在计算中使用它。 -- 使用三种算法的组合:数组、哈希表和具有错误校正表的 HyperLogLog。 - - 对于少量不同元素,使用数组。 - - 当集合大小较大时,使用哈希表。 - - 对于更多元素,使用 HyperLogLog,这将占用固定数量的内存。 -- 提供确定性的结果(不依赖于查询处理顺序)。 +- 为聚合中的所有参数计算哈希(针对所有数据类型的64位哈希),然后在计算中使用它。 +- 使用三种算法的组合:数组、哈希表和带有误差修正表的 HyperLogLog。 + - 对于少量不同元素,使用数组。 + - 当集合大小较大时,使用哈希表。 + - 对于数量较大的元素,使用 HyperLogLog,它将占用固定数量的内存。 +- 以确定性方式提供结果(不依赖于查询处理顺序)。 :::note -由于对所有类型使用 64 位哈希,因此结果不会因为基数显著大于 `UINT_MAX` 而遭受非常高的误差,就像 [uniqCombined](../../../sql-reference/aggregate-functions/reference/uniqcombined.md) 对非 `String` 类型使用 32 位哈希一样。 +由于它对所有类型使用64位哈希,因此结果不会像 [uniqCombined](../../../sql-reference/aggregate-functions/reference/uniqcombined.md) 那样在基数显著大于 `UINT_MAX` 时出现非常高的误差,因为后者对非 `String` 类型使用32位哈希。 ::: 与 [uniq](/sql-reference/aggregate-functions/reference/uniq) 函数相比,`uniqCombined64` 函数: -- 内存消耗少几倍。 -- 准确度提高了几倍。 +- 消耗的内存少了几倍。 +- 计算的准确度高了几倍。 **示例** -在下面的示例中,对 `1e10` 个不同数字运行 `uniqCombined64`,返回不同参数值数量的非常接近的近似值。 +在下面的示例中,`uniqCombined64` 在 `1e10` 个不同数字上运行,返回非常接近不同参数值数量的近似值。 查询: @@ -60,7 +61,7 @@ SELECT uniqCombined64(number) FROM numbers(1e10); └────────────────────────┘ ``` -相比之下,`uniqCombined` 函数对于如此大小的输入返回的近似值相当差。 +相比之下,`uniqCombined` 函数返回的对如此规模输入的近似值相当差。 查询: @@ -76,7 +77,7 @@ SELECT uniqCombined(number) FROM numbers(1e10); └──────────────────────┘ ``` -**另见** +**另请参阅** - [uniq](/sql-reference/aggregate-functions/reference/uniq) - [uniqCombined](/sql-reference/aggregate-functions/reference/uniqcombined) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/uniqcombined64.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/uniqcombined64.md.hash index 6db398ffd8e..5d15a5b3dbd 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/uniqcombined64.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/uniqcombined64.md.hash @@ -1 +1 @@ -602ddc66f894005a +f10cf0b42b5ae3c4 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/uniqexact.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/uniqexact.md index 6f348d236eb..04b2b807667 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/uniqexact.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/uniqexact.md @@ -1,30 +1,31 @@ --- -'description': '计算不同参数值的确切数量。' +'description': '计算不同参数值的精确数量。' 'sidebar_position': 207 'slug': '/sql-reference/aggregate-functions/reference/uniqexact' 'title': 'uniqExact' +'doc_type': 'reference' --- # uniqExact -计算不同参数值的准确数量。 +计算不同参数值的确切数量。 ```sql uniqExact(x[, ...]) ``` -如果您确实需要一个确切的结果,请使用 `uniqExact` 函数。否则,请使用 [uniq](/sql-reference/aggregate-functions/reference/uniq) 函数。 +如果您绝对需要精确的结果,请使用 `uniqExact` 函数。否则,请使用 [uniq](/sql-reference/aggregate-functions/reference/uniq) 函数。 -`uniqExact` 函数使用的内存比 `uniq` 多,因为随着不同值的增加,状态的大小会无限增长。 +`uniqExact` 函数比 `uniq` 使用更多内存,因为随着不同值数量的增加,状态的大小会无限增长。 **参数** -该函数接受可变数量的参数。参数可以为 `Tuple`、`Array`、`Date`、`DateTime`、`String` 或数值类型。 +该函数接受多个参数。参数可以是 `Tuple`、`Array`、`Date`、`DateTime`、`String` 或数值类型。 **示例** -在此示例中,我们将使用 `uniqExact` 函数来计算 [opensky 数据集](https://sql.clickhouse.com?query=U0VMRUNUIHVuaXFFeGFjdCh0eXBlY29kZSkgRlJPTSBvcGVuc2t5Lm9wZW5za3k&) 中唯一类型代码(飞机类型的短标识符)的数量。 +在此示例中,我们将使用 `uniqExact` 函数来计算 [opensky 数据集](https://sql.clickhouse.com?query=U0VMRUNUIHVuaXFFeGFjdCh0eXBlY29kZSkgRlJPTSBvcGVuc2t5Lm9wZW5za3k&) 中唯一类型代码的数量(飞机类型的简短标识符)。 ```sql title="Query" SELECT uniqExact(typecode) FROM opensky.opensky @@ -34,7 +35,7 @@ SELECT uniqExact(typecode) FROM opensky.opensky 1106 ``` -**另请参阅** +**另请参见** - [uniq](/sql-reference/aggregate-functions/reference/uniq) - [uniqCombined](/sql-reference/aggregate-functions/reference/uniqcombined) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/uniqexact.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/uniqexact.md.hash index abc63c4416d..5724ee993a4 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/uniqexact.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/uniqexact.md.hash @@ -1 +1 @@ -6cba104912b652ba +2d5c4e5a4a852e61 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/uniqhll12.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/uniqhll12.md index b899b2aa37e..bf26069bf81 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/uniqhll12.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/uniqhll12.md @@ -3,6 +3,7 @@ 'sidebar_position': 208 'slug': '/sql-reference/aggregate-functions/reference/uniqhll12' 'title': 'uniqHLL12' +'doc_type': 'reference' --- @@ -26,17 +27,17 @@ uniqHLL12(x[, ...]) 函数: -- 计算聚合中所有参数的哈希值,然后用于计算。 +- 为聚合中的所有参数计算哈希,然后在计算中使用它。 - 使用 HyperLogLog 算法来近似不同参数值的数量。 - 使用 2^12 个 5 位单元。状态的大小略大于 2.5 KB。对于小数据集 (<10K 元素),结果的准确性不是很高(误差高达 ~10%)。然而,对于高基数数据集 (10K-100M),结果相当准确,最大误差为 ~1.6%。从 100M 开始,估算误差增加,对于极高基数的数据集 (1B+ 元素),函数将返回非常不准确的结果。 + 使用 2^12 个 5 位单元格。状态的大小略大于 2.5 KB。对于小数据集(<10K 元素),结果的准确性不是很高(误差可达 ~10%)。然而,对于高基数数据集(10K-100M),结果相当准确,最大误差为 ~1.6%。从 100M 开始,估计误差会增加,对于具有极高基数的数据集(1B+ 元素),函数会返回非常不准确的结果。 - 提供确定性结果(不依赖于查询处理顺序)。 -我们不推荐使用此函数。在大多数情况下,使用 [uniq](/sql-reference/aggregate-functions/reference/uniq) 或 [uniqCombined](/sql-reference/aggregate-functions/reference/uniqcombined) 函数。 +我们不建议使用此函数。在大多数情况下,请使用 [uniq](/sql-reference/aggregate-functions/reference/uniq) 或 [uniqCombined](/sql-reference/aggregate-functions/reference/uniqcombined) 函数。 -**参见** +**另请参阅** - [uniq](/sql-reference/aggregate-functions/reference/uniq) - [uniqCombined](/sql-reference/aggregate-functions/reference/uniqcombined) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/uniqhll12.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/uniqhll12.md.hash index 22cd4268fee..8f874d4e94c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/uniqhll12.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/uniqhll12.md.hash @@ -1 +1 @@ -22df76a908e24791 +22ae706455ee63fa diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/uniqthetasketch.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/uniqthetasketch.md index 9f4261a9b22..cdba1475435 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/uniqthetasketch.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/uniqthetasketch.md @@ -1,8 +1,9 @@ --- -'description': '使用Theta Sketch框架计算不同参数值的近似数量。' +'description': '使用 Theta Sketch Framework 计算不同参数值的近似数量。' 'sidebar_position': 209 'slug': '/sql-reference/aggregate-functions/reference/uniqthetasketch' 'title': 'uniqTheta' +'doc_type': 'reference' --- 计算不同参数值的近似数量,使用 [Theta Sketch Framework](https://datasketches.apache.org/docs/Theta/ThetaSketches.html#theta-sketch-framework)。 @@ -17,21 +18,21 @@ uniqTheta(x[, ...]) **返回值** -- 一个 [UInt64](../../../sql-reference/data-types/int-uint.md) 类型的数字。 +- 一个 [UInt64](../../../sql-reference/data-types/int-uint.md)-类型的数字。 **实现细节** 函数: -- 计算所有参数的哈希值,然后在计算中使用它。 +- 为聚合中的所有参数计算哈希值,然后在计算中使用它。 - 使用 [KMV](https://datasketches.apache.org/docs/Theta/InverseEstimate.html) 算法来近似不同参数值的数量。 - 使用 4096(2^12) 64-bit sketch。状态的大小约为 41 KB。 + 使用 4096(2^12) 64 位 sketch。状态的大小约为 41 KB。 -- 相对误差为 3.125% (95% 置信水平),详见 [相对误差表](https://datasketches.apache.org/docs/Theta/ThetaErrorTable.html)。 +- 相对误差为 3.125%(95% 置信度),详细信息见 [相对误差表](https://datasketches.apache.org/docs/Theta/ThetaErrorTable.html)。 -**另见** +**另请参见** - [uniq](/sql-reference/aggregate-functions/reference/uniq) - [uniqCombined](/sql-reference/aggregate-functions/reference/uniqcombined) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/uniqthetasketch.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/uniqthetasketch.md.hash index c0ad5df03ed..5d9f44f9b10 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/uniqthetasketch.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/uniqthetasketch.md.hash @@ -1 +1 @@ -95a39edb29be0ab5 +c892e5cbf8833f71 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/varpop.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/varpop.md index 2dbb6b26e3b..6d8270d7de3 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/varpop.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/varpop.md @@ -1,8 +1,9 @@ --- 'description': '计算人口方差。' 'sidebar_position': 210 -'slug': '/en/sql-reference/aggregate-functions/reference/varPop' +'slug': '/sql-reference/aggregate-functions/reference/varPop' 'title': 'varPop' +'doc_type': 'reference' --- ## varPop {#varpop} @@ -19,19 +20,19 @@ $$ varPop(x) ``` -别名:`VAR_POP`。 +别名: `VAR_POP`. **参数** -- `x`:要计算总体方差的值的总体。 [(U)Int*](../../data-types/int-uint.md), [Float*](../../data-types/float.md), [Decimal*](../../data-types/decimal.md)。 +- `x`: 要计算总体方差的值的总体。[(U)Int*](../../data-types/int-uint.md), [Float*](../../data-types/float.md), [Decimal*](../../data-types/decimal.md). **返回值** -- 返回 `x` 的总体方差。 [`Float64`](../../data-types/float.md)。 +- 返回 `x` 的总体方差。[`Float64`](../../data-types/float.md). **示例** -查询: +查询: ```sql DROP TABLE IF EXISTS test_data; @@ -48,7 +49,7 @@ SELECT FROM test_data; ``` -结果: +结果: ```response ┌─var_pop─┐ diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/varpop.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/varpop.md.hash index 0ea1bc7115f..16bdb19016f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/varpop.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/varpop.md.hash @@ -1 +1 @@ -297f7eaf3c217020 +1fc3f6be5ffaa02c diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/varpopstable.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/varpopstable.md index 1c7cbc82173..cd1cdd7b471 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/varpopstable.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/varpopstable.md @@ -1,13 +1,14 @@ --- -'description': '返回总体方差。与 varPop 不同,此函数使用数值稳定的算法。它运行较慢,但提供较低的计算错误。' +'description': '返回人口方差。与 varPop 不同,这个函数使用了一个数值稳定的算法。它的工作速度较慢,但提供了更低的计算误差。' 'sidebar_position': 211 'slug': '/sql-reference/aggregate-functions/reference/varpopstable' 'title': 'varPopStable' +'doc_type': 'reference' --- ## varPopStable {#varpopstable} -返回总体方差。与 [`varPop`](../reference/varpop.md) 不同,此函数使用 [数值稳定](https://en.wikipedia.org/wiki/Numerical_stability) 算法。它的运行速度较慢,但提供了更低的计算误差。 +返回总体方差。与 [`varPop`](../reference/varpop.md) 不同,此函数使用一种 [数值稳定](https://en.wikipedia.org/wiki/Numerical_stability) 的算法。尽管速度较慢,但提供了更低的计算误差。 **语法** @@ -19,11 +20,11 @@ varPopStable(x) **参数** -- `x`:要查找总体方差的值的总体。[(U)Int*](../../data-types/int-uint.md), [Float*](../../data-types/float.md), [Decimal*](../../data-types/decimal.md)。 +- `x`:要计算总体方差的值的总体。[(U)Int*](../../data-types/int-uint.md), [Float*](../../data-types/float.md), [Decimal*](../../data-types/decimal.md)。 **返回值** -- 返回 `x` 的总体方差。[Float64](../../data-types/float.md)。 +- 返回 `x` 的总体方差。 [Float64](../../data-types/float.md)。 **示例** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/varpopstable.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/varpopstable.md.hash index b5b5d3b8dd8..366bfd267db 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/varpopstable.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/varpopstable.md.hash @@ -1 +1 @@ -eebba595d7b1584a +a95d9cb996610322 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/varsamp.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/varsamp.md index f18c3540783..1dd1e444d84 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/varsamp.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/varsamp.md @@ -3,6 +3,7 @@ 'sidebar_position': 212 'slug': '/sql-reference/aggregate-functions/reference/varSamp' 'title': 'varSamp' +'doc_type': 'reference' --- ## varSamp {#varsamp} @@ -19,11 +20,11 @@ varSamp(x) **参数** -- `x`: 您要计算样本方差的总体。 [(U)Int*](../../data-types/int-uint.md), [Float*](../../data-types/float.md), [Decimal*](../../data-types/decimal.md)。 +- `x`: 要计算样本方差的人群。[(U)Int*](../../data-types/int-uint.md), [Float*](../../data-types/float.md), [Decimal*](../../data-types/decimal.md)。 **返回值** -- 返回输入数据集 `x` 的样本方差。 [Float64](../../data-types/float.md)。 +- 返回输入数据集 `x` 的样本方差。[Float64](../../data-types/float.md)。 **实现细节** @@ -35,15 +36,15 @@ $$ 其中: -- `x` 是数据集中每个单独数据点。 +- `x` 是数据集中的每个单独数据点。 - `mean(x)` 是数据集的算术平均值。 - `n` 是数据集中数据点的数量。 -该函数假定输入数据集代表来自更大总体的样本。如果您想计算整个总体的方差(当您拥有完整数据集时),应使用 [`varPop`](../reference/varpop.md) 代替。 +该函数假定输入数据集表示来自更大人群的样本。如果你想计算整个总体的方差(当你拥有完整数据集时),应该使用 [`varPop`](../reference/varpop.md)。 **示例** -查询: +查询: ```sql DROP TABLE IF EXISTS test_data; @@ -58,7 +59,7 @@ INSERT INTO test_data VALUES (10.5), (12.3), (9.8), (11.2), (10.7); SELECT round(varSamp(x),3) AS var_samp FROM test_data; ``` -响应: +响应: ```response ┌─var_samp─┐ diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/varsamp.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/varsamp.md.hash index f3372e67204..e67adc9d765 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/varsamp.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/varsamp.md.hash @@ -1 +1 @@ -c5d73644141f29ea +025af3407272c4df diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/varsampstable.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/varsampstable.md index edb05ec04c0..6bc3ecf1f36 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/varsampstable.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/varsampstable.md @@ -1,13 +1,14 @@ --- -'description': '计算数据集的样本方差。与 `varSamp` 不同,此函数使用数值稳定的算法。虽然它运行较慢,但提供了更低的计算误差。' +'description': '计算数据集的样本方差。与 `varSamp` 不同,该函数使用数字稳定的算法。它运行较慢,但提供了较低的计算误差。' 'sidebar_position': 213 'slug': '/sql-reference/aggregate-functions/reference/varsampstable' 'title': 'varSampStable' +'doc_type': 'reference' --- ## varSampStable {#varsampstable} -计算数据集的样本方差。与 [`varSamp`](../reference/varsamp.md) 不同,此函数使用数值稳定的算法。虽然运行速度较慢,但提供了更低的计算误差。 +计算数据集的样本方差。与 [`varSamp`](../reference/varsamp.md) 不同,此函数使用数值稳定算法。它工作较慢,但提供更低的计算误差。 **语法** @@ -19,28 +20,28 @@ varSampStable(x) **参数** -- `x`: 要计算样本方差的总体。[(U)Int*](../../data-types/int-uint.md)、[Float*](../../data-types/float.md)、[Decimal*](../../data-types/decimal.md)。 +- `x`: 要计算样本方差的人群。[(U)Int*](../../data-types/int-uint.md), [Float*](../../data-types/float.md), [Decimal*](../../data-types/decimal.md)。 **返回值** -- 返回输入数据集的样本方差。[Float64](../../data-types/float.md)。 +- 返回输入数据集的样本方差。 [Float64](../../data-types/float.md)。 **实现细节** -`varSampStable` 函数使用与 [`varSamp`](../reference/varsamp.md) 相同的公式计算样本方差: +`varSampStable` 函数使用与 [`varSamp`](../reference/varsamp.md) 相同的公式来计算样本方差: $$ \sum\frac{(x - \text{mean}(x))^2}{(n - 1)} $$ -其中: +其中: - `x` 是数据集中每个单独的数据点。 -- `mean(x)` 是数据集的算术平均值。 +- `mean(x)` 是数据集的算术均值。 - `n` 是数据集中数据点的数量。 **示例** -查询: +查询: ```sql DROP TABLE IF EXISTS test_data; @@ -55,7 +56,7 @@ INSERT INTO test_data VALUES (10.5), (12.3), (9.8), (11.2), (10.7); SELECT round(varSampStable(x),3) AS var_samp_stable FROM test_data; ``` -响应: +响应: ```response ┌─var_samp_stable─┐ diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/varsampstable.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/varsampstable.md.hash index bb4ce0a73d3..795b0362f37 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/varsampstable.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/varsampstable.md.hash @@ -1 +1 @@ -94093c840a9dee8d +ebe81d9ab1ea0f7b diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/welchttest.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/welchttest.md index b092636c9e3..01b36e58c80 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/welchttest.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/welchttest.md @@ -1,15 +1,16 @@ --- -'description': '对来自两个总体的样本应用 Welch''s t-test。' +'description': '对来自两个种群的样本应用 Welch 的 t 检验.' 'sidebar_label': 'welchTTest' 'sidebar_position': 214 'slug': '/sql-reference/aggregate-functions/reference/welchttest' 'title': 'welchTTest' +'doc_type': 'reference' --- # welchTTest -应用 Welch 的 t 检验于两个总体的样本。 +应用 Welch 的 t 检验到两个总体的样本中。 **语法** @@ -17,8 +18,8 @@ welchTTest([confidence_level])(sample_data, sample_index) ``` -两个样本的值位于 `sample_data` 列中。如果 `sample_index` 等于 0,那么该行的值属于第一个总体的样本。否则,它属于第二个总体的样本。 -零假设是总体的均值相等。假设服从正态分布。总体可能具有不同的方差。 +两个样本的值位于 `sample_data` 列中。如果 `sample_index` 等于 0,则该行中的值属于第一个总体的样本。否则,它属于第二个总体的样本。 +原假设是总体的均值相等。假设服从正态分布。总体的方差可以不相等。 **参数** @@ -27,11 +28,11 @@ welchTTest([confidence_level])(sample_data, sample_index) **参数** -- `confidence_level` — 计算置信区间的置信水平。 [浮点数](../../../sql-reference/data-types/float.md)。 +- `confidence_level` — 用于计算置信区间的置信水平。 [浮点数](../../../sql-reference/data-types/float.md)。 **返回值** -[元组](../../../sql-reference/data-types/tuple.md) 包含两个或四个元素(如果指定了可选的 `confidence_level`) +[元组](../../../sql-reference/data-types/tuple.md),包含两个或四个元素(如果指定了可选的 `confidence_level`) - 计算得出的 t 统计量。 [Float64](../../../sql-reference/data-types/float.md)。 - 计算得出的 p 值。 [Float64](../../../sql-reference/data-types/float.md)。 @@ -69,5 +70,5 @@ SELECT welchTTest(sample_data, sample_index) FROM welch_ttest; **另见** -- [Welch 的 t 检验](https://en.wikipedia.org/wiki/Welch%27s_t-test) +- [Welch's t-test](https://en.wikipedia.org/wiki/Welch%27s_t-test) - [studentTTest 函数](/sql-reference/aggregate-functions/reference/studentttest) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/welchttest.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/welchttest.md.hash index 0f4a9960797..ec6eea1104e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/welchttest.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/aggregate-functions/reference/welchttest.md.hash @@ -1 +1 @@ -7616572631e1bb60 +6fb3d6305ab9acbf diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/aggregatefunction.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/aggregatefunction.md index b8631e08917..32d35b6274f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/aggregatefunction.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/aggregatefunction.md @@ -1,5 +1,5 @@ --- -'description': 'ClickHouse 中 AggregateFunction 数据类型的文档,它存储聚合函数的中间状态' +'description': 'ClickHouse 中 AggregateFunction 数据类型的文档,存储聚合函数的中间状态' 'keywords': - 'AggregateFunction' - 'Type' @@ -7,6 +7,7 @@ 'sidebar_position': 46 'slug': '/sql-reference/data-types/aggregatefunction' 'title': 'AggregateFunction 类型' +'doc_type': 'reference' --- @@ -14,12 +15,12 @@ ## 描述 {#description} -ClickHouse 中的所有 [聚合函数](/sql-reference/aggregate-functions) 都具有特定实现的中间状态,可以序列化为 `AggregateFunction` 数据类型并存储在表中。通常通过 [物化视图](../../sql-reference/statements/create/view.md) 来实现这一点。 +在 ClickHouse 中,所有的 [聚合函数](/sql-reference/aggregate-functions) 都有特定实现的中间状态,可以序列化为 `AggregateFunction` 数据类型并存储在表中。这通常通过 [物化视图](../../sql-reference/statements/create/view.md) 来完成。 -常用的两种聚合函数 [组合子](/sql-reference/aggregate-functions/combinators) 与 `AggregateFunction` 类型一起使用: +有两种常用的聚合函数 [组合器](/sql-reference/aggregate-functions/combinators) 与 `AggregateFunction` 类型一起使用: -- [`-State`](/sql-reference/aggregate-functions/combinators#-state) 聚合函数组合子,附加到聚合函数名称后,生成 `AggregateFunction` 中间状态。 -- [`-Merge`](/sql-reference/aggregate-functions/combinators#-merge) 聚合函数组合子,用于从中间状态中获取聚合的最终结果。 +- [`-State`](/sql-reference/aggregate-functions/combinators#-state) 聚合函数组合器,当附加到聚合函数名称时,会生成 `AggregateFunction` 中间状态。 +- [`-Merge`](/sql-reference/aggregate-functions/combinators#-merge) 聚合函数组合器,用于从中间状态获取聚合的最终结果。 ## 语法 {#syntax} @@ -29,7 +30,7 @@ AggregateFunction(aggregate_function_name, types_of_arguments...) **参数** -- `aggregate_function_name` - 聚合函数的名称。如果函数是参数化的,则其参数也应被指定。 +- `aggregate_function_name` - 聚合函数的名称。如果函数是参数化的,则还应指定其参数。 - `types_of_arguments` - 聚合函数参数的类型。 例如: @@ -47,30 +48,26 @@ CREATE TABLE t ### 数据插入 {#data-insertion} -要将数据插入到具有 `AggregateFunction` 类型的列的表中,可以使用 `INSERT SELECT` 与聚合函数以及 -[`-State`](/sql-reference/aggregate-functions/combinators#-state) 聚合函数组合子。 +要向包含 `AggregateFunction` 类型列的表中插入数据,可以使用带有聚合函数和 [`-State`](/sql-reference/aggregate-functions/combinators#-state) 聚合函数组合器的 `INSERT SELECT`。 -例如,要插入类型为 `AggregateFunction(uniq, UInt64)` 和 `AggregateFunction(quantiles(0.5, 0.9), UInt64)` 的列,你可以使用以下带组合子的聚合函数。 +例如,要插入类型为 `AggregateFunction(uniq, UInt64)` 和 `AggregateFunction(quantiles(0.5, 0.9), UInt64)` 的列,可以使用以下带组合器的聚合函数。 ```sql uniqState(UserID) quantilesState(0.5, 0.9)(SendTiming) ``` -与函数 `uniq` 和 `quantiles` 不同,`uniqState` 和 `quantilesState` -(附加了 `-State` 组合子)返回状态,而不是最终值。 -换句话说,它们返回的是 `AggregateFunction` 类型的值。 +与函数 `uniq` 和 `quantiles` 相对,`uniqState` 和 `quantilesState`(附加 `-State` 组合器)返回的是状态,而不是最终值。换句话说,它们返回的是 `AggregateFunction` 类型的值。 -在 `SELECT` 查询的结果中,`AggregateFunction` 类型的值对于所有 ClickHouse 输出格式具有特定实现的二进制表示。 +在 `SELECT` 查询的结果中,类型为 `AggregateFunction` 的值具有特定实现的二进制表示,适用于所有 ClickHouse 输出格式。 -如果你将数据导出到例如 `TabSeparated` 格式并使用 `SELECT` 查询,则可以通过 `INSERT` 查询将此转储加载回。 +如果你将数据以 `TabSeparated` 格式转储到,例如,使用 `SELECT` 查询,则可以使用 `INSERT` 查询将其加载回。 ### 数据选择 {#data-selection} -从 `AggregatingMergeTree` 表选择数据时,使用 `GROUP BY` 子句,以及在插入数据时所用的相同聚合函数,但使用 -[`-Merge`](/sql-reference/aggregate-functions/combinators#-merge) 组合子。 +在从 `AggregatingMergeTree` 表中选择数据时,请使用 `GROUP BY` 子句和与插入数据时相同的聚合函数,但请使用 [`-Merge`](/sql-reference/aggregate-functions/combinators#-merge) 组合器。 -附加 `-Merge` 组合子的聚合函数接受一组状态,合并它们,并返回完整数据聚合的结果。 +附加 `-Merge` 组合器的聚合函数接受一组状态,将它们组合,并返回完整数据聚合的结果。 例如,以下两个查询返回相同的结果: @@ -80,12 +77,12 @@ SELECT uniq(UserID) FROM table SELECT uniqMerge(state) FROM (SELECT uniqState(UserID) AS state FROM table GROUP BY RegionID) ``` -## 用法示例 {#usage-example} +## 使用示例 {#usage-example} -见 [AggregatingMergeTree](../../engines/table-engines/mergetree-family/aggregatingmergetree.md) 引擎描述。 +参见 [AggregatingMergeTree](../../engines/table-engines/mergetree-family/aggregatingmergetree.md) 引擎描述。 ## 相关内容 {#related-content} -- 博客: [在 ClickHouse 中使用聚合组合子](https://clickhouse.com/blog/aggregate-functions-combinators-in-clickhouse-for-arrays-maps-and-states) -- [MergeState](/sql-reference/aggregate-functions/combinators#-mergestate) 组合子。 -- [State](/sql-reference/aggregate-functions/combinators#-state) 组合子。 +- 博客: [在 ClickHouse 中使用聚合组合器](https://clickhouse.com/blog/aggregate-functions-combinators-in-clickhouse-for-arrays-maps-and-states) +- [MergeState](/sql-reference/aggregate-functions/combinators#-mergestate) 组合器。 +- [State](/sql-reference/aggregate-functions/combinators#-state) 组合器。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/aggregatefunction.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/aggregatefunction.md.hash index 2b63e95eb59..9a5ab910e37 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/aggregatefunction.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/aggregatefunction.md.hash @@ -1 +1 @@ -803a8f4a4bf6b9b3 +0c4ad3c8b8a68817 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/array.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/array.md index 668e8980f15..38701ef3b5e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/array.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/array.md @@ -1,9 +1,10 @@ --- -'description': 'ClickHouse 中 Array 数据类型的文档' +'description': '关于 ClickHouse 中 Array 数据类型的文档' 'sidebar_label': 'Array(T)' 'sidebar_position': 32 'slug': '/sql-reference/data-types/array' 'title': 'Array(T)' +'doc_type': 'reference' --- @@ -19,7 +20,7 @@ array(T) ``` -您还可以使用方括号。 +您也可以使用方括号。 ```sql [] @@ -47,11 +48,11 @@ SELECT [1, 2] AS x, toTypeName(x) └───────┴────────────────────┘ ``` -## 处理数据类型 {#working-with-data-types} +## 使用数据类型 {#working-with-data-types} -在动态创建数组时,ClickHouse 会自动将参数类型定义为能够存储所有列出参数的最小数据类型。如果有任何 [Nullable](/sql-reference/data-types/nullable) 或字面量 [NULL](/operations/settings/formats#input_format_null_as_default) 值,数组元素的类型也会变为 [Nullable](../../sql-reference/data-types/nullable.md)。 +在动态创建数组时,ClickHouse 会自动将参数类型定义为能够存储所有列出参数的最窄数据类型。如果有任何 [Nullable](/sql-reference/data-types/nullable) 或字面量 [NULL](/operations/settings/formats#input_format_null_as_default) 值,数组元素的类型也会变为 [Nullable](../../sql-reference/data-types/nullable.md)。 -如果 ClickHouse 无法确定数据类型,则会产生异常。例如,这种情况发生在尝试同时创建包含字符串和数字的数组时(`SELECT array(1, 'a')`)。 +如果 ClickHouse 无法确定数据类型,它会生成一个异常。例如,当尝试同时创建包含字符串和数字的数组时(`SELECT array(1, 'a')`),会发生这种情况。 自动数据类型检测的示例: @@ -65,7 +66,7 @@ SELECT array(1, 2, NULL) AS x, toTypeName(x) └────────────┴───────────────────────────────┘ ``` -如果您尝试创建不兼容数据类型的数组,ClickHouse 会抛出异常: +如果您尝试创建不兼容的数据类型数组,ClickHouse 将抛出异常: ```sql SELECT array(1, 'a') @@ -78,7 +79,7 @@ Code: 386. DB::Exception: Received from localhost:9000, 127.0.0.1. DB::Exception ## 数组大小 {#array-size} -可以通过使用 `size0` 子列查找数组的大小,而不需读取整个列。对于多维数组,可以使用 `sizeN-1`,其中 `N` 是所需的维度。 +可以使用 `size0` 子列找到数组的大小,而不必读取整个列。对于多维数组,您可以使用 `sizeN-1`,其中 `N` 是所需的维度。 **示例** @@ -100,9 +101,9 @@ SELECT arr.size0, arr.size1, arr.size2 FROM t_arr; └───────────┴───────────┴───────────┘ ``` -## 从数组读取嵌套子列 {#reading-nested-subcolumns-from-array} +## 从数组中读取嵌套子列 {#reading-nested-subcolumns-from-array} -如果 `Array` 中嵌套的类型 `T` 具有子列(例如,如果它是一个 [命名元组](./tuple.md)),您可以按相同的子列名称从 `Array(T)` 类型读取其子列。子列的类型将是原始子列类型的 `Array`。 +如果嵌套类型 `T` 在 `Array` 内部具有子列(例如,如果它是一个 [命名元组](./tuple.md)),您可以使用相同的子列名称从 `Array(T)` 类型中读取它的子列。子列的类型将是原始子列类型的 `Array`。 **示例** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/array.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/array.md.hash index 8072f3b3a9f..538b047b55d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/array.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/array.md.hash @@ -1 +1 @@ -b1b9b1e7797c356d +beaddf5a3f9ce0ff diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/boolean.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/boolean.md index 3ad72393ab4..58a9a288aad 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/boolean.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/boolean.md @@ -4,15 +4,16 @@ 'sidebar_position': 33 'slug': '/sql-reference/data-types/boolean' 'title': 'Bool' +'doc_type': 'reference' --- # Bool -类型 `bool` 在内部存储为 UInt8。可能的值为 `true` (1),`false` (0)。 +类型 `bool` 在内部存储为 UInt8。可能的值为 `true` (1) 和 `false` (0)。 ```sql -select true as col, toTypeName(col); +SELECT true AS col, toTypeName(col); ┌─col──┬─toTypeName(true)─┐ │ true │ Bool │ └──────┴──────────────────┘ diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/boolean.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/boolean.md.hash index d3b718ac8e7..2269ef71d46 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/boolean.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/boolean.md.hash @@ -1 +1 @@ -e9f470160c00fccf +9427f11d0fe86e18 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/data-types-binary-encoding.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/data-types-binary-encoding.md index 193db73c029..fd71e8eedc4 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/data-types-binary-encoding.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/data-types-binary-encoding.md @@ -1,116 +1,121 @@ --- -'description': '数据类型二进制编码规范的文档' +'description': '有关数据类型二进制编码规范的文档' 'sidebar_label': '数据类型二进制编码规范。' 'sidebar_position': 56 'slug': '/sql-reference/data-types/data-types-binary-encoding' 'title': '数据类型二进制编码规范' +'doc_type': 'reference' --- # 数据类型二进制编码规范 -该规范描述了可用于 ClickHouse 数据类型的二进制编码和解码的二进制格式。此格式用于 `Dynamic` 列 [二进制序列化](dynamic.md#binary-output-format),并且可以在相应设置下用于输入/输出格式 [RowBinaryWithNamesAndTypes](../../interfaces/formats.md#rowbinarywithnamesandtypes) 和 [Native](../../interfaces/formats.md#native)。 +此规范描述了可以用于 ClickHouse 数据类型的二进制编码和解码的二进制格式。该格式用于 `Dynamic` 列的 [二进制序列化](dynamic.md#binary-output-format),并可以在相应设置下用于输入/输出格式 [RowBinaryWithNamesAndTypes](../../interfaces/formats.md#rowbinarywithnamesandtypes) 和 [Native](../../interfaces/formats.md#native)。 -下表描述了每种数据类型在二进制格式中的表示方式。每种数据类型编码由 1 个字节组成,指示类型和一些可选的附加信息。二进制编码中的 `var_uint` 表示大小使用可变长度数量压缩编码。 +下表描述了每种数据类型是如何以二进制格式表示的。每种数据类型的编码由 1 字节组成,用于指示类型和一些可选的附加信息。二进制编码中的 `var_uint` 意味着大小使用可变长度数量压缩编码。 -| ClickHouse 数据类型 | 二进制编码 | -|-----------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `Nothing` | `0x00` | -| `UInt8` | `0x01` | -| `UInt16` | `0x02` | -| `UInt32` | `0x03` | -| `UInt64` | `0x04` | -| `UInt128` | `0x05` | -| `UInt256` | `0x06` | -| `Int8` | `0x07` | -| `Int16` | `0x08` | -| `Int32` | `0x09` | -| `Int64` | `0x0A` | -| `Int128` | `0x0B` | -| `Int256` | `0x0C` | -| `Float32` | `0x0D` | -| `Float64` | `0x0E` | -| `Date` | `0x0F` | -| `Date32` | `0x10` | -| `DateTime` | `0x11` | -| `DateTime(time_zone)` | `0x12` | -| `DateTime64(P)` | `0x13` | -| `DateTime64(P, time_zone)` | `0x14` | -| `String` | `0x15` | -| `FixedString(N)` | `0x16` | -| `Enum8` | `0x17...` | -| `Enum16` | `0x18...>` | -| `Decimal32(P, S)` | `0x19` | -| `Decimal64(P, S)` | `0x1A` | -| `Decimal128(P, S)` | `0x1B` | -| `Decimal256(P, S)` | `0x1C` | -| `UUID` | `0x1D` | -| `Array(T)` | `0x1E` | -| `Tuple(T1, ..., TN)` | `0x1F...` | -| `Tuple(name1 T1, ..., nameN TN)` | `0x20...` | -| `Set` | `0x21` | -| `Interval` | `0x22` (见 [interval kind binary encoding](#interval-kind-binary-encoding)) | -| `Nullable(T)` | `0x23` | -| `Function` | `0x24...` | -| `AggregateFunction(function_name(param_1, ..., param_N), arg_T1, ..., arg_TN)` | `0x25......` (见 [aggregate function parameter binary encoding](#aggregate-function-parameter-binary-encoding)) | -| `LowCardinality(T)` | `0x26` | -| `Map(K, V)` | `0x27` | -| `IPv4` | `0x28` | -| `IPv6` | `0x29` | -| `Variant(T1, ..., TN)` | `0x2A...` | -| `Dynamic(max_types=N)` | `0x2B` | -| `Custom type` (`Ring`, `Polygon`, 等) | `0x2C` | -| `Bool` | `0x2D` | -| `SimpleAggregateFunction(function_name(param_1, ..., param_N), arg_T1, ..., arg_TN)` | `0x2E......` (见 [aggregate function parameter binary encoding](#aggregate-function-parameter-binary-encoding)) | -| `Nested(name1 T1, ..., nameN TN)` | `0x2F...` | -| `JSON(max_dynamic_paths=N, max_dynamic_types=M, path Type, SKIP skip_path, SKIP REGEXP skip_path_regexp)` | `0x30.........` | +| ClickHouse 数据类型 | 二进制编码 | +|------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `Nothing` | `0x00` | +| `UInt8` | `0x01` | +| `UInt16` | `0x02` | +| `UInt32` | `0x03` | +| `UInt64` | `0x04` | +| `UInt128` | `0x05` | +| `UInt256` | `0x06` | +| `Int8` | `0x07` | +| `Int16` | `0x08` | +| `Int32` | `0x09` | +| `Int64` | `0x0A` | +| `Int128` | `0x0B` | +| `Int256` | `0x0C` | +| `Float32` | `0x0D` | +| `Float64` | `0x0E` | +| `Date` | `0x0F` | +| `Date32` | `0x10` | +| `DateTime` | `0x11` | +| `DateTime(time_zone)` | `0x12` | +| `DateTime64(P)` | `0x13` | +| `DateTime64(P, time_zone)` | `0x14` | +| `String` | `0x15` | +| `FixedString(N)` | `0x16` | +| `Enum8` | `0x17...` | +| `Enum16` | `0x18...>` | +| `Decimal32(P, S)` | `0x19` | +| `Decimal64(P, S)` | `0x1A` | +| `Decimal128(P, S)` | `0x1B` | +| `Decimal256(P, S)` | `0x1C` | +| `UUID` | `0x1D` | +| `Array(T)` | `0x1E` | +| `Tuple(T1, ..., TN)` | `0x1F...` | +| `Tuple(name1 T1, ..., nameN TN)` | `0x20...` | +| `Set` | `0x21` | +| `Interval` | `0x22` (见 [interval kind binary encoding](#interval-kind-binary-encoding)) | +| `Nullable(T)` | `0x23` | +| `Function` | `0x24...` | +| `AggregateFunction(function_name(param_1, ..., param_N), arg_T1, ..., arg_TN)` | `0x25......` (见 [aggregate function parameter binary encoding](#aggregate-function-parameter-binary-encoding)) | +| `LowCardinality(T)` | `0x26` | +| `Map(K, V)` | `0x27` | +| `IPv4` | `0x28` | +| `IPv6` | `0x29` | +| `Variant(T1, ..., TN)` | `0x2A...` | +| `Dynamic(max_types=N)` | `0x2B` | +| `自定义类型` (`Ring`, `Polygon`, 等) | `0x2C` | +| `Bool` | `0x2D` | +| `SimpleAggregateFunction(function_name(param_1, ..., param_N), arg_T1, ..., arg_TN)` | `0x2E......` (见 [aggregate function parameter binary encoding](#aggregate-function-parameter-binary-encoding)) | +| `Nested(name1 T1, ..., nameN TN)` | `0x2F...` | +| `JSON(max_dynamic_paths=N, max_dynamic_types=M, path Type, SKIP skip_path, SKIP REGEXP skip_path_regexp)` | `0x30.........` | +| `BFloat16` | `0x31` | +| `Time` | `0x32` | +| `Time64(P)` | `0x34` | +| `QBit(T, N)` | `0x36` | -对于类型 `JSON`,字节 `uint8_serialization_version` 指示序列化的版本。目前该版本始终为 0,但如果将来为 `JSON` 类型引入新的参数,则可能会有所更改。 -### 间隔种类的二进制编码 {#interval-kind-binary-encoding} +对于 `JSON` 类型,字节 `uint8_serialization_version` 表示序列化的版本。目前版本始终为 0,但如果将来引入 `JSON` 类型的新参数,则可能会变更。 -下表描述了 `Interval` 数据类型的不同间隔种类是如何编码的。 +### Interval kind binary encoding {#interval-kind-binary-encoding} -| 间隔种类 | 二进制编码 | -|----------------|------------| -| `Nanosecond` | `0x00` | -| `Microsecond` | `0x01` | -| `Millisecond` | `0x02` | -| `Second` | `0x03` | -| `Minute` | `0x04` | -| `Hour` | `0x05` | -| `Day` | `0x06` | -| `Week` | `0x07` | -| `Month` | `0x08` | -| `Quarter` | `0x09` | -| `Year` | `0x1A` | -### Aggregate function parameter binary encoding {#aggregate-function-parameter-binary-encoding} +下表描述了 `Interval` 数据类型的不同区间种类是如何编码的。 -下表描述了 `AggregateFunction` 和 `SimpleAggregateFunction` 的参数是如何编码的。 -参数的编码由 1 个字节表示参数类型和参数值本身组成。 +| 区间种类 | 二进制编码 | +|----------------|--------------| +| `Nanosecond` | `0x00` | +| `Microsecond` | `0x01` | +| `Millisecond` | `0x02` | +| `Second` | `0x03` | +| `Minute` | `0x04` | +| `Hour` | `0x05` | +| `Day` | `0x06` | +| `Week` | `0x07` | +| `Month` | `0x08` | +| `Quarter` | `0x09` | +| `Year` | `0x1A` | +### 聚合函数参数的二进制编码 {#aggregate-function-parameter-binary-encoding} -| 参数类型 | 二进制编码 | -|--------------------------|---------------------------------------------------------------------------------------------------------------------------| -| `Null` | `0x00` | -| `UInt64` | `0x01` | -| `Int64` | `0x02` | -| `UInt128` | `0x03` | -| `Int128` | `0x04` | -| `UInt128` | `0x05` | -| `Int128` | `0x06` | -| `Float64` | `0x07` | -| `Decimal32` | `0x08` | -| `Decimal64` | `0x09` | -| `Decimal128` | `0x0A` | -| `Decimal256` | `0x0B` | -| `String` | `0x0C` | -| `Array` | `0x0D...` | -| `Tuple` | `0x0E...` | -| `Map` | `0x0F...` | -| `IPv4` | `0x10` | -| `IPv6` | `0x11` | -| `UUID` | `0x12` | -| `Bool` | `0x13` | -| `Object` | `0x14...` | -| `AggregateFunctionState` | `0x15` | -| `Negative infinity` | `0xFE` | -| `Positive infinity` | `0xFF` | +下表描述了 `AggregateFunction` 和 `SimpleAggregateFunction` 的参数是如何编码的。参数的编码由 1 字节指示参数的类型和参数值本身组成。 + +| 参数类型 | 二进制编码 | +|-------------------------|-------------------------------------------------------------------------------------------------------------------------------| +| `Null` | `0x00` | +| `UInt64` | `0x01` | +| `Int64` | `0x02` | +| `UInt128` | `0x03` | +| `Int128` | `0x04` | +| `UInt128` | `0x05` | +| `Int128` | `0x06` | +| `Float64` | `0x07` | +| `Decimal32` | `0x08` | +| `Decimal64` | `0x09` | +| `Decimal128` | `0x0A` | +| `Decimal256` | `0x0B` | +| `String` | `0x0C` | +| `Array` | `0x0D...` | +| `Tuple` | `0x0E...` | +| `Map` | `0x0F...` | +| `IPv4` | `0x10` | +| `IPv6` | `0x11` | +| `UUID` | `0x12` | +| `Bool` | `0x13` | +| `Object` | `0x14...` | +| `AggregateFunctionState`| `0x15` | +| `Negative infinity` | `0xFE` | +| `Positive infinity` | `0xFF` | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/data-types-binary-encoding.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/data-types-binary-encoding.md.hash index a2e264b1683..e5af59d3094 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/data-types-binary-encoding.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/data-types-binary-encoding.md.hash @@ -1 +1 @@ -8195df9cd73ef89c +60e1ce71ae684ac4 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/date.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/date.md index 2748704a3c3..855f974b012 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/date.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/date.md @@ -1,23 +1,24 @@ --- -'description': 'ClickHouse 中的 Date 数据类型文档' -'sidebar_label': '日期' +'description': 'ClickHouse 中 Date 数据类型的文档' +'sidebar_label': 'Date' 'sidebar_position': 12 'slug': '/sql-reference/data-types/date' -'title': '日期' +'title': 'Date' +'doc_type': 'reference' --- -# 日期 +# Date -一个日期。以两个字节存储,自1970年1月1日以来的天数(无符号)。允许存储值的范围从Unix纪元开始后不久到在编译阶段定义的常量所定义的上限(目前为2149年,但最终完全支持的年份是2148年)。 +一个日期。以两个字节存储为自1970-01-01以来的天数(无符号)。允许存储从Unix纪元开始后的值到在编译阶段定义的常量所定义的上限(目前,这在2149年之前,但最终完全支持的年份是2148年)。 -支持的值范围:\[1970年1月1日, 2149年6月6日\]。 +支持的值范围:\[1970-01-01, 2149-06-06\]。 -日期值不带时区存储。 +日期值不存储时区。 **示例** -创建一个带有 `Date` 类型列的表并插入数据: +创建一个带有`Date`类型列的表并向其中插入数据: ```sql CREATE TABLE dt diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/date.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/date.md.hash index 505ee67b7e1..f7411f18784 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/date.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/date.md.hash @@ -1 +1 @@ -c0063c51f59a3856 +9d1065775eb0400f diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/date32.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/date32.md index 431e1abe068..e54a601a8ef 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/date32.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/date32.md @@ -1,19 +1,20 @@ --- -'description': 'ClickHouse 中 Date32 数据类型的文档,它存储的日期范围比 Date 更大' +'description': 'ClickHouse 中 Date32 数据类型的文档,它存储的日期范围比 Date 更广泛' 'sidebar_label': 'Date32' 'sidebar_position': 14 'slug': '/sql-reference/data-types/date32' 'title': 'Date32' +'doc_type': 'reference' --- # Date32 -一种日期。支持与 [DateTime64](../../sql-reference/data-types/datetime64.md) 相同的日期范围。以原生字节顺序存储为有符号的32位整数,其值表示自1900-01-01以来的天数(0表示1900-01-01,负值表示1900年前的天数)。 +一种日期。支持与 [DateTime64](../../sql-reference/data-types/datetime64.md) 相同的日期范围。以原生字节顺序存储为有符号32位整数,值表示自 `1900-01-01` 起的天数。**重要!** 0 表示 `1970-01-01`,负值表示在 `1970-01-01` 之前的天数。 **示例** -创建一个具有 `Date32` 类型列的表并插入数据: +创建一个包含 `Date32` 类型列的表并向其中插入数据: ```sql CREATE TABLE dt32 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/date32.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/date32.md.hash index 2dce8008b78..d6451599c52 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/date32.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/date32.md.hash @@ -1 +1 @@ -d1ecc8866ab24eb2 +f395905b148c61d3 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/datetime.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/datetime.md index a6476e6a3b6..5de62fc9237 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/datetime.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/datetime.md @@ -1,15 +1,16 @@ --- -'description': '有关 ClickHouse 中 DateTime 数据类型的文档,它以秒精度存储时间戳' -'sidebar_label': '日期时间' +'description': 'ClickHouse中DateTime数据类型的文档,存储具有秒级精度的时间戳' +'sidebar_label': 'DateTime' 'sidebar_position': 16 'slug': '/sql-reference/data-types/datetime' -'title': '日期时间' +'title': 'DateTime' +'doc_type': 'reference' --- # DateTime -允许存储时间的瞬间,可以表达为日历日期和一天中的时间。 +允许存储一个瞬间,该瞬间可以表示为日历日期和一天中的时间。 语法: @@ -19,33 +20,33 @@ DateTime([timezone]) 支持的值范围:\[1970-01-01 00:00:00, 2106-02-07 06:28:15\]。 -分辨率:1秒。 +分辨率:1 秒。 ## Speed {#speed} -在_大多数_情况下,`Date` 数据类型比 `DateTime` 更快。 +在 _大多数_ 情况下,`Date` 数据类型比 `DateTime` 更快。 -`Date` 类型需要 2 字节存储,而 `DateTime` 需要 4 字节。然而,当数据库压缩数据库时,这种差异会被放大。这种放大是因为 `DateTime` 中的分钟和秒数压缩率较低。过滤和聚合 `Date` 而不是 `DateTime` 也更快。 +`Date` 类型需要 2 字节的存储,而 `DateTime` 需要 4 字节。然而,在压缩过程中,Date 和 DateTime 之间的大小差异变得更加显著。这种放大是因为 `DateTime` 中的分钟和秒更难压缩。对 `Date` 进行过滤和聚合也比对 `DateTime` 更快。 ## Usage Remarks {#usage-remarks} -时间点作为 [Unix 时间戳](https://en.wikipedia.org/wiki/Unix_time) 保存,无论时区或夏令时如何。时区影响 `DateTime` 类型在文本格式中显示的值,以及如何解析作为字符串指定的值(例如:`'2020-01-01 05:00:01'`)。 +时间点作为 [Unix 时间戳](https://en.wikipedia.org/wiki/Unix_time) 存储,不考虑时区或夏令时。时区影响 `DateTime` 类型的值在文本格式中的显示方式,以及作为字符串指定的值如何解析(例如:'2020-01-01 05:00:01')。 -不考虑时区的 Unix 时间戳存储在表中,时区用于在数据导入/导出过程中将其转换为文本格式或反向转换,或对值进行日历计算(例如:`toDate`、`toHour` 函数等)。时区不存储在表的行中(或结果集中),而是存储在列元数据中。 +时间无关的 Unix 时间戳存储在表中,时区用于在数据导入/导出或在值上进行日历计算时将其转换为文本格式或反向转换(示例:`toDate`,`toHour` 函数等)。时区不存储在表的行中(或结果集中),而是存储在列元数据中。 -支持的时区列表可以在 [IANA 时间区数据库](https://www.iana.org/time-zones) 中找到,也可以通过 `SELECT * FROM system.time_zones` 查询。[该列表](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) 在维基百科上也可以找到。 +支持的时区列表可以在 [IANA 时区数据库](https://www.iana.org/time-zones) 中找到,也可以通过 `SELECT * FROM system.time_zones` 查询得到。[该列表](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) 在维基百科上也可以找到。 -创建表时,可以显式为 `DateTime` 类型的列设置时区。示例:`DateTime('UTC')`。如果未设置时区,ClickHouse 在 ClickHouse 服务器启动时使用服务器设置中的 [timezone](../../operations/server-configuration-parameters/settings.md#timezone) 参数值或操作系统设置。 +在创建表时,可以显式设置 `DateTime` 类型列的时区。例如:`DateTime('UTC')`。如果未设置时区,ClickHouse 使用 [timezone](../../operations/server-configuration-parameters/settings.md#timezone) 参数的值,或者在 ClickHouse 服务器启动时使用操作系统设置的值。 -如果在初始化数据类型时未显式设置时区,[clickhouse-client](../../interfaces/cli.md) 默认应用服务器时区。要使用客户端时区,请 使用 `--use_client_time_zone` 参数运行 `clickhouse-client`。 +如果在初始化数据类型时未显式设置时区,则 [clickhouse-client](../../interfaces/cli.md) 默认应用服务器时区。要使用客户端时区,请在运行 `clickhouse-client` 时加上 `--use_client_time_zone` 参数。 -ClickHouse 的输出值取决于 [date_time_output_format](../../operations/settings/settings-formats.md#date_time_output_format) 设置的值。默认情况下为 `YYYY-MM-DD hh:mm:ss` 文本格式。此外,您可以使用 [formatDateTime](../../sql-reference/functions/date-time-functions.md#formatdatetime) 函数更改输出。 +ClickHouse 根据 [date_time_output_format](../../operations/settings/settings-formats.md#date_time_output_format) 设置输出值。默认文本格式为 `YYYY-MM-DD hh:mm:ss`。此外,您还可以通过 [formatDateTime](../../sql-reference/functions/date-time-functions.md#formatDateTime) 函数更改输出格式。 -在将数据插入 ClickHouse 时,可以根据 [date_time_input_format](../../operations/settings/settings-formats.md#date_time_input_format) 设置的值使用不同格式的日期和时间字符串。 +在向 ClickHouse 插入数据时,您可以根据 [date_time_input_format](../../operations/settings/settings-formats.md#date_time_input_format) 设置的值使用不同格式的日期和时间字符串。 ## Examples {#examples} -**1.** 创建一个 `DateTime` 类型列的表并插入数据: +**1.** 创建一个带有 `DateTime` 类型列的表并向其中插入数据: ```sql CREATE TABLE dt @@ -60,22 +61,22 @@ ENGINE = TinyLog; -- Parse DateTime -- - from string, -- - from integer interpreted as number of seconds since 1970-01-01. -INSERT INTO dt VALUES ('2019-01-01 00:00:00', 1), (1546300800, 3); +INSERT INTO dt VALUES ('2019-01-01 00:00:00', 1), (1546300800, 2); SELECT * FROM dt; ``` ```text ┌───────────timestamp─┬─event_id─┐ -│ 2019-01-01 00:00:00 │ 2 │ -│ 2019-01-01 03:00:00 │ 1 │ +│ 2019-01-01 00:00:00 │ 1 │ +│ 2019-01-01 03:00:00 │ 2 │ └─────────────────────┴──────────┘ ``` -- 当以整数形式插入日期时间时,它被视为 Unix 时间戳(UTC)。 `1546300800` 代表 `'2019-01-01 00:00:00'` UTC。然而,由于 `timestamp` 列具有指定的 `Asia/Istanbul` (UTC+3) 时区,作为字符串输出时,值将显示为 `'2019-01-01 03:00:00'`。 -- 当字符串值作为日期时间插入时,它被视为在列时区内。 `'2019-01-01 00:00:00'` 将被视为在 `Asia/Istanbul` 时区并保存为 `1546290000`。 +- 当以整数插入日期时间时,它被视为 Unix 时间戳 (UTC)。 `1546300800` 代表 `'2019-01-01 00:00:00'` UTC。然而,由于 `timestamp` 列具有指定的 `Asia/Istanbul` (UTC+3) 时区,因此以字符串输出时,该值将显示为 `'2019-01-01 03:00:00'`。 +- 当将字符串值插入为日期时间时,它被视为列时区内的值。`'2019-01-01 00:00:00'` 将被视为处于 `Asia/Istanbul` 时区并保存为 `1546290000`。 -**2.** 过滤 `DateTime` 值 +**2.** 基于 `DateTime` 值进行过滤 ```sql SELECT * FROM dt WHERE timestamp = toDateTime('2019-01-01 00:00:00', 'Asia/Istanbul') @@ -87,7 +88,7 @@ SELECT * FROM dt WHERE timestamp = toDateTime('2019-01-01 00:00:00', 'Asia/Istan └─────────────────────┴──────────┘ ``` -`DateTime` 列的值可以使用 `WHERE` 谓词中的字符串值进行过滤。它将被自动转换为 `DateTime`: +`DateTime` 列的值可以使用 `WHERE` 谓词中的字符串值进行过滤。它将自动转换为 `DateTime`: ```sql SELECT * FROM dt WHERE timestamp = '2019-01-01 00:00:00' @@ -115,8 +116,8 @@ SELECT toDateTime(now(), 'Asia/Istanbul') AS column, toTypeName(column) AS x ```sql SELECT -toDateTime(timestamp, 'Europe/London') as lon_time, -toDateTime(timestamp, 'Asia/Istanbul') as mos_time +toDateTime(timestamp, 'Europe/London') AS lon_time, +toDateTime(timestamp, 'Asia/Istanbul') AS mos_time FROM dt ``` @@ -127,38 +128,37 @@ FROM dt └─────────────────────┴─────────────────────┘ ``` -由于时区转换仅更改元数据,该操作没有计算成本。 - +由于时区转换仅更改元数据,因此该操作没有计算成本。 ## Limitations on time zones support {#limitations-on-time-zones-support} -某些时区可能没有完全支持。有几个情况: +有些时区可能不完全支持。以下是几种情况: -如果与 UTC 的偏移量不是 15 分钟的倍数,小时和分钟的计算可能不正确。例如,利比里亚蒙罗维亚的时区在 1972 年 1 月 7 日之前的偏移量为 UTC -0:44:30。如果您在蒙罗维亚时区进行历史时间的计算,时间处理函数可能会给出不正确的结果。然而,1972 年 1 月 7 日之后的结果仍将是正确的。 +如果与 UTC 的偏移量不是 15 分钟的倍数,则小时和分钟的计算可能不正确。例如,利比里亚的蒙罗维亚在 1972 年 1 月 7 日之前的时区偏移为 UTC -0:44:30。如果您在蒙罗维亚时区对历史时间进行计算,时间处理函数可能会给出不正确的结果。然而,1972 年 1 月 7 日之后的结果将是正确的。 -如果由于夏令时或其他原因的时间转换是在一个不是 15 分钟的倍数的时间点执行的,则在这个特定的日子里您也可能得到不正确的结果。 +如果时间转换(由于夏令时或其他原因)在不是 15 分钟倍数的时间点进行,您在该特定日子也可能会得到不正确的结果。 -非单调的日历日期。例如在幸福谷-古斯贝,2010 年 11 月 7 日 00:01:00 时,时间向前调整了一小时(午夜后一分钟)。因此,在 11 月 6 日结束后,人们观察到了整整一分钟的 11 月 7 日,然后时间被调整回 11 月 6 日的 23:01,经过另一个 59 分钟,又开始了 11 月 7 日。 ClickHouse 还不支持这种情况。在这些日子里,时间处理函数的结果可能会略微不正确。 +非单调的日历日期。例如,在快乐谷 - 鳕鱼湾,时间在 2010 年 11 月 7 日 00:01:00 向后转了一小时(午夜后一分钟)。因此,在 11 月 6 日结束后,人们目睹了 11 月 7 日整整一分钟,然后时间回到 11 月 6 日 23:01,在再过 59 分钟后,11 月 7 日再次开始。ClickHouse 目前不支持这种情况。在这些日子里,时间处理函数的结果可能会略有不正确。 -2010 年,凯西南极站也存在类似问题。他们在 3 月 5 日的 02:00 将时间向后调了三个小时。如果您在南极站工作,请不要害怕使用 ClickHouse。只需确保将时区设置为 UTC 或了解不准确性。 +类似的问题出现在 2010 年的凯西南极站。他们在 3 月 5 日 02:00 时将时间回拨了三个小时。如果您在南极站工作,请不要害怕使用 ClickHouse。只需确保将时区设置为 UTC 或了解不准确之处。 -多天的时间偏移变化。一些太平洋岛屿将它们的时区偏移量从 UTC+14 更改为 UTC-12。这没问题,但是在转换日的历史时间点进行计算时可能会出现一些不准确性。 +多天的时间偏移。一些太平洋岛屿将其时区偏移从 UTC+14 更改为 UTC-12。这没问题,但在转换日期的历史时间点计算时,可能会出现一些不准确的情况。 -## Handling Daylight Saving Time (DST) {#handling-daylight-saving-time-dst} +## Handling daylight saving time (DST) {#handling-daylight-saving-time-dst} -ClickHouse 的带时区的 DateTime 类型在夏令时(DST)过渡期间可能会出现意外行为,特别是当: +ClickHouse 的 DateTime 类型与时区在夏令时 (DST) 转换期间可能会表现出意外行为,特别是在以下情况下: - [`date_time_output_format`](../../operations/settings/settings-formats.md#date_time_output_format) 设置为 `simple`。 -- 时钟向后移动("Fall Back"),导致一小时重叠。 -- 时钟向前移动("Spring Forward"),导致一小时间隙。 +- 时钟向后移动(“调回”),造成一小时重叠。 +- 时钟向前移动(“调前”),造成一小时间隔。 -默认情况下,ClickHouse 总是选择重叠时间的较早发生,并可能在向前推进时解析不存在的时间。 +默认情况下,ClickHouse 始终选择重叠时间的较早发生,可能会在向前移动时解释不存在的时间。 -例如,考虑从夏令时(DST)到标准时间的过渡。 +例如,考虑从夏令时 (DST) 转换到标准时间的以下情况。 -- 在 2023 年 10 月 29 日,02:00:00,时钟向后调整到 01:00:00(BST → GMT)。 -- 01:00:00 – 01:59:59 的小时出现了两次(一次在 BST,一次在 GMT)。 -- ClickHouse 总是选择第一个出现(BST),在添加时间间隔时导致意外结果。 +- 在2023年10月29日,在 02:00:00,时钟向后调整到 01:00:00(BST → GMT)。 +- 01:00:00 – 01:59:59 小时出现两次(一次在 BST,一次在 GMT) +- ClickHouse 始终选择第一次出现(BST),因此在添加时间间隔时会导致意外结果。 ```sql SELECT '2023-10-29 01:30:00'::DateTime('Europe/London') AS time, time + toIntervalHour(1) AS one_hour_later @@ -168,12 +168,12 @@ SELECT '2023-10-29 01:30:00'::DateTime('Europe/London') AS time, time + toInterv └─────────────────────┴─────────────────────┘ ``` -类似地,在从标准时间到夏令时的过渡中,可能会跳过一个小时。 +同样,在从标准时间转向夏令时的过程中,可能会有一个小时被跳过。 例如: -- 在 2023 年 3 月 26 日,`00:59:59` 时,时钟跳转到 02:00:00(GMT → BST)。 -- `01:00:00` – `01:59:59` 的小时不存在。 +- 在 2023 年 3 月 26 日的 `00:59:59`,时钟跳转到 02:00:00(GMT → BST)。 +- 01:00:00 – 01:59:59 小时不存在。 ```sql SELECT '2023-03-26 01:30:00'::DateTime('Europe/London') AS time, time + toIntervalHour(1) AS one_hour_later @@ -183,16 +183,16 @@ SELECT '2023-03-26 01:30:00'::DateTime('Europe/London') AS time, time + toInterv └─────────────────────┴─────────────────────┘ ``` -在这种情况下,ClickHouse 将不存在的时间 `2023-03-26 01:30:00` 向后调整为 `2023-03-26 00:30:00`。 +在这种情况下,ClickHouse 将不存在的时间 `2023-03-26 01:30:00` 向后移动到 `2023-03-26 00:30:00`。 ## See Also {#see-also} - [类型转换函数](../../sql-reference/functions/type-conversion-functions.md) - [处理日期和时间的函数](../../sql-reference/functions/date-time-functions.md) - [处理数组的函数](../../sql-reference/functions/array-functions.md) -- [date_time_input_format] 设置](../../operations/settings/settings-formats.md#date_time_input_format) -- [date_time_output_format] 设置](../../operations/settings/settings-formats.md#date_time_output_format) -- [timezone] 服务器配置参数](../../operations/server-configuration-parameters/settings.md#timezone) -- [session_timezone] 设置](../../operations/settings/settings.md#session_timezone) +- [`date_time_input_format` 设置](../../operations/settings/settings-formats.md#date_time_input_format) +- [`date_time_output_format` 设置](../../operations/settings/settings-formats.md#date_time_output_format) +- [`timezone` 服务器配置参数](../../operations/server-configuration-parameters/settings.md#timezone) +- [`session_timezone` 设置](../../operations/settings/settings.md#session_timezone) - [处理日期和时间的运算符](../../sql-reference/operators#operators-for-working-with-dates-and-times) -- [Date 数据类型](../../sql-reference/data-types/date.md) +- [`Date` 数据类型](../../sql-reference/data-types/date.md) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/datetime.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/datetime.md.hash index 36d21b64f35..63ccff0fad9 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/datetime.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/datetime.md.hash @@ -1 +1 @@ -277215a91c6865e3 +ce1bf603ad17f1aa diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/datetime64.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/datetime64.md index a58d143a5e0..5c23d45b981 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/datetime64.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/datetime64.md @@ -1,18 +1,18 @@ --- -'description': 'ClickHouse 中 DateTime64 数据类型的文档,它存储具有亚秒精度的时间戳' +'description': 'ClickHouse 中 DateTime64 数据类型的文档,存储具有亚秒精度的时间戳' 'sidebar_label': 'DateTime64' 'sidebar_position': 18 'slug': '/sql-reference/data-types/datetime64' 'title': 'DateTime64' +'doc_type': 'reference' --- # DateTime64 -允许存储一个时间点,可以表示为日历日期和一天中的时间,并具有定义的亚秒精度 +允许存储一个时间瞬间,可以表示为一个日历日期和一天中的时间,并具有定义的亚秒精度。 -刻度大小(精度):10-precision 秒。有效范围:[0 : 9]。 -通常使用 - 3(毫秒),6(微秒),9(纳秒)。 +滴答大小(精度):10-precision 秒。有效范围:[ 0 : 9 ]。通常使用 - 3(毫秒)、6(微秒)、9(纳秒)。 **语法:** @@ -20,11 +20,13 @@ DateTime64(precision, [timezone]) ``` -内部将数据存储为自纪元开始(1970-01-01 00:00:00 UTC)以来的“刻度”数量,类型为 Int64。刻度分辨率由精度参数决定。此外,`DateTime64` 类型可以存储整个列的时区,这影响了`DateTime64` 类型值以文本格式显示时的方式以及以字符串指定的值如何解析('2020-01-01 05:00:01.000')。时区并不存储在表的行中(或结果集中),而是存储在列元数据中。详细信息请参见 [DateTime](../../sql-reference/data-types/datetime.md)。 +内部将数据存储为自纪元开始(1970-01-01 00:00:00 UTC)以来的'滴答'数,类型为 Int64。滴答分辨率由精度参数确定。此外,`DateTime64` 类型可以存储整个列的时区,这会影响 `DateTime64` 类型值在文本格式上的显示方式以及如何解析作为字符串指定的值(如 '2020-01-01 05:00:01.000')。时区不存储在表的行中(或结果集中),而是存储在列的元数据中。详情请参见 [DateTime](../../sql-reference/data-types/datetime.md)。 支持的值范围:\[1900-01-01 00:00:00, 2299-12-31 23:59:59.99999999\] -注意:最大值的精度为8。如果使用最大精度9位(纳秒),则支持的最大值为 `2262-04-11 23:47:16`(UTC)。 +小数点后的位数取决于精度参数。 + +注意:最大值的精度为 8。如果使用最大精度为 9 位(纳秒),最大支持值为 `2262-04-11 23:47:16`(UTC)。 ## 示例 {#examples} @@ -41,8 +43,9 @@ ENGINE = TinyLog; ```sql -- Parse DateTime --- - from integer interpreted as number of seconds since 1970-01-01. --- - from string, +-- - from integer interpreted as number of microseconds (because of precision 3) since 1970-01-01, +-- - from decimal interpreted as number of seconds before the decimal part, and based on the precision after the decimal point, +-- - from string. INSERT INTO dt64 VALUES (1546300800123, 1), (1546300800.123, 2), ('2019-01-01 00:00:00', 3); SELECT * FROM dt64; @@ -56,10 +59,10 @@ SELECT * FROM dt64; └─────────────────────────┴──────────┘ ``` -- 当将datetime作为整数插入时,它会被视为适当缩放的Unix时间戳(UTC)。`1546300800000` (精度为3)代表 `'2019-01-01 00:00:00'` UTC。然而,由于 `timestamp` 列指定了 `Asia/Istanbul` (UTC+3)时区,因此在作为字符串输出时,该值将显示为 `'2019-01-01 03:00:00'`。将datetime作为小数插入时,将类似于对整数的处理,只不过小数点之前的值是Unix时间戳(包括秒),而小数点之后的值将被视为精度。 -- 当将字符串值作为datetime插入时,它会被视为在列时区内。`'2019-01-01 00:00:00'` 将被视为在 `Asia/Istanbul` 时区,并存储为 `1546290000000`。 +- 当插入日期时间为整数时,将其视为适当缩放的 Unix 时间戳(UTC)。`1546300800000`(精度为 3)表示 `'2019-01-01 00:00:00'` UTC。然而,由于 `timestamp` 列指定了 `Asia/Istanbul`(UTC+3)时区,因此在作为字符串输出时,该值将显示为 `'2019-01-01 03:00:00'`。将日期时间作为小数插入时,将类似于整数处理,除小数点前的值是 Unix 时间戳(包括秒),小数点后的值将视为精度。 +- 当插入字符串值作为日期时间时,它被视为在列时区中。`'2019-01-01 00:00:00'` 将被视为在 `Asia/Istanbul` 时区,并存储为 `1546290000000`。 -2. 筛选 `DateTime64` 值 +2. 过滤 `DateTime64` 值 ```sql SELECT * FROM dt64 WHERE timestamp = toDateTime64('2019-01-01 00:00:00', 3, 'Asia/Istanbul'); @@ -84,7 +87,7 @@ SELECT * FROM dt64 WHERE timestamp = toDateTime64(1546300800.123, 3); └─────────────────────────┴──────────┘ ``` -相对于插入,`toDateTime64` 函数将所有值视为小数变体,因此需要在小数点后给出精度。 +与插入相反,`toDateTime64` 函数将所有值视为小数形式,因此需要在小数点后给出精度。 3. 获取 `DateTime64` 类型值的时区: @@ -102,8 +105,8 @@ SELECT toDateTime64(now(), 3, 'Asia/Istanbul') AS column, toTypeName(column) AS ```sql SELECT -toDateTime64(timestamp, 3, 'Europe/London') as lon_time, -toDateTime64(timestamp, 3, 'Asia/Istanbul') as istanbul_time +toDateTime64(timestamp, 3, 'Europe/London') AS lon_time, +toDateTime64(timestamp, 3, 'Asia/Istanbul') AS istanbul_time FROM dt64; ``` @@ -115,7 +118,7 @@ FROM dt64; └─────────────────────────┴─────────────────────────┘ ``` -**另请参阅** +**另请参见** - [类型转换函数](../../sql-reference/functions/type-conversion-functions.md) - [用于处理日期和时间的函数](../../sql-reference/functions/date-time-functions.md) @@ -123,6 +126,6 @@ FROM dt64; - [`date_time_output_format` 设置](../../operations/settings/settings-formats.md#date_time_output_format) - [`timezone` 服务器配置参数](../../operations/server-configuration-parameters/settings.md#timezone) - [`session_timezone` 设置](../../operations/settings/settings.md#session_timezone) -- [处理日期和时间的操作符](../../sql-reference/operators/index.md#operators-for-working-with-dates-and-times) +- [用于处理日期和时间的操作符](../../sql-reference/operators/index.md#operators-for-working-with-dates-and-times) - [`Date` 数据类型](../../sql-reference/data-types/date.md) - [`DateTime` 数据类型](../../sql-reference/data-types/datetime.md) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/datetime64.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/datetime64.md.hash index 693a8371f42..741fa389b1a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/datetime64.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/datetime64.md.hash @@ -1 +1 @@ -1714697d90724a24 +f62d0fd278889c73 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/decimal.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/decimal.md index 0af977061c6..1c1fd1e7eca 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/decimal.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/decimal.md @@ -1,29 +1,29 @@ --- -'description': 'ClickHouse中Decimal数据类型的文档,它提供了可配置精度的定点算术' +'description': 'ClickHouse 中十进制数据类型的文档,提供了可配置精度的定点算术' 'sidebar_label': 'Decimal' 'sidebar_position': 6 'slug': '/sql-reference/data-types/decimal' -'title': 'Decimal, Decimal(P), Decimal(P, S), Decimal32(S), Decimal64(S), Decimal128(S), - Decimal256(S)' +'title': '十进制,Decimal(P),Decimal(P, S),Decimal32(S),Decimal64(S),Decimal128(S),Decimal256(S)' +'doc_type': 'reference' --- # Decimal, Decimal(P), Decimal(P, S), Decimal32(S), Decimal64(S), Decimal128(S), Decimal256(S) -带符号的定点数,在加、减和乘法操作中保持精度。对于除法,最低有效位将被丢弃(不进行舍入)。 +带符号的定点数在加法、减法和乘法操作中保持精度。对于除法,最不重要的数字被丢弃(不会进行四舍五入)。 ## 参数 {#parameters} -- P - 精度。有效范围:\[ 1 : 76 \]。确定数字可以有多少个十进制位(包括小数部分)。默认情况下,精度为 10。 -- S - 尺度。有效范围:\[ 0 : P \]。确定小数部分可以有多少个十进制位。 +- P - 精度。有效范围:\[ 1 : 76 \]。确定数字可以有多少个十进制数字(包括小数)。默认情况下,精度为 10。 +- S - 小数位数。有效范围:\[ 0 : P \]。确定小数部分可以有多少个十进制数字。 -Decimal(P) 等价于 Decimal(P, 0)。同样,语法 Decimal 等价于 Decimal(10, 0)。 +Decimal(P) 等价于 Decimal(P, 0)。类似地,语法 Decimal 等价于 Decimal(10, 0)。 根据 P 参数值,Decimal(P, S) 是以下的同义词: -- P 从\[ 1 : 9 \] - 对应 Decimal32(S) -- P 从\[ 10 : 18 \] - 对应 Decimal64(S) -- P 从\[ 19 : 38 \] - 对应 Decimal128(S) -- P 从\[ 39 : 76 \] - 对应 Decimal256(S) +- P 从 \[ 1 : 9 \] - 对于 Decimal32(S) +- P 从 \[ 10 : 18 \] - 对于 Decimal64(S) +- P 从 \[ 19 : 38 \] - 对于 Decimal128(S) +- P 从 \[ 39 : 76 \] - 对于 Decimal256(S) ## Decimal 值范围 {#decimal-value-ranges} @@ -37,37 +37,37 @@ Decimal(P) 等价于 Decimal(P, 0)。同样,语法 Decimal 等价于 Decimal(1 ## 内部表示 {#internal-representation} -内部数据表示为正常的带符号整数,具有相应的位宽。可以存储在内存中的实际值范围比上面指定的略大,仅在从字符串转换时检查。 +在内部,数据作为具有相应位宽的正常带符号整数表示。可以存储的真实值范围比上面指定的稍大,只有在从字符串转换时才进行检查。 -因为现代 CPU 不本地支持 128 位和 256 位整数,所以对 Decimal128 和 Decimal256 的操作是模拟的。因此,Decimal128 和 Decimal256 的工作速度明显慢于 Decimal32/Decimal64。 +由于现代 CPU 不支持原生的 128 位和 256 位整数,因此 Decimal128 和 Decimal256 上的操作是模拟的。因此,Decimal128 和 Decimal256 的工作速度显著慢于 Decimal32/Decimal64。 ## 操作和结果类型 {#operations-and-result-type} -对 Decimal 的二元操作将导致更宽的结果类型(不论参数顺序)。 +Decimal 上的二元操作会产生更宽的结果类型(参数顺序无关)。 - `Decimal64(S1) Decimal32(S2) -> Decimal64(S)` - `Decimal128(S1) Decimal32(S2) -> Decimal128(S)` - `Decimal128(S1) Decimal64(S2) -> Decimal128(S)` - `Decimal256(S1) Decimal<32|64|128>(S2) -> Decimal256(S)` -尺度规则: +缩放规则: - 加法、减法:S = max(S1, S2)。 - 乘法:S = S1 + S2。 - 除法:S = S1。 -对于 Decimal 和整数之间的类似操作,结果是与参数大小相同的 Decimal。 +对于 Decimal 和整数之间的类似操作,结果是与参数相同大小的 Decimal。 -Decimal 与 Float32/Float64 之间的操作未定义。如果需要,可以使用 toDecimal32、toDecimal64、toDecimal128 或 toFloat32、toFloat64 内置函数显式转换其中一个参数。请注意,结果将失去精度,类型转换是一个计算上开销较大的操作。 +Decimal 与 Float32/Float64 之间的操作未定义。如果需要,可以使用 toDecimal32、toDecimal64、toDecimal128 或 toFloat32、toFloat64 内置函数显式转换其中一个参数。请记住,结果将失去精度,类型转换是一种计算成本较高的操作。 -一些对 Decimal 的函数返回结果为 Float64(例如,var 或 stddev)。中间计算可能仍然以 Decimal 进行,这可能导致具有相同值的 Float64 和 Decimal 输入之间的结果不同。 +某些 Decimal 函数返回的结果为 Float64(例如,var 或 stddev)。中间计算可能仍会在 Decimal 中执行,这可能导致相同值的 Float64 和 Decimal 输入之间产生不同的结果。 ## 溢出检查 {#overflow-checks} -在对 Decimal 进行计算时,可能会发生整数溢出。小数部分的过多位数将被丢弃(不进行舍入)。整数部分的过多位数将导致异常。 +在 Decimal 上进行计算时,可能会发生整数溢出。过多的小数位将被丢弃(不会进行四舍五入)。整数部分的过多位数将导致异常。 :::warning -对于 Decimal128 和 Decimal256,未实现溢出检查。如果发生溢出,将返回不正确的结果,不会抛出异常。 +Decimal128 和 Decimal256 的溢出检查尚未实现。发生溢出时会返回不正确的结果,而不会抛出异常。 ::: ```sql @@ -96,7 +96,7 @@ SELECT toDecimal32(4.2, 8) AS x, 6 * x DB::Exception: Decimal math overflow. ``` -溢出检查会导致操作减慢。如果知晓溢出不可能,禁用检查是有意义的,使用 `decimal_check_overflow` 设置。禁用检查后,如果发生溢出,则结果将不正确: +溢出检查会导致操作速度变慢。如果已知不可能发生溢出,则可以通过 `decimal_check_overflow` 设置禁用检查。当禁用检查且发生溢出时,结果将不正确: ```sql SET decimal_check_overflow = 0; @@ -109,7 +109,7 @@ SELECT toDecimal32(4.2, 8) AS x, 6 * x └────────────┴──────────────────────────────────┘ ``` -溢出检查不仅发生在算术操作中,还发生在值比较中: +溢出检查不仅在算术操作上发生,也在值比较中发生: ```sql SELECT toDecimal32(1, 8) < 100 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/decimal.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/decimal.md.hash index 8cdced392a0..0ed3c6181ba 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/decimal.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/decimal.md.hash @@ -1 +1 @@ -9f6132c93d875cf1 +32086d6504521c36 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/domains/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/domains/index.md index 5d77bf3804e..fdca863c97f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/domains/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/domains/index.md @@ -1,32 +1,33 @@ --- -'description': '对 ClickHouse 中域类型的概述,这些类型在基础类型的基础上扩展了附加特性' -'sidebar_label': '域' +'description': '在 ClickHouse 中的域类型概述,它们通过附加特性扩展基本类型' +'sidebar_label': 'Domains' 'sidebar_position': 56 'slug': '/sql-reference/data-types/domains/' -'title': '域' +'title': 'Domains' +'doc_type': 'reference' --- # 域 -域是特殊用途的类型,它在现有基本类型上添加了一些额外的功能,但保持底层数据类型的传输和存储格式不变。目前,ClickHouse 不支持用户定义的域。 +域是特殊用途的类型,它在现有基本类型的基础上添加了额外的功能,同时保持底层数据类型的传输和存储格式不变。目前,ClickHouse 不支持用户定义的域。 您可以在任何可以使用相应基本类型的地方使用域,例如: -- 创建一个域类型的列 -- 从域列中读写值 +- 创建域类型的列 +- 从域列读取/写入值 - 如果基本类型可以用作索引,则将其用作索引 - 使用域列的值调用函数 ### 域的额外功能 {#extra-features-of-domains} -- 在 `SHOW CREATE TABLE` 或 `DESCRIBE TABLE` 中显示明确的列类型名称 -- 从人类友好的格式输入 `INSERT INTO domain_table(domain_column) VALUES(...)` -- 输出为人类友好的格式 `SELECT domain_column FROM domain_table` -- 从外部源以人类友好的格式加载数据:`INSERT INTO domain_table FORMAT CSV ...` +- 在 `SHOW CREATE TABLE` 或 `DESCRIBE TABLE` 中明确列类型名称 +- 以人类友好的格式输入: `INSERT INTO domain_table(domain_column) VALUES(...)` +- 为 `SELECT domain_column FROM domain_table` 输出人类友好的格式 +- 以人类友好的格式从外部源加载数据: `INSERT INTO domain_table FORMAT CSV ...` ### 限制 {#limitations} - 不能通过 `ALTER TABLE` 将基本类型的索引列转换为域类型。 -- 从另一个列或表插入数据时,不能隐式地将字符串值转换为域值。 -- 域不会对存储的值添加约束。 +- 在从另一列或表插入数据时,不能将字符串值隐式转换为域值。 +- 域对存储值没有任何约束。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/domains/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/domains/index.md.hash index 19d479998fc..9214cde33ad 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/domains/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/domains/index.md.hash @@ -1 +1 @@ -b5c050340e42f0da +13493d106f3a552b diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/dynamic.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/dynamic.md index b3b6c37e4d4..5eaaf113b80 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/dynamic.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/dynamic.md @@ -1,15 +1,16 @@ --- -'description': 'ClickHouse 中 Dynamic 数据类型的文档,该类型可以在单个列中存储不同类型的值' -'sidebar_label': '动态' +'description': 'ClickHouse 中的 Dynamic 数据类型文档,允许在单个列中存储不同类型的值' +'sidebar_label': 'Dynamic' 'sidebar_position': 62 'slug': '/sql-reference/data-types/dynamic' -'title': '动态' +'title': 'Dynamic' +'doc_type': 'guide' --- # Dynamic -这种类型允许在内部存储任何类型的值,而无需事先知道它们的所有类型。 +这种类型允许在其中存储任何类型的值,而无需事先知道所有类型。 要声明一个 `Dynamic` 类型的列,请使用以下语法: @@ -17,9 +18,9 @@ Dynamic(max_types=N) ``` -其中 `N` 是一个可选参数,范围在 `0` 到 `254` 之间,指示在一个 `Dynamic` 类型的列内,能够作为独立子列存储的不同数据类型数量,该列跨单个存储在单独数据块中的数据(例如,跨 MergeTree 表的单个数据部分)。如果超过此限制,所有具有新类型的值将一起存储在一个特殊的共享数据结构中,以二进制形式存储。`max_types` 的默认值为 `32`。 +其中 `N` 是一个可选参数,范围在 `0` 到 `254` 之间,指示在 `Dynamic` 类型的列中可以存储多少种不同的数据类型作为单独的子列,分布在单个数据块中(例如,对于 MergeTree 表的单个数据部分)。如果超过该限制,所有具有新类型的值将一起存储在一个特殊的共享数据结构中,以二进制形式存储。`max_types` 的默认值为 `32`。 -## Creating Dynamic {#creating-dynamic} +## 创建 Dynamic {#creating-dynamic} 在表列定义中使用 `Dynamic` 类型: @@ -38,10 +39,10 @@ SELECT d, dynamicType(d) FROM test; └───────────────┴────────────────┘ ``` -使用 CAST 从普通列: +通过普通列进行 CAST: ```sql -SELECT 'Hello, World!'::Dynamic as d, dynamicType(d); +SELECT 'Hello, World!'::Dynamic AS d, dynamicType(d); ``` ```text @@ -50,10 +51,10 @@ SELECT 'Hello, World!'::Dynamic as d, dynamicType(d); └───────────────┴────────────────┘ ``` -使用 CAST 从 `Variant` 列: +通过 `Variant` 列进行 CAST: ```sql -SET enable_variant_type = 1, use_variant_as_common_type = 1; +SET use_variant_as_common_type = 1; SELECT multiIf((number % 3) = 0, number, (number % 3) = 1, range(number + 1), NULL)::Dynamic AS d, dynamicType(d) FROM numbers(3) ``` @@ -65,15 +66,11 @@ SELECT multiIf((number % 3) = 0, number, (number % 3) = 1, range(number + 1), NU └───────┴────────────────┘ ``` +## 将 Dynamic 嵌套类型作为子列读取 {#reading-dynamic-nested-types-as-subcolumns} -## Reading Dynamic nested types as subcolumns {#reading-dynamic-nested-types-as-subcolumns} +`Dynamic` 类型支持使用类型名称作为子列从 `Dynamic` 列中读取单个嵌套类型。因此,如果您有列 `d Dynamic`,则可以使用语法 `d.T` 读取任何有效类型 `T` 的子列, 如果 `T` 可以在 `Nullable` 中,则该子列的类型为 `Nullable(T)`,否则则为 `T`。该子列的大小将与原始 `Dynamic` 列相同,并在所有原始 `Dynamic` 列没有类型 `T` 的行中包含 `NULL` 值(或者如果 `T` 不能在 `Nullable` 中,则包含空值)。 -`Dynamic` 类型支持使用类型名称作为子列,从 `Dynamic` 列中读取单个嵌套类型。 -因此,如果您有列 `d Dynamic`,您可以使用语法 `d.T` 来读取任何有效类型 `T` 的子列, -该子列将具有类型 `Nullable(T)`,如果 `T` 可以在 `Nullable` 内部;否则为 `T`。该子列的大小 -将与原始 `Dynamic` 列相同,并且在原始 `Dynamic` 列没有类型 `T` 的所有行中将包含 `NULL` 值(或者如果 `T` 不能在 `Nullable` 内部,则包含空值)。 - -`Dynamic` 子列也可以使用函数 `dynamicElement(dynamic_column, type_name)` 进行读取。 +还可以使用函数 `dynamicElement(dynamic_column, type_name)` 读取 `Dynamic` 子列。 示例: @@ -115,14 +112,14 @@ SELECT d, dynamicType(d), dynamicElement(d, 'String'), dynamicElement(d, 'Int64' └───────────────┴────────────────┴─────────────────────────────┴────────────────────────────┴───────────────────────────────────┴───────────────────────────┴────────────────────────────────────┘ ``` -要知道每行存储的变体,可以使用函数 `dynamicType(dynamic_column)`。它返回每行的值类型名称的 `String`(如果行是 `NULL`,则返回 `'None'`)。 +要知道每一行存储了什么变体,可以使用函数 `dynamicType(dynamic_column)`。它返回每行的值类型名称的 `String`(如果行是 `NULL`,则返回 `'None'`)。 示例: ```sql CREATE TABLE test (d Dynamic) ENGINE = Memory; INSERT INTO test VALUES (NULL), (42), ('Hello, World!'), ([1, 2, 3]); -SELECT dynamicType(d) from test; +SELECT dynamicType(d) FROM test; ``` ```text @@ -134,14 +131,14 @@ SELECT dynamicType(d) from test; └────────────────┘ ``` -## Conversion between Dynamic column and other columns {#conversion-between-dynamic-column-and-other-columns} +## Dynamic 列与其他列之间的转换 {#conversion-between-dynamic-column-and-other-columns} -可以对 `Dynamic` 列进行四种可能的转换。 +可以对 `Dynamic` 列进行 4 种可能的转换。 -### Converting an ordinary column to a Dynamic column {#converting-an-ordinary-column-to-a-dynamic-column} +### 将普通列转换为 Dynamic 列 {#converting-an-ordinary-column-to-a-dynamic-column} ```sql -SELECT 'Hello, World!'::Dynamic as d, dynamicType(d); +SELECT 'Hello, World!'::Dynamic AS d, dynamicType(d); ``` ```text @@ -150,9 +147,9 @@ SELECT 'Hello, World!'::Dynamic as d, dynamicType(d); └───────────────┴────────────────┘ ``` -### Converting a String column to a Dynamic column through parsing {#converting-a-string-column-to-a-dynamic-column-through-parsing} +### 通过解析将字符串列转换为 Dynamic 列 {#converting-a-string-column-to-a-dynamic-column-through-parsing} -要从 `String` 列解析 `Dynamic` 类型值,您可以启用设置 `cast_string_to_dynamic_use_inference`: +要从字符串列解析 `Dynamic` 类型值,您可以启用设置 `cast_string_to_dynamic_use_inference`: ```sql SET cast_string_to_dynamic_use_inference = 1; @@ -165,9 +162,9 @@ SELECT CAST(materialize(map('key1', '42', 'key2', 'true', 'key3', '2020-01-01')) └─────────────────────────────────────────────┴──────────────────────────────────────────────┘ ``` -### Converting a Dynamic column to an ordinary column {#converting-a-dynamic-column-to-an-ordinary-column} +### 将 Dynamic 列转换为普通列 {#converting-a-dynamic-column-to-an-ordinary-column} -可以将 `Dynamic` 列转换为普通列。在这种情况下,所有嵌套类型将被转换为目标类型: +可以将 `Dynamic` 列转换为普通列。在这种情况下,所有嵌套类型都将转换为目标类型: ```sql CREATE TABLE test (d Dynamic) ENGINE = Memory; @@ -185,12 +182,12 @@ SELECT d::Nullable(Float64) FROM test; └──────────────────────────────┘ ``` -### Converting a Variant column to Dynamic column {#converting-a-variant-column-to-dynamic-column} +### 将 Variant 列转换为 Dynamic 列 {#converting-a-variant-column-to-dynamic-column} ```sql CREATE TABLE test (v Variant(UInt64, String, Array(UInt64))) ENGINE = Memory; INSERT INTO test VALUES (NULL), (42), ('String'), ([1, 2, 3]); -SELECT v::Dynamic as d, dynamicType(d) from test; +SELECT v::Dynamic AS d, dynamicType(d) FROM test; ``` ```text @@ -202,9 +199,9 @@ SELECT v::Dynamic as d, dynamicType(d) from test; └─────────┴────────────────┘ ``` -### Converting a Dynamic(max_types=N) column to another Dynamic(max_types=K) {#converting-a-dynamicmax_typesn-column-to-another-dynamicmax_typesk} +### 将 Dynamic(max_types=N) 列转换为另一个 Dynamic(max_types=K) {#converting-a-dynamicmax_typesn-column-to-another-dynamicmax_typesk} -如果 `K >= N`,那么在转换过程中数据不会改变: +如果 `K >= N`,则在转换过程中数据不会改变: ```sql CREATE TABLE test (d Dynamic(max_types=3)) ENGINE = Memory; @@ -222,7 +219,7 @@ SELECT d::Dynamic(max_types=5) as d2, dynamicType(d2) FROM test; └───────┴────────────────┘ ``` -如果 `K < N`,则具有最稀有类型的值将被插入到单个特殊子列中,但仍然可以访问: +如果 `K < N`,则具有最稀有类型的值将被插入到一个单独的特殊子列中,但仍然可以访问: ```text CREATE TABLE test (d Dynamic(max_types=4)) ENGINE = Memory; INSERT INTO test VALUES (NULL), (42), (43), ('42.42'), (true), ([1, 2, 3]); @@ -240,9 +237,9 @@ SELECT d, dynamicType(d), d::Dynamic(max_types=2) as d2, dynamicType(d2), isDyna └─────────┴────────────────┴─────────┴─────────────────┴──────────────────────────────────┘ ``` -函数 `isDynamicElementInSharedData` 对存储在 `Dynamic` 内部特殊共享数据结构中的行返回 `true`,如我们所见,结果列仅包含未存储在共享数据结构中的 2 种类型。 +函数 `isDynamicElementInSharedData` 返回 `true` 的行是存储在 `Dynamic` 内部特殊共享数据结构中的,正如我们所看到的,结果列只包含没有存储在共享数据结构中的 2 种类型。 -如果 `K=0`,所有类型将被插入到单个特殊子列中: +如果 `K=0`,所有类型将插入到单个特殊子列中: ```text CREATE TABLE test (d Dynamic(max_types=4)) ENGINE = Memory; @@ -261,9 +258,9 @@ SELECT d, dynamicType(d), d::Dynamic(max_types=0) as d2, dynamicType(d2), isDyna └─────────┴────────────────┴─────────┴─────────────────┴──────────────────────────────────┘ ``` -## Reading Dynamic type from the data {#reading-dynamic-type-from-the-data} +## 从数据中读取 Dynamic 类型 {#reading-dynamic-type-from-the-data} -所有文本格式(TSV, CSV, CustomSeparated, Values, JSONEachRow 等)支持读取 `Dynamic` 类型。在数据解析过程中,ClickHouse 尝试推断每个值的类型并在插入到 `Dynamic` 列时使用它。 +所有文本格式(TSV、CSV、CustomSeparated、Values、JSONEachRow 等)都支持读取 `Dynamic` 类型。在数据解析过程中,ClickHouse 尝试推断每个值的类型,并在插入到 `Dynamic` 列时使用该类型。 示例: @@ -295,10 +292,9 @@ $$) └───────────────┴────────────────┴───────────────┴──────┴───────┴────────────┴─────────┘ ``` -## Using Dynamic type in functions {#using-dynamic-type-in-functions} +## 在函数中使用 Dynamic 类型 {#using-dynamic-type-in-functions} -大多数函数支持类型为 `Dynamic` 的参数。在这种情况下,该函数将分别在存储在 `Dynamic` 列内部的每种内部数据类型上执行。 -当函数的结果类型依赖于参数类型时,使用 `Dynamic` 参数执行的结果将是 `Dynamic`。当函数的结果类型不依赖于参数类型时,结果将是 `Nullable(T)`,其中 `T` 是该函数的常规结果类型。 +大多数函数支持类型为 `Dynamic` 的参数。在这种情况下,函数将分别在存储在 `Dynamic` 列中的每个内部数据类型上执行。当函数的结果类型依赖于参数类型时,使用 `Dynamic` 参数执行的此类函数的结果将是 `Dynamic`。当函数的结果类型不依赖于参数类型时,结果将是 `Nullable(T)`,其中 `T` 是此函数的常规结果类型。 示例: @@ -441,14 +437,13 @@ SELECT d, d[1] AS res, toTypeName(res), dynamicType(res) FROM test; └───────┴──────┴─────────────────┴──────────────────┘ ``` -如果函数无法在 `Dynamic` 列中的某个类型上执行,将抛出异常: +如果函数无法在 `Dynamic` 列中的某些类型上执行,将抛出异常: ```sql INSERT INTO test VALUES (42), (43), ('str_1'); SELECT d, dynamicType(d) FROM test; ``` - ```text ┌─d─────┬─dynamicType(d)─┐ │ 42 │ Int64 │ @@ -484,7 +479,7 @@ SELECT d, d + 1 AS res, toTypeName(res), dynamicType(res) FROM test WHERE dynami └────┴─────┴─────────────────┴──────────────────┘ ``` -或提取所需类型作为子列: +或者将所需的类型提取为子列: ```sql SELECT d, d.Int64 + 1 AS res, toTypeName(res) FROM test; @@ -503,14 +498,14 @@ SELECT d, d.Int64 + 1 AS res, toTypeName(res) FROM test; └───────┴──────┴─────────────────┘ ``` -## Using Dynamic type in ORDER BY and GROUP BY {#using-dynamic-type-in-order-by-and-group-by} +## 在 ORDER BY 和 GROUP BY 中使用 Dynamic 类型 {#using-dynamic-type-in-order-by-and-group-by} -在 `ORDER BY` 和 `GROUP BY` 期间,`Dynamic` 类型的值与 `Variant` 类型的值的比较方式相同: -操作符 `<` 对于值 `d1`(底层类型为 `T1`)和 `d2`(底层类型为 `T2`)的 `Dynamic` 类型的结果定义如下: -- 如果 `T1 = T2 = T`,结果将是 `d1.T < d2.T`(基础值将被比较)。 -- 如果 `T1 != T2`,结果将是 `T1 < T2`(类型名称将被比较)。 +在 `ORDER BY` 和 `GROUP BY` 中,`Dynamic` 类型的值的比较类似于 `Variant` 类型的值: +`<` 操作符对于具有基础类型 `T1` 的值 `d1` 和具有基础类型 `T2` 的值 `d2` 的结果定义如下: +- 如果 `T1 = T2 = T`,结果将是 `d1.T < d2.T`(将比较基础值)。 +- 如果 `T1 != T2`,结果将是 `T1 < T2`(将比较类型名称)。 -默认情况下,`GROUP BY`/`ORDER BY` 键中不允许使用 `Dynamic` 类型,如果您想使用它,请考虑其特殊比较规则,并启用 `allow_suspicious_types_in_group_by`/`allow_suspicious_types_in_order_by` 设置。 +默认情况下,`Dynamic` 类型不允许在 `GROUP BY`/`ORDER BY` 键中使用,如果您想使用它,请考虑其特殊比较规则,并启用 `allow_suspicious_types_in_group_by`/`allow_suspicious_types_in_order_by` 设置。 示例: ```sql @@ -550,7 +545,7 @@ SELECT d, dynamicType(d) FROM test ORDER BY d SETTINGS allow_suspicious_types_in └─────────┴────────────────┘ ``` -**注意:**具有不同数值类型的动态类型值被视为不同的值,并且不会相互比较,而是比较它们的类型名称。 +**注意:** 不同数字类型的动态类型值被视为不同的值,并且不相互比较,它们的类型名称会进行比较。 示例: @@ -570,7 +565,7 @@ SELECT d, dynamicType(d) FROM test ORDER BY d SETTINGS allow_suspicious_types_in ``` ```sql -SELECT d, dynamicType(d) FROM test GROUP by d SETTINGS allow_suspicious_types_in_group_by=1; +SELECT d, dynamicType(d) FROM test GROUP BY d SETTINGS allow_suspicious_types_in_group_by=1; ``` ```text @@ -582,18 +577,17 @@ SELECT d, dynamicType(d) FROM test GROUP by d SETTINGS allow_suspicious_types_in └─────┴────────────────┘ ``` -**注意:**所描述的比较规则在执行比较函数时并不适用,例如 `<`/`>`/`=` 等,因为 [特殊工作](#using-dynamic-type-in-functions) 的函数具有 `Dynamic` 类型。 +**注意:** 由于 [特定工作](#using-dynamic-type-in-functions) 的函数在执行比较时不适用上述比较规则,例如 `<`/`>`/`=` 和其他函数。 -## Reaching the limit in number of different data types stored inside Dynamic {#reaching-the-limit-in-number-of-different-data-types-stored-inside-dynamic} +## 达到 Dynamic 中存储的不同数据类型数量的限制 {#reaching-the-limit-in-number-of-different-data-types-stored-inside-dynamic} -`Dynamic` 数据类型只能存储有限数量的不同数据类型作为独立子列。默认情况下,这个限制是 `32`,但您可以在类型声明中使用语法 `Dynamic(max_types=N)` 来更改它,其中 N 的范围在 0 到 254 之间(由于实现细节,无法存储超过 254 种不同数据类型作为独立子列)。 -当达到限制时,所有插入到 `Dynamic` 列的新数据类型将插入到一个共享数据结构中,该结构以二进制形式存储具有不同数据类型的值。 +`Dynamic` 数据类型只能存储有限数量的不同数据类型作为单独的子列。默认情况下,此限制为 `32`,但您可以使用语法 `Dynamic(max_types=N)` 在类型声明中更改此值,其中 N 在 `0` 到 `254` 之间(由于实现细节,无法存储超过 `254` 种不同的数据类型作为动态内部的单独子列)。当达到限制时,所有新数据类型插入到 `Dynamic` 列中将插入一个单一的共享数据结构,该结构以二进制形式存储不同数据类型的值。 -让我们看看当达到限制时在不同场景下会发生什么。 +让我们看看在不同场景下达到限制时会发生什么。 -### Reaching the limit during data parsing {#reaching-the-limit-during-data-parsing} +### 在数据解析期间达到限制 {#reaching-the-limit-during-data-parsing} -在从数据解析 `Dynamic` 值的过程中,当当前数据块达到限制时,所有新值将插入到共享数据结构中: +在从数据中解析 `Dynamic` 值时,当当前数据块的限制达到时,所有新值将被插入到共享数据结构中: ```sql SELECT d, dynamicType(d), isDynamicElementInSharedData(d) FROM format(JSONEachRow, 'd Dynamic(max_types=3)', ' @@ -617,17 +611,16 @@ SELECT d, dynamicType(d), isDynamicElementInSharedData(d) FROM format(JSONEachRo └────────────────────────┴────────────────────────────────┴─────────────────────────────────┘ ``` -如我们所见,插入 3 种不同的数据类型 `Int64`、`Array(Int64)` 和 `String` 后,所有新类型均被插入到特殊共享数据结构中。 +正如我们所看到的,在插入 `Int64`、`Array(Int64)` 和 `String` 这三种不同数据类型后,所有新类型都插入到了特殊共享数据结构中。 -### During merges of data parts in MergeTree table engines {#during-merges-of-data-parts-in-mergetree-table-engines} +### 在 MergeTree 表引擎中合并数据部分期间 {#during-merges-of-data-parts-in-mergetree-table-engines} -在 MergeTree 表中合并多个数据部分时,结果数据部分中的 `Dynamic` 列可能达到可以存储在独立子列中的不同数据类型的限制,并且将无法存储所有来自源部分的类型作为子列。 -在这种情况下,ClickHouse 将选择哪些类型在合并后保持为独立子列,哪些类型将插入到共享数据结构中。在大多数情况下,ClickHouse 尝试保留最常见的类型,并将最稀有的类型存储在共享数据结构中,但这取决于具体实现。 +在 MergeTree 表中合并多个数据部分时,结果数据部分中的 `Dynamic` 列可能会达到可以存储的不同数据类型数量的限制,并无法从源部分存储所有类型作为子列。在这种情况下,ClickHouse 会选择在合并后哪些类型将作为单独子列保留,哪些类型将插入到共享数据结构中。在大多数情况下,ClickHouse 会尽量保留最常见的类型,并将最稀有的类型存储在共享数据结构中,但这取决于具体实现。 -让我们看看这样的合并示例。首先,让我们创建一个带有 `Dynamic` 列的表,将不同数据类型的限制设置为 `3`,并插入具有 `5` 种不同类型的值: +让我们看一个这样的合并示例。首先,创建一个包含 `Dynamic` 列的表,将不同数据类型的限制设置为 `3`,并插入具有 `5` 种不同类型的值: ```sql -CREATE TABLE test (id UInt64, d Dynamic(max_types=3)) engine=MergeTree ORDER BY id; +CREATE TABLE test (id UInt64, d Dynamic(max_types=3)) ENGINE=MergeTree ORDER BY id; SYSTEM STOP MERGES test; INSERT INTO test SELECT number, number FROM numbers(5); INSERT INTO test SELECT number, range(number) FROM numbers(4); @@ -636,7 +629,7 @@ INSERT INTO test SELECT number, map(number, number) FROM numbers(2); INSERT INTO test SELECT number, 'str_' || toString(number) FROM numbers(1); ``` -每次插入将创建一个包含单一类型的独立数据部分: +每次插入都会创建一个包含单种类型的单独数据部分: ```sql SELECT count(), dynamicType(d), isDynamicElementInSharedData(d), _part FROM test GROUP BY _part, dynamicType(d), isDynamicElementInSharedData(d) ORDER BY _part, count(); ``` @@ -651,7 +644,7 @@ SELECT count(), dynamicType(d), isDynamicElementInSharedData(d), _part FROM test └─────────┴─────────────────────┴─────────────────────────────────┴───────────┘ ``` -现在,让我们将所有部分合并为一个并看看会发生什么: +现在,让我们将所有部分合并成一个,看看会发生什么: ```sql SYSTEM START MERGES test; @@ -669,9 +662,9 @@ SELECT count(), dynamicType(d), isDynamicElementInSharedData(d), _part FROM test └─────────┴─────────────────────┴─────────────────────────────────┴───────────┘ ``` -如我们所见,ClickHouse 保留了最常见的类型 `UInt64` 和 `Array(UInt64)` 作为子列,并将所有其他类型插入到共享数据中。 +正如我们所看到的,ClickHouse 保留了最常见的类型 `UInt64` 和 `Array(UInt64)` 作为子列,并将所有其他类型插入到共享数据中。 -## JSONExtract functions with Dynamic {#jsonextract-functions-with-dynamic} +## Dynamic 的 JSONExtract 函数 {#jsonextract-functions-with-dynamic} 所有 `JSONExtract*` 函数支持 `Dynamic` 类型: @@ -705,9 +698,9 @@ SELECT JSONExtractKeysAndValues('{"a" : 42, "b" : "Hello", "c" : [1,2,3]}', 'Dyn └────────────────────────────────────────┴───────────────────────────────────────────────────────────────┘ ``` -### Binary output format {#binary-output-format} +### 二进制输出格式 {#binary-output-format} -在 RowBinary 格式中,`Dynamic` 类型的值以以下格式进行序列化: +在 RowBinary 格式中,`Dynamic` 类型的值以以下格式序列化: ```text diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/dynamic.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/dynamic.md.hash index 5d2c138500f..688f0d3bad0 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/dynamic.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/dynamic.md.hash @@ -1 +1 @@ -9320ab9741e11616 +57cfacbef210c667 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/enum.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/enum.md index 3ec12bca11c..c93a7d1aaa6 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/enum.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/enum.md @@ -1,26 +1,27 @@ --- -'description': 'ClickHouse 中 Enum 数据类型的文档,它表示一组命名的常量值' -'sidebar_label': '枚举' +'description': 'ClickHouse 中 Enum 数据类型的文档,表示一组命名常量值' +'sidebar_label': 'Enum' 'sidebar_position': 20 'slug': '/sql-reference/data-types/enum' -'title': '枚举' +'title': 'Enum' +'doc_type': 'reference' --- # Enum -枚举类型,由命名值组成。 +枚举类型由命名值组成。 -命名值可以被声明为 `'string' = integer` 对或仅为 `'string'` 名称。 ClickHouse 仅存储数字,但通过它们的名称支持与这些值的操作。 +命名值可以声明为 `'string' = integer` 对或 `'string'` 名称。 ClickHouse 仅存储数字,但通过其名称支持对值的操作。 ClickHouse 支持: -- 8位 `Enum`。它可以包含最多 256 个值,列举在 `[-128, 127]` 范围内。 -- 16位 `Enum`。它可以包含最多 65536 个值,列举在 `[-32768, 32767]` 范围内。 +- 8位 `Enum`。它最多可以包含 256 个值,枚举范围为 `[-128, 127]`。 +- 16位 `Enum`。它最多可以包含 65536 个值,枚举范围为 `[-32768, 32767]`。 -在插入数据时,ClickHouse 自动选择 `Enum` 的类型。你也可以使用 `Enum8` 或 `Enum16` 类型以确保存储的大小。 +ClickHouse 在插入数据时自动选择 `Enum` 的类型。您也可以使用 `Enum8` 或 `Enum16` 类型来确保存储的大小。 -## 使用示例 {#usage-examples} +## Usage Examples {#usage-examples} 在这里,我们创建一个具有 `Enum8('hello' = 1, 'world' = 2)` 类型列的表: @@ -32,7 +33,7 @@ CREATE TABLE t_enum ENGINE = TinyLog ``` -同样,你可以省略数字。ClickHouse 会自动分配连续的数字。数字默认从 1 开始分配。 +同样,您可以省略数字。 ClickHouse 会自动分配连续的数字。 默认情况下,数字从 1 开始分配。 ```sql CREATE TABLE t_enum @@ -42,7 +43,7 @@ CREATE TABLE t_enum ENGINE = TinyLog ``` -你也可以为第一个名称指定合法的起始数字。 +您还可以为第一个名称指定合法的起始数字。 ```sql CREATE TABLE t_enum @@ -65,7 +66,7 @@ Exception on server: Code: 69. DB::Exception: Value -129 for element 'hello' exceeds range of Enum8. ``` -列 `x` 只能存储在类型定义中列出的值:`'hello'` 或 `'world'`。如果你尝试保存任何其他值,ClickHouse 将引发异常。此 `Enum` 的 8 位大小是自动选择的。 +列 `x` 只能存储类型定义中列出的值:`'hello'` 或 `'world'`。如果您尝试保存任何其他值,ClickHouse 将引发异常。此 `Enum` 的 8 位大小自动选择。 ```sql INSERT INTO t_enum VALUES ('hello'), ('world'), ('hello') @@ -76,7 +77,7 @@ Ok. ``` ```sql -INSERT INTO t_enum values('a') +INSERT INTO t_enum VALUES('a') ``` ```text @@ -84,7 +85,7 @@ Exception on client: Code: 49. DB::Exception: Unknown element 'a' for type Enum('hello' = 1, 'world' = 2) ``` -当你从表中查询数据时,ClickHouse 输出 `Enum` 的字符串值。 +当您查询表中的数据时,ClickHouse 输出 `Enum` 的字符串值。 ```sql SELECT * FROM t_enum @@ -98,7 +99,7 @@ SELECT * FROM t_enum └───────┘ ``` -如果你需要查看行的数字等效值,必须将 `Enum` 值转换为整数类型。 +如果您需要查看行的数字对应值,您必须将 `Enum` 值强制转换为整数类型。 ```sql SELECT CAST(x, 'Int8') FROM t_enum @@ -112,7 +113,7 @@ SELECT CAST(x, 'Int8') FROM t_enum └─────────────────┘ ``` -要在查询中创建 Enum 值,你也需要使用 `CAST`。 +要在查询中创建 `Enum` 值,您还需要使用 `CAST`。 ```sql SELECT toTypeName(CAST('a', 'Enum(\'a\' = 1, \'b\' = 2)')) @@ -124,13 +125,13 @@ SELECT toTypeName(CAST('a', 'Enum(\'a\' = 1, \'b\' = 2)')) └─────────────────────────────────────────────────────┘ ``` -## 一般规则和用法 {#general-rules-and-usage} +## General Rules and Usage {#general-rules-and-usage} -每个值在 `Enum8` 的范围内分配一个数字 `-128 ... 127` 或在 `Enum16` 的范围内 `-32768 ... 32767`。所有字符串和数字必须是不同的。允许使用空字符串。如果该类型在表定义中被指定,数字可以是任意顺序。然而,顺序并不重要。 +每个值在 `Enum8` 的范围 `-128 ... 127` 或 `Enum16` 的范围 `-32768 ... 32767` 内分配一个数字。所有字符串和数字必须不同。允许为空字符串。如果此类型在表定义中指定,则数字可以以任意顺序出现。然而,顺序无关紧要。 -`Enum` 中的字符串或数值都不能为 [NULL](../../sql-reference/syntax.md)。 +`Enum` 中的字符串和值都不能为 [NULL](../../sql-reference/syntax.md)。 -`Enum` 可以包含在 [Nullable](../../sql-reference/data-types/nullable.md) 类型中。因此,如果你使用查询创建一个表 +`Enum` 可以包含在 [Nullable](../../sql-reference/data-types/nullable.md) 类型中。因此,如果您使用查询创建一个表 ```sql CREATE TABLE t_enum_nullable @@ -140,25 +141,26 @@ CREATE TABLE t_enum_nullable ENGINE = TinyLog ``` -它可以存储的不仅是 `'hello'` 和 `'world'`,还可以是 `NULL`。 +它不仅可以存储 `'hello'` 和 `'world'`,还可以存储 `NULL`。 ```sql -INSERT INTO t_enum_nullable Values('hello'),('world'),(NULL) +INSERT INTO t_enum_nullable VALUES('hello'),('world'),(NULL) ``` -在 RAM 中,`Enum` 列与相应数值的 `Int8` 或 `Int16` 以相同方式存储。 +在 RAM 中,`Enum` 列的存储方式与相应数值的 `Int8` 或 `Int16` 相同。 -在以文本形式读取时,ClickHouse 将值解析为字符串并搜索与 `Enum` 值集合对应的字符串。如果未找到,则会抛出异常。在以文本格式读取时,读取字符串并查找相应的数值。如果未找到,则会抛出异常。在以文本形式写入时,将值写入为相应字符串。如果列数据包含垃圾(不是有效集合中的数字),则会抛出异常。在以二进制形式读取和写入时,行为与 Int8 和 Int16 数据类型相同。 -隐式默认值是最低数字的值。 +以文本形式读取时,ClickHouse 将值解析为字符串并搜索与枚举值集中的相应字符串。如果没有找到,将引发异常。在读取文本格式时,字符串被读取,相应的数字值被查找。如果未找到,将抛出异常。 +以文本形式写入时,写入其对应的字符串值。如果列数据包含垃圾(不在有效集合中的数字),则会引发异常。在以二进制形式读取和写入时,工作方式与 Int8 和 Int16 数据类型相同。 +隐式默认值是最低数字值。 -在 `ORDER BY`、`GROUP BY`、`IN`、`DISTINCT` 等操作中,Enums 的行为与相应的数字相同。例如,ORDER BY 对它们进行数字排序。相等和比较运算符在 Enums 上的工作方式与在基础数值上一样。 +在 `ORDER BY`、`GROUP BY`、`IN`、`DISTINCT` 等操作中,枚举的行为与相应数字相同。例如,ORDER BY 按数字排序。相等和比较运算符在枚举上的工作方式与在底层数字值上的工作方式相同。 -Enum 值不能与数字进行比较。Enums 可以与常量字符串进行比较。如果比较的字符串不是 Enum 的有效值,则会抛出异常。支持在左侧是 Enum 而右侧是一组字符串的 IN 运算符。这些字符串是相应 Enum 的值。 +枚举值不能与数字进行比较。枚举可以与常量字符串进行比较。如果比较的字符串不是枚举的有效值,将引发异常。支持将枚举放在左侧,字符串集合放在右侧的 IN 运算符。这些字符串是相应枚举的值。 -大多数数字和字符串操作对 Enum 值并未定义,例如将数字添加到 Enum 或将字符串连接到 Enum。 -然而,Enum 有自然的 `toString` 函数,返回其字符串值。 +大多数数字和字符串操作不适用于枚举值,例如将数字添加到枚举或将字符串连接到枚举。 +但是,枚举具有自然的 `toString` 函数,返回其字符串值。 -Enum 值也可以通过 `toT` 函数转换为数字类型,其中 T 是数字类型。当 T 与枚举的基础数字类型对应时,此转换是零成本的。 -Enum 类型可以通过 ALTER 在不产生成本的情况下更改,只要仅更改值集。使用 ALTER 既可以添加也可以移除 Enum 的成员(移除是安全的,前提是被移除的值从未在表中使用过)。作为一种保护机制,更改先前定义的 Enum 成员的数字值将引发异常。 +枚举值还可以使用 `toT` 函数转换为数值类型,其中 T 是数值类型。当 T 对应于枚举的底层数值类型时,该转换是零成本的。 +如果仅更改值集合,则可以使用 ALTER 无成本地更改枚举类型。可以使用 ALTER 添加和移除枚举成员(移除是安全的,仅当被移除的值从未在表中使用)。作为安全措施,更改先前定义的枚举成员的数值将引发异常。 使用 ALTER,可以将 Enum8 更改为 Enum16,反之亦然,就像将 Int8 更改为 Int16 一样。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/enum.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/enum.md.hash index 3c7d1805bcd..968226878d9 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/enum.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/enum.md.hash @@ -1 +1 @@ -21e38695d3031d86 +db41a82fdf92565f diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/fixedstring.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/fixedstring.md index 578b1b99174..d941ad566eb 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/fixedstring.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/fixedstring.md @@ -1,15 +1,16 @@ --- -'description': 'ClickHouse 中 FixedString 数据类型的文档' +'description': 'ClickHouse中FixedString数据类型的文档' 'sidebar_label': 'FixedString(N)' 'sidebar_position': 10 'slug': '/sql-reference/data-types/fixedstring' 'title': 'FixedString(N)' +'doc_type': 'reference' --- # FixedString(N) -一个长度为 `N` 字节的固定长度字符串(既不是字符也不是代码点)。 +一个固定长度为 `N` 字节的字符串(既不是字符也不是代码点)。 要声明一个 `FixedString` 类型的列,请使用以下语法: @@ -19,45 +20,93 @@ 其中 `N` 是一个自然数。 -当数据的长度恰好为 `N` 字节时,`FixedString` 类型是高效的。在所有其他情况下,它可能会降低效率。 +当数据的长度恰好为 `N` 字节时,`FixedString` 类型是高效的。在所有其他情况下,可能会降低效率。 -可以高效存储在 `FixedString` 类型列中的值示例: +可以高效存储在 `FixedString` 类型列中的值的示例: -- IP 地址的二进制表示(`FixedString(16)` 用于 IPv6)。 +- IP 地址的二进制表示(IPv6 的 `FixedString(16)`)。 - 语言代码(ru_RU, en_US ...)。 - 货币代码(USD, RUB ...)。 -- 哈希的二进制表示(`FixedString(16)` 用于 MD5,`FixedString(32)` 用于 SHA256)。 +- 哈希的二进制表示(MD5 的 `FixedString(16)`,SHA256 的 `FixedString(32)`)。 要存储 UUID 值,请使用 [UUID](../../sql-reference/data-types/uuid.md) 数据类型。 -在插入数据时,ClickHouse: +在插入数据时,ClickHouse 会: -- 如果字符串少于 `N` 字节,则用空字节补充字符串。 -- 如果字符串超过 `N` 字节,则抛出 `Too large value for FixedString(N)` 异常。 +- 如果字符串包含的字节少于 `N` 字节,则用空字节补充字符串。 +- 如果字符串包含的字节超过 `N` 字节,则抛出 `Too large value for FixedString(N)` 异常。 -在选择数据时,ClickHouse 不会移除字符串末尾的空字节。如果使用 `WHERE` 子句,则应手动添加空字节以匹配 `FixedString` 值。以下示例说明了如何使用带有 `FixedString` 的 `WHERE` 子句。 +我们来考虑以下仅包含一个 `FixedString(2)` 列的表: -让我们考虑以下只有单个 `FixedString(2)` 列的表: +```sql -```text -┌─name──┐ -│ b │ -└───────┘ -``` -查询 `SELECT * FROM FixedStringTable WHERE a = 'b'` 不会返回任何数据作为结果。我们应该用空字节来补充过滤模式。 +INSERT INTO FixedStringTable VALUES ('a'), ('ab'), (''); +``` ```sql -SELECT * FROM FixedStringTable -WHERE a = 'b\0' +SELECT + name, + toTypeName(name), + length(name), + empty(name) +FROM FixedStringTable; ``` ```text -┌─a─┐ -│ b │ -└───┘ +┌─name─┬─toTypeName(name)─┬─length(name)─┬─empty(name)─┐ +│ a │ FixedString(2) │ 2 │ 0 │ +│ ab │ FixedString(2) │ 2 │ 0 │ +│ │ FixedString(2) │ 2 │ 1 │ +└──────┴──────────────────┴──────────────┴─────────────┘ ``` -这种行为与 MySQL 的 `CHAR` 类型不同(在 MySQL 中,字符串用空格填充,并且输出时空格会被移除)。 +请注意,`FixedString(N)` 值的长度是常量。即使 `FixedString(N)` 值仅用空字节填充, [length](/sql-reference/functions/array-functions#length) 函数也会返回 `N`,但在这种情况下, [empty](../../sql-reference/functions/string-functions.md#empty) 函数返回 `1`。 + +通过 `WHERE` 子句选择数据时,根据条件的指定不同会返回不同的结果: + +- 如果使用等号运算符 `=` 或 `==` 或 `equals` 函数,ClickHouse _不_ 考虑 `\0` 字符,即查询 `SELECT * FROM FixedStringTable WHERE name = 'a';` 和 `SELECT * FROM FixedStringTable WHERE name = 'a\0';` 返回相同结果。 +- 如果使用 `LIKE` 子句,则 ClickHouse _会_ 考虑 `\0` 字符,因此可能需要在过滤条件中显式指定 `\0` 字符。 + +```sql +SELECT name +FROM FixedStringTable +WHERE name = 'a' +FORMAT JSONStringsEachRow + +{"name":"a\u0000"} + + +SELECT name +FROM FixedStringTable +WHERE name = 'a\0' +FORMAT JSONStringsEachRow -请注意,`FixedString(N)` 值的长度是恒定的。即使 `FixedString(N)` 值仅用空字节填充,[length](/sql-reference/functions/array-functions#length) 函数仍会返回 `N`,但 [empty](../../sql-reference/functions/string-functions.md#empty) 函数在这种情况下会返回 `1`。 +{"name":"a\u0000"} + + +SELECT name +FROM FixedStringTable +WHERE name = 'a' +FORMAT JSONStringsEachRow + +Query id: c32cec28-bb9e-4650-86ce-d74a1694d79e + +{"name":"a\u0000"} + + +SELECT name +FROM FixedStringTable +WHERE name LIKE 'a' +FORMAT JSONStringsEachRow + +0 rows in set. + + +SELECT name +FROM FixedStringTable +WHERE name LIKE 'a\0' +FORMAT JSONStringsEachRow + +{"name":"a\u0000"} +``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/fixedstring.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/fixedstring.md.hash index 08b6d3a9894..6a8cdb6dfd0 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/fixedstring.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/fixedstring.md.hash @@ -1 +1 @@ -e9fa7ddfd9235841 +38c717fa04c5af3d diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/float.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/float.md index 2439ebc008d..0ed6dc1a3a2 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/float.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/float.md @@ -4,10 +4,11 @@ 'sidebar_position': 4 'slug': '/sql-reference/data-types/float' 'title': 'Float32 | Float64 | BFloat16 类型' +'doc_type': 'reference' --- :::note -如果您需要准确的计算,特别是当您处理需要高精度的财务或商业数据时,您应该考虑使用 [Decimal](../data-types/decimal.md)。 +如果您需要精确的计算,尤其是在处理需要高精度的财务或商业数据时,您应该考虑使用 [Decimal](../data-types/decimal.md) 代替。 [浮点数](https://en.wikipedia.org/wiki/IEEE_754) 可能会导致不准确的结果,如下所示: @@ -17,7 +18,7 @@ CREATE TABLE IF NOT EXISTS float_vs_decimal my_float Float64, my_decimal Decimal64(3) ) -Engine=MergeTree +ENGINE=MergeTree ORDER BY tuple(); @@ -46,14 +47,14 @@ ClickHouse 和 C 中的等效类型如下: ClickHouse 中的浮点类型具有以下别名: -- `Float32` — `FLOAT`,`REAL`,`SINGLE`。 -- `Float64` — `DOUBLE`,`DOUBLE PRECISION`。 +- `Float32` — `FLOAT`, `REAL`, `SINGLE`。 +- `Float64` — `DOUBLE`, `DOUBLE PRECISION`。 -创建表时,可以设置浮点数的数值参数(例如 `FLOAT(12)`,`FLOAT(15, 22)`,`DOUBLE(12)`,`DOUBLE(4, 18)`),但 ClickHouse 会忽略这些参数。 +创建表时,可以设置浮点数的数字参数(例如 `FLOAT(12)`,`FLOAT(15, 22)`,`DOUBLE(12)`,`DOUBLE(4, 18)`),但 ClickHouse 会忽略这些参数。 ## 使用浮点数 {#using-floating-point-numbers} -- 使用浮点数进行计算可能会产生舍入误差。 +- 与浮点数的计算可能会产生舍入误差。 @@ -65,13 +66,13 @@ SELECT 1 - 0.9 └─────────────────────┘ ``` -- 计算结果取决于计算方法(处理器类型和计算机系统的架构)。 -- 浮点计算可能会导致如无穷大(`Inf`)和“非数”(`NaN`)这样的数字出现。在处理计算结果时应考虑这一点。 -- 从文本解析浮点数时,结果可能不是最接近的机器可表示的数字。 +- 计算的结果依赖于计算方法(处理器类型和计算机系统架构)。 +- 浮点计算可能会产生如无穷大(`Inf`)和“非数字”(`NaN`)的结果。这在处理计算结果时应该予以考虑。 +- 从文本中解析浮点数时,结果可能不是最近的机器可表示数字。 ## NaN 和 Inf {#nan-and-inf} -与标准 SQL 不同,ClickHouse 支持以下类别的浮点数: +与标准 SQL 相比,ClickHouse 支持以下类别的浮点数: - `Inf` – 无穷大。 @@ -97,7 +98,7 @@ SELECT -0.5 / 0 └─────────────────┘ ``` -- `NaN` — 非数。 +- `NaN` — 非数字。 @@ -109,14 +110,15 @@ SELECT 0 / 0 └──────────────┘ ``` -有关 `NaN` 排序的规则,请参见 [ORDER BY 子句](../../sql-reference/statements/select/order-by.md) 部分。 +有关 `NaN` 排序的规则,请参见[ORDER BY 子句](../../sql-reference/statements/select/order-by.md)。 ## BFloat16 {#bfloat16} -`BFloat16` 是一种 16 位浮点数据类型,具有 8 位指数、符号和 7 位尾数。 -它对于机器学习和人工智能应用非常有用。 +`BFloat16` 是一种 16 位的浮点数据类型,具有 8 位的指数、符号和 7 位的尾数。 +它对机器学习和 AI 应用非常有用。 -ClickHouse 支持在 `Float32` 和 `BFloat16` 之间的转换,可以使用 [`toFloat32()`](../functions/type-conversion-functions.md/#tofloat32) 或 [`toBFloat16`](../functions/type-conversion-functions.md/#tobfloat16) 函数进行转换。 +ClickHouse 支持 `Float32` 和 `BFloat16` 之间的转换, +可以使用 [`toFloat32()`](../functions/type-conversion-functions.md/#tofloat32) 或 [`toBFloat16`](../functions/type-conversion-functions.md/#tobfloat16) 函数来完成。 :::note 大多数其他操作不被支持。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/float.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/float.md.hash index f209cae6f7a..432bb6c298b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/float.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/float.md.hash @@ -1 +1 @@ -d1f6cc288261bb15 +eccd3bc6107e4e09 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/geo.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/geo.md index 0e96a70486c..303cb3770c4 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/geo.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/geo.md @@ -1,19 +1,20 @@ --- -'description': 'ClickHouse 中用于表示地理对象和位置的几何数据类型的文档' +'description': 'ClickHouse中几何数据类型的文档,用于表示地理对象和位置' 'sidebar_label': 'Geo' 'sidebar_position': 54 'slug': '/sql-reference/data-types/geo' 'title': '几何' +'doc_type': 'reference' --- -ClickHouse 支持用于表示地理对象的数据类型——位置、土地等。 +ClickHouse 支持用于表示地理对象的数据类型 — 位置、土地等。 -**另请参阅** +**参见** - [表示简单地理特征](https://en.wikipedia.org/wiki/GeoJSON)。 ## Point {#point} -`Point` 由其 X 和 Y 坐标表示,存储为 [Tuple](tuple.md)([Float64](float.md), [Float64](float.md))。 +`Point` 由其 X 和 Y 坐标表示,存储为一个 [Tuple](tuple.md)([Float64](float.md), [Float64](float.md))。 **示例** @@ -34,7 +35,7 @@ SELECT p, toTypeName(p) FROM geo_point; ## Ring {#ring} -`Ring` 是一个没有孔的简单多边形,存储为一个点的数组:[Array](array.md)([Point](#point))。 +`Ring` 是一个没有孔的简单多边形,存储为点的数组:[Array](array.md)([Point](#point))。 **示例** @@ -55,7 +56,7 @@ SELECT r, toTypeName(r) FROM geo_ring; ## LineString {#linestring} -`LineString` 是一条线,存储为一个点的数组:[Array](array.md)([Point](#point))。 +`LineString` 是一个存储为点数组的线:[Array](array.md)([Point](#point))。 **示例** @@ -76,7 +77,7 @@ SELECT l, toTypeName(l) FROM geo_linestring; ## MultiLineString {#multilinestring} -`MultiLineString` 是多条线,存储为一个 `LineString` 的数组:[Array](array.md)([LineString](#linestring))。 +`MultiLineString` 是多个存储为 `LineString` 数组的线:[Array](array.md)([LineString](#linestring))。 **示例** @@ -97,11 +98,11 @@ SELECT l, toTypeName(l) FROM geo_multilinestring; ## Polygon {#polygon} -`Polygon` 是一个带孔的多边形,存储为一个环的数组:[Array](array.md)([Ring](#ring))。外数组的第一个元素是多边形的外部形状,后续的所有元素都是孔。 +`Polygon` 是一个带孔的多边形,存储为环的数组:[Array](array.md)([Ring](#ring))。外部数组的第一个元素是多边形的外形,后面的所有元素是孔。 **示例** -这是一个带有一个孔的多边形: +这是一个有一个孔的多边形: ```sql CREATE TABLE geo_polygon (pg Polygon) ENGINE = Memory(); @@ -118,11 +119,11 @@ SELECT pg, toTypeName(pg) FROM geo_polygon; ## MultiPolygon {#multipolygon} -`MultiPolygon` 由多个多边形组成,存储为一个多边形的数组:[Array](array.md)([Polygon](#polygon))。 +`MultiPolygon` 由多个多边形组成,存储为多边形的数组:[Array](array.md)([Polygon](#polygon))。 **示例** -这个多边形由两个独立的多边形组成——第一个没有孔,第二个有一个孔: +这个多边形由两个独立的多边形组成 — 第一个没有孔,第二个有一个孔: ```sql CREATE TABLE geo_multipolygon (mpg MultiPolygon) ENGINE = Memory(); @@ -139,4 +140,4 @@ SELECT mpg, toTypeName(mpg) FROM geo_multipolygon; ## 相关内容 {#related-content} -- [在 ClickHouse 中探索大规模的现实世界数据集:100 多年的气象记录](https://clickhouse.com/blog/real-world-data-noaa-climate-data) +- [探索大量真实世界数据集:ClickHouse 中的 100 多年气象记录](https://clickhouse.com/blog/real-world-data-noaa-climate-data) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/geo.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/geo.md.hash index 0fd4025bdb8..2a4d2f4d21c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/geo.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/geo.md.hash @@ -1 +1 @@ -7d8a8a48ed4cb8e8 +af0948200c297bf6 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/index.md index a29cca426ce..76096879d5b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/index.md @@ -1,15 +1,16 @@ --- -'description': 'ClickHouse中的数据类型文档' +'description': 'ClickHouse 中数据类型的文档' 'sidebar_label': '数据类型列表' 'sidebar_position': 1 'slug': '/sql-reference/data-types/' -'title': 'ClickHouse中的数据类型' +'title': 'ClickHouse 中的数据类型' +'doc_type': 'reference' --- -# ClickHouse中的数据类型 +# Data Types in ClickHouse -本节描述了ClickHouse支持的数据类型,例如 [整数](int-uint.md)、[浮点数](float.md) 和 [字符串](string.md)。 +本节描述了 ClickHouse 支持的数据类型,例如 [整数](int-uint.md)、[浮点数](float.md) 和 [字符串](string.md)。 系统表 [system.data_type_families](/operations/system-tables/data_type_families) 提供了所有可用数据类型的概述。 -它还显示了数据类型是否是另一个数据类型的别名,并且其名称是区分大小写的(例如 `bool` 与 `BOOL`)。 +它还显示了一个数据类型是否是另一个数据类型的别名,并且它的名称是区分大小写的(例如 `bool` 与 `BOOL`)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/index.md.hash index 803e5163246..0d41e69bcc8 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/index.md.hash @@ -1 +1 @@ -959891ab58d08da6 +e6d43e8ef48b3529 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/int-uint.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/int-uint.md index ab6ea1d0a54..10cfc0de77c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/int-uint.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/int-uint.md @@ -4,34 +4,35 @@ 'sidebar_position': 2 'slug': '/sql-reference/data-types/int-uint' 'title': 'Int | UInt 类型' +'doc_type': 'reference' --- -ClickHouse 提供了一系列固定长度的整数,带符号(`Int`)或无符号(unsigned `UInt`),范围从一个字节到 32 字节。 +ClickHouse 提供了多种固定长度的整数,带符号(`Int`)或无符号(unsigned `UInt`),范围从一个字节到 32 字节。 -在创建表时,可以设置整数数字的数值参数(例如 `TINYINT(8)`、`SMALLINT(16)`、`INT(32)`、`BIGINT(64)`),但 ClickHouse 会忽略它们。 +在创建表时,可以设置整数的数值参数(例如 `TINYINT(8)`、`SMALLINT(16)`、`INT(32)`、`BIGINT(64)`),但 ClickHouse 会忽略这些参数。 ## 整数范围 {#integer-ranges} 整数类型具有以下范围: -| 类型 | 范围 | -|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `Int8` | \[-128 : 127\] | -| `Int16` | \[-32768 : 32767\] | -| `Int32` | \[-2147483648 : 2147483647\] | -| `Int64` | \[-9223372036854775808 : 9223372036854775807\] | -| `Int128` | \[-170141183460469231731687303715884105728 : 170141183460469231731687303715884105727\] | +| 类型 | 范围 | +|----------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `Int8` | \[-128 : 127\] | +| `Int16` | \[-32768 : 32767\] | +| `Int32` | \[-2147483648 : 2147483647\] | +| `Int64` | \[-9223372036854775808 : 9223372036854775807\] | +| `Int128` | \[-170141183460469231731687303715884105728 : 170141183460469231731687303715884105727\] | | `Int256` | \[-57896044618658097711785492504343953926634992332820282019728792003956564819968 : 57896044618658097711785492504343953926634992332820282019728792003956564819967\] | 无符号整数类型具有以下范围: -| 类型 | 范围 | -|-----------|----------------------------------------------------------------------------------------| -| `UInt8` | \[0 : 255\] | -| `UInt16` | \[0 : 65535\] | -| `UInt32` | \[0 : 4294967295\] | -| `UInt64` | \[0 : 18446744073709551615\] | -| `UInt128` | \[0 : 340282366920938463463374607431768211455\] | +| 类型 | 范围 | +|-----------|-----------------------------------------------------------------------------------------| +| `UInt8` | \[0 : 255\] | +| `UInt16` | \[0 : 65535\] | +| `UInt32` | \[0 : 4294967295\] | +| `UInt64` | \[0 : 18446744073709551615\] | +| `UInt128` | \[0 : 340282366920938463463374607431768211455\] | | `UInt256` | \[0 : 115792089237316195423570985008687907853269984665640564039457584007913129639935\] | ## 整数别名 {#integer-aliases} diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/int-uint.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/int-uint.md.hash index 450e0750409..8fa37db733a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/int-uint.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/int-uint.md.hash @@ -1 +1 @@ -e3311fe92b425699 +263052daf1ea58be diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/ipv4.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/ipv4.md index 986480af263..4af5681f175 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/ipv4.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/ipv4.md @@ -4,11 +4,12 @@ 'sidebar_position': 28 'slug': '/sql-reference/data-types/ipv4' 'title': 'IPv4' +'doc_type': 'reference' --- ## IPv4 {#ipv4} -IPv4 地址。以 UInt32 的形式存储在 4 字节中。 +IPv4 地址。以 UInt32 的形式存储在 4 个字节中。 ### 基本用法 {#basic-usage} @@ -25,13 +26,13 @@ DESCRIBE TABLE hits; └──────┴────────┴──────────────┴────────────────────┴─────────┴──────────────────┘ ``` -或者可以将 IPv4 域作为键: +或者,您可以使用 IPv4 域作为键: ```sql CREATE TABLE hits (url String, from IPv4) ENGINE = MergeTree() ORDER BY from; ``` -`IPv4` 域支持自定义输入格式,如 IPv4 字符串: +`IPv4` 域支持自定义输入格式作为 IPv4 字符串: ```sql INSERT INTO hits (url, from) VALUES ('https://wikipedia.org', '116.253.40.133')('https://clickhouse.com', '183.247.232.58')('https://clickhouse.com/docs/en/', '116.106.34.242'); @@ -71,6 +72,6 @@ SELECT toIPv4('127.0.0.1') = toIPv6('::ffff:127.0.0.1'); └─────────────────────────────────────────────────────────┘ ``` -**另见** +**另请参见** - [处理 IPv4 和 IPv6 地址的函数](../functions/ip-address-functions.md) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/ipv4.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/ipv4.md.hash index ed58571a047..4639f78d498 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/ipv4.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/ipv4.md.hash @@ -1 +1 @@ -14e31dadc5f57e06 +593aecad73e78998 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/ipv6.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/ipv6.md index 5dc98a96677..4742a5f6f6b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/ipv6.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/ipv6.md @@ -1,14 +1,15 @@ --- -'description': 'ClickHouse 中 IPv6 数据类型的文档,用于将 IPv6 地址存储为 16 字节值' +'description': 'ClickHouse 中 IPv6 数据类型的文档,存储 IPv6 地址为 16 字节值' 'sidebar_label': 'IPv6' 'sidebar_position': 30 'slug': '/sql-reference/data-types/ipv6' 'title': 'IPv6' +'doc_type': 'reference' --- ## IPv6 {#ipv6} -IPv6 地址。以 UInt128 大端格式存储,占用 16 字节。 +IPv6 地址。以 UInt128 大端格式存储在 16 字节中。 ### 基本用法 {#basic-usage} @@ -59,7 +60,7 @@ SELECT toTypeName(from), hex(from) FROM hits LIMIT 1; └──────────────────┴──────────────────────────────────┘ ``` -IPv6 地址可以直接与 IPv4 地址进行比较: +IPv6 地址可以直接与 IPv4 地址比较: ```sql SELECT toIPv4('127.0.0.1') = toIPv6('::ffff:127.0.0.1'); diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/ipv6.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/ipv6.md.hash index 17a21d1875d..2f2e9676bb2 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/ipv6.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/ipv6.md.hash @@ -1 +1 @@ -ef6129c708e58012 +9643e8af27ce0d7a diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/json.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/json.md index c998f86bd47..468ed937107 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/json.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/json.md @@ -1,34 +1,35 @@ --- -'description': 'ClickHouse 中已弃用的 Object 数据类型的文档' +'description': '关于 ClickHouse 中已弃用的 Object 数据类型的文档' 'keywords': - 'object' - 'data type' -'sidebar_label': '对象数据类型' +'sidebar_label': 'Object' 'sidebar_position': 26 'slug': '/sql-reference/data-types/object-data-type' -'title': '对象数据类型' +'title': 'Object' +'doc_type': 'reference' --- import DeprecatedBadge from '@theme/badges/DeprecatedBadge'; -# Object Data Type +# 对象数据类型 -**此功能尚未准备好用于生产并已被弃用。** 如果您需要处理 JSON 文档,请考虑使用 [此指南](/integrations/data-formats/json/overview)。新的 JSON 对象支持实现正在测试中。更多详情请见 [此处](/sql-reference/data-types/newjson)。 +**此功能尚未准备好投入生产并已被弃用。** 如果您需要处理 JSON 文档,请考虑使用 [本指南](/integrations/data-formats/json/overview)。支持 JSON 对象的新实现处于测试阶段。更多详情请见 [这里](/sql-reference/data-types/newjson)。
-在单列中存储 JavaScript 对象表示法 (JSON) 文档。 +将 JavaScript 对象表示法 (JSON) 文档存储在单个列中。 -`JSON` 可以在设置 [use_json_alias_for_old_object_type](/operations/settings/settings#use_json_alias_for_old_object_type) 时用作 `Object('json')` 的别名。 +当启用 [use_json_alias_for_old_object_type](/operations/settings/settings#use_json_alias_for_old_object_type) 时,`JSON` 可以作为 `Object('json')` 的别名。 ## 示例 {#example} **示例 1** -创建一个带有 `JSON` 列的表并向其中插入数据: +创建一个包含 `JSON` 列的表并插入数据: ```sql CREATE TABLE json @@ -54,7 +55,7 @@ SELECT o.a, o.b.c, o.b.d[3] FROM json **示例 2** -为了能够创建有序的 `MergeTree` 家族表,必须将排序键提取到其列中。例如,要以 JSON 格式插入压缩的 HTTP 访问日志文件: +为了能够创建一个有序的 `MergeTree` 家族表,排序键必须提取到其列中。例如,要插入一个以 JSON 格式压缩的 HTTP 访问日志文件: ```sql CREATE TABLE logs @@ -74,7 +75,7 @@ FROM file('access.json.gz', JSONAsString) ## 显示 JSON 列 {#displaying-json-columns} -当显示 `JSON` 列时,ClickHouse 默认只显示字段值(因为在内部,它被表示为元组)。您还可以通过设置 `output_format_json_named_tuples_as_objects = 1` 来显示字段名称: +在显示 `JSON` 列时,ClickHouse 默认只显示字段值(因为它在内部表示为元组)。您也可以通过设置 `output_format_json_named_tuples_as_objects = 1` 来显示字段名称: ```sql SET output_format_json_named_tuples_as_objects = 1 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/json.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/json.md.hash index 3d4a4e97a75..3ff3ca0b717 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/json.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/json.md.hash @@ -1 +1 @@ -2fb1882fbe740c60 +3142804f19a8e5c7 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/lowcardinality.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/lowcardinality.md index cbdd92385cf..492a117ccdb 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/lowcardinality.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/lowcardinality.md @@ -1,9 +1,10 @@ --- -'description': '针对字符串列的 LowCardinality 优化的 Documentation' +'description': 'LowCardinality 优化用于字符串列的文档' 'sidebar_label': 'LowCardinality(T)' 'sidebar_position': 42 'slug': '/sql-reference/data-types/lowcardinality' 'title': 'LowCardinality(T)' +'doc_type': 'reference' --- @@ -11,7 +12,7 @@ 将其他数据类型的内部表示更改为字典编码。 -## 语法 {#syntax} +## Syntax {#syntax} ```sql LowCardinality(data_type) @@ -19,15 +20,15 @@ LowCardinality(data_type) **参数** -- `data_type` — [String](../../sql-reference/data-types/string.md)、[FixedString](../../sql-reference/data-types/fixedstring.md)、[Date](../../sql-reference/data-types/date.md)、[DateTime](../../sql-reference/data-types/datetime.md)和除 [Decimal](../../sql-reference/data-types/decimal.md) 之外的数字。对于某些数据类型,`LowCardinality` 并不高效,详见 [allow_suspicious_low_cardinality_types](../../operations/settings/settings.md#allow_suspicious_low_cardinality_types) 设置描述。 +- `data_type` — [String](../../sql-reference/data-types/string.md)、[FixedString](../../sql-reference/data-types/fixedstring.md)、[Date](../../sql-reference/data-types/date.md)、[DateTime](../../sql-reference/data-types/datetime.md) 和除 [Decimal](../../sql-reference/data-types/decimal.md) 之外的数字。对某些数据类型,`LowCardinality` 并不高效,请参阅 [allow_suspicious_low_cardinality_types](../../operations/settings/settings.md#allow_suspicious_low_cardinality_types) 设置的说明。 ## 描述 {#description} -`LowCardinality` 是一种超结构,改变了数据存储方式和数据处理规则。ClickHouse 对 `LowCardinality` 列应用 [字典编码](https://en.wikipedia.org/wiki/Dictionary_coder)。对字典编码数据的操作显著提高了许多应用中 [SELECT](../../sql-reference/statements/select/index.md) 查询的性能。 +`LowCardinality` 是一种超级结构,改变了数据存储方法和数据处理规则。ClickHouse 在 `LowCardinality` 列上应用 [字典编码](https://en.wikipedia.org/wiki/Dictionary_coder)。使用字典编码的数据进行操作显著提高了许多应用程序的 [SELECT](../../sql-reference/statements/select/index.md) 查询性能。 -使用 `LowCardinality` 数据类型的效率取决于数据的多样性。如果字典包含少于 10,000 个不同值,则 ClickHouse 在数据读取和存储方面通常表现出更高的效率。如果字典包含超过 100,000 个不同值,则 ClickHouse 与使用普通数据类型相比,性能可能下降。 +使用 `LowCardinality` 数据类型的效率依赖于数据的多样性。如果字典中包含少于 10,000 个不同值,则 ClickHouse 在数据读取和存储方面通常显示出更高的效率。如果字典中包含超过 100,000 个不同值,则 ClickHouse 在使用普通数据类型时表现可能会更差。 -在处理字符串时,考虑使用 `LowCardinality` 代替 [Enum](../../sql-reference/data-types/enum.md)。`LowCardinality` 提供了更大的灵活性,通常能展现相同或更高的效率。 +在处理字符串时,考虑使用 `LowCardinality` 代替 [Enum](../../sql-reference/data-types/enum.md)。`LowCardinality` 提供了更多的使用灵活性,并且通常表现出相同或更高的效率。 ## 示例 {#example} @@ -59,6 +60,6 @@ ORDER BY id ## 相关内容 {#related-content} -- 博客: [使用模式和编码优化 ClickHouse](https://clickhouse.com/blog/optimize-clickhouse-codecs-compression-schema) -- 博客: [在 ClickHouse 中处理时间序列数据](https://clickhouse.com/blog/working-with-time-series-data-and-functions-ClickHouse) +- 博客:[使用模式和编解码优化 ClickHouse](https://clickhouse.com/blog/optimize-clickhouse-codecs-compression-schema) +- 博客:[在 ClickHouse 中处理时间序列数据](https://clickhouse.com/blog/working-with-time-series-data-and-functions-ClickHouse) - [字符串优化(俄语视频演示)](https://youtu.be/rqf-ILRgBdY?list=PL0Z2YDlm0b3iwXCpEFiOOYmwXzVmjJfEt)。 [英文幻灯片](https://github.com/ClickHouse/clickhouse-presentations/raw/master/meetup19/string_optimization.pdf) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/lowcardinality.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/lowcardinality.md.hash index a7ae624deda..ff6710748dc 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/lowcardinality.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/lowcardinality.md.hash @@ -1 +1 @@ -2f48abad0d20e2f9 +8d28c82d3e1d96ab diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/map.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/map.md index d0a6ef1dcd6..8c07c437c9a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/map.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/map.md @@ -4,6 +4,7 @@ 'sidebar_position': 36 'slug': '/sql-reference/data-types/map' 'title': 'Map(K, V)' +'doc_type': 'reference' --- @@ -11,15 +12,15 @@ 数据类型 `Map(K, V)` 存储键值对。 -与其他数据库不同,ClickHouse 中的映射并不是唯一的,即一个映射可以包含两个具有相同键的元素。 -(这是因为映射在内部实现为 `Array(Tuple(K, V))`。) +与其他数据库不同,ClickHouse 中的映射不是唯一的,即一个映射可以包含两个具有相同键的元素。 +(原因是映射在内部实现为 `Array(Tuple(K, V))`。) 您可以使用语法 `m[k]` 获取映射 `m` 中键 `k` 的值。 -此外,`m[k]` 会扫描映射,即操作的运行时间与映射的大小成线性关系。 +此外,`m[k]` 会扫描该映射,即该操作的运行时间与映射的大小成线性关系。 **参数** -- `K` — 映射键的类型。任意类型,除了 [Nullable](../../sql-reference/data-types/nullable.md) 和 [LowCardinality](../../sql-reference/data-types/lowcardinality.md) 嵌套的 [Nullable](../../sql-reference/data-types/nullable.md) 类型。 +- `K` — 映射键的类型。任意类型,但不能是 [Nullable](../../sql-reference/data-types/nullable.md) 和 [LowCardinality](../../sql-reference/data-types/lowcardinality.md) 嵌套于 [Nullable](../../sql-reference/data-types/nullable.md) 类型。 - `V` — 映射值的类型。任意类型。 **示例** @@ -47,8 +48,8 @@ SELECT m['key2'] FROM tab; └─────────────────────────┘ ``` -如果请求的键 `k` 不存在于映射中,`m[k]` 将返回值类型的默认值,例如,对于整数类型返回 `0`,对于字符串类型返回 `''`。 -要检查映射中是否存在某个键,可以使用函数 [mapContains](../../sql-reference/functions/tuple-map-functions#mapcontains)。 +如果请求的键 `k` 不在映射中,`m[k]` 返回值类型的默认值,例如,整数类型返回 `0`,字符串类型返回 `''`。 +要检查键是否存在于映射中,可以使用函数 [mapContains](../../sql-reference/functions/tuple-map-functions#mapcontains)。 ```sql CREATE TABLE tab (m Map(String, UInt64)) ENGINE=Memory; @@ -67,7 +68,7 @@ SELECT m['key1'] FROM tab; ## 将元组转换为映射 {#converting-tuple-to-map} -类型为 `Tuple()` 的值可以使用函数 [CAST](/sql-reference/functions/type-conversion-functions#cast) 转换为类型为 `Map()` 的值: +类型为 `Tuple()` 的值可以通过函数 [CAST](/sql-reference/functions/type-conversion-functions#cast) 转换为类型为 `Map()` 的值: **示例** @@ -87,7 +88,7 @@ SELECT CAST(([1, 2, 3], ['Ready', 'Steady', 'Go']), 'Map(UInt8, String)') AS map ## 读取映射的子列 {#reading-subcolumns-of-map} -为了避免读取整个映射,在某些情况下可以使用子列 `keys` 和 `values`。 +为避免读取整个映射,您可以在某些情况下使用子列 `keys` 和 `values`。 **示例** @@ -117,9 +118,8 @@ SELECT m.values FROM tab; -- same as mapValues(m) - [map()](/sql-reference/functions/tuple-map-functions#map) 函数 - [CAST()](/sql-reference/functions/type-conversion-functions#cast) 函数 -- [-Map 组合器用于映射数据类型](../aggregate-functions/combinators.md#-map) - +- [-Map组合器用于Map数据类型](../aggregate-functions/combinators.md#-map) ## 相关内容 {#related-content} -- 博客: [使用 ClickHouse 构建可观察性解决方案 - 第 2 部分 - 跟踪](https://clickhouse.com/blog/storing-traces-and-spans-open-telemetry-in-clickhouse) +- 博客: [使用ClickHouse构建可观察性解决方案 - 第2部分 - 跟踪](https://clickhouse.com/blog/storing-traces-and-spans-open-telemetry-in-clickhouse) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/map.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/map.md.hash index f1bf7d5103b..eca20199805 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/map.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/map.md.hash @@ -1 +1 @@ -362ea4f82b8b7193 +87ac94aa48c33060 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/nested-data-structures/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/nested-data-structures/index.md index 8636991f472..11fef776ae2 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/nested-data-structures/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/nested-data-structures/index.md @@ -3,7 +3,8 @@ 'sidebar_label': 'Nested(Name1 Type1, Name2 Type2, ...)' 'sidebar_position': 57 'slug': '/sql-reference/data-types/nested-data-structures/nested' -'title': '嵌套' +'title': 'Nested' +'doc_type': 'guide' --- @@ -11,7 +12,7 @@ ## Nested(name1 Type1, Name2 Type2, ...) {#nestedname1-type1-name2-type2-} -嵌套数据结构就像是单元格内的一个表。嵌套数据结构的参数——列名和类型——以与 [CREATE TABLE](../../../sql-reference/statements/create/table.md) 查询中相同的方式指定。每个表行可以对应嵌套数据结构中的任意数量行。 +嵌套数据结构就像一个单元格内部的表。嵌套数据结构的参数——列名称和类型——与 [CREATE TABLE](../../../sql-reference/statements/create/table.md) 查询中指定的方式相同。每个表行可以对应于嵌套数据结构中的任意数量的行。 示例: @@ -38,11 +39,11 @@ CREATE TABLE test.visits ) ENGINE = CollapsingMergeTree(StartDate, intHash32(UserID), (CounterID, StartDate, intHash32(UserID), VisitID), 8192, Sign) ``` -此示例声明了 `Goals` 嵌套数据结构,该结构包含有关转化(达成的目标)的数据。'visits' 表中的每一行可以对应零个或任意数量的转化。 +此示例声明了 `Goals` 嵌套数据结构,它包含有关转换(达到目标)的数据。“visits” 表中的每一行可以对应于零个或任意数量的转换。 -当 [flatten_nested](/operations/settings/settings#flatten_nested) 设置为 `0` (默认情况下不是这样),支持任意层级的嵌套。 +当 [flatten_nested](/operations/settings/settings#flatten_nested) 设置为 `0`(默认情况下不是)时,支持任意级别的嵌套。 -在大多数情况下,处理嵌套数据结构时,其列以点号分隔的列名指定。这些列构成了相同类型的数组。单个嵌套数据结构的所有列数组具有相同的长度。 +在大多数情况下,在处理嵌套数据结构时,其列通过点分隔的列名称进行指定。这些列组成一个匹配类型的数组。单个嵌套数据结构的所有列数组具有相同的长度。 示例: @@ -70,9 +71,9 @@ LIMIT 10 └────────────────────────────────┴───────────────────────────────────────────────────────────────────────────────────────────┘ ``` -想象嵌套数据结构为多个同长度列数组的集合是最简单的。 +将嵌套数据结构视为一组相同长度的多个列数组是最简单的方式。 -SELECT 查询中唯一可以指定整个嵌套数据结构名称而不是单独列的地方是 ARRAY JOIN 子句。有关更多信息,请参见“ARRAY JOIN 子句”。示例: +SELECT 查询唯一可以指定整个嵌套数据结构名称而不是单个列的地方是 ARRAY JOIN 子句。有关更多信息,请参见“ARRAY JOIN 子句”。示例: ```sql SELECT @@ -99,10 +100,10 @@ LIMIT 10 └─────────┴─────────────────────┘ ``` -您不能对整个嵌套数据结构执行 SELECT。您只能显式列出其组成的单独列。 +您不能针对整个嵌套数据结构执行 SELECT。您只能明确列出它的单个列。 -对于 INSERT 查询,您应该将嵌套数据结构的所有组件列数组单独传递(就像它们是单独的列数组一样)。在插入过程中,系统会检查它们的长度是否相同。 +对于 INSERT 查询,您应单独传递嵌套数据结构的所有组件列数组(就像它们是单独的列数组一样)。在插入过程中,系统检查它们是否具有相同的长度。 对于 DESCRIBE 查询,嵌套数据结构中的列以相同的方式单独列出。 -嵌套数据结构元素的 ALTER 查询具有一定的限制。 +ALTER 查询对于嵌套数据结构中的元素有其限制。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/nested-data-structures/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/nested-data-structures/index.md.hash index 1d7cf54447c..940eeeec6da 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/nested-data-structures/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/nested-data-structures/index.md.hash @@ -1 +1 @@ -1ed4021d6b29c4f9 +27aa7017d083d4b1 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/newjson.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/newjson.md index 5200016f2fb..57a7075f7af 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/newjson.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/newjson.md @@ -1,5 +1,5 @@ --- -'description': 'ClickHouse 中 JSON 数据类型的文档,它提供了对 JSON 数据的原生支持' +'description': 'ClickHouse 中 JSON 数据类型的文档,它原生支持处理 JSON 数据' 'keywords': - 'json' - 'data type' @@ -7,36 +7,33 @@ 'sidebar_position': 63 'slug': '/sql-reference/data-types/newjson' 'title': 'JSON 数据类型' +'doc_type': 'reference' --- import {CardSecondary} from '@clickhouse/click-ui/bundled'; +import Link from '@docusaurus/Link' +```jsx + +
-`JSON` 类型在单列中存储 JavaScript 对象表示法 (JSON) 文档。 - -如果您想使用 `JSON` 类型,并且想要查看本页上的示例,请使用: - -```sql -SET enable_json_type = 1 -``` - -但是,如果您使用的是 ClickHouse Cloud,则必须首先 [联系支持团队](https://clickhouse.com/docs/about-us/support) 以启用 `JSON` 类型的使用。 +`JSON` 类型将 JavaScript 对象表示法 (JSON) 文档存储在单个列中。 :::note -在 ClickHouse 开源版本中,JSON 数据类型在 25.3 版本中被标记为生产就绪。在以前的版本中,不建议在生产环境中使用该类型。 +在 ClickHouse 开源版本中,JSON 数据类型在 25.3 版本中标记为生产就绪。不建议在之前的版本中在生产中使用此类型。 ::: -要声明一个 `JSON` 类型的列,您可以使用以下语法: +要声明一个 `JSON` 类型的列,可以使用以下语法: ```sql JSON @@ -48,20 +45,19 @@ SET enable_json_type = 1 SKIP REGEXP 'paths_regexp' ) ``` -上述语法中的参数定义如下: - -| 参数 | 描述 | 默认值 | -|------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------| -| `max_dynamic_paths` | 一个可选参数,指示可以单独存储为子列的路径数量,这些路径跨单块数据单独存储(例如,跨 MergeTree 表的单个数据部分)。

如果超出此限制,所有其他路径将一起存储在一个结构中。 | `1024` | -| `max_dynamic_types` | 一个介于 `1` 和 `255` 之间的可选参数,指示在单个路径列中可以存储多少种不同的数据类型(类型为 `Dynamic`),这些数据类型跨单块数据单独存储(例如,跨 MergeTree 表的单个数据部分)。

如果超出此限制,所有新类型将被转换为 `String` 类型。 | `32` | -| `some.path TypeName` | 特定路径的可选类型提示。这样的路径将始终作为具有指定类型的子列存储。 | | -| `SKIP path.to.skip` | 对特定路径的可选提示,在 JSON 解析期间应跳过该路径。这样的路径将永远不会存储在 JSON 列中。如果指定的路径是嵌套的 JSON 对象,则整个嵌套对象将被跳过。 | | -| `SKIP REGEXP 'path_regexp'` | 使用正则表达式的可选提示,用于在 JSON 解析期间跳过路径。所有与此正则表达式匹配的路径将永远不会存储在 JSON 列中。 | | +其中上面语法中的参数定义如下: +| 参数 | 描述 | 默认值 | +|-----------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------| +| `max_dynamic_paths` | 一个可选参数,指示可以单独存储为子列的路径数,这些子列跨单个数据块单独存储(例如,跨 MergeTree 表的单个数据部分)。

如果超过此限制,所有其他路径将一起存储在单个结构中。 | `1024` | +| `max_dynamic_types` | 一个可选参数,介于 `1` 和 `255` 之间,指示在用类型 `Dynamic` 的单个路径列中可以存储多少种不同的数据类型,这些类型跨单个数据块单独存储(例如,跨 MergeTree 表的单个数据部分)。

如果超过此限制,所有新类型将被转换为类型 `String`。 | `32` | +| `some.path TypeName` | JSON 中特定路径的可选类型提示。此类路径将始终作为具有指定类型的子列存储。 | | +| `SKIP path.to.skip` | 在 JSON 解析期间应跳过的特定路径的可选提示。此类路径将永远不会存储在 JSON 列中。如果指定路径是一个嵌套的 JSON 对象,则将跳过整个嵌套对象。 | | +| `SKIP REGEXP 'path_regexp'` | 一个可选提示,使用正则表达式来跳过在 JSON 解析期间的路径。所有与该正则表达式匹配的路径将永远不会存储在 JSON 列中。 | | ## 创建 JSON {#creating-json} -在本节中,我们将看看创建 `JSON` 的各种方法。 +在本节中,我们将查看创建 `JSON` 的各种方法。 ### 在表列定义中使用 `JSON` {#using-json-in-a-table-column-definition} @@ -87,29 +83,29 @@ SELECT json FROM test; ```text title="Response (Example 2)" ┌─json──────────────────────────────┐ -│ {"a":{"b":42},"c":[1,2,3]} │ +│ {"a":{"b":42},"c":["1","2","3"]} │ │ {"a":{"b":0},"f":"Hello, World!"} │ -│ {"a":{"b":43},"c":[4,5,6]} │ +│ {"a":{"b":43},"c":["4","5","6"]} │ └───────────────────────────────────┘ ``` -### 使用 CAST 与 `::JSON` {#using-cast-with-json} +### 使用 `::JSON` 进行 CAST {#using-cast-with-json} -可以使用特殊语法 `::JSON` 将各种类型强制转换。 +可以使用特殊语法 `::JSON` 来强制转换各种类型。 -#### 从 `String` 转换为 `JSON` {#cast-from-string-to-json} +#### 从 `String` 到 `JSON` 的 CAST {#cast-from-string-to-json} ```sql title="Query" SELECT '{"a" : {"b" : 42},"c" : [1, 2, 3], "d" : "Hello, World!"}'::JSON AS json; ``` ```text title="Response" -┌─json───────────────────────────────────────────┐ -│ {"a":{"b":42},"c":[1,2,3],"d":"Hello, World!"} │ -└────────────────────────────────────────────────┘ +┌─json───────────────────────────────────────────────────┐ +│ {"a":{"b":"42"},"c":["1","2","3"],"d":"Hello, World!"} │ +└────────────────────────────────────────────────────────┘ ``` -#### 从 `Tuple` 转换为 `JSON` {#cast-from-tuple-to-json} +#### 从 `Tuple` 到 `JSON` 的 CAST {#cast-from-tuple-to-json} ```sql title="Query" SET enable_named_columns_in_function_tuple = 1; @@ -117,25 +113,25 @@ SELECT (tuple(42 AS b) AS a, [1, 2, 3] AS c, 'Hello, World!' AS d)::JSON AS json ``` ```text title="Response" -┌─json───────────────────────────────────────────┐ -│ {"a":{"b":42},"c":[1,2,3],"d":"Hello, World!"} │ -└────────────────────────────────────────────────┘ +┌─json───────────────────────────────────────────────────┐ +│ {"a":{"b":"42"},"c":["1","2","3"],"d":"Hello, World!"} │ +└────────────────────────────────────────────────────────┘ ``` -#### 从 `Map` 转换为 `JSON` {#cast-from-map-to-json} +#### 从 `Map` 到 `JSON` 的 CAST {#cast-from-map-to-json} ```sql title="Query" -SET enable_variant_type=1, use_variant_as_common_type=1; +SET use_variant_as_common_type=1; SELECT map('a', map('b', 42), 'c', [1,2,3], 'd', 'Hello, World!')::JSON AS json; ``` ```text title="Response" -┌─json───────────────────────────────────────────┐ -│ {"a":{"b":42},"c":[1,2,3],"d":"Hello, World!"} │ -└────────────────────────────────────────────────┘ +┌─json───────────────────────────────────────────────────┐ +│ {"a":{"b":"42"},"c":["1","2","3"],"d":"Hello, World!"} │ +└────────────────────────────────────────────────────────┘ ``` -#### 从弃用的 `Object('json')` 转换为 `JSON` {#cast-from-deprecated-objectjson-to-json} +#### 从弃用的 `Object('json')` 到 `JSON` 的 CAST {#cast-from-deprecated-objectjson-to-json} ```sql title="Query" SET allow_experimental_object_type = 1; @@ -143,18 +139,18 @@ SELECT '{"a" : {"b" : 42},"c" : [1, 2, 3], "d" : "Hello, World!"}'::Object('json ``` ```text title="Response" -┌─json───────────────────────────────────────────┐ -│ {"a":{"b":42},"c":[1,2,3],"d":"Hello, World!"} │ -└────────────────────────────────────────────────┘ +┌─json───────────────────────────────────────────────────┐ +│ {"a":{"b":"42"},"c":["1","2","3"],"d":"Hello, World!"} │ +└────────────────────────────────────────────────────────┘ ``` :::note -JSON 路径是以扁平化方式存储的。这意味着当从路径如 `a.b.c` 格式化 JSON 对象时,无法确定对象应该构造为 `{ "a.b.c" : ... }` 还是 `{ "a" : {"b" : {"c" : ... }}}`。我们的实现将始终假设后者。 +JSON 路径被存储为扁平化形式。这意味着当从路径 `a.b.c` 格式化 JSON 对象时,无法知道对象应该构建为 `{ "a.b.c" : ... }` 还是 `{ "a": { "b": { "c": ... }}}`。我们的实现将始终假设后者。 例如: ```sql -SELECT CAST('{"a.b.c" : 42}', 'JSON') as json +SELECT CAST('{"a.b.c" : 42}', 'JSON') AS json ``` 将返回: @@ -165,7 +161,7 @@ SELECT CAST('{"a.b.c" : 42}', 'JSON') as json └────────────────────────┘ ``` -而 **不是**: +而且 **不是**: ```sql ┌─json───────────┐ @@ -177,8 +173,7 @@ SELECT CAST('{"a.b.c" : 42}', 'JSON') as json ## 将 JSON 路径作为子列读取 {#reading-json-paths-as-sub-columns} `JSON` 类型支持将每个路径作为单独的子列读取。 -如果请求路径的类型未在 JSON 类型声明中指定, -则此路径的子列将始终具有类型 [Dynamic](/sql-reference/data-types/dynamic.md)。 +如果请求的路径的类型没有在 JSON 类型声明中指定,则路径的子列将始终具有类型 [Dynamic](/sql-reference/data-types/dynamic.md)。 例如: @@ -189,11 +184,11 @@ SELECT json FROM test; ``` ```text title="Response" -┌─json──────────────────────────────────────────────────┐ -│ {"a":{"b":42,"g":42.42},"c":[1,2,3],"d":"2020-01-01"} │ -│ {"a":{"b":0},"d":"2020-01-02","f":"Hello, World!"} │ -│ {"a":{"b":43,"g":43.43},"c":[4,5,6]} │ -└───────────────────────────────────────────────────────┘ +┌─json────────────────────────────────────────────────────────┐ +│ {"a":{"b":42,"g":42.42},"c":["1","2","3"],"d":"2020-01-01"} │ +│ {"a":{"b":0},"d":"2020-01-02","f":"Hello, World!"} │ +│ {"a":{"b":43,"g":43.43},"c":["4","5","6"]} │ +└─────────────────────────────────────────────────────────────┘ ``` ```sql title="Query (Reading JSON paths as sub-columns)" @@ -208,7 +203,21 @@ SELECT json.a.b, json.a.g, json.c, json.d FROM test; └──────────┴──────────┴─────────┴────────────┘ ``` -如果在数据中未找到请求的路径,则它将填充为 `NULL` 值: +您还可以使用 `getSubcolumn` 函数从 JSON 类型读取子列: + +```sql title="Query" +SELECT getSubcolumn(json, 'a.b'), getSubcolumn(json, 'a.g'), getSubcolumn(json, 'c'), getSubcolumn(json, 'd') FROM test; +``` + +```text title="Response" +┌─getSubcolumn(json, 'a.b')─┬─getSubcolumn(json, 'a.g')─┬─getSubcolumn(json, 'c')─┬─getSubcolumn(json, 'd')─┐ +│ 42 │ 42.42 │ [1,2,3] │ 2020-01-01 │ +│ 0 │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ 2020-01-02 │ +│ 43 │ 43.43 │ [4,5,6] │ ᴺᵁᴸᴸ │ +└───────────────────────────┴───────────────────────────┴─────────────────────────┴─────────────────────────┘ +``` + +如果在数据中未找到请求的路径,则将填写 `NULL` 值: ```sql title="Query" SELECT json.non.existing.path FROM test; @@ -236,10 +245,9 @@ SELECT toTypeName(json.a.b), toTypeName(json.a.g), toTypeName(json.c), toTypeNam └──────────────────────┴──────────────────────┴────────────────────┴────────────────────┘ ``` -如我们所见,对于 `a.b`,类型为 `UInt32`,因为我们在 JSON 类型声明中指定了它, -而对于所有其他子列,类型为 `Dynamic`。 +如我们所见,对于 `a.b`,类型为 `UInt32`,正如我们在 JSON 类型声明中指定的那样,所有其他子列的类型为 `Dynamic`。 -还可以使用特殊语法 `json.some.path.:TypeName` 读取 `Dynamic` 类型的子列: +使用特殊语法 `json.some.path.:TypeName` 也可以读取 `Dynamic` 类型的子列: ```sql title="Query" SELECT @@ -258,7 +266,7 @@ FROM test └─────────────────────┴───────────────────────┴────────────────┴─────────────────────┘ ``` -`Dynamic` 子列可以转换为任何数据类型。在这种情况下,如果 `Dynamic` 内部的内部类型无法转换为请求的类型,则会抛出异常: +`Dynamic` 子列可以被强制转换为任何数据类型。在这种情况下,如果 `Dynamic` 内部的类型无法强制转换为请求的类型,将抛出异常: ```sql title="Query" SELECT json.a.g::UInt64 AS uint @@ -287,9 +295,13 @@ while executing 'FUNCTION CAST(__table1.json.a.g :: 2, 'UUID'_String :: 1) -> CA (NOT_IMPLEMENTED) ``` +:::note +为了有效地从紧凑的 MergeTree 部分读取子列,请确保启用了 MergeTree 设置 [write_marks_for_substreams_in_compact_parts](../../operations/settings/merge-tree-settings.md#write_marks_for_substreams_in_compact_parts)。 +::: + ## 将 JSON 子对象作为子列读取 {#reading-json-sub-objects-as-sub-columns} -`JSON` 类型支持使用特殊语法 `json.^some.path` 将嵌套对象作为类型为 `JSON` 的子列读取: +`JSON` 类型支持使用特殊语法 `json.^some.path` 将嵌套对象作为类型 `JSON` 的子列读取: ```sql title="Query" CREATE TABLE test (json JSON) ENGINE = Memory; @@ -298,11 +310,11 @@ SELECT json FROM test; ``` ```text title="Response" -┌─json────────────────────────────────────────────────────────────────────────────────────────┐ -│ {"a":{"b":{"c":42,"g":42.42}},"c":[1,2,3],"d":{"e":{"f":{"g":"Hello, World","h":[1,2,3]}}}} │ -│ {"d":{"e":{"f":{"h":[4,5,6]}}},"f":"Hello, World!"} │ -│ {"a":{"b":{"c":43,"e":10,"g":43.43}},"c":[4,5,6]} │ -└─────────────────────────────────────────────────────────────────────────────────────────────┘ +┌─json──────────────────────────────────────────────────────────────────────────────────────────────────────┐ +│ {"a":{"b":{"c":"42","g":42.42}},"c":["1","2","3"],"d":{"e":{"f":{"g":"Hello, World","h":["1","2","3"]}}}} │ +│ {"d":{"e":{"f":{"h":["4","5","6"]}}},"f":"Hello, World!"} │ +│ {"a":{"b":{"c":"43","e":"10","g":43.43}},"c":["4","5","6"]} │ +└───────────────────────────────────────────────────────────────────────────────────────────────────────────┘ ``` ```sql title="Query" @@ -310,21 +322,22 @@ SELECT json.^a.b, json.^d.e.f FROM test; ``` ```text title="Response" -┌─json.^`a`.b───────────────┬─json.^`d`.e.f────────────────────┐ -│ {"c":42,"g":42.42} │ {"g":"Hello, World","h":[1,2,3]} │ -│ {} │ {"h":[4,5,6]} │ -│ {"c":43,"e":10,"g":43.43} │ {} │ -└───────────────────────────┴──────────────────────────────────┘ +┌─json.^`a`.b───────────────────┬─json.^`d`.e.f──────────────────────────┐ +│ {"c":"42","g":42.42} │ {"g":"Hello, World","h":["1","2","3"]} │ +│ {} │ {"h":["4","5","6"]} │ +│ {"c":"43","e":"10","g":43.43} │ {} │ +└───────────────────────────────┴────────────────────────────────────────┘ ``` :::note -将子对象作为子列读取可能效率不高,因为这可能需要对 JSON 数据进行近乎完全扫描。 +将子对象作为子列读取可能效率低下,因为这可能需要对 JSON 数据进行几乎完整的扫描。 ::: ## 路径的类型推断 {#type-inference-for-paths} -在解析 `JSON` 时,ClickHouse 尝试检测每个 JSON 路径最适合的数据类型。 -它的工作方式类似于 [自动架构推断输入数据](/interfaces/schema-inference.md),并受相同设置的控制: +在解析 `JSON` 时,ClickHouse 尝试为每个 JSON 路径检测最合适的数据类型。 +它的工作方式类似于 [输入数据的自动模式推断](/interfaces/schema-inference.md), +并受相同设置控制: - [input_format_try_infer_dates](/operations/settings/formats#input_format_try_infer_dates) - [input_format_try_infer_datetimes](/operations/settings/formats#input_format_try_infer_datetimes) @@ -335,8 +348,9 @@ SELECT json.^a.b, json.^d.e.f FROM test; - [input_format_json_read_bools_as_strings](/operations/settings/formats#input_format_json_read_bools_as_strings) - [input_format_json_read_bools_as_numbers](/operations/settings/formats#input_format_json_read_bools_as_numbers) - [input_format_json_read_arrays_as_strings](/operations/settings/formats#input_format_json_read_arrays_as_strings) +- [input_format_json_infer_array_of_dynamic_from_array_of_different_types](/operations/settings/formats#input_format_json_infer_array_of_dynamic_from_array_of_different_types) -让我们看一些示例: +让我们来看一些例子: ```sql title="Query" SELECT JSONAllPathsWithTypes('{"a" : "2020-01-01", "b" : "2020-01-01 10:00:00"}'::JSON) AS paths_with_types settings input_format_try_infer_dates=1, input_format_try_infer_datetimes=1; @@ -381,7 +395,7 @@ SELECT JSONAllPathsWithTypes('{"a" : [1, 2, 3]}'::JSON) AS paths_with_types sett ## 处理 JSON 对象的数组 {#handling-arrays-of-json-objects} 包含对象数组的 JSON 路径被解析为类型 `Array(JSON)`,并插入到路径的 `Dynamic` 列中。 -要读取对象数组,您可以将其作为子列从 `Dynamic` 列中提取: +要读取对象数组,可以将其作为子列从 `Dynamic` 列中提取: ```sql title="Query" CREATE TABLE test (json JSON) ENGINE = Memory; @@ -412,10 +426,10 @@ SELECT json.a.b, dynamicType(json.a.b) FROM test; └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┴──────────────────────────────────────────────────────────┘ ``` -正如您所注意到的,嵌套的 `JSON` 类型的 `max_dynamic_types`/`max_dynamic_paths` 参数比默认值减少。 -这是为了避免在 JSON 对象的嵌套数组中子列数量的快速增长。 +正如您可能已经注意到的,嵌套 `JSON` 类型的 `max_dynamic_types` / `max_dynamic_paths` 参数相较于默认值有所减少。 +这是为了避免在 JSON 对象的嵌套数组上子列数量失控增长。 -让我们尝试从嵌套的 `JSON` 列中读取子列: +让我们尝试从嵌套 `JSON` 列中读取子列: ```sql title="Query" SELECT json.a.b.:`Array(JSON)`.c, json.a.b.:`Array(JSON)`.f, json.a.b.:`Array(JSON)`.d FROM test; @@ -429,7 +443,7 @@ SELECT json.a.b.:`Array(JSON)`.c, json.a.b.:`Array(JSON)`.f, json.a.b.:`Array(JS └───────────────────────────┴─────────────────────────────────────────────────────────────┴───────────────────────────┘ ``` -我们可以通过特殊语法避免写入 `Array(JSON)` 子列名称: +我们可以使用特殊语法避免写 `Array(JSON)` 子列名称: ```sql title="Query" SELECT json.a.b[].c, json.a.b[].f, json.a.b[].d FROM test; @@ -443,9 +457,9 @@ SELECT json.a.b[].c, json.a.b[].f, json.a.b[].d FROM test; └───────────────────────────┴─────────────────────────────────────────────────────────────┴───────────────────────────┘ ``` -路径后面的 `[]` 数量表示数组级别。例如,`json.path[][]` 将转换为 `json.path.:Array(Array(JSON))` +路径后面的 `[]` 数量指示数组的级别。例如,`json.path[][]` 将被转换为 `json.path.:Array(Array(JSON))` -让我们检查 `Array(JSON)` 中的路径和类型: +让我们检查我们 `Array(JSON)` 中的路径和类型: ```sql title="Query" SELECT DISTINCT arrayJoin(JSONAllPathsWithTypes(arrayJoin(json.a.b[]))) FROM test; @@ -475,7 +489,7 @@ SELECT json.a.b[].c.:Int64, json.a.b[].f[][].g.:Float64, json.a.b[].f[][].h.:Dat └────────────────────────────────────┴──────────────────────────────────────────────────────────────┴───────────────────────────────────────────────────────────┘ ``` -我们还可以从嵌套的 `JSON` 列中读取子对象的子列: +我们还可以从嵌套的 `JSON` 列中读取子对象子列: ```sql title="Query" SELECT json.a.b[].^k FROM test @@ -489,14 +503,120 @@ SELECT json.a.b[].^k FROM test └──────────────────────────────────────┘ ``` -## 从数据中读取 JSON 类型 {#reading-json-type-from-data} +## 处理带有点的 JSON 键 {#handling-json-keys-with-dots} + +内部 JSON 列以扁平化形式存储所有路径和值。这意味着默认情况下,这两个对象被视为相同: +```json +{"a" : {"b" : 42}} +{"a.b" : 42} +``` + +它们都将内部存储为路径 `a.b` 和值 `42` 的一对。在格式化 JSON 时,我们始终根据用点分隔的路径部分形成嵌套对象: + +```sql title="Query" +SELECT '{"a" : {"b" : 42}}'::JSON AS json1, '{"a.b" : 42}'::JSON AS json2, JSONAllPaths(json1), JSONAllPaths(json2); +``` + +```text title="Response" +┌─json1────────────┬─json2────────────┬─JSONAllPaths(json1)─┬─JSONAllPaths(json2)─┐ +│ {"a":{"b":"42"}} │ {"a":{"b":"42"}} │ ['a.b'] │ ['a.b'] │ +└──────────────────┴──────────────────┴─────────────────────┴─────────────────────┘ +``` + +正如您所看到的,初始 JSON `{"a.b" : 42}` 现在被格式化为 `{"a" : {"b" : 42}}`。 + +此限制还会导致解析有效 JSON 对象失败,如下所示: + +```sql title="Query" +SELECT '{"a.b" : 42, "a" : {"b" : "Hello World!"}}'::JSON AS json; +``` + +```text title="Response" +Code: 117. DB::Exception: Cannot insert data into JSON column: Duplicate path found during parsing JSON object: a.b. You can enable setting type_json_skip_duplicated_paths to skip duplicated paths during insert: In scope SELECT CAST('{"a.b" : 42, "a" : {"b" : "Hello, World"}}', 'JSON') AS json. (INCORRECT_DATA) +``` + +如果您想保留带点的键并避免将它们格式化为嵌套对象,可以启用设置 [json_type_escape_dots_in_keys](/operations/settings/formats#json_type_escape_dots_in_keys) (从 `25.8` 版本开始可用)。在这种情况下,在解析期间,JSON 键中的所有点将被转义为 `%2E`,并在格式化过程中反转义。 + +```sql title="Query" +SET json_type_escape_dots_in_keys=1; +SELECT '{"a" : {"b" : 42}}'::JSON AS json1, '{"a.b" : 42}'::JSON AS json2, JSONAllPaths(json1), JSONAllPaths(json2); +``` + +```text title="Response" +┌─json1────────────┬─json2────────┬─JSONAllPaths(json1)─┬─JSONAllPaths(json2)─┐ +│ {"a":{"b":"42"}} │ {"a.b":"42"} │ ['a.b'] │ ['a%2Eb'] │ +└──────────────────┴──────────────┴─────────────────────┴─────────────────────┘ +``` + +```sql title="Query" +SET json_type_escape_dots_in_keys=1; +SELECT '{"a.b" : 42, "a" : {"b" : "Hello World!"}}'::JSON AS json, JSONAllPaths(json); +``` + +```text title="Response" +┌─json──────────────────────────────────┬─JSONAllPaths(json)─┐ +│ {"a.b":"42","a":{"b":"Hello World!"}} │ ['a%2Eb','a.b'] │ +└───────────────────────────────────────┴────────────────────┘ +``` + +要将带有转义点的键作为子列读取,您必须在子列名称中使用转义点: + +```sql title="Query" +SET json_type_escape_dots_in_keys=1; +SELECT '{"a.b" : 42, "a" : {"b" : "Hello World!"}}'::JSON AS json, json.`a%2Eb`, json.a.b; +``` + +```text title="Response" +┌─json──────────────────────────────────┬─json.a%2Eb─┬─json.a.b─────┐ +│ {"a.b":"42","a":{"b":"Hello World!"}} │ 42 │ Hello World! │ +└───────────────────────────────────────┴────────────┴──────────────┘ +``` + +注意:由于标识符解析器和分析器的限制,子列 ``json.`a.b`\`` 等价于子列 `json.a.b`,并且不会读取带有转义点的路径: + +```sql title="Query" +SET json_type_escape_dots_in_keys=1; +SELECT '{"a.b" : 42, "a" : {"b" : "Hello World!"}}'::JSON AS json, json.`a%2Eb`, json.`a.b`, json.a.b; +``` + +```text title="Response" +┌─json──────────────────────────────────┬─json.a%2Eb─┬─json.a.b─────┬─json.a.b─────┐ +│ {"a.b":"42","a":{"b":"Hello World!"}} │ 42 │ Hello World! │ Hello World! │ +└───────────────────────────────────────┴────────────┴──────────────┴──────────────┘ +``` + +此外,如果您想为包含带有点的键的 JSON 路径指定提示(或在 `SKIP` / `SKIP REGEX` 部分中使用),必须在提示中使用转义点: + +```sql title="Query" +SET json_type_escape_dots_in_keys=1; +SELECT '{"a.b" : 42, "a" : {"b" : "Hello World!"}}'::JSON(`a%2Eb` UInt8) as json, json.`a%2Eb`, toTypeName(json.`a%2Eb`); +``` + +```text title="Response" +┌─json────────────────────────────────┬─json.a%2Eb─┬─toTypeName(json.a%2Eb)─┐ +│ {"a.b":42,"a":{"b":"Hello World!"}} │ 42 │ UInt8 │ +└─────────────────────────────────────┴────────────┴────────────────────────┘ +``` + +```sql title="Query" +SET json_type_escape_dots_in_keys=1; +SELECT '{"a.b" : 42, "a" : {"b" : "Hello World!"}}'::JSON(SKIP `a%2Eb`) as json, json.`a%2Eb`; +``` + +```text title="Response" +┌─json───────────────────────┬─json.a%2Eb─┐ +│ {"a":{"b":"Hello World!"}} │ ᴺᵁᴸᴸ │ +└────────────────────────────┴────────────┘ +``` + +## 从数据读取 JSON 类型 {#reading-json-type-from-data} 所有文本格式 ([`JSONEachRow`](../../interfaces/formats/JSON/JSONEachRow.md), [`TSV`](../../interfaces/formats/TabSeparated/TabSeparated.md), [`CSV`](../../interfaces/formats/CSV/CSV.md), [`CustomSeparated`](../../interfaces/formats/CustomSeparated/CustomSeparated.md), -[`Values`](../../interfaces/formats/Values.md) 等等) 都支持读取 `JSON` 类型。 +[`Values`](../../interfaces/formats/Values.md) 等) 支持读取 `JSON` 类型。 示例: @@ -520,7 +640,7 @@ SELECT json FROM format(JSONEachRow, 'json JSON(a.b.c UInt32, SKIP a.b.d, SKIP d └───────────────────────────────────────────────────────────────┘ ``` -对于 `CSV`/`TSV` 等文本格式,`JSON` 是从包含 JSON 对象的字符串中解析的: +对于文本格式,如 `CSV` / `TSV` / 等,`JSON` 从包含 JSON 对象的字符串中解析: ```sql title="Query" SELECT json FROM format(TSV, 'json JSON(a.b.c UInt32, SKIP a.b.d, SKIP REGEXP \'b.*\')', @@ -541,22 +661,22 @@ SELECT json FROM format(TSV, 'json JSON(a.b.c UInt32, SKIP a.b.d, SKIP REGEXP \' └───────────────────────────────────────────────────────────────┘ ``` -## 达到 JSON 中动态路径的限制 {#reaching-the-limit-of-dynamic-paths-inside-json} +## 达到 JSON 内部动态路径的限制 {#reaching-the-limit-of-dynamic-paths-inside-json} `JSON` 数据类型只能内部存储有限数量的路径作为单独的子列。 默认情况下,此限制为 `1024`,但您可以使用参数 `max_dynamic_paths` 在类型声明中进行更改。 -当达到限制时,所有插入到 `JSON` 列的新路径将存储在单个共享数据结构中。 -仍然可以将这些路径作为子列读取, -但这将需要读取整个共享数据结构以提取该路径的值。 -此限制的设置是为了避免在不同的子列中拥有巨大的数量,这可能会使表变得不可用。 +当达到这个限制时,插入到 `JSON` 列的所有新路径将存储在一个共享的数据结构中。 +仍然可以将此类路径作为子列读取, +但可能效率较低([参见共享数据部分](#shared-data-structure))。 +此限制是为了避免有大量不同子列,从而使表无法使用。 -让我们看看在几种不同情况下达到限制时会发生什么。 +让我们看看在几个不同场景下达到限制时会发生什么。 -### 在数据解析过程中达到限制 {#reaching-the-limit-during-data-parsing} +### 在数据解析期间达到限制 {#reaching-the-limit-during-data-parsing} -在从数据解析 `JSON` 对象时,当当前数据块达到限制时, -所有新路径将存储在共享数据结构中。我们可以使用以下两种自省函数 `JSONDynamicPaths`、`JSONSharedDataPaths`: +在从数据中解析 `JSON` 对象时,当当前数据块达到限制时, +所有新路径将存储在共享数据结构中。我们可以使用以下两个 introspection 函数 `JSONDynamicPaths`,`JSONSharedDataPaths`: ```sql title="Query" SELECT json, JSONDynamicPaths(json), JSONSharedDataPaths(json) FROM format(JSONEachRow, 'json JSON(max_dynamic_paths=3)', ' @@ -578,21 +698,22 @@ SELECT json, JSONDynamicPaths(json), JSONSharedDataPaths(json) FROM format(JSONE └────────────────────────────────────────────────────────────────┴────────────────────────┴───────────────────────────┘ ``` -如我们所见,在插入路径 `e` 和 `f.g` 后达到了限制, +正如我们所见,在插入路径 `e` 和 `f.g` 之后,达到了限制, 它们被插入到共享数据结构中。 -### 在 MergeTree 表引擎的数据部分合并期间 {#during-merges-of-data-parts-in-mergetree-table-engines} +### 在 MergeTree 表引擎中合并数据部分期间 {#during-merges-of-data-parts-in-mergetree-table-engines} -在将多个数据部分合并到 `MergeTree` 表中时,结果数据部分中的 `JSON` 列可能达到动态路径的限制 -而无法将源部分中的所有路径存储为子列。 -在这种情况下,ClickHouse 选择合并后哪些路径将作为子列保留,哪些路径将存储在共享数据结构中。 -在大多数情况下,ClickHouse 尝试保留包含最多非 NULL 值的路径,并将最少见的路径移动到共享数据结构中。不过,这取决于实现。 +在 `MergeTree` 表中合并多个数据部分时,结果数据部分中的 `JSON` 列可能达到动态路径的限制 +并且无法将所有路径作为子列存储。 +在这种情况下,ClickHouse 会选择哪些路径在合并后保持为子列,以及哪些路径将存储在共享数据结构中。 +在大多数情况下,ClickHouse 会尝试保留包含 +最大数量非空值的路径,并将最稀有的路径移入共享数据结构。这确实取决于实现。 -让我们看看这样合并的示例。 -首先,让我们创建一个包含 `JSON` 列的表,将动态路径的限制设置为 `3`,然后插入具有 `5` 不同路径的值: +让我们看一个这样的合并示例。 +首先,让我们创建一个包含 `JSON` 列的表,将动态路径的限制设置为 `3`,然后插入具有 `5` 条不同路径的值: ```sql title="Query" -CREATE TABLE test (id UInt64, json JSON(max_dynamic_paths=3)) engine=MergeTree ORDER BY id; +CREATE TABLE test (id UInt64, json JSON(max_dynamic_paths=3)) ENGINE=MergeTree ORDER BY id; SYSTEM STOP MERGES test; INSERT INTO test SELECT number, formatRow('JSONEachRow', number as a) FROM numbers(5); INSERT INTO test SELECT number, formatRow('JSONEachRow', number as b) FROM numbers(4); @@ -601,7 +722,7 @@ INSERT INTO test SELECT number, formatRow('JSONEachRow', number as d) FROM numbe INSERT INTO test SELECT number, formatRow('JSONEachRow', number as e) FROM numbers(1); ``` -每次插入都会创建一个包含单一路径的 `JSON` 列的单独数据部分: +每次插入都会创建一个包含单个路径的 `JSON` 列的单独数据部分: ```sql title="Query" SELECT @@ -643,23 +764,71 @@ ORDER BY _part ASC └─────────┴───────────────┴───────────────────┴───────────┘ ``` -如我们所见,ClickHouse 保留了最常见的路径 `a`、`b` 和 `c`,并将路径 `d` 和 `e` 移动到共享数据结构中。 +正如我们所见,ClickHouse 保留了最常见的路径 `a`、`b` 和 `c` 并将路径 `d` 和 `e` 移入共享数据结构。 + +## 共享数据结构 {#shared-data-structure} + +正如在上一节中所述,当 `max_dynamic_paths` 限制达到时,所有新路径将存储在一个共享数据结构中。 +在本节中,我们将查看共享数据结构的详细信息以及如何从中读取路径子列。 + +有关用于检查 JSON 列内容的函数的详细信息,请参见节 ["introspection functions"](/sql-reference/data-types/newjson#introspection-functions)。 + +### 内存中的共享数据结构 {#shared-data-structure-in-memory} + +在内存中,共享数据结构只是一个类型为 `Map(String, String)` 的子列,用于存储从扁平化 JSON 路径到二进制编码值的映射。 +要从中提取路径子列,我们只需遍历此 `Map` 列中的所有行,并尝试找到请求的路径及其值。 + +### 在 MergeTree 部分中的共享数据结构 {#shared-data-structure-in-merge-tree-parts} + +在 [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) 表中,我们在数据部分中存储数据,这些数据存储在磁盘上(本地或远程)。而存储在磁盘上的数据可以以不同于内存的方式存储。 +目前,MergeTree 数据部分中有三种不同的共享数据结构序列化:`map`、`map_with_buckets` 和 `advanced`。 + +序列化版本由 MergeTree +设置 [object_shared_data_serialization_version](../../operations/settings/merge-tree-settings.md#object_shared_data_serialization_version) +和 [object_shared_data_serialization_version_for_zero_level_parts](../../operations/settings/merge-tree-settings.md#object_shared_data_serialization_version_for_zero_level_parts) 控制 +(零级部分是在将数据插入表时创建的,合并期间部分具有更高级别)。 + +注意:仅支持更改 `v3` [对象序列化版本](../../operations/settings/merge-tree-settings.md#object_serialization_version) 的共享数据结构序列化 + +#### Map {#shared-data-map} -## 自省函数 {#introspection-functions} +在 `map` 序列化版本中,共享数据序列化为类型为 `Map(String, String)` 的单列,与它在内存中存储的相同。要从此类型的序列化中读取路径子列,ClickHouse 读取整个 `Map` 列并在内存中提取请求的路径。 + +此序列化对写入数据和读取整个 `JSON` 列效率较高,但对读取路径子列效率较低。 + +#### 带有桶的 Map {#shared-data-map-with-buckets} + +在 `map_with_buckets` 序列化版本中,共享数据序列化为 `N` 列(“桶”),类型为 `Map(String, String)`。 +每个这样的桶仅包含路径的子集。要从此类型的序列化中读取路径子列,ClickHouse 从单个桶读取整个 `Map` 列并在内存中提取请求的路径。 + +此序列化对写入数据和读取整个 `JSON` 列效率较低,但对读取路径子列更高效,因为它仅从所需的桶中读取数据。 + +桶的数量 `N` 由 MergeTree 设置 [object_shared_data_buckets_for_compact_part](../../operations/settings/merge-tree-settings.md#object_shared_data_buckets_for_compact_part)(默认 8)和 [object_shared_data_buckets_for_wide_part](../../operations/settings/merge-tree-settings.md#object_shared_data_buckets_for_wide_part)(默认 32)控制。 + +#### 先进 {#shared-data-advanced} + +在 `advanced` 序列化版本中,共享数据以一种特殊的数据结构进行序列化,该结构通过存储一些附加信息来最大化路径子列读取的性能,允许仅读取请求路径的数据。 +此序列化还支持桶,因此每个桶仅包含路径的子集。 + +此序列化对写入数据非常低效(因此不建议在零级部分使用此序列化),读取整个 `JSON` 列与 `map` 序列化相比稍微低效,但对读取路径子列非常有效。 + +注意:由于在数据结构中存储一些附加信息,因此与 `map` 和 `map_with_buckets` 序列化相比,此序列化的磁盘存储大小更高。 + +## Introspection 函数 {#introspection-functions} 有几个函数可以帮助检查 JSON 列的内容: -- [`JSONAllPaths`](../functions/json-functions.md#jsonallpaths) -- [`JSONAllPathsWithTypes`](../functions/json-functions.md#jsonallpathswithtypes) -- [`JSONDynamicPaths`](../functions/json-functions.md#jsondynamicpaths) -- [`JSONDynamicPathsWithTypes`](../functions/json-functions.md#jsondynamicpathswithtypes) -- [`JSONSharedDataPaths`](../functions/json-functions.md#jsonshareddatapaths) -- [`JSONSharedDataPathsWithTypes`](../functions/json-functions.md#jsonshareddatapathswithtypes) +- [`JSONAllPaths`](../functions/json-functions.md#JSONAllPaths) +- [`JSONAllPathsWithTypes`](../functions/json-functions.md#JSONAllPathsWithTypes) +- [`JSONDynamicPaths`](../functions/json-functions.md#JSONDynamicPaths) +- [`JSONDynamicPathsWithTypes`](../functions/json-functions.md#JSONDynamicPathsWithTypes) +- [`JSONSharedDataPaths`](../functions/json-functions.md#JSONSharedDataPaths) +- [`JSONSharedDataPathsWithTypes`](../functions/json-functions.md#JSONSharedDataPathsWithTypes) - [`distinctDynamicTypes`](../aggregate-functions/reference/distinctdynamictypes.md) - [`distinctJSONPaths and distinctJSONPathsAndTypes`](../aggregate-functions/reference/distinctjsonpaths.md) **示例** -让我们调查日期为 `2020-01-01` 的 [GH Archive](https://www.gharchive.org/) 数据集的内容: +让我们检查 `2020-01-01` 的 [GH Archive](https://www.gharchive.org/) 数据集的内容: ```sql title="Query" SELECT arrayJoin(distinctJSONPaths(json)) @@ -727,7 +896,6 @@ FROM s3('s3://clickhouse-public-datasets/gharchive/original/2020-01-01-*.json.gz SETTINGS date_time_input_format = 'best_effort' ``` - ```text ┌─arrayJoin(distinctJSONPathsAndTypes(json))──────────────────┐ │ ('actor.avatar_url',['String']) │ @@ -783,14 +951,14 @@ SETTINGS date_time_input_format = 'best_effort' └─arrayJoin(distinctJSONPathsAndTypes(json))──────────────────┘ ``` -## ALTER MODIFY COLUMN 到 JSON 类型 {#alter-modify-column-to-json-type} +## ALTER MODIFY COLUMN 转换为 JSON 类型 {#alter-modify-column-to-json-type} -可以更改现有表的列类型为新的 `JSON` 类型。目前仅支持从 `String` 类型进行 `ALTER`。 +可以更改现有表并将列类型更改为新的 `JSON` 类型。目前仅支持从 `String` 类型进行 `ALTER`。 **示例** ```sql title="Query" -CREATE TABLE test (json String) ENGINE=MergeTree ORDeR BY tuple(); +CREATE TABLE test (json String) ENGINE=MergeTree ORDER BY tuple(); INSERT INTO test VALUES ('{"a" : 42}'), ('{"a" : 43, "b" : "Hello"}'), ('{"a" : 44, "b" : [1, 2, 3]}'), ('{"c" : "2020-01-01"}'); ALTER TABLE test MODIFY COLUMN json JSON; SELECT json, json.a, json.b, json.c FROM test; @@ -807,7 +975,7 @@ SELECT json, json.a, json.b, json.c FROM test; ## 比较 JSON 类型值 {#comparison-between-values-of-the-json-type} -JSON 对象的比较与 Map 类似。 +JSON 对象的比较方式类似于 Maps。 例如: @@ -841,18 +1009,18 @@ SELECT json1, json2, json1 < json2, json1 = json2, json1 > json2 FROM test; └────────────┴─────────────────────┴────────────────────┴──────────────────────┴───────────────────────┘ ``` -**注意:** 当 2 个路径包含不同数据类型的值时,它们将根据 `Variant` 数据类型的 [比较规则](/sql-reference/data-types/variant#comparing-values-of-variant-data) 进行比较。 +**注意:** 当两个路径包含不同数据类型的值时,它们会根据 `Variant` 数据类型的 [比较规则](/sql-reference/data-types/variant#comparing-values-of-variant-data) 进行比较。 -## 有关更好使用 JSON 类型的提示 {#tips-for-better-usage-of-the-json-type} +## 提高 JSON 类型使用效率的技巧 {#tips-for-better-usage-of-the-json-type} -在创建 `JSON` 列并加载数据之前,请考虑以下提示: +在创建 `JSON` 列并将数据加载到其中之前,请考虑以下建议: -- 调查您的数据并尽可能多地指定带有类型的路径提示。这将使存储和读取变得更高效。 -- 考虑您将需要哪些路径,以及哪些路径您将永远不需要。在 `SKIP` 部分指定您不需要的路径,在 `SKIP REGEXP` 部分指定(如有必要)。这将改善存储。 -- 不要将 `max_dynamic_paths` 参数设置为非常高的值,因为这可能会使存储和读取变得不够高效。 - 虽然取决于内存、CPU 等系统参数,但一般经验法则是不要将 `max_dynamic_paths` > 10 000。 +- 调查您的数据,并尽可能指定尽量多的路径提示和类型。这会使存储和读取更加高效。 +- 考虑您需要哪些路径以及您绝对不会需要哪些路径。将您不会需要的路径在 `SKIP` 部分中指定,如果需要,在 `SKIP REGEXP` 部分中也指定。这将改善存储。 +- 不要将 `max_dynamic_paths` 参数设置为非常高的值,因为这可能会降低存储和读取的效率。 + 虽然这在很大程度上依赖于系统参数,如内存、CPU 等,但一般经验法则是:不要将 `max_dynamic_paths` 设置大于 10 000 对于本地文件系统存储,和 1024 对于远程文件系统存储。 ## 进一步阅读 {#further-reading} -- [我们如何为 ClickHouse 构建了一个全新的强大 JSON 数据类型](https://clickhouse.com/blog/a-new-powerful-json-data-type-for-clickhouse) -- [十亿文档 JSON 挑战:ClickHouse 对比 MongoDB、Elasticsearch 等](https://clickhouse.com/blog/json-bench-clickhouse-vs-mongodb-elasticsearch-duckdb-postgresql) +- [我们是如何为 ClickHouse 构建一个新的强大的 JSON 数据类型的](https://clickhouse.com/blog/a-new-powerful-json-data-type-for-clickhouse) +- [十亿文档的 JSON 挑战:ClickHouse 与 MongoDB、Elasticsearch 等的比较](https://clickhouse.com/blog/json-bench-clickhouse-vs-mongodb-elasticsearch-duckdb-postgresql) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/newjson.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/newjson.md.hash index dc903d9d48b..c249acc158f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/newjson.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/newjson.md.hash @@ -1 +1 @@ -b748441a62d8e0fa +01e4501e0a178998 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/nullable.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/nullable.md index 7ea46b699ca..eb833dc16a6 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/nullable.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/nullable.md @@ -1,33 +1,34 @@ --- -'description': 'ClickHouse 中 Nullable 数据类型修饰符的文档' +'description': '关于 ClickHouse 中 Nullable 数据类型修饰符的文档' 'sidebar_label': 'Nullable(T)' 'sidebar_position': 44 'slug': '/sql-reference/data-types/nullable' 'title': 'Nullable(T)' +'doc_type': 'reference' --- # Nullable(T) -允许存储特殊标记([NULL](../../sql-reference/syntax.md)),表示“缺失值”,以及 `T` 允许的正常值。例如,`Nullable(Int8)` 类型的列可以存储 `Int8` 类型的值,而没有值的行将存储 `NULL`。 +允许存储特殊标记 ([NULL](../../sql-reference/syntax.md)),表示“缺失值”,以及 `T` 允许的正常值。例如,一个 `Nullable(Int8)` 类型的列可以存储 `Int8` 类型的值,而没有值的行将存储 `NULL`。 `T` 不能是任何复合数据类型 [Array](../../sql-reference/data-types/array.md)、[Map](../../sql-reference/data-types/map.md) 和 [Tuple](../../sql-reference/data-types/tuple.md),但复合数据类型可以包含 `Nullable` 类型的值,例如 `Array(Nullable(Int8))`。 `Nullable` 类型字段不能包含在表索引中。 -`NULL` 是任何 `Nullable` 类型的默认值,除非在 ClickHouse 服务器配置中另行指定。 +`NULL` 是任何 `Nullable` 类型的默认值,除非在 ClickHouse 服务器配置中另有指定。 ## Storage Features {#storage-features} -为了在表列中存储 `Nullable` 类型值,ClickHouse 除了存储值的常规文件外,还使用一个包含 `NULL` 掩码的单独文件。掩码文件中的条目允许 ClickHouse 区分每个表行中相应数据类型的 `NULL` 和默认值。由于额外的文件,`Nullable` 列比类似的普通列消耗更多的存储空间。 +为了在表列中存储 `Nullable` 类型的值,ClickHouse 使用一个单独的文件,带有 `NULL` 掩码,此外还有正常值的文件。掩码文件中的条目使 ClickHouse 能够区分 `NULL` 和每个表行对应数据类型的默认值。由于有额外的文件,`Nullable` 列相比于类似的普通列消耗更多的存储空间。 :::note -使用 `Nullable` 几乎总是会对性能产生负面影响,请在设计数据库时牢记这一点。 +使用 `Nullable` 几乎总是会对性能产生负面影响,在设计数据库时要牢记这一点。 ::: ## Finding NULL {#finding-null} -可以通过使用 `null` 子列而不读取整个列来找到列中的 `NULL` 值。它在相应的值为 `NULL` 时返回 `1`,否则返回 `0`。 +可以通过使用 `null` 子列而无需读取整个列来查找列中的 `NULL` 值。如果相应的值是 `NULL`,则返回 `1`,否则返回 `0`。 **示例** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/nullable.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/nullable.md.hash index db4ec47d1b7..dbdbe6cb997 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/nullable.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/nullable.md.hash @@ -1 +1 @@ -b4d2c773a239ef4b +0dbe0c02a22260bb diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/qbit.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/qbit.md new file mode 100644 index 00000000000..f2864b7737f --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/qbit.md @@ -0,0 +1,79 @@ +--- +'description': 'ClickHouse 中 QBit 数据类型的文档,它允许对近似向量搜索进行细粒度量化' +'keywords': +- 'qbit' +- 'data type' +'sidebar_label': 'QBit' +'sidebar_position': 64 +'slug': '/sql-reference/data-types/qbit' +'title': 'QBit 数据类型' +'doc_type': 'reference' +--- + +import ExperimentalBadge from '@theme/badges/ExperimentalBadge'; + + + +`QBit` 数据类型重新组织了向量存储,以便进行更快速的近似搜索。它不是将每个向量的元素一起存储,而是将所有向量中相同的二进制位位置分组。这可以以全精度存储向量,同时让你选择搜索时的细粒度量化级别:读取 fewer bits 以减少 I/O 和加快计算,或者读取更多 bits 以提高准确性。你将获得量化带来的数据传输和计算的速度优势,但所有原始数据在需要时依然可用。 + +:::note +`QBit` 数据类型及其相关的距离函数目前仍处于实验阶段。 +要启用它们,请首先运行 `SET allow_experimental_qbit_type = 1`。 +如果遇到问题,请在 [ClickHouse 代码库](https://github.com/clickhouse/clickhouse/issues) 中打开一个问题。 +::: + +要声明一个 `QBit` 类型的列,请使用以下语法: + +```sql +column_name QBit(element_type, dimension) +``` + +* `element_type` – 每个向量元素的类型。允许的类型有 `BFloat16`、`Float32` 和 `Float64` +* `dimension` – 每个向量中的元素数量 + +## 创建 QBit {#creating-qbit} + +在表列定义中使用 `QBit` 类型: + +```sql +CREATE TABLE test (id UInt32, vec QBit(Float32, 8)) ENGINE = Memory; +INSERT INTO test VALUES (1, [1, 2, 3, 4, 5, 6, 7, 8]), (2, [9, 10, 11, 12, 13, 14, 15, 16]); +SELECT vec FROM test ORDER BY id; +``` + +```text +┌─vec──────────────────────┐ +│ [1,2,3,4,5,6,7,8] │ +│ [9,10,11,12,13,14,15,16] │ +└──────────────────────────┘ +``` + +## QBit 子列 {#qbit-subcolumns} + +`QBit` 实现了一种子列访问模式,允许你访问存储向量的单个位平面。可以使用 `.N` 语法访问每个比特位置,其中 `N` 是比特位置: + +```sql +CREATE TABLE test (id UInt32, vec QBit(Float32, 8)) ENGINE = Memory; +INSERT INTO test VALUES (1, [0, 0, 0, 0, 0, 0, 0, 0]); +INSERT INTO test VALUES (1, [-0, -0, -0, -0, -0, -0, -0, -0]); +SELECT bin(vec.1) FROM test; +``` + +```text +┌─bin(tupleElement(vec, 1))─┐ +│ 00000000 │ +│ 11111111 │ +└───────────────────────────┘ +``` + +可访问的子列数取决于元素类型: + +* `BFloat16`: 16 个子列 (1-16) +* `Float32`: 32 个子列 (1-32) +* `Float64`: 64 个子列 (1-64) + +## 向量搜索函数 {#vector-search-functions} + +这些是使用 `QBit` 数据类型进行向量相似度搜索的距离函数: + +* [`L2DistanceTransposed`](../functions/distance-functions.md#L2DistanceTransposed) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/qbit.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/qbit.md.hash new file mode 100644 index 00000000000..04f5197627d --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/qbit.md.hash @@ -0,0 +1 @@ +6cfb3ad855c9b27d diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/simpleaggregatefunction.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/simpleaggregatefunction.md index fed2e722e8f..ed8723ae85f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/simpleaggregatefunction.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/simpleaggregatefunction.md @@ -4,6 +4,7 @@ 'sidebar_position': 48 'slug': '/sql-reference/data-types/simpleaggregatefunction' 'title': 'SimpleAggregateFunction 类型' +'doc_type': 'reference' --- @@ -11,15 +12,15 @@ ## 描述 {#description} -`SimpleAggregateFunction` 数据类型存储聚合函数的中间状态,但不如 [`AggregateFunction`](../../sql-reference/data-types/aggregatefunction.md) 类型那样存储完整状态。 +`SimpleAggregateFunction` 数据类型存储了聚合函数的中间状态,但不包括其完整状态,如 [`AggregateFunction`](../../sql-reference/data-types/aggregatefunction.md) 类型所做的那样。 -此优化适用于满足以下属性的函数: +此优化可应用于满足以下属性的函数: -> 将函数 `f` 应用于行集 `S1 UNION ALL S2` 的结果,可以通过分别对行集的各个部分应用 `f`,然后再次将 `f` 应用于结果来获得: `f(S1 UNION ALL S2) = f(f(S1) UNION ALL f(S2))`。 +> 对于行集 `S1 UNION ALL S2`,应用函数 `f` 的结果可以通过分别对行集的部分应用 `f`,然后再对结果应用 `f` 得到:`f(S1 UNION ALL S2) = f(f(S1) UNION ALL f(S2))`。 -这个属性保证了部分聚合结果足以计算组合结果,因此我们不必存储和处理任何额外的数据。例如,`min` 或 `max` 函数的结果不需要额外的步骤来从中间步骤计算最终结果,而 `avg` 函数需要跟踪一个总和和一个计数,这将在最终的 `Merge` 步骤中进行除法以获取平均值,从而结合中间状态。 +该属性保证部分聚合结果足以计算组合结果,因此我们无需存储和处理任何额外数据。例如,`min` 或 `max` 函数的结果在从中间步骤计算最终结果时不需要额外步骤,而 `avg` 函数需要跟踪一个总和和一个计数,这将在最终的 `Merge` 步骤中进行除法以获得平均值。 -聚合函数值通常是通过在函数名后附加 [`-SimpleState`](/sql-reference/aggregate-functions/combinators#-simplestate) 组合器来调用聚合函数生成的。 +聚合函数的值通常是通过调用附有 [`-SimpleState`](/sql-reference/aggregate-functions/combinators#-simplestate) 组合器的聚合函数来生成的。 ## 语法 {#syntax} @@ -34,7 +35,7 @@ SimpleAggregateFunction(aggregate_function_name, types_of_arguments...) ## 支持的函数 {#supported-functions} -支持以下聚合函数: +以下聚合函数是受支持的: - [`any`](/sql-reference/aggregate-functions/reference/any) - [`any_respect_nulls`](/sql-reference/aggregate-functions/reference/any) @@ -55,9 +56,9 @@ SimpleAggregateFunction(aggregate_function_name, types_of_arguments...) - [`maxMap`](/sql-reference/aggregate-functions/reference/maxmap) :::note -`SimpleAggregateFunction(func, Type)` 的值具有相同的 `Type`,因此与 `AggregateFunction` 类型不同,无需应用 `-Merge` / `-State` 组合器。 +`SimpleAggregateFunction(func, Type)` 的值具有相同的 `Type`,因此与 `AggregateFunction` 类型不同,无需应用 `-Merge`/`-State` 组合器。 -`SimpleAggregateFunction` 类型在性能上优于相同聚合函数的 `AggregateFunction`。 +`SimpleAggregateFunction` 类型在相同聚合函数下比 `AggregateFunction` 类型具有更好的性能。 ::: ## 示例 {#example} @@ -67,5 +68,5 @@ CREATE TABLE simple (id UInt64, val SimpleAggregateFunction(sum, Double)) ENGINE ``` ## 相关内容 {#related-content} -- 博客: [在 ClickHouse 中使用聚合组合器](https://clickhouse.com/blog/aggregate-functions-combinators-in-clickhouse-for-arrays-maps-and-states) -- [AggregateFunction](/sql-reference/data-types/aggregatefunction) 类型。 +- 博客: [在 ClickHouse 中使用聚合组合器](https://clickhouse.com/blog/aggregate-functions-combinators-in-clickhouse-for-arrays-maps-and-states) - 博客: [在 ClickHouse 中使用聚合组合器](https://clickhouse.com/blog/aggregate-functions-combinators-in-clickhouse-for-arrays-maps-and-states) +- [`AggregateFunction`](/sql-reference/data-types/aggregatefunction) 类型。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/simpleaggregatefunction.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/simpleaggregatefunction.md.hash index 55deb101e1a..eade31b6900 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/simpleaggregatefunction.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/simpleaggregatefunction.md.hash @@ -1 +1 @@ -1d6ea6d731fbe856 +40fdf830a5cf5cbe diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/special-data-types/expression.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/special-data-types/expression.md index 09b61e1951f..5b127c85b8c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/special-data-types/expression.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/special-data-types/expression.md @@ -4,9 +4,10 @@ 'sidebar_position': 58 'slug': '/sql-reference/data-types/special-data-types/expression' 'title': '表达式' +'doc_type': 'reference' --- # 表达式 -表达式用于表示高阶函数中的 lambda。 +表达式用于在高阶函数中表示 lambda。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/special-data-types/expression.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/special-data-types/expression.md.hash index f0f047ffe2a..a562f721569 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/special-data-types/expression.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/special-data-types/expression.md.hash @@ -1 +1 @@ -88202d028a560791 +8637c68329e66a30 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/special-data-types/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/special-data-types/index.md index 805ebb7d0e0..ef1838c62d3 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/special-data-types/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/special-data-types/index.md @@ -1,12 +1,13 @@ --- -'description': '在 ClickHouse 中用于查询执行期间中间结果的特殊数据类型概述' +'description': '关于 ClickHouse 中用于查询执行过程中间结果的特殊数据类型的概述' 'sidebar_label': '特殊数据类型' 'sidebar_position': 55 'slug': '/sql-reference/data-types/special-data-types/' 'title': '特殊数据类型' +'doc_type': 'reference' --- # 特殊数据类型 -特殊数据类型值无法被序列化以保存到表中或在查询结果中输出,但可以在查询执行过程中作为中间结果使用。 +特殊数据类型的值不能序列化以存储在表中或在查询结果中输出,但可以在查询执行期间作为中间结果使用。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/special-data-types/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/special-data-types/index.md.hash index a44394f5b9f..54ab8c38bfa 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/special-data-types/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/special-data-types/index.md.hash @@ -1 +1 @@ -2eca333f354c3128 +d0d64ad1866f7121 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/special-data-types/interval.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/special-data-types/interval.md index fa131bb7ae4..6c524392c56 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/special-data-types/interval.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/special-data-types/interval.md @@ -1,22 +1,23 @@ --- 'description': 'Interval 特殊数据类型的文档' -'sidebar_label': '区间' +'sidebar_label': 'Interval' 'sidebar_position': 61 'slug': '/sql-reference/data-types/special-data-types/interval' -'title': '区间' +'title': 'Interval' +'doc_type': 'reference' --- -# 时间间隔 +# Interval -表示时间和日期间隔的数据类型族。结果类型为 [INTERVAL](/sql-reference/operators#interval) 操作符的结果类型。 +表示时间和日期区间的数据类型系列。结果类型来自于 [INTERVAL](/sql-reference/operators#interval) 操作符。 结构: -- 作为无符号整数值的时间间隔。 -- 间隔的类型。 +- 作为无符号整数值的时间区间。 +- 区间的类型。 -支持的间隔类型: +支持的区间类型: - `NANOSECOND` - `MICROSECOND` @@ -30,7 +31,7 @@ - `QUARTER` - `YEAR` -对于每种间隔类型,都有一个单独的数据类型。例如,`DAY` 间隔对应于 `IntervalDay` 数据类型: +对于每种区间类型,都有一个单独的数据类型。例如,`DAY` 区间对应于 `IntervalDay` 数据类型: ```sql SELECT toTypeName(INTERVAL 4 DAY) @@ -42,12 +43,12 @@ SELECT toTypeName(INTERVAL 4 DAY) └──────────────────────────────┘ ``` -## 使用备注 {#usage-remarks} +## 使用注意事项 {#usage-remarks} -您可以在与 [Date](../../../sql-reference/data-types/date.md) 和 [DateTime](../../../sql-reference/data-types/datetime.md) 类型值的算术运算中使用 `Interval` 类型的值。例如,您可以将当前时间加上 4 天: +您可以在与 [Date](../../../sql-reference/data-types/date.md) 和 [DateTime](../../../sql-reference/data-types/datetime.md) 类型值的算术操作中使用 `Interval` 类型的值。例如,您可以给当前时间加上 4 天: ```sql -SELECT now() as current_date_time, current_date_time + INTERVAL 4 DAY +SELECT now() AS current_date_time, current_date_time + INTERVAL 4 DAY ``` ```text @@ -56,7 +57,7 @@ SELECT now() as current_date_time, current_date_time + INTERVAL 4 DAY └─────────────────────┴───────────────────────────────┘ ``` -同时也可以同时使用多个间隔: +同时也可以同时使用多个区间: ```sql SELECT now() AS current_date_time, current_date_time + (INTERVAL 4 DAY + INTERVAL 3 HOUR) @@ -68,7 +69,7 @@ SELECT now() AS current_date_time, current_date_time + (INTERVAL 4 DAY + INTERVA └─────────────────────┴────────────────────────────────────────────────────────────────────┘ ``` -并比较具有不同间隔的值: +并比较不同区间的值: ```sql SELECT toIntervalMicrosecond(3600000000) = toIntervalHour(1); @@ -80,7 +81,7 @@ SELECT toIntervalMicrosecond(3600000000) = toIntervalHour(1); └─────────────────────────────────────────────────────────────┘ ``` -## 另请参见 {#see-also} +## 另请参阅 {#see-also} - [INTERVAL](/sql-reference/operators#interval) 操作符 - [toInterval](/sql-reference/functions/type-conversion-functions#tointervalyear) 类型转换函数 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/special-data-types/interval.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/special-data-types/interval.md.hash index 4e75660137c..d80c094b4f3 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/special-data-types/interval.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/special-data-types/interval.md.hash @@ -1 +1 @@ -6ec0d08c3d2951fb +bd1d076ea919a2ea diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/special-data-types/nothing.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/special-data-types/nothing.md index d15c90da5a5..47299f6c586 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/special-data-types/nothing.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/special-data-types/nothing.md @@ -1,19 +1,20 @@ --- -'description': 'Nothing 特殊数据类型的文档' +'description': 'Nothing特殊数据类型的文档' 'sidebar_label': 'Nothing' 'sidebar_position': 60 'slug': '/sql-reference/data-types/special-data-types/nothing' 'title': 'Nothing' +'doc_type': 'reference' --- # Nothing -此数据类型的唯一目的是表示不期望值的情况。因此,您无法创建 `Nothing` 类型的值。 +这种数据类型的唯一目的在于表示不期望有值的情况。因此,您不能创建 `Nothing` 类型的值。 -例如,文字 [NULL](/sql-reference/syntax#null) 的类型为 `Nullable(Nothing)`。关于 [Nullable](../../../sql-reference/data-types/nullable.md) 的更多信息请参见。 +例如,文字 [NULL](/sql-reference/syntax#null) 的类型是 `Nullable(Nothing)`。有关更多信息,请参见 [Nullable](../../../sql-reference/data-types/nullable.md)。 -`Nothing` 类型也可用于表示空数组: +`Nothing` 类型还可以用于表示空数组: ```sql SELECT toTypeName(array()) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/special-data-types/nothing.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/special-data-types/nothing.md.hash index ea8f6a9a5ab..b93e19d834d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/special-data-types/nothing.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/special-data-types/nothing.md.hash @@ -1 +1 @@ -4bbb49d93e8ad1a2 +cf9e44209785a397 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/special-data-types/set.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/special-data-types/set.md index 94393762638..fdd7901b513 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/special-data-types/set.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/special-data-types/set.md @@ -1,12 +1,13 @@ --- 'description': 'IN 表达式中使用的 Set 特殊数据类型的文档' -'sidebar_label': '集合' +'sidebar_label': 'Set' 'sidebar_position': 59 'slug': '/sql-reference/data-types/special-data-types/set' -'title': '集合' +'title': 'Set' +'doc_type': 'reference' --- -# 集合 +# Set -用于[IN](/sql-reference/operators/in)表达式的右半部分。 +用于 [IN](/sql-reference/operators/in) 表达式的右半部分。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/special-data-types/set.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/special-data-types/set.md.hash index 2518233656a..5de02c76943 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/special-data-types/set.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/special-data-types/set.md.hash @@ -1 +1 @@ -233603b392da598a +0a1b335ff6724878 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/string.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/string.md index 472e121c605..b589bc8363f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/string.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/string.md @@ -1,26 +1,27 @@ --- -'description': 'ClickHouse 中 String 数据类型的文档' -'sidebar_label': '字符串' +'description': 'ClickHouse 中的 String 数据类型文档' +'sidebar_label': 'String' 'sidebar_position': 8 'slug': '/sql-reference/data-types/string' 'title': '字符串' +'doc_type': 'reference' --- -# String +# 字符串 -字符串的长度可以是任意的。长度没有限制。值可以包含任意字节集合,包括空字节。 -String 类型替代了其他数据库管理系统中的类型 VARCHAR、BLOB、CLOB 等。 +长度可变的字符串。长度没有限制。该值可以包含任意的字节集,包括空字节。 +String 类型替代了其他数据库管理系统中的 VARCHAR、BLOB、CLOB 等类型。 -在创建表时,可以为字符串字段设置数值参数(例如 `VARCHAR(255)`),但 ClickHouse 会忽略它们。 +在创建表时,可以为字符串字段设置数字参数(例如 `VARCHAR(255)`),但 ClickHouse 会忽略这些参数。 别名: -- `String` — `LONGTEXT`、`MEDIUMTEXT`、`TINYTEXT`、`TEXT`、`LONGBLOB`、`MEDIUMBLOB`、`TINYBLOB`、`BLOB`、`VARCHAR`、`CHAR`、`CHAR LARGE OBJECT`、`CHAR VARYING`、`CHARACTER LARGE OBJECT`、`CHARACTER VARYING`、`NCHAR LARGE OBJECT`、`NCHAR VARYING`、`NATIONAL CHARACTER LARGE OBJECT`、`NATIONAL CHARACTER VARYING`、`NATIONAL CHAR VARYING`、`NATIONAL CHARACTER`、`NATIONAL CHAR`、`BINARY LARGE OBJECT`、`BINARY VARYING`, +- `String` — `LONGTEXT`、`MEDIUMTEXT`、`TINYTEXT`、`TEXT`、`LONGBLOB`、`MEDIUMBLOB`、`TINYBLOB`、`BLOB`、`VARCHAR`、`CHAR`、`CHAR LARGE OBJECT`、`CHAR VARYING`、`CHARACTER LARGE OBJECT`、`CHARACTER VARYING`、`NCHAR LARGE OBJECT`、`NCHAR VARYING`、`NATIONAL CHARACTER LARGE OBJECT`、`NATIONAL CHARACTER VARYING`、`NATIONAL CHAR VARYING`、`NATIONAL CHARACTER`、`NATIONAL CHAR`、`BINARY LARGE OBJECT`、`BINARY VARYING`、 -## Encodings {#encodings} +## 编码 {#encodings} -ClickHouse 没有编码的概念。字符串可以包含任意字节集合,这些字节以原样存储和输出。 -如果需要存储文本,建议使用 UTF-8 编码。最起码,如果您的终端使用 UTF-8(如推荐那样),您可以在不进行转换的情况下读取和写入值。 -同样,某些操作字符串的函数有单独的变体,其假设字符串包含一组表示 UTF-8 编码文本的字节。 -例如, [length](../functions/string-functions.md#length) 函数计算字符串在字节上的长度,而 [lengthUTF8](../functions/string-functions.md#lengthutf8) 函数计算字符串在 Unicode 代码点上的长度,假设值是 UTF-8 编码的。 +ClickHouse 没有编码的概念。字符串可以包含任意的字节集,这些字节以原样存储和输出。 +如果需要存储文本,我们建议使用 UTF-8 编码。至少,如果您的终端使用 UTF-8(如推荐的那样),您可以在不进行转换的情况下读取和写入您的值。 +同样,某些用于处理字符串的函数有不同的变体,假设字符串包含代表 UTF-8 编码文本的一组字节。 +例如,[length](../functions/string-functions.md#length) 函数计算字符串的字节长度,而 [lengthUTF8](../functions/string-functions.md#lengthutf8) 函数计算字符串在 Unicode 代码点中的长度,假设该值为 UTF-8 编码。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/string.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/string.md.hash index 0a3bb0e0d5e..0761d05769a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/string.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/string.md.hash @@ -1 +1 @@ -32352246e3d0895c +1fb9296335628cbb diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/time.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/time.md index 20fd6fc6fb2..d11f505df56 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/time.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/time.md @@ -1,47 +1,53 @@ --- -'description': 'ClickHouse 中 Time 数据类型的文档,它以秒级精度存储时间范围' +'description': 'ClickHouse 中 Time 数据类型的文档,它以秒的精度存储时间范围' 'slug': '/sql-reference/data-types/time' 'sidebar_position': 15 -'sidebar_label': '时间' -'title': '时间' +'sidebar_label': 'Time' +'title': 'Time' +'doc_type': 'reference' --- -# 时间 +# Time -`Time` 数据类型用于存储独立于任何日历日期的时间值。它非常适合表示日常日程、事件时间或任何只需时间组件(小时、分钟、秒)的情况。 +数据类型 `Time` 表示具有小时、分钟和秒组成部分的时间。它独立于任何日历日期,适用于不需要日期、月份和年份组成部分的值。 语法: ```sql -Time() +Time ``` -支持的值范围:\[-999:59:59, 999:59:59\]。 +文本表示范围:[-999:59:59, 999:59:59]。 分辨率:1秒。 -## 速度 {#speed} +## 实现细节 {#implementation-details} -在 _大多数_ 情况下,`Date` 数据类型比 `Time` 更快。但 `Time` 数据类型与 `DateTime` 数据类型的速度大致相同。 +**表示和性能**。 +数据类型 `Time` 内部存储一个编码秒数的带符号32位整数。类型为 `Time` 和 `DateTime` 的值具有相同的字节大小,因此性能可比较。 -由于实现细节,`Time` 和 `DateTime` 类型需要4个字节的存储,而 `Date` 需要2个字节。然而,当数据库对数据进行压缩时,这种差异会被放大。 +**规范化**。 +在解析字符串为 `Time` 时,时间组成部分是被规范化而不是被验证的。例如,`25:70:70` 被解释为 `26:11:10`。 -## 使用备注 {#usage-remarks} +**负值**。 +支持并保留前导负号。负值通常来自对 `Time` 值的算术运算。对于 `Time` 类型,负输入在文本(例如,`'-01:02:03'`)和数字输入(例如,`-3723`)中都被保留。 -时间点以 [Unix 时间戳](https://en.wikipedia.org/wiki/Unix_time) 的形式保存,与时区或夏令时无关。 +**饱和**。 +一天中的时间组件被限制在范围[-999:59:59, 999:59:59]内。超出999小时(或低于-999)的值通过文本表示为 `999:59:59`(或 `-999:59:59`)。 -**注意:** `Time` 数据类型不考虑时区。它表示一个独立的时间值,不带有任何日期或区域偏移上下文。尝试对 `Time` 列应用或更改时区是无效的,并且不支持。 +**时区**。 +`Time` 不支持时区,即 `Time` 值在没有区域上下文的情况下被解释。将时区指定为 `Time` 的类型参数或在值创建期间会引发错误。同样,尝试在 `Time` 列上应用或更改时区也不被支持,结果会导致错误。`Time` 值不会在不同的时区下被静默重新解释。 ## 示例 {#examples} -**1.** 创建一个带有 `Time` 类型列的表并插入数据: +**1.** 创建一个具有 `Time` 类型列的表并向其中插入数据: ```sql -CREATE TABLE dt +CREATE TABLE tab ( - `time` Time, - `event_id` UInt8 + `event_id` UInt8, + `time` Time ) ENGINE = TinyLog; ``` @@ -49,64 +55,65 @@ ENGINE = TinyLog; ```sql -- Parse Time -- - from string, --- - from integer interpreted as number of seconds since 1970-01-01. -INSERT INTO dt VALUES ('100:00:00', 1), (12453, 3); +-- - from integer interpreted as number of seconds since 00:00:00. +INSERT INTO tab VALUES (1, '14:30:25'), (2, 52225); -SELECT * FROM dt; +SELECT * FROM tab ORDER BY event_id; ``` ```text - ┌──────time─┬─event_id─┐ -1. │ 100:00:00 │ 1 │ -2. │ 003:27:33 │ 3 │ - └───────────┴──────────┘ + ┌─event_id─┬──────time─┐ +1. │ 1 │ 14:30:25 │ +2. │ 2 │ 14:30:25 │ + └──────────┴───────────┘ ``` -**2.** 基于 `Time` 值进行过滤 +**2.** 对 `Time` 值进行过滤 ```sql -SELECT * FROM dt WHERE time = toTime('100:00:00') +SELECT * FROM tab WHERE time = toTime('14:30:25') ``` ```text - ┌──────time─┬─event_id─┐ -1. │ 100:00:00 │ 1 │ - └───────────┴──────────┘ + ┌─event_id─┬──────time─┐ +1. │ 1 │ 14:30:25 │ +2. │ 2 │ 14:30:25 │ + └──────────┴───────────┘ ``` -`Time` 列值可以使用 `WHERE` 子句中的字符串值进行过滤。它将自动转换为 `Time`: +`Time` 列的值可以使用 `WHERE` 谓词中的字符串值进行过滤。它将自动转换为 `Time`: ```sql -SELECT * FROM dt WHERE time = '100:00:00' +SELECT * FROM tab WHERE time = '14:30:25' ``` ```text - ┌──────time─┬─event_id─┐ -1. │ 100:00:00 │ 1 │ - └───────────┴──────────┘ + ┌─event_id─┬──────time─┐ +1. │ 1 │ 14:30:25 │ +2. │ 2 │ 14:30:25 │ + └──────────┴───────────┘ ``` -**3.** 获取 `Time` 类型列的时区: +**3.** 检查结果类型: ```sql -SELECT toTime(now()) AS column, toTypeName(column) AS x +SELECT CAST('14:30:25' AS Time) AS column, toTypeName(column) AS type ``` ```text - ┌────column─┬─x────┐ -1. │ 018:55:15 │ Time │ + ┌────column─┬─type─┐ +1. │ 14:30:25 │ Time │ └───────────┴──────┘ ``` - -## 另请参阅 {#see-also} +## 另请参见 {#see-also} - [类型转换函数](../functions/type-conversion-functions.md) -- [处理日期和时间的函数](../functions/date-time-functions.md) -- [处理数组的函数](../functions/array-functions.md) -- [设置 `date_time_input_format`](../../operations/settings/settings-formats.md#date_time_input_format) -- [设置 `date_time_output_format`](../../operations/settings/settings-formats.md#date_time_output_format) -- [服务器配置参数 `timezone`](../../operations/server-configuration-parameters/settings.md#timezone) -- [设置 `session_timezone`](../../operations/settings/settings.md#session_timezone) -- [`DateTime` 数据类型](datetime.md) -- [`Date` 数据类型](date.md) +- [用于处理日期和时间的函数](../functions/date-time-functions.md) +- [用于处理数组的函数](../functions/array-functions.md) +- [`date_time_input_format` 设置](../../operations/settings/settings-formats.md#date_time_input_format) +- [`date_time_output_format` 设置](../../operations/settings/settings-formats.md#date_time_output_format) +- [`timezone` 服务器配置参数](../../operations/server-configuration-parameters/settings.md#timezone) +- [`session_timezone` 设置](../../operations/settings/settings.md#session_timezone) +- [类型 `DateTime`](datetime.md) +- [类型 `Date`](date.md) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/time.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/time.md.hash index 3d1cfbb7f94..f148c1cd781 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/time.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/time.md.hash @@ -1 +1 @@ -29d9e49684408014 +f5f4f2ec42a06e72 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/time64.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/time64.md index 9d06fc8cd0f..3ecd9209bc2 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/time64.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/time64.md @@ -1,18 +1,20 @@ --- -'description': 'ClickHouse中Time64数据类型的文档,存储具有亚秒级精度的时间范围' +'description': 'ClickHouse中Time64数据类型的文档,它以亚秒精度存储时间范围' 'slug': '/sql-reference/data-types/time64' 'sidebar_position': 17 'sidebar_label': 'Time64' 'title': 'Time64' +'doc_type': 'reference' --- # Time64 -Time64 数据类型允许存储具有亚秒精度的时间值。与 DateTime64 不同,它不包括日历日期,仅表示时间。精度定义了存储值在小数秒中的分辨率。 +数据类型 `Time64` 表示一天中的时间,精确到分秒。 +它没有日历日期组件(天,月,年)。 +`precision` 参数定义了小数位数,因此也定义了刻度大小。 -刻度大小(精度):10-precision秒。有效范围:[ 0 : 9 ]。 -通常使用 - 3(毫秒)、6(微秒)、9(纳秒)。 +刻度大小(精度):10-precision 秒。有效范围:0..9。常见选择包括 3(毫秒)、6(微秒)和 9(纳秒)。 **语法:** @@ -20,89 +22,113 @@ Time64 数据类型允许存储具有亚秒精度的时间值。与 DateTime64 Time64(precision) ``` -在内部,Time64 以从一天开始(000:00:00.000000000)以来的 Int64 类型的刻度数存储数据。刻度分辨率由精度参数决定。可选择在列级别指定时区,这会影响时间值在文本格式中的解释和显示方式。 +在内部,`Time64` 存储一个带符号的 64 位十进制(Decimal64)表示的小数秒数。 +刻度分辨率由 `precision` 参数决定。 +不支持时区:使用 `Time64` 指定时区将导致错误。 -与 DateTime64 不同,Time64 没有存储日期组件,这意味着它仅表示时间。详细信息请参见 [Time](../../sql-reference/data-types/time.md)。 +与 `DateTime64` 不同,`Time64` 不存储日期组件。 +另请参阅 [`Time`](../../sql-reference/data-types/time.md)。 -支持的值范围:\[000:00:00, 999:59:59.99999999\] +文本表示范围:对于 `precision = 3`,范围为 [-999:59:59.000, 999:59:59.999]。一般来说,最小值为 `-999:59:59`,最大值为 `999:59:59`,精确到 `precision` 小数位(对于 `precision = 9`,最小值为 `-999:59:59.999999999`)。 + +## 实现细节 {#implementation-details} + +**表示**。 +带符号的 `Decimal64` 值,计算带 `precision` 小数位的秒数。 + +**规范化**。 +在将字符串解析为 `Time64` 时,时间组件被规范化而不是验证。 +例如,`25:70:70` 被解析为 `26:11:10`。 + +**负值**。 +支持并保留前导负号。 +负值通常源自对 `Time64` 值的算术操作。 +对于 `Time64`,负输入在文本(例如,`'-01:02:03.123'`)和数字输入(例如,`-3723.123`)中都被保留。 + +**饱和**。 +在转换为组件或序列化为文本时,时间组件被限制在范围 [-999:59:59.xxx, 999:59:59.xxx] 内。 +存储的数值可能超出此范围;但是,任何组件提取(小时、分钟、秒)和文本表示使用的是饱和值。 + +**时区**。 +`Time64` 不支持时区。 +在创建 `Time64` 类型或值时指定时区将导致错误。 +同样,尝试在 `Time64` 列上应用或更改时区不被支持,并会导致错误。 ## 示例 {#examples} -1. 创建一个包含 `Time64` 类型列的表并向其插入数据: +1. 创建带有 `Time64` 类型列的表并插入数据: ```sql -CREATE TABLE t64 +CREATE TABLE tab64 ( - `timestamp` Time64(3), - `event_id` UInt8 + `event_id` UInt8, + `time` Time64(3) ) ENGINE = TinyLog; ``` ```sql --- Parse Time --- - from integer interpreted as number of seconds since 1970-01-01. +-- Parse Time64 -- - from string, -INSERT INTO t64 VALUES (15463123, 1), (154600.123, 2), ('100:00:00', 3); +-- - from a number of seconds since 00:00:00 (fractional part according to precision). +INSERT INTO tab64 VALUES (1, '14:30:25'), (2, 52225.123), (3, '14:30:25'); -SELECT * FROM t64; +SELECT * FROM tab64 ORDER BY event_id; ``` ```text - ┌─────timestamp─┬─event_id─┐ -1. │ 004:17:43.123 │ 1 │ -2. │ 042:56:40.123 │ 2 │ -3. │ 100:00:00.000 │ 3 │ - └───────────────┴──────────┘ + ┌─event_id─┬────────time─┐ +1. │ 1 │ 14:30:25.000 │ +2. │ 2 │ 14:30:25.123 │ +3. │ 3 │ 14:30:25.000 │ + └──────────┴──────────────┘ ``` -2. 在 `Time64` 值上进行过滤 +2. 对 `Time64` 值进行过滤 ```sql -SELECT * FROM t64 WHERE timestamp = toTime64('100:00:00', 3); +SELECT * FROM tab64 WHERE time = toTime64('14:30:25', 3); ``` ```text - ┌─────timestamp─┬─event_id─┐ -1. │ 100:00:00.000 │ 3 │ - └───────────────┴──────────┘ + ┌─event_id─┬────────time─┐ +1. │ 1 │ 14:30:25.000 │ +2. │ 3 │ 14:30:25.000 │ + └──────────┴──────────────┘ ``` -与 `Time` 不同,`Time64` 值不会自动从 `String` 转换。 - ```sql -SELECT * FROM t64 WHERE timestamp = toTime64(154600.123, 3); +SELECT * FROM tab64 WHERE time = toTime64(52225.123, 3); ``` ```text - ┌─────timestamp─┬─event_id─┐ -1. │ 042:56:40.123 │ 2 │ - └───────────────┴──────────┘ + ┌─event_id─┬────────time─┐ +1. │ 2 │ 14:30:25.123 │ + └──────────┴──────────────┘ ``` -与插入相反,`toTime64` 函数将把所有值视为十进制变体,因此精度需要在小数点后给出。 +注意:`toTime64` 根据指定的精度将数字字面量解析为带小数部分的秒数,因此请显式提供预期的小数位。 -3. 获取 `Time64` 类型值的时区: +3. 检查结果类型: ```sql -SELECT toTime64(now(), 3) AS column, toTypeName(column) AS x; +SELECT CAST('14:30:25.250' AS Time64(3)) AS column, toTypeName(column) AS type; ``` ```text - ┌────────column─┬─x─────────┐ -1. │ 019:14:16.000 │ Time64(3) │ + ┌────────column─┬─type──────┐ +1. │ 14:30:25.250 │ Time64(3) │ └───────────────┴───────────┘ ``` - -**相关内容** +**参见** - [类型转换函数](../../sql-reference/functions/type-conversion-functions.md) - [处理日期和时间的函数](../../sql-reference/functions/date-time-functions.md) - [`date_time_input_format` 设置](../../operations/settings/settings-formats.md#date_time_input_format) -- [ `date_time_output_format` 设置](../../operations/settings/settings-formats.md#date_time_output_format) -- [ `timezone` 服务器配置参数](../../operations/server-configuration-parameters/settings.md#timezone) -- [ `session_timezone` 设置](../../operations/settings/settings.md#session_timezone) +- [`date_time_output_format` 设置](../../operations/settings/settings-formats.md#date_time_output_format) +- [服务器配置参数 `timezone`](../../operations/server-configuration-parameters/settings.md#timezone) +- [会话设置 `session_timezone`](../../operations/settings/settings.md#session_timezone) - [处理日期和时间的运算符](../../sql-reference/operators/index.md#operators-for-working-with-dates-and-times) - [`Date` 数据类型](../../sql-reference/data-types/date.md) - [`Time` 数据类型](../../sql-reference/data-types/time.md) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/time64.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/time64.md.hash index 81a28914ae1..b83490a2fb2 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/time64.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/time64.md.hash @@ -1 +1 @@ -3d9b54eb488d89e1 +44b10b3c92ce1603 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/tuple.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/tuple.md index e75c81415e3..04b09609065 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/tuple.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/tuple.md @@ -1,23 +1,24 @@ --- 'description': 'ClickHouse 中 Tuple 数据类型的文档' -'sidebar_label': '元组(T1, T2, ... )' +'sidebar_label': 'Tuple(T1, T2, ... )' 'sidebar_position': 34 'slug': '/sql-reference/data-types/tuple' -'title': '元组(T1, T2, ... )' +'title': 'Tuple(T1, T2, ... )' +'doc_type': 'reference' --- # Tuple(T1, T2, ...) -一个元组由多个元素组成,每个元素都有其单独的 [类型](/sql-reference/data-types)。元组必须至少包含一个元素。 +一个元素的元组,每个元素都有一个单独的 [类型](/sql-reference/data-types)。元组必须至少包含一个元素。 -元组用于临时列分组。在查询中使用 IN 表达式时,可以对列进行分组,并用于指定某些 lambda 函数的正式参数。有关更多信息,请参见 [IN 操作符](../../sql-reference/operators/in.md) 和 [高阶函数](/sql-reference/functions/overview#higher-order-functions) 部分。 +元组用于临时列分组。当在查询中使用 IN 表达式时,可以对列进行分组,并用于指定 lambda 函数的某些形式参数。有关更多信息,请参见 [IN 运算符](../../sql-reference/operators/in.md) 和 [高阶函数](/sql-reference/functions/overview#higher-order-functions) 部分。 -元组可以作为查询的结果。在这种情况下,对于除了 JSON 以外的文本格式,值在括号中用逗号分隔。在 JSON 格式中,元组输出为数组(在方括号中)。 +元组可以是查询的结果。在这种情况下,除了 JSON 的文本格式外,值在括号中以逗号分隔。在 JSON 格式中,元组作为数组输出(在方括号中)。 ## 创建元组 {#creating-tuples} -您可以使用函数来创建元组: +您可以使用一个函数来创建一个元组: ```sql tuple(T1, T2, ...) @@ -35,7 +36,7 @@ SELECT tuple(1, 'a') AS x, toTypeName(x) └─────────┴───────────────────────────┘ ``` -一个元组可以包含单个元素 +元组可以包含一个单独的元素 示例: @@ -65,7 +66,7 @@ SELECT (1, 'a') AS x, (today(), rand(), 'someString') AS y, ('a') AS not_a_tuple ## 数据类型检测 {#data-type-detection} -在动态创建元组时,ClickHouse 将推断元组参数的类型为能够容纳提供的参数值的最小类型。如果值为 [NULL](/operations/settings/formats#input_format_null_as_default),则推断的类型为 [Nullable](../../sql-reference/data-types/nullable.md)。 +在动态创建元组时,ClickHouse 会将元组参数的类型推断为可以容纳提供的参数值的最小类型。如果值为 [NULL](/operations/settings/formats#input_format_null_as_default),则推断的类型为 [Nullable](../../sql-reference/data-types/nullable.md)。 自动数据类型检测的示例: @@ -81,7 +82,7 @@ SELECT tuple(1, NULL) AS x, toTypeName(x) ## 引用元组元素 {#referring-to-tuple-elements} -可以通过名称或索引来引用元组元素: +可以通过名称或索引引用元组元素: ```sql CREATE TABLE named_tuples (`a` Tuple(s String, i Int64)) ENGINE = Memory; @@ -107,7 +108,7 @@ SELECT a.2 FROM named_tuples; -- by index ## 与元组的比较操作 {#comparison-operations-with-tuple} -两个元组通过从左到右依次比较其元素进行比较。如果第一个元组的元素大于(小于)第二个元组的对应元素,则第一个元组大于(小于)第二个元组,否则(如果两个元素相等),则比较下一个元素。 +两个元组通过顺序比较其从左到右的元素进行比较。如果第一个元组的某个元素大于(小于)第二个元组的相应元素,则第一个元组大于(小于)第二个元组;否则(两个元素相等),比较下一个元素。 示例: @@ -121,7 +122,7 @@ SELECT (1, 'z') > (1, 'a') c1, (2022, 01, 02) > (2023, 04, 02) c2, (1,2,3) = (3, └────┴────┴────┘ ``` -现实生活中的示例: +现实世界示例: ```sql CREATE TABLE test @@ -148,8 +149,6 @@ WHERE (year, month, day) > (2010, 1, 1); ┌─year─┬─month─┬─day─┐ │ 2022 │ 12 │ 31 │ └──────┴───────┴─────┘ - - CREATE TABLE test ( `key` Int64, diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/tuple.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/tuple.md.hash index 1a0a22b4d8e..66aa6dafa26 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/tuple.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/tuple.md.hash @@ -1 +1 @@ -ba33e6c91c1269e6 +fade784f303d6565 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/uuid.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/uuid.md index c3ec02ddabc..172d1000c28 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/uuid.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/uuid.md @@ -1,18 +1,19 @@ --- -'description': 'Documentation for UUID 数据类型 in ClickHouse' +'description': 'ClickHouse 中 UUID 数据类型的文档' 'sidebar_label': 'UUID' 'sidebar_position': 24 'slug': '/sql-reference/data-types/uuid' 'title': 'UUID' +'doc_type': 'reference' --- # UUID -一个通用唯一标识符(UUID)是一个用于标识记录的16字节值。有关UUID的详细信息,请参见 [Wikipedia](https://en.wikipedia.org/wiki/Universally_unique_identifier)。 +一个通用唯一标识符(UUID)是一个用于识别记录的16字节值。有关UUID的详细信息,请参阅 [Wikipedia](https://en.wikipedia.org/wiki/Universally_unique_identifier)。 -虽然存在不同的UUID变体(请参见 [这里](https://datatracker.ietf.org/doc/html/draft-ietf-uuidrev-rfc4122bis)),但ClickHouse并不验证插入的UUID是否符合特定的变体。 -UUID在内部被视为具有[8-4-4-4-12表示法](https://en.wikipedia.org/wiki/Universally_unique_identifier#Textual_representation)的16个随机字节序列,在SQL级别进行处理。 +虽然存在不同的UUID变体(见 [这里](https://datatracker.ietf.org/doc/html/draft-ietf-uuidrev-rfc4122bis)),但ClickHouse不验证插入的UUID是否符合特定的变体。 +UUID在内部被视为一系列16个随机字节,在SQL层级上以[8-4-4-4-12表示法](https://en.wikipedia.org/wiki/Universally_unique_identifier#Textual_representation)处理。 示例UUID值: @@ -20,14 +21,14 @@ UUID在内部被视为具有[8-4-4-4-12表示法](https://en.wikipedia.org/wiki/ 61f0c404-5cb3-11e7-907b-a6006ad3dba0 ``` -默认的UUID是全零。它在插入新记录但未指定UUID列值时使用,例如: +默认的UUID是全零值。例如,在插入新记录时,如果未指定UUID列的值,则会使用此值: ```text 00000000-0000-0000-0000-000000000000 ``` -由于历史原因,UUID按其后半部分进行排序。 -因此,UUID不应直接用于表的主键、排序键或分区键中。 +由于历史原因,UUID是按其后半部分排序的。 +因此,UUID不应直接用于表的主键、排序键或分区键。 示例: @@ -55,7 +56,7 @@ SELECT * FROM tab ORDER BY uuid; └──────────────────────────────────────┘ ``` -作为替代方案,可以将UUID转换为具有直观排序顺序的类型。 +作为一种解决方法,可以将UUID转换为具有直观排序顺序的类型。 使用转换为UInt128的示例: @@ -85,13 +86,13 @@ SELECT * FROM tab ORDER BY toUInt128(uuid); ## 生成UUID {#generating-uuids} -ClickHouse提供了 [generateUUIDv4](../../sql-reference/functions/uuid-functions.md) 函数,用于生成随机的UUID版本4值。 +ClickHouse提供了 [generateUUIDv4](../../sql-reference/functions/uuid-functions.md) 函数来生成随机的UUID版本4值。 ## 使用示例 {#usage-example} **示例 1** -此示例演示了创建一个带有UUID列的表并向该表插入值。 +此示例演示了创建一个带有UUID列的表并向该表插入一个值。 ```sql CREATE TABLE t_uuid (x UUID, y String) ENGINE=TinyLog @@ -111,7 +112,7 @@ SELECT * FROM t_uuid **示例 2** -在这个示例中,当记录被插入时,没有指定UUID列的值,即插入默认的UUID值: +在此示例中,插入记录时未指定UUID列值,即插入默认的UUID值: ```sql INSERT INTO t_uuid (y) VALUES ('Example 2') @@ -130,4 +131,4 @@ SELECT * FROM t_uuid UUID数据类型仅支持[字符串](../../sql-reference/data-types/string.md)数据类型也支持的函数(例如,[min](/sql-reference/aggregate-functions/reference/min)、[max](/sql-reference/aggregate-functions/reference/max)和[count](/sql-reference/aggregate-functions/reference/count))。 -UUID数据类型不支持算术操作(例如,[abs](/sql-reference/functions/arithmetic-functions#abs))或聚合函数,如[sum](/sql-reference/aggregate-functions/reference/sum)和[avg](/sql-reference/aggregate-functions/reference/avg)。 +UUID数据类型不支持算术运算(例如,[abs](/sql-reference/functions/arithmetic-functions#abs))或聚合函数,如[sum](/sql-reference/aggregate-functions/reference/sum)和[avg](/sql-reference/aggregate-functions/reference/avg)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/uuid.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/uuid.md.hash index fff5ac28739..e7bf12c5614 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/uuid.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/uuid.md.hash @@ -1 +1 @@ -6ac284e604885d8f +8e752ad50ff83a34 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/variant.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/variant.md index dc2b0d26801..ce829945265 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/variant.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/variant.md @@ -1,20 +1,21 @@ --- -'description': 'ClickHouse中的Variant数据类型文档' +'description': 'ClickHouse 中 Variant 数据类型的文档' 'sidebar_label': 'Variant(T1, T2, ...)' 'sidebar_position': 40 'slug': '/sql-reference/data-types/variant' 'title': 'Variant(T1, T2, ...)' +'doc_type': 'reference' --- # Variant(T1, T2, ...) -此类型表示其他数据类型的并集。类型 `Variant(T1, T2, ..., TN)` 意味着该类型的每一行都有一个值,类型可以是 `T1`、`T2`、... 或 `TN`,也可以是 `NULL` 值。 +此类型表示其他数据类型的联合。类型 `Variant(T1, T2, ..., TN)` 意味着此类型的每一行都有一个属于 `T1` 或 `T2` 或 ... 或 `TN` 的值,或者没有值(`NULL` 值)。 -嵌套类型的顺序无关紧要:Variant(T1, T2) = Variant(T2, T1)。嵌套类型可以是任意类型,但不能是 Nullable(...)、LowCardinality(Nullable(...)) 和 Variant(...) 类型。 +嵌套类型的顺序不重要:Variant(T1, T2) = Variant(T2, T1)。嵌套类型可以是任意类型,但不能是 Nullable(...)、LowCardinality(Nullable(...)) 和 Variant(...) 类型。 :::note -不建议将相似类型用作变体(例如,将不同数字类型作为 `Variant(UInt32, Int64)`,或将不同日期类型作为 `Variant(Date, DateTime)`),因为操作这些类型的值可能导致歧义。默认情况下,创建此类 `Variant` 类型将导致异常,但可以通过设置 `allow_suspicious_variant_types` 启用。 +不建议使用相似类型作为变体(例如不同的数值类型如 `Variant(UInt32, Int64)` 或不同的日期类型如 `Variant(Date, DateTime)`),因为处理此类类型的值可能会导致歧义。默认情况下,创建此类 `Variant` 类型将导致异常,但可以通过设置 `allow_suspicious_variant_types` 启用。 ::: ## 创建 Variant {#creating-variant} @@ -36,10 +37,10 @@ SELECT v FROM test; └───────────────┘ ``` -使用普通列进行 CAST: +从普通列使用 CAST: ```sql -SELECT toTypeName(variant) as type_name, 'Hello, World!'::Variant(UInt64, String, Array(UInt64)) as variant; +SELECT toTypeName(variant) AS type_name, 'Hello, World!'::Variant(UInt64, String, Array(UInt64)) as variant; ``` ```text @@ -48,7 +49,7 @@ SELECT toTypeName(variant) as type_name, 'Hello, World!'::Variant(UInt64, String └────────────────────────────────────────┴───────────────┘ ``` -当参数没有共同类型时,使用函数 `if/multiIf`(必须启用设置 `use_variant_as_common_type`): +当参数没有公共类型时,使用函数 `if/multiIf`(应启用设置 `use_variant_as_common_type`): ```sql SET use_variant_as_common_type = 1; @@ -79,7 +80,7 @@ SELECT multiIf((number % 4) = 0, 42, (number % 4) = 1, [1, 2, 3], (number % 4) = └───────────────┘ ``` -如果数组元素/映射值没有共同类型,可以使用函数 'array/map'(必须启用设置 `use_variant_as_common_type`): +如果数组元素/映射值没有公共类型,可以使用函数 'array/map'(应启用设置 `use_variant_as_common_type`): ```sql SET use_variant_as_common_type = 1; @@ -107,11 +108,11 @@ SELECT map('a', range(number), 'b', number, 'c', 'str_' || toString(number)) as └───────────────────────────────┘ ``` -## 以子列形式读取 Variant 嵌套类型 {#reading-variant-nested-types-as-subcolumns} +## 作为子列读取 Variant 嵌套类型 {#reading-variant-nested-types-as-subcolumns} -Variant 类型支持通过类型名称作为子列从 Variant 列中读取单个嵌套类型。因此,如果你有列 `variant Variant(T1, T2, T3)`,可以使用语法 `variant.T2` 读取类型为 `T2` 的子列,如果 `T2` 可以被包裹在 `Nullable` 中,则此子列的类型为 `Nullable(T2)`,否则为 `T2`。此子列将与原始 `Variant` 列大小相同,并且在原始 `Variant` 列没有类型 `T2` 的所有行中将包含 `NULL` 值(或者如果 `T2` 不能被包裹在 `Nullable` 中,则为空值)。 +Variant 类型支持使用类型名称作为子列从 Variant 列中读取单个嵌套类型。因此,如果你有列 `variant Variant(T1, T2, T3)`,你可以使用语法 `variant.T2` 读取类型为 `T2` 的子列,如果 `T2` 可以在 `Nullable` 中,则此子列将具有类型 `Nullable(T2)`,否则为 `T2`。这个子列将与原始 `Variant` 列大小相同,并且在原始 `Variant` 列中没有 `T2` 类型的所有行中将包含 `NULL` 值(或空值,如果 `T2` 不能在 `Nullable` 中)。 -Variant 子列还可以通过函数 `variantElement(variant_column, type_name)` 读取。 +Variant 子列也可以使用函数 `variantElement(variant_column, type_name)` 读取。 示例: @@ -153,14 +154,14 @@ SELECT v, variantElement(v, 'String'), variantElement(v, 'UInt64'), variantEleme └───────────────┴─────────────────────────────┴─────────────────────────────┴────────────────────────────────────┘ ``` -要知道每一行存储了什么变体,可以使用函数 `variantType(variant_column)`。它返回每行的变体类型名称的 `Enum`(如果行是 `NULL` 则返回 `'None'`)。 +要知道每行存储的变体,可以使用函数 `variantType(variant_column)`。它返回一个 `Enum`,包含每行的变体类型名称(如果行是 `NULL` 则返回 `'None'`)。 示例: ```sql CREATE TABLE test (v Variant(UInt64, String, Array(UInt64))) ENGINE = Memory; INSERT INTO test VALUES (NULL), (42), ('Hello, World!'), ([1, 2, 3]); -SELECT variantType(v) from test; +SELECT variantType(v) FROM test; ``` ```text @@ -182,16 +183,16 @@ SELECT toTypeName(variantType(v)) FROM test LIMIT 1; └─────────────────────────────────────────────────────────────────────┘ ``` -## Variant 列与其他列的转换 {#conversion-between-a-variant-column-and-other-columns} +## Variant 列与其他列之间的转换 {#conversion-between-a-variant-column-and-other-columns} -可以对 `Variant` 类型的列执行 4 种可能的转换。 +可以对类型为 `Variant` 的列执行 4 种可能的转换。 ### 将字符串列转换为 Variant 列 {#converting-a-string-column-to-a-variant-column} -从 `String` 到 `Variant` 的转换是通过从字符串值解析出 `Variant` 类型的值进行的: +将 `String` 转换为 `Variant` 是通过解析字符串值中的 `Variant` 类型值来执行的: ```sql -SELECT '42'::Variant(String, UInt64) as variant, variantType(variant) as variant_type +SELECT '42'::Variant(String, UInt64) AS variant, variantType(variant) AS variant_type ``` ```text @@ -211,7 +212,7 @@ SELECT '[1, 2, 3]'::Variant(String, Array(UInt64)) as variant, variantType(varia ``` ```sql -SELECT CAST(map('key1', '42', 'key2', 'true', 'key3', '2020-01-01'), 'Map(String, Variant(UInt64, Bool, Date))') as map_of_variants, mapApply((k, v) -> (k, variantType(v)), map_of_variants) as map_of_variant_types``` +SELECT CAST(map('key1', '42', 'key2', 'true', 'key3', '2020-01-01'), 'Map(String, Variant(UInt64, Bool, Date))') AS map_of_variants, mapApply((k, v) -> (k, variantType(v)), map_of_variants) AS map_of_variant_types``` ``` ```text @@ -220,7 +221,7 @@ SELECT CAST(map('key1', '42', 'key2', 'true', 'key3', '2020-01-01'), 'Map(String └─────────────────────────────────────────────┴───────────────────────────────────────────────┘ ``` -要禁用从 `String` 到 `Variant` 的转换解析,可以禁用设置 `cast_string_to_dynamic_use_inference`: +要在从 `String` 转换为 `Variant` 时禁用解析,可以禁用设置 `cast_string_to_dynamic_use_inference`: ```sql SET cast_string_to_variant_use_inference = 0; @@ -238,7 +239,7 @@ SELECT '[1, 2, 3]'::Variant(String, Array(UInt64)) as variant, variantType(varia 可以将类型为 `T` 的普通列转换为包含该类型的 `Variant` 列: ```sql -SELECT toTypeName(variant) as type_name, [1,2,3]::Array(UInt64)::Variant(UInt64, String, Array(UInt64)) as variant, variantType(variant) as variant_name +SELECT toTypeName(variant) AS type_name, [1,2,3]::Array(UInt64)::Variant(UInt64, String, Array(UInt64)) as variant, variantType(variant) as variant_name ``` ```text @@ -247,7 +248,7 @@ SELECT toTypeName(variant) as type_name, [1,2,3]::Array(UInt64)::Variant(UInt64, └────────────────────────────────────────┴─────────┴───────────────┘ ``` -注意:从 `String` 类型的转换始终通过解析执行,如果你需要将 `String` 列转换为不进行解析的 `Variant` 的 `String` 变体,可以执行如下操作: +注意:从 `String` 类型的转换始终通过解析执行,如果需要将 `String` 列转换为不带解析的 `Variant` 的字符串变体,可以执行以下操作: ```sql SELECT '[1, 2, 3]'::Variant(String)::Variant(String, Array(UInt64), UInt64) as variant, variantType(variant) as variant_type ``` @@ -260,7 +261,7 @@ SELECT '[1, 2, 3]'::Variant(String)::Variant(String, Array(UInt64), UInt64) as v ### 将 Variant 列转换为普通列 {#converting-a-variant-column-to-an-ordinary-column} -可以将 `Variant` 列转换为普通列。在这种情况下,所有嵌套变体将被转换为目标类型: +可以将 `Variant` 列转换为普通列。在这种情况下,所有嵌套的变体将转换为目标类型: ```sql CREATE TABLE test (v Variant(UInt64, String)) ENGINE = Memory; @@ -276,9 +277,9 @@ SELECT v::Nullable(Float64) FROM test; └──────────────────────────────┘ ``` -### 将 Variant 转换为另一个 Variant {#converting-a-variant-to-another-variant} +### 将一个 Variant 转换为另一个 Variant {#converting-a-variant-to-another-variant} -可以将 `Variant` 列转换为另一个 `Variant` 列,但前提是目标 `Variant` 列包含原始 `Variant` 的所有嵌套类型: +可以将 `Variant` 列转换为另一个 `Variant` 列,但前提是目标 `Variant` 列包含来自原始 `Variant` 的所有嵌套类型: ```sql CREATE TABLE test (v Variant(UInt64, String)) ENGINE = Memory; @@ -296,7 +297,7 @@ SELECT v::Variant(UInt64, String, Array(UInt64)) FROM test; ## 从数据中读取 Variant 类型 {#reading-variant-type-from-the-data} -所有文本格式(TSV、CSV、CustomSeparated、Values、JSONEachRow 等)均支持读取 `Variant` 类型。在数据解析期间,ClickHouse 尝试将值插入最合适的变体类型。 +所有文本格式(TSV、CSV、CustomSeparated、Values、JSONEachRow 等)都支持读取 `Variant` 类型。在数据解析期间,ClickHouse 尝试将值插入最合适的变体类型。 示例: @@ -331,9 +332,9 @@ $$) `Variant` 类型的值只能与相同 `Variant` 类型的值进行比较。 -操作符 `<` 对于具有基础类型 `T1` 的值 `v1` 和具有基础类型 `T2` 的值 `v2` 的 `Variant(..., T1, ... T2, ...)` 类型的定义如下: -- 如果 `T1 = T2 = T`,则结果为 `v1.T < v2.T`(将比较基础值)。 -- 如果 `T1 != T2`,则结果为 `T1 < T2`(将比较类型名称)。 +运算符 `<` 对于底层类型为 `T1` 的值 `v1` 和底层类型为 `T2` 的值 `v2` 的结果定义如下: +- 如果 `T1 = T2 = T`,结果将是 `v1.T < v2.T`(将比较底层值)。 +- 如果 `T1 != T2`,结果将是 `T1 < T2`(将比较类型名称)。 示例: ```sql @@ -342,7 +343,7 @@ INSERT INTO test VALUES (42, 42), (42, 43), (42, 'abc'), (42, [1, 2, 3]), (42, [ ``` ```sql -SELECT v2, variantType(v2) as v2_type from test order by v2; +SELECT v2, variantType(v2) AS v2_type FROM test ORDER BY v2; ``` ```text @@ -357,7 +358,7 @@ SELECT v2, variantType(v2) as v2_type from test order by v2; ``` ```sql -SELECT v1, variantType(v1) as v1_type, v2, variantType(v2) as v2_type, v1 = v2, v1 < v2, v1 > v2 from test; +SELECT v1, variantType(v1) AS v1_type, v2, variantType(v2) AS v2_type, v1 = v2, v1 < v2, v1 > v2 FROM test; ``` ```text @@ -372,9 +373,9 @@ SELECT v1, variantType(v1) as v1_type, v2, variantType(v2) as v2_type, v1 = v2, ``` -如果需要找到具有特定 `Variant` 值的行,可以执行以下操作: +如果需要找到具有特定 `Variant` 值的行,可以执行以下操作之一: -- 将值转换为对应的 `Variant` 类型: +- 将值转换为相应的 `Variant` 类型: ```sql SELECT * FROM test WHERE v2 == [1,2,3]::Array(UInt32)::Variant(String, UInt64, Array(UInt32)); @@ -398,7 +399,7 @@ SELECT * FROM test WHERE v2.`Array(UInt32)` == [1,2,3] -- or using variantElemen └────┴─────────┘ ``` -有时可以通过检查变体类型来提供额外的检查,因为不能将复杂类型如 `Array/Map/Tuple` 的子列放在 `Nullable` 中,并且在具有不同类型的行上将替代为默认值而不是 `NULL`: +有时对变体类型进行额外检查可能是有用的,因为像 `Array/Map/Tuple` 这样的复杂类型无法在 `Nullable` 中,并且在具有不同类型的行上将具有默认值而不是 `NULL`: ```sql SELECT v2, v2.`Array(UInt32)`, variantType(v2) FROM test WHERE v2.`Array(UInt32)` == []; @@ -424,7 +425,7 @@ SELECT v2, v2.`Array(UInt32)`, variantType(v2) FROM test WHERE variantType(v2) = └────┴──────────────────┴─────────────────┘ ``` -**注意:** 不同数值类型的变体值被视为不同变体,且不彼此比较,而是比较它们的类型名称。 +**注意:** 具有不同数值类型的变体被视为不同的变体,并且不会相互比较,而是比较它们的类型名称。 示例: @@ -444,9 +445,9 @@ SELECT v, variantType(v) FROM test ORDER by v; └─────┴────────────────┘ ``` -**注意** 默认情况下,不允许在 `GROUP BY`/`ORDER BY` 键中使用 `Variant` 类型,如果你想使用它,请考虑其特殊比较规则并启用 `allow_suspicious_types_in_group_by`/`allow_suspicious_types_in_order_by` 设置。 +**注意** 默认情况下,`Variant` 类型不允许在 `GROUP BY`/`ORDER BY` 键中使用,如果你想使用它,考虑其特殊比较规则并启用 `allow_suspicious_types_in_group_by`/`allow_suspicious_types_in_order_by` 设置。 -## 与 Variant 的 JSONExtract 函数 {#jsonextract-functions-with-variant} +## 与 Variant 相关的 JSONExtract 函数 {#jsonextract-functions-with-variant} 所有 `JSONExtract*` 函数支持 `Variant` 类型: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/variant.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/variant.md.hash index a5172fe2b79..2264f45ea5f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/variant.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/data-types/variant.md.hash @@ -1 +1 @@ -f7c60f40e5baf934 +50bb8b4d0dbd4222 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/dictionaries/_snippet_dictionary_in_cloud.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/dictionaries/_snippet_dictionary_in_cloud.md index 8d9460de72d..0c5af0a3e74 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/dictionaries/_snippet_dictionary_in_cloud.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/dictionaries/_snippet_dictionary_in_cloud.md @@ -1,9 +1,4 @@ ---- -null -... ---- - :::tip -如果您在 ClickHouse Cloud 中使用字典,请使用 DDL 查询选项来创建您的字典,并以用户 `default` 创建字典。 -此外,请在 [Cloud Compatibility guide](/cloud/reference/cloud-compatibility.md) 中验证支持的字典源列表。 +如果您在使用 ClickHouse Cloud 的字典,请使用 DDL 查询选项来创建您的字典,并以用户 `default` 创建您的字典。 +此外,请核实在 [Cloud Compatibility guide](/whats-new/cloud-compatibility) 中支持的字典源列表。 ::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/dictionaries/_snippet_dictionary_in_cloud.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/dictionaries/_snippet_dictionary_in_cloud.md.hash index 9cc4bbccfbe..55d62ee156c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/dictionaries/_snippet_dictionary_in_cloud.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/dictionaries/_snippet_dictionary_in_cloud.md.hash @@ -1 +1 @@ -690616306087c292 +93bc59aa0c0c9499 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/dictionaries/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/dictionaries/index.md index 0587928d5db..a80d7e12a25 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/dictionaries/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/dictionaries/index.md @@ -1,9 +1,10 @@ --- -'description': 'ClickHouse 中外部字典功能的概述' +'description': 'ClickHouse中外部字典功能的概述' 'sidebar_label': '定义字典' 'sidebar_position': 35 'slug': '/sql-reference/dictionaries' 'title': '字典' +'doc_type': 'Reference' --- import SelfManaged from '@site/i18n/zh/docusaurus-plugin-content-docs/current/_snippets/_self_managed_only_no_roadmap.md'; @@ -13,51 +14,51 @@ import CloudNotSupportedBadge from '@theme/badges/CloudNotSupportedBadge'; # 字典 -字典是一个映射 (`key -> attributes`),方便用于各种类型的引用列表。 +字典是一个映射(`key -> attributes`),方便进行各种类型的参考列表。 -ClickHouse 支持用于操作字典的特殊函数,这些函数可以在查询中使用。与参考表的 `JOIN` 相比,使用函数处理字典更简单,更高效。 +ClickHouse 支持用于操作字典的特殊函数,可以在查询中使用。使用函数操作字典比使用与参考表的 `JOIN` 更容易和有效。 ClickHouse 支持: -- 带有 [一组函数](../../sql-reference/functions/ext-dict-functions.md) 的字典。 -- 带有特定 [一组函数](../../sql-reference/functions/ym-dict-functions.md) 的 [嵌入式字典](#embedded-dictionaries)。 +- 具有 [一组函数](../../sql-reference/functions/ext-dict-functions.md) 的字典。 +- 具有特定 [一组函数](../../sql-reference/functions/embedded-dict-functions.md) 的 [嵌入式字典](#embedded-dictionaries)。 :::tip 教程 -如果您刚开始接触 ClickHouse 的字典,可以查看我们涵盖该主题的教程。请查看 [这里](tutorial.md)。 +如果你刚开始使用 ClickHouse 的字典,我们有一个涵盖该主题的教程。请查看 [这里](tutorial.md)。 ::: -您可以从各种数据源添加自己的字典。字典的来源可以是 ClickHouse 表、本地文本或可执行文件、HTTP(S) 资源或其他 DBMS。有关更多信息,请参阅 "[字典源](#dictionary-sources)"。 +你可以从各种数据源添加自己的字典。字典的源可以是 ClickHouse 表、本地文本或可执行文件、HTTP(s) 资源或其他 DBMS。有关更多信息,请参见 "[字典源](#dictionary-sources)"。 ClickHouse: -- 在 RAM 中完全或部分存储字典。 +- 完全或部分地将字典存储在 RAM 中。 - 定期更新字典并动态加载缺失的值。换句话说,字典可以动态加载。 - 允许使用 xml 文件或 [DDL 查询](../../sql-reference/statements/create/dictionary.md) 创建字典。 字典的配置可以位于一个或多个 xml 文件中。配置路径在 [dictionaries_config](../../operations/server-configuration-parameters/settings.md#dictionaries_config) 参数中指定。 -字典可以在服务器启动时加载,也可以在首次使用时加载,这取决于 [dictionaries_lazy_load](../../operations/server-configuration-parameters/settings.md#dictionaries_lazy_load) 设置。 +字典可以在服务器启动时或首次使用时加载,具体取决于 [dictionaries_lazy_load](../../operations/server-configuration-parameters/settings.md#dictionaries_lazy_load) 设置。 -[dictionaries](/operations/system-tables/dictionaries) 系统表包含关于在服务器上配置的字典的信息。您可以在这里找到每个字典的信息: +[system.dictionaries](/operations/system-tables/dictionaries) 系统表包含配置在服务器上的字典的信息。对于每个字典,您可以找到: -- 字典状态。 +- 字典的状态。 - 配置参数。 -- 指标,如分配给字典的 RAM 量或自字典成功加载以来的查询次数。 +- 指标,例如分配给字典的 RAM 数量或自字典成功加载以来的查询次数。 ## 使用 DDL 查询创建字典 {#creating-a-dictionary-with-a-ddl-query} -字典可以使用 [DDL 查询](../../sql-reference/statements/create/dictionary.md) 创建,这是一种推荐的方法,因为使用 DDL 创建的字典: -- 不会向服务器配置文件添加额外记录 -- 字典可以作为一等实体进行操作,如表或视图 -- 数据可以直接读取,使用熟悉的 SELECT 而不是字典表函数 -- 字典可以轻松重命名 +字典可以使用 [DDL 查询](../../sql-reference/statements/create/dictionary.md) 创建,这是推荐的方法,因为通过 DDL 创建的字典: +- 不会向服务器配置文件中添加额外记录。 +- 字典可以作为一类实体与表或视图共同操作。 +- 可以直接读取数据,使用熟悉的 SELECT 而不是字典表函数。请注意,当通过 SELECT 语句直接访问字典时,缓存字典将仅返回缓存数据,而非缓存字典则会返回其存储的所有数据。 +- 字典可以轻松重命名。 ## 使用配置文件创建字典 {#creating-a-dictionary-with-a-configuration-file} :::note -使用配置文件创建字典不适用于 ClickHouse Cloud。请使用 DDL(见上文),并作为用户 `default` 创建您的字典。 +使用配置文件创建字典不适用于 ClickHouse Cloud。请使用 DDL(见上文),并以用户 `default` 创建字典。 ::: 字典配置文件具有以下格式: @@ -81,7 +82,7 @@ ClickHouse: 您可以在同一文件中 [配置](#configuring-a-dictionary) 任意数量的字典。 :::note -您可以通过在 `SELECT` 查询中描述它来转换小字典的值(请参阅 [transform](../../sql-reference/functions/other-functions.md) 函数)。此功能与字典无关。 +可以通过在 `SELECT` 查询中描述小字典来转换值(请参见 [transform](../../sql-reference/functions/other-functions.md) 函数)。此功能与字典无关。 ::: ## 配置字典 {#configuring-a-dictionary} @@ -125,23 +126,23 @@ LIFETIME(...) -- Lifetime of dictionary in memory ``` ## 在内存中存储字典 {#storing-dictionaries-in-memory} -有多种方法可以在内存中存储字典。 +有多种方式可以在内存中存储字典。 -我们推荐 [flat](#flat)、[hashed](#hashed) 和 [complex_key_hashed](#complex_key_hashed),它们提供了最佳的处理速度。 +我们推荐使用 [flat](#flat),[hashed](#hashed) 和 [complex_key_hashed](#complex_key_hashed),这些提供最佳的处理速度。 -由于可能的低性能和选择最佳参数的困难,因此不推荐使用缓存。在 [cache](#cache) 部分阅读更多信息。 +由于性能可能不佳且难以选择最佳参数,因此不推荐使用缓存。请在 [cache](#cache) 部分中阅读更多信息。 有几种方法可以提高字典性能: -- 在 `GROUP BY` 之后调用处理字典的函数。 -- 标记提取的属性为单射。如果不同的键对应于不同的属性值,则该属性称为单射。因此,当 `GROUP BY` 使用一个通过键获取属性值的函数时,该函数会自动从 `GROUP BY` 中移除。 +- 在 `GROUP BY` 后调用操作字典的函数。 +- 将要提取的属性标记为单射。如果不同的键对应于不同的属性值,则该属性称为单射。因此,当 `GROUP BY` 使用通过键获取属性值的函数时,该函数会自动从 `GROUP BY` 中移除。 -ClickHouse 在字典出现错误时会生成异常。错误示例: +ClickHouse 为字典错误生成异常。错误示例: -- 无法加载访问的字典。 -- 查询 `cached` 字典时出现错误。 +- 无法加载被访问的字典。 +- 查询一个 `cached` 字典时出错。 -您可以在 [system.dictionaries](../../operations/system-tables/dictionaries.md) 表中查看字典及其状态的列表。 +您可以在 [system.dictionaries](../../operations/system-tables/dictionaries.md) 表中查看字典的列表及其状态。 @@ -170,11 +171,11 @@ LAYOUT(LAYOUT_TYPE(param value)) -- layout settings ... ``` -没有 "complex-key*" 字样的字典布局具有 [UInt64](../../sql-reference/data-types/int-uint.md) 类型的键,而 "complex-key*" 字典具有复合键(复杂,具有任意类型)。 +没有 `complex-key*` 字样的字典布局具有类型为 [UInt64](../../sql-reference/data-types/int-uint.md) 的键,`complex-key*` 字典具有复合键(复杂,带有任意类型)。 -[UInt64](../../sql-reference/data-types/int-uint.md) 字典中的键用 `` 标签定义。 +[UInt64](../../sql-reference/data-types/int-uint.md) 键在 XML 字典中用 `` 标签定义。 -配置示例(列 key_column 具有 UInt64 类型): +列的键 key_column 类型为 UInt64 的配置示例: ```xml ... @@ -186,7 +187,7 @@ LAYOUT(LAYOUT_TYPE(param value)) -- layout settings 复合 `complex` 键的 XML 字典通过 `` 标签定义。 -复合键的配置示例(键具有一个元素,类型为 [String](../../sql-reference/data-types/string.md)): +复合键的配置示例(键有一个元素,其类型为 [String](../../sql-reference/data-types/string.md)): ```xml ... @@ -200,6 +201,8 @@ LAYOUT(LAYOUT_TYPE(param value)) -- layout settings ``` ## 在内存中存储字典的方法 {#ways-to-store-dictionaries-in-memory} +在内存中存储字典数据的各种方法与 CPU 和 RAM 使用之间存在权衡。字典相关 [博客文章](https://clickhouse.com/blog/faster-queries-dictionaries-clickhouse#choosing-a-layout) 中发布的决策树是决定使用哪个布局的一个良好起点。 + - [flat](#flat) - [hashed](#hashed) - [sparse_hashed](#sparse_hashed) @@ -218,13 +221,13 @@ LAYOUT(LAYOUT_TYPE(param value)) -- layout settings - [ip_trie](#ip_trie) ### flat {#flat} -字典以平面数组的形式完全存储在内存中。字典使用了多少内存?数量与最大键的大小成正比(使用的空间)。 +字典以平面数组的形式完全存储在内存中。字典使用了多少内存?此数量与最大键的大小成正比(使用的空间)。 -字典键具有 [UInt64](../../sql-reference/data-types/int-uint.md) 类型,值限制为 `max_array_size`(默认值为 500,000)。如果在创建字典时发现更大的键,将引发异常,并且字典不会被创建。字典平面数组的初始大小由 `initial_array_size` 设置控制(默认值为 1024)。 +字典键的类型为 [UInt64](../../sql-reference/data-types/int-uint.md),值的限制为 `max_array_size`(默认为 500,000)。如果在创建字典时发现键更大,则 ClickHouse 将抛出异常并不会创建该字典。字典平面数组的初始大小由 `initial_array_size` 设置控制(默认为 1024)。 -支持所有类型的源。更新时,数据(来自文件或表)会完全读取。 +支持所有类型的源。在更新时,数据(来自文件或表)会被完全读取。 -此方法在所有可用的字典存储方法中提供最佳性能。 +该方法在所有可用的字典存储方法中提供最佳性能。 配置示例: @@ -244,11 +247,11 @@ LAYOUT(FLAT(INITIAL_ARRAY_SIZE 50000 MAX_ARRAY_SIZE 5000000)) ``` ### hashed {#hashed} -字典以哈希表的形式完全存储在内存中。字典可以包含任意数量的元素和任意标识符。在实际操作中,键的数量可以达到数千万个。 +字典以哈希表的形式完全存储在内存中。字典可以包含任何数量的元素和任何标识符。在实践中,键的数量可以达到数千万个。 -字典键具有 [UInt64](../../sql-reference/data-types/int-uint.md) 类型。 +字典键的类型为 [UInt64](../../sql-reference/data-types/int-uint.md)。 -支持所有类型的源。更新时,数据(来自文件或表)会完全读取。 +支持所有类型的源。在更新时,数据(来自文件或表)会被完全读取。 配置示例: @@ -302,9 +305,9 @@ LAYOUT(HASHED([SHARDS 1] [SHARD_LOAD_QUEUE_BACKLOG 10000] [MAX_LOAD_FACTOR 0.5]) ``` ### sparse_hashed {#sparse_hashed} -类似于 `hashed`,但使用更少的内存,优先使用更多的 CPU。 +类似于 `hashed`,但使用较少的内存以换取更多的 CPU 使用。 -字典键具有 [UInt64](../../sql-reference/data-types/int-uint.md) 类型。 +字典键的类型为 [UInt64](../../sql-reference/data-types/int-uint.md)。 配置示例: @@ -324,7 +327,7 @@ LAYOUT(HASHED([SHARDS 1] [SHARD_LOAD_QUEUE_BACKLOG 10000] [MAX_LOAD_FACTOR 0.5]) LAYOUT(SPARSE_HASHED([SHARDS 1] [SHARD_LOAD_QUEUE_BACKLOG 10000] [MAX_LOAD_FACTOR 0.5])) ``` -对于此类型的字典,也可以使用 `shards`,而对于 `sparse_hashed` 来说,这比 `hashed` 更重要,因为 `sparse_hashed` 更慢。 +此类字典也可以使用 `shards`,而对 `sparse_hashed` 来说则更为重要,因为 `sparse_hashed` 的速度较慢。 ### complex_key_hashed {#complex_key_hashed} 此类型的存储用于复合 [键](#dictionary-key-and-fields)。类似于 `hashed`。 @@ -369,11 +372,11 @@ LAYOUT(COMPLEX_KEY_SPARSE_HASHED([SHARDS 1] [SHARD_LOAD_QUEUE_BACKLOG 10000] [MA ``` ### hashed_array {#hashed_array} -字典完全存储在内存中。每个属性存储在数组中。键属性以哈希表的形式存储,其中值是属性数组中的索引。字典可以包含任意数量的元素和任意标识符。在实际操作中,键的数量可以达到数千万个。 +字典完全存储在内存中。每个属性都存储在一个数组中。键属性以哈希表的形式存储,其中值是属性数组中的索引。字典可以包含任何数量的元素和任何标识符。在实践中,键的数量可以达到数千万个。 -字典键具有 [UInt64](../../sql-reference/data-types/int-uint.md) 类型。 +字典键的类型为 [UInt64](../../sql-reference/data-types/int-uint.md)。 -支持所有类型的源。更新时,数据(来自文件或表)会完全读取。 +支持所有类型的源。在更新时,数据(来自文件或表)会被完全读取。 配置示例: @@ -410,10 +413,10 @@ LAYOUT(COMPLEX_KEY_HASHED_ARRAY([SHARDS 1])) 字典以哈希表的形式存储在内存中,具有有序的范围数组及其对应的值。 -字典键具有 [UInt64](../../sql-reference/data-types/int-uint.md) 类型。 -这种存储方法与哈希方式相同,并允许使用日期/时间(任意数字类型)范围,除了键之外。 +字典键的类型为 [UInt64](../../sql-reference/data-types/int-uint.md) 类型。 +该存储方法的工作方式与 hashed 相同,允许在键的基础上使用日期/时间(任意数值类型)范围。 -示例:表格中包含每个广告客户的折扣,格式如下: +示例:表中包含格式为每个广告商的折扣: ```text ┌─advertiser_id─┬─discount_start_date─┬─discount_end_date─┬─amount─┐ @@ -423,7 +426,7 @@ LAYOUT(COMPLEX_KEY_HASHED_ARRAY([SHARDS 1])) └───────────────┴─────────────────────┴───────────────────┴────────┘ ``` -要使用日期范围的示例,在 [structure](#dictionary-key-and-fields) 中定义 `range_min` 和 `range_max` 元素。这些元素必须包含元素 `name` 和 `type`(如果未指定 `type`,则将使用默认类型 - Date)。`type` 可以是任何数字类型(Date / DateTime / UInt64 / Int32 / 其他)。 +要使用日期范围进行采样,请在 [structure](#dictionary-key-and-fields) 中定义 `range_min` 和 `range_max` 元素。这些元素必须包含 `name` 和 `type` 元素(如果未指定 `type`,将使用默认类型 - Date)。`type` 可以是任何数值类型(Date / DateTime / UInt64 / Int32 / 其他)。 :::note `range_min` 和 `range_max` 的值应适合 `Int64` 类型。 @@ -469,7 +472,7 @@ LAYOUT(RANGE_HASHED(range_lookup_strategy 'max')) RANGE(MIN discount_start_date MAX discount_end_date) ``` -为了使用这些字典,您需要向 `dictGet` 函数传递一个额外的参数,以选择范围: +要与这些字典一起工作,您需要向 `dictGet` 函数传递一个额外的参数,以选择范围: ```sql dictGet('dict_name', 'attr_name', id, date) @@ -480,14 +483,14 @@ dictGet('dict_name', 'attr_name', id, date) SELECT dictGet('discounts_dict', 'amount', 1, '2022-10-20'::Date); ``` -该函数返回指定 `id` 和包含传递日期的日期范围的值。 +该函数返回对应于指定 `id` 和包含传递日期的日期范围的值。 算法细节: -- 如果未找到 `id` 或未找到 `id` 的范围,则返回属性类型的默认值。 -- 如果存在重叠范围并且 `range_lookup_strategy=min`,则返回具有最小 `range_min` 的匹配范围;如果找到多个范围,则返回具有最小 `range_max` 的范围;如果再次找到多个范围(多个范围具有相同的 `range_min` 和 `range_max`),则随机返回其中一个范围。 -- 如果存在重叠范围并且 `range_lookup_strategy=max`,则返回具有最大 `range_min` 的匹配范围;如果找到多个范围,则返回具有最大 `range_max` 的范围;如果再次找到多个范围(多个范围具有相同的 `range_min` 和 `range_max`),则随机返回其中一个范围。 -- 如果 `range_max` 为 `NULL`,则该范围是开放的。`NULL` 被视为可能的最大值。对于 `range_min`,可以使用 `1970-01-01` 或 `0` (-MAX_INT) 作为开放值。 +- 如果未找到 `id` 或未为 `id` 找到范围,则返回属性类型的默认值。 +- 如果存在重叠范围,并且 `range_lookup_strategy=min`,则返回最小 `range_min` 的匹配范围,如果找到多个范围,返回最小 `range_max` 的范围,如果再次找到多个范围(几个范围具有相同的 `range_min` 和 `range_max`),则返回其中一个随机范围。 +- 如果存在重叠范围,并且 `range_lookup_strategy=max`,则返回最大 `range_min` 的匹配范围,如果找到多个范围,返回最大 `range_max` 的范围,如果再次找到多个范围(几个范围具有相同的 `range_min` 和 `range_max`),则返回其中一个随机范围。 +- 如果 `range_max` 为 `NULL`,则范围是不定的。`NULL` 被视为可能的最大值。对于 `range_min`,可以使用 `1970-01-01` 或 `0`(-MAX_INT)作为开区间值。 配置示例: @@ -536,7 +539,7 @@ PRIMARY KEY Abcdef RANGE(MIN StartTimeStamp MAX EndTimeStamp) ``` -重叠范围和开放范围的配置示例: +带有重叠范围和开区间的配置示例: ```sql CREATE TABLE discounts @@ -639,7 +642,7 @@ select dictGet('discounts_dict', 'amount', 3, toDate('2015-01-01')) res; ``` ### complex_key_range_hashed {#complex_key_range_hashed} -字典以哈希表的形式存储在内存中,具有有序的范围数组及其对应的值(见 [range_hashed](#range_hashed))。此类型的存储用于复合 [键](#dictionary-key-and-fields)。 +字典以哈希表的形式存储在内存中,具有有序范围数组及其对应的值(参见 [range_hashed](#range_hashed))。此类型的存储用于复合 [键](#dictionary-key-and-fields)。 配置示例: @@ -660,21 +663,21 @@ RANGE(MIN StartDate MAX EndDate); ``` ### cache {#cache} -字典存储在具有固定数量单元格的缓存中。这些单元格包含经常使用的元素。 +字典存储在具有固定数量单元的缓存中。这些单元包含频繁使用的元素。 -字典键具有 [UInt64](../../sql-reference/data-types/int-uint.md) 类型。 +字典键的类型为 [UInt64](../../sql-reference/data-types/int-uint.md)。 -在寻找字典时,首先搜索缓存。对于每个数据块,所有未在缓存中找到或已过期的键都通过 `SELECT attrs... FROM db.table WHERE id IN (k1, k2, ...)` 从源请求。接收到的数据随后写入缓存。 +在搜索字典时,首先搜索缓存。对于每个数据块,所有未在缓存中找到的密钥或已过期的密钥将使用 `SELECT attrs... FROM db.table WHERE id IN (k1, k2, ...)` 从源请求。接收到的数据将写入缓存。 -如果在字典中未找到键,则创建更新缓存任务并将其添加到更新队列。更新队列的属性可以通过设置 `max_update_queue_size`、`update_queue_push_timeout_milliseconds`、`query_wait_timeout_milliseconds`、`max_threads_for_updates` 进行控制。 +如果在字典中找不到密钥,则会创建更新缓存任务并将其添加到更新队列。更新队列属性可以通过设置 `max_update_queue_size`、`update_queue_push_timeout_milliseconds`、`query_wait_timeout_milliseconds`、`max_threads_for_updates` 来控制。 -对于缓存字典,可以设置缓存中数据的过期 [生存时间](#refreshing-dictionary-data-using-lifetime)。如果自从加载了单元格中的数据以来已经过去的时间超过了 `lifetime`,则不使用单元格的值,键变为过期。下次需要使用时将重新请求该键。此行为可以通过设置 `allow_read_expired_keys` 进行配置。 +对于缓存字典,可以设置缓存中数据的过期 [生存时间](#refreshing-dictionary-data-using-lifetime)。如果在单元中加载数据后经过的时间超过 `lifetime`,则该单元的值不再使用,密钥将过期。下一次需要使用时,将重新请求该密钥。此行为可以通过设置 `allow_read_expired_keys` 配置。 -这是存储字典的所有方法中效率最低的方法。缓存的速度在很大程度上依赖于正确的设置和使用场景。当命中率足够高(建议 99% 及以上)时,缓存类型字典的性能良好。您可以在 [system.dictionaries](../../operations/system-tables/dictionaries.md) 表中查看平均命中率。 +这是所有存储字典的方法中效果最差的。缓存的速度在很大程度上依赖于正确的设置和使用场景。只有当缓存命中率足够高(推荐99%及以上)时,缓存类型字典才会表现良好。您可以在 [system.dictionaries](../../operations/system-tables/dictionaries.md) 表中查看平均命中率。 -如果设置 `allow_read_expired_keys` 设置为 1(默认为 0),则字典可以支持异步更新。如果客户端请求的键都在缓存中,但某些键已过期,则字典将返回过期的键给客户端,并从源异步请求它们。 +如果设置 `allow_read_expired_keys` 被设置为 1(默认是 0),则字典可以支持异步更新。如果客户端请求的所有密钥都在缓存中,但其中一些已经过期,则字典将返回过期的密钥,并向源异步请求这些密钥。 -为了提高缓存性能,使用带有 `LIMIT` 的子查询,并在外部调用包含字典的函数。 +要提高缓存性能,请使用带有 `LIMIT` 的子查询,并在外部调用字典的函数。 支持所有类型的源。 @@ -705,24 +708,24 @@ RANGE(MIN StartDate MAX EndDate); LAYOUT(CACHE(SIZE_IN_CELLS 1000000000)) ``` -设置一个足够大的缓存大小。需要进行实验以选择单元格数量: +设置足够大的缓存大小。您需要进行实验以选择单元的数量: 1. 设置某个值。 -2. 运行查询直到缓存完全充满。 +2. 运行查询直到缓存完全满。 3. 使用 `system.dictionaries` 表评估内存消耗。 -4. 增加或减少单元格数量,直到达到所需的内存消耗。 +4. 根据所需内存消耗增加或减少单元数量。 :::note -不要将 ClickHouse 作为源,因为它在随机读取的查询处理上速度慢。 +请勿使用 ClickHouse 作为源,因为处理随机读取的查询较慢。 ::: ### complex_key_cache {#complex_key_cache} 此类型的存储用于复合 [键](#dictionary-key-and-fields)。类似于 `cache`。 ### ssd_cache {#ssd_cache} -类似于 `cache`,但将数据存储在 SSD 上,同时将索引存储在 RAM 中。与更新队列相关的所有缓存字典设置也可以应用于 SSD 缓存字典。 +类似于 `cache`,但将数据存储在 SSD 上,并在 RAM 中创建索引。与更新队列相关的所有缓存字典设置也可应用于 SSD 缓存字典。 -字典键具有 [UInt64](../../sql-reference/data-types/int-uint.md) 类型。 +字典键的类型为 [UInt64](../../sql-reference/data-types/int-uint.md) 类型。 ```xml @@ -752,11 +755,11 @@ LAYOUT(SSD_CACHE(BLOCK_SIZE 4096 FILE_SIZE 16777216 READ_BUFFER_SIZE 1048576 此类型的存储用于复合 [键](#dictionary-key-and-fields)。类似于 `ssd_cache`。 ### direct {#direct} -字典不存储在内存中,而是在处理请求期间直接访问源。 +字典不存储在内存中,处理请求时直接访问源。 -字典键具有 [UInt64](../../sql-reference/data-types/int-uint.md) 类型。 +字典键的类型为 [UInt64](../../sql-reference/data-types/int-uint.md) 类型。 -支持所有类型的 [源](#dictionary-sources),但不包括本地文件。 +支持所有类型的 [源](#dictionary-sources),但本地文件除外。 配置示例: @@ -776,11 +779,13 @@ LAYOUT(DIRECT()) 此类型的存储用于复合 [键](#dictionary-key-and-fields)。类似于 `direct`。 ### ip_trie {#ip_trie} -此类型的存储用于将网络前缀(IP 地址)映射到元数据,例如 ASN。 +此字典设计用于通过网络前缀进行 IP 地址查找。它以 CIDR 表示法存储 IP 范围,并允许快速确定给定 IP 属于哪个前缀(例如子网或 ASN 范围),使其成为基于 IP 的搜索(如地理位置或网络分类)的理想选择。 + + **示例** -假设我们在 ClickHouse 中有一个表,包含我们的 IP 前缀和映射: +假设我们在 ClickHouse 中有一个包含我们的 IP 前缀和映射的表: ```sql CREATE TABLE my_ip_addresses ( @@ -846,9 +851,9 @@ LAYOUT(IP_TRIE) LIFETIME(3600); ``` -键必须只有一个 `String` 类型的属性,包含一个允许的 IP 前缀。其他类型尚不支持。 +该键必须只有一个类型为 `String` 的属性,包含允许的 IP 前缀。其他类型尚不支持。 -语法是: +语法为: ```sql dictGetT('dict_name', 'attr_name', ip) @@ -878,14 +883,14 @@ SELECT dictGet('my_ip_trie_dictionary', ('asn', 'cca2'), IPv6StringToNum('2001:d └──────────────┘ ``` -其他类型尚不支持。该函数返回与该 IP 地址对应的前缀的属性。如果有重叠前缀,则返回最具体的前缀。 +其他类型尚不支持。该函数返回与该 IP 地址对应的前缀的属性。如果存在重叠的前缀,则返回最具体的一个。 数据必须完全适合 RAM。 -## 使用生存时间刷新字典数据 {#refreshing-dictionary-data-using-lifetime} +## 使用 LIFETIME 刷新字典数据 {#refreshing-dictionary-data-using-lifetime} -ClickHouse 根据 `LIFETIME` 标签(以秒为单位)定期更新字典。`LIFETIME` 是完全下载字典的更新间隔和缓存字典的失效间隔。 +ClickHouse 定期根据 `LIFETIME` 标签(以秒为单位)更新字典。`LIFETIME` 是完全下载的字典的更新间隔,也是缓存字典的失效间隔。 -在更新期间,依旧可以查询旧版本的字典。字典更新(首次使用字典时除外)不会阻止查询。如果更新过程中发生错误,错误将记录在服务器日志中,查询可以继续使用旧版本的字典。如果字典更新成功,则旧版本的字典将被原子替换。 +在更新期间,旧版本的字典仍然可以查询。字典更新(除首次使用加载字典外)不会阻塞查询。如果在更新期间发生错误,则错误会写入服务器日志,查询可以继续使用旧版本的字典。如果字典更新成功,旧版本的字典将被原子地替换。 设置示例: @@ -908,9 +913,9 @@ LIFETIME(300) ... ``` -设置 `0`(`LIFETIME(0)`)将防止字典更新。 +设置 `0`(`LIFETIME(0)`)将阻止字典更新。 -您可以设置更新的时间间隔,ClickHouse 将选择该范围内的均匀随机时间。这是为了在大量服务器上更新时分散字典源的负载。 +您可以设置更新的时间间隔,ClickHouse 将在该范围内选择一个均匀随机的时间。这是为了在许多服务器上更新时分散字典源的负载。 设置示例: @@ -931,18 +936,18 @@ LIFETIME(300) LIFETIME(MIN 300 MAX 360) ``` -如果 `0` 和 `0`,ClickHouse 不会自动重新加载字典。 -在这种情况下,如果字典配置文件已更改或执行了 `SYSTEM RELOAD DICTIONARY` 命令,ClickHouse 可以提前重新加载字典。 +如果 `0` 和 `0`,ClickHouse 不会根据超时重新加载字典。 +在这种情况下,如果字典配置文件发生变化或执行了 `SYSTEM RELOAD DICTIONARY` 命令,ClickHouse 可以更早地重新加载字典。 -在更新字典时,ClickHouse 服务器根据 [源](#dictionary-sources) 的类型应用不同的逻辑: +在更新字典时,ClickHouse 服务器会根据 [源](#dictionary-sources) 的类型应用不同的逻辑: -- 对于文本文件,它检查修改时间。如果时间与先前记录的时间不同,则更新该字典。 -- 默认情况下,来自其他源的字典每次都会更新。 +- 对于文本文件,它会检查修改时间。如果时间与先前记录的时间不同,则更新字典。 +- 默认情况下,来自其他源的字典都会每次更新。 -对于其他源(ODBC、PostgreSQL、ClickHouse 等),您可以设置一个查询,只有在字典确实变化时才更新字典,而不是每次都更新。要做到这一点,请执行以下步骤: +对于其他源(如 ODBC、PostgreSQL、ClickHouse 等),您可以设置一个查询,仅在字典确实发生变化时更新字典,而不是每次都更新。要做到这一点,请执行以下步骤: -- 字典表必须具有一个在源数据更新时总是变化的字段。 -- 源的设置必须指定一个查询,该查询提取变化的字段。ClickHouse 服务器将查询结果解释为一行,如果该行相对于其先前状态发生了变化,则更新字典。在 [source](#dictionary-sources) 的设置中在 `` 字段中指定该查询。 +- 字典表必须有一个字段,该字段在源数据更新时始终变化。 +- 源的设置必须指定一个查询以检索变化字段。ClickHouse 服务器将查询结果解释为一行,如果该行与其以前的状态发生变化,则更新字典。在 [source](#dictionary-sources) 的设置中在 `` 字段中指定该查询。 设置示例: @@ -965,14 +970,14 @@ SOURCE(ODBC(... invalidate_query 'SELECT update_time FROM dictionary_source wher ... ``` -对于 `Cache`、`ComplexKeyCache`、`SSDCache` 和 `SSDComplexKeyCache` 字典,均支持同步和异步更新。 +对于 `Cache`、`ComplexKeyCache`、`SSDCache` 和 `SSDComplexKeyCache` 字典,支持同步和异步更新。 -对于 `Flat`、`Hashed`、`ComplexKeyHashed` 字典,只请求在上次更新后更改的数据也是可能的。如果在字典源配置中指定了 `update_field`,则会将上次更新的时间值(以秒为单位)添加到数据请求中。根据源类型(可执行文件、HTTP、MySQL、PostgreSQL、ClickHouse 或 ODBC),在从外部源请求数据之前,对 `update_field` 将应用不同的逻辑。 +对于 `Flat`、`Hashed`、`HashedArray`、`ComplexKeyHashed` 字典,也可以仅请求在上次更新后已更改的数据。如果在字典源配置中指定了 `update_field`,则上一更新时间的值(以秒为单位)将被添加到数据请求中。根据源的类型(可执行文件、HTTP、MySQL、PostgreSQL、ClickHouse 或 ODBC),在请求外部源数据之前,会对 `update_field` 应用不同的逻辑。 -- 如果源是 HTTP,则 `update_field` 将作为查询参数添加,最后更新时间作为参数值。 -- 如果源是可执行脚本,则 `update_field` 将作为可执行脚本参数添加,最后更新时间作为参数值。 -- 如果源是 ClickHouse、MySQL、PostgreSQL、ODBC,则在 `WHERE` 中会有一个额外的部分,其中 `update_field` 被比较为大于或等于最后更新时间。 - - 默认情况下,该 `WHERE` 条件在 SQL 查询的最高级别进行检查。或者,该条件可以在查询中的任何其他 `WHERE` 子句中使用 `{condition}` 关键字检查。示例: +- 如果源是 HTTP,则 `update_field` 将作为查询参数添加,参数值为最后更新的时间。 +- 如果源是可执行文件,则 `update_field` 将作为可执行脚本参数添加,参数值为最后更新的时间。 +- 如果源是 ClickHouse、MySQL、PostgreSQL 或 ODBC,则会在 `WHERE` 中增加一个附加部分,其中 `update_field` 被比较为大于或等于最后更新的时间。 + - 默认情况下,此 `WHERE` 条件在 SQL 查询的最高级别进行检查。或者,可以在查询中的任何其他 `WHERE` 子句中使用 `{condition}` 关键字检查该条件。示例: ```sql ... SOURCE(CLICKHOUSE(... @@ -988,7 +993,7 @@ SOURCE(CLICKHOUSE(... ... ``` -如果设置了 `update_field` 选项,则可以设置额外的选项 `update_lag`。`update_lag` 选项的值在请求更新数据时从上次更新时间值中减去。 +如果 `update_field` 选项被设置,则可以设置额外选项 `update_lag`。`update_lag` 选项的值在请求更新的数据之前将从上次更新的时间中减去。 设置示例: @@ -1015,9 +1020,9 @@ SOURCE(CLICKHOUSE(... update_field 'added_time' update_lag 15)) -字典可以连接到 ClickHouse 中的多种不同源。 +字典可以从许多不同的源连接到 ClickHouse。 -如果字典是使用 xml 文件配置的,则配置如下: +如果字典是通过 xml 文件配置的,配置看起来像这样: ```xml @@ -1043,9 +1048,9 @@ SOURCE(SOURCE_TYPE(param1 val1 ... paramN valN)) -- Source configuration ... ``` -来源在 `source` 部分中配置。 +源在 `source` 部分配置。 -对于源类型 [本地文件](#local-file)、[可执行文件](#executable-file)、[HTTP(S)](#https)、[ClickHouse](#clickhouse) 可以选择可选设置: +对于源类型 [本地文件](#local-file)、[可执行文件](#executable-file)、[HTTP(s)](#https),[ClickHouse](#clickhouse),可用可选设置: ```xml @@ -1066,20 +1071,20 @@ SOURCE(FILE(path './user_files/os.tsv' format 'TabSeparated')) SETTINGS(format_csv_allow_single_quotes = 0) ``` -源的类型(`source_type`): +源类型(`source_type`): - [本地文件](#local-file) - [可执行文件](#executable-file) - [可执行池](#executable-pool) - [HTTP(S)](#https) -- DBMS - - [ODBC](#odbc) - - [MySQL](#mysql) - - [ClickHouse](#clickhouse) - - [MongoDB](#mongodb) - - [Redis](#redis) - - [Cassandra](#cassandra) - - [PostgreSQL](#postgresql) +- 数据库管理系统 + - [ODBC](#odbc) + - [MySQL](#mysql) + - [ClickHouse](#clickhouse) + - [MongoDB](#mongodb) + - [Redis](#redis) + - [Cassandra](#cassandra) + - [PostgreSQL](#postgresql) ### 本地文件 {#local-file} 设置示例: @@ -1101,17 +1106,17 @@ SOURCE(FILE(path './user_files/os.tsv' format 'TabSeparated')) 设置字段: -- `path` — 文件的绝对路径。 -- `format` — 文件格式。支持 [Formats](/sql-reference/formats) 中描述的所有格式。 +- `path` – 文件的绝对路径。 +- `format` – 文件格式。支持 [Formats](/sql-reference/formats) 中描述的所有格式。 -当通过 DDL 命令 (`CREATE DICTIONARY ...`) 创建来源为 `FILE` 的字典时,源文件需要位于 `user_files` 目录中,以防止数据库用户访问 ClickHouse 节点上的任意文件。 +通过 DDL 命令(`CREATE DICTIONARY ...`)创建源为 `FILE` 的字典时,源文件需要位于 `user_files` 目录中,以防止数据库用户访问 ClickHouse 节点上的任意文件。 **另请参阅** - [字典函数](/sql-reference/table-functions/dictionary) ### 可执行文件 {#executable-file} -与可执行文件的操作依赖于 [字典如何存储在内存中](#storing-dictionaries-in-memory)。如果字典使用 `cache` 和 `complex_key_cache` 存储,ClickHouse 通过向可执行文件的 STDIN 发送请求来请求所需的键。否则,ClickHouse 启动可执行文件并将其输出视为字典数据。 +使用可执行文件取决于 [字典存储在内存中的方式](#storing-dictionaries-in-memory)。如果字典使用 `cache` 和 `complex_key_cache` 存储,ClickHouse 通过向可执行文件的标准输入发送请求来请求必要的键。否则,ClickHouse 启动可执行文件并将其输出视为字典数据。 设置示例: @@ -1129,19 +1134,19 @@ SOURCE(FILE(path './user_files/os.tsv' format 'TabSeparated')) - `command` — 可执行文件的绝对路径,或文件名(如果命令的目录在 `PATH` 中)。 - `format` — 文件格式。支持 [Formats](/sql-reference/formats) 中描述的所有格式。 -- `command_termination_timeout` — 可执行脚本应包含一个主要的读写循环。在字典被销毁后,管道关闭,可执行文件将有 `command_termination_timeout` 秒来关闭,然后 ClickHouse 将向子进程发送 SIGTERM 信号。`command_termination_timeout` 以秒为单位指定。默认值为 10。可选参数。 -- `command_read_timeout` - 从命令标准输出读取数据的超时,以毫秒为单位。默认值 10000。可选参数。 -- `command_write_timeout` - 向命令标准输入写入数据的超时,以毫秒为单位。默认值 10000。可选参数。 -- `implicit_key` — 可执行源文件只能返回值,且与请求的键的对应关系是隐式确定的 - 通过结果中行的顺序。默认值为 false。 -- `execute_direct` - 如果 `execute_direct` = `1`,则 `command` 将在由 [user_scripts_path](../../operations/server-configuration-parameters/settings.md#user_scripts_path) 指定的 user_scripts 文件夹中查找。可以使用空格分隔符指定额外的脚本参数。示例:`script_name arg1 arg2`。如果 `execute_direct` = `0`,则 `command` 作为参数传递给 `bin/sh -c`。默认值为 `0`。可选参数。 -- `send_chunk_header` - 控制是否在发送数据块之前发送行计数。可选。默认值为 `false`。 - -该字典源只能通过 XML 配置进行配置。通过 DDL 创建具有可执行源的字典是禁用的;否则,数据库用户将能够在 ClickHouse 节点上执行任意二进制文件。 +- `command_termination_timeout` — 可执行脚本应该包含一个主要的读写循环。在字典被销毁后,管道会关闭,可执行文件将有 `command_termination_timeout` 秒的时间退出,之后 ClickHouse 将向子进程发送 SIGTERM 信号。`command_termination_timeout` 的值以秒为单位指定,默认值为 10。可选参数。 +- `command_read_timeout` - 读取命令标准输出数据的超时,以毫秒为单位。默认值10000。可选参数。 +- `command_write_timeout` - 写入数据到命令标准输入的超时,以毫秒为单位。默认值10000。可选参数。 +- `implicit_key` — 可执行源文件只能返回值,并且与请求键的对应关系是通过结果中的行顺序隐式确定的。默认值为 false。 +- `execute_direct` - 如果 `execute_direct` = `1`,则 `command` 将在由 [user_scripts_path](../../operations/server-configuration-parameters/settings.md#user_scripts_path) 指定的 user_scripts 文件夹内部进行搜索。可以使用空格分隔符指定其他脚本参数。示例:`script_name arg1 arg2`。如果 `execute_direct` = `0`,则 `command` 作为参数传递给 `bin/sh -c`。默认值为 `0`。可选参数。 +- `send_chunk_header` - 控制是否在发送数据块进行处理之前发送行数。可选。默认值为 `false`。 + +仅可通过 XML 配置配置该字典源。通过 DDL 创建可执行源字典是禁用的;否则,数据库用户将能够在 ClickHouse 节点上执行任意二进制文件。 ### 可执行池 {#executable-pool} -可执行池允许从进程池中加载数据。此源不适用于需要从源加载所有数据的字典布局。可执行池在字典 [存储](#ways-to-store-dictionaries-in-memory) 使用 `cache`、`complex_key_cache`、`ssd_cache`、`complex_key_ssd_cache`、`direct` 或 `complex_key_direct` 布局时工作。 +可执行池允许从进程池中加载数据。对于需要从源加载所有数据的字典布局,此源不起作用。可执行池在字典 [存储](#ways-to-store-dictionaries-in-memory) 使用 `cache`、`complex_key_cache`、`ssd_cache`、`complex_key_ssd_cache`、`direct` 或 `complex_key_direct` 布局时有效。 -可执行池将生成具有指定命令的进程池,并使其继续运行直到退出。程序应在 STDIN 上读取数据,同时其可用,并将结果输出到 STDOUT。它可以等待 STDIN 上的下一个数据块。ClickHouse 在处理数据块后将不会关闭 STDIN,而是在需要时标记另一块数据。可执行脚本应准备好这种数据处理方式——它应轮询 STDIN 并提前将数据刷新到 STDOUT。 +可执行池将生成一个指定命令的进程池,并保持其运行直到它们退出。程序应在 STDIN 可用时读取数据并将结果输出到 STDOUT。它可以在 STDIN 上等待获取下一个数据块。ClickHouse 在处理数据块后不会关闭 STDIN,但在需要时会通过管道传输数据的另一部分。可执行脚本应准备好这种数据处理方式 — 应该提前轮询 STDIN 并将数据刷新到 STDOUT。 设置示例: @@ -1159,21 +1164,21 @@ SOURCE(FILE(path './user_files/os.tsv' format 'TabSeparated')) 设置字段: -- `command` — 可执行文件的绝对路径,或文件名(如果程序目录被写入 `PATH`)。 -- `format` — 文件格式。支持 [Formats](/sql-reference/formats) 中描述的所有格式。 -- `pool_size` — 池的大小。如果 `pool_size` 的值为 0,则没有池大小限制。默认值为 16。 -- `command_termination_timeout` — 可执行脚本应包含主要读写循环。在字典被销毁后,管道关闭,可执行文件将有 `command_termination_timeout` 秒的时间来关闭,ClickHouse 将在此之前发送 SIGTERM 信号给子进程。以秒为单位指定。默认值为 10。可选参数。 -- `max_command_execution_time` — 处理数据块的最大可执行脚本命令执行时间。以秒为单位指定。默认值为 10。可选参数。 -- `command_read_timeout` - 从命令标准输出读取数据的超时,以毫秒为单位。默认值 10000。可选参数。 -- `command_write_timeout` - 向命令标准输入写入数据的超时,以毫秒为单位。默认值 10000。可选参数。 -- `implicit_key` — 可执行源文件只能返回值,且与请求的键的对应关系是隐式确定的 - 通过结果中行的顺序。默认值为 false。可选参数。 -- `execute_direct` - 如果 `execute_direct` = `1`,则 `command` 将在由 [user_scripts_path](../../operations/server-configuration-parameters/settings.md#user_scripts_path) 指定的 user_scripts 文件夹中查找。可以使用空格分隔符指定额外的脚本参数。示例:`script_name arg1 arg2`。如果 `execute_direct` = `0`,则 `command` 作为参数传递给 `bin/sh -c`。默认值为 `1`。可选参数。 -- `send_chunk_header` - 控制是否在发送数据块之前发送行计数。可选。默认值为 `false`。 - -该字典源只能通过 XML 配置进行配置。通过 DDL 创建具有可执行源的字典是禁用的,否则,数据库用户将能够在 ClickHouse 节点上执行任意二进制文件。 +- `command` — 可执行文件的绝对路径,或文件名(如果程序目录写入到 `PATH` 中)。 +- `format` — 文件格式。支持 "[Formats](/sql-reference/formats)" 中描述的所有格式。 +- `pool_size` — 池的大小。如果指定 `pool_size` 为 0,则没有池大小限制。默认值为 `16`。 +- `command_termination_timeout` — 可执行脚本应包含主要的读写循环。在字典被销毁后,管道会关闭,可执行文件将有 `command_termination_timeout` 秒的时间退出,之后 ClickHouse 将向子进程发送 SIGTERM 信号。以秒为单位指定,默认值为 10。可选参数。 +- `max_command_execution_time` — 处理数据块的可执行脚本命令的最大执行时间。以秒为单位指定,默认值为 10。可选参数。 +- `command_read_timeout` - 读取命令标准输出数据的超时,以毫秒为单位。默认值10000。可选参数。 +- `command_write_timeout` - 写入数据到命令标准输入的超时,以毫秒为单位。默认值10000。可选参数。 +- `implicit_key` — 可执行源文件只能返回值,并且与请求键的对应关系是通过结果中的行顺序隐式确定的。默认值为 false。可选参数。 +- `execute_direct` - 如果 `execute_direct` = `1`,则 `command` 将在由 [user_scripts_path](../../operations/server-configuration-parameters/settings.md#user_scripts_path) 指定的 user_scripts 文件夹内进行搜索。通过空格分隔符可以指定额外的脚本参数。示例:`script_name arg1 arg2`。如果 `execute_direct` = `0`,则 `command` 作为参数传递给 `bin/sh -c`。默认值为 `1`。可选参数。 +- `send_chunk_header` - 控制是否在发送数据块进行处理之前发送行数。可选。默认值为 `false`。 + +仅可通过 XML 配置配置该字典源。通过 DDL 创建可执行源字典是禁用的;否则,数据库用户将能够在 ClickHouse 节点上执行任意二进制文件。 ### HTTP(S) {#https} -与 HTTP(S) 服务器的交互取决于 [字典如何存储在内存中](#storing-dictionaries-in-memory)。如果字典使用 `cache` 和 `complex_key_cache` 存储,ClickHouse 通过发送 `POST` 请求来请求必要的键。 +与HTTP(S)服务器的交互取决于 [字典在内存中的存储方式](#storing-dictionaries-in-memory)。如果字典是通过 `cache` 和 `complex_key_cache` 存储的,ClickHouse会通过 `POST` 方法发送请求以请求所需的键。 设置示例: @@ -1207,24 +1212,25 @@ SOURCE(HTTP( )) ``` -为了让 ClickHouse 访问 HTTPS 资源,您必须在服务器配置中 [配置 openSSL](../../operations/server-configuration-parameters/settings.md#openssl)。 +为了使ClickHouse能够访问HTTPS资源,必须在服务器配置中 [配置openSSL](../../operations/server-configuration-parameters/settings.md#openssl)。 设置字段: -- `url` – 源 URL。 -- `format` – 文件格式。支持 [Formats](/sql-reference/formats) 中描述的所有格式。 -- `credentials` – 基础 HTTP 身份验证。可选参数。 +- `url` – 源URL。 +- `format` – 文件格式。支持在 "[Formats](/sql-reference/formats)" 中描述的所有格式。 +- `credentials` – 基本HTTP身份验证。可选参数。 - `user` – 身份验证所需的用户名。 - `password` – 身份验证所需的密码。 -- `headers` – 用于 HTTP 请求的所有自定义 HTTP 头条目。可选参数。 -- `header` – 单个 HTTP 头条目。 -- `name` – 用于请求时发送的标头的标识符名称。 -- `value` – 为特定标识符名称设置的值。 +- `headers` – 用于HTTP请求的所有自定义HTTP头条目。可选参数。 +- `header` – 单个HTTP头条目。 +- `name` – 用于请求中发送头的标识符名称。 +- `value` – 特定标识符名称设置的值。 -在使用 DDL 命令 (`CREATE DICTIONARY ...`) 创建字典时,检查 HTTP 字典的远程主机是否符合配置中的 `remote_url_allow_hosts` 部分内容,以防止数据库用户访问任意 HTTP 服务器。 +在使用DDL命令(`CREATE DICTIONARY ...`)创建字典时,针对HTTP字典的远程主机会根据配置中的 `remote_url_allow_hosts` 部分进行检查,以防止数据库用户访问任意HTTP服务器。 +### DBMS {#dbms} #### ODBC {#odbc} -您可以使用此方法连接任何具有 ODBC 驱动程序的数据库。 +您可以使用此方法连接任何具有ODBC驱动程序的数据库。 设置示例: @@ -1254,29 +1260,29 @@ SOURCE(ODBC( 设置字段: -- `db` – 数据库名称。如果在 `` 参数中设置了数据库名称,则省略此项。 -- `table` – 表名和架构(如果存在)。 +- `db` – 数据库名称。如果数据库名称已在 `` 参数中设置,则省略。 +- `table` – 表名及其架构(如果存在)。 - `connection_string` – 连接字符串。 -- `invalidate_query` – 检查字典状态的查询。可选参数。请参阅[使用生存时间刷新字典数据](#refreshing-dictionary-data-using-lifetime)部分了解更多信息。 -- `background_reconnect` – 如果连接失败,则在后台重新连接到副本。可选参数。 +- `invalidate_query` – 检查字典状态的查询。可选参数。请参阅 [使用LIFETIME刷新的字典数据](#refreshing-dictionary-data-using-lifetime)部分以了解更多信息。 +- `background_reconnect` – 如果连接失败,后台重新连接到副本。可选参数。 - `query` – 自定义查询。可选参数。 :::note -`table` 和 `query` 字段不能一起使用。必须声明 `table` 或 `query` 中的任一字段。 +`table` 和 `query` 字段不能一起使用。并且必须声明 `table` 或 `query` 字段之一。 ::: -ClickHouse 从 ODBC 驱动程序接收引用符号,并在查询中对所有设置进行引用,因此必须根据数据库中的表名称情况设置表名称。 +ClickHouse从ODBC驱动程序接收引用符号,并在查询中引用所有设置,因此必须根据数据库中表名的大小写相应地设置表名。 -如果您在使用 Oracle 时遇到编码问题,请参阅相应的[常见问题解答](/knowledgebase/oracle-odbc)项。 -##### ODBC 字典功能的已知漏洞 {#known-vulnerability-of-the-odbc-dictionary-functionality} +如果在使用Oracle时遇到编码问题,请参阅相应的 [FAQ](/knowledgebase/oracle-odbc) 项目。 +##### 已知的ODBC字典功能漏洞 {#known-vulnerability-of-the-odbc-dictionary-functionality} :::note -通过 ODBC 驱动程序连接到数据库时,连接参数 `Servername` 可以被替换。在这种情况下,`odbc.ini` 中的 `USERNAME` 和 `PASSWORD` 值将被发送到远程服务器,并可能被泄露。 +通过ODBC驱动程序连接到数据库时,连接参数 `Servername` 可以被替代。在这种情况下,来自 `odbc.ini` 的 `USERNAME` 和 `PASSWORD` 的值将发送到远程服务器,可能会泄露。 ::: -**不安全用法示例** +**不安全使用的示例** -让我们为 PostgreSQL 配置 unixODBC。`/etc/odbc.ini` 文件的内容: +让我们为PostgreSQL配置unixODBC。`/etc/odbc.ini`的内容: ```text [gregtest] @@ -1289,24 +1295,24 @@ USERNAME = test PASSWORD = test ``` -如果您之后执行类似以下查询: +如果您随后执行如下查询 ```sql SELECT * FROM odbc('DSN=gregtest;Servername=some-server.com', 'test_db'); ``` -ODBC 驱动程序将把 `odbc.ini` 中的 `USERNAME` 和 `PASSWORD` 发送到 `some-server.com`。 -##### 连接 PostgreSQL 的示例 {#example-of-connecting-postgresql} +ODBC驱动程序将发送来自 `odbc.ini` 的 `USERNAME` 和 `PASSWORD` 的值到 `some-server.com`。 +##### 连接Postgresql的示例 {#example-of-connecting-postgresql} -Ubuntu 操作系统。 +Ubuntu操作系统。 -安装 unixODBC 和 PostgreSQL 的 ODBC 驱动程序: +安装unixODBC和PostgreSQL的ODBC驱动程序: ```bash $ sudo apt-get install -y unixodbc odbcinst odbc-postgresql ``` -配置 `/etc/odbc.ini`(如果您以运行 ClickHouse 的用户身份登录,则为 `~/.odbc.ini`): +配置`/etc/odbc.ini`(或`~/.odbc.ini`,如果您用运行ClickHouse的用户登录): ```text [DEFAULT] @@ -1327,7 +1333,7 @@ ShowSystemTables = No ConnSettings = ``` -ClickHouse 中的字典配置: +ClickHouse中的字典配置: ```xml @@ -1375,12 +1381,12 @@ LAYOUT(HASHED()) LIFETIME(MIN 300 MAX 360) ``` -您可能需要编辑 `odbc.ini` 以指定驱动程序库的完整路径 `DRIVER=/usr/local/lib/psqlodbcw.so`。 -##### 连接 MS SQL Server 的示例 {#example-of-connecting-ms-sql-server} +您可能需要编辑 `odbc.ini` 以指定带有驱动程序的库的完整路径 `DRIVER=/usr/local/lib/psqlodbcw.so`。 +##### 连接MS SQL Server的示例 {#example-of-connecting-ms-sql-server} -Ubuntu 操作系统。 +Ubuntu操作系统。 -安装用于连接到 MS SQL 的 ODBC 驱动程序: +安装连接到MS SQL的ODBC驱动程序: ```bash $ sudo apt-get install tdsodbc freetds-bin sqsh @@ -1432,9 +1438,9 @@ $ isql -v MSSQL "user" "password" ``` 备注: -- 要确定特定 SQL Server 版本支持的最早 TDS 版本,请查阅产品文档或查看 [MS-TDS 产品行为](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-tds/135d0ebe-5c4c-4a94-99bf-1811eccb9f4a) +- 要确定特定SQL Server版本支持的最早TDS版本,请参阅产品文档或查看 [MS-TDS产品行为](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-tds/135d0ebe-5c4c-4a94-99bf-1811eccb9f4a) -在 ClickHouse 中配置字典: +在ClickHouse中配置字典: ```xml @@ -1530,38 +1536,38 @@ SOURCE(MYSQL( 设置字段: -- `port` – MySQL 服务器的端口。您可以为所有副本指定此端口,或单独为每个副本(在 `` 内)。 +- `port` – MySQL服务器上的端口。您可以为所有副本指定它,或为每个副本单独指定(在``中)。 -- `user` – MySQL 用户名。您可以为所有副本指定此用户,或单独为每个副本(在 `` 内)。 +- `user` – MySQL用户的名称。您可以为所有副本指定它,或为每个副本单独指定(在``中)。 -- `password` – MySQL 用户的密码。您可以为所有副本指定此密码,或单独为每个副本(在 `` 内)。 +- `password` – MySQL用户的密码。您可以为所有副本指定它,或为每个副本单独指定(在``中)。 -- `replica` – 副本配置的部分。可以有多个部分。 +- `replica` – 副本配置节。可以有多个部分。 - - `replica/host` – MySQL 主机。 - - `replica/priority` – 副本优先级。在尝试连接时,ClickHouse 按优先级顺序遍历副本。数字越小,优先级越高。 + - `replica/host` – MySQL主机。 + - `replica/priority` – 副本优先级。尝试连接时,ClickHouse按优先级顺序遍历副本。数字越低,优先级越高。 - `db` – 数据库名称。 -- `table` – 表名。 +- `table` – 表名称。 -- `where` – 选择标准。条件的语法与 MySQL 中的 `WHERE` 子句相同,例如 `id > 10 AND id < 20`。可选参数。 +- `where` – 选择条件。条件的语法与MySQL中的 `WHERE` 子句相同,例如 `id > 10 AND id < 20`。可选参数。 -- `invalidate_query` – 检查字典状态的查询。可选参数。请参阅[使用生存时间刷新字典数据](#refreshing-dictionary-data-using-lifetime)部分了解更多信息。 +- `invalidate_query` – 检查字典状态的查询。可选参数。请参阅 [使用LIFETIME刷新的字典数据](#refreshing-dictionary-data-using-lifetime)部分以了解更多信息。 -- `fail_on_connection_loss` – 控制服务器在连接丢失时行为的配置参数。如果为 `true`,当客户端与服务器之间的连接丢失时将立即抛出异常。如果为 `false`,ClickHouse 服务器将在抛出异常之前尝试重新执行查询三次。请注意,重试会导致响应时间增加。默认值:`false`。 +- `fail_on_connection_loss` – 控制连接丢失时服务器行为的配置参数。如果`true`,则在客户端和服务器之间的连接丢失时立即抛出异常。如果`false`,ClickHouse服务器在抛出异常之前会尝试执行查询三次。请注意,重试会导致响应时间增加。默认值:`false`。 - `query` – 自定义查询。可选参数。 :::note -`table` 或 `where` 字段不能与 `query` 字段一起使用。必须声明 `table` 或 `query` 中的任一字段。 +`table` 或 `where` 字段不能与 `query` 字段一起使用。并且必须声明 `table` 或 `query` 字段之一。 ::: :::note -没有显式参数 `secure`。建立 SSL 连接时,安全性是强制性的。 +没有显式的 `secure` 参数。建立SSL连接时,安全性是必需的。 ::: -MySQL 可以通过套接字连接到本地主机。为此,请设置 `host` 和 `socket`。 +可以通过套接字连接到本地主机上的MySQL。为此,请设置 `host` 和 `socket`。 设置示例: @@ -1636,19 +1642,19 @@ SOURCE(CLICKHOUSE( 设置字段: -- `host` – ClickHouse 主机。如果是本地主机,则查询无需任何网络活动即可处理。为了提高容错能力,可以创建一个[分布式](../../engines/table-engines/special/distributed.md)表并在后续配置中输入它。 -- `port` – ClickHouse 服务器的端口。 -- `user` – ClickHouse 用户名。 -- `password` – ClickHouse 用户的密码。 +- `host` – ClickHouse主机。如果是本地主机,则查询将在没有任何网络活动的情况下处理。为了提高容错能力,您可以创建一个 [Distributed](../../engines/table-engines/special/distributed.md) 表并在后续配置中输入它。 +- `port` – ClickHouse服务器上的端口。 +- `user` – ClickHouse用户的名称。 +- `password` – ClickHouse用户的密码。 - `db` – 数据库名称。 -- `table` – 表名。 -- `where` – 选择标准。可以省略。 -- `invalidate_query` – 检查字典状态的查询。可选参数。请参阅[使用生存时间刷新字典数据](#refreshing-dictionary-data-using-lifetime)部分了解更多信息。 -- `secure` - 使用 SSL 进行连接。 +- `table` – 表名称。 +- `where` – 选择条件。可以省略。 +- `invalidate_query` – 检查字典状态的查询。可选参数。请参阅 [使用LIFETIME刷新的字典数据](#refreshing-dictionary-data-using-lifetime)部分以了解更多信息。 +- `secure` - 使用ssl进行连接。 - `query` – 自定义查询。可选参数。 :::note -`table` 或 `where` 字段不能与 `query` 字段一起使用。必须声明 `table` 或 `query` 中的任一字段。 +`table` 或 `where` 字段不能与 `query` 字段一起使用。并且必须声明 `table` 或 `query` 字段之一。 ::: #### MongoDB {#mongodb} @@ -1695,13 +1701,13 @@ SOURCE(MONGODB( 设置字段: -- `host` – MongoDB 主机。 -- `port` – MongoDB 服务器的端口。 -- `user` – MongoDB 用户名。 -- `password` – MongoDB 用户的密码。 +- `host` – MongoDB主机。 +- `port` – MongoDB服务器上的端口。 +- `user` – MongoDB用户的名称。 +- `password` – MongoDB用户的密码。 - `db` – 数据库名称。 - `collection` – 集合名称。 -- `options` - MongoDB 连接字符串选项(可选参数)。 +- `options` - MongoDB连接字符串选项(可选参数)。 或 @@ -1714,10 +1720,10 @@ SOURCE(MONGODB( 设置字段: -- `uri` - 用于建立连接的 URI。 +- `uri` - 建立连接的URI。 - `collection` – 集合名称。 -[有关引擎的更多信息](../../engines/table-engines/integrations/mongodb.md) +[引擎的更多信息](../../engines/table-engines/integrations/mongodb.md) #### Redis {#redis} 设置示例: @@ -1746,10 +1752,10 @@ SOURCE(REDIS( 设置字段: -- `host` – Redis 主机。 -- `port` – Redis 服务器的端口。 -- `storage_type` – 用于处理键的 Redis 内部存储的结构。`simple` 用于简单源和哈希单键源,`hash_map` 用于具有两个键的哈希源。范围源和具有复杂键的缓存源不受支持。可以省略,默认值为 `simple`。 -- `db_index` – Redis 逻辑数据库的特定数字索引。可以省略,默认值为 0。 +- `host` – Redis主机。 +- `port` – Redis服务器上的端口。 +- `storage_type` – 用于与键一起工作的内部Redis存储的结构。 `simple` 用于简单源和散列单键源, `hash_map` 用于具有两个键的散列源。不支持范围源和具有复杂键的缓存源。可以省略,默认值为 `simple`。 +- `db_index` – Redis逻辑数据库的特定数字索引。可以省略,默认值为0。 #### Cassandra {#cassandra} 设置示例: @@ -1775,21 +1781,21 @@ SOURCE(REDIS( 设置字段: -- `host` – Cassandra 主机或以逗号分隔的主机列表。 -- `port` – Cassandra 服务器的端口。如果未指定,则使用默认端口 9042。 -- `user` – Cassandra 用户名。 -- `password` – Cassandra 用户的密码。 -- `keyspace` – 密钥空间(数据库)的名称。 -- `column_family` – 列族(表)的名称。 -- `allow_filtering` – 标志,指示是否允许在聚类键列上使用潜在代价高昂的条件。默认值为 1。 -- `partition_key_prefix` – Cassandra 表的主键中分区键列的数量。合成键字典所需。字典定义中的键列顺序必须与 Cassandra 中的一致。默认值为 1(第一个键列为分区键,其他键列为聚类键)。 -- `consistency` – 一致性级别。可能的值:`One`,`Two`,`Three`,`All`,`EachQuorum`,`Quorum`,`LocalQuorum`,`LocalOne`,`Serial`,`LocalSerial`。默认值为 `One`。 -- `where` – 可选选择标准。 -- `max_threads` – 在合成键字典中从多个分区加载数据时使用的最大线程数。 +- `host` – Cassandra主机或以逗号分隔的主机列表。 +- `port` – Cassandra服务器上的端口。如果未指定,则使用默认端口9042。 +- `user` – Cassandra用户的名称。 +- `password` – Cassandra用户的密码。 +- `keyspace` – 键空间(数据库)的名称。 +- `column_family` – 列簇(表)的名称。 +- `allow_filtering` – 允许或不允许针对集群键列的潜在开销条件的标志。默认值为1。 +- `partition_key_prefix` – Cassandra表主键中分区键列的数量。为复合键字典所需。字典定义中的键列顺序必须与Cassandra中的相同。默认值为1(第一个键列是分区键,其他键列是集群键)。 +- `consistency` – 一致性级别。可能的值: `One`, `Two`, `Three`, `All`, `EachQuorum`, `Quorum`, `LocalQuorum`, `LocalOne`, `Serial`, `LocalSerial`。默认值为`One`。 +- `where` – 可选选择条件。 +- `max_threads` – 用于从复合键字典中的多个分区加载数据的最大线程数。 - `query` – 自定义查询。可选参数。 :::note -`column_family` 或 `where` 字段不能与 `query` 字段一起使用。必须声明 `column_family` 或 `query` 中的任一字段。 +`column_family` 或 `where` 字段不能与 `query` 字段一起使用。并且必须声明 `column_family` 或 `query` 字段之一。 ::: #### PostgreSQL {#postgresql} @@ -1831,27 +1837,27 @@ SOURCE(POSTGRESQL( 设置字段: -- `host` – PostgreSQL 服务器上的主机。您可以为所有副本指定此项,或单独为每个副本(在 `` 内)。 -- `port` – PostgreSQL 服务器上的端口。您可以为所有副本指定此项,或单独为每个副本(在 `` 内)。 -- `user` – PostgreSQL 用户名。您可以为所有副本指定此项,或单独为每个副本(在 `` 内)。 -- `password` – PostgreSQL 用户的密码。您可以为所有副本指定此项,或单独为每个副本(在 `` 内)。 -- `replica` – 副本配置的部分。可以有多个部分: - - `replica/host` – PostgreSQL 主机。 - - `replica/port` – PostgreSQL 端口。 - - `replica/priority` – 副本优先级。在尝试连接时,ClickHouse 按优先级顺序遍历副本。数字越小,优先级越高。 +- `host` – PostgreSQL服务器上的主机。您可以为所有副本指定它,或为每个副本单独指定(在 `` 中)。 +- `port` – PostgreSQL服务器上的端口。您可以为所有副本指定它,或为每个副本单独指定(在 `` 中)。 +- `user` – PostgreSQL用户的名称。您可以为所有副本指定它,或为每个副本单独指定(在 `` 中)。 +- `password` – PostgreSQL用户的密码。您可以为所有副本指定它,或为每个副本单独指定(在 `` 中)。 +- `replica` – 副本配置的节。可以有多个部分: + - `replica/host` – PostgreSQL主机。 + - `replica/port` – PostgreSQL端口。 + - `replica/priority` – 副本优先级。尝试连接时,ClickHouse按优先级顺序遍历副本。数字越低,优先级越高。 - `db` – 数据库名称。 -- `table` – 表名。 -- `where` – 选择标准。条件的语法与 PostgreSQL 中的 `WHERE` 子句相同。例如,`id > 10 AND id < 20`。可选参数。 -- `invalidate_query` – 检查字典状态的查询。可选参数。请参阅[使用生存时间刷新字典数据](#refreshing-dictionary-data-using-lifetime)部分了解更多信息。 -- `background_reconnect` – 如果连接失败,则在后台重新连接到副本。可选参数。 +- `table` – 表名称。 +- `where` – 选择条件。条件的语法与PostgreSQL中的 `WHERE` 子句相同。例如, `id > 10 AND id < 20`。可选参数。 +- `invalidate_query` – 检查字典状态的查询。可选参数。请参阅 [使用LIFETIME刷新的字典数据](#refreshing-dictionary-data-using-lifetime)部分以了解更多信息。 +- `background_reconnect` – 如果连接失败,后台重新连接到副本。可选参数。 - `query` – 自定义查询。可选参数。 :::note -`table` 或 `where` 字段不能与 `query` 字段一起使用。必须声明 `table` 或 `query` 中的任一字段。 +`table` 或 `where` 字段不能与 `query` 字段一起使用。并且必须声明 `table` 或 `query` 字段之一。 ::: ### Null {#null} -一种特殊源,可用于创建虚拟(空)字典。这些字典对测试或在分布式表节点上分开数据和查询节点的设置有用。 +一个特殊的源,可用于创建虚拟(空)字典。这些字典可以用于测试或在具有分布式表的数据节点和查询节点分开的设置中。 ```sql CREATE DICTIONARY null_dict ( @@ -1869,9 +1875,9 @@ LIFETIME(0); -`structure` 子句描述可用于查询的字典键和字段。 +`structure` 子句描述了字典键和可用于查询的字段。 -XML 描述: +XML描述: ```xml @@ -1895,7 +1901,7 @@ XML 描述: - `` — 键列 - `` — 数据列:可以有多个属性。 -DDL 查询: +DDL查询: ```sql CREATE DICTIONARY dict_name ( @@ -1912,19 +1918,19 @@ PRIMARY KEY Id - `AttrName AttrType` — 数据列。可以有多个属性。 ## 键 {#key} -ClickHouse 支持以下类型的键: +ClickHouse支持以下类型的键: -- 数字键。`UInt64`。在 `` 标签中定义,或使用 `PRIMARY KEY` 关键字。 -- 组合键。不同类型值的集合。在 `` 标签中定义或使用 `PRIMARY KEY` 关键字。 +- 数字键。 `UInt64`。在 `` 标签或使用 `PRIMARY KEY` 关键字中定义。 +- 复合键。不同类型值的集合。在 `` 标签或 `PRIMARY KEY` 关键字中定义。 -xml 结构可以包含 `` 或 ``。DDL 查询必须包含单一的 `PRIMARY KEY`。 +xml结构可以包含 `` 或 ``。DDL查询必须包含单一的 `PRIMARY KEY`。 :::note 您不得将键描述为属性。 ::: ### 数字键 {#numeric-key} -类型:`UInt64`。 +类型: `UInt64`。 配置示例: @@ -1938,7 +1944,7 @@ xml 结构可以包含 `` 或 ``。DDL 查询必须包含单一的 `PRI - `name` – 键列的名称。 -对于 DDL 查询: +对于DDL查询: ```sql CREATE DICTIONARY ( @@ -1950,15 +1956,15 @@ PRIMARY KEY Id ``` - `PRIMARY KEY` – 键列的名称。 -### 组合键 {#composite-key} +### 复合键 {#composite-key} -键可以是任何类型字段的 `tuple`。在这种情况下,布局必须是 `complex_key_hashed` 或 `complex_key_cache`。 +键可以是任何类型字段的 `tuple`。在这种情况下, [布局](#storing-dictionaries-in-memory) 必须是 `complex_key_hashed` 或 `complex_key_cache`。 :::tip -组合键可以由单个元素组成。这使得可以将字符串作为键。 +复合键可以由单个元素组成。这使得可以使用字符串作为键,例如。 ::: -键结构在 `` 元素中设置。键字段的格式与字典[属性](#dictionary-key-and-fields)相同。示例: +键结构在 `` 元素中设置。键字段按照与字典 [属性](#dictionary-key-and-fields) 相同的格式指定。示例: ```xml @@ -1981,14 +1987,14 @@ PRIMARY KEY Id ```sql CREATE DICTIONARY ( field1 String, - field2 String + field2 UInt32 ... ) PRIMARY KEY field1, field2 ... ``` -对于 `dictGet*` 函数的查询,作为键传递一个元组。示例:`dictGetString('dict_name', 'attr_name', tuple('field1 的字符串', num_for_field2))`。 +对于对 `dictGet*` 函数的查询,作为键传递元组。示例: `dictGetString('dict_name', 'attr_name', tuple('string for field1', num_for_field2))`。 ## 属性 {#attributes} 配置示例: @@ -2018,20 +2024,20 @@ CREATE DICTIONARY somename ( 配置字段: -| 标签 | 描述 | 必需 | -|------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------| -| `name` | 列名称。 | 是 | -| `type` | ClickHouse 数据类型:[UInt8](../../sql-reference/data-types/int-uint.md),[UInt16](../../sql-reference/data-types/int-uint.md),[UInt32](../../sql-reference/data-types/int-uint.md),[UInt64](../../sql-reference/data-types/int-uint.md),[Int8](../../sql-reference/data-types/int-uint.md),[Int16](../../sql-reference/data-types/int-uint.md),[Int32](../../sql-reference/data-types/int-uint.md),[Int64](../../sql-reference/data-types/int-uint.md),[Float32](../../sql-reference/data-types/float.md),[Float64](../../sql-reference/data-types/float.md),[UUID](../../sql-reference/data-types/uuid.md),[Decimal32](../../sql-reference/data-types/decimal.md),[Decimal64](../../sql-reference/data-types/decimal.md),[Decimal128](../../sql-reference/data-types/decimal.md),[Decimal256](../../sql-reference/data-types/decimal.md),[Date](../../sql-reference/data-types/date.md),[Date32](../../sql-reference/data-types/date32.md),[DateTime](../../sql-reference/data-types/datetime.md),[DateTime64](../../sql-reference/data-types/datetime64.md),[String](../../sql-reference/data-types/string.md),[Array](../../sql-reference/data-types/array.md)。
ClickHouse 尝试将字典中的值转换为指定的数据类型。例如,对于 MySQL,源表中的字段可以是 `TEXT`,`VARCHAR` 或 `BLOB`,但在 ClickHouse 中可以以 `String` 上传。
[Nullable](../../sql-reference/data-types/nullable.md) 当前支持[Flat](#flat),[Hashed](#hashed),[ComplexKeyHashed](#complex_key_hashed),[Direct](#direct),[ComplexKeyDirect](#complex_key_direct),[RangeHashed](#range_hashed),Polygon,[Cache](#cache),[ComplexKeyCache](#complex_key_cache),[SSDCache](#ssd_cache),[SSDComplexKeyCache](#complex_key_ssd_cache) 字典。`IPTrie` 字典中不支持 `Nullable` 类型。 | 是 | -| `null_value` | 非现有元素的默认值。
在本示例中,它是一个空字符串。仅对于 `Nullable` 类型(见上面有关类型描述的行)可以使用[NULL](../syntax.md#null)值。 | 是 | -| `expression` | ClickHouse 对值执行的[表达式](../../sql-reference/syntax.md#expressions)。
该表达式可以是远程 SQL 数据库中的列名。因此,您可以使用它为远程列创建别名。

默认值:没有表达式。 | 否 | -| `hierarchical` | 如果为 `true`,则该属性包含当前键的父键值。请参见[分层字典](#hierarchical-dictionaries)。

默认值:`false`。 | 否 | -| `injective` | 标志,指示 `id -> 属性` 映像是否是[单射](https://en.wikipedia.org/wiki/Injective_function)。
如果为 `true`,ClickHouse 可以在 `GROUP BY` 子句后自动放置注入字典的请求。通常这会显著减少此类请求的数量。

默认值:`false`。 | 否 | -| `is_object_id` | 标志,指示查询是否是通过 `ObjectID` 执行的 MongoDB 文档。

默认值:`false`。 -## 分层字典 {#hierarchical-dictionaries} +| 标签 | 描述 | 必需 | +|------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------| +| `name` | 列名称。 | 是 | +| `type` | ClickHouse数据类型:[UInt8](../../sql-reference/data-types/int-uint.md)、[UInt16](../../sql-reference/data-types/int-uint.md)、[UInt32](../../sql-reference/data-types/int-uint.md)、[UInt64](../../sql-reference/data-types/int-uint.md)、[Int8](../../sql-reference/data-types/int-uint.md)、[Int16](../../sql-reference/data-types/int-uint.md)、[Int32](../../sql-reference/data-types/int-uint.md)、[Int64](../../sql-reference/data-types/int-uint.md)、[Float32](../../sql-reference/data-types/float.md)、[Float64](../../sql-reference/data-types/float.md)、[UUID](../../sql-reference/data-types/uuid.md)、[Decimal32](../../sql-reference/data-types/decimal.md)、[Decimal64](../../sql-reference/data-types/decimal.md)、[Decimal128](../../sql-reference/data-types/decimal.md)、[Decimal256](../../sql-reference/data-types/decimal.md)、[Date](../../sql-reference/data-types/date.md)、[Date32](../../sql-reference/data-types/date32.md)、[DateTime](../../sql-reference/data-types/datetime.md)、[DateTime64](../../sql-reference/data-types/datetime64.md)、[String](../../sql-reference/data-types/string.md)、[Array](../../sql-reference/data-types/array.md)。
ClickHouse尝试将字典中的值转换为指定数据类型。例如,对于MySQL,字段在MySQL源表中可能是 `TEXT`、`VARCHAR` 或 `BLOB`,但可以在ClickHouse中上传为 `String`。
当前支持 [Nullable](../../sql-reference/data-types/nullable.md) 适用于 [Flat](#flat)、[Hashed](#hashed)、[ComplexKeyHashed](#complex_key_hashed)、[Direct](#direct)、[ComplexKeyDirect](#complex_key_direct)、[RangeHashed](#range_hashed)、Polygon、[Cache](#cache)、[ComplexKeyCache](#complex_key_cache)、[SSDCache](#ssd_cache)、[SSDComplexKeyCache](#complex_key_ssd_cache) 字典。在 [IPTrie](#ip_trie) 字典中不支持 `Nullable` 类型。 | 是 | +| `null_value` | 非现有元素的默认值。
在此示例中,它是一个空字符串。[NULL](../syntax.md#null) 值只能用于 `Nullable` 类型(请参见上面的类型描述)。 | 是 | +| `expression` | ClickHouse在值上执行的 [表达式](../../sql-reference/syntax.md#expressions)。
该表达式可以是远程SQL数据库中的列名称。因此,您可以使用它为远程列创建别名。

默认值:无表达式。 | 否 | +| `hierarchical` | 如果为 `true`,属性包含当前键的父键值。请参见 [层次字典](#hierarchical-dictionaries)。

默认值: `false`。 | 否 | +| `injective` | 显示 `id -> attribute` 映像是否为 [单射](https://en.wikipedia.org/wiki/Injective_function) 的标志。
如果为 `true`,ClickHouse可以在 `GROUP BY` 子句之后自动放置请求以进行字典注入。通常,这显著减少了此类请求的数量。

默认值: `false`。 | 否 | +| `is_object_id` | 表示查询是否通过 `ObjectID` 为MongoDB文档执行的标志。

默认值: `false`。 +## 层次字典 {#hierarchical-dictionaries} -ClickHouse 支持具有[数字键](#numeric-key)的分层字典。 +ClickHouse 支持带有 [数字键](#numeric-key) 的层次字典。 -请查看以下分层结构: +请查看以下层次结构: ```text 0 (Common parent) @@ -2051,19 +2057,19 @@ ClickHouse 支持具有[数字键](#numeric-key)的分层字典。 | region_id | parent_region | region_name | |------------|----------------|---------------| -| 1 | 0 | 俄罗斯 | -| 2 | 1 | 莫斯科 | -| 3 | 2 | 中心 | +| 1 | 0 | 俄罗斯 | +| 2 | 1 | 莫斯科 | +| 3 | 2 | 中心 | | 4 | 0 | 大不列颠 | -| 5 | 4 | 伦敦 | +| 5 | 4 | 伦敦 | -该表包含一个名为 `parent_region` 的列,该列包含该元素最近父键的键值。 +该表包含一列 `parent_region`,其中包含该元素最近父级的键。 -ClickHouse 支持外部字典属性的分层属性。此属性允许您配置类似于上述描述的分层字典。 +ClickHouse 支持外部字典属性的层次特性。该特性允许您配置层次字典,类似于上述描述。 [dictGetHierarchy](../../sql-reference/functions/ext-dict-functions.md#dictgethierarchy) 函数允许您获取元素的父链。 -对于我们的示例,字典的结构可以是以下内容: +在我们的示例中,字典的结构可以是以下内容: ```xml @@ -2088,12 +2094,13 @@ ClickHouse 支持外部字典属性的分层属性。此属性允许您配置类
``` -## Polygon dictionaries {#polygon-dictionaries} +## 多边形字典 {#polygon-dictionaries} -Polygon dictionaries 允许您高效搜索包含指定点的多边形。 -例如:通过地理坐标定义一个城市区域。 +该字典针对点在多边形查询进行了优化,基本上是“反向地理编码”查找。给定一个坐标(纬度/经度),它高效地找到包含该点的多边形/区域(从一组多边形中,例如国家或地区边界)。它非常适合将位置坐标映射到其包含区域。 -多边形字典配置示例: + + +多边形字典配置的示例: @@ -2130,7 +2137,7 @@ Polygon dictionaries 允许您高效搜索包含指定点的多边形。 ``` -相应的 [DDL-query](/sql-reference/statements/create/dictionary): +相应的 [DDL-query](/sql-reference/statements/create/dictionary): ```sql CREATE DICTIONARY polygon_dict_name ( key Array(Array(Array(Array(Float64)))), @@ -2142,35 +2149,35 @@ LAYOUT(POLYGON(STORE_POLYGON_KEY_COLUMN 1)) ... ``` -在配置多边形字典时,键必须具有以下两种类型之一: +在配置多边形字典时,键必须属于以下两种类型之一: -- 简单多边形。这是一个点的数组。 -- 多多边形。这是一个多边形的数组。每个多边形是一个二维点的数组。该数组的第一个元素是多边形的外边界,后续元素指定要从中排除的区域。 +- 简单多边形。它是一个点的数组。 +- 多个多边形。它是一个多边形的数组。每个多边形是一个二维点的数组。该数组的第一个元素是多边形的外部边界,后续元素指定要从中排除的区域。 -点可以作为坐标的数组或元组指定。在当前实现中,仅支持二维点。 +点可以作为数组或其坐标的元组进行指定。在当前实现中,仅支持二维点。 -用户可以上传自己的数据,格式为 ClickHouse 支持的所有格式。 +用户可以以 ClickHouse 支持的所有格式上传自己的数据。 -有 3 种类型的 [in-memory storage](#storing-dictionaries-in-memory) 可用: +有 3 种可用的 [内存存储类型](#storing-dictionaries-in-memory): -- `POLYGON_SIMPLE`。这是一种简单的实现,对于每个查询,都会线性遍历所有多边形,并在不使用额外索引的情况下检查每一个的成员资格。 +- `POLYGON_SIMPLE`。这是一个简单的实现,对于每个查询,它会线性地遍历所有多边形,并且不使用额外索引来检查每个多边形的成员资格。 -- `POLYGON_INDEX_EACH`。为每个多边形构建一个单独的索引,大多数情况下实现快速检查其所属关系(针对地理区域进行了优化)。 -此外,在考虑的区域上叠加一个网格,这显著缩小了需要考虑的多边形数量。 -该网格通过递归将单元格分成 16 个相等部分创建,并用两个参数进行配置。 -当递归深度达到 `MAX_DEPTH` 或单元格交叉不超过 `MIN_INTERSECTIONS` 个多边形时,分割停止。 -在响应查询时,有一个相应的单元格,并交替访问存储在其中的多边形的索引。 +- `POLYGON_INDEX_EACH`。为每个多边形构建一个单独的索引,在大多数情况下允许您快速检查它是否属于该多边形(为地理区域优化)。 +此外,会在考虑范围内叠加一个网格,这显著缩小了考虑的多边形数量。 +该网格通过递归将单元格划分为 16 个相等部分来创建,并通过两个参数进行配置。 +当递归深度达到 `MAX_DEPTH` 时,或者单元格交叉的多边形不超过 `MIN_INTERSECTIONS` 时,划分停止。 +为了响应查询,会有一个相应的单元格,交替访问存储在其中的多边形索引。 -- `POLYGON_INDEX_CELL`。这种放置也创建上述描述的网格。可用相同的选项。对于每个单元格,构建一个包含进入单元格中的所有多边形片段的索引,从而快速响应请求。 +- `POLYGON_INDEX_CELL`。此放置也创建了上述描述的网格。可用相同选项。对于每个网格单元格,建立一个索引,以便快速响应请求,涵盖落入该单元中的所有多边形片段。 -- `POLYGON`。它是 `POLYGON_INDEX_CELL` 的同义词。 +- `POLYGON`。与 `POLYGON_INDEX_CELL` 同义。 -字典查询通过标准的 [functions](../../sql-reference/functions/ext-dict-functions.md) 进行,来处理字典。 -一个重要的区别是,这里的键将是您希望找到包含它们的多边形的点。 +字典查询是通过标准的 [函数](../../sql-reference/functions/ext-dict-functions.md) 来执行的,用于处理字典。 +一个重要的不同之处在于,键将是您希望找到包含它们的多边形的点。 **示例** -使用上述定义的字典的示例: +与上述定义的字典的工作示例: ```sql CREATE TABLE points ( @@ -2181,11 +2188,11 @@ CREATE TABLE points ( SELECT tuple(x, y) AS key, dictGet(dict_name, 'name', key), dictGet(dict_name, 'value', key) FROM points ORDER BY x, y; ``` -执行最后一条命令的结果,对于 'points' 表中的每个点,将找到一个包含该点的最小区域多边形,并输出请求的属性。 +作为执行最后一条命令的结果,将为 'points' 表中的每个点找到一个最小区域多边形,并输出所请求的属性。 **示例** -您可以通过 SELECT 查询读取多边形字典中的列,只需在字典配置或相应的 DDL-query 中启用 `store_polygon_key_column = 1`。 +您可以通过 SELECT 查询从多边形字典中读取列,只需在字典配置或相应的 DDL-query 中启用 `store_polygon_key_column = 1`。 查询: @@ -2220,10 +2227,12 @@ SELECT * FROM polygons_test_dictionary; ``` ## 正则表达式树字典 {#regexp-tree-dictionary} -正则表达式树字典是一种特殊类型的字典,通过正则表达式树表示键到属性的映射。有一些用例,例如解析 [User Agent](https://en.wikipedia.org/wiki/User_agent) 字符串,只需使用正则表达式树字典即可优雅地表达。 -### 在 ClickHouse 开源版中使用正则表达式树字典 {#use-regular-expression-tree-dictionary-in-clickhouse-open-source} +该字典允许根据层次正则表达式模式将键映射到值。它针对模式匹配查找进行了优化(例如,通过匹配正则表达式模式来对用户代理字符串进行分类),而不是精确的键匹配。 + + +### 在 ClickHouse 开源中使用正则表达式树字典 {#use-regular-expression-tree-dictionary-in-clickhouse-open-source} -正则表达式树字典在 ClickHouse 开源版中使用 YAMLRegExpTree 源定义,后者提供了包含正则表达式树的 YAML 文件的路径。 +正则表达式树字典在 ClickHouse 开源中是使用 YAMLRegExpTree 来源定义的,该来源提供指向包含正则表达式树的 YAML 文件的路径。 ```sql CREATE DICTIONARY regexp_dict @@ -2261,11 +2270,11 @@ LAYOUT(regexp_tree) 此配置由正则表达式树节点的列表组成。每个节点具有以下结构: - **regexp**:节点的正则表达式。 -- **attributes**:用户定义的字典属性列表。在这个例子中,有两个属性:`name` 和 `version`。第一个节点定义了这两个属性。第二个节点仅定义属性 `name`。属性 `version` 由第二个节点的子节点提供。 - - 属性的值可能包含 **回溯引用**,引用匹配正则表达式的捕获组。在这个例子中,第一个节点中属性 `version` 的值包含对匹配正则表达式中的捕获组 `(\d+[\.\d]*)` 的回溯引用 `\1`。回溯引用编号范围从 1 到 9,并且以 `$1` 或 `\1`(对于数字 1)书写。回溯引用在查询执行期间被匹配的捕获组所替换。 -- **子节点**:正则表达式树节点的子节点列表,每个子节点都有自己的属性和(可能的)子节点。当进行字符串匹配时,采用深度优先的方式。如果字符串与正则表达式节点匹配,则字典检查它是否也匹配节点的子节点。如果是这种情况,则分配最深匹配节点的属性。子节点的属性会覆盖同名的父节点属性。YAML 文件中子节点的名称可以是任意的,例如上例中的 `versions`。 +- **attributes**:用户定义字典属性的列表。在此示例中,有两个属性:`name` 和 `version`。第一个节点定义了这两个属性。第二个节点仅定义属性 `name`。属性 `version` 由第二个节点的子节点提供。 + - 属性的值可以包含 **回溯引用**,引用匹配正则表达式的捕获组。在示例中,首节点的属性 `version` 的值由对捕获组 `(\d+[\.\d]*)` 的回溯引用 `\1` 组成。回溯引用的数字范围从 1 到 9,并以 `$1` 或 `\1`(对于数字 1)表示。在查询执行期间,回溯引用被匹配的捕获组替换。 +- **子节点**:正则表达式树节点的子节点列表,每个子节点都有其自身的属性和(可能的)子节点。字符串匹配以深度优先的方式进行。如果字符串匹配一个正则表达式节点,字典将检查它是否也是节点子节点的匹配。如果是这种情况,则分配最深匹配节点的属性。子节点的属性覆盖同名父节点的属性。YAML 文件中子节点的名称可以是任意的,例如上述示例中的 `versions`。 -正则表达式树字典只允许使用 `dictGet`、`dictGetOrDefault` 和 `dictGetAll` 函数进行访问。 +正则表达式树字典仅允许使用 `dictGet`、`dictGetOrDefault` 和 `dictGetAll` 函数访问。 示例: @@ -2281,14 +2290,14 @@ SELECT dictGet('regexp_dict', ('name', 'version'), '31/tclwebkit1024'); └─────────────────────────────────────────────────────────────────┘ ``` -在此情况下,我们首先在顶层的第二个节点中匹配正则表达式 `\d+/tclwebkit(?:\d+[\.\d]*)`。然后,字典继续查找子节点,并发现该字符串也与 `3[12]/tclwebkit` 匹配。因此,属性 `name` 的值为 `Android`(在第一层中定义),而属性 `version` 的值为 `12`(在子节点中定义)。 +在这种情况下,我们首先在顶层的第二个节点中匹配正则表达式 `\d+/tclwebkit(?:\d+[\.\d]*)`。然后字典继续查找子节点,并发现在 `3[12]/tclwebkit` 中字符串也匹配。因此,属性 `name` 的值为 `Android`(在第一层定义),而属性 `version` 的值为 `12`(在子节点中定义)。 -通过强大的 YAML 配置文件,我们可以将正则表达式树字典用作 User Agent 字符串解析器。我们支持 [uap-core](https://github.com/ua-parser/uap-core),并演示如何在功能测试中使用它 [02504_regexp_dictionary_ua_parser](https://github.com/ClickHouse/ClickHouse/blob/master/tests/queries/0_stateless/02504_regexp_dictionary_ua_parser.sh) +通过强大的 YAML 配置文件,我们可以将正则表达式树字典用作用户代理字符串解析器。我们支持 [uap-core](https://github.com/ua-parser/uap-core) 并演示如何在功能测试中使用它 [02504_regexp_dictionary_ua_parser](https://github.com/ClickHouse/ClickHouse/blob/master/tests/queries/0_stateless/02504_regexp_dictionary_ua_parser.sh) #### 收集属性值 {#collecting-attribute-values} -有时返回多个正则表达式匹配的值,而不仅仅是叶子节点的值是有用的。在这些情况下,可以使用专门的 [`dictGetAll`](../../sql-reference/functions/ext-dict-functions.md#dictgetall) 函数。如果某个节点的属性值类型为 `T`,则 `dictGetAll` 将返回一个包含零个或多个值的 `Array(T)`。 +有时返回多个匹配的正则表达式的值比仅返回叶节点的值更有用。在这些情况下,可以使用专门的 [`dictGetAll`](../../sql-reference/functions/ext-dict-functions.md#dictgetall) 函数。如果一个节点有类型为 `T` 的属性值,`dictGetAll` 将返回一个包含零个或多个值的 `Array(T)`。 -默认情况下,每个键返回的匹配数是无限制的。可以将边界作为可选的第四个参数传递给 `dictGetAll`。该数组按 _拓扑顺序_ 填充,这意味着子节点在父节点之前,兄弟节点遵循源中的顺序。 +默认情况下,对于每个键返回的匹配数量是无限制的。可以将边界作为可选的第四个参数传递给 `dictGetAll`。数组是按照 _拓扑顺序_ 填充的,这意味着子节点在父节点之前,兄弟节点按源中的顺序跟随。 示例: @@ -2347,12 +2356,12 @@ SELECT url, dictGetAll('regexp_dict', ('tag', 'topological_index', 'captured', ' ``` #### 匹配模式 {#matching-modes} -通过某些字典设置可以修改模式匹配行为: -- `regexp_dict_flag_case_insensitive`:使用不区分大小写的匹配(默认值为 `false`)。可以通过个别表达式中的 `(?i)` 和 `(?-i)` 重写。 -- `regexp_dict_flag_dotall`:允许 `.` 匹配换行符(默认值为 `false`)。 +模式匹配行为可以通过某些字典设置进行修改: +- `regexp_dict_flag_case_insensitive`:使用不区分大小写的匹配(默认为 `false`)。可以在单个表达式中使用 `(?i)` 和 `(?-i)` 进行覆盖。 +- `regexp_dict_flag_dotall`:允许 '.' 匹配换行符(默认为 `false`)。 ### 在 ClickHouse Cloud 中使用正则表达式树字典 {#use-regular-expression-tree-dictionary-in-clickhouse-cloud} -上述使用的 `YAMLRegExpTree` 源可在 ClickHouse 开源版中工作,但在 ClickHouse Cloud 中不适用。要在 ClickHouse 云中使用正则表达式树字典,首先在 ClickHouse 开源版中从 YAML 文件创建一个正则表达式树字典,然后使用 `dictionary` 表函数和 [INTO OUTFILE](../statements/select/into-outfile.md) 子句将此字典转储到 CSV 文件中。 +上面使用的 `YAMLRegExpTree` 来源在 ClickHouse 开源中有效,但在 ClickHouse Cloud 中无效。要在 ClickHouse Cloud 中使用正则表达式树字典,首先在 ClickHouse 开源的本地从 YAML 文件创建正则表达式树字典,然后使用 `dictionary` 表函数和 [INTO OUTFILE](../statements/select/into-outfile.md) 子句将该字典导出到 CSV 文件中。 ```sql SELECT * FROM dictionary(regexp_dict) INTO OUTFILE('regexp_dict.csv') @@ -2369,15 +2378,15 @@ CSV 文件的内容为: 6,2,"3[12]/tclwebkit","['version']","['10']" ``` -转储文件的模式为: +导出文件的模式为: - `id UInt64`:RegexpTree 节点的 ID。 -- `parent_id UInt64`:节点的父节点 ID。 +- `parent_id UInt64`:节点的父级 ID。 - `regexp String`:正则表达式字符串。 - `keys Array(String)`:用户定义属性的名称。 - `values Array(String)`:用户定义属性的值。 -要在 ClickHouse Cloud 中创建字典,首先使用以下表结构创建表 `regexp_dictionary_source_table`: +要在 ClickHouse Cloud 中创建字典,首先创建一个表 `regexp_dictionary_source_table`,其表结构如下: ```sql CREATE TABLE regexp_dictionary_source_table @@ -2390,7 +2399,7 @@ CREATE TABLE regexp_dictionary_source_table ) ENGINE=Memory; ``` -然后通过 +然后通过如下更新本地 CSV: ```bash clickhouse client \ @@ -2403,7 +2412,7 @@ clickhouse client \ FORMAT CSV" < regexp_dict.csv ``` -更新本地 CSV 文件。您可以查看如何 [Insert Local Files](/integrations/data-ingestion/insert-local-files) 了解更多细节。初始化源表后,我们可以通过表源创建 RegexpTree: +有关更多详细信息,请参见 [插入本地文件](/integrations/data-ingestion/insert-local-files)。初始化源表后,我们可以通过表源创建 RegexpTree: ```sql CREATE DICTIONARY regexp_dict @@ -2416,51 +2425,51 @@ SOURCE(CLICKHOUSE(TABLE 'regexp_dictionary_source_table')) LIFETIME(0) LAYOUT(regexp_tree); ``` -## 嵌入式字典 {#embedded-dictionaries} +## 嵌入字典 {#embedded-dictionaries} -ClickHouse 包含用于处理地理数据库的内置功能。 +ClickHouse 包含一个用于处理地理基础的内置功能。 这允许您: -- 使用区域 ID 获取其所需语言的名称。 -- 使用区域 ID 获取城市、地区、联邦区、国家或大洲的 ID。 -- 检查某个区域是否属于另一个区域。 -- 获取父区域的链。 +- 使用地区 ID 获取所需语言中的名称。 +- 使用地区 ID 获取城市、地区、联邦区、国家或洲的 ID。 +- 检查一个地区是否属于另一个地区。 +- 获取父地区的链条。 -所有函数都支持“跨地域性”,即同时使用不同的区域归属视角的能力。有关更多信息,请参见“处理网络分析字典的函数”部分。 +所有函数都支持“跨境性”,即能够同时使用不同的区域所有权视角。有关更多信息,请参见“处理网络分析字典的函数”部分。 -默认包中禁用内部字典。 -要启用它们,请在服务器配置文件中取消对 `path_to_regions_hierarchy_file` 和 `path_to_regions_names_files` 参数的注释。 +默认包中禁用了内部字典。 +要启用它们,请在服务器配置文件中取消注释 `path_to_regions_hierarchy_file` 和 `path_to_regions_names_files` 的参数。 -地理数据库从文本文件加载。 +地理基础从文本文件加载。 -将 `regions_hierarchy*.txt` 文件放入 `path_to_regions_hierarchy_file` 目录。该配置参数必须包含 `regions_hierarchy.txt` 文件(默认地区层次结构)的路径,其他文件(`regions_hierarchy_ua.txt`)必须放置在同一目录中。 +将 `regions_hierarchy*.txt` 文件放入 `path_to_regions_hierarchy_file` 目录中。该配置参数必须包含 `regions_hierarchy.txt` 文件(默认区域层次)的路径,而其他文件(`regions_hierarchy_ua.txt`)必须位于同一目录中。 -将 `regions_names_*.txt` 文件放入 `path_to_regions_names_files` 目录。 +将 `regions_names_*.txt` 文件放入 `path_to_regions_names_files` 目录中。 您也可以自己创建这些文件。文件格式如下: `regions_hierarchy*.txt`:制表符分隔(无标题),列: -- 区域 ID (`UInt32`) -- 父区域 ID (`UInt32`) -- 区域类型 (`UInt8`):1 - 大洲,3 - 国家,4 - 联邦区,5 - 区域,6 - 城市;其他类型没有值 +- 地区 ID (`UInt32`) +- 父地区 ID (`UInt32`) +- 地区类型 (`UInt8`):1 - 洲,3 - 国家,4 - 联邦区,5 - 地区,6 - 城市;其他类型没有值 - 人口 (`UInt32`) — 可选列 `regions_names_*.txt`:制表符分隔(无标题),列: -- 区域 ID (`UInt32`) -- 区域名称 (`String`) — 不能包含制表符或换行符,即便是转义的。 +- 地区 ID (`UInt32`) +- 地区名称 (`String`) — 不能包含制表符或换行符,甚至是转义的。 -使用扁平数组在 RAM 中存储,因此 ID 不应超过一百万。 +在 RAM 中使用平面数组进行存储。因此,ID 值不应超过一百万。 -字典可以在不重启服务器的情况下更新。然而,可用字典集不会更新。 -对于更新,检查文件修改时间。如果文件更改,则更新字典。 -检查更改的间隔由 `builtin_dictionaries_reload_interval` 参数配置。 -字典更新(除了初次使用时加载外)不会阻塞查询。在更新期间,查询使用旧版本的字典。如果在更新期间发生错误,错误将记录到服务器日志中,查询将继续使用旧版本的字典。 +字典可以在不重启服务器的情况下更新。但是,可用字典的集合不会更新。 +对于更新,检查文件的修改时间。如果文件已更改,字典将被更新。 +检查变化的间隔在 `builtin_dictionaries_reload_interval` 参数中配置。 +字典更新(除了首次使用时的加载)不会阻塞查询。在更新期间,查询使用旧版本的字典。如果在更新过程中出现错误,错误将被记录到服务器日志中,查询将继续使用旧版本的字典。 -我们建议定期更新带有地理数据库的字典。在更新期间,生成新文件并将其写入单独位置。当一切准备就绪后,重命名这些文件以替换服务器使用的文件。 +我们建议定期更新与地理基础相关的字典。在更新期间,生成新文件并将其写入单独的位置。准备好后,将它们重命名为服务器使用的文件。 -还有一些用于处理操作系统标识符和搜索引擎的功能,但不应使用。 +还有用于处理操作系统标识符和搜索引擎的函数,但不应使用。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/dictionaries/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/dictionaries/index.md.hash index 444e409bc70..546c48151d3 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/dictionaries/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/dictionaries/index.md.hash @@ -1 +1 @@ -f16c946bc2bffcd3 +55adb634d3ca229e diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/distributed-ddl.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/distributed-ddl.md index 93f472b27ce..9e56d1b4134 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/distributed-ddl.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/distributed-ddl.md @@ -4,20 +4,21 @@ 'sidebar_position': 3 'slug': '/sql-reference/distributed-ddl' 'title': '分布式 DDL 查询 (ON CLUSTER 子句)' +'doc_type': 'reference' --- -默认情况下,`CREATE`、`DROP`、`ALTER` 和 `RENAME` 查询仅影响执行这些操作的当前服务器。在集群设置中,可以使用 `ON CLUSTER` 子句以分布式方式运行此类查询。 +默认情况下,`CREATE`、`DROP`、`ALTER` 和 `RENAME` 查询仅影响执行它们的当前服务器。在集群设置中,可以使用 `ON CLUSTER` 子句以分布式方式运行这些查询。 -例如,以下查询在 `cluster` 中每个主机上创建 `all_hits` `Distributed` 表: +例如,以下查询将在 `cluster` 中的每个主机上创建 `all_hits` `Distributed` 表: ```sql CREATE TABLE IF NOT EXISTS all_hits ON CLUSTER cluster (p Date, i Int32) ENGINE = Distributed(cluster, default, hits) ``` -为了正确执行这些查询,每个主机必须具有相同的集群定义(为了简化配置同步,您可以使用来自 ZooKeeper 的替换)。它们还必须连接到 ZooKeeper 服务器。 +为了正确运行这些查询,每个主机必须具有相同的集群定义(为了简化配置同步,您可以使用来自 ZooKeeper 的替换)。它们还必须连接到 ZooKeeper 服务器。 -尽管某些主机当前不可用,但查询的本地版本最终将在集群中的每个主机上执行。 +即使一些主机当前不可用,查询的本地版本最终仍将在集群中的每个主机上执行。 - :::important -确保在单个主机内执行查询的顺序。 +:::important +在单个主机内执行查询的顺序是有保证的。 ::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/distributed-ddl.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/distributed-ddl.md.hash index 5d4cc9ecfa7..097e6119f1c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/distributed-ddl.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/distributed-ddl.md.hash @@ -1 +1 @@ -b1344b394ca65d39 +bb59ccd31de2f0ff diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/formats.mdx b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/formats.mdx index 51687018d22..02f8e301d62 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/formats.mdx +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/formats.mdx @@ -5,6 +5,7 @@ 'title': '输入和输出数据的格式' 'description': '支持的输入和输出格式' 'hide_title': true +'doc_type': 'reference' --- import Content from '../interfaces/formats.md'; diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/formats.mdx.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/formats.mdx.hash index 29c7b03a87e..9fec0f1db6b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/formats.mdx.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/formats.mdx.hash @@ -1 +1 @@ -f1091f5939b8f2ac +f36fde0da21f5700 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/arithmetic-functions.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/arithmetic-functions.md index 3443cf8bc73..f4e8b1ea12c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/arithmetic-functions.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/arithmetic-functions.md @@ -1,586 +1,43 @@ --- -'description': 'Arithmetic Functions 的文档' +'description': '算术函数的 Documentation' 'sidebar_label': 'Arithmetic' -'sidebar_position': 5 'slug': '/sql-reference/functions/arithmetic-functions' 'title': '算术函数' +'doc_type': 'reference' --- -# 算数函数 +# 算术函数 -算数函数适用于任何两个类型为 `UInt8`、`UInt16`、`UInt32`、`UInt64`、`Int8`、`Int16`、`Int32`、`Int64`、`Float32` 或 `Float64` 的操作数。 +## 概述 {#overview} -在执行操作之前,两个操作数都被强制转换为结果类型。结果类型的确定方式如下(除非在下面的函数文档中另有说明): -- 如果两个操作数的位宽都不超过32位,则结果类型的大小将为比两个操作数中较大者相应的下一个更大类型的大小(整数大小提升)。例如,`UInt8 + UInt16 = UInt32` 或 `Float32 * Float32 = Float64`。 -- 如果其中一个操作数的位数为64位或更高,则结果类型的大小将与两个操作数中较大的那一个相同。例如,`UInt32 + UInt128 = UInt128` 或 `Float32 * Float64 = Float64`。 -- 如果其中一个操作数为有符号,结果类型也将是有符号的,否则将为无符号。例如,`UInt32 * Int32 = Int64`。 +算术函数适用于任意两个 `UInt8`、`UInt16`、`UInt32`、`UInt64`、`Int8`、`Int16`、`Int32`、`Int64`、`Float32` 或 `Float64` 类型的操作数。 -这些规则确保结果类型将是最小的能够表示所有可能结果的类型。虽然这在值范围边界周围引入了溢出的风险,但它确保了使用最大本机整数宽度64位快速执行计算。这种行为还保证与许多提供64位整数(BIGINT)作为最大整数类型的其他数据库的兼容性。 +在执行操作之前,两个操作数都会被转换为结果类型。结果类型的确定如下(除非在下面的函数文档中另有说明): +- 如果两个操作数的位数都不超过 32 位,则结果类型的大小将是两个操作数中较大者的下一个较大类型的大小(整数大小提升)。例如,`UInt8 + UInt16 = UInt32` 或 `Float32 * Float32 = Float64`。 +- 如果其中一个操作数的位数为 64 或更多,则结果类型的大小将与较大操作数的大小相同。例如,`UInt32 + UInt128 = UInt128` 或 `Float32 * Float64 = Float64`。 +- 如果其中一个操作数是有符号的,则结果类型也将是有符号的,否则将是无符号的。例如,`UInt32 * Int32 = Int64`。 -示例: - -```sql -SELECT toTypeName(0), toTypeName(0 + 0), toTypeName(0 + 0 + 0), toTypeName(0 + 0 + 0 + 0) -``` - -```text -┌─toTypeName(0)─┬─toTypeName(plus(0, 0))─┬─toTypeName(plus(plus(0, 0), 0))─┬─toTypeName(plus(plus(plus(0, 0), 0), 0))─┐ -│ UInt8 │ UInt16 │ UInt32 │ UInt64 │ -└───────────────┴────────────────────────┴─────────────────────────────────┴──────────────────────────────────────────┘ -``` - -溢出产生的方式与 C++ 相同。 - -## plus {#plus} - -计算两个值 `a` 和 `b` 的和。 - -**语法** - -```sql -plus(a, b) -``` - -可以将一个整数与日期或带时间的日期相加。前者操作会增加日期中的天数,后者操作则会增加带时间的日期中的秒数。 - -别名:`a + b`(运算符) - -## minus {#minus} - -计算两个值 `a` 和 `b` 的差。结果始终为有符号。 - -与 `plus` 类似,可以从日期或带时间的日期中减去一个整数。 - -此外,支持带时间日期之间的减法,结果为它们之间的时间差。 - -**语法** - -```sql -minus(a, b) -``` - -别名:`a - b`(运算符) - -## multiply {#multiply} - -计算两个值 `a` 和 `b` 的积。 - -**语法** - -```sql -multiply(a, b) -``` - -别名:`a * b`(运算符) - -## divide {#divide} - -计算两个值 `a` 和 `b` 的商。结果类型始终为 [Float64](../data-types/float.md)。整数除法由 `intDiv` 函数提供。 - -除以 0 将返回 `inf`、`-inf` 或 `nan`。 - -**语法** - -```sql -divide(a, b) -``` - -别名:`a / b`(运算符) - -## divideOrNull {#divideornull} - -如同 [divide](#divide),但当除数为零时返回 null。 - -**语法** - -```sql -divideOrNull(a, b) -``` - -## intDiv {#intdiv} - -执行两个值 `a` 除以 `b` 的整数除法,即计算向下取整到下一个最小整数的商。 - -结果的宽度与被除数(第一个参数)相同。 - -当除以零、商不适合被除数的范围或者将最小负数除以 -1 时会抛出异常。 - -**语法** - -```sql -intDiv(a, b) -``` - -**示例** - -查询: - -```sql -SELECT - intDiv(toFloat64(1), 0.001) AS res, - toTypeName(res) -``` - -```response -┌──res─┬─toTypeName(intDiv(toFloat64(1), 0.001))─┐ -│ 1000 │ Int64 │ -└──────┴─────────────────────────────────────────┘ -``` - -```sql -SELECT - intDiv(1, 0.001) AS res, - toTypeName(res) -``` - -```response -Received exception from server (version 23.2.1): -Code: 153. DB::Exception: Received from localhost:9000. DB::Exception: Cannot perform integer division, because it will produce infinite or too large number: While processing intDiv(1, 0.001) AS res, toTypeName(res). (ILLEGAL_DIVISION) -``` - -## intDivOrZero {#intdivorzero} - -与 `intDiv` 相同,但在除以零或将最小负数除以 -1 时返回零。 - -**语法** - -```sql -intDivOrZero(a, b) -``` - -## intDivOrNull {#intdivornull} - -如同 [intDiv](#intdiv),但当除数为零时返回 null。 - -**语法** - -```sql -intDivOrNull(a, b) -``` - -## isFinite {#isfinite} - -如果 Float32 或 Float64 参数不是无限大且不是 NaN,则返回 1;否则该函数返回 0。 - -**语法** - -```sql -isFinite(x) -``` - -## isInfinite {#isinfinite} - -如果 Float32 或 Float64 参数是无限大,则返回 1;否则该函数返回 0。注意 NaN 会返回 0。 - -**语法** - -```sql -isInfinite(x) -``` - -## ifNotFinite {#ifnotfinite} - -检查浮点值是否有限。 - -**语法** - -```sql -ifNotFinite(x,y) -``` - -**参数** - -- `x` — 要检查无限的值。[Float\*](../data-types/float.md)。 -- `y` — 回退值。[Float\*](../data-types/float.md)。 - -**返回值** - -- 如果 `x` 是有限的,则返回 `x`。 -- 如果 `x` 不是有限的,则返回 `y`。 - -**示例** - -查询: - - SELECT 1/0 as infimum, ifNotFinite(infimum,42) - -结果: - - ┌─infimum─┬─ifNotFinite(divide(1, 0), 42)─┐ - │ inf │ 42 │ - └─────────┴───────────────────────────────┘ - -您可以通过使用 [三元运算符](/sql-reference/functions/conditional-functions#if) 获取类似结果:`isFinite(x) ? x : y`。 - -## isNaN {#isnan} - -如果 Float32 和 Float64 参数是 NaN,则返回 1;否则该函数返回 0。 - -**语法** - -```sql -isNaN(x) -``` - -## modulo {#modulo} - -计算两值 `a` 除以 `b` 的余数。 - -如果两个输入都是整数,则结果类型为整数。如果其中一个输入是浮点数,则结果类型为 [Float64](../data-types/float.md)。 - -余数的计算方式与 C++ 相同。对负数使用截断除法。 - -当除以零或将最小负数除以 -1 时会抛出异常。 - -**语法** - -```sql -modulo(a, b) -``` - -别名:`a % b`(运算符) - -## moduloOrZero {#moduloorzero} - -如同 [modulo](#modulo),但当除数为零时返回零。 - -**语法** - -```sql -moduloOrZero(a, b) -``` - -## moduloOrNull {#moduloornull} - -如同 [modulo](#modulo),但当除数为零时返回 null。 - -**语法** - -```sql -moduloOrNull(a, b) -``` - -## positiveModulo(a, b) {#positivemoduloa-b} - -如同 [modulo](#modulo),但始终返回非负数。 - -此函数比 `modulo` 慢 4-5 倍。 - -**语法** - -```sql -positiveModulo(a, b) -``` - -别名: -- `positive_modulo(a, b)` -- `pmod(a, b)` - -**示例** - -查询: - -```sql -SELECT positiveModulo(-1, 10) -``` - -结果: - -```result -┌─positiveModulo(-1, 10)─┐ -│ 9 │ -└────────────────────────┘ -``` - -## positiveModuloOrNull(a, b) {#positivemoduloornulla-b} - -如同 [positiveModulo](#positivemoduloa-b),但当除数为零时返回 null。 - -**语法** - -```sql -positiveModuloOrNull(a, b) -``` - -## negate {#negate} - -对值 `a` 取反。结果始终为有符号。 - -**语法** - -```sql -negate(a) -``` - -别名:`-a` - -## abs {#abs} - -计算 `a` 的绝对值。如果 `a` 为无符号类型,则无效。如果 `a` 为有符号类型,则返回无符号数。 - -**语法** - -```sql -abs(a) -``` - -## gcd {#gcd} - -返回两个值 `a` 和 `b` 的最大公约数。 - -当除以零或将最小负数除以 -1 时会抛出异常。 - -**语法** - -```sql -gcd(a, b) -``` - -## lcm(a, b) {#lcma-b} - -返回两个值 `a` 和 `b` 的最小公倍数。 - -当除以零或将最小负数除以 -1 时会抛出异常。 - -**语法** - -```sql -lcm(a, b) -``` - -## max2 {#max2} - -返回两个值 `a` 和 `b` 中较大的一个。返回值的类型为 [Float64](../data-types/float.md)。 - -**语法** - -```sql -max2(a, b) -``` - -**示例** - -查询: - -```sql -SELECT max2(-1, 2); -``` - -结果: - -```result -┌─max2(-1, 2)─┐ -│ 2 │ -└─────────────┘ -``` - -## min2 {#min2} - -返回两个值 `a` 和 `b` 中较小的一个。返回值的类型为 [Float64](../data-types/float.md)。 - -**语法** - -```sql -min2(a, b) -``` - -**示例** - -查询: - -```sql -SELECT min2(-1, 2); -``` - -结果: - -```result -┌─min2(-1, 2)─┐ -│ -1 │ -└─────────────┘ -``` - -## multiplyDecimal {#multiplydecimal} - -对两个小数 `a` 和 `b` 进行乘法运算。结果值将为 [Decimal256](../data-types/decimal.md) 类型。 - -结果的刻度可以通过 `result_scale` 明确指定。如果未指定 `result_scale`,则假设为输入值的最大刻度。 - -此函数的工作速度显著慢于普通 `multiply`。如果不需要控制结果精度和/或希望快速计算,可以考虑使用 `multiply`。 - -**语法** - -```sql -multiplyDecimal(a, b[, result_scale]) -``` - -**参数** - -- `a` — 第一个值。[Decimal](../data-types/decimal.md)。 -- `b` — 第二个值。[Decimal](../data-types/decimal.md)。 -- `result_scale` — 结果的刻度。[Int/UInt](../data-types/int-uint.md)。 - -**返回值** - -- 按给定刻度进行的乘法运算的结果。[Decimal256](../data-types/decimal.md)。 - -**示例** - -```result -┌─multiplyDecimal(toDecimal256(-12, 0), toDecimal32(-2.1, 1), 1)─┐ -│ 25.2 │ -└────────────────────────────────────────────────────────────────┘ -``` - -**与普通乘法的差异:** - -```sql -SELECT toDecimal64(-12.647, 3) * toDecimal32(2.1239, 4); -SELECT toDecimal64(-12.647, 3) as a, toDecimal32(2.1239, 4) as b, multiplyDecimal(a, b); -``` - -结果: - -```result -┌─multiply(toDecimal64(-12.647, 3), toDecimal32(2.1239, 4))─┐ -│ -26.8609633 │ -└───────────────────────────────────────────────────────────┘ -┌───────a─┬──────b─┬─multiplyDecimal(toDecimal64(-12.647, 3), toDecimal32(2.1239, 4))─┐ -│ -12.647 │ 2.1239 │ -26.8609 │ -└─────────┴────────┴──────────────────────────────────────────────────────────────────┘ -``` - -```sql -SELECT - toDecimal64(-12.647987876, 9) AS a, - toDecimal64(123.967645643, 9) AS b, - multiplyDecimal(a, b); - -SELECT - toDecimal64(-12.647987876, 9) AS a, - toDecimal64(123.967645643, 9) AS b, - a * b; -``` - -结果: - -```result -┌─────────────a─┬─────────────b─┬─multiplyDecimal(toDecimal64(-12.647987876, 9), toDecimal64(123.967645643, 9))─┐ -│ -12.647987876 │ 123.967645643 │ -1567.941279108 │ -└───────────────┴───────────────┴───────────────────────────────────────────────────────────────────────────────┘ - -Received exception from server (version 22.11.1): -Code: 407. DB::Exception: Received from localhost:9000. DB::Exception: Decimal math overflow: While processing toDecimal64(-12.647987876, 9) AS a, toDecimal64(123.967645643, 9) AS b, a * b. (DECIMAL_OVERFLOW) -``` - -## divideDecimal {#dividedecimal} - -对两个小数 `a` 和 `b` 进行除法运算。结果值将为 [Decimal256](../data-types/decimal.md) 类型。 - -结果的刻度可以通过 `result_scale` 明确指定。如果未指定 `result_scale`,则假设为输入值的最大刻度。 - -此函数的工作速度显著慢于普通 `divide`。如果不需要控制结果精度和/或希望快速计算,可以考虑使用 `divide`。 - -**语法** - -```sql -divideDecimal(a, b[, result_scale]) -``` - -**参数** - -- `a` — 第一个值:[Decimal](../data-types/decimal.md)。 -- `b` — 第二个值:[Decimal](../data-types/decimal.md)。 -- `result_scale` — 结果的刻度:[Int/UInt](../data-types/int-uint.md)。 - -**返回值** - -- 按给定刻度进行的除法运算的结果。[Decimal256](../data-types/decimal.md)。 - -**示例** - -```result -┌─divideDecimal(toDecimal256(-12, 0), toDecimal32(2.1, 1), 10)─┐ -│ -5.7142857142 │ -└──────────────────────────────────────────────────────────────┘ -``` - -**与普通除法的差异:** - -```sql -SELECT toDecimal64(-12, 1) / toDecimal32(2.1, 1); -SELECT toDecimal64(-12, 1) as a, toDecimal32(2.1, 1) as b, divideDecimal(a, b, 1), divideDecimal(a, b, 5); -``` - -结果: - -```result -┌─divide(toDecimal64(-12, 1), toDecimal32(2.1, 1))─┐ -│ -5.7 │ -└──────────────────────────────────────────────────┘ - -┌───a─┬───b─┬─divideDecimal(toDecimal64(-12, 1), toDecimal32(2.1, 1), 1)─┬─divideDecimal(toDecimal64(-12, 1), toDecimal32(2.1, 1), 5)─┐ -│ -12 │ 2.1 │ -5.7 │ -5.71428 │ -└─────┴─────┴────────────────────────────────────────────────────────────┴────────────────────────────────────────────────────────────┘ -``` - -```sql -SELECT toDecimal64(-12, 0) / toDecimal32(2.1, 1); -SELECT toDecimal64(-12, 0) as a, toDecimal32(2.1, 1) as b, divideDecimal(a, b, 1), divideDecimal(a, b, 5); -``` - -结果: - -```result -DB::Exception: Decimal result's scale is less than argument's one: While processing toDecimal64(-12, 0) / toDecimal32(2.1, 1). (ARGUMENT_OUT_OF_BOUND) - -┌───a─┬───b─┬─divideDecimal(toDecimal64(-12, 0), toDecimal32(2.1, 1), 1)─┬─divideDecimal(toDecimal64(-12, 0), toDecimal32(2.1, 1), 5)─┐ -│ -12 │ 2.1 │ -5.7 │ -5.71428 │ -└─────┴─────┴────────────────────────────────────────────────────────────┴────────────────────────────────────────────────────────────┘ -``` - -## byteSwap {#byteswap} - -反转一个整数的字节,即更改其 [字节序](https://en.wikipedia.org/wiki/Endianness)。 - -**语法** +这些规则确保结果类型将是可以表示所有可能结果的最小类型。虽然这在值范围边界周围引入了溢出的风险,但它确保计算是使用最大原生整数宽度(64 位)快速执行的。这种行为还确保与许多其他提供 64 位整数(BIGINT)作为最大整数类型的数据库兼容。 -```sql -byteSwap(a) -``` - -**示例** +示例: ```sql -byteSwap(3351772109) +SELECT toTypeName(0), toTypeName(0 + 0), toTypeName(0 + 0 + 0), toTypeName(0 + 0 + 0 + 0) ``` -结果: - -```result -┌─byteSwap(3351772109)─┐ -│ 3455829959 │ -└──────────────────────┘ +```text +┌─toTypeName(0)─┬─toTypeName(plus(0, 0))─┬─toTypeName(plus(plus(0, 0), 0))─┬─toTypeName(plus(plus(plus(0, 0), 0), 0))─┐ +│ UInt8 │ UInt16 │ UInt32 │ UInt64 │ +└───────────────┴────────────────────────┴─────────────────────────────────┴──────────────────────────────────────────┘ ``` -上述示例可按以下方式计算: -1. 将十进制整数转换为其大端格式的十六进制格式,即 3351772109 -> C7 C7 FB CD(4 字节) -2. 反转字节,即 C7 C7 FB CD -> CD FB C7 C7 -3. 假设为大端,将结果转换回整数,即 CD FB C7 C7 -> 3455829959 - -此函数的一个用例是反转 IPv4: - -```result -┌─toIPv4(byteSwap(toUInt32(toIPv4('205.251.199.199'))))─┐ -│ 199.199.251.205 │ -└───────────────────────────────────────────────────────┘ -``` +溢出与 C++ 中的处理方法相同。 @@ -588,6 +45,8 @@ byteSwap(3351772109) 引入于:v1.1 +计算 `x` 的绝对值。如果 `x` 是无符号类型则无效。如果 `x` 是有符号类型,则返回无符号数。 + **语法** ```sql @@ -596,7 +55,7 @@ abs(x) **参数** -- `x` — 要获取绝对值的值 +- `x` — 计算绝对值的值 **返回值** @@ -604,7 +63,7 @@ abs(x) **示例** -**用法示例** +**使用示例** ```sql title=Query SELECT abs(-0.5) @@ -620,6 +79,23 @@ SELECT abs(-0.5) 引入于:v23.10 + +反转整数的字节,即更改其 [字节序](https://en.wikipedia.org/wiki/Endianness)。 + +如下示例可以这样处理: + +1. 将十进制整数字转换为其等效的大端格式的十六进制格式,即 3351772109 -> C7 C7 FB CD(4 字节) +2. 反转字节,即 C7 C7 FB CD -> CD FB C7 C7 +3. 将结果假设为大端格式转换回整数,即 CD FB C7 C7 -> 3455829959 +该函数的一个用例是反转 IPv4: + +```result +┌─toIPv4(byteSwap(toUInt32(toIPv4('205.251.199.199'))))─┐ +│ 199.199.251.205 │ +└───────────────────────────────────────────────────────┘ +``` + + **语法** ```sql @@ -628,15 +104,16 @@ byteSwap(x) **参数** -- `x` — 一个整数值。 +- `x` — 整数值。[`(U)Int*`](/sql-reference/data-types/int-uint) + **返回值** -x 的字节反转 +返回字节反转后的 `x`。[`(U)Int*`](/sql-reference/data-types/int-uint) **示例** -**用法示例** +**使用示例** ```sql title=Query SELECT byteSwap(3351772109) @@ -692,6 +169,14 @@ SELECT byteSwap(123294967295) 引入于:v1.1 + + 计算两个值 `a` 和 `b` 的商。结果类型始终为 [Float64](/sql-reference/data-types/float)。 + 整数除法由 `intDiv` 函数提供。 + + :::note + 除以 `0` 会返回 `inf`、`-inf` 或 `nan`。 + ::: + **语法** ```sql @@ -700,16 +185,15 @@ divide(x, y) **参数** -- `x` — 被除数 -- `y` — 除数 +- `x` — 被除数 - `y` — 除数 **返回值** -x 和 y 的商 +`x` 和 `y` 的商 **示例** -**除法计算** +**除以两个数字** ```sql title=Query SELECT divide(25,5) AS quotient, toTypeName(quotient) @@ -735,6 +219,16 @@ inf 引入于:v22.12 + +对两个十进制数进行除法运算。结果值的类型将是 [Decimal256](/sql-reference/data-types/decimal)。 +结果规模可以通过 `result_scale` 参数显式指定(范围为 `[0, 76]` 的常量整数)。如果没有指定,结果规模为给定参数的最大规模。 + +:::note +这些函数的工作速度显著慢于常规的 `divide`。 +如果您真的不需要受控精度和/或需要快速计算,考虑使用 [divide](#divide)。 +::: + + **语法** ```sql @@ -743,13 +237,11 @@ divideDecimal(x, y[, result_scale]) **参数** -- `x` — 第一个值:[Decimal](/sql-reference/data-types/decimal)。 -- `y` — 第二个值:[Decimal](/sql-reference/data-types/decimal)。 -- `result_scale` — 结果的刻度。类型 [Int/UInt](/sql-reference/data-types/int-uint)。 +- `x` — 第一个值:[Decimal](/sql-reference/data-types/decimal)。 - `y` — 第二个值:[Decimal](/sql-reference/data-types/decimal)。 - `result_scale` — 结果的规模。类型为 [Int/UInt](/sql-reference/data-types/int-uint)。 **返回值** -按给定刻度进行的除法运算的结果。类型: [Decimal256](/sql-reference/data-types/decimal.md)。 +具有给定规模的除法结果。[`Decimal256`](/sql-reference/data-types/decimal) **示例** @@ -783,10 +275,52 @@ SELECT toDecimal64(-12, 1) as a, toDecimal32(2.1, 1) as b, divideDecimal(a, b, 1 +## divideOrNull {#divideOrNull} + +引入于:v25.5 + + +与 `divide` 相同,但在除以零时返回 NULL。 + + +**语法** + +```sql +divideOrNull(x, y) +``` + +**参数** + +- `x` — 被除数 - `y` — 除数 + +**返回值** + +`x` 和 `y` 的商,或者 NULL。 + +**示例** + +**除以零** + +```sql title=Query +SELECT divideOrNull(25, 0) +``` + +```response title=Response +\N +``` + + + ## gcd {#gcd} 引入于:v1.1 + + 返回两个值 `a` 和 `b` 的最大公约数。 + + 除以零或将最小负数除以 -1 会引发异常。 + + **语法** ```sql @@ -795,8 +329,7 @@ gcd(x, y) **参数** -- `x` — 第一个整数 -- `y` — 第二个整数 +- `x` — 第一个整数 - `y` — 第二个整数 **返回值** @@ -804,7 +337,7 @@ gcd(x, y) **示例** -**用法示例** +**使用示例** ```sql title=Query SELECT gcd(12, 18) @@ -820,6 +353,12 @@ SELECT gcd(12, 18) 引入于:v20.3 + +检查浮点值是否为有限值。 + +您可以通过使用 [三元操作符](/sql-reference/functions/conditional-functions#if) 获得类似的结果:`isFinite(x) ? x : y`。 + + **语法** ```sql @@ -828,8 +367,9 @@ ifNotFinite(x,y) **参数** -- `x` — 检查是否为无限的值。Float32/Float64 -- `y` — 回退值。Float32/Float64 +- `x` — 要检查是否为无限大的值。[`Float*`](/sql-reference/data-types/float) +- `y` — 后备值。[`Float*`](/sql-reference/data-types/float) + **返回值** @@ -838,7 +378,7 @@ ifNotFinite(x,y) **示例** -**用法示例** +**使用示例** ```sql title=Query SELECT 1/0 AS infimum, ifNotFinite(infimum,42) @@ -854,6 +394,14 @@ inf 42 引入于:v1.1 + +对两个值 `x` 除以 `y` 进行整数除法。换句话说,它计算向下取整到下一个最小整数的商。 + +结果的宽度与被除数(第一个参数)相同。 + +除以零、商不适合被除数范围或将最小负数除以 -1 会引发异常。 + + **语法** ```sql @@ -862,8 +410,7 @@ intDiv(x, y) **参数** -- `x` — 左操作数。 -- `y` — 右操作数。 +- `x` — 左操作数。 - `y` — 右操作数。 **返回值** @@ -901,10 +448,62 @@ large number: While processing intDiv(1, 0.001) AS res, toTypeName(res). +## intDivOrNull {#intDivOrNull} + +引入于:v25.5 + + +与 `intDiv` 相同,但在除以零或将最小负数除以 -1 时返回 NULL。 + + +**语法** + +```sql +intDivOrNull(x, y) +``` + +**参数** + +- `x` — 左操作数。[`(U)Int*`](/sql-reference/data-types/int-uint) +- `y` — 右操作数。[`(U)Int*`](/sql-reference/data-types/int-uint) + + +**返回值** + +`x` 和 `y` 的整数除法结果,或 NULL。 + +**示例** + +**整数除法除以零** + +```sql title=Query +SELECT intDivOrNull(1, 0) +``` + +```response title=Response +\N +``` + +**将最小负数除以 -1** + +```sql title=Query +SELECT intDivOrNull(-9223372036854775808, -1) +``` + +```response title=Response +\N +``` + + + ## intDivOrZero {#intDivOrZero} 引入于:v1.1 + +与 `intDiv` 相同,但在除以零或将最小负数除以 -1 时返回零。 + + **语法** ```sql @@ -913,8 +512,9 @@ intDivOrZero(a, b) **参数** -- `a` — 左操作数。 -- `b` — 右操作数。 +- `a` — 左操作数。[`(U)Int*`](/sql-reference/data-types/int-uint) +- `b` — 右操作数。[`(U)Int*`](/sql-reference/data-types/int-uint) + **返回值** @@ -922,7 +522,7 @@ intDivOrZero(a, b) **示例** -**以零进行整数除法** +**整数除法除以零** ```sql title=Query SELECT intDivOrZero(1, 0) @@ -932,7 +532,7 @@ SELECT intDivOrZero(1, 0) 0 ``` -**将最小负数除以负 1** +**将最小负数除以 -1** ```sql title=Query SELECT intDivOrZero(0.05, -1) @@ -948,6 +548,10 @@ SELECT intDivOrZero(0.05, -1) 引入于:v1.1 + +如果 Float32 或 Float64 参数不是无限大且不是 `NaN`,则返回 `1`,否则此函数返回 `0`。 + + **语法** ```sql @@ -956,15 +560,16 @@ isFinite(x) **参数** -- `x` — 检查有限性的数字。Float32 或 Float64。 +- `x` — 要检查是否为有限值的数字。[`Float*`](/sql-reference/data-types/float) + **返回值** -如果 x 不是无限大且不是 `NaN`,则返回 `1`,否则返回 `0`。 +如果 `x` 不是无限的且不是 `NaN`,则返回 `1`,否则返回 `0`。 **示例** -**测试数字是否有限** +**测试一个数字是否有限** ```sql title=Query SELECT isFinite(inf) @@ -980,6 +585,11 @@ SELECT isFinite(inf) 引入于:v1.1 + + 如果 Float32 或 Float64 参数是无限的,则返回 `1`,否则此函数返回 `0`。 + 请注意,对于 `NaN` 返回 `0`。 + + **语法** ```sql @@ -988,15 +598,16 @@ isInfinite(x) **参数** -- `x` — 检查无限性的数字。Float32 或 Float64。 +- `x` — 要检查是否为无限大的数字。[`Float*`](/sql-reference/data-types/float) + **返回值** -如果 x 是无限大,则返回 `1`,否则返回 `0`(包括 `NaN` 的情况)。 +如果 `x` 是无限的,则返回 `1`,否则返回 `0`(包括对于 `NaN`)。 **示例** -**测试数字是否无限** +**测试一个数字是否是无限的** ```sql title=Query SELECT isInfinite(inf), isInfinite(NaN), isInfinite(10)) @@ -1012,6 +623,8 @@ SELECT isInfinite(inf), isInfinite(NaN), isInfinite(10)) 引入于:v1.1 +如果 Float32 和 Float64 参数是 `NaN`,则返回 `1`,否则返回 `0`。 + **语法** ```sql @@ -1020,15 +633,16 @@ isNaN(x) **参数** -- `x` — 要评估是否为 `NaN` 的参数 +- `x` — 要评估其是否为 `NaN` 的参数。[`Float*`](/sql-reference/data-types/float) + **返回值** -如果为 `NaN` 则返回 `1`,否则返回 `0` +如果是 `NaN`,则返回 `1`,否则返回 `0` **示例** -**用法示例** +**使用示例** ```sql title=Query SELECT isNaN(NaN) @@ -1044,6 +658,12 @@ SELECT isNaN(NaN) 引入于:v1.1 + +返回两个值 `x` 和 `y` 的最小公倍数。 + +除以零或将最小负数除以 -1 会引发异常。 + + **语法** ```sql @@ -1052,16 +672,17 @@ lcm(x, y) **参数** -- `x` — 第一个整数 -- `y` — 第二个整数 +- `x` — 第一个整数。[`(U)Int*`](/sql-reference/data-types/int-uint) +- `y` — 第二个整数。[`(U)Int*`](/sql-reference/data-types/int-uint) + **返回值** -`x` 和 `y` 的最小公倍数。 +返回 `x` 和 `y` 的最小公倍数。[`(U)Int*`](/sql-reference/data-types/int-uint) **示例** -**用法示例** +**使用示例** ```sql title=Query SELECT lcm(6, 8) @@ -1077,6 +698,10 @@ SELECT lcm(6, 8) 引入于:v21.11 + + 返回两个数值 `x` 和 `y` 中较大的一个。 + + **语法** ```sql @@ -1085,16 +710,17 @@ max2(x, y) **参数** -- `x` — 第一个值 -- `y` — 第二个值 +- `x` — 第一个值 [`(U)Int8/16/32/64`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal`](/sql-reference/data-types/decimal) +- `y` — 第二个值 [`(U)Int8/16/32/64`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal`](/sql-reference/data-types/decimal) + **返回值** -返回 `x` 和 `y` 中较大的值 +返回 `x` 和 `y` 中较大的值。[`Float64`](/sql-reference/data-types/float) **示例** -**用法示例** +**使用示例** ```sql title=Query SELECT max2(-1, 2) @@ -1110,6 +736,10 @@ SELECT max2(-1, 2) 引入于:v21.11 + + 返回两个数值 `x` 和 `y` 中较小的一个。 + + **语法** ```sql @@ -1118,16 +748,17 @@ min2(x, y) **参数** -- `x` — 第一个值 -- `y` — 第二个值 +- `x` — 第一个值 [`(U)Int8/16/32/64`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal`](/sql-reference/data-types/decimal) +- `y` — 第二个值 [`(U)Int8/16/32/64`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal`](/sql-reference/data-types/decimal) + **返回值** -返回 `x` 和 `y` 中较小的值 +返回 `x` 和 `y` 中较小的值。[`Float64`](/sql-reference/data-types/float) **示例** -**用法示例** +**使用示例** ```sql title=Query SELECT min2(-1, 2) @@ -1143,6 +774,11 @@ SELECT min2(-1, 2) 引入于:v1.1 + +计算两个值 `a` 和 `b` 的差。结果始终为有符号。类似于加法,可以从日期或带时间的日期中减去整数。 +此外,也支持带时间的日期之间的减法,从而得出它们之间的时间差。 + + **语法** ```sql @@ -1151,26 +787,25 @@ minus(x, y) **参数** -- `x` — 被减数 -- `y` — 减数 +- `x` — 被减数。 - `y` — 减数。 **返回值** -x 减去 y +`x` 减去 `y` **示例** **减去两个数字** ```sql title=Query -SELECT minus(10,5) +SELECT minus(10, 5) ``` ```response title=Response 5 ``` -**减去整数和日期** +**从日期中减去一个整数** ```sql title=Query SELECT minus(toDate('2025-01-01'),5) @@ -1186,6 +821,16 @@ SELECT minus(toDate('2025-01-01'),5) 引入于:v1.1 + + 计算两个值 `a` 除以 `b` 的余数。 + + 如果两个输入都是整数,结果类型为整数。如果其中一个输入是浮点数,结果类型为 Float64。 + + 余数是按 C++ 中的方式计算的。负数使用截断除法。 + + 除以零或将最小负数除以 -1 会引发异常。 + + **语法** ```sql @@ -1194,8 +839,7 @@ modulo(a, b) **参数** -- `a` — 被除数 -- `b` — 除数(模数) +- `a` — 被除数 - `b` — 除数(模数) **返回值** @@ -1203,7 +847,7 @@ modulo(a, b) **示例** -**用法示例** +**使用示例** ```sql title=Query SELECT modulo(5, 2) @@ -1215,10 +859,52 @@ SELECT modulo(5, 2) +## moduloOrNull {#moduloOrNull} + +引入于:v25.5 + + +计算 `a` 除以 `b` 的余数。类似于 `modulo` 函数,不同之处在于 `moduloOrNull` 如果右侧参数为 0 则会返回 NULL。 + + +**语法** + +```sql +moduloOrNull(x, y) +``` + +**参数** + +- `x` — 被除数。[`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) +- `y` — 除数(模数)。[`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) + + +**返回值** + +返回 `x` 被 `y` 除的余数,或当除数为零时返回 null。 + +**示例** + +**moduloOrNull 除以零** + +```sql title=Query +SELECT moduloOrNull(5, 0) +``` + +```response title=Response +\N +``` + + + ## moduloOrZero {#moduloOrZero} 引入于:v20.3 + +与 `modulo` 相似,但在除数为零时返回零,而不是 `modulo` 函数中的异常。 + + **语法** ```sql @@ -1227,16 +913,17 @@ moduloOrZero(a, b) **参数** -- `a` — 被除数。[`(U)Int*`](/sql-reference/data-types/int-uint)/[`Float32/64`](/sql-reference/data-types/float)。 -- `b` — 除数(模数)。[`(U)Int*`](/sql-reference/data-types/int-uint)/[`Float32/64`](/sql-reference/data-types/float)。 +- `a` — 被除数。[`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) +- `b` — 除数(模数)。[`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) + **返回值** -`a % b` 的余数,或者当除数为 `0` 时返回 `0`。 +返回 `a % b` 的余数,或当除数为 `0` 时返回 `0`。 **示例** -**用法示例** +**使用示例** ```sql title=Query SELECT moduloOrZero(5, 0) @@ -1252,6 +939,8 @@ SELECT moduloOrZero(5, 0) 引入于:v1.1 +计算两个值 `x` 和 `y` 的乘积。 + **语法** ```sql @@ -1260,12 +949,13 @@ multiply(x, y) **参数** -- `x` — 因子 -- `y` — 因子 +- `x` — 因子。[`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal`](/sql-reference/data-types/decimal) +- `y` — 因子。[`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal`](/sql-reference/data-types/decimal) + **返回值** -`x` 和 `y` 的积 +返回 `x` 和 `y` 的乘积 **示例** @@ -1285,6 +975,16 @@ SELECT multiply(5,5) 引入于:v22.12 + +对两个十进制数进行乘法运算。结果值的类型将是 [Decimal256](/sql-reference/data-types/decimal)。 +结果规模可以通过 `result_scale` 参数显式指定(范围为 `[0, 76]` 的常量整数)。如果没有指定,结果规模为给定参数的最大规模。 + +:::note +这些函数的工作速度显著慢于常规的 `multiply`。 +如果您真的不需要受控精度和/或需要快速计算,考虑使用 [multiply](#multiply)。 +::: + + **语法** ```sql @@ -1293,17 +993,18 @@ multiplyDecimal(a, b[, result_scale]) **参数** -- `a` — 第一个值。类型 [Decimal](/sql-reference/data-types/decimal)。 -- `b` — 第二个值。类型 [Decimal](/sql-reference/data-types/decimal)。 -- `result_scale` — 结果的刻度。类型 [Int/UInt](/sql-reference/data-types/int-uint)。 +- `a` — 第一个值。[`Decimal`](/sql-reference/data-types/decimal) +- `b` — 第二个值。[`Decimal`](/sql-reference/data-types/decimal) +- `result_scale` — 结果的规模。[`(U)Int*`](/sql-reference/data-types/int-uint) + **返回值** -按给定刻度进行的乘法运算的结果。类型:[Decimal256](/sql-reference/data-types/decimal)。 +具有给定规模的乘法结果。类型:[ `Decimal256`](/sql-reference/data-types/decimal) **示例** -**用法示例** +**使用示例** ```sql title=Query SELECT multiplyDecimal(toDecimal256(-12, 0), toDecimal32(-2.1, 1), 1) @@ -1313,7 +1014,7 @@ SELECT multiplyDecimal(toDecimal256(-12, 0), toDecimal32(-2.1, 1), 1) 25.2 ``` -**与普通乘法的差异** +**与常规乘法的区别** ```sql title=Query SELECT multiplyDecimal(toDecimal256(-12, 0), toDecimal32(-2.1, 1), 1) @@ -1328,7 +1029,7 @@ SELECT multiplyDecimal(toDecimal256(-12, 0), toDecimal32(-2.1, 1), 1) └──────────────────────────────────────────────────────────────────┘ ``` -**小数溢出** +**十进制溢出** ```sql title=Query SELECT @@ -1356,6 +1057,8 @@ While processing toDecimal64(-12.647987876, 9) AS a, toDecimal64(123.967645643, 引入于:v1.1 +对参数 `x` 取反。结果始终为有符号。 + **语法** ```sql @@ -1364,15 +1067,15 @@ negate(x) **参数** -- `x` — 要取反的值。 +- `x` — 要取反的值。 **返回值** -返回 -x 从 x +返回 `-x` **示例** -**用法示例** +**使用示例** ```sql title=Query SELECT negate(10) @@ -1388,6 +1091,11 @@ SELECT negate(10) 引入于:v1.1 + +计算两个值 `x` 和 `y` 的和。别名:`x + y`(操作符)。 +可以将整数和日期或带时间的日期相加。前一种操作增加日期中的天数,后一种操作增加带时间的日期中的秒数。 + + **语法** ```sql @@ -1396,12 +1104,11 @@ plus(x, y) **参数** -- `x` — 左操作数。 -- `y` — 右操作数。 +- `x` — 左操作数。 - `y` — 右操作数。 **返回值** -`x` 和 `y` 的和 +返回 `x` 和 `y` 的和 **示例** @@ -1431,6 +1138,10 @@ SELECT plus(toDate('2025-01-01'),5) 引入于:v22.11 + +计算 `x` 除以 `y` 的余数。与 `modulo` 函数类似,不同之处在于 `positiveModulo` 始终返回非负数。 + + **语法** ```sql @@ -1439,16 +1150,17 @@ positiveModulo(x, y) **参数** -- `x` — 被除数。[`(U)Int*`](/sql-reference/data-types/int-uint)/[`Float32/64`](/sql-reference/data-types/float)。 -- `y` — 除数(模数)。[`(U)Int*`](/sql-reference/data-types/int-uint)/[`Float32/64`](/sql-reference/data-types/float)。 +- `x` — 被除数。[`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal`](/sql-reference/data-types/decimal) +- `y` — 除数(模数)。[`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal`](/sql-reference/data-types/decimal) + **返回值** -返回 `x` 和不大于 `x` 的最近整数的差,该整数可被 `y` 整除。 +返回`x` 与最大不大于 `x` 的可被 `y` 整除的整数之间的差。 **示例** -**用法示例** +**使用示例** ```sql title=Query SELECT positiveModulo(-1, 10) @@ -1462,33 +1174,38 @@ SELECT positiveModulo(-1, 10) ## positiveModuloOrNull {#positiveModuloOrNull} -引入于:v22.11 +引入于:v25.5 + + +计算 `a` 除以 `b` 的余数。与 `positiveModulo` 函数类似,不同之处在于 `positiveModuloOrNull` 如果右侧参数为 0 则会返回 NULL。 + **语法** ```sql -positiveModulo(x, y) +positiveModuloOrNull(x, y) ``` **参数** -- `x` — 被除数。[`(U)Int*`](/sql-reference/data-types/int-uint)/[`Float32/64`](/sql-reference/data-types/float)。 -- `x` — 除数(模数)。[`(U)Int*`](/sql-reference/data-types/int-uint)/[`Float32/64`](/sql-reference/data-types/float)。 +- `x` — 被除数。[`(U)Int*`](/sql-reference/data-types/int-uint)/[`Float32/64`](/sql-reference/data-types/float)。 - `y` — 除数(模数)。[`(U)Int*`](/sql-reference/data-types/int-uint)/[`Float32/64`](/sql-reference/data-types/float)。 **返回值** -返回 `x` 和不大于 `x` 的最近整数的差,该整数可被 `y` 整除;当除数为零时返回 `null`。 +返回 `x` 与最大不大于 `x` 的可被 `y` 整除的整数之间的差,或当除数为零时返回 null。 **示例** -**positiveModulo** +**positiveModuloOrNull** ```sql title=Query -SELECT positiveModulo(-1, 10) +SELECT positiveModuloOrNull(5, 0) ``` ```response title=Response -9 -``` +\N +``` + + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/arithmetic-functions.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/arithmetic-functions.md.hash index 6490b999a9c..81673b88937 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/arithmetic-functions.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/arithmetic-functions.md.hash @@ -1 +1 @@ -16b5535665e05945 +af64e0fc41c440a2 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/array-functions.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/array-functions.md index 47a132d613e..58431ebd783 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/array-functions.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/array-functions.md @@ -1,18 +1,18 @@ --- 'description': 'Array Functions 的文档' -'sidebar_label': 'Arrays' -'sidebar_position': 10 +'sidebar_label': '数组' 'slug': '/sql-reference/functions/array-functions' 'title': '数组函数' +'doc_type': 'reference' --- # 数组函数 @@ -20,6 +20,16 @@ 引入于:v1.1 + +根据函数参数创建一个数组。 + +参数应为常量,并且具有共享的共同超类型。 +必须传递至少一个参数,因为否则不清楚要创建哪种类型的数组。 +这意味着您不能使用此函数创建空数组。要创建空数组,请使用`emptyArray*`函数。 + +使用`[ ]`运算符获得相同的功能。 + + **语法** ```sql @@ -28,12 +38,11 @@ array(x1 [, x2, ..., xN]) **参数** -- `x1` — 任意类型 T 的常量值。如果仅提供此参数,数组的类型将为 T。 -- `[, x2, ..., xN]` — 与 `x1` 共享共同超类型的额外 N 个常量值。 +- `x1` — 任何类型 T 的常量值。如果仅提供此参数,则数组将为类型 T。 - `[, x2, ..., xN]` — 共享与`x1`相同超类型的额外 N 个常量值 **返回值** -返回 'Array(T)' 类型结果,其中 'T' 是传入参数中最小的共同类型。 +返回一个数组,其中 'T' 是传递参数中最小的共同类型。 [`Array(T)`](/sql-reference/data-types/array) **示例** @@ -64,6 +73,13 @@ There is no supertype for types Int32, DateTime, Int8 ... 引入于:v20.4 + +计算精确率-召回(PR)曲线下的面积。 +精确率-召回曲线是通过将精确率绘制在 y 轴上而产生的,同时将召回率绘制在 x 轴上,覆盖所有阈值。 +结果值范围为 0 到 1,较高的值表示更好的模型表现。 +PR AUC 特别适用于不平衡数据集,与 ROC AUC 相比,它提供了更清晰的性能比较。 +有关更多详细信息,请参阅 [这里](https://developers.google.com/machine-learning/glossary#pr-auc-area-under-the-pr-curve), [这里](https://developers.google.com/machine-learning/crash-course/classification/roc-and-auc#expandable-1) 和 [这里](https://en.wikipedia.org/wiki/Receiver_operating_characteristic#Area_under_the_curve)。 + **语法** ```sql @@ -72,26 +88,25 @@ arrayAUCPR(scores, labels[, partial_offsets]) **参数** -- `cores` — 模型提供的评分预测。 [Array](/sql-reference/data-types/array) 的 [整数](../data-types/int-uint.md) 或 [浮点数](../data-types/float.md)。 -- `labels` — 样本的标签,通常为正样本的 1 和负样本的 0。 [Array](/sql-reference/data-types/array) 的 [整数](../data-types/int-uint.md) 或 [枚举](../data-types/enum.md)。 +- `cores` — 评分预测模型给出的分数。 [`Array((U)Int*)`](/sql-reference/data-types/array) 或 [`Array(Float*)`](/sql-reference/data-types/array) +- `labels` — 样本标签,通常正样本为 1,负样本为 0。 [`Array((U)Int*)`](/sql-reference/data-types/array) 或 [`Array(Enum)`](/sql-reference/data-types/array) - `partial_offsets` — -- 可选。用于计算 PR 曲线下部分区域的 [`Array(T)`](/sql-reference/data-types/array) ,包含三个非负整数,而不是整个 AUC。此选项对 PR AUC 的分布式计算很有用。数组必须包含以下元素 [`higher_partitions_tp`, `higher_partitions_fp`, `total_positives`]。 [Array](/sql-reference/data-types/array) 的非负 [整数](../data-types/int-uint.md)。可选。 - - `higher_partitions_tp`: 在高分分区中正标签的数量。 - - `higher_partitions_fp`: 在高分分区中负标签的数量。 +- 可选。用于计算 PR 曲线部分面积的一个 [`Array(T)`](/sql-reference/data-types/array),包括三个非负整数(相当于 PR 空间的垂直带),而不是整个 AUC。此选项对于 PR AUC 的分布式计算很有用。数组必须包含以下元素 [`higher_partitions_tp`, `higher_partitions_fp`, `total_positives`]。 + - `higher_partitions_tp`: 在高分区中正标签的数量。 + - `higher_partitions_fp`: 在高分区中负标签的数量。 - `total_positives`: 整个数据集中正样本的总数。 ::::note -当使用 `arr_partial_offsets` 时,`arr_scores` 与 `arr_labels` 应仅为整个数据集的一个分区,包含一个分数区间。 -数据集应被划分为连续的分区,每个分区包含分数落在特定范围内的数据子集。 +当使用`arr_partial_offsets`时,`arr_scores`和`arr_labels`应仅为整个数据集的一部分,包含分数的区间。 +数据集应被划分为连续的分区,其中每个分区包含分数落在特定范围内的数据子集。 例如: -- 一个分区可以包含所有在范围 [0, 0.5) 的分数。 -- 另一个分区可以包含范围 [0.5, 1.0] 的分数。 -:::: - +- 一个分区可以包含所有分数在 [0, 0.5) 范围内。 +- 另一个分区可以包含分数在 [0.5, 1.0] 范围内。 +:::: **返回值** -返回精确-召回 (PR) 曲线下的区域。 [Float64](../data-types/float.md)。 +返回精确率-召回(PR)曲线下的面积。 [`Float64`](/sql-reference/data-types/float) **示例** @@ -110,6 +125,9 @@ SELECT arrayAUCPR([0.1, 0.4, 0.35, 0.8], [0, 0, 1, 1]); 引入于:v1.1 + +如果 lambda `func(x [, y1, y2, ... yN])` 对所有元素返回 true,则返回 `1`。否则,返回 `0`。 + **语法** ```sql @@ -118,13 +136,13 @@ arrayAll(func(x[, y1, ..., yN]), source_arr[, cond1_arr, ... , condN_arr]) **参数** -- `func(x[, y1, ..., yN])` — 操作源数组 (`x`) 和条件数组 (`y`) 元素的 lambda 函数。 [Lambda 函数](/sql-reference/functions/overview#arrow-operator-and-lambda)。 -- `source_arr` — 要处理的源数组。 [`Array(T)`](/sql-reference/data-types/array)。 -- `[, cond1_arr, ... , condN_arr]` — 可选。提供额外参数给 lambda 函数的 N 个条件数组。 [`Array(T)`](/sql-reference/data-types/array)。 +- `func(x[, y1, ..., yN])` — 一个对源数组 (`x`) 和条件数组 (`y`) 中元素操作的 lambda 函数。 [`Lambda function`](/sql-reference/functions/overview#arrow-operator-and-lambda) +- `source_arr` — 要处理的源数组。 [`Array(T)`](/sql-reference/data-types/array) +- `cond1_arr, ...` — 可选。N个条件数组,为 lambda 函数提供额外参数。 [`Array(T)`](/sql-reference/data-types/array) **返回值** -如果 lambda 函数对所有元素返回 true,则返回 `1`,否则返回 `0`。 [`UInt8`](/sql-reference/data-types/int-uint)。 +如果 lambda 函数对所有元素返回 true,则返回 `1`,否则返回 `0` [`UInt8`](/sql-reference/data-types/int-uint) **示例** @@ -138,7 +156,7 @@ SELECT arrayAll(x, y -> x=y, [1, 2, 3], [1, 2, 3]) 1 ``` -**不是所有元素匹配** +**并非所有元素匹配** ```sql title=Query SELECT arrayAll(x, y -> x=y, [1, 2, 3], [1, 1, 1]) @@ -151,6 +169,12 @@ SELECT arrayAll(x, y -> x=y, [1, 2, 3], [1, 1, 1]) 引入于:v21.1 + +返回源数组中元素的平均值。 + +如果指定了 lambda 函数 `func`,则返回 lambda 结果的元素平均值。 + + **语法** ```sql @@ -159,13 +183,13 @@ arrayAvg([func(x[, y1, ..., yN])], source_arr[, cond1_arr, ... , condN_arr]) **参数** -- `func(x[, y1, ..., yN])` — 可选。操作源数组 (`x`) 和条件数组 (`y`) 元素的 lambda 函数。 [Lambda 函数](/sql-reference/functions/overview#arrow-operator-and-lambda)。 -- `source_arr` — 要处理的源数组。 [`Array(T)`](/sql-reference/data-types/array)。 -- `[, cond1_arr, ... , condN_arr]` — 可选。提供额外参数给 lambda 函数的 N 个条件数组。 [`Array(T)`](/sql-reference/data-types/array)。 +- `func(x[, y1, ..., yN])` — 可选。对源数组 (`x`) 和条件数组 (`y`) 中元素操作的 lambda 函数。 [`Lambda function`](/sql-reference/functions/overview#arrow-operator-and-lambda) +- `source_arr` — 要处理的源数组。 [`Array(T)`](/sql-reference/data-types/array) +- `[, cond1_arr, ... , condN_arr]` — 可选。N 个条件数组,为 lambda 函数提供额外参数。 [`Array(T)`](/sql-reference/data-types/array) **返回值** -返回源数组中元素的平均值,或者如果提供,则返回 lambda 结果的平均值。 [`Float64`](/sql-reference/data-types/float)。 +返回源数组中元素的平均值,如果提供了lambda结果,则返回lambda结果的元素平均值。 [`Float64`](/sql-reference/data-types/float) **示例** @@ -179,7 +203,7 @@ SELECT arrayAvg([1, 2, 3, 4]); 2.5 ``` -**使用 lambda 函数** +**与 lambda 函数的用法** ```sql title=Query SELECT arrayAvg(x, y -> x*y, [2, 3], [2, 3]) AS res; @@ -192,6 +216,8 @@ SELECT arrayAvg(x, y -> x*y, [2, 3], [2, 3]) AS res; 引入于:v20.1 +删除数组中连续重复的元素,包括 `null` 值。结果数组中的值的顺序根据源数组中的顺序确定。 + **语法** ```sql @@ -204,7 +230,7 @@ arrayCompact(arr) **返回值** -返回不包含重复值的数组。 [`Array(T)`](/sql-reference/data-types/array)。 +返回一个没有重复值的数组 [`Array(T)`](/sql-reference/data-types/array) **示例** @@ -217,10 +243,213 @@ SELECT arrayCompact([1, 1, nan, nan, 2, 3, 3, 3]); ```response title=Response [1,nan,2,3] ``` +## arrayConcat {#arrayConcat} + +引入于:v1.1 + +将作为参数传递的数组组合在一起。 + +**语法** + +```sql +arrayConcat(arr1 [, arr2, ... , arrN]) +``` + +**参数** + +- `arr1 [, arr2, ... , arrN]` — N 个要连接的数组。 [`Array(T)`](/sql-reference/data-types/array) + +**返回值** + +返回由提供的数组参数组成的单个组合数组。 [`Array(T)`](/sql-reference/data-types/array) + +**示例** + +**用法示例** + +```sql title=Query +SELECT arrayConcat([1, 2], [3, 4], [5, 6]) AS res +``` + +```response title=Response +[1, 2, 3, 4, 5, 6] +``` +## arrayCount {#arrayCount} + +引入于:v1.1 + + +返回`func(arr1[i], ..., arrN[i])`返回 true 的元素数量。 +如果未指定`func`,则返回数组中非零元素的数量。 + +`arrayCount` 是一个 [高阶函数](/sql-reference/functions/overview#higher-order-functions)。 + + +**语法** + +```sql +arrayCount([func, ] arr1, ...) +``` + +**参数** + +- `func` — 可选。要应用于数组中每个元素的函数。 [`Lambda function`](/sql-reference/functions/overview#arrow-operator-and-lambda) +- `arr1, ..., arrN` — N 个数组。 [`Array(T)`](/sql-reference/data-types/array) + +**返回值** + +返回`func`返回 true 的元素数量。否则,返回数组中非零元素的数量。 [`UInt32`](/sql-reference/data-types/int-uint) + +**示例** + +**用法示例** + +```sql title=Query +SELECT arrayCount(x -> (x % 2), groupArray(number)) FROM numbers(10) +``` + +```response title=Response +5 +``` +## arrayCumSum {#arrayCumSum} + +引入于:v1.1 + +返回源数组中元素的部分(运行)和的数组。如果指定了 lambda 函数,则通过将 lambda 应用到数组中每个位置的元素来计算和。 + +**语法** + +```sql +arrayCumSum([func,] arr1[, arr2, ... , arrN]) +``` + +**参数** + +- `func` — 可选。要应用于每个位置的数组元素的 lambda 函数。 [`Lambda function`](/sql-reference/functions/overview#arrow-operator-and-lambda) +- `arr1` — 源数组的数值。 [`Array(T)`](/sql-reference/data-types/array) +- `[arr2, ..., arrN]` — 可选。作为参数传递给 lambda 函数的相同大小的其他数组。 [`Array(T)`](/sql-reference/data-types/array) + +**返回值** + +返回源数组中元素的部分和的数组。结果类型与输入数组的数值类型相匹配。 [`Array(T)`](/sql-reference/data-types/array) + +**示例** + +**基本用法** + +```sql title=Query +SELECT arrayCumSum([1, 1, 1, 1]) AS res +``` + +```response title=Response +[1, 2, 3, 4] +``` + +**与 lambda 的用法** + +```sql title=Query +SELECT arrayCumSum(x -> x * 2, [1, 2, 3]) AS res +``` + +```response title=Response +[2, 6, 12] +``` +## arrayCumSumNonNegative {#arrayCumSumNonNegative} + +引入于:v18.12 + +返回源数组中元素的部分(运行)和的数组,将任何负数的运行和替换为零。如果指定了 lambda 函数,则通过将 lambda 应用到数组中每个位置的元素来计算和。 + +**语法** + +```sql +arrayCumSumNonNegative([func,] arr1[, arr2, ... , arrN]) +``` + +**参数** + +- `func` — 可选。要应用于每个位置的数组元素的 lambda 函数。 [`Lambda function`](/sql-reference/functions/overview#arrow-operator-and-lambda) +- `arr1` — 源数组的数值。 [`Array(T)`](/sql-reference/data-types/array) +- `[arr2, ..., arrN]` — 可选。作为参数传递给 lambda 函数的相同大小的其他数组。 [`Array(T)`](/sql-reference/data-types/array) + +**返回值** + +返回源数组中元素的部分和的数组,将任何负数的运行和替换为零。结果类型与输入数组的数值类型相匹配。 [`Array(T)`](/sql-reference/data-types/array) + +**示例** + +**基本用法** + +```sql title=Query +SELECT arrayCumSumNonNegative([1, 1, -4, 1]) AS res +``` + +```response title=Response +[1, 2, 0, 1] +``` + +**与 lambda 的用法** + +```sql title=Query +SELECT arrayCumSumNonNegative(x -> x * 2, [1, -2, 3]) AS res +``` + +```response title=Response +[2, 0, 6] +``` +## arrayDifference {#arrayDifference} + +引入于:v1.1 + + +计算相邻数组元素之间的差的数组。 +结果数组的第一个元素为 0,第二个为 `arr[1] - arr[0]`,第三个为 `arr[2] - arr[1]`,以此类推。 +结果数组中元素的类型由减法的类型推断规则确定(例如 `UInt8` - `UInt8` = `Int16`)。 + + +**语法** + +```sql +arrayDifference(arr) +``` + +**参数** + +- `arr` — 用于计算相邻元素之间差异的数组。 [`Array(T)`](/sql-reference/data-types/array) + +**返回值** + +返回相邻数组元素之间的差的数组 [`UInt*`](/sql-reference/data-types/int-uint) + +**示例** + +**用法示例** + +```sql title=Query +SELECT arrayDifference([1, 2, 3, 4]); +``` + +```response title=Response +[0,1,1,1] +``` + +**由于结果类型 Int64 导致的溢出示例** + +```sql title=Query +SELECT arrayDifference([0, 10000000000000000000]); +``` + +```response title=Response +┌─arrayDifference([0, 10000000000000000000])─┐ +│ [0,-8446744073709551616] │ +└────────────────────────────────────────────┘ +``` ## arrayDistinct {#arrayDistinct} 引入于:v1.1 +返回一个只包含数组中不同元素的数组。 + **语法** ```sql @@ -229,11 +458,11 @@ arrayDistinct(arr) **参数** -- `arr` — 需要提取不同元素的数组。 [`Array(T)`](/sql-reference/data-types/array)。 +- `arr` — 用于提取不同元素的数组。 [`Array(T)`](/sql-reference/data-types/array) **返回值** -返回包含不同元素的数组。 [`Array(T)`](/sql-reference/data-types/array)。 +返回一个只包含不同元素的数组 [`Array(T)`](/sql-reference/data-types/array) **示例** @@ -246,10 +475,78 @@ SELECT arrayDistinct([1, 2, 2, 3, 1]); ```response title=Response [1,2,3] ``` +## arrayDotProduct {#arrayDotProduct} + +引入于:v23.5 + + +返回两个数组的点积。 + +:::note +两个向量的大小必须相等。数组和元组也可以包含混合元素类型。 +::: + + +**语法** + +```sql +arrayDotProduct(v1, v2) +``` + +**参数** + +- `v1` — 第一个向量。 [`Array((U)Int* | Float* | Decimal)`](/sql-reference/data-types/array) 或 [`Tuple((U)Int* | Float* | Decimal)`](/sql-reference/data-types/tuple) +- `v2` — 第二个向量。 [`Array((U)Int* | Float* | Decimal)`](/sql-reference/data-types/array) 或 [`Tuple((U)Int* | Float* | Decimal)`](/sql-reference/data-types/tuple) + +**返回值** + +两个向量的点积。 + +:::note +返回类型由参数的类型决定。如果数组或元组包含混合元素类型,则结果类型为超类型。 +::: + + [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal`](/sql-reference/data-types/decimal) + +**示例** + +**数组示例** + +```sql title=Query +SELECT arrayDotProduct([1, 2, 3], [4, 5, 6]) AS res, toTypeName(res); +``` + +```response title=Response +32 UInt16 +``` + +**元组示例** + +```sql title=Query +SELECT dotProduct((1::UInt16, 2::UInt8, 3::Float32),(4::Int16, 5::Float32, 6::UInt8)) AS res, toTypeName(res); +``` + +```response title=Response +32 Float64 +``` ## arrayElement {#arrayElement} 引入于:v1.1 + +获取提供的数组中索引为 `n` 的元素,其中 `n` 可以是任何整数类型。 +如果索引超出了数组的范围,则返回默认值(数字为 0,字符串为空等), +除非参数是非恒定数组和常量索引 0。在这种情况下,将出现错误 `Array indices are 1-based`。 + +:::note +ClickHouse 中的数组是基于 1 的索引。 +::: + +支持负索引。在这种情况下,从末尾开始编号,选择对应的元素。例如,`arr[-1]` 是数组中的最后一个项。 + +运算符 `[n]` 提供相同的功能。 + + **语法** ```sql @@ -258,12 +555,11 @@ arrayElement(arr, n) **参数** -- `arr` — 要搜索的数组。 [`Array(T)`](/sql-reference/data-types/array)。 -- `n` — 要获取的元素位置。 [`(U)Int*`](/sql-reference/data-types/int-uint)。 +- `arr` — 要搜索的数组。 [`Array(T)`](/sql-reference/data-types/array). - `n` — 要获取的元素的位置。 [`(U)Int*`](/sql-reference/data-types/int-uint). **返回值** -返回由提供的数组参数组成的单个组合数组。 [`Array(T)`](/sql-reference/data-types/array)。 +返回单个组合数组,来自提供的数组参数 [`Array(T)`](/sql-reference/data-types/array) **示例** @@ -287,7 +583,7 @@ SELECT arrayElement(arr, -1) FROM (SELECT [1, 2, 3] AS arr) 3 ``` -**使用 [n] 的表示法** +**使用 [n] 符号** ```sql title=Query SELECT arr[2] FROM (SELECT [1, 2, 3] AS arr) @@ -297,7 +593,7 @@ SELECT arr[2] FROM (SELECT [1, 2, 3] AS arr) 2 ``` -**索引超出数组边界** +**索引超出数组范围** ```sql title=Query SELECT arrayElement(arr, 4) FROM (SELECT [1, 2, 3] AS arr) @@ -310,6 +606,16 @@ SELECT arrayElement(arr, 4) FROM (SELECT [1, 2, 3] AS arr) 引入于:v1.1 + +获取提供的数组中索引为 `n` 的元素,其中 `n` 可以是任何整数类型。 +如果索引超出了数组的范围,则返回 `NULL`,而不是默认值。 + +:::note +ClickHouse 中的数组是基于 1 的索引。 +::: + +支持负索引。在这种情况下,它选择从末尾开始编号的对应元素。例如,`arr[-1]` 是数组中的最后一个项。 + **语法** ```sql @@ -318,11 +624,11 @@ arrayElementOrNull(arrays) **参数** -- `arrays` — 任意数量的 [`Array`](/sql-reference/data-types/array) 类型参数。 +- `arrays` — 任意数量的数组参数。 [`Array`](/sql-reference/data-types/array) **返回值** -返回由提供的数组参数组成的单个组合数组。 +返回单个组合数组,来自提供的数组参数. [`Array(T)`](/sql-reference/data-types/array) **示例** @@ -346,7 +652,7 @@ SELECT arrayElementOrNull(arr, -1) FROM (SELECT [1, 2, 3] AS arr) 3 ``` -**索引超出数组边界** +**索引超出数组范围** ```sql title=Query SELECT arrayElementOrNull(arr, 4) FROM (SELECT [1, 2, 3] AS arr) @@ -359,6 +665,13 @@ NULL 引入于:v1.1 + +返回数组 `[1, 2, 3, ..., length (arr)]` + +此函数通常与 [`ARRAY JOIN`](/sql-reference/statements/select/array-join) 子句一起使用。它允许对每个数组计数一次,方法是在应用 `ARRAY JOIN` 之后。 +此函数也可以在高阶函数中使用。例如,可以使用它来获取与条件匹配的元素的数组索引。 + + **语法** ```sql @@ -367,11 +680,11 @@ arrayEnumerate(arr) **参数** -- `arr` — 要枚举的数组。 [`Array`](/sql-reference/data-types/array)。 +- `arr` — 要枚举的数组。 [`Array`](/sql-reference/data-types/array) **返回值** -返回数组 `[1, 2, 3, ..., length(arr)]`。 Array(UInt32) +返回数组 `[1, 2, 3, ..., length (arr)]`。 [`Array(UInt32)`](/sql-reference/data-types/array) **示例** @@ -408,87 +721,346 @@ ARRAY JOIN │ 1 │ security │ 2.4.0-sec1 │ 3 │ └────┴────────────────┴─────────────┴─────┘ ``` -## arrayEnumerateUniqRanked {#arrayEnumerateUniqRanked} +## arrayEnumerateDense {#arrayEnumerateDense} -引入于:v20.1 +引入于:v18.12 + +返回一个与源数组大小相同的数组,指示每个元素在源数组中首次出现的位置。 **语法** ```sql -arrayEnumerateUniqRanked(clear_depth, arr, max_array_depth) +arrayEnumerateDense(arr) ``` **参数** -- `clear_depth` — 分别对指定级别的元素进行枚举。正整数 (Integer),小于或等于 `max_arr_depth`。 -- `arr` — 要枚举的 N 维数组。 [Array](/sql-reference/data-types/array)。 -- `max_array_depth` — 最大有效深度。正整数 (Integer),小于或等于 `arr` 的深度。 +- `arr` — 要枚举的数组。 [`Array(T)`](/sql-reference/data-types/array) **返回值** -返回与 `arr` 大小相同的 N 维数组,每个元素显示该元素相对于同一值的其他元素的位置。 +返回一个与 `arr` 大小相同的数组,指示每个元素在源数组中首次出现的位置 [`Array(T)`](/sql-reference/data-types/array) **示例** -**示例 1** +**用法示例** ```sql title=Query -With `clear_depth=1` and `max_array_depth=1`, the result of `arrayEnumerateUniqRanked` is identical to that which [`arrayEnumerateUniq`](#arrayenumerateuniq) would give for the same array. +SELECT arrayEnumerateDense([10, 20, 10, 30]) +``` + +```response title=Response +[1,2,1,3] +``` +## arrayEnumerateDenseRanked {#arrayEnumerateDenseRanked} + +引入于:v20.1 + +返回一个与源数组同样大小的数组,指示每个元素在源数组中首次出现的位置。它允许对多维数组进行枚举,并能够指定深入数组查看的层级。 + +**语法** ```sql -SELECT arrayEnumerateUniqRanked(1, [1,2,1], 1); +arrayEnumerateDenseRanked(clear_depth, arr, max_array_depth) ``` + +**参数** + +- `clear_depth` — 分别枚举指定层级的元素。必须小于或等于 `max_arr_depth`。 [`UInt*`](/sql-reference/data-types/int-uint) +- `arr` — 要枚举的 N 维数组。 [`Array(T)`](/sql-reference/data-types/array) +- `max_array_depth` — 最大有效深度。必须小于或等于 `arr` 的深度。 [`UInt*`](/sql-reference/data-types/int-uint) + +**返回值** + +返回一个数组,表示每个元素在源数组中首次出现的位置 [`Array`](/sql-reference/data-types/array) + +**示例** + +**基本用法** + +```sql title=Query +-- With clear_depth=1 and max_array_depth=1, the result is identical to what arrayEnumerateDense would give. + +SELECT arrayEnumerateDenseRanked(1,[10, 20, 10, 30],1); ``` ```response title=Response -[1,1,2] +[1,2,1,3] ``` -**示例 2** +**与多维数组的用法** + +```sql title=Query +-- In this example, arrayEnumerateDenseRanked is used to obtain an array indicating, for each element of the +-- multidimensional array, what its position is among elements of the same value. +-- For the first row of the passed array, [10, 10, 30, 20], the corresponding first row of the result is [1, 1, 2, 3], +-- indicating that 10 is the first number encountered in position 1 and 2, 30 the second number encountered in position 3 +-- and 20 is the third number encountered in position 4. +-- For the second row, [40, 50, 10, 30], the corresponding second row of the result is [4,5,1,2], indicating that 40 +-- and 50 are the fourth and fifth numbers encountered in position 1 and 2 of that row, that another 10 +-- (the first encountered number) is in position 3 and 30 (the second number encountered) is in the last position. + +SELECT arrayEnumerateDenseRanked(1,[[10,10,30,20],[40,50,10,30]],2); +``` + +```response title=Response +[[1,1,2,3],[4,5,1,2]] +``` + +**使用增加的 clear_depth 的示例** ```sql title=Query -With `clear_depth=1` and `max_array_depth=1`, the result of `arrayEnumerateUniqRanked` is identical to that which [`arrayEnumerateUniq`](#arrayenumerateuniq) would give for the same array. +-- Changing clear_depth=2 results in the enumeration occurring separately for each row anew. + +SELECT arrayEnumerateDenseRanked(2,[[10,10,30,20],[40,50,10,30]],2); +``` + +```response title=Response +[[1, 1, 2, 3], [1, 2, 3, 4]] +``` +## arrayEnumerateUniq {#arrayEnumerateUniq} + +引入于:v1.1 + + +返回一个与源数组大小相同的数组,指示每个元素在具有相同值的元素中的位置。 + +此函数在使用 `ARRAY JOIN` 和数组元素聚合时非常有用。 + +该函数可以接受多个相同大小的数组作为参数。在这种情况下,唯一性考虑的是在所有数组中相同位置的元素元组。 + +**语法** ```sql -SELECT arrayEnumerateUniqRanked(1, [[1,2,3],[2,2,1],[3]], 2);", "[[1,1,1],[2,3,2],[2]] +arrayEnumerateUniq(arr1[, arr2, ... , arrN]) +``` + +**参数** + +- `arr1` — 第一个要处理的数组。 [`Array(T)`](/sql-reference/data-types/array) +- `arr2, ...` — 可选。相同大小的其他数组,以实现元组唯一性。 [`Array(UInt32)`](/sql-reference/data-types/array) + +**返回值** + +返回一个数组,其中每个元素是具有相同值或元组的元素中的位置。 [`Array(T)`](/sql-reference/data-types/array) + +**示例** + +**基本用法** + +```sql title=Query +SELECT arrayEnumerateUniq([10, 20, 10, 30]); +``` + +```response title=Response +[1, 1, 2, 1] ``` + +**多个数组** + +```sql title=Query +SELECT arrayEnumerateUniq([1, 1, 1, 2, 2, 2], [1, 1, 2, 1, 1, 2]); ``` ```response title=Response -[1,1,2] +[1,2,1,1,2,1] ``` -**示例 3** +**ARRAY JOIN 聚合** ```sql title=Query -In this example, `arrayEnumerateUniqRanked` is used to obtain an array indicating, for each element of the multidimensional array, what its position is among elements of the same value. For the first row of the passed array,`[1,2,3]`, the corresponding result is `[1,1,1]`, indicating that this is the first time `1`,`2` and `3` are encountered. For the second row of the provided array,`[2,2,1]`, the corresponding result is `[2,3,3]`, indicating that `2` is encountered for a second and third time, and `1` is encountered for the second time. Likewise, for the third row of the provided array `[3]` the corresponding result is `[2]` indicating that `3` is encountered for the second time. +-- Each goal ID has a calculation of the number of conversions (each element in the Goals nested data structure is a goal that was reached, which we refer to as a conversion) +-- and the number of sessions. Without ARRAY JOIN, we would have counted the number of sessions as sum(Sign). But in this particular case, +-- the rows were multiplied by the nested Goals structure, so in order to count each session one time after this, we apply a condition to the +-- value of the arrayEnumerateUniq(Goals.ID) function. + +SELECT + Goals.ID AS GoalID, + sum(Sign) AS Reaches, + sumIf(Sign, num = 1) AS Visits +FROM test.visits +ARRAY JOIN + Goals, + arrayEnumerateUniq(Goals.ID) AS num +WHERE CounterID = 160656 +GROUP BY GoalID +ORDER BY Reaches DESC +LIMIT 10 +``` + +```response title=Response +┌──GoalID─┬─Reaches─┬─Visits─┐ +│ 53225 │ 3214 │ 1097 │ +│ 2825062 │ 3188 │ 1097 │ +│ 56600 │ 2803 │ 488 │ +│ 1989037 │ 2401 │ 365 │ +│ 2830064 │ 2396 │ 910 │ +│ 1113562 │ 2372 │ 373 │ +│ 3270895 │ 2262 │ 812 │ +│ 1084657 │ 2262 │ 345 │ +│ 56599 │ 2260 │ 799 │ +│ 3271094 │ 2256 │ 812 │ +└─────────┴─────────┴────────┘ +``` +## arrayEnumerateUniqRanked {#arrayEnumerateUniqRanked} + +引入于:v20.1 + + +返回与源数组相同维度的数组(或多维数组),指示每个元素在具有相同值的元素中的位置。 +它允许对多维数组进行枚举,能够指定深入数组查看的层级。 + +**语法** ```sql -SELECT arrayEnumerateUniqRanked(1, [[1,2,3],[2,2,1],[3]], 2); +arrayEnumerateUniqRanked(clear_depth, arr, max_array_depth) ``` + +**参数** + +- `clear_depth` — 分别枚举指定层级的元素。正整数,必须小于或等于 `max_arr_depth`。 [`UInt*`](/sql-reference/data-types/int-uint) +- `arr` — 要枚举的 N 维数组。 [`Array(T)`](/sql-reference/data-types/array) +- `max_array_depth` — 最大有效深度。正整数,必须小于或等于 `arr` 的深度。 [`UInt*`](/sql-reference/data-types/int-uint) + +**返回值** + +返回一个与 `arr` 相同大小的 N 维数组,其中每个元素显示该元素相较于其他相同值元素的位置。 [`Array(T)`](/sql-reference/data-types/array) + +**示例** + +**示例 1** + +```sql title=Query +-- With clear_depth=1 and max_array_depth=1, the result of arrayEnumerateUniqRanked +-- is identical to that which arrayEnumerateUniq would give for the same array. + +SELECT arrayEnumerateUniqRanked(1, [1, 2, 1], 1); +``` + +```response title=Response +[1, 1, 2] +``` + +**示例 2** + +```sql title=Query +-- with clear_depth=1 and max_array_depth=1, the result of arrayEnumerateUniqRanked +-- is identical to that which arrayEnumerateUniqwould give for the same array. + +SELECT arrayEnumerateUniqRanked(1, [[1, 2, 3], [2, 2, 1], [3]], 2);", "[[1, 1, 1], [2, 3, 2], [2]] ``` ```response title=Response -[[1,1,1],[2,3,2],[2]] +[1, 1, 2] +``` + +**示例 3** + +```sql title=Query +-- In this example, arrayEnumerateUniqRanked is used to obtain an array indicating, +-- for each element of the multidimensional array, what its position is among elements +-- of the same value. For the first row of the passed array, [1, 2, 3], the corresponding +-- result is [1, 1, 1], indicating that this is the first time 1, 2 and 3 are encountered. +-- For the second row of the provided array, [2, 2, 1], the corresponding result is [2, 3, 3], +-- indicating that 2 is encountered for a second and third time, and 1 is encountered +-- for the second time. Likewise, for the third row of the provided array [3] the +-- corresponding result is [2] indicating that 3 is encountered for the second time. + +SELECT arrayEnumerateUniqRanked(1, [[1, 2, 3], [2, 2, 1], [3]], 2); +``` + +```response title=Response +[[1, 1, 1], [2, 3, 2], [2]] ``` **示例 4** ```sql title=Query -Changing `clear_depth=2`, results in elements being enumerated separately for each row. +-- Changing clear_depth=2, results in elements being enumerated separately for each row. +SELECT arrayEnumerateUniqRanked(2,[[1, 2, 3],[2, 2, 1],[3]], 2); +``` + +```response title=Response +[[1, 1, 1], [1, 2, 1], [1]] +``` +## arrayExcept {#arrayExcept} + +引入于:v25.9 + + +返回一个包含 `source` 中元素而不在 `except` 中的数组,保持原始顺序。 + +此函数对两个数组执行集合差集操作。对于 `source` 中的每个元素,它检查该元素是否存在于 `except` 中(使用精确比较)。如果不存在,则将该元素包含在结果中。 + +该操作保持以下属性: +1. 从 `source` 中的元素顺序得以保持 +2. 在 `source` 中的重复项将保持,前提是它们不在 `except` 中 +3. NULL 被视为单独的值 + + +**语法** ```sql -SELECT arrayEnumerateUniqRanked(2, [[1,2,3],[2,2,1],[3]], 2); +arrayExcept(source, except) +``` + +**参数** + +- `source` — 包含要过滤元素的源数组。 [`Array(T)`](/sql-reference/data-types/array) +- `except` — 包含要从结果中排除的元素的数组。 [`Array(T)`](/sql-reference/data-types/array) + +**返回值** + +返回与输入数组相同类型的数组,包含未在 `except` 中找到的 `source` 中的元素。 [`Array(T)`](/sql-reference/data-types/array) + +**示例** + +**基本** + +```sql title=Query +SELECT arrayExcept([1, 2, 3, 2, 4], [3, 5]) +``` + +```response title=Response +[1, 2, 2, 4] +``` + +**有 NULL 的情况 1** + +```sql title=Query +SELECT arrayExcept([1, NULL, 2, NULL], [2]) +``` + +```response title=Response +[1, NULL, NULL] +``` + +**有 NULL 的情况 2** + +```sql title=Query +SELECT arrayExcept([1, NULL, 2, NULL], [NULL, 2, NULL]) +``` + +```response title=Response +[1] ``` + +**字符串** + +```sql title=Query +SELECT arrayExcept(['apple', 'banana', 'cherry'], ['banana', 'date']) ``` ```response title=Response -[[1,1,1],[1,2,1],[1]] +['apple', 'cherry'] ``` ## arrayExists {#arrayExists} 引入于:v1.1 + +如果源数组中至少有一个元素使得 `func(x[, y1, y2, ... yN])` 返回 true,则返回 `1`。否则,返回 `0`。 + **语法** ```sql @@ -497,13 +1069,13 @@ arrayExists(func(x[, y1, ..., yN]), source_arr[, cond1_arr, ... , condN_arr]) **参数** -- `func(x[, y1, ..., yN])` — 操作源数组 (`x`) 和条件数组 (`y`) 元素的 lambda 函数。 [Lambda 函数](/sql-reference/functions/overview#arrow-operator-and-lambda)。 -- `source_arr` — 要处理的源数组。 [`Array(T)`](/sql-reference/data-types/array)。 -- `[, cond1_arr, ... , condN_arr]` — 可选。提供额外参数给 lambda 函数的 N 个条件数组。 [`Array(T)`](/sql-reference/data-types/array)。 +- `func(x[, y1, ..., yN])` — 一个对源数组 (`x`) 和条件数组 (`y`) 中元素操作的 lambda 函数。 [`Lambda function`](/sql-reference/functions/overview#arrow-operator-and-lambda) +- `source_arr` — 要处理的源数组。 [`Array(T)`](/sql-reference/data-types/array) +- `[, cond1_arr, ... , condN_arr]` — 可选。N个条件数组,为 lambda 函数提供额外参数。 [`Array(T)`](/sql-reference/data-types/array) **返回值** -如果 lambda 函数对至少一个元素返回 true,则返回 `1`,否则返回 `0`。 [`UInt8`](/sql-reference/data-types/int-uint)。 +如果 lambda 函数对至少一个元素返回 true,则返回 `1`,否则返回 `0` [`UInt8`](/sql-reference/data-types/int-uint) **示例** @@ -520,6 +1092,9 @@ SELECT arrayExists(x, y -> x=y, [1, 2, 3], [0, 0, 0]) 引入于:v20.1 + +`arrayFill` 函数顺序处理源数组,从第一个元素到最后一个元素,在每个位置上评估 lambda 条件,使用源数组和条件数组的元素。当 lambda 函数在位置 i 处评估为 false 时,该函数将该元素替换为数组当前状态中位置 i-1 的元素。第一个元素始终被保留,不受任何条件影响。 + **语法** ```sql @@ -528,39 +1103,41 @@ arrayFill(func(x [, y1, ..., yN]), source_arr[, cond1_arr, ... , condN_arr]) **参数** -- `func(x [, y1, ..., yN])` — lambda 函数 `func(x [, y1, y2, ... yN]) → F(x [, y1, y2, ... yN])`,操作源数组 (`x`) 和条件数组 (`y`) 元素。 [Lambda 函数](/sql-reference/functions/overview#arrow-operator-and-lambda)。 -- `source_arr` — 要处理的源数组 [`Array(T)`](/sql-reference/data-types/array)。 -- `[, cond1_arr, ... , condN_arr]` — 可选。提供额外参数给 lambda 函数的 N 个条件数组。 [`Array(T)`](/sql-reference/data-types/array)。 +- `func(x [, y1, ..., yN])` — 操作源数组 (`x`) 和条件数组 (`y`) 元素的 lambda 函数 `func(x [, y1, y2, ... yN]) → F(x [, y1, y2, ... yN] )。 [`Lambda function`](/sql-reference/functions/overview#arrow-operator-and-lambda) +- `source_arr` — 要处理的源数组。 [`Lambda function`](/sql-reference/functions/overview#arrow-operator-and-lambda) +- `[, cond1_arr, ... , condN_arr]` — 可选。N 个条件数组,为 lambda 函数提供额外参数。 [`Array(T)`](/sql-reference/data-types/array) **返回值** -返回一个数组。 [`Array(T)`](/sql-reference/data-types/array)。 +返回数组 [`Array(T)`](/sql-reference/data-types/array) **示例** -**单个数组的示例** +**使用单个数组的示例** ```sql title=Query SELECT arrayFill(x -> not isNull(x), [1, null, 2, null]) AS res ``` ```response title=Response -[1,1,2,2] +[1, 1, 2, 2] ``` -**两个数组的示例** +**使用两个数组的示例** ```sql title=Query SELECT arrayFill(x, y, z -> x > y AND x < z, [5, 3, 6, 2], [4, 7, 1, 3], [10, 2, 8, 5]) AS res ``` ```response title=Response -[5,5,6,6] +[5, 5, 6, 6] ``` ## arrayFilter {#arrayFilter} 引入于:v1.1 +返回一个数组,仅包含源数组中返回 true 的元素。 + **语法** ```sql @@ -569,13 +1146,13 @@ arrayFilter(func(x[, y1, ..., yN]), source_arr[, cond1_arr, ... , condN_arr])] **参数** -- `func(x[, y1, ..., yN])` — 操作源数组 (`x`) 和条件数组 (`y`) 元素的 lambda 函数。 [Lambda 函数](/sql-reference/functions/overview#arrow-operator-and-lambda)。 -- `source_arr` — 要处理的源数组 [`Array(T)`](/sql-reference/data-types/array)。 -- `[, cond1_arr, ... , condN_arr]` — 可选。提供额外参数给 lambda 函数的 N 个条件数组。 [`Array(T)`](/sql-reference/data-types/array)。 +- `func(x[, y1, ..., yN])` — 一个对源数组 (`x`) 和条件数组 (`y`) 中元素操作的 lambda 函数。 [`Lambda function`](/sql-reference/functions/overview#arrow-operator-and-lambda) +- `source_arr` — 要处理的源数组。 [`Array(T)`](/sql-reference/data-types/array) +- `[, cond1_arr, ... , condN_arr]` — 可选。N 个条件数组,为 lambda 函数提供额外参数。 [`Array(T)`](/sql-reference/data-types/array) **返回值** -返回源数组的子集。 [`Array(T)`](/sql-reference/data-types/array)。 +返回源数组的子集 [`Array(T)`](/sql-reference/data-types/array) **示例** @@ -607,6 +1184,10 @@ SELECT 引入于:v1.1 + +返回源数组中第一个使得 `func(x[, y1, y2, ... yN])` 返回 true 的元素,否则返回默认值。 + + **语法** ```sql @@ -615,13 +1196,11 @@ arrayFirst(func(x[, y1, ..., yN]), source_arr[, cond1_arr, ... , condN_arr]) **参数** -- `func(x[, y1, ..., yN])` — 操作源数组 (`x`) 和条件数组 (`y`) 元素的 lambda 函数。 [Lambda 函数](/sql-reference/functions/overview#arrow-operator-and-lambda)。 -- `source_arr` — 要处理的源数组。 [`Array(T)`](/sql-reference/data-types/array)。 -- `[, cond1_arr, ... , condN_arr]` — 可选。提供额外参数给 lambda 函数的 N 个条件数组。 [`Array(T)`](/sql-reference/data-types/array)。 +- `func(x[, y1, ..., yN])` — 一个对源数组 (`x`) 和条件数组 (`y`) 中元素操作的 lambda 函数。 [Lambda function](/sql-reference/functions/overview#arrow-operator-and-lambda). - `source_arr` — 要处理的源数组。 [`Array(T)`](/sql-reference/data-types/array). - `[, cond1_arr, ... , condN_arr]` — 可选。N个条件数组,为 lambda 函数提供额外参数。 [`Array(T)`](/sql-reference/data-types/array). **返回值** -返回源数组中第一个使 `λ` 为 true 的元素,否则返回 T 的默认值。 +返回源数组中第一个使得 `λ` 为 true 的元素,否则返回 `T` 的默认值。 **示例** @@ -635,7 +1214,7 @@ SELECT arrayFirst(x, y -> x=y, ['a', 'b', 'c'], ['c', 'b', 'a']) b ``` -**没有匹配** +**无匹配项** ```sql title=Query SELECT arrayFirst(x, y -> x=y, [0, 1, 2], [3, 3, 3]) AS res, toTypeName(res) @@ -648,6 +1227,9 @@ SELECT arrayFirst(x, y -> x=y, [0, 1, 2], [3, 3, 3]) AS res, toTypeName(res) 引入于:v1.1 + +返回源数组中第一个使得 `func(x[, y1, y2, ... yN])` 返回 true 的元素的索引,否则返回 '0'。 + **语法** ```sql @@ -656,13 +1238,11 @@ arrayFirstIndex(func(x[, y1, ..., yN]), source_arr[, cond1_arr, ... , condN_arr] **参数** -- `func(x[, y1, ..., yN])` — 操作源数组 (`x`) 和条件数组 (`y`) 元素的 lambda 函数。 [Lambda 函数](/sql-reference/functions/overview#arrow-operator-and-lambda)。 -- `source_arr` — 要处理的源数组。 [`Array(T)`](/sql-reference/data-types/array)。 -- `[, cond1_arr, ... , condN_arr]` — 可选。提供额外参数给 lambda 函数的 N 个条件数组。 [`Array(T)`](/sql-reference/data-types/array)。 +- `func(x[, y1, ..., yN])` — 一个对源数组 (`x`) 和条件数组 (`y`) 中元素操作的 lambda 函数。 [Lambda function](/sql-reference/functions/overview#arrow-operator-and-lambda). - `source_arr` — 要处理的源数组。 [`Array(T)`](/sql-reference/data-types/array). - `[, cond1_arr, ... , condN_arr]` — 可选。N个条件数组,为 lambda 函数提供额外参数。 [`Array(T)`](/sql-reference/data-types/array). **返回值** -返回源数组中第一个使 `func` 为 true 的元素的索引,否则返回 `0`。 [`UInt32`](/sql-reference/data-types/int-uint)。 +返回源数组中第一个使得 `func` 为 true 的元素的索引,否则返回 `0` [`UInt32`](/sql-reference/data-types/int-uint) **示例** @@ -676,7 +1256,7 @@ SELECT arrayFirstIndex(x, y -> x=y, ['a', 'b', 'c'], ['c', 'b', 'a']) 2 ``` -**没有匹配** +**无匹配项** ```sql title=Query SELECT arrayFirstIndex(x, y -> x=y, ['a', 'b', 'c'], ['d', 'e', 'f']) @@ -689,6 +1269,10 @@ SELECT arrayFirstIndex(x, y -> x=y, ['a', 'b', 'c'], ['d', 'e', 'f']) 引入于:v1.1 + +返回源数组中第一个使得 `func(x[, y1, y2, ... yN])` 返回 true 的元素,否则返回 `NULL`。 + + **语法** ```sql @@ -697,13 +1281,13 @@ arrayFirstOrNull(func(x[, y1, ..., yN]), source_arr[, cond1_arr, ... , condN_arr **参数** -- `func(x[, y1, ..., yN])` — 操作源数组 (`x`) 和条件数组 (`y`) 元素的 lambda 函数。 [Lambda 函数](/sql-reference/functions/overview#arrow-operator-and-lambda)。 -- `source_arr` — 要处理的源数组。 [`Array(T)`](/sql-reference/data-types/array)。 -- `[, cond1_arr, ... , condN_arr]` — 可选。提供额外参数给 lambda 函数的 N 个条件数组。 [`Array(T)`](/sql-reference/data-types/array)。 +- `func(x[, y1, ..., yN])` — 一个对源数组 (`x`) 和条件数组 (`y`) 中元素操作的 lambda 函数。 [`Lambda function`](/sql-reference/functions/overview#arrow-operator-and-lambda) +- `source_arr` — 要处理的源数组。 [`Array(T)`](/sql-reference/data-types/array) +- `[, cond1_arr, ... , condN_arr]` — 可选。N个条件数组,为 lambda 函数提供额外参数。 [`Array(T)`](/sql-reference/data-types/array) **返回值** -返回源数组中第一个使 `func` 为 true 的元素,否则返回 `NULL`。 +返回源数组中第一个使得 `func` 为 true 的元素,否则返回 `NULL`。 **示例** @@ -717,7 +1301,7 @@ SELECT arrayFirstOrNull(x, y -> x=y, ['a', 'b', 'c'], ['c', 'b', 'a']) b ``` -**没有匹配** +**无匹配项** ```sql title=Query SELECT arrayFirstOrNull(x, y -> x=y, [0, 1, 2], [3, 3, 3]) AS res, toTypeName(res) @@ -730,6 +1314,17 @@ NULL Nullable(UInt8) 引入于:v20.1 + +将数组的数组转换为平面数组。 + +函数: + +- 适用于任何深度的嵌套数组。 +- 不会更改已经是平面的数组。 + +扁平数组包含所有源数组中的所有元素。 + + **语法** ```sql @@ -738,11 +1333,11 @@ arrayFlatten(arr) **参数** -- `arr` — 多维数组。 [`Array(T)`](/sql-reference/data-types/array)(`Array`) +- `arr` — 一个多维数组。 [`Array(Array(T))`](/sql-reference/data-types/array) **返回值** -返回从多维数组平铺出的数组。 [`Array(T)`](/sql-reference/data-types/array)。 +返回从多维数组中扁平化的数组 [`Array(T)`](/sql-reference/data-types/array) **示例** @@ -753,12 +1348,14 @@ SELECT arrayFlatten([[[1]], [[2], [3]]]); ``` ```response title=Response -[1,2,3] +[1, 2, 3] ``` ## arrayFold {#arrayFold} 引入于:v23.10 +对一个或多个大小相等的数组应用 lambda 函数,并将结果收集到一个累加器中。 + **语法** ```sql @@ -767,9 +1364,9 @@ arrayFold(λ(acc, x1 [, x2, x3, ... xN]), arr1 [, arr2, arr3, ... arrN], acc) **参数** -- `λ(x, x1 [, x2, x3, ... xN])` — lambda 函数 `λ(acc, x1 [, x2, x3, ... xN]) → F(acc, x1 [, x2, x3, ... xN])`,其中 `F` 是应用于 `acc` 和来自 `x` 的数组值的操作,`acc` 的结果可以被重用。 [Lambda 函数](/sql-reference/functions/overview#arrow-operator-and-lambda)。 +- `λ(x, x1 [, x2, x3, ... xN])` — 一个 lambda 函数 `λ(acc, x1 [, x2, x3, ... xN]) → F(acc, x1 [, x2, x3, ... xN])`,其中 `F` 是应用于 `acc` 和来自 `x` 的数组值的操作,结果的 `acc` 被重用。 [`Lambda function`](/sql-reference/functions/overview#arrow-operator-and-lambda) - `arr1 [, arr2, arr3, ... arrN]` — N 个要操作的数组。 [`Array(T)`](/sql-reference/data-types/array) -- `acc` — 与 Lambda 函数返回类型相同的累加器值。 +- `acc` — 与 lambda 函数返回类型相同的累加器值。 **返回值** @@ -826,6 +1423,8 @@ SELECT arrayFold( 引入于:v1.1 +接受多个数组并返回一个包含在所有源数组中的元素的数组。结果仅包含唯一值。 + **语法** ```sql @@ -834,11 +1433,11 @@ arrayIntersect(arr, arr1, ..., arrN) **参数** -- `arrN` — 用于创建新数组的 N 个数组。 [`Array(T)`](/sql-reference/data-types/array)。 +- `arrN` — 从中创建新数组的 N 个数组。 [`Array(T)`](/sql-reference/data-types/array). **返回值** -返回一个包含所有 N 个数组中存在的不重复元素的数组。 [`Array(T)`](/sql-reference/data-types/array)。 +返回一个包含在所有 N 个数组中的不同元素的数组 [`Array(T)`](/sql-reference/data-types/array) **示例** @@ -859,6 +1458,8 @@ arrayIntersect([1, 2], [1, 3], [1, 4]) AS non_empty_intersection 引入于:v23.7 +返回两个数组的 [Jaccard 指数](https://en.wikipedia.org/wiki/Jaccard_index)。 + **语法** ```sql @@ -867,12 +1468,12 @@ arrayJaccardIndex(arr_x, arr_y) **参数** -- `arr_x` — 第一个数组。 [`Array(T)`](/sql-reference/data-types/array)。 -- `arr_y` — 第二个数组。 [`Array(T)`](/sql-reference/data-types/array)。 +- `arr_x` — 第一个数组。 [`Array(T)`](/sql-reference/data-types/array) +- `arr_y` — 第二个数组。 [`Array(T)`](/sql-reference/data-types/array) **返回值** -返回 `arr_x` 和 `arr_y` 的 Jaccard 指数。[Float64](/sql-reference/data-types/float) +返回 `arr_x` 和 `arr_y` 的 Jaccard 指数 [`Float64`](/sql-reference/data-types/float) **示例** @@ -885,10 +1486,16 @@ SELECT arrayJaccardIndex([1, 2], [2, 3]) AS res ```response title=Response 0.3333333333333333 ``` + ## arrayJoin {#arrayJoin} 引入于:v1.1 +`arrayJoin` 函数接受一个包含数组的行并展开它,生成多行——每个元素对应一行。 +这与 ClickHouse 的常规函数形成对比,常规函数将输入值映射到同一行的输出值,而聚合函数则将一组行“压缩”或“减少”成一行汇总(或者在与 `GROUP BY` 一起使用时为汇总行中的单个值)。 + +除了应用此函数的列中的值被替换为相应的数组值外,所有列中的值都被简单地复制。 + **语法** ```sql @@ -897,11 +1504,11 @@ arrayJoin(arr) **参数** -- `arr` — 要展开的数组。 [`Array(T)`](/sql-reference/data-types/array)。 +- `arr` — 要展开的数组。 [`Array(T)`](/sql-reference/data-types/array) **返回值** -返回从 `arr` 展开的行集合。 +返回从 `arr` 展开的多行。 **示例** @@ -922,9 +1529,8 @@ SELECT arrayJoin([1, 2, 3] AS src) AS dst, 'Hello', src **arrayJoin 影响查询的所有部分** ```sql title=Query -The `arrayJoin` function affects all sections of the query, including the `WHERE` section. Notice the result 2, even though the subquery returned 1 row. +-- The arrayJoin function affects all sections of the query, including the WHERE section. Notice the result 2, even though the subquery returned 1 row. -```sql SELECT sum(1) AS impressions FROM ( @@ -932,7 +1538,6 @@ FROM ) WHERE arrayJoin(cities) IN ['Istanbul', 'Berlin']; ``` -``` ```response title=Response ┌─impressions─┐ @@ -943,9 +1548,8 @@ WHERE arrayJoin(cities) IN ['Istanbul', 'Berlin']; **使用多个 arrayJoin 函数** ```sql title=Query -A query can use multiple `arrayJoin` functions. In this case, the transformation is performed multiple times and the rows are multiplied. +- A query can use multiple arrayJoin functions. In this case, the transformation is performed multiple times and the rows are multiplied. -```sql SELECT sum(1) AS impressions, arrayJoin(cities) AS city, @@ -960,7 +1564,6 @@ GROUP BY 2, 3 ``` -``` ```response title=Response ┌─impressions─┬─city─────┬─browser─┐ @@ -973,14 +1576,13 @@ GROUP BY └─────────────┴──────────┴─────────┘ ``` -**由于优化导致的意外结果** +**由于优化而导致的意外结果** ```sql title=Query -Using multiple `arrayJoin` with the same expression may not produce the expected result due to optimizations. -For these cases, consider modifying the repeated array expression with extra operations that do not affect join result. -e.g. `arrayJoin(arraySort(arr))`, `arrayJoin(arrayConcat(arr, []))` +-- Using multiple arrayJoin with the same expression may not produce the expected result due to optimizations. +-- For these cases, consider modifying the repeated array expression with extra operations that do not affect join result. +- e.g. arrayJoin(arraySort(arr)), arrayJoin(arrayConcat(arr, [])) -```sql SELECT arrayJoin(dice) as first_throw, /* arrayJoin(dice) as second_throw */ -- is technically correct, but will annihilate result set @@ -989,7 +1591,6 @@ FROM ( SELECT [1, 2, 3, 4, 5, 6] as dice ); ``` -``` ```response title=Response ┌─first_throw─┬─second_throw─┐ @@ -1035,10 +1636,9 @@ FROM ( **使用 ARRAY JOIN 语法** ```sql title=Query -Note the [`ARRAY JOIN`](../statements/select/array-join.md) syntax in the `SELECT` query below, which provides broader possibilities. -`ARRAY JOIN` allows you to convert multiple arrays with the same number of elements at a time. +-- Note the ARRAY JOIN syntax in the `SELECT` query below, which provides broader possibilities. +-- ARRAY JOIN allows you to convert multiple arrays with the same number of elements at a time. -```sql SELECT sum(1) AS impressions, city, @@ -1056,7 +1656,6 @@ GROUP BY 2, 3 ``` -``` ```response title=Response ┌─impressions─┬─city─────┬─browser─┐ @@ -1066,12 +1665,11 @@ GROUP BY └─────────────┴──────────┴─────────┘ ``` -**使用元组** +**使用 Tuple** ```sql title=Query -You can also use [Tuple](../data-types/tuple.md): +-- You can also use Tuple -```sql SELECT sum(1) AS impressions, (arrayJoin(arrayZip(cities, browsers)) AS t).1 AS city, @@ -1086,7 +1684,6 @@ GROUP BY 2, 3 ``` -``` ```response title=Response ┌─impressions─┬─city─────┬─browser─┐ @@ -1099,6 +1696,8 @@ GROUP BY 引入于:v1.1 +返回源数组中最后一个满足 lambda `func(x [, y1, y2, ... yN])` 返回 true 的元素,否则返回默认值。 + **语法** ```sql @@ -1107,13 +1706,13 @@ arrayLast(func(x[, y1, ..., yN]), source[, cond1, ... , condN_arr]) **参数** -- `func(x[, y1, ..., yN])` — 操作源数组 (`x`) 和条件数组 (`y`) 元素的 lambda 函数。 [Lambda 函数](/sql-reference/functions/overview#arrow-operator-and-lambda)。 -- `source` — 要处理的源数组。 [`Array(T)`](/sql-reference/data-types/array)。 -- `[, cond1, ... , condN]` — 可选。提供额外参数给 lambda 函数的 N 个条件数组。 [`Array(T)`](/sql-reference/data-types/array)。 +- `func(x[, y1, ..., yN])` — 在源数组元素 (`x`) 和条件数组 (`y`) 上操作的 lambda 函数。 [Lambda 函数](/sql-reference/functions/overview#arrow-operator-and-lambda) +- `source` — 要处理的源数组。 [`Array(T)`](/sql-reference/data-types/array) +- `[, cond1, ... , condN]` — 可选。 N 个条件数组,向 lambda 函数提供附加参数。 [`Array(T)`](/sql-reference/data-types/array) **返回值** -返回源数组中最后一个使 `func` 为 true 的元素,否则返回 T 的默认值。 +返回源数组中满足 `func` 的最后一个元素,否则返回 `T` 的默认值。 **示例** @@ -1127,7 +1726,7 @@ SELECT arrayLast(x, y -> x=y, ['a', 'b', 'c'], ['a', 'b', 'c']) c ``` -**没有匹配** +**未匹配** ```sql title=Query SELECT arrayFirst(x, y -> x=y, [0, 1, 2], [3, 3, 3]) AS res, toTypeName(res) @@ -1136,10 +1735,55 @@ SELECT arrayFirst(x, y -> x=y, [0, 1, 2], [3, 3, 3]) AS res, toTypeName(res) ```response title=Response 0 UInt8 ``` +## arrayLastIndex {#arrayLastIndex} + +引入于:v1.1 + +返回源数组中最后一个满足 `func(x[, y1, y2, ... yN])` 返回 true 的元素的索引,否则返回 '0'。 + +**语法** + +```sql +arrayLastIndex(func(x[, y1, ..., yN]), source_arr[, cond1_arr, ... , condN_arr]) +``` + +**参数** + +- `func(x[, y1, ..., yN])` — 在源数组元素 (`x`) 和条件数组 (`y`) 上操作的 lambda 函数。 [`Lambda 函数`](/sql-reference/functions/overview#arrow-operator-and-lambda) +- `source_arr` — 要处理的源数组。 [`Array(T)`](/sql-reference/data-types/array) +- `[, cond1_arr, ... , condN_arr]` — 可选。 N 个条件数组,向 lambda 函数提供附加参数。 [`Array(T)`](/sql-reference/data-types/array) + +**返回值** + +返回源数组中最后一个满足 `func` 的元素的索引,否则返回 `0` [`UInt32`](/sql-reference/data-types/int-uint) + +**示例** + +**用法示例** + +```sql title=Query +SELECT arrayLastIndex(x, y -> x=y, ['a', 'b', 'c'], ['a', 'b', 'c']); +``` + +```response title=Response +3 +``` + +**未匹配** + +```sql title=Query +SELECT arrayLastIndex(x, y -> x=y, ['a', 'b', 'c'], ['d', 'e', 'f']); +``` + +```response title=Response +0 +``` ## arrayLastOrNull {#arrayLastOrNull} 引入于:v1.1 +返回源数组中最后一个满足 lambda `func(x [, y1, y2, ... yN])` 返回 true 的元素,否则返回 `NULL`。 + **语法** ```sql @@ -1148,13 +1792,13 @@ arrayLastOrNull(func(x[, y1, ..., yN]), source_arr[, cond1_arr, ... , condN_arr] **参数** -- `func(x [, y1, ..., yN])` — 操作源数组 (`x`) 和条件数组 (`y`) 元素的 lambda 函数。 [Lambda 函数](/sql-reference/functions/overview#arrow-operator-and-lambda)。 -- `source_arr` — 要处理的源数组。 [`Array(T)`](/sql-reference/data-types/array)。 -- `[, cond1_arr, ... , condN_arr]` — 可选。提供额外参数给 lambda 函数的 N 个条件数组。 [`Array(T)`](/sql-reference/data-types/array)。 +- `func(x [, y1, ..., yN])` — 在源数组元素 (`x`) 和条件数组 (`y`) 上操作的 lambda 函数。 [Lambda 函数](/sql-reference/functions/overview#arrow-operator-and-lambda) +- `source_arr` — 要处理的源数组。 [`Array(T)`](/sql-reference/data-types/array) +- `[, cond1_arr, ... , condN_arr]` — 可选。 N 个条件数组,向 lambda 函数提供附加参数。 [`Array(T)`](/sql-reference/data-types/array) **返回值** -返回源数组中最后一个使 `λ` 不为 true 的元素,否则返回 `NULL`。 +返回源数组中最后一个不满足 `λ` 的元素,否则返回 `NULL`。 **示例** @@ -1168,7 +1812,7 @@ SELECT arrayLastOrNull(x, y -> x=y, ['a', 'b', 'c'], ['a', 'b', 'c']) c ``` -**没有匹配** +**未匹配** ```sql title=Query SELECT arrayLastOrNull(x, y -> x=y, [0, 1, 2], [3, 3, 3]) AS res, toTypeName(res) @@ -1181,6 +1825,8 @@ NULL Nullable(UInt8) 引入于:v25.4 +计算两个数组的 Levenshtein 距离。 + **语法** ```sql @@ -1189,12 +1835,12 @@ arrayLevenshteinDistance(from, to) **参数** -- `from` — 第一个数组。 [`Array(T)`](/sql-reference/data-types/array)。 -- `to` — 第二个数组。 [`Array(T)`](/sql-reference/data-types/array)。 +- `from` — 第一个数组。 [`Array(T)`](/sql-reference/data-types/array) +- `to` — 第二个数组。 [`Array(T)`](/sql-reference/data-types/array) **返回值** -第一个数组与第二个数组之间的 Levenshtein 距离。 [`Float64`](/sql-reference/data-types/float)。 +第一个数组和第二个数组之间的 Levenshtein 距离。 [`Float64`](/sql-reference/data-types/float) **示例** @@ -1211,6 +1857,9 @@ SELECT arrayLevenshteinDistance([1, 2, 4], [1, 2, 3]) 引入于:v25.4 +计算两个数组的 Levenshtein 距离,并为每个元素分配自定义权重。 +数组的元素数量和权重应该匹配。 + **语法** ```sql @@ -1219,14 +1868,14 @@ arrayLevenshteinDistanceWeighted(from, to, from_weights, to_weights) **参数** -- `from` — 第一个数组。 [`Array(T)`](/sql-reference/data-types/array)。 -- `to` — 第二个数组。 [`Array(T)`](/sql-reference/data-types/array)。 -- `from_weights` — 第一个数组的权重。 [`Array(Float32)`](/sql-reference/data-types/array)。 -- `to_weights` — 第二个数组的权重。 [`Array(Float32)`](/sql-reference/data-types/array)。 +- `from` — 第一个数组。 [`Array(T)`](/sql-reference/data-types/array) +- `to` — 第二个数组。 [`Array(T)`](/sql-reference/data-types/array) +- `from_weights` — 第一个数组的权重。 [`Array((U)Int*|Float*)`](/sql-reference/data-types/array) +- `to_weights` — 第二个数组的权重。 [`Array((U)Int*|Float*)`](/sql-reference/data-types/array) **返回值** -具有自定义权重的 Levenshtein 距离,第一个数组和第二个数组的每个元素。 [`Float64`](/sql-reference/data-types/float)。 +第一个数组和第二个数组之间带有自定义元素权重的 Levenshtein 距离 [`Float64`](/sql-reference/data-types/float) **示例** @@ -1243,6 +1892,8 @@ SELECT arrayLevenshteinDistanceWeighted(['A', 'B', 'C'], ['A', 'K', 'L'], [1.0, 引入于:v1.1 +返回通过对每个元素应用 lambda 函数得到的数组。 + **语法** ```sql @@ -1251,12 +1902,12 @@ arrayMap(func, arr) **参数** -- `func` — 操作源数组 (`x`) 和条件数组 (`y`) 元素的 lambda 函数。 [Lambda 函数](/sql-reference/functions/overview#arrow-operator-and-lambda)。 -- `arr` — 要处理的 N 个数组。 [Array(T)](/sql-reference/data-types/array)。 +- `func` — 在源数组元素 (`x`) 和条件数组 (`y`) 上操作的 lambda 函数。 [`Lambda 函数`](/sql-reference/functions/overview#arrow-operator-and-lambda) +- `arr` — 要处理的 N 个数组。 [`Array(T)`](/sql-reference/data-types/array) **返回值** -返回 lambda 结果组成的数组。 [`Array(T)`](/sql-reference/data-types/array) +返回由 lambda 结果生成的数组 [`Array(T)`](/sql-reference/data-types/array) **示例** @@ -1267,7 +1918,7 @@ SELECT arrayMap(x -> (x + 2), [1, 2, 3]) as res; ``` ```response title=Response -[3,4,5] +[3, 4, 5] ``` **从不同数组创建元素的元组** @@ -1277,12 +1928,16 @@ SELECT arrayMap((x, y) -> (x, y), [1, 2, 3], [4, 5, 6]) AS res ``` ```response title=Response -[(1,4),(2,5),(3,6)] +[(1, 4),(2, 5),(3, 6)] ``` ## arrayMax {#arrayMax} 引入于:v21.1 +返回源数组中的最大元素。 + +如果指定了 lambda 函数 `func`,则返回 lambda 结果的最大元素。 + **语法** ```sql @@ -1291,13 +1946,13 @@ arrayMax([func(x[, y1, ..., yN])], source_arr[, cond1_arr, ... , condN_arr]) **参数** -- `func(x[, y1, ..., yN])` — 可选。操作源数组 (`x`) 和条件数组 (`y`) 元素的 lambda 函数。 [Lambda 函数](/sql-reference/functions/overview#arrow-operator-and-lambda)。 -- `source_arr` — 要处理的源数组。 [`Array(T)`](/sql-reference/data-types/array)。 -- `[, cond1_arr, ... , condN_arr]` — 可选。提供额外参数给 lambda 函数的 N 个条件数组。 [`Array(T)`](/sql-reference/data-types/array)。 +- `func(x[, y1, ..., yN])` — 可选。在源数组元素 (`x`) 和条件数组 (`y`) 上操作的 lambda 函数。 [`Lambda 函数`](/sql-reference/functions/overview#arrow-operator-and-lambda) +- `source_arr` — 要处理的源数组。 [`Array(T)`](/sql-reference/data-types/array) +- `[, cond1_arr, ... , condN_arr]` — 可选。 N 个条件数组,向 lambda 函数提供附加参数。 [`Array(T)`](/sql-reference/data-types/array) **返回值** -返回源数组中的最大元素,或者如果提供则返回 lambda 结果的最小元素。 +返回源数组中的最大元素,或者如果提供,则返回 lambda 结果中的最大元素。 **示例** @@ -1311,7 +1966,7 @@ SELECT arrayMax([5, 3, 2, 7]); 7 ``` -**与 lambda 函数的用法** +**与 lambda 函数一起使用** ```sql title=Query SELECT arrayMax(x, y -> x/y, [4, 8, 12, 16], [1, 2, 1, 2]); @@ -1324,6 +1979,10 @@ SELECT arrayMax(x, y -> x/y, [4, 8, 12, 16], [1, 2, 1, 2]); 引入于:v21.1 +返回源数组中的最小元素。 + +如果指定了 lambda 函数 `func`,则返回 lambda 结果的最小元素。 + **语法** ```sql @@ -1332,13 +1991,13 @@ arrayMin([func(x[, y1, ..., yN])], source_arr[, cond1_arr, ... , condN_arr]) **参数** -- `func(x[, y1, ..., yN])` — 可选。操作源数组 (`x`) 和条件数组 (`y`) 元素的 lambda 函数。 [Lambda 函数](/sql-reference/functions/overview#arrow-operator-and-lambda)。 -- `source_arr` — 要处理的源数组 [`Array(T)`](/sql-reference/data-types/array)。 -- `[, cond1_arr, ... , condN_arr]` — 可选。提供额外参数给 lambda 函数的 N 个条件数组。 [`Array(T)`](/sql-reference/data-types/array)。 +- `func(x[, y1, ..., yN])` — 可选。在源数组元素 (`x`) 和条件数组 (`y`) 上操作的 lambda 函数。 [`Lambda 函数`](/sql-reference/functions/overview#arrow-operator-and-lambda) +- `source_arr` — 要处理的源数组。 [`Array(T)`](/sql-reference/data-types/array) +- `cond1_arr, ...` — 可选。 N 个条件数组,向 lambda 函数提供附加参数。 [`Array(T)`](/sql-reference/data-types/array) **返回值** -返回源数组中的最小元素,或者如果提供则返回 lambda 结果的最小元素。 +返回源数组中的最小元素,或者如果提供,则返回 lambda 结果中的最小元素。 **示例** @@ -1352,7 +2011,7 @@ SELECT arrayMin([5, 3, 2, 7]); 2 ``` -**与 lambda 函数的用法** +**与 lambda 函数一起使用** ```sql title=Query SELECT arrayMin(x, y -> x/y, [4, 8, 12, 16], [1, 2, 1, 2]); @@ -1365,6 +2024,8 @@ SELECT arrayMin(x, y -> x/y, [4, 8, 12, 16], [1, 2, 1, 2]); 引入于:v25.1 +计算标准化的 Gini 系数。 + **语法** ```sql @@ -1373,12 +2034,12 @@ arrayNormalizedGini(predicted, label) **参数** -- `predicted` — 预测值。 [`Array(T)`](/sql-reference/data-types/array)。 -- `label` — 实际值。 [`Array(T)`](/sql-reference/data-types/array)。 +- `predicted` — 预测值。 [`Array(T)`](/sql-reference/data-types/array) +- `label` — 实际值。 [`Array(T)`](/sql-reference/data-types/array) **返回值** -返回一个元组,包含预测值的 Gini 系数,归一化值的 Gini 系数,和归一化 Gini 系数(= 前两个 Gini 系数的比率)。 [Tuple(Float64, Float64, Float64)](/sql-reference/data-types/tuple)。 +一个包含预测值的 Gini 系数、标准化值的 Gini 系数和标准化 Gini 系数(= 前两个 Gini 系数的比率)的元组 [`Tuple(Float64, Float64, Float64)`](/sql-reference/data-types/tuple) **示例** @@ -1389,12 +2050,18 @@ SELECT arrayNormalizedGini([0.9, 0.3, 0.8, 0.7],[6, 1, 0, 2]); ``` ```response title=Response -(0.18055555555555558,0.2638888888888889,0.6842105263157896) +(0.18055555555555558, 0.2638888888888889, 0.6842105263157896) ``` ## arrayPartialReverseSort {#arrayPartialReverseSort} 引入于:v23.2 +此函数与 `arrayReverseSort` 相同,但增加了一个 `limit` 参数,允许进行部分排序。 + +:::tip +要仅保留已排序的元素,请使用 `arrayResize`。 +::: + **语法** ```sql @@ -1403,14 +2070,14 @@ arrayPartialReverseSort([f,] arr [, arr1, ... ,arrN], limit) **参数** -- `f(arr[, arr1, ... ,arrN])` — 应用于数组 `x` 元素的 lambda 函数。 -- `arr` — 要排序的数组。 [`Array(T)`](/sql-reference/data-types/array)。 -- `arr1, ... ,arrN` — 当 `f` 接受多个参数时的 N 个额外数组。 [`Array(T)`](/sql-reference/data-types/array)。 -- `limit` — 排序将进行的索引值。 [`(U)Int*`](/sql-reference/data-types/int-uint)`] +- `f(arr[, arr1, ... ,arrN])` — 应用于数组 `x` 的元素的 lambda 函数。 [`Lambda 函数`](/sql-reference/functions/overview#arrow-operator-and-lambda) +- `arr` — 要排序的数组。 [`Array(T)`](/sql-reference/data-types/array) +- `arr1, ... ,arrN` — N 个附加数组,适用于 `f` 接受多个参数的情况。 [`Array(T)`](/sql-reference/data-types/array) +- `limit` — 排序将发生的索引值。 [`(U)Int*`](/sql-reference/data-types/int-uint) **返回值** -返回与原始数组大小相同的数组,其中 `[1..limit]` 范围内的元素按降序排序。剩余元素 `(limit..N]` 的顺序不确定。 +返回与原始数组大小相同的数组,其中 `[1..limit]` 范围内的元素按降序排序,其余元素 `(limit..N]` 则按未指定的顺序排列。 **示例** @@ -1421,7 +2088,7 @@ SELECT arrayPartialReverseSort(2, [5, 9, 1, 3]) ``` ```response title=Response -[9,5,1,3] +[9, 5, 1, 3] ``` **simple_string** @@ -1441,7 +2108,7 @@ SELECT arrayResize(arrayPartialReverseSort(2, [5, 9, 1, 3]), 2) ``` ```response title=Response -[9,5] +[9, 5] ``` **lambda_simple** @@ -1451,7 +2118,7 @@ SELECT arrayPartialReverseSort((x) -> -x, 2, [5, 9, 1, 3]) ``` ```response title=Response -[1,3,5,9] +[1, 3, 5, 9] ``` **lambda_complex** @@ -1461,12 +2128,21 @@ SELECT arrayPartialReverseSort((x, y) -> -y, 1, [0, 1, 2], [1, 2, 3]) as res ``` ```response title=Response -[0,1,2] +[0, 1, 2] ``` ## arrayPartialShuffle {#arrayPartialShuffle} 引入于:v23.2 +返回一个与原始数组大小相同的数组,其中 `[1..limit]` 范围内的元素是原始数组的随机子集。剩余的 `(limit..n]` 则包含不在 `[1..limit]` 范围内的元素,顺序未定义。 +`limit` 的值必须在 `[1..n]` 范围内。超出此范围的值相当于执行完整的 `arrayShuffle`: + +:::note +此函数不会使常量物化。 + +`limit` 的值应在 `[1..N]` 范围内。超出此范围的值相当于执行完整的 [`arrayShuffle`](#arrayShuffle)。 +::: + **语法** ```sql @@ -1475,13 +2151,13 @@ arrayPartialShuffle(arr [, limit[, seed]]) **参数** -- `arr` — 要打乱的数组。 [`Array(T)`](/sql-reference/data-types/array)。 -- `seed` — 可选。用于随机数生成的种子。如果未提供,则使用随机值。 [`(U)Int*`](../data-types/int-uint.md)。 -- `limit` — 可选。在范围 `[1..N]` 内限制元素交换的数量。 [`(U)Int*`](../data-types/int-uint.md)。 +- `arr` — 要洗牌的数组。 [`Array(T)`](/sql-reference/data-types/array) +- `seed` — 可选。用于随机数生成的种子。如果未提供,则使用随机值。 [`(U)Int*`](/sql-reference/data-types/array) +- `limit` — 可选。在 `[1..N]` 范围内限制元素交换的数量。 [`(U)Int*`](/sql-reference/data-types/array) **返回值** -部分打乱后的数组。 [`Array(T)`](/sql-reference/data-types/array)。 +包含部分洗牌元素的数组。 [`Array(T)`](/sql-reference/data-types/array) **示例** @@ -1492,7 +2168,7 @@ SELECT arrayPartialShuffle([1, 2, 3, 4], 0) ``` ```response title=Response -[2,4,3,1] +[2, 4, 3, 1] ``` **no_limit2** @@ -1502,7 +2178,7 @@ SELECT arrayPartialShuffle([1, 2, 3, 4]) ``` ```response title=Response -[4,1,3,2] +[4, 1, 3, 2] ``` **random_seed** @@ -1512,7 +2188,7 @@ SELECT arrayPartialShuffle([1, 2, 3, 4], 2) ``` ```response title=Response -[3,4,1,2] +[3, 4, 1, 2] ``` **explicit_seed** @@ -1522,7 +2198,7 @@ SELECT arrayPartialShuffle([1, 2, 3, 4], 2, 41) ``` ```response title=Response -[3,2,1,4] +[3, 2, 1, 4] ``` **materialize** @@ -1549,6 +2225,12 @@ SELECT arrayPartialShuffle(materialize([1, 2, 3, 4]), 2, 42), arrayPartialShuffl 引入于:v23.2 +此函数与 `arraySort` 相同,但增加了一个 `limit` 参数,允许进行部分排序。 + +:::tip +要仅保留已排序的元素,请使用 `arrayResize`。 +::: + **语法** ```sql @@ -1557,14 +2239,14 @@ arrayPartialSort([f,] arr [, arr1, ... ,arrN], limit) **参数** -- `f(arr[, arr1, ... ,arrN])` — 应用于数组 `x` 元素的 lambda 函数。 -- `arr` — 要排序的数组。 [`Array(T)`](/sql-reference/data-types/array)。 -- `arr1, ... ,arrN` — 当 `f` 接受多个参数时的 N 个额外数组。 [`Array(T)`](/sql-reference/data-types/array)。 -- `limit` — 排序将进行的索引值。 [`(U)Int*`](/sql-reference/data-types/int-uint)`] +- `f(arr[, arr1, ... ,arrN])` — 应用于数组 `x` 的元素的 lambda 函数。 [`Lambda 函数`](/sql-reference/functions/overview#arrow-operator-and-lambda) +- `arr` — 要排序的数组。 [`Array(T)`](/sql-reference/data-types/array) +- `arr1, ... ,arrN` — N 个附加数组,适用于 `f` 接受多个参数的情况。 [`Array(T)`](/sql-reference/data-types/array) +- `limit` — 排序将发生的索引值。 [`(U)Int*`](/sql-reference/data-types/int-uint) **返回值** -返回与原始数组大小相同的数组,其中 `[1..limit]` 范围内的元素按升序排序。剩余元素 `(limit..N]` 的顺序不确定。 +返回与原始数组大小相同的数组,其中 `[1..limit]` 范围内的元素按升序排序,其余元素 `(limit..N]` 则按未指定的顺序排列。 **示例** @@ -1575,17 +2257,17 @@ SELECT arrayPartialSort(2, [5, 9, 1, 3]) ``` ```response title=Response -[1,3,5,9] +[1, 3, 5, 9] ``` **simple_string** ```sql title=Query -SELECT arrayPartialSort(2, ['expenses','lasso','embolism','gladly']) +SELECT arrayPartialSort(2, ['expenses', 'lasso', 'embolism', 'gladly']) ``` ```response title=Response -['embolism','expenses','gladly','lasso'] +['embolism', 'expenses', 'gladly', 'lasso'] ``` **retain_sorted** @@ -1595,7 +2277,7 @@ SELECT arrayResize(arrayPartialSort(2, [5, 9, 1, 3]), 2) ``` ```response title=Response -[1,3] +[1, 3] ``` **lambda_simple** @@ -1605,7 +2287,7 @@ SELECT arrayPartialSort((x) -> -x, 2, [5, 9, 1, 3]) ``` ```response title=Response -[9,5,1,3] +[9, 5, 1, 3] ``` **lambda_complex** @@ -1615,12 +2297,14 @@ SELECT arrayPartialSort((x, y) -> -y, 1, [0, 1, 2], [1, 2, 3]) as res ``` ```response title=Response -[2,1,0] +[2, 1, 0] ``` ## arrayPopBack {#arrayPopBack} 引入于:v1.1 +从数组中删除最后一个元素。 + **语法** ```sql @@ -1629,11 +2313,11 @@ arrayPopBack(arr) **参数** -- `arr` — 要移除最后一个元素的数组。 [`Array(T)`](/sql-reference/data-types/array)。 +- `arr` — 要从中删除最后一个元素的数组。 [`Array(T)`](/sql-reference/data-types/array) **返回值** -返回与 `arr` 相同但最后一个元素被移除的数组。 [`Array(T)`](/sql-reference/data-types/array)。 +返回一个与 `arr` 相同但没有最后一个元素的数组 [`Array(T)`](/sql-reference/data-types/array) **示例** @@ -1644,12 +2328,14 @@ SELECT arrayPopBack([1, 2, 3]) AS res; ``` ```response title=Response -[1,2] +[1, 2] ``` ## arrayPopFront {#arrayPopFront} 引入于:v1.1 +从数组中删除第一个元素。 + **语法** ```sql @@ -1658,11 +2344,11 @@ arrayPopFront(arr) **参数** -- `arr` — 要移除第一个元素的数组。 [`Array(T)`](/sql-reference/data-types/array)。 +- `arr` — 要从中删除第一个元素的数组。 [`Array(T)`](/sql-reference/data-types/array) **返回值** -返回与 `arr` 相同但第一个元素被移除的数组。 [`Array(T)`](/sql-reference/data-types/array)。 +返回一个与 `arr` 相同但没有第一个元素的数组 [`Array(T)`](/sql-reference/data-types/array) **示例** @@ -1673,12 +2359,16 @@ SELECT arrayPopFront([1, 2, 3]) AS res; ``` ```response title=Response -[2,3] +[2, 3] ``` ## arrayProduct {#arrayProduct} 引入于:v21.1 +返回源数组中元素的乘积。 + +如果指定了 lambda 函数 `func`,则返回 lambda 结果的乘积。 + **语法** ```sql @@ -1687,13 +2377,13 @@ arrayProduct([func(x[, y1, ..., yN])], source_arr[, cond1_arr, ... , condN_arr]) **参数** -- `func(x[, y1, ..., yN])` — 可选。操作源数组 (`x`) 和条件数组 (`y`) 元素的 lambda 函数。 [Lambda 函数](/sql-reference/functions/overview#arrow-operator-and-lambda)。 -- `source_arr` — 要处理的源数组 [`Array(T)`](/sql-reference/data-types/array)。 -- `[, cond1_arr, ... , condN_arr]` — 可选。提供额外参数给 lambda 函数的 N 个条件数组。 [`Array(T)`](/sql-reference/data-types/array)。 +- `func(x[, y1, ..., yN])` — 可选。在源数组元素 (`x`) 和条件数组 (`y`) 上操作的 lambda 函数。 [`Lambda 函数`](/sql-reference/functions/overview#arrow-operator-and-lambda) +- `source_arr` — 要处理的源数组。 [`Array(T)`](/sql-reference/data-types/array) +- `[, cond1_arr, ... , condN_arr]` — 可选。 N 个条件数组,向 lambda 函数提供附加参数。 [`Array(T)`](/sql-reference/data-types/array) **返回值** -返回源数组中元素的乘积,或者如果提供则返回 lambda 结果的乘积。 [`Float64`](/sql-reference/data-types/float)。 +返回源数组中的元素乘积,或者如果提供,则返回 lambda 结果中的乘积。 [`Float64`](/sql-reference/data-types/float) **示例** @@ -1707,7 +2397,7 @@ SELECT arrayProduct([1, 2, 3, 4]); 24 ``` -**与 lambda 函数的用法** +**与 lambda 函数一起使用** ```sql title=Query SELECT arrayProduct(x, y -> x+y, [2, 2], [2, 2]) AS res; @@ -1720,6 +2410,8 @@ SELECT arrayProduct(x, y -> x+y, [2, 2], [2, 2]) AS res; 引入于:v1.1 +在数组末尾添加一个项。 + **语法** ```sql @@ -1728,22 +2420,21 @@ arrayPushBack(arr, x) **参数** -- `arr` — 要在其末尾添加值 `x` 的数组。 [`Array(T)`](/sql-reference/data-types/array)。 +- `arr` — 要在其末尾添加值 `x` 的数组。 [`Array(T)`](/sql-reference/data-types/array) - `x` — -- 要添加到数组末尾的单个值。 [`Array(T)`](/sql-reference/data-types/array)。 +- 添加到数组末尾的单个值。 [`Array(T)`](/sql-reference/data-types/array) :::note -- 仅数字可以添加到数字数组中,且仅字符串可以添加到字符串数组中。 -- 在添加数字时,ClickHouse 会自动将 `x` 的类型设置为数组的数据类型。 -- 可以为 `NULL`。该函数将 `NULL` 元素添加到数组,并且数组元素的类型将转换为 `Nullable`。 +- 只能将数字添加到数字数组,且只能将字符串添加到字符串数组。 +- 添加数字时,ClickHouse 会自动为 `x` 设置与数组的数据类型相符的类型。 +- 可以是 `NULL`。该函数将 `NULL` 元素添加到数组,数组元素的类型转换为 `Nullable`。 有关 ClickHouse 中数据类型的更多信息,请参见 [数据类型](/sql-reference/data-types)。 ::: - **返回值** -返回与 `arr` 相同的数组,但在数组末尾附加了一个值 `x`。 [`Array(T)`](/sql-reference/data-types/array)。 +返回与 `arr` 相同,但在数组末尾额外添加了值 `x` 的数组 [`Array(T)`](/sql-reference/data-types/array) **示例** @@ -1760,6 +2451,8 @@ SELECT arrayPushBack(['a'], 'b') AS res; 引入于:v1.1 +在数组开头添加一个元素。 + **语法** ```sql @@ -1768,22 +2461,21 @@ arrayPushFront(arr, x) **参数** -- `arr` — 要在其前面添加值 `x` 的数组。 [`Array(T)`](/sql-reference/data-types/array)。 +- `arr` — 要在其开头添加值 `x` 的数组。 [`Array(T)`](/sql-reference/data-types/array) - `x` — -- 要添加到数组开头的单个值。 [`Array(T)`](/sql-reference/data-types/array)。 +- 添加到数组开头的单个值。 [`Array(T)`](/sql-reference/data-types/array) :::note -- 仅数字可以添加到数字数组中,且仅字符串可以添加到字符串数组中。 -- 在添加数字时,ClickHouse 会自动将 `x` 的类型设置为数组的数据类型。 -- 可以为 `NULL`。该函数将 `NULL` 元素添加到数组,并且数组元素的类型将转换为 `Nullable`。 +- 只能将数字添加到数字数组,且只能将字符串添加到字符串数组。 +- 添加数字时,ClickHouse 会自动为 `x` 设置与数组的数据类型相符的类型。 +- 可以是 `NULL`。该函数将 `NULL` 元素添加到数组,数组元素的类型转换为 `Nullable`。 有关 ClickHouse 中数据类型的更多信息,请参见 [数据类型](/sql-reference/data-types)。 ::: - **返回值** -返回与 `arr` 相同的数组,但在数组开头附加了一个值 `x`。 [`Array(T)`](/sql-reference/data-types/array)。 +返回与 `arr` 相同,但在数组开头额外添加了值 `x` 的数组 [`Array(T)`](/sql-reference/data-types/array) **示例** @@ -1800,6 +2492,13 @@ SELECT arrayPushFront(['b'], 'a') AS res; 引入于:v20.4 +计算接收者操作特征(ROC)曲线下的面积。 +ROC 曲线通过在 y 轴上绘制真正率(TPR)和在 x 轴上绘制假正率(FPR)来创建,涵盖所有阈值。 +结果值范围从零到一,值越高表示模型性能越好。 + +ROC AUC(也称为 AUC)是机器学习中的一个概念。 +更多详细信息,请参见 [这里](https://developers.google.com/machine-learning/glossary#pr-auc-area-under-the-pr-curve), [这里](https://developers.google.com/machine-learning/crash-course/classification/roc-and-auc#expandable-1) 和 [这里](https://en.wikipedia.org/wiki/Receiver_operating_characteristic#Area_under_the_curve)。 + **语法** ```sql @@ -1808,28 +2507,27 @@ arrayROCAUC(scores, labels[, scale[, partial_offsets]]) **参数** -- `scores` — 模型提供的评分预测。 [`Array(T)`](/sql-reference/data-types/array) 的 [整数](../data-types/int-uint.md) 或 [浮点数](../data-types/float.md)。 -- `labels` — 样本的标签,通常为正样本的 1 和负样本的 0。 [Array](/sql-reference/data-types/array) 的 [整数](../data-types/int-uint.md) 或 [枚举](../data-types/enum.md)。 -- `scale` — 决定是否返回归一化区域。如果为 false,则返回 TP(真阳性) x FP(假阳性)曲线下的区域。默认值: true。 [Bool](../data-types/boolean.md)。可选。 +- `scores` — 预测模型的分数。 [`Array((U)Int*)`](/sql-reference/data-types/array) 或 [`Array(Float*)`](/sql-reference/data-types/array) +- `labels` — 样本的标签,通常对于正样本为 1,对于负样本为 0。 [`Array((U)Int*)`](/sql-reference/data-types/array) 或 [`Enum`](/sql-reference/data-types/enum) +- `scale` — 可选。决定是否返回标准化面积。如果为 false,则返回 TP(真正例)x FP(假正例)曲线下的面积。默认值:true。 [`Bool`](/sql-reference/data-types/boolean) - `partial_offsets` — -- 用于计算 ROC 曲线下部分区域的四个非负整数数组(相当于 ROC 空间的垂直带),而不是整个 AUC。此选项对 ROC AUC 的分布式计算很有用。数组必须包含以下元素 [`higher_partitions_tp`, `higher_partitions_fp`, `total_positives`, `total_negatives`]。 [Array](/sql-reference/data-types/array) 的非负 [整数](../data-types/int-uint.md)。可选。 - - `higher_partitions_tp`: 在高分分区中正标签的数量。 - - `higher_partitions_fp`: 在高分分区中负标签的数量。 - - `total_positives`: 整个数据集中正样本的总数。 - - `total_negatives`: 整个数据集中负样本的总数。 +- 一个包含四个非负整数的数组,用于计算部分 ROC 曲线下的面积(相当于 ROC 空间中的垂直带),而不是整个 AUC。此选项对 ROC AUC 的分布式计算非常有用。数组必须包含以下元素 [`higher_partitions_tp`, `higher_partitions_fp`, `total_positives`, `total_negatives`]。 [Array](/sql-reference/data-types/array) 的非负 [整型](../data-types/int-uint.md)。可选。 + - `higher_partitions_tp`:在分数较高的分区中的正标签数量。 + - `higher_partitions_fp`:在分数较高的分区中的负标签数量。 + - `total_positives`:整个数据集中正样本的总数。 + - `total_negatives`:整个数据集中负样本的总数。 ::::note -当使用 `arr_partial_offsets` 时,`arr_scores` 与 `arr_labels` 应仅为整个数据集的一个分区,包含一个分数区间。 -数据集应被划分为连续的分区,每个分区包含分数落在特定范围内的数据子集。 +使用 `arr_partial_offsets` 时,`arr_scores` 和 `arr_labels` 应仅为整个数据集的一部分,包含一段分数的区间。 +数据集应被划分为连续分区,每个分区包含分数在特定范围内的数据子集。 例如: -- 一个分区可以包含所有在范围 [0, 0.5) 的分数。 -- 另一个分区可以包含范围 [0.5, 1.0] 的分数。 +- 一个分区可以包含所有分数在 [0, 0.5) 范围内的样本。 +- 另一个分区可以包含分数在 [0.5, 1.0] 范围内的样本。 :::: - **返回值** -返回受试者工作特征 (ROC) 曲线下的区域。 [Float64](../data-types/float.md)。 +返回 ROC 曲线下的面积。 [`Float64`](/sql-reference/data-types/float) **示例** @@ -1844,7 +2542,9 @@ SELECT arrayROCAUC([0.1, 0.4, 0.35, 0.8], [0, 0, 1, 1]); ``` ## arrayRandomSample {#arrayRandomSample} -引入时间:v23.10 +引入于:v23.10 + +返回包含 `samples` 个随机元素的子集。如果 `samples` 超过输入数组的大小,则样本大小限制为数组的大小,即返回所有数组元素,但其顺序不保证。该函数可以处理平面数组和嵌套数组。 **语法** @@ -1854,12 +2554,12 @@ arrayRandomSample(arr, samples) **参数** -- `arr` — 输入数组或多维数组,以从中抽样元素。 ([`Array(T)`](/sql-reference/data-types/array)). -- `samples` — 随机样本中包含的元素数量 ([`(U)Int*`](../data-types/int-uint.md)). +- `arr` — 要从中抽取元素的输入数组或多维数组。 [`Array(T)`](/sql-reference/data-types/array) +- `samples` — 要包含在随机样本中的元素个数。 [`(U)Int*`](/sql-reference/data-types/int-uint) **返回值** -返回一个包含输入数组中元素的随机样本的数组。 [`Array(T)`](/sql-reference/data-types/array). +包含输入数组随机样本的数组 [`Array(T)`](/sql-reference/data-types/array) **示例** @@ -1884,18 +2584,22 @@ SELECT arrayRandomSample([[1, 2], [3, 4], [5, 6]], 2) as res; ``` ## arrayReduce {#arrayReduce} -引入时间:v1.1 +引入于:v1.1 + +对数组元素应用聚合函数并返回其结果。 +聚合函数的名称作为字符串传入,使用单引号引起来,例如 `'max'`、`'sum'`。 +在使用参数化聚合函数时,参数在函数名称后用括号表示 `'uniqUpTo(6)'`。 **语法** ```sql -arrayReduce(agg_f, arr1 [, arr2, ... , arrN)] +arrayReduce(agg_f, arr1 [, arr2, ... , arrN)]) ``` **参数** -- `agg_f` — 需要为一个常量的聚合函数的名称 [String](/sql-reference/data-types/string). -- `arr1 [, arr2, ... , arrN)]` — N 个数组,对应于 `agg_f` 的参数。 [`Array(T)`](/sql-reference/data-types/array). +- `agg_f` — 应为常量的聚合函数名称。 [`String`](/sql-reference/data-types/string) +- `arr1 [, arr2, ... , arrN]` — N 个数组,作为 `agg_f` 的参数。 [`Array(T)`](/sql-reference/data-types/array) **返回值** @@ -1915,15 +2619,13 @@ SELECT arrayReduce('max', [1, 2, 3]); └───────────────────────────────┘ ``` -**使用多个参数的聚合函数示例** +**使用多个参数的聚合函数的示例** ```sql title=Query -If an aggregate function takes multiple arguments, then this function must be applied to multiple arrays of the same size. +--If an aggregate function takes multiple arguments, then this function must be applied to multiple arrays of the same size. -```sql SELECT arrayReduce('maxIf', [3, 5], [1, 0]); ``` -``` ```response title=Response ┌─arrayReduce('maxIf', [3, 5], [1, 0])─┐ @@ -1944,23 +2646,26 @@ SELECT arrayReduce('uniqUpTo(3)', [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); ``` ## arrayReduceInRanges {#arrayReduceInRanges} -引入时间:v20.4 +引入于:v20.4 + +对给定范围内的数组元素应用聚合函数,并返回包含每个范围对应结果的数组。 +该函数将返回与多个 `arrayReduce(agg_func, arraySlice(arr1, index, length), ...)` 相同的结果。 **语法** ```sql -arrayReduceInRanges(agg_f, ranges, arr1 [, arr2, ... ,arrN)] +arrayReduceInRanges(agg_f, ranges, arr1 [, arr2, ... ,arrN)]) ``` **参数** -- `agg_f` — 要使用的聚合函数的名称。 [String](/sql-reference/data-types/string) -- `ranges` — 聚合的范围。一个包含元组的数组 `(i, r)`,包含从 `i` 开始的索引和聚合的范围 `r`,[`Array(T)`](/sql-reference/data-types/array)([`Tuple(T1, T2, ...)`](/sql-reference/data-types/tuple)) -- `arr1 [, arr2, ... ,arrN)]` — 作为聚合函数参数的 N 个数组。 [`Array(T)`](/sql-reference/data-types/array). +- `agg_f` — 要使用的聚合函数名称。 [`String`](/sql-reference/data-types/string) +- `ranges` — 聚合的范围。一个包含起始索引 `i` 和聚合范围 `r` 的元组数组 `(i, r)`。 [`Array(T)`](/sql-reference/data-types/array) 或 [`Tuple(T)`](/sql-reference/data-types/tuple) +- `arr1 [, arr2, ... ,arrN]` — 作为聚合函数参数的 N 个数组。 [`Array(T)`](/sql-reference/data-types/array) **返回值** -返回一个包含在指定范围内的聚合函数结果的数组。 [`Array(T)`](/sql-reference/data-types/array). +返回包含指定范围内聚合函数结果的数组 [`Array(T)`](/sql-reference/data-types/array) **示例** @@ -1981,7 +2686,9 @@ SELECT arrayReduceInRanges( ``` ## arrayResize {#arrayResize} -引入时间:v1.1 +引入于:v1.1 + +更改数组的长度。 **语法** @@ -1991,17 +2698,16 @@ arrayResize(arr, size[, extender]) **参数** -- `arr` — 要调整大小的数组。 [Array(T)](/sql-reference/data-types/array) +- `arr` — 要调整大小的数组。 [`Array(T)`](/sql-reference/data-types/array) - `size` — -- 新数组的长度。 -如果 `size` 小于原始数组的大小,则数组将从右侧截断。 -如果 `size` 大于数组的初始大小,则数组将向右扩展,并使用 `extender` 值或数组项的数据类型的默认值。 - +- 新的数组长度。 +如果 `size` 小于数组的原始大小,则数组从右侧截断。 +如果 `size` 大于数组的初始大小,则数组向右扩展,使用 `extender` 值或数组项数据类型的默认值。 - `extender` — 用于扩展数组的值。可以是 `NULL`。 **返回值** -长度为 `size` 的数组。 [Array(T)](/sql-reference/data-types/array). +长度为 `size` 的数组。 [`Array(T)`](/sql-reference/data-types/array) **示例** @@ -2026,7 +2732,13 @@ SELECT arrayResize([1], 3, NULL); ``` ## arrayReverse {#arrayReverse} -引入时间:v1.1 +引入于:v1.1 + +反转给定数组的元素顺序。 + +:::note +函数 `reverse(arr)` 执行相同的功能,但还适用于其他数据类型,除了数组。 +::: **语法** @@ -2036,11 +2748,11 @@ arrayReverse(arr) **参数** -- `arr` — 要反转的数组。 [`Array(T)`](/sql-reference/data-types/array). +- `arr` — 要反转的数组。 [`Array(T)`](/sql-reference/data-types/array) **返回值** -返回与原数组大小相同的数组,元素顺序已反转。 [`Array(T)`](/sql-reference/data-types/array). +返回与原始数组大小相同并且顺序反转的数组 [`Array(T)`](/sql-reference/data-types/array) **示例** @@ -2055,7 +2767,9 @@ SELECT arrayReverse([1, 2, 3]) ``` ## arrayReverseFill {#arrayReverseFill} -引入时间:v20.1 +引入于:v20.1 + +`arrayReverseFill` 函数按照顺序处理源数组,从最后一个元素处理到第一个元素,在每个位置使用源数组和条件数组中的元素评估 lambda 条件。当条件在位置 i 处评估为 false 时,该函数用当前数组状态中位置 i+1 的元素替换该元素。最后一个元素始终被保留,无论条件如何。 **语法** @@ -2065,38 +2779,51 @@ arrayReverseFill(func(x[, y1, ..., yN]), source_arr[, cond1_arr, ... , condN_arr **参数** -- `func(x[, y1, ..., yN])` — 一个在源数组的元素 (`x`) 和条件数组 (`y`) 上进行操作的 lambda 函数。 [Lambda function](/sql-reference/functions/overview#arrow-operator-and-lambda). -- `source_arr` — 要处理的源数组 [`Array(T)`](/sql-reference/data-types/array). -- `[, cond1_arr, ... , condN_arr]` — 可选。 N 个条件数组,为 lambda 函数提供额外的参数。 [`Array(T)`](/sql-reference/data-types/array). +- `func(x[, y1, ..., yN])` — 在源数组元素 (`x`) 和条件数组 (`y`) 上操作的 lambda 函数。 [`Lambda 函数`](/sql-reference/functions/overview#arrow-operator-and-lambda) +- `source_arr` — 要处理的源数组。 [`Array(T)`](/sql-reference/data-types/array) +- `[, cond1_arr, ... , condN_arr]` — 可选。 N 个条件数组,向 lambda 函数提供附加参数。 [`Array(T)`](/sql-reference/data-types/array) **返回值** -返回一个数组,其元素由 lambda 的结果替换了源数组的元素。 [`Array(T)`](/sql-reference/data-types/array). +返回一个用 lambda 结果替换源数组元素的数组。 [`Array(T)`](/sql-reference/data-types/array) **示例** -**使用单个数组的示例** +**单数组示例** ```sql title=Query SELECT arrayReverseFill(x -> not isNull(x), [1, null, 2, null]) AS res ``` ```response title=Response -[1,2,2,NULL] +[1, 2, 2, NULL] ``` -**使用两个数组的示例** +**两个数组的示例** ```sql title=Query SELECT arrayReverseFill(x, y, z -> x > y AND x < z, [5, 3, 6, 2], [4, 7, 1, 3], [10, 2, 8, 5]) AS res; ``` ```response title=Response -[5,6,6,2] +[5, 6, 6, 2] ``` ## arrayReverseSort {#arrayReverseSort} -引入时间:v1.1 +引入于:v1.1 + +按降序对数组元素进行排序。 +如果指定了函数 `f`,则提供的数组将根据应用于数组元素的函数结果排序,然后再反转排序后的数组。 +如果 `f` 接受多个参数,则 `arrayReverseSort` 函数将传递多个数组,`func` 的参数与这些数组相对应。 + +如果要排序的数组包含 `-Inf`、`NULL`、`NaN` 或 `Inf`,则它们将按以下顺序排序: + +1. `-Inf` +2. `Inf` +3. `NaN` +4. `NULL` + +`arrayReverseSort` 是一个 [高阶函数](/sql-reference/functions/overview#higher-order-functions)。 **语法** @@ -2106,13 +2833,13 @@ arrayReverseSort([f,] arr [, arr1, ... ,arrN) **参数** -- `f(y1[, y2 ... yN])` — 要应用于数组 `x` 元素的 lambda 函数。 +- `f(y1[, y2 ... yN])` — 应用于数组 `x` 的元素的 lambda 函数。 - `arr` — 要排序的数组。 [`Array(T)`](/sql-reference/data-types/array) -- `arr1, ..., yN` — 可选。当 `f` 接受多个参数时,N 个额外数组。 +- `arr1, ..., yN` — 可选。在 `f` 接受多个参数的情况下的 N 个附加数组。 **返回值** -如果未提供 lambda 函数,则返回按降序排列的数组 `x`,否则返回根据提供的 lambda 函数逻辑排序后再反转的数组。 [`Array(T)`](/sql-reference/data-types/array). +如果没有提供 lambda 函数,则返回按降序排序的数组 `x`,否则返回根据提供的 lambda 函数逻辑排序的数组,然后再反转。 [`Array(T)`](/sql-reference/data-types/array)。 **示例** @@ -2137,7 +2864,9 @@ SELECT arrayReverseSort((x, y) -> -y, [4, 3, 5], [1, 2, 3]) AS res; ``` ## arrayReverseSplit {#arrayReverseSplit} -引入时间:v20.1 +引入于:v20.1 + +将源数组拆分为多个数组。当 `func(x[, y1, ..., yN])` 返回非零值时,数组将在该元素的右侧拆分。数组不会在最后一个元素之后拆分。 **语法** @@ -2147,13 +2876,13 @@ arrayReverseSplit(func(x[, y1, ..., yN]), source_arr[, cond1_arr, ... , condN_ar **参数** -- `func(x[, y1, ..., yN])` — 一个在源数组的元素 (`x`) 和条件数组 (`y`) 上进行操作的 lambda 函数。 [Lambda function](/sql-reference/functions/overview#arrow-operator-and-lambda). -- `source_arr` — 要处理的源数组。 [`Array(T)`](/sql-reference/data-types/array). -- `[, cond1_arr, ... , condN_arr]` — 可选。 N 个条件数组,为 lambda 函数提供额外的参数。 [`Array(T)`](/sql-reference/data-types/array). +- `func(x[, y1, ..., yN])` — 在源数组元素 (`x`) 和条件数组 (`y`) 上操作的 lambda 函数。 [`Lambda 函数`](/sql-reference/functions/overview#arrow-operator-and-lambda) +- `source_arr` — 要处理的源数组。 [`Lambda 函数`](/sql-reference/functions/overview#arrow-operator-and-lambda) +- `[, cond1_arr, ... , condN_arr]` — 可选。 N 个条件数组,向 lambda 函数提供附加参数。 [`Array(T)`](/sql-reference/data-types/array) **返回值** -返回一个数组的数组。 [`Array(Array(T))`](/sql-reference/data-types/array). +返回一个数组的数组。 [`Array(Array(T))`](/sql-reference/data-types/array) **示例** @@ -2168,7 +2897,9 @@ SELECT arrayReverseSplit((x, y) -> y, [1, 2, 3, 4, 5], [1, 0, 0, 1, 0]) AS res ``` ## arrayRotateLeft {#arrayRotateLeft} -引入时间:v23.8 +引入于:v23.8 + +将数组向左旋转指定数量的元素。`n` 的负值视为按绝对旋转值向右旋转。 **语法** @@ -2178,12 +2909,12 @@ arrayRotateLeft(arr, n) **参数** -- `arr` — 要旋转元素的数组。[`Array(T)`](/sql-reference/data-types/array). -- `n` — 旋转的元素数量。 [`(U)Int8/16/32/64`](/sql-reference/data-types/int-uint). +- `arr` — 要旋转元素的数组。 [`Array(T)`](/sql-reference/data-types/array) +- `n` — 要旋转的元素数量。 [`(U)Int8/16/32/64`](/sql-reference/data-types/int-uint) **返回值** -一个向左旋转指定数量元素的数组。 [`Array(T)`](/sql-reference/data-types/array). +向左旋转指定数量的元素的数组 [`Array(T)`](/sql-reference/data-types/array) **示例** @@ -2208,7 +2939,9 @@ SELECT arrayRotateLeft([1,2,3,4,5,6], -2) as res; ``` ## arrayRotateRight {#arrayRotateRight} -引入时间:v23.8 +引入于:v23.8 + +将数组向右旋转指定数量的元素。`n` 的负值视为按绝对旋转值向左旋转。 **语法** @@ -2218,12 +2951,12 @@ arrayRotateRight(arr, n) **参数** -- `arr` — 要旋转元素的数组。[`Array(T)`](/sql-reference/data-types/array). -- `n` — 旋转的元素数量。 [`(U)Int8/16/32/64`](/sql-reference/data-types/int-uint). +- `arr` — 要旋转元素的数组。 [`Array(T)`](/sql-reference/data-types/array) +- `n` — 要旋转的元素数量。 [`(U)Int8/16/32/64`](/sql-reference/data-types/int-uint) **返回值** -一个向右旋转指定数量元素的数组。 [`Array(T)`](/sql-reference/data-types/array). +向右旋转指定数量的元素的数组 [`Array(T)`](/sql-reference/data-types/array) **示例** @@ -2246,10 +2979,15 @@ SELECT arrayRotateRight([1,2,3,4,5,6], -2) as res; ```response title=Response [3,4,5,6,1,2] ``` + ## arrayShiftLeft {#arrayShiftLeft} -引入时间:v23.8 +引入版本:v23.8 +将数组向左移动指定数量的元素。 +新元素使用提供的参数或数组元素类型的默认值填充。 +如果元素数量为负,数组将向右移动。 + **语法** ```sql @@ -2258,13 +2996,13 @@ arrayShiftLeft(arr, n[, default]) **参数** -- `arr` — 要移动元素的数组。[`Array(T)`](/sql-reference/data-types/array). -- `n` — 要移动的元素数量。[`(U)Int8/16/32/64`](/sql-reference/data-types/int-uint). -- `default` — 可选。新元素的默认值。 +- `arr` — 要移动元素的数组。[`Array(T)`](/sql-reference/data-types/array) +- `n` — 要移动的元素数量。[`(U)Int8/16/32/64`](/sql-reference/data-types/int-uint) +- `default` — 可选。新元素的默认值。 **返回值** -一个向左移动指定数量元素的数组。 [`Array(T)`](/sql-reference/data-types/array). +一个向左移动指定数量元素的数组 [`Array(T)`](/sql-reference/data-types/array) **示例** @@ -2278,7 +3016,7 @@ SELECT arrayShiftLeft([1,2,3,4,5,6], 2) as res; [3,4,5,6,0,0] ``` -**n 的负值** +**n的负值** ```sql title=Query SELECT arrayShiftLeft([1,2,3,4,5,6], -2) as res; @@ -2297,10 +3035,15 @@ SELECT arrayShiftLeft([1,2,3,4,5,6], 2, 42) as res; ```response title=Response [3,4,5,6,42,42] ``` + ## arrayShiftRight {#arrayShiftRight} -引入时间:v23.8 +引入版本:v23.8 +将数组向右移动指定数量的元素。 +新元素使用提供的参数或数组元素类型的默认值填充。 +如果元素数量为负,数组将向左移动。 + **语法** ```sql @@ -2309,48 +3052,51 @@ arrayShiftRight(arr, n[, default]) **参数** -- `arr` — 要移动元素的数组。 [`Array(T)`](/sql-reference/data-types/array). -- `n` — 要移动的元素数量。 [`(U)Int8/16/32/64`](/sql-reference/data-types/int-uint). -- `default` — 可选。新元素的默认值。 +- `arr` — 要移动元素的数组。[`Array(T)`](/sql-reference/data-types/array) +- `n` — 要移动的元素数量。[`(U)Int8/16/32/64`](/sql-reference/data-types/int-uint) +- `default` — 可选。新元素的默认值。 **返回值** -一个向右移动指定数量元素的数组。 [`Array(T)`](/sql-reference/data-types/array). +一个向右移动指定数量元素的数组 [`Array(T)`](/sql-reference/data-types/array) **示例** **用法示例** ```sql title=Query -SELECT arrayShiftRight([1,2,3,4,5,6], 2) as res; +SELECT arrayShiftRight([1, 2, 3, 4, 5, 6], 2) as res; ``` ```response title=Response -[0,0,1,2,3,4] +[0, 0, 1, 2, 3, 4] ``` -**n 的负值** +**n的负值** ```sql title=Query -SELECT arrayShiftRight([1,2,3,4,5,6], -2) as res; +SELECT arrayShiftRight([1, 2, 3, 4, 5, 6], -2) as res; ``` ```response title=Response -[3,4,5,6,0,0] +[3, 4, 5, 6, 0, 0] ``` **使用默认值** ```sql title=Query -SELECT arrayShiftRight([1,2,3,4,5,6], 2, 42) as res; +SELECT arrayShiftRight([1, 2, 3, 4, 5, 6], 2, 42) as res; ``` ```response title=Response -[42,42,1,2,3,4] +[42, 42, 1, 2, 3, 4] ``` + ## arrayShingles {#arrayShingles} -引入时间:v24.1 +引入版本:v24.1 + +生成一个 shingles 数组(类似于字符串的 ngrams),即输入数组的指定长度的连续子数组。 **语法** @@ -2360,28 +3106,36 @@ arrayShingles(arr, l) **参数** -- `arr` — 要生成 shingles 的数组。 [`Array(T)`](/sql-reference/data-types/array). -- `l` — 每个 shingle 的长度。 [`(U)Int*`](/sql-reference/data-types/int-uint) +- `arr` — 要生成 shingles 数组的数组。[`Array(T)`](/sql-reference/data-types/array) +- `l` — 每个 shingle 的长度。[`(U)Int*`](/sql-reference/data-types/int-uint) **返回值** -生成的 shingles 数组。 [`Array(T)`](/sql-reference/data-types/array) +生成的 shingles 数组 [`Array(T)`](/sql-reference/data-types/array) **示例** **用法示例** ```sql title=Query -SELECT arrayShingles([1,2,3,4], 3) as res; +SELECT arrayShingles([1, 2, 3, 4], 3) as res; ``` ```response title=Response -[[1,2,3],[2,3,4]] +[[1, 2, 3], [2, 3, 4]] ``` + ## arrayShuffle {#arrayShuffle} -引入时间:v23.2 +引入版本:v23.2 +返回一个与原数组大小相同的数组,包含随机顺序的元素。 +元素的重新排序使得这些元素的每种可能排列出现的概率相等。 + +:::note +此函数将不会物化常量。 +::: + **语法** ```sql @@ -2390,16 +3144,16 @@ arrayShuffle(arr [, seed]) **参数** -- `arr` — 要打乱的数组。 [`Array(T)`](/sql-reference/data-types/array). -- `seed (可选)` — 可选。与随机数生成一起使用的种子。如果未提供,则使用随机种子。 [`(U)Int*`](../data-types/int-uint.md). +- `arr` — 要打乱的数组。[`Array(T)`](/sql-reference/data-types/array) +- `seed (可选)` — 可选。用于随机数生成的种子。如果未提供,则使用随机值。[`(U)Int*`](/sql-reference/data-types/int-uint) **返回值** -打乱元素的数组。 [`Array(T)`](/sql-reference/data-types/array). +打乱元素的数组 [`Array(T)`](/sql-reference/data-types/array) **示例** -**没有种子的示例(不稳定的结果)** +**没有种子的例子(不稳定结果)** ```sql title=Query SELECT arrayShuffle([1, 2, 3, 4]); @@ -2409,7 +3163,7 @@ SELECT arrayShuffle([1, 2, 3, 4]); [1,4,2,3] ``` -**没有种子的示例(稳定的结果)** +**没有种子的例子(稳定结果)** ```sql title=Query SELECT arrayShuffle([1, 2, 3, 4], 41); @@ -2418,9 +3172,12 @@ SELECT arrayShuffle([1, 2, 3, 4], 41); ```response title=Response [3,2,1,4] ``` + ## arraySimilarity {#arraySimilarity} -引入时间:v25.4 +引入版本:v25.4 + +基于加权的 Levenshtein 距离计算两个数组之间的相似度,范围从 `0` 到 `1`。 **语法** @@ -2430,14 +3187,14 @@ arraySimilarity(from, to, from_weights, to_weights) **参数** -- `from` — 第一个数组 -- `to` — 第二个数组 -- `from_weights` — 第一个数组的权重 -- `to_weights` — 第二个数组的权重 +- `from` — 第一个数组 [`Array(T)`](/sql-reference/data-types/array) +- `to` — 第二个数组 [`Array(T)`](/sql-reference/data-types/array) +- `from_weights` — 第一个数组的权重。 [`Array((U)Int*|Float*)`](/sql-reference/data-types/array) +- `to_weights` — 第二个数组的权重。 [`Array((U)Int*|Float*)`](/sql-reference/data-types/array) **返回值** -返回两个数组之间的相似度,值在 `0` 和 `1` 之间,基于加权的 Levenshtein 距离。 [`Float64`](/sql-reference/data-types/float). +返回基于加权 Levenshtein 距离的两个数组之间的相似度,范围从 `0` 到 `1` [`Float64`](/sql-reference/data-types/float) **示例** @@ -2450,9 +3207,12 @@ SELECT arraySimilarity(['A', 'B', 'C'], ['A', 'K', 'L'], [1.0, 2, 3], [3.0, 4, 5 ```response title=Response 0.2222222222222222 ``` + ## arraySlice {#arraySlice} -引入时间:v1.1 +引入版本:v1.1 + +返回数组的切片,包括 `NULL` 元素。 **语法** @@ -2462,13 +3222,13 @@ arraySlice(arr, offset [, length]) **参数** -- `arr` — 要切片的数组。 [`Array(T)`](/sql-reference/data-types/array). -- `offset` — 从数组边缘的缩进。正值表示左侧的偏移,而负值表示右侧的偏移。数组项的编号从 `1` 开始。 [`(U)Int*`](/sql-reference/data-types/int-uint). -- `length` — 所需切片的长度。如果指定负值,函数返回开放切片 `[offset, array_length - length]`。如果省略值,函数返回切片 `[offset, the_end_of_array]`。 [`(U)Int*`](/sql-reference/data-types/int-uint). +- `arr` — 要切片的数组。[`Array(T)`](/sql-reference/data-types/array) +- `offset` — 从数组的边缘的缩进。正值表示左侧的偏移,负值表示右侧的缩进。数组项编号从 `1` 开始。 [`(U)Int*`](/sql-reference/data-types/int-uint) +- `length` — 所需切片的长度。如果指定负值,函数返回一个开放切片 `[offset, array_length - length]`。如果省略该值,函数返回切片 `[offset, the_end_of_array]`。 [`(U)Int*`](/sql-reference/data-types/int-uint) **返回值** -返回指定 `offset` 的 `length` 元素的数组切片。 [`Array(T)`](/sql-reference/data-types/array). +返回从指定 `offset` 开始的 `length` 元素的数组切片 [`Array(T)`](/sql-reference/data-types/array) **示例** @@ -2479,11 +3239,25 @@ SELECT arraySlice([1, 2, NULL, 4, 5], 2, 3) AS res; ``` ```response title=Response -[2,NULL,4] +[2, NULL, 4] ``` + ## arraySort {#arraySort} -引入时间:v1.1 +引入版本:v1.1 + +按升序对提供的数组元素进行排序。 +如果指定了 lambda 函数 `f`,排序顺序由施加于数组每个元素的 lambda 的结果决定。 +如果 lambda 接受多个参数,`arraySort` 函数将传递多个数组,这些数组将对应于 `f` 的参数。 + +如果要排序的数组包含 `-Inf`、`NULL`、`NaN` 或 `Inf`,它们将按以下顺序排序: + +1. `-Inf` +2. `Inf` +3. `NaN` +4. `NULL` + +`arraySort` 是一个 [高阶函数](/sql-reference/functions/overview#higher-order-functions)。 **语法** @@ -2493,13 +3267,13 @@ arraySort([f,] arr [, arr1, ... ,arrN]) **参数** -- `f(y1[, y2 ... yN])` — 要应用于数组 `x` 元素的 lambda 函数。 -- `arr` — 要排序的数组。 [`Array(T)`](/sql-reference/data-types/array) -- `arr1, ..., yN` — 可选。当 `f` 接受多个参数时,N 个额外数组。 +- `f(y1[, y2 ... yN])` — 要施加于数组 `x` 元素的 lambda 函数。 +- `arr` — 要排序的数组。 [`Array(T)`](/sql-reference/data-types/array) +- `arr1, ..., yN` — 可选。N个附加数组,当 `f` 接受多个参数时使用。 **返回值** -如果未提供 lambda 函数,则返回按升序排列的数组 `arr`,否则返回根据提供的 lambda 函数逻辑排序的数组。 [`Array(T)`](/sql-reference/data-types/array). +如果未提供 lambda 函数,则返回升序排序的数组 `arr`,否则返回根据提供的 lambda 函数逻辑排序的数组。 [`Array(T)`](/sql-reference/data-types/array)。 **示例** @@ -2532,9 +3306,12 @@ SELECT arraySort([1, nan, 2, NULL, 3, nan, -4, NULL, inf, -inf]); ```response title=Response [-inf,-4,1,2,3,inf,nan,nan,NULL,NULL] ``` + ## arraySplit {#arraySplit} -引入时间:v20.1 +引入版本:v20.1 + +将源数组分割成多个数组。当 `func(x [, y1, ..., yN])` 返回非零值时,数组将在元素左侧分割。数组不会在第一个元素之前分割。 **语法** @@ -2544,13 +3321,13 @@ arraySplit(func(x[, y1, ..., yN]), source_arr[, cond1_arr, ... , condN_arr]) **参数** -- `func(x[, y1, ..., yN])` — 一个在源数组的元素 (`x`) 和条件数组 (`y`) 上进行操作的 lambda 函数。[Lambda function](/sql-reference/functions/overview#arrow-operator-and-lambda). -- `source_arr` — 要拆分的源数组 [`Array(T)`](/sql-reference/data-types/array). -- `[, cond1_arr, ... , condN_arr]` — 可选。N 个条件数组,为 lambda 函数提供额外的参数。 [`Array(T)`](/sql-reference/data-types/array). +- `func(x[, y1, ..., yN])` — 操作源数组 (`x`) 元素和条件数组 (`y`) 的 lambda 函数。[Lambda 函数](/sql-reference/functions/overview#arrow-operator-and-lambda) +- `source_arr` — 要分割的源数组 [`Array(T)`](/sql-reference/data-types/array) +- `[, cond1_arr, ... , condN_arr]` — 可选。N个条件数组,为 lambda 函数提供附加参数。 [`Array(T)`](/sql-reference/data-types/array) **返回值** -返回一个数组的数组。 [`Array(Array(T))`](/sql-reference/data-types/array). +返回一个数组的数组 [`Array(Array(T))`](/sql-reference/data-types/array) **示例** @@ -2563,10 +3340,15 @@ SELECT arraySplit((x, y) -> y, [1, 2, 3, 4, 5], [1, 0, 0, 1, 0]) AS res ```response title=Response [[1, 2, 3], [4, 5]] ``` + ## arraySum {#arraySum} -引入时间:v21.1 +引入版本:v21.1 + +返回源数组中元素的总和。 +如果指定了 lambda 函数 `func`,则返回 lambda 结果的元素总和。 + **语法** ```sql @@ -2575,13 +3357,13 @@ arrayMax([func(x[, y1, ..., yN])], source_arr[, cond1_arr, ... , condN_arr]) **参数** -- `func(x[, y1, ..., yN])` — 可选。一个在源数组的元素 (`x`) 和条件数组 (`y`) 上进行操作的 lambda 函数。 [Lambda function](/sql-reference/functions/overview#arrow-operator-and-lambda). -- `source_arr` — 要处理的源数组。 [`Array(T)`](/sql-reference/data-types/array). -- `[, cond1_arr, ... , condN_arr]` — 可选。 N 个条件数组,为 lambda 函数提供额外的参数。 [`Array(T)`](/sql-reference/data-types/array). +- `func(x[, y1, ..., yN])` — 可选。操作源数组(`x`) 元素和条件数组(`y`) 的 lambda 函数。[Lambda 函数](/sql-reference/functions/overview#arrow-operator-and-lambda) +- `source_arr` — 要处理的源数组。 [`Array(T)`](/sql-reference/data-types/array) +- `, cond1_arr, ... , condN_arr]` — 可选。N个条件数组,为 lambda 函数提供附加参数。 [`Array(T)`](/sql-reference/data-types/array) **返回值** -返回源数组中元素的总和,或返回提供的 lambda 结果的元素总和。 +返回源数组中元素的总和,或者如果提供了则返回 lambda 结果的元素总和。 **示例** @@ -2595,7 +3377,7 @@ SELECT arraySum([1, 2, 3, 4]); 10 ``` -**与 lambda 函数配合使用的示例** +**与 lambda 函数一起使用** ```sql title=Query SELECT arraySum(x, y -> x+y, [1, 1, 1, 1], [1, 1, 1, 1]); @@ -2604,9 +3386,19 @@ SELECT arraySum(x, y -> x+y, [1, 1, 1, 1], [1, 1, 1, 1]); ```response title=Response 8 ``` + ## arraySymmetricDifference {#arraySymmetricDifference} -引入时间:v25.4 +引入版本:v25.4 + +接受多个数组并返回一个数组,包含不在所有源数组中的元素。结果仅包含唯一值。 + +:::note +多个集合的对称差是[数学定义的](https://en.wikipedia.org/wiki/Symmetric_difference#n-ary_symmetric_difference) +为出现于奇数个输入集合中的所有输入元素。 +相反,函数 `arraySymmetricDifference` 仅仅返回不出现在所有输入集合中的输入元素集合。 +::: + **语法** @@ -2616,11 +3408,11 @@ arraySymmetricDifference(arr1, arr2, ... , arrN) **参数** -- `arrN` — 从 N 个数组中生成的新数组。 [`Array(T)`](/sql-reference/data-types/array). +- `arrN` — N 个数组,用于创建新数组。 [`Array(T)`](/sql-reference/data-types/array) **返回值** -返回一个不在所有源数组中的不同元素的数组。 [`Array(T)`](/sql-reference/data-types/array). +返回一个不在所有源数组中的不同元素的数组 [`Array(T)`](/sql-reference/data-types/array) **示例** @@ -2637,9 +3429,12 @@ arraySymmetricDifference([1, 2], [1, 2], [1, 3]) AS non_empty_symmetric_differen │ [] │ [3] │ └────────────────────────────┴────────────────────────────────┘ ``` + ## arrayUnion {#arrayUnion} -引入时间:v24.10 +引入版本:v24.10 + +接受多个数组并返回一个数组,包含在源数组中的所有元素。结果仅包含唯一值。 **语法** @@ -2649,11 +3444,11 @@ arrayUnion(arr1, arr2, ..., arrN) **参数** -- `arrN` — 从 N 个数组生成的新数组。 [`Array(T)`](/sql-reference/data-types/array). +- `arrN` — N 个数组,用于创建新数组。 [`Array(T)`](/sql-reference/data-types/array) **返回值** -返回一个包含源数组中不同元素的数组。 [`Array(T)`](/sql-reference/data-types/array). +返回一个包含来自源数组的不同元素的数组 [`Array(T)`](/sql-reference/data-types/array) **示例** @@ -2671,9 +3466,26 @@ arrayUnion([1, 3, NULL], [2, 3, NULL]) as null_example │ [10,-2,1] │ ['hello','hi'] │ [3,2,1,NULL] │ └─────────────┴────────────────┴──────────────┘ ``` + ## arrayUniq {#arrayUniq} -引入时间:v1.1 +引入版本:v1.1 + +对于传入的单个参数,计算数组中不同元素的数量。 +对于传入的多个参数,计算在多个数组中对应位置上元素形成的不同 **元组** 的数量。 + +例如 `SELECT arrayUniq([1,2], [3,4], [5,6])` 将形成以下元组: +* 位置 1: (1,3,5) +* 位置 2: (2,4,6) + +它将计算唯一元组的数量。在这种情况下为 `2`。 + +所有传入的数组必须具有相同的长度。 + +:::tip +如果您想获得数组中的唯一项列表,可以使用 `arrayReduce('groupUniqArray', arr)`。 +::: + **语法** @@ -2683,13 +3495,12 @@ arrayUniq(arr1[, arr2, ..., arrN]) **参数** -- `arr1` — 用于计算独特元素数量的数组。 [`Array(T)`](/sql-reference/data-types/array). -- `[, arr2, ..., arrN] (可选)` — 可选。附加数组,用于计算多个数组中对应位置元素的独特元组数量。 [`Array(T)`](/sql-reference/data-types/array). +- `arr1` — 要计算唯一元素数量的数组。 [`Array(T)`](/sql-reference/data-types/array) +- `[, arr2, ..., arrN]` — 可选。用于计算在多个数组中相应位置上元素的唯一元组数量的附加数组。 [`Array(T)`](/sql-reference/data-types/array) **返回值** -对于单个参数,返回独特元素数量。对于多个参数,返回由多个数组中对应位置的元素构成的独特元组数量。 -[`UInt32`](/sql-reference/data-types/int-uint). +对于单个参数,返回唯一元素的数量。对于多个参数,返回由多个数组中每个相应位置的元素组成的不同元组的数量。 [`UInt32`](/sql-reference/data-types/int-uint) **示例** @@ -2712,10 +3523,13 @@ SELECT arrayUniq([1, 2, 3, 1], [4, 5, 6, 4]) ```response title=Response 3 ``` + ## arrayWithConstant {#arrayWithConstant} -引入时间:v20.1 +引入版本:v20.1 +创建一个长度为 `length` 的数组,填充常量 `x`。 + **语法** ```sql @@ -2724,12 +3538,12 @@ arrayWithConstant(N, x) **参数** -- `length` — 数组中的元素数量。 [`(U)Int*`](/sql-reference/data-types/int-uint). -- `x` — 数组中 `N` 个元素的值,可以是任何类型。 +- `length` — 数组中的元素数量。 [`(U)Int*`](/sql-reference/data-types/int-uint) +- `x` — 数组中 `N` 个元素的值,任何类型。 **返回值** -返回具有 `N` 个值为 `x` 的数组。 +返回一个值为 `x` 的 `N` 元素的数组。 [`Array(T)`](/sql-reference/data-types/array) **示例** @@ -2740,11 +3554,14 @@ SELECT arrayWithConstant(3, 1) ``` ```response title=Response -[1,1,1] +[1, 1, 1] ``` + ## arrayZip {#arrayZip} -引入时间:v20.1 +引入版本:v20.1 + +将多个数组组合成一个单一数组。结果数组包含源数组中对应元素的元组,按参数列表中的顺序分组。 **语法** @@ -2754,11 +3571,11 @@ arrayZip(arr1, arr2, ... , arrN) **参数** -- `arr1, arr2, ... , arrN` — N 个要组合成一个数组的数组。 [`Array(T)`](/sql-reference/data-types/array) +- `arr1, arr2, ... , arrN` — N 个数组,被组合成一个单一数组。 [`Array(T)`](/sql-reference/data-types/array) **返回值** -返回一个元素来自源数组的元组组合的数组。元组中的数据类型与输入数组的类型相同,并按照数组传递的顺序排列。 [`Array(T)`](/sql-reference/data-types/array)([`Tuple`](/sql-reference/data-types/tuple)). +返回一个数组,其元素来自源数组,按元组分组。元组中的数据类型与输入数组的类型相同,顺序与数组的传递顺序相同 [`Array(T)`](/sql-reference/data-types/array) **示例** @@ -2771,9 +3588,12 @@ SELECT arrayZip(['a', 'b', 'c'], [5, 2, 1]); ```response title=Response [('a', 5), ('b', 2), ('c', 1)] ``` + ## arrayZipUnaligned {#arrayZipUnaligned} -引入时间:v20.1 +引入版本:v20.1 + +将多个数组组合成一个单一数组,允许未对齐的数组(长度不同的数组)。结果数组包含源数组中对应元素的元组,按参数列表中的顺序分组。 **语法** @@ -2783,11 +3603,11 @@ arrayZipUnaligned(arr1, arr2, ..., arrN) **参数** -- `arr1, arr2, ..., arrN` — N 个要组合成一个数组的数组。 [`Array(T)`](/sql-reference/data-types/array). +- `arr1, arr2, ..., arrN` — N 个数组,被组合成一个单一数组。 [`Array(T)`](/sql-reference/data-types/array) **返回值** -返回一个元素来自源数组的元组组合的数组。元组中的数据类型与输入数组的类型相同,并按数组传递的顺序排列。 [`Array(T)`](/sql-reference/data-types/array)([`Tuple(T1, T2, ...)`](/sql-reference/data-types/tuple)). +返回一个数组,其元素来自源数组,按元组分组。元组中的数据类型与输入数组的类型相同,顺序与数组的传递顺序相同。 [`Array(T)`](/sql-reference/data-types/array) 或 [`Tuple(T1, T2, ...)`](/sql-reference/data-types/tuple) **示例** @@ -2800,9 +3620,14 @@ SELECT arrayZipUnaligned(['a'], [1, 2, 3]); ```response title=Response [('a', 1),(NULL, 2),(NULL, 3)] ``` + ## countEqual {#countEqual} -引入时间:v1.1 +引入版本:v1.1 + +返回数组中等于 `x` 的元素数量。等同于 `arrayCount(elem -> elem = x, arr)`。 + +`NULL` 元素被视为单独的值。 **语法** @@ -2812,12 +3637,12 @@ countEqual(arr, x) **参数** -- `arr` — 要搜索的数组。 [`Array(T)`](/sql-reference/data-types/array). -- `x` — 要计数的数组中的值。可以是任何类型。 +- `arr` — 要搜索的数组。 [`Array(T)`](/sql-reference/data-types/array) +- `x` — 要计数的数组中的值。任何类型。 **返回值** -返回数组中等于 `x` 的元素数量。 [UInt64](/sql-reference/data-types/int-uint). +返回数组中等于 `x` 的元素数量 [`UInt64`](/sql-reference/data-types/int-uint) **示例** @@ -2830,10 +3655,21 @@ SELECT countEqual([1, 2, NULL, NULL], NULL) ```response title=Response 2 ``` + ## empty {#empty} -引入时间:v1.1 +引入版本:v1.1 + +检查输入数组是否为空。 + +如果数组不包含任何元素,则被视为空数组。 + +:::note +通过启用 [`optimize_functions_to_subcolumns` 设置](/operations/settings/settings#optimize_functions_to_subcolumns) 可以进行优化。使用 `optimize_functions_to_subcolumns = 1`,函数仅读取 [size0](/sql-reference/data-types/array#array-size) 子列,而不是读取和处理整个数组列。查询 `SELECT empty(arr) FROM TABLE;` 转换为 `SELECT arr.size0 = 0 FROM TABLE;`。 +::: +该函数也适用于 [字符串](string-functions.md#empty) 或 [UUID](uuid-functions.md#empty)。 + **语法** ```sql @@ -2842,11 +3678,11 @@ empty(arr) **参数** -- `arr` — 输入数组。 [`Array(T)`](/sql-reference/data-types/array). +- `arr` — 输入数组。 [`Array(T)`](/sql-reference/data-types/array) **返回值** -对于空数组返回 `1`,对于非空数组返回 `0`。 [`UInt8`](../data-types/int-uint.md). +对于空数组返回 `1`,对于非空数组返回 `0` [`UInt8`](/sql-reference/data-types/int-uint) **示例** @@ -2859,9 +3695,12 @@ SELECT empty([]); ```response title=Response 1 ``` + ## emptyArrayDate {#emptyArrayDate} -引入时间:v1.1 +引入版本:v1.1 + +返回一个空的日期数组。 **语法** @@ -2871,11 +3710,10 @@ emptyArrayDate() **参数** -- `` — - +- 无。 **返回值** -一个空的日期数组。 [`Array(T)`](/sql-reference/data-types/array). +一个空的日期数组。 [`Array(T)`](/sql-reference/data-types/array) **示例** @@ -2888,9 +3726,12 @@ SELECT emptyArrayDate ```response title=Response [] ``` + ## emptyArrayDateTime {#emptyArrayDateTime} -引入时间:v1.1 +引入版本:v1.1 + +返回一个空的日期时间数组。 **语法** @@ -2900,11 +3741,10 @@ emptyArrayDateTime() **参数** -- `` — - +- 无。 **返回值** -一个空的日期时间数组。 [`Array(T)`](/sql-reference/data-types/array). +一个空的日期时间数组。 [`Array(T)`](/sql-reference/data-types/array) **示例** @@ -2917,9 +3757,12 @@ SELECT emptyArrayDateTime ```response title=Response [] ``` + ## emptyArrayFloat32 {#emptyArrayFloat32} -引入时间:v1.1 +引入版本:v1.1 + +返回一个空的 Float32 数组。 **语法** @@ -2929,11 +3772,10 @@ emptyArrayFloat32() **参数** -- `` — - +- 无。 **返回值** -一个空的 Float32 数组。 [`Array(T)`](/sql-reference/data-types/array). +一个空的 Float32 数组。 [`Array(T)`](/sql-reference/data-types/array) **示例** @@ -2946,9 +3788,12 @@ SELECT emptyArrayFloat32 ```response title=Response [] ``` + ## emptyArrayFloat64 {#emptyArrayFloat64} -引入时间:v1.1 +引入版本:v1.1 + +返回一个空的 Float64 数组。 **语法** @@ -2958,11 +3803,10 @@ emptyArrayFloat64() **参数** -- `` — - +- 无。 **返回值** -一个空的 Float64 数组。 [`Array(T)`](/sql-reference/data-types/array). +一个空的 Float64 数组。 [`Array(T)`](/sql-reference/data-types/array) **示例** @@ -2975,9 +3819,12 @@ SELECT emptyArrayFloat64 ```response title=Response [] ``` + ## emptyArrayInt16 {#emptyArrayInt16} -引入时间:v1.1 +引入版本:v1.1 + +返回一个空的 Int16 数组。 **语法** @@ -2987,11 +3834,10 @@ emptyArrayInt16() **参数** -- `` — - +- 无。 **返回值** -一个空的 Int16 数组。 [`Array(T)`](/sql-reference/data-types/array). +一个空的 Int16 数组。 [`Array(T)`](/sql-reference/data-types/array) **示例** @@ -3004,9 +3850,12 @@ SELECT emptyArrayInt16 ```response title=Response [] ``` + ## emptyArrayInt32 {#emptyArrayInt32} -引入时间:v1.1 +引入版本:v1.1 + +返回一个空的 Int32 数组。 **语法** @@ -3016,11 +3865,10 @@ emptyArrayInt32() **参数** -- `` — - +- 无。 **返回值** -一个空的 Int32 数组。 [`Array(T)`](/sql-reference/data-types/array). +一个空的 Int32 数组。 [`Array(T)`](/sql-reference/data-types/array) **示例** @@ -3033,9 +3881,12 @@ SELECT emptyArrayInt32 ```response title=Response [] ``` + ## emptyArrayInt64 {#emptyArrayInt64} -引入时间:v1.1 +引入版本:v1.1 + +返回一个空的 Int64 数组。 **语法** @@ -3045,11 +3896,10 @@ emptyArrayInt64() **参数** -- `` — - +- 无。 **返回值** -一个空的 Int64 数组。 [`Array(T)`](/sql-reference/data-types/array). +一个空的 Int64 数组。 [`Array(T)`](/sql-reference/data-types/array) **示例** @@ -3062,9 +3912,12 @@ SELECT emptyArrayInt64 ```response title=Response [] ``` + ## emptyArrayInt8 {#emptyArrayInt8} -引入时间:v1.1 +引入版本:v1.1 + +返回一个空的 Int8 数组。 **语法** @@ -3074,11 +3927,10 @@ emptyArrayInt8() **参数** -- `` — - +- 无。 **返回值** -一个空的 Int8 数组。 [`Array(T)`](/sql-reference/data-types/array). +一个空的 Int8 数组。 [`Array(T)`](/sql-reference/data-types/array) **示例** @@ -3091,9 +3943,12 @@ SELECT emptyArrayInt8 ```response title=Response [] ``` + ## emptyArrayString {#emptyArrayString} -引入时间:v1.1 +引入版本:v1.1 + +返回一个空的字符串数组。 **语法** @@ -3103,11 +3958,10 @@ emptyArrayString() **参数** -- `` — - +- 无。 **返回值** -一个空的字符串数组。 [`Array(T)`](/sql-reference/data-types/array). +一个空的字符串数组。 [`Array(T)`](/sql-reference/data-types/array) **示例** @@ -3120,10 +3974,13 @@ SELECT emptyArrayString ```response title=Response [] ``` + ## emptyArrayToSingle {#emptyArrayToSingle} -引入时间:v1.1 +引入版本:v1.1 +接受一个空数组并返回一个元素为默认值的单元素数组。 + **语法** ```sql @@ -3136,7 +3993,7 @@ emptyArrayToSingle(arr) **返回值** -一个具有数组默认类型单一值的数组。 +一个值为数组默认类型的单一值的数组。 [`Array(T)`](/sql-reference/data-types/array) **示例** @@ -3161,9 +4018,12 @@ SELECT emptyArrayToSingle(a), emptyArrayToSingle(b), emptyArrayToSingle(c) FROM │ [0] │ [''] │ ['1970-01-01 01:00:00'] │ └───────────────────────┴───────────────────────┴─────────────────────────┘ ``` + ## emptyArrayUInt16 {#emptyArrayUInt16} -引入时间:v1.1 +引入版本:v1.1 + +返回一个空的 UInt16 数组。 **语法** @@ -3173,11 +4033,10 @@ emptyArrayUInt16() **参数** -- `` — - +- 无。 **返回值** -一个空的 UInt16 数组。 [`Array(T)`](/sql-reference/data-types/array). +一个空的 UInt16 数组。 [`Array(T)`](/sql-reference/data-types/array) **示例** @@ -3190,9 +4049,12 @@ SELECT emptyArrayUInt16 ```response title=Response [] ``` + ## emptyArrayUInt32 {#emptyArrayUInt32} -引入时间:v1.1 +引入版本:v1.1 + +返回一个空的 UInt32 数组。 **语法** @@ -3202,11 +4064,10 @@ emptyArrayUInt32() **参数** -- `` — - +- 无。 **返回值** -一个空的 UInt32 数组。 [`Array(T)`](/sql-reference/data-types/array). +一个空的 UInt32 数组。 [`Array(T)`](/sql-reference/data-types/array) **示例** @@ -3219,9 +4080,12 @@ SELECT emptyArrayUInt32 ```response title=Response [] ``` + ## emptyArrayUInt64 {#emptyArrayUInt64} -引入时间:v1.1 +引入版本:v1.1 + +返回一个空的 UInt64 数组。 **语法** @@ -3231,11 +4095,10 @@ emptyArrayUInt64() **参数** -- `` — - +- 无。 **返回值** -一个空的 UInt64 数组。 [`Array(T)`](/sql-reference/data-types/array). +一个空的 UInt64 数组。 [`Array(T)`](/sql-reference/data-types/array) **示例** @@ -3248,9 +4111,12 @@ SELECT emptyArrayUInt64 ```response title=Response [] ``` + ## emptyArrayUInt8 {#emptyArrayUInt8} -引入时间:v1.1 +引入版本:v1.1 + +返回一个空的 UInt8 数组。 **语法** @@ -3260,11 +4126,10 @@ emptyArrayUInt8() **参数** -- `` — - +- 无。 **返回值** -一个空的 UInt8 数组。 [`Array(T)`](/sql-reference/data-types/array). +一个空的 UInt8 数组。 [`Array(T)`](/sql-reference/data-types/array) **示例** @@ -3277,9 +4142,59 @@ SELECT emptyArrayUInt8 ```response title=Response [] ``` + +## has {#has} + +引入版本:v1.1 + +返回数组是否包含指定的元素。 + +**语法** + +```sql +has(arr, x) +``` + +**参数** + +- `arr` — 源数组。 [`Array(T)`](/sql-reference/data-types/array) +- `x` — 要搜索的数组中的值。 + +**返回值** + +如果数组包含指定元素,则返回 `1`,否则返回 `0`。 [`UInt8`](/sql-reference/data-types/int-uint) + +**示例** + +**基本用法** + +```sql title=Query +SELECT has([1, 2, 3], 2) +``` + +```response title=Response +1 +``` + +**未找到** + +```sql title=Query +SELECT has([1, 2, 3], 4) +``` + +```response title=Response +0 +``` + ## hasAll {#hasAll} -引入时间:v1.1 +引入版本:v1.1 + +检查一个数组是否是另一个数组的子集。 + +- 空数组是任何数组的子集。 +- `Null` 被视为一个值。 +- 两个数组中值的顺序没有关系。 **语法** @@ -3289,15 +4204,15 @@ hasAll(set, subset) **参数** -- `set` — 具有元素集的任何类型数组。 [`Array`](/sql-reference/data-types/array). -- `subset` — 具有与 `set` 共享公共父类型的元素的任何类型数组,包含应测试为 `set` 的子集的元素。 [`Array`](/sql-reference/data-types/array). +- `set` — 任何类型的元素集合数组。 [`Array(T)`](/sql-reference/data-types/array) +- `subset` — 任何类型的数组,与 `set` 共享一个通用超类型,包含应测试是否为 `set` 的子集的元素。 [`Array(T)`](/sql-reference/data-types/array) **返回值** -- `1`,如果 `set` 包含来自 `subset` 的所有元素。 -- `0`,否则。 +- 如果 `set` 包含 `subset` 中的所有元素,则返回 `1`。 +- 否则返回 `0`。 -如果 set 和 subset 元素没有共享共同的父类型,则引发 `NO_COMMON_TYPE` 异常。 +如果集合和子集元素没有共享通用超类型,将引发 `NO_COMMON_TYPE` 异常。 **示例** @@ -3360,9 +4275,15 @@ SELECT hasAll([[1, 2], [3, 4]], [[1, 2], [3, 5]]) ```response title=Response 0 ``` + ## hasAny {#hasAny} -引入时间:v1.1 +引入版本:v1.1 + +检查两个数组是否有交集。 + +- `Null` 被视为一个值。 +- 两个数组中值的顺序没有关系。 **语法** @@ -3372,15 +4293,15 @@ hasAny(arr_x, arr_y) **参数** -- `arr_x` — 具有元素集的任何类型数组。 [`Array(T)`](/sql-reference/data-types/array). -- `arr_y` — 与数组 `arr_x` 共享公共父类型的任何类型数组。 [`Array(T)`](/sql-reference/data-types/array). +- `arr_x` — 任何类型的元素集合数组。 [`Array(T)`](/sql-reference/data-types/array) +- `arr_y` — 与数组 `arr_x` 共享一个通用超类型的任何类型数组。 [`Array(T)`](/sql-reference/data-types/array) **返回值** -- `1`,如果 `arr_x` 和 `arr_y` 至少有一个相似的元素。 -- `0`,否则。 +- 如果 `arr_x` 和 `arr_y` 至少有一个相似元素,则返回 `1`。 +- 否则返回 `0`。 -如果两个数组的任何元素没有共享共同的父类型,则引发 `NO_COMMON_TYPE` 异常。 +如果两个数组的任一元素没有共享通用超类型,将引发 `NO_COMMON_TYPE` 异常。 **示例** @@ -3391,7 +4312,7 @@ SELECT hasAny([1], []) ``` ```response title=Response -1 +0 ``` **包含 NULL 值的数组** @@ -3433,9 +4354,22 @@ SELECT hasAll([[1, 2], [3, 4]], [[1, 2], [1, 2]]) ```response title=Response 1 ``` + ## hasSubstr {#hasSubstr} -引入时间:v20.6 +引入版本:v20.6 + +检查所有 `array2` 的元素是否按完全相同的顺序出现在 `array1` 中。 +因此,该函数仅在且仅在 `array1 = prefix + array2 + suffix` 时返回 `1`。 + +换句话说,函数将检查 `array2` 的所有元素是否如函数 `hasAll` 所示包含在 `array1` 中。 +此外,它还会检查在两个数组中元素的顺序是否一致。 + +- 如果 `array2` 为空,函数将返回 `1`。 +- `Null` 被视为一个值。换句话说 `hasSubstr([1, 2, NULL, 3, 4], [2,3])` 将返回 `0`。但是 `hasSubstr([1, 2, NULL, 3, 4], [2,NULL,3])` 将返回 `1`。 +- 两个数组的值的顺序是重要的。 + +如果两个数组的任一元素没有共享通用超类型,将引发 `NO_COMMON_TYPE` 异常。 **语法** @@ -3445,12 +4379,12 @@ hasSubstr(arr1, arr2) **参数** -- `arr1` — 具有元素集的任何类型数组。 [`Array(T)`](/sql-reference/data-types/array). -- `arr2` — 具有元素集的任何类型数组。 [`Array(T)`](/sql-reference/data-types/array). +- `arr1` — 任何类型的元素数组。 [`Array(T)`](/sql-reference/data-types/array) +- `arr2` — 任何类型的元素数组。 [`Array(T)`](/sql-reference/data-types/array) **返回值** -如果数组 `arr1` 包含数组 `arr2`,则返回 `1`。否则,返回 `0`。 +如果数组 `arr1` 包含数组 `arr2`,则返回 `1`。否则返回 `0`。 [`UInt8`](/sql-reference/data-types/int-uint) **示例** @@ -3494,7 +4428,7 @@ SELECT hasSubstr(['a', 'b'], ['a']) 1 ``` -**有效顺序的数组** +**有有效顺序的数组** ```sql title=Query SELECT hasSubstr(['a', 'b' , 'c'], ['a', 'b']) @@ -3504,7 +4438,7 @@ SELECT hasSubstr(['a', 'b' , 'c'], ['a', 'b']) 1 ``` -**无效顺序的数组** +**有无效顺序的数组** ```sql title=Query SELECT hasSubstr(['a', 'b' , 'c'], ['a', 'c']) @@ -3533,10 +4467,15 @@ SELECT hasSubstr([1, 2, NULL, 3, 4], ['a']) ```response title=Response Raises a `NO_COMMON_TYPE` exception ``` + ## indexOf {#indexOf} -引入时间:v1.1 +引入版本:v1.1 + +返回数组中值为 'x' 的第一个元素的索引(从 1 开始),如果它在数组中。如果数组不包含要搜索的值,则函数返回 `0`。 +设置为 `NULL` 的元素作为普通值处理。 + **语法** ```sql @@ -3545,12 +4484,12 @@ indexOf(arr, x) **参数** -- `arr` — 要搜索 `x` 的数组。 [`Array`](/sql-reference/data-types/array). -- `x` — 在 `arr` 中寻找的第一个匹配元素的值。 UInt64. +- `arr` — 要搜索的数组 `[x]`。 [`Array(T)`](/sql-reference/data-types/array) +- `x` — 要在 `arr` 中返回索引的第一个匹配元素的值。 [`UInt64`](/sql-reference/data-types/int-uint) **返回值** -如果存在,则返回 `arr` 中首个 `x` 的索引(从一开始编号)。否则,返回 `0`。 +如果存在,则返回 `arr` 中第一个 `x` 的索引(从 1 编号)。否则返回 `0`。 [`UInt64`](/sql-reference/data-types/int-uint) **示例** @@ -3564,7 +4503,7 @@ SELECT indexOf([5, 4, 1, 3], 3) 4 ``` -**带有空值的数组** +**数组中包含 null** ```sql title=Query SELECT indexOf([1, 3, NULL, NULL], NULL) @@ -3573,10 +4512,17 @@ SELECT indexOf([1, 3, NULL, NULL], NULL) ```response title=Response 3 ``` + ## indexOfAssumeSorted {#indexOfAssumeSorted} -引入时间:v24.12 +引入版本:v24.12 +返回数组中值为 'x' 的第一个元素的索引(从 `1` 开始),如果它在数组中。如果数组不包含要搜索的值,则函数返回 `0`。 + +:::note +与 `indexOf` 函数不同,此函数假定数组按升序排序。如果数组未排序,则结果将是未定义的。 +::: + **语法** ```sql @@ -3585,12 +4531,12 @@ indexOfAssumeSorted(arr, x) **参数** -- `arr` — 要搜索的排序数组。 [`Array(T)`](/sql-reference/data-types/array). -- `x` — 在排序 `arr` 中寻找的第一个匹配元素的值。UInt64 +- `arr` — 要搜索的已排序数组。 [`Array(T)`](/sql-reference/data-types/array) +- `x` — 要在已排序的 `arr` 中返回索引的第一个匹配元素的值。 [`UInt64`](/sql-reference/data-types/int-uint) **返回值** -如果存在,则返回 `arr` 中首个 `x` 的索引(从一开始编号)。否则,返回 `0`。 +如果存在,则返回 `arr` 中第一个 `x` 的索引(从 `1` 开始)。否则返回 `0`。 [`UInt64`](/sql-reference/data-types/int-uint) **示例** @@ -3603,10 +4549,21 @@ SELECT indexOfAssumeSorted([1, 3, 3, 3, 4, 4, 5], 4) ```response title=Response 5 ``` + ## length {#length} -引入时间:v1.1 +引入版本:v1.1 + +计算字符串或数组的长度。 +- 对于字符串或固定字符串参数:计算字符串中的字节数。 +- 对于数组参数:计算数组中的元素数量。 +- 如果应用于固定字符串参数,该函数是常量表达式。 + +请注意,字符串中的字节数与 Unicode "代码点" 的数量不同,它与 Unicode "图形簇"(通常称为 "字符")的数量不同,它与可见字符串宽度的多少也不同。 + +字符串中可以有 ASCII NULL 字节,并且这些字节也会被计算在内。 + **语法** ```sql @@ -3615,15 +4572,15 @@ length(x) **参数** -- `x` — 用于计算字节数量(对于字符串/固定字符串)或元素数量(对于数组)的字符串、固定字符串或数组。 +- `x` — 要计算字节数(对于字符串/固定字符串)或元素数量(对于数组)的值。 [`String`](/sql-reference/data-types/string) 或 [`FixedString`](/sql-reference/data-types/fixedstring) 或 [`Array(T)`](/sql-reference/data-types/array) **返回值** -返回字符串/固定字符串 `x` 中的字节数/数组 `x` 中的元素数量。 +返回字符串/固定字符串 `x` 中的字节数/数组 `x` 中元素的数量 [`UInt64`](/sql-reference/data-types/int-uint) **示例** -**string1** +**字符串示例** ```sql title=Query SELECT length('Hello, world!') @@ -3633,7 +4590,7 @@ SELECT length('Hello, world!') 13 ``` -**arr1** +**数组示例** ```sql title=Query SELECT length(['Hello', 'world']) @@ -3643,7 +4600,7 @@ SELECT length(['Hello', 'world']) 2 ``` -**constexpr** +**constexpr 示例** ```sql title=Query WITH 'hello' || toString(number) AS str @@ -3661,7 +4618,7 @@ FROM numbers(3) └────────┴────────────────────────┴──────────────────────────────┘ ``` -**unicode** +**unicode 示例** ```sql title=Query SELECT 'ёлка' AS str1, length(str1), lengthUTF8(str1), normalizeUTF8NFKD(str1) AS str2, length(str2), lengthUTF8(str2) @@ -3673,7 +4630,7 @@ SELECT 'ёлка' AS str1, length(str1), lengthUTF8(str1), normalizeUTF8NFKD(str └──────┴──────────────┴──────────────────┴──────┴──────────────┴──────────────────┘ ``` -**ascii_vs_utf8** +**ascii_vs_utf8 示例** ```sql title=Query SELECT 'ábc' AS str, length(str), lengthUTF8(str) @@ -3684,10 +4641,21 @@ SELECT 'ábc' AS str, length(str), lengthUTF8(str) │ ábc │ 4 │ 3 │ └─────┴──────────────┴─────────────────┘ ``` + ## notEmpty {#notEmpty} -引入时间:v1.1 +引入版本:v1.1 + +检查输入数组是否非空。 + +如果数组至少包含一个元素,则被视为非空数组。 + +:::note +通过启用 [`optimize_functions_to_subcolumns`](/operations/settings/settings#optimize_functions_to_subcolumns) 设置可以进行优化。使用 `optimize_functions_to_subcolumns = 1`,函数仅读取 [size0](/sql-reference/data-types/array#array-size) 子列,而不是读取和处理整个数组列。查询 `SELECT notEmpty(arr) FROM table` 转换为 `SELECT arr.size0 != 0 FROM TABLE`。 +::: +该函数也适用于 [字符串](string-functions.md#notempty) 或 [UUID](uuid-functions.md#notempty)。 + **语法** ```sql @@ -3696,11 +4664,11 @@ notEmpty(arr) **参数** -- `arr` — 输入数组。 [`Array(T)`](/sql-reference/data-types/array). +- `arr` — 输入数组。 [`Array(T)`](/sql-reference/data-types/array) **返回值** -对于非空数组返回 `1`,对于空数组返回 `0`。 [`UInt8`](../data-types/int-uint.md). +对于非空数组返回 `1`,对于空数组返回 `0` [`UInt8`](/sql-reference/data-types/int-uint) **示例** @@ -3713,10 +4681,21 @@ SELECT notEmpty([1,2]); ```response title=Response 1 ``` + ## range {#range} -引入时间:v1.1 +引入版本:v1.1 + +返回从 `start` 到 `end - 1` 的数字数组,按 `step` 递增。 +支持的类型有: +- `UInt8/16/32/64` +- `Int8/16/32/64` + +- 所有参数 `start`、`end`、`step` 必须是上述支持的类型之一。返回数组的元素将是参数的超类型。 +- 如果函数返回的数组总长度超过由设置 [`function_range_max_elements_in_block`](../../operations/settings/settings.md#function_range_max_elements_in_block) 指定的元素数量,将抛出异常。 +- 如果任何参数具有 Nullable(nothing) 类型,则返回 `NULL`。如果任何参数具有`NULL` 值(Nullable(T) 类型),将抛出异常。 + **语法** ```sql @@ -3725,13 +4704,13 @@ range([start, ] end [, step]) **参数** -- `start` — 可选。数组的第一个元素。如果使用了 `step`,这是必需的。默认值: `0`。 -- `end` — 必需。在此之前构造数组的数字。 -- `step` — 可选。决定数组中每个元素之间的增量步长。默认值: `1`。 +- `start` — 可选。数组的第一个元素。如果使用 `step`,则为必需。默认值:`0`。 +- `end` — 必需。在此之前构建数组的数字。 +- `step` — 可选。确定数组中每个元素之间的增量步长。默认值:`1`。 **返回值** -数组中的数字从 `start` 到 `end - 1`,步长为 `step`。 +从 `start` 到 `end - 1` 的数字数组,按 `step` 递增。 [`Array(T)`](/sql-reference/data-types/array) **示例** @@ -3746,3 +4725,87 @@ SELECT range(5), range(1, 5), range(1, 5, 2), range(-1, 5, 2); │ [0,1,2,3,4] │ [1,2,3,4] │ [1,3] │ [-1,1,3] │ └─────────────┴─────────────┴────────────────┴─────────────────┘ ``` + +## replicate {#replicate} + +引入版本:v1.1 + +创建一个包含单个值的数组。 + +**语法** + +```sql +replicate(x, arr) +``` + +**参数** + +- `x` — 填充结果数组的值。 [`Any`](/sql-reference/data-types) +- `arr` — 一个数组。 [`Array(T)`](/sql-reference/data-types/array) + +**返回值** + +返回一个与 `arr` 长度相同的数组,填充值 `x`。 [`Array(T)`](/sql-reference/data-types/array) + +**示例** + +**用法示例** + +```sql title=Query +SELECT replicate(1, ['a', 'b', 'c']); +``` + +```response title=Response +┌─replicate(1, ['a', 'b', 'c'])───┐ +│ [1, 1, 1] │ +└─────────────────────────────────┘ +``` + +## reverse {#reverse} + +引入于: v1.1 + +反转输入数组中的元素顺序或输入字符串中的字符顺序。 + +**语法** + +```sql +reverse(arr | str) +``` + +**参数** + +- `arr | str` — 源数组或字符串。 [`Array(T)`](/sql-reference/data-types/array) 或 [`String`](/sql-reference/data-types/string) + +**返回值** + +返回一个数组或字符串,其元素或字符顺序被反转。 + +**示例** + +**反转数组** + +```sql title=Query +SELECT reverse([1, 2, 3, 4]); +``` + +```response title=Response +[4, 3, 2, 1] +``` + +**反转字符串** + +```sql title=Query +SELECT reverse('abcd'); +``` + +```response title=Response +'dcba' +``` + + + + +## Distance functions {#distance-functions} + +所有支持的函数在 [distance functions documentation](../../sql-reference/functions/distance-functions.md) 中有描述。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/array-functions.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/array-functions.md.hash index 3067ce5a550..cad00305e94 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/array-functions.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/array-functions.md.hash @@ -1 +1 @@ -0af67d6e2b1dd48a +ffec02dcfe583626 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/array-join.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/array-join.md index 136d39d98c9..1729d117e8b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/array-join.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/array-join.md @@ -1,30 +1,35 @@ --- 'description': 'arrayJoin 函数的文档' 'sidebar_label': 'arrayJoin' -'sidebar_position': 15 'slug': '/sql-reference/functions/array-join' 'title': 'arrayJoin 函数' +'doc_type': 'reference' --- # arrayJoin 函数 -这是一个非常独特的函数。 +这是一个非常特殊的函数。 -普通函数不改变行集,只是改变每行中的值(映射)。 -聚合函数压缩一组行(折叠或减少)。 -`arrayJoin` 函数则获取每一行并生成一组行(展开)。 +普通函数不会改变行的集合,而只是改变每行中的值(映射)。 +聚合函数压缩行的集合(折叠或减少)。 +`arrayJoin` 函数则是将每一行生成一组行(展开)。 -该函数以数组作为参数,并将源行传播到数组中元素数量的多个行。 -所有列中的值都被简单地复制,除了此函数应用的列中的值;该值将被对应的数组值替换。 +此函数将数组作为参数,并将源行传播为与数组中元素数量相对应的多行。 +除了应用此函数的列中的值被替换为相应的数组值外,其他列中的所有值都被简单地复制。 -示例: +:::note +如果数组为空,`arrayJoin` 不会产生任何行。 +要返回一个包含数组类型默认值的单行,可以使用 [emptyArrayToSingle](./array-functions.md#emptyArrayToSingle) 包裹,例如:`arrayJoin(emptyArrayToSingle(...))`。 +::: -```sql +例如: + +```sql title="Query" SELECT arrayJoin([1, 2, 3] AS src) AS dst, 'Hello', src ``` -```text +```text title="Response" ┌─dst─┬─\'Hello\'─┬─src─────┐ │ 1 │ Hello │ [1,2,3] │ │ 2 │ Hello │ [1,2,3] │ @@ -32,30 +37,27 @@ SELECT arrayJoin([1, 2, 3] AS src) AS dst, 'Hello', src └─────┴───────────┴─────────┘ ``` -`arrayJoin` 函数影响查询的所有部分,包括 `WHERE` 部分。请注意结果是 2,尽管子查询返回 1 行。 +`arrayJoin` 函数影响查询的所有部分,包括 `WHERE` 部分。请注意,下面查询的结果是 `2`,尽管子查询返回了 1 行。 -示例: - -```sql +```sql title="Query" SELECT sum(1) AS impressions FROM ( - SELECT ['Istanbul', 'Berlin', 'Bobruisk'] AS cities + SELECT ['Istanbul', 'Berlin', 'Babruysk'] AS cities ) WHERE arrayJoin(cities) IN ['Istanbul', 'Berlin']; ``` -```text +```text title="Response" ┌─impressions─┐ │ 2 │ └─────────────┘ ``` -一个查询可以使用多个 `arrayJoin` 函数。在这种情况下,转换将多次执行,并且行数将被放大。 - -示例: +一个查询可以使用多个 `arrayJoin` 函数。在这种情况下,转换会多次进行,行将被重复。 +例如: -```sql +```sql title="Query" SELECT sum(1) AS impressions, arrayJoin(cities) AS city, @@ -63,7 +65,7 @@ SELECT FROM ( SELECT - ['Istanbul', 'Berlin', 'Bobruisk'] AS cities, + ['Istanbul', 'Berlin', 'Babruysk'] AS cities, ['Firefox', 'Chrome', 'Chrome'] AS browsers ) GROUP BY @@ -71,33 +73,36 @@ GROUP BY 3 ``` -```text +```text title="Response" ┌─impressions─┬─city─────┬─browser─┐ │ 2 │ Istanbul │ Chrome │ │ 1 │ Istanbul │ Firefox │ │ 2 │ Berlin │ Chrome │ │ 1 │ Berlin │ Firefox │ -│ 2 │ Bobruisk │ Chrome │ -│ 1 │ Bobruisk │ Firefox │ +│ 2 │ Babruysk │ Chrome │ +│ 1 │ Babruysk │ Firefox │ └─────────────┴──────────┴─────────┘ ``` -### 重要说明! {#important-note} -使用相同表达式的多个 `arrayJoin` 可能会由于优化而未能产生预期结果。 -对于这种情况,请考虑通过额外的操作修改重复的数组表达式,这些操作不会影响连接结果 - 例如 `arrayJoin(arraySort(arr))`、`arrayJoin(arrayConcat(arr, []))` + +### 最佳实践 {#important-note} + +使用相同表达式的多个 `arrayJoin` 可能不会产生预期结果,因为会消除公共子表达式。 +在这些情况下,可以考虑通过额外的操作来修改重复的数组表达式,这些操作不会影响连接结果。例如,`arrayJoin(arraySort(arr))`、`arrayJoin(arrayConcat(arr, []))`。 示例: + ```sql SELECT - arrayJoin(dice) as first_throw, + arrayJoin(dice) AS first_throw, /* arrayJoin(dice) as second_throw */ -- is technically correct, but will annihilate result set - arrayJoin(arrayConcat(dice, [])) as second_throw -- intentionally changed expression to force re-evaluation + arrayJoin(arrayConcat(dice, [])) AS second_throw -- intentionally changed expression to force re-evaluation FROM ( - SELECT [1, 2, 3, 4, 5, 6] as dice + SELECT [1, 2, 3, 4, 5, 6] AS dice ); ``` -请注意 SELECT 查询中的 [ARRAY JOIN](../statements/select/array-join.md) 语法,它提供了更广泛的可能性。 -`ARRAY JOIN` 允许你一次性转换多个具有相同元素数量的数组。 +注意在 SELECT 查询中的 [`ARRAY JOIN`](../statements/select/array-join.md) 语法,它提供了更广泛的可能性。 +`ARRAY JOIN` 允许你同时转换多个具有相同数量元素的数组。 示例: @@ -109,7 +114,7 @@ SELECT FROM ( SELECT - ['Istanbul', 'Berlin', 'Bobruisk'] AS cities, + ['Istanbul', 'Berlin', 'Babruysk'] AS cities, ['Firefox', 'Chrome', 'Chrome'] AS browsers ) ARRAY JOIN @@ -124,15 +129,15 @@ GROUP BY ┌─impressions─┬─city─────┬─browser─┐ │ 1 │ Istanbul │ Firefox │ │ 1 │ Berlin │ Chrome │ -│ 1 │ Bobruisk │ Chrome │ +│ 1 │ Babruysk │ Chrome │ └─────────────┴──────────┴─────────┘ ``` -或者你可以使用 [Tuple](../data-types/tuple.md) +或者你可以使用 [`Tuple`](../data-types/tuple.md)。 示例: -```sql +```sql title="Query" SELECT sum(1) AS impressions, (arrayJoin(arrayZip(cities, browsers)) AS t).1 AS city, @@ -140,7 +145,7 @@ SELECT FROM ( SELECT - ['Istanbul', 'Berlin', 'Bobruisk'] AS cities, + ['Istanbul', 'Berlin', 'Babruysk'] AS cities, ['Firefox', 'Chrome', 'Chrome'] AS browsers ) GROUP BY @@ -148,10 +153,12 @@ GROUP BY 3 ``` -```text +```text title="Row" ┌─impressions─┬─city─────┬─browser─┐ │ 1 │ Istanbul │ Firefox │ │ 1 │ Berlin │ Chrome │ -│ 1 │ Bobruisk │ Chrome │ +│ 1 │ Babruysk │ Chrome │ └─────────────┴──────────┴─────────┘ ``` + +在 ClickHouse 中,`arrayJoin` 的名称源于其概念上与 JOIN 操作的相似性,但适用于单行内的数组。传统的 JOIN 是将来自不同表的行组合在一起,而 `arrayJoin` 则“连接”每行数组中的每个元素,生成多个行—每个数组元素一个,同时复制其他列的值。ClickHouse 还提供了 [`ARRAY JOIN`](/sql-reference/statements/select/array-join) 子句语法,通过使用熟悉的 SQL JOIN 术语,使得这种关系与传统 JOIN 操作更加显而易见。这个过程也被称为“展开”数组,但在函数名称和子句中使用“连接”这个术语是因为它类似于将表与数组元素连接在一起,实际上以一种类似于 JOIN 操作的方式扩展数据集。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/array-join.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/array-join.md.hash index 20899303f99..9653ea3ee19 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/array-join.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/array-join.md.hash @@ -1 +1 @@ -437c009a1faa5eb6 +662ecca246880f42 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/bit-functions.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/bit-functions.md index 77175ba422d..95477c92f87 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/bit-functions.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/bit-functions.md @@ -1,451 +1,733 @@ --- -'description': 'Documentation for Bit Functions' +'description': 'Bit Functions 的文档' 'sidebar_label': 'Bit' -'sidebar_position': 20 'slug': '/sql-reference/functions/bit-functions' 'title': '位函数' +'doc_type': 'reference' --- -# 位函数 +# 位运算函数 -位函数适用于 `UInt8`、`UInt16`、`UInt32`、`UInt64`、`Int8`、`Int16`、`Int32`、`Int64`、`Float32` 或 `Float64` 中的任何一对类型。某些函数支持 `String` 和 `FixedString` 类型。 +位运算函数适用于任何一对类型:`UInt8`、`UInt16`、`UInt32`、`UInt64`、`Int8`、`Int16`、`Int32`、`Int64`、`Float32` 或 `Float64`。某些函数支持 `String` 和 `FixedString` 类型。 -结果类型是一个整数,其位等于参数的最大位数。如果至少有一个参数是有符号的,则结果为有符号数。如果参数是浮点数,则会转换为 Int64。 +结果类型是一个整数,其位数等于参数的最大位数。如果至少有一个参数是有符号的,则结果是一个有符号数。如果参数是浮点数,则它被转换为 Int64。 -## bitAnd(a, b) {#bitanda-b} + -## bitOr(a, b) {#bitora-b} + +## bitAnd {#bitAnd} -## bitXor(a, b) {#bitxora-b} +引入于: v1.1 -## bitNot(a) {#bitnota} +执行两个值之间的按位与操作。 -## bitShiftLeft(a, b) {#bitshiftlefta-b} +**语法** -将一个值的二进制表示向左移动指定的位数。 +```sql +bitAnd(a, b) +``` + +**参数** + +- `a` — 第一个值。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) +- `b` — 第二个值。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) + + +**返回值** + +返回按位操作 `a AND b` 的结果。 + +**示例** + +**用法示例** + +```sql title=Query +CREATE TABLE bits +( + `a` UInt8, + `b` UInt8 +) +ENGINE = Memory; + +INSERT INTO bits VALUES (0, 0), (0, 1), (1, 0), (1, 1); + +SELECT + a, + b, + bitAnd(a, b) +FROM bits +``` + +```response title=Response +┌─a─┬─b─┬─bitAnd(a, b)─┐ +│ 0 │ 0 │ 0 │ +│ 0 │ 1 │ 0 │ +│ 1 │ 0 │ 0 │ +│ 1 │ 1 │ 1 │ +└───┴───┴──────────────┘ +``` -`FixedString` 或 `String` 被视为单个多字节值。 -`FixedString` 值的位在向外移动时会丢失。相反,`String` 值会用额外的字节扩展,因此不会丢失位。 + +## bitCount {#bitCount} + +引入于: v20.3 + +计算数字的二进制表示中被设置为一的位数。 **语法** ```sql -bitShiftLeft(a, b) +bitCount(x) ``` **参数** -- `a` — 要移动的值。[整数类型](../data-types/int-uint.md)、[String](../data-types/string.md) 或 [FixedString](../data-types/fixedstring.md)。 -- `b` — 移动的位数。[无符号整数类型](../data-types/int-uint.md)、64 位类型或更小的类型是允许的。 +- `x` — 一个整数或浮点值。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) + **返回值** -- 移动后的值。 +返回 `x` 中被设置为一的位数。 [`UInt8`](../data-types/int-uint.md)。 -返回值的类型与输入值的类型相同。 +:::note +该函数不会将输入值转换为更大的类型([符号扩展](https://en.wikipedia.org/wiki/Sign_extension))。 +例如:`bitCount(toUInt8(-1)) = 8`。 +::: **示例** -在以下查询中,使用了 [bin](encoding-functions.md#bin) 和 [hex](encoding-functions.md#hex) 函数来显示移动后的值的位。 +**用法示例** -```sql -SELECT 99 AS a, bin(a), bitShiftLeft(a, 2) AS a_shifted, bin(a_shifted); -SELECT 'abc' AS a, hex(a), bitShiftLeft(a, 4) AS a_shifted, hex(a_shifted); -SELECT toFixedString('abc', 3) AS a, hex(a), bitShiftLeft(a, 4) AS a_shifted, hex(a_shifted); +```sql title=Query +SELECT bin(333), bitCount(333); ``` -结果: - -```text -┌──a─┬─bin(99)──┬─a_shifted─┬─bin(bitShiftLeft(99, 2))─┐ -│ 99 │ 01100011 │ 140 │ 10001100 │ -└────┴──────────┴───────────┴──────────────────────────┘ -┌─a───┬─hex('abc')─┬─a_shifted─┬─hex(bitShiftLeft('abc', 4))─┐ -│ abc │ 616263 │ &0 │ 06162630 │ -└─────┴────────────┴───────────┴─────────────────────────────┘ -┌─a───┬─hex(toFixedString('abc', 3))─┬─a_shifted─┬─hex(bitShiftLeft(toFixedString('abc', 3), 4))─┐ -│ abc │ 616263 │ &0 │ 162630 │ -└─────┴──────────────────────────────┴───────────┴───────────────────────────────────────────────┘ +```response title=Response +┌─bin(333)─────────┬─bitCount(333)─┐ +│ 0000000101001101 │ 5 │ +└──────────────────┴───────────────┘ ``` -## bitShiftRight(a, b) {#bitshiftrighta-b} -将一个值的二进制表示向右移动指定的位数。 -`FixedString` 或 `String` 被视为单个多字节值。请注意,`String` 值的长度在位被移出时会减少。 +## bitHammingDistance {#bitHammingDistance} + +引入于: v21.1 + + +返回两个数字的位表示之间的 [汉明距离](https://en.wikipedia.org/wiki/Hamming_distance)。 +可与 [`SimHash`](../../sql-reference/functions/hash-functions.md#ngramSimHash) 函数一起使用,用于检测半重复字符串。 +距离越小,字符串越相似。 + **语法** ```sql -bitShiftRight(a, b) +bitHammingDistance(x, y) ``` **参数** -- `a` — 要移动的值。[整数类型](../data-types/int-uint.md)、[String](../data-types/string.md) 或 [FixedString](../data-types/fixedstring.md)。 -- `b` — 移动的位数。[无符号整数类型](../data-types/int-uint.md)、64 位类型或更小的类型是允许的。 +- `x` — 用于计算汉明距离的第一个数字。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) +- `y` — 用于计算汉明距离的第二个数字。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) -**返回值** -- 移动后的值。 +**返回值** -返回值的类型与输入值的类型相同。 +返回 `x` 和 `y` 之间的汉明距离 [`UInt8`](/sql-reference/data-types/int-uint) **示例** -查询: +**用法示例** -```sql -SELECT 101 AS a, bin(a), bitShiftRight(a, 2) AS a_shifted, bin(a_shifted); -SELECT 'abc' AS a, hex(a), bitShiftRight(a, 12) AS a_shifted, hex(a_shifted); -SELECT toFixedString('abc', 3) AS a, hex(a), bitShiftRight(a, 12) AS a_shifted, hex(a_shifted); +```sql title=Query +SELECT bitHammingDistance(111, 121); ``` -结果: - -```text -┌───a─┬─bin(101)─┬─a_shifted─┬─bin(bitShiftRight(101, 2))─┐ -│ 101 │ 01100101 │ 25 │ 00011001 │ -└─────┴──────────┴───────────┴────────────────────────────┘ -┌─a───┬─hex('abc')─┬─a_shifted─┬─hex(bitShiftRight('abc', 12))─┐ -│ abc │ 616263 │ │ 0616 │ -└─────┴────────────┴───────────┴───────────────────────────────┘ -┌─a───┬─hex(toFixedString('abc', 3))─┬─a_shifted─┬─hex(bitShiftRight(toFixedString('abc', 3), 12))─┐ -│ abc │ 616263 │ │ 000616 │ -└─────┴──────────────────────────────┴───────────┴─────────────────────────────────────────────────┘ +```response title=Response +┌─bitHammingDistance(111, 121)─┐ +│ 3 │ +└──────────────────────────────┘ ``` -## bitRotateLeft(a, b) {#bitrotatelefta-b} -## bitRotateRight(a, b) {#bitrotaterighta-b} -## bitSlice(s, offset, length) {#bitslices-offset-length} +## bitNot {#bitNot} -返回从 'offset' 索引开始的子字符串,长度为 'length' 位。位的索引从 1 开始。 +引入于: v1.1 + +执行按位取反操作。 **语法** ```sql -bitSlice(s, offset[, length]) +bitNot(a) ``` **参数** -- `s` — s 是 [String](../data-types/string.md) 或 [FixedString](../data-types/fixedstring.md)。 -- `offset` — 起始位的索引,正值表示在左侧的偏移,负值表示在右侧的缩进。位的编号从 1 开始。 -- `length` — 子字符串的位长。如果指定了负值,函数将返回一个开放子字符串 \[offset, array_length - length\]。如果省略该值,函数将返回子字符串 \[offset, the_end_string\]。如果 length 超过 s,将被截断。如果 length 不是 8 的倍数,则在右侧填充 0。 +- `a` — 要应用按位取反操作的值。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`String`](/sql-reference/data-types/string) + **返回值** -- 子字符串。[String](../data-types/string.md) +返回 `~a` 的结果,即 `a` 的位被翻转。 **示例** -查询: +**用法示例** -```sql -select bin('Hello'), bin(bitSlice('Hello', 1, 8)) -select bin('Hello'), bin(bitSlice('Hello', 1, 2)) -select bin('Hello'), bin(bitSlice('Hello', 1, 9)) -select bin('Hello'), bin(bitSlice('Hello', -4, 8)) +```sql title=Query +SELECT + CAST('5', 'UInt8') AS original, + bin(original) AS original_binary, + bitNot(original) AS result, + bin(bitNot(original)) AS result_binary; ``` -结果: - -```text -┌─bin('Hello')─────────────────────────────┬─bin(bitSlice('Hello', 1, 8))─┐ -│ 0100100001100101011011000110110001101111 │ 01001000 │ -└──────────────────────────────────────────┴──────────────────────────────┘ -┌─bin('Hello')─────────────────────────────┬─bin(bitSlice('Hello', 1, 2))─┐ -│ 0100100001100101011011000110110001101111 │ 01000000 │ -└──────────────────────────────────────────┴──────────────────────────────┘ -┌─bin('Hello')─────────────────────────────┬─bin(bitSlice('Hello', 1, 9))─┐ -│ 0100100001100101011011000110110001101111 │ 0100100000000000 │ -└──────────────────────────────────────────┴──────────────────────────────┘ -┌─bin('Hello')─────────────────────────────┬─bin(bitSlice('Hello', -4, 8))─┐ -│ 0100100001100101011011000110110001101111 │ 11110000 │ -└──────────────────────────────────────────┴───────────────────────────────┘ +```response title=Response +┌─original─┬─original_binary─┬─result─┬─result_binary─┐ +│ 5 │ 00000101 │ 250 │ 11111010 │ +└──────────┴─────────────────┴────────┴───────────────┘ ``` -## byteSlice(s, offset, length) {#byteslices-offset-length} -参见函数 [substring](string-functions.md#substring)。 -## bitTest {#bittest} +## bitOr {#bitOr} + +引入于: v1.1 -接受任何整数并将其转换为 [二进制形式](https://en.wikipedia.org/wiki/Binary_number),返回指定位置的位的值。计数是从右到左,从 0 开始。 +执行两个值之间的按位或操作。 **语法** ```sql -SELECT bitTest(number, index) +bitOr(a, b) ``` **参数** -- `number` – 整数。 -- `index` – 位的位置。 +- `a` — 第一个值。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) +- `b` — 第二个值。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) + **返回值** -- 指定位置的位的值。[UInt8](../data-types/int-uint.md)。 +返回按位操作 `a OR b` 的结果。 **示例** -例如,数字 43 在二进制(基数 2)系统中是 101011。 +**用法示例** + +```sql title=Query +CREATE TABLE bits +( + `a` UInt8, + `b` UInt8 +) +ENGINE = Memory; + +INSERT INTO bits VALUES (0, 0), (0, 1), (1, 0), (1, 1); + +SELECT + a, + b, + bitOr(a, b) +FROM bits; +``` + +```response title=Response +┌─a─┬─b─┬─bitOr(a, b)─┐ +│ 0 │ 0 │ 0 │ +│ 0 │ 1 │ 1 │ +│ 1 │ 0 │ 1 │ +│ 1 │ 1 │ 1 │ +└───┴───┴─────────────┘ +``` + + -查询: +## bitRotateLeft {#bitRotateLeft} + +引入于: v1.1 + +将位向左旋转指定数量的位置。脱落的位将环绕到右侧。 + +**语法** ```sql -SELECT bitTest(43, 1); +bitRotateLeft(a, N) ``` -结果: +**参数** + +- `a` — 要旋转的值。 [`(U)Int8/16/32/64`](/sql-reference/data-types/int-uint) +- `N` — 向左旋转的位置数。 [`UInt8/16/32/64`](/sql-reference/data-types/int-uint) + + +**返回值** + +返回旋转后的值,其类型与 `a` 相同。 [`(U)Int8/16/32/64`](/sql-reference/data-types/int-uint) + +**示例** + +**用法示例** -```text -┌─bitTest(43, 1)─┐ -│ 1 │ -└────────────────┘ +```sql title=Query +SELECT 99 AS a, bin(a), bitRotateLeft(a, 2) AS a_rotated, bin(a_rotated); ``` -另一个示例: +```response title=Response +┌──a─┬─bin(a)───┬─a_rotated─┬─bin(a_rotated)─┐ +│ 99 │ 01100011 │ 141 │ 10001101 │ +└────┴──────────┴───────────┴────────────────┘ +``` + + + +## bitRotateRight {#bitRotateRight} + +引入于: v1.1 -查询: +将位向右旋转指定数量的位置。脱落的位将环绕到左侧。 + +**语法** ```sql -SELECT bitTest(43, 2); +bitRotateRight(a, N) ``` -结果: +**参数** + +- `a` — 要旋转的值。 [`(U)Int8/16/32/64`](/sql-reference/data-types/int-uint) +- `N` — 向右旋转的位置数。 [`UInt8/16/32/64`](/sql-reference/data-types/int-uint) -```text -┌─bitTest(43, 2)─┐ -│ 0 │ -└────────────────┘ + +**返回值** + +返回旋转后的值,其类型与 `a` 相同。 [`(U)Int8/16/32/64`](/sql-reference/data-types/int-uint) + +**示例** + +**用法示例** + +```sql title=Query +SELECT 99 AS a, bin(a), bitRotateRight(a, 2) AS a_rotated, bin(a_rotated); ``` -## bitTestAll {#bittestall} +```response title=Response +┌──a─┬─bin(a)───┬─a_rotated─┬─bin(a_rotated)─┐ +│ 99 │ 01100011 │ 216 │ 11011000 │ +└────┴──────────┴───────────┴────────────────┘ +``` -返回给定位置所有位的 [逻辑合取](https://en.wikipedia.org/wiki/Logical_conjunction)(AND 操作符)的结果。计数是从右到左,从 0 开始。 -位运算的合取: -0 AND 0 = 0 +## bitShiftLeft {#bitShiftLeft} -0 AND 1 = 0 +引入于: v1.1 -1 AND 0 = 0 -1 AND 1 = 1 +将值的二进制表示向左移动指定数量的位。 + +`FixedString` 或 `String` 被视为单个多字节值。 + +当 `FixedString` 的值被移位时,某些位会被丢失。 +相反,`String` 值会用附加字节扩展,因此不会丢失任何位。 + **语法** ```sql -SELECT bitTestAll(number, index1, index2, index3, index4, ...) +bitShiftLeft(a, N) ``` **参数** -- `number` – 整数。 -- `index1`、`index2`、`index3`、`index4` – 位的位置。例如,对于位置集(`index1`、`index2`、`index3`、`index4`),当且仅当所有位置都为真时,该条件为真(`index1` ⋀ `index2` ⋀ `index3` ⋀ `index4`)。 +- `a` — 要移位的值。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`String`](/sql-reference/data-types/string) 或 [`FixedString`](/sql-reference/data-types/fixedstring) +- `N` — 要移位的位数。 [`UInt8/16/32/64`](/sql-reference/data-types/int-uint) + **返回值** -- 逻辑合取的结果。[UInt8](../data-types/int-uint.md)。 +返回移位后的值,其类型与 `a` 相同。 **示例** -例如,数字 43 在二进制(基数 2)系统中是 101011。 +**二进制编码的用法示例** -查询: +```sql title=Query +SELECT 99 AS a, bin(a), bitShiftLeft(a, 2) AS a_shifted, bin(a_shifted); +``` -```sql -SELECT bitTestAll(43, 0, 1, 3, 5); +```response title=Response +┌──a─┬─bin(99)──┬─a_shifted─┬─bin(bitShiftLeft(99, 2))─┐ +│ 99 │ 01100011 │ 140 │ 10001100 │ +└────┴──────────┴───────────┴──────────────────────────┘ ``` -结果: +**十六进制编码的用法示例** -```text -┌─bitTestAll(43, 0, 1, 3, 5)─┐ -│ 1 │ -└────────────────────────────┘ +```sql title=Query +SELECT 'abc' AS a, hex(a), bitShiftLeft(a, 4) AS a_shifted, hex(a_shifted); ``` -另一个示例: +```response title=Response +┌─a───┬─hex('abc')─┬─a_shifted─┬─hex(bitShiftLeft('abc', 4))─┐ +│ abc │ 616263 │ &0 │ 06162630 │ +└─────┴────────────┴───────────┴─────────────────────────────┘ +``` -查询: +**Fixed String 编码的用法示例** -```sql -SELECT bitTestAll(43, 0, 1, 3, 5, 2); +```sql title=Query +SELECT toFixedString('abc', 3) AS a, hex(a), bitShiftLeft(a, 4) AS a_shifted, hex(a_shifted); ``` -结果: - -```text -┌─bitTestAll(43, 0, 1, 3, 5, 2)─┐ -│ 0 │ -└───────────────────────────────┘ +```response title=Response +┌─a───┬─hex(toFixedString('abc', 3))─┬─a_shifted─┬─hex(bitShiftLeft(toFixedString('abc', 3), 4))─┐ +│ abc │ 616263 │ &0 │ 162630 │ +└─────┴──────────────────────────────┴───────────┴───────────────────────────────────────────────┘ ``` -## bitTestAny {#bittestany} -返回给定位置所有位的 [逻辑析取](https://en.wikipedia.org/wiki/Logical_disjunction)(OR 操作符)的结果。计数是从右到左,从 0 开始。 -位运算的析取: +## bitShiftRight {#bitShiftRight} + +引入于: v1.1 -0 OR 0 = 0 -0 OR 1 = 1 +将值的二进制表示向右移动指定数量的位。 + +`FixedString` 或 `String` 被视为单个多字节值。 -1 OR 0 = 1 +当 `FixedString` 的值被移位时,某些位会被丢失。 +相反,`String` 值会用附加字节扩展,因此不会丢失任何位。 -1 OR 1 = 1 **语法** ```sql -SELECT bitTestAny(number, index1, index2, index3, index4, ...) +bitShiftRight(a, N) ``` **参数** -- `number` – 整数。 -- `index1`、`index2`、`index3`、`index4` – 位的位置。 +- `a` — 要移位的值。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`String`](/sql-reference/data-types/string) 或 [`FixedString`](/sql-reference/data-types/fixedstring) +- `N` — 要移位的位数。 [`UInt8/16/32/64`](/sql-reference/data-types/int-uint) + **返回值** -- 逻辑析取的结果。[UInt8](../data-types/int-uint.md)。 +返回移位后的值,其类型与 `a` 相同。 **示例** -例如,数字 43 在二进制(基数 2)系统中是 101011。 +**二进制编码的用法示例** -查询: +```sql title=Query +SELECT 101 AS a, bin(a), bitShiftRight(a, 2) AS a_shifted, bin(a_shifted); +``` -```sql -SELECT bitTestAny(43, 0, 2); +```response title=Response +┌───a─┬─bin(101)─┬─a_shifted─┬─bin(bitShiftRight(101, 2))─┐ +│ 101 │ 01100101 │ 25 │ 00011001 │ +└─────┴──────────┴───────────┴────────────────────────────┘ +``` + +**十六进制编码的用法示例** + +```sql title=Query +SELECT 'abc' AS a, hex(a), bitShiftLeft(a, 4) AS a_shifted, hex(a_shifted); ``` -结果: +```response title=Response +┌─a───┬─hex('abc')─┬─a_shifted─┬─hex(bitShiftRight('abc', 12))─┐ +│ abc │ 616263 │ │ 0616 │ +└─────┴────────────┴───────────┴───────────────────────────────┘ +``` + +**Fixed String 编码的用法示例** + +```sql title=Query +SELECT toFixedString('abc', 3) AS a, hex(a), bitShiftRight(a, 12) AS a_shifted, hex(a_shifted); +``` -```text -┌─bitTestAny(43, 0, 2)─┐ -│ 1 │ -└──────────────────────┘ +```response title=Response +┌─a───┬─hex(toFixedString('abc', 3))─┬─a_shifted─┬─hex(bitShiftRight(toFixedString('abc', 3), 12))─┐ +│ abc │ 616263 │ │ 000616 │ +└─────┴──────────────────────────────┴───────────┴─────────────────────────────────────────────────┘ ``` -另一个示例: -查询: + +## bitSlice {#bitSlice} + +引入于: v22.2 + +返回从 '偏移量' 索引开始的子字符串,长度为 '长度' 位。 + +**语法** ```sql -SELECT bitTestAny(43, 4, 2); +bitSlice(s, offset[, length]) ``` -结果: +**参数** + +- `s` — 要切片的字符串或固定字符串。 [`String`](/sql-reference/data-types/string) 或 [`FixedString`](/sql-reference/data-types/fixedstring) +- `offset` — 返回的起始位位置(以1为基准)。 +- 正值:从字符串开头开始计数。 +- 负值:从字符串末尾开始计数。 + + [`(U)Int8/16/32/64`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) +- `length` — +可选。 要提取的位数。 +- 正值:提取 `length` 位。 +- 负值:从偏移量提取到 `(string_length - |length|)`。 +- 省略:从偏移量提取到字符串末尾。 +- 如果长度不是8的倍数,结果将用零在右侧填充。 + [`(U)Int8/16/32/64`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) + + +**返回值** + +返回包含提取位的字符串,以二进制序列表示。结果始终填充到字节边界(8位的倍数) [`String`](/sql-reference/data-types/string) + +**示例** -```text -┌─bitTestAny(43, 4, 2)─┐ -│ 0 │ -└──────────────────────┘ +**用法示例** + +```sql title=Query +SELECT bin('Hello'), bin(bitSlice('Hello', 1, 8)); +SELECT bin('Hello'), bin(bitSlice('Hello', 1, 2)); +SELECT bin('Hello'), bin(bitSlice('Hello', 1, 9)); +SELECT bin('Hello'), bin(bitSlice('Hello', -4, 8)); +``` + +```response title=Response +┌─bin('Hello')─────────────────────────────┬─bin(bitSlice('Hello', 1, 8))─┐ +│ 0100100001100101011011000110110001101111 │ 01001000 │ +└──────────────────────────────────────────┴──────────────────────────────┘ +┌─bin('Hello')─────────────────────────────┬─bin(bitSlice('Hello', 1, 2))─┐ +│ 0100100001100101011011000110110001101111 │ 01000000 │ +└──────────────────────────────────────────┴──────────────────────────────┘ +┌─bin('Hello')─────────────────────────────┬─bin(bitSlice('Hello', 1, 9))─┐ +│ 0100100001100101011011000110110001101111 │ 0100100000000000 │ +└──────────────────────────────────────────┴──────────────────────────────┘ +┌─bin('Hello')─────────────────────────────┬─bin(bitSlice('Hello', -4, 8))─┐ +│ 0100100001100101011011000110110001101111 │ 11110000 │ +└──────────────────────────────────────────┴───────────────────────────────┘ ``` -## bitCount {#bitcount} -计算数字的二进制表示中设置为 1 的位的数量。 + +## bitTest {#bitTest} + +引入于: v1.1 + +接受任何数字并将其转换为 [二进制形式](https://en.wikipedia.org/wiki/Binary_number),然后返回指定位置的位值。计数从右到左,从0开始。 **语法** ```sql -bitCount(x) +bitTest(a, i) ``` **参数** -- `x` — [整数](../data-types/int-uint.md) 或 [浮点](../data-types/float.md) 数字。该函数使用内存中的值表示。它允许支持浮点数。 +- `a` — 要转换的数字。 [`(U)Int8/16/32/64`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) +- `i` — 要返回的位的位置。 [`(U)Int8/16/32/64`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) -**返回值** -- 输入数字中设置为 1 的位的数量。[UInt8](../data-types/int-uint.md)。 +**返回值** -:::note -该函数不会将输入值转换为更大的类型([符号扩展](https://en.wikipedia.org/wiki/Sign_extension))。例如,`bitCount(toUInt8(-1)) = 8`。 -::: +返回 `a` 的二进制表示中位置 `i` 的位的值 [`UInt8`](/sql-reference/data-types/int-uint) **示例** -例如,数字 333。它的二进制表示:0000000101001101。 +**用法示例** -查询: +```sql title=Query +SELECT bin(2), bitTest(2, 1); +``` + +```response title=Response +┌─bin(2)───┬─bitTest(2, 1)─┐ +│ 00000010 │ 1 │ +└──────────┴───────────────┘ +``` + + + +## bitTestAll {#bitTestAll} + +引入于: v1.1 + + +返回给定位置的所有位的 [逻辑与](https://en.wikipedia.org/wiki/Logical_conjunction)(AND 运算符)结果。 +从右到左计数,从0开始。 + +两个位之间的逻辑与在且仅在两个输入位都为真时为真。 + + +**语法** ```sql -SELECT bitCount(333); +bitTestAll(a, index1[, index2, ... , indexN]) ``` -结果: +**参数** + +- `a` — 一个整数值。 [`(U)Int8/16/32/64`](/sql-reference/data-types/int-uint) +- `index1, ...` — 一个或多个位的位置。 [`(U)Int8/16/32/64`](/sql-reference/data-types/int-uint) + + +**返回值** + +返回逻辑与的结果 [`UInt8`](/sql-reference/data-types/int-uint) -```text -┌─bitCount(333)─┐ -│ 5 │ -└───────────────┘ +**示例** + +**用法示例 1** + +```sql title=Query +SELECT bitTestAll(43, 0, 1, 3, 5); ``` -## bitHammingDistance {#bithammingdistance} +```response title=Response +┌─bin(43)──┬─bitTestAll(43, 0, 1, 3, 5)─┐ +│ 00101011 │ 1 │ +└──────────┴────────────────────────────┘ +``` + +**用法示例 2** + +```sql title=Query +SELECT bitTestAll(43, 0, 1, 3, 5, 2); +``` + +```response title=Response +┌─bin(43)──┬─bitTestAll(4⋯1, 3, 5, 2)─┐ +│ 00101011 │ 0 │ +└──────────┴──────────────────────────┘ +``` + + + +## bitTestAny {#bitTestAny} + +引入于: v1.1 + + +返回给定位置的所有位的 [逻辑或](https://en.wikipedia.org/wiki/Logical_disjunction)(OR 运算符)结果。 +从右到左计数,从0开始。 -返回两个整数值的位表示之间的 [汉明距离](https://en.wikipedia.org/wiki/Hamming_distance)。可以与 [SimHash](../../sql-reference/functions/hash-functions.md#ngramsimhash) 函数一起使用,以检测半重复的字符串。距离越小,说明这些字符串越可能相同。 +两个位之间的逻辑或在至少一个输入位为真时为真。 + **语法** ```sql -bitHammingDistance(int1, int2) +bitTestAny(a, index1[, index2, ... , indexN]) ``` **参数** -- `int1` — 第一个整数值。[Int64](../data-types/int-uint.md)。 -- `int2` — 第二个整数值。[Int64](../data-types/int-uint.md)。 +- `a` — 一个整数值。 [`(U)Int8/16/32/64`](/sql-reference/data-types/int-uint) +- `index1, ...` — 一个或多个位的位置。 [`(U)Int8/16/32/64`](/sql-reference/data-types/int-uint) + **返回值** -- 汉明距离。[UInt8](../data-types/int-uint.md)。 +返回逻辑或的结果 [`UInt8`](/sql-reference/data-types/int-uint) **示例** -查询: +**用法示例 1** -```sql -SELECT bitHammingDistance(111, 121); +```sql title=Query +SELECT bitTestAny(43, 0, 2); ``` -结果: +```response title=Response +┌─bin(43)──┬─bitTestAny(43, 0, 2)─┐ +│ 00101011 │ 1 │ +└──────────┴──────────────────────┘ +``` -```text -┌─bitHammingDistance(111, 121)─┐ -│ 3 │ -└──────────────────────────────┘ +**用法示例 2** + +```sql title=Query +SELECT bitTestAny(43, 4, 2); +``` + +```response title=Response +┌─bin(43)──┬─bitTestAny(43, 4, 2)─┐ +│ 00101011 │ 0 │ +└──────────┴──────────────────────┘ ``` -与 [SimHash](../../sql-reference/functions/hash-functions.md#ngramsimhash) 一起使用: + + +## bitXor {#bitXor} + +引入于: v1.1 + +执行两个值之间的按位异或(XOR)操作。 + +**语法** ```sql -SELECT bitHammingDistance(ngramSimHash('cat ate rat'), ngramSimHash('rat ate cat')); +bitXor(a, b) ``` -结果: +**参数** + +- `a` — 第一个值。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) +- `b` — 第二个值。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) + + +**返回值** + +返回按位操作 `a XOR b` 的结果。 + +**示例** + +**用法示例** -```text -┌─bitHammingDistance(ngramSimHash('cat ate rat'), ngramSimHash('rat ate cat'))─┐ -│ 5 │ -└──────────────────────────────────────────────────────────────────────────────┘ +```sql title=Query +CREATE TABLE bits +( + `a` UInt8, + `b` UInt8 +) +ENGINE = Memory; + +INSERT INTO bits VALUES (0, 0), (0, 1), (1, 0), (1, 1); + +SELECT + a, + b, + bitXor(a, b) +FROM bits; ``` - +```response title=Response +┌─a─┬─b─┬─bitXor(a, b)─┐ +│ 0 │ 0 │ 0 │ +│ 0 │ 1 │ 1 │ +│ 1 │ 0 │ 1 │ +│ 1 │ 1 │ 0 │ +└───┴───┴──────────────┘ +``` + + - diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/bit-functions.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/bit-functions.md.hash index 7dabda3872a..d8bd395372b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/bit-functions.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/bit-functions.md.hash @@ -1 +1 @@ -5ec967c26138327c +2b08f31fb0c56775 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/bitmap-functions.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/bitmap-functions.md index da50e34fbaa..f82de1f8889 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/bitmap-functions.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/bitmap-functions.md @@ -1,234 +1,281 @@ --- 'description': '关于 Bitmap Functions 的文档' 'sidebar_label': 'Bitmap' -'sidebar_position': 25 'slug': '/sql-reference/functions/bitmap-functions' 'title': '位图函数' +'doc_type': 'reference' --- # 位图函数 -位图可以通过两种方式构建。第一种是通过聚合函数 groupBitmap 和 `-State` 构建的,另一种是从 Array 对象构建位图。 +位图可以通过两种方式构造。第一种方式是通过聚合函数 groupBitmap 与 `-State` 构造,另一种方式是从数组对象构造位图。 -## bitmapBuild {#bitmapbuild} + -从无符号整数数组构建位图。 + +## bitmapAnd {#bitmapAnd} + +引入于:v20.1 + +计算两个位图的逻辑与(AND)。 **语法** ```sql -bitmapBuild(array) +bitmapAnd(bitmap1, bitmap2) ``` **参数** -- `array` – 无符号整数数组。 +- `bitmap1` — 第一个位图对象。 [`AggregateFunction(groupBitmap, T)`](/sql-reference/data-types/aggregatefunction). - `bitmap2` — 第二个位图对象。 [`AggregateFunction(groupBitmap, T)`](/sql-reference/data-types/aggregatefunction). + +**返回值** + +返回包含两个输入位图中均存在的位的位图 [`AggregateFunction(groupBitmap, T)`](/sql-reference/data-types/aggregatefunction) **示例** -```sql -SELECT bitmapBuild([1, 2, 3, 4, 5]) AS res, toTypeName(res); +**用法示例** + +```sql title=Query +SELECT bitmapToArray(bitmapAnd(bitmapBuild([1, 2, 3]), bitmapBuild([3, 4, 5]))) AS res; ``` -```text -┌─res─┬─toTypeName(bitmapBuild([1, 2, 3, 4, 5]))─────┐ -│ │ AggregateFunction(groupBitmap, UInt8) │ -└─────┴──────────────────────────────────────────────┘ +```response title=Response +┌─res─┐ +│ [3] │ +└─────┘ ``` -## bitmapToArray {#bitmaptoarray} -将位图转换为整数数组。 + +## bitmapAndCardinality {#bitmapAndCardinality} + +引入于:v20.1 + +返回两个位图的逻辑与(AND)的基数。 **语法** ```sql -bitmapToArray(bitmap) +bitmapAndCardinality(bitmap1, bitmap2) ``` **参数** -- `bitmap` – 位图对象。 +- `bitmap1` — 第一个位图对象。 [`AggregateFunction(groupBitmap, T)`](/sql-reference/data-types/aggregatefunction). - `bitmap2` — 第二个位图对象。 [`AggregateFunction(groupBitmap, T)`](/sql-reference/data-types/aggregatefunction). + +**返回值** + +返回两个位图交集中的设置位的数量 [`UInt64`](/sql-reference/data-types/int-uint) **示例** -```sql -SELECT bitmapToArray(bitmapBuild([1, 2, 3, 4, 5])) AS res; -``` +**用法示例** -结果: +```sql title=Query +SELECT bitmapAndCardinality(bitmapBuild([1,2,3]), bitmapBuild([3,4,5])) AS res; +``` -```text -┌─res─────────┐ -│ [1,2,3,4,5] │ -└─────────────┘ +```response title=Response +┌─res─┐ +│ 1 │ +└─────┘ ``` -## bitmapSubsetInRange {#bitmapsubsetinrange} -返回位图中位于值区间内的子集。 + +## bitmapAndnot {#bitmapAndnot} + +引入于:v20.1 + +计算两个位图的逻辑与并取反结果(AND-NOT)。 **语法** ```sql -bitmapSubsetInRange(bitmap, range_start, range_end) +bitmapAndnot(bitmap1, bitmap2) ``` **参数** -- `bitmap` – [位图对象](#bitmapbuild)。 -- `range_start` – 范围的开始(包括)。 [UInt32](../data-types/int-uint.md)。 -- `range_end` – 范围的结束(不包括)。 [UInt32](../data-types/int-uint.md)。 +- `bitmap1` — 第一个位图对象。 [`AggregateFunction(groupBitmap, T)`](/sql-reference/data-types/aggregatefunction). - `bitmap2` — 第二个位图对象。 [`AggregateFunction(groupBitmap, T)`](/sql-reference/data-types/aggregatefunction). + +**返回值** + +返回一个位图,其中包含第一个位图中设置的位,但不包含第二个位图中的位 [`AggregateFunction(groupBitmap, T)`](/sql-reference/data-types/aggregatefunction) **示例** -```sql -SELECT bitmapToArray(bitmapSubsetInRange(bitmapBuild([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,100,200,500]), toUInt32(30), toUInt32(200))) AS res; -``` +**用法示例** -结果: +```sql title=Query +SELECT bitmapToArray(bitmapAndnot(bitmapBuild([1, 2, 3]), bitmapBuild([3, 4, 5]))) AS res; +``` -```text -┌─res───────────────┐ -│ [30,31,32,33,100] │ -└───────────────────┘ +```response title=Response +┌─res────┐ +│ [1, 2] │ +└────────┘ ``` -## bitmapSubsetLimit {#bitmapsubsetlimit} -返回位图中最小位值为 `range_start` 并且最多包含 `cardinality_limit` 个元素的子集。 + +## bitmapAndnotCardinality {#bitmapAndnotCardinality} + +引入于:v20.1 + +返回两个位图的 AND-NOT 操作的基数。 **语法** ```sql -bitmapSubsetLimit(bitmap, range_start, cardinality_limit) +bitmapAndnotCardinality(bitmap1, bitmap2) ``` **参数** -- `bitmap` – [位图对象](#bitmapbuild)。 -- `range_start` – 范围的开始(包括)。 [UInt32](../data-types/int-uint.md)。 -- `cardinality_limit` – 子集的最大基数。 [UInt32](../data-types/int-uint.md)。 +- `bitmap1` — 第一个位图对象。 [`AggregateFunction(groupBitmap, T)`](/sql-reference/data-types/aggregatefunction). - `bitmap2` — 第二个位图对象。 [`AggregateFunction(groupBitmap, T)`](/sql-reference/data-types/aggregatefunction). + +**返回值** + +返回 `bitmap1 AND-NOT bitmap2` 结果中的设置位的数量 [`UInt64`](/sql-reference/data-types/int-uint) **示例** -```sql -SELECT bitmapToArray(bitmapSubsetLimit(bitmapBuild([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,100,200,500]), toUInt32(30), toUInt32(200))) AS res; -``` +**用法示例** -结果: +```sql title=Query +SELECT bitmapAndnotCardinality(bitmapBuild([1,2,3]), bitmapBuild([3,4,5])) AS res; +``` -```text -┌─res───────────────────────┐ -│ [30,31,32,33,100,200,500] │ -└───────────────────────────┘ +```response title=Response +┌─res─┐ +│ 2 │ +└─────┘ ``` -## subBitmap {#subbitmap} -返回位图的子集,从位置 `offset` 开始。返回的位图的最大基数为 `cardinality_limit`。 + +## bitmapBuild {#bitmapBuild} + +引入于:v20.1 + +从无符号整数数组构建位图。它是函数 [`bitmapToArray`](/sql-reference/functions/bitmap-functions#bitmapToArray) 的反向操作。 **语法** ```sql -subBitmap(bitmap, offset, cardinality_limit) +bitmapBuild(array) ``` **参数** -- `bitmap` – 位图。 [位图对象](#bitmapbuild)。 -- `offset` – 子集的第一元素位置。 [UInt32](../data-types/int-uint.md)。 -- `cardinality_limit` – 子集中元素的最大数量。 [UInt32](../data-types/int-uint.md)。 +- `array` — 无符号整数数组。 [`Array(UInt*)`](/sql-reference/data-types/array) + + +**返回值** + +返回提供的数组构建的位图 [`AggregateFunction(groupBitmap, T)`](/sql-reference/data-types/aggregatefunction) **示例** -```sql -SELECT bitmapToArray(subBitmap(bitmapBuild([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,100,200,500]), toUInt32(10), toUInt32(10))) AS res; -``` +**用法示例** -结果: +```sql title=Query +SELECT bitmapBuild([1, 2, 3, 4, 5]) AS res, toTypeName(res); +``` -```text -┌─res─────────────────────────────┐ -│ [10,11,12,13,14,15,16,17,18,19] │ -└─────────────────────────────────┘ +```response title=Response +┌─res─┬─toTypeName(bitmapBuild([1, 2, 3, 4, 5]))─────┐ +│ │ AggregateFunction(groupBitmap, UInt8) │ +└─────┴──────────────────────────────────────────────┘ ``` -## bitmapContains {#bitmapcontains} -检查位图是否包含某个元素。 + +## bitmapCardinality {#bitmapCardinality} + +引入于:v20.1 + +返回位图中设置的位的数量(基数)。 + +**语法** ```sql -bitmapContains(bitmap, needle) +bitmapCardinality(bitmap) ``` **参数** -- `bitmap` – [位图对象](#bitmapbuild)。 -- `needle` – 被搜索的位值。 [UInt32](../data-types/int-uint.md)。 +- `bitmap` — 位图对象。 [`AggregateFunction(groupBitmap, T)`](/sql-reference/data-types/aggregatefunction). **返回值** -- 0 - 如果 `bitmap` 不包含 `needle`。 [UInt8](../data-types/int-uint.md)。 -- 1 - 如果 `bitmap` 包含 `needle`。 [UInt8](../data-types/int-uint.md)。 +返回位图中设置的位的数量 [`UInt64`](/sql-reference/data-types/int-uint) **示例** -```sql -SELECT bitmapContains(bitmapBuild([1,5,7,9]), toUInt32(9)) AS res; -``` +**用法示例** -结果: +```sql title=Query +SELECT bitmapCardinality(bitmapBuild([1, 3, 3, 5, 7, 7])) AS res +``` -```text +```response title=Response ┌─res─┐ -│ 1 │ +│ 4 │ └─────┘ ``` -## bitmapHasAny {#bitmaphasany} -检查两个位图是否相交。 -如果 `bitmap2` 恰好包含一个元素,请考虑使用 [bitmapContains](#bitmapcontains) 作为更高效的选择。 +## bitmapContains {#bitmapContains} + +引入于:v20.1 + +检查位图是否包含特定元素。 **语法** ```sql -bitmapHasAny(bitmap1, bitmap2) +bitmapContains(bitmap, value) ``` **参数** -- `bitmap1` – 位图对象 1。 -- `bitmap2` – 位图对象 2。 +- `bitmap` — 位图对象。 [`AggregateFunction(groupBitmap, T)`](/sql-reference/data-types/aggregatefunction). - `value` — 待检查的元素。 [(U)Int8/16/32/64](/sql-reference/data-types/int-uint/) **返回值** -- `1`,如果 `bitmap1` 和 `bitmap2` 至少有一个共享元素。 -- `0`,否则。 +如果位图包含指定值,则返回 `1`,否则返回 `0` [`UInt8`](/sql-reference/data-types/int-uint) **示例** -```sql -SELECT bitmapHasAny(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res; -``` +**用法示例** -结果: +```sql title=Query +SELECT bitmapContains(bitmapBuild([1, 2, 3]), 2) AS res; +``` -```text +```response title=Response ┌─res─┐ │ 1 │ └─────┘ ``` -## bitmapHasAll {#bitmaphasall} -如果第一个位图包含第二个位图的所有元素,则返回 1,否则返回 0。 -如果第二个位图为空,返回 1。 -另见 `hasAll(array, array)`。 +## bitmapHasAll {#bitmapHasAll} + +引入于:v20.1 + +检查第一个位图是否包含第二个位图的所有设置位。 **语法** @@ -238,362 +285,460 @@ bitmapHasAll(bitmap1, bitmap2) **参数** -- `bitmap1` – 位图对象 1。 -- `bitmap2` – 位图对象 2。 +- `bitmap1` — 第一个位图对象。 [`AggregateFunction(groupBitmap, T)`](/sql-reference/data-types/aggregatefunction). - `bitmap2` — 第二个位图对象。 [`AggregateFunction(groupBitmap, T)`](/sql-reference/data-types/aggregatefunction). + +**返回值** + +如果第二个位图的所有设置位都存在于第一个位图中,则返回 `1`,否则返回 `0` [`UInt8`](/sql-reference/data-types/int-uint) **示例** -```sql -SELECT bitmapHasAll(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res; -``` +**用法示例** -结果: +```sql title=Query +SELECT bitmapHasAll(bitmapBuild([1, 2, 3]), bitmapBuild([2, 3])) AS res; +``` -```text +```response title=Response ┌─res─┐ -│ 0 │ +│ 1 │ └─────┘ ``` -## bitmapCardinality {#bitmapcardinality} -返回位图的基数。 + +## bitmapHasAny {#bitmapHasAny} + +引入于:v20.1 + +检查第一个位图是否包含第二个位图的任何设置位。 **语法** ```sql -bitmapCardinality(bitmap) +bitmapHasAny(bitmap1, bitmap2) ``` **参数** -- `bitmap` – 位图对象。 +- `bitmap1` — 第一个位图对象。 [`AggregateFunction(groupBitmap, T)`](/sql-reference/data-types/aggregatefunction). - `bitmap2` — 第二个位图对象。 [`AggregateFunction(groupBitmap, T)`](/sql-reference/data-types/aggregatefunction). + +**返回值** + +如果第二个位图的任何位存在于第一个位图中,则返回 `1`,否则返回 `0` [`UInt8`](/sql-reference/data-types/int-uint) **示例** -```sql -SELECT bitmapCardinality(bitmapBuild([1, 2, 3, 4, 5])) AS res; -``` +**用法示例** -结果: +```sql title=Query +SELECT bitmapHasAny(bitmapBuild([1, 2, 3]), bitmapBuild([3, 4, 5])) AS res; +``` -```text +```response title=Response ┌─res─┐ -│ 5 │ +│ 1 │ └─────┘ ``` -## bitmapMin {#bitmapmin} -计算位图中设置的最小位,或者如果位图为空则返回 UINT32_MAX(如果类型 >= 8 位则返回 UINT64_MAX)。 + +## bitmapMax {#bitmapMax} + +引入于:v20.1 + +返回位图中设置的最大位的位置,如果位图为空,则返回 `0`。 **语法** ```sql -bitmapMin(bitmap) +bitmapMax(bitmap) ``` **参数** -- `bitmap` – 位图对象。 +- `bitmap` — 位图对象。 [`AggregateFunction(groupBitmap, T)`](/sql-reference/data-types/aggregatefunction). + +**返回值** + +返回位图中设置的最大位的位置,否则返回 `0` [`UInt64`](/sql-reference/data-types/int-uint) **示例** -```sql -SELECT bitmapMin(bitmapBuild([1, 2, 3, 4, 5])) AS res; -``` +**用法示例** -结果: +```sql title=Query +SELECT bitmapMax(bitmapBuild([1, 2, 3, 4, 5])) AS res; +``` -```text +```response title=Response ┌─res─┐ -│ 1 │ +│ 5 │ └─────┘ ``` -## bitmapMax {#bitmapmax} -计算位图中设置的最大位,或者如果位图为空则返回 0。 + +## bitmapMin {#bitmapMin} + +引入于:v20.1 + +返回位图中设置的最小位的位置。如果所有位都未设置,则返回 `UINT32_MAX`(如果位图包含超过 `2^64` 个位,则返回 `UINT64_MAX`)。 **语法** ```sql -bitmapMax(bitmap) +bitmapMin(bitmap) ``` **参数** -- `bitmap` – 位图对象。 +- `bitmap` — 位图对象。 [`AggregateFunction(groupBitmap, T)`](/sql-reference/data-types/aggregatefunction). + +**返回值** + +返回位图中设置的最小位的位置,或 `UINT32_MAX`/`UINT64_MAX` [`UInt64`](/sql-reference/data-types/int-uint) **示例** -```sql -SELECT bitmapMax(bitmapBuild([1, 2, 3, 4, 5])) AS res; -``` +**用法示例** -结果: +```sql title=Query +SELECT bitmapMin(bitmapBuild([3, 5, 2, 6])) AS res; +``` -```text +```response title=Response ┌─res─┐ -│ 5 │ +│ 2 │ └─────┘ ``` -## bitmapTransform {#bitmaptransform} -在位图中至多替换 N 位。第 i 个替换位的旧值和新值分别由 `from_array[i]` 和 `to_array[i]` 给出。 -结果依赖于 `from_array` 和 `to_array` 的数组顺序。 +## bitmapOr {#bitmapOr} + +引入于:v20.1 + +计算两个位图的逻辑或(OR)。 **语法** ```sql -bitmapTransform(bitmap, from_array, to_array) +bitmapOr(bitmap1, bitmap2) ``` **参数** -- `bitmap` – 位图对象。 -- `from_array` – UInt32 数组。对于 idx 在范围 \[0, from_array.size()) 内,如果位图包含 from_array\[idx\],则用 to_array\[idx\] 替换。 -- `to_array` – 与 `from_array` 大小相同的 UInt32 数组。 +- `bitmap1` — 第一个位图对象。 [`AggregateFunction(groupBitmap, T)`](/sql-reference/data-types/aggregatefunction). - `bitmap2` — 第二个位图对象。 [`AggregateFunction(groupBitmap, T)`](/sql-reference/data-types/aggregatefunction). + +**返回值** + +返回一个包含任一输入位图中设置位的位图 [`AggregateFunction(groupBitmap, T)`](/sql-reference/data-types/aggregatefunction) **示例** -```sql -SELECT bitmapToArray(bitmapTransform(bitmapBuild([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), cast([5,999,2] as Array(UInt32)), cast([2,888,20] as Array(UInt32)))) AS res; -``` +**用法示例** -结果: +```sql title=Query +SELECT bitmapToArray(bitmapOr(bitmapBuild([1, 2, 3]), bitmapBuild([3, 4, 5]))) AS res; +``` -```text -┌─res───────────────────┐ -│ [1,3,4,6,7,8,9,10,20] │ -└───────────────────────┘ +```response title=Response +┌─res─────────────┐ +│ [1, 2, 3, 4, 5] │ +└─────────────────┘ ``` -## bitmapAnd {#bitmapand} -计算两个位图的逻辑与。 + +## bitmapOrCardinality {#bitmapOrCardinality} + +引入于:v20.1 + +返回两个位图的逻辑或(OR)的基数。 **语法** ```sql -bitmapAnd(bitmap,bitmap) +bitmapOrCardinality(bitmap1, bitmap2) ``` **参数** -- `bitmap` – 位图对象。 +- `bitmap1` — 第一个位图对象。 [`AggregateFunction(groupBitmap, T)`](/sql-reference/data-types/aggregatefunction). - `bitmap2` — 第二个位图对象。 [`AggregateFunction(groupBitmap, T)`](/sql-reference/data-types/aggregatefunction). + +**返回值** + +返回两个位图并集中的设置位的数量 [`UInt64`](/sql-reference/data-types/int-uint) **示例** -```sql -SELECT bitmapToArray(bitmapAnd(bitmapBuild([1,2,3]),bitmapBuild([3,4,5]))) AS res; -``` +**用法示例** -结果: +```sql title=Query +SELECT bitmapOrCardinality(bitmapBuild([1,2,3]), bitmapBuild([3,4,5])) AS res; +``` -```text +```response title=Response ┌─res─┐ -│ [3] │ +│ 5 │ └─────┘ ``` -## bitmapOr {#bitmapor} -计算两个位图的逻辑或。 + +## bitmapSubsetInRange {#bitmapSubsetInRange} + +引入于:v20.1 + +返回位图的一个子集,仅包含指定范围内的设置位 [start, end)。使用基于 1 的索引。 **语法** ```sql -bitmapOr(bitmap,bitmap) +bitmapSubsetInRange(bitmap, start, end) ``` **参数** -- `bitmap` – 位图对象。 +- `bitmap` — 要提取子集的位图。 [`AggregateFunction(groupBitmap, T)`](/sql-reference/data-types/aggregatefunction). - `start` — 范围的开始(包含)。 [`UInt*`](/sql-reference/data-types/int-uint) - `end` — 范围的结束(不包含)。 [`UInt*`](/sql-reference/data-types/int-uint) + +**返回值** + +返回仅包含指定范围内设置位的位图 [`AggregateFunction(groupBitmap, T)`](/sql-reference/data-types/aggregatefunction) **示例** -```sql -SELECT bitmapToArray(bitmapOr(bitmapBuild([1,2,3]),bitmapBuild([3,4,5]))) AS res; -``` +**用法示例** -结果: +```sql title=Query +SELECT bitmapToArray(bitmapSubsetInRange(bitmapBuild([1, 2, 3, 4, 5]), 2, 5)) AS res; +``` -```text -┌─res─────────┐ -│ [1,2,3,4,5] │ -└─────────────┘ +```response title=Response +┌─res───────┐ +│ [2, 3, 4] │ +└───────────┘ ``` -## bitmapXor {#bitmapxor} -对两个位图进行异或运算。 + +## bitmapSubsetLimit {#bitmapSubsetLimit} + +引入于:v20.1 + +返回位图自位置 `range_start` 开始的子集,最多包含 `cardinality_limit` 个设置位。使用基于 1 的索引。 **语法** ```sql -bitmapXor(bitmap,bitmap) +bitmapSubsetLimit(bitmap, range_start, cardinality_limit) ``` **参数** -- `bitmap` – 位图对象。 +- `bitmap` — 位图对象。 [`AggregateFunction(groupBitmap, T)`](/sql-reference/data-types/aggregatefunction). - `range_start` — 范围的开始(包含)。 [`UInt32`](/sql-reference/data-types/int-uint) - `cardinality_limit` — 子集的最大基数。 [`UInt32`](/sql-reference/data-types/int-uint) + +**返回值** + +返回最多包含 `cardinality_limit` 个设置位的位图,从 `range_start` 开始 [`AggregateFunction(groupBitmap, T)`](/sql-reference/data-types/aggregatefunction) **示例** -```sql -SELECT bitmapToArray(bitmapXor(bitmapBuild([1,2,3]),bitmapBuild([3,4,5]))) AS res; -``` +**用法示例** -结果: +```sql title=Query +SELECT bitmapToArray(bitmapSubsetLimit(bitmapBuild([1, 5, 3, 2, 8]), 3, 2)) AS res; +``` -```text -┌─res───────┐ -│ [1,2,4,5] │ -└───────────┘ +```response title=Response +┌─res────┐ +│ [5, 3] │ +└────────┘ ``` -## bitmapAndnot {#bitmapandnot} -计算两个位图的逻辑与并对结果取反。 + +## bitmapToArray {#bitmapToArray} + +引入于:v20.1 + +将位图转换为无符号整数数组。它是函数 [`bitmapBuild`](/sql-reference/functions/bitmap-functions#bitmapBuild) 的反向操作。 **语法** ```sql -bitmapAndnot(bitmap,bitmap) +bitmapToArray(bitmap) ``` **参数** -- `bitmap` – 位图对象。 +- `bitmap` — 要转换的位图。 [`AggregateFunction(groupBitmap, T)`](/sql-reference/data-types/aggregatefunction). + +**返回值** + +返回位图中包含的无符号整数数组 [`Array(UInt*)`](/sql-reference/data-types/array) **示例** -```sql -SELECT bitmapToArray(bitmapAndnot(bitmapBuild([1,2,3]),bitmapBuild([3,4,5]))) AS res; -``` +**用法示例** -结果: +```sql title=Query +SELECT bitmapToArray(bitmapBuild([1, 2, 3, 4, 5])) AS res; +``` -```text -┌─res───┐ -│ [1,2] │ -└───────┘ +```response title=Response +┌─res─────────────┐ +│ [1, 2, 3, 4, 5] │ +└─────────────────┘ ``` -## bitmapAndCardinality {#bitmapandcardinality} -返回两个位图的逻辑与的基数。 + +## bitmapTransform {#bitmapTransform} + +引入于:v20.1 + + +通过将 `from_array` 中的特定位值与 `to_array` 中的对应值交换,改变位图中的最多 N 个位。 + **语法** ```sql -bitmapAndCardinality(bitmap,bitmap) +bitmapTransform(bitmap, from_array, to_array) ``` **参数** -- `bitmap` – 位图对象。 +- `bitmap` — 位图对象。 [`AggregateFunction(groupBitmap, T)`](/sql-reference/data-types/aggregatefunction). - `from_array` — 要替换的原始设置位数组。 [`Array(T)`](/sql-reference/data-types/array). - `to_array` — 用于替换的新的设置位数组。 [`Array(T)`](/sql-reference/data-types/array). + +**返回值** + +根据给定的映射,返回转换后的位图 [`AggregateFunction(groupBitmap, T)`](/sql-reference/data-types/aggregatefunction) **示例** -```sql -SELECT bitmapAndCardinality(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res; -``` +**用法示例** -结果: +```sql title=Query +SELECT bitmapToArray(bitmapTransform(bitmapBuild([1, 2, 3, 4, 5]), [2, 4], [20, 40])) AS res; +``` -```text -┌─res─┐ -│ 1 │ -└─────┘ +```response title=Response +┌─res───────────────┐ +│ [1, 3, 5, 20, 40] │ +└───────────────────┘ ``` -## bitmapOrCardinality {#bitmaporcardinality} -返回两个位图的逻辑或的基数。 + +## bitmapXor {#bitmapXor} + +引入于:v20.1 + +计算两个位图的对称差异(XOR)。 + +**语法** ```sql -bitmapOrCardinality(bitmap,bitmap) +bitmapXor(bitmap1, bitmap2) ``` **参数** -- `bitmap` – 位图对象。 +- `bitmap1` — 第一个位图对象。 [`AggregateFunction(groupBitmap, T)`](/sql-reference/data-types/aggregatefunction). - `bitmap2` — 第二个位图对象。 [`AggregateFunction(groupBitmap, T)`](/sql-reference/data-types/aggregatefunction). + +**返回值** + +返回一个包含任一输入位图中设置位的位图,但不包含两个位图中均存在的位 [`AggregateFunction(groupBitmap, T)`](/sql-reference/data-types/aggregatefunction) **示例** -```sql -SELECT bitmapOrCardinality(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res; -``` +**用法示例** -结果: +```sql title=Query +SELECT bitmapToArray(bitmapXor(bitmapBuild([1, 2, 3]), bitmapBuild([3, 4, 5]))) AS res; +``` -```text -┌─res─┐ -│ 5 │ -└─────┘ +```response title=Response +┌─res──────────┐ +│ [1, 2, 4, 5] │ +└──────────────┘ ``` -## bitmapXorCardinality {#bitmapxorcardinality} -返回两个位图的异或的基数。 + +## bitmapXorCardinality {#bitmapXorCardinality} + +引入于:v20.1 + +返回两个位图的 XOR(对称差异)的基数。 + +**语法** ```sql -bitmapXorCardinality(bitmap,bitmap) +bitmapXorCardinality(bitmap1, bitmap2) ``` **参数** -- `bitmap` – 位图对象。 +- `bitmap1` — 第一个位图对象。 [`AggregateFunction(groupBitmap, T)`](/sql-reference/data-types/aggregatefunction). - `bitmap2` — 第二个位图对象。 [`AggregateFunction(groupBitmap, T)`](/sql-reference/data-types/aggregatefunction). + +**返回值** + +返回两个位图的对称差异中设置位的数量 [`UInt64`](/sql-reference/data-types/int-uint) **示例** -```sql -SELECT bitmapXorCardinality(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res; -``` +**用法示例** -结果: +```sql title=Query +SELECT bitmapXorCardinality(bitmapBuild([1,2,3]), bitmapBuild([3,4,5])) AS res; +``` -```text +```response title=Response ┌─res─┐ │ 4 │ └─────┘ ``` -## bitmapAndnotCardinality {#bitmapandnotcardinality} -返回两个位图的 AND-NOT 操作的基数。 + +## subBitmap {#subBitmap} + +引入于:v21.9 + +返回位图的一个子集,从位置 `offset` 开始。返回位图的最大基数为 `cardinality_limit`。 + +**语法** ```sql -bitmapAndnotCardinality(bitmap,bitmap) +subBitmap(bitmap, offset, cardinality_limit) ``` **参数** -- `bitmap` – 位图对象。 +- `bitmap` — 位图对象。 [`AggregateFunction(groupBitmap, T)`](/sql-reference/data-types/aggregatefunction). - `offset` — 从开始(零索引)跳过的设置位数。 [`UInt32`](/sql-reference/data-types/int-uint) - `cardinality_limit` — 包含在子集中的最大设置位数。 [`UInt32`](/sql-reference/data-types/int-uint) + +**返回值** + +返回包含最多 `limit` 个设置位的位图,从 `offset` 设置位开始,按升序排列 [`AggregateFunction(groupBitmap, T)`](/sql-reference/data-types/aggregatefunction) **示例** -```sql -SELECT bitmapAndnotCardinality(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res; -``` +**用法示例** -结果: +```sql title=Query +SELECT bitmapToArray(subBitmap(bitmapBuild([1, 2, 3, 4, 5]), 2, 2)) AS res; +``` -```text -┌─res─┐ -│ 2 │ -└─────┘ +```response title=Response +┌─res────┐ +│ [3, 4] │ +└────────┘ ``` - - + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/bitmap-functions.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/bitmap-functions.md.hash index 4f7701c488c..6b4dd57b911 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/bitmap-functions.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/bitmap-functions.md.hash @@ -1 +1 @@ -3bd717de65ebfde4 +4ccc855d867addac diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/comparison-functions.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/comparison-functions.md index b31533fafe0..eb5835fb7fb 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/comparison-functions.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/comparison-functions.md @@ -1,101 +1,259 @@ --- -'description': 'Documentation for Comparison Functions' -'sidebar_label': '比较' -'sidebar_position': 35 +'description': 'Comparison Functions 的文档' +'sidebar_label': 'Comparison' 'slug': '/sql-reference/functions/comparison-functions' 'title': '比较函数' +'doc_type': 'reference' --- # 比较函数 -下面的比较函数返回 `0` 或 `1`,类型为 [UInt8](/sql-reference/data-types/int-uint)。仅同一组中的值可以进行比较(例如 `UInt16` 和 `UInt64`),而组之间的值不能比较(例如 `UInt16` 和 `DateTime`)。数字和字符串的比较是可能的,字符串与日期的比较以及日期与时间的比较也是可以的。对于元组和数组,比较是按词典顺序进行的,这意味着比较是针对左侧和右侧元组/数组的每个相应元素进行的。 +## 比较规则 {#comparison-rules} -以下类型可以进行比较: +下面的比较函数返回 `0` 或 `1`,数据类型为 [UInt8](/sql-reference/data-types/int-uint)。只有同一组内的值可以进行比较(例如 `UInt16` 和 `UInt64`),而不能跨组比较(例如 `UInt16` 和 `DateTime`)。数字和字符串之间的比较是可能的,同时字符串与日期和日期与时间之间的比较也是可能的。对于元组和数组,比较是按字典顺序进行的,意味着对左侧和右侧的元组/数组中的每个对应元素进行比较。 + +可以比较的类型有: - 数字和小数 - 字符串和固定字符串 - 日期 - 带时间的日期 -- 元组(词典顺序比较) -- 数组(词典顺序比较) +- 元组(字典序比较) +- 数组(字典序比较) :::note -字符串是逐字节比较的。如果其中一个字符串包含UTF-8编码的多字节字符,这可能导致意外结果。一个字符串 S1 如果以另一个字符串 S2 为前缀,则被认为比 S2 更长。 +字符串是逐字节比较的。如果其中一个字符串包含UTF-8编码的多字节字符,这可能导致意外结果。一个以另一个字符串 S2 为前缀的字符串 S1 被认为比 S2 更长。 ::: -## equals, `=`, `==` 操作符 {#equals} + + + +## equals {#equals} + +引入于:v1.1 + +比较两个值是否相等。 **语法** ```sql equals(a, b) + -- a = b + -- a == b ``` -别名: -- `a = b`(操作符) -- `a == b`(操作符) +**参数** + +- `a` — 第一个值。[*](#comparison-rules) - `b` — 第二个值。[*](#comparison-rules) + +**返回值** + +如果 `a` 等于 `b`,则返回 `1`,否则返回 `0` [`UInt8`](/sql-reference/data-types/int-uint) -## notEquals, `!=`, `<>` 操作符 {#notequals} +**示例** + +**使用示例** + +```sql title=Query +SELECT 1 = 1, 1 = 2; +``` + +```response title=Response +┌─equals(1, 1)─┬─equals(1, 2)─┐ +│ 1 │ 0 │ +└──────────────┴──────────────┘ +``` + + + +## greater {#greater} + +引入于:v1.1 + +比较两个值的大小关系。 **语法** ```sql -notEquals(a, b) +greater(a, b) + -- a > b ``` -别名: -- `a != b`(操作符) -- `a <> b`(操作符) +**参数** -## less, `<` 操作符 {#less} +- `a` — 第一个值。[*](#comparison-rules) - `b` — 第二个值。[*](#comparison-rules) + +**返回值** + +如果 `a` 大于 `b`,则返回 `1`,否则返回 `0` [`UInt8`](/sql-reference/data-types/int-uint) + +**示例** + +**使用示例** + +```sql title=Query +SELECT 2 > 1, 1 > 2; +``` + +```response title=Response +┌─greater(2, 1)─┬─greater(1, 2)─┐ +│ 1 │ 0 │ +└───────────────┴───────────────┘ +``` + + + +## greaterOrEquals {#greaterOrEquals} + +引入于:v1.1 + +比较两个值的大小或相等关系。 **语法** ```sql -less(a, b) +greaterOrEquals(a, b) + -- a >= b +``` + +**参数** + +- `a` — 第一个值。[*](#comparison-rules) - `b` — 第二个值。[*](#comparison-rules) + +**返回值** + +如果 `a` 大于或等于 `b`,则返回 `1`,否则返回 `0` [`UInt8`](/sql-reference/data-types/int-uint) + +**示例** + +**使用示例** + +```sql title=Query +SELECT 2 >= 1, 2 >= 2, 1 >= 2; +``` + +```response title=Response +┌─greaterOrEquals(2, 1)─┬─greaterOrEquals(2, 2)─┬─greaterOrEquals(1, 2)─┐ +│ 1 │ 1 │ 0 │ +└───────────────────────┴───────────────────────┴───────────────────────┘ ``` -别名: -- `a < b`(操作符) -## greater, `>` 操作符 {#greater} + +## less {#less} + +引入于:v1.1 + +比较两个值的大小关系。 **语法** ```sql -greater(a, b) +less(a, b) + -- a < b ``` -别名: -- `a > b`(操作符) +**参数** + +- `a` — 第一个值。[*](#comparison-rules) - `b` — 第二个值。[*](#comparison-rules) + +**返回值** -## lessOrEquals, `<=` 操作符 {#lessorequals} +如果 `a` 小于 `b`,则返回 `1`,否则返回 `0` [`UInt8`](/sql-reference/data-types/int-uint) + +**示例** + +**使用示例** + +```sql title=Query +SELECT 1 < 2, 2 < 1; +``` + +```response title=Response +┌─less(1, 2)─┬─less(2, 1)─┐ +│ 1 │ 0 │ +└────────────┴────────────┘ +``` + + + +## lessOrEquals {#lessOrEquals} + +引入于:v1.1 + +比较两个值的大小或相等关系。 **语法** ```sql lessOrEquals(a, b) +-- a <= b ``` -别名: -- `a <= b`(操作符) +**参数** + +- `a` — 第一个值。[*](#comparison-rules) - `b` — 第二个值。[*](#comparison-rules) -## greaterOrEquals, `>=` 操作符 {#greaterorequals} +**返回值** + +如果 `a` 小于或等于 `b`,则返回 `1`,否则返回 `0` [`UInt8`](/sql-reference/data-types/int-uint) + +**示例** + +**使用示例** + +```sql title=Query +SELECT 1 <= 2, 2 <= 2, 3 <= 2; +``` + +```response title=Response +┌─lessOrEquals(1, 2)─┬─lessOrEquals(2, 2)─┬─lessOrEquals(3, 2)─┐ +│ 1 │ 1 │ 0 │ +└────────────────────┴────────────────────┴────────────────────┘ +``` + + + +## notEquals {#notEquals} + +引入于:v1.1 + +比较两个值是否不相等。 **语法** ```sql -greaterOrEquals(a, b) +notEquals(a, b) + -- a != b + -- a <> b +``` + +**参数** + +- `a` — 第一个值。[*](#comparison-rules) - `b` — 第二个值。[*](#comparison-rules) + +**返回值** + +如果 `a` 不等于 `b`,则返回 `1`,否则返回 `0`。 [`UInt8`](/sql-reference/data-types/int-uint) + +**示例** + +**使用示例** + +```sql title=Query +SELECT 1 != 2, 1 != 1; +``` + +```response title=Response +┌─notEquals(1, 2)─┬─notEquals(1, 1)─┐ +│ 1 │ 0 │ +└─────────────────┴─────────────────┘ ``` -别名: -- `a >= b`(操作符) - - diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/comparison-functions.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/comparison-functions.md.hash index 515d3bf259d..0a926b65f0a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/comparison-functions.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/comparison-functions.md.hash @@ -1 +1 @@ -e7493310402f17d9 +4af25e543d4175d3 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/conditional-functions.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/conditional-functions.md index 0baaa42bf4c..4297b84fb1d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/conditional-functions.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/conditional-functions.md @@ -1,111 +1,19 @@ --- -'description': 'Conditional Functions的文档' -'sidebar_label': 'Conditional' -'sidebar_position': 40 +'description': '关于 Conditional Functions 的文档' +'sidebar_label': '条件' 'slug': '/sql-reference/functions/conditional-functions' 'title': '条件函数' +'doc_type': 'reference' --- # 条件函数 -## if {#if} - -执行条件分支。 - -如果条件 `cond` 的结果为非零值,函数返回表达式 `then` 的结果。如果 `cond` 的结果为零或 `NULL`,则返回 `else` 表达式的结果。 - -设置 [short_circuit_function_evaluation](/operations/settings/settings#short_circuit_function_evaluation) 控制是否使用短路求值。如果启用,`then` 表达式仅在 `cond` 为 `true` 的行上进行评估,而 `else` 表达式在 `cond` 为 `false` 的行上进行评估。例如,在短路求值的情况下,执行查询 `SELECT if(number = 0, 0, intDiv(42, number)) FROM numbers(10)` 时不会抛出除以零的异常。 - -`then` 和 `else` 必须是相似的类型。 - -**语法** - -```sql -if(cond, then, else) -``` -别名: `cond ? then : else`(三元运算符) - -**参数** - -- `cond` – 被评估的条件。UInt8、Nullable(UInt8) 或 NULL。 -- `then` – 如果 `condition` 为 true,则返回的表达式。 -- `else` – 如果 `condition` 为 false 或 NULL,则返回的表达式。 +## 概述 {#overview} -**返回值** +### 直接使用条件结果 {#using-conditional-results-directly} -依赖于条件 `cond` 的 `then` 和 `else` 表达式的结果。 - -**示例** - -```sql -SELECT if(1, plus(2, 2), plus(2, 6)); -``` - -结果: - -```text -┌─plus(2, 2)─┐ -│ 4 │ -└────────────┘ -``` - -## multiIf {#multiif} - -允许以更紧凑的格式在查询中编写 [CASE](../../sql-reference/operators/index.md#conditional-expression) 操作符。 - -**语法** - -```sql -multiIf(cond_1, then_1, cond_2, then_2, ..., else) -``` - -设置 [short_circuit_function_evaluation](/operations/settings/settings#short_circuit_function_evaluation) 控制是否使用短路求值。如果启用,`then_i` 表达式仅在 `((NOT cond_1) AND (NOT cond_2) AND ... AND (NOT cond_{i-1}) AND cond_i)` 为 `true` 的行上进行评估,`cond_i` 仅在 `((NOT cond_1) AND (NOT cond_2) AND ... AND (NOT cond_{i-1}))` 为 `true` 的行上进行评估。例如,在短路求值的情况下,执行查询 `SELECT multiIf(number = 2, intDiv(1, number), number = 5) FROM numbers(10)` 时不会抛出除以零的异常。 - -**参数** - -这个函数接受 `2N+1` 个参数: -- `cond_N` — 第 N 个被评估的条件,控制是否返回 `then_N`。 -- `then_N` — 当 `cond_N` 为 true 时函数的结果。 -- `else` — 如果没有条件为 true 的函数结果。 - -**返回值** - -依赖于条件 `cond_N` 的 `then_N` 或 `else` 表达式的结果。 - -**示例** - -假设这个表: - -```text -┌─left─┬─right─┐ -│ ᴺᵁᴸᴸ │ 4 │ -│ 1 │ 3 │ -│ 2 │ 2 │ -│ 3 │ 1 │ -│ 4 │ ᴺᵁᴸᴸ │ -└──────┴───────┘ -``` - -```sql -SELECT - left, - right, - multiIf(left < right, 'left is smaller', left > right, 'left is greater', left = right, 'Both equal', 'Null value') AS result -FROM LEFT_RIGHT - -┌─left─┬─right─┬─result──────────┐ -│ ᴺᵁᴸᴸ │ 4 │ Null value │ -│ 1 │ 3 │ left is smaller │ -│ 2 │ 2 │ Both equal │ -│ 3 │ 1 │ left is greater │ -│ 4 │ ᴺᵁᴸᴸ │ Null value │ -└──────┴───────┴─────────────────┘ -``` - -## 直接使用条件结果 {#using-conditional-results-directly} - -条件总是结果为 `0`、`1` 或 `NULL`。因此,你可以像这样直接使用条件结果: +条件总是返回 `0`,`1` 或 `NULL`。因此,您可以直接像这样使用条件结果: ```sql SELECT left < right AS is_small @@ -120,9 +28,9 @@ FROM LEFT_RIGHT └──────────┘ ``` -## 条件中的 NULL 值 {#null-values-in-conditionals} +### 条件中的 NULL 值 {#null-values-in-conditionals} -当 `NULL` 值涉及到条件时,结果也将是 `NULL`。 +当条件中涉及 `NULL` 值时,结果也将是 `NULL`。 ```sql SELECT @@ -136,9 +44,9 @@ SELECT └───────────────┴───────────────┴──────────────────┴────────────────────┘ ``` -因此,如果类型为 `Nullable`,你应该小心构造查询。 +因此,如果类型是 `Nullable`,您应该仔细构建查询。 -以下示例演示了在 `multiIf` 中未能添加等于条件的情况。 +以下示例通过未能将等于条件添加到 `multiIf` 中来演示这一点。 ```sql SELECT @@ -156,128 +64,15 @@ FROM LEFT_RIGHT └──────┴───────┴──────────────────┘ ``` -## greatest {#greatest} - -返回一组值中的最大值。所有列表成员必须是可比较的类型。 - -示例: - -```sql -SELECT greatest(1, 2, toUInt8(3), 3.) result, toTypeName(result) type; -``` -```response -┌─result─┬─type────┐ -│ 3 │ Float64 │ -└────────┴─────────┘ -``` - -:::note -返回的类型是 Float64,因为 UInt8 必须被提升到 64 位以进行比较。 -::: - -```sql -SELECT greatest(['hello'], ['there'], ['world']) -``` -```response -┌─greatest(['hello'], ['there'], ['world'])─┐ -│ ['world'] │ -└───────────────────────────────────────────┘ -``` - -```sql -SELECT greatest(toDateTime32(now() + toIntervalDay(1)), toDateTime64(now(), 3)) -``` -```response -┌─greatest(toDateTime32(plus(now(), toIntervalDay(1))), toDateTime64(now(), 3))─┐ -│ 2023-05-12 01:16:59.000 │ -└──---──────────────────────────────────────────────────────────────────────────┘ -``` - -:::note -返回的类型是 DateTime64,因为 DateTime32 必须被提升到 64 位以进行比较。 -::: - -## least {#least} - -返回一组值中的最小值。所有列表成员必须是可比较的类型。 - -示例: - -```sql -SELECT least(1, 2, toUInt8(3), 3.) result, toTypeName(result) type; -``` -```response -┌─result─┬─type────┐ -│ 1 │ Float64 │ -└────────┴─────────┘ -``` - -:::note -返回的类型是 Float64,因为 UInt8 必须被提升到 64 位以进行比较。 -::: +### CASE 语句 {#case-statement} -```sql -SELECT least(['hello'], ['there'], ['world']) -``` -```response -┌─least(['hello'], ['there'], ['world'])─┐ -│ ['hello'] │ -└────────────────────────────────────────┘ -``` - -```sql -SELECT least(toDateTime32(now() + toIntervalDay(1)), toDateTime64(now(), 3)) -``` -```response -┌─least(toDateTime32(plus(now(), toIntervalDay(1))), toDateTime64(now(), 3))─┐ -│ 2023-05-12 01:16:59.000 │ -└────────────────────────────────────────────────────────────────────────────┘ -``` - -:::note -返回的类型是 DateTime64,因为 DateTime32 必须被提升到 64 位以进行比较。 -::: - -## clamp {#clamp} - -将返回值限制在 A 和 B 之间。 - -**语法** - -```sql -clamp(value, min, max) -``` - -**参数** - -- `value` – 输入值。 -- `min` – 限制下界。 -- `max` – 限制上界。 - -**返回值** - -如果值小于最小值,返回最小值;如果大于最大值,返回最大值;否则返回当前值。 - -示例: - -```sql -SELECT clamp(1, 2, 3) result, toTypeName(result) type; -``` -```response -┌─result─┬─type────┐ -│ 2 │ Float64 │ -└────────┴─────────┘ -``` - -## CASE 语句 {#case-statement} - -ClickHouse 中的 CASE 表达式提供了类似于 SQL CASE 操作符的条件逻辑。它评估条件,并根据第一个匹配的条件返回值。 +ClickHouse 中的 CASE 表达式提供类似于 SQL CASE 操作符的条件逻辑。它评估条件并根据第一个匹配的条件返回值。 ClickHouse 支持两种形式的 CASE: 1. `CASE WHEN ... THEN ... ELSE ... END` -
-这种形式允许完全灵活性,并通过 [multiIf](/sql-reference/functions/conditional-functions#multiif) 函数内部实现。每个条件独立评估,表达式可以包括非常量值。 +
+ 这种形式允许完全的灵活性,并且使用 [multiIf](/sql-reference/functions/conditional-functions#multiIf) 函数在内部实现。每个条件都是独立评估的,表达式可以包含非常量值。 ```sql SELECT @@ -309,8 +104,8 @@ WHERE number < 5 ``` 2. `CASE WHEN THEN ... WHEN THEN ... ELSE ... END` -
-这种更紧凑的形式优化了常量值匹配,并在内部使用 `caseWithExpression()`。 +
+ 这种更紧凑的形式针对常量值匹配进行了优化,并在内部使用 `caseWithExpression()`。 例如,以下是有效的: @@ -372,15 +167,15 @@ WHERE number < 3 3 rows in set. Elapsed: 0.001 sec. ``` -### 注意事项 {#caveats} +#### 注意事项 {#caveats} -ClickHouse 在评估任何条件之前确定 CASE 表达式(或其内部等效物,如 `multiIf`)的结果类型。当返回表达式的类型不同时,例如不同时区或数字类型时,这一点非常重要。 +ClickHouse 在评估任何条件之前确定 CASE 表达式(或其内部等效项,如 `multiIf`)的结果类型。这在返回表达式类型不同的情况下非常重要,例如不同的时区或数字类型。 -- 结果类型基于所有分支中最大的兼容类型进行选择。 -- 一旦选择了这一类型,所有其他分支将被隐式转换为此类型——即使它们的逻辑在运行时永远不会被执行。 -- 对于如 DateTime64 这样的类型,其中时区是类型签名的一部分,这可能导致意外行为:第一个遇到的时区可能会用于所有分支,即使其他分支指定了不同的时区。 +- 结果类型是根据所有分支中最大的兼容类型来选择的。 +- 一旦选择了此类型,所有其他分支都隐式转换为此类型,即使其逻辑在运行时永远不会被执行。 +- 对于像 DateTime64 这样,时区是类型签名的一部分,这可能导致意想不到的行为:第一次遇到的时区可能会被用于所有分支,即使其他分支指定了不同的时区。 -例如,下面所有行返回在第一个匹配分支的时区中的时间戳,即 `Asia/Kolkata` +例如,下面所有行返回的时间戳都位于第一个匹配分支的时区,即 `Asia/Kolkata` ```sql SELECT @@ -410,9 +205,9 @@ WHERE number < 3 3 rows in set. Elapsed: 0.011 sec. ``` -在这里,ClickHouse 看到多个 `DateTime64(3, )` 返回类型。它推断出共同类型为 `DateTime64(3, 'Asia/Kolkata'` 作为它第一次看到的类型,隐式地将其他分支转换为此类型。 +在这里,ClickHouse 看到多个 `DateTime64(3, )` 返回类型。它推断出公共类型为 `DateTime64(3, 'Asia/Kolkata'`,因为这是它看到的第一个类型,隐式地将其他分支转换为此类型。 -可以通过转换为字符串来保留预期的时区格式: +这可以通过转换为字符串以保留预期的时区格式来解决: ```sql SELECT @@ -443,10 +238,340 @@ WHERE number < 3 ``` +## clamp {#clamp} + +引入于:v24.5 + + +限制一个值在指定的最小和最大范围内。 + +如果值小于最小值,则返回最小值。如果值大于最大值,则返回最大值。否则,返回值本身。 + +所有参数必须是可比较类型。结果类型是所有参数中的最大兼容类型。 + + +**语法** + +```sql +clamp(value, min, max) +``` + +**参数** + +- `value` — 要限制的值。 - `min` — 最小范围。 - `max` — 最大范围。 + +**返回值** + +返回限制在 [min, max] 范围内的值。 + +**示例** + +**基本用法** + +```sql title=Query +SELECT clamp(5, 1, 10) AS result; +``` + +```response title=Response +┌─result─┐ +│ 5 │ +└────────┘ +``` + +**低于最小值** + +```sql title=Query +SELECT clamp(-3, 0, 7) AS result; +``` + +```response title=Response +┌─result─┐ +│ 0 │ +└────────┘ +``` + +**高于最大值** + +```sql title=Query +SELECT clamp(15, 0, 7) AS result; +``` + +```response title=Response +┌─result─┐ +│ 7 │ +└────────┘ +``` + + + +## greatest {#greatest} + +引入于:v1.1 + + +返回参数中最大的值。 +`NULL` 参数将被忽略。 + +- 对于数组,返回字典序最大的数组。 +- 对于 `DateTime` 类型,结果类型会提升到最大类型(例如,混合 `DateTime32` 时返回 `DateTime64`)。 + +:::note 使用设置 `least_greatest_legacy_null_behavior` 更改 `NULL` 的行为 +版本 [24.12](/whats-new/changelog/2024#a-id2412a-clickhouse-release-2412-2024-12-19) 引入了一个向后不兼容的更改,使得 `NULL` 值被忽略,而之前如果其中一个参数为 `NULL` 则返回 `NULL`。 +要保持先前的行为,请将设置 `least_greatest_legacy_null_behavior`(默认值:`false`)设为 `true`。 +::: + + +**语法** + +```sql +greatest(x1[, x2, ...]) +``` + +**参数** + +- `x1[, x2, ...]` — 一个或多个要比较的值。所有参数必须是可比较类型。[`Any`](/sql-reference/data-types) + + +**返回值** + +返回参数中的最大值,并提升为最大兼容类型。[`Any`](/sql-reference/data-types) + +**示例** + +**数字类型** + +```sql title=Query +SELECT greatest(1, 2, toUInt8(3), 3.) AS result, toTypeName(result) AS type; +-- The type returned is a Float64 as the UInt8 must be promoted to 64 bit for the comparison. +``` + +```response title=Response +┌─result─┬─type────┐ +│ 3 │ Float64 │ +└────────┴─────────┘ +``` + +**数组** + +```sql title=Query +SELECT greatest(['hello'], ['there'], ['world']); +``` + +```response title=Response +┌─greatest(['hello'], ['there'], ['world'])─┐ +│ ['world'] │ +└───────────────────────────────────────────┘ +``` + +**DateTime 类型** + +```sql title=Query +SELECT greatest(toDateTime32(now() + toIntervalDay(1)), toDateTime64(now(), 3)); +-- The type returned is a DateTime64 as the DateTime32 must be promoted to 64 bit for the comparison. +``` + +```response title=Response +┌─greatest(toD⋯(now(), 3))─┐ +│ 2025-05-28 15:50:53.000 │ +└──────────────────────────┘ +``` + + + +## if {#if} + +引入于:v1.1 + + +执行条件分支。 + +- 如果条件 `cond` 评估为非零值,则该函数返回表达式 `then` 的结果。 +- 如果 `cond` 评估为零或 NULL,则返回 `else` 表达式的结果。 + +设置 [`short_circuit_function_evaluation`](/operations/settings/settings#short_circuit_function_evaluation) 控制是否使用短路求值。 + +如果启用,`then` 表达式只会在 `cond` 为真时在行上进行评估,而 `else` 表达式只会在 `cond` 为假时进行评估。 + +例如,使用短路求值时,执行以下查询时不会引发除零异常: + +```sql +SELECT if(number = 0, 0, intDiv(42, number)) FROM numbers(10) +``` + +`then` 和 `else` 必须是相似的类型。 + + +**语法** + +```sql +if(cond, then, else) +``` + +**参数** + +- `cond` — 被评估的条件。[`UInt8`](/sql-reference/data-types/int-uint) 或 [`Nullable(UInt8)`](/sql-reference/data-types/nullable) 或 [`NULL`](/sql-reference/syntax#null) +- `then` — 如果 `cond` 为真则返回的表达式。 - `else` — 如果 `cond` 为假或为 `NULL` 则返回的表达式。 + +**返回值** + +根据条件 `cond` 返回 `then` 或 `else` 表达式的结果。 + +**示例** + +**示例用法** + +```sql title=Query +SELECT if(1, 2 + 2, 2 + 6) AS res; +``` + +```response title=Response +┌─res─┐ +│ 4 │ +└─────┘ +``` + + + +## least {#least} + +引入于:v1.1 + + +返回参数中最小的值。 +`NULL` 参数将被忽略。 + +- 对于数组,返回字典序最小的数组。 +- 对于 DateTime 类型,结果类型会提升到最大类型(例如,混合 DateTime32 时返回 DateTime64)。 + +:::note 使用设置 `least_greatest_legacy_null_behavior` 更改 `NULL` 的行为 +版本 [24.12](/whats-new/changelog/2024#a-id2412a-clickhouse-release-2412-2024-12-19) 引入了一个向后不兼容的更改,使得 `NULL` 值被忽略,而之前如果其中一个参数为 `NULL` 则返回 `NULL`。 +要保持先前的行为,请将设置 `least_greatest_legacy_null_behavior`(默认值:`false`)设为 `true`。 +::: + + +**语法** + +```sql +least(x1[, x2, ...]) +``` + +**参数** + +- `x1[, x2, ...]` — 一个单独的值或多个值进行比较。所有参数必须是可比较类型。[`Any`](/sql-reference/data-types) + + +**返回值** + +返回参数中的最小值,并提升为最大兼容类型。[`Any`](/sql-reference/data-types) + +**示例** + +**数字类型** + +```sql title=Query +SELECT least(1, 2, toUInt8(3), 3.) AS result, toTypeName(result) AS type; +-- The type returned is a Float64 as the UInt8 must be promoted to 64 bit for the comparison. +``` + +```response title=Response +┌─result─┬─type────┐ +│ 1 │ Float64 │ +└────────┴─────────┘ +``` + +**数组** + +```sql title=Query +SELECT least(['hello'], ['there'], ['world']); +``` + +```response title=Response +┌─least(['hell⋯ ['world'])─┐ +│ ['hello'] │ +└──────────────────────────┘ +``` + +**DateTime 类型** + +```sql title=Query +SELECT least(toDateTime32(now() + toIntervalDay(1)), toDateTime64(now(), 3)); +-- The type returned is a DateTime64 as the DateTime32 must be promoted to 64 bit for the comparison. +``` + +```response title=Response +┌─least(toDate⋯(now(), 3))─┐ +│ 2025-05-27 15:55:20.000 │ +└──────────────────────────┘ +``` + + + +## multiIf {#multiIf} + +引入于:v1.1 + + +允许在查询中以更紧凑的方式编写 [`CASE`](/sql-reference/operators#conditional-expression) 操作符。 +按顺序评估每个条件。对于第一个为真(非零且不为 `NULL`)的条件,返回相应的分支值。 +如果没有条件为真,则返回 `else` 值。 + +设置 [`short_circuit_function_evaluation`](/operations/settings/settings#short_circuit_function_evaluation) 控制是否使用短路求值。如果启用,`then_i` 表达式仅在 `((NOT cond_1) AND ... AND (NOT cond_{i-1}) AND cond_i)` 为真时在行上进行评估。 + +例如,使用短路求值时,执行以下查询时不会引发除零异常: + +```sql +SELECT multiIf(number = 2, intDiv(1, number), number = 5) FROM numbers(10) +``` + +所有分支和 else 表达式必须具有共同的超类型。 `NULL` 条件被视为假。 + + +**语法** + +```sql +multiIf(cond_1, then_1, cond_2, then_2, ..., else) +``` + +**参数** + +- `cond_N` — 第 N 个被评估的条件,控制是否返回 `then_N`。[`UInt8`](/sql-reference/data-types/int-uint) 或 [`Nullable(UInt8)`](/sql-reference/data-types/nullable) 或 [`NULL`](/sql-reference/syntax#null) +- `then_N` — 当 `cond_N` 为真时函数的结果。 - `else` — 如果没有条件为真,则函数的结果。 + +**返回值** + +返回匹配 `cond_N` 的 `then_N` 的结果,否则返回 `else` 条件。 + +**示例** + +**示例用法** + +```sql title=Query +CREATE TABLE LEFT_RIGHT (left Nullable(UInt8), right Nullable(UInt8)) ENGINE = Memory; +INSERT INTO LEFT_RIGHT VALUES (NULL, 4), (1, 3), (2, 2), (3, 1), (4, NULL); + +SELECT + left, + right, + multiIf(left < right, 'left is smaller', left > right, 'left is greater', left = right, 'Both equal', 'Null value') AS result +FROM LEFT_RIGHT; +``` + +```response title=Response +┌─left─┬─right─┬─result──────────┐ +│ ᴺᵁᴸᴸ │ 4 │ Null value │ +│ 1 │ 3 │ left is smaller │ +│ 2 │ 2 │ Both equal │ +│ 3 │ 1 │ left is greater │ +│ 4 │ ᴺᵁᴸᴸ │ Null value │ +└──────┴───────┴─────────────────┘ +``` + + + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/conditional-functions.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/conditional-functions.md.hash index ca38e720755..c86dc7eeb3b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/conditional-functions.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/conditional-functions.md.hash @@ -1 +1 @@ -8f9fcc45b155548d +cbac41ffaa372b36 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/date-time-functions.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/date-time-functions.md index 2a5ac9b2d3f..737855addc4 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/date-time-functions.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/date-time-functions.md @@ -1,13 +1,12 @@ --- 'description': '处理日期和时间的函数的文档' 'sidebar_label': '日期和时间' -'sidebar_position': 45 'slug': '/sql-reference/functions/date-time-functions' 'title': '处理日期和时间的函数' +'doc_type': 'reference' --- - # 处理日期和时间的函数 本节中的大多数函数接受一个可选的时区参数,例如 `Europe/Amsterdam`。在这种情况下,时区是指定的,而不是本地(默认)时区。 @@ -27,4836 +26,5426 @@ SELECT │ 2016-06-15 23:00:00 │ 2016-06-15 │ 2016-06-16 │ 2016-06-15 09:00:00 │ └─────────────────────┴────────────┴────────────┴─────────────────────┘ ``` -## makeDate {#makedate} -从年份、月份和日期参数创建一个 [Date](../data-types/date.md) -- 从年份、月份和日期参数,或 -- 从年份和年份中的日期参数。 + + + +## UTCTimestamp {#UTCTimestamp} + +引入于:v22.11 + + +返回查询分析时的当前日期和时间。该函数是一个常量表达式。 + +这个函数给出的结果与 `now('UTC')` 相同。该函数仅为支持 MySQL 而添加。[`now`](#now) 是推荐的用法。 + **语法** ```sql -makeDate(year, month, day); -makeDate(year, day_of_year); +UTCTimestamp() ``` -别名: -- `MAKEDATE(year, month, day);` -- `MAKEDATE(year, day_of_year);` - **参数** -- `year` — 年。 [Integer](../data-types/int-uint.md)、[Float](../data-types/float.md) 或 [Decimal](../data-types/decimal.md)。 -- `month` — 月。 [Integer](../data-types/int-uint.md)、[Float](../data-types/float.md) 或 [Decimal](../data-types/decimal.md)。 -- `day` — 日。 [Integer](../data-types/int-uint.md)、[Float](../data-types/float.md) 或 [Decimal](../data-types/decimal.md)。 -- `day_of_year` — 年中的日期。 [Integer](../data-types/int-uint.md)、[Float](../data-types/float.md) 或 [Decimal](../data-types/decimal.md)。 - +- 无。 **返回值** -- 从参数创建的日期。 [Date](../data-types/date.md)。 +返回查询分析时的当前日期和时间。 [`DateTime`](/sql-reference/data-types/datetime) **示例** -从年份、月份和日期创建一个日期: - -```sql -SELECT makeDate(2023, 2, 28) AS Date; -``` +**获取当前 UTC 时间戳** -结果: - -```text -┌───────date─┐ -│ 2023-02-28 │ -└────────────┘ +```sql title=Query +SELECT UTCTimestamp() ``` -从年份和年份中的日期参数创建一个日期: - -```sql -SELECT makeDate(2023, 42) AS Date; +```response title=Response +┌──────UTCTimestamp()─┐ +│ 2024-05-28 08:32:09 │ +└─────────────────────┘ ``` +## YYYYMMDDToDate {#YYYYMMDDToDate} -结果: +引入于:v23.9 -```text -┌───────date─┐ -│ 2023-02-11 │ -└────────────┘ -``` -## makeDate32 {#makedate32} -从年份、月份、日(或可选的年份和一天)创建一个 [Date32](../../sql-reference/data-types/date32.md) 类型的值。 +将包含年份、月份和日期的数字转换为一个 `Date`。 +此函数是函数 [`toYYYYMMDD()`](/sql-reference/functions/date-time-functions#toYYYYMMDD) 的反向操作。 +如果输入不编码有效的日期值,则输出未定义。 + **语法** ```sql -makeDate32(year, [month,] day) +YYYYMMDDToDate(YYYYMMDD) ``` **参数** -- `year` — 年。 [Integer](../../sql-reference/data-types/int-uint.md)、[Float](../../sql-reference/data-types/float.md) 或 [Decimal](../../sql-reference/data-types/decimal.md)。 -- `month` — 月(可选)。 [Integer](../../sql-reference/data-types/int-uint.md)、[Float](../../sql-reference/data-types/float.md) 或 [Decimal](../../sql-reference/data-types/decimal.md)。 -- `day` — 日。 [Integer](../../sql-reference/data-types/int-uint.md)、[Float](../../sql-reference/data-types/float.md) 或 [Decimal](../../sql-reference/data-types/decimal.md)。 +- `YYYYMMDD` — 包含年份、月份和日期的数字。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal`](/sql-reference/data-types/decimal) -:::note -如果省略 `month`,则 `day` 应取值在 `1` 到 `365` 之间,否则它应取值在 `1` 到 `31` 之间。 -::: **返回值** -- 从参数创建的日期。 [Date32](../../sql-reference/data-types/date32.md)。 +根据提供的参数返回一个 `Date` 值 [`Date`](/sql-reference/data-types/date) **示例** -从年份、月份和日期创建一个日期: - -查询: - -```sql -SELECT makeDate32(2024, 1, 1); -``` - -结果: +**示例** -```response -2024-01-01 +```sql title=Query +SELECT YYYYMMDDToDate(20230911); ``` -从年份和年份中的日期创建一个日期: - -查询: - -```sql -SELECT makeDate32(2024, 100); +```response title=Response +┌─toYYYYMMDD(20230911)─┐ +│ 2023-09-11 │ +└──────────────────────┘ ``` +## YYYYMMDDToDate32 {#YYYYMMDDToDate32} -结果: +引入于:v23.9 -```response -2024-04-09 -``` -## makeDateTime {#makedatetime} -从年份、月份、日、小时、分钟和秒参数创建一个 [DateTime](../data-types/datetime.md)。 +将包含年份、月份和日期的数字转换为一个 `Date32`。 +此函数是函数 [`toYYYYMMDD()`](/sql-reference/functions/date-time-functions#toYYYYMMDD) 的反向操作。 +如果输入不编码有效的 `Date32` 值,则输出未定义。 + **语法** ```sql -makeDateTime(year, month, day, hour, minute, second[, timezone]) +YYYYMMDDToDate32(YYYYMMDD) ``` **参数** -- `year` — 年。 [Integer](../data-types/int-uint.md)、[Float](../data-types/float.md) 或 [Decimal](../data-types/decimal.md)。 -- `month` — 月。 [Integer](../data-types/int-uint.md)、[Float](../data-types/float.md) 或 [Decimal](../data-types/decimal.md)。 -- `day` — 日。 [Integer](../data-types/int-uint.md)、[Float](../data-types/float.md) 或 [Decimal](../data-types/decimal.md)。 -- `hour` — 时。 [Integer](../data-types/int-uint.md)、[Float](../data-types/float.md) 或 [Decimal](../data-types/decimal.md)。 -- `minute` — 分。 [Integer](../data-types/int-uint.md)、[Float](../data-types/float.md) 或 [Decimal](../data-types/decimal.md)。 -- `second` — 秒。 [Integer](../data-types/int-uint.md)、[Float](../data-types/float.md) 或 [Decimal](../data-types/decimal.md)。 -- `timezone` — [Timezone](../../operations/server-configuration-parameters/settings.md#timezone) 用于返回值(可选)。 +- `YYYYMMDD` — 包含年份、月份和日期的数字。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal`](/sql-reference/data-types/decimal) + **返回值** -- 从参数创建的日期和时间。 [DateTime](../data-types/datetime.md)。 +根据提供的参数返回一个 `Date32` 值 [`Date32`](/sql-reference/data-types/date32) **示例** -```sql -SELECT makeDateTime(2023, 2, 28, 17, 12, 33) AS DateTime; -``` +**示例** -结果: +```sql title=Query +SELECT YYYYMMDDToDate32(20000507); +``` -```text -┌────────────DateTime─┐ -│ 2023-02-28 17:12:33 │ -└─────────────────────┘ +```response title=Response +┌─YYYYMMDDToDate32(20000507)─┐ +│ 2000-05-07 │ +└────────────────────────────┘ ``` -## makeDateTime64 {#makedatetime64} +## YYYYMMDDhhmmssToDateTime {#YYYYMMDDhhmmssToDateTime} + +引入于:v23.9 -从其组件(年、月、日、小时、分钟、秒)创建一个 [DateTime64](../../sql-reference/data-types/datetime64.md) 数据类型值。具有可选的亚秒精度。 + +将包含年份、月份、日期、小时、分钟和秒的数字转换为一个 `DateTime`。 +此函数是函数 [`toYYYYMMDDhhmmss()`](/sql-reference/functions/date-time-functions#toYYYYMMDDhhmmss) 的反向操作。 +如果输入不编码有效的 `DateTime` 值,则输出未定义。 + **语法** ```sql -makeDateTime64(year, month, day, hour, minute, second[, precision]) +YYYYMMDDhhmmssToDateTime(YYYYMMDDhhmmss[, timezone]) ``` **参数** -- `year` — 年(0-9999)。 [Integer](../../sql-reference/data-types/int-uint.md)、[Float](../../sql-reference/data-types/float.md) 或 [Decimal](../../sql-reference/data-types/decimal.md)。 -- `month` — 月(1-12)。 [Integer](../../sql-reference/data-types/int-uint.md)、[Float](../../sql-reference/data-types/float.md) 或 [Decimal](../../sql-reference/data-types/decimal.md)。 -- `day` — 日(1-31)。 [Integer](../../sql-reference/data-types/int-uint.md)、[Float](../../sql-reference/data-types/float.md) 或 [Decimal](../../sql-reference/data-types/decimal.md)。 -- `hour` — 时(0-23)。 [Integer](../../sql-reference/data-types/int-uint.md)、[Float](../../sql-reference/data-types/float.md) 或 [Decimal](../../sql-reference/data-types/decimal.md)。 -- `minute` — 分(0-59)。 [Integer](../../sql-reference/data-types/int-uint.md)、[Float](../../sql-reference/data-types/float.md) 或 [Decimal](../../sql-reference/data-types/decimal.md)。 -- `second` — 秒(0-59)。 [Integer](../../sql-reference/data-types/int-uint.md)、[Float](../../sql-reference/data-types/float.md) 或 [Decimal](../../sql-reference/data-types/decimal.md)。 -- `precision` — 亚秒组成部分的可选精度(0-9)。 [Integer](../../sql-reference/data-types/int-uint.md)。 +- `YYYYMMDDhhmmss` — 包含年份、月份、日期、小时、分钟和秒的数字。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal`](/sql-reference/data-types/decimal) +- `timezone` — 时区名称。 [`String`](/sql-reference/data-types/string) + **返回值** -- 从提供的参数创建的日期和时间。 [DateTime64](../../sql-reference/data-types/datetime64.md)。 +根据提供的参数返回一个 `DateTime` 值 [`DateTime`](/sql-reference/data-types/datetime) **示例** -```sql -SELECT makeDateTime64(2023, 5, 15, 10, 30, 45, 779, 5); +**示例** + +```sql title=Query +SELECT YYYYMMDDToDateTime(20230911131415); ``` -```response -┌─makeDateTime64(2023, 5, 15, 10, 30, 45, 779, 5)─┐ -│ 2023-05-15 10:30:45.00779 │ -└─────────────────────────────────────────────────┘ +```response title=Response +┌──────YYYYMMDDhhmmssToDateTime(20230911131415)─┐ +│ 2023-09-11 13:14:15 │ +└───────────────────────────────────────────────┘ ``` -## timestamp {#timestamp} +## YYYYMMDDhhmmssToDateTime64 {#YYYYMMDDhhmmssToDateTime64} -将第一个参数 'expr' 转换为 [DateTime64(6)](../data-types/datetime64.md) 类型。 -如果提供了第二个参数 'expr_time',则将指定的时间添加到转换值。 +引入于:v23.9 + + +将包含年份、月份、日期、小时、分钟和秒的数字转换为一个 `DateTime64`。 +此函数是函数 [`toYYYYMMDDhhmmss()`](/sql-reference/functions/date-time-functions#toYYYYMMDDhhmmss) 的反向操作。 +如果输入不编码有效的 `DateTime64` 值,则输出未定义。 + **语法** ```sql -timestamp(expr[, expr_time]) +YYYYMMDDhhmmssToDateTime64(YYYYMMDDhhmmss[, precision[, timezone]]) ``` -别名: `TIMESTAMP` - **参数** -- `expr` - 日期或日期时间。 [String](../data-types/string.md)。 -- `expr_time` - 可选参数。 要添加的时间。 [String](../data-types/string.md)。 +- `YYYYMMDDhhmmss` — 包含年份、月份、日期、小时、分钟和秒的数字。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal`](/sql-reference/data-types/decimal) +- `precision` — 小数部分的精度(0-9)。 [`UInt8`](/sql-reference/data-types/int-uint) +- `timezone` — 时区名称。 [`String`](/sql-reference/data-types/string) -**示例** -```sql -SELECT timestamp('2023-12-31') as ts; -``` +**返回值** -结果: +根据提供的参数返回一个 `DateTime64` 值 [`DateTime64`](/sql-reference/data-types/datetime64) -```text -┌─────────────────────────ts─┐ -│ 2023-12-31 00:00:00.000000 │ -└────────────────────────────┘ -``` +**示例** -```sql -SELECT timestamp('2023-12-31 12:00:00', '12:00:00.11') as ts; -``` +**示例** -结果: +```sql title=Query +SELECT YYYYMMDDhhmmssToDateTime64(20230911131415, 3, 'Asia/Istanbul'); +``` -```text -┌─────────────────────────ts─┐ -│ 2024-01-01 00:00:00.110000 │ -└────────────────────────────┘ +```response title=Response +┌─YYYYMMDDhhmm⋯/Istanbul')─┐ +│ 2023-09-11 13:14:15.000 │ +└──────────────────────────┘ ``` +## addDate {#addDate} -**返回值** +引入于:v23.9 -- [DateTime64](../data-types/datetime64.md)(6) -## timeZone {#timezone} -返回当前会话的时区,即设定值 [session_timezone](../../operations/settings/settings.md#session_timezone) 的值。 -如果在分布式表的上下文中执行此函数,则生成一个正常列,其值与每个分片相关,否则返回一个常量值。 +将时间间隔添加到指定的日期、日期和时间或字符串编码的日期或日期和时间中。 +如果添加的结果超出数据类型的边界,则结果未定义。 + **语法** ```sql -timeZone() +addDate(datetime, interval) ``` -别名: `timezone`。 +**参数** + +- `datetime` — 将要添加 `interval` 的日期或带时间的日期。 [`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) 或 [`String`](/sql-reference/data-types/string) +- `interval` — 要添加的时间间隔。 [`Interval`](/sql-reference/data-types/int-uint) + **返回值** -- 时区。 [String](../data-types/string.md)。 +返回通过将 `interval` 添加到 `datetime` 得到的日期或带时间的日期。 [`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) **示例** -```sql -SELECT timezone() -``` +**向日期添加时间间隔** -结果: +```sql title=Query +SELECT addDate(toDate('2018-01-01'), INTERVAL 3 YEAR) +``` -```response -┌─timezone()─────┐ -│ America/Denver │ -└────────────────┘ +```response title=Response +┌─addDate(toDa⋯valYear(3))─┐ +│ 2021-01-01 │ +└──────────────────────────┘ ``` +## addDays {#addDays} -**另见** +引入于:v1.1 -- [serverTimeZone](#servertimezone) -## serverTimeZone {#servertimezone} -返回服务器的时区,即设定值 [timezone](../../operations/server-configuration-parameters/settings.md#timezone) 的值。 -如果在分布式表的上下文中执行此函数,则生成一个正常列,其值与每个分片相关。否则,返回一个常量值。 +将指定数量的天数添加到日期、带时间的日期或字符串编码的日期或带时间的日期中。 + **语法** ```sql -serverTimeZone() +addDays(datetime, num) ``` -别名: `serverTimezone`。 +**参数** + +- `datetime` — 要添加指定天数的日期或带时间的日期。 [`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) 或 [`String`](/sql-reference/data-types/string) +- `num` — 要添加的天数。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) + **返回值** -- 时区。 [String](../data-types/string.md)。 +返回 `datetime` 加 `num` 天后的结果。 [`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) **示例** -```sql -SELECT serverTimeZone() +**向不同日期类型添加天数** + +```sql title=Query +WITH + toDate('2024-01-01') AS date, + toDateTime('2024-01-01 00:00:00') AS date_time, + '2024-01-01 00:00:00' AS date_time_string +SELECT + addDays(date, 5) AS add_days_with_date, + addDays(date_time, 5) AS add_days_with_date_time, + addDays(date_time_string, 5) AS add_days_with_date_time_string ``` -结果: +```response title=Response +┌─add_days_with_date─┬─add_days_with_date_time─┬─add_days_with_date_time_string─┐ +│ 2024-01-06 │ 2024-01-06 00:00:00 │ 2024-01-06 00:00:00.000 │ +└────────────────────┴─────────────────────────┴────────────────────────────────┘ +``` -```response -┌─serverTimeZone()─┐ -│ UTC │ -└──────────────────┘ +**使用替代的 INTERVAL 语法** + +```sql title=Query +SELECT dateAdd('1998-06-16'::Date, INTERVAL 10 day) +``` + +```response title=Response +┌─plus(CAST('1⋯valDay(10))─┐ +│ 1998-06-26 │ +└──────────────────────────┘ ``` +## addHours {#addHours} -**另见** +引入于:v1.1 -- [timeZone](#timezone) -## toTimeZone {#totimezone} -将日期或日期时间转换为指定的时区。并不改变数据的内部值(unix秒数),只改变值的时区属性和字符串表示。 +将指定数量的小时添加到日期、带时间的日期或字符串编码的日期或带时间的日期中。 + **语法** ```sql -toTimezone(value, timezone) +addHours(datetime, num) ``` -别名: `toTimezone`。 - **参数** -- `value` — 时间或日期和时间。 [DateTime64](../data-types/datetime64.md)。 -- `timezone` — 返回值的时区。 [String](../data-types/string.md)。 这个参数是常量,因为 `toTimezone` 改变列的时区(timezone是 `DateTime*` 类型的属性)。 +- `datetime` — 要添加指定小时数的日期或带时间的日期。 [`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) 或 [`String`](/sql-reference/data-types/string) +- `num` — 要添加的小时数。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) + **返回值** -- 日期和时间。 [DateTime](../data-types/datetime.md)。 +返回 `datetime` 加 `num` 小时后的结果 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64(3)`](/sql-reference/data-types/datetime64) **示例** -```sql -SELECT toDateTime('2019-01-01 00:00:00', 'UTC') AS time_utc, - toTypeName(time_utc) AS type_utc, - toInt32(time_utc) AS int32utc, - toTimeZone(time_utc, 'Asia/Yekaterinburg') AS time_yekat, - toTypeName(time_yekat) AS type_yekat, - toInt32(time_yekat) AS int32yekat, - toTimeZone(time_utc, 'US/Samoa') AS time_samoa, - toTypeName(time_samoa) AS type_samoa, - toInt32(time_samoa) AS int32samoa -FORMAT Vertical; +**向不同日期类型添加小时** + +```sql title=Query +WITH + toDate('2024-01-01') AS date, + toDateTime('2024-01-01 00:00:00') AS date_time, + '2024-01-01 00:00:00' AS date_time_string +SELECT + addHours(date, 12) AS add_hours_with_date, + addHours(date_time, 12) AS add_hours_with_date_time, + addHours(date_time_string, 12) AS add_hours_with_date_time_string ``` -结果: +```response title=Response +┌─add_hours_with_date─┬─add_hours_with_date_time─┬─add_hours_with_date_time_string─┐ +│ 2024-01-01 12:00:00 │ 2024-01-01 12:00:00 │ 2024-01-01 12:00:00.000 │ +└─────────────────────┴──────────────────────────┴─────────────────────────────────┘ +``` -```text -Row 1: -────── -time_utc: 2019-01-01 00:00:00 -type_utc: DateTime('UTC') -int32utc: 1546300800 -time_yekat: 2019-01-01 05:00:00 -type_yekat: DateTime('Asia/Yekaterinburg') -int32yekat: 1546300800 -time_samoa: 2018-12-31 13:00:00 -type_samoa: DateTime('US/Samoa') -int32samoa: 1546300800 +**使用替代的 INTERVAL 语法** + +```sql title=Query +SELECT dateAdd('1998-06-16'::Date, INTERVAL 10 hour) +``` + +```response title=Response +┌─plus(CAST('1⋯alHour(10))─┐ +│ 1998-06-16 10:00:00 │ +└──────────────────────────┘ ``` +## addInterval {#addInterval} -**另见** +引入于:v22.11 -- [formatDateTime](#formatdatetime) - 支持非恒定时区。 -- [toString](type-conversion-functions.md#tostring) - 支持非恒定时区。 -## timeZoneOf {#timezoneof} -返回 [DateTime](../data-types/datetime.md) 或 [DateTime64](../data-types/datetime64.md) 数据类型的时区名称。 +将一个间隔添加到另一个间隔或间隔元组中。 + +:::note +相同类型的间隔将组合成一个单一的间隔。例如,如果传入 `toIntervalDay(1)` 和 `toIntervalDay(2)`,则结果将是 `(3)` 而不是 `(1,1)`。 +::: + **语法** ```sql -timeZoneOf(value) +addInterval(interval_1, interval_2) ``` -别名: `timezoneOf`。 - **参数** -- `value` — 日期和时间。 [DateTime](../data-types/datetime.md) 或 [DateTime64](../data-types/datetime64.md)。 +- `interval_1` — 第一个间隔或间隔元组。 [`Interval`](/sql-reference/data-types/int-uint) 或 [`Tuple(Interval)`](/sql-reference/data-types/tuple) +- `interval_2` — 要添加的第二个间隔。 [`Interval`](/sql-reference/data-types/int-uint) + **返回值** -- 时区名称。 [String](../data-types/string.md)。 +返回一个间隔元组 [`Tuple(Interval)`](/sql-reference/data-types/tuple) **示例** -```sql -SELECT timezoneOf(now()); +**添加间隔** + +```sql title=Query +SELECT addInterval(INTERVAL 1 DAY, INTERVAL 1 MONTH); +SELECT addInterval((INTERVAL 1 DAY, INTERVAL 1 YEAR), INTERVAL 1 MONTH); +SELECT addInterval(INTERVAL 2 DAY, INTERVAL 1 DAY) ``` -结果: -```text -┌─timezoneOf(now())─┐ -│ Etc/UTC │ -└───────────────────┘ +```response title=Response +┌─addInterval(toIntervalDay(1), toIntervalMonth(1))─┐ +│ (1,1) │ +└───────────────────────────────────────────────────┘ +┌─addInterval((toIntervalDay(1), toIntervalYear(1)), toIntervalMonth(1))─┐ +│ (1,1,1) │ +└────────────────────────────────────────────────────────────────────────┘ +┌─addInterval(toIntervalDay(2), toIntervalDay(1))─┐ +│ (3) │ +└─────────────────────────────────────────────────┘ ``` -## timeZoneOffset {#timezoneoffset} +## addMicroseconds {#addMicroseconds} + +引入于:v22.6 -返回与 [UTC](https://en.wikipedia.org/wiki/Coordinated_Universal_Time) 的时区偏移(以秒为单位)。 -该函数考虑了 [夏令时](https://en.wikipedia.org/wiki/Daylight_saving_time) 和指定日期时间的历史时区变化。 -使用 [IANA 时区数据库](https://www.iana.org/time-zones) 计算偏移。 + +将指定数量的微秒添加到带时间的日期或字符串编码的带时间的日期中。 + **语法** ```sql -timeZoneOffset(value) +addMicroseconds(datetime, num) ``` -别名: `timezoneOffset`。 - **参数** -- `value` — 日期和时间。 [DateTime](../data-types/datetime.md) 或 [DateTime64](../data-types/datetime64.md)。 +- `datetime` — 要添加指定数量微秒的带时间的日期。 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) 或 [`String`](/sql-reference/data-types/string) +- `num` — 要添加的微秒数。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) + **返回值** -- 与 UTC 的偏移(以秒为单位)。 [Int32](../data-types/int-uint.md)。 +返回 `date_time` 加 `num` 微秒后的结果 [`DateTime64`](/sql-reference/data-types/datetime64) **示例** -```sql -SELECT toDateTime('2021-04-21 10:20:30', 'America/New_York') AS Time, toTypeName(Time) AS Type, - timeZoneOffset(Time) AS Offset_in_seconds, (Offset_in_seconds / 3600) AS Offset_in_hours; -``` - -结果: +**向不同的日期时间类型添加微秒** -```text -┌────────────────Time─┬─Type─────────────────────────┬─Offset_in_seconds─┬─Offset_in_hours─┐ -│ 2021-04-21 10:20:30 │ DateTime('America/New_York') │ -14400 │ -4 │ -└─────────────────────┴──────────────────────────────┴───────────────────┴─────────────────┘ +```sql title=Query +WITH + toDateTime('2024-01-01 00:00:00') AS date_time, + '2024-01-01 00:00:00' AS date_time_string +SELECT + addMicroseconds(date_time, 1000000) AS add_microseconds_with_date_time, + addMicroseconds(date_time_string, 1000000) AS add_microseconds_with_date_time_string ``` -## toYear {#toyear} -返回日期或日期时间的年份成分(公元)。 - -**语法** - -```sql -toYear(value) +```response title=Response +┌─add_microseconds_with_date_time─┬─add_microseconds_with_date_time_string─┐ +│ 2024-01-01 00:00:01.000000 │ 2024-01-01 00:00:01.000000 │ +└─────────────────────────────────┴────────────────────────────────────────┘ ``` -别名: `YEAR` - -**参数** - -- `value` - [Date](../data-types/date.md)、[Date32](../data-types/date32.md)、[DateTime](../data-types/datetime.md) 或 [DateTime64](../data-types/datetime64.md) - -**返回值** +**使用替代的 INTERVAL 语法** -- 所给日期/时间的年份。 [UInt16](../data-types/int-uint.md)。 - -**示例** +```sql title=Query +SELECT dateAdd('1998-06-16'::DateTime, INTERVAL 10 microsecond) +``` -```sql -SELECT toYear(toDateTime('2023-04-21 10:20:30')) +```response title=Response +┌─plus(CAST('19⋯osecond(10))─┐ +│ 1998-06-16 00:00:00.000010 │ +└────────────────────────────┘ ``` +## addMilliseconds {#addMilliseconds} -结果: +引入于:v22.6 -```response -┌─toYear(toDateTime('2023-04-21 10:20:30'))─┐ -│ 2023 │ -└───────────────────────────────────────────┘ -``` -## toQuarter {#toquarter} -返回日期或日期时间的季度(1-4)。 +将指定数量的毫秒添加到带时间的日期或字符串编码的带时间的日期中。 + **语法** ```sql -toQuarter(value) +addMilliseconds(datetime, num) ``` -别名: `QUARTER` - **参数** -- `value` - [Date](../data-types/date.md)、[Date32](../data-types/date32.md)、[DateTime](../data-types/datetime.md) 或 [DateTime64](../data-types/datetime64.md) +- `datetime` — 要添加指定数量毫秒的带时间的日期。 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) 或 [`String`](/sql-reference/data-types/string) +- `num` — 要添加的毫秒数。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) + **返回值** -- 所给日期/时间的季度(1、2、3 或 4)。 [UInt8](../data-types/int-uint.md)。 +返回 `datetime` 加 `num` 毫秒后的结果 [`DateTime64`](/sql-reference/data-types/datetime64) **示例** -```sql -SELECT toQuarter(toDateTime('2023-04-21 10:20:30')) +**向不同的日期时间类型添加毫秒** + +```sql title=Query +WITH + toDateTime('2024-01-01 00:00:00') AS date_time, + '2024-01-01 00:00:00' AS date_time_string +SELECT + addMilliseconds(date_time, 1000) AS add_milliseconds_with_date_time, + addMilliseconds(date_time_string, 1000) AS add_milliseconds_with_date_time_string ``` -结果: +```response title=Response +┌─add_milliseconds_with_date_time─┬─add_milliseconds_with_date_time_string─┐ +│ 2024-01-01 00:00:01.000 │ 2024-01-01 00:00:01.000 │ +└─────────────────────────────────┴────────────────────────────────────────┘ +``` -```response -┌─toQuarter(toDateTime('2023-04-21 10:20:30'))─┐ -│ 2 │ -└──────────────────────────────────────────────┘ +**使用替代的 INTERVAL 语法** + +```sql title=Query +SELECT dateAdd('1998-06-16'::DateTime, INTERVAL 10 millisecond) ``` -## toMonth {#tomonth} -返回日期或日期时间的月份成分(1-12)。 +```response title=Response +┌─plus(CAST('1⋯second(10))─┐ +│ 1998-06-16 00:00:00.010 │ +└──────────────────────────┘ +``` +## addMinutes {#addMinutes} + +引入于:v1.1 + + +将指定数量的分钟添加到日期、带时间的日期或字符串编码的日期或带时间的日期中。 + **语法** ```sql -toMonth(value) +addMinutes(datetime, num) ``` -别名: `MONTH` - **参数** -- `value` - [Date](../data-types/date.md)、[Date32](../data-types/date32.md)、[DateTime](../data-types/datetime.md) 或 [DateTime64](../data-types/datetime64.md) +- `datetime` — 要添加指定分钟数的日期或带时间的日期。 [`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) 或 [`String`](/sql-reference/data-types/string) +- `num` — 要添加的分钟数。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) + **返回值** -- 所给日期/时间的月份(1 - 12)。 [UInt8](../data-types/int-uint.md)。 +返回 `datetime` 加 `num` 分钟后的结果 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64(3)`](/sql-reference/data-types/datetime64) **示例** -```sql -SELECT toMonth(toDateTime('2023-04-21 10:20:30')) +**向不同日期类型添加分钟** + +```sql title=Query +WITH + toDate('2024-01-01') AS date, + toDateTime('2024-01-01 00:00:00') AS date_time, + '2024-01-01 00:00:00' AS date_time_string +SELECT + addMinutes(date, 20) AS add_minutes_with_date, + addMinutes(date_time, 20) AS add_minutes_with_date_time, + addMinutes(date_time_string, 20) AS add_minutes_with_date_time_string ``` -结果: +```response title=Response +┌─add_minutes_with_date─┬─add_minutes_with_date_time─┬─add_minutes_with_date_time_string─┐ +│ 2024-01-01 00:20:00 │ 2024-01-01 00:20:00 │ 2024-01-01 00:20:00.000 │ +└───────────────────────┴────────────────────────────┴───────────────────────────────────┘ +``` -```response -┌─toMonth(toDateTime('2023-04-21 10:20:30'))─┐ -│ 4 │ -└────────────────────────────────────────────┘ +**使用替代的 INTERVAL 语法** + +```sql title=Query +SELECT dateAdd('1998-06-16'::Date, INTERVAL 10 minute) +``` + +```response title=Response +┌─plus(CAST('1⋯Minute(10))─┐ +│ 1998-06-16 00:10:00 │ +└──────────────────────────┘ ``` -## toDayOfYear {#todayofyear} +## addMonths {#addMonths} + +引入于:v1.1 -返回日期或日期时间在年内的天数(1-366)。 + +将指定数量的月份添加到日期、带时间的日期或字符串编码的日期或带时间的日期中。 + **语法** ```sql -toDayOfYear(value) +addMonths(datetime, num) ``` -别名: `DAYOFYEAR` - **参数** -- `value` - [Date](../data-types/date.md)、[Date32](../data-types/date32.md)、[DateTime](../data-types/datetime.md) 或 [DateTime64](../data-types/datetime64.md) +- `datetime` — 要添加指定月份数的日期或带时间的日期。 [`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) 或 [`String`](/sql-reference/data-types/string) +- `num` — 要添加的月份数。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) + **返回值** -- 所给日期/时间的天数(1 - 366)。 [UInt16](../data-types/int-uint.md)。 +返回 `datetime` 加 `num` 月份后的结果 [`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) **示例** -```sql -SELECT toDayOfYear(toDateTime('2023-04-21 10:20:30')) +**向不同日期类型添加月份** + +```sql title=Query +WITH + toDate('2024-01-01') AS date, + toDateTime('2024-01-01 00:00:00') AS date_time, + '2024-01-01 00:00:00' AS date_time_string +SELECT + addMonths(date, 6) AS add_months_with_date, + addMonths(date_time, 6) AS add_months_with_date_time, + addMonths(date_time_string, 6) AS add_months_with_date_time_string +``` + +```response title=Response +┌─add_months_with_date─┬─add_months_with_date_time─┬─add_months_with_date_time_string─┐ +│ 2024-07-01 │ 2024-07-01 00:00:00 │ 2024-07-01 00:00:00.000 │ +└──────────────────────┴───────────────────────────┴──────────────────────────────────┘ ``` -结果: +**使用替代的 INTERVAL 语法** -```response -┌─toDayOfYear(toDateTime('2023-04-21 10:20:30'))─┐ -│ 111 │ -└────────────────────────────────────────────────┘ +```sql title=Query +SELECT dateAdd('1998-06-16'::Date, INTERVAL 10 month) ``` -## toDayOfMonth {#todayofmonth} -返回日期或日期时间在月份中的天数(1-31)。 +```response title=Response +┌─plus(CAST('1⋯lMonth(10))─┐ +│ 1999-04-16 │ +└──────────────────────────┘ +``` +## addNanoseconds {#addNanoseconds} + +引入于:v22.6 + + +将指定数量的纳秒添加到带时间的日期或字符串编码的带时间的日期中。 + **语法** ```sql -toDayOfMonth(value) +addNanoseconds(datetime, num) ``` -别名: `DAYOFMONTH`、`DAY` - **参数** -- `value` - [Date](../data-types/date.md)、[Date32](../data-types/date32.md)、[DateTime](../data-types/datetime.md) 或 [DateTime64](../data-types/datetime64.md) +- `datetime` — 要添加指定数量纳秒的带时间的日期。 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) 或 [`String`](/sql-reference/data-types/string) +- `num` — 要添加的纳秒数。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) + **返回值** -- 所给日期/时间的天数(1 - 31)。 [UInt8](../data-types/int-uint.md)。 +返回 `datetime` 加 `num` 纳秒后的结果 [`DateTime64`](/sql-reference/data-types/datetime64) **示例** -```sql -SELECT toDayOfMonth(toDateTime('2023-04-21 10:20:30')) +**向不同的日期时间类型添加纳秒** + +```sql title=Query +WITH + toDateTime('2024-01-01 00:00:00') AS date_time, + '2024-01-01 00:00:00' AS date_time_string +SELECT + addNanoseconds(date_time, 1000) AS add_nanoseconds_with_date_time, + addNanoseconds(date_time_string, 1000) AS add_nanoseconds_with_date_time_string +``` + +```response title=Response +┌─add_nanoseconds_with_date_time─┬─add_nanoseconds_with_date_time_string─┐ +│ 2024-01-01 00:00:00.000001000 │ 2024-01-01 00:00:00.000001000 │ +└────────────────────────────────┴───────────────────────────────────────┘ ``` -结果: +**使用替代的 INTERVAL 语法** -```response -┌─toDayOfMonth(toDateTime('2023-04-21 10:20:30'))─┐ -│ 21 │ -└─────────────────────────────────────────────────┘ +```sql title=Query +SELECT dateAdd('1998-06-16'::DateTime, INTERVAL 1000 nanosecond) ``` -## toDayOfWeek {#todayofweek} -返回日期或日期时间在周内的天数。 +```response title=Response +┌─plus(CAST('199⋯osecond(1000))─┐ +│ 1998-06-16 00:00:00.000001000 │ +└───────────────────────────────┘ +``` +## addQuarters {#addQuarters} -`toDayOfWeek()` 的两个参数形式允许您指定一周的开始日是星期一还是星期天,以及返回值是否应在 0 到 6 或 1 到 7 的范围内。如果省略模式参数,默认模式为 0。日期的时区可以作为第三个参数指定。 +引入于:v20.1 -| 模式 | 一周的第一天 | 范围 | -|------|---------------|------------------------------------------------| -| 0 | 星期一 | 1-7: 星期一 = 1,星期二 = 2,...,星期天 = 7 | -| 1 | 星期一 | 0-6: 星期一 = 0,星期二 = 1,...,星期天 = 6 | -| 2 | 星期天 | 0-6: 星期天 = 0,星期一 = 1,...,星期六 = 6 | -| 3 | 星期天 | 1-7: 星期天 = 1,星期一 = 2,...,星期六 = 7 | + +将指定数量的季度添加到日期、带时间的日期或字符串编码的带时间的日期中。 + **语法** ```sql -toDayOfWeek(t[, mode[, timezone]]) +addQuarters(datetime, num) ``` -别名: `DAYOFWEEK`。 - **参数** -- `t` - [Date](../data-types/date.md)、[Date32](../data-types/date32.md)、[DateTime](../data-types/datetime.md) 或 [DateTime64](../data-types/datetime64.md) -- `mode` - 确定一周的第一天。可能的值为 0、1、2 或 3。请参见上表获取差异。 -- `timezone` - 可选参数,它的行为与其他任何转换函数相同 +- `datetime` — 要添加指定季度数的日期或带时间的日期。 [`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) 或 [`String`](/sql-reference/data-types/string) +- `num` — 要添加的季度数。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) -第一个参数也可以指定为 [String](../data-types/string.md),以 [parseDateTime64BestEffort()](type-conversion-functions.md#parsedatetime64besteffort) 支持的格式。这种对字符串参数的支持仅出于与 MySQL 兼容的原因,某些第三方工具期待这样。由于字符串参数的支持可能在将来取决于新的 MySQL 兼容设置,并且字符串解析通常较慢,因此建议不要使用它。 **返回值** -- 所给日期/时间的星期几(1-7),取决于所选模式 +返回 `datetime` 加 `num` 季度后的结果 [`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) **示例** -以下日期为 2023 年 4 月 21 日,为星期五: +**向不同日期类型添加季度** -```sql +```sql title=Query +WITH + toDate('2024-01-01') AS date, + toDateTime('2024-01-01 00:00:00') AS date_time, + '2024-01-01 00:00:00' AS date_time_string SELECT - toDayOfWeek(toDateTime('2023-04-21')), - toDayOfWeek(toDateTime('2023-04-21'), 1) + addQuarters(date, 1) AS add_quarters_with_date, + addQuarters(date_time, 1) AS add_quarters_with_date_time, + addQuarters(date_time_string, 1) AS add_quarters_with_date_time_string ``` -结果: +```response title=Response +┌─add_quarters_with_date─┬─add_quarters_with_date_time─┬─add_quarters_with_date_time_string─┐ +│ 2024-04-01 │ 2024-04-01 00:00:00 │ 2024-04-01 00:00:00.000 │ +└────────────────────────┴─────────────────────────────┴────────────────────────────────────┘ +``` -```response -┌─toDayOfWeek(toDateTime('2023-04-21'))─┬─toDayOfWeek(toDateTime('2023-04-21'), 1)─┐ -│ 5 │ 4 │ -└───────────────────────────────────────┴──────────────────────────────────────────┘ +**使用替代的 INTERVAL 语法** + +```sql title=Query +SELECT dateAdd('1998-06-16'::Date, INTERVAL 10 quarter) +``` + +```response title=Response +┌─plus(CAST('1⋯uarter(10))─┐ +│ 2000-12-16 │ +└──────────────────────────┘ ``` -## toHour {#tohour} +## addSeconds {#addSeconds} + +引入于:v1.1 -返回带时间的日期的小时成分(0-24)。 -假设如果时钟向前移动,则为一小时,并发生在凌晨 2 点;如果时钟向后移动,则为一小时,并发生在凌晨 3 点(这并不总是确切发生 - 取决于时区)。 +将指定数量的秒添加到日期、带时间的日期或字符串编码的日期或带时间的日期中。 + **语法** ```sql -toHour(value) +addSeconds(datetime, num) ``` -别名: `HOUR` - **参数** -- `value` - [DateTime](../data-types/datetime.md) 或 [DateTime64](../data-types/datetime64.md) +- `datetime` — 要添加指定秒数的日期或带时间的日期。 [`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) 或 [`String`](/sql-reference/data-types/string) +- `num` — 要添加的秒数。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) + **返回值** -- 所给日期/时间的小时(0 - 23)。 [UInt8](../data-types/int-uint.md)。 +返回 `datetime` 加 `num` 秒后的结果 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64(3)`](/sql-reference/data-types/datetime64) **示例** -```sql -SELECT toHour(toDateTime('2023-04-21 10:20:30')) +**向不同日期类型添加秒数** + +```sql title=Query +WITH + toDate('2024-01-01') AS date, + toDateTime('2024-01-01 00:00:00') AS date_time, + '2024-01-01 00:00:00' AS date_time_string +SELECT + addSeconds(date, 30) AS add_seconds_with_date, + addSeconds(date_time, 30) AS add_seconds_with_date_time, + addSeconds(date_time_string, 30) AS add_seconds_with_date_time_string ``` -结果: +```response title=Response +┌─add_seconds_with_date─┬─add_seconds_with_date_time─┬─add_seconds_with_date_time_string─┐ +│ 2024-01-01 00:00:30 │ 2024-01-01 00:00:30 │ 2024-01-01 00:00:30.000 │ +└───────────────────────┴────────────────────────────┴───────────────────────────────────┘ +``` -```response -┌─toHour(toDateTime('2023-04-21 10:20:30'))─┐ -│ 10 │ -└───────────────────────────────────────────┘ +**使用替代的 INTERVAL 语法** + +```sql title=Query +SELECT dateAdd('1998-06-16'::Date, INTERVAL 10 second) +``` + +```response title=Response +┌─dateAdd('1998-06-16'::Date, INTERVAL 10 second)─┐ +│ 1998-06-16 00:00:10 │ +└─────────────────────────────────────────────────┘ ``` -## toMinute {#tominute} +## addTupleOfIntervals {#addTupleOfIntervals} + +引入于:v22.11 + -返回带时间的日期的分钟成分(0-59)。 +连续将一组间隔添加到一个日期或带时间的日期中。 + **语法** ```sql -toMinute(value) +addTupleOfIntervals(datetime, intervals) ``` -别名: `MINUTE` - **参数** -- `value` - [DateTime](../data-types/datetime.md) 或 [DateTime64](../data-types/datetime64.md) +- `datetime` — 要添加间隔的日期或带时间的日期。 [`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) +- `intervals` — 要添加到 `datetime` 的间隔元组。 [`Tuple(Interval)`](/sql-reference/data-types/tuple) + **返回值** -- 所给日期/时间的分钟(0 - 59)。 [UInt8](../data-types/int-uint.md)。 +返回添加了 `intervals` 的日期 [`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) **示例** -```sql -SELECT toMinute(toDateTime('2023-04-21 10:20:30')) -``` +**向日期添加间隔元组** -结果: +```sql title=Query +WITH toDate('2018-01-01') AS date +SELECT addTupleOfIntervals(date, (INTERVAL 1 DAY, INTERVAL 1 MONTH, INTERVAL 1 YEAR)) +``` -```response -┌─toMinute(toDateTime('2023-04-21 10:20:30'))─┐ -│ 20 │ -└─────────────────────────────────────────────┘ +```response title=Response +┌─addTupleOfIntervals(date, (toIntervalDay(1), toIntervalMonth(1), toIntervalYear(1)))─┐ +│ 2019-02-02 │ +└──────────────────────────────────────────────────────────────────────────────────────┘ ``` -## toSecond {#tosecond} +## addWeeks {#addWeeks} + +引入于:v1.1 + -返回带时间的日期的秒成分(0-59)。不考虑闰秒。 +将指定数量的周数添加到日期、带时间的日期或字符串编码的日期或带时间的日期中。 + **语法** ```sql -toSecond(value) +addWeeks(datetime, num) ``` -别名: `SECOND` - **参数** -- `value` - [DateTime](../data-types/datetime.md) 或 [DateTime64](../data-types/datetime64.md) +- `datetime` — 要添加指定周数的日期或带时间的日期。 [`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) 或 [`String`](/sql-reference/data-types/string) +- `num` — 要添加的周数。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) + **返回值** -- 所给日期/时间的秒(0 - 59)。 [UInt8](../data-types/int-uint.md)。 +返回 `datetime` 加 `num` 周后的结果 [`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) **示例** -```sql -SELECT toSecond(toDateTime('2023-04-21 10:20:30')) -``` +**向不同日期类型添加周数** -结果: +```sql title=Query +WITH + toDate('2024-01-01') AS date, + toDateTime('2024-01-01 00:00:00') AS date_time, + '2024-01-01 00:00:00' AS date_time_string +SELECT + addWeeks(date, 5) AS add_weeks_with_date, + addWeeks(date_time, 5) AS add_weeks_with_date_time, + addWeeks(date_time_string, 5) AS add_weeks_with_date_time_string +``` -```response -┌─toSecond(toDateTime('2023-04-21 10:20:30'))─┐ -│ 30 │ -└─────────────────────────────────────────────┘ +```response title=Response +┌─add_weeks_with_date─┬─add_weeks_with_date_time─┬─add_weeks_with_date_time_string─┐ +│ 2024-02-05 │ 2024-02-05 00:00:00 │ 2024-02-05 00:00:00.000 │ +└─────────────────────┴──────────────────────────┴─────────────────────────────────┘ ``` -## toMillisecond {#tomillisecond} -返回带时间的日期的毫秒成分(0-999)。 +**使用替代的 INTERVAL 语法** -**语法** +```sql title=Query +SELECT dateAdd('1998-06-16'::Date, INTERVAL 10 week) +``` -```sql -toMillisecond(value) +```response title=Response +┌─plus(CAST('1⋯alWeek(10))─┐ +│ 1998-08-25 │ +└──────────────────────────┘ ``` +## addYears {#addYears} + +引入于:v1.1 -**参数** -- `value` - [DateTime](../data-types/datetime.md) 或 [DateTime64](../data-types/datetime64.md) +将指定数量的年份添加到日期、带时间的日期或字符串编码的日期或带时间的日期中。 + -别名: `MILLISECOND` +**语法** ```sql -SELECT toMillisecond(toDateTime64('2023-04-21 10:20:30.456', 3)) +addYears(datetime, num) ``` -结果: +**参数** -```response -┌──toMillisecond(toDateTime64('2023-04-21 10:20:30.456', 3))─┐ -│ 456 │ -└────────────────────────────────────────────────────────────┘ -``` +- `datetime` — 要添加指定年份的日期或带时间的日期。 [`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) 或 [`String`](/sql-reference/data-types/string) +- `num` — 要添加的年份数。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) -**返回值** -- 所给日期/时间的毫秒(0 - 59)。 [UInt16](../data-types/int-uint.md)。 -## toUnixTimestamp {#tounixtimestamp} +**返回值** -将字符串、日期或带时间的日期转换为 `UInt32` 表示的 [Unix 时间戳](https://en.wikipedia.org/wiki/Unix_time)。 +返回 `datetime` 加 `num` 年后的结果 [`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) -如果该函数以字符串形式调用,则接受一个可选的时区参数。 +**示例** -**语法** +**向不同日期类型添加年份** -```sql -toUnixTimestamp(date) -toUnixTimestamp(str, [timezone]) +```sql title=Query +WITH + toDate('2024-01-01') AS date, + toDateTime('2024-01-01 00:00:00') AS date_time, + '2024-01-01 00:00:00' AS date_time_string +SELECT + addYears(date, 1) AS add_years_with_date, + addYears(date_time, 1) AS add_years_with_date_time, + addYears(date_time_string, 1) AS add_years_with_date_time_string ``` -**返回值** +```response title=Response +┌─add_years_with_date─┬─add_years_with_date_time─┬─add_years_with_date_time_string─┐ +│ 2025-01-01 │ 2025-01-01 00:00:00 │ 2025-01-01 00:00:00.000 │ +└─────────────────────┴──────────────────────────┴─────────────────────────────────┘ +``` -- 返回 unix 时间戳。 [UInt32](../data-types/int-uint.md)。 +**使用替代的 INTERVAL 语法** -**示例** +```sql title=Query +SELECT dateAdd('1998-06-16'::Date, INTERVAL 10 year) +``` -```sql -SELECT - '2017-11-05 08:07:47' AS dt_str, - toUnixTimestamp(dt_str) AS from_str, - toUnixTimestamp(dt_str, 'Asia/Tokyo') AS from_str_tokyo, - toUnixTimestamp(toDateTime(dt_str)) AS from_datetime, - toUnixTimestamp(toDateTime64(dt_str, 0)) AS from_datetime64, - toUnixTimestamp(toDate(dt_str)) AS from_date, - toUnixTimestamp(toDate32(dt_str)) AS from_date32 -FORMAT Vertical; +```response title=Response +┌─plus(CAST('1⋯alYear(10))─┐ +│ 2008-06-16 │ +└──────────────────────────┘ ``` +## age {#age} -结果: +引入于:v23.1 -```text -Row 1: -────── -dt_str: 2017-11-05 08:07:47 -from_str: 1509869267 -from_str_tokyo: 1509836867 -from_datetime: 1509869267 -from_datetime64: 1509869267 -from_date: 1509840000 -from_date32: 1509840000 -``` -:::note -`toStartOf*`、`toLastDayOf*`、`toMonday`、`timeSlot` 函数的返回类型由配置参数 [enable_extended_results_for_datetime_functions](/operations/settings/settings#enable_extended_results_for_datetime_functions) 决定,默认值为 `0`。 - -行为如下: -* `enable_extended_results_for_datetime_functions = 0`: - * 函数 `toStartOfYear`、`toStartOfISOYear`、`toStartOfQuarter`、`toStartOfMonth`、`toStartOfWeek`、`toLastDayOfWeek`、`toLastDayOfMonth`、`toMonday` 返回 `Date` 或 `DateTime`。 - * 函数 `toStartOfDay`、`toStartOfHour`、`toStartOfFifteenMinutes`、`toStartOfTenMinutes`、`toStartOfFiveMinutes`、`toStartOfMinute`、`timeSlot` 返回 `DateTime`。尽管这些函数可以接受扩展类型 `Date32` 和 `DateTime64` 的值作为参数,但传递超出正常范围的时间(对于 `Date` 从1970年到2149年/对于 `DateTime` 为2106年)将产生错误结果。 -* `enable_extended_results_for_datetime_functions = 1`: - * 函数 `toStartOfYear`、`toStartOfISOYear`、`toStartOfQuarter`、`toStartOfMonth`、`toStartOfWeek`、`toLastDayOfWeek`、`toLastDayOfMonth`、`toMonday` 返回 `Date` 或 `DateTime`(如果它们的参数是 `Date` 或 `DateTime`),并且如果参数是 `Date32` 或 `DateTime64`,则返回 `Date32` 或 `DateTime64`。 - * 函数 `toStartOfDay`、`toStartOfHour`、`toStartOfFifteenMinutes`、`toStartOfTenMinutes`、`toStartOfFiveMinutes`、`toStartOfMinute`、`timeSlot` 返回 `DateTime` (如果它们的参数是 `Date` 或 `DateTime`),并且如果参数是 `Date32` 或 `DateTime64`,则返回 `DateTime64`。 -::: -## toStartOfYear {#tostartofyear} +返回 `startdate` 和 `enddate` 之间的单位组件差异。 +差异通过 1 纳秒的精度进行计算。 -将日期或日期时间向下取整到该年的第一天。返回值为 `Date` 对象。 +例如,2021-12-29 和 2022-01-01 之间的差异在天单位上是 3 天, +在月单位上是 0 个月,在年单位上是 0 年。 + +有关 age 的替代方法,请参见函数 [`timeDiff`](#timeDiff)。 + **语法** ```sql -toStartOfYear(value) +age('unit', startdate, enddate, [timezone]) ``` **参数** -- `value` - [Date](../data-types/date.md)、[Date32](../data-types/date32.md)、[DateTime](../data-types/datetime.md) 或 [DateTime64](../data-types/datetime64.md) +- `unit` — 结果的间隔类型。 + +| 单位 | 可能值 | +|------------|------------------------------------| +| 纳秒 | `nanosecond`, `nanoseconds`, `ns` | +| 微秒 | `microsecond`, `microseconds`, `us`, `u` | +| 毫秒 | `millisecond`, `milliseconds`, `ms` | +| 秒 | `second`, `seconds`, `ss`, `s` | +| 分钟 | `minute`, `minutes`, `mi`, `n` | +| 小时 | `hour`, `hours`, `hh`, `h` | +| 天 | `day`, `days`, `dd`, `d` | +| 周 | `week`, `weeks`, `wk`, `ww` | +| 月 | `month`, `months`, `mm`, `m` | +| 季度 | `quarter`, `quarters`, `qq`, `q` | +| 年 | `year`, `years`, `yyyy`, `yy` | + - `startdate` — 第一个时间值进行减法(被减数)。 [`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) +- `enddate` — 第二个时间值进行减法(减数)。 [`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) +- `timezone` — 可选。时区名称。如果指定,则将其应用于 `startdate` 和 `enddate`。如果未指定,则使用 `startdate` 和 `enddate` 的时区。如果不相同,则结果未定义。 [`String`](/sql-reference/data-types/string) + **返回值** -- 输入日期/时间的第一天。 [Date](../data-types/date.md)。 +返回以单位表示的 `enddate` 和 `startdate` 之间的差异。 [`Int32`](/sql-reference/data-types/int-uint) **示例** -```sql -SELECT toStartOfYear(toDateTime('2023-04-21 10:20:30')) +**计算小时数的年龄** + +```sql title=Query +SELECT age('hour', toDateTime('2018-01-01 22:30:00'), toDateTime('2018-01-02 23:00:00')) +``` + +```response title=Response +┌─age('hour', toDateTime('2018-01-01 22:30:00'), toDateTime('2018-01-02 23:00:00'))─┐ +│ 24 │ +└───────────────────────────────────────────────────────────────────────────────────┘ ``` -结果: +**计算不同单位的年龄** -```response -┌─toStartOfYear(toDateTime('2023-04-21 10:20:30'))─┐ -│ 2023-01-01 │ -└──────────────────────────────────────────────────┘ +```sql title=Query +SELECT + toDate('2022-01-01') AS e, + toDate('2021-12-29') AS s, + age('day', s, e) AS day_age, + age('month', s, e) AS month_age, + age('year', s, e) AS year_age +``` + +```response title=Response +┌──────────e─┬──────────s─┬─day_age─┬─month_age─┬─year_age─┐ +│ 2022-01-01 │ 2021-12-29 │ 3 │ 0 │ 0 │ +└────────────┴────────────┴─────────┴───────────┴──────────┘ ``` -## toStartOfISOYear {#tostartofisoyear} +## changeDay {#changeDay} + +引入于:v24.7 -将日期或日期时间向下取整到 ISO 年的第一天,这可能与“常规”年份不同。(请参阅 [https://en.wikipedia.org/wiki/ISO_week_date](https://en.wikipedia.org/wiki/ISO_week_date))。 +更改日期或日期时间的日部分。 **语法** ```sql -toStartOfISOYear(value) +changeDay(date_or_datetime, value) ``` **参数** -- `value` - [Date](../data-types/date.md)、[Date32](../data-types/date32.md)、[DateTime](../data-types/datetime.md) 或 [DateTime64](../data-types/datetime64.md) +- `date_or_datetime` — 要更改的值。 [`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) +- `value` — 新值。 [`(U)Int*`](/sql-reference/data-types/int-uint) + **返回值** -- 输入日期/时间的第一天。 [Date](../data-types/date.md)。 +返回与 `date_or_datetime` 同类型的值,其日部分已修改。 [`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) **示例** -```sql -SELECT toStartOfISOYear(toDateTime('2023-04-21 10:20:30')) -``` +**用法示例** -结果: +```sql title=Query +SELECT changeDay('2024-01-31'::DateTime, 15) +``` -```response -┌─toStartOfISOYear(toDateTime('2023-04-21 10:20:30'))─┐ -│ 2023-01-02 │ -└─────────────────────────────────────────────────────┘ +```response title=Response +2024-01-15 00:00:00 ``` -## toStartOfQuarter {#tostartofquarter} +## changeHour {#changeHour} -将日期或日期时间向下取整到该季度的第一天。季度的第一天为 1 月 1 日、4 月 1 日、7 月 1 日或 10 月 1 日。 -返回日期。 +引入于:v24.7 + +更改日期或日期时间的小时部分。 **语法** ```sql -toStartOfQuarter(value) +changeHour(date_or_datetime, value) ``` **参数** -- `value` - [Date](../data-types/date.md)、[Date32](../data-types/date32.md)、[DateTime](../data-types/datetime.md) 或 [DateTime64](../data-types/datetime64.md) +- `date_or_datetime` — 要更改的值。 [`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) +- `value` — 新值。 [`(U)Int*`](/sql-reference/data-types/int-uint) + **返回值** -- 所给日期/时间的季度的第一天。 [Date](../data-types/date.md)。 +返回与 `date_or_datetime` 同类型的值,其小时部分已修改。 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) **示例** -```sql -SELECT toStartOfQuarter(toDateTime('2023-04-21 10:20:30')) -``` +**用法示例** -结果: +```sql title=Query +SELECT changeHour('2024-01-01 12:00:00'::DateTime, 5) +``` -```response -┌─toStartOfQuarter(toDateTime('2023-04-21 10:20:30'))─┐ -│ 2023-04-01 │ -└─────────────────────────────────────────────────────┘ +```response title=Response +2024-01-01 05:00:00 ``` -## toStartOfMonth {#tostartofmonth} +## changeMinute {#changeMinute} + +引入于:v24.7 -将日期或日期时间向下取整到该月的第一天。返回日期。 +更改 `date or date time` 的分钟部分。 **语法** ```sql -toStartOfMonth(value) +changeMinute(date_or_datetime, value) ``` **参数** -- `value` - [Date](../data-types/date.md)、[Date32](../data-types/date32.md)、[DateTime](../data-types/datetime.md) 或 [DateTime64](../data-types/datetime64.md) +- `date_or_datetime` — 要更改的值。 [`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) +- `value` — 新值。 [`(U)Int*`](/sql-reference/data-types/int-uint) + **返回值** -- 所给日期/时间的月份的第一天。 [Date](../data-types/date.md)。 +返回与 `date_or_datetime` 同类型的值,其分钟部分已修改。 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) **示例** -```sql -SELECT toStartOfMonth(toDateTime('2023-04-21 10:20:30')) +**用法示例** + +```sql title=Query +SELECT changeMinute('2024-01-01 12:30:00'::DateTime, 45) ``` -结果: - -```response -┌─toStartOfMonth(toDateTime('2023-04-21 10:20:30'))─┐ -│ 2023-04-01 │ -└───────────────────────────────────────────────────┘ +```response title=Response +2024-01-01 12:45:00 ``` +## changeMonth {#changeMonth} -:::note -解析不正确日期的行为是实现特定的。 ClickHouse 可能返回零日期,抛出异常,或执行“自然”溢出。 -::: -## toLastDayOfMonth {#tolastdayofmonth} +引入于:v24.7 -将日期或日期时间向上取整到该月的最后一天。返回日期。 +更改日期或日期时间的月份部分。 **语法** ```sql -toLastDayOfMonth(value) +changeMonth(date_or_datetime, value) ``` -别名: `LAST_DAY` - **参数** -- `value` - [Date](../data-types/date.md)、[Date32](../data-types/date32.md)、[DateTime](../data-types/datetime.md) 或 [DateTime64](../data-types/datetime64.md) +- `date_or_datetime` — 要更改的值。 [`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) +- `value` — 新值。 [`(U)Int*`](/sql-reference/data-types/int-uint) + **返回值** -- 所给日期/时间的月份的最后一天。 [Date](../data-types/date.md)。 +返回与 `date_or_datetime` 同类型的值,其月份部分已修改。 [`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) **示例** -```sql -SELECT toLastDayOfMonth(toDateTime('2023-04-21 10:20:30')) -``` +**用法示例** -结果: +```sql title=Query +SELECT changeMonth('2024-01-01'::DateTime, 12) +``` -```response -┌─toLastDayOfMonth(toDateTime('2023-04-21 10:20:30'))─┐ -│ 2023-04-30 │ -└─────────────────────────────────────────────────────┘ +```response title=Response +2024-12-01 00:00:00 ``` -## toMonday {#tomonday} +## changeSecond {#changeSecond} + +引入于:v24.7 -将日期或日期时间向下取整到最靠近的星期一。返回日期。 +更改日期或日期时间的秒部分。 **语法** ```sql -toMonday(value) +changeSecond(date_or_datetime, value) ``` **参数** -- `value` - [Date](../data-types/date.md)、[Date32](../data-types/date32.md)、[DateTime](../data-types/datetime.md) 或 [DateTime64](../data-types/datetime64.md) +- `date_or_datetime` — 要更改的值。 [`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) +- `value` — 新值。 [`(U)Int*`](/sql-reference/data-types/int-uint) + **返回值** -- 所给日期最靠近的星期一或之前的日期。 [Date](../data-types/date.md)。 +返回与 `date_or_datetime` 同类型的值,其秒部分已修改。 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) **示例** -```sql -SELECT - toMonday(toDateTime('2023-04-21 10:20:30')), /* a Friday */ - toMonday(toDate('2023-04-24')), /* already a Monday */ -``` +**用法示例** -结果: +```sql title=Query +SELECT changeSecond('2024-01-01 12:30:45'::DateTime, 15) +``` -```response -┌─toMonday(toDateTime('2023-04-21 10:20:30'))─┬─toMonday(toDate('2023-04-24'))─┐ -│ 2023-04-17 │ 2023-04-24 │ -└─────────────────────────────────────────────┴────────────────────────────────┘ +```response title=Response +2024-01-01 12:30:15 ``` -## toStartOfWeek {#tostartofweek} +## changeYear {#changeYear} -将日期或日期时间向下取整到最靠近的星期天或星期一。返回日期。模式参数的工作方式与函数 `toWeek()` 中的模式参数完全相同。如果没有指定模式,则默认值为 0。 +引入于:v24.7 + +更改日期或日期时间的年份部分。 **语法** ```sql -toStartOfWeek(t[, mode[, timezone]]) +changeYear(date_or_datetime, value) ``` **参数** -- `t` - [Date](../data-types/date.md)、[Date32](../data-types/date32.md)、[DateTime](../data-types/datetime.md) 或 [DateTime64](../data-types/datetime64.md) -- `mode` - 确定一周的第一天,如 [toWeek()](#toweek) 函数所述 -- `timezone` - 可选参数,它的行为与其他任何转换函数相同 +- `date_or_datetime` — 要更改的值。 [`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) +- `value` — 新值。 [`(U)Int*`](/sql-reference/data-types/int-uint) + **返回值** -- 最靠近给定日期的星期天或星期一的日期,具体取决于模式。 [Date](../data-types/date.md)。 +返回与 `date_or_datetime` 同类型的值,其年份部分已修改。 [`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) **示例** -```sql -SELECT - toStartOfWeek(toDateTime('2023-04-21 10:20:30')), /* a Friday */ - toStartOfWeek(toDateTime('2023-04-21 10:20:30'), 1), /* a Friday */ - toStartOfWeek(toDate('2023-04-24')), /* a Monday */ - toStartOfWeek(toDate('2023-04-24'), 1) /* a Monday */ -FORMAT Vertical -``` +**用法示例** -结果: +```sql title=Query +SELECT changeYear('2024-01-01'::DateTime, 2023) +``` -```response -Row 1: -────── -toStartOfWeek(toDateTime('2023-04-21 10:20:30')): 2023-04-16 -toStartOfWeek(toDateTime('2023-04-21 10:20:30'), 1): 2023-04-17 -toStartOfWeek(toDate('2023-04-24')): 2023-04-23 -toStartOfWeek(toDate('2023-04-24'), 1): 2023-04-24 +```response title=Response +2023-01-01 00:00:00 ``` -## toLastDayOfWeek {#tolastdayofweek} +## dateName {#dateName} + +引入于:v21.7 + -将日期或日期时间向上取整到最靠近的星期六或星期天。返回日期。 -模式参数的工作方式与函数 `toWeek()` 中的模式参数完全相同。如果没有指定模式,则默认为 0。 +返回指定的日期部分。 + +可能值: +- 'year' +- 'quarter' +- 'month' +- 'week' +- 'dayofyear' +- 'day' +- 'weekday' +- 'hour' +- 'minute' +- 'second' + **语法** ```sql -toLastDayOfWeek(t[, mode[, timezone]]) +dateName(date_part, date[, timezone]) ``` **参数** -- `t` - [Date](../data-types/date.md)、[Date32](../data-types/date32.md)、[DateTime](../data-types/datetime.md) 或 [DateTime64](../data-types/datetime64.md) -- `mode` - 确定一周的最后一天,如 [toWeek](#toweek) 函数所述 -- `timezone` - 可选参数,它的行为与其他任何转换函数相同 +- `date_part` — 要提取的日期部分。 [`String`](/sql-reference/data-types/string) +- `datetime` — 日期或带时间的日期值。 [`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) +- `timezone` — 可选。时区。 [`String`](/sql-reference/data-types/string) + **返回值** -- 最靠近给定日期的星期天或星期一,具体取决于模式。 [Date](../data-types/date.md)。 +返回指定的日期部分。 [`String`](/sql-reference/data-types/string) **示例** -```sql +**提取不同的日期部分** + +```sql title=Query +WITH toDateTime('2021-04-14 11:22:33') AS date_value SELECT - toLastDayOfWeek(toDateTime('2023-04-21 10:20:30')), /* a Friday */ - toLastDayOfWeek(toDateTime('2023-04-21 10:20:30'), 1), /* a Friday */ - toLastDayOfWeek(toDate('2023-04-22')), /* a Saturday */ - toLastDayOfWeek(toDate('2023-04-22'), 1) /* a Saturday */ -FORMAT Vertical + dateName('year', date_value), + dateName('month', date_value), + dateName('day', date_value) ``` -结果: - -```response -Row 1: -────── -toLastDayOfWeek(toDateTime('2023-04-21 10:20:30')): 2023-04-22 -toLastDayOfWeek(toDateTime('2023-04-21 10:20:30'), 1): 2023-04-23 -toLastDayOfWeek(toDate('2023-04-22')): 2023-04-22 -toLastDayOfWeek(toDate('2023-04-22'), 1): 2023-04-23 +```response title=Response +┌─dateName('year', date_value)─┬─dateName('month', date_value)─┬─dateName('day', date_value)─┐ +│ 2021 │ April │ 14 │ +└──────────────────────────────┴───────────────────────────────┴─────────────────────────────┘ ``` -## toStartOfDay {#tostartofday} +## dateTrunc {#dateTrunc} + +引入于:v20.8 -将带时间的日期向下取整到该天的开始。 + +将日期和时间值截断到指定的日期部分。 + **语法** ```sql -toStartOfDay(value) +dateTrunc(unit, datetime[, timezone]) ``` **参数** -- `value` - [Date](../data-types/date.md)、[Date32](../data-types/date32.md)、[DateTime](../data-types/datetime.md) 或 [DateTime64](../data-types/datetime64.md) +- `unit` — +截断结果的间隔类型。 `unit` 参数不区分大小写。 +| 单位 | 兼容性 | +|--------------|-----------------------------| +| `nanosecond` | 仅与 DateTime64 兼容 | +| `microsecond`| 仅与 DateTime64 兼容 | +| `millisecond`| 仅与 DateTime64 兼容 | +| `second` | | +| `minute` | | +| `hour` | | +| `day` | | +| `week` | | +| `month` | | +| `quarter` | | +| `year` | | + [`String`](/sql-reference/data-types/string) +- `datetime` — 日期和时间。 [`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) +- `timezone` — 可选。返回 datetime 的时区名称。如果未指定,函数将使用 `datetime` 参数的时区。 [`String`](/sql-reference/data-types/string) + **返回值** -- 所给日期/时间的开始。 [DateTime](../data-types/datetime.md)。 +返回截断后的日期和时间值。 + +| 单位参数 | `datetime` 参数 | 返回类型 | +|-----------------------|-----------------------------------|---------------------------------------------------------------------| +| 年、季度、月、周 | `Date32` 或 `DateTime64` 或 `Date` 或 `DateTime` | [`Date32`](../data-types/date32.md) 或 [`Date`](../data-types/date.md) | +| 天、小时、分钟、秒 | `Date32`、`DateTime64`、`Date`或`DateTime`| [`DateTime64`](../data-types/datetime64.md) 或 [`DateTime`](../data-types/datetime.md) | +| 毫秒、微秒、 | 任何 | [`DateTime64`](../data-types/datetime64.md) | +| 纳秒 | | 精度为 3、6 或 9 | **示例** -```sql -SELECT toStartOfDay(toDateTime('2023-04-21 10:20:30')) +**无时区截断** + +```sql title=Query +SELECT now(), dateTrunc('hour', now()); ``` -结果: +```response title=Response +┌───────────────now()─┬─dateTrunc('hour', now())──┐ +│ 2020-09-28 10:40:45 │ 2020-09-28 10:00:00 │ +└─────────────────────┴───────────────────────────┘ +``` -```response -┌─toStartOfDay(toDateTime('2023-04-21 10:20:30'))─┐ -│ 2023-04-21 00:00:00 │ -└─────────────────────────────────────────────────┘ +**带指定时区的截断** + +```sql title=Query +SELECT now(), dateTrunc('hour', now(), 'Asia/Istanbul'); ``` -## toStartOfHour {#tostartofhour} -将带时间的日期向下取整到该小时的开始。 +```response title=Response +┌───────────────now()─┬─dateTrunc('hour', now(), 'Asia/Istanbul')──┐ +│ 2020-09-28 10:46:26 │ 2020-09-28 13:00:00 │ +└─────────────────────┴────────────────────────────────────────────┘ +``` +## formatDateTime {#formatDateTime} + +引入于:v1.1 + +根据给定的格式字符串格式化日期或带时间的日期。`format` 是一个常量表达式,因此你不能为单个结果列使用多个格式。 + +`formatDateTime` 使用 MySQL 的日期时间格式风格,详情请参阅 [mysql docs](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_date-format)。 + +此函数的反向操作是 [`parseDateTime`](/sql-reference/functions/type-conversion-functions#parsedatetime)。 + +使用替换字段,你可以定义结果字符串的模式。 +下表中的示例列显示 `2018-01-02 22:33:44` 的格式化结果。 + +**替换字段:** + +| 占位符 | 描述 | 示例 | +|-------------|-------------|---------| +| %a | 缩写的星期几名称(周一-周日) | Mon | +| %b | 缩写的月份名称(1月-12月) | Jan | +| %c | 月份的整数值(01-12) | 01 | +| %C | 年除以 100 并舍去小数部分的结果(00-99) | 20 | +| %d | 月份的天数,零填充(01-31) | 02 | +| %D | 短格式 MM/DD/YY 日期,相当于 %m/%d/%y | 01/02/18 | +| %e | 月份中的天数,空格填充(1-31) | 2 | +| %f | 小数秒 | 123456 | +| %F | 短格式 YYYY-MM-DD 日期,相当于 %Y-%m-%d | 2018-01-02 | +| %g | 两位数的年份格式,与 ISO 8601 对齐 | 18 | +| %G | ISO 周数的四位数字年份格式 | 2018 | +| %h | 12 小时格式的小时数(01-12) | 09 | +| %H | 24 小时格式的小时数(00-23) | 22 | +| %i | 分钟(00-59) | 33 | +| %I | 12 小时格式的小时数(01-12) | 10 | +| %j | 一年的第几天(001-366) | 002 | +| %k | 24 小时格式的小时数(00-23) | 14 | +| %l | 12 小时格式的小时数(01-12) | 09 | +| %m | 月份的整数值(01-12) | 01 | +| %M | 完整的月份名称(1月-12月) | January | +| %n | 换行字符 | | +| %p | AM 或 PM 标识 | PM | +| %Q | 季度(1-4) | 1 | +| %r | 12小时 HH:MM AM/PM 时间,相当于 %h:%i %p | 10:30 PM | +| %R | 24小时 HH:MM 时间,相当于 %H:%i | 22:33 | +| %s | 秒(00-59) | 44 | +| %S | 秒(00-59) | 44 | +| %t | 横向制表符 | | +| %T | ISO 8601 时间格式(HH:MM:SS),相当于 %H:%i:%S | 22:33:44 | +| %u | ISO 8601 星期几作为数字,周一为 1(1-7) | 2 | +| %V | ISO 8601 周数(01-53) | 01 | +| %w | 星期几作为整数值,周日为 0(0-6) | 2 | +| %W | 完整的星期几名称(周一-周日) | Monday | +| %y | 年的最后两位数字(00-99) | 18 | +| %Y | 年 | 2018 | +| %z | UTC 时间偏移,格式为 +HHMM 或 -HHMM | -0500 | +| %% | 百分号 | % | + +- 在 v23.4 之前的 ClickHouse 版本中,如果格式化值为 Date,Date32 或 DateTime(没有小数秒)或 DateTime64 的精度为 0,则 `%f` 会打印一个零(0)。 +- 在 v25.1 之前的 ClickHouse 版本中,`%f` 将打印 DateTime64 指定的位数而不是固定的 6 位数字。 +- 在 v23.4 之前的 ClickHouse 版本中,`%M` 打印分钟(00-59),而不是完整的月份名称(1月-12月)。 **语法** ```sql -toStartOfHour(value) +formatDateTime(datetime, format[, timezone]) ``` **参数** -- `value` - [DateTime](../data-types/datetime.md) 或 [DateTime64](../data-types/datetime64.md) +- `datetime` — 要格式化的日期或带时间的日期。 [`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) +- `format` — 带替换字段的格式字符串。 [`String`](/sql-reference/data-types/string) +- `timezone` — 可选。 格式化时间的时区名称。 [`String`](/sql-reference/data-types/string) **返回值** -- 所给日期/时间的开始(小时)。 [DateTime](../data-types/datetime.md)。 +根据确定的格式返回时间和日期值。 [`String`](/sql-reference/data-types/string) **示例** -```sql -SELECT - toStartOfHour(toDateTime('2023-04-21 10:20:30')), - toStartOfHour(toDateTime64('2023-04-21', 6)) +**用年份占位符格式化日期** + +```sql title=Query +SELECT formatDateTime(toDate('2010-01-04'), '%g') +``` + +```response title=Response +┌─formatDateTime(toDate('2010-01-04'), '%g')─┐ +│ 10 │ +└────────────────────────────────────────────┘ +``` + +**用小数秒格式化 DateTime64** + +```sql title=Query +SELECT formatDateTime(toDateTime64('2010-01-04 12:34:56.123456', 7), '%f') +``` + +```response title=Response +┌─formatDateTime(toDateTime64('2010-01-04 12:34:56.123456', 7), '%f')─┐ +│ 1234560 │ +└─────────────────────────────────────────────────────────────────────┘ ``` -结果: +**带时区格式** -```response -┌─toStartOfHour(toDateTime('2023-04-21 10:20:30'))─┬─toStartOfHour(toDateTime64('2023-04-21', 6))─┐ -│ 2023-04-21 10:00:00 │ 2023-04-21 00:00:00 │ -└──────────────────────────────────────────────────┴──────────────────────────────────────────────┘ +```sql title=Query +SELECT + now() AS ts, + time_zone, + formatDateTime(ts, '%T', time_zone) AS str_tz_time +FROM system.time_zones +WHERE time_zone LIKE 'Europe%' +LIMIT 10 ``` -## toStartOfMinute {#tostartofminute} -将带时间的日期向下取整到该分钟的开始。 +```response title=Response +┌──────────────────ts─┬─time_zone─────────┬─str_tz_time─┐ +│ 2023-09-08 19:13:40 │ Europe/Amsterdam │ 21:13:40 │ +│ 2023-09-08 19:13:40 │ Europe/Andorra │ 21:13:40 │ +│ 2023-09-08 19:13:40 │ Europe/Astrakhan │ 23:13:40 │ +│ 2023-09-08 19:13:40 │ Europe/Athens │ 22:13:40 │ +│ 2023-09-08 19:13:40 │ Europe/Belfast │ 20:13:40 │ +│ 2023-09-08 19:13:40 │ Europe/Belgrade │ 21:13:40 │ +│ 2023-09-08 19:13:40 │ Europe/Berlin │ 21:13:40 │ +│ 2023-09-08 19:13:40 │ Europe/Bratislava │ 21:13:40 │ +│ 2023-09-08 19:13:40 │ Europe/Brussels │ 21:13:40 │ +│ 2023-09-08 19:13:40 │ Europe/Bucharest │ 22:13:40 │ +└─────────────────────┴───────────────────┴─────────────┘ +``` +## formatDateTimeInJodaSyntax {#formatDateTimeInJodaSyntax} + +引入于:v20.1 + +类似于 `formatDateTime`,不同的是它以 Joda 风格格式化日期时间,而不是 MySQL 风格。请参阅 [Joda Time documentation](https://joda-time.sourceforge.net/apidocs/org/joda/time/format/DateTimeFormat.html)。 + +此函数的反向操作是 [`parseDateTimeInJodaSyntax`](/sql-reference/functions/type-conversion-functions#parsedatetimeinjodasyntax)。 + +使用替换字段,你可以定义结果字符串的模式。 + +**替换字段:** + +| 占位符 | 描述 | 表现 | 示例 | +|-------------|-------------|-------------|----------| +| G | 纪元 | 文本 | AD | +| C | 纪元的世纪(>=0) | 数字 | 20 | +| Y | 纪元年份(>=0) | 年份 | 1996 | +| x | 周年(尚不支持) | 年份 | 1996 | +| w | 周年中的周(尚不支持) | 数字 | 27 | +| e | 星期几 | 数字 | 2 | +| E | 星期几 | 文本 | Tuesday; Tue | +| y | 年份 | 年份 | 1996 | +| D | 一年的天数 | 数字 | 189 | +| M | 月份 | 月 | July; Jul; 07 | +| d | 月份中的天数 | 数字 | 10 | +| a | 一天中的半天 | 文本 | PM | +| K | 半天中的小时数(0~11) | 数字 | 0 | +| h | 半天中的时钟小时(1~12) | 数字 | 12 | +| H | 一天中的小时数(0~23) | 数字 | 0 | +| k | 一天中的时钟小时(1~24) | 数字 | 24 | +| m | 小时中的分钟 | 数字 | 30 | +| s | 分钟中的秒 | 数字 | 55 | +| S | 秒的小数部分 | 数字 | 978 | +| z | 时区 | 文本 | Eastern Standard Time; EST | +| Z | 时区偏移 | 区域 | -0800; -0812 | +| ' | 文本的转义字符 | 分隔符 | | +| '' | 单引号 | 文本 | ' | **语法** ```sql -toStartOfMinute(value) +formatDateTimeInJodaSyntax(datetime, format[, timezone]) ``` **参数** -- `value` - [DateTime](../data-types/datetime.md) 或 [DateTime64](../data-types/datetime64.md) +- `datetime` — 要格式化的日期或带时间的日期。 [`DateTime`](/sql-reference/data-types/datetime) 或 [`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime64`](/sql-reference/data-types/datetime64) +- `format` — 带 Joda 风格替换字段的格式字符串。 [`String`](/sql-reference/data-types/string) +- `timezone` — 可选。 格式化时间的时区名称。 [`String`](/sql-reference/data-types/string) **返回值** -- 所给日期/时间的开始(分钟)。 [DateTime](../data-types/datetime.md)。 +根据确定的格式返回时间和日期值。 [`String`](/sql-reference/data-types/string) **示例** -```sql -SELECT - toStartOfMinute(toDateTime('2023-04-21 10:20:30')), - toStartOfMinute(toDateTime64('2023-04-21 10:20:30.5300', 8)) -FORMAT Vertical -``` +**使用 Joda 语法格式化日期时间** -结果: +```sql title=Query +SELECT formatDateTimeInJodaSyntax(toDateTime('2010-01-04 12:34:56'), 'yyyy-MM-dd HH:mm:ss') +``` -```response -Row 1: -────── -toStartOfMinute(toDateTime('2023-04-21 10:20:30')): 2023-04-21 10:20:00 -toStartOfMinute(toDateTime64('2023-04-21 10:20:30.5300', 8)): 2023-04-21 10:20:00 +```response title=Response +┌─formatDateTimeInJodaSyntax(toDateTime('2010-01-04 12:34:56'), 'yyyy-MM-dd HH:mm:ss')─┐ +│ 2010-01-04 12:34:56 │ +└─────────────────────────────────────────────────────────────────────────────────────────┘ ``` -## toStartOfSecond {#tostartofsecond} +## fromDaysSinceYearZero {#fromDaysSinceYearZero} + +引入于:v23.11 -截断亚秒。 +对于自 [公元0000年1月1日](https://en.wikipedia.org/wiki/Year_zero) 以来经过的天数,返回 ISO 8601 定义的[前瞻性格里高尔日历](https://en.wikipedia.org/wiki/Gregorian_calendar#Proleptic_Gregorian_calendar) 中相应的日期。 + +该计算与 MySQL 的 `FROM_DAYS()` 函数相同。如果在 [Date](../data-types/date.md) 类型的范围内不能表示,结果是未定义的。 **语法** ```sql -toStartOfSecond(value, [timezone]) +fromDaysSinceYearZero(days) ``` **参数** -- `value` — 日期和时间。 [DateTime64](../data-types/datetime64.md)。 -- `timezone` — [Timezone](../../operations/server-configuration-parameters/settings.md#timezone) 用于返回值(可选)。如果未指定,函数使用 `value` 参数的时区。 [String](../data-types/string.md)。 +- `days` — 自公元零年起经过的天数。 [`UInt32`](/sql-reference/data-types/int-uint) **返回值** -- 不带亚秒的输入值。 [DateTime64](../data-types/datetime64.md)。 +返回自公元零年起经过的天数对应的日期。 [`Date`](/sql-reference/data-types/date) **示例** -不带时区的查询: +**将自公元零年起的天数转换为日期** -```sql -WITH toDateTime64('2020-01-01 10:20:30.999', 3) AS dt64 -SELECT toStartOfSecond(dt64); +```sql title=Query +SELECT +fromDaysSinceYearZero(739136) AS date1, +fromDaysSinceYearZero(toDaysSinceYearZero(toDate('2023-09-08'))) AS date2 ``` -结果: - -```text -┌───toStartOfSecond(dt64)─┐ -│ 2020-01-01 10:20:30.000 │ -└─────────────────────────┘ +```response title=Response +┌──────date1─┬──────date2─┐ +│ 2023-09-08 │ 2023-09-08 │ +└────────────┴────────────┘ ``` +## fromDaysSinceYearZero32 {#fromDaysSinceYearZero32} + +引入于:v23.11 -带时区的查询: +对于自 [公元0000年1月1日](https://en.wikipedia.org/wiki/Year_zero) 以来经过的天数,返回 ISO 8601 定义的[前瞻性格里高尔日历](https://en.wikipedia.org/wiki/Gregorian_calendar#Proleptic_Gregorian_calendar) 中相应的日期。 +该计算与 MySQL 的 `FROM_DAYS()` 函数相同。如果在 [`Date32`](../data-types/date32.md) 类型的范围内不能表示,结果是未定义的。 + +**语法** ```sql -WITH toDateTime64('2020-01-01 10:20:30.999', 3) AS dt64 -SELECT toStartOfSecond(dt64, 'Asia/Istanbul'); +fromDaysSinceYearZero32(days) ``` -结果: +**参数** -```text -┌─toStartOfSecond(dt64, 'Asia/Istanbul')─┐ -│ 2020-01-01 13:20:30.000 │ -└────────────────────────────────────────┘ +- `days` — 自公元零年起经过的天数。 [`UInt32`](/sql-reference/data-types/int-uint) + +**返回值** + +返回自公元零年起经过的天数对应的日期。 [`Date32`](/sql-reference/data-types/date32) + +**示例** + +**将自公元零年起的天数转换为日期** + +```sql title=Query +SELECT +fromDaysSinceYearZero32(739136) AS date1, +fromDaysSinceYearZero32(toDaysSinceYearZero(toDate('2023-09-08'))) AS date2 ``` -**另见** +```response title=Response +┌──────date1─┬──────date2─┐ +│ 2023-09-08 │ 2023-09-08 │ +└────────────┴────────────┘ +``` +## fromModifiedJulianDay {#fromModifiedJulianDay} -- [Timezone](../../operations/server-configuration-parameters/settings.md#timezone) 服务器配置参数。 -## toStartOfMillisecond {#tostartofmillisecond} +引入于:v21.1 -将带时间的日期向下取整到毫秒的开始。 +将[修订过的儒略日](https://en.wikipedia.org/wiki/Julian_day#Variants)数字转换为文本形式的[前瞻性格里高尔日历](https://en.wikipedia.org/wiki/Proleptic_Gregorian_calendar) 日期 `YYYY-MM-DD`。此函数支持的天数范围为 `-678941` 到 `2973483`(分别代表 0000-01-01 和 9999-12-31)。如果天数超出支持范围,将引发异常。 **语法** ```sql -toStartOfMillisecond(value, [timezone]) +fromModifiedJulianDay(day) ``` **参数** -- `value` — 日期和时间。 [DateTime64](../../sql-reference/data-types/datetime64.md)。 -- `timezone` — [Timezone](../../operations/server-configuration-parameters/settings.md#timezone) 用于返回值(可选)。如果未指定,函数使用 `value` 参数的时区。 [String](../../sql-reference/data-types/string.md)。 +- `day` — 修订的儒略日数字。 [`(U)Int*`](/sql-reference/data-types/int-uint) **返回值** -- 输入值带亚毫秒。 [DateTime64](../../sql-reference/data-types/datetime64.md)。 +返回文本形式的日期。 [`String`](/sql-reference/data-types/string) **示例** -不带时区的查询: - -```sql -WITH toDateTime64('2020-01-01 10:20:30.999999999', 9) AS dt64 -SELECT toStartOfMillisecond(dt64); -``` +**将修订的儒略日转换为日期** -结果: - -```text -┌────toStartOfMillisecond(dt64)─┐ -│ 2020-01-01 10:20:30.999000000 │ -└───────────────────────────────┘ +```sql title=Query +SELECT fromModifiedJulianDay(58849) ``` -带时区的查询: - -```sql -┌─toStartOfMillisecond(dt64, 'Asia/Istanbul')─┐ -│ 2020-01-01 12:20:30.999000000 │ -└─────────────────────────────────────────────┘ +```response title=Response +┌─fromModifiedJulianDay(58849)─┐ +│ 2020-01-01 │ +└──────────────────────────────┘ ``` +## fromModifiedJulianDayOrNull {#fromModifiedJulianDayOrNull} -结果: - -```text -┌─toStartOfMillisecond(dt64, 'Asia/Istanbul')─┐ -│ 2020-01-01 12:20:30.999 │ -└─────────────────────────────────────────────┘ -``` -## toStartOfMicrosecond {#tostartofmicrosecond} +引入于:v21.1 -将带时间的日期向下取整到微秒的开始。 +类似于 [`fromModifiedJulianDay()`](#fromModifiedJulianDay),但不引发异常,而是返回 `NULL`。 **语法** ```sql -toStartOfMicrosecond(value, [timezone]) +fromModifiedJulianDayOrNull(day) ``` **参数** -- `value` — 日期和时间。 [DateTime64](../../sql-reference/data-types/datetime64.md)。 -- `timezone` — [Timezone](../../operations/server-configuration-parameters/settings.md#timezone) 用于返回值(可选)。如果未指定,函数使用 `value` 参数的时区。 [String](../../sql-reference/data-types/string.md)。 +- `day` — 修订的儒略日数字。 [`(U)Int*`](/sql-reference/data-types/int-uint) **返回值** -- 输入值带亚微秒。 [DateTime64](../../sql-reference/data-types/datetime64.md)。 +对于有效的 `day` 参数,返回文本形式的日期;否则返回 `null`。 [`Nullable(String)`](/sql-reference/data-types/nullable) **示例** -不带时区的查询: +**在处理 null 时将修订的儒略日转换为日期** -```sql -WITH toDateTime64('2020-01-01 10:20:30.999999999', 9) AS dt64 -SELECT toStartOfMicrosecond(dt64); +```sql title=Query +SELECT fromModifiedJulianDayOrNull(58849); +SELECT fromModifiedJulianDayOrNull(60000000); -- invalid argument, returns NULL ``` -结果: - -```text -┌────toStartOfMicrosecond(dt64)─┐ -│ 2020-01-01 10:20:30.999999000 │ -└───────────────────────────────┘ +```response title=Response +┌─fromModified⋯Null(58849)─┐ +│ 2020-01-01 │ +└──────────────────────────┘ +┌─fromModified⋯l(60000000)─┐ +│ ᴺᵁᴸᴸ │ +└──────────────────────────┘ ``` +## fromUTCTimestamp {#fromUTCTimestamp} + +引入于:v22.1 + +将来自 UTC 时区的日期或带时间的值转换为指定时区的日期或带时间的值。此函数主要是为了与 Apache Spark 等框架的兼容性而包含。 -带时区的查询: +**语法** ```sql -WITH toDateTime64('2020-01-01 10:20:30.999999999', 9) AS dt64 -SELECT toStartOfMicrosecond(dt64, 'Asia/Istanbul'); +fromUTCTimestamp(datetime, time_zone) ``` -结果: +**参数** + +- `datetime` — 常量值或表达式中的日期或带时间的日期。 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) +- `time_zone` — 表示时区的常量字符串类型值或表达式。 [`String`](/sql-reference/data-types/string) -```text -┌─toStartOfMicrosecond(dt64, 'Asia/Istanbul')─┐ -│ 2020-01-01 12:20:30.999999000 │ -└─────────────────────────────────────────────┘ +**返回值** + +返回指定时区的 DateTime/DateTime64。 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) + +**示例** + +**将 UTC 时区转换为指定时区** + +```sql title=Query +SELECT fromUTCTimestamp(toDateTime64('2023-03-16 10:00:00', 3), 'Asia/Shanghai') +``` + +```response title=Response +┌─fromUTCTimestamp(toDateTime64('2023-03-16 10:00:00',3), 'Asia/Shanghai')─┐ +│ 2023-03-16 18:00:00.000 │ +└─────────────────────────────────────────────────────────────────────────┘ ``` +## fromUnixTimestamp {#fromUnixTimestamp} -**另见** +引入于:v20.8 -- [Timezone](../../operations/server-configuration-parameters/settings.md#timezone) 服务器配置参数。 -## toStartOfNanosecond {#tostartofnanosecond} +此函数将 Unix 时间戳转换为日历日期和一天中的时间。 -将带时间的日期向下取整到纳秒的开始。 +它可以以两种方式调用: + +- 当给定一个类型为 [`Integer`](../data-types/int-uint.md) 的单一参数时,它返回类型为 [`DateTime`](../data-types/datetime.md) 的值,即行为类似于 [`toDateTime`](../../sql-reference/functions/type-conversion-functions.md#todatetime)。 +- 当给定两个或三个参数时,第一个参数是类型为 [`Integer`](../data-types/int-uint.md)、[`Date`](../data-types/date.md)、[`Date32`](../data-types/date32.md)、[`DateTime`](../data-types/datetime.md) 或 [`DateTime64`](../data-types/datetime64.md) 的值,第二个参数是常量格式字符串,第三个参数是可选的常量时区字符串,该函数返回类型为 [`String`](../data-types/string.md) 的值,即其行为类似于 [`formatDateTime`](#formatDateTime)。 + 在这种情况下,使用 [MySQL 的日期时间格式风格](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_date-format)。 **语法** ```sql -toStartOfNanosecond(value, [timezone]) +fromUnixTimestamp(timestamp) +fromUnixTimestamp(timestamp[, format[, timezone]]) ``` **参数** -- `value` — 日期和时间。 [DateTime64](../../sql-reference/data-types/datetime64.md)。 -- `timezone` — [Timezone](../../operations/server-configuration-parameters/settings.md#timezone) 用于返回值(可选)。如果未指定,函数使用 `value` 参数的时区。 [String](../../sql-reference/data-types/string.md)。 +- `timestamp` — Unix 时间戳或日期/带时间的值。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) +- `format` — 可选。 输出格式的常量格式字符串。 [`String`](/sql-reference/data-types/string) +- `timezone` — 可选。 常量时区字符串。 [`String`](/sql-reference/data-types/string) **返回值** -- 输入值带纳秒。 [DateTime64](../../sql-reference/data-types/datetime64.md)。 +当以一个参数调用时返回时间戳的 `DateTime`,或以两个或三个参数调用时返回字符串。 [`DateTime`](/sql-reference/data-types/datetime) 或 [`String`](/sql-reference/data-types/string) **示例** -不带时区的查询: +**将 Unix 时间戳转换为 DateTime** -```sql -WITH toDateTime64('2020-01-01 10:20:30.999999999', 9) AS dt64 -SELECT toStartOfNanosecond(dt64); +```sql title=Query +SELECT fromUnixTimestamp(423543535) ``` -结果: - -```text -┌─────toStartOfNanosecond(dt64)─┐ -│ 2020-01-01 10:20:30.999999999 │ -└───────────────────────────────┘ +```response title=Response +┌─fromUnixTimestamp(423543535)─┐ +│ 1983-06-04 10:58:55 │ +└──────────────────────────────┘ ``` -带时区的查询: +**带格式的 Unix 时间戳转换** -```sql -WITH toDateTime64('2020-01-01 10:20:30.999999999', 9) AS dt64 -SELECT toStartOfNanosecond(dt64, 'Asia/Istanbul'); +```sql title=Query +SELECT fromUnixTimestamp(1234334543, '%Y-%m-%d %R:%S') AS DateTime ``` -结果: - -```text -┌─toStartOfNanosecond(dt64, 'Asia/Istanbul')─┐ -│ 2020-01-01 12:20:30.999999999 │ -└────────────────────────────────────────────┘ +```response title=Response +┌─DateTime────────────┐ +│ 2009-02-11 14:42:23 │ +└─────────────────────┘ ``` +## fromUnixTimestampInJodaSyntax {#fromUnixTimestampInJodaSyntax} -**另见** +引入于:v23.1 -- [Timezone](../../operations/server-configuration-parameters/settings.md#timezone) 服务器配置参数。 -## toStartOfFiveMinutes {#tostartoffiveminutes} +此函数将 Unix 时间戳转换为日历日期和一天中的时间。 -将带时间的日期向下取整到五分钟间隔的开始。 +它可以以两种方式调用: + +当给定一个类型为 [`Integer`](../data-types/int-uint.md) 的单一参数时,它返回类型为 [`DateTime`](../data-types/datetime.md) 的值,即行为类似于 [`toDateTime`](../../sql-reference/functions/type-conversion-functions.md#todatetime)。 + +当给定两个或三个参数时,第一个参数是类型为 [`Integer`](../data-types/int-uint.md)、[`Date`](../data-types/date.md)、[`Date32`](../data-types/date32.md)、[`DateTime`](../data-types/datetime.md) 或 [`DateTime64`](../data-types/datetime64.md) 的值,第二个参数是常量格式字符串,第三个参数是可选的常量时区字符串,该函数返回类型为 [`String`](../data-types/string.md) 的值,即其行为类似于 [`formatDateTimeInJodaSyntax`](#formatDateTimeInJodaSyntax)。在这种情况下,使用 [Joda 日期时间格式风格](https://joda-time.sourceforge.net/apidocs/org/joda/time/format/DateTimeFormat.html)。 **语法** ```sql -toStartOfFiveMinutes(value) +fromUnixTimestampInJodaSyntax(timestamp) +fromUnixTimestampInJodaSyntax(timestamp, format[, timezone]) ``` **参数** -- `value` - [DateTime](../data-types/datetime.md) 或 [DateTime64](../data-types/datetime64.md) +- `timestamp` — Unix 时间戳或日期/时间值。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) +- `format` — 可选。 使用 Joda 语法的输出格式常量字符串。 [`String`](/sql-reference/data-types/string) +- `timezone` — 可选。 常量时区字符串。 [`String`](/sql-reference/data-types/string) **返回值** -- 所给日期时间的五分钟间隔的开始。 [DateTime](../data-types/datetime.md)。 +在以一个参数调用时返回带时间的日期,或在以两个或三个参数调用时返回字符串。 [`DateTime`](/sql-reference/data-types/datetime) 或 [`String`](/sql-reference/data-types/string) **示例** -```sql -SELECT - toStartOfFiveMinutes(toDateTime('2023-04-21 10:17:00')), - toStartOfFiveMinutes(toDateTime('2023-04-21 10:20:00')), - toStartOfFiveMinutes(toDateTime('2023-04-21 10:23:00')) -FORMAT Vertical -``` - -结果: +**以 Joda 格式转换 Unix 时间戳** -```response -Row 1: -────── -toStartOfFiveMinutes(toDateTime('2023-04-21 10:17:00')): 2023-04-21 10:15:00 -toStartOfFiveMinutes(toDateTime('2023-04-21 10:20:00')): 2023-04-21 10:20:00 -toStartOfFiveMinutes(toDateTime('2023-04-21 10:23:00')): 2023-04-21 10:20:00 +```sql title=Query +SELECT fromUnixTimestampInJodaSyntax(1234334543, 'yyyy-MM-dd HH:mm:ss', 'UTC') AS DateTime ``` -## toStartOfTenMinutes {#tostartoftenminutes} -将带时间的日期向下取整到十分钟间隔的开始。 +```response title=Response +┌─DateTime────────────┐ +│ 2009-02-11 06:42:23 │ +└─────────────────────┘ +``` +## makeDate {#makeDate} + +引入于:v22.6 + +从以下任一项创建 `Date`: +- 一年、一个月和一天 +- 一年和一年中的第几天 **语法** ```sql -toStartOfTenMinutes(value) +makeDate(year, month, day) +makeDate(year, day_of_year) ``` **参数** -- `value` - [DateTime](../data-types/datetime.md) 或 [DateTime64](../data-types/datetime64.md) +- `year` — 年份数字。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal`](/sql-reference/data-types/decimal) +- `month` — 月份数字(1-12)。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal`](/sql-reference/data-types/decimal) +- `day` — 该月的天数(1-31)。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal`](/sql-reference/data-types/decimal) +- `day_of_year` — 年中的天数(1-365)。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal`](/sql-reference/data-types/decimal) **返回值** -- 所给日期时间的十分钟间隔的开始。 [DateTime](../data-types/datetime.md)。 +返回由提供的参数构造的 `Date` 值 [`Date`](/sql-reference/data-types/date) **示例** -```sql -SELECT - toStartOfTenMinutes(toDateTime('2023-04-21 10:17:00')), - toStartOfTenMinutes(toDateTime('2023-04-21 10:20:00')), - toStartOfTenMinutes(toDateTime('2023-04-21 10:23:00')) -FORMAT Vertical +**从年份、月份和日期创建日期** + +```sql title=Query +SELECT makeDate(2023, 2, 28) AS date; +``` + +```response title=Response +┌───────date─┐ +│ 2023-02-28 │ +└────────────┘ ``` -结果: +**从年份和一年中的第几天创建日期** -```response -Row 1: -────── -toStartOfTenMinutes(toDateTime('2023-04-21 10:17:00')): 2023-04-21 10:10:00 -toStartOfTenMinutes(toDateTime('2023-04-21 10:20:00')): 2023-04-21 10:20:00 -toStartOfTenMinutes(toDateTime('2023-04-21 10:23:00')): 2023-04-21 10:20:00 +```sql title=Query +SELECT makeDate(2023, 42) AS date; +``` + +```response title=Response +┌───────date─┐ +│ 2023-02-11 │ +└────────────┘ ``` -## toStartOfFifteenMinutes {#tostartoffifteenminutes} +## makeDate32 {#makeDate32} -将带时间的日期取整到十五分钟间隔的开始。 +引入于:v22.6 + +从以下任一项创建 `Date32`: +- 一年、一个月和一天 +- 一年和一年中的第几天 **语法** ```sql -toStartOfFifteenMinutes(value) +makeDate32(year, month, day) +makeDate32(year, day_of_year) ``` **参数** -- `value` - [DateTime](../data-types/datetime.md) 或 [DateTime64](../data-types/datetime64.md) +- `year` — 年份数字。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal`](/sql-reference/data-types/decimal) +- `month` — 月份数字(1-12)。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal`](/sql-reference/data-types/decimal) +- `day` — 该月的天数(1-31)。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal`](/sql-reference/data-types/decimal) +- `day_of_year` — 年中的天数(1-365)。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal`](/sql-reference/data-types/decimal) **返回值** -- 所给日期时间的十五分钟间隔的开始。 [DateTime](../data-types/datetime.md)。 +返回由提供的参数构造的 `Date32` 值 [`Date32`](/sql-reference/data-types/date32) **示例** -```sql -SELECT - toStartOfFifteenMinutes(toDateTime('2023-04-21 10:17:00')), - toStartOfFifteenMinutes(toDateTime('2023-04-21 10:20:00')), - toStartOfFifteenMinutes(toDateTime('2023-04-21 10:23:00')) -FORMAT Vertical -``` - -结果: +**从年份、月份和日期创建 Date32** -```response -Row 1: -────── -toStartOfFifteenMinutes(toDateTime('2023-04-21 10:17:00')): 2023-04-21 10:15:00 -toStartOfFifteenMinutes(toDateTime('2023-04-21 10:20:00')): 2023-04-21 10:15:00 -toStartOfFifteenMinutes(toDateTime('2023-04-21 10:23:00')): 2023-04-21 10:15:00 +```sql title=Query +SELECT makeDate(2023, 2, 28) AS date; ``` -## toStartOfInterval {#tostartofinterval} - -此函数使用 `toStartOfInterval(date_or_date_with_time, INTERVAL x unit [, time_zone])` 语法概括了其他 `toStartOf*()` 函数。 -例如, -- `toStartOfInterval(t, INTERVAL 1 YEAR)` 返回与 `toStartOfYear(t)` 相同的结果, -- `toStartOfInterval(t, INTERVAL 1 MONTH)` 返回与 `toStartOfMonth(t)` 相同的结果, -- `toStartOfInterval(t, INTERVAL 1 DAY)` 返回与 `toStartOfDay(t)` 相同的结果, -- `toStartOfInterval(t, INTERVAL 15 MINUTE)` 返回与 `toStartOfFifteenMinutes(t)` 相同的结果。 - -计算是相对于特定时间点进行的: - -| Interval | Start | -|-------------|------------------------| -| YEAR | year 0 | -| QUARTER | 1900 Q1 | -| MONTH | 1900 January | -| WEEK | 1970, 1st week (01-05) | -| DAY | 1970-01-01 | -| HOUR | (*) | -| MINUTE | 1970-01-01 00:00:00 | -| SECOND | 1970-01-01 00:00:00 | -| MILLISECOND | 1970-01-01 00:00:00 | -| MICROSECOND | 1970-01-01 00:00:00 | -| NANOSECOND | 1970-01-01 00:00:00 | - -(*) 小时间隔是特殊的:计算始终相对于当天的 00:00:00(午夜)进行。因此,只有范围在 1 到 23 之间的小时值是有用的。 - -如果指定了单位 `WEEK`,则 `toStartOfInterval` 假定周一为一周的开始。请注意,这种行为与函数 `toStartOfWeek` 不同,在该函数中,周日为默认的一周开始。 - -**语法** - -```sql -toStartOfInterval(value, INTERVAL x unit[, time_zone]) -toStartOfInterval(value, INTERVAL x unit[, origin[, time_zone]]) +```response title=Response +┌───────date─┐ +│ 2023-02-28 │ +└────────────┘ ``` -别名: `time_bucket`, `date_bin`。 -第二个重载模拟了 TimescaleDB 的 `time_bucket()` 函数,分别是 PostgreSQL 的 `date_bin()` 函数,例如: +**从年份和一年中的第几天创建 Date32** -```SQL -SELECT toStartOfInterval(toDateTime('2023-01-01 14:45:00'), INTERVAL 1 MINUTE, toDateTime('2023-01-01 14:35:30')); +```sql title=Query +SELECT makeDate(2023, 42) AS date; ``` -结果: - -```reference -┌───toStartOfInterval(...)─┐ -│ 2023-01-01 14:44:30 │ -└──────────────────────────┘ +```response title=Response +┌───────date─┐ +│ 2023-02-11 │ +└────────────┘ ``` +## makeDateTime {#makeDateTime} -**参见** -- [date_trunc](#date_trunc) - -## toTime {#totime} +引入于:v22.6 -将带时间的日期转换为某个固定日期,同时保留时间。 +从年份、月份、日期、小时、分钟和秒创建 `DateTime`,可选的时区。 **语法** ```sql -toTime(date[,timezone]) +makeDateTime(year, month, day, hour, minute, second[, timezone]) ``` **参数** -- `date` — 要转换为时间的日期。 [Date](../data-types/date.md)/[DateTime](../data-types/datetime.md)/[DateTime64](../data-types/datetime64.md)。 -- `timezone` (可选) — 返回值的时区。 [String](../data-types/string.md)。 +- `year` — 年份数字。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal`](/sql-reference/data-types/decimal) +- `month` — 月份数字(1-12)。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal`](/sql-reference/data-types/decimal) +- `day` — 该月的天数(1-31)。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal`](/sql-reference/data-types/decimal) +- `hour` — 小时(0-23)。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal`](/sql-reference/data-types/decimal) +- `minute` — 分钟(0-59)。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal`](/sql-reference/data-types/decimal) +- `second` — 秒(0-59)。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal`](/sql-reference/data-types/decimal) +- `timezone` — 时区名称。 [`String`](/sql-reference/data-types/string) **返回值** -- DateTime,日期等于 `1970-01-02`,同时保留时间。 [DateTime](../data-types/datetime.md)。 - -:::note -如果输入参数 `date` 包含小于一秒的组件, -它们将在返回的 `DateTime` 值中以秒为精度被舍弃。 -::: +返回由提供的参数构造的 `DateTime` 值 [`DateTime`](/sql-reference/data-types/datetime) **示例** -查询: +**从年份、月份、日期、小时、分钟、秒创建 DateTime** -```sql -SELECT toTime(toDateTime64('1970-12-10 01:20:30.3000',3)) AS result, toTypeName(result); +```sql title=Query +SELECT makeDateTime(2023, 2, 28, 17, 12, 33) AS DateTime; ``` -结果: - -```response -┌──────────────result─┬─toTypeName(result)─┐ -│ 1970-01-02 01:20:30 │ DateTime │ -└─────────────────────┴────────────────────┘ +```response title=Response +┌────────────DateTime─┐ +│ 2023-02-28 17:12:33 │ +└─────────────────────┘ ``` +## makeDateTime64 {#makeDateTime64} -## toRelativeYearNum {#torelativeyearnum} +引入于:v22.6 -将日期或带时间的日期转换为自某个过去固定时间点以来经过的年数。 +从年份、月份、日期、小时、分钟、秒创建 `DateTime64`,可选的小数部分、精度和时区。 **语法** ```sql -toRelativeYearNum(date) +makeDateTime64(year, month, day, hour, minute, second[, fraction[, precision[, timezone]]]) ``` **参数** -- `date` — 日期或带时间的日期。 [Date](../data-types/date.md)/[DateTime](../data-types/datetime.md)/[DateTime64](../data-types/datetime64.md)。 +- `year` — 年份数字。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal`](/sql-reference/data-types/decimal) +- `month` — 月份数字(1-12)。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal`](/sql-reference/data-types/decimal) +- `day` — 该月的天数(1-31)。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal`](/sql-reference/data-types/decimal) +- `hour` — 小时(0-23)。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal`](/sql-reference/data-types/decimal) +- `minute` — 分钟(0-59)。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal`](/sql-reference/data-types/decimal) +- `second` — 秒(0-59)。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal`](/sql-reference/data-types/decimal) +- `fraction` — 秒的小数部分。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal`](/sql-reference/data-types/decimal) +- `precision` — 小数部分的精度(0-9)。 [`UInt8`](/sql-reference/data-types/int-uint) +- `timezone` — 时区名称。 [`String`](/sql-reference/data-types/string) **返回值** -- 从过去某个固定参考点计算的年数。 [UInt16](../data-types/int-uint.md)。 +返回由提供的参数构造的 `DateTime64` 值 [`DateTime64`](/sql-reference/data-types/datetime64) **示例** -查询: +**从年份、月份、日期、小时、分钟、秒创建 DateTime64** -```sql -SELECT - toRelativeYearNum(toDate('2002-12-08')) AS y1, - toRelativeYearNum(toDate('2010-10-26')) AS y2 +```sql title=Query +SELECT makeDateTime64(2023, 5, 15, 10, 30, 45, 779, 5); ``` -结果: - -```response -┌───y1─┬───y2─┐ -│ 2002 │ 2010 │ -└──────┴──────┘ +```response title=Response +┌─makeDateTime64(2023, 5, 15, 10, 30, 45, 779, 5)─┐ +│ 2023-05-15 10:30:45.00779 │ +└─────────────────────────────────────────────────┘ ``` +## monthName {#monthName} -## toRelativeQuarterNum {#torelativequarternum} +引入于:v22.1 -将日期或带时间的日期转换为自某个过去固定时间点以来经过的季度数。 +从日期或带时间的日期中返回月份名称作为字符串。 **语法** ```sql -toRelativeQuarterNum(date) +monthName(datetime) ``` **参数** -- `date` — 日期或带时间的日期。 [Date](../data-types/date.md)/[DateTime](../data-types/datetime.md)/[DateTime64](../data-types/datetime64.md)。 +- `datetime` — 日期或带时间的日期。 [`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) **返回值** -- 从过去某个固定参考点计算的季度数。 [UInt32](../data-types/int-uint.md)。 +返回月份的名称。 [`String`](/sql-reference/data-types/string) **示例** -查询: +**从日期中获取月份名称** -```sql -SELECT - toRelativeQuarterNum(toDate('1993-11-25')) AS q1, - toRelativeQuarterNum(toDate('2005-01-05')) AS q2 +```sql title=Query +WITH toDateTime('2021-04-14 11:22:33') AS date_value +SELECT monthName(date_value) ``` -结果: - -```response -┌───q1─┬───q2─┐ -│ 7975 │ 8020 │ -└──────┴──────┘ +```response title=Response +┌─monthName(date_value)─┐ +│ April │ +└───────────────────────┘ ``` +## now {#now} -## toRelativeMonthNum {#torelativemonthnum} +引入于:v1.1 -将日期或带时间的日期转换为自某个过去固定时间点以来经过的月数。 +在查询分析的瞬间返回当前日期和时间。此函数为常量表达式。 **语法** ```sql -toRelativeMonthNum(date) +now([timezone]) ``` **参数** -- `date` — 日期或带时间的日期。 [Date](../data-types/date.md)/[DateTime](../data-types/datetime.md)/[DateTime64](../data-types/datetime64.md)。 +- `timezone` — 可选。 返回值的时区名称。 [`String`](/sql-reference/data-types/string) **返回值** -- 从过去某个固定参考点计算的月数。 [UInt32](../data-types/int-uint.md)。 +返回当前日期和时间。 [`DateTime`](/sql-reference/data-types/datetime) **示例** -查询: +**没有时区的查询** -```sql -SELECT - toRelativeMonthNum(toDate('2001-04-25')) AS m1, - toRelativeMonthNum(toDate('2009-07-08')) AS m2 +```sql title=Query +SELECT now() +``` + +```response title=Response +┌───────────────now()─┐ +│ 2020-10-17 07:42:09 │ +└─────────────────────┘ ``` -结果: +**带指定时区的查询** -```response -┌────m1─┬────m2─┐ -│ 24016 │ 24115 │ -└───────┴───────┘ +```sql title=Query +SELECT now('Asia/Istanbul') +``` + +```response title=Response +┌─now('Asia/Istanbul')─┐ +│ 2020-10-17 10:42:23 │ +└──────────────────────┘ ``` +## now64 {#now64} -## toRelativeWeekNum {#torelativeweeknum} +引入于:v20.1 -将日期或带时间的日期转换为自某个过去固定时间点以来经过的周数。 +在查询分析的瞬间返回当前日期和时间,具有亚秒级精度。此函数为常量表达式。 **语法** ```sql -toRelativeWeekNum(date) +now64([scale], [timezone]) ``` **参数** -- `date` — 日期或带时间的日期。 [Date](../data-types/date.md)/[DateTime](../data-types/datetime.md)/[DateTime64](../data-types/datetime64.md)。 +- `scale` — 可选。 Tick 大小(精度): 10^-precision 秒。有效范围:[0 : 9]。通常使用 - 3(默认)(毫秒),6(微秒),9(纳秒)。 [`UInt8`](/sql-reference/data-types/int-uint) +- `timezone` — 可选。 返回值的时区名称。 [`String`](/sql-reference/data-types/string) **返回值** -- 从过去某个固定参考点计算的周数。 [UInt32](../data-types/int-uint.md)。 +返回带有亚秒级精度的当前日期和时间。 [`DateTime64`](/sql-reference/data-types/datetime64) **示例** -查询: +**使用默认和自定义精度的查询** -```sql -SELECT - toRelativeWeekNum(toDate('2000-02-29')) AS w1, - toRelativeWeekNum(toDate('2001-01-12')) AS w2 +```sql title=Query +SELECT now64(), now64(9, 'Asia/Istanbul') ``` -结果: - -```response -┌───w1─┬───w2─┐ -│ 1574 │ 1619 │ -└──────┴──────┘ +```response title=Response +┌─────────────────now64()─┬─────now64(9, 'Asia/Istanbul')─┐ +│ 2022-08-21 19:34:26.196 │ 2022-08-21 22:34:26.196542766 │ +└─────────────────────────┴───────────────────────────────┘ ``` +## nowInBlock {#nowInBlock} -## toRelativeDayNum {#torelativedaynum} +引入于:v22.8 -将日期或带时间的日期转换为自某个过去固定时间点以来经过的天数。 +在处理每个数据块的瞬间返回当前日期和时间。与函数 [`now`](#now) 不同,它不是常量表达式,因此对于长时间运行的查询,不同数据块的返回值将不同。 + +在长时间运行的 `INSERT SELECT` 查询中使用此函数生成当前时间是有意义的。 **语法** ```sql -toRelativeDayNum(date) +nowInBlock([timezone]) ``` **参数** -- `date` — 日期或带时间的日期。 [Date](../data-types/date.md)/[DateTime](../data-types/datetime.md)/[DateTime64](../data-types/datetime64.md)。 +- `timezone` — 可选。 返回值的时区名称。 [`String`](/sql-reference/data-types/string) **返回值** -- 从过去某个固定参考点计算的天数。 [UInt32](../data-types/int-uint.md)。 +在处理每个数据块的瞬间返回当前日期和时间。 [`DateTime`](/sql-reference/data-types/datetime) **示例** -查询: +**与 now() 函数的区别** -```sql +```sql title=Query SELECT - toRelativeDayNum(toDate('1993-10-05')) AS d1, - toRelativeDayNum(toDate('2000-09-20')) AS d2 + now(), + nowInBlock(), + sleep(1) +FROM numbers(3) +SETTINGS max_block_size = 1 +FORMAT PrettyCompactMonoBlock ``` -结果: - -```response -┌───d1─┬────d2─┐ -│ 8678 │ 11220 │ -└──────┴───────┘ +```response title=Response +┌───────────────now()─┬────────nowInBlock()─┬─sleep(1)─┐ +│ 2022-08-21 19:41:19 │ 2022-08-21 19:41:19 │ 0 │ +│ 2022-08-21 19:41:19 │ 2022-08-21 19:41:20 │ 0 │ +│ 2022-08-21 19:41:19 │ 2022-08-21 19:41:21 │ 0 │ +└─────────────────────┴─────────────────────┴──────────┘ ``` +## nowInBlock64 {#nowInBlock64} -## toRelativeHourNum {#torelativehournum} +引入于:v25.8 -将日期或带时间的日期转换为自某个过去固定时间点以来经过的小时数。 +在处理每个数据块的瞬间返回当前日期和时间,单位为毫秒。与函数 [now64](#now64) 不同,它不是常量表达式,因此对于长时间运行的查询,不同数据块的返回值将不同。 + +在长时间运行的 `INSERT SELECT` 查询中使用此函数生成当前时间是有意义的。 **语法** ```sql -toRelativeHourNum(date) +nowInBlock([scale[, timezone]]) ``` **参数** -- `date` — 日期或带时间的日期。 [Date](../data-types/date.md)/[DateTime](../data-types/datetime.md)/[DateTime64](../data-types/datetime64.md)。 +- `scale` — 可选。 Tick 大小(精度): 10^-precision 秒。有效范围:[0 : 9]。通常使用 - 3(默认)(毫秒),6(微秒),9(纳秒)。 [`UInt8`](/sql-reference/data-types/int-uint) +- `timezone` — 可选。 返回值的时区名称。 [`String`](/sql-reference/data-types/string) **返回值** -- 从过去某个固定参考点计算的小时数。 [UInt32](../data-types/int-uint.md)。 +在处理每个数据块的瞬间返回带有亚秒级精度的当前日期和时间。 [`DateTime64`](/sql-reference/data-types/datetime64) **示例** -查询: +**与 now64() 函数的区别** -```sql +```sql title=Query SELECT - toRelativeHourNum(toDateTime('1993-10-05 05:20:36')) AS h1, - toRelativeHourNum(toDateTime('2000-09-20 14:11:29')) AS h2 + now64(), + nowInBlock64(), + sleep(1) +FROM numbers(3) +SETTINGS max_block_size = 1 +FORMAT PrettyCompactMonoBlock ``` -结果: - -```response -┌─────h1─┬─────h2─┐ -│ 208276 │ 269292 │ -└────────┴────────┘ +```response title=Response +┌─────────────────now64()─┬──────────nowInBlock64()─┬─sleep(1)─┐ +│ 2025-07-29 17:07:29.526 │ 2025-07-29 17:07:29.534 │ 0 │ +│ 2025-07-29 17:07:29.526 │ 2025-07-29 17:07:30.535 │ 0 │ +│ 2025-07-29 17:07:29.526 │ 2025-07-29 17:07:31.535 │ 0 │ +└─────────────────────────┴─────────────────────────┴──────────┘ ``` +## serverTimezone {#serverTimezone} -## toRelativeMinuteNum {#torelativeminutenum} +引入于:v23.6 -将日期或带时间的日期转换为自某个过去固定时间点以来经过的分钟数。 +返回服务器的时区,即 [`timezone`](/operations/server-configuration-parameters/settings#timezone) 设置的值。 +如果在分布式表的上下文中执行此函数,则会生成与每个分片相关的正常列的值。否则则生成一个常量值。 **语法** ```sql -toRelativeMinuteNum(date) +serverTimeZone() ``` **参数** -- `date` — 日期或带时间的日期。 [Date](../data-types/date.md)/[DateTime](../data-types/datetime.md)/[DateTime64](../data-types/datetime64.md)。 - +- 无 **返回值** -- 从过去某个固定参考点计算的分钟数。 [UInt32](../data-types/int-uint.md)。 +返回服务器时区,类型为 [`String`](/sql-reference/data-types/string) **示例** -查询: +**使用示例** -```sql -SELECT - toRelativeMinuteNum(toDateTime('1993-10-05 05:20:36')) AS m1, - toRelativeMinuteNum(toDateTime('2000-09-20 14:11:29')) AS m2 +```sql title=Query +SELECT serverTimeZone() ``` -结果: - -```response -┌───────m1─┬───────m2─┐ -│ 12496580 │ 16157531 │ -└──────────┴──────────┘ +```response title=Response +┌─serverTimeZone()─┐ +│ UTC │ +└──────────────────┘ ``` +## subDate {#subDate} -## toRelativeSecondNum {#torelativesecondnum} +引入于:v23.9 -将日期或带时间的日期转换为自某个过去固定时间点以来经过的秒数。 +从提供的日期、带时间的日期或字符串编码的日期或带时间中减去时间间隔。 +如果减法结果超出数据类型的边界,结果是未定义的。 **语法** ```sql -toRelativeSecondNum(date) +subDate(datetime, interval) ``` **参数** -- `date` — 日期或带时间的日期。 [Date](../data-types/date.md)/[DateTime](../data-types/datetime.md)/[DateTime64](../data-types/datetime64.md)。 +- `datetime` — 要减去 `interval` 的日期或带时间的日期。 [`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) +- `interval` — 要减去的间隔。 [`Interval`](/sql-reference/data-types/int-uint) **返回值** -- 从过去某个固定参考点计算的秒数。 [UInt32](../data-types/int-uint.md)。 +返回通过从 `datetime` 中减去 `interval` 获得的日期或带时间的日期。 [`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) **示例** -查询: +**从日期中减去间隔** -```sql -SELECT - toRelativeSecondNum(toDateTime('1993-10-05 05:20:36')) AS s1, - toRelativeSecondNum(toDateTime('2000-09-20 14:11:29')) AS s2 +```sql title=Query +SELECT subDate(toDate('2018-01-01'), INTERVAL 3 YEAR) ``` -结果: - -```response -┌────────s1─┬────────s2─┐ -│ 749794836 │ 969451889 │ -└───────────┴───────────┘ +```response title=Response +┌─subDate(toDate('2018-01-01'), toIntervalYear(3))─┐ +│ 2015-01-01 │ +└──────────────────────────────────────────────────┘ ``` +## subtractDays {#subtractDays} -## toISOYear {#toisoyear} +引入于:v1.1 -将日期或带时间的日期转换为 ISO 年,返回 UInt16 类型的数字。 +从日期、带时间的日期或字符串编码的日期或带时间中减去指定的天数。 **语法** ```sql -toISOYear(value) +subtractDays(datetime, num) ``` **参数** -- `value` — 带日期或带时间的值。 [Date](../data-types/date.md)、[Date32](../data-types/date32.md)、[DateTime](../data-types/datetime.md) 或 [DateTime64](../data-types/datetime64.md) +- `datetime` — 要从中减去指定天数的日期或带时间的日期。 [`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64)或 [`String`](/sql-reference/data-types/string) +- `num` — 要减去的天数。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) **返回值** -- 输入值转换为 ISO 年的数字。 [UInt16](../data-types/int-uint.md)。 +返回 `datetime` 减去 `num` 天 [`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) **示例** -查询: +**从不同日期类型减去天数** -```sql +```sql title=Query +WITH + toDate('2024-01-01') AS date, + toDateTime('2024-01-01 00:00:00') AS date_time, + '2024-01-01 00:00:00' AS date_time_string SELECT - toISOYear(toDate('2024/10/02')) as year1, - toISOYear(toDateTime('2024-10-02 01:30:00')) as year2 + subtractDays(date, 31) AS subtract_days_with_date, + subtractDays(date_time, 31) AS subtract_days_with_date_time, + subtractDays(date_time_string, 31) AS subtract_days_with_date_time_string +``` + +```response title=Response +┌─subtract_days_with_date─┬─subtract_days_with_date_time─┬─subtract_days_with_date_time_string─┐ +│ 2023-12-01 │ 2023-12-01 00:00:00 │ 2023-12-01 00:00:00.000 │ +└─────────────────────────┴──────────────────────────────┴─────────────────────────────────────┘ ``` -结果: +**使用替代的 INTERVAL 语法** -```response -┌─year1─┬─year2─┐ -│ 2024 │ 2024 │ -└───────┴───────┘ +```sql title=Query +SELECT dateSub('1998-06-16'::Date, INTERVAL 10 day) ``` -## toISOWeek {#toisoweek} +```response title=Response +┌─minus(CAST('⋯valDay(10))─┐ +│ 1998-06-06 │ +└──────────────────────────┘ +``` +## subtractHours {#subtractHours} -将日期或带时间的日期转换为包含 ISO 周数的 UInt8 数字。 +引入于:v1.1 + +从日期、带时间的日期或字符串编码的日期或带时间中减去指定的小时数。 **语法** ```sql -toISOWeek(value) +subtractHours(datetime, num) ``` **参数** -- `value` — 带日期或带时间的值。 +- `datetime` — 要从中减去指定小时的日期或带时间的日期。 [`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32)或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64)或 [`String`](/sql-reference/data-types/string) +- `num` — 要减去的小时数。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) **返回值** -- `value` 转换为当前 ISO 周数。 [UInt8](../data-types/int-uint.md)。 +返回 `datetime` 减去 `num` 小时 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64(3)`](/sql-reference/data-types/datetime64) **示例** -查询: +**从不同日期类型减去小时数** -```sql +```sql title=Query +WITH + toDate('2024-01-01') AS date, + toDateTime('2024-01-01 00:00:00') AS date_time, + '2024-01-01 00:00:00' AS date_time_string SELECT - toISOWeek(toDate('2024/10/02')) AS week1, - toISOWeek(toDateTime('2024/10/02 01:30:00')) AS week2 + subtractHours(date, 12) AS subtract_hours_with_date, + subtractHours(date_time, 12) AS subtract_hours_with_date_time, + subtractHours(date_time_string, 12) AS subtract_hours_with_date_time_string ``` -响应: - -```response -┌─week1─┬─week2─┐ -│ 40 │ 40 │ -└───────┴───────┘ +```response title=Response +┌─subtract_hours_with_date─┬─subtract_hours_with_date_time─┬─subtract_hours_with_date_time_string─┐ +│ 2023-12-31 12:00:00 │ 2023-12-31 12:00:00 │ 2023-12-31 12:00:00.000 │ +└──────────────────────────┴───────────────────────────────┴──────────────────────────────────────┘ ``` -## toWeek {#toweek} - -此函数返回日期或日期时间的周数。 `toWeek()` 的两参数形式允许您指定一周是从周日开始还是周一开始,以及返回值是否应在 0 到 53 或 1 到 53 的范围内。如果省略 mode 参数,默认模式为 0。 - -`toISOWeek()` 是兼容函数,相当于 `toWeek(date,3)`。 +**使用替代的 INTERVAL 语法** -以下表格描述了 mode 参数的工作方式。 - -| Mode | 一周的第一天 | 范围 | 第 1 周是这一年中的第一周 ... | -|------|---------------|-------|----------------------------------| -| 0 | 周日 | 0-53 | 这一年内有一个周日 | -| 1 | 周一 | 0-53 | 这一年内有 4 天或更多天 | -| 2 | 周日 | 1-53 | 这一年内有一个周日 | -| 3 | 周一 | 1-53 | 这一年内有 4 天或更多天 | -| 4 | 周日 | 0-53 | 这一年内有 4 天或更多天 | -| 5 | 周一 | 0-53 | 这一年内有一个周一 | -| 6 | 周日 | 1-53 | 这一年内有 4 天或更多天 | -| 7 | 周一 | 1-53 | 这一年内有一个周一 | -| 8 | 周日 | 1-53 | 包含 1 月 1 日 | -| 9 | 周一 | 1-53 | 包含 1 月 1 日 | +```sql title=Query +SELECT dateSub('1998-06-16'::Date, INTERVAL 10 hour) +``` -适用于“这一年内有 4 天或更多天”模式的值,周按照 ISO 8601:1988 编号: +```response title=Response +┌─minus(CAST('⋯alHour(10))─┐ +│ 1998-06-15 14:00:00 │ +└──────────────────────────┘ +``` +## subtractInterval {#subtractInterval} -- 如果包含 1 月 1 日的周在新的一年中有 4 天或更多天,则这一周为第 1 周。 +引入于:v22.11 -- 否则,它为前一年的最后一周,下一周为第 1 周。 +将一个间隔的负值添加到另一个间隔或间隔元组中。 -适用于“包含 1 月 1 日”模式的值,其包含 1 月 1 日的那一周为第 1 周。 -即使该周在新的一年中仅包含一天,结果也不影响。 -也就是说,如果 12 月的最后一周包含下一年的 1 月 1 日,则该周为下一年的第 1 周。 +注意:相同类型的间隔将合并为一个单一的间隔。例如,如果传入 `toIntervalDay(2)` 和 `toIntervalDay(1)`,则结果将是 `(1)` 而不是 `(2,1)`。 **语法** ```sql -toWeek(t[, mode[, time_zone]]) +subtractInterval(interval_1, interval_2) ``` -别名: `WEEK` - **参数** -- `t` – 日期或日期时间。 -- `mode` – 可选参数,值的范围为 \[0,9\],默认为 0。 -- `Timezone` – 可选参数,表现得像其他转换函数。 +- `interval_1` — 第一个间隔或间隔元组。 [`Interval`](/sql-reference/data-types/int-uint) 或 [`Tuple(Interval)`](/sql-reference/data-types/tuple) +- `interval_2` — 第二个间隔,将被取负。 [`Interval`](/sql-reference/data-types/int-uint) + +**返回值** -第一个参数也可以指定为 [String](../data-types/string.md),格式由 [parseDateTime64BestEffort()](type-conversion-functions.md#parsedatetime64besteffort) 支持。仅出于与某些第三方工具的 MySQL 兼容理由而存在字符串参数支持。因为字符串参数的支持在将来可能会依赖于新的 MySQL 兼容设置,并且字符串解析通常比较慢,建议不要使用它。 +返回间隔元组 [`Tuple(T)`](/sql-reference/data-types/tuple) **示例** -```sql -SELECT toDate('2016-12-27') AS date, toWeek(date) AS week0, toWeek(date,1) AS week1, toWeek(date,9) AS week9; -``` +**减去间隔** -```text -┌───────date─┬─week0─┬─week1─┬─week9─┐ -│ 2016-12-27 │ 52 │ 52 │ 1 │ -└────────────┴───────┴───────┴───────┘ +```sql title=Query +SELECT subtractInterval(INTERVAL 1 DAY, INTERVAL 1 MONTH); +SELECT subtractInterval((INTERVAL 1 DAY, INTERVAL 1 YEAR), INTERVAL 1 MONTH); +SELECT subtractInterval(INTERVAL 2 DAY, INTERVAL 1 DAY); ``` -## toYearWeek {#toyearweek} - -返回日期的年份和周数。结果中的年份可能与日期参数中的年份不同,适用于年份的第一周和最后一周。 -mode 参数的工作方式与 `toWeek()` 的 mode 参数相同。对于单参数语法,使用 0 的 mode 值。 +```response title=Response +┌─subtractInterval(toIntervalDay(1), toIntervalMonth(1))─┐ +│ (1,-1) │ +└────────────────────────────────────────────────────────┘ +┌─subtractInterval((toIntervalDay(1), toIntervalYear(1)), toIntervalMonth(1))─┐ +│ (1,1,-1) │ +└─────────────────────────────────────────────────────────────────────────────┘ +┌─subtractInterval(toIntervalDay(2), toIntervalDay(1))─┐ +│ (1) │ +└──────────────────────────────────────────────────────┘ +``` +## subtractMicroseconds {#subtractMicroseconds} -`toISOYear()` 是兼容函数,相当于 `intDiv(toYearWeek(date,3),100)`。 +引入于:v22.6 -:::warning -`toYearWeek()` 返回的周数与 `toWeek()` 返回的周数可能不同。`toWeek()` 总是在给定年份的上下文中返回周数,如果 `toWeek()` 返回 `0`,则 `toYearWeek()` 返回对应于上一年最后一周的值。请参阅下面示例中的 `prev_yearWeek`。 -::: +从带时间的日期或字符串编码的带时间的日期中减去指定的微秒数。 **语法** ```sql -toYearWeek(t[, mode[, timezone]]) +subtractMicroseconds(datetime, num) ``` -别名: `YEARWEEK` +**参数** + +- `datetime` — 带时间的日期,减去指定的微秒数。 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64)或 [`String`](/sql-reference/data-types/string) +- `num` — 要减去的微秒数。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) + +**返回值** -第一个参数也可以指定为 [String](../data-types/string.md),格式由 [parseDateTime64BestEffort()](type-conversion-functions.md#parsedatetime64besteffort) 支持。仅出于与某些第三方工具的 MySQL 兼容理由而存在字符串参数支持。因为字符串参数的支持在将来可能会依赖于新的 MySQL 兼容设置,并且字符串解析通常比较慢,建议不要使用它。 +返回 `datetime` 减去 `num` 微秒 [`DateTime64`](/sql-reference/data-types/datetime64) **示例** -```sql -SELECT toDate('2016-12-27') AS date, toYearWeek(date) AS yearWeek0, toYearWeek(date,1) AS yearWeek1, toYearWeek(date,9) AS yearWeek9, toYearWeek(toDate('2022-01-01')) AS prev_yearWeek; +**从不同日期时间类型减去微秒** + +```sql title=Query +WITH + toDateTime('2024-01-01 00:00:00') AS date_time, + '2024-01-01 00:00:00' AS date_time_string +SELECT + subtractMicroseconds(date_time, 1000000) AS subtract_microseconds_with_date_time, + subtractMicroseconds(date_time_string, 1000000) AS subtract_microseconds_with_date_time_string ``` -```text -┌───────date─┬─yearWeek0─┬─yearWeek1─┬─yearWeek9─┬─prev_yearWeek─┐ -│ 2016-12-27 │ 201652 │ 201652 │ 201701 │ 202152 │ -└────────────┴───────────┴───────────┴───────────┴───────────────┘ +```response title=Response +┌─subtract_microseconds_with_date_time─┬─subtract_microseconds_with_date_time_string─┐ +│ 2023-12-31 23:59:59.000000 │ 2023-12-31 23:59:59.000000 │ +└──────────────────────────────────────┴─────────────────────────────────────────────┘ ``` -## toDaysSinceYearZero {#todayssinceyearzero} -在 [ISO 8601 定义的先行公历](https://en.wikipedia.org/wiki/Gregorian_calendar#Proleptic_Gregorian_calendar) 中返回给定日期自 [公元 0000 年 1 月 1 日](https://en.wikipedia.org/wiki/Year_zero) 以来经过的天数。计算方式与 MySQL 的 [`TO_DAYS()`](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_to-days) 函数相同。 +**使用替代的 INTERVAL 语法** -**语法** +```sql title=Query +SELECT dateSub('1998-06-16'::DateTime, INTERVAL 10 microsecond) +``` -```sql -toDaysSinceYearZero(date[, time_zone]) +```response title=Response +┌─minus(CAST('1⋯osecond(10))─┐ +│ 1998-06-15 23:59:59.999990 │ +└────────────────────────────┘ ``` -别名: `TO_DAYS` +## subtractMilliseconds {#subtractMilliseconds} -**参数** +引入于:v22.6 -- `date` — 计算自公元零年以来经过的天数的日期。 [Date](../data-types/date.md)、[Date32](../data-types/date32.md)、[DateTime](../data-types/datetime.md) 或 [DateTime64](../data-types/datetime64.md)。 -- `time_zone` — 字符串类型常量值或表示时区的表达式。 [String types](../data-types/string.md) +从带有时间的日期或字符串编码的带有时间的日期中减去指定数量的毫秒。 -**返回值** +**语法** -自日期 0000-01-01 以来经过的天数。 [UInt32](../data-types/int-uint.md)。 +```sql +subtractMilliseconds(datetime, num) +``` + +**参数** + +- `datetime` — 要减去指定毫秒数的带有时间的日期。[`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) 或 [`String`](/sql-reference/data-types/string) +- `num` — 要减去的毫秒数。[`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) + +**返回值** + +返回 `datetime` 减去 `num` 毫秒后的值 [`DateTime64`](/sql-reference/data-types/datetime64) **示例** -```sql -SELECT toDaysSinceYearZero(toDate('2023-09-08')); -``` +**从不同日期时间类型中减去毫秒** -结果: +```sql title=Query +WITH + toDateTime('2024-01-01 00:00:00') AS date_time, + '2024-01-01 00:00:00' AS date_time_string +SELECT + subtractMilliseconds(date_time, 1000) AS subtract_milliseconds_with_date_time, + subtractMilliseconds(date_time_string, 1000) AS subtract_milliseconds_with_date_time_string +``` -```text -┌─toDaysSinceYearZero(toDate('2023-09-08')))─┐ -│ 713569 │ -└────────────────────────────────────────────┘ +```response title=Response +┌─subtract_milliseconds_with_date_time─┬─subtract_milliseconds_with_date_time_string─┐ +│ 2023-12-31 23:59:59.000 │ 2023-12-31 23:59:59.000 │ +└──────────────────────────────────────┴─────────────────────────────────────────────┘ ``` -**参见** +**使用替代的 INTERVAL 语法** -- [fromDaysSinceYearZero](#fromdayssinceyearzero) +```sql title=Query +SELECT dateSub('1998-06-16'::DateTime, INTERVAL 10 millisecond) +``` -## fromDaysSinceYearZero {#fromdayssinceyearzero} +```response title=Response +┌─minus(CAST('⋯second(10))─┐ +│ 1998-06-15 23:59:59.990 │ +└──────────────────────────┘ +``` +## subtractMinutes {#subtractMinutes} -返回给定的自 [公元 0000 年 1 月 1 日](https://en.wikipedia.org/wiki/Year_zero) 以来经过的天数对应的日期,在 [ISO 8601 定义的先行公历](https://en.wikipedia.org/wiki/Gregorian_calendar#Proleptic_Gregorian_calendar) 中。计算方式与 MySQL 的 [`FROM_DAYS()`](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_from-days) 函数相同。 +引入于:v1.1 -如果无法在 [Date](../data-types/date.md) 类型的范围内表示结果,则结果未定义。 +从日期、带有时间的日期或字符串编码的日期或带有时间的日期中减去指定数量的分钟。 **语法** ```sql -fromDaysSinceYearZero(days) +subtractMinutes(datetime, num) ``` -别名: `FROM_DAYS` - **参数** -- `days` — 自公元零年以来经过的天数。 +- `datetime` — 要减去指定分钟数的日期或带有时间的日期。[`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) 或 [`String`](/sql-reference/data-types/string) +- `num` — 要减去的分钟数。[`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) **返回值** -与经过的天数相对应的日期。 [Date](../data-types/date.md)。 +返回 `datetime` 减去 `num` 分钟后的值 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64(3)`](/sql-reference/data-types/datetime64) **示例** -```sql -SELECT fromDaysSinceYearZero(739136), fromDaysSinceYearZero(toDaysSinceYearZero(toDate('2023-09-08'))); -``` - -结果: +**从不同日期类型中减去分钟** -```text -┌─fromDaysSinceYearZero(739136)─┬─fromDaysSinceYearZero(toDaysSinceYearZero(toDate('2023-09-08')))─┐ -│ 2023-09-08 │ 2023-09-08 │ -└───────────────────────────────┴──────────────────────────────────────────────────────────────────┘ +```sql title=Query +WITH + toDate('2024-01-01') AS date, + toDateTime('2024-01-01 00:00:00') AS date_time, + '2024-01-01 00:00:00' AS date_time_string +SELECT + subtractMinutes(date, 30) AS subtract_minutes_with_date, + subtractMinutes(date_time, 30) AS subtract_minutes_with_date_time, + subtractMinutes(date_time_string, 30) AS subtract_minutes_with_date_time_string ``` -**参见** - -- [toDaysSinceYearZero](#todayssinceyearzero) +```response title=Response +┌─subtract_minutes_with_date─┬─subtract_minutes_with_date_time─┬─subtract_minutes_with_date_time_string─┐ +│ 2023-12-31 23:30:00 │ 2023-12-31 23:30:00 │ 2023-12-31 23:30:00.000 │ +└────────────────────────────┴─────────────────────────────────┴────────────────────────────────────────┘ +``` -## fromDaysSinceYearZero32 {#fromdayssinceyearzero32} +**使用替代的 INTERVAL 语法** -类似于 [fromDaysSinceYearZero](#fromdayssinceyearzero),但返回 [Date32](../data-types/date32.md)。 +```sql title=Query +SELECT dateSub('1998-06-16'::Date, INTERVAL 10 minute) +``` -## age {#age} +```response title=Response +┌─minus(CAST('⋯Minute(10))─┐ +│ 1998-06-15 23:50:00 │ +└──────────────────────────┘ +``` +## subtractMonths {#subtractMonths} -返回 `startdate` 和 `enddate` 之间差异的 `unit` 组件。差异是使用 1 纳秒的精度计算的。 -例如,`2021-12-29` 和 `2022-01-01` 之间的差异在 `day` 单位上为 3 天,在 `month` 单位上为 0 个月,在 `year` 单位上为 0 年。 +引入于:v1.1 -有关 `age` 的替代方案,请参见函数 `date_diff`。 +从日期、带有时间的日期或字符串编码的日期或带有时间的日期中减去指定数量的月份。 **语法** ```sql -age('unit', startdate, enddate, [timezone]) +subtractMonths(datetime, num) ``` **参数** -- `unit` — 结果的时间间隔类型。 [String](../data-types/string.md)。 - 可能的值: - - - `nanosecond`, `nanoseconds`, `ns` - - `microsecond`, `microseconds`, `us`, `u` - - `millisecond`, `milliseconds`, `ms` - - `second`, `seconds`, `ss`, `s` - - `minute`, `minutes`, `mi`, `n` - - `hour`, `hours`, `hh`, `h` - - `day`, `days`, `dd`, `d` - - `week`, `weeks`, `wk`, `ww` - - `month`, `months`, `mm`, `m` - - `quarter`, `quarters`, `qq`, `q` - - `year`, `years`, `yyyy`, `yy` - -- `startdate` — 第一个要相减的时间值(被减数)。 [Date](../data-types/date.md)、[Date32](../data-types/date32.md)、[DateTime](../data-types/datetime.md) 或 [DateTime64](../data-types/datetime64.md)。 - -- `enddate` — 第二个时间值(被减数的减数)。 [Date](../data-types/date.md)、[Date32](../data-types/date32.md)、[DateTime](../data-types/datetime.md) 或 [DateTime64](../data-types/datetime64.md)。 - -- `timezone` — [时区名称](../../operations/server-configuration-parameters/settings.md#timezone)(可选)。如果指定,则适用于 `startdate` 和 `enddate`。如果未指定,则使用 `startdate` 和 `enddate` 的时区。如果它们不相同,则结果未指定。 [String](../data-types/string.md)。 +- `datetime` — 要减去指定月份数的日期或带有时间的日期。[`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) 或 [`String`](/sql-reference/data-types/string) +- `num` — 要减去的月份数。[`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) **返回值** -以 `unit` 表示的 `enddate` 和 `startdate` 之间的差异。 [Int](../data-types/int-uint.md)。 +返回 `datetime` 减去 `num` 个月后的值 [`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) **示例** -```sql -SELECT age('hour', toDateTime('2018-01-01 22:30:00'), toDateTime('2018-01-02 23:00:00')); -``` - -结果: +**从不同日期类型中减去月份** -```text -┌─age('hour', toDateTime('2018-01-01 22:30:00'), toDateTime('2018-01-02 23:00:00'))─┐ -│ 24 │ -└───────────────────────────────────────────────────────────────────────────────────┘ +```sql title=Query +WITH + toDate('2024-01-01') AS date, + toDateTime('2024-01-01 00:00:00') AS date_time, + '2024-01-01 00:00:00' AS date_time_string +SELECT + subtractMonths(date, 1) AS subtract_months_with_date, + subtractMonths(date_time, 1) AS subtract_months_with_date_time, + subtractMonths(date_time_string, 1) AS subtract_months_with_date_time_string ``` -```sql -SELECT - toDate('2022-01-01') AS e, - toDate('2021-12-29') AS s, - age('day', s, e) AS day_age, - age('month', s, e) AS month__age, - age('year', s, e) AS year_age; +```response title=Response +┌─subtract_months_with_date─┬─subtract_months_with_date_time─┬─subtract_months_with_date_time_string─┐ +│ 2023-12-01 │ 2023-12-01 00:00:00 │ 2023-12-01 00:00:00.000 │ +└───────────────────────────┴────────────────────────────────┴───────────────────────────────────────┘ ``` -结果: +**使用替代的 INTERVAL 语法** -```text -┌──────────e─┬──────────s─┬─day_age─┬─month__age─┬─year_age─┐ -│ 2022-01-01 │ 2021-12-29 │ 3 │ 0 │ 0 │ -└────────────┴────────────┴─────────┴────────────┴──────────┘ +```sql title=Query +SELECT dateSub('1998-06-16'::Date, INTERVAL 10 month) ``` -## date_diff {#date_diff} - -返回在 `startdate` 和 `enddate` 之间跨越的指定 `unit` 边界的数量。 -差异是使用相对单位计算的,例如 `2021-12-29` 和 `2022-01-01` 之间的差异在 `day` 单位上是 3 天(见 [toRelativeDayNum](#torelativedaynum)),在 `month` 单位上是 1 月(见 [toRelativeMonthNum](#torelativemonthnum)),在 `year` 单位上是 1 年(见 [toRelativeYearNum](#torelativeyearnum))。 +```response title=Response +┌─minus(CAST('⋯lMonth(10))─┐ +│ 1997-08-16 │ +└──────────────────────────┘ +``` +## subtractNanoseconds {#subtractNanoseconds} -如果指定了单位 `week`,则 `date_diff` 假定周一为一周的开始。注意,这种行为与函数 `toWeek()` 中默认的周日开始不同。 +引入于:v20.1 -有关 `date_diff` 的替代方案,请参见函数 `age`。 +从带有时间的日期或字符串编码的带有时间的日期中减去指定数量的纳秒。 **语法** ```sql -date_diff('unit', startdate, enddate, [timezone]) +subtractNanoseconds(datetime, num) ``` -别名: `dateDiff`, `DATE_DIFF`, `timestampDiff`, `timestamp_diff`, `TIMESTAMP_DIFF`。 - **参数** -- `unit` — 结果的时间间隔类型。 [String](../data-types/string.md)。 - 可能的值: - - - `nanosecond`, `nanoseconds`, `ns` - - `microsecond`, `microseconds`, `us`, `u` - - `millisecond`, `milliseconds`, `ms` - - `second`, `seconds`, `ss`, `s` - - `minute`, `minutes`, `mi`, `n` - - `hour`, `hours`, `hh`, `h` - - `day`, `days`, `dd`, `d` - - `week`, `weeks`, `wk`, `ww` - - `month`, `months`, `mm`, `m` - - `quarter`, `quarters`, `qq`, `q` - - `year`, `years`, `yyyy`, `yy` - -- `startdate` — 第一个要相减的时间值(被减数)。 [Date](../data-types/date.md)、[Date32](../data-types/date32.md)、[DateTime](../data-types/datetime.md) 或 [DateTime64](../data-types/datetime64.md)。 - -- `enddate` — 第二个时间值(被减数的减数)。 [Date](../data-types/date.md)、[Date32](../data-types/date32.md)、[DateTime](../data-types/datetime.md) 或 [DateTime64](../data-types/datetime64.md)。 - -- `timezone` — [时区名称](../../operations/server-configuration-parameters/settings.md#timezone) (可选)。如果指定,则适用于 `startdate` 和 `enddate`。如果未指定,则使用 `startdate` 和 `enddate` 的时区。如果它们不相同,则结果未指定。 [String](../data-types/string.md)。 +- `datetime` — 要减去指定纳秒数的带有时间的日期。[`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) 或 [`String`](/sql-reference/data-types/string) +- `num` — 要减去的纳秒数。[`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) **返回值** -以 `unit` 表示的 `enddate` 和 `startdate` 之间的差异。 [Int](../data-types/int-uint.md)。 +返回 `datetime` 减去 `num` 纳秒后的值 [`DateTime64`](/sql-reference/data-types/datetime64) **示例** -```sql -SELECT dateDiff('hour', toDateTime('2018-01-01 22:00:00'), toDateTime('2018-01-02 23:00:00')); -``` - -结果: +**从不同日期时间类型中减去纳秒** -```text -┌─dateDiff('hour', toDateTime('2018-01-01 22:00:00'), toDateTime('2018-01-02 23:00:00'))─┐ -│ 25 │ -└────────────────────────────────────────────────────────────────────────────────────────┘ +```sql title=Query +WITH + toDateTime('2024-01-01 00:00:00') AS date_time, + '2024-01-01 00:00:00' AS date_time_string +SELECT + subtractNanoseconds(date_time, 1000) AS subtract_nanoseconds_with_date_time, + subtractNanoseconds(date_time_string, 1000) AS subtract_nanoseconds_with_date_time_string ``` -```sql -SELECT - toDate('2022-01-01') AS e, - toDate('2021-12-29') AS s, - dateDiff('day', s, e) AS day_diff, - dateDiff('month', s, e) AS month__diff, - dateDiff('year', s, e) AS year_diff; +```response title=Response +┌─subtract_nanoseconds_with_date_time─┬─subtract_nanoseconds_with_date_time_string─┐ +│ 2023-12-31 23:59:59.999999000 │ 2023-12-31 23:59:59.999999000 │ +└─────────────────────────────────────┴────────────────────────────────────────────┘ ``` -结果: +**使用替代的 INTERVAL 语法** -```text -┌──────────e─┬──────────s─┬─day_diff─┬─month__diff─┬─year_diff─┐ -│ 2022-01-01 │ 2021-12-29 │ 3 │ 1 │ 1 │ -└────────────┴────────────┴──────────┴─────────────┴───────────┘ +```sql title=Query +SELECT dateSub('1998-06-16'::DateTime, INTERVAL 10 nanosecond) +``` + +```response title=Response +┌─minus(CAST('19⋯anosecond(10))─┐ +│ 1998-06-15 23:59:59.999999990 │ +└───────────────────────────────┘ ``` +## subtractQuarters {#subtractQuarters} -## date\_trunc {#date_trunc} +引入于:v20.1 -将日期和时间数据截断到指定的日期部分。 +从日期、带有时间的日期或字符串编码的日期或带有时间的日期中减去指定数量的季度。 **语法** ```sql -date_trunc(unit, value[, timezone]) +subtractQuarters(datetime, num) ``` -别名: `dateTrunc`。 - **参数** -- `unit` — 截断结果的时间间隔类型。 [String Literal](/sql-reference/syntax#string)。 - 可能的值: - - - `nanosecond` - 仅与 DateTime64 兼容 - - `microsecond` - 仅与 DateTime64 兼容 - - `millisecond` - 仅与 DateTime64 兼容 - - `second` - - `minute` - - `hour` - - `day` - - `week` - - `month` - - `quarter` - - `year` - - `unit` 参数不区分大小写。 - -- `value` — 日期和时间。 [Date](../data-types/date.md)、[Date32](../data-types/date32.md)、[DateTime](../data-types/datetime.md) 或 [DateTime64](../data-types/datetime64.md)。 -- `timezone` — 返回值的 [时区名称](../../operations/server-configuration-parameters/settings.md#timezone)(可选)。如果未指定,则函数使用 `value` 参数的时区。 [String](../data-types/string.md)。 +- `datetime` — 要减去指定季度数的日期或带有时间的日期。[`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) 或 [`String`](/sql-reference/data-types/string) +- `num` — 要减去的季度数。[`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) **返回值** -如果 unit 参数为 Year、Quarter、Month 或 Week, -- 且 value 参数为 Date32 或 DateTime64,则返回 [Date32](../data-types/date32.md); -- 否则返回 [Date](../data-types/date.md)。 - -如果 unit 参数为 Day、Hour、Minute 或 Second, -- 且 value 参数为 Date32 或 DateTime64,则返回 [DateTime64](../data-types/datetime64.md); -- 否则返回 [DateTime](../data-types/datetime.md)。 - -如果 unit 参数为 Millisecond、Microsecond 或 Nanosecond,则返回 [DateTime64](../data-types/datetime64.md),其刻度为 3、6 或 9(取决于 unit 参数)。 +返回 `datetime` 减去 `num` 季度后的值 [`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) **示例** -不带时区的查询: +**从不同日期类型中减去季度** -```sql -SELECT now(), date_trunc('hour', now()); +```sql title=Query +WITH + toDate('2024-01-01') AS date, + toDateTime('2024-01-01 00:00:00') AS date_time, + '2024-01-01 00:00:00' AS date_time_string +SELECT + subtractQuarters(date, 1) AS subtract_quarters_with_date, + subtractQuarters(date_time, 1) AS subtract_quarters_with_date_time, + subtractQuarters(date_time_string, 1) AS subtract_quarters_with_date_time_string ``` -结果: - -```text -┌───────────────now()─┬─date_trunc('hour', now())─┐ -│ 2020-09-28 10:40:45 │ 2020-09-28 10:00:00 │ -└─────────────────────┴───────────────────────────┘ +```response title=Response +┌─subtract_quarters_with_date─┬─subtract_quarters_with_date_time─┬─subtract_quarters_with_date_time_string─┐ +│ 2023-10-01 │ 2023-10-01 00:00:00 │ 2023-10-01 00:00:00.000 │ +└─────────────────────────────┴──────────────────────────────────┴─────────────────────────────────────────┘ ``` -带指定时区的查询: +**使用替代的 INTERVAL 语法** -```sql -SELECT now(), date_trunc('hour', now(), 'Asia/Istanbul'); +```sql title=Query +SELECT dateSub('1998-06-16'::Date, INTERVAL 10 quarter) ``` -结果: - -```text -┌───────────────now()─┬─date_trunc('hour', now(), 'Asia/Istanbul')─┐ -│ 2020-09-28 10:46:26 │ 2020-09-28 13:00:00 │ -└─────────────────────┴────────────────────────────────────────────┘ +```response title=Response +┌─minus(CAST('1⋯Quarter(10))─┐ +│ 1996-09-16 │ +└───────────────────────────┘ ``` +## subtractSeconds {#subtractSeconds} -**参见** - -- [toStartOfInterval](#tostartofinterval) +引入于:v1.1 -## date\_add {#date_add} - -将时间间隔或日期间隔加到提供的日期或带时间的日期上。 - -如果加法结果超出数据类型的范围,则结果未定义。 +从日期、带有时间的日期或字符串编码的日期或带有时间的日期中减去指定数量的秒。 **语法** ```sql -date_add(unit, value, date) -``` - -替代语法: - -```sql -date_add(date, INTERVAL value unit) +subtractSeconds(datetime, num) ``` -别名: `dateAdd`, `DATE_ADD`。 - **参数** -- `unit` — 要加的时间间隔类型。注意:这不是 [String](../data-types/string.md),因此不能加引号。 - 可能的值: - - - `second` - - `minute` - - `hour` - - `day` - - `week` - - `month` - - `quarter` - - `year` - -- `value` — 要加的间隔的值。 [Int](../data-types/int-uint.md)。 -- `date` — 要将 `value` 加到的日期或带时间的日期。 [Date](../data-types/date.md)、[Date32](../data-types/date32.md)、[DateTime](../data-types/datetime.md) 或 [DateTime64](../data-types/datetime64.md)。 +- `datetime` — 要减去指定秒数的日期或带有时间的日期。[`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) 或 [`String`](/sql-reference/data-types/string) +- `num` — 要减去的秒数。[`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) **返回值** -通过将以 `unit` 表达的 `value` 加到 `date` 上获得的日期或带时间的日期。 [Date](../data-types/date.md)、[Date32](../data-types/date32.md)、[DateTime](../data-types/datetime.md) 或 [DateTime64](../data-types/datetime64.md)。 +返回 `datetime` 减去 `num` 秒后的值 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64(3)`](/sql-reference/data-types/datetime64) **示例** -```sql -SELECT date_add(YEAR, 3, toDate('2018-01-01')); +**从不同日期类型中减去秒** + +```sql title=Query +WITH + toDate('2024-01-01') AS date, + toDateTime('2024-01-01 00:00:00') AS date_time, + '2024-01-01 00:00:00' AS date_time_string +SELECT + subtractSeconds(date, 60) AS subtract_seconds_with_date, + subtractSeconds(date_time, 60) AS subtract_seconds_with_date_time, + subtractSeconds(date_time_string, 60) AS subtract_seconds_with_date_time_string ``` -结果: +```response title=Response +┌─subtract_seconds_with_date─┬─subtract_seconds_with_date_time─┬─subtract_seconds_with_date_time_string─┐ +│ 2023-12-31 23:59:00 │ 2023-12-31 23:59:00 │ 2023-12-31 23:59:00.000 │ +└────────────────────────────┴─────────────────────────────────┴────────────────────────────────────────┘ +``` -```text -┌─plus(toDate('2018-01-01'), toIntervalYear(3))─┐ -│ 2021-01-01 │ -└───────────────────────────────────────────────┘ +**使用替代的 INTERVAL 语法** + +```sql title=Query +SELECT dateSub('1998-06-16'::Date, INTERVAL 10 second) ``` -```sql -SELECT date_add(toDate('2018-01-01'), INTERVAL 3 YEAR); +```response title=Response +┌─minus(CAST('⋯Second(10))─┐ +│ 1998-06-15 23:59:50 │ +└──────────────────────────┘ ``` +## subtractTupleOfIntervals {#subtractTupleOfIntervals} -结果: +引入于:v22.11 -```text -┌─plus(toDate('2018-01-01'), toIntervalYear(3))─┐ -│ 2021-01-01 │ -└───────────────────────────────────────────────┘ +连续地从日期或带有时间的日期中减去一组间隔。 + +**语法** + +```sql +subtractTupleOfIntervals(datetime, intervals) ``` -**参见** +**参数** -- [addDate](#adddate) +- `datetime` — 要减去间隔的日期或带有时间的日期。[`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) +- `intervals` — 要从 `datetime` 中减去的间隔元组。[`Tuple(Interval)`](/sql-reference/data-types/tuple) -## date\_sub {#date_sub} +**返回值** -从提供的日期或带时间的日期中减去时间间隔或日期间隔。 +返回减去 `intervals` 后的日期 [`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) -如果减法结果超出数据类型的范围,则结果未定义。 +**示例** -**语法** +**从日期中减去间隔元组** -```sql -date_sub(unit, value, date) +```sql title=Query +WITH toDate('2018-01-01') AS date SELECT subtractTupleOfIntervals(date, (INTERVAL 1 DAY, INTERVAL 1 YEAR)) ``` -替代语法: - -```sql -date_sub(date, INTERVAL value unit) +```response title=Response +┌─subtractTupl⋯alYear(1)))─┐ +│ 2016-12-31 │ +└──────────────────────────┘ ``` +## subtractWeeks {#subtractWeeks} -别名: `dateSub`, `DATE_SUB`。 +引入于:v1.1 -**参数** +从日期、带有时间的日期或字符串编码的日期或带有时间的日期中减去指定数量的周。 -- `unit` — 要减去的时间间隔类型。注意:这不是 [String](../data-types/string.md),因此不能加引号。 +**语法** - 可能的值: +```sql +subtractWeeks(datetime, num) +``` - - `second` - - `minute` - - `hour` - - `day` - - `week` - - `month` - - `quarter` - - `year` +**参数** -- `value` — 要减去的间隔的值。 [Int](../data-types/int-uint.md)。 -- `date` — 要从中减去 `value` 的日期或带时间的日期。 [Date](../data-types/date.md)、[Date32](../data-types/date32.md)、[DateTime](../data-types/datetime.md) 或 [DateTime64](../data-types/datetime64.md)。 +- `datetime` — 要减去指定周数的日期或带有时间的日期。[`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) 或 [`String`](/sql-reference/data-types/string) +- `num` — 要减去的周数。[`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) **返回值** -通过将以 `unit` 表达的 `value` 从 `date` 中减去获得的日期或带时间的日期。 [Date](../data-types/date.md)、[Date32](../data-types/date32.md)、[DateTime](../data-types/datetime.md) 或 [DateTime64](../data-types/datetime64.md)。 +返回 `datetime` 减去 `num` 周后的值 [`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) **示例** -```sql -SELECT date_sub(YEAR, 3, toDate('2018-01-01')); -``` +**从不同日期类型中减去周** -结果: - -```text -┌─minus(toDate('2018-01-01'), toIntervalYear(3))─┐ -│ 2015-01-01 │ -└────────────────────────────────────────────────┘ +```sql title=Query +WITH + toDate('2024-01-01') AS date, + toDateTime('2024-01-01 00:00:00') AS date_time, + '2024-01-01 00:00:00' AS date_time_string +SELECT + subtractWeeks(date, 1) AS subtract_weeks_with_date, + subtractWeeks(date_time, 1) AS subtract_weeks_with_date_time, + subtractWeeks(date_time_string, 1) AS subtract_weeks_with_date_time_string ``` -```sql -SELECT date_sub(toDate('2018-01-01'), INTERVAL 3 YEAR); +```response title=Response +┌─subtract_weeks_with_date─┬─subtract_weeks_with_date_time─┬─subtract_weeks_with_date_time_string─┐ +│ 2023-12-25 │ 2023-12-25 00:00:00 │ 2023-12-25 00:00:00.000 │ +└──────────────────────────┴───────────────────────────────┴──────────────────────────────────────┘ ``` -结果: +**使用替代的 INTERVAL 语法** -```text -┌─minus(toDate('2018-01-01'), toIntervalYear(3))─┐ -│ 2015-01-01 │ -└────────────────────────────────────────────────┘ +```sql title=Query +SELECT dateSub('1998-06-16'::Date, INTERVAL 10 week) ``` -**参见** - -- [subDate](#subdate) - -## timestamp\_add {#timestamp_add} +```response title=Response +┌─minus(CAST('⋯alWeek(10))─┐ +│ 1998-04-07 │ +└──────────────────────────┘ +``` +## subtractYears {#subtractYears} -将指定的时间值与提供的日期或日期时间值相加。 +引入于:v1.1 -如果加法结果超出数据类型的范围,则结果未定义。 +从日期、带有时间的日期或字符串编码的日期或带有时间的日期中减去指定数量的年。 **语法** ```sql -timestamp_add(date, INTERVAL value unit) +subtractYears(datetime, num) ``` -别名: `timeStampAdd`, `TIMESTAMP_ADD`。 - **参数** -- `date` — 日期或带时间的日期。 [Date](../data-types/date.md)、[Date32](../data-types/date32.md)、[DateTime](../data-types/datetime.md) 或 [DateTime64](../data-types/datetime64.md)。 -- `value` — 要加的间隔的值。 [Int](../data-types/int-uint.md)。 -- `unit` — 要加的时间间隔类型。 [String](../data-types/string.md)。 - 可能的值: - - - `second` - - `minute` - - `hour` - - `day` - - `week` - - `month` - - `quarter` - - `year` +- `datetime` — 要减去指定年数的日期或带有时间的日期。[`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) 或 [`String`](/sql-reference/data-types/string) +- `num` — 要减去的年数。[`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) **返回值** -在指定的 `unit` 中运算后,日期或带时间的日期。 [Date](../data-types/date.md)、[Date32](../data-types/date32.md)、[DateTime](../data-types/datetime.md) 或 [DateTime64](../data-types/datetime64.md)。 +返回 `datetime` 减去 `num` 年后的值 [`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) **示例** -```sql -select timestamp_add(toDate('2018-01-01'), INTERVAL 3 MONTH); +**从不同日期类型中减去年** + +```sql title=Query +WITH + toDate('2024-01-01') AS date, + toDateTime('2024-01-01 00:00:00') AS date_time, + '2024-01-01 00:00:00' AS date_time_string +SELECT + subtractYears(date, 1) AS subtract_years_with_date, + subtractYears(date_time, 1) AS subtract_years_with_date_time, + subtractYears(date_time_string, 1) AS subtract_years_with_date_time_string ``` -结果: +```response title=Response +┌─subtract_years_with_date─┬─subtract_years_with_date_time─┬─subtract_years_with_date_time_string─┐ +│ 2023-01-01 │ 2023-01-01 00:00:00 │ 2023-01-01 00:00:00.000 │ +└──────────────────────────┴───────────────────────────────┴──────────────────────────────────────┘ +``` -```text -┌─plus(toDate('2018-01-01'), toIntervalMonth(3))─┐ -│ 2018-04-01 │ -└────────────────────────────────────────────────┘ +**使用替代的 INTERVAL 语法** + +```sql title=Query +SELECT dateSub('1998-06-16'::Date, INTERVAL 10 year) +``` + +```response title=Response +┌─minus(CAST('⋯alYear(10))─┐ +│ 1988-06-16 │ +└──────────────────────────┘ ``` +## timeDiff {#timeDiff} + +引入于:v23.4 -## timestamp\_sub {#timestamp_sub} +返回 `startdate` 和 `enddate` 之间跨越的指定 `unit` 边界的数量。差异通过相对单位计算。例如,2021-12-29 和 2022-01-01 之间的差异为3天,单位为天(参见 [`toRelativeDayNum`](#toRelativeDayNum)),单位为月为1个月(参见 [`toRelativeMonthNum`](#toRelativeMonthNum)),单位为年为1年(参见 [`toRelativeYearNum`](#toRelativeYearNum))。 -从提供的日期或带时间的日期中减去时间间隔。 +如果指定了单位 `week`,则 `timeDiff` 假定周从星期一开始。请注意,此行为与 `toWeek()` 函数的行为不同,后者默认周从星期天开始。 -如果减法结果超出数据类型的范围,则结果未定义。 +关于 [`timeDiff`](#timeDiff)的替代方案,请参见函数 [`age`](#age)。 **语法** ```sql -timestamp_sub(unit, value, date) +date_diff(unit, startdate, enddate, [timezone]) ``` -别名: `timeStampSub`, `TIMESTAMP_SUB`。 - **参数** -- `unit` — 要减去的时间间隔类型。 [String](../data-types/string.md)。 - 可能的值: - - - `second` - - `minute` - - `hour` - - `day` - - `week` - - `month` - - `quarter` - - `year` - -- `value` — 要减去的间隔的值。 [Int](../data-types/int-uint.md)。 -- `date` — 日期或带时间的日期。 [Date](../data-types/date.md)、[Date32](../data-types/date32.md)、[DateTime](../data-types/datetime.md) 或 [DateTime64](../data-types/datetime64.md)。 +- `unit` — 结果的间隔类型。 + +| 单位 | 可能的值 | +|-------------|-----------------------------------------------| +| nanosecond | `nanosecond`, `nanoseconds`, `ns` | +| microsecond | `microsecond`, `microseconds`, `us`, `u` | +| millisecond | `millisecond`, `milliseconds`, `ms` | +| second | `second`, `seconds`, `ss`, `s` | +| minute | `minute`, `minutes`, `mi`, `n` | +| hour | `hour`, `hours`, `hh`, `h` | +| day | `day`, `days`, `dd`, `d` | +| week | `week`, `weeks`, `wk`, `ww` | +| month | `month`, `months`, `mm`, `m` | +| quarter | `quarter`, `quarters`, `qq`, `q` | +| year | `year`, `years`, `yyyy`, `yy` | +- `startdate` — 第一个时间值(被减数)。[`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) +- `enddate` — 从中减去的第二个时间值(被减数)。[`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) +- `timezone` — 可选。时区名称。如果指定,应用于 `startdate` 和 `enddate`。如果未指定,则使用 `startdate` 和 `enddate` 的时区。如果它们不相同,则结果未定义。[`String`](/sql-reference/data-types/string) **返回值** -通过将以 `unit` 表达的 `value` 从 `date` 中减去获得的日期或带时间的日期。 [Date](../data-types/date.md)、[Date32](../data-types/date32.md)、[DateTime](../data-types/datetime.md) 或 [DateTime64](../data-types/datetime64.md)。 +返回以 `unit` 表示的 `enddate` 和 `startdate` 之间的差异。[`Int64`](/sql-reference/data-types/int-uint) **示例** -```sql -select timestamp_sub(MONTH, 5, toDateTime('2018-12-18 01:02:03')); +**计算以小时为单位的日期差异** + +```sql title=Query +SELECT timeDiff('hour', toDateTime('2018-01-01 22:00:00'), toDateTime('2018-01-02 23:00:00')) AS res +``` + +```response title=Response +┌─res─┐ +│ 25 │ +└─────┘ ``` -结果: +**计算不同单位的日期差异** -```text -┌─minus(toDateTime('2018-12-18 01:02:03'), toIntervalMonth(5))─┐ -│ 2018-07-18 01:02:03 │ -└──────────────────────────────────────────────────────────────┘ +```sql title=Query +SELECT + toDate('2022-01-01') AS e, + toDate('2021-12-29') AS s, + timeDiff('day', s, e) AS day_diff, + timeDiff('month', s, e) AS month_diff, + timeDiff('year', s, e) AS year_diff +``` + +```response title=Response +┌──────────e─┬──────────s─┬─day_diff─┬─month_diff─┬─year_diff─┐ +│ 2022-01-01 │ 2021-12-29 │ 3 │ 1 │ 1 │ +└────────────┴────────────┴──────────┴────────────┴───────────┘ ``` +## timeSlot {#timeSlot} -## addDate {#adddate} +引入于:v1.1 -将时间间隔加到提供的日期、日期时间或字符串编码的日期/日期时间上。 +将时间四舍五入到半小时长度间隔的开始。 -如果加法结果超出数据类型的范围,则结果未定义。 +:::note +虽然这个函数可以接收扩展类型 `Date32` 和 `DateTime64` 的值作为参数,但将其传递一个超出正常范围(1970 年至 2149 年的年份对于 `Date` / 2106 年对于 `DateTime`)的时间将产生错误结果。 +::: **语法** ```sql -addDate(date, interval) +timeSlot(time[, time_zone]) ``` **参数** -- `date` — 要加上 `interval` 的日期或带时间的日期。 [Date](../data-types/date.md)、[Date32](../data-types/date32.md)、[DateTime](../data-types/datetime.md)、[DateTime64](../data-types/datetime64.md) 或 [String](../data-types/string.md) -- `interval` — 要加的间隔。 [Interval](../data-types/special-data-types/interval.md)。 +- `time` — 要四舍五入到半小时长度间隔开始的时间。[`DateTime`](/sql-reference/data-types/datetime) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime64`](/sql-reference/data-types/datetime64) +- `time_zone` — 可选。一个字符串类型常量或表示时区的表达式。[`String`](/sql-reference/data-types/string) **返回值** -通过将 `interval` 加到 `date` 上获得的日期或带时间的日期。 [Date](../data-types/date.md)、[Date32](../data-types/date32.md)、[DateTime](../data-types/datetime.md) 或 [DateTime64](../data-types/datetime64.md)。 +返回四舍五入到半小时长度间隔开始的时间。[`DateTime`](/sql-reference/data-types/datetime) **示例** -```sql -SELECT addDate(toDate('2018-01-01'), INTERVAL 3 YEAR); -``` - -结果: +**将时间四舍五入到半小时间隔** -```text -┌─addDate(toDate('2018-01-01'), toIntervalYear(3))─┐ -│ 2021-01-01 │ -└──────────────────────────────────────────────────┘ +```sql title=Query +SELECT timeSlot(toDateTime('2000-01-02 03:04:05', 'UTC')) ``` -别名: `ADDDATE` - -**参见** +```response title=Response +┌─timeSlot(toDateTime('2000-01-02 03:04:05', 'UTC'))─┐ +│ 2000-01-02 03:00:00 │ +└────────────────────────────────────────────────────┘ +``` +## timeSlots {#timeSlots} -- [date_add](#date_add) +引入于:v1.1 -## subDate {#subdate} +对于从 `StartTime` 开始并持续 `Duration` 秒的时间间隔,返回一组时间点,该点由从此间隔中向下取整到 `Size` 秒生成。`Size` 是一个可选参数,默认为 1800(30 分钟)。 -从提供的日期、带时间的日期或字符串编码的日期/日期时间中减去时间间隔。 +这在例如搜索对应会话中的页面视图时是必要的。 -如果减法结果超出数据类型的范围,则结果未定义。 +对于 `DateTime64`,返回值的比例可能与 `StartTime` 的比例不同。会取所有给定参数中最高的比例。 **语法** ```sql -subDate(date, interval) +timeSlots(StartTime, Duration[, Size]) ``` **参数** -- `date` — 要从中减去 `interval` 的日期或带时间的日期。 [Date](../data-types/date.md)、[Date32](../data-types/date32.md)、[DateTime](../data-types/datetime.md)、[DateTime64](../data-types/datetime64.md) 或 [String](../data-types/string.md) -- `interval` — 要减去的间隔。 [Interval](../data-types/special-data-types/interval.md)。 +- `StartTime` — 时间间隔的开始时间。[`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) +- `Duration` — 以秒为单位的时间间隔的持续时间。[`UInt32`](/sql-reference/data-types/int-uint) 或 [`DateTime64`](/sql-reference/data-types/datetime64) +- `Size` — 可选。时间段大小,单位为秒。默认值为 1800(30 分钟)。[`UInt32`](/sql-reference/data-types/int-uint) 或 [`DateTime64`](/sql-reference/data-types/datetime64) **返回值** -通过将 `interval` 从 `date` 中减去获得的日期或带时间的日期。 [Date](../data-types/date.md)、[Date32](../data-types/date32.md)、[DateTime](../data-types/datetime.md) 或 [DateTime64](../data-types/datetime64.md)。 +返回一个 DateTime/DateTime64 数组(返回类型与 `StartTime` 的类型匹配)。对于 DateTime64,返回值的比例可能与 `StartTime` 的比例不同 - 取所有给定参数中最高的比例。[`Array(DateTime)`](/sql-reference/data-types/array) 或 [`Array(DateTime64)`](/sql-reference/data-types/array) **示例** -```sql -SELECT subDate(toDate('2018-01-01'), INTERVAL 3 YEAR); -``` +**生成时间段数组** -结果: - -```text -┌─subDate(toDate('2018-01-01'), toIntervalYear(3))─┐ -│ 2015-01-01 │ -└──────────────────────────────────────────────────┘ +```sql title=Query +SELECT timeSlots(toDateTime('2012-01-01 12:20:00'), toUInt32(600)); +SELECT timeSlots(toDateTime('1980-12-12 21:01:02', 'UTC'), toUInt32(600), 299); +SELECT timeSlots(toDateTime64('1980-12-12 21:01:02.1234', 4, 'UTC'), toDecimal64(600.1, 1), toDecimal64(299, 0)) ``` -别名: `SUBDATE` - -**参见** - -- [date_sub](#date_sub) - -## now {#now} +```response title=Response +┌─timeSlots(toDateTime('2012-01-01 12:20:00'), toUInt32(600))─┐ +│ ['2012-01-01 12:00:00','2012-01-01 12:30:00'] │ +└─────────────────────────────────────────────────────────────┘ +┌─timeSlots(toDateTime('1980-12-12 21:01:02', 'UTC'), toUInt32(600), 299)─┐ +│ ['1980-12-12 20:56:13','1980-12-12 21:01:12','1980-12-12 21:06:11'] │ +└─────────────────────────────────────────────────────────────────────────┘ +┌─timeSlots(toDateTime64('1980-12-12 21:01:02.1234', 4, 'UTC'), toDecimal64(600.1, 1), toDecimal64(299, 0))─┐ +│ ['1980-12-12 20:56:13.0000','1980-12-12 21:01:12.0000','1980-12-12 21:06:11.0000'] │ +└───────────────────────────────────────────────────────────────────────────────────────────────────────────┘ +``` +## timestamp {#timestamp} -返回查询解析时当前的日期和时间。此函数是一个常量表达式。 +引入于:v23.9 -别名: `current_timestamp`。 +将第一个参数 `expr` 转换为 [`DateTime64(6)`](/sql-reference/data-types/datetime64)。如果提供了第二个参数 `expr_time`,则将指定的时间添加到转换后的值中。 **语法** ```sql -now([timezone]) +timestamp(expr[, expr_time]) ``` **参数** -- `timezone` — 返回值的 [时区名称](../../operations/server-configuration-parameters/settings.md#timezone)(可选)。 [String](../data-types/string.md)。 +- `expr` — 日期或带有时间的日期。[`String`](/sql-reference/data-types/string) +- `expr_time` — 可选。要添加到转换值的时间。[`String`](/sql-reference/data-types/string) **返回值** -- 当前的日期和时间。 [DateTime](../data-types/datetime.md)。 +返回转换后的 `expr` 值,或添加时间后的 `expr` [`DateTime64(6)`](/sql-reference/data-types/datetime64) **示例** -不带时区的查询: +**将日期字符串转换为 DateTime64(6)** -```sql -SELECT now(); +```sql title=Query +SELECT timestamp('2023-12-31') AS ts; ``` -结果: - -```text -┌───────────────now()─┐ -│ 2020-10-17 07:42:09 │ -└─────────────────────┘ +```response title=Response +┌─────────────────────────ts─┐ +│ 2023-12-31 00:00:00.000000 │ +└────────────────────────────┘ ``` -带指定时区的查询: +**将时间添加到日期字符串** -```sql -SELECT now('Asia/Istanbul'); +```sql title=Query +SELECT timestamp('2023-12-31 12:00:00', '12:00:00.11') AS ts; ``` -结果: - -```text -┌─now('Asia/Istanbul')─┐ -│ 2020-10-17 10:42:23 │ -└──────────────────────┘ +```response title=Response +┌─────────────────────────ts─┐ +│ 2024-01-01 00:00:00.110000 │ +└────────────────────────────┘ ``` +## timezone {#timezone} -## now64 {#now64} +引入于:v21.4 -返回查询解析时当前的日期和时间,带有子秒精度。此函数是一个常量表达式。 +返回当前会话的时区名称或将时区偏移或名称转换为规范时区名称。 **语法** ```sql -now64([scale], [timezone]) +timezone() ``` **参数** -- `scale` - 时间戳精度: 10-precision 秒。有效范围:[ 0 : 9 ]。通常使用 - 3(默认)(毫秒)、6(微秒)、9(纳秒)。 -- `timezone` — 返回值的 [时区名称](../../operations/server-configuration-parameters/settings.md#timezone)(可选)。 [String](../data-types/string.md)。 +- 无。 **返回值** -- 当前日期和时间,带有子秒的精度。 [DateTime64](../data-types/datetime64.md)。 +返回规格化的时区名称,作为 [`String`](/sql-reference/data-types/string) **示例** -```sql -SELECT now64(), now64(9, 'Asia/Istanbul'); -``` - -结果: +**用法示例** -```text -┌─────────────────now64()─┬─────now64(9, 'Asia/Istanbul')─┐ -│ 2022-08-21 19:34:26.196 │ 2022-08-21 22:34:26.196542766 │ -└─────────────────────────┴───────────────────────────────┘ +```sql title=Query +SELECT timezone() ``` -## nowInBlock {#nowInBlock} +```response title=Response +┌─timezone()───────┐ +│ Europe/Amsterdam │ +└──────────────────┘ +``` +## timezoneOf {#timezoneOf} -返回在每个数据块处理时的当前日期和时间。与函数 [now](#now) 不同,它不是常量表达式,对于长时间运行的查询,不同的块返回的值可能不同。 +引入于:v21.4 -在长时间运行的 INSERT SELECT 查询中生成当前时间时使用此函数是有意义的。 +返回 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) 值的时区名称。 **语法** ```sql -nowInBlock([timezone]) +timeZoneOf(datetime) ``` **参数** -- `timezone` — 返回值的 [时区名称](../../operations/server-configuration-parameters/settings.md#timezone)(可选)。 [String](../data-types/string.md)。 +- `datetime` — 类型值。[`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) +- `timezone` — 可选。要转换 `datetime` 值时区的时区名称。[`String`](/sql-reference/data-types/string) **返回值** -- 在每个数据块处理时的当前日期和时间。 [DateTime](../data-types/datetime.md)。 +返回 `datetime` 的时区名称 [`String`](/sql-reference/data-types/string) **示例** -```sql -SELECT - now(), - nowInBlock(), - sleep(1) -FROM numbers(3) -SETTINGS max_block_size = 1 -FORMAT PrettyCompactMonoBlock -``` +**用法示例** -结果: +```sql title=Query +SELECT timezoneOf(now()); +``` -```text -┌───────────────now()─┬────────nowInBlock()─┬─sleep(1)─┐ -│ 2022-08-21 19:41:19 │ 2022-08-21 19:41:19 │ 0 │ -│ 2022-08-21 19:41:19 │ 2022-08-21 19:41:20 │ 0 │ -│ 2022-08-21 19:41:19 │ 2022-08-21 19:41:21 │ 0 │ -└─────────────────────┴─────────────────────┴──────────┘ +```response title=Response +┌─timezoneOf(now())─┐ +│ Europe/Amsterdam │ +└───────────────────┘ ``` +## timezoneOffset {#timezoneOffset} -## today {#today} +引入于:v21.6 -返回查询解析时的当前日期。它与 'toDate(now())' 相同,并具有别名: `curdate`, `current_date`。 +返回与 [UTC](https://en.wikipedia.org/wiki/Coordinated_Universal_Time) 的时区偏移(以秒为单位)。该函数考虑了在指定日期和时间的夏令时和历史时区变化。 **语法** ```sql -today() +timeZoneOffset(datetime) ``` **参数** -- 无 +- `datetime` — 要获取时区偏移的 `DateTime` 值。[`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) **返回值** -- 当前日期。 [DateTime](../data-types/datetime.md)。 +返回与 UTC 的偏移,单位为秒 [`Int32`](/sql-reference/data-types/int-uint) **示例** -查询: +**用法示例** -```sql -SELECT today() AS today, curdate() AS curdate, current_date() AS current_date FORMAT Pretty +```sql title=Query +SELECT toDateTime('2021-04-21 10:20:30', 'America/New_York') AS Time, +toTypeName(Time) AS Type, +timeZoneOffset(Time) AS Offset_in_seconds, +(Offset_in_seconds / 3600) AS Offset_in_hours; ``` -**结果**: - -在 2024 年 3 月 3 日运行上述查询将返回以下响应: - -```response -┏━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━┓ -┃ today ┃ curdate ┃ current_date ┃ -┡━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━┩ -│ 2024-03-03 │ 2024-03-03 │ 2024-03-03 │ -└────────────┴────────────┴──────────────┘ +```response title=Response +┌────────────────Time─┬─Type─────────────────────────┬─Offset_in_seconds─┬─Offset_in_hours─┐ +│ 2021-04-21 10:20:30 │ DateTime('America/New_York') │ -14400 │ -4 │ +└─────────────────────┴──────────────────────────────┴───────────────────┴─────────────────┘ ``` +## toDayOfMonth {#toDayOfMonth} -## yesterday {#yesterday} - -接受零个参数并返回查询解析时的昨天的日期。 -与 'today() - 1' 相同。 - -## timeSlot {#timeslot} +引入于:v1.1 -将时间四舍五入到半小时长度区间的开始。 +返回 `Date` 或 `DateTime` 的月份天数(1-31)。 **语法** ```sql -timeSlot(time[, time_zone]) +toDayOfMonth(datetime) ``` **参数** -- `time` — 要四舍五入到半小时长度区间开始的时间。 [DateTime](../data-types/datetime.md)/[Date32](../data-types/date32.md)/[DateTime64](../data-types/datetime64.md)。 -- `time_zone` — 表示时区的字符串类型常量值或表达式。 [String](../data-types/string.md)。 - -:::note -尽管此函数可以接受扩展类型 `Date32` 和 `DateTime64` 的值作为参数,但传递超出正常范围的时间(对于 `Date` 的年限为 1970 到 2149 / 对于 `DateTime` 为 2106)将会产生错误的结果。 -::: +- `datetime` — 要获取月份天数的日期或带有时间的日期。[`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) -**返回类型** +**返回值** -- 返回四舍五入到半小时长度区间开始的时间。 [DateTime](../data-types/datetime.md)。 +返回给定日期/时间的月份日期 [`UInt8`](/sql-reference/data-types/int-uint) **示例** -查询: +**用法示例** -```sql -SELECT timeSlot(toDateTime('2000-01-02 03:04:05', 'UTC')); +```sql title=Query +SELECT toDayOfMonth(toDateTime('2023-04-21 10:20:30')) ``` -结果: - -```response -┌─timeSlot(toDateTime('2000-01-02 03:04:05', 'UTC'))─┐ -│ 2000-01-02 03:00:00 │ -└────────────────────────────────────────────────────┘ +```response title=Response +┌─toDayOfMonth(toDateTime('2023-04-21 10:20:30'))─┐ +│ 21 │ +└─────────────────────────────────────────────────┘ ``` -## toYYYYMM {#toyyyymm} - -将日期或带时间的日期转换为一个包含年份和月份数字的 UInt32 数字(YYYY * 100 + MM)。接受第二个可选的时区参数。如果提供,那么时区必须是一个字符串常量。 - -此函数是 `YYYYMMDDToDate()` 函数的反向操作。 - -**示例** +## toDayOfWeek {#toDayOfWeek} -```sql -SELECT - toYYYYMM(now(), 'US/Eastern') -``` +引入于:v1.1 -结果: +返回 `Date` 或 `DateTime` 值在一周内的星期几号。 -```text -┌─toYYYYMM(now(), 'US/Eastern')─┐ -│ 202303 │ -└───────────────────────────────┘ -``` -## toYYYYMMDD {#toyyyymmdd} +`toDayOfWeek()` 的双参数形式使您可以指定一周是从星期一还是星期天开始,并且返回值的范围是 0 到 6 还是 1 到 7。 -将日期或带时间的日期转换为一个包含年份和月份数字的 UInt32 数字(YYYY * 10000 + MM * 100 + DD)。接受第二个可选的时区参数。如果提供,那么时区必须是一个字符串常量。 +| 模式 | 一周的第一天 | 范围 | +|------|---------------|-------------------------------------------| +| 0 | 星期一 | 1-7: 星期一 = 1, 星期二 = 2, ..., 星期天 = 7 | +| 1 | 星期一 | 0-6: 星期一 = 0, 星期二 = 1, ..., 星期天 = 6 | +| 2 | 星期天 | 0-6: 星期天 = 0, 星期一 = 1, ..., 星期六 = 6 | +| 3 | 星期天 | 1-7: 星期天 = 1, 星期一 = 2, ..., 星期六 = 7 | -**示例** +**语法** ```sql -SELECT toYYYYMMDD(now(), 'US/Eastern') +toDayOfWeek(datetime[, mode[, timezone]]) ``` -结果: +**参数** -```response -┌─toYYYYMMDD(now(), 'US/Eastern')─┐ -│ 20230302 │ -└─────────────────────────────────┘ -``` -## toYYYYMMDDhhmmss {#toyyyymmddhhmmss} +- `datetime` — 要获取星期几的日期或带有时间的日期。[`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) +- `mode` — 可选。指定周模式的整数(0-3)。默认值为 0。如果省略,默认为 0。[`UInt8`](/sql-reference/data-types/int-uint) +- `timezone` — 可选。用于转换的时区。[`String`](/sql-reference/data-types/string) -将带时间的日期转换为一个 UInt64 数字,包含年份和月份数字(YYYY * 10000000000 + MM * 100000000 + DD * 1000000 + hh * 10000 + mm * 100 + ss)。接受第二个可选的时区参数。如果提供,那么时区必须是一个字符串常量。 +**返回值** -**示例** +返回给定 `Date` 或 `DateTime` 的星期几 [`UInt8`](/sql-reference/data-types/int-uint) -```sql -SELECT toYYYYMMDDhhmmss(now(), 'US/Eastern') -``` +**示例** -结果: +**用法示例** -```response -┌─toYYYYMMDDhhmmss(now(), 'US/Eastern')─┐ -│ 20230302112209 │ -└───────────────────────────────────────┘ +```sql title=Query +-- The following date is April 21, 2023, which was a Friday: +SELECT + toDayOfWeek(toDateTime('2023-04-21')), + toDayOfWeek(toDateTime('2023-04-21'), 1) ``` -## YYYYMMDDToDate {#yyyymmddtodate} -将包含年份、月份和日期的数字转换为一个 [Date](../data-types/date.md)。 +```response title=Response +┌─toDayOfWeek(toDateTime('2023-04-21'))─┬─toDayOfWeek(toDateTime('2023-04-21'), 1)─┐ +│ 5 │ 4 │ +└───────────────────────────────────────┴──────────────────────────────────────────┘ +``` +## toDayOfYear {#toDayOfYear} -此函数是 `toYYYYMMDD()` 函数的反向操作。 +引入于:v18.4 -如果输入未编码有效的 Date 值,输出将是未定义的。 +返回 `Date` 或 `DateTime` 值在一年中的日期号(1-366)。 **语法** ```sql -YYYYMMDDToDate(yyyymmdd); +toDayOfYear(datetime) ``` **参数** -- `yyyymmdd` - 一个表示年份、月份和日期的数字。 [Integer](../data-types/int-uint.md)、[Float](../data-types/float.md) 或 [Decimal](../data-types/decimal.md)。 +- `datetime` — 要获取年份天数的日期或带有时间的日期。[`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) **返回值** -- 从参数创建的日期。 [Date](../data-types/date.md)。 +返回给定日期或 DateTime 的年份天数 [`UInt16`](/sql-reference/data-types/int-uint) **示例** -```sql -SELECT YYYYMMDDToDate(20230911); -``` - -结果: +**用法示例** -```response -┌─toYYYYMMDD(20230911)─┐ -│ 2023-09-11 │ -└──────────────────────┘ +```sql title=Query +SELECT toDayOfYear(toDateTime('2023-04-21 10:20:30')) ``` -## YYYYMMDDToDate32 {#yyyymmddtodate32} -与 `YYYYMMDDToDate()` 函数类似,但生成一个 [Date32](../data-types/date32.md)。 -## YYYYMMDDhhmmssToDateTime {#yyyymmddhhmmsstodatetime} +```response title=Response +┌─toDayOfYear(toDateTime('2023-04-21 10:20:30'))─┐ +│ 111 │ +└────────────────────────────────────────────────┘ +``` +## toDaysSinceYearZero {#toDaysSinceYearZero} -将数字中包含的年份、月份、日期、小时、分钟和秒转换为一个 [DateTime](../data-types/datetime.md)。 +引入于:v23.9 -如果输入未编码有效的 DateTime 值,输出将是未定义的。 +对于给定日期,返回自 [公元 0000 年 1 月 1 日](https://en.wikipedia.org/wiki/Year_zero) 以来的天数,使用 [ISO 8601 定义的历法](https://en.wikipedia.org/wiki/Gregorian_calendar#Proleptic_Gregorian_calendar) 计算。 -此函数是 `toYYYYMMDDhhmmss()` 函数的反向操作。 +计算方法与 MySQL 的 [`TO_DAYS`](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_to-days) 函数相同。 **语法** ```sql -YYYYMMDDhhmmssToDateTime(yyyymmddhhmmss[, timezone]); +toDaysSinceYearZero(date[, time_zone]) ``` **参数** -- `yyyymmddhhmmss` - 一个表示年份、月份和日期的数字。 [Integer](../data-types/int-uint.md)、[Float](../data-types/float.md) 或 [Decimal](../data-types/decimal.md)。 -- `timezone` - 返回值的 [Timezone](../../operations/server-configuration-parameters/settings.md#timezone)(可选)。 +- `date` — 要计算自公元零年起天数的日期或带有时间的日期。[`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) +- `time_zone` — 时区。[`String`](/sql-reference/data-types/string) **返回值** -- 从参数创建的带时间的日期。 [DateTime](../data-types/datetime.md)。 +返回自日期 `0000-01-01` 以来的天数。[`UInt32`](/sql-reference/data-types/int-uint) **示例** -```sql -SELECT YYYYMMDDToDateTime(20230911131415); -``` - -结果: +**计算自公元零年起的天数** -```response -┌──────YYYYMMDDhhmmssToDateTime(20230911131415)─┐ -│ 2023-09-11 13:14:15 │ -└───────────────────────────────────────────────┘ +```sql title=Query +SELECT toDaysSinceYearZero(toDate('2023-09-08')) ``` -## YYYYMMDDhhmmssToDateTime64 {#yyyymmddhhmmsstodatetime64} -与 `YYYYMMDDhhmmssToDate()` 函数类似,但生成一个 [DateTime64](../data-types/datetime64.md)。 +```response title=Response +┌─toDaysSinceYearZero(toDate('2023-09-08')))─┐ +│ 713569 │ +└────────────────────────────────────────────┘ +``` +## toHour {#toHour} -在 `timezone` 参数后接受一个额外的可选 `precision` 参数。 -## changeYear {#changeyear} +引入于:v1.1 -更改日期或带时间日期的年份组件。 +返回 `DateTime` 或 `DateTime64` 值的小时部分(0-23)。 **语法** -```sql -changeYear(date_or_datetime, value) +```sql +toHour(datetime) ``` **参数** -- `date_or_datetime` - 一个 [Date](../data-types/date.md)、[Date32](../data-types/date32.md)、[DateTime](../data-types/datetime.md) 或 [DateTime64](../data-types/datetime64.md) -- `value` - 新的年份值。 [Integer](../../sql-reference/data-types/int-uint.md)。 +- `datetime` — 要获取小时的带有时间的日期。[`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) **返回值** -- 与 `date_or_datetime` 相同的类型。 +返回 `datetime` 的小时(0-23)。[`UInt8`](/sql-reference/data-types/int-uint) **示例** -```sql -SELECT changeYear(toDate('1999-01-01'), 2000), changeYear(toDateTime64('1999-01-01 00:00:00.000', 3), 2000); -``` +**用法示例** -结果: +```sql title=Query +SELECT toHour(toDateTime('2023-04-21 10:20:30')) +``` -```sql -┌─changeYear(toDate('1999-01-01'), 2000)─┬─changeYear(toDateTime64('1999-01-01 00:00:00.000', 3), 2000)─┐ -│ 2000-01-01 │ 2000-01-01 00:00:00.000 │ -└────────────────────────────────────────┴──────────────────────────────────────────────────────────────┘ +```response title=Response +┌─toHour(toDateTime('2023-04-21 10:20:30'))─┐ +│ 10 │ +└───────────────────────────────────────────┘ ``` -## changeMonth {#changemonth} +## toISOYear {#toISOYear} + +引入于:v18.4 -更改日期或带时间日期的月份组件。 +将日期或带有时间的日期转换为 ISO 年号。 **语法** ```sql -changeMonth(date_or_datetime, value) +toISOYear(datetime) ``` **参数** -- `date_or_datetime` - 一个 [Date](../data-types/date.md)、[Date32](../data-types/date32.md)、[DateTime](../data-types/datetime.md) 或 [DateTime64](../data-types/datetime64.md) -- `value` - 新的月份值。 [Integer](../../sql-reference/data-types/int-uint.md)。 +- `datetime` — 带有日期或时间的值。[`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) **返回值** -- 返回与 `date_or_datetime` 相同类型的值。 +返回输入值转换为ISO年号。[`UInt16`](/sql-reference/data-types/int-uint) **示例** -```sql -SELECT changeMonth(toDate('1999-01-01'), 2), changeMonth(toDateTime64('1999-01-01 00:00:00.000', 3), 2); -``` +**从日期值获取ISO年** -结果: +```sql title=Query +SELECT +toISOYear(toDate('2024/10/02')) as year1, +toISOYear(toDateTime('2024-10-02 01:30:00')) as year2 +``` -```sql -┌─changeMonth(toDate('1999-01-01'), 2)─┬─changeMonth(toDateTime64('1999-01-01 00:00:00.000', 3), 2)─┐ -│ 1999-02-01 │ 1999-02-01 00:00:00.000 │ -└──────────────────────────────────────┴────────────────────────────────────────────────────────────┘ +```response title=Response +┌─week1─┬─week2─┐ +│ 40 │ 40 │ +└───────┴───────┘ ``` -## changeDay {#changeday} +## toLastDayOfMonth {#toLastDayOfMonth} + +引入于:v1.1 -更改日期或带时间日期的日期组件。 +将日期或带有时间的日期四舍五入到该月的最后一天。 + +:::note +返回类型可以通过设置 [`enable_extended_results_for_datetime_functions`](/operations/settings/settings#enable_extended_results_for_datetime_functions) 来配置。 +::: **语法** ```sql -changeDay(date_or_datetime, value) +toLastDayOfMonth(value) ``` **参数** -- `date_or_datetime` - 一个 [Date](../data-types/date.md)、[Date32](../data-types/date32.md)、[DateTime](../data-types/datetime.md) 或 [DateTime64](../data-types/datetime64.md) -- `value` - 新的日期值。 [Integer](../../sql-reference/data-types/int-uint.md)。 +- `value` — 要四舍五入到该月最后一天的日期或带有时间的日期。[`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) **返回值** -- 返回与 `date_or_datetime` 相同类型的值。 +返回给定日期或带有时间的日期的该月最后一天的日期。[`Date`](/sql-reference/data-types/date) **示例** -```sql -SELECT changeDay(toDate('1999-01-01'), 5), changeDay(toDateTime64('1999-01-01 00:00:00.000', 3), 5); -``` +**四舍五入到该月的最后一天** -结果: +```sql title=Query +SELECT toLastDayOfMonth(toDateTime('2023-04-21 10:20:30')) +``` -```sql -┌─changeDay(toDate('1999-01-01'), 5)─┬─changeDay(toDateTime64('1999-01-01 00:00:00.000', 3), 5)─┐ -│ 1999-01-05 │ 1999-01-05 00:00:00.000 │ -└────────────────────────────────────┴──────────────────────────────────────────────────────────┘ +```response title=Response +┌─toLastDayOfMonth(toDateTime('2023-04-21 10:20:30'))─┐ +│ 2023-04-30 │ +└─────────────────────────────────────────────────────┘ ``` -## changeHour {#changehour} +## toLastDayOfWeek {#toLastDayOfWeek} + +引入于:v23.5 -更改日期或带时间日期的小时组件。 +将日期或带有时间的日期四舍五入到最近的星期六或星期天。 + +:::note +返回类型可以通过设置 [`enable_extended_results_for_datetime_functions`](/operations/settings/settings#enable_extended_results_for_datetime_functions) 来配置。 +::: **语法** ```sql -changeHour(date_or_datetime, value) +toLastDayOfWeek(datetime[, mode[, timezone]]) ``` **参数** -- `date_or_datetime` - 一个 [Date](../data-types/date.md)、[Date32](../data-types/date32.md)、[DateTime](../data-types/datetime.md) 或 [DateTime64](../data-types/datetime64.md) -- `value` - 新的小时值。 [Integer](../../sql-reference/data-types/int-uint.md)。 +- `datetime` — 要转换的日期或带有时间的日期。[`Date`](/sql-reference/data-types/date) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime64`](/sql-reference/data-types/datetime64) +- `mode` — 确定一周的第一天,如 `toWeek()` 函数中所述。默认值为 `0`。[`UInt8`](/sql-reference/data-types/int-uint) +- `timezone` — 可选。用于转换的时区。如果未指定,则使用服务器的时区。[`String`](/sql-reference/data-types/string) **返回值** -- 返回与 `date_or_datetime` 相同类型的值。如果输入是 [Date](../data-types/date.md),返回 [DateTime](../data-types/datetime.md)。如果输入是 [Date32](../data-types/date32.md),返回 [DateTime64](../data-types/datetime64.md)。 +返回给定日期之后最近的星期六或星期天的日期,具体取决于模式 [`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) **示例** -```sql -SELECT changeHour(toDate('1999-01-01'), 14), changeHour(toDateTime64('1999-01-01 00:00:00.000', 3), 14); -``` +**四舍五入到最近的星期六或星期天** -结果: +```sql title=Query +SELECT + toLastDayOfWeek(toDateTime('2023-04-21 10:20:30')), /* a Friday */ + toLastDayOfWeek(toDateTime('2023-04-21 10:20:30'), 1), /* a Friday */ + toLastDayOfWeek(toDate('2023-04-23')), /* a Sunday */ + toLastDayOfWeek(toDate('2023-04-23'), 1) /* a Sunday */ +FORMAT Vertical +``` -```sql -┌─changeHour(toDate('1999-01-01'), 14)─┬─changeHour(toDateTime64('1999-01-01 00:00:00.000', 3), 14)─┐ -│ 1999-01-01 14:00:00 │ 1999-01-01 14:00:00.000 │ -└──────────────────────────────────────┴────────────────────────────────────────────────────────────┘ +```response title=Response +Row 1: +────── +toLastDayOfWeek(toDateTime('2023-04-21 10:20:30')): 2023-04-23 +toLastDayOfWeek(toDateTime('2023-04-21 10:20:30'), 1): 2023-04-22 +toLastDayOfWeek(toDate('2023-04-23')): 2023-04-23 +toLastDayOfWeek(toDate('2023-04-23'), 1): 2023-04-23 ``` -## changeMinute {#changeminute} +## toMillisecond {#toMillisecond} -更改日期或带时间日期的分钟组件。 +引入于:v24.2 + +返回 `DateTime` 或 `DateTime64` 值的毫秒部分(0-999)。 **语法** ```sql -changeMinute(date_or_datetime, value) +toMillisecond(datetime) ``` **参数** -- `date_or_datetime` - 一个 [Date](../data-types/date.md)、[Date32](../data-types/date32.md)、[DateTime](../data-types/datetime.md) 或 [DateTime64](../data-types/datetime64.md) -- `value` - 新的分钟值。 [Integer](../../sql-reference/data-types/int-uint.md)。 +- `datetime` — 要获取毫秒的带有时间的日期。[`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) **返回值** -- 返回与 `date_or_datetime` 相同类型的值。如果输入是 [Date](../data-types/date.md),返回 [DateTime](../data-types/datetime.md)。如果输入是 [Date32](../data-types/date32.md),返回 [DateTime64](../data-types/datetime64.md)。 +返回 `datetime` 中的毫秒(0 - 999)。[`UInt16`](/sql-reference/data-types/int-uint) **示例** -```sql -SELECT changeMinute(toDate('1999-01-01'), 15), changeMinute(toDateTime64('1999-01-01 00:00:00.000', 3), 15); -``` +**用法示例** -结果: +```sql title=Query +SELECT toMillisecond(toDateTime64('2023-04-21 10:20:30.456', 3)); +``` -```sql -┌─changeMinute(toDate('1999-01-01'), 15)─┬─changeMinute(toDateTime64('1999-01-01 00:00:00.000', 3), 15)─┐ -│ 1999-01-01 00:15:00 │ 1999-01-01 00:15:00.000 │ -└────────────────────────────────────────┴──────────────────────────────────────────────────────────────┘ +```response title=Response +┌──toMillisecond(toDateTime64('2023-04-21 10:20:30.456', 3))─┐ +│ 456 │ +└────────────────────────────────────────────────────────────┘ ``` -## changeSecond {#changesecond} +## toMinute {#toMinute} + +引入于:v1.1 -更改日期或带时间日期的秒组件。 +返回 `Date` 或 `DateTime` 值的分钟部分(0-59)。 **语法** ```sql -changeSecond(date_or_datetime, value) +toMinute(datetime) ``` **参数** -- `date_or_datetime` - 一个 [Date](../data-types/date.md)、[Date32](../data-types/date32.md)、[DateTime](../data-types/datetime.md) 或 [DateTime64](../data-types/datetime64.md) -- `value` - 新的秒值。 [Integer](../../sql-reference/data-types/int-uint.md)。 +- `datetime` — 要获取分钟的带有时间的日期。[`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) **返回值** -- 返回与 `date_or_datetime` 相同类型的值。如果输入是 [Date](../data-types/date.md),返回 [DateTime](../data-types/datetime.md)。如果输入是 [Date32](../data-types/date32.md),返回 [DateTime64](../data-types/datetime64.md)。 +返回 `datetime` 的分钟数(0 - 59)。[`UInt8`](/sql-reference/data-types/int-uint) **示例** -```sql -SELECT changeSecond(toDate('1999-01-01'), 15), changeSecond(toDateTime64('1999-01-01 00:00:00.000', 3), 15); -``` +**用法示例** -结果: +```sql title=Query +SELECT toMinute(toDateTime('2023-04-21 10:20:30')) +``` -```sql -┌─changeSecond(toDate('1999-01-01'), 15)─┬─changeSecond(toDateTime64('1999-01-01 00:00:00.000', 3), 15)─┐ -│ 1999-01-01 00:00:15 │ 1999-01-01 00:00:15.000 │ -└────────────────────────────────────────┴──────────────────────────────────────────────────────────────┘ +```response title=Response +┌─toMinute(toDateTime('2023-04-21 10:20:30'))─┐ +│ 20 │ +└─────────────────────────────────────────────┘ ``` -## addYears {#addyears} +## toModifiedJulianDay {#toModifiedJulianDay} + +引入于:v21.1 -向日期、带时间的日期或字符串编码的日期/带时间的日期添加指定数量的年份。 +将 [Proleptic Gregorian calendar](https://en.wikipedia.org/wiki/Proleptic_Gregorian_calendar) 形式的日期 `YYYY-MM-DD` 转换为 [Modified Julian Day](https://en.wikipedia.org/wiki/Julian_day#Variants) 编号(`Int32`)。此函数支持的日期范围从 `0000-01-01` 到 `9999-12-31`。如果参数无法解析为日期或日期无效,则会引发异常。 **语法** ```sql -addYears(date, num) +toModifiedJulianDay(date) ``` **参数** -- `date`: 要增加指定年份的日期/带时间的日期。 [Date](../data-types/date.md)/[Date32](../data-types/date32.md)/[DateTime](../data-types/datetime.md)/[DateTime64](../data-types/datetime64.md)、[String](../data-types/string.md)。 -- `num`: 要添加的年份数量。 [(U)Int*](../data-types/int-uint.md)、[Float*](../data-types/float.md)。 +- `date` — 字符串形式的日期。[`String`](/sql-reference/data-types/string) 或 [`FixedString`](/sql-reference/data-types/fixedstring) **返回值** -- 返回 `date` 加上 `num` 年。 [Date](../data-types/date.md)/[Date32](../data-types/date32.md)/[DateTime](../data-types/datetime.md)/[DateTime64](../data-types/datetime64.md)。 +返回修改后的朱利安日编号。[`Int32`](/sql-reference/data-types/int-uint) **示例** -```sql -WITH - toDate('2024-01-01') AS date, - toDateTime('2024-01-01 00:00:00') AS date_time, - '2024-01-01 00:00:00' AS date_time_string -SELECT - addYears(date, 1) AS add_years_with_date, - addYears(date_time, 1) AS add_years_with_date_time, - addYears(date_time_string, 1) AS add_years_with_date_time_string +**将日期转换为修改后的朱利安日** + +```sql title=Query +SELECT toModifiedJulianDay('2020-01-01') ``` -```response -┌─add_years_with_date─┬─add_years_with_date_time─┬─add_years_with_date_time_string─┐ -│ 2025-01-01 │ 2025-01-01 00:00:00 │ 2025-01-01 00:00:00.000 │ -└─────────────────────┴──────────────────────────┴─────────────────────────────────┘ +```response title=Response +┌─toModifiedJulianDay('2020-01-01')─┐ +│ 58849 │ +└───────────────────────────────────┘ ``` -## addQuarters {#addquarters} +## toModifiedJulianDayOrNull {#toModifiedJulianDayOrNull} + +引入于:v21.1 -向日期、带时间的日期或字符串编码的日期/带时间的日期添加指定数量的季度。 +类似于 [`toModifiedJulianDay()`](#toModifiedJulianDay),但不再引发异常,而是返回 `NULL`。 **语法** ```sql -addQuarters(date, num) +toModifiedJulianDayOrNull(date) ``` **参数** -- `date`: 要增加指定季度的日期/带时间的日期。 [Date](../data-types/date.md)/[Date32](../data-types/date32.md)/[DateTime](../data-types/datetime.md)/[DateTime64](../data-types/datetime64.md)、[String](../data-types/string.md)。 -- `num`: 要添加的季度数量。 [(U)Int*](../data-types/int-uint.md)、[Float*](../data-types/float.md)。 +- `date` — 字符串形式的日期。[`String`](/sql-reference/data-types/string) 或 [`FixedString`](/sql-reference/data-types/fixedstring) **返回值** -- 返回 `date` 加上 `num` 季度。 [Date](../data-types/date.md)/[Date32](../data-types/date32.md)/[DateTime](../data-types/datetime.md)/[DateTime64](../data-types/datetime64.md)。 +对于有效的 `date` ,返回修改后的朱利安日编号,否则返回 `null`。[`Nullable(Int32)`](/sql-reference/data-types/nullable) **示例** -```sql -WITH - toDate('2024-01-01') AS date, - toDateTime('2024-01-01 00:00:00') AS date_time, - '2024-01-01 00:00:00' AS date_time_string -SELECT - addQuarters(date, 1) AS add_quarters_with_date, - addQuarters(date_time, 1) AS add_quarters_with_date_time, - addQuarters(date_time_string, 1) AS add_quarters_with_date_time_string +**将日期转换为修改后的朱利安日,并处理 null** + +```sql title=Query +SELECT toModifiedJulianDayOrNull('2020-01-01'); +SELECT toModifiedJulianDayOrNull('0000-00-00'); -- invalid date, returns NULL ``` -```response -┌─add_quarters_with_date─┬─add_quarters_with_date_time─┬─add_quarters_with_date_time_string─┐ -│ 2024-04-01 │ 2024-04-01 00:00:00 │ 2024-04-01 00:00:00.000 │ -└────────────────────────┴─────────────────────────────┴────────────────────────────────────┘ +```response title=Response +┌─toModifiedJu⋯020-01-01')─┐ +│ 58849 │ +└──────────────────────────┘ +┌─toModifiedJu⋯000-00-00')─┐ +│ ᴺᵁᴸᴸ │ +└──────────────────────────┘ ``` -## addMonths {#addmonths} +## toMonday {#toMonday} + +引入于:v1.1 -向日期、带时间的日期或字符串编码的日期/带时间的日期添加指定数量的月份。 +将日期或带有时间的日期向下取整到同一周的星期一。返回该日期。 + +:::note +返回类型可以通过设置 [`enable_extended_results_for_datetime_functions`](/operations/settings/settings#enable_extended_results_for_datetime_functions) 来配置。 +::: **语法** ```sql -addMonths(date, num) +toMonday(value) ``` **参数** -- `date`: 要增加指定月份的日期/带时间的日期。 [Date](../data-types/date.md)/[Date32](../data-types/date32.md)/[DateTime](../data-types/datetime.md)/[DateTime64](../data-types/datetime64.md)、[String](../data-types/string.md)。 -- `num`: 要添加的月份数量。 [(U)Int*](../data-types/int-uint.md)、[Float*](../data-types/float.md)。 +- `value` — 要向下取整到本周星期一的日期或带有时间的日期。[`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) **返回值** -- 返回 `date` 加上 `num` 月份。 [Date](../data-types/date.md)/[Date32](../data-types/date32.md)/[DateTime](../data-types/datetime.md)/[DateTime64](../data-types/datetime64.md)。 +返回给定日期或带有时间的日期的同一周的星期一的日期。[`Date`](/sql-reference/data-types/date) **示例** -```sql -WITH - toDate('2024-01-01') AS date, - toDateTime('2024-01-01 00:00:00') AS date_time, - '2024-01-01 00:00:00' AS date_time_string +**向下取整到本周的星期一** + +```sql title=Query SELECT - addMonths(date, 6) AS add_months_with_date, - addMonths(date_time, 6) AS add_months_with_date_time, - addMonths(date_time_string, 6) AS add_months_with_date_time_string +toMonday(toDateTime('2023-04-21 10:20:30')), -- A Friday +toMonday(toDate('2023-04-24')); -- Already a Monday ``` -```response -┌─add_months_with_date─┬─add_months_with_date_time─┬─add_months_with_date_time_string─┐ -│ 2024-07-01 │ 2024-07-01 00:00:00 │ 2024-07-01 00:00:00.000 │ -└──────────────────────┴───────────────────────────┴──────────────────────────────────┘ +```response title=Response +┌─toMonday(toDateTime('2023-04-21 10:20:30'))─┬─toMonday(toDate('2023-04-24'))─┐ +│ 2023-04-17 │ 2023-04-24 │ +└─────────────────────────────────────────────┴────────────────────────────────┘ ``` -## addWeeks {#addweeks} +## toMonth {#toMonth} + +引入于:v1.1 -向日期、带时间的日期或字符串编码的日期/带时间的日期添加指定数量的周。 +返回 `Date` 或 `DateTime` 值的月份部分(1-12)。 **语法** ```sql -addWeeks(date, num) +toMonth(datetime) ``` **参数** -- `date`: 要增加指定周数的日期/带时间的日期。 [Date](../data-types/date.md)/[Date32](../data-types/date32.md)/[DateTime](../data-types/datetime.md)/[DateTime64](../data-types/datetime64.md)、[String](../data-types/string.md)。 -- `num`: 要添加的周数。 [(U)Int*](../data-types/int-uint.md)、[Float*](../data-types/float.md)。 +- `datetime` — 要获取月份的带有时间的日期。[`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) **返回值** -- 返回 `date` 加上 `num` 周。 [Date](../data-types/date.md)/[Date32](../data-types/date32.md)/[DateTime](../data-types/datetime.md)/[DateTime64](../data-types/datetime64.md)。 +返回给定日期/时间的月份 [`UInt8`](/sql-reference/data-types/int-uint) **示例** -```sql -WITH - toDate('2024-01-01') AS date, - toDateTime('2024-01-01 00:00:00') AS date_time, - '2024-01-01 00:00:00' AS date_time_string -SELECT - addWeeks(date, 5) AS add_weeks_with_date, - addWeeks(date_time, 5) AS add_weeks_with_date_time, - addWeeks(date_time_string, 5) AS add_weeks_with_date_time_string +**用法示例** + +```sql title=Query +SELECT toMonth(toDateTime('2023-04-21 10:20:30')) ``` -```response -┌─add_weeks_with_date─┬─add_weeks_with_date_time─┬─add_weeks_with_date_time_string─┐ -│ 2024-02-05 │ 2024-02-05 00:00:00 │ 2024-02-05 00:00:00.000 │ -└─────────────────────┴──────────────────────────┴─────────────────────────────────┘ +```response title=Response +┌─toMonth(toDateTime('2023-04-21 10:20:30'))─┐ +│ 4 │ +└────────────────────────────────────────────┘ ``` -## addDays {#adddays} +## toMonthNumSinceEpoch {#toMonthNumSinceEpoch} + +引入于:v25.3 -向日期、带时间的日期或字符串编码的日期/带时间的日期添加指定数量的天。 +返回自 1970 年以来经历的月份数。 **语法** ```sql -addDays(date, num) +toMonthNumSinceEpoch(date) ``` **参数** -- `date`: 要增加指定天数的日期/带时间的日期。 [Date](../data-types/date.md)/[Date32](../data-types/date32.md)/[DateTime](../data-types/datetime.md)/[DateTime64](../data-types/datetime64.md)、[String](../data-types/string.md)。 -- `num`: 要添加的天数。 [(U)Int*](../data-types/int-uint.md)、[Float*](../data-types/float.md)。 +- `date` — 日期或带有时间的日期。[`Date`](/sql-reference/data-types/date) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) **返回值** -- 返回 `date` 加上 `num` 天。 [Date](../data-types/date.md)/[Date32](../data-types/date32.md)/[DateTime](../data-types/datetime.md)/[DateTime64](../data-types/datetime64.md)。 +正整数 **示例** -```sql -WITH - toDate('2024-01-01') AS date, - toDateTime('2024-01-01 00:00:00') AS date_time, - '2024-01-01 00:00:00' AS date_time_string -SELECT - addDays(date, 5) AS add_days_with_date, - addDays(date_time, 5) AS add_days_with_date_time, - addDays(date_time_string, 5) AS add_days_with_date_time_string +**示例** + +```sql title=Query +SELECT toMonthNumSinceEpoch(toDate('2024-10-01')) ``` -```response -┌─add_days_with_date─┬─add_days_with_date_time─┬─add_days_with_date_time_string─┐ -│ 2024-01-06 │ 2024-01-06 00:00:00 │ 2024-01-06 00:00:00.000 │ -└────────────────────┴─────────────────────────┴────────────────────────────────┘ +```response title=Response +657 ``` -## addHours {#addhours} +## toQuarter {#toQuarter} -向日期、带时间的日期或字符串编码的日期/带时间的日期添加指定数量的小时。 +引入于:v1.1 + +返回给定 `Date` 或 `DateTime` 值的季度(1-4)。 **语法** ```sql -addHours(date, num) +toQuarter(datetime) ``` **参数** -- `date`: 要增加指定小时数的日期/带时间的日期。 [Date](../data-types/date.md)/[Date32](../data-types/date32.md)/[DateTime](../data-types/datetime.md)/[DateTime64](../data-types/datetime64.md)、[String](../data-types/string.md)。 -- `num`: 要添加的小时数。 [(U)Int*](../data-types/int-uint.md)、[Float*](../data-types/float.md)。 +- `datetime` — 要获取季度的带有时间的日期。[`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) **返回值** -o -- 返回 `date` 加上 `num` 小时。 [Date](../data-types/date.md)/[Date32](../data-types/date32.md)/[DateTime](../data-types/datetime.md)/[DateTime64](../data-types/datetime64.md)。 + +返回给定日期/时间的季度 [`UInt8`](/sql-reference/data-types/int-uint) **示例** -```sql -WITH - toDate('2024-01-01') AS date, - toDateTime('2024-01-01 00:00:00') AS date_time, - '2024-01-01 00:00:00' AS date_time_string -SELECT - addHours(date, 12) AS add_hours_with_date, - addHours(date_time, 12) AS add_hours_with_date_time, - addHours(date_time_string, 12) AS add_hours_with_date_time_string +**用法示例** + +```sql title=Query +SELECT toQuarter(toDateTime('2023-04-21 10:20:30')) ``` -```response -┌─add_hours_with_date─┬─add_hours_with_date_time─┬─add_hours_with_date_time_string─┐ -│ 2024-01-01 12:00:00 │ 2024-01-01 12:00:00 │ 2024-01-01 12:00:00.000 │ -└─────────────────────┴──────────────────────────┴─────────────────────────────────┘ +```response title=Response +┌─toQuarter(toDateTime('2023-04-21 10:20:30'))─┐ +│ 2 │ +└──────────────────────────────────────────────┘ ``` -## addMinutes {#addminutes} -向日期、带时间的日期或字符串编码的日期/带时间的日期添加指定数量的分钟。 +## toRelativeDayNum {#toRelativeDayNum} + +引入于:v1.1 + + +将日期或带时间的日期转换为自过去某个固定点以来经过的天数。 +确切的时间点是实现细节,因此此函数不打算单独使用。 +该函数的主要目的在于计算两个日期或带时间的日期之间的天数差,例如 `toRelativeDayNum(dt1) - toRelativeDayNum(dt2)`。 + **语法** ```sql -addMinutes(date, num) +toRelativeDayNum(date) ``` **参数** -- `date`: 要增加指定分钟数的日期/带时间的日期。 [Date](../data-types/date.md)/[Date32](../data-types/date32.md)/[DateTime](../data-types/datetime.md)/[DateTime64](../data-types/datetime64.md)、[String](../data-types/string.md)。 -- `num`: 要添加的分钟数。 [(U)Int*](../data-types/int-uint.md)、[Float*](../data-types/float.md)。 +- `date` — 日期或带时间的日期。 [`Date`](/sql-reference/data-types/date) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) + **返回值** -- 返回 `date` 加上 `num` 分钟。 [Date](../data-types/date.md)/[Date32](../data-types/date32.md)/[DateTime](../data-types/datetime.md)/[DateTime64](../data-types/datetime64.md)。 +返回自过去某个固定参考点以来的天数。 [`UInt32`](/sql-reference/data-types/int-uint) **示例** -```sql -WITH - toDate('2024-01-01') AS date, - toDateTime('2024-01-01 00:00:00') AS date_time, - '2024-01-01 00:00:00' AS date_time_string -SELECT - addMinutes(date, 20) AS add_minutes_with_date, - addMinutes(date_time, 20) AS add_minutes_with_date_time, - addMinutes(date_time_string, 20) AS add_minutes_with_date_time_string +**获取相对日期数** + +```sql title=Query +SELECT toRelativeDayNum(toDate('2023-04-01')) - toRelativeDayNum(toDate('2023-01-01')) ``` -```response -┌─add_minutes_with_date─┬─add_minutes_with_date_time─┬─add_minutes_with_date_time_string─┐ -│ 2024-01-01 00:20:00 │ 2024-01-01 00:20:00 │ 2024-01-01 00:20:00.000 │ -└───────────────────────┴────────────────────────────┴───────────────────────────────────┘ +```response title=Response +┌─minus(toRela⋯3-01-01')))─┐ +│ 90 │ +└──────────────────────────┘ ``` -## addSeconds {#addseconds} +## toRelativeHourNum {#toRelativeHourNum} -向日期、带时间的日期或字符串编码的日期/带时间的日期添加指定数量的秒。 +引入于:v1.1 + + +将日期或带时间的日期转换为自过去某个固定点以来经过的小时数。 +确切的时间点是实现细节,因此此函数不打算单独使用。 +该函数的主要目的在于计算两个日期或带时间的日期之间的小时差,例如 `toRelativeHourNum(dt1) - toRelativeHourNum(dt2)`。 + **语法** ```sql -addSeconds(date, num) +toRelativeHourNum(date) ``` **参数** -- `date`: 要增加指定秒数的日期/带时间的日期。 [Date](../data-types/date.md)/[Date32](../data-types/date32.md)/[DateTime](../data-types/datetime.md)/[DateTime64](../data-types/datetime64.md)、[String](../data-types/string.md)。 -- `num`: 要添加的秒数。 [(U)Int*](../data-types/int-uint.md)、[Float*](../data-types/float.md)。 +- `date` — 日期或带时间的日期。 [`Date`](/sql-reference/data-types/date) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) + **返回值** -- 返回 `date` 加上 `num` 秒。 [Date](../data-types/date.md)/[Date32](../data-types/date32.md)/[DateTime](../data-types/datetime.md)/[DateTime64](../data-types/datetime64.md)。 +返回自过去某个固定参考点以来的小时数。 [`UInt32`](/sql-reference/data-types/int-uint) **示例** -```sql -WITH - toDate('2024-01-01') AS date, - toDateTime('2024-01-01 00:00:00') AS date_time, - '2024-01-01 00:00:00' AS date_time_string -SELECT - addSeconds(date, 30) AS add_seconds_with_date, - addSeconds(date_time, 30) AS add_seconds_with_date_time, - addSeconds(date_time_string, 30) AS add_seconds_with_date_time_string +**获取相对小时数** + +```sql title=Query +SELECT toRelativeHourNum(toDateTime('2023-01-01 12:00:00')) - toRelativeHourNum(toDateTime('2023-01-01 00:00:00')) AS hours_difference ``` -```response -┌─add_seconds_with_date─┬─add_seconds_with_date_time─┬─add_seconds_with_date_time_string─┐ -│ 2024-01-01 00:00:30 │ 2024-01-01 00:00:30 │ 2024-01-01 00:00:30.000 │ -└───────────────────────┴────────────────────────────┴───────────────────────────────────┘ +```response title=Response +┌─hours_difference─┐ +│ 12 │ +└──────────────────┘ ``` -## addMilliseconds {#addmilliseconds} +## toRelativeMinuteNum {#toRelativeMinuteNum} + +引入于:v1.1 + -向带时间的日期或字符串编码的带时间的日期添加指定数量的毫秒。 +将日期或带时间的日期转换为自过去某个固定点以来经过的分钟数。 +确切的时间点是实现细节,因此此函数不打算单独使用。 +该函数的主要目的在于计算两个日期或带时间的日期之间的分钟差,例如 `toRelativeMinuteNum(dt1) - toRelativeMinuteNum(dt2)`。 + **语法** ```sql -addMilliseconds(date_time, num) +toRelativeMinuteNum(date) ``` **参数** -- `date_time`: 带时间的日期,增加指定数量的毫秒。 [DateTime](../data-types/datetime.md)/[DateTime64](../data-types/datetime64.md)、[String](../data-types/string.md)。 -- `num`: 要添加的毫秒数。 [(U)Int*](../data-types/int-uint.md)、[Float*](../data-types/float.md)。 +- `date` — 日期或带时间的日期。 [`Date`](/sql-reference/data-types/date) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) + **返回值** -- 返回 `date_time` 加上 `num` 毫秒。 [DateTime64](../data-types/datetime64.md)。 +返回自过去某个固定参考点以来的分钟数。 [`UInt32`](/sql-reference/data-types/int-uint) **示例** -```sql -WITH - toDateTime('2024-01-01 00:00:00') AS date_time, - '2024-01-01 00:00:00' AS date_time_string -SELECT - addMilliseconds(date_time, 1000) AS add_milliseconds_with_date_time, - addMilliseconds(date_time_string, 1000) AS add_milliseconds_with_date_time_string +**获取相对分钟数** + +```sql title=Query +SELECT toRelativeMinuteNum(toDateTime('2023-01-01 00:30:00')) - toRelativeMinuteNum(toDateTime('2023-01-01 00:00:00')) AS minutes_difference ``` -```response -┌─add_milliseconds_with_date_time─┬─add_milliseconds_with_date_time_string─┐ -│ 2024-01-01 00:00:01.000 │ 2024-01-01 00:00:01.000 │ -└─────────────────────────────────┴────────────────────────────────────────┘ +```response title=Response +┌─minutes_difference─┐ +│ 30 │ +└────────────────────┘ ``` -## addMicroseconds {#addmicroseconds} +## toRelativeMonthNum {#toRelativeMonthNum} + +引入于:v1.1 -向带时间的日期或字符串编码的带时间的日期添加指定数量的微秒。 + +将日期或带时间的日期转换为自过去某个固定点以来经过的月份数。 +确切的时间点是实现细节,因此此函数不打算单独使用。 +该函数的主要目的在于计算两个日期或带时间的日期之间的月份差,例如 `toRelativeMonthNum(dt1) - toRelativeMonthNum(dt2)`。 + **语法** ```sql -addMicroseconds(date_time, num) +toRelativeMonthNum(date) ``` **参数** -- `date_time`: 带时间的日期,增加指定数量的微秒。 [DateTime](../data-types/datetime.md)/[DateTime64](../data-types/datetime64.md)、[String](../data-types/string.md)。 -- `num`: 要添加的微秒数。 [(U)Int*](../data-types/int-uint.md)、[Float*](../data-types/float.md)。 +- `date` — 日期或带时间的日期。 [`Date`](/sql-reference/data-types/date) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) + **返回值** -- 返回 `date_time` 加上 `num` 微秒。 [DateTime64](../data-types/datetime64.md)。 +返回自过去某个固定参考点以来的月份数。 [`UInt32`](/sql-reference/data-types/int-uint) **示例** -```sql -WITH - toDateTime('2024-01-01 00:00:00') AS date_time, - '2024-01-01 00:00:00' AS date_time_string -SELECT - addMicroseconds(date_time, 1000000) AS add_microseconds_with_date_time, - addMicroseconds(date_time_string, 1000000) AS add_microseconds_with_date_time_string +**获取相对月份数** + +```sql title=Query +SELECT toRelativeMonthNum(toDate('2023-04-01')) - toRelativeMonthNum(toDate('2023-01-01')) AS months_difference ``` -```response -┌─add_microseconds_with_date_time─┬─add_microseconds_with_date_time_string─┐ -│ 2024-01-01 00:00:01.000000 │ 2024-01-01 00:00:01.000000 │ -└─────────────────────────────────┴────────────────────────────────────────┘ +```response title=Response +┌─months_difference─┐ +│ 3 │ +└───────────────────┘ ``` -## addNanoseconds {#addnanoseconds} +## toRelativeQuarterNum {#toRelativeQuarterNum} + +引入于:v1.1 -向带时间的日期或字符串编码的带时间的日期添加指定数量的纳秒。 + +将日期或带时间的日期转换为自过去某个固定点以来经过的季度数。 +确切的时间点是实现细节,因此此函数不打算单独使用。 +该函数的主要目的在于计算两个日期或带时间的日期之间的季度差,例如 `toRelativeQuarterNum(dt1) - toRelativeQuarterNum(dt2)`。 + **语法** ```sql -addNanoseconds(date_time, num) +toRelativeQuarterNum(date) ``` **参数** -- `date_time`: 带时间的日期,增加指定数量的纳秒。 [DateTime](../data-types/datetime.md)/[DateTime64](../data-types/datetime64.md)、[String](../data-types/string.md)。 -- `num`: 要添加的纳秒数。 [(U)Int*](../data-types/int-uint.md)、[Float*](../data-types/float.md)。 +- `date` — 日期或带时间的日期。 [`Date`](/sql-reference/data-types/date) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) + **返回值** -- 返回 `date_time` 加上 `num` 纳秒。 [DateTime64](../data-types/datetime64.md)。 +返回自过去某个固定参考点以来的季度数。 [`UInt32`](/sql-reference/data-types/int-uint) **示例** -```sql -WITH - toDateTime('2024-01-01 00:00:00') AS date_time, - '2024-01-01 00:00:00' AS date_time_string -SELECT - addNanoseconds(date_time, 1000) AS add_nanoseconds_with_date_time, - addNanoseconds(date_time_string, 1000) AS add_nanoseconds_with_date_time_string +**获取相对季度数** + +```sql title=Query +SELECT toRelativeQuarterNum(toDate('2023-04-01')) - toRelativeQuarterNum(toDate('2023-01-01')) AS quarters_difference ``` -```response -┌─add_nanoseconds_with_date_time─┬─add_nanoseconds_with_date_time_string─┐ -│ 2024-01-01 00:00:00.000001000 │ 2024-01-01 00:00:00.000001000 │ -└────────────────────────────────┴───────────────────────────────────────┘ +```response title=Response +┌─quarters_difference─┐ +│ 1 │ +└─────────────────────┘ ``` -## addInterval {#addinterval} +## toRelativeSecondNum {#toRelativeSecondNum} + +引入于:v1.1 -将一个区间添加到另一个区间或区间的元组中。 + +将日期或带时间的日期转换为自过去某个固定点以来经过的秒数。 +确切的时间点是实现细节,因此此函数不打算单独使用。 +该函数的主要目的在于计算两个日期或带时间的日期之间的秒数差,例如 `toRelativeSecondNum(dt1) - toRelativeSecondNum(dt2)`。 + **语法** ```sql -addInterval(interval_1, interval_2) +toRelativeSecondNum(date) ``` **参数** -- `interval_1`: 第一个区间或区间的元组。 [interval](../data-types/special-data-types/interval.md)、[tuple](../data-types/tuple.md)([interval](../data-types/special-data-types/interval.md))。 -- `interval_2`: 要添加的第二个区间。 [interval](../data-types/special-data-types/interval.md)。 +- `date` — 日期或带时间的日期。 [`Date`](/sql-reference/data-types/date) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) -**返回值** -- 返回一个区间的元组。 [tuple](../data-types/tuple.md)([interval](../data-types/special-data-types/interval.md))。 +**返回值** -:::note -同类型的区间将被组合成单个区间。例如,如果传递了 `toIntervalDay(1)` 和 `toIntervalDay(2)`,则结果将是 `(3)` 而不是 `(1,1)`。 -::: +返回自过去某个固定参考点以来的秒数。 [`UInt32`](/sql-reference/data-types/int-uint) **示例** -查询: +**获取相对秒数** -```sql -SELECT addInterval(INTERVAL 1 DAY, INTERVAL 1 MONTH); -SELECT addInterval((INTERVAL 1 DAY, INTERVAL 1 YEAR), INTERVAL 1 MONTH); -SELECT addInterval(INTERVAL 2 DAY, INTERVAL 1 DAY); +```sql title=Query +SELECT toRelativeSecondNum(toDateTime('2023-01-01 00:01:00')) - toRelativeSecondNum(toDateTime('2023-01-01 00:00:00')) AS seconds_difference ``` -结果: - -```response -┌─addInterval(toIntervalDay(1), toIntervalMonth(1))─┐ -│ (1,1) │ -└───────────────────────────────────────────────────┘ -┌─addInterval((toIntervalDay(1), toIntervalYear(1)), toIntervalMonth(1))─┐ -│ (1,1,1) │ -└────────────────────────────────────────────────────────────────────────┘ -┌─addInterval(toIntervalDay(2), toIntervalDay(1))─┐ -│ (3) │ -└─────────────────────────────────────────────────┘ +```response title=Response +┌─seconds_difference─┐ +│ 60 │ +└────────────────────┘ ``` -## addTupleOfIntervals {#addtupleofintervals} +## toRelativeWeekNum {#toRelativeWeekNum} + +引入于:v1.1 + -将一个区间的元组连续地添加到 Date 或 DateTime。 +将日期或带时间的日期转换为自过去某个固定点以来经过的周数。 +确切的时间点是实现细节,因此此函数不打算单独使用。 +该函数的主要目的在于计算两个日期或带时间的日期之间的周数差,例如 `toRelativeWeekNum(dt1) - toRelativeWeekNum(dt2)`。 + **语法** ```sql -addTupleOfIntervals(interval_1, interval_2) +toRelativeWeekNum(date) ``` **参数** -- `date`: 第一个区间或区间的元组。 [date](../data-types/date.md)/[date32](../data-types/date32.md)/[datetime](../data-types/datetime.md)/[datetime64](../data-types/datetime64.md)。 -- `intervals`: 要添加到 `date` 的区间元组。 [tuple](../data-types/tuple.md)([interval](../data-types/special-data-types/interval.md))。 +- `date` — 日期或带时间的日期。 [`Date`](/sql-reference/data-types/date) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) + **返回值** -- 返回加上 `intervals` 的 `date`。 [date](../data-types/date.md)/[date32](../data-types/date32.md)/[datetime](../data-types/datetime.md)/[datetime64](../data-types/datetime64.md)。 +返回自过去某个固定参考点以来的周数。 [`UInt32`](/sql-reference/data-types/int-uint) **示例** -查询: +**获取相对周数** -```sql -WITH toDate('2018-01-01') AS date -SELECT addTupleOfIntervals(date, (INTERVAL 1 DAY, INTERVAL 1 MONTH, INTERVAL 1 YEAR)) +```sql title=Query +SELECT toRelativeWeekNum(toDate('2023-01-08')) - toRelativeWeekNum(toDate('2023-01-01')) AS weeks_difference ``` -结果: - -```response -┌─addTupleOfIntervals(date, (toIntervalDay(1), toIntervalMonth(1), toIntervalYear(1)))─┐ -│ 2019-02-02 │ -└──────────────────────────────────────────────────────────────────────────────────────┘ +```response title=Response +┌─weeks_difference─┐ +│ 1 │ +└──────────────────┘ ``` -## subtractYears {#subtractyears} +## toRelativeYearNum {#toRelativeYearNum} + +引入于:v1.1 + -从日期、带时间的日期或字符串编码的日期/带时间的日期中减去指定数量的年份。 +将日期或带时间的日期转换为自过去某个固定点以来经过的年数。 +确切的时间点是实现细节,因此此函数不打算单独使用。 +该函数的主要目的在于计算两个日期或带时间的日期之间的年数差,例如 `toRelativeYearNum(dt1) - toRelativeYearNum(dt2)`。 + **语法** ```sql -subtractYears(date, num) +toRelativeYearNum(date) ``` **参数** -- `date`: 从中减去指定年份的日期/带时间的日期。 [Date](../data-types/date.md)/[Date32](../data-types/date32.md)/[DateTime](../data-types/datetime.md)/[DateTime64](../data-types/datetime64.md)、[String](../data-types/string.md)。 -- `num`: 要减去的年份数量。 [(U)Int*](../data-types/int-uint.md)、[Float*](../data-types/float.md)。 +- `date` — 日期或带时间的日期。 [`Date`](/sql-reference/data-types/date) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) + **返回值** -- 返回 `date` 减去 `num` 年。 [Date](../data-types/date.md)/[Date32](../data-types/date32.md)/[DateTime](../data-types/datetime.md)/[DateTime64](../data-types/datetime64.md)。 +返回自过去某个固定参考点以来的年数。 [`UInt16`](/sql-reference/data-types/int-uint) **示例** -```sql -WITH - toDate('2024-01-01') AS date, - toDateTime('2024-01-01 00:00:00') AS date_time, - '2024-01-01 00:00:00' AS date_time_string -SELECT - subtractYears(date, 1) AS subtract_years_with_date, - subtractYears(date_time, 1) AS subtract_years_with_date_time, - subtractYears(date_time_string, 1) AS subtract_years_with_date_time_string +**获取相对年份数** + +```sql title=Query +SELECT toRelativeYearNum('2010-10-01'::DateTime) - toRelativeYearNum('2000-01-01'::DateTime) ``` -```response -┌─subtract_years_with_date─┬─subtract_years_with_date_time─┬─subtract_years_with_date_time_string─┐ -│ 2023-01-01 │ 2023-01-01 00:00:00 │ 2023-01-01 00:00:00.000 │ -└──────────────────────────┴───────────────────────────────┴──────────────────────────────────────┘ +```response title=Response +┌─minus(toRela⋯ateTime')))─┐ +│ 10 │ +└──────────────────────────┘ ``` -## subtractQuarters {#subtractquarters} +## toSecond {#toSecond} -从日期、带时间的日期或字符串编码的日期/带时间的日期中减去指定数量的季度。 +引入于:v1.1 + + +返回 `DateTime` 或 `DateTime64` 值的秒部分(0-59)。 + **语法** ```sql -subtractQuarters(date, num) +toSecond(datetime) ``` **参数** -- `date`: 从中减去指定季度的日期/带时间的日期。 [Date](../data-types/date.md)/[Date32](../data-types/date32.md)/[DateTime](../data-types/datetime.md)/[DateTime64](../data-types/datetime64.md)、[String](../data-types/string.md)。 -- `num`: 要减去的季度数量。 [(U)Int*](../data-types/int-uint.md)、[Float*](../data-types/float.md)。 +- `datetime` — 从中获取秒的带时间日期。 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) + **返回值** -- 返回 `date` 减去 `num` 季度。 [Date](../data-types/date.md)/[Date32](../data-types/date32.md)/[DateTime](../data-types/datetime.md)/[DateTime64](../data-types/datetime64.md)。 +返回 `datetime` 中的秒(0 - 59)。 [`UInt8`](/sql-reference/data-types/int-uint) **示例** -```sql -WITH - toDate('2024-01-01') AS date, - toDateTime('2024-01-01 00:00:00') AS date_time, - '2024-01-01 00:00:00' AS date_time_string -SELECT - subtractQuarters(date, 1) AS subtract_quarters_with_date, - subtractQuarters(date_time, 1) AS subtract_quarters_with_date_time, - subtractQuarters(date_time_string, 1) AS subtract_quarters_with_date_time_string +**用法示例** + +```sql title=Query +SELECT toSecond(toDateTime('2023-04-21 10:20:30')) ``` -```response -┌─subtract_quarters_with_date─┬─subtract_quarters_with_date_time─┬─subtract_quarters_with_date_time_string─┐ -│ 2023-10-01 │ 2023-10-01 00:00:00 │ 2023-10-01 00:00:00.000 │ -└─────────────────────────────┴──────────────────────────────────┴─────────────────────────────────────────┘ +```response title=Response +┌─toSecond(toDateTime('2023-04-21 10:20:30'))─┐ +│ 30 │ +└─────────────────────────────────────────────┘ ``` -## subtractMonths {#subtractmonths} +## toStartOfDay {#toStartOfDay} -从日期、带时间的日期或字符串编码的日期/带时间的日期中减去指定数量的月份。 +引入于:v1.1 + + +将带时间的日期向下舍入到一天的开始。 + +:::note +返回值类型可以通过设置 [`enable_extended_results_for_datetime_functions`](/operations/settings/settings#enable_extended_results_for_datetime_functions) 来配置。 +::: + **语法** ```sql -subtractMonths(date, num) +toStartOfDay(datetime) ``` **参数** -- `date`: 从中减去指定月份的日期/带时间的日期。 [Date](../data-types/date.md)/[Date32](../data-types/date32.md)/[DateTime](../data-types/datetime.md)/[DateTime64](../data-types/datetime64.md)、[String](../data-types/string.md)。 -- `num`: 要减去的月份数量。 [(U)Int*](../data-types/int-uint.md)、[Float*](../data-types/float.md)。 +- `datetime` — 要舍入的日期或带时间的日期。 [`Date`](/sql-reference/data-types/date) 或 [`DateTime`](/sql-reference/data-types/datetime) + **返回值** -- 返回 `date` 减去 `num` 月份。 [Date](../data-types/date.md)/[Date32](../data-types/date32.md)/[DateTime](../data-types/datetime.md)/[DateTime64](../data-types/datetime64.md)。 +返回向下舍入到一天开始的带时间的日期。 [`Date`](/sql-reference/data-types/date) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime64`](/sql-reference/data-types/datetime64) **示例** -```sql -WITH - toDate('2024-01-01') AS date, - toDateTime('2024-01-01 00:00:00') AS date_time, - '2024-01-01 00:00:00' AS date_time_string -SELECT - subtractMonths(date, 1) AS subtract_months_with_date, - subtractMonths(date_time, 1) AS subtract_months_with_date_time, - subtractMonths(date_time_string, 1) AS subtract_months_with_date_time_string +**舍入到一天的开始** + +```sql title=Query +SELECT toStartOfDay(toDateTime('2023-04-21 10:20:30')) ``` -```response -┌─subtract_months_with_date─┬─subtract_months_with_date_time─┬─subtract_months_with_date_time_string─┐ -│ 2023-12-01 │ 2023-12-01 00:00:00 │ 2023-12-01 00:00:00.000 │ -└───────────────────────────┴────────────────────────────────┴───────────────────────────────────────┘ +```response title=Response +┌─toStartOfDay(toDateTime('2023-04-21 10:20:30'))─┐ +│ 2023-04-21 00:00:00 │ +└─────────────────────────────────────────────────┘ ``` -## subtractWeeks {#subtractweeks} +## toStartOfFifteenMinutes {#toStartOfFifteenMinutes} + +引入于:v1.1 + -从日期、带时间的日期或字符串编码的日期/带时间的日期中减去指定数量的周。 +将带时间的日期向下舍入到十五分钟间隔的开始。 + +:::note +返回值类型可以通过设置 [`enable_extended_results_for_datetime_functions`](/operations/settings/settings#enable_extended_results_for_datetime_functions) 来配置。 +::: + **语法** ```sql -subtractWeeks(date, num) +toStartOfFifteenMinutes(datetime) ``` **参数** -- `date`: 从中减去指定周数的日期/带时间的日期。 [Date](../data-types/date.md)/[Date32](../data-types/date32.md)/[DateTime](../data-types/datetime.md)/[DateTime64](../data-types/datetime64.md)、[String](../data-types/string.md)。 -- `num`: 要减去的周数。 [(U)Int*](../data-types/int-uint.md)、[Float*](../data-types/float.md)。 +- `datetime` — 要舍入的日期或带时间的日期。 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) + **返回值** -- 返回 `date` 减去 `num` 周。 [Date](../data-types/date.md)/[Date32](../data-types/date32.md)/[DateTime](../data-types/datetime.md)/[DateTime64](../data-types/datetime64.md)。 +返回向下舍入到最近的十五分钟间隔的带时间的日期 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) **示例** -```sql -WITH - toDate('2024-01-01') AS date, - toDateTime('2024-01-01 00:00:00') AS date_time, - '2024-01-01 00:00:00' AS date_time_string +**示例** + +```sql title=Query SELECT - subtractWeeks(date, 1) AS subtract_weeks_with_date, - subtractWeeks(date_time, 1) AS subtract_weeks_with_date_time, - subtractWeeks(date_time_string, 1) AS subtract_weeks_with_date_time_string + toStartOfFifteenMinutes(toDateTime('2023-04-21 10:17:00')), + toStartOfFifteenMinutes(toDateTime('2023-04-21 10:20:00')), + toStartOfFifteenMinutes(toDateTime('2023-04-21 10:23:00')) +FORMAT Vertical ``` -```response -┌─subtract_weeks_with_date─┬─subtract_weeks_with_date_time─┬─subtract_weeks_with_date_time_string─┐ -│ 2023-12-25 │ 2023-12-25 00:00:00 │ 2023-12-25 00:00:00.000 │ -└──────────────────────────┴───────────────────────────────┴──────────────────────────────────────┘ +```response title=Response +Row 1: +────── +toStartOfFifteenMinutes(toDateTime('2023-04-21 10:17:00')): 2023-04-21 10:15:00 +toStartOfFifteenMinutes(toDateTime('2023-04-21 10:20:00')): 2023-04-21 10:15:00 +toStartOfFifteenMinutes(toDateTime('2023-04-21 10:23:00')): 2023-04-21 10:15:00 ``` -## subtractDays {#subtractdays} +## toStartOfFiveMinutes {#toStartOfFiveMinutes} -从日期、带时间的日期或字符串编码的日期/带时间的日期中减去指定数量的天。 +引入于:v22.6 + + +将带时间的日期向下舍入到最近的五分钟间隔的开始。 + +:::note +返回值类型可以通过设置 [`enable_extended_results_for_datetime_functions`](/operations/settings/settings#enable_extended_results_for_datetime_functions) 来配置。 +::: + **语法** ```sql -subtractDays(date, num) +toStartOfFiveMinutes(datetime) ``` **参数** -- `date`: 从中减去指定天数的日期/带时间的日期。 [Date](../data-types/date.md)/[Date32](../data-types/date32.md)/[DateTime](../data-types/datetime.md)/[DateTime64](../data-types/datetime64.md)、[String](../data-types/string.md)。 -- `num`: 要减去的天数。 [(U)Int*](../data-types/int-uint.md)、[Float*](../data-types/float.md)。 +- `datetime` — 带时间的日期。 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) + **返回值** -- 返回 `date` 减去 `num` 天。 [Date](../data-types/date.md)/[Date32](../data-types/date32.md)/[DateTime](../data-types/datetime.md)/[DateTime64](../data-types/datetime64.md)。 +返回向下舍入到最近的五分钟间隔的带时间的日期 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) **示例** -```sql -WITH - toDate('2024-01-01') AS date, - toDateTime('2024-01-01 00:00:00') AS date_time, - '2024-01-01 00:00:00' AS date_time_string +**示例** + +```sql title=Query SELECT - subtractDays(date, 31) AS subtract_days_with_date, - subtractDays(date_time, 31) AS subtract_days_with_date_time, - subtractDays(date_time_string, 31) AS subtract_days_with_date_time_string + toStartOfFiveMinutes(toDateTime('2023-04-21 10:17:00')), + toStartOfFiveMinutes(toDateTime('2023-04-21 10:20:00')), + toStartOfFiveMinutes(toDateTime('2023-04-21 10:23:00')) +FORMAT Vertical ``` -```response -┌─subtract_days_with_date─┬─subtract_days_with_date_time─┬─subtract_days_with_date_time_string─┐ -│ 2023-12-01 │ 2023-12-01 00:00:00 │ 2023-12-01 00:00:00.000 │ -└─────────────────────────┴──────────────────────────────┴─────────────────────────────────────┘ +```response title=Response +Row 1: +────── +toStartOfFiveMinutes(toDateTime('2023-04-21 10:17:00')): 2023-04-21 10:15:00 +toStartOfFiveMinutes(toDateTime('2023-04-21 10:20:00')): 2023-04-21 10:20:00 +toStartOfFiveMinutes(toDateTime('2023-04-21 10:23:00')): 2023-04-21 10:20:00 ``` -## subtractHours {#subtracthours} +## toStartOfHour {#toStartOfHour} + +引入于:v1.1 + + +将带时间的日期向下舍入到小时的开始。 -从日期、带时间的日期或字符串编码的日期/带时间的日期中减去指定数量的小时。 +:::note +返回值类型可以通过设置 [`enable_extended_results_for_datetime_functions`](/operations/settings/settings#enable_extended_results_for_datetime_functions) 来配置。 +::: + **语法** ```sql -subtractHours(date, num) +toStartOfHour(datetime) ``` **参数** -- `date`: 从中减去指定小时数的日期/带时间的日期。 [Date](../data-types/date.md)/[Date32](../data-types/date32.md)/[Datetime](../data-types/datetime.md)/[Datetime64](../data-types/datetime64.md)、[String](../data-types/string.md)。 -- `num`: 要减去的小时数。 [(U)Int*](../data-types/int-uint.md)、[Float*](../data-types/float.md)。 +- `datetime` — 带时间的日期。 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) + **返回值** -- 返回 `date` 减去 `num` 小时。 [Date](../data-types/date.md)/[Date32](../data-types/date32.md)/[Datetime](../data-types/datetime.md)/[DateTime64](../data-types/datetime64.md)。 +返回向下舍入到小时开始的带时间的日期。 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) **示例** -```sql -WITH - toDate('2024-01-01') AS date, - toDateTime('2024-01-01 00:00:00') AS date_time, - '2024-01-01 00:00:00' AS date_time_string +**舍入到小时的开始** + +```sql title=Query SELECT - subtractHours(date, 12) AS subtract_hours_with_date, - subtractHours(date_time, 12) AS subtract_hours_with_date_time, - subtractHours(date_time_string, 12) AS subtract_hours_with_date_time_string + toStartOfHour(toDateTime('2023-04-21 10:20:30')); ``` -结果: - -```response -┌─subtract_hours_with_date─┬─subtract_hours_with_date_time─┬─subtract_hours_with_date_time_string─┐ -│ 2023-12-31 12:00:00 │ 2023-12-31 12:00:00 │ 2023-12-31 12:00:00.000 │ -└──────────────────────────┴───────────────────────────────┴──────────────────────────────────────┘ +```response title=Response +┌─────────────────res─┬─toTypeName(res)─┐ +│ 2023-04-21 10:00:00 │ DateTime │ +└─────────────────────┴─────────────────┘ ``` -## subtractMinutes {#subtractminutes} +## toStartOfISOYear {#toStartOfISOYear} -从日期、带时间的日期或字符串编码的日期/带时间的日期中减去指定数量的分钟。 +引入于:v1.1 + + +将日期或带时间的日期向下舍入到ISO年第一天,ISO年可能与常规年份不同。请参见 [ISO week date](https://en.wikipedia.org/wiki/ISO_week_date)。 + +:::note +返回值类型可以通过设置 [`enable_extended_results_for_datetime_functions`](/operations/settings/settings#enable_extended_results_for_datetime_functions) 来配置。 +::: + **语法** ```sql -subtractMinutes(date, num) +toStartOfISOYear(value) ``` **参数** -- `date`: 从中减去指定分钟数的日期/带时间的日期。 [Date](../data-types/date.md)/[Date32](../data-types/date32.md)/[DateTime](../data-types/datetime.md)/[DateTime64](../data-types/datetime64.md)、[String](../data-types/string.md)。 -- `num`: 要减去的分钟数。 [(U)Int*](../data-types/int-uint.md)、[Float*](../data-types/float.md)。 +- `value` — 要向下舍入到ISO年第一天的日期或带时间的日期。 [`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) + **返回值** -- 返回 `date` 减去 `num` 分钟。 [Date](../data-types/date.md)/[Date32](../data-types/date32.md)/[DateTime](../data-types/datetime.md)/[DateTime64](../data-types/datetime64.md)。 +返回给定日期或带时间的日期的ISO年第一天。 [`Date`](/sql-reference/data-types/date) **示例** +**向下舍入到ISO年第一天** + +```sql title=Query +SELECT toStartOfISOYear(toDateTime('2023-04-21 10:20:30')) +``` + +```response title=Response +┌─toStartOfISOYear(toDateTime('2023-04-21 10:20:30'))─┐ +│ 2023-01-02 │ +└─────────────────────────────────────────────────────┘ +``` +## toStartOfInterval {#toStartOfInterval} + +引入于:v20.1 + + +此函数通过 `toStartOfInterval(date_or_date_with_time, INTERVAL x unit [, time_zone])` 语法对其他 `toStartOf*()` 函数进行了通用化。 + +例如, +- `toStartOfInterval(t, INTERVAL 1 YEAR)` 返回与 `toStartOfYear(t)` 相同的结果, +- `toStartOfInterval(t, INTERVAL 1 MONTH)` 返回与 `toStartOfMonth(t)` 相同的结果, +- `toStartOfInterval(t, INTERVAL 1 DAY)` 返回与 `toStartOfDay(t)` 相同的结果, +- `toStartOfInterval(t, INTERVAL 15 MINUTE)` 返回与 `toStartOfFifteenMinutes(t)` 相同的结果。 + +计算是相对于特定时间点进行的: + +| 间隔 | 开始 | +|-----------|------------------------| +| YEAR | 年 0 | +| QUARTER | 1900 Q1 | +| MONTH | 1900年1月 | +| WEEK | 1970年第1周 (01-05) | +| DAY | 1970-01-01 | +| HOUR | (*) | +| MINUTE | 1970-01-01 00:00:00 | +| SECOND | 1970-01-01 00:00:00 | +| MILLISECOND | 1970-01-01 00:00:00 | +| MICROSECOND | 1970-01-01 00:00:00 | +| NANOSECOND | 1970-01-01 00:00:00 | +| (*) 小时间隔为特殊情况:计算始终相对于当天的00:00:00(午夜)进行。因此,只有1到23之间的小时值是有用的。 + +如果指定了单位 `WEEK`,`toStartOfInterval` 假定周从星期一开始。请注意,该行为不同于默认从星期日开始的 `toStartOfWeek` 函数。 + +第二个重载模拟了 TimescaleDB 的 `time_bucket()` 函数,以及 PostgreSQL 的 `date_bin()` 函数。 + + +**语法** + ```sql -WITH - toDate('2024-01-01') AS date, - toDateTime('2024-01-01 00:00:00') AS date_time, - '2024-01-01 00:00:00' AS date_time_string -SELECT - subtractMinutes(date, 30) AS subtract_minutes_with_date, - subtractMinutes(date_time, 30) AS subtract_minutes_with_date_time, - subtractMinutes(date_time_string, 30) AS subtract_minutes_with_date_time_string +toStartOfInterval(value, INTERVAL x unit[, time_zone]) +toStartOfInterval(value, INTERVAL x unit[, origin[, time_zone]]) ``` -结果: +**参数** -```response -┌─subtract_minutes_with_date─┬─subtract_minutes_with_date_time─┬─subtract_minutes_with_date_time_string─┐ -│ 2023-12-31 23:30:00 │ 2023-12-31 23:30:00 │ 2023-12-31 23:30:00.000 │ -└────────────────────────────┴─────────────────────────────────┴────────────────────────────────────────┘ +- `value` — 要向下舍入的日期或带时间的日期。 [`Date`](/sql-reference/data-types/date) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) +- `x` — 间隔长度数。 - `unit` — 间隔单位:YEAR, QUARTER, MONTH, WEEK, DAY, HOUR, MINUTE, SECOND, MILLISECOND, MICROSECOND, NANOSECOND。 - `time_zone` — 可选。作为字符串的时区名称。 - `origin` — 可选。用于计算的起点(仅适用于第二个重载)。 + +**返回值** + +返回包含输入值的间隔开始。 [`DateTime`](/sql-reference/data-types/datetime) + +**示例** + +**基本间隔舍入** + +```sql title=Query +SELECT toStartOfInterval(toDateTime('2023-01-15 14:30:00'), INTERVAL 1 MONTH) +``` + +```response title=Response +┌─toStartOfInt⋯alMonth(1))─┐ +│ 2023-01-01 │ +└──────────────────────────┘ +``` + +**使用起点** + +```sql title=Query +SELECT toStartOfInterval(toDateTime('2023-01-01 14:45:00'), INTERVAL 1 MINUTE, toDateTime('2023-01-01 14:35:30')) +``` + +```response title=Response +┌─toStartOfInt⋯14:35:30'))─┐ +│ 2023-01-01 14:44:30 │ +└──────────────────────────┘ ``` -## subtractSeconds {#subtractseconds} +## toStartOfMicrosecond {#toStartOfMicrosecond} + +引入于:v22.6 -从日期、带时间的日期或字符串编码的日期/带时间的日期中减去指定数量的秒。 + +将带时间的日期向下舍入到微秒的开始。 + **语法** ```sql -subtractSeconds(date, num) +toStartOfMicrosecond(datetime, [timezone]) ``` **参数** -- `date`: 从中减去指定秒数的日期/带时间的日期。 [Date](../data-types/date.md)/[Date32](../data-types/date32.md)/[DateTime](../data-types/datetime.md)/[DateTime64](../data-types/datetime64.md)、[String](../data-types/string.md)。 -- `num`: 要减去的秒数。 [(U)Int*](../data-types/int-uint.md)、[Float*](../data-types/float.md)。 +- `datetime` — 日期和时间。 [`DateTime64`](/sql-reference/data-types/datetime64) +- `timezone` — 可选。返回值的时区。如果未指定,函数将使用 `value` 参数的时区。 [`String`](/sql-reference/data-types/string) + **返回值** -- 返回 `date` 减去 `num` 秒。 [Date](../data-types/date.md)/[Date32](../data-types/date32.md)/[DateTime](../data-types/datetime.md)/[DateTime64](../data-types/datetime64.md)。 +输入值的微秒部分 [`DateTime64`](/sql-reference/data-types/datetime64) **示例** -```sql -WITH - toDate('2024-01-01') AS date, - toDateTime('2024-01-01 00:00:00') AS date_time, - '2024-01-01 00:00:00' AS date_time_string -SELECT - subtractSeconds(date, 60) AS subtract_seconds_with_date, - subtractSeconds(date_time, 60) AS subtract_seconds_with_date_time, - subtractSeconds(date_time_string, 60) AS subtract_seconds_with_date_time_string +**无时区的查询** + +```sql title=Query +WITH toDateTime64('2020-01-01 10:20:30.999999999', 9) AS dt64 +SELECT toStartOfMicrosecond(dt64); +``` + +```response title=Response +┌────toStartOfMicrosecond(dt64)─┐ +│ 2020-01-01 10:20:30.999999000 │ +└───────────────────────────────┘ ``` -结果: +**带时区的查询** -```response -┌─subtract_seconds_with_date─┬─subtract_seconds_with_date_time─┬─subtract_seconds_with_date_time_string─┐ -│ 2023-12-31 23:59:00 │ 2023-12-31 23:59:00 │ 2023-12-31 23:59:00.000 │ -└────────────────────────────┴─────────────────────────────────┴────────────────────────────────────────┘ +```sql title=Query +WITH toDateTime64('2020-01-01 10:20:30.999999999', 9) AS dt64 +SELECT toStartOfMicrosecond(dt64, 'Asia/Istanbul'); ``` -## subtractMilliseconds {#subtractmilliseconds} -从带时间的日期或字符串编码的带时间的日期中减去指定数量的毫秒。 +```response title=Response +┌─toStartOfMicrosecond(dt64, 'Asia/Istanbul')─┐ +│ 2020-01-01 12:20:30.999999000 │ +└─────────────────────────────────────────────┘ +``` +## toStartOfMillisecond {#toStartOfMillisecond} + +引入于:v22.6 + + +将带时间的日期向下舍入到毫秒的开始。 + **语法** ```sql -subtractMilliseconds(date_time, num) +toStartOfMillisecond(datetime, [timezone]) ``` **参数** -- `date_time`: 带时间的日期,从中减去指定数量的毫秒。 [DateTime](../data-types/datetime.md)/[DateTime64](../data-types/datetime64.md)、[String](../data-types/string.md)。 -- `num`: 要减去的毫秒数。 [(U)Int*](../data-types/int-uint.md)、[Float*](../data-types/float.md)。 +- `datetime` — 日期和时间。 [`DateTime64`](/sql-reference/data-types/datetime64) +- `timezone` — 可选。返回值的时区。如果未指定,函数将使用 `value` 参数的时区。 [`String`](/sql-reference/data-types/string) + **返回值** -- 返回 `date_time` 减去 `num` 毫秒。 [DateTime64](../data-types/datetime64.md)。 +输入值的毫秒部分。 [`DateTime64`](/sql-reference/data-types/datetime64) **示例** -```sql -WITH - toDateTime('2024-01-01 00:00:00') AS date_time, - '2024-01-01 00:00:00' AS date_time_string -SELECT - subtractMilliseconds(date_time, 1000) AS subtract_milliseconds_with_date_time, - subtractMilliseconds(date_time_string, 1000) AS subtract_milliseconds_with_date_time_string +**无时区的查询** + +```sql title=Query +WITH toDateTime64('2020-01-01 10:20:30.999999999', 9) AS dt64 +SELECT toStartOfMillisecond(dt64); ``` -结果: +```response title=Response +┌────toStartOfMillisecond(dt64)─┐ +│ 2020-01-01 10:20:30.999000000 │ +└───────────────────────────────┘ +``` -```response -┌─subtract_milliseconds_with_date_time─┬─subtract_milliseconds_with_date_time_string─┐ -│ 2023-12-31 23:59:59.000 │ 2023-12-31 23:59:59.000 │ -└──────────────────────────────────────┴─────────────────────────────────────────────┘ +**带时区的查询** + +```sql title=Query +WITH toDateTime64('2020-01-01 10:20:30.999999999', 9) AS dt64 +SELECT toStartOfMillisecond(dt64, 'Asia/Istanbul'); ``` -## subtractMicroseconds {#subtractmicroseconds} -从带时间的日期或字符串编码的带时间的日期中减去指定数量的微秒。 +```response title=Response +┌─toStartOfMillisecond(dt64, 'Asia/Istanbul')─┐ +│ 2020-01-01 12:20:30.999000000 │ +└─────────────────────────────────────────────┘ +``` +## toStartOfMinute {#toStartOfMinute} + +引入于:v1.1 + + +将带时间的日期向下舍入到分钟的开始。 + +:::note +返回值类型可以通过设置 [`enable_extended_results_for_datetime_functions`](/operations/settings/settings#enable_extended_results_for_datetime_functions) 来配置。 +::: + **语法** ```sql -subtractMicroseconds(date_time, num) +toStartOfMinute(datetime) ``` **参数** -- `date_time`: 带时间的日期,从中减去指定数量的微秒。 [DateTime](../data-types/datetime.md)/[DateTime64](../data-types/datetime64.md)、[String](../data-types/string.md)。 -- `num`: 要减去的微秒数。 [(U)Int*](../data-types/int-uint.md)、[Float*](../data-types/float.md)。 +- `datetime` — 要舍入的带时间日期。 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) + **返回值** -- 返回 `date_time` 减去 `num` 微秒。 [DateTime64](../data-types/datetime64.md)。 +返回向下舍入到分钟开始的带时间日期。 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) **示例** -```sql -WITH - toDateTime('2024-01-01 00:00:00') AS date_time, - '2024-01-01 00:00:00' AS date_time_string +**舍入到分钟的开始** + +```sql title=Query SELECT - subtractMicroseconds(date_time, 1000000) AS subtract_microseconds_with_date_time, - subtractMicroseconds(date_time_string, 1000000) AS subtract_microseconds_with_date_time_string + toStartOfMinute(toDateTime('2023-04-21 10:20:30')), + toStartOfMinute(toDateTime64('2023-04-21 10:20:30.5300', 8)) +FORMAT Vertical ``` -结果: +```response title=Response +Row 1: +────── +toStartOfMinute(toDateTime('2023-04-21 10:20:30')): 2023-04-21 10:20:00 +toStartOfMinute(toDateTime64('2023-04-21 10:20:30.5300', 8)): 2023-04-21 10:20:00 +``` +## toStartOfMonth {#toStartOfMonth} -```response -┌─subtract_microseconds_with_date_time─┬─subtract_microseconds_with_date_time_string─┐ -│ 2023-12-31 23:59:59.000000 │ 2023-12-31 23:59:59.000000 │ -└──────────────────────────────────────┴─────────────────────────────────────────────┘ +引入于:v1.1 + + +将日期或带时间的日期向下舍入到本月的第一天。 + +:::note +返回值类型可以通过设置 [`enable_extended_results_for_datetime_functions`](/operations/settings/settings#enable_extended_results_for_datetime_functions) 来配置。 +::: + + +**语法** + +```sql +toStartOfMonth(value) ``` -## subtractNanoseconds {#subtractnanoseconds} -从带时间的日期或字符串编码的带时间的日期中减去指定数量的纳秒。 +**参数** + +- `value` — 要向下舍入到本月第一天的日期或带时间的日期。 [`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) + + +**返回值** + +返回给定日期或带时间的日期的本月第一天。 [`Date`](/sql-reference/data-types/date) + +**示例** + +**向下舍入到本月的第一天** + +```sql title=Query +SELECT toStartOfMonth(toDateTime('2023-04-21 10:20:30')) +``` + +```response title=Response +┌─toStartOfMonth(toDateTime('2023-04-21 10:20:30'))─┐ +│ 2023-04-01 │ +└───────────────────────────────────────────────────┘ +``` +## toStartOfNanosecond {#toStartOfNanosecond} + +引入于:v22.6 + + +将带时间的日期向下舍入到纳秒的开始。 + **语法** ```sql -subtractNanoseconds(date_time, num) +toStartOfNanosecond(datetime, [timezone]) ``` **参数** -- `date_time`: 带时间的日期,从中减去指定数量的纳秒。 [DateTime](../data-types/datetime.md)/[DateTime64](../data-types/datetime64.md)、[String](../data-types/string.md)。 -- `num`: 要减去的纳秒数。 [(U)Int*](../data-types/int-uint.md)、[Float*](../data-types/float.md)。 +- `datetime` — 日期和时间。 [`DateTime64`](/sql-reference/data-types/datetime64) +- `timezone` — 可选。返回值的时区。如果未指定,函数将使用 `value` 参数的时区。 [`String`](/sql-reference/data-types/string) + **返回值** -- 返回 `date_time` 减去 `num` 纳秒。 [DateTime64](../data-types/datetime64.md)。 +输入值的纳秒部分。 [`DateTime64`](/sql-reference/data-types/datetime64) **示例** +**无时区的查询** + +```sql title=Query +WITH toDateTime64('2020-01-01 10:20:30.999999999', 9) AS dt64 +SELECT toStartOfNanosecond(dt64); +``` + +```response title=Response +┌─────toStartOfNanosecond(dt64)─┐ +│ 2020-01-01 10:20:30.999999999 │ +└───────────────────────────────┘ +``` + +**带时区的查询** + +```sql title=Query +WITH toDateTime64('2020-01-01 10:20:30.999999999', 9) AS dt64 +SELECT toStartOfNanosecond(dt64, 'Asia/Istanbul'); +``` + +```response title=Response +┌─toStartOfNanosecond(dt64, 'Asia/Istanbul')─┐ +│ 2020-01-01 12:20:30.999999999 │ +└────────────────────────────────────────────┘ +``` +## toStartOfQuarter {#toStartOfQuarter} + +引入于:v1.1 + + +将日期或带时间的日期向下舍入到季度的第一天。季度的第一天是每年的1月1日、4月1日、7月1日或10月1日。 + +:::note +返回值类型可以通过设置 [`enable_extended_results_for_datetime_functions`](/operations/settings/settings#enable_extended_results_for_datetime_functions) 来配置。 +::: + + +**语法** + ```sql -WITH - toDateTime('2024-01-01 00:00:00') AS date_time, - '2024-01-01 00:00:00' AS date_time_string -SELECT - subtractNanoseconds(date_time, 1000) AS subtract_nanoseconds_with_date_time, - subtractNanoseconds(date_time_string, 1000) AS subtract_nanoseconds_with_date_time_string +toStartOfQuarter(value) ``` -结果: +**参数** -```response -┌─subtract_nanoseconds_with_date_time─┬─subtract_nanoseconds_with_date_time_string─┐ -│ 2023-12-31 23:59:59.999999000 │ 2023-12-31 23:59:59.999999000 │ -└─────────────────────────────────────┴────────────────────────────────────────────┘ +- `value` — 要向下舍入到季度第一天的日期或带时间的日期。 [`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) + + +**返回值** + +返回给定日期或带时间的日期的季度第一天。 [`Date`](/sql-reference/data-types/date) + +**示例** + +**向下舍入到季度的第一天** + +```sql title=Query +SELECT toStartOfQuarter(toDateTime('2023-04-21 10:20:30')) ``` -## subtractInterval {#subtractinterval} -将负的区间添加到另一个区间或区间的元组中。 +```response title=Response +┌─toStartOfQuarter(toDateTime('2023-04-21 10:20:30'))─┐ +│ 2023-04-01 │ +└─────────────────────────────────────────────────────┘ +``` +## toStartOfSecond {#toStartOfSecond} + +引入于:v20.5 + + +将带时间的日期向下舍入到秒的开始。 + **语法** ```sql -subtractInterval(interval_1, interval_2) +toStartOfSecond(datetime, [timezone]) ``` **参数** -- `interval_1`: 第一个区间或区间的元组。 [interval](../data-types/special-data-types/interval.md)、[tuple](../data-types/tuple.md)([interval](../data-types/special-data-types/interval.md))。 -- `interval_2`: 要取反的第二个区间。 [interval](../data-types/special-data-types/interval.md)。 +- `datetime` — 日期和时间以截断亚秒。 [`DateTime64`](/sql-reference/data-types/datetime64) +- `timezone` — 可选。返回值的时区。如果未指定,函数将使用 `value` 参数的时区。 [`String`](/sql-reference/data-types/string) + **返回值** -- 返回一个区间的元组。 [tuple](../data-types/tuple.md)([interval](../data-types/special-data-types/interval.md))。 +返回输入值,而没有亚秒部分。 [`DateTime64`](/sql-reference/data-types/datetime64) + +**示例** + +**无时区的查询** + +```sql title=Query +WITH toDateTime64('2020-01-01 10:20:30.999', 3) AS dt64 +SELECT toStartOfSecond(dt64); +``` + +```response title=Response +┌───toStartOfSecond(dt64)─┐ +│ 2020-01-01 10:20:30.000 │ +└─────────────────────────┘ +``` + +**带时区的查询** + +```sql title=Query +WITH toDateTime64('2020-01-01 10:20:30.999', 3) AS dt64 +SELECT toStartOfSecond(dt64, 'Asia/Istanbul'); +``` + +```response title=Response +┌─toStartOfSecond(dt64, 'Asia/Istanbul')─┐ +│ 2020-01-01 13:20:30.000 │ +└────────────────────────────────────────┘ +``` +## toStartOfTenMinutes {#toStartOfTenMinutes} + +引入于:v20.1 + + +将带时间的日期向下舍入到最近的十分钟间隔的开始。 :::note -同类型的区间将被组合成单个区间。例如,如果传递了 `toIntervalDay(2)` 和 `toIntervalDay(1)`,则结果将是 `(1)` 而不是 `(2,1)` +返回值类型可以通过设置 [`enable_extended_results_for_datetime_functions`](/operations/settings/settings#enable_extended_results_for_datetime_functions) 来配置。 ::: + -**示例** - -查询: +**语法** ```sql -SELECT subtractInterval(INTERVAL 1 DAY, INTERVAL 1 MONTH); -SELECT subtractInterval((INTERVAL 1 DAY, INTERVAL 1 YEAR), INTERVAL 1 MONTH); -SELECT subtractInterval(INTERVAL 2 DAY, INTERVAL 1 DAY); +toStartOfTenMinutes(datetime) ``` -结果: +**参数** -```response -┌─subtractInterval(toIntervalDay(1), toIntervalMonth(1))─┐ -│ (1,-1) │ -└────────────────────────────────────────────────────────┘ -┌─subtractInterval((toIntervalDay(1), toIntervalYear(1)), toIntervalMonth(1))─┐ -│ (1,1,-1) │ -└─────────────────────────────────────────────────────────────────────────────┘ -┌─subtractInterval(toIntervalDay(2), toIntervalDay(1))─┐ -│ (1) │ -└──────────────────────────────────────────────────────┘ +- `datetime` — 带时间的日期。 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) + + +**返回值** + +返回向下舍入到最近的十分钟间隔的带时间的日期 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) + +**示例** + +**示例** + +```sql title=Query +SELECT + toStartOfTenMinutes(toDateTime('2023-04-21 10:17:00')), + toStartOfTenMinutes(toDateTime('2023-04-21 10:20:00')), + toStartOfTenMinutes(toDateTime('2023-04-21 10:23:00')) +FORMAT Vertical +``` + +```response title=Response +Row 1: +────── +toStartOfTenMinutes(toDateTime('2023-04-21 10:17:00')): 2023-04-21 10:10:00 +toStartOfTenMinutes(toDateTime('2023-04-21 10:20:00')): 2023-04-21 10:20:00 +toStartOfTenMinutes(toDateTime('2023-04-21 10:23:00')): 2023-04-21 10:20:00 ``` -## subtractTupleOfIntervals {#subtracttupleofintervals} +## toStartOfWeek {#toStartOfWeek} + +引入于:v20.1 -连续地从 Date 或 DateTime 中减去区间的元组。 + +将日期或带时间的日期舍入到最近的星期日或星期一。 + +:::note +返回值类型可以通过设置 [`enable_extended_results_for_datetime_functions`](/operations/settings/settings#enable_extended_results_for_datetime_functions) 来配置。 +::: + **语法** ```sql -subtractTupleOfIntervals(interval_1, interval_2) +toStartOfWeek(datetime[, mode[, timezone]]) ``` **参数** -- `date`: 第一个区间或区间的元组。 [Date](../data-types/date.md)/[Date32](../data-types/date32.md)/[DateTime](../data-types/datetime.md)/[DateTime64](../data-types/datetime64.md)。 -- `intervals`: 要从 `date` 中减去的区间元组。 [tuple](../data-types/tuple.md)([interval](../data-types/special-data-types/interval.md))。 +- `datetime` — 要转换的日期或带时间的日期。 [`Date`](/sql-reference/data-types/date) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime64`](/sql-reference/data-types/datetime64) +- `mode` — 确定一周的第一天,如 `toWeek()` 函数中所述。 默认值为 `0`。 [`UInt8`](/sql-reference/data-types/int-uint) +- `timezone` — 用于转换的时区。如果未指定,将使用服务器的时区。 [`String`](/sql-reference/data-types/string) + **返回值** -- 返回减去 `intervals` 的 `date`。 [Date](../data-types/date.md)/[Date32](../data-types/date32.md)/[DateTime](../data-types/datetime.md)/[DateTime64](../data-types/datetime64.md)。 +返回在给定日期之前或最近的星期日或星期一的日期,具体取决于模式 [`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) **示例** -查询: +**舍入到最近的星期日或星期一** + +```sql title=Query +SELECT + toStartOfWeek(toDateTime('2023-04-21 10:20:30')), /* a Friday */ + toStartOfWeek(toDateTime('2023-04-21 10:20:30'), 1), /* a Friday */ + toStartOfWeek(toDate('2023-04-24')), /* a Monday */ + toStartOfWeek(toDate('2023-04-24'), 1) /* a Monday */ + FORMAT Vertical +``` + +```response title=Response +Row 1: + ────── + toStartOfWeek(toDateTime('2023-04-21 10:20:30')): 2023-04-17 + toStartOfWeek(toDateTime('2023-04-21 10:20:30'), 1): 2023-04-17 + toStartOfWeek(toDate('2023-04-24')): 2023-04-24 + toStartOfWeek(toDate('2023-04-24'), 1): 2023-04-24 +``` +## toStartOfYear {#toStartOfYear} + +引入于:v1.1 + + +将日期或带时间的日期向下舍入到这一年的第一天。返回的日期为 `Date` 对象。 + +:::note +返回值类型可以通过设置 [`enable_extended_results_for_datetime_functions`](/operations/settings/settings#enable_extended_results_for_datetime_functions) 来配置。 +::: + + +**语法** ```sql -WITH toDate('2018-01-01') AS date SELECT subtractTupleOfIntervals(date, (INTERVAL 1 DAY, INTERVAL 1 YEAR)) +toStartOfYear(value) ``` -结果: +**参数** -```response -┌─subtractTupleOfIntervals(date, (toIntervalDay(1), toIntervalYear(1)))─┐ -│ 2016-12-31 │ -└───────────────────────────────────────────────────────────────────────┘ -``` -## timeSlots {#timeslots} +- `value` — 要舍入的日期或带时间的日期。 [`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) -对于从 'StartTime' 开始并持续 'Duration' 秒的时间间隔,它返回一个时间点的数组,由此区间的点向下舍入到 'Size' 秒。'Size' 是一个可选参数,默认为 1800(30 分钟)。 -当搜索相应会话中的页面浏览量时,此功能非常必要。 -接受 DateTime 和 DateTime64 作为 'StartTime' 参数。对于 DateTime,'Duration' 和 'Size' 参数必须为 `UInt32`。对于 'DateTime64',它们必须为 `Decimal64`。 -返回一组 DateTime/DateTime64(返回类型与 'StartTime' 的类型匹配)。对于 DateTime64,返回值的精度可能与 'StartTime' 的精度不同——所有给定参数中最高的精度将被采用。 -**语法** +**返回值** -```sql -timeSlots(StartTime, Duration,\[, Size\]) -``` +返回给定日期/时间的这一年的第一天 [`Date`](/sql-reference/data-types/date) **示例** -```sql -SELECT timeSlots(toDateTime('2012-01-01 12:20:00'), toUInt32(600)); -SELECT timeSlots(toDateTime('1980-12-12 21:01:02', 'UTC'), toUInt32(600), 299); -SELECT timeSlots(toDateTime64('1980-12-12 21:01:02.1234', 4, 'UTC'), toDecimal64(600.1, 1), toDecimal64(299, 0)); -``` +**向下舍入到这一年的第一天** -结果: +```sql title=Query +SELECT toStartOfYear(toDateTime('2023-04-21 10:20:30')) +``` -```text -┌─timeSlots(toDateTime('2012-01-01 12:20:00'), toUInt32(600))─┐ -│ ['2012-01-01 12:00:00','2012-01-01 12:30:00'] │ -└─────────────────────────────────────────────────────────────┘ -┌─timeSlots(toDateTime('1980-12-12 21:01:02', 'UTC'), toUInt32(600), 299)─┐ -│ ['1980-12-12 20:56:13','1980-12-12 21:01:12','1980-12-12 21:06:11'] │ -└─────────────────────────────────────────────────────────────────────────┘ -┌─timeSlots(toDateTime64('1980-12-12 21:01:02.1234', 4, 'UTC'), toDecimal64(600.1, 1), toDecimal64(299, 0))─┐ -│ ['1980-12-12 20:56:13.0000','1980-12-12 21:01:12.0000','1980-12-12 21:06:11.0000'] │ -└───────────────────────────────────────────────────────────────────────────────────────────────────────────┘ +```response title=Response +┌─toStartOfYear(toDateTime('2023-04-21 10:20:30'))─┐ +│ 2023-01-01 │ +└──────────────────────────────────────────────────┘ ``` -## formatDateTime {#formatdatetime} +## toTimeWithFixedDate {#toTimeWithFixedDate} -根据给定的格式字符串格式化时间。格式是常量表达式,因此无法为单个结果列设置多个格式。 +引入于:v1.1 -formatDateTime 使用 MySQL 日期时间格式样式,参见 https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_date-format。 -该函数的相反操作是 [parseDateTime](/sql-reference/functions/type-conversion-functions#parsedatetime)。 +提取日期或带时间的日期的时间部分。 +返回的结果是相对于固定时间点的偏移量,目前为 `1970-01-02`, +但确切的时间点是实现细节,将来可能会改变。 -别名:`DATE_FORMAT`。 +因此,`toTime` 不应单独使用。 +该函数的主要目的是计算两个日期或带时间的日期之间的时间差,例如 `toTime(dt1) - toTime(dt2)`。 + **语法** ```sql -formatDateTime(Time, Format[, Timezone]) +toTime(date[, timezone]) ``` +**参数** + +- `date` — 要转换为时间的日期。 [`Date`](/sql-reference/data-types/date) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) +- `timezone` — 可选。返回值的时区。 [`String`](/sql-reference/data-types/string) + + **返回值** -根据确定的格式返回时间和日期值。 - -**替换字段** - -使用替换字段,您可以为结果字符串定义模式。“示例”列显示 `2018-01-02 22:33:44` 的格式化结果。 - -| 占位符 | 描述 | 示例 | -|-------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------| -| %a | 简写的星期几名称(周一-周日) | Mon | -| %b | 简写的月份名称(1月-12月) | Jan | -| %c | 作为整数(01-12)表示的月份,参见下面的“注释 4” | 01 | -| %C | 年份除以 100 后向下取整(00-99) | 20 | -| %d | 零填充的月份中的日期(01-31) | 02 | -| %D | 短格式 MM/DD/YY 日期,相当于 %m/%d/%y | 01/02/18| -| %e | 零填充的月份中的日期( 1-31),参见下面的“注释 5” |   2 | -| %f | 小数秒,参见下面的“注释 1”和“注释 2” | 123456 | -| %F | 短格式 YYYY-MM-DD 日期,相当于 %Y-%m-%d | 2018-01-02 | -| %g | 两位数字的年份格式,符合 ISO 8601,缩写自四位数字表示法 | 18 | -| %G | ISO 周号的四位数字年份格式,按照 [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601#Week_dates) 标准计算的基于周的年份,通常仅与 %V 一起使用 | 2018 | -| %h | 12 小时制格式的小时(01-12) | 09 | -| %H | 24 小时制格式的小时(00-23) | 22 | -| %i | 分钟(00-59) | 33 | -| %I | 12 小时制格式的小时(01-12) | 10 | -| %j | 年中的天数(001-366) | 002 | -| %k | 24 小时制格式的小时(00-23),参见下面的“注释 4” | 14 | -| %l | 12 小时制格式的小时(01-12),参见下面的“注释 4” | 09 | -| %m | 作为整数(01-12)表示的月份 | 01 | -| %M | 完整的月份名称(1月-12月),参见下面的“注释 3” | January | -| %n | 换行符('') | | -| %p | AM 或 PM 的标志 | PM | -| %Q | 季度(1-4) | 1 | -| %r | 12 小时制 HH:MM AM/PM 时间,相当于 %h:%i %p | 10:30 PM | -| %R | 24 小时制 HH:MM 时间,相当于 %H:%i | 22:33 | -| %s | 秒(00-59) | 44 | -| %S | 秒(00-59) | 44 | -| %t | 水平制表符(') | | -| %T | ISO 8601 时间格式(HH:MM:SS),相当于 %H:%i:%S | 22:33:44 | -| %u | ISO 8601 星期几作为数字,周一为 1(1-7) | 2 | -| %V | ISO 8601 周号(01-53) | 01 | -| %w | 星期几作为整数表示,周日为 0(0-6) | 2 | -| %W | 完整的星期几名称(周一-周日) | Monday | -| %y | 年,最后两位数字(00-99) | 18 | -| %Y | 年 | 2018 | -| %z | 相对于 UTC 的时间偏移,格式为 +HHMM 或 -HHMM | -0500 | -| %% | 一个 % 符号 | % | - -注释 1:在 ClickHouse v23.4 之前的版本中,如果格式化值为 Date,Date32 或 DateTime(没有小数秒)或 DateTime64 的精度为 0,则 `%f` 打印单个零(0)。可以通过设置 `formatdatetime_f_prints_single_zero = 1` 恢复以前的行为。 - -注释 2:在 ClickHouse v25.1 之前的版本中,`%f` 打印的位数由 DateTime64 的小数位数确定,而不是固定的 6 位数。可以通过设置 `formatdatetime_f_prints_scale_number_of_digits= 1` 恢复以前的行为。 - -注释 3:在 ClickHouse v23.4 之前的版本中,`%M` 打印分钟(00-59)而不是完整的月份名称(1月-12月)。可以通过设置 `formatdatetime_parsedatetime_m_is_month_name = 0` 恢复以前的行为。 - -注释 4:在 ClickHouse v23.11 之前的版本中,`parseDateTime` 函数要求格式化器 `%c`(月份)和 `%l`/`%k`(小时)有前导零,例如 `07`。在后来的版本中,可以省略前导零,例如 `7`。可以通过设置 `parsedatetime_parse_without_leading_zeros = 0` 恢复以前的行为。请注意,函数 `formatDateTime` 默认仍然为 `%c` 和 `%l`/`%k` 打印前导零,以不破坏现有用例。可以通过设置 `formatdatetime_format_without_leading_zeros = 1` 更改此行为。 - -注释 5:在 ClickHouse v25.5 之前的版本中,函数 `parseDateTime` 对于格式化器 `%e` 要求单数字天数进行空格填充,例如 ` 3`。在后来的版本中,空间填充是可选的,例如 `3` 和 ` 3` 都可以。要保留以前的行为,请设置 `parsedatetime_e_requires_space_padding = 1`。类似地,函数 `formatDateTime` 中的格式化器 `%e` 之前无条件地进行前导空格填充,而现在可以不带前导空格进行打印。要保留以前的行为,请设置 `formatdatetime_e_with_space_padding = 1`。 +以偏移量的形式返回日期或带时间的日期的时间部分(选定为1970-01-02) [`DateTime`](/sql-reference/data-types/datetime) **示例** -```sql -SELECT formatDateTime(toDate('2010-01-04'), '%g') -``` - -结果: +**计算两个日期之间的时间差** -```text -┌─formatDateTime(toDate('2010-01-04'), '%g')─┐ -│ 10 │ -└────────────────────────────────────────────┘ +```sql title=Query +SELECT toTime('2025-06-15 12:00:00'::DateTime) - toTime('2024-05-10 11:00:00'::DateTime) AS result, toTypeName(result) ``` -```sql -SELECT formatDateTime(toDateTime64('2010-01-04 12:34:56.123456', 7), '%f') +```response title=Response +┌─result─┬─toTypeName(result)─┐ +│ 3600 │ Int32 │ +└────────┴────────────────────┘ ``` +## toTimezone {#toTimezone} -结果: +引入于:v1.1 -```sql -┌─formatDateTime(toDateTime64('2010-01-04 12:34:56.123456', 7), '%f')─┐ -│ 1234560 │ -└─────────────────────────────────────────────────────────────────────┘ -``` -另外,`formatDateTime` 函数可以接受第三个字符串参数,包含时区的名称。例如:`Asia/Istanbul`。在这种情况下,时间将按照指定的时区格式化。 +将 `DateTime` 或 `DateTime64` 转换为指定的时区。 +数据的内部值(unix秒数)不会改变。 +只有值的时区属性和字符串表示发生变化。 + -**示例** +**语法** ```sql -SELECT - now() AS ts, - time_zone, - formatDateTime(ts, '%T', time_zone) AS str_tz_time -FROM system.time_zones -WHERE time_zone LIKE 'Europe%' -LIMIT 10 - -┌──────────────────ts─┬─time_zone─────────┬─str_tz_time─┐ -│ 2023-09-08 19:13:40 │ Europe/Amsterdam │ 21:13:40 │ -│ 2023-09-08 19:13:40 │ Europe/Andorra │ 21:13:40 │ -│ 2023-09-08 19:13:40 │ Europe/Astrakhan │ 23:13:40 │ -│ 2023-09-08 19:13:40 │ Europe/Athens │ 22:13:40 │ -│ 2023-09-08 19:13:40 │ Europe/Belfast │ 20:13:40 │ -│ 2023-09-08 19:13:40 │ Europe/Belgrade │ 21:13:40 │ -│ 2023-09-08 19:13:40 │ Europe/Berlin │ 21:13:40 │ -│ 2023-09-08 19:13:40 │ Europe/Bratislava │ 21:13:40 │ -│ 2023-09-08 19:13:40 │ Europe/Brussels │ 21:13:40 │ -│ 2023-09-08 19:13:40 │ Europe/Bucharest │ 22:13:40 │ -└─────────────────────┴───────────────────┴─────────────┘ +toTimeZone(datetime, timezone) ``` -**另请参见** - -- [formatDateTimeInJodaSyntax](#formatdatetimeinjodasyntax) - -## formatDateTimeInJodaSyntax {#formatdatetimeinjodasyntax} - -与 formatDateTime 类似,除了以 Joda 风格格式化日期时间,而不是 MySQL 风格。参见 https://joda-time.sourceforge.net/apidocs/org/joda/time/format/DateTimeFormat.html。 +**参数** -该函数的相反操作是 [parseDateTimeInJodaSyntax](/sql-reference/functions/type-conversion-functions#parsedatetimeinjodasyntax)。 +- `date` — 要转换的值。 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) +- `timezone` — 目标时区名称。 [`String`](/sql-reference/data-types/string) -**替换字段** -使用替换字段,您可以为结果字符串定义模式。 +**返回值** -| 占位符 | 描述 | 表现 | 示例 | -|-------|-------------------------------------|------------|----------------------------------| -| G | 时代 | 文本 | AD | -| C | 时代的世纪(>=0) | 数字 | 20 | -| Y | 时代的年份(>=0) | 年 | 1996 | -| x | 周年份(尚不支持) | 年 | 1996 | -| w | 周年份的周(尚不支持) | 数字 | 27 | -| e | 星期几 | 数字 | 2 | -| E | 星期几 | 文本 | Tuesday; Tue | -| y | 年 | 年 | 1996 | -| D | 年中的天数 | 数字 | 189 | -| M | 年中的月份 | 月份 | July; Jul; 07 | -| d | 当月的天数 | 数字 | 10 | -| a | 半天 | 文本 | PM | -| K | 半天的小时(0~11) | 数字 | 0 | -| h | 半天的时钟小时(1~12) | 数字 | 12 | -| H | 一天的小时(0~23) | 数字 | 0 | -| k | 一天的时钟小时(1~24) | 数字 | 24 | -| m | 小时中的分钟 | 数字 | 30 | -| s | 分钟中的秒 | 数字 | 55 | -| S | 小数秒 | 数字 | 978 | -| z | 时区 | 文本 | Eastern Standard Time; EST | -| Z | 时区偏移 | 区域 | -0800; -0812 | -| ' | 文本转义 | 分隔符 | | -| '' | 单引号 | 字面 | ' | +返回与输入相同的时间戳,但时区为指定的时区 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) **示例** -```sql -SELECT formatDateTimeInJodaSyntax(toDateTime('2010-01-04 12:34:56'), 'yyyy-MM-dd HH:mm:ss') -``` +**用法示例** -结果: +```sql title=Query +SELECT toDateTime('2019-01-01 00:00:00', 'UTC') AS time_utc, +toTypeName(time_utc) AS type_utc, +toInt32(time_utc) AS int32utc, +toTimeZone(time_utc, 'Asia/Yekaterinburg') AS time_yekat, +toTypeName(time_yekat) AS type_yekat, +toInt32(time_yekat) AS int32yekat, +toTimeZone(time_utc, 'US/Samoa') AS time_samoa, +toTypeName(time_samoa) AS type_samoa, +toInt32(time_samoa) AS int32samoa +FORMAT Vertical; +``` -```java -┌─formatDateTimeInJodaSyntax(toDateTime('2010-01-04 12:34:56'), 'yyyy-MM-dd HH:mm:ss')─┐ -│ 2010-01-04 12:34:56 │ -└─────────────────────────────────────────────────────────────────────────────────────────┘ +```response title=Response +Row 1: +────── +time_utc: 2019-01-01 00:00:00 +type_utc: DateTime('UTC') +int32utc: 1546300800 +time_yekat: 2019-01-01 05:00:00 +type_yekat: DateTime('Asia/Yekaterinburg') +int32yekat: 1546300800 +time_samoa: 2018-12-31 13:00:00 +type_samoa: DateTime('US/Samoa') +int32samoa: 1546300800 ``` +## toUTCTimestamp {#toUTCTimestamp} -## dateName {#datename} +引入于:v23.8 -返回指定的日期部分。 + +将日期或带时间的值从一个时区转换为 UTC 时区时间戳。此函数主要是为了与 Apache Spark 和类似框架的兼容性。 + **语法** ```sql -dateName(date_part, date) +toUTCTimestamp(datetime, time_zone) ``` **参数** -- `date_part` — 日期部分。可能的值:'year','quarter','month','week','dayofyear','day','weekday','hour','minute','second'。 [字符串](../data-types/string.md)。 -- `date` — 日期。[日期](../data-types/date.md), [Date32](../data-types/date32.md), [DateTime](../data-types/datetime.md) 或 [DateTime64](../data-types/datetime64.md)。 -- `timezone` — 时区。可选。[字符串](../data-types/string.md)。 +- `datetime` — 日期或带时间类型的常量值或表达式。 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) +- `time_zone` — 字符串类型常量值或表示时区的表达式。 [`String`](/sql-reference/data-types/string) + **返回值** -- 日期的指定部分。[字符串](/sql-reference/data-types/string) +返回 UTC 时区中的日期或带时间的日期。 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) **示例** -```sql -WITH toDateTime('2021-04-14 11:22:33') AS date_value -SELECT - dateName('year', date_value), - dateName('month', date_value), - dateName('day', date_value); -``` +**将时区转换为 UTC** -结果: +```sql title=Query +SELECT toUTCTimestamp(toDateTime('2023-03-16'), 'Asia/Shanghai') +``` -```text -┌─dateName('year', date_value)─┬─dateName('month', date_value)─┬─dateName('day', date_value)─┐ -│ 2021 │ April │ 14 │ -└──────────────────────────────┴───────────────────────────────┴─────────────────────────────┘ +```response title=Response +┌─toUTCTimestamp(toDateTime('2023-03-16'), 'Asia/Shanghai')─┐ +│ 2023-03-15 16:00:00 │ +└─────────────────────────────────────────────────────────┘ ``` +## toUnixTimestamp {#toUnixTimestamp} -## monthName {#monthname} +引入于:v1.1 -返回月份名称。 + +将 `String`、`Date` 或 `DateTime` 转换为 Unix 时间戳(自 `1970-01-01 00:00:00 UTC` 起的秒数),返回类型为 `UInt32`。 + **语法** ```sql -monthName(date) +toUnixTimestamp(date, [timezone]) ``` **参数** -- `date` — 日期或带时间的日期。[日期](../data-types/date.md), [DateTime](../data-types/datetime.md) 或 [DateTime64](../data-types/datetime64.md)。 +- `date` — 要转换的值。 [`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) 或 [`String`](/sql-reference/data-types/string) +- `timezone` — 可选。用于转换的时区。如果未指定,将使用服务器的时区。 [`String`](/sql-reference/data-types/string) + **返回值** -- 月份名称。[字符串](/sql-reference/data-types/string) +返回 Unix 时间戳。 [`UInt32`](/sql-reference/data-types/int-uint) **示例** -```sql -WITH toDateTime('2021-04-14 11:22:33') AS date_value -SELECT monthName(date_value); -``` +**用法示例** -结果: +```sql title=Query +SELECT +'2017-11-05 08:07:47' AS dt_str, +toUnixTimestamp(dt_str) AS from_str, +toUnixTimestamp(dt_str, 'Asia/Tokyo') AS from_str_tokyo, +toUnixTimestamp(toDateTime(dt_str)) AS from_datetime, +toUnixTimestamp(toDateTime64(dt_str, 0)) AS from_datetime64, +toUnixTimestamp(toDate(dt_str)) AS from_date, +toUnixTimestamp(toDate32(dt_str)) AS from_date32 +FORMAT Vertical; +``` -```text -┌─monthName(date_value)─┐ -│ April │ -└───────────────────────┘ +```response title=Response +Row 1: +────── +dt_str: 2017-11-05 08:07:47 +from_str: 1509869267 +from_str_tokyo: 1509836867 +from_datetime: 1509869267 +from_datetime64: 1509869267 +from_date: 1509840000 +from_date32: 1509840000 ``` +## toWeek {#toWeek} -## fromUnixTimestamp {#fromunixtimestamp} +引入于:v20.1 -此函数将 Unix 时间戳转换为日历日期和一天的时间。 -它可以以两种方式调用: +该函数返回日期或日期时间的周数。`toWeek()` 的两个参数形式使您能够指定一周的起始日 +为星期日或星期一,以及返回值是否应该在 `0` 到 `53` 的范围内,还是在 `1` 到 `53` 的范围内。 -当给定一个类型为 [整数](../data-types/int-uint.md) 的单个参数时,返回一个类型为 [DateTime](../data-types/datetime.md) 的值,即表现得像是 [toDateTime](../../sql-reference/functions/type-conversion-functions.md#todatetime)。 +[`toISOWeek()`](#toWeek) 是一个兼容性函数,相当于 `toWeek(date,3)`。 -别名:`FROM_UNIXTIME`。 +下表描述了模式参数的运作方式。 -**示例:** +| 模式 | 一周的第一天 | 范围 | 第1周是包含在此年的第一周... | +|------|---------------|-----|-----------------------------------| +| 0 | 星期日 | 0-53 | 此年内包含星期日 | +| 1 | 星期一 | 0-53 | 此年内有4天及以上 | +| 2 | 星期日 | 1-53 | 此年内包含星期日 | +| 3 | 星期一 | 1-53 | 此年内有4天及以上 | +| 4 | 星期日 | 0-53 | 此年内有4天及以上 | +| 5 | 星期一 | 0-53 | 此年内包含星期一 | +| 6 | 星期日 | 1-53 | 此年内有4天及以上 | +| 7 | 星期一 | 1-53 | 此年内包含星期一 | +| 8 | 星期日 | 1-53 | 包含1月1日 | +| 9 | 星期一 | 1-53 | 包含1月1日 | -```sql -SELECT fromUnixTimestamp(423543535); -``` +对于具有"此年内有4天及以上"含义的模式值,周的编号遵循 ISO 8601:1988: -结果: +- 如果包含1月1日的周在新的一年中有4天或更多,则为第1周。 +- 否则,它是上一年的最后一周,下一周为第1周。 -```text -┌─fromUnixTimestamp(423543535)─┐ -│ 1983-06-04 10:58:55 │ -└──────────────────────────────┘ -``` +对于具有"包含1月1日"含义的模式值,包含1月1日的周为第1周。 +这不论新年中包含多少天,即使只包含一天。 +即,如果12月的最后一周包含下一年的1月1日,则该周将是下一年的第1周。 -当给定两个或三个参数时,第一个参数是类型为 [整数](../data-types/int-uint.md)、[日期](../data-types/date.md)、[Date32](../data-types/date32.md)、[DateTime](../data-types/datetime.md) 或 [DateTime64](../data-types/datetime64.md) 的值,第二个参数是常量格式字符串,第三个参数是一个可选的常量时区字符串,该函数返回一个类型为 [字符串](/sql-reference/data-types/string) 的值,即它的表现像 [formatDateTime](#formatdatetime)。在这种情况下,使用 [MySQL 的日期时间格式样式](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_date-format)。 +第一个参数也可以指定为 [`String`](../data-types/string.md)格式,该格式受到 [`parseDateTime64BestEffort()`](type-conversion-functions.md#parsedatetime64besteffort) 支持。字符串参数的支持仅出于与某些第三方工具的兼容性的目的。由于字符串参数的解析通常很慢,因此建议不要使用它。 + -**示例:** +**语法** ```sql -SELECT fromUnixTimestamp(1234334543, '%Y-%m-%d %R:%S') AS DateTime; +toWeek(datetime[, mode[, time_zone]]) ``` -结果: +**参数** -```text -┌─DateTime────────────┐ -│ 2009-02-11 14:42:23 │ -└─────────────────────┘ -``` +- `datetime` — 要获取周数的日期或带时间的日期。 [`Date`](/sql-reference/data-types/date) 或 [`DateTime`](/sql-reference/data-types/datetime) +- `mode` — 可选。模式 `0` 到 `9` 决定一周的第一天和周数的范围。默认值 `0`。 - `time_zone` — 可选。时区。 [`String`](/sql-reference/data-types/string) -**另请参见** -- [fromUnixTimestampInJodaSyntax](#fromunixtimestampinjodasyntax) +**返回值** -## fromUnixTimestampInJodaSyntax {#fromunixtimestampinjodasyntax} +根据指定模式返回周数。 [`UInt32`](/sql-reference/data-types/int-uint) -与 [fromUnixTimestamp](#fromunixtimestamp) 相同,但当以第二种方式调用(两个或三个参数)时,格式化使用 [Joda 风格](https://joda-time.sourceforge.net/apidocs/org/joda/time/format/DateTimeFormat.html),而不是 MySQL 风格。 +**示例** -**示例:** +**使用不同模式获取周数** -```sql -SELECT fromUnixTimestampInJodaSyntax(1234334543, 'yyyy-MM-dd HH:mm:ss', 'UTC') AS DateTime; +```sql title=Query +SELECT toDate('2016-12-27') AS date, toWeek(date) AS week0, toWeek(date,1) AS week1, toWeek(date,9) AS week9 ``` -结果: - -```text -┌─DateTime────────────┐ -│ 2009-02-11 06:42:23 │ -└─────────────────────┘ +```response title=Response +┌───────date─┬─week0─┬─week1─┬─week9─┐ +│ 2016-12-27 │ 52 │ 52 │ 1 │ +└────────────┴───────┴───────┴───────┘ ``` +## toYYYYMM {#toYYYYMM} + +引入于:v1.1 -## toModifiedJulianDay {#tomodifiedjulianday} +将日期或带时间的日期转换为一个包含年份和月份的 `UInt32` 数字(YYYY * 100 + MM)。接受第二个可选的时区参数。如果提供,时区必须是一个字符串常量。 -将文本形式的 [先历格里历](https://en.wikipedia.org/wiki/Proleptic_Gregorian_calendar) 日期 `YYYY-MM-DD` 转换为 Int32 的 [修订过的 Julian Day](https://en.wikipedia.org/wiki/Julian_day#Variants) 数字。此函数支持从 `0000-01-01` 到 `9999-12-31` 的日期。如果参数无法解析为日期,或者该日期无效,则会引发异常。 +该函数是函数 `YYYYMMDDToDate()` 的反函数。 + **语法** ```sql -toModifiedJulianDay(date) +toYYYYMM(datetime[, timezone]) ``` **参数** -- `date` — 文本形式的日期。[字符串](../data-types/string.md) 或 [固定字符串](../data-types/fixedstring.md)。 +- `datetime` — 要转换的日期或带时间的日期。 [`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) +- `timezone` — 可选。用于转换的时区。如果提供,时区必须是一个字符串常量。 [`String`](/sql-reference/data-types/string) + **返回值** -- 修订过的 Julian Day 数字。[Int32](../data-types/int-uint.md)。 +返回一个包含年份和月份的 UInt32 数字(YYYY * 100 + MM)。 [`UInt32`](/sql-reference/data-types/int-uint) **示例** -```sql -SELECT toModifiedJulianDay('2020-01-01'); -``` +**将当前日期转换为 YYYYMM 格式** -结果: +```sql title=Query +SELECT toYYYYMM(now(), 'US/Eastern') +``` -```text -┌─toModifiedJulianDay('2020-01-01')─┐ -│ 58849 │ -└───────────────────────────────────┘ +```response title=Response +┌─toYYYYMM(now(), 'US/Eastern')─┐ +│ 202303 │ +└───────────────────────────────┘ ``` +## toYYYYMMDD {#toYYYYMMDD} -## toModifiedJulianDayOrNull {#tomodifiedjuliandayornull} +引入于:v1.1 -类似于 [toModifiedJulianDay()](#tomodifiedjulianday),但不引发异常,而是返回 `NULL`。 +将日期或带时间的日期转换为一个包含年份、月份和日期的 `UInt32` 数字(YYYY * 10000 + MM * 100 + DD)。接受第二个可选的时区参数。如果提供,时区必须是一个字符串常量。 + **语法** ```sql -toModifiedJulianDayOrNull(date) +toYYYYMMDD(datetime[, timezone]) ``` **参数** -- `date` — 文本形式的日期。[字符串](../data-types/string.md) 或 [固定字符串](../data-types/fixedstring.md)。 +- `datetime` — 要转换的日期或带时间的日期。 [`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) +- `timezone` — 可选。用于转换的时区。如果提供,时区必须是一个字符串常量。 [`String`](/sql-reference/data-types/string) + **返回值** -- 修订过的 Julian Day 数字。[Nullable(Int32)](../data-types/int-uint.md)。 +返回一个 `UInt32` 数字,包含年份、月份和日期(YYYY * 10000 + MM * 100 + DD)。 [`UInt32`](/sql-reference/data-types/int-uint) **示例** -```sql -SELECT toModifiedJulianDayOrNull('2020-01-01'); -``` +**将当前日期转换为 YYYYMMDD 格式** -结果: +```sql title=Query +SELECT toYYYYMMDD(now(), 'US/Eastern') +``` -```text -┌─toModifiedJulianDayOrNull('2020-01-01')─┐ -│ 58849 │ -└─────────────────────────────────────────┘ +```response title=Response +┌─toYYYYMMDD(now(), 'US/Eastern')─┐ +│ 20230302 │ +└─────────────────────────────────┘ ``` +## toYYYYMMDDhhmmss {#toYYYYMMDDhhmmss} -## fromModifiedJulianDay {#frommodifiedjulianday} +引入于:v1.1 -将 [修订过的 Julian Day](https://en.wikipedia.org/wiki/Julian_day#Variants) 数字转换为文本形式的 [先历格里历](https://en.wikipedia.org/wiki/Proleptic_Gregorian_calendar) 日期 `YYYY-MM-DD`。此函数支持从 `-678941` 到 `2973483` 的天数(分别对应于 0000-01-01 和 9999-12-31)。如果天数超出支持的范围,则会引发异常。 +将日期或带时间的日期转换为一个包含年份、月份、日期、小时、分钟和秒的 `UInt64` 数字(YYYY * 10000000000 + MM * 100000000 + DD * 1000000 + hh * 10000 + mm * 100 + ss)。接受第二个可选的时区参数。如果提供,时区必须是一个字符串常量。 + **语法** ```sql -fromModifiedJulianDay(day) +toYYYYMMDDhhmmss(datetime[, timezone]) ``` **参数** -- `day` — 修订过的 Julian Day 数字。[任何整型](../data-types/int-uint.md)。 +- `datetime` — 要转换的日期或带时间的日期。 [`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) +- `timezone` — 可选。用于转换的时区。如果提供,时区必须是一个字符串常量。 [`String`](/sql-reference/data-types/string) + **返回值** -- 文本形式的日期。[字符串](../data-types/string.md) +返回一个 `UInt64` 数字,包含年份、月份、日期、小时、分钟和秒(YYYY * 10000000000 + MM * 100000000 + DD * 1000000 + hh * 10000 + mm * 100 + ss)。 [`UInt64`](/sql-reference/data-types/int-uint) **示例** -```sql -SELECT fromModifiedJulianDay(58849); -``` +**将当前日期和时间转换为 YYYYMMDDhhmmss 格式** -结果: +```sql title=Query +SELECT toYYYYMMDDhhmmss(now(), 'US/Eastern') +``` -```text -┌─fromModifiedJulianDay(58849)─┐ -│ 2020-01-01 │ -└──────────────────────────────┘ +```response title=Response +┌─toYYYYMMDDhhmmss(now(), 'US/Eastern')─┐ +│ 20230302112209 │ +└───────────────────────────────────────┘ ``` +## toYear {#toYear} -## fromModifiedJulianDayOrNull {#frommodifiedjuliandayornull} +引入于:v1.1 -类似于 [fromModifiedJulianDayOrNull()](#frommodifiedjuliandayornull),但不引发异常,而是返回 `NULL`。 +返回 `Date` 或 `DateTime` 值的年份组成部分(公元年)。 + **语法** ```sql -fromModifiedJulianDayOrNull(day) +toYear(datetime) ``` **参数** -- `day` — 修订过的 Julian Day 数字。[任何整型](../data-types/int-uint.md)。 +- `datetime` — 要提取年份的日期或带时间的日期。 [`Date`](/sql-reference/data-types/date) 或 [`Date32`](/sql-reference/data-types/date32) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) + **返回值** -- 文本形式的日期。[Nullable(String)](../data-types/string.md) +返回给定日期或日期时间的年份 [`UInt16`](/sql-reference/data-types/int-uint) **示例** -```sql -SELECT fromModifiedJulianDayOrNull(58849); -``` +**用法示例** -结果: +```sql title=Query +SELECT toYear(toDateTime('2023-04-21 10:20:30')) +``` -```text -┌─fromModifiedJulianDayOrNull(58849)─┐ -│ 2020-01-01 │ -└────────────────────────────────────┘ +```response title=Response +┌─toYear(toDateTime('2023-04-21 10:20:30'))─┐ + │ 2023 │ + └───────────────────────────────────────────┘ ``` +## toYearNumSinceEpoch {#toYearNumSinceEpoch} -## toUTCTimestamp {#toutctimestamp} +引入于:v25.3 -将 DateTime/DateTime64 类型的值从其他时区转换为 UTC 时区的时间戳。此函数主要用于与 Apache Spark 和类似框架的兼容性。 +返回从1970年起经过的年份数。 **语法** ```sql -toUTCTimestamp(time_val, time_zone) +toYearNumSinceEpoch(date) ``` **参数** -- `time_val` — DateTime/DateTime64 类型的常量值或表达式。[DateTime/DateTime64 类型](../data-types/datetime.md) -- `time_zone` — 字符串类型的常量值或表示时区的表达式。[字符串类型](../data-types/string.md) +- `date` — 要转换的日期或带时间的日期。 [`Date`](/sql-reference/data-types/date) 或 [`DateTime`](/sql-reference/data-types/datetime) 或 [`DateTime64`](/sql-reference/data-types/datetime64) + **返回值** -- 文本形式的 DateTime/DateTime64 +正整数 **示例** -```sql -SELECT toUTCTimestamp(toDateTime('2023-03-16'), 'Asia/Shanghai'); -``` +**示例** -结果: +```sql title=Query +SELECT toYearNumSinceEpoch(toDate('2024-10-01')) +``` -```text -┌─toUTCTimestamp(toDateTime('2023-03-16'), 'Asia/Shanghai')┐ -│ 2023-03-15 16:00:00 │ -└─────────────────────────────────────────────────────────┘ +```response title=Response +54 ``` +## toYearWeek {#toYearWeek} + +引入于:v20.1 -## fromUTCTimestamp {#fromutctimestamp} +返回日期的年份和周数。结果中的年份可能与日期参数中的年份不同,适用于年初和年末的第一周和最后一周。 -将 DateTime/DateTime64 类型的值从 UTC 时区转换为其他时区的时间戳。此函数主要用于与 Apache Spark 和类似框架的兼容性。 +`mode` 参数的作用与[`toWeek()`](/sql-reference/functions/date-time-functions#toWeek) 的 `mode` 参数相同。 + +警告:`toYearWeek()` 返回的周数可能与 `toWeek()` 返回的不同。`toWeek()` 总是返回给定年份上下文中的周数,如果 `toWeek()` 返回 `0`,`toYearWeek()` 返回对应于前一年最后一周的值。请参见下面示例中的 `prev_yearWeek`。 + +第一个参数也可以作为 [`String`](../data-types/string.md) 以 [`parseDateTime64BestEffort()`](type-conversion-functions.md#parsedatetime64besteffort) 支持的格式指定。字符串参数的支持仅因兼容某些第三方工具的 MySQL 而存在。由于字符串参数支持未来可能依赖于新的 MySQL 兼容设置,并且字符串解析通常较慢,因此不推荐使用。 + **语法** ```sql -fromUTCTimestamp(time_val, time_zone) +toYearWeek(datetime[, mode[, timezone]]) ``` **参数** -- `time_val` — DateTime/DateTime64 类型的常量值或表达式。[DateTime/DateTime64 类型](../data-types/datetime.md) -- `time_zone` — 字符串类型的常量值或表示时区的表达式。[字符串类型](../data-types/string.md) +- `datetime` — 要获取年份和周数的日期或带时间的日期。 [`Date`](/sql-reference/data-types/date) 或 [`DateTime`](/sql-reference/data-types/datetime) +- `mode` — 可选。模式 `0` 到 `9` 决定每周的第一天和周数范围。默认 `0`。 - `timezone` — 可选。时区。 [`String`](/sql-reference/data-types/string) + **返回值** -- 文本形式的 DateTime/DateTime64 +以组合整数值返回年份和周数。 [`UInt32`](/sql-reference/data-types/int-uint) **示例** -```sql -SELECT fromUTCTimestamp(toDateTime64('2023-03-16 10:00:00', 3), 'Asia/Shanghai'); -``` - -结果: +**获取具有不同模式的年-周组合** -```text -┌─fromUTCTimestamp(toDateTime64('2023-03-16 10:00:00',3), 'Asia/Shanghai')─┐ -│ 2023-03-16 18:00:00.000 │ -└─────────────────────────────────────────────────────────────────────────┘ +```sql title=Query +SELECT toDate('2016-12-27') AS date, toYearWeek(date) AS yearWeek0, toYearWeek(date,1) AS yearWeek1, toYearWeek(date,9) AS yearWeek9, toYearWeek(toDate('2022-01-01')) AS prev_yearWeek ``` -## UTCTimestamp {#utctimestamp} +```response title=Response +┌───────date─┬─yearWeek0─┬─yearWeek1─┬─yearWeek9─┬─prev_yearWeek─┐ +│ 2016-12-27 │ 201652 │ 201652 │ 201701 │ 202152 │ +└────────────┴───────────┴───────────┴───────────┴───────────────┘ +``` +## today {#today} -返回查询分析时的当前日期和时间。该函数是常量表达式。 +引入于:v1.1 -:::note -此函数提供的结果与 `now('UTC')` 相同。它仅为了支持 MySQL 而添加,而 [`now`](#now) 是首选用法。 -::: +返回查询分析时的当前日期。与 `toDate(now())` 相同。 **语法** ```sql -UTCTimestamp() +today() ``` -别名:`UTC_timestamp`。 +**参数** +- 无。 **返回值** -- 返回查询分析时的当前日期和时间。[DateTime](../data-types/datetime.md)。 +返回当前日期 [`Date`](/sql-reference/data-types/date) **示例** -查询: +**用法示例** -```sql -SELECT UTCTimestamp(); +```sql title=Query +SELECT today() AS today, curdate() AS curdate, current_date() AS current_date FORMAT Pretty ``` -结果: - -```response -┌──────UTCTimestamp()─┐ -│ 2024-05-28 08:32:09 │ -└─────────────────────┘ +```response title=Response +┏━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━┓ +┃ today ┃ curdate ┃ current_date ┃ +┡━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━┩ +│ 2025-03-03 │ 2025-03-03 │ 2025-03-03 │ +└────────────┴────────────┴──────────────┘ ``` +## yesterday {#yesterday} -## timeDiff {#timediff} +引入于:v1.1 -返回两个日期或日期时间值之间的差值。差值以秒为单位计算。它与 `dateDiff` 相同,仅用于支持 MySQL。`dateDiff` 更受欢迎。 +接受零个参数,并返回查询分析时的昨天日期。 + **语法** ```sql -timeDiff(first_datetime, second_datetime) +yesterday() ``` **参数** -- `first_datetime` — DateTime/DateTime64 类型的常量值或表达式。[DateTime/DateTime64 类型](../data-types/datetime.md) -- `second_datetime` — DateTime/DateTime64 类型的常量值或表达式。[DateTime/DateTime64 类型](../data-types/datetime.md) - +- 无。 **返回值** -两个日期或日期时间值之间的差值(以秒为单位)。 +返回昨天的日期。 [`Date`](/sql-reference/data-types/date) **示例** -查询: +**获取昨天的日期** -```sql -timeDiff(toDateTime64('1927-01-01 00:00:00', 3), toDate32('1927-01-02')); +```sql title=Query +SELECT yesterday(); +SELECT today() - 1; ``` -**结果**: - -```response -┌─timeDiff(toDateTime64('1927-01-01 00:00:00', 3), toDate32('1927-01-02'))─┐ -│ 86400 │ -└──────────────────────────────────────────────────────────────────────────┘ +```response title=Response +┌─yesterday()─┐ +│ 2025-06-09 │ +└─────────────┘ +┌─minus(today(), 1)─┐ +│ 2025-06-09 │ +└───────────────────┘ ``` -## 相关内容 {#related-content} - -- 博客:[在 ClickHouse 中处理时间序列数据](https://clickhouse.com/blog/working-with-time-series-data-and-functions-ClickHouse) - - - - diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/date-time-functions.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/date-time-functions.md.hash index 4a796f5abfd..207d120fbf2 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/date-time-functions.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/date-time-functions.md.hash @@ -1 +1 @@ -4bbc700e81631413 +f1df28379e98c3af diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/distance-functions.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/distance-functions.md index 55b2eb761c1..7080104ebf8 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/distance-functions.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/distance-functions.md @@ -1,309 +1,390 @@ --- -'description': 'Distance Functions 的文档' +'description': '距离函数的文档' 'sidebar_label': 'Distance' -'sidebar_position': 55 'slug': '/sql-reference/functions/distance-functions' 'title': '距离函数' +'keywords': +- 'distance functions' +- 'norms' +- 'distances' +- 'vectors' +'doc_type': 'reference' --- # 距离函数 -## L1Norm {#l1norm} + + + +## L1Distance {#L1Distance} + +引入于: v21.11 -计算向量绝对值的总和。 + +计算两个点之间的距离(向量的元素为坐标)在 `L1` 空间中 (1-范数 ([出租车几何](https://en.wikipedia.org/wiki/Taxicab_geometry) 距离)). + **语法** ```sql -L1Norm(vector) +L1Distance(vector1, vector2) ``` -别名: `normL1`。 - **参数** -- `vector` — [元组](../data-types/tuple.md) 或 [数组](../data-types/array.md)。 +- `vector1` — 第一个向量. [`Tuple(T)`](/sql-reference/data-types/tuple) 或 [`Array(T)`](/sql-reference/data-types/array) +- `vector2` — 第二个向量. [`Tuple(T)`](/sql-reference/data-types/tuple) 或 [`Array(T)`](/sql-reference/data-types/array) + **返回值** -- L1范数或 [出租车几何](https://en.wikipedia.org/wiki/Taxicab_geometry) 距离。 [UInt](../data-types/int-uint.md), [Float](../data-types/float.md) 或 [Decimal](../data-types/decimal.md)。 +返回 1-范数距离. [`UInt32`](/sql-reference/data-types/int-uint) 或 [`Float64`](/sql-reference/data-types/float) **示例** -查询: +**基本用法** + +```sql title=Query +SELECT L1Distance((1, 2), (2, 3)) +``` + +```response title=Response +┌─L1Distance((1, 2), (2, 3))─┐ +│ 2 │ +└────────────────────────────┘ +``` + + + +## L1Norm {#L1Norm} + +引入于: v21.11 + + +计算向量的绝对元素之和. + + +**语法** ```sql -SELECT L1Norm((1, 2)); +L1Norm(vector) ``` -结果: +**参数** + +- `vector` — 向量或数字值的元组. [`Array(T)`](/sql-reference/data-types/array) 或 [`Tuple(T)`](/sql-reference/data-types/tuple) + + +**返回值** + +返回 L1范数或 [出租车几何](https://en.wikipedia.org/wiki/Taxicab_geometry)距离. [`UInt*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal`](/sql-reference/data-types/decimal) + +**示例** + +**基本用法** -```text +```sql title=Query +SELECT L1Norm((1, 2)) +``` + +```response title=Response ┌─L1Norm((1, 2))─┐ │ 3 │ └────────────────┘ ``` -## L2Norm {#l2norm} -计算向量值的平方和的平方根。 + +## L1Normalize {#L1Normalize} + +引入于: v21.11 + + +计算给定向量的单位向量(元组的元素为坐标)在 `L1` 空间中 ([出租车几何](https://en.wikipedia.org/wiki/Taxicab_geometry)). + **语法** ```sql -L2Norm(vector) +L1Normalize(tuple) ``` -别名: `normL2`。 - **参数** -- `vector` — [元组](../data-types/tuple.md) 或 [数组](../data-types/array.md)。 +- `tuple` — 一个数字值的元组. [`Tuple(T)`](/sql-reference/data-types/tuple) + **返回值** -- L2范数或 [欧几里得距离](https://en.wikipedia.org/wiki/Euclidean_distance)。 [Float](../data-types/float.md)。 +返回单位向量. [`Tuple(Float64)`](/sql-reference/data-types/tuple) **示例** -查询: +**基本用法** -```sql -SELECT L2Norm((1, 2)); +```sql title=Query +SELECT L1Normalize((1, 2)) ``` -结果: - -```text -┌───L2Norm((1, 2))─┐ -│ 2.23606797749979 │ -└──────────────────┘ +```response title=Response +┌─L1Normalize((1, 2))─────────────────────┐ +│ (0.3333333333333333,0.6666666666666666) │ +└─────────────────────────────────────────┘ ``` -## L2SquaredNorm {#l2squarednorm} -计算向量值的平方和的平方根([L2Norm](#l2norm) 的平方)。 + +## L2Distance {#L2Distance} + +引入于: v21.11 + + +计算两个点之间的距离(向量的元素为坐标)在欧几里得空间中 ([欧几里得距离](https://en.wikipedia.org/wiki/Euclidean_distance)). + **语法** ```sql -L2SquaredNorm(vector) +L2Distance(vector1, vector2) ``` -别名: `normL2Squared`。 - **参数** -- `vector` — [元组](../data-types/tuple.md) 或 [数组](../data-types/array.md)。 +- `vector1` — 第一个向量. [`Tuple(T)`](/sql-reference/data-types/tuple) 或 [`Array(T)`](/sql-reference/data-types/array) +- `vector2` — 第二个向量. [`Tuple(T)`](/sql-reference/data-types/tuple) 或 [`Array(T)`](/sql-reference/data-types/array) + **返回值** -- L2范数的平方。 [Float](../data-types/float.md)。 +返回 2-范数距离. [`Float64`](/sql-reference/data-types/float) **示例** -查询: +**基本用法** -```sql -SELECT L2SquaredNorm((1, 2)); +```sql title=Query +SELECT L2Distance((1, 2), (2, 3)) ``` -结果: - -```text -┌─L2SquaredNorm((1, 2))─┐ -│ 5 │ -└───────────────────────┘ +```response title=Response +┌─L2Distance((1, 2), (2, 3))─┐ +│ 1.4142135623730951 │ +└────────────────────────────┘ ``` -## LinfNorm {#linfnorm} -计算向量绝对值的最大值。 + +## L2DistanceTransposed {#L2DistanceTransposed} + +引入于: v25.10 + + +计算两个点之间的近似距离(向量的值为坐标)在欧几里得空间中 ([欧几里得距离](https://en.wikipedia.org/wiki/Euclidean_distance)). **语法** ```sql -LinfNorm(vector) +L2DistanceTransposed(vector1, vector2, p) ``` -别名: `normLinf`。 - **参数** -- `vector` — [元组](../data-types/tuple.md) 或 [数组](../data-types/array.md)。 +- `vectors` — 向量. [`QBit(T, UInt64)`](/sql-reference/data-types/qbit) +- `reference` — 参考向量. [`Array(T)`](/sql-reference/data-types/array) +- `p` — 从每个向量元素中使用的位数用于距离计算 (1到元素位宽). 量化级别控制精度与速度的权衡. 使用较少位数会导致更快的输入/输出和计算,但精度降低,而使用更多位数会提高精度,但性能下降. [`UInt`](/sql-reference/data-types/int-uint) + **返回值** -- Linf范数或最大绝对值。 [Float](../data-types/float.md)。 +返回近似的 2-范数距离. [`Float`](/sql-reference/data-types/float) **示例** -查询: +**基本用法** -```sql -SELECT LinfNorm((1, -2)); +```sql title=Query +CREATE TABLE qbit (id UInt32, vec QBit(Float64, 2)) ENGINE = Memory; +INSERT INTO qbit VALUES (1, [0, 1]); +SELECT L2DistanceTransposed(vec, array(1.0, 2.0), 16) FROM qbit;" ``` -结果: - -```text -┌─LinfNorm((1, -2))─┐ -│ 2 │ -└───────────────────┘ +```response title=Response +┌─L2DistanceTransposed([0, 1], [1.0, 2.0], 16)─┐ +│ 1.4142135623730951 │ +└──────────────────────────────────────────────┘ ``` -## LpNorm {#lpnorm} -计算向量绝对值的 `p` 次方和的平方根。 + +## L2Norm {#L2Norm} + +引入于: v21.11 + + +计算向量元素平方和的平方根. + **语法** ```sql -LpNorm(vector, p) +L2Norm(vector) ``` -别名: `normLp`。 - **参数** -- `vector` — [元组](../data-types/tuple.md) 或 [数组](../data-types/array.md)。 -- `p` — 指数。可能的值: [1; inf) 范围内的实数。 [UInt](../data-types/int-uint.md) 或 [Float](../data-types/float.md)。 +- `vector` — 向量或数字值的元组. [`Tuple(T)`](/sql-reference/data-types/tuple) 或 [`Array(T)`](/sql-reference/data-types/array) + **返回值** -- [Lp范数](https://en.wikipedia.org/wiki/Norm_(mathematics)#p-norm)。 [Float](../data-types/float.md)。 +返回 L2范数或 [欧几里得距离](https://en.wikipedia.org/wiki/Euclidean_distance). [`UInt*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) **示例** -查询: +**基本用法** -```sql -SELECT LpNorm((1, -2), 2); +```sql title=Query +SELECT L2Norm((1, 2)) ``` -结果: - -```text -┌─LpNorm((1, -2), 2)─┐ -│ 2.23606797749979 │ -└────────────────────┘ +```response title=Response +┌───L2Norm((1, 2))─┐ +│ 2.23606797749979 │ +└──────────────────┘ ``` -## L1Distance {#l1distance} -计算两点之间的距离(向量的值是坐标)在 `L1` 空间中(1范数 ([出租车几何](https://en.wikipedia.org/wiki/Taxicab_geometry) 距离))。 + +## L2Normalize {#L2Normalize} + +引入于: v21.11 + + +计算给定向量的单位向量(元组的元素为坐标)在欧几里得空间中 (使用 [欧几里得距离](https://en.wikipedia.org/wiki/Euclidean_distance)). + **语法** ```sql -L1Distance(vector1, vector2) +L2Normalize(tuple) ``` -别名: `distanceL1`。 - **参数** -- `vector1` — 第一个向量。 [元组](../data-types/tuple.md) 或 [数组](../data-types/array.md)。 -- `vector2` — 第二个向量。 [元组](../data-types/tuple.md) 或 [数组](../data-types/array.md)。 +- `tuple` — 一个数字值的元组. [`Tuple(T)`](/sql-reference/data-types/tuple) + **返回值** -- 1范数距离。 [Float](../data-types/float.md)。 +返回单位向量. [`Tuple(Float64)`](/sql-reference/data-types/tuple) **示例** -查询: +**基本用法** -```sql -SELECT L1Distance((1, 2), (2, 3)); +```sql title=Query +SELECT L2Normalize((3, 4)) ``` -结果: - -```text -┌─L1Distance((1, 2), (2, 3))─┐ -│ 2 │ -└────────────────────────────┘ +```response title=Response +┌─L2Normalize((3, 4))─┐ +│ (0.6,0.8) │ +└─────────────────────┘ ``` -## L2Distance {#l2distance} -计算两点之间的距离(向量的值是坐标)在欧几里得空间中([欧几里得距离](https://en.wikipedia.org/wiki/Euclidean_distance))。 + +## L2SquaredDistance {#L2SquaredDistance} + +引入于: v22.7 + + +计算两个向量对应元素差的平方和. + **语法** ```sql -L2Distance(vector1, vector2) +L2SquaredDistance(vector1, vector2) ``` -别名: `distanceL2`。 - **参数** -- `vector1` — 第一个向量。 [元组](../data-types/tuple.md) 或 [数组](../data-types/array.md)。 -- `vector2` — 第二个向量。 [元组](../data-types/tuple.md) 或 [数组](../data-types/array.md)。 +- `vector1` — 第一个向量. [`Tuple(T)`](/sql-reference/data-types/tuple) 或 [`Array(T)`](/sql-reference/data-types/array) +- `vector2` — 第二个向量. [`Tuple(T)`](/sql-reference/data-types/tuple) 或 [`Array(T)`](/sql-reference/data-types/array) + **返回值** -- 2范数距离。 [Float](../data-types/float.md)。 +返回两个向量对应元素差的平方和. [`Float64`](/sql-reference/data-types/float) **示例** -查询: +**基本用法** -```sql -SELECT L2Distance((1, 2), (2, 3)); +```sql title=Query +SELECT L2SquaredDistance([1, 2, 3], [0, 0, 0]) ``` -结果: - -```text -┌─L2Distance((1, 2), (2, 3))─┐ -│ 1.4142135623730951 │ -└────────────────────────────┘ +```response title=Response +┌─L2SquaredDis⋯ [0, 0, 0])─┐ +│ 14 │ +└──────────────────────────┘ ``` -## L2SquaredDistance {#l2squareddistance} -计算两个向量对应元素之间差值的平方和。 + +## L2SquaredNorm {#L2SquaredNorm} + +引入于: v22.7 + + +计算向量元素的平方和的平方根 (即 [`L2Norm`](#L2Norm) 的平方). + **语法** ```sql -L2SquaredDistance(vector1, vector2) +L2SquaredNorm(vector) ``` -别名: `distanceL2Squared`。 - **参数** -- `vector1` — 第一个向量。 [元组](../data-types/tuple.md) 或 [数组](../data-types/array.md)。 -- `vector2` — 第二个向量。 [元组](../data-types/tuple.md) 或 [数组](../data-types/array.md)。 +- `vector` — 向量或数字值的元组. [`Array(T)`](/sql-reference/data-types/array) 或 [`Tuple(T)`](/sql-reference/data-types/tuple) + **返回值** -- 两个向量对应元素之间差值的平方和。 [Float](../data-types/float.md)。 +返回 L2范数的平方. [`UInt*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal`](/sql-reference/data-types/decimal) **示例** -查询: +**基本用法** -```sql -SELECT L2SquaredDistance([1, 2, 3], [0, 0, 0]) +```sql title=Query +SELECT L2SquaredNorm((1, 2)) ``` -结果: - -```response -┌─L2SquaredDistance([1, 2, 3], [0, 0, 0])─┐ -│ 14 │ -└─────────────────────────────────────────┘ +```response title=Response +┌─L2SquaredNorm((1, 2))─┐ +│ 5 │ +└───────────────────────┘ ``` -## LinfDistance {#linfdistance} -计算两点之间的距离(向量的值是坐标)在 `L_{inf}` 空间中([最大范数](https://en.wikipedia.org/wiki/Norm_(mathematics)#Maximum_norm_(special_case_of:_infinity_norm,_uniform_norm,_or_supremum_norm) ))。 + +## LinfDistance {#LinfDistance} + +引入于: v21.11 + + +计算两个点之间的距离(向量的元素为坐标)在 `L_{inf}` 空间中 ([最大范数](https://en.wikipedia.org/wiki/Norm_(mathematics)#Maximum_norm_(special_case_of:_infinity_norm,_uniform_norm,_or_supremum_norm))). + **语法** @@ -311,182 +392,203 @@ SELECT L2SquaredDistance([1, 2, 3], [0, 0, 0]) LinfDistance(vector1, vector2) ``` -别名: `distanceLinf`。 - **参数** -- `vector1` — 第一个向量。 [元组](../data-types/tuple.md) 或 [数组](../data-types/array.md)。 -- `vector1` — 第二个向量。 [元组](../data-types/tuple.md) 或 [数组](../data-types/array.md)。 +- `vector1` — 第一个向量. [`Tuple(T)`](/sql-reference/data-types/tuple) 或 [`Array(T)`](/sql-reference/data-types/array) +- `vector2` — 第二个向量. [`Tuple(T)`](/sql-reference/data-types/tuple) 或 [`Array(T)`](/sql-reference/data-types/array) + **返回值** -- 无穷范数距离。 [Float](../data-types/float.md)。 +返回无穷大范数距离. [`Float64`](/sql-reference/data-types/float) **示例** -查询: +**基本用法** -```sql -SELECT LinfDistance((1, 2), (2, 3)); +```sql title=Query +SELECT LinfDistance((1, 2), (2, 3)) ``` -结果: - -```text +```response title=Response ┌─LinfDistance((1, 2), (2, 3))─┐ │ 1 │ └──────────────────────────────┘ ``` -## LpDistance {#lpdistance} -计算两点之间的距离(向量的值是坐标)在 `Lp` 空间中([p-范数距离](https://en.wikipedia.org/wiki/Norm_(mathematics)#p-norm))。 + +## LinfNorm {#LinfNorm} + +引入于: v21.11 + + +计算向量的绝对元素的最大值. + **语法** ```sql -LpDistance(vector1, vector2, p) +LinfNorm(vector) ``` -别名: `distanceLp`。 - **参数** -- `vector1` — 第一个向量。 [元组](../data-types/tuple.md) 或 [数组](../data-types/array.md)。 -- `vector2` — 第二个向量。 [元组](../data-types/tuple.md) 或 [数组](../data-types/array.md)。 -- `p` — 指数。可能的值: [1; inf) 范围内的任意数字。 [UInt](../data-types/int-uint.md) 或 [Float](../data-types/float.md)。 +- `vector` — 向量或数字值的元组. [`Array(T)`](/sql-reference/data-types/array) 或 [`Tuple(T)`](/sql-reference/data-types/tuple) + **返回值** -- p-范数距离。 [Float](../data-types/float.md)。 +返回 Linf范数或绝对值的最大值. [`Float64`](/sql-reference/data-types/float) **示例** -查询: +**基本用法** -```sql -SELECT LpDistance((1, 2), (2, 3), 3); +```sql title=Query +SELECT LinfNorm((1, -2)) ``` -结果: - -```text -┌─LpDistance((1, 2), (2, 3), 3)─┐ -│ 1.2599210498948732 │ -└───────────────────────────────┘ +```response title=Response +┌─LinfNorm((1, -2))─┐ +│ 2 │ +└───────────────────┘ ``` -## L1Normalize {#l1normalize} -计算给定向量的单位向量(元组的值是坐标)在 `L1` 空间中([出租车几何](https://en.wikipedia.org/wiki/Taxicab_geometry))。 + +## LinfNormalize {#LinfNormalize} + +引入于: v21.11 + + +计算给定向量的单位向量(元组的元素为坐标)在 `L_{inf}` 空间中 (使用 [最大范数](https://en.wikipedia.org/wiki/Norm_(mathematics)#Maximum_norm_(special_case_of:_infinity_norm,_uniform_norm,_or_supremum_norm))). + **语法** ```sql -L1Normalize(tuple) +LinfNormalize(tuple) ``` -别名: `normalizeL1`。 - **参数** -- `tuple` — [元组](../data-types/tuple.md)。 +- `tuple` — 一个数字值的元组. [`Tuple(T)`](/sql-reference/data-types/tuple) + **返回值** -- 单位向量。 [元组](../data-types/tuple.md) 的 [Float](../data-types/float.md)。 +返回单位向量. [`Tuple(Float64)`](/sql-reference/data-types/tuple) **示例** -查询: +**基本用法** -```sql -SELECT L1Normalize((1, 2)); +```sql title=Query +SELECT LinfNormalize((3, 4)) ``` -结果: - -```text -┌─L1Normalize((1, 2))─────────────────────┐ -│ (0.3333333333333333,0.6666666666666666) │ -└─────────────────────────────────────────┘ +```response title=Response +┌─LinfNormalize((3, 4))─┐ +│ (0.75,1) │ +└───────────────────────┘ ``` -## L2Normalize {#l2normalize} -计算给定向量的单位向量(元组的值是坐标)在欧几里得空间中(使用[欧几里得距离](https://en.wikipedia.org/wiki/Euclidean_distance))。 + +## LpDistance {#LpDistance} + +引入于: v21.11 + + +计算两个点之间的距离(向量的元素为坐标)在 `Lp` 空间中 ([p-范数距离](https://en.wikipedia.org/wiki/Norm_(mathematics)#p-norm)). + **语法** ```sql -L2Normalize(tuple) +LpDistance(vector1, vector2, p) ``` -别名: `normalizeL1`。 - **参数** -- `tuple` — [元组](../data-types/tuple.md)。 +- `vector1` — 第一个向量. [`Tuple(T)`](/sql-reference/data-types/tuple) 或 [`Array(T)`](/sql-reference/data-types/array) +- `vector2` — 第二个向量. [`Tuple(T)`](/sql-reference/data-types/tuple) 或 [`Array(T)`](/sql-reference/data-types/array) +- `p` — 幂. 可能的值: 实数从 `[1; inf)`. [`UInt*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) + **返回值** -- 单位向量。 [元组](../data-types/tuple.md) 的 [Float](../data-types/float.md)。 +返回 p-范数距离. [`Float64`](/sql-reference/data-types/float) **示例** -查询: +**基本用法** -```sql -SELECT L2Normalize((3, 4)); +```sql title=Query +SELECT LpDistance((1, 2), (2, 3), 3) ``` -结果: - -```text -┌─L2Normalize((3, 4))─┐ -│ (0.6,0.8) │ -└─────────────────────┘ +```response title=Response +┌─LpDistance((1, 2), (2, 3), 3)─┐ +│ 1.2599210498948732 │ +└───────────────────────────────┘ ``` -## LinfNormalize {#linfnormalize} -计算给定向量的单位向量(元组的值是坐标)在 `L_{inf}` 空间中(使用 [最大范数](https://en.wikipedia.org/wiki/Norm_(mathematics)#Maximum_norm_(special_case_of:_infinity_norm,_uniform_norm,_or_supremum_norm) ))。 + +## LpNorm {#LpNorm} + +引入于: v21.11 + + +计算向量的 p-范数,即绝对元素的 p 次方和的 p 次根. + +特殊情况: +- 当 p=1 时,相当于 L1Norm (曼哈顿距离). +- 当 p=2 时,相当于 L2Norm (欧几里得距离). +- 当 p=∞ 时,相当于 LinfNorm (最大范数). + **语法** ```sql -LinfNormalize(tuple) +LpNorm(vector, p) ``` -别名: `normalizeLinf `。 - **参数** -- `tuple` — [元组](../data-types/tuple.md)。 +- `vector` — 向量或数字值的元组. [`Tuple(T)`](/sql-reference/data-types/tuple) 或 [`Array(T)`](/sql-reference/data-types/array) +- `p` — 幂. 可能的值为范围在 `[1; inf)` 之内的实数. [`UInt*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) + **返回值** -- 单位向量。 [元组](../data-types/tuple.md) 的 [Float](../data-types/float.md)。 +返回 [Lp-norm](https://en.wikipedia.org/wiki/Norm_(mathematics)#p-norm). [`Float64`](/sql-reference/data-types/float) **示例** -查询: +**基本用法** -```sql -SELECT LinfNormalize((3, 4)); +```sql title=Query +SELECT LpNorm((1, -2), 2) ``` -结果: - -```text -┌─LinfNormalize((3, 4))─┐ -│ (0.75,1) │ -└───────────────────────┘ +```response title=Response +┌─LpNorm((1, -2), 2)─┐ +│ 2.23606797749979 │ +└────────────────────┘ ``` -## LpNormalize {#lpnormalize} -计算给定向量的单位向量(元组的值是坐标)在 `Lp` 空间中(使用 [p-范数](https://en.wikipedia.org/wiki/Norm_(mathematics)#p-norm))。 + +## LpNormalize {#LpNormalize} + +引入于: v21.11 + + +计算给定向量的单位向量(元组的元素为坐标)在 `Lp` 空间中 (使用 [p-范数](https://en.wikipedia.org/wiki/Norm_(mathematics)#p-norm)). + **语法** @@ -494,36 +596,39 @@ SELECT LinfNormalize((3, 4)); LpNormalize(tuple, p) ``` -别名: `normalizeLp `。 - **参数** -- `tuple` — [元组](../data-types/tuple.md)。 -- `p` — 指数。可能的值: [1; inf) 范围内的任意数字。 [UInt](../data-types/int-uint.md) 或 [Float](../data-types/float.md)。 +- `tuple` — 一个数字值的元组. [`Tuple(T)`](/sql-reference/data-types/tuple) +- `p` — 幂. 可能的值为在范围从 `[1; inf)` 之内的任何数. [`UInt*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) + **返回值** -- 单位向量。 [元组](../data-types/tuple.md) 的 [Float](../data-types/float.md)。 +返回单位向量. [`Tuple(Float64)`](/sql-reference/data-types/tuple) **示例** -查询: +**基本用法** -```sql -SELECT LpNormalize((3, 4),5); +```sql title=Query +SELECT LpNormalize((3, 4), 5) ``` -结果: - -```text +```response title=Response ┌─LpNormalize((3, 4), 5)──────────────────┐ │ (0.7187302630182624,0.9583070173576831) │ └─────────────────────────────────────────┘ ``` -## cosineDistance {#cosinedistance} -计算两个向量之间的余弦距离(元组的值是坐标)。返回值越小,向量越相似。 + +## cosineDistance {#cosineDistance} + +引入于: v1.1 + + +计算两个向量之间的余弦距离(元组的元素为坐标)。返回值越小,向量越相似. + **语法** @@ -533,34 +638,28 @@ cosineDistance(vector1, vector2) **参数** -- `vector1` — 第一个元组。 [元组](../data-types/tuple.md) 或 [数组](../data-types/array.md)。 -- `vector2` — 第二个元组。 [元组](../data-types/tuple.md) 或 [数组](../data-types/array.md)。 +- `vector1` — 第一个元组. [`Tuple(T)`](/sql-reference/data-types/tuple) 或 [`Array(T)`](/sql-reference/data-types/array) +- `vector2` — 第二个元组. [`Tuple(T)`](/sql-reference/data-types/tuple) 或 [`Array(T)`](/sql-reference/data-types/array) + **返回值** -- 两个向量之间角度的余弦减去一。 [Float](../data-types/float.md)。 +返回两个向量之间的角度的余弦值减去1. [`Float64`](/sql-reference/data-types/float) **示例** -查询: +**基本用法** -```sql +```sql title=Query SELECT cosineDistance((1, 2), (2, 3)); ``` -结果: - -```text +```response title=Response ┌─cosineDistance((1, 2), (2, 3))─┐ │ 0.007722123286332261 │ └────────────────────────────────┘ ``` - - + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/distance-functions.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/distance-functions.md.hash index d342da3b9c0..f22344ca597 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/distance-functions.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/distance-functions.md.hash @@ -1 +1 @@ -be86d0eca822a649 +7fc828794bf523e8 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/ym-dict-functions.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/embedded-dict-functions.md similarity index 76% rename from i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/ym-dict-functions.md rename to i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/embedded-dict-functions.md index 27276b6acd3..de8167cf91a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/ym-dict-functions.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/embedded-dict-functions.md @@ -1,27 +1,27 @@ --- -'description': '处理嵌入式字典的函数的文档' -'sidebar_label': '嵌入式字典' -'sidebar_position': 60 +'description': '嵌入字典的函数文档' +'sidebar_label': 'Embedded dictionary' 'slug': '/sql-reference/functions/ym-dict-functions' -'title': '处理嵌入式字典的函数' +'title': '处理嵌入字典的函数' +'doc_type': 'reference' --- # 使用嵌入式字典的函数 :::note -为了使下面的函数能够工作,服务器配置必须指定获取所有嵌入式字典的路径和地址。这些字典在第一次调用这些函数时加载。如果无法加载参考列表,则会抛出异常。 +为了使下面的函数正常工作,服务器配置必须指定获取所有嵌入式字典的路径和地址。字典在首次调用这些函数时加载。如果无法加载参考列表,则会抛出异常。 -因此,本节中所示的示例在[ClickHouse Fiddle](https://fiddle.clickhouse.com/)和快速发布与生产部署中默认会抛出异常,除非首先进行配置。 +因此,本节中显示的示例在默认情况下将在 [ClickHouse Fiddle](https://fiddle.clickhouse.com/) 和快速发布及生产部署中抛出异常,除非首先进行配置。 ::: 有关创建参考列表的信息,请参见["字典"](../dictionaries#embedded-dictionaries)部分。 ## 多个地理基础 {#multiple-geobases} -ClickHouse支持同时使用多个替代地理基础(地区层级),以支持对某些地区所属国家的不同视角。 +ClickHouse 支持同时处理多个替代地理基础(区域层级),以支持对于某些地区属于哪些国家的各种视角。 -'clickhouse-server'配置指定了包含地区层级的文件: +'clickhouse-server' 配置指定区域层次的文件: ```/opt/geo/regions_hierarchy.txt``` @@ -42,7 +42,7 @@ regionToCountry(RegionID, 'ua') – Uses the dictionary for the 'ua' key: /opt/g ### regionToName {#regiontoname} -接受地区ID和地理基础,并返回对应语言中的地区名称字符串。如果指定ID的地区不存在,则返回空字符串。 +接受一个区域 ID 和地理基础,并返回对应语言的区域名称字符串。如果指定 ID 的区域不存在,则返回空字符串。 **语法** @@ -51,12 +51,12 @@ regionToName(id\[, lang\]) ``` **参数** -- `id` — 来自地理基础的地区ID。 [UInt32](../data-types/int-uint). -- `geobase` — 字典键。请参见[多个地理基础](#multiple-geobases)。 [String](../data-types/string). 可选。 +- `id` — 来自地理基础的区域 ID。 [UInt32](../data-types/int-uint). +- `geobase` — 字典键。见 [多个地理基础](#multiple-geobases)。 [String](../data-types/string). 可选。 **返回值** -- 对应于`geobase`指定语言的地区名称。 [String](../data-types/string). +- 对应于 `geobase` 指定语言的区域名称。 [String](../data-types/string). - 否则,返回空字符串。 **示例** @@ -81,7 +81,7 @@ SELECT regionToName(number::UInt32,'en') FROM numbers(0,5); ### regionToCity {#regiontocity} -接受来自地理基础的地区ID。如果该地区是城市或城市的一部分,则返回适当城市的地区ID。否则,返回0。 +接受来自地理基础的区域 ID。如果该区域是城市或城市的一部分,则返回适当城市的区域 ID。否则,返回 0。 **语法** @@ -91,13 +91,13 @@ regionToCity(id [, geobase]) **参数** -- `id` — 来自地理基础的地区ID。 [UInt32](../data-types/int-uint). -- `geobase` — 字典键。请参见[多个地理基础](#multiple-geobases)。 [String](../data-types/string). 可选。 +- `id` — 来自地理基础的区域 ID。 [UInt32](../data-types/int-uint). +- `geobase` — 字典键。见 [多个地理基础](#multiple-geobases)。 [String](../data-types/string). 可选。 **返回值** -- 如果存在,返回适当城市的地区ID。 [UInt32](../data-types/int-uint). -- 如果不存在,返回0。 +- 如果存在,则返回适当城市的区域 ID。 [UInt32](../data-types/int-uint). +- 如果不存在,返回 0。 **示例** @@ -129,7 +129,7 @@ SELECT regionToName(number::UInt32, 'en'), regionToCity(number::UInt32) AS id, r ### regionToArea {#regiontoarea} -将地区转换为区域(在地理基础中为类型5)。在其他方面,此函数与['regionToCity'](#regiontocity)相同。 +将区域转换为区域(地理基础中的类型 5)。在其他方面,此函数与 ['regionToCity'](#regiontocity) 相同。 **语法** @@ -139,13 +139,13 @@ regionToArea(id [, geobase]) **参数** -- `id` — 来自地理基础的地区ID。 [UInt32](../data-types/int-uint). -- `geobase` — 字典键。请参见[多个地理基础](#multiple-geobases)。 [String](../data-types/string). 可选。 +- `id` — 来自地理基础的区域 ID。 [UInt32](../data-types/int-uint). +- `geobase` — 字典键。见 [多个地理基础](#multiple-geobases)。 [String](../data-types/string). 可选。 **返回值** -- 如果存在,返回适当区域的地区ID。 [UInt32](../data-types/int-uint). -- 如果不存在,返回0。 +- 如果存在,则返回适当区域的区域 ID。 [UInt32](../data-types/int-uint). +- 如果不存在,返回 0。 **示例** @@ -181,7 +181,7 @@ LIMIT 15 ### regionToDistrict {#regiontodistrict} -将地区转换为联邦区(在地理基础中为类型4)。在其他方面,此函数与'regionToCity'相同。 +将区域转换为联邦区(地理基础中的类型 4)。在其他方面,此函数与 'regionToCity' 相同。 **语法** @@ -191,13 +191,13 @@ regionToDistrict(id [, geobase]) **参数** -- `id` — 来自地理基础的地区ID。 [UInt32](../data-types/int-uint). -- `geobase` — 字典键。请参见[多个地理基础](#multiple-geobases)。 [String](../data-types/string). 可选。 +- `id` — 来自地理基础的区域 ID。 [UInt32](../data-types/int-uint). +- `geobase` — 字典键。见 [多个地理基础](#multiple-geobases)。 [String](../data-types/string). 可选。 **返回值** -- 如果存在,返回适当城市的地区ID。 [UInt32](../data-types/int-uint). -- 如果不存在,返回0。 +- 如果存在,则返回适当城市的区域 ID。 [UInt32](../data-types/int-uint). +- 如果不存在,返回 0。 **示例** @@ -233,7 +233,7 @@ LIMIT 15 ### regionToCountry {#regiontocountry} -将地区转换为国家(在地理基础中为类型3)。在其他方面,此函数与'regionToCity'相同。 +将区域转换为国家(地理基础中的类型 3)。在其他方面,此函数与 'regionToCity' 相同。 **语法** @@ -243,13 +243,13 @@ regionToCountry(id [, geobase]) **参数** -- `id` — 来自地理基础的地区ID。 [UInt32](../data-types/int-uint). -- `geobase` — 字典键。请参见[多个地理基础](#multiple-geobases)。 [String](../data-types/string). 可选。 +- `id` — 来自地理基础的区域 ID。 [UInt32](../data-types/int-uint). +- `geobase` — 字典键。见 [多个地理基础](#multiple-geobases)。 [String](../data-types/string). 可选。 **返回值** -- 如果存在,返回适当国家的地区ID。 [UInt32](../data-types/int-uint). -- 如果不存在,返回0。 +- 如果存在,则返回适当国家的区域 ID。 [UInt32](../data-types/int-uint). +- 如果不存在,返回 0。 **示例** @@ -281,7 +281,7 @@ SELECT regionToName(number::UInt32, 'en'), regionToCountry(number::UInt32) AS id ### regionToContinent {#regiontocontinent} -将地区转换为大陆(在地理基础中为类型1)。在其他方面,此函数与'regionToCity'相同。 +将区域转换为大陆(地理基础中的类型 1)。在其他方面,此函数与 'regionToCity' 相同。 **语法** @@ -291,13 +291,13 @@ regionToContinent(id [, geobase]) **参数** -- `id` — 来自地理基础的地区ID。 [UInt32](../data-types/int-uint). -- `geobase` — 字典键。请参见[多个地理基础](#multiple-geobases)。 [String](../data-types/string). 可选。 +- `id` — 来自地理基础的区域 ID。 [UInt32](../data-types/int-uint). +- `geobase` — 字典键。见 [多个地理基础](#multiple-geobases)。 [String](../data-types/string). 可选。 **返回值** -- 如果存在,返回适当大陆的地区ID。 [UInt32](../data-types/int-uint). -- 如果不存在,返回0。 +- 如果存在,则返回适当大陆的区域 ID。 [UInt32](../data-types/int-uint). +- 如果不存在,返回 0。 **示例** @@ -329,7 +329,7 @@ SELECT regionToName(number::UInt32, 'en'), regionToContinent(number::UInt32) AS ### regionToTopContinent {#regiontotopcontinent} -查找该地区层级中的最高洲。 +查找区域层次中最高的大陆。 **语法** @@ -339,13 +339,13 @@ regionToTopContinent(id[, geobase]) **参数** -- `id` — 来自地理基础的地区ID。 [UInt32](../data-types/int-uint). -- `geobase` — 字典键。请参见[多个地理基础](#multiple-geobases)。 [String](../data-types/string). 可选。 +- `id` — 来自地理基础的区域 ID。 [UInt32](../data-types/int-uint). +- `geobase` — 字典键。见 [多个地理基础](#multiple-geobases)。 [String](../data-types/string). 可选。 **返回值** -- 顶级大陆的标识符(当你向上爬升地区层级时)。 [UInt32](../data-types/int-uint). -- 如果不存在,返回0。 +- 顶级大陆的标识符(即当您沿着区域层次上升时的最后一个)。 [UInt32](../data-types/int-uint). +- 如果不存在,返回 0。 **示例** @@ -377,7 +377,7 @@ SELECT regionToName(number::UInt32, 'en'), regionToTopContinent(number::UInt32) ### regionToPopulation {#regiontopopulation} -获取地区的人口。人口可以在地理基础的文件中记录。请参见["字典"](../dictionaries#embedded-dictionaries)部分。如果未记录该地区的人口,则返回0。在地理基础中,人口可能记录在子地区,但不记录在父区域。 +获取区域的人口。人口可以在地理基础的文件中记录。有关更多信息,请参见["字典"](../dictionaries#embedded-dictionaries)部分。如果该区域没有记录人口,则返回 0。在地理基础中,人口可能记录在子区域中,但不记录在父区域中。 **语法** @@ -387,13 +387,13 @@ regionToPopulation(id[, geobase]) **参数** -- `id` — 来自地理基础的地区ID。 [UInt32](../data-types/int-uint). -- `geobase` — 字典键。请参见[多个地理基础](#multiple-geobases)。 [String](../data-types/string). 可选。 +- `id` — 来自地理基础的区域 ID。 [UInt32](../data-types/int-uint). +- `geobase` — 字典键。见 [多个地理基础](#multiple-geobases)。 [String](../data-types/string). 可选。 **返回值** -- 该地区的人口。 [UInt32](../data-types/int-uint). -- 如果不存在,返回0。 +- 该区域的人口。 [UInt32](../data-types/int-uint). +- 如果不存在,返回 0。 **示例** @@ -425,7 +425,7 @@ SELECT regionToName(number::UInt32, 'en'), regionToPopulation(number::UInt32) AS ### regionIn {#regionin} -检查`lhs`地区是否属于`rhs`地区。如果属于,则返回等于1的UInt8数字;如果不属于,则返回0。 +检查一个 `lhs` 区域是否属于一个 `rhs` 区域。如果属于,则返回等于 1 的 UInt8 数字;如果不属于,则返回 0。 **语法** @@ -435,18 +435,18 @@ regionIn(lhs, rhs\[, geobase\]) **参数** -- `lhs` — 来自地理基础的lhs地区ID。 [UInt32](../data-types/int-uint). -- `rhs` — 来自地理基础的rhs地区ID。 [UInt32](../data-types/int-uint). -- `geobase` — 字典键。请参见[多个地理基础](#multiple-geobases)。 [String](../data-types/string). 可选。 +- `lhs` — 来自地理基础的左侧区域 ID。 [UInt32](../data-types/int-uint). +- `rhs` — 来自地理基础的右侧区域 ID。 [UInt32](../data-types/int-uint). +- `geobase` — 字典键。见 [多个地理基础](#multiple-geobases)。 [String](../data-types/string). 可选。 **返回值** -- 如果属于,则返回1。 [UInt8](../data-types/int-uint). -- 如果不属于,则返回0。 +- 如果属于,则返回 1。 [UInt8](../data-types/int-uint). +- 如果不属于,则返回 0。 **实现细节** -该关系是自反的——任何地区也属于其自身。 +这种关系是自反的——任何区域也属于它自己。 **示例** @@ -473,7 +473,7 @@ USA is not in Boulder ### regionHierarchy {#regionhierarchy} -接受一个UInt32数字——来自地理基础的地区ID。返回一个包含传入地区及沿链条所有父地区的地区ID数组。 +接受一个 UInt32 数字——来自地理基础的区域 ID。返回一个由传递区域及沿链的所有父级组成的区域 ID 数组。 **语法** @@ -483,12 +483,12 @@ regionHierarchy(id\[, geobase\]) **参数** -- `id` — 来自地理基础的地区ID。 [UInt32](../data-types/int-uint). -- `geobase` — 字典键。请参见[多个地理基础](#multiple-geobases)。 [String](../data-types/string). 可选。 +- `id` — 来自地理基础的区域 ID。 [UInt32](../data-types/int-uint). +- `geobase` — 字典键。见 [多个地理基础](#multiple-geobases)。 [String](../data-types/string). 可选。 **返回值** -- 包含传入地区及沿链条所有父地区的地区ID数组。 [Array](../data-types/array)([UInt32](../data-types/int-uint)). +- 由传递区域及沿链的所有父级组成的区域 ID 数组。 [Array](../data-types/array)([UInt32](../data-types/int-uint)). **示例** @@ -511,8 +511,9 @@ SELECT regionHierarchy(number::UInt32) AS arr, arrayMap(id -> regionToName(id, ' ``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/embedded-dict-functions.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/embedded-dict-functions.md.hash new file mode 100644 index 00000000000..d663f6264dd --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/embedded-dict-functions.md.hash @@ -0,0 +1 @@ +3ae0989cd0977069 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/encoding-functions.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/encoding-functions.md index 6476024f854..8af3aa4d2da 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/encoding-functions.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/encoding-functions.md @@ -1,1096 +1,1152 @@ --- -'description': '文档关于 Encoding Functions' +'description': '编码函数的文档' 'sidebar_label': 'Encoding' -'sidebar_position': 65 'slug': '/sql-reference/functions/encoding-functions' 'title': '编码函数' +'keywords': +- 'encoding' +- 'regular functions' +- 'encode' +- 'decode' +'doc_type': 'reference' --- # 编码函数 -## char {#char} + + + +## bech32Decode {#bech32Decode} + +引入于:v25.6 + + +解码由 bech32 或 bech32m 算法生成的 Bech32 地址字符串。 -返回长度与传入参数数量相同且每个字节值等于对应参数的字符串。接受多个数值类型参数。如果参数值超出 UInt8 数据类型的范围,则会转换为 UInt8,可能会发生四舍五入和溢出。 +:::note +与 encode 函数不同,`Bech32Decode` 将自动处理填充的 FixedStrings。 +::: + **语法** ```sql -char(number_1, [number_2, ..., number_n]); +bech32Decode(address) ``` **参数** -- `number_1, number_2, ..., number_n` — 作为整数解释的数值参数。类型: [Int](../data-types/int-uint.md), [Float](../data-types/float.md)。 +- `address` — 要解码的 Bech32 字符串。 [`String`](/sql-reference/data-types/string) 或 [`FixedString`](/sql-reference/data-types/fixedstring) + **返回值** -- 给定字节的字符串。 [String](../data-types/string.md)。 +返回一个元组,包含用来编码字符串的 `(hrp, data)`。数据为二进制格式。 [`Tuple(String, String)`](/sql-reference/data-types/tuple) **示例** -查询: +**解码地址** -```sql -SELECT char(104.1, 101, 108.9, 108.9, 111) AS hello; +```sql title=Query +SELECT tup.1 AS hrp, hex(tup.2) AS data FROM (SELECT bech32Decode('bc1w508d6qejxtdg4y5r3zarvary0c5xw7kj7gz7z') AS tup) ``` -结果: - -```text -┌─hello─┐ -│ hello │ -└───────┘ +```response title=Response +bc 751E76E8199196D454941C45D1B3A323F1433BD6 ``` -您可以通过传递相应的字节构造任意编码的字符串。以下是 UTF-8 的示例: +**测试网地址** -查询: - -```sql -SELECT char(0xD0, 0xBF, 0xD1, 0x80, 0xD0, 0xB8, 0xD0, 0xB2, 0xD0, 0xB5, 0xD1, 0x82) AS hello; +```sql title=Query +SELECT tup.1 AS hrp, hex(tup.2) AS data FROM (SELECT bech32Decode('tb1w508d6qejxtdg4y5r3zarvary0c5xw7kzp034v') AS tup) ``` -结果: - -```text -┌─hello──┐ -│ привет │ -└────────┘ +```response title=Response +tb 751E76E8199196D454941C45D1B3A323F1433BD6 ``` -查询: -```sql -SELECT char(0xE4, 0xBD, 0xA0, 0xE5, 0xA5, 0xBD) AS hello; -``` -结果: +## bech32Encode {#bech32Encode} -```text -┌─hello─┐ -│ 你好 │ -└───────┘ -``` +引入于:v25.6 -## hex {#hex} -返回一个包含参数的十六进制表示的字符串。 +使用 [Bech32 或 Bech32m](https://en.bitcoin.it/wiki/Bech32) 算法对二进制数据字符串及人类可读部分 (HRP) 进行编码。 -别名: `HEX`。 +:::note +使用 [`FixedString`](../data-types/fixedstring.md) 数据类型时,如果某个值没有完全填满行,则用空字符填充。 +虽然 `bech32Encode` 函数会自动处理 hrp 参数,但对于 data 参数,值不得填充。 +因此,除非您确定所有数据值的长度相同并确保 `FixedString` 列设置为该长度,否则不建议使用 [`FixedString`](../data-types/fixedstring.md) 数据类型。 +::: + **语法** ```sql -hex(arg) +bech32Encode(hrp, data[, witver]) ``` -该函数使用大写字母 `A-F`,并且不使用任何前缀(如 `0x`)或后缀(如 `h`)。 - -对于整数参数,它从最重要到最不重要(大端或“人类可读”顺序)打印十六进制数字(“半字节”)。它从最重要的非零字节开始(省略前导零字节),但总是打印每个字节的两个数字,即使前导数字为零。 - -[Date](../data-types/date.md) 和 [DateTime](../data-types/datetime.md) 类型的值被格式化为相应的整数(自 Epoch 起的天数对于 Date,Unix 时间戳的值对于 DateTime)。 - -对于 [String](../data-types/string.md) 和 [FixedString](../data-types/fixedstring.md),所有字节都简单地编码为两个十六进制数字。零字节不会被省略。 - -[Float](../data-types/float.md) 和 [Decimal](../data-types/decimal.md) 类型的值被编码为它们在内存中的表示。由于我们支持小端架构,因此它们以小端编码。前导/尾随零字节不会被省略。 - -[UUID](../data-types/uuid.md) 类型的值被编码为大端顺序字符串。 - **参数** -- `arg` — 要转换为十六进制的值。类型: [String](../data-types/string.md), [UInt](../data-types/int-uint.md), [Float](../data-types/float.md), [Decimal](../data-types/decimal.md), [Date](../data-types/date.md) 或 [DateTime](../data-types/datetime.md)。 +- `hrp` — 一个 `1 - 83` 个小写字符组成的字符串,指定代码的人类可读部分。通常为 'bc' 或 'tb'。 [`String`](/sql-reference/data-types/string) 或 [`FixedString`](/sql-reference/data-types/fixedstring) +- `data` — 要编码的二进制数据字符串。 [`String`](/sql-reference/data-types/string) 或 [`FixedString`](/sql-reference/data-types/fixedstring) +- `witver` — 可选。见证版本 (默认 = 1)。一个 `UInt*`,指定要运行的算法版本。`0` 表示 Bech32,`1` 或更大则表示 Bech32m。 [`UInt*`](/sql-reference/data-types/int-uint) + **返回值** -- 一个字符串,包含参数的十六进制表示。 [String](../data-types/string.md)。 +返回一个 Bech32 地址字符串,包含人类可读部分、一个总是为 '1' 的分隔符字符,以及一个数据部分。字符串的长度不会超过 90 个字符。如果算法无法从输入生成有效地址,将返回一个空字符串。 [`String`](/sql-reference/data-types/string) **示例** -查询: +**默认 Bech32m** -```sql -SELECT hex(1); +```sql title=Query +-- When no witness version is supplied, the default is 1, the updated Bech32m algorithm. +SELECT bech32Encode('bc', unhex('751e76e8199196d454941c45d1b3a323f1433bd6')) ``` -结果: - -```text -01 +```response title=Response +bc1w508d6qejxtdg4y5r3zarvary0c5xw7k8zcwmq ``` -查询: +**Bech32 算法** -```sql -SELECT hex(toFloat32(number)) AS hex_presentation FROM numbers(15, 2); +```sql title=Query +-- A witness version of 0 will result in a different address string. +SELECT bech32Encode('bc', unhex('751e76e8199196d454941c45d1b3a323f1433bd6'), 0) ``` -结果: - -```text -┌─hex_presentation─┐ -│ 00007041 │ -│ 00008041 │ -└──────────────────┘ -``` - -查询: - -```sql -SELECT hex(toFloat64(number)) AS hex_presentation FROM numbers(15, 2); +```response title=Response +bc1w508d6qejxtdg4y5r3zarvary0c5xw7kj7gz7z ``` -结果: +**自定义 HRP** -```text -┌─hex_presentation─┐ -│ 0000000000002E40 │ -│ 0000000000003040 │ -└──────────────────┘ +```sql title=Query +-- While 'bc' (Mainnet) and 'tb' (Testnet) are the only allowed hrp values for the +-- SegWit address format, Bech32 allows any hrp that satisfies the above requirements. +SELECT bech32Encode('abcdefg', unhex('751e76e8199196d454941c45d1b3a323f1433bd6'), 10) ``` -查询: - -```sql -SELECT lower(hex(toUUID('61f0c404-5cb3-11e7-907b-a6006ad3dba0'))) as uuid_hex +```response title=Response +abcdefg1w508d6qejxtdg4y5r3zarvary0c5xw7k9rp8r4 ``` -结果: - -```text -┌─uuid_hex─────────────────────────┐ -│ 61f0c4045cb311e7907ba6006ad3dba0 │ -└──────────────────────────────────┘ -``` -## unhex {#unhex} +## bin {#bin} -执行 [hex](#hex) 的反操作。它将每对十六进制数字(在参数中)解释为一个数字,并将其转换为由该数字表示的字节。返回值是一个二进制字符串(BLOB)。 +引入于:v21.8 -如果您想将结果转换为一个数字,可以使用 [reverse](../../sql-reference/functions/string-functions.md#reverse) 和 [reinterpretAs<Type>](/sql-reference/functions/type-conversion-functions) 函数。 -:::note -如果在 `clickhouse-client` 中调用 `unhex`,二进制字符串将使用 UTF-8 显示。 -::: +返回一个包含参数的二进制表示的字符串,根据以下不同类型的逻辑: -别名: `UNHEX`。 +| 类型 | 描述 | +|----------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `(U)Int*` | 从最重要位到最不重要位打印二进制位(大端或“人类可读”顺序)。从最重要的非零字节开始(省略前导零字节)但始终打印每个字节的八位数字,即使前导数字为零。| +| `Date` 和 `DateTime` | 格式化为相应的整数(Date 的自纪元以来的天数,以及 DateTime 的 Unix 时间戳值)。 | +| `String` 和 `FixedString` | 所有字节简单地编码为八个二进制数字。零字节不会被省略。 | +| `Float*` 和 `Decimal` | 编码为它们在内存中的表示。由于我们支持小端架构,因此它们以小端方式编码。前导/结尾的零字节不被省略。 | +| `UUID` | 编码为大端顺序字符串。 | + **语法** ```sql -unhex(arg) +bin(arg) ``` **参数** -- `arg` — 包含任意数量十六进制数字的字符串。 [String](../data-types/string.md), [FixedString](../data-types/fixedstring.md)。 +- `arg` — 要转换为二进制的值。 [`String`](/sql-reference/data-types/string) 或 [`FixedString`](/sql-reference/data-types/fixedstring) 或 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal`](/sql-reference/data-types/decimal) 或 [`Date`](/sql-reference/data-types/date) 或 [`DateTime`](/sql-reference/data-types/datetime) -支持大写和小写字母 `A-F`。十六进制数字的数量不必是偶数。如果是奇数,则最后一个数字被解释为 `00-0F` 字节的最低有效半部分。如果参数字符串包含任何非十六进制数字,则返回某些实现定义的结果(不会抛出异常)。对于数值参数,unhex() 不会执行 hex(N) 的逆操作。 **返回值** -- 一个二进制字符串(BLOB)。 [String](../data-types/string.md)。 +返回参数的二进制表示字符串。 [`String`](/sql-reference/data-types/string) **示例** -查询: -```sql -SELECT unhex('303132'), UNHEX('4D7953514C'); +**简单整数** + +```sql title=Query +SELECT bin(14) ``` -结果: -```text -┌─unhex('303132')─┬─unhex('4D7953514C')─┐ -│ 012 │ MySQL │ -└─────────────────┴─────────────────────┘ +```response title=Response +┌─bin(14)──┐ +│ 00001110 │ +└──────────┘ ``` -查询: +**Float32 数字** -```sql -SELECT reinterpretAsUInt64(reverse(unhex('FFF'))) AS num; +```sql title=Query +SELECT bin(toFloat32(number)) AS bin_presentation FROM numbers(15, 2) ``` -结果: +```response title=Response +┌─bin_presentation─────────────────┐ +│ 00000000000000000111000001000001 │ +│ 00000000000000001000000001000001 │ +└──────────────────────────────────┘ +``` -```text -┌──num─┐ -│ 4095 │ -└──────┘ +**Float64 数字** + +```sql title=Query +SELECT bin(toFloat64(number)) AS bin_presentation FROM numbers(15, 2) ``` -## bin {#bin} +```response title=Response +┌─bin_presentation─────────────────────────────────────────────────┐ +│ 0000000000000000000000000000000000000000000000000010111001000000 │ +│ 0000000000000000000000000000000000000000000000000011000001000000 │ +└──────────────────────────────────────────────────────────────────┘ +``` -返回一个包含参数的二进制表示的字符串。 +**UUID 转换** -**语法** +```sql title=Query +SELECT bin(toUUID('61f0c404-5cb3-11e7-907b-a6006ad3dba0')) AS bin_uuid +``` -```sql -bin(arg) +```response title=Response +┌─bin_uuid─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ +│ 01100001111100001100010000000100010111001011001100010001111001111001000001111011101001100000000001101010110100111101101110100000 │ +└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ ``` -别名: `BIN`。 -对于整数参数,它从最重要到最不重要(大端或“人类可读”顺序)打印二进制数字。它从最重要的非零字节开始(省略前导零字节),但总是打印每个字节的八个数字,即使前导数字为零。 -[Date](../data-types/date.md) 和 [DateTime](../data-types/datetime.md) 类型的值被格式化为相应的整数(自 `Date` 起的天数和 `DateTime` 的 Unix 时间戳值)。 +## bitPositionsToArray {#bitPositionsToArray} -对于 [String](../data-types/string.md) 和 [FixedString](../data-types/fixedstring.md),所有字节都简单地编码为八个二进制数字。零字节不会被省略。 +引入于:v21.7 -[Float](../data-types/float.md) 和 [Decimal](../data-types/decimal.md) 类型的值被编码为它们在内存中的表示。由于我们支持小端架构,因此它们以小端编码。前导/尾随零字节不会被省略。 -[UUID](../data-types/uuid.md) 类型的值被编码为大端顺序字符串。 +该函数返回无符号整数的二进制表示中 1 位的位置(按升序排列)。 +有符号输入整数首先被转换为无符号整数。 + + +**语法** + +```sql +bitPositionsToArray(arg) +``` **参数** -- `arg` — 要转换为二进制的值。 [String](../data-types/string.md), [FixedString](../data-types/fixedstring.md), [UInt](../data-types/int-uint.md), [Float](../data-types/float.md), [Decimal](../data-types/decimal.md), [Date](../data-types/date.md), 或 [DateTime](../data-types/datetime.md)。 +- `arg` — 一个整数值。 [`(U)Int*`](/sql-reference/data-types/int-uint) + **返回值** -- 一个字符串,包含参数的二进制表示。 [String](../data-types/string.md)。 +返回一个包含输入的 1 位在其二进制表示中过升序排列的位置的数组。 [`Array(UInt64)`](/sql-reference/data-types/array) **示例** -查询: +**单个位被设置** -```sql -SELECT bin(14); +```sql title=Query +SELECT bitPositionsToArray(toInt8(1)) AS bit_positions ``` -结果: - -```text -┌─bin(14)──┐ -│ 00001110 │ -└──────────┘ +```response title=Response +┌─bit_positions─┐ +│ [0] │ +└───────────────┘ ``` -查询: +**所有位被设置** -```sql -SELECT bin(toFloat32(number)) AS bin_presentation FROM numbers(15, 2); +```sql title=Query +SELECT bitPositionsToArray(toInt8(-1)) AS bit_positions ``` -结果: - -```text -┌─bin_presentation─────────────────┐ -│ 00000000000000000111000001000001 │ -│ 00000000000000001000000001000001 │ -└──────────────────────────────────┘ +```response title=Response +┌─bit_positions─────────────┐ +│ [0, 1, 2, 3, 4, 5, 6, 7] │ +└───────────────────────────┘ ``` -查询: -```sql -SELECT bin(toFloat64(number)) AS bin_presentation FROM numbers(15, 2); -``` -结果: +## bitmaskToArray {#bitmaskToArray} + +引入于:v1.1 -```text -┌─bin_presentation─────────────────────────────────────────────────┐ -│ 0000000000000000000000000000000000000000000000000010111001000000 │ -│ 0000000000000000000000000000000000000000000000000011000001000000 │ -└──────────────────────────────────────────────────────────────────┘ -``` -查询: +该函数将整数分解为 2 的幂之和。 +以升序排列的幂将作为数组返回。 + + +**语法** ```sql -SELECT bin(toUUID('61f0c404-5cb3-11e7-907b-a6006ad3dba0')) as bin_uuid +bitmaskToArray(num) ``` -结果: +**参数** -```text -┌─bin_uuid─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ -│ 01100001111100001100010000000100010111001011001100010001111001111001000001111011101001100000000001101010110100111101101110100000 │ -└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ -``` +- `num` — 一个整数值。 [`(U)Int*`](/sql-reference/data-types/int-uint) -## unbin {#unbin} +**返回值** -解释参数中的每对二进制数字作为一个数字,并将其转换为由该数字表示的字节。该函数执行 [bin](#bin) 的反操作。 +返回一个包含组成输入数字的升序排列的幂的数组。 [`Array(UInt64)`](/sql-reference/data-types/array) -**语法** +**示例** -```sql -unbin(arg) +**基本示例** + +```sql title=Query +SELECT bitmaskToArray(50) AS powers_of_two ``` -别名: `UNBIN`。 +```response title=Response +┌─powers_of_two───┐ +│ [2, 16, 32] │ +└─────────────────┘ +``` -对于数值参数 `unbin()` 不会返回 `bin()` 的逆。如果您想将结果转换为一个数字,可以使用 [reverse](../../sql-reference/functions/string-functions.md#reverse) 和 [reinterpretAs<Type>](/sql-reference/functions/type-conversion-functions#reinterpret) 函数。 +**单个 2 的幂** -:::note -如果在 `clickhouse-client` 中调用 `unbin`,二进制字符串将使用 UTF-8 显示。 -::: +```sql title=Query +SELECT bitmaskToArray(8) AS powers_of_two +``` -支持二进制数字 `0` 和 `1`。二进制数字的数量不必是八的倍数。如果参数字符串包含任何非二进制数字,则返回某些实现定义的结果(不会抛出异常)。 +```response title=Response +┌─powers_of_two─┐ +│ [8] │ +└───────────────┘ +``` -**参数** -- `arg` — 包含任意数量二进制数字的字符串。 [String](../data-types/string.md)。 -**返回值** +## bitmaskToList {#bitmaskToList} -- 一个二进制字符串(BLOB)。 [String](../data-types/string.md)。 +引入于:v1.1 -**示例** -查询: +与 bitmaskToArray 类似,但将 2 的幂作为逗号分隔的字符串返回。 + + +**语法** ```sql -SELECT UNBIN('001100000011000100110010'), UNBIN('0100110101111001010100110101000101001100'); +bitmaskToList(num) ``` -结果: +**参数** -```text -┌─unbin('001100000011000100110010')─┬─unbin('0100110101111001010100110101000101001100')─┐ -│ 012 │ MySQL │ -└───────────────────────────────────┴───────────────────────────────────────────────────┘ -``` +- `num` — 一个整数值。 [`(U)Int*`](/sql-reference/data-types/int-uint) -查询: -```sql -SELECT reinterpretAsUInt64(reverse(unbin('1110'))) AS num; -``` +**返回值** -结果: +返回一个包含逗号分隔的幂的字符串。 [`String`](/sql-reference/data-types/string) -```text -┌─num─┐ -│ 14 │ -└─────┘ +**示例** + +**基本示例** + +```sql title=Query +SELECT bitmaskToList(50) AS powers_list +``` + +```response title=Response +┌─powers_list───┐ +│ 2, 16, 32 │ +└───────────────┘ ``` -## bitmaskToList(num) {#bitmasktolistnum} -接受一个整数。返回一个字符串,包含当求和时总计源数字的二的幂,以文本格式逗号分隔且没有空格,按升序排列。 -## bitmaskToArray(num) {#bitmasktoarraynum} +## char {#char} + +引入于:v20.1 -接受一个整数。返回一个包含二的幂的 UInt64 数字数组,这些幂加总后为源数字。数组中的数字按升序排列。 -## bitPositionsToArray(num) {#bitpositionstoarraynum} +返回一个长度等于传递的参数个数的字符串,其中每个字节的值等于相应参数的值。接受多种数值类型的多个参数。 -接受一个整数并将其转换为无符号整数。返回一个包含 `arg` 中等于 `1` 的位位置列表的 `UInt64` 数字数组,按升序排列。 +如果参数的值超出 `UInt8` 数据类型的范围,则可能会有舍入和溢出,转换为 `UInt8`。 + **语法** ```sql -bitPositionsToArray(arg) +char(num1[, num2[, ...]]) ``` **参数** -- `arg` — 整数值。 [Int/UInt](../data-types/int-uint.md)。 +- `num1[, num2[, num3 ...]]` — 被解释为整数的数值参数。 [`(U)Int8/16/32/64`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) + **返回值** -- 一个包含符合条件的位位置列表的数组,按升序排列。 [Array](../data-types/array.md)([UInt64](../data-types/int-uint.md))。 +返回给定字节的字符串。 [`String`](/sql-reference/data-types/string) **示例** -查询: +**基本示例** -```sql -SELECT bitPositionsToArray(toInt8(1)) AS bit_positions; +```sql title=Query +SELECT char(104.1, 101, 108.9, 108.9, 111) AS hello; ``` -结果: - -```text -┌─bit_positions─┐ -│ [0] │ -└───────────────┘ +```response title=Response +┌─hello─┐ +│ hello │ +└───────┘ ``` -查询: +**构建任意编码** -```sql -SELECT bitPositionsToArray(toInt8(-1)) AS bit_positions; +```sql title=Query +-- You can construct a string of arbitrary encoding by passing the corresponding bytes. +-- for example UTF8 +SELECT char(0xD0, 0xBF, 0xD1, 0x80, 0xD0, 0xB8, 0xD0, 0xB2, 0xD0, 0xB5, 0xD1, 0x82) AS hello; ``` -结果: - -```text -┌─bit_positions─────┐ -│ [0,1,2,3,4,5,6,7] │ -└───────────────────┘ +```response title=Response +┌─hello──┐ +│ привет │ +└────────┘ ``` -## mortonEncode {#mortonencode} -计算无符号整数列表的 Morton 编码(ZCurve)。 -该函数有两种操作模式: -- 简单 -- 扩展 +## hex {#hex} -### 简单模式 {#simple-mode} +引入于:v1.1 -接受最多 8 个无符号整数作为参数,并生成一个 UInt64 代码。 + +返回一个字符串,其中包含参数的十六进制表示,按照以下不同类型的逻辑: + +| 类型 | 描述 | +|----------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `(U)Int*` | 从最重要到最不重要位打印十六进制数字(“半字节”)(大端或“人类可读”顺序)。从最重要的非零字节开始(省略前导零字节)但始终打印每个字节的两个数字,即使前导数字是零。 | +| `Date` 和 `DateTime` | 格式化为相应的整数(Date 的自纪元以来的天数,以及 DateTime 的 Unix 时间戳值)。 | +| `String` 和 `FixedString` | 所有字节简单编码为两个十六进制数字。零字节不会被省略。 | +| `Float*` 和 `Decimal` | 编码为它们在内存中的表示。ClickHouse 内部始终以小端方式表示这些值,因此以此方式编码。前导/后缀的零字节不会被省略。 | +| `UUID` | 编码为大端顺序字符串。 | + +该函数使用大写字母 `A-F`,并且不使用前缀(如 `0x`)或后缀(如 `h`)。 + **语法** ```sql -mortonEncode(args) +hex(arg) ``` **参数** -- `args`: 最多 8 个 [无符号整数](../data-types/int-uint.md) 或上述类型的列。 +- `arg` — 要转换为十六进制的值。 [`String`](/sql-reference/data-types/string) 或 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal`](/sql-reference/data-types/decimal) 或 [`Date`](/sql-reference/data-types/date) 或 [`DateTime`](/sql-reference/data-types/datetime) + **返回值** -- 一个 UInt64 代码。 [UInt64](../data-types/int-uint.md) +返回参数的十六进制表示字符串。 [`String`](/sql-reference/data-types/string) **示例** -查询: +**简单整数** -```sql -SELECT mortonEncode(1, 2, 3); +```sql title=Query +SELECT hex(1) ``` -结果: -```response -53 +```response title=Response +01 ``` -### 扩展模式 {#expanded-mode} +**Float32 数字** -接受一个范围掩码([tuple](../data-types/tuple.md))作为第一个参数,以及最多 8 个 [无符号整数](../data-types/int-uint.md) 作为其他参数。 +```sql title=Query +SELECT hex(toFloat32(number)) AS hex_presentation FROM numbers(15, 2) +``` -掩码中的每个数字配置范围扩展的量: -
1 - 无扩展
-2 - 2x 扩展
-3 - 3x 扩展
-...
-最大扩展 8x。
+```response title=Response +┌─hex_presentation─┐ +│ 00007041 │ +│ 00008041 │ +└──────────────────┘ +``` -**语法** +**Float64 数字** -```sql -mortonEncode(range_mask, args) +```sql title=Query +SELECT hex(toFloat64(number)) AS hex_presentation FROM numbers(15, 2) ``` -**参数** -- `range_mask`: 1-8。 -- `args`: 最多 8 个 [无符号整数](../data-types/int-uint.md) 或上述类型的列。 +```response title=Response +┌─hex_presentation─┐ +│ 0000000000002E40 │ +│ 0000000000003040 │ +└──────────────────┘ +``` -注意: 使用列作为 `args` 时,提供的 `range_mask` 元组仍应为常量。 +**UUID 转换** -**返回值** +```sql title=Query +SELECT lower(hex(toUUID('61f0c404-5cb3-11e7-907b-a6006ad3dba0'))) AS uuid_hex +``` -- 一个 UInt64 代码。 [UInt64](../data-types/int-uint.md) +```response title=Response +┌─uuid_hex─────────────────────────┐ +│ 61f0c4045cb311e7907ba6006ad3dba0 │ +└──────────────────────────────────┘ +``` -**示例** -范围扩展在您需要对具有截然不同范围(或基数)的参数进行相似分布时可能会很有帮助。 -例如:'IP 地址' (0...FFFFFFFF) 和 '国家代码' (0...FF)。 -查询: +## hilbertDecode {#hilbertDecode} -```sql -SELECT mortonEncode((1,2), 1024, 16); -``` +引入于:v24.6 -结果: -```response -1572864 -``` +将 Hilbert 曲线索引解码为一个元组的无符号整数,表示多维空间的坐标。 + +与 `hilbertEncode` 函数一样,该函数有两种操作模式: +- **简单** +- **扩展** -注意: 元组大小必须与其他参数的数量相等。 +**简单模式** -**示例** +接受最多 2 个无符号整数作为参数并生成 `UInt64` 代码。 -一个参数的 Morton 编码始终是该参数本身: +**扩展模式** -查询: +将范围掩码(元组)作为第一个参数,最多接受 2 个无符号整数作为其他参数。掩码中的每个数字配置对应参数向左移动的位数,有效地在其范围内缩放参数。 + +范围扩展在需要为具有截然不同范围(或基数)的参数提供相似分布时可能非常有用。例如:“IP 地址” `(0...FFFFFFFF)` 和 “国家代码” `(0...FF)`。与编码函数一样,这个限制为最多 8 个数字。 + + +**语法** ```sql -SELECT mortonEncode(1); +hilbertDecode(tuple_size, code) ``` -结果: +**参数** -```response -1 -``` +- `tuple_size` — 不超过 `2` 的整数值。 [`UInt8/16/32/64`](/sql-reference/data-types/int-uint) 或 [`Tuple(UInt8/16/32/64)`](/sql-reference/data-types/tuple) +- `code` — `UInt64` 代码。 [`UInt64`](/sql-reference/data-types/int-uint) + + +**返回值** + +返回指定大小的元组。 [`Tuple(UInt64)`](/sql-reference/data-types/tuple) **示例** -也可以扩展一个参数: +**简单模式** -查询: +```sql title=Query +SELECT hilbertDecode(2, 31) +``` -```sql -SELECT mortonEncode(tuple(2), 128); +```response title=Response +["3", "4"] ``` -结果: +**单个参数** -```response -32768 +```sql title=Query +-- Hilbert code for one argument is always the argument itself (as a tuple). +SELECT hilbertDecode(1, 1) ``` -**示例** +```response title=Response +["1"] +``` + +**扩展模式** -您还可以在函数中使用列名称。 +```sql title=Query +-- A single argument with a tuple specifying bit shifts will be right-shifted accordingly. +SELECT hilbertDecode(tuple(2), 32768) +``` -首先创建表并插入一些数据。 +```response title=Response +["128"] +``` -```sql -create table morton_numbers( +**列用法** + +```sql title=Query +-- First create the table and insert some data +CREATE TABLE hilbert_numbers( n1 UInt32, - n2 UInt32, - n3 UInt16, - n4 UInt16, - n5 UInt8, - n6 UInt8, - n7 UInt8, - n8 UInt8 + n2 UInt32 ) -Engine=MergeTree() +ENGINE=MergeTree() ORDER BY n1 SETTINGS index_granularity = 8192, index_granularity_bytes = '10Mi'; -insert into morton_numbers (*) values(1,2,3,4,5,6,7,8); -``` -使用列名称而不是常量作为 `mortonEncode` 的函数参数 +insert into hilbert_numbers (*) values(1,2); -查询: +-- Use column names instead of constants as function arguments +SELECT untuple(hilbertDecode(2, hilbertEncode(n1, n2))) FROM hilbert_numbers; +``` -```sql -SELECT mortonEncode(n1, n2, n3, n4, n5, n6, n7, n8) FROM morton_numbers; +```response title=Response +1 2 ``` -结果: -```response -2155374165 -``` -**实现细节** +## hilbertEncode {#hilbertEncode} -请注意,您只能在 Morton 代码中放入 [UInt64](../data-types/int-uint.md) 所能容纳的比特信息。两个参数的范围最大为 2^32 (64/2),三个参数的范围最大为 2^21 (64/3),依此类推。所有溢出将被限制为零。 +引入于:v24.6 -## mortonDecode {#mortondecode} -将 Morton 编码(ZCurve)解码为相应的无符号整数元组。 +为一系列无符号整数计算 Hilbert 曲线代码。 -与 `mortonEncode` 函数一样,该函数有两种操作模式: -- 简单 -- 扩展 +该函数有两种操作模式: +- **简单** +- **扩展** + +**简单模式** -### 简单模式 {#simple-mode-1} +最多接受 2 个无符号整数作为参数并生成 `UInt64` 代码。 -接受一个结果元组大小作为第一个参数,代码作为第二个参数。 +**扩展模式** + +将范围掩码 ([Tuple](../../sql-reference/data-types/tuple.md)) 作为第一个参数,最多接受 2 个 [无符号整数](../../sql-reference/data-types/int-uint.md) 作为其他参数。 + +掩码中的每个数字配置对应参数向左移动的位数,有效地在其范围内缩放参数。 + **语法** ```sql -mortonDecode(tuple_size, code) +-- Simplified mode +hilbertEncode(args) + +-- Expanded mode +hilbertEncode(range_mask, args) ``` **参数** -- `tuple_size`: 不超过 8 的整数值。 -- `code`: [UInt64](../data-types/int-uint.md) 代码。 + +- `args` — 最多两个 `UInt` 值或 `UInt` 类型的列。 [`UInt8/16/32/64`](/sql-reference/data-types/int-uint) +- `range_mask` — 对于扩展模式,最多两个 `UInt` 值或 `UInt` 类型的列。 [`UInt8/16/32/64`](/sql-reference/data-types/int-uint) + **返回值** -- 指定大小的 [tuple](../data-types/tuple.md)。 [UInt64](../data-types/int-uint.md) +返回一个 `UInt64` 代码。 [`UInt64`](/sql-reference/data-types/int-uint) **示例** -查询: +**简单模式** -```sql -SELECT mortonDecode(3, 53); +```sql title=Query +SELECT hilbertEncode(3, 4) ``` -结果: - -```response -["1","2","3"] +```response title=Response +31 ``` -### 扩展模式 {#expanded-mode-1} +**扩展模式** -接受一个范围掩码(元组)作为第一个参数,代码作为第二个参数。 -掩码中的每个数字配置范围缩小的量: -
1 - 无缩小
-2 - 2x 缩小
-3 - 3x 缩小
-...
-最大缩小 8x。
+```sql title=Query +-- Range expansion can be beneficial when you need a similar distribution for +-- arguments with wildly different ranges (or cardinality). +-- For example: 'IP Address' (0...FFFFFFFF) and 'Country code' (0...FF). +-- Note: tuple size must be equal to the number of the other arguments. +SELECT hilbertEncode((10, 6), 1024, 16) +``` -范围扩展在您需要对具有截然不同范围(或基数)的参数进行相似分布时可能会很有帮助。 -例如:'IP 地址' (0...FFFFFFFF) 和 '国家代码' (0...FF)。 -与编码函数一样,最多限于 8 个数字。 +```response title=Response +4031541586602 +``` -**示例** +**单个参数** -查询: +```sql title=Query +-- For a single argument without a tuple, the function returns the argument +-- itself as the Hilbert index, since no dimensional mapping is needed. +SELECT hilbertEncode(1) +``` -```sql -SELECT mortonDecode(1, 1); +```response title=Response +1 ``` -结果: +**扩展单个参数** -```response -["1"] +```sql title=Query +-- If a single argument is provided with a tuple specifying bit shifts, the function +-- shifts the argument left by the specified number of bits. +SELECT hilbertEncode(tuple(2), 128) ``` -**示例** +```response title=Response +512 +``` -也可以缩小一个参数: +**列用法** -查询: +```sql title=Query +-- First create the table and insert some data +CREATE TABLE hilbert_numbers( + n1 UInt32, + n2 UInt32 +) +ENGINE=MergeTree() +ORDER BY n1; +insert into hilbert_numbers (*) values(1, 2); -```sql -SELECT mortonDecode(tuple(2), 32768); +-- Use column names instead of constants as function arguments +SELECT hilbertEncode(n1, n2) FROM hilbert_numbers; ``` -结果: - -```response -["128"] +```response title=Response +13 ``` -**示例** -您还可以在函数中使用列名称。 -首先创建表并插入一些数据。 +## mortonDecode {#mortonDecode} -查询: -```sql -create table morton_numbers( - n1 UInt32, - n2 UInt32, - n3 UInt16, - n4 UInt16, - n5 UInt8, - n6 UInt8, - n7 UInt8, - n8 UInt8 -) -Engine=MergeTree() -ORDER BY n1 SETTINGS index_granularity = 8192, index_granularity_bytes = '10Mi'; -insert into morton_numbers (*) values(1,2,3,4,5,6,7,8); -``` -使用列名称而不是常量作为 `mortonDecode` 的函数参数 +引入于:v24.6 -查询: -```sql -select untuple(mortonDecode(8, mortonEncode(n1, n2, n3, n4, n5, n6, n7, n8))) from morton_numbers; -``` +将摩顿编码 (ZCurve) 解码为对应的无符号整数元组。 -结果: +与 `mortonEncode` 函数一样,该函数有两种操作模式: +- **简单** +- **扩展** -```response -1 2 3 4 5 6 7 8 -``` +**简单模式** -## hilbertEncode {#hilbertencode} +接受结果的元组大小作为第一个参数,代码作为第二个参数。 -计算一组无符号整数的 Hilbert 曲线编码。 +**扩展模式** -该函数有两种操作模式: -- 简单 -- 扩展 +将范围掩码(元组)作为第一个参数,将代码作为第二个参数。 +掩码中的每个数字配置范围缩小的量: -### 简单模式 {#simple-mode-2} +* `1` - 不缩小 +* `2` - 2x 缩小 +* `3` - 3x 缩小 +⋮ +* 最多 8x 缩小。 -简单: 接受最多 2 个无符号整数作为参数,并生成一个 UInt64 代码。 +范围扩展在需要为具有截然不同范围(或基数)的参数提供相似分布时可能非常有用。例如:“IP 地址” `(0...FFFFFFFF)` 和 “国家代码” `(0...FF)`。与编码函数一样,这个限制为最多 8 个数字。 + **语法** ```sql -hilbertEncode(args) +-- Simple mode +mortonDecode(tuple_size, code) + +-- Expanded mode +mortonDecode(range_mask, code) ``` **参数** -- `args`: 最多 2 个 [无符号整数](../../sql-reference/data-types/int-uint.md) 或上述类型的列。 +- `tuple_size` — 不超过 8 的整数值。 [`UInt8/16/32/64`](/sql-reference/data-types/int-uint) +- `range_mask` — 对于扩展模式,每个参数的掩码。掩码是无符号整数的元组。掩码中的每个数字配置范围缩小的量。 [`Tuple(UInt8/16/32/64)`](/sql-reference/data-types/tuple) +- `code` — `UInt64` 代码。 [`UInt64`](/sql-reference/data-types/int-uint) -**返回值** -- 一个 UInt64 代码 +**返回值** -类型: [UInt64](../../sql-reference/data-types/int-uint.md) +返回指定大小的元组。 [`Tuple(UInt64)`](/sql-reference/data-types/tuple) **示例** -查询: +**简单模式** -```sql -SELECT hilbertEncode(3, 4); +```sql title=Query +SELECT mortonDecode(3, 53) ``` -结果: -```response -31 +```response title=Response +["1", "2", "3"] ``` -### 扩展模式 {#expanded-mode-2} +**单个参数** -接受一个范围掩码([tuple](../../sql-reference/data-types/tuple.md))作为第一个参数,以及最多 2 个 [无符号整数](../../sql-reference/data-types/int-uint.md) 作为其他参数。 +```sql title=Query +SELECT mortonDecode(1, 1) +``` -掩码中的每个数字配置对应参数向左移动的位数,从而在其范围内缩放参数。 +```response title=Response +["1"] +``` -**语法** +**扩展模式,缩小一个参数** -```sql -hilbertEncode(range_mask, args) +```sql title=Query +SELECT mortonDecode(tuple(2), 32768) ``` -**参数** -- `range_mask`: ([tuple](../../sql-reference/data-types/tuple.md)) -- `args`: 最多 2 个 [无符号整数](../../sql-reference/data-types/int-uint.md) 或上述类型的列。 +```response title=Response +["128"] +``` -注意: 使用列作为 `args` 时,提供的 `range_mask` 元组仍应为常量。 +**列用法** -**返回值** +```sql title=Query +-- First create the table and insert some data +CREATE TABLE morton_numbers( + n1 UInt32, + n2 UInt32, + n3 UInt16, + n4 UInt16, + n5 UInt8, + n6 UInt8, + n7 UInt8, + n8 UInt8 +) +ENGINE=MergeTree() +ORDER BY n1; +INSERT INTO morton_numbers (*) values(1, 2, 3, 4, 5, 6, 7, 8); -- 一个 UInt64 代码 +-- Use column names instead of constants as function arguments +SELECT untuple(mortonDecode(8, mortonEncode(n1, n2, n3, n4, n5, n6, n7, n8))) FROM morton_numbers; +``` -类型: [UInt64](../../sql-reference/data-types/int-uint.md) +```response title=Response +1 2 3 4 5 6 7 8 +``` -**示例** -范围扩展在您需要对具有截然不同范围(或基数)的参数进行相似分布时可能会很有帮助。 -例如:'IP 地址' (0...FFFFFFFF) 和 '国家代码' (0...FF)。 +## mortonEncode {#mortonEncode} -查询: +引入于:v24.6 -```sql -SELECT hilbertEncode((10,6), 1024, 16); -``` -结果: +为一系列无符号整数计算摩顿编码 (ZCurve)。 -```response -4031541586602 -``` +该函数有两种操作模式: +- **简单** +- **扩展** -注意: 元组大小必须与其他参数的数量相等。 +**简单模式** -**示例** +最多接受 8 个无符号整数作为参数并生成一个 `UInt64` 代码。 -对于没有元组的单一参数,函数返回该参数本身作为 Hilbert 索引,因为不需要维度映射。 +**扩展模式** -查询: +将范围掩码 ([Tuple](../data-types/tuple.md)) 作为第一个参数,最多接受 8 个 [无符号整数](../data-types/int-uint.md) 作为其他参数。 + +掩码中的每个数字配置范围扩展的量: +* 1 - 不扩展 +* 2 - 2x 扩展 +* 3 - 3x 扩展 +⋮ +* 最多 8x 扩展。 + + +**语法** ```sql -SELECT hilbertEncode(1); +-- Simplified mode +mortonEncode(args) + +-- Expanded mode +mortonEncode(range_mask, args) ``` -结果: +**参数** + +- `args` — 最多 8 个无符号整数或上述类型的列。 [`UInt8/16/32/64`](/sql-reference/data-types/int-uint) +- `range_mask` — 对于扩展模式,每个参数的掩码。掩码是介于 `1` - `8` 的无符号整数的元组。掩码中的每个数字配置范围缩小的量。 [`Tuple(UInt8/16/32/64)`](/sql-reference/data-types/tuple) -```response -1 -``` + +**返回值** + +返回一个 `UInt64` 代码。 [`UInt64`](/sql-reference/data-types/int-uint) **示例** -如果提供了一个单一参数,并带有指定位移的元组,则函数会将参数向左移动指定的位数。 +**简单模式** -查询: +```sql title=Query +SELECT mortonEncode(1, 2, 3) +``` -```sql -SELECT hilbertEncode(tuple(2), 128); +```response title=Response +53 ``` -结果: +**扩展模式** -```response -512 +```sql title=Query +-- Range expansion can be beneficial when you need a similar distribution for +-- arguments with wildly different ranges (or cardinality) +-- For example: 'IP Address' (0...FFFFFFFF) and 'Country code' (0...FF). +-- Note: the Tuple size must be equal to the number of the other arguments. +SELECT mortonEncode((1,2), 1024, 16) ``` -**示例** +```response title=Response +1572864 +``` -该函数还接受列作为参数: +**单个参数** -首先创建表并插入一些数据。 +```sql title=Query +-- Morton encoding for one argument is always the argument itself +SELECT mortonEncode(1) +``` -```sql -create table hilbert_numbers( - n1 UInt32, - n2 UInt32 -) -Engine=MergeTree() -ORDER BY n1 SETTINGS index_granularity = 8192, index_granularity_bytes = '10Mi'; -insert into hilbert_numbers (*) values(1,2); +```response title=Response +1 ``` -使用列名称而不是常量作为 `hilbertEncode` 的函数参数 -查询: +**扩展单个参数** -```sql -SELECT hilbertEncode(n1, n2) FROM hilbert_numbers; +```sql title=Query +SELECT mortonEncode(tuple(2), 128) +``` + +```response title=Response +32768 ``` -结果: +**列用法** -```response -13 +```sql title=Query +-- First create the table and insert some data +CREATE TABLE morton_numbers( + n1 UInt32, + n2 UInt32, + n3 UInt16, + n4 UInt16, + n5 UInt8, + n6 UInt8, + n7 UInt8, + n8 UInt8 +) +ENGINE=MergeTree() +ORDER BY n1; +INSERT INTO morton_numbers (*) values(1, 2, 3, 4, 5, 6, 7, 8); + +-- Use column names instead of constants as function arguments +SELECT mortonEncode(n1, n2, n3, n4, n5, n6, n7, n8) FROM morton_numbers; ``` -**实现细节** +```response title=Response +2155374165 +``` -请注意,您只能在 Hilbert 代码中放入 [UInt64](../../sql-reference/data-types/int-uint.md) 所能容纳的比特信息。两个参数的范围最大为 2^32 (64/2)。所有溢出将被限制为零。 -## hilbertDecode {#hilbertdecode} -将 Hilbert 曲线索引解码回无符号整数元组,表示多维空间中的坐标。 +## sqidDecode {#sqidDecode} -与 `hilbertEncode` 函数一样,该函数有两种操作模式: -- 简单 -- 扩展 +引入于:v24.1 -### 简单模式 {#simple-mode-3} -接受最多 2 个无符号整数作为参数,并生成一个 UInt64 代码。 +将 [sqid](https://sqids.org/) 转换回数字数组。 + **语法** ```sql -hilbertDecode(tuple_size, code) +sqidDecode(sqid) ``` **参数** -- `tuple_size`: 不超过 2 的整数值。 -- `code`: [UInt64](../../sql-reference/data-types/int-uint.md) 代码。 -**返回值** +- `sqid` — 要解码的 sqid。 [`String`](/sql-reference/data-types/string) + -- 指定大小的 [tuple](../../sql-reference/data-types/tuple.md)。 +**返回值** -类型: [UInt64](../../sql-reference/data-types/int-uint.md) +返回 `sqid` 中的数字数组。 [`Array(UInt64)`](/sql-reference/data-types/array) **示例** -查询: +**用法示例** -```sql -SELECT hilbertDecode(2, 31); +```sql title=Query +SELECT sqidDecode('gXHfJ1C6dN'); ``` -结果: - -```response -["3", "4"] +```response title=Response +┌─sqidDecode('gXHfJ1C6dN')─────┐ +│ [1, 2, 3, 4, 5] │ +└──────────────────────────────┘ ``` -### 扩展模式 {#expanded-mode-3} -接受一个范围掩码(元组)作为第一个参数,最多 2 个无符号整数作为其他参数。 -掩码中的每个数字配置对应参数向左移动的位数,从而在其范围内缩放参数。 -范围扩展在您需要对具有截然不同范围(或基数)的参数进行相似分布时可能会很有帮助。 -例如:'IP 地址' (0...FFFFFFFF) 和 '国家代码' (0...FF)。 -与编码函数一样,最多限于 8 个数字。 +## sqidEncode {#sqidEncode} + +引入于:v24.1 -**示例** -Hilbert 代码对于一个参数始终为该参数本身(作为元组)。 +将数字转换为 [sqid](https://sqids.org/),类似于 Youtube 的 ID 字符串。 + -查询: +**语法** ```sql -SELECT hilbertDecode(1, 1); +sqidEncode(n1[, n2, ...]) ``` -结果: +**参数** -```response -["1"] -``` +- `n1[, n2, ...]` — 任意多个数字。 [`UInt8/16/32/64`](/sql-reference/data-types/int-uint) -**示例** -单一参数与指定位移的元组将相应右移。 +**返回值** -查询: +返回哈希 ID [`String`](/sql-reference/data-types/string) -```sql -SELECT hilbertDecode(tuple(2), 32768); -``` +**示例** -结果: +**用法示例** -```response -["128"] +```sql title=Query +SELECT sqidEncode(1, 2, 3, 4, 5); ``` -**示例** +```response title=Response +┌─sqidEncode(1, 2, 3, 4, 5)─┐ +│ gXHfJ1C6dN │ +└───────────────────────────┘ +``` -该函数接受代码列作为第二个参数: -首先创建表并插入一些数据。 -查询: -```sql -create table hilbert_numbers( - n1 UInt32, - n2 UInt32 -) -Engine=MergeTree() -ORDER BY n1 SETTINGS index_granularity = 8192, index_granularity_bytes = '10Mi'; -insert into hilbert_numbers (*) values(1,2); -``` -使用列名称而不是常量作为 `hilbertDecode` 的函数参数 +## unbin {#unbin} -查询: +引入于:v21.8 -```sql -select untuple(hilbertDecode(2, hilbertEncode(n1, n2))) from hilbert_numbers; -``` -结果: +将每对二进制数字(在参数中)视为一个数字并转换为由该数字表示的字节。该函数执行 bin 的逆操作。 -```response -1 2 -``` +对于数值参数,`unbin()` 不会返回 `bin()` 的逆。如果您想将结果转换为数字,可以使用 reverse 和 `reinterpretAs` 函数。 -## bech32Encode {#bech32encode} +:::note +如果 `unbin` 是从 `clickhouse-client` 中调用的,二进制字符串将以 UTF-8 显示。 +::: -将二进制数据字符串以及人类可读部分(HRP)编码,使用 [Bech32 或 Bech32m](https://en.bitcoin.it/wiki/Bech32) 算法。 +支持二进制数字 `0` 和 `1`。二进制数字的数量不必是八的倍数。如果参数字符串包含除二进制数字以外的任何内容,结果是未定义的(不会抛出异常)。 + **语法** ```sql -bech32Encode(hrp, data[, witver]) +unbin(arg) ``` **参数** -- `hrp` — 指定代码的“人类可读部分”的 1 - 83 个小写字母字符串。通常是 'bc' 或 'tb'。 [String](../data-types/string.md) 或 [FixedString](../data-types/fixedstring.md)。 -- `data` — 要编码的二进制数据字符串。 [String](../data-types/string.md) 或 [FixedString](../data-types/fixedstring.md)。 -- `witver` - 见证版本。可选,默认 = 1。一个 [UInt*](../data-types/int-uint.md),指定要运行的算法版本。0 表示 Bech32,1 或更高表示 Bech32m。 +- `arg` — 一个包含任意数量二进制数字的字符串。 [`String`](/sql-reference/data-types/string) -:::note -使用 [FixedString](../data-types/fixedstring.md) 数据类型时,如果一个值未完全填充行,它将被填充为 null 字符。 -虽然 `bech32Encode` 函数会自动处理 hrp 参数,但对于数据参数,值不得填充。 -因此,不建议将 [FixedString](../data-types/fixedstring.md) 数据类型用于您的数据值,除非您确定它们都具有相同的长度,并确保您的 [FixedString](../data-types/fixedstring.md) 列也设置为该长度。 -::: **返回值** -- 一个 Bech32 地址字符串,由人类可读部分、分隔符(始终为 '1')和数据部分组成。字符串的长度永远不会超过 90 个字符。如果算法无法从输入生成有效地址,则会返回空字符串。 - -类型: [String](../data-types/string.md)。 +返回一个二进制字符串(BLOB)。 [`String`](/sql-reference/data-types/string) **示例** -当未提供见证版本时,默认为 1,即更新的 Bech32m 算法。 +**基本用法** -查询: - -```sql -SELECT bech32Encode('bc', unhex('751e76e8199196d454941c45d1b3a323f1433bd6')); +```sql title=Query +SELECT UNBIN('001100000011000100110010'), UNBIN('0100110101111001010100110101000101001100') ``` -结果: - -```response -bc1w508d6qejxtdg4y5r3zarvary0c5xw7k8zcwmq +```response title=Response +┌─unbin('001100000011000100110010')─┬─unbin('0100110101111001010100110101000101001100')─┐ +│ 012 │ MySQL │ +└───────────────────────────────────┴───────────────────────────────────────────────────┘ ``` -见证版本为 0 将导致不同的地址字符串。 +**转换为数字** -查询: +```sql title=Query +SELECT reinterpretAsUInt64(reverse(unbin('1110'))) AS num +``` -```sql -SELECT bech32Encode('bc', unhex('751e76e8199196d454941c45d1b3a323f1433bd6'), 0); +```response title=Response +┌─num─┐ +│ 14 │ +└─────┘ ``` -结果: -```response -bc1w508d6qejxtdg4y5r3zarvary0c5xw7kj7gz7z -``` -虽然 'bc'(主网)和 'tb'(测试网)是 SegWit 地址格式中唯一允许的 hrp 值,但 Bech32 允许任何满足上述要求的 hrp。 +## unhex {#unhex} -查询: +引入于:v1.1 -```sql -SELECT bech32Encode('abcdefg', unhex('751e76e8199196d454941c45d1b3a323f1433bd6'), 10); -``` -结果: +执行 [`hex`](#hex) 的相反操作。将每对十六进制数字(在参数中)视为一个数字并转换为由该数字表示的字节。返回值为二进制字符串(BLOB)。 -```response -abcdefg1w508d6qejxtdg4y5r3zarvary0c5xw7k9rp8r4 -``` +如果您想将结果转换为数字,可以使用 `reverse` 和 `reinterpretAs` 函数。 + +:::note +`clickhouse-client` 将字符串解释为 UTF-8。 +这可能会导致通过 `hex` 返回的值被意外地显示。 +::: -## bech32Decode {#bech32decode} +支持大写和小写字母 `A-F`。 +十六进制数字的数量不必是偶数。 +如果是奇数,最后一个数字被解释为 `00-0F` 字节的最低有效位。 +如果参数字符串包含除十六进制数字以外的任何内容,则返回一些实现定义的结果(不会抛出异常)。 +对于数值参数,unhex() 不执行 hex(N) 的逆操作。 -解码由 bech32 或 bech32m 算法生成的 Bech32 地址字符串。 **语法** ```sql -bech32Decode(address) +unhex(arg) ``` **参数** -- `address` — 要解码的 Bech32 字符串。 [String](../data-types/string.md) 或 [FixedString](../data-types/fixedstring.md)。 +- `arg` — 一个包含任意数量十六进制数字的字符串。 [`String`](/sql-reference/data-types/string) 或 [`FixedString`](/sql-reference/data-types/fixedstring) -:::note -与 encode 函数不同,`Bech32Decode` 将自动处理填充的 [FixedStrings](../data-types/fixedstring.md)。 -::: **返回值** -- 由 (hrp, data) 组成的元组,用于编码该字符串。数据以二进制格式表示。 - -类型: ([String](../data-types/string.md), [String](../data-types/string.md))。 +返回一个二进制字符串(BLOB)。 [`String`](/sql-reference/data-types/string) **示例** -查询: +**基本用法** -```sql -SELECT tup.1 AS hrp, hex(tup.2) AS data FROM (SELECT bech32Decode('bc1w508d6qejxtdg4y5r3zarvary0c5xw7kj7gz7z') AS tup); +```sql title=Query +SELECT unhex('303132'), UNHEX('4D7953514C') ``` -结果: - -```response -bc 751E76E8199196D454941C45D1B3A323F1433BD6 +```response title=Response +┌─unhex('303132')─┬─unhex('4D7953514C')─┐ +│ 012 │ MySQL │ +└─────────────────┴─────────────────────┘ ``` -查询: +**转换为数字** -```sql -SELECT tup.1 AS hrp, hex(tup.2) AS data FROM (SELECT bech32Decode('tb1w508d6qejxtdg4y5r3zarvary0c5xw7kzp034v') AS tup); +```sql title=Query +SELECT reinterpretAsUInt64(reverse(unhex('FFF'))) AS num ``` -结果: - -```response -tb 751E76E8199196D454941C45D1B3A323F1433BD6 +```response title=Response +┌──num─┐ +│ 4095 │ +└──────┘ ``` - - + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/encoding-functions.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/encoding-functions.md.hash index 5f5da78d1bf..85449b5a090 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/encoding-functions.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/encoding-functions.md.hash @@ -1 +1 @@ -c440b0fa2b070df2 +ccff48b2f91fccf9 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/encryption-functions.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/encryption-functions.md index a55c61ef9d2..454407f7f1e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/encryption-functions.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/encryption-functions.md @@ -1,226 +1,192 @@ --- 'description': '加密函数的 Documentation' -'sidebar_label': 'Encryption' -'sidebar_position': 70 +'sidebar_label': '加密' 'slug': '/sql-reference/functions/encryption-functions' 'title': '加密函数' +'keywords': +- 'encryption' +- 'regular functions' +- 'encrypt' +- 'decrypt' +'doc_type': 'reference' --- # 加密函数 -这些函数使用 AES (高级加密标准) 算法实现数据的加密和解密。 +这些函数使用 AES(高级加密标准)算法实现数据的加密和解密。 -密钥长度取决于加密模式。对于 `-128-`、`-196-` 和 `-256-` 模式,长度分别为 16、24 和 32 字节。 +密钥长度取决于加密模式:`-128-`、`-196-` 和 `-256-` 模式分别为 `16`、`24` 和 `32` 字节长。 -初始化向量的长度始终为 16 字节(超出 16 字节的字节将被忽略)。 +初始化向量的长度始终为 16 字节(超过 16 字节的字节将被忽略)。 -请注意,这些函数在 ClickHouse 21.1 之前运行缓慢。 + + + +## aes_decrypt_mysql {#aes_decrypt_mysql} + +引入于:v20.12 -## encrypt {#encrypt} -该函数使用以下模式加密数据: +解密由 MySQL 的 [`AES_ENCRYPT`](https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_aes-encrypt) 函数加密的数据。 + +对于相同的输入,产生与 [`decrypt`](#decrypt) 相同的明文。 +当 `key` 或 `iv` 长度超过正常情况时,`aes_decrypt_mysql` 将遵循 MySQL 的 `aes_decrypt` 所做的,即“折叠” `key` 并忽略 `IV` 的多余位。 + +支持以下解密模式: - aes-128-ecb, aes-192-ecb, aes-256-ecb - aes-128-cbc, aes-192-cbc, aes-256-cbc +- aes-128-cfb128 - aes-128-ofb, aes-192-ofb, aes-256-ofb -- aes-128-gcm, aes-192-gcm, aes-256-gcm -- aes-128-ctr, aes-192-ctr, aes-256-ctr -- aes-128-cfb, aes-128-cfb1, aes-128-cfb8 + **语法** ```sql -encrypt('mode', 'plaintext', 'key' [, iv, aad]) +aes_decrypt_mysql(mode, ciphertext, key[, iv]) ``` **参数** -- `mode` — 加密模式。 [String](/sql-reference/data-types/string)。 -- `plaintext` — 需要加密的文本。 [String](/sql-reference/data-types/string)。 -- `key` — 加密密钥。 [String](/sql-reference/data-types/string)。 -- `iv` — 初始化向量。 对于 `-gcm` 模式是必需的,对于其他模式是可选的。 [String](/sql-reference/data-types/string)。 -- `aad` — 附加认证数据。它不被加密,但会影响解密。仅在 `-gcm` 模式下有效,对于其他模式会抛出异常。 [String](/sql-reference/data-types/string)。 +- `mode` — 解密模式。 [`String`](/sql-reference/data-types/string) +- `ciphertext` — 需要解密的加密文本。 [`String`](/sql-reference/data-types/string) +- `key` — 解密密钥。 [`String`](/sql-reference/data-types/string) +- `iv` — 可选。初始化向量。 [`String`](/sql-reference/data-types/string) + **返回值** -- 密文二进制字符串。 [String](/sql-reference/data-types/string)。 +返回解密后的字符串。 [`String`](/sql-reference/data-types/string) **示例** -创建此表: - -查询: - -```sql -CREATE TABLE encryption_test -( - `comment` String, - `secret` String -) -ENGINE = Memory; -``` - -插入一些数据(请避免将密钥/iv 存储在数据库中,因为这会破坏加密的整个概念);同时存储“提示”也不安全,仅用于说明目的: - -查询: - -```sql -INSERT INTO encryption_test VALUES('aes-256-ofb no IV', encrypt('aes-256-ofb', 'Secret', '12345678910121314151617181920212')),\ -('aes-256-ofb no IV, different key', encrypt('aes-256-ofb', 'Secret', 'keykeykeykeykeykeykeykeykeykeyke')),\ -('aes-256-ofb with IV', encrypt('aes-256-ofb', 'Secret', '12345678910121314151617181920212', 'iviviviviviviviv')),\ -('aes-256-cbc no IV', encrypt('aes-256-cbc', 'Secret', '12345678910121314151617181920212')); -``` - -查询: +**解密 MySQL 数据** -```sql -SELECT comment, hex(secret) FROM encryption_test; -``` +```sql title=Query +-- Let's decrypt data we've previously encrypted with MySQL: +mysql> SET block_encryption_mode='aes-256-ofb'; +Query OK, 0 rows affected (0.00 sec) -结果: +mysql> SELECT aes_encrypt('Secret', '123456789101213141516171819202122', 'iviviviviviviviv123456') as ciphertext; ++------------------------+ +| ciphertext | ++------------------------+ +| 0x24E9E4966469 | ++------------------------+ +1 row in set (0.00 sec) -```text -┌─comment──────────────────────────┬─hex(secret)──────────────────────┐ -│ aes-256-ofb no IV │ B4972BDC4459 │ -│ aes-256-ofb no IV, different key │ 2FF57C092DC9 │ -│ aes-256-ofb with IV │ 5E6CB398F653 │ -│ aes-256-cbc no IV │ 1BC0629A92450D9E73A00E7D02CF4142 │ -└──────────────────────────────────┴──────────────────────────────────┘ +SELECT aes_decrypt_mysql('aes-256-ofb', unhex('24E9E4966469'), '123456789101213141516171819202122', 'iviviviviviviviv123456') AS plaintext ``` -使用 `-gcm` 的示例: - -查询: - -```sql -INSERT INTO encryption_test VALUES('aes-256-gcm', encrypt('aes-256-gcm', 'Secret', '12345678910121314151617181920212', 'iviviviviviviviv')), \ -('aes-256-gcm with AAD', encrypt('aes-256-gcm', 'Secret', '12345678910121314151617181920212', 'iviviviviviviviv', 'aad')); - -SELECT comment, hex(secret) FROM encryption_test WHERE comment LIKE '%gcm%'; +```response title=Response +┌─plaintext─┐ +│ Secret │ +└───────────┘ ``` -结果: -```text -┌─comment──────────────┬─hex(secret)──────────────────────────────────┐ -│ aes-256-gcm │ A8A3CCBC6426CFEEB60E4EAE03D3E94204C1B09E0254 │ -│ aes-256-gcm with AAD │ A8A3CCBC6426D9A1017A0A932322F1852260A4AD6837 │ -└──────────────────────┴──────────────────────────────────────────────┘ -``` ## aes_encrypt_mysql {#aes_encrypt_mysql} -与 mysql 加密兼容,结果密文可用 [AES_DECRYPT](https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_aes-decrypt) 函数解密。 +引入于:v20.12 + -在相同输入下将生成与 `encrypt` 相同的密文。但是当 `key` 或 `iv` 超过正常长度时,`aes_encrypt_mysql` 将遵循 MySQL 的 `aes_encrypt` 所做的:'折叠' `key` 并忽略 `iv` 的多余位。 +以与 MySQL 的 `AES_ENCRYPT` 函数相同的方式加密文本。 +生成的密文可以使用 MySQL 的 `AES_DECRYPT` 函数解密。 +对于相同的输入,产生与 `encrypt` 函数相同的密文。 +当 `key` 或 `iv` 长度超过正常情况时,`aes_encrypt_mysql` 将遵循 MySQL 的 `aes_encrypt` 所做的,即“折叠” `key` 并忽略 `iv` 的多余位。 -支持的加密模式: +支持的加密模式包括: - aes-128-ecb, aes-192-ecb, aes-256-ecb - aes-128-cbc, aes-192-cbc, aes-256-cbc - aes-128-ofb, aes-192-ofb, aes-256-ofb + **语法** ```sql -aes_encrypt_mysql('mode', 'plaintext', 'key' [, iv]) +aes_encrypt_mysql(mode, plaintext, key[, iv]) ``` **参数** -- `mode` — 加密模式。 [String](/sql-reference/data-types/string)。 -- `plaintext` — 需要加密的文本。 [String](/sql-reference/data-types/string)。 -- `key` — 加密密钥。如果密钥超过模式所需长度,将执行 MySQL 特有的密钥折叠。 [String](/sql-reference/data-types/string)。 -- `iv` — 初始化向量。可选,仅考虑前 16 字节。 [String](/sql-reference/data-types/string)。 +- `mode` — 加密模式。 [`String`](/sql-reference/data-types/string) +- `plaintext` — 应该被加密的文本。 [`String`](/sql-reference/data-types/string) +- `key` — 加密密钥。如果密钥长度超过 `mode` 的要求,将执行 MySQL 特定的密钥折叠。 [`String`](/sql-reference/data-types/string) +- `iv` — 可选。初始化向量。仅考虑前 16 个字节。 [`String`](/sql-reference/data-types/string) + **返回值** -- 密文二进制字符串。 [String](/sql-reference/data-types/string)。 +密文二进制字符串。 [`String`](/sql-reference/data-types/string) **示例** -给定相同输入,`encrypt` 和 `aes_encrypt_mysql` 生成相同的密文: - -查询: +**相等输入比较** -```sql +```sql title=Query +-- Given equal input encrypt and aes_encrypt_mysql produce the same ciphertext: SELECT encrypt('aes-256-ofb', 'Secret', '12345678910121314151617181920212', 'iviviviviviviviv') = aes_encrypt_mysql('aes-256-ofb', 'Secret', '12345678910121314151617181920212', 'iviviviviviviviv') AS ciphertexts_equal; ``` -结果: - -```response +```response title=Response ┌─ciphertexts_equal─┐ │ 1 │ └───────────────────┘ ``` -但是当 `key` 或 `iv` 超过预期时,`encrypt` 会失败: - -查询: +**使用长密钥时加密失败** -```sql +```sql title=Query +-- But encrypt fails when key or iv is longer than expected: SELECT encrypt('aes-256-ofb', 'Secret', '123456789101213141516171819202122', 'iviviviviviviviv123'); ``` -结果: - -```text +```response title=Response Received exception from server (version 22.6.1): Code: 36. DB::Exception: Received from localhost:9000. DB::Exception: Invalid key size: 33 expected 32: While processing encrypt('aes-256-ofb', 'Secret', '123456789101213141516171819202122', 'iviviviviviviviv123'). ``` -而 `aes_encrypt_mysql` 产生 MySQL 兼容的输出: - -查询: +**MySQL 兼容性** -```sql +```sql title=Query +-- aes_encrypt_mysql produces MySQL-compatible output: SELECT hex(aes_encrypt_mysql('aes-256-ofb', 'Secret', '123456789101213141516171819202122', 'iviviviviviviviv123')) AS ciphertext; ``` -结果: - -```response +```response title=Response ┌─ciphertext───┐ │ 24E9E4966469 │ └──────────────┘ ``` -注意,即使提供更长的 `IV` 也会产生相同的结果。 - -查询: +**较长的 IV 产生相同的结果** -```sql +```sql title=Query +-- Notice how supplying even longer IV produces the same result SELECT hex(aes_encrypt_mysql('aes-256-ofb', 'Secret', '123456789101213141516171819202122', 'iviviviviviviviv123456')) AS ciphertext ``` -结果: - -```text +```response title=Response ┌─ciphertext───┐ │ 24E9E4966469 │ └──────────────┘ ``` -这与 MySQL 对相同输入生成的结果是二进制相等的: -```sql -mysql> SET block_encryption_mode='aes-256-ofb'; -Query OK, 0 rows affected (0.00 sec) - -mysql> SELECT aes_encrypt('Secret', '123456789101213141516171819202122', 'iviviviviviviviv123456') as ciphertext; -+------------------------+ -| ciphertext | -+------------------------+ -| 0x24E9E4966469 | -+------------------------+ -1 row in set (0.00 sec) -``` ## decrypt {#decrypt} -此函数使用以下模式将密文解密为明文: +引入于:v20.12 + + +该函数使用以下模式解密 AES 加密的二进制字符串: - aes-128-ecb, aes-192-ecb, aes-256-ecb - aes-128-cbc, aes-192-cbc, aes-256-cbc @@ -228,38 +194,37 @@ mysql> SELECT aes_encrypt('Secret', '123456789101213141516171819202122', 'iviviv - aes-128-gcm, aes-192-gcm, aes-256-gcm - aes-128-ctr, aes-192-ctr, aes-256-ctr - aes-128-cfb, aes-128-cfb1, aes-128-cfb8 + **语法** ```sql -decrypt('mode', 'ciphertext', 'key' [, iv, aad]) +decrypt(mode, ciphertext, key[, iv, aad]) ``` **参数** -- `mode` — 解密模式。 [String](/sql-reference/data-types/string)。 -- `ciphertext` — 需要解密的加密文本。 [String](/sql-reference/data-types/string)。 -- `key` — 解密密钥。 [String](/sql-reference/data-types/string)。 -- `iv` — 初始化向量。对于 `-gcm` 模式是必需的,对于其他模式可选。 [String](/sql-reference/data-types/string)。 -- `aad` — 附加认证数据。如果该值不正确将无法解密。仅在 `-gcm` 模式下有效,对于其他模式会抛出异常。 [String](/sql-reference/data-types/string)。 +- `mode` — 解密模式。 [`String`](/sql-reference/data-types/string) +- `ciphertext` — 需要解密的加密文本。 [`String`](/sql-reference/data-types/string) +- `key` — 解密密钥。 [`String`](/sql-reference/data-types/string) +- `iv` — 初始化向量。对于 `-gcm` 模式是必需的,其他模式为可选。 [`String`](/sql-reference/data-types/string) +- `aad` — 附加认证数据。如果此值不正确,则不会解密。仅在 `-gcm` 模式中有效,其他模式抛出异常。 [`String`](/sql-reference/data-types/string) + **返回值** -- 解密字符串。 [String](/sql-reference/data-types/string)。 +返回解密后的明文。 [`String`](/sql-reference/data-types/string) **示例** -重用来自 [encrypt](#encrypt) 的表。 +**正确解密加密数据** -查询: - -```sql +```sql title=Query +-- Re-using the table from the encrypt function example SELECT comment, hex(secret) FROM encryption_test; ``` -结果: - -```text +```response title=Response ┌─comment──────────────┬─hex(secret)──────────────────────────────────┐ │ aes-256-gcm │ A8A3CCBC6426CFEEB60E4EAE03D3E94204C1B09E0254 │ │ aes-256-gcm with AAD │ A8A3CCBC6426D9A1017A0A932322F1852260A4AD6837 │ @@ -272,17 +237,14 @@ SELECT comment, hex(secret) FROM encryption_test; └──────────────────────────────────┴──────────────────────────────────┘ ``` -现在让我们尝试解密所有这些数据。 +**错误解密加密数据** -查询: - -```sql -SELECT comment, decrypt('aes-256-cfb128', secret, '12345678910121314151617181920212') as plaintext FROM encryption_test +```sql title=Query +SELECT comment, decrypt('aes-256-cfb128', secret, '12345678910121314151617181920212') AS plaintext FROM encryption_test ``` -结果: - -```text +```response title=Response +-- Notice how only a portion of the data was properly decrypted, and the rest is gibberish since either `mode`, `key`, or `iv` were different upon encryption. ┌─comment──────────────┬─plaintext──┐ │ aes-256-gcm │ OQ�E �t�7T�\���\� │ @@ -294,125 +256,162 @@ SELECT comment, decrypt('aes-256-cfb128', secret, '12345678910121314151617181920 │ aes-256-ofb no IV, different key │ �4� � │ │ aes-256-ofb with IV │ ���6�~ │ - │aes-256-cbc no IV │ �2*4�h3c�4w��@ +│aes-256-cbc no IV │ �2*4�h3c�4w��@ └──────────────────────────────────┴───────────┘ ``` -请注意,只有一部分数据被正确解密,其余部分则是乱码,因为加密时 `mode`、`key` 或 `iv` 不同。 -## tryDecrypt {#trydecrypt} -与 `decrypt` 类似,但如果因使用错误的密钥而解密失败,则返回 NULL。 +## encrypt {#encrypt} -**示例** +引入于:v20.12 -让我们创建一个表,其中 `user_id` 是唯一的用户 ID,`encrypted` 是加密字符串字段,`iv` 是解密/加密的初始向量。假设用户知道他们的 ID 和解密加密字段的密钥: -```sql -CREATE TABLE decrypt_null ( - dt DateTime, - user_id UInt32, - encrypted String, - iv String -) ENGINE = Memory; -``` +使用 AES 以以下模式之一将明文加密为密文: -插入一些数据: +- aes-128-ecb, aes-192-ecb, aes-256-ecb +- aes-128-cbc, aes-192-cbc, aes-256-cbc +- aes-128-ofb, aes-192-ofb, aes-256-ofb +- aes-128-gcm, aes-192-gcm, aes-256-gcm +- aes-128-ctr, aes-192-ctr, aes-256-ctr +- aes-128-cfb, aes-128-cfb1, aes-128-cfb8 + + +**语法** ```sql -INSERT INTO decrypt_null VALUES - ('2022-08-02 00:00:00', 1, encrypt('aes-256-gcm', 'value1', 'keykeykeykeykeykeykeykeykeykey01', 'iv1'), 'iv1'), - ('2022-09-02 00:00:00', 2, encrypt('aes-256-gcm', 'value2', 'keykeykeykeykeykeykeykeykeykey02', 'iv2'), 'iv2'), - ('2022-09-02 00:00:01', 3, encrypt('aes-256-gcm', 'value3', 'keykeykeykeykeykeykeykeykeykey03', 'iv3'), 'iv3'); +encrypt(mode, plaintext, key[, iv, aad]) ``` -查询: +**参数** -```sql -SELECT - dt, - user_id, - tryDecrypt('aes-256-gcm', encrypted, 'keykeykeykeykeykeykeykeykeykey02', iv) AS value -FROM decrypt_null -ORDER BY user_id ASC +- `mode` — 加密模式。 [`String`](/sql-reference/data-types/string) +- `plaintext` — 应该被加密的文本。 [`String`](/sql-reference/data-types/string) +- `key` — 加密密钥。 [`String`](/sql-reference/data-types/string) +- `iv` — 初始化向量。对于 `-gcm` 模式是必需的,其他模式为可选。 [`String`](/sql-reference/data-types/string) +- `aad` — 附加认证数据。它不会被加密,但会影响解密。仅在 `-gcm` 模式中有效,其他模式抛出异常。 [`String`](/sql-reference/data-types/string) + + +**返回值** + +返回二进制字符串密文。 [`String`](/sql-reference/data-types/string) + +**示例** + +**示例加密** + +```sql title=Query +CREATE TABLE encryption_test +( + `comment` String, + `secret` String +) +ENGINE = MergeTree; + +INSERT INTO encryption_test VALUES +('aes-256-ofb no IV', encrypt('aes-256-ofb', 'Secret', '12345678910121314151617181920212')), +('aes-256-ofb no IV, different key', encrypt('aes-256-ofb', 'Secret', 'keykeykeykeykeykeykeykeykeykeyke')), +('aes-256-ofb with IV', encrypt('aes-256-ofb', 'Secret', '12345678910121314151617181920212', 'iviviviviviviviv')), +('aes-256-cbc no IV', encrypt('aes-256-cbc', 'Secret', '12345678910121314151617181920212')); + +SELECT comment, hex(secret) FROM encryption_test; +``` + +```response title=Response +┌─comment──────────────────────────┬─hex(secret)──────────────────────┐ +│ aes-256-ofb no IV │ B4972BDC4459 │ +│ aes-256-ofb no IV, different key │ 2FF57C092DC9 │ +│ aes-256-ofb with IV │ 5E6CB398F653 │ +│ aes-256-cbc no IV │ 1BC0629A92450D9E73A00E7D02CF4142 │ +└──────────────────────────────────┴──────────────────────────────────┘ ``` -结果: +**使用 GCM 模式的示例** -```response -┌──────────────────dt─┬─user_id─┬─value──┐ -│ 2022-08-02 00:00:00 │ 1 │ ᴺᵁᴸᴸ │ -│ 2022-09-02 00:00:00 │ 2 │ value2 │ -│ 2022-09-02 00:00:01 │ 3 │ ᴺᵁᴸᴸ │ -└─────────────────────┴─────────┴────────┘ +```sql title=Query +INSERT INTO encryption_test VALUES +('aes-256-gcm', encrypt('aes-256-gcm', 'Secret', '12345678910121314151617181920212', 'iviviviviviviviv')), + +('aes-256-gcm with AAD', encrypt('aes-256-gcm', 'Secret', '12345678910121314151617181920212', 'iviviviviviviviv', 'aad')); + +SELECT comment, hex(secret) FROM encryption_test WHERE comment LIKE '%gcm%'; ``` -## aes_decrypt_mysql {#aes_decrypt_mysql} +```response title=Response +┌─comment──────────────┬─hex(secret)──────────────────────────────────┐ +│ aes-256-gcm │ A8A3CCBC6426CFEEB60E4EAE03D3E94204C1B09E0254 │ +│ aes-256-gcm with AAD │ A8A3CCBC6426D9A1017A0A932322F1852260A4AD6837 │ +└──────────────────────┴──────────────────────────────────────────────┘ +``` -与 mysql 加密兼容,解密用 [AES_ENCRYPT](https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_aes-encrypt) 函数加密的数据。 -在相同输入下将产生与 `decrypt` 相同的明文。但是当 `key` 或 `iv` 超过正常长度时,`aes_decrypt_mysql` 将遵循 MySQL 的 `aes_decrypt` 所做的:'折叠' `key` 并忽略 `IV` 的多余位。 -支持的解密模式: +## tryDecrypt {#tryDecrypt} -- aes-128-ecb, aes-192-ecb, aes-256-ecb -- aes-128-cbc, aes-192-cbc, aes-256-cbc -- aes-128-cfb128 -- aes-128-ofb, aes-192-ofb, aes-256-ofb +引入于:v22.10 + + +类似于 `decrypt` 函数,但当使用错误的密钥时,如果解密失败则返回 `NULL`。 + **语法** ```sql -aes_decrypt_mysql('mode', 'ciphertext', 'key' [, iv]) +tryDecrypt(mode, ciphertext, key[, iv, aad]) ``` **参数** -- `mode` — 解密模式。 [String](/sql-reference/data-types/string)。 -- `ciphertext` — 需要解密的加密文本。 [String](/sql-reference/data-types/string)。 -- `key` — 解密密钥。 [String](/sql-reference/data-types/string)。 -- `iv` — 初始化向量。可选。 [String](/sql-reference/data-types/string)。 +- `mode` — 解密模式。 [`String`](/sql-reference/data-types/string) +- `ciphertext` — 需要解密的加密文本。 [`String`](/sql-reference/data-types/string) +- `key` — 解密密钥。 [`String`](/sql-reference/data-types/string) +- `iv` — 可选。初始化向量。对于 `-gcm` 模式是必需的,其他模式为可选。 [`String`](/sql-reference/data-types/string) +- `aad` — 可选。附加认证数据。如果此值不正确,则不会解密。仅在 `-gcm` 模式中有效,对于其他模式抛出异常。 [`String`](/sql-reference/data-types/string) + **返回值** -- 解密字符串。 [String](/sql-reference/data-types/string)。 +返回解密后的字符串,如果解密失败则返回 `NULL`。 [`Nullable(String)`](/sql-reference/data-types/nullable) **示例** -让我们解密之前用 MySQL 加密的数据: +**创建表并插入数据** -```sql -mysql> SET block_encryption_mode='aes-256-ofb'; -Query OK, 0 rows affected (0.00 sec) - -mysql> SELECT aes_encrypt('Secret', '123456789101213141516171819202122', 'iviviviviviviviv123456') as ciphertext; -+------------------------+ -| ciphertext | -+------------------------+ -| 0x24E9E4966469 | -+------------------------+ -1 row in set (0.00 sec) -``` +```sql title=Query +-- Let's create a table where user_id is the unique user id, encrypted is an encrypted string field, iv is an initial vector for decrypt/encrypt. +-- Assume that users know their id and the key to decrypt the encrypted field: +CREATE TABLE decrypt_null +( + dt DateTime, + user_id UInt32, + encrypted String, + iv String +) +ENGINE = MergeTree; -查询: +-- Insert some data: +INSERT INTO decrypt_null VALUES +('2022-08-02 00:00:00', 1, encrypt('aes-256-gcm', 'value1', 'keykeykeykeykeykeykeykeykeykey01', 'iv1'), 'iv1'), +('2022-09-02 00:00:00', 2, encrypt('aes-256-gcm', 'value2', 'keykeykeykeykeykeykeykeykeykey02', 'iv2'), 'iv2'), +('2022-09-02 00:00:01', 3, encrypt('aes-256-gcm', 'value3', 'keykeykeykeykeykeykeykeykeykey03', 'iv3'), 'iv3'); -```sql -SELECT aes_decrypt_mysql('aes-256-ofb', unhex('24E9E4966469'), '123456789101213141516171819202122', 'iviviviviviviviv123456') AS plaintext +-- Try decrypt with one key +SELECT + dt, + user_id, + tryDecrypt('aes-256-gcm', encrypted, 'keykeykeykeykeykeykeykeykeykey02', iv) AS value +FROM decrypt_null +ORDER BY user_id ASC ``` -结果: - -```text -┌─plaintext─┐ -│ Secret │ -└───────────┘ +```response title=Response +┌──────────────────dt─┬─user_id─┬─value──┐ +│ 2022-08-02 00:00:00 │ 1 │ ᴺᵁᴸᴸ │ +│ 2022-09-02 00:00:00 │ 2 │ value2 │ +│ 2022-09-02 00:00:01 │ 3 │ ᴺᵁᴸᴸ │ +└─────────────────────┴─────────┴────────┘ ``` - - + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/encryption-functions.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/encryption-functions.md.hash index 2c0c8ed4290..f383bd5981b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/encryption-functions.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/encryption-functions.md.hash @@ -1 +1 @@ -0249fcda9b42b0d8 +fb5d2764ab94122e diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/ext-dict-functions.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/ext-dict-functions.md index a661a7af2c4..9a53f3b8497 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/ext-dict-functions.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/ext-dict-functions.md @@ -1,19 +1,19 @@ --- -'description': '字典的函数文档' -'sidebar_label': '字典' -'sidebar_position': 50 +'description': '字典操作函数的文档' +'sidebar_label': 'Dictionaries' 'slug': '/sql-reference/functions/ext-dict-functions' -'title': '与字典一起使用的函数' +'title': '字典操作函数' +'doc_type': 'reference' --- -# 用于处理字典的函数 +# 字典操作函数 :::note -对于使用 [DDL 查询](../../sql-reference/statements/create/dictionary.md) 创建的字典,`dict_name` 参数必须完全指定,如 `.`。否则,将使用当前数据库。 +对于使用 [DDL 查询](../../sql-reference/statements/create/dictionary.md) 创建的字典,`dict_name` 参数必须完全指定,例如 `.`。否则,将使用当前数据库。 ::: -有关连接和配置字典的信息,请参见 [Dictionaries](../../sql-reference/dictionaries/index.md)。 +关于连接和配置字典的信息,请参见 [字典](../../sql-reference/dictionaries/index.md)。 ## dictGet, dictGetOrDefault, dictGetOrNull {#dictget-dictgetordefault-dictgetornull} @@ -27,33 +27,33 @@ dictGetOrNull('dict_name', attr_name, id_expr) **参数** -- `dict_name` — 字典的名称。[字符串文字](/sql-reference/syntax#string)。 -- `attr_names` — 字典的列名,[字符串文字](/sql-reference/syntax#string),或列名的元组,[Tuple](/sql-reference/data-types/tuple)([字符串文字](/sql-reference/syntax#string)。 -- `id_expr` — 键值。[表达式](/sql-reference/syntax#expressions),返回字典键类型的值或根据字典配置返回的 [Tuple](../data-types/tuple.md) 类型值。 -- `default_value_expr` — 如果字典中不包含具有 `id_expr` 键的行则返回的值。[表达式](/sql-reference/syntax#expressions) 或 [Tuple](../data-types/tuple.md)([表达式](/sql-reference/syntax#expressions)),返回与 `attr_names` 属性配置的数据类型相对应的值(或值)。 +- `dict_name` — 字典的名称。 [字符串文字](/sql-reference/syntax#string)。 +- `attr_names` — 字典列的名称, [字符串文字](/sql-reference/syntax#string),或列名称的元组,[Tuple](/sql-reference/data-types/tuple)([字符串文字](/sql-reference/syntax#string))。 +- `id_expr` — 键值。 [表达式](/sql-reference/syntax#expressions) 返回字典键类型的值或根据字典配置返回 [Tuple](../data-types/tuple.md) 类型的值。 +- `default_value_expr` — 如果字典中不包含具有 `id_expr` 键的行,则返回的值。 [表达式](/sql-reference/syntax#expressions) 或 [Tuple](../data-types/tuple.md)([表达式](/sql-reference/syntax#expressions)),返回配置为 `attr_names` 属性的数据类型的值(或值)。 -**返回的值** +**返回值** -- 如果 ClickHouse 成功解析了属性的 [属性数据类型](/sql-reference/dictionaries#dictionary-key-and-fields),则函数返回与 `id_expr` 对应的字典属性值。 +- 如果 ClickHouse 能够成功解析该属性的 [属性数据类型](/sql-reference/dictionaries#dictionary-key-and-fields),则函数返回与 `id_expr` 对应的字典属性的值。 - 如果字典中没有与 `id_expr` 对应的键,则: - - - `dictGet` 返回在字典配置中为该属性指定的 `` 元素的内容。 + + - `dictGet` 返回在字典配置中为属性指定的 `` 元素的内容。 - `dictGetOrDefault` 返回作为 `default_value_expr` 参数传递的值。 - - `dictGetOrNull` 在未找到键的情况下返回 `NULL`。 + - `dictGetOrNull` 如果在字典中未找到键,则返回 `NULL`。 -如果 ClickHouse 无法解析属性的值或值与属性数据类型不匹配,它将抛出异常。 +如果 ClickHouse 无法解析属性的值,或者值与属性数据类型不匹配,则会抛出异常。 **简单键字典示例** -创建一个文本文件 `ext-dict-test.csv`,内容如下: +创建包含以下内容的文本文件 `ext-dict-test.csv`: ```text 1,1 2,2 ``` -第一列为 `id`,第二列为 `c1`。 +第一列是 `id`,第二列是 `c1`。 配置字典: @@ -105,7 +105,7 @@ LIMIT 3; **复杂键字典示例** -创建一个文本文件 `ext-dict-mult.csv`,内容如下: +创建包含以下内容的文本文件 `ext-dict-mult.csv`: ```text 1,1,'1' @@ -113,7 +113,7 @@ LIMIT 3; 3,3,'3' ``` -第一列为 `id`,第二列为 `c1`,第三列为 `c2`。 +第一列是 `id`,第二列是 `c1`,第三列是 `c2`。 配置字典: @@ -217,6 +217,7 @@ SELECT dictGetOrNull('range_key_dictionary', ('value', 'value_nullable'), number, toDate('2019-05-20')) FROM system.numbers LIMIT 5 FORMAT TabSeparated; ``` + 结果: ```text @@ -227,9 +228,9 @@ FROM system.numbers LIMIT 5 FORMAT TabSeparated; (4,'2019-05-20') 0 \N \N (NULL,NULL) ``` -**另见** +**另请参阅** -- [Dictionaries](../../sql-reference/dictionaries/index.md) +- [字典](../../sql-reference/dictionaries/index.md) ## dictHas {#dicthas} @@ -241,17 +242,17 @@ dictHas('dict_name', id_expr) **参数** -- `dict_name` — 字典的名称。[字符串文字](/sql-reference/syntax#string)。 -- `id_expr` — 键值。[表达式](/sql-reference/syntax#expressions),返回字典键类型的值或根据字典配置返回的 [Tuple](../data-types/tuple.md) 类型值。 +- `dict_name` — 字典的名称。 [字符串文字](/sql-reference/syntax#string)。 +- `id_expr` — 键值。 [表达式](/sql-reference/syntax#expressions) 返回字典键类型值或根据字典配置返回 [Tuple](../data-types/tuple.md) 类型的值。 -**返回的值** +**返回值** -- 0,表示没有该键。[UInt8](../data-types/int-uint.md)。 -- 1,表示存在该键。[UInt8](../data-types/int-uint.md)。 +- 如果没有键,则返回 0。 [UInt8](../data-types/int-uint.md)。 +- 如果有键,则返回 1。 [UInt8](../data-types/int-uint.md)。 ## dictGetHierarchy {#dictgethierarchy} -创建一个数组,包含在 [层次字典](../../sql-reference/dictionaries/index.md#hierarchical-dictionaries) 中某个键的所有父项。 +创建一个数组,包含键在 [层次字典](../../sql-reference/dictionaries/index.md#hierarchical-dictionaries) 中的所有父级。 **语法** @@ -261,16 +262,16 @@ dictGetHierarchy('dict_name', key) **参数** -- `dict_name` — 字典的名称。[字符串文字](/sql-reference/syntax#string)。 -- `key` — 键值。[表达式](/sql-reference/syntax#expressions),返回一个 [UInt64](../data-types/int-uint.md) 类型的值。 +- `dict_name` — 字典的名称。 [字符串文字](/sql-reference/syntax#string)。 +- `key` — 键值。 [表达式](/sql-reference/syntax#expressions) 返回 [UInt64](../data-types/int-uint.md) 类型的值。 -**返回的值** +**返回值** -- 键的父项。[Array(UInt64)](../data-types/array.md)。 +- 键的父节点。 [Array(UInt64)](../data-types/array.md)。 ## dictIsIn {#dictisin} -检查某个键在字典中的整个层次链中是否为某个祖先。 +通过整个层次链检查某个键的祖先。 ```sql dictIsIn('dict_name', child_id_expr, ancestor_id_expr) @@ -278,18 +279,18 @@ dictIsIn('dict_name', child_id_expr, ancestor_id_expr) **参数** -- `dict_name` — 字典的名称。[字符串文字](/sql-reference/syntax#string)。 -- `child_id_expr` — 要检查的键。[表达式](/sql-reference/syntax#expressions),返回一个 [UInt64](../data-types/int-uint.md) 类型的值。 -- `ancestor_id_expr` — `child_id_expr` 键的假定祖先。[表达式](/sql-reference/syntax#expressions),返回一个 [UInt64](../data-types/int-uint.md) 类型的值。 +- `dict_name` — 字典的名称。 [字符串文字](/sql-reference/syntax#string)。 +- `child_id_expr` — 要检查的键。 [表达式](/sql-reference/syntax#expressions) 返回 [UInt64](../data-types/int-uint.md) 类型的值。 +- `ancestor_id_expr` — `child_id_expr` 键的假定祖先。 [表达式](/sql-reference/syntax#expressions) 返回 [UInt64](../data-types/int-uint.md) 类型的值。 -**返回的值** +**返回值** -- 0,如果 `child_id_expr` 不是 `ancestor_id_expr` 的子项。[UInt8](../data-types/int-uint.md)。 -- 1,如果 `child_id_expr` 是 `ancestor_id_expr` 的子项,或者如果 `child_id_expr` 是 `ancestor_id_expr`。[UInt8](../data-types/int-uint.md)。 +- 如果 `child_id_expr` 不是 `ancestor_id_expr` 的子级,则返回 0。 [UInt8](../data-types/int-uint.md)。 +- 如果 `child_id_expr` 是 `ancestor_id_expr` 的子级,或者 `child_id_expr` 是 `ancestor_id_expr`,则返回 1。 [UInt8](../data-types/int-uint.md)。 ## dictGetChildren {#dictgetchildren} -返回第一层子项,作为索引数组。这是对 [dictGetHierarchy](#dictgethierarchy) 的逆转换。 +返回第一层子节点,作为索引数组。这是 [dictGetHierarchy](#dictgethierarchy) 的逆变换。 **语法** @@ -299,12 +300,12 @@ dictGetChildren(dict_name, key) **参数** -- `dict_name` — 字典的名称。[字符串文字](/sql-reference/syntax#string)。 -- `key` — 键值。[表达式](/sql-reference/syntax#expressions),返回一个 [UInt64](../data-types/int-uint.md) 类型的值。 +- `dict_name` — 字典的名称。 [字符串文字](/sql-reference/syntax#string)。 +- `key` — 键值。 [表达式](/sql-reference/syntax#expressions) 返回 [UInt64](../data-types/int-uint.md) 类型的值。 **返回值** -- 键的第一层后代。[Array](../data-types/array.md)([UInt64](../data-types/int-uint.md))。 +- 针对该键的第一层后代。 [Array](../data-types/array.md)([UInt64](../data-types/int-uint.md))。 **示例** @@ -319,7 +320,7 @@ dictGetChildren(dict_name, key) └────┴───────────┘ ``` -第一层子项: +第一层子节点: ```sql SELECT dictGetChildren('hierarchy_flat_dictionary', number) FROM system.numbers LIMIT 4; @@ -336,7 +337,7 @@ SELECT dictGetChildren('hierarchy_flat_dictionary', number) FROM system.numbers ## dictGetDescendant {#dictgetdescendant} -返回所有后代,就像对 [dictGetChildren](#dictgetchildren) 函数应用 `level` 次递归一样。 +返回所有后代,仿佛 [dictGetChildren](#dictgetchildren) 函数递归地应用了 `level` 次。 **语法** @@ -346,13 +347,13 @@ dictGetDescendants(dict_name, key, level) **参数** -- `dict_name` — 字典的名称。[字符串文字](/sql-reference/syntax#string)。 -- `key` — 键值。[表达式](/sql-reference/syntax#expressions),返回一个 [UInt64](../data-types/int-uint.md) 类型的值。 -- `level` — 层次级别。如果 `level = 0` 返回所有后代到最后。[UInt8](../data-types/int-uint.md)。 +- `dict_name` — 字典的名称。 [字符串文字](/sql-reference/syntax#string)。 +- `key` — 键值。 [表达式](/sql-reference/syntax#expressions) 返回 [UInt64](../data-types/int-uint.md) 类型的值。 +- `level` — 层次级别。如果 `level = 0`,则返回所有后代到最后。 [UInt8](../data-types/int-uint.md)。 **返回值** -- 键的后代。[Array](../data-types/array.md)([UInt64](../data-types/int-uint.md))。 +- 针对该键的后代。 [Array](../data-types/array.md)([UInt64](../data-types/int-uint.md))。 **示例** @@ -366,6 +367,7 @@ dictGetDescendants(dict_name, key, level) │ 4 │ 2 │ └────┴───────────┘ ``` + 所有后代: ```sql @@ -396,12 +398,11 @@ SELECT dictGetDescendants('hierarchy_flat_dictionary', number, 1) FROM system.nu └────────────────────────────────────────────────────────────┘ ``` - ## dictGetAll {#dictgetall} -检索与正则表达式树字典([regular expression tree dictionary](../../sql-reference/dictionaries/index.md#regexp-tree-dictionary))中每个键匹配的节点的所有属性值。 +检索与每个键匹配的所有节点的属性值,适用于 [正则表达式树字典](../../sql-reference/dictionaries/index.md#regexp-tree-dictionary)。 -除了返回 `Array(T)` 类型而非 `T` 外,此函数的行为与 [`dictGet`](#dictget-dictgetordefault-dictgetornull) 类似。 +除了返回类型为 `Array(T)` 而不是 `T` 之外,该函数的行为类似于 [`dictGet`](#dictget-dictgetordefault-dictgetornull)。 **语法** @@ -411,18 +412,18 @@ dictGetAll('dict_name', attr_names, id_expr[, limit]) **参数** -- `dict_name` — 字典的名称。[字符串文字](/sql-reference/syntax#string)。 -- `attr_names` — 字典的列名,[字符串文字](/sql-reference/syntax#string),或列名的元组,[Tuple](/sql-reference/data-types/tuple)([字符串文字](/sql-reference/syntax#string))。 -- `id_expr` — 键值。[表达式](/sql-reference/syntax#expressions),返回字典键类型值的数组或根据字典配置返回的 [Tuple](../data-types/tuple) 类型值。 -- `limit` - 返回的每个值数组的最大长度。在截断时,子节点优先于父节点,除此之外正则表达式树字典的定义列表顺序得到尊重。如果未指定,数组长度不受限制。 +- `dict_name` — 字典的名称。 [字符串文字](/sql-reference/syntax#string)。 +- `attr_names` — 字典列的名称, [字符串文字](/sql-reference/syntax#string),或列名称的元组,[Tuple](/sql-reference/data-types/tuple)([字符串文字](/sql-reference/syntax#string))。 +- `id_expr` — 键值。 [表达式](/sql-reference/syntax#expressions) 返回字典键类型的数组或根据字典配置返回 [Tuple](../data-types/tuple) 类型的值。 +- `limit` - 每个返回值数组的最大长度。截断时,子节点优先于父节点,否则遵循正则表达式树字典中定义的列表顺序。如果未指定,数组长度不受限制。 -**返回的值** +**返回值** -- 如果 ClickHouse 在字典中按定义解析属性的数据类型,则返回与 `id_expr` 对应的字典属性值数组。 +- 如果 ClickHouse 在字典中的属性数据类型上成功解析了属性,则返回与每个属性 `attr_names` 对应的字典属性值的数组。 - 如果在字典中没有与 `id_expr` 对应的键,则返回一个空数组。 -如果 ClickHouse 无法解析属性的值或值与属性数据类型不匹配,它将抛出异常。 +如果 ClickHouse 无法解析属性的值,或者值与属性数据类型不匹配,则会抛出异常。 **示例** @@ -451,7 +452,7 @@ LAYOUT(regexp_tree) tag: 'baz_attr' ``` -获取所有匹配值: +获取所有匹配的值: ```sql SELECT dictGetAll('regexp_dict', 'tag', 'foobarbaz'); @@ -463,7 +464,7 @@ SELECT dictGetAll('regexp_dict', 'tag', 'foobarbaz'); └───────────────────────────────────────────────┘ ``` -获取最多 2 个匹配值: +获取最多 2 个匹配的值: ```sql SELECT dictGetAll('regexp_dict', 'tag', 'foobarbaz', 2); @@ -477,9 +478,9 @@ SELECT dictGetAll('regexp_dict', 'tag', 'foobarbaz', 2); ## 其他函数 {#other-functions} -ClickHouse 支持专门的函数,无论字典配置如何,都将字典属性值转换为特定数据类型。 +ClickHouse 支持专门的函数,可以将字典属性值转换为特定数据类型,而不管字典配置如何。 -函数包括: +函数: - `dictGetInt8`, `dictGetInt16`, `dictGetInt32`, `dictGetInt64` - `dictGetUInt8`, `dictGetUInt16`, `dictGetUInt32`, `dictGetUInt64` @@ -501,21 +502,21 @@ dictGet[Type]OrDefault('dict_name', 'attr_name', id_expr, default_value_expr) **参数** -- `dict_name` — 字典的名称。[字符串文字](/sql-reference/syntax#string)。 -- `attr_name` — 字典的列名。[字符串文字](/sql-reference/syntax#string)。 -- `id_expr` — 键值。[表达式](/sql-reference/syntax#expressions),返回一个 [UInt64](../data-types/int-uint.md) 或 [Tuple](../data-types/tuple.md) 类型的值,具体取决于字典配置。 -- `default_value_expr` — 如果字典中不包含具有 `id_expr` 键的行则返回的值。[表达式](/sql-reference/syntax#expressions),返回与 `attr_name` 属性配置的数据类型相对应的值。 +- `dict_name` — 字典的名称。 [字符串文字](/sql-reference/syntax#string)。 +- `attr_name` — 字典列的名称。 [字符串文字](/sql-reference/syntax#string)。 +- `id_expr` — 键值。 [表达式](/sql-reference/syntax#expressions) 返回 [UInt64](../data-types/int-uint.md) 或 [Tuple](../data-types/tuple.md) 类型的值,具体取决于字典配置。 +- `default_value_expr` — 如果字典中不存在具有 `id_expr` 键的行,则返回的值。 [表达式](/sql-reference/syntax#expressions) 返回在为 `attr_name` 属性配置的数据类型中的值。 -**返回的值** +**返回值** -- 如果 ClickHouse 在 [属性的数据类型](/sql-reference/dictionaries#dictionary-key-and-fields) 中成功解析属性,则函数返回与 `id_expr` 对应的字典属性值。 +- 如果 ClickHouse 在 [属性数据类型](/sql-reference/dictionaries#dictionary-key-and-fields) 上成功解析了属性,则函数返回与 `id_expr` 对应的字典属性的值。 -- 如果在字典中没有请求的 `id_expr`,那么: +- 如果在字典中没有请求的 `id_expr`,则: - - `dictGet[Type]` 返回在字典配置中为该属性指定的 `` 元素的内容。 + - `dictGet[Type]` 返回在字典配置中为属性指定的 `` 元素的内容。 - `dictGet[Type]OrDefault` 返回作为 `default_value_expr` 参数传递的值。 -如果 ClickHouse 无法解析属性的值或值与属性数据类型不匹配,它将抛出异常。 +如果 ClickHouse 无法解析属性的值,或者值与属性数据类型不匹配,则会抛出异常。 + + +## financialInternalRateOfReturn {#financialInternalRateOfReturn} + +引入于:v25.7 + + +计算一系列定期现金流的内部收益率 (IRR)。内部收益率是使净现值 (NPV) 等于零的折现率。 + +IRR 尝试解决以下方程: + +$$ +\sum_{i=0}^n \frac{cashflow_i}{(1 + irr)^i} = 0 +$$ + + +**语法** + +```sql +financialInternalRateOfReturn(cashflows[, guess]) +``` + +**参数** + +- `cashflows` — 现金流数组。每个值表示支付(负值)或收入(正值)。[`Array(Int8/16/32/64)`](/sql-reference/data-types/array) 或 [`Array(Float*)`](/sql-reference/data-types/array) +- `[, guess]` — 可选的内部收益率初始猜测(常量值)(默认 0.1)。[`Float*`](/sql-reference/data-types/float) + + +**返回值** + +返回内部收益率或 `NaN`,如果计算无法收敛、输入数组为空或只有一个元素、所有现金流为零或发生其他计算错误。[`Float64`](/sql-reference/data-types/float) + +**示例** + +**简单示例** + +```sql title=Query +SELECT financialInternalRateOfReturn([-100, 39, 59, 55, 20]) +``` + +```response title=Response +0.2809484211599611 +``` + +**带猜测的简单示例** + +```sql title=Query +SELECT financialInternalRateOfReturn([-100, 39, 59, 55, 20], 0.1) +``` + +```response title=Response +0.2809484211599611 +``` + + + +## financialInternalRateOfReturnExtended {#financialInternalRateOfReturnExtended} + +引入于:v25.7 + + +计算一系列不规则现金流的扩展内部收益率 (XIRR)。XIRR 是使所有现金流的净现值 (NPV) 等于零的折现率。 + +XIRR 尝试解决以下方程(`ACT_365F` 的示例): + +$$ +\sum_{i=0}^n \frac{cashflow_i}{(1 + rate)^{(date_i - date_0)/365}} = 0 +$$ + +数组应按日期升序排列。日期需要是唯一的。 + + +**语法** + +```sql +financialInternalRateOfReturnExtended(cashflow, date [, guess, daycount]) +``` + +**参数** + +- `cashflow` — 对应于第二参数中的日期的现金流数组。[`Array(Int8/16/32/64)`](/sql-reference/data-types/array) 或 [`Array(Float*)`](/sql-reference/data-types/array) +- `date` — 对应于现金流的唯一日期的已排序数组。[`Array(Date)`](/sql-reference/data-types/array) 或 [`Array(Date32)`](/sql-reference/data-types/array) +- `[, guess]` — 可选。XIRR 计算的初始猜测(常量值)。[`Float*`](/sql-reference/data-types/float) +- `[, daycount]` — +可选的天数计算约定(默认 'ACT_365F')。支持的值: +- 'ACT_365F' - 实际/365 固定:使用两个日期之间的实际天数除以 365 +- 'ACT_365_25' - 实际/365.25:使用两个日期之间的实际天数除以 365.25 + [`String`](/sql-reference/data-types/string) + + +**返回值** + +返回 XIRR 值。如果无法执行计算,则返回 NaN。[`Float64`](/sql-reference/data-types/float) + +**示例** + +**简单示例** + +```sql title=Query +SELECT financialInternalRateOfReturnExtended([-10000, 5750, 4250, 3250], [toDate('2020-01-01'), toDate('2020-03-01'), toDate('2020-10-30'), toDate('2021-02-15')]) +``` + +```response title=Response +0.6342972615260243 +``` + +**带猜测的简单示例** + +```sql title=Query +SELECT financialInternalRateOfReturnExtended([-10000, 5750, 4250, 3250], [toDate('2020-01-01'), toDate('2020-03-01'), toDate('2020-10-30'), toDate('2021-02-15')], 0.5) +``` + +```response title=Response +0.6342972615260243 +``` + +**简单示例(天数计算)** + +```sql title=Query +SELECT round(financialInternalRateOfReturnExtended([100000, -110000], [toDate('2020-01-01'), toDate('2021-01-01')], 0.1, 'ACT_365_25'), 6) AS xirr_365_25 +``` + +```response title=Response +0.099785 +``` + + + +## financialNetPresentValue {#financialNetPresentValue} + +引入于:v25.7 + + +计算一系列现金流的净现值 (NPV),假设每个现金流之间的时间间隔相等。 + +默认变体(`start_from_zero` = true): + +$$ +\sum_{i=0}^{N-1} \frac{values_i}{(1 + rate)^i} +$$ + +与 Excel 兼容的变体(`start_from_zero` = false): + +$$ +\sum_{i=1}^{N} \frac{values_i}{(1 + rate)^i} +$$ + + +**语法** + +```sql +financialNetPresentValue(rate, cashflows[, start_from_zero]) +``` + +**参数** + +- `rate` — 要应用的折现率。[`Float*`](/sql-reference/data-types/float) +- `cashflows` — 现金流数组。每个值表示支付(负值)或收入(正值)。[`Array(Int8/16/32/64)`](/sql-reference/data-types/array) 或 [`Array(Float*)`](/sql-reference/data-types/array) +- `[, start_from_zero]` — 可选布尔参数,指示是从周期 `0`(true)开始计算 NPV,还是从周期 `1`(false,Excel 兼容)开始。默认:true。[`Bool`](/sql-reference/data-types/boolean) + + +**返回值** + +返回净现值,类型为 Float64。[`Float64`](/sql-reference/data-types/float) + +**示例** + +**默认计算** + +```sql title=Query +SELECT financialNetPresentValue(0.08, [-40000., 5000., 8000., 12000., 30000.]) +``` + +```response title=Response +3065.2226681795255 +``` + +**与 Excel 兼容的计算** + +```sql title=Query +SELECT financialNetPresentValue(0.08, [-40000., 5000., 8000., 12000., 30000.], false) +``` + +```response title=Response +2838.1691372032656 +``` + + + +## financialNetPresentValueExtended {#financialNetPresentValueExtended} + +引入于:v25.7 + + +计算一系列不规则现金流的扩展净现值 (XNPV)。XNPV 在计算现值时考虑每个现金流的具体时间。 + +`ACT_365F` 的 XNPV 方程: + +$$ +XNPV=\sum_{i=1}^n \frac{cashflow_i}{(1 + rate)^{(date_i - date_0)/365}} +$$ + +数组应按日期升序排列。日期需要是唯一的。 + + +**语法** + +```sql +financialNetPresentValueExtended(rate, cashflows, dates[, daycount]) +``` + +**参数** + +- `rate` — 要应用的折现率。[`Float*`](/sql-reference/data-types/float) +- `cashflows` — 现金流数组。每个值表示支付(负值)或收入(正值)。必须至少包含一个正值和一个负值。[`Array(Int8/16/32/64)`](/sql-reference/data-types/array) 或 [`Array(Float*)`](/sql-reference/data-types/array) +- `dates` — 对应于每个现金流的日期数组。必须与现金流数组大小相同。[`Array(Date)`](/sql-reference/data-types/array) 或 [`Array(Date32)`](/sql-reference/data-types/array) +- `[, daycount]` — 可选的天数计算约定。支持的值:`'ACT_365F'`(默认) — 实际/365 固定,`'ACT_365_25'` — 实际/365.25。[`String`](/sql-reference/data-types/string) + + +**返回值** + +返回净现值,类型为 Float64。[`Float64`](/sql-reference/data-types/float) + +**示例** + +**基本用法** + +```sql title=Query +SELECT financialNetPresentValueExtended(0.1, [-10000., 5750., 4250., 3250.], [toDate('2020-01-01'), toDate('2020-03-01'), toDate('2020-10-30'), toDate('2021-02-15')]) +``` + +```response title=Response +2506.579458169746 +``` + +**使用不同的天数计算约定** + +```sql title=Query +SELECT financialNetPresentValueExtended(0.1, [-10000., 5750., 4250., 3250.], [toDate('2020-01-01'), toDate('2020-03-01'), toDate('2020-10-30'), toDate('2021-02-15')], 'ACT_365_25') +``` + +```response title=Response +2507.067268742502 +``` + + + + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/financial-functions.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/financial-functions.md.hash new file mode 100644 index 00000000000..cbba11c7735 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/financial-functions.md.hash @@ -0,0 +1 @@ +f0d75976c0469b0e diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/functions-for-nulls.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/functions-for-nulls.md index 304d283b1b7..5fd2385093e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/functions-for-nulls.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/functions-for-nulls.md @@ -1,154 +1,255 @@ --- -'description': '处理 Nullable 值的函数的文档' +'description': '处理 nullable 值的函数的文档' 'sidebar_label': 'Nullable' -'sidebar_position': 135 'slug': '/sql-reference/functions/functions-for-nulls' -'title': '处理 Nullable 值的函数' +'title': '处理 nullable 值的函数' +'keywords': +- 'nullable' +- 'functions' +'doc_type': 'reference' --- -# 函数用于处理 Nullable 值 +# 处理可为NULL值的函数 -## isNull {#isnull} + + + +## assumeNotNull {#assumeNotNull} -返回参数是否为 [NULL](../../sql-reference/syntax.md#null)。 +引入于:v1.1 -另见操作符 [`IS NULL`](../operators/index.md#is_null)。 + +返回 [`Nullable`](../data-types/nullable.md) 类型值对应的非`Nullable`值。 +如果原始值为`NULL`,则可以返回任意结果。 + +另请参见:函数 [`ifNull`](#ifNull) 和 [`coalesce`](#coalesce)。 + **语法** ```sql -isNull(x) +assumeNotNull(x) ``` -别名: `ISNULL`。 - **参数** -- `x` — 非复合数据类型的值。 +- `x` — 任何可为NULL类型的原始值。[`Nullable(T)`](/sql-reference/data-types/nullable) + **返回值** -- 如果 `x` 是 `NULL`,则返回 `1`。 -- 如果 `x` 不是 `NULL`,则返回 `0`。 +如果原始值不是`NULL`,则返回非空值;如果输入值为`NULL`,则返回任意值。[`Any`](/sql-reference/data-types) **示例** -表: +**使用示例** + +```sql title=Query +CREATE TABLE t_null (x Int8, y Nullable(Int8)) +ENGINE=MergeTree() +ORDER BY x; -```text -┌─x─┬────y─┐ -│ 1 │ ᴺᵁᴸᴸ │ -│ 2 │ 3 │ -└───┴──────┘ +INSERT INTO t_null VALUES (1, NULL), (2, 3); + +SELECT assumeNotNull(y) FROM table; +SELECT toTypeName(assumeNotNull(y)) FROM t_null; ``` -查询: +```response title=Response +┌─assumeNotNull(y)─┐ +│ 0 │ +│ 3 │ +└──────────────────┘ +┌─toTypeName(assumeNotNull(y))─┐ +│ Int8 │ +│ Int8 │ +└──────────────────────────────┘ +``` + + + +## coalesce {#coalesce} + +引入于:v1.1 + + +返回最左侧的非`NULL`参数。 + + +**语法** ```sql -SELECT x FROM t_null WHERE isNull(y); +coalesce(x[, y, ...]) ``` -结果: +**参数** -```text -┌─x─┐ -│ 1 │ -└───┘ +- `x[, y, ...]` — 任何数量的非复合类型参数。所有参数必须是相互兼容的数据类型。[ `Any`](/sql-reference/data-types) + + +**返回值** + +返回第一个非`NULL`参数;如果所有参数均为`NULL`,则返回`NULL`。[ `Any`](/sql-reference/data-types) 或 [`NULL`](/sql-reference/syntax#null) + +**示例** + +**使用示例** + +```sql title=Query +-- Consider a list of contacts that may specify multiple ways to contact a customer. + +CREATE TABLE aBook +( + name String, + mail Nullable(String), + phone Nullable(String), + telegram Nullable(UInt32) +) +ENGINE = MergeTree +ORDER BY tuple(); + +INSERT INTO aBook VALUES ('client 1', NULL, '123-45-67', 123), ('client 2', NULL, NULL, NULL); + +-- The mail and phone fields are of type String, but the telegram field is UInt32 so it needs to be converted to String. + +-- Get the first available contact method for the customer from the contact list + +SELECT name, coalesce(mail, phone, CAST(telegram,'Nullable(String)')) FROM aBook; ``` -## isNullable {#isnullable} +```response title=Response +┌─name─────┬─coalesce(mail, phone, CAST(telegram, 'Nullable(String)'))─┐ +│ client 1 │ 123-45-67 │ +│ client 2 │ ᴺᵁᴸᴸ │ +└──────────┴───────────────────────────────────────────────────────────┘ +``` + + + +## firstNonDefault {#firstNonDefault} + +引入于:v25.9 -如果列是 [Nullable](../data-types/nullable.md)(即允许 `NULL` 值),返回 `1`;否则返回 `0`。 +返回一组参数中的第一个非默认值 **语法** ```sql -isNullable(x) + ``` **参数** -- `x` — 列。 +- `arg1` — 第一个要检查的参数 - `arg2` — 第二个要检查的参数 - `...` — 其他要检查的参数 **返回值** -- 如果 `x` 允许 `NULL` 值,则返回 `1`。[UInt8](../data-types/int-uint.md)。 -- 如果 `x` 不允许 `NULL` 值,则返回 `0`。[UInt8](../data-types/int-uint.md)。 +结果类型为所有参数的超类型 **示例** -查询: +**整数** -```sql -CREATE TABLE tab (ordinary_col UInt32, nullable_col Nullable(UInt32)) ENGINE = Log; -INSERT INTO tab (ordinary_col, nullable_col) VALUES (1,1), (2, 2), (3,3); -SELECT isNullable(ordinary_col), isNullable(nullable_col) FROM tab; +```sql title=Query +SELECT firstNonDefault(0, 1, 2) +``` + +```response title=Response +1 ``` -结果: +**字符串** -```text - ┌───isNullable(ordinary_col)──┬───isNullable(nullable_col)──┐ -1. │ 0 │ 1 │ -2. │ 0 │ 1 │ -3. │ 0 │ 1 │ - └─────────────────────────────┴─────────────────────────────┘ +```sql title=Query +SELECT firstNonDefault('', 'hello', 'world') ``` -## isNotNull {#isnotnull} +```response title=Response +'hello' +``` + +**空值** + +```sql title=Query +SELECT firstNonDefault(NULL, 0 :: UInt8, 1 :: UInt8) +``` + +```response title=Response +1 +``` + +**可为NULL的零** + +```sql title=Query +SELECT firstNonDefault(NULL, 0 :: Nullable(UInt8), 1 :: Nullable(UInt8)) +``` + +```response title=Response +0 +``` + + -返回参数是否不是 [NULL](/operations/settings/formats#input_format_null_as_default)。 +## ifNull {#ifNull} -另见操作符 [`IS NOT NULL`](../operators/index.md#is_not_null)。 +引入于:v1.1 + + +如果第一个参数为`NULL`,则返回一个替代值。 + + +**语法** ```sql -isNotNull(x) +ifNull(x, alt) ``` -**参数:** +**参数** + +- `x` — 要检查是否为`NULL`的值。[ `Any`](/sql-reference/data-types) +- `alt` — 如果`x`为`NULL`,该函数返回的值。[ `Any`](/sql-reference/data-types) -- `x` — 非复合数据类型的值。 **返回值** -- 如果 `x` 不是 `NULL`,则返回 `1`。 -- 如果 `x` 是 `NULL`,则返回 `0`。 +如果`x`不为`NULL`,则返回`x`的值;否则返回`alt`。[ `Any`](/sql-reference/data-types) **示例** -表: +**使用示例** -```text -┌─x─┬────y─┐ -│ 1 │ ᴺᵁᴸᴸ │ -│ 2 │ 3 │ -└───┴──────┘ +```sql title=Query +SELECT ifNull('a', 'b'), ifNull(NULL, 'b'); ``` -查询: - -```sql -SELECT x FROM t_null WHERE isNotNull(y); +```response title=Response +┌─ifNull('a', 'b')─┬─ifNull(NULL, 'b')─┐ +│ a │ b │ +└──────────────────┴───────────────────┘ ``` -结果: -```text -┌─x─┐ -│ 2 │ -└───┘ -``` -## isNotDistinctFrom {#isnotdistinctfrom} +## isNotDistinctFrom {#isNotDistinctFrom} + +引入于:v23.8 + -执行 null 安全比较。用于比较 JOIN ON 部分中包含 NULL 值的 JOIN 键。 -该函数会将两个 `NULL` 值视为相同,并返回 `true`,这与常规的相等行为不同,后者比较两个 `NULL` 值会返回 `NULL`。 +执行两个`JOIN`键之间的空安全比较。该函数会将两个`NULL`值视为相同,并返回`true`,这与通常的相等行为不同,通常比较两个`NULL`值会返回`NULL`。 -:::note -此函数是 JOIN ON 实现中使用的内部函数。请勿在查询中手动使用。 +:::info +该函数是`JOIN ON`实现中使用的内部函数。 +请勿在查询中手动使用。 ::: +有关完整示例,请参见:[ `JOIN` 键中的 `NULL` 值](/sql-reference/statements/select/join#null-values-in-join-keys)。 + + **语法** ```sql @@ -157,310 +258,295 @@ isNotDistinctFrom(x, y) **参数** -- `x` — 第一个 JOIN 键。 -- `y` — 第二个 JOIN 键。 +- `x` — 第一个要比较的`JOIN`键。[ `Any`](/sql-reference/data-types) +- `y` — 第二个要比较的`JOIN`键。[ `Any`](/sql-reference/data-types) + **返回值** -- 当 `x` 和 `y` 都为 `NULL` 时返回 `true`。 -- 否则返回 `false`。 +当`x`和`y`均为`NULL`时返回`true`,否则返回`false`。[ `Bool`](/sql-reference/data-types/boolean) **示例** -完整示例见:[JOIN 键中的 NULL 值](../../sql-reference/statements/select/join#null-values-in-join-keys)。 -## isZeroOrNull {#iszeroornull} -返回参数是否为 0(零)或 [NULL](/operations/settings/formats#input_format_null_as_default)。 +## isNotNull {#isNotNull} + +引入于:v1.1 + + +检查参数是否不为`NULL`。 + +另请参见:运算符 [`IS NOT NULL`](/sql-reference/operators#is_not_null)。 + + +**语法** ```sql -isZeroOrNull(x) +isNotNull(x) ``` -**参数:** +**参数** + +- `x` — 非复合数据类型的值。[ `Any`](/sql-reference/data-types) -- `x` — 非复合数据类型的值。 **返回值** -- 如果 `x` 是 0(零)或 `NULL`,则返回 `1`。 -- 否则返回 `0`。 +如果`x`不为`NULL`,则返回`1`;否则返回`0`。[ `UInt8`](/sql-reference/data-types/int-uint) **示例** -表: +**使用示例** -```text -┌─x─┬────y─┐ -│ 1 │ ᴺᵁᴸᴸ │ -│ 2 │ 0 │ -│ 3 │ 3 │ -└───┴──────┘ -``` +```sql title=Query +CREATE TABLE t_null +( + x Int32, + y Nullable(Int32) +) +ENGINE = MergeTree +ORDER BY tuple(); -查询: +INSERT INTO t_null VALUES (1, NULL), (2, 3); -```sql -SELECT x FROM t_null WHERE isZeroOrNull(y); +SELECT x FROM t_null WHERE isNotNull(y); ``` -结果: - -```text +```response title=Response ┌─x─┐ -│ 1 │ │ 2 │ └───┘ ``` -## coalesce {#coalesce} -返回最左边的非 `NULL` 参数。 + +## isNull {#isNull} + +引入于:v1.1 + + +检查参数是否为`NULL`。 + +另请参见:运算符 [`IS NULL`](/sql-reference/operators#is_null)。 + + +**语法** ```sql -coalesce(x,...) +isNull(x) ``` -**参数:** +**参数** + +- `x` — 非复合数据类型的值。[ `Any`](/sql-reference/data-types) -- 任何数量的非复合类型参数。所有参数必须是相互兼容的数据类型。 **返回值** -- 第一个非 `NULL` 参数 -- 如果所有参数都是 `NULL`,则返回 `NULL`。 +如果`x`为`NULL`,则返回`1`;否则返回`0`。[ `UInt8`](/sql-reference/data-types/int-uint) **示例** -考虑一个可能指定多种方式与客户联系的联系方式列表。 +**使用示例** -```text -┌─name─────┬─mail─┬─phone─────┬──telegram─┐ -│ client 1 │ ᴺᵁᴸᴸ │ 123-45-67 │ 123 │ -│ client 2 │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ -└──────────┴──────┴───────────┴───────────┘ -``` +```sql title=Query +CREATE TABLE t_null +( + x Int32, + y Nullable(Int32) +) +ENGINE = MergeTree +ORDER BY tuple(); -`mail` 和 `phone` 字段为 String 类型,但 `telegram` 字段是 `UInt32`,因此需要转换为 String。 +INSERT INTO t_null VALUES (1, NULL), (2, 3); -从联系方式列表中获取客户的第一个可用联系方式: - -```sql -SELECT name, coalesce(mail, phone, CAST(telegram,'Nullable(String)')) FROM aBook; +SELECT x FROM t_null WHERE isNull(y); ``` -```text -┌─name─────┬─coalesce(mail, phone, CAST(telegram, 'Nullable(String)'))─┐ -│ client 1 │ 123-45-67 │ -│ client 2 │ ᴺᵁᴸᴸ │ -└──────────┴───────────────────────────────────────────────────────────┘ +```response title=Response +┌─x─┐ +│ 1 │ +└───┘ ``` -## ifNull {#ifnull} -如果参数为 `NULL`,则返回备用值。 + +## isNullable {#isNullable} + +引入于:v22.7 + + +检查参数的数据类型是否为`Nullable`(即是否允许`NULL`值)。 + + +**语法** ```sql -ifNull(x, alt) +isNullable(x) ``` -**参数:** +**参数** + +- `x` — 任何数据类型的值。[ `Any`](/sql-reference/data-types) -- `x` — 要检查 `NULL` 的值。 -- `alt` — 如果 `x` 为 `NULL`,则函数返回的值。 **返回值** -- 如果 `x` 不是 `NULL`,则返回 `x`。 -- 如果 `x` 是 `NULL`,则返回 `alt`。 +如果`x`的数据类型为`Nullable`,则返回`1`;否则返回`0`。[ `UInt8`](/sql-reference/data-types/int-uint) **示例** -查询: +**使用示例** -```sql -SELECT ifNull('a', 'b'); +```sql title=Query +CREATE TABLE tab ( + ordinary_col UInt32, + nullable_col Nullable(UInt32) +) +ENGINE = MergeTree +ORDER BY tuple(); +INSERT INTO tab (ordinary_col, nullable_col) VALUES (1,1), (2, 2), (3,3); +SELECT isNullable(ordinary_col), isNullable(nullable_col) FROM tab; ``` -结果: - -```text -┌─ifNull('a', 'b')─┐ -│ a │ -└──────────────────┘ +```response title=Response +┌───isNullable(ordinary_col)──┬───isNullable(nullable_col)──┐ +│ 0 │ 1 │ +│ 0 │ 1 │ +│ 0 │ 1 │ +└─────────────────────────────┴─────────────────────────────┘ ``` -查询: -```sql -SELECT ifNull(NULL, 'b'); -``` -结果: +## isZeroOrNull {#isZeroOrNull} + +引入于:v20.3 -```text -┌─ifNull(NULL, 'b')─┐ -│ b │ -└───────────────────┘ -``` -## nullIf {#nullif} +检查参数是否为零(`0`)或`NULL`。 + -如果两个参数相等,则返回 `NULL`。 +**语法** ```sql -nullIf(x, y) +isZeroOrNull(x) ``` -**参数:** +**参数** + +- `x` — 数值。[ `UInt`](/sql-reference/data-types/int-uint) -`x`,`y` — 要比较的值。必须是兼容的类型。 **返回值** -- 如果参数相等,则返回 `NULL`。 -- 如果参数不相等,则返回 `x`。 +如果`x`为`NULL`或等于零,则返回`1`;否则返回`0`。[ `UInt8/16/32/64`](/sql-reference/data-types/int-uint) 或 [`Float32/Float64`](/sql-reference/data-types/float) **示例** -查询: +**使用示例** -```sql -SELECT nullIf(1, 1); -``` +```sql title=Query +CREATE TABLE t_null +( + x Int32, + y Nullable(Int32) +) +ENGINE = MergeTree +ORDER BY tuple(); -结果: +INSERT INTO t_null VALUES (1, NULL), (2, 0), (3, 3); -```text -┌─nullIf(1, 1)─┐ -│ ᴺᵁᴸᴸ │ -└──────────────┘ +SELECT x FROM t_null WHERE isZeroOrNull(y); ``` -查询: - -```sql -SELECT nullIf(1, 2); +```response title=Response +┌─x─┐ +│ 1 │ +│ 2 │ +└───┘ ``` -结果: -```text -┌─nullIf(1, 2)─┐ -│ 1 │ -└──────────────┘ -``` -## assumeNotNull {#assumenotnull} +## nullIf {#nullIf} + +引入于:v1.1 -返回 [Nullable](../data-types/nullable.md) 类型值的相应非 `Nullable` 值。如果原始值为 `NULL`,则可以返回任意结果。另见函数 `ifNull` 和 `coalesce`。 + +如果两个参数相等,则返回`NULL`。 + + +**语法** ```sql -assumeNotNull(x) +nullIf(x, y) ``` -**参数:** +**参数** + +- `x` — 第一个值。[ `Any`](/sql-reference/data-types) +- `y` — 第二个值。[ `Any`](/sql-reference/data-types) -- `x` — 原始值。 **返回值** -- 如果输入值不是 `NULL`,则以非 `Nullable` 类型返回输入值。 -- 如果输入值为 `NULL`,则返回一个任意值。 +如果两个参数相等,则返回`NULL`,否则返回第一个参数。[ `NULL`](/sql-reference/syntax#null) 或 [`Nullable(x)`](/sql-reference/data-types/nullable) **示例** -表: +**使用示例** -```text - -┌─x─┬────y─┐ -│ 1 │ ᴺᵁᴸᴸ │ -│ 2 │ 3 │ -└───┴──────┘ +```sql title=Query +SELECT nullIf(1, 1), nullIf(1, 2); ``` -查询: - -```sql -SELECT assumeNotNull(y) FROM table; +```response title=Response +┌─nullIf(1, 1)─┬─nullIf(1, 2)─┐ +│ ᴺᵁᴸᴸ │ 1 │ +└──────────────┴──────────────┘ ``` -结果: - -```text -┌─assumeNotNull(y)─┐ -│ 0 │ -│ 3 │ -└──────────────────┘ -``` -查询: -```sql -SELECT toTypeName(assumeNotNull(y)) FROM t_null; -``` +## toNullable {#toNullable} -结果: +引入于:v1.1 -```text -┌─toTypeName(assumeNotNull(y))─┐ -│ Int8 │ -│ Int8 │ -└──────────────────────────────┘ -``` -## toNullable {#tonullable} +将提供的参数类型转换为`Nullable`。 + -将参数类型转换为 `Nullable`。 +**语法** ```sql toNullable(x) ``` -**参数:** +**参数** + +- `x` — 任何非复合类型的值。[ `Any`](/sql-reference/data-types) -- `x` — 非复合类型的值。 **返回值** -- 输入值,但为 `Nullable` 类型。 +返回输入值但为`Nullable`类型。[ `Nullable(Any)`](/sql-reference/data-types/nullable) **示例** -查询: +**使用示例** -```sql -SELECT toTypeName(10); +```sql title=Query +SELECT toTypeName(10), toTypeName(toNullable(10)); ``` -结果: - -```text -┌─toTypeName(10)─┐ -│ UInt8 │ -└────────────────┘ +```response title=Response +┌─toTypeName(10)─┬─toTypeName(toNullable(10))─┐ +│ UInt8 │ Nullable(UInt8) │ +└────────────────┴────────────────────────────┘ ``` -查询: - -```sql -SELECT toTypeName(toNullable(10)); -``` -结果: -```text -┌─toTypeName(toNullable(10))─┐ -│ Nullable(UInt8) │ -└────────────────────────────┘ -``` - - - - diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/functions-for-nulls.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/functions-for-nulls.md.hash index b4e3e761164..118ee325cba 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/functions-for-nulls.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/functions-for-nulls.md.hash @@ -1 +1 @@ -018f21702d3cbf18 +aeda9113d97adc7b diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/geo/coordinates.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/geo/coordinates.md index 4ac9c8132eb..83fdcc0594c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/geo/coordinates.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/geo/coordinates.md @@ -1,14 +1,14 @@ --- -'description': 'Documentation for Coordinates' +'description': 'Coordinates 的文档' 'sidebar_label': '地理坐标' -'sidebar_position': 62 'slug': '/sql-reference/functions/geo/coordinates' 'title': '处理地理坐标的函数' +'doc_type': 'reference' --- ## greatCircleDistance {#greatcircledistance} -计算地球表面两个点之间的距离,使用[大圆公式](https://en.wikipedia.org/wiki/Great-circle_distance)。 +计算地球表面两个点之间的距离,使用 [大圆公式](https://en.wikipedia.org/wiki/Great-circle_distance)。 ```sql greatCircleDistance(lon1Deg, lat1Deg, lon2Deg, lat2Deg) @@ -16,18 +16,18 @@ greatCircleDistance(lon1Deg, lat1Deg, lon2Deg, lat2Deg) **输入参数** -- `lon1Deg` — 第一个点的经度(单位:度),范围:`[-180°, 180°]`。 -- `lat1Deg` — 第一个点的纬度(单位:度),范围:`[-90°, 90°]`。 -- `lon2Deg` — 第二个点的经度(单位:度),范围:`[-180°, 180°]`。 -- `lat2Deg` — 第二个点的纬度(单位:度),范围:`[-90°, 90°]`。 +- `lon1Deg` — 第一个点的经度(单位:度)。范围: `[-180°, 180°]`。 +- `lat1Deg` — 第一个点的纬度(单位:度)。范围: `[-90°, 90°]`。 +- `lon2Deg` — 第二个点的经度(单位:度)。范围: `[-180°, 180°]`。 +- `lat2Deg` — 第二个点的纬度(单位:度)。范围: `[-90°, 90°]`。 -正值对应于北纬和东经,负值对应于南纬和西经。 +正值对应北纬和东经,负值对应南纬和西经。 **返回值** -地球表面两个点之间的距离,单位为米。 +地球表面两个点之间的距离,单位:米。 -当输入参数值超出范围时,会生成异常。 +当输入参数的值超出范围时,将生成异常。 **示例** @@ -43,10 +43,10 @@ SELECT greatCircleDistance(55.755831, 37.617673, -55.755831, -37.617673) AS grea ## geoDistance {#geodistance} -类似于 `greatCircleDistance`,但计算 WGS-84 椭球体上的距离,而不是球面。这是对地球大地体的更精确的近似。 +与 `greatCircleDistance` 类似,但计算 WGS-84 椭球体上的距离,而不是球体。这个方法对地球地球体的近似更加精确。 性能与 `greatCircleDistance` 相同(没有性能缺陷)。建议使用 `geoDistance` 来计算地球上的距离。 -技术说明:对于足够接近的点,我们使用切平面上的度量,通过坐标中点的平面近似计算距离。 +技术说明:对于足够接近的点,我们使用在坐标中点的切平面上的度量来计算距离。 ```sql geoDistance(lon1Deg, lat1Deg, lon2Deg, lat2Deg) @@ -54,18 +54,18 @@ geoDistance(lon1Deg, lat1Deg, lon2Deg, lat2Deg) **输入参数** -- `lon1Deg` — 第一个点的经度(单位:度),范围:`[-180°, 180°]`。 -- `lat1Deg` — 第一个点的纬度(单位:度),范围:`[-90°, 90°]`。 -- `lon2Deg` — 第二个点的经度(单位:度),范围:`[-180°, 180°]`。 -- `lat2Deg` — 第二个点的纬度(单位:度),范围:`[-90°, 90°]`。 +- `lon1Deg` — 第一个点的经度(单位:度)。范围: `[-180°, 180°]`。 +- `lat1Deg` — 第一个点的纬度(单位:度)。范围: `[-90°, 90°]`。 +- `lon2Deg` — 第二个点的经度(单位:度)。范围: `[-180°, 180°]`。 +- `lat2Deg` — 第二个点的纬度(单位:度)。范围: `[-90°, 90°]`。 -正值对应于北纬和东经,负值对应于南纬和西经。 +正值对应北纬和东经,负值对应南纬和西经。 **返回值** -地球表面两个点之间的距离,单位为米。 +地球表面两个点之间的距离,单位:米。 -当输入参数值超出范围时,会生成异常。 +当输入参数的值超出范围时,将生成异常。 **示例** @@ -81,7 +81,7 @@ SELECT geoDistance(38.8976, -77.0366, 39.9496, -75.1503) AS geoDistance ## greatCircleAngle {#greatcircleangle} -计算地球表面两个点之间的中心角,使用[大圆公式](https://en.wikipedia.org/wiki/Great-circle_distance)。 +计算地球表面两个点之间的中心角,使用 [大圆公式](https://en.wikipedia.org/wiki/Great-circle_distance)。 ```sql greatCircleAngle(lon1Deg, lat1Deg, lon2Deg, lat2Deg) @@ -112,8 +112,8 @@ SELECT greatCircleAngle(0, 0, 45, 0) AS arc ## pointInEllipses {#pointinellipses} -检查点是否属于至少一个椭圆。 -坐标在笛卡尔坐标系中是几何的。 +检查一个点是否属于至少一个椭圆。 +坐标为笛卡尔坐标系统中的几何坐标。 ```sql pointInEllipses(x, y, x₀, y₀, a₀, b₀,...,xₙ, yₙ, aₙ, bₙ) @@ -123,13 +123,13 @@ pointInEllipses(x, y, x₀, y₀, a₀, b₀,...,xₙ, yₙ, aₙ, bₙ) - `x, y` — 平面上点的坐标。 - `xᵢ, yᵢ` — 第 `i` 个椭圆的中心坐标。 -- `aᵢ, bᵢ` — 第 `i` 个椭圆的长短轴(单位:x, y 坐标)。 +- `aᵢ, bᵢ` — 第 `i` 个椭圆的轴长,以 x, y 坐标单位表示。 输入参数的数量必须为 `2+4⋅n`,其中 `n` 是椭圆的数量。 **返回值** -如果点在至少一个椭圆内,返回 `1`;如果不在,返回 `0`。 +如果点在至少一个椭圆内,则返回 `1`;如果不在,则返回 `0`。 **示例** @@ -145,7 +145,7 @@ SELECT pointInEllipses(10., 10., 10., 9.1, 1., 0.9999) ## pointInPolygon {#pointinpolygon} -检查点是否属于平面上的多边形。 +检查一个点是否属于平面上的多边形。 ```sql pointInPolygon((x, y), [(a, b), (c, d) ...], ...) @@ -153,13 +153,14 @@ pointInPolygon((x, y), [(a, b), (c, d) ...], ...) **输入值** -- `(x, y)` — 平面上点的坐标。数据类型 — [Tuple](../../data-types/tuple.md) — 包含两个数字的元组。 -- `[(a, b), (c, d) ...]` — 多边形的顶点。数据类型 — [Array](../../data-types/array.md)。每个顶点由一对坐标 `(a, b)` 表示。顶点应按顺时针或逆时针顺序指定。顶点的最小数量为 3。多边形必须是常数。 -- 此函数还支持带有孔(切割出的部分)的多边形。在这种情况下,使用函数的附加参数添加定义切割部分的多边形。此函数不支持非简单连通的多边形。 +- `(x, y)` — 点的坐标。数据类型 — [Tuple](../../data-types/tuple.md) — 一对数字的元组。 +- `[(a, b), (c, d) ...]` — 多边形的顶点。数据类型 — [Array](../../data-types/array.md)。每个顶点由坐标对 `(a, b)` 表示。顶点应按顺时针或逆时针顺序指定。顶点的最少数量为 3。多边形必须是常量。 +- 该函数支持具有孔(切割部分)的多边形。数据类型 — [Polygon](../../data-types/geo.md/#polygon)。可以将整个 `Polygon` 作为第二个参数传递,或者先传递外环,然后将每个孔作为单独的额外参数传递。 +- 该函数还支持多重多边形。数据类型 — [MultiPolygon](../../data-types/geo.md/#multipolygon)。可以将整个 `MultiPolygon` 作为第二个参数传递,或者将每个组成多边形列为它自己的参数。 **返回值** -如果点在多边形内,返回 `1`;如果不在,返回 `0`。 +如果点在多边形内,则返回 `1`;如果不在,则返回 `0`。 如果点在多边形边界上,函数可能返回 0 或 1。 **示例** @@ -173,3 +174,7 @@ SELECT pointInPolygon((3., 3.), [(6, 0), (8, 4), (5, 8), (0, 2)]) AS res │ 1 │ └─────┘ ``` + +> **注意** +> • 您可以设置 `validate_polygons = 0` 来绕过几何验证。 +> • `pointInPolygon` 假定每个多边形格式良好。如果输入为自交、多环顺序错误或边重叠,则结果可能不可靠,尤其是对于恰好位于边上、顶点上或位于自交处的点,“内部”与“外部”的概念未定义。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/geo/coordinates.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/geo/coordinates.md.hash index f3272ec1652..2a015ce10a1 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/geo/coordinates.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/geo/coordinates.md.hash @@ -1 +1 @@ -6379f74807e49d26 +bc439bdfb10472bc diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/geo/geohash.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/geo/geohash.md index 6729737d547..384a4180221 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/geo/geohash.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/geo/geohash.md @@ -3,13 +3,14 @@ 'sidebar_label': 'Geohash' 'slug': '/sql-reference/functions/geo/geohash' 'title': '处理 Geohash 的函数' +'doc_type': 'reference' --- ## Geohash {#geohash} -[Geohash](https://en.wikipedia.org/wiki/Geohash) 是一种地理编码系统,它将地球表面细分为网格形状的桶,并将每个单元编码为一个简短的字母和数字字符串。它是一种层次数据结构,因此 geohash 字符串越长,地理位置的精确度就越高。 +[Geohash](https://en.wikipedia.org/wiki/Geohash) 是一种地理编码系统,它将地球表面划分为网格状的区域,并将每个单元编码为一串简短的字母和数字。它是一种层次数据结构,因此 geohash 字符串越长,地理位置的精度就越高。 -如果您需要手动将地理坐标转换为 geohash 字符串,可以使用 [geohash.org](http://geohash.org/)。 +如果您需要手动将地理坐标转换为 geohash 字符串,可以使用 [geohash.org](http://geohash.co/) ## geohashEncode {#geohashencode} @@ -23,18 +24,18 @@ geohashEncode(longitude, latitude, [precision]) **输入值** -- `longitude` — 您要编码的坐标的经度部分。范围为 `[-180°, 180°]` 的浮点数。[Float](../../data-types/float.md)。 -- `latitude` — 您要编码的坐标的纬度部分。范围为 `[-90°, 90°]` 的浮点数。[Float](../../data-types/float.md)。 -- `precision` (可选) — 生成的编码字符串的长度。默认为 `12`。范围为 `[1, 12]` 的整数。[Int8](../../data-types/int-uint.md)。 +- `longitude` — 您想编码的坐标的经度部分。范围为 `[-180°, 180°]` 的浮点数。 [Float](../../data-types/float.md)。 +- `latitude` — 您想编码的坐标的纬度部分。范围为 `[-90°, 90°]` 的浮点数。 [Float](../../data-types/float.md)。 +- `precision`(可选) — 结果编码字符串的长度。默认为 `12`。范围为 `[1, 12]` 的整数。 [Int8](../../data-types/int-uint.md)。 :::note -- 所有坐标参数必须为相同类型:`Float32` 或 `Float64`。 -- 对于 `precision` 参数,少于 `1` 或大于 `12` 的任何值将被静默转换为 `12`。 +- 所有坐标参数必须为相同类型:要么是 `Float32`,要么是 `Float64`。 +- 对于 `precision` 参数,任何小于 `1` 或大于 `12` 的值都会默默转换为 `12`。 ::: **返回值** -- 编码坐标的字母数字字符串(使用修改版的 base32 编码字母表)。[String](../../data-types/string.md)。 +- 编码坐标的字母数字字符串(使用修改版本的 base32 编码字母表)。 [String](../../data-types/string.md)。 **示例** @@ -68,7 +69,7 @@ geohashDecode(hash_str) **返回值** -- 由 `Float64` 类型的经度和纬度组成的元组 `(longitude, latitude)`。[Tuple](../../data-types/tuple.md)([Float64](../../data-types/float.md)) +- 包含经度和纬度的 `Float64` 值的元组 `(longitude, latitude)`。 [Tuple](../../data-types/tuple.md)([Float64](../../data-types/float.md)) **示例** @@ -84,7 +85,7 @@ SELECT geohashDecode('ezs42') AS res; ## geohashesInBox {#geohashesinbox} -返回给定精度内的 [geohash](#geohash) 编码字符串数组,这些字符串落在并相交于给定区域的边界,基本上是展平为数组的 2D 网格。 +返回给定精度的 [geohash](#geohash) 编码字符串的数组,这些字符串位于指定区域的内部并与边界相交,基本上是一个被压缩为数组的二维网格。 **语法** @@ -94,23 +95,23 @@ geohashesInBox(longitude_min, latitude_min, longitude_max, latitude_max, precisi **参数** -- `longitude_min` — 最小经度。范围: `[-180°, 180°]`。[Float](../../data-types/float.md)。 -- `latitude_min` — 最小纬度。范围: `[-90°, 90°]`。[Float](../../data-types/float.md)。 -- `longitude_max` — 最大经度。范围: `[-180°, 180°]`。[Float](../../data-types/float.md)。 -- `latitude_max` — 最大纬度。范围: `[-90°, 90°]`。[Float](../../data-types/float.md)。 -- `precision` — Geohash 精度。范围: `[1, 12]`。[UInt8](../../data-types/int-uint.md)。 +- `longitude_min` — 最小经度。范围:`[-180°, 180°]`。 [Float](../../data-types/float.md)。 +- `latitude_min` — 最小纬度。范围:`[-90°, 90°]`。 [Float](../../data-types/float.md)。 +- `longitude_max` — 最大经度。范围:`[-180°, 180°]`。 [Float](../../data-types/float.md)。 +- `latitude_max` — 最大纬度。范围:`[-90°, 90°]`。 [Float](../../data-types/float.md)。 +- `precision` — Geohash 精度。范围:`[1, 12]`。 [UInt8](../../data-types/int-uint.md)。 :::note -所有坐标参数必须为相同类型:`Float32` 或 `Float64`。 +所有坐标参数必须为相同类型:要么是 `Float32`,要么是 `Float64`。 ::: **返回值** -- 覆盖提供区域的精度长的 geohash-boxes 字符串数组,您不应依赖项的顺序。[Array](../../data-types/array.md)([String](../../data-types/string.md))。 -- `[]` - 如果最小纬度和经度值不小于相应的最大值,则返回空数组。 +- 包含所提供区域的 geohash-boxes 的精度长字符串数组,您不应依赖于项目的顺序。 [Array](../../data-types/array.md)([String](../../data-types/string.md))。 +- `[]` - 如果最小纬度和经度值不小于相应的最大值,返回空数组。 :::note -如果结果数组超过 10'000'000 项,函数将抛出异常。 +如果结果数组超过 10,000,000 项,函数将抛出异常。 ::: **示例** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/geo/geohash.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/geo/geohash.md.hash index 4fb1ad0ae3f..8bbf7a98a30 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/geo/geohash.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/geo/geohash.md.hash @@ -1 +1 @@ -4ad8e464b6d4f81f +00dbae8572012c5b diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/geo/h3.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/geo/h3.md index 13c1e6f4329..6652e8907c4 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/geo/h3.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/geo/h3.md @@ -1,25 +1,27 @@ --- -'description': 'H3 文档' +'description': 'H3 的文档' 'sidebar_label': 'H3 索引' 'slug': '/sql-reference/functions/geo/h3' -'title': '处理 H3 索引的函数' +'title': '用于处理 H3 索引的函数' +'doc_type': 'reference' --- + ## H3 索引 {#h3-index} -[H3](https://eng.uber.com/h3/) 是一种地理索引系统,其中地球表面被划分为均匀的六角形单元格网格。该系统是分层的,即每个顶层的六角形("父级")可以分割成七个相等但较小的六角形("子级"),依此类推。 +[H3](https://eng.uber.com/h3/) 是一种地理编码系统,地球表面被划分为均匀的六边形网格。该系统是分层的,即每个顶层的六边形(“父级”)可以分割成七个均匀但更小的六边形(“子级”),依此类推。 -层级的级别称为 `resolution`,可以取值从 `0` 到 `15`,其中 `0` 是具有最大和最粗糙单元格的 `base` 级别。 +层次的级别称为 `resolution`,可以取值从 `0` 到 `15`,其中 `0` 是具有最大和粗糙单元的 `base` 层级。 -经纬度对可以转换为 64 位 H3 索引,用于识别一个网格单元格。 +一个纬度和经度的组合可以转换为一个 64 位的 H3 索引,用以标识一个网格单元。 -H3 索引主要用于对位置进行分桶和其他地理空间操作。 +H3 索引用于主要的地点分组及其他地理空间操作。 -H3 系统的完整描述可在 [Uber Engineering 网站](https://eng.uber.com/h3/) 上找到。 +H3 系统的完整介绍,请访问 [Uber 工程网站](https://eng.uber.com/h3/)。 ## h3IsValid {#h3isvalid} -验证该数字是否是有效的 [H3](#h3-index) 索引。 +验证该数字是否为有效的 [H3](#h3-index) 索引。 **语法** @@ -29,7 +31,7 @@ h3IsValid(h3index) **参数** -- `h3index` — 六角形索引编号。 [UInt64](../../data-types/int-uint.md)。 +- `h3index` — 六边形索引编号。 [UInt64](../../data-types/int-uint.md)。 **返回值** @@ -54,7 +56,7 @@ SELECT h3IsValid(630814730351855103) AS h3IsValid; ## h3GetResolution {#h3getresolution} -定义给定 [H3](#h3-index) 索引的分辨率。 +定义给定的 [H3](#h3-index) 索引的分辨率。 **语法** @@ -64,12 +66,12 @@ h3GetResolution(h3index) **参数** -- `h3index` — 六角形索引编号。 [UInt64](../../data-types/int-uint.md)。 +- `h3index` — 六边形索引编号。 [UInt64](../../data-types/int-uint.md)。 **返回值** -- 索引分辨率。范围:`[0, 15]`。 [UInt8](../../data-types/int-uint.md)。 -- 如果索引无效,函数将返回随机值。使用 [h3IsValid](#h3isvalid) 验证索引。 [UInt8](../../data-types/int-uint.md)。 +- 索引分辨率。范围: `[0, 15]`。 [UInt8](../../data-types/int-uint.md)。 +- 如果索引无效,函数返回随机值。使用 [h3IsValid](#h3isvalid) 验证索引。 [UInt8](../../data-types/int-uint.md)。 **示例** @@ -89,7 +91,7 @@ SELECT h3GetResolution(639821929606596015) AS resolution; ## h3EdgeAngle {#h3edgeangle} -计算 [H3](#h3-index) 六角形边的平均长度(以度数表示)。 +计算 [H3](#h3-index) 六边形边的平均长度(单位为度)。 **语法** @@ -99,11 +101,11 @@ h3EdgeAngle(resolution) **参数** -- `resolution` — 索引分辨率。 [UInt8](../../data-types/int-uint.md)。范围:`[0, 15]`。 +- `resolution` — 索引分辨率。 [UInt8](../../data-types/int-uint.md)。范围: `[0, 15]`。 **返回值** -- [H3](#h3-index) 六角形边的平均长度(以度数表示)。 [Float64](../../data-types/float.md)。 +- [H3](#h3-index) 六边形边的平均长度(单位为度)。 [Float64](../../data-types/float.md)。 **示例** @@ -123,7 +125,7 @@ SELECT h3EdgeAngle(10) AS edgeAngle; ## h3EdgeLengthM {#h3edgelengthm} -计算 [H3](#h3-index) 六角形边的平均长度(以米为单位)。 +计算 [H3](#h3-index) 六边形边的平均长度(单位为米)。 **语法** @@ -133,11 +135,11 @@ h3EdgeLengthM(resolution) **参数** -- `resolution` — 索引分辨率。 [UInt8](../../data-types/int-uint.md)。范围:`[0, 15]`。 +- `resolution` — 索引分辨率。 [UInt8](../../data-types/int-uint.md)。范围: `[0, 15]`。 **返回值** -- [H3](#h3-index) 六角形边的平均长度(以米为单位)。 [Float64](../../data-types/float.md)。 +- [H3](#h3-index) 六边形边的平均长度(单位为米)。 [Float64](../../data-types/float.md)。 **示例** @@ -157,7 +159,7 @@ SELECT h3EdgeLengthM(15) AS edgeLengthM; ## h3EdgeLengthKm {#h3edgelengthkm} -计算 [H3](#h3-index) 六角形边的平均长度(以公里为单位)。 +计算 [H3](#h3-index) 六边形边的平均长度(单位为千米)。 **语法** @@ -167,11 +169,11 @@ h3EdgeLengthKm(resolution) **参数** -- `resolution` — 索引分辨率。 [UInt8](../../data-types/int-uint.md)。范围:`[0, 15]`。 +- `resolution` — 索引分辨率。 [UInt8](../../data-types/int-uint.md)。范围: `[0, 15]`。 **返回值** -- [H3](#h3-index) 六角形边的平均长度(以公里为单位)。 [Float64](../../data-types/float.md)。 +- [H3](#h3-index) 六边形边的平均长度(单位为千米)。 [Float64](../../data-types/float.md)。 **示例** @@ -191,7 +193,7 @@ SELECT h3EdgeLengthKm(15) AS edgeLengthKm; ## geoToH3 {#geotoh3} -返回具有指定分辨率的 [H3](#h3-index) 点索引 `(lat, lon)`。 +返回给定分辨率的 [H3](#h3-index) 点索引 `(lat, lon)`。 **语法** @@ -203,14 +205,14 @@ geoToH3(lat, lon, resolution) - `lat` — 纬度。 [Float64](../../data-types/float.md)。 - `lon` — 经度。 [Float64](../../data-types/float.md)。 -- `resolution` — 索引分辨率。范围:`[0, 15]`。 [UInt8](../../data-types/int-uint.md)。 +- `resolution` — 索引分辨率。范围: `[0, 15]`。 [UInt8](../../data-types/int-uint.md)。 **返回值** -- 六角形索引编号。 [UInt64](../../data-types/int-uint.md)。 +- 六边形索引编号。 [UInt64](../../data-types/int-uint.md)。 - 错误时返回 0。 [UInt64](../../data-types/int-uint.md)。 -注意:在 ClickHouse v25.4 或更早版本中,`geoToH3()` 采用 `(lon, lat)` 的顺序。根据 ClickHouse v25.5,输入值的顺序为 `(lat, lon)`。可以通过设置 `geotoh3_argument_order = 'lon_lat'` 恢复之前的行为。 +注意:在 ClickHouse v25.4 或更早版本中,`geoToH3()` 按照 `(lon, lat)` 的顺序接受值。根据 ClickHouse v25.5,输入值按照 `(lat, lon)` 的顺序。可以使用设置 `geotoh3_argument_order = 'lon_lat'` 恢复以前的行为。 **示例** @@ -230,7 +232,7 @@ SELECT geoToH3(55.71290588, 37.79506683, 15) AS h3Index; ## h3ToGeo {#h3togeo} -返回与提供的 [H3](#h3-index) 索引对应的质心经纬度。 +返回与给定的 [H3](#h3-index) 索引对应的中心纬度和经度。 **语法** @@ -244,9 +246,9 @@ h3ToGeo(h3Index) **返回值** -- 由两个值组成的元组:`tuple(lat,lon)`。`lat` — 纬度。 [Float64](../../data-types/float.md)。`lon` — 经度。 [Float64](../../data-types/float.md)。 +- 一个包含两个值的元组:`tuple(lat,lon)`。`lat` — 纬度。 [Float64](../../data-types/float.md)。`lon` — 经度。 [Float64](../../data-types/float.md)。 -注意:在 ClickHouse v24.12 或更早版本中,`h3ToGeo()` 返回的值顺序为 `(lon, lat)`。根据 ClickHouse v25.1,返回值的顺序为 `(lat, lon)`。可以通过设置 `h3togeo_lon_lat_result_order = true` 恢复之前的行为。 +注意:在 ClickHouse v24.12 或更早版本中,`h3ToGeo()` 返回的值按照 `(lon, lat)` 的顺序。根据 ClickHouse v25.1,返回的值按照 `(lat, lon)` 的顺序。可以使用设置 `h3togeo_lon_lat_result_order = true` 恢复以前的行为。 **示例** @@ -266,7 +268,7 @@ SELECT h3ToGeo(644325524701193974) AS coordinates; ## h3ToGeoBoundary {#h3togeoboundary} -返回与提供的 H3 索引对应的边界的 `(lat, lon)` 对数组。 +返回一个对应于给定 H3 索引的边界的 `(lat, lon)` 对数组。 **语法** @@ -280,7 +282,7 @@ h3ToGeoBoundary(h3Index) **返回值** -- `(lat, lon)` 对数组。 [Array](../../data-types/array.md)([Float64](../../data-types/float.md), [Float64](../../data-types/float.md))。 +- `(lat, lon)` 对的数组。 [Array](../../data-types/array.md)([Float64](../../data-types/float.md), [Float64](../../data-types/float.md))。 **示例** @@ -300,7 +302,7 @@ SELECT h3ToGeoBoundary(644325524701193974) AS coordinates; ## h3kRing {#h3kring} -列出与给定六角形的半径为 `k` 的所有 [H3](#h3-index) 六角形,以随机顺序返回。 +列出距离给定六边形 `k` 范围内的所有 [H3](#h3-index) 六边形,顺序为随机。 **语法** @@ -310,7 +312,7 @@ h3kRing(h3index, k) **参数** -- `h3index` — 六角形索引编号。 [UInt64](../../data-types/int-uint.md)。 +- `h3index` — 六边形索引编号。 [UInt64](../../data-types/int-uint.md)。 - `k` — 半径。 [integer](../../data-types/int-uint.md) **返回值** @@ -351,11 +353,11 @@ h3GetBaseCell(index) **参数** -- `index` — 六角形索引编号。 [UInt64](../../data-types/int-uint.md)。 +- `index` — 六边形索引编号。 [UInt64](../../data-types/int-uint.md)。 **返回值** -- 六角形基单元编号。 [UInt8](../../data-types/int-uint.md)。 +- 六边形基单元编号。 [UInt8](../../data-types/int-uint.md)。 **示例** @@ -375,7 +377,7 @@ SELECT h3GetBaseCell(612916788725809151) AS basecell; ## h3HexAreaM2 {#h3hexaream2} -返回给定分辨率的平均六角形面积(以平方米为单位)。 +返回给定分辨率下的平均六边形面积(单位为平方米)。 **语法** @@ -385,11 +387,11 @@ h3HexAreaM2(resolution) **参数** -- `resolution` — 索引分辨率。范围:`[0, 15]`。 [UInt8](../../data-types/int-uint.md)。 +- `resolution` — 索引分辨率。范围: `[0, 15]`。 [UInt8](../../data-types/int-uint.md)。 **返回值** -- 面积(以平方米为单位)。 [Float64](../../data-types/float.md)。 +- 面积(单位为平方米)。 [Float64](../../data-types/float.md)。 **示例** @@ -409,7 +411,7 @@ SELECT h3HexAreaM2(13) AS area; ## h3HexAreaKm2 {#h3hexareakm2} -返回给定分辨率的平均六角形面积(以平方公里为单位)。 +返回给定分辨率下的平均六边形面积(单位为平方千米)。 **语法** @@ -419,11 +421,11 @@ h3HexAreaKm2(resolution) **参数** -- `resolution` — 索引分辨率。范围:`[0, 15]`。 [UInt8](../../data-types/int-uint.md)。 +- `resolution` — 索引分辨率。范围: `[0, 15]`。 [UInt8](../../data-types/int-uint.md)。 **返回值** -- 面积(以平方公里为单位)。 [Float64](../../data-types/float.md)。 +- 面积(单位为平方千米)。 [Float64](../../data-types/float.md)。 **示例** @@ -443,7 +445,7 @@ SELECT h3HexAreaKm2(13) AS area; ## h3IndexesAreNeighbors {#h3indexesareneighbors} -返回提供的 [H3](#h3-index) 索引是否是邻居。 +返回提供的 [H3](#h3-index) 索引是否为相邻。 **语法** @@ -453,13 +455,13 @@ h3IndexesAreNeighbors(index1, index2) **参数** -- `index1` — 六角形索引编号。 [UInt64](../../data-types/int-uint.md)。 -- `index2` — 六角形索引编号。 [UInt64](../../data-types/int-uint.md)。 +- `index1` — 六边形索引编号。 [UInt64](../../data-types/int-uint.md)。 +- `index2` — 六边形索引编号。 [UInt64](../../data-types/int-uint.md)。 **返回值** -- `1` — 索引是邻居。 [UInt8](../../data-types/int-uint.md)。 -- `0` — 索引不是邻居。 [UInt8](../../data-types/int-uint.md)。 +- `1` — 索引是相邻的。 [UInt8](../../data-types/int-uint.md)。 +- `0` — 索引不是相邻的。 [UInt8](../../data-types/int-uint.md)。 **示例** @@ -489,12 +491,12 @@ h3ToChildren(index, resolution) **参数** -- `index` — 六角形索引编号。 [UInt64](../../data-types/int-uint.md)。 -- `resolution` — 索引分辨率。范围:`[0, 15]`。 [UInt8](../../data-types/int-uint.md)。 +- `index` — 六边形索引编号。 [UInt64](../../data-types/int-uint.md)。 +- `resolution` — 索引分辨率。范围: `[0, 15]`。 [UInt8](../../data-types/int-uint.md)。 **返回值** -- 子 H3 索引数组。 [Array](../../data-types/array.md)([UInt64](../../data-types/int-uint.md))。 +- 子 H3 索引的数组。 [Array](../../data-types/array.md)([UInt64](../../data-types/int-uint.md))。 **示例** @@ -514,7 +516,7 @@ SELECT h3ToChildren(599405990164561919, 6) AS children; ## h3ToParent {#h3toparent} -返回包含给定的 [H3](#h3-index) 索引的父(粗糙)索引。 +返回包含给定 [H3](#h3-index) 索引的父级(更粗)的索引。 **语法** @@ -524,8 +526,8 @@ h3ToParent(index, resolution) **参数** -- `index` — 六角形索引编号。 [UInt64](../../data-types/int-uint.md)。 -- `resolution` — 索引分辨率。范围:`[0, 15]`。 [UInt8](../../data-types/int-uint.md)。 +- `index` — 六边形索引编号。 [UInt64](../../data-types/int-uint.md)。 +- `resolution` — 索引分辨率。范围: `[0, 15]`。 [UInt8](../../data-types/int-uint.md)。 **返回值** @@ -549,7 +551,7 @@ SELECT h3ToParent(599405990164561919, 3) AS parent; ## h3ToString {#h3tostring} -将索引的 `H3Index` 表示转换为字符串表示。 +将索引的 `H3Index` 表示形式转换为字符串表示形式。 ```sql h3ToString(index) @@ -557,7 +559,7 @@ h3ToString(index) **参数** -- `index` — 六角形索引编号。 [UInt64](../../data-types/int-uint.md)。 +- `index` — 六边形索引编号。 [UInt64](../../data-types/int-uint.md)。 **返回值** @@ -595,7 +597,7 @@ stringToH3(index_str) **返回值** -- 六角形索引编号。出现错误时返回 0。 [UInt64](../../data-types/int-uint.md)。 +- 六边形索引编号。错误时返回 0。 [UInt64](../../data-types/int-uint.md)。 **示例** @@ -625,11 +627,11 @@ h3GetResolution(index) **参数** -- `index` — 六角形索引编号。 [UInt64](../../data-types/int-uint.md)。 +- `index` — 六边形索引编号。 [UInt64](../../data-types/int-uint.md)。 **返回值** -- 索引分辨率。范围:`[0, 15]`。 [UInt8](../../data-types/int-uint.md)。 +- 索引分辨率。范围: `[0, 15]`。 [UInt8](../../data-types/int-uint.md)。 **示例** @@ -649,7 +651,7 @@ SELECT h3GetResolution(617420388352917503) AS res; ## h3IsResClassIII {#h3isresclassiii} -返回 [H3](#h3-index) 索引是否具有 III 类方向的分辨率。 +返回 [H3](#h3-index) 索引是否具有 Class III 定向的分辨率。 **语法** @@ -659,12 +661,12 @@ h3IsResClassIII(index) **参数** -- `index` — 六角形索引编号。 [UInt64](../../data-types/int-uint.md)。 +- `index` — 六边形索引编号。 [UInt64](../../data-types/int-uint.md)。 **返回值** -- `1` — 索引具有 III 类方向的分辨率。 [UInt8](../../data-types/int-uint.md)。 -- `0` — 索引不具有 III 类方向的分辨率。 [UInt8](../../data-types/int-uint.md)。 +- `1` — 索引具有 Class III 定向的分辨率。 [UInt8](../../data-types/int-uint.md)。 +- `0` — 索引没有 Class III 定向的分辨率。 [UInt8](../../data-types/int-uint.md)。 **示例** @@ -684,7 +686,7 @@ SELECT h3IsResClassIII(617420388352917503) AS res; ## h3IsPentagon {#h3ispentagon} -返回此 [H3](#h3-index) 索引是否表示一个五边形单元。 +返回该 [H3](#h3-index) 索引是否表示五边形单元。 **语法** @@ -694,11 +696,11 @@ h3IsPentagon(index) **参数** -- `index` — 六角形索引编号。 [UInt64](../../data-types/int-uint.md)。 +- `index` — 六边形索引编号。 [UInt64](../../data-types/int-uint.md)。 **返回值** -- `1` — 索引表示一个五边形单元。 [UInt8](../../data-types/int-uint.md)。 +- `1` — 索引表示五边形单元。 [UInt8](../../data-types/int-uint.md)。 - `0` — 索引不表示五边形单元。 [UInt8](../../data-types/int-uint.md)。 **示例** @@ -719,7 +721,7 @@ SELECT h3IsPentagon(644721767722457330) AS pentagon; ## h3GetFaces {#h3getfaces} -返回与给定的 [H3](#h3-index) 索引相交的20面体面。 +返回与给定 [H3](#h3-index) 索引相交的二十面体面。 **语法** @@ -729,11 +731,11 @@ h3GetFaces(index) **参数** -- `index` — 六角形索引编号。 [UInt64](../../data-types/int-uint.md)。 +- `index` — 六边形索引编号。 [UInt64](../../data-types/int-uint.md)。 **返回值** -- 包含与给定 H3 索引相交的 icosahedron 面的数组。 [Array](../../data-types/array.md)([UInt64](../../data-types/int-uint.md))。 +- 包含与给定 H3 索引相交的二十面体面的数组。 [Array](../../data-types/array.md)([UInt64](../../data-types/int-uint.md))。 **示例** @@ -753,7 +755,7 @@ SELECT h3GetFaces(599686042433355775) AS faces; ## h3CellAreaM2 {#h3cellaream2} -返回与给定输入 H3 索引相对应的特定单元的确切面积(以平方米为单位)。 +返回与给定输入 H3 索引相对应的特定单元的确切面积(单位为平方米)。 **语法** @@ -763,11 +765,11 @@ h3CellAreaM2(index) **参数** -- `index` — 六角形索引编号。 [UInt64](../../data-types/int-uint.md)。 +- `index` — 六边形索引编号。 [UInt64](../../data-types/int-uint.md)。 **返回值** -- 单元面积(以平方米为单位)。 [Float64](../../data-types/float.md)。 +- 单元面积(单位为平方米)。 [Float64](../../data-types/float.md)。 **示例** @@ -787,7 +789,7 @@ SELECT h3CellAreaM2(579205133326352383) AS area; ## h3CellAreaRads2 {#h3cellarearads2} -返回与给定输入 H3 索引相对应的特定单元的确切面积(以平方弧度为单位)。 +返回与给定输入 H3 索引相对应的特定单元的确切面积(单位为平方弧度)。 **语法** @@ -797,11 +799,11 @@ h3CellAreaRads2(index) **参数** -- `index` — 六角形索引编号。 [UInt64](../../data-types/int-uint.md)。 +- `index` — 六边形索引编号。 [UInt64](../../data-types/int-uint.md)。 **返回值** -- 单元面积(以平方弧度为单位)。 [Float64](../../data-types/float.md)。 +- 单元面积(单位为平方弧度)。 [Float64](../../data-types/float.md)。 **示例** @@ -821,7 +823,7 @@ SELECT h3CellAreaRads2(579205133326352383) AS area; ## h3ToCenterChild {#h3tocenterchild} -返回给定 [H3](#h3-index) 中包含的中心子(更细) [H3](#h3-index) 索引,按照指定的分辨率。 +返回包含给定分辨率下的给定 [H3](#h3-index) 的中心子索引(更细)。 **语法** @@ -831,12 +833,12 @@ h3ToCenterChild(index, resolution) **参数** -- `index` — 六角形索引编号。 [UInt64](../../data-types/int-uint.md)。 -- `resolution` — 索引分辨率。范围:`[0, 15]`。 [UInt8](../../data-types/int-uint.md)。 +- `index` — 六边形索引编号。 [UInt64](../../data-types/int-uint.md)。 +- `resolution` — 索引分辨率。范围: `[0, 15]`。 [UInt8](../../data-types/int-uint.md)。 **返回值** -- 给定 [H3](#h3-index) 中包含的中心子 [H3](#h3-index) 索引,按照指定的分辨率。 [UInt64](../../data-types/int-uint.md)。 +- 在给定分辨率下包含的中心子索引的 [H3](#h3-index)。 [UInt64](../../data-types/int-uint.md)。 **示例** @@ -856,7 +858,7 @@ SELECT h3ToCenterChild(577023702256844799,1) AS centerToChild; ## h3ExactEdgeLengthM {#h3exactedgelengthm} -返回由输入 h3 索引表示的单向边在米中的确切边长。 +返回表示输入 h3 索引的单向边的确切边长(单位为米)。 **语法** @@ -866,11 +868,11 @@ h3ExactEdgeLengthM(index) **参数** -- `index` — 六角形索引编号。 [UInt64](../../data-types/int-uint.md)。 +- `index` — 六边形索引编号。 [UInt64](../../data-types/int-uint.md)。 **返回值** -- 确切边长(以米为单位)。 [Float64](../../data-types/float.md)。 +- 确切边长(单位为米)。 [Float64](../../data-types/float.md)。 **示例** @@ -890,7 +892,7 @@ SELECT h3ExactEdgeLengthM(1310277011704381439) AS exactEdgeLengthM;; ## h3ExactEdgeLengthKm {#h3exactedgelengthkm} -返回由输入 h3 索引表示的单向边在公里中的确切边长。 +返回表示输入 h3 索引的单向边的确切边长(单位为千米)。 **语法** @@ -900,11 +902,11 @@ h3ExactEdgeLengthKm(index) **参数** -- `index` — 六角形索引编号。 [UInt64](../../data-types/int-uint.md)。 +- `index` — 六边形索引编号。 [UInt64](../../data-types/int-uint.md)。 **返回值** -- 确切边长(以公里为单位)。 [Float64](../../data-types/float.md)。 +- 确切边长(单位为千米)。 [Float64](../../data-types/float.md)。 **示例** @@ -924,7 +926,7 @@ SELECT h3ExactEdgeLengthKm(1310277011704381439) AS exactEdgeLengthKm;; ## h3ExactEdgeLengthRads {#h3exactedgelengthrads} -返回由输入 h3 索引表示的单向边在弧度中的确切边长。 +返回表示输入 h3 索引的单向边的确切边长(单位为弧度)。 **语法** @@ -934,11 +936,11 @@ h3ExactEdgeLengthRads(index) **参数** -- `index` — 六角形索引编号。 [UInt64](../../data-types/int-uint.md)。 +- `index` — 六边形索引编号。 [UInt64](../../data-types/int-uint.md)。 **返回值** -- 确切边长(以弧度为单位)。 [Float64](../../data-types/float.md)。 +- 确切边长(单位为弧度)。 [Float64](../../data-types/float.md)。 **示例** @@ -968,7 +970,7 @@ h3NumHexagons(resolution) **参数** -- `resolution` — 索引分辨率。范围:`[0, 15]`。 [UInt8](../../data-types/int-uint.md)。 +- `resolution` — 索引分辨率。范围: `[0, 15]`。 [UInt8](../../data-types/int-uint.md)。 **返回值** @@ -992,7 +994,7 @@ SELECT h3NumHexagons(3) AS numHexagons; ## h3PointDistM {#h3pointdistm} -返回点对 GeoCoord 点(纬度/经度)对之间的"大圆"或"哈弗辛"距离(以米为单位)。 +返回成对 GeoCoord 点(纬度/经度)之间的“大圆”或“哈弗辛”距离(单位为米)。 **语法** @@ -1002,19 +1004,19 @@ h3PointDistM(lat1, lon1, lat2, lon2) **参数** -- `lat1`, `lon1` — 点1 的纬度和经度(以度为单位)。 [Float64](../../data-types/float.md)。 -- `lat2`, `lon2` — 点2 的纬度和经度(以度为单位)。 [Float64](../../data-types/float.md)。 +- `lat1`, `lon1` — 第一个点的纬度和经度(单位为度)。 [Float64](../../data-types/float.md)。 +- `lat2`, `lon2` — 第二个点的纬度和经度(单位为度)。 [Float64](../../data-types/float.md)。 **返回值** -- 哈弗辛或大圆距离(以米为单位)。 [Float64](../../data-types/float.md)。 +- 哈弗辛或大圆距离(单位为米)。 [Float64](../../data-types/float.md)。 **示例** 查询: ```sql -select h3PointDistM(-10.0 ,0.0, 10.0, 0.0) as h3PointDistM; +SELECT h3PointDistM(-10.0 ,0.0, 10.0, 0.0) AS h3PointDistM; ``` 结果: @@ -1027,7 +1029,7 @@ select h3PointDistM(-10.0 ,0.0, 10.0, 0.0) as h3PointDistM; ## h3PointDistKm {#h3pointdistkm} -返回点对 GeoCoord 点(纬度/经度)对之间的"大圆"或"哈弗辛"距离(以公里为单位)。 +返回成对 GeoCoord 点(纬度/经度)之间的“大圆”或“哈弗辛”距离(单位为千米)。 **语法** @@ -1037,19 +1039,19 @@ h3PointDistKm(lat1, lon1, lat2, lon2) **参数** -- `lat1`, `lon1` — 点1 的纬度和经度(以度为单位)。 [Float64](../../data-types/float.md)。 -- `lat2`, `lon2` — 点2 的纬度和经度(以度为单位)。 [Float64](../../data-types/float.md)。 +- `lat1`, `lon1` — 第一个点的纬度和经度(单位为度)。 [Float64](../../data-types/float.md)。 +- `lat2`, `lon2` — 第二个点的纬度和经度(单位为度)。 [Float64](../../data-types/float.md)。 **返回值** -- 哈弗辛或大圆距离(以公里为单位)。 [Float64](../../data-types/float.md)。 +- 哈弗辛或大圆距离(单位为千米)。 [Float64](../../data-types/float.md)。 **示例** 查询: ```sql -select h3PointDistKm(-10.0 ,0.0, 10.0, 0.0) as h3PointDistKm; +SELECT h3PointDistKm(-10.0 ,0.0, 10.0, 0.0) AS h3PointDistKm; ``` 结果: @@ -1062,7 +1064,7 @@ select h3PointDistKm(-10.0 ,0.0, 10.0, 0.0) as h3PointDistKm; ## h3PointDistRads {#h3pointdistrads} -返回点对 GeoCoord 点(纬度/经度)对之间的"大圆"或"哈弗辛"距离(以弧度为单位)。 +返回成对 GeoCoord 点(纬度/经度)之间的“大圆”或“哈弗辛”距离(单位为弧度)。 **语法** @@ -1072,19 +1074,19 @@ h3PointDistRads(lat1, lon1, lat2, lon2) **参数** -- `lat1`, `lon1` — 点1 的纬度和经度(以度为单位)。 [Float64](../../data-types/float.md)。 -- `lat2`, `lon2` — 点2 的纬度和经度(以度为单位)。 [Float64](../../data-types/float.md)。 +- `lat1`, `lon1` — 第一个点的纬度和经度(单位为度)。 [Float64](../../data-types/float.md)。 +- `lat2`, `lon2` — 第二个点的纬度和经度(单位为度)。 [Float64](../../data-types/float.md)。 **返回值** -- 哈弗辛或大圆距离(以弧度为单位)。 [Float64](../../data-types/float.md)。 +- 哈弗辛或大圆距离(单位为弧度)。 [Float64](../../data-types/float.md)。 **示例** 查询: ```sql -select h3PointDistRads(-10.0 ,0.0, 10.0, 0.0) as h3PointDistRads; +SELECT h3PointDistRads(-10.0 ,0.0, 10.0, 0.0) AS h3PointDistRads; ``` 结果: @@ -1097,7 +1099,7 @@ select h3PointDistRads(-10.0 ,0.0, 10.0, 0.0) as h3PointDistRads; ## h3GetRes0Indexes {#h3getres0indexes} -返回所有分辨率 0 的 H3 索引数组。 +返回所有分辨率为 0 的 H3 索引的数组。 **语法** @@ -1107,14 +1109,14 @@ h3GetRes0Indexes() **返回值** -- 所有分辨率 0 的 H3 索引数组。 [Array](../../data-types/array.md)([UInt64](../../data-types/int-uint.md))。 +- 所有分辨率为 0 的 H3 索引的数组。 [Array](../../data-types/array.md)([UInt64](../../data-types/int-uint.md))。 **示例** 查询: ```sql -select h3GetRes0Indexes as indexes ; +SELECT h3GetRes0Indexes AS indexes ; ``` 结果: @@ -1127,7 +1129,7 @@ select h3GetRes0Indexes as indexes ; ## h3GetPentagonIndexes {#h3getpentagonindexes} -返回指定分辨率下的所有五边形 H3 索引。 +返回指定分辨率的所有五边形 H3 索引。 **语法** @@ -1137,11 +1139,11 @@ h3GetPentagonIndexes(resolution) **参数** -- `resolution` — 索引分辨率。范围:`[0, 15]`。 [UInt8](../../data-types/int-uint.md)。 +- `resolution` — 索引分辨率。范围: `[0, 15]`。 [UInt8](../../data-types/int-uint.md)。 **返回值** -- 所有五边形 H3 索引数组。 [Array](../../data-types/array.md)([UInt64](../../data-types/int-uint.md))。 +- 所有五边形 H3 索引的数组。 [Array](../../data-types/array.md)([UInt64](../../data-types/int-uint.md))。 **示例** @@ -1161,7 +1163,7 @@ SELECT h3GetPentagonIndexes(3) AS indexes; ## h3Line {#h3line} -返回提供的两个索引之间的索引线。 +返回两个提供的索引之间的索引线。 **语法** @@ -1171,19 +1173,19 @@ h3Line(start,end) **参数** -- `start` — 表示起始点的六角形索引编号。 [UInt64](../../data-types/int-uint.md)。 -- `end` — 表示结束点的六角形索引编号。 [UInt64](../../data-types/int-uint.md)。 +- `start` — 表示起始点的六边形索引编号。 [UInt64](../../data-types/int-uint.md)。 +- `end` — 表示结束点的六边形索引编号。 [UInt64](../../data-types/int-uint.md)。 **返回值** -表示提供的两个索引之间的索引线的 H3 索引数组。 [Array](../../data-types/array.md)([UInt64](../../data-types/int-uint.md))。 +表示两个提供的索引之间的索引线的 H3 索引数组。 [Array](../../data-types/array.md)([UInt64](../../data-types/int-uint.md))。 **示例** 查询: ```sql -SELECT h3Line(590080540275638271,590103561300344831) as indexes; +SELECT h3Line(590080540275638271,590103561300344831) AS indexes; ``` 结果: @@ -1206,8 +1208,8 @@ h3Distance(start,end) **参数** -- `start` — 表示起始点的六角形索引编号。 [UInt64](../../data-types/int-uint.md)。 -- `end` — 表示结束点的六角形索引编号。 [UInt64](../../data-types/int-uint.md)。 +- `start` — 表示起始点的六边形索引编号。 [UInt64](../../data-types/int-uint.md)。 +- `end` — 表示结束点的六边形索引编号。 [UInt64](../../data-types/int-uint.md)。 **返回值** @@ -1220,7 +1222,7 @@ h3Distance(start,end) 查询: ```sql -SELECT h3Distance(590080540275638271,590103561300344831) as distance; +SELECT h3Distance(590080540275638271,590103561300344831) AS distance; ``` 结果: @@ -1233,9 +1235,9 @@ SELECT h3Distance(590080540275638271,590103561300344831) as distance; ## h3HexRing {#h3hexring} -返回以所提供的原始 h3Index 为中心的六边形环的索引,长度为 k。 +返回以给定原点 h3Index 为中心、长度为 k 的六边形环的索引。 -如果未遇到五边形变形,则返回 0。 +如果没有遇到五边形畸变,则返回 0。 **语法** @@ -1245,7 +1247,7 @@ h3HexRing(index, k) **参数** -- `index` — 表示原点的六角形索引编号。 [UInt64](../../data-types/int-uint.md)。 +- `index` — 表示原点的六边形索引编号。 [UInt64](../../data-types/int-uint.md)。 - `k` — 距离。 [UInt64](../../data-types/int-uint.md)。 **返回值** @@ -1270,7 +1272,7 @@ SELECT h3HexRing(590080540275638271, toUInt16(1)) AS hexRing; ## h3GetUnidirectionalEdge {#h3getunidirectionaledge} -根据提供的原点和目标返回单向边 H3 索引,如出错则返回 0。 +根据提供的原点和目的地返回一个单向边 H3 索引,并在错误时返回 0。 **语法** @@ -1280,19 +1282,19 @@ h3GetUnidirectionalEdge(originIndex, destinationIndex) **参数** -- `originIndex` — 原点六角形索引编号。 [UInt64](../../data-types/int-uint.md)。 -- `destinationIndex` — 目标六角形索引编号。 [UInt64](../../data-types/int-uint.md)。 +- `originIndex` — 原点六边形索引编号。 [UInt64](../../data-types/int-uint.md)。 +- `destinationIndex` — 目的地六边形索引编号。 [UInt64](../../data-types/int-uint.md)。 **返回值** -- 单向边六角形索引编号。 [UInt64](../../data-types/int-uint.md)。 +- 单向边六边形索引编号。 [UInt64](../../data-types/int-uint.md)。 **示例** 查询: ```sql -SELECT h3GetUnidirectionalEdge(599686042433355775, 599686043507097599) as edge; +SELECT h3GetUnidirectionalEdge(599686042433355775, 599686043507097599) AS edge; ``` 结果: @@ -1305,7 +1307,7 @@ SELECT h3GetUnidirectionalEdge(599686042433355775, 599686043507097599) as edge; ## h3UnidirectionalEdgeIsValid {#h3unidirectionaledgeisvalid} -确定提供的 H3Index 是否为有效的单向边索引。 如果是单向边则返回 1,否则返回 0。 +确定提供的 H3Index 是否为有效的单向边索引。如果是单向边则返回 1,否则返回 0。 **语法** @@ -1315,7 +1317,7 @@ h3UnidirectionalEdgeisValid(index) **参数** -- `index` — 六角形索引编号。 [UInt64](../../data-types/int-uint.md)。 +- `index` — 六边形索引编号。 [UInt64](../../data-types/int-uint.md)。 **返回值** @@ -1327,7 +1329,7 @@ h3UnidirectionalEdgeisValid(index) 查询: ```sql -SELECT h3UnidirectionalEdgeIsValid(1248204388774707199) as validOrNot; +SELECT h3UnidirectionalEdgeIsValid(1248204388774707199) AS validOrNot; ``` 结果: @@ -1340,7 +1342,7 @@ SELECT h3UnidirectionalEdgeIsValid(1248204388774707199) as validOrNot; ## h3GetOriginIndexFromUnidirectionalEdge {#h3getoriginindexfromunidirectionaledge} -从单向边 H3Index 中返回原点六角形索引。 +返回单向边 H3Index 的原点六边形索引。 **语法** @@ -1350,18 +1352,18 @@ h3GetOriginIndexFromUnidirectionalEdge(edge) **参数** -- `edge` — 表示单向边的六角形索引编号。 [UInt64](../../data-types/int-uint.md)。 +- `edge` — 表示单向边的六边形索引编号。 [UInt64](../../data-types/int-uint.md)。 **返回值** -- 原点六角形索引编号。 [UInt64](../../data-types/int-uint.md)。 +- 原点六边形索引编号。 [UInt64](../../data-types/int-uint.md)。 **示例** 查询: ```sql -SELECT h3GetOriginIndexFromUnidirectionalEdge(1248204388774707197) as origin; +SELECT h3GetOriginIndexFromUnidirectionalEdge(1248204388774707197) AS origin; ``` 结果: @@ -1374,7 +1376,7 @@ SELECT h3GetOriginIndexFromUnidirectionalEdge(1248204388774707197) as origin; ## h3GetDestinationIndexFromUnidirectionalEdge {#h3getdestinationindexfromunidirectionaledge} -从单向边 H3Index 中返回目标六角形索引。 +返回单向边 H3Index 的目的地六边形索引。 **语法** @@ -1384,18 +1386,18 @@ h3GetDestinationIndexFromUnidirectionalEdge(edge) **参数** -- `edge` — 表示单向边的六角形索引编号。 [UInt64](../../data-types/int-uint.md)。 +- `edge` — 表示单向边的六边形索引编号。 [UInt64](../../data-types/int-uint.md)。 **返回值** -- 目标六角形索引编号。 [UInt64](../../data-types/int-uint.md)。 +- 目的地六边形索引编号。 [UInt64](../../data-types/int-uint.md)。 **示例** 查询: ```sql -SELECT h3GetDestinationIndexFromUnidirectionalEdge(1248204388774707197) as destination; +SELECT h3GetDestinationIndexFromUnidirectionalEdge(1248204388774707197) AS destination; ``` 结果: @@ -1408,7 +1410,7 @@ SELECT h3GetDestinationIndexFromUnidirectionalEdge(1248204388774707197) as desti ## h3GetIndexesFromUnidirectionalEdge {#h3getindexesfromunidirectionaledge} -返回给定单向边 H3Index 的原点和目标六角形索引。 +从给定的单向边 H3Index 返回原点和目的地六边形索引。 **语法** @@ -1418,14 +1420,14 @@ h3GetIndexesFromUnidirectionalEdge(edge) **参数** -- `edge` — 表示单向边的六角形索引编号。 [UInt64](../../data-types/int-uint.md)。 +- `edge` — 表示单向边的六边形索引编号。 [UInt64](../../data-types/int-uint.md)。 **返回值** -一个由两个值组成的元组 `tuple(origin,destination)`: +包含两个值的元组 `tuple(origin,destination)`: -- `origin` — 原点六角形索引编号。 [UInt64](../../data-types/int-uint.md)。 -- `destination` — 目标六角形索引编号。 [UInt64](../../data-types/int-uint.md)。 +- `origin` — 原点六边形索引编号。 [UInt64](../../data-types/int-uint.md)。 +- `destination` — 目的地六边形索引编号。 [UInt64](../../data-types/int-uint.md)。 如果提供的输入无效,则返回 `(0,0)`。 @@ -1434,7 +1436,7 @@ h3GetIndexesFromUnidirectionalEdge(edge) 查询: ```sql -SELECT h3GetIndexesFromUnidirectionalEdge(1248204388774707199) as indexes; +SELECT h3GetIndexesFromUnidirectionalEdge(1248204388774707199) AS indexes; ``` 结果: @@ -1447,7 +1449,7 @@ SELECT h3GetIndexesFromUnidirectionalEdge(1248204388774707199) as indexes; ## h3GetUnidirectionalEdgesFromHexagon {#h3getunidirectionaledgesfromhexagon} -提供从提供的 H3Index 的所有单向边。 +提供来自给定 H3Index 的所有单向边。 **语法** @@ -1457,7 +1459,7 @@ h3GetUnidirectionalEdgesFromHexagon(index) **参数** -- `index` — 表示单向边的六角形索引编号。 [UInt64](../../data-types/int-uint.md)。 +- `index` — 表示单向边的六边形索引编号。 [UInt64](../../data-types/int-uint.md)。 **返回值** @@ -1468,7 +1470,7 @@ h3GetUnidirectionalEdgesFromHexagon(index) 查询: ```sql -SELECT h3GetUnidirectionalEdgesFromHexagon(1248204388774707199) as edges; +SELECT h3GetUnidirectionalEdgesFromHexagon(1248204388774707199) AS edges; ``` 结果: @@ -1491,18 +1493,18 @@ h3GetUnidirectionalEdgeBoundary(index) **参数** -- `index` — 表示单向边的六角形索引编号。 [UInt64](../../data-types/int-uint.md)。 +- `index` — 表示单向边的六边形索引编号。 [UInt64](../../data-types/int-uint.md)。 **返回值** -- `(lon, lat)` 对数组。 [Array](../../data-types/array.md)([Float64](../../data-types/float.md), [Float64](../../data-types/float.md))。 +- `(lon, lat)` 对的数组。 [Array](../../data-types/array.md)([Float64](../../data-types/float.md), [Float64](../../data-types/float.md))。 **示例** 查询: ```sql -SELECT h3GetUnidirectionalEdgeBoundary(1248204388774707199) as boundary; +SELECT h3GetUnidirectionalEdgeBoundary(1248204388774707199) AS boundary; ``` 结果: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/geo/h3.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/geo/h3.md.hash index 20565fe81cf..92a059796a6 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/geo/h3.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/geo/h3.md.hash @@ -1 +1 @@ -6815e2ad2d08261d +b98648342844fb77 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/geo/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/geo/index.md index 71051a5c965..ab98448562b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/geo/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/geo/index.md @@ -1,9 +1,9 @@ --- -'description': 'Index 的文档' +'description': '索引的文档' 'sidebar_label': 'Geo' -'sidebar_position': 62 'slug': '/sql-reference/functions/geo/' 'title': '地理函数' +'doc_type': 'reference' --- -用于处理几何对象的函数,例如 [计算球面上点之间的距离](./coordinates.md)、[计算地理哈希](./geohash.md) 以及处理 [h3 索引](./h3.md)。 +用于处理几何对象的函数,例如 [计算球面上点之间的距离](./coordinates.md),[计算地理哈希](./geohash.md),以及处理 [h3 索引](./h3.md)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/geo/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/geo/index.md.hash index f2e568f0927..260ec4f1edf 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/geo/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/geo/index.md.hash @@ -1 +1 @@ -546ee462cd8934e0 +8ddbda189302915b diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/geo/polygon.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/geo/polygon.md index 93dc9fa470c..f250d7e01e9 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/geo/polygon.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/geo/polygon.md @@ -1,13 +1,14 @@ --- -'description': 'Polygon的文档' +'description': 'Polygon 的文档' 'sidebar_label': '多边形' 'slug': '/sql-reference/functions/geo/polygons' 'title': '用于处理多边形的函数' +'doc_type': 'reference' --- ## WKT {#wkt} -从各种 [Geo Data Types](../../data-types/geo.md) 返回 WKT (Well Known Text) 几何对象。支持的 WKT 对象有: +返回来自各种 [Geo Data Types](../../data-types/geo.md) 的 WKT(Well Known Text)几何对象。支持的 WKT 对象有: - POINT - POLYGON @@ -23,7 +24,7 @@ WKT(geo_data) **参数** -`geo_data` 可以是以下 [Geo Data Types](../../data-types/geo.md) 或其基础原始类型之一: +`geo_data` 可以是以下 [Geo Data Types](../../data-types/geo.md) 之一或其底层原始类型: - [Point](../../data-types/geo.md#point) - [Ring](../../data-types/geo.md#ring) @@ -34,15 +35,15 @@ WKT(geo_data) **返回值** -- 对于 Point,返回 WKT 几何对象 `POINT`。 -- 对于 Polygon,返回 WKT 几何对象 `POLYGON`。 -- 对于 MultiPolygon,返回 WKT 几何对象 `MULTIPOLYGON`。 -- 对于 LineString,返回 WKT 几何对象 `LINESTRING`。 -- 对于 MultiLineString,返回 WKT 几何对象 `MULTILINESTRING`。 +- 返回 WKT 几何对象 `POINT` 用于 Point。 +- 返回 WKT 几何对象 `POLYGON` 用于 Polygon。 +- 返回 WKT 几何对象 `MULTIPOLYGON` 用于 MultiPolygon。 +- 返回 WKT 几何对象 `LINESTRING` 用于 LineString。 +- 返回 WKT 几何对象 `MULTILINESTRING` 用于 MultiLineString。 **示例** -来自元组的 POINT: +从元组获取 POINT: ```sql SELECT wkt((0., 0.)); @@ -52,7 +53,7 @@ SELECT wkt((0., 0.)); POINT(0 0) ``` -来自元组数组或元组数组的 POLYGON: +从元组数组或元组数组数组获取 POLYGON: ```sql SELECT wkt([(0., 0.), (10., 0.), (10., 10.), (0., 10.)]); @@ -62,7 +63,7 @@ SELECT wkt([(0., 0.), (10., 0.), (10., 10.), (0., 10.)]); POLYGON((0 0,10 0,10 10,0 10)) ``` -来自多维元组数组的 MULTIPOLYGON: +从多维元组数组获取 MULTIPOLYGON: ```sql SELECT wkt([[[(0., 0.), (10., 0.), (10., 10.), (0., 10.)], [(4., 4.), (5., 4.), (5., 5.), (4., 5.)]], [[(-10., -10.), (-10., -9.), (-9., 10.)]]]); @@ -74,7 +75,7 @@ MULTIPOLYGON(((0 0,10 0,10 10,0 10,0 0),(4 4,5 4,5 5,4 5,4 4)),((-10 -10,-10 -9, ## readWKTMultiPolygon {#readwktmultipolygon} -将 WKT (Well Known Text) MultiPolygon 转换为 MultiPolygon 类型。 +将 WKT(Well Known Text)MultiPolygon 转换为 MultiPolygon 类型。 ### 示例 {#example} @@ -98,7 +99,7 @@ MultiPolygon ## readWKTPolygon {#readwktpolygon} -将 WKT (Well Known Text) MultiPolygon 转换为 Polygon 类型。 +将 WKT(Well Known Text)MultiPolygon 转换为 Polygon 类型。 ### 示例 {#example-1} @@ -132,11 +133,11 @@ readWKTPoint(wkt_string) ### 参数 {#arguments} -- `wkt_string`: 表示 Point 几何的输入 WKT 字符串。 +- `wkt_string`: 表示点几何的输入 WKT 字符串。 ### 返回值 {#returned-value-2} -该函数返回 Point 几何的 ClickHouse 内部表示。 +该函数返回 ClickHouse 内部表示的点几何。 ### 示例 {#example-2} @@ -150,7 +151,7 @@ SELECT readWKTPoint('POINT (1.2 3.4)'); ## readWKTLineString {#readwktlinestring} -解析 LineString 几何的 Well-Known Text (WKT) 表示,并将其返回为 ClickHouse 内部格式。 +解析代表 LineString 几何的 Well-Known Text (WKT) 表示,并返回 ClickHouse 内部格式。 ### 语法 {#syntax-1} @@ -164,7 +165,7 @@ readWKTLineString(wkt_string) ### 返回值 {#returned-value-3} -该函数返回 LineString 几何的 ClickHouse 内部表示。 +该函数返回 ClickHouse 内部表示的 LineString 几何。 ### 示例 {#example-3} @@ -176,9 +177,9 @@ SELECT readWKTLineString('LINESTRING (1 1, 2 2, 3 3, 1 1)'); [(1,1),(2,2),(3,3),(1,1)] ``` -## readWKTMultiLineString {#readwktmultilinestring} +## readWKTMultiLineString {#readwkbmultilinestring} -解析 MultiLineString 几何的 Well-Known Text (WKT) 表示,并将其返回为 ClickHouse 内部格式。 +解析代表 MultiLineString 几何的 Well-Known Text (WKT) 表示,并返回 ClickHouse 内部格式。 ### 语法 {#syntax-2} @@ -192,7 +193,7 @@ readWKTMultiLineString(wkt_string) ### 返回值 {#returned-value-4} -该函数返回 MultiLineString 几何的 ClickHouse 内部表示。 +该函数返回 ClickHouse 内部表示的 MultiLineString 几何。 ### 示例 {#example-4} @@ -206,7 +207,7 @@ SELECT readWKTMultiLineString('MULTILINESTRING ((1 1, 2 2, 3 3), (4 4, 5 5, 6 6) ## readWKTRing {#readwktring} -解析 Polygon 几何的 Well-Known Text (WKT) 表示,并将其返回为 ClickHouse 内部格式的环(闭合线串)。 +解析代表 Polygon 几何的 Well-Known Text (WKT) 表示,并返回内部 ClickHouse 格式的环(闭合的 LineString)。 ### 语法 {#syntax-3} @@ -220,7 +221,7 @@ readWKTRing(wkt_string) ### 返回值 {#returned-value-5} -该函数返回环(闭合线串)几何的 ClickHouse 内部表示。 +该函数返回 ClickHouse 内部表示的环(闭合的 LineString)几何。 ### 示例 {#example-5} @@ -234,28 +235,160 @@ SELECT readWKTRing('POLYGON ((1 1, 2 2, 3 3, 1 1))'); ## polygonsWithinSpherical {#polygonswithinspherical} -根据一个多边形是否完全位于另一个多边形内返回真或假。参考 https://www.boost.org/doc/libs/1_62_0/libs/geometry/doc/html/geometry/reference/algorithms/within/within_2.html +根据一个多边形是否完全位于另一个多边形内部返回 true 或 false。参考 https://www.boost.org/doc/libs/1_62_0/libs/geometry/doc/html/geometry/reference/algorithms/within/within_2.html ### 示例 {#example-6} ```sql -select polygonsWithinSpherical([[[(4.3613577, 50.8651821), (4.349556, 50.8535879), (4.3602419, 50.8435626), (4.3830299, 50.8428851), (4.3904543, 50.8564867), (4.3613148, 50.8651279)]]], [[[(4.346693, 50.858306), (4.367945, 50.852455), (4.366227, 50.840809), (4.344961, 50.833264), (4.338074, 50.848677), (4.346693, 50.858306)]]]); +SELECT polygonsWithinSpherical([[[(4.3613577, 50.8651821), (4.349556, 50.8535879), (4.3602419, 50.8435626), (4.3830299, 50.8428851), (4.3904543, 50.8564867), (4.3613148, 50.8651279)]]], [[[(4.346693, 50.858306), (4.367945, 50.852455), (4.366227, 50.840809), (4.344961, 50.833264), (4.338074, 50.848677), (4.346693, 50.858306)]]]); ``` ```response 0 ``` +## readWKBMultiPolygon {#readwkbmultipolygon} + +将 WKB(Well Known Binary)MultiPolygon 转换为 MultiPolygon 类型。 + +### 示例 {#example-7} + +```sql +SELECT + toTypeName(readWKBMultiPolygon(unhex('0106000000020000000103000000020000000500000000000000000000400000000000000000000000000000244000000000000000000000000000002440000000000000244000000000000000000000000000002440000000000000004000000000000000000500000000000000000010400000000000001040000000000000144000000000000010400000000000001440000000000000144000000000000010400000000000001440000000000000104000000000000010400103000000010000000400000000000000000024c000000000000024c000000000000024c000000000000022c000000000000022c0000000000000244000000000000024c000000000000024c0'))) AS type, + readWKBMultiPolygon(unhex('0106000000020000000103000000020000000500000000000000000000400000000000000000000000000000244000000000000000000000000000002440000000000000244000000000000000000000000000002440000000000000004000000000000000000500000000000000000010400000000000001040000000000000144000000000000010400000000000001440000000000000144000000000000010400000000000001440000000000000104000000000000010400103000000010000000400000000000000000024c000000000000024c000000000000024c000000000000022c000000000000022c0000000000000244000000000000024c000000000000024c0')) AS output FORMAT Markdown + +``` +| 类型 | 输出 | +|:-|:-| +| MultiPolygon | [[[(2,0),(10,0),(10,10),(0,10),(2,0)],[(4,4),(5,4),(5,5),(4,5),(4,4)]],[[(-10,-10),(-10,-9),(-9,10),(-10,-10)]]] | + ### 输入参数 {#input-parameters-2} +以 `MULTIPOLYGON` 开头的字符串 + ### 返回值 {#returned-value-6} +MultiPolygon + +## readWKBPolygon {#readwkbpolygon} + +将 WKB(Well Known Binary)MultiPolygon 转换为 Polygon 类型。 + +### 示例 {#example-8} + +```sql +SELECT + toTypeName(readWKBPolygon(unhex('010300000001000000050000000000000000000040000000000000000000000000000024400000000000000000000000000000244000000000000024400000000000000000000000000000244000000000000000400000000000000000'))) AS type, + readWKBPolygon(unhex('010300000001000000050000000000000000000040000000000000000000000000000024400000000000000000000000000000244000000000000024400000000000000000000000000000244000000000000000400000000000000000')) AS output +FORMAT Markdown +``` +| 类型 | 输出 | +|:-|:-| +| Polygon | [[(2,0),(10,0),(10,10),(0,10),(2,0)]] | + +### 输入参数 {#input-parameters-3} + +以 `POLYGON` 开头的字符串 + +### 返回值 {#returned-value-7} + +Polygon + +## readWKBPoint {#readwkbpoint} + +`readWKBPoint` 函数在 ClickHouse 中解析 Well-Known Binary (WKB) 表示的点几何,并返回 ClickHouse 内部格式的点。 + +### 语法 {#syntax-4} + +```sql +readWKBPoint(wkb_string) +``` + +### 参数 {#arguments-4} + +- `wkb_string`: 表示点几何的输入 WKB 字符串。 + +### 返回值 {#returned-value-8} + +该函数返回 ClickHouse 内部表示的点几何。 + +### 示例 {#example-9} + +```sql +SELECT readWKBPoint(unhex('0101000000333333333333f33f3333333333330b40')); +``` + +```response +(1.2,3.4) +``` + +## readWKBLineString {#readwkblinestring} + +解析代表 LineString 几何的 Well-Known Binary (WKB) 表示,并返回 ClickHouse 内部格式。 + +### 语法 {#syntax-5} + +```sql +readWKBLineString(wkb_string) +``` + +### 参数 {#arguments-5} + +- `wkb_string`: 表示 LineString 几何的输入 WKB 字符串。 + +### 返回值 {#returned-value-9} + +该函数返回 ClickHouse 内部表示的 LineString 几何。 + +### 示例 {#example-10} + +```sql +SELECT readWKBLineString(unhex('010200000004000000000000000000f03f000000000000f03f0000000000000040000000000000004000000000000008400000000000000840000000000000f03f000000000000f03f')); +``` + +```response +[(1,1),(2,2),(3,3),(1,1)] +``` + +## readWKBMultiLineString {#readwkbmultilinestring} + +解析代表 MultiLineString 几何的 Well-Known Binary (WKB) 表示,并返回 ClickHouse 内部格式。 + +### 语法 {#syntax-6} + +```sql +readWKBMultiLineString(wkb_string) +``` + +### 参数 {#arguments-6} + +- `wkb_string`: 表示 MultiLineString 几何的输入 WKB 字符串。 + +### 返回值 {#returned-value-10} + +该函数返回 ClickHouse 内部表示的 MultiLineString 几何。 + +### 示例 {#example-11} + +```sql +SELECT readWKBMultiLineString(unhex('010500000002000000010200000003000000000000000000f03f000000000000f03f0000000000000040000000000000004000000000000008400000000000000840010200000003000000000000000000104000000000000010400000000000001440000000000000144000000000000018400000000000001840')); +``` + +```response +[[(1,1),(2,2),(3,3)],[(4,4),(5,5),(6,6)]] +``` + +### 输入参数 {#input-parameters-4} + +### 返回值 {#returned-value-11} + UInt8,0 表示 false,1 表示 true ## polygonsDistanceSpherical {#polygonsdistancespherical} -计算两点之间的最小距离,其中一个点属于第一个多边形,另一个点属于另一个多边形。球面意味着坐标被解释为纯理想球体上的坐标,这对地球并不准确。使用这种类型的坐标系统加速执行,但当然不精确。 +计算两个点之间的最小距离,其中一个点属于第一个多边形,另一个点属于另一个多边形。球面意味着坐标被解释为纯理想球体上的坐标,这对于地球并不准确。使用这种坐标系统加快了执行速度,但当然不是精确的。 -### 示例 {#example-7} +### 示例 {#example-12} ```sql SELECT polygonsDistanceSpherical([[[(0, 0), (0, 0.1), (0.1, 0.1), (0.1, 0)]]], [[[(10., 10.), (10., 40.), (40., 40.), (40., 10.), (10., 10.)]]]) @@ -264,11 +397,11 @@ SELECT polygonsDistanceSpherical([[[(0, 0), (0, 0.1), (0.1, 0.1), (0.1, 0)]]], [ 0.24372872211133834 ``` -### 输入参数 {#input-parameters-3} +### 输入参数 {#input-parameters-5} 两个多边形 -### 返回值 {#returned-value-7} +### 返回值 {#returned-value-12} Float64 @@ -276,7 +409,7 @@ Float64 计算两个多边形之间的距离 -### 示例 {#example-8} +### 示例 {#example-13} ```sql SELECT polygonsDistanceCartesian([[[(0, 0), (0, 0.1), (0.1, 0.1), (0.1, 0)]]], [[[(10., 10.), (10., 40.), (40., 40.), (40., 10.), (10., 10.)]]]) @@ -285,19 +418,19 @@ SELECT polygonsDistanceCartesian([[[(0, 0), (0, 0.1), (0.1, 0.1), (0.1, 0)]]], [ 14.000714267493642 ``` -### 输入参数 {#input-parameters-4} +### 输入参数 {#input-parameters-6} 两个多边形 -### 返回值 {#returned-value-8} +### 返回值 {#returned-value-13} Float64 ## polygonsEqualsCartesian {#polygonsequalscartesian} -如果两个多边形相等,则返回真 +如果两个多边形相等,则返回 true -### 示例 {#example-9} +### 示例 {#example-14} ```sql SELECT polygonsEqualsCartesian([[[(1., 1.), (1., 4.), (4., 4.), (4., 1.)]]], [[[(1., 1.), (1., 4.), (4., 4.), (4., 1.), (1., 1.)]]]) @@ -306,19 +439,19 @@ SELECT polygonsEqualsCartesian([[[(1., 1.), (1., 4.), (4., 4.), (4., 1.)]]], [[[ 1 ``` -### 输入参数 {#input-parameters-5} +### 输入参数 {#input-parameters-7} 两个多边形 -### 返回值 {#returned-value-9} +### 返回值 {#returned-value-14} UInt8,0 表示 false,1 表示 true ## polygonsSymDifferenceSpherical {#polygonssymdifferencespherical} -计算两个多边形之间的空间集合理论对称差异 (XOR) +计算两个多边形之间的空间集合理论对称差异(XOR) -### 示例 {#example-10} +### 示例 {#example-15} ```sql SELECT wkt(arraySort(polygonsSymDifferenceSpherical([[(50., 50.), (50., -50.), (-50., -50.), (-50., 50.), (50., 50.)], [(10., 10.), (10., 40.), (40., 40.), (40., 10.), (10., 10.)], [(-10., -10.), (-10., -40.), (-40., -40.), (-40., -10.), (-10., -10.)]], [[(-20., -20.), (-20., 20.), (20., 20.), (20., -20.), (-20., -20.)]]))); @@ -327,19 +460,19 @@ SELECT wkt(arraySort(polygonsSymDifferenceSpherical([[(50., 50.), (50., -50.), ( MULTIPOLYGON(((-20 -10.3067,-10 -10,-10 -20.8791,-20 -20,-20 -10.3067)),((10 20.8791,20 20,20 10.3067,10 10,10 20.8791)),((50 50,50 -50,-50 -50,-50 50,50 50),(20 10.3067,40 10,40 40,10 40,10 20.8791,-20 20,-20 -10.3067,-40 -10,-40 -40,-10 -40,-10 -20.8791,20 -20,20 10.3067))) ``` -### 输入参数 {#input-parameters-6} +### 输入参数 {#input-parameters-8} 多边形 -### 返回值 {#returned-value-10} +### 返回值 {#returned-value-15} MultiPolygon ## polygonsSymDifferenceCartesian {#polygonssymdifferencecartesian} -与 `polygonsSymDifferenceSpherical` 相同,但坐标处于笛卡尔坐标系中;更接近于现实世界的模型。 +与 `polygonsSymDifferenceSpherical` 相同,但坐标位于笛卡尔坐标系统中;这更接近真实地球的模型。 -### 示例 {#example-11} +### 示例 {#example-16} ```sql SELECT wkt(polygonsSymDifferenceCartesian([[[(0, 0), (0, 3), (1, 2.9), (2, 2.6), (2.6, 2), (2.9, 1), (3, 0), (0, 0)]]], [[[(1., 1.), (1., 4.), (4., 4.), (4., 1.), (1., 1.)]]])) @@ -348,19 +481,19 @@ SELECT wkt(polygonsSymDifferenceCartesian([[[(0, 0), (0, 3), (1, 2.9), (2, 2.6), MULTIPOLYGON(((1 2.9,1 1,2.9 1,3 0,0 0,0 3,1 2.9)),((1 2.9,1 4,4 4,4 1,2.9 1,2.6 2,2 2.6,1 2.9))) ``` -### 输入参数 {#input-parameters-7} +### 输入参数 {#input-parameters-9} 多边形 -### 返回值 {#returned-value-11} +### 返回值 {#returned-value-16} MultiPolygon ## polygonsIntersectionSpherical {#polygonsintersectionspherical} -计算多边形间的交集(AND),坐标为球面坐标。 +计算多边形之间的交集(AND),坐标为球面坐标。 -### 示例 {#example-12} +### 示例 {#example-17} ```sql SELECT wkt(arrayMap(a -> arrayMap(b -> arrayMap(c -> (round(c.1, 6), round(c.2, 6)), b), a), polygonsIntersectionSpherical([[[(4.3613577, 50.8651821), (4.349556, 50.8535879), (4.3602419, 50.8435626), (4.3830299, 50.8428851), (4.3904543, 50.8564867), (4.3613148, 50.8651279)]]], [[[(4.346693, 50.858306), (4.367945, 50.852455), (4.366227, 50.840809), (4.344961, 50.833264), (4.338074, 50.848677), (4.346693, 50.858306)]]]))) @@ -369,19 +502,19 @@ SELECT wkt(arrayMap(a -> arrayMap(b -> arrayMap(c -> (round(c.1, 6), round(c.2, MULTIPOLYGON(((4.3666 50.8434,4.36024 50.8436,4.34956 50.8536,4.35268 50.8567,4.36794 50.8525,4.3666 50.8434))) ``` -### 输入参数 {#input-parameters-8} +### 输入参数 {#input-parameters-10} 多边形 -### 返回值 {#returned-value-12} +### 返回值 {#returned-value-17} MultiPolygon ## polygonsWithinCartesian {#polygonswithincartesian} -如果第二个多边形位于第一个多边形内,则返回真。 +如果第二个多边形在第一个多边形内,则返回 true。 -### 示例 {#example-13} +### 示例 {#example-18} ```sql SELECT polygonsWithinCartesian([[[(2., 2.), (2., 3.), (3., 3.), (3., 2.)]]], [[[(1., 1.), (1., 4.), (4., 4.), (4., 1.), (1., 1.)]]]) @@ -390,11 +523,53 @@ SELECT polygonsWithinCartesian([[[(2., 2.), (2., 3.), (3., 3.), (3., 2.)]]], [[[ 1 ``` -### 输入参数 {#input-parameters-9} +### 输入参数 {#input-parameters-11} 两个多边形 -### 返回值 {#returned-value-13} +### 返回值 {#returned-value-18} + +UInt8,0 表示 false,1 表示 true + +## polygonsIntersectCartesian {#polygonsintersectcartesian} + +如果两个多边形相交(共享任何公共区域或边界),则返回 true。 + +### 示例 {#example-intersects-cartesian} + +```sql +SELECT polygonsIntersectCartesian([[[(2., 2.), (2., 3.), (3., 3.), (3., 2.)]]], [[[(1., 1.), (1., 4.), (4., 4.), (4., 1.), (1., 1.)]]]) +``` +```response +1 +``` + +### 输入参数 {#input-parameters-intersects-cartesian} + +两个多边形 + +### 返回值 {#returned-value-intersects-cartesian} + +UInt8,0 表示 false,1 表示 true + +## polygonsIntersectSpherical {#polygonsintersectspherical} + +如果两个多边形相交(共享任何公共区域或边界),则返回 true。参考 https://www.boost.org/doc/libs/1_62_0/libs/geometry/doc/html/geometry/reference/algorithms/intersects.html + +### 示例 {#example-intersects-spherical} + +```sql +SELECT polygonsIntersectSpherical([[[(4.3613577, 50.8651821), (4.349556, 50.8535879), (4.3602419, 50.8435626), (4.3830299, 50.8428851), (4.3904543, 50.8564867), (4.3613148, 50.8651279)]]], [[[(4.346693, 50.858306), (4.367945, 50.852455), (4.366227, 50.840809), (4.344961, 50.833264), (4.338074, 50.848677), (4.346693, 50.858306)]]]); +``` +```response +1 +``` + +### 输入参数 {#input-parameters-intersects-spherical} + +两个多边形 + +### 返回值 {#returned-value-intersects-spherical} UInt8,0 表示 false,1 表示 true @@ -402,9 +577,9 @@ UInt8,0 表示 false,1 表示 true 计算凸包。 [参考](https://www.boost.org/doc/libs/1_61_0/libs/geometry/doc/html/geometry/reference/algorithms/convex_hull.html) -坐标处于笛卡尔坐标系中。 +坐标位于笛卡尔坐标系统中。 -### 示例 {#example-14} +### 示例 {#example-19} ```sql SELECT wkt(polygonConvexHullCartesian([[[(0., 0.), (0., 5.), (5., 5.), (5., 0.), (2., 3.)]]])) @@ -413,11 +588,11 @@ SELECT wkt(polygonConvexHullCartesian([[[(0., 0.), (0., 5.), (5., 5.), (5., 0.), POLYGON((0 0,0 5,5 5,5 0,0 0)) ``` -### 输入参数 {#input-parameters-10} +### 输入参数 {#input-parameters-12} MultiPolygon -### 返回值 {#returned-value-14} +### 返回值 {#returned-value-19} Polygon @@ -425,7 +600,7 @@ Polygon 计算多边形的表面积。 -### 示例 {#example-15} +### 示例 {#example-20} ```sql SELECT round(polygonAreaSpherical([[[(4.346693, 50.858306), (4.367945, 50.852455), (4.366227, 50.840809), (4.344961, 50.833264), (4.338074, 50.848677), (4.346693, 50.858306)]]]), 14) @@ -434,19 +609,19 @@ SELECT round(polygonAreaSpherical([[[(4.346693, 50.858306), (4.367945, 50.852455 9.387704e-8 ``` -### 输入参数 {#input-parameters-11} +### 输入参数 {#input-parameters-13} Polygon -### 返回值 {#returned-value-15} +### 返回值 {#returned-value-20} Float ## polygonsUnionSpherical {#polygonsunionspherical} -计算并集 (OR)。 +计算并集(OR)。 -### 示例 {#example-16} +### 示例 {#example-21} ```sql SELECT wkt(polygonsUnionSpherical([[[(4.3613577, 50.8651821), (4.349556, 50.8535879), (4.3602419, 50.8435626), (4.3830299, 50.8428851), (4.3904543, 50.8564867), (4.3613148, 50.8651279)]]], [[[(4.346693, 50.858306), (4.367945, 50.852455), (4.366227, 50.840809), (4.344961, 50.833264), (4.338074, 50.848677), (4.346693, 50.858306)]]])) @@ -455,11 +630,11 @@ SELECT wkt(polygonsUnionSpherical([[[(4.3613577, 50.8651821), (4.349556, 50.8535 MULTIPOLYGON(((4.36661 50.8434,4.36623 50.8408,4.34496 50.8333,4.33807 50.8487,4.34669 50.8583,4.35268 50.8567,4.36136 50.8652,4.36131 50.8651,4.39045 50.8565,4.38303 50.8429,4.36661 50.8434))) ``` -### 输入参数 {#input-parameters-12} +### 输入参数 {#input-parameters-14} 多边形 -### 返回值 {#returned-value-16} +### 返回值 {#returned-value-21} MultiPolygon @@ -467,11 +642,11 @@ MultiPolygon 计算多边形的周长。 -### 示例 {#example-17} +### 示例 {#example-22} -#### 表示津巴布韦的多边形 {#polygon-representing-zimbabwe} +#### 代表津巴布韦的多边形 {#polygon-representing-zimbabwe} -这是表示津巴布韦的多边形: +这是代表津巴布韦的多边形: ```text POLYGON((30.0107 -15.6462,30.0502 -15.6401,30.09 -15.6294,30.1301 -15.6237,30.1699 -15.6322,30.1956 -15.6491,30.2072 -15.6532,30.2231 -15.6497,30.231 -15.6447,30.2461 -15.6321,30.2549 -15.6289,30.2801 -15.6323,30.2962 -15.639,30.3281 -15.6524,30.3567 -15.6515,30.3963 -15.636,30.3977 -15.7168,30.3993 -15.812,30.4013 -15.9317,30.4026 -16.0012,30.5148 -16.0004,30.5866 -16,30.7497 -15.9989,30.8574 -15.9981,30.9019 -16.0071,30.9422 -16.0345,30.9583 -16.0511,30.9731 -16.062,30.9898 -16.0643,31.012 -16.0549,31.0237 -16.0452,31.0422 -16.0249,31.0569 -16.0176,31.0654 -16.0196,31.0733 -16.0255,31.0809 -16.0259,31.089 -16.0119,31.1141 -15.9969,31.1585 -16.0002,31.26 -16.0235,31.2789 -16.0303,31.2953 -16.0417,31.3096 -16.059,31.3284 -16.0928,31.3409 -16.1067,31.3603 -16.1169,31.3703 -16.1237,31.3746 -16.1329,31.3778 -16.1422,31.384 -16.1488,31.3877 -16.1496,31.3956 -16.1477,31.3996 -16.1473,31.4043 -16.1499,31.4041 -16.1545,31.4027 -16.1594,31.4046 -16.1623,31.4241 -16.1647,31.4457 -16.165,31.4657 -16.1677,31.4806 -16.178,31.5192 -16.1965,31.6861 -16.2072,31.7107 -16.2179,31.7382 -16.2398,31.7988 -16.3037,31.8181 -16.3196,31.8601 -16.3408,31.8719 -16.3504,31.8807 -16.368,31.8856 -16.4063,31.8944 -16.4215,31.9103 -16.4289,32.0141 -16.4449,32.2118 -16.4402,32.2905 -16.4518,32.3937 -16.4918,32.5521 -16.5534,32.6718 -16.5998,32.6831 -16.6099,32.6879 -16.6243,32.6886 -16.6473,32.6987 -16.6868,32.7252 -16.7064,32.7309 -16.7087,32.7313 -16.7088,32.7399 -16.7032,32.7538 -16.6979,32.7693 -16.6955,32.8007 -16.6973,32.862 -16.7105,32.8934 -16.7124,32.9096 -16.7081,32.9396 -16.6898,32.9562 -16.6831,32.9685 -16.6816,32.9616 -16.7103,32.9334 -16.8158,32.9162 -16.8479,32.9005 -16.8678,32.8288 -16.9351,32.8301 -16.9415,32.8868 -17.0382,32.9285 -17.1095,32.9541 -17.1672,32.9678 -17.2289,32.9691 -17.2661,32.9694 -17.2761,32.9732 -17.2979,32.9836 -17.3178,32.9924 -17.3247,33.0147 -17.3367,33.0216 -17.3456,33.0225 -17.3615,33.0163 -17.3772,33.0117 -17.384,32.9974 -17.405,32.9582 -17.4785,32.9517 -17.4862,32.943 -17.4916,32.9366 -17.4983,32.9367 -17.5094,32.9472 -17.5432,32.9517 -17.5514,32.9691 -17.5646,33.0066 -17.581,33.0204 -17.5986,33.0245 -17.6192,33.0206 -17.6385,33.0041 -17.6756,33.0002 -17.7139,33.0032 -17.7577,32.9991 -17.7943,32.9736 -17.8106,32.957 -17.818,32.9461 -17.8347,32.9397 -17.8555,32.9369 -17.875,32.9384 -17.8946,32.9503 -17.9226,32.9521 -17.9402,32.9481 -17.9533,32.9404 -17.96,32.9324 -17.9649,32.9274 -17.9729,32.929 -17.9823,32.9412 -17.9963,32.9403 -18.0048,32.9349 -18.0246,32.9371 -18.0471,32.9723 -18.1503,32.9755 -18.1833,32.9749 -18.1908,32.9659 -18.2122,32.9582 -18.2254,32.9523 -18.233,32.9505 -18.2413,32.955 -18.2563,32.9702 -18.2775,33.0169 -18.3137,33.035 -18.3329,33.0428 -18.352,33.0381 -18.3631,33.0092 -18.3839,32.9882 -18.4132,32.9854 -18.4125,32.9868 -18.4223,32.9995 -18.4367,33.003 -18.4469,32.9964 -18.4671,32.9786 -18.4801,32.9566 -18.4899,32.9371 -18.501,32.9193 -18.51,32.9003 -18.5153,32.8831 -18.5221,32.8707 -18.5358,32.8683 -18.5526,32.8717 -18.5732,32.8845 -18.609,32.9146 -18.6659,32.9223 -18.6932,32.9202 -18.7262,32.9133 -18.753,32.9025 -18.7745,32.8852 -18.7878,32.8589 -18.79,32.8179 -18.787,32.7876 -18.7913,32.6914 -18.8343,32.6899 -18.8432,32.6968 -18.8972,32.7032 -18.9119,32.7158 -18.9198,32.7051 -18.9275,32.6922 -18.9343,32.6825 -18.9427,32.6811 -18.955,32.6886 -18.9773,32.6903 -18.9882,32.6886 -19.001,32.6911 -19.0143,32.699 -19.0222,32.7103 -19.026,32.7239 -19.0266,32.786 -19.0177,32.8034 -19.0196,32.8142 -19.0238,32.82 -19.0283,32.823 -19.0352,32.8253 -19.0468,32.8302 -19.0591,32.8381 -19.0669,32.8475 -19.0739,32.8559 -19.0837,32.8623 -19.1181,32.8332 -19.242,32.8322 -19.2667,32.8287 -19.2846,32.8207 -19.3013,32.8061 -19.3234,32.7688 -19.3636,32.7665 -19.3734,32.7685 -19.4028,32.7622 -19.4434,32.7634 -19.464,32.7739 -19.4759,32.7931 -19.4767,32.8113 -19.4745,32.8254 -19.4792,32.8322 -19.5009,32.8325 -19.5193,32.8254 -19.5916,32.8257 -19.6008,32.8282 -19.6106,32.8296 -19.6237,32.8254 -19.6333,32.8195 -19.642,32.8163 -19.6521,32.8196 -19.6743,32.831 -19.6852,32.8491 -19.6891,32.8722 -19.6902,32.8947 -19.6843,32.9246 -19.6553,32.9432 -19.6493,32.961 -19.6588,32.9624 -19.6791,32.9541 -19.7178,32.9624 -19.7354,32.9791 -19.7514,33.0006 -19.7643,33.0228 -19.7731,33.0328 -19.7842,33.0296 -19.8034,33.0229 -19.8269,33.0213 -19.8681,33.002 -19.927,32.9984 -20.0009,33.0044 -20.0243,33.0073 -20.032,32.9537 -20.0302,32.9401 -20.0415,32.9343 -20.0721,32.9265 -20.0865,32.9107 -20.0911,32.8944 -20.094,32.8853 -20.103,32.8779 -20.1517,32.8729 -20.1672,32.8593 -20.1909,32.8571 -20.2006,32.8583 -20.2075,32.8651 -20.2209,32.8656 -20.2289,32.8584 -20.2595,32.853 -20.2739,32.8452 -20.2867,32.8008 -20.3386,32.7359 -20.4142,32.7044 -20.4718,32.6718 -20.5318,32.6465 -20.558,32.6037 -20.5648,32.5565 -20.5593,32.5131 -20.5646,32.4816 -20.603,32.4711 -20.6455,32.4691 -20.6868,32.4835 -20.7942,32.4972 -20.8981,32.491 -20.9363,32.4677 -20.9802,32.4171 -21.0409,32.3398 -21.1341,32.3453 -21.1428,32.3599 -21.1514,32.3689 -21.163,32.3734 -21.1636,32.3777 -21.1634,32.3806 -21.1655,32.3805 -21.1722,32.3769 -21.1785,32.373 -21.184,32.3717 -21.1879,32.4446 -21.3047,32.4458 -21.309,32.4472 -21.3137,32.4085 -21.2903,32.373 -21.3279,32.3245 -21.3782,32.2722 -21.4325,32.2197 -21.4869,32.1673 -21.5413,32.1148 -21.5956,32.0624 -21.65,32.01 -21.7045,31.9576 -21.7588,31.9052 -21.8132,31.8527 -21.8676,31.8003 -21.922,31.7478 -21.9764,31.6955 -22.0307,31.6431 -22.0852,31.5907 -22.1396,31.5382 -22.1939,31.4858 -22.2483,31.4338 -22.302,31.3687 -22.345,31.2889 -22.3973,31.2656 -22.3655,31.2556 -22.358,31.2457 -22.3575,31.2296 -22.364,31.2215 -22.3649,31.2135 -22.3619,31.1979 -22.3526,31.1907 -22.3506,31.1837 -22.3456,31.1633 -22.3226,31.1526 -22.3164,31.1377 -22.3185,31.1045 -22.3334,31.097 -22.3349,31.0876 -22.3369,31.0703 -22.3337,31.0361 -22.3196,30.9272 -22.2957,30.8671 -22.2896,30.8379 -22.2823,30.8053 -22.2945,30.6939 -22.3028,30.6743 -22.3086,30.6474 -22.3264,30.6324 -22.3307,30.6256 -22.3286,30.6103 -22.3187,30.6011 -22.3164,30.5722 -22.3166,30.5074 -22.3096,30.4885 -22.3102,30.4692 -22.3151,30.4317 -22.3312,30.4127 -22.3369,30.3721 -22.3435,30.335 -22.3447,30.3008 -22.337,30.2693 -22.3164,30.2553 -22.3047,30.2404 -22.2962,30.2217 -22.2909,30.197 -22.2891,30.1527 -22.2948,30.1351 -22.2936,30.1111 -22.2823,30.0826 -22.2629,30.0679 -22.2571,30.0381 -22.2538,30.0359 -22.2506,30.0345 -22.2461,30.0155 -22.227,30.0053 -22.2223,29.9838 -22.2177,29.974 -22.214,29.9467 -22.1983,29.9321 -22.1944,29.896 -22.1914,29.8715 -22.1793,29.8373 -22.1724,29.7792 -22.1364,29.7589 -22.1309,29.6914 -22.1341,29.6796 -22.1383,29.6614 -22.1265,29.6411 -22.1292,29.604 -22.1451,29.5702 -22.142,29.551 -22.146,29.5425 -22.1625,29.5318 -22.1724,29.5069 -22.1701,29.4569 -22.1588,29.4361 -22.1631,29.3995 -22.1822,29.378 -22.1929,29.3633 -22.1923,29.3569 -22.1909,29.3501 -22.1867,29.2736 -22.1251,29.2673 -22.1158,29.2596 -22.0961,29.2541 -22.0871,29.2444 -22.0757,29.2393 -22.0726,29.1449 -22.0753,29.108 -22.0692,29.0708 -22.051,29.0405 -22.0209,29.0216 -21.9828,29.0138 -21.9404,29.0179 -21.8981,29.0289 -21.8766,29.0454 -21.8526,29.0576 -21.8292,29.0553 -21.81,29.0387 -21.7979,28.9987 -21.786,28.9808 -21.7748,28.9519 -21.7683,28.891 -21.7649,28.8609 -21.7574,28.7142 -21.6935,28.6684 -21.68,28.6297 -21.6513,28.6157 -21.6471,28.5859 -21.6444,28.554 -21.6366,28.5429 -21.6383,28.5325 -21.6431,28.4973 -21.6515,28.4814 -21.6574,28.4646 -21.6603,28.4431 -21.6558,28.3618 -21.6163,28.3219 -21.6035,28.2849 -21.5969,28.1657 -21.5952,28.0908 -21.5813,28.0329 -21.5779,28.0166 -21.5729,28.0026 -21.5642,27.9904 -21.5519,27.9847 -21.5429,27.9757 -21.5226,27.9706 -21.5144,27.9637 -21.5105,27.9581 -21.5115,27.9532 -21.5105,27.9493 -21.5008,27.9544 -21.4878,27.9504 -21.482,27.9433 -21.4799,27.9399 -21.478,27.9419 -21.4685,27.9496 -21.4565,27.953 -21.4487,27.9502 -21.4383,27.9205 -21.3812,27.9042 -21.3647,27.8978 -21.3554,27.8962 -21.3479,27.8967 -21.3324,27.8944 -21.3243,27.885 -21.3102,27.8491 -21.2697,27.8236 -21.2317,27.7938 -21.1974,27.7244 -21.1497,27.7092 -21.1345,27.6748 -21.0901,27.6666 -21.0712,27.6668 -21.0538,27.679 -21.0007,27.6804 -20.9796,27.6727 -20.9235,27.6726 -20.9137,27.6751 -20.8913,27.6748 -20.8799,27.676 -20.8667,27.6818 -20.8576,27.689 -20.849,27.6944 -20.8377,27.7096 -20.7567,27.7073 -20.7167,27.6825 -20.6373,27.6904 -20.6015,27.7026 -20.5661,27.7056 -20.5267,27.6981 -20.5091,27.6838 -20.4961,27.666 -20.4891,27.6258 -20.4886,27.5909 -20.4733,27.5341 -20.483,27.4539 -20.4733,27.3407 -20.473,27.306 -20.4774,27.2684 -20.4958,27.284 -20.3515,27.266 -20.2342,27.2149 -20.1105,27.2018 -20.093,27.1837 -20.0823,27.1629 -20.0766,27.1419 -20.0733,27.1297 -20.0729,27.1198 -20.0739,27.1096 -20.0732,27.0973 -20.0689,27.0865 -20.0605,27.0692 -20.0374,27.0601 -20.0276,27.0267 -20.0101,26.9943 -20.0068,26.9611 -20.0072,26.9251 -20.0009,26.8119 -19.9464,26.7745 -19.9398,26.7508 -19.9396,26.731 -19.9359,26.7139 -19.9274,26.6986 -19.9125,26.6848 -19.8945,26.6772 -19.8868,26.6738 -19.8834,26.6594 -19.8757,26.6141 -19.8634,26.5956 -19.8556,26.5819 -19.8421,26.5748 -19.8195,26.5663 -19.8008,26.5493 -19.7841,26.5089 -19.7593,26.4897 -19.7519,26.4503 -19.7433,26.4319 -19.7365,26.4128 -19.7196,26.3852 -19.6791,26.3627 -19.6676,26.3323 -19.6624,26.3244 -19.6591,26.3122 -19.6514,26.3125 -19.6496,26.3191 -19.6463,26.3263 -19.6339,26.3335 -19.613,26.331 -19.605,26.3211 -19.592,26.3132 -19.5842,26.3035 -19.5773,26.2926 -19.5725,26.2391 -19.5715,26.1945 -19.5602,26.1555 -19.5372,26.1303 -19.5011,26.0344 -19.2437,26.0114 -19.1998,25.9811 -19.1618,25.9565 -19.1221,25.9486 -19.1033,25.9449 -19.0792,25.9481 -19.0587,25.9644 -19.0216,25.9678 -19.001,25.9674 -18.9999,25.9407 -18.9213,25.8153 -18.814,25.7795 -18.7388,25.7734 -18.6656,25.7619 -18.6303,25.7369 -18.6087,25.6983 -18.5902,25.6695 -18.566,25.6221 -18.5011,25.6084 -18.4877,25.5744 -18.4657,25.5085 -18.3991,25.4956 -18.3789,25.4905 -18.3655,25.4812 -18.3234,25.4732 -18.3034,25.4409 -18.2532,25.4088 -18.176,25.3875 -18.139,25.3574 -18.1158,25.3234 -18.0966,25.2964 -18.0686,25.255 -18.0011,25.2261 -17.9319,25.2194 -17.908,25.2194 -17.8798,25.2598 -17.7941,25.2667 -17.8009,25.2854 -17.8093,25.3159 -17.8321,25.3355 -17.8412,25.3453 -17.8426,25.3765 -17.8412,25.4095 -17.853,25.4203 -17.8549,25.4956 -17.8549,25.5007 -17.856,25.5102 -17.8612,25.5165 -17.8623,25.5221 -17.8601,25.5309 -17.851,25.5368 -17.8487,25.604 -17.8362,25.657 -17.8139,25.6814 -17.8115,25.6942 -17.8194,25.7064 -17.8299,25.7438 -17.8394,25.766 -17.8498,25.786 -17.8622,25.7947 -17.8727,25.8044 -17.8882,25.8497 -17.9067,25.8636 -17.9238,25.8475 -17.9294,25.8462 -17.9437,25.8535 -17.96,25.8636 -17.9716,25.9245 -17.999,25.967 -18.0005,25.9785 -17.999,26.0337 -17.9716,26.0406 -17.9785,26.0466 -17.9663,26.0625 -17.9629,26.0812 -17.9624,26.0952 -17.9585,26.0962 -17.9546,26.0942 -17.9419,26.0952 -17.9381,26.1012 -17.9358,26.1186 -17.9316,26.1354 -17.9226,26.1586 -17.9183,26.1675 -17.9136,26.203 -17.8872,26.2119 -17.8828,26.2211 -17.8863,26.2282 -17.8947,26.2339 -17.904,26.2392 -17.9102,26.2483 -17.9134,26.2943 -17.9185,26.3038 -17.9228,26.312 -17.9284,26.3183 -17.9344,26.3255 -17.936,26.3627 -17.9306,26.4086 -17.939,26.4855 -17.9793,26.5271 -17.992,26.5536 -17.9965,26.5702 -18.0029,26.5834 -18.0132,26.5989 -18.03,26.6127 -18.0412,26.6288 -18.0492,26.6857 -18.0668,26.7 -18.0692,26.7119 -18.0658,26.7406 -18.0405,26.7536 -18.033,26.7697 -18.029,26.794 -18.0262,26.8883 -17.9846,26.912 -17.992,26.9487 -17.9689,26.9592 -17.9647,27.0063 -17.9627,27.0213 -17.9585,27.0485 -17.9443,27.0782 -17.917,27.1154 -17.8822,27.149 -17.8425,27.1465 -17.8189,27.1453 -17.7941,27.147 -17.7839,27.1571 -17.7693,27.4221 -17.5048,27.5243 -17.4151,27.5773 -17.3631,27.6045 -17.3128,27.6249 -17.2333,27.6412 -17.1985,27.7773 -17.0012,27.8169 -16.9596,27.8686 -16.9297,28.023 -16.8654,28.1139 -16.8276,28.2125 -16.7486,28.2801 -16.7065,28.6433 -16.5688,28.6907 -16.5603,28.7188 -16.5603,28.7328 -16.5581,28.7414 -16.5507,28.7611 -16.5323,28.7693 -16.5152,28.8089 -16.4863,28.8225 -16.4708,28.8291 -16.4346,28.8331 -16.4264,28.8572 -16.3882,28.857 -16.3655,28.8405 -16.3236,28.8368 -16.3063,28.8403 -16.2847,28.8642 -16.2312,28.8471 -16.2027,28.8525 -16.1628,28.8654 -16.1212,28.871 -16.0872,28.8685 -16.0822,28.8638 -16.0766,28.8593 -16.0696,28.8572 -16.0605,28.8603 -16.0494,28.8741 -16.0289,28.8772 -16.022,28.8989 -15.9955,28.9324 -15.9637,28.9469 -15.9572,28.9513 -15.9553,28.9728 -15.9514,29.0181 -15.9506,29.0423 -15.9463,29.0551 -15.9344,29.0763 -15.8954,29.0862 -15.8846,29.1022 -15.8709,29.1217 -15.8593,29.1419 -15.8545,29.151 -15.8488,29.1863 -15.8128,29.407 -15.7142,29.4221 -15.711,29.5085 -15.7036,29.5262 -15.6928,29.5634 -15.6621,29.5872 -15.6557,29.6086 -15.6584,29.628 -15.6636,29.6485 -15.6666,29.6728 -15.6633,29.73 -15.6447,29.7733 -15.6381,29.8143 -15.6197,29.8373 -15.6148,29.8818 -15.6188,29.9675 -15.6415,30.0107 -15.6462)) @@ -486,15 +661,15 @@ SELECT round(polygonPerimeterSpherical([(30.010654, -15.646227), (30.050238, -15 0.45539 ``` -### 输入参数 {#input-parameters-13} +### 输入参数 {#input-parameters-15} -### 返回值 {#returned-value-17} +### 返回值 {#returned-value-22} ## polygonsIntersectionCartesian {#polygonsintersectioncartesian} 计算多边形的交集。 -### 示例 {#example-18} +### 示例 {#example-23} ```sql SELECT wkt(polygonsIntersectionCartesian([[[(0., 0.), (0., 3.), (1., 2.9), (2., 2.6), (2.6, 2.), (2.9, 1.), (3., 0.), (0., 0.)]]], [[[(1., 1.), (1., 4.), (4., 4.), (4., 1.), (1., 1.)]]])) @@ -503,11 +678,11 @@ SELECT wkt(polygonsIntersectionCartesian([[[(0., 0.), (0., 3.), (1., 2.9), (2., MULTIPOLYGON(((1 2.9,2 2.6,2.6 2,2.9 1,1 1,1 2.9))) ``` -### 输入参数 {#input-parameters-14} +### 输入参数 {#input-parameters-16} 多边形 -### 返回值 {#returned-value-18} +### 返回值 {#returned-value-23} MultiPolygon @@ -515,7 +690,7 @@ MultiPolygon 计算多边形的面积 -### 示例 {#example-19} +### 示例 {#example-24} ```sql SELECT polygonAreaCartesian([[[(0., 0.), (0., 5.), (5., 5.), (5., 0.)]]]) @@ -524,11 +699,11 @@ SELECT polygonAreaCartesian([[[(0., 0.), (0., 5.), (5., 5.), (5., 0.)]]]) 25 ``` -### 输入参数 {#input-parameters-15} +### 输入参数 {#input-parameters-17} Polygon -### 返回值 {#returned-value-19} +### 返回值 {#returned-value-24} Float64 @@ -536,7 +711,7 @@ Float64 计算多边形的周长。 -### 示例 {#example-20} +### 示例 {#example-25} ```sql SELECT polygonPerimeterCartesian([[[(0., 0.), (0., 5.), (5., 5.), (5., 0.)]]]) @@ -545,11 +720,11 @@ SELECT polygonPerimeterCartesian([[[(0., 0.), (0., 5.), (5., 5.), (5., 0.)]]]) 15 ``` -### 输入参数 {#input-parameters-16} +### 输入参数 {#input-parameters-18} Polygon -### 返回值 {#returned-value-20} +### 返回值 {#returned-value-25} Float64 @@ -557,7 +732,7 @@ Float64 计算多边形的并集。 -### 示例 {#example-21} +### 示例 {#example-26} ```sql SELECT wkt(polygonsUnionCartesian([[[(0., 0.), (0., 3.), (1., 2.9), (2., 2.6), (2.6, 2.), (2.9, 1), (3., 0.), (0., 0.)]]], [[[(1., 1.), (1., 4.), (4., 4.), (4., 1.), (1., 1.)]]])) @@ -566,12 +741,12 @@ SELECT wkt(polygonsUnionCartesian([[[(0., 0.), (0., 3.), (1., 2.9), (2., 2.6), ( MULTIPOLYGON(((1 2.9,1 4,4 4,4 1,2.9 1,3 0,0 0,0 3,1 2.9))) ``` -### 输入参数 {#input-parameters-17} +### 输入参数 {#input-parameters-19} 多边形 -### 返回值 {#returned-value-21} +### 返回值 {#returned-value-26} MultiPolygon -有关几何系统的更多信息,请参见关于 Boost 库的 [演示文稿](https://archive.fosdem.org/2020/schedule/event/working_with_spatial_trajectories_in_boost_geometry/attachments/slides/3988/export/events/attachments/working_with_spatial_trajectories_in_boost_geometry/slides/3988/FOSDEM20_vissarion.pdf),这是 ClickHouse 使用的内容。 +有关几何系统的更多信息,请参阅关于 Boost 库的此 [演示](https://archive.fosdem.org/2020/schedule/event/working_with_spatial_trajectories_in_boost_geometry/attachments/slides/3988/export/events/attachments/working_with_spatial_trajectories_in_boost_geometry/slides/3988/FOSDEM20_vissarion.pdf),ClickHouse 使用的正是这个库。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/geo/polygon.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/geo/polygon.md.hash index 53c8b623d53..4cd36392f04 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/geo/polygon.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/geo/polygon.md.hash @@ -1 +1 @@ -ee3f1f0c57b9e721 +315bc08c592023ea diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/geo/s2.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/geo/s2.md index 013cebb10e3..4c479d9855b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/geo/s2.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/geo/s2.md @@ -2,21 +2,22 @@ 'slug': '/sql-reference/functions/geo/s2' 'sidebar_label': 'S2 几何' 'title': '用于处理 S2 索引的函数' -'description': '处理 S2 索引的函数的文档' +'description': '用于处理 S2 indexes 的函数的文档' +'doc_type': 'reference' --- -# 函数用于处理 S2 索引 +# 使用 S2 索引的函数 ## S2Index {#s2index} -[S2](https://s2geometry.io/) 是一种地理索引系统,其中所有地理数据都在球体上表示(类似于地球仪)。 +[S2](https://s2geometry.io/) 是一种地理索引系统,其中所有地理数据都在一个球体上表示(类似于地球仪)。 -在 S2 库中,点被表示为 S2 索引——一个特定的数字,它在内部编码了单位球表面上的一个点,不同于传统的(纬度,经度)对。要获取指定为 (纬度,经度) 格式的给定点的 S2 点索引,使用 [geoToS2](#geotos2) 函数。此外,您可以使用 [s2ToGeo](#s2togeo) 函数来获取与指定的 S2 点索引对应的地理坐标。 +在 S2 库中,点被表示为 S2 索引 - 一个特定的数字,它在内部编码一个单位球面上的点,这与传统的(纬度,经度)对不同。要获取指定格式(纬度,经度)的点的 S2 点索引,请使用 [geoToS2](#geotos2) 函数。此外,您可以使用 [s2ToGeo](#s2togeo) 函数获取与指定 S2 点索引对应的地理坐标。 ## geoToS2 {#geotos2} -返回与提供的坐标 `(经度, 纬度)` 对应的 [S2](#s2index) 点索引。 +返回提供的坐标 `(经度, 纬度)` 对应的 [S2](#s2index) 点索引。 **语法** @@ -65,7 +66,7 @@ s2ToGeo(s2index) **返回值** -- 一个 [元组](../../data-types/tuple.md),由两个值组成: +- 一个由两个值组成的 [元组](../../data-types/tuple.md): - `lon`。[Float64](../../data-types/float.md)。 - `lat`。[Float64](../../data-types/float.md)。 @@ -87,7 +88,7 @@ SELECT s2ToGeo(4704772434919038107) AS s2Coodrinates; ## s2GetNeighbors {#s2getneighbors} -返回与提供的 [S2](#s2index) 对应的 S2 邻居索引。在 S2 系统中,每个单元格是一个由四条测地线包围的四边形。因此,每个单元格有 4 个邻居。 +返回与提供的 [S2](#s2index) 对应的 S2 邻居索引。S2 系统中的每个单元格是由四条测地线界定的四边形。因此,每个单元格有 4 个邻居。 **语法** @@ -101,7 +102,7 @@ s2GetNeighbors(s2index) **返回值** -- 一个包含 4 个邻居索引的数组:`array[s2index1, s2index3, s2index2, s2index4]`。[Array](../../data-types/array.md)([UInt64](../../data-types/int-uint.md))。 +- 一个由 4 个邻居索引组成的数组:`array[s2index1, s2index3, s2index2, s2index4]`。[Array](../../data-types/array.md)([UInt64](../../data-types/int-uint.md))。 **示例** @@ -156,7 +157,7 @@ SELECT s2CellsIntersect(9926595209846587392, 9926594385212866560) AS intersect; ## s2CapContains {#s2capcontains} -确定一个帽子是否包含一个 S2 点。帽子表示由平面切割的球体的一部分。它由球体上的一个点和一个以度为单位的半径定义。 +确定一个帽子是否包含一个 S2 点。帽子表示一个被平面切割的球体的一部分。它由球体上的一个点和一个以度为单位的半径定义。 **语法** @@ -229,7 +230,7 @@ SELECT s2CapUnion(3814912406305146967, 1.0, 1157347770437378819, 1.0) AS capUnio ## s2RectAdd {#s2rectadd} -增加边界矩形的大小,以包含给定的 S2 点。在 S2 系统中,矩形由一种称为 `S2LatLngRect` 的 S2Region 类型表示,该类型代表纬度-经度空间中的矩形。 +增加边界矩形的大小以包括给定的 S2 点。在 S2 系统中,矩形由一种称为 `S2LatLngRect` 的 S2Region 类型表示,它表示纬度-经度空间中的矩形。 **语法** @@ -241,12 +242,12 @@ s2RectAdd(s2pointLow, s2pointHigh, s2Point) - `s2PointLow` — 对应于矩形的低 S2 点索引。[UInt64](../../data-types/int-uint.md)。 - `s2PointHigh` — 对应于矩形的高 S2 点索引。[UInt64](../../data-types/int-uint.md)。 -- `s2Point` — 要包含的目标 S2 点索引。[UInt64](../../data-types/int-uint.md)。 +- `s2Point` — 目标 S2 点索引,边界矩形应增长以包含该点。[UInt64](../../data-types/int-uint.md)。 **返回值** -- `s2PointLow` — 对应于扩展矩形的低 S2 单元格 ID。[UInt64](../../data-types/int-uint.md)。 -- `s2PointHigh` — 对应于扩展矩形的高 S2 单元格 ID。[UInt64](../../data-types/float.md)。 +- `s2PointLow` — 对应于增长矩形的低 S2 单元格 ID。[UInt64](../../data-types/int-uint.md)。 +- `s2PointHigh` — 对应于增长矩形的高 S2 单元格 ID。[UInt64](../../data-types/float.md)。 **示例** @@ -266,7 +267,7 @@ SELECT s2RectAdd(5178914411069187297, 5177056748191934217, 5179056748191934217) ## s2RectContains {#s2rectcontains} -确定给定矩形是否包含一个 S2 点。在 S2 系统中,矩形由一种称为 `S2LatLngRect` 的 S2Region 类型表示,该类型代表纬度-经度空间中的矩形。 +确定给定的矩形是否包含一个 S2 点。在 S2 系统中,矩形由一种称为 `S2LatLngRect` 的 S2Region 类型表示,它表示纬度-经度空间中的矩形。 **语法** @@ -303,7 +304,7 @@ SELECT s2RectContains(5179062030687166815, 5177056748191934217, 5177914411069187 ## s2RectUnion {#s2rectunion} -返回包含此矩形与给定矩形的并集的最小矩形。在 S2 系统中,矩形由一种称为 `S2LatLngRect` 的 S2Region 类型表示,该类型代表纬度-经度空间中的矩形。 +返回包含此矩形与给定矩形的并集的最小矩形。在 S2 系统中,矩形由一种称为 `S2LatLngRect` 的 S2Region 类型表示,它表示纬度-经度空间中的矩形。 **语法** @@ -318,8 +319,8 @@ s2RectUnion(s2Rect1PointLow, s2Rect1PointHi, s2Rect2PointLow, s2Rect2PointHi) **返回值** -- `s2UnionRect2PointLow` — 对应于联合矩形的低 S2 单元格 ID。[UInt64](../../data-types/int-uint.md)。 -- `s2UnionRect2PointHi` — 对应于联合矩形的高 S2 单元格 ID。[UInt64](../../data-types/int-uint.md)。 +- `s2UnionRect2PointLow` — 对应于并集矩形的低 S2 单元格 ID。[UInt64](../../data-types/int-uint.md)。 +- `s2UnionRect2PointHi` — 对应于并集矩形的高 S2 单元格 ID。[UInt64](../../data-types/int-uint.md)。 **示例** @@ -339,7 +340,7 @@ SELECT s2RectUnion(5178914411069187297, 5177056748191934217, 5179062030687166815 ## s2RectIntersection {#s2rectintersection} -返回包含此矩形与给定矩形的交集的最小矩形。在 S2 系统中,矩形由一种称为 `S2LatLngRect` 的 S2Region 类型表示,该类型代表纬度-经度空间中的矩形。 +返回包含此矩形与给定矩形交集的最小矩形。在 S2 系统中,矩形由一种称为 `S2LatLngRect` 的 S2Region 类型表示,它表示纬度-经度空间中的矩形。 **语法** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/geo/s2.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/geo/s2.md.hash index c2ca9a48061..0242c824ac3 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/geo/s2.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/geo/s2.md.hash @@ -1 +1 @@ -4d8566bdd5a50803 +0c903eeb912204e6 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/geo/svg.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/geo/svg.md index 0677ebb99da..b20f0904353 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/geo/svg.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/geo/svg.md @@ -1,13 +1,14 @@ --- -'description': 'SVG的文档' +'description': 'Svg的文档' 'sidebar_label': 'SVG' 'slug': '/sql-reference/functions/geo/svg' 'title': '从地理数据生成SVG图像的函数' +'doc_type': 'reference' --- ## Svg {#svg} -返回来自 Geo 数据的选择的 SVG 元素标签字符串。 +返回从地理数据中选择的 SVG 元素标签的字符串。 **语法** @@ -19,12 +20,12 @@ Svg(geometry,[style]) **参数** -- `geometry` — Geo 数据。 [Geo](../../data-types/geo). -- `style` — 可选的样式名称。 [String](../../data-types/string). +- `geometry` — 地理数据。 [Geo](../../data-types/geo). +- `style` — 可选样式名称。 [String](../../data-types/string). **返回值** -- 几何的 SVG 表示。 [String](../../data-types/string). +- 几何图形的 SVG 表示。 [String](../../data-types/string). - SVG 圆形 - SVG 多边形 - SVG 路径 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/geo/svg.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/geo/svg.md.hash index bf849be4af1..bf3fc5b75fa 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/geo/svg.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/geo/svg.md.hash @@ -1 +1 @@ -011f6803f8563d21 +0e15e5a9703cc433 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/hash-functions.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/hash-functions.md index 1c2183a2c79..ecbe1d54c46 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/hash-functions.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/hash-functions.md @@ -1,1641 +1,2347 @@ --- 'description': '哈希函数的文档' 'sidebar_label': 'Hash' -'sidebar_position': 85 'slug': '/sql-reference/functions/hash-functions' 'title': '哈希函数' +'doc_type': 'reference' --- +# Hash 函数 -# Hash Functions +Hash 函数可用于元素的确定性伪随机洗牌。 -哈希函数可用于元素的确定性伪随机洗牌。 +Simhash 是一种 hash 函数,对于相似(接近)的参数返回相近的 hash 值。 -Simhash 是一种哈希函数,它为相近(相似)的参数返回相近的哈希值。 - -大多数哈希函数接受任意数量的任意类型的参数。 +大多数 hash 函数接受任意数量和类型的参数。 :::note -NULL 的哈希值是 NULL。要获得 Nullable 列的非 NULL 哈希值,请将其包装在元组中: +NULL 的 Hash 值是 NULL。要获得 Nullable 列的非 NULL hash,请将其包装在元组中: ```sql SELECT cityHash64(tuple(NULL)) ``` ::: :::note -要计算整个表的内容的哈希值,请使用 `sum(cityHash64(tuple(*)))` (或其他哈希函数)。`tuple` 确保包含 NULL 值的行不会被跳过。`sum` 确保行的顺序无关紧要。 +要计算整个表内容的 hash,请使用 `sum(cityHash64(tuple(*)))` (或其他 hash 函数)。`tuple` 确保不会跳过包含 NULL 值的行。`sum` 确保行的顺序无关紧要。 ::: -## halfMD5 {#halfmd5} -[将所有输入参数解释为字符串](/sql-reference/functions/type-conversion-functions#reinterpretasstring)并计算每个参数的 [MD5](https://en.wikipedia.org/wiki/MD5) 哈希值。然后将哈希值组合,取结果字符串哈希的前 8 字节,并将其解释为大端字节顺序的 `UInt64`。 + + + +## BLAKE3 {#BLAKE3} + +Introduced in: v22.10 + + +计算 BLAKE3 hash 字符串,并返回结果字节集作为 FixedString。 +该加密 hash 函数与 BLAKE3 Rust 库集成到 ClickHouse 中。 +该函数相当快,与 SHA-2 比较性能大约快两倍,同时生成的 hash 与 SHA-256 相同长度。 +它返回一个字节数组类型的 BLAKE3 hash,类型为 FixedString(32)。 + + +**语法** ```sql -halfMD5(par1, ...) +BLAKE3(message) ``` -该函数相对较慢(每个处理器核心每秒处理 500 万个短字符串)。 -考虑使用 [sipHash64](#siphash64) 函数代替。 +**参数** + +- `message` — 要 hash 的输入字符串。 [`String`](/sql-reference/data-types/string) -**Arguments** -该函数接受可变数量的输入参数。参数可以是任何 [支持的数据类型](../data-types/index.md)。对于某些数据类型,即使参数的类型不同(不同大小的整数,带有相同数据的命名和未命名的 `Tuple`,以及具有相同数据的 `Map` 和相应的 `Array(Tuple(key, value))` 类型),其哈希函数的计算值可能是相同的。 +**返回值** -**Returned Value** +返回输入字符串的 32 字节 BLAKE3 hash,作为固定长度字符串。 [`FixedString(32)`](/sql-reference/data-types/fixedstring) -一个 [UInt64](../data-types/int-uint.md) 数据类型的哈希值。 +**示例** -**Example** +**hash** -```sql -SELECT halfMD5(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS halfMD5hash, toTypeName(halfMD5hash) AS type; +```sql title=Query +SELECT hex(BLAKE3('ABC')) ``` -```response -┌────────halfMD5hash─┬─type───┐ -│ 186182704141653334 │ UInt64 │ -└────────────────────┴────────┘ +```response title=Response +┌─hex(BLAKE3('ABC'))───────────────────────────────────────────────┐ +│ D1717274597CF0289694F75D96D444B992A096F1AFD8E7BBFA6EBB1D360FEDFC │ +└──────────────────────────────────────────────────────────────────┘ ``` -## MD4 {#md4} +## MD4 {#MD4} -计算字符串的 MD4,并将结果字节集作为 FixedString(16) 返回。 -## MD5 {#md5} +Introduced in: v21.11 -计算字符串的 MD5,并将结果字节集作为 FixedString(16) 返回。 -如果您不特别需要 MD5,但需要一个体面的 128 位加密哈希,请使用 'sipHash128' 函数代替。 -如果您想要与 md5sum 工具输出相同的结果,请使用 lower(hex(MD5(s)))。 -## RIPEMD160 {#ripemd160} -生成 [RIPEMD-160](https://en.wikipedia.org/wiki/RIPEMD) 哈希值。 +计算给定字符串的 MD4 hash。 + -**Syntax** +**语法** ```sql -RIPEMD160(input) +MD4(s) ``` -**Parameters** +**参数** -- `input`: 输入字符串。 [字符串](../data-types/string.md) +- `s` — 要 hash 的输入字符串。 [`String`](/sql-reference/data-types/string) -**Returned value** -- 160 位 `RIPEMD-160` 哈希值,类型为 [FixedString(20)](../data-types/fixedstring.md)。 +**返回值** -**Example** +返回给定输入字符串的 MD4 hash,作为固定长度字符串。 [`FixedString(16)`](/sql-reference/data-types/fixedstring) -使用 [hex](../functions/encoding-functions.md/#hex) 函数将结果表示为十六进制编码字符串。 +**示例** -查询: +**使用示例** -```sql -SELECT HEX(RIPEMD160('The quick brown fox jumps over the lazy dog')); +```sql title=Query +SELECT HEX(MD4('abc')); ``` -```response -┌─HEX(RIPEMD160('The quick brown fox jumps over the lazy dog'))─┐ -│ 37F332F68DB77BD9D7EDD4969571AD671CF9DD3B │ -└───────────────────────────────────────────────────────────────┘ +```response title=Response +┌─hex(MD4('abc'))──────────────────┐ +│ A448017AAF21D8525FC10AE87AA6729D │ +└──────────────────────────────────┘ ``` -## sipHash64 {#siphash64} +## MD5 {#MD5} -生成 64 位 [SipHash](https://en.wikipedia.org/wiki/SipHash) 哈希值。 +Introduced in: v1.1 -```sql -sipHash64(par1,...) -``` -这是一个加密哈希函数。它的速度至少是 [MD5](#md5) 哈希函数的三倍。 +计算给定字符串的 MD5 hash。 + + +**语法** -该函数 [将所有输入参数解释为字符串](/sql-reference/functions/type-conversion-functions#reinterpretasstring) 并计算每个参数的哈希值。然后通过以下算法组合哈希: +```sql +MD5(s) +``` -1. 第一个和第二个哈希值连接到一个数组中并进行哈希。 -2. 先前计算的哈希值和第三个输入参数的哈希值以类似方式进行哈希。 -3. 对原始输入的所有剩余哈希值重复此计算。 +**参数** -**Arguments** +- `s` — 要 hash 的输入字符串。 [`String`](/sql-reference/data-types/string) -该函数接受可变数量的任何 [支持的数据类型](../data-types/index.md) 的输入参数。 -**Returned Value** +**返回值** -一个 [UInt64](../data-types/int-uint.md) 数据类型的哈希值。 +返回给定输入字符串的 MD5 hash,作为固定长度字符串。 [`FixedString(16)`](/sql-reference/data-types/fixedstring) -请注意,对于不同参数类型的相同输入值,计算得到的哈希值可能相等。这影响了例如不同大小的整数类型,带有相同数据的命名和未命名的 `Tuple`,`Map` 以及相应的具有相同数据的 `Array(Tuple(key, value))` 类型。 +**示例** -**Example** +**使用示例** -```sql -SELECT sipHash64(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS SipHash, toTypeName(SipHash) AS type; +```sql title=Query +SELECT HEX(MD5('abc')); ``` -```response -┌──────────────SipHash─┬─type───┐ -│ 11400366955626497465 │ UInt64 │ -└──────────────────────┴────────┘ +```response title=Response +┌─hex(MD5('abc'))──────────────────┐ +│ 900150983CD24FB0D6963F7D28E17F72 │ +└──────────────────────────────────┘ ``` -## sipHash64Keyed {#siphash64keyed} +## RIPEMD160 {#RIPEMD160} + +Introduced in: v24.10 -与 [sipHash64](#siphash64) 相同,但另外接收一个显式的密钥参数,而不是使用固定密钥。 +计算给定字符串的 RIPEMD-160 hash。 -**Syntax** +**语法** ```sql -sipHash64Keyed((k0, k1), par1,...) +RIPEMD160(s) ``` -**Arguments** +**参数** + +- `s` — 要 hash 的输入字符串。 [`String`](/sql-reference/data-types/string) -与 [sipHash64](#siphash64) 相同,但第一个参数是表示密钥的两个 UInt64 值的元组。 -**Returned value** +**返回值** -一个 [UInt64](../data-types/int-uint.md) 数据类型的哈希值。 +返回给定输入字符串的 RIPEMD160 hash,作为固定长度字符串。 [`FixedString(20)`](/sql-reference/data-types/fixedstring) -**Example** +**示例** -查询: +**使用示例** -```sql -SELECT sipHash64Keyed((506097522914230528, 1084818905618843912), array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS SipHash, toTypeName(SipHash) AS type; +```sql title=Query +SELECT HEX(RIPEMD160('The quick brown fox jumps over the lazy dog')); ``` -```response -┌─────────────SipHash─┬─type───┐ -│ 8017656310194184311 │ UInt64 │ -└─────────────────────┴────────┘ +```response title=Response +┌─HEX(RIPEMD160('The quick brown fox jumps over the lazy dog'))─┐ +│ 37F332F68DB77BD9D7EDD4969571AD671CF9DD3B │ +└───────────────────────────────────────────────────────────────┘ ``` -## sipHash128 {#siphash128} +## SHA1 {#SHA1} -与 [sipHash64](#siphash64) 类似,但生成一个 128 位哈希值,即最终的异或折叠状态进行到 128 位。 +Introduced in: v1.1 -:::note -这个 128 位变体与参考实现不同,并且它更弱。 -这个版本存在的原因是,在编写时,没有官方的 128 位 SipHash 扩展。 -新的项目应该使用 [sipHash128Reference](#siphash128reference)。 -::: -**Syntax** +计算给定字符串的 SHA1 hash。 + + +**语法** ```sql -sipHash128(par1,...) +SHA1(s) ``` -**Arguments** +**参数** -与 [sipHash64](#siphash64) 相同。 +- `s` — 要 hash 的输入字符串 [`String`](/sql-reference/data-types/string) -**Returned value** -一个 128 位 `SipHash` 哈希值,类型为 [FixedString(16)](../data-types/fixedstring.md)。 +**返回值** -**Example** +返回给定输入字符串的 SHA1 hash,作为固定长度字符串。 [`FixedString(20)`](/sql-reference/data-types/fixedstring) -查询: +**示例** -```sql -SELECT hex(sipHash128('foo', '\x01', 3)); -``` +**使用示例** -结果: +```sql title=Query +SELECT HEX(SHA1('abc')); +``` -```response -┌─hex(sipHash128('foo', '', 3))────┐ -│ 9DE516A64A414D4B1B609415E4523F24 │ -└──────────────────────────────────┘ +```response title=Response +┌─hex(SHA1('abc'))─────────────────────────┐ +│ A9993E364706816ABA3E25717850C26C9CD0D89D │ +└──────────────────────────────────────────┘ ``` -## sipHash128Keyed {#siphash128keyed} +## SHA224 {#SHA224} -与 [sipHash128](#siphash128) 相同,但另外接收一个显式的密钥参数,而不是使用固定密钥。 +Introduced in: v1.1 -:::note -这个 128 位变体与参考实现不同,并且它更弱。 -这个版本存在的原因是,在编写时,没有官方的 128 位 SipHash 扩展。 -新的项目应该使用 [sipHash128ReferenceKeyed](#siphash128referencekeyed)。 -::: -**Syntax** +计算给定字符串的 SHA224 hash。 + + +**语法** ```sql -sipHash128Keyed((k0, k1), par1,...) +SHA224(s) ``` -**Arguments** +**参数** -与 [sipHash128](#siphash128) 相同,但第一个参数是表示密钥的两个 UInt64 值的元组。 +- `s` — 要 hash 的输入值。 [`String`](/sql-reference/data-types/string) -**Returned value** -一个 128 位 `SipHash` 哈希值,类型为 [FixedString(16)](../data-types/fixedstring.md)。 +**返回值** -**Example** +返回给定输入字符串的 SHA224 hash,作为固定长度字符串。 [`FixedString(28)`](/sql-reference/data-types/fixedstring) -查询: +**示例** -```sql -SELECT hex(sipHash128Keyed((506097522914230528, 1084818905618843912),'foo', '\x01', 3)); -``` +**使用示例** -结果: +```sql title=Query +SELECT HEX(SHA224('abc')); +``` -```response -┌─hex(sipHash128Keyed((506097522914230528, 1084818905618843912), 'foo', '', 3))─┐ -│ B8467F65C8B4CFD9A5F8BD733917D9BF │ -└───────────────────────────────────────────────────────────────────────────────┘ +```response title=Response +┌─hex(SHA224('abc'))───────────────────────────────────────┐ +│ 23097D223405D8228642A477BDA255B32AADBCE4BDA0B3F7E36C9DA7 │ +└──────────────────────────────────────────────────────────┘ ``` -## sipHash128Reference {#siphash128reference} +## SHA256 {#SHA256} + +Introduced in: v1.1 -与 [sipHash128](#siphash128) 相同,但实现了来自 SipHash 原始作者的 128 位算法。 -**Syntax** +计算给定字符串的 SHA256 hash。 + + +**语法** ```sql -sipHash128Reference(par1,...) +SHA256(s) ``` -**Arguments** +**参数** -与 [sipHash128](#siphash128) 相同。 +- `s` — 要 hash 的输入字符串。 [`String`](/sql-reference/data-types/string) -**Returned value** -一个 128 位 `SipHash` 哈希值,类型为 [FixedString(16)](../data-types/fixedstring.md)。 +**返回值** -**Example** +返回给定输入字符串的 SHA256 hash,作为固定长度字符串。 [`FixedString(32)`](/sql-reference/data-types/fixedstring) -查询: +**示例** -```sql -SELECT hex(sipHash128Reference('foo', '\x01', 3)); -``` +**使用示例** -结果: +```sql title=Query +SELECT HEX(SHA256('abc')); +``` -```response -┌─hex(sipHash128Reference('foo', '', 3))─┐ -│ 4D1BE1A22D7F5933C0873E1698426260 │ -└────────────────────────────────────────┘ +```response title=Response +┌─hex(SHA256('abc'))───────────────────────────────────────────────┐ +│ BA7816BF8F01CFEA414140DE5DAE2223B00361A396177A9CB410FF61F20015AD │ +└──────────────────────────────────────────────────────────────────┘ ``` -## sipHash128ReferenceKeyed {#siphash128referencekeyed} +## SHA384 {#SHA384} + +Introduced in: v1.1 + -与 [sipHash128Reference](#siphash128reference) 相同,但另外接收一个显式的密钥参数,而不是使用固定密钥。 +计算给定字符串的 SHA384 hash。 + -**Syntax** +**语法** ```sql -sipHash128ReferenceKeyed((k0, k1), par1,...) +SHA384(s) ``` -**Arguments** +**参数** + +- `s` — 要 hash 的输入字符串。 [`String`](/sql-reference/data-types/string) + -与 [sipHash128Reference](#siphash128reference) 相同,但第一个参数是表示密钥的两个 UInt64 值的元组。 +**返回值** -**Returned value** +返回给定输入字符串的 SHA384 hash,作为固定长度字符串。 [`FixedString(48)`](/sql-reference/data-types/fixedstring) -一个 128 位 `SipHash` 哈希值,类型为 [FixedString(16)](../data-types/fixedstring.md)。 +**示例** -**Example** +**使用示例** -查询: +```sql title=Query +SELECT HEX(SHA384('abc')); +``` -```sql -SELECT hex(sipHash128ReferenceKeyed((506097522914230528, 1084818905618843912),'foo', '\x01', 3)); +```response title=Response +┌─hex(SHA384('abc'))───────────────────────────────────────────────────────────────────────────────┐ +│ CB00753F45A35E8BB5A03D699AC65007272C32AB0EDED1631A8B605A43FF5BED8086072BA1E7CC2358BAECA134C825A7 │ +└──────────────────────────────────────────────────────────────────────────────────────────────────┘ ``` +## SHA512 {#SHA512} -结果: +Introduced in: v1.1 -```response -┌─hex(sipHash128ReferenceKeyed((506097522914230528, 1084818905618843912), 'foo', '', 3))─┐ -│ 630133C9722DC08646156B8130C4CDC8 │ -└────────────────────────────────────────────────────────────────────────────────────────┘ -``` -## cityHash64 {#cityhash64} -生成 64 位 [CityHash](https://github.com/google/cityhash) 哈希值。 +计算给定字符串的 SHA512 hash。 + + +**语法** ```sql -cityHash64(par1,...) +SHA512(s) ``` -这是一个快速的非加密哈希函数。它使用 CityHash 算法处理字符串参数,并为其他数据类型的参数使用实现特定的快速非加密哈希函数。该函数使用 CityHash 组合器来获得最终结果。 - -请注意,Google 在将 CityHash 添加到 ClickHouse 之后更改了 CityHash 的算法。换句话说,ClickHouse 的 cityHash64 和 Google 的上游 CityHash 现在生成不同的结果。ClickHouse 的 cityHash64 对应于 CityHash v1.0.2。 +**参数** -**Arguments** +- `s` — 要 hash 的输入字符串 [`String`](/sql-reference/data-types/string) -该函数接受可变数量的输入参数。参数可以是任何 [支持的数据类型](../data-types/index.md)。对于某些数据类型,即使参数的类型不同(不同大小的整数,带有相同数据的命名和未命名的 `Tuple`,`Map` 以及相应的具有相同数据的 `Array(Tuple(key, value))` 类型),其哈希函数的计算值可能是相同的。 -**Returned Value** +**返回值** -一个 [UInt64](../data-types/int-uint.md) 数据类型的哈希值。 +返回给定输入字符串的 SHA512 hash,作为固定长度字符串。 [`FixedString(64)`](/sql-reference/data-types/fixedstring) -**Examples** +**示例** -调用示例: +**使用示例** -```sql -SELECT cityHash64(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS CityHash, toTypeName(CityHash) AS type; +```sql title=Query +SELECT HEX(SHA512('abc')); ``` -```response -┌─────────────CityHash─┬─type───┐ -│ 12072650598913549138 │ UInt64 │ -└──────────────────────┴────────┘ +```response title=Response +┌─hex(SHA512('abc'))───────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ +│ DDAF35A193617ABACC417349AE20413112E6FA4E89A97EA20A9EEEE64B55D39A2192992A274FC1A836BA3C23A3FEEBBD454D4423643CE80E2A9AC94FA54CA49F │ +└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ ``` +## SHA512_256 {#SHA512_256} -以下示例展示了如何以行序列顺序计算整个表的校验和: +Introduced in: v1.1 -```sql -SELECT groupBitXor(cityHash64(*)) FROM table -``` -## intHash32 {#inthash32} -从任何类型的整数计算一个 32 位哈希码。 -这是一个相对快速的非加密哈希函数,适用于数字的平均质量。 +计算给定字符串的 SHA512_256 hash。 + -**Syntax** +**语法** ```sql -intHash32(int) +SHA512_256(s) ``` -**Arguments** - -- `int` — 要哈希的整数。 [(U)Int*](../data-types/int-uint.md)。 +**参数** -**Returned value** +- `s` — 要 hash 的输入字符串。 [`String`](/sql-reference/data-types/string) -- 32 位哈希码。 [UInt32](../data-types/int-uint.md)。 -**Example** +**返回值** -查询: +返回给定输入字符串的 SHA512_256 hash,作为固定长度字符串。 [`FixedString(32)`](/sql-reference/data-types/fixedstring) -```sql -SELECT intHash32(42); -``` +**示例** -结果: +**使用示例** -```response -┌─intHash32(42)─┐ -│ 1228623923 │ -└───────────────┘ +```sql title=Query +SELECT HEX(SHA512_256('abc')); ``` -## intHash64 {#inthash64} - -从任何类型的整数计算一个 64 位哈希码。 -这是一个相对快速的非加密哈希函数,适用于数字的平均质量。 -它的速度比 [intHash32](#inthash32) 快。 -**Syntax** - -```sql -intHash64(int) +```response title=Response +┌─hex(SHA512_256('abc'))───────────────────────────────────────────┐ +│ 53048E2681941EF99B2E29B76B4C7DABE4C2D0C634FC6D46E0E2F13107E7AF23 │ +└──────────────────────────────────────────────────────────────────┘ ``` +## URLHash {#URLHash} -**Arguments** - -- `int` — 要哈希的整数。 [(U)Int*](../data-types/int-uint.md)。 - -**Returned value** +Introduced in: v1.1 -- 64 位哈希码。 [UInt64](../data-types/int-uint.md)。 -**Example** - -查询: - -```sql -SELECT intHash64(42); -``` +一种快速、优质的非加密 hash 函数,用于从 URL 获取的字符串,并进行某种类型的规范化。 -结果: +该 hash 函数有两种模式: -```response -┌────────intHash64(42)─┐ -│ 11490350930367293593 │ -└──────────────────────┘ -``` -## SHA1, SHA224, SHA256, SHA512, SHA512_256 {#sha1-sha224-sha256-sha512-sha512_256} +| 模式 | 描述 | +|------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +|`URLHash(url)` | 计算一个字符串的 hash,在字符串末尾去掉一个尾随符号 `/`、`?` 或 `#` (如有)。 | +|`URLHash(url, N)` | 计算字符串以 N 级别的 URL 层次结构的 hash,末尾去掉一个尾随符号 `/`、`?` 或 `#` (如有)。层级与 `URLHierarchy` 相同。| -计算字符串的 SHA-1, SHA-224, SHA-256, SHA-512, SHA-512-256 哈希,并将结果字节集作为 [FixedString](../data-types/fixedstring.md) 返回。 -**Syntax** +**语法** ```sql -SHA1('s') -... -SHA512('s') +URLHash(url[, N]) ``` -该函数操作相对较慢(SHA-1 每个处理器核心每秒处理约 500 万个短字符串,而 SHA-224 和 SHA-256 每秒约处理 220 万个)。 -我们建议仅在需要特定哈希函数并且无法选择其他时使用此函数。 -即使在这些情况下,我们也建议在将值插入表时离线应用该函数并预计算值,而不是在 `SELECT` 查询中应用。 - -**Arguments** +**参数** -- `s` — 用于 SHA 哈希计算的输入字符串。 [字符串](../data-types/string.md)。 +- `url` — 要 hash 的 URL 字符串。 [`String`](/sql-reference/data-types/string) +- `N` — 可选。 URL 层次结构中的级别。 [`(U)Int*`](/sql-reference/data-types/int-uint) -**Returned value** -- SHA 哈希以未编码的十六进制 FixedString 形式返回。SHA-1 返回为 FixedString(20),SHA-224 返回为 FixedString(28),SHA-256 返回为 FixedString(32),SHA-512 返回为 FixedString(64)。 [FixedString](../data-types/fixedstring.md)。 +**返回值** -**Example** +返回计算得到的 `url` 的 hash 值。 [`UInt64`](/sql-reference/data-types/int-uint) -使用 [hex](../functions/encoding-functions.md/#hex) 函数将结果表示为十六进制编码字符串。 +**示例** -查询: +**使用示例** -```sql -SELECT hex(SHA1('abc')); +```sql title=Query +SELECT URLHash('https://www.clickhouse.com') ``` -结果: - -```response -┌─hex(SHA1('abc'))─────────────────────────┐ -│ A9993E364706816ABA3E25717850C26C9CD0D89D │ -└──────────────────────────────────────────┘ +```response title=Response +┌─URLHash('htt⋯house.com')─┐ +│ 13614512636072854701 │ +└──────────────────────────┘ ``` -## BLAKE3 {#blake3} -计算 BLAKE3 哈希字符串,并将结果字节集作为 [FixedString](../data-types/fixedstring.md) 返回。 +**带有指定级别的 URL hash** -**Syntax** +```sql title=Query +SELECT URLHash('https://www.clickhouse.com/docs', 0); +SELECT URLHash('https://www.clickhouse.com/docs', 1); +``` -```sql -BLAKE3('s') +```response title=Response +-- hash of https://www.clickhouse.com +┌─URLHash('htt⋯m/docs', 0)─┐ +│ 13614512636072854701 │ +└──────────────────────────┘ +-- hash of https://www.clickhouse.com/docs +┌─URLHash('htt⋯m/docs', 1)─┐ +│ 13167253331440520598 │ +└──────────────────────────┘ ``` +## cityHash64 {#cityHash64} -该加密哈希函数集成在 ClickHouse 中,使用 BLAKE3 Rust 库。该函数相当快速,性能大约比 SHA-2 快两倍,同时生成与 SHA-256 相同长度的哈希。 +Introduced in: v1.1 -**Arguments** -- s - BLAKE3 哈希计算的输入字符串。 [字符串](../data-types/string.md)。 +生成 64 位 [CityHash](https://github.com/google/cityhash) hash 值。 -**Return value** +这是一个快速的非加密 hash 函数。 +对于字符串参数使用 CityHash 算法,而对于其他数据类型的参数使用实现特定的快速非加密 hash 函数。 +该函数使用 CityHash 组合器来获得最终结果。 -- BLAKE3 哈希,类型为 FixedString(32) 的字节数组。 [FixedString](../data-types/fixedstring.md)。 +:::info +Google 在将 CityHash 集成到 ClickHouse 后更改了算法。 +换句话说,ClickHouse 的 cityHash64 和 Google 的上游 CityHash 现在生成不同的结果。 +ClickHouse 的 cityHash64 对应于 CityHash v1.0.2。 +::: -**Example** +:::note +相同输入值的不同参数类型可能计算出相同的 hash 值。 +这影响例如不同大小的整数类型、具有相同数据的命名和未命名 `Tuple`、`Map` 和相应的 `Array(Tuple(key, value))` 类型的相同数据。 +::: -使用函数 [hex](../functions/encoding-functions.md/#hex) 将结果表示为十六进制编码字符串。 -查询: -```sql -SELECT hex(BLAKE3('ABC')) -``` +**语法** -结果: ```sql -┌─hex(BLAKE3('ABC'))───────────────────────────────────────────────┐ -│ D1717274597CF0289694F75D96D444B992A096F1AFD8E7BBFA6EBB1D360FEDFC │ -└──────────────────────────────────────────────────────────────────┘ +cityHash64(arg1[, arg2, ...]) ``` -## URLHash(url\[, N\]) {#urlhashurl-n} - -一种快速、质量良好的非加密哈希函数,用于通过某种类型的规范化从 URL 中获得字符串。 -`URLHash(s)` – 从字符串计算哈希,末尾去掉一个斜杠 `/`、`?` 或 `#`,如果存在的话。 -`URLHash(s, N)` – 从字符串计算哈希,直到 URL 层次结构中的 N 级别,末尾去掉一个斜杠 `/`、`?` 或 `#`,如果存在的话。 -层次结构与 URLHierarchy 中的相同。 -## farmFingerprint64 {#farmfingerprint64} -## farmHash64 {#farmhash64} - -生成 64 位 [FarmHash](https://github.com/google/farmhash) 或指纹值。`farmFingerprint64` 更适合于稳定且可移植的值。 -```sql -farmFingerprint64(par1, ...) -farmHash64(par1, ...) -``` +**参数** -这些函数分别使用从所有 [可用方法](https://github.com/google/farmhash/blob/master/src/farmhash.h) 中的 `Fingerprint64` 和 `Hash64` 方法。 +- `arg1[, arg2, ...]` — 可变数量的输入参数,以计算 hash。 [`Any`](/sql-reference/data-types) -**Arguments** -该函数接受可变数量的输入参数。参数可以是任何 [支持的数据类型](../data-types/index.md)。对于某些数据类型,即使参数的类型不同(不同大小的整数,带有相同数据的命名和未命名的 `Tuple`,`Map` 以及相应的具有相同数据的 `Array(Tuple(key, value))` 类型),其哈希函数的计算值可能是相同的。 +**返回值** -**Returned Value** +返回输入参数计算出的 hash。 [`UInt64`](/sql-reference/data-types/int-uint) -一个 [UInt64](../data-types/int-uint.md) 数据类型的哈希值。 +**示例** -**Example** +**调用示例** -```sql -SELECT farmHash64(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS FarmHash, toTypeName(FarmHash) AS type; +```sql title=Query +SELECT cityHash64(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS CityHash, toTypeName(CityHash) AS type; ``` -```response -┌─────────────FarmHash─┬─type───┐ -│ 17790458267262532859 │ UInt64 │ +```response title=Response +┌─────────────CityHash─┬─type───┐ +│ 12072650598913549138 │ UInt64 │ └──────────────────────┴────────┘ ``` -## javaHash {#javahash} -从 [字符串](http://hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/478a4add975b/src/share/classes/java/lang/String.java#l1452), -[字节](https://hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/478a4add975b/src/share/classes/java/lang/Byte.java#l405), -[短整型](https://hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/478a4add975b/src/share/classes/java/lang/Short.java#l410), -[整型](https://hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/478a4add975b/src/share/classes/java/lang/Integer.java#l959), -[长整型](https://hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/478a4add975b/src/share/classes/java/lang/Long.java#l1060) 计算 JavaHash。 -这个哈希函数既不快速也没有很好的质量。使用它的唯一原因是在另一个系统中已经使用了该算法,并且您必须计算完全相同的结果。 +**计算整个表的校验和,精确到行的顺序** -请注意,Java 仅支持计算带符号整数哈希,因此如果要计算无符号整数哈希,必须将其转换为适当的带符号 ClickHouse 类型。 +```sql title=Query +CREATE TABLE users ( + id UInt32, + name String, + age UInt8, + city String +) +ENGINE = MergeTree +ORDER BY tuple(); -**Syntax** +INSERT INTO users VALUES +(1, 'Alice', 25, 'New York'), +(2, 'Bob', 30, 'London'), +(3, 'Charlie', 35, 'Tokyo'); -```sql -SELECT javaHash('') +SELECT groupBitXor(cityHash64(*)) FROM users; ``` -**Returned value** +```response title=Response +┌─groupBitXor(⋯age, city))─┐ +│ 11639977218258521182 │ +└──────────────────────────┘ +``` +## farmFingerprint64 {#farmFingerprint64} -一个 `Int32` 数据类型的哈希值。 +Introduced in: v20.12 -**Example** -查询: +使用 `Fingerprint64` 方法生成 64 位 [FarmHash](https://github.com/google/farmhash) 值。 -```sql -SELECT javaHash(toInt32(123)); -``` +:::tip +`farmFingerprint64` 在生成稳定和可移植值时优于 [`farmHash64`](#farmHash64)。 +::: -结果: +:::note +相同输入值的不同参数类型可能计算出相同的 hash 值。 +这影响例如不同大小的整数类型、具有相同数据的命名和未命名 `Tuple`、`Map` 和相应的 `Array(Tuple(key, value))` 类型的相同数据。 +::: -```response -┌─javaHash(toInt32(123))─┐ -│ 123 │ -└────────────────────────┘ -``` -查询: +**语法** ```sql -SELECT javaHash('Hello, world!'); +farmFingerprint64(arg1[, arg2, ...]) ``` -结果: +**参数** -```response -┌─javaHash('Hello, world!')─┐ -│ -1880044555 │ -└───────────────────────────┘ -``` -## javaHashUTF16LE {#javahashutf16le} +- `arg1[, arg2, ...]` — 可变数量的输入参数,以计算 hash。 [`Any`](/sql-reference/data-types) -从字符串计算 [JavaHash](http://hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/478a4add975b/src/share/classes/java/lang/String.java#l1452),假设它包含 UTF-16LE 编码的字节。 -**Syntax** +**返回值** -```sql -javaHashUTF16LE(stringUtf16le) -``` +返回输入参数计算出的 hash 值。 [`UInt64`](/sql-reference/data-types/int-uint) -**Arguments** +**示例** -- `stringUtf16le` — UTF-16LE 编码的字符串。 +**使用示例** -**Returned value** +```sql title=Query +SELECT farmFingerprint64(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS FarmFingerprint, toTypeName(FarmFingerprint) AS type; +``` -一个 `Int32` 数据类型的哈希值。 +```response title=Response +┌─────FarmFingerprint─┬─type───┐ +│ 5752020380710916328 │ UInt64 │ +└─────────────────────┴────────┘ +``` +## farmHash64 {#farmHash64} -**Example** +Introduced in: v1.1 -正确的查询,包含 UTF-16LE 编码的字符串。 -查询: +使用 `Hash64` 方法生成 64 位 [FarmHash](https://github.com/google/farmhash)。 -```sql -SELECT javaHashUTF16LE(convertCharset('test', 'utf-8', 'utf-16le')); -``` +:::tip +[`farmFingerprint64`](#farmFingerprint64) 在生成稳定和可移植值时优于。 +::: -结果: +:::note +相同输入值的不同参数类型可能计算出相同的 hash 值。 +这影响例如不同大小的整数类型、具有相同数据的命名和未命名 `Tuple`、`Map` 和相应的 `Array(Tuple(key, value))` 类型的相同数据。 +::: -```response -┌─javaHashUTF16LE(convertCharset('test', 'utf-8', 'utf-16le'))─┐ -│ 3556498 │ -└──────────────────────────────────────────────────────────────┘ -``` -## hiveHash {#hivehash} -计算字符串的 `HiveHash`。 +**语法** ```sql -SELECT hiveHash('') +farmHash64(arg1[, arg2, ...]) ``` -这只是 [JavaHash](#javahash),其符号位为零。该函数用于 [Apache Hive](https://en.wikipedia.org/wiki/Apache_Hive) 版本 3.0 之前。这个哈希函数既不快速也没有很好的质量。使用它的唯一原因是在另一个系统中已经使用了该算法,并且您必须计算完全相同的结果。 +**参数** -**Returned value** +- `arg1[, arg2, ...]` — 可变数量的输入参数,以计算 hash。 [`Any`](/sql-reference/data-types) -- `hiveHash` 哈希值。 [Int32](../data-types/int-uint.md)。 -**Example** +**返回值** -查询: +返回输入参数计算出的 hash 值。 [`UInt64`](/sql-reference/data-types/int-uint) -```sql -SELECT hiveHash('Hello, world!'); -``` +**示例** -结果: +**使用示例** -```response -┌─hiveHash('Hello, world!')─┐ -│ 267439093 │ -└───────────────────────────┘ +```sql title=Query +SELECT farmHash64(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS FarmHash, toTypeName(FarmHash) AS type; ``` -## metroHash64 {#metrohash64} - -生成 64 位 [MetroHash](http://www.jandrewrogers.com/2015/05/27/metrohash/) 哈希值。 -```sql -metroHash64(par1, ...) +```response title=Response +┌─────────────FarmHash─┬─type───┐ +│ 18125596431186471178 │ UInt64 │ +└──────────────────────┴────────┘ ``` +## gccMurmurHash {#gccMurmurHash} + +Introduced in: v20.1 -**Arguments** -该函数接受可变数量的输入参数。参数可以是任何 [支持的数据类型](../data-types/index.md)。对于某些数据类型,即使参数的类型不同(不同大小的整数,带有相同数据的命名和未命名的 `Tuple`,`Map` 以及相应的具有相同数据的 `Array(Tuple(key, value))` 类型),其哈希函数的计算值可能是相同的。 +使用与 [GCC](https://github.com/gcc-mirror/gcc/blob/41d6b10e96a1de98e90a7c0378437c3255814b16/libstdc%2B%2B-v3/include/bits/functional_hash.h#L191) 相同的种子,计算输入值的 64 位 [MurmurHash2](https://github.com/aappleby/smhasher) hash。 -**Returned Value** +它在 Clang 和 GCC 构建之间是可移植的。 -一个 [UInt64](../data-types/int-uint.md) 数据类型的哈希值。 -**Example** +**语法** ```sql -SELECT metroHash64(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS MetroHash, toTypeName(MetroHash) AS type; +gccMurmurHash(arg1[, arg2, ...]) ``` -```response -┌────────────MetroHash─┬─type───┐ -│ 14235658766382344533 │ UInt64 │ -└──────────────────────┴────────┘ -``` -## jumpConsistentHash {#jumpconsistenthash} +**参数** -从一个 UInt64 计算 JumpConsistentHash。 -接受两个参数:一个 UInt64 类型的键和桶的数量。返回 Int32。 -有关更多信息,请参见链接:[JumpConsistentHash](https://arxiv.org/pdf/1406.2294.pdf) -## kostikConsistentHash {#kostikconsistenthash} +- `arg1[, arg2, ...]` — 可变数量的输入参数,以计算 hash。 [`Any`](/sql-reference/data-types) -由 Konstantin 'kostik' Oblakov 提供的 O(1) 时间和空间一致哈希算法。以前称为 `yandexConsistentHash`。 -**Syntax** +**返回值** + +返回输入参数计算出的 hash 值。 [`UInt64`](/sql-reference/data-types/int-uint) + +**示例** + +**使用示例** + +```sql title=Query +SELECT + gccMurmurHash(1, 2, 3) AS res1, + gccMurmurHash(('a', [1, 2, 3], 4, (4, ['foo', 'bar'], 1, (1, 2)))) AS res2 +``` + +```response title=Response +┌─────────────────res1─┬────────────────res2─┐ +│ 12384823029245979431 │ 1188926775431157506 │ +└──────────────────────┴─────────────────────┘ +``` +## halfMD5 {#halfMD5} + +Introduced in: v1.1 + + +[解释](/sql-reference/functions/type-conversion-functions#reinterpretasstring) 所有输入参数为字符串,并计算每个参数的 MD5 hash 值。然后组合哈希值,取结果字符串的前 8 个字节,并将其解释为 [UInt64](/sql-reference/data-types/int-uint) 的大端字节顺序。该函数相对较慢(每秒每个处理器核心处理 5 百万条短字符串)。 + +请考虑改用 [`sipHash64`](#sipHash64) 函数。 + +该函数接受可变数量的输入参数。 +参数可以是任何支持的数据类型。 +对于某些数据类型,即使参数的类型不同,计算出的 hash 函数值可能对相同的值相同(不同大小的整数、具有相同数据的命名和未命名 Tuple、Map 和相应的 Array(Tuple(key, value)) 类型的相同数据)。 + + +**语法** + +```sql +halfMD5(arg1[, arg2, ..., argN]) +``` + +**参数** + +- `arg1[, arg2, ..., argN]` — 可变数量的输入参数,以计算 hash。 [`Any`](/sql-reference/data-types) + + +**返回值** + +返回计算得出的给定输入参数的半 MD5 hash,作为大端字节顺序的 `UInt64`。 [`UInt64`](/sql-reference/data-types/int-uint) + +**示例** + +**使用示例** + +```sql title=Query +SELECT HEX(halfMD5('abc', 'cde', 'fgh')); +``` + +```response title=Response +┌─hex(halfMD5('abc', 'cde', 'fgh'))─┐ +│ 2C9506B7374CFAF4 │ +└───────────────────────────────────┘ +``` +## hiveHash {#hiveHash} + +Introduced in: v20.1 + + +从字符串计算 “HiveHash”。 +这只是 [`JavaHash`](#javaHash) 的符号位清零版本。 +该函数用于 [Apache Hive](https://en.wikipedia.org/wiki/Apache_Hive) 3.0 之前的版本。 + +::caution +该 hash 函数性能较差。 +仅在另一个系统中已经使用此算法且需要计算相同结果时使用。 +::: + + +**语法** + +```sql +hiveHash(arg) +``` + +**参数** + +- `arg` — 输入字符串以进行 hash。 [`String`](/sql-reference/data-types/string) + + +**返回值** + +返回输入字符串的计算 “hive hash”。 [`Int32`](/sql-reference/data-types/int-uint) + +**示例** + +**使用示例** + +```sql title=Query +SELECT hiveHash('Hello, world!'); +``` + +```response title=Response +┌─hiveHash('Hello, world!')─┐ +│ 267439093 │ +└───────────────────────────┘ +``` +## intHash32 {#intHash32} + +Introduced in: v1.1 + + +计算整数的 32 位 hash。 + +该 hash 函数相对较快,但不是加密 hash 函数。 + + +**语法** + +```sql +intHash32(arg) +``` + +**参数** + +- `arg` — 要 hash 的整数。 [`(U)Int*`](/sql-reference/data-types/int-uint) + + +**返回值** + +返回输入整数的计算 32 位 hash 代码。 [`UInt32`](/sql-reference/data-types/int-uint) + +**示例** + +**使用示例** + +```sql title=Query +SELECT intHash32(42); +``` + +```response title=Response +┌─intHash32(42)─┐ +│ 1228623923 │ +└───────────────┘ +``` +## intHash64 {#intHash64} + +Introduced in: v1.1 + + +计算整数的 64 位 hash。 + +该 hash 函数相对较快(甚至比 [`intHash32`](#intHash32) 还快)但不是加密 hash 函数。 + + +**语法** + +```sql +intHash64(int) +``` + +**参数** + +- `int` — 要 hash 的整数。 [`(U)Int*`](/sql-reference/data-types/int-uint) + + +**返回值** + +返回 64 位 hash 代码。 [`UInt64`](/sql-reference/data-types/int-uint) + +**示例** + +**使用示例** + +```sql title=Query +SELECT intHash64(42); +``` + +```response title=Response +┌────────intHash64(42)─┐ +│ 11490350930367293593 │ +└──────────────────────┘ +``` +## javaHash {#javaHash} + +Introduced in: v20.1 + + +从以下内容计算 JavaHash: +- [string](http://hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/478a4add975b/src/share/classes/java/lang/String.java#l1452), +- [Byte](https://hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/478a4add975b/src/share/classes/java/lang/Byte.java#l405), +- [Short](https://hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/478a4add975b/src/share/classes/java/lang/Short.java#l410), +- [Integer](https://hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/478a4add975b/src/share/classes/java/lang/Integer.java#l959), +- [Long](https://hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/478a4add975b/src/share/classes/java/lang/Long.java#l1060)。 + +:::caution +该 hash 函数性能较差。 +仅在另一个系统中已经使用此算法且需要计算相同结果时使用。 +::: + +:::note +Java 仅支持计算有符号整数的 hash,因此如果要计算无符号整数的 hash,则必须将其转换为适当的有符号 ClickHouse 类型。 +::: + + +**语法** + +```sql +javaHash(arg) +``` + +**参数** + +- `arg` — 要 hash 的输入值。 [`Any`](/sql-reference/data-types) + + +**返回值** + +返回输入 `arg` 的计算 hash。 [`Int32`](/sql-reference/data-types/int-uint) + +**示例** + +**使用示例 1** + +```sql title=Query +SELECT javaHash(toInt32(123)); +``` + +```response title=Response +┌─javaHash(toInt32(123))─┐ +│ 123 │ +└────────────────────────┘ +``` + +**使用示例 2** + +```sql title=Query +SELECT javaHash('Hello, world!'); +``` + +```response title=Response +┌─javaHash('Hello, world!')─┐ +│ -1880044555 │ +└───────────────────────────┘ +``` +## javaHashUTF16LE {#javaHashUTF16LE} + +Introduced in: v20.1 + + +计算来自字符串的 [JavaHash](http://hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/478a4add975b/src/share/classes/java/lang/String.java#l1452),假定它包含表示字符串的 UTF-16LE 编码字节。 + + +**语法** + +```sql +javaHashUTF16LE(arg) +``` + +**参数** + +- `arg` — UTF-16LE 编码的字符串。 [`String`](/sql-reference/data-types/string) + + +**返回值** + +返回 UTF-16LE 编码字符串的计算 hash。 [`Int32`](/sql-reference/data-types/int-uint) + +**示例** + +**使用示例** + +```sql title=Query +SELECT javaHashUTF16LE(convertCharset('test', 'utf-8', 'utf-16le')); +``` + +```response title=Response +┌─javaHashUTF16LE(convertCharset('test', 'utf-8', 'utf-16le'))─┐ +│ 3556498 │ +└──────────────────────────────────────────────────────────────┘ +``` +## jumpConsistentHash {#jumpConsistentHash} + +Introduced in: v1.1 + + +计算整数的 [jump consistent hash](https://arxiv.org/pdf/1406.2294.pdf)。 + + +**语法** + +```sql +jumpConsistentHash(key, buckets) +``` + +**参数** + +- `key` — 输入键。 [`UInt64`](/sql-reference/data-types/int-uint) +- `buckets` — 桶的数量。 [`Int32`](/sql-reference/data-types/int-uint) + + +**返回值** + +返回计算得到的 hash 值。 [`Int32`](/sql-reference/data-types/int-uint) + +**示例** + +**使用示例** + +```sql title=Query +SELECT jumpConsistentHash(256, 4) +``` + +```response title=Response +┌─jumpConsistentHash(256, 4)─┐ +│ 3 │ +└────────────────────────────┘ +``` +## kafkaMurmurHash {#kafkaMurmurHash} + +Introduced in: v23.4 + + +使用与 [Kafka](https://github.com/apache/kafka/blob/461c5cfe056db0951d9b74f5adc45973670404d7/clients/src/main/java/org/apache/kafka/common/utils/Utils.java#L482) 相同的种子,计算输入值的 32 位 [MurmurHash2](https://github.com/aappleby/smhasher) hash,并去掉高位,以兼容 [Default Partitioner](https://github.com/apache/kafka/blob/139f7709bd3f5926901a21e55043388728ccca78/clients/src/main/java/org/apache/kafka/clients/producer/internals/BuiltInPartitioner.java#L328)。 + + +**语法** + +```sql +kafkaMurmurHash(arg1[, arg2, ...]) +``` + +**参数** + +- `arg1[, arg2, ...]` — 可变数量的参数,以计算 hash。 [`Any`](/sql-reference/data-types) + + +**返回值** + +返回输入参数计算出的 hash 值。 [`UInt32`](/sql-reference/data-types/int-uint) + +**示例** + +**使用示例** + +```sql title=Query +SELECT + kafkaMurmurHash('foobar') AS res1, + kafkaMurmurHash(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS res2 +``` + +```response title=Response +┌───────res1─┬─────res2─┐ +│ 1357151166 │ 85479775 │ +└────────────┴──────────┘ +``` +## keccak256 {#keccak256} + +Introduced in: v25.4 + + +计算给定字符串的 Keccak-256 加密 hash。 +该 hash 函数广泛用于区块链应用,特别是以太坊。 + + +**语法** + +```sql +keccak256(message) +``` + +**参数** + +- `message` — 要 hash 的输入字符串。 [`String`](/sql-reference/data-types/string) + + +**返回值** + +返回输入字符串的 32 字节 Keccak-256 hash,作为固定长度字符串。 [`FixedString(32)`](/sql-reference/data-types/fixedstring) + +**示例** + +**使用示例** + +```sql title=Query +SELECT hex(keccak256('hello')) +``` + +```response title=Response +┌─hex(keccak256('hello'))──────────────────────────────────────────┐ +│ 1C8AFF950685C2ED4BC3174F3472287B56D9517B9C948127319A09A7A36DEAC8 │ +└──────────────────────────────────────────────────────────────────┘ +``` +## kostikConsistentHash {#kostikConsistentHash} + +Introduced in: v22.6 + + +Konstantin 'Kostik' Oblakov 提出的 O(1) 时间和空间一致性 hash 算法。 +当 `n <= 32768` 时效率高。 + + +**语法** + +```sql +kostikConsistentHash(input, n) +``` + +**参数** + +- `input` — 整数键。 [`UInt64`](/sql-reference/data-types/int-uint) +- `n` — 桶的数量。 [`UInt16`](/sql-reference/data-types/int-uint) + + +**返回值** + +返回计算得到的 hash 值。 [`UInt16`](/sql-reference/data-types/int-uint) + +**示例** + +**使用示例** + +```sql title=Query +SELECT kostikConsistentHash(16045690984833335023, 2); +``` + +```response title=Response +┌─kostikConsistentHash(16045690984833335023, 2)─┐ +│ 1 │ +└───────────────────────────────────────────────┘ +``` +## metroHash64 {#metroHash64} + +Introduced in: v1.1 + + +生成 64 位 [MetroHash](http://www.jandrewrogers.com/2015/05/27/metrohash/) hash 值。 + +:::note +相同输入值的不同参数类型可能计算出相同的 hash 值。 +这影响例如不同大小的整数类型、具有相同数据的命名和未命名 `Tuple`、`Map` 和相应的 `Array(Tuple(key, value))` 类型的相同数据。 +::: + + +**语法** ```sql -kostikConsistentHash(input, n) +metroHash64(arg1[, arg2, ...]) ``` -别名:`yandexConsistentHash` (保留用于向后兼容)。 +**参数** + +- `arg1[, arg2, ...]` — 可变数量的输入参数,以计算 hash。 [`Any`](/sql-reference/data-types) + + +**返回值** + +返回输入参数计算出的 hash。 [`UInt64`](/sql-reference/data-types/int-uint) + +**示例** + +**使用示例** -**Parameters** +```sql title=Query +SELECT metroHash64(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS MetroHash, toTypeName(MetroHash) AS type; +``` -- `input`: 一个 UInt64 类型的键 [UInt64](../data-types/int-uint.md)。 -- `n`: 桶的数量。 [UInt16](../data-types/int-uint.md)。 +```response title=Response +┌────────────MetroHash─┬─type───┐ +│ 14235658766382344533 │ UInt64 │ +└──────────────────────┴────────┘ +``` +## murmurHash2_32 {#murmurHash2_32} -**Returned value** +Introduced in: v18.5 -- 一个 [UInt16](../data-types/int-uint.md) 数据类型的哈希值。 -**Implementation details** +计算输入值的 [MurmurHash2](https://github.com/aappleby/smhasher) hash。 -当 n <= 32768 时,它效率较高。 +:::note +相同输入值的不同参数类型可能计算出相同的 hash 值。 +这影响例如不同大小的整数类型、具有相同数据的命名和未命名 `Tuple`、`Map` 和相应的 `Array(Tuple(key, value))` 类型的相同数据。 +::: -**Example** -查询: +**语法** ```sql -SELECT kostikConsistentHash(16045690984833335023, 2); +murmurHash2_32(arg1[, arg2, ...]) ``` -```response -┌─kostikConsistentHash(16045690984833335023, 2)─┐ -│ 1 │ -└───────────────────────────────────────────────┘ +**参数** + +- `arg1[, arg2, ...]` — 可变数量的输入参数,以计算 hash。 [`Any`](/sql-reference/data-types) + + +**返回值** + +返回输入参数计算出的 hash 值。 [`UInt32`](/sql-reference/data-types/int-uint) + +**示例** + +**使用示例** + +```sql title=Query +SELECT murmurHash2_32(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS MurmurHash2, toTypeName(MurmurHash2) AS type; +``` + +```response title=Response +┌─MurmurHash2─┬─type───┐ +│ 3681770635 │ UInt32 │ +└─────────────┴────────┘ +``` +## murmurHash2_64 {#murmurHash2_64} + +Introduced in: v18.10 + + +计算输入值的 [MurmurHash2](https://github.com/aappleby/smhasher) hash。 + +:::note +相同输入值的不同参数类型可能计算出相同的 hash 值。 +这影响例如不同大小的整数类型、具有相同数据的命名和未命名 `Tuple`、`Map` 和相应的 `Array(Tuple(key, value))` 类型的相同数据。 +::: + + +**语法** + +```sql +murmurHash2_64(arg1[, arg2, ...]) +``` + +**参数** + +- `arg1[, arg2, ...]` — 可变数量的输入参数,以计算 hash。 [`Any`](/sql-reference/data-types) + + +**返回值** + +返回输入参数计算出的 hash。 [`UInt64`](/sql-reference/data-types/int-uint) + +**示例** + +**使用示例** + +```sql title=Query +SELECT murmurHash2_64(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS MurmurHash2, toTypeName(MurmurHash2) AS type; +``` + +```response title=Response +┌──────────MurmurHash2─┬─type───┐ +│ 11832096901709403633 │ UInt64 │ +└──────────────────────┴────────┘ +``` +## murmurHash3_128 {#murmurHash3_128} + +Introduced in: v18.10 + + +计算输入值的 128 位 [MurmurHash3](https://github.com/aappleby/smhasher) hash。 + + +**语法** + +```sql +murmurHash3_128(arg1[, arg2, ...]) +``` + +**参数** + +- `arg1[, arg2, ...]` — 可变数量的输入参数,以计算 hash。 [`Any`](/sql-reference/data-types) + + +**返回值** + +返回输入参数计算出的 128 位 `MurmurHash3` hash 值。 [`FixedString(16)`](/sql-reference/data-types/fixedstring) + +**示例** + +**使用示例** + +```sql title=Query +SELECT hex(murmurHash3_128('foo', 'foo', 'foo')); +``` + +```response title=Response +┌─hex(murmurHash3_128('foo', 'foo', 'foo'))─┐ +│ F8F7AD9B6CD4CF117A71E277E2EC2931 │ +└───────────────────────────────────────────┘ +``` +## murmurHash3_32 {#murmurHash3_32} + +Introduced in: v18.10 + + +生成 [MurmurHash3](https://github.com/aappleby/smhasher) hash 值。 + +:::note +相同输入值的不同参数类型可能计算出相同的 hash 值。 +这影响例如不同大小的整数类型、具有相同数据的命名和未命名 `Tuple`、`Map` 和相应的 `Array(Tuple(key, value))` 类型的相同数据。 +::: + + +**语法** + +```sql +murmurHash3_32(arg1[, arg2, ...]) +``` + +**参数** + +- `arg1[, arg2, ...]` — 可变数量的输入参数,以计算 hash。 [`Any`](/sql-reference/data-types) + + +**返回值** + +返回输入参数计算出的 hash 值。 [`UInt32`](/sql-reference/data-types/int-uint) + +**示例** + +**使用示例** + +```sql title=Query +SELECT murmurHash3_32(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS MurmurHash3, toTypeName(MurmurHash3) AS type; +``` + +```response title=Response +┌─MurmurHash3─┬─type───┐ +│ 2152717 │ UInt32 │ +└─────────────┴────────┘ +``` +## murmurHash3_64 {#murmurHash3_64} + +Introduced in: v18.10 + + +计算输入值的 [MurmurHash3](https://github.com/aappleby/smhasher) hash。 + +:::note +相同输入值的不同参数类型可能计算出相同的 hash 值。 +这影响例如不同大小的整数类型、具有相同数据的命名和未命名 `Tuple`、`Map` 和相应的 `Array(Tuple(key, value))` 类型的相同数据。 +::: + + +**语法** + +```sql +murmurHash3_64(arg1[, arg2, ...]) +``` + +**参数** + +- `arg1[, arg2, ...]` — 可变数量的输入参数,以计算 hash。 [`Any`](/sql-reference/data-types) + + +**返回值** + +返回输入参数计算出的 hash 值。 [`UInt64`](/sql-reference/data-types/int-uint) + +**示例** + +**使用示例** + +```sql title=Query +SELECT murmurHash3_64(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS MurmurHash3, toTypeName(MurmurHash3) AS type; +``` + +```response title=Response +┌──────────MurmurHash3─┬─type───┐ +│ 11832096901709403633 │ UInt64 │ +└──────────────────────┴────────┘ +``` +## ngramMinHash {#ngramMinHash} + +Introduced in: v21.1 + + +将 ASCII 字符串拆分为 `ngramsize` 符号的 n-grams,并计算每个 n-gram 的 hash 值,返回一个包含这些 hash 的元组。 +使用 `hashnum` 个最小 hash 来计算最小 hash,使用 `hashnum` 个最大 hash 来计算最大 hash。 +该函数对大小写敏感。 + +可用于使用 [`tupleHammingDistance`](../functions/tuple-functions.md/#tuplehammingdistance) 检测半重复字符串。 +对于两个字符串,如果返回的 hash 对于这两个字符串是相同的,则这两个字符串是相同的。 + + +**语法** + +```sql +ngramMinHash(string[, ngramsize, hashnum]) +``` + +**参数** + +- `string` — 要计算 hash 的字符串。 [`String`](/sql-reference/data-types/string) +- `ngramsize` — 可选。 n-gram 的大小,范围为 `1` 到 `25` 的任意数字。默认值为 `3`。 [`UInt8`](/sql-reference/data-types/int-uint) +- `hashnum` — 可选。 用于计算结果的最小和最大 hash 的数量,范围为 `1` 到 `25` 的任意数字。默认值为 `6`。 [`UInt8`](/sql-reference/data-types/int-uint) + + +**返回值** + +返回包含两个 hash 的元组 — 最小和最大。 [`Tuple`](/sql-reference/data-types/tuple) + +**示例** + +**使用示例** + +```sql title=Query +SELECT ngramMinHash('ClickHouse') AS Tuple; +``` + +```response title=Response +┌─Tuple──────────────────────────────────────┐ +│ (18333312859352735453,9054248444481805918) │ +└────────────────────────────────────────────┘ +``` +## ngramMinHashArg {#ngramMinHashArg} + +Introduced in: v21.1 + + +将 ASCII 字符串拆分为 `ngramsize` 符号的 n-grams,并返回 minimum hash 和 maximum hash,计算方法为与相同输入的 [`ngramMinHash`](#ngramMinHash) 函数。 +该函数对大小写敏感。 + + +**语法** + +```sql +ngramMinHashArg(string[, ngramsize, hashnum]) +``` + +**参数** + +- `string` — 要计算 hash 的字符串。 [`String`](/sql-reference/data-types/string) +- `ngramsize` — 可选。 n-gram 的大小,范围为 `1` 到 `25` 的任意数字。默认值为 `3`。 [`UInt8`](/sql-reference/data-types/int-uint) +- `hashnum` — 可选。 用于计算结果的最小和最大 hash 的数量,范围为 `1` 到 `25` 的任意数字。默认值为 `6`。 [`UInt8`](/sql-reference/data-types/int-uint) + + +**返回值** + +返回包含两个元组的元组,每个元组都有 `hashnum` 个 n-grams。 [`Tuple(String)`](/sql-reference/data-types/tuple) + +**示例** + +**使用示例** + +```sql title=Query +SELECT ngramMinHashArg('ClickHouse') AS Tuple; +``` + +```response title=Response +┌─Tuple─────────────────────────────────────────────────────────────────────────┐ +│ (('ous','ick','lic','Hou','kHo','use'),('Hou','lic','ick','ous','ckH','Cli')) │ +└───────────────────────────────────────────────────────────────────────────────┘ +``` +## ngramMinHashArgCaseInsensitive {#ngramMinHashArgCaseInsensitive} + +Introduced in: v21.1 + + +将 ASCII 字符串拆分为 `ngramsize` 符号的 n-grams,并返回 minimum hash 和 maximum hash,计算方法为与相同输入的 [`ngramMinHashCaseInsensitive`](#ngramMinHashCaseInsensitive) 函数。 +该函数对大小写不敏感。 + + +**语法** + +```sql +ngramMinHashArgCaseInsensitive(string[, ngramsize, hashnum]) ``` -## murmurHash2_32, murmurHash2_64 {#murmurhash2_32-murmurhash2_64} -生成 [MurmurHash2](https://github.com/aappleby/smhasher) 哈希值。 +**参数** + +- `string` — 要计算 hash 的字符串。 [`String`](/sql-reference/data-types/string) +- `ngramsize` — 可选。 n-gram 的大小,范围为 `1` 到 `25` 的任意数字。默认值为 `3`。 [`UInt8`](/sql-reference/data-types/int-uint) +- `hashnum` — 可选。 用于计算结果的最小和最大 hash 的数量,范围为 `1` 到 `25` 的任意数字。默认值为 `6`。 [`UInt8`](/sql-reference/data-types/int-uint) + + +**返回值** + +返回包含两个元组的元组,每个元组都有 `hashnum` 个 n-grams。 [`Tuple(Tuple(String))`](/sql-reference/data-types/tuple) + +**示例** + +**使用示例** + +```sql title=Query +SELECT ngramMinHashArgCaseInsensitive('ClickHouse') AS Tuple; +``` -```sql -murmurHash2_32(par1, ...) -murmurHash2_64(par1, ...) +```response title=Response +┌─Tuple─────────────────────────────────────────────────────────────────────────┐ +│ (('ous','ick','lic','kHo','use','Cli'),('kHo','lic','ick','ous','ckH','Hou')) │ +└───────────────────────────────────────────────────────────────────────────────┘ ``` +## ngramMinHashArgCaseInsensitiveUTF8 {#ngramMinHashArgCaseInsensitiveUTF8} -**Arguments** +Introduced in: v21.1 -这两个函数接受可变数量的输入参数。参数可以是任何 [支持的数据类型](../data-types/index.md)。对于某些数据类型,即使参数的类型不同(不同大小的整数,带有相同数据的命名和未命名的 `Tuple`,`Map` 以及相应的具有相同数据的 `Array(Tuple(key, value))` 类型),其哈希函数的计算值可能是相同的。 -**Returned Value** +将 UTF-8 字符串拆分为 `ngramsize` 符号的 n-grams,并返回 minimum hash 和 maximum hash,计算方法为与相同输入的 ngramMinHashCaseInsensitiveUTF8 函数。 +该函数对大小写不敏感。 -- `murmurHash2_32` 函数返回类型为 [UInt32](../data-types/int-uint.md) 的哈希值。 -- `murmurHash2_64` 函数返回类型为 [UInt64](../data-types/int-uint.md) 的哈希值。 -**Example** +**语法** ```sql -SELECT murmurHash2_64(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS MurmurHash2, toTypeName(MurmurHash2) AS type; +ngramMinHashArgCaseInsensitiveUTF8(string[, ngramsize, hashnum]) ``` -```response -┌──────────MurmurHash2─┬─type───┐ -│ 11832096901709403633 │ UInt64 │ -└──────────────────────┴────────┘ -``` -## gccMurmurHash {#gccmurmurhash} +**参数** -使用与 [gcc](https://github.com/gcc-mirror/gcc/blob/41d6b10e96a1de98e90a7c0378437c3255814b16/libstdc%2B%2B-v3/include/bits/functional_hash.h#L191) 相同的哈希种子计算 64 位 [MurmurHash2](https://github.com/aappleby/smhasher) 哈希值。它在 Clang 和 GCC 构建之间是可移植的。 +- `string` — 要计算 hash 的字符串。 [`String`](/sql-reference/data-types/string) +- `ngramsize` — 可选。 n-gram 的大小,范围为 `1` 到 `25` 的任意数字。默认值为 `3`。 [`UInt8`](/sql-reference/data-types/int-uint) +- `hashnum` — 可选。 用于计算结果的最小和最大 hash 的数量,范围为 `1` 到 `25` 的任意数字。默认值为 `6`。 [`UInt8`](/sql-reference/data-types/int-uint) -**Syntax** -```sql -gccMurmurHash(par1, ...) +**返回值** + +返回包含两个元组的元组,每个元组都有 `hashnum` 个 n-grams。 [`Tuple(Tuple(String))`](/sql-reference/data-types/tuple) + +**示例** + +**使用示例** + +```sql title=Query +SELECT ngramMinHashArgCaseInsensitiveUTF8('ClickHouse') AS Tuple; ``` -**Arguments** +```response title=Response +┌─Tuple─────────────────────────────────────────────────────────────────────────┐ +│ (('ckH','ous','ick','lic','kHo','use'),('kHo','lic','ick','ous','ckH','Hou')) │ +└───────────────────────────────────────────────────────────────────────────────┘ +``` +## ngramMinHashArgUTF8 {#ngramMinHashArgUTF8} -- `par1, ...` — 可变数量的参数,可以是任何 [支持的数据类型](/sql-reference/data-types)。 +Introduced in: v21.1 -**Returned value** -- 计算得到的哈希值。 [UInt64](../data-types/int-uint.md)。 +将 UTF-8 字符串拆分为 `ngramsize` 符号的 n-grams,并返回 minimum hash 和 maximum hash,计算方法为与相同输入的 `ngramMinHashUTF8` 函数。 +该函数对大小写敏感。 -**Example** -查询: +**语法** ```sql -SELECT - gccMurmurHash(1, 2, 3) AS res1, - gccMurmurHash(('a', [1, 2, 3], 4, (4, ['foo', 'bar'], 1, (1, 2)))) AS res2 +ngramMinHashArgUTF8(string[, ngramsize, hashnum]) ``` -结果: +**参数** -```response -┌─────────────────res1─┬────────────────res2─┐ -│ 12384823029245979431 │ 1188926775431157506 │ -└──────────────────────┴─────────────────────┘ -``` -## kafkaMurmurHash {#kafkamurmurhash} +- `string` — 要计算 hash 的字符串。 [`String`](/sql-reference/data-types/string) +- `ngramsize` — 可选。 n-gram 的大小,范围为 `1` 到 `25` 的任意数字。默认值为 `3`。 [`UInt8`](/sql-reference/data-types/int-uint) +- `hashnum` — 可选。 用于计算结果的最小和最大 hash 的数量,范围为 `1` 到 `25` 的任意数字。默认值为 `6`。 [`UInt8`](/sql-reference/data-types/int-uint) -使用与 [Kafka](https://github.com/apache/kafka/blob/461c5cfe056db0951d9b74f5adc45973670404d7/clients/src/main/java/org/apache/kafka/common/utils/Utils.java#L482) 相同的哈希种子计算 32 位 [MurmurHash2](https://github.com/aappleby/smhasher) 哈希值,并且不使用最高位,以便与 [Default Partitioner](https://github.com/apache/kafka/blob/139f7709bd3f5926901a21e55043388728ccca78/clients/src/main/java/org/apache/kafka/clients/producer/internals/BuiltInPartitioner.java#L328) 兼容。 -**Syntax** +**返回值** -```sql -MurmurHash(par1, ...) -``` +返回包含两个元组的元组,每个元组都有 `hashnum` 个 n-grams。 [`Tuple(Tuple(String))`](/sql-reference/data-types/tuple) -**Arguments** +**示例** -- `par1, ...` — 可变数量的参数,可以是任何 [支持的数据类型](/sql-reference/data-types)。 +**使用示例** -**Returned value** +```sql title=Query +SELECT ngramMinHashArgUTF8('ClickHouse') AS Tuple; +``` -- 计算得到的哈希值。 [UInt32](../data-types/int-uint.md)。 +```response title=Response +┌─Tuple─────────────────────────────────────────────────────────────────────────┐ +│ (('ous','ick','lic','Hou','kHo','use'),('kHo','Hou','lic','ick','ous','ckH')) │ +└───────────────────────────────────────────────────────────────────────────────┘ +``` +## ngramMinHashCaseInsensitive {#ngramMinHashCaseInsensitive} -**Example** +Introduced in: v21.1 -查询: -```sql -SELECT - kafkaMurmurHash('foobar') AS res1, - kafkaMurmurHash(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS res2 -``` +将 ASCII 字符串拆分为 `ngramsize` 符号的 n-grams,并计算每个 n-gram 的 hash 值,返回一个包含这些 hash 的元组 +使用 `hashnum` 个最小 hash 来计算最小 hash,使用 `hashnum` 个最大 hash 来计算最大 hash。 +该函数对大小写不敏感。 -结果: +可用于使用 [`tupleHammingDistance`](../functions/tuple-functions.md/#tuplehammingdistance) 检测半重复字符串。 +对于两个字符串,如果返回的 hash 对于这两个字符串是相同的,则这两个字符串是相同的。 -```response -┌───────res1─┬─────res2─┐ -│ 1357151166 │ 85479775 │ -└────────────┴──────────┘ -``` -## murmurHash3_32, murmurHash3_64 {#murmurhash3_32-murmurhash3_64} -生成 [MurmurHash3](https://github.com/aappleby/smhasher) 哈希值。 +**语法** ```sql -murmurHash3_32(par1, ...) -murmurHash3_64(par1, ...) +ngramMinHashCaseInsensitive(string[, ngramsize, hashnum]) ``` -**Arguments** +**参数** -这两个函数接受可变数量的输入参数。参数可以是任何 [支持的数据类型](../data-types/index.md)。对于某些数据类型,即使参数的类型不同(不同大小的整数,带有相同数据的命名和未命名的 `Tuple`,`Map` 以及相应的具有相同数据的 `Array(Tuple(key, value))` 类型),其哈希函数的计算值可能是相同的。 +- `string` — 字符串。 [String](../data-types/string.md)。 - `ngramsize` — n-gram 的大小。可选。可能的值:范围为 `1` 到 `25` 的任意数字。默认值:`3`。 [UInt8](../data-types/int-uint.md)。 - `hashnum` — 用于计算结果的最小和最大 hash 的数量。可选。可能的值:范围为 `1` 到 `25` 的任意数字。默认值:`6`。 [UInt8](../data-types/int-uint.md)。 -**Returned Value** +**返回值** -- `murmurHash3_32` 函数返回类型为 [UInt32](../data-types/int-uint.md) 的哈希值。 -- `murmurHash3_64` 函数返回类型为 [UInt64](../data-types/int-uint.md) 的哈希值。 +包含两个 hash 的元组 — 最小和最大。 [Tuple](../data-types/tuple.md)([UInt64](../data-types/int-uint.md), [UInt64](../data-types/int-uint.md)). [`Tuple`](/sql-reference/data-types/tuple) -**Example** +**示例** -```sql -SELECT murmurHash3_32(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS MurmurHash3, toTypeName(MurmurHash3) AS type; -``` +**使用示例** -```response -┌─MurmurHash3─┬─type───┐ -│ 2152717 │ UInt32 │ -└─────────────┴────────┘ +```sql title=Query +SELECT ngramMinHashCaseInsensitive('ClickHouse') AS Tuple; ``` -## murmurHash3_128 {#murmurhash3_128} - -生成 128 位 [MurmurHash3](https://github.com/aappleby/smhasher) 哈希值。 -**Syntax** - -```sql -murmurHash3_128(expr) +```response title=Response +┌─Tuple──────────────────────────────────────┐ +│ (2106263556442004574,13203602793651726206) │ +└────────────────────────────────────────────┘ ``` +## ngramMinHashCaseInsensitiveUTF8 {#ngramMinHashCaseInsensitiveUTF8} -**Arguments** +引入于:v21.1 -- `expr` — 一组 [表达式](/sql-reference/syntax#expressions)。 [字符串](../data-types/string.md)。 -**Returned value** +将 UTF-8 字符串拆分为 `ngramsize` 符号的 n-grams,并计算每个 n-gram 的散列值,然后返回包含这些散列的元组。 +使用 `hashnum` 个最小散列来计算最小散列,使用 `hashnum` 个最大散列来计算最大散列。 +此功能对大小写不敏感。 -一个 128 位 `MurmurHash3` 哈希值。 [FixedString(16)](../data-types/fixedstring.md)。 +可以与 [`tupleHammingDistance`](../functions/tuple-functions.md/#tuplehammingdistance) 一起使用来检测半重复字符串。 +对于两个字符串,如果返回的散列对两个字符串都是相同的,则这两个字符串是相同的。 -**Example** -查询: +**语法** ```sql -SELECT hex(murmurHash3_128('foo', 'foo', 'foo')); +ngramMinHashCaseInsensitiveUTF8(string [, ngramsize, hashnum]) ``` -结果: +**参数** -```response -┌─hex(murmurHash3_128('foo', 'foo', 'foo'))─┐ -│ F8F7AD9B6CD4CF117A71E277E2EC2931 │ -└───────────────────────────────────────────┘ -``` -## xxh3 {#xxh3} +- `string` — 要计算散列的字符串。 [`String`](/sql-reference/data-types/string) +- `ngramsize` — 可选。n-gram 的大小,范围从 `1` 到 `25` 的任何数字。默认值为 `3`。 [`UInt8`](/sql-reference/data-types/int-uint) +- `hashnum` — 可选。用于计算结果的最小和最大散列的数量,范围从 `1` 到 `25` 的任何数字。默认值为 `6`。 [`UInt8`](/sql-reference/data-types/int-uint) -生成 64 位 [xxh3](https://github.com/Cyan4973/xxHash) 哈希值。 -**Syntax** +**返回值** -```sql -xxh3(expr) -``` +返回包含两个散列的元组 — 最小值和最大值。 [`Tuple`](/sql-reference/data-types/tuple) -**Arguments** +**示例** -- `expr` — 一组 [表达式](/sql-reference/syntax#expressions),可以是任意数据类型。 +**用法示例** -**Returned value** +```sql title=Query +SELECT ngramMinHashCaseInsensitiveUTF8('ClickHouse') AS Tuple; +``` -一个 64 位 `xxh3` 哈希值。 [UInt64](../data-types/int-uint.md)。 +```response title=Response +┌─Tuple───────────────────────────────────────┐ +│ (12493625717655877135,13203602793651726206) │ +└─────────────────────────────────────────────┘ +``` +## ngramMinHashUTF8 {#ngramMinHashUTF8} -**Example** +引入于:v21.1 -查询: -```sql -SELECT xxh3('Hello', 'world') -``` +将 UTF-8 字符串拆分为 `ngramsize` 符号的 n-grams,并计算每个 n-gram 的散列值,然后返回包含这些散列的元组。 +使用 `hashnum` 个最小散列来计算最小散列,使用 `hashnum` 个最大散列来计算最大散列。 +此功能对大小写敏感。 -结果: +可以与 [`tupleHammingDistance`](../functions/tuple-functions.md/#tuplehammingdistance) 一起使用来检测半重复字符串。 +对于两个字符串,如果返回的散列对两个字符串都是相同的,则这两个字符串是相同的。 -```response -┌─xxh3('Hello', 'world')─┐ -│ 5607458076371731292 │ -└────────────────────────┘ -``` -## xxHash32, xxHash64 {#xxhash32-xxhash64} -从字符串计算 `xxHash`。提供 32 位和 64 位两种形式。 +**语法** ```sql -SELECT xxHash32('') +ngramMinHashUTF8(string[, ngramsize, hashnum]) +``` -OR +**参数** -SELECT xxHash64('') -``` +- `string` — 要计算散列的字符串。 [`String`](/sql-reference/data-types/string) +- `ngramsize` — 可选。n-gram 的大小,范围从 `1` 到 `25` 的任何数字。默认值为 `3`。 [`UInt8`](/sql-reference/data-types/int-uint) +- `hashnum` — 可选。用于计算结果的最小和最大散列的数量,范围从 `1` 到 `25` 的任何数字。默认值为 `6`。 [`UInt8`](/sql-reference/data-types/int-uint) -**Returned value** -- 哈希值。 [UInt32/64](../data-types/int-uint.md)。 +**返回值** -:::note -返回类型为 `xxHash32` 的将为 `UInt32`,而 `xxHash64` 将为 `UInt64`。 -::: +返回包含两个散列的元组 — 最小值和最大值。 [`Tuple`](/sql-reference/data-types/tuple) -**Example** +**示例** -查询: +**用法示例** -```sql -SELECT xxHash32('Hello, world!'); +```sql title=Query +SELECT ngramMinHashUTF8('ClickHouse') AS Tuple; ``` -结果: - -```response -┌─xxHash32('Hello, world!')─┐ -│ 834093149 │ -└───────────────────────────┘ +```response title=Response +┌─Tuple──────────────────────────────────────┐ +│ (18333312859352735453,6742163577938632877) │ +└────────────────────────────────────────────┘ ``` +## ngramSimHash {#ngramSimHash} -**See Also** +引入于:v21.1 -- [xxHash](http://cyan4973.github.io/xxHash/). -## ngramSimHash {#ngramsimhash} -将 ASCII 字符串分成 n-grams,大小为 `ngramsize` 符号,并返回 n-gram `simhash`。区分大小写。 +将 ASCII 字符串拆分为 `ngramsize` 符号的 n-grams,并返回 n-gram 的 `simhash`。 -可以用于检测半重复字符串,配合 [bitHammingDistance](../functions/bit-functions.md/#bithammingdistance) 使用。计算的两个字符串的 `simhashes` 的 [Hamming Distance](https://en.wikipedia.org/wiki/Hamming_distance) 越小,这两 string 越可能相同。 +可以与 [`bitHammingDistance`](../functions/bit-functions.md/#bitHammingDistance) 一起使用来检测半重复字符串。 +计算出的两个字符串的 `simhash` 之间的 [汉明距离](https://en.wikipedia.org/wiki/Hamming_distance) 越小,这两个字符串相同的可能性就越大。 -**Syntax** + +**语法** ```sql ngramSimHash(string[, ngramsize]) ``` -**Arguments** +**参数** -- `string` — 字符串。 [字符串](../data-types/string.md)。 -- `ngramsize` — n-gram 的大小。可选。可能值:从 `1` 到 `25` 的任意数字。默认值:`3`。 [UInt8](../data-types/int-uint.md)。 +- `string` — 要计算的对大小写敏感的 `simhash` 的字符串。 [`String`](/sql-reference/data-types/string) +- `ngramsize` — 可选。n-gram 的大小,范围从 `1` 到 `25` 的任何数字。默认值为 `3`。 [`UInt8`](/sql-reference/data-types/int-uint) -**Returned value** -- 哈希值。 [UInt64](../data-types/int-uint.md)。 +**返回值** -**Example** +返回输入字符串的计算散列。 [`UInt64`](/sql-reference/data-types/int-uint) -查询: +**示例** -```sql +**用法示例** + +```sql title=Query SELECT ngramSimHash('ClickHouse') AS Hash; ``` -结果: - -```response +```response title=Response ┌───────Hash─┐ │ 1627567969 │ └────────────┘ ``` -## ngramSimHashCaseInsensitive {#ngramsimhashcaseinsensitive} +## ngramSimHashCaseInsensitive {#ngramSimHashCaseInsensitive} + +引入于:v21.1 + -将 ASCII 字符串分成 n-grams,大小为 `ngramsize` 符号,并返回 n-gram `simhash`。不区分大小写。 +将 ASCII 字符串拆分为 `ngramsize` 符号的 n-grams,并返回 n-gram 的 `simhash`。 +此功能对大小写不敏感。 -可以用于检测半重复字符串,配合 [bitHammingDistance](../functions/bit-functions.md/#bithammingdistance) 使用。计算的两个字符串的 `simhashes` 的 [Hamming Distance](https://en.wikipedia.org/wiki/Hamming_distance) 越小,这两 string 越可能相同。 +可以与 [`bitHammingDistance`](/sql-reference/functions/bit-functions#bitHammingDistance) 一起使用来检测半重复字符串。 +计算出的两个字符串的 `simhash` 之间的 [汉明距离](https://en.wikipedia.org/wiki/Hamming_distance) 越小,这两个字符串相同的可能性就越大。 -**Syntax** + +**语法** ```sql ngramSimHashCaseInsensitive(string[, ngramsize]) ``` -**Arguments** +**参数** + +- `string` — 要计算的对大小写不敏感的 `simhash` 的字符串。 [`String`](/sql-reference/data-types/string) +- `ngramsize` — 可选。n-gram 的大小,范围从 `1` 到 `25` 的任何数字。默认值为 `3`。 [`UInt8`](/sql-reference/data-types/int-uint) -- `string` — 字符串。 [字符串](../data-types/string.md)。 -- `ngramsize` — n-gram 的大小。可选。可能值:从 `1` 到 `25` 的任意数字。默认值:`3`。 [UInt8](../data-types/int-uint.md)。 -**Returned value** +**返回值** -- 哈希值。 [UInt64](../data-types/int-uint.md)。 +散列值。 [UInt64](../data-types/int-uint.md). [`UInt64`](/sql-reference/data-types/int-uint) -**Example** +**示例** -查询: +**用法示例** -```sql +```sql title=Query SELECT ngramSimHashCaseInsensitive('ClickHouse') AS Hash; ``` -结果: - -```response +```response title=Response ┌──────Hash─┐ │ 562180645 │ └───────────┘ ``` -## ngramSimHashUTF8 {#ngramsimhashutf8} - -将 UTF-8 字符串分成 n-grams,大小为 `ngramsize` 符号,并返回 n-gram `simhash`。区分大小写。 - -可以用于检测半重复字符串,配合 [bitHammingDistance](../functions/bit-functions.md/#bithammingdistance) 使用。计算的两个字符串的 `simhashes` 的 [Hamming Distance](https://en.wikipedia.org/wiki/Hamming_distance) 越小,这两 string 越可能相同。 - -**Syntax** - -```sql -ngramSimHashUTF8(string[, ngramsize]) -``` - -**Arguments** - -- `string` — 字符串。 [字符串](../data-types/string.md)。 -- `ngramsize` — n-gram 的大小。可选。可能值:从 `1` 到 `25` 的任意数字。默认值:`3`。 [UInt8](../data-types/int-uint.md)。 - -**Returned value** - -- 哈希值。 [UInt64](../data-types/int-uint.md)。 - -**Example** +## ngramSimHashCaseInsensitiveUTF8 {#ngramSimHashCaseInsensitiveUTF8} -查询: +引入于:v21.1 -```sql -SELECT ngramSimHashUTF8('ClickHouse') AS Hash; -``` - -结果: -```response -┌───────Hash─┐ -│ 1628157797 │ -└────────────┘ -``` -## ngramSimHashCaseInsensitiveUTF8 {#ngramsimhashcaseinsensitiveutf8} +将 UTF-8 字符串拆分为 `ngramsize` 符号的 n-grams,并返回 n-gram 的 `simhash`。 +此功能对大小写不敏感。 -将 UTF-8 字符串分成 n-grams,大小为 `ngramsize` 符号,并返回 n-gram `simhash`。不区分大小写。 +可以与 [bitHammingDistance](../functions/bit-functions.md/#bitHammingDistance) 一起使用来检测半重复字符串。计算出的两个字符串的 `simhash` 之间的 [汉明距离](https://en.wikipedia.org/wiki/Hamming_distance) 越小,这两个字符串相同的可能性就越大。 -可以用于检测半重复字符串,配合 [bitHammingDistance](../functions/bit-functions.md/#bithammingdistance) 使用。计算的两个字符串的 `simhashes` 的 [Hamming Distance](https://en.wikipedia.org/wiki/Hamming_distance) 越小,这两 string 越可能相同。 -**Syntax** +**语法** ```sql ngramSimHashCaseInsensitiveUTF8(string[, ngramsize]) ``` -**Arguments** +**参数** + +- `string` — 要计算散列的字符串。 [`String`](/sql-reference/data-types/string) +- `ngramsize` — 可选。n-gram 的大小,范围从 `1` 到 `25` 的任何数字。默认值为 `3`。 [`UInt8`](/sql-reference/data-types/int-uint) -- `string` — 字符串。 [字符串](../data-types/string.md)。 -- `ngramsize` — n-gram 的大小。可选。可能值:从 `1` 到 `25` 的任意数字。默认值:`3`。 [UInt8](../data-types/int-uint.md)。 -**Returned value** +**返回值** -- 哈希值。 [UInt64](../data-types/int-uint.md)。 +返回计算出的散列值。 [`UInt64`](/sql-reference/data-types/int-uint) -**Example** +**示例** -查询: +**用法示例** -```sql +```sql title=Query SELECT ngramSimHashCaseInsensitiveUTF8('ClickHouse') AS Hash; ``` -结果: - -```response +```response title=Response ┌───────Hash─┐ │ 1636742693 │ └────────────┘ ``` -## wordShingleSimHash {#wordshinglesimhash} +## ngramSimHashUTF8 {#ngramSimHashUTF8} + +引入于:v21.1 -将 ASCII 字符串分成部分(shingles),大小为 `shinglesize` 个单词,并返回单词 shingle 的 `simhash`。区分大小写。 -可以用于检测半重复字符串,配合 [bitHammingDistance](../functions/bit-functions.md/#bithammingdistance) 使用。计算的两个字符串的 `simhashes` 的 [Hamming Distance](https://en.wikipedia.org/wiki/Hamming_distance) 越小,这两 string 越可能相同。 +将 UTF-8 编码的字符串拆分为 `ngramsize` 符号的 n-grams,并返回 n-gram 的 `simhash`。 +此功能对大小写敏感。 -**Syntax** +可以与 [`bitHammingDistance`](../functions/bit-functions.md/#bitHammingDistance) 一起使用来检测半重复字符串。 +计算出的两个字符串的 `simhash` 之间的 [汉明距离](https://en.wikipedia.org/wiki/Hamming_distance) 越小,这两个字符串相同的可能性就越大。 + + +**语法** ```sql -wordShingleSimHash(string[, shinglesize]) +ngramSimHashUTF8(string[, ngramsize]) ``` -**Arguments** +**参数** + +- `string` — 要计算散列的字符串。 [`String`](/sql-reference/data-types/string) +- `ngramsize` — 可选。n-gram 的大小,范围从 `1` 到 `25` 的任何数字。默认值为 `3`。 [`UInt8`](/sql-reference/data-types/int-uint) -- `string` — 字符串。 [字符串](../data-types/string.md)。 -- `shinglesize` — 单词 shingle 的大小。可选。可能值:从 `1` 到 `25` 的任意数字。默认值:`3`。 [UInt8](../data-types/int-uint.md)。 -**Returned value** +**返回值** -- 哈希值。 [UInt64](../data-types/int-uint.md)。 +返回计算出的散列值。 [`UInt64`](/sql-reference/data-types/int-uint) -**Example** +**示例** -查询: +**用法示例** -```sql -SELECT wordShingleSimHash('ClickHouse® is a column-oriented database management system (DBMS) for online analytical processing of queries (OLAP).') AS Hash; +```sql title=Query +SELECT ngramSimHashUTF8('ClickHouse') AS Hash; ``` -结果: - -```response +```response title=Response ┌───────Hash─┐ -│ 2328277067 │ +│ 1628157797 │ └────────────┘ ``` -## wordShingleSimHashCaseInsensitive {#wordshinglesimhashcaseinsensitive} - -将 ASCII 字符串分成部分(shingles),大小为 `shinglesize` 个单词,并返回单词 shingle 的 `simhash`。不区分大小写。 +## sipHash128 {#sipHash128} -可以用于检测半重复字符串,配合 [bitHammingDistance](../functions/bit-functions.md/#bithammingdistance) 使用。计算的两个字符串的 `simhashes` 的 [Hamming Distance](https://en.wikipedia.org/wiki/Hamming_distance) 越小,这两 string 越可能相同。 +引入于:v1.1 -**Syntax** -```sql -wordShingleSimHashCaseInsensitive(string[, shinglesize]) -``` +与 [`sipHash64`](#sipHash64) 类似,但生成 128 位散列值,即最终的异或折叠状态处理到 128 位。 -**Arguments** +:::tip 对于新项目请使用 sipHash128Reference +此 128 位变体与参考实现不同且更弱。 +此版本存在的原因是,在编写时,没有官方的 128 位 SipHash 扩展。 +建议新项目使用 [`sipHash128Reference`](#sipHash128Reference)。 +::: -- `string` — 字符串。 [字符串](../data-types/string.md)。 -- `shinglesize` — 单词 shingle 的大小。可选。可能值:从 `1` 到 `25` 的任意数字。默认值:`3`。 [UInt8](../data-types/int-uint.md)。 -**Returned value** +**语法** -- 哈希值。 [UInt64](../data-types/int-uint.md)。 +```sql +sipHash128(arg1[, arg2, ...]) +``` -**Example** +**参数** -查询: +- `arg1[, arg2, ...]` — 要计算散列的输入参数的可变数量。 [`Any`](/sql-reference/data-types) -```sql -SELECT wordShingleSimHashCaseInsensitive('ClickHouse® is a column-oriented database management system (DBMS) for online analytical processing of queries (OLAP).') AS Hash; -``` -结果: +**返回值** -```response -┌───────Hash─┐ -│ 2194812424 │ -└────────────┘ -``` -## wordShingleSimHashUTF8 {#wordshinglesimhashutf8} +返回 128 位 `SipHash` 散列值。 [`FixedString(16)`](/sql-reference/data-types/fixedstring) -将 UTF-8 字符串分成部分(shingles),大小为 `shinglesize` 个单词,并返回单词 shingle 的 `simhash`。区分大小写。 +**示例** -可以用于检测半重复字符串,配合 [bitHammingDistance](../functions/bit-functions.md/#bithammingdistance) 使用。计算的两个字符串的 `simhashes` 的 [Hamming Distance](https://en.wikipedia.org/wiki/Hamming_distance) 越小,这两 string 越可能相同。 +**用法示例** -**Syntax** +```sql title=Query +SELECT hex(sipHash128('foo', '\x01', 3)); +``` -```sql -wordShingleSimHashUTF8(string[, shinglesize]) +```response title=Response +┌─hex(sipHash128('foo', '', 3))────┐ +│ 9DE516A64A414D4B1B609415E4523F24 │ +└──────────────────────────────────┘ ``` +## sipHash128Keyed {#sipHash128Keyed} -**Arguments** +引入于:v23.2 -- `string` — 字符串。 [字符串](../data-types/string.md)。 -- `shinglesize` — 单词 shingle 的大小。可选。可能值:从 `1` 到 `25` 的任意数字。默认值:`3`。 [UInt8](../data-types/int-uint.md)。 -**Returned value** +与 [`sipHash128`](#sipHash128) 相同,但额外提供一个明确的密钥参数,而不是使用固定密钥。 -- 哈希值。 [UInt64](../data-types/int-uint.md)。 +:::tip 对于新项目请使用 sipHash128ReferenceKeyed +此 128 位变体与参考实现不同且更弱。 +此版本存在的原因是,在编写时,没有官方的 128 位 SipHash 扩展。 +新项目可能应该使用 [`sipHash128ReferenceKeyed`](#sipHash128ReferenceKeyed)。 +::: -**Example** -查询: +**语法** ```sql -SELECT wordShingleSimHashUTF8('ClickHouse® is a column-oriented database management system (DBMS) for online analytical processing of queries (OLAP).') AS Hash; -``` - -结果: - -```response -┌───────Hash─┐ -│ 2328277067 │ -└────────────┘ +sipHash128Keyed((k0, k1), [arg1, arg2, ...]) ``` -## wordShingleSimHashCaseInsensitiveUTF8 {#wordshinglesimhashcaseinsensitiveutf8} - -将 UTF-8 字符串分成部分(shingles),大小为 `shinglesize` 个单词,并返回单词 shingle 的 `simhash`。不区分大小写。 -可以用于检测半重复字符串,配合 [bitHammingDistance](../functions/bit-functions.md/#bithammingdistance) 使用。计算的两个字符串的 `simhashes` 的 [Hamming Distance](https://en.wikipedia.org/wiki/Hamming_distance) 越小,这两 string 越可能相同。 - -**Syntax** +**参数** -```sql -wordShingleSimHashCaseInsensitiveUTF8(string[, shinglesize]) -``` +- `(k0, k1)` — 表示密钥的两个 UInt64 值的元组。 [`Tuple(UInt64, UInt64)`](/sql-reference/data-types/tuple) +- `arg1[, arg2, ...]` — 要计算散列的输入参数的可变数量。 [`Any`](/sql-reference/data-types) -**Arguments** -- `string` — 字符串。 [字符串](../data-types/string.md)。 -- `shinglesize` — 单词 shingle 的大小。可选。可能值:从 `1` 到 `25` 的任意数字。默认值:`3`。 [UInt8](../data-types/int-uint.md)。 +**返回值** -**Returned value** +返回输入值的 128 位 `SipHash` 散列值。 [`FixedString(16)`](/sql-reference/data-types/fixedstring) -- 哈希值。 [UInt64](../data-types/int-uint.md)。 +**示例** -**Example** +**用法示例** -查询: +```sql title=Query +SELECT hex(sipHash128Keyed((506097522914230528, 1084818905618843912),'foo', '\x01', 3)); +``` -```sql -SELECT wordShingleSimHashCaseInsensitiveUTF8('ClickHouse® is a column-oriented database management system (DBMS) for online analytical processing of queries (OLAP).') AS Hash; +```response title=Response +┌─hex(sipHash128Keyed((506097522914230528, 1084818905618843912), 'foo', '', 3))─┐ +│ B8467F65C8B4CFD9A5F8BD733917D9BF │ +└───────────────────────────────────────────────────────────────────────────────┘ ``` +## sipHash128Reference {#sipHash128Reference} -结果: +引入于:v23.2 -```response -┌───────Hash─┐ -│ 2194812424 │ -└────────────┘ -``` -## wyHash64 {#wyhash64} -生成 64 位 [wyHash64](https://github.com/wangyi-fudan/wyhash) 哈希值。 +与 [`sipHash128`](/sql-reference/functions/hash-functions#sipHash128) 类似,但实现 SipHash 原作者的 128 位算法。 + -**Syntax** +**语法** ```sql -wyHash64(string) +sipHash128Reference(arg1[, arg2, ...]) ``` -**Arguments** +**参数** + +- `arg1[, arg2, ...]` — 要计算散列的输入参数的可变数量。 [`Any`](/sql-reference/data-types) -- `string` — 字符串。 [字符串](../data-types/string.md)。 -**Returned value** +**返回值** -- 哈希值。 [UInt64](../data-types/int-uint.md)。 +返回输入参数计算出的 128 位 `SipHash` 散列值。 [`FixedString(16)`](/sql-reference/data-types/fixedstring) -**Example** +**示例** -查询: +**用法示例** -```sql -SELECT wyHash64('ClickHouse') AS Hash; +```sql title=Query +SELECT hex(sipHash128Reference('foo', '', 3)); ``` -结果: - -```response -┌─────────────────Hash─┐ -│ 12336419557878201794 │ -└──────────────────────┘ +```response title=Response +┌─hex(sipHash128Reference('foo', '', 3))─┐ +│ 4D1BE1A22D7F5933C0873E1698426260 │ +└────────────────────────────────────────┘ ``` -## ngramMinHash {#ngramminhash} +## sipHash128ReferenceKeyed {#sipHash128ReferenceKeyed} -将 ASCII 字符串分成 n-grams,大小为 `ngramsize` 符号,并计算每个 n-gram 的哈希值。使用 `hashnum` 最小哈希计算最小哈希,使用 `hashnum` 最大哈希计算最大哈希。返回包含这些哈希的元组。区分大小写。 +引入于:v23.2 -可以用于检测半重复字符串,配合 [tupleHammingDistance](../functions/tuple-functions.md/#tuplehammingdistance) 使用。对于两个字符串:如果返回的哈希之一在两个字符串中是相同的,我们认为这两个字符串是相同的。 -**Syntax** +与 [`sipHash128Reference`](#sipHash128Reference) 相同,但额外提供一个明确的密钥参数,而不是使用固定密钥。 + + +**语法** ```sql -ngramMinHash(string[, ngramsize, hashnum]) +sipHash128ReferenceKeyed((k0, k1), arg1[, arg2, ...]) ``` -**Arguments** +**参数** -- `string` — 字符串。 [字符串](../data-types/string.md)。 -- `ngramsize` — n-gram 的大小。可选。可能值:从 `1` 到 `25` 的任意数字。默认值:`3`。 [UInt8](../data-types/int-uint.md)。 -- `hashnum` — 用于计算结果的最小和最大哈希的数量。可选。可能值:从 `1` 到 `25` 的任意数字。默认值:`6`。 [UInt8](../data-types/int-uint.md)。 +- `(k0, k1)` — 表示密钥的两个值的元组 [`Tuple(UInt64, UInt64)`](/sql-reference/data-types/tuple) +- `arg1[, arg2, ...]` — 要计算散列的输入参数的可变数量。 [`Any`](/sql-reference/data-types) -**Returned value** -- 包含两个哈希的元组 — 最小哈希和最大哈希。 [Tuple](../data-types/tuple.md)([UInt64](../data-types/int-uint.md), [UInt64](../data-types/int-uint.md))。 +**返回值** -**Example** +返回输入参数计算出的 128 位 `SipHash` 散列值。 [`FixedString(16)`](/sql-reference/data-types/fixedstring) -查询: +**示例** -```sql -SELECT ngramMinHash('ClickHouse') AS Tuple; +**用法示例** + +```sql title=Query +SELECT hex(sipHash128Reference('foo', '', 3)); +``` + +```response title=Response +┌─hex(sipHash128Reference('foo', '', 3))─┐ +│ 4D1BE1A22D7F5933C0873E1698426260 │ +└────────────────────────────────────────┘ ``` +## sipHash64 {#sipHash64} + +引入于:v1.1 + -结果: +生成 64 位 [SipHash](https://en.wikipedia.org/wiki/SipHash) 散列值。 -```response -┌─Tuple──────────────────────────────────────┐ -│ (18333312859352735453,9054248444481805918) │ -└────────────────────────────────────────────┘ -``` +这是一个密码散列函数。其速度至少比 [`MD5`](#MD5) 散列函数快三倍。 -## ngramMinHashCaseInsensitive {#ngramminhashcaseinsensitive} +该函数 [将所有输入参数解释](/sql-reference/functions/type-conversion-functions#reinterpretasstring) 为字符串,并计算每个输入参数的散列值。 +然后使用以下算法组合这些散列: -将 ASCII 字符串拆分为 `ngramsize` 符号的 n-grams,并计算每个 n-gram 的哈希值。使用 `hashnum` 最小哈希计算最小哈希,并使用 `hashnum` 最大哈希计算最大哈希。返回一个包含这些哈希的元组。区分大小写。 +1. 第一个和第二个散列值被连接到一个数组中,并进行散列。 +2. 先前计算的散列值和第三个输入参数的散列值以类似的方式进行散列。 +3. 对原始输入的所有剩余散列值重复此计算。 + +:::note +对于不同参数类型的相同输入值,计算出的散列值可能相等。 +这会影响例如不同大小的整数类型,具有相同数据的命名和未命名的 `Tuple`,以及具有相同数据的 `Map` 和相应的 `Array(Tuple(key, value))` 类型。 +::: -可用于检测半重复字符串,结合使用 [tupleHammingDistance](../functions/tuple-functions.md/#tuplehammingdistance)。对于两个字符串:如果返回的哈希值之一在这两个字符串中相同,我们认为这两个字符串是相同的。 **语法** ```sql -ngramMinHashCaseInsensitive(string[, ngramsize, hashnum]) +sipHash64(arg1[, arg2, ...]) ``` **参数** -- `string` — 字符串。 [String](../data-types/string.md)。 -- `ngramsize` — n-gram 的大小。可选。可能的值:从 `1` 到 `25` 的任意数字。默认值:`3`。 [UInt8](../data-types/int-uint.md)。 -- `hashnum` — 用于计算结果的最小和最大哈希的数量。可选。可能的值:从 `1` 到 `25` 的任意数字。默认值:`6`。 [UInt8](../data-types/int-uint.md)。 +- `arg1[, arg2, ...]` — 可变数量的输入参数。 [`Any`](/sql-reference/data-types) + **返回值** -- 包含两个哈希的元组 — 最小和最大哈希。 [Tuple](../data-types/tuple.md)([UInt64](../data-types/int-uint.md), [UInt64](../data-types/int-uint.md))。 +返回计算的输入参数的散列值。 [`UInt64`](/sql-reference/data-types/int-uint) **示例** -查询: +**用法示例** -```sql -SELECT ngramMinHashCaseInsensitive('ClickHouse') AS Tuple; +```sql title=Query +SELECT sipHash64(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS SipHash, toTypeName(SipHash) AS type; ``` -结果: - -```response -┌─Tuple──────────────────────────────────────┐ -│ (2106263556442004574,13203602793651726206) │ -└────────────────────────────────────────────┘ +```response title=Response +┌──────────────SipHash─┬─type───┐ +│ 11400366955626497465 │ UInt64 │ +└──────────────────────┴────────┘ ``` -## ngramMinHashUTF8 {#ngramminhashutf8} +## sipHash64Keyed {#sipHash64Keyed} + +引入于:v23.2 -将 UTF-8 字符串拆分为 `ngramsize` 符号的 n-grams,并计算每个 n-gram 的哈希值。使用 `hashnum` 最小哈希计算最小哈希,并使用 `hashnum` 最大哈希计算最大哈希。返回一个包含这些哈希的元组。区分大小写。 -可用于检测半重复字符串,结合使用 [tupleHammingDistance](../functions/tuple-functions.md/#tuplehammingdistance)。对于两个字符串:如果返回的哈希值之一在这两个字符串中相同,我们认为这两个字符串是相同的。 +与 [`sipHash64`](#sipHash64) 类似,但额外提供一个明确的密钥参数,而不是使用固定密钥。 + **语法** ```sql -ngramMinHashUTF8(string[, ngramsize, hashnum]) +sipHash64Keyed((k0, k1), arg1[,arg2, ...]) ``` **参数** -- `string` — 字符串。 [String](../data-types/string.md)。 -- `ngramsize` — n-gram 的大小。可选。可能的值:从 `1` 到 `25` 的任意数字。默认值:`3`。 [UInt8](../data-types/int-uint.md)。 -- `hashnum` — 用于计算结果的最小和最大哈希的数量。可选。可能的值:从 `1` 到 `25` 的任意数字。默认值:`6`。 [UInt8](../data-types/int-uint.md)。 +- `(k0, k1)` — 表示密钥的两个值的元组。 [`Tuple(UInt64, UInt64)`](/sql-reference/data-types/tuple) +- `arg1[,arg2, ...]` — 要计算散列的输入参数的可变数量。 [`Any`](/sql-reference/data-types) + **返回值** -- 包含两个哈希的元组 — 最小和最大哈希。 [Tuple](../data-types/tuple.md)([UInt64](../data-types/int-uint.md), [UInt64](../data-types/int-uint.md))。 +返回输入值的计算散列。 [`UInt64`](/sql-reference/data-types/int-uint) **示例** -查询: +**用法示例** -```sql -SELECT ngramMinHashUTF8('ClickHouse') AS Tuple; +```sql title=Query +SELECT sipHash64Keyed((506097522914230528, 1084818905618843912), array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS SipHash, toTypeName(SipHash) AS type; ``` -结果: - -```response -┌─Tuple──────────────────────────────────────┐ -│ (18333312859352735453,6742163577938632877) │ -└────────────────────────────────────────────┘ +```response title=Response +┌─────────────SipHash─┬─type───┐ +│ 8017656310194184311 │ UInt64 │ +└─────────────────────┴────────┘ ``` -## ngramMinHashCaseInsensitiveUTF8 {#ngramminhashcaseinsensitiveutf8} +## wordShingleMinHash {#wordShingleMinHash} + +引入于:v21.1 + + +将 ASCII 字符串拆分为 `shinglesize` 个单词的部分(shingles),计算每个单词 shingles 的散列值,并返回包含这些散列的元组。 +使用 `hashnum` 个最小散列来计算最小散列,使用 `hashnum` 个最大散列来计算最大散列。 +此功能对大小写敏感。 -将 UTF-8 字符串拆分为 `ngramsize` 符号的 n-grams,并计算每个 n-gram 的哈希值。使用 `hashnum` 最小哈希计算最小哈希,并使用 `hashnum` 最大哈希计算最大哈希。返回一个包含这些哈希的元组。区分大小写。 +可以与 [`tupleHammingDistance`](../functions/tuple-functions.md/#tuplehammingdistance) 一起使用来检测半重复字符串。 +对于两个字符串,如果返回的散列对两个字符串都是相同的,则这两个字符串是相同的。 -可用于检测半重复字符串,结合使用 [tupleHammingDistance](../functions/tuple-functions.md/#tuplehammingdistance)。对于两个字符串:如果返回的哈希值之一在这两个字符串中相同,我们认为这两个字符串是相同的。 **语法** ```sql -ngramMinHashCaseInsensitiveUTF8(string [, ngramsize, hashnum]) +wordShingleMinHash(string[, shinglesize, hashnum]) ``` **参数** -- `string` — 字符串。 [String](../data-types/string.md)。 -- `ngramsize` — n-gram 的大小。可选。可能的值:从 `1` 到 `25` 的任意数字。默认值:`3`。 [UInt8](../data-types/int-uint.md)。 -- `hashnum` — 用于计算结果的最小和最大哈希的数量。可选。可能的值:从 `1` 到 `25` 的任意数字。默认值:`6`。 [UInt8](../data-types/int-uint.md)。 +- `string` — 要计算散列的字符串。 [`String`](/sql-reference/data-types/string) +- `shinglesize` — 可选。单词 shingles 的大小,范围从 `1` 到 `25` 的任何数字。默认值为 `3`。 [`UInt8`](/sql-reference/data-types/int-uint) +- `hashnum` — 可选。用于计算结果的最小和最大散列的数量,范围从 `1` 到 `25` 的任何数字。默认值为 `6`。 [`UInt8`](/sql-reference/data-types/int-uint) + **返回值** -- 包含两个哈希的元组 — 最小和最大哈希。 [Tuple](../data-types/tuple.md)([UInt64](../data-types/int-uint.md), [UInt64](../data-types/int-uint.md))。 +返回包含两个散列的元组 — 最小值和最大值。 [`Tuple(UInt64, UInt64)`](/sql-reference/data-types/tuple) **示例** -查询: +**用法示例** -```sql -SELECT ngramMinHashCaseInsensitiveUTF8('ClickHouse') AS Tuple; +```sql title=Query +SELECT wordShingleMinHash('ClickHouse® is a column-oriented database management system (DBMS) for online analytical processing of queries (OLAP).') AS Tuple; ``` -结果: - -```response -┌─Tuple───────────────────────────────────────┐ -│ (12493625717655877135,13203602793651726206) │ -└─────────────────────────────────────────────┘ +```response title=Response +┌─Tuple──────────────────────────────────────┐ +│ (16452112859864147620,5844417301642981317) │ +└────────────────────────────────────────────┘ ``` -## ngramMinHashArg {#ngramminhasharg} +## wordShingleMinHashArg {#wordShingleMinHashArg} + +引入于:v1.1 + + +将 ASCII 字符串拆分为 `shinglesize` 个单词的部分(shingles),并返回具有最小和最大单词散列的 shingles,这些散列是通过具有相同输入的 wordShingleMinHash 函数计算的。 +此功能对大小写敏感。 -将 ASCII 字符串拆分为 `ngramsize` 符号的 n-grams,并返回通过相同输入计算的 [ngramMinHash](#ngramminhash) 函数得到的具有最小和最大哈希的 n-grams。区分大小写。 **语法** ```sql -ngramMinHashArg(string[, ngramsize, hashnum]) +wordShingleMinHashArg(string[, shinglesize, hashnum]) ``` **参数** -- `string` — 字符串。 [String](../data-types/string.md)。 -- `ngramsize` — n-gram 的大小。可选。可能的值:从 `1` 到 `25` 的任意数字。默认值:`3`。 [UInt8](../data-types/int-uint.md)。 -- `hashnum` — 用于计算结果的最小和最大哈希的数量。可选。可能的值:从 `1` 到 `25` 的任意数字。默认值:`6`。 [UInt8](../data-types/int-uint.md)。 +- `string` — 要计算散列的字符串。 [`String`](/sql-reference/data-types/string) +- `shinglesize` — 可选。单词 shingles 的大小,范围从 `1` 到 `25` 的任何数字。默认值为 `3`。 [`UInt8`](/sql-reference/data-types/int-uint) +- `hashnum` — 可选。用于计算结果的最小和最大散列的数量,范围从 `1` 到 `25` 的任何数字。默认值为 `6`。 [`UInt8`](/sql-reference/data-types/int-uint) + **返回值** -- 包含两个元组的元组,每个元组包含 `hashnum` 个 n-grams。 [Tuple](../data-types/tuple.md)([Tuple](../data-types/tuple.md)([String](../data-types/string.md)), [Tuple](../data-types/tuple.md)([String](../data-types/string.md)))。 +返回包含两个元组的元组,每个元组具有 `hashnum` 个单词 shingles。 [`Tuple(Tuple(String))`](/sql-reference/data-types/tuple) **示例** -查询: +**用法示例** -```sql -SELECT ngramMinHashArg('ClickHouse') AS Tuple; +```sql title=Query +SELECT wordShingleMinHashArg('ClickHouse® is a column-oriented database management system (DBMS) for online analytical processing of queries (OLAP).', 1, 3) AS Tuple; ``` -结果: - -```response -┌─Tuple─────────────────────────────────────────────────────────────────────────┐ -│ (('ous','ick','lic','Hou','kHo','use'),('Hou','lic','ick','ous','ckH','Cli')) │ -└───────────────────────────────────────────────────────────────────────────────┘ +```response title=Response +┌─Tuple─────────────────────────────────────────────────────────────────┐ +│ (('OLAP','database','analytical'),('online','oriented','processing')) │ +└───────────────────────────────────────────────────────────────────────┘ ``` -## ngramMinHashArgCaseInsensitive {#ngramminhashargcaseinsensitive} +## wordShingleMinHashArgCaseInsensitive {#wordShingleMinHashArgCaseInsensitive} + +引入于:v21.1 + + +将 ASCII 字符串拆分为 `shinglesize` 个单词的部分(shingles),并返回具有最小和最大单词散列的 shingles,这些散列是通过 [`wordShingleMinHashCaseInsensitive`](#wordShingleMinHashCaseInsensitive) 函数计算的。 +此功能对大小写不敏感。 -将 ASCII 字符串拆分为 `ngramsize` 符号的 n-grams,并返回通过相同输入计算的 [ngramMinHashCaseInsensitive](#ngramminhashcaseinsensitive) 函数得到的具有最小和最大哈希的 n-grams。区分大小写。 **语法** ```sql -ngramMinHashArgCaseInsensitive(string[, ngramsize, hashnum]) +wordShingleMinHashArgCaseInsensitive(string[, shinglesize, hashnum]) ``` **参数** -- `string` — 字符串。 [String](../data-types/string.md)。 -- `ngramsize` — n-gram 的大小。可选。可能的值:从 `1` 到 `25` 的任意数字。默认值:`3`。 [UInt8](../data-types/int-uint.md)。 -- `hashnum` — 用于计算结果的最小和最大哈希的数量。可选。可能的值:从 `1` 到 `25` 的任意数字。默认值:`6`。 [UInt8](../data-types/int-uint.md)。 +- `string` — 要计算散列的字符串。 [`String`](/sql-reference/data-types/string) +- `shinglesize` — 可选。单词 shingles 的大小,范围从 `1` 到 `25` 的任何数字。默认值为 `3`。 [`UInt8`](/sql-reference/data-types/int-uint) +- `hashnum` — 可选。用于计算结果的最小和最大散列的数量,范围从 `1` 到 `25` 的任何数字。默认值为 `6`。 [`UInt8`](/sql-reference/data-types/int-uint) + **返回值** -- 包含两个元组的元组,每个元组包含 `hashnum` 个 n-grams。 [Tuple](../data-types/tuple.md)([Tuple](../data-types/tuple.md)([String](../data-types/string.md)), [Tuple](../data-types/tuple.md)([String](../data-types/string.md)))。 +返回包含两个元组的元组,每个元组具有 `hashnum` 个单词 shingles。 [`Tuple(Tuple(String))`](/sql-reference/data-types/tuple) **示例** -查询: +**用法示例** -```sql -SELECT ngramMinHashArgCaseInsensitive('ClickHouse') AS Tuple; +```sql title=Query +SELECT wordShingleMinHashArgCaseInsensitive('ClickHouse® is a column-oriented database management system (DBMS) for online analytical processing of queries (OLAP).', 1, 3) AS Tuple; ``` -结果: - -```response -┌─Tuple─────────────────────────────────────────────────────────────────────────┐ -│ (('ous','ick','lic','kHo','use','Cli'),('kHo','lic','ick','ous','ckH','Hou')) │ -└───────────────────────────────────────────────────────────────────────────────┘ +```response title=Response +┌─Tuple──────────────────────────────────────────────────────────────────┐ +│ (('queries','database','analytical'),('oriented','processing','DBMS')) │ +└────────────────────────────────────────────────────────────────────────┘ ``` -## ngramMinHashArgUTF8 {#ngramminhashargutf8} +## wordShingleMinHashArgCaseInsensitiveUTF8 {#wordShingleMinHashArgCaseInsensitiveUTF8} + +引入于:v21.1 + + +将 UTF-8 字符串拆分为 `shinglesize` 个单词的部分(shingles),并返回具有最小和最大单词散列的 shingles,这些散列是通过 [`wordShingleMinHashCaseInsensitiveUTF8`](#wordShingleMinHashCaseInsensitiveUTF8) 函数计算的。 +此功能对大小写不敏感。 -将 UTF-8 字符串拆分为 `ngramsize` 符号的 n-grams,并返回通过相同输入计算的 [ngramMinHashUTF8](#ngramminhashutf8) 函数得到的具有最小和最大哈希的 n-grams。区分大小写。 **语法** ```sql -ngramMinHashArgUTF8(string[, ngramsize, hashnum]) +wordShingleMinHashArgCaseInsensitiveUTF8(string[, shinglesize, hashnum]) ``` **参数** -- `string` — 字符串。 [String](../data-types/string.md)。 -- `ngramsize` — n-gram 的大小。可选。可能的值:从 `1` 到 `25` 的任意数字。默认值:`3`。 [UInt8](../data-types/int-uint.md)。 -- `hashnum` — 用于计算结果的最小和最大哈希的数量。可选。可能的值:从 `1` 到 `25` 的任意数字。默认值:`6`。 [UInt8](../data-types/int-uint.md)。 +- `string` — 要计算散列的字符串。 [`String`](/sql-reference/data-types/string) +- `shinglesize` — 可选。单词 shingles 的大小,范围从 `1` 到 `25` 的任何数字。默认值为 `3`。 [`UInt8`](/sql-reference/data-types/int-uint) +- `hashnum` — 可选。用于计算结果的最小和最大散列的数量,范围从 `1` 到 `25` 的任何数字。默认值为 `6`。 [`UInt8`](/sql-reference/data-types/int-uint) + **返回值** -- 包含两个元组的元组,每个元组包含 `hashnum` 个 n-grams。 [Tuple](../data-types/tuple.md)([Tuple](../data-types/tuple.md)([String](../data-types/string.md)), [Tuple](../data-types/tuple.md)([String](../data-types/string.md)))。 +返回包含两个元组的元组,每个元组具有 `hashnum` 个单词 shingles。 [`Tuple(Tuple(String))`](/sql-reference/data-types/tuple) **示例** -查询: +**用法示例** -```sql -SELECT ngramMinHashArgUTF8('ClickHouse') AS Tuple; +```sql title=Query +SELECT wordShingleMinHashArgCaseInsensitiveUTF8('ClickHouse® is a column-oriented database management system (DBMS) for online analytical processing of queries (OLAP).', 1, 3) AS Tuple; ``` -结果: - -```response -┌─Tuple─────────────────────────────────────────────────────────────────────────┐ -│ (('ous','ick','lic','Hou','kHo','use'),('kHo','Hou','lic','ick','ous','ckH')) │ -└───────────────────────────────────────────────────────────────────────────────┘ +```response title=Response +┌─Tuple──────────────────────────────────────────────────────────────────┐ +│ (('queries','database','analytical'),('oriented','processing','DBMS')) │ +└────────────────────────────────────────────────────────────────────────┘ ``` -## ngramMinHashArgCaseInsensitiveUTF8 {#ngramminhashargcaseinsensitiveutf8} +## wordShingleMinHashArgUTF8 {#wordShingleMinHashArgUTF8} + +引入于:v21.1 + + +将 UTF-8 字符串拆分为 `shinglesize` 个单词的部分(shingles),并返回具有最小和最大单词散列的 shingles,这些散列是通过 [`wordShingleMinHashUTF8`](#wordShingleMinHashUTF8) 函数计算的。 +此功能对大小写敏感。 -将 UTF-8 字符串拆分为 `ngramsize` 符号的 n-grams,并返回通过相同输入计算的 [ngramMinHashCaseInsensitiveUTF8](#ngramminhashcaseinsensitiveutf8) 函数得到的具有最小和最大哈希的 n-grams。区分大小写。 **语法** ```sql -ngramMinHashArgCaseInsensitiveUTF8(string[, ngramsize, hashnum]) +wordShingleMinHashArgUTF8(string[, shinglesize, hashnum]) ``` **参数** -- `string` — 字符串。 [String](../data-types/string.md)。 -- `ngramsize` — n-gram 的大小。可选。可能的值:从 `1` 到 `25` 的任意数字。默认值:`3`。 [UInt8](../data-types/int-uint.md)。 -- `hashnum` — 用于计算结果的最小和最大哈希的数量。可选。可能的值:从 `1` 到 `25` 的任意数字。默认值:`6`。 [UInt8](../data-types/int-uint.md)。 +- `string` — 要计算散列的字符串。 [`String`](/sql-reference/data-types/string) +- `shinglesize` — 可选。单词 shingles 的大小,范围从 `1` 到 `25` 的任何数字。默认值为 `3`。 [`UInt8`](/sql-reference/data-types/int-uint) +- `hashnum` — 可选。用于计算结果的最小和最大散列的数量,范围从 `1` 到 `25` 的任何数字。默认值为 `6`。 [`UInt8`](/sql-reference/data-types/int-uint) + **返回值** -- 包含两个元组的元组,每个元组包含 `hashnum` 个 n-grams。 [Tuple](../data-types/tuple.md)([Tuple](../data-types/tuple.md)([String](../data-types/string.md)), [Tuple](../data-types/tuple.md)([String](../data-types/string.md)))。 +返回包含两个元组的元组,每个元组具有 `hashnum` 个单词 shingles。 [`Tuple(Tuple(String))`](/sql-reference/data-types/tuple) **示例** -查询: +**用法示例** -```sql -SELECT ngramMinHashArgCaseInsensitiveUTF8('ClickHouse') AS Tuple; +```sql title=Query +SELECT wordShingleMinHashArgUTF8('ClickHouse® is a column-oriented database management system (DBMS) for online analytical processing of queries (OLAP).', 1, 3) AS Tuple; ``` -结果: - -```response -┌─Tuple─────────────────────────────────────────────────────────────────────────┐ -│ (('ckH','ous','ick','lic','kHo','use'),('kHo','lic','ick','ous','ckH','Hou')) │ -└───────────────────────────────────────────────────────────────────────────────┘ +```response title=Response +┌─Tuple─────────────────────────────────────────────────────────────────┐ +│ (('OLAP','database','analytical'),('online','oriented','processing')) │ +└───────────────────────────────────────────────────────────────────────┘ ``` -## wordShingleMinHash {#wordshingleminhash} +## wordShingleMinHashCaseInsensitive {#wordShingleMinHashCaseInsensitive} + +引入于:v21.1 + + +将 ASCII 字符串拆分为 `shinglesize` 个单词的部分(shingles),计算每个单词 shingles 的散列值,并返回包含这些散列的元组。 +使用 `hashnum` 个最小散列来计算最小散列,使用 `hashnum` 个最大散列来计算最大散列。 +此功能对大小写不敏感。 -将 ASCII 字符串拆分为 `shinglesize` 个单词的部分(shingles),并计算每个单词 shingle 的哈希值。使用 `hashnum` 最小哈希计算最小哈希,并使用 `hashnum` 最大哈希计算最大哈希。返回一个包含这些哈希的元组。区分大小写。 +可以与 [`tupleHammingDistance`](../functions/tuple-functions.md/#tuplehammingdistance) 一起使用来检测半重复字符串。 +对于两个字符串,如果返回的散列对两个字符串都是相同的,则这两个字符串是相同的。 -可用于检测半重复字符串,结合使用 [tupleHammingDistance](../functions/tuple-functions.md/#tuplehammingdistance)。对于两个字符串:如果返回的哈希值之一在这两个字符串中相同,我们认为这两个字符串是相同的。 **语法** ```sql -wordShingleMinHash(string[, shinglesize, hashnum]) +wordShingleMinHashCaseInsensitive(string[, shinglesize, hashnum]) ``` **参数** -- `string` — 字符串。 [String](../data-types/string.md)。 -- `shinglesize` — 单词 shingle 的大小。可选。可能的值:从 `1` 到 `25` 的任意数字。默认值:`3`。 [UInt8](../data-types/int-uint.md)。 -- `hashnum` — 用于计算结果的最小和最大哈希的数量。可选。可能的值:从 `1` 到 `25` 的任意数字。默认值:`6`。 [UInt8](../data-types/int-uint.md)。 +- `string` — 要计算散列的字符串。 [`String`](/sql-reference/data-types/string) +- `shinglesize` — 可选。单词 shingles 的大小,范围从 `1` 到 `25` 的任何数字。默认值为 `3`。 [`UInt8`](/sql-reference/data-types/int-uint) +- `hashnum` — 可选。用于计算结果的最小和最大散列的数量,范围从 `1` 到 `25` 的任何数字。默认值为 `6`。 [`UInt8`](/sql-reference/data-types/int-uint) + **返回值** -- 包含两个哈希的元组 — 最小和最大哈希。 [Tuple](../data-types/tuple.md)([UInt64](../data-types/int-uint.md), [UInt64](../data-types/int-uint.md))。 +返回包含两个散列的元组 — 最小值和最大值。 [`Tuple(UInt64, UInt64)`](/sql-reference/data-types/tuple) **示例** -查询: +**用法示例** -```sql -SELECT wordShingleMinHash('ClickHouse® is a column-oriented database management system (DBMS) for online analytical processing of queries (OLAP).') AS Tuple; +```sql title=Query +SELECT wordShingleMinHashCaseInsensitive('ClickHouse® is a column-oriented database management system (DBMS) for online analytical processing of queries (OLAP).') AS Tuple; ``` -结果: - -```response -┌─Tuple──────────────────────────────────────┐ -│ (16452112859864147620,5844417301642981317) │ -└────────────────────────────────────────────┘ +```response title=Response +┌─Tuple─────────────────────────────────────┐ +│ (3065874883688416519,1634050779997673240) │ +└───────────────────────────────────────────┘ ``` -## wordShingleMinHashCaseInsensitive {#wordshingleminhashcaseinsensitive} +## wordShingleMinHashCaseInsensitiveUTF8 {#wordShingleMinHashCaseInsensitiveUTF8} + +引入于:v21.1 + + +将 UTF-8 字符串拆分为 `shinglesize` 个单词的部分(shingles),计算每个单词 shingles 的散列值,并返回包含这些散列的元组。 +使用 `hashnum` 个最小散列来计算最小散列,使用 `hashnum` 个最大散列来计算最大散列。 +此功能对大小写不敏感。 -将 ASCII 字符串拆分为 `shinglesize` 个单词的部分(shingles),并计算每个单词 shingle 的哈希值。使用 `hashnum` 最小哈希计算最小哈希,并使用 `hashnum` 最大哈希计算最大哈希。返回一个包含这些哈希的元组。区分大小写。 +可以与 [`tupleHammingDistance`](../functions/tuple-functions.md/#tuplehammingdistance) 一起使用来检测半重复字符串。 +对于两个字符串,如果返回的散列对两个字符串都是相同的,则这两个字符串是相同的。 -可用于检测半重复字符串,结合使用 [tupleHammingDistance](../functions/tuple-functions.md/#tuplehammingdistance)。对于两个字符串:如果返回的哈希值之一在这两个字符串中相同,我们认为这两个字符串是相同的。 **语法** ```sql -wordShingleMinHashCaseInsensitive(string[, shinglesize, hashnum]) +wordShingleMinHashCaseInsensitiveUTF8(string[, shinglesize, hashnum]) ``` **参数** -- `string` — 字符串。 [String](../data-types/string.md)。 -- `shinglesize` — 单词 shingle 的大小。可选。可能的值:从 `1` 到 `25` 的任意数字。默认值:`3`。 [UInt8](../data-types/int-uint.md)。 -- `hashnum` — 用于计算结果的最小和最大哈希的数量。可选。可能的值:从 `1` 到 `25` 的任意数字。默认值:`6`。 [UInt8](../data-types/int-uint.md)。 +- `string` — 要计算散列的字符串。 [`String`](/sql-reference/data-types/string) +- `shinglesize` — 可选。单词 shingles 的大小,范围从 `1` 到 `25` 的任何数字。默认值为 `3`。 [`UInt8`](/sql-reference/data-types/int-uint) +- `hashnum` — 可选。用于计算结果的最小和最大散列的数量,范围从 `1` 到 `25` 的任何数字。默认值为 `6`。 [`UInt8`](/sql-reference/data-types/int-uint) + **返回值** -- 包含两个哈希的元组 — 最小和最大哈希。 [Tuple](../data-types/tuple.md)([UInt64](../data-types/int-uint.md), [UInt64](../data-types/int-uint.md))。 +返回包含两个散列的元组 — 最小值和最大值。 [`Tuple(UInt64, UInt64)`](/sql-reference/data-types/tuple) **示例** -查询: +**用法示例** -```sql -SELECT wordShingleMinHashCaseInsensitive('ClickHouse® is a column-oriented database management system (DBMS) for online analytical processing of queries (OLAP).') AS Tuple; +```sql title=Query +SELECT wordShingleMinHashCaseInsensitiveUTF8('ClickHouse® is a column-oriented database management system (DBMS) for online analytical processing of queries (OLAP).') AS Tuple; ``` -结果: - -```response +```response title=Response ┌─Tuple─────────────────────────────────────┐ │ (3065874883688416519,1634050779997673240) │ └───────────────────────────────────────────┘ ``` -## wordShingleMinHashUTF8 {#wordshingleminhashutf8} +## wordShingleMinHashUTF8 {#wordShingleMinHashUTF8} + +引入于:v21.1 -将 UTF-8 字符串拆分为 `shinglesize` 个单词的部分(shingles),并计算每个单词 shingle 的哈希值。使用 `hashnum` 最小哈希计算最小哈希,并使用 `hashnum` 最大哈希计算最大哈希。返回一个包含这些哈希的元组。区分大小写。 -可用于检测半重复字符串,结合使用 [tupleHammingDistance](../functions/tuple-functions.md/#tuplehammingdistance)。对于两个字符串:如果返回的哈希值之一在这两个字符串中相同,我们认为这两个字符串是相同的。 +将 UTF-8 字符串拆分为 `shinglesize` 个单词的部分(shingles),计算每个单词 shingles 的散列值,并返回包含这些散列的元组。 +使用 `hashnum` 个最小散列来计算最小散列,使用 `hashnum` 个最大散列来计算最大散列。 +此功能对大小写敏感。 + +可以与 [`tupleHammingDistance`](../functions/tuple-functions.md/#tuplehammingdistance) 一起使用来检测半重复字符串。 +对于两个字符串,如果返回的散列对两个字符串都是相同的,则这两个字符串是相同的。 + **语法** @@ -1645,310 +2351,331 @@ wordShingleMinHashUTF8(string[, shinglesize, hashnum]) **参数** -- `string` — 字符串。 [String](../data-types/string.md)。 -- `shinglesize` — 单词 shingle 的大小。可选。可能的值:从 `1` 到 `25` 的任意数字。默认值:`3`。 [UInt8](../data-types/int-uint.md)。 -- `hashnum` — 用于计算结果的最小和最大哈希的数量。可选。可能的值:从 `1` 到 `25` 的任意数字。默认值:`6`。 [UInt8](../data-types/int-uint.md)。 +- `string` — 要计算散列的字符串。 [`String`](/sql-reference/data-types/string) +- `shinglesize` — 可选。单词 shingles 的大小,范围从 `1` 到 `25` 的任何数字。默认值为 `3`。 [`UInt8`](/sql-reference/data-types/int-uint) +- `hashnum` — 可选。用于计算结果的最小和最大散列的数量,范围从 `1` 到 `25` 的任何数字。默认值为 `6`。 [`UInt8`](/sql-reference/data-types/int-uint) + **返回值** -- 包含两个哈希的元组 — 最小和最大哈希。 [Tuple](../data-types/tuple.md)([UInt64](../data-types/int-uint.md), [UInt64](../data-types/int-uint.md))。 +返回包含两个散列的元组 — 最小值和最大值。 [`Tuple(UInt64, UInt64)`](/sql-reference/data-types/tuple) **示例** -查询: +**用法示例** -```sql +```sql title=Query SELECT wordShingleMinHashUTF8('ClickHouse® is a column-oriented database management system (DBMS) for online analytical processing of queries (OLAP).') AS Tuple; ``` -结果: - -```response +```response title=Response ┌─Tuple──────────────────────────────────────┐ │ (16452112859864147620,5844417301642981317) │ └────────────────────────────────────────────┘ ``` -## wordShingleMinHashCaseInsensitiveUTF8 {#wordshingleminhashcaseinsensitiveutf8} +## wordShingleSimHash {#wordShingleSimHash} + +引入于:v21.1 + + +将 ASCII 字符串拆分为 `shinglesize` 个单词的部分(shingles),并返回单词 shingles 的 `simhash`。 +此功能对大小写敏感。 -将 UTF-8 字符串拆分为 `shinglesize` 个单词的部分(shingles),并计算每个单词 shingle 的哈希值。使用 `hashnum` 最小哈希计算最小哈希,并使用 `hashnum` 最大哈希计算最大哈希。返回一个包含这些哈希的元组。区分大小写。 +可以与 [`bitHammingDistance`](../functions/bit-functions.md/#bitHammingDistance) 一起使用来检测半重复字符串。 +计算出的两个字符串的 `simhash` 之间的 [汉明距离](https://en.wikipedia.org/wiki/Hamming_distance) 越小,这两个字符串相同的可能性就越大。 -可用于检测半重复字符串,结合使用 [tupleHammingDistance](../functions/tuple-functions.md/#tuplehammingdistance)。对于两个字符串:如果返回的哈希值之一在这两个字符串中相同,我们认为这两个字符串是相同的。 **语法** ```sql -wordShingleMinHashCaseInsensitiveUTF8(string[, shinglesize, hashnum]) +wordShingleSimHash(string[, shinglesize]) ``` **参数** -- `string` — 字符串。 [String](../data-types/string.md)。 -- `shinglesize` — 单词 shingle 的大小。可选。可能的值:从 `1` 到 `25` 的任意数字。默认值:`3`。 [UInt8](../data-types/int-uint.md)。 -- `hashnum` — 用于计算结果的最小和最大哈希的数量。可选。可能的值:从 `1` 到 `25` 的任意数字。默认值:`6`。 [UInt8](../data-types/int-uint.md)。 +- `string` — 要计算散列的字符串。 [`String`](/sql-reference/data-types/string) +- `shinglesize` — 可选。单词 shingles 的大小,范围从 `1` 到 `25` 的任何数字。默认值为 `3`。 [`UInt8`](/sql-reference/data-types/int-uint) + **返回值** -- 包含两个哈希的元组 — 最小和最大哈希。 [Tuple](../data-types/tuple.md)([UInt64](../data-types/int-uint.md), [UInt64](../data-types/int-uint.md))。 +返回计算出的散列值。 [`UInt64`](/sql-reference/data-types/int-uint) **示例** -查询: +**用法示例** -```sql -SELECT wordShingleMinHashCaseInsensitiveUTF8('ClickHouse® is a column-oriented database management system (DBMS) for online analytical processing of queries (OLAP).') AS Tuple; +```sql title=Query +SELECT wordShingleSimHash('ClickHouse® is a column-oriented database management system (DBMS) for online analytical processing of queries (OLAP).') AS Hash; ``` -结果: - -```response -┌─Tuple─────────────────────────────────────┐ -│ (3065874883688416519,1634050779997673240) │ -└───────────────────────────────────────────┘ +```response title=Response +┌───────Hash─┐ +│ 2328277067 │ +└────────────┘ ``` -## wordShingleMinHashArg {#wordshingleminhasharg} +## wordShingleSimHashCaseInsensitive {#wordShingleSimHashCaseInsensitive} + +引入于:v21.1 + + +将 ASCII 字符串拆分为 `shinglesize` 个单词的部分(shingles),并返回单词 shingles 的 `simhash`。 +此功能对大小写不敏感。 + +可以与 [`bitHammingDistance`](../functions/bit-functions.md/#bitHammingDistance) 一起使用来检测半重复字符串。 +计算出的两个字符串的 `simhash` 之间的 [汉明距离](https://en.wikipedia.org/wiki/Hamming_distance) 越小,这两个字符串相同的可能性就越大。 -将 ASCII 字符串拆分为 `shinglesize` 个单词部分(shingles),并返回通过相同输入计算的 [wordshingleMinHash](#wordshingleminhash) 函数得到的具有最小和最大单词哈希的 shingles。区分大小写。 **语法** ```sql -wordShingleMinHashArg(string[, shinglesize, hashnum]) +wordShingleSimHashCaseInsensitive(string[, shinglesize]) ``` **参数** -- `string` — 字符串。 [String](../data-types/string.md)。 -- `shinglesize` — 单词 shingle 的大小。可选。可能的值:从 `1` 到 `25` 的任意数字。默认值:`3`。 [UInt8](../data-types/int-uint.md)。 -- `hashnum` — 用于计算结果的最小和最大哈希的数量。可选。可能的值:从 `1` 到 `25` 的任意数字。默认值:`6`。 [UInt8](../data-types/int-uint.md)。 +- `string` — 要计算散列的字符串。 [`String`](/sql-reference/data-types/string) +- `shinglesize` — 可选。单词 shingles 的大小,范围从 `1` 到 `25` 的任何数字。默认值为 `3`。 [`UInt8`](/sql-reference/data-types/int-uint) + **返回值** -- 包含两个元组的元组,每个元组包含 `hashnum` 个单词 shingles。 [Tuple](../data-types/tuple.md)([Tuple](../data-types/tuple.md)([String](../data-types/string.md)), [Tuple](../data-types/tuple.md)([String](../data-types/string.md)))。 +返回计算出的散列值。 [`UInt64`](/sql-reference/data-types/int-uint) **示例** -查询: +**用法示例** -```sql -SELECT wordShingleMinHashArg('ClickHouse® is a column-oriented database management system (DBMS) for online analytical processing of queries (OLAP).', 1, 3) AS Tuple; +```sql title=Query +SELECT wordShingleSimHashCaseInsensitive('ClickHouse® is a column-oriented database management system (DBMS) for online analytical processing of queries (OLAP).') AS Hash; ``` -结果: - -```response -┌─Tuple─────────────────────────────────────────────────────────────────┐ -│ (('OLAP','database','analytical'),('online','oriented','processing')) │ -└───────────────────────────────────────────────────────────────────────┘ +```response title=Response +┌───────Hash─┐ +│ 2194812424 │ +└────────────┘ ``` -## wordShingleMinHashArgCaseInsensitive {#wordshingleminhashargcaseinsensitive} +## wordShingleSimHashCaseInsensitiveUTF8 {#wordShingleSimHashCaseInsensitiveUTF8} + +引入于:v1.1 + + +将 UTF-8 编码的字符串拆分为 `shinglesize` 个单词的部分(shingles),并返回单词 shingles 的 `simhash`。 +此功能对大小写不敏感。 + +可以与 [`bitHammingDistance`](../functions/bit-functions.md/#bitHammingDistance) 一起使用来检测半重复字符串。 +计算出的两个字符串的 `simhash` 之间的 [汉明距离](https://en.wikipedia.org/wiki/Hamming_distance) 越小,这两个字符串相同的可能性就越大。 -将 ASCII 字符串拆分为 `shinglesize` 个单词部分(shingles),并返回通过相同输入计算的 [wordShingleMinHashCaseInsensitive](#wordshingleminhashcaseinsensitive) 函数得到的具有最小和最大单词哈希的 shingles。区分大小写。 **语法** ```sql -wordShingleMinHashArgCaseInsensitive(string[, shinglesize, hashnum]) +wordShingleSimHashCaseInsensitiveUTF8(string[, shinglesize]) ``` **参数** -- `string` — 字符串。 [String](../data-types/string.md)。 -- `shinglesize` — 单词 shingle 的大小。可选。可能的值:从 `1` 到 `25` 的任意数字。默认值:`3`。 [UInt8](../data-types/int-uint.md)。 -- `hashnum` — 用于计算结果的最小和最大哈希的数量。可选。可能的值:从 `1` 到 `25` 的任意数字。默认值:`6`。 [UInt8](../data-types/int-uint.md)。 +- `string` — 要计算散列的字符串。 [`String`](/sql-reference/data-types/string) +- `shinglesize` — 可选。单词 shingles 的大小,范围从 `1` 到 `25` 的任何数字。默认值为 `3`。 [`UInt8`](/sql-reference/data-types/int-uint) + **返回值** -- 包含两个元组的元组,每个元组包含 `hashnum` 个单词 shingles。 [Tuple](../data-types/tuple.md)([Tuple](../data-types/tuple.md)([String](../data-types/string.md)), [Tuple](../data-types/tuple.md)([String](../data-types/string.md)))。 +返回计算出的散列值。 [`UInt64`](/sql-reference/data-types/int-uint) **示例** -查询: +**用法示例** -```sql -SELECT wordShingleMinHashArgCaseInsensitive('ClickHouse® is a column-oriented database management system (DBMS) for online analytical processing of queries (OLAP).', 1, 3) AS Tuple; +```sql title=Query +SELECT wordShingleSimHashCaseInsensitiveUTF8('ClickHouse® is a column-oriented database management system (DBMS) for online analytical processing of queries (OLAP).') AS Hash; ``` -结果: - -```response -┌─Tuple──────────────────────────────────────────────────────────────────┐ -│ (('queries','database','analytical'),('oriented','processing','DBMS')) │ -└────────────────────────────────────────────────────────────────────────┘ +```response title=Response +┌───────Hash─┐ +│ 2194812424 │ +└────────────┘ ``` -## wordShingleMinHashArgUTF8 {#wordshingleminhashargutf8} +## wordShingleSimHashUTF8 {#wordShingleSimHashUTF8} + +引入于:v21.1 + + +将 UTF-8 字符串拆分为 `shinglesize` 个单词的部分(shingles),并返回单词 shingles 的 `simhash`。 +此功能对大小写敏感。 + +可以与 [`bitHammingDistance`](../functions/bit-functions.md/#bitHammingDistance) 一起使用来检测半重复字符串。 +计算出的两个字符串的 `simhash` 之间的 [汉明距离](https://en.wikipedia.org/wiki/Hamming_distance) 越小,这两个字符串相同的可能性就越大。 -将 UTF-8 字符串拆分为 `shinglesize` 个单词部分(shingles),并返回通过相同输入计算的 [wordShingleMinHashUTF8](#wordshingleminhashutf8) 函数得到的具有最小和最大单词哈希的 shingles。区分大小写。 **语法** ```sql -wordShingleMinHashArgUTF8(string[, shinglesize, hashnum]) +wordShingleSimHashUTF8(string[, shinglesize]) ``` **参数** -- `string` — 字符串。 [String](../data-types/string.md)。 -- `shinglesize` — 单词 shingle 的大小。可选。可能的值:从 `1` 到 `25` 的任意数字。默认值:`3`。 [UInt8](../data-types/int-uint.md)。 -- `hashnum` — 用于计算结果的最小和最大哈希的数量。可选。可能的值:从 `1` 到 `25` 的任意数字。默认值:`6`。 [UInt8](../data-types/int-uint.md)。 +- `string` — 要计算散列的字符串。 [`String`](/sql-reference/data-types/string) +- `shinglesize` — 可选。单词 shingles 的大小,范围从 `1` 到 `25` 的任何数字。默认值为 `3`。 [`UInt8`](/sql-reference/data-types/int-uint) + **返回值** -- 包含两个元组的元组,每个元组包含 `hashnum` 个单词 shingles。 [Tuple](../data-types/tuple.md)([Tuple](../data-types/tuple.md)([String](../data-types/string.md)), [Tuple](../data-types/tuple.md)([String](../data-types/string.md)))。 +返回计算出的散列值。 [`UInt64`](/sql-reference/data-types/int-uint) **示例** -查询: +**用法示例** -```sql -SELECT wordShingleMinHashArgUTF8('ClickHouse® is a column-oriented database management system (DBMS) for online analytical processing of queries (OLAP).', 1, 3) AS Tuple; +```sql title=Query +SELECT wordShingleSimHashUTF8('ClickHouse® is a column-oriented database management system (DBMS) for online analytical processing of queries (OLAP).') AS Hash; ``` -结果: - -```response -┌─Tuple─────────────────────────────────────────────────────────────────┐ -│ (('OLAP','database','analytical'),('online','oriented','processing')) │ -└───────────────────────────────────────────────────────────────────────┘ +```response title=Response +┌───────Hash─┐ +│ 2328277067 │ +└────────────┘ ``` -## wordShingleMinHashArgCaseInsensitiveUTF8 {#wordshingleminhashargcaseinsensitiveutf8} +## wyHash64 {#wyHash64} -将 UTF-8 字符串拆分为 `shinglesize` 个单词部分(shingles),并返回通过相同输入计算的 [wordShingleMinHashCaseInsensitiveUTF8](#wordshingleminhashcaseinsensitiveutf8) 函数得到的具有最小和最大单词哈希的 shingles。区分大小写。 +引入于:v22.7 + +计算 64 位 [wyHash64](https://github.com/wangyi-fudan/wyhash) 散列值。 **语法** ```sql -wordShingleMinHashArgCaseInsensitiveUTF8(string[, shinglesize, hashnum]) +wyHash64(arg) ``` **参数** -- `string` — 字符串。 [String](../data-types/string.md)。 -- `shinglesize` — 单词 shingle 的大小。可选。可能的值:从 `1` 到 `25` 的任意数字。默认值:`3`。 [UInt8](../data-types/int-uint.md)。 -- `hashnum` — 用于计算结果的最小和最大哈希的数量。可选。可能的值:从 `1` 到 `25` 的任意数字。默认值:`6`。 [UInt8](../data-types/int-uint.md)。 +- `arg` — 要计算散列的字符串参数。 [`String`](/sql-reference/data-types/string) + **返回值** -- 包含两个元组的元组,每个元组包含 `hashnum` 个单词 shingles。 [Tuple](../data-types/tuple.md)([Tuple](../data-types/tuple.md)([String](../data-types/string.md)), [Tuple](../data-types/tuple.md)([String](../data-types/string.md)))。 +返回计算出的 64 位散列值 [`UInt64`](/sql-reference/data-types/int-uint) **示例** -查询: +**用法示例** -```sql -SELECT wordShingleMinHashArgCaseInsensitiveUTF8('ClickHouse® is a column-oriented database management system (DBMS) for online analytical processing of queries (OLAP).', 1, 3) AS Tuple; +```sql title=Query +SELECT wyHash64('ClickHouse') AS Hash; ``` -结果: - -```response -┌─Tuple──────────────────────────────────────────────────────────────────┐ -│ (('queries','database','analytical'),('oriented','processing','DBMS')) │ -└────────────────────────────────────────────────────────────────────────┘ +```response title=Response +12336419557878201794 ``` -## sqidEncode {#sqidencode} +## xxHash32 {#xxHash32} + +引入于:v20.1 + + +从字符串计算 [xxHash](http://cyan4973.github.io/xxHash/)。 + +有关 64 位版本,请参见 [`xxHash64`](#xxHash64) -将数字编码为 [Sqid](https://sqids.org/),即类似 YouTube 的 ID 字符串。 -输出字母表为 `abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789`。 -请勿将此函数用于哈希 - 生成的 ID 可以解码回原始数字。 **语法** ```sql -sqidEncode(number1, ...) +xxHash32(arg) ``` -别名:`sqid` - **参数** -- 任意数量的 UInt8、UInt16、UInt32 或 UInt64 数字。 +- `arg` — 输入字符串进行哈希。 [`String`](/sql-reference/data-types/string) + **返回值** -一个 sqid [String](../data-types/string.md)。 +返回计算出的输入字符串的 32 位散列。 [`UInt32`](/sql-reference/data-types/int-uint) **示例** -```sql -SELECT sqidEncode(1, 2, 3, 4, 5); +**用法示例** + +```sql title=Query +SELECT xxHash32('Hello, world!'); ``` -```response -┌─sqidEncode(1, 2, 3, 4, 5)─┐ -│ gXHfJ1C6dN │ +```response title=Response +┌─xxHash32('Hello, world!')─┐ +│ 834093149 │ └───────────────────────────┘ ``` -## sqidDecode {#sqiddecode} +## xxHash64 {#xxHash64} + +引入于:v20.1 + + +从字符串计算 [xxHash](http://cyan4973.github.io/xxHash/)。 + +有关 32 位版本,请参见 [`xxHash32`](#xxHash32) -将 [Sqid](https://sqids.org/) 解码回其原始数字。 -如果输入字符串不是有效的 sqid,则返回一个空数组。 **语法** ```sql -sqidDecode(sqid) +xxHash64(arg) ``` **参数** -- 一个 sqid - [String](../data-types/string.md) +- `arg` — 输入字符串进行哈希。 [`String`](/sql-reference/data-types/string) + **返回值** -将 sqid 转换为数字 [Array(UInt64)](../data-types/array.md)。 +返回计算出的输入字符串的 64 位散列。 [`UInt64`](/sql-reference/data-types/int-uint) **示例** -```sql -SELECT sqidDecode('gXHfJ1C6dN'); +**用法示例** + +```sql title=Query +SELECT xxHash64('Hello, world!'); ``` -```response -┌─sqidDecode('gXHfJ1C6dN')─┐ -│ [1,2,3,4,5] │ -└──────────────────────────┘ +```response title=Response +┌─xxHash64('Hello, world!')─┐ +│ 17691043854468224118 │ +└───────────────────────────┘ ``` -## keccak256 {#keccak256} +## xxh3 {#xxh3} -计算 Keccak-256 哈希字符串,并将结果字节集作为 [FixedString](../data-types/fixedstring.md) 返回。 +引入于:v22.12 + +计算 [XXH3](https://github.com/Cyan4973/xxHash) 64 位散列值。 **语法** ```sql -keccak256('s') +xxh3(expr) ``` -此加密哈希函数在 [EVM-based blockchains](https://ethereum.github.io/yellowpaper/paper.pdf) 中被广泛使用。 - **参数** -- s - 用于 Keccak-256 哈希计算的输入字符串。 [String](../data-types/string.md)。 +- `expr` — 任意数据类型的表达式列表。 [`Any`](/sql-reference/data-types) + **返回值** -- Keccak-256 哈希作为 FixedString(32) 类型的字节数组。 [FixedString](../data-types/fixedstring.md)。 +返回计算的 64 位 `xxh3` 散列值 [`UInt64`](/sql-reference/data-types/int-uint) **示例** -使用函数 [hex](../functions/encoding-functions.md/#hex) 将结果格式化为十六进制编码字符串。 +**用法示例** -查询: -```sql -select hex(keccak256('hello')) +```sql title=Query +SELECT xxh3('ClickHouse') ``` -结果: -```sql - ┌─hex(keccak256('hello'))──────────────────────────────────────────┐ -1. │ 1C8AFF950685C2ED4BC3174F3472287B56D9517B9C948127319A09A7A36DEAC8 │ - └──────────────────────────────────────────────────────────────────┘ +```response title=Response +18009318874338624809 ``` - - - diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/hash-functions.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/hash-functions.md.hash index 9dfba5d9e18..99012216b88 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/hash-functions.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/hash-functions.md.hash @@ -1 +1 @@ -bf57d17943cce0fa +aaf8985f957e016f diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/in-functions.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/in-functions.md index 484154aa7fc..9846b5441d2 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/in-functions.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/in-functions.md @@ -1,14 +1,14 @@ --- -'description': '关于实现 IN 操作符的函数的文档' +'description': '关于实现 IN 运算符的函数的文档' 'sidebar_label': 'IN Operator' -'sidebar_position': 90 'slug': '/sql-reference/functions/in-functions' -'title': '实现 IN 操作符的函数' +'title': '实现 IN 运算符的函数' +'doc_type': 'reference' --- -# 实现 IN 操作符的函数 +# 实现 IN 运算符的函数 ## in, notIn, globalIn, globalNotIn {#in-notin-globalin-globalnotin} -请参见 [IN 操作符](/sql-reference/operators/in) 部分。 +请参见[IN 运算符](/sql-reference/operators/in)一节。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/in-functions.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/in-functions.md.hash index 6b9ee71007f..ac913d76d9a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/in-functions.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/in-functions.md.hash @@ -1 +1 @@ -1f9560a402916995 +735c967b65cf6f2a diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/index.md index f1ae43fab12..d0abc2a1a71 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/index.md @@ -3,11 +3,12 @@ 'sidebar': 'sqlreference' 'slug': '/sql-reference/functions' 'title': 'Functions 的登录页面' +'doc_type': 'landing-page' --- -| 页面 | 描述 | -|---------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------| -| [常规函数](/sql-reference/functions/regular-functions) | 其结果对每一行是独立于所有其他行的函数。 | -| [聚合函数](/sql-reference/aggregate-functions) | 在行之间累积一组值的函数。 | -| [表函数](/sql-reference/aggregate-functions) | 用于构造表的方法。 | -| [窗口函数](/sql-reference/window-functions) | 允许您在与当前行相关的一组行上执行计算的函数。 | +| 页面 | 描述 | +|---------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------| +| [常规函数](/sql-reference/functions/regular-functions) | 对于每一行,其结果独立于所有其他行的函数。 | +| [聚合函数](/sql-reference/aggregate-functions) | 在行之间累积一组值的函数。 | +| [表函数](/sql-reference/table-functions) | 构建表的方法。 | +| [窗口函数](/sql-reference/window-functions) | 允许您在与当前行相关的一组行上执行计算的函数。 | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/index.md.hash index 6cc6ef6625d..4fbd69f7b48 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/index.md.hash @@ -1 +1 @@ -8209c8cb32f27791 +5e8eb4e3cfcb40b6 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/introspection.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/introspection.md index 661ad210205..08129030f59 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/introspection.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/introspection.md @@ -1,254 +1,71 @@ --- -'description': 'Documentation for Introspection Functions' -'sidebar_label': '内省' -'sidebar_position': 100 +'description': 'Introspection Functions 的文档' +'sidebar_label': '自省' 'slug': '/sql-reference/functions/introspection' -'title': '内省函数' +'title': '自省函数' +'doc_type': 'reference' --- -# 自省函数 +# 反射函数 -您可以使用本章中描述的函数来自省 [ELF](https://en.wikipedia.org/wiki/Executable_and_Linkable_Format) 和 [DWARF](https://en.wikipedia.org/wiki/DWARF) 以进行查询分析。 +您可以使用本章描述的函数来反射 [ELF](https://en.wikipedia.org/wiki/Executable_and_Linkable_Format) 和 [DWARF](https://en.wikipedia.org/wiki/DWARF) 以进行查询分析。 :::note -这些函数速度较慢,并可能存在安全隐患。 +这些函数运行缓慢,可能会带来安全隐患。 ::: -为了使自省函数正常工作: +为了使反射函数正常工作: - 安装 `clickhouse-common-static-dbg` 包。 - 将 [allow_introspection_functions](../../operations/settings/settings.md#allow_introspection_functions) 设置为 1。 - 出于安全原因,自省函数默认情况下被禁用。 + 出于安全原因,反射函数默认情况下是禁用的。 -ClickHouse 将分析报告保存到 [trace_log](/operations/system-tables/trace_log) 系统表中。确保该表和分析器配置正确。 +ClickHouse 将分析器报告保存到 [trace_log](/operations/system-tables/trace_log) 系统表中。请确保该表和分析器已正确配置。 -## addressToLine {#addresstoline} - -将 ClickHouse 服务器进程中的虚拟内存地址转换为 ClickHouse 源代码中的文件名和行号。 - -如果您使用官方 ClickHouse 软件包,则需要安装 `clickhouse-common-static-dbg` 包。 - -**语法** - -```sql -addressToLine(address_of_binary_instruction) -``` - -**参数** - -- `address_of_binary_instruction` ([UInt64](../data-types/int-uint.md)) — 正在运行的进程中的指令地址。 - -**返回值** - -- 源代码文件名和该文件中的行号,用冒号分隔。 - 例如,`/build/obj-x86_64-linux-gnu/../src/Common/ThreadPool.cpp:199`,其中 `199` 是行号。 -- 如果函数找不到调试信息,则返回二进制文件的名称。 -- 如果地址无效,则返回空字符串。 - -类型: [String](../../sql-reference/data-types/string.md)。 - -**示例** - -启用自省函数: - -```sql -SET allow_introspection_functions=1; -``` - -选择 `trace_log` 系统表中的第一条字符串: - -```sql -SELECT * FROM system.trace_log LIMIT 1 \G; -``` - -```text -Row 1: -────── -event_date: 2019-11-19 -event_time: 2019-11-19 18:57:23 -revision: 54429 -timer_type: Real -thread_number: 48 -query_id: 421b6855-1858-45a5-8f37-f383409d6d72 -trace: [140658411141617,94784174532828,94784076370703,94784076372094,94784076361020,94784175007680,140658411116251,140658403895439] -``` - -`trace` 字段包含采样时的堆栈跟踪。 - -获取单个地址的源代码文件名和行号: - -```sql -SELECT addressToLine(94784076370703) \G; -``` - -```text -Row 1: -────── -addressToLine(94784076370703): /build/obj-x86_64-linux-gnu/../src/Common/ThreadPool.cpp:199 -``` - -将该函数应用于整个堆栈跟踪: - -```sql -SELECT - arrayStringConcat(arrayMap(x -> addressToLine(x), trace), '\n') AS trace_source_code_lines -FROM system.trace_log -LIMIT 1 -\G -``` - -[ arrayMap](/sql-reference/functions/array-functions#arraymapfunc-arr1-) 函数允许通过 `addressToLine` 函数处理 `trace` 数组中的每个单独元素。您可以在输出的 `trace_source_code_lines` 列中看到此处理的结果。 + -```text -Row 1: -────── -trace_source_code_lines: /lib/x86_64-linux-gnu/libpthread-2.27.so -/usr/lib/debug/usr/bin/clickhouse -/build/obj-x86_64-linux-gnu/../src/Common/ThreadPool.cpp:199 -/build/obj-x86_64-linux-gnu/../src/Common/ThreadPool.h:155 -/usr/include/c++/9/bits/atomic_base.h:551 -/usr/lib/debug/usr/bin/clickhouse -/lib/x86_64-linux-gnu/libpthread-2.27.so -/build/glibc-OTsEL5/glibc-2.27/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:97 -``` + +## demangle {#demangle} -## addressToLineWithInlines {#addresstolinewithinlines} +引入于:v20.1 -类似于 `addressToLine`,但返回一个包含所有内联函数的数组。因此,它比 `addressToLine` 更慢。 -:::note -如果您使用官方 ClickHouse 软件包,则需要安装 `clickhouse-common-static-dbg` 包。 -::: +将符号转换为 C++ 函数名称。 +该符号通常由函数 `addressToSymbol` 返回。 + **语法** ```sql -addressToLineWithInlines(address_of_binary_instruction) +demangle(symbol) ``` **参数** -- `address_of_binary_instruction` ([UInt64](../data-types/int-uint.md)) — 正在运行的进程中的指令地址。 - -**返回值** - -- 数组的第一个元素是源代码文件名和文件中的行号,用冒号分隔。从第二个元素开始,列出了内联函数的源代码文件名、行号和函数名。如果函数找不到调试信息,则返回一个单元素数组,该元素等于二进制名称;如果地址无效,则返回空数组。[Array(String)](../data-types/array.md)。 - -**示例** - -启用自省函数: - -```sql -SET allow_introspection_functions=1; -``` - -应用该函数到地址。 - -```sql -SELECT addressToLineWithInlines(531055181::UInt64); -``` - -```text -┌─addressToLineWithInlines(CAST('531055181', 'UInt64'))────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ -│ ['./src/Functions/addressToLineWithInlines.cpp:98','./build_normal_debug/./src/Functions/addressToLineWithInlines.cpp:176:DB::(anonymous namespace)::FunctionAddressToLineWithInlines::implCached(unsigned long) const'] │ -└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ -``` - -将该函数应用于整个堆栈跟踪: +- `symbol` — 来自对象文件的符号。 [`String`](/sql-reference/data-types/string) -```sql -SELECT - ta, addressToLineWithInlines(arrayJoin(trace) as ta) -FROM system.trace_log -WHERE - query_id = '5e173544-2020-45de-b645-5deebe2aae54'; -``` - -[ arrayJoin](/sql-reference/functions/array-join) 函数将数组拆分为行。 - -```text -┌────────ta─┬─addressToLineWithInlines(arrayJoin(trace))───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ -│ 365497529 │ ['./build_normal_debug/./contrib/libcxx/include/string_view:252'] │ -│ 365593602 │ ['./build_normal_debug/./src/Common/Dwarf.cpp:191'] │ -│ 365593866 │ ['./build_normal_debug/./src/Common/Dwarf.cpp:0'] │ -│ 365592528 │ ['./build_normal_debug/./src/Common/Dwarf.cpp:0'] │ -│ 365591003 │ ['./build_normal_debug/./src/Common/Dwarf.cpp:477'] │ -│ 365590479 │ ['./build_normal_debug/./src/Common/Dwarf.cpp:442'] │ -│ 365590600 │ ['./build_normal_debug/./src/Common/Dwarf.cpp:457'] │ -│ 365598941 │ ['./build_normal_debug/./src/Common/Dwarf.cpp:0'] │ -│ 365607098 │ ['./build_normal_debug/./src/Common/Dwarf.cpp:0'] │ -│ 365590571 │ ['./build_normal_debug/./src/Common/Dwarf.cpp:451'] │ -│ 365598941 │ ['./build_normal_debug/./src/Common/Dwarf.cpp:0'] │ -│ 365607098 │ ['./build_normal_debug/./src/Common/Dwarf.cpp:0'] │ -│ 365590571 │ ['./build_normal_debug/./src/Common/Dwarf.cpp:451'] │ -│ 365598941 │ ['./build_normal_debug/./src/Common/Dwarf.cpp:0'] │ -│ 365607098 │ ['./build_normal_debug/./src/Common/Dwarf.cpp:0'] │ -│ 365590571 │ ['./build_normal_debug/./src/Common/Dwarf.cpp:451'] │ -│ 365598941 │ ['./build_normal_debug/./src/Common/Dwarf.cpp:0'] │ -│ 365597289 │ ['./build_normal_debug/./src/Common/Dwarf.cpp:807'] │ -│ 365599840 │ ['./build_normal_debug/./src/Common/Dwarf.cpp:1118'] │ -│ 531058145 │ ['./build_normal_debug/./src/Functions/addressToLineWithInlines.cpp:152'] │ -│ 531055181 │ ['./src/Functions/addressToLineWithInlines.cpp:98','./build_normal_debug/./src/Functions/addressToLineWithInlines.cpp:176:DB::(anonymous namespace)::FunctionAddressToLineWithInlines::implCached(unsigned long) const'] │ -│ 422333613 │ ['./build_normal_debug/./src/Functions/IFunctionAdaptors.h:21'] │ -│ 586866022 │ ['./build_normal_debug/./src/Functions/IFunction.cpp:216'] │ -│ 586869053 │ ['./build_normal_debug/./src/Functions/IFunction.cpp:264'] │ -│ 586873237 │ ['./build_normal_debug/./src/Functions/IFunction.cpp:334'] │ -│ 597901620 │ ['./build_normal_debug/./src/Interpreters/ExpressionActions.cpp:601'] │ -│ 597898534 │ ['./build_normal_debug/./src/Interpreters/ExpressionActions.cpp:718'] │ -│ 630442912 │ ['./build_normal_debug/./src/Processors/Transforms/ExpressionTransform.cpp:23'] │ -│ 546354050 │ ['./build_normal_debug/./src/Processors/ISimpleTransform.h:38'] │ -│ 626026993 │ ['./build_normal_debug/./src/Processors/ISimpleTransform.cpp:89'] │ -│ 626294022 │ ['./build_normal_debug/./src/Processors/Executors/ExecutionThreadContext.cpp:45'] │ -│ 626293730 │ ['./build_normal_debug/./src/Processors/Executors/ExecutionThreadContext.cpp:63'] │ -│ 626169525 │ ['./build_normal_debug/./src/Processors/Executors/PipelineExecutor.cpp:213'] │ -│ 626170308 │ ['./build_normal_debug/./src/Processors/Executors/PipelineExecutor.cpp:178'] │ -│ 626166348 │ ['./build_normal_debug/./src/Processors/Executors/PipelineExecutor.cpp:329'] │ -│ 626163461 │ ['./build_normal_debug/./src/Processors/Executors/PipelineExecutor.cpp:84'] │ -│ 626323536 │ ['./build_normal_debug/./src/Processors/Executors/PullingAsyncPipelineExecutor.cpp:85'] │ -│ 626323277 │ ['./build_normal_debug/./src/Processors/Executors/PullingAsyncPipelineExecutor.cpp:112'] │ -│ 626323133 │ ['./build_normal_debug/./contrib/libcxx/include/type_traits:3682'] │ -│ 626323041 │ ['./build_normal_debug/./contrib/libcxx/include/tuple:1415'] │ -└───────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ - -``` - -## addressToSymbol {#addresstosymbol} - -将 ClickHouse 服务器进程中的虚拟内存地址转换为 ClickHouse 对象文件中的符号。 - -**语法** - -```sql -addressToSymbol(address_of_binary_instruction) -``` - -**参数** - -- `address_of_binary_instruction` ([UInt64](../data-types/int-uint.md)) — 正在运行的进程中的指令地址。 **返回值** -- 来自 ClickHouse 对象文件的符号。[String](../data-types/string.md)。 -- 如果地址无效,则返回空字符串。[String](../data-types/string.md)。 +返回 C++ 函数的名称,如果符号无效,则返回空字符串。 [`String`](/sql-reference/data-types/string) **示例** -启用自省函数: +**从 `trace_log` 系统表中选择第一个字符串** -```sql -SET allow_introspection_functions=1; -``` - -选择 `trace_log` 系统表中的第一条字符串: - -```sql +```sql title=Query SELECT * FROM system.trace_log LIMIT 1 \G; ``` -```text +```response title=Response +-- The `trace` field contains the stack trace at the moment of sampling. Row 1: ────── event_date: 2019-11-20 @@ -260,117 +77,27 @@ query_id: 724028bf-f550-45aa-910d-2af6212b94ac trace: [94138803686098,94138815010911,94138815096522,94138815101224,94138815102091,94138814222988,94138806823642,94138814457211,94138806823642,94138814457211,94138806823642,94138806795179,94138806796144,94138753770094,94138753771646,94138753760572,94138852407232,140399185266395,140399178045583] ``` -`trace` 字段包含采样时的堆栈跟踪。 - -获取单个地址的符号: - -```sql -SELECT addressToSymbol(94138803686098) \G; -``` - -```text -Row 1: -────── -addressToSymbol(94138803686098): _ZNK2DB24IAggregateFunctionHelperINS_20AggregateFunctionSumImmNS_24AggregateFunctionSumDataImEEEEE19addBatchSinglePlaceEmPcPPKNS_7IColumnEPNS_5ArenaE -``` - -将该函数应用于整个堆栈跟踪: - -```sql -SELECT - arrayStringConcat(arrayMap(x -> addressToSymbol(x), trace), '\n') AS trace_symbols -FROM system.trace_log -LIMIT 1 -\G -``` - -[ arrayMap](/sql-reference/functions/array-functions#arraymapfunc-arr1-) 函数允许通过 `addressToSymbols` 函数处理 `trace` 数组中的每个单独元素。您可以在输出的 `trace_symbols` 列中看到此处理的结果。 - -```text -Row 1: -────── -trace_symbols: _ZNK2DB24IAggregateFunctionHelperINS_20AggregateFunctionSumImmNS_24AggregateFunctionSumDataImEEEEE19addBatchSinglePlaceEmPcPPKNS_7IColumnEPNS_5ArenaE -_ZNK2DB10Aggregator21executeWithoutKeyImplERPcmPNS0_28AggregateFunctionInstructionEPNS_5ArenaE -_ZN2DB10Aggregator14executeOnBlockESt6vectorIN3COWINS_7IColumnEE13immutable_ptrIS3_EESaIS6_EEmRNS_22AggregatedDataVariantsERS1_IPKS3_SaISC_EERS1_ISE_SaISE_EERb -_ZN2DB10Aggregator14executeOnBlockERKNS_5BlockERNS_22AggregatedDataVariantsERSt6vectorIPKNS_7IColumnESaIS9_EERS6_ISB_SaISB_EERb -_ZN2DB10Aggregator7executeERKSt10shared_ptrINS_17IBlockInputStreamEERNS_22AggregatedDataVariantsE -_ZN2DB27AggregatingBlockInputStream8readImplEv -_ZN2DB17IBlockInputStream4readEv -_ZN2DB26ExpressionBlockInputStream8readImplEv -_ZN2DB17IBlockInputStream4readEv -_ZN2DB26ExpressionBlockInputStream8readImplEv -_ZN2DB17IBlockInputStream4readEv -_ZN2DB28AsynchronousBlockInputStream9calculateEv -_ZNSt17_Function_handlerIFvvEZN2DB28AsynchronousBlockInputStream4nextEvEUlvE_E9_M_invokeERKSt9_Any_data -_ZN14ThreadPoolImplI20ThreadFromGlobalPoolE6workerESt14_List_iteratorIS0_E -_ZZN20ThreadFromGlobalPoolC4IZN14ThreadPoolImplIS_E12scheduleImplIvEET_St8functionIFvvEEiSt8optionalImEEUlvE1_JEEEOS4_DpOT0_ENKUlvE_clEv -_ZN14ThreadPoolImplISt6threadE6workerESt14_List_iteratorIS0_E -execute_native_thread_routine -start_thread -clone -``` - -## demangle {#demangle} - -将您可以通过 [addressToSymbol](#addresstosymbol) 函数获取的符号转换为 C++ 函数名称。 - -**语法** - -```sql -demangle(symbol) -``` - -**参数** - -- `symbol` ([String](../data-types/string.md)) — 来自对象文件的符号。 - -**返回值** - -- C++ 函数的名称,或者如果符号无效则返回空字符串。[String](../data-types/string.md)。 - -**示例** - -启用自省函数: +**获取单个地址的函数名称** -```sql +```sql title=Query SET allow_introspection_functions=1; -``` - -选择 `trace_log` 系统表中的第一条字符串: - -```sql -SELECT * FROM system.trace_log LIMIT 1 \G; -``` - -```text -Row 1: -────── -event_date: 2019-11-20 -event_time: 2019-11-20 16:57:59 -revision: 54429 -timer_type: Real -thread_number: 48 -query_id: 724028bf-f550-45aa-910d-2af6212b94ac -trace: [94138803686098,94138815010911,94138815096522,94138815101224,94138815102091,94138814222988,94138806823642,94138814457211,94138806823642,94138814457211,94138806823642,94138806795179,94138806796144,94138753770094,94138753771646,94138753760572,94138852407232,140399185266395,140399178045583] -``` - -`trace` 字段包含采样时的堆栈跟踪。 - -获取单个地址的函数名称: - -```sql SELECT demangle(addressToSymbol(94138803686098)) \G; ``` -```text +```response title=Response Row 1: ────── demangle(addressToSymbol(94138803686098)): DB::IAggregateFunctionHelper > >::addBatchSinglePlace(unsigned long, char*, DB::IColumn const**, DB::Arena*) const ``` -将该函数应用于整个堆栈跟踪: +**将函数应用于整个堆栈跟踪** + +```sql title=Query +SET allow_introspection_functions=1; + +-- The arrayMap function allows to process each individual element of the trace array by the demangle function. +-- The result of this processing is shown in the trace_functions column of output. -```sql SELECT arrayStringConcat(arrayMap(x -> demangle(addressToSymbol(x)), trace), '\n') AS trace_functions FROM system.trace_log @@ -378,9 +105,7 @@ LIMIT 1 \G ``` -[ arrayMap](/sql-reference/functions/array-functions#arraymapfunc-arr1-) 函数允许通过 `demangle` 函数处理 `trace` 数组中的每个单独元素。您可以在输出的 `trace_functions` 列中看到此处理的结果。 - -```text +```response title=Response Row 1: ────── trace_functions: DB::IAggregateFunctionHelper > >::addBatchSinglePlace(unsigned long, char*, DB::IColumn const**, DB::Arena*) const @@ -404,73 +129,95 @@ start_thread clone ``` -## tid {#tid} -返回当前处理的 [Block](/development/architecture/#block) 的线程 id。 + +## isMergeTreePartCoveredBy {#isMergeTreePartCoveredBy} + +引入于:v25.6 + + +该函数检查第一个参数的部分是否被第二个参数的部分覆盖。 + **语法** ```sql -tid() +isMergeTreePartCoveredBy(nested_part, covering_part) ``` +**参数** + +- `nested_part` — 预期的嵌套部分名称。 [`String`](/sql-reference/data-types/string) +- `covering_part` — 预期的覆盖部分名称。 [`String`](/sql-reference/data-types/string) + + **返回值** -- 当前线程 id。[Uint64](/sql-reference/data-types/int-uint#integer-ranges)。 +如果覆盖返回 `1`,否则返回 `0`。 [`UInt8`](/sql-reference/data-types/int-uint) **示例** -查询: +**基本示例** -```sql -SELECT tid(); +```sql title=Query +WITH 'all_12_25_7_4' AS lhs, 'all_7_100_10_20' AS rhs +SELECT isMergeTreePartCoveredBy(rhs, lhs), isMergeTreePartCoveredBy(lhs, rhs); ``` -结果: - -```text -┌─tid()─┐ -│ 3878 │ -└───────┘ +```response title=Response +┌─isMergeTreePartCoveredBy(rhs, lhs)─┬─isMergeTreePartCoveredBy(lhs, rhs)─┐ +│ 0 │ 1 │ +└────────────────────────────────────┴────────────────────────────────────┘ ``` -## logTrace {#logtrace} -为每个 [Block](/development/architecture/#block) 向服务器日志发出trace日志消息。 + +## logTrace {#logTrace} + +引入于:v20.12 + + +为每个 [Block](/development/architecture/#block) 向服务器日志发出跟踪日志消息。 + **语法** ```sql -logTrace('message') +logTrace(message) ``` **参数** -- `message` — 发往服务器日志的消息。[String](/sql-reference/data-types/string)。 +- `message` — 发出到服务器日志的消息。 [`const String`](/sql-reference/data-types/string) + **返回值** -- 始终返回 0。 +始终返回 `0`。 [`UInt8`](/sql-reference/data-types/int-uint) **示例** -查询: +**基本示例** -```sql +```sql title=Query SELECT logTrace('logTrace message'); ``` -结果: - -```text +```response title=Response ┌─logTrace('logTrace message')─┐ │ 0 │ └──────────────────────────────┘ ``` -## mergeTreePartInfo {#mergetreepartinfo} -函数帮助从 `MergeTree` 部件名称中提取有用值。 + +## mergeTreePartInfo {#mergeTreePartInfo} + +引入于:v25.6 + + +该函数帮助从 `MergeTree` 部分名称中提取有用值。 + **语法** @@ -480,73 +227,65 @@ mergeTreePartInfo(part_name) **参数** -- `part_name` ([String](../data-types/string.md)) — 要解包的部分的名称。 +- `part_name` — 要解包的部分名称。 [`String`](/sql-reference/data-types/string) + **返回值** -- [Tuple](../data-types/tuple.md) 具有子列: - - `partition_id` - - `min_block` - - `max_block` - - `level` - - `mutation` +返回一个元组,其子列包括:`partition_id`,`min_block`,`max_block`,`level`,`mutation`。 [`Tuple`](/sql-reference/data-types/tuple) **示例** -查询: +**基本示例** -```sql -WITH mergeTreePartInfo('all_12_25_7_4') AS info SELECT info.partition_id, info.min_block, info.max_block, info.level, info.mutation; +```sql title=Query +WITH mergeTreePartInfo('all_12_25_7_4') AS info +SELECT info.partition_id, info.min_block, info.max_block, info.level, info.mutation; ``` -结果: - -```text +```response title=Response ┌─info.partition_id─┬─info.min_block─┬─info.max_block─┬─info.level─┬─info.mutation─┐ │ all │ 12 │ 25 │ 7 │ 4 │ └───────────────────┴────────────────┴────────────────┴────────────┴───────────────┘ ``` -## isMergeTreePartCoveredBy {#ismergetreepartcoveredby} -检查第一个参数的部分是否被第二个参数的部分覆盖的函数。 + +## tid {#tid} + +引入于:v20.12 + + +返回当前 [Block](/development/architecture/#block) 正在处理的线程的 ID。 + **语法** ```sql -isMergeTreePartCoveredBy(nested_part, covering_part) +tid() ``` **参数** -- `nested_part` ([String](../data-types/string.md)) — 预期嵌套部分的名称。 -- `covering_part` ([String](../data-types/string.md)) — 预期覆盖部分的名称。 - +- 无。 **返回值** -- 如果它覆盖,则返回 1,否则返回 0。 +返回当前线程 ID。 [`UInt64`](/sql-reference/data-types/int-uint) **示例** -查询: +**使用示例** -```sql -WITH 'all_12_25_7_4' AS lhs, 'all_7_100_10_20' AS rhs SELECT isMergeTreePartCoveredBy(rhs, lhs), isMergeTreePartCoveredBy(lhs, rhs); +```sql title=Query +SELECT tid(); ``` -结果: - -```text -┌─isMergeTreeP⋯y(rhs, lhs)─┬─isMergeTreeP⋯y(lhs, rhs)─┐ -│ 0 │ 1 │ -└──────────────────────────┴──────────────────────────┘ +```response title=Response +┌─tid()─┐ +│ 3878 │ +└───────┘ ``` - - + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/introspection.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/introspection.md.hash index 73621c384ce..8f09ef647ed 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/introspection.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/introspection.md.hash @@ -1 +1 @@ -f034d45cb966aaf9 +d7749f2c0d42f043 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/ip-address-functions.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/ip-address-functions.md index 701d5754ce4..6c89c351d22 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/ip-address-functions.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/ip-address-functions.md @@ -1,41 +1,128 @@ --- -'description': '处理IPv4和IPv6地址的函数的文档' -'sidebar_label': 'IP地址' -'sidebar_position': 95 +'description': '用于处理 IPv4 和 IPv6 地址的函数的 Documentation。' +'sidebar_label': 'IP 地址' 'slug': '/sql-reference/functions/ip-address-functions' -'title': '处理IPv4和IPv6地址的函数' +'title': '处理 IPv4 和 IPv6 地址的函数' +'doc_type': 'reference' --- -# 处理 IPv4 和 IPv6 地址的函数 +# 函数用于处理IPv4和IPv6地址 + + + + +## IPv4CIDRToRange {#IPv4CIDRToRange} + +引入于:v20.1 + + +接受带有无类域间路由 (CIDR) 前缀长度的IPv4地址,返回该子网的地址范围,作为两个IPv4值的元组:该子网中的第一个和最后一个地址。 +IPv6版本请参见 [`IPv6CIDRToRange`](#IPv4CIDRToRange)。 + + +**语法** + +```sql +IPv4CIDRToRange(ipv4, cidr) +``` + +**参数** + +- `ipv4` — IPv4地址。 [`IPv4`](/sql-reference/data-types/ipv4) 或 [`String`](/sql-reference/data-types/string) +- `cidr` — CIDR值。 [`UInt8`](/sql-reference/data-types/int-uint) + + +**返回值** + +返回一个包含两个IPv4地址的元组,表示子网范围。 [`Tuple(IPv4, IPv4)`](/sql-reference/data-types/tuple) + +**示例** + +**用法示例** + +```sql title=Query +SELECT IPv4CIDRToRange(toIPv4('192.168.5.2'), 16); +``` + +```response title=Response +┌─IPv4CIDRToRange(toIPv4('192.168.5.2'), 16)─┐ +│ ('192.168.0.0','192.168.255.255') │ +└────────────────────────────────────────────┘ +``` + + ## IPv4NumToString {#IPv4NumToString} -接收一个 UInt32 数字,将其解释为一个大端格式的 IPv4 地址。返回一个字符串,包含与之对应的 IPv4 地址,格式为 A.B.C.d(以点分隔的十进制数字)。 +引入于:v1.1 -别名: `INET_NTOA`。 -## IPv4StringToNum {#IPv4StringToNum} +将32位整数转换为其在点分十进制表示法中的IPv4地址字符串表示 (A.B.C.D格式)。 +使用大端字节序解释输入。 + + +**语法** + +```sql +IPv4NumToString(num) +``` -[IPv4NumToString](#IPv4NumToString) 的反向函数。如果 IPv4 地址格式无效,则抛出异常。 +**参数** + +- `num` — IPv4地址作为UInt32数字。 [`UInt32`](/sql-reference/data-types/int-uint) + + +**返回值** -别名: `INET_ATON`。 +返回代表MAC地址的数字,或如果格式无效则返回`0`。 [`String`](/sql-reference/data-types/string) -## IPv4StringToNumOrDefault(s) {#ipv4stringtonumordefaults} +**示例** -与 `IPv4StringToNum` 相同,但如果 IPv4 地址格式无效,则返回 0。 +**用法示例** -## IPv4StringToNumOrNull(s) {#ipv4stringtonumornulls} +```sql title=Query +IPv4NumToString(3232235521) +``` -与 `IPv4StringToNum` 相同,但如果 IPv4 地址格式无效,则返回 null。 +```response title=Response +192.168.0.1 +``` -## IPv4NumToStringClassC(num) {#ipv4numtostringclasscnum} -类似于 IPv4NumToString,但使用 xxx 替代最后一个八位字节。 -示例: +## IPv4NumToStringClassC {#IPv4NumToStringClassC} + +引入于:v1.1 + + +将32位整数转换为其在点分十进制表示法中的IPv4地址字符串表示 (A.B.C.D格式), +类似于 [`IPv4NumToString`](#IPv4NumToString),但使用`xxx`替代最后一个八位组。 + + +**语法** ```sql +IPv4NumToStringClassC(num) +``` + +**参数** + +- `num` — IPv4地址作为UInt32数字。 [`UInt32`](/sql-reference/data-types/int-uint) + + +**返回值** + +返回IPv4地址字符串,用xxx替代最后一个八位组。 [`String`](/sql-reference/data-types/string) + +**示例** + +**基本示例与聚合** + +```sql title=Query SELECT IPv4NumToStringClassC(ClientIP) AS k, count() AS c @@ -45,7 +132,7 @@ ORDER BY c DESC LIMIT 10 ``` -```text +```response title=Response ┌─k──────────────┬─────c─┐ │ 83.149.9.xxx │ 26238 │ │ 217.118.81.xxx │ 26074 │ @@ -60,28 +147,249 @@ LIMIT 10 └────────────────┴───────┘ ``` -由于使用 'xxx' 是极其不寻常的,未来可能会有所更改。我们建议您不要依赖此片段的确切格式。 -### IPv6NumToString(x) {#ipv6numtostringx} -接受一个包含 IPv6 地址的 FixedString(16) 值,格式为二进制。返回一个字符串,包含该地址的文本格式。 -IPv6 映射的 IPv4 地址以格式 ::ffff:111.222.33.44 输出。 +## IPv4StringToNum {#IPv4StringToNum} + +引入于:v1.1 + + +将点分十进制表示法中的IPv4地址字符串 (A.B.C.D格式) 转换为其对应的32位整数表示。 (与 [`IPv4NumToString`](#IPv4NumToString) 相反)。 +如果IPv4地址格式无效,则抛出异常。 + + +**语法** + +```sql +IPv4StringToNum(string) +``` + +**参数** + +- `string` — IPv4地址字符串。 [`String`](/sql-reference/data-types/string) + + +**返回值** + +返回IPv4地址。 [`UInt32`](/sql-reference/data-types/int-uint) + +**示例** + +**用法示例** + +```sql title=Query +IPv4StringToNum('192.168.0.1') +``` + +```response title=Response +3232235521 +``` + + + +## IPv4StringToNumOrDefault {#IPv4StringToNumOrDefault} + +引入于:v22.3 + + +将点分十进制表示法中的IPv4地址字符串 (A.B.C.D格式) 转换为其对应的32位整数表示,但如果IPv4地址格式无效,则返回`0`。 + + +**语法** + +```sql +IPv4StringToNumOrDefault(string) +``` + +**参数** + +- `string` — IPv4地址字符串。 [`String`](/sql-reference/data-types/string) + + +**返回值** + +返回IPv4地址,如果无效则返回`0`。 [`UInt32`](/sql-reference/data-types/int-uint) + +**示例** + +**带有无效地址的示例** + +```sql title=Query +SELECT + IPv4StringToNumOrDefault('127.0.0.1') AS valid, + IPv4StringToNumOrDefault('invalid') AS invalid; +``` + +```response title=Response +┌──────valid─┬─invalid─┐ +│ 2130706433 │ 0 │ +└────────────┴─────────┘ +``` + + + +## IPv4StringToNumOrNull {#IPv4StringToNumOrNull} + +引入于:v22.3 + + +将32位整数转换为点分十进制表示法中的IPv4地址字符串 (A.B.C.D格式),但如果IPv4地址格式无效,则返回`NULL`。 + + +**语法** + +```sql +IPv4StringToNumOrNull(string) +``` + +**参数** + +- `string` — IPv4地址字符串。 [`String`](/sql-reference/data-types/string) + + +**返回值** + +返回IPv4地址,如果无效则返回`NULL`。 [`Nullable(UInt32)`](/sql-reference/data-types/nullable) + +**示例** + +**带有无效地址的示例** + +```sql title=Query +SELECT +IPv4StringToNumOrNull('127.0.0.1') AS valid, +IPv4StringToNumOrNull('invalid') AS invalid; +``` + +```response title=Response +┌──────valid─┬─invalid─┐ +│ 2130706433 │ ᴺᵁᴸᴸ │ +└────────────┴─────────┘ +``` + + + +## IPv4ToIPv6 {#IPv4ToIPv6} + +引入于:v1.1 + + +将一个(大端)32位数字解释为IPv4地址,然后将其解释为对应的IPv6地址,以`FixedString(16)`格式表示。 + + +**语法** + +```sql +IPv4ToIPv6(x) +``` + +**参数** + +- `x` — IPv4地址。 [`UInt32`](/sql-reference/data-types/int-uint) + + +**返回值** + +返回以二进制格式表示的IPv6地址。 [`FixedString(16)`](/sql-reference/data-types/fixedstring) + +**示例** + +**用法示例** + +```sql title=Query +SELECT IPv6NumToString(IPv4ToIPv6(IPv4StringToNum('192.168.0.1'))) AS addr; +``` + +```response title=Response +┌─addr───────────────┐ +│ ::ffff:192.168.0.1 │ +└────────────────────┘ +``` + + + +## IPv6CIDRToRange {#IPv6CIDRToRange} + +引入于:v20.1 + + +接受带有无类域间路由 (CIDR) 前缀长度的IPv6地址,返回该子网的地址范围,作为两个IPv6值的元组:该子网中的最低和最高地址。 +IPv4版本请参见 [`IPv4CIDRToRange`](#IPv4CIDRToRange)。 + + +**语法** + +```sql +IPv6CIDRToRange(ipv6, cidr) +``` + +**参数** + +- `ipv6` — IPv6地址。 [`IPv6`](/sql-reference/data-types/ipv6) 或 [`String`](/sql-reference/data-types/string) +- `cidr` — CIDR值。 [`UInt8`](/sql-reference/data-types/int-uint) + + +**返回值** + +返回一个包含两个IPv6地址的元组,表示子网范围。 [`Tuple(IPv6, IPv6)`](/sql-reference/data-types/tuple) + +**示例** + +**用法示例** + +```sql title=Query +SELECT IPv6CIDRToRange(toIPv6('2001:0db8:0000:85a3:0000:0000:ac1f:8001'), 32); +``` + +```response title=Response +┌─IPv6CIDRToRange(toIPv6('2001:0db8:0000:85a3:0000:0000:ac1f:8001'), 32)─┐ +│ ('2001:db8::','2001:db8:ffff:ffff:ffff:ffff:ffff:ffff') │ +└────────────────────────────────────────────────────────────────────────┘ +``` + + + +## IPv6NumToString {#IPv6NumToString} -别名: `INET6_NTOA`。 +引入于:v1.1 -示例: + +将二进制格式中的IPv6地址(`FixedString(16)`)转换为其标准文本表示。 +IPv4映射的IPv6地址以格式`::ffff:111.222.33.44`显示。 + + +**语法** ```sql +IPv6NumToString(x) +``` + +**参数** + +- `x` — 二进制格式的IPv6地址。 [`FixedString(16)`](/sql-reference/data-types/fixedstring) 或 [`IPv6`](/sql-reference/data-types/ipv6) + + +**返回值** + +返回以文本格式表示的IPv6地址。 [`String`](/sql-reference/data-types/string) + +**示例** + +**用法示例** + +```sql title=Query SELECT IPv6NumToString(toFixedString(unhex('2A0206B8000000000000000000000011'), 16)) AS addr; ``` -```text +```response title=Response ┌─addr─────────┐ │ 2a02:6b8::11 │ └──────────────┘ ``` -```sql +**带有命中分析的IPv6** + +```sql title=Query SELECT IPv6NumToString(ClientIP6 AS k), count() AS c @@ -92,7 +400,7 @@ ORDER BY c DESC LIMIT 10 ``` -```text +```response title=Response ┌─IPv6NumToString(ClientIP6)──────────────┬─────c─┐ │ 2a02:2168:aaa:bbbb::2 │ 24695 │ │ 2a02:2698:abcd:abcd:abcd:abcd:8888:5555 │ 22408 │ @@ -107,7 +415,9 @@ LIMIT 10 └─────────────────────────────────────────┴───────┘ ``` -```sql +**IPv6映射的IPv4地址** + +```sql title=Query SELECT IPv6NumToString(ClientIP6 AS k), count() AS c @@ -118,7 +428,7 @@ ORDER BY c DESC LIMIT 10 ``` -```text +```response title=Response ┌─IPv6NumToString(ClientIP6)─┬──────c─┐ │ ::ffff:94.26.111.111 │ 747440 │ │ ::ffff:37.143.222.4 │ 529483 │ @@ -133,14 +443,20 @@ LIMIT 10 └────────────────────────────┴────────┘ ``` -## IPv6StringToNum {#ipv6stringtonum} -[IPv6NumToString](#ipv6numtostringx) 的反向函数。如果 IPv6 地址格式无效,则抛出异常。 -如果输入字符串包含有效的 IPv4 地址,则返回其 IPv6 等效地址。 -HEX 可以是大写或小写。 +## IPv6StringToNum {#IPv6StringToNum} + +引入于:v1.1 + -别名: `INET6_ATON`。 +将标准文本表示的IPv6地址转换为二进制格式 (`FixedString(16)`)。 +接受格式为`::ffff:111.222.33.44.`的IPv4映射IPv6地址。 +如果IPv6地址格式无效,则抛出异常。 + +如果输入字符串包含有效IPv4地址,则返回其IPv6等效地址。 +HEX可以是大写或小写。 + **语法** @@ -150,23 +466,22 @@ IPv6StringToNum(string) **参数** -- `string` — IP 地址。 [String](../data-types/string.md)。 +- `string` — IPv6地址字符串。 [`String`](/sql-reference/data-types/string) + **返回值** -- IPv6 地址,格式为二进制。 [FixedString(16)](../data-types/fixedstring.md)。 +返回以二进制格式表示的IPv6地址。 [`FixedString(16)`](/sql-reference/data-types/fixedstring) **示例** -查询: +**基本示例** -```sql +```sql title=Query SELECT addr, cutIPv6(IPv6StringToNum(addr), 0, 0) FROM (SELECT ['notaddress', '127.0.0.1', '1111::ffff'] AS addr) ARRAY JOIN addr; ``` -结果: - -```text +```response title=Response ┌─addr───────┬─cutIPv6(IPv6StringToNum(addr), 0, 0)─┐ │ notaddress │ :: │ │ 127.0.0.1 │ ::ffff:127.0.0.1 │ @@ -174,574 +489,718 @@ SELECT addr, cutIPv6(IPv6StringToNum(addr), 0, 0) FROM (SELECT ['notaddress', '1 └────────────┴──────────────────────────────────────┘ ``` -**参见** -- [cutIPv6](#cutipv6x-bytestocutforipv6-bytestocutforipv4)。 -## IPv6StringToNumOrDefault(s) {#ipv6stringtonumordefaults} +## IPv6StringToNumOrDefault {#IPv6StringToNumOrDefault} -与 `IPv6StringToNum` 相同,但如果 IPv6 地址格式无效,则返回 0。 +引入于:v22.3 -## IPv6StringToNumOrNull(s) {#ipv6stringtonumornulls} -与 `IPv6StringToNum` 相同,但如果 IPv6 地址格式无效,则返回 null。 +将标准文本表示的IPv6地址转换为二进制格式 (`FixedString(16)`)。 +接受格式为`::ffff:111.222.33.44.`的IPv4映射IPv6地址。 +如果IPv6地址格式无效,则返回默认值`::`。 + -## IPv4ToIPv6(x) {#ipv4toipv6x} - -接受一个 `UInt32` 数字。将其解释为一个大端格式的 IPv4 地址 [big endian](https://en.wikipedia.org/wiki/Endianness)。返回一个包含 IPv6 地址的 `FixedString(16)` 值,其格式为二进制。示例: +**语法** ```sql -SELECT IPv6NumToString(IPv4ToIPv6(IPv4StringToNum('192.168.0.1'))) AS addr; +IPv6StringToNumOrDefault(string) ``` -```text -┌─addr───────────────┐ -│ ::ffff:192.168.0.1 │ -└────────────────────┘ -``` +**参数** -## cutIPv6(x, bytesToCutForIPv6, bytesToCutForIPv4) {#cutipv6x-bytestocutforipv6-bytestocutforipv4} +- `string` — IPv6地址字符串。 [`String`](/sql-reference/data-types/string) -接受一个包含 IPv6 地址的 FixedString(16) 值,格式为二进制。返回一个字符串,包含以文本格式删除指定字节数后的地址。例如: -```sql -WITH - IPv6StringToNum('2001:0DB8:AC10:FE01:FEED:BABE:CAFE:F00D') AS ipv6, - IPv4ToIPv6(IPv4StringToNum('192.168.0.1')) AS ipv4 -SELECT - cutIPv6(ipv6, 2, 0), - cutIPv6(ipv4, 0, 2) -``` +**返回值** -```text -┌─cutIPv6(ipv6, 2, 0)─────────────────┬─cutIPv6(ipv4, 0, 2)─┐ -│ 2001:db8:ac10:fe01:feed:babe:cafe:0 │ ::ffff:192.168.0.0 │ -└─────────────────────────────────────┴─────────────────────┘ -``` +返回以二进制格式表示的IPv6地址,如果无效则返回零填充的FixedString(16)。 [`FixedString(16)`](/sql-reference/data-types/fixedstring) -## IPv4CIDRToRange(ipv4, Cidr) {#ipv4cidrtorangeipv4-cidr} +**示例** -接收一个 IPv4 和一个 UInt8 值,包含 [CIDR](https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing)。返回一个元组,包含两个 IPv4 地址,分别表示子网的下限和上限范围。 +**带有无效地址的基本示例** -```sql -SELECT IPv4CIDRToRange(toIPv4('192.168.5.2'), 16); +```sql title=Query +SELECT + IPv6NumToString(IPv6StringToNumOrDefault('2001:db8::1')) AS valid, + IPv6NumToString(IPv6StringToNumOrDefault('invalid')) AS invalid; ``` -```text -┌─IPv4CIDRToRange(toIPv4('192.168.5.2'), 16)─┐ -│ ('192.168.0.0','192.168.255.255') │ -└────────────────────────────────────────────┘ +```response title=Response +┌─valid───────┬─invalid─┐ +│ 2001:db8::1 │ :: │ +└─────────────┴─────────┘ ``` -## IPv6CIDRToRange(ipv6, Cidr) {#ipv6cidrtorangeipv6-cidr} -接收一个 IPv6 和一个 UInt8 值,包含 CIDR。返回一个元组,包含两个 IPv6 地址,分别表示子网的下限和上限范围。 -```sql -SELECT IPv6CIDRToRange(toIPv6('2001:0db8:0000:85a3:0000:0000:ac1f:8001'), 32); -``` +## IPv6StringToNumOrNull {#IPv6StringToNumOrNull} -```text -┌─IPv6CIDRToRange(toIPv6('2001:0db8:0000:85a3:0000:0000:ac1f:8001'), 32)─┐ -│ ('2001:db8::','2001:db8:ffff:ffff:ffff:ffff:ffff:ffff') │ -└────────────────────────────────────────────────────────────────────────┘ -``` +引入于:v22.3 -## toIPv4 {#toipv4} -将字符串或 UInt32 格式的 IPv4 地址转换为 [IPv4](../data-types/ipv4.md) 类型。 -类似于 [`IPv4StringToNum`](#IPv4StringToNum) 和 [IPv4NumToString](#IPv4NumToString) 函数,但支持字符串和无符号整数数据类型的输入参数。 +将标准文本表示的IPv6地址转换为二进制格式 (`FixedString(16)`)。 +接受格式为`::ffff:111.222.33.44.`的IPv4映射IPv6地址。 +如果IPv6地址格式无效,则返回`NULL`。 + **语法** ```sql -toIPv4(x) +IPv6StringToNumOrNull(string) ``` **参数** -- `x` — IPv4 地址。 [`String`](../data-types/string.md)、[`UInt8/16/32`](../data-types/int-uint.md)。 +- `string` — IPv6地址字符串。 [`String`](/sql-reference/data-types/string) + **返回值** -- IPv4 地址。 [IPv4](../data-types/ipv4.md)。 +返回以二进制格式表示的IPv6地址,如果无效则返回`NULL`。 [`Nullable(FixedString(16))`](/sql-reference/data-types/nullable) **示例** -查询: +**带有无效地址的基本示例** -```sql -SELECT toIPv4('171.225.130.45'); +```sql title=Query +SELECT + IPv6NumToString(IPv6StringToNumOrNull('2001:db8::1')) AS valid, + IPv6StringToNumOrNull('invalid') AS invalid; ``` -结果: - -```text -┌─toIPv4('171.225.130.45')─┐ -│ 171.225.130.45 │ -└──────────────────────────┘ +```response title=Response +┌─valid───────┬─invalid─┐ +│ 2001:db8::1 │ ᴺᵁᴸᴸ │ +└─────────────┴─────────┘ ``` -查询: + + +## cutIPv6 {#cutIPv6} + +引入于:v1.1 + + +接受包含二进制格式中的IPv6地址的 `FixedString(16)` 值。 +返回包含指定字节数移除的文本格式地址的字符串。 + + +**语法** ```sql +cutIPv6(x, bytesToCutForIPv6, bytesToCutForIPv4) +``` + +**参数** + +- `x` — 二进制格式的IPv6地址。 [`FixedString(16)`](/sql-reference/data-types/fixedstring) 或 [`IPv6`](/sql-reference/data-types/ipv6) +- `bytesToCutForIPv6` — 需要移除的IPv6字节数。 [`UInt8`](/sql-reference/data-types/int-uint) +- `bytesToCutForIPv4` — 需要移除的IPv4字节数。 [`UInt8`](/sql-reference/data-types/int-uint) + + +**返回值** + +返回以文本格式表示的IPv6地址字符串,移除了指定的字节。 [`String`](/sql-reference/data-types/string) + +**示例** + +**用法示例** + +```sql title=Query WITH - '171.225.130.45' as IPv4_string + IPv6StringToNum('2001:0DB8:AC10:FE01:FEED:BABE:CAFE:F00D') AS ipv6, + IPv4ToIPv6(IPv4StringToNum('192.168.0.1')) AS ipv4 SELECT - hex(IPv4StringToNum(IPv4_string)), - hex(toIPv4(IPv4_string)) + cutIPv6(ipv6, 2, 0), + cutIPv6(ipv4, 0, 2) ``` -结果: - -```text -┌─hex(IPv4StringToNum(IPv4_string))─┬─hex(toIPv4(IPv4_string))─┐ -│ ABE1822D │ ABE1822D │ -└───────────────────────────────────┴──────────────────────────┘ +```response title=Response +┌─cutIPv6(ipv6, 2, 0)─────────────────┬─cutIPv6(ipv4, 0, 2)─┐ +│ 2001:db8:ac10:fe01:feed:babe:cafe:0 │ ::ffff:192.168.0.0 │ +└─────────────────────────────────────┴─────────────────────┘ ``` -查询: -```sql -SELECT toIPv4(2130706433); -``` -结果: +## isIPAddressInRange {#isIPAddressInRange} + +引入于:v21.4 -```text -┌─toIPv4(2130706433)─┐ -│ 127.0.0.1 │ -└────────────────────┘ -``` -## toIPv4OrDefault {#toipv4ordefault} +判断一个IP地址是否包含在以[无类域间路由 (CIDR)](https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing)表示的网络中。 -与 `toIPv4` 相同,但如果 IPv4 地址格式无效,则返回 `0.0.0.0` (0 IPv4)或提供的 IPv4 默认值。 +该函数接受以字符串表示的IPv4和IPv6地址(和网络)。如果IP地址的IP版本与CIDR不匹配,则返回 `0`。 + **语法** ```sql -toIPv4OrDefault(string[, default]) +isIPAddressInRange(address, prefix) ``` **参数** -- `value` — IP 地址。 [String](../data-types/string.md)。 -- `default`(可选)— 如果 `string` 格式无效时要返回的值。 [IPv4](../data-types/ipv4.md)。 +- `address` — IPv4或IPv6地址。 [`String`](/sql-reference/data-types/string) +- `prefix` — 表示CIDR的IPv4或IPv6网络前缀。 [`String`](/sql-reference/data-types/string) + **返回值** -- `string` 转换为当前 IPv4 地址。 [String](../data-types/string.md)。 +如果地址的IP版本与CIDR匹配,则返回`1`,否则返回`0`。 [`UInt8`](/sql-reference/data-types/int-uint) **示例** -查询: +**在范围内的IPv4地址** -```sql -WITH - '::ffff:127.0.0.1' AS valid_IPv6_string, - 'fe80:2030:31:24' AS invalid_IPv6_string -SELECT - toIPv4OrDefault(valid_IPv6_string) AS valid, - toIPv4OrDefault(invalid_IPv6_string) AS default, - toIPv4OrDefault(invalid_IPv6_string, toIPv4('1.1.1.1')) AS provided_default; +```sql title=Query +SELECT isIPAddressInRange('127.0.0.1', '127.0.0.0/8') +``` + +```response title=Response +1 +``` + +**不在范围内的IPv4地址** + +```sql title=Query +SELECT isIPAddressInRange('127.0.0.1', 'ffff::/16') +``` + +```response title=Response +0 ``` -结果: +**不在范围内的IPv6地址** -```response -┌─valid───┬─default─┬─provided_default─┐ -│ 0.0.0.0 │ 0.0.0.0 │ 1.1.1.1 │ -└─────────┴─────────┴──────────────────┘ +```sql title=Query +SELECT isIPAddressInRange('::ffff:192.168.0.1', '::ffff:192.168.0.4/128') ``` -## toIPv4OrNull {#toipv4ornull} +```response title=Response +0 +``` + + + +## isIPv4String {#isIPv4String} -与 [`toIPv4`](#toipv4) 相同,但如果 IPv4 地址格式无效,则返回 null。 +引入于:v21.1 + + +判断输入字符串是否为IPv4地址。 +IPv6版本请参见 [`isIPv6String`](#isIPv6String)。 + **语法** ```sql -toIPv4OrNull(string) +isIPv4String(string) ``` **参数** -- `string` — IP 地址。 [String](../data-types/string.md)。 +- `string` — 要检查的IP地址字符串。 [`String`](/sql-reference/data-types/string) + **返回值** -- `string` 转换为当前 IPv4 地址,如果 `string` 是无效地址,则返回 null。 [String](../data-types/string.md)。 +如果`string`为IPv4地址则返回`1`,否则返回`0`。 [`UInt8`](/sql-reference/data-types/int-uint) **示例** -查询: +**用法示例** -```sql -WITH 'fe80:2030:31:24' AS invalid_IPv6_string -SELECT toIPv4OrNull(invalid_IPv6_string); +```sql title=Query +SELECT addr, isIPv4String(addr) +FROM( +SELECT ['0.0.0.0', '127.0.0.1', '::ffff:127.0.0.1'] AS addr +) +ARRAY JOIN addr; ``` -结果: - -```text -┌─toIPv4OrNull(invalid_IPv6_string)─┐ -│ ᴺᵁᴸᴸ │ -└───────────────────────────────────┘ +```response title=Response +┌─addr─────────────┬─isIPv4String(addr)─┐ +│ 0.0.0.0 │ 1 │ +│ 127.0.0.1 │ 1 │ +│ ::ffff:127.0.0.1 │ 0 │ +└──────────────────┴────────────────────┘ ``` -## toIPv4OrZero {#toipv4orzero} -与 [`toIPv4`](#toipv4) 相同,但如果 IPv4 地址格式无效,则返回 `0.0.0.0`。 + +## isIPv6String {#isIPv6String} + +引入于:v21.1 + + +判断输入字符串是否为IPv6地址。 +IPv4版本请参见 [`isIPv4String`](#isIPv4String)。 + **语法** ```sql -toIPv4OrZero(string) +isIPv6String(string) ``` **参数** -- `string` — IP 地址。 [String](../data-types/string.md)。 +- `string` — 要检查的IP地址字符串。 [`String`](/sql-reference/data-types/string) + **返回值** -- `string` 转换为当前 IPv4 地址,如果 `string` 是无效地址,则返回 `0.0.0.0` 。 [String](../data-types/string.md)。 +如果`string`为IPv6地址则返回`1`,否则返回`0`。 [`UInt8`](/sql-reference/data-types/int-uint) **示例** -查询: +**用法示例** -```sql -WITH 'Not an IP address' AS invalid_IPv6_string -SELECT toIPv4OrZero(invalid_IPv6_string); +```sql title=Query +SELECT addr, isIPv6String(addr) +FROM(SELECT ['::', '1111::ffff', '::ffff:127.0.0.1', '127.0.0.1'] AS addr) +ARRAY JOIN addr; ``` -结果: - -```text -┌─toIPv4OrZero(invalid_IPv6_string)─┐ -│ 0.0.0.0 │ -└───────────────────────────────────┘ +```response title=Response +┌─addr─────────────┬─isIPv6String(addr)─┐ +│ :: │ 1 │ +│ 1111::ffff │ 1 │ +│ ::ffff:127.0.0.1 │ 1 │ +│ 127.0.0.1 │ 0 │ +└──────────────────┴────────────────────┘ ``` -## toIPv6 {#toipv6} -将字符串或 UInt128 格式的 IPv6 地址转换为 [IPv6](../data-types/ipv6.md) 类型。对于字符串,如果 IPv6 地址格式无效,则返回空值。 -类似于 [IPv6StringToNum](#ipv6stringtonum) 和 [IPv6NumToString](#ipv6numtostringx) 函数,这些函数可以在二进制格式(即 `FixedString(16)`)之间转换 IPv6 地址。 -如果输入字符串包含有效的 IPv4 地址,则返回其 IPv6 等效地址。 +## toIPv4 {#toIPv4} + +引入于:v20.1 + + +将字符串或UInt32形式的IPv4地址转换为IPv4类型。 +它类似于[`IPv4StringToNum`](/sql-reference/functions/ip-address-functions#IPv4StringToNum) 和 [`IPv4NumToString`](/sql-reference/functions/ip-address-functions#IPv4NumToString)函数,但它支持字符串和无符号整数数据类型作为输入参数。 + **语法** ```sql -toIPv6(string) -toIPv6(UInt128) +toIPv4(x) ``` **参数** -- `x` — IP 地址。 [`String`](../data-types/string.md) 或 [`UInt128`](../data-types/int-uint.md)。 +- `x` — 一个IPv4地址 [`String`](/sql-reference/data-types/string) 或 [`UInt8/16/32`](/sql-reference/data-types/int-uint) + **返回值** -- IP 地址。 [IPv6](../data-types/ipv6.md)。 +返回IPv4地址。 [`IPv4`](/sql-reference/data-types/ipv4) **示例** -查询: +**用法示例** -```sql -WITH '2001:438:ffff::407d:1bc1' AS IPv6_string -SELECT - hex(IPv6StringToNum(IPv6_string)), - hex(toIPv6(IPv6_string)); +```sql title=Query +SELECT toIPv4('171.225.130.45'); ``` -结果: - -```text -┌─hex(IPv6StringToNum(IPv6_string))─┬─hex(toIPv6(IPv6_string))─────────┐ -│ 20010438FFFF000000000000407D1BC1 │ 20010438FFFF000000000000407D1BC1 │ -└───────────────────────────────────┴──────────────────────────────────┘ +```response title=Response +┌─toIPv4('171.225.130.45')─┐ +│ 171.225.130.45 │ +└──────────────────────────┘ ``` -查询: +**与IPv4StringToNum和IPv4NumToString函数的比较。** -```sql -SELECT toIPv6('127.0.0.1'); +```sql title=Query +WITH + '171.225.130.45' AS IPv4_string +SELECT + hex(IPv4StringToNum(IPv4_string)), + hex(toIPv4(IPv4_string)) +``` + +```response title=Response +┌─hex(IPv4StringToNum(IPv4_string))─┬─hex(toIPv4(IPv4_string))─┐ +│ ABE1822D │ ABE1822D │ +└───────────────────────────────────┴──────────────────────────┘ ``` -结果: +**从整数转换** -```text -┌─toIPv6('127.0.0.1')─┐ -│ ::ffff:127.0.0.1 │ -└─────────────────────┘ +```sql title=Query +SELECT toIPv4(2130706433); ``` -## toIPv6OrDefault {#toipv6ordefault} +```response title=Response +┌─toIPv4(2130706433)─┐ +│ 127.0.0.1 │ +└────────────────────┘ +``` + + + +## toIPv4OrDefault {#toIPv4OrDefault} -与 [`toIPv6`](#toipv6) 相同,但如果 IPv6 地址格式无效,则返回 `::`(0 IPv6)或提供的 IPv6 默认值。 +引入于:v22.3 + + +将字符串或UInt32形式的IPv4地址转换为[`IPv4`](../data-types/ipv4.md)类型。 +如果IPv4地址格式无效,则返回`0.0.0.0` (0 IPv4),或提供的IPv4默认值。 + **语法** ```sql -toIPv6OrDefault(string[, default]) +toIPv4OrDefault(string[, default]) ``` **参数** -- `string` — IP 地址。 [String](../data-types/string.md)。 -- `default`(可选)— 如果 `string` 格式无效时要返回的值。 [IPv6](../data-types/ipv6.md)。 +- `string` — 要转换的IP地址字符串。 [`String`](/sql-reference/data-types/string) +- `default` — 可选。如果字符串为无效IPv4地址时返回的值。 [`IPv4`](/sql-reference/data-types/ipv4) + **返回值** -- IPv6 地址 [IPv6](../data-types/ipv6.md),否则如果 `string` 格式无效则返回 `::` 或提供的可选默认值。 +返回当前IPv4地址转换后的字符串,或在转换失败时返回默认值。 [`IPv4`](/sql-reference/data-types/ipv4) **示例** -查询: +**有效和无效的IPv4字符串** -```sql +```sql title=Query WITH - '127.0.0.1' AS valid_IPv4_string, - '127.0.0.1.6' AS invalid_IPv4_string + '192.168.1.1' AS valid_IPv4_string, + '999.999.999.999' AS invalid_IPv4_string, + 'not_an_ip' AS malformed_string SELECT - toIPv6OrDefault(valid_IPv4_string) AS valid, - toIPv6OrDefault(invalid_IPv4_string) AS default, - toIPv6OrDefault(invalid_IPv4_string, toIPv6('1.1.1.1')) AS provided_default + toIPv4OrDefault(valid_IPv4_string) AS valid, + toIPv4OrDefault(invalid_IPv4_string) AS default_value, + toIPv4OrDefault(malformed_string, toIPv4('8.8.8.8')) AS provided_default; ``` -结果: - -```text -┌─valid────────────┬─default─┬─provided_default─┐ -│ ::ffff:127.0.0.1 │ :: │ ::ffff:1.1.1.1 │ -└──────────────────┴─────────┴──────────────────┘ +```response title=Response +┌─valid─────────┬─default_value─┬─provided_default─┐ +│ 192.168.1.1 │ 0.0.0.0 │ 8.8.8.8 │ +└───────────────┴───────────────┴──────────────────┘ ``` -## toIPv6OrNull {#toipv6ornull} -与 [`toIPv6`](#to_ipv6) 相同,但如果 IPv6 地址格式无效,则返回 null。 + +## toIPv4OrNull {#toIPv4OrNull} + +引入于:v22.3 + + +将输入值转换为类型`IPv4`的值,但在发生错误的情况下返回`NULL`。 +类似于 [`toIPv4`](#toIPv4),但在转换错误时返回`NULL`而不是抛出异常。 + +支持的参数: +- 点分十进制表示法中的IPv4地址的字符串表示。 +- IPv4地址的整数表示。 + +不支持的参数(返回`NULL`): +- 无效的IP地址格式。 +- IPv6地址。 +- 超出范围的值。 +- 格式错误的地址。 + **语法** ```sql -toIPv6OrNull(string) +toIPv4OrNull(x) ``` **参数** -- `string` — IP 地址。 [String](../data-types/string.md)。 +- `x` — IPv4地址的字符串或整数表示。 [`String`](/sql-reference/data-types/string) 或 [`Integer`](/sql-reference/data-types/int-uint) + **返回值** -- IP 地址。 [IPv6](../data-types/ipv6.md),如果 `string` 不是有效格式,则返回 null。 +如果成功,则返回IPv4地址,否则返回`NULL`。 [`IPv4`](/sql-reference/data-types/ipv4) 或 [`NULL`](/sql-reference/syntax#null) **示例** -查询: +**用法示例** -```sql -WITH '127.0.0.1.6' AS invalid_IPv4_string -SELECT toIPv6OrNull(invalid_IPv4_string); +```sql title=Query +SELECT + toIPv4OrNull('192.168.1.1') AS valid_ip, + toIPv4OrNull('invalid.ip') AS invalid_ip ``` -结果: - -```text -┌─toIPv6OrNull(invalid_IPv4_string)─┐ -│ ᴺᵁᴸᴸ │ -└───────────────────────────────────┘ +```response title=Response +┌─valid_ip────┬─invalid_ip─┐ +│ 192.168.1.1 │ ᴺᵁᴸᴸ │ +└─────────────┴────────────┘ ``` -## toIPv6OrZero {#toipv6orzero} -与 [`toIPv6`](#toipv6) 相同,但如果 IPv6 地址格式无效,则返回 `::`。 + +## toIPv4OrZero {#toIPv4OrZero} + +引入于:v23.1 + + +将输入值转换为类型[IPv4](../data-types/ipv4.md)的值,但在发生错误时返回零IPv4地址。 +类似于 [`toIPv4`](#toIPv4),但在转换错误时返回零IPv4地址(`0.0.0.0`)而不是抛出异常。 + +支持的参数: +- 点分十进制表示法中的IPv4地址的字符串表示。 +- IPv4地址的整数表示。 + +不支持的参数(返回零IPv4): +- 无效的IP地址格式。 +- IPv6地址。 +- 超出范围的值。 + **语法** ```sql -toIPv6OrZero(string) +toIPv4OrZero(x) ``` **参数** -- `string` — IP 地址。 [String](../data-types/string.md)。 +- `x` — IPv4地址的字符串或整数表示。 [`String`](/sql-reference/data-types/string) 或 [`Integer`](/sql-reference/data-types/int-uint) + **返回值** -- IP 地址。 [IPv6](../data-types/ipv6.md),如果 `string` 不是有效格式,则返回 `::`。 +如果成功,则返回IPv4地址,否则返回零IPv4地址(`0.0.0.0`)。 [`IPv4`](/sql-reference/data-types/ipv4) **示例** -查询: +**用法示例** -```sql -WITH '127.0.0.1.6' AS invalid_IPv4_string -SELECT toIPv6OrZero(invalid_IPv4_string); +```sql title=Query +SELECT + toIPv4OrZero('192.168.1.1') AS valid_ip, + toIPv4OrZero('invalid.ip') AS invalid_ip ``` -结果: - -```text -┌─toIPv6OrZero(invalid_IPv4_string)─┐ -│ :: │ -└───────────────────────────────────┘ +```response title=Response +┌─valid_ip────┬─invalid_ip─┐ +│ 192.168.1.1 │ 0.0.0.0 │ +└─────────────┴────────────┘ ``` -## IPv6StringToNumOrDefault(s) {#ipv6stringtonumordefaults-1} -与 `toIPv6` 相同,但如果 IPv6 地址格式无效,则返回 0。 -## IPv6StringToNumOrNull(s) {#ipv6stringtonumornulls-1} +## toIPv6 {#toIPv6} -与 `toIPv6` 相同,但如果 IPv6 地址格式无效,则返回 null。 +引入于:v20.1 -## isIPv4String {#isipv4string} -判断输入字符串是否为 IPv4 地址。如果 `string` 为 IPv6 地址,则返回 `0`。 +将字符串或 `UInt128`形式的IPv6地址转换为[`IPv6`](../data-types/ipv6.md)类型。 +对于字符串,如果IPv6地址格式无效,则返回空值。 +类似于[`IPv6StringToNum`](/sql-reference/functions/ip-address-functions#IPv6StringToNum)和[`IPv6NumToString`](/sql-reference/functions/ip-address-functions#IPv6NumToString)函数,它们在二进制格式 (即`FixedString(16)`)之间转换IPv6地址。 + +如果输入字符串包含有效的IPv4地址,则返回该IPv4地址的IPv6等效地址。 + **语法** ```sql -isIPv4String(string) +toIPv6(x) ``` **参数** -- `string` — IP 地址。 [String](../data-types/string.md)。 +- `x` — 一个IP地址。 [`String`](/sql-reference/data-types/string) 或 [`UInt128`](/sql-reference/data-types/int-uint) + **返回值** -- 如果 `string` 是 IPv4 地址,则返回 `1`,否则返回 `0`。 [UInt8](../data-types/int-uint.md)。 +返回IPv6地址。 [`IPv6`](/sql-reference/data-types/ipv6) **示例** -查询: +**用法示例** -```sql -SELECT addr, isIPv4String(addr) FROM ( SELECT ['0.0.0.0', '127.0.0.1', '::ffff:127.0.0.1'] AS addr ) ARRAY JOIN addr; +```sql title=Query +WITH '2001:438:ffff::407d:1bc1' AS IPv6_string +SELECT + hex(IPv6StringToNum(IPv6_string)), + hex(toIPv6(IPv6_string)); ``` -结果: +```response title=Response +┌─hex(IPv6StringToNum(IPv6_string))─┬─hex(toIPv6(IPv6_string))─────────┐ +│ 20010438FFFF000000000000407D1BC1 │ 20010438FFFF000000000000407D1BC1 │ +└───────────────────────────────────┴──────────────────────────────────┘ +``` -```text -┌─addr─────────────┬─isIPv4String(addr)─┐ -│ 0.0.0.0 │ 1 │ -│ 127.0.0.1 │ 1 │ -│ ::ffff:127.0.0.1 │ 0 │ -└──────────────────┴────────────────────┘ +**IPv4到IPv6的映射** + +```sql title=Query +SELECT toIPv6('127.0.0.1'); +``` + +```response title=Response +┌─toIPv6('127.0.0.1')─┐ +│ ::ffff:127.0.0.1 │ +└─────────────────────┘ ``` -## isIPv6String {#isipv6string} -判断输入字符串是否为 IPv6 地址。如果 `string` 为 IPv4 地址,则返回 `0`。 + +## toIPv6OrDefault {#toIPv6OrDefault} + +引入于:v22.3 + + +将字符串或UInt128形式的IPv6地址转换为[`IPv6`](../data-types/ipv6.md)类型。 +如果IPv6地址格式无效,则返回`::` (0 IPv6)或提供的IPv6默认值。 + **语法** ```sql -isIPv6String(string) +toIPv6OrDefault(string[, default]) ``` **参数** -- `string` — IP 地址。 [String](../data-types/string.md)。 +- `string` — 要转换的IP地址字符串。 - `default` — 可选。如果字符串格式无效,则返回的值。 **返回值** -- 如果 `string` 是 IPv6 地址,则返回 `1`,否则返回 `0`。 [UInt8](../data-types/int-uint.md)。 +返回IPv6地址,如果无效则返回`::`或提供的可选默认值,如果参数`string`格式无效。 [`IPv6`](/sql-reference/data-types/ipv6) **示例** -查询: +**有效和无效的IPv6字符串** -```sql -SELECT addr, isIPv6String(addr) FROM ( SELECT ['::', '1111::ffff', '::ffff:127.0.0.1', '127.0.0.1'] AS addr ) ARRAY JOIN addr; +```sql title=Query +WITH + '2001:0db8:85a3:0000:0000:8a2e:0370:7334' AS valid_IPv6_string, + '2001:0db8:85a3::8a2e:370g:7334' AS invalid_IPv6_string, + 'not_an_ipv6' AS malformed_string +SELECT + toIPv6OrDefault(valid_IPv6_string) AS valid, + toIPv6OrDefault(invalid_IPv6_string) AS default_value, + toIPv6OrDefault(malformed_string, toIPv6('::1')) AS provided_default; ``` -结果: - -```text -┌─addr─────────────┬─isIPv6String(addr)─┐ -│ :: │ 1 │ -│ 1111::ffff │ 1 │ -│ ::ffff:127.0.0.1 │ 1 │ -│ 127.0.0.1 │ 0 │ -└──────────────────┴────────────────────┘ +```response title=Response +┌─valid──────────────────────────────────┬─default_value─┬─provided_default─┐ +│ 2001:db8:85a3::8a2e:370:7334 │ :: │ ::1 │ +└────────────────────────────────────────┴───────────────┴──────────────────┘ ``` -## isIPAddressInRange {#isipaddressinrange} -判断一个 IP 地址是否包含在以 [CIDR](https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing) 表示的网络中。如果为真,则返回 `1`,否则返回 `0`。 + +## toIPv6OrNull {#toIPv6OrNull} + +引入于:v22.3 + + +将输入值转换为类型 `IPv6` 的值,但在发生错误时返回 `NULL`。 +类似于 [`toIPv6`](#toIPv6),但在转换错误时返回 `NULL`而不是抛出异常。 + +支持的参数: +- 标准表示法中IPv6地址的字符串表示。 +- IPv4地址的字符串表示(转换为IPv4映射的IPv6)。 +- IPv6地址的二进制表示。 + +不支持的参数(返回`NULL`): +- 无效的IP地址格式。 +- 格式错误的IPv6地址。 +- 超出范围的值。 +- 格式错误的表示法。 + **语法** ```sql -isIPAddressInRange(address, prefix) +toIPv6OrNull(x) ``` -该函数接受以字符串表示的 IPv4 和 IPv6 地址(以及网络)。如果 IP 地址的版本与 CIDR 不匹配,则返回 `0`。 - **参数** -- `address` — IPv4 或 IPv6 地址。 [String](../data-types/string.md)、[IPv4](../data-types/ipv4.md)、[IPv6](../data-types/ipv6.md)、`Nullable(String)`、`Nullable(IPv4)` 和 `Nullable(IPv6)`。 -- `prefix` — 以 CIDR 表示的 IPv4 或 IPv6 网络前缀。 [String](../data-types/string.md)。 +- `x` — 一个IPv6或IPv4地址的字符串表示。 [`String`](/sql-reference/data-types/string) + **返回值** -- `1` 或 `0`。 [UInt8](../data-types/int-uint.md)。 +如果成功,则返回IPv6地址,否则返回`NULL`。 [`IPv6`](/sql-reference/data-types/ipv6) 或 [`NULL`](/sql-reference/syntax#null) **示例** -查询: +**用法示例** -```sql -SELECT isIPAddressInRange('127.0.0.1', '127.0.0.0/8'); +```sql title=Query +SELECT + toIPv6OrNull('2001:0db8:85a3:0000:0000:8a2e:0370:7334') AS valid_ipv6, + toIPv6OrNull('invalid::ip') AS invalid_ipv6 ``` -结果: - -```text -┌─isIPAddressInRange('127.0.0.1', '127.0.0.0/8')─┐ -│ 1 │ -└────────────────────────────────────────────────┘ +```response title=Response +┌─valid_ipv6──────────────────────────┬─invalid_ipv6─┐ +│ 2001:db8:85a3::8a2e:370:7334 │ ᴺᵁᴸᴸ │ +└─────────────────────────────────────┴──────────────┘ ``` -查询: -```sql -SELECT isIPAddressInRange('127.0.0.1', 'ffff::/16'); -``` -结果: +## toIPv6OrZero {#toIPv6OrZero} -```text -┌─isIPAddressInRange('127.0.0.1', 'ffff::/16')─┐ -│ 0 │ -└──────────────────────────────────────────────┘ -``` +引入于:v23.1 + + +将输入值转换为类型[IPv6](../data-types/ipv6.md)的值,但在发生错误时返回零IPv6地址。 +类似于 [`toIPv6`](#toIPv6),但在转换错误时返回零IPv6地址 (`::`)而不是抛出异常。 -查询: +支持的参数: +- 标准表示法中IPv6地址的字符串表示。 +- IPv4地址的字符串表示(转换为IPv4映射的IPv6)。 +- IPv6地址的二进制表示。 + +不支持的参数(返回零IPv6): +- 无效的IP地址格式。 +- 格式错误的IPv6地址。 +- 超出范围的值。 + + +**语法** ```sql -SELECT isIPAddressInRange('::ffff:192.168.0.1', '::ffff:192.168.0.4/128'); +toIPv6OrZero(x) ``` -结果: +**参数** -```text -┌─isIPAddressInRange('::ffff:192.168.0.1', '::ffff:192.168.0.4/128')─┐ -│ 0 │ -└────────────────────────────────────────────────────────────────────┘ +- `x` — 一个IPv6或IPv4地址的字符串表示。 [`String`](/sql-reference/data-types/string) + + +**返回值** + +如果成功,则返回IPv6地址,否则返回零IPv6地址 (`::`)。 [`IPv6`](/sql-reference/data-types/ipv6) + +**示例** + +**用法示例** + +```sql title=Query +SELECT + toIPv6OrZero('2001:0db8:85a3:0000:0000:8a2e:0370:7334') AS valid_ipv6, + toIPv6OrZero('invalid::ip') AS invalid_ipv6 ``` - +```response title=Response +┌─valid_ipv6──────────────────────────┬─invalid_ipv6─┐ +│ 2001:db8:85a3::8a2e:370:7334 │ :: │ +└─────────────────────────────────────┴──────────────┘ +``` + + - diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/ip-address-functions.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/ip-address-functions.md.hash index b02e9760e45..b3dba364b44 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/ip-address-functions.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/ip-address-functions.md.hash @@ -1 +1 @@ -0f3483fb8096c6ee +b12d7bc6b40c20ce diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/json-functions.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/json-functions.md index 868ad518cff..e21959321a5 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/json-functions.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/json-functions.md @@ -1,1383 +1,2099 @@ --- -'description': 'JSON Functions 的文档' +'description': 'Json Functions 的文档' 'sidebar_label': 'JSON' -'sidebar_position': 105 'slug': '/sql-reference/functions/json-functions' 'title': 'JSON 函数' +'doc_type': 'reference' --- -There are two sets of functions to parse JSON: - - [`simpleJSON*` (`visitParam*`)](#simplejson-visitparam-functions) 用于快速解析受限子集的 JSON。 - - [`JSONExtract*`](#jsonextract-functions) 用于解析普通 JSON。 +## JSON 函数类型 {#types-of-functions} -## simpleJSON (visitParam) functions {#simplejson-visitparam-functions} +有两组函数用于解析 JSON: +- [`simpleJSON*`(`visitParam*`)](#simplejson-visitparam-functions),旨在以极快的速度解析有限子集的 JSON。 +- [`JSONExtract*`](#jsonextract-functions),旨在解析普通 JSON。 +### simpleJSON(visitParam)函数 {#simplejson-visitparam-functions} -ClickHouse 具有用于简化 JSON 的特殊函数。所有这些 JSON 函数都基于对 JSON 可能的强假设。它们尽量做最少的事情,以尽快完成工作。 +ClickHouse 提供了用于处理简化 JSON 的特殊函数。所有这些 JSON 函数都基于强假设,假设 JSON 的内容是特定的。它们尽量以最小的操作完成任务,以最快的速度完成工作。 -做出以下假设: +以下假设成立: -1. 字段名称(函数参数)必须是常量。 -2. 字段名称以某种方式在 JSON 中以规范形式编码。例如: `simpleJSONHas('{"abc":"def"}', 'abc') = 1`,但 `simpleJSONHas('{"\\u0061\\u0062\\u0063":"def"}', 'abc') = 0` -3. 在任意嵌套级别上,字段不加区分地进行搜索。如果存在多个匹配字段,则使用第一个匹配项。 -4. JSON 的字符串文字外部没有空格字符。 +1. 字段名(函数参数)必须是常量。 +2. 字段名在 JSON 中以某种方式标准化编码。例如:`simpleJSONHas('{"abc":"def"}', 'abc') = 1`,但是 `simpleJSONHas('{"\\u0061\\u0062\\u0063":"def"}', 'abc') = 0` +3. 在任何嵌套级别上搜索字段,不加区分。如果有多个匹配字段,则使用第一个出现的字段。 +4. JSON 在字符串字面量之外没有空格字符。 +### JSONExtract 函数 {#jsonextract-functions} -### simpleJSONHas {#simplejsonhas} +这些函数基于 [simdjson](https://github.com/lemire/simdjson),旨在满足更复杂的 JSON 解析要求。 +### 不区分大小写的 JSONExtract 函数 {#case-insensitive-jsonextract-functions} -检查是否存在名为 `field_name` 的字段。结果是 `UInt8`。 +这些函数在从 JSON 对象中提取值时执行 ASCII 不区分大小写的键匹配。 +它们的工作方式与其区分大小写的对应版本相同,只是对象键不考虑大小写。 +当多个键以不同的大小写匹配时,将返回第一个匹配。 + +:::note +这些函数的性能可能不如其区分大小写的对应版本,因此如果可能,请使用常规的 JSONExtract 函数。 +::: + + + + +## JSONAllPaths {#JSONAllPaths} + +引入版本:v24.8 + + +返回每行 JSON 列中存储的所有路径的列表。 + **语法** ```sql -simpleJSONHas(json, field_name) +JSONAllPaths(json) ``` -别名: `visitParamHas`。 - **参数** -- `json` — 要搜索字段的 JSON。 [String](/sql-reference/data-types/string) -- `field_name` — 要搜索的字段的名称。 [String literal](/sql-reference/syntax#string) +- `json` — JSON 列。 [`JSON`](/sql-reference/data-types/newjson) + **返回值** -- 如果字段存在,则返回 `1`,否则返回 `0`。 [UInt8](../data-types/int-uint.md)。 +返回 JSON 列中所有路径的数组。 [`Array(String)`](/sql-reference/data-types/array) **示例** -查询: - -```sql -CREATE TABLE jsons -( - `json` String -) -ENGINE = Memory; - -INSERT INTO jsons VALUES ('{"foo":"true","qux":1}'); +**用法示例** -SELECT simpleJSONHas(json, 'foo') FROM jsons; -SELECT simpleJSONHas(json, 'bar') FROM jsons; +```sql title=Query +CREATE TABLE test (json JSON(max_dynamic_paths=1)) ENGINE = Memory; +INSERT INTO test FORMAT JSONEachRow {"json" : {"a" : 42}}, {"json" : {"b" : "Hello"}}, {"json" : {"a" : [1, 2, 3], "c" : "2020-01-01"}} +SELECT json, JSONAllPaths(json) FROM test; ``` -结果: - -```response -1 -0 +```response title=Response +┌─json─────────────────────────────────┬─JSONAllPaths(json)─┐ +│ {"a":"42"} │ ['a'] │ +│ {"b":"Hello"} │ ['b'] │ +│ {"a":["1","2","3"],"c":"2020-01-01"} │ ['a','c'] │ +└──────────────────────────────────────┴────────────────────┘ ``` +## JSONAllPathsWithTypes {#JSONAllPathsWithTypes} + +引入版本:v24.8 -### simpleJSONExtractUInt {#simplejsonextractuint} -从名为 `field_name` 的字段值解析 `UInt64`。如果这是一个字符串字段,它会尝试从字符串的开头解析一个数字。如果字段不存在,或者字段存在但不包含数字,则返回 `0`。 +返回每行 JSON 列中存储的所有路径及其数据类型的列表。 + **语法** ```sql -simpleJSONExtractUInt(json, field_name) +JSONAllPathsWithTypes(json) ``` -别名: `visitParamExtractUInt`。 - **参数** -- `json` — 要搜索字段的 JSON。 [String](/sql-reference/data-types/string) -- `field_name` — 要搜索的字段的名称。 [String literal](/sql-reference/syntax#string) +- `json` — JSON 列。 [`JSON`](/sql-reference/data-types/newjson) + **返回值** -- 如果字段存在并且包含数字,则返回从字段解析出的数字, 否则返回 `0`。 [UInt64](../data-types/int-uint.md)。 +返回 JSON 列中所有路径及其数据类型的映射。 [`Map(String, String)`](/sql-reference/data-types/map) **示例** -查询: - -```sql -CREATE TABLE jsons -( - `json` String -) -ENGINE = Memory; - -INSERT INTO jsons VALUES ('{"foo":"4e3"}'); -INSERT INTO jsons VALUES ('{"foo":3.4}'); -INSERT INTO jsons VALUES ('{"foo":5}'); -INSERT INTO jsons VALUES ('{"foo":"not1number"}'); -INSERT INTO jsons VALUES ('{"baz":2}'); +**用法示例** -SELECT simpleJSONExtractUInt(json, 'foo') FROM jsons ORDER BY json; +```sql title=Query +CREATE TABLE test (json JSON(max_dynamic_paths=1)) ENGINE = Memory; +INSERT INTO test FORMAT JSONEachRow {"json" : {"a" : 42}}, {"json" : {"b" : "Hello"}}, {"json" : {"a" : [1, 2, 3], "c" : "2020-01-01"}} +SELECT json, JSONAllPathsWithTypes(json) FROM test; ``` -结果: - -```response -0 -4 -0 -3 -5 +```response title=Response +┌─json─────────────────────────────────┬─JSONAllPathsWithTypes(json)───────────────┐ +│ {"a":"42"} │ {'a':'Int64'} │ +│ {"b":"Hello"} │ {'b':'String'} │ +│ {"a":["1","2","3"],"c":"2020-01-01"} │ {'a':'Array(Nullable(Int64))','c':'Date'} │ +└──────────────────────────────────────┴───────────────────────────────────────────┘ ``` +## JSONArrayLength {#JSONArrayLength} + +引入版本:v23.2 -### simpleJSONExtractInt {#simplejsonextractint} -从名为 `field_name` 的字段值解析 `Int64`。如果这是一个字符串字段,它会尝试从字符串的开头解析一个数字。如果字段不存在,或者字段存在但不包含数字,则返回 `0`。 +返回最外层 JSON 数组中的元素数量。 +如果输入的 JSON 字符串无效,函数将返回 `NULL`。 + **语法** ```sql -simpleJSONExtractInt(json, field_name) +JSONArrayLength(json) ``` -别名: `visitParamExtractInt`。 - **参数** -- `json` — 要搜索字段的 JSON。 [String](/sql-reference/data-types/string) -- `field_name` — 要搜索的字段的名称。 [String literal](/sql-reference/syntax#string) +- `json` — 有效 JSON 的字符串。 [`String`](/sql-reference/data-types/string) + **返回值** -- 如果字段存在并且包含数字,则返回从字段解析出的数字, 否则返回 `0`。 [Int64](../data-types/int-uint.md)。 +如果 `json` 是有效的 JSON 数组字符串,则返回数组元素的数量;否则返回 `NULL`。 [`Nullable(UInt64)`](/sql-reference/data-types/nullable) **示例** -查询: - -```sql -CREATE TABLE jsons -( - `json` String -) -ENGINE = Memory; - -INSERT INTO jsons VALUES ('{"foo":"-4e3"}'); -INSERT INTO jsons VALUES ('{"foo":-3.4}'); -INSERT INTO jsons VALUES ('{"foo":5}'); -INSERT INTO jsons VALUES ('{"foo":"not1number"}'); -INSERT INTO jsons VALUES ('{"baz":2}'); +**用法示例** -SELECT simpleJSONExtractInt(json, 'foo') FROM jsons ORDER BY json; +```sql title=Query +SELECT + JSONArrayLength(''), + JSONArrayLength('[1,2,3]'); ``` -结果: - -```response -0 --4 -0 --3 -5 +```response title=Response +┌─JSONArrayLength('')─┬─JSONArrayLength('[1,2,3]')─┐ +│ ᴺᵁᴸᴸ │ 3 │ +└─────────────────────┴────────────────────────────┘ ``` +## JSONDynamicPaths {#JSONDynamicPaths} -### simpleJSONExtractFloat {#simplejsonextractfloat} +引入版本:v24.8 -从名为 `field_name` 的字段值解析 `Float64`。如果这是一个字符串字段,它会尝试从字符串的开头解析一个数字。如果字段不存在,或者字段存在但不包含数字,则返回 `0`。 + +返回作为单独子列存储在 JSON 列中的动态路径列表。 + **语法** ```sql -simpleJSONExtractFloat(json, field_name) +JSONDynamicPaths(json) ``` -别名: `visitParamExtractFloat`。 - **参数** -- `json` — 要搜索字段的 JSON。 [String](/sql-reference/data-types/string) -- `field_name` — 要搜索的字段的名称。 [String literal](/sql-reference/syntax#string) +- `json` — JSON 列。 [`JSON`](/sql-reference/data-types/newjson) + **返回值** -- 如果字段存在并且包含数字,则返回从字段解析出的数字, 否则返回 `0`。 [Float64](/sql-reference/data-types/float)。 +返回 JSON 列中的动态路径数组。 [`Array(String)`](/sql-reference/data-types/array) **示例** -查询: - -```sql -CREATE TABLE jsons -( - `json` String -) -ENGINE = Memory; - -INSERT INTO jsons VALUES ('{"foo":"-4e3"}'); -INSERT INTO jsons VALUES ('{"foo":-3.4}'); -INSERT INTO jsons VALUES ('{"foo":5}'); -INSERT INTO jsons VALUES ('{"foo":"not1number"}'); -INSERT INTO jsons VALUES ('{"baz":2}'); +**用法示例** -SELECT simpleJSONExtractFloat(json, 'foo') FROM jsons ORDER BY json; +```sql title=Query +CREATE TABLE test (json JSON(max_dynamic_paths=1)) ENGINE = Memory; +INSERT INTO test FORMAT JSONEachRow {"json" : {"a" : 42}}, {"json" : {"b" : "Hello"}}, {"json" : {"a" : [1, 2, 3], "c" : "2020-01-01"}} +SELECT json, JSONDynamicPaths(json) FROM test; ``` -结果: - -```response -0 --4000 -0 --3.4 -5 +```response title=Response +┌─json─────────────────────────────────┬─JSONDynamicPaths(json)─┐ +│ {"a":"42"} │ ['a'] │ +│ {"b":"Hello"} │ [] │ +│ {"a":["1","2","3"],"c":"2020-01-01"} │ ['a'] │ +└──────────────────────────────────────┴────────────────────────┘ ``` +## JSONDynamicPathsWithTypes {#JSONDynamicPathsWithTypes} + +引入版本:v24.8 -### simpleJSONExtractBool {#simplejsonextractbool} -从名为 `field_name` 的字段值解析 true/false 值。结果为 `UInt8`。 +返回作为单独子列存储在 JSON 列中的动态路径及其类型的列表。 + **语法** ```sql -simpleJSONExtractBool(json, field_name) +JSONDynamicPathsWithTypes(json) ``` -别名: `visitParamExtractBool`。 - **参数** -- `json` — 要搜索字段的 JSON。 [String](/sql-reference/data-types/string) -- `field_name` — 要搜索的字段的名称。 [String literal](/sql-reference/syntax#string) +- `json` — JSON 列。 [`JSON`](/sql-reference/data-types/newjson) + **返回值** -如果字段的值为 `true`,则返回 `1`,否则返回 `0`。这意味着该函数将返回 `0` 包括(而不仅仅是在以下情况下): - - 如果字段不存在。 - - 如果字段包含的值为 “true” 的字符串,例如: `{"field":"true"}`。 - - 如果字段包含的值为 `1` 的数值。 +返回 JSON 列中动态路径及其数据类型的映射。 [`Map(String, String)`](/sql-reference/data-types/map) **示例** -查询: - -```sql -CREATE TABLE jsons -( - `json` String -) -ENGINE = Memory; - -INSERT INTO jsons VALUES ('{"foo":false,"bar":true}'); -INSERT INTO jsons VALUES ('{"foo":"true","qux":1}'); +**用法示例** -SELECT simpleJSONExtractBool(json, 'bar') FROM jsons ORDER BY json; -SELECT simpleJSONExtractBool(json, 'foo') FROM jsons ORDER BY json; +```sql title=Query +CREATE TABLE test (json JSON(max_dynamic_paths=1)) ENGINE = Memory; +INSERT INTO test FORMAT JSONEachRow {"json" : {"a" : 42}}, {"json" : {"b" : "Hello"}}, {"json" : {"a" : [1, 2, 3], "c" : "2020-01-01"}} +SELECT json, JSONDynamicPathsWithTypes(json) FROM test; ``` -结果: - -```response -0 -1 -0 -0 +```response title=Response +┌─json─────────────────────────────────┬─JSONDynamicPathsWithTypes(json)─┐ +│ {"a":"42"} │ {'a':'Int64'} │ +│ {"b":"Hello"} │ {} │ +│ {"a":["1","2","3"],"c":"2020-01-01"} │ {'a':'Array(Nullable(Int64))'} │ +└──────────────────────────────────────┴─────────────────────────────────┘ ``` +## JSONExtract {#JSONExtract} + +引入版本:v19.14 -### simpleJSONExtractRaw {#simplejsonextractraw} -返回名为 `field_name` 的字段的值作为 `String`,包括分隔符。 +解析 JSON 并提取具有给定 ClickHouse 数据类型的值。 + **语法** ```sql -simpleJSONExtractRaw(json, field_name) +JSONExtract(json, return_type[, indices_or_keys, ...]) ``` -别名: `visitParamExtractRaw`。 - **参数** -- `json` — 要搜索字段的 JSON。 [String](/sql-reference/data-types/string) -- `field_name` — 要搜索的字段的名称。 [String literal](/sql-reference/syntax#string) +- `json` — 要解析的 JSON 字符串。 [`String`](/sql-reference/data-types/string) +- `return_type` — 要返回的 ClickHouse 数据类型。 [`String`](/sql-reference/data-types/string) +- `indices_or_keys` — 一组零个或多个参数,每个参数可以是字符串或整数。 [`String`](/sql-reference/data-types/string) 或 [`(U)Int*`](/sql-reference/data-types/int-uint) + **返回值** -- 如果字段存在,则返回字段的值作为字符串,包括分隔符,否则返回空字符串。 [`String`](/sql-reference/data-types/string) +如果可能,返回指定 ClickHouse 数据类型的值;否则返回该类型的默认值。 **示例** -查询: - -```sql -CREATE TABLE jsons -( - `json` String -) -ENGINE = Memory; - -INSERT INTO jsons VALUES ('{"foo":"-4e3"}'); -INSERT INTO jsons VALUES ('{"foo":-3.4}'); -INSERT INTO jsons VALUES ('{"foo":5}'); -INSERT INTO jsons VALUES ('{"foo":{"def":[1,2,3]}}'); -INSERT INTO jsons VALUES ('{"baz":2}'); +**用法示例** -SELECT simpleJSONExtractRaw(json, 'foo') FROM jsons ORDER BY json; +```sql title=Query +SELECT JSONExtract('{"a": "hello", "b": [-100, 200.0, 300]}', 'Tuple(String, Array(Float64))') AS res; ``` -结果: - -```response - -"-4e3" --3.4 -5 -{"def":[1,2,3]} +```response title=Response +┌─res──────────────────────────────┐ +│ ('hello',[-100,200,300]) │ +└──────────────────────────────────┘ ``` +## JSONExtractArrayRaw {#JSONExtractArrayRaw} -### simpleJSONExtractString {#simplejsonextractstring} +引入版本:v20.1 -从名为 `field_name` 的字段值中解析 `String`(用双引号括起来)。 + +返回 JSON 数组的元素数组,每个元素表示为未解析的字符串。 + **语法** ```sql -simpleJSONExtractString(json, field_name) +JSONExtractArrayRaw(json[, indices_or_keys, ...]) ``` -别名: `visitParamExtractString`。 - **参数** -- `json` — 要搜索字段的 JSON。 [String](/sql-reference/data-types/string) -- `field_name` — 要搜索的字段的名称。 [String literal](/sql-reference/syntax#string) - -**返回值** +- `json` — 要解析的 JSON 字符串。 [`String`](/sql-reference/data-types/string) +- `indices_or_keys` — 一组零个或多个参数,每个参数可以是字符串或整数。 [`String`](/sql-reference/data-types/string) 或 [`(U)Int*`](/sql-reference/data-types/int-uint) -- 返回字段的未转义值作为字符串,包括分隔符。如果字段不包含用双引号括起来的字符串,如果解码失败或字段不存在,则返回空字符串。 [String](../data-types/string.md)。 -**实现细节** +**返回值** -目前不支持格式为 `\uXXXX\uYYYY` 的代码点,它们被转换为 CESU-8,而不是 UTF-8。 +返回包含 JSON 数组元素的字符串数组。如果该部分不是数组或不存在,将返回空数组。 [`Array(String)`](/sql-reference/data-types/array) **示例** -查询: - -```sql -CREATE TABLE jsons -( - `json` String -) -ENGINE = Memory; +**用法示例** -INSERT INTO jsons VALUES ('{"foo":"\\n\\u0000"}'); -INSERT INTO jsons VALUES ('{"foo":"\\u263"}'); -INSERT INTO jsons VALUES ('{"foo":"\\u263a"}'); -INSERT INTO jsons VALUES ('{"foo":"hello}'); +```sql title=Query +SELECT JSONExtractArrayRaw('{"a": "hello", "b": [-100, 200.0, "hello"]}', 'b') AS res; +``` -SELECT simpleJSONExtractString(json, 'foo') FROM jsons ORDER BY json; +```response title=Response +┌─res──────────────────────────┐ +│ ['-100','200.0','"hello"'] │ +└──────────────────────────────┘ ``` +## JSONExtractArrayRawCaseInsensitive {#JSONExtractArrayRawCaseInsensitive} -结果: +引入版本:v25.8 -```response -\n\0 -☺ +返回 JSON 数组的元素数组,每个元素表示为未解析的字符串,并使用不区分大小写的键匹配。此函数与 [`JSONExtractArrayRaw`](#JSONExtractArrayRaw) 类似。 + -``` +**语法** -## JSONExtract functions {#jsonextract-functions} +```sql +JSONExtractArrayRawCaseInsensitive(json [, indices_or_keys]...) +``` -以下函数基于 [simdjson](https://github.com/lemire/simdjson),旨在满足更复杂的 JSON 解析要求。 +**参数** -### isValidJSON {#isvalidjson} +- `json` — 要解析的 JSON 字符串 [`String`](/sql-reference/data-types/string) +- `indices_or_keys` — 可选。 导航到数组的索引或键。 键使用不区分大小写的匹配 [`String`](/sql-reference/data-types/string) 或 [`(U)Int*`](/sql-reference/data-types/int-uint) -检查传递的字符串是否是有效 JSON。 -**语法** +**返回值** -```sql -isValidJSON(json) -``` +返回原始 JSON 字符串的数组。 [`Array(String)`](/sql-reference/data-types/array) **示例** -```sql -SELECT isValidJSON('{"a": "hello", "b": [-100, 200.0, 300]}') = 1 -SELECT isValidJSON('not a json') = 0 +**基本** + +```sql title=Query +SELECT JSONExtractArrayRawCaseInsensitive('{"Items": [1, 2, 3]}', 'ITEMS') +``` + +```response title=Response +['1','2','3'] ``` +## JSONExtractBool {#JSONExtractBool} + +引入版本:v20.1 -### JSONHas {#jsonhas} -如果值在 JSON 文档中存在,将返回 `1`。如果值不存在,将返回 `0`。 +解析 JSON 并提取布尔类型的值。 + **语法** ```sql -JSONHas(json [, indices_or_keys]...) +JSONExtractBool(json[, indices_or_keys, ...]) ``` **参数** -- `json` — 要解析的 JSON 字符串。 [String](../data-types/string.md)。 -- `indices_or_keys` — 一个零个或多个参数的列表,每个参数可以是字符串或整数。 [String](../data-types/string.md), [Int*](../data-types/int-uint.md)。 +- `json` — 要解析的 JSON 字符串。 [`String`](/sql-reference/data-types/string) +- `indices_or_keys` — 一组零个或多个参数,每个参数可以是字符串或整数。 [`String`](/sql-reference/data-types/string) 或 [`(U)Int*`](/sql-reference/data-types/int-uint) -`indices_or_keys` 类型: -- 字符串 = 通过键访问对象成员。 -- 正整数 = 从头开始访问第 n 个成员/键。 -- 负整数 = 从尾部访问第 n 个成员/键。 **返回值** -- 如果值在 `json` 中存在,则返回 `1`,否则返回 `0`。 [UInt8](../data-types/int-uint.md)。 +如果存在,返回布尔值;否则返回 `0`。 [`Bool`](/sql-reference/data-types/boolean) **示例** -查询: +**用法示例** -```sql -SELECT JSONHas('{"a": "hello", "b": [-100, 200.0, 300]}', 'b') = 1 -SELECT JSONHas('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', 4) = 0 +```sql title=Query +SELECT JSONExtractBool('{"passed": true}', 'passed') AS res; ``` -元素的最小索引为 1。因此,元素 0 不存在。您可以使用整数访问 JSON 数组和 JSON 对象。例如: - -```sql -SELECT JSONExtractKey('{"a": "hello", "b": [-100, 200.0, 300]}', 1) = 'a' -SELECT JSONExtractKey('{"a": "hello", "b": [-100, 200.0, 300]}', 2) = 'b' -SELECT JSONExtractKey('{"a": "hello", "b": [-100, 200.0, 300]}', -1) = 'b' -SELECT JSONExtractKey('{"a": "hello", "b": [-100, 200.0, 300]}', -2) = 'a' -SELECT JSONExtractString('{"a": "hello", "b": [-100, 200.0, 300]}', 1) = 'hello' +```response title=Response +┌─res─┐ +│ 1 │ +└─────┘ ``` +## JSONExtractBoolCaseInsensitive {#JSONExtractBoolCaseInsensitive} + +引入版本:v25.8 -### JSONLength {#jsonlength} -返回 JSON 数组或 JSON 对象的长度。如果值不存在或类型不正确,将返回 `0`。 +解析 JSON 并使用不区分大小写的键匹配提取布尔值。此函数与 [`JSONExtractBool`](#JSONExtractBool) 类似。 + **语法** ```sql -JSONLength(json [, indices_or_keys]...) +JSONExtractBoolCaseInsensitive(json [, indices_or_keys]...) ``` **参数** -- `json` — 要解析的 JSON 字符串。 [String](../data-types/string.md)。 -- `indices_or_keys` — 一个零个或多个参数的列表,每个参数可以是字符串或整数。 [String](../data-types/string.md), [Int*](../data-types/int-uint.md)。 +- `json` — 要解析的 JSON 字符串 [`String`](/sql-reference/data-types/string) +- `indices_or_keys` — 可选。 导航到字段的索引或键。 键使用不区分大小写的匹配 [`String`](/sql-reference/data-types/string) 或 [`(U)Int*`](/sql-reference/data-types/int-uint) -`indices_or_keys` 类型: -- 字符串 = 通过键访问对象成员。 -- 正整数 = 从头开始访问第 n 个成员/键。 -- 负整数 = 从尾部访问第 n 个成员/键。 **返回值** -- 返回 JSON 数组或 JSON 对象的长度。如果值不存在或者类型不正确,则返回 `0`。 [UInt64](../data-types/int-uint.md)。 +返回提取的布尔值(1 表示真,0 表示假),如果未找到则返回 0。 [`UInt8`](/sql-reference/data-types/int-uint) **示例** -```sql -SELECT JSONLength('{"a": "hello", "b": [-100, 200.0, 300]}', 'b') = 3 -SELECT JSONLength('{"a": "hello", "b": [-100, 200.0, 300]}') = 2 +**基本** + +```sql title=Query +SELECT JSONExtractBoolCaseInsensitive('{"IsActive": true}', 'isactive') ``` -### JSONType {#jsontype} +```response title=Response +1 +``` +## JSONExtractCaseInsensitive {#JSONExtractCaseInsensitive} + +引入版本:v25.8 + -返回 JSON 值的类型。如果值不存在,将返回 `Null=0`(不是通常的 [Null](../data-types/nullable.md),而是 `Enum8('Null' = 0, 'String' = 34,...`)。 +解析 JSON 并使用不区分大小写的键匹配提取给定 ClickHouse 数据类型的值。此函数与 [`JSONExtract`](#JSONExtract) 类似。 + **语法** ```sql -JSONType(json [, indices_or_keys]...) +JSONExtractCaseInsensitive(json [, indices_or_keys...], return_type) ``` **参数** -- `json` — 要解析的 JSON 字符串。 [String](../data-types/string.md)。 -- `indices_or_keys` — 一个零个或多个参数的列表,每个参数可以是字符串或整数。 [String](../data-types/string.md), [Int*](../data-types/int-uint.md)。 +- `json` — 要解析的 JSON 字符串 [`String`](/sql-reference/data-types/string) +- `indices_or_keys` — 可选。 导航到字段的索引或键。 键使用不区分大小写的匹配 [`String`](/sql-reference/data-types/string) 或 [`(U)Int*`](/sql-reference/data-types/int-uint) +- `return_type` — 要提取的 ClickHouse 数据类型 [`String`](/sql-reference/data-types/string) -`indices_or_keys` 类型: -- 字符串 = 通过键访问对象成员。 -- 正整数 = 从头开始访问第 n 个成员/键。 -- 负整数 = 从尾部访问第 n 个成员/键。 **返回值** -- 返回 JSON 值的类型作为字符串,如果值不存在则返回 `Null=0`。 [Enum](../data-types/enum.md)。 +以指定数据类型返回提取的值。 [`Any`](/sql-reference/data-types) **示例** -```sql -SELECT JSONType('{"a": "hello", "b": [-100, 200.0, 300]}') = 'Object' -SELECT JSONType('{"a": "hello", "b": [-100, 200.0, 300]}', 'a') = 'String' -SELECT JSONType('{"a": "hello", "b": [-100, 200.0, 300]}', 'b') = 'Array' +**int_type** + +```sql title=Query +SELECT JSONExtractCaseInsensitive('{"Number": 123}', 'number', 'Int32') +``` + +```response title=Response +123 ``` -### JSONExtractUInt {#jsonextractuint} +**array_type** -解析 JSON 并提取 UInt 类型的值。 +```sql title=Query +SELECT JSONExtractCaseInsensitive('{"List": [1, 2, 3]}', 'list', 'Array(Int32)') +``` + +```response title=Response +[1,2,3] +``` +## JSONExtractFloat {#JSONExtractFloat} + +引入版本:v20.1 + + +解析 JSON 并提取浮点类型的值。 + **语法** ```sql -JSONExtractUInt(json [, indices_or_keys]...) +JSONExtractFloat(json[, indices_or_keys, ...]) ``` **参数** -- `json` — 要解析的 JSON 字符串。 [String](../data-types/string.md)。 -- `indices_or_keys` — 一个零个或多个参数的列表,每个参数可以是字符串或整数。 [String](../data-types/string.md), [Int*](../data-types/int-uint.md)。 +- `json` — 要解析的 JSON 字符串。 [`String`](/sql-reference/data-types/string) +- `indices_or_keys` — 一组零个或多个参数,每个参数可以是字符串或整数。 [`String`](/sql-reference/data-types/string) 或 [`(U)Int*`](/sql-reference/data-types/int-uint) -`indices_or_keys` 类型: -- 字符串 = 通过键访问对象成员。 -- 正整数 = 从头开始访问第 n 个成员/键。 -- 负整数 = 从尾部访问第 n 个成员/键。 **返回值** -- 如果存在,则返回 UInt 值,否则返回 `0`。 [UInt64](../data-types/int-uint.md)。 +如果存在,返回浮点值;否则返回 `0`。 [`Float64`](/sql-reference/data-types/float) **示例** -查询: +**用法示例** -```sql -SELECT JSONExtractUInt('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', -1) as x, toTypeName(x); +```sql title=Query +SELECT JSONExtractFloat('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', 2) AS res; ``` -结果: - -```response -┌───x─┬─toTypeName(x)─┐ -│ 300 │ UInt64 │ -└─────┴───────────────┘ +```response title=Response +┌─res─┐ +│ 200 │ +└─────┘ ``` +## JSONExtractFloatCaseInsensitive {#JSONExtractFloatCaseInsensitive} -### JSONExtractInt {#jsonextractint} +引入版本:v25.8 -解析 JSON 并提取 Int 类型的值。 + +解析 JSON 并使用不区分大小写的键匹配提取浮点值。此函数与 [`JSONExtractFloat`](#JSONExtractFloat) 类似。 + **语法** ```sql -JSONExtractInt(json [, indices_or_keys]...) +JSONExtractFloatCaseInsensitive(json [, indices_or_keys]...) ``` **参数** -- `json` — 要解析的 JSON 字符串。 [String](../data-types/string.md)。 -- `indices_or_keys` — 一个零个或多个参数的列表,每个参数可以是字符串或整数。 [String](../data-types/string.md), [Int*](../data-types/int-uint.md)。 +- `json` — 要解析的 JSON 字符串 [`String`](/sql-reference/data-types/string) +- `indices_or_keys` — 可选。 导航到字段的索引或键。 键使用不区分大小写的匹配 [`String`](/sql-reference/data-types/string) 或 [`(U)Int*`](/sql-reference/data-types/int-uint) -`indices_or_keys` 类型: -- 字符串 = 通过键访问对象成员。 -- 正整数 = 从头开始访问第 n 个成员/键。 -- 负整数 = 从尾部访问第 n 个成员/键。 **返回值** -- 如果存在,则返回 Int 值,否则返回 `0`。 [Int64](../data-types/int-uint.md)。 +返回提取的浮点值,如果未找到或无法转换则返回 0。 [`Float64`](/sql-reference/data-types/float) **示例** -查询: +**基本** -```sql -SELECT JSONExtractInt('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', -1) as x, toTypeName(x); +```sql title=Query +SELECT JSONExtractFloatCaseInsensitive('{"Price": 12.34}', 'PRICE') ``` -结果: - -```response -┌───x─┬─toTypeName(x)─┐ -│ 300 │ Int64 │ -└─────┴───────────────┘ +```response title=Response +12.34 ``` +## JSONExtractInt {#JSONExtractInt} + +引入版本:v20.1 -### JSONExtractFloat {#jsonextractfloat} -解析 JSON 并提取 Float 类型的值。 +解析 JSON 并提取整型类型的值。 + **语法** ```sql -JSONExtractFloat(json [, indices_or_keys]...) +JSONExtractInt(json[, indices_or_keys, ...]) ``` **参数** -- `json` — 要解析的 JSON 字符串。 [String](../data-types/string.md)。 -- `indices_or_keys` — 一个零个或多个参数的列表,每个参数可以是字符串或整数。 [String](../data-types/string.md), [Int*](../data-types/int-uint.md)。 +- `json` — 要解析的 JSON 字符串。 [`String`](/sql-reference/data-types/string) +- `indices_or_keys` — 一组零个或多个参数,每个参数可以是字符串或整数。 [`String`](/sql-reference/data-types/string) 或 [`(U)Int*`](/sql-reference/data-types/int-uint) -`indices_or_keys` 类型: -- 字符串 = 通过键访问对象成员。 -- 正整数 = 从头开始访问第 n 个成员/键。 -- 负整数 = 从尾部访问第 n 个成员/键。 **返回值** -- 如果存在,则返回 Float 值,否则返回 `0`。 [Float64](../data-types/float.md)。 +如果存在,返回整型值;否则返回 `0`。 [`Int64`](/sql-reference/data-types/int-uint) **示例** -查询: +**用法示例** -```sql -SELECT JSONExtractFloat('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', 2) as x, toTypeName(x); +```sql title=Query +SELECT JSONExtractInt('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', 1) AS res; ``` -结果: - -```response -┌───x─┬─toTypeName(x)─┐ -│ 200 │ Float64 │ -└─────┴───────────────┘ +```response title=Response +┌─res─┐ +│ 200 │ +└─────┘ ``` +## JSONExtractIntCaseInsensitive {#JSONExtractIntCaseInsensitive} -### JSONExtractBool {#jsonextractbool} +引入版本:v25.8 -解析 JSON 并提取布尔值。如果值不存在或类型不正确,则返回 `0`。 + +解析 JSON 并使用不区分大小写的键匹配提取整型类型的值。此函数与 [`JSONExtractInt`](#JSONExtractInt) 类似。 + **语法** ```sql -JSONExtractBool(json\[, indices_or_keys\]...) +JSONExtractIntCaseInsensitive(json [, indices_or_keys]...) ``` **参数** -- `json` — 要解析的 JSON 字符串。 [String](../data-types/string.md)。 -- `indices_or_keys` — 一个零个或多个参数的列表,每个参数可以是字符串或整数。 [String](../data-types/string.md), [Int*](../data-types/int-uint.md)。 +- `json` — 要解析的 JSON 字符串 [`String`](/sql-reference/data-types/string) +- `indices_or_keys` — 可选。 导航到字段的索引或键。 键使用不区分大小写的匹配 [`String`](/sql-reference/data-types/string) 或 [`(U)Int*`](/sql-reference/data-types/int-uint) -`indices_or_keys` 类型: -- 字符串 = 通过键访问对象成员。 -- 正整数 = 从头开始访问第 n 个成员/键。 -- 负整数 = 从尾部访问第 n 个成员/键。 **返回值** -- 返回布尔值如果存在,否则返回 `0`。 [Bool](../data-types/boolean.md)。 +返回提取的整型值,如果未找到或无法转换则返回 0。 [`Int64`](/sql-reference/data-types/int-uint) **示例** -查询: +**基本** -```sql -SELECT JSONExtractBool('{"passed": true}', 'passed'); +```sql title=Query +SELECT JSONExtractIntCaseInsensitive('{"Value": 123}', 'value') ``` -结果: +```response title=Response +123 +``` + +**嵌套** + +```sql title=Query +SELECT JSONExtractIntCaseInsensitive('{"DATA": {"COUNT": 42}}', 'data', 'Count') +``` -```response -┌─JSONExtractBool('{"passed": true}', 'passed')─┐ -│ 1 │ -└───────────────────────────────────────────────┘ +```response title=Response +42 ``` +## JSONExtractKeys {#JSONExtractKeys} -### JSONExtractString {#jsonextractstring} +引入版本:v21.11 -解析 JSON 并提取字符串。此函数与 [`visitParamExtractString`](#simplejsonextractstring) 函数类似。如果值不存在或类型不正确,将返回空字符串。 + +解析 JSON 字符串并提取键。 + **语法** ```sql -JSONExtractString(json [, indices_or_keys]...) +JSONExtractKeys(json[, indices_or_keys, ...]) ``` **参数** -- `json` — 要解析的 JSON 字符串。 [String](../data-types/string.md)。 -- `indices_or_keys` — 一个零个或多个参数的列表,每个参数可以是字符串或整数。 [String](../data-types/string.md), [Int*](../data-types/int-uint.md)。 +- `json` — 要解析的 JSON 字符串。 [`String`](/sql-reference/data-types/string) +- `indices_or_keys` — 一组零个或多个参数,每个参数可以是字符串或整数。 [`String`](/sql-reference/data-types/string) 或 [`(U)Int*`](/sql-reference/data-types/int-uint) -`indices_or_keys` 类型: -- 字符串 = 通过键访问对象成员。 -- 正整数 = 从头开始访问第 n 个成员/键。 -- 负整数 = 从尾部访问第 n 个成员/键。 **返回值** -- 返回从 `json` 提取的未经转义的字符串。如果解码失败,如果值不存在或类型不正确,则返回空字符串。 [String](../data-types/string.md)。 +返回 JSON 对象的键数组。 [`Array(String)`](/sql-reference/data-types/array) **示例** -```sql -SELECT JSONExtractString('{"a": "hello", "b": [-100, 200.0, 300]}', 'a') = 'hello' -SELECT JSONExtractString('{"abc":"\\n\\u0000"}', 'abc') = '\n\0' -SELECT JSONExtractString('{"abc":"\\u263a"}', 'abc') = '☺' -SELECT JSONExtractString('{"abc":"\\u263"}', 'abc') = '' -SELECT JSONExtractString('{"abc":"hello}', 'abc') = '' +**用法示例** + +```sql title=Query +SELECT JSONExtractKeys('{"a": "hello", "b": [-100, 200.0, 300]}') AS res; ``` -### JSONExtract {#jsonextract} +```response title=Response +┌─res─────────┐ +│ ['a','b'] │ +└─────────────┘ +``` +## JSONExtractKeysAndValues {#JSONExtractKeysAndValues} + +引入版本:v20.1 -解析 JSON 并提取指定 ClickHouse 数据类型的值。此函数是前面 `JSONExtract` 函数的通用版本。含义: -`JSONExtract(..., 'String')` 返回与 `JSONExtractString()` 完全相同, -`JSONExtract(..., 'Float64')` 返回与 `JSONExtractFloat()` 完全相同。 +解析 JSON 中的键值对,其中值为给定的 ClickHouse 数据类型。 + **语法** ```sql -JSONExtract(json [, indices_or_keys...], return_type) +JSONExtractKeysAndValues(json, value_type[, indices_or_keys, ...]) ``` **参数** -- `json` — 要解析的 JSON 字符串。 [String](../data-types/string.md)。 -- `indices_or_keys` — 一个零个或多个参数的列表,每个参数可以是字符串或整数。 [String](../data-types/string.md), [Int*](../data-types/int-uint.md)。 -- `return_type` — 指定要提取的值类型的字符串。 [String](../data-types/string.md)。 +- `json` — 要解析的 JSON 字符串。 [`String`](/sql-reference/data-types/string) +- `value_type` — 值的 ClickHouse 数据类型。 [`String`](/sql-reference/data-types/string) +- `indices_or_keys` — 一组零个或多个参数,每个参数可以是字符串或整数。 [`String`](/sql-reference/data-types/string) 或 [`(U)Int*`](/sql-reference/data-types/int-uint) -`indices_or_keys` 类型: -- 字符串 = 通过键访问对象成员。 -- 正整数 = 从头开始访问第 n 个成员/键。 -- 负整数 = 从尾部访问第 n 个成员/键。 **返回值** -- 返回指定返回类型的值(如果存在),否则会根据指定的返回类型返回 `0`、`Null` 或空字符串。 [UInt64](../data-types/int-uint.md)、[Int64](../data-types/int-uint.md)、[Float64](../data-types/float.md)、[Bool](../data-types/boolean.md) 或 [String](../data-types/string.md)。 +返回解析的键值对的元组数组。 [`Array(Tuple(String, value_type))`](/sql-reference/data-types/array) **示例** -```sql -SELECT JSONExtract('{"a": "hello", "b": [-100, 200.0, 300]}', 'Tuple(String, Array(Float64))') = ('hello',[-100,200,300]) -SELECT JSONExtract('{"a": "hello", "b": [-100, 200.0, 300]}', 'Tuple(b Array(Float64), a String)') = ([-100,200,300],'hello') -SELECT JSONExtract('{"a": "hello", "b": "world"}', 'Map(String, String)') = map('a', 'hello', 'b', 'world'); -SELECT JSONExtract('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', 'Array(Nullable(Int8))') = [-100, NULL, NULL] -SELECT JSONExtract('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', 4, 'Nullable(Int64)') = NULL -SELECT JSONExtract('{"passed": true}', 'passed', 'UInt8') = 1 -SELECT JSONExtract('{"day": "Thursday"}', 'day', 'Enum8(\'Sunday\' = 0, \'Monday\' = 1, \'Tuesday\' = 2, \'Wednesday\' = 3, \'Thursday\' = 4, \'Friday\' = 5, \'Saturday\' = 6)') = 'Thursday' -SELECT JSONExtract('{"day": 5}', 'day', 'Enum8(\'Sunday\' = 0, \'Monday\' = 1, \'Tuesday\' = 2, \'Wednesday\' = 3, \'Thursday\' = 4, \'Friday\' = 5, \'Saturday\' = 6)') = 'Friday' -``` +**用法示例** -通过传递多个 indices_or_keys 参数引用嵌套值: -```sql -SELECT JSONExtract('{"a":{"b":"hello","c":{"d":[1,2,3],"e":[1,3,7]}}}','a','c','Map(String, Array(UInt8))') AS val, toTypeName(val), val['d']; +```sql title=Query +SELECT JSONExtractKeysAndValues('{"x": {"a": 5, "b": 7, "c": 11}}', 'Int8', 'x') AS res; ``` -结果: -```response -┌─val───────────────────────┬─toTypeName(val)───────────┬─arrayElement(val, 'd')─┐ -│ {'d':[1,2,3],'e':[1,3,7]} │ Map(String, Array(UInt8)) │ [1,2,3] │ -└───────────────────────────┴───────────────────────────┴────────────────────────┘ + +```response title=Response +┌─res────────────────────┐ +│ [('a',5),('b',7),('c',11)] │ +└────────────────────────┘ ``` +## JSONExtractKeysAndValuesCaseInsensitive {#JSONExtractKeysAndValuesCaseInsensitive} -### JSONExtractKeysAndValues {#jsonextractkeysandvalues} +引入版本:v25.8 -从 JSON 中解析键值对,其中值是指定的 ClickHouse 数据类型。 + +使用不区分大小写的键匹配从 JSON 中解析键值对。此函数与 [`JSONExtractKeysAndValues`](#JSONExtractKeysAndValues) 类似。 + **语法** ```sql -JSONExtractKeysAndValues(json [, indices_or_keys...], value_type) +JSONExtractKeysAndValuesCaseInsensitive(json [, indices_or_keys...], value_type) ``` **参数** -- `json` — 要解析的 JSON 字符串。 [String](../data-types/string.md)。 -- `indices_or_keys` — 一个零个或多个参数的列表,每个参数可以是字符串或整数。 [String](../data-types/string.md), [Int*](../data-types/int-uint.md)。 -- `value_type` — 指定要提取的值的类型的字符串。 [String](../data-types/string.md)。 +- `json` — 要解析的 JSON 字符串 [`String`](/sql-reference/data-types/string) +- `indices_or_keys` — 可选。 导航到对象的索引或键。 键使用不区分大小写的匹配 [`String`](/sql-reference/data-types/string) 或 [`(U)Int*`](/sql-reference/data-types/int-uint) +- `value_type` — 值的 ClickHouse 数据类型 [`String`](/sql-reference/data-types/string) -`indices_or_keys` 类型: -- 字符串 = 通过键访问对象成员。 -- 正整数 = 从头开始访问第 n 个成员/键。 -- 负整数 = 从尾部访问第 n 个成员/键。 **返回值** -- 返回解析的键值对数组。 [Array](../data-types/array.md)([Tuple](../data-types/tuple.md)(`value_type`))。 +返回包含键值对的元组数组。 [`Array(Tuple(String, T))`](/sql-reference/data-types/array) **示例** -```sql -SELECT JSONExtractKeysAndValues('{"x": {"a": 5, "b": 7, "c": 11}}', 'x', 'Int8') = [('a',5),('b',7),('c',11)]; +**基本** + +```sql title=Query +SELECT JSONExtractKeysAndValuesCaseInsensitive('{"Name": "Alice", "AGE": 30}', 'String') +``` + +```response title=Response +[('Name','Alice'),('AGE','30')] ``` +## JSONExtractKeysAndValuesRaw {#JSONExtractKeysAndValuesRaw} -### JSONExtractKeys {#jsonextractkeys} +引入版本:v20.4 -解析 JSON 字符串并提取键。 + +返回包含来自 JSON 对象的键和值的元组数组。所有值表示为未解析的字符串。 + **语法** ```sql -JSONExtractKeys(json[, a, b, c...]) +JSONExtractKeysAndValuesRaw(json[, indices_or_keys, ...]) ``` **参数** -- `json` — [String](../data-types/string.md) 有效 JSON。 -- `a, b, c...` — 逗号分隔的索引或键,指定在嵌套 JSON 对象中内部字段的路径。每个参数可以是 [String](../data-types/string.md)通过键获取字段,或 [Integer](../data-types/int-uint.md) 获取第 N 个字段(从 1 开始索引,负整数从结尾计数)。如果未设置,则将整个 JSON 作为顶级对象解析。可选参数。 +- `json` — 要解析的 JSON 字符串。 [`String`](/sql-reference/data-types/string) +- `indices_or_keys` — 一组零个或多个参数,每个参数可以是字符串或整数。 [`String`](/sql-reference/data-types/string) 或 [`(U)Int*`](/sql-reference/data-types/int-uint) + **返回值** -- 返回 JSON 的键数组。 [Array](../data-types/array.md)([String](../data-types/string.md))。 +返回解析的键值对的元组数组,值为未解析的字符串。 [`Array(Tuple(String, String))`](/sql-reference/data-types/array) **示例** -查询: +**用法示例** -```sql -SELECT JSONExtractKeys('{"a": "hello", "b": [-100, 200.0, 300]}'); +```sql title=Query +SELECT JSONExtractKeysAndValuesRaw('{"a": [-100, 200.0], "b": "hello"}') AS res; ``` -结果: - -```response -┌─JSONExtractKeys('{"a": "hello", "b": [-100, 200.0, 300]}')─┐ -│ ['a','b'] │ -└────────────────────────────────────────────────────────────┘ +```response title=Response +┌─res──────────────────────────────────┐ +│ [('a','[-100,200.0]'),('b','"hello"')] │ +└──────────────────────────────────────┘ ``` +## JSONExtractKeysAndValuesRawCaseInsensitive {#JSONExtractKeysAndValuesRawCaseInsensitive} -### JSONExtractRaw {#jsonextractraw} +引入版本:v25.8 -将 JSON 的一部分作为未解析的字符串返回。如果该部分不存在或类型不正确,则返回空字符串。 + +使用不区分大小写的键匹配从 JSON 中提取原始键值对。此函数与 [`JSONExtractKeysAndValuesRaw`](#JSONExtractKeysAndValuesRaw) 类似。 + **语法** ```sql -JSONExtractRaw(json [, indices_or_keys]...) +JSONExtractKeysAndValuesRawCaseInsensitive(json [, indices_or_keys]...) ``` **参数** -- `json` — 要解析的 JSON 字符串。 [String](../data-types/string.md)。 -- `indices_or_keys` — 一个零个或多个参数的列表,每个参数可以是字符串或整数。 [String](../data-types/string.md), [Int*](../data-types/int-uint.md)。 +- `json` — 要解析的 JSON 字符串 [`String`](/sql-reference/data-types/string) +- `indices_or_keys` — 可选。 导航到对象的索引或键。 键使用不区分大小写的匹配 [`String`](/sql-reference/data-types/string) 或 [`(U)Int*`](/sql-reference/data-types/int-uint) -`indices_or_keys` 类型: -- 字符串 = 通过键访问对象成员。 -- 正整数 = 从头开始访问第 n 个成员/键。 -- 负整数 = 从尾部访问第 n 个成员/键。 **返回值** -- 将 JSON 的一部分作为未解析的字符串返回。如果该部分不存在或类型不正确,则返回空字符串。 [String](../data-types/string.md)。 +返回包含原始字符串形式的键值对的元组数组。 [`Array(Tuple(String, String))`](/sql-reference/data-types/array) **示例** -```sql -SELECT JSONExtractRaw('{"a": "hello", "b": [-100, 200.0, 300]}', 'b') = '[-100, 200.0, 300]'; +**基本** + +```sql title=Query +SELECT JSONExtractKeysAndValuesRawCaseInsensitive('{"Name": "Alice", "AGE": 30}') +``` + +```response title=Response +[('Name','"Alice"'),('AGE','30')] ``` +## JSONExtractKeysCaseInsensitive {#JSONExtractKeysCaseInsensitive} + +引入版本:v25.8 -### JSONExtractArrayRaw {#jsonextractarrayraw} -返回 JSON 数组的元素数组,每个元素表示为未解析的字符串。如果该部分不存在或不是数组,则返回空数组。 +解析 JSON 字符串并使用不区分大小写的键匹配提取键,以导航到嵌套对象。此函数与 [`JSONExtractKeys`](#JSONExtractKeys) 类似。 + **语法** ```sql -JSONExtractArrayRaw(json [, indices_or_keys...]) +JSONExtractKeysCaseInsensitive(json [, indices_or_keys]...) ``` **参数** -- `json` — 要解析的 JSON 字符串。 [String](../data-types/string.md)。 -- `indices_or_keys` — 一个零个或多个参数的列表,每个参数可以是字符串或整数。 [String](../data-types/string.md), [Int*](../data-types/int-uint.md)。 +- `json` — 要解析的 JSON 字符串 [`String`](/sql-reference/data-types/string) +- `indices_or_keys` — 可选。 导航到对象的索引或键。 键使用不区分大小写的匹配 [`String`](/sql-reference/data-types/string) 或 [`(U)Int*`](/sql-reference/data-types/int-uint) -`indices_or_keys` 类型: -- 字符串 = 通过键访问对象成员。 -- 正整数 = 从头开始访问第 n 个成员/键。 -- 负整数 = 从尾部访问第 n 个成员/键。 **返回值** -- 返回 JSON 数组的元素数组,每个元素表示为未解析的字符串。否则,如果该部分不存在或不是数组,则返回空数组。 [Array](../data-types/array.md)([String](../data-types/string.md))。 +返回 JSON 对象中的键数组。 [`Array(String)`](/sql-reference/data-types/array) **示例** -```sql -SELECT JSONExtractArrayRaw('{"a": "hello", "b": [-100, 200.0, "hello"]}', 'b') = ['-100', '200.0', '"hello"']; +**基本** + +```sql title=Query +SELECT JSONExtractKeysCaseInsensitive('{"Name": "Alice", "AGE": 30}') ``` -### JSONExtractKeysAndValuesRaw {#jsonextractkeysandvaluesraw} +```response title=Response +['Name','AGE'] +``` + +**嵌套** + +```sql title=Query +SELECT JSONExtractKeysCaseInsensitive('{"User": {"name": "John", "AGE": 25}}', 'user') +``` + +```response title=Response +['name','AGE'] +``` +## JSONExtractRaw {#JSONExtractRaw} + +引入版本:v20.1 + -从 JSON 对象中提取原始数据。 +返回 JSON 的一部分作为未解析的字符串。 + **语法** ```sql -JSONExtractKeysAndValuesRaw(json[, p, a, t, h]) +JSONExtractRaw(json[, indices_or_keys, ...]) ``` **参数** -- `json` — [String](../data-types/string.md) 有效 JSON。 -- `p, a, t, h` — 逗号分隔的索引或键,指定在嵌套 JSON 对象中内部字段的路径。每个参数可以是 [string](../data-types/string.md) 通过键获取字段,或 [integer](../data-types/int-uint.md) 获取第 N 个字段(从 1 开始索引,负整数从结尾计数)。如果未设置,则整个 JSON 作为顶级对象解析。可选参数。 +- `json` — 要解析的 JSON 字符串。 [`String`](/sql-reference/data-types/string) +- `indices_or_keys` — 一组零个或多个参数,每个参数可以是字符串或整数。 [`String`](/sql-reference/data-types/string) 或 [`(U)Int*`](/sql-reference/data-types/int-uint) + **返回值** -- 返回 `('key', 'value')` 元组的数组。两个元组成员都为字符串。 [Array](../data-types/array.md)([Tuple](../data-types/tuple.md)([String](../data-types/string.md), [String](../data-types/string.md)))。 -- 如果请求的对象不存在,或输入 JSON 无效,则返回空数组。 [Array](../data-types/array.md)([Tuple](../data-types/tuple.md)([String](../data-types/string.md), [String](../data-types/string.md)))。 +以未解析字符串的形式返回 JSON 的部分。如果部分不存在或类型错误,则返回空字符串。 [`String`](/sql-reference/data-types/string) **示例** -查询: +**用法示例** -```sql -SELECT JSONExtractKeysAndValuesRaw('{"a": [-100, 200.0], "b":{"c": {"d": "hello", "f": "world"}}}'); +```sql title=Query +SELECT JSONExtractRaw('{"a": "hello", "b": [-100, 200.0, 300]}', 'b') AS res; ``` -结果: - -```text -┌─JSONExtractKeysAndValuesRaw('{"a": [-100, 200.0], "b":{"c": {"d": "hello", "f": "world"}}}')─┐ -│ [('a','[-100,200]'),('b','{"c":{"d":"hello","f":"world"}}')] │ -└──────────────────────────────────────────────────────────────────────────────────────────────┘ +```response title=Response +┌─res──────────────┐ +│ [-100,200.0,300] │ +└──────────────────┘ ``` +## JSONExtractRawCaseInsensitive {#JSONExtractRawCaseInsensitive} + +引入版本:v25.8 -查询: + +返回 JSON 的一部分作为未解析的字符串,并使用不区分大小写的键匹配。此函数与 [`JSONExtractRaw`](#JSONExtractRaw) 类似。 + + +**语法** ```sql -SELECT JSONExtractKeysAndValuesRaw('{"a": [-100, 200.0], "b":{"c": {"d": "hello", "f": "world"}}}', 'b'); +JSONExtractRawCaseInsensitive(json [, indices_or_keys]...) ``` -结果: +**参数** + +- `json` — 要解析的 JSON 字符串 [`String`](/sql-reference/data-types/string) +- `indices_or_keys` — 可选。 导航到字段的索引或键。 键使用不区分大小写的匹配 [`String`](/sql-reference/data-types/string) 或 [`(U)Int*`](/sql-reference/data-types/int-uint) -```text -┌─JSONExtractKeysAndValuesRaw('{"a": [-100, 200.0], "b":{"c": {"d": "hello", "f": "world"}}}', 'b')─┐ -│ [('c','{"d":"hello","f":"world"}')] │ -└───────────────────────────────────────────────────────────────────────────────────────────────────┘ -``` -查询: +**返回值** -```sql -SELECT JSONExtractKeysAndValuesRaw('{"a": [-100, 200.0], "b":{"c": {"d": "hello", "f": "world"}}}', -1, 'c'); -``` +返回提取元素的原始 JSON 字符串。 [`String`](/sql-reference/data-types/string) + +**示例** + +**对象** -结果: +```sql title=Query +SELECT JSONExtractRawCaseInsensitive('{"Object": {"key": "value"}}', 'OBJECT') +``` -```text -┌─JSONExtractKeysAndValuesRaw('{"a": [-100, 200.0], "b":{"c": {"d": "hello", "f": "world"}}}', -1, 'c')─┐ -│ [('d','"hello"'),('f','"world"')] │ -└───────────────────────────────────────────────────────────────────────────────────────────────────────┘ +```response title=Response +{"key":"value"} ``` +## JSONExtractString {#JSONExtractString} + +引入版本:v20.1 -### JSON_EXISTS {#json_exists} -如果值在 JSON 文档中存在,则返回 `1`。如果值不存在,则返回 `0`。 +解析 JSON 并提取字符串类型的值。 + **语法** ```sql -JSON_EXISTS(json, path) +JSONExtractString(json[, indices_or_keys, ...]) ``` **参数** -- `json` — 有效 JSON 的字符串。 [String](../data-types/string.md)。 -- `path` — 表示路径的字符串。 [String](../data-types/string.md)。 +- `json` — 要解析的 JSON 字符串。 [`String`](/sql-reference/data-types/string) +- `indices_or_keys` — 一组零个或多个参数,每个参数可以是字符串或整数。 [`String`](/sql-reference/data-types/string) 或 [`(U)Int*`](/sql-reference/data-types/int-uint) -:::note -在 21.11 版本之前,参数的顺序是错误的,即 JSON_EXISTS(path, json) -::: **返回值** -- 如果值存在于 JSON 文档中,则返回 `1`,否则返回 `0`。 +如果存在,返回字符串类型的值;否则返回空字符串。 [`String`](/sql-reference/data-types/string) **示例** -```sql -SELECT JSON_EXISTS('{"hello":1}', '$.hello'); -SELECT JSON_EXISTS('{"hello":{"world":1}}', '$.hello.world'); -SELECT JSON_EXISTS('{"hello":["world"]}', '$.hello[*]'); -SELECT JSON_EXISTS('{"hello":["world"]}', '$.hello[0]'); +**用法示例** + +```sql title=Query +SELECT JSONExtractString('{"a": "hello", "b": [-100, 200.0, 300]}', 'a') AS res; +``` + +```response title=Response +┌─res───┐ +│ hello │ +└───────┘ ``` +## JSONExtractStringCaseInsensitive {#JSONExtractStringCaseInsensitive} + +引入版本:v25.8 -### JSON_QUERY {#json_query} -解析 JSON 并将值提取为 JSON 数组或 JSON 对象。如果值不存在,则返回空字符串。 +解析 JSON 并使用不区分大小写的键匹配提取字符串。此函数与 [`JSONExtractString`](#JSONExtractString) 类似。 + **语法** ```sql -JSON_QUERY(json, path) +JSONExtractStringCaseInsensitive(json [, indices_or_keys]...) ``` **参数** -- `json` — 有效 JSON 的字符串。 [String](../data-types/string.md)。 -- `path` — 表示路径的字符串。 [String](../data-types/string.md)。 +- `json` — 要解析的 JSON 字符串 [`String`](/sql-reference/data-types/string) +- `indices_or_keys` — 可选。 导航到字段的索引或键。 键使用不区分大小写的匹配 [`String`](/sql-reference/data-types/string) 或 [`(U)Int*`](/sql-reference/data-types/int-uint) -:::note -在 21.11 版本之前,参数的顺序是错误的,即 JSON_EXISTS(path, json) -::: **返回值** -- 返回提取的 JSON 数组或 JSON 对象的值。否则,如果值不存在,则返回空字符串。 [String](../data-types/string.md)。 +返回提取的字符串值,如果未找到则返回空字符串。 [`String`](/sql-reference/data-types/string) **示例** -查询: +**基本** -```sql -SELECT JSON_QUERY('{"hello":"world"}', '$.hello'); -SELECT JSON_QUERY('{"array":[[0, 1, 2, 3, 4, 5], [0, -1, -2, -3, -4, -5]]}', '$.array[*][0 to 2, 4]'); -SELECT JSON_QUERY('{"hello":2}', '$.hello'); -SELECT toTypeName(JSON_QUERY('{"hello":2}', '$.hello')); +```sql title=Query +SELECT JSONExtractStringCaseInsensitive('{"ABC": "def"}', 'abc') ``` -结果: +```response title=Response +def +``` -```text -["world"] -[0, 1, 4, 0, -1, -4] -[2] -String +**嵌套** + +```sql title=Query +SELECT JSONExtractStringCaseInsensitive('{"User": {"Name": "John"}}', 'user', 'name') ``` -### JSON_VALUE {#json_value} +```response title=Response +John +``` +## JSONExtractUInt {#JSONExtractUInt} -解析 JSON 并提取值作为 JSON 标量。如果值不存在,默认情况下返回空字符串。 +引入版本:v20.1 -此函数受以下设置控制: -- 通过 SET `function_json_value_return_type_allow_nullable` = `true`,将返回 `NULL`。如果值是复杂类型(例如:结构、数组、映射),将默认返回空字符串。 -- 通过 SET `function_json_value_return_type_allow_complex` = `true`,将返回复杂值。 +解析 JSON 并提取无符号整型类型的值。 + **语法** ```sql -JSON_VALUE(json, path) +JSONExtractUInt(json [, indices_or_keys, ...]) ``` **参数** -- `json` — 有效 JSON 的字符串。 [String](../data-types/string.md)。 -- `path` — 表示路径的字符串。 [String](../data-types/string.md)。 +- `json` — 要解析的 JSON 字符串。 [`String`](/sql-reference/data-types/string) +- `indices_or_keys` — 一组零个或多个参数,每个参数可以是字符串或整数。 [`String`](/sql-reference/data-types/string) 或 [`(U)Int*`](/sql-reference/data-types/int-uint) -:::note -在 21.11 版本之前,参数的顺序是错误的,即 JSON_EXISTS(path, json) -::: **返回值** -- 如果值存在,则作为 JSON 标量返回提取的值,否则返回空字符串。 [String](../data-types/string.md)。 +如果存在,返回无符号整型值;否则返回 `0`。 [`UInt64`](/sql-reference/data-types/int-uint) **示例** -查询: +**用法示例** -```sql -SELECT JSON_VALUE('{"hello":"world"}', '$.hello'); -SELECT JSON_VALUE('{"array":[[0, 1, 2, 3, 4, 5], [0, -1, -2, -3, -4, -5]]}', '$.array[*][0 to 2, 4]'); -SELECT JSON_VALUE('{"hello":2}', '$.hello'); -SELECT toTypeName(JSON_VALUE('{"hello":2}', '$.hello')); -select JSON_VALUE('{"hello":"world"}', '$.b') settings function_json_value_return_type_allow_nullable=true; -select JSON_VALUE('{"hello":{"world":"!"}}', '$.hello') settings function_json_value_return_type_allow_complex=true; +```sql title=Query +SELECT JSONExtractUInt('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', -1) AS res; ``` -结果: - -```text -world -0 -2 -String +```response title=Response +┌─res─┐ +│ 300 │ +└─────┘ ``` +## JSONExtractUIntCaseInsensitive {#JSONExtractUIntCaseInsensitive} -### toJSONString {#tojsonstring} +引入版本:v25.8 -将值序列化为 JSON 表示形式。支持各种数据类型和嵌套结构。 -64 位 [整数](../data-types/int-uint.md) 或更大(如 `UInt64` 或 `Int128`)默认用引号括起来。 [output_format_json_quote_64bit_integers](/operations/settings/formats#output_format_json_quote_64bit_integers) 控制此行为。 -特定值 `NaN` 和 `inf` 被替换为 `null`。启用 [output_format_json_quote_denormals](/operations/settings/formats#output_format_json_quote_denormals) 设置以显示它们。 -在序列化 [Enum](../data-types/enum.md) 值时,函数输出其名称。 + +解析 JSON 并使用不区分大小写的键匹配提取无符号整型类型的值。此函数与 [`JSONExtractUInt`](#JSONExtractUInt) 类似。 + **语法** ```sql -toJSONString(value) +JSONExtractUIntCaseInsensitive(json [, indices_or_keys]...) ``` **参数** -- `value` — 要序列化的值。值可以是任何数据类型。 +- `json` — 要解析的 JSON 字符串 [`String`](/sql-reference/data-types/string) +- `indices_or_keys` — 可选。 导航到字段的索引或键。 键使用不区分大小写的匹配 [`String`](/sql-reference/data-types/string) 或 [`(U)Int*`](/sql-reference/data-types/int-uint) + **返回值** -- 值的 JSON 表示形式。 [String](../data-types/string.md)。 +返回提取的无符号整型值,如果未找到或无法转换则返回 0。 [`UInt64`](/sql-reference/data-types/int-uint) **示例** -第一个示例显示了 [Map](../data-types/map.md) 的序列化。 -第二个示例显示了一些特殊值封装在 [Tuple](../data-types/tuple.md) 中。 +**基本** -查询: +```sql title=Query +SELECT JSONExtractUIntCaseInsensitive('{"COUNT": 789}', 'count') +``` -```sql -SELECT toJSONString(map('key1', 1, 'key2', 2)); -SELECT toJSONString(tuple(1.25, NULL, NaN, +inf, -inf, [])) SETTINGS output_format_json_quote_denormals = 1; +```response title=Response +789 ``` +## JSONHas {#JSONHas} + +引入版本:v20.1 + + +检查 JSON 文档中是否存在提供的值。 + -结果: +**语法** -```text -{"key1":1,"key2":2} -[1.25,null,"nan","inf","-inf",[]] +```sql +JSONHas(json[ ,indices_or_keys, ...]) ``` -**另见** +**参数** -- [output_format_json_quote_64bit_integers](/operations/settings/formats#output_format_json_quote_64bit_integers) -- [output_format_json_quote_denormals](/operations/settings/formats#output_format_json_quote_denormals) +- `json` — 要解析的 JSON 字符串 [`String`](/sql-reference/data-types/string) +- `[ ,indices_or_keys, ...]` — 一组零个或多个参数。 [`String`](/sql-reference/data-types/string) 或 [`(U)Int*`](/sql-reference/data-types/int-uint) + + +**返回值** + +如果在 `json` 中存在该值,则返回 `1`;否则返回 `0`。 [`UInt8`](/sql-reference/data-types/int-uint) + +**示例** + +**用法示例** +```sql title=Query +SELECT JSONHas('{"a": "hello", "b": [-100, 200.0, 300]}', 'b') = 1; +SELECT JSONHas('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', 4) = 0; +``` + +```response title=Response +1 +0 +``` +## JSONLength {#JSONLength} + +引入版本:v20.1 -### JSONArrayLength {#jsonarraylength} -返回最外层 JSON 数组中的元素数量。如果输入 JSON 字符串无效,则函数返回 NULL。 +返回 JSON 数组或 JSON 对象的长度。 +如果值不存在或类型错误,则返回 `0`。 + **语法** ```sql -JSONArrayLength(json) +JSONLength(json [, indices_or_keys, ...]) ``` -别名: `JSON_ARRAY_LENGTH(json)`。 - **参数** -- `json` — [String](../data-types/string.md) 有效 JSON。 +- `json` — 要解析的 JSON 字符串 [`String`](/sql-reference/data-types/string) +- `[, indices_or_keys, ...]` — 可选。一组零个或多个参数。 [`String`](/sql-reference/data-types/string) 或 [`(U)Int8/16/32/64`](/sql-reference/data-types/int-uint) + **返回值** -- 如果 `json` 是有效的 JSON 数组字符串,则返回数组元素的数量,否则返回 NULL。 [Nullable(UInt64)](../data-types/int-uint.md)。 +返回 JSON 数组或 JSON 对象的长度;否则,如果值不存在或类型错误,则返回 `0`。 [`UInt64`](/sql-reference/data-types/int-uint) **示例** -```sql -SELECT - JSONArrayLength(''), - JSONArrayLength('[1,2,3]') +**用法示例** -┌─JSONArrayLength('')─┬─JSONArrayLength('[1,2,3]')─┐ -│ ᴺᵁᴸᴸ │ 3 │ -└─────────────────────┴────────────────────────────┘ +```sql title=Query +SELECT JSONLength('{"a": "hello", "b": [-100, 200.0, 300]}', 'b') = 3; +SELECT JSONLength('{"a": "hello", "b": [-100, 200.0, 300]}') = 2; +``` + +```response title=Response +1 +1 ``` +## JSONMergePatch {#JSONMergePatch} +引入版本:v23.10 -### jsonMergePatch {#jsonmergepatch} -返回合并后的 JSON 对象字符串,合并多个 JSON 对象生成。 +返回由合并多个 JSON 对象形成的合并 JSON 对象字符串。 + **语法** ```sql -jsonMergePatch(json1, json2, ...) +jsonMergePatch(json1[, json2, ...]) ``` **参数** -- `json` — [String](../data-types/string.md) 有效 JSON。 +- `json1[, json2, ...]` — 一个或多个有效 JSON 的字符串。 [`String`](/sql-reference/data-types/string) + **返回值** -- 如果 JSON 对象字符串有效,返回合并后的 JSON 对象字符串。 [String](../data-types/string.md)。 +返回合并的 JSON 对象字符串,如果 JSON 对象字符串有效。 [`String`](/sql-reference/data-types/string) **示例** -```sql -SELECT jsonMergePatch('{"a":1}', '{"name": "joey"}', '{"name": "tom"}', '{"name": "zoey"}') AS res +**用法示例** + +```sql title=Query +SELECT jsonMergePatch('{"a":1}', '{"name": "joey"}', '{"name": "tom"}', '{"name": "zoey"}') AS res; +``` +```response title=Response ┌─res───────────────────┐ │ {"a":1,"name":"zoey"} │ └───────────────────────┘ ``` +## JSONSharedDataPaths {#JSONSharedDataPaths} + +引入版本:v24.8 -### JSONAllPaths {#jsonallpaths} -返回存储在每行的 [JSON](../data-types/newjson.md) 列中的所有路径列表。 +返回存储在 JSON 列共享数据结构中的路径列表。 + **语法** ```sql -JSONAllPaths(json) +JSONSharedDataPaths(json) ``` **参数** -- `json` — [JSON](../data-types/newjson.md)。 +- `json` — JSON 列。 [`JSON`](/sql-reference/data-types/newjson) + **返回值** -- 路径数组。 [Array(String)](../data-types/array.md)。 +返回存储在 JSON 列共享数据结构中的路径的数组。 [`Array(String)`](/sql-reference/data-types/array) **示例** -```sql +**用法示例** + +```sql title=Query CREATE TABLE test (json JSON(max_dynamic_paths=1)) ENGINE = Memory; INSERT INTO test FORMAT JSONEachRow {"json" : {"a" : 42}}, {"json" : {"b" : "Hello"}}, {"json" : {"a" : [1, 2, 3], "c" : "2020-01-01"}} -SELECT json, JSONAllPaths(json) FROM test; +SELECT json, JSONSharedDataPaths(json) FROM test; ``` -```response -┌─json─────────────────────────────────┬─JSONAllPaths(json)─┐ -│ {"a":"42"} │ ['a'] │ -│ {"b":"Hello"} │ ['b'] │ -│ {"a":["1","2","3"],"c":"2020-01-01"} │ ['a','c'] │ -└──────────────────────────────────────┴────────────────────┘ +```response title=Response +┌─json─────────────────────────────────┬─JSONSharedDataPaths(json)─┐ +│ {"a":"42"} │ [] │ +│ {"b":"Hello"} │ ['b'] │ +│ {"a":["1","2","3"],"c":"2020-01-01"} │ ['c'] │ +└──────────────────────────────────────┴───────────────────────────┘ ``` +## JSONSharedDataPathsWithTypes {#JSONSharedDataPathsWithTypes} + +引入版本:v24.8 -### JSONAllPathsWithTypes {#jsonallpathswithtypes} -返回存储在每行的 [JSON](../data-types/newjson.md) 列中的所有路径及其数据类型的映射。 +返回存储在 JSON 列共享数据结构及其类型中的路径列表。 + **语法** ```sql -JSONAllPathsWithTypes(json) +JSONSharedDataPathsWithTypes(json) ``` **参数** -- `json` — [JSON](../data-types/newjson.md)。 +- `json` — JSON 列。 [`JSON`](/sql-reference/data-types/newjson) + **返回值** -- 路径数组。 [Map(String, String)](../data-types/array.md)。 +返回存储在 JSON 列共享数据结构中的路径及其数据类型的映射。 [`Map(String, String)`](/sql-reference/data-types/map) **示例** -```sql +**用法示例** + +```sql title=Query CREATE TABLE test (json JSON(max_dynamic_paths=1)) ENGINE = Memory; INSERT INTO test FORMAT JSONEachRow {"json" : {"a" : 42}}, {"json" : {"b" : "Hello"}}, {"json" : {"a" : [1, 2, 3], "c" : "2020-01-01"}} -SELECT json, JSONAllPathsWithTypes(json) FROM test; +SELECT json, JSONSharedDataPathsWithTypes(json) FROM test; ``` -```response -┌─json─────────────────────────────────┬─JSONAllPathsWithTypes(json)───────────────┐ -│ {"a":"42"} │ {'a':'Int64'} │ -│ {"b":"Hello"} │ {'b':'String'} │ -│ {"a":["1","2","3"],"c":"2020-01-01"} │ {'a':'Array(Nullable(Int64))','c':'Date'} │ -└──────────────────────────────────────┴───────────────────────────────────────────┘ +```response title=Response +┌─json─────────────────────────────────┬─JSONSharedDataPathsWithTypes(json)─┐ +│ {"a":"42"} │ {} │ +│ {"b":"Hello"} │ {'b':'String'} │ +│ {"a":["1","2","3"],"c":"2020-01-01"} │ {'c':'Date'} │ +└──────────────────────────────────────┴─────────────────────────────────────┘ ``` +## JSONType {#JSONType} + +引入版本:v20.1 -### JSONDynamicPaths {#jsondynamicpaths} -返回存储在 [JSON](../data-types/newjson.md) 列中作为单独子列的动态路径列表。 +返回 JSON 值的类型。如果值不存在,则返回 `Null=0`。 + **语法** ```sql -JSONDynamicPaths(json) +JSONType(json[, indices_or_keys, ...]) ``` **参数** -- `json` — [JSON](../data-types/newjson.md)。 +- `json` — 要解析的 JSON 字符串 [`String`](/sql-reference/data-types/string) +- `json[, indices_or_keys, ...]` — 一组零个或多个参数,每个参数可以是字符串或整数。 [`String`](/sql-reference/data-types/string) 或 [`(U)Int8/16/32/64`](/sql-reference/data-types/int-uint) + **返回值** -- 路径数组。 [Array(String)](../data-types/array.md)。 +返回 JSON 值的类型作为字符串;否则,如果值不存在则返回 `Null=0`。 [`Enum`](/sql-reference/data-types/enum) **示例** -```sql -CREATE TABLE test (json JSON(max_dynamic_paths=1)) ENGINE = Memory; -INSERT INTO test FORMAT JSONEachRow {"json" : {"a" : 42}}, {"json" : {"b" : "Hello"}}, {"json" : {"a" : [1, 2, 3], "c" : "2020-01-01"}} -SELECT json, JSONDynamicPaths(json) FROM test; +**用法示例** + +```sql title=Query +SELECT JSONType('{"a": "hello", "b": [-100, 200.0, 300]}') = 'Object'; +SELECT JSONType('{"a": "hello", "b": [-100, 200.0, 300]}', 'a') = 'String'; +SELECT JSONType('{"a": "hello", "b": [-100, 200.0, 300]}', 'b') = 'Array'; ``` -```response -┌─json─────────────────────────────────┬─JSONDynamicPaths(json)─┐ -| {"a":"42"} │ ['a'] │ -│ {"b":"Hello"} │ [] │ -│ {"a":["1","2","3"],"c":"2020-01-01"} │ ['a'] │ -└──────────────────────────────────────┴────────────────────────┘ +```response title=Response +1 +1 +1 ``` +## JSON_EXISTS {#JSON_EXISTS} -### JSONDynamicPathsWithTypes {#jsondynamicpathswithtypes} +引入版本:v21.8 -返回存储在 [JSON](../data-types/newjson.md) 列中作为单独子列的动态路径及其类型的映射。 + +如果值存在于 JSON 文档中,则返回 `1`。 +如果值不存在,则返回 `0`。 + **语法** ```sql -JSONAllPathsWithTypes(json) +JSON_EXISTS(json, path) ``` **参数** -- `json` — [JSON](../data-types/newjson.md)。 +- `json` — 一个有效 JSON 的字符串。 [`String`](/sql-reference/data-types/string) +- `path` — 表示路径的字符串。 [`String`](/sql-reference/data-types/string) + **返回值** -- 路径数组。 [Map(String, String)](../data-types/array.md)。 +如果值存在于 JSON 文档中,则返回 `1`;否则返回 `0`。 [`UInt8`](/sql-reference/data-types/int-uint) **示例** -```sql -CREATE TABLE test (json JSON(max_dynamic_paths=1)) ENGINE = Memory; -INSERT INTO test FORMAT JSONEachRow {"json" : {"a" : 42}}, {"json" : {"b" : "Hello"}}, {"json" : {"a" : [1, 2, 3], "c" : "2020-01-01"}} -SELECT json, JSONDynamicPathsWithTypes(json) FROM test; +**用法示例** + +```sql title=Query +SELECT JSON_EXISTS('{"hello":1}', '$.hello'); +SELECT JSON_EXISTS('{"hello":{"world":1}}', '$.hello.world'); +SELECT JSON_EXISTS('{"hello":["world"]}', '$.hello[*]'); +SELECT JSON_EXISTS('{"hello":["world"]}', '$.hello[0]'); ``` -```response -┌─json─────────────────────────────────┬─JSONDynamicPathsWithTypes(json)─┐ -│ {"a":"42"} │ {'a':'Int64'} │ -│ {"b":"Hello"} │ {} │ -│ {"a":["1","2","3"],"c":"2020-01-01"} │ {'a':'Array(Nullable(Int64))'} │ -└──────────────────────────────────────┴─────────────────────────────────┘ +```response title=Response +┌─JSON_EXISTS(⋯ '$.hello')─┐ +│ 1 │ +└──────────────────────────┘ +┌─JSON_EXISTS(⋯llo.world')─┐ +│ 1 │ +└──────────────────────────┘ +┌─JSON_EXISTS(⋯.hello[*]')─┐ +│ 1 │ +└──────────────────────────┘ +┌─JSON_EXISTS(⋯.hello[0]')─┐ +│ 1 │ +└──────────────────────────┘ ``` +## JSON_QUERY {#JSON_QUERY} -### JSONSharedDataPaths {#jsonshareddatapaths} +引入版本:v21.8 -返回存储在 [JSON](../data-types/newjson.md) 列中的共享数据结构中的路径列表。 + +解析 JSON 并提取值作为 JSON 数组或 JSON 对象。 +如果值不存在,则返回空字符串。 + **语法** ```sql -JSONSharedDataPaths(json) +JSON_QUERY(json, path) ``` **参数** -- `json` — [JSON](../data-types/newjson.md)。 +- `json` — 一个有效 JSON 的字符串。 [`String`](/sql-reference/data-types/string) +- `path` — 表示路径的字符串。 [`String`](/sql-reference/data-types/string) + **返回值** -- 路径数组。 [Array(String)](../data-types/array.md)。 +返回提取的 JSON 数组或 JSON 对象作为字符串;如果值不存在则返回空字符串。 [`String`](/sql-reference/data-types/string) **示例** -```sql -CREATE TABLE test (json JSON(max_dynamic_paths=1)) ENGINE = Memory; -INSERT INTO test FORMAT JSONEachRow {"json" : {"a" : 42}}, {"json" : {"b" : "Hello"}}, {"json" : {"a" : [1, 2, 3], "c" : "2020-01-01"}} -SELECT json, JSONSharedDataPaths(json) FROM test; +**用法示例** + +```sql title=Query +SELECT JSON_QUERY('{"hello":"world"}', '$.hello'); +SELECT JSON_QUERY('{"array":[[0, 1, 2, 3, 4, 5], [0, -1, -2, -3, -4, -5]]}', '$.array[*][0 to 2, 4]'); +SELECT JSON_QUERY('{"hello":2}', '$.hello'); +SELECT toTypeName(JSON_QUERY('{"hello":2}', '$.hello')); ``` -```response -┌─json─────────────────────────────────┬─JSONSharedDataPaths(json)─┐ -│ {"a":"42"} │ [] │ -│ {"b":"Hello"} │ ['b'] │ -│ {"a":["1","2","3"],"c":"2020-01-01"} │ ['c'] │ -└──────────────────────────────────────┴───────────────────────────┘ +```response title=Response +["world"] +[0, 1, 4, 0, -1, -4] +[2] +String ``` +## JSON_VALUE {#JSON_VALUE} + +引入版本:v21.11 + -### JSONSharedDataPathsWithTypes {#jsonshareddatapathswithtypes} +解析 JSON 并提取值作为 JSON 标量。如果值不存在,则默认返回空字符串。 -返回存储在 [JSON](../data-types/newjson.md) 列中共享数据结构及其类型的路径的映射。 +此函数受以下设置控制: +- 通过设置 `function_json_value_return_type_allow_nullable` = `true`,将返回 `NULL`。如果值为复杂类型(如:结构、数组、映射),则默认返回空字符串。 +- 通过设置 `function_json_value_return_type_allow_complex` = `true`,将返回复杂值。 + **语法** ```sql -JSONSharedDataPathsWithTypes(json) +JSON_VALUE(json, path) ``` **参数** -- `json` — [JSON](../data-types/newjson.md)。 +- `json` — 一个有效 JSON 的字符串。 [`String`](/sql-reference/data-types/string) +- `path` — 表示路径的字符串。 [`String`](/sql-reference/data-types/string) + **返回值** -- 路径数组。 [Map(String, String)](../data-types/array.md)。 +返回提取的 JSON 标量作为字符串;如果值不存在,则返回空字符串。 [`String`](/sql-reference/data-types/string) **示例** -```sql -CREATE TABLE test (json JSON(max_dynamic_paths=1)) ENGINE = Memory; -INSERT INTO test FORMAT JSONEachRow {"json" : {"a" : 42}}, {"json" : {"b" : "Hello"}}, {"json" : {"a" : [1, 2, 3], "c" : "2020-01-01"}} -SELECT json, JSONSharedDataPathsWithTypes(json) FROM test; +**用法示例** + +```sql title=Query +SELECT JSON_VALUE('{"hello":"world"}', '$.hello'); +SELECT JSON_VALUE('{"array":[[0, 1, 2, 3, 4, 5], [0, -1, -2, -3, -4, -5]]}', '$.array[*][0 to 2, 4]'); +SELECT JSON_VALUE('{"hello":2}', '$.hello'); +SELECT JSON_VALUE('{"hello":"world"}', '$.b') settings function_json_value_return_type_allow_nullable=true; ``` -```response -┌─json─────────────────────────────────┬─JSONSharedDataPathsWithTypes(json)─┐ -│ {"a":"42"} │ {} │ -│ {"b":"Hello"} │ {'b':'String'} │ -│ {"a":["1","2","3"],"c":"2020-01-01"} │ {'c':'Date'} │ -└──────────────────────────────────────┴────────────────────────────────────┘ +```response title=Response +world +0 +2 +ᴺᵁᴸᴸ ``` +## dynamicElement {#dynamicElement} - +引入版本:v - - + +从 `Dynamic` 列中提取指定类型的列。 + + +**语法** + +```sql +dynamicElement(dynamic, type_name) +``` + +**参数** + +- `dynamic` — 动态列 - `type_name` — 要提取的变体类型的名称 + +**返回值** + + + +**示例** + +**示例** + +```sql title=Query +CREATE TABLE test (d Dynamic) ENGINE = Memory; +INSERT INTO test VALUES (NULL), (42), ('Hello, World!'), ([1, 2, 3]); +SELECT d, dynamicType(d), dynamicElement(d, 'String'), dynamicElement(d, 'Int64'), dynamicElement(d, 'Array(Int64)'), dynamicElement(d, 'Date'), dynamicElement(d, 'Array(String)') FROM test; +``` + +```response title=Response +┌─d─────────────┬─dynamicType(d)─┬─dynamicElement(d, 'String')─┬─dynamicElement(d, 'Int64')─┬─dynamicElement(d, 'Array(Int64)')─┬─dynamicElement(d, 'Date')─┬─dynamicElement(d, 'Array(String)')─┐ +│ ᴺᵁᴸᴸ │ None │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ [] │ ᴺᵁᴸᴸ │ [] │ +│ 42 │ Int64 │ ᴺᵁᴸᴸ │ 42 │ [] │ ᴺᵁᴸᴸ │ [] │ +│ Hello, World! │ String │ Hello, World! │ ᴺᵁᴸᴸ │ [] │ ᴺᵁᴸᴸ │ [] │ +│ [1,2,3] │ Array(Int64) │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ [1,2,3] │ ᴺᵁᴸᴸ │ [] │ +└───────────────┴────────────────┴─────────────────────────────┴────────────────────────────┴───────────────────────────────────┴───────────────────────────┴────────────────────────────────────┘ +``` +## dynamicType {#dynamicType} + +引入版本:v + + +返回 `Dynamic` 列每行的变体类型名称。如果行包含 NULL,则返回 'None'。 + + +**语法** + +```sql +dynamicType(dynamic) +``` + +**参数** + +- `dynamic` — 动态列 + +**返回值** + + + +**示例** + +**示例** + +```sql title=Query +CREATE TABLE test (d Dynamic) ENGINE = Memory; +INSERT INTO test VALUES (NULL), (42), ('Hello, World!'), ([1, 2, 3]); +SELECT d, dynamicType(d) FROM test; +``` + +```response title=Response +┌─d─────────────┬─dynamicType(d)─┐ +│ ᴺᵁᴸᴸ │ None │ +│ 42 │ Int64 │ +│ Hello, World! │ String │ +│ [1,2,3] │ Array(Int64) │ +└───────────────┴────────────────┘ +``` +## isDynamicElementInSharedData {#isDynamicElementInSharedData} + +引入版本:v + + +返回在动态列中不分解为子列并以内存共享变体的二进制形式存储的行的真假值。 + + +**语法** + +```sql +isDynamicElementInSharedData(dynamic) +``` + +**参数** + +- `dynamic` — 动态列 + +**返回值** + + + +**示例** + +**示例** + +```sql title=Query +CREATE TABLE test (d Dynamic(max_types=2)) ENGINE = Memory; +INSERT INTO test VALUES (NULL), (42), ('Hello, World!'), ([1, 2, 3]); +SELECT d, isDynamicElementInSharedData(d) FROM test; +``` + +```response title=Response +┌─d─────────────┬─isDynamicElementInSharedData(d)─┐ +│ ᴺᵁᴸᴸ │ false │ +│ 42 │ false │ +│ Hello, World! │ true │ +│ [1,2,3] │ true │ +└───────────────┴────────────────────┘ +``` +## isValidJSON {#isValidJSON} + +引入版本:v20.1 + + +检查传入的字符串是否有效 JSON。 + + +**语法** + +```sql +isValidJSON(json) +``` + +**参数** + +- `json` — 要验证的 JSON 字符串 [`String`](/sql-reference/data-types/string) + + +**返回值** + +如果字符串是有效 JSON,则返回 `1`;否则返回 `0`。 [`UInt8`](/sql-reference/data-types/int-uint) + +**示例** + +**用法示例** + +```sql title=Query +SELECT isValidJSON('{"a": "hello", "b": [-100, 200.0, 300]}') = 1; +SELECT isValidJSON('not JSON') = 0; +``` + +```response title=Response +1 +0 +``` + +**使用整数访问 JSON 数组和 JSON 对象** + +```sql title=Query +SELECT JSONHas('{"a": "hello", "b": [-100, 200.0, 300]}', 0); +SELECT JSONHas('{"a": "hello", "b": [-100, 200.0, 300]}', 1); +SELECT JSONHas('{"a": "hello", "b": [-100, 200.0, 300]}', 2); +SELECT JSONHas('{"a": "hello", "b": [-100, 200.0, 300]}', -1); +SELECT JSONHas('{"a": "hello", "b": [-100, 200.0, 300]}', -2); +SELECT JSONHas('{"a": "hello", "b": [-100, 200.0, 300]}', 3); +``` + +```response title=Response +0 +1 +1 +1 +1 +1 +0 +``` +## simpleJSONExtractBool {#simpleJSONExtractBool} + +引入版本:v21.4 + + +从名为 `field_name` 的字段中解析真/假值。 +结果为 `UInt8`。 + + +**语法** + +```sql +simpleJSONExtractBool(json, field_name) +``` + +**参数** + +- `json` — 要搜索字段的 JSON。 [`String`](/sql-reference/data-types/string) +- `field_name` — 要搜索的字段名称。 [`const String`](/sql-reference/data-types/string) + + +**返回值** + +如果字段的值为 `true`,则返回 `1`;否则返回 `0`。这意味着此函数将返回 `0` 包括(但不限于)以下情况: +- 如果字段不存在。 +- 如果字段包含 `true` 字符串,例如:`{"field":"true"}`。 +- 如果字段包含 `1` 作为数值。 [`UInt8`](/sql-reference/data-types/int-uint) + +**示例** + +**用法示例** + +```sql title=Query +CREATE TABLE jsons +( + `json` String +) +ENGINE = MergeTree +ORDER BY tuple(); + +INSERT INTO jsons VALUES ('{"foo":false,"bar":true}'); +INSERT INTO jsons VALUES ('{"foo":"true","qux":1}'); + +SELECT simpleJSONExtractBool(json, 'bar') FROM jsons ORDER BY json; +SELECT simpleJSONExtractBool(json, 'foo') FROM jsons ORDER BY json; +``` + +```response title=Response +0 +1 +0 +0 +``` +## simpleJSONExtractFloat {#simpleJSONExtractFloat} + +引入于: v21.4 + +从名为 `field_name` 的字段值中解析 `Float64`。 +如果 `field_name` 是字符串字段,它会尝试从字符串的开头解析一个数字。 +如果字段不存在,或者存在但不包含数字,它将返回 `0`。 + +**语法** + +```sql +simpleJSONExtractFloat(json, field_name) +``` + +**参数** + +- `json` — 要搜索字段的 JSON。[`String`](/sql-reference/data-types/string) +- `field_name` — 要搜索的字段名称。[`const String`](/sql-reference/data-types/string) + +**返回值** + +如果字段存在且包含数字,则返回从字段解析的数字,否则返回 `0`。 [`Float64`](/sql-reference/data-types/float) + +**示例** + +**使用示例** + +```sql title=Query +CREATE TABLE jsons +( + `json` String +) +ENGINE = MergeTree +ORDER BY tuple(); + +INSERT INTO jsons VALUES ('{"foo":"-4e3"}'); +INSERT INTO jsons VALUES ('{"foo":-3.4}'); +INSERT INTO jsons VALUES ('{"foo":5}'); +INSERT INTO jsons VALUES ('{"foo":"not1number"}'); +INSERT INTO jsons VALUES ('{"baz":2}'); + +SELECT simpleJSONExtractFloat(json, 'foo') FROM jsons ORDER BY json; +``` + +```response title=Response +0 +-4000 +0 +-3.4 +5 +``` +## simpleJSONExtractInt {#simpleJSONExtractInt} + +引入于: v21.4 + +从名为 `field_name` 的字段值中解析 `Int64`。 +如果 `field_name` 是字符串字段,它会尝试从字符串的开头解析一个数字。 +如果字段不存在,或者存在但不包含数字,它将返回 `0`。 + +**语法** + +```sql +simpleJSONExtractInt(json, field_name) +``` + +**参数** + +- `json` — 要搜索字段的 JSON。[`String`](/sql-reference/data-types/string) +- `field_name` — 要搜索的字段名称。[`const String`](/sql-reference/data-types/string) + +**返回值** + +如果字段存在且包含数字,则返回从字段解析的数字,`0` 否则。 [`Int64`](/sql-reference/data-types/int-uint) + +**示例** + +**使用示例** + +```sql title=Query +CREATE TABLE jsons +( + `json` String +) +ENGINE = MergeTree +ORDER BY tuple(); + +INSERT INTO jsons VALUES ('{"foo":"-4e3"}'); +INSERT INTO jsons VALUES ('{"foo":-3.4}'); +INSERT INTO jsons VALUES ('{"foo":5}'); +INSERT INTO jsons VALUES ('{"foo":"not1number"}'); +INSERT INTO jsons VALUES ('{"baz":2}'); + +SELECT simpleJSONExtractInt(json, 'foo') FROM jsons ORDER BY json; +``` + +```response title=Response +0 +-4 +0 +-3 +5 +``` +## simpleJSONExtractRaw {#simpleJSONExtractRaw} + +引入于: v21.4 + +将名为 `field_name` 的字段值返回为 `String`,包括分隔符。 + +**语法** + +```sql +simpleJSONExtractRaw(json, field_name) +``` + +**参数** + +- `json` — 要搜索字段的 JSON。[`String`](/sql-reference/data-types/string) +- `field_name` — 要搜索的字段名称。[`const String`](/sql-reference/data-types/string) + +**返回值** + +如果字段存在,则返回字段的值作为字符串,包括分隔符,否则返回空字符串。[`String`](/sql-reference/data-types/string) + +**示例** + +**使用示例** + +```sql title=Query +CREATE TABLE jsons +( + `json` String +) +ENGINE = MergeTree +ORDER BY tuple(); + +INSERT INTO jsons VALUES ('{"foo":"-4e3"}'); +INSERT INTO jsons VALUES ('{"foo":-3.4}'); +INSERT INTO jsons VALUES ('{"foo":5}'); +INSERT INTO jsons VALUES ('{"foo":{"def":[1,2,3]}}'); +INSERT INTO jsons VALUES ('{"baz":2}'); + +SELECT simpleJSONExtractRaw(json, 'foo') FROM jsons ORDER BY json; +``` + +```response title=Response +"-4e3" +-3.4 +5 +{"def":[1,2,3]} +``` +## simpleJSONExtractString {#simpleJSONExtractString} + +引入于: v21.4 + +从名为 `field_name` 的字段值中解析带有双引号的 `String`。 + +**实现细节** + +目前不支持基本多语言平面以外格式 `\uXXXX\uYYYY` 的代码点(它们会被转换为 CESU-8 而不是 UTF-8)。 + +**语法** + +```sql +simpleJSONExtractString(json, field_name) +``` + +**参数** + +- `json` — 要搜索字段的 JSON。[`String`](/sql-reference/data-types/string) +- `field_name` — 要搜索的字段名称。[`const String`](/sql-reference/data-types/string) + +**返回值** + +返回字段的未转义值作为字符串,包括分隔符。如果字段不包含双引号字符串,或者未转义失败,或者字段不存在,则返回空字符串。[`String`](/sql-reference/data-types/string) + +**示例** + +**使用示例** + +```sql title=Query +CREATE TABLE jsons +( + `json` String +) +ENGINE = MergeTree +ORDER BY tuple(); + +INSERT INTO jsons VALUES ('{"foo":"\\n\\u0000"}'); +INSERT INTO jsons VALUES ('{"foo":"\\u263"}'); +INSERT INTO jsons VALUES ('{"foo":"\\u263a"}'); +INSERT INTO jsons VALUES ('{"foo":"hello}'); + +SELECT simpleJSONExtractString(json, 'foo') FROM jsons ORDER BY json; +``` + +```response title=Response +\n\0 + +☺ +``` +## simpleJSONExtractUInt {#simpleJSONExtractUInt} + +引入于: v21.4 + +从名为 `field_name` 的字段值中解析 `UInt64`。 +如果 `field_name` 是字符串字段,它会尝试从字符串的开头解析一个数字。 +如果字段不存在,或者存在但不包含数字,它将返回 `0`。 + +**语法** + +```sql +simpleJSONExtractUInt(json, field_name) +``` + +**参数** + +- `json` — 要搜索字段的 JSON。[`String`](/sql-reference/data-types/string) +- `field_name` — 要搜索的字段名称。[`const String`](/sql-reference/data-types/string) + +**返回值** + +如果字段存在且包含数字,则返回从字段解析的数字,`0` 否则。[`UInt64`](/sql-reference/data-types/int-uint) + +**示例** + +**使用示例** + +```sql title=Query +CREATE TABLE jsons +( + `json` String +) +ENGINE = MergeTree +ORDER BY tuple(); + +INSERT INTO jsons VALUES ('{"foo":"4e3"}'); +INSERT INTO jsons VALUES ('{"foo":3.4}'); +INSERT INTO jsons VALUES ('{"foo":5}'); +INSERT INTO jsons VALUES ('{"foo":"not1number"}'); +INSERT INTO jsons VALUES ('{"baz":2}'); + +SELECT simpleJSONExtractUInt(json, 'foo') FROM jsons ORDER BY json; +``` + +```response title=Response +0 +4 +0 +3 +5 +``` +## simpleJSONHas {#simpleJSONHas} + +引入于: v21.4 + +检查是否存在名为 `field_name` 的字段。 + +**语法** + +```sql +simpleJSONHas(json, field_name) +``` + +**参数** + +- `json` — 要搜索字段的 JSON。[`String`](/sql-reference/data-types/string) +- `field_name` — 要搜索的字段名称。[`const String`](/sql-reference/data-types/string) + +**返回值** + +如果字段存在,则返回 `1`,否则返回 `0`。[`UInt8`](/sql-reference/data-types/int-uint) + +**示例** + +**使用示例** + +```sql title=Query +CREATE TABLE jsons +( + `json` String +) +ENGINE = MergeTree +ORDER BY tuple(); + +INSERT INTO jsons VALUES ('{"foo":"true","qux":1}'); + +SELECT simpleJSONHas(json, 'foo') FROM jsons; +SELECT simpleJSONHas(json, 'bar') FROM jsons; +``` + +```response title=Response +1 +0 +``` +## toJSONString {#toJSONString} + +引入于: v21.7 + +将值序列化为其 JSON 表示形式。支持各种数据类型和嵌套结构。 +64 位 [整数](../data-types/int-uint.md) 或更大(如 `UInt64` 或 `Int128`)默认用引号括起来。[output_format_json_quote_64bit_integers](/operations/settings/formats#output_format_json_quote_64bit_integers) 控制此行为。 +特殊值 `NaN` 和 `inf` 被替换为 `null`。启用 [output_format_json_quote_denormals](/operations/settings/formats#output_format_json_quote_denormals) 设置以显示它们。 +序列化 [Enum](../data-types/enum.md) 值时,函数输出其名称。 + +另请参见: +- [output_format_json_quote_64bit_integers](/operations/settings/formats#output_format_json_quote_64bit_integers) +- [output_format_json_quote_denormals](/operations/settings/formats#output_format_json_quote_denormals) + +**语法** + +```sql +toJSONString(value) +``` + +**参数** + +- `value` — 要序列化的值。值可以是任何数据类型。[`Any`](/sql-reference/data-types) + +**返回值** + +返回值的 JSON 表示。[`String`](/sql-reference/data-types/string) + +**示例** + +**映射序列化** + +```sql title=Query +SELECT toJSONString(map('key1', 1, 'key2', 2)); +``` + +```response title=Response +┌─toJSONString(map('key1', 1, 'key2', 2))─┐ +│ {"key1":1,"key2":2} │ +└─────────────────────────────────────────┘ +``` + +**特殊值** + +```sql title=Query +SELECT toJSONString(tuple(1.25, NULL, NaN, +inf, -inf, [])) SETTINGS output_format_json_quote_denormals = 1; +``` + +```response title=Response +┌─toJSONString(tuple(1.25, NULL, NaN, plus(inf), minus(inf), []))─┐ +│ [1.25,null,"nan","inf","-inf",[]] │ +└─────────────────────────────────────────────────────────────────┘ +``` +## variantElement {#variantElement} + +引入于: v + +从 `Variant` 列中提取指定类型的列。 + +**语法** + +```sql +variantElement(variant, type_name, [, default_value]) +``` + +**参数** + +- `variant` — Variant 列 +- `type_name` — 要提取的变体类型的名称 +- `default_value` — 如果变体没有具有指定类型的变体,将使用的默认值。可以是任何类型。可选 + +**返回值** + + + +**示例** + +**示例** + +```sql title=Query +CREATE TABLE test (v Variant(UInt64, String, Array(UInt64))) ENGINE = Memory; +INSERT INTO test VALUES (NULL), (42), ('Hello, World!'), ([1, 2, 3]); +SELECT v, variantElement(v, 'String'), variantElement(v, 'UInt64'), variantElement(v, 'Array(UInt64)') FROM test; +``` + +```response title=Response +┌─v─────────────┬─variantElement(v, 'String')─┬─variantElement(v, 'UInt64')─┬─variantElement(v, 'Array(UInt64)')─┐ +│ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ [] │ +│ 42 │ ᴺᵁᴸᴸ │ 42 │ [] │ +│ Hello, World! │ Hello, World! │ ᴺᵁᴸᴸ │ [] │ +│ [1,2,3] │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ [1,2,3] │ +└───────────────┴─────────────────────────────┴─────────────────────────────┴────────────────────────────────────┘ +``` +## variantType {#variantType} + +引入于: v + +返回每行 `Variant` 列的变体类型名称。如果行包含 NULL,则为其返回 'None'。 + +**语法** + +```sql +variantType(variant) +``` + +**参数** + +- `variant` — Variant 列 + +**返回值** + + + +**示例** + +**示例** + +```sql title=Query +CREATE TABLE test (v Variant(UInt64, String, Array(UInt64))) ENGINE = Memory; +INSERT INTO test VALUES (NULL), (42), ('Hello, World!'), ([1, 2, 3]); +SELECT variantType(v) FROM test; +``` + +```response title=Response +┌─variantType(v)─┐ +│ None │ +│ UInt64 │ +│ String │ +│ Array(UInt64) │ +└────────────────┘ +``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/json-functions.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/json-functions.md.hash index 989456edb6a..3199316b59f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/json-functions.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/json-functions.md.hash @@ -1 +1 @@ -40429561ad35b402 +3210359abb94f1f3 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/logical-functions.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/logical-functions.md index aa202055245..1becde05d35 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/logical-functions.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/logical-functions.md @@ -1,205 +1,215 @@ --- -'description': 'Documentation for Logical Functions' +'description': '逻辑函数的文档' 'sidebar_label': 'Logical' -'sidebar_position': 110 'slug': '/sql-reference/functions/logical-functions' 'title': '逻辑函数' +'doc_type': 'reference' --- # 逻辑函数 -下面的函数对任意数值类型的参数执行逻辑操作。它们返回0或1,作为[UInt8](../data-types/int-uint.md),在某些情况下返回`NULL`。 +下面的函数对任意 numeric 类型的参数执行逻辑操作。它们返回 `0` 或 `1` 作为 [`UInt8`](../data-types/int-uint.md),在某些情况下返回 `NULL`。 -零值被视为`false`,非零值被视为`true`。 +零作为参数被视为 `false`,非零值被视为 `true`。 + + + ## and {#and} -计算两个或多个值的逻辑与。 +引入于: v1.1 + + +计算两个或多个值的逻辑结合。 + +设置 [`short_circuit_function_evaluation`](/operations/settings/settings#short_circuit_function_evaluation) 控制是否使用短路计算。如果启用,只有在 `(val_1 AND val_2 AND ... AND val_{i-1})` 为 `true` 时,才会评估 `val_i`。 + +例如,使用短路计算时,在执行查询 `SELECT and(number = 2, intDiv(1, number)) FROM numbers(5)` 时不会抛出除零异常。零作为参数被视为 `false`,非零值被视为 `true`。 -设置 [short_circuit_function_evaluation](/operations/settings/settings#short_circuit_function_evaluation) 控制是否使用短路评估。如果启用,`val_i` 仅在`(val_1 AND val_2 AND ... AND val_{i-1})` 为 `true` 时进行评估。例如,通过短路评估,在执行查询 `SELECT and(number = 2, intDiv(1, number)) FROM numbers(5)` 时不会引发除以零的异常。 **语法** ```sql -and(val1, val2...) +and(val1, val2[, ...]) ``` -别名: [AND 运算符](../../sql-reference/operators/index.md#logical-and-operator)。 - **参数** -- `val1, val2, ...` — 至少两个值的列表。 [Int](../data-types/int-uint.md), [UInt](../data-types/int-uint.md), [Float](../data-types/float.md) 或 [Nullable](../data-types/nullable.md)。 +- `val1, val2[, ...]` — 至少两个值的列表。 [`Nullable((U)Int*)`](/sql-reference/data-types/nullable) 或 [`Nullable(Float*)`](/sql-reference/data-types/nullable) -**返回值** -- `0`,如果至少一个参数评估为 `false`, -- `NULL`,如果没有参数评估为 `false` 且至少一个参数为 `NULL`, -- `1`,否则。 +**返回值** -类型:[UInt8](../../sql-reference/data-types/int-uint.md) 或 [Nullable](../../sql-reference/data-types/nullable.md)([UInt8](../../sql-reference/data-types/int-uint.md))。 +返回: +- `0`,如果至少一个参数评估为 `false` +- `NULL`,如果没有参数评估为 `false` 且至少一个参数为 `NULL` +- `1`,否则 + [`Nullable(UInt8)`](/sql-reference/data-types/nullable) **示例** -```sql +**基本用法** + +```sql title=Query SELECT and(0, 1, -2); ``` -结果: - -```text -┌─and(0, 1, -2)─┐ -│ 0 │ -└───────────────┘ +```response title=Response +0 ``` -带`NULL`: +**与 NULL** -```sql +```sql title=Query SELECT and(NULL, 1, 10, -2); ``` -结果: - -```text -┌─and(NULL, 1, 10, -2)─┐ -│ ᴺᵁᴸᴸ │ -└──────────────────────┘ +```response title=Response +ᴺᵁᴸᴸ ``` -## or {#or} -计算两个或多个值的逻辑或。 -设置 [short_circuit_function_evaluation](/operations/settings/settings#short_circuit_function_evaluation) 控制是否使用短路评估。如果启用,`val_i` 仅在`((NOT val_1) AND (NOT val_2) AND ... AND (NOT val_{i-1}))` 为 `true` 时进行评估。例如,通过短路评估,在执行查询 `SELECT or(number = 0, intDiv(1, number) != 0) FROM numbers(5)` 时不会引发除以零的异常。 +## not {#not} + +引入于: v1.1 + + +计算值的逻辑否定。零作为参数被视为 `false`,非零值被视为 `true`。 + **语法** ```sql -or(val1, val2...) +not(val) ``` -别名: [OR 运算符](../../sql-reference/operators/index.md#logical-or-operator)。 - **参数** -- `val1, val2, ...` — 至少两个值的列表。 [Int](../data-types/int-uint.md), [UInt](../data-types/int-uint.md), [Float](../data-types/float.md) 或 [Nullable](../data-types/nullable.md)。 +- `val` — 值。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) -**返回值** -- `1`,如果至少一个参数评估为 `true`, -- `0`,如果所有参数评估为 `false`, -- `NULL`,如果所有参数评估为 `false` 且至少一个参数为 `NULL`。 +**返回值** -类型:[UInt8](../../sql-reference/data-types/int-uint.md) 或 [Nullable](../../sql-reference/data-types/nullable.md)([UInt8](../../sql-reference/data-types/int-uint.md))。 +返回: +- `1`,如果 `val` 评估为 `false` +- `0`,如果 `val` 评估为 `true` +- `NULL`,如果 `val` 为 `NULL`。 + [`Nullable(UInt8)`](/sql-reference/data-types/nullable) **示例** -```sql -SELECT or(1, 0, 0, 2, NULL); -``` +**基本用法** -结果: +```sql title=Query +SELECT NOT(1); +``` -```text -┌─or(1, 0, 0, 2, NULL)─┐ -│ 1 │ -└──────────────────────┘ +```response title=Response +0 ``` -带`NULL`: -```sql -SELECT or(0, NULL); -``` -结果: +## or {#or} -```text -┌─or(0, NULL)─┐ -│ ᴺᵁᴸᴸ │ -└─────────────┘ -``` +引入于: v1.1 -## not {#not} -计算一个值的逻辑非。 +计算两个或多个值的逻辑析取。 + +设置 [`short_circuit_function_evaluation`](https://clickhouse.com/docs/operations/settings/settings#short_circuit_function_evaluation) 控制是否使用短路计算。如果启用,只有在 `((NOT val_1) AND (NOT val_2) AND ... AND (NOT val_{i-1}))` 为 `true` 时,才会评估 `val_i`。 + +例如,使用短路计算时,在执行查询 `SELECT or(number = 0, intDiv(1, number) != 0) FROM numbers(5)` 时不会抛出除零异常。零作为参数被视为 `false`,非零值被视为 `true`。 + **语法** ```sql -not(val); +or(val1, val2[, ...]) ``` -别名:[否定运算符](../../sql-reference/operators/index.md#logical-negation-operator)。 - **参数** -- `val` — 值。 [Int](../data-types/int-uint.md), [UInt](../data-types/int-uint.md), [Float](../data-types/float.md) 或 [Nullable](../data-types/nullable.md)。 +- `val1, val2[, ...]` — 至少两个值的列表。 [`Nullable((U)Int*)`](/sql-reference/data-types/nullable) 或 [`Nullable(Float*)`](/sql-reference/data-types/nullable) -**返回值** -- `1`,如果 `val` 评估为 `false`, -- `0`,如果 `val` 评估为 `true`, -- `NULL`,如果 `val` 为 `NULL`。 +**返回值** -类型:[UInt8](../../sql-reference/data-types/int-uint.md) 或 [Nullable](../../sql-reference/data-types/nullable.md)([UInt8](../../sql-reference/data-types/int-uint.md))。 +返回: +- `1`,如果至少一个参数评估为 `true` +- `0`,如果所有参数评估为 `false` +- `NULL`,如果所有参数评估为 `false` 且至少一个参数为 `NULL` + [`Nullable(UInt8)`](/sql-reference/data-types/nullable) **示例** -```sql -SELECT NOT(1); +**基本用法** + +```sql title=Query +SELECT or(1, 0, 0, 2, NULL); ``` -结果: +```response title=Response +1 +``` + +**与 NULL** + +```sql title=Query +SELECT or(0, NULL); +``` -```test -┌─not(1)─┐ -│ 0 │ -└────────┘ +```response title=Response +ᴺᵁᴸᴸ ``` + + ## xor {#xor} -计算两个或多个值的逻辑异或。对于超过两个输入值的情况,该函数首先对前两个值进行异或运算,然后将结果与第三个值进行异或,以此类推。 +引入于: v1.1 + + +计算两个或多个值的逻辑排他性析取。对于超过两个的输入值,该函数首先将前两个值进行异或运算,然后将结果与第三个值进行异或,依此类推。零作为参数被视为 `false`,非零值被视为 `true`。 + **语法** ```sql -xor(val1, val2...) +xor(val1, val2[, ...]) ``` **参数** -- `val1, val2, ...` — 至少两个值的列表。 [Int](../data-types/int-uint.md), [UInt](../data-types/int-uint.md), [Float](../data-types/float.md) 或 [Nullable](../data-types/nullable.md)。 +- `val1, val2[, ...]` — 至少两个值的列表。 [`Nullable((U)Int*)`](/sql-reference/data-types/nullable) 或 [`Nullable(Float*)`](/sql-reference/data-types/nullable) -**返回值** -- `1`,对于两个值:如果其中一个值评估为 `false` 而另一个不评估为 `false`, -- `0`,对于两个值:如果两个值都评估为 `false` 或都评估为 `true`, -- `NULL`,如果至少一个输入值为 `NULL`。 +**返回值** -类型:[UInt8](../../sql-reference/data-types/int-uint.md) 或 [Nullable](../../sql-reference/data-types/nullable.md)([UInt8](../../sql-reference/data-types/int-uint.md))。 +返回: +- `1`,对于两个值:如果其中一个值评估为 `false`,而另一个则不 +- `0`,对于两个值:如果两个值都评估为 `false` 或都评估为 `true` +- `NULL`,如果至少一个输入为 `NULL`。 + [`Nullable(UInt8)`](/sql-reference/data-types/nullable) **示例** -```sql +**基本用法** + +```sql title=Query SELECT xor(0, 1, 1); ``` -结果: - -```text -┌─xor(0, 1, 1)─┐ -│ 0 │ -└──────────────┘ +```response title=Response +0 ``` - - + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/logical-functions.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/logical-functions.md.hash index d21f62cdedd..de1d302c87b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/logical-functions.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/logical-functions.md.hash @@ -1 +1 @@ -ec4a21ec41742ccc +a80f297bfd6dda13 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/machine-learning-functions.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/machine-learning-functions.md index 7057ade9292..8f32f0a0bb4 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/machine-learning-functions.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/machine-learning-functions.md @@ -1,9 +1,9 @@ --- -'description': '文档与 Machine Learning Functions' +'description': 'Documentation for Machine Learning Functions' 'sidebar_label': '机器学习' -'sidebar_position': 115 'slug': '/sql-reference/functions/machine-learning-functions' 'title': '机器学习函数' +'doc_type': 'reference' --- @@ -11,19 +11,18 @@ ## evalMLMethod {#evalmlmethod} -使用拟合的回归模型进行预测使用 `evalMLMethod` 函数。请参见 `linearRegression` 中的链接。 +使用拟合回归模型进行预测使用 `evalMLMethod` 函数。请参见 `linearRegression` 中的链接。 ## stochasticLinearRegression {#stochasticlinearregression} -[stochasticLinearRegression](/sql-reference/aggregate-functions/reference/stochasticlinearregression) 聚合函数实现了使用线性模型和均方误差 (MSE) 损失函数的随机梯度下降方法。使用 `evalMLMethod` 对新数据进行预测。 +[stochasticLinearRegression](/sql-reference/aggregate-functions/reference/stochasticlinearregression) 聚合函数使用线性模型和 MSE 损失函数实现随机梯度下降方法。使用 `evalMLMethod` 对新数据进行预测。 ## stochasticLogisticRegression {#stochasticlogisticregression} -[stochasticLogisticRegression](/sql-reference/aggregate-functions/reference/stochasticlogisticregression) 聚合函数实现了用于二元分类问题的随机梯度下降方法。使用 `evalMLMethod` 对新数据进行预测。 +[stochasticLogisticRegression](/sql-reference/aggregate-functions/reference/stochasticlogisticregression) 聚合函数实现了二元分类问题的随机梯度下降方法。使用 `evalMLMethod` 对新数据进行预测。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/machine-learning-functions.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/machine-learning-functions.md.hash index be2360cfd3c..baa7e90ec03 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/machine-learning-functions.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/machine-learning-functions.md.hash @@ -1 +1 @@ -5a6e6f01497e25c9 +0319f369c402ce6f diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/math-functions.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/math-functions.md index fa38ad4852d..17708e05a63 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/math-functions.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/math-functions.md @@ -1,223 +1,492 @@ --- -'description': '数学函数的 Documentation' +'description': '数学函数的文档' 'sidebar_label': '数学' -'sidebar_position': 125 'slug': '/sql-reference/functions/math-functions' 'title': '数学函数' +'doc_type': 'reference' --- # 数学函数 -## e {#e} + + + +## acos {#acos} + +引入于:v1.1 + + +返回参数的反余弦值。 -返回 $e$ ([欧拉常数](https://en.wikipedia.org/wiki/Euler%27s_constant))。 **语法** ```sql -e() +acos(x) ``` +**参数** + +- `x` — 要查找其反余弦值的值。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal*`](/sql-reference/data-types/decimal) + + **返回值** -类型: [Float64](../data-types/float.md)。 +返回 x 的反余弦值 [`Float*`](/sql-reference/data-types/float) -## pi {#pi} +**示例** + +**用法示例** + +```sql title=Query +SELECT acos(0.5); +``` + +```response title=Response +1.0471975511965979 +``` + + + +## acosh {#acosh} + +引入于:v20.12 + + +返回反双曲余弦值。 -返回 $\pi$ ([圆周率](https://en.wikipedia.org/wiki/Pi))。 **语法** ```sql -pi() +acosh(x) ``` +**参数** + +- `x` — 角度的双曲余弦值。值在区间:`1 ≤ x < +∞`。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal*`](/sql-reference/data-types/decimal) + + **返回值** -类型: [Float64](../data-types/float.md)。 +返回角度,以弧度为单位。值在区间:`0 ≤ acosh(x) < +∞`。 [`Float64`](/sql-reference/data-types/float) -## exp {#exp} +**示例** -返回 $e^{x}$,其中 x 是传递给函数的参数。 +**用法示例** + +```sql title=Query +SELECT acosh(1) +``` + +```response title=Response +0 +``` + + + +## asin {#asin} + +引入于:v1.1 + + +计算给定参数的反正弦值。 +对于范围 `[-1, 1]` 内的参数,返回值在范围 `[-pi() / 2, pi() / 2]` 内。 + **语法** ```sql -exp(x) +asin(x) ``` **参数** -- `x` - [(U)Int*](../data-types/int-uint.md),[Float*](../data-types/float.md) 或 [Decimal*](../data-types/decimal.md)。 +- `x` — 要计算其反正弦值的参数。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal`](/sql-reference/data-types/decimal) + + +**返回值** + +返回提供的参数 `x` 的反正弦值 [`Float64`](/sql-reference/data-types/float) **示例** -查询: +**反向** -```sql -SELECT round(exp(-1), 4); +```sql title=Query +SELECT asin(1.0) = pi() / 2, sin(asin(1)), asin(sin(1)) ``` -结果: +```response title=Response +1 1 1 +``` -```response -┌─round(exp(-1), 4)─┐ -│ 0.3679 │ -└───────────────────┘ +**float32** + +```sql title=Query +SELECT toTypeName(asin(1.0::Float32)) ``` -**返回值** +```response title=Response +Float64 +``` -类型: [Float*](../data-types/float.md)。 +**nan** -## log {#log} +```sql title=Query +SELECT asin(1.1), asin(-2), asin(inf), asin(nan) +``` + +```response title=Response +nan nan nan nan +``` + + + +## asinh {#asinh} + +引入于:v20.12 + + +返回反双曲正弦值。 -返回参数的自然对数。 **语法** ```sql -log(x) +asinh(x) ``` -别名: `ln(x)` - **参数** -- `x` - [(U)Int*](../data-types/int-uint.md),[Float*](../data-types/float.md) 或 [Decimal*](../data-types/decimal.md)。 +- `x` — 角度的双曲正弦值。值在区间:`-∞ < x < +∞`。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal*`](/sql-reference/data-types/decimal) + **返回值** -类型: [Float*](../data-types/float.md)。 +返回角度,以弧度为单位。值在区间:`-∞ < asinh(x) < +∞`。 [`Float64`](/sql-reference/data-types/float) + +**示例** + +**基本用法** + +```sql title=Query +SELECT asinh(0) +``` + +```response title=Response +0 +``` -## exp2 {#exp2} -返回 2 的给定参数的幂。 + +## atan {#atan} + +引入于:v1.1 + + +返回参数的反正切值。 + **语法** ```sql -exp2(x) +atan(x) ``` **参数** -- `x` - [(U)Int*](../data-types/int-uint.md),[Float*](../data-types/float.md) 或 [Decimal*](../data-types/decimal.md)。 +- `x` — 要查找其反正切值的值。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal*`](/sql-reference/data-types/decimal) + **返回值** -类型: [Float*](../data-types/float.md)。 +返回 `x` 的反正切值。 [`Float*`](/sql-reference/data-types/float) + +**示例** + +**用法示例** -## intExp2 {#intexp2} +```sql title=Query +SELECT atan(1); +``` + +```response title=Response +0.7853981633974483 +``` + + + +## atan2 {#atan2} + +引入于:v20.12 + + +返回以弧度表示的欧几里得平面中,正 x 轴与指向点 `(x, y) ≠ (0, 0)` 的射线之间的角度. -类似于 [`exp`](#exp),但返回 UInt64。 **语法** ```sql -intExp2(x) +atan2(y, x) ``` -## log2 {#log2} +**参数** + +- `y` — 射线经过的点的 y 坐标。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal*`](/sql-reference/data-types/decimal) +- `x` — 射线经过的点的 x 坐标。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal*`](/sql-reference/data-types/decimal) + + +**返回值** + +返回角度 `θ` 满足 `-π < θ ≤ π`,以弧度表示 [`Float64`](/sql-reference/data-types/float) + +**示例** + +**用法示例** + +```sql title=Query +SELECT atan2(1, 1) +``` + +```response title=Response +0.7853981633974483 +``` + + + +## atanh {#atanh} + +引入于:v20.12 + + +返回反双曲正切值。 -返回参数的二进制对数。 **语法** ```sql -log2(x) +atanh(x) ``` **参数** -- `x` - [(U)Int*](../data-types/int-uint.md),[Float*](../data-types/float.md) 或 [Decimal*](../data-types/decimal.md)。 +- `x` — 角度的双曲正切值。值在区间:-1 < x < 1。 `(U)Int*`、`Float*` 或 `Decimal*`。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal*`](/sql-reference/data-types/decimal) + **返回值** -类型: [Float*](../data-types/float.md)。 +返回角度,以弧度为单位。值在区间:-∞ < atanh(x) < +∞ [`Float64`](/sql-reference/data-types/float) -## exp10 {#exp10} +**示例** + +**用法示例** + +```sql title=Query +SELECT atanh(0) +``` + +```response title=Response +0 +``` + + + +## cbrt {#cbrt} + +引入于:v1.1 + + +返回参数的立方根。 -返回 10 的给定参数的幂。 **语法** ```sql -exp10(x) +cbrt(x) ``` **参数** -- `x` - [(U)Int*](../data-types/int-uint.md),[Float*](../data-types/float.md) 或 [Decimal*](../data-types/decimal.md)。 +- `x` — 要查找立方根的值。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal*`](/sql-reference/data-types/decimal) + **返回值** -类型: [Float*](../data-types/float.md)。 +返回 `x` 的立方根。 [`Float*`](/sql-reference/data-types/float) + +**示例** + +**用法示例** + +```sql title=Query +SELECT cbrt(8); +``` + +```response title=Response +2 +``` -## intExp10 {#intexp10} -类似于 [`exp10`](#exp10),但返回 UInt64。 + +## cos {#cos} + +引入于:v1.1 + + +返回参数的余弦值。 + **语法** ```sql -intExp10(x) +cos(x) ``` -## log10 {#log10} +**参数** + +- `x` — 以弧度表示的角度。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal*`](/sql-reference/data-types/decimal) + + +**返回值** + +返回 `x` 的余弦值。 [`Float*`](/sql-reference/data-types/float) + +**示例** + +**用法示例** + +```sql title=Query +SELECT cos(0); +``` + +```response title=Response +1 +``` + + + +## cosh {#cosh} + +引入于:v20.12 + + +返回参数的双曲余弦值。 -返回参数的十进制对数。 **语法** ```sql -log10(x) +cosh(x) ``` **参数** -- `x` - [(U)Int*](../data-types/int-uint.md),[Float*](../data-types/float.md) 或 [Decimal*](../data-types/decimal.md)。 +- `x` — 角度,以弧度为单位。值在区间:`-∞ < x < +∞`。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal*`](/sql-reference/data-types/decimal) + **返回值** -类型: [Float*](../data-types/float.md)。 +返回值在区间:`1 ≤ cosh(x) < +∞` [`Float64`](/sql-reference/data-types/float) -## sqrt {#sqrt} +**示例** -返回参数的平方根。 +**基本用法** + +```sql title=Query +SELECT cosh(0) +``` + +```response title=Response +1 +``` + + + +## degrees {#degrees} + +引入于:v22.2 + + +将弧度转换为度。 + + +**语法** ```sql -sqrt(x) +degrees(x) ``` **参数** -- `x` - [(U)Int*](../data-types/int-uint.md),[Float*](../data-types/float.md) 或 [Decimal*](../data-types/decimal.md)。 +- `x` — 以弧度为输入。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal*`](/sql-reference/data-types/decimal) + **返回值** -类型: [Float*](../data-types/float.md)。 +返回以度为单位的 `x` 值。 [`Float64`](/sql-reference/data-types/float) + +**示例** + +**基本用法** + +```sql title=Query +SELECT degrees(3.141592653589793) +``` + +```response title=Response +180 +``` -## cbrt {#cbrt} -返回参数的立方根。 + +## e {#e} + +引入于:v1.1 + + +返回欧拉常数 (e)。 + + +**语法** ```sql -cbrt(x) +e() ``` **参数** -- `x` - [(U)Int*](../data-types/int-uint.md),[Float*](../data-types/float.md) 或 [Decimal*](../data-types/decimal.md)。 - +- 无。 **返回值** -类型: [Float*](../data-types/float.md)。 +返回欧拉常数 [`Float64`](/sql-reference/data-types/float) + +**示例** + +**用法示例** + +```sql title=Query +SELECT e(); +``` + +```response title=Response +2.718281828459045 +``` + + ## erf {#erf} -如果 `x` 非负,则 $erf(\frac{x}{\sigma\sqrt{2}})$ 是一个随机变量具有标准差为 $\sigma$ 的正态分布时,取值与期望值相隔超过 `x` 的概率。 +引入于:v1.1 + + +如果 `x` 非负,则 `erf(x/(σ√2))` 是随机变量具有标准差为 `σ` 的正态分布的概率,该变量取值与期望值的偏差大于 `x`。 + **语法** @@ -227,29 +496,36 @@ erf(x) **参数** -- `x` - [(U)Int*](../data-types/int-uint.md),[Float*](../data-types/float.md) 或 [Decimal*](../data-types/decimal.md)。 +- `x` — 要计算误差函数值的值。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal*`](/sql-reference/data-types/decimal) + **返回值** -类型: [Float*](../data-types/float.md)。 +返回误差函数值 [`Float*`](/sql-reference/data-types/float) **示例** -(三个西格玛法则) +**三西格玛法则** -```sql -SELECT erf(3 / sqrt(2)); +```sql title=Query +SELECT erf(3 / sqrt(2)) ``` -```result +```response title=Response ┌─erf(divide(3, sqrt(2)))─┐ │ 0.9973002039367398 │ └─────────────────────────┘ ``` + + ## erfc {#erfc} -返回接近 $1-erf(x)$ 的数字,而在大 `x` 值下精度不丢失。 +引入于:v1.1 + + +返回接近 `1-erf(x)` 的数值,在大 `x` 值的情况下,不会造成精度损失。 + **语法** @@ -259,767 +535,904 @@ erfc(x) **参数** -- `x` - [(U)Int*](../data-types/int-uint.md),[Float*](../data-types/float.md) 或 [Decimal*](../data-types/decimal.md)。 +- `x` — 要查找误差函数值的值。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal*`](/sql-reference/data-types/decimal) + **返回值** -类型: [Float*](../data-types/float.md)。 +返回互补误差函数值 [`Float*`](/sql-reference/data-types/float) -## lgamma {#lgamma} +**示例** + +**用法示例** + +```sql title=Query +SELECT erfc(0); +``` + +```response title=Response +1 +``` + + + +## exp {#exp} + +引入于:v1.1 + + +返回 e 的 x 次方,这里的 `x` 是传递给函数的给定参数。 -返回伽马函数的对数。 **语法** ```sql -lgamma(x) +exp(x) ``` **参数** -- `x` - [(U)Int*](../data-types/int-uint.md),[Float*](../data-types/float.md) 或 [Decimal*](../data-types/decimal.md)。 +- `x` — 指数。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal*`](/sql-reference/data-types/decimal) + **返回值** -类型: [Float*](../data-types/float.md)。 +返回 `e^x` [`Float*`](/sql-reference/data-types/float) -## tgamma {#tgamma} +**示例** + +**基本用法** + +```sql title=Query +SELECT round(exp(-1), 4) +``` + +```response title=Response +┌─round(exp(-1), 4)─┐ +│ 0.3679 │ +└───────────────────┘ +``` + + + +## exp10 {#exp10} + +引入于:v1.1 + + +返回 10 的给定参数次方。 -返回伽马函数。 **语法** ```sql -gamma(x) +exp10(x) ``` **参数** -- `x` - [(U)Int*](../data-types/int-uint.md),[Float*](../data-types/float.md) 或 [Decimal*](../data-types/decimal.md)。 +- `x` — 指数。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal*`](/sql-reference/data-types/decimal) + **返回值** -类型: [Float*](../data-types/float.md)。 +返回 10^x [`Float*`](/sql-reference/data-types/float) + +**示例** + +**用法示例** + +```sql title=Query +SELECT exp10(2); +``` + +```response title=Response +100 +``` + + + +## exp2 {#exp2} + +引入于:v1.1 -## sin {#sin} -返回参数的正弦。 +返回 2 的给定参数次方。 + **语法** ```sql -sin(x) +exp2(x) ``` **参数** -- `x` - [(U)Int*](../data-types/int-uint.md),[Float*](../data-types/float.md) 或 [Decimal*](../data-types/decimal.md)。 +- `x` — 指数。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal*`](/sql-reference/data-types/decimal) + **返回值** -类型: [Float*](../data-types/float.md)。 +返回 2^x [`Float*`](/sql-reference/data-types/float) **示例** -查询: +**用法示例** + +```sql title=Query +SELECT exp2(3); +``` + +```response title=Response +8 +``` + + + +## factorial {#factorial} + +引入于:v22.11 + + +计算整数值的阶乘。 +0 的阶乘为 1。同样,`factorial()` 函数对于任何负值返回 `1`。 +输入参数的最大正值为 `20`,值为 `21` 或更大将导致异常。 + + +**语法** ```sql -SELECT sin(1.23); +factorial(n) ``` -```response -0.9424888019316975 +**参数** + +- `n` — 要计算阶乘的整数值。 最大值为 20。 [`(U)Int8/16/32/64`](/sql-reference/data-types/int-uint) + + +**返回值** + +返回输入值的阶乘,以 UInt64 表示。 对于输入 0 或任何负值返回 1。 [`UInt64`](/sql-reference/data-types/int-uint) + +**示例** + +**用法示例** + +```sql title=Query +factorial(10) ``` -## cos {#cos} +```response title=Response +3628800 +``` + + + +## hypot {#hypot} + +引入于:v20.12 + + +返回直角三角形的斜边长度。 +hypot 避免了在平方非常大或非常小的数字时出现的问题。 -返回参数的余弦。 **语法** ```sql -cos(x) +hypot(x, y) +``` + +**参数** + +- `x` — 直角三角形的第一条直角边。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal*`](/sql-reference/data-types/decimal) +- `y` — 直角三角形的第二条直角边。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal*`](/sql-reference/data-types/decimal) + + +**返回值** + +返回直角三角形的斜边长度。 [`Float64`](/sql-reference/data-types/float) + +**示例** + +**基本用法** + +```sql title=Query +SELECT hypot(1, 1) +``` + +```response title=Response +1.4142135623730951 +``` + + + +## intExp10 {#intExp10} + +引入于:v1.1 + + +类似于 [exp10](#exp10),但返回一个 `UInt64` 数字。 + + +**语法** + +```sql +intExp10(x) +``` + +**参数** + +- `x` — 指数。 [`Int*`](/sql-reference/data-types/int-uint) 或 [`UInt*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) + + +**返回值** + +返回 10^x。 [`UInt64`](/sql-reference/data-types/int-uint) + +**示例** + +**用法示例** + +```sql title=Query +SELECT intExp10(2); +``` + +```response title=Response +100 +``` + + + +## intExp2 {#intExp2} + +引入于:v1.1 + + +类似于 [exp2](#exp2),但返回一个 `UInt64` 数字。 + + +**语法** + +```sql +intExp2(x) ``` **参数** -- `x` - [(U)Int*](../data-types/int-uint.md),[Float*](../data-types/float.md) 或 [Decimal*](../data-types/decimal.md)。 +- `x` — 指数。 [`Int*`](/sql-reference/data-types/int-uint) 或 [`UInt*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) + **返回值** -类型: [Float*](../data-types/float.md)。 +返回 2^x。 [`UInt64`](/sql-reference/data-types/int-uint) -## tan {#tan} +**示例** -返回参数的正切。 +**用法示例** -**语法** +```sql title=Query +SELECT intExp2(3); +``` -```sql -tan(x) +```response title=Response +8 ``` -**参数** -- `x` - [(U)Int*](../data-types/int-uint.md),[Float*](../data-types/float.md) 或 [Decimal*](../data-types/decimal.md)。 -**返回值** +## lgamma {#lgamma} -类型: [Float*](../data-types/float.md)。 +引入于:v1.1 -## asin {#asin} -返回参数的反正弦。 +返回伽马函数的对数。 + **语法** ```sql -asin(x) +lgamma(x) ``` **参数** -- `x` - [(U)Int*](../data-types/int-uint.md),[Float*](../data-types/float.md) 或 [Decimal*](../data-types/decimal.md)。 +- `x` — 要计算伽马函数对数的数。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal*`](/sql-reference/data-types/decimal) + **返回值** -类型: [Float*](../data-types/float.md)。 +返回 `x` 的伽马函数对数值。 [`Float*`](/sql-reference/data-types/float) -## acos {#acos} +**示例** -返回参数的反余弦。 +**用法示例** -**语法** +```sql title=Query +SELECT lgamma(5); +``` -```sql -acos(x) +```response title=Response +3.1780538303479458 ``` -**参数** -- `x` - [(U)Int*](../data-types/int-uint.md),[Float*](../data-types/float.md) 或 [Decimal*](../data-types/decimal.md)。 -**返回值** +## log {#log} -类型: [Float*](../data-types/float.md)。 +引入于:v1.1 -## atan {#atan} -返回参数的反正切。 +返回参数的自然对数。 + **语法** ```sql -atan(x) +log(x) ``` **参数** -- `x` - [(U)Int*](../data-types/int-uint.md),[Float*](../data-types/float.md) 或 [Decimal*](../data-types/decimal.md)。 +- `x` — 要计算自然对数的数。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal*`](/sql-reference/data-types/decimal) + **返回值** -类型: [Float*](../data-types/float.md)。 +返回 `x` 的自然对数。 [`Float*`](/sql-reference/data-types/float) -## pow {#pow} +**示例** -返回 $x^y$。 +**用法示例** -**语法** +```sql title=Query +SELECT log(10); +``` -```sql -pow(x, y) +```response title=Response +2.302585092994046 ``` -别名: `power(x, y)` -**参数** -- `x` - [(U)Int8/16/32/64](../data-types/int-uint.md),[Float*](../data-types/float.md) 或 [Decimal*](../data-types/decimal.md) -- `y` - [(U)Int8/16/32/64](../data-types/int-uint.md),[Float*](../data-types/float.md) 或 [Decimal*](../data-types/decimal.md) +## log10 {#log10} -**返回值** +引入于:v1.1 -类型: [Float64](../data-types/float.md)。 -## cosh {#cosh} +返回参数的十进制对数。 -返回参数的 [双曲余弦](https://in.mathworks.com/help/matlab/ref/cosh.html)。 **语法** ```sql -cosh(x) +log10(x) ``` **参数** -- `x` — 角度,以弧度为单位。值在区间:$-\infty \lt x \lt +\infty$。[(U)Int*](../data-types/int-uint.md),[Float*](../data-types/float.md) 或 [Decimal*](../data-types/decimal.md)。 +- `x` — 要计算十进制对数的数字。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal*`](/sql-reference/data-types/decimal) -**返回值** -- 值在区间:$1 \le cosh(x) \lt +\infty$。 +**返回值** -类型: [Float64](/sql-reference/data-types/float)。 +返回 `x` 的十进制对数。 [`Float*`](/sql-reference/data-types/float) **示例** -```sql -SELECT cosh(0); -``` +**用法示例** -结果: +```sql title=Query +SELECT log10(100); +``` -```result -┌─cosh(0)──┐ -│ 1 │ -└──────────┘ +```response title=Response +2 ``` -## acosh {#acosh} -返回 [反双曲余弦](https://www.mathworks.com/help/matlab/ref/acosh.html)。 + +## log1p {#log1p} + +引入于:v20.12 + + +计算 log(1+x)。 +对于小值 `x`,计算 log1p(x) 比 log(1+x) 更准确。 + **语法** ```sql -acosh(x) +log1p(x) ``` **参数** -- `x` — 角度的双曲余弦。值在区间:$1 \le x \lt +\infty$。[(U)Int*](../data-types/int-uint.md),[Float*](../data-types/float.md) 或 [Decimal*](../data-types/decimal.md)。 +- `x` — 值在区间:`-1 < x < +∞`。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal*`](/sql-reference/data-types/decimal) -**返回值** -- 角度,以弧度为单位。值在区间:$0 \le acosh(x) \lt +\infty$。 +**返回值** -类型: [Float64](/sql-reference/data-types/float)。 +返回值在区间:-∞ < log1p(x) < +∞ [`Float64`](/sql-reference/data-types/float) **示例** -```sql -SELECT acosh(1); -``` +**用法示例** -结果: +```sql title=Query +SELECT log1p(0) +``` -```result -┌─acosh(1)─┐ -│ 0 │ -└──────────┘ +```response title=Response +0 ``` -## sinh {#sinh} -返回 [双曲正弦](https://www.mathworks.com/help/matlab/ref/sinh.html)。 + +## log2 {#log2} + +引入于:v1.1 + + +返回参数的二进制对数。 + **语法** ```sql -sinh(x) +log2(x) ``` **参数** -- `x` — 角度,以弧度为单位。值在区间:$-\infty \lt x \lt +\infty$。[(U)Int*](../data-types/int-uint.md),[Float*](../data-types/float.md) 或 [Decimal*](../data-types/decimal.md)。 +- `x` — 要计算二进制对数的数字。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal*`](/sql-reference/data-types/decimal) -**返回值** -- 值在区间:$-\infty \lt sinh(x) \lt +\infty$。 +**返回值** -类型: [Float64](/sql-reference/data-types/float)。 +返回 `x` 的二进制对数。 [`Float*`](/sql-reference/data-types/float) **示例** -```sql -SELECT sinh(0); -``` +**用法示例** -结果: +```sql title=Query +SELECT log2(8); +``` -```result -┌─sinh(0)──┐ -│ 0 │ -└──────────┘ +```response title=Response +3 ``` -## asinh {#asinh} -返回 [反双曲正弦](https://www.mathworks.com/help/matlab/ref/asinh.html)。 + +## pi {#pi} + +引入于:v1.1 + + +返回 pi (π)。 + **语法** ```sql -asinh(x) +pi() ``` **参数** -- `x` — 角度的双曲正弦。值在区间:$-\infty \lt x \lt +\infty$。[(U)Int*](../data-types/int-uint.md),[Float*](../data-types/float.md) 或 [Decimal*](../data-types/decimal.md)。 - +- 无。 **返回值** -- 角度,以弧度为单位。值在区间:$-\infty \lt asinh(x) \lt +\infty$。 - -类型: [Float64](/sql-reference/data-types/float)。 +返回 pi [`Float64`](/sql-reference/data-types/float) **示例** -```sql -SELECT asinh(0); -``` +**用法示例** -结果: +```sql title=Query +SELECT pi(); +``` -```result -┌─asinh(0)─┐ -│ 0 │ -└──────────┘ +```response title=Response +3.141592653589793 ``` -## tanh {#tanh} -返回 [双曲正切](https://www.mathworks.com/help/matlab/ref/tanh.html)。 + +## pow {#pow} + +引入于:v1.1 + + +返回 x 的 y 次方。 + **语法** ```sql -tanh(x) +pow(x, y) ``` **参数** -- `x` — 角度,以弧度为单位。值在区间:$-\infty \lt x \lt +\infty$。[(U)Int*](../data-types/int-uint.md),[Float*](../data-types/float.md) 或 [Decimal*](../data-types/decimal.md)。 +- `x` — 基数。 [`(U)Int8/16/32/64`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal*`](/sql-reference/data-types/decimal) +- `y` — 指数。 [`(U)Int8/16/32/64`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal*`](/sql-reference/data-types/decimal) -**返回值** -- 值在区间:$-1 \lt tanh(x) \lt 1$。 +**返回值** -类型: [Float*](/sql-reference/data-types/float)。 +返回 x^y [`Float64`](/sql-reference/data-types/float) **示例** -```sql -SELECT tanh(0); -``` +**用法示例** -结果: +```sql title=Query +SELECT pow(2, 3); +``` -```result -0 +```response title=Response +8 ``` -## atanh {#atanh} -返回 [反双曲正切](https://www.mathworks.com/help/matlab/ref/atanh.html)。 + +## radians {#radians} + +引入于:v22.2 + + +将度转换为弧度。 + **语法** ```sql -atanh(x) +radians(x) ``` **参数** -- `x` — 角度的双曲正切。值在区间:$-1 \lt x \lt 1$。[(U)Int*](../data-types/int-uint.md),[Float*](../data-types/float.md) 或 [Decimal*](../data-types/decimal.md)。 +- `x` — 以度为输入。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal*`](/sql-reference/data-types/decimal) -**返回值** -- 角度,以弧度为单位。值在区间:$-\infty \lt atanh(x) \lt +\infty$。 +**返回值** -类型: [Float64](/sql-reference/data-types/float)。 +返回以弧度表示的值 [`Float64`](/sql-reference/data-types/float) **示例** -```sql -SELECT atanh(0); -``` +**用法示例** -结果: +```sql title=Query +SELECT radians(180) +``` -```result -┌─atanh(0)─┐ -│ 0 │ -└──────────┘ +```response title=Response +3.141592653589793 ``` -## atan2 {#atan2} -返回 [atan2](https://en.wikipedia.org/wiki/Atan2) 作为给定的 Euclidean 平面中,单位为弧度的角度,介于正 x 轴和指向点 `(x, y) ≠ (0, 0)` 的射线之间。 + +## sign {#sign} + +引入于:v21.2 + + +返回实数的符号。 + **语法** ```sql -atan2(y, x) +sign(x) ``` **参数** -- `y` — 射线经过的点的 y 坐标。[(U)Int*](../data-types/int-uint.md),[Float*](../data-types/float.md) 或 [Decimal*](../data-types/decimal.md)。 -- `x` — 射线经过的点的 x 坐标。[(U)Int*](../data-types/int-uint.md),[Float*](../data-types/float.md) 或 [Decimal*](../data-types/decimal.md)。 +- `x` — 值范围从 -∞ 到 +∞。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Decimal*`](/sql-reference/data-types/decimal) 或 [`Float*`](/sql-reference/data-types/float) -**返回值** -- 角度 `θ`,使得 $-\pi \lt 0 \le \pi$,以弧度为单位。 +**返回值** -类型: [Float64](/sql-reference/data-types/float)。 +对于 `x < 0` 返回 `-1`,对于 `x = 0` 返回 `0`,对于 `x > 0` 返回 `1`。 [`Int8`](/sql-reference/data-types/int-uint) **示例** -```sql -SELECT atan2(1, 1); -``` - -结果: +**零的符号** -```result -┌────────atan2(1, 1)─┐ -│ 0.7853981633974483 │ -└────────────────────┘ +```sql title=Query +SELECT sign(0) ``` -## hypot {#hypot} - -返回直角三角形的斜边长度。 [Hypot](https://en.wikipedia.org/wiki/Hypot) 避免了平方过大或过小数字时出现的问题。 - -**语法** - -```sql -hypot(x, y) +```response title=Response +0 ``` -**参数** - -- `x` — 直角三角形的第一条直角边。[(U)Int*](../data-types/int-uint.md),[Float*](../data-types/float.md) 或 [Decimal*](../data-types/decimal.md)。 -- `y` — 直角三角形的第二条直角边。[(U)Int*](../data-types/int-uint.md),[Float*](../data-types/float.md) 或 [Decimal*](../data-types/decimal.md)。 +**正数的符号** -**返回值** +```sql title=Query +SELECT sign(1) +``` -- 直角三角形的斜边长度。 +```response title=Response +1 +``` -类型: [Float64](/sql-reference/data-types/float)。 +**负数的符号** -**示例** +```sql title=Query +SELECT sign(-1) +``` -```sql -SELECT hypot(1, 1); +```response title=Response +-1 ``` -结果: -```result -┌────────hypot(1, 1)─┐ -│ 1.4142135623730951 │ -└────────────────────┘ -``` -## log1p {#log1p} +## sin {#sin} + +引入于:v -计算 `log(1+x)`。 对于小的 `x` 值,[计算](https://en.wikipedia.org/wiki/Natural_logarithm#lnp1) `log1p(x)` 的精度比 `log(1+x)` 更高。 +返回参数的正弦值。 **语法** ```sql -log1p(x) +sin(x) ``` **参数** -- `x` — 值在区间:$-1 \lt x \lt +\infty$。[(U)Int*](../data-types/int-uint.md),[Float*](../data-types/float.md) 或 [Decimal*](../data-types/decimal.md)。 +- `x` — 要返回正弦值的数字。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal*`](/sql-reference/data-types/decimal) -**返回值** -- 值在区间:$-\infty < log1p(x) \lt +\infty$。 +**返回值** -类型: [Float64](/sql-reference/data-types/float)。 +返回 `x` 的正弦值。 **示例** -```sql -SELECT log1p(0); -``` +**简单** -结果: +```sql title=Query +SELECT sin(1.23) +``` -```result -┌─log1p(0)─┐ -│ 0 │ -└──────────┘ +```response title=Response +0.9424888019316975 ``` -## sign {#sign} -返回实数的符号。 + +## sinh {#sinh} + +引入于:v20.12 + + +返回双曲正弦值。 + **语法** ```sql -sign(x) +sinh(x) ``` **参数** -- `x` — 从 $-\infty$ 到 $+\infty$ 的值。支持 ClickHouse 中的所有数字类型。 +- `x` — 角度,以弧度为单位。值在区间:-∞ < x < +∞。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal*`](/sql-reference/data-types/decimal) -**返回值** -- 当 `x < 0` 时,返回 -1 -- 当 `x = 0` 时,返回 0 -- 当 `x > 0` 时,返回 1 +**返回值** -类型: [Int8](../data-types/int-uint.md)。 +返回值在区间:-∞ < sinh(x) < +∞ [`Float64`](/sql-reference/data-types/float) **示例** -零值的符号: - -```sql -SELECT sign(0); -``` - -结果: +**用法示例** -```result -┌─sign(0)─┐ -│ 0 │ -└─────────┘ +```sql title=Query +SELECT sinh(0) ``` -正值的符号: - -```sql -SELECT sign(1); +```response title=Response +0 ``` -结果: - -```result -┌─sign(1)─┐ -│ 1 │ -└─────────┘ -``` -负值的符号: -```sql -SELECT sign(-1); -``` +## sqrt {#sqrt} -结果: +引入于:v1.1 -```result -┌─sign(-1)─┐ -│ -1 │ -└──────────┘ -``` -## sigmoid {#sigmoid} +返回参数的平方根。 -返回 [sigmoid 函数](https://en.wikipedia.org/wiki/Sigmoid_function)。 **语法** ```sql -sigmoid(x) +sqrt(x) ``` **参数** -- `x` — 输入值。值在区间:$-\infty \lt x \lt +\infty$。[(U)Int*](../data-types/int-uint.md),[Float*](../data-types/float.md) 或 [Decimal*](../data-types/decimal.md)。 +- `x` — 要查找平方根的数字。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal*`](/sql-reference/data-types/decimal) + **返回值** -- 位于 0 和 1 之间的 sigmoidal 曲线的对应值。[Float64](../data-types/float.md)。 +返回 `x` 的平方根 [`Float*`](/sql-reference/data-types/float) **示例** -查询: +**用法示例** -```sql -SELECT round(sigmoid(x), 5) FROM (SELECT arrayJoin([-1, 0, 1]) AS x); +```sql title=Query +SELECT sqrt(16); ``` -结果: - -```result -0.26894 -0.5 -0.73106 +```response title=Response +4 ``` -## degrees {#degrees} -将弧度转换为度数。 + +## tan {#tan} + +引入于:v1.1 + + +返回参数的正切值。 + **语法** ```sql -degrees(x) +tan(x) ``` **参数** -- `x` — 以弧度为单位的输入。[(U)Int*](../data-types/int-uint.md),[Float*](../data-types/float.md) 或 [Decimal*](../data-types/decimal.md)。 -- `x` — 以弧度为单位的输入。[(U)Int*](../data-types/int-uint.md),[Float*](../data-types/float.md) 或 [Decimal*](../data-types/decimal.md)。 +- `x` — 以弧度表示的角度。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal*`](/sql-reference/data-types/decimal) + **返回值** -- 度数值。[Float64](/sql-reference/data-types/float)。 +返回 `x` 的正切值。 [`Float*`](/sql-reference/data-types/float) **示例** -```sql -SELECT degrees(3.141592653589793); -``` +**用法示例** -结果: +```sql title=Query +SELECT tan(0); +``` -```result -┌─degrees(3.141592653589793)─┐ -│ 180 │ -└────────────────────────────┘ +```response title=Response +0 ``` -## radians {#radians} -将度数转换为弧度。 + +## tanh {#tanh} + +引入于:v20.1 + + +返回双曲正切值。 + **语法** ```sql -radians(x) +tanh(x) ``` **参数** -- `x` — 以度数为单位的输入。[(U)Int*](../data-types/int-uint.md),[Float*](../data-types/float.md) 或 [Decimal*](../data-types/decimal.md)。 +- `x` — 以弧度表示的角度。值在区间:-∞ < x < +∞。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal*`](/sql-reference/data-types/decimal) -**返回值** -- 弧度中的值。 +**返回值** -类型: [Float64](/sql-reference/data-types/float)。 +返回值在区间:-1 < tanh(x) < 1 [`Float*`](/sql-reference/data-types/float) **示例** -```sql -SELECT radians(180); -``` +**用法示例** -结果: +```sql title=Query +SELECT tanh(0) +``` -```result -┌──────radians(180)─┐ -│ 3.141592653589793 │ -└───────────────────┘ +```response title=Response +0 ``` -## factorial {#factorial} -计算整数值的阶乘。适用于包括 UInt(8|16|32|64) 和 Int(8|16|32|64) 在内的任何原生整数类型。返回类型为 UInt64。 -阶乘 0 的值为 1。同样,factorial() 函数对任何负值返回 1。输入参数的最大正值为 20,输入值 21 或更大将导致抛出异常。 +## tgamma {#tgamma} + +引入于:v1.1 + + +返回伽马函数。 + **语法** ```sql -factorial(n) +tgamma(x) ``` -**示例** +**参数** -```sql -SELECT factorial(10); -``` +- `x` — 要计算伽马函数的数。 [`(U)Int*`](/sql-reference/data-types/int-uint) 或 [`Float*`](/sql-reference/data-types/float) 或 [`Decimal*`](/sql-reference/data-types/decimal) -结果: -```result -┌─factorial(10)─┐ -│ 3628800 │ -└───────────────┘ -``` +**返回值** -## width_bucket {#width_bucket} +返回伽马函数值 [`Float*`](/sql-reference/data-types/float) -返回 `operand` 在直方图中落入的桶的编号,该直方图具有 `count` 个等宽桶,跨越 `low` 到 `high` 的范围。如果 `operand < low`,则返回 `0`,如果 `operand >= high`,则返回 `count+1`。 +**示例** -`operand`,`low`,`high` 可以是任何原生数字类型。`count` 只能是无符号原生整数,其值不能为零。 +**用法示例** -**语法** +```sql title=Query +SELECT tgamma(5); +``` -```sql -widthBucket(operand, low, high, count) +```response title=Response +24 ``` -别名: `WIDTH_BUCKET` -**示例** -```sql -SELECT widthBucket(10.15, -8.6, 23, 18); -``` +## widthBucket {#widthBucket} -结果: +引入于:v23.3 -```result -┌─widthBucket(10.15, -8.6, 23, 18)─┐ -│ 11 │ -└──────────────────────────────────┘ -``` -## proportionsZTest {#proportionsztest} +返回参数 `operand` 在一个有着相等宽度桶的直方图中落入的桶的编号,该直方图的范围从 `low` 到 `high` 的数量。如果 `operand` 小于 `low`,则返回 0;如果 `operand` 大于或等于 `high`,则返回 `count` + 1。 +还有一个不区分大小写的别名 `WIDTH_BUCKET` 以提供与其他数据库的兼容性。 -返回两个比例 Z 检验的测试统计量 - 用于比较来自两个总体 `x` 和 `y` 的比例的统计检验。 **语法** ```sql -proportionsZTest(successes_x, successes_y, trials_x, trials_y, conf_level, pool_type) +widthBucket(operand, low, high, count) ``` **参数** -- `successes_x`: 总体 `x` 中的成功次数。 [UInt64](../data-types/int-uint.md)。 -- `successes_y`: 总体 `y` 中的成功次数。 [UInt64](../data-types/int-uint.md)。 -- `trials_x`: 总体 `x` 中的试验次数。 [UInt64](../data-types/int-uint.md)。 -- `trials_y`: 总体 `y` 中的试验次数。 [UInt64](../data-types/int-uint.md)。 -- `conf_level`: 检测的置信水平。 [Float64](../data-types/float.md)。 -- `pool_type`: 选择池化(估计标准误差的方式)。可以是 `unpooled` 或 `pooled`。 [String](../data-types/string.md)。 +- `operand` — 要确定桶的值。 [`(U)Int8/16/32/64`](/sql-reference/data-types/int-uint) +- `low` — 直方图范围的下界。 [`(U)Int8/16/32/64`](/sql-reference/data-types/int-uint) +- `high` — 直方图范围的上界。 [`(U)Int8/16/32/64`](/sql-reference/data-types/int-uint) +- `count` — 桶的数量。不能为零。 [`UInt8/16/32/64`](/sql-reference/data-types/int-uint) -:::note -对于参数 `pool_type`:在池化版本中,两个比例平均,并且只使用一个比例来估计标准误差。在非池化版本中,则分别使用两个比例。 -::: **返回值** -- `z_stat`: Z 统计量。 [Float64](../data-types/float.md)。 -- `p_val`: P 值。 [Float64](../data-types/float.md)。 -- `ci_low`: 下置信区间。 [Float64](../data-types/float.md)。 -- `ci_high`: 上置信区间。 [Float64](../data-types/float.md)。 +作为整数返回桶的编号。如果 operand < low,返回 0;如果 operand >= high,返回 count + 1。 [`UInt8/16/32/64`](/sql-reference/data-types/int-uint) **示例** -查询: +**用法示例** -```sql -SELECT proportionsZTest(10, 11, 100, 101, 0.95, 'unpooled'); +```sql title=Query +widthBucket(10.15, -8.6, 23, 18) ``` -结果: - -```response -┌─proportionsZTest(10, 11, 100, 101, 0.95, 'unpooled')───────────────────────────────┐ -│ (-0.20656724435948853,0.8363478437079654,-0.09345975390115283,0.07563797172293502) │ -└────────────────────────────────────────────────────────────────────────────────────┘ +```response title=Response +11 ``` - - + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/math-functions.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/math-functions.md.hash index 9d7f36941fb..d3c8c6b82c5 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/math-functions.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/math-functions.md.hash @@ -1 +1 @@ -2064dad2d4f81ae1 +079f1de1414a4bd5 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/nlp-functions.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/nlp-functions.md index 893f7898d0e..2511d26441e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/nlp-functions.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/nlp-functions.md @@ -1,9 +1,12 @@ --- 'description': '自然语言处理 (NLP) 函数的文档' 'sidebar_label': 'NLP' -'sidebar_position': 130 'slug': '/sql-reference/functions/nlp-functions' 'title': '自然语言处理 (NLP) 函数' +'doc_type': 'reference' +'keywords': +- 'NLP' +- 'Natural Language Processing' --- import ExperimentalBadge from '@theme/badges/ExperimentalBadge'; @@ -16,400 +19,372 @@ import CloudNotSupportedBadge from '@theme/badges/CloudNotSupportedBadge'; :::warning -这是一个正在开发中的实验性功能,目前尚未准备好供一般使用。它将在未来的版本中以不可预测的向后不兼容方式进行更改。设置 `allow_experimental_nlp_functions = 1` 以启用它。 +这是一个实验性功能,当前正在开发中,并尚未准备好供一般使用。它将在未来的版本中以不可预测的向后不兼容的方式发生变化。设置 `allow_experimental_nlp_functions = 1` 以启用它。 ::: -## detectCharset {#detectcharset} + -`detectCharset` 函数用于检测非UTF8编码输入字符串的字符集。 + +## detectCharset {#detectCharset} -*语法* +引入于: v22.2 + + +检测非UTF8编码输入字符串的字符集。 + + +**语法** ```sql -detectCharset('text_to_be_analyzed') +detectCharset(s) ``` -*参数* +**参数** -- `text_to_be_analyzed` — 要分析的字符串集合(或句子)。 [String](/sql-reference/data-types/string)。 +- `s` — 要分析的文本。 [`String`](/sql-reference/data-types/string) -*返回值* -- 一个包含检测到的字符集代码的 `String` +**返回值** -*示例* +返回一个包含检测到的字符集代码的字符串 [`String`](/sql-reference/data-types/string) -查询: +**示例** -```sql -SELECT detectCharset('Ich bleibe für ein paar Tage.'); -``` +**基本用法** -结果: +```sql title=Query +SELECT detectCharset('Ich bleibe für ein paar Tage.') +``` -```response -┌─detectCharset('Ich bleibe für ein paar Tage.')─┐ -│ WINDOWS-1252 │ -└────────────────────────────────────────────────┘ +```response title=Response +WINDOWS-1252 ``` -## detectLanguage {#detectlanguage} -检测UTF8编码输入字符串的语言。该函数使用 [CLD2 library](https://github.com/CLD2Owners/cld2) 进行检测,并返回2字母的ISO语言代码。 -`detectLanguage` 函数在输入字符串中提供超过200个字符时效果最佳。 +## detectLanguage {#detectLanguage} + +引入于: v22.2 + + +检测UTF8编码输入字符串的语言。 +该函数使用 [CLD2 库](https://github.com/CLD2Owners/cld2) 进行检测,并返回 2 字母 ISO 语言代码。 + +输入的文本越长,语言检测的精确度越高。 -*语法* + +**语法** ```sql -detectLanguage('text_to_be_analyzed') +detectLanguage(s) ``` -*参数* - -- `text_to_be_analyzed` — 要分析的字符串集合(或句子)。 [String](/sql-reference/data-types/string)。 +**参数** -*返回值* +- `text_to_be_analyzed` — 要分析的文本。 [`String`](/sql-reference/data-types/string) -- 检测到的语言的2字母ISO代码 -其他可能的结果: +**返回值** -- `un` = unknown,无法检测任何语言。 -- `other` = 检测到的语言没有2字母代码。 +返回检测到的语言的 2 字母 ISO 代码。其他可能的结果:`un` = 未知,无法检测任何语言,`other` = 检测到的语言没有 2 字母代码。 [`String`](/sql-reference/data-types/string) -*示例* +**示例** -查询: +**混合语言文本** -```sql -SELECT detectLanguage('Je pense que je ne parviendrai jamais à parler français comme un natif. Where there's a will, there's a way.'); +```sql title=Query +SELECT detectLanguage('Je pense que je ne parviendrai jamais à parler français comme un natif. Where there\'s a will, there\'s a way.') ``` -结果: - -```response +```response title=Response fr ``` -## detectLanguageMixed {#detectlanguagemixed} -与 `detectLanguage` 函数类似,但 `detectLanguageMixed` 返回一个 `Map`,其中2字母语言代码映射到文本中特定语言的百分比。 -*语法* +## detectLanguageMixed {#detectLanguageMixed} + +引入于: v22.2 + + +与 [`detectLanguage`](#detectLanguage) 函数类似,但 `detectLanguageMixed` 返回一个 `Map`,其 2 字母语言代码映射到文本中相应语言的百分比。 + + +**语法** ```sql -detectLanguageMixed('text_to_be_analyzed') +detectLanguageMixed(s) ``` -*参数* +**参数** -- `text_to_be_analyzed` — 要分析的字符串集合(或句子)。 [String](/sql-reference/data-types/string)。 +- `s` — 要分析的文本 [`String`](/sql-reference/data-types/string) -*返回值* -- `Map(String, Float32)`: 键是2字母ISO代码,值是文本中找到的该语言的百分比 +**返回值** -*示例* +返回一个映射,键为 2 字母 ISO 代码,对应值为该语言在文本中所占的百分比 [`Map(String, Float32)`](/sql-reference/data-types/map) -查询: +**示例** -```sql -SELECT detectLanguageMixed('二兎を追う者は一兎をも得ず二兎を追う者は一兎をも得ず A vaincre sans peril, on triomphe sans gloire.'); -``` +**混合语言** -结果: +```sql title=Query +SELECT detectLanguageMixed('二兎を追う者は一兎をも得ず二兎を追う者は一兎をも得ず A vaincre sans peril, on triomphe sans gloire.') +``` -```response -┌─detectLanguageMixed()─┐ -│ {'ja':0.62,'fr':0.36 │ -└───────────────────────┘ +```response title=Response +{'ja':0.62,'fr':0.36} ``` -## detectProgrammingLanguage {#detectprogramminglanguage} -从源代码中确定编程语言。计算源代码中命令的所有单元组和双元组。 -然后,使用带权重的各种编程语言的单元组和双元组标记字典,找到编程语言的最大权重并返回它。 -*语法* +## detectLanguageUnknown {#detectLanguageUnknown} + +引入于: v22.2 + + +与 [`detectLanguage`](#detectLanguage) 函数类似,但 detectLanguageUnknown 函数处理非UTF8编码字符串。当字符集为 UTF-16 或 UTF-32 时,请优先使用此版本。 + + +**语法** ```sql -detectProgrammingLanguage('source_code') +detectLanguageUnknown('s') ``` -*参数* +**参数** -- `source_code` — 要分析的源代码的字符串表示。 [String](/sql-reference/data-types/string)。 +- `s` — 要分析的文本。 [`String`](/sql-reference/data-types/string) -*返回值* -- 编程语言。 [String](../data-types/string.md)。 +**返回值** -*示例* +返回检测到的语言的 2 字母 ISO 代码。其他可能的结果:`un` = 未知,无法检测任何语言,`other` = 检测到的语言没有 2 字母代码。 [`String`](/sql-reference/data-types/string) -查询: +**示例** -```sql -SELECT detectProgrammingLanguage('#include '); -``` +**基本用法** -结果: +```sql title=Query +SELECT detectLanguageUnknown('Ich bleibe für ein paar Tage.') +``` -```response -┌─detectProgrammingLanguage('#include ')─┐ -│ C++ │ -└──────────────────────────────────────────────────┘ +```response title=Response +de ``` -## detectLanguageUnknown {#detectlanguageunknown} -与 `detectLanguage` 函数类似,但 `detectLanguageUnknown` 函数处理非UTF8编码字符串。当你的字符集为UTF-16或UTF-32时,优先使用此版本。 -*语法* +## detectProgrammingLanguage {#detectProgrammingLanguage} + +引入于: v22.2 + + +从给定的源代码片段中确定编程语言。 + + +**语法** ```sql -detectLanguageUnknown('text_to_be_analyzed') +detectProgrammingLanguage('source_code') ``` -*参数* +**参数** -- `text_to_be_analyzed` — 要分析的字符串集合(或句子)。 [String](/sql-reference/data-types/string)。 +- `source_code` — 要分析的源代码的字符串表示。 [`String`](/sql-reference/data-types/string) -*返回值* -- 检测到的语言的2字母ISO代码 +**返回值** -其他可能的结果: +返回编程语言 [`String`](/sql-reference/data-types/string) -- `un` = unknown,无法检测任何语言。 -- `other` = 检测到的语言没有2字母代码。 +**示例** -*示例* +**C++ 代码检测** -查询: +```sql title=Query +SELECT detectProgrammingLanguage('#include ') +``` -```sql -SELECT detectLanguageUnknown('Ich bleibe für ein paar Tage.'); +```response title=Response +C++ ``` -结果: -```response -┌─detectLanguageUnknown('Ich bleibe für ein paar Tage.')─┐ -│ de │ -└────────────────────────────────────────────────────────┘ -``` -## detectTonality {#detecttonality} +## detectTonality {#detectTonality} + +引入于: v22.2 + -确定文本数据的情感。使用标记的情感字典,其中每个单词的情感范围为 `-12` 到 `6`。 -对于每段文本,它计算其单词的平均情感值,并在 `[-1,1]` 范围内返回。 +确定提供的文本数据的情感。 -:::note -此函数目前的形式受限。当前使用位于 `/contrib/nlp-data/tonality_ru.zst` 的嵌入式情感字典,仅适用于俄语。 +:::note 限制 +此函数在当前形式下受到限制,因为它使用嵌入的情感词典,仅对俄语有效。 ::: -*语法* + +**语法** ```sql -detectTonality(text) +detectTonality(s) ``` -*参数* +**参数** -- `text` — 要分析的文本。 [String](/sql-reference/data-types/string)。 +- `s` — 要分析的文本。 [`String`](/sql-reference/data-types/string) -*返回值* -- `text` 中单词的平均情感值。 [Float32](../data-types/float.md)。 +**返回值** -*示例* +返回文本中单词的平均情感值 [`Float32`](/sql-reference/data-types/float) -查询: +**示例** -```sql -SELECT detectTonality('Шарик - хороший пёс'), -- Sharik is a good dog - detectTonality('Шарик - пёс'), -- Sharik is a dog - detectTonality('Шарик - плохой пёс'); -- Sharkik is a bad dog -``` +**俄语情感分析** -结果: +```sql title=Query +SELECT + detectTonality('Шарик - хороший пёс'), + detectTonality('Шарик - пёс'), + detectTonality('Шарик - плохой пёс') +``` -```response -┌─detectTonality('Шарик - хороший пёс')─┬─detectTonality('Шарик - пёс')─┬─detectTonality('Шарик - плохой пёс')─┐ -│ 0.44445 │ 0 │ -0.3 │ -└───────────────────────────────────────┴───────────────────────────────┴──────────────────────────────────────┘ +```response title=Response +0.44445, 0, -0.3 ``` + + ## lemmatize {#lemmatize} -对给定单词进行词形还原。需要字典才能操作,可以在 [这里](https://github.com/vpodpecan/lemmagen3/tree/master/src/lemmagen3/models) 获得。 +引入于: v21.9 + + +对给定单词进行词形还原。 +该函数需要字典进行操作,可以从 [github](https://github.com/vpodpecan/lemmagen3/tree/master/src/lemmagen3/models) 获取。有关从本地文件加载字典的更多细节,请参见页面 ["定义字典"](/sql-reference/dictionaries#local-file)。 -*语法* + +**语法** ```sql -lemmatize('language', word) +lemmatize(lang, word) ``` -*参数* +**参数** -- `language` — 将适用规则的语言。 [String](/sql-reference/data-types/string)。 -- `word` — 需要进行词形还原的单词。必须是小写。 [String](/sql-reference/data-types/string)。 +- `lang` — 将应用规则的语言。 [`String`](/sql-reference/data-types/string) +- `word` — 需要进行词形还原的小写单词。 [`String`](/sql-reference/data-types/string) -*示例* -查询: +**返回值** -```sql -SELECT lemmatize('en', 'wolves'); -``` +返回单词的词形还原形式 [`String`](/sql-reference/data-types/string) + +**示例** -结果: +**英语词形还原** -```text -┌─lemmatize("wolves")─┐ -│ "wolf" │ -└─────────────────────┘ +```sql title=Query +SELECT lemmatize('en', 'wolves') ``` -*配置* +```response title=Response +wolf +``` -此配置指定应使用字典 `en.bin` 进行英语(`en`)单词的词形还原。可以从 [这里](https://github.com/vpodpecan/lemmagen3/tree/master/src/lemmagen3/models) 下载 `.bin` 文件。 -```xml - - - - en - en.bin - - - -``` ## stem {#stem} +引入于: v21.9 + + 对给定单词进行词干提取。 -*语法* + +**语法** ```sql -stem('language', word) +stem(lang, word) ``` -*参数* +**参数** -- `language` — 将适用规则的语言。使用两字母 [ISO 639-1 代码](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes)。 -- `word` — 需要进行词干提取的单词。必须是小写。 [String](/sql-reference/data-types/string)。 +- `lang` — 将应用规则的语言。使用两个字母的 ISO 639-1 代码。 [`String`](/sql-reference/data-types/string) +- `word` — 需要进行词干提取的小写单词。 [`String`](/sql-reference/data-types/string) -*示例* -查询: +**返回值** -```sql -SELECT arrayMap(x -> stem('en', x), ['I', 'think', 'it', 'is', 'a', 'blessing', 'in', 'disguise']) as res; -``` +返回单词的词干形式 [`String`](/sql-reference/data-types/string) + +**示例** -结果: +**英语词干提取** -```text -┌─res────────────────────────────────────────────────┐ -│ ['I','think','it','is','a','bless','in','disguis'] │ -└────────────────────────────────────────────────────┘ +```sql title=Query +SELECT arrayMap(x -> stem('en', x), +['I', 'think', 'it', 'is', 'a', 'blessing', 'in', 'disguise']) AS res ``` -*支持的语言用于 stem()* +```response title=Response +['I','think','it','is','a','bless','in','disguis'] +``` -:::note -stem() 函数使用 [Snowball stemming](https://snowballstem.org/) 库,请参阅 Snowball 网站以获取更新的语言等信息。 -::: -- 阿拉伯语 -- 亚美尼亚语 -- 巴斯克语 -- 加泰罗尼亚语 -- 丹麦语 -- 荷兰语 -- 英语 -- 芬兰语 -- 法语 -- 德语 -- 希腊语 -- 印地语 -- 匈牙利语 -- 印度尼西亚语 -- 爱尔兰语 -- 意大利语 -- 立陶宛语 -- 尼泊尔语 -- 挪威语 -- 波特 -- 葡萄牙语 -- 罗马尼亚语 -- 俄语 -- 塞尔维亚语 -- 西班牙语 -- 瑞典语 -- 泰米尔语 -- 土耳其语 -- 意第绪语 ## synonyms {#synonyms} -查找给定单词的同义词。有两种类型的同义词扩展:`plain` 和 `wordnet`。 +引入于: v21.9 + + +查找给定单词的同义词。 + +有两种类型的同义词扩展: +- `plain` +- `wordnet` + +使用 `plain` 扩展类型时,您需要提供一个简单文本文件的路径,其中每行对应于某个同义词集。 +每行中的单词必须用空格或制表符分隔。 -使用 `plain` 扩展类型时,我们需要提供一个简单文本文件的路径,其中每行对应某个同义词集。这行中的单词必须用空格或制表符分隔。 +使用 `wordnet` 扩展类型时,您需要提供一个包含 WordNet 词库的目录的路径。 +词库必须包含 WordNet 意义索引。 -使用 `wordnet` 扩展类型时,我们需要提供一个包含WordNet词库的目录路径。词库必须包含WordNet感知索引。 -*语法* +**语法** ```sql -synonyms('extension_name', word) +synonyms(ext_name, word) ``` -*参数* +**参数** -- `extension_name` — 将执行搜索的扩展的名称。 [String](/sql-reference/data-types/string)。 -- `word` — 将在扩展中搜索的单词。 [String](/sql-reference/data-types/string)。 +- `ext_name` — 将执行搜索的扩展的名称。 [`String`](/sql-reference/data-types/string) +- `word` — 将在扩展中搜索的单词。 [`String`](/sql-reference/data-types/string) -*示例* -查询: +**返回值** -```sql -SELECT synonyms('list', 'important'); -``` +返回给定单词的同义词数组。 [`Array(String)`](/sql-reference/data-types/array) + +**示例** -结果: +**查找同义词** -```text -┌─synonyms('list', 'important')────────────┐ -│ ['important','big','critical','crucial'] │ -└──────────────────────────────────────────┘ +```sql title=Query +SELECT synonyms('list', 'important') ``` -*配置* -```xml - - - en - plain - en.txt - - - en - wordnet - en/ - - +```response title=Response +['important','big','critical','crucial'] ``` - - + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/nlp-functions.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/nlp-functions.md.hash index 7f262a9f75f..ab2b397b6b5 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/nlp-functions.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/nlp-functions.md.hash @@ -1 +1 @@ -671740b06711050c +074564387fb5b810 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/numeric-indexed-vector-functions.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/numeric-indexed-vector-functions.md new file mode 100644 index 00000000000..7de07d62379 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/numeric-indexed-vector-functions.md @@ -0,0 +1,622 @@ +--- +'description': 'Documentation for NumericIndexedVector 和其函数' +'sidebar_label': 'NumericIndexedVector' +'slug': '/sql-reference/functions/numeric-indexed-vector-functions' +'title': 'NumericIndexedVector 函数' +'doc_type': 'reference' +--- + + +# NumericIndexedVector + +NumericIndexedVector 是一种抽象数据结构,封装了一个向量并实现了向量聚合和逐点操作。它的存储方法是 Bit-Sliced Index。有关理论基础和使用场景,请参考论文 [Large-Scale Metric Computation in Online Controlled Experiment Platform](https://arxiv.org/pdf/2405.08411)。 + +## BSI {#bit-sliced-index} + +在 BSI(Bit-Sliced Index)存储方法中,数据以 [Bit-Sliced Index](https://dl.acm.org/doi/abs/10.1145/253260.253268) 的形式存储,然后使用 [Roaring Bitmap](https://github.com/RoaringBitmap/RoaringBitmap) 进行压缩。聚合操作和逐点操作直接在压缩数据上进行,这可以显著提高存储和查询的效率。 + +一个向量包含索引及其对应的值。以下是在 BSI 存储模式下该数据结构的一些特性和限制: + +- 索引类型可以是 `UInt8`、`UInt16` 或 `UInt32`。**注意:** 考虑到 Roaring Bitmap 的 64 位实现性能,BSI 格式不支持 `UInt64`/`Int64`。 +- 值类型可以是 `Int8`、`Int16`、`Int32`、`Int64`、`UInt8`、`UInt16`、`UInt32`、`UInt64`、`Float32` 或 `Float64`。**注意:** 值类型不会自动扩展。例如,如果您使用 `UInt8` 作为值类型,任何超过 `UInt8` 容量的和将导致溢出,而不是提升到更高的类型;同样,整数运算将产生整数结果(例如,除法不会自动转换为浮点结果)。因此,提前规划和设计值类型非常重要。在实际场景中,通常使用浮点类型(`Float32`/`Float64`)。 +- 只有同一索引类型和值类型的两个向量可以进行操作。 +- 底层存储使用 Bit-Sliced Index,位图存储索引。Roaring Bitmap 用作位图的具体实现。最佳实践是尽可能将索引集中在几个 Roaring Bitmap 容器中,以最大化压缩和查询性能。 +- Bit-Sliced Index 机制将值转换为二进制。对于浮点类型,转换使用定点表示,这可能导致精度损失。通过自定义用于小数部分的位数可以调整精度,默认是 24 位,这对于大多数场景来说是足够的。您可以在构建 NumericIndexedVector 时使用聚合函数 groupNumericIndexedVector 与 `-State` 自定义整数位和小数位的位数。 +- 索引有三种情况:非零值、零值和不存在。在 NumericIndexedVector 中,仅存储非零值和零值。此外,在两个 NumericIndexedVectors 之间的逐点操作中,不存在的索引值将视为 0。在除法场景中,当除数为零时,结果为零。 + +## Create a numericIndexedVector object {#create-numeric-indexed-vector-object} + +创建此结构有两种方法:一种是使用带有 `-State` 的聚合函数 `groupNumericIndexedVector`。您可以添加后缀 `-if` 以接受额外的条件。聚合函数将仅处理触发条件的行。另一种是使用 `numericIndexedVectorBuild` 从映射构建它。`groupNumericIndexedVectorState` 函数通过参数允许自定义整数位和小数位的数量,而 `numericIndexedVectorBuild` 则不支持。 + +## groupNumericIndexedVector {#group-numeric-indexed-vector} + +从两个数据列构建一个 NumericIndexedVector,并返回所有值的总和,类型为 `Float64`。如果添加后缀 `State`,则返回一个 NumericIndexedVector 对象。 + +**语法** + +```sql +groupNumericIndexedVectorState(col1, col2) +groupNumericIndexedVectorState(type, integer_bit_num, fraction_bit_num)(col1, col2) +``` + +**参数** + +- `type`: 字符串,可选。指定存储格式。目前仅支持 `'BSI'`。 +- `integer_bit_num`: `UInt32`,可选。在 `'BSI'` 存储格式下有效,此参数指示用于整数部分的位数。当索引类型为整数类型时,默认值对应于用于存储索引的位数。例如,如果索引类型是 UInt16,则默认 `integer_bit_num` 为 16。对于 Float32 和 Float64 索引类型,`integer_bit_num` 的默认值为 40,从而可以表示的数据的整数部分在范围 `[-2^39, 2^39 - 1]` 内。合法范围是 `[0, 64]`。 +- `fraction_bit_num`: `UInt32`,可选。在 `'BSI'` 存储格式下有效,此参数指示用于小数部分的位数。当值类型为整数时,默认值为 0;当值类型为 Float32 或 Float64 类型时,默认值为 24。有效范围是 `[0, 24]`。 +- 还有一个约束,即 integer_bit_num + fraction_bit_num 的有效范围为 [0, 64]。 +- `col1`: 索引列。支持的类型:`UInt8`/`UInt16`/`UInt32`/`Int8`/`Int16`/`Int32`。 +- `col2`: 值列。支持的类型:`Int8`/`Int16`/`Int32`/`Int64`/`UInt8`/`UInt16`/`UInt32`/`UInt64`/`Float32`/`Float64`。 + +**返回值** + +一个 `Float64` 值,表示所有值的总和。 + +**示例** + +测试数据: + +```text +UserID PlayTime +1 10 +2 20 +3 30 +``` + +查询 & 结果: + +```sql +SELECT groupNumericIndexedVector(UserID, PlayTime) AS num FROM t; +┌─num─┐ +│ 60 │ +└─────┘ + +SELECT groupNumericIndexedVectorState(UserID, PlayTime) as res, toTypeName(res), numericIndexedVectorAllValueSum(res) FROM t; +┌─res─┬─toTypeName(res)─────────────────────────────────────────────┬─numericIndexedVectorAllValueSum(res)──┐ +│ │ AggregateFunction(groupNumericIndexedVector, UInt8, UInt8) │ 60 │ +└─────┴─────────────────────────────────────────────────────────────┴───────────────────────────────────────┘ + +SELECT groupNumericIndexedVectorStateIf(UserID, PlayTime, day = '2025-04-22') as res, toTypeName(res), numericIndexedVectorAllValueSum(res) FROM t; +┌─res─┬─toTypeName(res)────────────────────────────────────────────┬─numericIndexedVectorAllValueSum(res)──┐ +│ │ AggregateFunction(groupNumericIndexedVector, UInt8, UInt8) │ 30 │ +└─────┴────────────────────────────────────────────────────────────┴───────────────────────────────────────┘ + +SELECT groupNumericIndexedVectorStateIf('BSI', 32, 0)(UserID, PlayTime, day = '2025-04-22') as res, toTypeName(res), numericIndexedVectorAllValueSum(res) FROM t; +┌─res─┬─toTypeName(res)──────────────────────────────────────────────────────────┬─numericIndexedVectorAllValueSum(res)──┐ +│ │ AggregateFunction('BSI', 32, 0)(groupNumericIndexedVector, UInt8, UInt8) │ 30 │ +└─────┴──────────────────────────────────────────────────────────────────────────┴───────────────────────────────────────┘ +``` + +## numericIndexedVectorBuild {#numeric-indexed-vector-build} + +从映射创建一个 NumericIndexedVector。映射的键代表向量的索引,映射的值代表向量的值。 + +语法 + +```sql +numericIndexedVectorBuild(map) +``` + +参数 + +- `map` – 一个从索引到值的映射。 + +示例 + +```sql +SELECT numericIndexedVectorBuild(mapFromArrays([1, 2, 3], [10, 20, 30])) AS res, toTypeName(res); +``` + +结果 + +```text +┌─res─┬─toTypeName(res)────────────────────────────────────────────┐ +│ │ AggregateFunction(groupNumericIndexedVector, UInt8, UInt8) │ +└─────┴────────────────────────────────────────────────────────────┘ +``` + +## numericIndexedVectorToMap + +将 NumericIndexedVector 转换为映射。 + +语法 + +```sql +numericIndexedVectorToMap(numericIndexedVector) +``` + +参数 + +- `numericIndexedVector` – 一个 NumericIndexedVector 对象。 + +示例 + +```sql +SELECT numericIndexedVectorToMap(numericIndexedVectorBuild(mapFromArrays([1, 2, 3], [10, 20, 30]))) AS res; +``` + +结果 + +```text +┌─res──────────────┐ +│ {1:10,2:20,3:30} │ +└──────────────────┘ +``` + +## numericIndexedVectorCardinality + +返回 NumericIndexedVector 的基数(唯一索引的数量)。 + +语法 + +```sql +numericIndexedVectorCardinality(numericIndexedVector) +``` + +参数 + +- `numericIndexedVector` – 一个 NumericIndexedVector 对象。 + +示例 + +```sql +SELECT numericIndexedVectorCardinality(numericIndexedVectorBuild(mapFromArrays([1, 2, 3], [10, 20, 30]))) AS res; +``` + +结果 + +```text +┌─res─┐ +│ 3 │ +└─────┘ +``` + +## numericIndexedVectorAllValueSum + +返回 NumericIndexedVector 中所有值的总和。 + +语法 + +```sql +numericIndexedVectorAllValueSum(numericIndexedVector) +``` + +参数 + +- `numericIndexedVector` – 一个 NumericIndexedVector 对象。 + +示例 + +```sql +SELECT numericIndexedVectorAllValueSum(numericIndexedVectorBuild(mapFromArrays([1, 2, 3], [10, 20, 30]))) AS res; +``` + +结果 + +```text +┌─res─┐ +│ 60 │ +└─────┘ +``` + +## numericIndexedVectorGetValue + +检索对应于指定索引的值。 + +语法 + +```sql +numericIndexedVectorGetValue(numericIndexedVector, index) +``` + +参数 + +- `numericIndexedVector` – 一个 NumericIndexedVector 对象。 +- `index` – 要检索其值的索引。 + +示例 + +```sql +SELECT numericIndexedVectorGetValue(numericIndexedVectorBuild(mapFromArrays([1, 2, 3], [10, 20, 30])), 3) AS res; +``` + +结果 + +```text +┌─res─┐ +│ 30 │ +└─────┘ +``` + +## numericIndexedVectorShortDebugString + +以 json 格式返回 NumericIndexedVector 的内部信息。此函数主要用于调试目的。 + +语法 + +```sql +numericIndexedVectorShortDebugString(numericIndexedVector) +``` + +参数 + +- `numericIndexedVector` – 一个 NumericIndexedVector 对象。 + +示例 + +```sql +SELECT numericIndexedVectorShortDebugString(numericIndexedVectorBuild(mapFromArrays([1, 2, 3], [10, 20, 30]))) AS res\G; +``` + +结果 + +```text +Row 1: +────── +res: {"vector_type":"BSI","index_type":"char8_t","value_type":"char8_t","integer_bit_num":8,"fraction_bit_num":0,"zero_indexes_info":{"cardinality":"0"},"non_zero_indexes_info":{"total_cardinality":"3","all_value_sum":60,"number_of_bitmaps":"8","bitmap_info":{"cardinality":{"0":"0","1":"2","2":"2","3":"2","4":"2","5":"0","6":"0","7":"0"}}}} +``` + +- `vector_type`: 向量的存储类型,目前仅支持 `BSI`。 +- `index_type`: 索引的类型。 +- `value_type`: 值的类型。 + +在 BSI 向量类型下,以下信息是有效的。 + +- `integer_bit_num`: 用于整数部分的位数。 +- `fraction_bit_num`: 用于小数部分的位数。 +- `zero_indexes info`: 值等于 0 的索引的信息 + - `cardinality`: 值等于 0 的索引数量。 +- `non_zero_indexes info`: 值不等于 0 的索引的信息 + - `total_cardinality`: 值不等于 0 的索引数量。 + - `all value sum`: 所有值的总和。 + - `number_of_bitmaps`: 此索引值不等于 0 时使用的位图数量。 + - `bitmap_info`: 每个位图的信息 + - `cardinality`: 每个位图中的索引数量。 + +## numericIndexedVectorPointwiseAdd + +在 NumericIndexedVector 和另一个 NumericIndexedVector 或数字常量之间执行逐点加法。该函数返回一个新的 NumericIndexedVector。 + +语法 + +```sql +numericIndexedVectorPointwiseAdd(numericIndexedVector, numericIndexedVector | numeric) +``` + +参数 + +- `numericIndexedVector` – 一个 NumericIndexedVector 对象。 +- `numeric` - 一个数字常量。 + +示例 + +```sql +WITH + numericIndexedVectorBuild(mapFromArrays([1, 2, 3], arrayMap(x -> toInt32(x), [10, 20, 30]))) AS vec1, + numericIndexedVectorBuild(mapFromArrays([2, 3, 4], arrayMap(x -> toInt32(x), [10, 20, 30]))) AS vec2 +SELECT + numericIndexedVectorToMap(numericIndexedVectorPointwiseAdd(vec1, vec2)) AS res1, + numericIndexedVectorToMap(numericIndexedVectorPointwiseAdd(vec1, 2)) AS res2; +``` + +结果 + +```text +┌─res1──────────────────┬─res2─────────────┐ +│ {1:10,2:30,3:50,4:30} │ {1:12,2:22,3:32} │ +└───────────────────────┴──────────────────┘ +``` + +## numericIndexedVectorPointwiseSubtract + +在 NumericIndexedVector 和另一个 NumericIndexedVector 或数字常量之间执行逐点减法。该函数返回一个新的 NumericIndexedVector。 + +语法 + +```sql +numericIndexedVectorPointwiseSubtract(numericIndexedVector, numericIndexedVector | numeric) +``` + +参数 + +- `numericIndexedVector` – 一个 NumericIndexedVector 对象。 +- `numeric` - 一个数字常量。 + +示例 + +```sql +WITH + numericIndexedVectorBuild(mapFromArrays([1, 2, 3], arrayMap(x -> toInt32(x), [10, 20, 30]))) AS vec1, + numericIndexedVectorBuild(mapFromArrays([2, 3, 4], arrayMap(x -> toInt32(x), [10, 20, 30]))) AS vec2 +SELECT + numericIndexedVectorToMap(numericIndexedVectorPointwiseSubtract(vec1, vec2)) AS res1, + numericIndexedVectorToMap(numericIndexedVectorPointwiseSubtract(vec1, 2)) AS res2; +``` + +结果 + +```text +┌─res1───────────────────┬─res2────────────┐ +│ {1:10,2:10,3:10,4:-30} │ {1:8,2:18,3:28} │ +└────────────────────────┴─────────────────┘ +``` + +## numericIndexedVectorPointwiseMultiply + +在 NumericIndexedVector 和另一个 NumericIndexedVector 或数字常量之间执行逐点乘法。该函数返回一个新的 NumericIndexedVector。 + +语法 + +```sql +numericIndexedVectorPointwiseMultiply(numericIndexedVector, numericIndexedVector | numeric) +``` + +参数 + +- `numericIndexedVector` – 一个 NumericIndexedVector 对象。 +- `numeric` - 一个数字常量。 + +示例 + +```sql +WITH + numericIndexedVectorBuild(mapFromArrays([1, 2, 3], arrayMap(x -> toInt32(x), [10, 20, 30]))) AS vec1, + numericIndexedVectorBuild(mapFromArrays([2, 3, 4], arrayMap(x -> toInt32(x), [10, 20, 30]))) AS vec2 +SELECT + numericIndexedVectorToMap(numericIndexedVectorPointwiseMultiply(vec1, vec2)) AS res1, + numericIndexedVectorToMap(numericIndexedVectorPointwiseMultiply(vec1, 2)) AS res2; +``` + +结果 + +```text +┌─res1──────────┬─res2─────────────┐ +│ {2:200,3:600} │ {1:20,2:40,3:60} │ +└───────────────┴──────────────────┘ +``` + +## numericIndexedVectorPointwiseDivide + +在 NumericIndexedVector 和另一个 NumericIndexedVector 或数字常量之间执行逐点除法。该函数返回一个新的 NumericIndexedVector。当除数为零时,结果为零。 + +语法 + +```sql +numericIndexedVectorPointwiseDivide(numericIndexedVector, numericIndexedVector | numeric) +``` + +参数 + +- `numericIndexedVector` – 一个 NumericIndexedVector 对象。 +- `numeric` - 一个数字常量。 + +示例 + +```sql +WITH + numericIndexedVectorBuild(mapFromArrays([1, 2, 3], arrayMap(x -> toFloat64(x), [10, 20, 30]))) AS vec1, + numericIndexedVectorBuild(mapFromArrays([2, 3, 4], arrayMap(x -> toFloat64(x), [10, 20, 30]))) AS vec2 +SELECT + numericIndexedVectorToMap(numericIndexedVectorPointwiseDivide(vec1, vec2)) AS res1, + numericIndexedVectorToMap(numericIndexedVectorPointwiseDivide(vec1, 2)) AS res2; +``` + +结果 + +```text +┌─res1────────┬─res2────────────┐ +│ {2:2,3:1.5} │ {1:5,2:10,3:15} │ +└─────────────┴─────────────────┘ +``` + +## numericIndexedVectorPointwiseEqual + +在 NumericIndexedVector 和另一个 NumericIndexedVector 或数字常量之间执行逐点比较。结果是一个 NumericIndexedVector,其中包含值相等的索引,所有对应值设置为 1。 + +语法 + +```sql +numericIndexedVectorPointwiseEqual(numericIndexedVector, numericIndexedVector | numeric) +``` + +参数 + +- `numericIndexedVector` – 一个 NumericIndexedVector 对象。 +- `numeric` - 一个数字常量。 + +示例 + +```sql +WITH + numericIndexedVectorBuild(mapFromArrays([1, 2, 3], arrayMap(x -> toFloat64(x), [10, 20, 30]))) AS vec1, + numericIndexedVectorBuild(mapFromArrays([2, 3, 4], arrayMap(x -> toFloat64(x), [20, 20, 30]))) AS vec2 +SELECT + numericIndexedVectorToMap(numericIndexedVectorPointwiseEqual(vec1, vec2)) AS res1, + numericIndexedVectorToMap(numericIndexedVectorPointwiseEqual(vec1, 20)) AS res2; +``` + +结果 + +```text +┌─res1──┬─res2──┐ +│ {2:1} │ {2:1} │ +└───────┴───────┘ +``` + +## numericIndexedVectorPointwiseNotEqual + +在 NumericIndexedVector 和另一个 NumericIndexedVector 或数字常量之间执行逐点比较。结果是一个 NumericIndexedVector,其中包含值不相等的索引,所有对应值设置为 1。 + +语法 + +```sql +numericIndexedVectorPointwiseNotEqual(numericIndexedVector, numericIndexedVector | numeric) +``` + +参数 + +- `numericIndexedVector` – 一个 NumericIndexedVector 对象。 +- `numeric` - 一个数字常量。 + +示例 + +```sql +WITH + numericIndexedVectorBuild(mapFromArrays([1, 2, 3], arrayMap(x -> toFloat64(x), [10, 20, 30]))) AS vec1, + numericIndexedVectorBuild(mapFromArrays([2, 3, 4], arrayMap(x -> toFloat64(x), [20, 20, 30]))) AS vec2 +SELECT + numericIndexedVectorToMap(numericIndexedVectorPointwiseNotEqual(vec1, vec2)) AS res1, + numericIndexedVectorToMap(numericIndexedVectorPointwiseNotEqual(vec1, 20)) AS res2; +``` + +结果 + +```text +┌─res1──────────┬─res2──────┐ +│ {1:1,3:1,4:1} │ {1:1,3:1} │ +└───────────────┴───────────┘ +``` + +## numericIndexedVectorPointwiseLess + +在 NumericIndexedVector 和另一个 NumericIndexedVector 或数字常量之间执行逐点比较。结果是一个 NumericIndexedVector,其中包含第一个向量的值小于第二个向量的值的索引,所有对应值设置为 1。 + +语法 + +```sql +numericIndexedVectorPointwiseLess(numericIndexedVector, numericIndexedVector | numeric) +``` + +参数 + +- `numericIndexedVector` – 一个 NumericIndexedVector 对象。 +- `numeric` - 一个数字常量。 + +示例 + +```sql +WITH + numericIndexedVectorBuild(mapFromArrays([1, 2, 3], arrayMap(x -> toFloat64(x), [10, 20, 30]))) AS vec1, + numericIndexedVectorBuild(mapFromArrays([2, 3, 4], arrayMap(x -> toFloat64(x), [20, 40, 30]))) AS vec2 +SELECT + numericIndexedVectorToMap(numericIndexedVectorPointwiseLess(vec1, vec2)) AS res1, + numericIndexedVectorToMap(numericIndexedVectorPointwiseLess(vec1, 20)) AS res2; +``` + +结果 + +```text +┌─res1──────┬─res2──┐ +│ {3:1,4:1} │ {1:1} │ +└───────────┴───────┘ +``` + +## numericIndexedVectorPointwiseLessEqual + +在 NumericIndexedVector 和另一个 NumericIndexedVector 或数字常量之间执行逐点比较。结果是一个 NumericIndexedVector,其中包含第一个向量的值小于或等于第二个向量的值的索引,所有对应值设置为 1。 + +语法 + +```sql +numericIndexedVectorPointwiseLessEqual(numericIndexedVector, numericIndexedVector | numeric) +``` + +参数 + +- `numericIndexedVector` – 一个 NumericIndexedVector 对象。 +- `numeric` - 一个数字常量。 + +示例 + +```sql +WITH + numericIndexedVectorBuild(mapFromArrays([1, 2, 3], arrayMap(x -> toFloat64(x), [10, 20, 30]))) AS vec1, + numericIndexedVectorBuild(mapFromArrays([2, 3, 4], arrayMap(x -> toFloat64(x), [20, 40, 30]))) AS vec2 +SELECT + numericIndexedVectorToMap(numericIndexedVectorPointwiseLessEqual(vec1, vec2)) AS res1, + numericIndexedVectorToMap(numericIndexedVectorPointwiseLessEqual(vec1, 20)) AS res2; +``` + +结果 + +```text +┌─res1──────────┬─res2──────┐ +│ {2:1,3:1,4:1} │ {1:1,2:1} │ +└───────────────┴───────────┘ +``` + +## numericIndexedVectorPointwiseGreater + +在 NumericIndexedVector 和另一个 NumericIndexedVector 或数字常量之间执行逐点比较。结果是一个 NumericIndexedVector,其中包含第一个向量的值大于第二个向量的值的索引,所有对应值设置为 1。 + +语法 + +```sql +numericIndexedVectorPointwiseGreater(numericIndexedVector, numericIndexedVector | numeric) +``` + +参数 + +- `numericIndexedVector` – 一个 NumericIndexedVector 对象。 +- `numeric` - 一个数字常量。 + +示例 + +```sql +WITH + numericIndexedVectorBuild(mapFromArrays([1, 2, 3], arrayMap(x -> toFloat64(x), [10, 20, 50]))) AS vec1, + numericIndexedVectorBuild(mapFromArrays([2, 3, 4], arrayMap(x -> toFloat64(x), [20, 40, 30]))) AS vec2 +SELECT + numericIndexedVectorToMap(numericIndexedVectorPointwiseGreater(vec1, vec2)) AS res1, + numericIndexedVectorToMap(numericIndexedVectorPointwiseGreater(vec1, 20)) AS res2; +``` + +结果 + +```text +┌─res1──────┬─res2──┐ +│ {1:1,3:1} │ {3:1} │ +└───────────┴───────┘ +``` + +## numericIndexedVectorPointwiseGreaterEqual + +在 NumericIndexedVector 和另一个 NumericIndexedVector 或数字常量之间执行逐点比较。结果是一个 NumericIndexedVector,其中包含第一个向量的值大于或等于第二个向量的值的索引,所有对应值设置为 1。 + +语法 + +```sql +numericIndexedVectorPointwiseGreaterEqual(numericIndexedVector, numericIndexedVector | numeric) +``` + +参数 + +- `numericIndexedVector` – 一个 NumericIndexedVector 对象。 +- `numeric` - 一个数字常量。 + +示例 + +```sql +WITH + numericIndexedVectorBuild(mapFromArrays([1, 2, 3], arrayMap(x -> toFloat64(x), [10, 20, 50]))) AS vec1, + numericIndexedVectorBuild(mapFromArrays([2, 3, 4], arrayMap(x -> toFloat64(x), [20, 40, 30]))) AS vec2 +SELECT + numericIndexedVectorToMap(numericIndexedVectorPointwiseGreaterEqual(vec1, vec2)) AS res1, + numericIndexedVectorToMap(numericIndexedVectorPointwiseGreaterEqual(vec1, 20)) AS res2; +``` + +结果 + +```text +┌─res1──────────┬─res2──────┐ +│ {1:1,2:1,3:1} │ {2:1,3:1} │ +└───────────────┴───────────┘ +``` + + + + + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/numeric-indexed-vector-functions.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/numeric-indexed-vector-functions.md.hash new file mode 100644 index 00000000000..43ab0549662 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/numeric-indexed-vector-functions.md.hash @@ -0,0 +1 @@ +87faf8ad5b097a10 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/other-functions.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/other-functions.md index 89ae157d87b..75d4e9ca52a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/other-functions.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/other-functions.md @@ -1,9 +1,9 @@ --- -'description': '其他函数的文档' +'description': '其他函数的Documentation' 'sidebar_label': '其他' -'sidebar_position': 140 'slug': '/sql-reference/functions/other-functions' 'title': '其他函数' +'doc_type': 'reference' --- import ExperimentalBadge from '@theme/badges/ExperimentalBadge'; @@ -14,8 +14,7 @@ import DeprecatedBadge from '@theme/badges/DeprecatedBadge'; # 其他函数 ## hostName {#hostname} -返回执行此函数的主机名称。如果该函数在远程服务器上执行(分布式处理),则返回远程服务器名称。 -如果该函数在分布式表的上下文中执行,则生成一个正常的列,其中的值与每个分片相关。否则,它会生成一个常量值。 +返回执行此函数的主机名称。如果该函数在远程服务器(分布式处理)上执行,则返回远程服务器名称。 如果函数在分布式表的上下文中执行,它将生成一个包含与每个分片相关的值的正常列。否则,它产生一个常量值。 **语法** @@ -25,10 +24,11 @@ hostName() **返回值** -- 主机名。[字符串](../data-types/string.md)。 +- 主机名称。[String](../data-types/string.md)。 + ## getMacro {#getMacro} -从服务器配置的 [macros](../../operations/server-configuration-parameters/settings.md#macros) 部分返回一个命名值。 +返回服务器配置的 [macros](../../operations/server-configuration-parameters/settings.md#macros) 部分中的命名值。 **语法** @@ -38,15 +38,15 @@ getMacro(name); **参数** -- `name` — 要从 `` 部分检索的宏名称。[字符串](/sql-reference/data-types/string)。 +- `name` — 从 `` 部分检索的宏名称。[String](/sql-reference/data-types/string)。 **返回值** -- 指定宏的值。[字符串](../data-types/string.md)。 +- 指定宏的值。[String](../data-types/string.md)。 **示例** -服务器配置文件中 `` 部分的示例: +以下是服务器配置文件中 `` 部分的示例: ```xml @@ -68,7 +68,7 @@ SELECT getMacro('test'); └──────────────────┘ ``` -同样的值可以通过以下方式检索: +相同的值可以通过以下方式检索: ```sql SELECT * FROM system.macros @@ -80,9 +80,10 @@ WHERE macro = 'test'; │ test │ Value │ └───────┴──────────────┘ ``` + ## fqdn {#fqdn} -返回 ClickHouse 服务器的完全合格域名。 +返回 ClickHouse 服务器的完全限定域名。 **语法** @@ -90,11 +91,11 @@ WHERE macro = 'test'; fqdn(); ``` -别名:`fullHostName`, `FQDN`。 +别名:`fullHostName`,`FQDN`。 **返回值** -- 包含完全合格域名的字符串。[字符串](../data-types/string.md)。 +- 完全限定域名的字符串。[String](../data-types/string.md)。 **示例** @@ -109,6 +110,7 @@ SELECT FQDN(); │ clickhouse.ru-central1.internal │ └─────────────────────────────────┘ ``` + ## basename {#basename} 提取字符串最后一个斜杠或反斜杠后的尾部。此函数通常用于从路径中提取文件名。 @@ -119,13 +121,13 @@ basename(expr) **参数** -- `expr` — [字符串](../data-types/string.md) 类型的值。反斜杠必须被转义。 +- `expr` — 类型为 [String](../data-types/string.md) 的值。反斜杠必须进行转义。 **返回值** -一个字符串,包含: +包含以下内容的字符串: -- 输入字符串最后一个斜杠或反斜杠后的尾部。如果输入字符串以斜杠或反斜杠结尾(例如 `/` 或 `c:\`),则该函数返回一个空字符串。 +- 输入字符串最后一个斜杠或反斜杠后的尾部。如果输入字符串以斜杠或反斜杠结束(例如 `/` 或 `c:\`),则该函数返回空字符串。 - 如果没有斜杠或反斜杠,则返回原始字符串。 **示例** @@ -171,12 +173,12 @@ SELECT 'some-file-name' AS a, basename(a) │ some-file-name │ some-file-name │ └────────────────┴────────────────────────────┘ ``` + ## visibleWidth {#visiblewidth} -计算将值以文本格式(制表符分隔)输出时的近似宽度。 -此函数由系统用于实现 [Pretty formats](../../interfaces/formats.md)。 +在将值以文本格式(制表符分隔)输出到控制台时,计算近似宽度。 此函数由系统用于实现 [Pretty formats](../../interfaces/formats.md)。 -`NULL` 表示为与 `Pretty` 格式中的 `NULL` 相对应的字符串。 +`NULL` 被表示为对应于 `Pretty` 格式的字符串 `NULL`。 **语法** @@ -199,11 +201,12 @@ SELECT visibleWidth(NULL) │ 4 │ └────────────────────┘ ``` + ## toTypeName {#totypename} -返回传入参数的类型名称。 +返回传递参数的类型名称。 -如果传入 `NULL`,该函数返回类型 `Nullable(Nothing)`,这对应于 ClickHouse 的内部 `NULL` 表示。 +如果传递 `NULL`,该函数返回类型 `Nullable(Nothing)`,对应于 ClickHouse 的内部 `NULL` 表示。 **语法** @@ -217,7 +220,7 @@ toTypeName(value) **返回值** -- 输入值的数据类型名称。[字符串](../data-types/string.md)。 +- 输入值的数据类型名称。[String](../data-types/string.md)。 **示例** @@ -234,10 +237,10 @@ SELECT toTypeName(123); │ UInt8 │ └─────────────────┘ ``` + ## blockSize {#blockSize} -在 ClickHouse 中,查询以 [blocks](/development/architecture#block)(块)方式处理。 -此函数返回对该函数调用的块的大小(行数)。 +在 ClickHouse 中,查询以 [blocks](/development/architecture#block)(块)处理。此函数返回调用该函数的块的大小(行数)。 **语法** @@ -271,9 +274,10 @@ FROM test; 5. │ 5 │ └─────────────┘ ``` + ## byteSize {#bytesize} -返回其参数在内存中未压缩的字节大小的估算。 +返回其参数在内存中未压缩的字节大小的估计值。 **语法** @@ -287,11 +291,11 @@ byteSize(argument [, ...]) **返回值** -- 参数在内存中字节大小的估算。[UInt64](../data-types/int-uint.md)。 +- 参数在内存中字节大小的估计值。[UInt64](../data-types/int-uint.md)。 **示例** -对于 [字符串](../data-types/string.md) 参数,该函数返回字符串长度 + 9(终止零 + 长度)。 +对于 [String](../data-types/string.md) 参数,该函数返回字符串长度 + 8(长度)。 查询: @@ -350,7 +354,7 @@ byteSize(Float32): 4 byteSize(Float64): 8 ``` -如果函数有多个参数,那么函数将它们的字节大小累加。 +如果该函数有多个参数,则函数将累加其字节大小。 查询: @@ -365,12 +369,10 @@ SELECT byteSize(NULL, 1, 0.3, ''); │ 19 │ └────────────────────────────┘ ``` + ## materialize {#materialize} -将常量转换为包含单个值的完整列。 -完整列和常量在内存中的表示形式不同。 -函数通常对正常和常量参数执行不同的代码,但结果通常应该是相同的。 -此函数可用于调试此行为。 +将常量转换为包含单个值的完整列。完整列和常量在内存中的表示方式不同。 函数通常会为正常和常量参数执行不同的代码,尽管结果通常应该相同。此函数可用于调试此行为。 **语法** @@ -380,7 +382,7 @@ materialize(x) **参数** -- `x` — 常量。[常量](overview.md/#constants)。 +- `x` — 常量。[Constant](overview.md/#constants)。 **返回值** @@ -388,8 +390,7 @@ materialize(x) **示例** -在下面的示例中,`countMatches` 函数期望一个常量的第二个参数。 -此行为可以通过使用 `materialize` 函数将常量转换为一个完整列来调试,从而验证该函数对非常量参数抛出错误。 +在下面的示例中,`countMatches` 函数期望第二个参数为常量。 可以使用 `materialize` 函数将常量转换为完整列来调试此行为,验证该函数对非恒定参数抛出错误。 查询: @@ -404,10 +405,10 @@ SELECT countMatches('foobarfoo', materialize('foo')); 2 Code: 44. DB::Exception: Received from localhost:9000. DB::Exception: Illegal type of argument #2 'pattern' of function countMatches, expected constant String, got String ``` + ## ignore {#ignore} -接受任意参数并无条件返回 `0`。 -参数仍会在内部评估,这使其在基准测试等情况下非常有用。 +接受任意参数并无条件返回 `0`。 参数仍在内部进行评估,适用于基准测试等目的。 **语法** @@ -417,7 +418,7 @@ ignore([arg1[, arg2[, ...]]) **参数** -- 接受任意数量的任意类型的参数,包括 `NULL`。 +- 接受任意类型的任意数量的参数,包括 `NULL`。 **返回值** @@ -438,9 +439,10 @@ SELECT ignore(0, 'ClickHouse', NULL); │ 0 │ └───────────────────────────────┘ ``` + ## sleep {#sleep} -用于在查询的执行中引入延迟或暂停。主要用于测试和调试目的。 +用于在查询执行中引入延迟或暂停。主要用于测试和调试目的。 **语法** @@ -450,7 +452,7 @@ sleep(seconds) **参数** -- `seconds`: [UInt*](../data-types/int-uint.md) 或 [Float](../data-types/float.md)。暂停查询执行的秒数,最多为 3 秒。可以是浮点值以指定分秒。 +- `seconds`: [UInt*](../data-types/int-uint.md) 或 [Float](../data-types/float.md) 暂停查询执行的秒数,最长为 3 秒。可以是浮点值,以指定小数秒。 **返回值** @@ -458,11 +460,7 @@ sleep(seconds) **示例** -```sql -SELECT sleep(2); -``` - -此函数不返回任何值。不过,如果使用 `clickhouse client` 运行该函数,您将看到类似的内容: +此函数不返回任何值。然而,如果您使用 `clickhouse client` 运行该函数,您将看到类似于: ```response SELECT sleep(2) @@ -476,20 +474,21 @@ Query id: 8aa9943e-a686-45e1-8317-6e8e3a5596ac 1 row in set. Elapsed: 2.012 sec. ``` -此查询将在完成之前暂停 2 秒。在此期间,不会返回任何结果,查询看起来会挂起或无响应。 +该查询将在完成前暂停 2 秒。在此期间,将不会返回任何结果,查询将看起来像是挂起或无响应。 **实现细节** -`sleep()` 函数通常不在生产环境中使用,因为它可能对查询性能和系统响应能力产生负面影响。不过,在以下情况下可以有用: +`sleep()` 函数通常不在生产环境中使用,因为它可能会对查询性能和系统响应性产生负面影响。然而,在以下情况下可能会有用: -1. **测试**:在测试或基准测试 ClickHouse 时,您可能希望模拟延迟或引入暂停,以观察系统在特定条件下的行为。 -2. **调试**:如果您需要检查系统的状态或在特定时间点查询的执行情况,可以使用 `sleep()` 引入暂停,从而允许您检查或收集相关信息。 -3. **模拟**:在某些情况下,您可能希望模拟现实世界场景,其中发生延迟或暂停,例如网络延迟或外部系统依赖性。 +1. **测试**:在测试或基准测试 ClickHouse 时,您可能希望模拟延迟或引入暂停,以观察系统在某些条件下的行为。 +2. **调试**:如果您需要在特定时间点检查系统的状态或查询的执行状态,可以使用 `sleep()` 引入暂停,从而允许您检查或收集相关信息。 +3. **模拟**:在某些情况下,您可能希望模拟发生延迟或暂停的现实场景,例如网络延迟或外部系统依赖。 + +重要的是,明智地使用 `sleep()` 函数,仅在必要时使用,因为它可能会对 ClickHouse 系统的整体性能和响应性产生影响。 -重要的是要明智地使用 `sleep()` 函数,仅在必要时使用,因为这可能会对 ClickHouse 系统的整体性能和响应能力产生潜在影响。 ## sleepEachRow {#sleepeachrow} -暂停查询的执行,每行结果集暂停指定的秒数。 +在结果集中对每一行暂停执行查询指定的秒数。 **语法** @@ -499,11 +498,11 @@ sleepEachRow(seconds) **参数** -- `seconds`: [UInt*](../data-types/int-uint.md) 或 [Float*](../data-types/float.md)。暂停查询执行的秒数,最多为 3 秒,可以是浮点值以指定分秒。 +- `seconds`: [UInt*](../data-types/int-uint.md) 或 [Float*](../data-types/float.md) 为结果集中的每一行暂停查询执行的秒数,最长为 3 秒。可以是浮点值,以指定小数秒。 **返回值** -此函数返回与接收到的输入值相同的值,不会对其进行修改。 +此函数返回与接收的输入值相同的值,而不对其进行修改。 **示例** @@ -521,19 +520,19 @@ SELECT number, sleepEachRow(0.5) FROM system.numbers LIMIT 5; └────────┴───────────────────┘ ``` -但输出会延迟,每行之间有 0.5 秒的暂停。 +但是输出将被延迟,每一行之间有 0.5 秒的暂停。 + +`sleepEachRow()` 函数主要用于测试和调试目的,类似于 `sleep()` 函数。它允许您在处理每一行时模拟延迟或引入暂停,这在以下场景中可能会很有用: -`sleepEachRow()` 函数主要用于测试和调试目的,类似于 `sleep()` 函数。它允许您在处理每一行中模拟延迟或引入暂停,这在以下情况中可能会很有用: +1. **测试**:在测试或基准测试 ClickHouse 在特定条件下的性能时,您可以使用 `sleepEachRow()` 对处理的每一行模拟延迟或引入暂停。 +2. **调试**:如果您需要检查系统的状态或每一行处理的查询执行状态,可以使用 `sleepEachRow()` 引入暂停,以便您可以检查或收集相关信息。 +3. **模拟**:在某些情况下,您可能希望模拟在处理每一行时发生延迟或暂停的现实场景,例如处理外部系统或网络延迟时。 -1. **测试**:在测试或基准测试 ClickHouse 在特定条件下的性能时,您可以使用 `sleepEachRow()` 模拟延迟或为处理的每行引入暂停。 -2. **调试**:如果您需要检查系统状态或每行处理的查询执行情况,可以使用 `sleepEachRow()` 引入暂停,从而允许您检查或收集相关信息。 -3. **模拟**:在某些情况下,您可能希望模拟现实场景,在处理每行时发生延迟或暂停,例如在处理外部系统或网络延迟时。 +与 [`sleep()` 函数](#sleep) 一样,重要的是明智地使用 `sleepEachRow()`,并仅在必要时使用,因为它可能会显著影响 ClickHouse 系统的整体性能和响应性,尤其是在处理大型结果集时。 -与 [`sleep()` 函数](#sleep) 一样,重要的是要明智地使用 `sleepEachRow()`,并仅在必要时使用,因为它可能会显著影响 ClickHouse 系统的整体性能和响应能力,尤其是在处理大结果集时。 ## currentDatabase {#currentdatabase} -返回当前数据库的名称。 -在需要指定数据库的 `CREATE TABLE` 查询的表引擎参数中非常有用。 +返回当前数据库的名称。 在需要指定数据库的 `CREATE TABLE` 查询的表引擎参数中非常有用。 **语法** @@ -543,7 +542,7 @@ currentDatabase() **返回值** -- 返回当前数据库名称。[字符串](../data-types/string.md)。 +- 返回当前数据库名称。[String](../data-types/string.md)。 **示例** @@ -560,9 +559,10 @@ SELECT currentDatabase() │ default │ └───────────────────┘ ``` + ## currentUser {#currentUser} -返回当前用户的名称。如果是分布式查询,则返回发起查询的用户名称。 +返回当前用户的名称。在分布式查询的情况下,返回发起查询的用户的名称。 **语法** @@ -570,12 +570,12 @@ SELECT currentDatabase() currentUser() ``` -别名:`user()`, `USER()`, `current_user()`。别名不区分大小写。 +别名:`user()`,`USER()`,`current_user()`。别名不区分大小写。 **返回值** -- 当前用户的名称。[字符串](../data-types/string.md)。 -- 在分布式查询中,发起查询的用户的登录名。[字符串](../data-types/string.md)。 +- 当前用户的名称。[String](../data-types/string.md)。 +- 在分布式查询中,发起查询的用户的登录名。[String](../data-types/string.md)。 **示例** @@ -590,9 +590,10 @@ SELECT currentUser(); │ default │ └───────────────┘ ``` + ## currentSchemas {#currentschemas} -返回一个包含当前数据库架构名称的单元素数组。 +返回一个单元素数组,包含当前数据库模式的名称。 **语法** @@ -604,15 +605,15 @@ currentSchemas(bool) **参数** -- `bool`:布尔值。[布尔](../data-types/boolean.md)。 +- `bool`: 布尔值。[Bool](../data-types/boolean.md)。 :::note -布尔参数会被忽略。它的存在仅仅是为了与 PostgreSQL 中该函数的实现保持兼容性。 +布尔参数被忽略。它仅存在于兼容性目的,以与 PostgreSQL 中的 [实现](https://www.postgresql.org/docs/7.3/functions-misc.html) 一致。 ::: **返回值** -- 返回一个包含当前数据库名称的单元素数组。 +- 返回一个单元素数组,包含当前数据库的名称。 **示例** @@ -625,11 +626,130 @@ SELECT currentSchemas(true); ```response ['default'] ``` + +## colorSRGBToOKLCH {#colorsrgbtoOKLCH} + +将 **sRGB** 颜色空间中编码的颜色转换为感知均匀的 **OKLCH** 颜色空间。 + +如果任何输入通道超出 `[0...255]` 或 gamma 值为非正,则行为为实现定义。 + +:::note +**OKLCH** 是 OKLab 颜色空间的圆柱形版本。 它的三个坐标是 **L**(亮度范围为 `[0...1]`)、**C**(色度 `>= 0`)和 **H**(色相在度数 `[0...360]`)**。 +OKLab/OKLCH 旨在在保持计算简便的同时感知均匀。 +::: + +**语法** + +```sql +colorSRGBToOKLCH(tuple [, gamma]) +``` + +**参数** + +- `tuple` - 三个数值 R、G、B,范围为 `[0...255]`。[Tuple](../data-types/tuple.md)。 +- `gamma` - 可选数值。用于线性化 sRGB 的指数,通过对每个通道 `x` 应用 `(x / 255)^gamma`。默认为 `2.2`。 + +**返回值** + +- 类型为 `Tuple(Float64, Float64, Float64)` 的 `tuple`(L, C, H)。 + +**实现细节** + +该转换由三个阶段组成: + +1) sRGB 转 Linear sRGB +2) Linear sRGB 转 OKLab +3) OKLab 转 OKLCH。 + +Gamma 在第一阶段使用,即计算线性 sRGB。 为此,我们对 sRGB 值进行归一化,并将其取为 gamma 的幂。 请注意,由于浮点舍入,这缺少了一些精度。 做出这一设计选择是为了能够快速计算不同 gamma 的值,并且由于差异不会显著改变颜色感知。 + +两个阶段涉及矩阵乘法和三角函数转换。 有关数学的更多详细信息,请参见关于 OKLab 颜色空间的文章:https://bottosson.github.io/posts/OKLab/ + +为了在 OKLCH 空间中拥有某些颜色的参考,以及它们与 sRGB 颜色的对应关系,请参见 https://OKLCH.com/ + +**示例** + +```sql +SELECT colorSRGBToOKLCH((128, 64, 32), 2.2) AS lch; +``` + +结果: + +```response +┌─lch─────────────────────────────────────────────────────────┐ +│ (0.4436238384931984,0.10442699545678624,45.907345481930236) │ +└─────────────────────────────────────────────────────────────┘ +``` + +## colorOKLCHToSRGB {#colorOKLCHtosrgb} + +将 **OKLCH** 视觉颜色空间中的颜色转换为熟悉的 **sRGB** 颜色空间。 + +如果 **L** 超出 `[0...1]`,**C** 为负,或 **H** 超出 `[0...360]`,则结果由实现定义。 + +:::note +**OKLCH** 是 OKLab 颜色空间的圆柱形版本。 它的三个坐标是 **L**(亮度范围为 `[0...1]`)、**C**(色度 `>= 0`)和 **H**(色相在度数 `[0...360]`)**。 +OKLab/OKLCH 旨在在保持计算简便的同时感知均匀。 +::: + +**语法** + +```sql +colorOKLCHToSRGB(tuple [, gamma]) +``` + +**参数** + +- `tuple` - 三个数值 **L**、**C**、**H**,以元组的形式呈现,其中 **L** 在范围 `[0...1]` 内, **C** `>= 0`,且 **H** 在范围 `[0...360]` 内。[Tuple](../data-types/tuple.md)。 +- `gamma` - 可选数值。用于将线性 sRGB 变回 sRGB 的指数,通过对每个通道 `x` 应用 `(x ^ (1 / gamma)) * 255`。默认为 `2.2`。 + +**返回值** + +- 类型为 `Tuple(Float64, Float64, Float64)` 的 `tuple`(R, G, B)。 + +:::note +此函数返回浮点数,而不是整数值,以避免强制舍入。用户可以自行进行舍入。 +::: + +**实现细节** + +该转换是 `colorSRGBToOKLCH` 的反向: + +1) OKLCH 转 OKLab。 +2) OKLab 转 Linear sRGB。 +3) Linear sRGB 转 sRGB。 + +第二个参数 gamma 在最后阶段使用。 注意,在计算线性 sRGB 之前,所有三个通道都会在范围 `[0...1]` 剪裁,然后在求 `1 / gamma` 的幂。 若 `gamma` 为 `0`,则 `1 / gamma` 被改为 `1'000'000`。因此,无论输入如何,我们通常都会返回范围在 `[0...255]` 的浮点数。 + +与 `colorSRGBToOKLCH` 一样,其他两个阶段分别涉及三角函数转换和矩阵乘法。 有关数学的更多详细信息,请参见关于 OKLab 颜色空间的文章:https://bottosson.github.io/posts/oklab/ + +为了在 OKLCH 空间中拥有某些颜色的参考,以及它们与 sRGB 颜色的对应关系,请参见:https://oklch.com/ + +**示例** + +```sql +SELECT colorOKLCHToSRGB((0.4466, 0.0991, 45.44), 2.2) AS rgb +WITH colorOKLCHToSRGB((0.7, 0.1, 54)) as t SELECT tuple(toUInt8(t.1), toUInt8(t.2), toUInt8(t.3)) AS RGB + +``` + +结果: + +```response +┌─rgb──────────────────────────────────────────────────────┐ +│ (127.03349738778945,66.06672044472008,37.11802592155851) │ +└──────────────────────────────────────────────────────────┘ + +┌─RGB──────────┐ +│ (205,139,97) │ +└──────────────┘ +``` + ## isConstant {#isconstant} -返回参数是否是常量表达式。 +返回参数是否为常量表达式。 -常量表达式是查询分析期间结果已知的表达式,即在执行之前。例如,针对 [literals](../../sql-reference/syntax.md#literals) 的表达式是常量表达式。 +常量表达式是在查询分析期间即知道结果的表达式,即在执行之前。例如,涉及 [literals](../../sql-reference/syntax.md#literals) 的表达式是常量表达式。 此函数主要用于开发、调试和演示。 @@ -645,8 +765,8 @@ isConstant(x) **返回值** -- 如果 `x` 是常量则返回 `1`。[UInt8](../data-types/int-uint.md)。 -- 如果 `x` 不是常量则返回 `0`。[UInt8](../data-types/int-uint.md)。 +- 如果 `x` 是常量,则返回 `1`。[UInt8](../data-types/int-uint.md)。 +- 如果 `x` 不是常量,则返回 `0`。[UInt8](../data-types/int-uint.md)。 **示例** @@ -691,9 +811,10 @@ SELECT isConstant(number) FROM numbers(1) │ 0 │ └────────────────────┘ ``` + ## hasColumnInTable {#hascolumnintable} -给定数据库名称、表名称和常量字符串列名称,如果给定列存在,则返回 1,否则返回 0。 +给定数据库名称、表名称和列名称作为常量字符串,如果给定列存在,则返回 1,否则返回 0。 **语法** @@ -703,21 +824,21 @@ hasColumnInTable(\['hostname'\[, 'username'\[, 'password'\]\],\] 'database', 'ta **参数** -- `database` : 数据库名称。[字符串字面量](/sql-reference/syntax#string) -- `table` : 表名称。[字符串字面量](/sql-reference/syntax#string) -- `column` : 列名称。[字符串字面量](/sql-reference/syntax#string) -- `hostname` : 用于进行检查的远程服务器名称。[字符串字面量](/sql-reference/syntax#string) -- `username` : 远程服务器的用户名。[字符串字面量](/sql-reference/syntax#string) -- `password` : 远程服务器的密码。[字符串字面量](/sql-reference/syntax#string) +- `database` : 数据库的名称。[String literal](/sql-reference/syntax#string) +- `table` : 表的名称。[String literal](/sql-reference/syntax#string) +- `column` : 列的名称。[String literal](/sql-reference/syntax#string) +- `hostname` : 要执行检查的远程服务器名称。[String literal](/sql-reference/syntax#string) +- `username` : 远程服务器的用户名。[String literal](/sql-reference/syntax#string) +- `password` : 远程服务器的密码。[String literal](/sql-reference/syntax#string) **返回值** -- 如果给定列存在,返回 `1`。 +- 如果给定列存在,则返回 `1`。 - 否则返回 `0`。 **实现细节** -对于嵌套数据结构中的元素,函数检查列的存在性。对于嵌套数据结构本身,函数返回 0。 +对于嵌套数据结构中的元素,函数检查列的存在性。对于嵌套数据结构本身,该函数返回 0。 **示例** @@ -738,28 +859,30 @@ SELECT hasColumnInTable('system','metrics','non-existing_column') ```response 0 ``` + ## hasThreadFuzzer {#hasthreadfuzzer} -返回线程模糊器是否有效。可以在测试中使用,以防止运行时间过长。 +返回线程模糊器是否有效。它可以在测试中使用,以防止运行时间过长。 **语法** ```sql hasThreadFuzzer(); ``` + ## bar {#bar} -构建柱状图。 +构建条形图。 -`bar(x, min, max, width)` 绘制一个宽度与 `(x - min)` 成比例,并在 `x = max` 时等于 `width` 字符的带状图。 +`bar(x, min, max, width)` 绘制宽度与 `(x - min)` 成正比且在 `x = max` 时等于 `width` 个字符的带。 **参数** - `x` — 要显示的大小。 - `min, max` — 整数常量。值必须适合 `Int64`。 -- `width` — 常量,正整数,可以是小数。 +- `width` — 常量,正整数,可以是分数。 -带状图的绘制精确到符号的八分之一。 +该带的绘制精度为符号的八分之一。 示例: @@ -801,31 +924,29 @@ ORDER BY h ASC │ 23 │ 400397 │ █████████████▎ │ └────┴────────┴────────────────────┘ ``` + ## transform {#transform} -根据某些元素到其他元素的显式映射转换值。 -此函数有两种变体: +根据某些元素到其他元素的明确映射转换值。 该函数有两种变体: ### transform(x, array_from, array_to, default) {#transformx-array_from-array_to-default} -`x` – 要转换的值。 +`x` – 要转换的内容。 -`array_from` – 要转换的常量值数组。 +`array_from` – 用于转换的常量值数组。 -`array_to` – 要将 `from` 中的值转换到的常量值数组。 +`array_to` – 用于将 `from` 中的值转换到的常量值数组。 -`default` – 如果 `x` 不等于 `from` 中的任何值,则使用该值。 +`default` – 如果 `x` 不等于 `from` 中的任何值,则使用的值。 `array_from` 和 `array_to` 必须具有相同数量的元素。 签名: -对于 `x` 等于 `array_from` 中的一个元素,函数返回 `array_to` 中对应的元素,即在相同数组索引处的元素。否则,它返回 `default`。如果 `array_from` 中存在多个匹配元素,则返回第一个的对应元素。 +对于 `x` 等于 `array_from` 中一个元素的情况,函数返回 `array_to` 中相应的元素,即在同一数组索引处的元素。否则,它返回 `default`。如果在 `array_from` 中存在多个匹配元素,则返回对应于其中第一个的元素。 `transform(T, Array(T), Array(U), U) -> U` -`T` 和 `U` 可以是数字、字符串或日期或日期时间类型。 -相同的字母(T 或 U)表示类型必须是互相兼容的,不一定相等。 -例如,第一个参数可以是类型为 `Int64`,而第二个参数可以是类型为 `Array(UInt16)`。 +`T` 和 `U` 可以是数字、字符串或日期或日期时间类型。相同的字母(T或U)意味着类型必须是相互兼容的,而不一定相等。 例如,第一个参数可以为 `Int64` 类型,而第二个参数可以为 `Array(UInt16)` 类型。 示例: @@ -846,9 +967,10 @@ ORDER BY c DESC │ Other │ 104472 │ └───────────┴────────┘ ``` + ### transform(x, array_from, array_to) {#transformx-array_from-array_to} -与另一个变体相似,但没有 'default' 参数。如果找不到匹配,返回 `x`。 +与其他变体类似,但没有 `default` 参数。如果找不到匹配,返回 `x`。 示例: @@ -875,11 +997,12 @@ LIMIT 10 │ example.com │ 57316 │ └────────────────┴─────────┘ ``` + ## formatReadableDecimalSize {#formatreadabledecimalsize} -给定一个大小(字节数),此函数返回一个可读的、四舍五入的大小,并带有后缀(KB、MB 等)的字符串。 +给定一个大小(字节数),此函数返回可读的四舍五入大小,带有后缀(KB、MB 等)作为字符串。 -此函数的反操作是 [parseReadableSize](#parsereadablesize)、[parseReadableSizeOrZero](#parsereadablesizeorzero) 和 [parseReadableSizeOrNull](#parsereadablesizeornull)。 +此函数的反操作为 [parseReadableSize](#parsereadablesize)、[parseReadableSizeOrZero](#parsereadablesizeorzero) 和 [parseReadableSizeOrNull](#parsereadablesizeornull)。 **语法** @@ -907,11 +1030,12 @@ SELECT │ 192851925 │ 192.85 MB │ └────────────────┴────────────┘ ``` + ## formatReadableSize {#formatreadablesize} -给定一个大小(字节数),此函数返回一个可读的、四舍五入的大小,并带有后缀(KiB、MiB 等)的字符串。 +给定一个大小(字节数),此函数返回可读的四舍五入大小,带有后缀(KiB、MiB 等)作为字符串。 -此函数的反操作是 [parseReadableSize](#parsereadablesize)、[parseReadableSizeOrZero](#parsereadablesizeorzero) 和 [parseReadableSizeOrNull](#parsereadablesizeornull)。 +此函数的反操作为 [parseReadableSize](#parsereadablesize)、[parseReadableSizeOrZero](#parsereadablesizeorzero) 和 [parseReadableSizeOrNull](#parsereadablesizeornull)。 **语法** @@ -922,7 +1046,7 @@ formatReadableSize(x) 别名:`FORMAT_BYTES`。 :::note -此函数接受任何数字类型作为输入,但在内部会将其转换为 Float64。对于大值,结果可能不理想。 +此函数接受任何数值类型作为输入,但在内部将其强制转换为 Float64。大型值的结果可能不尽如人意。 ::: **示例** @@ -945,9 +1069,10 @@ SELECT │ 192851925 │ 183.92 MiB │ └────────────────┴────────────┘ ``` + ## formatReadableQuantity {#formatreadablequantity} -给定一个数字,此函数返回一个带后缀(千、百万、十亿等)四舍五入的数字字符串。 +给定一个数字,该函数返回带有后缀(千、百万、十亿等)的四舍五入数字作为字符串。 **语法** @@ -956,7 +1081,7 @@ formatReadableQuantity(x) ``` :::note -此函数接受任何数字类型作为输入,但在内部会将其转换为 Float64。对于大值,结果可能不理想。 +此函数接受任何数值类型作为输入,但在内部将其强制转换为 Float64。大型值的结果可能不尽如人意。 ::: **示例** @@ -979,9 +1104,10 @@ SELECT │ 98765432101234 │ 98.77 trillion │ └────────────────┴───────────────────┘ ``` + ## formatReadableTimeDelta {#formatreadabletimedelta} -给定一个时间间隔(增量)以秒为单位,此函数返回一个时间增量字符串,包含年/月/天/小时/分钟/秒/毫秒/微秒/纳秒。 +给定一个以秒为单位的时间间隔(增量),此函数返回以年/月/天/小时/分钟/秒/毫秒/微秒/纳秒表示的时间增量作为字符串。 **语法** @@ -990,18 +1116,18 @@ formatReadableTimeDelta(column[, maximum_unit, minimum_unit]) ``` :::note -此函数接受任何数字类型作为输入,但在内部会将其转换为 Float64。对于大值,结果可能不理想。 +此函数接受任何数值类型作为输入,但在内部将其强制转换为 Float64。大型值的结果可能不尽如人意。 ::: **参数** - `column` — 带有数值时间增量的列。 -- `maximum_unit` — 可选。最大单位显示。 - - 可接受的值:`nanoseconds`, `microseconds`, `milliseconds`, `seconds`, `minutes`, `hours`, `days`, `months`, `years`。 +- `maximum_unit` — 可选。显示的最大单位。 + - 可接受值:`nanoseconds`、`microseconds`、`milliseconds`、`seconds`、`minutes`、`hours`、`days`、`months`、`years`。 - 默认值:`years`。 -- `minimum_unit` — 可选。最小单位显示。所有更小的单位都会被截断。 - - 可接受的值:`nanoseconds`, `microseconds`, `milliseconds`, `seconds`, `minutes`, `hours`, `days`, `months`, `years`。 - - 如果显式指定的值大于 `maximum_unit`,则将抛出异常。 +- `minimum_unit` — 可选。显示的最小单位。所有更小的单位将被截断。 + - 可接受值:`nanoseconds`、`microseconds`、`milliseconds`、`seconds`、`minutes`、`hours`、`days`、`months`、`years`。 + - 如果显式指定的值大于 `maximum_unit`,将抛出异常。 - 默认值:如果 `maximum_unit` 为 `seconds` 或更大,则为 `seconds`;否则为 `nanoseconds`。 **示例** @@ -1047,12 +1173,13 @@ SELECT │ 432546534.00000006 │ 7209108 minutes, 54 seconds and 60 nanoseconds │ └────────────────────┴────────────────────────────────────────────────┘ ``` + ## parseReadableSize {#parsereadablesize} -给定一个包含字节大小的字符串和 `B`、`KiB`、`KB`、`MiB`、`MB` 等单位(即 [ISO/IEC 80000-13](https://en.wikipedia.org/wiki/ISO/IEC_80000) 或十进制字节单位),该函数返回对应的字节数。 -如果函数无法解析输入值,则抛出异常。 +给定一个包含字节大小的字符串和 `B`、`KiB`、`KB`、`MiB`、`MB` 等作为单位(即 [ISO/IEC 80000-13](https://en.wikipedia.org/wiki/ISO/IEC_80000) 或十进制字节单位),此函数返回相应的字节数。 +如果该函数无法解析输入值,将抛出异常。 -此函数的反操作是 [formatReadableSize](#formatreadablesize) 和 [formatReadableDecimalSize](#formatreadabledecimalsize)。 +此函数的反操作为 [formatReadableSize](#formatreadablesize) 和 [formatReadableDecimalSize](#formatreadabledecimalsize)。 **语法** @@ -1062,7 +1189,7 @@ parseReadableSize(x) **参数** -- `x` : 带有 ISO/IEC 80000-13 或十进制字节单位的可读大小 ([字符串](../../sql-reference/data-types/string.md))。 +- `x` : 带有 ISO/IEC 80000-13 或十进制字节单位的可读大小 ([String](../../sql-reference/data-types/string.md))。 **返回值** @@ -1084,12 +1211,13 @@ SELECT │ 5.314 KiB │ 5442 │ └────────────────┴─────────┘ ``` + ## parseReadableSizeOrNull {#parsereadablesizeornull} -给定一个包含字节大小的字符串和 `B`、`KiB`、`KB`、`MiB`、`MB` 等单位(即 [ISO/IEC 80000-13](https://en.wikipedia.org/wiki/ISO/IEC_80000) 或十进制字节单位),该函数返回对应的字节数。 -如果函数无法解析输入值,则返回 `NULL`。 +给定一个包含字节大小的字符串和 `B`、`KiB`、`KB`、`MiB`、`MB` 等作为单位(即 [ISO/IEC 80000-13](https://en.wikipedia.org/wiki/ISO/IEC_80000) 或十进制字节单位),此函数返回相应的字节数。 +如果该函数无法解析输入值,则返回 `NULL`。 -此函数的反操作是 [formatReadableSize](#formatreadablesize) 和 [formatReadableDecimalSize](#formatreadabledecimalsize)。 +此函数的反操作为 [formatReadableSize](#formatreadablesize) 和 [formatReadableDecimalSize](#formatreadabledecimalsize)。 **语法** @@ -1099,11 +1227,11 @@ parseReadableSizeOrNull(x) **参数** -- `x` : 带有 ISO/IEC 80000-13 或十进制字节单位的可读大小 ([字符串](../../sql-reference/data-types/string.md))。 +- `x` : 带有 ISO/IEC 80000-13 或十进制字节单位的可读大小 ([String](../../sql-reference/data-types/string.md))。 **返回值** -- 字节数,四舍五入到最接近的整数,或者如果无法解析输入,则为 NULL(Nullable([UInt64](../../sql-reference/data-types/int-uint.md)))。 +- 字节数,四舍五入到最接近的整数,或者如果无法解析输入,则为 NULL (Nullable([UInt64](../../sql-reference/data-types/int-uint.md))。 **示例** @@ -1122,11 +1250,12 @@ SELECT │ invalid │ ᴺᵁᴸᴸ │ └────────────────┴─────────┘ ``` + ## parseReadableSizeOrZero {#parsereadablesizeorzero} -给定一个包含字节大小的字符串和 `B`、`KiB`、`KB`、`MiB`、`MB` 等单位(即 [ISO/IEC 80000-13](https://en.wikipedia.org/wiki/ISO/IEC_80000) 或十进制字节单位),该函数返回对应的字节数。 如果函数无法解析输入值,则返回 `0`。 +给定一个包含字节大小的字符串和 `B`、`KiB`、`KB`、`MiB`、`MB` 等作为单位(即 [ISO/IEC 80000-13](https://en.wikipedia.org/wiki/ISO/IEC_80000) 或十进制字节单位),此函数返回相应的字节数。如果该函数无法解析输入值,则返回 `0`。 -此函数的反操作是 [formatReadableSize](#formatreadablesize) 和 [formatReadableDecimalSize](#formatreadabledecimalsize)。 +此函数的反操作为 [formatReadableSize](#formatreadablesize) 和 [formatReadableDecimalSize](#formatreadabledecimalsize)。 **语法** @@ -1136,11 +1265,11 @@ parseReadableSizeOrZero(x) **参数** -- `x` : 带有 ISO/IEC 80000-13 或十进制字节单位的可读大小 ([字符串](../../sql-reference/data-types/string.md))。 +- `x` : 带有 ISO/IEC 80000-13 或十进制字节单位的可读大小 ([String](../../sql-reference/data-types/string.md))。 **返回值** -- 字节数,四舍五入到最接近的整数,或者如果无法解析输入,则返回 0 ([UInt64](../../sql-reference/data-types/int-uint.md))。 +- 字节数,四舍五入到最接近的整数,或者如果无法解析输入,则为 0 ([UInt64](../../sql-reference/data-types/int-uint.md))。 **示例** @@ -1159,9 +1288,10 @@ SELECT │ invalid │ 0 │ └────────────────┴─────────┘ ``` + ## parseTimeDelta {#parsetimedelta} -解析一系列数字后跟类似时间单位的内容。 +解析一系列数字,后跟类似于时间单位的内容。 **语法** @@ -1171,7 +1301,7 @@ parseTimeDelta(timestr) **参数** -- `timestr` — 一系列数字后跟类似时间单位的内容。 +- `timestr` — 一系列数字,后跟类似于时间单位的内容。 **返回值** @@ -1179,8 +1309,6 @@ parseTimeDelta(timestr) **示例** -查询: - ```sql SELECT parseTimeDelta('11s+22min') ``` @@ -1200,9 +1328,10 @@ SELECT parseTimeDelta('1yr2mo') │ 36806400 │ └──────────────────────────┘ ``` + ## least {#least} -返回一个或多个输入参数中的最小参数。`NULL` 参数会被忽略。 +返回一个或多个输入参数中最小的参数。 `NULL` 参数被忽略。 **语法** @@ -1211,11 +1340,12 @@ least(a, b) ``` :::note -版本 [24.12](/whats-new/changelog/2024#a-id2412a-clickhouse-release-2412-2024-12-19) 引入了一个向后不兼容的更改,即 `NULL` 值被忽略,而之前如果参数中有一个 `NULL`,则返回 `NULL`。要保持以前的行为,请将设置 `least_greatest_legacy_null_behavior` (默认:`false`)设置为 `true`。 +版本 [24.12](/whats-new/changelog/2024#a-id2412a-clickhouse-release-2412-2024-12-19) 引入了向后不兼容的更改,使得 `NULL` 值被忽略,而之前如果一个参数为 `NULL` 则返回 `NULL`。要保留先前的行为,请将设置 `least_greatest_legacy_null_behavior`(默认值:`false`)设置为 `true`。 ::: + ## greatest {#greatest} -返回一个或多个输入参数中的最大参数。`NULL` 参数会被忽略。 +返回一个或多个输入参数中最大的参数。 `NULL` 参数被忽略。 **语法** @@ -1224,12 +1354,12 @@ greatest(a, b) ``` :::note -版本 [24.12](/whats-new/changelog/2024#a-id2412a-clickhouse-release-2412-2024-12-19) 引入了一个向后不兼容的更改,即 `NULL` 值被忽略,而之前如果参数中有一个 `NULL`,则返回 `NULL`。要保持以前的行为,请将设置 `least_greatest_legacy_null_behavior` (默认:`false`)设置为 `true`。 +版本 [24.12](/whats-new/changelog/2024#a-id2412a-clickhouse-release-2412-2024-12-19) 引入了向后不兼容的更改,使得 `NULL` 值被忽略,而之前如果一个参数为 `NULL` 则返回 `NULL`。要保留先前的行为,请将设置 `least_greatest_legacy_null_behavior`(默认值:`false`)设置为 `true`。 ::: + ## uptime {#uptime} -返回服务器的运行时间(以秒为单位)。 -如果在分布式表的上下文中执行,则此函数生成一个与每个分片相关的正常列的值。否则,它会产生一个常量值。 +返回服务器的运行时间(秒)。 如果在分布式表的上下文中执行,则此函数生成一个包含与每个分片相关值的正常列。否则,它生成一个常量值。 **语法** @@ -1239,14 +1369,14 @@ uptime() **返回值** -- 以秒为单位的时间值。[UInt32](../data-types/int-uint.md)。 +- 时间值(秒数)。[UInt32](../data-types/int-uint.md)。 **示例** 查询: ```sql -SELECT uptime() as Uptime; +SELECT uptime() AS Uptime; ``` 结果: @@ -1256,20 +1386,21 @@ SELECT uptime() as Uptime; │ 55867 │ └────────┘ ``` + ## version {#version} -以字符串形式返回 ClickHouse 的当前版本,其格式为: +返回 ClickHouse 当前版本,以字符串形式表示,格式如下: - 主版本 - 次版本 -- 修补版本 -- 自上一个稳定版本以来的提交数量。 +- 修订版本 +- 上一个稳定版本以来的提交次数。 ```text major_version.minor_version.patch_version.number_of_commits_since_the_previous_stable_release ``` -如果在分布式表的上下文中执行,则此函数生成一个与每个分片相关的正常列的值。否则,它会产生一个常量值。 +如果在分布式表的上下文中执行,则此函数生成一个包含与每个分片相关值的正常列。否则,它生成一个常量值。 **语法** @@ -1283,7 +1414,7 @@ version() **返回值** -- ClickHouse 的当前版本。[字符串](../data-types/string)。 +- ClickHouse 的当前版本。[String](../data-types/string.md)。 **实现细节** @@ -1304,20 +1435,20 @@ SELECT version() │ 24.2.1.1 │ └───────────┘ ``` + ## buildId {#buildid} -返回由编译器为运行的 ClickHouse 服务器二进制文件生成的构建 ID。 -如果在分布式表的上下文中执行,则此函数生成一个与每个分片相关的正常列的值。否则,它会产生一个常量值。 +返回为正在运行的 ClickHouse 服务器二进制文件生成的构建 ID。 如果在分布式表的上下文中执行,则此函数生成一个包含与每个分片相关值的正常列。否则,它生成一个常量值。 **语法** ```sql buildId() ``` + ## blockNumber {#blocknumber} -返回包含该行的 [block](../../development/architecture.md#block) 的单调递增序列号。 -返回的块号基于最佳努力更新,即它可能不完全准确。 +返回包含行的 [block](../../development/architecture.md#block) 的单调递增序列号。 返回的块编号在最佳努力基础上进行更新,即可能并不完全准确。 **语法** @@ -1327,7 +1458,7 @@ blockNumber() **返回值** -- 存在该行中的数据块的序列号。[UInt64](../data-types/int-uint.md)。 +- 行所在数据块的序列号。[UInt64](../data-types/int-uint.md)。 **示例** @@ -1367,10 +1498,10 @@ FROM │ 11 │ └───────────────┘ ``` + ## rowNumberInBlock {#rowNumberInBlock} -返回 `rowNumberInBlock` 处理的每个 [block](../../development/architecture.md#block) 的当前行号。 -返回的数字从每个块的 0 开始。 +返回 `rowNumberInBlock` 处理的每个 [block](../../development/architecture.md#block) 的当前行号。返回的编号在每个块中从 0 开始。 **语法** @@ -1380,7 +1511,7 @@ rowNumberInBlock() **返回值** -- 从 0 开始的数据块中行的序号。[UInt64](../data-types/int-uint.md)。 +- 从 0 开始的数据块中的行的序号。[UInt64](../data-types/int-uint.md)。 **示例** @@ -1420,9 +1551,10 @@ FROM │ 1 │ └────────────────────┘ ``` + ## rowNumberInAllBlocks {#rownumberinallblocks} -返回由 `rowNumberInAllBlocks` 处理的每行唯一行号。返回的数字从 0 开始。 +返回 `rowNumberInAllBlocks` 处理的每一行的唯一行号。返回的编号从 0 开始。 **语法** @@ -1432,7 +1564,7 @@ rowNumberInAllBlocks() **返回值** -- 从 0 开始的数据块中行的序号。[UInt64](../data-types/int-uint.md)。 +- 从 0 开始的数据块中的行的序号。[UInt64](../data-types/int-uint.md)。 **示例** @@ -1473,9 +1605,10 @@ SETTINGS max_block_size = 2 │ 9 │ └────────────────────────┘ ``` + ## normalizeQuery {#normalizequery} -用占位符 `?` 替换文字、文字序列和复杂别名(包含空格、超过两个数字或至少 36 字节长的内容,例如 UUID)。 +用占位符 `?` 替换字面值、字面值序列和复杂别名(包含空格、超过两个数字或至少 36 字节长,如 UUID)。 **语法** @@ -1485,11 +1618,11 @@ normalizeQuery(x) **参数** -- `x` — 字符序列。[字符串](../data-types/string.md)。 +- `x` — 字符序列。[String](../data-types/string.md)。 **返回值** -- 带占位符的字符序列。[字符串](../data-types/string.md)。 +- 带有占位符的字符序列。[String](../data-types/string.md)。 **示例** @@ -1506,9 +1639,10 @@ SELECT normalizeQuery('[1, 2, 3, x]') AS query; │ [?.., x] │ └──────────┘ ``` + ## normalizeQueryKeepNames {#normalizequerykeepnames} -用占位符 `?` 替换文字和文字序列,但不替换复杂别名(包含空格、超过两个数字或至少 36 字节长的内容,例如 UUID)。这有助于更好地分析复杂查询日志。 +用占位符 `?` 替换字面值和字面值序列,但不替换复杂别名(包含空格、超过两个数字或至少 36 字节长,如 UUID)。这有助于更好地分析复杂查询日志。 **语法** @@ -1518,11 +1652,11 @@ normalizeQueryKeepNames(x) **参数** -- `x` — 字符序列。[字符串](../data-types/string.md)。 +- `x` — 字符序列。[String](../data-types/string.md)。 **返回值** -- 带占位符的字符序列。[字符串](../data-types/string.md)。 +- 带有占位符的字符序列。[String](../data-types/string.md)。 **示例** @@ -1539,9 +1673,10 @@ SELECT normalizeQuery('SELECT 1 AS aComplexName123'), normalizeQueryKeepNames('S │ SELECT ? AS `?` │ SELECT ? AS aComplexName123 │ └───────────────────────────────────────────────┴────────────────────────────────────────────────────────┘ ``` + ## normalizedQueryHash {#normalizedqueryhash} -返回相似查询的文字值无值的相同 64 位哈希值。可以帮助分析查询日志。 +返回不带字面值的相似查询的相同 64 位哈希值。 有助于分析查询日志。 **语法** @@ -1551,7 +1686,7 @@ normalizedQueryHash(x) **参数** -- `x` — 字符序列。[字符串](../data-types/string.md)。 +- `x` — 字符序列。[String](../data-types/string.md)。 **返回值** @@ -1572,9 +1707,10 @@ SELECT normalizedQueryHash('SELECT 1 AS `xyz`') != normalizedQueryHash('SELECT 1 │ 1 │ └─────┘ ``` + ## normalizedQueryHashKeepNames {#normalizedqueryhashkeepnames} -与 [normalizedQueryHash](#normalizedqueryhash) 相似,它返回相似查询的文字值无值的相同 64 位哈希值,但在哈希之前不将复杂别名(包含空格、超过两个数字或至少 36 字节长的内容,例如 UUID)替换为占位符。这有助于分析查询日志。 +与 [normalizedQueryHash](#normalizedqueryhash) 类似,它返回不带字面值的相似查询的相同 64 位哈希值,但在哈希之前不将复杂别名(包含空格、超过两个数字或至少 36 字节长,如 UUID)替换为占位符。 有助于分析查询日志。 **语法** @@ -1584,7 +1720,7 @@ normalizedQueryHashKeepNames(x) **参数** -- `x` — 字符序列。[字符串](../data-types/string.md)。 +- `x` — 字符序列。[String](../data-types/string.md)。 **返回值** @@ -1611,7 +1747,7 @@ SELECT normalizedQueryHashKeepNames('SELECT 1 AS `xyz123`') != normalizedQueryHa -窗口函数,提供对指定偏移量前后行的访问。 +窗口函数提供对给定列的当前行前后指定偏移量的行的访问。 **语法** @@ -1619,29 +1755,29 @@ SELECT normalizedQueryHashKeepNames('SELECT 1 AS `xyz123`') != normalizedQueryHa neighbor(column, offset[, default_value]) ``` -函数的结果取决于受影响数据块和数据在块中的顺序。 +该函数的结果取决于受影响的数据块和数据在块中的顺序。 :::note -仅返回当前处理数据块内的相邻值。 -由于这种易出错的行为,该函数已被弃用,请使用适当的窗口函数。 +仅返回当前处理的数据块内的邻近值。 +由于这种容易出错的行为,该函数已被弃用,请使用适当的窗口函数。 ::: -在计算 `neighbor()` 时,行的顺序可能会与用户返回的行的顺序不同。 -为防止这种情况,可以创建一个带有 [ORDER BY](../../sql-reference/statements/select/order-by.md) 的子查询,并从子查询外部调用该函数。 +在计算 `neighbor()` 时,行的顺序可能与返回给用户的行的顺序不同。 +为防止这种情况,您可以创建带有 [ORDER BY](../../sql-reference/statements/select/order-by.md) 的子查询,并在子查询之外调用该函数。 **参数** -- `column` — 列名称或标量表达式。 -- `offset` — 在 `column` 中查找当前行之前或之后的行数。[Int64](../data-types/int-uint.md)。 -- `default_value` — 可选。如果偏移量超出块边界,则返回该值。受影响的数据块的类型。 +- `column` — 列名或标量表达式。 +- `offset` — 在 `column` 中查找当前行之前或之前的行的数量。 [Int64](../data-types/int-uint.md)。 +- `default_value` — 可选。如果偏移超出块边界,则返回该值。受影响的数据块的数据类型。 **返回值** -- 当前行偏移量为 `offset` 的 `column` 值,如果 `offset` 不在块边界之外。 -- `column` 的默认值或 `default_value`(如果提供),如果 `offset` 超出块边界。 +- 如果 `offset` 不超出块边界,返回与当前行相距 `offset` 的 `column` 的值。 +- 如果 `offset` 超出块边界,则返回 `column` 的默认值或 `default_value`(如果给定)。 :::note -返回类型将是受影响的数据块的类型或默认值类型。 +返回类型将是受影响的数据块类型或默认值类型。 ::: **示例** @@ -1692,7 +1828,7 @@ SELECT number, neighbor(number, 2, 999) FROM system.numbers LIMIT 10; └────────┴──────────────────────────┘ ``` -此函数可用于计算年比年指标值: +此函数可用于计算同比指标值: 查询: @@ -1730,18 +1866,17 @@ FROM numbers(16) ``` ## runningDifference {#runningDifference} -计算数据块中两个连续行值之间的差异。 -对于第一行返回 0,对于后续行,返回与前一行的差异。 +计算数据块中两行连续行值之间的差。对于第一行返回 0,对于随后的行返回与前一行的差。 :::note -仅返回当前处理数据块内的差异。 -由于这种易出错的行为,该函数已被弃用,请使用适当的窗口函数。 +仅返回当前处理的数据块内的差。 +由于这种容易出错的行为,该函数已被弃用,请使用适当的窗口函数。 ::: -函数的结果取决于受影响数据块和数据在块中的顺序。 +该函数的结果取决于受影响的数据块和数据在块中的顺序。 -在计算 `runningDifference()` 时,行的顺序可能会与用户返回的行的顺序不同。 -为防止这种情况,可以创建一个带有 [ORDER BY](../../sql-reference/statements/select/order-by.md) 的子查询,并从子查询外部调用该函数。 +在计算 `runningDifference()` 时,行的顺序可能与返回给用户的行的顺序不同。 +为防止这种情况,您可以创建带有 [ORDER BY](../../sql-reference/statements/select/order-by.md) 的子查询,并在子查询之外调用该函数。 **语法** @@ -1782,7 +1917,7 @@ FROM └─────────┴─────────────────────┴───────┘ ``` -请注意,块大小会影响结果。`runningDifference` 的内部状态在每个新块处重置。 +请注意,块大小会影响结果。`runningDifference` 的内部状态会在每个新块中重置。 查询: @@ -1827,18 +1962,17 @@ WHERE diff != 1 ## runningDifferenceStartingWithFirstValue {#runningdifferencestartingwithfirstvalue} :::note -该函数已被弃用(请参见 `runningDifference` 的说明)。 +此函数已弃用(请参见 `runningDifference` 的注释)。 ::: -与 [runningDifference](/sql-reference/functions/other-functions#runningDifference) 相同,但将第一行的值作为第一行的值返回。 +与 [runningDifference](/sql-reference/functions/other-functions#runningDifference) 相同,但返回第一行的值作为第一行的值。 ## runningConcurrency {#runningconcurrency} -计算并发事件的数量。 -每个事件都有开始时间和结束时间。开始时间包含在事件中,而结束时间不包含。带有开始时间和结束时间的列必须具有相同的数据类型。 -该函数计算每个事件开始时间的活动(并发)事件总数。 +计算并发事件的数量。每个事件都有一个开始时间和结束时间。开始时间包含在事件中,而结束时间则不包含。具有开始时间和结束时间的列必须具有相同的数据类型。 +该函数计算每个事件开始时间的活动(并发)事件的总数。 :::tip -事件必须按升序排列的开始时间。如果违反此要求,函数将引发异常。每个数据块单独处理。如果来自不同数据块的事件重叠,则不能正确处理它们。 +事件必须按升序排列的开始时间。如果不满足此要求,函数会抛出异常。每个数据块都单独处理。如果来自不同数据块的事件重叠,则无法正确处理。 ::: **语法** @@ -1849,16 +1983,16 @@ runningConcurrency(start, end) **参数** -- `start` — 事件的开始时间列。[日期](../data-types/date.md)、[日期时间](../data-types/datetime.md)或 [DateTime64](../data-types/datetime64.md)。 -- `end` — 事件的结束时间列。[日期](../data-types/date.md)、[日期时间](../data-types/datetime.md)或 [DateTime64](../data-types/datetime64.md)。 +- `start` — 事件的开始时间的列。 [Date](../data-types/date.md)、[DateTime](../data-types/datetime.md) 或 [DateTime64](../data-types/datetime64.md)。 +- `end` — 事件的结束时间的列。 [Date](../data-types/date.md)、[DateTime](../data-types/datetime.md) 或 [DateTime64](../data-types/datetime64.md)。 **返回值** -- 每个事件开始时间的并发事件数量。[UInt32](../data-types/int-uint.md) +- 每个事件开始时间的并发事件数量。 [UInt32](../data-types/int-uint.md) **示例** -考虑表: +考虑以下表: ```text ┌──────start─┬────────end─┐ @@ -1885,10 +2019,9 @@ SELECT start, runningConcurrency(start, end) FROM example_table; │ 2021-03-11 │ 2 │ └────────────┴────────────────────────────────┘ ``` - ## MACNumToString {#macnumtostring} -将 UInt64 数字解释为大端格式的 MAC 地址。以字符串形式返回相应的 MAC 地址,格式为 AA:BB:CC:DD:EE:FF(十六进制形式的冒号分隔数字)。 +将 UInt64 数字解释为大端格式的 MAC 地址。以格式 AA:BB:CC:DD:EE:FF(以冒号分隔的十六进制数字)作为字符串返回相应的 MAC 地址。 **语法** @@ -1897,7 +2030,7 @@ MACNumToString(num) ``` ## MACStringToNum {#macstringtonum} -MACNumToString 的逆函数。如果 MAC 地址格式无效,则返回 0。 +与 MACNumToString 相反的函数。如果 MAC 地址格式无效,则返回 0。 **语法** @@ -1906,7 +2039,7 @@ MACStringToNum(s) ``` ## MACStringToOUI {#macstringtooui} -给定格式为 AA:BB:CC:DD:EE:FF(十六进制形式的冒号分隔数字)的 MAC 地址,返回前三个八位字节作为 UInt64 数字。如果 MAC 地址格式无效,则返回 0。 +给定格式为 AA:BB:CC:DD:EE:FF(以冒号分隔的十六进制数字)的 MAC 地址,返回前三区段作为 UInt64 数字。如果 MAC 地址格式无效,则返回 0。 **语法** @@ -1915,8 +2048,7 @@ MACStringToOUI(s) ``` ## getSizeOfEnumType {#getsizeofenumtype} -返回 [Enum](../data-types/enum.md) 中字段的数量。 -如果类型不是 `Enum`,则会抛出异常。 +返回 [Enum](../data-types/enum.md) 中的字段数量。如果该类型不是 `Enum`,则抛出异常。 **语法** @@ -1930,7 +2062,7 @@ getSizeOfEnumType(value) **返回值** -- 具有 `Enum` 输入值的字段数量。 +- 输入值为 `Enum` 的字段数量。 **示例** @@ -1945,7 +2077,7 @@ SELECT getSizeOfEnumType( CAST('a' AS Enum8('a' = 1, 'b' = 2) ) ) AS x ``` ## blockSerializedSize {#blockserializedsize} -返回未考虑压缩的磁盘大小。 +返回磁盘上的大小,不考虑压缩。 ```sql blockSerializedSize(value[, value[, ...]]) @@ -1953,18 +2085,18 @@ blockSerializedSize(value[, value[, ...]]) **参数** -- `value` — 任意值。 +- `value` — 任何值。 **返回值** -- 在没有压缩的情况下,将为值块写入磁盘的字节数。 +- 将写入磁盘的值块的字节数(未压缩)。 **示例** 查询: ```sql -SELECT blockSerializedSize(maxState(1)) as x +SELECT blockSerializedSize(maxState(1)) AS x ``` 结果: @@ -1976,7 +2108,7 @@ SELECT blockSerializedSize(maxState(1)) as x ``` ## toColumnTypeName {#tocolumntypename} -返回代表该值的数据类型的内部名称。 +返回表示该值的数据类型的内部名称。 **语法** @@ -1986,7 +2118,7 @@ toColumnTypeName(value) **参数:** -- `value` — 任意类型的值。 +- `value` — 任何类型的值。 **返回值** @@ -1994,7 +2126,7 @@ toColumnTypeName(value) **示例** -`toTypeName` 与 `toColumnTypeName` 之间的区别: +`toTypeName` 和 `toColumnTypeName` 之间的区别: ```sql SELECT toTypeName(CAST('2018-01-01 01:02:03' AS DateTime)) @@ -2022,10 +2154,10 @@ SELECT toColumnTypeName(CAST('2018-01-01 01:02:03' AS DateTime)) └───────────────────────────────────────────────────────────┘ ``` -示例表明,`DateTime` 数据类型在内部存储为 `Const(UInt32)`。 +示例显示 `DateTime` 数据类型在内部存储为 `Const(UInt32)`。 ## dumpColumnStructure {#dumpcolumnstructure} -输出 RAM 中数据结构的详细描述 +输出 RAM 中数据结构的详细描述。 ```sql dumpColumnStructure(value) @@ -2033,11 +2165,11 @@ dumpColumnStructure(value) **参数:** -- `value` — 任意类型的值。 +- `value` — 任何类型的值。 **返回值** -- 描述用于表示 `value` 的列结构。 +- 用于表示 `value` 的列结构的描述。 **示例** @@ -2064,13 +2196,13 @@ defaultValueOfArgumentType(expression) **参数:** -- `expression` — 任意类型的值或结果为任意类型的表达式。 +- `expression` — 任意类型的值或结果为任意类型值的表达式。 **返回值** - 数字的默认值为 `0`。 - 字符串的默认值为空字符串。 -- `ᴺᵁᴸᴸ` 表示 [Nullable](../data-types/nullable.md)。 +- 对于 [Nullable](../data-types/nullable.md) 的返回值为 `ᴺᵁᴸᴸ`。 **示例** @@ -2119,7 +2251,7 @@ defaultValueOfTypeName(type) - 数字的默认值为 `0`。 - 字符串的默认值为空字符串。 -- `ᴺᵁᴸᴸ` 表示 [Nullable](../data-types/nullable.md)。 +- 对于 [Nullable](../data-types/nullable.md) 的返回值为 `ᴺᵁᴸᴸ`。 **示例** @@ -2152,9 +2284,9 @@ SELECT defaultValueOfTypeName('Nullable(Int8)') ``` ## indexHint {#indexhint} -此函数用于调试和自省。它忽略其参数并始终返回 1。参数不被评估。 +此函数用于调试和内省。它忽略其参数并始终返回 1。参数不会被求值。 -但在索引分析期间,该函数的参数假定没有被 `indexHint` 包装。这允许通过相应的条件选择索引范围内的数据,但不需对该条件进一步过滤。在 ClickHouse 中,索引是稀疏的,使用 `indexHint` 将产生比直接指定相同条件更多的数据。 +但是在索引分析期间,该函数的参数假设不被 `indexHint` 包裹。这使得可以通过相应的条件在索引范围内选择数据,但不再通过此条件进一步过滤。在 ClickHouse 中,索引是稀疏的,使用 `indexHint` 将产生比直接指定相同条件更多的数据。 **语法** @@ -2182,7 +2314,7 @@ SELECT count() FROM ontime └─────────┘ ``` -表在字段 `(FlightDate, (Year, FlightDate))` 上有索引。 +该表针对字段 `(FlightDate, (Year, FlightDate))` 创建索引。 创建一个不使用索引的查询: @@ -2190,7 +2322,7 @@ SELECT count() FROM ontime SELECT FlightDate AS k, count() FROM ontime GROUP BY k ORDER BY k ``` -ClickHouse 处理了整个表 (`处理了 428 万行`)。 +ClickHouse 处理了整个表(`处理了 4.28 百万行`)。 结果: @@ -2205,13 +2337,13 @@ ClickHouse 处理了整个表 (`处理了 428 万行`)。 └────────────┴─────────┘ ``` -为了应用索引,选择特定日期: +要应用索引,选择一个特定日期: ```sql SELECT FlightDate AS k, count() FROM ontime WHERE k = '2017-09-15' GROUP BY k ORDER BY k ``` -ClickHouse 现在使用索引处理数量显著较少的行 (`处理了 32740 行`)。 +ClickHouse 现在使用索引处理了显著更少的行(`处理了 32.74 千行`)。 结果: @@ -2221,7 +2353,7 @@ ClickHouse 现在使用索引处理数量显著较少的行 (`处理了 32740 └────────────┴─────────┘ ``` -现在将表达式 `k = '2017-09-15'` 包装在 `indexHint` 函数中: +现在将表达式 `k = '2017-09-15'` 包裹在函数 `indexHint` 中: 查询: @@ -2235,8 +2367,8 @@ GROUP BY k ORDER BY k ASC ``` -ClickHouse 以与之前相同的方式使用索引 (`处理了 32740 行`)。 -生成结果时未使用表达式 `k = '2017-09-15'`。 +ClickHouse 以与之前相同的方式使用索引(`处理了 32.74 千行`)。 +在生成结果时未使用表达式 `k = '2017-09-15'`。 在示例中,`indexHint` 函数允许查看相邻日期。 结果: @@ -2251,7 +2383,7 @@ ClickHouse 以与之前相同的方式使用索引 (`处理了 32740 行`)。 ``` ## replicate {#replicate} -创建一个包含单个值的数组。 +创建一个仅包含单一值的数组。 :::note 此函数用于 [arrayJoin](/sql-reference/functions/array-join) 的内部实现。 @@ -2265,12 +2397,12 @@ replicate(x, arr) **参数** -- `x` — 用于填充结果数组的值。 -- `arr` — 数组。 [Array](../data-types/array.md)。 +- `x` — 填充结果数组的值。 +- `arr` — 一个数组。 [Array](../data-types/array.md)。 **返回值** -一个与 `arr` 大小相同的数组,填充值 `x`。 [Array](../data-types/array.md)。 +一个与 `arr` 相同长度的数组,填充值 `x`。 [Array](../data-types/array.md)。 **示例** @@ -2289,7 +2421,7 @@ SELECT replicate(1, ['a', 'b', 'c']); ``` ## revision {#revision} -返回当前 ClickHouse [服务器版本](../../operations/system-tables/metrics#revision)。 +返回当前 ClickHouse [server revision](../../operations/system-tables/metrics#revision) 。 **语法** @@ -2299,7 +2431,7 @@ revision() **返回值** -- 当前 ClickHouse 服务器版本。 [UInt32](../data-types/int-uint.md)。 +- 当前 ClickHouse 服务器修订版。 [UInt32](../data-types/int-uint.md)。 **示例** @@ -2318,7 +2450,7 @@ SELECT revision(); ``` ## filesystemAvailable {#filesystemavailable} -返回托管数据库持久性的文件系统中的可用空间量。返回的值总是小于总的可用空间量 ([filesystemUnreserved](#filesystemunreserved)),因为某些空间是为操作系统保留的。 +返回托管数据库持久性的文件系统中的可用空间。返回的值总是小于总可用空间([filesystemUnreserved](#filesystemunreserved)),因为有部分空间被操作系统保留。 **语法** @@ -2328,7 +2460,7 @@ filesystemAvailable() **返回值** -- 以字节为单位的剩余可用空间量。 [UInt64](../data-types/int-uint.md)。 +- 以字节为单位的剩余可用空间。 [UInt64](../data-types/int-uint.md)。 **示例** @@ -2347,7 +2479,7 @@ SELECT formatReadableSize(filesystemAvailable()) AS "Available space"; ``` ## filesystemUnreserved {#filesystemunreserved} -返回托管数据库持久性的文件系统上的总可用空间量。 (之前称为 `filesystemFree` )。 另见 [`filesystemAvailable`](#filesystemavailable)。 +返回托管数据库持久性的文件系统中的总可用空间。(之前叫做 `filesystemFree`)。另见 [`filesystemAvailable`](#filesystemavailable)。 **语法** @@ -2357,7 +2489,7 @@ filesystemUnreserved() **返回值** -- 以字节为单位的可用空间总量。 [UInt64](../data-types/int-uint.md)。 +- 以字节为单位的可用空间。 [UInt64](../data-types/int-uint.md)。 **示例** @@ -2376,7 +2508,7 @@ SELECT formatReadableSize(filesystemUnreserved()) AS "Free space"; ``` ## filesystemCapacity {#filesystemcapacity} -返回文件系统的容量(以字节为单位)。需要配置 [path](../../operations/server-configuration-parameters/settings.md#path) 指向数据目录。 +返回文件系统的容量(以字节为单位)。需要为数据目录配置 [path](../../operations/server-configuration-parameters/settings.md#path)。 **语法** @@ -2386,7 +2518,7 @@ filesystemCapacity() **返回值** -- 文件系统的容量(以字节为单位)。 [UInt64](../data-types/int-uint.md)。 +- 文件系统的容量,以字节为单位。 [UInt64](../data-types/int-uint.md)。 **示例** @@ -2405,7 +2537,7 @@ SELECT formatReadableSize(filesystemCapacity()) AS "Capacity"; ``` ## initializeAggregation {#initializeaggregation} -根据单个值计算聚合函数的结果。此函数可用于初始化带组合器的聚合函数 [-State](/sql-reference/aggregate-functions/combinators#-state)。您可以创建聚合函数的状态并将其插入到类型为 [AggregateFunction](/sql-reference/data-types/aggregatefunction) 的列中,或使用初始化的聚合作为默认值。 +基于单个值计算聚合函数的结果。此函数可用于初始化与组合器 [-State](/sql-reference/aggregate-functions/combinators#-state) 相关的聚合函数。您可以创建聚合函数的状态并将其插入到类型为 [AggregateFunction](/sql-reference/data-types/aggregatefunction) 的列中,或将初始化过的聚合用作默认值。 **语法** @@ -2422,7 +2554,7 @@ initializeAggregation (aggregate_function, arg1, arg2, ..., argN) - 传递给函数的每一行的聚合结果。 -返回类型与 `initializeAggregation` 作为第一个参数所接受的函数的返回类型相同。 +返回类型与作为第一个参数传递给 `initializeAggregation` 的函数的返回类型相同。 **示例** @@ -2458,7 +2590,7 @@ SELECT finalizeAggregation(state), toTypeName(state) FROM (SELECT initializeAggr └────────────────────────────┴───────────────────────────────┘ ``` -在使用 `AggregatingMergeTree` 表引擎和 `AggregateFunction` 列的示例: +使用 `AggregatingMergeTree` 表引擎和 `AggregateFunction` 列的示例: ```sql CREATE TABLE metrics @@ -2474,12 +2606,12 @@ ORDER BY key INSERT INTO metrics VALUES (0, initializeAggregation('sumState', toUInt64(42))) ``` -**另见** +**另请参见** -- [arrayReduce](../../sql-reference/functions/array-functions.md#arrayreduce) +- [arrayReduce](../../sql-reference/functions/array-functions.md#arrayReduce) ## finalizeAggregation {#finalizeaggregation} -给定聚合函数的状态,此函数返回聚合的结果(或在使用 [-State](/sql-reference/aggregate-functions/combinators#-state) 组合器时的最终状态)。 +给定聚合函数的状态,此函数返回聚合结果(或在使用 [-State](/sql-reference/aggregate-functions/combinators#-state) 组合器时的最终状态)。 **语法** @@ -2493,10 +2625,10 @@ finalizeAggregation(state) **返回值** -- 被聚合的值/值。 +- 被聚合的值。 :::note -返回类型与任何被聚合的类型的类型相同。 +返回类型等于任何被聚合类型的类型。 ::: **示例** @@ -2575,17 +2707,17 @@ FROM numbers(10); └────────┴─────────────┴────────────────┘ ``` -**另见** +**另请参见** -- [arrayReduce](../../sql-reference/functions/array-functions.md#arrayreduce) +- [arrayReduce](../../sql-reference/functions/array-functions.md#arrayReduce) - [initializeAggregation](#initializeaggregation) ## runningAccumulate {#runningaccumulate} -在每个数据块的行上累积聚合函数的状态。 +为数据块的每一行累积聚合函数的状态。 :::note -每个新数据块都会重置状态。 -由于这种错误易发的行为,此函数已被弃用,请使用适当的窗口函数。 +该状态在每个新数据块中重置。 +由于这种容易出错的行为,该函数已被弃用,请使用适当的窗口函数。 ::: **语法** @@ -2597,22 +2729,22 @@ runningAccumulate(agg_state[, grouping]); **参数** - `agg_state` — 聚合函数的状态。 [AggregateFunction](/sql-reference/data-types/aggregatefunction)。 -- `grouping` — 分组键。可选。如果更改 `grouping` 值,则会重置函数的状态。它可以是任何支持数据类型的类型 [index.md](../data-types/index.md) 的类型,对于这些类型定义了相等运算符。 +- `grouping` — 分组键。可选。如果改变 `grouping` 值,则重置函数的状态。它可以是任何已定义相等运算符的 [支持数据类型](../data-types/index.md)。 **返回值** -- 每个结果行包含用于所有输入行的聚合函数结果,累积到当前的行位置为止。 `runningAccumulate` 在每个新数据块或 `grouping` 值更改时重置状态。 +- 每个结果行包含从 0 到当前行的所有输入行的聚合函数结果。 `runningAccumulate` 在每个新数据块或 `grouping` 值更改时重置状态。 -类型依赖于使用的聚合函数。 +类型取决于使用的聚合函数。 **示例** -考虑如何使用 `runningAccumulate` 计算不分组和分组的数字的累积和。 +考虑如何使用 `runningAccumulate` 查找数字的累积和,没有分组和有分组。 查询: ```sql -SELECT k, runningAccumulate(sum_k) AS res FROM (SELECT number as k, sumState(k) AS sum_k FROM numbers(10) GROUP BY k ORDER BY k); +SELECT k, runningAccumulate(sum_k) AS res FROM (SELECT number AS k, sumState(k) AS sum_k FROM numbers(10) GROUP BY k ORDER BY k); ``` 结果: @@ -2632,16 +2764,16 @@ SELECT k, runningAccumulate(sum_k) AS res FROM (SELECT number as k, sumState(k) └───┴─────┘ ``` -子查询为从 `0` 到 `9` 的每个数字生成 `sumState`。 `sumState` 返回包含单个数字和(../../sql-reference/aggregate-functions/reference/sum.md)函数的状态。 +子查询生成从 `0` 到 `9` 的每一个数字的 `sumState`。`sumState` 返回 [sum](../../sql-reference/aggregate-functions/reference/sum.md) 函数的状态,该状态包含一个数字的总和。 整个查询执行以下操作: 1. 对于第一行,`runningAccumulate` 取 `sumState(0)` 并返回 `0`。 -2. 对于第二行,函数合并 `sumState(0)` 和 `sumState(1)`,结果为 `sumState(0 + 1)`,并返回 `1` 作为结果。 -3. 对于第三行,函数合并 `sumState(0 + 1)` 和 `sumState(2)`,结果为 `sumState(0 + 1 + 2)`,并返回 `3` 作为结果。 -4. 这些操作重复进行,直到块结束。 +2. 对于第二行,该函数合并 `sumState(0)` 和 `sumState(1)`,结果为 `sumState(0 + 1)`,返回 `1` 作为结果。 +3. 对于第三行,该函数合并 `sumState(0 + 1)` 和 `sumState(2)`,结果为 `sumState(0 + 1 + 2)`,返回 `3` 作为结果。 +4. 在块结束之前,操作不断重复。 -下一个示例显示 `groupping` 参数的用法: +以下示例展示了 `grouping` 参数的用法: 查询: @@ -2684,10 +2816,10 @@ FROM └──────────┴──────┴─────┘ ``` -如您所见,`runningAccumulate` 会分别合并每组行的状态。 +可见,`runningAccumulate` 为每组行分别合并状态。 ## joinGet {#joinget} -该函数允许您从表中提取数据,方式与从 [dictionary](../../sql-reference/dictionaries/index.md) 相同。 使用指定的连接键从 [Join](../../engines/table-engines/special/join.md#creating-a-table) 表中获取数据。 +该函数允许您以与从 [dictionary](../../sql-reference/dictionaries/index.md) 相同的方式从表中提取数据。通过指定的连接键从 [Join](../../engines/table-engines/special/join.md#creating-a-table) 表中获取数据。 :::note 仅支持使用 `ENGINE = Join(ANY, LEFT, )` 语句创建的表。 @@ -2701,12 +2833,12 @@ joinGet(join_storage_table_name, `value_column`, join_keys) **参数** -- `join_storage_table_name` — 指定搜索位置的 [标识符](/sql-reference/syntax#identifiers)。 +- `join_storage_table_name` — 一个 [identifier](/sql-reference/syntax#identifiers),指示搜索的位置。 - `value_column` — 包含所需数据的表的列名。 - `join_keys` — 键的列表。 :::note -该标识符在默认数据库中进行搜索(请参阅配置文件中的设置 `default_database`)。要覆盖默认数据库,请使用 `USE db_name` 或通过分隔符 `db_name.db_table` 指定数据库和表,如示例所示。 +在默认数据库中搜索标识符(请参见配置文件中的 `default_database` 设置)。要覆盖默认数据库,请使用 `USE db_name` 或通过分隔符 `db_name.db_table` 指定数据库和表,如示例中所示。 ::: **返回值** @@ -2714,8 +2846,8 @@ joinGet(join_storage_table_name, `value_column`, join_keys) - 返回与键列表对应的值列表。 :::note -如果某个键在源表中不存在,则根据表创建时的 [join_use_nulls](../../operations/settings/settings.md#join_use_nulls) 设置,将返回 `0` 或 `null`。 -有关 `join_use_nulls` 的更多信息,请参阅 [Join 操作](../../engines/table-engines/special/join.md)。 +如果源表中不存在某个键,则根据创建表时的 [join_use_nulls](../../operations/settings/settings.md#join_use_nulls) 设置返回 `0` 或 `null`。 +有关 `join_use_nulls` 的更多信息,请参见 [Join 操作](../../engines/table-engines/special/join.md)。 ::: **示例** @@ -2740,7 +2872,7 @@ SELECT * FROM db_test.id_val; 查询: ```sql -SELECT number, joinGet(db_test.id_val, 'val', toUInt32(number)) from numbers(4); +SELECT number, joinGet(db_test.id_val, 'val', toUInt32(number)) FROM numbers(4); ``` 结果: @@ -2754,7 +2886,7 @@ SELECT number, joinGet(db_test.id_val, 'val', toUInt32(number)) from numbers(4); └────────┴────────────────────────────────────────────────────┘ ``` -在表创建时可以使用设置 `join_use_nulls` 来更改键不存在时返回的行为。 +在创建表时,可以使用设置 `join_use_nulls` 来改变如果源表中没有键时返回的行为。 ```sql CREATE DATABASE db_test; @@ -2774,7 +2906,7 @@ SELECT * FROM db_test.id_val_nulls; 查询: ```sql -SELECT number, joinGet(db_test.id_val_nulls, 'val', toUInt32(number)) from numbers(4); +SELECT number, joinGet(db_test.id_val_nulls, 'val', toUInt32(number)) FROM numbers(4); ``` 结果: @@ -2789,7 +2921,7 @@ SELECT number, joinGet(db_test.id_val_nulls, 'val', toUInt32(number)) from numbe ``` ## joinGetOrNull {#joingetornull} -类似于 [joinGet](#joinget) 但在缺少键时返回 `NULL`,而不是返回默认值。 +与 [joinGet](#joinget) 相似,但在缺失键时返回 `NULL` 而不是返回默认值。 **语法** @@ -2799,12 +2931,12 @@ joinGetOrNull(join_storage_table_name, `value_column`, join_keys) **参数** -- `join_storage_table_name` — 指定搜索位置的 [标识符](/sql-reference/syntax#identifiers)。 +- `join_storage_table_name` — 一个 [identifier](/sql-reference/syntax#identifiers),指示搜索的位置。 - `value_column` — 包含所需数据的表的列名。 - `join_keys` — 键的列表。 :::note -该标识符在默认数据库中进行搜索(请参阅配置文件中的设置 `default_database`)。要覆盖默认数据库,请使用 `USE db_name` 或通过分隔符 `db_name.db_table` 指定数据库和表,如示例所示。 +在默认数据库中搜索标识符(请参见配置文件中的 `default_database` 设置)。要覆盖默认数据库,请使用 `USE db_name` 或通过分隔符 `db_name.db_table` 指定数据库和表,如示例中所示。 ::: **返回值** @@ -2812,7 +2944,7 @@ joinGetOrNull(join_storage_table_name, `value_column`, join_keys) - 返回与键列表对应的值列表。 :::note -如果某个键在源表中不存在,则将为该键返回 `NULL`。 +如果源表中不存在某个键,则为该键返回 `NULL`。 ::: **示例** @@ -2837,7 +2969,7 @@ SELECT * FROM db_test.id_val; 查询: ```sql -SELECT number, joinGetOrNull(db_test.id_val, 'val', toUInt32(number)) from numbers(4); +SELECT number, joinGetOrNull(db_test.id_val, 'val', toUInt32(number)) FROM numbers(4); ``` 结果: @@ -2858,8 +2990,7 @@ SELECT number, joinGetOrNull(db_test.id_val, 'val', toUInt32(number)) from numbe 此函数在 ClickHouse Cloud 中不可用。 ::: -评估外部 catboost 模型。 [CatBoost](https://catboost.ai) 是由 Yandex 开发的开源梯度提升库,用于机器学习。 -接受 catboost 模型的路径和模型参数(特征)。返回 Float64。 +评估外部 catboost 模型。[CatBoost](https://catboost.ai) 是 Yandex 开发的开源梯度提升库,用于机器学习。接受指向 catboost 模型及模型参数(特征)的路径。返回 Float64。 **语法** @@ -2874,13 +3005,13 @@ SELECT feat1, ..., feat_n, catboostEvaluate('/path/to/model.bin', feat_1, ..., f FROM data_table ``` -**前提条件** +**先决条件** 1. 构建 catboost 评估库 -在评估 catboost 模型之前,必须提供 `libcatboostmodel.` 库。有关如何进行编译,请参阅 [CatBoost 文档](https://catboost.ai/docs/concepts/c-plus-plus-api_dynamic-c-pluplus-wrapper.html)。 +在评估 catboost 模型之前,必须提供 `libcatboostmodel.` 库。请参见 [CatBoost 文档](https://catboost.ai/docs/concepts/c-plus-plus-api_dynamic-c-pluplus-wrapper.html) 了解如何编译它。 -接下来,在 ClickHouse 配置中指定路径到 `libcatboostmodel.`: +接下来,在 ClickHouse 配置中指定 `libcatboostmodel.` 的路径: ```xml @@ -2890,8 +3021,9 @@ FROM data_table ``` -出于安全和隔离原因,模型评估不会在服务器进程中运行,而是在 clickhouse-library-bridge 进程中运行。 -在第一次执行 `catboostEvaluate()` 时,服务器会启动库桥接进程(如果尚未运行)。这两个进程通过 HTTP 接口进行通信。默认情况下,端口 `9012` 被使用。如果端口 `9012` 已被分配给其他服务,可以按以下方式指定其他端口 - 这在端口 `9012` 已分配给其他服务的情况下非常有用。 +出于安全和隔离的原因,模型评估不会在服务器进程中运行,而是在 clickhouse-library-bridge 进程中运行。 +在第一次执行 `catboostEvaluate()` 时,如果该库桥接进程尚未运行,则服务器会启动该进程。这两个进程 +通过 HTTP 接口进行通信。默认情况下使用端口 `9012`。可以通过以下方式指定其他端口 - 如果端口 `9012` 已经分配给其他服务,则此功能十分有用。 ```xml @@ -2901,10 +3033,10 @@ FROM data_table 2. 使用 libcatboost 训练 catboost 模型 -请参阅 [Training and applying models](https://catboost.ai/docs/features/training.html#training) 以了解如何根据训练数据集训练 catboost 模型。 +请参见 [训练和应用模型](https://catboost.ai/docs/features/training.html#training) 了解如何从训练数据集训练 catboost 模型。 ## throwIf {#throwif} -如果参数 `x` 为真,则抛出异常。 +如果参数 `x` 为真则抛出异常。 **语法** @@ -2918,7 +3050,7 @@ throwIf(x[, message[, error_code]]) - `message` - 提供自定义错误消息的常量字符串。可选。 - `error_code` - 提供自定义错误代码的常量整数。可选。 -要使用 `error_code` 参数,必须启用配置参数 `allow_custom_error_code_in_throwif`。 +要使用 `error_code` 参数,配置参数 `allow_custom_error_code_in_throwif` 必须启用。 **示例** @@ -2934,7 +3066,7 @@ Code: 395. DB::Exception: Received from localhost:9000. DB::Exception: Too many. ``` ## identity {#identity} -返回其参数。用于调试和测试。允许取消使用索引,并获取全表扫描的查询性能。当查询在闭合索引时进行可能的分析时,分析器会忽略 `identity` 函数中的所有内容。也禁用了常量折叠。 +返回它的参数。用于调试和测试。取消使用索引,并获取全扫描的查询性能。当查询分析以判断是否使用索引时,分析器会忽略 `identity` 函数中的所有内容。同时禁用常量折叠。 **语法** @@ -2959,7 +3091,7 @@ SELECT identity(42); ``` ## getSetting {#getsetting} -返回当前 [自定义设置](/operations/settings/query-level#custom_settings) 的值。 +返回 [自定义设置](/operations/settings/query-level#custom_settings) 的当前值。 **语法** @@ -2990,12 +3122,12 @@ SELECT getSetting('custom_a'); 123 ``` -**另见** +**另请参见** - [自定义设置](/operations/settings/query-level#custom_settings) ## getSettingOrDefault {#getsettingordefault} -返回当前 [自定义设置](/operations/settings/query-level#custom_settings) 的值,或者如果当前配置未设置自定义设置,则返回第二个参数中指定的默认值。 +返回 [自定义设置](/operations/settings/query-level#custom_settings) 的当前值,或者如果当前配置文件中未设置自定义配置,则返回第二个参数中指定的默认值。 **语法** @@ -3006,11 +3138,11 @@ getSettingOrDefault('custom_setting', default_value); **参数** - `custom_setting` — 设置名称。 [String](../data-types/string.md)。 -- `default_value` — 如果未设置 custom_setting,则返回的值。值可以是任何数据类型或 Null。 +- `default_value` — 如果未设置 custom_setting 的值,则返回的值。值可以是任何数据类型或 Null。 **返回值** -- 设置的当前值或设置未设置时的 default_value。 +- 设置的当前值或如果未设置,则返回 default_value。 **示例** @@ -3030,12 +3162,12 @@ my_value NULL ``` -**另见** +**另请参见** - [自定义设置](/operations/settings/query-level#custom_settings) ## isDecimalOverflow {#isdecimaloverflow} -检查 [Decimal](../data-types/decimal.md) 值是否超出其精度或超出指定精度。 +检查 [Decimal](../data-types/decimal.md) 值是否超出其精度或指定精度之外。 **语法** @@ -3046,11 +3178,11 @@ isDecimalOverflow(d, [p]) **参数** - `d` — 值。 [Decimal](../data-types/decimal.md)。 -- `p` — 精度。可选。如果省略,将使用第一个参数的初始精度。此参数在将数据迁移到/从其他数据库或文件时很有用。 [UInt8](/sql-reference/data-types/int-uint#integer-ranges)。 +- `p` — 精度。可选。如果省略,则使用第一个参数的初始精度。此参数在从/向另一个数据库或文件迁移数据时可能会有用。 [UInt8](/sql-reference/data-types/int-uint#integer-ranges)。 **返回值** -- `1` — Decimal 值的位数超出了其精度允许的范围, +- `1` — Decimal 值的数字超过其精度允许的数量, - `0` — Decimal 值满足指定的精度。 **示例** @@ -3088,7 +3220,7 @@ countDigits(x) - 位数。 [UInt8](/sql-reference/data-types/int-uint#integer-ranges)。 :::note -对于 `Decimal` 值,考虑它们的规模:计算结果是在基础整数类型上 `(value * scale)`。 例如: `countDigits(42) = 2`, `countDigits(42.000) = 5`, `countDigits(0.04200) = 4`。也就是说,您可以通过 `countDecimal(x) > 18` 检查 `Decimal64` 类型的超出精度。 +对于 `Decimal` 值,考虑它们的规模:在基础整数类型上计算结果,即 `(value * scale)`。例如: `countDigits(42) = 2`, `countDigits(42.000) = 5`, `countDigits(0.04200) = 4`。即您可以通过 `countDecimal(x) > 18` 来检查 `Decimal64` 的小数溢出。这是 [isDecimalOverflow](#isdecimaloverflow) 的慢变体。 ::: **示例** @@ -3124,7 +3256,7 @@ UNSUPPORTED_METHOD ## tcpPort {#tcpport} 返回此服务器监听的 [native interface](../../interfaces/tcp.md) TCP 端口号。 -如果在分布式表的上下文中执行,则此函数生成一个包含与每个分片相关的值的普通列。否则,它产生一个常量值。 +如果在分布式表的上下文中执行,则该函数生成与每个分片相关的正常列。否则,它产生一个常量值。 **语法** @@ -3156,14 +3288,14 @@ SELECT tcpPort(); └───────────┘ ``` -**另见** +**另请参见** - [tcp_port](../../operations/server-configuration-parameters/settings.md#tcp_port) ## currentProfiles {#currentprofiles} 返回当前用户的当前 [设置配置文件](../../guides/sre/user-management/index.md#settings-profiles-management) 列表。 -命令 [SET PROFILE](/sql-reference/functions/other-functions#currentprofiles) 可用于更改当前配置文件。如果没有使用命令 `SET PROFILE`,则函数将返回在当前用户定义中指定的配置文件(请参阅 [CREATE USER](/sql-reference/statements/create/user))。 +可以使用命令 [SET PROFILE](/sql-reference/functions/other-functions#currentprofiles) 来更改当前设置配置文件。如果未使用命令 `SET PROFILE`,则该函数返回当前用户定义的配置文件(请参见 [CREATE USER](/sql-reference/statements/create/user))。 **语法** @@ -3176,7 +3308,7 @@ currentProfiles() - 当前用户设置配置文件的列表。 [Array](../data-types/array.md)([String](../data-types/string.md)). ## enabledProfiles {#enabledprofiles} -返回显式和隐式分配给当前用户的设置配置文件。显式分配的配置文件与 [currentProfiles](#currentprofiles) 函数返回的相同。隐式分配的配置文件包括其他分配配置文件的父配置文件、通过授予角色分配的配置文件、通过自身设置分配的配置文件以及主默认配置文件(请参阅主服务器配置文件中的 `default_profile` 部分)。 +返回当前用户显式和隐式分配的设置配置文件。显式分配的配置文件与 [currentProfiles](#currentprofiles) 函数返回的相同。隐式分配的配置文件包括其他分配的配置文件的父配置文件、通过授予角色分配的配置文件、通过其自身设置分配的配置文件以及主要默认配置文件(请参见主服务器配置文件中的 `default_profile` 部分)。 **语法** @@ -3186,10 +3318,10 @@ enabledProfiles() **返回值** -- 启用的设置配置文件的列表。 [Array](../data-types/array.md)([String](../data-types/string.md)). +- 启用的设置配置文件列表。 [Array](../data-types/array.md)([String](../data-types/string.md)). ## defaultProfiles {#defaultprofiles} -返回在当前用户定义中指定的所有配置文件(请参阅 [CREATE USER](/sql-reference/statements/create/user) 语句)。 +返回当前用户定义的所有配置文件(请参见 [CREATE USER](/sql-reference/statements/create/user) 语句)。 **语法** @@ -3202,7 +3334,7 @@ defaultProfiles() - 默认设置配置文件的列表。 [Array](../data-types/array.md)([String](../data-types/string.md)). ## currentRoles {#currentroles} -返回分配给当前用户的角色。角色可以通过 [SET ROLE](/sql-reference/statements/set-role) 语句进行更改。如果没有使用 `SET ROLE` 语句,则函数 `currentRoles` 返回与 `defaultRoles` 相同的结果。 +返回分配给当前用户的角色。角色可以通过 [SET ROLE](/sql-reference/statements/set-role) 语句进行更改。如果未使用 `SET ROLE` 语句,则函数 `currentRoles` 返回与 `defaultRoles` 相同的结果。 **语法** @@ -3215,7 +3347,7 @@ currentRoles() - 当前用户的当前角色列表。 [Array](../data-types/array.md)([String](../data-types/string.md)). ## enabledRoles {#enabledroles} -返回当前角色和授予当前角色的角色的名称。 +返回当前角色和授予某些当前角色的角色的名称。 **语法** @@ -3225,10 +3357,10 @@ enabledRoles() **返回值** -- 当前用户的启用角色列表。 [Array](../data-types/array.md)([String](../data-types/string.md)). +- 当前用户启用的角色列表。 [Array](../data-types/array.md)([String](../data-types/string.md)). ## defaultRoles {#defaultroles} -返回当前用户登录时默认启用的角色。这些角色最初是授予当前用户的所有角色(请参阅 [GRANT](../../sql-reference/statements/grant.md#select)),但可以通过 [SET DEFAULT ROLE](/sql-reference/statements/set-role#set-default-role) 语句进行更改。 +返回当前用户登录时默认启用的角色。最初,这些角色是授予当前用户的所有角色(请参见 [GRANT](../../sql-reference/statements/grant.md#select)),但可以通过 [SET DEFAULT ROLE](/sql-reference/statements/set-role#set-default-role) 语句进行更改。 **语法** @@ -3285,9 +3417,9 @@ SELECT getServerPort('tcp_port'); ``` ## queryID {#queryid} -返回当前查询的 ID。其他查询参数可以通过 `query_id` 从 [system.query_log](../../operations/system-tables/query_log.md) 表中提取。 +返回当前查询的 ID。查询的其他参数可以通过 `query_id` 从 [system.query_log](../../operations/system-tables/query_log.md) 表中提取。 -与 [initialQueryID](#initialqueryid) 函数相比,`queryID` 在不同的分片上可能返回不同的结果(请参见示例)。 +与 [initialQueryID](#initialqueryid) 函数相比,`queryID` 在不同分片上可能返回不同的结果(请参见示例)。 **语法** @@ -3318,9 +3450,9 @@ SELECT count(DISTINCT t) FROM (SELECT queryID() AS t FROM remote('127.0.0.{1..3} ``` ## initialQueryID {#initialqueryid} -返回初始当前查询的 ID。其他查询参数可以通过 `initial_query_id` 从 [system.query_log](../../operations/system-tables/query_log.md) 表中提取。 +返回初始当前查询的 ID。查询的其他参数可以通过 `initial_query_id` 从 [system.query_log](../../operations/system-tables/query_log.md) 表中提取。 -与 [queryID](/sql-reference/functions/other-functions#queryid) 函数相比,`initialQueryID` 在不同的分片上返回相同的结果(请参见示例)。 +与 [queryID](/sql-reference/functions/other-functions#queryid) 函数相比,`initialQueryID` 在不同分片上返回相同的结果(请参见示例)。 **语法** @@ -3387,7 +3519,7 @@ SELECT count(DISTINCT t) FROM (SELECT initialQueryStartTime() AS t FROM remote(' 计算 [partition ID](../../engines/table-engines/mergetree-family/custom-partitioning-key.md)。 :::note -此函数较慢,不应对大量行调用。 +此函数较慢,不应在大量行上调用。 ::: **语法** @@ -3398,12 +3530,12 @@ partitionID(x[, y, ...]); **参数** -- `x` — 返回其分区 ID 的列。 -- `y, ...` — 返回其分区 ID 的剩余 N 列(可选)。 +- `x` — 要返回分区 ID 的列。 +- `y,...` — 剩余的 N 列(可选)。 **返回值** -- 行所属的分区 ID。 [String](../data-types/string.md)。 +- 行所属的分区 ID。 [String](../data-types/string.md). **示例** @@ -3442,8 +3574,8 @@ SELECT i, j, partitionID(i), _partition_id FROM tab ORDER BY i, j; ``` ## shardNum {#shardnum} -返回在分布式查询中处理部分数据的分片索引。索引从 `1` 开始。 -如果查询未分布,则返回常量值 `0`。 +返回处理分布式查询中数据部分的分片索引。索引从 `1` 开始。 +如果查询不是分布式的,则返回常量值 `0`。 **语法** @@ -3453,11 +3585,11 @@ shardNum() **返回值** -- 分片索引或常量 `0`。 [UInt32](../data-types/int-uint.md)。 +- 分片索引或常量 `0`。[UInt32](../data-types/int-uint.md)。 **示例** -在以下示例中,使用两个分片的配置。查询在每个分片的 [system.one](../../operations/system-tables/one.md) 表上执行。 +在以下示例中,使用了两个分片的配置。在每个分片上执行 [system.one](../../operations/system-tables/one.md) 表的查询。 查询: @@ -3476,13 +3608,14 @@ SELECT dummy, shardNum(), shardCount() FROM shard_num_example; └───────┴────────────┴──────────────┘ ``` -**另见** +**另请参阅** - [分布式表引擎](../../engines/table-engines/special/distributed.md) + ## shardCount {#shardcount} -返回分布式查询的总分片数。 -如果查询未分布,则返回常量值 `0`。 +返回分布式查询的分片总数。 +如果查询不是分布式的,则返回常量值 `0`。 **语法** @@ -3492,11 +3625,12 @@ shardCount() **返回值** -- 总分片数或 `0`。 [UInt32](../data-types/int-uint.md)。 +- 总分片数或 `0`。[UInt32](../data-types/int-uint.md)。 -**另见** +**另请参阅** + +- [shardNum()](#shardnum) 函数示例也包含 `shardCount()` 函数调用。 -- [shardNum()](#shardnum) 函数示例也包含了 `shardCount()` 函数调用。 ## getOSKernelVersion {#getoskernelversion} 返回当前操作系统内核版本的字符串。 @@ -3513,7 +3647,7 @@ getOSKernelVersion() **返回值** -- 当前操作系统内核版本。 [String](../data-types/string.md)。 +- 当前操作系统内核版本。[String](../data-types/string.md)。 **示例** @@ -3530,9 +3664,10 @@ SELECT getOSKernelVersion(); │ Linux 4.15.0-55-generic │ └─────────────────────────┘ ``` + ## zookeeperSessionUptime {#zookeepersessionuptime} -返回当前 ZooKeeper 会话的正常运行时间(以秒为单位)。 +返回当前 ZooKeeper 会话的运行时间(秒)。 **语法** @@ -3546,7 +3681,7 @@ zookeeperSessionUptime() **返回值** -- 当前 ZooKeeper 会话的正常运行时间(以秒为单位)。 [UInt32](../data-types/int-uint.md)。 +- 当前 ZooKeeper 会话的运行时间(秒)。[UInt32](../data-types/int-uint.md)。 **示例** @@ -3563,9 +3698,10 @@ SELECT zookeeperSessionUptime(); │ 286 │ └──────────────────────────┘ ``` + ## generateRandomStructure {#generaterandomstructure} -生成随机的表结构,格式为 `column1_name column1_type, column2_name column2_type, ...`。 +生成随机表结构,格式为 `column1_name column1_type, column2_name column2_type, ...`。 **语法** @@ -3575,14 +3711,14 @@ generateRandomStructure([number_of_columns, seed]) **参数** -- `number_of_columns` — 结果表结构中所需的列数。如果设置为 0 或 `Null`,则列数将在 1 到 128 之间随机选择。默认值: `Null`。 -- `seed` - 用于生成稳定结果的随机种子。如果未指定种子或设置为 `Null`,则会随机生成。 +- `number_of_columns` — 结果表结构中所需的列数。如果设置为 0 或 `Null`,列数将随机在 1 到 128 之间。默认值:`Null`。 +- `seed` - 随机种子,以生成稳定的结果。如果种子未指定或设置为 `Null`,则随机生成。 -所有参数必须是常量。 +所有参数必须为常量。 **返回值** -- 随机生成的表结构。 [String](../data-types/string.md)。 +- 随机生成的表结构。[String](../data-types/string.md)。 **示例** @@ -3628,12 +3764,13 @@ SELECT generateRandomStructure(NULL, 33) └────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ ``` -**注意**:复杂类型(Array、Tuple、Map、Nested)的最大嵌套深度限制为 16。 +**注意**: 复杂类型(Array, Tuple, Map, Nested)的最大嵌套深度限制为 16。 + +该函数可以与 [generateRandom](../../sql-reference/table-functions/generate.md) 一起使用,以生成完全随机的表。 -此函数可以与 [generateRandom](../../sql-reference/table-functions/generate.md) 一起使用以生成完全随机的表格。 ## structureToCapnProtoSchema {#structure_to_capn_proto_schema} -将 ClickHouse 表结构转换为 CapnProto 架构。 +将 ClickHouse 表结构转换为 CapnProto 模式。 **语法** @@ -3644,11 +3781,11 @@ structureToCapnProtoSchema(structure) **参数** - `structure` — 表结构,格式为 `column1_name column1_type, column2_name column2_type, ...`。 -- `root_struct_name` — CapnProto 架构中根结构的名称。默认值 - `Message`; +- `root_struct_name` — CapnProto 模式中的根结构名称。默认值 - `Message`; **返回值** -- CapnProto 架构。 [String](../data-types/string.md)。 +- CapnProto 模式。[String](../data-types/string.md)。 **示例** @@ -3729,9 +3866,10 @@ struct Root column2 @1 : UInt32; } ``` + ## structureToProtobufSchema {#structure_to_protobuf_schema} -将 ClickHouse 表结构转换为 Protobuf 架构。 +将 ClickHouse 表结构转换为 Protobuf 模式。 **语法** @@ -3742,11 +3880,11 @@ structureToProtobufSchema(structure) **参数** - `structure` — 表结构,格式为 `column1_name column1_type, column2_name column2_type, ...`。 -- `root_message_name` — Protobuf 架构中根消息的名称。默认值 - `Message`; +- `root_message_name` — Protobuf 模式中的根消息名称。默认值 - `Message`; **返回值** -- Protobuf 架构。 [String](../data-types/string.md)。 +- Protobuf 模式。[String](../data-types/string.md)。 **示例** @@ -3810,11 +3948,12 @@ message Root uint32 column2 = 2; } ``` + ## formatQuery {#formatquery} -返回给定 SQL 查询的格式化版本,可能是多行。 +返回给定 SQL 查询的格式化版本,可能是多行的。 -如果查询格式不正确,则会抛出异常。要返回 `NULL`,可以使用函数 `formatQueryOrNull()`。 +如果查询格式不正确,则抛出异常。要返回 `NULL`,可以使用函数 `formatQueryOrNull()`。 **语法** @@ -3825,16 +3964,14 @@ formatQueryOrNull(query) **参数** -- `query` - 要格式化的 SQL 查询。 [String](../data-types/string.md) +- `query` - 需要格式化的 SQL 查询。[String](../data-types/string.md) **返回值** -- 格式化的查询。 [String](../data-types/string.md)。 +- 格式化后的查询。[String](../data-types/string.md)。 **示例** -查询: - ```sql SELECT formatQuery('select a, b FRom tab WHERE a > 3 and b < 3'); ``` @@ -3853,7 +3990,7 @@ WHERE (a > 3) AND (b < 3) │ ## formatQuerySingleLine {#formatquerysingleline} -像 formatQuery() 但返回的格式化字符串不包含换行符。 +与 formatQuery() 类似,但返回的格式化字符串不包含换行符。 如果查询格式不正确,则抛出异常。要返回 `NULL`,可以使用函数 `formatQuerySingleLineOrNull()`。 @@ -3866,11 +4003,11 @@ formatQuerySingleLineOrNull(query) **参数** -- `query` - 要格式化的 SQL 查询。 [String](../data-types/string.md) +- `query` - 需要格式化的 SQL 查询。[String](../data-types/string.md) **返回值** -- 格式化后的查询。 [String](../data-types/string.md)。 +- 格式化后的查询。[String](../data-types/string.md)。 **示例** @@ -3885,6 +4022,7 @@ SELECT formatQuerySingleLine('select a, b FRom tab WHERE a > 3 and b < 3'); │ SELECT a, b FROM tab WHERE (a > 3) AND (b < 3) │ └─────────────────────────────────────────────────────────────────────────┘ ``` + ## variantElement {#variantelement} 从 `Variant` 列中提取指定类型的列。 @@ -3897,9 +4035,9 @@ variantElement(variant, type_name, [, default_value]) **参数** -- `variant` — Variant 列。 [Variant](../data-types/variant.md)。 -- `type_name` — 要提取的变体类型的名称。 [String](../data-types/string.md)。 -- `default_value` - 如果变体中没有指定类型的变体,则使用的默认值。可以是任何类型。可选。 +- `variant` — Variant 列。[Variant](../data-types/variant.md)。 +- `type_name` — 要提取的变体类型的名称。[String](../data-types/string.md)。 +- `default_value` - 如果变体没有指定类型的变体时使用的默认值。可以是任何类型。可选。 **返回值** @@ -3907,6 +4045,8 @@ variantElement(variant, type_name, [, default_value]) **示例** +查询: + ```sql CREATE TABLE test (v Variant(UInt64, String, Array(UInt64))) ENGINE = Memory; INSERT INTO test VALUES (NULL), (42), ('Hello, World!'), ([1, 2, 3]); @@ -3921,9 +4061,10 @@ SELECT v, variantElement(v, 'String'), variantElement(v, 'UInt64'), variantEleme │ [1,2,3] │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │ [1,2,3] │ └───────────────┴─────────────────────────────┴─────────────────────────────┴────────────────────────────────────┘ ``` + ## variantType {#varianttype} -返回 `Variant` 列的每行的变体类型名称。如果行包含 NULL,则返回 `'None'`。 +返回 `Variant` 列每行的变体类型名称。如果行包含 NULL,则返回 `'None'`。 **语法** @@ -3933,11 +4074,11 @@ variantType(variant) **参数** -- `variant` — Variant 列。 [Variant](../data-types/variant.md)。 +- `variant` — Variant 列。[Variant](../data-types/variant.md)。 **返回值** -- 带有每行变体类型名称的 Enum8 列。 +- 每行的变体类型名称的 Enum8 列。 **示例** @@ -3965,9 +4106,10 @@ SELECT toTypeName(variantType(v)) FROM test LIMIT 1; │ Enum8('None' = -1, 'Array(UInt64)' = 0, 'String' = 1, 'UInt64' = 2) │ └─────────────────────────────────────────────────────────────────────┘ ``` + ## minSampleSizeConversion {#minsamplesizeconversion} -计算 A/B 测试中比较两个样本的转化所需的最小样本量。 +计算比较两个样本中转化率(比例)的 A/B 测试所需的最小样本量。 **语法** @@ -3975,26 +4117,26 @@ SELECT toTypeName(variantType(v)) FROM test LIMIT 1; minSampleSizeConversion(baseline, mde, power, alpha) ``` -使用 [这篇文章](https://towardsdatascience.com/required-sample-size-for-a-b-testing-6f6608dd330a) 中描述的公式。假设处理组和对照组的大小相等。返回一个组所需的样本量(即整个实验所需的样本量是返回值的两倍)。 +使用 [这篇文章](https://towardsdatascience.com/required-sample-size-for-a-b-testing-6f6608dd330a) 中描述的公式。假设处理组和对照组的大小相等。返回一个组所需的样本大小(即整个实验所需的样本大小是返回值的两倍)。 **参数** -- `baseline` — 基线转化率。 [Float](../data-types/float.md)。 -- `mde` — 最小可检测效应 (MDE) 的百分比点(例如,对于基线转化率 0.25,MDE 0.03 意味着预期变化为 0.25 ± 0.03)。 [Float](../data-types/float.md)。 -- `power` — 测试所需的统计功效(1 - 错误类型 II 的概率)。 [Float](../data-types/float.md)。 -- `alpha` — 测试所需的显著性水平(错误类型 I 的概率)。 [Float](../data-types/float.md)。 +- `baseline` — 基线转化率。[Float](../data-types/float.md)。 +- `mde` — 最小可检测效应(MDE),单位为百分点(例如,对于基线转化率 0.25,MDE 0.03 表示期望变化为 0.25 ± 0.03)。[Float](../data-types/float.md)。 +- `power` — 测试所需的统计功效(1 - II类错误的概率)。[Float](../data-types/float.md)。 +- `alpha` — 测试所需的显著性水平(I类错误的概率)。[Float](../data-types/float.md)。 **返回值** 一个命名的 [Tuple](../data-types/tuple.md),包含 3 个元素: -- `"minimum_sample_size"` — 所需的样本量。 [Float64](../data-types/float.md)。 -- `"detect_range_lower"` — 使用返回的所需样本量无法检测到的值范围的下限(即,小于或等于 `"detect_range_lower"` 的所有值都可以使用提供的 `alpha` 和 `power` 检测)。计算为 `baseline - mde`。 [Float64](../data-types/float.md)。 -- `"detect_range_upper"` — 使用返回的所需样本量无法检测到的值范围的上限(即,大于或等于 `"detect_range_upper"` 的所有值都可以使用提供的 `alpha` 和 `power` 检测)。计算为 `baseline + mde`。 [Float64](../data-types/float.md)。 +- `"minimum_sample_size"` — 所需样本大小。[Float64](../data-types/float.md)。 +- `"detect_range_lower"` — 无法用返回的所需样本大小检测到的值范围的下界(即,所有小于或等于 `"detect_range_lower"` 的值都可以用提供的 `alpha` 和 `power` 检测到)。计算为 `baseline - mde`。[Float64](../data-types/float.md)。 +- `"detect_range_upper"` — 无法用返回的所需样本大小检测到的值范围的上界(即,所有大于或等于 `"detect_range_upper"` 的值都可以用提供的 `alpha` 和 `power` 检测到)。计算为 `baseline + mde`。[Float64](../data-types/float.md)。 **示例** -以下查询计算基线转化率为 25%、MDE 为 3%、显著性水平为 5%、期望统计功效为 80% 的 A/B 测试所需的样本量: +以下查询计算基线转化率为 25%、MDE 为 3%、显著性水平为 5%和所需统计功效为 80% 的 A/B 测试所需的样本大小: ```sql SELECT minSampleSizeConversion(0.25, 0.03, 0.80, 0.05) AS sample_size; @@ -4007,39 +4149,36 @@ SELECT minSampleSizeConversion(0.25, 0.03, 0.80, 0.05) AS sample_size; │ (3396.077603219163,0.22,0.28) │ └───────────────────────────────┘ ``` + ## minSampleSizeContinuous {#minsamplesizecontinuous} -计算 A/B 测试中比较两个样本的连续指标均值所需的最小样本量。 +计算比较两个样本中连续指标均值的 A/B 测试所需的最小样本量。 **语法** -```sql -minSampleSizeContinous(baseline, sigma, mde, power, alpha) -``` - -别名:`minSampleSizeContinous` +别名: `minSampleSizeContinous` -使用 [这篇文章](https://towardsdatascience.com/required-sample-size-for-a-b-testing-6f6608dd330a) 中描述的公式。假设处理组和对照组的大小相等。返回一个组所需的样本量(即整个实验所需的样本量是返回值的两倍)。还假设处理组和对照组中的测试指标方差相等。 +使用 [这篇文章](https://towardsdatascience.com/required-sample-size-for-a-b-testing-6f6608dd330a) 中描述的公式。假设处理组和对照组的大小相等。返回一个组所需的样本大小(即整个实验所需的样本大小是返回值的两倍)。还假设处理和对照组中测试指标的方差相等。 **参数** -- `baseline` — 指标的基线值。 [Integer](../data-types/int-uint.md) 或 [Float](../data-types/float.md)。 -- `sigma` — 指标的基线标准差。 [Integer](../data-types/int-uint.md) 或 [Float](../data-types/float.md)。 -- `mde` — 最小可检测效应 (MDE) 作为基线值的百分比(例如,对于基线值 112.25,MDE 0.03 表示预期变化为 112.25 ± 112.25*0.03)。 [Integer](../data-types/int-uint.md) 或 [Float](../data-types/float.md)。 -- `power` — 测试所需的统计功效(1 - 错误类型 II 的概率)。 [Integer](../data-types/int-uint.md) 或 [Float](../data-types/float.md)。 -- `alpha` — 测试所需的显著性水平(错误类型 I 的概率)。 [Integer](../data-types/int-uint.md) 或 [Float](../data-types/float.md)。 +- `baseline` — 指标的基线值。[Integer](../data-types/int-uint.md) 或 [Float](../data-types/float.md)。 +- `sigma` — 指标的基线标准差。[Integer](../data-types/int-uint.md) 或 [Float](../data-types/float.md)。 +- `mde` — 最小可检测效应(MDE),单位为基线值的百分比(例如,对于基线值 112.25,MDE 0.03 表示期望变化为 112.25 ± 112.25\*0.03)。[Integer](../data-types/int-uint.md) 或 [Float](../data-types/float.md)。 +- `power` — 测试所需的统计功效(1 - II类错误的概率)。[Integer](../data-types/int-uint.md) 或 [Float](../data-types/float.md)。 +- `alpha` — 测试所需的显著性水平(I类错误的概率)。[Integer](../data-types/int-uint.md) 或 [Float](../data-types/float.md)。 **返回值** 一个命名的 [Tuple](../data-types/tuple.md),包含 3 个元素: -- `"minimum_sample_size"` — 所需的样本量。 [Float64](../data-types/float.md)。 -- `"detect_range_lower"` — 使用返回的所需样本量无法检测到的值范围的下限(即,小于或等于 `"detect_range_lower"` 的所有值都可以使用提供的 `alpha` 和 `power` 检测)。计算为 `baseline * (1 - mde)`。 [Float64](../data-types/float.md)。 -- `"detect_range_upper"` — 使用返回的所需样本量无法检测到的值范围的上限(即,大于或等于 `"detect_range_upper"` 的所有值都可以使用提供的 `alpha` 和 `power` 检测)。计算为 `baseline * (1 + mde)`。 [Float64](../data-types/float.md)。 +- `"minimum_sample_size"` — 所需样本大小。[Float64](../data-types/float.md)。 +- `"detect_range_lower"` — 无法用返回的所需样本大小检测到的值范围的下界(即,所有小于或等于 `"detect_range_lower"` 的值都可以用提供的 `alpha` 和 `power` 检测到)。计算为 `baseline * (1 - mde)`。[Float64](../data-types/float.md)。 +- `"detect_range_upper"` — 无法用返回的所需样本大小检测到的值范围的上界(即,所有大于或等于 `"detect_range_upper"` 的值都可以用提供的 `alpha` 和 `power` 检测到)。计算为 `baseline * (1 + mde)`。[Float64](../data-types/float.md)。 **示例** -以下查询计算基线值为 112.25、标准差为 21.1、MDE 为 3%、显著性水平为 5% 和期望统计功效为 80% 的指标的 A/B 测试所需的样本量: +以下查询计算基线值为 112.25、标准差为 21.1、MDE 为 3%、显著性水平为 5%和所需统计功效为 80% 的 A/B 测试所需的样本大小: ```sql SELECT minSampleSizeContinous(112.25, 21.1, 0.03, 0.80, 0.05) AS sample_size; @@ -4052,9 +4191,10 @@ SELECT minSampleSizeContinous(112.25, 21.1, 0.03, 0.80, 0.05) AS sample_size; │ (616.2931945826209,108.8825,115.6175) │ └───────────────────────────────────────┘ ``` + ## connectionId {#connectionid} -检索提交当前查询的客户端的连接 ID,并以 UInt64 整数形式返回。 +检索提交当前查询的客户端的连接 ID,并将其作为 UInt64 整数返回。 **语法** @@ -4062,7 +4202,7 @@ SELECT minSampleSizeContinous(112.25, 21.1, 0.03, 0.80, 0.05) AS sample_size; connectionId() ``` -别名: `connection_id`。 +别名: `connection_id`。 **参数** @@ -4070,11 +4210,11 @@ connectionId() **返回值** -当前连接 ID。 [UInt64](../data-types/int-uint.md)。 +当前连接 ID。[UInt64](../data-types/int-uint.md)。 **实现细节** -该函数在调试场景或 MySQL 处理程序内部目的中最为有用。它是为了与 [MySQL 的 `CONNECTION_ID` 函数](https://dev.mysql.com/doc/refman/8.0/en/information-functions.html#function_connection-id) 兼容而创建的。它通常不用于生产查询。 +此函数在调试场景或 MySQL 处理程序的内部目的中最为有用。它是为了兼容 [MySQL 的 `CONNECTION_ID` 函数](https://dev.mysql.com/doc/refman/8.0/en/information-functions.html#function_connection-id) 而创建的。通常不在生产查询中使用。 **示例** @@ -4084,25 +4224,29 @@ connectionId() SELECT connectionId(); ``` +结果: + ```response 0 ``` + ## getClientHTTPHeader {#getclienthttpheader} 获取 HTTP 头的值。 -如果没有此类头,或者当前请求不是通过 HTTP 接口执行的,则该函数返回空字符串。 +如果没有这样的头,或者当前请求不是通过 HTTP 接口执行的,则该函数返回一个空字符串。 某些 HTTP 头(例如 `Authentication` 和 `X-ClickHouse-*`)是受限的。 -该函数要求启用设置 `allow_get_client_http_header`。 -出于安全原因,默认情况下不启用该设置,因为某些头,例如 `Cookie`,可能包含敏感信息。 +该函数需要启用设置 `allow_get_client_http_header`。 +出于安全原因,默认情况下未启用该设置,因为某些头(例如 `Cookie`)可能包含敏感信息。 + +对于此函数,HTTP 头是区分大小写的。 -HTTP 头对该函数是区分大小写的。 +如果该函数在分布式查询的上下文中使用,则仅在发起节点上返回非空结果。 -如果在分布式查询的上下文中使用该函数,它仅在发起节点上返回非空结果。 ## showCertificate {#showcertificate} -显示关于当前服务器的安全套接字层(SSL)证书的信息,如果已配置。有关如何配置 ClickHouse 使用 OpenSSL 证书验证连接的更多信息,请参见 [配置 SSL-TLS](/guides/sre/configuring-ssl)。 +如果当前服务器的安全套接字层 (SSL) 证书已被配置,则显示有关该证书的信息。有关如何配置 ClickHouse 使用 OpenSSL 证书验证连接的更多信息,请参见 [配置 SSL-TLS](/guides/sre/configuring-ssl)。 **语法** @@ -4112,7 +4256,7 @@ showCertificate() **返回值** -- 与配置的 SSL 证书相关的键值对映射。 [Map](../data-types/map.md)([String](../data-types/string.md), [String](../data-types/string.md))。 +- 与配置的 SSL 证书相关的键值对的映射。[Map](../data-types/map.md)([String](../data-types/string.md), [String](../data-types/string.md))。 **示例** @@ -4127,9 +4271,10 @@ SELECT showCertificate() FORMAT LineAsString; ```response {'version':'1','serial_number':'2D9071D64530052D48308473922C7ADAFA85D6C5','signature_algo':'sha256WithRSAEncryption','issuer':'/CN=marsnet.local CA','not_before':'May 7 17:01:21 2024 GMT','not_after':'May 7 17:01:21 2025 GMT','subject':'/CN=chnode1','pkey_algo':'rsaEncryption'} ``` + ## lowCardinalityIndices {#lowcardinalityindices} -返回 [LowCardinality](../data-types/lowcardinality.md) 列中值在字典中的位置。位置从 1 开始。由于 LowCardinality 列按部分具有不同的字典,因此该函数可能会在不同的部分为同一值返回不同的位置。 +返回 [LowCardinality](../data-types/lowcardinality.md) 列中值在字典中的位置。位置从 1 开始。由于 LowCardinality 每个分片有字典,因此该函数可能会返回同一值在不同分片中的不同位置。 **语法** @@ -4139,11 +4284,11 @@ lowCardinalityIndices(col) **参数** -- `col` — 低基数列。 [LowCardinality](../data-types/lowcardinality.md)。 +- `col` — 低基数列。[LowCardinality](../data-types/lowcardinality.md)。 **返回值** -- 当前部分字典中值的位置。 [UInt64](../data-types/int-uint.md)。 +- 当前分片中值在字典中的位置。[UInt64](../data-types/int-uint.md)。 **示例** @@ -4179,23 +4324,24 @@ SELECT s, lowCardinalityIndices(s) FROM test; 10. │ ef │ 1 │ └────┴──────────────────────────┘ ``` + ## lowCardinalityKeys {#lowcardinalitykeys} -返回 [LowCardinality](../data-types/lowcardinality.md) 列的字典值。如果块的大小小于或大于字典大小,则结果将被截断或使用默认值扩展。由于 LowCardinality 列按部分具有不同的字典,因此该函数可能会在不同的部分返回不同的字典值。 +返回 [LowCardinality](../data-types/lowcardinality.md) 列的字典值。如果数据块小于或大于字典大小,结果将被截断或使用默认值扩展。由于 LowCardinality 每个分片有字典,因此该函数可能在不同分片中返回不同的字典值。 **语法** ```sql -lowCardinalityIndices(col) +lowCardinalityKeys(col) ``` **参数** -- `col` — 低基数列。 [LowCardinality](../data-types/lowcardinality.md)。 +- `col` — 低基数列。[LowCardinality](../data-types/lowcardinality.md)。 **返回值** -- 字典键。 [UInt64](../data-types/int-uint.md)。 +- 字典键。[UInt64](../data-types/int-uint.md)。 **示例** @@ -4231,9 +4377,10 @@ SELECT s, lowCardinalityKeys(s) FROM test; 10. │ df │ │ └────┴───────────────────────┘ ``` + ## displayName {#displayname} -返回 [config](/operations/configuration-files) 中的 `display_name` 值,如果未设置,则返回服务器的完全合格域名 (FQDN)。 +返回 [config](/operations/configuration-files) 中的 `display_name` 值,或者如果未设置则返回服务器的完全限定域名 (FQDN)。 **语法** @@ -4243,11 +4390,11 @@ displayName() **返回值** -- 从 config 中的 `display_name` 的值,如果未设置,则返回服务器的 FQDN。 [String](../data-types/string.md)。 +- 从配置中获取的 `display_name` 值或服务器 FQDN(如果未设置)。[String](../data-types/string.md)。 **示例** -可以在 `config.xml` 中设置 `display_name`。例如,用 `display_name` 配置为 'production' 的服务器: +`display_name` 可以在 `config.xml` 中设置。以配置为 'production' 的服务器为例: ```xml `。注释必须以 `-->` 结束。不允许嵌套注释。 -注意: 像 `` 和 `` 这样的结构在 HTML 中不是有效的注释,但它们会被其他规则跳过。 -2. CDATA 被逐字粘贴。注意: CDATA 是 XML/XHTML 特有的,并在“尽力而为”的基础上进行处理。 -3. `script` 和 `style` 元素以及其所有内容均被移除。注意: 假定闭合标签不能出现在内容中。例如,在 JS 字符串字面值中必须像 `"<\/script>"` 一样转义。 -注意: 在 `script` 或 `style` 中可能存在注释和 CDATA - 在这种情况下,不搜索闭合标签在 CDATA 之内。例如: `]]>`。但它们仍然在注释里面被搜索。有时变得复杂: ` var y = "-->"; alert(x + y);`。 -注意: `script` 和 `style` 可以是 XML 名称空间的名称 - 那样它们不会像通常的 `script` 或 `style` 元素那样处理。例如: `Hello`。 -注意: 闭合标签名称后可能有空白: ``,但闭合标签前不能有空白: `< / script>`。 -4. 跳过没有内部内容的其他标签或类似标签的元素。例如: `.`。 -注意: 预计此 HTML 是非法的: ``。 -注意: 它还会跳过类似标签的东西: `<>`, `` 等。 -注意: 没有结尾的标签会跳到输入的末尾: `world
`,`Helloworld` - 在 HTML 中没有空白,但该函数插入了它。还要考虑: `Hello

world

`,`Hello
world`。这种行为对于数据分析是合理的,例如将 HTML 转换为词袋。 -7. 另请注意,正确处理空白需要支持 `
` 和 CSS `display` 和 `white-space` 属性。
+1. 跳过注释。例如: ``。注释必须以 `-->` 结束。禁止嵌套注释。
+注意:像 `` 和 `` 的构造在 HTML 中不是有效的注释,但会被其他规则跳过。
+2. CDATA 被逐字粘贴。注意:CDATA 是 XML/XHTML 特定的,并以“尽力而为”的方式处理。
+3. `script` 和 `style` 元素及其内容被移除。注意:假设闭合标签不能出现在内容内部。例如,在 JS 字符串字面量中必须像 `"<\/script>"` 一样转义。
+注意: `script` 或 `style` 内部可能有注释和 CDATA - 那么在 CDATA 内部不搜索闭合标签。例如: `]]>`。但它们仍然会在注释中被搜索。有时变得复杂: ` var y = "-->"; alert(x + y);`
+注意: `script` 和 `style` 可能是 XML 命名空间的名称 - 然后它们不会像通常的 `script` 或 `style` 元素那样处理。例如: `Hello`。
+注意:闭合标签名称后可以有空白: ``,但不能在前面: `< / script>`。
+4. 其他标签或类标签的元素在没有内部内容的情况下被跳过。例如: `.`
+注意:预期此 HTML 是非法的: ``
+注意:它还跳过一些类似标签的东西: `<>`、 `` 等等。
+注意:没有结束的标签被跳过直到输入结束: `world
`, `Helloworld` - 在 HTML 中没有空白,但该函数插入了空白。还要考虑: `Hello

world

`, `Hello
world`。这种行为对于数据分析是合理的,例如,将 HTML 转换为单词袋。 +7. 另外注意,正确处理空白需要支持 `
` 和 CSS `display` 和 `white-space` 属性。
 
 **语法**
 
@@ -1970,17 +1958,17 @@ extractTextFromHTML(x)
 
 **参数**
 
-- `x` — 输入文本。 [String](../data-types/string.md).
+- `x` — 输入文本。 [String](../data-types/string.md)。
 
 **返回值**
 
-- 提取的文本。 [String](../data-types/string.md).
+- 提取的文本。 [String](../data-types/string.md)。
 
 **示例**
 
-第一个示例包含多个标签和一个注释,并且还显示了空白处理。
-第二个示例显示了 CDATA 和 `script` 标签处理。
-在第三个示例中,从通过 [url](../../sql-reference/table-functions/url.md) 函数接收到的完整 HTML 响应中提取文本。
+第一个示例包含几个标签和一个注释,并且还展示了空白处理。
+第二个示例展示了 CDATA 和 script 标签处理。
+在第三个示例中,文本是从通过 [url](../../sql-reference/table-functions/url.md) 函数接收到的完整 HTML 响应中提取的。
 
 ```sql
 SELECT extractTextFromHTML(' 

A text withtags.

'); @@ -1997,9 +1985,9 @@ Do Nothing for 2 Minutes 2:00   ``` ## ascii {#ascii} -返回字符串 `s` 的第一个字符的 ASCII 代码点(作为 Int32)。 +返回字符串 `s` 第一个字符的 ASCII 码点 (以 Int32 表示)。 -如果 `s` 为空,结果为 0。如果第一个字符不是 ASCII 字符或不属于 UTF-16 的 Latin-1 补充范围,则结果未定义。 +如果 `s` 为空,结果为 0。如果第一个字符不是 ASCII 字符或不在 UTF-16 的 Latin-1 supplements 范围内,结果是未定义的。 **语法** @@ -2027,7 +2015,7 @@ soundex(val) **示例** ```sql -select soundex('aksel'); +SELECT soundex('aksel'); ``` 结果: @@ -2040,7 +2028,7 @@ select soundex('aksel'); ## punycodeEncode {#punycodeencode} 返回字符串的 [Punycode](https://en.wikipedia.org/wiki/Punycode) 表示。 -该字符串必须为 UTF8 编码,否则行为未定义。 +字符串必须是 UTF8 编码的,否则行为是未定义的。 **语法** @@ -2059,7 +2047,7 @@ punycodeEncode(val) **示例** ```sql -select punycodeEncode('München'); +SELECT punycodeEncode('München'); ``` 结果: @@ -2071,8 +2059,8 @@ select punycodeEncode('München'); ``` ## punycodeDecode {#punycodedecode} -返回一个 [Punycode](https://en.wikipedia.org/wiki/Punycode) 编码字符串的 UTF8 编码明文。 -如果未给出有效的 Punycode 编码字符串,则引发异常。 +返回 [Punycode](https://en.wikipedia.org/wiki/Punycode) 编码字符串的 UTF8 编码明文。 +如果没有提供有效的 Punycode 编码字符串,则会抛出异常。 **语法** @@ -2091,7 +2079,7 @@ punycodeEncode(val) **示例** ```sql -select punycodeDecode('Mnchen-3ya'); +SELECT punycodeDecode('Mnchen-3ya'); ``` 结果: @@ -2103,12 +2091,12 @@ select punycodeDecode('Mnchen-3ya'); ``` ## tryPunycodeDecode {#trypunycodedecode} -像 `punycodeDecode` 但如果未给出有效的 Punycode 编码字符串则返回空字符串。 +像 `punycodeDecode`,但如果没有提供有效的 Punycode 编码字符串,则返回空字符串。 ## idnaEncode {#idnaencode} -返回根据 [国际化域名应用](https://en.wikipedia.org/wiki/Internationalized_domain_name#Internationalizing_Domain_Names_in_Applications) (IDNA) 机制的域名的 ASCII 表示 (ToASCII 算法)。 -输入字符串必须是 UTF 编码的并且可翻译为 ASCII 字符串,否则引发异常。 -注意: 不执行百分比解码或修剪制表符、空格或控制字符。 +返回域名的 ASCII 表示 (ToASCII 算法),根据 [国际化域名应用](https://en.wikipedia.org/wiki/Internationalized_domain_name#Internationalizing_Domain_Names_in_Applications) (IDNA) 机制。 +输入字符串必须是 UTF 编码,并且可转换为 ASCII 字符串,否则将抛出异常。 +注意:不进行百分比解码或去除制表符、空格或控制字符。 **语法** @@ -2127,7 +2115,7 @@ idnaEncode(val) **示例** ```sql -select idnaEncode('straße.münchen.de'); +SELECT idnaEncode('straße.münchen.de'); ``` 结果: @@ -2139,12 +2127,12 @@ select idnaEncode('straße.münchen.de'); ``` ## tryIdnaEncode {#tryidnaencode} -像 `idnaEncode` 但在发生错误时返回空字符串而不是引发异常。 +像 `idnaEncode` 但在发生错误时返回空字符串而不是抛出异常。 ## idnaDecode {#idnadecode} -返回根据 [国际化域名应用](https://en.wikipedia.org/wiki/Internationalized_domain_name#Internationalizing_Domain_Names_in_Applications) (IDNA) 机制的域名的 Unicode (UTF-8) 表示 (ToUnicode 算法)。 -如果发生错误(例如因为输入无效),则返回输入字符串。 -请注意,`idnaEncode()` 和 `idnaDecode()` 的重复应用不一定返回原始字符串,因为会进行大小写规范化。 +返回域名的 Unicode (UTF-8) 表示 (ToUnicode 算法),根据 [国际化域名应用](https://en.wikipedia.org/wiki/Internationalized_domain_name#Internationalizing_Domain_Names_in_Applications) (IDNA) 机制。 +在发生错误时(例如,因为输入无效),返回输入字符串。 +请注意,`idnaEncode()` 和 `idnaDecode()` 的重复应用不一定返回原始字符串,原因是大小写归一化。 **语法** @@ -2163,7 +2151,7 @@ idnaDecode(val) **示例** ```sql -select idnaDecode('xn--strae-oqa.xn--mnchen-3ya.de'); +SELECT idnaDecode('xn--strae-oqa.xn--mnchen-3ya.de'); ``` 结果: @@ -2197,7 +2185,7 @@ SELECT byteHammingDistance('karolin', 'kathrin'); └───────────────────────────────────────────┘ ``` -别名: `mismatches` +别名: `mismatches` ## stringJaccardIndex {#stringjaccardindex} 计算两个字节字符串之间的 [Jaccard 相似度指数](https://en.wikipedia.org/wiki/Jaccard_index)。 @@ -2223,7 +2211,7 @@ SELECT stringJaccardIndex('clickhouse', 'mouse'); ``` ## stringJaccardIndexUTF8 {#stringjaccardindexutf8} -与 [stringJaccardIndex](#stringjaccardindex) 类似,但适用于 UTF8 编码字符串。 +像 [stringJaccardIndex](#stringjaccardindex) 但针对 UTF8 编码字符串。 ## editDistance {#editdistance} 计算两个字节字符串之间的 [编辑距离](https://en.wikipedia.org/wiki/Edit_distance)。 @@ -2248,7 +2236,7 @@ SELECT editDistance('clickhouse', 'mouse'); └─────────────────────────────────────┘ ``` -别名: `levenshteinDistance` +别名: `levenshteinDistance` ## editDistanceUTF8 {#editdistanceutf8} 计算两个 UTF8 字符串之间的 [编辑距离](https://en.wikipedia.org/wiki/Edit_distance)。 @@ -2273,7 +2261,7 @@ SELECT editDistanceUTF8('我是谁', '我是我'); └─────────────────────────────────────┘ ``` -别名: `levenshteinDistanceUTF8` +别名: `levenshteinDistanceUTF8` ## damerauLevenshteinDistance {#dameraulevenshteindistance} 计算两个字节字符串之间的 [Damerau-Levenshtein 距离](https://en.wikipedia.org/wiki/Damerau%E2%80%93Levenshtein_distance)。 @@ -2345,10 +2333,10 @@ SELECT jaroWinklerSimilarity('clickhouse', 'click'); ``` ## initcap {#initcap} -将每个单词的首字母转换为大写,其余字母转换为小写。单词是由非字母数字字符分隔的字母数字字符的序列。 +将每个单词的首字母转换为大写,其余字母转换为小写。单词是由非字母数字字符分隔的字母数字字符序列。 :::note -因为 `initCap` 仅将每个单词的首字母转换为大写,因此您可能会观察到对于包含撇号或大写字母的单词的意外行为。例如: +因为 `initCap` 仅将每个单词的首字母转换为大写,可能会对带有撇号或大写字母的单词产生意想不到的行为。例如: ```sql SELECT initCap('mother''s daughter'), initCap('joe McAdam'); @@ -2362,7 +2350,7 @@ SELECT initCap('mother''s daughter'), initCap('joe McAdam'); └───────────────────────────────┴───────────────────────┘ ``` -这是已知的行为,目前没有计划对此进行修复。 +这是一个已知行为,目前没有计划进行修复。 ::: **语法** @@ -2373,11 +2361,11 @@ initcap(val) **参数** -- `val` — 输入值。 [String](../data-types/string.md). +- `val` — 输入值。 [String](../data-types/string.md)。 **返回值** -- `val` 中每个单词的首字母转换为大写。 [String](../data-types/string.md). +- `val` 的每个单词首字母转换为大写。 [String](../data-types/string.md)。 **示例** @@ -2396,12 +2384,12 @@ SELECT initcap('building for fast'); ``` ## initcapUTF8 {#initcaputf8} -与 [initcap](#initcap) 类似,`initcapUTF8` 将每个单词的首字母转换为大写,其余字母转换为小写。假设字符串包含有效的 UTF-8 编码的文本。 -如果这个假设被违反,则不抛出异常,结果未定义。 +像 [initcap](#initcap),`initcapUTF8` 将每个单词的首字母转换为大写,其余字母转换为小写。假设字符串包含有效的 UTF-8 编码文本。 +如果这个假设被违反,不会抛出异常,并且结果是未定义的。 :::note -此函数不检测语言,例如对于土耳其语,结果可能不完全正确(i/İ 与 i/I)。 -如果 UTF-8 字节序列的长度对于一个代码点的大小写不同,则该代码点的结果可能不正确。 +此函数不检测语言,例如对于土耳其语,结果可能不完全正确 (i/İ vs. i/I)。 +如果 UTF-8 字节序列的长度在大写和小写的代码点之间不同,则该代码点的结果可能不正确。 ::: **语法** @@ -2412,11 +2400,11 @@ initcapUTF8(val) **参数** -- `val` — 输入值。 [String](../data-types/string.md). +- `val` — 输入值。 [String](../data-types/string.md)。 **返回值** -- `val` 中每个单词的首字母转换为大写。 [String](../data-types/string.md). +- `val` 的每个单词首字母转换为大写。 [String](../data-types/string.md)。 **示例** @@ -2435,7 +2423,7 @@ SELECT initcapUTF8('не тормозит'); ``` ## firstLine {#firstline} -返回多行字符串中的第一行。 +返回多行字符串的第一行。 **语法** @@ -2449,12 +2437,12 @@ firstLine(val) **返回值** -- 输入值的第一行或如果没有行分隔符则返回整个值。 [String](../data-types/string.md) +- 输入值的第一行,如果没有换行符则返回整个值。 [String](../data-types/string.md) **示例** ```sql -select firstLine('foo\nbar\nbaz'); +SELECT firstLine('foo\nbar\nbaz'); ``` 结果: @@ -2466,7 +2454,7 @@ select firstLine('foo\nbar\nbaz'); ``` ## stringCompare {#stringcompare} -在字典顺序中比较两个字符串。 +对两个字符串进行字典顺序比较。 **语法** @@ -2476,28 +2464,28 @@ stringCompare(string1, string2[, str1_off, string2_offset, num_bytes]); **参数** -- `string1` — 要比较的第一个字符串。 [String](../data-types/string.md) -- `string2` - 要比较的第二个字符串。[String](../data-types/string.md) -- `string1_offset` — 在 `string1` 中用于开始比较的位置(零基)。可选,正数。 -- `string2_offset` — 在 `string2` 中用于开始比较的位置(零基)。可选,正数。 -- `num_bytes` — 在两个字符串中要比较的最大字节数。如果 `string_offset` + `num_bytes` 超出输入字符串的末尾,则 `num_bytes` 将相应减少。 +- `string1` — 第一个要比较的字符串。 [String](../data-types/string.md) +- `string2` - 第二个要比较的字符串。[String](../data-types/string.md) +- `string1_offset` — 在 `string1` 中进行比较的起始位置(零基)。可选,正数。 +- `string2_offset` — 在 `string2` 中进行比较的起始位置(零基索引)。可选,正数。 +- `num_bytes` — 要比较的最大字节数。如果 `string_offset` + `num_bytes` 超过输入字符串的末尾,则 `num_bytes` 将相应减少。 **返回值** -- -1 — 如果 `string1`[`string1_offset`: `string1_offset` + `num_bytes`] < `string2`[`string2_offset`:`string2_offset` + `num_bytes`] 且 `string1_offset` < len(`string1`) 且 `string2_offset` < len(`string2`)。 -如果 `string1_offset` >= len(`string1`) 且 `string2_offset` < len(`string2`)。 -- 0 — 如果 `string1`[`string1_offset`: `string1_offset` + `num_bytes`] = `string2`[`string2_offset`:`string2_offset` + `num_bytes`] 且 `string1_offset` < len(`string1`) 且 `string2_offset` < len(`string2`)。 -如果 `string1_offset` >= len(`string1`) 且 `string2_offset` >= len(`string2`)。 -- 1 — 如果 `string1`[`string1_offset`: `string1_offset` + `num_bytes`] > `string2`[`string2_offset`:`string2_offset` + `num_bytes`] 且 `string1_offset` < len(`string1`) 且 `string2_offset` < len(`string2`)。 -如果 `string1_offset` < len(`string1`) 且 `string2_offset` >= len(`string2`)。 +- -1 — 如果 `string1`[`string1_offset`: `string1_offset` + `num_bytes`] < `string2`[`string2_offset`:`string2_offset` + `num_bytes`] 并且 `string1_offset` < len(`string1`) 和 `string2_offset` < len(`string2`)。 +如果 `string1_offset` >= len(`string1`) 并且 `string2_offset` < len(`string2`)。 +- 0 — 如果 `string1`[`string1_offset`: `string1_offset` + `num_bytes`] = `string2`[`string2_offset`:`string2_offset` + `num_bytes`] 并且 `string1_offset` < len(`string1`) 和 `string2_offset` < len(`string2`)。 +如果 `string1_offset` >= len(`string1`) 并且 `string2_offset` >= len(`string2`)。 +- 1 — 如果 `string1`[`string1_offset`: `string1_offset` + `num_bytes`] > `string2`[`string2_offset`:`string2_offset` + `num_bytes`] 并且 `string1_offset` < len(`string1`) 和 `string2_offset` < len(`string2`)。 +如果 `string1_offset` < len(`string1`) 并且 `string2_offset` >= len(`string2`)。 **示例** ```sql SELECT - stringCompare('alice', 'bob', 0, 0, 3) as result1, - stringCompare('alice', 'alicia', 0, 0, 3) as result2, - stringCompare('bob', 'alice', 0, 0, 3) as result3 + stringCompare('alice', 'bob', 0, 0, 3) AS result1, + stringCompare('alice', 'alicia', 0, 0, 3) AS result2, + stringCompare('bob', 'alice', 0, 0, 3) AS result3 ``` 结果: ```result @@ -2508,9 +2496,9 @@ SELECT ```sql SELECT - stringCompare('alice', 'alicia') as result2, - stringCompare('alice', 'alice') as result1, - stringCompare('bob', 'alice') as result3 + stringCompare('alice', 'alicia') AS result2, + stringCompare('alice', 'alice') AS result1, + stringCompare('bob', 'alice') AS result3 ``` 结果: ```result @@ -2520,8 +2508,8 @@ SELECT ``` ## sparseGrams {#sparsegrams} -查找给定字符串中所有长度至少为 `n` 的子字符串, -其中子字符串的边界的 (n-1)-grams 的哈希值严格大于子字符串内部的任何 (n-1)-gram 的哈希值。 +寻找给定字符串中所有长度至少为 `n` 的子字符串, +其中子字符串边界处的 (n-1)-grams 的哈希值严格大于任何 (n-1)-gram 内部的哈希值。 使用 [crc32](./string-functions.md#crc32) 作为哈希函数。 **语法** @@ -2533,12 +2521,12 @@ sparseGrams(s[, min_ngram_length]); **参数** - `s` — 输入字符串。 [String](../data-types/string.md) -- `min_ngram_length` — 提取的 ngram 的最小长度。默认值和最小值为 3。 -- `max_ngram_length` — 提取的 ngram 的最大长度。默认值为 100。应不小于 'min_ngram_length'。 +- `min_ngram_length` — 提取的 ngram 的最小长度。默认和最小值为 3。 +- `max_ngram_length` — 提取的 ngram 的最大长度。默认值为 100。应不小于 'min_ngram_length' **返回值** -- 选定子字符串的数组。 [Array](../data-types/array.md)([String](../data-types/string.md)). +- 选定子字符串的数组。 [Array](../data-types/array.md)([String](../data-types/string.md))。 **示例** @@ -2553,10 +2541,10 @@ SELECT sparseGrams('alice', 3) AS result ``` ## sparseGramsUTF8 {#sparsegramsutf8} -查找给定字符串中所有长度至少为 `n` 的子字符串, -其中子字符串的边界的 (n-1)-grams 的哈希值严格大于子字符串内部的任何 (n-1)-gram 的哈希值。 +寻找给定字符串中所有长度至少为 `n` 的子字符串, +其中子字符串边界处的 (n-1)-grams 的哈希值严格大于任何 (n-1)-gram 内部的哈希值。 使用 [crc32](./string-functions.md#crc32) 作为哈希函数。 -期望 UTF-8 字符串,如果无效的 UTF-8 序列则抛出异常。 +期望 UTF-8 字符串,在无效 UTF-8 序列的情况下抛出异常。 **语法** @@ -2567,12 +2555,12 @@ sparseGramsUTF8(s[, min_ngram_length]); **参数** - `s` — 输入字符串。 [String](../data-types/string.md) -- `min_ngram_length` — 提取的 ngram 的最小长度。默认值和最小值为 3。 -- `max_ngram_length` — 提取的 ngram 的最大长度。默认值为 100。应不小于 'min_ngram_length'。 +- `min_ngram_length` — 提取的 ngram 的最小长度。默认和最小值为 3。 +- `max_ngram_length` — 提取的 ngram 的最大长度。默认值为 100。应不小于 'min_ngram_length' **返回值** -- 选定子字符串的数组。 [Array](../data-types/array.md)([String](../data-types/string.md)). +- 选定子字符串的数组。 [Array](../data-types/array.md)([String](../data-types/string.md))。 **示例** @@ -2587,8 +2575,8 @@ SELECT sparseGramsUTF8('алиса', 3) AS result ``` ## sparseGramsHashes {#sparsegramshashes} -查找给定字符串中所有长度至少为 `n` 的子字符串的哈希值, -其中子字符串的边界的 (n-1)-grams 的哈希值严格大于子字符串内部的任何 (n-1)-gram 的哈希值。 +寻找给定字符串中所有长度至少为 `n` 的子字符串, +其中子字符串边界处的 (n-1)-grams 的哈希值严格大于任何 (n-1)-gram 内部的哈希值。 使用 [crc32](./string-functions.md#crc32) 作为哈希函数。 **语法** @@ -2600,12 +2588,12 @@ sparseGramsHashes(s[, min_ngram_length]); **参数** - `s` — 输入字符串。 [String](../data-types/string.md) -- `min_ngram_length` — 提取的 ngram 的最小长度。默认值和最小值为 3。 -- `max_ngram_length` — 提取的 ngram 的最大长度。默认值为 100。应不小于 'min_ngram_length'。 +- `min_ngram_length` — 提取的 ngram 的最小长度。默认和最小值为 3。 +- `max_ngram_length` — 提取的 ngram 的最大长度。默认值为 100。应不小于 'min_ngram_length' **返回值** -- 选定子字符串 crc32-c 哈希的数组。 [Array](../data-types/array.md)([UInt32](../data-types/int-uint.md)). +- 选定子字符串 crc32-c 哈希的数组。 [Array](../data-types/array.md)([UInt32](../data-types/int-uint.md))。 **示例** @@ -2620,10 +2608,10 @@ SELECT sparseGramsHashes('alice', 3) AS result ``` ## sparseGramsHashesUTF8 {#sparsegramshashesutf8} -查找给定字符串中所有长度至少为 `n` 的子字符串的哈希值, -其中子字符串的边界的 (n-1)-grams 的哈希值严格大于子字符串内部的任何 (n-1)-gram 的哈希值。 +寻找给定字符串中所有长度至少为 `n` 的子字符串, +其中子字符串边界处的 (n-1)-grams 的哈希值严格大于任何 (n-1)-gram 内部的哈希值。 使用 [crc32](./string-functions.md#crc32) 作为哈希函数。 -期望 UTF-8 字符串,如果无效的 UTF-8 序列则抛出异常。 +期望 UTF-8 字符串,在无效 UTF-8 序列的情况下抛出异常。 **语法** @@ -2634,12 +2622,12 @@ sparseGramsUTF8(s[, min_ngram_length]); **参数** - `s` — 输入字符串。 [String](../data-types/string.md) -- `min_ngram_length` — 提取的 ngram 的最小长度。默认值和最小值为 3。 -- `max_ngram_length` — 提取的 ngram 的最大长度。默认值为 100。应不小于 'min_ngram_length'。 +- `min_ngram_length` — 提取的 ngram 的最小长度。默认和最小值为 3。 +- `max_ngram_length` — 提取的 ngram 的最大长度。默认值为 100。应不小于 'min_ngram_length' **返回值** -- 选定子字符串 crc32-c 哈希的数组。 [Array](../data-types/array.md)([UInt32](../data-types/int-uint.md)). +- 选定子字符串 crc32-c 哈希的数组。 [Array](../data-types/array.md)([UInt32](../data-types/int-uint.md))。 **示例** @@ -2664,11 +2652,11 @@ stringBytesUniq(s) **参数** -- `s` — 要分析的字符串。 [String](../data-types/string.md). +- `s` — 要分析的字符串。 [String](../data-types/string.md)。 **返回值** -- 字符串中不同字节的数量。 [UInt16](../data-types/int-uint.md). +- 字符串中不同字节的数量。 [UInt16](../data-types/int-uint.md)。 **示例** @@ -2695,11 +2683,11 @@ stringBytesEntropy(s) **参数** -- `s` — 要分析的字符串。 [String](../data-types/string.md). +- `s` — 要分析的字符串。 [String](../data-types/string.md)。 **返回值** -- 字符串中字节分布的香农熵。 [Float64](../data-types/float.md). +- 字符串中字节分布的香农熵。 [Float64](../data-types/float.md)。 **示例** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/string-functions.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/string-functions.md.hash index 9ecf0832ced..546e0343f39 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/string-functions.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/string-functions.md.hash @@ -1 +1 @@ -0f35c8630c9f228e +af638ded915ca0e0 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/string-replace-functions.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/string-replace-functions.md index 075d30fdd77..5c32aad67c6 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/string-replace-functions.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/string-replace-functions.md @@ -1,19 +1,19 @@ --- -'description': '字符串替换的函数的文档' +'description': '字符串中替换的函数的文档' 'sidebar_label': '字符串替换' -'sidebar_position': 150 'slug': '/sql-reference/functions/string-replace-functions' -'title': '字符串替换的函数' +'title': '在字符串中替换的函数' +'doc_type': 'reference' --- # 字符串替换函数 -[一般字符串函数](string-functions.md) 和 [字符串搜索函数](string-search-functions.md) 分别进行描述。 +[常规字符串函数](string-functions.md) 和 [字符串搜索函数](string-search-functions.md) 被单独描述。 ## overlay {#overlay} -用另一个字符串 `replace` 替换字符串 `input` 的一部分,从 1 开始的索引 `offset` 开始。 +用另一字符串 `replace` 替换字符串 `input` 的一部分,从 1 基索引 `offset` 开始。 **语法** @@ -25,12 +25,12 @@ overlay(s, replace, offset[, length]) - `s`: 字符串类型 [String](../data-types/string.md)。 - `replace`: 字符串类型 [String](../data-types/string.md)。 -- `offset`: 整数类型 [Int](../data-types/int-uint.md)(以 1 为基准)。如果 `offset` 为负,则从字符串 `s` 的末尾计数。 -- `length`: 可选。整数类型 [Int](../data-types/int-uint.md)。`length` 指定要替换的输入字符串 `s` 中片段的长度。如果未指定 `length`,从 `s` 中移除的字节数等于 `replace` 的长度;否则将移除 `length` 字节。 +- `offset`: 整数类型 [Int](../data-types/int-uint.md) (1-based)。如果 `offset` 为负,则从字符串 `s` 的末尾开始计数。 +- `length`: 可选。整数类型 [Int](../data-types/int-uint.md)。`length` 指定要替换的输入字符串 `s` 中片段的长度。如果未指定 `length`,则从 `s` 中移除的字节数等于 `replace` 的长度;否则移除 `length` 字节。 **返回值** -- 一个 [String](../data-types/string.md) 数据类型的值。 +- 一个 [String](../data-types/string.md) 数据类型值。 **示例** @@ -60,9 +60,10 @@ SELECT overlay('My father is from Mexico.', 'dad', 4, 6) AS res; ## overlayUTF8 {#overlayutf8} -用另一个字符串 `replace` 替换字符串 `input` 的一部分,从 1 开始的索引 `offset` 开始。 +用另一字符串 `replace` 替换字符串 `input` 的一部分,从 1 基索引 `offset` 开始。 -假设字符串包含有效的 UTF-8 编码文本。如果违反此假设,则不会抛出异常,结果是未定义的。 +假设字符串包含有效的 UTF-8 编码文本。 +如果这一假设被违反,不会抛出异常,结果是未定义的。 **语法** @@ -74,12 +75,12 @@ overlayUTF8(s, replace, offset[, length]) - `s`: 字符串类型 [String](../data-types/string.md)。 - `replace`: 字符串类型 [String](../data-types/string.md)。 -- `offset`: 整数类型 [Int](../data-types/int-uint.md)(以 1 为基准)。如果 `offset` 为负,则从输入字符串 `s` 的末尾计数。 -- `length`: 可选。整数类型 [Int](../data-types/int-uint.md)。`length` 指定要替换的输入字符串 `s` 中片段的长度。如果未指定 `length`,从 `s` 中移除的字符数等于 `replace` 的长度;否则将移除 `length` 个字符。 +- `offset`: 整数类型 [Int](../data-types/int-uint.md) (1-based)。如果 `offset` 为负,则从输入字符串 `s` 的末尾开始计数。 +- `length`: 可选。整数类型 [Int](../data-types/int-uint.md)。`length` 指定要替换的输入字符串 `s` 中片段的长度。如果未指定 `length`,则从 `s` 中移除的字符数等于 `replace` 的长度;否则移除 `length` 字符。 **返回值** -- 一个 [String](../data-types/string.md) 数据类型的值。 +- 一个 [String](../data-types/string.md) 数据类型值。 **示例** @@ -97,7 +98,7 @@ SELECT overlay('Mein Vater ist aus Österreich.', 'der Türkei', 20) AS res; ## replaceOne {#replaceone} -替换 `haystack` 中的子字符串 `pattern` 的第一个出现为 `replacement` 字符串。 +替换 `haystack` 中子字符串 `pattern` 的第一次出现为 `replacement` 字符串。 **语法** @@ -107,7 +108,7 @@ replaceOne(haystack, pattern, replacement) ## replaceAll {#replaceall} -将 `haystack` 中所有出现的子字符串 `pattern` 替换为 `replacement` 字符串。 +替换 `haystack` 中子字符串 `pattern` 的所有出现为 `replacement` 字符串。 **语法** @@ -119,13 +120,13 @@ replaceAll(haystack, pattern, replacement) ## replaceRegexpOne {#replaceregexpone} -将符合正则表达式 `pattern`(使用 [re2 语法](https://github.com/google/re2/wiki/Syntax))匹配的子字符串在 `haystack` 中的第一个出现替换为 `replacement` 字符串。 +替换 `haystack` 中符合正则表达式 `pattern` (使用 [re2 语法](https://github.com/google/re2/wiki/Syntax))的子字符串第一次出现为 `replacement` 字符串。 -`replacement` 可以包含替换 `\0-\9`。 -替换 `\1-\9` 对应于第 1 到第 9 个捕获组(子匹配),替换 `\0` 对应于整个匹配。 +`replacement` 可以包含替换项 `\0-\9`。 +替换项 `\1-\9` 对应于第 1 到第 9 个捕获组(子匹配),替换项 `\0` 对应于整个匹配。 -要在 `pattern` 或 `replacement` 字符串中使用逐字 `\` 字符,请使用 `\` 进行转义。 -还要注意字符串字面量需要额外的转义。 +要在 `pattern` 或 `replacement` 字符串中使用逐字的 `\` 字符,需要用 `\` 转义。 +同时请记住,字符串字面量需要额外转义。 **语法** @@ -158,7 +159,7 @@ FORMAT TabSeparated 2014-03-23 03/23/2014 ``` -将字符串复制十次: +将一个字符串复制十次: ```sql SELECT replaceRegexpOne('Hello, World!', '.*', '\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0') AS res @@ -174,7 +175,7 @@ SELECT replaceRegexpOne('Hello, World!', '.*', '\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0') ## replaceRegexpAll {#replaceregexpall} -类似于 `replaceRegexpOne`,但替换模式的所有出现。 +与 `replaceRegexpOne` 类似,但替换所有模式出现。 别名:`REGEXP_REPLACE`。 @@ -192,7 +193,7 @@ SELECT replaceRegexpAll('Hello, World!', '.', '\\0\\0') AS res └────────────────────────────┘ ``` -作为例外,如果正则表达式在空子字符串上工作,则替换不得多于一次,例如: +作为例外,如果正则表达式作用于空子字符串,则替换不会执行超过一次,例如: ```sql SELECT replaceRegexpAll('Hello, World!', '^', 'here: ') AS res @@ -208,9 +209,9 @@ SELECT replaceRegexpAll('Hello, World!', '^', 'here: ') AS res ## regexpQuoteMeta {#regexpquotemeta} -在这些在正则表达式中具有特殊含义的字符之前添加反斜杠: `\0`, `\\`, `|`, `(`, `)`, `^`, `$`, `.`, `[`, `]`, `?`, `*`, `+`, `{`, `:`, `-`。 +在这些在正则表达式中具有特殊含义的字符前添加反斜杠: `\0`, `\\`, `|`, `(`, `)`, `^`, `$`, `.`, `[`, `]`, `?`, `*`, `+`, `{`, `:`, `-`。 -此实现与 re2::RE2::QuoteMeta 略有不同。它将零字节转义为 `\0` 而不是 `\x00`,并且仅转义所需的字符。 +该实现与 re2::RE2::QuoteMeta 略有不同。它将零字节转义为 `\0` 而不是 `\x00`,并且仅转义所需字符。 有关更多信息,请参见 [RE2](https://github.com/google/re2/blob/master/re2/re2.cc#L473) **语法** @@ -221,7 +222,7 @@ regexpQuoteMeta(s) ## format {#format} -使用参数中列出的值(字符串、整数等)格式化 `pattern` 字符串,类似于 Python 中的格式化。模式字符串可以包含用大括号 `{}` 包围的替换字段。未包含在大括号中的任何内容都被视为文字文本,并原样复制到输出中。文字大括号字符可以通过两个大括号进行转义:`{{ '{{' }}` 和 `{{ '}}' }}`。字段名称可以是数字(从零开始)或者为空(则隐式赋予单调增加的数字)。 +使用参数中列出的值(字符串、整数等)格式化 `pattern` 字符串,这类似于 Python 中的格式化。模式字符串可以包含用大括号 `{}` 括起来的替换字段。任何不包含在大括号中的内容都被视为文本字面量并逐字复制到输出中。字面量大括号字符可以通过使用两个大括号进行转义:`{{ '{{' }}` 和 `{{ '}}' }}`。字段名称可以是数字(从零开始)或空(则它们被隐含地赋予单调递增的数字)。 **语法** @@ -255,11 +256,11 @@ SELECT format('{} {}', 'Hello', 'World') ## translate {#translate} -使用 `from` 和 `to` 字符串定义的字符一对一映射来替换字符串 `s` 中的字符。 +使用由 `from` 和 `to` 字符串定义的一对一字符映射替换字符串 `s` 中的字符。 `from` 和 `to` 必须是常量 ASCII 字符串。 -如果 `from` 和 `to` 的大小相等,则 `s` 中的 `first` 的第 1 个字符的每个出现都被替换为 `to` 的第 1 个字符,`first` 的第 2 个字符在 `s` 中的出现被替换为 `to` 的第 2 个字符,依此类推。 -如果 `from` 包含的字符比 `to` 多,则从 `s` 中删除 `from` 末尾所有没有对应字符在 `to` 中的字符。 -`s` 中的非 ASCII 字符不会被此函数修改。 +如果 `from` 和 `to` 的大小相等,`s` 中 `first` 的第一个字符的每个出现都将被替换为 `to` 的第一个字符,`s` 中 `first` 的第二个字符的每个出现都将被替换为 `to` 的第二个字符,依此类推。 +如果 `from` 中的字符比 `to` 中的字符多,则 `from` 末尾没有对应字符的所有字符将在 `s` 中被删除。 +`s` 中的非 ASCII 字符不受该函数的影响。 **语法** @@ -281,7 +282,7 @@ SELECT translate('Hello, World!', 'delor', 'DELOR') AS res └───────────────┘ ``` -`from` 和 `to` 参数具有不同的长度: +`from` 和 `to` 参数长度不同: ```sql SELECT translate('clickhouse', 'clickhouse', 'CLICK') AS res @@ -297,7 +298,7 @@ SELECT translate('clickhouse', 'clickhouse', 'CLICK') AS res ## translateUTF8 {#translateutf8} -类似于 [translate](#translate),但假设 `s`、`from` 和 `to` 是 UTF-8 编码字符串。 +与 [translate](#translate) 相似,但假设 `s`、`from` 和 `to` 是 UTF-8 编码的字符串。 **语法** @@ -313,7 +314,7 @@ translateUTF8(s, from, to) **返回值** -- 一个 [String](../data-types/string.md) 数据类型的值。 +- 一个 [String](../data-types/string.md) 数据类型值。 **示例** @@ -331,7 +332,7 @@ SELECT translateUTF8('Münchener Straße', 'üß', 'us') AS res; ## printf {#printf} -`printf` 函数格式化给定字符串,与 C++ 中的 printf 函数类似,使用参数中列出的值(字符串、整数、浮点数等)。格式字符串可以包含以 `%` 字符开头的格式说明符。未包含在 `%` 和后随格式说明符中的任何内容都被视为文字文本,并原样复制到输出中。文字 `%` 字符可以通过 `%%` 进行转义。 +`printf` 函数将给定字符串格式化为参数中列出的值(字符串、整数、浮点等),类似于 C++ 中的 printf 函数。格式字符串可以包含以 `%` 字符开头的格式说明符。任何不包含在 `%` 和后续格式说明符中的内容都被视为文本字面量并逐字复制到输出中。字面量 `%` 字符可以通过 `%%` 进行转义。 **语法** @@ -344,9 +345,8 @@ printf(format, arg1, arg2, ...) 查询: ```sql -select printf('%%%s %s %d', 'Hello', 'World', 2024); +SELECT printf('%%%s %s %d', 'Hello', 'World', 2024); ``` - ```response ┌─printf('%%%s %s %d', 'Hello', 'World', 2024)─┐ │ %Hello World 2024 │ diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/string-replace-functions.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/string-replace-functions.md.hash index 7b134f5142c..7eb996c9e75 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/string-replace-functions.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/string-replace-functions.md.hash @@ -1 +1 @@ -1e7384ffa253a29e +16f8b022f284c498 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/string-search-functions.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/string-search-functions.md index 199994e690e..22d4a5cb7ba 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/string-search-functions.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/string-search-functions.md @@ -1,23 +1,24 @@ --- -'description': '字符串搜索的函数的文档' +'description': '查找字符串的函数的文档' 'sidebar_label': '字符串搜索' -'sidebar_position': 160 'slug': '/sql-reference/functions/string-search-functions' -'title': '字符串搜索的函数' +'title': '查找字符串的函数' +'doc_type': 'reference' --- + # 字符串搜索函数 -本节中的所有函数默认区分大小写进行搜索。通常,通过单独的函数变体提供不区分大小写的搜索。 +本节中的所有函数默认为区分大小写搜索。区分大小写的搜索通常由单独的函数变体提供。 :::note -不区分大小写的搜索遵循英语的大小写规则。例如,英语中大写的 `i` 是 `I`,而在土耳其语中则是 `İ` — 其他语言的结果可能出乎意料。 +不区分大小写的搜索遵循英语的大小写规则。例如,在英语中大写的 `i` 是 `I`,而在土耳其语中是 `İ` - 非英语语言的结果可能会意外。 ::: -本节中的函数还假设被搜索的字符串(在本节中称为 `haystack`)和搜索字符串(在本节中称为 `needle`)是单字节编码文本。如果这一假设被违反,则不会抛出异常,结果是未定义的。使用 UTF-8 编码字符串的搜索通常通过单独的函数变体提供。同样,如果使用了 UTF-8 函数变体并且输入字符串不是 UTF-8 编码文本,则不会抛出异常,结果是未定义的。请注意,不执行自动 Unicode 规范化,然而,您可以使用 [normalizeUTF8*()](https://clickhouse.com../functions/string-functions/) 函数来实现。 +本节中的函数还假设被搜索的字符串(在本节中称为 `haystack`)和搜索字符串(在本节中称为 `needle`)为单字节编码文本。如果违反此假设,则不会抛出异常,结果是未定义的。使用 UTF-8 编码字符串的搜索通常由单独的函数变体提供。同样,如果使用了 UTF-8 函数变体且输入字符串不是 UTF-8 编码文本,则不会抛出异常,结果是未定义的。请注意,没有进行自动 Unicode 规范化,但您可以使用 [normalizeUTF8*()](https://clickhouse.com../functions/string-functions/) 函数来实现这一点。 -[通用字符串函数](string-functions.md) 和 [替换字符串的函数](string-replace-functions.md) 被单独描述。 +[通用字符串函数](string-functions.md) 和 [字符串替换函数](string-replace-functions.md) 被单独描述。 ## position {#position} 返回子字符串 `needle` 在字符串 `haystack` 中的位置(以字节为单位,从 1 开始)。 @@ -33,22 +34,22 @@ position(haystack, needle[, start_pos]) **参数** -- `haystack` — 进行搜索的字符串。[String](../data-types/string.md) 或 [Enum](../data-types/string.md)。 -- `needle` — 要搜索的子字符串。[String](../data-types/string.md)。 -- `start_pos` – 在 `haystack` 中开始搜索的位置(以 1 为基数)。[UInt](../data-types/int-uint.md)。可选。 +- `haystack` — 执行搜索的字符串。 [String](../data-types/string.md) 或 [Enum](../data-types/string.md)。 +- `needle` — 要搜索的子字符串。 [String](../data-types/string.md)。 +- `start_pos` – 在 `haystack` 中开始搜索的位置(基于 1)。 [UInt](../data-types/int-uint.md)。 可选。 **返回值** -- 如果找到子字符串,则返回以字节为单位、从 1 开始的起始位置。[UInt64](../data-types/int-uint.md)。 -- 如果未找到子字符串,则返回 0。[UInt64](../data-types/int-uint.md)。 +- 如果找到子字符串,则返回以字节为单位且从 1 开始的起始位置。 [UInt64](../data-types/int-uint.md)。 +- 如果未找到子字符串,则返回 0。 [UInt64](../data-types/int-uint.md)。 -如果子字符串 `needle` 为空,适用以下规则: +如果子字符串 `needle` 为空,则适用以下规则: - 如果未指定 `start_pos`:返回 `1` - 如果 `start_pos = 0`:返回 `1` - 如果 `start_pos >= 1` 且 `start_pos <= length(haystack) + 1`:返回 `start_pos` - 否则:返回 `0` -相同的规则也适用于函数 `locate`、`positionCaseInsensitive`、`positionUTF8` 和 `positionCaseInsensitiveUTF8`。 +相同规则也适用于函数 `locate`、`positionCaseInsensitive`、`positionUTF8` 和 `positionCaseInsensitiveUTF8`。 **示例** @@ -66,7 +67,7 @@ SELECT position('Hello, world!', '!'); └────────────────────────────────┘ ``` -带 `start_pos` 参数的示例: +带有 `start_pos` 参数的示例: 查询: @@ -84,7 +85,7 @@ SELECT └───────────────────────────────────┴───────────────────────────────────┘ ``` -使用 `needle IN haystack` 语法的示例: +`needle IN haystack` 语法的示例: 查询: @@ -124,11 +125,11 @@ SELECT ``` ## locate {#locate} -像 [position](#position) 但交换了参数 `haystack` 和 `locate`。 +类似于 [position](#position),但参数 `haystack` 和 `locate` 交换位置。 此函数的行为取决于 ClickHouse 的版本: -- 在版本 < v24.3 中,`locate` 是 `position` 函数的别名,并接受参数 `(haystack, needle[, start_pos])`。 -- 在版本 >= 24.3 中,`locate` 是一个独立的函数(为了更好的与 MySQL 兼容),接受参数 `(needle, haystack[, start_pos])`。可以使用设置 [function_locate_has_mysql_compatible_argument_order = false](/operations/settings/settings#function_locate_has_mysql_compatible_argument_order) 恢复先前的行为。 +- 在版本 < v24.3 中,`locate` 是函数 `position` 的别名,接受参数 `(haystack, needle[, start_pos])`。 +- 在版本 >= 24.3 中,`locate` 是一个独立的函数(为了更好地与 MySQL 兼容),接受参数 `(needle, haystack[, start_pos])`。可以使用设置 [function_locate_has_mysql_compatible_argument_order = false](/operations/settings/settings#function_locate_has_mysql_compatible_argument_order) 恢复之前的行为。 **语法** @@ -137,7 +138,7 @@ locate(needle, haystack[, start_pos]) ``` ## positionCaseInsensitive {#positioncaseinsensitive} -[例如](#position) 的不区分大小写变体。 +[Position](#position) 的不区分大小写版本。 **示例** @@ -156,11 +157,11 @@ SELECT positionCaseInsensitive('Hello, world!', 'hello'); ``` ## positionUTF8 {#positionutf8} -类似于 [position](#position),但假设 `haystack` 和 `needle` 是 UTF-8 编码的字符串。 +类似于 [position](#position),但假定 `haystack` 和 `needle` 是 UTF-8 编码的字符串。 **示例** -函数 `positionUTF8` 正确将字符 `ö`(由两个点表示)计算为单个 Unicode 代码点: +函数 `positionUTF8` 正确将字符 `ö`(由两个点表示)计为一个 Unicode 代码点: 查询: @@ -177,13 +178,13 @@ SELECT positionUTF8('Motörhead', 'r'); ``` ## positionCaseInsensitiveUTF8 {#positioncaseinsensitiveutf8} -类似于 [positionUTF8](#positionutf8),但不区分大小写地搜索。 +类似于 [positionUTF8](#positionutf8),但不区分大小写搜索。 ## multiSearchAllPositions {#multisearchallpositions} -类似于 [position](#position),但返回一个数组,其中包含多个 `needle` 子字符串在 `haystack` 字符串中的位置(以字节为单位,从 1 开始)。 +类似于 [position](#position),但返回 `haystack` 字符串中多个 `needle` 子字符串的位置数组(以字节为单位,从 1 开始)。 :::note -所有 `multiSearch*()` 函数仅支持最多 28 个针。 +所有 `multiSearch*()` 函数最多仅支持 28 个 `needle`。 ::: **语法** @@ -194,12 +195,12 @@ multiSearchAllPositions(haystack, [needle1, needle2, ..., needleN]) **参数** -- `haystack` — 进行搜索的字符串。[String](../data-types/string.md)。 -- `needle` — 要搜索的子字符串。[Array](../data-types/array.md)。 +- `haystack` — 执行搜索的字符串。 [String](../data-types/string.md)。 +- `needle` — 要搜索的子字符串。 [Array](../data-types/array.md)。 **返回值** -- 如果找到子字符串,则返回起始位置的数组,以字节为单位,从 1 开始。 +- 如果找到子字符串,则返回以字节为单位且从 1 开始的起始位置的数组。 - 如果未找到子字符串,则返回 0。 **示例** @@ -219,7 +220,7 @@ SELECT multiSearchAllPositions('Hello, World!', ['hello', '!', 'world']); ``` ## multiSearchAllPositionsCaseInsensitive {#multisearchallpositionscaseinsensitive} -像 [multiSearchAllPositions](#multisearchallpositions),但忽略大小写。 +类似于 [multiSearchAllPositions](#multisearchallpositions),但忽略大小写。 **语法** @@ -229,12 +230,12 @@ multiSearchAllPositionsCaseInsensitive(haystack, [needle1, needle2, ..., needleN **参数** -- `haystack` — 进行搜索的字符串。[String](../data-types/string.md)。 -- `needle` — 要搜索的子字符串。[Array](../data-types/array.md)。 +- `haystack` — 执行搜索的字符串。 [String](../data-types/string.md)。 +- `needle` — 要搜索的子字符串。 [Array](../data-types/array.md)。 **返回值** -- 如果找到子字符串,则返回起始位置的数组,以字节为单位,从 1 开始。 +- 如果找到子字符串,则返回以字节为单位且从 1 开始的起始位置的数组。 - 如果未找到子字符串,则返回 0。 **示例** @@ -252,7 +253,7 @@ SELECT multiSearchAllPositionsCaseInsensitive('ClickHouse',['c','h']); ``` ## multiSearchAllPositionsUTF8 {#multisearchallpositionsutf8} -类似于 [multiSearchAllPositions](#multisearchallpositions),但假设 `haystack` 和 `needle` 子字符串是 UTF-8 编码的字符串。 +类似于 [multiSearchAllPositions](#multisearchallpositions),但假定 `haystack` 和 `needle` 子字符串是 UTF-8 编码的字符串。 **语法** @@ -262,12 +263,12 @@ multiSearchAllPositionsUTF8(haystack, [needle1, needle2, ..., needleN]) **参数** -- `haystack` — 进行搜索的 UTF-8 编码字符串。[String](../data-types/string.md)。 -- `needle` — 要搜索的 UTF-8 编码子字符串。[Array](../data-types/array.md)。 +- `haystack` — UTF-8 编码的字符串,在其中执行搜索。 [String](../data-types/string.md)。 +- `needle` — UTF-8 编码的子字符串。 [Array](../data-types/array.md)。 **返回值** -- 如果找到子字符串,则返回起始位置的数组,以字节为单位,从 1 开始。 +- 如果找到子字符串,则返回以字节为单位且从 1 开始的起始位置的数组。 - 如果未找到子字符串,则返回 0。 **示例** @@ -297,12 +298,12 @@ multiSearchAllPositionsCaseInsensitiveUTF8(haystack, [needle1, needle2, ..., nee **参数** -- `haystack` — 进行搜索的 UTF-8 编码字符串。[String](../data-types/string.md)。 -- `needle` — 要搜索的 UTF-8 编码子字符串。[Array](../data-types/array.md)。 +- `haystack` — UTF-8 编码的字符串,在其中执行搜索。 [String](../data-types/string.md)。 +- `needle` — UTF-8 编码的子字符串。 [Array](../data-types/array.md)。 **返回值** -- 如果找到子字符串,则返回起始位置的数组,以字节为单位,从 1 开始。 +- 如果找到子字符串,则返回以字节为单位且从 1 开始的起始位置的数组。 - 如果未找到子字符串,则返回 0。 **示例** @@ -322,9 +323,9 @@ SELECT multiSearchAllPositionsCaseInsensitiveUTF8('\x43\x6c\x69\x63\x6b\x48\x6f\ ``` ## multiSearchFirstPosition {#multisearchfirstposition} -像 [`position`](#position),但返回 `haystack` 字符串中匹配多个 `needle` 字符串的最左边偏移量。 +类似于 [`position`](#position),但返回在 `haystack` 字符串中匹配任意多个 `needle` 字符串的最左偏移量。 -函数 [`multiSearchFirstPositionCaseInsensitive`](#multisearchfirstpositioncaseinsensitive)、[`multiSearchFirstPositionUTF8`](#multisearchfirstpositionutf8) 和 [`multiSearchFirstPositionCaseInsensitiveUTF8`](#multisearchfirstpositioncaseinsensitiveutf8) 提供此函数的不区分大小写和/或 UTF-8 变体。 +函数 [`multiSearchFirstPositionCaseInsensitive`](#multisearchfirstpositioncaseinsensitive)、[`multiSearchFirstPositionUTF8`](#multisearchfirstpositionutf8) 和 [`multiSearchFirstPositionCaseInsensitiveUTF8`](#multisearchfirstpositioncaseinsensitiveutf8) 提供了此函数的不区分大小写和/或 UTF-8 变体。 **语法** @@ -334,12 +335,12 @@ multiSearchFirstPosition(haystack, [needle1, needle2, ..., needleN]) **参数** -- `haystack` — 进行搜索的字符串。[String](../data-types/string.md)。 -- `needle` — 要搜索的子字符串。[Array](../data-types/array.md)。 +- `haystack` — 执行搜索的字符串。 [String](../data-types/string.md)。 +- `needle` — 要搜索的子字符串。 [Array](../data-types/array.md)。 **返回值** -- 找到匹配多个 `needle` 字符串的 `haystack` 字符串的最左边偏移量。 +- 在 `haystack` 字符串中匹配任意多个 `needle` 字符串的最左偏移量。 - 如果没有匹配,则返回 0。 **示例** @@ -357,7 +358,7 @@ SELECT multiSearchFirstPosition('Hello World',['llo', 'Wor', 'ld']); ``` ## multiSearchFirstPositionCaseInsensitive {#multisearchfirstpositioncaseinsensitive} -像 [`multiSearchFirstPosition`](#multisearchfirstposition) 但忽略大小写。 +类似于 [`multiSearchFirstPosition`](#multisearchfirstposition),但忽略大小写。 **语法** @@ -367,12 +368,12 @@ multiSearchFirstPositionCaseInsensitive(haystack, [needle1, needle2, ..., needle **参数** -- `haystack` — 进行搜索的字符串。[String](../data-types/string.md)。 -- `needle` — 要搜索的子字符串数组。[Array](../data-types/array.md)。 +- `haystack` — 执行搜索的字符串。 [String](../data-types/string.md)。 +- `needle` — 要搜索的子字符串。 [Array](../data-types/array.md)。 **返回值** -- 找到匹配多个 `needle` 字符串的 `haystack` 字符串的最左边偏移量。 +- 在 `haystack` 字符串中匹配任意多个 `needle` 字符串的最左偏移量。 - 如果没有匹配,则返回 0。 **示例** @@ -390,7 +391,7 @@ SELECT multiSearchFirstPositionCaseInsensitive('HELLO WORLD',['wor', 'ld', 'ello ``` ## multiSearchFirstPositionUTF8 {#multisearchfirstpositionutf8} -像 [`multiSearchFirstPosition`](#multisearchfirstposition),但假设 `haystack` 和 `needle` 是 UTF-8 字符串。 +类似于 [`multiSearchFirstPosition`](#multisearchfirstposition),但假定 `haystack` 和 `needle` 是 UTF-8 字符串。 **语法** @@ -400,17 +401,17 @@ multiSearchFirstPositionUTF8(haystack, [needle1, needle2, ..., needleN]) **参数** -- `haystack` — 进行搜索的 UTF-8 字符串。[String](../data-types/string.md)。 -- `needle` — 要搜索的 UTF-8 字符串数组。[Array](../data-types/array.md)。 +- `haystack` — UTF-8 字符串,在其中执行搜索。 [String](../data-types/string.md)。 +- `needle` — 要搜索的 UTF-8 子字符串。 [Array](../data-types/array.md)。 **返回值** -- 找到匹配多个 `needle` 字符串的 `haystack` 字符串的最左边偏移量。 +- 在 `haystack` 字符串中匹配任意多个 `needle` 字符串的最左偏移量。 - 如果没有匹配,则返回 0。 **示例** -查找 UTF-8 字符串 `hello world` 中与给定针匹配的最左边的偏移量。 +在 UTF-8 字符串 `hello world` 中,查找任意给定 `needle` 的最左偏移量。 查询: @@ -425,7 +426,7 @@ SELECT multiSearchFirstPositionUTF8('\x68\x65\x6c\x6c\x6f\x20\x77\x6f\x72\x6c\x6 ``` ## multiSearchFirstPositionCaseInsensitiveUTF8 {#multisearchfirstpositioncaseinsensitiveutf8} -像 [`multiSearchFirstPosition`](#multisearchfirstposition),但假设 `haystack` 和 `needle` 是 UTF-8 字符串并忽略大小写。 +类似于 [`multiSearchFirstPosition`](#multisearchfirstposition),但假定 `haystack` 和 `needle` 是 UTF-8 字符串并忽略大小写。 **语法** @@ -435,17 +436,17 @@ multiSearchFirstPositionCaseInsensitiveUTF8(haystack, [needle1, needle2, ..., ne **参数** -- `haystack` — 进行搜索的 UTF-8 字符串。[String](../data-types/string.md)。 -- `needle` — 要搜索的 UTF-8 字符串数组。[Array](../data-types/array.md)。 +- `haystack` — UTF-8 字符串,在其中执行搜索。 [String](../data-types/string.md)。 +- `needle` — 要搜索的 UTF-8 子字符串。 [Array](../data-types/array.md)。 **返回值** -- 找到匹配多个 `needle` 字符串的 `haystack` 字符串的最左边偏移量,忽略大小写。 +- 在 `haystack` 字符串中匹配任意多个 `needle` 字符串的最左偏移量,忽略大小写。 - 如果没有匹配,则返回 0。 **示例** -查找 UTF-8 字符串 `HELLO WORLD` 中与给定针匹配的最左边的偏移量。 +在 UTF-8 字符串 `HELLO WORLD` 中,查找任意给定 `needle` 的最左偏移量。 查询: @@ -460,24 +461,23 @@ SELECT multiSearchFirstPositionCaseInsensitiveUTF8('\x48\x45\x4c\x4c\x4f\x20\x57 ``` ## multiSearchFirstIndex {#multisearchfirstindex} -返回字符串 `haystack` 中最左边找到的 needlei 的索引 `i`(从 1 开始),否则返回 0。 +返回字符串 `haystack` 中找到的最左 `needle`i 的索引 `i`(从 1 开始),否则返回 0。 -函数 [`multiSearchFirstIndexCaseInsensitive`](#multisearchfirstindexcaseinsensitive)、[`multiSearchFirstIndexUTF8`](#multisearchfirstindexutf8) 和 [`multiSearchFirstIndexCaseInsensitiveUTF8`](#multisearchfirstindexcaseinsensitiveutf8) 提供不区分大小写和/或 UTF-8 变体。 +函数 [`multiSearchFirstIndexCaseInsensitive`](#multisearchfirstindexcaseinsensitive)、[`multiSearchFirstIndexUTF8`](#multisearchfirstindexutf8) 和 [`multiSearchFirstIndexCaseInsensitiveUTF8`](#multisearchfirstindexcaseinsensitiveutf8) 提供了不区分大小写和/或 UTF-8 的变体。 **语法** ```sql multiSearchFirstIndex(haystack, [needle1, needle2, ..., needleN]) ``` - **参数** -- `haystack` — 进行搜索的字符串。[String](../data-types/string.md)。 -- `needle` — 要搜索的子字符串数组。[Array](../data-types/array.md)。 +- `haystack` — 执行搜索的字符串。 [String](../data-types/string.md)。 +- `needle` — 要搜索的子字符串。 [Array](../data-types/array.md)。 **返回值** -- 找到的最左边的 needle 的索引(从 1 开始)。如果没有找到,则返回 0。[UInt8](../data-types/int-uint.md)。 +- 找到的最左 `needle` 的索引(从 1 开始)。否则,如果没有匹配,则返回 0。 [UInt8](../data-types/int-uint.md)。 **示例** @@ -494,7 +494,7 @@ SELECT multiSearchFirstIndex('Hello World',['World','Hello']); ``` ## multiSearchFirstIndexCaseInsensitive {#multisearchfirstindexcaseinsensitive} -返回字符串 `haystack` 中最左边找到的 needlei 的索引 `i`(从 1 开始),否则返回 0。忽略大小写。 +返回字符串 `haystack` 中找到的最左 `needle`i 的索引 `i`(从 1 开始),否则返回 0。忽略大小写。 **语法** @@ -504,12 +504,12 @@ multiSearchFirstIndexCaseInsensitive(haystack, [needle1, needle2, ..., needleN]) **参数** -- `haystack` — 进行搜索的字符串。[String](../data-types/string.md)。 -- `needle` — 要搜索的子字符串数组。[Array](../data-types/array.md)。 +- `haystack` — 执行搜索的字符串。 [String](../data-types/string.md)。 +- `needle` — 要搜索的子字符串。 [Array](../data-types/array.md)。 **返回值** -- 找到的最左边的 needle 的索引(从 1 开始)。如果没有找到,则返回 0。[UInt8](../data-types/int-uint.md)。 +- 找到的最左 `needle` 的索引(从 1 开始)。否则,如果没有匹配,则返回 0。 [UInt8](../data-types/int-uint.md)。 **示例** @@ -526,7 +526,7 @@ SELECT multiSearchFirstIndexCaseInsensitive('hElLo WoRlD',['World','Hello']); ``` ## multiSearchFirstIndexUTF8 {#multisearchfirstindexutf8} -返回字符串 `haystack` 中最左边找到的 needlei 的索引 `i`(从 1 开始),否则返回 0。假设 `haystack` 和 `needle` 是 UTF-8 编码的字符串。 +返回字符串 `haystack` 中找到的最左 `needle`i 的索引 `i`(从 1 开始),否则返回 0。假定 `haystack` 和 `needle` 是 UTF-8 编码的字符串。 **语法** @@ -536,16 +536,16 @@ multiSearchFirstIndexUTF8(haystack, [needle1, needle2, ..., needleN]) **参数** -- `haystack` — 进行搜索的 UTF-8 字符串。[String](../data-types/string.md)。 -- `needle` — 要搜索的 UTF-8 字符串数组。[Array](../data-types/array.md)。 +- `haystack` — UTF-8 字符串,在其中执行搜索。 [String](../data-types/string.md)。 +- `needle` — 要搜索的 UTF-8 字符串数组。 [Array](../data-types/array.md) **返回值** -- 找到的最左边的 needle 的索引(从 1 开始)。如果没有找到,则返回 0。[UInt8](../data-types/int-uint.md)。 +- 找到的最左 `needle` 的索引(从 1 开始)。否则,如果没有匹配,则返回 0。 [UInt8](../data-types/int-uint.md)。 **示例** -给定 `Hello World` 作为 UTF-8 字符串,找到 UTF-8 字符串 `Hello` 和 `World` 的第一个索引。 +给定 `Hello World` 作为 UTF-8 字符串,查找 UTF-8 字符串 `Hello` 和 `World` 的第一个索引。 查询: @@ -560,7 +560,7 @@ SELECT multiSearchFirstIndexUTF8('\x48\x65\x6c\x6c\x6f\x20\x57\x6f\x72\x6c\x64', ``` ## multiSearchFirstIndexCaseInsensitiveUTF8 {#multisearchfirstindexcaseinsensitiveutf8} -返回字符串 `haystack` 中最左边找到的 needlei 的索引 `i`(从 1 开始),否则返回 0。假设 `haystack` 和 `needle` 是 UTF-8 编码的字符串。忽略大小写。 +返回字符串 `haystack` 中找到的最左 `needle`i 的索引 `i`(从 1 开始),否则返回 0。假定 `haystack` 和 `needle` 是 UTF-8 编码的字符串。忽略大小写。 **语法** @@ -570,16 +570,16 @@ multiSearchFirstIndexCaseInsensitiveUTF8(haystack, [needle1, needle2, ..., needl **参数** -- `haystack` — 进行搜索的 UTF-8 字符串。[String](../data-types/string.md)。 -- `needle` — 要搜索的 UTF-8 字符串数组。[Array](../data-types/array.md)。 +- `haystack` — UTF-8 字符串,在其中执行搜索。 [String](../data-types/string.md)。 +- `needle` — 要搜索的 UTF-8 字符串数组。 [Array](../data-types/array.md)。 **返回值** -- 找到的最左边的 needle 的索引(从 1 开始)。如果没有找到,则返回 0。[UInt8](../data-types/int-uint.md)。 +- 找到的最左 `needle` 的索引(从 1 开始)。否则,如果没有匹配,则返回 0。 [UInt8](../data-types/int-uint.md)。 **示例** -给定 `HELLO WORLD` 作为 UTF-8 字符串,找到 UTF-8 字符串 `hello` 和 `world` 的第一个索引。 +给定 `HELLO WORLD` 作为 UTF-8 字符串,查找 UTF-8 字符串 `hello` 和 `world` 的第一个索引。 查询: @@ -594,9 +594,9 @@ SELECT multiSearchFirstIndexCaseInsensitiveUTF8('\x48\x45\x4c\x4c\x4f\x20\x57\x4 ``` ## multiSearchAny {#multisearchany} -如果至少有一个字符串 needlei 与字符串 `haystack` 匹配,则返回 1,否则返回 0。 +如果至少有一个字符串 `needle`i 与字符串 `haystack` 匹配,则返回 1,否则返回 0。 -函数 [`multiSearchAnyCaseInsensitive`](#multisearchanycaseinsensitive)、[`multiSearchAnyUTF8`](#multisearchanyutf8) 和 [`multiSearchAnyCaseInsensitiveUTF8`](#multisearchanycaseinsensitiveutf8) 提供不区分大小写和/或 UTF-8 变体。 +函数 [`multiSearchAnyCaseInsensitive`](#multisearchanycaseinsensitive)、[`multiSearchAnyUTF8`](#multisearchanyutf8) 和 [`multiSearchAnyCaseInsensitiveUTF8`](#multisearchanycaseinsensitiveutf8) 提供了不区分大小写和/或 UTF-8 的变体。 **语法** @@ -606,13 +606,13 @@ multiSearchAny(haystack, [needle1, needle2, ..., needleN]) **参数** -- `haystack` — 进行搜索的字符串。[String](../data-types/string.md)。 -- `needle` — 要搜索的子字符串数组。[Array](../data-types/array.md)。 +- `haystack` — 执行搜索的字符串。 [String](../data-types/string.md)。 +- `needle` — 要搜索的子字符串。 [Array](../data-types/array.md)。 **返回值** -- 1,如果至少有一个匹配。 -- 0,如果没有至少一个匹配。 +- 如果至少有一个匹配,则返回 1。 +- 如果没有匹配,则返回 0。 **示例** @@ -629,7 +629,7 @@ SELECT multiSearchAny('ClickHouse',['C','H']); ``` ## multiSearchAnyCaseInsensitive {#multisearchanycaseinsensitive} -像 [multiSearchAny](#multisearchany),但忽略大小写。 +类似于 [multiSearchAny](#multisearchany),但忽略大小写。 **语法** @@ -639,13 +639,13 @@ multiSearchAnyCaseInsensitive(haystack, [needle1, needle2, ..., needleN]) **参数** -- `haystack` — 进行搜索的字符串。[String](../data-types/string.md)。 -- `needle` — 要搜索的子字符串数组。[Array](../data-types/array.md)。 +- `haystack` — 执行搜索的字符串。 [String](../data-types/string.md)。 +- `needle` — 要搜索的子字符串。 [Array](../data-types/array.md) **返回值** -- 1,如果至少有一个不区分大小写的匹配。 -- 0,如果没有至少一个不区分大小写的匹配。 +- 如果至少有一个不区分大小写的匹配,则返回 1。 +- 如果没有至少一个不区分大小写的匹配,则返回 0。 **示例** @@ -662,7 +662,7 @@ SELECT multiSearchAnyCaseInsensitive('ClickHouse',['c','h']); ``` ## multiSearchAnyUTF8 {#multisearchanyutf8} -类似于 [multiSearchAny](#multisearchany),但假设 `haystack` 和 `needle` 子字符串是 UTF-8 编码的字符串。 +类似于 [multiSearchAny](#multisearchany),但假定 `haystack` 和 `needle` 子字符串是 UTF-8 编码的字符串。 **语法** @@ -672,17 +672,17 @@ multiSearchAnyUTF8(haystack, [needle1, needle2, ..., needleN]) **参数** -- `haystack` — 进行搜索的 UTF-8 字符串。[String](../data-types/string.md)。 -- `needle` — 要搜索的 UTF-8 子字符串数组。[Array](../data-types/array.md)。 +- `haystack` — UTF-8 字符串,在其中执行搜索。 [String](../data-types/string.md)。 +- `needle` — 要搜索的 UTF-8 子字符串。 [Array](../data-types/array.md)。 **返回值** -- 1,如果至少有一个匹配。 -- 0,如果没有至少一个匹配。 +- 如果至少有一个匹配,则返回 1。 +- 如果没有至少一个匹配,则返回 0。 **示例** -给定 `ClickHouse` 作为 UTF-8 字符串,检查单词中是否包含字母 `C`('\x43')或 `H`('\x48')。 +给定 `ClickHouse` 作为 UTF-8 字符串,检查单词中是否有字母 `C`(`\x43`)或 `H`(`\x48`)。 查询: @@ -707,13 +707,13 @@ multiSearchAnyCaseInsensitiveUTF8(haystack, [needle1, needle2, ..., needleN]) **参数** -- `haystack` — 进行搜索的 UTF-8 字符串。[String](../data-types/string.md)。 -- `needle` — 要搜索的 UTF-8 子字符串数组。[Array](../data-types/array.md)。 +- `haystack` — UTF-8 字符串,在其中执行搜索。 [String](../data-types/string.md)。 +- `needle` — 要搜索的 UTF-8 子字符串。 [Array](../data-types/array.md) **返回值** -- 1,如果至少有一个不区分大小写的匹配。 -- 0,如果没有至少一个不区分大小写的匹配。 +- 如果至少有一个不区分大小写的匹配,则返回 1。 +- 如果没有至少一个不区分大小写的匹配,则返回 0。 **示例** @@ -727,18 +727,162 @@ SELECT multiSearchAnyCaseInsensitiveUTF8('\x43\x6c\x69\x63\x6b\x48\x6f\x75\x73\x 结果: +```response +1 +``` +## hasAnyTokens {#hasanytokens} + +:::note +此函数仅在设置 [allow_experimental_full_text_index](/operations/settings/settings#allow_experimental_full_text_index) 被启用时可以使用。 +::: + +如果至少有一个字符串 `needle`i 与 `input` 列匹配,则返回 1,否则返回 0。 + +**语法** + +```sql +hasAnyTokens(input, ['needle1', 'needle2', ..., 'needleN']) +``` + +**参数** + +- `input` — 输入列。 [String](../data-types/string.md) 或 [FixedString](../data-types/fixedstring.md)。 +- `needles` — 要搜索的令牌。最多支持 64 个令牌。 [Array](../data-types/array.md)([String](../data-types/string.md))。 + +:::note +列 `input` 必须具有 [文本索引][../../engines/table-engines/mergetree-family/invertedindexes.md]。 +::: + +`input` 字符串由索引定义中的分词器进行分词。 + +每个 `needle` 数组元素 tokeni 被视为一个单一的令牌,即不再进一步分词。 +例如,如果您想用索引 `tokenizer = ngrams(5)` 搜索 `ClickHouse`,提供这些 needles: `['Click', 'lickH', 'ickHo', 'ckHou', 'kHous', 'House']`。 +要生成这些 needles,您可以使用 [tokens](/sql-reference/functions/splitting-merging-functions.md/#tokens) 函数。 +重复的令牌是无效的,例如,`['ClickHouse', 'ClickHouse']` 与 `['ClickHouse']` 是相同的。 + +**返回值** + +- 如果至少有一个匹配,则返回 1。 +- 否则返回 0。 + +**示例** + +查询: + +```sql +CREATE TABLE table ( + id UInt32, + msg String, + INDEX idx(msg) TYPE text(tokenizer = splitByString(['()', '\\']) +) +ENGINE = MergeTree +ORDER BY id; + +INSERT INTO table VALUES (1, '()a,\\bc()d'), (2, '()\\a()bc\\d'), (3, ',()a\\,bc,(),d,'); + +SELECT count() FROM table WHERE hasAnyTokens(msg, ['a', 'd']); +``` + +结果: + +```response +3 +``` + +**使用 `tokens` 函数生成针** + +查询: + +```sql +SELECT count() FROM table WHERE hasAnyTokens(msg, tokens('a()d', 'splitByString', ['()', '\\'])); +``` + +结果: + +```response +3 +``` +## hasAllTokens {#hasalltokens} + +:::note +此函数仅在设置 [allow_experimental_full_text_index](/operations/settings/settings#allow_experimental_full_text_index) 被启用时可以使用。 +::: + +类似于 [hasAnyTokens](#hasanytokens),只有在所有字符串 `needle`i 与 `input` 列匹配时才返回 1,否则返回 0。 + +**语法** + +```sql +hasAllTokens(input, ['needle1', 'needle2', ..., 'needleN']) +``` + +**参数** + +- `input` — 输入列。 [String](../data-types/string.md) 或 [FixedString](../data-types/fixedstring.md)。 +- `needles` — 要搜索的令牌。最多支持 64 个令牌。 [Array](../data-types/array.md)([String](../data-types/string.md))。 + +:::note +列 `input` 必须具有 [文本索引][../../engines/table-engines/mergetree-family/invertedindexes.md]。 +::: + +`input` 字符串由索引定义中的分词器进行分词。 + +每个 `needle` 数组元素 tokeni 被视为一个单一的令牌,即不再进一步分词。 +例如,如果您想用索引 `tokenizer = ngrams(5)` 搜索 `ClickHouse`,提供这些 needles: `['Click', 'lickH', 'ickHo', 'ckHou', 'kHous', 'House']`。 +要生成这些 needles,您可以使用 [tokens](/sql-reference/functions/splitting-merging-functions.md/#tokens) 函数。 +重复的令牌是无效的,例如,`['ClickHouse', 'ClickHouse']` 与 `['ClickHouse']` 是相同的。 + +**返回值** + +- 如果所有 needle 匹配,则返回 1。 +- 否则返回 0。 + +**示例** + +查询: + +```sql +CREATE TABLE table ( + id UInt32, + msg String, + INDEX idx(msg) TYPE text(tokenizer = splitByString(['()', '\\']) +) +ENGINE = MergeTree +ORDER BY id; + +INSERT INTO table VALUES (1, '()a,\\bc()d'), (2, '()\\a()bc\\d'), (3, ',()a\\,bc,(),d,'); + +SELECT count() FROM table WHERE hasAllTokens(msg, ['a', 'd']); +``` + +结果: + +```response +1 +``` + +**使用 `tokens` 函数生成针** + +查询: + +```sql +SELECT count() FROM table WHERE hasAllTokens(msg, tokens('a()d', 'splitByString', ['()', '\\'])); +``` + +结果: + ```response 1 ``` ## match {#match} -返回字符串 `haystack` 是否与正则表达式 `pattern` 匹配,使用 [re2 正则表达式语法](https://github.com/google/re2/wiki/Syntax)。 +返回字符串 `haystack` 是否与正则表达式 `pattern` 匹配,[re2 正则表达式语法](https://github.com/google/re2/wiki/Syntax)。 -匹配基于 UTF-8,例如,`.` 匹配 Unicode 代码点 `¥`,该代码点在 UTF-8 中使用两个字节表示。正则表达式中不得包含空字节。如果 haystack 或 pattern 不是有效的 UTF-8,则行为未定义。 +匹配是基于 UTF-8 的,例如 `.` 匹配 Unicode 代码点 `¥`,其在 UTF-8 中使用两个字节表示。正则表达式中不得包含空字节。如果 haystack 或模式不是有效 UTF-8,则行为是未定义的。 -与 re2 的默认行为不同,`.` 匹配换行符。要禁用此功能,可在模式前添加 `(?-s)`。 +与 re2 的默认行为不同,`.` 匹配换行符。要禁用此功能,请在模式前添加 `(?-s)`。 -如果您只想在字符串中搜索子字符串,可以使用 [like](#like) 或 [position](#position) 函数,它们的性能比此函数快得多。 +如果您只想在字符串中查找子字符串,可以使用函数 [like](#like) 或 [position](#position),它们的速度比此函数快得多。 **语法** @@ -749,19 +893,19 @@ match(haystack, pattern) 别名:`haystack REGEXP pattern operator` ## multiMatchAny {#multimatchany} -像 `match` 但如果至少有一个模式匹配,则返回 1,否则返回 0。 +类似于 `match`,但如果至少有一个模式匹配,则返回 1,否则返回 0。 :::note -`multi[Fuzzy]Match*()` 函数族使用 (Vectorscan)[https://github.com/VectorCamp/vectorscan] 库。因此,它们仅在 ClickHouse 编译时启用了对 vectorscan 的支持。 +`multi[Fuzzy]Match*()` 函数系列使用 (Vectorscan)[https://github.com/VectorCamp/vectorscan] 库。因此,它们仅在 ClickHouse 被编译为支持 vectorscan 时启用。 要关闭所有使用 hyperscan 的函数,请使用设置 `SET allow_hyperscan = 0;`。 -由于 vectorscan 的限制,haystack 字符串的长度必须小于 232 字节。 +由于 vectorscan 的限制,`haystack` 字符串的长度必须小于 232 字节。 -Hyperscan 通常容易受到正则表达式拒绝服务(ReDoS)攻击(例如,请参见 (here)[https://www.usenix.org/conference/usenixsecurity22/presentation/turonova],(here)[https://doi.org/10.1007/s10664-021-10033-1] 和 (here)[https://doi.org/10.1145/3236024.3236027])。建议用户仔细检查提供的模式。 +Hyperscan 通常容易受到正则表达式拒绝服务(ReDoS)攻击(例如,请参见 (here)[https://www.usenix.org/conference/usenixsecurity22/presentation/turonova]、(here)[https://doi.org/10.1007/s10664-021-10033-1] 和 (here)[https://doi.org/10.1145/3236024.3236027])。建议用户仔细检查提供的模式。 ::: -如果您只想在字符串中搜索多个子字符串,可以使用函数 [multiSearchAny](#multisearchany),因为它的性能比此函数更快。 +如果您只想在字符串中搜索多个子字符串,可以使用函数 [multiSearchAny](#multisearchany),它的速度比此函数快得多。 **语法** @@ -770,7 +914,7 @@ multiMatchAny(haystack, \[pattern1, pattern2, ..., pattern ``` ## multiMatchAnyIndex {#multimatchanyindex} -像 `multiMatchAny` 但返回与 haystack 匹配的任何索引。 +类似于 `multiMatchAny`,但返回与 `haystack` 匹配的任何索引。 **语法** @@ -779,7 +923,7 @@ multiMatchAnyIndex(haystack, \[pattern1, pattern2, ..., pa ``` ## multiMatchAllIndices {#multimatchallindices} -像 `multiMatchAny` 但返回与 haystack 匹配的所有索引的数组,顺序任意。 +类似于 `multiMatchAny`,但返回所有匹配 `haystack` 的索引数组,顺序无关。 **语法** @@ -788,10 +932,10 @@ multiMatchAllIndices(haystack, \[pattern1, pattern2, ..., ``` ## multiFuzzyMatchAny {#multifuzzymatchany} -像 `multiMatchAny` 但如果任何模式在一个恒定的 [编辑距离](https://en.wikipedia.org/wiki/Edit_distance) 内与 haystack 匹配,则返回 1。此函数依赖于 [hyperscan](https://intel.github.io/hyperscan/dev-reference/compilation.html#approximate-matching) 库的实验特性,在某些极端情况下可能会缓慢。性能取决于编辑距离值和使用的模式,但总是比非模糊变体贵得多。 +类似于 `multiMatchAny`,但如果任何模式在某个常量 [编辑距离](https://en.wikipedia.org/wiki/Edit_distance) 内匹配 `haystack`,则返回 1。此函数依赖于 [hyperscan](https://intel.github.io/hyperscan/dev-reference/compilation.html#approximate-matching) 库的实验性功能,并且对于某些极端情况可能很慢。性能依赖于编辑距离值和使用的模式,但始终比非模糊变体更昂贵。 :::note -`multiFuzzyMatch*()` 函数族不支持 UTF-8 正则表达式(将其视为字节序列),由于 hyperscan 的限制。 +`multiFuzzyMatch*()` 函数系列不支持 UTF-8 正则表达式(因为它将其视为字节序列),这受到 hyperscan 的限制。 ::: **语法** @@ -801,7 +945,7 @@ multiFuzzyMatchAny(haystack, distance, \[pattern1, pattern21, pattern2 ``` ## multiFuzzyMatchAllIndices {#multifuzzymatchallindices} -像 `multiFuzzyMatchAny` 但返回与 haystack 匹配的所有索引的数组,顺序任意,距离为常数。 +类似于 `multiFuzzyMatchAny`,但返回在常量编辑距离内与 `haystack` 匹配的所有索引的数组,顺序无关。 **语法** @@ -819,9 +963,10 @@ multiFuzzyMatchAllIndices(haystack, distance, \[pattern1, pattern= 25.6 时,`countMatches` 会在出现空匹配时继续执行。 + 可以使用设置 [count_matches_stop_at_empty_match = true](/operations/settings/settings#count_matches_stop_at_empty_match) 恢复遗留行为。 **语法** @@ -1518,7 +1662,7 @@ countMatches(haystack, pattern) **参数** - `haystack` — 要搜索的字符串。 [字符串](../data-types/string.md)。 -- `pattern` — 使用 [re2 正则表达式语法](https://github.com/google/re2/wiki/Syntax) 的正则表达式。 [字符串](../data-types/string.md)。 +- `pattern` — 带有 [re2 正则表达式语法](https://github.com/google/re2/wiki/Syntax) 的正则表达式。 [字符串](../data-types/string.md)。 **返回值** @@ -1549,10 +1693,9 @@ SELECT countMatches('aaaa', 'aa'); │ 2 │ └───────────────────────────────┘ ``` - ## countMatchesCaseInsensitive {#countmatchescaseinsensitive} -返回在 haystack 中的模式的正则表达式匹配数量,类似于 [`countMatches`](#countmatches),但匹配时忽略大小写。 +返回字符串 `haystack` 中与模式匹配的正则表达式的数量,类似于 [`countMatches`](#countmatches),但匹配时忽略大小写。 **语法** @@ -1563,7 +1706,7 @@ countMatchesCaseInsensitive(haystack, pattern) **参数** - `haystack` — 要搜索的字符串。 [字符串](../data-types/string.md)。 -- `pattern` — 使用 [re2 正则表达式语法](https://github.com/google/re2/wiki/Syntax) 的正则表达式。 [字符串](../data-types/string.md)。 +- `pattern` — 带有 [re2 正则表达式语法](https://github.com/google/re2/wiki/Syntax) 的正则表达式。 [字符串](../data-types/string.md)。 **返回值** @@ -1584,24 +1727,27 @@ SELECT countMatchesCaseInsensitive('AAAA', 'aa'); │ 2 │ └──────────────────────────────────────────────┘ ``` - ## regexpExtract {#regexpextract} -提取在 `haystack` 中与正则表达式模式匹配的第一个字符串,并对应到正则表达式组索引。 +提取在 `haystack` 中与正则表达式模式匹配并对应于正则表达式组索引的第一个字符串。 **语法** +```sql +regexpExtract(haystack, pattern[, index]) +``` + 别名:`REGEXP_EXTRACT(haystack, pattern[, index])`。 **参数** -- `haystack` — 字符串,其中将匹配正则表达式模式。 [字符串](../data-types/string.md)。 +- `haystack` — 要匹配正则表达式模式的字符串。 [字符串](../data-types/string.md)。 - `pattern` — 字符串,正则表达式,必须是常量。 [字符串](../data-types/string.md)。 -- `index` – 一个大于或等于 0 的整数,默认值为 1。它表示要提取哪个正则表达式组。 [UInt 或 Int](../data-types/int-uint.md)。 可选。 +- `index` – 整数,取值大于或等于 0,默认值为 1。它表示要提取的正则表达式组。 [UInt 或 Int](../data-types/int-uint.md)。 可选。 **返回值** -`pattern` 可能包含多个正则表达式组,`index` 指示要提取哪个正则表达式组。 0 的索引表示匹配整个正则表达式。 [字符串](../data-types/string.md)。 +`pattern` 可能包含多个正则表达式组,`index` 指示要提取的正则表达式组。索引 0 意味着匹配整个正则表达式。 [字符串](../data-types/string.md)。 **示例** @@ -1620,12 +1766,10 @@ SELECT │ 100 │ 200 │ 100-200 │ 100 │ └──────────────────────────────────────────────┴──────────────────────────────────────────────┴──────────────────────────────────────────────┴───────────────────────────────────────────┘ ``` - ## hasSubsequence {#hassubsequence} -如果 `needle` 是 `haystack` 的子序列,则返回 1,否则返回 0。 -字符串的子序列是通过删除一个或多个元素而不改变剩余元素的顺序从给定字符串派生的序列。 - +如果 `needle` 是 `haystack` 的子序列,则返回 1, 否则返回 0。 +字符串的子序列是可以由给定字符串派生的序列,通过删除零或多个元素而不更改剩余元素的顺序。 **语法** ```sql @@ -1634,12 +1778,12 @@ hasSubsequence(haystack, needle) **参数** -- `haystack` — 搜索的字符串。 [字符串](../data-types/string.md)。 +- `haystack` — 进行搜索的字符串。 [字符串](../data-types/string.md)。 - `needle` — 要搜索的子序列。 [字符串](../data-types/string.md)。 **返回值** -- 1,如果 needle 是 haystack 的子序列,0 否则。 [UInt8](../data-types/int-uint.md)。 +- 如果 needle 是 haystack 的子序列,则返回 1,否则返回 0。 [UInt8](../data-types/int-uint.md)。 **示例** @@ -1656,10 +1800,9 @@ SELECT hasSubsequence('garbage', 'arg'); │ 1 │ └──────────────────────────────────┘ ``` - ## hasSubsequenceCaseInsensitive {#hassubsequencecaseinsensitive} -与 [hasSubsequence](#hassubsequence) 相似,但不区分大小写地搜索。 +类似于 [hasSubsequence](#hassubsequence),但不区分大小写搜索。 **语法** @@ -1669,12 +1812,12 @@ hasSubsequenceCaseInsensitive(haystack, needle) **参数** -- `haystack` — 搜索的字符串。 [字符串](../data-types/string.md)。 +- `haystack` — 进行搜索的字符串。 [字符串](../data-types/string.md)。 - `needle` — 要搜索的子序列。 [字符串](../data-types/string.md)。 **返回值** -- 1,如果 needle 是 haystack 的子序列,0 否则。 [UInt8](../data-types/int-uint.md)。 +- 如果 needle 是 haystack 的子序列,则返回 1,否则返回 0。 [UInt8](../data-types/int-uint.md)。 **示例** @@ -1691,10 +1834,9 @@ SELECT hasSubsequenceCaseInsensitive('garbage', 'ARG'); │ 1 │ └─────────────────────────────────────────────────┘ ``` - ## hasSubsequenceUTF8 {#hassubsequenceutf8} -与 [hasSubsequence](#hassubsequence) 相似,但假设 `haystack` 和 `needle` 是 UTF-8 编码的字符串。 +类似于 [hasSubsequence](#hassubsequence),但假设 `haystack` 和 `needle` 为 UTF-8 编码的字符串。 **语法** @@ -1704,19 +1846,19 @@ hasSubsequenceUTF8(haystack, needle) **参数** -- `haystack` — 搜索的字符串。 UTF-8 编码 [字符串](../data-types/string.md)。 -- `needle` — 要搜索的子序列。 UTF-8 编码 [字符串](../data-types/string.md)。 +- `haystack` — 进行搜索的字符串。 UTF-8 编码的 [字符串](../data-types/string.md)。 +- `needle` — 要搜索的子序列。 UTF-8 编码的 [字符串](../data-types/string.md)。 **返回值** -- 1,如果 needle 是 haystack 的子序列,0 否则。 [UInt8](../data-types/int-uint.md)。 +- 如果 needle 是 haystack 的子序列,则返回 1,否则返回 0。 [UInt8](../data-types/int-uint.md)。 查询: **示例** ```sql -select hasSubsequenceUTF8('ClickHouse - столбцовая система управления базами данных', 'система'); +SELECT hasSubsequenceUTF8('ClickHouse - столбцовая система управления базами данных', 'система'); ``` 结果: @@ -1726,10 +1868,9 @@ select hasSubsequenceUTF8('ClickHouse - столбцовая система уп │ 1 │ └───────────────────────────────────────────────────────────────────────────────────────────┘ ``` - ## hasSubsequenceCaseInsensitiveUTF8 {#hassubsequencecaseinsensitiveutf8} -与 [hasSubsequenceUTF8](#hassubsequenceutf8) 相似,但不区分大小写地搜索。 +类似于 [hasSubsequenceUTF8](#hassubsequenceutf8),但不区分大小写搜索。 **语法** @@ -1739,19 +1880,19 @@ hasSubsequenceCaseInsensitiveUTF8(haystack, needle) **参数** -- `haystack` — 搜索的字符串。 UTF-8 编码 [字符串](../data-types/string.md)。 -- `needle` — 要搜索的子序列。 UTF-8 编码 [字符串](../data-types/string.md)。 +- `haystack` — 进行搜索的字符串。 UTF-8 编码的 [字符串](../data-types/string.md)。 +- `needle` — 要搜索的子序列。 UTF-8 编码的 [字符串](../data-types/string.md)。 **返回值** -- 1,如果 needle 是 haystack 的子序列,0 否则。 [UInt8](../data-types/int-uint.md)。 +- 如果 needle 是 haystack 的子序列,则返回 1,否则返回 0。 [UInt8](../data-types/int-uint.md)。 **示例** 查询: ```sql -select hasSubsequenceCaseInsensitiveUTF8('ClickHouse - столбцовая система управления базами данных', 'СИСТЕМА'); +SELECT hasSubsequenceCaseInsensitiveUTF8('ClickHouse - столбцовая система управления базами данных', 'СИСТЕМА'); ``` 结果: @@ -1761,10 +1902,9 @@ select hasSubsequenceCaseInsensitiveUTF8('ClickHouse - столбцовая си │ 1 │ └──────────────────────────────────────────────────────────────────────────────────────────────────────────┘ ``` - ## hasToken {#hastoken} -如果给定的标记出现在 `haystack` 中,则返回 1,否则返回 0。 +如果给定的 token 存在于 haystack 中,则返回 1,否则返回 0。 **语法** @@ -1774,16 +1914,16 @@ hasToken(haystack, token) **参数** -- `haystack`: 搜索的字符串。 [字符串](../data-types/string.md) 或 [枚举](../data-types/enum.md)。 -- `token`: 在两个非字母数字 ASCII 字符(或 `haystack` 边界)之间的最大长度子字符串。 +- `haystack`:进行搜索的字符串。 [字符串](../data-types/string.md) 或 [枚举](../data-types/enum.md)。 +- `token`:两个非字母数字 ASCII 字符之间的最大长度子字符串(或 haystack 的边界)。 **返回值** -- 1,如果标记在 haystack 中存在,0 否则。 [UInt8](../data-types/int-uint.md)。 +- 如果 token 存在于 haystack 中,则返回 1,否则返回 0。 [UInt8](../data-types/int-uint.md)。 **实现细节** -标记必须是常量字符串。由 tokenbf_v1 索引特化支持。 +Token 必须是常量字符串。受 tokenbf_v1 索引特殊化支持。 **示例** @@ -1796,10 +1936,9 @@ SELECT hasToken('Hello World','Hello'); ```response 1 ``` - ## hasTokenOrNull {#hastokenornull} -如果给定的标记存在,则返回 1,如果不存在,则返回 0,如果标记格式错误,则返回 null。 +如果给定的 token 存在,则返回 1,如果不存在,则返回 0,如果 token 格式不正确,则返回 null。 **语法** @@ -1809,20 +1948,20 @@ hasTokenOrNull(haystack, token) **参数** -- `haystack`: 搜索的字符串。 [字符串](../data-types/string.md) 或 [枚举](../data-types/enum.md)。 -- `token`: 在两个非字母数字 ASCII 字符(或 `haystack` 边界)之间的最大长度子字符串。 +- `haystack`:进行搜索的字符串。 [字符串](../data-types/string.md) 或 [枚举](../data-types/enum.md)。 +- `token`:两个非字母数字 ASCII 字符之间的最大长度子字符串(或 haystack 的边界)。 **返回值** -- 1,如果标记在 haystack 中存在;如果不存,则返回 0,如果标记格式错误,则返回 null。 +- 如果 token 存在于 haystack 中,则返回 1,如果不存在,则返回 0;如果 token 格式不正确,则返回 [`null`](../data-types/nullable.md)。 [UInt8](../data-types/int-uint.md)。 **实现细节** -标记必须是常量字符串。由 tokenbf_v1 索引特化支持。 +Token 必须是常量字符串。受 tokenbf_v1 索引特殊化支持。 **示例** -如果 `hasToken` 对格式错误的标记抛出错误,则 `hasTokenOrNull` 对格式错误的标记返回 `null`。 +如果 `hasToken` 对格式不正确的 token 抛出错误,`hasTokenOrNull` 则返回格式不正确的 token 对应的 `null`。 查询: @@ -1833,10 +1972,9 @@ SELECT hasTokenOrNull('Hello World','Hello,World'); ```response null ``` - ## hasTokenCaseInsensitive {#hastokencaseinsensitive} -如果给定的标记在 `haystack` 中存在,则返回 1,否则返回 0。忽略大小写。 +如果给定的 token 存在于 haystack 中,则返回 1,否则返回 0。 忽略大小写。 **语法** @@ -1846,16 +1984,16 @@ hasTokenCaseInsensitive(haystack, token) **参数** -- `haystack`: 搜索的字符串。 [字符串](../data-types/string.md) 或 [枚举](../data-types/enum.md)。 -- `token`: 在两个非字母数字 ASCII 字符(或 `haystack` 边界)之间的最大长度子字符串。 +- `haystack`:进行搜索的字符串。 [字符串](../data-types/string.md) 或 [枚举](../data-types/enum.md)。 +- `token`:两个非字母数字 ASCII 字符之间的最大长度子字符串(或 haystack 的边界)。 **返回值** -- 1,如果标记在 haystack 中存在,0 否则。 [UInt8](../data-types/int-uint.md)。 +- 如果 token 存在于 haystack 中,则返回 1,否则返回 0。 [UInt8](../data-types/int-uint.md)。 **实现细节** -标记必须是常量字符串。由 tokenbf_v1 索引特化支持。 +Token 必须是常量字符串。受 tokenbf_v1 索引特殊化支持。 **示例** @@ -1868,10 +2006,9 @@ SELECT hasTokenCaseInsensitive('Hello World','hello'); ```response 1 ``` +## hasTokenCaseInsensitiveOrNull {#hastokencaseinsensitiveornull} -## hasTokenCaseInsensitiveOrNull {#hastokencaseinsensitivedornull} - -如果给定的标记在 `haystack` 中存在,则返回 1,否则返回 0。忽略大小写,并在标记格式错误时返回 null。 +如果给定的 token 存在于 haystack 中,则返回 1,否则返回 0。 忽略大小写,并在 token 格式不正确时返回 null。 **语法** @@ -1881,20 +2018,20 @@ hasTokenCaseInsensitiveOrNull(haystack, token) **参数** -- `haystack`: 搜索的字符串。 [字符串](../data-types/string.md) 或 [枚举](../data-types/enum.md)。 -- `token`: 在两个非字母数字 ASCII 字符(或 `haystack` 边界)之间的最大长度子字符串。 +- `haystack`:进行搜索的字符串。 [字符串](../data-types/string.md) 或 [枚举](../data-types/enum.md)。 +- `token`:两个非字母数字 ASCII 字符之间的最大长度子字符串(或 haystack 的边界)。 **返回值** -- 1,如果标记在 haystack 中存在,0 如果标记不存在,否则 [`null`](../data-types/nullable.md) 如果标记格式错误。 [UInt8](../data-types/int-uint.md)。 +- 如果 token 存在于 haystack 中,则返回 1,如果 token 不存在,则返回 0,否则如果 token 格式不正确,则返回 [`null`](../data-types/nullable.md)。 [UInt8](../data-types/int-uint.md)。 **实现细节** -标记必须是常量字符串。由 tokenbf_v1 索引特化支持。 +Token 必须是常量字符串。受 tokenbf_v1 索引特殊化支持。 **示例** -如果 `hasTokenCaseInsensitive` 对格式错误的标记抛出错误,则 `hasTokenCaseInsensitiveOrNull` 对格式错误的标记返回 `null`。 +如果 `hasTokenCaseInsensitive` 对格式不正确的 token 抛出错误,`hasTokenCaseInsensitiveOrNull` 则返回格式不正确的 token 对应的 `null`。 查询: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/string-search-functions.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/string-search-functions.md.hash index b92f7769449..9e2df86dcaa 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/string-search-functions.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/string-search-functions.md.hash @@ -1 +1 @@ -62c354cbd79a1a4c +e5733bb1f6af1dc2 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/time-series-analysis-functions.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/time-series-analysis-functions.md new file mode 100644 index 00000000000..cfd092c1d95 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/time-series-analysis-functions.md @@ -0,0 +1,175 @@ +--- +'description': '时间序列分析的函数的文档' +'sidebar_label': '时间序列分析' +'slug': '/sql-reference/functions/time-series-analysis-functions' +'title': '时间序列分析的函数' +'doc_type': 'reference' +--- + + +# 时间序列分析的函数 + +以下函数用于序列数据分析。 + +## seriesOutliersDetectTukey {#seriesoutliersdetecttukey} + +使用 [Tukey Fences](https://en.wikipedia.org/wiki/Outlier#Tukey%27s_fences) 检测序列数据中的异常值。 + +**语法** + +```sql +seriesOutliersDetectTukey(series); +seriesOutliersDetectTukey(series, min_percentile, max_percentile, K); +``` + +**参数** + +- `series` - 数值数组。 +- `min_percentile` - 用于计算四分位距 [(IQR)](https://en.wikipedia.org/wiki/Interquartile_range) 的最小百分位数。值必须在 [0.02,0.98] 范围内。默认值为 0.25。 +- `max_percentile` - 用于计算四分位距 (IQR) 的最大百分位数。值必须在 [0.02,0.98] 范围内。默认值为 0.75。 +- `K` - 检测轻微或更强异常值的非负常数值。默认值为 1.5。 + +在 `series` 中至少需要四个数据点以检测异常值。 + +**返回值** + +- 返回一个与输入数组长度相同的数组,其中每个值代表系列中相应元素的可能异常分数。非零分数表示可能存在异常。 [Array](../data-types/array.md)。 + +**示例** + +查询: + +```sql +SELECT seriesOutliersDetectTukey([-3, 2, 15, 3, 5, 6, 4, 5, 12, 45, 12, 3, 3, 4, 5, 6]) AS print_0; +``` + +结果: + +```text +┌───────────print_0─────────────────┐ +│[0,0,0,0,0,0,0,0,0,27,0,0,0,0,0,0] │ +└───────────────────────────────────┘ +``` + +查询: + +```sql +SELECT seriesOutliersDetectTukey([-3, 2, 15, 3, 5, 6, 4.50, 5, 12, 45, 12, 3.40, 3, 4, 5, 6], 0.2, 0.8, 1.5) AS print_0; +``` + +结果: + +```text +┌─print_0──────────────────────────────┐ +│ [0,0,0,0,0,0,0,0,0,19.5,0,0,0,0,0,0] │ +└──────────────────────────────────────┘ +``` + +## seriesPeriodDetectFFT {#seriesperioddetectfft} + +使用FFT - [快速傅里叶变换](https://en.wikipedia.org/wiki/Fast_Fourier_transform) 找到给定序列数据的周期。 + +**语法** + +```sql +seriesPeriodDetectFFT(series); +``` + +**参数** + +- `series` - 数值数组。 + +**返回值** + +- 返回与序列数据周期相等的实值。当数据点数少于四个时返回 NaN。 [Float64](../data-types/float.md)。 + +**示例** + +查询: + +```sql +SELECT seriesPeriodDetectFFT([1, 4, 6, 1, 4, 6, 1, 4, 6, 1, 4, 6, 1, 4, 6, 1, 4, 6, 1, 4, 6]) AS print_0; +``` + +结果: + +```text +┌───────────print_0──────┐ +│ 3 │ +└────────────────────────┘ +``` + +```sql +SELECT seriesPeriodDetectFFT(arrayMap(x -> abs((x % 6) - 3), range(1000))) AS print_0; +``` + +结果: + +```text +┌─print_0─┐ +│ 6 │ +└─────────┘ +``` + +## seriesDecomposeSTL {#seriesdecomposestl} + +使用 STL [(基于 Loess 的季节性-趋势分解程序)](https://www.wessa.net/download/stl.pdf) 对序列数据进行分解,得到季节成分、趋势成分和残差成分。 + +**语法** + +```sql +seriesDecomposeSTL(series, period); +``` + +**参数** + +- `series` - 数值数组。 +- `period` - 正整数。 + +`series` 中的数据点数应至少是 `period` 值的两倍。 + +**返回值** + +- 返回四个数组的数组,其中第一个数组包含季节成分,第二个数组 - 趋势,第三个数组 - 残差成分,第四个数组 - 基线(季节 + 趋势)成分。 [Array](../data-types/array.md)。 + +**示例** + +查询: + +```sql +SELECT seriesDecomposeSTL([10.1, 20.45, 40.34, 10.1, 20.45, 40.34, 10.1, 20.45, 40.34, 10.1, 20.45, 40.34, 10.1, 20.45, 40.34, 10.1, 20.45, 40.34, 10.1, 20.45, 40.34, 10.1, 20.45, 40.34], 3) AS print_0; +``` + +结果: + +```text +┌───────────print_0──────────────────────────────────────────────────────────────────────────────────────────────────────┐ +│ [[ + -13.529999, -3.1799996, 16.71, -13.53, -3.1799996, 16.71, -13.53, -3.1799996, + 16.71, -13.530001, -3.18, 16.710001, -13.530001, -3.1800003, 16.710001, -13.530001, + -3.1800003, 16.710001, -13.530001, -3.1799994, 16.71, -13.529999, -3.1799994, 16.709997 + ], + [ + 23.63, 23.63, 23.630003, 23.630001, 23.630001, 23.630001, 23.630001, 23.630001, + 23.630001, 23.630001, 23.630001, 23.63, 23.630001, 23.630001, 23.63, 23.630001, + 23.630001, 23.63, 23.630001, 23.630001, 23.630001, 23.630001, 23.630001, 23.630003 + ], + [ + 0, 0.0000019073486, -0.0000019073486, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0.0000019073486, 0, + 0 + ], + [ + 10.1, 20.449999, 40.340004, 10.100001, 20.45, 40.34, 10.100001, 20.45, 40.34, 10.1, 20.45, 40.34, + 10.1, 20.45, 40.34, 10.1, 20.45, 40.34, 10.1, 20.45, 40.34, 10.100002, 20.45, 40.34 + ]] │ +└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ +``` + + + + + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/time-series-analysis-functions.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/time-series-analysis-functions.md.hash new file mode 100644 index 00000000000..c94973213f4 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/time-series-analysis-functions.md.hash @@ -0,0 +1 @@ +8d078eab9d1f2423 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/time-series-functions.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/time-series-functions.md index 89fcf9c81fc..c12acb2a961 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/time-series-functions.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/time-series-functions.md @@ -1,173 +1,116 @@ --- -'description': 'Documentation for 时间序列函数' -'sidebar_label': '时间序列' -'sidebar_position': 172 +'description': '处理时间序列的函数的文档' +'sidebar_label': 'TimeSeries' 'slug': '/sql-reference/functions/time-series-functions' -'title': '时间序列函数' +'title': '处理时间序列的函数' +'doc_type': 'reference' --- # 时间序列函数 -以下函数用于序列数据分析。 +以下函数旨在与 `timeSeries*()` 聚合函数一起使用,例如 +[timeSeriesInstantRateToGrid](../aggregate-functions/reference/timeSeriesInstantRateToGrid.md), +[timeSeriesLastToGrid](../aggregate-functions/reference/timeSeriesResampleToGridWithStaleness.md) 等。 -## seriesOutliersDetectTukey {#seriesoutliersdetecttukey} +## timeSeriesRange {#timeSeriesRange} -使用 [Tukey Fences](https://en.wikipedia.org/wiki/Outlier#Tukey%27s_fences) 检测序列数据中的异常值。 +生成时间戳范围。 **语法** ```sql -seriesOutliersDetectTukey(series); -seriesOutliersDetectTukey(series, min_percentile, max_percentile, K); +timeSeriesRange(start_timestamp, end_timestamp, step) ``` **参数** -- `series` - 数值数组。 -- `min_percentile` - 计算四分位间距所使用的最小百分位。该值必须在 [0.02,0.98] 范围内。默认值为 0.25。 -- `max_percentile` - 计算四分位间距所使用的最大百分位。该值必须在 [0.02,0.98] 范围内。默认值为 0.75。 -- `K` - 非负常数值,用于检测轻微或更强的异常值。默认值为 1.5。 - -在 `series` 中至少需要四个数据点才能检测到异常值。 +- `start_timestamp` - 范围的开始。 +- `end_timestamp` - 范围的结束。 +- `step` - 范围的步长,以秒为单位。 **返回值** -- 返回一个与输入数组具有相同长度的数组,其中每个值表示对应元素在系列中的可能异常分数。非零分数表示可能的异常。 [Array](../data-types/array.md)。 +- 返回时间戳范围 `[start_timestamp, start_timestamp + step, start_timestamp + 2 * step, ..., end_timestamp]`。 **示例** 查询: ```sql -SELECT seriesOutliersDetectTukey([-3, 2, 15, 3, 5, 6, 4, 5, 12, 45, 12, 3, 3, 4, 5, 6]) AS print_0; +SELECT timeSeriesRange('2025-06-01 00:00:00'::DateTime64(3), '2025-06-01 00:01:00'::DateTime64(3), 30) AS rng; ``` 结果: ```text -┌───────────print_0─────────────────┐ -│[0,0,0,0,0,0,0,0,0,27,0,0,0,0,0,0] │ -└───────────────────────────────────┘ +┌────────────────────────────────────result─────────────────────────────────────────┐ +│ ['2025-06-01 00:00:00.000', '2025-06-01 00:00:30.000', '2025-06-01 00:01:00.000'] │ +└───────────────────────────────────────────────────────────────────────────────────┘ ``` -查询: - +**注意** +- 如果函数 `timeSeriesRange()` 的 `start_timestamp` 等于 `end_timestamp`,则返回包含该时间戳的 1 元素数组:`[start_timestamp]` +- 函数 `timeSeriesRange()` 与函数 [range](../functions/array-functions.md#range) 类似。 +例如,如果时间戳类型为 `DateTime64(3)` 且 `start_timestamp < end_timestamp`,那么 `timeSeriesRange(start_timestamp, end_timestamp, step)` 返回的结果与以下表达式相同: ```sql -SELECT seriesOutliersDetectTukey([-3, 2, 15, 3, 5, 6, 4.50, 5, 12, 45, 12, 3.40, 3, 4, 5, 6], 0.2, 0.8, 1.5) AS print_0; +range(start_timestamp::Int64, end_timestamp::Int64 + 1, step::Int64)::Array(DateTime64(3)) ``` -结果: +## timeSeriesFromGrid {#timeSeriesFromGrid} -```text -┌─print_0──────────────────────────────┐ -│ [0,0,0,0,0,0,0,0,0,19.5,0,0,0,0,0,0] │ -└──────────────────────────────────────┘ -``` +将值数组 `[value1, value2, value3, ..., valueN]` 转换为元组数组 +`[(start_timestamp, value1), (start_timestamp + step, value2), (start_timestamp + 2 * step, value3), ..., (end_timestamp, valueN)]`。 -## seriesPeriodDetectFFT {#seriesperioddetectfft} +如果某些值 `[value1, value2, value3, ...]` 为 `NULL`,则该函数不会将这些空值复制到结果数组中, +但仍会增加当前时间戳,即例如对于 `[value1, NULL, value2]`,函数将返回 +`[(start_timestamp, value1), (start_timestamp + 2 * step, value2)]`。 -使用 FFT - [快速傅里叶变换](https://en.wikipedia.org/wiki/Fast_Fourier_transform) 找到给定序列数据的周期。 +当前时间戳会按步长增加,直到它大于 `end_timestamp`,每个时间戳将与指定值数组中的值结合。如果值的数量与时间戳的数量不匹配,函数将抛出异常。 **语法** ```sql -seriesPeriodDetectFFT(series); +timeSeriesFromGrid(start_timestamp, end_timestamp, step, values); ``` **参数** -- `series` - 数值数组 +- `start_timestamp` - 网格的开始。 +- `end_timestamp` - 网格的结束。 +- `step` - 网格的步长,以秒为单位。 +- `values` - 值数组 `[value1, value2, ..., valueN]`。 **返回值** -- 返回与序列数据的周期相等的实值。当数据点数量少于四个时返回 NaN。 [Float64](../data-types/float.md)。 +- 返回源值数组中的值与由 `start_timestamp` 和 `step` 描述的规则时间网格相结合的时间戳。 **示例** 查询: ```sql -SELECT seriesPeriodDetectFFT([1, 4, 6, 1, 4, 6, 1, 4, 6, 1, 4, 6, 1, 4, 6, 1, 4, 6, 1, 4, 6]) AS print_0; +SELECT timeSeriesFromGrid('2025-06-01 00:00:00'::DateTime64(3), '2025-06-01 00:01:30.000'::DateTime64(3), 30, [10, 20, NULL, 30]) AS result; ``` 结果: ```text -┌───────────print_0──────┐ -│ 3 │ -└────────────────────────┘ +┌─────────────────────────────────────────────result─────────────────────────────────────────────┐ +│ [('2025-06-01 00:00:00.000',10),('2025-06-01 00:00:30.000',20),('2025-06-01 00:01:30.000',30)] │ +└────────────────────────────────────────────────────────────────────────────────────────────────┘ ``` +**注意** +函数 `timeSeriesFromGrid(start_timestamp, end_timestamp, step, values)` 返回的结果与以下表达式相同: ```sql -SELECT seriesPeriodDetectFFT(arrayMap(x -> abs((x % 6) - 3), range(1000))) AS print_0; -``` - -结果: - -```text -┌─print_0─┐ -│ 6 │ -└─────────┘ -``` - -## seriesDecomposeSTL {#seriesdecomposestl} - -使用 STL [(基于 Loess 的季节-趋势分解程序)](https://www.wessa.net/download/stl.pdf) 对序列数据进行分解,得到季节、趋势和残差成分。 - -**语法** - -```sql -seriesDecomposeSTL(series, period); -``` - -**参数** - -- `series` - 数值数组 -- `period` - 正整数 - -`series` 中的数据点数量应至少是 `period` 的两倍。 - -**返回值** - -- 返回一个包含四个数组的数组,第一个数组包含季节成分,第二个数组 - 趋势,第三个数组 - 残差成分,第四个数组 - 基线(季节 + 趋势)成分。 [Array](../data-types/array.md)。 - -**示例** - -查询: - -```sql -SELECT seriesDecomposeSTL([10.1, 20.45, 40.34, 10.1, 20.45, 40.34, 10.1, 20.45, 40.34, 10.1, 20.45, 40.34, 10.1, 20.45, 40.34, 10.1, 20.45, 40.34, 10.1, 20.45, 40.34, 10.1, 20.45, 40.34], 3) AS print_0; -``` - -结果: - -```text -┌───────────print_0──────────────────────────────────────────────────────────────────────────────────────────────────────┐ -│ [[ - -13.529999, -3.1799996, 16.71, -13.53, -3.1799996, 16.71, -13.53, -3.1799996, - 16.71, -13.530001, -3.18, 16.710001, -13.530001, -3.1800003, 16.710001, -13.530001, - -3.1800003, 16.710001, -13.530001, -3.1799994, 16.71, -13.529999, -3.1799994, 16.709997 - ], - [ - 23.63, 23.63, 23.630003, 23.630001, 23.630001, 23.630001, 23.630001, 23.630001, - 23.630001, 23.630001, 23.630001, 23.63, 23.630001, 23.630001, 23.63, 23.630001, - 23.630001, 23.63, 23.630001, 23.630001, 23.630001, 23.630001, 23.630001, 23.630003 - ], - [ - 0, 0.0000019073486, -0.0000019073486, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0.0000019073486, 0, - 0 - ], - [ - 10.1, 20.449999, 40.340004, 10.100001, 20.45, 40.34, 10.100001, 20.45, 40.34, 10.1, 20.45, 40.34, - 10.1, 20.45, 40.34, 10.1, 20.45, 40.34, 10.1, 20.45, 40.34, 10.100002, 20.45, 40.34 - ]] │ -└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ +arrayFilter(x -> x.2 IS NOT NULL, arrayZip(timeSeriesRange(start_timestamp, end_timestamp, step), values)) ``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/time-series-functions.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/time-series-functions.md.hash index 69280a2a724..9cdf63da4a5 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/time-series-functions.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/time-series-functions.md.hash @@ -1 +1 @@ -c47c3bd8a0f5f476 +9f3cf1a755dd083b diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/time-window-functions.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/time-window-functions.md index 91c042162ea..c273727dc58 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/time-window-functions.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/time-window-functions.md @@ -1,9 +1,9 @@ --- -'description': '关于时间窗口函数的文档' +'description': '时间窗口函数的文档' 'sidebar_label': '时间窗口' -'sidebar_position': 175 'slug': '/sql-reference/functions/time-window-functions' 'title': '时间窗口函数' +'doc_type': 'reference' --- import ExperimentalBadge from '@theme/badges/ExperimentalBadge'; @@ -15,11 +15,11 @@ import CloudNotSupportedBadge from '@theme/badges/CloudNotSupportedBadge'; -时间窗口函数返回相应窗口的包含下界和不包含上界。用于处理 [WindowView](/sql-reference/statements/create/view#window-view) 的函数如下所列: +时间窗口函数返回对应窗口的包含下限和排除上限。用于处理 [WindowView](/sql-reference/statements/create/view#window-view) 的函数如下所示: ## tumble {#tumble} -翻滚时间窗口将记录分配到不重叠且持续的窗口,具有固定的持续时间(`interval`)。 +翻转时间窗口将记录分配到非重叠的、连续的具有固定持续时间(`interval`)的窗口中。 **语法** @@ -29,12 +29,12 @@ tumble(time_attr, interval [, timezone]) **参数** - `time_attr` — 日期和时间。 [DateTime](../data-types/datetime.md)。 -- `interval` — 窗口间隔 [Interval](../data-types/special-data-types/interval.md)。 +- `interval` — [Interval](../data-types/special-data-types/interval.md) 中的窗口间隔。 - `timezone` — [时区名称](../../operations/server-configuration-parameters/settings.md#timezone)(可选)。 **返回值** -- 相应翻滚窗口的包含下界和不包含上界。[Tuple](../data-types/tuple.md)([DateTime](../data-types/datetime.md), [DateTime](../data-types/datetime.md))。 +- 对应的翻转窗口的包含下限和排除上限。 [Tuple](../data-types/tuple.md)([DateTime](../data-types/datetime.md), [DateTime](../data-types/datetime.md))。 **示例** @@ -54,7 +54,7 @@ SELECT tumble(now(), toIntervalDay('1')); ## tumbleStart {#tumblestart} -返回相应 [翻滚窗口](#tumble) 的包含下界。 +返回对应 [翻转窗口](#tumble) 的包含下限。 **语法** @@ -65,12 +65,12 @@ tumbleStart(time_attr, interval [, timezone]); **参数** - `time_attr` — 日期和时间。 [DateTime](../data-types/datetime.md)。 -- `interval` — 窗口间隔 [Interval](../data-types/special-data-types/interval.md)。 +- `interval` — [Interval](../data-types/special-data-types/interval.md) 中的窗口间隔。 - `timezone` — [时区名称](../../operations/server-configuration-parameters/settings.md#timezone)(可选)。 **返回值** -- 相应翻滚窗口的包含下界。[DateTime](../data-types/datetime.md)、[Tuple](../data-types/tuple.md) 或 [UInt32](../data-types/int-uint.md)。 +- 对应翻转窗口的包含下限。 [DateTime](../data-types/datetime.md),[Tuple](../data-types/tuple.md) 或 [UInt32](../data-types/int-uint.md)。 **示例** @@ -90,7 +90,7 @@ SELECT tumbleStart(now(), toIntervalDay('1')); ## tumbleEnd {#tumbleend} -返回相应 [翻滚窗口](#tumble) 的不包含上界。 +返回对应 [翻转窗口](#tumble) 的排除上限。 **语法** @@ -101,12 +101,12 @@ tumbleEnd(time_attr, interval [, timezone]); **参数** - `time_attr` — 日期和时间。 [DateTime](../data-types/datetime.md)。 -- `interval` — 窗口间隔 [Interval](../data-types/special-data-types/interval.md)。 +- `interval` — [Interval](../data-types/special-data-types/interval.md) 中的窗口间隔。 - `timezone` — [时区名称](../../operations/server-configuration-parameters/settings.md#timezone)(可选)。 **返回值** -- 相应翻滚窗口的包含下界。[DateTime](../data-types/datetime.md)、[Tuple](../data-types/tuple.md) 或 [UInt32](../data-types/int-uint.md)。 +- 对应翻转窗口的排除上限。 [DateTime](../data-types/datetime.md),[Tuple](../data-types/tuple.md) 或 [UInt32](../data-types/int-uint.md)。 **示例** @@ -126,7 +126,7 @@ SELECT tumbleEnd(now(), toIntervalDay('1')); ## hop {#hop} -跳动时间窗口具有固定的持续时间(`window_interval`)并按指定的跳动间隔(`hop_interval`)进行跳动。如果 `hop_interval` 小于 `window_interval`,则跳动窗口是重叠的。因此,记录可以分配到多个窗口。 +跳跃时间窗口具有固定的持续时间(`window_interval`)并按指定的跳跃间隔(`hop_interval`)跳跃。如果 `hop_interval` 小于 `window_interval`,则跳跃窗口会重叠。因此,记录可以被分配到多个窗口。 ```sql hop(time_attr, hop_interval, window_interval [, timezone]) @@ -135,16 +135,16 @@ hop(time_attr, hop_interval, window_interval [, timezone]) **参数** - `time_attr` — 日期和时间。 [DateTime](../data-types/datetime.md)。 -- `hop_interval` — 正的跳动间隔。[Interval](../data-types/special-data-types/interval.md)。 -- `window_interval` — 正的窗口间隔。[Interval](../data-types/special-data-types/interval.md)。 +- `hop_interval` — 正的跳跃间隔。 [Interval](../data-types/special-data-types/interval.md)。 +- `window_interval` — 正的窗口间隔。 [Interval](../data-types/special-data-types/interval.md)。 - `timezone` — [时区名称](../../operations/server-configuration-parameters/settings.md#timezone)(可选)。 **返回值** -- 相应跳动窗口的包含下界和不包含上界。[Tuple](../data-types/tuple.md)([DateTime](../data-types/datetime.md), [DateTime](../data-types/datetime.md))。 +- 对应跳跃窗口的包含下限和排除上限。 [Tuple](../data-types/tuple.md)([DateTime](../data-types/datetime.md), [DateTime](../data-types/datetime.md))。 :::note -由于一个记录可以分配到多个跳动窗口,因此,当在 **没有** `WINDOW VIEW` 的情况下使用跳动函数时,该函数仅返回 **第一个** 窗口的边界。 +由于一条记录可以被分配到多个跳跃窗口,因此在 **不使用** `WINDOW VIEW` 的情况下调用跳跃函数时,该函数仅返回 **第一个** 窗口的边界。 ::: **示例** @@ -165,26 +165,27 @@ SELECT hop(now(), INTERVAL '1' DAY, INTERVAL '2' DAY); ## hopStart {#hopstart} -返回相应 [跳动窗口](#hop) 的包含下界。 +返回对应 [跳跃窗口](#hop) 的包含下限。 **语法** ```sql hopStart(time_attr, hop_interval, window_interval [, timezone]); ``` + **参数** - `time_attr` — 日期和时间。 [DateTime](../data-types/datetime.md)。 -- `hop_interval` — 正的跳动间隔。[Interval](../data-types/special-data-types/interval.md)。 -- `window_interval` — 正的窗口间隔。[Interval](../data-types/special-data-types/interval.md)。 +- `hop_interval` — 正的跳跃间隔。 [Interval](../data-types/special-data-types/interval.md)。 +- `window_interval` — 正的窗口间隔。 [Interval](../data-types/special-data-types/interval.md)。 - `timezone` — [时区名称](../../operations/server-configuration-parameters/settings.md#timezone)(可选)。 **返回值** -- 相应跳动窗口的包含下界。[DateTime](../data-types/datetime.md)、[Tuple](../data-types/tuple.md) 或 [UInt32](../data-types/int-uint.md)。 +- 对应跳跃窗口的包含下限。 [DateTime](../data-types/datetime.md),[Tuple](../data-types/tuple.md) 或 [UInt32](../data-types/int-uint.md)。 :::note -由于一个记录可以分配到多个跳动窗口,因此,当在 **没有** `WINDOW VIEW` 的情况下使用跳动函数时,该函数仅返回 **第一个** 窗口的边界。 +由于一条记录可以被分配到多个跳跃窗口,因此在 **不使用** `WINDOW VIEW` 的情况下调用跳跃函数时,该函数仅返回 **第一个** 窗口的边界。 ::: **示例** @@ -205,26 +206,27 @@ SELECT hopStart(now(), INTERVAL '1' DAY, INTERVAL '2' DAY); ## hopEnd {#hopend} -返回相应 [跳动窗口](#hop) 的不包含上界。 +返回对应 [跳跃窗口](#hop) 的排除上限。 **语法** ```sql hopEnd(time_attr, hop_interval, window_interval [, timezone]); ``` + **参数** - `time_attr` — 日期和时间。 [DateTime](../data-types/datetime.md)。 -- `hop_interval` — 正的跳动间隔。[Interval](../data-types/special-data-types/interval.md)。 -- `window_interval` — 正的窗口间隔。[Interval](../data-types/special-data-types/interval.md)。 +- `hop_interval` — 正的跳跃间隔。 [Interval](../data-types/special-data-types/interval.md)。 +- `window_interval` — 正的窗口间隔。 [Interval](../data-types/special-data-types/interval.md)。 - `timezone` — [时区名称](../../operations/server-configuration-parameters/settings.md#timezone)(可选)。 **返回值** -- 相应跳动窗口的不包含上界。[DateTime](../data-types/datetime.md)、[Tuple](../data-types/tuple.md) 或 [UInt32](../data-types/int-uint.md)。 +- 对应跳跃窗口的排除上限。 [DateTime](../data-types/datetime.md),[Tuple](../data-types/tuple.md) 或 [UInt32](../data-types/int-uint.md)。 :::note -由于一个记录可以分配到多个跳动窗口,因此,当在 **没有** `WINDOW VIEW` 的情况下使用跳动函数时,该函数仅返回 **第一个** 窗口的边界。 +由于一条记录可以被分配到多个跳跃窗口,因此在 **不使用** `WINDOW VIEW` 的情况下调用跳跃函数时,该函数仅返回 **第一个** 窗口的边界。 ::: **示例** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/time-window-functions.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/time-window-functions.md.hash index 3414af55c58..e0c9bde2353 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/time-window-functions.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/time-window-functions.md.hash @@ -1 +1 @@ -d8eddb3e1b038acb +9ecc5db1bef322a6 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/tuple-functions.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/tuple-functions.md index f9096b775d5..634c8378f97 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/tuple-functions.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/tuple-functions.md @@ -1,16 +1,14 @@ --- 'description': 'Tuple Functions 的文档' 'sidebar_label': '元组' -'sidebar_position': 180 'slug': '/sql-reference/functions/tuple-functions' 'title': '元组函数' +'doc_type': 'reference' --- ## tuple {#tuple} -一个允许将多个列分组的函数。 -对于类型为 T1, T2, ... 的列 C1, C2, ...,如果它们的名称是唯一的,并且可以视为未引用的标识符,则返回包含这些列的命名元组 Tuple(C1 T1, C2 T2, ...),否则返回 Tuple(T1, T2, ...)。执行此函数没有成本。 -元组通常用作 IN 操作符参数的中间值,或用于创建 lambda 函数的形式参数列表。元组不能写入表中。 +一个允许将多个列分组的函数。对于类型为 `T1, T2, ...` 的列 `C1, C2, ...`,它返回 `Tuple(T1, T2, ...)`。如果设置 [`enable_named_columns_in_function_tuple`](/operations/settings/settings#enable_named_columns_in_function_tuple) 被启用,那么它返回 `Tuple(C1 T1, C2 T2, ...)`,包含这些列(如果它们的名称是唯一的并且可以被视为未引用的标识符)。执行该函数没有成本。元组通常用作 IN 操作符的参数的中间值,或者用于创建 lambda 函数的形式参数列表。元组不能被写入表中。 该函数实现了操作符 `(x, y, ...)`。 @@ -24,7 +22,7 @@ tuple(x, y, ...) 一个允许从元组中获取列的函数。 -如果第二个参数是一个数字 `index`,则表示列索引,从 1 开始。如果第二个参数是字符串 `name`,则表示元素的名称。此外,我们可以提供第三个可选参数,当索引越界或名称没有元素时,返回默认值,而不是抛出异常。第二和第三个参数如果提供,则必须是常量。执行此函数没有成本。 +如果第二个参数是数字 `index`,则它是从 1 开始的列索引。如果第二个参数是字符串 `name`,则表示元素的名称。此外,我们可以提供第三个可选参数,当索引越界或不存在该名称的元素时,返回默认值而不是抛出异常。如果提供,第二和第三个参数必须是常量。执行该函数没有成本。 该函数实现了操作符 `x.index` 和 `x.name`。 @@ -39,7 +37,7 @@ tupleElement(tuple, name, [, default_value]) 在调用位置执行 [tuple](/sql-reference/data-types/tuple) 元素的语法替换。 -结果列的名称是实现特定的并且可能会变化。请勿假定在 `untuple` 之后的特定列名称。 +结果列的名称是特定于实现的,并且有可能变化。不要假设 `untuple` 后的具体列名称。 **语法** @@ -47,15 +45,15 @@ tupleElement(tuple, name, [, default_value]) untuple(x) ``` -您可以使用 `EXCEPT` 表达式在查询结果中跳过列。 +可以使用 `EXCEPT` 表达式跳过查询结果中的列。 **参数** -- `x` — 一个 `tuple` 函数、列或元素元组。 [Tuple](../data-types/tuple.md)。 +- `x` — 一个 `tuple` 函数、列或元素的元组。 [Tuple](../data-types/tuple.md)。 **返回值** -- None. +- 无。 **示例** @@ -111,7 +109,7 @@ SELECT untuple((* EXCEPT (v2, v3),)) FROM kv; └─────┴────┴────┴────┴───────────┘ ``` -**参考** +**另见** - [Tuple](../data-types/tuple.md) @@ -130,14 +128,14 @@ tupleHammingDistance(tuple1, tuple2) - `tuple1` — 第一个元组。 [Tuple](../data-types/tuple.md)。 - `tuple2` — 第二个元组。 [Tuple](../data-types/tuple.md)。 -元组的元素类型应该相同。 +元组应该具有相同类型的元素。 **返回值** - 汉明距离。 :::note -结果类型的计算方式与 [算术函数](../../sql-reference/functions/arithmetic-functions.md) 的计算一致,基于输入元组中元素的数量。 +结果类型的计算方式与 [算术函数](../../sql-reference/functions/arithmetic-functions.md) 相同,基于输入元组中的元素数量。 ::: ```sql @@ -171,7 +169,7 @@ SELECT tupleHammingDistance((1, 2, 3), (3, 2, 1)) AS HammingDistance; └─────────────────┘ ``` -可以与 [MinHash](../../sql-reference/functions/hash-functions.md#ngramminhash) 函数一起使用,检测半重复字符串: +可以与 [MinHash](../../sql-reference/functions/hash-functions.md#ngramMinHash) 函数结合使用,以检测半重复字符串: ```sql SELECT tupleHammingDistance(wordShingleMinHash(string), wordShingleMinHashCaseInsensitive(string)) AS HammingDistance @@ -188,8 +186,7 @@ FROM (SELECT 'ClickHouse is a column-oriented database management system for onl ## tupleToNameValuePairs {#tupletonamevaluepairs} -将命名元组转换为 (名称, 值) 对的数组。对于 `Tuple(a T, b T, ..., c T)` 返回 `Array(Tuple(String, T), ...)` -其中 `Strings` 表示元组的命名字段,`T` 是与这些名称关联的值。元组中的所有值应该是同一类型。 +将命名元组转换为 (名称, 值) 对的数组。对于 `Tuple(a T, b T, ..., c T)` 返回 `Array(Tuple(String, T), ...)`,其中 `Strings` 表示元组的命名字段,`T` 是与这些名称关联的值。元组中的所有值应具有相同类型。 **语法** @@ -199,11 +196,11 @@ tupleToNameValuePairs(tuple) **参数** -- `tuple` — 命名元组。 [Tuple](../data-types/tuple.md) 具有任何类型的值。 +- `tuple` — 命名元组。 [Tuple](../data-types/tuple.md),具有任意类型的值。 **返回值** -- 一个包含 (名称, 值) 对的数组。 [Array](../data-types/array.md)([Tuple](../data-types/tuple.md)([String](../data-types/string.md), ...))。 +- 具有 (名称, 值) 对的数组。 [Array](../data-types/array.md)([Tuple](../data-types/tuple.md)([String](../data-types/string.md), ...))。 **示例** @@ -226,7 +223,7 @@ SELECT tupleToNameValuePairs(col) FROM tupletest; └───────────────────────────────────────┘ ``` -可以使用此函数将列转换为行: +可以使用该函数将列转换为行: ```sql CREATE TABLE tupletest (col Tuple(CPU Float64, Memory Float64, Disk Float64)) ENGINE = Memory; @@ -246,7 +243,7 @@ SELECT arrayJoin(tupleToNameValuePairs(col)) FROM tupletest; └───────────────────────────────────────┘ ``` -如果将简单元组传递给该函数,ClickHouse 将使用值的索引作为它们的名称: +如果将简单元组传递给该函数,ClickHouse 会使用值的索引作为它们的名称: ```sql SELECT tupleToNameValuePairs(tuple(3, 2, 1)); @@ -262,7 +259,7 @@ SELECT tupleToNameValuePairs(tuple(3, 2, 1)); ## tupleNames {#tuplenames} -将元组转换为列名称的数组。对于 `Tuple(a T, b T, ...)` 形式的元组,它返回一个字符串数组,表示元组的命名列。如果元组元素没有显式名称,则将使用它们的索引作为列名称。 +将元组转换为列名称的数组。对于形式为 `Tuple(a T, b T, ...)` 的元组,它返回一个字符串数组,表示元组的命名列。如果元组元素没有显式名称,则将使用它们的索引作为列名称。 **语法** @@ -272,11 +269,11 @@ tupleNames(tuple) **参数** -- `tuple` — 命名元组。 [Tuple](../../sql-reference/data-types/tuple.md) 具有任何类型的值。 +- `tuple` — 命名元组。 [Tuple](../../sql-reference/data-types/tuple.md),具有任意类型的值。 **返回值** -- 一个包含字符串的数组。 +- 一个字符串数组。 类型: [Array](../../sql-reference/data-types/array.md)([Tuple](../../sql-reference/data-types/tuple.md)([String](../../sql-reference/data-types/string.md), ...))。 @@ -300,7 +297,7 @@ SELECT tupleNames(col) FROM tupletest; └──────────────────────────┘ ``` -如果将简单元组传递给该函数,ClickHouse 将使用列的索引作为它们的名称: +如果将简单元组传递给该函数,ClickHouse 会使用列的索引作为它们的名称: ```sql SELECT tupleNames(tuple(3, 2, 1)); @@ -425,7 +422,7 @@ SELECT tupleMultiply((1, 2), (2, 3)); ## tupleDivide {#tupledivide} -计算两个相同大小的元组的对应值的除法。请注意,除以零将返回 `inf`。 +计算两个相同大小的元组的对应值的除法。注意,除以零将返回 `inf`。 **语法** @@ -460,7 +457,7 @@ SELECT tupleDivide((1, 2), (2, 3)); ## tupleNegate {#tuplenegate} -计算元组值的否定。 +计算元组值的取反。 **语法** @@ -474,7 +471,7 @@ tupleNegate(tuple) **返回值** -- 否定结果的元组。 [Tuple](../data-types/tuple.md)。 +- 取反结果的元组。 [Tuple](../data-types/tuple.md)。 **示例** @@ -505,11 +502,11 @@ tupleMultiplyByNumber(tuple, number) **参数** - `tuple` — [Tuple](../data-types/tuple.md)。 -- `number` — 乘数。 [Int/UInt](../data-types/int-uint.md), [Float](../data-types/float.md) 或 [Decimal](../data-types/decimal.md)。 +- `number` — 乘数。 [Int/UInt](../data-types/int-uint.md)、[Float](../data-types/float.md) 或 [Decimal](../data-types/decimal.md)。 **返回值** -- 乘法结果的元组。 [Tuple](../data-types/tuple.md)。 +- 乘以值的元组。 [Tuple](../data-types/tuple.md)。 **示例** @@ -529,7 +526,7 @@ SELECT tupleMultiplyByNumber((1, 2), -2.1); ## tupleDivideByNumber {#tupledividebynumber} -返回一个所有值都除以一个数字的元组。请注意,除以零将返回 `inf`。 +返回一个所有值都除以一个数字的元组。注意,除以零将返回 `inf`。 **语法** @@ -540,11 +537,11 @@ tupleDivideByNumber(tuple, number) **参数** - `tuple` — [Tuple](../data-types/tuple.md)。 -- `number` — 除数。 [Int/UInt](../data-types/int-uint.md), [Float](../data-types/float.md) 或 [Decimal](../data-types/decimal.md)。 +- `number` — 除数。 [Int/UInt](../data-types/int-uint.md)、[Float](../data-types/float.md) 或 [Decimal](../data-types/decimal.md)。 **返回值** -- 除法结果的元组。 [Tuple](../data-types/tuple.md)。 +- 除以值的元组。 [Tuple](../data-types/tuple.md)。 **示例** @@ -564,7 +561,7 @@ SELECT tupleDivideByNumber((1, 2), 0.5); ## tupleConcat {#tupleconcat} -合并作为参数传递的元组。 +组合作为参数传递的元组。 ```sql tupleConcat(tuples) @@ -572,7 +569,7 @@ tupleConcat(tuples) **参数** -- `tuples` – 任意数量的 [Tuple](../data-types/tuple.md) 类型参数。 +- `tuples` – 任意数量的 [Tuple](../data-types/tuple.md) 类型的参数。 **示例** @@ -588,7 +585,7 @@ SELECT tupleConcat((1, 2), (3, 4), (true, false)) AS res ## tupleIntDiv {#tupleintdiv} -执行一个分子元组和一个分母元组的整数除法,并返回一个商的元组。 +对一个数值元组和一个分母元组进行整数除法,并返回一个商元组。 **语法** @@ -598,16 +595,16 @@ tupleIntDiv(tuple_num, tuple_div) **参数** -- `tuple_num`: 分子值的元组。 [Tuple](../data-types/tuple) 的数值类型。 -- `tuple_div`: 除数值的元组。 [Tuple](../data-types/tuple) 的数值类型。 +- `tuple_num`: 数值的元组。[Tuple](../data-types/tuple)。 +- `tuple_div`: 除数的元组。[Tuple](../data-types/tuple)。 **返回值** -- `tuple_num` 和 `tuple_div` 的商的元组。 [Tuple](../data-types/tuple) 的整数值。 +- `tuple_num` 和 `tuple_div` 的商元组。 [Tuple](../data-types/tuple) 的整数值。 **实现细节** -- 如果 `tuple_num` 或 `tuple_div` 包含非整数值,则对每个非整数分子或除数的结果通过四舍五入到最接近的整数来计算。 +- 如果 `tuple_num` 或 `tuple_div` 包含非整型值,则结果通过对每个非整型分子或除数进行四舍五入到最近的整数来计算。 - 除以 0 时将抛出错误。 **示例** @@ -642,7 +639,7 @@ SELECT tupleIntDiv((15, 10, 5), (5.5, 5.5, 5.5)); ## tupleIntDivOrZero {#tupleintdivorzero} -类似于 [tupleIntDiv](#tupleintdiv),它执行一个分子元组和一个分母元组的整数除法,并返回一个商的元组。它不会因除数为 0 而抛出错误,而是将商返回为 0。 +与 [tupleIntDiv](#tupleintdiv) 类似,执行一个数值元组和一个分母元组的整数除法,并返回一个商元组。它不会对 0 除数抛出错误,而是将商返回为 0。 **语法** @@ -650,17 +647,17 @@ SELECT tupleIntDiv((15, 10, 5), (5.5, 5.5, 5.5)); tupleIntDivOrZero(tuple_num, tuple_div) ``` -- `tuple_num`: 分子值的元组。 [Tuple](../data-types/tuple) 的数值类型。 -- `tuple_div`: 除数值的元组。 [Tuple](../data-types/tuple) 的数值类型。 +- `tuple_num`: 数值的元组。[Tuple](../data-types/tuple)。 +- `tuple_div`: 除数的元组。[Tuple](../data-types/tuple)。 **返回值** -- `tuple_num` 和 `tuple_div` 的商的元组。 [Tuple](../data-types/tuple) 的整数值。 +- `tuple_num` 和 `tuple_div` 的商元组。 [Tuple](../data-types/tuple) 的整数值。 - 对于除数为 0 的商返回 0。 **实现细节** -- 如果 `tuple_num` 或 `tuple_div` 包含非整数值,则对每个非整数分子或除数的结果通过四舍五入到最接近的整数来计算,类似于 [tupleIntDiv](#tupleintdiv)。 +- 如果 `tuple_num` 或 `tuple_div` 包含非整型值,则结果通过对每个非整型分子或除数进行四舍五入到最近的整数进行计算,如同 [tupleIntDiv](#tupleintdiv) 一样。 **示例** @@ -680,7 +677,7 @@ SELECT tupleIntDivOrZero((5, 10, 15), (0, 0, 0)); ## tupleIntDivByNumber {#tupleintdivbynumber} -对一个分子元组进行整数除法并以给定的除数返回一个商的元组。 +对一个数值元组和给定的除数执行整数除法,并返回一个商元组。 **语法** @@ -690,16 +687,16 @@ tupleIntDivByNumber(tuple_num, div) **参数** -- `tuple_num`: 分子值的元组。 [Tuple](../data-types/tuple) 的数值类型。 -- `div`: 除数值。 [Numeric](../data-types/int-uint.md) 类型。 +- `tuple_num`: 数值的元组。[Tuple](../data-types/tuple)。 +- `div`: 除数值。[Numeric](../data-types/int-uint.md) 类型。 **返回值** -- `tuple_num` 和 `div` 的商的元组。 [Tuple](../data-types/tuple) 的整数值。 +- `tuple_num` 和 `div` 的商元组。 [Tuple](../data-types/tuple) 的整数值。 **实现细节** -- 如果 `tuple_num` 或 `div` 包含非整数值,则对每个非整数分子或除数的结果通过四舍五入到最接近的整数来计算。 +- 如果 `tuple_num` 或 `div` 包含非整型值,则结果通过对每个非整型分子或除数进行四舍五入到最近的整数进行计算。 - 除以 0 时将抛出错误。 **示例** @@ -734,7 +731,7 @@ SELECT tupleIntDivByNumber((15.2, 10.7, 5.5), 5.8); ## tupleIntDivOrZeroByNumber {#tupleintdivorzerobynumber} -类似于 [tupleIntDivByNumber](#tupleintdivbynumber),它对一个分子元组进行整数除法并以给定的除数返回一个商的元组。它不会因除数为 0 而抛出错误,而是将商返回为 0。 +与 [tupleIntDivByNumber](#tupleintdivbynumber) 类似,执行一个数值元组和给定分母的整数除法,并返回一个商元组。它不会对 0 除数抛出错误,而是将商返回为 0。 **语法** @@ -744,17 +741,17 @@ tupleIntDivOrZeroByNumber(tuple_num, div) **参数** -- `tuple_num`: 分子值的元组。 [Tuple](../data-types/tuple) 的数值类型。 -- `div`: 除数值。 [Numeric](../data-types/int-uint.md) 类型。 +- `tuple_num`: 数值的元组。[Tuple](../data-types/tuple)。 +- `div`: 除数值。[Numeric](../data-types/int-uint.md) 类型。 **返回值** -- `tuple_num` 和 `div` 的商的元组。 [Tuple](../data-types/tuple) 的整数值。 +- `tuple_num` 和 `div` 的商元组。 [Tuple](../data-types/tuple) 的整数值。 - 对于除数为 0 的商返回 0。 **实现细节** -- 如果 `tuple_num` 或 `div` 包含非整数值,则对每个非整数分子或除数的结果通过四舍五入到最接近的整数来计算,类似于 [tupleIntDivByNumber](#tupleintdivbynumber)。 +- 如果 `tuple_num` 或 `div` 包含非整型值,则结果通过对每个非整型分子或除数进行四舍五入到最近的整数进行计算,如同 [tupleIntDivByNumber](#tupleintdivbynumber) 一样。 **示例** @@ -798,13 +795,13 @@ tupleModulo(tuple_num, tuple_mod) **参数** -- `tuple_num`: 分子值的元组。 [Tuple](../data-types/tuple) 的数值类型。 -- `tuple_div`: 除数值的元组。 [Tuple](../data-types/tuple) 的数值类型。 +- `tuple_num`: 数值的元组。[Tuple](../data-types/tuple)。 +- `tuple_div`: 模值的元组。[Tuple](../data-types/tuple)。 **返回值** -- `tuple_num` 和 `tuple_div` 之间除法的余数元组。 [Tuple](../data-types/tuple) 的非零整数值。 -- 对于除以零将抛出错误。 +- `tuple_num` 和 `tuple_div` 的余数的元组。 [Tuple](../data-types/tuple) 的非零整数值。 +- 除以零时抛出错误。 **示例** @@ -824,7 +821,7 @@ SELECT tupleModulo((15, 10, 5), (5, 3, 2)); ## tupleModuloByNumber {#tuplemodulobynumber} -返回一个元组的模(余数)与给定除数的除法结果。 +返回一元组和给定除数的模(余数)的元组。 **语法** @@ -834,13 +831,13 @@ tupleModuloByNumber(tuple_num, div) **参数** -- `tuple_num`: 分子值的元组。 [Tuple](../data-types/tuple) 的数值类型。 -- `div`: 除数值。 [Numeric](../data-types/int-uint.md) 类型。 +- `tuple_num`: 数值的元组。[Tuple](../data-types/tuple)。 +- `div`: 除数值。[Numeric](../data-types/int-uint.md) 类型。 **返回值** -- `tuple_num` 和 `div` 之间除法的余数元组。 [Tuple](../data-types/tuple) 的非零整数值。 -- 对于除以零将抛出错误。 +- `tuple_num` 和 `div` 的余数的元组。 [Tuple](../data-types/tuple) 的非零整数值。 +- 除以零时抛出错误。 **示例** @@ -860,7 +857,7 @@ SELECT tupleModuloByNumber((15, 10, 5), 2); ## flattenTuple {#flattentuple} -从嵌套的命名 `input` 元组返回一个扁平化的 `output` 元组。`output` 元组的元素是来自原始 `input` 元组的路径。例如: `Tuple(a Int, Tuple(b Int, c Int)) -> Tuple(a Int, b Int, c Int)`。`flattenTuple` 可用于将 `Object` 类型的所有路径选择为单独的列。 +从嵌套的命名 `input` 元组合并返回一个扁平化的 `output` 元组。`output` 元组的元素是来自原始 `input` 元组的路径。例如: `Tuple(a Int, Tuple(b Int, c Int)) -> Tuple(a Int, b Int, c Int)`。 `flattenTuple` 可以用于将类型为 `Object` 的所有路径选择为单独的列。 **语法** @@ -870,11 +867,11 @@ flattenTuple(input) **参数** -- `input`: 要扁平化的嵌套命名元组。 [Tuple](../data-types/tuple)。 +- `input`: 要扁平化的嵌套命名元组。[Tuple](../data-types/tuple)。 **返回值** -- 其元素是来自原始 `input` 的路径的 `output` 元组。 [Tuple](../data-types/tuple)。 +- 返回的 `output` 元组,其元素是原始 `input` 的路径。 [Tuple](../data-types/tuple)。 **示例** @@ -896,7 +893,7 @@ SELECT flattenTuple(t) FROM t_flatten_tuple; ## Distance functions {#distance-functions} -所有支持的函数在 [距离函数文档](../../sql-reference/functions/distance-functions.md) 中进行了描述。 +所有支持的函数在 [distance functions documentation](../../sql-reference/functions/distance-functions.md) 中有描述。 - - - diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/udf.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/udf.md.hash index 322ab19cdfc..643c872b302 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/udf.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/udf.md.hash @@ -1 +1 @@ -ed3bc543b7c32a40 +79670f26c563e2fd diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/ulid-functions.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/ulid-functions.md index 9f85780b49e..984b2bf5431 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/ulid-functions.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/ulid-functions.md @@ -1,9 +1,9 @@ --- -'description': 'ULID的处理函数文档' +'description': '处理 ULID 的函数的文档' 'sidebar_label': 'ULID' -'sidebar_position': 190 'slug': '/sql-reference/functions/ulid-functions' -'title': '处理ULID的函数' +'title': '与 ULID 配合使用的函数' +'doc_type': 'reference' --- @@ -21,13 +21,13 @@ generateULID([x]) **参数** -- `x` — [表达式](/sql-reference/syntax#expressions),结果为任何 [支持的数据类型](/sql-reference/data-types)。结果值被丢弃,但表达式本身在函数在一个查询中被多次调用时用于绕过 [常见子表达式消除](/sql-reference/functions/overview#common-subexpression-elimination)。可选参数。 +- `x` — [表达式](/sql-reference/syntax#expressions),结果为任何 [支持的数据类型](/sql-reference/data-types)。结果值将被丢弃,但该表达式本身用于绕过 [公共子表达式消除](/sql-reference/functions/overview#common-subexpression-elimination),如果函数在一个查询中被多次调用。可选参数。 **返回值** -[FixedString](../data-types/fixedstring.md) 类型值。 +[FixedString](../data-types/fixedstring.md) 类型的值。 -**用法示例** +**使用示例** ```sql SELECT generateULID() @@ -39,7 +39,7 @@ SELECT generateULID() └────────────────────────────┘ ``` -**在一行中生成多个值的用法示例** +**如果需要在一行中生成多个值的使用示例** ```sql SELECT generateULID(1), generateULID(2) @@ -63,14 +63,14 @@ ULIDStringToDateTime(ulid[, timezone]) **参数** -- `ulid` — 输入的 ULID。 [String](../data-types/string.md) 或 [FixedString(26)](../data-types/fixedstring.md)。 -- `timezone` — 返回值的 [时区名称](../../operations/server-configuration-parameters/settings.md#timezone)(可选)。 [String](../data-types/string.md)。 +- `ulid` — 输入的 ULID。[String](../data-types/string.md) 或 [FixedString(26)](../data-types/fixedstring.md)。 +- `timezone` — 返回值的 [时区名称](../../operations/server-configuration-parameters/settings.md#timezone)(可选)。[String](../data-types/string.md)。 **返回值** -- 毫秒精度的时间戳。 [DateTime64(3)](../data-types/datetime64.md)。 +- 毫秒精度的时间戳。[DateTime64(3)](../data-types/datetime64.md)。 -**用法示例** +**使用示例** ```sql SELECT ULIDStringToDateTime('01GNB2S2FGN2P93QPXDNB4EN2R') @@ -82,14 +82,14 @@ SELECT ULIDStringToDateTime('01GNB2S2FGN2P93QPXDNB4EN2R') └────────────────────────────────────────────────────┘ ``` -## 另见 {#see-also} +## 另请参阅 {#see-also} - [UUID](../../sql-reference/functions/uuid-functions.md) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/ulid-functions.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/ulid-functions.md.hash index 228ab043dd3..5188ce53332 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/ulid-functions.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/ulid-functions.md.hash @@ -1 +1 @@ -0b9a26a31586b077 +101b8ed4d27155a3 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/uniqtheta-functions.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/uniqtheta-functions.md index 1d377edfdad..9272b6b218c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/uniqtheta-functions.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/uniqtheta-functions.md @@ -1,20 +1,20 @@ --- 'description': 'uniqTheta 函数的文档' 'sidebar_label': 'uniqTheta' -'sidebar_position': 210 'slug': '/sql-reference/functions/uniqtheta-functions' 'title': 'uniqTheta 函数' +'doc_type': 'reference' --- # uniqTheta 函数 -uniqTheta 函数用于两个 uniqThetaSketch 对象之间进行集合操作计算,如 ∪ / ∩ / ×(并集/交集/补集),返回一个包含结果的新的 uniqThetaSketch 对象。 +uniqTheta 函数用于两个 uniqThetaSketch 对象之间进行集合操作计算,例如 ∪ / ∩ / ×(并集/交集/差集),返回一个新的 uniqThetaSketch 对象,其中包含结果。 -uniqThetaSketch 对象是通过聚合函数 uniqTheta 与 -State 构建的。 +uniqThetaSketch 对象通过聚合函数 uniqTheta 构造,使用 -State。 UniqThetaSketch 是一种存储近似值集合的数据结构。 -有关 RoaringBitmap 的更多信息,请参见: [Theta Sketch Framework](https://datasketches.apache.org/docs/Theta/ThetaSketchFramework.html)。 +有关 RoaringBitmap 的更多信息,请参阅:[Theta Sketch Framework](https://datasketches.apache.org/docs/Theta/ThetaSketchFramework.html)。 ## uniqThetaUnion {#uniqthetaunion} @@ -31,9 +31,9 @@ uniqThetaUnion(uniqThetaSketch,uniqThetaSketch) **示例** ```sql -select finalizeAggregation(uniqThetaUnion(a, b)) as a_union_b, finalizeAggregation(a) as a_cardinality, finalizeAggregation(b) as b_cardinality -from -(select arrayReduce('uniqThetaState',[1,2]) as a, arrayReduce('uniqThetaState',[2,3,4]) as b ); +SELECT finalizeAggregation(uniqThetaUnion(a, b)) AS a_union_b, finalizeAggregation(a) AS a_cardinality, finalizeAggregation(b) AS b_cardinality +FROM +(SELECT arrayReduce('uniqThetaState',[1,2]) AS a, arrayReduce('uniqThetaState',[2,3,4]) AS b ); ``` ```text @@ -57,9 +57,9 @@ uniqThetaIntersect(uniqThetaSketch,uniqThetaSketch) **示例** ```sql -select finalizeAggregation(uniqThetaIntersect(a, b)) as a_intersect_b, finalizeAggregation(a) as a_cardinality, finalizeAggregation(b) as b_cardinality -from -(select arrayReduce('uniqThetaState',[1,2]) as a, arrayReduce('uniqThetaState',[2,3,4]) as b ); +SELECT finalizeAggregation(uniqThetaIntersect(a, b)) AS a_intersect_b, finalizeAggregation(a) AS a_cardinality, finalizeAggregation(b) AS b_cardinality +FROM +(SELECT arrayReduce('uniqThetaState',[1,2]) AS a, arrayReduce('uniqThetaState',[2,3,4]) AS b ); ``` ```text @@ -83,9 +83,9 @@ uniqThetaNot(uniqThetaSketch,uniqThetaSketch) **示例** ```sql -select finalizeAggregation(uniqThetaNot(a, b)) as a_not_b, finalizeAggregation(a) as a_cardinality, finalizeAggregation(b) as b_cardinality -from -(select arrayReduce('uniqThetaState',[2,3,4]) as a, arrayReduce('uniqThetaState',[1,2]) as b ); +SELECT finalizeAggregation(uniqThetaNot(a, b)) AS a_not_b, finalizeAggregation(a) AS a_cardinality, finalizeAggregation(b) AS b_cardinality +FROM +(SELECT arrayReduce('uniqThetaState',[2,3,4]) AS a, arrayReduce('uniqThetaState',[1,2]) AS b ); ``` ```text diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/uniqtheta-functions.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/uniqtheta-functions.md.hash index 5464955650c..dcf769e3fb6 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/uniqtheta-functions.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/uniqtheta-functions.md.hash @@ -1 +1 @@ -d5d4bb549d0993b7 +c28fc8b31d9d4da8 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/url-functions.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/url-functions.md index bd901956e14..3eb1142013b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/url-functions.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/url-functions.md @@ -1,21 +1,21 @@ --- -'description': '处理URL的函数的文档' +'description': '处理 URL 的函数的文档' 'sidebar_label': 'URLs' -'sidebar_position': 200 'slug': '/sql-reference/functions/url-functions' -'title': '处理URL的函数' +'title': '处理 URL 的函数' +'doc_type': 'reference' --- # 处理 URL 的函数 :::note -本节提到的函数经过优化,以实现最大的性能,并且在大多数情况下不遵循 RFC-3986 标准。实现 RFC-3986 的函数在其函数名称后附加 `RFC`,通常较慢。 +本节中提到的函数经过优化以实现最大性能,并且在大多数情况下不遵循 RFC-3986 标准。实现 RFC-3986 的函数名称后会附加 `RFC`,通常速度较慢。 ::: -在处理不包含用户字符串或 `@` 符号的公开注册域名时,通常可以使用非 `RFC` 函数变体。下表详细说明了 URL 中哪些符号可以 (`✔`) 或不可以 (`✗`) 被各自的 `RFC` 和非 `RFC` 变体解析: +在处理不包含用户字符串或 `@` 符号的公共注册域时,通常可以使用非 `RFC` 函数变体。下表详细列出了在 URL 中各个符号可以 (`✔`) 或不能 (`✗`) 被相应的 `RFC` 和非 `RFC` 变体解析的情况: -|符号 | 非 `RFC` | `RFC` | +|符号 | 非`RFC`| `RFC` | |-------|----------|-------| | ' ' | ✗ |✗ | | \t | ✗ |✗ | @@ -34,17 +34,17 @@ | = | ✗ |✔* | | & | ✗ |✔* | -被标记为 `*` 的符号是 RFC 3986 中的子分隔符,并且在 `@` 符号后允许作为用户信息。 +标记为 `*` 的符号是 RFC 3986 中的子分隔符,允许在 `@` 符号后进行用户信息。 ## 提取 URL 部分的函数 {#functions-that-extract-parts-of-a-url} -如果 URL 中没有相关部分,将返回空字符串。 +如果 URL 中不存在相关部分,将返回空字符串。 ### protocol {#protocol} 从 URL 中提取协议。 -典型的返回值示例: http、https、ftp、mailto、tel、magnet。 +典型返回值的示例: http, https, ftp, mailto, tel, magnet。 ### domain {#domain} @@ -58,9 +58,9 @@ domain(url) **参数** -- `url` — URL. [String](../../sql-reference/data-types/string.md)。 +- `url` — URL。 [String](../../sql-reference/data-types/string.md)。 -URL 可以带协议或不带协议来指定。例如: +URL 可指定带有或不带协议。示例: ```text svn+ssh://some.svn-hosting.com:80/repo/trunk @@ -68,7 +68,7 @@ some.svn-hosting.com:80/repo/trunk https://clickhouse.com/time/ ``` -对于这些示例,`domain` 函数返回以下结果: +在这些示例中,`domain` 函数返回以下结果: ```text some.svn-hosting.com @@ -94,7 +94,7 @@ SELECT domain('svn+ssh://some.svn-hosting.com:80/repo/trunk'); ### domainRFC {#domainrfc} -从 URL 中提取主机名。类似于 [domain](#domain),但符合 RFC 3986。 +从 URL 中提取主机名。与 [domain](#domain) 类似,但符合 RFC 3986。 **语法** @@ -104,7 +104,7 @@ domainRFC(url) **参数** -- `url` — URL. [String](../data-types/string.md)。 +- `url` — URL。 [String](../data-types/string.md)。 **返回值** @@ -126,7 +126,7 @@ SELECT ### domainWithoutWWW {#domainwithoutwww} -返回不带前缀 `www.` 的域名(如果存在)。 +如果存在,则返回没有前缀 `www.` 的域名。 **语法** @@ -136,7 +136,7 @@ domainWithoutWWW(url) **参数** -- `url` — URL. [String](../data-types/string.md)。 +- `url` — URL。 [String](../data-types/string.md)。 **返回值** @@ -156,7 +156,7 @@ SELECT domainWithoutWWW('http://paul@www.example.com:80/'); ### domainWithoutWWWRFC {#domainwithoutwwwrfc} -返回不带前缀 `www.` 的域名(如果存在)。类似于 [domainWithoutWWW](#domainwithoutwww) 但符合 RFC 3986。 +如果存在,则返回没有前缀 `www.` 的域名。与 [domainWithoutWWW](#domainwithoutwww) 类似,但符合 RFC 3986。 **语法** @@ -166,7 +166,7 @@ domainWithoutWWWRFC(url) **参数** -- `url` — URL. [String](../data-types/string.md)。 +- `url` — URL。 [String](../data-types/string.md)。 **返回值** @@ -200,10 +200,10 @@ topLevelDomain(url) **参数** -- `url` — URL. [String](../../sql-reference/data-types/string.md)。 +- `url` — URL。 [String](../../sql-reference/data-types/string.md)。 :::note -URL 可以带协议或不带协议来指定。例如: +URL 可指定带有或不带协议。示例: ```text svn+ssh://some.svn-hosting.com:80/repo/trunk @@ -214,7 +214,7 @@ https://clickhouse.com/time/ **返回值** -- 如果输入字符串可以解析为 URL,则返回域名。否则返回空字符串。 [String](../../sql-reference/data-types/string.md)。 +- 如果输入字符串可以解析为 URL,则返回域名。否则,返回空字符串。 [String](../../sql-reference/data-types/string.md)。 **示例** @@ -234,7 +234,8 @@ SELECT topLevelDomain('svn+ssh://www.some.svn-hosting.com:80/repo/trunk'); ### topLevelDomainRFC {#topleveldomainrfc} -从 URL 中提取顶级域名。类似于 [topLevelDomain](#topleveldomain),但符合 RFC 3986。 +从 URL 中提取顶级域名。 +与 [topLevelDomain](#topleveldomain) 类似,但符合 RFC 3986。 ```sql topLevelDomainRFC(url) @@ -242,10 +243,10 @@ topLevelDomainRFC(url) **参数** -- `url` — URL. [String](../../sql-reference/data-types/string.md)。 +- `url` — URL。 [String](../../sql-reference/data-types/string.md)。 :::note -URL 可以带协议或不带协议来指定。例如: +URL 可指定带有或不带协议。示例: ```text svn+ssh://some.svn-hosting.com:80/repo/trunk @@ -256,7 +257,7 @@ https://clickhouse.com/time/ **返回值** -- 如果输入字符串可以解析为 URL,则返回域名。否则返回空字符串。 [String](../../sql-reference/data-types/string.md)。 +- 如果输入字符串可以解析为 URL,则返回域名。否则,返回空字符串。 [String](../../sql-reference/data-types/string.md)。 **示例** @@ -276,7 +277,10 @@ SELECT topLevelDomain('http://foo:foo%41bar@foo.com'), topLevelDomainRFC('http:/ ### firstSignificantSubdomain {#firstsignificantsubdomain} -返回“第一个显著子域名”。第一个显著子域名对于 `com`、`net`、`org` 或 `co` 是二级域名,否则是三级域名。例如,`firstSignificantSubdomain ('https://news.clickhouse.com/') = 'clickhouse'`,`firstSignificantSubdomain ('https://news.clickhouse.com.tr/') = 'clickhouse'`。显著的二级域名及其他实现细节的列表可能会在未来发生变化。 +返回“第一个显著子域”。 +第一个显著子域是 `com`、`net`、`org` 或 `co` 的二级域名,否则是三级域名。 +例如,`firstSignificantSubdomain ('https://news.clickhouse.com/') = 'clickhouse'`, `firstSignificantSubdomain ('https://news.clickhouse.com.tr/') = 'clickhouse'`。 +“非显著”二级域名的列表和其他实现细节可能在未来更改。 **语法** @@ -286,11 +290,11 @@ firstSignificantSubdomain(url) **参数** -- `url` — URL. [String](../../sql-reference/data-types/string.md)。 +- `url` — URL。 [String](../../sql-reference/data-types/string.md)。 **返回值** -- 第一个显著子域名。 [String](../data-types/string.md)。 +- 第一个显著子域。 [String](../data-types/string.md)。 **示例** @@ -310,7 +314,11 @@ SELECT firstSignificantSubdomain('http://www.example.com/a/b/c?a=b') ### firstSignificantSubdomainRFC {#firstsignificantsubdomainrfc} -返回“第一个显著子域名”。第一个显著子域名对于 `com`、`net`、`org` 或 `co` 是二级域名,否则是三级域名。例如,`firstSignificantSubdomain ('https://news.clickhouse.com/') = 'clickhouse'`,`firstSignificantSubdomain ('https://news.clickhouse.com.tr/') = 'clickhouse'`。显著的二级域名及其他实现细节的列表可能会在未来发生变化。类似于 [firstSignficantSubdomain](#firstsignificantsubdomain),但符合 RFC 1034。 +返回“第一个显著子域”。 +第一个显著子域是 `com`、`net`、`org` 或 `co` 的二级域名,否则是三级域名。 +例如,`firstSignificantSubdomain ('https://news.clickhouse.com/') = 'clickhouse'`, `firstSignificantSubdomain ('https://news.clickhouse.com.tr/') = 'clickhouse'`。 +“非显著”二级域名的列表和其他实现细节可能在未来更改。 +与 [firstSignficantSubdomain](#firstsignificantsubdomain) 类似,但符合 RFC 1034。 **语法** @@ -320,11 +328,11 @@ firstSignificantSubdomainRFC(url) **参数** -- `url` — URL. [String](../../sql-reference/data-types/string.md)。 +- `url` — URL。 [String](../../sql-reference/data-types/string.md)。 **返回值** -- 第一个显著子域名。 [String](../data-types/string.md)。 +- 第一个显著子域。 [String](../data-types/string.md)。 **示例** @@ -346,7 +354,7 @@ SELECT ### cutToFirstSignificantSubdomain {#cuttofirstsignificantsubdomain} -返回域名的一部分,包括顶级子域名,直到“第一个显著子域名”为止。 +返回包括顶级子域到“第一个显著子域”的域的部分。 **语法** @@ -356,11 +364,11 @@ cutToFirstSignificantSubdomain(url) **参数** -- `url` — URL. [String](../../sql-reference/data-types/string.md)。 +- `url` — URL。 [String](../../sql-reference/data-types/string.md)。 **返回值** -- 包含顶级子域名的域名部分,直到第一个显著子域名(如果可能),否则返回空字符串。 [String](../data-types/string.md)。 +- 包括顶级子域到第一个显著子域的域的部分(如果可能),否则返回空字符串。 [String](../data-types/string.md)。 **示例** @@ -383,7 +391,8 @@ SELECT ### cutToFirstSignificantSubdomainRFC {#cuttofirstsignificantsubdomainrfc} -返回域名的一部分,包括顶级子域名,直到“第一个显著子域名”为止。类似于 [cutToFirstSignificantSubdomain](#cuttofirstsignificantsubdomain),但符合 RFC 3986。 +返回包括顶级子域到“第一个显著子域”的域的部分。 +与 [cutToFirstSignificantSubdomain](#cuttofirstsignificantsubdomain) 类似,但符合 RFC 3986。 **语法** @@ -393,11 +402,11 @@ cutToFirstSignificantSubdomainRFC(url) **参数** -- `url` — URL. [String](../../sql-reference/data-types/string.md)。 +- `url` — URL。 [String](../../sql-reference/data-types/string.md)。 **返回值** -- 包含顶级子域名的域名部分,直到第一个显著子域名(如果可能),否则返回空字符串。 [String](../data-types/string.md)。 +- 包括顶级子域到第一个显著子域的域的部分(如果可能),否则返回空字符串。 [String](../data-types/string.md)。 **示例** @@ -419,7 +428,7 @@ SELECT ### cutToFirstSignificantSubdomainWithWWW {#cuttofirstsignificantsubdomainwithwww} -返回域名的一部分,包括顶级子域名,直到“第一个显著子域名”为止,不去掉 `www`。 +返回包括顶级子域到“第一个显著子域”的域的部分,保留 `www`。 **语法** @@ -429,11 +438,11 @@ cutToFirstSignificantSubdomainWithWWW(url) **参数** -- `url` — URL. [String](../../sql-reference/data-types/string.md)。 +- `url` — URL。 [String](../../sql-reference/data-types/string.md)。 **返回值** -- 包含顶级子域名的域名部分,直到第一个显著子域名(带 `www`,如果可能),否则返回空字符串。 [String](../data-types/string.md)。 +- 包括顶级子域到第一个显著子域的域的部分(带 `www`,如果可能),否则返回空字符串。 [String](../data-types/string.md)。 **示例** @@ -456,7 +465,8 @@ SELECT ### cutToFirstSignificantSubdomainWithWWWRFC {#cuttofirstsignificantsubdomainwithwwwrfc} -返回域名的一部分,包括顶级子域名,直到“第一个显著子域名”为止,不去掉 `www`。类似于 [cutToFirstSignificantSubdomainWithWWW](#cuttofirstsignificantsubdomaincustomwithwww),但符合 RFC 3986。 +返回包括顶级子域到“第一个显著子域”的域的部分,保留 `www`。 +与 [cutToFirstSignificantSubdomainWithWWW](#cuttofirstsignificantsubdomaincustomwithwww) 类似,但符合 RFC 3986。 **语法** @@ -466,11 +476,11 @@ cutToFirstSignificantSubdomainWithWWW(url) **参数** -- `url` — URL. [String](../../sql-reference/data-types/string.md)。 +- `url` — URL。 [String](../../sql-reference/data-types/string.md)。 **返回值** -- 包含顶级子域名的域名部分,直到第一个显著子域名(带 "www",如果可能),否则返回空字符串。 [String](../../sql-reference/data-types/string.md)。 +- 包括顶级子域到第一个显著子域的域的部分(带“www”,如果可能),否则返回空字符串。 [String](../data-types/string.md)。 **示例** @@ -492,7 +502,9 @@ SELECT ### cutToFirstSignificantSubdomainCustom {#cuttofirstsignificantsubdomaincustom} -返回域名的一部分,包括顶级子域名,直到第一个显著子域名。接受自定义 [TLD 列表](https://en.wikipedia.org/wiki/List_of_Internet_top-level_domains) 名称。如果您需要一个新的 TLD 列表或有自定义列表,此函数可能会很有用。 +返回包括顶级子域到第一个显著子域的域的部分。 +接受自定义 [TLD 列表](https://en.wikipedia.org/wiki/List_of_Internet_top-level_domains) 名称。 +如果需要新的 TLD 列表或具有自定义列表,此函数可能会很有用。 **配置示例** @@ -513,12 +525,12 @@ cutToFirstSignificantSubdomain(url, tld) **参数** -- `url` — URL. [String](../../sql-reference/data-types/string.md)。 +- `url` — URL。 [String](../../sql-reference/data-types/string.md)。 - `tld` — 自定义 TLD 列表名称。 [String](../../sql-reference/data-types/string.md)。 **返回值** -- 包含顶级子域名的域名部分,直到第一个显著子域名。 [String](../../sql-reference/data-types/string.md)。 +- 返回包括顶级子域到第一个显著子域的域的部分。 [String](../../sql-reference/data-types/string.md)。 **示例** @@ -542,7 +554,10 @@ SELECT cutToFirstSignificantSubdomainCustom('bar.foo.there-is-no-such-domain', ' ### cutToFirstSignificantSubdomainCustomRFC {#cuttofirstsignificantsubdomaincustomrfc} -返回域名的一部分,包括顶级子域名,直到第一个显著子域名。接受自定义 [TLD 列表](https://en.wikipedia.org/wiki/List_of_Internet_top-level_domains) 名称。如果您需要一个新的 TLD 列表或有自定义列表,此函数可能会很有用。类似于 [cutToFirstSignificantSubdomainCustom](#cuttofirstsignificantsubdomaincustom),但符合 RFC 3986。 +返回包括顶级子域到第一个显著子域的域的部分。 +接受自定义 [TLD 列表](https://en.wikipedia.org/wiki/List_of_Internet_top-level_domains) 名称。 +如果需要新的 TLD 列表或具有自定义列表,此函数可能会很有用。 +与 [cutToFirstSignificantSubdomainCustom](#cuttofirstsignificantsubdomaincustom) 类似,但符合 RFC 3986。 **语法** @@ -552,12 +567,12 @@ cutToFirstSignificantSubdomainRFC(url, tld) **参数** -- `url` — URL. [String](../../sql-reference/data-types/string.md)。 +- `url` — URL。 [String](../../sql-reference/data-types/string.md)。 - `tld` — 自定义 TLD 列表名称。 [String](../../sql-reference/data-types/string.md)。 **返回值** -- 包含顶级子域名的域名部分,直到第一个显著子域名。 [String](../../sql-reference/data-types/string.md)。 +- 返回包括顶级子域到第一个显著子域的域的部分。 [String](../../sql-reference/data-types/string.md)。 **参见** @@ -565,7 +580,9 @@ cutToFirstSignificantSubdomainRFC(url, tld) ### cutToFirstSignificantSubdomainCustomWithWWW {#cuttofirstsignificantsubdomaincustomwithwww} -返回域名的一部分,包括顶级子域名,直到第一个显著子域名,不去掉 `www`。接受自定义 TLD 列表名称。如果您需要一个新的 TLD 列表或有自定义列表,此函数可能会很有用。 +返回包括顶级子域到第一个显著子域的域的部分而不去掉 `www`。 +接受自定义 TLD 列表名称。 +如果需要新的 TLD 列表或具有自定义列表,此函数可能会很有用。 **配置示例** @@ -586,12 +603,12 @@ cutToFirstSignificantSubdomainCustomWithWWW(url, tld) **参数** -- `url` — URL. [String](../../sql-reference/data-types/string.md)。 +- `url` — URL。 [String](../../sql-reference/data-types/string.md)。 - `tld` — 自定义 TLD 列表名称。 [String](../../sql-reference/data-types/string.md)。 **返回值** -- 包含顶级子域名的域名部分,直到第一个显著子域名且不去掉 `www`。 [String](../data-types/string.md)。 +- 返回包括顶级子域到第一个显著子域的域的部分而不去掉 `www`。 [String](../data-types/string.md)。 **示例** @@ -616,7 +633,10 @@ SELECT cutToFirstSignificantSubdomainCustomWithWWW('www.foo', 'public_suffix_lis ### cutToFirstSignificantSubdomainCustomWithWWWRFC {#cuttofirstsignificantsubdomaincustomwithwwwrfc} -返回域名的一部分,包括顶级子域名,直到第一个显著子域名且不去掉 `www`。接受自定义 TLD 列表名称。如果您需要一个新的 TLD 列表或有自定义列表,此函数可能会很有用。类似于 [cutToFirstSignificantSubdomainCustomWithWWW](#cuttofirstsignificantsubdomaincustomwithwww),但符合 RFC 3986。 +返回包括顶级子域到第一个显著子域的域的部分而不去掉 `www`。 +接受自定义 TLD 列表名称。 +如果需要新的 TLD 列表或具有自定义列表,此函数可能会很有用。 +与 [cutToFirstSignificantSubdomainCustomWithWWW](#cuttofirstsignificantsubdomaincustomwithwww) 类似,但符合 RFC 3986。 **语法** @@ -626,12 +646,12 @@ cutToFirstSignificantSubdomainCustomWithWWWRFC(url, tld) **参数** -- `url` — URL. [String](../../sql-reference/data-types/string.md)。 +- `url` — URL。 [String](../../sql-reference/data-types/string.md)。 - `tld` — 自定义 TLD 列表名称。 [String](../../sql-reference/data-types/string.md)。 **返回值** -- 包含顶级子域名的域名部分,直到第一个显著子域名且不去掉 `www`。 [String](../../sql-reference/data-types/string.md)。 +- 返回包括顶级子域到第一个显著子域的域的部分而不去掉 `www`。 [String](../../sql-reference/data-types/string.md)。 **参见** @@ -640,7 +660,9 @@ cutToFirstSignificantSubdomainCustomWithWWWRFC(url, tld) ### firstSignificantSubdomainCustom {#firstsignificantsubdomaincustom} -返回第一个显著子域名。接受自定义 TLD 列表名称。如果您需要新的 TLD 列表或有自定义,则该函数可能会很有用。 +返回第一个显著子域。 +接受自定义 TLD 列表名称。 +如果需要新 TLD 列表或具有自定义列表,此功能可能会很有用。 配置示例: @@ -661,12 +683,12 @@ firstSignificantSubdomainCustom(url, tld) **参数** -- `url` — URL. [String](../../sql-reference/data-types/string.md)。 +- `url` — URL。 [String](../../sql-reference/data-types/string.md)。 - `tld` — 自定义 TLD 列表名称。 [String](../../sql-reference/data-types/string.md)。 **返回值** -- 第一个显著子域名。 [String](../../sql-reference/data-types/string.md)。 +- 第一个显著子域。 [String](../../sql-reference/data-types/string.md)。 **示例** @@ -691,7 +713,10 @@ SELECT firstSignificantSubdomainCustom('bar.foo.there-is-no-such-domain', 'publi ### firstSignificantSubdomainCustomRFC {#firstsignificantsubdomaincustomrfc} -返回第一个显著子域名。接受自定义 TLD 列表名称。如果您需要新的 TLD 列表或有自定义,则该函数可能会很有用。类似于 [firstSignificantSubdomainCustom](#firstsignificantsubdomaincustom),但符合 RFC 3986。 +返回第一个显著子域。 +接受自定义 TLD 列表名称。 +如果需要新 TLD 列表或具有自定义列表,此功能可能会很有用。 +与 [firstSignificantSubdomainCustom](#firstsignificantsubdomaincustom) 类似,但符合 RFC 3986。 **语法** @@ -701,12 +726,12 @@ firstSignificantSubdomainCustomRFC(url, tld) **参数** -- `url` — URL. [String](../../sql-reference/data-types/string.md)。 +- `url` — URL。 [String](../../sql-reference/data-types/string.md)。 - `tld` — 自定义 TLD 列表名称。 [String](../../sql-reference/data-types/string.md)。 **返回值** -- 第一个显著子域名。 [String](../../sql-reference/data-types/string.md)。 +- 第一个显著子域。 [String](../../sql-reference/data-types/string.md)。 **参见** @@ -715,7 +740,7 @@ firstSignificantSubdomainCustomRFC(url, tld) ### port {#port} -如果 URL 不包含端口或无法解析,则返回端口或 `default_port`。 +返回端口或者 `default_port`,如果 URL 不包含端口或无法解析。 **语法** @@ -725,12 +750,12 @@ port(url [, default_port = 0]) **参数** -- `url` — URL. [String](../data-types/string.md)。 -- `default_port` — 默认端口号,将返回。 [UInt16](../data-types/int-uint.md)。 +- `url` — URL。 [String](../data-types/string.md)。 +- `default_port` — 要返回的默认端口号。 [UInt16](../data-types/int-uint.md)。 **返回值** -- 端口或默认端口,如果 URL 中没有端口或在验证错误情况下。 [UInt16](../data-types/int-uint.md)。 +- 端口或默认端口,如果 URL 中没有端口或发生验证错误。 [UInt16](../data-types/int-uint.md)。 **示例** @@ -750,7 +775,8 @@ SELECT port('http://paul@www.example.com:80/'); ### portRFC {#portrfc} -如果 URL 不包含端口或无法解析,则返回端口或 `default_port`。类似于 [port](#port),但符合 RFC 3986。 +返回端口或 `default_port`,如果 URL 不包含端口或无法解析。 +与 [port](#port) 类似,但符合 RFC 3986。 **语法** @@ -760,12 +786,12 @@ portRFC(url [, default_port = 0]) **参数** -- `url` — URL. [String](../../sql-reference/data-types/string.md)。 -- `default_port` — 默认端口号,将返回。 [UInt16](../data-types/int-uint.md)。 +- `url` — URL。 [String](../../sql-reference/data-types/string.md)。 +- `default_port` — 要返回的默认端口号。 [UInt16](../data-types/int-uint.md)。 **返回值** -- 端口或默认端口,如果 URL 中没有端口或在验证错误情况下。 [UInt16](../data-types/int-uint.md)。 +- 端口或默认端口,如果 URL 中没有端口或发生验证错误。 [UInt16](../data-types/int-uint.md)。 **示例** @@ -787,19 +813,19 @@ SELECT ### path {#path} -返回不带查询字符串的路径。 +返回没有查询字符串的路径。 示例: `/top/news.html`。 ### pathFull {#pathfull} -与上述相同,但包括查询字符串和片段。 +与上面相同,但包括查询字符串和片段。 示例: `/top/news.html?page=2#comments`。 ### protocol {#protocol-1} -从 URL 中提取协议。 +从 URL 中提取协议。 **语法** @@ -833,39 +859,45 @@ SELECT protocol('https://clickhouse.com/'); ### queryString {#querystring} -返回查询字符串,不包括初始问号,`#` 和 `#` 后面的内容。 +返回查询字符串,不包括开头的问号,`#` 和 `#` 后的所有内容。 示例: `page=1&lr=213`。 ### fragment {#fragment} -返回碎片标识符,不包括初始哈希符号。 +返回不带开头井号的片段标识符。 ### queryStringAndFragment {#querystringandfragment} -返回查询字符串和碎片标识符。 +返回查询字符串和片段标识符。 示例: `page=1#29390`。 ### extractURLParameter(url, name) {#extracturlparameterurl-name} -返回 URL 中 `name` 参数的值(如果存在),否则返回空字符串。如果有多个同名参数,将返回第一个出现的值。该函数假定 `url` 参数中的参数按照与 `name` 参数相同的方式编码。 +返回 URL 中 `name` 参数的值(如果存在),否则返回空字符串。 +如果该名称存在多个参数,则返回第一个出现的值。 +该函数假设 `url` 参数中的参数以与 `name` 参数中的相同方式编码。 ### extractURLParameters(url) {#extracturlparametersurl} -返回与 URL 参数对应的 `name=value` 字符串数组。值未解码。 +返回与 URL 参数对应的 `name=value` 字符串数组。 +值未解码。 ### extractURLParameterNames(url) {#extracturlparameternamesurl} -返回与 URL 参数名称对应的名称字符串数组。值未解码。 +返回与 URL 参数名称对应的名称字符串数组。 +值未解码。 ### URLHierarchy(url) {#urlhierarchyurl} -返回一个数组,其中包含 URL,在路径和查询字符串中以符号 / 和 ? 截断。连续的分隔符字符计为一个。切割在所有连续分隔符字符之后的位置完成。 +返回一个数组,包含 URL,路径和查询字符串末尾截断的符号 / 和 ?。 +连续的分隔符字符计为一个。 +切割是在所有连续分隔符字符后进行的。 ### URLPathHierarchy(url) {#urlpathhierarchyurl} -与上述相同,但结果中不包含协议和主机。根元素 `/` 不包括。 +与上面相同,但结果中不包含协议和主机。根元素 `/` 不包括在内。 ```text URLPathHierarchy('https://example.com/browse/CONV-6788') = @@ -925,7 +957,7 @@ SELECT encodeURLFormComponent('http://127.0.0.1:8123/?query=SELECT 1 2+3') AS En ### decodeURLFormComponent(url) {#decodeurlformcomponenturl} -返回解码后的 URL。遵循 rfc-1866,普通加号(`+`)解码为空格(` `)。 +返回解码后的 URL。遵循 rfc-1866,普通的加号(`+`)解码为空格(` `)。 示例: @@ -941,7 +973,7 @@ SELECT decodeURLFormComponent('http://127.0.0.1:8123/?query=SELECT%201+2%2B3') A ### netloc {#netloc} -从 URL 中提取网络位置 (`username:password@host:port`)。 +从 URL 中提取网络位置(`username:password@host:port`)。 **语法** @@ -951,7 +983,7 @@ netloc(url) **参数** -- `url` — URL. [String](../../sql-reference/data-types/string.md)。 +- `url` — URL。 [String](../../sql-reference/data-types/string.md)。 **返回值** @@ -973,29 +1005,30 @@ SELECT netloc('http://paul@www.example.com:80/'); └───────────────────────────────────────────┘ ``` -## 移除 URL 部分的函数 {#functions-that-remove-part-of-a-url} +## 删除 URL 部分的函数 {#functions-that-remove-part-of-a-url} -如果 URL 没有类似的部分,则 URL 保持不变。 +如果 URL 不具有任何相似的内容,则 URL 保持不变。 ### cutWWW {#cutwww} -从 URL 的域中移除前导 `www.`(如果存在)。 +从 URL 的域中删除前缀 `www.`(如果存在)。 ### cutQueryString {#cutquerystring} -移除查询字符串,包括问号。 +删除查询字符串,包括问号。 ### cutFragment {#cutfragment} -移除碎片标识符,包括数字符号。 +删除片段标识符,包括数字符号。 ### cutQueryStringAndFragment {#cutquerystringandfragment} -移除查询字符串和碎片标识符,包括问号和数字符号。 +删除查询字符串和片段标识符,包括问号和数字符号。 ### cutURLParameter(url, name) {#cuturlparameterurl-name} -从 URL 中移除 `name` 参数(如果存在)。此函数不对参数名称中的字符进行编码或解码,例如 `Client ID` 和 `Client%20ID` 被视为不同的参数名称。 +从 URL 中删除 `name` 参数(如果存在)。 +该函数不对参数名称中的字符进行编码或解码,例如 `Client ID` 和 `Client%20ID` 被视为不同的参数名称。 **语法** @@ -1005,12 +1038,12 @@ cutURLParameter(url, name) **参数** -- `url` — URL. [String](../../sql-reference/data-types/string.md)。 -- `name` — URL 参数的名称。 [String](../../sql-reference/data-types/string.md) 或 [Array](../../sql-reference/data-types/array.md) 的字符串。 +- `url` — URL。 [String](../../sql-reference/data-types/string.md)。 +- `name` — URL 参数名称。 [String](../../sql-reference/data-types/string.md) 或 [Array](../../sql-reference/data-types/array.md) 的字符串。 **返回值** -- 移除 `name` URL 参数后的 URL。 [String](../data-types/string.md)。 +- 删除了 `name` URL 参数的 URL。 [String](../data-types/string.md)。 **示例** @@ -1018,8 +1051,8 @@ cutURLParameter(url, name) ```sql SELECT - cutURLParameter('http://bigmir.net/?a=b&c=d&e=f#g', 'a') as url_without_a, - cutURLParameter('http://bigmir.net/?a=b&c=d&e=f#g', ['c', 'e']) as url_without_c_and_e; + cutURLParameter('http://bigmir.net/?a=b&c=d&e=f#g', 'a') AS url_without_a, + cutURLParameter('http://bigmir.net/?a=b&c=d&e=f#g', ['c', 'e']) AS url_without_c_and_e; ``` 结果: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/url-functions.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/url-functions.md.hash index 561ac46502d..9072adcdd9b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/url-functions.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/url-functions.md.hash @@ -1 +1 @@ -30dcf150238e49de +97b85b96ececc61f diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/uuid-functions.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/uuid-functions.md index 40e4deb3ae0..39c68d55ca9 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/uuid-functions.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/uuid-functions.md @@ -1,19 +1,57 @@ --- 'description': '处理UUID的函数的文档' 'sidebar_label': 'UUIDs' -'sidebar_position': 205 'slug': '/sql-reference/functions/uuid-functions' 'title': '处理UUID的函数' +'doc_type': 'reference' --- import DeprecatedBadge from '@theme/badges/DeprecatedBadge'; -# 操作UUID的函数 +# 处理UUID的函数 + +## UUIDv7生成 {#uuidv7-generation} + +生成的UUID包含一个48位的Unix毫秒时间戳,后跟版本“7”(4位),一个计数器(42位)以区分同一毫秒内的UUID(包括一个变体字段“2”,2位)和一个随机字段(32位)。 +对于任何给定的时间戳(`unix_ts_ms`),计数器从一个随机值开始,并在时间戳变化之前每生成一个新的UUID时递增1。如果计数器溢出,时间戳字段会增加1,并且计数器重置为一个随机的新起始值。 +UUID生成函数确保在并发运行的线程和查询中,时间戳内的计数器字段在所有函数调用中单调递增。 + +```text + 0 1 2 3 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +├─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┤ +| unix_ts_ms | +├─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┤ +| unix_ts_ms | ver | counter_high_bits | +├─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┤ +|var| counter_low_bits | +├─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┤ +| rand_b | +└─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┘ +``` + +## 雪花ID生成 {#snowflake-id-generation} + +生成的雪花ID包含当前Unix时间戳(以毫秒为单位,41 + 1位高零位),后跟机器ID(10位)和一个计数器(12位)以区分同一毫秒内的ID。对于任何给定的时间戳(`unix_ts_ms`),计数器从0开始,并在时间戳变化之前每生成一个新的雪花ID时递增1。如果计数器溢出,时间戳字段会增加1,计数器重置为0。 + +:::note +生成的雪花ID基于UNIX纪元1970-01-01。虽然没有标准或推荐的雪花ID纪元,但其他系统中的实现可能使用不同的纪元,例如Twitter/X(2010-11-04)或Mastodon(2015-01-01)。 +::: + +```text + 0 1 2 3 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +├─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┤ +|0| timestamp | +├─┼ ┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┤ +| | machine_id | machine_seq_num | +└─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┘ +``` ## generateUUIDv4 {#generateuuidv4} -生成一个 [版本 4](https://tools.ietf.org/html/rfc4122#section-4.4) [UUID](../data-types/uuid.md)。 +生成一个[版本4](https://tools.ietf.org/html/rfc4122#section-4.4)的[UUID](../data-types/uuid.md)。 **语法** @@ -23,15 +61,15 @@ generateUUIDv4([expr]) **参数** -- `expr` — 一个任意的 [表达式](/sql-reference/syntax#expressions),用于在查询中多次调用该函数时绕过 [常见子表达式消除](/sql-reference/functions/overview#common-subexpression-elimination)。表达式的值对返回的UUID没有影响。可选。 +- `expr` — 一个任意的[表达式](/sql-reference/syntax#expressions),用于绕过[常见子表达式消除](/sql-reference/functions/overview#common-subexpression-elimination)在查询中多次调用该函数时。表达式的值对返回的UUID没有影响。可选。 **返回值** -UUIDv4 类型的值。 +UUIDv4类型的值。 **示例** -首先,创建一个类型为 UUID 的列的表,然后将生成的 UUIDv4 插入到表中。 +首先,创建一个包含UUID类型列的表,然后将生成的UUIDv4插入到表中。 ```sql CREATE TABLE tab (uuid UUID) ENGINE = Memory; @@ -61,30 +99,12 @@ SELECT generateUUIDv4(1), generateUUIDv4(2); ## generateUUIDv7 {#generateUUIDv7} -生成一个 [版本 7](https://datatracker.ietf.org/doc/html/draft-peabody-dispatch-new-uuid-format-04) [UUID](../data-types/uuid.md)。 - -生成的UUID包含当前的Unix时间戳(毫秒,48位),后跟版本 "7"(4位),一个计数器(42位)用于区分毫秒内的UUID(包括变体字段 "2",2位),以及一个随机字段(32位)。 -对于任何给定的时间戳(unix_ts_ms),计数器从一个随机值开始,并在每次生成新UUID时加1,直到时间戳改变。 -如果计数器溢出,时间戳字段加1,计数器重置为一个新的随机起始值。 +生成一个[版本7](https://datatracker.ietf.org/doc/html/draft-peabody-dispatch-new-uuid-format-04)的[UUID](../data-types/uuid.md)。 -函数 `generateUUIDv7` 确保在并发运行的线程和查询中,时间戳内的计数器字段在所有函数调用中的增加是单调的。 - -```text - 0 1 2 3 - 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 -├─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┤ -| unix_ts_ms | -├─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┤ -| unix_ts_ms | ver | counter_high_bits | -├─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┤ -|var| counter_low_bits | -├─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┤ -| rand_b | -└─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┘ -``` +有关UUID结构、计数器管理和并发保证的详细信息,请参阅["UUIDv7生成"](#uuidv7-generation)。 :::note -截至2024年4月,版本7的UUID处于草案状态,其布局可能会在未来发生改变。 +截至2024年4月,版本7 UUID处于草案状态,其布局可能会在未来发生变化。 ::: **语法** @@ -95,15 +115,15 @@ generateUUIDv7([expr]) **参数** -- `expr` — 一个任意的 [表达式](/sql-reference/syntax#expressions),用于在查询中多次调用该函数时绕过 [常见子表达式消除](/sql-reference/functions/overview#common-subexpression-elimination)。表达式的值对返回的UUID没有影响。可选。 +- `expr` — 一个任意的[表达式](/sql-reference/syntax#expressions),用于绕过[常见子表达式消除](/sql-reference/functions/overview#common-subexpression-elimination)在查询中多次调用该函数时。表达式的值对返回的UUID没有影响。可选。 **返回值** -UUIDv7 类型的值。 +UUIDv7类型的值。 **示例** -首先,创建一个类型为 UUID 的列的表,然后将生成的 UUIDv7 插入到表中。 +首先,创建一个包含UUID类型列的表,然后将生成的UUIDv7插入到表中。 ```sql CREATE TABLE tab (uuid UUID) ENGINE = Memory; @@ -131,9 +151,68 @@ SELECT generateUUIDv7(1), generateUUIDv7(2); └──────────────────────────────────────┴──────────────────────────────────────┘ ``` +## dateTimeToUUIDv7 {#datetimetouuidv7} + +将给定时间的[DateTime](../data-types/datetime.md)值转换为[UUIDv7](https://en.wikipedia.org/wiki/UUID#Version_7)。 + +有关UUID结构、计数器管理和并发保证的详细信息,请参阅["UUIDv7生成"](#uuidv7-generation)。 + +:::note +截至2024年4月,版本7 UUID处于草案状态,其布局可能会在未来发生变化。 +::: + +**语法** + +```sql +dateTimeToUUIDv7(value) +``` + +**参数** + +- `value` — 日期和时间。 [DateTime](../data-types/datetime.md)。 + +**返回值** + +UUIDv7类型的值。 + +**示例** + +```sql +SELECT dateTimeToUUIDv7(toDateTime('2021-08-15 18:57:56', 'Asia/Shanghai')); +``` + +结果: + +```response +┌─dateTimeToUUIDv7(toDateTime('2021-08-15 18:57:56', 'Asia/Shanghai'))─┐ +│ 018f05af-f4a8-778f-beee-1bedbc95c93b │ +└─────────────────────────────────────────────────────────────────────────┘ +``` + +**对于相同时间戳生成多个UUID的示例** + +```sql +SELECT dateTimeToUUIDv7(toDateTime('2021-08-15 18:57:56')); +SELECT dateTimeToUUIDv7(toDateTime('2021-08-15 18:57:56')); +``` + +**结果** + +```response + ┌─dateTimeToUUIDv7(t⋯08-15 18:57:56'))─┐ +1. │ 017b4b2d-7720-76ed-ae44-bbcc23a8c550 │ + └──────────────────────────────────────┘ + + ┌─dateTimeToUUIDv7(t⋯08-15 18:57:56'))─┐ +1. │ 017b4b2d-7720-76ed-ae44-bbcf71ed0fd3 │ + └──────────────────────────────────────┘ +``` + +该函数确保对相同时间戳的多次调用生成唯一的、单调递增的UUID。 + ## empty {#empty} -检查输入UUID是否为空。 +检查输入的UUID是否为空。 **语法** @@ -141,21 +220,21 @@ SELECT generateUUIDv7(1), generateUUIDv7(2); empty(UUID) ``` -如果UUID包含所有零(零UUID),则视为 empty。 +如果UUID全部为零(零UUID),则认为其为空。 -该函数也适用于 [数组](/sql-reference/functions/array-functions#empty) 和 [字符串](string-functions.md#empty)。 +该函数也适用于[数组](/sql-reference/functions/array-functions#empty)和[字符串](string-functions.md#empty)。 **参数** -- `x` — UUID。 [UUID](../data-types/uuid.md)。 +- `x` — 一个UUID。 [UUID](../data-types/uuid.md)。 **返回值** -- 对于空UUID返回 `1`,对于非空UUID返回 `0`。 [UInt8](../data-types/int-uint.md)。 +- 对于空UUID返回`1`,对于非空UUID返回`0`。 [UInt8](../data-types/int-uint.md)。 **示例** -要生成UUID值,ClickHouse提供了 [generateUUIDv4](#generateuuidv4) 函数。 +要生成UUID值,ClickHouse提供了[generateUUIDv4](#generateuuidv4)函数。 查询: @@ -173,7 +252,7 @@ SELECT empty(generateUUIDv4()); ## notEmpty {#notempty} -检查输入UUID是否非空。 +检查输入的UUID是否非空。 **语法** @@ -181,21 +260,21 @@ SELECT empty(generateUUIDv4()); notEmpty(UUID) ``` -如果UUID包含所有零(零UUID),则视为 empty。 +如果UUID全部为零(零UUID),则认为其为空。 -该函数也适用于 [数组](/sql-reference/functions/array-functions#notempty) 或 [字符串](string-functions.md#notempty)。 +该函数也适用于[数组](/sql-reference/functions/array-functions#notEmpty)或[字符串](string-functions.md#notempty)。 **参数** -- `x` — UUID。 [UUID](../data-types/uuid.md)。 +- `x` — 一个UUID。 [UUID](../data-types/uuid.md)。 **返回值** -- 对于非空UUID返回 `1`,对于空UUID返回 `0`。 [UInt8](../data-types/int-uint.md)。 +- 对于非空UUID返回`1`,对于空UUID返回`0`。 [UInt8](../data-types/int-uint.md)。 **示例** -要生成UUID值,ClickHouse提供了 [generateUUIDv4](#generateuuidv4) 函数。 +要生成UUID值,ClickHouse提供了[generateUUIDv4](#generateuuidv4)函数。 查询: @@ -213,7 +292,7 @@ SELECT notEmpty(generateUUIDv4()); ## toUUID {#touuid} -将类型为字符串的值转换为UUID。 +将字符串类型的值转换为UUID。 ```sql toUUID(string) @@ -221,7 +300,7 @@ toUUID(string) **返回值** -UUID类型的值。 +UUID类型值。 **使用示例** @@ -241,8 +320,8 @@ SELECT toUUID('61f0c404-5cb3-11e7-907b-a6006ad3dba0') AS uuid **参数** -- `string` — 36个字符的字符串或 FixedString(36)。 [字符串](../syntax.md#string)。 -- `default` — 如果第一个参数无法转换为UUID类型,则使用此UUID作为默认值。 [UUID](../data-types/uuid.md)。 +- `string` — 36个字符或FixedString(36)的字符串。[字符串](../syntax.md#string)。 +- `default` — 如果第一个参数无法转换为UUID类型,则用作默认值的UUID。[UUID](../data-types/uuid.md)。 **返回值** @@ -254,14 +333,14 @@ toUUIDOrDefault(string, default) **返回值** -UUID类型的值。 +UUID类型值。 **使用示例** -第一个示例将返回第一个参数转换为UUID类型,因为可以转换: +第一个示例返回可以转换为UUID类型的第一个参数: ```sql -SELECT toUUIDOrDefault('61f0c404-5cb3-11e7-907b-a6006ad3dba0', cast('59f0c404-5cb3-11e7-907b-a6006ad3dba0' as UUID)); +SELECT toUUIDOrDefault('61f0c404-5cb3-11e7-907b-a6006ad3dba0', cast('59f0c404-5cb3-11e7-907b-a6006ad3dba0' AS UUID)); ``` 结果: @@ -272,10 +351,10 @@ SELECT toUUIDOrDefault('61f0c404-5cb3-11e7-907b-a6006ad3dba0', cast('59f0c404-5c └───────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ ``` -第二个示例将返回第二个参数(提供的默认UUID),因为第一个参数无法转换为UUID类型: +第二个示例返回第二个参数(提供的默认UUID),因为第一个参数无法转换为UUID类型: ```sql -SELECT toUUIDOrDefault('-----61f0c404-5cb3-11e7-907b-a6006ad3dba0', cast('59f0c404-5cb3-11e7-907b-a6006ad3dba0' as UUID)); +SELECT toUUIDOrDefault('-----61f0c404-5cb3-11e7-907b-a6006ad3dba0', cast('59f0c404-5cb3-11e7-907b-a6006ad3dba0' AS UUID)); ``` 结果: @@ -288,7 +367,7 @@ SELECT toUUIDOrDefault('-----61f0c404-5cb3-11e7-907b-a6006ad3dba0', cast('59f0c4 ## toUUIDOrNull {#touuidornull} -接受字符串类型的参数,并尝试将其解析为UUID。如果失败,则返回NULL。 +接受一个字符串类型的参数,并尝试将其解析为UUID。如果失败,则返回NULL。 ```sql toUUIDOrNull(string) @@ -314,7 +393,7 @@ SELECT toUUIDOrNull('61f0c404-5cb3-11e7-907b-a6006ad3dba0T') AS uuid ## toUUIDOrZero {#touuidorzero} -接受字符串类型的参数,并尝试将其解析为UUID。如果失败,则返回零UUID。 +接受一个字符串类型的参数,并尝试将其解析为UUID。如果失败,则返回零UUID。 ```sql toUUIDOrZero(string) @@ -322,7 +401,7 @@ toUUIDOrZero(string) **返回值** -UUID类型的值。 +UUID类型值。 **使用示例** @@ -340,7 +419,7 @@ SELECT toUUIDOrZero('61f0c404-5cb3-11e7-907b-a6006ad3dba0T') AS uuid ## UUIDStringToNum {#uuidstringtonum} -接受包含36个字符的 `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx` 格式的 `string`,并返回 [FixedString(16)](../data-types/fixedstring.md) 作为其二进制表示,格式可以由`variant`指明(默认是 `Big-endian`)。 +接受一个包含36个字符的`string`,格式为`xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`,并返回一个[FixedString(16)](../data-types/fixedstring.md)作为其二进制表示,可以选择性地通过`variant`指定格式(默认是`Big-endian`)。 **语法** @@ -350,8 +429,8 @@ UUIDStringToNum(string[, variant = 1]) **参数** -- `string` — 一个含有36个字符的 [字符串](/sql-reference/data-types/string) 或 [FixedString](/sql-reference/data-types/string) -- `variant` — 整数,表示由 [RFC4122](https://datatracker.ietf.org/doc/html/rfc4122#section-4.1.1) 指定的变体。1 = `Big-endian`(默认),2 = `Microsoft`。 +- `string` — 一种[字符串](/sql-reference/data-types/string),包含36个字符或[FixedString](/sql-reference/data-types/string) +- `variant` — 整数,表示按照[RFC4122](https://datatracker.ietf.org/doc/html/rfc4122#section-4.1.1)指定的变体。1 = `Big-endian`(默认),2 = `Microsoft`。 **返回值** @@ -389,7 +468,7 @@ SELECT ## UUIDNumToString {#uuidnumtostring} -接受 `binary`,其包含UUID的二进制表示,格式可以由`variant`指明(默认是 `Big-endian`),并返回一个包含36个字符的文本格式字符串。 +接受一个包含UUID二进制表示的`binary`,可以选择性地通过`variant`指定格式(默认是`Big-endian`),并返回一个包含36个字符的字符串。 **语法** @@ -400,7 +479,7 @@ UUIDNumToString(binary[, variant = 1]) **参数** - `binary` — [FixedString(16)](../data-types/fixedstring.md),作为UUID的二进制表示。 -- `variant` — 整数,表示由 [RFC4122](https://datatracker.ietf.org/doc/html/rfc4122#section-4.1.1) 指定的变体。1 = `Big-endian`(默认),2 = `Microsoft`。 +- `variant` — 整数,表示按照[RFC4122](https://datatracker.ietf.org/doc/html/rfc4122#section-4.1.1)指定的变体。1 = `Big-endian`(默认),2 = `Microsoft`。 **返回值** @@ -438,7 +517,7 @@ SELECT ## UUIDToNum {#uuidtonum} -接受一个 [UUID](../data-types/uuid.md),并将其二进制表示返回为 [FixedString(16)](../data-types/fixedstring.md),格式可以由`variant`指明(默认是 `Big-endian`)。这个函数替代了两个独立调用的函数 `UUIDStringToNum(toString(uuid))`,因此无需从UUID到字符串的中间转换以提取UUID的字节。 +接受一个[UUID](../data-types/uuid.md),并返回其二进制表示,作为[FixedString(16)](../data-types/fixedstring.md),可以选择性地通过`variant`指定格式(默认是`Big-endian`)。该函数替代了对两个单独函数的调用`UUIDStringToNum(toString(uuid))`,因此无需将UUID转换为字符串以提取字节。 **语法** @@ -449,7 +528,7 @@ UUIDToNum(uuid[, variant = 1]) **参数** - `uuid` — [UUID](../data-types/uuid.md)。 -- `variant` — 整数,表示由 [RFC4122](https://datatracker.ietf.org/doc/html/rfc4122#section-4.1.1) 指定的变体。1 = `Big-endian`(默认),2 = `Microsoft`。 +- `variant` — 整数,表示按照[RFC4122](https://datatracker.ietf.org/doc/html/rfc4122#section-4.1.1)指定的变体。1 = `Big-endian`(默认),2 = `Microsoft`。 **返回值** @@ -497,12 +576,12 @@ UUIDv7ToDateTime(uuid[, timezone]) **参数** -- `uuid` — 版本7的 [UUID](../data-types/uuid.md)。 -- `timezone` — 返回值的 [时区名称](../../operations/server-configuration-parameters/settings.md#timezone)(可选)。 [字符串](../data-types/string.md)。 +- `uuid` — 版本7的[UUID](../data-types/uuid.md)。 +- `timezone` — 返回值的[时区名称](../../operations/server-configuration-parameters/settings.md#timezone)(可选)。[字符串](../data-types/string.md)。 **返回值** -- 具有毫秒精度的时间戳。如果UUID不是有效的版本7 UUID,则返回 1970-01-01 00:00:00.000。 [DateTime64(3)](../data-types/datetime64.md)。 +- 带有毫秒精度的时间戳。如果UUID不是有效的版本7 UUID,则返回1970-01-01 00:00:00.000。 [DateTime64(3)](../data-types/datetime64.md)。 **使用示例** @@ -532,7 +611,7 @@ SELECT UUIDv7ToDateTime(toUUID('018f05c9-4ab8-7b86-b64e-c9f03fbd45d1'), 'America ## serverUUID {#serveruuid} -返回在ClickHouse服务器首次启动时生成的随机UUID。UUID存储在ClickHouse服务器目录中的 `uuid` 文件中(例如 `/var/lib/clickhouse/`),并在服务器重启时保留。 +返回在ClickHouse服务器首次启动时生成的随机UUID。该UUID存储在ClickHouse服务器目录(例如`/var/lib/clickhouse/`)中的文件`uuid`中,并在服务器重启之间保留。 **语法** @@ -546,28 +625,10 @@ serverUUID() ## generateSnowflakeID {#generatesnowflakeid} -生成一个 [Snowflake ID](https://en.wikipedia.org/wiki/Snowflake_ID)。 +生成一个[雪花ID](https://en.wikipedia.org/wiki/Snowflake_ID)。 +该函数确保在并发运行的线程和查询中,时间戳内的计数器字段在所有函数调用中单调递增。 -生成的Snowflake ID包含当前的Unix时间戳(毫秒,41 + 1个顶部零位),后跟一个机器ID(10位),以及一个计数器(12位)以区分毫秒内的ID。 -对于任何给定的时间戳(unix_ts_ms),计数器从0开始,并在每次生成新Snowflake ID时加1,直到时间戳变化。 -如果计数器溢出,时间戳字段加1,计数器重置为0。 - -函数 `generateSnowflakeID` 确保在并发运行的线程和查询中,时间戳内的计数器字段在所有函数调用中的增加是单调的。 - -:::note -生成的Snowflake ID基于UNIX纪元1970-01-01。 -虽然Snowflake ID的纪元没有标准或建议,但其他系统中的实现可能使用不同的纪元,例如Twitter/X(2010-11-04)或Mastodon(2015-01-01)。 -::: - -```text - 0 1 2 3 - 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 -├─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┤ -|0| timestamp | -├─┼ ┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┤ -| | machine_id | machine_seq_num | -└─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┘ -``` +有关实现的详细信息,请参阅["雪花ID生成"](#snowflake-id-generation)。 **语法** @@ -577,16 +638,16 @@ generateSnowflakeID([expr, [machine_id]]) **参数** -- `expr` — 一个任意的 [表达式](/sql-reference/syntax#expressions),用于在查询中多次调用该函数时绕过 [常见子表达式消除](/sql-reference/functions/overview#common-subexpression-elimination)。表达式的值对返回的Snowflake ID没有影响。可选。 -- `machine_id` — 机器ID,使用最低的10位。 [Int64](../data-types/int-uint.md)。可选。 +- `expr` — 一个任意的[表达式](/sql-reference/syntax#expressions),用于绕过[常见子表达式消除](/sql-reference/functions/overview#common-subexpression-elimination)在查询中多次调用该函数时。表达式的值对返回的雪花ID没有影响。可选。 +- `machine_id` — 一个机器ID,使用最低的10位。[Int64](../data-types/int-uint.md)。可选。 **返回值** -UInt64 类型的值。 +UInt64类型的值。 **示例** -首先,创建一个类型为UInt64的列的表,然后将生成的Snowflake ID插入到表中。 +首先,创建一个包含UInt64类型列的表,然后将生成的雪花ID插入到表中。 ```sql CREATE TABLE tab (id UInt64) ENGINE = Memory; @@ -604,7 +665,7 @@ SELECT * FROM tab; └─────────────────────┘ ``` -**每行生成多个Snowflake ID的示例** +**每行生成多个雪花ID的示例** ```sql SELECT generateSnowflakeID(1), generateSnowflakeID(2); @@ -629,11 +690,13 @@ SELECT generateSnowflakeID('expr', 1); :::warning -此函数已弃用,仅在设置 [allow_deprecated_snowflake_conversion_functions](../../operations/settings/settings.md#allow_deprecated_snowflake_conversion_functions) 启用时可以使用。 -该函数将在未来某个时候被移除。 +该函数已弃用,仅在启用设置[allow_deprecated_snowflake_conversion_functions](../../operations/settings/settings.md#allow_deprecated_snowflake_conversion_functions)时可用。 +该函数将在未来某个时刻被移除。 + +请改用函数[snowflakeIDToDateTime](#snowflakeidtodatetime)。 ::: -提取 [Snowflake ID](https://en.wikipedia.org/wiki/Snowflake_ID) 的时间戳组件,以 [DateTime](../data-types/datetime.md) 格式返回。 +提取[Sowflake ID](https://en.wikipedia.org/wiki/Snowflake_ID)的时间戳组件,格式为[DateTime](../data-types/datetime.md)。 **语法** @@ -643,12 +706,12 @@ snowflakeToDateTime(value[, time_zone]) **参数** -- `value` — Snowflake ID。 [Int64](../data-types/int-uint.md)。 -- `time_zone` — [时区](/operations/server-configuration-parameters/settings.md#timezone)。该函数根据时区解析 `time_string`。可选。 [字符串](../data-types/string.md)。 +- `value` — 雪花ID。 [Int64](../data-types/int-uint.md)。 +- `time_zone` — [时区](/operations/server-configuration-parameters/settings.md#timezone)。该函数根据时区解析`time_string`。可选。 [字符串](../data-types/string.md)。 **返回值** -- `value` 的时间戳组件作为 [DateTime](../data-types/datetime.md) 值。 +- `value`的时间戳组件,格式为[DateTime](../data-types/datetime.md)值。 **示例** @@ -672,11 +735,13 @@ SELECT snowflakeToDateTime(CAST('1426860702823350272', 'Int64'), 'UTC'); :::warning -此函数已弃用,仅在设置 [allow_deprecated_snowflake_conversion_functions](../../operations/settings/settings.md#allow_deprecated_snowflake_conversion_functions) 启用时可以使用。 -该函数将在未来某个时候被移除。 +该函数已弃用,仅在启用设置[allow_deprecated_snowflake_conversion_functions](../../operations/settings/settings.md#allow_deprecated_snowflake_conversion_functions)时可用。 +该函数将在未来某个时刻被移除。 + +请改用函数[snowflakeIDToDateTime64](#snowflakeidtodatetime64)。 ::: -提取 [Snowflake ID](https://en.wikipedia.org/wiki/Snowflake_ID) 的时间戳组件,以 [DateTime64](../data-types/datetime64.md) 格式返回。 +提取[Sowflake ID](https://en.wikipedia.org/wiki/Snowflake_ID)的时间戳组件,格式为[DateTime64](../data-types/datetime64.md)。 **语法** @@ -686,12 +751,12 @@ snowflakeToDateTime64(value[, time_zone]) **参数** -- `value` — Snowflake ID。 [Int64](../data-types/int-uint.md)。 -- `time_zone` — [时区](/operations/server-configuration-parameters/settings.md#timezone)。该函数根据时区解析 `time_string`。可选。 [字符串](../data-types/string.md)。 +- `value` — 雪花ID。 [Int64](../data-types/int-uint.md)。 +- `time_zone` — [时区](/operations/server-configuration-parameters/settings.md#timezone)。该函数根据时区解析`time_string`。可选。 [字符串](../data-types/string.md)。 **返回值** -- `value` 的时间戳组件作为 [DateTime64](../data-types/datetime64.md),其刻度 = 3,即毫秒精度。 +- `value`的时间戳组件,格式为[DateTime64](../data-types/datetime64.md),其比例 = 3,即毫秒精度。 **示例** @@ -715,11 +780,13 @@ SELECT snowflakeToDateTime64(CAST('1426860802823350272', 'Int64'), 'UTC'); :::warning -此函数已弃用,仅在设置 [allow_deprecated_snowflake_conversion_functions](../../operations/settings/settings.md#allow_deprecated_snowflake_conversion_functions) 启用时可以使用。 -该函数将在未来某个时候被移除。 +该函数已弃用,仅在启用设置[allow_deprecated_snowflake_conversion_functions](../../operations/settings/settings.md#allow_deprecated_snowflake_conversion_functions)时可用。 +该函数将在未来某个时刻被移除。 + +请改用函数[dateTimeToSnowflakeID](#datetimetosnowflakeid)。 ::: -将 [DateTime](../data-types/datetime.md) 值转换为给定时间的第一个 [Snowflake ID](https://en.wikipedia.org/wiki/Snowflake_ID)。 +将[DateTime](../data-types/datetime.md)值转换为给定时间的第一个[雪花ID](https://en.wikipedia.org/wiki/Snowflake_ID)。 **语法** @@ -729,11 +796,11 @@ dateTimeToSnowflake(value) **参数** -- `value` — 带有时间的日期。 [DateTime](../data-types/datetime.md)。 +- `value` — 日期和时间。[DateTime](../data-types/datetime.md)。 **返回值** -- 输入值转换为 [Int64](../data-types/int-uint.md) 数据类型,作为该时间的第一个Snowflake ID。 +- 输入值转换为[Int64](../data-types/int-uint.md)数据类型,作为该时间的第一个雪花ID。 **示例** @@ -756,11 +823,13 @@ WITH toDateTime('2021-08-15 18:57:56', 'Asia/Shanghai') AS dt SELECT dateTimeToS :::warning -此函数已弃用,仅在设置 [allow_deprecated_snowflake_conversion_functions](../../operations/settings/settings.md#allow_deprecated_snowflake_conversion_functions) 启用时可以使用。 -该函数将在未来某个时候被移除。 +该函数已弃用,仅在启用设置[allow_deprecated_snowflake_conversion_functions](../../operations/settings/settings.md#allow_deprecated_snowflake_conversion_functions)时可用。 +该函数将在未来某个时刻被移除。 + +请改用函数[dateTime64ToSnowflakeID](#datetime64tosnowflakeid)。 ::: -将 [DateTime64](../data-types/datetime64.md) 转换为给定时间的第一个 [Snowflake ID](https://en.wikipedia.org/wiki/Snowflake_ID)。 +将[DateTime64](../data-types/datetime64.md)转换为给定时间的第一个[雪花ID](https://en.wikipedia.org/wiki/Snowflake_ID)。 **语法** @@ -770,11 +839,11 @@ dateTime64ToSnowflake(value) **参数** -- `value` — 带有时间的日期。 [DateTime64](../data-types/datetime64.md)。 +- `value` — 日期和时间。[DateTime64](../data-types/datetime64.md)。 **返回值** -- 输入值转换为 [Int64](../data-types/int-uint.md) 数据类型,作为该时间的第一个Snowflake ID。 +- 输入值转换为[Int64](../data-types/int-uint.md)数据类型,作为该时间的第一个雪花ID。 **示例** @@ -794,7 +863,7 @@ WITH toDateTime64('2021-08-15 18:57:56.492', 3, 'Asia/Shanghai') AS dt64 SELECT ## snowflakeIDToDateTime {#snowflakeidtodatetime} -返回 [Snowflake ID](https://en.wikipedia.org/wiki/Snowflake_ID) 的时间戳组件,作为 [DateTime](../data-types/datetime.md) 类型的值。 +返回[Sowflake ID](https://en.wikipedia.org/wiki/Snowflake_ID)的时间戳组件,类型为[DateTime](../data-types/datetime.md)。 **语法** @@ -804,13 +873,13 @@ snowflakeIDToDateTime(value[, epoch[, time_zone]]) **参数** -- `value` — Snowflake ID。 [UInt64](../data-types/int-uint.md)。 -- `epoch` - Snowflake ID的纪元,自1970-01-01以来的毫秒。默认为0(1970-01-01)。对于Twitter/X纪元(2015-01-01),提供1288834974657。可选。 [UInt*](../data-types/int-uint.md)。 -- `time_zone` — [时区](/operations/server-configuration-parameters/settings.md#timezone)。该函数根据时区解析 `time_string`。可选。 [字符串](../data-types/string.md)。 +- `value` — 雪花ID。 [UInt64](../data-types/int-uint.md)。 +- `epoch` - 雪花ID的纪元,以毫秒为单位,自1970-01-01起计算。默认为0(1970-01-01)。对于Twitter/X纪元(2015-01-01),提供1288834974657。可选。[UInt*](../data-types/int-uint.md)。 +- `time_zone` — [时区](/operations/server-configuration-parameters/settings.md#timezone)。该函数根据时区解析`time_string`。可选。[字符串](../data-types/string.md)。 **返回值** -- `value` 的时间戳组件作为 [DateTime](../data-types/datetime.md) 值。 +- `value`的时间戳组件类型为[DateTime](../data-types/datetime.md)的值。 **示例** @@ -830,7 +899,7 @@ SELECT snowflakeIDToDateTime(7204436857747984384) AS res ## snowflakeIDToDateTime64 {#snowflakeidtodatetime64} -返回 [Snowflake ID](https://en.wikipedia.org/wiki/Snowflake_ID) 的时间戳组件,作为 [DateTime64](../data-types/datetime64.md) 类型的值。 +返回[Sowflake ID](https://en.wikipedia.org/wiki/Snowflake_ID)的时间戳组件,类型为[DateTime64](../data-types/datetime64.md)。 **语法** @@ -840,13 +909,13 @@ snowflakeIDToDateTime64(value[, epoch[, time_zone]]) **参数** -- `value` — Snowflake ID。 [UInt64](../data-types/int-uint.md)。 -- `epoch` - Snowflake ID的纪元,自1970-01-01以来的毫秒。默认为0(1970-01-01)。对于Twitter/X纪元(2015-01-01),提供1288834974657。可选。 [UInt*](../data-types/int-uint.md)。 -- `time_zone` — [时区](/operations/server-configuration-parameters/settings.md#timezone)。该函数根据时区解析 `time_string`。可选。 [字符串](../data-types/string.md)。 +- `value` — 雪花ID。 [UInt64](../data-types/int-uint.md)。 +- `epoch` - 雪花ID的纪元,以毫秒为单位,自1970-01-01起计算。默认为0(1970-01-01)。对于Twitter/X纪元(2015-01-01),提供1288834974657。可选。[UInt*](../data-types/int-uint.md)。 +- `time_zone` — [时区](/operations/server-configuration-parameters/settings.md#timezone)。该函数根据时区解析`time_string`。可选。[字符串](../data-types/string.md)。 **返回值** -- `value` 的时间戳组件作为 [DateTime64](../data-types/datetime64.md),其刻度 = 3,即毫秒精度。 +- `value`的时间戳组件,类型为[DateTime64](../data-types/datetime64.md),其精度为3,即毫秒精度。 **示例** @@ -866,7 +935,7 @@ SELECT snowflakeIDToDateTime64(7204436857747984384) AS res ## dateTimeToSnowflakeID {#datetimetosnowflakeid} -将 [DateTime](../data-types/datetime.md) 值转换为给定时间的第一个 [Snowflake ID](https://en.wikipedia.org/wiki/Snowflake_ID)。 +将[DateTime](../data-types/datetime.md)值转换为给定时间的第一个[雪花ID](https://en.wikipedia.org/wiki/Snowflake_ID)。 **语法** @@ -876,12 +945,12 @@ dateTimeToSnowflakeID(value[, epoch]) **参数** -- `value` — 带有时间的日期。 [DateTime](../data-types/datetime.md)。 -- `epoch` - Snowflake ID的纪元,自1970-01-01以来的毫秒。默认为0(1970-01-01)。对于Twitter/X纪元(2015-01-01),提供1288834974657。可选。 [UInt*](../data-types/int-uint.md)。 +- `value` — 日期和时间。[DateTime](../data-types/datetime.md)。 +- `epoch` - 雪花ID的纪元,以毫秒为单位,自1970-01-01起计算。默认为0(1970-01-01)。对于Twitter/X纪元(2015-01-01),提供1288834974657。可选。[UInt*](../data-types/int-uint.md)。 **返回值** -- 输入值转换为 [UInt64](../data-types/int-uint.md),作为该时间的第一个Snowflake ID。 +- 输入值转换为[UInt64](../data-types/int-uint.md),作为该时间的第一个雪花ID。 **示例** @@ -901,7 +970,7 @@ SELECT toDateTime('2021-08-15 18:57:56', 'Asia/Shanghai') AS dt, dateTimeToSnowf ## dateTime64ToSnowflakeID {#datetime64tosnowflakeid} -将 [DateTime64](../data-types/datetime64.md) 转换为给定时间的第一个 [Snowflake ID](https://en.wikipedia.org/wiki/Snowflake_ID)。 +将[DateTime64](../data-types/datetime64.md)转换为给定时间的第一个[雪花ID](https://en.wikipedia.org/wiki/Snowflake_ID)。 **语法** @@ -911,12 +980,12 @@ dateTime64ToSnowflakeID(value[, epoch]) **参数** -- `value` — 带有时间的日期。 [DateTime64](../data-types/datetime64.md)。 -- `epoch` - Snowflake ID的纪元,自1970-01-01以来的毫秒。默认为0(1970-01-01)。对于Twitter/X纪元(2015-01-01),提供1288834974657。可选。 [UInt*](../data-types/int-uint.md)。 +- `value` — 日期和时间。[DateTime64](../data-types/datetime64.md)。 +- `epoch` - 雪花ID的纪元,以毫秒为单位,自1970-01-01起计算。默认为0(1970-01-01)。对于Twitter/X纪元(2015-01-01),提供1288834974657。可选。[UInt*](../data-types/int-uint.md)。 **返回值** -- 输入值转换为 [UInt64](../data-types/int-uint.md),作为该时间的第一个Snowflake ID。 +- 输入值转换为[UInt64](../data-types/int-uint.md),作为该时间的第一个雪花ID。 **示例** @@ -934,12 +1003,12 @@ SELECT toDateTime('2021-08-15 18:57:56.493', 3, 'Asia/Shanghai') AS dt, dateTime └─────────────────────────┴─────────────────────┘ ``` -## 另见 {#see-also} +## 另请参阅 {#see-also} - [dictGetUUID](/sql-reference/functions/ext-dict-functions#other-functions) - diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/uuid-functions.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/uuid-functions.md.hash index 27decca6367..e607fcffaf3 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/uuid-functions.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/uuid-functions.md.hash @@ -1 +1 @@ -bbd18695d1625ed0 +3136f91224abd446 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/ym-dict-functions.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/ym-dict-functions.md.hash deleted file mode 100644 index 272a46b40b2..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/functions/ym-dict-functions.md.hash +++ /dev/null @@ -1 +0,0 @@ -26d97598f5255575 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/index.md index 8a88e0acce7..3fe5773be0b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/index.md @@ -9,6 +9,7 @@ - 'syntax' 'slug': '/sql-reference' 'title': 'SQL 参考' +'doc_type': 'reference' --- import { TwoColumnList } from '/src/components/two_column_list' @@ -21,7 +22,7 @@ import LinksDeployment from './sql-reference-links.json' # ClickHouse SQL 参考 -ClickHouse 支持基于 SQL 的声明性查询语言,在许多情况下与 ANSI SQL 标准相同。 +ClickHouse 支持一种基于 SQL 的声明性查询语言,在许多情况下与 ANSI SQL 标准相同。 支持的查询包括 GROUP BY、ORDER BY、FROM 中的子查询、JOIN 子句、IN 运算符、窗口函数和标量子查询。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/index.md.hash index e4d42e96234..2fe0006f48b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/index.md.hash @@ -1 +1 @@ -ed17e8260cdcefd5 +fc09917f6f962f5a diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/operators/distributed-ddl.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/operators/distributed-ddl.md index fed4e506af9..1c01d2901f0 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/operators/distributed-ddl.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/operators/distributed-ddl.md @@ -1,8 +1,9 @@ --- -'description': 'Distributed DDL 的文档' +'description': 'Distributed Ddl 的文档' 'sidebar_label': 'Distributed DDL' 'slug': '/sql-reference/other/distributed-ddl' 'title': '分布式 DDL 页面' +'doc_type': 'reference' --- import Content from '@site/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/distributed-ddl.md'; diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/operators/distributed-ddl.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/operators/distributed-ddl.md.hash index def362117ad..6227b15c8c9 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/operators/distributed-ddl.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/operators/distributed-ddl.md.hash @@ -1 +1 @@ -93d842fb218cb586 +f04e8153c4414a27 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/operators/exists.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/operators/exists.md index 855364ee800..7378bcbce92 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/operators/exists.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/operators/exists.md @@ -1,18 +1,19 @@ --- -'description': '`EXISTS` 运算符的文档' +'description': '`EXISTS` 操作符的文档' 'slug': '/sql-reference/operators/exists' 'title': 'EXISTS' +'doc_type': 'reference' --- # EXISTS -`EXISTS` 运算符检查子查询的结果中有多少条记录。如果是空的,则运算符返回 `0`。否则,它返回 `1`。 +`EXISTS` 操作符检查子查询结果中有多少记录。如果结果为空,则该操作符返回 `0`。否则,它返回 `1`。 -`EXISTS` 也可以在 [WHERE](../../sql-reference/statements/select/where.md) 子句中使用。 +`EXISTS` 也可以用于 [WHERE](../../sql-reference/statements/select/where.md) 子句。 :::tip -不支持在子查询中引用主查询的表和列。 +在子查询中不支持对主查询表和列的引用。 ::: **语法** @@ -37,7 +38,7 @@ SELECT EXISTS(SELECT * FROM numbers(10) WHERE number > 8), EXISTS(SELECT * FROM └───────────────────┴───────────────────┘ ``` -返回多行的子查询的查询: +返回几行的子查询的查询: ```sql SELECT count() FROM numbers(10) WHERE EXISTS(SELECT number FROM numbers(10) WHERE number > 8); diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/operators/exists.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/operators/exists.md.hash index 8b8f106877f..5e7a2967e9b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/operators/exists.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/operators/exists.md.hash @@ -1 +1 @@ -9d603a364fa8251d +a2e89f1fadf9b46d diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/operators/in.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/operators/in.md index fe56ec90e9a..f207272b253 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/operators/in.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/operators/in.md @@ -1,15 +1,16 @@ --- -'description': '关于 IN 运算符的文档,不包括 NOT IN、GLOBAL IN 和 GLOBAL NOT IN 运算符,这些运算符单独覆盖。' +'description': 'IN 运算符的文档,不包括 NOT IN、GLOBAL IN 和 GLOBAL NOT IN 运算符,这些运算符单独覆盖' 'slug': '/sql-reference/operators/in' 'title': 'IN 运算符' +'doc_type': 'reference' --- # IN 操作符 -`IN`、`NOT IN`、`GLOBAL IN` 和 `GLOBAL NOT IN` 操作符单独涵盖,因为它们的功能非常丰富。 +`IN`、`NOT IN`、`GLOBAL IN` 和 `GLOBAL NOT IN` 操作符分别讨论,因为它们的功能相当丰富。 -操作符的左侧可以是单个列或一个元组。 +操作符的左侧可以是单个列或元组。 示例: @@ -18,15 +19,16 @@ SELECT UserID IN (123, 456) FROM ... SELECT (CounterID, UserID) IN ((34, 123), (101500, 456)) FROM ... ``` -如果左侧是一个在索引中的单个列,而右侧是一组常量,系统将使用索引来处理查询。 +如果左侧是一个在索引中的单列,而右侧是一组常量,则系统会利用索引来处理查询。 -不要显式列出太多值(例如——亿级)。如果数据集很大,请将其放入临时表中(例如,参见 [用于查询处理的外部数据](../../engines/table-engines/special/external-data.md)),然后使用子查询。 +不要显式列出过多的值(即数百万个)。如果数据集很大,请将其放入临时表中(例如,请参见[查询处理的外部数据](../../engines/table-engines/special/external-data.md)一节),然后使用子查询。 -操作符的右侧可以是一组常量表达式、一组带常量表达式的元组(如上例所示),或用括号括起来的数据库表名或 `SELECT` 子查询。 +操作符的右侧可以是一组常量表达式、一组带有常量表达式的元组(如上面示例所示),或者是用括号括起来的数据库表名或`SELECT`子查询。 -ClickHouse 允许 `IN` 子查询的左右部分的类型不同。在这种情况下,它会将右侧的值转换为左侧的类型,就好像对右侧应用了 [accurateCastOrNull](/sql-reference/functions/type-conversion-functions#accuratecastornullx-t) 函数一样。 +ClickHouse 允许 `IN` 子查询的左侧和右侧的类型不同。 +在这种情况下,它将右侧的值转换为左侧的类型,就好像对右侧应用了[accurateCastOrNull](/sql-reference/functions/type-conversion-functions#accuratecastornullx-t)函数一样。 -这意味着数据类型变为 [Nullable](../../sql-reference/data-types/nullable.md),如果无法进行转换,将返回 [NULL](/operations/settings/formats#input_format_null_as_default)。 +这意味着数据类型变为[Nullable](../../sql-reference/data-types/nullable.md),如果无法进行转换,则返回[NULL](/operations/settings/formats#input_format_null_as_default)。 **示例** @@ -44,11 +46,11 @@ SELECT '1' IN (SELECT 1); └──────────────────────┘ ``` -如果操作符的右侧是一个表名(例如,`UserID IN users`),这等同于子查询 `UserID IN (SELECT * FROM users)`。在处理与查询一起发送的外部数据时使用此方式。例如,可以将查询与加载到“users”临时表的用户 ID 集一起发送,以便进行过滤。 +如果操作符的右侧是表的名称(例如,`UserID IN users`),这就等同于子查询`UserID IN (SELECT * FROM users)`。在处理与查询一起发送的外部数据时使用此方法。例如,查询可以与加载到“users”临时表中的用户 ID 集合一起发送,这些用户 ID 应该被过滤。 -如果操作符的右侧是一个具有 Set 引擎的表名(这是一个始终在 RAM 中的准备好数据集),则数据集不会为每个查询重新创建。 +如果操作符的右侧是具有 Set 引擎的表名(一个始终在 RAM 中的数据集),该数据集将不会为每个查询重复创建。 -子查询可以指定多个列来过滤元组。 +子查询可以指定多个列以过滤元组。 示例: @@ -56,7 +58,7 @@ SELECT '1' IN (SELECT 1); SELECT (CounterID, UserID) IN (SELECT CounterID, UserID FROM ...) FROM ... ``` -`IN` 操作符左右的列应具有相同的类型。 +`IN` 操作符左侧和右侧的列应具有相同的类型。 `IN` 操作符和子查询可以出现在查询的任何部分,包括聚合函数和 lambda 函数。 示例: @@ -87,14 +89,14 @@ ORDER BY EventDate ASC └────────────┴──────────┘ ``` -在 3 月 17 日之后的每一天,统计访问 3 月 17 日网站的用户所产生的页面浏览量比例。 -`IN` 子句中的子查询总是仅在单台服务器上运行一次。没有依赖性子查询。 +对于 3 月 17 日之后的每一天,计算在 3 月 17 日访问了该网站的用户产生的页面浏览量的百分比。 +`IN` 子句中的子查询在单个服务器上始终只运行一次。没有依赖子查询。 ## NULL 处理 {#null-processing} -在请求处理期间,`IN` 操作符假设与 [NULL](/operations/settings/formats#input_format_null_as_default) 的运算结果始终等于 `0`,无论 `NULL` 在操作符的左侧还是右侧。`NULL` 值不包含在任何数据集中,彼此不对应,如果 [transform_null_in = 0](../../operations/settings/settings.md#transform_null_in),则无法进行比较。 +在请求处理过程中,`IN` 操作符假定与[NULL](/operations/settings/formats#input_format_null_as_default)的操作结果始终等于 `0`,无论 `NULL` 在操作符的右边还是左边。`NULL` 值不包含在任何数据集中,不彼此对应,也无法在[transform_null_in = 0](../../operations/settings/settings.md#transform_null_in)时进行比较。 -这是一个 `t_null` 表的示例: +这是一个包含 `t_null` 表的示例: ```text ┌─x─┬────y─┐ @@ -103,7 +105,7 @@ ORDER BY EventDate ASC └───┴──────┘ ``` -执行查询 `SELECT x FROM t_null WHERE y IN (NULL,3)` 产生以下结果: +运行查询 `SELECT x FROM t_null WHERE y IN (NULL,3)` 将返回以下结果: ```text ┌─x─┐ @@ -111,7 +113,7 @@ ORDER BY EventDate ASC └───┘ ``` -可以看到 `y = NULL` 的行被从查询结果中排除。这是因为 ClickHouse 无法确定 `NULL` 是否包含在 `(NULL,3)` 集中,返回 `0` 作为运算结果,因此 `SELECT` 排除该行的最终输出。 +可以看到,其中 `y = NULL` 的行被排除在查询结果之外。这是因为 ClickHouse 无法决定 `NULL` 是否包含在 `(NULL,3)` 集合中,返回操作的结果为 `0`,因此 `SELECT` 将该行从最终输出中排除。 ```sql SELECT y IN (NULL, 3) @@ -127,23 +129,23 @@ FROM t_null ## 分布式子查询 {#distributed-subqueries} -带有子查询的 `IN` 操作符有两种选项(类似于 `JOIN` 操作符):普通的 `IN` / `JOIN` 和 `GLOBAL IN` / `GLOBAL JOIN`。它们在分布式查询处理中运行的方式不同。 +`IN` 操作符与子查询有两种选项(类似于 `JOIN` 操作符):普通 `IN` / `JOIN` 和 `GLOBAL IN` / `GLOBAL JOIN`。它们在分布式查询处理中的运行方式不同。 :::note -请记住,下面描述的算法可能会根据 [设置](../../operations/settings/settings.md) 中的 `distributed_product_mode` 设置而有所不同。 +请记住,下面描述的算法可能会根据[设置](../../operations/settings/settings.md)中的`distributed_product_mode`设置而异。 ::: -使用常规的 `IN` 时,查询会发送到远程服务器,每个服务器会运行 `IN` 或 `JOIN` 子句中的子查询。 +使用常规的 `IN` 时,查询会发送到远程服务器,每台服务器都会运行 `IN` 或 `JOIN` 子句中的子查询。 -使用 `GLOBAL IN` / `GLOBAL JOIN` 时,首先运行所有 `GLOBAL IN` / `GLOBAL JOIN` 的子查询,并将结果收集到临时表中。然后将临时表发送到每个远程服务器,查询将使用这些临时数据运行。 +使用 `GLOBAL IN` / `GLOBAL JOIN` 时,首先对所有子查询进行 `GLOBAL IN` / `GLOBAL JOIN`,并将结果收集到临时表中。然后将临时表发送到每个远程服务器,在这些服务器上使用该临时数据运行查询。 对于非分布式查询,请使用常规的 `IN` / `JOIN`。 -在进行分布式查询处理时,小心使用 `IN` / `JOIN` 子句中的子查询。 +在分布式查询处理时,使用 `IN` / `JOIN` 子句中的子查询时请小心。 -让我们看看一些示例。假设集群中的每个服务器都有一个普通的 **local_table**。每个服务器还具有一个类型为 **Distributed** 的 **distributed_table** 表,用于查看集群中的所有服务器。 +让我们看一些示例。假设集群中的每台服务器都有一个普通的 **local_table**。每台服务器还有一个 **distributed_table** 表,其类型为 **Distributed**,可以查看集群中的所有服务器。 -对于 **distributed_table** 的查询,查询将发送到所有远程服务器,并在它们上运行,使用 **local_table**。 +针对 **distributed_table** 的查询将发送到所有远程服务器,并在它们上使用 **local_table**。 例如,查询 @@ -151,13 +153,13 @@ FROM t_null SELECT uniq(UserID) FROM distributed_table ``` -将作为以下查询发送到所有远程服务器: +将以如下格式发送到所有远程服务器 ```sql SELECT uniq(UserID) FROM local_table ``` -并在每个服务器上并行运行,直到达到可以组合中间结果的阶段。然后,中间结果将返回请求服务器并在其上合并,最终结果将发送到客户端。 +并在每台服务器上并行运行,直到达到可以合并中间结果的阶段。然后将中间结果返回给请求者服务器并在其上合并,最终结果将发送给客户端。 现在让我们检查一个带有 `IN` 的查询: @@ -167,37 +169,37 @@ SELECT uniq(UserID) FROM distributed_table WHERE CounterID = 101500 AND UserID I - 计算两个网站受众的交集。 -此查询将作为以下查询发送到所有远程服务器: +该查询将以如下格式发送到所有远程服务器 ```sql SELECT uniq(UserID) FROM local_table WHERE CounterID = 101500 AND UserID IN (SELECT UserID FROM local_table WHERE CounterID = 34) ``` -换句话说,`IN` 子句中的数据集将在每台服务器上独立收集,仅跨每台服务器上存储的数据。 +换句话说,`IN` 子句中的数据集将在每台服务器上独立收集,仅针对每台服务器本地存储的数据。 -如果您为此情况做好准备,并且已经将数据分布在集群服务器上,以便单个 UserID 的数据完全位于单个服务器上,则这将正确且高效地工作。在这种情况下,每台服务器上都将本地可用所有必要数据。否则,结果将不准确。我们将这种查询变体称为“本地 IN”。 +如果您已经为此情况做好准备,并且在集群服务器上分布数据,使得单个 UserID 的数据完全位于一台服务器上,则这样工作会正确且最佳。在这种情况下,所有必要的数据都会在每台服务器的本地可用。否则,结果将不准确。我们将这种查询的变体称为“本地 IN”。 -要更正查询在数据随机分布在集群服务器上的工作方式,您可以在子查询中指定 **distributed_table**。查询将如下所示: +为了修正查询在数据随机分布于集群服务器上的工作方式,您可以在子查询中指定 **distributed_table**。查询将如下所示: ```sql SELECT uniq(UserID) FROM distributed_table WHERE CounterID = 101500 AND UserID IN (SELECT UserID FROM distributed_table WHERE CounterID = 34) ``` -此查询将作为以下查询发送到所有远程服务器: +该查询将以如下格式发送到所有远程服务器 ```sql SELECT uniq(UserID) FROM local_table WHERE CounterID = 101500 AND UserID IN (SELECT UserID FROM distributed_table WHERE CounterID = 34) ``` -子查询将开始在每个远程服务器上运行。由于子查询使用分布式表,因此每个远程服务器上的子查询将重新发送到所有远程服务器,如下所示: +子查询将在每个远程服务器上开始运行。由于子查询使用分布式表,因此每个远程服务器上的子查询将重新发送到每台远程服务器,如下所示: ```sql SELECT UserID FROM local_table WHERE CounterID = 34 ``` -例如,如果您有一个由 100 台服务器组成的集群,执行整个查询将需要 10,000 个基本请求,这通常被认为是不可接受的。 +例如,如果您有一个 100 台服务器的集群,执行整个查询将需要 10,000 个基本请求,这通常被认为是不可接受的。 -在这种情况下,您应该始终使用 `GLOBAL IN` 而不是 `IN`。让我们看看它在查询中的工作方式: +在这种情况下,您应该始终使用 `GLOBAL IN` 而不是 `IN`。让我们看看查询的工作原理: ```sql SELECT uniq(UserID) FROM distributed_table WHERE CounterID = 101500 AND UserID GLOBAL IN (SELECT UserID FROM distributed_table WHERE CounterID = 34) @@ -209,60 +211,60 @@ SELECT uniq(UserID) FROM distributed_table WHERE CounterID = 101500 AND UserID G SELECT UserID FROM distributed_table WHERE CounterID = 34 ``` -结果将放入 RAM 中的临时表。然后请求将作为以下内容发送到每个远程服务器: +结果将放入 RAM 中的临时表中。然后请求将以如下格式发送到每个远程服务器: ```sql SELECT uniq(UserID) FROM local_table WHERE CounterID = 101500 AND UserID GLOBAL IN _data1 ``` -临时表 `_data1` 将与查询一起发送到每个远程服务器(临时表的名称由实现决定)。 +临时表 `_data1` 将与查询一起发送到每台远程服务器(临时表的名称是实现定义的)。 -这比使用普通的 `IN` 更有效。但请记住以下几点: +这比使用常规的 `IN` 更具优化。但是,请记住以下几点: -1. 创建临时表时,数据不会唯一。为了减少网络上传输的数据量,请在子查询中指定 DISTINCT。(对于普通的 `IN` 不需要这样做。) -2. 临时表将发送到所有远程服务器。传输不考虑网络拓扑。例如,如果 10 台远程服务器位于与请求服务器关系非常遥远的数据中心,则数据将通过通道发送 10 次到远程数据中心。尝试在使用 `GLOBAL IN` 时避免大型数据集。 -3. 向远程服务器传输数据时,无法配置网络带宽的限制。您可能会过载网络。 -4. 尝试在服务器之间分配数据,以便不需要经常使用 `GLOBAL IN`。 -5. 如果您需要频繁使用 `GLOBAL IN`,请规划 ClickHouse 集群的位置,以便一组副本不超过一个数据中心,并且它们之间网络速度较快,以便查询可以完全在单个数据中心内处理。 +1. 创建临时表时,数据不会变得唯一。为了减少通过网络传输的数据量,请在子查询中指定 DISTINCT。(对于普通的 `IN`,您不需要这样做。) +2. 临时表将发送到所有远程服务器。传输不考虑网络拓扑。例如,如果 10 台远程服务器位于与请求服务器非常偏远的数据中心,则数据将在通道上向远程数据中心发送 10 次。在使用 `GLOBAL IN` 时,尝试避免大型数据集。 +3. 向远程服务器传输数据时,网络带宽的限制不可配置。您可能会导致网络过载。 +4. 尝试在服务器间分配数据,以便您不需要定期使用 `GLOBAL IN`。 +5. 如果您需要频繁使用 `GLOBAL IN`,请规划 ClickHouse 集群的位置,以便一组副本位于不超过一个数据中心中,并且它们之间的网络快速,这样查询可以完全在单一数据中心内处理。 -在 `GLOBAL IN` 子句中指定本地表也是合理的,以防此本地表仅在请求服务器上可用,并且您希望从远程服务器使用该数据。 +在 `GLOBAL IN` 子句中指定本地表也是有意义的,如果该本地表仅在请求服务器上可用,并且您希望在远程服务器上使用该数据。 ### 分布式子查询与 max_rows_in_set {#distributed-subqueries-and-max_rows_in_set} -您可以使用 [`max_rows_in_set`](/operations/settings/settings#max_rows_in_set) 和 [`max_bytes_in_set`](/operations/settings/settings#max_bytes_in_set) 来控制在分布式查询期间传输的数据量。 +您可以使用 [`max_rows_in_set`](/operations/settings/settings#max_rows_in_set) 和 [`max_bytes_in_set`](/operations/settings/settings#max_bytes_in_set) 来控制分布式查询期间传输的数据量。 -这对于 `GLOBAL IN` 查询返回大量数据时尤其重要。考虑以下 SQL: +这在 `GLOBAL IN` 查询返回大量数据时尤为重要。请考虑以下 SQL: ```sql -select * from table1 where col1 global in (select col1 from table2 where ) +SELECT * FROM table1 WHERE col1 GLOBAL IN (SELECT col1 FROM table2 WHERE ) ``` - -如果 `some_predicate` 的选择性不足,将返回大量数据并导致性能问题。在这种情况下,限制网络数据传输是明智的。此外,请注意 [`set_overflow_mode`](/operations/settings/settings#set_overflow_mode) 默认为 `throw`,这意味着当达到这些阈值时会引发异常。 + +如果 `some_predicate` 的选择性不够,它将返回大量数据并导致性能问题。在这种情况下,限制通过网络传输的数据量是明智的。此外,请注意,[`set_overflow_mode`](/operations/settings/settings#set_overflow_mode) 默认为 `throw`,这意味着达到了这些阈值时会抛出异常。 ### 分布式子查询与 max_parallel_replicas {#distributed-subqueries-and-max_parallel_replicas} -当 [max_parallel_replicas](#distributed-subqueries-and-max_parallel_replicas) 大于 1 时,分布式查询进一步转化。 +当[max_parallel_replicas](#distributed-subqueries-and-max_parallel_replicas)大于 1 时,分布式查询会进一步转换。 -例如,下面的查询: +例如,以下内容: ```sql SELECT CounterID, count() FROM distributed_table_1 WHERE UserID IN (SELECT UserID FROM local_table_2 WHERE CounterID < 100) SETTINGS max_parallel_replicas=3 ``` -在每个服务器上转化为: +在每台服务器上转换为: ```sql SELECT CounterID, count() FROM local_table_1 WHERE UserID IN (SELECT UserID FROM local_table_2 WHERE CounterID < 100) SETTINGS parallel_replicas_count=3, parallel_replicas_offset=M ``` -其中 `M` 在 `1` 和 `3` 之间,具体取决于本地查询在哪个副本上执行。 +其中 `M` 介于 `1` 和 `3` 之间,具体取决于本地查询在哪个副本上执行。 -这些设置影响查询中的每个 MergeTree 家族表,并具有与在每个表上应用 `SAMPLE 1/3 OFFSET (M-1)/3` 相同的效果。 +这些设置影响查询中的每个 MergeTree 系列表,并与对每个表应用 `SAMPLE 1/3 OFFSET (M-1)/3` 的效果相同。 -因此,添加 [max_parallel_replicas](#distributed-subqueries-and-max_parallel_replicas) 设置只有在两个表具有相同的复制方案并按 UserID 或其子键进行采样时才会产生正确的结果。特别是,如果 `local_table_2` 没有采样键,将会产生不正确的结果。这个规则同样适用于 `JOIN`。 +因此,仅在两个表具有相同的复制方案并按 UserID 或其子键进行采样时,添加 [max_parallel_replicas](#distributed-subqueries-and-max_parallel_replicas) 设置才会产生正确的结果。特别是如果 `local_table_2` 没有采样键,将会产生不正确的结果。相同的规则适用于 `JOIN`。 -如果 `local_table_2` 不符合要求,那么可以使用 `GLOBAL IN` 或 `GLOBAL JOIN` 作为变通方法。 +如果 `local_table_2` 不满足要求,一种解决方法是使用 `GLOBAL IN` 或 `GLOBAL JOIN`。 -如果表没有采样键,可以使用更灵活的 [parallel_replicas_custom_key](/operations/settings/settings#parallel_replicas_custom_key) 选项,这可以产生不同且更优的行为。 +如果表没有采样键,可以使用更灵活的选项 [parallel_replicas_custom_key](/operations/settings/settings#parallel_replicas_custom_key) 来产生不同且更优化的行为。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/operators/in.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/operators/in.md.hash index ef7f0a7c94d..ce0c95a637d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/operators/in.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/operators/in.md.hash @@ -1 +1 @@ -094ef802b26ede0d +9ca5e2f21ca5b541 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/operators/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/operators/index.md index fad204b045c..895e83f7b74 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/operators/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/operators/index.md @@ -5,123 +5,123 @@ 'sidebar_position': 38 'slug': '/sql-reference/operators/' 'title': '操作符' +'doc_type': 'reference' --- -# 操作符 +# 运算符 -ClickHouse 在查询解析阶段根据操作符的优先级、优先顺序和结合性将操作符转换为其相应的函数。 +ClickHouse 会根据运算符的优先级、等级和结合性,在查询解析阶段将运算符转换为相应的函数。 -## 访问操作符 {#access-operators} +## 访问运算符 {#access-operators} -`a[N]` – 访问数组的一个元素。这个对应的函数是 `arrayElement(a, N)`。 +`a[N]` – 访问数组的元素。相当于 `arrayElement(a, N)` 函数。 -`a.N` – 访问元组元素。这个对应的函数是 `tupleElement(a, N)`。 +`a.N` – 访问元组元素。相当于 `tupleElement(a, N)` 函数。 -## 数值取负操作符 {#numeric-negation-operator} +## 数值否定运算符 {#numeric-negation-operator} -`-a` – 这个对应的函数是 `negate (a)`。 +`-a` – 相当于 `negate(a)` 函数。 -对于元组取负: [tupleNegate](../../sql-reference/functions/tuple-functions.md#tuplenegate)。 +对于元组否定: [tupleNegate](../../sql-reference/functions/tuple-functions.md#tuplenegate)。 -## 乘法和除法操作符 {#multiplication-and-division-operators} +## 乘法和除法运算符 {#multiplication-and-division-operators} -`a * b` – 这个对应的函数是 `multiply (a, b)`。 +`a * b` – 相当于 `multiply(a, b)` 函数。 -用于将元组与数字相乘: [tupleMultiplyByNumber](../../sql-reference/functions/tuple-functions.md#tuplemultiplybynumber),用于标量乘积: [dotProduct](/sql-reference/functions/array-functions#arraydotproduct)。 +对于元组乘以数字:[tupleMultiplyByNumber](../../sql-reference/functions/tuple-functions.md#tuplemultiplybynumber),对于标量积:[dotProduct](/sql-reference/functions/array-functions#arrayDotProduct)。 -`a / b` – 这个对应的函数是 `divide(a, b)`。 +`a / b` – 相当于 `divide(a, b)` 函数。 -用于将元组与数字相除: [tupleDivideByNumber](../../sql-reference/functions/tuple-functions.md#tupledividebynumber)。 +对于元组除以数字:[tupleDivideByNumber](../../sql-reference/functions/tuple-functions.md#tupledividebynumber)。 -`a % b` – 这个对应的函数是 `modulo(a, b)`。 +`a % b` – 相当于 `modulo(a, b)` 函数。 -## 加法和减法操作符 {#addition-and-subtraction-operators} +## 加法和减法运算符 {#addition-and-subtraction-operators} -`a + b` – 这个对应的函数是 `plus(a, b)`。 +`a + b` – 相当于 `plus(a, b)` 函数。 -用于元组的加法: [tuplePlus](../../sql-reference/functions/tuple-functions.md#tupleplus)。 +对于元组加法:[tuplePlus](../../sql-reference/functions/tuple-functions.md#tupleplus)。 -`a - b` – 这个对应的函数是 `minus(a, b)`。 +`a - b` – 相当于 `minus(a, b)` 函数。 -用于元组的减法: [tupleMinus](../../sql-reference/functions/tuple-functions.md#tupleminus)。 +对于元组减法:[tupleMinus](../../sql-reference/functions/tuple-functions.md#tupleminus)。 -## 比较操作符 {#comparison-operators} +## 比较运算符 {#comparison-operators} ### 等于函数 {#equals-function} -`a = b` – 这个对应的函数是 `equals(a, b)`。 +`a = b` – 相当于 `equals(a, b)` 函数。 -`a == b` – 这个对应的函数是 `equals(a, b)`。 +`a == b` – 相当于 `equals(a, b)` 函数。 ### 不等于函数 {#notequals-function} -`a != b` – 这个对应的函数是 `notEquals(a, b)`。 +`a != b` – 相当于 `notEquals(a, b)` 函数。 -`a <> b` – 这个对应的函数是 `notEquals(a, b)`。 +`a <> b` – 相当于 `notEquals(a, b)` 函数。 ### 小于或等于函数 {#lessorequals-function} -`a <= b` – 这个对应的函数是 `lessOrEquals(a, b)`。 +`a <= b` – 相当于 `lessOrEquals(a, b)` 函数。 ### 大于或等于函数 {#greaterorequals-function} -`a >= b` – 这个对应的函数是 `greaterOrEquals(a, b)`。 +`a >= b` – 相当于 `greaterOrEquals(a, b)` 函数。 ### 小于函数 {#less-function} -`a < b` – 这个对应的函数是 `less(a, b)`。 +`a < b` – 相当于 `less(a, b)` 函数。 ### 大于函数 {#greater-function} -`a > b` – 这个对应的函数是 `greater(a, b)`。 +`a > b` – 相当于 `greater(a, b)` 函数。 ### LIKE 函数 {#like-function} -`a LIKE s` – 这个对应的函数是 `like(a, b)`。 +`a LIKE b` – 相当于 `like(a, b)` 函数。 ### NOT LIKE 函数 {#notlike-function} -`a NOT LIKE s` – 这个对应的函数是 `notLike(a, b)`。 +`a NOT LIKE b` – 相当于 `notLike(a, b)` 函数。 ### ILIKE 函数 {#ilike-function} -`a ILIKE s` – 这个对应的函数是 `ilike(a, b)`。 +`a ILIKE b` – 相当于 `ilike(a, b)` 函数。 ### BETWEEN 函数 {#between-function} `a BETWEEN b AND c` – 与 `a >= b AND a <= c` 相同。 `a NOT BETWEEN b AND c` – 与 `a < b OR a > c` 相同。 -## 数据集操作的操作符 {#operators-for-working-with-data-sets} +## 数据集操作运算符 {#operators-for-working-with-data-sets} -请参阅 [IN 操作符](../../sql-reference/operators/in.md) 和 [EXISTS](../../sql-reference/operators/exists.md) 操作符。 +参见 [IN 运算符](../../sql-reference/operators/in.md) 和 [EXISTS](../../sql-reference/operators/exists.md) 运算符。 -### IN 函数 {#in-function} -`a IN ...` – 这个对应的函数是 `in(a, b)`。 +### in 函数 {#in-function} +`a IN ...` – 相当于 `in(a, b)` 函数。 -### NOT IN 函数 {#notin-function} -`a NOT IN ...` – 这个对应的函数是 `notIn(a, b)`。 +### notIn 函数 {#notin-function} +`a NOT IN ...` – 相当于 `notIn(a, b)` 函数。 -### GLOBAL IN 函数 {#globalin-function} -`a GLOBAL IN ...` – 这个对应的函数是 `globalIn(a, b)`。 +### globalIn 函数 {#globalin-function} +`a GLOBAL IN ...` – 相当于 `globalIn(a, b)` 函数。 -### GLOBAL NOT IN 函数 {#globalnotin-function} -`a GLOBAL NOT IN ...` – 这个对应的函数是 `globalNotIn(a, b)`。 +### globalNotIn 函数 {#globalnotin-function} +`a GLOBAL NOT IN ...` – 相当于 `globalNotIn(a, b)` 函数。 -### IN 子查询函数 {#in-subquery-function} -`a = ANY (subquery)` – 这个对应的函数是 `in(a, subquery)`。 +### in 子查询函数 {#in-subquery-function} +`a = ANY (subquery)` – 相当于 `in(a, subquery)` 函数。 -### NOT IN 子查询函数 {#notin-subquery-function} +### notIn 子查询函数 {#notin-subquery-function} `a != ANY (subquery)` – 与 `a NOT IN (SELECT singleValueOrNull(*) FROM subquery)` 相同。 -### IN 子查询函数 {#in-subquery-function-1} +### in 子查询函数 {#in-subquery-function-1} `a = ALL (subquery)` – 与 `a IN (SELECT singleValueOrNull(*) FROM subquery)` 相同。 -### NOT IN 子查询函数 {#notin-subquery-function-1} -`a != ALL (subquery)` – 这个对应的函数是 `notIn(a, subquery)`。 - +### notIn 子查询函数 {#notin-subquery-function-1} +`a != ALL (subquery)` – 相当于 `notIn(a, subquery)` 函数。 **示例** -使用 ALL 的查询: +查询使用 ALL: ```sql SELECT number AS a FROM numbers(10) WHERE a > ALL (SELECT number FROM numbers(3, 3)); ``` -结果: +结果: ```text ┌─a─┐ @@ -132,13 +132,13 @@ SELECT number AS a FROM numbers(10) WHERE a > ALL (SELECT number FROM numbers(3, └───┘ ``` -使用 ANY 的查询: +查询使用 ANY: ```sql SELECT number AS a FROM numbers(10) WHERE a > ANY (SELECT number FROM numbers(3, 3)); ``` -结果: +结果: ```text ┌─a─┐ @@ -151,7 +151,7 @@ SELECT number AS a FROM numbers(10) WHERE a > ANY (SELECT number FROM numbers(3, └───┘ ``` -## 日期和时间操作的操作符 {#operators-for-working-with-dates-and-times} +## 日期和时间操作运算符 {#operators-for-working-with-dates-and-times} ### EXTRACT {#extract} @@ -159,16 +159,16 @@ SELECT number AS a FROM numbers(10) WHERE a > ANY (SELECT number FROM numbers(3, EXTRACT(part FROM date); ``` -从给定日期提取部分。例如,您可以从给定日期中提取月份,或者从时间中提取秒数。 +从给定日期提取部分值。例如,您可以从给定日期中获取月份,或者从时间中获取秒。 -`part` 参数指定要提取日期的哪个部分。以下值可用: +`part` 参数指定要检索的日期部分。可用的值如下: -- `DAY` — 月中的某一天。可取值:1–31。 -- `MONTH` — 月份的数字。可取值:1–12。 +- `DAY` — 月中的天。可能的值:1–31。 +- `MONTH` — 月份的数字。可能的值:1–12。 - `YEAR` — 年。 -- `SECOND` — 秒。可取值:0–59。 -- `MINUTE` — 分钟。可取值:0–59。 -- `HOUR` — 小时。可取值:0–23。 +- `SECOND` — 秒。可能的值:0–59。 +- `MINUTE` — 分钟。可能的值:0–59。 +- `HOUR` — 小时。可能的值:0–23。 `part` 参数不区分大小写。 @@ -182,7 +182,7 @@ SELECT EXTRACT(MONTH FROM toDate('2017-06-15')); SELECT EXTRACT(YEAR FROM toDate('2017-06-15')); ``` -在以下示例中,我们创建一个表并插入一个 `DateTime` 类型的值。 +在以下示例中,我们创建一个表并插入一个具有 `DateTime` 类型的值。 ```sql CREATE TABLE test.Orders @@ -215,11 +215,11 @@ FROM test.Orders; └───────────┴────────────┴──────────┴───────────┴─────────────┴─────────────┘ ``` -您可以在 [tests](https://github.com/ClickHouse/ClickHouse/blob/master/tests/queries/0_stateless/00619_extract.sql) 中查看更多示例。 +您可以在 [tests](https://github.com/ClickHouse/ClickHouse/blob/master/tests/queries/0_stateless/00619_extract.sql) 中看到更多示例。 ### INTERVAL {#interval} -创建一个 [Interval](../../sql-reference/data-types/special-data-types/interval.md) 类型的值,该值应在与 [Date](../../sql-reference/data-types/date.md) 和 [DateTime](../../sql-reference/data-types/datetime.md) 类型的值进行算术运算时使用。 +创建一个 [Interval](../../sql-reference/data-types/special-data-types/interval.md)-类型值,该值应在与 [Date](../../sql-reference/data-types/date.md) 和 [DateTime](../../sql-reference/data-types/datetime.md)-类型值进行算术操作时使用。 间隔类型: - `SECOND` @@ -231,10 +231,10 @@ FROM test.Orders; - `QUARTER` - `YEAR` -在设置 `INTERVAL` 值时,您还可以使用字符串文字。例如,`INTERVAL 1 HOUR` 与 `INTERVAL '1 hour'` 或 `INTERVAL '1' hour` 是相同的。 +设置 `INTERVAL` 值时,您还可以使用字符串字面量。例如,`INTERVAL 1 HOUR` 与 `INTERVAL '1 hour'` 或 `INTERVAL '1' hour` 是相同的。 :::tip -不同类型的间隔不能结合。您不能使用像 `INTERVAL 4 DAY 1 HOUR` 这样的表达式。请在单位小于或等于间隔的最小单位时指定间隔,例如 `INTERVAL 25 HOUR`。您可以执行连续操作,如下面的示例所示。 +不同类型的间隔不能结合。您不能使用表达式如 `INTERVAL 4 DAY 1 HOUR`。应在小于或等于间隔的最小单位的单位中指定间隔,例如 `INTERVAL 25 HOUR`。您可以使用连续操作,如下例所示。 ::: 示例: @@ -270,7 +270,7 @@ SELECT now() AS current_date_time, current_date_time + INTERVAL '4' day + INTERV ``` :::note -总是推荐使用 `INTERVAL` 语法或 `addDays` 函数。简单的加法或减法(例如 `now() + ...`)不考虑时间设置,例如夏令时。 +建议优先使用 `INTERVAL` 语法或 `addDays` 函数。简单的加法或减法(如 `now() + ...` 的语法)不考虑时间设置。例如,夏令时。 ::: 示例: @@ -290,25 +290,25 @@ SELECT toDateTime('2014-10-26 00:00:00', 'Asia/Istanbul') AS time, time + 60 * 6 - [Interval](../../sql-reference/data-types/special-data-types/interval.md) 数据类型 - [toInterval](/sql-reference/functions/type-conversion-functions#tointervalyear) 类型转换函数 -## 逻辑 AND 操作符 {#logical-and-operator} +## 逻辑与运算符 {#logical-and-operator} -语法 `SELECT a AND b` — 计算 `a` 和 `b` 的逻辑与,使用函数 [and](/sql-reference/functions/logical-functions#and)。 +语法 `SELECT a AND b` — 计算 `a` 和 `b` 的逻辑合取,使用函数 [and](/sql-reference/functions/logical-functions#and)。 -## 逻辑 OR 操作符 {#logical-or-operator} +## 逻辑或运算符 {#logical-or-operator} -语法 `SELECT a OR b` — 计算 `a` 和 `b` 的逻辑或,使用函数 [or](/sql-reference/functions/logical-functions#or)。 +语法 `SELECT a OR b` — 计算 `a` 和 `b` 的逻辑析取,使用函数 [or](/sql-reference/functions/logical-functions#or)。 -## 逻辑取反操作符 {#logical-negation-operator} +## 逻辑否定运算符 {#logical-negation-operator} -语法 `SELECT NOT a` — 计算 `a` 的逻辑取反,使用函数 [not](/sql-reference/functions/logical-functions#not)。 +语法 `SELECT NOT a` — 计算 `a` 的逻辑否定,使用函数 [not](/sql-reference/functions/logical-functions#not)。 -## 条件操作符 {#conditional-operator} +## 条件运算符 {#conditional-operator} -`a ? b : c` – 这个对应的函数是 `if(a, b, c)`。 +`a ? b : c` – 相当于 `if(a, b, c)` 函数。 注意: -条件操作符计算 b 和 c 的值,然后检查条件 a 是否满足,然后返回相应的值。如果 `b` 或 `C` 是一个 [arrayJoin()](/sql-reference/functions/array-join) 函数,则每一行将被复制,不管 "a" 条件。 +条件运算符计算 b 和 c 的值,然后检查条件 a 是否满足,随后返回相应的值。如果 `b` 或 `c` 是 [arrayJoin()](/sql-reference/functions/array-join) 函数,则无论 "a" 条件如何,每行都会被复制。 ## 条件表达式 {#conditional-expression} @@ -320,49 +320,49 @@ CASE [x] END ``` -如果指定了 `x`,则使用 `transform(x, [a, ...], [b, ...], c)` 函数。否则 – `multiIf(a, b, ..., c)`。 +如果指定了 `x`,则使用 `transform(x, [a, ...], [b, ...], c)` 函数。否则使用 `multiIf(a, b, ..., c)`。 -如果表达式中没有 `ELSE c` 子句,默认值为 `NULL`。 +如果表达式中没有 `ELSE c` 子句,则默认值为 `NULL`。 `transform` 函数不适用于 `NULL`。 -## 连接操作符 {#concatenation-operator} +## 连接运算符 {#concatenation-operator} -`s1 || s2` – 这个对应的函数是 `concat(s1, s2)`。 +`s1 || s2` – 相当于 `concat(s1, s2)` 函数。 -## Lambda 创建操作符 {#lambda-creation-operator} +## Lambda 创建运算符 {#lambda-creation-operator} -`x -> expr` – 这个对应的函数是 `lambda(x, expr)`。 +`x -> expr` – 相当于 `lambda(x, expr)` 函数。 -以下操作符没有优先级,因为它们是括号: +以下运算符没有优先级,因为它们是括号: -## 数组创建操作符 {#array-creation-operator} +## 数组创建运算符 {#array-creation-operator} -`[x1, ...]` – 这个对应的函数是 `array(x1, ...)`。 +`[x1, ...]` – 相当于 `array(x1, ...)` 函数。 -## 元组创建操作符 {#tuple-creation-operator} +## 元组创建运算符 {#tuple-creation-operator} -`(x1, x2, ...)` – 这个对应的函数是 `tuple(x2, x2, ...)`。 +`(x1, x2, ...)` – 相当于 `tuple(x2, x2, ...)` 函数。 ## 结合性 {#associativity} -所有二元操作符具有左结合性。例如,`1 + 2 + 3` 转换为 `plus(plus(1, 2), 3)`。 -有时这并不会按照您的预期工作。例如,`SELECT 4 > 2 > 3` 将结果为 0。 +所有二元运算符都是左结合的。例如,`1 + 2 + 3` 转换为 `plus(plus(1, 2), 3)`。 +有时这不按您预期的方式工作。例如,`SELECT 4 > 2 > 3` 的结果将为 0。 -为了提高效率,`and` 和 `or` 函数接受任意数量的参数。对应的 `AND` 和 `OR` 操作符的链被转换为这些函数的单次调用。 +为了效率,`and` 和 `or` 函数接受任何数量的参数。相应的 `AND` 和 `OR` 运算符的链条会被转换为这些函数的单一调用。 -## NULL 检查 {#checking-for-null} +## 检查 `NULL` {#checking-for-null} -ClickHouse 支持 `IS NULL` 和 `IS NOT NULL` 操作符。 +ClickHouse 支持 `IS NULL` 和 `IS NOT NULL` 运算符。 ### IS NULL {#is_null} -- 对于 [Nullable](../../sql-reference/data-types/nullable.md) 类型的值,`IS NULL` 操作符返回: - - `1`,如果值为 `NULL`。 - - 否则返回 `0`。 -- 对于其他值,`IS NULL` 操作符始终返回 `0`。 +- 对于 [Nullable](../../sql-reference/data-types/nullable.md) 类型的值,`IS NULL` 运算符返回: + - `1`,如果值为 `NULL`。 + - 否则返回 `0`。 +- 对于其他值,`IS NULL` 运算符始终返回 `0`。 -可以通过启用 [optimize_functions_to_subcolumns](/operations/settings/settings#optimize_functions_to_subcolumns) 设置进行优化。使用 `optimize_functions_to_subcolumns = 1` 时,该函数仅读取 [null](../../sql-reference/data-types/nullable.md#finding-null) 子列,而不是读取和处理整个列的数据。查询 `SELECT n IS NULL FROM table` 转换为 `SELECT n.null FROM TABLE`。 +可以通过启用 [optimize_functions_to_subcolumns](/operations/settings/settings#optimize_functions_to_subcolumns) 设置来优化。使用 `optimize_functions_to_subcolumns = 1` 时,函数只读取 [null](../../sql-reference/data-types/nullable.md#finding-null) 子列,而不是读取和处理整列数据。查询 `SELECT n IS NULL FROM table` 转换为 `SELECT n.null FROM TABLE`。 @@ -378,10 +378,10 @@ SELECT x+100 FROM t_null WHERE y IS NULL ### IS NOT NULL {#is_not_null} -- 对于 [Nullable](../../sql-reference/data-types/nullable.md) 类型的值,`IS NOT NULL` 操作符返回: - - `0`,如果值为 `NULL`。 - - 否则返回 `1`。 -- 对于其他值,`IS NOT NULL` 操作符始终返回 `1`。 +- 对于 [Nullable](../../sql-reference/data-types/nullable.md) 类型的值,`IS NOT NULL` 运算符返回: + - `0`,如果值为 `NULL`。 + - 否则返回 `1`。 +- 对于其他值,`IS NOT NULL` 运算符始终返回 `1`。 @@ -395,4 +395,4 @@ SELECT * FROM t_null WHERE y IS NOT NULL └───┴───┘ ``` -可以通过启用 [optimize_functions_to_subcolumns](/operations/settings/settings#optimize_functions_to_subcolumns) 设置进行优化。使用 `optimize_functions_to_subcolumns = 1` 时,该函数仅读取 [null](../../sql-reference/data-types/nullable.md#finding-null) 子列,而不是读取和处理整个列的数据。查询 `SELECT n IS NOT NULL FROM table` 转换为 `SELECT NOT n.null FROM TABLE`。 +可以通过启用 [optimize_functions_to_subcolumns](/operations/settings/settings#optimize_functions_to_subcolumns) 设置来优化。使用 `optimize_functions_to_subcolumns = 1` 时,函数只读取 [null](../../sql-reference/data-types/nullable.md#finding-null) 子列,而不是读取和处理整列数据。查询 `SELECT n IS NOT NULL FROM table` 转换为 `SELECT NOT n.null FROM TABLE`。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/operators/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/operators/index.md.hash index b44d65cafaf..a856fc864a9 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/operators/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/operators/index.md.hash @@ -1 +1 @@ -b016dbacf24140ad +5539931332723aa6 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/apply-deleted-mask.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/apply-deleted-mask.md index 7f175f94d46..09ade02f2d3 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/apply-deleted-mask.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/apply-deleted-mask.md @@ -1,9 +1,10 @@ --- -'description': '已删除行掩码的文档' +'description': '关于应用已删除行的掩码的文档' 'sidebar_label': 'APPLY DELETED MASK' 'sidebar_position': 46 'slug': '/sql-reference/statements/alter/apply-deleted-mask' 'title': '应用已删除行的掩码' +'doc_type': 'reference' --- @@ -13,13 +14,13 @@ ALTER TABLE [db].name [ON CLUSTER cluster] APPLY DELETED MASK [IN PARTITION partition_id] ``` -该命令应用由 [轻量级删除](/sql-reference/statements/delete) 创建的掩码,并强制从磁盘中删除标记为已删除的行。该命令是一个重量级变更,其语义等同于查询 ```ALTER TABLE [db].name DELETE WHERE _row_exists = 0```。 +该命令应用通过 [轻量级删除](/sql-reference/statements/delete) 创建的掩码,并强制从磁盘中删除标记为已删除的行。该命令属于重量级变更,与查询 ```ALTER TABLE [db].name DELETE WHERE _row_exists = 0``` 在语义上等价。 :::note -它仅适用于 [`MergeTree`](../../../engines/table-engines/mergetree-family/mergetree.md) 家族的表(包括 [复制](../../../engines/table-engines/mergetree-family/replication.md) 表)。 +它仅适用于 [`MergeTree`](../../../engines/table-engines/mergetree-family/mergetree.md) 家族中的表(包括 [复制](../../../engines/table-engines/mergetree-family/replication.md) 表)。 ::: -**参见** +**另见** - [轻量级删除](/sql-reference/statements/delete) - [重量级删除](/sql-reference/statements/alter/delete.md) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/apply-deleted-mask.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/apply-deleted-mask.md.hash index 76dee6a259c..122c9d99b3f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/apply-deleted-mask.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/apply-deleted-mask.md.hash @@ -1 +1 @@ -65d2dbff97bd931b +7f350777b9e9c181 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/column.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/column.md index 39ee5dc1892..24da963b6f5 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/column.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/column.md @@ -1,12 +1,13 @@ --- -'description': '关于 COLUMN 的文档' +'description': '有关 Column 的文档' 'sidebar_label': 'COLUMN' 'sidebar_position': 37 'slug': '/sql-reference/statements/alter/column' -'title': '列操作' +'title': '列 操作' +'doc_type': 'reference' --- -一组允许更改表结构的查询。 +一组允许改变表结构的查询。 语法: @@ -15,21 +16,21 @@ ALTER [TEMPORARY] TABLE [db].name [ON CLUSTER cluster] ADD|DROP|RENAME|CLEAR|COM ``` 在查询中,指定一个或多个以逗号分隔的操作列表。 -每个操作是对列的操作。 +每个操作都是针对列的操作。 支持以下操作: - [ADD COLUMN](#add-column) — 向表中添加新列。 - [DROP COLUMN](#drop-column) — 删除列。 - [RENAME COLUMN](#rename-column) — 重命名现有列。 -- [CLEAR COLUMN](#clear-column) — 重置列值。 +- [CLEAR COLUMN](#clear-column) — 重置列的值。 - [COMMENT COLUMN](#comment-column) — 向列添加文本注释。 -- [MODIFY COLUMN](#modify-column) — 更改列的类型、默认表达式、TTL和列设置。 -- [MODIFY COLUMN REMOVE](#modify-column-remove) — 移除列的某个属性。 +- [MODIFY COLUMN](#modify-column) — 更改列的类型、默认表达式、TTL 和列设置。 +- [MODIFY COLUMN REMOVE](#modify-column-remove) — 删除列的某个属性。 - [MODIFY COLUMN MODIFY SETTING](#modify-column-modify-setting) - 更改列设置。 - [MODIFY COLUMN RESET SETTING](#modify-column-reset-setting) - 重置列设置。 -- [MATERIALIZE COLUMN](#materialize-column) — 在缺少列的分区中物化该列。 -这些操作的详细内容在下面描述。 +- [MATERIALIZE COLUMN](#materialize-column) — 在缺失列的分区中物化该列。 +这些操作将在下面详细描述。 ## ADD COLUMN {#add-column} @@ -37,13 +38,13 @@ ALTER [TEMPORARY] TABLE [db].name [ON CLUSTER cluster] ADD|DROP|RENAME|CLEAR|COM ADD COLUMN [IF NOT EXISTS] name [type] [default_expr] [codec] [AFTER name_after | FIRST] ``` -向表中添加具有指定 `name`、`type`、[`codec`](../create/table.md/#column_compression_codec) 和 `default_expr` 的新列(请参阅 [默认表达式](/sql-reference/statements/create/table#default_values) 部分)。 +使用指定的 `name`、`type`、[`codec`](../create/table.md/#column_compression_codec) 和 `default_expr`(参见 [默认表达式](/sql-reference/statements/create/table#default_values)部分)向表中添加新列。 -如果包含 `IF NOT EXISTS` 子句,则当列已经存在时,查询不会返回错误。如果您指定 `AFTER name_after`(另一个列的名称),则该列会在指定列后添加到表列列表中。如果想在表的开头添加列,可以使用 `FIRST` 子句。否则,列将添加到表的末尾。对于操作链,`name_after` 可以是之前操作中添加的列的名称。 +如果包含 `IF NOT EXISTS` 子句,则如果列已存在,则查询不会返回错误。如果指定了 `AFTER name_after`(另一个列的名称),则该列将在表列列表中指定的列之后添加。如果要将列添加到表的开头,请使用 `FIRST` 子句。否则,该列将被添加到表的末尾。对于一系列操作,`name_after` 可以是在之前的操作中添加的列的名称。 -添加列仅更改表结构,而不对数据执行任何操作。执行 `ALTER` 后,数据不会出现在磁盘上。如果在从表读取时某列的数据缺失,则会用默认值填充(执行默认表达式,如果存在,或者使用零或空字符串)。在合并数据片段后,该列才会出现在磁盘上(见 [MergeTree](/engines/table-engines/mergetree-family/mergetree.md))。 +添加列只是改变了表结构,未对数据进行任何操作。在 `ALTER` 操作后,数据不会出现在磁盘上。如果从表中读取时某列缺少数据,则将用默认值填充(如果存在,则执行默认表达式,或者使用零或空字符串)。在合并数据分区后,该列才会在磁盘上出现(参见 [MergeTree](/engines/table-engines/mergetree-family/mergetree.md))。 -这种方法允许我们立即完成 `ALTER` 查询,而不会增加旧数据的量。 +这种方法使我们能够立即完成 `ALTER` 查询,而不会增加旧数据的体积。 示例: @@ -73,12 +74,12 @@ Added3 UInt32 DROP COLUMN [IF EXISTS] name ``` -删除名称为 `name` 的列。如果指定了 `IF EXISTS` 子句,则当列不存在时,查询不会返回错误。 +删除名称为 `name` 的列。如果指定了 `IF EXISTS` 子句,则如果列不存在,查询不会返回错误。 -从文件系统中删除数据。由于这会删除整个文件,因此查询几乎瞬间完成。 +从文件系统中删除数据。由于此操作会删除整个文件,因此查询几乎立即完成。 :::tip -如果某列被 [物化视图](/sql-reference/statements/create/view) 引用,则无法删除该列。否则,将返回错误。 +如果该列被 [物化视图](/sql-reference/statements/create/view) 引用,则无法删除该列。否则,它会返回错误。 ::: 示例: @@ -93,9 +94,9 @@ ALTER TABLE visits DROP COLUMN browser RENAME COLUMN [IF EXISTS] name to new_name ``` -将列 `name` 重命名为 `new_name`。如果指定了 `IF EXISTS` 子句,则当列不存在时,查询不会返回错误。由于重命名不涉及底层数据,因此查询几乎瞬间完成。 +将列 `name` 重命名为 `new_name`。如果指定了 `IF EXISTS` 子句,则如果列不存在,查询不会返回错误。由于重命名不涉及底层数据,因此查询几乎立即完成。 -**注意**:在表的键表达式中指定的列(通过 `ORDER BY` 或 `PRIMARY KEY`)无法重命名。尝试更改这些列将产生 `SQL Error [524]`。 +**注意**:在表的键表达式中指定的列(无论是通过 `ORDER BY` 还是 `PRIMARY KEY`)都不能被重命名。尝试更改这些列将产生 `SQL Error [524]`。 示例: @@ -109,9 +110,9 @@ ALTER TABLE visits RENAME COLUMN webBrowser TO browser CLEAR COLUMN [IF EXISTS] name IN PARTITION partition_name ``` -重置指定分区中列的所有数据。有关设置分区名称的更多信息,请参阅 [如何设置分区表达式](../alter/partition.md/#how-to-set-partition-expression)。 +重置指定分区中列的所有数据。有关设置分区名称的信息,请参见 [如何设置分区表达式](../alter/partition.md/#how-to-set-partition-expression) 部分。 -如果指定了 `IF EXISTS` 子句,则当列不存在时,查询不会返回错误。 +如果指定了 `IF EXISTS` 子句,则如果列不存在,查询不会返回错误。 示例: @@ -125,11 +126,11 @@ ALTER TABLE visits CLEAR COLUMN browser IN PARTITION tuple() COMMENT COLUMN [IF EXISTS] name 'Text comment' ``` -向列添加注释。如果指定了 `IF EXISTS` 子句,则当列不存在时,查询不会返回错误。 +向列添加注释。如果指定了 `IF EXISTS` 子句,则如果列不存在,查询不会返回错误。 -每列可以有一个注释。如果列已经存在注释,则新注释将覆盖之前的注释。 +每列可以有一个注释。如果列已有评论,新评论将覆盖以前的评论。 -注释存储在 [DESCRIBE TABLE](/sql-reference/statements/describe-table.md) 查询返回的 `comment_expression` 列中。 +注释存储在通过 [DESCRIBE TABLE](/sql-reference/statements/describe-table.md) 查询返回的 `comment_expression` 列中。 示例: @@ -144,27 +145,27 @@ MODIFY COLUMN [IF EXISTS] name [type] [default_expr] [codec] [TTL] [settings] [A ALTER COLUMN [IF EXISTS] name TYPE [type] [default_expr] [codec] [TTL] [settings] [AFTER name_after | FIRST] ``` -此查询更改 `name` 列属性: +此查询更改列 `name` 的属性: - 类型 - 默认表达式 -- 压缩编码 +- 压缩编解码器 - TTL - 列级设置 -有关修改列压缩 CODECS 的示例,请参见 [列压缩编解码器](../create/table.md/#column_compression_codec)。 +有关修改列压缩编码器的示例,请参见 [列压缩编码器](../create/table.md/#column_compression_codec)。 -有关列 TTL 修改的示例,请参见 [列 TTL](/engines/table-engines/mergetree-family/mergetree.md/#mergetree-column-ttl)。 +有关修改列 TTL 的示例,请参见 [列TTL](/engines/table-engines/mergetree-family/mergetree.md/#mergetree-column-ttl)。 有关修改列级设置的示例,请参见 [列级设置](/engines/table-engines/mergetree-family/mergetree.md/#column-level-settings)。 -如果指定了 `IF EXISTS` 子句,则当列不存在时,查询不会返回错误。 +如果指定了 `IF EXISTS` 子句,则如果列不存在,查询不会返回错误。 -更改类型时,值会像应用 [toType](/sql-reference/functions/type-conversion-functions.md) 函数一样进行转换。如果只是更改了默认表达式,则查询不会执行任何复杂操作,并且几乎瞬间完成。 +在更改类型时,值会像应用 [toType](/sql-reference/functions/type-conversion-functions.md) 函数一样进行转换。如果仅更改默认表达式,则查询不会执行任何复杂操作,并且几乎立即完成。 示例: @@ -172,9 +173,9 @@ ALTER COLUMN [IF EXISTS] name TYPE [type] [default_expr] [codec] [TTL] [settings ALTER TABLE visits MODIFY COLUMN browser Array(String) ``` -更改列类型是唯一复杂的操作——它会更改包含数据的文件的内容。对于大型表,这可能需要很长时间。 +更改列类型是唯一的复杂操作 - 它更改包含数据的文件的内容。对于大型表,这可能需要很长时间。 -查询还可以使用 `FIRST | AFTER` 子句更改列的顺序,请参见 [ADD COLUMN](#add-column) 描述,但在这种情况下列类型是必需的。 +查询还可以使用 `FIRST | AFTER` 子句更改列的顺序,请参见 [ADD COLUMN](#add-column) 描述,但这种情况下列类型是必需的。 示例: @@ -208,13 +209,17 @@ DESCRIBE users; └──────┴────────┴ ``` -`ALTER` 查询是原子的。对于 MergeTree 表,它还不需要锁定。 +`ALTER` 查询是原子的。对于 MergeTree 表,它也是无锁的。 -对列进行更改的 `ALTER` 查询是可复制的。指令保存在 ZooKeeper 中,然后每个副本应用它们。所有 `ALTER` 查询按相同顺序运行。查询等待其他副本完成相应操作。但是,在一个副本表中更改列的查询可能会被中断,所有操作将异步执行。 +更改列的 `ALTER` 查询是复制的。这些指令保存在 ZooKeeper 中,然后每个副本应用它们。所有 `ALTER` 查询按相同的顺序运行。查询等待在其他副本上完成相应的操作。然而,在复制表中更改列的查询可以被中断,所有操作将异步执行。 + +:::note +在将 Nullable 列更改为非 Nullable 时,请小心。确保它没有任何 NULL 值,否则在读取时会导致问题。在这种情况下,解决方法是结束变更并将列恢复为 Nullable 类型。 +::: ## MODIFY COLUMN REMOVE {#modify-column-remove} -移除列的一个属性: `DEFAULT`、`ALIAS`、`MATERIALIZED`、`CODEC`、`COMMENT`、`TTL`、`SETTINGS`。 +删除列的某个属性:`DEFAULT`、`ALIAS`、`MATERIALIZED`、`CODEC`、`COMMENT`、`TTL`、`SETTINGS`。 语法: @@ -230,7 +235,7 @@ ALTER TABLE table_name MODIFY COLUMN column_name REMOVE property; ALTER TABLE table_with_ttl MODIFY COLUMN column_ttl REMOVE TTL; ``` -**另请参阅** +**另请参见** - [REMOVE TTL](ttl.md)。 @@ -254,7 +259,7 @@ ALTER TABLE table_name MODIFY COLUMN column_name MODIFY SETTING max_compress_blo ## MODIFY COLUMN RESET SETTING {#modify-column-reset-setting} -重置列设置,并从表的 CREATE 查询中删除设置声明。 +重置列设置,同时还会删除表 CREATE 查询中的设置声明。 语法: @@ -272,21 +277,21 @@ ALTER TABLE table_name MODIFY COLUMN column_name RESET SETTING max_compress_bloc ## MATERIALIZE COLUMN {#materialize-column} -物化带有 `DEFAULT` 或 `MATERIALIZED` 值表达式的列。当使用 `ALTER TABLE table_name ADD COLUMN column_name MATERIALIZED` 添加物化列时,现有行中没有物化值不会自动填充。可以使用 `MATERIALIZE COLUMN` 语句在添加或更新了 (仅更新了元数据,但不更改现有数据) `DEFAULT` 或 `MATERIALIZED` 表达式后重写现有列数据。请注意,在排序键中物化列是无效操作,因为它可能会破坏排序顺序。 -实现为 [突变](/sql-reference/statements/alter/index.md#mutations)。 +使用 `DEFAULT` 或 `MATERIALIZED` 值表达式物化列。在通过 `ALTER TABLE table_name ADD COLUMN column_name MATERIALIZED` 添加物化列时,现有没有物化值的行不会自动填充。`MATERIALIZE COLUMN` 语句可用于在添加或更新 `DEFAULT` 或 `MATERIALIZED` 表达式后重写现有列数据(这仅更新元数据,但不改变现有数据)。请注意,在排序键中物化列是无效的操作,因为这可能会打破排序顺序。 +实现为 [mutation](/sql-reference/statements/alter/index.md#mutations)。 -对于具有新或更新的 `MATERIALIZED` 值表达式的列,所有现有行将被重写。 +对于具有新或更新的 `MATERIALIZED` 值表达式的列,所有现有行都会被重写。 -对于具有新或更新的 `DEFAULT` 值表达式的列,则行为取决于 ClickHouse 版本: -- 在 ClickHouse < v24.2 中,所有现有行都将被重写。 -- 在 ClickHouse >= v24.2 中,区分在插入时是否明确指定了 `DEFAULT` 值表达式的某行值,或者不是,即通过 `DEFAULT` 值表达式计算的。如果值是明确指定的,ClickHouse 将保持不变。如果值是计算得出的,ClickHouse 将其更改为新的或更新的 `MATERIALIZED` 值表达式。 +对于具有新或更新的 `DEFAULT` 值表达式的列,其行为依赖于 ClickHouse 版本: +- 在 ClickHouse < v24.2 中,所有现有行都会被重写。 +- ClickHouse >= v24.2 区分在插入时列中 `DEFAULT` 值表达式的行值是否是显式指定的,或者是由 `DEFAULT` 值表达式计算的。如果值是显式指定的,ClickHouse 会保持原样。如果值是计算得来的,ClickHouse 会将其更改为新的或更新的 `MATERIALIZED` 值表达式。 语法: ```sql ALTER TABLE [db.]table [ON CLUSTER cluster] MATERIALIZE COLUMN col [IN PARTITION partition | IN PARTITION ID 'partition_id']; ``` -- 如果指定了 PARTITION,则仅对指定分区物化列。 +- 如果您指定了 PARTITION,则列将仅在指定分区中物化。 **示例** @@ -324,18 +329,18 @@ SELECT groupArray(x), groupArray(s) FROM tmp; └───────────────────────┴───────────────────────────────────────────────────────┘ ``` -**另请参阅** +**另请参见** - [MATERIALIZED](/sql-reference/statements/create/view#materialized-view)。 ## 限制 {#limitations} -`ALTER` 查询允许您创建和删除嵌套数据结构中的单独元素(列),但不支持整个嵌套数据结构。要添加嵌套数据结构,可以添加名称似乎 `name.nested_name` 且类型为 `Array(T)` 的列。嵌套数据结构相当于多个数组列,它们的名称在点之前具有相同的前缀。 +`ALTER` 查询允许您在嵌套数据结构中创建和删除单独元素(列),但不支持整个嵌套数据结构的删除。要添加嵌套数据结构,您可以添加名称像 `name.nested_name` 和类型 `Array(T)` 的列。嵌套数据结构相当于多个具有相同前缀名称的数组列。 -不支持删除主键或采样键中的列(在 `ENGINE` 表达式中使用的列)。仅当这项更改不会导致数据被修改时,才能更改包含在主键中的列的类型(例如,允许向 Enum 添加值或将类型从 `DateTime` 更改为 `UInt32`)。 +不支持删除主键或采样键中的列(在 `ENGINE` 表达式中使用的列)。仅在未导致数据修改的情况下,才可以更改包含在主键中的列的类型(例如,您可以将值添加到枚举中或将类型从 `DateTime` 更改为 `UInt32`)。 -如果 `ALTER` 查询不足以完成您所需的表更改,可以创建一个新表,将数据通过 [INSERT SELECT](/sql-reference/statements/insert-into.md/#inserting-the-results-of-select) 查询复制到其中,然后使用 [RENAME](/sql-reference/statements/rename.md/#rename-table) 查询切换表并删除旧表。 +如果 `ALTER` 查询不足以进行所需的表更改,您可以创建一个新表,使用 [INSERT SELECT](/sql-reference/statements/insert-into.md/#inserting-the-results-of-select) 查询将数据复制到新表中,然后使用 [RENAME](/sql-reference/statements/rename.md/#rename-table) 查询切换表,并删除旧表。 -`ALTER` 查询会阻塞对该表的所有读取和写入。换句话说,如果在 `ALTER` 查询时运行了长时间的 `SELECT`,则 `ALTER` 查询将等待它完成。与此同时,所有对同一表的新查询将在执行此 `ALTER` 时等待。 +`ALTER` 查询阻塞对表的所有读写操作。换句话说,如果在执行 `ALTER` 查询时正在进行长时间的 `SELECT` 操作,则 `ALTER` 查询将等待其完成。同时,所有对同一表的新查询将在此 `ALTER` 操作执行时等待。 -对于不自己存储数据的表(例如 [Merge](/sql-reference/statements/alter/index.md) 和 [Distributed](/sql-reference/statements/alter/index.md)),`ALTER` 仅更改表结构,而不更改从属表的结构。例如,在 `Distributed` 表上运行 ALTER 时,您还需要对所有远程服务器上的表运行 `ALTER`。 +对于不自己存储数据的表(如 [Merge](/sql-reference/statements/alter/index.md) 和 [Distributed](/sql-reference/statements/alter/index.md)),`ALTER` 仅更改表结构,而不改变从属表的结构。例如,在对 `Distributed` 表运行 ALTER 时,还需要在所有远程服务器上运行 `ALTER`。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/column.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/column.md.hash index 51814169366..8a0025d80eb 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/column.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/column.md.hash @@ -1 +1 @@ -53bb049d54e622cd +d72f75f16bff9f3b diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/comment.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/comment.md index e8ea8bea03a..17bfa7ea3e7 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/comment.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/comment.md @@ -1,29 +1,29 @@ --- 'description': 'ALTER TABLE ... MODIFY COMMENT 的文档,允许添加、修改或删除表注释' -'sidebar_label': 'ALTER TABLE ... 修改注释' +'sidebar_label': 'ALTER TABLE ... MODIFY COMMENT' 'sidebar_position': 51 'slug': '/sql-reference/statements/alter/comment' -'title': 'ALTER TABLE ... 修改注释' +'title': 'ALTER TABLE ... MODIFY COMMENT' 'keywords': - 'ALTER TABLE' - 'MODIFY COMMENT' +'doc_type': 'reference' --- # ALTER TABLE ... MODIFY COMMENT -添加、修改或删除表注释,无论之前是否设置过。注释的更改会反映在 [`system.tables`](../../../operations/system-tables/tables.md) -以及 `SHOW CREATE TABLE` 查询中。 +添加、修改或删除表注释,无论之前是否设置过。注释的更改反映在 [`system.tables`](../../../operations/system-tables/tables.md) 和 `SHOW CREATE TABLE` 查询中。 -## 语法 {#syntax} +## Syntax {#syntax} ```sql ALTER TABLE [db].name [ON CLUSTER cluster] MODIFY COMMENT 'Comment' ``` -## 示例 {#examples} +## Examples {#examples} -要创建一个带注释的表: +要创建带有注释的表: ```sql CREATE TABLE table_with_comment @@ -62,7 +62,7 @@ WHERE database = currentDatabase() AND name = 'table_with_comment'; ALTER TABLE table_with_comment MODIFY COMMENT ''; ``` -要验证注释是否已删除: +要验证注释是否已被删除: ```sql title="Query" SELECT comment @@ -76,13 +76,13 @@ WHERE database = currentDatabase() AND name = 'table_with_comment'; └─────────┘ ``` -## 注意事项 {#caveats} +## Caveats {#caveats} -对于 Replicated 表,不同副本上的注释可以不同。修改注释仅适用于单个副本。 +对于副本表,不同副本上的注释可能不同。修改注释仅适用于单一副本。 -此功能自版本 23.9 起可用。它在以前的 ClickHouse 版本中无法使用。 +该功能自 23.9 版本起可用。在之前的 ClickHouse 版本中无法使用。 -## 相关内容 {#related-content} +## Related content {#related-content} - [`COMMENT`](/sql-reference/statements/create/table#comment-clause) 子句 - [`ALTER DATABASE ... MODIFY COMMENT`](./database-comment.md) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/comment.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/comment.md.hash index ff4142c5b00..1075863a4d4 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/comment.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/comment.md.hash @@ -1 +1 @@ -15dedcb119d37e96 +d2234dde5a02b34d diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/constraint.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/constraint.md index ad5c6998c94..71abcb77f3e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/constraint.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/constraint.md @@ -1,15 +1,16 @@ --- -'description': 'Manipulating Constraints 的文档' +'description': '关于操作约束的文档' 'sidebar_label': 'CONSTRAINT' 'sidebar_position': 43 'slug': '/sql-reference/statements/alter/constraint' 'title': '操作约束' +'doc_type': 'reference' --- # 操作约束 -约束可以使用以下语法添加或删除: +可以使用以下语法添加或删除约束: ```sql ALTER TABLE [db].name [ON CLUSTER cluster] ADD CONSTRAINT [IF NOT EXISTS] constraint_name CHECK expression; @@ -18,10 +19,10 @@ ALTER TABLE [db].name [ON CLUSTER cluster] DROP CONSTRAINT [IF EXISTS] constrain 有关更多信息,请参见 [constraints](../../../sql-reference/statements/create/table.md#constraints)。 -查询将关于约束的元数据添加或移除自表,因此它们会立即处理。 +查询将从表中添加或删除关于约束的元数据,因此它们会立即处理。 :::tip -约束检查 **不会在** 已存在的数据上执行,如果它被添加了。 +如果添加了约束,则**不会对现有数据执行约束检查**。 ::: -在复制表上的所有更改都会广播到 ZooKeeper,并将在其他副本上也应用。 +对复制表的所有更改都会广播到 ZooKeeper,并将应用于其他副本。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/constraint.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/constraint.md.hash index b23f135361a..cd7486a68f1 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/constraint.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/constraint.md.hash @@ -1 +1 @@ -839642cd14a0bc76 +d4acfa7a8383c499 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/database-comment.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/database-comment.md index 3f2b3b52f14..bfdea09fa4f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/database-comment.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/database-comment.md @@ -1,5 +1,5 @@ --- -'description': '关于 ALTER DATABASE ... MODIFY COMMENT 语句的文档,这些语句允许添加、修改或删除数据库注释。' +'description': 'ALTER DATABASE ... MODIFY COMMENT 语句的文档,允许添加、修改或删除数据库注释。' 'slug': '/sql-reference/statements/alter/database-comment' 'sidebar_position': 51 'sidebar_label': 'ALTER DATABASE ... MODIFY COMMENT' @@ -7,12 +7,13 @@ 'keywords': - 'ALTER DATABASE' - 'MODIFY COMMENT' +'doc_type': 'reference' --- # ALTER DATABASE ... MODIFY COMMENT -添加、修改或删除数据库注释,无论之前是否设置过该注释。注释变更在 [`system.databases`](/operations/system-tables/databases.md) 以及 `SHOW CREATE DATABASE` 查询中均有反映。 +添加、修改或删除数据库注释,无论之前是否设置过。注释更改会反映在 [`system.databases`](/operations/system-tables/databases.md) 和 `SHOW CREATE DATABASE` 查询中。 ## Syntax {#syntax} @@ -56,7 +57,7 @@ ALTER DATABASE database_with_comment MODIFY COMMENT ''; ``` -要验证注释是否已删除: +要验证注释是否已被删除: ```sql title="Query" SELECT comment diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/database-comment.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/database-comment.md.hash index d662eaaacb2..4415ee99a83 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/database-comment.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/database-comment.md.hash @@ -1 +1 @@ -3fae41f781cea695 +faff177ce8b6afa8 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/delete.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/delete.md index 8d0c1b31554..4e379cc08e9 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/delete.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/delete.md @@ -4,6 +4,7 @@ 'sidebar_position': 39 'slug': '/sql-reference/statements/alter/delete' 'title': 'ALTER TABLE ... DELETE 语句' +'doc_type': 'reference' --- @@ -13,19 +14,19 @@ ALTER TABLE [db.]table [ON CLUSTER cluster] DELETE WHERE filter_expr ``` -删除与指定过滤表达式匹配的数据。实现为 [mutation](/sql-reference/statements/alter/index.md#mutations)。 +删除匹配指定过滤表达式的数据。实现为 [mutation](/sql-reference/statements/alter/index.md#mutations)。 :::note -`ALTER TABLE` 前缀使得此语法与大多数其他支持 SQL 的系统不同。它旨在表明,与 OLTP 数据库中的类似查询不同,这是一项不设计为频繁使用的重操作。`ALTER TABLE` 被认为是一个重量级操作,需要在删除之前合并底层数据。对于 MergeTree 表,建议使用 [`DELETE FROM` 查询](/sql-reference/statements/delete.md),它执行轻量级删除,并且可以快得多。 +`ALTER TABLE` 前缀使此语法与大多数支持 SQL 的其他系统不同。它旨在表明,与 OLTP 数据库中的类似查询不同,这是一项不设计为频繁使用的重操作。 `ALTER TABLE` 被认为是一项重量级操作,要求在删除之前必须对底层数据进行合并。对于 MergeTree 表,考虑使用 [`DELETE FROM` 查询](/sql-reference/statements/delete.md),该查询执行轻量级删除,并且可能更快。 ::: -`filter_expr` 必须为 `UInt8` 类型。该查询删除表中该表达式取非零值的行。 +`filter_expr` 必须为 `UInt8` 类型。该查询删除表中对于该表达式取非零值的行。 一个查询可以包含多个用逗号分隔的命令。 查询处理的同步性由 [mutations_sync](/operations/settings/settings.md/#mutations_sync) 设置定义。默认情况下,它是异步的。 -**另见** +**另请参见** - [Mutations](/sql-reference/statements/alter/index.md#mutations) - [ALTER 查询的同步性](/sql-reference/statements/alter/index.md#synchronicity-of-alter-queries) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/delete.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/delete.md.hash index 0d0c38f1799..ab6dbb90897 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/delete.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/delete.md.hash @@ -1 +1 @@ -2f124258c335e1cb +ba8b43d1a0f0e54e diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/index.md index 22d7c2da760..be76e1bcd1e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/index.md @@ -4,6 +4,7 @@ 'sidebar_position': 35 'slug': '/sql-reference/statements/alter/' 'title': 'ALTER' +'doc_type': 'reference' --- @@ -11,72 +12,72 @@ 大多数 `ALTER TABLE` 查询修改表设置或数据: -| 修饰符 | -|---------------------------------------------------------------------------------------------| -| [COLUMN](/sql-reference/statements/alter/column.md) | -| [PARTITION](/sql-reference/statements/alter/partition.md) | -| [DELETE](/sql-reference/statements/alter/delete.md) | -| [UPDATE](/sql-reference/statements/alter/update.md) | -| [ORDER BY](/sql-reference/statements/alter/order-by.md) | -| [INDEX](/sql-reference/statements/alter/skipping-index.md) | -| [CONSTRAINT](/sql-reference/statements/alter/constraint.md) | -| [TTL](/sql-reference/statements/alter/ttl.md) | -| [STATISTICS](/sql-reference/statements/alter/statistics.md) | -| [APPLY DELETED MASK](/sql-reference/statements/alter/apply-deleted-mask.md) | +| Modifier | +|-------------------------------------------------------------------------------------| +| [COLUMN](/sql-reference/statements/alter/column.md) | +| [PARTITION](/sql-reference/statements/alter/partition.md) | +| [DELETE](/sql-reference/statements/alter/delete.md) | +| [UPDATE](/sql-reference/statements/alter/update.md) | +| [ORDER BY](/sql-reference/statements/alter/order-by.md) | +| [INDEX](/sql-reference/statements/alter/skipping-index.md) | +| [CONSTRAINT](/sql-reference/statements/alter/constraint.md) | +| [TTL](/sql-reference/statements/alter/ttl.md) | +| [STATISTICS](/sql-reference/statements/alter/statistics.md) | +| [APPLY DELETED MASK](/sql-reference/statements/alter/apply-deleted-mask.md) | :::note -大多数 `ALTER TABLE` 查询仅支持 [\*MergeTree](/engines/table-engines/mergetree-family/index.md), [Merge](/engines/table-engines/special/merge.md) 和 [Distributed](/engines/table-engines/special/distributed.md) 表。 +大多数 `ALTER TABLE` 查询仅支持 [\*MergeTree](/engines/table-engines/mergetree-family/index.md)、[Merge](/engines/table-engines/special/merge.md) 和 [Distributed](/engines/table-engines/special/distributed.md) 表。 ::: 这些 `ALTER` 语句操作视图: -| 语句 | 描述 | -|-----------------------------------------------------------------------------------|----------------------------------------------------------------------------------------| -| [ALTER TABLE ... MODIFY QUERY](/sql-reference/statements/alter/view.md) | 修改 [物化视图](/sql-reference/statements/create/view) 结构。 | -| [ALTER LIVE VIEW](/sql-reference/statements/alter/view#alter-live-view-statement) | 刷新 [实时视图](/sql-reference/statements/create/view.md/#live-view)。 | +| Statement | Description | +|-------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------| +| [ALTER TABLE ... MODIFY QUERY](/sql-reference/statements/alter/view.md) | 修改 [物化视图](/sql-reference/statements/create/view) 结构。 | +| [ALTER LIVE VIEW](/sql-reference/statements/alter/view#alter-live-view-statement) | 刷新 [实时视图](/sql-reference/statements/create/view.md/#live-view)。| 这些 `ALTER` 语句修改与基于角色的访问控制相关的实体: -| 语句 | -|-----------------------------------------------------------------------------------| -| [USER](/sql-reference/statements/alter/user.md) | -| [ROLE](/sql-reference/statements/alter/role.md) | -| [QUOTA](/sql-reference/statements/alter/quota.md) | -| [ROW POLICY](/sql-reference/statements/alter/row-policy.md) | -| [SETTINGS PROFILE](/sql-reference/statements/alter/settings-profile.md) | +| Statement | +|---------------------------------------------------------------------------------| +| [USER](/sql-reference/statements/alter/user.md) | +| [ROLE](/sql-reference/statements/alter/role.md) | +| [QUOTA](/sql-reference/statements/alter/quota.md) | +| [ROW POLICY](/sql-reference/statements/alter/row-policy.md) | +| [SETTINGS PROFILE](/sql-reference/statements/alter/settings-profile.md) | -| 语句 | 描述 | -|---------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------| -| [ALTER TABLE ... MODIFY COMMENT](/sql-reference/statements/alter/comment.md) | 向表添加、修改或删除注释,无论其是否之前已设置。 | -| [ALTER NAMED COLLECTION](/sql-reference/statements/alter/named-collection.md) | 修改 [命名集合](/operations/named-collections.md)。 | +| Statement | Description | +|---------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------| +| [ALTER TABLE ... MODIFY COMMENT](/sql-reference/statements/alter/comment.md) | 添加、修改或删除表的注释,无论其之前是否设置。 | +| [ALTER NAMED COLLECTION](/sql-reference/statements/alter/named-collection.md) | 修改 [命名集合](/operations/named-collections.md)。 | ## Mutations {#mutations} -旨在操作表数据的 `ALTER` 查询通过一种称为“变更”的机制实现,特别是 [ALTER TABLE ... DELETE](/sql-reference/statements/alter/delete.md) 和 [ALTER TABLE ... UPDATE](/sql-reference/statements/alter/update.md)。它们是异步后台进程,类似于 [MergeTree](/engines/table-engines/mergetree-family/index.md) 表中的合并,以生成“变更”版本的分片。 +`ALTER` 查询旨在操作表数据是通过称为“变更”的机制实现的,特别是 [ALTER TABLE ... DELETE](/sql-reference/statements/alter/delete.md) 和 [ALTER TABLE ... UPDATE](/sql-reference/statements/alter/update.md)。它们是异步后台进程,类似于 [MergeTree](/engines/table-engines/mergetree-family/index.md) 表中的合并,用于生成新“变更”的部分版本。 -对于 `*MergeTree` 表,变更通过 **重写整个数据分片** 来执行。 -没有原子性—一旦分片准备好,就会用变更的分片替换原来的分片,在变更过程中开始执行的 `SELECT` 查询会看到已经变更的分片的数据以及尚未变更的分片的数据。 +对于 `*MergeTree` 表,变更通过 **重写整个数据部分** 执行。 +没有原子性——随着变更后的部分准备就绪,部分会被替换,正在执行的 `SELECT` 查询将看到已变更部分的数据以及尚未变更部分的数据。 -变更按照其创建顺序完全排序,并按该顺序应用于每个分片。变更与 `INSERT INTO` 查询部分排序:在提交变更之前插入表中的数据将被变更,而在变更提交后插入的数据不会被变更。请注意,变更不会以任何方式阻塞插入。 +变更完全按创建顺序排序,并按此顺序应用于每个部分。变更与 `INSERT INTO` 查询也部分排序:在提交变更之前插入的表的数据将会被变更,而在此之后插入的数据将不会被变更。请注意,变更不会以任何方式阻止插入。 -变更查询在变更条目添加后立即返回(对于复制表则是添加到 ZooKeeper,对于非复制表则是添加到文件系统)。变更本身使用系统配置设置异步执行。要跟踪变更的进度,可以使用 [`system.mutations`](/operations/system-tables/mutations) 表。成功提交的变更将继续执行,即使 ClickHouse 服务器重启。一旦提交变更,就无法回滚,但如果变更因某种原因被卡住,可以通过 [`KILL MUTATION`](/sql-reference/statements/kill.md/#kill-mutation) 查询取消该变更。 +变更查询在变更条目添加后立即返回(对于复制表,添加到 ZooKeeper,对于非复制表,添加到文件系统)。变更本身是使用系统配置设置异步执行的。要跟踪变更的进度,可以使用 [`system.mutations`](/operations/system-tables/mutations) 表。成功提交的变更将继续执行,即使 ClickHouse 服务器重启。提交后无法回滚变更,但如果变更因为某种原因卡住,可以使用 [`KILL MUTATION`](/sql-reference/statements/kill.md/#kill-mutation) 查询取消。 -已完成变更的条目不会立即删除(保留条目的数量由 `finished_mutations_to_keep` 存储引擎参数决定)。旧的变更条目会被删除。 +已完成变更的条目不会立即删除(保留条目的数量由 `finished_mutations_to_keep` 存储引擎参数确定)。较旧的变更条目会被删除。 ## Synchronicity of ALTER Queries {#synchronicity-of-alter-queries} -对于非复制表,所有 `ALTER` 查询都是同步执行的。对于复制表,该查询只是将相应操作的指令添加到 `ZooKeeper`,这些操作将在尽可能快的时间内执行。然而,查询可以等待这些操作在所有副本上完成。 +对于非复制表,所有 `ALTER` 查询都是同步执行的。对于复制表,查询只会将相关操作的指令添加到 `ZooKeeper`,而这些操作本身会尽快执行。然而,查询可以等待这些操作在所有副本上完成。 对于创建变更的 `ALTER` 查询(例如:包括但不限于 `UPDATE`、`DELETE`、`MATERIALIZE INDEX`、`MATERIALIZE PROJECTION`、`MATERIALIZE COLUMN`、`APPLY DELETED MASK`、`CLEAR STATISTIC`、`MATERIALIZE STATISTIC`),同步性由 [mutations_sync](/operations/settings/settings.md/#mutations_sync) 设置定义。 -对于其他仅修改元数据的 `ALTER` 查询,您可以使用 [alter_sync](/operations/settings/settings#alter_sync) 设置来配置等待。 +对于仅修改元数据的其他 `ALTER` 查询,可以使用 [alter_sync](/operations/settings/settings#alter_sync) 设置来设置等待。 -您可以使用 [replication_wait_for_inactive_replica_timeout](/operations/settings/settings#replication_wait_for_inactive_replica_timeout) 设置指定等待多少秒(以秒为单位)来等待非活动副本执行所有 `ALTER` 查询。 +您可以指定等待非活动副本执行所有 `ALTER` 查询的时间(以秒为单位),方法是使用 [replication_wait_for_inactive_replica_timeout](/operations/settings/settings#replication_wait_for_inactive_replica_timeout) 设置。 :::note -对于所有 `ALTER` 查询,如果 `alter_sync = 2` 且某些副本在 `replication_wait_for_inactive_replica_timeout` 设置中指定的时间内未激活,则会抛出异常 `UNFINISHED`。 +对于所有 `ALTER` 查询,如果 `alter_sync = 2` 且某些副本在 `replication_wait_for_inactive_replica_timeout` 设置中指定的时间内未处于活动状态,则会抛出异常 `UNFINISHED`。 ::: ## Related content {#related-content} -- 博客: [在 ClickHouse 中处理更新和删除](https://clickhouse.com/blog/handling-updates-and-deletes-in-clickhouse) +- Blog: [在 ClickHouse 中处理更新和删除](https://clickhouse.com/blog/handling-updates-and-deletes-in-clickhouse) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/index.md.hash index 1b6c98b6863..7743427973b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/index.md.hash @@ -1 +1 @@ -42911dcfc9f88f5d +2a8541dd2bd1a307 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/named-collection.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/named-collection.md index 76664440809..168b5745dc6 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/named-collection.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/named-collection.md @@ -3,6 +3,7 @@ 'sidebar_label': 'NAMED COLLECTION' 'slug': '/sql-reference/statements/alter/named-collection' 'title': 'ALTER NAMED COLLECTION' +'doc_type': 'reference' --- import CloudNotSupportedBadge from '@theme/badges/CloudNotSupportedBadge'; @@ -10,7 +11,7 @@ import CloudNotSupportedBadge from '@theme/badges/CloudNotSupportedBadge'; -# ALTER NAMED COLLECTION +# 修改命名集合 此查询旨在修改已经存在的命名集合。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/named-collection.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/named-collection.md.hash index 4360c801b9c..73a2d9de9b7 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/named-collection.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/named-collection.md.hash @@ -1 +1 @@ -57888c5a275391ef +617ece13b899e859 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/order-by.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/order-by.md index 9476df41686..a5ec522af23 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/order-by.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/order-by.md @@ -4,19 +4,20 @@ 'sidebar_position': 41 'slug': '/sql-reference/statements/alter/order-by' 'title': '操作主键表达式' +'doc_type': 'reference' --- -# 操作键表达式 +# 操作关键表达式 ```sql ALTER TABLE [db].name [ON CLUSTER cluster] MODIFY ORDER BY new_expression ``` -该命令将表的 [排序键](../../../engines/table-engines/mergetree-family/mergetree.md) 更改为 `new_expression`(一个表达式或表达式的元组)。主键保持不变。 +该命令将表的 [排序关键](../../../engines/table-engines/mergetree-family/mergetree.md) 更改为 `new_expression`(一个表达式或表达式的元组)。主键保持不变。 -该命令是轻量级的,因为它仅更改元数据。为了保持数据部分行按排序键表达式排序的特性,您不能将包含现有列的表达式添加到排序键中(仅允许在同一 `ALTER` 查询中通过 `ADD COLUMN` 命令添加的列,不带默认列值)。 +该命令是轻量级的,因为它仅更改元数据。为了保持数据部分行按排序关键表达式有序的特性,您不能将包含现有列的表达式添加到排序关键中(只能在同一 `ALTER` 查询中通过 `ADD COLUMN` 命令添加的列,且不带默认列值)。 :::note -它仅适用于 [`MergeTree`](../../../engines/table-engines/mergetree-family/mergetree.md) 家族中的表(包括 [复制](../../../engines/table-engines/mergetree-family/replication.md) 表)。 +它仅适用于 [`MergeTree`](../../../engines/table-engines/mergetree-family/mergetree.md) 系列的表(包括 [复制](../../../engines/table-engines/mergetree-family/replication.md) 表)。 ::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/order-by.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/order-by.md.hash index 9d21708e7ab..b0ded75d6e4 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/order-by.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/order-by.md.hash @@ -1 +1 @@ -251df243420dcadb +8556263005f07017 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/partition.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/partition.md index 10eea5d9f44..33eb8fb8720 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/partition.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/partition.md @@ -4,26 +4,28 @@ 'sidebar_position': 38 'slug': '/sql-reference/statements/alter/partition' 'title': '操作分区和分区片段' +'doc_type': 'reference' --- -以下与 [分区](/engines/table-engines/mergetree-family/custom-partitioning-key.md) 相关的操作可用: +以下关于 [partitions](/engines/table-engines/mergetree-family/custom-partitioning-key.md) 的操作可用: -- [DETACH PARTITION\|PART](#detach-partitionpart) — 将分区或片段移动到 `detached` 目录并忘记它。 -- [DROP PARTITION\|PART](#drop-partitionpart) — 删除分区或片段。 -- [DROP DETACHED PARTITION\|PART](#drop-detached-partitionpart) - 从 `detached` 删除一个片段或所有片段。 -- [FORGET PARTITION](#forget-partition) — 如果分区为空,则从 Zookeeper 中删除分区元数据。 -- [ATTACH PARTITION\|PART](#attach-partitionpart) — 从 `detached` 目录向表中添加分区或片段。 -- [ATTACH PARTITION FROM](#attach-partition-from) — 将一个表中的数据分区复制到另一个表并添加。 -- [REPLACE PARTITION](#replace-partition) — 将一个表中的数据分区复制到另一个表并替换。 -- [MOVE PARTITION TO TABLE](#move-partition-to-table) — 将数据分区从一个表移动到另一个表。 +- [DETACH PARTITION\|PART](#detach-partitionpart) — 将一个分区或部分移动到 `detached` 目录并忘记它。 +- [DROP PARTITION\|PART](#drop-partitionpart) — 删除一个分区或部分。 +- [DROP DETACHED PARTITION\|PART](#drop-detached-partitionpart) - 从 `detached` 删除一个部分或所有分区的部分。 +- [FORGET PARTITION](#forget-partition) — 如果分区为空,则从 zookeeper 中删除分区元数据。 +- [ATTACH PARTITION\|PART](#attach-partitionpart) — 从 `detached` 目录向表中添加一个分区或部分。 +- [ATTACH PARTITION FROM](#attach-partition-from) — 将一个表的数据分区复制到另一个表并添加。 +- [REPLACE PARTITION](#replace-partition) — 将一个表的数据分区复制到另一个表并替换。 +- [MOVE PARTITION TO TABLE](#move-partition-to-table) — 将一个表的数据分区移动到另一个表。 - [CLEAR COLUMN IN PARTITION](#clear-column-in-partition) — 重置分区中指定列的值。 - [CLEAR INDEX IN PARTITION](#clear-index-in-partition) — 重置分区中指定的二级索引。 -- [FREEZE PARTITION](#freeze-partition) — 创建分区的备份。 +- [FREEZE PARTITION](#freeze-partition) — 创建一个分区的备份。 - [UNFREEZE PARTITION](#unfreeze-partition) — 删除分区的备份。 -- [FETCH PARTITION\|PART](#fetch-partitionpart) — 从另一个服务器下载片段或分区。 -- [MOVE PARTITION\|PART](#move-partitionpart) — 将分区/数据片段移动到另一个磁盘或卷。 -- [UPDATE IN PARTITION](#update-in-partition) — 根据条件更新分区内的数据。 -- [DELETE IN PARTITION](#delete-in-partition) — 根据条件删除分区内的数据。 +- [FETCH PARTITION\|PART](#fetch-partitionpart) — 从另一台服务器下载一个部分或分区。 +- [MOVE PARTITION\|PART](#move-partitionpart) — 将分区/数据部分移动到另一个磁盘或卷。 +- [UPDATE IN PARTITION](#update-in-partition) — 通过条件更新分区内的数据。 +- [DELETE IN PARTITION](#delete-in-partition) — 通过条件删除分区内的数据。 +- [REWRITE PARTS](#rewrite-parts) — 完全重写表中的部分(或特定分区)。 @@ -33,7 +35,7 @@ ALTER TABLE table_name [ON CLUSTER cluster] DETACH PARTITION|PART partition_expr ``` -将指定分区的所有数据移动到 `detached` 目录。服务器忘记此已分离的数据分区,就好像它不存在。服务器在您执行 [ATTACH](#attach-partitionpart) 查询之前将对此数据一无所知。 +将指定分区的所有数据移动到 `detached` 目录。服务器忘记了已分离的数据分区,仿佛它不存在。直到您执行 [ATTACH](#attach-partitionpart) 查询,服务器才会知道这些数据。 示例: @@ -42,11 +44,11 @@ ALTER TABLE mt DETACH PARTITION '2020-11-21'; ALTER TABLE mt DETACH PART 'all_2_2_0'; ``` -有关设置分区表达式的更多信息,请参见 [如何设置分区表达式](#how-to-set-partition-expression) 部分。 +阅读关于在 [如何设置分区表达式](#how-to-set-partition-expression) 一节中的分区表达式设置。 -查询执行后,您可以对 `detached` 目录中的数据做任何您想做的事情——从文件系统中删除它,或者就这样留着。 +在查询执行后,您可以随意处理 `detached` 目录中的数据——从文件系统中删除它,或只是留下它。 -这个查询是可复制的——它将在所有副本上将数据移动到 `detached` 目录。请注意,您只能在主副本上执行此查询。要找出某个副本是否为主副本,请对 [system.replicas](/operations/system-tables/replicas) 表执行 `SELECT` 查询。或者,在所有副本上执行 `DETACH` 查询更容易——所有副本都会抛出异常,除主副本外(因为允许多个主副本)。 +此查询是复制的——它将数据移动到所有副本的 `detached` 目录。请注意,您只能在一个主副本上执行此查询。要找出某个副本是否是主副本,请对 [system.replicas](/operations/system-tables/replicas) 表执行 `SELECT` 查询。或者,更简单地可以在所有副本上执行 `DETACH` 查询——所有副本都会抛出异常,除了主副本(因为允许多个主副本)。 ## DROP PARTITION\|PART {#drop-partitionpart} @@ -54,11 +56,11 @@ ALTER TABLE mt DETACH PART 'all_2_2_0'; ALTER TABLE table_name [ON CLUSTER cluster] DROP PARTITION|PART partition_expr ``` -从表中删除指定的分区。该查询将分区标记为非活动,并完全删除数据,约需10分钟。 +从表中删除指定的分区。此查询将分区标记为非活动状态并完全删除数据,约需10分钟。 -有关设置分区表达式的更多信息,请参见 [如何设置分区表达式](#how-to-set-partition-expression) 部分。 +阅读关于在 [如何设置分区表达式](#how-to-set-partition-expression) 一节中的分区表达式设置。 -该查询是可复制的——它会删除所有副本上的数据。 +此查询是复制的——它在所有副本上删除数据。 示例: @@ -73,8 +75,8 @@ ALTER TABLE mt DROP PART 'all_4_4_0'; ALTER TABLE table_name [ON CLUSTER cluster] DROP DETACHED PARTITION|PART ALL|partition_expr ``` -从 `detached` 中删除指定的片段或指定分区的所有片段。 -有关设置分区表达式的更多信息,请参见 [如何设置分区表达式](#how-to-set-partition-expression) 部分。 +从 `detached` 中删除指定的部分或所有指定分区的部分。 +阅读更多关于在 [如何设置分区表达式](#how-to-set-partition-expression) 中的分区表达式设置。 ## FORGET PARTITION {#forget-partition} @@ -82,9 +84,9 @@ ALTER TABLE table_name [ON CLUSTER cluster] DROP DETACHED PARTITION|PART ALL|par ALTER TABLE table_name FORGET PARTITION partition_expr ``` -从 ZooKeeper 中删除有关空分区的所有元数据。如果分区不为空或未知,查询将失败。确保仅对将不再使用的分区执行此操作。 +从 ZooKeeper 中删除关于空分区的所有元数据。如果分区不为空或未知,查询将失败。请确保仅对将来不会再使用的分区执行此操作。 -有关设置分区表达式的更多信息,请参见 [如何设置分区表达式](#how-to-set-partition-expression) 部分。 +阅读关于在 [如何设置分区表达式](#how-to-set-partition-expression) 一节中的分区表达式设置。 示例: @@ -95,25 +97,25 @@ ALTER TABLE mt FORGET PARTITION '20201121'; ## ATTACH PARTITION\|PART {#attach-partitionpart} ```sql -ALTER TABLE table_name [ON CLUSTER cluster] ATTACH PARTITION|PART partition_expr +ALTER TABLE table_name ATTACH PARTITION|PART partition_expr ``` -从 `detached` 目录向表中添加数据。可以为整个分区或单个片段添加数据。示例: +从 `detached` 目录向表中添加数据。可以为整个分区或单个部分添加数据。示例: ```sql ALTER TABLE visits ATTACH PARTITION 201901; ALTER TABLE visits ATTACH PART 201901_2_2_0; ``` -有关设置分区表达式的更多信息,请参见 [如何设置分区表达式](#how-to-set-partition-expression) 部分。 +阅读更多关于在 [如何设置分区表达式](#how-to-set-partition-expression) 一节中的分区表达式设置。 -该查询是可复制的。副本发起者检查 `detached` 目录中是否存在数据。 -如果数据存在,查询将检查其完整性。如果一切正常,查询将数据添加到表中。 +此查询是复制的。启动副本检查 `detached` 目录中是否有数据。 +如果存在数据,查询将检查其完整性。如果所有内容都是正确的,查询将数据添加到表中。 -如果非发起副本在接收到附加命令时找到其自己 `detached` 文件夹中具有正确校验和的片段,则它会在不从其他副本获取数据的情况下附加该数据。 -如果没有具有正确校验和的片段,则从任何拥有该片段的副本下载数据。 +如果非启动副本在接收到附加命令时,在其自己的 `detached` 文件夹中找到具有正确校验和的部分,它将无需从其他副本获取数据而直接附加该数据。 +如果没有具有正确校验和的部分,则数据将从任何具有该部分的副本下载。 -您可以将数据放入一个副本的 `detached` 目录,并使用 `ALTER ... ATTACH` 查询将其添加到所有副本的表中。 +您可以在一个副本的 `detached` 目录中放置数据,并使用 `ALTER ... ATTACH` 查询将其添加到所有副本的表中。 ## ATTACH PARTITION FROM {#attach-partition-from} @@ -121,19 +123,19 @@ ALTER TABLE visits ATTACH PART 201901_2_2_0; ALTER TABLE table2 [ON CLUSTER cluster] ATTACH PARTITION partition_expr FROM table1 ``` -该查询将数据分区从 `table1` 复制到 `table2`。 +此查询将 `table1` 的数据分区复制到 `table2`。 请注意: - 数据不会从 `table1` 或 `table2` 中删除。 - `table1` 可以是临时表。 -为使查询成功执行,必须满足以下条件: +要确保查询成功执行,必须满足以下条件: -- 两个表必须具有相同的结构。 +- 两个表结构必须相同。 - 两个表必须具有相同的分区键、相同的排序键和相同的主键。 - 两个表必须具有相同的存储策略。 -- 目标表必须包含源表中的所有索引和投影。如果目标表中启用了 `enforce_index_structure_match_on_partition_manipulation` 设置,则索引和投影必须完全相同。否则,目标表可以包含源表索引和投影的超集。 +- 目标表必须包含源表的所有索引和投影。如果目标表中启用了 `enforce_index_structure_match_on_partition_manipulation` 设置,则索引和投影必须完全相同。否则,目标表可以包含源表的索引和投影的超集。 ## REPLACE PARTITION {#replace-partition} @@ -141,19 +143,19 @@ ALTER TABLE table2 [ON CLUSTER cluster] ATTACH PARTITION partition_expr FROM tab ALTER TABLE table2 [ON CLUSTER cluster] REPLACE PARTITION partition_expr FROM table1 ``` -该查询将数据分区从 `table1` 复制到 `table2` 并替换 `table2` 中的现有分区。该操作是原子的。 +此查询将 `table1` 的数据分区复制到 `table2`,并替换 `table2` 中的现有分区。此操作是原子的。 请注意: - 数据不会从 `table1` 中删除。 - `table1` 可以是临时表。 -为使查询成功执行,必须满足以下条件: +要确保查询成功执行,必须满足以下条件: -- 两个表必须具有相同的结构。 +- 两个表结构必须相同。 - 两个表必须具有相同的分区键、相同的排序键和相同的主键。 - 两个表必须具有相同的存储策略。 -- 目标表必须包含源表中的所有索引和投影。如果目标表中启用了 `enforce_index_structure_match_on_partition_manipulation` 设置,则索引和投影必须完全相同。否则,目标表可以包含源表索引和投影的超集。 +- 目标表必须包含源表的所有索引和投影。如果目标表中启用了 `enforce_index_structure_match_on_partition_manipulation` 设置,则索引和投影必须完全相同。否则,目标表可以包含源表的索引和投影的超集。 ## MOVE PARTITION TO TABLE {#move-partition-to-table} @@ -161,15 +163,15 @@ ALTER TABLE table2 [ON CLUSTER cluster] REPLACE PARTITION partition_expr FROM ta ALTER TABLE table_source [ON CLUSTER cluster] MOVE PARTITION partition_expr TO TABLE table_dest ``` -该查询将数据分区从 `table_source` 移动到 `table_dest`,并从 `table_source` 中删除数据。 +此查询将数据分区从 `table_source` 移动到 `table_dest`,同时删除 `table_source` 中的数据。 -为使查询成功执行,必须满足以下条件: +要确保查询成功执行,必须满足以下条件: -- 两个表必须具有相同的结构。 +- 两个表结构必须相同。 - 两个表必须具有相同的分区键、相同的排序键和相同的主键。 - 两个表必须具有相同的存储策略。 -- 两个表必须属于相同的引擎系列(复制或非复制)。 -- 目标表必须包含源表中的所有索引和投影。如果目标表中启用了 `enforce_index_structure_match_on_partition_manipulation` 设置,则索引和投影必须完全相同。否则,目标表可以包含源表索引和投影的超集。 +- 两个表必须属于相同的引擎系列(复制的或非复制的)。 +- 目标表必须包含源表的所有索引和投影。如果目标表中启用了 `enforce_index_structure_match_on_partition_manipulation` 设置,则索引和投影必须完全相同。否则,目标表可以包含源表的索引和投影的超集。 ## CLEAR COLUMN IN PARTITION {#clear-column-in-partition} @@ -177,7 +179,7 @@ ALTER TABLE table_source [ON CLUSTER cluster] MOVE PARTITION partition_expr TO T ALTER TABLE table_name [ON CLUSTER cluster] CLEAR COLUMN column_name IN PARTITION partition_expr ``` -重置分区中指定列的所有值。如果在创建表时确定了 `DEFAULT` 子句,则该查询将列值设置为指定的默认值。 +重置分区中指定列的所有值。如果在创建表时确定了 `DEFAULT` 子句,此查询将列的值设置为指定的默认值。 示例: @@ -191,41 +193,41 @@ ALTER TABLE visits CLEAR COLUMN hour in PARTITION 201902 ALTER TABLE table_name [ON CLUSTER cluster] FREEZE [PARTITION partition_expr] [WITH NAME 'backup_name'] ``` -该查询为指定分区创建本地备份。如果省略 `PARTITION` 子句,则查询会一次性创建所有分区的备份。 +此查询创建指定分区的本地备份。如果省略 `PARTITION` 子句,则查询一次性创建所有分区的备份。 :::note 整个备份过程在不停止服务器的情况下进行。 ::: -请注意,对于旧风格的表,您可以指定分区名称的前缀(例如 `2019`)——然后查询将为所有相应的分区创建备份。有关设置分区表达式的更多信息,请参见 [如何设置分区表达式](#how-to-set-partition-expression) 部分。 +请注意,对于旧风格的表,您可以指定分区名称的前缀(例如 `2019`)—这样查询将为所有对应的分区创建备份。阅读关于在 [如何设置分区表达式](#how-to-set-partition-expression) 中的分区表达式设置。 -在执行时,对于数据快照,该查询会对表数据创建硬链接。硬链接位于目录 `/var/lib/clickhouse/shadow/N/...` 中,其中: +在执行时,对于数据快照,该查询会生成表数据的硬链接。硬链接置于 `/var/lib/clickhouse/shadow/N/...` 目录,其中: - `/var/lib/clickhouse/` 是配置中指定的工作 ClickHouse 目录。 -- `N` 是备份的递增编号。 -- 如果指定了 `WITH NAME` 参数,则 `'backup_name'` 参数的值将替代递增编号。 +- `N` 是备份的增量编号。 +- 如果指定了 `WITH NAME` 参数,则将使用 `'backup_name'` 参数的值,而不是增量编号。 :::note -如果您在表中使用 [一组磁盘进行数据存储](/engines/table-engines/mergetree-family/mergetree.md/#table_engine-mergetree-multiple-volumes),则在每个磁盘上都将出现 `shadow/N` 目录,存储与 `PARTITION` 表达式匹配的数据片段。 +如果您使用 [一组磁盘进行数据存储](/engines/table-engines/mergetree-family/mergetree.md/#table_engine-mergetree-multiple-volumes),则在每个磁盘上都会出现 `shadow/N` 目录,存储与 `PARTITION` 表达式匹配的数据部分。 ::: -备份内部的目录结构与 `/var/lib/clickhouse/` 内的结构相同。该查询对所有文件执行 `chmod`,禁止对其写入。 +查询内部创建的目录结构与 `/var/lib/clickhouse/` 中的相同。查询会对所有文件执行 `chmod`,禁止写入。 -创建备份后,您可以将数据从 `/var/lib/clickhouse/shadow/` 复制到远程服务器,然后从本地服务器中删除。请注意,`ALTER t FREEZE PARTITION` 查询不会被复制。它仅在本地服务器上创建本地备份。 +创建备份后,您可以从 `/var/lib/clickhouse/shadow/` 复制数据到远程服务器,然后从本地服务器中删除它。请注意,`ALTER t FREEZE PARTITION` 查询不进行复制。它仅在本地服务器上创建本地备份。 -该查询几乎是瞬时的(但首先它会等待与相应表相关的当前查询完成运行)。 +该查询几乎是瞬时创建的(但首先它会等待当前对相应表的查询完成执行)。 -`ALTER TABLE t FREEZE PARTITION` 仅复制数据,而不复制表元数据。要备份表元数据,请复制文件 `/var/lib/clickhouse/metadata/database/table.sql`。 +`ALTER TABLE t FREEZE PARTITION` 仅复制数据,不复制表元数据。要备份表的元数据,请复制 `/var/lib/clickhouse/metadata/database/table.sql` 文件。 -要从备份中恢复数据,请执行以下操作: +要从备份中恢复数据,请执行以下步骤: -1. 如果表不存在,则创建该表。要查看查询,请使用 .sql 文件(将 `ATTACH` 替换为 `CREATE`)。 -2. 将备份中 `data/database/table/` 目录中的数据复制到 `/var/lib/clickhouse/data/database/table/detached/` 目录中。 -3. 执行 `ALTER TABLE t ATTACH PARTITION` 查询将数据添加到表中。 +1. 如果表不存在,则创建该表。要查看查询,请使用 .sql 文件(将其中的 `ATTACH` 替换为 `CREATE`)。 +2. 从备份中的 `data/database/table/` 目录复制数据到 `/var/lib/clickhouse/data/database/table/detached/` 目录。 +3. 运行 `ALTER TABLE t ATTACH PARTITION` 查询将数据添加到表中。 -从备份恢复无需停止服务器。 +从备份中恢复不需要停止服务器。 -有关备份和恢复数据的更多信息,请参见 [数据备份](/operations/backup.md) 部分。 +有关备份和恢复数据的更多信息,请参见 [数据备份](/operations/backup.md) 一节。 ## UNFREEZE PARTITION {#unfreeze-partition} @@ -233,20 +235,24 @@ ALTER TABLE table_name [ON CLUSTER cluster] FREEZE [PARTITION partition_expr] [W ALTER TABLE table_name [ON CLUSTER cluster] UNFREEZE [PARTITION 'part_expr'] WITH NAME 'backup_name' ``` -从磁盘中删除具有指定名称的 `frozen` 分区。如果省略 `PARTITION` 子句,查询会一次性删除所有分区的备份。 +从磁盘中删除具有指定名称的 `frozen` 分区。如果省略 `PARTITION` 子句,则查询一次性删除所有分区的备份。 ## CLEAR INDEX IN PARTITION {#clear-index-in-partition} -该查询的工作原理类似于 `CLEAR COLUMN`,但重置的是索引而不是列数据。 +```sql +ALTER TABLE table_name [ON CLUSTER cluster] CLEAR INDEX index_name IN PARTITION partition_expr +``` + +该查询与 `CLEAR COLUMN` 类似,但它重置的是一个索引,而不是列数据。 -## FETCH PARTITION\|PART {#fetch-partitionpart} +## FETCH PARTITION|PART {#fetch-partitionpart} -从另一个服务器下载分区。此查询仅适用于复制表。 +从另一台服务器下载一个分区。此查询仅适用于复制表。 该查询执行以下操作: -1. 从指定分片下载分区|片段。在 'path-in-zookeeper' 中,您必须指定指向 ZooKeeper 中分片的路径。 -2. 然后查询将下载的数据放入 `table_name` 表的 `detached` 目录。使用 [ATTACH PARTITION\|PART](#attach-partitionpart) 查询将数据添加到表中。 +1. 从指定的分片下载分区|部分。在 'path-in-zookeeper' 中,您必须指定 ZooKeeper 中的分片路径。 +2. 然后,查询将下载的数据放入 `table_name` 表的 `detached` 目录。使用 [ATTACH PARTITION\|PART](#attach-partitionpart) 查询将数据添加到表中。 例如: @@ -263,16 +269,16 @@ ALTER TABLE users ATTACH PART 201901_2_2_0; 请注意: -- `ALTER ... FETCH PARTITION|PART` 查询不会被复制。它仅在本地服务器上将片段或分区放入 `detached` 目录。 -- `ALTER TABLE ... ATTACH` 查询是可复制的。它将数据添加到所有副本中。数据从 `detached` 目录中的一个副本添加到其他副本中,则从邻近副本添加。 +- `ALTER ... FETCH PARTITION|PART` 查询没有复制。它仅在本地服务器上将部分或分区放入 `detached` 目录。 +- `ALTER TABLE ... ATTACH` 查询是复制的。它将数据添加到所有副本中。数据从 `detached` 目录添加到其中一个副本,从邻近副本添加到其他副本。 -在下载之前,系统检查分区是否存在以及表结构是否匹配。最合适的副本将从健康副本中自动选择。 +在下载之前,系统会检查分区是否存在以及表结构是否匹配。从健康副本中自动选择最合适的副本。 -尽管查询被称为 `ALTER TABLE`,但它不会更改表结构,并且不会立即更改表中可用的数据。 +尽管该查询称为 `ALTER TABLE`,但它并不更改表结构,也不立即更改表中的可用数据。 ## MOVE PARTITION\|PART {#move-partitionpart} -将分区或数据片段移动到 `MergeTree` 引擎表的另一个卷或磁盘。请参见 [使用多个存储设备进行数据存储](/engines/table-engines/mergetree-family/mergetree.md/#table_engine-mergetree-multiple-volumes)。 +将分区或数据部分移动到另一卷或磁盘用于 `MergeTree` 引擎表。请参见 [使用多个块设备进行数据存储](/engines/table-engines/mergetree-family/mergetree.md/#table_engine-mergetree-multiple-volumes)。 ```sql ALTER TABLE table_name [ON CLUSTER cluster] MOVE PARTITION|PART partition_expr TO DISK|VOLUME 'disk_name' @@ -280,9 +286,9 @@ ALTER TABLE table_name [ON CLUSTER cluster] MOVE PARTITION|PART partition_expr T `ALTER TABLE t MOVE` 查询: -- 不可复制,因为不同副本可能具有不同的存储策略。 -- 如果未配置指定的磁盘或卷,将返回错误。如果所指定的存储策略无法应用于数据移动,查询也会返回错误。 -- 如果要移动的数据已被后台进程、并发的 `ALTER TABLE t MOVE` 查询或作为后台数据合并的结果移动,可能会返回错误。在这种情况下,用户不应执行任何其他操作。 +- 不进行复制,因为不同副本可以有不同的存储策略。 +- 如果指定的磁盘或卷没有配置,则返回错误。如果在存储策略中指定的数据移动条件无法应用,也会返回错误。 +- 如果要移动的数据已被后台进程、并发的 `ALTER TABLE t MOVE` 查询或后台数据合并进程移动,则可能返回错误。在这种情况下,用户不应执行任何其他操作。 示例: @@ -293,7 +299,7 @@ ALTER TABLE hits MOVE PARTITION '2019-09-01' TO DISK 'fast_ssd' ## UPDATE IN PARTITION {#update-in-partition} -操作指定分区中匹配指定过滤表达式的数据。实现为 [突变](/sql-reference/statements/alter/index.md#mutations)。 +根据指定的过滤表达式操作指定分区中的数据。实现为 [mutation](/sql-reference/statements/alter/index.md#mutations)。 语法: @@ -311,13 +317,13 @@ ALTER TABLE mt UPDATE x = x + 1 IN PARTITION 2 WHERE p = 2; ALTER TABLE mt UPDATE x = x + 1 IN PARTITION ID '2' WHERE p = 2; ``` -### 另见 {#see-also} +### 另请参见 {#see-also} - [UPDATE](/sql-reference/statements/alter/partition#update-in-partition) ## DELETE IN PARTITION {#delete-in-partition} -删除指定分区中匹配指定过滤表达式的数据。实现为 [突变](/sql-reference/statements/alter/index.md#mutations)。 +根据指定的过滤表达式删除指定分区中的数据。实现为 [mutation](/sql-reference/statements/alter/index.md#mutations)。 语法: @@ -335,28 +341,39 @@ ALTER TABLE mt DELETE IN PARTITION 2 WHERE p = 2; ALTER TABLE mt DELETE IN PARTITION ID '2' WHERE p = 2; ``` -### 另见 {#see-also-1} +## REWRITE PARTS {#rewrite-parts} + +这将从头开始重写部分,使用所有新设置。这是有意义的,因为例如 `use_const_adaptive_granularity` 的表级设置默认仅对新写入的部分应用。 + +### 示例 {#example-rewrite-parts} + +```sql +ALTER TABLE mt REWRITE PARTS; +ALTER TABLE mt REWRITE PARTS IN PARTITION 2; +``` + +### 另请参见 {#see-also-1} - [DELETE](/sql-reference/statements/alter/delete) ## 如何设置分区表达式 {#how-to-set-partition-expression} -您可以在 `ALTER ... PARTITION` 查询中通过不同方式指定分区表达式: +您可以在 `ALTER ... PARTITION` 查询中以不同方式指定分区表达式: -- 作为 `system.parts` 表中 `partition` 列的值。例如,`ALTER TABLE visits DETACH PARTITION 201901`。 -- 使用关键字 `ALL`。此关键字仅可与 DROP/DETACH/ATTACH/ATTACH FROM 一起使用。例如,`ALTER TABLE visits ATTACH PARTITION ALL`。 -- 作为与表分区键元组在类型上匹配的表达式或常量的元组。在单元素分区键的情况下,表达式应包裹在 `tuple (...)` 函数中。例如,`ALTER TABLE visits DETACH PARTITION tuple(toYYYYMM(toDate('2019-01-25')))`. -- 使用分区 ID。分区 ID 是分区的字符串标识符(尽可能易于阅读),在文件系统和 Zookeeper 中作为分区的名称。分区 ID 必须在 `PARTITION ID` 子句中用单引号指定。例如,`ALTER TABLE visits DETACH PARTITION ID '201901'`。 -- 在 [ALTER ATTACH PART](#attach-partitionpart) 和 [DROP DETACHED PART](#drop-detached-partitionpart) 查询中,要指定片段的名称,可使用来自 [system.detached_parts](/operations/system-tables/detached_parts) 表中 `name` 列的字符串字面值。例如,`ALTER TABLE visits ATTACH PART '201901_1_1_0'`。 +- 作为 `system.parts` 表的 `partition` 列中的值。例如,`ALTER TABLE visits DETACH PARTITION 201901`。 +- 使用关键字 `ALL`。它只能与 DROP/DETACH/ATTACH/ATTACH FROM 一起使用。例如,`ALTER TABLE visits ATTACH PARTITION ALL`。 +- 作为与表分区键元组匹配(在类型上)的表达式或常量的元组。在单元素分区键的情况下,表达式应包装在 `tuple (...)` 函数中。例如,`ALTER TABLE visits DETACH PARTITION tuple(toYYYYMM(toDate('2019-01-25')))`. +- 使用分区 ID。分区 ID 是分区的字符串标识符(如果可能的话,便于人类阅读),用于文件系统和 ZooKeeper 中作为分区的名称。分区 ID 必须在 `PARTITION ID` 子句中用单引号指定。例如,`ALTER TABLE visits DETACH PARTITION ID '201901'`。 +- 在 [ALTER ATTACH PART](#attach-partitionpart) 和 [DROP DETACHED PART](#drop-detached-partitionpart) 查询中,要指定部分的名称,请使用来自 [system.detached_parts](/operations/system-tables/detached_parts) 表的 `name` 列的字符串字面量。例如,`ALTER TABLE visits ATTACH PART '201901_1_1_0'`。 -指定分区时使用引号取决于分区表达式的类型。例如,对于 `String` 类型,您必须用引号(`'`)指定其名称。对于 `Date` 和 `Int*` 类型则不需要引号。 +在指定分区时使用引号取决于分区表达式的类型。例如,对于 `String` 类型,您必须在引号(`'`)中指定其名称。对于 `Date` 和 `Int*` 类型,则不需要引号。 -上述所有规则在 [OPTIMIZE](/sql-reference/statements/optimize.md) 查询中同样适用。如果您需要在优化非分区表时指定唯一分区,请设置表达式 `PARTITION tuple()`。例如: +上述所有规则对于 [OPTIMIZE](/sql-reference/statements/optimize.md) 查询同样适用。如果您需要在优化非分区表时仅指定一个分区,请设置表达式 `PARTITION tuple()`。例如: ```sql OPTIMIZE TABLE table_not_partitioned PARTITION tuple() FINAL; ``` -`IN PARTITION` 指定应用于 `UPDATE`(/sql-reference/statements/alter/update) 或 `DELETE`(/sql-reference/statements/alter/delete) 表达式的分区,作为 `ALTER TABLE` 查询的结果。从指定分区中只会创建新的片段。通过这种方式,`IN PARTITION` 有助于在表被划分为许多分区时减少负载,而您只需逐点更新数据。 +`IN PARTITION` 指定在 `ALTER TABLE` 查询的结果中应用 [UPDATE](/sql-reference/statements/alter/update) 或 [DELETE](/sql-reference/statements/alter/delete) 表达式的分区。仅从指定分区创建新部分。通过这种方式,`IN PARTITION` 有助于减少当表划分为多个分区且您只需逐点更新数据时的负载。 -`ALTER ... PARTITION` 查询的示例在测试 [`00502_custom_partitioning_local`](https://github.com/ClickHouse/ClickHouse/blob/master/tests/queries/0_stateless/00502_custom_partitioning_local.sql) 和 [`00502_custom_partitioning_replicated_zookeeper`](https://github.com/ClickHouse/ClickHouse/blob/master/tests/queries/0_stateless/00502_custom_partitioning_replicated_zookeeper.sql) 中展示。 +`ALTER ... PARTITION` 查询的示例在测试中演示 [`00502_custom_partitioning_local`](https://github.com/ClickHouse/ClickHouse/blob/master/tests/queries/0_stateless/00502_custom_partitioning_local.sql) 和 [`00502_custom_partitioning_replicated_zookeeper`](https://github.com/ClickHouse/ClickHouse/blob/master/tests/queries/0_stateless/00502_custom_partitioning_replicated_zookeeper.sql)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/partition.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/partition.md.hash index 6773ce538d6..1c532e8caa6 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/partition.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/partition.md.hash @@ -1 +1 @@ -cac231c2232cfc0c +05bc9ee8f0abaa29 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/projection.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/projection.md index 86a12a6f2ed..3545033db23 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/projection.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/projection.md @@ -1,26 +1,27 @@ --- -'description': '关于操作 PROJECTIONS 的文档' +'description': '用于操作投影的文档' 'sidebar_label': 'PROJECTION' 'sidebar_position': 49 'slug': '/sql-reference/statements/alter/projection' 'title': '投影' +'doc_type': 'reference' --- Projections store data in a format that optimizes query execution, this feature is useful for: -- 在主键之外的列上运行查询 +- 在不是主键的列上运行查询 - 预聚合列,这将减少计算和 IO -您可以为表定义一个或多个投影,在查询分析期间,将由 ClickHouse 选择数据扫描量最少的投影,而不会修改用户提供的查询。 +您可以为一个表定义一个或多个投影,并且在查询分析期间,将由 ClickHouse 选择数据扫描量最少的投影,而不会修改用户提供的查询。 -:::note 磁盘使用 +:::note 磁盘使用情况 -投影将在内部创建一个新的隐藏表,这意味着将需要更多的 IO 和磁盘空间。 -例如,如果投影定义了不同的主键,则原始表中的所有数据将被复制。 +投影将内部创建一个新的隐藏表,这意味着将需要更多的 IO 和磁盘空间。 +例如,如果投影定义了不同的主键,则原始表中的所有数据将会被重复。 ::: -您可以在此 [页面](/guides/best-practices/sparse-primary-indexes.md/#option-3-projections) 查看关于投影如何在内部工作的更多技术细节。 +您可以在此 [页面](/guides/best-practices/sparse-primary-indexes.md/#option-3-projections) 查看有关投影如何在内部工作的更多技术细节。 -## 示例:不使用主键的过滤 {#example-filtering-without-using-primary-keys} +## 示例:未使用主键的过滤 {#example-filtering-without-using-primary-keys} 创建表: ```sql @@ -54,8 +55,8 @@ INSERT INTO visits_order SELECT FROM numbers(1, 100); ``` -投影将允许我们快速按 `user_name` 进行过滤,即使在原始表中 `user_name` 并未被定义为 `PRIMARY_KEY`。 -在查询时,ClickHouse 判断如果使用投影,将处理更少的数据,因为数据是按 `user_name` 排序的。 +投影将允许我们快速按 `user_name` 进行过滤,即使在原始表中 `user_name` 并未定义为 `PRIMARY_KEY`。 +在查询时,ClickHouse 确定如果使用投影,将处理更少的数据,因为数据是按 `user_name` 排序的。 ```sql SELECT * @@ -64,14 +65,14 @@ WHERE user_name='test' LIMIT 2 ``` -要验证一个查询是否使用了投影,我们可以查看 `system.query_log` 表。在 `projections` 字段中,我们可以看到使用的投影名称,如果未使用则为空: +要验证查询是否使用投影,我们可以查看 `system.query_log` 表。在 `projections` 字段中,我们可以找到所使用的投影名称,如果没有使用任何,则为空: ```sql SELECT query, projections FROM system.query_log WHERE query_id='' ``` ## 示例:预聚合查询 {#example-pre-aggregation-query} -创建带有投影的表: +使用投影创建表: ```sql CREATE TABLE visits ( @@ -107,7 +108,7 @@ INSERT INTO visits SELECT 'IOS' FROM numbers(100, 500); ``` -我们将执行一个使用 `GROUP BY` 的首次查询,使用字段 `user_agent`,该查询将不使用定义的投影,因为预聚合不匹配。 +我们将执行第一个查询,使用 `GROUP BY` 和字段 `user_agent`,该查询将不会使用定义的投影,因为预聚合不匹配。 ```sql SELECT user_agent, @@ -116,7 +117,7 @@ FROM visits GROUP BY user_agent ``` -要使用投影,我们可以执行选择部分或所有预聚合和 `GROUP BY` 字段的查询。 +要使用投影,我们可以执行选择部分或全部预聚合和 `GROUP BY` 字段的查询。 ```sql SELECT user_agent @@ -132,14 +133,14 @@ FROM visits GROUP BY user_agent ``` -如前所述,我们可以查看 `system.query_log` 表。在 `projections` 字段中,我们可以看到使用的投影名称,如果未使用则为空: +如前所述,我们可以查看 `system.query_log` 表。在 `projections` 字段中,我们可以找到所使用的投影名称,如果没有使用任何,则为空: ```sql SELECT query, projections FROM system.query_log WHERE query_id='' ``` -## 正常投影与 `_part_offset` 字段 {#normal-projection-with-part-offset-field} +## 带有 `_part_offset` 字段的正常投影 {#normal-projection-with-part-offset-field} -创建一个包含正常投影且利用 `_part_offset` 字段的表: +创建一个带有正常投影的表,该投影利用 `_part_offset` 字段: ```sql CREATE TABLE events @@ -167,44 +168,45 @@ INSERT INTO events SELECT * FROM generateRandom() LIMIT 100000; ### 使用 `_part_offset` 作为二级索引 {#normal-projection-secondary-index} -`_part_offset` 字段保持其值在合并和变更中,从而使其成为二级索引的有价值选项。我们可以在查询中利用这一点: +`_part_offset` 字段在合并和变更中保留其值,这使得它对于二级索引非常有价值。我们可以在查询中利用这一点: ```sql SELECT count() FROM events -WHERE (_part, _part_offset) IN ( - SELECT _part, _part_offset +WHERE _part_starting_offset + _part_offset IN ( + SELECT _part_starting_offset + _part_offset FROM events WHERE user_id = 42 ) +SETTINGS enable_shared_storage_snapshot_in_query = 1 ``` # 操作投影 -以下操作与 [projections](/engines/table-engines/mergetree-family/mergetree.md/#projections) 可用: +以下与 [projections](/engines/table-engines/mergetree-family/mergetree.md/#projections) 相关的操作是可用的: ## 添加投影 {#add-projection} -`ALTER TABLE [db.]name [ON CLUSTER cluster] ADD PROJECTION [IF NOT EXISTS] name ( SELECT [GROUP BY] [ORDER BY] )` - 将投影描述添加到表元数据。 +`ALTER TABLE [db.]name [ON CLUSTER cluster] ADD PROJECTION [IF NOT EXISTS] name ( SELECT [GROUP BY] [ORDER BY] )` - 向表元数据添加投影描述。 ## 删除投影 {#drop-projection} -`ALTER TABLE [db.]name [ON CLUSTER cluster] DROP PROJECTION [IF EXISTS] name` - 从表元数据中移除投影描述,并从磁盘中删除投影文件。实现为 [mutation](/sql-reference/statements/alter/index.md#mutations)。 +`ALTER TABLE [db.]name [ON CLUSTER cluster] DROP PROJECTION [IF EXISTS] name` - 从表元数据中删除投影描述,并从磁盘删除投影文件。作为 [mutation](/sql-reference/statements/alter/index.md#mutations) 实现。 ## 物化投影 {#materialize-projection} -`ALTER TABLE [db.]table [ON CLUSTER cluster] MATERIALIZE PROJECTION [IF EXISTS] name [IN PARTITION partition_name]` - 查询在分区 `partition_name` 中重建投影 `name`。实现为 [mutation](/sql-reference/statements/alter/index.md#mutations)。 +`ALTER TABLE [db.]table [ON CLUSTER cluster] MATERIALIZE PROJECTION [IF EXISTS] name [IN PARTITION partition_name]` - 该查询在分区 `partition_name` 中重建投影 `name`。作为 [mutation](/sql-reference/statements/alter/index.md#mutations) 实现。 ## 清除投影 {#clear-projection} -`ALTER TABLE [db.]table [ON CLUSTER cluster] CLEAR PROJECTION [IF EXISTS] name [IN PARTITION partition_name]` - 从磁盘中删除投影文件而不移除描述。实现为 [mutation](/sql-reference/statements/alter/index.md#mutations)。 +`ALTER TABLE [db.]table [ON CLUSTER cluster] CLEAR PROJECTION [IF EXISTS] name [IN PARTITION partition_name]` - 从磁盘删除投影文件而不删除描述。作为 [mutation](/sql-reference/statements/alter/index.md#mutations) 实现。 命令 `ADD`、`DROP` 和 `CLEAR` 是轻量级的,因为它们仅更改元数据或删除文件。 此外,它们是可复制的,通过 ClickHouse Keeper 或 ZooKeeper 同步投影元数据。 :::note -投影操作仅支持具有 [`*MergeTree`](/engines/table-engines/mergetree-family/mergetree.md) 引擎的表(包括 [复制](/engines/table-engines/mergetree-family/replication.md) 变体)。 +投影操作仅支持使用 [`*MergeTree`](/engines/table-engines/mergetree-family/mergetree.md) 引擎的表(包括 [replicated](/engines/table-engines/mergetree-family/replication.md) 变体)。 ::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/projection.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/projection.md.hash index 29d516acb26..6af582b066c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/projection.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/projection.md.hash @@ -1 +1 @@ -40385e30268aa045 +e90abb113093eb11 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/quota.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/quota.md index 3827537edc5..314b1bc3c34 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/quota.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/quota.md @@ -1,14 +1,15 @@ --- -'description': '配额的文档' +'description': 'Quota 的文档' 'sidebar_label': 'QUOTA' 'sidebar_position': 46 'slug': '/sql-reference/statements/alter/quota' 'title': 'ALTER QUOTA' +'doc_type': 'reference' --- Changes quotas. -语法: +Syntax: ```sql ALTER QUOTA [IF EXISTS] name [ON CLUSTER cluster_name] @@ -23,17 +24,17 @@ ALTER QUOTA [IF EXISTS] name [ON CLUSTER cluster_name] 参数 `queries`、`query_selects`、`query_inserts`、`errors`、`result_rows`、`result_bytes`、`read_rows`、`read_bytes`、`execution_time` 对应于 [system.quotas_usage](../../../operations/system-tables/quotas_usage.md) 表中的字段。 -`ON CLUSTER` 子句允许在集群上创建配额,请参见 [Distributed DDL](../../../sql-reference/distributed-ddl.md)。 +`ON CLUSTER` 子句允许在集群上创建配额,请参阅 [Distributed DDL](../../../sql-reference/distributed-ddl.md)。 **示例** -限制当前用户的最大查询数量为 123 个,在 15 个月约束内: +限制当前用户在 15 个月内的最大查询数为 123 查询: ```sql ALTER QUOTA IF EXISTS qA FOR INTERVAL 15 month MAX queries = 123 TO CURRENT_USER; ``` -对于默认用户,限制最大执行时间为半秒,在 30 分钟内,并限制最大查询数量为 321,最大错误数量为 10,在 5 个季度内: +对于默认用户,限制 30 分钟内的最大执行时间为半秒,并限制查询的最大数量为 321,错误的最大数量为 10,在 5 个季度内: ```sql ALTER QUOTA IF EXISTS qB FOR INTERVAL 30 minute MAX execution_time = 0.5, FOR INTERVAL 5 quarter MAX queries = 321, errors = 10 TO default; diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/quota.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/quota.md.hash index e17f6d22c3b..f412e8d88d5 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/quota.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/quota.md.hash @@ -1 +1 @@ -d3bea9d02ec06f03 +f79fa71ba2ff84d2 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/role.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/role.md index f2a2d02942d..c813cf4990f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/role.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/role.md @@ -4,9 +4,10 @@ 'sidebar_position': 46 'slug': '/sql-reference/statements/alter/role' 'title': 'ALTER ROLE' +'doc_type': 'reference' --- -更改角色。 +Changes roles. 语法: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/role.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/role.md.hash index 36f4bac44e5..3bcdc9669b4 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/role.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/role.md.hash @@ -1 +1 @@ -c0cfd89f2aa3551f +9b770116c2b68bca diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/row-policy.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/row-policy.md index 2759a2d885f..98f94265eb4 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/row-policy.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/row-policy.md @@ -4,6 +4,7 @@ 'sidebar_position': 47 'slug': '/sql-reference/statements/alter/row-policy' 'title': 'ALTER ROW POLICY' +'doc_type': 'reference' --- diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/row-policy.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/row-policy.md.hash index 697e9983a2d..4644c669f29 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/row-policy.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/row-policy.md.hash @@ -1 +1 @@ -99cc11d60d5a13c1 +91850b4a757b0a06 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/sample-by.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/sample-by.md index 4f4330c559f..57657c765fb 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/sample-by.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/sample-by.md @@ -4,6 +4,7 @@ 'sidebar_position': 41 'slug': '/sql-reference/statements/alter/sample-by' 'title': '操作采样键表达式' +'doc_type': 'reference' --- @@ -17,7 +18,7 @@ ALTER TABLE [db].name [ON CLUSTER cluster] MODIFY SAMPLE BY new_expression ``` -该命令将表的 [采样键](../../../engines/table-engines/mergetree-family/mergetree.md) 更改为 `new_expression` (一个表达式或表达式的元组)。主键必须包含新的采样键。 +该命令将表的 [采样键](../../../engines/table-engines/mergetree-family/mergetree.md) 更改为 `new_expression`(一个表达式或表达式元组)。主键必须包含新的采样键。 ## REMOVE {#remove} @@ -27,8 +28,8 @@ ALTER TABLE [db].name [ON CLUSTER cluster] REMOVE SAMPLE BY 该命令移除表的 [采样键](../../../engines/table-engines/mergetree-family/mergetree.md)。 -命令 `MODIFY` 和 `REMOVE` 是轻量级的,因为它们仅更改元数据或删除文件。 +命令 `MODIFY` 和 `REMOVE` 是轻量级的,因为它们只更改元数据或移除文件。 :::note -它仅适用于 [MergeTree](../../../engines/table-engines/mergetree-family/mergetree.md) 系列的表(包括 [复制](../../../engines/table-engines/mergetree-family/replication.md) 表)。 +它仅适用于 [MergeTree](../../../engines/table-engines/mergetree-family/mergetree.md) 家族中的表(包括 [复制](../../../engines/table-engines/mergetree-family/replication.md) 表)。 ::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/sample-by.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/sample-by.md.hash index 28c1c93954d..ff0cc9d0a70 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/sample-by.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/sample-by.md.hash @@ -1 +1 @@ -800ab89bea5f8c0c +e7e6e2113239a9e1 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/setting.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/setting.md index cb4a7ce33cb..47afb1e2e0b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/setting.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/setting.md @@ -4,12 +4,13 @@ 'sidebar_position': 38 'slug': '/sql-reference/statements/alter/setting' 'title': '表设置操作' +'doc_type': 'reference' --- # 表设置操作 -有一组查询可以更改表设置。您可以修改设置或将其重置为默认值。单个查询可以同时更改多个设置。如果指定名称的设置不存在,则查询会引发异常。 +有一组查询用于更改表设置。您可以修改设置或将其重置为默认值。单个查询可以同时更改多个设置。如果指定名称的设置不存在,则查询会引发异常。 **语法** @@ -41,7 +42,7 @@ ALTER TABLE example_table MODIFY SETTING max_part_loading_threads=8, max_parts_i ## 重置设置 {#reset-setting} -将表设置重置为默认值。如果设置处于默认状态,则不采取任何操作。 +将表设置重置为默认值。如果设置处于默认状态,则不执行任何操作。 **语法** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/setting.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/setting.md.hash index 584b6f34713..be94aadc7a2 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/setting.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/setting.md.hash @@ -1 +1 @@ -b5f8916959c54627 +05ef625a45e2a26a diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/settings-profile.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/settings-profile.md index 144a7bee92f..0be1523e6ed 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/settings-profile.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/settings-profile.md @@ -1,14 +1,15 @@ --- -'description': 'Settings Profile 的文档' +'description': 'Settings Profile的文档' 'sidebar_label': 'SETTINGS PROFILE' 'sidebar_position': 48 'slug': '/sql-reference/statements/alter/settings-profile' 'title': 'ALTER SETTINGS PROFILE' +'doc_type': 'reference' --- -翻译如下: +翻译: -更改设置配置文件。 +修改设置配置文件。 语法: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/settings-profile.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/settings-profile.md.hash index edba3608832..ebb9679c462 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/settings-profile.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/settings-profile.md.hash @@ -1 +1 @@ -eee60f4b65b4367f +599d3229e74d6df6 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/skipping-index.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/skipping-index.md index 2f9eeb508f1..dd4805d3200 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/skipping-index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/skipping-index.md @@ -1,10 +1,11 @@ --- -'description': 'Manipulating 数据跳过索引 的文档' +'description': '操作数据跳过索引的文档' 'sidebar_label': 'INDEX' 'sidebar_position': 42 'slug': '/sql-reference/statements/alter/skipping-index' 'title': '操作数据跳过索引' 'toc_hidden_folder': true +'doc_type': 'reference' --- @@ -12,24 +13,24 @@ 以下操作可用: -## ADD INDEX {#add-index} +## 添加索引 {#add-index} `ALTER TABLE [db.]table_name [ON CLUSTER cluster] ADD INDEX [IF NOT EXISTS] name expression TYPE type [GRANULARITY value] [FIRST|AFTER name]` - 将索引描述添加到表的元数据中。 -## DROP INDEX {#drop-index} +## 删除索引 {#drop-index} -`ALTER TABLE [db.]table_name [ON CLUSTER cluster] DROP INDEX [IF EXISTS] name` - 从表的元数据中删除索引描述,并从磁盘删除索引文件。实现为[变更](/sql-reference/statements/alter/index.md#mutations)。 +`ALTER TABLE [db.]table_name [ON CLUSTER cluster] DROP INDEX [IF EXISTS] name` - 从表的元数据中删除索引描述,并从磁盘删除索引文件。 实现为 [mutation](/sql-reference/statements/alter/index.md#mutations)。 -## MATERIALIZE INDEX {#materialize-index} +## 物化索引 {#materialize-index} -`ALTER TABLE [db.]table_name [ON CLUSTER cluster] MATERIALIZE INDEX [IF EXISTS] name [IN PARTITION partition_name]` - 为指定的 `partition_name` 重新构建二级索引 `name`。实现为[变更](/sql-reference/statements/alter/index.md#mutations)。如果省略 `IN PARTITION` 部分,则为整个表数据重新构建该索引。 +`ALTER TABLE [db.]table_name [ON CLUSTER cluster] MATERIALIZE INDEX [IF EXISTS] name [IN PARTITION partition_name]` - 为指定的 `partition_name` 重新构建二级索引 `name`。 实现为 [mutation](/sql-reference/statements/alter/index.md#mutations)。 如果省略 `IN PARTITION` 部分,则会为整个表数据重新构建索引。 -## CLEAR INDEX {#clear-index} +## 清除索引 {#clear-index} -`ALTER TABLE [db.]table_name [ON CLUSTER cluster] CLEAR INDEX [IF EXISTS] name [IN PARTITION partition_name]` - 从磁盘中删除二级索引文件,而不移除描述。实现为[变更](/sql-reference/statements/alter/index.md#mutations)。 +`ALTER TABLE [db.]table_name [ON CLUSTER cluster] CLEAR INDEX [IF EXISTS] name [IN PARTITION partition_name]` - 从磁盘中删除二级索引文件而不移除描述。 实现为 [mutation](/sql-reference/statements/alter/index.md#mutations)。 -`ADD`、`DROP` 和 `CLEAR` 命令是轻量级的,因为它们只改变元数据或移除文件。同时,它们是被复制的,通过 ClickHouse Keeper 或 ZooKeeper 同步索引元数据。 +命令 `ADD`、`DROP` 和 `CLEAR` 是轻量级的,因为它们只更改元数据或删除文件。 此外,它们是被复制的,通过 ClickHouse Keeper 或 ZooKeeper 同步索引元数据。 :::note -索引操作仅支持使用[`*MergeTree`](/engines/table-engines/mergetree-family/mergetree.md)引擎的表(包括[复制](/engines/table-engines/mergetree-family/replication.md)变体)。 +仅支持对使用 [`*MergeTree`](/engines/table-engines/mergetree-family/mergetree.md) 引擎的表(包括 [replicated](/engines/table-engines/mergetree-family/replication.md) 变体)进行索引操作。 ::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/skipping-index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/skipping-index.md.hash index d016c9a599a..fce5be29d1b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/skipping-index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/skipping-index.md.hash @@ -1 +1 @@ -a40226ed217a7e6a +5e62d2c4887d689c diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/statistics.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/statistics.md index 45927d3ec31..871c8464173 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/statistics.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/statistics.md @@ -1,9 +1,10 @@ --- -'description': '关于操作列统计信息的文档' +'description': '有关操作列统计信息的文档' 'sidebar_label': 'STATISTICS' 'sidebar_position': 45 'slug': '/sql-reference/statements/alter/statistics' 'title': '操作列统计信息' +'doc_type': 'reference' --- import ExperimentalBadge from '@theme/badges/ExperimentalBadge'; @@ -15,30 +16,30 @@ import CloudNotSupportedBadge from '@theme/badges/CloudNotSupportedBadge'; -以下操作可用: +以下操作是可用的: -- `ALTER TABLE [db].table ADD STATISTICS [IF NOT EXISTS] (column list) TYPE (type list)` - 将统计信息描述添加到表的元数据中。 +- `ALTER TABLE [db].table ADD STATISTICS [IF NOT EXISTS] (column list) TYPE (type list)` - 向表元数据添加统计描述。 -- `ALTER TABLE [db].table MODIFY STATISTICS (column list) TYPE (type list)` - 修改表的元数据中的统计信息描述。 +- `ALTER TABLE [db].table MODIFY STATISTICS (column list) TYPE (type list)` - 修改表元数据的统计描述。 -- `ALTER TABLE [db].table DROP STATISTICS [IF EXISTS] (column list)` - 从指定列的元数据中删除统计信息,并删除所有部分中指定列的所有统计对象。 +- `ALTER TABLE [db].table DROP STATISTICS [IF EXISTS] (column list)` - 从指定列的元数据中删除统计信息,并删除所有分片中指定列的所有统计对象。 -- `ALTER TABLE [db].table CLEAR STATISTICS [IF EXISTS] (column list)` - 删除所有部分中指定列的所有统计对象。可以使用 `ALTER TABLE MATERIALIZE STATISTICS` 重建统计对象。 +- `ALTER TABLE [db].table CLEAR STATISTICS [IF EXISTS] (column list)` - 删除指定列的所有分片中的所有统计对象。可以使用 `ALTER TABLE MATERIALIZE STATISTICS` 重新构建统计对象。 -- `ALTER TABLE [db.]table MATERIALIZE STATISTICS [IF EXISTS] (column list)` - 重建列的统计信息。实现为 [mutation](../../../sql-reference/statements/alter/index.md#mutations)。 +- `ALTER TABLE [db.]table MATERIALIZE STATISTICS (ALL | [IF EXISTS] (column list))` - 重建列的统计。作为一种 [mutation](../../../sql-reference/statements/alter/index.md#mutations) 实现。 前两个命令是轻量级的,因为它们只更改元数据或删除文件。 -此外,它们是被复制的,通过 ZooKeeper 同步统计元数据。 +此外,它们是复制的,通过 ZooKeeper 同步统计元数据。 ## 示例: {#example} -向两个列添加两种统计信息类型: +向两个列添加两种统计类型: ```sql ALTER TABLE t1 MODIFY STATISTICS c, d TYPE TDigest, Uniq; ``` :::note -统计信息仅支持 [`*MergeTree`](../../../engines/table-engines/mergetree-family/mergetree.md) 引擎表(包括 [复制](../../../engines/table-engines/mergetree-family/replication.md) 变体)。 +统计仅支持 [`*MergeTree`](../../../engines/table-engines/mergetree-family/mergetree.md) 引擎表(包括 [复制的](../../../engines/table-engines/mergetree-family/replication.md) 变体)。 ::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/statistics.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/statistics.md.hash index 55bf69f1239..b8d647faefa 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/statistics.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/statistics.md.hash @@ -1 +1 @@ -c4152a1b3e1fe4e2 +80b93ed39c774748 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/ttl.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/ttl.md index 0ad84d8d11a..b235595cf64 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/ttl.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/ttl.md @@ -1,29 +1,30 @@ --- -'description': '与表生存时间 (TTL) 操作的文档' +'description': 'Manipulations with Table TTL 的文档' 'sidebar_label': 'TTL' 'sidebar_position': 44 'slug': '/sql-reference/statements/alter/ttl' 'title': '与表生存时间 (TTL) 的操作' +'doc_type': 'reference' --- -# Manipulations with Table TTL +# 表 TTL 操作 :::note -如果您想了解使用 TTL 管理旧数据的详细信息,请查看 [使用 TTL 管理数据](/guides/developer/ttl.md) 用户指南。以下文档演示了如何更改或删除现有的 TTL 规则。 +如果您想了解如何使用 TTL 管理旧数据,请查看[使用 TTL 管理数据](/guides/developer/ttl.md)用户指南。以下文档演示了如何更改或删除现有的 TTL 规则。 ::: -## MODIFY TTL {#modify-ttl} +## 修改 TTL {#modify-ttl} -您可以通过以下形式的请求更改 [表 TTL](../../../engines/table-engines/mergetree-family/mergetree.md#mergetree-table-ttl): +您可以通过以下形式的请求更改[表 TTL](../../../engines/table-engines/mergetree-family/mergetree.md#mergetree-table-ttl): ```sql ALTER TABLE [db.]table_name [ON CLUSTER cluster] MODIFY TTL ttl_expression; ``` -## REMOVE TTL {#remove-ttl} +## 删除 TTL {#remove-ttl} -可以通过以下查询从表中删除 TTL 属性: +可以通过以下查询从表中移除 TTL 属性: ```sql ALTER TABLE [db.]table_name [ON CLUSTER cluster] REMOVE TTL @@ -31,7 +32,7 @@ ALTER TABLE [db.]table_name [ON CLUSTER cluster] REMOVE TTL **示例** -考虑具有表 `TTL` 的表: +考虑一个具有表 `TTL` 的表: ```sql CREATE TABLE table_with_ttl @@ -50,7 +51,7 @@ INSERT INTO table_with_ttl VALUES (now(), 1, 'username1'); INSERT INTO table_with_ttl VALUES (now() - INTERVAL 4 MONTH, 2, 'username2'); ``` -运行 `OPTIMIZE` 强制执行 `TTL` 清理: +运行 `OPTIMIZE` 以强制清理 `TTL`: ```sql OPTIMIZE TABLE table_with_ttl FINAL; @@ -70,7 +71,7 @@ SELECT * FROM table_with_ttl FORMAT PrettyCompact; ALTER TABLE table_with_ttl REMOVE TTL; ``` -重新插入已删除的行,并通过 `OPTIMIZE` 强制执行 `TTL` 清理: +重新插入已删除的行,并通过 `OPTIMIZE` 再次强制清理 `TTL`: ```sql INSERT INTO table_with_ttl VALUES (now() - INTERVAL 4 MONTH, 2, 'username2'); @@ -89,5 +90,5 @@ SELECT * FROM table_with_ttl FORMAT PrettyCompact; **另见** -- 了解更多关于 [TTL 表达式](../../../sql-reference/statements/create/table.md#ttl-expression) 的信息。 -- 修改列 [使用 TTL](/sql-reference/statements/alter/ttl)。 +- 更多关于[TTL 表达式](../../../sql-reference/statements/create/table.md#ttl-expression)的信息。 +- 修改列[与 TTL](/sql-reference/statements/alter/ttl)有关。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/ttl.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/ttl.md.hash index 6318cb7a1df..486ad4adc89 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/ttl.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/ttl.md.hash @@ -1 +1 @@ -ded53dd0b10fc68a +0a41595dd5161c49 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/update.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/update.md index 50b6b333ed2..4f98f4ac44e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/update.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/update.md @@ -4,6 +4,7 @@ 'sidebar_position': 40 'slug': '/sql-reference/statements/alter/update' 'title': 'ALTER TABLE ... UPDATE 语句' +'doc_type': 'reference' --- @@ -13,13 +14,13 @@ ALTER TABLE [db.]table [ON CLUSTER cluster] UPDATE column1 = expr1 [, ...] [IN PARTITION partition_id] WHERE filter_expr ``` -操作与指定过滤表达式匹配的数据。实现为 [mutation](/sql-reference/statements/alter/index.md#mutations)。 +操纵与指定筛选表达式匹配的数据。作为一个 [mutation](/sql-reference/statements/alter/index.md#mutations) 实现。 :::note -`ALTER TABLE` 前缀使得此语法与大多数其他支持 SQL 的系统不同。它旨在表明,与 OLTP 数据库中的类似查询不同,这是一项不设计为频繁使用的重操作。 +`ALTER TABLE` 前缀使得该语法与大多数支持 SQL 的其他系统不同。它旨在表示,与 OLTP 数据库中的类似查询不同,这是一项重操作,并不设计为频繁使用。 ::: -`filter_expr` 必须是 `UInt8` 类型。此查询将指定列的值更新为 `filter_expr` 取非零值的行中对应表达式的值。值使用 `CAST` 运算符转换为列类型。不支持更新在主键或分区键计算中使用的列。 +`filter_expr` 必须为 `UInt8` 类型。此查询将指定列的值更新为 `filter_expr` 非零值行中对应表达式的值。值通过 `CAST` 操作符转换为列类型。不支持更新用于计算主键或分区键的列。 一个查询可以包含多个用逗号分隔的命令。 @@ -31,7 +32,6 @@ ALTER TABLE [db.]table [ON CLUSTER cluster] UPDATE column1 = expr1 [, ...] [IN P - [ALTER 查询的同步性](/sql-reference/statements/alter/index.md#synchronicity-of-alter-queries) - [mutations_sync](/operations/settings/settings.md/#mutations_sync) 设置 - ## 相关内容 {#related-content} - 博客: [在 ClickHouse 中处理更新和删除](https://clickhouse.com/blog/handling-updates-and-deletes-in-clickhouse) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/update.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/update.md.hash index f6239ad1db6..5c122bbfc43 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/update.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/update.md.hash @@ -1 +1 @@ -0e6d0a4e823bfaf3 +95aab65398f3b0e3 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/user.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/user.md index 6544a0520fd..55a7be37206 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/user.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/user.md @@ -4,6 +4,7 @@ 'sidebar_position': 45 'slug': '/sql-reference/statements/alter/user' 'title': 'ALTER USER' +'doc_type': 'reference' --- Changes ClickHouse 用户账户。 @@ -31,14 +32,14 @@ ALTER USER [IF EXISTS] name1 [RENAME TO new_name |, name2 [,...]] ## GRANTEES 子句 {#grantees-clause} -指定允许从此用户接收 [特权](../../../sql-reference/statements/grant.md#privileges) 的用户或角色,前提是此用户也拥有所有通过 [GRANT OPTION](../../../sql-reference/statements/grant.md#granting-privilege-syntax) 授予的所需访问权限。`GRANTEES` 子句的选项: +指定可以从此用户接收 [特权](../../../sql-reference/statements/grant.md#privileges) 的用户或角色,前提是此用户也具有使用 [GRANT OPTION](../../../sql-reference/statements/grant.md#granting-privilege-syntax) 授予的所有所需访问权限。 `GRANTEES` 子句的选项: - `user` — 指定此用户可以授予特权的用户。 - `role` — 指定此用户可以授予特权的角色。 -- `ANY` — 此用户可以将特权授予任何人。这是默认设置。 -- `NONE` — 此用户不能授予任何特权。 +- `ANY` — 该用户可以将特权授予任何人。这是默认设置。 +- `NONE` — 该用户不能授予任何特权。 -您可以使用 `EXCEPT` 表达式排除任何用户或角色。例如,`ALTER USER user1 GRANTEES ANY EXCEPT user2`。这意味着如果 `user1` 已获得某些通过 `GRANT OPTION` 授予的特权,它将能够将这些特权授予除 `user2` 之外的任何人。 +您可以使用 `EXCEPT` 表达式排除任何用户或角色。例如,`ALTER USER user1 GRANTEES ANY EXCEPT user2`。这意味着如果 `user1` 被授予了一些具有 `GRANT OPTION` 的特权,它将能够将这些特权授予任何人,除了 `user2`。 ## 示例 {#examples} @@ -48,7 +49,7 @@ ALTER USER [IF EXISTS] name1 [RENAME TO new_name |, name2 [,...]] ALTER USER user DEFAULT ROLE role1, role2 ``` -如果没有之前分配的角色,ClickHouse 将抛出异常。 +如果角色未被先前分配给用户,ClickHouse 将抛出异常。 将所有分配的角色设置为默认: @@ -56,55 +57,54 @@ ALTER USER user DEFAULT ROLE role1, role2 ALTER USER user DEFAULT ROLE ALL ``` -如果将来为用户分配角色,它将自动成为默认角色。 +如果将来将角色分配给用户,它将自动成为默认角色。 -将所有分配的角色设置为默认,排除 `role1` 和 `role2`: +将所有分配的角色设置为默认,除了 `role1` 和 `role2`: ```sql ALTER USER user DEFAULT ROLE ALL EXCEPT role1, role2 ``` -允许具有 `john` 账户的用户将自己的特权授予具有 `jack` 账户的用户: +允许 `john` 账户的用户将其特权授予 `jack` 账户的用户: ```sql ALTER USER john GRANTEES jack; ``` -在保留现有身份验证方法的情况下向用户添加新的身份验证方法: +在保留现有认证方式的同时,向用户添加新的认证方式: ```sql ALTER USER user1 ADD IDENTIFIED WITH plaintext_password by '1', bcrypt_password by '2', plaintext_password by '3' ``` 注意: -1. 较旧版本的 ClickHouse 可能不支持多重身份验证方法的语法。因此,如果 ClickHouse 服务器包含此类用户并降级到不支持该功能的版本,则此类用户将变为不可用,并且某些与用户相关的操作将中断。为了优雅地降级,必须在降级之前将所有用户设置为包含单一身份验证方法。或者,如果服务器在没有适当程序的情况下降级,则应删除有问题的用户。 -2. 出于安全原因,`no_password` 不能与其他身份验证方法共存。因为这样,无法 `ADD` `no_password` 身份验证方法。以下查询将抛出错误: +1. 旧版本的 ClickHouse 可能不支持多个认证方式的语法。因此,如果 ClickHouse 服务器包含这种用户并被降级到不支持该功能的版本,这些用户将变得不可用,并且某些与用户相关的操作将出现故障。为了平稳降级,必须在降级之前将所有用户设置为包含单个认证方式。或者,如果服务器在没有正确程序的情况下被降级,则应删除有问题的用户。 +2. 出于安全原因,`no_password` 不能与其他认证方式共存。因此,无法 `ADD` 一个 `no_password` 认证方式。以下查询将引发错误: ```sql ALTER USER user1 ADD IDENTIFIED WITH no_password ``` -如果您想为用户删除身份验证方法并依赖 `no_password`,您必须以以下替换形式指定。 +如果您想删除用户的认证方式并依赖于 `no_password`,必须在下面的替换形式中指定。 -重置身份验证方法并添加查询中指定的方法(效果类似于省略 ADD 关键字的 IDENTIFIED): +重置认证方式并添加查询中指定的方式(与前导 IDENTIFIED 具有相同效果,不带 ADD 关键字): ```sql ALTER USER user1 IDENTIFIED WITH plaintext_password by '1', bcrypt_password by '2', plaintext_password by '3' ``` -重置身份验证方法并保留最近添加的一个: +重置认证方式并保留最近添加的方式: ```sql ALTER USER user1 RESET AUTHENTICATION METHODS TO NEW ``` ## VALID UNTIL 子句 {#valid-until-clause} -允许您指定身份验证方法的到期日期和可选时间。它接受一个字符串作为参数。建议使用 `YYYY-MM-DD [hh:mm:ss] [timezone]` 格式指定日期时间。默认情况下,该参数等于 `'infinity'`。 -`VALID UNTIL` 子句只能与身份验证方法一起指定,除非查询中未指定任何身份验证方法。在这种情况下,`VALID UNTIL` 子句将应用于所有现有身份验证方法。 +允许您指定认证方式的过期日期和(可选的)时间。它接受一个字符串作为参数。建议使用 `YYYY-MM-DD [hh:mm:ss] [timezone]` 格式的日期时间。默认情况下,该参数等于 `'infinity'`。`VALID UNTIL` 子句只能与认证方式一起指定,除了在查询中没有指定认证方式的情况。在这种情况下,`VALID UNTIL` 子句将适用于所有现有的认证方式。 示例: - `ALTER USER name1 VALID UNTIL '2025-01-01'` - `ALTER USER name1 VALID UNTIL '2025-01-01 12:00:00 UTC'` - `ALTER USER name1 VALID UNTIL 'infinity'` -- `ALTER USER name1 IDENTIFIED WITH plaintext_password BY 'no_expiration', bcrypt_password BY 'expiration_set' VALID UNTIL'2025-01-01'` +- `ALTER USER name1 IDENTIFIED WITH plaintext_password BY 'no_expiration', bcrypt_password BY 'expiration_set' VALID UNTIL '2025-01-01'` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/user.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/user.md.hash index d6f93eab4dd..62cb66d758b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/user.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/user.md.hash @@ -1 +1 @@ -897d4fe7db7b46ce +793c92c38856034f diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/view.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/view.md index fc1c0b49808..92d85bb9fa7 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/view.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/view.md @@ -1,17 +1,18 @@ --- -'description': 'ALTER TABLE ... MODIFY QUERY 语句 的文档' +'description': 'ALTER TABLE ... MODIFY QUERY 语句的文档' 'sidebar_label': 'VIEW' 'sidebar_position': 50 'slug': '/sql-reference/statements/alter/view' 'title': 'ALTER TABLE ... MODIFY QUERY 语句' +'doc_type': 'reference' --- # ALTER TABLE ... MODIFY QUERY 语句 -您可以使用 `ALTER TABLE ... MODIFY QUERY` 语句修改在创建 [物化视图](/sql-reference/statements/create/view#materialized-view) 时指定的 `SELECT` 查询,而不影响数据摄取过程。 +您可以使用 `ALTER TABLE ... MODIFY QUERY` 语句修改在创建 [物化视图](/sql-reference/statements/create/view#materialized-view) 时指定的 `SELECT` 查询,而无需中断数据摄取过程。 -此命令用于更改使用 `TO [db.]name` 子句创建的物化视图。它不会更改底层存储表的结构,也不会更改物化视图的列定义,因此,对于没有使用 `TO [db.]name` 子句创建的物化视图,此命令的应用非常有限。 +此命令旨在更改使用 `TO [db.]name` 子句创建的物化视图。它不会更改底层存储表的结构,也不会更改物化视图的列定义,因此,只有在没有使用 `TO [db.]name` 子句创建的物化视图时,此命令的应用非常有限。 **带 TO 表的示例** @@ -28,7 +29,7 @@ FROM events GROUP BY ts, event_type; INSERT INTO events -SELECT Date '2020-01-01' + interval number * 900 second, +SELECT DATE '2020-01-01' + interval number * 900 second, ['imp', 'click'][number%2+1] FROM numbers(100); @@ -162,9 +163,9 @@ GROUP BY browser ``` -**无 TO 表的示例** +**不带 TO 表的示例** -应用非常有限,因为您只能更改 `SELECT` 部分而不能添加新列。 +应用非常有限,因为您只能更改 `SELECT` 部分,而不能添加新列。 ```sql CREATE TABLE src_table (`a` UInt32) ENGINE = MergeTree ORDER BY a; @@ -196,8 +197,8 @@ SELECT * FROM mv; ## ALTER LIVE VIEW 语句 {#alter-live-view-statement} -`ALTER LIVE VIEW ... REFRESH` 语句用于刷新 [实时视图](/sql-reference/statements/create/view#live-view)。请参阅 [强制刷新实时视图](/sql-reference/statements/create/view#live-view)。 +`ALTER LIVE VIEW ... REFRESH` 语句刷新 [实时视图](/sql-reference/statements/create/view#live-view)。请参见 [强制刷新实时视图](/sql-reference/statements/create/view#live-view)。 ## ALTER TABLE ... MODIFY REFRESH 语句 {#alter-table--modify-refresh-statement} -`ALTER TABLE ... MODIFY REFRESH` 语句更改 [可刷新的物化视图](../create/view.md#refreshable-materialized-view) 的刷新参数。请参阅 [更改刷新参数](../create/view.md#changing-refresh-parameters)。 +`ALTER TABLE ... MODIFY REFRESH` 语句更改 [可刷新的物化视图](../create/view.md#refreshable-materialized-view) 的刷新参数。请参见 [更改刷新参数](../create/view.md#changing-refresh-parameters)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/view.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/view.md.hash index 8c5363a99ec..68febb97e57 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/view.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/alter/view.md.hash @@ -1 +1 @@ -ecc2d6cd4fe306db +7fff356c3f1524f4 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/attach.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/attach.md index baf4fad110f..a30be835b0c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/attach.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/attach.md @@ -4,9 +4,10 @@ 'sidebar_position': 40 'slug': '/sql-reference/statements/attach' 'title': 'ATTACH 语句' +'doc_type': 'reference' --- -将表或字典附加到另一个服务器时,例如在移动数据库时。 +附加一个表或字典,例如,在将数据库移动到另一台服务器时。 **语法** @@ -14,9 +15,9 @@ ATTACH TABLE|DICTIONARY|DATABASE [IF NOT EXISTS] [db.]name [ON CLUSTER cluster] ... ``` -该查询不会在磁盘上创建数据,而是假设数据已经在适当的位置,只是将关于指定表、字典或数据库的信息添加到服务器。执行 `ATTACH` 查询后,服务器将知道表、字典或数据库的存在。 +该查询不会在磁盘上创建数据,而是假设数据已经在适当的位置,只是将指定的表、字典或数据库的信息添加到服务器。执行 `ATTACH` 查询后,服务器将知道表、字典或数据库的存在。 -如果一个表之前被分离(即 [DETACH](../../sql-reference/statements/detach.md) 查询),意味着它的结构已知,可以使用简写而无需定义结构。 +如果之前已脱离表([DETACH](../../sql-reference/statements/detach.md) 查询),意味着其结构已知,可以使用简写而不必定义结构。 ## 附加现有表 {#attach-existing-table} @@ -26,15 +27,15 @@ ATTACH TABLE|DICTIONARY|DATABASE [IF NOT EXISTS] [db.]name [ON CLUSTER cluster] ATTACH TABLE [IF NOT EXISTS] [db.]name [ON CLUSTER cluster] ``` -该查询在服务器启动时使用。服务器将表元数据作为 `ATTACH` 查询的文件存储,这些查询在启动时会简单地运行(某些系统表除外,这些表会在服务器上显式创建)。 +该查询用于启动服务器。服务器将表元数据存储为文件,并在启动时简单运行 `ATTACH` 查询(某些系统表除外,它们是在服务器上明确创建的)。 -如果表被永久分离,则在服务器启动时不会重新附加,因此需要显式使用 `ATTACH` 查询。 +如果表被永久脱离,则在服务器启动时不会重新附加,因此需要显式使用 `ATTACH` 查询。 ## 创建新表并附加数据 {#create-new-table-and-attach-data} ### 指定表数据路径 {#with-specified-path-to-table-data} -该查询使用提供的结构创建一个新表,并从 `user_files` 中提供的目录附加表数据。 +该查询创建一个具有提供结构的新表,并从 `user_files` 中提供的目录附加表数据。 **语法** @@ -62,7 +63,7 @@ SELECT * FROM test; ### 指定表 UUID {#with-specified-table-uuid} -该查询使用提供的结构创建一个新表,并从具有指定 UUID 的表附加数据。 +该查询创建一个具有提供结构的新表,并从指定 UUID 的表中附加数据。 它由 [Atomic](../../engines/database-engines/atomic.md) 数据库引擎支持。 **语法** @@ -73,11 +74,11 @@ ATTACH TABLE name UUID '' (col1 Type1, ...) ## 将 MergeTree 表附加为 ReplicatedMergeTree {#attach-mergetree-table-as-replicatedmergetree} -允许将非复制的 MergeTree 表附加为 ReplicatedMergeTree。ReplicatedMergeTree 表将使用 `default_replica_path` 和 `default_replica_name` 设置的值创建。也可以将复制表附加为常规的 MergeTree。 +允许将非复制的 MergeTree 表附加为 ReplicatedMergeTree。将使用 `default_replica_path` 和 `default_replica_name` 设置的值创建 ReplicatedMergeTree 表。也可以将复制的表作为常规 MergeTree 附加。 -请注意,此查询不会影响 ZooKeeper 中表的数据。这意味着您必须使用 `SYSTEM RESTORE REPLICA` 在 ZooKeeper 中添加元数据,或者在附加后使用 `SYSTEM DROP REPLICA ... FROM ZKPATH ...` 清除它。 +请注意,该查询不会影响 ZooKeeper 中表的数据。这意味着您必须使用 `SYSTEM RESTORE REPLICA` 在 ZooKeeper 中添加元数据,或在附加后使用 `SYSTEM DROP REPLICA ... FROM ZKPATH ...` 清除它。 -如果您试图向现有的 ReplicatedMergeTree 表添加副本,请记住,转换后的 MergeTree 表中的所有本地数据将被分离。 +如果您尝试向现有的 ReplicatedMergeTree 表添加副本,请记住,转换后的 MergeTree 表中的所有本地数据将被脱离。 **语法** @@ -85,7 +86,7 @@ ATTACH TABLE name UUID '' (col1 Type1, ...) ATTACH TABLE [db.]name AS [NOT] REPLICATED ``` -**将表转换为复制的** +**将表转换为复制表** ```sql DETACH TABLE test; @@ -93,7 +94,7 @@ ATTACH TABLE test AS REPLICATED; SYSTEM RESTORE REPLICA test; ``` -**将表转换为非复制的** +**将表转换为非复制表** 获取表的 ZooKeeper 路径和副本名称: @@ -106,7 +107,7 @@ SELECT replica_name, zookeeper_path FROM system.replicas WHERE table='test'; │ r1 │ /clickhouse/tables/401e6a1f-9bf2-41a3-a900-abb7e94dff98/s1 │ └──────────────┴────────────────────────────────────────────────────────────┘ ``` -将表作为非复制附加,并从 ZooKeeper 中删除副本的数据: +将表附加为非复制表并从 ZooKeeper 中删除副本数据: ```sql DETACH TABLE test; ATTACH TABLE test AS NOT REPLICATED; @@ -115,7 +116,7 @@ SYSTEM DROP REPLICA 'r1' FROM ZKPATH '/clickhouse/tables/401e6a1f-9bf2-41a3-a900 ## 附加现有字典 {#attach-existing-dictionary} -附加之前分离的字典。 +附加一个之前脱离的字典。 **语法** @@ -125,7 +126,7 @@ ATTACH DICTIONARY [IF NOT EXISTS] [db.]name [ON CLUSTER cluster] ## 附加现有数据库 {#attach-existing-database} -附加之前分离的数据库。 +附加一个之前脱离的数据库。 **语法** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/attach.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/attach.md.hash index 89b440e028f..f7dc08e739e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/attach.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/attach.md.hash @@ -1 +1 @@ -5149c2ae334b8081 +ceb24619d086e420 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/check-grant.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/check-grant.md index 24b9b5b9692..4a1170678e2 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/check-grant.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/check-grant.md @@ -4,9 +4,10 @@ 'sidebar_position': 56 'slug': '/sql-reference/statements/check-grant' 'title': 'CHECK GRANT 语句' +'doc_type': 'reference' --- -`CHECK GRANT` 查询用于检查当前用户/角色是否被授予特定的权限。 +`CHECK GRANT` 查询用于检查当前用户/角色是否被授予特定权限。 ## 语法 {#syntax} @@ -20,9 +21,9 @@ CHECK GRANT privilege[(column_name [,...])] [,...] ON {db.table[*]|db[*].*|*.*|t ## 示例 {#examples} -如果用户曾被授予该权限,响应 `check_grant` 将为 `1`。否则,响应 `check_grant` 将为 `0`。 +如果用户之前被授予该权限,则响应 `check_grant` 将为 `1`。否则,响应 `check_grant` 将为 `0`。 -如果 `table_1.col1` 存在且当前用户被授予权限 `SELECT`/`SELECT(con)` 或角色(具有权限),则响应为 `1`。 +如果 `table_1.col1` 存在并且当前用户被授予 `SELECT`/`SELECT(con)` 权限或角色(具有该权限),则响应为 `1`。 ```sql CHECK GRANT SELECT(col1) ON table_1; ``` @@ -32,7 +33,7 @@ CHECK GRANT SELECT(col1) ON table_1; │ 1 │ └────────┘ ``` -如果 `table_2.col2` 不存在,或者当前用户未被授予权限 `SELECT`/`SELECT(con)` 或角色(具有权限),则响应为 `0`。 +如果 `table_2.col2` 不存在,或者当前用户没有被授予 `SELECT`/`SELECT(con)` 权限或角色(具有该权限),则响应为 `0`。 ```sql CHECK GRANT SELECT(col2) ON table_2; ``` @@ -44,4 +45,4 @@ CHECK GRANT SELECT(col2) ON table_2; ``` ## 通配符 {#wildcard} -指定权限时,可以使用星号 (`*`) 代替表名或数据库名。有关通配符规则,请参阅 [WILDCARD GRANTS](../../sql-reference/statements/grant.md#wildcard-grants)。 +指定权限时,可以使用星号(`*`)代替表名或数据库名。请查看 [WILDCARD GRANTS](../../sql-reference/statements/grant.md#wildcard-grants) 以获取通配符规则。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/check-grant.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/check-grant.md.hash index 74542a11327..d9759bc72a0 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/check-grant.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/check-grant.md.hash @@ -1 +1 @@ -4403770a7017596d +97a91c5b8af351bd diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/check-table.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/check-table.md index 718c62f9df7..3d54b5b4934 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/check-table.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/check-table.md @@ -4,16 +4,17 @@ 'sidebar_position': 41 'slug': '/sql-reference/statements/check-table' 'title': 'CHECK TABLE 语句' +'doc_type': 'reference' --- -在 ClickHouse 中,`CHECK TABLE` 查询用于对特定表或其分区进行验证检查。它通过验证校验和和其他内部数据结构来确保数据的完整性。 +在 ClickHouse 中,`CHECK TABLE` 查询用于对特定表或其分区执行验证检查。它通过验证校验和和其他内部数据结构来确保数据的完整性。 -具体而言,它比较实际文件大小与存储在服务器上的期望值。如果文件大小与存储的值不匹配,则表示数据已损坏。这可能是由于查询执行期间系统崩溃等原因造成的。 +特别地,它比较实际文件大小与存储在服务器上的预期值。如果文件大小与存储的值不匹配,则意味着数据已损坏。这可能是由系统在查询执行期间崩溃等原因引起的。 :::warning -`CHECK TABLE` 查询可能会读取表中的所有数据并占用一些资源,使其资源密集型。 +`CHECK TABLE` 查询可能会读取表中的所有数据并占用一些资源,因此资源密集型。 在执行此查询之前,请考虑对性能和资源利用的潜在影响。 -此查询不会改善系统的性能,如果您不确定自己在做什么,请勿执行该查询。 +此查询不会提高系统的性能,您不应在不确定自己在做什么的情况下执行它。 ::: ## 语法 {#syntax} @@ -25,20 +26,20 @@ CHECK TABLE table_name [PARTITION partition_expression | PART part_name] [FORMAT ``` - `table_name`:指定要检查的表的名称。 -- `partition_expression`:(可选)如果要检查表的特定分区,可以使用此表达式指定该分区。 -- `part_name`:(可选)如果要检查表中的特定部分,可以添加字符串文本以指定部分名称。 -- `FORMAT format`:(可选)允许您指定结果的输出格式。 -- `SETTINGS`:(可选)允许额外的设置。 - - **`check_query_single_value_result`**:(可选)此设置允许您在详细结果(`0`)或汇总结果(`1`)之间切换。 - - 还可以应用其他设置。如果您不需要结果的确定顺序,可以将 max_threads 设置为大于 1 的值以加快查询。 +- `partition_expression`: (可选)如果您想检查表的特定分区,可以使用此表达式来指定分区。 +- `part_name`: (可选)如果您想检查表中的特定部分,可以添加字符串文字以指定部分名称。 +- `FORMAT format`: (可选)允许您指定结果的输出格式。 +- `SETTINGS`: (可选)允许其他设置。 + - **`check_query_single_value_result`**: (可选)此设置允许您在详细结果(`0`)或汇总结果(`1`)之间切换。 + - 其他设置也可以应用。如果您不需要结果的确定性顺序,可以将 max_threads 设置为大于 1 的值以加快查询速度。 查询响应取决于 `check_query_single_value_result` 设置的值。 -在 `check_query_single_value_result = 1` 的情况下,仅返回一个带有单一行的 `result` 列。该行中的值为 `1`,如果完整性检查通过,若数据损坏则为 `0`。 +在 `check_query_single_value_result = 1` 的情况下,仅返回包含单行的 `result` 列。此行中的值为 `1`,如果完整性检查通过,如果数据已损坏,则为 `0`。 -当 `check_query_single_value_result = 0` 时,查询将返回以下列: +当 `check_query_single_value_result = 0` 时,查询返回以下列: - `part_path`:指示数据部分的路径或文件名。 - - `is_passed`:如果此部分检查成功,则返回 1,否则返回 0。 - - `message`:与检查相关的任何其他消息,例如错误或成功消息。 + - `is_passed`:如果此部分的检查成功则返回 1,否则返回 0。 + - `message`:与检查相关的任何附加消息,例如错误或成功消息。 `CHECK TABLE` 查询支持以下表引擎: @@ -47,13 +48,13 @@ CHECK TABLE table_name [PARTITION partition_expression | PART part_name] [FORMAT - [StripeLog](../../engines/table-engines/log-family/stripelog.md) - [MergeTree family](../../engines/table-engines/mergetree-family/mergetree.md) -在其他表引擎的表上执行会导致 `NOT_IMPLEMENTED` 异常。 +在其他表引擎上执行时会导致 `NOT_IMPLEMENTED` 异常。 -`*Log` 家族的引擎在故障时不提供自动数据恢复。请使用 `CHECK TABLE` 查询及时跟踪数据丢失。 +来自 `*Log` 家族的引擎在失败时不提供自动数据恢复。使用 `CHECK TABLE` 查询及时跟踪数据丢失。 ## 示例 {#examples} -默认情况下,`CHECK TABLE` 查询显示一般的表检查状态: +默认情况下,`CHECK TABLE` 查询显示一般表检查状态: ```sql CHECK TABLE test_table; @@ -100,7 +101,7 @@ SETTINGS check_query_single_value_result = 0 └──────────────┴───────────┴─────────┘ ``` -请注意,当部分不存在时,查询会返回错误: +请注意,当部分不存在时,查询返回错误: ```sql CHECK TABLE t0 PART '201003_111_222_0' @@ -110,13 +111,13 @@ CHECK TABLE t0 PART '201003_111_222_0' DB::Exception: No such data part '201003_111_222_0' to check in table 'default.t0'. (NO_SUCH_DATA_PART) ``` -### 接收 'Corrupted' 结果 {#receiving-a-corrupted-result} +### 接收'已损坏'结果 {#receiving-a-corrupted-result} :::warning -免责声明:此处描述的过程,包括直接从数据目录手动操作或删除文件,仅适用于实验或开发环境。请**勿**在生产服务器上尝试,因为这可能导致数据丢失或其他意外后果。 +免责声明:这里描述的过程,包括手动操作或直接删除数据目录中的文件,仅适用于实验或开发环境。**不**要在生产服务器上尝试此操作,因为这可能导致数据丢失或其他意外后果。 ::: -移除现有的校验和文件: +删除现有的校验和文件: ```bash rm /var/lib/clickhouse-server/data/default/t0/201003_3_3_0/checksums.txt @@ -137,9 +138,9 @@ Output: └──────────────┴───────────┴──────────────────────────────────────────┘ ``` -如果 checksums.txt 文件丢失,则可以恢复。它将在针对特定分区执行 CHECK TABLE 命令期间被重新计算和重写,并且状态仍将报告为 'is_passed = 1'。 +如果 checksums.txt 文件缺失,可以恢复。在 CHECK TABLE 命令执行特定分区时,它将被重新计算并重写,状态仍将报告为 'is_passed = 1'。 -您可以通过使用 `CHECK ALL TABLES` 查询一次性检查所有现有的 `(Replicated)MergeTree` 表。 +您可以通过使用 `CHECK ALL TABLES` 查询检查所有现有的 `(Replicated)MergeTree` 表。 ```sql CHECK ALL TABLES @@ -164,9 +165,9 @@ SETTINGS check_query_single_value_result = 0 ## 如果数据已损坏 {#if-the-data-is-corrupted} -如果表已损坏,您可以将非损坏的数据复制到另一个表。为此: +如果表已损坏,您可以将未损坏的数据复制到另一个表。为此: -1. 创建一个与损坏表结构相同的新表。为此执行查询 `CREATE TABLE AS `。 -2. 将 `max_threads` 值设置为 1,以便在单个线程中处理下一个查询。为此运行查询 `SET max_threads = 1`。 -3. 执行查询 `INSERT INTO SELECT * FROM `。该请求将非损坏数据从损坏表复制到另一个表。仅复制损坏部分前的数据。 -4. 重启 `clickhouse-client` 以重置 `max_threads` 值。 +1. 创建一个与损坏表具有相同结构的新表。为此执行查询 `CREATE TABLE AS `。 +2. 将 `max_threads` 值设置为 1,以在单线程中处理下一个查询。为此运行查询 `SET max_threads = 1`。 +3. 执行查询 `INSERT INTO SELECT * FROM `。此请求将未损坏的数据从损坏的表复制到另一个表中。仅会复制损坏部分之前的数据。 +4. 重新启动 `clickhouse-client` 以重置 `max_threads` 值。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/check-table.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/check-table.md.hash index 1aa8d14c0c7..47a594889ff 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/check-table.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/check-table.md.hash @@ -1 +1 @@ -47b486fcfd14fda0 +2d81a4b9ed37e489 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/database.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/database.md index fbb409bf6ac..11a7acf68d7 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/database.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/database.md @@ -4,10 +4,11 @@ 'sidebar_position': 35 'slug': '/sql-reference/statements/create/database' 'title': 'CREATE DATABASE' +'doc_type': 'reference' --- -# CREATE DATABASE +# 创建数据库 创建一个新的数据库。 @@ -15,36 +16,36 @@ CREATE DATABASE [IF NOT EXISTS] db_name [ON CLUSTER cluster] [ENGINE = engine(...)] [COMMENT 'Comment'] ``` -## Clauses {#clauses} +## 子句 {#clauses} -### IF NOT EXISTS {#if-not-exists} +### 如果不存在 {#if-not-exists} -如果 `db_name` 数据库已经存在,则 ClickHouse 不会创建新数据库,并且: +如果 `db_name` 数据库已经存在,则 ClickHouse 不会创建新的数据库,并且: -- 如果指定了该子句,则不会抛出异常。 -- 如果未指定该子句,则会抛出异常。 +- 如果指定了子句,则不会抛出异常。 +- 如果未指定子句,则会抛出异常。 -### ON CLUSTER {#on-cluster} +### 在集群上 {#on-cluster} -ClickHouse 在指定集群的所有服务器上创建 `db_name` 数据库。更多细节请参阅 [Distributed DDL](../../../sql-reference/distributed-ddl.md) 文章。 +ClickHouse 在指定集群的所有服务器上创建 `db_name` 数据库。更多详细信息请参阅 [分布式 DDL](../../../sql-reference/distributed-ddl.md) 文章。 -### ENGINE {#engine} +### 引擎 {#engine} -默认情况下,ClickHouse 使用它自己的 [Atomic](../../../engines/database-engines/atomic.md) 数据库引擎。还有 [Lazy](../../../engines/database-engines/lazy.md)、[MySQL](../../../engines/database-engines/mysql.md)、[PostgresSQL](../../../engines/database-engines/postgresql.md)、[MaterializedPostgreSQL](../../../engines/database-engines/materialized-postgresql.md)、[Replicated](../../../engines/database-engines/replicated.md)、[SQLite](../../../engines/database-engines/sqlite.md)。 +默认情况下,ClickHouse 使用其自己的 [Atomic](../../../engines/database-engines/atomic.md) 数据库引擎。还提供 [Lazy](../../../engines/database-engines/lazy.md)、[MySQL](../../../engines/database-engines/mysql.md)、[PostgresSQL](../../../engines/database-engines/postgresql.md)、[MaterializedPostgreSQL](../../../engines/database-engines/materialized-postgresql.md)、[Replicated](../../../engines/database-engines/replicated.md)、[SQLite](../../../engines/database-engines/sqlite.md) 等引擎。 -### COMMENT {#comment} +### 注释 {#comment} -在创建数据库时可以添加注释。 +创建数据库时可以添加注释。 -该注释对所有数据库引擎都支持。 +所有数据库引擎都支持注释。 -**Syntax** +**语法** ```sql CREATE DATABASE db_name ENGINE = engine(...) COMMENT 'Comment' ``` -**Example** +**示例** 查询: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/database.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/database.md.hash index 1e9b3d63d05..499763de413 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/database.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/database.md.hash @@ -1 +1 @@ -1a027207d0a2d9b8 +7158691762e71139 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/dictionary.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/dictionary.md index 48dfb52b2be..451e223e465 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/dictionary.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/dictionary.md @@ -1,12 +1,13 @@ --- -'description': '字典的 Documentation' +'description': '字典的文档' 'sidebar_label': 'DICTIONARY' 'sidebar_position': 38 'slug': '/sql-reference/statements/create/dictionary' 'title': 'CREATE DICTIONARY' +'doc_type': 'reference' --- -创建一个新的 [dictionary](../../../sql-reference/dictionaries/index.md),其具有给定的 [structure](../../../sql-reference/dictionaries/index.md#dictionary-key-and-fields)、[source](../../../sql-reference/dictionaries/index.md#dictionary-sources)、[layout](/sql-reference/dictionaries#storing-dictionaries-in-memory) 和 [lifetime](/sql-reference/dictionaries#refreshing-dictionary-data-using-lifetime)。 +创建一个新的 [字典](../../../sql-reference/dictionaries/index.md),其具有给定的 [结构](../../../sql-reference/dictionaries/index.md#dictionary-key-and-fields)、[源](../../../sql-reference/dictionaries/index.md#dictionary-sources)、[布局](/sql-reference/dictionaries#storing-dictionaries-in-memory) 和 [生存时间](/sql-reference/dictionaries#refreshing-dictionary-data-using-lifetime)。 ## 语法 {#syntax} @@ -26,11 +27,11 @@ SETTINGS(setting_name = setting_value, setting_name = setting_value, ...) COMMENT 'Comment' ``` -字典结构由属性组成。字典属性的指定方式类似于表列。唯一必需的属性是其类型,所有其他属性可以具有默认值。 +字典结构由属性组成。字典属性的指定方式与表列相似。唯一的必需属性是其类型,其他所有属性可以具有默认值。 -`ON CLUSTER` 子句允许在集群上创建字典,请参见 [Distributed DDL](../../../sql-reference/distributed-ddl.md)。 +`ON CLUSTER` 子句允许在集群上创建字典,详见 [分布式 DDL](../../../sql-reference/distributed-ddl.md)。 -根据字典的 [layout](/sql-reference/dictionaries#storing-dictionaries-in-memory),可以指定一个或多个属性作为字典键。 +根据字典的 [布局](/sql-reference/dictionaries#storing-dictionaries-in-memory),可以指定一个或多个属性作为字典键。 ## 源 {#source} @@ -84,7 +85,7 @@ LAYOUT(FLAT()) ``` :::note -在 [ClickHouse Cloud](https://clickhouse.com) 中使用 SQL 控制台时,创建字典时必须指定用户(`default` 或任何其他具有 `default_role` 角色的用户)和密码。 +在 [ClickHouse Cloud](https://clickhouse.com) 的 SQL 控制台中使用时,创建字典时必须指定一个用户(`default` 或任何其他具有 `default_role` 角色的用户)和密码。 ::: ```sql @@ -155,9 +156,9 @@ LAYOUT(HASHED()) ### 从另一个数据库创建字典 {#create-a-dictionary-from-another-database} -请查看 [Dictionary sources](/sql-reference/dictionaries#dbms) 中的详细信息。 +请参见 [字典源](/sql-reference/dictionaries#dbms) 中的详细信息。 **另见** -- 有关更多信息,请参见 [Dictionaries](../../../sql-reference/dictionaries/index.md) 部分。 -- [system.dictionaries](../../../operations/system-tables/dictionaries.md) — 此表包含有关 [Dictionaries](../../../sql-reference/dictionaries/index.md) 的信息。 +- 欲了解更多信息,请参见 [字典](../../../sql-reference/dictionaries/index.md) 部分。 +- [system.dictionaries](../../../operations/system-tables/dictionaries.md) — 此表包含有关 [字典](../../../sql-reference/dictionaries/index.md) 的信息。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/dictionary.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/dictionary.md.hash index baf4732cd9c..c2b08f01028 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/dictionary.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/dictionary.md.hash @@ -1 +1 @@ -2e17ce3ed06ac65a +0bd211652077df56 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/function.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/function.md index 8e629c603d0..b5b0cc12cc9 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/function.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/function.md @@ -1,27 +1,28 @@ --- -'description': 'Function 的文档' +'description': '函数的文档' 'sidebar_label': 'FUNCTION' 'sidebar_position': 38 'slug': '/sql-reference/statements/create/function' 'title': 'CREATE FUNCTION - 用户定义函数 (UDF)' +'doc_type': 'reference' --- -创建一个从 lambda 表达式生成的用户定义函数 (UDF)。该表达式必须由函数参数、常量、运算符或其他函数调用组成。 +创建一个用户定义的函数(UDF),该函数由一个 lambda 表达式构成。表达式必须包含函数参数、常量、运算符或其他函数调用。 **语法** ```sql CREATE FUNCTION name [ON CLUSTER cluster] AS (parameter0, ...) -> expression ``` -一个函数可以有任意数量的参数。 +函数可以有任意数量的参数。 -有一些限制: +有几个限制: -- 函数的名称在用户定义的和系统函数中必须是唯一的。 +- 函数的名称在用户定义和系统函数中必须是唯一的。 - 不允许递归函数。 - 函数使用的所有变量必须在其参数列表中指定。 -如果违反任何限制,将引发异常。 +如果违反了任何限制,则会引发异常。 **示例** @@ -42,7 +43,7 @@ SELECT number, linear_equation(number, 2, 1) FROM numbers(3); └────────┴──────────────────────────────┘ ``` -在以下查询中,用户定义的函数中调用了[条件函数](../../../sql-reference/functions/conditional-functions.md): +在以下查询中,用户定义的函数中调用了一个 [条件函数](../../../sql-reference/functions/conditional-functions.md): ```sql CREATE FUNCTION parity_str AS (n) -> if(n % 2, 'odd', 'even'); @@ -61,6 +62,6 @@ SELECT number, parity_str(number) FROM numbers(3); ## 相关内容 {#related-content} -### [可执行的 UDFs](/sql-reference/functions/udf.md). {#executable-udfs} +### [可执行的 UDFs](/sql-reference/functions/udf.md)。 {#executable-udfs} ### [ClickHouse Cloud 中的用户定义函数](https://clickhouse.com/blog/user-defined-functions-clickhouse-udfs) {#user-defined-functions-in-clickhouse-cloud} diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/function.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/function.md.hash index 9981ab09b35..a98277e1a63 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/function.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/function.md.hash @@ -1 +1 @@ -cf108e1e958fe9af +412884eff91492fe diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/index.md index 36e94bba197..0bbb981ab67 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/index.md @@ -4,6 +4,7 @@ 'sidebar_position': 34 'slug': '/sql-reference/statements/create/' 'title': 'CREATE 查询' +'doc_type': 'reference' --- diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/index.md.hash index 254dbb9f364..4f0da8aed18 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/index.md.hash @@ -1 +1 @@ -b03702e0ba16147f +5087a0fdadf12ce9 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/named-collection.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/named-collection.md index cd17f4a6f29..5005d2a2f5e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/named-collection.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/named-collection.md @@ -1,8 +1,9 @@ --- -'description': 'NAMED COLLECTION 的文档' +'description': '用于 CREATE NAMED COLLECTION 的文档' 'sidebar_label': 'NAMED COLLECTION' 'slug': '/sql-reference/statements/create/named-collection' 'title': 'CREATE NAMED COLLECTION' +'doc_type': 'reference' --- import CloudNotSupportedBadge from '@theme/badges/CloudNotSupportedBadge'; @@ -35,6 +36,6 @@ CREATE NAMED COLLECTION foobar AS a = '1', b = '2' OVERRIDABLE; - [创建命名集合](/sql-reference/statements/alter/named-collection) - [删除命名集合](/sql-reference/statements/drop#drop-function) -**另见** +**另请参见** - [命名集合指南](/operations/named-collections.md) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/named-collection.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/named-collection.md.hash index 090e241ab2b..3b7a142e534 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/named-collection.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/named-collection.md.hash @@ -1 +1 @@ -a1234a63881a8e54 +e245297f75633477 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/quota.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/quota.md index fbbbdb5dc6c..5608aba452d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/quota.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/quota.md @@ -4,9 +4,10 @@ 'sidebar_position': 42 'slug': '/sql-reference/statements/create/quota' 'title': 'CREATE QUOTA' +'doc_type': 'reference' --- -创建一个[配额](../../../guides/sre/user-management/index.md#quotas-management),可以分配给用户或角色。 +创建一个可以分配给用户或角色的 [配额](../../../guides/sre/user-management/index.md#quotas-management)。 语法: @@ -15,33 +16,33 @@ CREATE QUOTA [IF NOT EXISTS | OR REPLACE] name [ON CLUSTER cluster_name] [IN access_storage_type] [KEYED BY {user_name | ip_address | client_key | client_key,user_name | client_key,ip_address} | NOT KEYED] [FOR [RANDOMIZED] INTERVAL number {second | minute | hour | day | week | month | quarter | year} - {MAX { {queries | query_selects | query_inserts | errors | result_rows | result_bytes | read_rows | read_bytes | execution_time} = number } [,...] | + {MAX { {queries | query_selects | query_inserts | errors | result_rows | result_bytes | read_rows | read_bytes | written_bytes | execution_time | failed_sequential_authentications} = number } [,...] | NO LIMITS | TRACKING ONLY} [,...]] [TO {role [,...] | ALL | ALL EXCEPT role [,...]}] ``` 键 `user_name`、`ip_address`、`client_key`、`client_key, user_name` 和 `client_key, ip_address` 对应于 [system.quotas](../../../operations/system-tables/quotas.md) 表中的字段。 -参数 `queries`、`query_selects`、`query_inserts`、`errors`、`result_rows`、`result_bytes`、`read_rows`、`read_bytes`、`execution_time` 和 `failed_sequential_authentications` 对应于 [system.quotas_usage](../../../operations/system-tables/quotas_usage.md) 表中的字段。 +参数 `queries`、`query_selects`、`query_inserts`、`errors`、`result_rows`、`result_bytes`、`read_rows`、`read_bytes`、`written_bytes`、`execution_time`、`failed_sequential_authentications` 对应于 [system.quotas_usage](../../../operations/system-tables/quotas_usage.md) 表中的字段。 -`ON CLUSTER` 子句允许在集群上创建配额,见 [Distributed DDL](../../../sql-reference/distributed-ddl.md)。 +`ON CLUSTER` 子句允许在集群上创建配额,见 [分布式 DDL](../../../sql-reference/distributed-ddl.md)。 **示例** -限制当前用户在15个月内的最大查询数为123: +限制当前用户在 15 个月内最多可执行 123 个查询: ```sql CREATE QUOTA qA FOR INTERVAL 15 month MAX queries = 123 TO CURRENT_USER; ``` -对于默认用户,将最大执行时间限制为半秒,在30分钟内,最大查询数限制为321,最大错误数限制为10,在5个季度内: +对于默认用户,限制 30 分钟内最大执行时间为半秒,限制最多可执行 321 个查询和最多 10 个错误,限于 5 个季度: ```sql CREATE QUOTA qB FOR INTERVAL 30 minute MAX execution_time = 0.5, FOR INTERVAL 5 quarter MAX queries = 321, errors = 10 TO default; ``` -更多示例,使用xml配置(在ClickHouse Cloud中不支持),可以在[配额指南](/operations/quotas)中找到。 +更多示例,使用 XML 配置(不支持 ClickHouse Cloud),可以在 [配额指南](/operations/quotas) 中找到。 ## 相关内容 {#related-content} -- 博客: [使用ClickHouse构建单页应用程序](https://clickhouse.com/blog/building-single-page-applications-with-clickhouse-and-http) +- 博客: [使用 ClickHouse 构建单页应用程序](https://clickhouse.com/blog/building-single-page-applications-with-clickhouse-and-http) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/quota.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/quota.md.hash index e133c2aea4b..c373ed2fcff 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/quota.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/quota.md.hash @@ -1 +1 @@ -2f07d9985914671d +fcf6c2b2489270fb diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/role.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/role.md index a06bc28f1f6..e6ec01e5ebc 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/role.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/role.md @@ -4,9 +4,10 @@ 'sidebar_position': 40 'slug': '/sql-reference/statements/create/role' 'title': 'CREATE ROLE' +'doc_type': 'reference' --- -创建新的 [角色](../../../guides/sre/user-management/index.md#role-management)。角色是一组 [特权](/sql-reference/statements/grant#granting-privilege-syntax)。被分配角色的 [用户](../../../sql-reference/statements/create/user.md) 将获得该角色的所有特权。 +创建新的 [角色](../../../guides/sre/user-management/index.md#role-management)。角色是一组 [权限](/sql-reference/statements/grant#granting-privilege-syntax)。分配给角色的 [用户](../../../sql-reference/statements/create/user.md) 获取该角色的所有权限。 语法: @@ -18,13 +19,13 @@ CREATE ROLE [IF NOT EXISTS | OR REPLACE] name1 [, name2 [,...]] [ON CLUSTER clus ## 管理角色 {#managing-roles} -用户可以被分配多个角色。用户可以通过 [SET ROLE](../../../sql-reference/statements/set-role.md) 语句以任意组合应用其分配的角色。最终的特权范围是所有应用角色的所有特权的组合。如果用户的用户帐户直接授予了特权,这些特权也将与角色授予的特权相结合。 +用户可以被分配多个角色。用户可以通过 [SET ROLE](../../../sql-reference/statements/set-role.md) 语句按任意组合应用其分配的角色。最终权限范围是所有应用角色的所有权限的组合。如果用户的用户账户直接授予了权限,这些权限也会与通过角色授予的权限组合在一起。 -用户可以具有默认角色,这些角色在用户登录时生效。要设置默认角色,请使用 [SET DEFAULT ROLE](/sql-reference/statements/set-role#set-default-role) 语句或 [ALTER USER](/sql-reference/statements/alter/user) 语句。 +用户可以拥有默认角色,这些角色在用户登录时应用。要设置默认角色,请使用 [SET DEFAULT ROLE](/sql-reference/statements/set-role#set-default-role) 语句或 [ALTER USER](/sql-reference/statements/alter/user) 语句。 要撤销角色,请使用 [REVOKE](../../../sql-reference/statements/revoke.md) 语句。 -要删除角色,请使用 [DROP ROLE](/sql-reference/statements/drop#drop-role) 语句。被删除的角色会自动从所有分配了该角色的用户和角色中撤销。 +要删除角色,请使用 [DROP ROLE](/sql-reference/statements/drop#drop-role) 语句。被删除的角色会自动从所有被分配的用户和角色中撤销。 ## 示例 {#examples} @@ -33,15 +34,15 @@ CREATE ROLE accountant; GRANT SELECT ON db.* TO accountant; ``` -这组查询创建了角色 `accountant`,其具有从 `db` 数据库读取数据的特权。 +这一系列查询创建了一个具有从 `db` 数据库读取数据权限的角色 `accountant`。 -将角色分配给用户 `mira`: +将该角色分配给用户 `mira`: ```sql GRANT accountant TO mira; ``` -在角色分配后,用户可以应用该角色并执行允许的查询。例如: +在角色被分配之后,用户可以应用它并执行允许的查询。例如: ```sql SET ROLE accountant; diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/role.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/role.md.hash index 48eb58daa00..4ca14c35e14 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/role.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/role.md.hash @@ -1 +1 @@ -9558e93ebca174f0 +36cf3558489de07e diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/row-policy.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/row-policy.md index 81914d91671..fa298eefe33 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/row-policy.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/row-policy.md @@ -1,15 +1,16 @@ --- -'description': 'Row Policy的文档' +'description': 'Row Policy 的文档' 'sidebar_label': 'ROW POLICY' 'sidebar_position': 41 'slug': '/sql-reference/statements/create/row-policy' 'title': 'CREATE ROW POLICY' +'doc_type': 'reference' --- 创建一个 [行策略](../../../guides/sre/user-management/index.md#row-policy-management),即用于确定用户可以从表中读取哪些行的过滤器。 :::tip -行策略仅对具有只读访问权限的用户有意义。如果用户可以修改表或在表之间复制分区,那么行策略的限制就失去了意义。 +行策略仅对具有只读访问权限的用户有意义。如果用户可以修改表或在表之间复制分区,则会破坏行策略的限制。 ::: 语法: @@ -25,44 +26,44 @@ CREATE [ROW] POLICY [IF NOT EXISTS | OR REPLACE] policy_name1 [ON CLUSTER cluste ## USING 子句 {#using-clause} -允许指定条件来过滤行。如果条件计算为非零,则用户将看到该行。 +允许指定条件以过滤行。只有在条件对该行计算为非零时,用户才能看到该行。 ## TO 子句 {#to-clause} -在 `TO` 部分,您可以提供此策略适用的用户和角色列表。例如,`CREATE ROW POLICY ... TO accountant, john@localhost`。 +在 `TO` 部分,您可以提供一个用户和角色的列表,该策略应适用于这些用户。例如,`CREATE ROW POLICY ... TO accountant, john@localhost`。 关键字 `ALL` 表示所有 ClickHouse 用户,包括当前用户。关键字 `ALL EXCEPT` 允许从所有用户列表中排除某些用户,例如,`CREATE ROW POLICY ... TO ALL EXCEPT accountant, john@localhost`。 :::note -如果一个表没有定义行策略,则任何用户都可以 `SELECT` 表中的所有行。为表定义一个或多个行策略使得访问表依赖于行策略,无论这些行策略是否为当前用户定义。例如,以下策略: +如果没有为表定义行策略,则任何用户都可以 `SELECT` 表中的所有行。为表定义一个或多个行策略会使访问表依赖于行策略,无论这些行策略是否为当前用户定义。例如,以下策略: `CREATE ROW POLICY pol1 ON mydb.table1 USING b=1 TO mira, peter` -禁止用户 `mira` 和 `peter` 看到 `b != 1` 的行,而任何未提及的用户(例如用户 `paul`)将完全看不到 `mydb.table1` 的任何行。 +禁止用户 `mira` 和 `peter` 查看 `b != 1` 的行,并且任何未提及的用户(例如用户 `paul`)将完全看不到 `mydb.table1` 中的任何行。 -如果这不是所期望的,可以通过添加一个新的行策略来解决,像下面这样: +如果这不是所期望的,可以通过添加另一个行策略来解决,如下所示: `CREATE ROW POLICY pol2 ON mydb.table1 USING 1 TO ALL EXCEPT mira, peter` ::: ## AS 子句 {#as-clause} -允许在同一时间内为同一用户在同一表上启用多个策略。因此,我们需要一种方法来组合多个策略的条件。 +允许同一用户在同一表上同时启用多个策略。因此,我们需要一种方法来结合多个策略的条件。 -默认情况下,策略使用布尔 `OR` 运算符进行组合。例如,以下策略: +默认情况下,策略是使用布尔 `OR` 运算符组合的。例如,以下策略: ```sql CREATE ROW POLICY pol1 ON mydb.table1 USING b=1 TO mira, peter CREATE ROW POLICY pol2 ON mydb.table1 USING c=2 TO peter, antonio ``` -使用户 `peter` 能够看到 `b=1` 或 `c=2` 的行。 +使用户 `peter` 能够查看 `b=1` 或 `c=2` 的行。 -`AS` 子句指定策略应如何与其他策略结合。策略可以是准许的或限制性的。默认情况下,策略是准许的,这意味着它们使用布尔 `OR` 运算符进行组合。 +`AS` 子句指定策略如何与其他策略组合。策略可以是允许的或限制性的。默认情况下,策略是允许的,这意味着它们使用布尔 `OR` 运算符组合。 -策略也可以定义为限制性的作为替代。限制性策略使用布尔 `AND` 运算符进行组合。 +策略也可以被定义为限制性的作为一种替代方案。限制性策略是使用布尔 `AND` 运算符组合的。 -以下是一般公式: +这里是一般公式: ```text row_is_visible = (one or more of the permissive policies' conditions are non-zero) AND @@ -76,9 +77,9 @@ CREATE ROW POLICY pol1 ON mydb.table1 USING b=1 TO mira, peter CREATE ROW POLICY pol2 ON mydb.table1 USING c=2 AS RESTRICTIVE TO peter, antonio ``` -使用户 `peter` 仅在 `b=1` 和 `c=2` 都为真时才能看到行。 +使用户 `peter` 仅在 `b=1` AND `c=2` 两个条件都为真时才能查看行。 -数据库策略与表策略组合在一起。 +数据库策略与表策略相结合。 例如,以下策略: @@ -87,14 +88,12 @@ CREATE ROW POLICY pol1 ON mydb.* USING b=1 TO mira, peter CREATE ROW POLICY pol2 ON mydb.table1 USING c=2 AS RESTRICTIVE TO peter, antonio ``` -使用户 `peter` 仅在 `b=1` 和 `c=2` 都为真时才能看到 table1 的行,尽管在 mydb 中的任何其他表对该用户仅应用 `b=1` 策略。 - - +使用户 `peter` 仅在 `b=1` AND `c=2` 两个条件都为真时才能查看 table1 的行,尽管 +mydb 中的任何其他表对该用户仅应用 `b=1` 策略。 ## ON CLUSTER 子句 {#on-cluster-clause} -允许在集群上创建行策略,参见 [分布式 DDL](../../../sql-reference/distributed-ddl.md)。 - +允许在集群上创建行策略,请参见 [Distributed DDL](../../../sql-reference/distributed-ddl.md)。 ## 示例 {#examples} diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/row-policy.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/row-policy.md.hash index 4d29d93207b..861fe728551 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/row-policy.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/row-policy.md.hash @@ -1 +1 @@ -a82ff2247766e9f7 +bc3ab9305cdaa436 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/settings-profile.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/settings-profile.md index 1686b827141..c1eec4d97c1 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/settings-profile.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/settings-profile.md @@ -1,9 +1,10 @@ --- -'description': '设置配置文件的文档' +'description': 'SETTINGS PROFILE 的文档' 'sidebar_label': 'SETTINGS PROFILE' 'sidebar_position': 43 'slug': '/sql-reference/statements/create/settings-profile' 'title': 'CREATE SETTINGS PROFILE' +'doc_type': 'reference' --- 创建可以分配给用户或角色的 [设置配置文件](../../../guides/sre/user-management/index.md#settings-profiles-management)。 @@ -18,7 +19,7 @@ CREATE SETTINGS PROFILE [IF NOT EXISTS | OR REPLACE] name1 [, name2 [,...]] [TO {{role1 | user1 [, role2 | user2 ...]} | NONE | ALL | ALL EXCEPT {role1 | user1 [, role2 | user2 ...]}}] ``` -`ON CLUSTER` 子句允许在一个集群上创建设置配置文件,参见 [分布式 DDL](../../../sql-reference/distributed-ddl.md)。 +`ON CLUSTER` 子句允许在集群上创建设置配置文件,参见 [分布式 DDL](../../../sql-reference/distributed-ddl.md)。 ## 示例 {#example} @@ -27,7 +28,7 @@ CREATE SETTINGS PROFILE [IF NOT EXISTS | OR REPLACE] name1 [, name2 [,...]] CREATE USER robin IDENTIFIED BY 'password'; ``` -创建 `max_memory_usage_profile` 设置配置文件,该配置文件具有 `max_memory_usage` 设置的值和约束,并将其分配给用户 `robin`: +创建 `max_memory_usage_profile` 设置配置文件,并为 `max_memory_usage` 设置赋值和约束,并将其分配给用户 `robin`: ```sql CREATE diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/settings-profile.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/settings-profile.md.hash index 45e23ee2592..7c3cba8977c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/settings-profile.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/settings-profile.md.hash @@ -1 +1 @@ -08475682ed094541 +2bd0272767e76da1 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/table.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/table.md index 72233a4f829..fa59db10675 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/table.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/table.md @@ -1,5 +1,5 @@ --- -'description': 'Table 的文档' +'description': '表的 文档' 'keywords': - 'compression' - 'codec' @@ -9,19 +9,20 @@ 'sidebar_position': 36 'slug': '/sql-reference/statements/create/table' 'title': 'CREATE TABLE' +'doc_type': 'reference' --- import CloudNotSupportedBadge from '@theme/badges/CloudNotSupportedBadge'; import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; -创建新表。此查询可以根据用例具有各种语法形式。 +创建一个新表。根据用例,此查询可以有不同的语法形式。 -默认情况下,表只在当前服务器上创建。分布式 DDL 查询通过 `ON CLUSTER` 子句实现,具体内容 [单独描述](../../../sql-reference/distributed-ddl.md)。 +默认情况下,表仅在当前服务器上创建。分布式 DDL 查询作为 `ON CLUSTER` 子句实现, [另有描述](../../../sql-reference/distributed-ddl.md)。 ## 语法形式 {#syntax-forms} -### 使用显式模式 {#with-explicit-schema} +### 具有显式架构 {#with-explicit-schema} ```sql CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] @@ -33,32 +34,32 @@ CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] [COMMENT 'comment for table'] ``` -在 `db` 数据库中创建名为 `table_name` 的表,或者如果未设置 `db`,则在当前数据库中创建,表的结构在括号中指定,以及 `engine` 引擎。 -表的结构是列描述、二级索引和约束的列表。如果引擎支持 [主键](#primary-key),则将其作为表引擎的参数指示。 +在 `db` 数据库中创建一个名为 `table_name` 的表,如果没有设置 `db`,则在当前数据库中创建,结构在括号中指定和 `engine` 引擎。 +表的结构是列描述、二级索引和约束的列表。如果引擎支持 [主键](#primary-key),则会作为表引擎的参数指明。 -列描述在最简单的情况下为 `name type`。示例:`RegionID UInt32`。 +列描述在最简单的情况下是 `name type`。示例:`RegionID UInt32`。 也可以为默认值定义表达式(见下文)。 -如有必要,可以指定主键,包含一个或多个键表达式。 +如果必要,可以指定主键,一个或多个键的表达式。 可以为列和表添加注释。 -### 使用与其他表相似的模式 {#with-a-schema-similar-to-other-table} +### 具有类似其他表的架构 {#with-a-schema-similar-to-other-table} ```sql CREATE TABLE [IF NOT EXISTS] [db.]table_name AS [db2.]name2 [ENGINE = engine] ``` -创建一个具有与另一表相同结构的表。可以为该表指定不同的引擎。如果未指定引擎,则将使用 `db2.name2` 表的相同引擎。 +创建一个具有与另一个表相同结构的表。您可以为该表指定不同的引擎。如果未指定引擎,则将使用与 `db2.name2` 表相同的引擎。 -### 使用从其他表中克隆的模式和数据 {#with-a-schema-and-data-cloned-from-another-table} +### 具有从另一个表克隆的架构和数据 {#with-a-schema-and-data-cloned-from-another-table} ```sql CREATE TABLE [IF NOT EXISTS] [db.]table_name CLONE AS [db2.]name2 [ENGINE = engine] ``` -创建一个具有与另一表相同结构的表。可以为该表指定不同的引擎。如果未指定引擎,则将使用 `db2.name2` 表的相同引擎。创建新表后,将所有来自 `db2.name2` 的分区附加到它。换句话说,`db2.name2` 的数据在创建时克隆到 `db.table_name`。此查询等同于以下内容: +创建一个与另一个表相同结构的表。您可以为该表指定不同的引擎。如果未指定引擎,则将使用与 `db2.name2` 表相同的引擎。新表创建后,将所有来自 `db2.name2` 的分区附加到它。换句话说,`db2.name2` 的数据在创建时被克隆到 `db.table_name` 中。此查询等价于以下内容: ```sql CREATE TABLE [IF NOT EXISTS] [db.]table_name AS [db2.]name2 [ENGINE = engine]; @@ -71,7 +72,7 @@ ALTER TABLE [db.]table_name ATTACH PARTITION ALL FROM [db2].name2; CREATE TABLE [IF NOT EXISTS] [db.]table_name AS table_function() ``` -创建一个与指定的 [表函数](/sql-reference/table-functions) 结果相同的表。创建的表在工作原理上也与指定的相应表函数相同。 +创建一个与指定的 [表函数](/sql-reference/table-functions) 结果相同的表。创建的表也将在相同的方式下工作,与所指定的相应表函数相同。 ### 从 SELECT 查询 {#from-select-query} @@ -79,9 +80,9 @@ CREATE TABLE [IF NOT EXISTS] [db.]table_name AS table_function() CREATE TABLE [IF NOT EXISTS] [db.]table_name[(name1 [type1], name2 [type2], ...)] ENGINE = engine AS SELECT ... ``` -创建一个具有与 `SELECT` 查询结果类似的结构的表,使用 `engine` 引擎,并填充来自 `SELECT` 的数据。还可以显式指定列描述。 +创建一个结构类似于 `SELECT` 查询的结果的表,使用 `engine` 引擎,并用 `SELECT` 的数据填充它。您还可以显式指定列描述。 -如果表已经存在并且指定了 `IF NOT EXISTS`,则查询不会执行任何操作。 +如果表已经存在并且指定了 `IF NOT EXISTS`,那么查询将不执行任何操作。 查询中的 `ENGINE` 子句后可以有其他子句。有关如何创建表的详细文档,请参见 [表引擎](/engines/table-engines) 的描述。 @@ -126,29 +127,29 @@ SELECT x, toTypeName(x) FROM t1; ## NULL 或 NOT NULL 修饰符 {#null-or-not-null-modifiers} -在列定义的数据类型后使用 `NULL` 和 `NOT NULL` 修饰符允许或不允许列是 [Nullable](/sql-reference/data-types/nullable)。 +数据类型定义中的列定义后 `NULL` 和 `NOT NULL` 修饰符允许或不允许其为 [Nullable](/sql-reference/data-types/nullable)。 -如果类型不是 `Nullable` 并且指定了 `NULL`,则将被视为 `Nullable`;如果指定了 `NOT NULL`,则不是。例如,`INT NULL` 和 `Nullable(INT)` 是相同的。如果类型为 `Nullable`,而指定了 `NULL` 或 `NOT NULL` 修饰符,将抛出异常。 +如果类型不是 `Nullable` 并且指定了 `NULL`,则将被视为 `Nullable`;如果指定了 `NOT NULL`,则不是。例如,`INT NULL` 与 `Nullable(INT)` 是相同的。如果类型是 `Nullable` 并且指定了 `NULL` 或 `NOT NULL` 修饰符,将抛出异常。 -另见 [data_type_default_nullable](../../../operations/settings/settings.md#data_type_default_nullable) 设置。 +另请参见 [data_type_default_nullable](../../../operations/settings/settings.md#data_type_default_nullable) 设置。 ## 默认值 {#default_values} -列描述可以以 `DEFAULT expr`、`MATERIALIZED expr` 或 `ALIAS expr` 的形式指定默认值表达式。例如:`URLDomain String DEFAULT domain(URL)`。 +列描述可以以 `DEFAULT expr`、`MATERIALIZED expr` 或 `ALIAS expr` 的形式指定默认值表达式。示例:`URLDomain String DEFAULT domain(URL)`。 -表达式 `expr` 是可选的。如果省略,则必须显式指定列类型,对于数字列,默认值将为 `0`,对于字符串列,默认为 `''`(空字符串),对于数组列,默认为 `[]`(空数组),对于日期列,默认为 `1970-01-01`,或对于可空列,默认为 `NULL`。 +表达式 `expr` 是可选的。如果省略,则必须显式指定列类型,且默认值将为数字列的 `0`、字符串列的 `''`(空字符串)、数组列的 `[]`(空数组)、日期列的 `1970-01-01` 或可空列的 `NULL`。 -默认值列的列类型可以省略,在这种情况下,它将从 `expr` 的类型推断出。例如,`EventDate DEFAULT toDate(EventTime)` 的列类型将是日期。 +默认值列的列类型可以省略,在这种情况下从 `expr` 的类型推断。例如,列 `EventDate DEFAULT toDate(EventTime)` 的类型将为日期。 -如果同时指定了数据类型和默认值表达式,则会插入一个隐式类型强制转换函数,将表达式转换为指定的类型。例如,`Hits UInt32 DEFAULT 0` 在内部表示为 `Hits UInt32 DEFAULT toUInt32(0)`。 +如果同时指定了数据类型和默认值表达式,则会插入隐式类型转换函数,将表达式转换为指定类型。例如`Hits UInt32 DEFAULT 0` 在内部表示为 `Hits UInt32 DEFAULT toUInt32(0)`。 -默认值表达式 `expr` 可以引用任意表列和常量。ClickHouse 检查表结构的更改不会在表达式计算中引入循环。对于 INSERT,它检查表达式是否可解析——即它们可以从中计算的所有列都已传递。 +默认值表达式 `expr` 可以引用任意表列和常量。ClickHouse 检查表结构的更改是否不会在表达式计算中引入循环。对于 INSERT,它检查表达式是否可解析 - 即它们可以计算的所有列是否已经传递。 ### DEFAULT {#default} `DEFAULT expr` -正常默认值。如果在 INSERT 查询中未指定此列的值,则它将从 `expr` 计算出来。 +普通默认值。如果在 INSERT 查询中未指定该列的值,则从 `expr` 计算。 示例: @@ -162,7 +163,7 @@ CREATE OR REPLACE TABLE test ENGINE = MergeTree ORDER BY id; -INSERT INTO test (id) Values (1); +INSERT INTO test (id) VALUES (1); SELECT * FROM test; ┌─id─┬──────────updated_at─┬─updated_at_date─┐ @@ -174,9 +175,9 @@ SELECT * FROM test; `MATERIALIZED expr` -物化表达式。这类列的值在插入行时会根据指定的物化表达式自动计算。插入时无法显式指定值。 +物化表达式。此类列的值在插入行时根据指定的物化表达式自动计算。无法在 `INSERT` 中显式指定值。 -此外,这类默认值列不包含在 `SELECT *` 的结果中。这是为了保持 `SELECT *` 的结果可以通过 `INSERT` 重新插入回表中的不变性。这种行为可以通过设置 `asterisk_include_materialized_columns` 来禁用。 +此外,此类型的默认值列不包含在 `SELECT *` 的结果中。这是为了保持 `SELECT *` 的结果可以始终通过 `INSERT` 插回表的不变性。此行为可以通过设置 `asterisk_include_materialized_columns` 禁用。 示例: @@ -190,7 +191,7 @@ CREATE OR REPLACE TABLE test ENGINE = MergeTree ORDER BY id; -INSERT INTO test Values (1); +INSERT INTO test VALUES (1); SELECT * FROM test; ┌─id─┐ @@ -212,9 +213,9 @@ SELECT * FROM test SETTINGS asterisk_include_materialized_columns=1; `EPHEMERAL [expr]` -临时列。这类列不存储在表中,因此无法从中进行 SELECT。临时列的唯一目的是为其他列构建默认值表达式。 +短暂列。此类列不存储在表中,无法对其进行 SELECT。短暂列的唯一目的是从中构建其他列的默认值表达式。 -未显式指定列时的插入将跳过此类列。这是为了保持 `SELECT *` 的结果可以通过 `INSERT` 重新插入回表中的不变性。 +未显式指定列的插入将跳过此类列。这是为了保持 `SELECT *` 的结果可以始终通过 `INSERT` 插回表的不变性。 示例: @@ -228,7 +229,7 @@ CREATE OR REPLACE TABLE test ENGINE = MergeTree ORDER BY id; -INSERT INTO test (id, unhexed) Values (1, '5a90b714'); +INSERT INTO test (id, unhexed) VALUES (1, '5a90b714'); SELECT id, @@ -248,13 +249,13 @@ hex(hexed): 5A90B714 `ALIAS expr` -计算列(同义词)。此类列不存储在表中,因此无法向其中 INSERT 值。 +计算列(同义词)。此类列不存储在表中,无法向其 INSERT 值。 -当 SELECT 查询明确引用此类列时,值将在查询时间根据 `expr` 进行计算。默认情况下,`SELECT *` 排除 ALIAS 列。可以通过设置 `asterisk_include_alias_columns` 禁用此行为。 +当 SELECT 查询显式引用此类列时,值在查询时根据 `expr` 计算。默认情况下,`SELECT *` 排除 ALIAS 列。此行为可以通过设置 `asterisk_include_alias_columns` 禁用。 -使用 ALTER 查询添加新列时,旧数据将不写入这些列。相反,在读取没有新列值的旧数据时,默认情况下将动态计算表达式。但是,如果运行表达式需要不同列,而这些列在查询中未指示,这些列还会被读取,但仅适用于需要的数据块。 +使用 ALTER 查询添加新列时,不会写入这些列的旧数据。相反,在读取未为新列提供值的旧数据时,表达式默认按需计算。然而,如果运行表达式需要查询中未指示的不同列,这些列将额外被读取,但仅针对需要它的数据块。 -如果向表中添加新列,但后来更改其默认表达式,则用于旧数据的值将会改变(对于未在磁盘上存储值的数据)。请注意,在运行后台合并时,缺少合并部分中一个列的数据将写入合并部分。 +如果向表中添加新列,但稍后更改其默认表达式,旧数据使用的值将会更改(对于未在磁盘上存储值的数据)。请注意,运行后台合并时,对于合并部分丢失的列的数据会写入合并部分。 无法为嵌套数据结构中的元素设置默认值。 @@ -283,7 +284,7 @@ SELECT * FROM test SETTINGS asterisk_include_alias_columns=1; ## 主键 {#primary-key} -在创建表时,可以定义 [主键](../../../engines/table-engines/mergetree-family/mergetree.md#primary-keys-and-indexes-in-queries)。主键可以通过两种方式指定: +创建表时可以定义 [主键](../../../engines/table-engines/mergetree-family/mergetree.md#primary-keys-and-indexes-in-queries)。主键可以通过两种方式指定: - 在列列表内 @@ -308,12 +309,12 @@ PRIMARY KEY(expr1[, expr2,...]); ``` :::tip -不能在一个查询中组合两种方式。 +您不能在一个查询中结合这两种方式。 ::: ## 约束 {#constraints} -除了列描述外,还可以定义约束: +除了列描述之外,还可以定义约束: ### CONSTRAINT {#constraint} @@ -327,15 +328,15 @@ CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] ) ENGINE = engine ``` -`boolean_expr_1` 可以是任何布尔表达式。如果为表定义了约束,将为每一行在 INSERT 查询中检查它们。如果未满足任何约束——服务器将引发带有约束名称和检查表达式的异常。 +`boolean_expr_1` 可以是任何布尔表达式。如果为表定义了约束,则在每个 `INSERT` 查询的每一行中都会检查它们。如果不满足任何约束 - 服务器将抛出异常,并附上约束名称和检查表达式。 -添加大量约束可能会对大型 INSERT 查询的性能产生负面影响。 +添加大量约束可能会对大 `INSERT` 查询的性能产生负面影响。 ### ASSUME {#assume} -`ASSUME` 子句用于在假定为真的表上定义 `CONSTRAINT`。此约束然后可以被优化器用来增强 SQL 查询性能。 +`ASSUME` 子句用于定义被假定为真实的表上的 `CONSTRAINT`。该约束随后可以被优化器使用,以增强 SQL 查询的性能。 -以下是使用 `ASSUME CONSTRAINT` 创建 `users_a` 表的示例: +考虑以下示例,其中在 `users_a` 表的创建中使用了 `ASSUME CONSTRAINT`: ```sql CREATE TABLE users_a ( @@ -349,23 +350,23 @@ ENGINE=MergeTree ORDER BY (name_len, name); ``` -在这里,使用 `ASSUME CONSTRAINT` 断言 `length(name)` 函数总是等于 `name_len` 列的值。这意味着每当在查询中调用 `length(name)` 时,ClickHouse 可以将其替换为 `name_len`,因为它避免调用 `length()` 函数,这应该更快。 +在这里,`ASSUME CONSTRAINT` 用于断言 `length(name)` 函数始终等于 `name_len` 列的值。这意味着每当在查询中调用 `length(name)` 时,ClickHouse 可以将其替换为 `name_len`,这应该更快,因为避免了调用 `length()` 函数。 -然后,当执行查询 `SELECT name FROM users_a WHERE length(name) < 5;` 时,ClickHouse 可以优化为 `SELECT name FROM users_a WHERE name_len < 5`; 这是由于 `ASSUME CONSTRAINT`。这可以使查询运行得更快,因为它避免了计算每一行 `name` 的长度。 +然后,在执行查询 `SELECT name FROM users_a WHERE length(name) < 5;` 时,由于 `ASSUME CONSTRAINT`,ClickHouse 可以将其优化为 `SELECT name FROM users_a WHERE name_len < 5`; 因为否则将需要计算每一行的 `name` 的长度。 -`ASSUME CONSTRAINT` **不强制执行约束**,它只通知优化器该约束是正确的。如果约束实际上不成立,则查询结果可能不正确。因此,只有当你确定约束是正确时,才应使用 `ASSUME CONSTRAINT`。 +`ASSUME CONSTRAINT` **并不会强制约束**,它仅通知优化器该约束是成立的。如果约束实际上不成立,则查询结果可能会不正确。因此,您应仅在确定约束成立的情况下使用 `ASSUME CONSTRAINT`。 ## TTL 表达式 {#ttl-expression} -定义值的存储时间。只能为 MergeTree 家族表指定。有关详细描述,请参见 [列和表的 TTL](../../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-ttl)。 +定义值的存储时间。仅可为 MergeTree 家族表指定。有关详细描述,请参见 [TTL for columns and tables](../../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-ttl)。 -## 列压缩编码器 {#column_compression_codec} +## 列压缩编码 {#column_compression_codec} -默认情况下,ClickHouse 在自管理版本中应用 `lz4` 压缩,在 ClickHouse Cloud 中应用 `zstd`。 +默认情况下,ClickHouse 在自管理版本中应用 `lz4` 压缩,而在 ClickHouse Cloud 中应用 `zstd`。 -对于 `MergeTree` 引擎家族,可以在服务器配置的 [compression](/operations/server-configuration-parameters/settings#compression) 部分更改默认压缩方法。 +对于 `MergeTree` 引擎家族,您可以在服务器配置的 [compression](/operations/server-configuration-parameters/settings#compression) 部分更改默认压缩方法。 -还可以在 `CREATE TABLE` 查询中为每一列定义压缩方法。 +还可以在 `CREATE TABLE` 查询中为每个单独的列定义压缩方法。 ```sql CREATE TABLE codec_example @@ -380,25 +381,25 @@ ENGINE = ... ``` -可以指定 `Default` 编解码器以引用可能在运行时依赖于不同设置(和数据属性)的默认压缩。 -示例:`value UInt64 CODEC(Default)` — 等同于缺少编解码器规范。 +可以指定 `Default` 编解码器来引用默认压缩,这可能在运行时依赖于不同的设置(和数据的属性)。 +示例:`value UInt64 CODEC(Default)` — 与缺少编解码器指定相同。 -还可以从列中删除当前 CODEC,并使用来自 config.xml 的默认压缩: +您也可以将当前的 CODEC 从列中移除,并使用来自 config.xml 的默认压缩: ```sql ALTER TABLE codec_example MODIFY COLUMN float_value CODEC(Default); ``` -编解码器可以结合在一起使用,例如,`CODEC(Delta, Default)`。 +编码可以以管道方式组合,例如,`CODEC(Delta, Default)`。 :::tip -不能使用外部工具(如 `lz4`)解压 ClickHouse 数据库文件。相反,请使用特殊的 [clickhouse-compressor](https://github.com/ClickHouse/ClickHouse/tree/master/programs/compressor) 工具。 +您无法使用外部工具(如 `lz4`)解压 ClickHouse 数据库文件。请使用专用的 [clickhouse-compressor](https://github.com/ClickHouse/ClickHouse/tree/master/programs/compressor) 工具。 ::: 压缩支持以下表引擎: -- [MergeTree](../../../engines/table-engines/mergetree-family/mergetree.md) 家族。支持列压缩编码器并通过 [compression](/operations/server-configuration-parameters/settings#compression) 设置选择默认压缩方法。 -- [Log](../../../engines/table-engines/log-family/index.md) 家族。默认使用 `lz4` 压缩方法,并支持列压缩编码器。 +- [MergeTree](../../../engines/table-engines/mergetree-family/mergetree.md) 家族。支持列压缩编码和通过 [compression](/operations/server-configuration-parameters/settings#compression) 设置选择默认压缩方法。 +- [Log](../../../engines/table-engines/log-family/index.md) 家族。默认使用 `lz4` 压缩方法,并支持列压缩编码。 - [Set](../../../engines/table-engines/special/set.md)。仅支持默认压缩。 - [Join](../../../engines/table-engines/special/join.md)。仅支持默认压缩。 @@ -408,72 +409,72 @@ ClickHouse 支持通用编解码器和专用编解码器。 #### NONE {#none} -`NONE` — 不压缩。 +`NONE` — 无压缩。 #### LZ4 {#lz4} -`LZ4` — 默认使用的无损 [数据压缩算法](https://github.com/lz4/lz4)。应用 LZ4 快速压缩。 +`LZ4` — 默认情况下使用的不失真 [数据压缩算法](https://github.com/lz4/lz4)。应用 LZ4 快速压缩。 #### LZ4HC {#lz4hc} -`LZ4HC[(level)]` — 可配置等级的 LZ4 HC(高压缩)算法。默认级别:9。设置 `level <= 0` 应用默认级别。可能的级别:\[1, 12\]。推荐级别范围:\[4, 9\]。 +`LZ4HC[(level)]` — 带有可配置级别的 LZ4 HC(高压缩)算法。默认级别:9。设置 `level <= 0` 应用默认级别。可能级别:\[1, 12\]。推荐级别范围:\[4, 9\]。 #### ZSTD {#zstd} -`ZSTD[(level)]` — 可配置 `level` 的 [ZSTD 压缩算法](https://en.wikipedia.org/wiki/Zstandard)。可能的级别:\[1, 22\]。默认级别:1。 +`ZSTD[(level)]` — 带有可配置 `level` 的 [ZSTD 压缩算法](https://en.wikipedia.org/wiki/Zstandard)。可能级别:\[1, 22\]。默认级别:1。 -较高的压缩级别适用于不对称的场景,例如压缩一次,随后多次解压。更高的级别意味着更好的压缩和更高的 CPU 使用率。 +较高的压缩级别对于不对称场景非常有用,例如压缩一次,重复解压缩。更高的级别意味着更好的压缩效果以及更高的 CPU 使用率。 #### ZSTD_QAT {#zstd_qat} -`ZSTD_QAT[(level)]` — 可配置级别的 [ZSTD 压缩算法](https://en.wikipedia.org/wiki/Zstandard),通过 [Intel® QATlib](https://github.com/intel/qatlib) 和 [Intel® QAT ZSTD Plugin](https://github.com/intel/QAT-ZSTD-Plugin) 实现。可能的级别:\[1, 12\]。默认级别:1。推荐级别范围:\[6, 12\]。有一些限制适用: +`ZSTD_QAT[(level)]` — 带有可配置级别的 [ZSTD 压缩算法](https://en.wikipedia.org/wiki/Zstandard),由 [Intel® QATlib](https://github.com/intel/qatlib) 和 [Intel® QAT ZSTD Plugin](https://github.com/intel/QAT-ZSTD-Plugin) 实现。可能级别:\[1, 12\]。默认级别:1。推荐级别范围:\[6, 12\]。一些限制适用: -- ZSTD_QAT 默认情况下是禁用的,只能在启用配置设置 [enable_zstd_qat_codec](../../../operations/settings/settings.md#enable_zstd_qat_codec) 后使用。 -- 对于压缩,ZSTD_QAT 尝试使用 Intel® QAT 卸载设备([QuickAssist Technology](https://www.intel.com/content/www/us/en/developer/topic-technology/open/quick-assist-technology/overview.html))。如果未找到这样的设备,它将回退到软件中的 ZSTD 压缩。 -- 解压总是以软件方式执行。 +- ZSTD_QAT 默认情况下被禁用,只能在启用配置设置 [enable_zstd_qat_codec](../../../operations/settings/settings.md#enable_zstd_qat_codec) 后使用。 +- 对于压缩,ZSTD_QAT 尝试使用 Intel® QAT 协处理器([快速协助技术](https://www.intel.com/content/www/us/en/developer/topic-technology/open/quick-assist-technology/overview.html))。如果找不到这样的设备,它将回退到软件中的 ZSTD 压缩。 +- 解压缩始终在软件中执行。 #### DEFLATE_QPL {#deflate_qpl} -`DEFLATE_QPL` — [Deflate 压缩算法](https://github.com/intel/qpl) 由 Intel® Query Processing Library 实现。有一些限制适用: +`DEFLATE_QPL` — 由 Intel® 查询处理库实现的 [Deflate 压缩算法](https://github.com/intel/qpl)。一些限制适用: -- DEFLATE_QPL 默认情况下是禁用的,只能在启用配置设置 [enable_deflate_qpl_codec](../../../operations/settings/settings.md#enable_deflate_qpl_codec) 后使用。 -- DEFLATE_QPL 需要使用 SSE 4.2 指令编译的 ClickHouse 版本(默认情况下是这种情况)。有关更多详细信息,请参阅 [使用 DEFLATE_QPL 构建 Clickhouse](/development/building_and_benchmarking_deflate_qpl)。 -- DEFLATE_QPL 最适合于系统配备 Intel® IAA(内存分析加速器)卸载设备。有关更多详细信息,请参阅 [加速器配置](https://intel.github.io/qpl/documentation/get_started_docs/installation.html#accelerator-configuration) 和 [使用 DEFLATE_QPL 进行基准测试](/development/building_and_benchmarking_deflate_qpl)。 -- DEFLATE_QPL 压缩的数据只能在与 SSE 4.2 启用的 ClickHouse 节点之间转换。 +- DEFLATE_QPL 默认情况下被禁用,只能在启用配置设置 [enable_deflate_qpl_codec](../../../operations/settings/settings.md#enable_deflate_qpl_codec) 后使用。 +- DEFLATE_QPL 需要使用 SSE 4.2 指令编译的 ClickHouse 构建(默认情况下即为如此)。有关更多详细信息,请参阅 [使用 DEFLATE_QPL 构建 Clickhouse](/development/building_and_benchmarking_deflate_qpl)。 +- 如果系统中具有 Intel® IAA(内存分析加速器)协处理器,DEFLATE_QPL 的效果最佳。有关更多详细信息,请参阅 [加速器配置](https://intel.github.io/qpl/documentation/get_started_docs/installation.html#accelerator-configuration) 和 [使用 DEFLATE_QPL 进行基准测试](/development/building_and_benchmarking_deflate_qpl)。 +- DEFLATE_QPL 压缩的数据只能在编译时启用了 SSE 4.2 的 ClickHouse 节点之间传输。 ### 专用编解码器 {#specialized-codecs} -这些编解码器旨在通过利用数据的特定特征使压缩更有效。其中一些编解码器本身不压缩数据,而是对数据进行预处理,使得使用通用编解码器的第二阶段压缩可以实现更高的数据压缩率。 +这些编解码器旨在利用数据的特定特性,使压缩更加有效。其中一些编解码器不实际压缩数据,它们会对数据进行预处理,以便使用通用编解码器进行的第二次压缩阶段可以实现更高的数据压缩率。 #### Delta {#delta} -`Delta(delta_bytes)` — 一种压缩方法,其中原始值被其两个相邻值间的差替换,除了保持不变的第一个值。最多使用 `delta_bytes` 来存储增量值,因此 `delta_bytes` 是原始值的最大大小。可能的 `delta_bytes` 值:1、2、4、8。默认值为 `sizeof(type)`,如果等于 1、2、4 或 8。在其他情况下,它为 1。Delta 是一种数据准备编解码器,即它不能单独使用。 +`Delta(delta_bytes)` — 一种压缩方法,其中原始值被相邻两个值的差替代,第一个值保持不变。`delta_bytes` 是原始值的最大大小,默认值为 `sizeof(type)`。指定 `delta_bytes` 作为参数已被弃用,并将在将来的版本中删除。Delta 是一种数据准备编解码器,即不能单独使用。 #### DoubleDelta {#doubledelta} -`DoubleDelta(bytes_size)` — 计算增量的增量并以紧凑的二进制形式写入。可能的 `bytes_size` 值:1、2、4、8,默认值为 `sizeof(type)`,如果等于 1、2、4 或 8。在所有其他情况下,它为 1。对于具有恒定步幅的单调序列(如时间序列数据),可以获取最佳压缩率。可以与任何固定宽度类型一起使用。实现了 Gorilla TSDB 中使用的算法,并扩展以支持 64 位类型。对于 32 位增量,使用了 1 位额外的位:5 位前缀而不是 4 位前缀。有关更多信息,请参见 [Gorilla: A Fast, Scalable, In-Memory Time Series Database](http://www.vldb.org/pvldb/vol8/p1816-teller.pdf) 中的压缩时间戳。DoubleDelta 是一种数据准备编解码器,即它不能单独使用。 +`DoubleDelta(bytes_size)` — 计算增量的增量,并以紧凑的二进制形式写入。`bytes_size` 的含义与 [Delta](#delta) 编解码器中的 `delta_bytes` 类似。对于具有恒定步幅的单调序列(如时间序列数据)可以获得最佳压缩率。可以与任何数值类型一起使用。实现了用于 Gorilla TSDB 的算法,扩展其以支持 64 位类型。对于 32 位增量,使用 1 个额外的位:使用 5 位前缀而不是 4 位前缀。有关更多信息,请参见 [Compressing Time Stamps in Gorilla: A Fast, Scalable, In-Memory Time Series Database](http://www.vldb.org/pvldb/vol8/p1816-teller.pdf)。DoubleDelta 是一种数据准备编解码器,即不能单独使用。 #### GCD {#gcd} -`GCD()` - 计算列中值的最大公约数 (GCD),然后将每个值除以 GCD。可以用于整数、十进制和日期/时间列。此编解码器非常适合于值以 GCD 倍数变化(增加或减少)的列,例如 24、28、16、24、8、24(GCD = 4)。GCD 是一种数据准备编解码器,即它不能单独使用。 +`GCD()` - 计算列中值的最大公约数(GCD),然后将每个值除以 GCD。可以用于整数、十进制和日期/时间列。该编解码器非常适合值按 GCD 的倍数发生变化(增加或减少)的列,例如 24、28、16、24、8、24(GCD = 4)。GCD 是一种数据准备编解码器,即不能单独使用。 #### Gorilla {#gorilla} -`Gorilla(bytes_size)` — 计算当前浮点值与前一个浮点值之间的异或,并以紧凑的二进制形式写入。连续值之间的差异越小,即系列值变化越慢,压缩率越好。实现了 Gorilla TSDB 中使用的算法,并扩展以支持 64 位类型。可能的 `bytes_size` 值:1、2、4、8,默认值为 `sizeof(type)`,如果等于 1、2、4 或 8。在所有其他情况下,它为 1。有关更多信息,请参见 [Gorilla: A Fast, Scalable, In-Memory Time Series Database](https://doi.org/10.14778/2824032.2824078) 第 4.1 节。 +`Gorilla(bytes_size)` — 计算当前和前一个浮点值之间的 XOR,并以紧凑的二进制形式写入。连续值之间的差异越小,即序列的值变化越慢,压缩率越好。实现了用于 Gorilla TSDB 的算法,扩展其以支持 64 位类型。可能的 `bytes_size` 值:1、2、4、8,如果为 1、2、4 或 8,则默认值为 `sizeof(type)`;在所有其他情况下,取 1。有关更多信息,请参见 [Gorilla: A Fast, Scalable, In-Memory Time Series Database](https://doi.org/10.14778/2824032.2824078) 中的第 4.1 节。 #### FPC {#fpc} -`FPC(level, float_size)` - 重复预测序列中的下一个浮点值,使用两个预测器中较好的一个,然后将实际值与预测值进行异或,并压缩结果的前导零。与 Gorilla 类似,这在存储缓慢变化的浮点值序列时非常有效。对于 64 位值(双精度),FPC 比 Gorilla 更快,对于 32 位值,效果可能有所不同。可能的 `level` 值:1-28,默认值为 12。可能的 `float_size` 值:4、8,默认值为 `sizeof(type)`,如果类型为 Float。在其他情况下,它为 4。有关算法的详细描述,请参见 [High Throughput Compression of Double-Precision Floating-Point Data](https://userweb.cs.txstate.edu/~burtscher/papers/dcc07a.pdf)。 +`FPC(level, float_size)` — 反复使用两个预测器中较好的一个来预测序列中下一个浮点值,然后将实际值与预测值进行 XOR,并进行前导零压缩。类似于 Gorilla,这在存储值变化缓慢的浮点值序列时效率较高。对于 64 位值(双精度),FPC 比 Gorilla 更快,对于 32 位值效果可能有所不同。可能的 `level` 值:1-28,默认值为 12。可能的 `float_size` 值:4、8,如果类型为 Float,则默认值为 `sizeof(type)`;在所有其他情况下,取 4。有关该算法的详细描述,请参见 [High Throughput Compression of Double-Precision Floating-Point Data](https://userweb.cs.txstate.edu/~burtscher/papers/dcc07a.pdf)。 #### T64 {#t64} -`T64` — 一种压缩方法,裁剪整数数据类型(包括 `Enum`、`Date` 和 `DateTime`)中值的未使用高位。在其算法的每一步中,编解码器选择 64 个值的块,将其放入 64x64 位矩阵中,转置,裁剪值的未使用位,然后将其作为序列返回。未使用的位是数据部分中的最大值和最小值之间不差异的位。 +`T64` — 一种压缩方法,裁剪整数数据类型中值的未使用的高位(包括 `Enum`、`Date` 和 `DateTime`)。在其算法的每一步中,编解码器获取 64 个值块,将它们放入 64x64 位矩阵,转置,裁剪未使用的值位并将其余部分作为序列返回。未使用的位是在整个数据部分的最大值和最小值之间没有差异的位。 -`DoubleDelta` 和 `Gorilla` 编解码器在 Gorilla TSDB 中用作其压缩算法的组成部分。Gorilla 方法在存在一系列缓慢变化的值及其时间戳的场景中有效。 `DoubleDelta` 编解码器有效压缩时间戳,而 `Gorilla` 编解码器有效压缩值。例如,要获取有效存储的表,可以以以下配置创建它: +`DoubleDelta` 和 `Gorilla` 编解码器作为其压缩算法的组成部分在 Gorilla TSDB 中使用。在时间戳具有缓慢变化的值的序列场景中,Gorilla 方法非常有效。时间戳通过 `DoubleDelta` 编解码器有效压缩,而值通过 `Gorilla` 编解码器有效压缩。例如,要获得有效存储的表,可以在以下配置中创建它: ```sql CREATE TABLE codec_example @@ -486,26 +487,26 @@ ENGINE = MergeTree() ### 加密编解码器 {#encryption-codecs} -这些编解码器实际上不压缩数据,而是对磁盘上的数据进行加密。仅在通过 [encryption](/operations/server-configuration-parameters/settings#encryption) 设置指定加密密钥时可用。请注意,加密仅在编解码器管道的末尾是有意义的,因为加密数据通常无法以任何有意义的方式进行压缩。 +这些编解码器实际上并不压缩数据,而是对磁盘上的数据进行加密。仅在通过 [encryption](/operations/server-configuration-parameters/settings#encryption) 设置指定了加密密钥时可用。请注意,加密仅在编码管道的末尾有意义,因为加密的数据通常无法以任何有意义的方式进行压缩。 加密编解码器: #### AES_128_GCM_SIV {#aes_128_gcm_siv} -`CODEC('AES-128-GCM-SIV')` — 使用 AES-128 在 [RFC 8452](https://tools.ietf.org/html/rfc8452) GCM-SIV 模式加密数据。 +`CODEC('AES-128-GCM-SIV')` — 使用 AES-128 加密数据,采用 [RFC 8452](https://tools.ietf.org/html/rfc8452) GCM-SIV 模式。 #### AES-256-GCM-SIV {#aes-256-gcm-siv} -`CODEC('AES-256-GCM-SIV')` — 使用 AES-256 在 GCM-SIV 模式下加密数据。 +`CODEC('AES-256-GCM-SIV')` — 使用 AES-256 加密数据,采用 GCM-SIV 模式。 -这些编解码器使用固定的随机数,因此加密是确定性的。这使其兼容于如 [ReplicatedMergeTree](../../../engines/table-engines/mergetree-family/replication.md) 之类的去重引擎,但存在一个弱点:当同一数据块被加密两次时,结果密文将完全相同,因此可以读取磁盘的对手可以看到这种相等性(尽管仅仅是相等性,而没有获取其内容)。 +这些编解码器使用固定的 nonce,因此加密是确定性的。这使其与能够去重的引擎(如 [ReplicatedMergeTree](../../../engines/table-engines/mergetree-family/replication.md))兼容,但也有一个弱点:当相同的数据块被加密两次时,结果的密文将完全相同,因此可以读取磁盘的对手可以看到这种等价性(尽管只有等价性,而无法获取其内容)。 :::note -大多数引擎,包括 "\*MergeTree" 家族,在磁盘上创建索引文件时不会应用编解码器。这意味着明文将出现在磁盘上,如果加密列被索引。 +大多数引擎(包括 "*MergeTree" 家族)在磁盘上创建索引文件时未应用编码。这意味着如果加密列已被索引,明文将出现在磁盘上。 ::: :::note -如果你在加密列中执行 SELECT 查询,并提到特定值(如在其 WHERE 子句中),该值可能会出现在 [system.query_log](../../../operations/system-tables/query_log.md) 中。你可能要禁用日志记录。 +如果您在加密列中提及特定值的 SELECT 查询(例如在其 WHERE 子句中),该值可能出现在 [system.query_log](../../../operations/system-tables/query_log.md) 中。您可能希望禁用日志记录。 ::: **示例** @@ -519,7 +520,7 @@ ENGINE = MergeTree ORDER BY x; ``` :::note -如果需要应用压缩,必须显式指定。否则,仅对数据应用加密。 +如果需要应用压缩,必须显式指定。否则,仅会对数据应用加密。 ::: **示例** @@ -527,7 +528,7 @@ ENGINE = MergeTree ORDER BY x; ```sql CREATE TABLE mytable ( - x String Codec(Delta, LZ4, AES_128_GCM_SIV) + x String CODEC(Delta, LZ4, AES_128_GCM_SIV) ) ENGINE = MergeTree ORDER BY x; ``` @@ -535,17 +536,17 @@ ENGINE = MergeTree ORDER BY x; ## 临时表 {#temporary-tables} :::note -请注意,临时表没有复制。因此,无法保证插入临时表的数据在其他副本中可用。临时表的主要使用案例是在单个会话中查询或连接小型外部数据集。 +请注意,临时表不被复制。因此,无法保证插入临时表中的数据将在其他副本中可用。临时表最主要的用例是用于在单个会话期间查询或连接小型外部数据集。 ::: -ClickHouse 支持临时表,具有以下特性: +ClickHouse 支持以下特性临时表: -- 当会话结束时,临时表将消失,包括连接丢失时。 -- 当未指定引擎时,临时表使用内存表引擎,它可以使用除 Replicated 和 `KeeperMap` 引擎外的任何表引擎。 -- 无法为临时表指定数据库。它是在数据库之外创建的。 -- 无法通过使用 `ON CLUSTER` 的分布式 DDL 查询在所有集群服务器上创建临时表:此表仅存在于当前会话中。 -- 如果临时表与其他表同名,并且查询指定列名而不指定数据库,则将使用临时表。 -- 对于分布式查询处理,在查询中使用 Memory 引擎的临时表将传递给远程服务器。 +- 临时表在会话结束时消失,包括如果连接丢失时。 +- 当未指定引擎时,临时表使用 Memory 表引擎,并且它可以使用除 Replicated 和 `KeeperMap` 引擎以外的任何表引擎。 +- 对于临时表,无法指定数据库。它是在数据库之外创建的。 +- 无法通过在所有集群服务器上使用分布式 DDL 查询(使用 `ON CLUSTER`)创建临时表:该表仅在当前会话中存在。 +- 如果临时表与另一个表同名,且查询在未指定数据库时指定了表名,则将使用临时表。 +- 对于分布式查询处理,查询中使用 Memory 引擎的临时表会传递到远程服务器。 要创建临时表,请使用以下语法: @@ -558,19 +559,22 @@ CREATE TEMPORARY TABLE [IF NOT EXISTS] table_name ) [ENGINE = engine] ``` -在大多数情况下,不手动创建临时表,而是在使用外部数据进行查询时,或者用于分布式 `(GLOBAL) IN`。有关更多信息,请参见适当的部分。 +在大多数情况下,临时表不是手动创建的,而是在查询中使用外部数据时,或用于分布式 `(GLOBAL) IN`。有关更多信息,请参见相关部分。 -可以使用 [ENGINE = Memory](../../../engines/table-engines/special/memory.md) 的表代替临时表。 +也可以使用 [ENGINE = Memory](../../../engines/table-engines/special/memory.md) 表替代临时表。 ## REPLACE TABLE {#replace-table} `REPLACE` 语句允许您以 [原子方式](/concepts/glossary#atomicity) 更新表。 :::note -该语句支持 [`Atomic`](../../../engines/database-engines/atomic.md) 和 [`Replicated`](../../../engines/database-engines/replicated.md) 数据库引擎,这两者分别是 ClickHouse 和 ClickHouse Cloud 的默认数据库引擎。 +此语句支持 [`Atomic`](../../../engines/database-engines/atomic.md) 和 [`Replicated`](../../../engines/database-engines/replicated.md) 数据库引擎,这是 ClickHouse 和 ClickHouse Cloud 的默认数据库引擎。 ::: -通常,如果需要从表中删除某些数据,可以创建新表,并通过 `SELECT` 语句填充该表,不检索不需要的数据,然后删除旧表并重命名新表。此方法在下面的示例中演示: +通常,如果您需要从表中删除一些数据, +可以创建一个新表并填充它,使用 `SELECT` 语句以不检索不需要的数据, +然后删除旧表并重命名新表。 +该方法在下面的示例中得以展示: ```sql CREATE TABLE myNewTable AS myOldTable; @@ -584,7 +588,7 @@ DROP TABLE myOldTable; RENAME TABLE myNewTable TO myOldTable; ``` -除了上述方法外,还可以使用 `REPLACE`(前提是您使用默认的数据库引擎)来实现相同的结果: +除了上述方法外,您还可以使用 `REPLACE`(前提是您使用默认数据库引擎)来实现相同的结果: ```sql REPLACE TABLE myOldTable @@ -602,10 +606,10 @@ WHERE CounterID <12345; ``` :::note -所有 `CREATE` 语句的语法形式也适用于此语句。调用不存在的表的 `REPLACE` 将导致错误。 +所有 `CREATE` 语句的语法形式也适用于此语句。在不存在的表上调用 `REPLACE` 会导致错误。 ::: -### 示例 {#examples} +### 示例: {#examples} @@ -653,7 +657,7 @@ SELECT * FROM base.t1; └───┴────┘ ``` -或者我们可以使用 `REPLACE` 语句更改表结构: +或者可以使用 `REPLACE` 语句更改表结构: ```sql REPLACE TABLE base.t1 (n UInt64) @@ -671,7 +675,7 @@ SELECT * FROM base.t1; -考虑 ClickHouse Cloud 中的以下表: +考虑 ClickHouse Cloud 上的以下表: ```sql CREATE DATABASE base; @@ -709,7 +713,7 @@ SELECT * FROM base.t1; 2 ``` -或者我们可以使用 `REPLACE` 语句更改表结构: +或者可以使用 `REPLACE` 语句更改表结构: ```sql REPLACE TABLE base.t1 (n UInt64) @@ -727,7 +731,7 @@ SELECT * FROM base.t1; ## COMMENT 子句 {#comment-clause} -在创建表时,可以添加注释。 +创建表时可以为其添加注释。 **语法** @@ -759,5 +763,5 @@ SELECT name, comment FROM system.tables WHERE name = 't1'; ## 相关内容 {#related-content} -- 博客: [优化 ClickHouse 的模式和编码](https://clickhouse.com/blog/optimize-clickhouse-codecs-compression-schema) -- 博客: [在 ClickHouse 中处理时间序列数据](https://clickhouse.com/blog/working-with-time-series-data-and-functions-ClickHouse) +- 博客:[优化 ClickHouse 的架构和编解码器](https://clickhouse.com/blog/optimize-clickhouse-codecs-compression-schema) +- 博客:[在 ClickHouse 中处理时间序列数据](https://clickhouse.com/blog/working-with-time-series-data-and-functions-ClickHouse) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/table.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/table.md.hash index ff55bda5341..4284a666aeb 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/table.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/table.md.hash @@ -1 +1 @@ -14aa78f435b5f5aa +90004fb8d6e5dc9a diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/user.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/user.md index 0d38b1b358a..a9001e456ce 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/user.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/user.md @@ -4,9 +4,10 @@ 'sidebar_position': 39 'slug': '/sql-reference/statements/create/user' 'title': 'CREATE USER' +'doc_type': 'reference' --- -创建 [用户账号](../../../guides/sre/user-management/index.md#user-account-management)。 +创建 [用户账户](../../../guides/sre/user-management/index.md#user-account-management)。 语法: @@ -23,11 +24,11 @@ CREATE USER [IF NOT EXISTS | OR REPLACE] name1 [, name2 [,...]] [ON CLUSTER clus [SETTINGS variable [= value] [MIN [=] min_value] [MAX [=] max_value] [READONLY | WRITABLE] | PROFILE 'profile_name'] [,...] ``` -`ON CLUSTER` 子句允许在集群上创建用户,参见 [分布式 DDL](../../../sql-reference/distributed-ddl.md)。 +`ON CLUSTER` 子句允许在集群上创建用户,参见 [分布式DDL](../../../sql-reference/distributed-ddl.md)。 -## 识别 {#identification} +## 身份识别 {#identification} -有多种用户识别方式: +用户身份识别有多种方式: - `IDENTIFIED WITH no_password` - `IDENTIFIED WITH plaintext_password BY 'qwerty'` @@ -44,7 +45,7 @@ CREATE USER [IF NOT EXISTS | OR REPLACE] name1 [, name2 [,...]] [ON CLUSTER clus - `IDENTIFIED WITH http SERVER 'http_server'` 或 `IDENTIFIED WITH http SERVER 'http_server' SCHEME 'basic'` - `IDENTIFIED BY 'qwerty'` -密码复杂性要求可以在 [config.xml](/operations/configuration-files) 中编辑。以下是一个示例配置,要求密码至少为 12 个字符长,并包含 1 个数字。每个密码复杂性规则要求使用正则表达式与密码匹配,并给出规则描述。 +密码复杂性要求可在 [config.xml](/operations/configuration-files) 中进行编辑。下面是一个示例配置,要求密码至少为 12 个字符长,并包含 1 个数字。每个密码复杂性规则需要一个正则表达式与密码进行匹配,并提供规则的描述。 ```xml @@ -63,7 +64,7 @@ CREATE USER [IF NOT EXISTS | OR REPLACE] name1 [, name2 [,...]] [ON CLUSTER clus :::note 在 ClickHouse Cloud 中,默认情况下,密码必须满足以下复杂性要求: -- 至少 12 个字符 +- 至少 12 个字符长 - 至少包含 1 个数字字符 - 至少包含 1 个大写字符 - 至少包含 1 个小写字符 @@ -72,29 +73,29 @@ CREATE USER [IF NOT EXISTS | OR REPLACE] name1 [, name2 [,...]] [ON CLUSTER clus ## 示例 {#examples} -1. 以下用户名为 `name1`,不需要密码——显然这并不能提供太多安全性: +1. 以下用户名是 `name1`,不需要密码——显然这并没有提供太多安全性: ```sql CREATE USER name1 NOT IDENTIFIED ``` -2. 要指定明文密码: +2. 要指定一个明文密码: ```sql CREATE USER name2 IDENTIFIED WITH plaintext_password BY 'my_password' ``` :::tip - 密码以 SQL 文本文件的形式存储在 `/var/lib/clickhouse/access` 中,因此不建议使用 `plaintext_password`。请尝试使用 `sha256_password`,如下面所示... + 密码存储在 `/var/lib/clickhouse/access` 中的 SQL 文本文件中,因此使用 `plaintext_password` 不是一个好主意。请尝试使用 `sha256_password`,如下所示... ::: -3. 最常见的选项是使用使用 SHA-256 哈希的密码。当你指定 `IDENTIFIED WITH sha256_password` 时,ClickHouse 将为你哈希密码。例如: +3. 最常用的选项是使用一个以 SHA-256 哈希的密码。当您指定 `IDENTIFIED WITH sha256_password` 时,ClickHouse 将为您哈希密码。例如: ```sql CREATE USER name3 IDENTIFIED WITH sha256_password BY 'my_password' ``` - 现在 `name3` 用户可以使用 `my_password` 登录,但密码以上述哈希值存储。以下 SQL 文件在 `/var/lib/clickhouse/access` 中创建,并在服务器启动时执行: + 当前 `name3` 用户可以使用 `my_password` 登录,但密码存储为上述哈希值。以下 SQL 文件已在 `/var/lib/clickhouse/access` 中创建并在服务器启动时执行: ```bash /var/lib/clickhouse/access $ cat 3843f510-6ebd-a52d-72ac-e021686d8a93.sql @@ -102,10 +103,10 @@ ATTACH USER name3 IDENTIFIED WITH sha256_hash BY '0C268556C1680BEF0640AAC1E71875 ``` :::tip - 如果你已经为某个用户名创建了哈希值和相应的盐值,则可以使用 `IDENTIFIED WITH sha256_hash BY 'hash'` 或 `IDENTIFIED WITH sha256_hash BY 'hash' SALT 'salt'`。对于使用 `SALT` 的 `sha256_hash` 识别 - 哈希必须从 'password' 和 'salt' 的连接中计算得出。 + 如果您已经为用户名创建了哈希值和相应的盐值,则可以使用 `IDENTIFIED WITH sha256_hash BY 'hash'` 或 `IDENTIFIED WITH sha256_hash BY 'hash' SALT 'salt'`。对于使用 `SALT` 的 `sha256_hash` 身份验证——哈希必须是从‘password’和‘salt’的串联计算得出的。 ::: -4. `double_sha1_password` 通常不需要,但在与需要它的客户端工作时十分方便(例如 MySQL 接口): +4. `double_sha1_password` 通常不需要,但在处理需要此功能的客户端(如 MySQL 接口)时,这一点很方便: ```sql CREATE USER name4 IDENTIFIED WITH double_sha1_password BY 'my_password' @@ -117,19 +118,26 @@ CREATE USER name4 IDENTIFIED WITH double_sha1_password BY 'my_password' CREATE USER name4 IDENTIFIED WITH double_sha1_hash BY 'CCD3A959D6A004B9C3807B728BC2E55B67E10518' ``` -5. `bcrypt_password` 是存储密码的最安全选项。它使用 [bcrypt](https://en.wikipedia.org/wiki/Bcrypt) 算法,即使密码哈希被泄露,也能抵御暴力破解攻击。 +5. `bcrypt_password` 是存储密码的最安全选项。它使用 [bcrypt](https://en.wikipedia.org/wiki/Bcrypt) 算法,在密码哈希被破解的情况下仍然能抵御暴力攻击。 ```sql CREATE USER name5 IDENTIFIED WITH bcrypt_password BY 'my_password' ``` - 通过这种方法,密码的长度限制为 72 个字符。bcrypt 工作因子参数,定义了计算哈希和验证密码所需的计算和时间,可以在服务器配置中修改: + 此方法的密码长度限制为 72 个字符。 + bcrypt 的工作因子参数,定义计算哈希和验证密码所需的计算量和时间,可以在服务器配置中进行修改: ```xml 12 ``` - 工作因子必须在 4 和 31 之间,默认值为 12。 + 工作因子必须在 4 到 31 之间,默认值为 12。 + + :::warning + 对于高频身份验证的应用程序, + 由于 bcrypt 在较高工作因子下的计算开销, + 请考虑其他身份验证方法。 + ::: 6. 密码类型也可以省略: @@ -143,43 +151,43 @@ CREATE USER name6 IDENTIFIED BY 'my_password' sha256_password ``` - 可用的密码类型为: `plaintext_password`, `sha256_password`, `double_sha1_password`。 + 可用的密码类型有:`plaintext_password`,`sha256_password`,`double_sha1_password`。 -7. 可以指定多个认证方法: +7. 可以指定多种身份验证方法: ```sql CREATE USER user1 IDENTIFIED WITH plaintext_password by '1', bcrypt_password by '2', plaintext_password by '3'' ``` 注意: -1. 较旧版本的 ClickHouse 可能不支持多个认证方法的语法。因此,如果 ClickHouse 服务器包含此类用户并降级到不支持该语法的版本,则该用户将变得不可用,并且某些用户相关操作将失效。为了平稳降级,必须在降级之前设置所有用户仅包含单一认证方法。或者,如果服务器在没有适当程序的情况下降级,则应删除故障用户。 -2. 出于安全原因,`no_password` 不能与其他认证方法共存。因此,只有在查询中它是唯一的认证方法时,才能指定 `no_password`。 +1. 较旧版本的 ClickHouse 可能不支持多种身份验证方法的语法。因此,如果 ClickHouse 服务器包含这样的用户并降级到不支持它的版本,这些用户将变得不可用,某些与用户相关的操作将会出现故障。为了平稳降级,必须在降级之前将所有用户设为只包含单一身份验证方法。或者,如果在没有适当程序的情况下降级了服务器,则应删除有问题的用户。 +2. 出于安全原因,`no_password` 不能与其他身份验证方法共存。因此,您只能在查询中指定 `no_password`,如果它是唯一的身份验证方法。 ## 用户主机 {#user-host} -用户主机是可以与 ClickHouse 服务器建立连接的主机。主机可以通过以下方式在 `HOST` 查询部分中指定: +用户主机是可以与 ClickHouse 服务器建立连接的主机。主机可以在 `HOST` 查询部分以以下方式指定: -- `HOST IP 'ip_address_or_subnetwork'` — 用户只能从指定的 IP 地址或 [子网络](https://en.wikipedia.org/wiki/Subnetwork) 连接到 ClickHouse 服务器。示例:`HOST IP '192.168.0.0/16'`,`HOST IP '2001:DB8::/32'`。在生产环境中,仅指定 `HOST IP` 元素(IP 地址及其掩码),因为使用 `host` 和 `host_regexp` 可能导致额外延迟。 +- `HOST IP 'ip_address_or_subnetwork'` — 用户只能从指定的 IP 地址或 [子网](https://en.wikipedia.org/wiki/Subnetwork) 连接到 ClickHouse 服务器。例如:`HOST IP '192.168.0.0/16'`,`HOST IP '2001:DB8::/32'`。在生产中,只应指定 `HOST IP` 元素(IP 地址及其掩码),因为使用 `host` 和 `host_regexp` 可能会造成额外的延迟。 - `HOST ANY` — 用户可以从任何位置连接。这是默认选项。 -- `HOST LOCAL` — 用户只能本地连接。 +- `HOST LOCAL` — 用户只能在本地连接。 - `HOST NAME 'fqdn'` — 用户主机可以指定为 FQDN。例如,`HOST NAME 'mysite.com'`。 -- `HOST REGEXP 'regexp'` — 指定用户主机时可以使用 [pcre](http://www.pcre.org/) 正则表达式。例如,`HOST REGEXP '.*\.mysite\.com'`。 -- `HOST LIKE 'template'` — 允许使用 [LIKE](/sql-reference/functions/string-search-functions#like) 操作符来过滤用户主机。例如,`HOST LIKE '%'` 等同于 `HOST ANY`,`HOST LIKE '%.mysite.com'` 过滤所有在 `mysite.com` 域中的主机。 +- `HOST REGEXP 'regexp'` — 在指定用户主机时,可以使用 [pcre](http://www.pcre.org/) 正则表达式。例如,`HOST REGEXP '.*\.mysite\.com'`。 +- `HOST LIKE 'template'` — 允许您使用 [LIKE](/sql-reference/functions/string-search-functions#like) 运算符来过滤用户主机。例如,`HOST LIKE '%'` 等同于 `HOST ANY`,`HOST LIKE '%.mysite.com'` 过滤所有在 `mysite.com` 域中的主机。 -另一种指定主机的方法是使用 `@` 语法跟随用户名。示例: +指定主机的另一种方法是使用 `@` 语法跟在用户名后面。例如: -- `CREATE USER mira@'127.0.0.1'` — 相当于 `HOST IP` 语法。 -- `CREATE USER mira@'localhost'` — 相当于 `HOST LOCAL` 语法。 -- `CREATE USER mira@'192.168.%.%'` — 相当于 `HOST LIKE` 语法。 +- `CREATE USER mira@'127.0.0.1'` — 等同于 `HOST IP` 语法。 +- `CREATE USER mira@'localhost'` — 等同于 `HOST LOCAL` 语法。 +- `CREATE USER mira@'192.168.%.%'` — 等同于 `HOST LIKE` 语法。 :::tip -ClickHouse 将 `user_name@'address'` 视为一个整体用户名。因此,从技术上讲,你可以创建多个具有相同 `user_name` 的用户,并在 `@` 后面使用不同的构造。然而,我们不建议这样做。 +ClickHouse 将 `user_name@'address'` 作为一个整体用户名。因此,技术上您可以创建多个具有相同 `user_name` 和不同 `@` 后构造的用户。然而,我们不推荐这样做。 ::: ## 有效直到子句 {#valid-until-clause} -允许你指定认证方法的到期日期,及可选的时间。它接受一个字符串作为参数。建议使用 `YYYY-MM-DD [hh:mm:ss] [timezone]` 格式表示日期和时间。默认情况下,该参数等于 `'infinity'`。 -`VALID UNTIL` 子句只能与认证方法一起指定,除非查询中未指定任何认证方法。在这种情况下,`VALID UNTIL` 子句将应用于所有现有的认证方法。 +允许您指定身份验证方法的到期日期,并可选择性地指定时间。它接受一个字符串作为参数。推荐使用 `YYYY-MM-DD [hh:mm:ss] [timezone]` 格式进行日期时间。默认情况下,此参数等于 `'infinity'`。 +`VALID UNTIL` 子句只能与身份验证方法一起指定,除非查询中未指定任何身份验证方法。在这种情况下,`VALID UNTIL` 子句将应用于所有现有身份验证方法。 示例: @@ -191,47 +199,54 @@ ClickHouse 将 `user_name@'address'` 视为一个整体用户名。因此,从 ## 授权人子句 {#grantees-clause} -指定允许从此用户接收 [特权](../../../sql-reference/statements/grant.md#privileges) 的用户或角色,条件是该用户也获得了所需的访问权限与 [GRANT OPTION](../../../sql-reference/statements/grant.md#granting-privilege-syntax)。`GRANTEES` 子句的选项: +指定可以从该用户获得 [权限](../../../sql-reference/statements/grant.md#privileges) 的用户或角色,前提是该用户也具有所有必需的访问权限,并附加 [GRANT OPTION](../../../sql-reference/statements/grant.md#granting-privilege-syntax)。`GRANTEES` 子句的选项: -- `user` — 指定此用户可以授予特权的用户。 -- `role` — 指定此用户可以授予特权的角色。 -- `ANY` — 此用户可以向任何人授予特权。这是默认设置。 -- `NONE` — 此用户无法授予特权。 +- `user` — 指定该用户可以授予权限的用户。 +- `role` — 指定该用户可以授予权限的角色。 +- `ANY` — 该用户可以向任何人授予权限。这是默认设置。 +- `NONE` — 该用户无法授予权限。 -你可以通过使用 `EXCEPT` 表达式排除任何用户或角色。例如,`CREATE USER user1 GRANTEES ANY EXCEPT user2`。这意味着如果 `user1` 具有某些通过 `GRANT OPTION` 授予的特权,它将能够将这些特权授予除 `user2` 以外的任何人。 +您可以通过使用 `EXCEPT` 表达式排除任何用户或角色。例如,`CREATE USER user1 GRANTEES ANY EXCEPT user2`。这意味着如果 `user1` 拥有某些授予了 `GRANT OPTION` 的权限,它将能够向任何人授予这些权限,除了 `user2`。 ## 示例 {#examples-1} -创建用户账号 `mira`,并用密码 `qwerty` 保护: +创建用户账户 `mira`,密码为 `qwerty`: ```sql CREATE USER mira HOST IP '127.0.0.1' IDENTIFIED WITH sha256_password BY 'qwerty'; ``` -`mira` 应该在 ClickHouse 服务器运行的主机上启动客户端应用程序。 +`mira` 应在 ClickHouse 服务器运行的主机上启动客户端应用程序。 -创建用户账号 `john`,并为其分配角色并使这些角色成为默认角色: +创建用户账户 `john`,并为其分配角色,使这些角色成为默认角色: ```sql CREATE USER john DEFAULT ROLE role1, role2; ``` -创建用户账号 `john`,并使他所有未来的角色成为默认角色: +创建用户账户 `john`,使他所有未来的角色成为默认角色: ```sql CREATE USER john DEFAULT ROLE ALL; ``` -当将某个角色将来分配给 `john` 时,它将自动成为默认角色。 +当将某些角色在未来分配给 `john` 时,它将自动成为默认。 -创建用户账号 `john`,并使他所有未来的角色成为默认角色,除 `role1` 和 `role2`: +创建用户账户 `john`,使他所有未来的角色成为默认角色,除了 `role1` 和 `role2`: ```sql CREATE USER john DEFAULT ROLE ALL EXCEPT role1, role2; ``` -创建用户账号 `john`,并允许他将自己的特权授权给 `jack` 用户: +创建用户账户 `john`,并允许他将其权限授予 `jack` 账户的用户: ```sql CREATE USER john GRANTEES jack; ``` + +使用查询参数创建用户账户 `john`: + +```sql +SET param_user=john; +CREATE USER {user:Identifier}; +``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/user.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/user.md.hash index f5e1aa52c8f..577791b24d6 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/user.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/user.md.hash @@ -1 +1 @@ -819d15bbbc2382ea +19f5e9bdb4374960 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/view.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/view.md index 5c748dcafaa..0fea7bf947d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/view.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/view.md @@ -4,6 +4,7 @@ 'sidebar_position': 37 'slug': '/sql-reference/statements/create/view' 'title': 'CREATE VIEW' +'doc_type': 'reference' --- import ExperimentalBadge from '@theme/badges/ExperimentalBadge'; @@ -11,11 +12,12 @@ import DeprecatedBadge from '@theme/badges/DeprecatedBadge'; import CloudNotSupportedBadge from '@theme/badges/CloudNotSupportedBadge'; -# CREATE VIEW -创建一个新的视图。视图可以是 [普通视图](#normal-view)、[物化视图](#materialized-view)、[可刷新物化视图](#refreshable-materialized-view) 和 [窗口视图](/sql-reference/statements/create/view#window-view)(可刷新物化视图和窗口视图是实验性功能)。 +# 创建视图 -## Normal View {#normal-view} +创建一个新的视图。视图可以是 [普通](#normal-view)、[物化](#materialized-view)、[可刷新的物化](#refreshable-materialized-view) 和 [窗口](/sql-reference/statements/create/view#window-view)。 + +## 普通视图 {#normal-view} 语法: @@ -26,9 +28,9 @@ AS SELECT ... [COMMENT 'comment'] ``` -普通视图不存储任何数据。每次访问时,它仅从另一个表中读取数据。换句话说,普通视图不过是一个保存的查询。当从视图中读取数据时,这个保存的查询作为 [FROM](../../../sql-reference/statements/select/from.md) 子查询使用。 +普通视图不存储任何数据。它们仅在每次访问时执行从另一个表的读取。换句话说,普通视图只是一个保存的查询。当从视图中读取数据时,这个保存的查询作为子查询在 [FROM](../../../sql-reference/statements/select/from.md) 子句中使用。 -作为示例,假设您创建了一个视图: +例如,假设您创建了一个视图: ```sql CREATE VIEW view AS SELECT ... @@ -40,26 +42,26 @@ CREATE VIEW view AS SELECT ... SELECT a, b, c FROM view ``` -这个查询与使用子查询是完全等效的: +这个查询完全等价于使用子查询: ```sql SELECT a, b, c FROM (SELECT ...) ``` -## Parameterized View {#parameterized-view} +## 带参数视图 {#parameterized-view} -参数化视图与普通视图类似,但可以使用未立即解析的参数创建。这些视图可以与表函数一起使用,表函数将视图的名称指定为函数名称,参数值作为参数。 +带参数视图类似于普通视图,但可以创建时带有未立即解析的参数。这些视图可以与表函数一起使用,其指定视图名称作为函数名称,参数值作为其参数。 ```sql CREATE VIEW view AS SELECT * FROM TABLE WHERE Column1={column1:datatype1} and Column2={column2:datatype2} ... ``` -上述创建了一个可以通过替换参数作为表函数使用的视图,如下所示。 +上述创建了一个可以通过如下面所示的方式替换参数的表函数的视图。 ```sql SELECT * FROM view(column1=value1, column2=value2 ...) ``` -## Materialized View {#materialized-view} +## 物化视图 {#materialized-view} ```sql CREATE MATERIALIZED VIEW [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster_name] [TO[db.]name [(columns)]] [ENGINE = engine] [POPULATE] @@ -69,80 +71,80 @@ AS SELECT ... ``` :::tip -这里有关于使用 [物化视图](/guides/developer/cascading-materialized-views.md) 的逐步指南。 +这是使用 [物化视图](/guides/developer/cascading-materialized-views.md) 的逐步指导。 ::: -物化视图存储由相应的 [SELECT](../../../sql-reference/statements/select/index.md) 查询转换的数据。 +物化视图存储通过相应的 [SELECT](../../../sql-reference/statements/select/index.md) 查询转换的数据。 -创建物化视图时,如果未使用 `TO [db].[table]`,则必须指定 `ENGINE`,即用于存储数据的表引擎。 +在没有 `TO [db].[table]` 的情况下创建物化视图时,您必须指定 `ENGINE` – 用于存储数据的表引擎。 -创建物化视图时使用 `TO [db].[table]`,则不能同时使用 `POPULATE`。 +在使用 `TO [db].[table]` 创建物化视图时,您不能同时使用 `POPULATE`。 -物化视图的实现如下:当向 `SELECT` 中指定的表插入数据时,部分插入的数据会通过这个 `SELECT` 查询进行转换,结果插入到视图中。 +物化视图的实现方式如下:当向在 `SELECT` 中指定的表插入数据时,部分插入的数据通过此 `SELECT` 查询转换,并将结果插入视图。 :::note -ClickHouse 中的物化视图在插入目标表时使用 **列名** 而不是列顺序。如果某些列名在 `SELECT` 查询结果中不存在,ClickHouse 会使用默认值,即使该列不是 [Nullable](../../data-types/nullable.md)。安全的做法是在使用物化视图时为每一列添加别名。 +ClickHouse 中的物化视图使用 **列名** 而不是列的顺序在目标表中插入数据。如果在 `SELECT` 查询结果中没有某些列名,ClickHouse 将使用默认值,即使该列不是 [Nullable](../../data-types/nullable.md)。在使用物化视图时,安全的做法是为每个列添加别名。 -ClickHouse 中的物化视图的实现更像是插入触发器。如果视图查询中有某些聚合,它仅应用于新插入数据的批次。对源表的任何现有数据的更改(如更新、删除、删除分区等)不会改变物化视图。 +ClickHouse 中的物化视图更像是插入触发器的实现。如果视图查询中有某些聚合,它仅应用于批量新插入的数据。对源表的现有数据的任何更改(例如更新、删除、丢弃分区等)不会改变物化视图。 -ClickHouse 中的物化视图在出现错误时没有确定性行为。这意味着已经写入的块会保留在目标表中,但错误之后的所有块将不会。 +ClickHouse 中的物化视图在发生错误时没有确定性行为。这意味着已经写入的块将在目标表中保留,但错误后的所有块将不保留。 -默认情况下,如果推送到某个视图失败,则 INSERT 查询也会失败,可能导致某些块未写入目标表。这可以通过 `materialized_views_ignore_errors` 设置来改变(您应该为 `INSERT` 查询设置此选项),如果将 `materialized_views_ignore_errors=true`,则在推送到视图时的任何错误将被忽略,所有块将被写入到目标表。 +默认情况下,如果推送到某个视图失败,则 INSERT 查询也将失败,某些块可能不会写入目标表。可以通过使用 `materialized_views_ignore_errors` 设置来更改此行为(应为 `INSERT` 查询设置该选项),如果您设置 `materialized_views_ignore_errors=true`,那么在向视图推送时的任何错误将被忽略,所有块将被写入目标表。 -还要注意,`materialized_views_ignore_errors` 默认值为 `true`,适用于 `system.*_log` 表。 +还要注意,`materialized_views_ignore_errors` 在 `system.*_log` 表中默认设置为 `true`。 ::: -如果您指定了 `POPULATE`,则在创建视图时,现有表数据将插入视图,就像执行 `CREATE TABLE ... AS SELECT ...` 一样。否则,查询仅包含在创建视图后插入到表中的数据。我们 **不推荐** 使用 `POPULATE`,因为在创建视图期间插入到表中的数据将不会插入其中。 +如果指定了 `POPULATE`,则在创建视图时,现有表数据将插入到视图中,类似于执行 `CREATE TABLE ... AS SELECT ...`。否则,查询仅包含在创建视图后插入到表中的数据。我们 **不推荐** 使用 `POPULATE`,因为在创建视图期间插入到表中的数据将不会插入该视图。 :::note -由于 `POPULATE` 像 `CREATE TABLE ... AS SELECT ...` 一样工作,它有一些限制: -- 在复制数据库中不受支持 -- 在 ClickHouse Cloud 中不受支持 +由于 `POPULATE` 的作用类似于 `CREATE TABLE ... AS SELECT ...`,它有以下限制: +- 不支持复制数据库 +- 不支持 ClickHouse 云 可以使用单独的 `INSERT ... SELECT`。 ::: -`SELECT` 查询可以包含 `DISTINCT`、`GROUP BY`、`ORDER BY`、`LIMIT`。请注意,相应的转换在插入数据的每个块上是独立执行的。例如,如果设置了 `GROUP BY`,数据在插入期间被聚合,但仅在单个插入数据包内。数据不会进一步聚合。例外情况是使用能够独立执行数据聚合的 `ENGINE`,例如 `SummingMergeTree`。 +`SELECT` 查询可以包含 `DISTINCT`、`GROUP BY`、`ORDER BY`、`LIMIT`。注意,相应的转换在插入的每个块上独立执行。例如,如果设置了 `GROUP BY`,则数据在插入过程中进行聚合,但仅在单个插入数据包中。数据不会进一步聚合。例外情况是使用独立执行数据聚合的 `ENGINE`,例如 `SummingMergeTree`。 -对物化视图执行的 [ALTER](/sql-reference/statements/alter/view.md) 查询有一些限制,例如,您不能更新 `SELECT` 查询,因此这可能会带来不便。如果物化视图使用构造 `TO [db.]name`,您可以 `DETACH` 该视图,在目标表上运行 `ALTER`,然后 `ATTACH` 先前分离的(`DETACH`)视图。 +对物化视图执行 [ALTER](/sql-reference/statements/alter/view.md) 查询时有限制,例如,不能更新 `SELECT` 查询,因此这可能不方便。如果物化视图使用了 `TO [db.]name` 的构造,则可以 `DETACH` 视图,为目标表运行 `ALTER`,然后 `ATTACH` 先前分离的 (`DETACH`) 视图。 -请注意,物化视图受 [optimize_on_insert](/operations/settings/settings#optimize_on_insert) 设置的影响。在插入到视图之前,数据会合并。 +请注意,物化视图受 [optimize_on_insert](/operations/settings/settings#optimize_on_insert) 设置的影响。数据在插入视图之前会被合并。 -视图看起来和普通表一样。例如,它们在 `SHOW TABLES` 查询的结果中列出。 +视图看起来与普通表相同。例如,它们在 `SHOW TABLES` 查询的结果中列出。 -要删除一个视图,请使用 [DROP VIEW](../../../sql-reference/statements/drop.md#drop-view)。虽然 `DROP TABLE` 同样适用于视图。 +要删除视图,请使用 [DROP VIEW](../../../sql-reference/statements/drop.md#drop-view)。尽管 `DROP TABLE` 对视图也有效。 -## SQL security {#sql_security} +## SQL 安全性 {#sql_security} `DEFINER` 和 `SQL SECURITY` 允许您指定执行视图底层查询时使用哪个 ClickHouse 用户。 `SQL SECURITY` 有三个合法值:`DEFINER`、`INVOKER` 或 `NONE`。您可以在 `DEFINER` 子句中指定任何现有用户或 `CURRENT_USER`。 -下表将解释每个用户选择视图所需的权限。 -请注意,不管 SQL 安全选项如何,在每种情况下,依然需要有 `GRANT SELECT ON ` 才能从中读取。 +以下表格将解释每个用户选择视图所需的权限。 +请注意,无论 SQL 安全性选项如何,在每种情况下仍然需要有 `GRANT SELECT ON ` 才能读取。 -| SQL 安全选项 | 视图 | 物化视图 | -|------------------|-----------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------| -| `DEFINER alice` | `alice` 必须对视图的源表拥有 `SELECT` 授权。 | `alice` 必须对视图的源表拥有 `SELECT` 授权,并对视图的目标表拥有 `INSERT` 授权。 | -| `INVOKER` | 用户必须对视图的源表拥有 `SELECT` 授权。 | `SQL SECURITY INVOKER` 不能为物化视图指定。 | -| `NONE` | - | - | +| SQL 安全性选项 | 视图 | 物化视图 | +|-------------------|-----------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------| +| `DEFINER alice` | `alice` 必须对视图的源表具有 `SELECT` 授权。 | `alice` 必须对视图的源表具有 `SELECT` 授权,以及对视图目标表具有 `INSERT` 授权。 | +| `INVOKER` | 用户必须对视图的源表具有 `SELECT` 授权。 | `SQL SECURITY INVOKER` 不能为物化视图指定。 | +| `NONE` | - | - | :::note -`SQL SECURITY NONE` 是一个已弃用的选项。任何拥有创建视图权限的用户都可以执行任何任意查询。 -因此,必须拥有 `GRANT ALLOW SQL SECURITY NONE TO ` 才能使用此选项创建视图。 +`SQL SECURITY NONE` 是一个已弃用的选项。任何具有使用 `SQL SECURITY NONE` 创建视图的权限的用户都能够执行任何任意查询。 +因此,要求有 `GRANT ALLOW SQL SECURITY NONE TO ` 才能创建具有此选项的视图。 ::: -如果未指定 `DEFINER`/`SQL SECURITY`,则使用默认值: -- `SQL SECURITY`:普通视图为 `INVOKER`,物化视图为 `DEFINER`([可通过设置配置](../../../operations/settings/settings.md#default_normal_view_sql_security)) -- `DEFINER`:`CURRENT_USER` ([可通过设置配置](../../../operations/settings/settings.md#default_view_definer)) +如果未指定 `DEFINER` / `SQL SECURITY`,则使用默认值: +- `SQL SECURITY`:对于普通视图为 `INVOKER`,对于物化视图为 `DEFINER`([通过设置可配置](../../../operations/settings/settings.md#default_normal_view_sql_security)) +- `DEFINER`:`CURRENT_USER`([通过设置可配置](../../../operations/settings/settings.md#default_view_definer)) -如果视图被附加且未指定 `DEFINER`/`SQL SECURITY`,则默认为物化视图的 `SQL SECURITY NONE` 和普通视图的 `SQL SECURITY INVOKER`。 +如果视图在未指定 `DEFINER` / `SQL SECURITY` 的情况下被附加,则默认值为物化视图的 `SQL SECURITY NONE` 和普通视图的 `SQL SECURITY INVOKER`。 要更改现有视图的 SQL 安全性,请使用 ```sql ALTER TABLE MODIFY SQL SECURITY { DEFINER | INVOKER | NONE } [DEFINER = { user | CURRENT_USER }] ``` -### Examples {#examples} +### 示例 {#examples} ```sql CREATE VIEW test_view DEFINER = alice SQL SECURITY DEFINER @@ -155,15 +157,15 @@ SQL SECURITY INVOKER AS SELECT ... ``` -## Live View {#live-view} +## 实时视图 {#live-view} 此功能已弃用,并将在未来删除。 -为了方便您,旧文档位于 [此处](https://pastila.nl/?00f32652/fdf07272a7b54bda7e13b919264e449f.md) +为了您的方便,旧文档位于 [这里](https://pastila.nl/?00f32652/fdf07272a7b54bda7e13b919264e449f.md) -## Refreshable Materialized View {#refreshable-materialized-view} +## 可刷新的物化视图 {#refreshable-materialized-view} ```sql CREATE MATERIALIZED VIEW [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] @@ -178,24 +180,22 @@ REFRESH EVERY|AFTER interval [OFFSET interval] AS SELECT ... [COMMENT 'comment'] ``` -其中 `interval` 是一系列简单间隔: +其中 `interval` 是一系列简单的时间间隔: ```sql number SECOND|MINUTE|HOUR|DAY|WEEK|MONTH|YEAR ``` -定期运行相应的查询并将其结果存储在表中。 - * 如果查询指示 `APPEND`,每次刷新都会向表中插入行,而不会删除现有行。插入不是原子的,就像常规的 INSERT SELECT。 - * 否则每次刷新原子性地替换表的先前内容。 - -与常规不可刷新的物化视图的区别: - * 无插入触发器。即,当新数据插入到 `SELECT` 中指定的表时,它不会自动推送到可刷新的物化视图中。定期刷新将运行整个查询。 - * 对 SELECT 查询没有限制。允许使用表函数(例如 `url()`)、视图、UNION、JOIN 等。 +定期运行相应的查询并将结果存储在表中。 +* 如果查询中说 `APPEND`,则每次刷新将向表中插入行,而不会删除现有行。插入不是原子性的,类似于常规的 INSERT SELECT。 +* 否则,每次刷新会原子性地替换表的先前内容。 +与常规的不可刷新物化视图的区别: +* 没有插入触发器。即当新数据插入于 SELECT 指定的表中时,它不会自动推送到可刷新的物化视图。定期刷新的运行将整个查询运行。* SELECT 查询没有限制。表函数(例如 `url()`)、视图、UNION、JOIN 均被允许。 :::note -查询的 `REFRESH ... SETTINGS` 部分中的设置是刷新设置(例如 `refresh_retries`),与常规设置(例如 `max_threads`)不同。常规设置可以通过在查询末尾使用 `SETTINGS` 指定。 +查询中 `REFRESH ... SETTINGS` 部分的设置是刷新设置(例如 `refresh_retries`),与常规设置(例如 `max_threads`)不同。常规设置可以在查询末尾使用 `SETTINGS` 指定。 ::: -### Refresh Schedule {#refresh-schedule} +### 刷新计划 {#refresh-schedule} 示例刷新计划: ```sql @@ -217,67 +217,66 @@ REFRESH EVERY 5 MONTHS -- every 5 months, different months each year (as 12 is n REFRESH EVERY 1 DAY OFFSET 2 HOUR RANDOMIZE FOR 1 HOUR -- every day at random time between 01:30 and 02:30 ``` -在给定的视图中,每次最多只能运行一个刷新。例如,如果具有 `REFRESH EVERY 1 MINUTE` 的视图需要 2 分钟才能刷新,它将每 2 分钟刷新一次。如果之后变得更快并开始在 10 秒内刷新,它将恢复为每分钟刷新一次。(特别地,它不会每 10 秒刷新一次以赶上错过的刷新 - 并没有这样的积压。) +一次最多只能运行一个刷新,针对给定视图。例如,如果具有 `REFRESH EVERY 1 MINUTE` 的视图需要 2 分钟刷新,它只会每 2 分钟刷新一次。如果刷新速度更快并开始在 10 秒内刷新的话,它将恢复到每分钟刷新一次。(特别是,它不会每 10 秒刷新一次以追赶错过的刷新 - 没有这样的积压。) -此外,在创建物化视图后,会立即启动刷新,除非在 `CREATE` 查询中指定了 `EMPTY`。如果指定了 `EMPTY`,则第一次刷新将按照计划进行。 +此外,在创建物化视图后,刷新会立即启动,除非在 `CREATE` 查询中指定了 `EMPTY`。如果指定了 `EMPTY`,第一次刷新会根据计划进行。 -### In Replicated DB {#in-replicated-db} +### 在复制数据库中 {#in-replicated-db} -如果可刷新的物化视图位于 [复制数据库](../../../engines/database-engines/replicated.md) 中,则副本之间协调,以便每次计划时间仅有一个副本执行刷新。需要 [ReplicatedMergeTree](../../../engines/table-engines/mergetree-family/replication.md) 表引擎,以便所有副本都能看到刷新的数据。 +如果可刷新的物化视图位于 [复制数据库](../../../engines/database-engines/replicated.md) 中,副本之间相互协调,以便每次调度时只有一个副本执行刷新。要求使用 [ReplicatedMergeTree](../../../engines/table-engines/mergetree-family/replication.md) 表引擎,以便所有副本都能看到由刷新生成的数据。 -在 `APPEND` 模式下,可以使用 `SETTINGS all_replicas = 1` 禁用协调。这使副本独立进行刷新。在这种情况下,不需要 ReplicatedMergeTree。 +在 `APPEND` 模式下,可以使用 `SETTINGS all_replicas = 1` 禁用协调。这使得副本独立执行刷新。在这种情况下,无需使用 ReplicatedMergeTree。 -在非 `APPEND` 模式下,仅支持协调刷新。对于未协调的情况,请使用 `Atomic` 数据库,并使用 `CREATE ... ON CLUSTER` 查询在所有副本上创建可刷新的物化视图。 +在非 `APPEND` 模式下,仅支持协调刷新。对于不协调的情况,使用 `Atomic` 数据库和 `CREATE ... ON CLUSTER` 查询在所有副本上创建可刷新的物化视图。 -协调是通过 Keeper 完成的。znode 路径通过 [default_replica_path](../../../operations/server-configuration-parameters/settings.md#default_replica_path) 服务器设置确定。 +协调通过 Keeper 完成。znode 路径由 [default_replica_path](../../../operations/server-configuration-parameters/settings.md#default_replica_path) 服务器设置确定。 -### Dependencies {#refresh-dependencies} +### 依赖 {#refresh-dependencies} -`DEPENDS ON` 同步不同表的刷新。例如,假设有两个可刷新的物化视图的链: +`DEPENDS ON` 同步不同表的刷新。例如,假设有一链两个可刷新的物化视图: ```sql CREATE MATERIALIZED VIEW source REFRESH EVERY 1 DAY AS SELECT * FROM url(...) CREATE MATERIALIZED VIEW destination REFRESH EVERY 1 DAY AS SELECT ... FROM source ``` -如果没有 `DEPENDS ON`,则两个视图都将在午夜启动刷新,通常 `destination` 将看到 `source` 中昨天的数据。如果我们添加依赖关系: +没有 `DEPENDS ON`,两个视图将在午夜开始刷新,`destination` 通常会看到 `source` 中昨天的数据。如果我们添加依赖: ```sql CREATE MATERIALIZED VIEW destination REFRESH EVERY 1 DAY DEPENDS ON source AS SELECT ... FROM source ``` -那么 `destination` 的刷新只会在 `source` 的刷新在当天完成后开始,从而使得 `destination` 基于新鲜的数据。 +然后 `destination` 的刷新将仅在 `source` 的刷新在那天完成后开始,因此 `destination` 将基于新鲜的数据。 -另外,可以通过以下方式获得相同的结果: +另外,可以通过使用以下方式实现相同的结果: ```sql CREATE MATERIALIZED VIEW destination REFRESH AFTER 1 HOUR DEPENDS ON source AS SELECT ... FROM source ``` -其中 `1 HOUR` 可以是任何少于 `source` 刷新周期的持续时间。依赖的表不会比其任何依赖项刷新得更频繁。这是一种有效的设置可刷新的视图链的方法,而无需多次指定实际刷新周期。 - -还有更多的例子: - * `REFRESH EVERY 1 DAY OFFSET 10 MINUTE`(`destination`)依赖于 `REFRESH EVERY 1 DAY`(`source`)
- 如果 `source` 刷新需要超过 10 分钟,则 `destination` 将等待它。 - * `REFRESH EVERY 1 DAY OFFSET 1 HOUR` 依赖于 `REFRESH EVERY 1 DAY OFFSET 23 HOUR`
- 与上述相似,即使相应的刷新发生在不同的日历日。 - `destination` 在 X+1 日的刷新将等待 X 日的 `source` 刷新(如果超过 2 小时)。 - * `REFRESH EVERY 2 HOUR` 依赖于 `REFRESH EVERY 1 HOUR`
- 2 小时刷新发生在每个小时的 1 小时刷新之后,例如在午夜 - 刷新之后,然后在凌晨 2 点刷新等。 - * `REFRESH EVERY 1 MINUTE` 依赖于 `REFRESH EVERY 2 HOUR`
- `REFRESH AFTER 1 MINUTE` 依赖于 `REFRESH EVERY 2 HOUR`
- `REFRESH AFTER 1 MINUTE` 依赖于 `REFRESH AFTER 2 HOUR`
- `destination` 每次在每个 `source` 刷新后刷新一次,即每 2 小时刷新一次。`1 MINUTE` 实际上被忽略。 - * `REFRESH AFTER 1 HOUR` 依赖于 `REFRESH AFTER 1 HOUR`
- 当前不推荐这种做法。 +其中 `1 HOUR` 可以是任何少于 `source` 刷新周期的持续时间。依赖表的刷新频率不会超过其依赖项。这是在不多次指定实际刷新周期的情况下设置可刷新的视图链的有效方式。 + +再举几个例子: +* `REFRESH EVERY 1 DAY OFFSET 10 MINUTE`(`destination`)依赖于 `REFRESH EVERY 1 DAY`(`source`)
+ 如果 `source` 刷新耗时超过 10 分钟,则 `destination` 将等待它。 +* `REFRESH EVERY 1 DAY OFFSET 1 HOUR` 依赖于 `REFRESH EVERY 1 DAY OFFSET 23 HOUR`
+ 类似于上面,尽管相应的刷新发生在不同的日历天。 + `destination` 在第 X+1 天的刷新将等待 `source` 在第 X 天的刷新(如果需要超过 2 小时)。 +* `REFRESH EVERY 2 HOUR` 依赖于 `REFRESH EVERY 1 HOUR`
+ 2 小时的刷新会在每小时的 1 小时刷新之后发生,例如在午夜刷新之后,然后在凌晨 2 点刷新等。 +* `REFRESH EVERY 1 MINUTE` 依赖于 `REFRESH EVERY 2 HOUR`
+ `REFRESH AFTER 1 MINUTE` 依赖于 `REFRESH EVERY 2 HOUR`
+ `REFRESH AFTER 1 MINUTE` 依赖于 `REFRESH AFTER 2 HOUR`
+ `destination` 在每次 `source` 刷新后刷新一次,即每 2 小时刷新一次。`1 MINUTE` 实际上被忽略。 +* `REFRESH AFTER 1 HOUR` 依赖于 `REFRESH AFTER 1 HOUR`
+ 目前不推荐这样做。 :::note -`DEPENDS ON` 仅适用于可刷新的物化视图。在 `DEPENDS ON` 列表中列出常规表将导致视图永远无法刷新(可以使用 `ALTER` 移除依赖)。 +`DEPENDS ON` 仅在可刷新的物化视图之间有效。在 `DEPENDS ON` 列表中列出常规表将阻止该视图刷新(依赖项可通过 `ALTER` 删除,见下文)。 ::: -### Settings {#settings} +### 设置 {#settings} 可用的刷新设置: - * `refresh_retries` - 如果刷新查询因异常而失败,则重试多少次。如果所有重试均失败,则跳到下一个计划的刷新时间。0 意味着不重试,-1 意味着无限重试。默认值:0。 - * `refresh_retry_initial_backoff_ms` - 如果 `refresh_retries` 不为零,则第一次重试之前的延迟。每个后续重试将延迟翻倍,直到 `refresh_retry_max_backoff_ms`。默认值:100 毫秒。 - * `refresh_retry_max_backoff_ms` - 刷新尝试之间延迟的指数增长的限制。默认值:60000 毫秒(1 分钟)。 +* `refresh_retries` - 如果刷新查询因异常失败,要重试多少次。如果所有重试失败,则跳到下一个调度刷新时间。0 意味着不重试,-1 意味着无限重试。默认值:0。 +* `refresh_retry_initial_backoff_ms` - 第一次重试之前的延迟,如果 `refresh_retries` 不为零。每次后续重试都会将延迟加倍,直到达到 `refresh_retry_max_backoff_ms`。默认值:100 毫秒。 +* `refresh_retry_max_backoff_ms` - 刷新尝试之间延迟的指数增长限制。默认值:60000 毫秒(1 分钟)。 -### Changing Refresh Parameters {#changing-refresh-parameters} +### 更改刷新参数 {#changing-refresh-parameters} 要更改刷新参数: ```sql @@ -285,28 +284,28 @@ ALTER TABLE [db.]name MODIFY REFRESH EVERY|AFTER ... [RANDOMIZE FOR ...] [DEPEND ``` :::note -这会一次性替换 *所有* 刷新参数:计划、依赖关系、设置和 APPEND 属性。例如,如果表具有 `DEPENDS ON`,则在不带 `DEPENDS ON` 的情况下执行 `MODIFY REFRESH` 将删除依赖项。 +这将一次替换 *所有* 刷新参数:计划、依赖关系、设置和 APPEND 状态。例如,如果表有 `DEPENDS ON`,则在不包含 `DEPENDS ON` 的情况下执行 `MODIFY REFRESH` 将删除依赖关系。 ::: -### Other operations {#other-operations} +### 其他操作 {#other-operations} -所有可刷新的物化视图的状态可在表 [`system.view_refreshes`](../../../operations/system-tables/view_refreshes.md) 中查看。特别地,它包含刷新进度(如果正在运行)、上一次和下一次刷新时间、出错时的异常消息。 +所有可刷新的物化视图的状态可在表 [`system.view_refreshes`](../../../operations/system-tables/view_refreshes.md) 中查看。特别是,它包含刷新进度(如果正在运行)、最后一次和下一次刷新时间、如果刷新失败则显示异常消息。 要手动停止、启动、触发或取消刷新,请使用 [`SYSTEM STOP|START|REFRESH|WAIT|CANCEL VIEW`](../system.md#refreshable-materialized-views)。 -要等待刷新完成,请使用 [`SYSTEM WAIT VIEW`](../system.md#refreshable-materialized-views)。特别适合在创建视图后等待初始刷新。 +要等待刷新完成,请使用 [`SYSTEM WAIT VIEW`](../system.md#refreshable-materialized-views)。特别是,有助于在创建视图后等待初次刷新。 :::note -有趣的事实:刷新查询可以从正在刷新的视图中读取,看到预刷新版本的数据。这意味着您可以实现康威的生命游戏:https://pastila.nl/?00021a4b/d6156ff819c83d490ad2dcec05676865#O0LGWTO7maUQIA4AcGUtlA== +有趣的是:刷新查询被允许从正在刷新的视图中读取,查看预刷新版本的数据。这意味着您可以实现康威的生命游戏:https://pastila.nl/?00021a4b/d6156ff819c83d490ad2dcec05676865#O0LGWTO7maUQIA4AcGUtlA== ::: -## Window View {#window-view} +## 窗口视图 {#window-view} :::info -这是一个实验性功能,未来的版本可能会以向后不兼容的方式进行更改。启用窗口视图和 `WATCH` 查询的使用,请使用 [allow_experimental_window_view](/operations/settings/settings#allow_experimental_window_view) 设置。输入命令 `set allow_experimental_window_view = 1`。 +这是一个实验性功能,可能会在未来的版本中发生向后不兼容的变化。通过 [allow_experimental_window_view](/operations/settings/settings#allow_experimental_window_view) 设置启用使用窗口视图和 `WATCH` 查询。输入命令 `set allow_experimental_window_view = 1`。 ::: ```sql @@ -316,35 +315,35 @@ GROUP BY time_window_function [COMMENT 'comment'] ``` -窗口视图可以按时间窗口聚合数据,并在窗口准备好时输出结果。它将部分聚合结果存储在一个内部(或指定的)表中,以减少延迟,并可以将处理结果推送到指定表或使用 WATCH 查询推送通知。 +窗口视图可以通过时间窗口聚合数据,并在窗口准备好时输出结果。它将部分聚合结果存储在内部(或指定)表中以减少延迟,并可以将处理结果推送到指定表或使用 WATCH 查询推送通知。 -创建窗口视图类似于创建 `MATERIALIZED VIEW`。窗口视图需要一个内部存储引擎来存储中间数据。可以使用 `INNER ENGINE` 子句指定内部存储,窗口视图将使用 `AggregatingMergeTree` 作为默认内部引擎。 +创建窗口视图类似于创建 `MATERIALIZED VIEW`。窗口视图需要一个内部存储引擎来存储中间数据。可以通过使用 `INNER ENGINE` 子句指定内部存储,窗口视图将默认使用 `AggregatingMergeTree` 作为内部引擎。 -在没有 `TO [db].[table]` 的情况下创建窗口视图时,必须指定 `ENGINE`,即用于存储数据的表引擎。 +在没有 `TO [db].[table]` 的情况下创建窗口视图时,您必须指定 `ENGINE` – 用于存储数据的表引擎。 -### Time Window Functions {#time-window-functions} +### 时间窗口函数 {#time-window-functions} [时间窗口函数](../../functions/time-window-functions.md) 用于获取记录的下限和上限窗口。窗口视图需要与时间窗口函数一起使用。 -### TIME ATTRIBUTES {#time-attributes} +### 时间属性 {#time-attributes} 窗口视图支持 **处理时间** 和 **事件时间** 处理。 -**处理时间** 使窗口视图能够根据本地机器的时间生成结果,并作为默认使用。这是时间的最直观概念,但不提供确定性。处理时间属性可以通过将时间窗口函数的 `time_attr` 设置为表列或使用 `now()` 函数来定义。以下查询创建了一个具有处理时间的窗口视图。 +**处理时间** 允许窗口视图基于本地机器的时间生成结果,默认使用。它是对时间的最简单的概念,但并不提供确定性。处理时间属性可以通过将时间窗口函数的 `time_attr` 设置为表列或使用函数 `now()` 定义。以下查询创建一个带处理时间的窗口视图。 ```sql CREATE WINDOW VIEW wv AS SELECT count(number), tumbleStart(w_id) as w_start from date GROUP BY tumble(now(), INTERVAL '5' SECOND) as w_id ``` -**事件时间** 是每个独立事件在其产生设备上发生的时间。此时间通常在生成时嵌入到记录中。事件时间处理允许在事件顺序混乱或事件延迟的情况下提供一致的结果。窗口视图通过使用 `WATERMARK` 语法支持事件时间处理。 +**事件时间** 是每个单独事件在其产生设备上发生的时间。此时间通常在生成时嵌入到记录中。事件时间处理允许在事件乱序或延迟的情况下获得一致的结果。窗口视图通过使用 `WATERMARK` 语法支持事件时间处理。 -窗口视图提供三种水位线策略: +窗口视图提供三种水印策略: -* `STRICTLY_ASCENDING`:发出到目前为止观察到的最大时间戳的水位线。时间戳小于最大时间戳的行不会被视为延迟。 -* `ASCENDING`:发出到目前为止观察到的最大时间戳减去 1 的水位线。时间戳等于或小于最大时间戳的行不会被视为延迟。 -* `BOUNDED`:WATERMARK=INTERVAL。发出水位线,即最大观察到的时间戳减去指定延迟。 +* `STRICTLY_ASCENDING`:发出迄今为止观察到的最大时间戳的水印。时间戳小于最大时间戳的行不算晚到。 +* `ASCENDING`:发出迄今为止观察到的最大时间戳减去 1 的水印。时间戳等于或小于最大时间戳的行不算晚到。 +* `BOUNDED`:WATERMARK=INTERVAL。发出水印,即最大观察到的时间戳减去指定的延迟。 -以下查询是使用 `WATERMARK` 创建窗口视图的示例: +以下查询是创建带 `WATERMARK` 的窗口视图的示例: ```sql CREATE WINDOW VIEW wv WATERMARK=STRICTLY_ASCENDING AS SELECT count(number) FROM date GROUP BY tumble(timestamp, INTERVAL '5' SECOND); @@ -352,19 +351,19 @@ CREATE WINDOW VIEW wv WATERMARK=ASCENDING AS SELECT count(number) FROM date GROU CREATE WINDOW VIEW wv WATERMARK=INTERVAL '3' SECOND AS SELECT count(number) FROM date GROUP BY tumble(timestamp, INTERVAL '5' SECOND); ``` -默认情况下,当水位线到达时窗口将被触发,已到达水位线的元素将被丢弃。窗口视图通过设置 `ALLOWED_LATENESS=INTERVAL` 支持延迟事件处理。延迟处理的示例如下: +默认情况下,当水印到达时,窗口将被触发,滞后水印到达的元素将被丢弃。窗口视图通过设置 `ALLOWED_LATENESS=INTERVAL` 支持滞后事件处理。滞后处理的一个示例是: ```sql CREATE WINDOW VIEW test.wv TO test.dst WATERMARK=ASCENDING ALLOWED_LATENESS=INTERVAL '2' SECOND AS SELECT count(a) AS count, tumbleEnd(wid) AS w_end FROM test.mt GROUP BY tumble(timestamp, INTERVAL '5' SECOND) AS wid; ``` -请注意,由延迟触发发出的元素应视为先前计算的更新结果。窗口视图将在延迟事件到达时立即触发,而不是在窗口结束时触发。因此,它将导致同一窗口的多次输出。用户需要考虑这些重复结果或对其进行去重。 +注意,由滞后触发的元素应视为先前计算的更新结果。窗口视图不会在窗口结束时触发,而是在滞后事件到达时立即触发。因此,它将导致同一窗口输出多次。用户需要考虑这些重复结果或对其去重。 -您可以使用 `ALTER TABLE ... MODIFY QUERY` 语句修改在窗口视图中指定的 `SELECT` 查询。生成的新 `SELECT` 查询的数据结构应与原始 `SELECT` 查询的数据结构相同,无论是否带有 `TO [db.]name` 子句。请注意,由于中间状态无法重用,当前窗口中的数据将丢失。 +您可以使用 `ALTER TABLE ... MODIFY QUERY` 语句修改窗口视图中指定的 `SELECT` 查询。形成新 `SELECT` 查询的数据结构应与原始 `SELECT` 查询在有或没有 `TO [db.]name` 子句时相同。请注意,当前窗口中的数据将丢失,因为中间状态无法重用。 -### Monitoring New Windows {#monitoring-new-windows} +### 监控新窗口 {#monitoring-new-windows} -窗口视图支持 [WATCH](../../../sql-reference/statements/watch.md) 查询以监控更改,或使用 `TO` 语法将结果输出到表中。 +窗口视图支持 [WATCH](../../../sql-reference/statements/watch.md) 查询以监控变化,或使用 `TO` 语法将结果输出到表。 ```sql WATCH [db.]window_view @@ -373,29 +372,29 @@ WATCH [db.]window_view [FORMAT format] ``` -`WATCH` 查询的作用类似于 `LIVE VIEW`。可以指定 `LIMIT` 来设置在终止查询之前接收更新的数量。可以使用 `EVENTS` 子句获取 `WATCH` 查询的简短形式,其中您将仅获得最新的查询水位线,而不是查询结果。 +`WATCH` 查询的作用类似于 `LIVE VIEW`。可以指定 `LIMIT` 来设置在终止查询之前接收的更新数量。`EVENTS` 子句可用于获得 `WATCH` 查询的简短形式,在该形式中,您将仅获得最新的查询水印,而不是查询结果。 -### Settings {#settings-1} +### 设置 {#settings-1} -- `window_view_clean_interval`:窗口视图的清理间隔(以秒为单位)以释放过时数据。系统将保留根据系统时间或 `WATERMARK` 配置未完全触发的窗口,其他数据将被删除。 -- `window_view_heartbeat_interval`:以秒为单位的心跳间隔,以指示观察查询处于活动状态。 -- `wait_for_window_view_fire_signal_timeout`:等待事件时间处理中的窗口视图触发信号的超时。 +- `window_view_clean_interval`:窗口视图的清理间隔(以秒为单位)以释放过时数据。系统将保留根据系统时间或 `WATERMARK` 配置尚未完全触发的窗口,其他数据将被删除。 +- `window_view_heartbeat_interval`:心跳间隔(以秒为单位),以指示观察查询处于活动状态。 +- `wait_for_window_view_fire_signal_timeout`:事件时间处理中等待窗口视图触发信号的超时。 -### Example {#example} +### 示例 {#example} -假设我们需要计算一个日志表中每 10 秒的点击日志数量,其表结构为: +假设我们需要计算名为 `data` 的日志表中每 10 秒的点击日志数量,其表结构为: ```sql CREATE TABLE data ( `id` UInt64, `timestamp` DateTime) ENGINE = Memory; ``` -首先,我们创建一个具有 10 秒间隔的窗口视图: +首先,我们创建一个以 10 秒为间隔的滚动窗口视图: ```sql CREATE WINDOW VIEW wv as select count(id), tumbleStart(w_id) as window_start from data group by tumble(timestamp, INTERVAL '10' SECOND) as w_id ``` -然后,我们使用 `WATCH` 查询获取结果。 +然后,我们使用 `WATCH` 查询来获取结果。 ```sql WATCH wv @@ -407,7 +406,7 @@ WATCH wv INSERT INTO data VALUES(1,now()) ``` -`WATCH` 查询应该打印如下结果: +`WATCH` 查询应如下所示打印结果: ```text ┌─count(id)─┬────────window_start─┐ @@ -415,22 +414,120 @@ INSERT INTO data VALUES(1,now()) └───────────┴─────────────────────┘ ``` -另外,我们可以使用 `TO` 语法将输出附加到另一个表。 +另外,我们可以使用 `TO` 语法将输出附加到另一个表中。 ```sql CREATE WINDOW VIEW wv TO dst AS SELECT count(id), tumbleStart(w_id) as window_start FROM data GROUP BY tumble(timestamp, INTERVAL '10' SECOND) as w_id ``` -在 ClickHouse 的状态测试中可以找到其他示例(它们被命名为 `*window_view*`)。 +有关更多示例,可以在 ClickHouse 的有状态测试中找到(它们命名为 `*window_view*`)。 -### Window View Usage {#window-view-usage} +### 窗口视图的使用 {#window-view-usage} 窗口视图在以下场景中非常有用: * **监控**:按时间聚合和计算指标日志,并将结果输出到目标表。仪表板可以使用目标表作为源表。 -* **分析**:自动聚合和预处理时间窗口中的数据。当分析大量日志时,这会很有用。预处理消除了多个查询中的重复计算,并减少了查询延迟。 +* **分析**:自动聚合和预处理时间窗口中的数据。在分析大量日志时,这非常有用。预处理消除了多个查询中的重复计算,减少了查询延迟。 + +## 相关内容 {#related-content} + +- 博客: [在 ClickHouse 中处理时间序列数据](https://clickhouse.com/blog/working-with-time-series-data-and-functions-ClickHouse) +- 博客: [使用 ClickHouse 构建可观察性解决方案 - 第 2 部分 - 跟踪](https://clickhouse.com/blog/storing-traces-and-spans-open-telemetry-in-clickhouse) + +## 临时视图 {#temporary-views} + +ClickHouse 支持 **临时视图**,具有以下特性(在适用情况下与临时表匹配): + +* **会话生命周期** + 临时视图仅在当前会话期间存在。会话结束时会自动删除。 + +* **没有数据库** + 您 **无法** 用数据库名限定临时视图。它生活在数据库之外(会话命名空间)。 + +* **不复制 / 无 ON CLUSTER** + 临时对象仅对会话本地,**不能** 使用 `ON CLUSTER` 创建。 + +* **名称解析** + 如果一个临时对象(表或视图)与持久对象同名,并且查询 **不** 带数据库引用,则使用 **临时** 对象。 + +* **逻辑对象(没有存储)** + 临时视图仅存储其 `SELECT` 文本(内部使用 `View` 存储)。它不持久化数据,无法接受 `INSERT`。 + +* **引擎子句** + 您 **不** 需要指定 `ENGINE`;如果提供为 `ENGINE = View`,则会被忽略/视为相同的逻辑视图。 + +* **安全性 / 权限** + 创建临时视图需要 `CREATE TEMPORARY VIEW` 权限,该权限由 `CREATE VIEW` 隐式授予。 + +* **SHOW CREATE** + 使用 `SHOW CREATE TEMPORARY VIEW view_name;` 打印临时视图的 DDL。 + +### 语法 {#temporary-views-syntax} + +```sql +CREATE TEMPORARY VIEW [IF NOT EXISTS] view_name AS +``` + +`OR REPLACE` **不** 支持临时视图(以匹配临时表)。如果您需要“替换”临时视图,请先删除它,然后再创建。 + +### 示例 {#temporary-views-examples} + +创建一个临时源表和一个临时视图: + +```sql +CREATE TEMPORARY TABLE t_src (id UInt32, val String); +INSERT INTO t_src VALUES (1, 'a'), (2, 'b'); + +CREATE TEMPORARY VIEW tview AS +SELECT id, upper(val) AS u +FROM t_src +WHERE id <= 2; + +SELECT * FROM tview ORDER BY id; +``` + +显示它的 DDL: + +```sql +SHOW CREATE TEMPORARY VIEW tview; +``` + +删除它: + +```sql +DROP TEMPORARY VIEW IF EXISTS tview; -- temporary views are dropped with TEMPORARY TABLE syntax +``` + +### 不允许 / 限制 {#temporary-views-limitations} + +* `CREATE OR REPLACE TEMPORARY VIEW ...` → **不允许**(使用 `DROP` + `CREATE`)。 +* `CREATE TEMPORARY MATERIALIZED VIEW ...` / `LIVE VIEW` / `WINDOW VIEW` → **不允许**。 +* `CREATE TEMPORARY VIEW db.view AS ...` → **不允许**(无数据库限定)。 +* `CREATE TEMPORARY VIEW view ON CLUSTER 'name' AS ...` → **不允许**(临时对象是会话本地的)。 +* `POPULATE`、`REFRESH`、`TO [db.table]`、内部引擎和所有与 MV 特有的子句 → **不适用于** 临时视图。 -## Related Content {#related-content} +### 有关分布式查询的说明 {#temporary-views-distributed-notes} -- 博客:[在 ClickHouse 中处理时间序列数据](https://clickhouse.com/blog/working-with-time-series-data-and-functions-ClickHouse) -- 博客:[使用 ClickHouse 构建可观察性解决方案 - 第 2 部分 - 跟踪](https://clickhouse.com/blog/storing-traces-and-spans-open-telemetry-in-clickhouse) +临时 **视图** 只是一个定义;没有数据流动。如果您的临时视图引用临时 **表**(例如,`Memory`),在执行分布式查询时,它们的数据可以像临时表一样被传输到远程服务器。 + +#### 示例 {#temporary-views-distributed-example} + +```sql +-- A session-scoped, in-memory table +CREATE TEMPORARY TABLE temp_ids (id UInt64) ENGINE = Memory; + +INSERT INTO temp_ids VALUES (1), (5), (42); + +-- A session-scoped view over the temp table (purely logical) +CREATE TEMPORARY VIEW v_ids AS +SELECT id FROM temp_ids; + +-- Replace 'test' with your cluster name. +-- GLOBAL JOIN forces ClickHouse to *ship* the small join-side (temp_ids via v_ids) +-- to every remote server that executes the left side. +SELECT count() +FROM cluster('test', system.numbers) AS n +GLOBAL ANY INNER JOIN v_ids USING (id) +WHERE n.number < 100; + +``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/view.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/view.md.hash index 3d9cc43112a..fd882c018f2 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/view.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/create/view.md.hash @@ -1 +1 @@ -151c6a0d17c2f420 +c4783efb34002ed6 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/delete.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/delete.md index dcd54d968cf..cab0b22b42b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/delete.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/delete.md @@ -6,15 +6,16 @@ 'sidebar_position': 36 'slug': '/sql-reference/statements/delete' 'title': '轻量级 DELETE 语句' +'doc_type': 'reference' --- -轻量级 `DELETE` 语句从表 `[db.]table` 中删除与表达式 `expr` 匹配的行。它仅可用于 *MergeTree 表引擎系列。 +轻量级的 `DELETE` 语句从表 `[db.]table` 中删除匹配表达式 `expr` 的行。它仅适用于 *MergeTree 表引擎家族。 ```sql DELETE FROM [db.]table [ON CLUSTER cluster] [IN PARTITION partition_expr] WHERE expr; ``` -之所以称为“轻量级 `DELETE`”,是为了与 [ALTER TABLE ... DELETE](/sql-reference/statements/alter/delete) 命令形成对比,后者是一个重量级过程。 +之所以称为“轻量级 `DELETE`”,是与 [ALTER TABLE ... DELETE](/sql-reference/statements/alter/delete) 命令形成对比,而后者是一个重量级的过程。 ## 示例 {#examples} @@ -23,75 +24,75 @@ DELETE FROM [db.]table [ON CLUSTER cluster] [IN PARTITION partition_expr] WHERE DELETE FROM hits WHERE Title LIKE '%hello%'; ``` -## 轻量级 `DELETE` 不会立即删除数据 {#lightweight-delete-does-not-delete-data-immediately} +## 轻量级 `DELETE` 并不立即删除数据 {#lightweight-delete-does-not-delete-data-immediately} -轻量级 `DELETE` 实现为一个 [mutation](/sql-reference/statements/alter#mutations),它将行标记为已删除,但并不会立即物理删除它们。 +轻量级 `DELETE` 实现为一个 [突变](/sql-reference/statements/alter#mutations),它将行标记为已删除,但不会立即物理删除它们。 -默认情况下,`DELETE` 语句会等待直到标记行已删除完成后再返回。如果数据量很大,这可能需要很长时间。或者,您可以使用设置 [`lightweight_deletes_sync`](/operations/settings/settings#lightweight_deletes_sync) 在后台异步运行它。如果禁用,`DELETE` 语句将立即返回,但在后台分支完成之前,数据仍可能对查询可见。 +默认情况下,`DELETE` 语句会等到标记删除行完成后再返回。如果数据量很大,这可能会需要很长时间。或者,你可以使用设置 [`lightweight_deletes_sync`](/operations/settings/settings#lightweight_deletes_sync) 在后台异步运行。如果禁用,`DELETE` 语句将立即返回,但数据在后台突变完成之前仍可能对查询可见。 -该变更不会物理删除已标记为删除的行,只有在下次合并时才会发生。因此,在未指定的时间内,数据可能不会立即从存储中删除,而只是标记为已删除。 +突变并不会物理删除被标记为删除的行,这仅会在下一次合并时发生。因此,可能在不确定的时间段内,数据并没有被实际从存储中删除,仅被标记为删除。 -如果您需要确保数据在可预测的时间内从存储中删除,可以考虑使用表设置 [`min_age_to_force_merge_seconds`](/operations/settings/merge-tree-settings#min_age_to_force_merge_seconds)。或者,您可以使用 [ALTER TABLE ... DELETE](/sql-reference/statements/alter/delete) 命令。请注意,使用 `ALTER TABLE ... DELETE` 删除数据可能会消耗大量资源,因为它会重新创建所有受影响的部分。 +如果你需要确保你的数据在可预测的时间内从存储中删除,考虑使用表设置 [`min_age_to_force_merge_seconds`](/operations/settings/merge-tree-settings#min_age_to_force_merge_seconds)。或者你可以使用 [ALTER TABLE ... DELETE](/sql-reference/statements/alter/delete) 命令。请注意,使用 `ALTER TABLE ... DELETE` 删除数据可能会消耗大量资源,因为它会重新创建所有受影响的分区片段。 ## 删除大量数据 {#deleting-large-amounts-of-data} -大量删除可能会对 ClickHouse 性能产生负面影响。如果您试图从表中删除所有行,建议使用 [`TRUNCATE TABLE`](/sql-reference/statements/truncate) 命令。 +大量删除会对 ClickHouse 性能产生负面影响。如果你打算从一个表中删除所有行,考虑使用 [`TRUNCATE TABLE`](/sql-reference/statements/truncate) 命令。 -如果您预期会频繁删除,可以考虑使用 [自定义分区键](/engines/table-engines/mergetree-family/custom-partitioning-key)。然后,您可以使用 [`ALTER TABLE ... DROP PARTITION`](/sql-reference/statements/alter/partition#drop-partitionpart) 命令快速删除与该分区相关的所有行。 +如果你预期会频繁删除,考虑使用 [自定义分区键](/engines/table-engines/mergetree-family/custom-partitioning-key)。然后你可以使用 [`ALTER TABLE ... DROP PARTITION`](/sql-reference/statements/alter/partition#drop-partitionpart) 命令快速删除与该分区关联的所有行。 ## 轻量级 `DELETE` 的限制 {#limitations-of-lightweight-delete} ### 带有投影的轻量级 `DELETE` {#lightweight-deletes-with-projections} -默认情况下,`DELETE` 不适用于带有投影的表。这是因为投影中的行可能会受 `DELETE` 操作的影响。但有一个 [MergeTree 设置](/operations/settings/merge-tree-settings) `lightweight_mutation_projection_mode` 可以更改此行为。 +默认情况下,`DELETE` 对具有投影的表不起作用。这是因为投影中的行可能会受到 `DELETE` 操作的影响。但有一个 [MergeTree 设置](/operations/settings/merge-tree-settings) `lightweight_mutation_projection_mode` 可以更改此行为。 -## 使用轻量级 `DELETE` 的性能考虑 {#performance-considerations-when-using-lightweight-delete} +## 使用轻量级 `DELETE` 时的性能考虑 {#performance-considerations-when-using-lightweight-delete} **使用轻量级 `DELETE` 语句删除大量数据可能会对 SELECT 查询性能产生负面影响。** -以下因素也可能对轻量级 `DELETE` 性能产生负面影响: +以下几点也可能对轻量级 `DELETE` 性能产生负面影响: -- `DELETE` 查询中的繁重 `WHERE` 条件。 -- 如果变更队列中填充了许多其他变更,这可能会导致性能问题,因为对表的所有变更都是按顺序执行的。 -- 受影响的表有大量数据部分。 -- 在紧凑部分中有大量数据。在紧凑部分中,所有列都存储在一个文件中。 +- `DELETE` 查询中的重条件。 +- 如果突变队列中充满了许多其他突变,可能会导致性能问题,因为对一个表的所有突变是顺序执行的。 +- 受影响的表具有非常多的数据分区。 +- 过多的数据集中在紧凑分区中。在紧凑分区中,所有列都存储在一个文件中。 ## 删除权限 {#delete-permissions} -`DELETE` 需要 `ALTER DELETE` 权限。要为特定用户在指定表上启用 `DELETE` 语句,请运行以下命令: +`DELETE` 需要 `ALTER DELETE` 权限。要为特定用户在特定表上启用 `DELETE` 语句,请运行以下命令: ```sql GRANT ALTER DELETE ON db.table to username; ``` -## 点击房子内部如何工作轻量级 DELETE {#how-lightweight-deletes-work-internally-in-clickhouse} +## 轻量级 DELETE 在 ClickHouse 内部是如何工作的 {#how-lightweight-deletes-work-internally-in-clickhouse} -1. **对受影响行应用“掩码”** +1. **应用“掩码”到受影响的行** - 当执行 `DELETE FROM table ...` 查询时,ClickHouse 保存一个掩码,其中每行被标记为“存在”或“已删除”。这些“已删除”的行在后续查询中被省略。不过,实际上这些行会在后续合并中被删除。写入此掩码要比通过 `ALTER TABLE ... DELETE` 查询所做的工作轻得多。 + 当执行 `DELETE FROM table ...` 查询时,ClickHouse 保存一个掩码,其中每行被标记为“存在”或“已删除”。这些“已删除”的行会在后续查询中被省略。然而,这些行只有在后续合并时才会被实际移除。写入此掩码比执行 `ALTER TABLE ... DELETE` 查询要轻量得多。 - 该掩码实现为一个隐藏的 `_row_exists` 系统列,存储可见行的 `True` 和已删除行的 `False`。只有当部分中有某些行被删除时,该列才会存在。当一个部分中的所有值都等于 `True` 时,该列不存在。 + 该掩码被实现为一个隐藏的 `_row_exists` 系统列,存储所有可见行的 `True` 和已删除行的 `False`。只有当分区中有一些行被删除时,该列才会存在。如果分区中的所有值都等于 `True`,则该列不存在。 -2. **`SELECT` 查询被转换以包括掩码** +2. **`SELECT` 查询被转换以包含掩码** - 当在查询中使用掩码列时,内部的 `SELECT ... FROM table WHERE condition` 查询将通过对 `_row_exists` 的谓词进行扩展,并转换为: + 当在查询中使用带掩码的列时,内部 `SELECT ... FROM table WHERE condition` 查询会通过 `_row_exists` 进行扩展,并转化为: ```sql SELECT ... FROM table PREWHERE _row_exists WHERE condition ``` - 在执行时,读取列 `_row_exists` 以确定哪些行不应返回。如果有很多已删除的行,ClickHouse 可以确定在读取其余列时可以完全跳过哪些粒度。 + 在执行时,读取 `_row_exists` 列以确定哪些行不应返回。如果有很多已删除的行,ClickHouse 可以确定在读取其他列时可以完全跳过哪些颗粒。 3. **`DELETE` 查询被转换为 `ALTER TABLE ... UPDATE` 查询** - `DELETE FROM table WHERE condition` 被翻译为 `ALTER TABLE table UPDATE _row_exists = 0 WHERE condition` 的变更。 + `DELETE FROM table WHERE condition` 被翻译为 `ALTER TABLE table UPDATE _row_exists = 0 WHERE condition` 突变。 - 从内部来看,该变更分为两个步骤执行: + 内部,这个突变分两个步骤执行: - 1. 为每个单独的部分执行 `SELECT count() FROM table WHERE condition` 命令,以确定该部分是否受影响。 + 1. 为每个单独的分区执行 `SELECT count() FROM table WHERE condition` 命令,以确定该分区是否受到影响。 - 2. 根据以上命令,对受影响的部分进行变更,并为未受影响的部分创建硬链接。在宽部分的情况下,更新每行的 `_row_exists` 列,而所有其他列的文件则被硬链接。对于紧凑部分,由于所有列都存储在一个文件中,因此所有列都被重新写入。 + 2. 根据上述命令,对受影响的分区进行突变,并为未受影响的分区创建硬链接。在宽分区的情况下,更新每行的 `_row_exists` 列,所有其他列的文件都被硬链接。对于紧凑分区,所有列都被重新写入,因为它们都存储在一个文件中。 - 通过以上步骤,可以看出使用掩码技术的轻量级 `DELETE` 在性能上优于传统的 `ALTER TABLE ... DELETE`,因为它不需要重新写入受影响部分的所有列文件。 + 从上述步骤可以看出,使用掩码技术的轻量级 `DELETE` 相较于传统的 `ALTER TABLE ... DELETE` 提高了性能,因为它不必为受影响的分区重新写入所有列的文件。 ## 相关内容 {#related-content} -- 博客: [处理 ClickHouse 中的更新和删除](https://clickhouse.com/blog/handling-updates-and-deletes-in-clickhouse) +- 博客: [在 ClickHouse 中处理更新和删除](https://clickhouse.com/blog/handling-updates-and-deletes-in-clickhouse) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/delete.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/delete.md.hash index b18ad849953..b774e153916 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/delete.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/delete.md.hash @@ -1 +1 @@ -0905a97d7f227775 +f4254f7014fcb1a6 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/describe-table.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/describe-table.md index 53132febc11..95eedc45e10 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/describe-table.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/describe-table.md @@ -1,12 +1,13 @@ --- -'description': '描述 TABLE 的文档' -'sidebar_label': '描述 TABLE' +'description': '描述表的文档' +'sidebar_label': 'DESCRIBE TABLE' 'sidebar_position': 42 'slug': '/sql-reference/statements/describe-table' -'title': '描述 TABLE' +'title': 'DESCRIBE TABLE' +'doc_type': 'reference' --- -返回有关表列的信息。 +返回关于表列的信息。 **语法** @@ -18,14 +19,14 @@ DESC|DESCRIBE TABLE [db.]table [INTO OUTFILE filename] [FORMAT format] - `name` — 列名。 - `type` — 列类型。 -- `default_type` — 用于列 [default expression](/sql-reference/statements/create/table) 的子句: `DEFAULT`、`MATERIALIZED` 或 `ALIAS`。如果没有默认表达式,则返回空字符串。 -- `default_expression` — 在 `DEFAULT` 子句之后指定的表达式。 +- `default_type` — 用于列 [default expression](/sql-reference/statements/create/table) 的子句:`DEFAULT`、`MATERIALIZED` 或 `ALIAS`。如果没有默认表达式,则返回空字符串。 +- `default_expression` — 在 `DEFAULT` 子句后指定的表达式。 - `comment` — [列注释](/sql-reference/statements/alter/column#comment-column)。 - `codec_expression` — 应用于列的 [codec](/sql-reference/statements/create/table#column_compression_codec)。 - `ttl_expression` — [TTL](../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-ttl) 表达式。 -- `is_subcolumn` — 一个标志,如果是内部子列,则等于 `1`。仅当通过 [describe_include_subcolumns](../../operations/settings/settings.md#describe_include_subcolumns) 设置启用子列描述时,会将其包含在结果中。 +- `is_subcolumn` — 一个标志,对于内部子列等于 `1`。仅在通过 [describe_include_subcolumns](../../operations/settings/settings.md#describe_include_subcolumns) 设置启用子列描述时才会包含在结果中。 -在 [Nested](../../sql-reference/data-types/nested-data-structures/index.md) 数据结构中的所有列将单独描述。每列的名称以父列名称和一个点作为前缀。 +[Nested](../../sql-reference/data-types/nested-data-structures/index.md) 数据结构中的所有列单独描述。每列的名称以父列名和一个点作为前缀。 要显示其他数据类型的内部子列,请使用 [describe_include_subcolumns](../../operations/settings/settings.md#describe_include_subcolumns) 设置。 @@ -53,7 +54,7 @@ DESCRIBE TABLE describe_example SETTINGS describe_include_subcolumns=1; └──────┴───────────────────────────────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┘ ``` -第二个查询另外显示子列: +第二个查询还额外显示了子列: ```text ┌─name──────┬─type──────────────────────────┬─default_type─┬─default_expression─┬─comment─┬─codec_expression─┬─ttl_expression─┬─is_subcolumn─┐ @@ -65,6 +66,6 @@ DESCRIBE TABLE describe_example SETTINGS describe_include_subcolumns=1; └───────────┴───────────────────────────────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┴──────────────┘ ``` -**另见** +**另请参阅** - [describe_include_subcolumns](../../operations/settings/settings.md#describe_include_subcolumns) 设置。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/describe-table.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/describe-table.md.hash index 186783ddb89..e8548735af4 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/describe-table.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/describe-table.md.hash @@ -1 +1 @@ -9bc91062ae4faf63 +662ef15d0d03e027 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/detach.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/detach.md index 33942aa68e4..560dec9369d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/detach.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/detach.md @@ -1,12 +1,13 @@ --- -'description': 'Detach 的文档' +'description': 'DETACH 的文档' 'sidebar_label': 'DETACH' 'sidebar_position': 43 'slug': '/sql-reference/statements/detach' 'title': 'DETACH 语句' +'doc_type': 'reference' --- -使服务器“忘记”一个表、物化视图、字典或数据库的存在。 +使服务器“忘记”表、物化视图、字典或数据库的存在。 **语法** @@ -14,18 +15,18 @@ DETACH TABLE|VIEW|DICTIONARY|DATABASE [IF EXISTS] [db.]name [ON CLUSTER cluster] [PERMANENTLY] [SYNC] ``` -分离并不会删除表、物化视图、字典或数据库的数据或元数据。如果实体没有被 `PERMANENTLY` 分离,下一次服务器启动时,服务器将读取元数据并重新调用表/视图/字典/数据库。如果实体被 `PERMANENTLY` 分离,则不会自动重新调用。 +分离不会删除表、物化视图、字典或数据库的数据或元数据。如果一个实体没有被`PERMANENTLY`分离,在下次服务器启动时,服务器将读取元数据并再次回忆起表/视图/字典/数据库。如果一个实体被`PERMANENTLY`分离,则不会自动回忆。 -无论一个表、字典或数据库是否被永久分离,您都可以使用 [ATTACH](../../sql-reference/statements/attach.md) 查询重新附加它们。 -系统日志表也可以重新附加(例如 `query_log`,`text_log` 等)。其他系统表无法重新附加。下次服务器启动时,服务器将再次调用这些表。 +无论一个表、字典或数据库是否被永久分离,您都可以使用[ATTACH](../../sql-reference/statements/attach.md)查询重新附加它们。 +系统日志表也可以重新附加(例如`query_log`、`text_log`等)。其他系统表不能被重新附加。在下次服务器启动时,服务器将再次回忆这些表。 -`ATTACH MATERIALIZED VIEW` 不支持短语法(没有 `SELECT`),但您可以通过 `ATTACH TABLE` 查询来附加它。 +`ATTACH MATERIALIZED VIEW`不支持简短语法(不带`SELECT`),但您可以使用`ATTACH TABLE`查询进行附加。 -请注意,您不能永久分离已经分离的(临时)表。但您可以将其重新附加,然后再次永久分离。 +请注意,您不能永久分离已经被临时分离的表。但是,您可以将其重新附加,然后再永久分离。 -此外,您不能 [DROP](../../sql-reference/statements/drop.md#drop-table) 被分离的表,或者 [CREATE TABLE](../../sql-reference/statements/create/table.md) 使用与永久分离的同名表,或用 [RENAME TABLE](../../sql-reference/statements/rename.md) 查询替换它。 +此外,您不能[DROP](../../sql-reference/statements/drop.md#drop-table)已分离的表,或使用与永久分离的同名表[CREATE TABLE](../../sql-reference/statements/create/table.md)或用[RENAME TABLE](../../sql-reference/statements/rename.md)查询替换它。 -`SYNC` 修饰符立即执行该操作。 +`SYNC`修饰符会立即执行该操作。 **示例** @@ -72,10 +73,10 @@ Code: 60. DB::Exception: Received from localhost:9000. DB::Exception: Table defa ``` :::note -在 ClickHouse Cloud 中,用户应使用 `PERMANENTLY` 子句,例如 `DETACH TABLE PERMANENTLY`。如果此子句未使用,在集群重启时(例如在升级期间),表将被重新附加。 +在 ClickHouse Cloud 中,用户应使用`PERMANENTLY`子句,例如`DETACH TABLE
PERMANENTLY`。如果未使用此子句,则在集群重启(例如在升级期间)时,表将被重新附加。 ::: -**另见** +**另请参阅** - [物化视图](/sql-reference/statements/create/view#materialized-view) - [字典](../../sql-reference/dictionaries/index.md) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/detach.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/detach.md.hash index c3568e58bf1..47927f1e955 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/detach.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/detach.md.hash @@ -1 +1 @@ -e97f6e65a6d71b60 +3a91cd71698561a6 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/drop.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/drop.md index 32df1b039b4..843f7457f49 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/drop.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/drop.md @@ -4,12 +4,13 @@ 'sidebar_position': 44 'slug': '/sql-reference/statements/drop' 'title': 'DROP 语句' +'doc_type': 'reference' --- # DROP 语句 -删除现有实体。如果指定了 `IF EXISTS` 子句,当实体不存在时这些查询不会返回错误。如果指定了 `SYNC` 修饰符,则实体会立即被删除。 +删除现有实体。如果指定了 `IF EXISTS` 子句,则这些查询在实体不存在时不会返回错误。如果指定了 `SYNC` 修饰符,则实体会立即被删除。 ## DROP DATABASE {#drop-database} @@ -26,7 +27,7 @@ DROP DATABASE [IF EXISTS] db [ON CLUSTER cluster] [SYNC] 删除一个或多个表。 :::tip -要撤消表的删除,请参见 [UNDROP TABLE](/sql-reference/statements/undrop.md) +要撤销表的删除,请参见 [UNDROP TABLE](/sql-reference/statements/undrop.md) ::: 语法: @@ -36,8 +37,8 @@ DROP [TEMPORARY] TABLE [IF EXISTS] [IF EMPTY] [db1.]name_1[, [db2.]name_2, ...] ``` 限制: -- 如果指定了 `IF EMPTY` 子句,服务器仅在接收查询的副本上检查表是否为空。 -- 同时删除多个表不是一个原子操作,即如果某个表的删除失败,后续的表将不会被删除。 +- 如果指定了 `IF EMPTY` 子句,则服务器仅在接收查询的副本上检查表是否为空。 +- 同时删除多个表不是一个原子操作,即如果一个表的删除失败,则后续表不会被删除。 ## DROP DICTIONARY {#drop-dictionary} @@ -61,7 +62,7 @@ DROP USER [IF EXISTS] name [,...] [ON CLUSTER cluster_name] [FROM access_storage ## DROP ROLE {#drop-role} -删除角色。被删除的角色将从所有分配该角色的实体中撤销。 +删除角色。已删除的角色从所有分配了该角色的实体中撤销。 语法: @@ -71,7 +72,7 @@ DROP ROLE [IF EXISTS] name [,...] [ON CLUSTER cluster_name] [FROM access_storage ## DROP ROW POLICY {#drop-row-policy} -删除行策略。被删除的行策略将从所有分配该策略的实体中撤销。 +删除行策略。已删除的行策略从所有分配了该策略的实体中撤销。 语法: @@ -81,7 +82,7 @@ DROP [ROW] POLICY [IF EXISTS] name [,...] ON [database.]table [,...] [ON CLUSTER ## DROP QUOTA {#drop-quota} -删除配额。被删除的配额将从所有分配该配额的实体中撤销。 +删除配额。已删除的配额从所有分配了该配额的实体中撤销。 语法: @@ -91,7 +92,7 @@ DROP QUOTA [IF EXISTS] name [,...] [ON CLUSTER cluster_name] [FROM access_storag ## DROP SETTINGS PROFILE {#drop-settings-profile} -删除设置配置文件。被删除的设置配置文件将从所有分配该配置文件的实体中撤销。 +删除设置配置文件。已删除的设置配置文件从所有分配了该配置文件的实体中撤销。 语法: @@ -111,7 +112,8 @@ DROP VIEW [IF EXISTS] [db.]name [ON CLUSTER cluster] [SYNC] ## DROP FUNCTION {#drop-function} -删除由 [CREATE FUNCTION](./create/function.md) 创建的用户定义函数。系统函数不能被删除。 +删除由 [CREATE FUNCTION](./create/function.md) 创建的用户定义函数。 +系统函数无法被删除。 **语法** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/drop.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/drop.md.hash index 9c3dabda9b0..bf57cfd0b5e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/drop.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/drop.md.hash @@ -1 +1 @@ -90728f508fb354c9 +67301c21c21fa6c4 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/exchange.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/exchange.md index c674f77a280..3870573996a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/exchange.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/exchange.md @@ -4,15 +4,17 @@ 'sidebar_position': 49 'slug': '/sql-reference/statements/exchange' 'title': 'EXCHANGE 语句' +'doc_type': 'reference' --- # EXCHANGE 语句 -**EXCHANGE** 语句原子地交换两个表或字典的名称。 这个任务也可以通过一个使用临时名称的 [RENAME](./rename.md) 查询来完成,但在这种情况下,该操作不是原子的。 +原子性地交换两个表或字典的名称。 +这个任务也可以通过使用临时名称的 [`RENAME`](./rename.md) 查询来完成,但在这种情况下操作不是原子的。 :::note -`EXCHANGE` 查询仅由 [Atomic](../../engines/database-engines/atomic.md) 数据库引擎支持。 +`EXCHANGE` 查询仅由 [`Atomic`](../../engines/database-engines/atomic.md) 和 [`Shared`](/cloud/reference/shared-catalog#shared-database-engine) 数据库引擎支持。 ::: **语法** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/exchange.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/exchange.md.hash index b748d9d3c2a..aea1f7f4312 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/exchange.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/exchange.md.hash @@ -1 +1 @@ -6300df4aad941fc1 +927bb8ed0ec4902c diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/exists.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/exists.md index 271420e63c1..5e5e2c3b011 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/exists.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/exists.md @@ -4,6 +4,7 @@ 'sidebar_position': 45 'slug': '/sql-reference/statements/exists' 'title': 'EXISTS 语句' +'doc_type': 'reference' --- @@ -13,4 +14,4 @@ EXISTS [TEMPORARY] [TABLE|DICTIONARY|DATABASE] [db.]name [INTO OUTFILE filename] [FORMAT format] ``` -返回一个单一的 `UInt8` 类型列,如果表或数据库不存在,则该值为 `0`,如果表在指定的数据库中存在,则该值为 `1`。 +返回一个单一的 `UInt8` 类型的列,如果表或数据库不存在,则包含值 `0`;如果表在指定的数据库中存在,则包含值 `1`。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/exists.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/exists.md.hash index 95532b24522..67c1031c71d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/exists.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/exists.md.hash @@ -1 +1 @@ -62a78fb0490e47a1 +8059205f4df1816d diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/explain.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/explain.md index e5f434f98ce..ff247bbb9ef 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/explain.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/explain.md @@ -4,6 +4,7 @@ 'sidebar_position': 39 'slug': '/sql-reference/statements/explain' 'title': 'EXPLAIN 语句' +'doc_type': 'reference' --- 显示语句的执行计划。 @@ -59,14 +60,14 @@ Union ## EXPLAIN 类型 {#explain-types} - `AST` — 抽象语法树。 -- `SYNTAX` — AST级别优化后的查询文本。 -- `QUERY TREE` — 查询树在查询树级别优化后的状态。 +- `SYNTAX` — 在 AST 层级优化后的查询文本。 +- `QUERY TREE` — 在查询树层级优化后的查询树。 - `PLAN` — 查询执行计划。 - `PIPELINE` — 查询执行管道。 ### EXPLAIN AST {#explain-ast} -转储查询 AST。支持所有类型的查询,包括不仅限于 `SELECT`。 +转储查询 AST。支持所有类型的查询,不仅限于 `SELECT`。 示例: @@ -100,37 +101,57 @@ AlterQuery t1 (children 1) ### EXPLAIN SYNTAX {#explain-syntax} -返回经过语法优化后的查询。 +显示查询的抽象语法树(AST),在语法分析之后。 + +它通过解析查询,构造查询 AST 和查询树,选择性地运行查询分析器和优化过程,然后将查询树转换回查询 AST。 + +设置: + +- `oneline` – 以一行打印查询。默认: `0`。 +- `run_query_tree_passes` – 在转储查询树之前运行查询树过程。默认: `0`。 +- `query_tree_passes` – 如果设置了 `run_query_tree_passes`,指定要运行多少次过程。未指定 `query_tree_passes` 时,将运行所有过程。 示例: ```sql -EXPLAIN SYNTAX SELECT * FROM system.numbers AS a, system.numbers AS b, system.numbers AS c; +EXPLAIN SYNTAX SELECT * FROM system.numbers AS a, system.numbers AS b, system.numbers AS c WHERE a.number = b.number AND b.number = c.number; +``` + +输出: + +```sql +SELECT * +FROM system.numbers AS a, system.numbers AS b, system.numbers AS c +WHERE (a.number = b.number) AND (b.number = c.number) ``` +带有 `run_query_tree_passes`: + +```sql +EXPLAIN SYNTAX run_query_tree_passes = 1 SELECT * FROM system.numbers AS a, system.numbers AS b, system.numbers AS c WHERE a.number = b.number AND b.number = c.number; +``` + +输出: + ```sql SELECT - `--a.number` AS `a.number`, - `--b.number` AS `b.number`, - number AS `c.number` -FROM -( - SELECT - number AS `--a.number`, - b.number AS `--b.number` - FROM system.numbers AS a - CROSS JOIN system.numbers AS b -) AS `--.s` -CROSS JOIN system.numbers AS c + __table1.number AS `a.number`, + __table2.number AS `b.number`, + __table3.number AS `c.number` +FROM system.numbers AS __table1 +ALL INNER JOIN system.numbers AS __table2 ON __table1.number = __table2.number +ALL INNER JOIN system.numbers AS __table3 ON __table2.number = __table3.number ``` ### EXPLAIN QUERY TREE {#explain-query-tree} 设置: -- `run_passes` — 在转储查询树之前运行所有查询树的优化步骤。默认值:`1`。 -- `dump_passes` — 在转储查询树之前转储关于已使用优化步骤的信息。默认值:`0`。 -- `passes` — 指定要运行的优化步骤数量。如果设置为 `-1`,则运行所有优化步骤。默认值:`-1`。 +- `run_passes` — 在转储查询树之前运行所有查询树过程。默认: `1`。 +- `dump_passes` — 在转储查询树之前转储所用过程的信息。默认: `0`。 +- `passes` — 指定要运行多少次过程。如果设置为 `-1`,则运行所有过程。默认: `-1`。 +- `dump_tree` — 显示查询树。默认: `1`。 +- `dump_ast` — 显示从查询树生成的查询 AST。默认: `0`。 示例: ```sql @@ -156,13 +177,14 @@ QUERY id: 0 设置: -- `header` — 为步骤打印输出头。默认值:0。 -- `description` — 打印步骤描述。默认值:1。 -- `indexes` — 显示使用的索引、过滤的分区数量和每个索引的过滤粒度数量。默认值:0。支持[MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) 表。 -- `actions` — 打印关于步骤动作的详细信息。默认值:0。 -- `json` — 以[JSON](../../interfaces/formats.md#json)格式打印查询计划步骤。默认值:0。建议使用[TSVRaw](../../interfaces/formats.md#tabseparatedraw)格式以避免不必要的转义。 +- `header` — 打印步骤的输出头部。默认: 0。 +- `description` — 打印步骤描述。默认: 1。 +- `indexes` — 显示使用的索引,过滤的部分数量以及每个应用的索引过滤的粒度数量。默认: 0。支持 [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) 表。 +- `projections` — 显示所有分析的投影及其对基于投影主键条件的部分级过滤的影响。对于每个投影,此部分包括统计信息,如评估使用投影主键的部分数量、行数、标记和范围。它还显示由于此过滤而跳过的多少数据部分,而无需从投影本身读取。投影是否实际用于读取或仅用于过滤分析可以通过 `description` 字段判断。默认: 0。支持 [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) 表。 +- `actions` — 打印关于步骤动作的详细信息。默认: 0。 +- `json` — 以 [JSON](../../interfaces/formats.md#json) 格式打印查询计划步骤。默认: 0。建议使用 [TSVRaw](../../interfaces/formats.md#tabseparatedraw) 格式以避免不必要的转义。 -当 `json=1`时,步骤名称将包含一个附加后缀,带有唯一步骤标识符。 +当 `json=1` 时,步骤名称将包含一个附加后缀,标识唯一的步骤标识符。 示例: @@ -180,11 +202,11 @@ Union ReadFromStorage (SystemNumbers) ``` -:::note -步骤和查询成本估算不支持。 +:::note +步骤和查询成本估算不受支持。 ::: -当 `json = 1`时,查询计划以 JSON 格式表示。每个节点都是一个字典,始终包含 `Node Type` 和 `Plans` 键。`Node Type` 是步骤名称的字符串。`Plans` 是包含子步骤描述的数组。其他可选键可能会根据节点类型和设置进行添加。 +当 `json = 1` 时,查询计划表示为 JSON 格式。每个节点是一个字典,始终具有 `Node Type` 和 `Plans` 的键。`Node Type` 是一个包含步骤名称的字符串。`Plans` 是一个包含子步骤描述的数组。根据节点类型和设置,可能会添加其他可选键。 示例: @@ -225,7 +247,7 @@ EXPLAIN json = 1, description = 0 SELECT 1 UNION ALL SELECT 2 FORMAT TSVRaw; ] ``` -当 `description` = 1 时,将向步骤添加 `Description` 键: +当 `description` = 1 时,步骤中将添加 `Description` 键: ```json { @@ -234,7 +256,7 @@ EXPLAIN json = 1, description = 0 SELECT 1 UNION ALL SELECT 2 FORMAT TSVRaw; } ``` -当 `header` = 1 时,将 `Header` 键作为列数组添加到步骤中。 +当 `header` = 1 时,步骤中将添加 `Header` 键,作为一组列的数组。 示例: @@ -275,14 +297,15 @@ EXPLAIN json = 1, description = 0, header = 1 SELECT 1, 2 + dummy; ] ``` -当 `indexes` = 1 时,添加了 `Indexes` 键。它包含一个使用的索引数组。每个索引描述为 JSON,包括 `Type` 键(一个字符串 `MinMax`、`Partition`、`PrimaryKey` 或 `Skip`)和可选键: +当 `indexes` = 1 时,将添加 `Indexes` 键。它包含一个使用的索引数组。每个索引描述为 JSON,具有 `Type` 键(字符串`MinMax`、`Partition`、`PrimaryKey` 或 `Skip`)及可选键: - `Name` — 索引名称(当前仅用于 `Skip` 索引)。 - `Keys` — 索引使用的列数组。 - `Condition` — 使用的条件。 - `Description` — 索引描述(当前仅用于 `Skip` 索引)。 -- `Parts` — 应用索引前后的分区数量。 -- `Granules` — 应用索引前后的粒度数量。 +- `Parts` — 应用该索引后的部分数量。 +- `Granules` — 应用该索引后的粒度数量。 +- `Ranges` — 应用索引后粒度范围的数量。 示例: @@ -293,41 +316,83 @@ EXPLAIN json = 1, description = 0, header = 1 SELECT 1, 2 + dummy; "Type": "MinMax", "Keys": ["y"], "Condition": "(y in [1, +inf))", - "Parts": 5/4, - "Granules": 12/11 + "Parts": 4/5, + "Granules": 11/12 }, { "Type": "Partition", "Keys": ["y", "bitAnd(z, 3)"], "Condition": "and((bitAnd(z, 3) not in [1, 1]), and((y in [1, +inf)), (bitAnd(z, 3) not in [1, 1])))", - "Parts": 4/3, - "Granules": 11/10 + "Parts": 3/4, + "Granules": 10/11 }, { "Type": "PrimaryKey", "Keys": ["x", "y"], "Condition": "and((x in [11, +inf)), (y in [1, +inf)))", - "Parts": 3/2, - "Granules": 10/6 + "Parts": 2/3, + "Granules": 6/10, + "Search Algorithm": "generic exclusion search" }, { "Type": "Skip", "Name": "t_minmax", "Description": "minmax GRANULARITY 2", - "Parts": 2/1, - "Granules": 6/2 + "Parts": 1/2, + "Granules": 2/6 }, { "Type": "Skip", "Name": "t_set", "Description": "set GRANULARITY 2", "": 1/1, - "Granules": 2/1 + "Granules": 1/2 } ] ``` -当 `actions` = 1 时,添加的键取决于步骤类型。 +当 `projections` = 1 时,将添加 `Projections` 键。它包含一个分析的投影数组。每个投影描述为 JSON,具有以下键: + +- `Name` — 投影名称。 +- `Condition` — 使用的投影主键条件。 +- `Description` — 投影使用的描述(例如,部分级过滤)。 +- `Selected Parts` — 被投影选择的部分数量。 +- `Selected Marks` — 被选择的标记数量。 +- `Selected Ranges` — 被选择的范围数量。 +- `Selected Rows` — 被选择的行数量。 +- `Filtered Parts` — 由于部分级过滤而跳过的部分数量。 + +示例: + +```json +"Node Type": "ReadFromMergeTree", +"Projections": [ + { + "Name": "region_proj", + "Description": "Projection has been analyzed and is used for part-level filtering", + "Condition": "(region in ['us_west', 'us_west'])", + "Search Algorithm": "binary search", + "Selected Parts": 3, + "Selected Marks": 3, + "Selected Ranges": 3, + "Selected Rows": 3, + "Filtered Parts": 2 + }, + { + "Name": "user_id_proj", + "Description": "Projection has been analyzed and is used for part-level filtering", + "Condition": "(user_id in [107, 107])", + "Search Algorithm": "binary search", + "Selected Parts": 1, + "Selected Marks": 1, + "Selected Ranges": 1, + "Selected Rows": 1, + "Filtered Parts": 2 + } +] +``` + +当 `actions` = 1 时,添加的键根据步骤类型不同而有所不同。 示例: @@ -390,11 +455,11 @@ EXPLAIN json = 1, actions = 1, description = 0 SELECT 1 FORMAT TSVRaw; 设置: -- `header` — 为每个输出端口打印头。默认值:0。 -- `graph` — 打印以[DOT](https://en.wikipedia.org/wiki/DOT_(graph_description_language))图描述语言描述的图。默认值:0。 -- `compact` — 如果启用了 `graph` 设置,则以紧凑模式打印图。默认值:1。 +- `header` — 为每个输出端口打印头。默认: 0。 +- `graph` — 打印用 [DOT](https://en.wikipedia.org/wiki/DOT_(graph_description_language)) 图形描述语言描述的图形。默认: 0。 +- `compact` — 如果启用 `graph` 设置,则以紧凑模式打印图形。默认: 1。 -当 `compact=0` 且 `graph=1` 时,处理器名称将包含一个附加后缀,带有唯一处理器标识符。 +当 `compact=0` 且 `graph=1` 时,处理器名称将包含一个附加后缀,标识唯一的处理器标识符。 示例: @@ -417,14 +482,13 @@ ExpressionTransform (ReadFromStorage) NumbersRange × 2 0 → 1 ``` - ### EXPLAIN ESTIMATE {#explain-estimate} -显示在处理查询时从表中读取的估计行、标记和分区数量。可以用于[MergeTree](/engines/table-engines/mergetree-family/mergetree)系列表。 +显示在处理查询时要从表中读取的估算行数、标记和部分数量。适用于 [MergeTree](/engines/table-engines/mergetree-family/mergetree) 类型的表。 **示例** -创建一个表: +创建表: ```sql CREATE TABLE ttt (i Int64) ENGINE = MergeTree() ORDER BY i SETTINGS index_granularity = 16, write_final_mark = 0; @@ -448,12 +512,12 @@ EXPLAIN ESTIMATE SELECT * FROM ttt; ### EXPLAIN TABLE OVERRIDE {#explain-table-override} -显示通过表函数访问的表模式的表覆盖结果。 -还进行了一些验证,如果覆盖会导致某种类型的失败,则会抛出异常。 +显示通过表函数访问的表模式中的表覆盖结果。 +还进行了一些验证,如果覆盖会导致某种类型的失败,将抛出异常。 **示例** -假设你有一个远程的 MySQL 表,如下所示: +假设您有一个远程 MySQL 表,如下所示: ```sql CREATE TABLE db.tbl ( @@ -475,6 +539,6 @@ PARTITION BY toYYYYMM(assumeNotNull(created)) └─────────────────────────────────────────────────────────┘ ``` -:::note -验证不完整,因此成功的查询并不能保证覆盖不会导致问题。 +:::note +验证并不完整,因此成功的查询并不保证覆盖不会引发问题。 ::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/explain.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/explain.md.hash index 8a1ca4972c4..6585ac0cc47 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/explain.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/explain.md.hash @@ -1 +1 @@ -5dcb6c951ae47f4f +89c15698e9649925 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/grant.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/grant.md index 3675f600423..c02448fd3a3 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/grant.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/grant.md @@ -1,9 +1,10 @@ --- -'description': 'GRANT 语句的文档' +'description': 'GRANT 语句 的文档' 'sidebar_label': 'GRANT' 'sidebar_position': 38 'slug': '/sql-reference/statements/grant' 'title': 'GRANT 语句' +'doc_type': 'reference' --- import CloudNotSupportedBadge from '@theme/badges/CloudNotSupportedBadge'; @@ -11,23 +12,23 @@ import CloudNotSupportedBadge from '@theme/badges/CloudNotSupportedBadge'; # GRANT 语句 -- 将[权限](#privileges)授予 ClickHouse 用户帐户或角色。 -- 将角色分配给用户帐户或其他角色。 +- 将 [权限](#privileges) 授予 ClickHouse 用户账户或角色。 +- 将角色分配给用户账户或其他角色。 -要撤销权限,请使用 [REVOKE](../../sql-reference/statements/revoke.md) 语句。您还可以使用 [SHOW GRANTS](../../sql-reference/statements/show.md#show-grants) 语句列出授予的权限。 +要撤销权限,请使用 [REVOKE](../../sql-reference/statements/revoke.md) 语句。您还可以使用 [SHOW GRANTS](../../sql-reference/statements/show.md#show-grants) 语句列出已授予的权限。 -## 授权权限语法 {#granting-privilege-syntax} +## 授予权限语法 {#granting-privilege-syntax} ```sql GRANT [ON CLUSTER cluster_name] privilege[(column_name [,...])] [,...] ON {db.table[*]|db[*].*|*.*|table[*]|*} TO {user | role | CURRENT_USER} [,...] [WITH GRANT OPTION] [WITH REPLACE OPTION] ``` -- `privilege` — 权限类型。 -- `role` — ClickHouse 用户角色。 -- `user` — ClickHouse 用户帐户。 +- `privilege` - 权限的类型。 +- `role` - ClickHouse 用户角色。 +- `user` - ClickHouse 用户账户。 -`WITH GRANT OPTION` 子句授予 `user` 或 `role` 执行 `GRANT` 查询的权限。用户可以授予他们具有的相同范围及更低范围的权限。 -`WITH REPLACE OPTION` 子句可以将 `user` 或 `role` 的旧权限替换为新权限,如果未指定,它将附加权限。 +`WITH GRANT OPTION` 子句授予 `user` 或 `role` 执行 `GRANT` 查询的权限。用户可以授予他们拥有的相同范围及以下的权限。 +`WITH REPLACE OPTION` 子句用新的权限替换 `user` 或 `role` 的旧权限,如果未指定,则附加权限。 ## 分配角色语法 {#assigning-role-syntax} @@ -35,23 +36,23 @@ GRANT [ON CLUSTER cluster_name] privilege[(column_name [,...])] [,...] ON {db.ta GRANT [ON CLUSTER cluster_name] role [,...] TO {user | another_role | CURRENT_USER} [,...] [WITH ADMIN OPTION] [WITH REPLACE OPTION] ``` -- `role` — ClickHouse 用户角色。 -- `user` — ClickHouse 用户帐户。 +- `role` - ClickHouse 用户角色。 +- `user` - ClickHouse 用户账户。 `WITH ADMIN OPTION` 子句授予 `user` 或 `role` [ADMIN OPTION](#admin-option) 权限。 -`WITH REPLACE OPTION` 子句可以将 `user` 或 `role` 的旧角色替换为新角色,如果未指定,它将附加角色。 +`WITH REPLACE OPTION` 子句用新角色替换 `user` 或 `role` 的旧角色,如果未指定,则附加角色。 ## 授予当前权限语法 {#grant-current-grants-syntax} ```sql GRANT CURRENT GRANTS{(privilege[(column_name [,...])] [,...] ON {db.table|db.*|*.*|table|*}) | ON {db.table|db.*|*.*|table|*}} TO {user | role | CURRENT_USER} [,...] [WITH GRANT OPTION] [WITH REPLACE OPTION] ``` -- `privilege` — 权限类型。 -- `role` — ClickHouse 用户角色。 -- `user` — ClickHouse 用户帐户。 +- `privilege` - 权限的类型。 +- `role` - ClickHouse 用户角色。 +- `user` - ClickHouse 用户账户。 -使用 `CURRENT GRANTS` 语句可以为给定用户或角色授予所有指定的权限。 -如果未指定任何权限,则给定用户或角色将接收 `CURRENT_USER` 的所有可用权限。 +使用 `CURRENT GRANTS` 语句可以将所有指定的权限授予给指定的用户或角色。 +如果未指定任何权限,则指定的用户或角色将会获得 `CURRENT_USER` 的所有可用权限。 ## 使用方法 {#usage} @@ -69,26 +70,31 @@ GRANT SELECT(x,y) ON db.table TO john WITH GRANT OPTION - `SELECT x FROM db.table`。 - `SELECT y FROM db.table`。 -`john` 无法执行 `SELECT z FROM db.table`。`SELECT * FROM db.table` 也不可用。处理此查询时,ClickHouse 不会返回任何数据,即使是 `x` 和 `y`。唯一的例外是,如果表只包含 `x` 和 `y` 列。在这种情况下,ClickHouse 返回所有数据。 +`john` 不能执行 `SELECT z FROM db.table`。`SELECT * FROM db.table` 也不可用。在处理此查询时,ClickHouse 不会返回任何数据,即使是 `x` 和 `y`。唯一的例外是,如果表中仅包含 `x` 和 `y` 列。在这种情况下,ClickHouse 返回所有数据。 -此外,`john` 还拥有 `GRANT OPTION` 权限,因此可以授予其他用户与其相同或更小范围的权限。 +同时 `john` 拥有 `GRANT OPTION` 权限,因此可以授予其他用户相同或更小范围的权限。 -始终允许访问 `system` 数据库(因为该数据库用于处理查询)。 +对 `system` 数据库的访问总是被允许(因为该数据库用于处理查询)。 -您可以在一个查询中授予多个账户多个权限。查询 `GRANT SELECT, INSERT ON *.* TO john, robin` 允许账户 `john` 和 `robin` 在服务器上对所有数据库的所有表执行 `INSERT` 和 `SELECT` 查询。 +:::note +虽然有许多系统表新的用户默认可以访问,但他们可能无法在没有授权的情况下访问每个系统表。 +此外,由于安全原因,Cloud 用户对某些系统表(如 `system.zookeeper`)的访问受到限制。 +::: + +您可以在一个查询中将多个权限授予多个账户。查询 `GRANT SELECT, INSERT ON *.* TO john, robin` 允许账户 `john` 和 `robin` 执行对服务器上所有数据库中所有表的 `INSERT` 和 `SELECT` 查询。 ## 通配符授权 {#wildcard-grants} -在指定权限时,您可以使用星号 (`*`) 来代替表或数据库名称。例如,查询 `GRANT SELECT ON db.* TO john` 允许 `john` 在 `db` 数据库中的所有表上执行 `SELECT` 查询。 -此外,您可以省略数据库名称。在这种情况下,权限被授予当前数据库。 -例如,`GRANT SELECT ON * TO john` 授予当前数据库中所有表的权限,`GRANT SELECT ON mytable TO john` 授予当前数据库中的 `mytable` 表的权限。 +在指定权限时,您可以使用星号(`*`)而不是表名或数据库名。例如,查询 `GRANT SELECT ON db.* TO john` 允许 `john` 执行对 `db` 数据库中所有表的 `SELECT` 查询。 +此外,您也可以省略数据库名。在这种情况下,权限将授予当前数据库。 +例如,`GRANT SELECT ON * TO john` 授予对当前数据库中所有表的权限,`GRANT SELECT ON mytable TO john` 授予对当前数据库中 `mytable` 表的权限。 :::note -以下描述的功能从 24.10 版本的 ClickHouse 开始提供。 +以下描述的特性在 24.10 ClickHouse 版本中可用。 ::: -您还可以在表或数据库名称的末尾放置星号。这一特性使您能够在表路径的抽象前缀上授予权限。 -示例:`GRANT SELECT ON db.my_tables* TO john`。这个查询允许 `john` 在所有以 `my_tables` 为前缀的 `db` 数据库表上执行 `SELECT` 查询。 +您还可以在表名或数据库名后添加星号。这一特性允许您在表路径的抽象前缀上授予权限。 +示例:`GRANT SELECT ON db.my_tables* TO john`。此查询允许 `john` 执行对 `db` 数据库中所有以 `my_tables*` 为前缀的表的 `SELECT` 查询。 更多示例: @@ -111,10 +117,10 @@ SELECT * FROM db.other_table -- granted SELECT * FROM db2.my_tables -- granted ``` -所有在授予路径内新创建的表将自动继承来自其父表的所有权限。 -例如,如果您运行查询 `GRANT SELECT ON db.* TO john`,然后创建一个新表 `db.new_table`,用户 `john` 将能够运行查询 `SELECT * FROM db.new_table`。 +在授予路径内创建的所有新表将自动继承其父级的所有权限。 +例如,如果您运行 `GRANT SELECT ON db.* TO john` 查询,然后创建新表 `db.new_table`,用户 `john` 将能够运行 `SELECT * FROM db.new_table` 查询。 -您只能对前缀指定星号: +您只能为前缀指定星号: ```sql GRANT SELECT ON db.* TO john -- correct GRANT SELECT ON db*.* TO john -- correct @@ -127,228 +133,228 @@ GRANT SELECT(foo) ON db.table* TO john -- wrong ## 权限 {#privileges} -权限是授予用户执行特定类型查询的许可。 +权限是授予用户执行特定类型查询的权限。 权限具有分层结构,允许的查询集取决于权限范围。 ClickHouse 中权限的层次结构如下所示: - [`ALL`](#all) - - [`ACCESS MANAGEMENT`](#access-management) - - `ALLOW SQL SECURITY NONE` - - `ALTER QUOTA` - - `ALTER ROLE` - - `ALTER ROW POLICY` - - `ALTER SETTINGS PROFILE` - - `ALTER USER` - - `CREATE QUOTA` - - `CREATE ROLE` - - `CREATE ROW POLICY` - - `CREATE SETTINGS PROFILE` - - `CREATE USER` - - `DROP QUOTA` - - `DROP ROLE` - - `DROP ROW POLICY` - - `DROP SETTINGS PROFILE` - - `DROP USER` - - `ROLE ADMIN` - - `SHOW ACCESS` - - `SHOW QUOTAS` - - `SHOW ROLES` - - `SHOW ROW POLICIES` - - `SHOW SETTINGS PROFILES` - - `SHOW USERS` - - [`ALTER`](#alter) - - `ALTER DATABASE` - - `ALTER DATABASE SETTINGS` - - `ALTER TABLE` - - `ALTER COLUMN` - - `ALTER ADD COLUMN` - - `ALTER CLEAR COLUMN` - - `ALTER COMMENT COLUMN` - - `ALTER DROP COLUMN` - - `ALTER MATERIALIZE COLUMN` - - `ALTER MODIFY COLUMN` - - `ALTER RENAME COLUMN` - - `ALTER CONSTRAINT` - - `ALTER ADD CONSTRAINT` - - `ALTER DROP CONSTRAINT` - - `ALTER DELETE` - - `ALTER FETCH PARTITION` - - `ALTER FREEZE PARTITION` - - `ALTER INDEX` - - `ALTER ADD INDEX` - - `ALTER CLEAR INDEX` - - `ALTER DROP INDEX` - - `ALTER MATERIALIZE INDEX` - - `ALTER ORDER BY` - - `ALTER SAMPLE BY` - - `ALTER MATERIALIZE TTL` - - `ALTER MODIFY COMMENT` - - `ALTER MOVE PARTITION` - - `ALTER PROJECTION` - - `ALTER SETTINGS` - - `ALTER STATISTICS` - - `ALTER ADD STATISTICS` - - `ALTER DROP STATISTICS` - - `ALTER MATERIALIZE STATISTICS` - - `ALTER MODIFY STATISTICS` - - `ALTER TTL` - - `ALTER UPDATE` - - `ALTER VIEW` - - `ALTER VIEW MODIFY QUERY` - - `ALTER VIEW REFRESH` - - `ALTER VIEW MODIFY SQL SECURITY` - - [`BACKUP`](#backup) - - [`CLUSTER`](#cluster) - - [`CREATE`](#create) - - `CREATE ARBITRARY TEMPORARY TABLE` - - `CREATE TEMPORARY TABLE` - - `CREATE DATABASE` - - `CREATE DICTIONARY` - - `CREATE FUNCTION` - - `CREATE RESOURCE` - - `CREATE TABLE` - - `CREATE VIEW` - - `CREATE WORKLOAD` - - [`dictGet`](#dictget) - - [`displaySecretsInShowAndSelect`](#displaysecretsinshowandselect) - - [`DROP`](#drop) - - `DROP DATABASE` - - `DROP DICTIONARY` - - `DROP FUNCTION` - - `DROP RESOURCE` - - `DROP TABLE` - - `DROP VIEW` - - `DROP WORKLOAD` - - [`INSERT`](#insert) - - [`INTROSPECTION`](#introspection) - - `addressToLine` - - `addressToLineWithInlines` - - `addressToSymbol` - - `demangle` - - `KILL QUERY` - - `KILL TRANSACTION` - - `MOVE PARTITION BETWEEN SHARDS` - - [`NAMED COLLECTION ADMIN`](#named-collection-admin) - - `ALTER NAMED COLLECTION` - - `CREATE NAMED COLLECTION` - - `DROP NAMED COLLECTION` - - `NAMED COLLECTION` - - `SHOW NAMED COLLECTIONS` - - `SHOW NAMED COLLECTIONS SECRETS` - - [`OPTIMIZE`](#optimize) - - [`SELECT`](#select) - - [`SET DEFINER`](/sql-reference/statements/create/view#sql_security) - - [`SHOW`](#show) - - `SHOW COLUMNS` - - `SHOW DATABASES` - - `SHOW DICTIONARIES` - - `SHOW TABLES` - - `SHOW FILESYSTEM CACHES` - - [`SOURCES`](#sources) - - `AZURE` - - `FILE` - - `HDFS` - - `HIVE` - - `JDBC` - - `KAFKA` - - `MONGO` - - `MYSQL` - - `NATS` - - `ODBC` - - `POSTGRES` - - `RABBITMQ` - - `REDIS` - - `REMOTE` - - `S3` - - `SQLITE` - - `URL` - - [`SYSTEM`](#system) - - `SYSTEM CLEANUP` - - `SYSTEM DROP CACHE` - - `SYSTEM DROP COMPILED EXPRESSION CACHE` - - `SYSTEM DROP CONNECTIONS CACHE` - - `SYSTEM DROP DISTRIBUTED CACHE` - - `SYSTEM DROP DNS CACHE` - - `SYSTEM DROP FILESYSTEM CACHE` - - `SYSTEM DROP FORMAT SCHEMA CACHE` - - `SYSTEM DROP MARK CACHE` - - `SYSTEM DROP MMAP CACHE` - - `SYSTEM DROP PAGE CACHE` - - `SYSTEM DROP PRIMARY INDEX CACHE` - - `SYSTEM DROP QUERY CACHE` - - `SYSTEM DROP S3 CLIENT CACHE` - - `SYSTEM DROP SCHEMA CACHE` - - `SYSTEM DROP UNCOMPRESSED CACHE` - - `SYSTEM DROP PRIMARY INDEX CACHE` - - `SYSTEM DROP REPLICA` - - `SYSTEM FAILPOINT` - - `SYSTEM FETCHES` - - `SYSTEM FLUSH` - - `SYSTEM FLUSH ASYNC INSERT QUEUE` - - `SYSTEM FLUSH LOGS` - - `SYSTEM JEMALLOC` - - `SYSTEM KILL QUERY` - - `SYSTEM KILL TRANSACTION` - - `SYSTEM LISTEN` - - `SYSTEM LOAD PRIMARY KEY` - - `SYSTEM MERGES` - - `SYSTEM MOVES` - - `SYSTEM PULLING REPLICATION LOG` - - `SYSTEM REDUCE BLOCKING PARTS` - - `SYSTEM REPLICATION QUEUES` - - `SYSTEM REPLICA READINESS` - - `SYSTEM RESTART DISK` - - `SYSTEM RESTART REPLICA` - - `SYSTEM RESTORE REPLICA` - - `SYSTEM RELOAD` - - `SYSTEM RELOAD ASYNCHRONOUS METRICS` - - `SYSTEM RELOAD CONFIG` - - `SYSTEM RELOAD DICTIONARY` - - `SYSTEM RELOAD EMBEDDED DICTIONARIES` - - `SYSTEM RELOAD FUNCTION` - - `SYSTEM RELOAD MODEL` - - `SYSTEM RELOAD USERS` - - `SYSTEM SENDS` - - `SYSTEM DISTRIBUTED SENDS` - - `SYSTEM REPLICATED SENDS` - - `SYSTEM SHUTDOWN` - - `SYSTEM SYNC DATABASE REPLICA` - - `SYSTEM SYNC FILE CACHE` - - `SYSTEM SYNC FILESYSTEM CACHE` - - `SYSTEM SYNC REPLICA` - - `SYSTEM SYNC TRANSACTION LOG` - - `SYSTEM THREAD FUZZER` - - `SYSTEM TTL MERGES` - - `SYSTEM UNFREEZE` - - `SYSTEM UNLOAD PRIMARY KEY` - - `SYSTEM VIEWS` - - `SYSTEM VIRTUAL PARTS UPDATE` - - `SYSTEM WAIT LOADING PARTS` - - [`TABLE ENGINE`](#table-engine) - - [`TRUNCATE`](#truncate) - - `UNDROP TABLE` + - [`ACCESS MANAGEMENT`](#access-management) + - `ALLOW SQL SECURITY NONE` + - `ALTER QUOTA` + - `ALTER ROLE` + - `ALTER ROW POLICY` + - `ALTER SETTINGS PROFILE` + - `ALTER USER` + - `CREATE QUOTA` + - `CREATE ROLE` + - `CREATE ROW POLICY` + - `CREATE SETTINGS PROFILE` + - `CREATE USER` + - `DROP QUOTA` + - `DROP ROLE` + - `DROP ROW POLICY` + - `DROP SETTINGS PROFILE` + - `DROP USER` + - `ROLE ADMIN` + - `SHOW ACCESS` + - `SHOW QUOTAS` + - `SHOW ROLES` + - `SHOW ROW POLICIES` + - `SHOW SETTINGS PROFILES` + - `SHOW USERS` + - [`ALTER`](#alter) + - `ALTER DATABASE` + - `ALTER DATABASE SETTINGS` + - `ALTER TABLE` + - `ALTER COLUMN` + - `ALTER ADD COLUMN` + - `ALTER CLEAR COLUMN` + - `ALTER COMMENT COLUMN` + - `ALTER DROP COLUMN` + - `ALTER MATERIALIZE COLUMN` + - `ALTER MODIFY COLUMN` + - `ALTER RENAME COLUMN` + - `ALTER CONSTRAINT` + - `ALTER ADD CONSTRAINT` + - `ALTER DROP CONSTRAINT` + - `ALTER DELETE` + - `ALTER FETCH PARTITION` + - `ALTER FREEZE PARTITION` + - `ALTER INDEX` + - `ALTER ADD INDEX` + - `ALTER CLEAR INDEX` + - `ALTER DROP INDEX` + - `ALTER MATERIALIZE INDEX` + - `ALTER ORDER BY` + - `ALTER SAMPLE BY` + - `ALTER MATERIALIZE TTL` + - `ALTER MODIFY COMMENT` + - `ALTER MOVE PARTITION` + - `ALTER PROJECTION` + - `ALTER SETTINGS` + - `ALTER STATISTICS` + - `ALTER ADD STATISTICS` + - `ALTER DROP STATISTICS` + - `ALTER MATERIALIZE STATISTICS` + - `ALTER MODIFY STATISTICS` + - `ALTER TTL` + - `ALTER UPDATE` + - `ALTER VIEW` + - `ALTER VIEW MODIFY QUERY` + - `ALTER VIEW REFRESH` + - `ALTER VIEW MODIFY SQL SECURITY` + - [`BACKUP`](#backup) + - [`CLUSTER`](#cluster) + - [`CREATE`](#create) + - `CREATE ARBITRARY TEMPORARY TABLE` + - `CREATE TEMPORARY TABLE` + - `CREATE DATABASE` + - `CREATE DICTIONARY` + - `CREATE FUNCTION` + - `CREATE RESOURCE` + - `CREATE TABLE` + - `CREATE VIEW` + - `CREATE WORKLOAD` + - [`dictGet`](#dictget) + - [`displaySecretsInShowAndSelect`](#displaysecretsinshowandselect) + - [`DROP`](#drop) + - `DROP DATABASE` + - `DROP DICTIONARY` + - `DROP FUNCTION` + - `DROP RESOURCE` + - `DROP TABLE` + - `DROP VIEW` + - `DROP WORKLOAD` + - [`INSERT`](#insert) + - [`INTROSPECTION`](#introspection) + - `addressToLine` + - `addressToLineWithInlines` + - `addressToSymbol` + - `demangle` + - `KILL QUERY` + - `KILL TRANSACTION` + - `MOVE PARTITION BETWEEN SHARDS` + - [`NAMED COLLECTION ADMIN`](#named-collection-admin) + - `ALTER NAMED COLLECTION` + - `CREATE NAMED COLLECTION` + - `DROP NAMED COLLECTION` + - `NAMED COLLECTION` + - `SHOW NAMED COLLECTIONS` + - `SHOW NAMED COLLECTIONS SECRETS` + - [`OPTIMIZE`](#optimize) + - [`SELECT`](#select) + - [`SET DEFINER`](/sql-reference/statements/create/view#sql_security) + - [`SHOW`](#show) + - `SHOW COLUMNS` + - `SHOW DATABASES` + - `SHOW DICTIONARIES` + - `SHOW TABLES` + - `SHOW FILESYSTEM CACHES` + - [`SOURCES`](#sources) + - `AZURE` + - `FILE` + - `HDFS` + - `HIVE` + - `JDBC` + - `KAFKA` + - `MONGO` + - `MYSQL` + - `NATS` + - `ODBC` + - `POSTGRES` + - `RABBITMQ` + - `REDIS` + - `REMOTE` + - `S3` + - `SQLITE` + - `URL` + - [`SYSTEM`](#system) + - `SYSTEM CLEANUP` + - `SYSTEM DROP CACHE` + - `SYSTEM DROP COMPILED EXPRESSION CACHE` + - `SYSTEM DROP CONNECTIONS CACHE` + - `SYSTEM DROP DISTRIBUTED CACHE` + - `SYSTEM DROP DNS CACHE` + - `SYSTEM DROP FILESYSTEM CACHE` + - `SYSTEM DROP FORMAT SCHEMA CACHE` + - `SYSTEM DROP MARK CACHE` + - `SYSTEM DROP MMAP CACHE` + - `SYSTEM DROP PAGE CACHE` + - `SYSTEM DROP PRIMARY INDEX CACHE` + - `SYSTEM DROP QUERY CACHE` + - `SYSTEM DROP S3 CLIENT CACHE` + - `SYSTEM DROP SCHEMA CACHE` + - `SYSTEM DROP UNCOMPRESSED CACHE` + - `SYSTEM DROP PRIMARY INDEX CACHE` + - `SYSTEM DROP REPLICA` + - `SYSTEM FAILPOINT` + - `SYSTEM FETCHES` + - `SYSTEM FLUSH` + - `SYSTEM FLUSH ASYNC INSERT QUEUE` + - `SYSTEM FLUSH LOGS` + - `SYSTEM JEMALLOC` + - `SYSTEM KILL QUERY` + - `SYSTEM KILL TRANSACTION` + - `SYSTEM LISTEN` + - `SYSTEM LOAD PRIMARY KEY` + - `SYSTEM MERGES` + - `SYSTEM MOVES` + - `SYSTEM PULLING REPLICATION LOG` + - `SYSTEM REDUCE BLOCKING PARTS` + - `SYSTEM REPLICATION QUEUES` + - `SYSTEM REPLICA READINESS` + - `SYSTEM RESTART DISK` + - `SYSTEM RESTART REPLICA` + - `SYSTEM RESTORE REPLICA` + - `SYSTEM RELOAD` + - `SYSTEM RELOAD ASYNCHRONOUS METRICS` + - `SYSTEM RELOAD CONFIG` + - `SYSTEM RELOAD DICTIONARY` + - `SYSTEM RELOAD EMBEDDED DICTIONARIES` + - `SYSTEM RELOAD FUNCTION` + - `SYSTEM RELOAD MODEL` + - `SYSTEM RELOAD USERS` + - `SYSTEM SENDS` + - `SYSTEM DISTRIBUTED SENDS` + - `SYSTEM REPLICATED SENDS` + - `SYSTEM SHUTDOWN` + - `SYSTEM SYNC DATABASE REPLICA` + - `SYSTEM SYNC FILE CACHE` + - `SYSTEM SYNC FILESYSTEM CACHE` + - `SYSTEM SYNC REPLICA` + - `SYSTEM SYNC TRANSACTION LOG` + - `SYSTEM THREAD FUZZER` + - `SYSTEM TTL MERGES` + - `SYSTEM UNFREEZE` + - `SYSTEM UNLOAD PRIMARY KEY` + - `SYSTEM VIEWS` + - `SYSTEM VIRTUAL PARTS UPDATE` + - `SYSTEM WAIT LOADING PARTS` + - [`TABLE ENGINE`](#table-engine) + - [`TRUNCATE`](#truncate) + - `UNDROP TABLE` - [`NONE`](#none) -如何处理此层次结构的示例: +该层次结构处理的示例: -- `ALTER` 权限包含所有其他 `ALTER*` 权限。 +- `ALTER` 权限包括所有其他 `ALTER*` 权限。 - `ALTER CONSTRAINT` 包括 `ALTER ADD CONSTRAINT` 和 `ALTER DROP CONSTRAINT` 权限。 -权限适用于不同级别。了解一个级别指示可用于权限的语法。 +权限在不同层次上应用。了解某个层次可以指示可用于权限的语法。 -级别(从低到高): +层次(从低到高): -- `COLUMN` — 权限可以针对列、表、数据库或全局授予。 -- `TABLE` — 权限可以针对表、数据库或全局授予。 -- `VIEW` — 权限可以针对视图、数据库或全局授予。 -- `DICTIONARY` — 权限可以针对字典、数据库或全局授予。 -- `DATABASE` — 权限可以针对数据库或全局授予。 -- `GLOBAL` — 权限只能针对全局授予。 -- `GROUP` — 将不同级别的权限分组。当授予 `GROUP` 级别的权限时,仅授予与所用语法对应的权限。 +- `COLUMN` - 权限可授予列、表、数据库或全局。 +- `TABLE` - 权限可授予表、数据库或全局。 +- `VIEW` - 权限可授予视图、数据库或全局。 +- `DICTIONARY` - 权限可授予字典、数据库或全局。 +- `DATABASE` - 权限可授予数据库或全局。 +- `GLOBAL` - 权限只能全局授予。 +- `GROUP` - 将不同层次的权限分组。当授予 `GROUP` 级别的权限时,仅授予与所用语法对应的权限。 -允许语法的示例: +允许的语法示例: - `GRANT SELECT(x) ON db.table TO user` - `GRANT SELECT ON db.* TO user` @@ -358,13 +364,13 @@ ClickHouse 中权限的层次结构如下所示: - `GRANT CREATE USER(x) ON db.table TO user` - `GRANT CREATE USER ON db.* TO user` -特殊权限 [ALL](#all) 授予用户帐户或角色所有权限。 +特殊权限 [ALL](#all) 将所有权限授予用户账户或角色。 -默认情况下,用户帐户或角色没有任何权限。 +默认情况下,用户账户或角色没有权限。 -如果用户或角色没有权限,则以 [NONE](#none) 权限显示。 +如果用户或角色没有权限,则显示为 [NONE](#none) 权限。 -某些查询由于其实现需要一组权限。例如,要执行 [RENAME](../../sql-reference/statements/optimize.md) 查询,您需要以下权限:`SELECT`、`CREATE TABLE`、`INSERT` 和 `DROP TABLE`。 +某些查询根据其实现需要一组权限。例如,要执行 [RENAME](../../sql-reference/statements/optimize.md) 查询,您需要以下权限:`SELECT`、`CREATE TABLE`、`INSERT` 和 `DROP TABLE`。 ### SELECT {#select} @@ -374,7 +380,7 @@ ClickHouse 中权限的层次结构如下所示: **描述** -具有此权限的用户可以在指定表和数据库中的指定列列表上执行 `SELECT` 查询。如果用户包含其他列,则指定查询返回无数据。 +获得此权限的用户可以在指定的表和数据库上针对指定列列表执行 `SELECT` 查询。如果用户包括其他列,则指定的查询不会返回数据。 考虑以下权限: @@ -382,7 +388,7 @@ ClickHouse 中权限的层次结构如下所示: GRANT SELECT(x,y) ON db.table TO john ``` -该权限允许 `john` 执行涉及 `db.table` 中 `x` 和/或 `y` 列数据的任何 `SELECT` 查询,例如 `SELECT x FROM db.table`。 `john` 无法执行 `SELECT z FROM db.table`。 `SELECT * FROM db.table` 也不可用。处理此查询时,ClickHouse 不会返回任何数据,即使是 `x` 和 `y`。唯一的例外是,如果表只包含 `x` 和 `y` 列,在这种情况下 ClickHouse 返回所有数据。 +该权限允许 `john` 执行任何涉及 `db.table` 的 `x` 和/或 `y` 列数据的 `SELECT` 查询,例如,`SELECT x FROM db.table`。`john` 无法执行 `SELECT z FROM db.table`。`SELECT * FROM db.table` 也不可用。在处理此查询时,ClickHouse 不会返回任何数据,即使是 `x` 和 `y`。唯一的例外是,如果一个表仅包含 `x` 和 `y` 列,这种情况下 ClickHouse 返回所有数据。 ### INSERT {#insert} @@ -392,7 +398,7 @@ GRANT SELECT(x,y) ON db.table TO john **描述** -具有此权限的用户可以在指定表和数据库中的指定列列表上执行 `INSERT` 查询。如果用户包含其他列,则指定查询不会插入任何数据。 +获得此权限的用户可以在指定的表和数据库上针对指定列列表执行 `INSERT` 查询。如果用户包括其他列,则指定的查询不会插入任何数据。 **示例** @@ -407,86 +413,85 @@ GRANT INSERT(x,y) ON db.table TO john 允许根据以下权限层次结构执行 [ALTER](../../sql-reference/statements/alter/index.md) 查询: - `ALTER`。级别:`COLUMN`。 - - `ALTER TABLE`。级别:`GROUP` - - `ALTER UPDATE`。级别:`COLUMN`。别名:`UPDATE` - - `ALTER DELETE`。级别:`COLUMN`。别名:`DELETE` - - `ALTER COLUMN`。级别:`GROUP` - - `ALTER ADD COLUMN`。级别:`COLUMN`。别名:`ADD COLUMN` - - `ALTER DROP COLUMN`。级别:`COLUMN`。别名:`DROP COLUMN` - - `ALTER MODIFY COLUMN`。级别:`COLUMN`。别名:`MODIFY COLUMN` - - `ALTER COMMENT COLUMN`。级别:`COLUMN`。别名:`COMMENT COLUMN` - - `ALTER CLEAR COLUMN`。级别:`COLUMN`。别名:`CLEAR COLUMN` - - `ALTER RENAME COLUMN`。级别:`COLUMN`。别名:`RENAME COLUMN` - - `ALTER INDEX`。级别:`GROUP`。别名:`INDEX` - - `ALTER ORDER BY`。级别:`TABLE`。别名:`ALTER MODIFY ORDER BY`、`MODIFY ORDER BY` - - `ALTER SAMPLE BY`。级别:`TABLE`。别名:`ALTER MODIFY SAMPLE BY`、`MODIFY SAMPLE BY` - - `ALTER ADD INDEX`。级别:`TABLE`。别名:`ADD INDEX` - - `ALTER DROP INDEX`。级别:`TABLE`。别名:`DROP INDEX` - - `ALTER MATERIALIZE INDEX`。级别:`TABLE`。别名:`MATERIALIZE INDEX` - - `ALTER CLEAR INDEX`。级别:`TABLE`。别名:`CLEAR INDEX` - - `ALTER CONSTRAINT`。级别:`GROUP`。别名:`CONSTRAINT` - - `ALTER ADD CONSTRAINT`。级别:`TABLE`。别名:`ADD CONSTRAINT` - - `ALTER DROP CONSTRAINT`。级别:`TABLE`。别名:`DROP CONSTRAINT` - - `ALTER TTL`。级别:`TABLE`。别名:`ALTER MODIFY TTL`、`MODIFY TTL` - - `ALTER MATERIALIZE TTL`。级别:`TABLE`。别名:`MATERIALIZE TTL` - - `ALTER SETTINGS`。级别:`TABLE`。别名:`ALTER SETTING`、`ALTER MODIFY SETTING`、`MODIFY SETTING` - - `ALTER MOVE PARTITION`。级别:`TABLE`。别名:`ALTER MOVE PART`、`MOVE PARTITION`、`MOVE PART` - - `ALTER FETCH PARTITION`。级别:`TABLE`。别名:`ALTER FETCH PART`、`FETCH PARTITION`、`FETCH PART` - - `ALTER FREEZE PARTITION`。级别:`TABLE`。别名:`FREEZE PARTITION` - - `ALTER VIEW` 级别:`GROUP` - - `ALTER VIEW REFRESH`。级别:`VIEW`。别名:`ALTER LIVE VIEW REFRESH`、`REFRESH VIEW` - - `ALTER VIEW MODIFY QUERY`。级别:`VIEW`。别名:`ALTER TABLE MODIFY QUERY` - - `ALTER VIEW MODIFY SQL SECURITY`。级别:`VIEW`。别名:`ALTER TABLE MODIFY SQL SECURITY` + - `ALTER TABLE`。级别:`GROUP` + - `ALTER UPDATE`。级别:`COLUMN`。别名:`UPDATE` + - `ALTER DELETE`。级别:`COLUMN`。别名:`DELETE` + - `ALTER COLUMN`。级别:`GROUP` + - `ALTER ADD COLUMN`。级别:`COLUMN`。别名:`ADD COLUMN` + - `ALTER DROP COLUMN`。级别:`COLUMN`。别名:`DROP COLUMN` + - `ALTER MODIFY COLUMN`。级别:`COLUMN`。别名:`MODIFY COLUMN` + - `ALTER COMMENT COLUMN`。级别:`COLUMN`。别名:`COMMENT COLUMN` + - `ALTER CLEAR COLUMN`。级别:`COLUMN`。别名:`CLEAR COLUMN` + - `ALTER RENAME COLUMN`。级别:`COLUMN`。别名:`RENAME COLUMN` + - `ALTER INDEX`。级别:`GROUP`。别名:`INDEX` + - `ALTER ORDER BY`。级别:`TABLE`。别名:`ALTER MODIFY ORDER BY`、`MODIFY ORDER BY` + - `ALTER SAMPLE BY`。级别:`TABLE`。别名:`ALTER MODIFY SAMPLE BY`、`MODIFY SAMPLE BY` + - `ALTER ADD INDEX`。级别:`TABLE`。别名:`ADD INDEX` + - `ALTER DROP INDEX`。级别:`TABLE`。别名:`DROP INDEX` + - `ALTER MATERIALIZE INDEX`。级别:`TABLE`。别名:`MATERIALIZE INDEX` + - `ALTER CLEAR INDEX`。级别:`TABLE`。别名:`CLEAR INDEX` + - `ALTER CONSTRAINT`。级别:`GROUP`。别名:`CONSTRAINT` + - `ALTER ADD CONSTRAINT`。级别:`TABLE`。别名:`ADD CONSTRAINT` + - `ALTER DROP CONSTRAINT`。级别:`TABLE`。别名:`DROP CONSTRAINT` + - `ALTER TTL`。级别:`TABLE`。别名:`ALTER MODIFY TTL`、`MODIFY TTL` + - `ALTER MATERIALIZE TTL`。级别:`TABLE`。别名:`MATERIALIZE TTL` + - `ALTER SETTINGS`。级别:`TABLE`。别名:`ALTER SETTING`、`ALTER MODIFY SETTING`、`MODIFY SETTING` + - `ALTER MOVE PARTITION`。级别:`TABLE`。别名:`ALTER MOVE PART`、`MOVE PARTITION`、`MOVE PART` + - `ALTER FETCH PARTITION`。级别:`TABLE`。别名:`ALTER FETCH PART`、`FETCH PARTITION`、`FETCH PART` + - `ALTER FREEZE PARTITION`。级别:`TABLE`。别名:`FREEZE PARTITION` + - `ALTER VIEW`。级别:`GROUP` + - `ALTER VIEW REFRESH`。级别:`VIEW`。别名:`ALTER LIVE VIEW REFRESH`、`REFRESH VIEW` + - `ALTER VIEW MODIFY QUERY`。级别:`VIEW`。别名:`ALTER TABLE MODIFY QUERY` + - `ALTER VIEW MODIFY SQL SECURITY`。级别:`VIEW`。别名:`ALTER TABLE MODIFY SQL SECURITY` 如何处理此层次结构的示例: -- `ALTER` 权限包含所有其他 `ALTER*` 权限。 +- `ALTER` 权限包括所有其他 `ALTER*` 权限。 - `ALTER CONSTRAINT` 包括 `ALTER ADD CONSTRAINT` 和 `ALTER DROP CONSTRAINT` 权限。 -**注意** +**备注** -- `MODIFY SETTING` 权限允许修改表引擎设置。它不会影响设置或服务器配置参数。 +- `MODIFY SETTING` 权限允许修改表引擎设置。它不影响设置或服务器配置参数。 - `ATTACH` 操作需要 [CREATE](#create) 权限。 - `DETACH` 操作需要 [DROP](#drop) 权限。 -- 要通过 [KILL MUTATION](../../sql-reference/statements/kill.md#kill-mutation) 查询停止变更,您需要拥有启动该变更的权限。例如,如果要停止 `ALTER UPDATE` 查询,则需要 `ALTER UPDATE`、`ALTER TABLE` 或 `ALTER` 权限。 +- 要通过 [KILL MUTATION](../../sql-reference/statements/kill.md#kill-mutation) 查询停止突变,您需要有权启动此突变。例如,如果您想停止 `ALTER UPDATE` 查询,则需要 `ALTER UPDATE`、`ALTER TABLE` 或 `ALTER` 权限。 ### BACKUP {#backup} -允许执行 [`BACKUP`] 查询。有关备份的更多信息,请参见 ["备份与恢复"](../../operations/backup.md)。 +允许在查询中执行 [`BACKUP`]。有关备份的更多信息,请参阅 ["备份和恢复"](../../operations/backup.md)。 ### CREATE {#create} 允许根据以下权限层次结构执行 [CREATE](../../sql-reference/statements/create/index.md) 和 [ATTACH](../../sql-reference/statements/attach.md) DDL 查询: - `CREATE`。级别:`GROUP` - - `CREATE DATABASE`。级别:`DATABASE` - - `CREATE TABLE`。级别:`TABLE` - - `CREATE ARBITRARY TEMPORARY TABLE`。级别:`GLOBAL` - - `CREATE TEMPORARY TABLE`。级别:`GLOBAL` - - `CREATE VIEW`。级别:`VIEW` - - `CREATE DICTIONARY`。级别:`DICTIONARY` + - `CREATE DATABASE`。级别:`DATABASE` + - `CREATE TABLE`。级别:`TABLE` + - `CREATE ARBITRARY TEMPORARY TABLE`。级别:`GLOBAL` + - `CREATE TEMPORARY TABLE`。级别:`GLOBAL` + - `CREATE VIEW`。级别:`VIEW` + - `CREATE DICTIONARY`。级别:`DICTIONARY` -**注意** +**备注** - 要删除创建的表,用户需要 [DROP](#drop) 权限。 ### CLUSTER {#cluster} -允许执行 `ON CLUSTER` 查询。 +允许执行带有 `ON CLUSTER` 的查询。 ```sql title="Syntax" GRANT CLUSTER ON *.* TO ``` -默认情况下,带有 `ON CLUSTER` 的查询要求用户拥有 `CLUSTER` 权限。 -如果您尝试在没有首先授予 `CLUSTER` 权限的情况下在查询中使用 `ON CLUSTER`,将会收到以下错误: +默认情况下,带有 `ON CLUSTER` 的查询需要用户具有 `CLUSTER` 授权。 +如果您在没有首先授予 `CLUSTER` 权限的情况下尝试在查询中使用 `ON CLUSTER`,则会收到以下错误: ```text Not enough privileges. To execute this query, it's necessary to have the grant CLUSTER ON *.*. ``` -通过设置 `on_cluster_queries_require_cluster_grant` 设置,可以更改默认行为, -该设置位于 `config.xml` 的 `access_control_improvements` 部分(见下文),设置为 `false`。 +默认行为可以通过将 `on_cluster_queries_require_cluster_grant` 设置为 `false` 来更改,该设置位于 `config.xml` 的 `access_control_improvements` 部分(见下文)。 ```yaml title="config.xml" @@ -499,10 +504,10 @@ Not enough privileges. To execute this query, it's necessary to have the grant C 允许根据以下权限层次结构执行 [DROP](../../sql-reference/statements/drop.md) 和 [DETACH](../../sql-reference/statements/detach.md) 查询: - `DROP`。级别:`GROUP` - - `DROP DATABASE`。级别:`DATABASE` - - `DROP TABLE`。级别:`TABLE` - - `DROP VIEW`。级别:`VIEW` - - `DROP DICTIONARY`。级别:`DICTIONARY` + - `DROP DATABASE`。级别:`DATABASE` + - `DROP TABLE`。级别:`TABLE` + - `DROP VIEW`。级别:`VIEW` + - `DROP DICTIONARY`。级别:`DICTIONARY` ### TRUNCATE {#truncate} @@ -518,17 +523,17 @@ Not enough privileges. To execute this query, it's necessary to have the grant C ### SHOW {#show} -允许执行 `SHOW`、`DESCRIBE`、`USE` 和 `EXISTS` 查询,依据以下权限层次结构: +允许根据以下权限层次结构执行 `SHOW`、`DESCRIBE`、`USE` 和 `EXISTS` 查询: - `SHOW`。级别:`GROUP` - - `SHOW DATABASES`。级别:`DATABASE`。允许执行 `SHOW DATABASES`、`SHOW CREATE DATABASE`、`USE ` 查询。 - - `SHOW TABLES`。级别:`TABLE`。允许执行 `SHOW TABLES`、`EXISTS
`、`CHECK
` 查询。 - - `SHOW COLUMNS`。级别:`COLUMN`。允许执行 `SHOW CREATE TABLE`、`DESCRIBE` 查询。 - - `SHOW DICTIONARIES`。级别:`DICTIONARY`。允许执行 `SHOW DICTIONARIES`、`SHOW CREATE DICTIONARY`、`EXISTS ` 查询。 + - `SHOW DATABASES`。级别:`DATABASE`。允许执行 `SHOW DATABASES`、`SHOW CREATE DATABASE`、`USE ` 查询。 + - `SHOW TABLES`。级别:`TABLE`。允许执行 `SHOW TABLES`、`EXISTS
`、`CHECK
` 查询。 + - `SHOW COLUMNS`。级别:`COLUMN`。允许执行 `SHOW CREATE TABLE`、`DESCRIBE` 查询。 + - `SHOW DICTIONARIES`。级别:`DICTIONARY`。允许执行 `SHOW DICTIONARIES`、`SHOW CREATE DICTIONARY`、`EXISTS ` 查询。 -**注意** +**备注** -如果用户对指定的表、字典或数据库有任何其他权限,则用户拥有 `SHOW` 权限。 +如果用户拥有与指定表、字典或数据库相关的任何其他权限,则该用户具有 `SHOW` 权限。 ### KILL QUERY {#kill-query} @@ -536,7 +541,7 @@ Not enough privileges. To execute this query, it's necessary to have the grant C 权限级别:`GLOBAL`。 -**注意** +**备注** `KILL QUERY` 权限允许一个用户终止其他用户的查询。 @@ -545,59 +550,59 @@ Not enough privileges. To execute this query, it's necessary to have the grant C 允许用户执行管理用户、角色和行策略的查询。 - `ACCESS MANAGEMENT`。级别:`GROUP` - - `CREATE USER`。级别:`GLOBAL` - - `ALTER USER`。级别:`GLOBAL` - - `DROP USER`。级别:`GLOBAL` - - `CREATE ROLE`。级别:`GLOBAL` - - `ALTER ROLE`。级别:`GLOBAL` - - `DROP ROLE`。级别:`GLOBAL` - - `ROLE ADMIN`。级别:`GLOBAL` - - `CREATE ROW POLICY`。级别:`GLOBAL`。别名:`CREATE POLICY` - - `ALTER ROW POLICY`。级别:`GLOBAL`。别名:`ALTER POLICY` - - `DROP ROW POLICY`。级别:`GLOBAL`。别名:`DROP POLICY` - - `CREATE QUOTA`。级别:`GLOBAL` - - `ALTER QUOTA`。级别:`GLOBAL` - - `DROP QUOTA`。级别:`GLOBAL` - - `CREATE SETTINGS PROFILE`。级别:`GLOBAL`。别名:`CREATE PROFILE` - - `ALTER SETTINGS PROFILE`。级别:`GLOBAL`。别名:`ALTER PROFILE` - - `DROP SETTINGS PROFILE`。级别:`GLOBAL`。别名:`DROP PROFILE` - - `SHOW ACCESS`。级别:`GROUP` - - `SHOW_USERS`。级别:`GLOBAL`。别名:`SHOW CREATE USER` - - `SHOW_ROLES`。级别:`GLOBAL`。别名:`SHOW CREATE ROLE` - - `SHOW_ROW_POLICIES`。级别:`GLOBAL`。别名:`SHOW POLICIES`、`SHOW CREATE ROW POLICY`、`SHOW CREATE POLICY` - - `SHOW_QUOTAS`。级别:`GLOBAL`。别名:`SHOW CREATE QUOTA` - - `SHOW_SETTINGS_PROFILES`。级别:`GLOBAL`。别名:`SHOW PROFILES`、`SHOW CREATE SETTINGS PROFILE`、`SHOW CREATE PROFILE` - - `ALLOW SQL SECURITY NONE`。级别:`GLOBAL`。别名:`CREATE SQL SECURITY NONE`、`SQL SECURITY NONE`、`SECURITY NONE` - -`ROLE ADMIN` 权限允许用户分配和撤销任何角色,包括未分配给管理员选项的角色。 + - `CREATE USER`。级别:`GLOBAL` + - `ALTER USER`。级别:`GLOBAL` + - `DROP USER`。级别:`GLOBAL` + - `CREATE ROLE`。级别:`GLOBAL` + - `ALTER ROLE`。级别:`GLOBAL` + - `DROP ROLE`。级别:`GLOBAL` + - `ROLE ADMIN`。级别:`GLOBAL` + - `CREATE ROW POLICY`。级别:`GLOBAL`。别名:`CREATE POLICY` + - `ALTER ROW POLICY`。级别:`GLOBAL`。别名:`ALTER POLICY` + - `DROP ROW POLICY`。级别:`GLOBAL`。别名:`DROP POLICY` + - `CREATE QUOTA`。级别:`GLOBAL` + - `ALTER QUOTA`。级别:`GLOBAL` + - `DROP QUOTA`。级别:`GLOBAL` + - `CREATE SETTINGS PROFILE`。级别:`GLOBAL`。别名:`CREATE PROFILE` + - `ALTER SETTINGS PROFILE`。级别:`GLOBAL`。别名:`ALTER PROFILE` + - `DROP SETTINGS PROFILE`。级别:`GLOBAL`。别名:`DROP PROFILE` + - `SHOW ACCESS`。级别:`GROUP` + - `SHOW_USERS`。级别:`GLOBAL`。别名:`SHOW CREATE USER` + - `SHOW_ROLES`。级别:`GLOBAL`。别名:`SHOW CREATE ROLE` + - `SHOW_ROW_POLICIES`。级别:`GLOBAL`。别名:`SHOW POLICIES`、`SHOW CREATE ROW POLICY`、`SHOW CREATE POLICY` + - `SHOW_QUOTAS`。级别:`GLOBAL`。别名:`SHOW CREATE QUOTA` + - `SHOW_SETTINGS_PROFILES`。级别:`GLOBAL`。别名:`SHOW PROFILES`、`SHOW CREATE SETTINGS PROFILE`、`SHOW CREATE PROFILE` + - `ALLOW SQL SECURITY NONE`。级别:`GLOBAL`。别名:`CREATE SQL SECURITY NONE`、`SQL SECURITY NONE`、`SECURITY NONE` + +`ROLE ADMIN` 权限允许用户分配和撤销任何角色,包括未分配给具有管理员选项的用户的角色。 ### SYSTEM {#system} 允许用户根据以下权限层次结构执行 [SYSTEM](../../sql-reference/statements/system.md) 查询。 - `SYSTEM`。级别:`GROUP` - - `SYSTEM SHUTDOWN`。级别:`GLOBAL`。别名:`SYSTEM KILL`、`SHUTDOWN` - - `SYSTEM DROP CACHE`。别名:`DROP CACHE` - - `SYSTEM DROP DNS CACHE`。级别:`GLOBAL`。别名:`SYSTEM DROP DNS`、`DROP DNS CACHE`、`DROP DNS` - - `SYSTEM DROP MARK CACHE`。级别:`GLOBAL`。别名:`SYSTEM DROP MARK`、`DROP MARK CACHE`、`DROP MARKS` - - `SYSTEM DROP UNCOMPRESSED CACHE`。级别:`GLOBAL`。别名:`SYSTEM DROP UNCOMPRESSED`、`DROP UNCOMPRESSED CACHE`、`DROP UNCOMPRESSED` - - `SYSTEM RELOAD`。级别:`GROUP` - - `SYSTEM RELOAD CONFIG`。级别:`GLOBAL`。别名:`RELOAD CONFIG` - - `SYSTEM RELOAD DICTIONARY`。级别:`GLOBAL`。别名:`SYSTEM RELOAD DICTIONARIES`、`RELOAD DICTIONARY`、`RELOAD DICTIONARIES` - - `SYSTEM RELOAD EMBEDDED DICTIONARIES`。级别:`GLOBAL`。别名:`RELOAD EMBEDDED DICTIONARIES` - - `SYSTEM MERGES`。级别:`TABLE`。别名:`SYSTEM STOP MERGES`、`SYSTEM START MERGES`、`STOP MERGES`、`START MERGES` - - `SYSTEM TTL MERGES`。级别:`TABLE`。别名:`SYSTEM STOP TTL MERGES`、`SYSTEM START TTL MERGES`、`STOP TTL MERGES`、`START TTL MERGES` - - `SYSTEM FETCHES`。级别:`TABLE`。别名:`SYSTEM STOP FETCHES`、`SYSTEM START FETCHES`、`STOP FETCHES`、`START FETCHES` - - `SYSTEM MOVES`。级别:`TABLE`。别名:`SYSTEM STOP MOVES`、`SYSTEM START MOVES`、`STOP MOVES`、`START MOVES` - - `SYSTEM SENDS`。级别:`GROUP`。别名:`SYSTEM STOP SENDS`、`SYSTEM START SENDS`、`STOP SENDS`、`START SENDS` - - `SYSTEM DISTRIBUTED SENDS`。级别:`TABLE`。别名:`SYSTEM STOP DISTRIBUTED SENDS`、`SYSTEM START DISTRIBUTED SENDS`、`STOP DISTRIBUTED SENDS`、`START DISTRIBUTED SENDS` - - `SYSTEM REPLICATED SENDS`。级别:`TABLE`。别名:`SYSTEM STOP REPLICATED SENDS`、`SYSTEM START REPLICATED SENDS`、`STOP REPLICATED SENDS`、`START REPLICATED SENDS` - - `SYSTEM REPLICATION QUEUES`。级别:`TABLE`。别名:`SYSTEM STOP REPLICATION QUEUES`、`SYSTEM START REPLICATION QUEUES`、`STOP REPLICATION QUEUES`、`START REPLICATION QUEUES` - - `SYSTEM SYNC REPLICA`。级别:`TABLE`。别名:`SYNC REPLICA` - - `SYSTEM RESTART REPLICA`。级别:`TABLE`。别名:`RESTART REPLICA` - - `SYSTEM FLUSH`。级别:`GROUP` - - `SYSTEM FLUSH DISTRIBUTED`。级别:`TABLE`。别名:`FLUSH DISTRIBUTED` - - `SYSTEM FLUSH LOGS`。级别:`GLOBAL`。别名:`FLUSH LOGS` + - `SYSTEM SHUTDOWN`。级别:`GLOBAL`。别名:`SYSTEM KILL`、`SHUTDOWN` + - `SYSTEM DROP CACHE`。别名:`DROP CACHE` + - `SYSTEM DROP DNS CACHE`。级别:`GLOBAL`。别名:`SYSTEM DROP DNS`、`DROP DNS CACHE`、`DROP DNS` + - `SYSTEM DROP MARK CACHE`。级别:`GLOBAL`。别名:`SYSTEM DROP MARK`、`DROP MARK CACHE`、`DROP MARKS` + - `SYSTEM DROP UNCOMPRESSED CACHE`。级别:`GLOBAL`。别名:`SYSTEM DROP UNCOMPRESSED`、`DROP UNCOMPRESSED CACHE`、`DROP UNCOMPRESSED` + - `SYSTEM RELOAD`。级别:`GROUP` + - `SYSTEM RELOAD CONFIG`。级别:`GLOBAL`。别名:`RELOAD CONFIG` + - `SYSTEM RELOAD DICTIONARY`。级别:`GLOBAL`。别名:`SYSTEM RELOAD DICTIONARIES`、`RELOAD DICTIONARY`、`RELOAD DICTIONARIES` + - `SYSTEM RELOAD EMBEDDED DICTIONARIES`。级别:`GLOBAL`。别名:`RELOAD EMBEDDED DICTIONARIES` + - `SYSTEM MERGES`。级别:`TABLE`。别名:`SYSTEM STOP MERGES`、`SYSTEM START MERGES`、`STOP MERGES`、`START MERGES` + - `SYSTEM TTL MERGES`。级别:`TABLE`。别名:`SYSTEM STOP TTL MERGES`、`SYSTEM START TTL MERGES`、`STOP TTL MERGES`、`START TTL MERGES` + - `SYSTEM FETCHES`。级别:`TABLE`。别名:`SYSTEM STOP FETCHES`、`SYSTEM START FETCHES`、`STOP FETCHES`、`START FETCHES` + - `SYSTEM MOVES`。级别:`TABLE`。别名:`SYSTEM STOP MOVES`、`SYSTEM START MOVES`、`STOP MOVES`、`START MOVES` + - `SYSTEM SENDS`。级别:`GROUP`。别名:`SYSTEM STOP SENDS`、`SYSTEM START SENDS`、`STOP SENDS`、`START SENDS` + - `SYSTEM DISTRIBUTED SENDS`。级别:`TABLE`。别名:`SYSTEM STOP DISTRIBUTED SENDS`、`SYSTEM START DISTRIBUTED SENDS`、`STOP DISTRIBUTED SENDS`、`START DISTRIBUTED SENDS` + - `SYSTEM REPLICATED SENDS`。级别:`TABLE`。别名:`SYSTEM STOP REPLICATED SENDS`、`SYSTEM START REPLICATED SENDS`、`STOP REPLICATED SENDS`、`START REPLICATED SENDS` + - `SYSTEM REPLICATION QUEUES`。级别:`TABLE`。别名:`SYSTEM STOP REPLICATION QUEUES`、`SYSTEM START REPLICATION QUEUES`、`STOP REPLICATION QUEUES`、`START REPLICATION QUEUES` + - `SYSTEM SYNC REPLICA`。级别:`TABLE`。别名:`SYNC REPLICA` + - `SYSTEM RESTART REPLICA`。级别:`TABLE`。别名:`RESTART REPLICA` + - `SYSTEM FLUSH`。级别:`GROUP` + - `SYSTEM FLUSH DISTRIBUTED`。级别:`TABLE`。别名:`FLUSH DISTRIBUTED` + - `SYSTEM FLUSH LOGS`。级别:`GLOBAL`。别名:`FLUSH LOGS` `SYSTEM RELOAD EMBEDDED DICTIONARIES` 权限由 `SYSTEM RELOAD DICTIONARY ON *.*` 权限隐式授予。 @@ -606,41 +611,95 @@ Not enough privileges. To execute this query, it's necessary to have the grant C 允许使用 [introspection](../../operations/optimizing-performance/sampling-query-profiler.md) 函数。 - `INTROSPECTION`。级别:`GROUP`。别名:`INTROSPECTION FUNCTIONS` - - `addressToLine`。级别:`GLOBAL` - - `addressToLineWithInlines`。级别:`GLOBAL` - - `addressToSymbol`。级别:`GLOBAL` - - `demangle`。级别:`GLOBAL` + - `addressToLine`。级别:`GLOBAL` + - `addressToLineWithInlines`。级别:`GLOBAL` + - `addressToSymbol`。级别:`GLOBAL` + - `demangle`。级别:`GLOBAL` ### SOURCES {#sources} 允许使用外部数据源。适用于 [表引擎](../../engines/table-engines/index.md) 和 [表函数](/sql-reference/table-functions)。 -- `SOURCES`。级别:`GROUP` - - `AZURE`。级别:`GLOBAL` - - `FILE`。级别:`GLOBAL` - - `HDFS`。级别:`GLOBAL` - - `HIVE`。级别:`GLOBAL` - - `JDBC`。级别:`GLOBAL` - - `KAFKA`。级别:`GLOBAL` - - `MONGO`。级别:`GLOBAL` - - `MYSQL`。级别:`GLOBAL` - - `NATS`。级别:`GLOBAL` - - `ODBC`。级别:`GLOBAL` - - `POSTGRES`。级别:`GLOBAL` - - `RABBITMQ`。级别:`GLOBAL` - - `REDIS`。级别:`GLOBAL` - - `REMOTE`。级别:`GLOBAL` - - `S3`。级别:`GLOBAL` - - `SQLITE`。级别:`GLOBAL` - - `URL`。级别:`GLOBAL` - -`SOURCES` 权限启用使用所有源。您还可以单独授予每个源的权限。要使用源,您需要额外的权限。 +- `READ`。级别:`GLOBAL_WITH_PARAMETER` +- `WRITE`。级别:`GLOBAL_WITH_PARAMETER` + +可能的参数: +- `AZURE` +- `FILE` +- `HDFS` +- `HIVE` +- `JDBC` +- `KAFKA` +- `MONGO` +- `MYSQL` +- `NATS` +- `ODBC` +- `POSTGRES` +- `RABBITMQ` +- `REDIS` +- `REMOTE` +- `S3` +- `SQLITE` +- `URL` + +:::note +对于源的读取/写入权限的分离,从 25.7 版本开始可用,并且仅在服务器设置 `access_control_improvements.enable_read_write_grants` 启用时可用。 + +否则,您应该使用语法 `GRANT AZURE ON *.* TO user`,这等同于新的 `GRANT READ, WRITE ON AZURE TO user` +::: 示例: - 要创建一个使用 [MySQL 表引擎](../../engines/table-engines/integrations/mysql.md) 的表,您需要 `CREATE TABLE (ON db.table_name)` 和 `MYSQL` 权限。 - 要使用 [mysql 表函数](../../sql-reference/table-functions/mysql.md),您需要 `CREATE TEMPORARY TABLE` 和 `MYSQL` 权限。 +### 源过滤器授权 {#source-filter-grants} + +:::note +此功能从版本 25.8 开始可用,并且仅在服务器设置 `access_control_improvements.enable_read_write_grants` 启用时可用 +::: + +您可以使用正则表达式过滤器授予对特定源 URI 的访问权限。这允许对用户可以访问哪些外部数据源进行细粒度控制。 + +**语法:** + +```sql +GRANT READ ON S3('regexp_pattern') TO user +``` + +此授权将允许用户仅从与指定正则表达式模式匹配的 S3 URI 中读取。 + +**示例:** + +授予对特定 S3 桶路径的访问: +```sql +-- Allow user to read only from s3://foo/ paths +GRANT READ ON S3('s3://foo/.*') TO john + +-- Allow user to read from specific file patterns +GRANT READ ON S3('s3://mybucket/data/2024/.*\.parquet') TO analyst + +-- Multiple filters can be granted to the same user +GRANT READ ON S3('s3://foo/.*') TO john +GRANT READ ON S3('s3://bar/.*') TO john +``` + +**使用 GRANT OPTION 重新授权:** + +如果原始授权带有 `WITH GRANT OPTION`,可以使用 `GRANT CURRENT GRANTS` 进行重新授权: +```sql +-- Original grant with GRANT OPTION +GRANT READ ON S3('s3://foo/.*') TO john WITH GRANT OPTION + +-- John can now regrant this access to others +GRANT CURRENT GRANTS(READ ON S3) TO alice +``` + +**重要限制:** + +- **不允许部分撤销:** 您不能撤销授予的过滤器模式的子集。如果需要,必须撤销整个授权并使用新模式重新授权。 +- **不允许通配符授权:** 您不能使用 `GRANT READ ON *('regexp')` 或类似仅通配符的模式。必须提供具体源。 + ### dictGet {#dictget} - `dictGet`。别名:`dictHas`、`dictGetHierarchy`、`dictIsIn` @@ -656,28 +715,28 @@ Not enough privileges. To execute this query, it's necessary to have the grant C ### displaySecretsInShowAndSelect {#displaysecretsinshowandselect} -允许用户在 `SHOW` 和 `SELECT` 查询中查看秘密,如果同时启用 +允许用户在 `SHOW` 和 `SELECT` 查询中查看机密,如果同时启用 [`display_secrets_in_show_and_select` 服务器设置](../../operations/server-configuration-parameters/settings#display_secrets_in_show_and_select) 和 [`format_display_secrets_in_show_and_select` 格式设置](../../operations/settings/formats#format_display_secrets_in_show_and_select)。 ### NAMED COLLECTION ADMIN {#named-collection-admin} -允许在指定的命名集合上进行某些操作。在 23.7 之前,称为 NAMED COLLECTION CONTROL,23.7 之后增加了 NAMED COLLECTION ADMIN,并保留了 NAMED COLLECTION CONTROL 作为别名。 +允许对指定命名集合执行特定操作。在 23.7 版本之前称为 NAMED COLLECTION CONTROL,在 23.7 之后添加了 NAMED COLLECTION ADMIN,并将 NAMED COLLECTION CONTROL 保留为别名。 - `NAMED COLLECTION ADMIN`。级别:`NAMED_COLLECTION`。别名:`NAMED COLLECTION CONTROL` - - `CREATE NAMED COLLECTION`。级别:`NAMED_COLLECTION` - - `DROP NAMED COLLECTION`。级别:`NAMED_COLLECTION` - - `ALTER NAMED COLLECTION`。级别:`NAMED_COLLECTION` - - `SHOW NAMED COLLECTIONS`。级别:`NAMED_COLLECTION`。别名:`SHOW NAMED COLLECTIONS` - - `SHOW NAMED COLLECTIONS SECRETS`。级别:`NAMED_COLLECTION`。别名:`SHOW NAMED COLLECTIONS SECRETS` - - `NAMED COLLECTION`。级别:`NAMED_COLLECTION`。别名:`NAMED COLLECTION USAGE`、`USE NAMED COLLECTION` + - `CREATE NAMED COLLECTION`。级别:`NAMED_COLLECTION` + - `DROP NAMED COLLECTION`。级别:`NAMED_COLLECTION` + - `ALTER NAMED COLLECTION`。级别:`NAMED_COLLECTION` + - `SHOW NAMED COLLECTIONS`。级别:`NAMED_COLLECTION`。别名:`SHOW NAMED COLLECTIONS` + - `SHOW NAMED COLLECTIONS SECRETS`。级别:`NAMED_COLLECTION`。别名:`SHOW NAMED COLLECTIONS SECRETS` + - `NAMED COLLECTION`。级别:`NAMED_COLLECTION`。别名:`NAMED COLLECTION USAGE`、`USE NAMED COLLECTION` -与其他所有权限(CREATE、DROP、ALTER、SHOW)不同,NAMED COLLECTION 的授予仅在 23.7 中添加,而其他权限则是在 22.12 之前添加。 +与所有其他授权(CREATE、DROP、ALTER、SHOW)不同,授予 NAMED COLLECTION 的权限仅在 23.7 中添加,而所有其他授权则在早期(22.12)添加。 **示例** -假设命名集合名为 abc,我们授予用户 john 创建命名集合的权限。 +假设一个命名集合叫 abc,我们授予用户 john CREATE NAMED COLLECTION 权限。 - `GRANT CREATE NAMED COLLECTION ON abc TO john` ### TABLE ENGINE {#table-engine} @@ -693,11 +752,11 @@ Not enough privileges. To execute this query, it's necessary to have the grant C -向用户帐户或角色授予对受管实体的所有权限。 +授予用户账户或角色对受管实体的所有权限。 :::note -在 ClickHouse Cloud 中不支持权限 `ALL`,其中 `default` 用户具有有限权限。用户可以通过授予 `default_role` 将最大权限授予给用户。更多详细信息请参见[这里](/cloud/security/cloud-access-management/overview#initial-settings)。 -用户还可以以默认用户的身份使用 `GRANT CURRENT GRANTS` 来实现类似于 `ALL` 的效果。 +在 ClickHouse Cloud 中不支持 `ALL` 权限,其中 `default` 用户的权限有限。用户可以通过授予 `default_role` 来最大程度地授权其他用户。有关详细信息,请参见 [here](/cloud/security/cloud-access-management/overview#initial-settings)。 +用户也可以作为默认用户使用 `GRANT CURRENT GRANTS` 来实现与 `ALL` 类似的效果。 ::: ### NONE {#none} @@ -706,4 +765,4 @@ Not enough privileges. To execute this query, it's necessary to have the grant C ### ADMIN OPTION {#admin-option} -`ADMIN OPTION` 权限允许用户将其角色授予其他用户。 +`ADMIN OPTION` 权限允许用户将其角色授予另一个用户。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/grant.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/grant.md.hash index 9dc566fb281..0105bbf2976 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/grant.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/grant.md.hash @@ -1 +1 @@ -c29985cccd6e6522 +75ae367068c26271 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/index.md index 22490e56230..94176fa77fa 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/index.md @@ -4,9 +4,10 @@ 'sidebar_position': 1 'slug': '/sql-reference/statements/' 'title': 'ClickHouse SQL 语句' +'doc_type': 'reference' --- # ClickHouse SQL 语句 -用户使用 SQL 语句与 ClickHouse 进行交互。ClickHouse 支持常见的 SQL 语句,如 [SELECT](select/index.md) 和 [CREATE](create/index.md),但它还提供了专门的语句,如 [KILL](kill.md) 和 [OPTIMIZE](optimize.md)。 +用户通过 SQL 语句与 ClickHouse 进行交互。ClickHouse 支持常见的 SQL 语句,如 [SELECT](select/index.md) 和 [CREATE](create/index.md),但也提供了特定的语句,如 [KILL](kill.md) 和 [OPTIMIZE](optimize.md)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/index.md.hash index 71c2e06faea..208a8237123 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/index.md.hash @@ -1 +1 @@ -05d7ac1db94fdf21 +520f0da73b703187 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/insert-into.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/insert-into.md index 82c6823ea18..0a5dca367d9 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/insert-into.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/insert-into.md @@ -4,6 +4,7 @@ 'sidebar_position': 33 'slug': '/sql-reference/statements/insert-into' 'title': 'INSERT INTO 语句' +'doc_type': 'reference' --- @@ -17,7 +18,7 @@ INSERT INTO [TABLE] [db.]table [(c1, c2, c3)] [SETTINGS ...] VALUES (v11, v12, v13), (v21, v22, v23), ... ``` -您可以使用 `(c1, c2, c3)` 指定要插入的列列表。您还可以使用带有列 [匹配器](../../sql-reference/statements/select/index.md#asterisk) 的表达式,例如 `*` 和/或 [修饰符](../../sql-reference/statements/select/index.md#select-modifiers),例如 [APPLY](/sql-reference/statements/select#apply)、 [EXCEPT](/sql-reference/statements/select#except) 和 [REPLACE](/sql-reference/statements/select#replace)。 +您可以使用 `(c1, c2, c3)` 指定要插入的列列表。您还可以使用列 [匹配器](../../sql-reference/statements/select/index.md#asterisk) 表达式,例如 `*` 和/或 [修饰符](../../sql-reference/statements/select/index.md#select-modifiers),例如 [APPLY](/sql-reference/statements/select/apply-modifier),[EXCEPT](/sql-reference/statements/select/except-modifier),[REPLACE](/sql-reference/statements/select/replace-modifier)。 例如,考虑以下表: @@ -40,7 +41,7 @@ ORDER BY a INSERT INTO insert_select_testtable (*) VALUES (1, 'a', 1) ; ``` -如果您想向除列 `b` 之外的所有列插入数据,可以使用 `EXCEPT` 关键字。根据上述语法,您需要确保插入的值数量 (`VALUES (v11, v13)`) 与您指定的列数量 (`(c1, c3)`) 相匹配: +如果您想向除列 `b` 之外的所有列插入数据,可以使用 `EXCEPT` 关键字。参考上面的语法,您需要确保插入的值(`VALUES (v11, v13)`)与您指定的列(`(c1, c3)`)数量相同: ```sql INSERT INTO insert_select_testtable (* EXCEPT(b)) Values (2, 2); @@ -59,18 +60,18 @@ SELECT * FROM insert_select_testtable; └───┴───┴───┘ ``` -在这个例子中,我们看到第二个被插入的行有 `a` 和 `c` 列由传递的值填充,而 `b` 列则填充了默认值。还可以使用 `DEFAULT` 关键字插入默认值: +在这个例子中,我们看到第二行插入行的 `a` 和 `c` 列由传递的值填充,而 `b` 列则填充了默认值。也可以使用 `DEFAULT` 关键字插入默认值: ```sql INSERT INTO insert_select_testtable VALUES (1, DEFAULT, 1) ; ``` -如果列列表不包含所有现有的列,则其余列将填充如下: +如果列列表不包含所有现有列,其余的列将填充: -- 从表定义中指定的 `DEFAULT` 表达式计算出的值。 -- 如果没有定义 `DEFAULT` 表达式,则为零和空字符串。 +- 在表定义中指定的 `DEFAULT` 表达式计算出的值。 +- 如果未定义 `DEFAULT` 表达式,则填充零和空字符串。 -数据可以以 ClickHouse 支持的任何 [格式](/sql-reference/formats) 传递给 INSERT。格式必须在查询中明确指定: +数据可以以 ClickHouse 支持的任何 [格式](/sql-reference/formats) 传递给 INSERT。格式必须在查询中显式指定: ```sql INSERT INTO [db.]table [(c1, c2, c3)] FORMAT format_name data_set @@ -82,7 +83,7 @@ INSERT INTO [db.]table [(c1, c2, c3)] FORMAT format_name data_set INSERT INTO [db.]table [(c1, c2, c3)] FORMAT Values (v11, v12, v13), (v21, v22, v23), ... ``` -ClickHouse 会在数据之前删除所有空格和一行换行符(如果存在)。在形成查询时,我们建议将数据放在查询运算符之后的新行上,这对于数据以空格开头的情况非常重要。 +ClickHouse 会在数据之前删除所有空格和一个换行符(如果存在)。在形成查询时,我们建议将数据放在查询操作符之后的新行中,这在数据以空格开头时特别重要。 示例: @@ -92,10 +93,10 @@ INSERT INTO t FORMAT TabSeparated 22 Qwerty ``` -您可以使用 [命令行客户端](/operations/utilities/clickhouse-local) 或 [HTTP 接口](/interfaces/http/) 单独插入数据。 +您可以使用 [命令行客户端](/operations/utilities/clickhouse-local) 或 [HTTP 接口](/interfaces/http/) 分开从查询中插入数据。 :::note -如果您想为 `INSERT` 查询指定 `SETTINGS`,则必须在 `FORMAT` 子句之前进行,因为在 `FORMAT format_name` 之后的所有内容都被视为数据。例如: +如果您要为 `INSERT` 查询指定 `SETTINGS`,则必须在 `FORMAT` 子句 _之前_ 进行,因为在 `FORMAT format_name` 之后的所有内容都被视为数据。例如: ```sql INSERT INTO table SETTINGS ... FORMAT format_name data_set @@ -104,7 +105,7 @@ INSERT INTO table SETTINGS ... FORMAT format_name data_set ## 约束 {#constraints} -如果表具有 [约束](../../sql-reference/statements/create/table.md#constraints),则会检查每一行插入数据的表达式。如果违反任何一个约束 - 服务器将引发包含约束名称和表达式的异常,并停止查询。 +如果表具有 [约束](../../sql-reference/statements/create/table.md#constraints),则将检查插入数据的每一行的表达式。如果未满足任何这些约束,则服务器将引发包含约束名称和表达式的异常,查询将停止。 ## 从 SELECT 插入结果 {#inserting-the-results-of-select} @@ -114,24 +115,24 @@ INSERT INTO table SETTINGS ... FORMAT format_name data_set INSERT INTO [TABLE] [db.]table [(c1, c2, c3)] SELECT ... ``` -列根据 `SELECT` 子句中的位置进行映射。然而,`SELECT` 表达式和 `INSERT` 表中的表的名称可能不同。如有必要,执行类型转换。 +列按其在 `SELECT` 子句中的位置进行映射。但是,它们在 `SELECT` 表达式和用于 `INSERT` 的表中的名称可能不同。如果需要,将执行类型转换。 -除了 Values 格式外,没有其他数据格式允许设置如 `now()`、`1 + 2` 等表达式的值。Values 格式允许有限地使用表达式,但这并不推荐,因为在这种情况下会使用低效的代码进行执行。 +除 Values 格式外,没有数据格式允许将值设置为 `now()`、`1 + 2` 等表达式。Values 格式允许有限使用表达式,但不推荐这样做,因为在这种情况下使用的是低效的代码来执行它们。 -不支持其他修改数据部分的查询:`UPDATE`、`DELETE`、`REPLACE`、`MERGE`、`UPSERT`、`INSERT UPDATE`。但是,您可以使用 `ALTER TABLE ... DROP PARTITION` 删除旧数据。 +不支持其他修改数据部分的查询:`UPDATE`、`DELETE`、`REPLACE`、`MERGE`、`UPSERT`、`INSERT UPDATE`。 +但是,您可以使用 `ALTER TABLE ... DROP PARTITION` 删除旧数据。 -如果 `SELECT` 子句包含表函数 [input()](../../sql-reference/table-functions/input.md),则 `FORMAT` 子句必须在查询的末尾指定。 +如果 `SELECT` 子句包含表函数 [input()](../../sql-reference/table-functions/input.md),则必须在查询的末尾指定 `FORMAT` 子句。 要向具有非空数据类型的列插入默认值而不是 `NULL`,请启用 [insert_null_as_default](../../operations/settings/settings.md#insert_null_as_default) 设置。 -`INSERT` 还支持 CTE(公共表表达式)。例如,以下两个语句是等效的: +`INSERT` 还支持 CTE(公用表表达式)。例如,以下两个语句是等效的: ```sql INSERT INTO x WITH y AS (SELECT * FROM numbers(10)) SELECT * FROM y; WITH y AS (SELECT * FROM numbers(10)) INSERT INTO x SELECT * FROM y; ``` - ## 从文件插入数据 {#inserting-data-from-a-file} **语法** @@ -140,15 +141,15 @@ WITH y AS (SELECT * FROM numbers(10)) INSERT INTO x SELECT * FROM y; INSERT INTO [TABLE] [db.]table [(c1, c2, c3)] FROM INFILE file_name [COMPRESSION type] [SETTINGS ...] [FORMAT format_name] ``` -使用上述语法从存储在 **客户端** 侧的文件或文件中插入数据。`file_name` 和 `type` 是字符串字面量。输入文件 [格式](../../interfaces/formats.md) 必须在 `FORMAT` 子句中设置。 +使用上述语法从存储在 **客户端** 侧的文件或文件中插入数据。`file_name` 和 `type` 是字符串字面量。输入文件的 [格式](../../interfaces/formats.md) 必须在 `FORMAT` 子句中设置。 -支持压缩文件。压缩类型由文件名扩展名检测,或可以在 `COMPRESSION` 子句中明确指定。支持的类型包括: `'none'`、`'gzip'`、`'deflate'`、`'br'`、`'xz'`、`'zstd'`、`'lz4'`、`'bz2'`。 +支持压缩文件。压缩类型通过文件名的扩展名检测。或者可以在 `COMPRESSION` 子句中显式指定。支持的类型有:`'none'`、`'gzip'`、`'deflate'`、`'br'`、`'xz'`、`'zstd'`、`'lz4'`、`'bz2'`。 -此功能在 [命令行客户端](../../interfaces/cli.md) 和 [clickhouse-local](../../operations/utilities/clickhouse-local.md) 中可用。 +该功能在 [命令行客户端](../../interfaces/cli.md) 和 [clickhouse-local](../../operations/utilities/clickhouse-local.md) 中可用。 **示例** -### 使用 FROM INFILE 的单个文件 {#single-file-with-from-infile} +### 使用 FROM INFILE 插入单个文件 {#single-file-with-from-infile} 使用 [命令行客户端](../../interfaces/cli.md) 执行以下查询: @@ -168,9 +169,9 @@ clickhouse-client --query="SELECT * FROM table_from_file FORMAT PrettyCompact;" └────┴──────┘ ``` -### 使用通配符从多个文件插入数据 {#multiple-files-with-from-infile-using-globs} +### 使用通配符从 FILE 插入多个文件 {#multiple-files-with-from-infile-using-globs} -此示例与前一个示例非常相似,但使用 `FROM INFILE 'input_*.csv` 从多个文件中执行插入。 +该示例与前一个示例非常相似,但使用 `FROM INFILE 'input_*.csv` 从多个文件中进行插入。 ```bash echo 1,A > input_1.csv ; echo 2,B > input_2.csv @@ -180,7 +181,7 @@ clickhouse-client --query="SELECT * FROM infile_globs FORMAT PrettyCompact;" ``` :::tip -除了使用 `*` 选择多个文件外,您还可以使用范围(`{1,2}` 或 `{1..9}`)和其他 [通配符替代](https://clickhouse.com/docs/zh/sql-reference/table-functions/file.md/#globs-in-path)。这三者都可以与上述示例一起使用: +除了使用 `*` 选择多个文件外,您还可以使用范围(`{1,2}` 或 `{1..9}`)和其他 [通配符替换](/sql-reference/table-functions/file.md/#globs-in-path)。这三种方法都适用于上面的示例: ```sql INSERT INTO infile_globs FROM INFILE 'input_*.csv' FORMAT CSV; @@ -191,7 +192,7 @@ INSERT INTO infile_globs FROM INFILE 'input_?.csv' FORMAT CSV; ## 使用表函数插入 {#inserting-using-a-table-function} -数据可以插入到 [表函数](../../sql-reference/table-functions/index.md) 引用的表中。 +数据可以插入到由 [表函数](../../sql-reference/table-functions/index.md) 引用的表中。 **语法** @@ -220,9 +221,9 @@ SELECT * FROM simple_table; ## 插入到 ClickHouse Cloud {#inserting-into-clickhouse-cloud} -默认情况下,ClickHouse Cloud 上的服务提供多个副本以实现高可用性。当您连接到服务时,会与这些副本之一建立连接。 +默认情况下,ClickHouse Cloud 上的服务提供多个副本以提高可用性。当您连接到服务时,会与这些副本中的一个建立连接。 -在 `INSERT` 成功后,数据会写入底层存储。然而,副本接收这些更新可能需要一些时间。因此,如果您使用另一个连接在其他副本之一上执行 `SELECT` 查询,则更新的数据可能尚未反映。 +在 `INSERT` 成功后,数据会写入底层存储。但是,副本接收这些更新可能需要一些时间。因此,如果您使用不同的连接在这些其他副本之一上执行 `SELECT` 查询,则更新数据可能尚未反映出来。 可以使用 `select_sequential_consistency` 强制副本接收最新更新。以下是使用此设置的 `SELECT` 查询示例: @@ -230,35 +231,37 @@ SELECT * FROM simple_table; SELECT .... SETTINGS select_sequential_consistency = 1; ``` -请注意,使用 `select_sequential_consistency` 会增加 ClickHouse Keeper(ClickHouse Cloud 内部使用)上的负载,并可能导致性能下降,具体取决于服务的负载。我们建议在非必要情况下不要启用此设置。推荐的方法是在同一会话中执行读/写,或者使用使用原生协议的客户端驱动程序(因此支持粘性连接)。 +请注意,使用 `select_sequential_consistency` 会增加 ClickHouse Keeper(ClickHouse Cloud 内部使用)上的负载,可能导致性能降低,具体取决于服务的负载。除非必要,我们不建议启用此设置。建议的方法是在同一会话中执行读/写,或使用使用本地协议的客户端驱动程序(因此支持粘性连接)。 -## 插入到复制设置中 {#inserting-into-a-replicated-setup} +## 插入到复制设置 {#inserting-into-a-replicated-setup} -在复制设置中,在数据被复制后,其他副本上将可见。数据在 `INSERT` 后立即开始复制(在其他副本上下载)。这与 ClickHouse Cloud 不同,后者数据会立即写入共享存储,副本订阅元数据更改。 +在复制设置中,数据将在复制后在其他副本上可见。数据在 `INSERT` 后立即开始复制(下载到其他副本)。这与 ClickHouse Cloud 不同,在 ClickHouse Cloud 中,数据会立即写入共享存储,副本会订阅元数据更改。 -请注意,对于复制设置,`INSERT` 有时可能需要相当长的时间(约一秒钟),因为它需要向 ClickHouse Keeper 提交以进行分布式共识。使用 S3 进行存储也增加了额外的延迟。 +请注意,对于复制设置,`INSERT` 有时可能需要相当长的时间(大约一秒),因为需要提交给 ClickHouse Keeper 以实现分布式共识。使用 S3 作为存储也会增加额外延迟。 ## 性能考虑 {#performance-considerations} -`INSERT` 会根据主键对输入数据进行排序,并按分区键将其拆分为分区。如果您同时向多个分区插入数据,可能会显著降低 `INSERT` 查询的性能。为了避免这种情况: +`INSERT` 按主键对输入数据进行排序,并按分区键将其拆分为分区。如果您同时向多个分区插入数据,则可能会显著降低 `INSERT` 查询的性能。为避免这种情况: -- 在相当大的批次中添加数据,例如每次 100,000 行。 -- 在将数据上传到 ClickHouse 之前,按分区键对数据进行分组。 +- 批量添加相当大的数据,例如每次 100,000 行。 +- 在将数据上传到 ClickHouse 之前按分区键对数据进行分组。 -如果满足以下条件,性能将不会降低: +如果: - 实时添加数据。 -- 您上传的数据通常按时间排序。 +- 上传的数据显示出时间上的排序。 + +则性能不会降低。 ### 异步插入 {#asynchronous-inserts} -可以以小批量但频繁的方式异步插入数据。这类插入的数据会合并为批次,然后安全地插入到表中。要使用异步插入,请启用 [`async_insert`](/operations/settings/settings#async_insert) 设置。 +可以以小而频繁的插入方式异步插入数据。此类插入的数据会合并为批次,然后安全地插入到表中。要使用异步插入,请启用 [`async_insert`](/operations/settings/settings#async_insert) 设置。 使用 `async_insert` 或 [`Buffer` 表引擎](/engines/table-engines/special/buffer) 会导致额外的缓冲。 -### 大型或长时间运行的插入 {#large-or-long-running-inserts} +### 大量或长时间运行的插入 {#large-or-long-running-inserts} -当插入大量数据时,ClickHouse 将通过称为 “压缩” 的过程优化写入性能。内存中插入的小块数据会合并并压缩为更大的块,然后再写入磁盘。压缩减少了与每次写入操作相关的开销。在此过程中,插入的数据将在 ClickHouse 完成写入每个 [`max_insert_block_size`](/operations/settings/settings#max_insert_block_size) 行后可供查询。 +当您插入大量数据时,ClickHouse 将通过一个称为 "合并" 的过程优化写入性能。内存中插入的小块数据会合并并压缩成更大的块,然后写入磁盘。合并减少每个写入操作的开销。在此过程中,插入的数据将在 ClickHouse 完成写入每个 [`max_insert_block_size`](/operations/settings/settings#max_insert_block_size) 行后可用以查询。 **另请参见** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/insert-into.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/insert-into.md.hash index cacd733faa4..c3e9572458a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/insert-into.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/insert-into.md.hash @@ -1 +1 @@ -763f6cb5f28eeec6 +bad5961262c63f53 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/kill.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/kill.md index 3f51414b805..3d025fffede 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/kill.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/kill.md @@ -1,12 +1,13 @@ --- -'description': '有关 KILL 的文档' +'description': '关于 KILL 的文档' 'sidebar_label': 'KILL' 'sidebar_position': 46 'slug': '/sql-reference/statements/kill' 'title': 'KILL 语句' +'doc_type': 'reference' --- -有两种类型的终止语句:终止查询和终止变更 +有两种类型的终止语句:用于终止查询和用于终止变更 ## KILL QUERY {#kill-query} @@ -18,13 +19,13 @@ KILL QUERY [ON CLUSTER cluster] ``` 尝试强制终止当前正在运行的查询。 -要终止的查询通过`KILL`查询的`WHERE`子句中定义的标准从system.processes表中选择。 +要终止的查询是从 system.processes 表中选择的,使用 `KILL` 查询的 `WHERE` 子句中定义的标准。 示例: -首先,您需要获取未完成查询的列表。这个SQL查询根据运行时间最长的查询提供它们: +首先,您需要获取未完成查询的列表。此 SQL 查询根据运行时间最长的查询提供它们: -从单个ClickHouse节点获取列表: +从单个 ClickHouse 节点列表: ```sql SELECT initial_query_id, @@ -37,7 +38,7 @@ SELECT ORDER BY time_delta DESC; ``` -从ClickHouse集群获取列表: +从 ClickHouse 集群列表: ```sql SELECT initial_query_id, @@ -60,28 +61,28 @@ KILL QUERY WHERE user='username' SYNC ``` :::tip -如果您在ClickHouse Cloud或自管理集群中终止查询,请确保使用```ON CLUSTER [cluster-name]```选项,以确保在所有副本上终止查询。 +如果您在 ClickHouse Cloud 或自管理集群中终止查询,请务必使用 `ON CLUSTER [cluster-name]` 选项,以确保在所有副本上终止该查询。 ::: -只读用户只能停止他们自己的查询。 +只读用户只能停止自己的查询。 -默认情况下,使用的是查询的异步版本(`ASYNC`),它不等待查询已停止的确认。 +默认情况下,使用的是查询的异步版本(`ASYNC`),这不会等待查询停止的确认。 -同步版本(`SYNC`)等待所有查询停止,并在每个进程停止时显示有关该进程的信息。 -响应包含`kill_status`列,可以取以下值: +同步版本(`SYNC`)会等待所有查询停止,并在每个进程停止时显示相关信息。 +响应包含 `kill_status` 列,可能取值如下: -1. `finished` – 查询已成功终止。 -2. `waiting` – 在给查询发送终止信号后,等待查询结束。 -3. 其他值解释了为什么查询无法停止。 +1. `finished` – 查询成功终止。 +2. `waiting` – 等待查询结束,在发送终止信号后。 +3. 其他值解释了查询无法停止的原因。 -测试查询(`TEST`)仅检查用户的权限,并显示要停止的查询列表。 +测试查询(`TEST`)仅检查用户的权限并显示要停止的查询列表。 ## KILL MUTATION {#kill-mutation} -长时间运行或未完成的变更通常表明ClickHouse服务运行不良。变更的异步特性可能导致它们消耗系统上所有可用资源。您可能需要: +长时间运行或未完成的变更的存在通常表明 ClickHouse 服务运行不良。变更的异步特性可能导致它们消耗系统中的所有可用资源。您可能需要: -- 暂停所有新的变更、`INSERT`和`SELECT`,并允许变更队列完成。 -- 或者通过发送`KILL`命令手动终止某些变更。 +- 暂停所有新变更、`INSERT` 和 `SELECT` ,并允许变更队列完成。 +- 或者通过发送 `KILL` 命令手动终止其中一些变更。 ```sql KILL MUTATION @@ -90,22 +91,22 @@ KILL MUTATION [FORMAT format] ``` -尝试取消和移除当前执行的[变更](/sql-reference/statements/alter#mutations)。要取消的变更通过`KILL`查询的`WHERE`子句中指定的过滤器从[`system.mutations`](/operations/system-tables/mutations)表中选择。 +尝试取消和移除当前正在执行的 [变更](/sql-reference/statements/alter#mutations)。要取消的变更是从 [`system.mutations`](/operations/system-tables/mutations) 表中选择的,使用 `KILL` 查询的 `WHERE` 子句中指定的过滤器。 -测试查询(`TEST`)仅检查用户的权限,并显示要停止的变更列表。 +测试查询(`TEST`)仅检查用户的权限并显示要停止的变更列表。 示例: -获取未完成变更的`count()`数量: +获取未完成变更的 `count()` 数量: -从单个ClickHouse节点获取的变更数量: +从单个 ClickHouse 节点的变更计数: ```sql SELECT count(*) FROM system.mutations WHERE is_done = 0; ``` -从ClickHouse副本集群获取的变更数量: +从 ClickHouse 副本集群的变更计数: ```sql SELECT count(*) FROM clusterAllReplicas('default', system.mutations) @@ -114,14 +115,14 @@ WHERE is_done = 0; 查询未完成变更的列表: -从单个ClickHouse节点获取的变更列表: +从单个 ClickHouse 节点的变更列表: ```sql SELECT mutation_id, * FROM system.mutations WHERE is_done = 0; ``` -从ClickHouse集群获取的变更列表: +从 ClickHouse 集群的变更列表: ```sql SELECT mutation_id, * FROM clusterAllReplicas('default', system.mutations) @@ -137,10 +138,10 @@ KILL MUTATION WHERE database = 'default' AND table = 'table' KILL MUTATION WHERE database = 'default' AND table = 'table' AND mutation_id = 'mutation_3.txt' ``` -当某个变更卡住无法完成时,此查询非常有用(例如,如果变更查询中的某个函数在应用于表中包含的数据时抛出异常)。 +当变更被卡住并无法完成时(例如,如果变更查询中的某些函数对表中包含的数据应用时抛出异常),该查询非常有用。 -变更所做的更改不会进行回滚。 +变更已经做出的更改不会被回滚。 :::note -在[system.mutations](/operations/system-tables/mutations)表中,`is_killed=1`列(仅限ClickHouse Cloud)并不一定意味着变更已完全完成。变更可能保持在`is_killed=1`和`is_done=0`的状态中很长时间。这种情况可能发生,因为另一个长时间运行的变更正在阻塞被终止的变更。这是一种正常情况。 +`is_killed=1` 列(仅 ClickHouse Cloud)在 [system.mutations](/operations/system-tables/mutations) 表中不一定意味着变更已完全完成。变更可能保持在 `is_killed=1` 和 `is_done=0` 的状态中,持续一段时间。如果另一个长时间运行的变更阻止了被终止的变更,这种情况是正常的。 ::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/kill.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/kill.md.hash index d0f6cb518c8..9e56fb55678 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/kill.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/kill.md.hash @@ -1 +1 @@ -efd4f3bc52ef673e +d1448fa5ebc10313 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/move.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/move.md index cbcc5335a80..8f1f548c8e1 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/move.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/move.md @@ -4,6 +4,7 @@ 'sidebar_position': 54 'slug': '/sql-reference/statements/move' 'title': 'MOVE 访问实体语句' +'doc_type': 'reference' --- @@ -17,12 +18,12 @@ MOVE {USER, ROLE, QUOTA, SETTINGS PROFILE, ROW POLICY} name1 [, name2, ...] TO access_storage_type ``` -当前,ClickHouse 中有五个访问存储: - - `local_directory` - - `memory` - - `replicated` - - `users_xml` (只读) - - `ldap` (只读) +目前,ClickHouse 中有五个访问存储: +- `local_directory` +- `memory` +- `replicated` +- `users_xml` (只读) +- `ldap` (只读) 示例: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/move.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/move.md.hash index d7eb1b8d192..8e8f34b2366 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/move.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/move.md.hash @@ -1 +1 @@ -48dc5f49d852d6f2 +f10341c5c662c750 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/optimize.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/optimize.md index f28edcae7a9..917e3b1ca57 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/optimize.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/optimize.md @@ -4,12 +4,13 @@ 'sidebar_position': 47 'slug': '/sql-reference/statements/optimize' 'title': 'OPTIMIZE 语句' +'doc_type': 'reference' --- -这个查询尝试初始化表的数据部分的无计划合并。请注意,我们通常不推荐使用 `OPTIMIZE TABLE ... FINAL`(请参见这些 [文档](/optimize/avoidoptimizefinal)),因为它的用例主要用于管理,而非日常操作。 +这个查询尝试初始化对表的数据部分进行未经计划的合并。请注意,我们通常不推荐使用 `OPTIMIZE TABLE ... FINAL` (请参阅这些 [文档](/optimize/avoidoptimizefinal)),因为其使用情况是为了管理,而不是日常操作。 :::note -`OPTIMIZE` 不能修复 `太多部分` 错误。 +`OPTIMIZE` 无法修复 `Too many parts` 错误。 ::: **语法** @@ -18,29 +19,29 @@ OPTIMIZE TABLE [db.]name [ON CLUSTER cluster] [PARTITION partition | PARTITION ID 'partition_id'] [FINAL | FORCE] [DEDUPLICATE [BY expression]] ``` -`OPTIMIZE` 查询支持 [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) 家族(包括 [物化视图](/sql-reference/statements/create/view#materialized-view))和 [Buffer](../../engines/table-engines/special/buffer.md) 引擎。其他表引擎不被支持。 +`OPTIMIZE` 查询支持 [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) 家族(包括 [物化视图](/sql-reference/statements/create/view#materialized-view))和 [Buffer](../../engines/table-engines/special/buffer.md) 引擎。其他表引擎不受支持。 -当 `OPTIMIZE` 与 [ReplicatedMergeTree](../../engines/table-engines/mergetree-family/replication.md) 家族的表引擎一起使用时,ClickHouse 会创建一个合并任务并等待在所有副本上执行(如果 [alter_sync](/operations/settings/settings#alter_sync) 设置为 `2`)或在当前副本上执行(如果 [alter_sync](/operations/settings/settings#alter_sync) 设置为 `1`)。 +当 `OPTIMIZE` 与 [ReplicatedMergeTree](../../engines/table-engines/mergetree-family/replication.md) 家族的表引擎一起使用时,ClickHouse 创建一个合并任务并等待在所有副本上执行(如果 [alter_sync](/operations/settings/settings#alter_sync) 设置为 `2`)或在当前副本上(如果 [alter_sync](/operations/settings/settings#alter_sync) 设置为 `1`)。 - 如果 `OPTIMIZE` 因任何原因未执行合并,它不会通知客户端。要启用通知,请使用 [optimize_throw_if_noop](/operations/settings/settings#optimize_throw_if_noop) 设置。 - 如果您指定了 `PARTITION`,则仅优化指定的分区。[如何设置分区表达式](alter/partition.md#how-to-set-partition-expression)。 -- 如果您指定了 `FINAL` 或 `FORCE`,即使所有数据已经合并到一个部分,仍然会执行优化。您可以使用 [optimize_skip_merged_partitions](/operations/settings/settings#optimize_skip_merged_partitions) 设置来控制此行为。此外,即使正在执行并发合并,也会强制执行合并。 -- 如果您指定了 `DEDUPLICATE`,则完全相同的行(除非指定了 by 子句)将被去重(比较所有列),这仅对 MergeTree 引擎有意义。 +- 如果您指定了 `FINAL` 或 `FORCE`,即使所有数据已经在一个部分中,也会进行优化。您可以使用 [optimize_skip_merged_partitions](/operations/settings/settings#optimize_skip_merged_partitions) 来控制此行为。此外,即使正在进行并发合并,也会强制执行合并。 +- 如果您指定了 `DEDUPLICATE`,则完全相同的行(除非指定了 by-子句)将被去重(所有列进行比较),这仅对 MergeTree 引擎有意义。 -您可以通过 [replication_wait_for_inactive_replica_timeout](/operations/settings/settings#replication_wait_for_inactive_replica_timeout) 设置指定等待非活动副本执行 `OPTIMIZE` 查询的时间(以秒为单位)。 +您可以通过 [replication_wait_for_inactive_replica_timeout](/operations/settings/settings#replication_wait_for_inactive_replica_timeout) 设置指定等待不活跃副本执行 `OPTIMIZE` 查询的时间(以秒为单位)。 :::note -如果 `alter_sync` 设置为 `2`,并且某些副本在指定的 `replication_wait_for_inactive_replica_timeout` 设置时间内没有变为活动状态,则会抛出异常 `未完成`。 +如果 `alter_sync` 设置为 `2`,并且某些副本超过 `replication_wait_for_inactive_replica_timeout` 设置所指定的时间不活跃,则会抛出异常 `UNFINISHED`。 ::: ## BY 表达式 {#by-expression} -如果您想根据自定义列集而非所有列进行去重,可以显式指定列的列表,或使用 [`*`](../../sql-reference/statements/select/index.md#asterisk)、[`COLUMNS`](/sql-reference/statements/select#select-clause) 或 [`EXCEPT`](/sql-reference/statements/select#except) 表达式的任意组合。显式编写或隐式扩展的列列表必须包括行排序表达式(主键和排序键)和分区表达式(分区键)中指定的所有列。 +如果您想在自定义列集上执行去重,而不是在所有列上,您可以显式指定列的列表,或使用 [`*`](../../sql-reference/statements/select/index.md#asterisk)、[`COLUMNS`](/sql-reference/statements/select#select-clause) 或 [`EXCEPT`](/sql-reference/statements/select/except-modifier) 表达式的任意组合。显式书写或隐式扩展的列列表必须包括所有在行排序表达式中指定的列(包括主键和排序键)和分区表达式(分区键)。 :::note -注意,`*` 的行为与 `SELECT` 中相同:[MATERIALIZED](/sql-reference/statements/create/view#materialized-view) 和 [ALIAS](../../sql-reference/statements/create/table.md#alias) 列不用于扩展。 +请注意,`*` 的行为与 `SELECT` 相同: [MATERIALIZED](/sql-reference/statements/create/view#materialized-view) 和 [ALIAS](../../sql-reference/statements/create/table.md#alias) 列不用于扩展。 -此外,指定空列列表或写出导致列列表为空的表达式,或通过 `ALIAS` 列进行去重都是错误的。 +此外,指定空列列表或写出导致空列列表的表达式,或者通过 `ALIAS` 列进行去重都是错误的。 ::: **语法** @@ -99,10 +100,10 @@ SELECT * FROM example; └─────────────┴───────────────┴───────┴───────────────┘ ``` -以下所有示例均在包含 5 行的状态下执行。 +以下所有示例均在此状态下执行,包含 5 行。 #### `DEDUPLICATE` {#deduplicate} -当未指定去重列时,所有列都会被考虑。只有当所有列中的值都等于前一行的对应值时,行才会被移除: +当未指定去重的列时,所有列都会被考虑。只有当所有列的值与前一行的对应值相等时,该行才会被删除: ```sql OPTIMIZE TABLE example FINAL DEDUPLICATE; @@ -129,7 +130,7 @@ SELECT * FROM example; #### `DEDUPLICATE BY *` {#deduplicate-by-} -当隐式指定列时,表将根据所有非 `ALIAS` 或 `MATERIALIZED` 的列进行去重。考虑上面的表,这些列是 `primary_key`、`secondary_key`、`value` 和 `partition_key`: +当隐式指定列时,表会按所有非 `ALIAS` 或 `MATERIALIZED` 的列进行去重。考虑上面的表,这些列为 `primary_key`、`secondary_key`、`value` 和 `partition_key` 列: ```sql OPTIMIZE TABLE example FINAL DEDUPLICATE BY *; @@ -155,7 +156,7 @@ SELECT * FROM example; ``` #### `DEDUPLICATE BY * EXCEPT` {#deduplicate-by--except} -根据所有非 `ALIAS` 或 `MATERIALIZED` 的列去重,并显式不包括 `value`:`primary_key`、`secondary_key` 和 `partition_key` 列。 +通过所有非 `ALIAS` 或 `MATERIALIZED` 的列去重,且显式排除 `value` 列:`primary_key`、`secondary_key` 和 `partition_key` 列。 ```sql OPTIMIZE TABLE example FINAL DEDUPLICATE BY * EXCEPT value; @@ -179,9 +180,9 @@ SELECT * FROM example; └─────────────┴───────────────┴───────┴───────────────┘ ``` -#### `DEDUPLICATE BY <列列表>` {#deduplicate-by-list-of-columns} +#### `DEDUPLICATE BY ` {#deduplicate-by-list-of-columns} -显式根据 `primary_key`、`secondary_key` 和 `partition_key` 列去重: +显式按 `primary_key`、`secondary_key` 和 `partition_key` 列去重: ```sql OPTIMIZE TABLE example FINAL DEDUPLICATE BY primary_key, secondary_key, partition_key; @@ -204,9 +205,9 @@ SELECT * FROM example; └─────────────┴───────────────┴───────┴───────────────┘ ``` -#### `DEDUPLICATE BY COLUMNS(<正则表达式>)` {#deduplicate-by-columnsregex} +#### `DEDUPLICATE BY COLUMNS()` {#deduplicate-by-columnsregex} -根据匹配正则表达式的所有列进行去重:`primary_key`、`secondary_key` 和 `partition_key` 列: +按与正则表达式匹配的所有列去重:`primary_key`、`secondary_key` 和 `partition_key` 列: ```sql OPTIMIZE TABLE example FINAL DEDUPLICATE BY COLUMNS('.*_key'); diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/optimize.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/optimize.md.hash index f7f3bf0cb4e..32288393599 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/optimize.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/optimize.md.hash @@ -1 +1 @@ -627377f49e127b9a +2f868c32ee1a7e8c diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/parallel_with.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/parallel_with.md index d279e2a6b5d..3a042331860 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/parallel_with.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/parallel_with.md @@ -4,6 +4,7 @@ 'sidebar_position': 53 'slug': '/sql-reference/statements/parallel_with' 'title': 'PARALLEL WITH 子句' +'doc_type': 'reference' --- @@ -17,9 +18,9 @@ statement1 PARALLEL WITH statement2 [PARALLEL WITH statement3 ...] ``` -并行执行语句 `statement1`、`statement2`、`statement3` 等。那些语句的输出将被丢弃。 +并行执行语句 `statement1`、`statement2`、`statement3`,...。这些语句的输出被舍弃。 -在许多情况下,进行并行语句执行的速度可能比简单地顺序执行相同的语句要快。例如,`statement1 PARALLEL WITH statement2 PARALLEL WITH statement3` 可能比 `statement1; statement2; statement3` 更快。 +在许多情况下,使用并行执行语句可能比单纯顺序执行相同的语句更快。例如,`statement1 PARALLEL WITH statement2 PARALLEL WITH statement3` 可能比 `statement1; statement2; statement3` 更快。 ## 示例 {#examples} @@ -41,11 +42,11 @@ DROP TABLE table2; ## 设置 {#settings} -设置 [max_threads](../../operations/settings/settings.md#max_threads) 控制生成的线程数。 +设置 [max_threads](../../operations/settings/settings.md#max_threads) 控制生成多少线程。 ## 与 UNION 的比较 {#comparison-with-union} -`PARALLEL WITH` 子句与 [UNION](select/union.md) 有些相似,后者也会并行执行其操作数。然而,它们之间有一些不同点: -- `PARALLEL WITH` 不会返回其操作数的执行结果,如果有异常,只能重新抛出异常; +`PARALLEL WITH` 子句与 [UNION](select/union.md) 有点相似,后者也并行执行其操作数。然而,有一些差异: +- `PARALLEL WITH` 不会返回其操作数执行的任何结果,如果有的话只能重新抛出异常; - `PARALLEL WITH` 不要求其操作数具有相同的结果列集; -- `PARALLEL WITH` 可以执行任何语句(不仅仅是 `SELECT`)。 +- `PARALLEL WITH` 可以执行任何语句(不仅限于 `SELECT`)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/parallel_with.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/parallel_with.md.hash index 18bb24286a9..48ca1872b88 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/parallel_with.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/parallel_with.md.hash @@ -1 +1 @@ -685e5aecbd263978 +ee3d6578ccc940cb diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/rename.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/rename.md index aeaf2be6b6a..599e0ba3a1e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/rename.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/rename.md @@ -4,13 +4,14 @@ 'sidebar_position': 48 'slug': '/sql-reference/statements/rename' 'title': 'RENAME 语句' +'doc_type': 'reference' --- # RENAME 语句 -重命名数据库、表或字典。可以在单个查询中重命名多个实体。 -请注意,带有多个实体的 `RENAME` 查询是非原子操作。要原子性地交换实体名称,请使用 [EXCHANGE](./exchange.md) 语句。 +重命名数据库、表或字典。多个实体可以在单个查询中重命名。 +请注意,包含多个实体的 `RENAME` 查询是非原子操作。要原子性地交换实体名称,请使用 [EXCHANGE](./exchange.md) 语句。 **语法** @@ -32,8 +33,8 @@ RENAME DATABASE atomic_database1 TO atomic_database2 [,...] [ON CLUSTER cluster] 重命名一个或多个表。 -重命名表是一个轻量级操作。如果在 `TO` 后传递了一个不同的数据库,则该表将被移动到该数据库。然而,数据库的目录必须位于同一文件系统中。否则,会返回错误。 -如果在一个查询中重命名多个表,该操作不是原子性的。它可能会部分执行,其他会话中的查询可能会出现 `Table ... does not exist ...` 错误。 +重命名表是一项轻量级操作。如果在 `TO` 后传递了不同的数据库,则该表将被移动到此数据库。然而,数据库的目录必须位于同一文件系统中。否则,将返回错误。 +如果在一个查询中重命名多个表,该操作不是原子性的。它可能会部分执行,并且其他会话中的查询可能会出现 `Table ... does not exist ...` 错误。 **语法** @@ -47,7 +48,7 @@ RENAME TABLE [db1.]name1 TO [db2.]name2 [,...] [ON CLUSTER cluster] RENAME TABLE table_A TO table_A_bak, table_B TO table_B_bak; ``` -您还可以使用更简单的 SQL: +您也可以使用更简单的 SQL: ```sql RENAME table_A TO table_A_bak, table_B TO table_B_bak; ``` @@ -62,6 +63,6 @@ RENAME table_A TO table_A_bak, table_B TO table_B_bak; RENAME DICTIONARY [db0.]dict_A TO [db1.]dict_B [,...] [ON CLUSTER cluster] ``` -**另见** +**另请参阅** - [字典](../../sql-reference/dictionaries/index.md) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/rename.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/rename.md.hash index 168de340cb3..705b08f9adc 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/rename.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/rename.md.hash @@ -1 +1 @@ -4a6c470a73b017bd +c91fd11132e80457 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/revoke.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/revoke.md index 6866d56e766..366d6a7acca 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/revoke.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/revoke.md @@ -4,12 +4,13 @@ 'sidebar_position': 39 'slug': '/sql-reference/statements/revoke' 'title': 'REVOKE 语句' +'doc_type': 'reference' --- # REVOKE 语句 -从用户或角色中撤销权限。 +撤销用户或角色的权限。 ## 语法 {#syntax} @@ -27,22 +28,22 @@ REVOKE [ON CLUSTER cluster_name] [ADMIN OPTION FOR] role [,...] FROM {user | rol ## 描述 {#description} -要撤销某些权限,您可以使用比您计划撤销的权限范围更广泛的权限。例如,如果用户拥有 `SELECT (x,y)` 权限,管理员可以执行 `REVOKE SELECT(x,y) ...`,或 `REVOKE SELECT * ...`,甚至 `REVOKE ALL PRIVILEGES ...` 查询来撤销此权限。 +要撤销某个权限,您可以使用一个范围更广的权限。例如,如果用户拥有 `SELECT (x,y)` 权限,管理员可以执行 `REVOKE SELECT(x,y) ...`,或者 `REVOKE SELECT * ...`,甚至 `REVOKE ALL PRIVILEGES ...` 查询来撤销该权限。 ### 部分撤销 {#partial-revokes} -您可以撤销部分权限。例如,如果用户拥有 `SELECT *.*` 权限,您可以从中撤销对某个表或数据库读取数据的权限。 +您可以撤销部分权限。例如,如果用户拥有 `SELECT *.*` 权限,您可以撤销从某个表或数据库读取数据的权限。 ## 示例 {#examples} -授予 `john` 用户账户从所有数据库中选择的权限,除了 `accounts` 数据库: +授予 `john` 用户账号从所有数据库中选择的权限,但不包括 `accounts` 数据库: ```sql GRANT SELECT ON *.* TO john; REVOKE SELECT ON accounts.* FROM john; ``` -授予 `mira` 用户账户从 `accounts.staff` 表中选择所有列的权限,除了 `wage` 列。 +授予 `mira` 用户账号从 `accounts.staff` 表中选择所有列的权限,但不包括 `wage` 列。 ```sql GRANT SELECT ON accounts.staff TO mira; diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/revoke.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/revoke.md.hash index 5179215806e..75d7b165b5a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/revoke.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/revoke.md.hash @@ -1 +1 @@ -33fb4d400412a996 +738f8bd299ad41fc diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/all.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/all.md index 13fecafaf88..9a98ca8f9b7 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/all.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/all.md @@ -3,14 +3,15 @@ 'sidebar_label': 'ALL' 'slug': '/sql-reference/statements/select/all' 'title': 'ALL 子句' +'doc_type': 'reference' --- -# ALL 子句 +# ALL Clause -如果表中有多行匹配,则 `ALL` 返回所有匹配的行。`SELECT ALL` 与没有 `DISTINCT` 的 `SELECT` 是相同的。如果同时指定了 `ALL` 和 `DISTINCT`,将抛出异常。 +如果一个表中有多个匹配的行,则 `ALL` 会返回所有这些行。`SELECT ALL` 与没有 `DISTINCT` 的 `SELECT` 是相同的。如果同时指定了 `ALL` 和 `DISTINCT`,则会抛出异常。 -`ALL` 可以在聚合函数内指定,尽管它对查询结果没有实际影响。 +`ALL` 可以在聚合函数中指定,尽管它对查询结果没有实际影响。 例如: @@ -18,7 +19,7 @@ SELECT sum(ALL number) FROM numbers(10); ``` -相当于: +等价于: ```sql SELECT sum(number) FROM numbers(10); diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/all.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/all.md.hash index 36649941394..dae47579600 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/all.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/all.md.hash @@ -1 +1 @@ -53ac32cb766617f6 +cdb5c4ff38c44632 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/apply_modifier.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/apply_modifier.md new file mode 100644 index 00000000000..521182d3b8f --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/apply_modifier.md @@ -0,0 +1,35 @@ +--- +'description': '描述 APPL的修饰符的文档,允许您对查询的外部表表达式返回的每一行调用某个函数。' +'sidebar_label': 'APPLY' +'slug': '/sql-reference/statements/select/apply-modifier' +'title': 'APPLY 修饰符' +'keywords': +- 'APPLY' +- 'modifier' +'doc_type': 'reference' +--- + + +# APPLY modifier {#apply} + +> 允许您对查询外部表表达式返回的每一行调用某个函数。 + +## Syntax {#syntax} + +```sql +SELECT APPLY( ) FROM [db.]table_name +``` + +## Example {#example} + +```sql +CREATE TABLE columns_transformers (i Int64, j Int16, k Int64) ENGINE = MergeTree ORDER by (i); +INSERT INTO columns_transformers VALUES (100, 10, 324), (120, 8, 23); +SELECT * APPLY(sum) FROM columns_transformers; +``` + +```response +┌─sum(i)─┬─sum(j)─┬─sum(k)─┐ +│ 220 │ 18 │ 347 │ +└────────┴────────┴────────┘ +``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/apply_modifier.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/apply_modifier.md.hash new file mode 100644 index 00000000000..e6957bfd612 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/apply_modifier.md.hash @@ -0,0 +1 @@ +ee04781db23632bf diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/array-join.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/array-join.md index 9fa3aaad4c2..f59001b1f6b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/array-join.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/array-join.md @@ -3,14 +3,15 @@ 'sidebar_label': 'ARRAY JOIN' 'slug': '/sql-reference/statements/select/array-join' 'title': 'ARRAY JOIN 子句' +'doc_type': 'reference' --- # ARRAY JOIN 子句 -对于包含数组列的表,生成一个新表的操作是很常见的,该新表的每一行都包含初始列的每个单独数组元素,而其他列的值则被重复。这就是 `ARRAY JOIN` 子句的基本情况。 +对于包含数组列的表,将初始列的每个单独数组元素生成一行的新表是一个常见操作,同时其他列的值会被重复。这就是 `ARRAY JOIN` 子句的基本用法。 -其名称源于可以将其视为与数组或嵌套数据结构执行 `JOIN`。其意图与 [arrayJoin](/sql-reference/functions/array-join) 函数相似,但该子句的功能更广泛。 +它的名称来源于可以被视为对一个数组或嵌套数据结构执行 `JOIN` 的事实。其意图与 [arrayJoin](/sql-reference/functions/array-join) 函数相似,但该子句的功能更广泛。 语法: @@ -24,14 +25,14 @@ FROM 支持的 `ARRAY JOIN` 类型如下所示: -- `ARRAY JOIN` - 在基本 case 下,空数组不包含在 `JOIN` 的结果中。 -- `LEFT ARRAY JOIN` - `JOIN` 的结果包含带有空数组的行。空数组的值设置为数组元素类型的默认值(通常为 0、空字符串或 NULL)。 +- `ARRAY JOIN` - 在基本情况下,空数组不包含在 `JOIN` 的结果中。 +- `LEFT ARRAY JOIN` - `JOIN` 的结果包含具有空数组的行。空数组的值被设置为数组元素类型的默认值(通常为 0、空字符串或 NULL)。 ## 基本 ARRAY JOIN 示例 {#basic-array-join-examples} ### ARRAY JOIN 和 LEFT ARRAY JOIN {#array-join-left-array-join-examples} -下面的示例展示了 `ARRAY JOIN` 和 `LEFT ARRAY JOIN` 子句的用法。让我们创建一个包含 [Array](../../../sql-reference/data-types/array.md) 类型列的表并插入值: +以下示例演示了 `ARRAY JOIN` 和 `LEFT ARRAY JOIN` 子句的用法。我们来创建一个具有 [Array](../../../sql-reference/data-types/array.md) 类型列的表并插入值: ```sql CREATE TABLE arrays_test @@ -91,7 +92,7 @@ LEFT ARRAY JOIN arr; ### ARRAY JOIN 和 arrayEnumerate 函数 {#array-join-arrayEnumerate} -该函数通常与 `ARRAY JOIN` 一起使用。它允许在应用 `ARRAY JOIN` 后仅对每个数组计数一次。示例: +这个函数通常与 `ARRAY JOIN` 一起使用。它允许在应用 `ARRAY JOIN` 后对每个数组计数一次。示例: ```sql SELECT @@ -111,7 +112,7 @@ LIMIT 10 └─────────┴───────┘ ``` -在此示例中,Reaches 是转换的数量(在应用 `ARRAY JOIN` 后接收到的字符串),而 Hits 是页面浏览量(在 `ARRAY JOIN` 之前的字符串)。在此特定情况下,您可以更简单地获得相同的结果: +在这个示例中,Reaches 是转换的数量(应用 `ARRAY JOIN` 后接收到的字符串),而 Hits 是页面浏览量(在 `ARRAY JOIN` 之前的字符串)。在这种特定情况下,你可以通过一种更简单的方式获得相同的结果: ```sql SELECT @@ -129,9 +130,9 @@ WHERE (CounterID = 160656) AND notEmpty(GoalsReached) ### ARRAY JOIN 和 arrayEnumerateUniq {#array_join_arrayEnumerateUniq} -在使用 `ARRAY JOIN` 和聚合数组元素时,此函数非常有用。 +在使用 `ARRAY JOIN` 和聚合数组元素时,这个函数非常有用。 -在此示例中,每个目标 ID 都计算了转换的数量(Goals 嵌套数据结构中的每个元素是一个达成的目标,我们称之为转换)和会话数量。如果没有 `ARRAY JOIN`,我们将会话数量计算为 sum(Sign)。但在此特定情况下,行数是由嵌套 Goals 结构乘以的,因此为了在这之后计算每个会话一次,我们对 `arrayEnumerateUniq(Goals.ID)` 函数的值应用条件。 +在这个示例中,每个目标 ID 都有一个转换数量的计算(Goals 嵌套数据结构中的每个元素都是一个达成的目标,我们称之为转换)和会话的数量。在没有 `ARRAY JOIN` 的情况下,我们会将会话的数量统计为 sum(Sign)。但在这种特定情况下,行数被嵌套的 Goals 结构乘以,因此为了在这之后计算每个会话一次,我们应用了对 `arrayEnumerateUniq(Goals.ID)` 函数值的条件。 ```sql SELECT @@ -165,7 +166,7 @@ LIMIT 10 ## 使用别名 {#using-aliases} -可以为 `ARRAY JOIN` 子句中的数组指定别名。在这种情况下,可以通过该别名访问数组项目,但数组本身仍通过原始名称访问。示例: +在 `ARRAY JOIN` 子句中,可以为数组指定一个别名。在这种情况下,可以通过这个别名访问数组项,但数组本身通过原始名称访问。示例: ```sql SELECT s, arr, a @@ -183,7 +184,7 @@ ARRAY JOIN arr AS a; └───────┴─────────┴───┘ ``` -使用别名,您可以通过外部数组执行 `ARRAY JOIN`。例如: +使用别名,你可以对子数组执行 `ARRAY JOIN`。例如: ```sql SELECT s, arr_external @@ -205,7 +206,7 @@ ARRAY JOIN [1, 2, 3] AS arr_external; └─────────────┴──────────────┘ ``` -在 `ARRAY JOIN` 子句中,可以用逗号分隔多个数组。在这种情况下,会同时对它们执行 `JOIN`(直接和,而不是笛卡尔积)。请注意,默认情况下,所有数组必须具有相同的大小。示例: +多个数组可以在 `ARRAY JOIN` 子句中用逗号分隔。在这种情况下,`JOIN` 是同时执行的(直接的总和,而不是笛卡尔积)。请注意,默认情况下所有数组必须具有相同的大小。示例: ```sql SELECT s, arr, a, num, mapped @@ -223,7 +224,7 @@ ARRAY JOIN arr AS a, arrayEnumerate(arr) AS num, arrayMap(x -> x + 1, arr) AS ma └───────┴─────────┴───┴─────┴────────┘ ``` -下面的示例使用 [arrayEnumerate](/sql-reference/functions/array-functions#arrayenumeratearr) 函数: +下面的示例使用了 [arrayEnumerate](/sql-reference/functions/array-functions#arrayEnumerate) 函数: ```sql SELECT s, arr, a, num, arrayEnumerate(arr) @@ -241,11 +242,11 @@ ARRAY JOIN arr AS a, arrayEnumerate(arr) AS num; └───────┴─────────┴───┴─────┴─────────────────────┘ ``` -可以通过使用:`SETTINGS enable_unaligned_array_join = 1` 将不同大小的多个数组连接起来。示例: +可以通过使用 `SETTINGS enable_unaligned_array_join = 1` 将多个不同大小的数组连接起来。示例: ```sql SELECT s, arr, a, b -FROM arrays_test ARRAY JOIN arr as a, [['a','b'],['c']] as b +FROM arrays_test ARRAY JOIN arr AS a, [['a','b'],['c']] AS b SETTINGS enable_unaligned_array_join = 1; ``` @@ -263,7 +264,7 @@ SETTINGS enable_unaligned_array_join = 1; ## ARRAY JOIN 与嵌套数据结构 {#array-join-with-nested-data-structure} -`ARRAY JOIN` 同样适用于 [嵌套数据结构](../../../sql-reference/data-types/nested-data-structures/index.md): +`ARRAY JOIN` 也适用于 [嵌套数据结构](../../../sql-reference/data-types/nested-data-structures/index.md): ```sql CREATE TABLE nested_test @@ -302,7 +303,7 @@ ARRAY JOIN nest; └───────┴────────┴────────┘ ``` -在 `ARRAY JOIN` 中指定嵌套数据结构的名称时,含义与其包含的所有数组元素的 `ARRAY JOIN` 相同。下面列出了示例: +在 `ARRAY JOIN` 中指定嵌套数据结构的名称时,其含义与其构成的所有数组元素的 `ARRAY JOIN` 相同。以下是示例: ```sql SELECT s, `nest.x`, `nest.y` @@ -320,7 +321,7 @@ ARRAY JOIN `nest.x`, `nest.y`; └───────┴────────┴────────┘ ``` -这个变体也有意义: +这种变体也有意义: ```sql SELECT s, `nest.x`, `nest.y` @@ -338,7 +339,7 @@ ARRAY JOIN `nest.x`; └───────┴────────┴────────────┘ ``` -可以为嵌套数据结构使用别名,以选择要么 `JOIN` 的结果,要么源数组。示例: +可以为嵌套数据结构使用别名,以选择 `JOIN` 结果或源数组。示例: ```sql SELECT s, `n.x`, `n.y`, `nest.x`, `nest.y` @@ -356,7 +357,7 @@ ARRAY JOIN nest AS n; └───────┴─────┴─────┴─────────┴────────────┘ ``` -使用 [arrayEnumerate](/sql-reference/functions/array-functions#arrayenumeratearr) 函数的示例: +使用 [arrayEnumerate](/sql-reference/functions/array-functions#arrayEnumerate) 函数的示例: ```sql SELECT s, `n.x`, `n.y`, `nest.x`, `nest.y`, num @@ -376,14 +377,14 @@ ARRAY JOIN nest AS n, arrayEnumerate(`nest.x`) AS num; ## 实现细节 {#implementation-details} -在运行 `ARRAY JOIN` 时,查询执行顺序是优化的。虽然 `ARRAY JOIN` 必须始终在查询中指定在 [WHERE](../../../sql-reference/statements/select/where.md)/[PREWHERE](../../../sql-reference/statements/select/prewhere.md) 子句之前,但从技术上讲,它们可以以任何顺序执行,除非 `ARRAY JOIN` 的结果用于过滤。处理顺序由查询优化器控制。 +运行 `ARRAY JOIN` 时,查询执行顺序是经过优化的。虽然 `ARRAY JOIN` 必须始终在查询中的 [WHERE](../../../sql-reference/statements/select/where.md)/[PREWHERE](../../../sql-reference/statements/select/prewhere.md) 子句之前指定,但从技术上讲,它们可以以任何顺序执行,除非 `ARRAY JOIN` 的结果用于过滤。处理顺序由查询优化器控制。 ### 与短路函数求值的不兼容性 {#incompatibility-with-short-circuit-function-evaluation} -[短路函数求值](/operations/settings/settings#short_circuit_function_evaluation) 是一种优化特定函数(如 `if`、`multiIf`、`and` 和 `or`)中复杂表达式执行的特性。它防止在执行这些函数的过程中出现潜在异常,例如除以零。 +[短路函数求值](/operations/settings/settings#short_circuit_function_evaluation) 是一个功能,它优化在特定函数(如 `if`、`multiIf`、`and` 和 `or`)中复杂表达式的执行。它防止在这些函数执行期间出现潜在异常,例如除以零。 -`arrayJoin` 始终被执行,并且不支持短路函数求值。这是因为它是一个独特的函数,在查询分析和执行中与所有其他函数分开处理,并且需要额外的逻辑,这与短路函数执行不兼容。原因在于,结果中的行数取决于 `arrayJoin` 的结果,懒惰地执行 `arrayJoin` 实现起来太复杂且成本太高。 +`arrayJoin` 始终被执行,并且不支持短路函数求值。这是因为它是一个单独处理的独特函数,在查询分析和执行期间与所有其他函数分开处理,并且需要额外的逻辑,这在短路函数执行中不起作用。原因是结果中的行数取决于 `arrayJoin` 的结果,而实现 `arrayJoin` 的惰性执行太复杂和昂贵。 ## 相关内容 {#related-content} -- 博客:[在 ClickHouse 中处理时间序列数据](https://clickhouse.com/blog/working-with-time-series-data-and-functions-ClickHouse) +- 博客: [在 ClickHouse 中处理时间序列数据](https://clickhouse.com/blog/working-with-time-series-data-and-functions-ClickHouse) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/array-join.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/array-join.md.hash index eee667b2157..1c5d53cb7f4 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/array-join.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/array-join.md.hash @@ -1 +1 @@ -feec2bf04e91b613 +837c74651a0362c8 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/distinct.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/distinct.md index b43da0bc1c4..7c4d17693a4 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/distinct.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/distinct.md @@ -3,16 +3,17 @@ 'sidebar_label': 'DISTINCT' 'slug': '/sql-reference/statements/select/distinct' 'title': 'DISTINCT 子句' +'doc_type': 'reference' --- # DISTINCT 子句 -如果指定了 `SELECT DISTINCT`,查询结果中只会保留唯一的行。因此,在结果中,所有完全匹配的行中只会保留一行。 +如果指定了 `SELECT DISTINCT`,则查询结果中只会保留唯一的行。因此,所有完全匹配的行中只会剩下单行。 -您可以指定必须具有唯一值的列列表:`SELECT DISTINCT ON (column1, column2,...)`。如果未指定列,则考虑所有列。 +您可以指定必须具有唯一值的列列表:`SELECT DISTINCT ON (column1, column2,...)`。如果没有指定列,则考虑所有列。 -请考虑以下表: +考虑以下表: ```text ┌─a─┬─b─┬─c─┐ @@ -25,7 +26,7 @@ └───┴───┴───┘ ``` -使用未指定列的 `DISTINCT`: +使用 `DISTINCT` 而不指定列: ```sql SELECT DISTINCT * FROM t1; @@ -40,7 +41,7 @@ SELECT DISTINCT * FROM t1; └───┴───┴───┘ ``` -使用指定列的 `DISTINCT`: +使用 `DISTINCT` 并指定列: ```sql SELECT DISTINCT ON (a,b) * FROM t1; @@ -54,11 +55,11 @@ SELECT DISTINCT ON (a,b) * FROM t1; └───┴───┴───┘ ``` -## DISTINCT 和 ORDER BY {#distinct-and-order-by} +## DISTINCT 与 ORDER BY {#distinct-and-order-by} ClickHouse 支持在一个查询中对不同列使用 `DISTINCT` 和 `ORDER BY` 子句。`DISTINCT` 子句在 `ORDER BY` 子句之前执行。 -请考虑以下表: +考虑以下表: ```text ┌─a─┬─b─┐ @@ -82,7 +83,6 @@ SELECT DISTINCT a FROM t1 ORDER BY b ASC; │ 3 │ └───┘ ``` - 选择不同排序方向的数据: ```sql @@ -97,18 +97,18 @@ SELECT DISTINCT a FROM t1 ORDER BY b DESC; └───┘ ``` -在排序之前,第 `2` 和 `4` 行被剪切。 +在排序之前,行 `2, 4` 被截断。 -在编写查询时,请考虑这一实现细节。 +在编写查询时,请考虑此实现特性。 -## NULL 处理 {#null-processing} +## Null 处理 {#null-processing} -`DISTINCT` 将 [NULL](/sql-reference/syntax#null) 视作特定值,并且 `NULL==NULL`。换句话说,在 `DISTINCT` 结果中,包含 `NULL` 的不同组合只出现一次。这与其他大多数上下文中的 `NULL` 处理有所不同。 +`DISTINCT` 将 [NULL](/sql-reference/syntax#null) 视为特定值进行处理,并且 `NULL==NULL`。换句话说,在 `DISTINCT` 的结果中,带有 `NULL` 的不同组合仅出现一次。这与大多数其他上下文中的 `NULL` 处理有所不同。 ## 替代方案 {#alternatives} -可以通过在与 `SELECT` 子句指定的相同值集合上应用 [GROUP BY](/sql-reference/statements/select/group-by),而不使用任何聚合函数,从而获得相同的结果。但与 `GROUP BY` 方法有一些不同之处: +可以通过在与 `SELECT` 子句中指定的相同值集上应用 [GROUP BY](/sql-reference/statements/select/group-by) 来获得相同的结果,而不使用任何聚合函数。但与 `GROUP BY` 方法有一些不同之处: - `DISTINCT` 可以与 `GROUP BY` 一起使用。 -- 当省略 [ORDER BY](../../../sql-reference/statements/select/order-by.md) 并定义 [LIMIT](../../../sql-reference/statements/select/limit.md) 时,查询将在读取所需数量的不同行后立即停止运行。 -- 数据块在处理时输出,而不等待整个查询完成。 +- 当省略 [ORDER BY](../../../sql-reference/statements/select/order-by.md) 且定义了 [LIMIT](../../../sql-reference/statements/select/limit.md) 时,查询在读取到所需数量的不同行后会立即停止运行。 +- 数据块在处理时输出,而无需等待整个查询完成运行。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/distinct.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/distinct.md.hash index a6da6a79715..c4caa178714 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/distinct.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/distinct.md.hash @@ -1 +1 @@ -e8990d7c6e8cc953 +92a17c7117d93a34 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/except.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/except.md index 715914522e4..8bc4db908da 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/except.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/except.md @@ -1,19 +1,23 @@ --- -'description': 'EXCEPT 子句 的文档' +'description': 'EXCEPT 子句的文档,它仅返回由于第一个查询而产生的行,而不包括第二个。' 'sidebar_label': 'EXCEPT' 'slug': '/sql-reference/statements/select/except' 'title': 'EXCEPT 子句' +'keywords': +- 'EXCEPT' +- 'clause' +'doc_type': 'reference' --- # EXCEPT 子句 -`EXCEPT` 子句仅返回第一个查询的结果中不包含第二个查询的行。 +> `EXCEPT` 子句仅返回第一条查询的结果中不包括第二条查询的行。 - 两个查询必须具有相同数量的列,并且列的顺序和数据类型必须相同。 -- `EXCEPT` 的结果可以包含重复的行。如果不希望出现重复行,请使用 `EXCEPT DISTINCT`。 -- 如果没有指定括号,多个 `EXCEPT` 语句将从左到右依次执行。 -- `EXCEPT` 操作符与 `UNION` 子句的优先级相同,低于 `INTERSECT` 子句的优先级。 +- `EXCEPT` 的结果可以包含重复行。如果不希望出现重复行,请使用 `EXCEPT DISTINCT`。 +- 如果未指定括号,则多个 `EXCEPT` 语句按从左到右的顺序执行。 +- `EXCEPT` 操作符的优先级与 `UNION` 子句相同,低于 `INTERSECT` 子句。 ## 语法 {#syntax} @@ -28,9 +32,9 @@ SELECT column1 [, column2 ] FROM table2 [WHERE condition] ``` -条件可以是根据您的要求的任何表达式。 +条件可以是基于您的需求的任何表达式。 -此外,可以使用 `EXCEPT()` 来排除结果中的某些列,语法与 BigQuery (Google Cloud) 中的用法相同,如下所示: +此外,可以使用 `EXCEPT()` 从同一表的结果中排除列,正如在 BigQuery(Google Cloud)中可能的那样,使用以下语法: ```sql SELECT column1 [, column2 ] EXCEPT (column3 [, column4]) @@ -40,25 +44,21 @@ FROM table1 ## 示例 {#examples} -本节的示例演示了 `EXCEPT` 子句的用法。 +本节中的示例演示了 `EXCEPT` 子句的用法。 ### 使用 `EXCEPT` 子句过滤数字 {#filtering-numbers-using-the-except-clause} -这是一个简单的示例,它返回数字 1 到 10 中不包括数字 3 到 8 的结果: +这是一个简单的示例,返回 1 到 10 中不在 3 到 8 中的数字: -查询: - -```sql +```sql title="Query" SELECT number FROM numbers(1, 10) EXCEPT SELECT number -FROM numbers(3, 8) +FROM numbers(3, 6) ``` -结果: - -```response +```response title="Response" ┌─number─┐ │ 1 │ │ 2 │ @@ -69,11 +69,9 @@ FROM numbers(3, 8) ### 使用 `EXCEPT()` 排除特定列 {#excluding-specific-columns-using-except} -`EXCEPT()` 可以快速排除结果中的列。例如,如果我们想选择表中的所有列,但排除一些特定的列,如下例所示: - -查询: +`EXCEPT()` 可以快速排除结果中的列。例如,如果我们想从表中选择所有列,但排除一些特定列,如下例所示: -```sql +```sql title="Query" SHOW COLUMNS IN system.settings SELECT * EXCEPT (default, alias_for, readonly, description) @@ -81,9 +79,7 @@ FROM system.settings LIMIT 5 ``` -结果: - -```response +```response title="Response" ┌─field───────┬─type─────────────────────────────────────────────────────────────────────┬─null─┬─key─┬─default─┬─extra─┐ 1. │ alias_for │ String │ NO │ │ ᴺᵁᴸᴸ │ │ 2. │ changed │ UInt8 │ NO │ │ ᴺᵁᴸᴸ │ │ @@ -108,14 +104,12 @@ LIMIT 5 └─────────────────────────┴────────────┴─────────┴──────┴──────┴─────────┴─────────────┴────────────┘ ``` -### 使用 `EXCEPT` 和 `INTERSECT` 处理加密货币数据 {#using-except-and-intersect-with-cryptocurrency-data} - -`EXCEPT` 和 `INTERSECT` 在不同的布尔逻辑中通常可以互换使用,它们都在两个共享一个或多个公共列的表中非常有用。 -例如,假设我们有几百万行的历史加密货币数据,其中包含交易价格和交易量: +### 在加密货币数据中使用 `EXCEPT` 和 `INTERSECT` {#using-except-and-intersect-with-cryptocurrency-data} -查询: +`EXCEPT` 和 `INTERSECT` 常常可以根据不同的布尔逻辑互换使用,如果您有两个共享公共列(或列)的表,它们都是有用的。 +例如,假设我们有几百万行历史加密货币数据,包含交易价格和交易量: -```sql +```sql title="Query" CREATE TABLE crypto_prices ( trade_date Date, @@ -141,9 +135,7 @@ ORDER BY trade_date DESC LIMIT 10; ``` -结果: - -```response +```response title="Response" ┌─trade_date─┬─crypto_name─┬──────volume─┬────price─┬───market_cap─┬──change_1_day─┐ │ 2020-11-02 │ Bitcoin │ 30771456000 │ 13550.49 │ 251119860000 │ -0.013585099 │ │ 2020-11-01 │ Bitcoin │ 24453857000 │ 13737.11 │ 254569760000 │ -0.0031840964 │ @@ -158,7 +150,7 @@ LIMIT 10; └────────────┴─────────────┴─────────────┴──────────┴──────────────┴───────────────┘ ``` -现在假设我们有一个名为 `holdings` 的表,包含我们拥有的加密货币列表,以及每种货币的数量: +现在假设我们有一个名为 `holdings` 的表,包含我们拥有的加密货币的列表,以及相应的硬币数量: ```sql CREATE TABLE holdings @@ -178,46 +170,42 @@ INSERT INTO holdings VALUES ('Bitcoin Diamond', 5000); ``` -我们可以使用 `EXCEPT` 来回答这样的问题 **“我们拥有的哪些币的交易价格从未低于 $10?”**: +我们可以使用 `EXCEPT` 来回答一个问题,例如 **“我们拥有的硬币中,哪些从未交易低于 $10?”**: -```sql +```sql title="Query" SELECT crypto_name FROM holdings EXCEPT SELECT crypto_name FROM crypto_prices WHERE price < 10; ``` -结果: - -```response +```response title="Response" ┌─crypto_name─┐ │ Bitcoin │ │ Bitcoin │ └─────────────┘ ``` -这意味着在我们拥有的四种加密货币中,只有比特币从未跌破 $10(基于我们在此示例中的有限数据)。 +这意味着在我们拥有的四种加密货币中,只有比特币从未跌破过 $10(基于我们在此示例中拥有的有限数据)。 ### 使用 `EXCEPT DISTINCT` {#using-except-distinct} -注意在之前的查询中,我们在结果中有多个比特币的持有记录。您可以在 `EXCEPT` 后添加 `DISTINCT` 以消除结果中的重复行: +注意在前面的查询中,结果中有多个比特币 holdings。您可以在 `EXCEPT` 中添加 `DISTINCT` 来消除结果中的重复行: -```sql +```sql title="Query" SELECT crypto_name FROM holdings EXCEPT DISTINCT SELECT crypto_name FROM crypto_prices WHERE price < 10; ``` -结果: - -```response +```response title="Response" ┌─crypto_name─┐ │ Bitcoin │ └─────────────┘ ``` -**另请参见** +**另请参阅** - [UNION](/sql-reference/statements/select/union) - [INTERSECT](/sql-reference/statements/select/intersect) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/except.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/except.md.hash index 134fed7975f..6f8abad5f7c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/except.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/except.md.hash @@ -1 +1 @@ -cb21718ce28f8163 +d1cd9afe0f1e097e diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/except_modifier.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/except_modifier.md new file mode 100644 index 00000000000..ff23a5f0ca6 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/except_modifier.md @@ -0,0 +1,34 @@ +--- +'description': '文档描述了 EXCEPT 修饰符,该修饰符指定要从结果中排除的一个或多个列的名称。所有匹配的列名都将从输出中省略。' +'sidebar_label': 'EXCEPT' +'slug': '/sql-reference/statements/select/except-modifier' +'title': 'EXCEPT 修饰符' +'keywords': +- 'EXCEPT' +- 'modifier' +'doc_type': 'reference' +--- + + +# EXCEPT 修饰符 {#except} + +> 指定要从结果中排除的一列或多列的名称。所有匹配的列名将从输出中省略。 + +## 语法 {#syntax} + +```sql +SELECT EXCEPT ( col_name1 [, col_name2, col_name3, ...] ) FROM [db.]table_name +``` + +## 示例 {#examples} + +```sql title="Query" +SELECT * EXCEPT (i) from columns_transformers; +``` + +```response title="Response" +┌──j─┬───k─┐ +│ 10 │ 324 │ +│ 8 │ 23 │ +└────┴─────┘ +``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/except_modifier.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/except_modifier.md.hash new file mode 100644 index 00000000000..516bd655410 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/except_modifier.md.hash @@ -0,0 +1 @@ +ac35555eff766c54 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/format.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/format.md index 6253e7a75b7..97b2722ccec 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/format.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/format.md @@ -1,21 +1,22 @@ --- -'description': 'FORMAT 子句的文档' +'description': 'FORMAT 子句 的文档' 'sidebar_label': 'FORMAT' 'slug': '/sql-reference/statements/select/format' 'title': 'FORMAT 子句' +'doc_type': 'reference' --- # FORMAT 子句 -ClickHouse 支持多种 [序列化格式](../../../interfaces/formats.md),可用于查询结果等多个方面。有多种方法可以选择 `SELECT` 输出格式,其中之一是在查询末尾指定 `FORMAT format` 以获取任何特定格式的结果数据。 +ClickHouse 支持多种 [序列化格式](../../../interfaces/formats.md),可用于查询结果等多种场景。有多种方式可以为 `SELECT` 输出选择格式,其中之一是在查询末尾指定 `FORMAT format` 以获取特定格式的结果数据。 -特定格式可以用于便利性、与其他系统的集成或性能提升。 +使用特定格式可能是出于便利性、与其他系统的集成或性能提升的考虑。 ## 默认格式 {#default-format} -如果省略 `FORMAT` 子句,则使用默认格式,具体取决于设置和用于访问 ClickHouse 服务器的接口。对于 [HTTP 接口](../../../interfaces/http.md) 和批处理模式中的 [命令行客户端](../../../interfaces/cli.md),默认格式为 `TabSeparated`。对于交互模式中的命令行客户端,默认格式为 `PrettyCompact`(它生成紧凑的易读表格)。 +如果省略 `FORMAT` 子句,将使用默认格式,该格式取决于访问 ClickHouse 服务器所用的设置和接口。对于 [HTTP 接口](../../../interfaces/http.md) 和以批处理模式运行的 [命令行客户端](../../../interfaces/cli.md),默认格式为 `TabSeparated`。对于以交互模式运行的命令行客户端,默认格式为 `PrettyCompact` (它生成紧凑的人类可读表格)。 ## 实现细节 {#implementation-details} -在使用命令行客户端时,数据始终以内部高效格式 (`Native`) 通过网络传输。客户端独立解释查询的 `FORMAT` 子句,并自行格式化数据(从而减轻网络和服务器的额外负担)。 +在使用命令行客户端时,数据始终以内部高效格式(`Native`)通过网络传输。客户端独立解释查询的 `FORMAT` 子句并自行格式化数据(从而减轻网络和服务器的额外负担)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/format.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/format.md.hash index 131b9c5987f..e8304ac3f7b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/format.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/format.md.hash @@ -1 +1 @@ -5a1e9a671917b659 +024b670658ff84d0 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/from.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/from.md index c4ef6a8d184..0c6f22a0aef 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/from.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/from.md @@ -1,14 +1,15 @@ --- -'description': 'FROM 子句的文档' +'description': 'FROM 子句 的文档' 'sidebar_label': 'FROM' 'slug': '/sql-reference/statements/select/from' 'title': 'FROM 子句' +'doc_type': 'reference' --- # FROM 子句 -`FROM` 子句指定读取数据的源: +`FROM` 子句指定要读取数据的源: - [表](../../../engines/table-engines/index.md) - [子查询](../../../sql-reference/statements/select/index.md) @@ -16,11 +17,11 @@ [JOIN](../../../sql-reference/statements/select/join.md) 和 [ARRAY JOIN](../../../sql-reference/statements/select/array-join.md) 子句也可以用于扩展 `FROM` 子句的功能。 -子查询是可以在 `FROM` 子句中用括号指定的另一个 `SELECT` 查询。 +子查询是另一种 `SELECT` 查询,可以在 `FROM` 子句内用括号指定。 -`FROM` 可以包含多个数据源,以逗号分隔,这相当于对它们执行 [CROSS JOIN](../../../sql-reference/statements/select/join.md)。 +`FROM` 可以包含多个数据源,用逗号分隔,这相当于对它们执行 [CROSS JOIN](../../../sql-reference/statements/select/join.md)。 -`FROM` 可以选择性地出现在 `SELECT` 子句之前。这是 ClickHouse 特有的标准 SQL 扩展,使 `SELECT` 语句更易于阅读。示例: +`FROM` 可以选择性地出现在 `SELECT` 子句之前。这是 ClickHouse 特有的扩展,使得 `SELECT` 语句更容易阅读。示例: ```sql FROM table @@ -29,29 +30,29 @@ SELECT * ## FINAL 修饰符 {#final-modifier} -当指定 `FINAL` 时,ClickHouse 在返回结果之前会完全合并数据。这还会为给定的表引擎执行在合并过程中发生的所有数据转换。 +当指定 `FINAL` 时,ClickHouse 会在返回结果之前完全合并数据。这也会执行在给定表引擎的合并期间发生的所有数据转换。 -在从使用以下表引擎的表中选择数据时适用: +在使用以下表引擎从表中选择数据时适用: - `ReplacingMergeTree` - `SummingMergeTree` - `AggregatingMergeTree` - `CollapsingMergeTree` - `VersionedCollapsingMergeTree` -带有 `FINAL` 的 `SELECT` 查询是并行执行的。 [max_final_threads](/operations/settings/settings#max_final_threads) 设置限制了使用的线程数量。 +带有 `FINAL` 的 `SELECT` 查询是并行执行的。设置 [max_final_threads](/operations/settings/settings#max_final_threads) 限制了使用的线程数。 ### 缺点 {#drawbacks} 使用 `FINAL` 的查询执行速度略慢于不使用 `FINAL` 的类似查询,因为: - 数据在查询执行期间被合并。 -- 带有 `FINAL` 的查询可能会读取主键列,以及查询中指定的列。 +- 带有 `FINAL` 的查询可能会读取除查询中指定的列以外的主键列。 -`FINAL` 需要额外的计算和内存资源,因为通常会在合并时发生的处理必须在查询时内存中进行。然而,使用 FINAL 有时是必须的,以便产生准确的结果(因为数据可能尚未完全合并)。这比运行 `OPTIMIZE` 强制合并要便宜。 +`FINAL` 需要额外的计算和内存资源,因为通常在合并时发生的处理必须在查询时在内存中进行。然而,为了生成准确的结果,有时需要使用 `FINAL`(因为数据可能还没有完全合并)。它的成本低于运行 `OPTIMIZE` 强制合并。 -作为使用 `FINAL` 的替代,有时可以使用不同的查询,这些查询假定 `MergeTree` 引擎的后台进程尚未发生,并通过应用聚合(例如,丢弃重复项)来处理它。如果需要在查询中使用 `FINAL` 以获得所需结果,使用它是可以的,但要意识到所需的额外处理。 +作为使用 `FINAL` 的替代方案,有时可以使用不同的查询,假设 `MergeTree` 引擎的后台进程尚未发生,并通过应用聚合来处理它(例如,丢弃重复项)。如果您需要在查询中使用 `FINAL` 以获得所需的结果,可以这样做,但要注意所需的额外处理。 -可以使用 [FINAL](../../../operations/settings/settings.md#final) 设置自动应用于查询中所有表的 `FINAL`。 +`FINAL` 可以通过 [FINAL](../../../operations/settings/settings.md#final) 设置自动应用于查询中的所有表,使用会话或用户配置文件。 ### 示例用法 {#example-usage} @@ -61,13 +62,13 @@ SELECT * SELECT x, y FROM mytable FINAL WHERE x > 1; ``` -将 `FINAL` 作为查询级别的设置使用 +将 `FINAL` 作为查询级别设置使用 ```sql SELECT x, y FROM mytable WHERE x > 1 SETTINGS final = 1; ``` -将 `FINAL` 作为会话级别的设置使用 +将 `FINAL` 作为会话级别设置使用 ```sql SET final = 1; @@ -76,8 +77,8 @@ SELECT x, y FROM mytable WHERE x > 1; ## 实现细节 {#implementation-details} -如果省略 `FROM` 子句,将从 `system.one` 表读取数据。 -`system.one` 表确切包含一行(该表发挥的作用与其他 DBMS 中的 DUAL 表相同)。 +如果省略 `FROM` 子句,则数据将从 `system.one` 表中读取。 +`system.one` 表仅包含一行(该表的作用与其他数据库管理系统中的 DUAL 表相同)。 -要执行查询,查询中列出的所有列都从适当的表中提取。任何外部查询不需要的列都将从子查询中丢弃。 -如果查询没有列出任何列(例如,`SELECT count() FROM t`),仍会从表中提取某些列(首选最小的列),以计算行数。 +要执行查询,查询中列出的所有列都从适当的表中提取。任何对于外部查询不需要的列会从子查询中剔除。 +如果查询未列出任何列(例如,`SELECT count() FROM t`),仍然会从表中提取某一列(优先选择最小的列),以计算行数。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/from.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/from.md.hash index a9a5250af69..402efce5f79 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/from.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/from.md.hash @@ -1 +1 @@ -f77c1da59247aa32 +331b086f8f3fc1df diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/group-by.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/group-by.md index 23af0f15a93..91ab52686b5 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/group-by.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/group-by.md @@ -1,32 +1,33 @@ --- -'description': 'GROUP BY 子句的文档' +'description': 'GROUP BY 子句 的文档' 'sidebar_label': 'GROUP BY' 'slug': '/sql-reference/statements/select/group-by' 'title': 'GROUP BY 子句' +'doc_type': 'reference' --- # GROUP BY 子句 -`GROUP BY` 子句将 `SELECT` 查询切换到聚合模式,工作原理如下: +`GROUP BY` 子句将 `SELECT` 查询切换到聚合模式,其工作方式如下: -- `GROUP BY` 子句包含一个表达式列表(或者一个表达式,视为长度为一的列表)。该列表作为“分组键”,而每个单独的表达式将被称为“键表达式”。 -- 所有在 [SELECT](/sql-reference/statements/select/index.md)、[HAVING](/sql-reference/statements/select/having.md) 和 [ORDER BY](/sql-reference/statements/select/order-by.md) 子句中的表达式 **必须** 基于键表达式 **或** 在非键表达式(包括普通列)上的 [聚合函数](../../../sql-reference/aggregate-functions/index.md) 来计算。换句话说,从表中选择的每一列必须要么用于键表达式,要么在聚合函数内使用,但不能同时用于两者。 -- 聚合 `SELECT` 查询的结果行数将与源表中“分组键”的唯一值数量相等。通常,这会显著降低行数,往往是几个数量级,但不一定:如果所有“分组键”值都是唯一的,行数保持不变。 +- `GROUP BY` 子句包含一个表达式列表(或一个单一表达式,该表达式被视为长度为一的列表)。这个列表充当“分组键”,而每个单独的表达式将被称为“键表达式”。 +- [SELECT](/sql-reference/statements/select/index.md)、[HAVING](/sql-reference/statements/select/having.md) 和 [ORDER BY](/sql-reference/statements/select/order-by.md) 子句中的所有表达式 **必须** 基于键表达式 **或** 非键表达式(包括普通列)上的 [聚合函数](../../../sql-reference/aggregate-functions/index.md) 进行计算。换句话说,从表中选择的每一列必须用于键表达式或聚合函数内部,但不能同时用于这两者。 +- 聚合 `SELECT` 查询的结果将包含与源表中“分组键”唯一值的数量相等的行。通常,这会显著减少行数,通常是几个数量级,但并不一定:如果所有“分组键”值都是唯一的,则行数保持不变。 -当您想根据列号而不是列名对表中的数据进行分组时,可以启用设置 [enable_positional_arguments](/operations/settings/settings#enable_positional_arguments)。 +当您希望按列数字而不是列名对表中的数据进行分组时,请启用设置 [enable_positional_arguments](/operations/settings/settings#enable_positional_arguments)。 :::note -还有另一种在表上运行聚合的方法。如果查询仅在聚合函数内包含表列,则 `GROUP BY` 子句可以省略,并假定使用空的键集进行聚合。这种查询始终返回正好一行。 +还有另一种在表上运行聚合的方法。如果查询仅在聚合函数内部包含表列,则可以省略 `GROUP BY` 子句,默认情况下假设根据空的键集进行聚合。这类查询总是返回一行。 ::: ## NULL 处理 {#null-processing} -在分组时,ClickHouse 将 [NULL](/sql-reference/syntax#null) 视为一个值,并且 `NULL==NULL`。这与其他上下文中的 `NULL` 处理有所不同。 +对于分组,ClickHouse 将 [NULL](/sql-reference/syntax#null) 视为值,并且 `NULL==NULL`。这与大多数其他上下文中的 NULL 处理不同。 -以下是一个示例,说明这意味着什么。 +以下是一个示例以展示这意味着什么。 -假设您有以下表: +假设您有这个表: ```text ┌─x─┬────y─┐ @@ -38,7 +39,7 @@ └───┴──────┘ ``` -查询 `SELECT sum(x), y FROM t_null_big GROUP BY y` 的结果为: +查询 `SELECT sum(x), y FROM t_null_big GROUP BY y` 的结果是: ```text ┌─sum(x)─┬────y─┐ @@ -48,20 +49,20 @@ └────────┴──────┘ ``` -您可以看到 `GROUP BY` 对 `y = NULL` 的处理对 `x` 进行了求和,就好像 `NULL` 是这个值一样。 +您可以看到对于 `y = NULL` 的 `GROUP BY` 对 `x` 进行了求和,仿佛 `NULL` 是这个值。 -如果您向 `GROUP BY` 传递多个键,结果将给出所选内容的所有组合,就好像 `NULL` 是一个特定的值。 +如果您将多个键传递给 `GROUP BY`,结果将给出选择的所有组合,仿佛 `NULL` 是一个特定值。 ## ROLLUP 修饰符 {#rollup-modifier} -`ROLLUP` 修饰符用于根据 `GROUP BY` 列表中的顺序计算键表达式的子总计。子总计行在结果表之后添加。 +`ROLLUP` 修饰符用于根据 `GROUP BY` 列表中的顺序计算键表达式的子总计。子总计行将添加到结果表之后。 -子总计是按相反顺序计算的:首先为列表中的最后一个键表达式计算子总计,然后是前一个,以此类推,直到第一个键表达式。 +子总计是按相反的顺序计算的:首先计算列表中最后一个键表达式的子总计,然后是前一个,以此类推,直到第一个键表达式。 -在子总计行中,已“分组”的键表达式的值被设置为 `0` 或空行。 +在子总计行中,已经“分组”的键表达式的值被设置为 `0` 或空行。 :::note -请注意, [HAVING](/sql-reference/statements/select/having.md) 子句可能会影响子总计结果。 +请注意 [HAVING](/sql-reference/statements/select/having.md) 子句可能会影响子总计结果。 ::: **示例** @@ -84,12 +85,12 @@ ```sql SELECT year, month, day, count(*) FROM t GROUP BY ROLLUP(year, month, day); ``` -由于 `GROUP BY` 部分有三个键表达式,因此结果包含四个带有子总计的表,这些总计是从右到左“滚动”得出的: +由于 `GROUP BY` 部分有三个键表达式,结果包含四个带有从右到左“卷起”的子总计的表: -- `GROUP BY year, month, day`; -- `GROUP BY year, month`(`day` 列填充为零); -- `GROUP BY year`(现在 `month, day` 列都填充为零); -- 和总计(所有三个键表达式列都是零)。 +- `GROUP BY year, month, day`; +- `GROUP BY year, month`(并且 `day` 列填充为零); +- `GROUP BY year`(现在 `month, day` 列均填充为零); +- 以及总计(所有三个键表达式列均为零)。 ```text ┌─year─┬─month─┬─day─┬─count()─┐ @@ -113,23 +114,23 @@ SELECT year, month, day, count(*) FROM t GROUP BY ROLLUP(year, month, day); │ 0 │ 0 │ 0 │ 6 │ └──────┴───────┴─────┴─────────┘ ``` -同样的查询也可以使用 `WITH` 关键字重写。 +相同的查询也可以使用 `WITH` 关键字书写。 ```sql SELECT year, month, day, count(*) FROM t GROUP BY year, month, day WITH ROLLUP; ``` -**另请参阅** +**另见** - [group_by_use_nulls](/operations/settings/settings.md#group_by_use_nulls) 设置以兼容 SQL 标准。 ## CUBE 修饰符 {#cube-modifier} -`CUBE` 修饰符用于计算 `GROUP BY` 列表中每个键表达式组合的子总计。子总计行在结果表之后添加。 +`CUBE` 修饰符用于计算 `GROUP BY` 列表中键表达式的每个组合的子总计。子总计行将添加到结果表之后。 -在子总计行中,所有“分组”键表达式的值被设置为 `0` 或空行。 +在子总计行中,所有“分组”的键表达式的值被设置为 `0` 或空行。 :::note -请注意, [HAVING](/sql-reference/statements/select/having.md) 子句可能会影响子总计结果。 +请注意 [HAVING](/sql-reference/statements/select/having.md) 子句可能会影响子总计结果。 ::: **示例** @@ -153,7 +154,7 @@ SELECT year, month, day, count(*) FROM t GROUP BY year, month, day WITH ROLLUP; SELECT year, month, day, count(*) FROM t GROUP BY CUBE(year, month, day); ``` -由于 `GROUP BY` 部分有三个键表达式,因此结果包含八个带有所有键表达式组合的子总计的表: +由于 `GROUP BY` 部分有三个键表达式,结果包含八个带有所有键表达式组合的子总计的表: - `GROUP BY year, month, day` - `GROUP BY year, month` @@ -162,9 +163,9 @@ SELECT year, month, day, count(*) FROM t GROUP BY CUBE(year, month, day); - `GROUP BY month, day` - `GROUP BY month` - `GROUP BY day` -- 和总计。 +- 以及总计。 -未包含在 `GROUP BY` 中的列填充为零。 +不在 `GROUP BY` 中的列填充为零。 ```text ┌─year─┬─month─┬─day─┬─count()─┐ @@ -208,54 +209,54 @@ SELECT year, month, day, count(*) FROM t GROUP BY CUBE(year, month, day); │ 0 │ 0 │ 0 │ 6 │ └──────┴───────┴─────┴─────────┘ ``` -同样的查询也可以使用 `WITH` 关键字重写。 +相同的查询还可以使用 `WITH` 关键字书写。 ```sql SELECT year, month, day, count(*) FROM t GROUP BY year, month, day WITH CUBE; ``` -**另请参阅** +**另见** - [group_by_use_nulls](/operations/settings/settings.md#group_by_use_nulls) 设置以兼容 SQL 标准。 ## WITH TOTALS 修饰符 {#with-totals-modifier} -如果指定了 `WITH TOTALS` 修饰符,将计算另一行。该行将具有包含默认值(零或空行)的键列,以及在所有行上计算的聚合函数的列(“总计”值)。 +如果指定了 `WITH TOTALS` 修饰符,将计算另一行。该行的键列将包含默认值(零或空行),而聚合函数的列将对所有行进行计算(“总计”值)。 -此额外行仅在 `JSON*`、`TabSeparated*` 和 `Pretty*` 格式中生成,与其他行分开: +此额外行仅在 `JSON*`、`TabSeparated*` 和 `Pretty*` 格式中生成,独立于其他行: -- 在 `XML` 和 `JSON*` 格式中,此行作为单独的 'totals' 字段输出。 -- 在 `TabSeparated*`、`CSV*` 和 `Vertical` 格式中,行在主要结果之后,前面有一行空行(在其他数据之后)。 -- 在 `Pretty*` 格式中,该行在主要结果后作为单独的表输出。 -- 在 `Template` 格式中,行根据指定的模板输出。 +- 在 `XML` 和 `JSON*` 格式中,该行输出为单独的“总计”字段。 +- 在 `TabSeparated*`、`CSV*` 和 `Vertical` 格式中,该行在主要结果之后出现,前面有一行空行(在其他数据之后)。 +- 在 `Pretty*` 格式中,该行输出为主要结果之后的单独表。 +- 在 `Template` 格式中,该行根据指定模板输出。 - 在其他格式中不可用。 :::note -在 `SELECT` 查询的结果中输出 totals,但在 `INSERT INTO ... SELECT` 中不会输出。 +总计在 `SELECT` 查询的结果中输出,不会在 `INSERT INTO ... SELECT` 中输出。 ::: -当存在 [HAVING](/sql-reference/statements/select/having.md) 时,`WITH TOTALS` 可以以不同方式运行。该行为取决于 `totals_mode` 设置。 +当存在 [HAVING](/sql-reference/statements/select/having.md) 时,可以以不同方式运行 `WITH TOTALS`。其行为取决于 `totals_mode` 设置。 ### 配置总计处理 {#configuring-totals-processing} -默认情况下,`totals_mode = 'before_having'`。在这种情况下,'totals' 是基于所有行计算的,包括那些未通过 HAVING 和 `max_rows_to_group_by` 的行。 +默认情况下,`totals_mode = 'before_having'`。在这种情况下,“总计”是在所有行上计算的,包括未通过 HAVING 和 `max_rows_to_group_by` 的行。 -其他选项包括仅将通过 HAVING 的行包含在 'totals' 中,并在 `max_rows_to_group_by` 和 `group_by_overflow_mode = 'any'` 设置上表现不同。 +其他选项包括仅将通过 HAVING 的行包含在“总计”中,并在 `max_rows_to_group_by` 和 `group_by_overflow_mode = 'any'` 设置时表现不同。 -`after_having_exclusive` – 不包括未通过 `max_rows_to_group_by` 的行。换句话说,'totals' 的行数将少于或等于未通过 `max_rows_to_group_by` 时的行数。 +`after_having_exclusive` - 不包含未通过 `max_rows_to_group_by` 的行。换句话说,“总计”的行数将少于或等于未省略 `max_rows_to_group_by` 时的行数。 -`after_having_inclusive` – 包含所有未通过 'max_rows_to_group_by' 的行。换句话说,'totals' 的行数将多于或等于未通过 `max_rows_to_group_by` 时的行数。 +`after_having_inclusive` - 包括所有未通过 `max_rows_to_group_by` 的行在“总计”中。换句话说,“总计”的行数将多于或等于未省略 `max_rows_to_group_by` 时的行数。 -`after_having_auto` – 计算通过 HAVING 的行数。如果超过某个数量(默认值 50%),则将所有未通过 'max_rows_to_group_by' 的行包含在 'totals' 中。否则,不包括它们。 +`after_having_auto` - 计算通过 HAVING 的行数。如果超过某个量(默认 50%),则在“总计”中包括所有未通过 `max_rows_to_group_by` 的行。否则,不包括它们。 -`totals_auto_threshold` – 默认值为 0.5。用于 `after_having_auto` 的系数。 +`totals_auto_threshold` - 默认值为 0.5。用于 `after_having_auto` 的系数。 -如果未使用 `max_rows_to_group_by` 和 `group_by_overflow_mode = 'any'`,则所有 `after_having` 的变体是相同的,您可以使用它们中的任何一个(例如, `after_having_auto`)。 +如果未使用 `max_rows_to_group_by` 和 `group_by_overflow_mode = 'any'`,则 `after_having` 的所有变体都是相同的,您可以使用它们中的任何一种(例如,`after_having_auto`)。 -您可以在子查询中使用 `WITH TOTALS`,包括在 [JOIN](/sql-reference/statements/select/join.md) 子句中的子查询(在这种情况下,相应的总值会组合在一起)。 +您可以在子查询中使用 `WITH TOTALS`,包括在 [JOIN](/sql-reference/statements/select/join.md) 子句中的子查询(在此情况下,相应的总计值会合并)。 ## GROUP BY ALL {#group-by-all} -`GROUP BY ALL` 等同于列出所有未使用聚合函数的 SELECT 表达式。 +`GROUP BY ALL` 相当于列出所有未作为聚合函数的 SELECT 表达式。 例如: @@ -268,7 +269,7 @@ FROM t GROUP BY ALL ``` -与 +与以下内容相同: ```sql SELECT @@ -279,9 +280,7 @@ FROM t GROUP BY a * 2, b ``` -相同。 - -对于特殊情况,如果存在一个函数接受聚合函数和其他字段作为其参数,`GROUP BY` 键将包含我们能够提取的最大非聚合字段。 +对于一个特殊情况,如果有一个函数拥有聚合函数和其他字段作为其参数,则 `GROUP BY` 键将包含我们可以从中提取的最大非聚合字段。 例如: @@ -293,7 +292,7 @@ FROM t GROUP BY ALL ``` -与 +与以下内容相同: ```sql SELECT @@ -303,8 +302,6 @@ FROM t GROUP BY substring(a, 4, 2), substring(a, 1, 2) ``` -相同。 - ## 示例 {#examples} 示例: @@ -317,7 +314,7 @@ SELECT FROM hits ``` -与 MySQL 相比(并符合标准 SQL),您不能获取一些不在键或聚合函数中的列的值(常量表达式除外)。为了解决这个问题,您可以使用 'any' 聚合函数(获取首次遇到的值)或 'min/max'。 +与 MySQL 相对(并符合标准 SQL),您不能获取某个不在键或聚合函数中的列的一些值(常量表达式除外)。为了解决这个问题,您可以使用 'any' 聚合函数(获取首次遇到的值)或 'min/max'。 示例: @@ -330,21 +327,21 @@ FROM hits GROUP BY domain ``` -对于每个遇到的不同键值,`GROUP BY` 计算一组聚合函数值。 +对于遇到的每个不同的键值,`GROUP BY` 计算一组聚合函数值。 ## GROUPING SETS 修饰符 {#grouping-sets-modifier} -这是最通用的修饰符。 -此修饰符允许手动指定多个聚合键集(分组集)。 -聚合分别在每个分组集上执行,之后将所有结果合并。 -如果某列未出现在分组集中,则用默认值填充。 +这是最一般的修饰符。 +该修饰符允许手动指定多个聚合键集(分组集)。 +对每个分组集单独执行聚合,然后将所有结果合并在一起。 +如果某一列未在分组集中,则用默认值填充。 -换句话说,上述描述的修饰符可以通过 `GROUPING SETS` 表示。 -尽管带有 `ROLLUP`、`CUBE` 和 `GROUPING SETS` 修饰符的查询在语法上是相等的,但它们的执行方式可能不同。 -当 `GROUPING SETS` 尝试并行执行所有操作时,`ROLLUP` 和 `CUBE` 在单个线程中执行聚合的最终合并。 +换句话说,上述修饰符可以通过 `GROUPING SETS` 表示。 +尽管带有 `ROLLUP`、`CUBE` 和 `GROUPING SETS` 修饰符的查询在语法上是相等的,但它们的执行可能有所不同。 +当 `GROUPING SETS` 尝试并行执行所有内容时,`ROLLUP` 和 `CUBE` 会在单线程中执行聚合的最终合并。 -在源列包含默认值的情况下,可能很难区分一行是否是使用这些列作为键的聚合的一部分。 -为了解决此问题,必须使用 `GROUPING` 函数。 +在源列包含默认值的情况下,可能很难区分一行是否属于使用这些列作为键的聚合。 +为了解决这个问题,必须使用 `GROUPING` 函数。 **示例** @@ -365,32 +362,32 @@ GROUPING SETS ); ``` -**另请参阅** +**另见** - [group_by_use_nulls](/operations/settings/settings.md#group_by_use_nulls) 设置以兼容 SQL 标准。 ## 实现细节 {#implementation-details} -聚合是列式 DBMS 中最重要的功能之一,因此它的实现是 ClickHouse 中优化得最彻底的部分之一。默认情况下,聚合在内存中使用哈希表完成。它具有 40 多种专用实现,可以根据“分组键”数据类型自动选择。 +聚合是列式数据库管理系统最重要的特性之一,因此它的实现是 ClickHouse 最优化的部分之一。默认情况下,聚合是在内存中使用哈希表进行的。它有 40 多个特化版本,依据“分组键”数据类型自动选择。 -### 根据表排序键优化 GROUP BY {#group-by-optimization-depending-on-table-sorting-key} +### 根据表排序键的 GROUP BY 优化 {#group-by-optimization-depending-on-table-sorting-key} -如果表按某个键排序,并且 `GROUP BY` 表达式至少包含排序键的前缀或单射函数,则可以更有效地执行聚合。在这种情况下,当从表中读取新的键时,可以最终确定聚合的中间结果并将其发送给客户端。这种行为由 [optimize_aggregation_in_order](../../../operations/settings/settings.md#optimize_aggregation_in_order) 设置开启。此优化在聚合期间减少内存使用,但在某些情况下可能会减慢查询执行速度。 +如果表通过某个键排序,并且 `GROUP BY` 表达式至少包含排序键的前缀或单射函数,则聚合可以更有效地执行。在这种情况下,当从表中读取新的键时,可以最终确定聚合的中间结果并发送给客户端。此行为通过设置 [optimize_aggregation_in_order](../../../operations/settings/settings.md#optimize_aggregation_in_order) 开启。这种优化在聚合期间减少了内存使用,但在某些情况下可能会减慢查询执行速度。 -### 在外部内存中执行 GROUP BY {#group-by-in-external-memory} +### 在外部内存中的 GROUP BY {#group-by-in-external-memory} -您可以启用将临时数据转储到磁盘,以限制 `GROUP BY` 期间的内存使用情况。 -[ max_bytes_before_external_group_by](/operations/settings/settings#max_bytes_before_external_group_by) 设置确定将 `GROUP BY` 临时数据转储到文件系统的 RAM 使用阈值。如果设置为 0(默认值),则禁用。 -另外,您可以设置 [max_bytes_ratio_before_external_group_by](/operations/settings/settings#max_bytes_ratio_before_external_group_by),这允许在查询达到某个使用内存的阈值时才在外部内存中使用 `GROUP BY`。 +您可以启用将临时数据转储到磁盘的功能,以限制在 `GROUP BY` 期间的内存使用。 +设置 [max_bytes_before_external_group_by](/operations/settings/settings#max_bytes_before_external_group_by) 确定转储 `GROUP BY` 临时数据到文件系统的内存消耗阈值。如果设置为 0(默认值),则禁用。 +或者,您可以设置 [max_bytes_ratio_before_external_group_by](/operations/settings/settings#max_bytes_ratio_before_external_group_by),这允许在查询达到特定的内存使用阈值之前仅在外部内存中使用 `GROUP BY`。 -在使用 `max_bytes_before_external_group_by` 时,我们建议您将 `max_memory_usage` 设置为大约两倍(或 `max_bytes_ratio_before_external_group_by=0.5`)。这是因为聚合有两个阶段:读取数据并形成中间数据(1)和合并中间数据(2)。数据转储到文件系统只能在阶段 1 中发生。如果临时数据未被转储,则阶段 2 可能需要的内存与阶段 1 相同。 +使用 `max_bytes_before_external_group_by` 时,我们建议您将 `max_memory_usage` 设置为大约两倍(或 `max_bytes_ratio_before_external_group_by=0.5`)。这是因为聚合有两个阶段:读取数据并形成中间数据(1)和合并中间数据(2)。只能在阶段 1 期间将数据转储到文件系统中。如果临时数据没有转储,那么阶段 2 可能会需要与阶段 1 相同数量的内存。 -例如,如果 [max_memory_usage](/operations/settings/settings#max_memory_usage) 设置为 10000000000 并且您想使用外部聚合,那么将 `max_bytes_before_external_group_by` 设置为 10000000000,并将 `max_memory_usage` 设置为 20000000000 是合乎逻辑的。当触发外部聚合时(如果至少有一次临时数据转储),最大 RAM 消耗仅略高于 `max_bytes_before_external_group_by`。 +例如,如果设置了 [max_memory_usage](/operations/settings/settings#max_memory_usage) 为 10000000000 并且您希望使用外部聚合,那么将 `max_bytes_before_external_group_by` 设置为 10000000000 并将 `max_memory_usage` 设置为 20000000000 是有意义的。当触发外部聚合时(如果至少有一次临时数据转储),最大内存消耗仅比 `max_bytes_before_external_group_by` 稍高。 -在分布式查询处理时,外部聚合在远程服务器上执行。为了使请求服务器仅使用少量 RAM,请将 `distributed_aggregation_memory_efficient` 设置为 1。 +在分布式查询处理中,外部聚合在远程服务器上执行。为了使请求者服务器仅使用少量 RAM,设置 `distributed_aggregation_memory_efficient` 为 1。 -当合并已刷新到磁盘的数据时,以及在 `distributed_aggregation_memory_efficient` 设置启用时合并来自远程服务器的结果时,会消耗最多 `1/256 * 线程数` 的总 RAM。 +在合并刷新到磁盘的数据时,以及在启用 `distributed_aggregation_memory_efficient` 设置时合并来自远程服务器的结果时,消耗的 RAM 最高为 `1/256 * the_number_of_threads`。 -当启用外部聚合时,如果数据少于 `max_bytes_before_external_group_by`(即数据未被刷新),查询的运行速度与没有外部聚合时相同。如果有任何临时数据被刷新,则运行时间将长几倍(大约三倍)。 +启用外部聚合时,如果数据少于 `max_bytes_before_external_group_by`(即数据未刷新),查询运行与未进行外部聚合时一样快。如果任何临时数据被刷新,运行时间将延长几倍(大约三倍)。 -如果您的 [ORDER BY](/sql-reference/statements/select/order-by.md) 后有一个 [LIMIT](/sql-reference/statements/select/limit.md),则使用的 RAM 量取决于 `LIMIT` 中的数据量,而不是整个表中的数据量。但如果 `ORDER BY` 没有 `LIMIT`,请记得启用外部排序(`max_bytes_before_external_sort`)。 +如果您在 `GROUP BY` 之后有一个带有 [LIMIT](/sql-reference/statements/select/limit.md) 的 [ORDER BY](/sql-reference/statements/select/order-by.md),那么所使用的 RAM 的量取决于 `LIMIT` 中的数据量,而不是整个表的量。但如果 `ORDER BY` 没有 `LIMIT`,请不要忘记启用外部排序 (`max_bytes_before_external_sort`)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/group-by.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/group-by.md.hash index d318e9bcb9a..342efdc0999 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/group-by.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/group-by.md.hash @@ -1 +1 @@ -5da138567496d6ed +e5dba83119a3b8c8 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/having.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/having.md index ea509381f49..d96fc061f2a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/having.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/having.md @@ -3,14 +3,15 @@ 'sidebar_label': 'HAVING' 'slug': '/sql-reference/statements/select/having' 'title': 'HAVING 子句' +'doc_type': 'reference' --- # HAVING 子句 -允许过滤通过 [GROUP BY](/sql-reference/statements/select/group-by) 产生的聚合结果。它类似于 [WHERE](../../../sql-reference/statements/select/where.md) 子句,但不同之处在于 `WHERE` 在聚合之前执行,而 `HAVING` 在聚合之后执行。 +允许过滤由 [GROUP BY](/sql-reference/statements/select/group-by) 产生的聚合结果。它类似于 [WHERE](../../../sql-reference/statements/select/where.md) 子句,但区别在于 `WHERE` 在聚合之前执行,而 `HAVING` 在聚合之后执行。 -可以在 `HAVING` 子句中通过别名引用 `SELECT` 子句中的聚合结果。或者,`HAVING` 子句可以基于查询结果中未返回的其他聚合结果进行过滤。 +可以通过其别名在 `HAVING` 子句中引用 `SELECT` 子句的聚合结果。或者,`HAVING` 子句可以过滤未在查询结果中返回的额外聚合结果。 ## 限制 {#limitations} diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/having.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/having.md.hash index 4641a05d7ea..84c87a25096 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/having.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/having.md.hash @@ -1 +1 @@ -16f1b10bc035f9a4 +4847bc4b81735863 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/index.md index 060b13b81fc..cdb243a57f1 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/index.md @@ -4,12 +4,13 @@ 'sidebar_position': 32 'slug': '/sql-reference/statements/select/' 'title': 'SELECT 查询' +'doc_type': 'reference' --- # SELECT 查询 -`SELECT` 查询执行数据检索。默认情况下,请求的数据返回给客户端,而在与 [INSERT INTO](../../../sql-reference/statements/insert-into.md) 结合使用时,它可以转发到不同的表。 +`SELECT` 查询执行数据检索。默认情况下,请求的数据会返回给客户端,而与 [INSERT INTO](../../../sql-reference/statements/insert-into.md) 结合使用时,可以转发到不同的表。 ## 语法 {#syntax} @@ -35,9 +36,9 @@ SELECT [DISTINCT [ON (column1, column2, ...)]] expr_list [FORMAT format] ``` -除了在 `SELECT` 后面紧接着的所需表达式列表是必需的外,所有子句都是可选的,这部分将在 [下文](#select-clause) 中详细介绍。 +除了 `SELECT` 后面所需的表达式列表之外,所有子句都是可选的,详细信息如下 [下文](#select-clause)。 -每个可选子句的具体内容在单独的小节中阐述,这些小节按执行顺序列出: +每个可选子句的细节在单独的部分中介绍,这些部分按执行顺序列出: - [WITH 子句](../../../sql-reference/statements/select/with.md) - [SELECT 子句](#select-clause) @@ -62,25 +63,25 @@ SELECT [DISTINCT [ON (column1, column2, ...)]] expr_list ## SELECT 子句 {#select-clause} -在 `SELECT` 子句中指定的 [表达式](/sql-reference/syntax#expressions) 在上述子句中所有操作完成后计算。这些表达式的工作方式就像它们适用于结果中的独立行。如果 `SELECT` 子句中的表达式包含聚合函数,则 ClickHouse 在 [GROUP BY](/sql-reference/statements/select/group-by) 聚合期间处理这些聚合函数及其参数。 +在 `SELECT` 子句中指定的[表达式](/sql-reference/syntax#expressions) 在上述子句中的所有操作完成后计算。这些表达式的作用是应用于结果中的单独行。如果 `SELECT` 子句中的表达式包含聚合函数,则 ClickHouse 在执行 [GROUP BY](/sql-reference/statements/select/group-by) 聚合时处理聚合函数及其参数所用的表达式。 -如果您想在结果中包含所有列,请使用星号(`*`)符号。例如,`SELECT * FROM ...`。 +如果您想在结果中包含所有列,可以使用星号 (`*`) 符号。例如,`SELECT * FROM ...`。 ### 动态列选择 {#dynamic-column-selection} -动态列选择(也称为 COLUMNS 表达式)允许您用正则表达式匹配结果中的某些列,具体是 [re2](https://en.wikipedia.org/wiki/RE2_(software)) 正则表达式。 +动态列选择(也称为 COLUMNS 表达式)允许您将结果中的某些列与 [re2](https://en.wikipedia.org/wiki/RE2_(software)) 正则表达式进行匹配。 ```sql COLUMNS('regexp') ``` -例如,考虑下面的表: +例如,考虑这个表: ```sql CREATE TABLE default.col_names (aa Int8, ab Int8, bc Int8) ENGINE = TinyLog ``` -以下查询选择所有列名中包含 `a` 符号的数据。 +以下查询选择所有名称中包含 `a` 符号的列的数据。 ```sql SELECT COLUMNS('a') FROM col_names @@ -92,9 +93,9 @@ SELECT COLUMNS('a') FROM col_names └────┴────┘ ``` -所选列的返回顺序不是按字母顺序排列。 +选中的列不会按字母顺序返回。 -您可以在查询中使用多个 `COLUMNS` 表达式并对它们应用函数。 +您可以在一个查询中使用多个 `COLUMNS` 表达式并对它们应用函数。 例如: @@ -108,7 +109,7 @@ SELECT COLUMNS('a'), COLUMNS('c'), toTypeName(COLUMNS('c')) FROM col_names └────┴────┴────┴────────────────┘ ``` -每个通过 `COLUMNS` 表达式返回的列作为单独的参数传递给函数。如果该函数支持其他参数,您也可以将其他参数传递给它。使用函数时,请小心。如果一个函数不支持您传递的参数数量,ClickHouse 将抛出异常。 +通过 `COLUMNS` 表达式返回的每一列都作为单独的参数传递给函数。如果函数支持,您还可以传递其他参数。在使用函数时要小心。如果函数不支持您传递的参数数量,ClickHouse 将抛出异常。 例如: @@ -121,41 +122,41 @@ Received exception from server (version 19.14.1): Code: 42. DB::Exception: Received from localhost:9000. DB::Exception: Number of arguments for function plus does not match: passed 3, should be 2. ``` -在这个例子中,`COLUMNS('a')` 返回两个列:`aa` 和 `ab`。`COLUMNS('c')` 返回 `bc` 列。`+` 运算符无法应用于 3 个参数,因此 ClickHouse 抛出了一个相关的异常信息。 +在此示例中,`COLUMNS('a')` 返回两列:`aa` 和 `ab`。`COLUMNS('c')` 返回 `bc` 列。`+` 运算符无法应用于 3 个参数,因此 ClickHouse 抛出异常并给出相关消息。 -匹配 `COLUMNS` 表达式的列可以具有不同的数据类型。如果 `COLUMNS` 没有匹配任何列,并且是 `SELECT` 中唯一的表达式,ClickHouse 会抛出异常。 +匹配 `COLUMNS` 表达式的列可以具有不同的数据类型。如果 `COLUMNS` 没有匹配任何列,并且是 `SELECT` 中的唯一表达式,ClickHouse 将抛出异常。 ### 星号 {#asterisk} -您可以在查询中的任何位置放置一个星号来代替一个表达式。当查询被分析时,星号会扩展为所有表列的列表(不包括 `MATERIALIZED` 和 `ALIAS` 列)。在以下少数情况下使用星号是合理的: +您可以在查询的任何部分使用星号来代替表达式。当查询被分析时,星号会展开为所有表列的列表(不包括 `MATERIALIZED` 和 `ALIAS` 列)。只有在少数几种情况下,使用星号是合理的: -- 创建表的转储。 -- 对于仅包含少数列的表,例如系统表。 -- 获取有关表中有哪些列的信息。在这种情况下,设置 `LIMIT 1`。但最好使用 `DESC TABLE` 查询。 +- 创建表转储时。 +- 对于只包含少数列的表,例如系统表。 +- 获取表中哪些列的信息。在这种情况下,设置 `LIMIT 1`。但是,最好使用 `DESC TABLE` 查询。 - 当使用 `PREWHERE` 对少数列进行强过滤时。 -- 在子查询中(因为不需要用于外部查询的列会从子查询中排除)。 +- 在子查询中(因为不需要用于外部查询的列会被排除在子查询之外)。 -在所有其他情况下,我们不建议使用星号,因为它只会让您获得列式 DBMS 的缺点,而不是优点。换句话说,不推荐使用星号。 +在所有其他情况下,我们不建议使用星号,因为它只会带来列式数据库管理系统的缺点,而不是优点。换句话说,不推荐使用星号。 ### 极值 {#extreme-values} -除了结果外,您还可以获取结果列的最小和最大值。为此,将 **extremes** 设置为 1。最小值和最大值是为数值类型、日期和时间戳计算的。对于其他列,输出默认值。 +除了结果之外,您还可以获取结果列的最小值和最大值。要做到这一点,请将 **extremes** 设置为 1。最小值和最大值适用于数值类型、日期和带时间的日期。对于其他列,输出默认值。 -额外的两行被计算出来——分别是最小值和最大值。这两行在 `XML`、`JSON*`、`TabSeparated*`、`CSV*`、`Vertical`、`Template` 和 `Pretty*` [格式](../../../interfaces/formats.md) 中输出,与其他行分开输出。它们不会在其他格式中输出。 +额外计算两行 - 最小值和最大值。以 `XML`、`JSON*`、`TabSeparated*`、`CSV*`、`Vertical`、`Template` 和 `Pretty*` [格式](../../../interfaces/formats.md) 输出这两行,且与其他行分开。对于其他格式,则不会输出。 -在 `JSON*` 和 `XML` 格式中,极值输出在一个单独的 "extremes" 字段中。在 `TabSeparated*`、`CSV*` 和 `Vertical` 格式中,该行位于主结果之后,并在存在时位于 'totals' 之后。它前面有一行空行(在其他数据之后)。在 `Pretty*` 格式中,该行作为一个单独的表在主结果之后输出,并在存在时位于 `totals` 之后。在 `Template` 格式中,极值依据指定模板输出。 +在 `JSON*` 和 `XML` 格式中,极值在单独的 'extremes' 字段中输出。在 `TabSeparated*`、`CSV*` 和 `Vertical` 格式中,该行位于主结果之后,并在 'totals' 之后(如果存在)。该行前面有一空行(在其他数据之后)。在 `Pretty*` 格式中,该行作为主结果之后的单独表输出,并在 'totals' 之后(如果存在)。在 `Template` 格式中,极值根据指定模板输出。 -极值是在 `LIMIT` 之前计算的,但在 `LIMIT BY` 之后计算。然而,使用 `LIMIT offset, size` 时,`offset` 之前的行也包含在 `extremes` 中。在流请求中,结果可能还包括通过 `LIMIT` 的少量行。 +在 `LIMIT` 之前计算极值行,但在 `LIMIT BY` 之后。然而,当使用 `LIMIT offset, size` 时,`offset` 之前的行包括在 `extremes` 中。在流请求中,结果还可能包括通过 `LIMIT` 的少量行。 -### 说明 {#notes} +### 注意事项 {#notes} 您可以在查询的任何部分使用同义词(`AS` 别名)。 -`GROUP BY`、`ORDER BY` 和 `LIMIT BY` 子句可以支持位置参数。要启用此功能,请打开 [enable_positional_arguments](/operations/settings/settings#enable_positional_arguments) 设置。然后,例如,`ORDER BY 1,2` 将按照第一列和第二列对表中的行进行排序。 +`GROUP BY`、`ORDER BY` 和 `LIMIT BY` 子句可以支持位置参数。要启用此功能,请打开 [enable_positional_arguments](/operations/settings/settings#enable_positional_arguments) 设置。例如,`ORDER BY 1,2` 将按第一列和第二列对表中的行进行排序。 ## 实现细节 {#implementation-details} -如果查询省略了 `DISTINCT`、`GROUP BY` 和 `ORDER BY` 子句以及 `IN` 和 `JOIN` 子查询,则查询将完全以流方式处理,使用 O(1) 的内存量。否则,如果未指定适当的限制,查询可能会消耗大量内存: +如果查询省略了 `DISTINCT`、`GROUP BY` 和 `ORDER BY` 子句以及 `IN` 和 `JOIN` 子查询,则查询将完全通过流处理,使用 O(1) 的内存。否则,如果未指定适当的限制,查询可能消耗大量内存: - `max_memory_usage` - `max_rows_to_group_by` @@ -171,94 +172,28 @@ Code: 42. DB::Exception: Received from localhost:9000. DB::Exception: Number of - `max_bytes_before_external_group_by` - `max_bytes_ratio_before_external_group_by` -有关更多信息,请参见“设置”部分。可以使用外部排序(将临时表保存到磁盘)和外部聚合。 +有关更多信息,请参阅“设置”部分。可以使用外部排序(将临时表保存到磁盘)和外部聚合。 ## SELECT 修饰符 {#select-modifiers} 您可以在 `SELECT` 查询中使用以下修饰符。 -### APPLY {#apply} - -允许您对查询外部表表达式返回的每一行调用某个函数。 - -**语法:** - -```sql -SELECT APPLY( ) FROM [db.]table_name -``` - -**示例:** - -```sql -CREATE TABLE columns_transformers (i Int64, j Int16, k Int64) ENGINE = MergeTree ORDER by (i); -INSERT INTO columns_transformers VALUES (100, 10, 324), (120, 8, 23); -SELECT * APPLY(sum) FROM columns_transformers; -``` - -```response -┌─sum(i)─┬─sum(j)─┬─sum(k)─┐ -│ 220 │ 18 │ 347 │ -└────────┴────────┴────────┘ -``` - -### EXCEPT {#except} - -指定要从结果中排除的一个或多个列的名称。所有匹配的列名将从输出中省略。 - -**语法:** - -```sql -SELECT EXCEPT ( col_name1 [, col_name2, col_name3, ...] ) FROM [db.]table_name -``` - -**示例:** - -```sql -SELECT * EXCEPT (i) from columns_transformers; -``` - -```response -┌──j─┬───k─┐ -│ 10 │ 324 │ -│ 8 │ 23 │ -└────┴─────┘ -``` - -### REPLACE {#replace} - -指定一个或多个 [表达式别名](/sql-reference/syntax#expression-aliases)。每个别名必须匹配 `SELECT *` 语句中的列名。在输出的列列表中,匹配别名的列被该 `REPLACE` 中的表达式替代。 - -此修饰符不会更改列的名称或顺序。然而,它可以改变值和值类型。 - -**语法:** - -```sql -SELECT REPLACE( AS col_name) from [db.]table_name -``` - -**示例:** - -```sql -SELECT * REPLACE(i + 1 AS i) from columns_transformers; -``` - -```response -┌───i─┬──j─┬───k─┐ -│ 101 │ 10 │ 324 │ -│ 121 │ 8 │ 23 │ -└─────┴────┴─────┘ -``` +| 修饰符 | 描述 | +|-----------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| [`APPLY`](./apply_modifier.md) | 允许您对查询外部表表达式返回的每一行调用某个函数。 | +| [`EXCEPT`](./except_modifier.md) | 指定要从结果中排除的一个或多个列的名称。所有匹配的列名都将从输出中省略。 | +| [`REPLACE`](./replace_modifier.md)| 指定一个或多个[表达式别名](/sql-reference/syntax#expression-aliases)。每个别名必须与 `SELECT *` 语句中的列名匹配。在输出列列表中,与别名匹配的列被该 `REPLACE` 中的表达式替换。此修饰符不会更改列的名称或顺序。但是,它可以更改值和值类型。 | ### 修饰符组合 {#modifier-combinations} -您可以单独使用每个修饰符或将它们组合在一起。 +您可以分别使用每个修饰符或将它们组合在一起。 **示例:** -多次使用相同的修饰符。 +多次使用同一修饰符。 ```sql -SELECT COLUMNS('[jk]') APPLY(toString) APPLY(length) APPLY(max) from columns_transformers; +SELECT COLUMNS('[jk]') APPLY(toString) APPLY(length) APPLY(max) FROM columns_transformers; ``` ```response @@ -281,9 +216,11 @@ SELECT * REPLACE(i + 1 AS i) EXCEPT (j) APPLY(sum) from columns_transformers; ## SELECT 查询中的 SETTINGS {#settings-in-select-query} -您可以直接在 `SELECT` 查询中指定必要的设置。设置值仅适用于该查询,并在查询执行后重置为默认值或先前值。 +您可以在 `SELECT` 查询中直接指定必要的设置。设置值仅应用于此查询,并在查询执行后重置为默认值或之前的值。 + +有关设置的其他方式,请参见 [这里](/operations/settings/overview)。 -有关其他设置方式,请参见 [这里](/operations/settings/overview)。 +对于布尔设置,如果设置为 true,可以通过省略值分配的简写语法来使用。当仅指定设置名称时,它会自动设置为 `1`(true)。 **示例** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/index.md.hash index 6893bad1c8f..26d2b163c95 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/index.md.hash @@ -1 +1 @@ -87adaed3600b4ba2 +65e8f4f8ab42cc14 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/intersect.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/intersect.md index c3157dd3ec3..b5ec81aebb6 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/intersect.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/intersect.md @@ -3,14 +3,15 @@ 'sidebar_label': 'INTERSECT' 'slug': '/sql-reference/statements/select/intersect' 'title': 'INTERSECT 子句' +'doc_type': 'reference' --- # INTERSECT 子句 -`INTERSECT` 子句仅返回来自第一个和第二个查询的结果行。这两个查询必须匹配列数、顺序和类型。`INTERSECT` 的结果可以包含重复行。 +`INTERSECT` 子句仅返回来自第一个和第二个查询的结果行。查询必须匹配列的数量、顺序和类型。`INTERSECT` 的结果可以包含重复的行。 -多个 `INTERSECT` 语句在没有指定括号的情况下从左到右执行。`INTERSECT` 运算符的优先级高于 `UNION` 和 `EXCEPT` 子句。 +如果没有指定括号,则多个 `INTERSECT` 语句从左到右执行。`INTERSECT` 操作符的优先级高于 `UNION` 和 `EXCEPT` 子句。 ```sql SELECT column1 [, column2 ] @@ -24,11 +25,11 @@ FROM table2 [WHERE condition] ``` -该条件可以根据您的需求是任何表达式。 +条件可以是基于您要求的任何表达式。 ## 示例 {#examples} -这是一个简单的示例,将数字 1 到 10 与数字 3 到 8 进行交集: +这是一个简单的示例,将数字1到10与数字3到8进行交集: ```sql SELECT number FROM numbers(1,10) INTERSECT SELECT number FROM numbers(3,8); @@ -47,7 +48,7 @@ SELECT number FROM numbers(1,10) INTERSECT SELECT number FROM numbers(3,8); └────────┘ ``` -当您有两个共享公共列(或列)的表时,`INTERSECT` 非常有用。您可以对两个查询的结果进行交集,只要这些结果包含相同的列。例如,假设我们有几百万行的历史加密货币数据,其中包含交易价格和交易量: +`INTERSECT` 在您有两个共享公共列(或列)的表时非常有用。只要结果包含相同的列,您就可以交集两个查询的结果。例如,假设我们有几百万行的历史加密货币数据,其中包含交易价格和交易量: ```sql CREATE TABLE crypto_prices @@ -90,7 +91,7 @@ LIMIT 10; └────────────┴─────────────┴─────────────┴──────────┴──────────────┴───────────────┘ ``` -现在假设我们有一个名为 `holdings` 的表,包含我们拥有的加密货币的列表,以及对应的币种数量: +现在假设我们有一个名为 `holdings` 的表,包含我们拥有的加密货币的列表,以及币的数量: ```sql CREATE TABLE holdings @@ -110,7 +111,7 @@ INSERT INTO holdings VALUES ('Bitcoin Diamond', 5000); ``` -我们可以使用 `INTERSECT` 来回答类似 **“我们拥有的哪些币在交易价格超过 $100 的情况下?”** 的问题: +我们可以使用 `INTERSECT` 来回答诸如 **“我们拥有的哪些币的交易价格超过100美元?”** 的问题: ```sql SELECT crypto_name FROM holdings @@ -130,11 +131,11 @@ WHERE price > 100 └─────────────┘ ``` -这意味着在某个时间点,比特币和以太坊的交易价格超过了 $100,而 DOGEFI 和 Bitcoin Diamond 从未交易过 $100(至少根据我们在这个例子中拥有的数据)。 +这意味着在某些时间点,比特币和以太坊的交易价格超过了100美元,而DOGEFI和比特币钻石从未交易超过100美元(至少根据我们在这个示例中所提供的数据)。 ## INTERSECT DISTINCT {#intersect-distinct} -请注意,在之前的查询中,我们有多个比特币和以太坊的持有量,它们的交易价格超过了 $100。去除重复行(因为它们只重复了我们已经知道的信息)可能会很好。您可以在 `INTERSECT` 中添加 `DISTINCT` 以消除结果中的重复行: +注意在前一个查询中,我们有多个比特币和以太坊的持有量交易价格超过100美元。去除重复的行可能会很有帮助(因为它们只重复了我们已经知道的信息)。您可以向 `INTERSECT` 添加 `DISTINCT` 以消除结果中的重复行: ```sql SELECT crypto_name FROM holdings @@ -152,8 +153,7 @@ WHERE price > 100; └─────────────┘ ``` - -**另见** +**另请参阅** - [UNION](/sql-reference/statements/select/union) - [EXCEPT](/sql-reference/statements/select/except) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/intersect.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/intersect.md.hash index a23ff04c9a8..7479bcfbc93 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/intersect.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/intersect.md.hash @@ -1 +1 @@ -c6582b961851fa9d +76ee23223b719888 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/into-outfile.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/into-outfile.md index 764071496c9..9e18c3635bc 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/into-outfile.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/into-outfile.md @@ -3,14 +3,15 @@ 'sidebar_label': 'INTO OUTFILE' 'slug': '/sql-reference/statements/select/into-outfile' 'title': 'INTO OUTFILE 子句' +'doc_type': 'reference' --- # INTO OUTFILE 子句 -`INTO OUTFILE` 子句将 `SELECT` 查询的结果重定向到 **客户端** 侧的一个文件。 +`INTO OUTFILE` 子句将 `SELECT` 查询的结果重定向到 **客户端** 侧的文件中。 -支持压缩文件。压缩类型通过文件名的扩展名进行检测(默认使用模式 `'auto'`)。或者可以在 `COMPRESSION` 子句中明确指定。可以在 `LEVEL` 子句中指定某个压缩类型的压缩级别。 +支持压缩文件。压缩类型通过文件名的扩展名进行检测(默认使用模式 `'auto'`)。或者可以在 `COMPRESSION` 子句中明确指定。可以在 `LEVEL` 子句中为特定的压缩类型指定压缩级别。 **语法** @@ -18,17 +19,17 @@ SELECT INTO OUTFILE file_name [AND STDOUT] [APPEND | TRUNCATE] [COMPRESSION type [LEVEL level]] ``` -`file_name` 和 `type` 是字符串字面量。支持的压缩类型有:`'none'`、`'gzip'`、`'deflate'`、`'br'`、`'xz'`、`'zstd'`、`'lz4'`、`'bz2'`。 +`file_name` 和 `type` 是字符串常量。支持的压缩类型有: `'none'`,`'gzip'`,`'deflate'`,`'br'`,`'xz'`,`'zstd'`,`'lz4'`,`'bz2'`。 -`level` 是数字字面量。支持的正整数范围为:`1-12` 对于 `lz4` 类型,`1-22` 对于 `zstd` 类型,以及 `1-9` 对于其他压缩类型。 +`level` 是数字常量。支持范围内的正整数:`1-12` 对于 `lz4` 类型,`1-22` 对于 `zstd` 类型以及 `1-9` 对于其他压缩类型。 -## 实现细节 {#implementation-details} +## 实现详情 {#implementation-details} -- 此功能在 [命令行客户端](../../../interfaces/cli.md) 和 [clickhouse-local](../../../operations/utilities/clickhouse-local.md) 中可用。因此,通过 [HTTP 接口](../../../interfaces/http.md) 发送的查询将会失败。 -- 如果已存在同名文件,则查询将失败。 -- 默认的 [输出格式](../../../interfaces/formats.md) 是 `TabSeparated`(与命令行客户端批处理模式相同)。使用 [FORMAT](format.md) 子句来更改它。 -- 如果查询中提到 `AND STDOUT`,则写入文件的输出也会显示在标准输出上。如果与压缩一起使用,则明文将在标准输出上显示。 -- 如果查询中提到 `APPEND`,则输出将附加到现有文件。如果使用压缩,则无法使用附加。 +- 该功能可在 [命令行客户端](../../../interfaces/cli.md) 和 [clickhouse-local](../../../operations/utilities/clickhouse-local.md) 中使用。因此,通过 [HTTP 接口](../../../interfaces/http.md) 发送的查询将会失败。 +- 如果已存在同名文件,查询将失败。 +- 默认的 [输出格式](../../../interfaces/formats.md) 是 `TabSeparated`(如在命令行客户端批处理模式下)。使用 [FORMAT](format.md) 子句来更改它。 +- 如果查询中提到了 `AND STDOUT`,则写入文件的输出也会显示在标准输出上。如果与压缩一起使用,明文将显示在标准输出上。 +- 如果查询中提到了 `APPEND`,则输出会附加到已存在的文件。如果使用了压缩,则不能使用附加。 - 当写入已存在的文件时,必须使用 `APPEND` 或 `TRUNCATE`。 **示例** diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/into-outfile.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/into-outfile.md.hash index 8d0cbde6d74..84d4dc6609f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/into-outfile.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/into-outfile.md.hash @@ -1 +1 @@ -fe7ac638648836da +62b3024bc2a652f2 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/join.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/join.md index e09e792e971..9f73aaf44f8 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/join.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/join.md @@ -3,12 +3,31 @@ 'sidebar_label': 'JOIN' 'slug': '/sql-reference/statements/select/join' 'title': 'JOIN 子句' +'keywords': +- 'INNER JOIN' +- 'LEFT JOIN' +- 'LEFT OUTER JOIN' +- 'RIGHT JOIN' +- 'RIGHT OUTER JOIN' +- 'FULL OUTER JOIN' +- 'CROSS JOIN' +- 'LEFT SEMI JOIN' +- 'RIGHT SEMI JOIN' +- 'LEFT ANTI JOIN' +- 'RIGHT ANTI JOIN' +- 'LEFT ANY JOIN' +- 'RIGHT ANY JOIN' +- 'INNER ANY JOIN' +- 'ASOF JOIN' +- 'LEFT ASOF JOIN' +- 'PASTE JOIN' +'doc_type': 'reference' --- -# JOIN子句 +# JOIN 子句 -`JOIN`子句通过使用各表中共同的值结合一个或多个表的列来生成新表。这是一种在支持SQL的数据库中常见的操作,对应于[关系代数](https://en.wikipedia.org/wiki/Relational_algebra#Joins_and_join-like_operators)的连接。单表连接的特例通常称为“自连接”。 +`JOIN` 子句通过使用每个表中共同的值,组合一个或多个表的列,从而生成一个新表。这是 SQL 支持的数据库中的一种常见操作,对应于 [关系代数](https://en.wikipedia.org/wiki/Relational_algebra#Joins_and_join-like_operators) 中的连接。一个表连接的特例通常被称为“自连接”。 **语法** @@ -19,43 +38,43 @@ FROM (ON )|(USING ) ... ``` -`ON`子句中的表达式和`USING`子句中的列称为“连接键”。除非另有说明,`JOIN`会从具有匹配“连接键”的行中产生一个[笛卡尔积](https://en.wikipedia.org/wiki/Cartesian_product),这可能导致结果的行数远远超过源表的行数。 +`ON` 子句中的表达式和 `USING` 子句中的列称为“连接键”。除非另有说明,`JOIN` 会从具有匹配“连接键”的行生成 [笛卡尔积](https://en.wikipedia.org/wiki/Cartesian_product),这可能会产生比源表更多的行结果。 -## 支持的JOIN类型 {#supported-types-of-join} +## 支持的 JOIN 类型 {#supported-types-of-join} -支持所有标准的[SQL JOIN](https://en.wikipedia.org/wiki/Join_(SQL))类型: +支持所有标准的 [SQL JOIN](https://en.wikipedia.org/wiki/Join_(SQL)) 类型: -| 类型 | 描述 | -|------------------------|---------------------------------------------------------------------------| -| `INNER JOIN` | 仅返回匹配的行。 | -| `LEFT OUTER JOIN` | 返回左表中非匹配的行以及匹配的行。 | -| `RIGHT OUTER JOIN` | 返回右表中非匹配的行以及匹配的行。 | -| `FULL OUTER JOIN` | 返回两个表中非匹配的行以及匹配的行。 | -| `CROSS JOIN` | 产生两个表的笛卡尔积,**不**指定“连接键”。 | +| 类型 | 描述 | +|-------------------|-----------------------------------------------------------------------------| +| `INNER JOIN` | 仅返回匹配的行。 | +| `LEFT OUTER JOIN` | 除匹配的行外,还返回左表中的不匹配行。 | +| `RIGHT OUTER JOIN`| 除匹配的行外,还返回右表中的不匹配行。 | +| `FULL OUTER JOIN` | 除匹配的行外,还返回两个表中的不匹配行。 | +| `CROSS JOIN` | 生成整个表的笛卡尔积,未指定“连接键”。 | -- 未指定类型的`JOIN`默认为`INNER`。 -- 关键字`OUTER`可以安全省略。 -- `CROSS JOIN`的替代语法是使用逗号分隔的多个表在[`FROM`子句](../../../sql-reference/statements/select/from.md)中指定。 +- 未指定类型的 `JOIN` 默认使用 `INNER`。 +- 关键字 `OUTER` 可以安全省略。 +- `CROSS JOIN` 的另一种语法是将多个表通过逗号分隔在 [`FROM` 子句](../../../sql-reference/statements/select/from.md) 中指定。 -ClickHouse中可用的其他连接类型有: +ClickHouse 中还提供额外的连接类型: -| 类型 | 描述 | -|----------------------------------------------|------------------------------------------------------------------------------------------------------------------| -| `LEFT SEMI JOIN`,`RIGHT SEMI JOIN` | 仅允许“连接键”的白名单,而不产生笛卡尔积。 | -| `LEFT ANTI JOIN`,`RIGHT ANTI JOIN` | 针对“连接键”的黑名单,而不产生笛卡尔积。 | -| `LEFT ANY JOIN`,`RIGHT ANY JOIN`,`INNER ANY JOIN` | 部分(对于`LEFT`和`RIGHT`的对立面)或完全(对于`INNER`和`FULL`)禁用标准`JOIN`类型的笛卡尔积。 | -| `ASOF JOIN`,`LEFT ASOF JOIN` | 使用非精确匹配连接序列。`ASOF JOIN`的用法如下所述。 | -| `PASTE JOIN` | 对两个表执行水平连接。 | +| 类型 | 描述 | +|---------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------| +| `LEFT SEMI JOIN`, `RIGHT SEMI JOIN` | 允许列表“连接键”,不产生笛卡尔积。 | +| `LEFT ANTI JOIN`, `RIGHT ANTI JOIN` | 拒绝列表“连接键”,不产生笛卡尔积。 | +| `LEFT ANY JOIN`, `RIGHT ANY JOIN`, `INNER ANY JOIN` | 部分(对应于 `LEFT` 和 `RIGHT` 的反面)或完全(对于 `INNER` 和 `FULL`)禁用标准 `JOIN` 类型的笛卡尔积。 | +| `ASOF JOIN`, `LEFT ASOF JOIN` | 通过非完全匹配连接序列。`ASOF JOIN` 的用法在下文中描述。 | +| `PASTE JOIN` | 执行两个表的横向连接。 | :::note -当[join_algorithm](../../../operations/settings/settings.md#join_algorithm)设置为`partial_merge`时,仅支持`RIGHT JOIN`和`FULL JOIN`,并且仅在`ALL`严格性下(`SEMI`、`ANTI`、`ANY`和`ASOF`不受支持)。 +当 [join_algorithm](../../../operations/settings/settings.md#join_algorithm) 设置为 `partial_merge` 时,`RIGHT JOIN` 和 `FULL JOIN` 仅在 `ALL` 严格性下支持(`SEMI`、`ANTI`、`ANY` 和 `ASOF` 不支持)。 ::: ## 设置 {#settings} -可以使用[`join_default_strictness`](../../../operations/settings/settings.md#join_default_strictness)设置覆盖默认的连接类型。 +默认的连接类型可以使用 [`join_default_strictness`](../../../operations/settings/settings.md#join_default_strictness) 设置进行覆盖。 -ClickHouse服务器对于`ANY JOIN`操作的行为取决于[`any_join_distinct_right_table_keys`](../../../operations/settings/settings.md#any_join_distinct_right_table_keys)设置。 +ClickHouse 服务器对于 `ANY JOIN` 操作的行为取决于 [`any_join_distinct_right_table_keys`](../../../operations/settings/settings.md#any_join_distinct_right_table_keys) 设置。 **另见** @@ -66,27 +85,27 @@ ClickHouse服务器对于`ANY JOIN`操作的行为取决于[`any_join_distinct_r - [`join_on_disk_max_files_to_merge`](../../../operations/settings/settings.md#join_on_disk_max_files_to_merge) - [`any_join_distinct_right_table_keys`](../../../operations/settings/settings.md#any_join_distinct_right_table_keys) -使用`cross_to_inner_join_rewrite`设置定义当ClickHouse无法将`CROSS JOIN`重写为`INNER JOIN`时的行为。默认值为`1`,允许连接继续,但会更慢。如果希望抛出错误,请将`cross_to_inner_join_rewrite`设置为`0`,将其设置为`2`将不运行交叉连接,而是强制重写所有逗号/交叉连接。如果在值为`2`时重写失败,您将收到一条错误消息,说明“请尝试简化`WHERE`部分”。 +使用 `cross_to_inner_join_rewrite` 设置来定义 ClickHouse 在无法将 `CROSS JOIN` 重写为 `INNER JOIN` 时的行为。默认值为 `1`,这允许连接继续,但会更慢。如果希望抛出错误,请将 `cross_to_inner_join_rewrite` 设置为 `0`;如果希望不运行交叉连接,而强制重写所有逗号/交叉连接,则将其设置为 `2`。如果在值为 `2` 时重写失败,您将收到一条错误消息,说明“请尝试简化 `WHERE` 部分”。 -## ON部分条件 {#on-section-conditions} +## ON 子句条件 {#on-section-conditions} -`ON`部分可以包含多个通过`AND`和`OR`运算符组合的条件。指定连接键的条件必须: -- 引用左表和右表 -- 使用等式运算符 +`ON` 子句可以包含多个通过 `AND` 和 `OR` 操作符组合的条件。指定连接键的条件必须: +- 同时引用左表和右表 +- 使用等于操作符 -其他条件可以使用其他逻辑运算符,但必须引用查询的左表或右表。 +其他条件可以使用其他逻辑操作符,但必须引用查询的左表或右表。 -如果满足整个复杂条件,则行被连接。如果条件不满足,则根据`JOIN`类型,行仍可能包含在结果中。请注意,如果相同的条件放置在`WHERE`部分且没有满足,则行将始终从结果中过滤掉。 +如果满足整个复杂条件,则行被连接。如果条件未满足,则可能会根据 `JOIN` 类型在结果中仍包括行。请注意,如果相同的条件放置在 `WHERE` 子句中且未满足,则行总是从结果中被过滤掉。 -`ON`子句中的`OR`运算符使用哈希连接算法——对于每个带有`JOIN`的连接键的`OR`参数,会创建一个单独的哈希表,因此内存消耗和查询执行时间随着`ON`子句中表达式`OR`数量的增加而线性增长。 +`ON` 子句中的 `OR` 操作符使用哈希连接算法工作——对于每个带有连接键的 `JOIN` 的 `OR` 参数,将创建一个单独的哈希表,因此内存消耗和查询执行时间随着 `ON` 子句中 `OR` 表达式的增加而线性增长。 :::note -如果条件引用来自不同表的列,则目前仅支持等值运算符(`=`)。 +如果条件引用来自不同表的列,则目前仅支持等于操作符(`=`)。 ::: **示例** -考虑`table_1`和`table_2`: +考虑 `table_1` 和 `table_2`: ```response ┌─Id─┬─name─┐ ┌─Id─┬─text───────────┬─scores─┐ @@ -96,14 +115,14 @@ ClickHouse服务器对于`ANY JOIN`操作的行为取决于[`any_join_distinct_r └────┴──────┘ └────┴────────────────┴────────┘ ``` -包含一个连接键条件和一个对`table_2`的附加条件的查询: +具有一个连接键条件和一个额外条件的查询以 `table_2` 为准: ```sql SELECT name, text FROM table_1 LEFT OUTER JOIN table_2 ON table_1.Id = table_2.Id AND startsWith(table_2.text, 'Text'); ``` -请注意,结果中包含名字为`C`且文本列为空的行。由于使用了`OUTER`类型的连接,因此它被包含在结果中。 +请注意,结果包含名称为 `C` 的行和空文本列。它包含在结果中,因为使用的是 `OUTER` 类型的连接。 ```response ┌─name─┬─text───┐ @@ -113,7 +132,7 @@ SELECT name, text FROM table_1 LEFT OUTER JOIN table_2 └──────┴────────┘ ``` -使用`INNER`类型连接和多个条件的查询: +具有 `INNER` 类型连接和多个条件的查询: ```sql SELECT name, text, scores FROM table_1 INNER JOIN table_2 @@ -127,7 +146,7 @@ SELECT name, text, scores FROM table_1 INNER JOIN table_2 │ B │ Text B │ 15 │ └──────┴────────┴────────┘ ``` -使用`INNER`类型连接和带有`OR`条件的查询: +具有 `INNER` 类型连接和 `OR` 条件的查询: ```sql CREATE TABLE t1 (`a` Int64, `b` Int64) ENGINE = MergeTree() ORDER BY a; @@ -153,13 +172,13 @@ SELECT a, b, val FROM t1 INNER JOIN t2 ON t1.a = t2.key OR t1.b = t2.key; └───┴────┴─────┘ ``` -使用`INNER`类型连接和带有`OR`和`AND`条件的查询: +具有 `INNER` 类型连接和 `OR` 和 `AND` 条件的查询: :::note -默认情况下,非相等条件是支持的,只要它们使用同一表中的列。 -例如,`t1.a = t2.key AND t1.b > 0 AND t2.b > t2.c`,因为`t1.b > 0`仅使用`t1`中的列,而`t2.b > t2.c`仅使用`t2`中的列。 -但是,您可以尝试实验性支持条件,例如`t1.a = t2.key AND t1.b > t2.key`,请查看下面的部分以获取更多详细信息。 +默认情况下,只要使用同一表中的列,就支持不等条件。 +例如,`t1.a = t2.key AND t1.b > 0 AND t2.b > t2.c`,因为 `t1.b > 0` 仅使用列来自 `t1`,而 `t2.b > t2.c` 仅使用列来自 `t2`。 +但是,您可以尝试实验性支持条件,例如 `t1.a = t2.key AND t1.b > t2.key`,有关更多详细信息,请查看下面的部分。 ::: @@ -177,13 +196,13 @@ SELECT a, b, val FROM t1 INNER JOIN t2 ON t1.a = t2.key OR t1.b = t2.key AND t2. └───┴────┴─────┘ ``` -## 带有不同表的列的不等式条件的JOIN {#join-with-inequality-conditions-for-columns-from-different-tables} +## 对不同表的列使用不等条件的 JOIN {#join-with-inequality-conditions-for-columns-from-different-tables} -Clickhouse当前支持`ALL/ANY/SEMI/ANTI INNER/LEFT/RIGHT/FULL JOIN`,并使用不等式条件以补充等式条件。不等式条件仅支持`hash`和`grace_hash`连接算法。使用`join_use_nulls`时不支持不等式条件。 +ClickHouse 目前支持 `ALL/ANY/SEMI/ANTI INNER/LEFT/RIGHT/FULL JOIN` 的不等条件,除了支持等于条件。不等条件仅支持 `hash` 和 `grace_hash` 连接算法。`join_use_nulls` 不支持不等条件。 **示例** -表`t1`: +表 `t1`: ```response ┌─key──┬─attr─┬─a─┬─b─┬─c─┐ @@ -197,7 +216,7 @@ Clickhouse当前支持`ALL/ANY/SEMI/ANTI INNER/LEFT/RIGHT/FULL JOIN`,并使用 └──────┴──────┴───┴───┴───┘ ``` -表`t2` +表 `t2` ```response ┌─key──┬─attr─┬─a─┬─b─┬─c─┐ @@ -211,7 +230,7 @@ Clickhouse当前支持`ALL/ANY/SEMI/ANTI INNER/LEFT/RIGHT/FULL JOIN`,并使用 ``` ```sql -SELECT t1.*, t2.* from t1 LEFT JOIN t2 ON t1.key = t2.key and (t1.a < t2.a) ORDER BY (t1.key, t1.attr, t2.key, t2.attr); +SELECT t1.*, t2.* FROM t1 LEFT JOIN t2 ON t1.key = t2.key AND (t1.a < t2.a) ORDER BY (t1.key, t1.attr, t2.key, t2.attr); ``` ```response @@ -227,14 +246,13 @@ key2 a2 1 1 1 0 0 \N key4 f 2 3 4 0 0 \N ``` +## JOIN 键中的 NULL 值 {#null-values-in-join-keys} -## JOIN键中的NULL值 {#null-values-in-join-keys} - -`NULL`不等于任何值,包括它自己。这意味着如果一个`JOIN`键在一个表中有`NULL`值,它将与另一个表中的`NULL`值不匹配。 +`NULL` 不等于任何值,包括它自己。这意味着如果一个表中的 `JOIN` 键具有 `NULL` 值,则在另一个表中不会与 `NULL` 值匹配。 **示例** -表`A`: +表 `A`: ```response ┌───id─┬─name────┐ @@ -244,7 +262,7 @@ key4 f 2 3 4 0 0 \N └──────┴─────────┘ ``` -表`B`: +表 `B`: ```response ┌───id─┬─score─┐ @@ -266,9 +284,9 @@ SELECT A.name, B.score FROM A LEFT JOIN B ON A.id = B.id └─────────┴───────┘ ``` -请注意,表`A`中的`Charlie`行和表`B`中的得分为88的行未出现在结果中,因为`JOIN`键中有`NULL`值。 +请注意,来自表 `A` 的行 `Charlie` 和来自表 `B` 的行 `88` 不在结果中,因为 `JOIN` 键中的 `NULL` 值。 -如果您想匹配`NULL`值,可以使用`isNotDistinctFrom`函数比较`JOIN`键。 +如果您想匹配 `NULL` 值,请使用 `isNotDistinctFrom` 函数来比较 `JOIN` 键。 ```sql SELECT A.name, B.score FROM A LEFT JOIN B ON isNotDistinctFrom(A.id, B.id) @@ -282,17 +300,17 @@ SELECT A.name, B.score FROM A LEFT JOIN B ON isNotDistinctFrom(A.id, B.id) └─────────┴───────┘ ``` -## ASOF JOIN用法 {#asof-join-usage} +## ASOF JOIN 用法 {#asof-join-usage} -`ASOF JOIN`在您需要连接没有精确匹配的记录时非常有用。 +`ASOF JOIN` 在需要连接没有精确匹配的记录时非常有用。 -此JOIN算法在表中需要一个特殊列。该列: +此 JOIN 算法需要表中的一个特殊列。该列: - 必须包含一个有序序列。 - 可以是以下类型之一:[Int, UInt](../../../sql-reference/data-types/int-uint.md)、[Float](../../../sql-reference/data-types/float.md)、[Date](../../../sql-reference/data-types/date.md)、[DateTime](../../../sql-reference/data-types/datetime.md)、[Decimal](../../../sql-reference/data-types/decimal.md)。 -- 对于`hash`连接算法,它不能是`JOIN`子句中唯一的列。 +- 对于 `hash` 连接算法,它不能是 `JOIN` 子句中的唯一列。 -语法`ASOF JOIN ... ON`: +语法 `ASOF JOIN ... ON`: ```sql SELECT expressions_list @@ -303,9 +321,9 @@ ON equi_cond AND closest_match_cond 您可以使用任意数量的等式条件和恰好一个最近匹配条件。例如,`SELECT count() FROM table_1 ASOF LEFT JOIN table_2 ON table_1.a == table_2.b AND table_2.t <= table_1.t`。 -最近匹配支持的条件:`>`、`>=`、`<`、`<=`。 +为最近匹配支持的条件:`>`、`>=`、`<`、`<=`。 -语法`ASOF JOIN ... USING`: +语法 `ASOF JOIN ... USING`: ```sql SELECT expressions_list @@ -314,9 +332,9 @@ ASOF JOIN table_2 USING (equi_column1, ... equi_columnN, asof_column) ``` -`ASOF JOIN`使用`equi_columnX`进行等式连接,使用`asof_column`进行最近匹配连接,条件为`table_1.asof_column >= table_2.asof_column`。`asof_column`列始终是在`USING`子句中的最后一个列。 +`ASOF JOIN` 使用 `equi_columnX` 进行等于连接,并使用 `asof_column` 进行最近匹配连接,条件为 `table_1.asof_column >= table_2.asof_column`。`asof_column` 列始终是 `USING` 子句中的最后一列。 -例如,考虑下面的表: +例如,考虑以下表: ```text table_1 table_2 @@ -329,18 +347,18 @@ event_1_2 | 13:00 | 42 event_2_3 | 13:00 | 42 ... ... ``` -`ASOF JOIN`可以从`table_1`获取用户事件的时间戳,并找到`table_2`中时间戳最接近于来自`table_1`的事件时间戳的事件,满足最近匹配条件。如果可用,相等的时间戳值就是最近的。在我们的例子中,`event_1_1`可以与`event_2_1`连接,`event_1_2`可以与`event_2_3`连接,但`event_2_2`无法连接。 +`ASOF JOIN` 可以从 `table_1` 提取用户事件的时间戳,并在 `table_2` 中找到与从 `table_1` 中提取的事件最近的时间戳相符合的事件。如果有可用的相同时间戳值,则这些值是最近的。在我们的示例中,`user_id` 列可用于用于等于连接,`ev_time` 列可用于最近匹配连接。 在我们的示例中,`event_1_1` 可以与 `event_2_1` 连接,`event_1_2` 可以与 `event_2_3` 连接,但 `event_2_2` 不能连接。 :::note -`ASOF JOIN`仅支持`hash`和`full_sorting_merge`连接算法。 -不支持[Join](../../../engines/table-engines/special/join.md)表引擎。 +`ASOF JOIN` 仅受 `hash` 和 `full_sorting_merge` 连接算法的支持。 +它在 [JOIN](../../../engines/table-engines/special/join.md) 表引擎中**不**受支持。 ::: -## PASTE JOIN用法 {#paste-join-usage} +## PASTE JOIN 用法 {#paste-join-usage} -`PASTE JOIN`的结果是一个包含左侧子查询所有列的表,随后是右侧子查询的所有列。 -根据原始表中的位置匹配行(行的顺序应该被定义)。 -如果子查询返回不同数量的行,则多余的行会被截断。 +`PASTE JOIN` 的结果是一个表,其中包含所有来自左子查询的列,后跟所有来自右子查询的列。 +行是根据它们在原始表中的位置进行匹配(行的顺序必须已经定义)。 +如果子查询返回不同数量的行,将会截断多余的行。 示例: ```sql @@ -363,7 +381,7 @@ PASTE JOIN └───┴──────┘ ``` -注意:在这种情况下,如果读取是并行的,结果可能是不确定的。例如: +注意:在这种情况下,如果读取是并行的,结果可能是非确定性的。例如: ```sql SELECT * @@ -393,29 +411,29 @@ SETTINGS max_block_size = 2; └───┴──────┘ ``` -## 分布式JOIN {#distributed-join} +## 分布式 JOIN {#distributed-join} -涉及分布式表的JOIN有两种执行方式: +执行涉及分布式表的 JOIN 有两种方式: -- 当使用普通的`JOIN`时,查询被发送到远程服务器。在每个服务器上运行子查询以生成右表,连接在此表上执行。换句话说,右表在每个服务器上单独生成。 -- 当使用`GLOBAL ... JOIN`时,请求服务器首先运行一个子查询来计算右表。此临时表被传递到每个远程服务器,在它们上使用传输的临时数据运行查询。 +- 使用普通的 `JOIN` 时,查询发送到远程服务器。每个服务器上运行子查询以生成右表,然后与该表进行连接。换句话说,右表在每个服务器上分别生成。 +- 使用 `GLOBAL ... JOIN` 时,首先请求服务器运行一个子查询以计算右表。此临时表将传递到每个远程服务器,并在它们上使用传输的临时数据运行查询。 -使用`GLOBAL`时要小心。有关更多信息,请参见[分布式子查询](/sql-reference/operators/in#distributed-subqueries)部分。 +使用 `GLOBAL` 时请小心。有关更多信息,请参见 [分布式子查询](/sql-reference/operators/in#distributed-subqueries) 部分。 ## 隐式类型转换 {#implicit-type-conversion} -`INNER JOIN`、`LEFT JOIN`、`RIGHT JOIN`和`FULL JOIN`查询支持“连接键”的隐式类型转换。但是,如果左表和右表中的连接键无法转换为单一类型,则无法执行查询(例如,不能有数据类型可以同时容纳所有来自`UInt64`和`Int64`的值,或 `String`和`Int32`)。 +`INNER JOIN`、`LEFT JOIN`、`RIGHT JOIN` 和 `FULL JOIN` 查询支持对“连接键”的隐式类型转换。然而,如果左表和右表的连接键无法转换为单一类型(例如,没有数据类型能够同时容纳 `UInt64` 和 `Int64`,或 `String` 和 `Int32` 中的所有值),查询将无法执行。 **示例** -考虑表`t_1`: +考虑表 `t_1`: ```response ┌─a─┬─b─┬─toTypeName(a)─┬─toTypeName(b)─┐ │ 1 │ 1 │ UInt16 │ UInt8 │ │ 2 │ 2 │ UInt16 │ UInt8 │ └───┴───┴───────────────┴───────────────┘ ``` -以及表`t_2`: +以及表 `t_2`: ```response ┌──a─┬────b─┬─toTypeName(a)─┬─toTypeName(b)───┐ │ -1 │ 1 │ Int16 │ Nullable(Int64) │ @@ -440,50 +458,50 @@ SELECT a, b, toTypeName(a), toTypeName(b) FROM t_1 FULL JOIN t_2 USING (a, b); ## 使用建议 {#usage-recommendations} -### 处理空或NULL单元格 {#processing-of-empty-or-null-cells} +### 处理空或 NULL 单元格 {#processing-of-empty-or-null-cells} -在连接表时,可能会出现空单元格。[join_use_nulls](../../../operations/settings/settings.md#join_use_nulls)设置定义了ClickHouse如何填充这些单元格。 +在连接表时,可能会出现空单元格。设置 [join_use_nulls](../../../operations/settings/settings.md#join_use_nulls) 定义 ClickHouse 如何填充这些单元格。 -如果`JOIN`键是[Nullable](../../../sql-reference/data-types/nullable.md)字段,则至少有一个键的值为[NULL](/sql-reference/syntax#null)的行不会连接。 +如果 `JOIN` 键是 [Nullable](../../../sql-reference/data-types/nullable.md) 字段,其中至少一个键的值为 [NULL](/sql-reference/syntax#null) 的行不会被连接。 ### 语法 {#syntax} -在`USING`中指定的列在两个子查询中必须具有相同的名称,其他列必须命名不同。您可以使用别名更改子查询中的列名。 +在 `USING` 中指定的列在两个子查询中必须具有相同的名称,其他列必须命名不同。您可以使用别名更改子查询中列的名称。 -`USING`子句指定一个或多个要连接的列,从而建立这些列的相等性。列列表未用括号括起来。不支持更复杂的连接条件。 +`USING` 子句指定一个或多个列以进行连接,从而建立这些列的相等关系。列的列表不带括号设置。不支持更复杂的连接条件。 ### 语法限制 {#syntax-limitations} -对于单个`SELECT`查询中的多个`JOIN`子句: +对于单个 `SELECT` 查询中的多个 `JOIN` 子句: -- 只有在连接表时才能通过`*`获取所有列,而不是子查询。 -- `PREWHERE`子句不可用。 -- `USING`子句不可用。 +- 通过 `*` 获取所有列仅在表连接时可用,而不适用于子查询。 +- `PREWHERE` 子句不可用。 +- `USING` 子句不可用。 -对于`ON`、`WHERE`和`GROUP BY`子句: +对于 `ON`、`WHERE` 和 `GROUP BY` 子句: -- 在`ON`、`WHERE`和`GROUP BY`子句中不能使用任意表达式,但是您可以在`SELECT`子句中定义表达式,然后通过别名在这些子句中使用它。 +- `ON`、`WHERE` 和 `GROUP BY` 子句中不能使用任意表达式,但您可以在 `SELECT` 子句中定义一个表达式,然后通过别名在这些子句中使用。 ### 性能 {#performance} -在执行`JOIN`时,查询执行的顺序不会相对于查询的其他阶段进行优化。连接(在右表中搜索)在`WHERE`中的过滤之前执行,并且在聚合之前执行。 +运行 `JOIN` 时,查询的执行顺序不会优化为与其他阶段相关。连接(在右表中搜索)在 `WHERE` 中的过滤之前以及聚合之前运行。 -每次使用相同`JOIN`运行查询时,子查询会再次运行,因为结果不会被缓存。为避免这种情况,使用特殊的[Join](../../../engines/table-engines/special/join.md)表引擎,这是一个始终在RAM中的准备好的用于连接的数组。 +每次以相同的 `JOIN` 运行查询时,子查询会再次运行,因为结果不会被缓存。要避免这种情况,使用特殊的 [JOIN](../../../engines/table-engines/special/join.md) 表引擎,该引擎是用于连接的准备好的数组,始终在内存中。 -在某些情况下,使用[IN](../../../sql-reference/operators/in.md)可能比`JOIN`更有效。 +在某些情况下,使用 [IN](../../../sql-reference/operators/in.md) 代替 `JOIN` 更有效。 -如果您需要一个用于与维度表连接的`JOIN`(这些表相对较小,包含维度属性,如广告活动的名称),由于右表在每个查询中都被重新访问,`JOIN`可能不太方便。对于这种情况,您应该使用“字典”功能,而不是`JOIN`。有关更多信息,请参见[字典](../../../sql-reference/dictionaries/index.md)部分。 +如果您需要与维度表进行连接的 `JOIN`(这些表相对较小,包含维度属性,如广告活动的名称),由于右表在每个查询中都会被重新访问,`JOIN` 可能不方便。在这种情况下,您应该使用“字典”功能,而不是使用 `JOIN`。有关更多信息,请参见 [字典](../../../sql-reference/dictionaries/index.md) 部分。 ### 内存限制 {#memory-limitations} -默认情况下,ClickHouse使用[哈希连接](https://en.wikipedia.org/wiki/Hash_join)算法。ClickHouse取右表并在RAM中为其创建哈希表。如果启用`join_algorithm = 'auto'`,那么在某些内存消耗阈值后,ClickHouse将回退到[归并](https://en.wikipedia.org/wiki/Sort-merge_join)连接算法。有关`JOIN`算法的描述,请参见[join_algorithm](../../../operations/settings/settings.md#join_algorithm)设置。 +默认情况下,ClickHouse 使用 [哈希连接](https://en.wikipedia.org/wiki/Hash_join) 算法。ClickHouse 将右表创建一个哈希表放入内存中。如果 `join_algorithm = 'auto'` 被启用,则在超过某个内存消耗阈值后,ClickHouse 会退回到 [合并](https://en.wikipedia.org/wiki/Sort-merge_join) 连接算法。有关 `JOIN` 算法的描述,请参阅 [join_algorithm](../../../operations/settings/settings.md#join_algorithm) 设置。 -如果您需要限制`JOIN`操作的内存消耗,请使用以下设置: +如果您需要限制 `JOIN` 操作的内存消耗,请使用以下设置: - [max_rows_in_join](/operations/settings/settings#max_rows_in_join) — 限制哈希表中的行数。 - [max_bytes_in_join](/operations/settings/settings#max_bytes_in_join) — 限制哈希表的大小。 -达到这些限制中的任何一个时,ClickHouse将按照[join_overflow_mode](/operations/settings/settings.md#join_overflow_mode)设置指示的方式进行处理。 +当达到这些限制时,ClickHouse 的表现将按照 [join_overflow_mode](/operations/settings/settings.md#join_overflow_mode) 设置指示的方式进行。 ## 示例 {#examples} @@ -530,7 +548,7 @@ LIMIT 10 ## 相关内容 {#related-content} -- 博客:[ClickHouse: 一个快速的DBMS,完全支持SQL连接 - 第1部分](https://clickhouse.com/blog/clickhouse-fully-supports-joins) -- 博客:[ClickHouse: 一个快速的DBMS,完全支持SQL连接 - 细节分析 - 第2部分](https://clickhouse.com/blog/clickhouse-fully-supports-joins-hash-joins-part2) -- 博客:[ClickHouse: 一个快速的DBMS,完全支持SQL连接 - 细节分析 - 第3部分](https://clickhouse.com/blog/clickhouse-fully-supports-joins-full-sort-partial-merge-part3) -- 博客:[ClickHouse: 一个快速的DBMS,完全支持SQL连接 - 细节分析 - 第4部分](https://clickhouse.com/blog/clickhouse-fully-supports-joins-direct-join-part4) +- 博客:[ClickHouse:一款快速的完全支持 SQL 连接的 DBMS - 第 1 部分](https://clickhouse.com/blog/clickhouse-fully-supports-joins) +- 博客:[ClickHouse:一款快速的完全支持 SQL 连接的 DBMS - 引擎深度解析 - 第 2 部分](https://clickhouse.com/blog/clickhouse-fully-supports-joins-hash-joins-part2) +- 博客:[ClickHouse:一款快速的完全支持 SQL 连接的 DBMS - 引擎深度解析 - 第 3 部分](https://clickhouse.com/blog/clickhouse-fully-supports-joins-full-sort-partial-merge-part3) +- 博客:[ClickHouse:一款快速的完全支持 SQL 连接的 DBMS - 引擎深度解析 - 第 4 部分](https://clickhouse.com/blog/clickhouse-fully-supports-joins-direct-join-part4) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/join.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/join.md.hash index aaa19d13ab4..fe76a667221 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/join.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/join.md.hash @@ -1 +1 @@ -3f0a32328669cb2b +b1b64bcf0c63d705 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/limit-by.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/limit-by.md index f37b1aa5e2d..f2fe97d7de8 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/limit-by.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/limit-by.md @@ -3,26 +3,26 @@ 'sidebar_label': 'LIMIT BY' 'slug': '/sql-reference/statements/select/limit-by' 'title': 'LIMIT BY 子句' +'doc_type': 'reference' --- # LIMIT BY 子句 -带有 `LIMIT n BY expressions` 子句的查询为每个独特的 `expressions` 值选择前 `n` 行。`LIMIT BY` 的键可以包含任意数量的 [expressions](/sql-reference/syntax#expressions)。 +带有 `LIMIT n BY expressions` 子句的查询选择每个 `expressions` 不同值的前 `n` 行。`LIMIT BY` 的键可以包含任意数量的 [expressions](/sql-reference/syntax#expressions)。 ClickHouse 支持以下语法变体: - `LIMIT [offset_value, ]n BY expressions` - `LIMIT n OFFSET offset_value BY expressions` -在查询处理过程中,ClickHouse 按照排序键选择数据。排序键通过 [ORDER BY](/sql-reference/statements/select/order-by) 子句显式设置,或作为表引擎的属性隐式设置(只有在使用 [ORDER BY](/sql-reference/statements/select/order-by) 时才能保证行的顺序,否则由于多线程,行块将不会有序)。然后,ClickHouse 应用 `LIMIT n BY expressions`,并返回每个独特的 `expressions` 组合的前 `n` 行。如果指定了 `OFFSET`,那么对于属于独特 `expressions` 组合的每个数据块,ClickHouse 从块的开头跳过 `offset_value` 行,并返回最多 `n` 行作为结果。如果 `offset_value` 大于数据块中的行数,ClickHouse 将从块中返回零行。 +在查询处理过程中,ClickHouse 按照排序键选择数据。排序键可以通过 [ORDER BY](/sql-reference/statements/select/order-by) 子句显式设置,或者作为表引擎的属性隐式设置(只有在使用 [ORDER BY](/sql-reference/statements/select/order-by) 时,才保证行的顺序;否则,由于多线程,行块将不会被排序)。然后,ClickHouse 应用 `LIMIT n BY expressions`,并返回每个 `expressions` 不同组合的前 `n` 行。如果指定了 `OFFSET`,则对于属于不同 `expressions` 组合的每个数据块,ClickHouse 从块的开头跳过 `offset_value` 个行,并最多返回 `n` 行作为结果。如果 `offset_value` 大于数据块中的行数,ClickHouse 将返回零行。 :::note -`LIMIT BY` 与 [LIMIT](../../../sql-reference/statements/select/limit.md) 无关。它们可以在同一查询中同时使用。 +`LIMIT BY` 与 [LIMIT](../../../sql-reference/statements/select/limit.md) 无关。它们可以在同一个查询中一起使用。 ::: -如果您希望在 `LIMIT BY` 子句中使用列编号而不是列名,请启用设置 [enable_positional_arguments](/operations/settings/settings#enable_positional_arguments)。 - +如果您希望在 `LIMIT BY` 子句中使用列编号而不是列名称,请启用设置 [enable_positional_arguments](/operations/settings/settings#enable_positional_arguments)。 ## 示例 {#examples} @@ -60,9 +60,9 @@ SELECT * FROM limit_by ORDER BY id, val LIMIT 1, 2 BY id └────┴─────┘ ``` -`SELECT * FROM limit_by ORDER BY id, val LIMIT 2 OFFSET 1 BY id` 查询将返回相同的结果。 +`SELECT * FROM limit_by ORDER BY id, val LIMIT 2 OFFSET 1 BY id` 查询返回相同的结果。 -以下查询返回每对 `domain, device_type` 的前 5 个引荐来源,总计最多 100 行(`LIMIT n BY + LIMIT`)。 +以下查询返回每个 `domain, device_type` 对的前 5 个引用来源,最多返回 100 行(`LIMIT n BY + LIMIT`)。 ```sql SELECT diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/limit-by.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/limit-by.md.hash index 00a83cf85cf..4919fdb6f2f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/limit-by.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/limit-by.md.hash @@ -1 +1 @@ -912e32ad4027ea34 +e533280da69dca65 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/limit.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/limit.md index ec04eac7b55..86116dcdbe8 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/limit.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/limit.md @@ -3,18 +3,19 @@ 'sidebar_label': 'LIMIT' 'slug': '/sql-reference/statements/select/limit' 'title': 'LIMIT 子句' +'doc_type': 'reference' --- -# LIMIT子句 +# LIMIT 子句 `LIMIT m` 允许从结果中选择前 `m` 行。 -`LIMIT n, m` 允许在跳过前 `n` 行后,从结果中选择 `m` 行。`LIMIT m OFFSET n` 语法等价。 +`LIMIT n, m` 允许选择跳过前 `n` 行后的 `m` 行。`LIMIT m OFFSET n` 语法是等效的。 `n` 和 `m` 必须是非负整数。 -如果没有显式排序结果的 [ORDER BY](../../../sql-reference/statements/select/order-by.md) 子句,则结果中选择的行可能是任意的且非确定性的。 +如果没有显式排序结果的 [ORDER BY](../../../sql-reference/statements/select/order-by.md) 子句,则结果集中的行选择可能是任意的且非确定性的。 :::note 结果集中的行数也可能依赖于 [limit](../../../operations/settings/settings.md#limit) 设置。 @@ -22,9 +23,9 @@ ## LIMIT ... WITH TIES 修饰符 {#limit--with-ties-modifier} -当您为 `LIMIT n[,m]` 设置 `WITH TIES` 修饰符并指定 `ORDER BY expr_list` 时,您将获得结果的前 `n` 行或 `n,m` 行,以及所有与位置 `n` 的行在 `ORDER BY` 字段值上相等的行(对于 `LIMIT n`)和与位置 `m` 的行相等的行(对于 `LIMIT n,m`)。 +当为 `LIMIT n[,m]` 设置 `WITH TIES` 修饰符并指定 `ORDER BY expr_list` 时,结果中将返回前 `n` 或 `n,m` 行,以及所有字段值与第 `n` 行(对于 `LIMIT n`)和第 `m` 行(对于 `LIMIT n,m`)的 `ORDER BY` 字段值相等的行。 -此修饰符还可以与 [ORDER BY ... WITH FILL 修饰符](/sql-reference/statements/select/order-by#order-by-expr-with-fill-modifier) 组合使用。 +这个修饰符还可以与 [ORDER BY ... WITH FILL 修饰符](/sql-reference/statements/select/order-by#order-by-expr-with-fill-modifier) 组合使用。 例如,以下查询 @@ -46,7 +47,7 @@ SELECT * FROM ( └───┘ ``` -但是在应用 `WITH TIES` 修饰符后 +但在应用 `WITH TIES` 修饰符后 ```sql SELECT * FROM ( @@ -54,7 +55,7 @@ SELECT * FROM ( ) ORDER BY n LIMIT 0,5 WITH TIES ``` -它返回另一组行 +它返回另一个行集 ```text ┌─n─┐ @@ -67,4 +68,4 @@ SELECT * FROM ( └───┘ ``` -因为第 6 行在字段 `n` 上与第 5 行具有相同的值 "2" +因为第 6 行在 `n` 字段上与第 5 行具有相同的值 "2"。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/limit.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/limit.md.hash index 215496b70a1..81d4409b47e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/limit.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/limit.md.hash @@ -1 +1 @@ -e300c7af20f35431 +0faaad02f9374b54 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/offset.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/offset.md index 40ad80e2dfa..a031e1eb636 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/offset.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/offset.md @@ -1,23 +1,24 @@ --- -'description': 'Offset 的文档' +'description': 'OFFSET 的文档' 'sidebar_label': 'OFFSET' 'slug': '/sql-reference/statements/select/offset' 'title': 'OFFSET FETCH 子句' +'doc_type': 'reference' --- -`OFFSET` 和 `FETCH` 允许你按部分检索数据。它们指定了你想通过单个查询获取的行块。 +`OFFSET` 和 `FETCH` 允许您按部分检索数据。它们指定您想通过单个查询获取的行块。 ```sql OFFSET offset_row_count {ROW | ROWS}] [FETCH {FIRST | NEXT} fetch_row_count {ROW | ROWS} {ONLY | WITH TIES}] ``` -`offset_row_count` 或 `fetch_row_count` 的值可以是一个数字或一个字面常量。你可以省略 `fetch_row_count`;默认情况下,它等于 1。 +`offset_row_count` 或 `fetch_row_count` 的值可以是一个数字或一个文字常量。您可以省略 `fetch_row_count`;默认值为 1。 -`OFFSET` 指定在开始返回查询结果集中的行之前要跳过的行数。 +`OFFSET` 指定在开始返回查询结果集的行之前要跳过的行数。 `FETCH` 指定查询结果中可以包含的最大行数。 -`ONLY` 选项用于返回紧接着被 `OFFSET` 省略的行。在这种情况下,`FETCH` 是对 [LIMIT](../../../sql-reference/statements/select/limit.md) 子句的替代。例如,以下查询 +`ONLY` 选项用于返回紧随 `OFFSET` 中省略的行之后的行。在这种情况下,`FETCH` 是 [LIMIT](../../../sql-reference/statements/select/limit.md) 子句的替代选择。例如,以下查询 ```sql SELECT * FROM test_fetch ORDER BY a OFFSET 1 ROW FETCH FIRST 3 ROWS ONLY; @@ -31,14 +32,14 @@ SELECT * FROM test_fetch ORDER BY a LIMIT 3 OFFSET 1; 是相同的。 -`WITH TIES` 选项用于返回根据 `ORDER BY` 子句在结果集中最后一名的行的任何其他行。例如,如果 `fetch_row_count` 设置为 5,但两个额外的行的值与第五行的 `ORDER BY` 列匹配,则结果集将包含七行。 +`WITH TIES` 选项用于返回在结果集中与 `ORDER BY` 子句根据最后一行的值相同的额外行。例如,如果 `fetch_row_count` 设置为 5,但还有两个额外的行与第五行的 `ORDER BY` 列值匹配,结果集将包含七行。 :::note -根据标准,如果同时存在,`OFFSET` 子句必须位于 `FETCH` 子句之前。 +根据标准,`OFFSET` 子句必须在 `FETCH` 子句之前出现,如果两者都存在。 ::: :::note -实际偏移量也可以依赖于 [offset](../../../operations/settings/settings.md#offset) 设置。 +实际偏移量还可能依赖于 [offset](../../../operations/settings/settings.md#offset) 设置。 ::: ## 示例 {#examples} diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/offset.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/offset.md.hash index 7ded9caf53c..581b5fc27c5 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/offset.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/offset.md.hash @@ -1 +1 @@ -0805fe8bf9420485 +d774afb478495efb diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/order-by.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/order-by.md index e3b7514f6f9..4fa270423a9 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/order-by.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/order-by.md @@ -3,6 +3,7 @@ 'sidebar_label': 'ORDER BY' 'slug': '/sql-reference/statements/select/order-by' 'title': 'ORDER BY 子句' +'doc_type': 'reference' --- @@ -11,30 +12,30 @@ `ORDER BY` 子句包含 - 表达式列表,例如 `ORDER BY visits, search_phrase`, -- 引用 `SELECT` 子句中列的数字列表,例如 `ORDER BY 2, 1`,或 +- 指向 `SELECT` 子句中列的数字列表,例如 `ORDER BY 2, 1`,或 - `ALL`,表示 `SELECT` 子句的所有列,例如 `ORDER BY ALL`。 要禁用按列号排序,请将设置 [enable_positional_arguments](/operations/settings/settings#enable_positional_arguments) 设置为 0。 要禁用按 `ALL` 排序,请将设置 [enable_order_by_all](/operations/settings/settings#enable_order_by_all) 设置为 0。 -`ORDER BY` 子句可以通过 `DESC`(降序)或 `ASC`(升序)修饰符进行修饰,以确定排序方向。 -除非指定了显式的排序顺序,默认使用 `ASC`。 +`ORDER BY` 子句可以使用 `DESC`(降序)或 `ASC`(升序)修饰符来确定排序方向。 +除非指定明确的排序顺序,否则默认使用 `ASC`。 排序方向适用于单个表达式,而不是整个列表,例如 `ORDER BY Visits DESC, SearchPhrase`。 此外,排序是区分大小写的。 -具有相同排序表达式值的行以任意且非确定的顺序返回。 -如果在 `SELECT` 语句中省略了 `ORDER BY` 子句,则行顺序也是任意和非确定的。 +对于具有相同排序表达式值的行,返回的顺序是任意和非确定性的。 +如果在 `SELECT` 语句中省略 `ORDER BY` 子句,则行顺序也是任意和非确定的。 ## 特殊值的排序 {#sorting-of-special-values} -`NaN` 和 `NULL` 排序顺序有两种方法: +有两种处理 `NaN` 和 `NULL` 排序顺序的方法: -- 默认情况下或使用 `NULLS LAST` 修饰符:先是值,然后是 `NaN`,然后是 `NULL`。 -- 使用 `NULLS FIRST` 修饰符:先是 `NULL`,然后是 `NaN`,再然后是其他值。 +- 默认或使用 `NULLS LAST` 修饰符:首先是值,然后是 `NaN`,接着是 `NULL`。 +- 使用 `NULLS FIRST` 修饰符:首先是 `NULL`,然后是 `NaN`,最后是其他值。 ### 示例 {#example} -对于以下表 +对于表 ```text ┌─x─┬────y─┐ @@ -51,7 +52,7 @@ └───┴──────┘ ``` -执行查询 `SELECT * FROM t_null_nan ORDER BY y NULLS FIRST` 获取: +运行查询 `SELECT * FROM t_null_nan ORDER BY y NULLS FIRST` 可以得到: ```text ┌─x─┬────y─┐ @@ -68,15 +69,15 @@ └───┴──────┘ ``` -当浮点数排序时,NaNs 与其他值是分开的。无论排序顺序如何,NaNs 都放在最后。换句话说,对于升序排序,它们被放置为比所有其他数字都大,而对于降序排序,它们被放置为比其余数字都小。 +当对浮点数进行排序时,NaN 和其他值是分开的。无论排序顺序如何,NaN 始终出现在最后。换句话说,对于升序排序,NaN 被放置为比所有其他数字都大,而对于降序排序,则被放置为比其他数小。 -## 排序支持 {#collation-support} +## 排序规则支持 {#collation-support} -对于按 [String](../../../sql-reference/data-types/string.md) 值排序,可以指定排序规则(比较)。示例:`ORDER BY SearchPhrase COLLATE 'tr'` - 按照关键字的升序排序,使用土耳其字母表,不区分大小写,假定字符串为 UTF-8 编码。`COLLATE` 可以独立为 `ORDER BY` 中的每个表达式指定或不指定。如果指定了 `ASC` 或 `DESC`,则 `COLLATE` 位于其后。当使用 `COLLATE` 时,排序始终不区分大小写。 +对于按 [String](../../../sql-reference/data-types/string.md) 值排序,您可以指定排序规则(比较)。示例:`ORDER BY SearchPhrase COLLATE 'tr'` - 用于按关键字升序排序,使用土耳其字母表,不区分大小写,假设字符串是以 UTF-8 编码的。可以为 `ORDER BY` 中的每个表达式独立指定或不指定 `COLLATE`。如果指定了 `ASC` 或 `DESC`,则 `COLLATE` 在其后指定。使用 `COLLATE` 时,排序始终是不区分大小写的。 -排序规则在 [LowCardinality](../../../sql-reference/data-types/lowcardinality.md)、[Nullable](../../../sql-reference/data-types/nullable.md)、[Array](../../../sql-reference/data-types/array.md) 和 [Tuple](../../../sql-reference/data-types/tuple.md) 中受到支持。 +在 [LowCardinality](../../../sql-reference/data-types/lowcardinality.md)、[Nullable](../../../sql-reference/data-types/nullable.md)、[Array](../../../sql-reference/data-types/array.md) 和 [Tuple](../../../sql-reference/data-types/tuple.md) 中支持排序规则。 -我们仅建议在最终排序少量行时使用 `COLLATE`,因为使用 `COLLATE` 排序效率低于按字节正常排序。 +我们仅建议在最终排序少量行时使用 `COLLATE`,因为使用 `COLLATE` 排序的效率低于按字节正常排序。 ## 排序规则示例 {#collation-examples} @@ -112,7 +113,7 @@ SELECT * FROM collate_test ORDER BY s ASC COLLATE 'en'; └───┴──────┘ ``` -与 [Nullable](../../../sql-reference/data-types/nullable.md) 的示例: +与 [Nullable](../../../sql-reference/data-types/nullable.md) 一起的示例: 输入表: @@ -148,7 +149,7 @@ SELECT * FROM collate_test ORDER BY s ASC COLLATE 'en'; └───┴──────┘ ``` -与 [Array](../../../sql-reference/data-types/array.md) 的示例: +与 [Array](../../../sql-reference/data-types/array.md) 一起的示例: 输入表: @@ -256,55 +257,55 @@ SELECT * FROM collate_test ORDER BY s ASC COLLATE 'en'; ## 实现细节 {#implementation-details} -如果在 `ORDER BY` 之外指定了足够小的 [LIMIT](../../../sql-reference/statements/select/limit.md),则使用的内存会更少。否则,所需的内存量与要排序的数据量成正比。对于分布式查询处理,如果省略 [GROUP BY](/sql-reference/statements/select/group-by),则排序部分在远程服务器上进行,结果在请求服务器上合并。这意味着对于分布式排序,待排序的数据量可能大于单个服务器的内存量。 +如果指定了足够小的 [LIMIT](../../../sql-reference/statements/select/limit.md) 除了 `ORDER BY`,则使用的 RAM 较少。否则,所消耗的内存量与排序的数据量成比例。对于分布式查询处理,如果省略 [GROUP BY](/sql-reference/statements/select/group-by),则在远程服务器上部分执行排序,并在请求服务器上合并结果。这意味着对于分布式排序,要排序的数据量可以大于单个服务器的内存量。 -如果 RAM 不足,可以在外部内存中执行排序(在磁盘上创建临时文件)。使用设置 `max_bytes_before_external_sort` 以此目的。如果将其设置为 0(默认值),则禁用外部排序。如果启用,当待排序的数据量达到指定字节数时,收集的数据将被排序并转储到临时文件中。所有数据读取完成后,所有排序文件将合并并输出结果。文件写入默认配置中的 `/var/lib/clickhouse/tmp/` 目录,但可以使用 `tmp_path` 参数更改此设置。 +如果内存不足,可以在外部内存中执行排序(在磁盘上创建临时文件)。为此,请使用设置 `max_bytes_before_external_sort`。如果设置为 0(默认值),则禁用外部排序。如果启用,当要排序的数据量达到指定字节数时,所收集的数据将被排序并倾倒到临时文件中。在读取所有数据后,将合并所有已排序文件并输出结果。文件被写入配置中的 `/var/lib/clickhouse/tmp/` 目录(默认情况下,但您可以使用 `tmp_path` 参数更改此设置)。只有在查询超过内存限制时才能使用溢出到磁盘,例如 `max_bytes_ratio_before_external_sort=0.6` 将在查询达到 `60%` 内存限制时启用溢出到磁盘(用户/服务器)。 -运行查询可能使用比 `max_bytes_before_external_sort` 更多的内存。因此,此设置的值必须显著小于 `max_memory_usage`。例如,如果您的服务器有 128 GB 的 RAM,并且您需要运行一个查询,将 `max_memory_usage` 设置为 100 GB,`max_bytes_before_external_sort` 设置为 80 GB。 +运行查询可能会使用比 `max_bytes_before_external_sort` 更多的内存。因此,此设置的值必须显著小于 `max_memory_usage`。举例来说,如果您的服务器具有 128 GB 的 RAM,您需要运行单个查询,将 `max_memory_usage` 设置为 100 GB,将 `max_bytes_before_external_sort` 设置为 80 GB。 -外部排序的效果远不如在 RAM 中排序的效果。 +外部排序的效率远低于内存中的排序。 ## 数据读取优化 {#optimization-of-data-reading} -如果 `ORDER BY` 表达式有与表排序键一致的前缀,您可以通过使用 [optimize_read_in_order](../../../operations/settings/settings.md#optimize_read_in_order) 设置来优化查询。 + 如果 `ORDER BY` 表达式具有与表排序键一致的前缀,您可以通过使用设置 [optimize_read_in_order](../../../operations/settings/settings.md#optimize_read_in_order) 来优化查询。 -当启用 `optimize_read_in_order` 设置时,ClickHouse 服务器使用表索引并按 `ORDER BY` 键的顺序读取数据。这样可以避免在指定 [LIMIT](../../../sql-reference/statements/select/limit.md) 的情况下读取所有数据。因此,对于大数据且小限制的查询处理速度更快。 + 当启用 `optimize_read_in_order` 设置时,ClickHouse 服务器使用表索引,并按 `ORDER BY` 键的顺序读取数据。这允许避免在指定 [LIMIT](../../../sql-reference/statements/select/limit.md) 的情况下读取所有数据。因此,具有小限制的大数据查询处理更快。 -优化适用于 `ASC` 和 `DESC`,并且不与 [GROUP BY](/sql-reference/statements/select/group-by) 子句或 [FINAL](/sql-reference/statements/select/from#final-modifier) 修饰符一起使用。 +优化在 `ASC` 和 `DESC` 下均可用,并且与 [GROUP BY](/sql-reference/statements/select/group-by) 子句及 [FINAL](/sql-reference/statements/select/from#final-modifier) 修饰符不能同时工作。 当禁用 `optimize_read_in_order` 设置时,ClickHouse 服务器在处理 `SELECT` 查询时不使用表索引。 -在运行有 `ORDER BY` 子句、大 `LIMIT` 和需要在查询到所需数据之前读取大量记录的 [WHERE](../../../sql-reference/statements/select/where.md) 条件的查询时,建议手动禁用 `optimize_read_in_order`。 +在运行具有 `ORDER BY` 子句、较大 `LIMIT` 和 [WHERE](../../../sql-reference/statements/select/where.md) 条件的查询时,请考虑手动禁用 `optimize_read_in_order`,该条件要求读取大量记录才能找到查询数据。 -此优化在以下表引擎中受到支持: +优化支持以下表引擎: - [MergeTree](../../../engines/table-engines/mergetree-family/mergetree.md)(包括 [物化视图](/sql-reference/statements/create/view#materialized-view)), - [Merge](../../../engines/table-engines/special/merge.md), - [Buffer](../../../engines/table-engines/special/buffer.md) -在 `MaterializedView` 引擎表中,优化适用于 `SELECT ... FROM merge_tree_table ORDER BY pk` 类型的视图。但是在 `SELECT ... FROM view ORDER BY pk` 的查询中,如果视图查询没有 `ORDER BY` 子句,则不支持此优化。 +在 `MaterializedView` 引擎表中,优化在视图上正常工作,例如 `SELECT ... FROM merge_tree_table ORDER BY pk`。但在视图查询没有 `ORDER BY` 子句的情况下,查询 `SELECT ... FROM view ORDER BY pk` 则不受支持。 ## ORDER BY Expr WITH FILL 修饰符 {#order-by-expr-with-fill-modifier} -该修饰符也可以与 [LIMIT ... WITH TIES 修饰符](/sql-reference/statements/select/limit#limit--with-ties-modifier) 结合使用。 +该修饰符也可以与 [LIMIT ... WITH TIES 修饰符](/sql-reference/statements/select/limit#limit--with-ties-modifier) 组合使用。 -`WITH FILL` 修饰符可以在期望的 `ORDER BY expr` 之后加上可选的 `FROM expr`、`TO expr` 和 `STEP expr` 参数。 -所有缺失的 `expr` 列的值将按顺序填充,其他列将按默认值填充。 +`WITH FILL` 修饰符可以在 `ORDER BY expr` 后设置,并带有可选的 `FROM expr`、`TO expr` 和 `STEP expr` 参数。 +所有缺失的 `expr` 列值将按顺序填充,其他列将填充默认值。 -要填充多个列,请在 `ORDER BY` 部分每个字段名称后添加带有可选参数的 `WITH FILL` 修饰符。 +要填充多个列,请在 `ORDER BY` 部分每个字段名后添加可选参数的 `WITH FILL` 修饰符。 ```sql ORDER BY expr [WITH FILL] [FROM const_expr] [TO const_expr] [STEP const_numeric_expr] [STALENESS const_numeric_expr], ... exprN [WITH FILL] [FROM expr] [TO expr] [STEP numeric_expr] [STALENESS numeric_expr] [INTERPOLATE [(col [AS expr], ... colN [AS exprN])]] ``` -`WITH FILL` 可以应用于 Numeric(所有种类的浮点数、十进制、整型)或 Date/DateTime 类型的字段。应用于 `String` 字段时,缺失值将用空字符串填充。 -如果未定义 `FROM const_expr`,填充顺序使用 `ORDER BY` 中的最小 `expr` 字段值。 -如果未定义 `TO const_expr`,填充顺序使用 `ORDER BY` 中的最大 `expr` 字段值。 -如果定义了 `STEP const_numeric_expr`,则 `const_numeric_expr` 对于数值类型按原样解释,对于 Date 类型为 `days`,对于 DateTime 类型为 `seconds`。它还支持表示时间和日期区间的 [INTERVAL](/sql-reference/data-types/special-data-types/interval/) 数据类型。 -如果省略了 `STEP const_numeric_expr`,则填充顺序使用数值类型为 `1.0`,日期类型为 `1 day`,DateTime 类型为 `1 second`。 -如果定义了 `STALENESS const_numeric_expr`,则查询会生成行,直到原始数据中与前一行的差异超过 `const_numeric_expr`。 -`INTERPOLATE` 可以应用于未参与 `ORDER BY WITH FILL` 的列。这些列基于前面的字段值按 `expr` 填充。如果 `expr` 不存在,将重复前一个值。省略的列表将包含所有允许的列。 +`WITH FILL` 可以应用于数值类型(所有种类的浮点数、十进制和整数)或日期/时间类型字段。当应用于 `String` 字段时,缺失的值用空字符串填充。 +当未定义 `FROM const_expr` 时,填充序列使用来自 `ORDER BY` 的最小 `expr` 字段值。 +当未定义 `TO const_expr` 时,填充序列使用来自 `ORDER BY` 的最大 `expr` 字段值。 +当定义了 `STEP const_numeric_expr` 时,`const_numeric_expr` 对于数值类型按原样进行解释,对于日期类型作为 `days`,对于日期时间类型作为 `seconds`。它还支持代表时间和日期间隔的 [INTERVAL](/sql-reference/data-types/special-data-types/interval/) 数据类型。 +当省略 `STEP const_numeric_expr` 时,填充序列使用数值类型的 `1.0`、日期类型的 `1 day` 和日期时间类型的 `1 second`。 +当定义了 `STALENESS const_numeric_expr` 时,查询将生成行,直到原始数据中的前一行与当前行之间的差异超过 `const_numeric_expr`。 +`INTERPOLATE` 可以应用于不参与 `ORDER BY WITH FILL` 的列。这些列的填充将基于前面的字段值通过应用 `expr`。如果未给出 `expr`,将重复前一个值。省略列表将导致包括所有允许的列。 没有 `WITH FILL` 的查询示例: @@ -325,7 +326,7 @@ SELECT n, source FROM ( └───┴──────────┘ ``` -在应用 `WITH FILL` 修饰符后的相同查询: +同一查询在应用 `WITH FILL` 修饰符后的结果: ```sql SELECT n, source FROM ( @@ -354,7 +355,7 @@ SELECT n, source FROM ( └─────┴──────────┘ ``` -在多个字段的情况下 `ORDER BY field2 WITH FILL, field1 WITH FILL` 的填充顺序将遵循 `ORDER BY` 中字段的顺序。 +对于多个字段的情况 `ORDER BY field2 WITH FILL, field1 WITH FILL` 填充的顺序将遵循 `ORDER BY` 子句中的字段顺序。 示例: @@ -384,9 +385,9 @@ ORDER BY └────────────┴────────────┴──────────┘ ``` -字段 `d1` 未填充并使用默认值,因为我们没有重复的 `d2` 值,且 `d1` 的填充顺序无法正确计算。 +字段 `d1` 不填充并使用默认值,因为我们没有重复的 `d2` 值,并且无法正确计算 `d1` 的序列。 -使用 `ORDER BY` 中字段更改的以下查询: +以下查询在 `ORDER BY` 中更改字段: ```sql SELECT @@ -420,7 +421,7 @@ ORDER BY └────────────┴────────────┴──────────┘ ``` -以下查询使用 `INTERVAL` 数据类型,每填充一行在列 `d1` 中填充 1 天的数据: +以下查询对 `d1` 列中的每个填充值使用 1 天的 `INTERVAL` 数据类型: ```sql SELECT @@ -504,7 +505,7 @@ ORDER BY 没有 `STALENESS` 的查询示例: ```sql -SELECT number as key, 5 * number value, 'original' AS source +SELECT number AS key, 5 * number value, 'original' AS source FROM numbers(16) WHERE key % 5 == 0 ORDER BY key WITH FILL; ``` @@ -532,10 +533,10 @@ ORDER BY key WITH FILL; └─────┴───────┴──────────┘ ``` -应用 `STALENESS 3` 后的相同查询: +同一查询在应用 `STALENESS 3` 后的结果: ```sql -SELECT number as key, 5 * number value, 'original' AS source +SELECT number AS key, 5 * number value, 'original' AS source FROM numbers(16) WHERE key % 5 == 0 ORDER BY key WITH FILL STALENESS 3; ``` @@ -563,7 +564,7 @@ ORDER BY key WITH FILL STALENESS 3; ```sql SELECT n, source, inter FROM ( - SELECT toFloat32(number % 10) AS n, 'original' AS source, number as inter + SELECT toFloat32(number % 10) AS n, 'original' AS source, number AS inter FROM numbers(10) WHERE number % 3 = 1 ) ORDER BY n WITH FILL FROM 0 TO 5.51 STEP 0.5; ``` @@ -588,11 +589,11 @@ SELECT n, source, inter FROM ( └─────┴──────────┴───────┘ ``` -应用 `INTERPOLATE` 后的相同查询: +同一查询在应用 `INTERPOLATE` 后的结果: ```sql SELECT n, source, inter FROM ( - SELECT toFloat32(number % 10) AS n, 'original' AS source, number as inter + SELECT toFloat32(number % 10) AS n, 'original' AS source, number AS inter FROM numbers(10) WHERE number % 3 = 1 ) ORDER BY n WITH FILL FROM 0 TO 5.51 STEP 0.5 INTERPOLATE (inter AS inter + 1); ``` @@ -619,7 +620,7 @@ SELECT n, source, inter FROM ( ## 按排序前缀分组填充 {#filling-grouped-by-sorting-prefix} -填充在特定列中具有相同值的行独立填充可能是有用的,一个很好的例子是在时间序列中填充缺失值。 +对特定列具有相同值的行进行独立填充可能会很有用 - 一个很好的示例是在时间序列中填充缺失值。 假设有以下时间序列表: ```sql CREATE TABLE timeseries @@ -639,8 +640,8 @@ SELECT * FROM timeseries; │ 432 │ 2021-12-01 00:00:05.000 │ 5 │ └───────────┴─────────────────────────┴───────┘ ``` -我们希望独立为每个传感器填充缺失值,间隔为 1 秒。 -实现的方法是使用 `sensor_id` 列作为填充列 `timestamp` 的排序前缀: +我们希望为每个传感器独立填充缺失值,间隔为 1 秒。 +要实现这一点,可以使用 `sensor_id` 列作为填充列 `timestamp` 的排序前缀: ```sql SELECT * FROM timeseries @@ -662,8 +663,8 @@ INTERPOLATE ( value AS 9999 ) │ 432 │ 2021-12-01 00:00:05.000 │ 5 │ └───────────┴─────────────────────────┴───────┘ ``` -这里,`value` 列被插值为 `9999`,只是为了使填充的行更加明显。 -此行为由设置 `use_with_fill_by_sorting_prefix` 控制(默认启用)。 +在此,`value` 列用 `9999` 进行插值,仅为使填充行更加显著。 +此行为由设置 `use_with_fill_by_sorting_prefix` 控制(默认启用) ## 相关内容 {#related-content} diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/order-by.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/order-by.md.hash index 988dc7a8de2..c9290866c31 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/order-by.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/order-by.md.hash @@ -1 +1 @@ -19e8bf80bce18d0e +5d298034a4dc4eb8 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/prewhere.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/prewhere.md index 76d11a13e67..de98228b86e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/prewhere.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/prewhere.md @@ -1,34 +1,35 @@ --- -'description': 'PREWHERE 子句的文档' +'description': '关于 PREWHERE 子句的文档' 'sidebar_label': 'PREWHERE' 'slug': '/sql-reference/statements/select/prewhere' 'title': 'PREWHERE 子句' +'doc_type': 'reference' --- -# PREWHERE 子句 +# PREWHERE子句 -PREWHERE 是一种优化,用于更有效地应用过滤条件。即使未显式指定 `PREWHERE` 子句,它也是默认启用的。它通过自动将部分 [WHERE](../../../sql-reference/statements/select/where.md) 条件移到预处理阶段来工作。`PREWHERE` 子句的作用仅在于控制此优化,如果您认为自己可以比默认情况做得更好。 +Prewhere是一种优化,用于更有效地应用过滤。即使未显式指定`PREWHERE`子句,它默认为启用状态。它的工作原理是自动将部分[WHERE](../../../sql-reference/statements/select/where.md)条件移动到prewhere阶段。`PREWHERE`子句的作用仅是控制这种优化,如果你认为自己知道如何比默认情况更好地处理它。 -通过预处理优化,首先仅读取执行预处理表达式所需的列。然后读取进行其余查询所需的其他列,但仅读取预处理表达式在某些行中为 `true` 的那些块。如果存在许多预处理表达式在所有行中为 `false` 的块,并且预处理所需的列少于查询其他部分所需的列,这通常允许从磁盘读取更少的数据以执行查询。 +通过prewhere优化,最初仅读取执行prewhere表达式所需的列。然后读取其他列,以运行查询的其余部分,但仅限于那些在某些行中prewhere表达式为`true`的区块。如果存在许多区块,其中所有行的prewhere表达式均为`false`,并且prewhere所需的列少于查询的其他部分,这通常允许从磁盘中读取更少的数据以执行查询。 -## 手动控制 PREWHERE {#controlling-prewhere-manually} +## 手动控制Prewhere {#controlling-prewhere-manually} -该子句的含义与 `WHERE` 子句相同。区别在于从表中读取哪些数据。当手动控制 `PREWHERE` 以过滤查询中少数列使用的条件,但提供强大的数据过滤时。这样可以减少读取的数据量。 +该子句的含义与`WHERE`子句相同。区别在于从表中读取的数据。当手动控制`PREWHERE`时,针对查询中仅使用少数列的过滤条件,但提供强大的数据过滤。这减少了要读取的数据量。 -查询可以同时指定 `PREWHERE` 和 `WHERE`。在这种情况下,`PREWHERE` 的优先级高于 `WHERE`。 +一个查询可以同时指定`PREWHERE`和`WHERE`。在这种情况下,`PREWHERE`优先于`WHERE`。 -如果 [optimize_move_to_prewhere](../../../operations/settings/settings.md#optimize_move_to_prewhere) 设置为 0,则禁用从 `WHERE` 自动移动表达式部分到 `PREWHERE` 的启发式操作。 +如果[optimize_move_to_prewhere](../../../operations/settings/settings.md#optimize_move_to_prewhere)设置为0,则禁用自动将表达式部分从`WHERE`移动到`PREWHERE`的启发式。 -如果查询具有 [FINAL](/sql-reference/statements/select/from#final-modifier) 修饰符,则 `PREWHERE` 优化并不总是正确。如果要启用它,则必须同时开启设置 [optimize_move_to_prewhere](../../../operations/settings/settings.md#optimize_move_to_prewhere) 和 [optimize_move_to_prewhere_if_final](../../../operations/settings/settings.md#optimize_move_to_prewhere_if_final)。 +如果查询具有[FINAL](/sql-reference/statements/select/from#final-modifier)修饰符,则`PREWHERE`优化并不总是正确的。只有在同时启用设置[optimize_move_to_prewhere](../../../operations/settings/settings.md#optimize_move_to_prewhere)和[optimize_move_to_prewhere_if_final](../../../operations/settings/settings.md#optimize_move_to_prewhere_if_final)时才会启用。 :::note -`PREWHERE` 部分在 `FINAL` 之前执行,因此在使用不在表的 `ORDER BY` 部分的字段时,`FROM ... FINAL` 查询的结果可能会失真。 +`PREWHERE`部分在`FINAL`之前执行,因此在使用不在表的`ORDER BY`部分中的字段的`FROM ... FINAL`查询时,结果可能会偏斜。 ::: ## 限制 {#limitations} -`PREWHERE` 仅支持 [*MergeTree](../../../engines/table-engines/mergetree-family/index.md) 家族的表。 +`PREWHERE`仅支持来自[*MergeTree](../../../engines/table-engines/mergetree-family/index.md)家族的表。 ## 示例 {#example} diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/prewhere.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/prewhere.md.hash index ebba0188947..42669be821e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/prewhere.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/prewhere.md.hash @@ -1 +1 @@ -8baee1ac793f9fae +52d6546be8302cfb diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/qualify.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/qualify.md index b3588d33408..32fcf10ae47 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/qualify.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/qualify.md @@ -3,18 +3,19 @@ 'sidebar_label': 'QUALIFY' 'slug': '/sql-reference/statements/select/qualify' 'title': 'QUALIFY 子句' +'doc_type': 'reference' --- # QUALIFY 子句 -允许过滤窗口函数的结果。它类似于 [WHERE](../../../sql-reference/statements/select/where.md) 子句,但不同之处在于 `WHERE` 在窗口函数评估之前执行,而 `QUALIFY` 在其之后执行。 +允许过滤窗口函数的结果。它类似于 [WHERE](../../../sql-reference/statements/select/where.md) 子句,但不同之处在于 `WHERE` 在评估窗口函数之前执行,而 `QUALIFY` 在评估之后执行。 -可以通过别名在 `QUALIFY` 子句中引用 `SELECT` 子句中的窗口函数结果。或者,`QUALIFY` 子句可以过滤没有在查询结果中返回的额外窗口函数的结果。 +可以通过其别名在 `QUALIFY` 子句中引用 `SELECT` 子句的窗口函数结果。或者,`QUALIFY` 子句可以根据未在查询结果中返回的其他窗口函数的结果进行过滤。 ## 限制 {#limitations} -如果没有窗口函数可供评估,无法使用 `QUALIFY`。请改用 `WHERE`。 +如果没有窗口函数可供评估,则不能使用 `QUALIFY`。请改用 `WHERE`。 ## 示例 {#examples} diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/qualify.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/qualify.md.hash index 5aeb30e97aa..a88f2d09786 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/qualify.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/qualify.md.hash @@ -1 +1 @@ -7c659d012a5517d2 +4a16cc15120a00f9 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/replace_modifier.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/replace_modifier.md new file mode 100644 index 00000000000..06106a4163f --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/replace_modifier.md @@ -0,0 +1,38 @@ +--- +'description': '描述APPLY修饰符的文档,该修饰符允许您为查询的外部表表达式返回的每一行调用某个函数。' +'sidebar_label': 'REPLACE' +'slug': '/sql-reference/statements/select/replace-modifier' +'title': '替换修饰符' +'keywords': +- 'REPLACE' +- 'modifier' +'doc_type': 'reference' +--- + + +# Replace modifier {#replace} + +> 允许您指定一个或多个 [expression aliases](/sql-reference/syntax#expression-aliases)。 + +每个别名必须与 `SELECT *` 语句中的列名匹配。在输出列列表中,与别名匹配的列将被该 `REPLACE` 中的表达式替换。 + +该修饰符不会改变列的名称或顺序。然而,它可以改变值和值的类型。 + +**语法:** + +```sql +SELECT REPLACE( AS col_name) from [db.]table_name +``` + +**示例:** + +```sql +SELECT * REPLACE(i + 1 AS i) from columns_transformers; +``` + +```response +┌───i─┬──j─┬───k─┐ +│ 101 │ 10 │ 324 │ +│ 121 │ 8 │ 23 │ +└─────┴────┴─────┘ +``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/replace_modifier.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/replace_modifier.md.hash new file mode 100644 index 00000000000..64b119dd9b1 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/replace_modifier.md.hash @@ -0,0 +1 @@ +6c4695ec7303518f diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/sample.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/sample.md index 55058b0722a..ca2f27fb380 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/sample.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/sample.md @@ -3,44 +3,45 @@ 'sidebar_label': 'SAMPLE' 'slug': '/sql-reference/statements/select/sample' 'title': 'SAMPLE 子句' +'doc_type': 'reference' --- # SAMPLE 子句 -`SAMPLE` 子句允许进行近似的 `SELECT` 查询处理。 +`SAMPLE` 子句允许近似的 `SELECT` 查询处理。 -当启用数据采样时,查询并不是在所有数据上执行,而只是在一定比例的数据(样本)上执行。例如,如果您需要计算所有访问的统计信息,仅需在所有访问的十分之一上执行查询,然后将结果乘以 10。 +当启用数据采样时,查询并非在所有数据上执行,而仅在某个数据的特定比例(样本)上执行。例如,如果您需要计算所有访问的统计信息,仅需在 1/10 的所有访问上执行查询,然后将结果乘以 10。 -近似查询处理在以下情况下可能会很有用: +近似查询处理在以下情况下可能很有用: -- 当您有严格的延迟要求(如低于 100ms),但无法证明为满足这些要求而增加额外硬件资源的成本是合理的。 -- 当您的原始数据不准确时,因此近似不会明显降低质量。 -- 业务需求针对近似结果(为了成本效益,或将精确结果市场化给高级用户)。 +- 当您有严格的延迟要求(如低于 100ms),但无法证明支出额外硬件资源以满足这些要求的合理性。 +- 当您的原始数据不准确时,因此近似不会显著降低质量。 +- 商业需求目标是近似结果(为了成本效益,或将确切结果市场销售给高端用户)。 :::note -您只能在 [MergeTree](../../../engines/table-engines/mergetree-family/mergetree.md) 家族的表中使用采样,并且只有在创建表时指定了采样表达式的情况下(参见 [MergeTree 引擎](../../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-creating-a-table))。 +您只能在 [MergeTree](../../../engines/table-engines/mergetree-family/mergetree.md) 家族中的表上使用采样,并且仅在创建表时指定了采样表达式的情况下(请参见 [MergeTree 引擎](../../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-creating-a-table))。 ::: -数据采样的特性如下所示: +数据采样的特点如下: -- 数据采样是一个确定性机制。相同的 `SELECT .. SAMPLE` 查询的结果始终相同。 -- 在不同的表上采样的一致性。有单一采样键的表,对于相同系数的样本总是选择相同的可能数据子集。例如,用户 ID 的样本从不同表中获取相同子集的所有可能用户 ID 的行。这意味着您可以在 [IN](../../../sql-reference/operators/in.md) 子句中使用样本进行子查询。此外,您可以使用 [JOIN](../../../sql-reference/statements/select/join.md) 子句连接样本。 -- 采样允许从磁盘中读取更少的数据。请注意,您必须正确指定采样键。有关更多信息,请参阅 [创建 MergeTree 表](../../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-creating-a-table)。 +- 数据采样是一个确定性机制。同一 `SELECT .. SAMPLE` 查询的结果始终相同。 +- 对于不同的表,采样结果是一致的。对具有单一采样键的表,相同系数的样本始终选择相同的可能数据子集。例如,用户 ID 的样本会从不同的表中选择具有相同子集的所有可能用户 ID 的行。这意味着您可以在 [IN](../../../sql-reference/operators/in.md) 子句中的子查询中使用样本。此外,您可以使用 [JOIN](../../../sql-reference/statements/select/join.md) 子句连接样本。 +- 采样允许从磁盘读取更少的数据。请注意,您必须正确指定采样键。有关更多信息,请参见 [创建 MergeTree 表](../../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-creating-a-table)。 对于 `SAMPLE` 子句,支持以下语法: -| SAMPLE 子句语法 | 描述 | -|----------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `SAMPLE k` | 这里的 `k` 是从 0 到 1 的数字。查询在 `k` 比例的数据上执行。例如,`SAMPLE 0.1` 在 10% 的数据上运行查询。 [了解更多](#sample-k) | -| `SAMPLE n` | 这里的 `n` 是一个够大的整数。查询在至少 `n` 行的样本上执行(但不会显著超过这个数字)。例如,`SAMPLE 10000000` 在至少 10,000,000 行的数据上运行查询。 [了解更多](#sample-n) | -| `SAMPLE k OFFSET m` | 这里的 `k` 和 `m` 是从 0 到 1 的数字。查询在 `k` 比例的数据样本上执行。用于样本的数据由 `m` 比例偏移。 [了解更多](#sample-k-offset-m) | +| SAMPLE 子句语法 | 描述 | +|---------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `SAMPLE k` | 这里 `k` 是从 0 到 1 的数字。查询在 `k` 比例的数据上执行。例如,`SAMPLE 0.1` 在 10% 的数据上运行查询。[阅读更多](#sample-k) | +| `SAMPLE n` | 这里 `n` 是一个足够大的整数。查询在至少 `n` 行的样本上执行(但不会比这多得多)。例如,`SAMPLE 10000000` 在至少 10,000,000 行上运行查询。[阅读更多](#sample-n) | +| `SAMPLE k OFFSET m` | 这里 `k` 和 `m` 是从 0 到 1 的数字。查询在 `k` 比例的数据样本上执行。用于样本的数据偏移 `m` 比例。[阅读更多](#sample-k-offset-m) | ## SAMPLE K {#sample-k} -这里的 `k` 是从 0 到 1 的数字(支持小数和小数点表示法)。例如,`SAMPLE 1/2` 或 `SAMPLE 0.5`。 +这里 `k` 是从 0 到 1 的数字(支持分数和小数表示法)。例如,`SAMPLE 1/2` 或 `SAMPLE 0.5`。 -在 `SAMPLE k` 子句中,样本来自 `k` 比例的数据。下面是示例: +在 `SAMPLE k` 子句中,样本是从 `k` 比例的数据中获取的。下面是示例: ```sql SELECT @@ -54,21 +55,21 @@ GROUP BY Title ORDER BY PageViews DESC LIMIT 1000 ``` -在这个例子中,查询在 0.1 (10%)的数据样本上执行。聚合函数的值不会自动调整,因此为了获得近似结果,需将 `count()` 的值手动乘以 10。 +在此示例中,查询在 0.1(10%)的数据样本上执行。聚合函数的值不会自动修正,因此为了获得近似结果,`count()` 的值需要手动乘以 10。 ## SAMPLE N {#sample-n} -这里的 `n` 是一个足够大的整数。例如,`SAMPLE 10000000`。 +这里 `n` 是一个足够大的整数。例如,`SAMPLE 10000000`。 -在这种情况下,查询在至少 `n` 行的样本上执行(但不会显著超过这个数字)。例如,`SAMPLE 10000000` 在至少 10,000,000 行的数据上运行查询。 +在这种情况下,查询在至少 `n` 行的样本上执行(但不会比这多得多)。例如,`SAMPLE 10000000` 在至少 10,000,000 行上运行查询。 -由于读取数据的最小单元是一个颗粒(其大小由 `index_granularity` 设置确定),因此设置一个远大于颗粒大小的样本是有意义的。 +由于数据读取的最小单位是一个粒度(其大小由 `index_granularity` 设置决定),因此设置一个比粒度大小大得多的样本是有意义的。 -使用 `SAMPLE n` 子句时,您不知道处理了哪个相对数据的百分比。因此,您不知道聚合函数应该乘以的系数。使用 `_sample_factor` 虚拟列获取近似结果。 +使用 `SAMPLE n` 子句时,您无法知道处理了哪个相对百分比的数据。因此,您不知道聚合函数应该乘以的系数。使用虚拟列 `_sample_factor` 来获得近似结果。 -`_sample_factor` 列包含动态计算的相对系数。此列在您 [创建](../../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-creating-a-table) 表时自动生成,并指定了采样键。以下是使用 `_sample_factor` 列的示例。 +`_sample_factor` 列包含动态计算的相对系数。当您 [创建](../../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-creating-a-table) 表时自动创建此列,并指定采样键。以下是 `_sample_factor` 列的使用示例。 -让我们考虑表 `visits`,它包含有关网站访问的统计信息。第一个示例展示了如何计算页面浏览量: +让我们考虑表 `visits`,该表包含有关网站访问的统计信息。第一个示例展示如何计算页面视图的数量: ```sql SELECT sum(PageViews * _sample_factor) @@ -76,7 +77,7 @@ FROM visits SAMPLE 10000000 ``` -下一个示例展示了如何计算访问的总数: +下一个示例展示如何计算总访问次数: ```sql SELECT sum(_sample_factor) @@ -84,7 +85,7 @@ FROM visits SAMPLE 10000000 ``` -下面的示例展示了如何计算平均会话持续时间。请注意,您在计算平均值时无需使用相对系数。 +下面的示例展示如何计算平均会话持续时间。请注意,您不需要使用相对系数来计算平均值。 ```sql SELECT avg(Duration) @@ -94,7 +95,7 @@ SAMPLE 10000000 ## SAMPLE K OFFSET M {#sample-k-offset-m} -这里的 `k` 和 `m` 是从 0 到 1 的数字。下面是示例。 +这里 `k` 和 `m` 是从 0 到 1 的数字。示例如下。 **示例 1** @@ -102,7 +103,7 @@ SAMPLE 10000000 SAMPLE 1/10 ``` -在这个例子中,样本是所有数据的 1/10: +在此示例中,样本为所有数据的 1/10: `[++------------]` @@ -112,6 +113,6 @@ SAMPLE 1/10 SAMPLE 1/10 OFFSET 1/2 ``` -在这里,从数据的后半部分取样 10%。 +在这里,从数据的后半部分采样 10%。 `[------++------]` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/sample.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/sample.md.hash index d058ec919e8..ee1a4399284 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/sample.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/sample.md.hash @@ -1 +1 @@ -f68a9c6e4782ccdf +442ff8b6dfbbcff4 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/union.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/union.md index e44ca4e4475..c7b024dba69 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/union.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/union.md @@ -1,18 +1,19 @@ --- -'description': 'UNION 子句 的文档' +'description': 'UNION 子句的文档' 'sidebar_label': 'UNION' 'slug': '/sql-reference/statements/select/union' 'title': 'UNION 子句' +'doc_type': 'reference' --- # UNION 子句 -您可以使用 `UNION` 并明确指定 `UNION ALL` 或 `UNION DISTINCT`。 +您可以使用 `UNION` 显式指定 `UNION ALL` 或 `UNION DISTINCT`。 -如果您没有指定 `ALL` 或 `DISTINCT`,则会根据 `union_default_mode` 设置来决定。`UNION ALL` 和 `UNION DISTINCT` 之间的区别在于,`UNION DISTINCT` 会对联合结果进行去重转换,相当于从包含 `UNION ALL` 的子查询中执行 `SELECT DISTINCT`。 +如果您没有指定 `ALL` 或 `DISTINCT`,这将取决于 `union_default_mode` 设置。`UNION ALL` 和 `UNION DISTINCT` 之间的区别在于,`UNION DISTINCT` 会对联合结果进行去重转换,相当于从包含 `UNION ALL` 的子查询中执行 `SELECT DISTINCT`。 -您可以使用 `UNION` 通过扩展结果来组合任何数量的 `SELECT` 查询。例如: +您可以使用 `UNION` 通过扩展结果来组合任意数量的 `SELECT` 查询。例如: ```sql SELECT CounterID, 1 AS table, toInt64(count()) AS c @@ -27,13 +28,13 @@ SELECT CounterID, 2 AS table, sum(Sign) AS c HAVING c > 0 ``` -结果列通过它们的索引(在 `SELECT` 中的顺序)进行匹配。如果列名不匹配,最终结果的名称将来自第一个查询。 +结果列根据它们在 `SELECT` 中的索引(顺序)进行匹配。如果列名不匹配,最终结果的名称将来自第一个查询。 -对于联合会执行类型转换。例如,如果两个要合并的查询具有相同的字段,且类型分别为非 `Nullable` 和 `Nullable` 的兼容类型,则所得的 `UNION` 将具有 `Nullable` 类型字段。 +在联合时会执行类型转换。例如,如果两个合并的查询具有相同字段,其中一个是非 `Nullable` 类型,另一个是 `Nullable` 类型,并且两者来自兼容类型,则结果 `UNION` 中将具有 `Nullable` 类型字段。 -`UNION` 中的查询可以用圆括号括起来。[ORDER BY](../../../sql-reference/statements/select/order-by.md) 和 [LIMIT](../../../sql-reference/statements/select/limit.md) 适用于单独的查询,而不是最终结果。如果需要对最终结果应用转换,可以将所有带有 `UNION` 的查询放入 [FROM](../../../sql-reference/statements/select/from.md) 子句中的子查询中。 +`UNION` 中的查询可以用圆括号括起来。[ORDER BY](../../../sql-reference/statements/select/order-by.md) 和 [LIMIT](../../../sql-reference/statements/select/limit.md) 应用于单独的查询,而不是最终结果。如果您需要对最终结果应用转换,可以将所有使用 `UNION` 的查询放在 [FROM](../../../sql-reference/statements/select/from.md) 子句中的子查询中。 -如果您使用 `UNION` 而没有明确指定 `UNION ALL` 或 `UNION DISTINCT`,可以使用 [union_default_mode](/operations/settings/settings#union_default_mode) 设置指定联合模式。该设置的值可以是 `ALL`、`DISTINCT` 或空字符串。但是,如果您使用 `union_default_mode` 设置为空字符串,则会抛出异常。以下示例演示了具有不同值设置的查询结果。 +如果您在未显式指定 `UNION ALL` 或 `UNION DISTINCT` 的情况下使用 `UNION`,可以使用 [union_default_mode](/operations/settings/settings#union_default_mode) 设置指定并集模式。设置值可以是 `ALL`、`DISTINCT` 或空字符串。但是,如果您使用 `union_default_mode` 设置为空字符串的 `UNION`,将会抛出异常。以下示例演示了具有不同值设置的查询结果。 查询: @@ -80,9 +81,9 @@ SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 2; └───┘ ``` -`UNION/UNION ALL/UNION DISTINCT` 的部分查询可以同时运行,并且它们的结果可以混合在一起。 +作为 `UNION/UNION ALL/UNION DISTINCT` 组成部分的查询可以同时运行,其结果可以混合在一起。 -**另请参阅** +**另见** - [insert_null_as_default](../../../operations/settings/settings.md#insert_null_as_default) 设置。 - [union_default_mode](/operations/settings/settings#union_default_mode) 设置。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/union.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/union.md.hash index b87d0f2b7e0..c893bf3ce40 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/union.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/union.md.hash @@ -1 +1 @@ -9d154f1c6af3840d +e9b7d717f1b610a8 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/where.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/where.md index 9833d93337c..3d221f46535 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/where.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/where.md @@ -1,29 +1,30 @@ --- -'description': 'WHERE 子句的文档' +'description': '关于 WHERE Clause 的文档' 'sidebar_label': 'WHERE' 'slug': '/sql-reference/statements/select/where' 'title': 'WHERE 子句' +'doc_type': 'reference' --- # WHERE 子句 -`WHERE` 子句允许过滤从 `SELECT` 的 [FROM](../../../sql-reference/statements/select/from.md) 子句中得到的数据。 +`WHERE` 子句允许过滤来自 `SELECT` 的 [FROM](../../../sql-reference/statements/select/from.md) 子句的数据。 -如果存在 `WHERE` 子句,则必须包含一个 `UInt8` 类型的表达式。这个表达式通常是带有比较和逻辑运算符的表达式。该表达式计算结果为 `0` 的行将被排除在进一步的转换或结果之外。 +如果存在 `WHERE` 子句,它必须包含一个 `UInt8` 类型的表达式。这个表达式通常使用比较和逻辑运算符。该表达式评估为 `0` 的行将被排除在进一步的转换或结果之外。 -`WHERE` 表达式的评价依赖于是否能够使用索引和分区裁剪,如果底层表引擎支持这些功能。 +`WHERE` 表达式的评估依赖于是否能够使用索引和分区裁剪,前提是底层表引擎支持这些功能。 :::note -有一种过滤优化称为 [PREWHERE](../../../sql-reference/statements/select/prewhere.md)。 +有一个名为 [PREWHERE](../../../sql-reference/statements/select/prewhere.md) 的过滤优化。 ::: -如果您需要测试某个值是否为 [NULL](/sql-reference/syntax#null),请使用 [IS NULL](/sql-reference/operators#is_null) 和 [IS NOT NULL](/sql-reference/operators#is_not_null) 运算符或 [isNull](../../../sql-reference/functions/functions-for-nulls.md#isnull) 和 [isNotNull](../../../sql-reference/functions/functions-for-nulls.md#isnotnull) 函数。 -否则,包含 `NULL` 的表达式将永远无法通过。 +如果你需要测试一个值是否为 [NULL](/sql-reference/syntax#null),可以使用 [IS NULL](/sql-reference/operators#is_null) 和 [IS NOT NULL](/sql-reference/operators#is_not_null) 运算符,或 [isNull](../../../sql-reference/functions/functions-for-nulls.md#isNull) 和 [isNotNull](../../../sql-reference/functions/functions-for-nulls.md#isNotNull) 函数。 +否则,即使表达式包含 `NULL`,也永远不会通过。 **示例** -要查找是 3 的倍数且大于 10 的数字,可以在 [numbers table](../../../sql-reference/table-functions/numbers.md) 上执行以下查询: +要查找是 3 的倍数且大于 10 的数字,请在 [numbers table](../../../sql-reference/table-functions/numbers.md) 上执行以下查询: ```sql SELECT number FROM numbers(20) WHERE (number > 10) AND (number % 3 == 0); @@ -39,7 +40,7 @@ SELECT number FROM numbers(20) WHERE (number > 10) AND (number % 3 == 0); └────────┘ ``` -带有 `NULL` 值的查询: +包含 `NULL` 值的查询: ```sql CREATE TABLE t_null(x Int8, y Nullable(Int8)) ENGINE=MergeTree() ORDER BY x; diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/where.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/where.md.hash index 5d8acfeecf4..86f3f3c3e52 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/where.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/where.md.hash @@ -1 +1 @@ -f623bfe17d615c0f +f6af9e56139e3606 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/with.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/with.md index dfd242a8d86..f8f5f39c0f8 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/with.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/with.md @@ -3,49 +3,74 @@ 'sidebar_label': 'WITH' 'slug': '/sql-reference/statements/select/with' 'title': 'WITH 子句' +'doc_type': 'reference' --- # WITH 子句 -ClickHouse 支持公共表表达式([CTE](https://en.wikipedia.org/wiki/Hierarchical_and_recursive_queries_in_SQL)),并在 `WITH` 子句的所有使用位置替换定义的代码。命名的子查询可以在允许表对象的地方包含到当前和子查询上下文中。通过在 WITH 表达式中隐藏当前级别的 CTE,避免了递归的发生。 +ClickHouse 支持公共表表达式 ([CTE](https://en.wikipedia.org/wiki/Hierarchical_and_recursive_queries_in_SQL))、公共标量表达式和递归查询。 -请注意,CTE 在调用的所有地方不保证相同的结果,因为查询将为每个使用情况重新执行。 +## 公共表表达式 {#common-table-expressions} -下面是这样的行为示例 +公共表表达式表示命名的子查询。 +可以在任何允许表表达式的 `SELECT` 查询中通过名称引用它们。 +命名的子查询可以在当前查询的作用域或子查询的作用域中通过名称引用。 + +在 `SELECT` 查询中对公共表表达式的每个引用总是由其定义中的子查询替换。 +通过在标识符解析过程中隐藏当前 CTE 来防止递归。 + +请注意,CTE 在调用的所有地方不保证返回相同的结果,因为查询会根据每个用例重新执行。 + +### 语法 {#common-table-expressions-syntax} + +```sql +WITH AS +``` + +### 示例 {#common-table-expressions-example} + +一个子查询被重新执行的示例: ```sql -with cte_numbers as +WITH cte_numbers AS ( - select + SELECT num - from generateRandom('num UInt64', NULL) - limit 1000000 + FROM generateRandom('num UInt64', NULL) + LIMIT 1000000 ) -select +SELECT count() -from cte_numbers -where num in (select num from cte_numbers) +FROM cte_numbers +WHERE num IN (SELECT num FROM cte_numbers) ``` -如果 CTE 传递的确切是结果,而不仅仅是一段代码,你将始终看到 `1000000` +如果 CTE 传递的结果是确切的,而不只是代码片段,您将始终看到 `1000000` + +然而,由于我们两次引用了 `cte_numbers`,每次都会生成随机数字,因此我们看到不同的随机结果,`280501, 392454, 261636, 196227` 等等... + +## 公共标量表达式 {#common-scalar-expressions} -然而,由于我们引用了 `cte_numbers` 两次,因此每次都会生成随机数,因此我们看到不同的随机结果,`280501, 392454, 261636, 196227` 等等... +ClickHouse 允许您在 `WITH` 子句中声明任意标量表达式的别名。 +公共标量表达式可以在查询的任何地方引用。 -## 语法 {#syntax} +:::note +如果公共标量表达式引用的是常量文字之外的内容,则该表达式可能会导致存在 [自由变量](https://en.wikipedia.org/wiki/Free_variables_and_bound_variables)。 +ClickHouse 在可能的最近作用域中解析任何标识符,这意味着自由变量可能会引用意外的实体(在名称冲突的情况下)或可能导致相关子查询。 +建议将 CSE 定义为 [lambda 函数](/sql-reference/functions/overview#arrow-operator-and-lambda)(仅在启用 [分析器](/operations/analyzer) 时可能),绑定所有使用的标识符,以实现更可预测的表达式标识符解析行为。 +::: + +### 语法 {#common-scalar-expressions-syntax} ```sql WITH AS ``` -或 -```sql -WITH AS -``` -## 示例 {#examples} +### 示例 {#common-scalar-expressions-examples} -**示例 1:** 将常量表达式用作“变量” +**示例 1:** 使用常量表达式作为 "变量" ```sql -WITH '2019-08-01 15:23:00' as ts_upper_bound +WITH '2019-08-01 15:23:00' AS ts_upper_bound SELECT * FROM hits WHERE @@ -53,10 +78,55 @@ WHERE EventTime <= ts_upper_bound; ``` -**示例 2:** 从 SELECT 子句列列表中剔除 sum(bytes) 表达式结果 +**示例 2:** 使用高阶函数绑定标识符 + +```sql +WITH + '.txt' as extension, + (id, extension) -> concat(lower(id), extension) AS gen_name +SELECT gen_name('test', '.sql') as file_name; +``` + +```response + ┌─file_name─┐ +1. │ test.sql │ + └───────────┘ +``` + +**示例 3:** 使用自由变量的高阶函数 + +以下示例查询显示,没有绑定的标识符在最接近的作用域中解析为一个实体。 +在这里,`extension` 在 `gen_name` lambda 函数体中未绑定。 +尽管 `extension` 在 `generated_names` 的定义和使用范围内被定义为常量 `'.txt'`,但它被解析为表 `extension_list` 的一列,因为它在 `generated_names` 子查询中是可用的。 + +```sql +CREATE TABLE extension_list +( + extension String +) +ORDER BY extension +AS SELECT '.sql'; + +WITH + '.txt' as extension, + generated_names as ( + WITH + (id) -> concat(lower(id), extension) AS gen_name + SELECT gen_name('test') as file_name FROM extension_list + ) +SELECT file_name FROM generated_names; +``` + +```response + ┌─file_name─┐ +1. │ test.sql │ + └───────────┘ +``` + +**示例 4:** 从 SELECT 子句列列表中驱逐 sum(bytes) 表达式结果 ```sql -WITH sum(bytes) as s +WITH sum(bytes) AS s SELECT formatReadableSize(s), table @@ -65,7 +135,7 @@ GROUP BY table ORDER BY s; ``` -**示例 3:** 使用标量子查询的结果 +**示例 5:** 使用标量子查询的结果 ```sql /* this example would return TOP 10 of most huge tables */ @@ -84,7 +154,7 @@ ORDER BY table_disk_usage DESC LIMIT 10; ``` -**示例 4:** 在子查询中重用表达式 +**示例 6:** 在子查询中复用表达式 ```sql WITH test1 AS (SELECT i + 1, j + 1 FROM test1) @@ -93,7 +163,7 @@ SELECT * FROM test1; ## 递归查询 {#recursive-queries} -可选的 RECURSIVE 修饰符允许 WITH 查询引用其自身的输出。例如: +可选的 `RECURSIVE` 修饰符允许 WITH 查询引用其自身的输出。示例: **示例:** 从 1 到 100 的整数求和 @@ -113,22 +183,22 @@ SELECT sum(number) FROM test_table; ``` :::note -递归 CTE 依赖于在版本 **`24.3`** 中引入的 [新查询分析器](/operations/analyzer)。如果您使用的是版本 **`24.3+`** 并遇到 **`(UNKNOWN_TABLE)`** 或 **`(UNSUPPORTED_METHOD)`** 异常,这表明您的实例、角色或配置中禁用了新分析器。要激活分析器,请启用设置 **`allow_experimental_analyzer`** 或将 **`compatibility`** 设置更新为更新版本。 -从版本 `24.8` 开始,新分析器已完全推广至生产环境,设置 `allow_experimental_analyzer` 已重命名为 `enable_analyzer`。 +递归 CTE 依赖于在版本 **`24.3`** 中引入的 [新查询分析器](/operations/analyzer)。如果您使用版本 **`24.3+`** 并遇到 **`(UNKNOWN_TABLE)`** 或 **`(UNSUPPORTED_METHOD)`** 异常,则表明您的实例、角色或配置文件中禁用了新分析器。要激活分析器,请启用设置 **`allow_experimental_analyzer`** 或将 **`compatibility`** 设置更新为较新版本。 +从版本 `24.8` 开始,新分析器已完全推广到生产,设置 `allow_experimental_analyzer` 已重命名为 `enable_analyzer`。 ::: -递归 `WITH` 查询的一般形式总是一个非递归项,然后是 `UNION ALL`,然后是递归项,只有递归项可以包含对查询自身输出的引用。递归 CTE 查询按以下方式执行: +递归 `WITH` 查询的一般形式始终是一个非递归项,然后是 `UNION ALL`,然后是一个递归项,其中只有递归项可以包含对查询自身输出的引用。递归 CTE 查询的执行过程如下: -1. 评估非递归项。将非递归项查询的结果放置在临时工作表中。 -2. 只要工作表不是空的,就重复以下步骤: - 1. 评估递归项,用工作表的当前内容替换递归自引用。将递归项查询的结果放置在临时中间表中。 +1. 评估非递归项。将非递归项查询的结果放在临时工作表中。 +2. 只要工作表不为空,就重复以下步骤: + 1. 评估递归项,将工作表的当前内容替换为递归自引用。将递归项查询的结果放在临时中间表中。 2. 用中间表的内容替换工作表的内容,然后清空中间表。 -递归查询通常用于处理层次结构或树结构的数据。例如,我们可以编写一个执行树遍历的查询: +递归查询通常用于处理分层或树状结构数据。例如,我们可以写一个执行树遍历的查询: **示例:** 树遍历 -首先让我们创建树表: +首先,让我们创建树表: ```sql DROP TABLE IF EXISTS tree; @@ -142,7 +212,7 @@ CREATE TABLE tree INSERT INTO tree VALUES (0, NULL, 'ROOT'), (1, 0, 'Child_1'), (2, 0, 'Child_2'), (3, 1, 'Child_1_1'); ``` -我们可以通过这样的查询遍历这些树: +我们可以用这样的查询遍历这些树: **示例:** 树遍历 ```sql @@ -221,7 +291,7 @@ SELECT * FROM search_tree ORDER BY depth; ### 循环检测 {#cycle-detection} -首先让我们建立图表: +首先让我们创建图表: ```sql DROP TABLE IF EXISTS graph; @@ -235,9 +305,9 @@ CREATE TABLE graph INSERT INTO graph VALUES (1, 2, '1 -> 2'), (1, 3, '1 -> 3'), (2, 3, '2 -> 3'), (1, 4, '1 -> 4'), (4, 5, '4 -> 5'); ``` -我们可以通过这样的查询遍历该图: +我们可以用这样的查询遍历该图: -**示例:** 无循环检测的图遍历 +**示例:** 不带循环检测的图遍历 ```sql WITH RECURSIVE search_graph AS ( SELECT from, to, label FROM graph g @@ -258,7 +328,7 @@ SELECT DISTINCT * FROM search_graph ORDER BY from; └──────┴────┴────────┘ ``` -但是如果我们在该图中添加循环,之前的查询将因 `Maximum recursive CTE evaluation depth` 错误而失败: +但是,如果我们在图中添加循环,之前的查询将因 `Maximum recursive CTE evaluation depth` 错误而失败: ```sql INSERT INTO graph VALUES (5, 1, '5 -> 1'); @@ -277,9 +347,9 @@ SELECT DISTINCT * FROM search_graph ORDER BY from; Code: 306. DB::Exception: Received from localhost:9000. DB::Exception: Maximum recursive CTE evaluation depth (1000) exceeded, during evaluation of search_graph AS (SELECT from, to, label FROM graph AS g UNION ALL SELECT g.from, g.to, g.label FROM graph AS g, search_graph AS sg WHERE g.from = sg.to). Consider raising max_recursive_cte_evaluation_depth setting.: While executing RecursiveCTESource. (TOO_DEEP_RECURSION) ``` -处理循环的标准方法是计算一个已经访问的节点数组: +处理循环的标准方法是计算一个已访问节点的数组: -**示例:** 带循环检测的图遍历 +**示例:** 带有循环检测的图遍历 ```sql WITH RECURSIVE search_graph AS ( SELECT from, to, label, false AS is_cycle, [tuple(g.from, g.to)] AS path FROM graph g diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/with.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/with.md.hash index 296437c48a1..bc75da9f08f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/with.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/select/with.md.hash @@ -1 +1 @@ -6ab57f25f1eaa985 +8346e289d746fe89 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/set-role.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/set-role.md index 7a433bc7a8a..6fd6e0eaa6f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/set-role.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/set-role.md @@ -1,9 +1,10 @@ --- -'description': 'Set Role 的文档' +'description': 'SET ROLE 的文档' 'sidebar_label': 'SET ROLE' 'sidebar_position': 51 'slug': '/sql-reference/statements/set-role' 'title': 'SET ROLE 语句' +'doc_type': 'reference' --- 激活当前用户的角色。 @@ -16,7 +17,7 @@ SET ROLE {DEFAULT | NONE | role [,...] | ALL | ALL EXCEPT role [,...]} 为用户设置默认角色。 -默认角色在用户登录时会自动激活。您只能将之前授予的角色设置为默认角色。如果该角色未授予用户,ClickHouse 会抛出异常。 +默认角色在用户登录时会自动激活。您只能将先前授予的角色设置为默认角色。如果角色未授予给用户,ClickHouse 将抛出异常。 ```sql SET DEFAULT ROLE {NONE | role [,...] | ALL | ALL EXCEPT role [,...]} TO {user|CURRENT_USER} [,...] @@ -42,7 +43,7 @@ SET DEFAULT ROLE ALL TO user SET DEFAULT ROLE NONE TO user ``` -将所有授予的角色设置为用户的默认角色,但排除特定角色 `role1` 和 `role2`: +将所有授予的角色设置为默认角色,除了特定角色 `role1` 和 `role2`: ```sql SET DEFAULT ROLE ALL EXCEPT role1, role2 TO user diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/set-role.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/set-role.md.hash index b55da30f00f..0fc6d5d4588 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/set-role.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/set-role.md.hash @@ -1 +1 @@ -1f92fa2b1f7f9ec0 +4df62c89854c357a diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/set.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/set.md index d2d82d66d35..b675eb83e70 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/set.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/set.md @@ -4,6 +4,7 @@ 'sidebar_position': 50 'slug': '/sql-reference/statements/set' 'title': 'SET 语句' +'doc_type': 'reference' --- @@ -13,12 +14,20 @@ SET param = value ``` -将 `value` 指定给当前会话的 `param` [设置](/operations/settings/overview)。您无法通过这种方式更改 [服务器设置](../../operations/server-configuration-parameters/settings.md)。 +将 `value` 分配给当前会话的 `param` [设置](/operations/settings/overview)。您不能通过这种方式更改 [服务器设置](../../operations/server-configuration-parameters/settings.md)。 -您还可以在一个查询中设置指定设置档案中的所有值。 +您还可以在单个查询中设置指定设置配置文件的所有值。 ```sql SET profile = 'profile-name-from-the-settings-file' ``` +对于设置为 true 的布尔值设置,您可以通过省略值分配使用简写语法。当仅指定设置名称时,它会自动设置为 `1` (true)。 + +```sql +-- These are equivalent: +SET force_index_by_date = 1 +SET force_index_by_date +``` + 有关更多信息,请参见 [设置](../../operations/settings/settings.md)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/set.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/set.md.hash index f31ddaba0f0..180134170d4 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/set.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/set.md.hash @@ -1 +1 @@ -30460fc3feb57fea +fda03df811233e19 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/show.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/show.md index a0de7ef40c1..2233df229c7 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/show.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/show.md @@ -1,24 +1,25 @@ --- -'description': 'Documentation for SHOW' +'description': 'SHOW 的文档' 'sidebar_label': 'SHOW' 'sidebar_position': 37 'slug': '/sql-reference/statements/show' 'title': 'SHOW 语句' +'doc_type': 'reference' --- :::note `SHOW CREATE (TABLE|DATABASE|USER)` 隐藏秘密,除非启用以下设置: -- [`display_secrets_in_show_and_select`](../../operations/server-configuration-parameters/settings/#display_secrets_in_show_and_select)(服务器设置) -- [`format_display_secrets_in_show_and_select`](../../operations/settings/formats/#format_display_secrets_in_show_and_select)(格式设置) +- [`display_secrets_in_show_and_select`](../../operations/server-configuration-parameters/settings/#display_secrets_in_show_and_select) (服务器设置) +- [`format_display_secrets_in_show_and_select`](../../operations/settings/formats/#format_display_secrets_in_show_and_select) (格式设置) -此外,用户应拥有 [`displaySecretsInShowAndSelect`](grant.md/#displaysecretsinshowandselect) 权限。 +此外,用户应该具有 [`displaySecretsInShowAndSelect`](grant.md/#displaysecretsinshowandselect) 权限。 ::: ## SHOW CREATE TABLE | DICTIONARY | VIEW | DATABASE {#show-create-table--dictionary--view--database} -这些语句返回一个类型为 String 的单列, +这些语句返回一个类型为 String 的单列, 包含用于创建指定对象的 `CREATE` 查询。 ### 语法 {#syntax} @@ -28,14 +29,14 @@ SHOW [CREATE] TABLE | TEMPORARY TABLE | DICTIONARY | VIEW | DATABASE [db.]table| ``` :::note -如果使用此语句获取系统表的 `CREATE` 查询, -您将得到一个 *虚假的* 查询,仅声明表结构, -但不能用于创建表。 +如果您使用此语句获取系统表的 `CREATE` 查询, +您将获得一个 *伪* 查询,该查询仅声明表结构, +但无法用于创建表。 ::: ## SHOW DATABASES {#show-databases} -该语句打印所有数据库的列表。 +此语句打印所有数据库的列表。 ### 语法 {#syntax-1} @@ -43,7 +44,7 @@ SHOW [CREATE] TABLE | TEMPORARY TABLE | DICTIONARY | VIEW | DATABASE [db.]table| SHOW DATABASES [[NOT] LIKE | ILIKE ''] [LIMIT ] [INTO OUTFILE filename] [FORMAT format] ``` -它与以下查询相同: +它与查询相同: ```sql SELECT name FROM system.databases [WHERE name [NOT] LIKE | ILIKE ''] [LIMIT ] [INTO OUTFILE filename] [FORMAT format] @@ -63,7 +64,7 @@ SHOW DATABASES LIKE '%de%' └─────────┘ ``` -我们也可以使用不区分大小写的方式进行查询: +我们也可以以不区分大小写的方式执行此操作: ```sql title="Query" SHOW DATABASES ILIKE '%DE%' @@ -90,7 +91,7 @@ SHOW DATABASES NOT LIKE '%de%' └────────────────────────────────┘ ``` -最后,我们可以获取前两个数据库的名称: +最后,我们可以只获取前两个数据库的名称: ```sql title="Query" SHOW DATABASES LIMIT 2 @@ -105,7 +106,7 @@ SHOW DATABASES LIMIT 2 ### 另请参见 {#see-also} -- [`CREATE DATABASE`]( /sql-reference/statements/create/database) +- [`CREATE DATABASE`](/sql-reference/statements/create/database) ## SHOW TABLES {#show-tables} @@ -117,9 +118,9 @@ SHOW DATABASES LIMIT 2 SHOW [FULL] [TEMPORARY] TABLES [{FROM | IN} ] [[NOT] LIKE | ILIKE ''] [LIMIT ] [INTO OUTFILE ] [FORMAT ] ``` -如果未指定 `FROM` 子句,则查询返回当前数据库的表列表。 +如果没有指定 `FROM` 子句,则查询返回当前数据库中的表列表。 -该语句与以下查询相同: +此语句与查询相同: ```sql SELECT name FROM system.tables [WHERE name [NOT] LIKE | ILIKE ''] [LIMIT ] [INTO OUTFILE ] [FORMAT ] @@ -140,7 +141,7 @@ SHOW TABLES FROM system LIKE '%user%' └──────────────────┘ ``` -我们也可以以不区分大小写的方式进行查询: +我们也可以以不区分大小写的方式执行此操作: ```sql title="Query" SHOW TABLES FROM system ILIKE '%USER%' @@ -167,7 +168,7 @@ SHOW TABLES FROM system NOT LIKE '%s%' └──────────────┘ ``` -最后,我们可以获取前两个表的名称: +最后,我们可以只获取前两个表的名称: ```sql title="Query" SHOW TABLES FROM system LIMIT 2 @@ -182,7 +183,7 @@ SHOW TABLES FROM system LIMIT 2 ### 另请参见 {#see-also-1} -- [`Create Tables`]( /sql-reference/statements/create/table) +- [`Create Tables`](/sql-reference/statements/create/table) - [`SHOW CREATE TABLE`](#show-create-table--dictionary--view--database) ## SHOW COLUMNS {#show_columns} @@ -196,30 +197,30 @@ SHOW [EXTENDED] [FULL] COLUMNS {FROM | IN}
[{FROM | IN} ] [{[NOT] {L OUTFILE ] [FORMAT ] ``` -数据库和表名可以以 `.
` 的简写形式指定, -这意味着 `FROM tab FROM db` 和 `FROM db.tab` 是等价的。 -如果未指定数据库,则查询返回当前数据库的列列表。 +数据库和表名可以用简写形式 `.
` 指定, +这意味着 `FROM tab FROM db` 和 `FROM db.tab` 是等效的。 +如果未指定数据库,则查询返回当前数据库中的列列表。 -还可以使用两个可选关键字: `EXTENDED` 和 `FULL`。`EXTENDED` 关键字当前没有效果, -存在是为了与 MySQL 兼容。`FULL` 关键字使输出包含排序规则、注释和权限列。 +还有两个可选关键字:`EXTENDED` 和 `FULL`。 `EXTENDED` 关键字目前没有效果, +存在是为了与 MySQL 兼容。 `FULL` 关键字使输出包括校对、注释和权限列。 -`SHOW COLUMNS` 语句生成具有以下结构的结果表: +`SHOW COLUMNS` 语句产生一个结果表,其结构如下: -| 列 | 描述 | 类型 | -|-------------|---------------------------------------------------------------------------------------------------------------------------|--------------------| -| `field` | 列的名称 | `String` | -| `type` | 列的数据类型。如果通过 MySQL 线协议执行查询,则显示 MySQL 中的等效类型名称。 | `String` | -| `null` | 如果列的数据类型为 Nullable,则为 `YES`,否则为 `NO` | `String` | -| `key` | 如果列是主键的一部分,则为 `PRI`;如果列是排序键的一部分,则为 `SOR`;否则为空。 | `String` | -| `default` | 如果列的类型为 `ALIAS`、 `DEFAULT` 或 `MATERIALIZED`,则为该列的默认表达式;否则为 `NULL`。 | `Nullable(String)` | -| `extra` | 额外信息,当前未使用 | `String` | -| `collation` | (仅在指定 `FULL` 关键字时适用)列的排序规则,始终为 `NULL`,因为 ClickHouse 不支持逐列排序规则 | `Nullable(String)` | -| `comment` | (仅在指定 `FULL` 关键字时适用)列的注释 | `String` | -| `privilege` | (仅在指定 `FULL` 关键字时适用)您对该列的权限,当前不可用 | `String` | +| 列 | 描述 | 类型 | +|-------------|------------------------------------------------------------------------------------------------------------------------|--------------------| +| `field` | 列的名称 | `String` | +| `type` | 列的数据类型。如果查询是通过 MySQL 线协议进行的,则显示 MySQL 中的等效类型名称。 | `String` | +| `null` | 如果列的数据类型是 Nullable,则为 `YES`,否则为 `NO` | `String` | +| `key` | 如果列是主键的一部分,则为 `PRI`,如果列是排序键的一部分,则为 `SOR`,否则为空 | `String` | +| `default` | 如果列的类型是 `ALIAS`、`DEFAULT` 或 `MATERIALIZED`,则为列的默认表达式,否则为 `NULL`。 | `Nullable(String)` | +| `extra` | 附加信息,目前未使用 | `String` | +| `collation` | (仅在指定了 `FULL` 关键字时)列的校对,总是 `NULL`,因为 ClickHouse 没有每列的校对 | `Nullable(String)` | +| `comment` | (仅在指定了 `FULL` 关键字时)列的注释 | `String` | +| `privilege` | (仅在指定了 `FULL` 关键字时)您在此列上的权限,目前不可用 | `String` | ### 示例 {#examples-2} -在此示例中,我们将使用 `SHOW COLUMNS` 语句获取有关表 'orders' 中所有以 'delivery_' 开头的列的信息: +在此示例中,我们将使用 `SHOW COLUMNS` 语句获取表 'orders' 中所有列的信息,从 'delivery_' 开始: ```sql title="Query" SHOW COLUMNS FROM 'orders' LIKE 'delivery_%' @@ -246,9 +247,9 @@ SHOW COLUMNS FROM 'orders' LIKE 'delivery_%' SHOW DICTIONARIES [FROM ] [LIKE ''] [LIMIT ] [INTO OUTFILE ] [FORMAT ] ``` -如果未指定 `FROM` 子句,则查询返回当前数据库的字典列表。 +如果没有指定 `FROM` 子句,则查询返回当前数据库中的字典列表。 -您可以通过以下方式获得与 `SHOW DICTIONARIES` 查询相同的结果: +您可以通过以下方式获取与 `SHOW DICTIONARIES` 查询相同的结果: ```sql SELECT name FROM system.dictionaries WHERE database = [AND name LIKE ] [LIMIT ] [INTO OUTFILE ] [FORMAT ] @@ -256,7 +257,7 @@ SELECT name FROM system.dictionaries WHERE database = [AND name LIKE [{FROM | IN} ] [WHERE ] [INTO OUTFILE ] [FORMAT ] ``` -数据库和表名可以以 `.
` 的简写形式指定,即 `FROM tab FROM db` 和 `FROM db.tab` 是等价的。如果未指定数据库,则查询假设当前数据库为数据库。 +数据库和表名可以用简写形式 `.
` 指定,即 `FROM tab FROM db` 和 `FROM db.tab` 是 +等效的。如果未指定数据库,则查询假定当前数据库为数据库。 -`EXTENDED` 可选关键字当前没有效果,存在是为了与 MySQL 兼容。 +可选关键字 `EXTENDED` 目前没有效果,存在是为了与 MySQL 兼容。 -该语句生成具有以下结构的结果表: +该语句产生一个结果表,其结构如下: -| 列 | 描述 | 类型 | -|-----------------|---------------------------------------------------------------------------------------------------|--------------------| -| `table` | 表的名称 | `String` | -| `non_unique` | 始终为 `1`,因为 ClickHouse 不支持唯一性约束。 | `UInt8` | -| `key_name` | 索引的名称,若索引为主键索引,则为 `PRIMARY`。 | `String` | -| `seq_in_index` | 对于主键索引,从 `1` 开始的列位置。对于数据跳过索引:始终为 `1`。 | `UInt8` | -| `column_name` | 对于主键索引,该列的名称。对数据跳过索引: `''`(空字符串),参见字段 "expression"。 | `String` | -| `collation` | 索引中列的排序:`A` 如果是升序, `D` 如果是降序, `NULL` 如果未排序。 | `Nullable(String)` | -| `cardinality` | 对索引基数的估计(索引中唯一值的数量)。当前始终为 0。 | `UInt64` | -| `sub_part` | 始终为 `NULL`,因为 ClickHouse 不支持像 MySQL 一样的索引前缀。 | `Nullable(String)` | -| `packed` | 始终为 `NULL`,因为 ClickHouse 不支持打包索引(如 MySQL)。 | `Nullable(String)` | -| `null` | 当前未使用 | | -| `index_type` | 索引类型,例如 `PRIMARY`、 `MINMAX`、 `BLOOM_FILTER` 等。 | `String` | -| `comment` | 有关索引的额外信息,当前始终为 `''`(空字符串)。 | `String` | -| `index_comment` | `''`(空字符串),因为 ClickHouse 中的索引不能有 `COMMENT` 字段(与 MySQL 不同)。 | `String` | -| `visible` | 如果索引对优化器可见,则始终为 `YES`。 | `String` | -| `expression` | 对于数据跳过索引,索引表达式。对于主键索引: `''`(空字符串)。 | `String` | +| 列 | 描述 | 类型 | +|-----------------|----------------------------------------------------------------------------------------------------------------------|--------------------| +| `table` | 表的名称。 | `String` | +| `non_unique` | 始终为 `1`,因为 ClickHouse 不支持唯一性约束。 | `UInt8` | +| `key_name` | 索引的名称,`PRIMARY` 如果索引是主键索引。 | `String` | +| `seq_in_index` | 对于主键索引,从 `1` 开始的列的位置。对于数据跳过索引:始终为 `1`。 | `UInt8` | +| `column_name` | 对于主键索引,列的名称。对于数据跳过索引:`''`(空字符串),见字段 "expression"。 | `String` | +| `collation` | 索引中列的排序:升序为 `A`,降序为 `D`,未排序为 `NULL`。 | `Nullable(String)` | +| `cardinality` | 索引基数的估计(索引中唯一值的数量)。目前始终为 0。 | `UInt64` | +| `sub_part` | 始终为 `NULL`,因为 ClickHouse 不支持像 MySQL 那样的索引前缀。 | `Nullable(String)` | +| `packed` | 始终为 `NULL`,因为 ClickHouse 不支持压缩索引(如 MySQL)。 | `Nullable(String)` | +| `null` | 当前未使用 | | +| `index_type` | 索引类型,例如 `PRIMARY`、`MINMAX`、`BLOOM_FILTER` 等。 | `String` | +| `comment` | 关于索引的附加信息,目前始终为 `''`(空字符串)。 | `String` | +| `index_comment` | `''`(空字符串),因为 ClickHouse 中的索引不能有 `COMMENT` 字段(与 MySQL 类似)。 | `String` | +| `visible` | 如果索引对优化器可见,始终为 `YES`。 | `String` | +| `expression` | 对于数据跳过索引,索引表达式。对于主键索引:`''`(空字符串)。 | `String` | ### 示例 {#examples-4} @@ -331,7 +335,7 @@ SHOW INDEX FROM 'tbl' ## SHOW PROCESSLIST {#show-processlist} -输出 [`system.processes`](/operations/system-tables/processes) 表的内容,其中包含正在处理的查询列表,排除了 `SHOW PROCESSLIST` 查询。 +输出 [`system.processes`](/operations/system-tables/processes) 表的内容,其中包含当前正在处理的查询列表,不包括 `SHOW PROCESSLIST` 查询。 ### 语法 {#syntax-6} @@ -339,7 +343,7 @@ SHOW INDEX FROM 'tbl' SHOW PROCESSLIST [INTO OUTFILE filename] [FORMAT format] ``` -`SELECT * FROM system.processes` 查询返回有关所有当前查询的数据。 +`SELECT * FROM system.processes` 查询返回所有当前查询的数据。 :::tip 在控制台中执行: @@ -361,13 +365,13 @@ SHOW GRANTS [FOR user1 [, user2 ...]] [WITH IMPLICIT] [FINAL] 如果未指定用户,则查询返回当前用户的权限。 -`WITH IMPLICIT` 修饰符允许显示隐式授予(例如, `GRANT SELECT ON system.one`) +`WITH IMPLICIT` 修饰符允许显示隐式授予(例如,`GRANT SELECT ON system.one`) -`FINAL` 修饰符合并用户及其授予角色的所有权限(包含继承)。 +`FINAL` 修饰符合并来自用户及其授予角色(带继承)的所有授予。 ## SHOW CREATE USER {#show-create-user} -`SHOW CREATE USER` 语句显示在 [用户创建](../../sql-reference/statements/create/user.md) 时使用的参数。 +`SHOW CREATE USER` 语句显示用于 [用户创建](../../sql-reference/statements/create/user.md) 的参数。 ### 语法 {#syntax-8} @@ -377,7 +381,7 @@ SHOW CREATE USER [name1 [, name2 ...] | CURRENT_USER] ## SHOW CREATE ROLE {#show-create-role} -`SHOW CREATE ROLE` 语句显示在 [角色创建](../../sql-reference/statements/create/role.md) 时使用的参数。 +`SHOW CREATE ROLE` 语句显示用于 [角色创建](../../sql-reference/statements/create/role.md) 的参数。 ### 语法 {#syntax-9} @@ -387,7 +391,7 @@ SHOW CREATE ROLE name1 [, name2 ...] ## SHOW CREATE ROW POLICY {#show-create-row-policy} -`SHOW CREATE ROW POLICY` 语句显示在 [行策略创建](../../sql-reference/statements/create/row-policy.md) 时使用的参数。 +`SHOW CREATE ROW POLICY` 语句显示用于 [行策略创建](../../sql-reference/statements/create/row-policy.md) 的参数。 ### 语法 {#syntax-10} @@ -397,7 +401,7 @@ SHOW CREATE [ROW] POLICY name ON [database1.]table1 [, [database2.]table2 ...] ## SHOW CREATE QUOTA {#show-create-quota} -`SHOW CREATE QUOTA` 语句显示在 [配额创建](../../sql-reference/statements/create/quota.md) 时使用的参数。 +`SHOW CREATE QUOTA` 语句显示用于 [配额创建](../../sql-reference/statements/create/quota.md) 的参数。 ### 语法 {#syntax-11} @@ -407,7 +411,7 @@ SHOW CREATE QUOTA [name1 [, name2 ...] | CURRENT] ## SHOW CREATE SETTINGS PROFILE {#show-create-settings-profile} -`SHOW CREATE SETTINGS PROFILE` 语句显示在 [设置配置文件创建](../../sql-reference/statements/create/settings-profile.md) 时使用的参数。 +`SHOW CREATE SETTINGS PROFILE` 语句显示用于 [设置配置文件创建](../../sql-reference/statements/create/settings-profile.md) 的参数。 ### 语法 {#syntax-12} @@ -417,8 +421,8 @@ SHOW CREATE [SETTINGS] PROFILE name1 [, name2 ...] ## SHOW USERS {#show-users} -`SHOW USERS` 语句返回 [用户账户](../../guides/sre/user-management/index.md#user-account-management) 名称的列表。 -要查看用户账户参数,请参阅系统表 [`system.users`](/operations/system-tables/users)。 +`SHOW USERS` 语句返回一个 [用户帐户](../../guides/sre/user-management/index.md#user-account-management) 名称列表。 +要查看用户帐户参数,请参见系统表 [`system.users`](/operations/system-tables/users)。 ### 语法 {#syntax-13} @@ -428,8 +432,9 @@ SHOW USERS ## SHOW ROLES {#show-roles} -`SHOW ROLES` 语句返回 [角色](../../guides/sre/user-management/index.md#role-management) 的列表。 -要查看其他参数,请参阅系统表 [`system.roles`](/operations/system-tables/roles) 和 [`system.role_grants`](/operations/system-tables/role-grants)。 +`SHOW ROLES` 语句返回一个 [角色](../../guides/sre/user-management/index.md#role-management) 名称列表。 +要查看其他参数, +请参见系统表 [`system.roles`](/operations/system-tables/roles) 和 [`system.role_grants`](/operations/system-tables/role_grants)。 ### 语法 {#syntax-14} @@ -438,8 +443,8 @@ SHOW [CURRENT|ENABLED] ROLES ``` ## SHOW PROFILES {#show-profiles} -`SHOW PROFILES` 语句返回 [设置配置文件](../../guides/sre/user-management/index.md#settings-profiles-management) 的列表。 -要查看用户账户参数,请参阅系统表 [`settings_profiles`](/operations/system-tables/settings_profiles)。 +`SHOW PROFILES` 语句返回一个 [设置配置文件](../../guides/sre/user-management/index.md#settings-profiles-management) 名称列表。 +要查看用户帐户参数,请参见系统表 [`settings_profiles`](/operations/system-tables/settings_profiles)。 ### 语法 {#syntax-15} @@ -449,8 +454,8 @@ SHOW [SETTINGS] PROFILES ## SHOW POLICIES {#show-policies} -`SHOW POLICIES` 语句返回指定表的 [行策略](../../guides/sre/user-management/index.md#row-policy-management) 的列表。 -要查看用户账户参数,请参阅系统表 [`system.row_policies`](/operations/system-tables/row_policies)。 +`SHOW POLICIES` 语句返回指定表的 [行策略](../../guides/sre/user-management/index.md#row-policy-management) 列表。 +要查看用户帐户参数,请参见系统表 [`system.row_policies`](/operations/system-tables/row_policies)。 ### 语法 {#syntax-16} @@ -460,8 +465,8 @@ SHOW [ROW] POLICIES [ON [db.]table] ## SHOW QUOTAS {#show-quotas} -`SHOW QUOTAS` 语句返回 [配额](../../guides/sre/user-management/index.md#quotas-management) 的列表。 -要查看配额参数,请参阅系统表 [`system.quotas`](/operations/system-tables/quotas)。 +`SHOW QUOTAS` 语句返回 [配额](../../guides/sre/user-management/index.md#quotas-management) 列表。 +要查看配额参数,请参见系统表 [`system.quotas`](/operations/system-tables/quotas)。 ### 语法 {#syntax-17} @@ -471,8 +476,8 @@ SHOW QUOTAS ## SHOW QUOTA {#show-quota} -`SHOW QUOTA` 语句返回所有用户或当前用户的 [配额](../../operations/quotas.md) 消耗。 -要查看其他参数,请参阅系统表 [`system.quotas_usage`](/operations/system-tables/quotas_usage) 和 [`system.quota_usage`](/operations/system-tables/quota_usage)。 +`SHOW QUOTA` 语句返回所有用户或当前用户的 [配额](../../operations/quotas.md) 消耗。 +要查看其他参数,请参见系统表 [`system.quotas_usage`](/operations/system-tables/quotas_usage) 和 [`system.quota_usage`](/operations/system-tables/quota_usage)。 ### 语法 {#syntax-18} @@ -481,7 +486,7 @@ SHOW [CURRENT] QUOTA ``` ## SHOW ACCESS {#show-access} -`SHOW ACCESS` 语句显示所有 [用户](../../guides/sre/user-management/index.md#user-account-management)、 [角色](../../guides/sre/user-management/index.md#role-management)、 [配置文件](../../guides/sre/user-management/index.md#settings-profiles-management) 等以及它们的所有 [授予](../../sql-reference/statements/grant.md#privileges)。 +`SHOW ACCESS` 语句显示所有 [用户](../../guides/sre/user-management/index.md#user-account-management)、[角色](../../guides/sre/user-management/index.md#role-management)、[配置文件](../../guides/sre/user-management/index.md#settings-profiles-management) 等及其所有 [授权](../../sql-reference/statements/grant.md#privileges)。 ### 语法 {#syntax-19} @@ -491,11 +496,11 @@ SHOW ACCESS ## SHOW CLUSTER(S) {#show-clusters} -`SHOW CLUSTER(S)` 语句返回集群的列表。 -所有可用集群在 [`system.clusters`](../../operations/system-tables/clusters.md) 表中列出。 +`SHOW CLUSTER(S)` 语句返回集群列表。 +所有可用集群都列在 [`system.clusters`](../../operations/system-tables/clusters.md) 表中。 :::note -`SHOW CLUSTER name` 查询显示指定集群名称的 `system.clusters` 表中的 `cluster`、 `shard_num`、 `replica_num`、 `host_name`、 `host_address` 和 `port`。 +`SHOW CLUSTER name` 查询显示 `system.clusters` 表中指定集群名称的 `cluster`、`shard_num`、`replica_num`、`host_name`、`host_address` 和 `port`。 ::: ### 语法 {#syntax-20} @@ -549,7 +554,7 @@ port: 9000 ## SHOW SETTINGS {#show-settings} -`SHOW SETTINGS` 语句返回系统设置及其值的列表。 +`SHOW SETTINGS` 语句返回系统设置及其值的列表。 它从 [`system.settings`](../../operations/system-tables/settings.md) 表中选择数据。 ### 语法 {#syntax-21} @@ -560,13 +565,13 @@ SHOW [CHANGED] SETTINGS LIKE|ILIKE ### 子句 {#clauses} -`LIKE|ILIKE` 允许为设置名称指定匹配模式。它可以包含如 `%` 或 `_` 的通配符。`LIKE` 子句区分大小写, `ILIKE` 则不区分大小写。 +`LIKE|ILIKE` 允许指定设置名称的匹配模式。它可以包含斜杠,如 `%` 或 `_`。 `LIKE` 子句是大小写敏感的,`ILIKE` — 不区分大小写。 -当使用 `CHANGED` 子句时,查询仅返回从其默认值更改的设置。 +当使用 `CHANGED` 子句时,查询仅返回已更改的设置与其默认值的不同。 ### 示例 {#examples-6} -带 `LIKE` 子句的查询: +带有 `LIKE` 子句的查询: ```sql title="Query" SHOW SETTINGS LIKE 'send_timeout'; @@ -578,7 +583,7 @@ SHOW SETTINGS LIKE 'send_timeout'; └──────────────┴─────────┴───────┘ ``` -带 `ILIKE` 子句的查询: +带有 `ILIKE` 子句的查询: ```sql title="Query" SHOW SETTINGS ILIKE '%CONNECT_timeout%' @@ -592,7 +597,7 @@ SHOW SETTINGS ILIKE '%CONNECT_timeout%' └─────────────────────────────────────────┴──────────────┴───────┘ ``` -带 `CHANGED` 子句的查询: +带有 `CHANGED` 子句的查询: ```sql title="Query" SHOW CHANGED SETTINGS ILIKE '%MEMORY%' @@ -638,8 +643,8 @@ SHOW FILESYSTEM CACHES ## SHOW ENGINES {#show-engines} -`SHOW ENGINES` 语句输出 [`system.table_engines`](../../operations/system-tables/table_engines.md) 表的内容, -该表包含服务器支持的表引擎及其功能支持信息的描述。 +`SHOW ENGINES` 语句输出 [`system.table_engines`](../../operations/system-tables/table_engines.md) 表的内容, +其中包含服务器支持的表引擎及其功能支持信息的描述。 ### 语法 {#syntax-23} @@ -649,7 +654,7 @@ SHOW ENGINES [INTO OUTFILE filename] [FORMAT format] ### 另请参见 {#see-also-6} -- [system.table_engines](../../operations/system-tables/table_engines.md) 表 +- [`system.table_engines`](../../operations/system-tables/table_engines.md) 表 ## SHOW FUNCTIONS {#show-functions} @@ -661,7 +666,7 @@ SHOW ENGINES [INTO OUTFILE filename] [FORMAT format] SHOW FUNCTIONS [LIKE | ILIKE ''] ``` -如果指定了 `LIKE` 或 `ILIKE` 子句,则查询返回与提供的 `` 匹配的系统函数名称列表。 +如果指定了 `LIKE` 或 `ILIKE` 子句,则查询会返回与提供的 `` 匹配的系统函数名称列表。 ### 另请参见 {#see-also-7} @@ -669,19 +674,19 @@ SHOW FUNCTIONS [LIKE | ILIKE ''] ## SHOW MERGES {#show-merges} -`SHOW MERGES` 语句返回合并的列表。 -所有合并在 [`system.merges`](../../operations/system-tables/merges.md) 表中列出: - -| 列 | 描述 | -|---------------------|----------------------------------------------------| -| `table` | 表名。 | -| `database` | 表所在数据库的名称。 | -| `estimate_complete` | 完成的估计时间(以秒为单位)。 | -| `elapsed` | 从合并开始以来经过的时间(以秒为单位)。 | -| `progress` | 完成工作百分比(0-100 百分比)。 | -| `is_mutation` | 如果该过程是部分变更,则为 1。 | -| `size_compressed` | 合并部分的压缩数据总大小。 | -| `memory_usage` | 合并过程的内存消耗。 | +`SHOW MERGES` 语句返回合并的列表。 +所有合并都列在 [`system.merges`](../../operations/system-tables/merges.md) 表中: + +| 列 | 描述 | +|-------------------|---------------------------------------------------------| +| `table` | 表名。 | +| `database` | 表所属数据库的名称。 | +| `estimate_complete` | 估计完成时间(以秒为单位)。 | +| `elapsed` | 自合并开始以来经过的时间(以秒为单位)。 | +| `progress` | 完成工作百分比(0-100 百分比)。 | +| `is_mutation` | 如果此过程是部分变更,则为 1。 | +| `size_compressed` | 合并部分的压缩数据的总大小。 | +| `memory_usage` | 合并过程的内存消耗。 | ### 语法 {#syntax-25} diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/show.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/show.md.hash index 241fdd2626b..9abfe9caf4e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/show.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/show.md.hash @@ -1 +1 @@ -71d2cbacc2638179 +f642dec49dc33ad7 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/system.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/system.md index dd9aece51d1..0a31995e853 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/system.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/system.md @@ -4,25 +4,21 @@ 'sidebar_position': 36 'slug': '/sql-reference/statements/system' 'title': 'SYSTEM 语句' +'doc_type': 'reference' --- import CloudNotSupportedBadge from '@theme/badges/CloudNotSupportedBadge'; -# SYSTEM 语句 +# SYSTEM Statements -## RELOAD EMBEDDED DICTIONARIES {#reload-embedded-dictionaries} +## SYSTEM RELOAD EMBEDDED DICTIONARIES {#reload-embedded-dictionaries} -重新加载所有 [Internal dictionaries](../../sql-reference/dictionaries/index.md)。 -默认情况下,内部字典是禁用的。 -无论内部字典更新的结果如何,总是返回 `Ok.`。 +重新加载所有 [内部字典](../../sql-reference/dictionaries/index.md)。 默认情况下,内部字典被禁用。 无论内部字典更新结果如何,始终返回 `Ok.`。 -## RELOAD DICTIONARIES {#reload-dictionaries} +## SYSTEM RELOAD DICTIONARIES {#reload-dictionaries} -重新加载之前成功加载的所有字典。 -默认情况下,字典是懒加载的(见 [dictionaries_lazy_load](../../operations/server-configuration-parameters/settings.md#dictionaries_lazy_load)),因此它们不会在启动时自动加载,而是在通过 dictGet 函数或从 ENGINE = Dictionary 的表中执行 SELECT 时首次访问时初始化。 -`SYSTEM RELOAD DICTIONARIES` 查询重新加载这样的字典 (LOADED)。 -无论字典更新的结果如何,总是返回 `Ok.`。 +重新加载之前成功加载的所有字典。 默认情况下,字典是懒加载的 (参见 [dictionaries_lazy_load](../../operations/server-configuration-parameters/settings.md#dictionaries_lazy_load)),因此它们不会在启动时自动加载,而是在通过 dictGet 函数或从 ENGINE = Dictionary 的表中 SELECT 时首次访问时被初始化。 `SYSTEM RELOAD DICTIONARIES` 查询重新加载这些字典 (LOADED)。 无论字典更新结果如何,始终返回 `Ok.`。 **语法** @@ -30,10 +26,9 @@ import CloudNotSupportedBadge from '@theme/badges/CloudNotSupportedBadge'; SYSTEM RELOAD DICTIONARIES [ON CLUSTER cluster_name] ``` -## RELOAD DICTIONARY {#reload-dictionary} +## SYSTEM RELOAD DICTIONARY {#reload-dictionary} -完全重新加载字典 `dictionary_name`,无论字典的状态(LOADED / NOT_LOADED / FAILED)。 -无论更新字典的结果如何,总是返回 `Ok.`。 +完全重新加载字典 `dictionary_name`,不论字典的状态(LOADED / NOT_LOADED / FAILED)。 无论字典更新结果如何,始终返回 `Ok.`。 ```sql SYSTEM RELOAD DICTIONARY [ON CLUSTER cluster_name] dictionary_name @@ -45,10 +40,10 @@ SYSTEM RELOAD DICTIONARY [ON CLUSTER cluster_name] dictionary_name SELECT name, status FROM system.dictionaries; ``` -## RELOAD MODELS {#reload-models} +## SYSTEM RELOAD MODELS {#reload-models} -:::note -该语句和 `SYSTEM RELOAD MODEL` 仅仅从 clickhouse-library-bridge 中卸载 catboost 模型。函数 `catboostEvaluate()` 在首次访问时加载模型,如果尚未加载。 +:::note +此语句及 `SYSTEM RELOAD MODEL` 仅从 clickhouse-library-bridge 卸载 catboost 模型。 函数 `catboostEvaluate()` 在首次访问时加载模型(如果尚未加载)。 ::: 卸载所有 CatBoost 模型。 @@ -59,7 +54,7 @@ SELECT name, status FROM system.dictionaries; SYSTEM RELOAD MODELS [ON CLUSTER cluster_name] ``` -## RELOAD MODEL {#reload-model} +## SYSTEM RELOAD MODEL {#reload-model} 卸载位于 `model_path` 的 CatBoost 模型。 @@ -69,9 +64,9 @@ SYSTEM RELOAD MODELS [ON CLUSTER cluster_name] SYSTEM RELOAD MODEL [ON CLUSTER cluster_name] ``` -## RELOAD FUNCTIONS {#reload-functions} +## SYSTEM RELOAD FUNCTIONS {#reload-functions} -从配置文件重新加载所有注册的 [executable user defined functions](/sql-reference/functions/udf#executable-user-defined-functions) 或其中之一。 +重新加载所有注册的 [可执行用户定义函数](/sql-reference/functions/udf#executable-user-defined-functions) 或从配置文件中重新加载其中之一。 **语法** @@ -80,29 +75,29 @@ SYSTEM RELOAD FUNCTIONS [ON CLUSTER cluster_name] SYSTEM RELOAD FUNCTION [ON CLUSTER cluster_name] function_name ``` -## RELOAD ASYNCHRONOUS METRICS {#reload-asynchronous-metrics} +## SYSTEM RELOAD ASYNCHRONOUS METRICS {#reload-asynchronous-metrics} -重新计算所有 [asynchronous metrics](../../operations/system-tables/asynchronous_metrics.md)。由于异步指标是基于设置 [asynchronous_metrics_update_period_s](../../operations/server-configuration-parameters/settings.md) 定期更新的,因此通常不需要使用此语句手动更新它们。 +重新计算所有 [异步指标](../../operations/system-tables/asynchronous_metrics.md)。 由于异步指标会根据设置 [asynchronous_metrics_update_period_s](../../operations/server-configuration-parameters/settings.md) 定期更新,因此通常不需要使用此语句手动更新它们。 ```sql SYSTEM RELOAD ASYNCHRONOUS METRICS [ON CLUSTER cluster_name] ``` -## DROP DNS CACHE {#drop-dns-cache} +## SYSTEM DROP DNS CACHE {#drop-dns-cache} -清除 ClickHouse 的内部 DNS 缓存。有时(对于旧版本的 ClickHouse),在更改基础架构(更改另一个 ClickHouse 服务器的 IP 地址或字典所使用的服务器)时,需要使用此命令。 +清除 ClickHouse 的内部 DNS 缓存。有时(对于旧版 ClickHouse),在更改基础架构(更改其他 ClickHouse 服务器的 IP 地址或字典使用的服务器)时,有必要使用此命令。 -有关更方便的(自动)缓存管理,请参见 disable_internal_dns_cache、dns_cache_max_entries、dns_cache_update_period 参数。 +要更便捷(自动)地管理缓存,请查看 `disable_internal_dns_cache`、`dns_cache_max_entries`、`dns_cache_update_period` 参数。 -## DROP MARK CACHE {#drop-mark-cache} +## SYSTEM DROP MARK CACHE {#drop-mark-cache} 清除标记缓存。 -## DROP ICEBERG METADATA CACHE {#drop-iceberg-metadata-cache} +## SYSTEM DROP ICEBERG METADATA CACHE {#drop-iceberg-metadata-cache} 清除冰山元数据缓存。 -## DROP REPLICA {#drop-replica} +## SYSTEM DROP REPLICA {#drop-replica} 可以使用以下语法删除 `ReplicatedMergeTree` 表的死副本: @@ -113,14 +108,11 @@ SYSTEM DROP REPLICA 'replica_name'; SYSTEM DROP REPLICA 'replica_name' FROM ZKPATH '/path/to/table/in/zk'; ``` -查询将删除 ZooKeeper 中的 `ReplicatedMergeTree` 副本路径。这在副本已死亡并且其元数据无法通过 `DROP TABLE` 从 ZooKeeper 中删除(因为不再有该表)的情况下非常有用。它只会删除非活动/过期的副本,无法删除本地副本,请使用 `DROP TABLE` 来执行此操作。`DROP REPLICA` 不会删除任何表,也不会从磁盘中删除任何数据或元数据。 +查询将从 ZooKeeper 中移除 `ReplicatedMergeTree` 副本路径。 当副本死亡且其元数据无法通过 `DROP TABLE` 从 ZooKeeper 中移除(因为该表再也不存在)时,便是有用的。它只会删除非活动/过时的副本,并且无法删除本地副本,请使用 `DROP TABLE` 来处理。 `DROP REPLICA` 不会删除任何表,也不会从磁盘上移除任何数据或元数据。 -第一个删除 `database.table` 表的 `'replica_name'` 副本的元数据。 -第二个对数据库中所有复制表执行相同操作。 -第三个对本地服务器上所有复制表执行相同操作。 -第四个在删除所有其他副本后,有助于删除损坏副本的元数据。它要求显式指定表路径。它必须与在创建表时传递给 `ReplicatedMergeTree` 引擎的第一个参数相同。 +第一个将删除 `database.table` 表的 `'replica_name'` 副本元数据。 第二个对数据库中的所有复制表执行相同操作。 第三个对本地服务器上的所有复制表执行相同操作。 第四个用于在删除了表的所有其他副本时,移除死副本的元数据。它要求显式指定表路径。它必须与创建表时传递给 `ReplicatedMergeTree` 引擎的第一个参数相同。 -## DROP DATABASE REPLICA {#drop-database-replica} +## SYSTEM DROP DATABASE REPLICA {#drop-database-replica} 可以使用以下语法删除 `Replicated` 数据库的死副本: @@ -130,24 +122,21 @@ SYSTEM DROP DATABASE REPLICA 'replica_name' [FROM SHARD 'shard_name']; SYSTEM DROP DATABASE REPLICA 'replica_name' [FROM SHARD 'shard_name'] FROM ZKPATH '/path/to/table/in/zk'; ``` -类似于 `SYSTEM DROP REPLICA`,但在没有数据库来运行 `DROP DATABASE` 时,从 ZooKeeper 中删除 `Replicated` 数据库副本路径。请注意,它不会删除 `ReplicatedMergeTree` 副本(因此您可能需要 `SYSTEM DROP REPLICA`)。分片和副本名称是创建数据库时在 `Replicated` 引擎参数中指定的名称。这些名称也可以从 `system.clusters` 中的 `database_shard_name` 和 `database_replica_name` 列获取。如果缺少 `FROM SHARD` 子句,则 `replica_name` 必须是 `shard_name|replica_name` 格式的完整副本名称。 +与 `SYSTEM DROP REPLICA` 相似,但当没有数据库来运行 `DROP DATABASE` 时,从 ZooKeeper 中移除 `Replicated` 数据库副本路径。 请注意,它并不会移除 `ReplicatedMergeTree` 副本(所以您可能也需要 `SYSTEM DROP REPLICA`)。 分片和副本名称是创建数据库时在 `Replicated` 引擎参数中指定的名称。此外,这些名称可以从 `system.clusters` 中的 `database_shard_name` 和 `database_replica_name` 列中获得。如果缺少 `FROM SHARD` 子句,则 `replica_name` 必须是 `shard_name|replica_name` 格式的完整副本名称。 -## DROP UNCOMPRESSED CACHE {#drop-uncompressed-cache} +## SYSTEM DROP UNCOMPRESSED CACHE {#drop-uncompressed-cache} -清除未压缩数据缓存。 -未压缩数据缓存的启用/禁用通过查询/用户/配置文件级设置 [`use_uncompressed_cache`](../../operations/settings/settings.md#use_uncompressed_cache) 进行控制。 -其大小可以使用服务器级设置 [`uncompressed_cache_size`](../../operations/server-configuration-parameters/settings.md#uncompressed_cache_size) 进行配置。 +清除未压缩数据缓存。未压缩数据缓存通过查询/用户/配置文件级别设置 [`use_uncompressed_cache`](../../operations/settings/settings.md#use_uncompressed_cache) 启用/禁用。其大小可以通过服务器级别设置 [`uncompressed_cache_size`](../../operations/server-configuration-parameters/settings.md#uncompressed_cache_size) 进行配置。 -## DROP COMPILED EXPRESSION CACHE {#drop-compiled-expression-cache} +## SYSTEM DROP COMPILED EXPRESSION CACHE {#drop-compiled-expression-cache} -清除编译表达式缓存。 -编译表达式缓存的启用/禁用通过查询/用户/配置文件级设置 [`compile_expressions`](../../operations/settings/settings.md#compile_expressions) 进行控制。 +清除编译表达式缓存。 编译表达式缓存通过查询/用户/配置文件级别设置 [`compile_expressions`](../../operations/settings/settings.md#compile_expressions) 启用/禁用。 -## DROP QUERY CONDITION CACHE {#drop-query-condition-cache} +## SYSTEM DROP QUERY CONDITION CACHE {#drop-query-condition-cache} 清除查询条件缓存。 -## DROP QUERY CACHE {#drop-query-cache} +## SYSTEM DROP QUERY CACHE {#drop-query-cache} ```sql SYSTEM DROP QUERY CACHE; @@ -157,22 +146,22 @@ SYSTEM DROP QUERY CACHE TAG '' Clears the [query cache](../../operations/query-cache.md). If a tag is specified, only query cache entries with the specified tag are deleted. -## DROP FORMAT SCHEMA CACHE {#system-drop-schema-format} +## SYSTEM DROP FORMAT SCHEMA CACHE {#system-drop-schema-format} Clears cache for schemas loaded from [`format_schema_path`](../../operations/server-configuration-parameters/settings.md#format_schema_path). -Supported formats: - -- Protobuf +Supported targets: +- Protobuf: Removes imported Protobuf message definitions from memory. +- Files: Deletes cached schema files stored locally in the [`format_schema_path`](../../operations/server-configuration-parameters/settings.md#format_schema_path), generated when `format_schema_source` is set to `query`. +Note: If no target is specified, both caches are cleared. ```sql -SYSTEM DROP FORMAT SCHEMA CACHE [FOR Protobuf] +SYSTEM DROP FORMAT SCHEMA CACHE [FOR Protobuf/Files] ``` -## FLUSH LOGS {#flush-logs} +## SYSTEM FLUSH LOGS {#flush-logs} -将缓冲的日志消息刷新到系统表,例如 system.query_log。主要用于调试,因为大多数系统表的默认刷新间隔为 7.5 秒。 -即使消息队列为空,这也将创建系统表。 +将缓冲的日志消息刷新到系统表,例如 system.query_log。 主要用于调试,因为大多数系统表的默认刷新间隔为 7.5 秒。即使消息队列为空,这也将创建系统表。 ```sql SYSTEM FLUSH LOGS [ON CLUSTER cluster_name] [log_name|[database.table]] [, ...] @@ -184,73 +173,73 @@ SYSTEM FLUSH LOGS [ON CLUSTER cluster_name] [log_name|[database.table]] [, ...] SYSTEM FLUSH LOGS query_log, system.query_views_log; ``` -## RELOAD CONFIG {#reload-config} +## SYSTEM RELOAD CONFIG {#reload-config} -重新加载 ClickHouse 配置。用于在配置存储在 ZooKeeper 中时。请注意,`SYSTEM RELOAD CONFIG` 不会重新加载存储在 ZooKeeper 中的 `USER` 配置,它只会重新加载存储在 `users.xml` 中的 `USER` 配置。要重新加载所有 `USER` 配置,请使用 `SYSTEM RELOAD USERS` +重新加载 ClickHouse 配置。 当配置存储在 ZooKeeper 中时使用。 注意 `SYSTEM RELOAD CONFIG` 不会重新加载存储在 ZooKeeper 中的 `USER` 配置,它只会重新加载存储在 `users.xml` 中的 `USER` 配置。要重新加载所有 `USER` 配置,请使用 `SYSTEM RELOAD USERS` ```sql SYSTEM RELOAD CONFIG [ON CLUSTER cluster_name] ``` -## RELOAD USERS {#reload-users} +## SYSTEM RELOAD USERS {#reload-users} -重新加载所有访问存储,包括:users.xml、本地磁盘访问存储、复制(在 ZooKeeper 中)访问存储。 +重新加载所有访问存储,包括: users.xml、本地磁盘访问存储、在 ZooKeeper 中复制的访问存储。 ```sql SYSTEM RELOAD USERS [ON CLUSTER cluster_name] ``` -## SHUTDOWN {#shutdown} +## SYSTEM SHUTDOWN {#shutdown} -通常关闭 ClickHouse(如 `service clickhouse-server stop` / `kill {$pid_clickhouse-server}`) +正常关闭 ClickHouse(如 `service clickhouse-server stop` / `kill {$pid_clickhouse-server}`) -## KILL {#kill} +## SYSTEM KILL {#kill} -中止 ClickHouse 进程(如 `kill -9 {$ pid_clickhouse-server}`) +中止 ClickHouse 进程(如 `kill -9 {$pid_clickhouse-server}`) -## 管理分布式表 {#managing-distributed-tables} +## Managing Distributed Tables {#managing-distributed-tables} -ClickHouse 可以管理 [distributed](../../engines/table-engines/special/distributed.md) 表。用户将数据插入这些表时,ClickHouse 首先创建一个应发送到集群节点的数据队列,然后异步发送。您可以通过 [`STOP DISTRIBUTED SENDS`](#stop-distributed-sends)、[FLUSH DISTRIBUTED](#flush-distributed) 和 [`START DISTRIBUTED SENDS`](#start-distributed-sends) 查询来管理队列处理。您还可以通过 [`distributed_foreground_insert`](../../operations/settings/settings.md#distributed_foreground_insert) 设置同步插入分布式数据。 +ClickHouse 可以管理 [分布式](../../engines/table-engines/special/distributed.md) 表。当用户向这些表插入数据时,ClickHouse 首先创建一个待发送到集群节点的数据队列,然后异步发送数据。可以使用 [`STOP DISTRIBUTED SENDS`](#stop-distributed-sends)、[FLUSH DISTRIBUTED](#flush-distributed) 和 [`START DISTRIBUTED SENDS`](#start-distributed-sends) 查询管理队列处理。您还可以使用 [`distributed_foreground_insert`](../../operations/settings/settings.md#distributed_foreground_insert) 设置同步插入分布式数据。 -### STOP DISTRIBUTED SENDS {#stop-distributed-sends} +### SYSTEM STOP DISTRIBUTED SENDS {#stop-distributed-sends} -在向分布式表插入数据时,禁用后台数据分发。 +在插入数据到分布式表时,禁用后台数据分发。 ```sql SYSTEM STOP DISTRIBUTED SENDS [db.] [ON CLUSTER cluster_name] ``` -:::note -如果启用了 [`prefer_localhost_replica`](../../operations/settings/settings.md#prefer_localhost_replica)(默认情况下),数据仍会插入到本地分片。 +:::note +如果启用了 [`prefer_localhost_replica`](../../operations/settings/settings.md#prefer_localhost_replica)(默认),数据仍然将插入到本地分片。 ::: -### FLUSH DISTRIBUTED {#flush-distributed} +### SYSTEM FLUSH DISTRIBUTED {#flush-distributed} -强制 ClickHouse 同步发送数据到集群节点。如果任何节点不可用,ClickHouse 将引发异常并停止查询执行。您可以重试查询,直到它成功,所有节点重新上线后将会成功。 +强制 ClickHouse 同步发送数据到集群节点。如果任何节点不可用,ClickHouse 将抛出异常并停止查询执行。您可以在查询成功之前重试,直到所有节点重新上线。 -您还可以通过 `SETTINGS` 子句覆盖某些设置,这在避免某些临时限制时非常有用,例如 `max_concurrent_queries_for_all_users` 或 `max_memory_usage`。 +您也可以通过 `SETTINGS` 子句覆盖一些设置,这可能有助于避免某些临时限制,如 `max_concurrent_queries_for_all_users` 或 `max_memory_usage`。 ```sql SYSTEM FLUSH DISTRIBUTED [db.] [ON CLUSTER cluster_name] [SETTINGS ...] ``` -:::note -每个待处理块都以初始 INSERT 查询中的设置存储在磁盘中,因此有时您可能希望覆盖设置。 +:::note +每个待处理的块都以初始 INSERT 查询的设置存储在磁盘上,因此,有时您可能希望覆盖设置。 ::: -### START DISTRIBUTED SENDS {#start-distributed-sends} +### SYSTEM START DISTRIBUTED SENDS {#start-distributed-sends} -在向分布式表插入数据时,启用后台数据分发。 +在插入数据到分布式表时,启用后台数据分发。 ```sql SYSTEM START DISTRIBUTED SENDS [db.] [ON CLUSTER cluster_name] ``` -### STOP LISTEN {#stop-listen} +### SYSTEM STOP LISTEN {#stop-listen} -关闭套接字并优雅地终止与指定端口和协议的现有连接。 +关闭套接字并优雅地终止与指定协议的服务器上的现有连接。 但是,如果在 clickhouse-server 配置中未指定相应的协议设置,则此命令将无效。 @@ -258,168 +247,162 @@ SYSTEM START DISTRIBUTED SENDS [db.] [ON CLUSTER cluster SYSTEM STOP LISTEN [ON CLUSTER cluster_name] [QUERIES ALL | QUERIES DEFAULT | QUERIES CUSTOM | TCP | TCP WITH PROXY | TCP SECURE | HTTP | HTTPS | MYSQL | GRPC | POSTGRESQL | PROMETHEUS | CUSTOM 'protocol'] ``` -- 如果指定了 `CUSTOM 'protocol'` 修饰符,将停止在服务器配置的协议部分中定义的具有指定名称的自定义协议。 -- 如果指定了 `QUERIES ALL [EXCEPT .. [,..]]` 修饰符,则会停止所有协议,除非用 `EXCEPT` 子句指定。 -- 如果指定了 `QUERIES DEFAULT [EXCEPT .. [,..]]` 修饰符,则会停止所有默认协议,除非用 `EXCEPT` 子句指定。 -- 如果指定了 `QUERIES CUSTOM [EXCEPT .. [,..]]` 修饰符,则会停止所有自定义协议,除非用 `EXCEPT` 子句指定。 +- 如果指定了 `CUSTOM 'protocol'` 修饰符,则定义在服务器配置的协议部分中的自定义协议将被停止。 +- 如果指定了 `QUERIES ALL [EXCEPT .. [,..]]` 修饰符,则除非在 `EXCEPT` 子句中指定的协议之外停止所有协议。 +- 如果指定了 `QUERIES DEFAULT [EXCEPT .. [,..]]` 修饰符,则除非在 `EXCEPT` 子句中指定的协议之外停止所有默认协议。 +- 如果指定了 `QUERIES CUSTOM [EXCEPT .. [,..]]` 修饰符,则除非在 `EXCEPT` 子句中指定的协议之外停止所有自定义协议。 -### START LISTEN {#start-listen} +### SYSTEM START LISTEN {#start-listen} -允许在指定协议上建立新连接。 +允许在指定协议上建立新的连接。 -但是,如果在指定端口和协议上的服务器未使用 SYSTEM STOP LISTEN 命令停止,则此命令将无效。 +但是,如果在未使用 SYSTEM STOP LISTEN 命令停止指定端口和协议的服务器,则此命令将无效。 ```sql SYSTEM START LISTEN [ON CLUSTER cluster_name] [QUERIES ALL | QUERIES DEFAULT | QUERIES CUSTOM | TCP | TCP WITH PROXY | TCP SECURE | HTTP | HTTPS | MYSQL | GRPC | POSTGRESQL | PROMETHEUS | CUSTOM 'protocol'] ``` -## 管理 MergeTree 表 {#managing-mergetree-tables} +## Managing MergeTree Tables {#managing-mergetree-tables} -ClickHouse 可以管理 [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) 表中的后台过程。 +ClickHouse 可以管理 [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) 表中的后台处理进程。 -### STOP MERGES {#stop-merges} +### SYSTEM STOP MERGES {#stop-merges} -提供停止 MergeTree 系列表的后台合并的功能: +提供停止 MergeTree 系列表的后台合并的可能性: ```sql SYSTEM STOP MERGES [ON CLUSTER cluster_name] [ON VOLUME | [db.]merge_tree_family_table_name] ``` -:::note -`DETACH / ATTACH` 表将即使在所有 MergeTree 表的合并被停止的情况下,仍然为表开始后台合并。 +:::note +`DETACH / ATTACH` 表将即使在先前停止所有 MergeTree 表的合并时也会启动表的后台合并。 ::: -### START MERGES {#start-merges} +### SYSTEM START MERGES {#start-merges} -提供为 MergeTree 系列表启动后台合并的功能: +提供启动 MergeTree 系列表的后台合并的可能性: ```sql SYSTEM START MERGES [ON CLUSTER cluster_name] [ON VOLUME | [db.]merge_tree_family_table_name] ``` -### STOP TTL MERGES {#stop-ttl-merges} +### SYSTEM STOP TTL MERGES {#stop-ttl-merges} -提供停止根据 [TTL 表达式](../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-ttl) 删除 MergeTree 系列表中的旧数据的功能: -即使表不存在或表没有 MergeTree 引擎,也返回 `Ok.`。 当数据库不存在时返回错误: +提供停止 MergeTree 系列表根据 [TTL 表达式](../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-ttl) 背景删除旧数据的可能性:即使表不存在,也返回 `Ok.`。当数据库不存在时返回错误: ```sql SYSTEM STOP TTL MERGES [ON CLUSTER cluster_name] [[db.]merge_tree_family_table_name] ``` -### START TTL MERGES {#start-ttl-merges} +### SYSTEM START TTL MERGES {#start-ttl-merges} -提供启动根据 [TTL 表达式](../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-ttl) 删除 MergeTree 系列表中的旧数据的功能: -即使表不存在,也返回 `Ok.`。当数据库不存在时返回错误: +提供启动 MergeTree 系列表根据 [TTL 表达式](../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-ttl) 背景删除旧数据的可能性:即使表不存在也返回 `Ok.`。当数据库不存在时返回错误: ```sql SYSTEM START TTL MERGES [ON CLUSTER cluster_name] [[db.]merge_tree_family_table_name] ``` -### STOP MOVES {#stop-moves} +### SYSTEM STOP MOVES {#stop-moves} -提供停止根据 [TTL 表表达式与 TO VOLUME 或 TO DISK 子句](../../engines/table-engines/mergetree-family/mergetree.md#mergetree-table-ttl) 移动 MergeTree 系列表中的数据的功能: -即使表不存在,也返回 `Ok.`。当数据库不存在时返回错误: +提供停止 MergeTree 系列表根据 [TTL 表表达式与 TO VOLUME 或 TO DISK 子句](../../engines/table-engines/mergetree-family/mergetree.md#mergetree-table-ttl) 背景移动数据的可能性:即使表不存在也返回 `Ok.`。当数据库不存在时返回错误: ```sql SYSTEM STOP MOVES [ON CLUSTER cluster_name] [[db.]merge_tree_family_table_name] ``` -### START MOVES {#start-moves} +### SYSTEM START MOVES {#start-moves} -提供启动根据 [TTL 表表达式与 TO VOLUME 和 TO DISK 子句](../../engines/table-engines/mergetree-family/mergetree.md#mergetree-table-ttl) 移动 MergeTree 系列表中的数据的功能: -即使表不存在,也返回 `Ok.`。当数据库不存在时返回错误: +提供启动 MergeTree 系列表根据 [TTL 表表达式与 TO VOLUME 和 TO DISK 子句](../../engines/table-engines/mergetree-family/mergetree.md#mergetree-table-ttl) 背景移动数据的可能性:即使表不存在也返回 `Ok.`。当数据库不存在时返回错误: ```sql SYSTEM START MOVES [ON CLUSTER cluster_name] [[db.]merge_tree_family_table_name] ``` -### SYSTEM UNFREEZE {#query_language-system-unfreeze} +### SYSTEM SYSTEM UNFREEZE {#query_language-system-unfreeze} -从所有磁盘中清除具有指定名称的冻结备份。有关取消冻结单个部分的更多信息,请参见 [ALTER TABLE table_name UNFREEZE WITH NAME ](/sql-reference/statements/alter/partition#unfreeze-partition) +从所有磁盘中清除指定名称的冻结备份。有关解冻单独部分的更多信息,请参见 [ALTER TABLE table_name UNFREEZE WITH NAME](/sql-reference/statements/alter/partition#unfreeze-partition) ```sql SYSTEM UNFREEZE WITH NAME ``` -### WAIT LOADING PARTS {#wait-loading-parts} +### SYSTEM WAIT LOADING PARTS {#wait-loading-parts} -等待所有异步加载的表数据部分(过时的数据部分)加载完成。 +等待所有异步加载的表数据部分(过时数据部分)被加载完成。 ```sql SYSTEM WAIT LOADING PARTS [ON CLUSTER cluster_name] [db.]merge_tree_family_table_name ``` -## 管理 ReplicatedMergeTree 表 {#managing-replicatedmergetree-tables} +## Managing ReplicatedMergeTree Tables {#managing-replicatedmergetree-tables} -ClickHouse 可以管理 [ReplicatedMergeTree](/engines/table-engines/mergetree-family/replication) 表中的后台复制相关过程。 +ClickHouse 可以管理 [ReplicatedMergeTree](/engines/table-engines/mergetree-family/replication) 表中的与后台复制相关的进程。 -### STOP FETCHES {#stop-fetches} +### SYSTEM STOP FETCHES {#stop-fetches} -提供停止为 `ReplicatedMergeTree` 系列表的插入部分进行后台提取的功能: -无论表引擎如何,即使表或数据库不存在,也始终返回 `Ok.`。 +提供停止 `ReplicatedMergeTree` 系列表的插入部分的后台提取的可能性:无论表引擎如何,即使表或数据库不存在,始终返回 `Ok.`。 ```sql SYSTEM STOP FETCHES [ON CLUSTER cluster_name] [[db.]replicated_merge_tree_family_table_name] ``` -### START FETCHES {#start-fetches} +### SYSTEM START FETCHES {#start-fetches} -提供开始为 `ReplicatedMergeTree` 系列表的插入部分进行后台提取的功能: -无论表引擎如何,即使表或数据库不存在,也始终返回 `Ok.`。 +提供启动 `ReplicatedMergeTree` 系列表的插入部分的后台提取的可能性:无论表引擎如何,即使表或数据库不存在,始终返回 `Ok.`。 ```sql SYSTEM START FETCHES [ON CLUSTER cluster_name] [[db.]replicated_merge_tree_family_table_name] ``` -### STOP REPLICATED SENDS {#stop-replicated-sends} +### SYSTEM STOP REPLICATED SENDS {#stop-replicated-sends} -提供停止针对 `ReplicatedMergeTree` 系列表的新插入部分进行后台发送到集群中其他副本的功能: +提供停止 `ReplicatedMergeTree` 系列表的新插入部分以发送到集群中其他副本的后台发送的可能性: ```sql SYSTEM STOP REPLICATED SENDS [ON CLUSTER cluster_name] [[db.]replicated_merge_tree_family_table_name] ``` -### START REPLICATED SENDS {#start-replicated-sends} +### SYSTEM START REPLICATED SENDS {#start-replicated-sends} -提供开始针对 `ReplicatedMergeTree` 系列表的新插入部分进行后台发送到集群中其他副本的功能: +提供启动 `ReplicatedMergeTree` 系列表的新插入部分以发送到集群中其他副本的后台发送的可能性: ```sql SYSTEM START REPLICATED SENDS [ON CLUSTER cluster_name] [[db.]replicated_merge_tree_family_table_name] ``` -### STOP REPLICATION QUEUES {#stop-replication-queues} +### SYSTEM STOP REPLICATION QUEUES {#stop-replication-queues} -提供停止从存储在 Zookeeper 中的复制队列中提取后台提取任务的功能,适用于 `ReplicatedMergeTree` 系列表。可能的后台任务类型 - 合并、提取、变更、DDL 语句及其 ON CLUSTER 子句: +提供停止从存储在 ZooKeeper 中的复制队列中提取后台任务的可能性,适用于 `ReplicatedMergeTree` 系列表。可能的背景任务类型 - 合并、提取、变更、带有 ON CLUSTER 子句的 DDL 语句: ```sql SYSTEM STOP REPLICATION QUEUES [ON CLUSTER cluster_name] [[db.]replicated_merge_tree_family_table_name] ``` -### START REPLICATION QUEUES {#start-replication-queues} +### SYSTEM START REPLICATION QUEUES {#start-replication-queues} -提供启动从存储在 Zookeeper 中的复制队列中提取后台提取任务的功能,适用于 `ReplicatedMergeTree` 系列表。可能的后台任务类型 - 合并、提取、变更、DDL 语句及其 ON CLUSTER 子句: +提供启动从存储在 ZooKeeper 中的复制队列中提取后台任务的可能性,适用于 `ReplicatedMergeTree` 系列表。可能的背景任务类型 - 合并、提取、变更、带有 ON CLUSTER 子句的 DDL 语句: ```sql SYSTEM START REPLICATION QUEUES [ON CLUSTER cluster_name] [[db.]replicated_merge_tree_family_table_name] ``` -### STOP PULLING REPLICATION LOG {#stop-pulling-replication-log} +### SYSTEM STOP PULLING REPLICATION LOG {#stop-pulling-replication-log} -停止从 `ReplicatedMergeTree` 表中的复制日志加载新条目到复制队列。 +停止从 `ReplicatedMergeTree` 表的复制日志中加载新条目到复制队列。 ```sql SYSTEM STOP PULLING REPLICATION LOG [ON CLUSTER cluster_name] [[db.]replicated_merge_tree_family_table_name] ``` -### START PULLING REPLICATION LOG {#start-pulling-replication-log} +### SYSTEM START PULLING REPLICATION LOG {#start-pulling-replication-log} 取消 `SYSTEM STOP PULLING REPLICATION LOG`。 @@ -427,7 +410,7 @@ SYSTEM STOP PULLING REPLICATION LOG [ON CLUSTER cluster_name] [[db.]replicated_m SYSTEM START PULLING REPLICATION LOG [ON CLUSTER cluster_name] [[db.]replicated_merge_tree_family_table_name] ``` -### SYNC REPLICA {#sync-replica} +### SYSTEM SYNC REPLICA {#sync-replica} 等待 `ReplicatedMergeTree` 表与集群中的其他副本同步,但不超过 `receive_timeout` 秒。 @@ -435,52 +418,75 @@ SYSTEM START PULLING REPLICATION LOG [ON CLUSTER cluster_name] [[db.]replicated_ SYSTEM SYNC REPLICA [ON CLUSTER cluster_name] [db.]replicated_merge_tree_family_table_name [IF EXISTS] [STRICT | LIGHTWEIGHT [FROM 'srcReplica1'[, 'srcReplica2'[, ...]]] | PULL] ``` -运行此语句后,`[db.]replicated_merge_tree_family_table_name` 从通用复制日志获取命令到其自身的复制队列中,然后查询等待直至副本处理所有提取的命令。支持以下修饰符: +在运行此语句后,`[db.]replicated_merge_tree_family_table_name` 从共同的复制日志提取命令到其自己的复制队列,然后查询等待副本处理所有提取的命令。支持以下修饰符: -- 使用 `IF EXISTS`(自 25.6 版本以来可用),如果表不存在,则查询不会抛出错误。这在将新副本添加到集群时非常有用,当它已是集群配置的一部分,但仍在创建和同步表的过程中。 -- 如果指定了 `STRICT` 修饰符,则查询会等待复制队列变为空。如果不断有新条目出现在复制队列中,则 `STRICT` 版本可能永远不会成功。 -- 如果指定了 `LIGHTWEIGHT` 修饰符,则查询仅等待 `GET_PART`、`ATTACH_PART`、`DROP_RANGE`、`REPLACE_RANGE` 和 `DROP_PART` 条目被处理。 - 此外,LIGHTWEIGHT 修饰符支持一个可选的 FROM 'srcReplicas' 子句,其中 'srcReplicas' 是源副本名称的以逗号分隔的列表。该扩展允许通过仅关注源副本中发起的复制任务来实现更有针对性的同步。 -- 如果指定了 `PULL` 修饰符,则查询将从 ZooKeeper 中提取新的复制队列条目,但不等待任何处理。 +- 使用 `IF EXISTS`(自 25.6 起可用)时,如果表不存在,查询不会引发错误。 当向集群添加新副本时,这很有用,当它已经是集群配置的一部分,但仍处于创建和同步表的过程中。 +- 如果指定了 `STRICT` 修饰符,则查询会等待复制队列变为空。在新条目不断出现在复制队列的情况下,`STRICT` 版本可能永远不会成功。 +- 如果指定了 `LIGHTWEIGHT` 修饰符,查询仅等待 `GET_PART`、`ATTACH_PART`、`DROP_RANGE`、`REPLACE_RANGE` 和 `DROP_PART` 条目被处理。此外,LIGHTWEIGHT 修饰符支持可选的 FROM 'srcReplicas' 子句,其中 'srcReplicas' 是源副本名称的逗号分隔列表。此扩展允许更具针对性的同步,仅关注来自指定源副本的复制任务。 +- 如果指定了 `PULL` 修饰符,查询将从 ZooKeeper 提取新的复制队列条目,但不会等待任何处理。 ### SYNC DATABASE REPLICA {#sync-database-replica} -等待指定的 [replicated database](/engines/database-engines/replicated) 应用来自该数据库的 DDL 队列中的所有模式更改。 +等待指定的 [复制数据库](/engines/database-engines/replicated) 从该数据库的 DDL 队列应用所有模式更改。 -**语法** +**语法** ```sql SYSTEM SYNC DATABASE REPLICA replicated_database_name; ``` -### RESTART REPLICA {#restart-replica} +### SYSTEM RESTART REPLICA {#restart-replica} -提供重新初始化 `ReplicatedMergeTree` 表的 Zookeeper 会话状态的功能,将当前状态与 Zookeeper 作为真相源进行比较,如有必要,向 Zookeeper 队列添加任务。 -基于 ZooKeeper 数据的复制队列初始化的方式与 `ATTACH TABLE` 语句相同。在短时间内,表将无法执行任何操作。 +提供对 `ReplicatedMergeTree` 表重新初始化 Zookeeper 会话状态的可能性,将当前状态与 Zookeeper 作为真实数据源进行比较,如有必要,将任务添加到 Zookeeper 队列。基于 ZooKeeper 数据的复制队列初始化与 `ATTACH TABLE` 语句的过程相同。在短时间内,该表将无法进行任何操作。 ```sql SYSTEM RESTART REPLICA [ON CLUSTER cluster_name] [db.]replicated_merge_tree_family_table_name ``` -### RESTORE REPLICA {#restore-replica} +### SYSTEM RESTORE REPLICA {#restore-replica} -如果数据 [可能] 存在但 Zookeeper 元数据丢失,恢复一个副本。 +如果数据 [可能] 存在但 Zookeeper 元数据丢失,则恢复副本。 -仅在只读 `ReplicatedMergeTree` 表上有效。 +仅适用于只读的 `ReplicatedMergeTree` 表。 -在以下情况下,可以执行查询: +可能在以下情况下执行查询: -- ZooKeeper 根目录 `/` 丢失。 -- 副本路径 `/replicas` 丢失。 -- 单个副本路径 `/replicas/replica_name/` 丢失。 +- 丢失 ZooKeeper 根 `/`。 +- 丢失副本路径 `/replicas`。 +- 丢失单个副本路径 `/replicas/replica_name/`。 -副本附加本地找到的部分,并将有关它们的信息发送到 Zookeeper。 -在元数据丢失之前,副本上存在的部分不会从其他部分重新提取,如果未过时(因此副本恢复并不意味着重新下载所有数据)。 +副本附加本地找到的部分,并将其信息发送到 Zookeeper。在元数据丢失之前存在于副本的部分如果没有过期则不会从其他部分重新提取(因此副本恢复并不意味着通过网络重新下载所有数据)。 -:::note -所有状态的部分都移动到 `detached/` 文件夹。在数据丢失之前处于活动状态的部分(已提交)被附加。 +:::note +所有状态的部分移至 `detached/` 文件夹。在数据丢失之前处于活动状态(已提交)的部分将被附加。 ::: -**语法** +### SYSTEM RESTORE DATABASE REPLICA {#restore-database-replica} + +如果数据 [可能] 存在但 Zookeeper 元数据丢失,则恢复副本。 + +**语法** + +```sql +SYSTEM RESTORE DATABASE REPLICA repl_db [ON CLUSTER cluster] +``` + +**示例** + +```sql +CREATE DATABASE repl_db +ENGINE=Replicated("/clickhouse/repl_db", shard1, replica1); + +CREATE TABLE repl_db.test_table (n UInt32) +ENGINE = ReplicatedMergeTree +ORDER BY n PARTITION BY n % 10; + +-- zookeeper_delete_path("/clickhouse/repl_db", recursive=True) <- root loss. + +SYSTEM RESTORE DATABASE REPLICA repl_db; +``` + +**语法** + ```sql SYSTEM RESTORE REPLICA [db.]replicated_merge_tree_family_table_name [ON CLUSTER cluster_name] ``` @@ -493,7 +499,7 @@ SYSTEM RESTORE REPLICA [ON CLUSTER cluster_name] [db.]replicated_merge_tree_fami **示例** -在多个服务器上创建一个表。副本在 ZooKeeper 中的元数据丢失后,表将作为只读附加,因为元数据缺失。最后一个查询需要在每个副本上执行。 +在多台服务器上创建表。 在 ZooKeeper 中丢失副本的元数据后,缺少元数据的表将作为只读附加。最后的查询需要在每个副本上执行。 ```sql CREATE TABLE test(n UInt32) @@ -508,28 +514,28 @@ SYSTEM RESTART REPLICA test; SYSTEM RESTORE REPLICA test; ``` -另一种方法: +另一种方式: ```sql SYSTEM RESTORE REPLICA test ON CLUSTER cluster; ``` -### RESTART REPLICAS {#restart-replicas} +### SYSTEM RESTART REPLICAS {#restart-replicas} -提供重新初始化所有 `ReplicatedMergeTree` 表的 Zookeeper 会话状态的功能,将当前状态与 Zookeeper 作为真相源进行比较,如有必要,向 Zookeeper 队列添加任务。 +提供重新初始化所有 `ReplicatedMergeTree` 表的 Zookeeper 会话状态的可能性,将当前状态与 Zookeeper 作为真实数据源进行比较,如果需要,将任务添加到 Zookeeper 队列。 -### DROP FILESYSTEM CACHE {#drop-filesystem-cache} +### SYSTEM DROP FILESYSTEM CACHE {#drop-filesystem-cache} -允许删除文件系统缓存。 +允许丢弃文件系统缓存。 ```sql SYSTEM DROP FILESYSTEM CACHE [ON CLUSTER cluster_name] ``` -### SYNC FILE CACHE {#sync-file-cache} +### SYSTEM SYNC FILE CACHE {#sync-file-cache} -:::note -这非常繁重,且有滥用的潜力。 +:::note +这太重且可能被滥用。 ::: 将执行同步系统调用。 @@ -538,7 +544,7 @@ SYSTEM DROP FILESYSTEM CACHE [ON CLUSTER cluster_name] SYSTEM SYNC FILE CACHE [ON CLUSTER cluster_name] ``` -### LOAD PRIMARY KEY {#load-primary-key} +### SYSTEM LOAD PRIMARY KEY {#load-primary-key} 加载给定表或所有表的主键。 @@ -550,7 +556,7 @@ SYSTEM LOAD PRIMARY KEY [db.]name SYSTEM LOAD PRIMARY KEY ``` -### UNLOAD PRIMARY KEY {#unload-primary-key} +### SYSTEM UNLOAD PRIMARY KEY {#unload-primary-key} 卸载给定表或所有表的主键。 @@ -562,13 +568,13 @@ SYSTEM UNLOAD PRIMARY KEY [db.]name SYSTEM UNLOAD PRIMARY KEY ``` -## 管理可刷新的物化视图 {#refreshable-materialized-views} +## Managing Refreshable Materialized Views {#refreshable-materialized-views} -控制由 [可刷新的物化视图](../../sql-reference/statements/create/view.md#refreshable-materialized-view) 执行的后台任务的命令。 +控制 [可刷新的物化视图](../../sql-reference/statements/create/view.md#refreshable-materialized-view) 中的后台任务的命令。 -在使用它们时,请关注 [`system.view_refreshes`](../../operations/system-tables/view_refreshes.md)。 +在使用它们时,请注意 [`system.view_refreshes`](../../operations/system-tables/view_refreshes.md)。 -### REFRESH VIEW {#refresh-view} +### SYSTEM REFRESH VIEW {#refresh-view} 触发给定视图的立即非计划刷新。 @@ -576,39 +582,39 @@ SYSTEM UNLOAD PRIMARY KEY SYSTEM REFRESH VIEW [db.]name ``` -### REFRESH VIEW {#refresh-view-1} +### SYSTEM WAIT VIEW {#wait-view} -等待当前运行的刷新完成。如果刷新失败,则引发异常。如果没有刷新正在进行,则立即完成,如果之前的刷新失败则抛出异常。 +等待当前正在进行的刷新完成。如果刷新失败,将抛出异常。如果没有刷新正在进行,立即完成,如果先前的刷新失败则抛出异常。 -### STOP [REPLICATED] VIEW, STOP VIEWS {#stop-view-stop-views} +### SYSTEM STOP [REPLICATED] VIEW, STOP VIEWS {#stop-view-stop-views} -禁用给定视图或所有可刷新的视图的定期刷新。如果刷新正在进行,则也取消该刷新。 +禁用给定视图或所有可刷新的视图的定期刷新。 如果刷新正在进行,也取消它。 -如果视图在 Replicated 或 Shared 数据库中,`STOP VIEW` 仅影响当前副本,而 `STOP REPLICATED VIEW` 影响所有副本。 +如果视图位于复制或共享数据库中,`STOP VIEW` 仅影响当前副本,而 `STOP REPLICATED VIEW` 影响所有副本。 ```sql SYSTEM STOP VIEW [db.]name -``` +``` ```sql SYSTEM STOP VIEWS ``` -### START [REPLICATED] VIEW, START VIEWS {#start-view-start-views} +### SYSTEM START [REPLICATED] VIEW, START VIEWS {#start-view-start-views} -启用给定视图或所有可刷新的视图的定期刷新。不会触发立即刷新。 +启用给定视图或所有可刷新的视图的定期刷新。 不会触发立即刷新。 -如果视图在 Replicated 或 Shared 数据库中,`START VIEW` 撤消 `STOP VIEW` 的效果,`START REPLICATED VIEW` 撤消 `STOP REPLICATED VIEW` 的效果。 +如果视图位于复制或共享数据库中,`START VIEW` 会恢复 `STOP VIEW` 的效果,而 `START REPLICATED VIEW` 会恢复 `STOP REPLICATED VIEW` 的效果。 ```sql SYSTEM START VIEW [db.]name -``` +``` ```sql SYSTEM START VIEWS ``` -### CANCEL VIEW {#cancel-view} +### SYSTEM CANCEL VIEW {#cancel-view} -如果当前副本的给定视图上正在进行刷新,请中断并取消它。否则不进行任何操作。 +如果当前副本的给定视图正在进行刷新,则中断并取消它。 否则不执行任何操作。 ```sql SYSTEM CANCEL VIEW [db.]name @@ -616,11 +622,11 @@ SYSTEM CANCEL VIEW [db.]name ### SYSTEM WAIT VIEW {#system-wait-view} -等待正在进行的刷新完成。如果没有刷新正在进行,则立即返回。如果最新的刷新尝试失败,则报告错误。 +等待正在进行的刷新完成。如果没有刷新正在进行,即时返回。如果最近的刷新尝试失败,报告错误。 -可以在创建新可刷新的物化视图(不带 EMPTY 关键字)后立即使用,以等待初始刷新的完成。 +可以在创建新的可刷新的物化视图(不带 EMPTY 关键字)后立即使用,等待初始刷新完成。 -如果视图在 Replicated 或 Shared 数据库中,且刷新在其他副本上进行,则等待该刷新完成。 +如果视图位于复制或共享数据库中,并且刷新在另一个副本上运行,则等待该刷新完成。 ```sql SYSTEM WAIT VIEW [db.]name diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/system.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/system.md.hash index 459587d9cb8..f3bd0b7f00e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/system.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/system.md.hash @@ -1 +1 @@ -001385eadadbe37f +22ba514990469ef0 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/truncate.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/truncate.md index 69c67031c6b..4afb9e350f6 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/truncate.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/truncate.md @@ -4,42 +4,70 @@ 'sidebar_position': 52 'slug': '/sql-reference/statements/truncate' 'title': 'TRUNCATE 语句' +'doc_type': 'reference' --- # TRUNCATE 语句 +ClickHouse 中的 `TRUNCATE` 语句用于快速删除表或数据库中的所有数据,同时保留其结构。 + ## TRUNCATE TABLE {#truncate-table} ```sql -TRUNCATE TABLE [IF EXISTS] [db.]name [ON CLUSTER cluster] +TRUNCATE TABLE [IF EXISTS] [db.]name [ON CLUSTER cluster] [SYNC] ``` +
+| 参数 | 描述 | +|------------------------|------------------------------------------------------------------------------------------------| +| `IF EXISTS` | 如果表不存在,则防止出现错误。如果省略,则查询返回错误。 | +| `db.name` | 可选的数据库名称。 | +| `ON CLUSTER cluster` | 在指定的集群中运行该命令。 | +| `SYNC` | 在使用复制表时,使得在副本中的截断操作同步。如果省略,默认情况下截断是异步进行的。 | -从表中删除所有数据。当省略 `IF EXISTS` 子句时,如果表不存在,查询将返回错误。 - -`TRUNCATE` 查询不支持 [View](../../engines/table-engines/special/view.md)、[File](../../engines/table-engines/special/file.md)、[URL](../../engines/table-engines/special/url.md)、[Buffer](../../engines/table-engines/special/buffer.md) 和 [Null](../../engines/table-engines/special/null.md) 表引擎。 - -您可以使用 [alter_sync](/operations/settings/settings#alter_sync) 设置来配置等待在副本上执行的操作。 +您可以使用 [alter_sync](/operations/settings/settings#alter_sync) 设置来设置等待在副本上执行的操作。 -您可以通过 [replication_wait_for_inactive_replica_timeout](/operations/settings/settings#replication_wait_for_inactive_replica_timeout) 设置来指定等待非活动副本执行 `TRUNCATE` 查询的时间(以秒为单位)。 +您可以使用 [replication_wait_for_inactive_replica_timeout](/operations/settings/settings#replication_wait_for_inactive_replica_timeout) 设置来指定等待非活动副本执行 `TRUNCATE` 查询的时间(以秒为单位)。 :::note -如果 `alter_sync` 设置为 `2` 并且某些副本超出了 `replication_wait_for_inactive_replica_timeout` 设置指定的时间而不活动,则会抛出异常 `UNFINISHED`。 +如果 `alter_sync` 设置为 `2`,并且某些副本在超过 `replication_wait_for_inactive_replica_timeout` 设置指定的时间后仍未激活,则抛出异常 `UNFINISHED`。 ::: +`TRUNCATE TABLE` 查询对以下表引擎 **不支持**: + +- [`View`](../../engines/table-engines/special/view.md) +- [`File`](../../engines/table-engines/special/file.md) +- [`URL`](../../engines/table-engines/special/url.md) +- [`Buffer`](../../engines/table-engines/special/buffer.md) +- [`Null`](../../engines/table-engines/special/null.md) + ## TRUNCATE ALL TABLES {#truncate-all-tables} ```sql TRUNCATE [ALL] TABLES FROM [IF EXISTS] db [LIKE | ILIKE | NOT LIKE ''] [ON CLUSTER cluster] ``` +
+| 参数 | 描述 | +|------------------------------|------------------------------------------------| +| `ALL` | 从数据库中的所有表中移除数据。 | +| `IF EXISTS` | 如果数据库不存在,则防止出现错误。 | +| `db` | 数据库名称。 | +| `LIKE \| ILIKE \| NOT LIKE ''` | 根据模式过滤表。 | +| `ON CLUSTER cluster` | 在集群中运行该命令。 | -从数据库中的所有表中删除所有数据。 +从数据库中的所有表中移除所有数据。 ## TRUNCATE DATABASE {#truncate-database} ```sql TRUNCATE DATABASE [IF EXISTS] db [ON CLUSTER cluster] ``` +
+| 参数 | 描述 | +|--------------------------|------------------------------------------------| +| `IF EXISTS` | 如果数据库不存在,则防止出现错误。 | +| `db` | 数据库名称。 | +| `ON CLUSTER cluster` | 在指定的集群中运行该命令。 | -从数据库中删除所有表,但保留数据库本身。当省略 `IF EXISTS` 子句时,如果数据库不存在,查询将返回错误。 +从数据库中移除所有表但保留数据库本身。当省略 `IF EXISTS` 子句时,如果数据库不存在,则查询返回错误。 :::note -`TRUNCATE DATABASE` 不支持 `Replicated` 数据库。要么使用 `DROP` 和 `CREATE` 来处理数据库。 +`TRUNCATE DATABASE` 不支持 `Replicated` 数据库。相反,可以直接 `DROP` 和 `CREATE` 数据库。 ::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/truncate.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/truncate.md.hash index c1ac3b8ea70..34d0958ad61 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/truncate.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/truncate.md.hash @@ -1 +1 @@ -fde97da1659286cc +6e538ddfa7d416ff diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/undrop.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/undrop.md index 63fcdce1bff..c51b2ad1ea2 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/undrop.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/undrop.md @@ -3,16 +3,17 @@ 'sidebar_label': 'UNDROP' 'slug': '/sql-reference/statements/undrop' 'title': 'UNDROP TABLE' +'doc_type': 'reference' --- # UNDROP TABLE -取消对表的删除。 +取消删除表。 -从 ClickHouse 版本 23.3 开始,可以在发出 DROP TABLE 语句后的 `database_atomic_delay_before_drop_table_sec`(默认情况下为 8 分钟)内对 Atomic 数据库中的表进行 UNDROP。被删除的表会列在名为 `system.dropped_tables` 的系统表中。 +从 ClickHouse 版本 23.3 开始,可以在发出 DROP TABLE 语句后的 `database_atomic_delay_before_drop_table_sec`(默认情况下为 8 分钟)内在原子数据库中 UNDROP 表。被删除的表会在一个名为 `system.dropped_tables` 的系统表中列出。 -如果您有一个没有 `TO` 子句与被删除表关联的物化视图,那么您还需要 UNDROP 那个视图的内部表。 +如果您有一个与被删除表相关联且没有 `TO` 子句的物化视图,则您还必须 UNDROP 那个视图的内部表。 :::tip 另请参见 [DROP TABLE](/sql-reference/statements/drop.md) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/undrop.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/undrop.md.hash index b32f53ba316..b2556d24d27 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/undrop.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/undrop.md.hash @@ -1 +1 @@ -2b0fcef78930c2ee +f3643dd8001ce4f9 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/update.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/update.md new file mode 100644 index 00000000000..b39d96f7686 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/update.md @@ -0,0 +1,126 @@ +--- +'description': '轻量级更新简化了使用分区片段在数据库中更新数据的过程。' +'keywords': +- 'update' +'sidebar_label': 'UPDATE' +'sidebar_position': 39 +'slug': '/sql-reference/statements/update' +'title': '轻量级 UPDATE 语句' +'doc_type': 'reference' +--- + +import BetaBadge from '@theme/badges/BetaBadge'; + + + +:::note +轻量级更新目前处于测试阶段。 +如果遇到问题,请在 [ClickHouse 仓库](https://github.com/clickhouse/clickhouse/issues) 中提起问题。 +::: + +轻量级 `UPDATE` 语句更新与表达式 `filter_expr` 匹配的表 `[db.]table` 中的行。 +之所以称为“轻量级更新”,是为了与 [`ALTER TABLE ... UPDATE`](/sql-reference/statements/alter/update) 查询进行对比,后者是一个重型过程,重写数据部分中的整个列。 +它仅适用于 [`MergeTree`](/engines/table-engines/mergetree-family/mergetree) 表引擎系列。 + +```sql +UPDATE [db.]table [ON CLUSTER cluster] SET column1 = expr1 [, ...] [IN PARTITION partition_expr] WHERE filter_expr; +``` + +`filter_expr` 必须为 `UInt8` 类型。该查询将指定列的值更新为 `filter_expr` 值为非零值的行中对应表达式的值。 +使用 `CAST` 操作符将值转换为列类型。更新用于计算主键或分区键的列是不支持的。 + +## 示例 {#examples} + +```sql +UPDATE hits SET Title = 'Updated Title' WHERE EventDate = today(); + +UPDATE wikistat SET hits = hits + 1, time = now() WHERE path = 'ClickHouse'; +``` + +## 轻量级更新不会立即更新数据 {#lightweight-update-does-not-update-data-immediately} + +轻量级 `UPDATE` 是通过 **patch parts** 实现的 - 一种仅包含更新列和行的特殊数据部分。 +轻量级 `UPDATE` 创建补丁部分,但不会立即在存储中物理修改原始数据。 +更新过程类似于 `INSERT ... SELECT ...` 查询,但 `UPDATE` 查询在返回之前等待补丁部分创建完成。 + +更新的值是: +- **立即可见** 通过补丁应用的 `SELECT` 查询 +- **物理具现** 仅在后续的合并和变更过程中 +- **自动清理** 一旦所有活动部分已经应用补丁 + +## 轻量级更新要求 {#lightweight-update-requirements} + +轻量级更新支持 [`MergeTree`](/engines/table-engines/mergetree-family/mergetree)、[`ReplacingMergeTree`](/engines/table-engines/mergetree-family/replacingmergetree)、[`CollapsingMergeTree`](/engines/table-engines/mergetree-family/collapsingmergetree) 引擎及其 [`Replicated`](/engines/table-engines/mergetree-family/replication.md) 和 [`Shared`](/cloud/reference/shared-merge-tree) 版本。 + +要使用轻量级更新,必须通过表设置 [`enable_block_number_column`](/operations/settings/merge-tree-settings#enable_block_number_column) 和 [`enable_block_offset_column`](/operations/settings/merge-tree-settings#enable_block_offset_column) 启用 `_block_number` 和 `_block_offset` 列的具现化。 + +## 轻量级删除 {#lightweight-delete} + +可以将 [轻量级 `DELETE`](/sql-reference/statements/delete) 查询作为轻量级 `UPDATE` 运行,而不是 `ALTER UPDATE` 变更。轻量级 `DELETE` 的实现由设置 [`lightweight_delete_mode`](/operations/settings/settings#lightweight_delete_mode) 控制。 + +## 性能考虑 {#performance-considerations} + +**轻量级更新的优点:** +- 更新的延迟与 `INSERT ... SELECT ...` 查询的延迟相当 +- 仅写入更新的列和值,而不是数据部分中的整个列 +- 无需等待当前正在运行的合并/变更完成,因此更新的延迟是可预测的 +- 可能并行执行轻量级更新 + +**潜在的性能影响:** +- 为需要应用补丁的 `SELECT` 查询添加额外开销 +- [跳过索引](/engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-data_skipping-indexes) 将不适用于数据部分中需要应用补丁的列。如果表中存在补丁部分,则 [投影](/engines/table-engines/mergetree-family/mergetree.md/#projections) 将不被使用,包括数据部分中没有需要应用补丁的部分。 +- 频繁的小更新可能导致“部分过多”错误。建议将多个更新批量成一个单独的查询,例如将更新的 ids 放在 `WHERE` 子句中的单个 `IN` 子句中 +- 轻量级更新旨在更新少量行(最多约 10% 的表)。如果需要更新较大数量,建议使用 [`ALTER TABLE ... UPDATE`](/sql-reference/statements/alter/update) 变更 + +## 并发操作 {#concurrent-operations} + +轻量级更新不同于重型变更,不需要等待当前运行的合并/变更完成。 +并发轻量级更新的一致性由设置 [`update_sequential_consistency`](/operations/settings/settings#update_sequential_consistency) 和 [`update_parallel_mode`](/operations/settings/settings#update_parallel_mode) 控制。 + +## 更新权限 {#update-permissions} + +`UPDATE` 需要 `ALTER UPDATE` 权限。要为特定用户启用特定表上的 `UPDATE` 语句,请运行: + +```sql +GRANT ALTER UPDATE ON db.table TO username; +``` + +## 实现细节 {#details-of-the-implementation} + +补丁部分与常规部分相同,但仅包含更新的列和几个系统列: +- `_part` - 原始部分的名称 +- `_part_offset` - 原始部分中的行号 +- `_block_number` - 原始部分中行的块编号 +- `_block_offset` - 原始部分中行的块偏移量 +- `_data_version` - 更新数据的数据版本(为 `UPDATE` 查询分配的块编号) + +平均而言,它在补丁部分中每更新行提供大约 40 字节(未压缩数据)的开销。 +系统列有助于找到原始部分中应该更新的行。 +系统列与原始部分中的 [虚拟列](/engines/table-engines/mergetree-family/mergetree.md/#virtual-columns) 相关,这些虚拟列在应应用补丁部分时添加以供读取。 +补丁部分按 `_part` 和 `_part_offset` 排序。 + +补丁部分属于与原始部分不同的分区。 +补丁部分的分区 ID 为 `patch-<补丁部分列名的哈希>-<原始分区 ID>`。 +因此,具有不同列的补丁部分存储在不同的分区中。 +例如,三个更新 `SET x = 1 WHERE `、`SET y = 1 WHERE ` 和 `SET x = 1, y = 1 WHERE ` 将在三个不同的分区中创建三个补丁部分。 + +补丁部分可以在它们之间合并,以减少 `SELECT` 查询中已应用补丁的数量并减少开销。补丁部分的合并使用 [替换](/engines/table-engines/mergetree-family/replacingmergetree) 合并算法,使用 `_data_version` 作为版本列。 +因此,补丁部分始终存储每个更新行在部分中的最新版本。 + +轻量级更新不等待当前运行的合并和变更完成,并始终使用数据部分的当前快照来执行更新并生成补丁部分。 +因此可以有两种情况应用补丁部分。 + +例如,如果我们读取部分 `A`,需要应用补丁部分 `X`: +- 如果 `X` 包含部分 `A` 本身。发生这种情况是因为当执行 `UPDATE` 时,`A` 并未参与合并。 +- 如果 `X` 包含部分 `B` 和 `C`,它们被部分 `A` 覆盖。这种情况发生在执行 `UPDATE` 时有一个合并(`B`、`C`)-> `A` 正在运行。 + +对于这两种情况,分别有两种方法应用补丁部分: +- 按照已排序列 `_part`、`_part_offset` 使用合并。 +- 按照 `_block_number`、`_block_offset` 列使用连接。 + +连接模式比合并模式慢,并需要更多内存,但使用频率较低。 + +## 相关内容 {#related-content} + +- [`ALTER UPDATE`](/sql-reference/statements/alter/update) - 重型 `UPDATE` 操作 +- [轻量级 `DELETE`](/sql-reference/statements/delete) - 轻量级 `DELETE` 操作 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/update.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/update.md.hash new file mode 100644 index 00000000000..28dcf088d44 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/update.md.hash @@ -0,0 +1 @@ +f049347d2451ab56 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/use.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/use.md index f7c7c2906c1..c15b35049da 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/use.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/use.md @@ -1,20 +1,21 @@ --- -'description': 'USE 语句的文档' +'description': '文档关于 USE 语句' 'sidebar_label': 'USE' 'sidebar_position': 53 'slug': '/sql-reference/statements/use' 'title': 'USE 语句' +'doc_type': 'reference' --- # USE 语句 ```sql -USE db +USE [DATABASE] db ``` 允许您为会话设置当前数据库。 -当前数据库用于在查询中未通过点在表名前明确定义数据库时搜索表。 +当前数据库用于查找表,如果在查询中未通过点在表名前显式定义数据库。 -当使用 HTTP 协议时,无法执行此查询,因为没有会话的概念。 +使用 HTTP 协议时无法执行此查询,因为没有会话的概念。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/use.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/use.md.hash index e2f3006b29f..ed039bdd267 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/use.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/use.md.hash @@ -1 +1 @@ -d8c722b197797484 +257900d1d8d39f58 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/watch.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/watch.md index edaac6543a8..560d2fadcec 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/watch.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/watch.md @@ -4,6 +4,7 @@ 'sidebar_position': 53 'slug': '/sql-reference/statements/watch' 'title': 'WATCH 语句' +'doc_type': 'reference' --- import DeprecatedBadge from '@theme/badges/DeprecatedBadge'; @@ -13,6 +14,6 @@ import DeprecatedBadge from '@theme/badges/DeprecatedBadge'; -此功能已被弃用,将在将来移除。 +此功能已被弃用,并将在未来移除。 -为方便起见,旧文档位于 [这里](https://pastila.nl/?007cd3ec/47276db1eb25eb10c6ee043a44fdf597#AESDirdloBX4wF5BjPSZSA==) +为了您的方便,旧文档位于 [这里](https://pastila.nl/?007cd3ec/47276db1eb25eb10c6ee043a44fdf597#AESDirdloBX4wF5BjPSZSA==) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/watch.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/watch.md.hash index 612f1dd486a..f848410bb5f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/watch.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/statements/watch.md.hash @@ -1 +1 @@ -5213c64c6b5be688 +371a9191b4c80f73 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/syntax.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/syntax.md index ceb27088eb2..db9616f48fa 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/syntax.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/syntax.md @@ -1,53 +1,53 @@ --- -'description': '语法的文档' +'description': 'Syntax 的文档' 'displayed_sidebar': 'sqlreference' 'sidebar_label': '语法' 'sidebar_position': 2 'slug': '/sql-reference/syntax' 'title': '语法' +'doc_type': 'reference' --- -在本节中,我们将查看 ClickHouse 的 SQL 语法。 -ClickHouse 使用基于 SQL 的语法,但提供了许多扩展和优化。 +在本节中,我们将查看 ClickHouse 的 SQL 语法。 +ClickHouse 使用基于 SQL 的语法,但提供了一些扩展和优化。 ## 查询解析 {#query-parsing} ClickHouse 中有两种类型的解析器: -- _全 SQL 解析器_(递归下降解析器)。 +- _完整 SQL 解析器_(递归下降解析器)。 - _数据格式解析器_(快速流解析器)。 -除 `INSERT` 查询外,所有情况下都使用全 SQL 解析器,`INSERT` 查询同时使用两个解析器。 +完整 SQL 解析器在所有情况下使用,除了 `INSERT` 查询,这种查询使用两种解析器。 -让我们检查下面的查询: +让我们查看下面的查询: ```sql INSERT INTO t VALUES (1, 'Hello, world'), (2, 'abc'), (3, 'def') ``` -如前所述,`INSERT` 查询使用了两个解析器。 -`INSERT INTO t VALUES` 片段由全解析器解析, -而数据 `(1, 'Hello, world'), (2, 'abc'), (3, 'def')` 则由数据格式解析器,即快速流解析器解析。 +如前所述,`INSERT` 查询使用了两种解析器。 +`INSERT INTO t VALUES` 片段由完整解析器解析, +数据 `(1, 'Hello, world'), (2, 'abc'), (3, 'def')` 则由数据格式解析器或快速流解析器解析。
-启用全解析器 +开启完整解析器 -您也可以通过使用 [`input_format_values_interpret_expressions`](../operations/settings/settings-formats.md#input_format_values_interpret_expressions) 设置来启用数据的全解析器。 +您还可以通过使用 [`input_format_values_interpret_expressions`](../operations/settings/settings-formats.md#input_format_values_interpret_expressions) 设置来为数据开启完整解析器。 -当上述设置为 `1` 时, -ClickHouse 首先尝试使用快速流解析器解析值。 -如果失败,ClickHouse 尝试对数据使用全解析器,将其视为 SQL [表达式](#expressions)。 +当上述设置设置为 `1` 时, +ClickHouse 首先尝试用快速流解析器解析值。 +如果失败,ClickHouse 尝试使用完整解析器解析数据,将其视作 SQL [表达式](#expressions)。
-数据可以具有任何格式。 -当接收到查询时,服务器在内存中计算请求的最多 [max_query_size](../operations/settings/settings.md#max_query_size) 字节 -(默认情况下为 1 MB),其余部分通过流解析。 -这是为了避免大 `INSERT` 查询可能出现的问题,这是推荐的向 ClickHouse 插入数据的方法。 +数据可以采用任何格式。 +当接收到查询时,服务器在 RAM 中计算请求不超过 [max_query_size](../operations/settings/settings.md#max_query_size) 字节(默认 1 MB),其余部分以流的形式进行解析。 +这样可以避免大 `INSERT` 查询的问题,这是在 ClickHouse 中插入数据的推荐方式。 -在 `INSERT` 查询中使用 [`Values`](../interfaces/formats.md/#data-format-values) 格式时, -看起来数据的解析方式与在 `SELECT` 查询中的表达式相同,但其实并非如此。 -`Values` 格式要有限得多。 +在 `INSERT` 查询中使用 [`Values`](../interfaces/formats.md/#data-format-values) 格式时, +数据解析似乎与 `SELECT` 查询中的表达式相同,但实际上并非如此。 +`Values` 格式的限制较多。 -该部分的其余内容涵盖全解析器。 +本节的其余部分讨论完整解析器。 :::note 有关格式解析器的更多信息,请参阅 [Formats](../interfaces/formats.md) 部分。 @@ -55,36 +55,36 @@ ClickHouse 首先尝试使用快速流解析器解析值。 ## 空格 {#spaces} -- 在语法结构之间(包括查询的开始和结束)可以有任意数量的空白符号。 -- 空白符号包括空格、制表符、换行符、回车符和换页符。 +- 在语法结构之间(包括查询的开头和结尾)可以有任意数量的空格符号。 +- 空格符号包括空格、制表符、换行符、回车符和换页符。 ## 注释 {#comments} ClickHouse 支持 SQL 风格和 C 风格的注释: -- SQL 风格的注释以 `--`、`#!` 或 `# ` 开头,并持续到行末。`--` 和 `#!` 后的空格可以省略。 -- C 风格的注释从 `/*` 到 `*/`,可以是多行的。也不需要空格。 +- SQL 风格的注释以 `--`、`#!` 或 `# ` 开始,并持续到行尾。在 `--` 和 `#!` 后面的空格可以省略。 +- C 风格的注释从 `/*` 到 `*/`,可以是多行的。空格也是不必要的。 -## 关键词 {#keywords} +## 关键字 {#keywords} -ClickHouse 中的关键词在上下文中可以是 _区分大小写_ 或 _不区分大小写_。 +ClickHouse 中的关键字可以是 _大小写敏感_ 或 _大小写不敏感_,这取决于上下文。 -当关键词对应于时,它们是 **不区分大小写** 的: +当关键字对应于以下内容时,它们是 **大小写不敏感** 的: - SQL 标准。例如,`SELECT`、`select` 和 `SeLeCt` 都是有效的。 -- 一些流行的 DBMS(MySQL 或 Postgres)中的实现。例如,`DateTime` 与 `datetime` 相同。 +- 一些流行的 DBMS(MySQL 或 Postgres)的实现。例如,`DateTime` 与 `datetime` 是相同的。 :::note -您可以在 [system.data_type_families](/operations/system-tables/data_type_families) 表中查看数据类型名称是否区分大小写。 +您可以在 [system.data_type_families](/operations/system-tables/data_type_families) 表中检查数据类型名称是否区分大小写。 ::: -与标准 SQL 相比,所有其他关键词(包括函数名称)都是 **区分大小写** 的。 +与标准 SQL 相比,其他所有关键字(包括函数名称)都是 **大小写敏感** 的。 -此外,关键词不是保留字。 -它们仅在相应的上下文中被视为保留字。 -如果您使用与关键词同名的 [标识符](#identifiers),请将它们用双引号或反引号括起来。 +此外,关键字不是保留的。 +它们只在相应的上下文中被视为保留的。 +如果您使用与关键字同名的 [标识符](#identifiers),请将它们用双引号或反引号括起来。 -例如,如果表 `table_name` 有一个名称为 `"FROM"` 的列,以下查询是有效的: +例如,如果表 `table_name` 有一个名为 `"FROM"` 的列,则以下查询是有效的: ```sql SELECT "FROM" FROM table_name @@ -92,143 +92,143 @@ SELECT "FROM" FROM table_name ## 标识符 {#identifiers} -标识符是: +标识符包括: -- 集群、数据库、表、分区和列名称。 +- 集群、数据库、表、分区和列名。 - [函数](#functions)。 - [数据类型](../sql-reference/data-types/index.md)。 - [表达式别名](#expression-aliases)。 -标识符可以是带引号的或不带引号的,尽管后者更可取。 +标识符可以是带引号的或不带引号的,尽管后者更为推荐。 -不带引号的标识符必须匹配正则表达式 `^[a-zA-Z_][0-9a-zA-Z_]*$`,并且不能等于 [关键词](#keywords)。 -请参阅下表以查看有效和无效标识符的示例: +不带引号的标识符必须匹配正则表达式 `^[a-zA-Z_][0-9a-zA-Z_]*$` 且不能等于 [关键字](#keywords)。 +下表举例说明了有效和无效的标识符: -| 有效标识符 | 无效标识符 | -|----------------------------------------|------------------------------------| -| `xyz`、`_internal`、`Id_with_underscores_123_` | `1x`、`tom@gmail.com`、`äußerst_schön` | +| 有效标识符 | 无效标识符 | +|-------------------------------------------|----------------------------------| +| `xyz`,`_internal`,`Id_with_underscores_123_` | `1x`,`tom@gmail.com`,`äußerst_schön` | -如果您想使用与关键词相同的标识符或者想在标识符中使用其他符号,请使用双引号或反引号将其引起来,例如,`"id"`、`` `id` ``。 +如果您想使用与关键字相同的标识符或您想在标识符中使用其他符号,请用双引号或反引号括起来,例如,`"id"`,`` `id` ``。 :::note -对于带引号的标识符的转义规则同样适用于字符串文字。有关详细信息,请参见 [String](#string)。 +用于转义的相同规则也适用于字符串字面量。有关更多详细信息,请参见 [String](#string)。 ::: -## 文 literals {#literals} +## 字面量 {#literals} -在 ClickHouse 中,字面量是直接在查询中表示的值。 -换句话说,它是一个在查询执行过程中不改变的固定值。 +在 ClickHouse 中,字面量是直接在查询中表示的值。 +换句话说,它是一个在查询执行期间不变的固定值。 字面量可以是: - [字符串](#string) - [数字](#numeric) -- [复合型](#compound) +- [复合](#compound) - [`NULL`](#null) - [Heredocs](#heredoc)(自定义字符串字面量) -我们将在下面的部分中更详细地查看每一个。 +我们将在下面的各节中详细查看这些内容。 ### 字符串 {#string} 字符串字面量必须用单引号括起来。不支持双引号。 -转义方式为: +转义可通过以下任一方式进行: -- 使用前单引号,单引号字符 `'`(仅此字符)可以转义为 `''`,或 -- 使用前反斜杠,并结合下面列出的支持的转义序列。 +- 使用前导单引号,其中单引号字符 `'`(仅此字符)可以转义为 `''`,或 +- 使用前导反斜杠与下表中列出的支持的转义序列。 :::note -反斜杠失去其特殊含义,即如果它位于其他字符前,则被解释为字面意思。 +反斜杠失去了特殊含义,即如果它出现在下列字符之外,则被视为字面量。 ::: -| 支持的转义 | 描述 | -|---------------------------|------------------------------------------------------------------| -| `\xHH` | 后面跟任意数量十六进制数字 (H) 的 8 位字符规格。 | -| `\N` | 保留的,不执行任何操作(例如,`SELECT 'a\Nb'` 返回 `ab`) | -| `\a` | 警报 | -| `\b` | 退格 | -| `\e` | 转义字符 | -| `\f` | 换页符 | -| `\n` | 换行符 | -| `\r` | 回车符 | -| `\t` | 水平制表符 | -| `\v` | 垂直制表符 | -| `\0` | 空字符 | -| `\\` | 反斜杠 | -| `\'`(或 ` '' `) | 单引号 | -| `\"` | 双引号 | -| `` ` `` | 反引号 | -| `\/` | 斜杠 | -| `\=` | 等号 | -| ASCII 控制字符 (c <= 31)。 | | +| 支持的转义 | 描述 | +|-------------------------------------|-----------------------------------------------------------------------| +| `\xHH` | 8 位字符规格,后跟任意数量的十六进制数字 (H)。 | +| `\N` | 保留,不执行任何操作(例如 `SELECT 'a\Nb'` 返回 `ab`) | +| `\a` | 警报 | +| `\b` | 退格 | +| `\e` | 转义字符 | +| `\f` | 换页 | +| `\n` | 换行 | +| `\r` | 回车 | +| `\t` | 水平制表符 | +| `\v` | 垂直制表符 | +| `\0` | 空字符 | +| `\\` | 反斜杠 | +| `\'`(或 ` '' `) | 单引号 | +| `\"` | 双引号 | +| `` ` `` | 反引号 | +| `\/` | 斜杠 | +| `\=` | 等号 | +| ASCII 控制字符(c <= 31)。 | | :::note -在字符串字面量中,您需要使用转义码 `\'`(或:`''`)和 `\\` 转义至少 `'` 和 `\`。 +在字符串字面量中,您需要使用转义码 `\'`(或:`''`)和 `\\` 来转义至少 `'` 和 `\`。 ::: ### 数字 {#numeric} -数字字面量解析如下: +数字字面量的解析如下: -- 首先,作为 64 位有符号数,使用 [strtoull](https://en.cppreference.com/w/cpp/string/byte/strtoul) 函数。 -- 如果不成功,则作为 64 位无符号数,使用 [strtoll](https://en.cppreference.com/w/cpp/string/byte/strtol) 函数。 -- 如果仍然不成功,则作为浮点数,使用 [strtod](https://en.cppreference.com/w/cpp/string/byte/strtof) 函数。 +- 首先,作为 64 位带符号数字,使用 [strtoull](https://en.cppreference.com/w/cpp/string/byte/strtoul) 函数。 +- 如果失败,则作为 64 位无符号数字,使用 [strtoll](https://en.cppreference.com/w/cpp/string/byte/strtol) 函数。 +- 如果失败,则作为浮点数,使用 [strtod](https://en.cppreference.com/w/cpp/string/byte/strtof) 函数。 - 否则,返回错误。 -字面值将被转换为适合该值的最小类型。 +字面值会转换为最小的适合该值的类型。 例如: - `1` 被解析为 `UInt8` -- `256` 被解析为 `UInt16`。 +- `256` 被解析为 `UInt16`。 有关更多信息,请参见 [数据类型](../sql-reference/data-types/index.md)。 -数字字面量中的下划线 `_` 会被忽略,可以用于提高可读性。 +在数字字面量中的下划线 `_` 被忽略,可以用于更好的可读性。 -支持的数字字面量如下: +支持以下数字字面量: -| 数字字面量 | 示例 | -|-----------------------------------|------------------------------------------------| -| **整数** | `1`、`10_000_000`、`18446744073709551615`、`01` | -| **十进制** | `0.1` | -| **指数记法** | `1e100`、`-1e-100` | -| **浮点数** | `123.456`、`inf`、`nan` | -| **十六进制** | `0xc0fe` | -| **符合 SQL 标准的十六进制字符串** | `x'c0fe'` | -| **二进制** | `0b1101` | -| **符合 SQL 标准的二进制字符串** | `b'1101'` | +| 数字字面量 | 示例 | +|-------------------------------------------|-------------------------------------------------| +| **整数** | `1`,`10_000_000`,`18446744073709551615`,`01` | +| **小数** | `0.1` | +| **指数表示法** | `1e100`,`-1e-100` | +| **浮点数** | `123.456`,`inf`,`nan` | +| **十六进制** | `0xc0fe` | +| **与 SQL 标准兼容的十六进制字符串** | `x'c0fe'` | +| **二进制** | `0b1101` | +| **与 SQL 标准兼容的二进制字符串** | `b'1101'` | :::note -不支持八进制字面量以避免意外的解释错误。 +为了避免意外的解释错误,不支持八进制字面量。 ::: -### 复合型 {#compound} +### 复合 {#compound} -数组用方括号构造 `[1, 2, 3]`。元组用圆括号构造 `(1, 'Hello, world!', 2)`。 -从技术上讲,这些不是字面量,而是分别带有数组创建操作符和元组创建操作符的表达式。 -数组必须至少包含一个项目,元组必须至少有两个项目。 +数组用方括号构造 `[1, 2, 3]`。元组用圆括号构造 `(1, 'Hello, world!', 2)`。 +从技术上讲,这些并不是字面量,而是分别使用数组创建运算符和元组创建运算符的表达式。 +数组必须至少包含一个元素,元组必须至少包含两个元素。 :::note -在 `SELECT` 查询的 `IN` 子句中出现元组时有一种特殊情况。 -查询结果可以包括元组,但元组不能保存到数据库(使用 [Memory](../engines/table-engines/special/memory.md) 引擎的表除外)。 +元组在 `SELECT` 查询的 `IN` 子句中出现时,有一个单独的情况。 +查询结果可以包括元组,但元组不能保存到数据库中(使用 [Memory](../engines/table-engines/special/memory.md) 引擎的表除外)。 ::: ### NULL {#null} -`NULL` 用于指示值缺失。 -要在表字段中存储 `NULL`,该字段必须属于 [Nullable](../sql-reference/data-types/nullable.md) 类型。 +`NULL` 用于表示一个值缺失。 +要在表字段中存储 `NULL`,该字段必须是 [Nullable](../sql-reference/data-types/nullable.md) 类型。 :::note -关于 `NULL`,需要注意以下几点: +以下是关于 `NULL` 的一些注意事项: -- 根据数据格式(输入或输出),`NULL` 可能有不同的表示形式。有关更多信息,请参见 [数据格式](/interfaces/formats)。 -- `NULL` 的处理方式很微妙。例如,如果比较操作的至少一个参数是 `NULL`,则该操作的结果也为 `NULL`。乘法、加法和其他操作也是如此。我们建议为每个操作阅读文档。 -- 在查询中,您可以使用 [`IS NULL`](/sql-reference/functions/functions-for-nulls#isnull) 和 [`IS NOT NULL`](/sql-reference/functions/functions-for-nulls#isnotnull) 操作符及相关函数 `isNull` 和 `isNotNull` 来检查 `NULL`。 +- 根据数据格式(输入或输出),`NULL` 可能有不同的表示。有关更多信息,请参见 [数据格式](/interfaces/formats)。 +- `NULL` 处理是复杂的。例如,如果比较操作的至少一个参数为 `NULL`,则该操作的结果也是 `NULL`。对于乘法、加法及其他操作也是如此。我们建议您查看每个操作的文档。 +- 在查询中,可以使用 [`IS NULL`](/sql-reference/functions/functions-for-nulls#isNull) 和 [`IS NOT NULL`](/sql-reference/functions/functions-for-nulls#isNotNull) 操作符以及相关函数 `isNull` 和 `isNotNull` 来检查 `NULL`。 ::: ### Heredoc {#heredoc} -[ heredoc ](https://en.wikipedia.org/wiki/Here_document) 是一种定义字符串(通常是多行),同时保持原始格式的方式。 -Heredoc 被定义为自定义字符串字面量,放置在两个 `$` 符号之间。 +[heredoc](https://en.wikipedia.org/wiki/Here_document) 是一种定义字符串(通常是多行),同时保持原始格式的方法。 +heredoc 被定义为一个自定义字符串字面量,放置在两个 `$` 符号之间。 例如: @@ -241,34 +241,34 @@ SELECT $heredoc$SHOW CREATE VIEW my_view$heredoc$; ``` :::note -- 在两个 heredocs 之间的值按原样处理。 +- 两个 heredoc 之间的值按原样处理。 ::: :::tip -- 您可以使用 heredoc 嵌入 SQL、HTML 或 XML 代码的片段等。 +- 您可以使用 heredoc 嵌入 SQL、HTML 或 XML 代码等片段。 ::: ## 定义和使用查询参数 {#defining-and-using-query-parameters} -查询参数允许您编写通用查询,包含抽象占位符而不是具体标识符。 -执行带有查询参数的查询时, -所有占位符都被解析并替换为实际的查询参数值。 +查询参数允许您编写包含抽象占位符而不是具体标识符的通用查询。 +当执行带有查询参数的查询时, +所有占位符都会被解析并替换为实际的查询参数值。 -有两种方法可以定义查询参数: +定义查询参数有两种方式: - `SET param_=` - `--param_=''` -使用第二种变体时,它作为参数传递给 `clickhouse-client`,命令行中的格式如下: -- `` 是查询参数的名称。 -- `` 是其值。 +使用第二种变体时,它作为参数传递给 `clickhouse-client` 命令行,其中: +- `` 为查询参数的名称。 +- `` 为其值。 -可以在查询中使用 `{: }` 引用查询参数,其中 `` 是查询参数名称,`` 是转换后的数据类型。 +在查询中可以使用 `{: }` 来引用查询参数,其中 `` 为查询参数名称,`` 为其转换类型。
使用 SET 命令的示例 -例如,以下 SQL 定义了名称为 `a`、`b`、`c` 和 `d` 的参数 - 每个参数具有不同的数据类型: +例如,下面的 SQL 定义了命名为 `a`、`b`、`c` 和 `d` 的参数 - 每个参数具有不同的数据类型: ```sql SET param_a = 13; @@ -289,7 +289,7 @@ SELECT
使用 clickhouse-client 的示例 -如果您使用 `clickhouse-client`,参数应指定为 `--param_name=value`。例如,以下参数名称为 `message`,并作为 `String` 检索: +如果您使用 `clickhouse-client`,参数的指定形式为 `--param_name=value`。例如,以下参数的名称为 `message`,并以 `String` 类型获取: ```bash clickhouse-client --param_message='hello' --query="SELECT {message: String}" @@ -297,7 +297,7 @@ clickhouse-client --param_message='hello' --query="SELECT {message: String}" hello ``` -如果查询参数表示数据库、表、函数或其他标识符的名称,请将其类型设置为 `Identifier`。例如,以下查询从名为 `uk_price_paid` 的表中返回行: +如果查询参数代表数据库、表、函数或其他标识符的名称,则使用 `Identifier` 作为其类型。例如,以下查询从名为 `uk_price_paid` 的表中返回行: ```sql SET param_mytablename = "uk_price_paid"; @@ -306,14 +306,14 @@ SELECT * FROM {mytablename:Identifier};
:::note -查询参数不是一般的文本替换,不能在任意 SQL 查询的任意位置使用。 -它们主要设计用于在 `SELECT` 语句中替换标识符或字面量。 +查询参数不是可以在任意 SQL 查询中任意位置使用的通用文本替换。 +它们主要旨在在 `SELECT` 语句中替代标识符或字面量。 ::: ## 函数 {#functions} -函数调用的写法与带有参数列表(可能为空)的标识符相同。 -与标准 SQL 不同的是,即使参数列表为空,括号也是必需的。 +函数调用的书写方式是像标识符一样,并在圆括号中列出参数(可能为空)。 +与标准 SQL 相比,即使参数列表为空,括号也是必需的。 例如: ```sql @@ -321,7 +321,7 @@ now() ``` 此外,还有: -- [普通函数](/sql-reference/functions/overview)。 +- [常规函数](/sql-reference/functions/overview)。 - [聚合函数](/sql-reference/aggregate-functions)。 某些聚合函数可以在括号中包含两个参数列表。例如: @@ -330,16 +330,16 @@ now() quantile (0.9)(x) ``` -这些聚合函数称为 "参数化" 函数, -第一个列表中的参数叫做 "参数"。 +这些聚合函数称为“参数化”函数, +而第一个列表中的参数称为“参数”。 :::note -不带参数的聚合函数的语法与普通函数的语法相同。 +没有参数的聚合函数的语法与常规函数相同。 ::: -## 操作符 {#operators} +## 运算符 {#operators} -操作符在查询解析过程中被转换为其对应的函数,考虑到优先级和结合性。 +运算符在查询解析期间会转换为相应的函数,同时考虑其优先级和结合性。 例如,表达式 @@ -347,7 +347,7 @@ quantile (0.9)(x) 1 + 2 * 3 + 4 ``` -被转换为 +被转化为 ```text plus(plus(1, multiply(2, 3)), 4)` @@ -355,8 +355,8 @@ plus(plus(1, multiply(2, 3)), 4)` ## 数据类型和数据库表引擎 {#data-types-and-database-table-engines} -在 `CREATE` 查询中,数据类型和表引擎的书写方式与标识符或函数相同。 -换句话说,它们可能包含也可能不包含参数列表。 +`CREATE` 查询中的数据类型和表引擎以与标识符或函数相同的方式书写。 +换句话说,它们可能包含也可能不包含括号中的参数列表。 有关更多信息,请参见以下部分: - [数据类型](/sql-reference/data-types/index.md) @@ -365,37 +365,40 @@ plus(plus(1, multiply(2, 3)), 4)` ## 表达式 {#expressions} -表达式可以是以下内容: -- 函数 -- 标识符 -- 字面量 -- 操作符的应用 -- 括号中的表达式 -- 子查询 -- 或星号。 +表达式可以是以下任意内容: +- 一个函数 +- 一个标识符 +- 一个字面量 +- 运算符的应用 +- 括号内的一个表达式 +- 一个子查询 +- 一个星号 -它也可以包含 [别名](#expression-aliases)。 +它也可以包含一个 [别名](#expression-aliases)。 -表达式列表是由一个或多个用逗号分隔的表达式。 -函数和操作符可以将表达式作为参数。 +表达式列表是一个或多个用逗号分隔的表达式。 +函数和运算符又可以有表达式作为参数。 + +恒定表达式是一个在查询分析期间结果已知的表达式,即在执行之前。 +例如,基于字面量的表达式是恒定表达式。 ## 表达式别名 {#expression-aliases} -别名是查询中为 [表达式](#expressions) 定义的用户自定义名称。 +别名是在查询中为 [表达式](#expressions) 定义的用户自定义名称。 ```sql expr AS alias ``` -上面的语法部分在下面解释。 +上面的语法部分解释如下。 -| 语法部分 | 描述 | 示例 | 备注 | -|----------|-----------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------| -| `AS` | 用于定义别名的关键字。您可以在 `SELECT` 子句中为表名或列名定义别名,而无需使用 `AS` 关键字。 | `SELECT table_name_alias.column_name FROM table_name table_name_alias`。| 在 [CAST](/sql-reference/functions/type-conversion-functions#cast) 函数中,`AS` 关键字有其他的含义。请参阅该函数的描述。 | -| `expr` | ClickHouse 支持的任何表达式。 | `SELECT column_name * 2 AS double FROM some_table` | | -| `alias` | `expr` 的名称。别名应符合 [标识符](#identifiers) 语法。 | `SELECT "table t".column_name FROM table_name AS "table t"`。 | | +| 语法部分 | 描述 | 示例 | 注释 | +|----------|------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------| +| `AS` | 定义别名的关键字。可以在 `SELECT` 子句中为表名或列名定义别名,而不使用 `AS` 关键字。 | `SELECT table_name_alias.column_name FROM table_name table_name_alias`。| 在 [CAST](/sql-reference/functions/type-conversion-functions#cast) 函数中,`AS` 关键字有另一种含义。请参阅该函数的说明。 | +| `expr` | ClickHouse 支持的任何表达式。 | `SELECT column_name * 2 AS double FROM some_table` | | +| `alias` | `expr` 的名称。别名应符合 [标识符](#identifiers) 语法。 | `SELECT "table t".column_name FROM table_name AS "table t"`。 | | -### 用法说明 {#notes-on-usage} +### 使用注意事项 {#notes-on-usage} - 别名对于查询或子查询是全局的,您可以在查询的任何部分为任何表达式定义别名。例如: @@ -409,13 +412,13 @@ SELECT (1 AS n) + 2, n`. `SELECT (SELECT sum(b.a) + num FROM b) - a.a AS num FROM a` ``` -- 如果在子查询的 `SELECT` 子句中为结果列定义了别名,这些列在外部查询中可见。例如: +- 如果在子查询的 `SELECT` 子句中为结果列定义了别名,则这些列在外部查询中可见。例如: ```sql SELECT n + m FROM (SELECT 1 AS n, 2 AS m)`. ``` -- 注意使用与列或表名称相同的别名。让我们考虑以下示例: +- 请注意使用与列名或表名相同的别名。我们考虑以下示例: ```sql CREATE TABLE t @@ -434,11 +437,11 @@ Received exception from server (version 18.14.17): Code: 184. DB::Exception: Received from localhost:9000, 127.0.0.1. DB::Exception: Aggregate function sum(b) is found inside another aggregate function in query. ``` -在前面的示例中,我们声明了表 `t` 及其列 `b`。 -然后,在选择数据时,我们定义了别名 `sum(b) AS b`。 -由于别名是全局的, -ClickHouse 将表达式 `argMax(a, b)` 中的字面量 `b` 替换为表达式 `sum(b)`。 -此替换导致了异常。 +在前面的示例中,我们声明了具有列 `b` 的表 `t`。 +然后,在选择数据时,我们定义了别名 `sum(b) AS b`。 +由于别名是全局的, +ClickHouse 在表达式 `argMax(a, b)` 中用表达式 `sum(b)` 替代了文字 `b`。 +这种替代导致了异常的产生。 :::note 您可以通过将 [prefer_column_name_to_alias](/operations/settings/settings#prefer_column_name_to_alias) 设置为 `1` 来更改此默认行为。 @@ -446,5 +449,4 @@ ClickHouse 将表达式 `argMax(a, b)` 中的字面量 `b` 替换为表达式 `s ## 星号 {#asterisk} -在 `SELECT` 查询中,星号可以替换表达式。 -有关更多信息,请参阅 [SELECT](/sql-reference/statements/select/index.md#asterisk) 部分。 +在 `SELECT` 查询中,星号可以替代表达式。有关更多信息,请参见 [SELECT](/sql-reference/statements/select/index.md#asterisk) 部分。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/syntax.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/syntax.md.hash index be6e4e0cf1f..561624256e5 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/syntax.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/syntax.md.hash @@ -1 +1 @@ -9cce95d2bdb52772 +07ce9fc0049d862c diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/arrowflight.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/arrowflight.md new file mode 100644 index 00000000000..87e6a34bacb --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/arrowflight.md @@ -0,0 +1,55 @@ +--- +'description': '允许在通过 Apache Arrow Flight 服务器暴露的数据上执行查询。' +'sidebar_label': 'arrowFlight' +'sidebar_position': 186 +'slug': '/sql-reference/table-functions/arrowflight' +'title': 'arrowFlight' +'doc_type': 'reference' +--- + + +# arrowFlight 表函数 + +允许对通过 [Apache Arrow Flight](../../interfaces/arrowflight.md) 服务器公开的数据执行查询。 + +**语法** + +```sql +arrowFlight('host:port', 'dataset_name' [, 'username', 'password']) +``` + +**参数** + +* `host:port` — Arrow Flight 服务器的地址。 [字符串](../../sql-reference/data-types/string.md). +* `dataset_name` — 在 Arrow Flight 服务器上可用的数据集或描述符的名称。 [字符串](../../sql-reference/data-types/string.md). +* `username` - 用于基本 HTTP 风格认证的用户名。 +* `password` - 用于基本 HTTP 风格认证的密码。 +如果未指定 `username` 和 `password`,这意味着不使用认证 +(仅当 Arrow Flight 服务器允许时才有效)。 + +**返回值** + +* 一个表示远程数据集的表对象。架构是从 Arrow Flight 响应中推断的。 + +**示例** + +查询: + +```sql +SELECT * FROM arrowFlight('127.0.0.1:9005', 'sample_dataset') ORDER BY id; +``` + +结果: + +```text +┌─id─┬─name────┬─value─┐ +│ 1 │ foo │ 42.1 │ +│ 2 │ bar │ 13.3 │ +│ 3 │ baz │ 77.0 │ +└────┴─────────┴───────┘ +``` + +**另请参阅** + +* [Arrow Flight](../../engines/table-engines/integrations/arrowflight.md) 表引擎 +* [Apache Arrow Flight SQL](https://arrow.apache.org/docs/format/FlightSql.html) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/arrowflight.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/arrowflight.md.hash new file mode 100644 index 00000000000..75d900fa03b --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/arrowflight.md.hash @@ -0,0 +1 @@ +560ac2415889693a diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/azureBlobStorage.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/azureBlobStorage.md index dd76d0e87f6..8dea95c20e1 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/azureBlobStorage.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/azureBlobStorage.md @@ -1,11 +1,12 @@ --- -'description': '提供一个类似表格的接口来选择/插入文件到 Azure Blob Storage。与 s3 函数类似。' +'description': '提供一个类似于表的接口来选择/插入文件到 Azure Blob Storage。与 s3 函数类似。' 'keywords': - 'azure blob storage' 'sidebar_label': 'azureBlobStorage' 'sidebar_position': 10 'slug': '/sql-reference/table-functions/azureBlobStorage' 'title': 'azureBlobStorage' +'doc_type': 'reference' --- import ExperimentalBadge from '@theme/badges/ExperimentalBadge'; @@ -14,36 +15,39 @@ import CloudNotSupportedBadge from '@theme/badges/CloudNotSupportedBadge'; # azureBlobStorage 表函数 -提供类似表的接口,用于在 [Azure Blob Storage](https://azure.microsoft.com/en-us/products/storage/blobs) 中选择/插入文件。这个表函数类似于 [s3 函数](../../sql-reference/table-functions/s3.md)。 +提供一个类似表的接口,以便在 [Azure Blob Storage](https://azure.microsoft.com/en-us/products/storage/blobs) 中选择/插入文件。此表函数与 [s3 函数](../../sql-reference/table-functions/s3.md) 类似。 ## 语法 {#syntax} ```sql -azureBlobStorage(- connection_string|storage_account_url, container_name, blobpath, [account_name, account_key, format, compression, structure]) +azureBlobStorage(- connection_string|storage_account_url, container_name, blobpath, [account_name, account_key, format, compression, structure, partition_strategy, partition_columns_in_data_file, extra_credentials(client_id=, tenant_id=)]) ``` ## 参数 {#arguments} -| 参数 | 描述 | -|-----------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `connection_string`\| `storage_account_url` | connection_string 包含账户名称和密钥 ([创建连接字符串](https://learn.microsoft.com/en-us/azure/storage/common/storage-configure-connection-string?toc=%2Fazure%2Fstorage%2Fblobs%2Ftoc.json&bc=%2Fazure%2Fstorage%2Fblobs%2Fbreadcrumb%2Ftoc.json#configure-a-connection-string-for-an-azure-storage-account)),或者您也可以在这里提供存储账户 URL,并将账户名称和账户密钥作为单独的参数提供(见参数 account_name 和 account_key) | -| `container_name` | 容器名称 | -| `blobpath` | 文件路径。在只读模式下支持以下通配符:`*`、`**`、`?`、`{abc,def}` 和 `{N..M}`,其中 `N`、`M` 为数字,`'abc'`、`'def'` 为字符串。 | -| `account_name` | 如果使用了 storage_account_url,则可以在此指定账户名称 | -| `account_key` | 如果使用了 storage_account_url,则可以在此指定账户密钥 | -| `format` | 文件的 [格式](/sql-reference/formats)。 | -| `compression` | 支持的值:`none`、`gzip/gz`、`brotli/br`、`xz/LZMA`、`zstd/zst`。默认情况下,通过文件扩展名自动检测压缩(与设置为 `auto` 相同)。 | -| `structure` | 表的结构。格式为 `'column1_name column1_type, column2_name column2_type, ...'`。 | +| 参数 | 描述 | +|-------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `connection_string`\| `storage_account_url` | connection_string 包括账户名称和密钥 ([创建连接字符串](https://learn.microsoft.com/en-us/azure/storage/common/storage-configure-connection-string?toc=%2Fazure%2Fstorage%2Fblobs%2Ftoc.json&bc=%2Fazure%2Fstorage%2Fblobs%2Fbreadcrumb%2Ftoc.json#configure-a-connection-string-for-an-azure-storage-account)),或者您也可以在这里提供存储账户 URL,并将账户名称和账户密钥作为单独的参数(参见参数 account_name 和 account_key)。 | +| `container_name` | 容器名称 | +| `blobpath` | 文件路径。在只读模式下支持以下通配符:`*`、`**`、`?`、`{abc,def}` 和 `{N..M}`,其中 `N`、`M` 为数字,`'abc'`、`'def'` 为字符串。 | +| `account_name` | 如果使用了 storage_account_url,则可以在此指定账户名称 | +| `account_key` | 如果使用了 storage_account_url,则可以在此指定账户密钥 | +| `format` | 文件的 [格式](/sql-reference/formats)。 | +| `compression` | 支持的值:`none`,`gzip/gz`,`brotli/br`,`xz/LZMA`,`zstd/zst`。默认情况下,它将根据文件扩展名自动检测压缩。(与设置为 `auto` 相同)。 | +| `structure` | 表的结构。格式为 `'column1_name column1_type, column2_name column2_type, ...'`。 | +| `partition_strategy` | 此参数为可选。支持的值:`WILDCARD` 或 `HIVE`。`WILDCARD` 要求路径中包含一个 `{_partition_id}`,该 ID 将替换为分区键。`HIVE` 不允许通配符,假设路径为表根,并生成 Hive 风格的分区目录,其中文件名为 Snowflake ID,文件格式作为扩展名。默认值为 `WILDCARD` | +| `partition_columns_in_data_file` | 此参数为可选。仅与 `HIVE` 分区策略一起使用。告知 ClickHouse 是否期望在数据文件中写入分区列。默认值为 `false`。 | +| `extra_credentials` | 使用 `client_id` 和 `tenant_id` 进行身份验证。如果提供了额外的凭据,则它们的优先级高于 `account_name` 和 `account_key`。 ## 返回值 {#returned_value} -一个具有指定结构的表,用于读取或写入指定文件中的数据。 +返回一个指定结构的表,用于在指定文件中读取或写入数据。 ## 示例 {#examples} -类似于 [AzureBlobStorage](/engines/table-engines/integrations/azureBlobStorage) 表引擎,用户可以使用 Azurite 模拟器进行本地 Azure 存储开发。更多详细信息 [在这里](https://learn.microsoft.com/en-us/azure/storage/common/storage-use-azurite?tabs=docker-hub%2Cblob-storage)。下面我们假设 Azurite 在主机名 `azurite1` 可用。 +与 [AzureBlobStorage](/engines/table-engines/integrations/azureBlobStorage) 表引擎类似,用户可以使用 Azurite 模拟器进行本地 Azure 存储开发。进一步的细节 [在这里](https://learn.microsoft.com/en-us/azure/storage/common/storage-use-azurite?tabs=docker-hub%2Cblob-storage)。以下假设 Azurite 在主机名 `azurite1` 上可用。 -使用以下内容将数据写入 Azure Blob 存储: +使用以下内容将数据写入 azure blob storage: ```sql INSERT INTO TABLE FUNCTION azureBlobStorage('http://azurite1:10000/devstoreaccount1', @@ -51,7 +55,7 @@ INSERT INTO TABLE FUNCTION azureBlobStorage('http://azurite1:10000/devstoreaccou 'CSV', 'auto', 'column1 UInt32, column2 UInt32, column3 UInt32') PARTITION BY column3 VALUES (1, 2, 3), (3, 2, 1), (78, 43, 3); ``` -然后可以使用 +然后可以使用以下方式读取: ```sql SELECT * FROM azureBlobStorage('http://azurite1:10000/devstoreaccount1', @@ -80,30 +84,57 @@ SELECT count(*) FROM azureBlobStorage('DefaultEndpointsProtocol=https;AccountNam ## 虚拟列 {#virtual-columns} -- `_path` — 文件的路径。类型:`LowCardinality(String)`。 -- `_file` — 文件名。类型:`LowCardinality(String)`。 -- `_size` — 文件大小(字节)。类型:`Nullable(UInt64)`。如果文件大小未知,则值为 `NULL`。 -- `_time` — 文件的最后修改时间。类型:`Nullable(DateTime)`。如果时间未知,则值为 `NULL`。 +- `_path` — 文件路径。类型:`LowCardinality(String)`。 +- `_file` — 文件名称。类型:`LowCardinality(String)`。 +- `_size` — 文件大小(以字节为单位)。类型:`Nullable(UInt64)`。如果文件大小未知,值为 `NULL`。 +- `_time` — 文件最后修改时间。类型:`Nullable(DateTime)`。如果时间未知,值为 `NULL`。 -## Hive 风格分区 {#hive-style-partitioning} +## 分区写入 {#partitioned-write} -当设置 `use_hive_partitioning` 为 1 时,ClickHouse 将检测路径中的 Hive 风格分区(`/name=value/`),并允许在查询中使用分区列作为虚拟列。这些虚拟列将与分区路径中的名称相同,但以 `_` 开头。 +### 分区策略 {#partition-strategy} + +仅支持 INSERT 查询。 + +`WILDCARD`(默认):将文件路径中的 `{_partition_id}` 通配符替换为实际的分区键。 + +`HIVE` 实现 hive 风格的分区以供读取和写入。它以以下格式生成文件:`//.`。 + +**`HIVE` 分区策略示例** + +```sql +INSERT INTO TABLE FUNCTION azureBlobStorage(azure_conf2, storage_account_url = 'http://localhost:30000/devstoreaccount1', container='cont', blob_path='azure_table_root', format='CSVWithNames', compression='auto', structure='year UInt16, country String, id Int32', partition_strategy='hive') PARTITION BY (year, country) VALUES (2020, 'Russia', 1), (2021, 'Brazil', 2); +``` + +```result +select _path, * from azureBlobStorage(azure_conf2, storage_account_url = 'http://localhost:30000/devstoreaccount1', container='cont', blob_path='azure_table_root/**.csvwithnames') + + ┌─_path───────────────────────────────────────────────────────────────────────────┬─id─┬─year─┬─country─┐ +1. │ cont/azure_table_root/year=2021/country=Brazil/7351307847391293440.csvwithnames │ 2 │ 2021 │ Brazil │ +2. │ cont/azure_table_root/year=2020/country=Russia/7351307847378710528.csvwithnames │ 1 │ 2020 │ Russia │ + └─────────────────────────────────────────────────────────────────────────────────┴────┴──────┴─────────┘ +``` + +## use_hive_partitioning 设置 {#hive-style-partitioning} + +这是 ClickHouse 在读取时解析 hive 风格分区文件的提示。对写入没有影响。对于对称的读取和写入,请使用 `partition_strategy` 参数。 + +当设置 `use_hive_partitioning` 为 1 时,ClickHouse 会检测路径中的 Hive 风格分区(`/name=value/`),并允许在查询中使用分区列作为虚拟列。这些虚拟列的名称与分区路径中的名称相同,但以 `_` 开头。 **示例** -使用 Hive 风格分区创建的虚拟列 +使用通过 hive 风格分区创建的虚拟列 ```sql -SELECT * from azureBlobStorage(config, storage_account_url='...', container='...', blob_path='http://data/path/date=*/country=*/code=*/*.parquet') where _date > '2020-01-01' and _country = 'Netherlands' and _code = 42; +SELECT * FROM azureBlobStorage(config, storage_account_url='...', container='...', blob_path='http://data/path/date=*/country=*/code=*/*.parquet') WHERE _date > '2020-01-01' AND _country = 'Netherlands' AND _code = 42; ``` ## 使用共享访问签名 (SAS) {#using-shared-access-signatures-sas-sas-tokens} -共享访问签名 (SAS) 是授予对 Azure 存储容器或文件的受限访问的 URI。使用它可以在不分享存储账户密钥的情况下提供对存储账户资源的限时访问。更多详细信息 [在这里](https://learn.microsoft.com/en-us/rest/api/storageservices/delegate-access-with-shared-access-signature)。 +共享访问签名 (SAS) 是一个 URI,授予对 Azure 存储容器或文件的受限访问。使用它可以在不共享存储账户密钥的情况下提供对存储账户资源的限时访问。有关更多详细信息,请访问 [此处](https://learn.microsoft.com/en-us/rest/api/storageservices/delegate-access-with-shared-access-signature)。 `azureBlobStorage` 函数支持共享访问签名 (SAS)。 -[Blob SAS 令牌](https://learn.microsoft.com/en-us/azure/ai-services/translator/document-translation/how-to-guides/create-sas-tokens?tabs=Containers)包含了所有需要验证请求的信息,包括目标 Blob、权限和有效期。要构建一个 blob URL,请将 SAS 令牌附加到 Blob 服务端点。例如,如果端点是 `https://clickhousedocstest.blob.core.windows.net/`,请求变为: +[Blob SAS 令牌](https://learn.microsoft.com/en-us/azure/ai-services/translator/document-translation/how-to-guides/create-sas-tokens?tabs=Containers) 包含所有所需的信息来验证请求,包括目标 blob、权限和有效期。要构造一个 blob URL,将 SAS 令牌附加到 blob 服务端点。例如,如果端点是 `https://clickhousedocstest.blob.core.windows.net/`,请求变为: ```sql SELECT count() @@ -119,7 +150,7 @@ FROM azureBlobStorage('BlobEndpoint=https://clickhousedocstest.blob.core.windows 或者,用户可以使用生成的 [Blob SAS URL](https://learn.microsoft.com/en-us/azure/ai-services/translator/document-translation/how-to-guides/create-sas-tokens?tabs=Containers): ```sql -SELECT count() +SELECT count() FROM azureBlobStorage('https://clickhousedocstest.blob.core.windows.net/?sp=r&st=2025-01-29T14:58:11Z&se=2025-01-29T22:58:11Z&spr=https&sv=2022-11-02&sr=c&sig=Ac2U0xl4tm%2Fp7m55IilWl1yHwk%2FJG0Uk6rMVuOiD0eE%3D', 'exampledatasets', 'example.csv') ┌─count()─┐ diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/azureBlobStorage.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/azureBlobStorage.md.hash index 12175e6c79b..99541bdfbac 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/azureBlobStorage.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/azureBlobStorage.md.hash @@ -1 +1 @@ -9711fec8890f2576 +63f08a2d13f65823 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/azureBlobStorageCluster.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/azureBlobStorageCluster.md index 8759f21b026..2c7a750e8ee 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/azureBlobStorageCluster.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/azureBlobStorageCluster.md @@ -1,16 +1,17 @@ --- -'description': '允许在指定集群中与多个节点并行处理来自 Azure Blob 存储的文件。' +'description': '允许在指定的集群中通过多个节点并行处理来自 Azure Blob 存储的文件。' 'sidebar_label': 'azureBlobStorageCluster' 'sidebar_position': 15 'slug': '/sql-reference/table-functions/azureBlobStorageCluster' 'title': 'azureBlobStorageCluster' +'doc_type': 'reference' --- # azureBlobStorageCluster 表函数 -允许在指定集群中的多个节点上并行处理来自 [Azure Blob Storage](https://azure.microsoft.com/en-us/products/storage/blobs) 的文件。在发起者上,它与集群中的所有节点建立连接,披露 S3 文件路径中的星号,并动态分配每个文件。在工作节点上,它向发起者请求下一个要处理的任务并进行处理。这一过程会重复,直到所有任务完成。 -该表函数类似于 [s3Cluster function](../../sql-reference/table-functions/s3Cluster.md)。 +允许在指定集群的多个节点中并行处理来自 [Azure Blob Storage](https://azure.microsoft.com/en-us/products/storage/blobs) 的文件。在发起节点上,它创建与集群中所有节点的连接,公开 S3 文件路径中的星号,并动态调度每个文件。在工作节点上,它向发起节点请求下一个要处理的任务并进行处理。这个过程重复进行,直到所有任务完成。 +这个表函数类似于 [s3Cluster function](../../sql-reference/table-functions/s3Cluster.md)。 ## 语法 {#syntax} @@ -20,30 +21,30 @@ azureBlobStorageCluster(cluster_name, connection_string|storage_account_url, con ## 参数 {#arguments} -| 参数 | 描述 | -|----------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `cluster_name` | 用于构建远程和本地服务器地址及连接参数集合的集群名称。 | -| `connection_string` | storage_account_url` — 连接字符串包括账户名称和密钥 ([创建连接字符串](https://learn.microsoft.com/en-us/azure/storage/common/storage-configure-connection-string?toc=%2Fazure%2Fstorage%2Fblobs%2Ftoc.json&bc=%2Fazure%2Fstorage%2Fblobs%2Fbreadcrumb%2Ftoc.json#configure-a-connection-string-for-an-azure-storage-account)),您也可以在此处提供存储账户 URL,并将账户名称和账户密钥作为单独的参数提供(见参数 account_name 和 account_key) | -| `container_name` | 容器名称 | | -| `blobpath` | 文件路径。支持以下可以在只读模式下使用的通配符:`*`、`**`、`?`、`{abc,def}` 和 `{N..M}`,其中 `N` 和 `M` 为数字,`'abc'` 和 `'def'` 为字符串。 | -| `account_name` | 如果使用 storage_account_url,则可以在此处指定账户名称。 | -| `account_key` | 如果使用 storage_account_url,则可以在此处指定账户密钥。 | -| `format` | 文件的 [格式](/sql-reference/formats)。 | -| `compression` | 支持的值:`none`、`gzip/gz`、`brotli/br`、`xz/LZMA`、`zstd/zst`。默认情况下,它会根据文件扩展名自动检测压缩(同于设置为 `auto`)。 | -| `structure` | 表的结构。格式为 `'column1_name column1_type, column2_name column2_type, ...'`。 | +| 参数 | 描述 | +|---------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `cluster_name` | 用于构建对远程和本地服务器的一组地址和连接参数的集群名称。 | +| `connection_string` | storage_account_url` — 连接字符串包括账户名称和密钥([创建连接字符串](https://learn.microsoft.com/en-us/azure/storage/common/storage-configure-connection-string?toc=%2Fazure%2Fstorage%2Fblobs%2Ftoc.json&bc=%2Fazure%2Fstorage%2Fblobs%2Fbreadcrumb%2Ftoc.json#configure-a-connection-string-for-an-azure-storage-account))或者您也可以在此提供存储账户 URL,并将账户名称和账户密钥作为单独的参数提供(见参数 account_name 和 account_key) | +| `container_name` | 容器名称 | +| `blobpath` | 文件路径。以只读模式支持以下通配符: `*`, `**`, `?`, `{abc,def}` 和 `{N..M}`,其中 `N`,`M` — 数字,`'abc'`,`'def'` — 字符串。 | +| `account_name` | 如果使用了 storage_account_url,则可以在此指定账户名称。 | +| `account_key` | 如果使用了 storage_account_url,则可以在此指定账户密钥。 | +| `format` | 文件的 [格式](/sql-reference/formats)。 | +| `compression` | 支持的值: `none`, `gzip/gz`, `brotli/br`, `xz/LZMA`, `zstd/zst`。默认情况下,它将根据文件扩展名自动检测压缩。(与设置为 `auto` 相同)。 | +| `structure` | 表的结构。格式为 `'column1_name column1_type, column2_name column2_type, ...'`。 | ## 返回值 {#returned_value} -返回一个指定结构的表以读取或写入指定文件中的数据。 +具有指定结构的表,用于读取或写入指定文件中的数据。 ## 示例 {#examples} -类似于 [AzureBlobStorage](/engines/table-engines/integrations/azureBlobStorage) 表引擎,用户可以使用 Azurite 模拟器进行本地 Azure 存储开发。更多细节请见 [这里](https://learn.microsoft.com/en-us/azure/storage/common/storage-use-azurite?tabs=docker-hub%2Cblob-storage)。以下假设 Azurite 在主机名 `azurite1` 上可用。 +类似于 [AzureBlobStorage](/engines/table-engines/integrations/azureBlobStorage) 表引擎,用户可以使用 Azurite 模拟器进行本地 Azure 存储开发。更多详情 [请参见这里](https://learn.microsoft.com/en-us/azure/storage/common/storage-use-azurite?tabs=docker-hub%2Cblob-storage)。以下假设 Azurite 在主机名 `azurite1` 上可用。 选择文件 `test_cluster_*.csv` 的计数,使用 `cluster_simple` 集群中的所有节点: ```sql -SELECT count(*) from azureBlobStorageCluster( +SELECT count(*) FROM azureBlobStorageCluster( 'cluster_simple', 'http://azurite1:10000/devstoreaccount1', 'testcontainer', 'test_cluster_count.csv', 'devstoreaccount1', 'Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==', 'CSV', 'auto', 'key UInt64') @@ -51,7 +52,7 @@ SELECT count(*) from azureBlobStorageCluster( ## 使用共享访问签名 (SAS) {#using-shared-access-signatures-sas-sas-tokens} -有关示例,请参见 [azureBlobStorage](/sql-reference/table-functions/azureBlobStorage#using-shared-access-signatures-sas-sas-tokens)。 +请参见 [azureBlobStorage](/sql-reference/table-functions/azureBlobStorage#using-shared-access-signatures-sas-sas-tokens) 获取示例。 ## 相关 {#related} diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/azureBlobStorageCluster.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/azureBlobStorageCluster.md.hash index 589f4f6010f..0af59c4ccb0 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/azureBlobStorageCluster.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/azureBlobStorageCluster.md.hash @@ -1 +1 @@ -ceb5051fa4f07e5d +3b3a1e151f6f8f65 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/cluster.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/cluster.md index 03e29b52a08..84b1ea070e0 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/cluster.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/cluster.md @@ -1,17 +1,18 @@ --- -'description': '允许访问集群的所有分片(在 `remote_servers` 部分配置)而无需创建分布式表。' +'description': '允许访问集群的所有分片(在 `remote_servers` 部分中配置)而无需创建分布式表。' 'sidebar_label': 'cluster' 'sidebar_position': 30 'slug': '/sql-reference/table-functions/cluster' 'title': 'clusterAllReplicas' +'doc_type': 'reference' --- # clusterAllReplicas 表函数 -允许访问集群中所有分片(在 `remote_servers` 部分配置)而无需创建一个 [Distributed](../../engines/table-engines/special/distributed.md) 表。仅查询每个分片的一个副本。 +允许访问集群中所有分片(在 `remote_servers` 部分配置)而无需创建 [Distributed](../../engines/table-engines/special/distributed.md) 表。只查询每个分片的一个副本。 -`clusterAllReplicas` 函数 - 与 `cluster` 相同,但查询所有副本。集群中的每个副本被用作一个独立的分片/连接。 +`clusterAllReplicas` 函数 — 与 `cluster` 相同,但查询所有副本。集群中的每个副本作为一个独立的分片/连接使用。 :::note 所有可用的集群都列在 [system.clusters](../../operations/system-tables/clusters.md) 表中。 @@ -27,11 +28,11 @@ clusterAllReplicas(['cluster_name', db, table, sharding_key]) ``` ## 参数 {#arguments} -| 参数 | 类型 | -|------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------| -| `cluster_name` | 用于构建远程和本地服务器的地址和连接参数的集群名称,如果未指定则设置为 `default`。 | -| `db.table` 或 `db`, `table` | 数据库和表的名称。 | -| `sharding_key` | 分片键。可选。如果集群有多个分片,则需要指定。 | +| 参数 | 类型 | +|-------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------| +| `cluster_name` | 用于构建远程和本地服务器的地址和连接参数集合的集群名称,未指定时默认为 `default`。 | +| `db.table` 或 `db`,`table` | 数据库和表的名称。 | +| `sharding_key` | 分片键。可选。如果集群有多个分片,则需要指定该键。 | ## 返回值 {#returned_value} @@ -39,7 +40,7 @@ clusterAllReplicas(['cluster_name', db, table, sharding_key]) ## 使用宏 {#using_macros} -`cluster_name` 可以包含宏 - 大括号中的替换。替换的值来自服务器配置文件的 [macros](../../operations/server-configuration-parameters/settings.md#macros) 部分。 +`cluster_name` 可以包含宏 — 用大括号包围的替换。替换值来自服务器配置文件的 [macros](../../operations/server-configuration-parameters/settings.md#macros) 部分。 示例: @@ -47,17 +48,17 @@ clusterAllReplicas(['cluster_name', db, table, sharding_key]) SELECT * FROM cluster('{cluster}', default.example_table); ``` -## 用法和建议 {#usage_recommendations} +## 使用和建议 {#usage_recommendations} -使用 `cluster` 和 `clusterAllReplicas` 表函数的效率低于创建 `Distributed` 表,因为在这种情况下,每个请求都会重新建立服务器连接。当处理大量查询时,请始终提前创建 `Distributed` 表,而不要使用 `cluster` 和 `clusterAllReplicas` 表函数。 +使用 `cluster` 和 `clusterAllReplicas` 表函数的效率低于创建 `Distributed` 表,因为这样每个请求都会重新建立服务器连接。在处理大量查询时,请始终提前创建 `Distributed` 表,并且不要使用 `cluster` 和 `clusterAllReplicas` 表函数。 -`cluster` 和 `clusterAllReplicas` 表函数在以下情况下可能会很有用: +`cluster` 和 `clusterAllReplicas` 表函数在以下情况下可能有用: -- 访问特定集群以进行数据比较、调试和测试。 -- 针对各种 ClickHouse 集群和副本的研究查询。 -- 手动进行的低频率分布式请求。 +- 访问特定集群进行数据比较、调试和测试。 +- 查询多个 ClickHouse 集群和副本以进行研究。 +- 不频繁的手动分布式请求。 -连接设置如 `host`、`port`、`user`、`password`、`compression`、`secure` 取自 `` 配置部分。有关详细信息,请参见 [Distributed engine](../../engines/table-engines/special/distributed.md)。 +连接设置如 `host`、`port`、`user`、`password`、`compression`、`secure` 来自 `` 配置部分。有关详细信息,请参见 [Distributed engine](../../engines/table-engines/special/distributed.md)。 ## 相关 {#related} diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/cluster.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/cluster.md.hash index db2804b9424..967517e6a41 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/cluster.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/cluster.md.hash @@ -1 +1 @@ -dd350c4e60eaf5a4 +661329957b524b76 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/deltalake.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/deltalake.md index 79766c13a15..075e33b1aaf 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/deltalake.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/deltalake.md @@ -1,19 +1,20 @@ --- -'description': '提供了一个只读的类似表格的接口来访问 Amazon S3 中的 Delta Lake 表。' +'description': '为Amazon S3中的Delta Lake 表提供只读的类似表接口。' 'sidebar_label': 'deltaLake' 'sidebar_position': 45 'slug': '/sql-reference/table-functions/deltalake' 'title': 'deltaLake' +'doc_type': 'reference' --- # deltaLake 表函数 -提供一个只读的类似表的接口,适用于 Amazon S3、Azure Blob Storage 或本地挂载文件系统中的 [Delta Lake](https://github.com/delta-io/delta) 表。 +提供一个只读的类表接口,用于访问 Amazon S3、Azure Blob Storage 或本地挂载文件系统中的 [Delta Lake](https://github.com/delta-io/delta) 表。 ## 语法 {#syntax} -`deltaLake` 是 `deltaLakeS3` 的别名,出于兼容性考虑支持此别名。 +`deltaLake` 是 `deltaLakeS3` 的别名,支持兼容性。 ```sql deltaLake(url [,aws_access_key_id, aws_secret_access_key] [,format] [,structure] [,compression]) @@ -27,8 +28,7 @@ deltaLakeLocal(path, [,format]) ## 参数 {#arguments} -参数的描述与表函数 `s3`、`azureBlobStorage`、`HDFS` 和 `file` 中参数的描述一致。 -`format` 代表 Delta lake 表中数据文件的格式。 +参数的描述与表函数 `s3`、`azureBlobStorage`、`HDFS` 和 `file` 中参数的描述相符。`format` 表示 Delta lake 表中数据文件的格式。 ## 返回值 {#returned_value} @@ -36,7 +36,7 @@ deltaLakeLocal(path, [,format]) ## 示例 {#examples} -从 S3 中的表 `https://clickhouse-public-datasets.s3.amazonaws.com/delta_lake/hits/` 中选择行: +从 S3 `https://clickhouse-public-datasets.s3.amazonaws.com/delta_lake/hits/` 中选择行: ```sql SELECT @@ -54,6 +54,14 @@ LIMIT 2 └───────────────────────────────────────────────────────────────────────┴───────────┘ ``` +## 虚拟列 {#virtual-columns} + +- `_path` — 文件路径。类型: `LowCardinality(String)`。 +- `_file` — 文件名。类型: `LowCardinality(String)`。 +- `_size` — 文件大小(以字节为单位)。类型: `Nullable(UInt64)`。如果文件大小未知,则值为 `NULL`。 +- `_time` — 文件的最后修改时间。类型: `Nullable(DateTime)`。如果时间未知,则值为 `NULL`。 +- `_etag` — 文件的 etag。类型: `LowCardinality(String)`。如果 etag 未知,则值为 `NULL`。 + ## 相关 {#related} - [DeltaLake 引擎](engines/table-engines/integrations/deltalake.md) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/deltalake.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/deltalake.md.hash index de0fb98f0f1..c2e1c5742f4 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/deltalake.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/deltalake.md.hash @@ -1 +1 @@ -0503fab652a53b01 +97a26a63cb46ac4c diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/deltalakeCluster.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/deltalakeCluster.md index 3998d357d0d..2f95b171ddf 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/deltalakeCluster.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/deltalakeCluster.md @@ -4,6 +4,7 @@ 'sidebar_position': 46 'slug': '/sql-reference/table-functions/deltalakeCluster' 'title': 'deltaLakeCluster' +'doc_type': 'reference' --- @@ -11,23 +12,39 @@ 这是对 [deltaLake](sql-reference/table-functions/deltalake.md) 表函数的扩展。 -允许从指定集群中的许多节点并行处理 Amazon S3 中的 [Delta Lake](https://github.com/delta-io/delta) 表文件。在发起者上,它创建与集群中所有节点的连接,并动态派发每个文件。在工作节点上,它向发起者询问下一个要处理的任务并进行处理。直到所有任务完成,这个过程会重复进行。 +允许从指定集群中的多个节点并行处理 Amazon S3 中的 [Delta Lake](https://github.com/delta-io/delta) 表的文件。在发起者上,它创建与集群中所有节点的连接并动态调度每个文件。在工作节点上,它向发起者询问要处理的下一个任务并进行处理。这个过程将持续,直到所有任务完成。 ## 语法 {#syntax} ```sql deltaLakeCluster(cluster_name, url [,aws_access_key_id, aws_secret_access_key] [,format] [,structure] [,compression]) +deltaLakeCluster(cluster_name, named_collection[, option=value [,..]]) + +deltaLakeS3Cluster(cluster_name, url [,aws_access_key_id, aws_secret_access_key] [,format] [,structure] [,compression]) +deltaLakeS3Cluster(cluster_name, named_collection[, option=value [,..]]) + +deltaLakeAzureCluster(cluster_name, connection_string|storage_account_url, container_name, blobpath, [,account_name], [,account_key] [,format] [,compression_method]) +deltaLakeAzureCluster(cluster_name, named_collection[, option=value [,..]]) ``` +`deltaLakeS3Cluster` 是 `deltaLakeCluster` 的别名,二者均用于 S3。 ## 参数 {#arguments} -- `cluster_name` — 用于构建一组地址和远程及本地服务器连接参数的集群名称。 +- `cluster_name` — 用于构建远程和本地服务器的地址和连接参数集合的集群名称。 -- 所有其他参数的描述与等效 [deltaLake](sql-reference/table-functions/deltalake.md) 表函数中的参数描述一致。 +- 所有其他参数的描述与等效的 [deltaLake](sql-reference/table-functions/deltalake.md) 表函数中的参数描述相同。 ## 返回值 {#returned_value} -一个具有指定结构的表,用于从指定的 Delta Lake 表中读取集群数据,该表位于 S3 中。 +一个具有指定结构的表,用于从 S3 中指定的 Delta Lake 表读取数据。 + +## 虚拟列 {#virtual-columns} + +- `_path` — 文件路径。类型:`LowCardinality(String)`。 +- `_file` — 文件名称。类型:`LowCardinality(String)`。 +- `_size` — 文件大小(以字节为单位)。类型:`Nullable(UInt64)`。如果文件大小未知,则值为 `NULL`。 +- `_time` — 文件的最后修改时间。类型:`Nullable(DateTime)`。如果时间未知,则值为 `NULL`。 +- `_etag` — 文件的 etag。类型:`LowCardinality(String)`。如果 etag 未知,则值为 `NULL`。 ## 相关 {#related} diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/deltalakeCluster.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/deltalakeCluster.md.hash index 04305256f21..a7172743b0c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/deltalakeCluster.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/deltalakeCluster.md.hash @@ -1 +1 @@ -1fafd0430220c23a +9ddabb0962d14fae diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/dictionary.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/dictionary.md index dcd436dc5c3..78c9ab95874 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/dictionary.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/dictionary.md @@ -1,15 +1,16 @@ --- -'description': '将字典数据以 ClickHouse 表的形式显示。与 Dictionary 引擎的工作方式相同。' +'description': '以 ClickHouse 表格的形式显示字典数据。与 Dictionary 引擎的工作方式相同。' 'sidebar_label': '字典' 'sidebar_position': 47 'slug': '/sql-reference/table-functions/dictionary' 'title': '字典' +'doc_type': 'reference' --- # dictionary 表函数 -显示 [dictionary](../../sql-reference/dictionaries/index.md) 数据作为 ClickHouse 表。与 [Dictionary](../../engines/table-engines/special/dictionary.md) 引擎的工作方式相同。 +将 [字典](../../sql-reference/dictionaries/index.md) 数据显示为 ClickHouse 表。其工作方式与 [Dictionary](../../engines/table-engines/special/dictionary.md) 引擎相同。 ## 语法 {#syntax} diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/dictionary.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/dictionary.md.hash index 08317119699..884c669c607 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/dictionary.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/dictionary.md.hash @@ -1 +1 @@ -e3cd5d43df136cb2 +7f239da30e4189e2 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/executable.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/executable.md index fa75c3515ac..45cc0b2d544 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/executable.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/executable.md @@ -1,5 +1,5 @@ --- -'description': '`executable` 表函数基于您在脚本中定义的用户自定义函数(UDF)的输出创建一个表,该函数将行输出到 **stdout**。' +'description': '`executable` 表函数基于您在脚本中定义的用户定义函数 (UDF) 的输出创建一个表,该函数将行输出到 **stdout**。' 'keywords': - 'udf' - 'user defined function' @@ -7,24 +7,25 @@ - 'executable' - 'table' - 'function' -'sidebar_label': 'executable' +'sidebar_label': '可执行的' 'sidebar_position': 50 'slug': '/engines/table-functions/executable' -'title': 'executable' +'title': '可执行的' +'doc_type': 'reference' --- -# 可执行表函数用于用户定义的函数(UDF) +# executable Table Function for UDFs -`executable` 表函数根据您在脚本中定义的用户定义的函数(UDF)的输出创建一个表,该函数将行输出到 **stdout**。可执行脚本存储在 `users_scripts` 目录中,并可以从任何源读取数据。确保您的 ClickHouse 服务器具有运行可执行脚本所需的所有软件包。例如,如果它是一个 Python 脚本,请确保服务器安装了必要的 Python 软件包。 +`executable` 表函数基于您在输出行到 **stdout** 的脚本中定义的用户定义函数 (UDF) 创建一个表。可执行脚本存储在 `users_scripts` 目录中,并可以从任何来源读取数据。确保您的 ClickHouse 服务器具备运行可执行脚本所需的所有软件包。例如,如果它是一个 Python 脚本,请确保服务器已安装必要的 Python 软件包。 您可以选择性地包含一个或多个输入查询,这些查询将其结果流式传输到 **stdin** 供脚本读取。 :::note -普通 UDF 函数与 `executable` 表函数和 `Executable` 表引擎之间的一个主要优势是,普通 UDF 函数无法更改行数。例如,如果输入是 100 行,则结果必须返回 100 行。当使用 `executable` 表函数或 `Executable` 表引擎时,您的脚本可以进行任何您想要的数据转换,包括复杂的聚合。 +普通 UDF 函数和 `executable` 表函数与 `Executable` 表引擎之间的一个关键优势是,普通 UDF 函数无法更改行数。例如,如果输入是 100 行,则结果必须返回 100 行。当使用 `executable` 表函数或 `Executable` 表引擎时,您的脚本可以进行您想要的数据转换,包括复杂的聚合。 ::: -## 语法 {#syntax} +## Syntax {#syntax} `executable` 表函数需要三个参数,并接受一个可选的输入查询列表: @@ -32,16 +33,16 @@ executable(script_name, format, structure, [input_query...] [,SETTINGS ...]) ``` -- `script_name`: 脚本的文件名,保存在 `user_scripts` 文件夹中(`user_scripts_path` 设置的默认文件夹)。 -- `format`: 生成表的格式。 -- `structure`: 生成表的表架构。 -- `input_query`: 一个可选的查询(或查询集合),其结果通过 **stdin** 传递给脚本。 +- `script_name`: 脚本的文件名。 保存在 `user_scripts` 文件夹中(`user_scripts_path` 设置的默认文件夹) +- `format`: 生成表的格式 +- `structure`: 生成表的表架构 +- `input_query`: 一个可选的查询(或查询集合),其结果通过 **stdin** 传递给脚本 :::note -如果您要重复调用相同的脚本并使用相同的输入查询,请考虑使用 [`Executable` 表引擎](../../engines/table-engines/special/executable.md)。 +如果您要使用相同的输入查询多次调用相同的脚本,请考虑使用 [`Executable` 表引擎](../../engines/table-engines/special/executable.md)。 ::: -以下 Python 脚本名为 `generate_random.py`,并保存在 `user_scripts` 文件夹中。它读取一个数字 `i`,并打印 `i` 个随机字符串,每个字符串前面都有一个数字,用制表符分隔: +下面的 Python 脚本名为 `generate_random.py`,保存在 `user_scripts` 文件夹中。它读取一个数字 `i` 并打印 `i` 个随机字符串,每个字符串前面都有一个用制表符分隔的数字: ```python #!/usr/local/bin/python3.9 @@ -69,13 +70,13 @@ if __name__ == "__main__": main() ``` -让我们调用脚本并生成 10 个随机字符串: +我们来调用该脚本并生成 10 个随机字符串: ```sql SELECT * FROM executable('generate_random.py', TabSeparated, 'id UInt32, random String', (SELECT 10)) ``` -响应如下所示: +响应看起来像: ```response ┌─id─┬─random─────┐ @@ -92,18 +93,18 @@ SELECT * FROM executable('generate_random.py', TabSeparated, 'id UInt32, random └────┴────────────┘ ``` -## 设置 {#settings} +## Settings {#settings} -- `send_chunk_header` - 控制在发送数据块进行处理之前是否发送行数。默认值为 `false`。 -- `pool_size` — 池的大小。如果指定 `pool_size` 为 0,则没有池大小限制。默认值为 16。 -- `max_command_execution_time` — 处理数据块的可执行脚本命令执行的最大时间。以秒为单位。默认值为 10。 -- `command_termination_timeout` — 可执行脚本应包含主读写循环。在表函数销毁后,管道关闭,执行文件将有 `command_termination_timeout` 秒的时间进行关机,之后 ClickHouse 将向子进程发送 SIGTERM 信号。以秒为单位。默认值为 10。 -- `command_read_timeout` - 从命令 stdout 读取数据的超时时间(以毫秒为单位)。默认值 10000。 -- `command_write_timeout` - 向命令 stdin 写入数据的超时时间(以毫秒为单位)。默认值 10000。 +- `send_chunk_header` - 控制在发送数据块以处理之前是否发送行计数。 默认值为 `false`。 +- `pool_size` — 池的大小。如果将 `pool_size` 指定为 0,则没有池大小限制。 默认值为 `16`。 +- `max_command_execution_time` — 处理数据块的可执行脚本命令执行的最大时间。以秒为单位指定。 默认值为 10。 +- `command_termination_timeout` — 可执行脚本应包含主读写循环。在表函数被销毁后,管道关闭,可执行文件将在 `command_termination_timeout` 秒内关闭,然后 ClickHouse 将向子进程发送 SIGTERM 信号。以秒为单位指定。 默认值为 10。 +- `command_read_timeout` - 从命令 stdout 中读取数据的超时,单位为毫秒。 默认值为 10000。 +- `command_write_timeout` - 向命令 stdin 写入数据的超时,单位为毫秒。 默认值为 10000。 -## 将查询结果传递给脚本 {#passing-query-results-to-a-script} +## Passing Query Results to a Script {#passing-query-results-to-a-script} -一定要查看 `Executable` 表引擎中的示例,了解 [如何将查询结果传递给脚本](../../engines/table-engines/special/executable.md#passing-query-results-to-a-script)。以下是如何在该示例中使用 `executable` 表函数执行相同脚本: +确保查看 `Executable` 表引擎中的示例,了解 [如何将查询结果传递给脚本](../../engines/table-engines/special/executable.md#passing-query-results-to-a-script)。以下是如何使用 `executable` 表函数执行示例中的相同脚本: ```sql SELECT * FROM executable( diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/executable.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/executable.md.hash index 087f851a2cf..e1a24269058 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/executable.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/executable.md.hash @@ -1 +1 @@ -37a2365f905ae34f +43004a18c681d860 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/file.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/file.md index 4b1ddd7e7d7..2a753f159d9 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/file.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/file.md @@ -1,9 +1,10 @@ --- -'description': '一种表引擎,提供类似表的接口以从文件中SELECT和INSERT,类似于s3表函数。使用`file()`时处理本地文件,使用`s3()`时处理对象存储中的存储桶,例如S3、GCS或MinIO。' +'description': '一个表引擎,提供类似于从文件中SELECT和INSERT的表格接口,类似于s3表函数。使用`file()`处理本地文件,使用`s3()`处理对象存储中的桶,如S3、GCS或MinIO。' 'sidebar_label': '文件' 'sidebar_position': 60 'slug': '/sql-reference/table-functions/file' 'title': '文件' +'doc_type': 'reference' --- import ExperimentalBadge from '@theme/badges/ExperimentalBadge'; @@ -12,7 +13,7 @@ import CloudNotSupportedBadge from '@theme/badges/CloudNotSupportedBadge'; # file 表函数 -一个提供类表接口的表引擎,可以从文件中 SELECT 和 INSERT,类似于 [s3](/sql-reference/table-functions/url.md) 表函数。使用 `file()` 处理本地文件,使用 `s3()` 处理对象存储中的桶,如 S3、GCS 或 MinIO。 +一种表引擎,提供表格接口,以便从文件中 `SELECT` 和 `INSERT`,类似于 [s3](/sql-reference/table-functions/url.md) 表函数。当处理本地文件时使用 `file()`,而在处理像 S3、GCS 或 MinIO 等对象存储中的桶时使用 `s3()`。 `file` 函数可以在 `SELECT` 和 `INSERT` 查询中用于读取或写入文件。 @@ -24,19 +25,19 @@ file([path_to_archive ::] path [,format] [,structure] [,compression]) ## 参数 {#arguments} -| 参数 | 描述 | -|-------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `path` | 从 [user_files_path](operations/server-configuration-parameters/settings.md#user_files_path) 的相对路径。支持只读模式下的以下 [通配符](#globs-in-path):`*`、`?`、`{abc,def}`(`'abc'` 和 `'def'` 是字符串)和 `{N..M}`(`N` 和 `M` 是数字)。 | -| `path_to_archive` | zip/tar/7z 存档的相对路径。支持与 `path` 相同的通配符。 | -| `format` | 文件的 [格式](/interfaces/formats)。 | -| `structure` | 表的结构。格式:`'column1_name column1_type, column2_name column2_type, ...'`。 | -| `compression` | 在 `SELECT` 查询中使用时现有的压缩类型,或在 `INSERT` 查询中使用时所需的压缩类型。支持的压缩类型有 `gz`、`br`、`xz`、`zst`、`lz4` 和 `bz2`。 | +| 参数 | 描述 | +|-------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `path` | 从 [user_files_path](operations/server-configuration-parameters/settings.md#user_files_path) 到文件的相对路径。在只读模式下支持以下 [通配符](#globs-in-path):`*`、`?`、`{abc,def}`(`'abc'` 和 `'def'` 为字符串)以及 `{N..M}`(`N` 和 `M` 为数字)。 | +| `path_to_archive` | zip/tar/7z 压缩档案的相对路径。支持与 `path` 相同的通配符。 | +| `format` | 文件的 [格式](/interfaces/formats)。 | +| `structure` | 表的结构。格式:`'column1_name column1_type, column2_name column2_type, ...'`。 | +| `compression` | 在 `SELECT` 查询中使用时的现有压缩类型,或者在 `INSERT` 查询中使用时的期望压缩类型。支持的压缩类型有 `gz`、`br`、`xz`、`zst`、`lz4` 和 `bz2`。 | ## 返回值 {#returned_value} -用于读取或写入文件中的数据的表。 +用于在文件中读取或写入数据的表。 -## 写入文件的示例 {#examples-for-writing-to-a-file} +## 示例:写入文件 {#examples-for-writing-to-a-file} ### 写入 TSV 文件 {#write-to-a-tsv-file} @@ -58,7 +59,7 @@ VALUES (1, 2, 3), (3, 2, 1), (1, 3, 2) ### 分区写入多个 TSV 文件 {#partitioned-write-to-multiple-tsv-files} -如果在将数据插入 `file()` 类型的表函数时指定了 `PARTITION BY` 表达式,则为每个分区创建一个单独的文件。将数据拆分到单独的文件有助于提高读取操作的性能。 +如果在向类型为 `file()` 的表函数插入数据时指定了 `PARTITION BY` 表达式,则为每个分区创建一个单独的文件。将数据拆分到不同的文件有助于提高读取操作的性能。 ```sql INSERT INTO TABLE FUNCTION @@ -83,9 +84,9 @@ VALUES (1, 2, 3), (3, 2, 1), (1, 3, 2) 1 2 3 ``` -## 从文件读取的示例 {#examples-for-reading-from-a-file} +## 示例:从文件读取 {#examples-for-reading-from-a-file} -### 从 CSV 文件 SELECT {#select-from-a-csv-file} +### 从 CSV 文件中 SELECT {#select-from-a-csv-file} 首先,在服务器配置中设置 `user_files_path` 并准备一个文件 `test.csv`: @@ -133,7 +134,7 @@ file('test.csv', 'CSV', 'column1 UInt32, column2 UInt32, column3 UInt32'); └─────────┴─────────┴─────────┘ ``` -从 `archive1.zip` 或/和 `archive2.zip` 中读取位于 `table.csv` 的数据: +从 `archive1.zip` 或/和 `archive2.zip` 中读取 `table.csv` 的数据: ```sql SELECT * FROM file('user_files/archives/archive{1..2}.zip :: table.csv'); @@ -141,21 +142,21 @@ SELECT * FROM file('user_files/archives/archive{1..2}.zip :: table.csv'); ## 路径中的通配符 {#globs-in-path} -路径可以使用通配符。文件必须匹配完整的路径模式,而不仅仅是后缀或前缀。有一个例外,如果路径指向一个现有的目录且不使用通配符,则会隐式地在路径末尾添加一个 `*`,以便选择目录中的所有文件。 +路径可以使用通配符。文件必须匹配整个路径模式,而不仅仅是后缀或前缀。有一个例外,如果路径指向已存在的目录且不使用通配符,则将隐式添加 `*` 到路径,因此选择目录中的所有文件。 -- `*` — 代表任意多个字符,除了 `/`,包括空字符串。 -- `?` — 代表任意一个字符。 -- `{some_string,another_string,yet_another_one}` — 替换为 `'some_string'`、`'another_string'` 和 `'yet_another_one'` 中的任意字符串。字符串可以包含 `/` 符号。 -- `{N..M}` — 代表任何数值 `>= N` 且 `<= M`。 -- `**` - 代表文件夹内的所有文件,递归查找。 +- `*` — 表示任意多个字符,除了 `/`,但包括空字符串。 +- `?` — 表示任意单个字符。 +- `{some_string,another_string,yet_another_one}` — 替换字符串 `'some_string'`、`'another_string'` 和 `'yet_another_one'` 中的任意一个。字符串可以包含 `/` 符号。 +- `{N..M}` — 表示任何数字 `>= N` 且 `<= M`。 +- `**` - 表示文件夹内的所有文件,递归查找。 -带 `{}` 的构造与 [remote](remote.md) 和 [hdfs](hdfs.md) 表函数类似。 +包含 `{}` 的构造与 [remote](remote.md) 和 [hdfs](hdfs.md) 表函数类似。 ## 示例 {#examples} **示例** -假设有以下相对路径的文件: +假设存在这些文件,具有以下相对路径: - `some_dir/some_file_1` - `some_dir/some_file_2` @@ -170,20 +171,20 @@ SELECT * FROM file('user_files/archives/archive{1..2}.zip :: table.csv'); SELECT count(*) FROM file('{some,another}_dir/some_file_{1..3}', 'TSV', 'name String, value UInt32'); ``` -一个替代的路径表达式可以达到同样的效果: +另一种实现相同结果的路径表达式: ```sql SELECT count(*) FROM file('{some,another}_dir/*', 'TSV', 'name String, value UInt32'); ``` -使用隐式的 `*` 查询 `some_dir` 中的总行数: +使用隐式 `*` 查询 `some_dir` 中的总行数: ```sql SELECT count(*) FROM file('some_dir', 'TSV', 'name String, value UInt32'); ``` :::note -如果文件列表中包含带有前导零的数字范围,请为每个数字单独使用大括号构造,或使用 `?`。 +如果您的文件列表包含带前导零的数字范围,请为每个数字单独使用大括号构造,或使用 `?`。 ::: **示例** @@ -196,7 +197,7 @@ SELECT count(*) FROM file('big_dir/file{0..9}{0..9}{0..9}', 'CSV', 'name String, **示例** -递归查询 `big_dir/` 目录中所有文件中的总行数: +递归查询 `big_dir/` 目录中所有文件的总行数: ```sql SELECT count(*) FROM file('big_dir/**', 'CSV', 'name String, value UInt32'); @@ -204,7 +205,7 @@ SELECT count(*) FROM file('big_dir/**', 'CSV', 'name String, value UInt32'); **示例** -递归查询 `big_dir/` 目录中任意文件夹内所有名为 `file002` 的文件中的总行数: +递归查询 `big_dir/` 目录中任意文件夹内名为 `file002` 的文件的总行数: ```sql SELECT count(*) FROM file('big_dir/**/file002', 'CSV', 'name String, value UInt32'); @@ -212,32 +213,32 @@ SELECT count(*) FROM file('big_dir/**/file002', 'CSV', 'name String, value UInt3 ## 虚拟列 {#virtual-columns} -- `_path` — 文件路径。类型:`LowCardinality(String)`。 -- `_file` — 文件名。类型:`LowCardinality(String)`。 -- `_size` — 文件大小(以字节为单位)。类型:`Nullable(UInt64)`。如果文件大小未知,则值为 `NULL`。 -- `_time` — 文件最后修改时间。类型:`Nullable(DateTime)`。如果时间未知,则值为 `NULL`。 +- `_path` — 文件的路径。类型:`LowCardinality(String)`。 +- `_file` — 文件的名称。类型:`LowCardinality(String)`。 +- `_size` — 文件的大小(以字节为单位)。类型:`Nullable(UInt64)`。如果文件大小未知,则值为 `NULL`。 +- `_time` — 文件的最后修改时间。类型:`Nullable(DateTime)`。如果时间未知,则值为 `NULL`。 -## Hive风格的分区 {#hive-style-partitioning} +## use_hive_partitioning 设置 {#hive-style-partitioning} -当设置 `use_hive_partitioning` 为 1 时,ClickHouse 会在路径中检测 Hive 风格的分区(`/name=value/`),并允许在查询中将分区列用作虚拟列。这些虚拟列将与分区路径中的名称相同,但以 `_` 开头。 +当设置 `use_hive_partitioning` 为 1 时,ClickHouse 将在路径中检测 Hive 风格的分区 (`/name=value/`),并允许在查询中使用分区列作为虚拟列。这些虚拟列将具有与分区路径相同的名称,但以 `_` 开头。 **示例** -使用使用 Hive 风格分区创建的虚拟列 +使用 Hive 风格分区创建的虚拟列 ```sql -SELECT * from file('data/path/date=*/country=*/code=*/*.parquet') where _date > '2020-01-01' and _country = 'Netherlands' and _code = 42; +SELECT * FROM file('data/path/date=*/country=*/code=*/*.parquet') WHERE _date > '2020-01-01' AND _country = 'Netherlands' AND _code = 42; ``` ## 设置 {#settings} -| 设置 | 描述 | -|--------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| [engine_file_empty_if_not_exists](/operations/settings/settings#engine_file_empty_if_not_exists) | 允许从不存在的文件中选择空数据。默认情况下禁用。 | -| [engine_file_truncate_on_insert](/operations/settings/settings#engine_file_truncate_on_insert) | 允许在插入之前截断文件。默认情况下禁用。 | -| [engine_file_allow_create_multiple_files](operations/settings/settings.md#engine_file_allow_create_multiple_files) | 如果格式有后缀,允许在每次插入时创建新文件。默认情况下禁用。 | -| [engine_file_skip_empty_files](operations/settings/settings.md#engine_file_skip_empty_files) | 允许在读取时跳过空文件。默认情况下禁用。 | -| [storage_file_read_method](/operations/settings/settings#engine_file_empty_if_not_exists) | 从存储文件读取数据的方法,选项包括:read、pread、mmap(仅适用于 clickhouse-local)。默认值:`pread` 对于 clickhouse-server,`mmap` 对于 clickhouse-local。 | +| 设置 | 描述 | +|------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| [engine_file_empty_if_not_exists](/operations/settings/settings#engine_file_empty_if_not_exists) | 允许从不存在的文件中选择空数据。默认情况下禁用。 | +| [engine_file_truncate_on_insert](/operations/settings/settings#engine_file_truncate_on_insert) | 允许在插入之前截断文件。默认情况下禁用。 | +| [engine_file_allow_create_multiple_files](operations/settings/settings.md#engine_file_allow_create_multiple_files) | 允许在每次插入时创建新文件(如果格式具有后缀)。默认情况下禁用。 | +| [engine_file_skip_empty_files](operations/settings/settings.md#engine_file_skip_empty_files) | 允许在读取时跳过空文件。默认情况下禁用。 | +| [storage_file_read_method](/operations/settings/settings#engine_file_empty_if_not_exists) | 从存储文件读取数据的方法,有效值为:read, pread, mmap(仅限 clickhouse-local)。默认值:`pread` 用于 clickhouse-server,`mmap` 用于 clickhouse-local。 | ## 相关 {#related} diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/file.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/file.md.hash index 9854bf14d92..5a1937414fa 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/file.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/file.md.hash @@ -1 +1 @@ -9dcaa99b71744391 +4b108cda2f16b466 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/fileCluster.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/fileCluster.md index 98776c7abd4..af1068a6142 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/fileCluster.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/fileCluster.md @@ -1,19 +1,20 @@ --- -'description': '在集群内启用同时处理匹配指定路径的文件,跨多个节点。发起者建立与工作节点的连接,扩展文件路径中的通配符,并将文件读取任务委派给工作节点。每个工作节点都在向发起者查询下一个要处理的文件,直到所有任务完成(所有文件被读取)。' +'description': '在集群内同时处理匹配指定路径的文件。发起者与工作节点建立连接,扩展文件路径中的通配符,并将文件读取任务委托给工作节点。每个工作节点都在向发起者查询下一个要处理的文件,重复此过程直到所有任务完成(所有文件均已读取)。' 'sidebar_label': 'fileCluster' 'sidebar_position': 61 'slug': '/sql-reference/table-functions/fileCluster' 'title': 'fileCluster' +'doc_type': 'reference' --- # fileCluster 表函数 -启用在集群内的多个节点同时处理与指定路径匹配的文件。发起者建立与工作节点的连接,扩展文件路径中的通配符,并将文件读取任务委派给工作节点。每个工作节点向发起者查询下一个待处理的文件,重复此过程直到所有任务完成(所有文件被读取)。 +允许在集群内的多个节点上同时处理匹配指定路径的文件。发起者与工作节点建立连接,展开文件路径中的通配符,并将文件读取任务委派给工作节点。每个工作节点向发起者查询下一个要处理的文件,重复此过程直到所有任务完成(所有文件都被读取)。 :::note -仅当与最初指定路径匹配的文件集合在所有节点上相同,并且它们的内容在不同节点之间一致时,此函数才能_正确_操作。 -如果这些文件在节点之间不同,则返回值不能预先确定,取决于工作节点从发起者请求任务的顺序。 +只有在初始指定路径匹配的文件集合在所有节点中相同,并且它们的内容在不同节点之间一致的情况下,此函数才能正常运行。 +如果这些文件在节点之间不同,则返回值不能预先确定,并且取决于工作节点从发起者请求任务的顺序。 ::: ## 语法 {#syntax} @@ -24,27 +25,27 @@ fileCluster(cluster_name, path[, format, structure, compression_method]) ## 参数 {#arguments} -| 参数 | 描述 | +| 参数 | 描述 | |-----------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `cluster_name` | 用于构建与远程和本地服务器的地址和连接参数集合的集群名称。 | -| `path` | 从 [user_files_path](/operations/server-configuration-parameters/settings.md#user_files_path) 到文件的相对路径。文件路径也支持 [通配符](#globs-in-path)。 | -| `format` | 文件的 [格式](/sql-reference/formats)。类型: [字符串](../../sql-reference/data-types/string.md)。 | -| `structure` | 表结构,格式为 `'UserID UInt64, Name String'`。确定列名和类型。类型: [字符串](../../sql-reference/data-types/string.md)。 | -| `compression_method` | 压缩方法。支持的压缩类型有 `gz`、`br`、`xz`、`zst`、`lz4` 和 `bz2`。 | +| `cluster_name` | 用于构建与远程和本地服务器的地址和连接参数集的集群名称。 | +| `path` | 从 [user_files_path](/operations/server-configuration-parameters/settings.md#user_files_path) 起的文件相对路径。文件路径还支持 [globs](#globs-in-path)。 | +| `format` | 文件的 [格式](/sql-reference/formats)。类型:[String](../../sql-reference/data-types/string.md)。 | +| `structure` | `'UserID UInt64, Name String'` 格式的表结构。确定列的名称和类型。类型:[String](../../sql-reference/data-types/string.md)。 | +| `compression_method` | 压缩方法。支持的压缩类型有 `gz`、`br`、`xz`、`zst`、`lz4` 和 `bz2`。 | ## 返回值 {#returned_value} -具有指定格式和结构以及来自与指定路径匹配的文件数据的表。 +一个具有指定格式和结构的表,包含匹配指定路径的文件的数据。 **示例** -给定一个名为 `my_cluster` 的集群,以及以下 `user_files_path` 设置的值: +给定一个名为 `my_cluster` 的集群,以及以下设置的 `user_files_path` 值: ```bash $ grep user_files_path /etc/clickhouse-server/config.xml /var/lib/clickhouse/user_files/ ``` -另外,假设每个集群节点的 `user_files_path` 中有文件 `test1.csv` 和 `test2.csv`,并且它们在不同节点之间的内容是相同的: +同时,给定每个集群节点的 `user_files_path` 中有文件 `test1.csv` 和 `test2.csv`,并且它们的内容在不同节点之间一致: ```bash $ cat /var/lib/clickhouse/user_files/test1.csv 1,"file1" @@ -55,7 +56,7 @@ $ cat /var/lib/clickhouse/user_files/test2.csv 22,"file22" ``` -例如,可以通过在每个集群节点上执行这两个查询来创建这些文件: +例如,可以在每个集群节点上执行这两个查询以创建这些文件: ```sql INSERT INTO TABLE FUNCTION file('file1.csv', 'CSV', 'i UInt32, s String') VALUES (1,'file1'), (11,'file11'); INSERT INTO TABLE FUNCTION file('file2.csv', 'CSV', 'i UInt32, s String') VALUES (2,'file2'), (22,'file22'); @@ -80,7 +81,7 @@ SELECT * FROM fileCluster('my_cluster', 'file{1,2}.csv', 'CSV', 'i UInt32, s Str ## 路径中的通配符 {#globs-in-path} -[File](../../sql-reference/table-functions/file.md#globs-in-path) 表函数支持的所有模式也都被 FileCluster 支持。 +由 [File](../../sql-reference/table-functions/file.md#globs-in-path) 表函数支持的所有模式都可以在 FileCluster 中使用。 ## 相关 {#related} diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/fileCluster.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/fileCluster.md.hash index 2864b914ffe..79b8b4a9b3b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/fileCluster.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/fileCluster.md.hash @@ -1 +1 @@ -6ed0679491c14ba9 +c9ca143d90787d3b diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/format.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/format.md index 635c9817463..e9d94d19d7f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/format.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/format.md @@ -1,37 +1,38 @@ --- -'description': '根据指定的输入格式解析来自参数的数据。如果未指定结构参数,则从数据中提取其结构。' +'description': '根据指定的输入格式解析来自参数的数据。如果未指定结构参数,则将从数据中提取它。' 'slug': '/sql-reference/table-functions/format' 'sidebar_position': 65 'sidebar_label': '格式' 'title': '格式' +'doc_type': 'reference' --- -# format 表函数 +# format Table Function -根据指定的输入格式解析来自参数的数据。如果未指定结构参数,则从数据中提取。 +根据指定的输入格式从参数中解析数据。如果未指定结构参数,则从数据中提取。 -## 语法 {#syntax} +## Syntax {#syntax} ```sql format(format_name, [structure], data) ``` -## 参数 {#arguments} +## Arguments {#arguments} - `format_name` — 数据的 [格式](/sql-reference/formats)。 - `structure` - 表的结构。可选。格式为 'column1_name column1_type, column2_name column2_type, ...'。 -- `data` — 字符串文字或返回包含指定格式数据的字符串的常量表达式。 +- `data` — 字符串字面量或返回包含指定格式数据的字符串的常量表达式。 -## 返回值 {#returned_value} +## Returned value {#returned_value} -一张根据指定格式和指定或提取的结构从 `data` 参数解析的数据表。 +根据指定格式和指定或提取的结构,从 `data` 参数中解析出的数据表。 -## 示例 {#examples} +## Examples {#examples} 没有 `structure` 参数: -**查询:** +**Query:** ```sql SELECT * FROM format(JSONEachRow, $$ @@ -42,7 +43,7 @@ $$ $$) ``` -**结果:** +**Result:** ```response ┌───b─┬─a─────┐ @@ -53,7 +54,7 @@ $$) └─────┴───────┘ ``` -**查询:** +**Query:** ```sql DESC format(JSONEachRow, $$ @@ -64,7 +65,7 @@ $$ $$) ``` -**结果:** +**Result:** ```response ┌─name─┬─type──────────────┬─default_type─┬─default_expression─┬─comment─┬─codec_expression─┬─ttl_expression─┐ @@ -75,7 +76,7 @@ $$) 有 `structure` 参数: -**查询:** +**Query:** ```sql SELECT * FROM format(JSONEachRow, 'a String, b UInt32', $$ @@ -86,7 +87,7 @@ $$ $$) ``` -**结果:** +**Result:** ```response ┌─a─────┬───b─┐ │ Hello │ 111 │ @@ -96,6 +97,6 @@ $$) └───────┴─────┘ ``` -## 相关内容 {#related} +## Related {#related} -- [格式](../../interfaces/formats.md) +- [Formats](../../interfaces/formats.md) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/format.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/format.md.hash index 93c838d03de..81da12e6339 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/format.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/format.md.hash @@ -1 +1 @@ -dfaf6630377cccbc +a8983fbdd3f7ca27 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/fuzzJSON.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/fuzzJSON.md index 083ff2497bf..fe3b3e9effe 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/fuzzJSON.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/fuzzJSON.md @@ -1,15 +1,16 @@ --- -'description': '对 JSON 字符串进行随机变动的扰动。' +'description': '对 JSON 字符串进行随机变化。' 'sidebar_label': 'fuzzJSON' 'sidebar_position': 75 'slug': '/sql-reference/table-functions/fuzzJSON' 'title': 'fuzzJSON' +'doc_type': 'reference' --- # fuzzJSON 表函数 -扰动带有随机变化的 JSON 字符串。 +通过随机变体扰动 JSON 字符串。 ## 语法 {#syntax} @@ -19,26 +20,26 @@ fuzzJSON({ named_collection [, option=value [,..]] | json_str[, random_seed] }) ## 参数 {#arguments} -| 参数 | 描述 | -|------------------------------------|--------------------------------------------------------------------------------------------| -| `named_collection` | 一个 [NAMED COLLECTION](sql-reference/statements/create/named-collection.md)。 | -| `option=value` | 命名集合的可选参数及其值。 | -| `json_str` (String) | 表示 JSON 格式结构化数据的源字符串。 | -| `random_seed` (UInt64) | 产生稳定结果的手动随机种子。 | -| `reuse_output` (boolean) | 将模糊处理的输出作为下一个模糊器的输入。 | -| `malform_output` (boolean) | 生成一个无法解析为 JSON 对象的字符串。 | -| `max_output_length` (UInt64) | 生成或扰动的 JSON 字符串的最大允许长度。 | -| `probability` (Float64) | 扰动 JSON 字段(键值对)的概率。范围必须在 [0, 1] 之间。 | -| `max_nesting_level` (UInt64) | JSON 数据中允许的最大嵌套结构深度。 | -| `max_array_size` (UInt64) | JSON 数组允许的最大大小。 | -| `max_object_size` (UInt64) | 单个 JSON 对象单层中允许的最大字段数。 | -| `max_string_value_length` (UInt64) | 字符串值的最大长度。 | -| `min_key_length` (UInt64) | 最小键长度。至少应为 1。 | -| `max_key_length` (UInt64) | 最大键长度。如果指定,则应大于或等于 `min_key_length`。 | +| 参数 | 描述 | +|--------------------------------------|-------------------------------------------------------------------------------------------| +| `named_collection` | 一个 [NAMED COLLECTION](sql-reference/statements/create/named-collection.md)。 | +| `option=value` | 命名集合的可选参数及其值。 | +| `json_str` (字符串) | 表示结构化数据的 JSON 格式的源字符串。 | +| `random_seed` (UInt64) | 用于生成稳定结果的手动随机种子。 | +| `reuse_output` (布尔值) | 将一个模糊处理过程的输出重用作为下一个模糊器的输入。 | +| `malform_output` (布尔值) | 生成一个无法解析为 JSON 对象的字符串。 | +| `max_output_length` (UInt64) | 生成或扰动的 JSON 字符串的最大允许长度。 | +| `probability` (Float64) | 模糊 JSON 字段(键值对)的概率。必须在 [0, 1] 范围内。 | +| `max_nesting_level` (UInt64) | JSON 数据中嵌套结构的最大允许深度。 | +| `max_array_size` (UInt64) | JSON 数组的最大允许大小。 | +| `max_object_size` (UInt64) | 单个 JSON 对象的一层中字段的最大允许数。 | +| `max_string_value_length` (UInt64) | 字符串值的最大长度。 | +| `min_key_length` (UInt64) | 最小键长度。应至少为 1。 | +| `max_key_length` (UInt64) | 最大键长度。如果指定,应大于或等于 `min_key_length`。 | ## 返回值 {#returned_value} -一个包含扰动 JSON 字符串的单列表对象。 +一个表对象,包含一个包含扰动 JSON 字符串的单列。 ## 使用示例 {#usage-example} diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/fuzzJSON.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/fuzzJSON.md.hash index 427a166edbc..847e4053db6 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/fuzzJSON.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/fuzzJSON.md.hash @@ -1 +1 @@ -bda0598d82192c4f +2f031a6389b61ff4 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/fuzzQuery.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/fuzzQuery.md index 2400a0457bb..025d0a86eac 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/fuzzQuery.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/fuzzQuery.md @@ -1,15 +1,16 @@ --- -'description': '对给定的查询字符串进行随机变动。' +'description': '对给定的查询字符串进行随机变化。' 'sidebar_label': 'fuzzQuery' 'sidebar_position': 75 'slug': '/sql-reference/table-functions/fuzzQuery' 'title': 'fuzzQuery' +'doc_type': 'reference' --- # fuzzQuery 表函数 -对给定的查询字符串进行随机变化。 +扰动给定的查询字符串以产生随机变化。 ## 语法 {#syntax} @@ -20,10 +21,10 @@ fuzzQuery(query[, max_query_length[, random_seed]]) ## 参数 {#arguments} | 参数 | 描述 | -|--------------------|-----------------------------------------------------------------------------| -| `query` | (String) - 要进行模糊处理的源查询。 | -| `max_query_length` | (UInt64) - 在模糊处理过程中查询所能达到的最大长度。 | -| `random_seed` | (UInt64) - 用于生成稳定结果的随机种子。 | +|--------------------|----------------------------------------------------------------------------| +| `query` | (字符串) - 用于执行扰动的源查询。 | +| `max_query_length` | (UInt64) - 在扰动过程中查询可以达到的最大长度。 | +| `random_seed` | (UInt64) - 用于生成稳定结果的随机种子。 | ## 返回值 {#returned_value} diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/fuzzQuery.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/fuzzQuery.md.hash index 881e7c53d67..6ba9df5b1f2 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/fuzzQuery.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/fuzzQuery.md.hash @@ -1 +1 @@ -ee81db6ef68fdc31 +294e577febdbcf3a diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/gcs.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/gcs.md index c635864c196..ace957b896f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/gcs.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/gcs.md @@ -1,5 +1,5 @@ --- -'description': '提供一个类似表格的接口用于 `SELECT` 和 `INSERT` 数据到 Google Cloud Storage。需要 `Storage +'description': '提供一个类似表的接口来 `SELECT` 和 `INSERT` 数据从 Google Cloud Storage。需要 `Storage Object User` IAM 角色。' 'keywords': - 'gcs' @@ -8,16 +8,17 @@ 'sidebar_position': 70 'slug': '/sql-reference/table-functions/gcs' 'title': 'gcs' +'doc_type': 'reference' --- # gcs 表函数 -提供一个类表的接口,以 `SELECT` 和 `INSERT` 数据到 [Google Cloud Storage](https://cloud.google.com/storage/)。需要 [`Storage Object User` IAM 角色](https://cloud.google.com/storage/docs/access-control/iam-roles)。 +提供一个类似表的接口,以 `SELECT` 和 `INSERT` 数据到 [Google Cloud Storage](https://cloud.google.com/storage/)。需要 [`Storage Object User` IAM 角色](https://cloud.google.com/storage/docs/access-control/iam-roles)。 这是 [s3 表函数](../../sql-reference/table-functions/s3.md) 的别名。 -如果您的集群中有多个副本,您可以使用 [s3Cluster 函数](../../sql-reference/table-functions/s3Cluster.md)(可与 GCS 一起使用)来并行插入。 +如果您的集群中有多个副本,可以使用 [s3Cluster 函数](../../sql-reference/table-functions/s3Cluster.md)(可与 GCS 配合使用)来并行插入。 ## 语法 {#syntax} @@ -27,23 +28,23 @@ gcs(named_collection[, option=value [,..]]) ``` :::tip GCS -GCS 表函数通过使用 GCS XML API 和 HMAC 密钥与 Google Cloud Storage 集成。 -有关端点和 HMAC 的更多详细信息,请参见 [Google 互操作性文档](https://cloud.google.com/storage/docs/interoperability)。 +GCS 表函数通过使用 GCS XML API 和 HMAC 密钥与 Google Cloud Storage 集成。 +有关端点和 HMAC 的更多详细信息,请参见 [Google 互操作性文档]( https://cloud.google.com/storage/docs/interoperability)。 ::: ## 参数 {#arguments} -| 参数 | 描述 | -|--------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `url` | 文件的存储桶路径。支持只读模式下的以下通配符: `*`,`**`,`?`,`{abc,def}` 和 `{N..M}`,其中 `N`,`M` 是数字,`'abc'`,`'def'` 是字符串。 | -| `NOSIGN` | 如果在凭证位置提供此关键字,则所有请求将不被签名。 | -| `hmac_key` 和 `hmac_secret` | 指定要与给定端点一起使用的凭证的密钥。可选。 | -| `format` | 文件的 [格式](/sql-reference/formats)。 | -| `structure` | 表的结构。格式为 `'column1_name column1_type, column2_name column2_type, ...'`。 | -| `compression_method` | 该参数是可选的。支持的值: `none`,`gzip` 或 `gz`,`brotli` 或 `br`,`xz` 或 `LZMA`,`zstd` 或 `zst`。默认情况下,它将根据文件扩展名自动检测压缩方法。 | +| 参数 | 描述 | +|------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `url` | 文件的桶路径。支持只读模式下的以下通配符:`*`, `**`, `?`, `{abc,def}` 和 `{N..M}` 其中 `N`, `M` — 数字,`'abc'`, `'def'` — 字符串。 | +| `NOSIGN` | 如果在凭据位置提供此关键字,则所有请求将不会被签名。 | +| `hmac_key` 和 `hmac_secret` | 指定与给定端点一起使用的凭据的密钥。可选。 | +| `format` | 文件的 [格式](/sql-reference/formats)。 | +| `structure` | 表的结构。格式为 `'column1_name column1_type, column2_name column2_type, ...'`。 | +| `compression_method` | 此参数是可选的。支持的值:`none`, `gzip` 或 `gz`, `brotli` 或 `br`, `xz` 或 `LZMA`, `zstd` 或 `zst`。默认情况下,按文件扩展名自动检测压缩方法。 | :::note GCS -GCS 路径的格式与 Google XML API 的端点格式不同于 JSON API: +GCS 路径的格式为以下内容,因为 Google XML API 的端点与 JSON API 不同: ```text https://storage.googleapis.com/// @@ -52,20 +53,20 @@ https://storage.googleapis.com/// 而不是 ~~https://storage.cloud.google.com~~。 ::: -参数还可以通过 [命名集合](operations/named-collections.md) 传递。在这种情况下,`url`、`format`、`structure`、`compression_method` 的工作方式是相同的,并且支持一些额外的参数: +参数也可以通过 [命名集合](operations/named-collections.md) 传递。在这种情况下,`url`、`format`、`structure`、`compression_method` 的使用方式相同,并且支持一些额外的参数: -| 参数 | 描述 | -|--------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `access_key_id` | `hmac_key`,可选。 | -| `secret_access_key` | `hmac_secret`,可选。 | -| `filename` | 如果指定,则附加到 url。 | -| `use_environment_credentials` | 默认启用,允许通过环境变量传递额外参数 `AWS_CONTAINER_CREDENTIALS_RELATIVE_URI`,`AWS_CONTAINER_CREDENTIALS_FULL_URI`,`AWS_CONTAINER_AUTHORIZATION_TOKEN`,`AWS_EC2_METADATA_DISABLED`。 | -| `no_sign_request` | 默认禁用。 | -| `expiration_window_seconds` | 默认值为 120。 | +| 参数 | 描述 | +|------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `access_key_id` | `hmac_key`,可选。 | +| `secret_access_key` | `hmac_secret`,可选。 | +| `filename` | 如果指定,则附加到 url。 | +| `use_environment_credentials` | 默认启用,允许使用环境变量 `AWS_CONTAINER_CREDENTIALS_RELATIVE_URI`、`AWS_CONTAINER_CREDENTIALS_FULL_URI`、`AWS_CONTAINER_AUTHORIZATION_TOKEN`、`AWS_EC2_METADATA_DISABLED` 传递额外参数。 | +| `no_sign_request` | 默认禁用。 | +| `expiration_window_seconds` | 默认值为 120。 | ## 返回值 {#returned_value} -一个具有指定结构的表,用于在指定文件中读取或写入数据。 +具有指定结构的表,用于在指定文件中读取或写入数据。 ## 示例 {#examples} @@ -84,7 +85,7 @@ LIMIT 2; └─────────┴─────────┴─────────┘ ``` -类似但来自使用 `gzip` 压缩方法的文件: +从文件中使用 `gzip` 压缩方法的类似查询: ```sql SELECT * @@ -99,9 +100,9 @@ LIMIT 2; └─────────┴─────────┴─────────┘ ``` -## 使用 {#usage} +## 用法 {#usage} -假设我们在 GCS 上有多个文件,具有以下 URI: +假设我们在 GCS 上有多个文件,URI 如下: - 'https://storage.googleapis.com/my-test-bucket-768/some_prefix/some_file_1.csv' - 'https://storage.googleapis.com/my-test-bucket-768/some_prefix/some_file_2.csv' @@ -112,7 +113,7 @@ LIMIT 2; - 'https://storage.googleapis.com/my-test-bucket-768/another_prefix/some_file_3.csv' - 'https://storage.googleapis.com/my-test-bucket-768/another_prefix/some_file_4.csv' -计算以数字 1 到 3 结尾的文件中的行数: +统计文件中以数字 1 到 3 结尾的行数: ```sql SELECT count(*) @@ -125,7 +126,7 @@ FROM gcs('https://storage.googleapis.com/clickhouse_public_datasets/my-test-buck └─────────┘ ``` -计算这两个目录中所有文件的行数: +统计这两个目录中所有文件的总行数: ```sql SELECT count(*) @@ -139,10 +140,10 @@ FROM gcs('https://storage.googleapis.com/clickhouse_public_datasets/my-test-buck ``` :::warning -如果您的文件列表包含带有前导零的数字范围,请为每个数字单独使用带括号的构造,或使用 `?`。 +如果您的文件列表包含前导零的数字范围,请为每个数字单独使用大括号结构,或使用 `?`。 ::: -计算名为 `file-000.csv`,`file-001.csv`,...,`file-999.csv` 的文件中的总行数: +统计名为 `file-000.csv`、`file-001.csv`、...、`file-999.csv` 的文件中的总行数: ```sql SELECT count(*) @@ -169,19 +170,19 @@ INSERT INTO FUNCTION gcs('https://storage.googleapis.com/my-test-bucket-768/test SELECT name, value FROM existing_table; ``` -通配符 ** 可用于递归遍历目录。考虑下面的示例,它将递归获取 `my-test-bucket-768` 目录的所有文件: +Glob ** 可用于递归目录遍历。请考虑以下示例,它将递归获取 `my-test-bucket-768` 目录中的所有文件: ```sql SELECT * FROM gcs('https://storage.googleapis.com/my-test-bucket-768/**', 'CSV', 'name String, value UInt32', 'gzip'); ``` -下面从 `my-test-bucket` 目录中任何文件夹的所有 `test-data.csv.gz` 文件获取数据: +以下示例将递归获取 `my-test-bucket` 目录中的所有 `test-data.csv.gz` 文件: ```sql SELECT * FROM gcs('https://storage.googleapis.com/my-test-bucket-768/**/test-data.csv.gz', 'CSV', 'name String, value UInt32', 'gzip'); ``` -对于生产用例,建议使用 [命名集合](operations/named-collections.md)。以下是示例: +对于生产使用情况,建议使用 [命名集合](operations/named-collections.md)。以下是示例: ```sql CREATE NAMED COLLECTION creds AS @@ -193,28 +194,28 @@ FROM gcs(creds, url='https://s3-object-url.csv') ## 分区写入 {#partitioned-write} -如果在将数据插入到 `GCS` 表时指定了 `PARTITION BY` 表达式,则会为每个分区值创建一个单独的文件。将数据拆分为单独的文件有助于提高读取操作的效率。 +如果在将数据插入到 `GCS` 表时指定 `PARTITION BY` 表达式,则为每个分区值创建一个单独的文件。将数据拆分成单独的文件有助于提高读取操作的效率。 **示例** -1. 在键中使用分区 ID 创建单独的文件: +1. 在键中使用分区 ID 会创建独立的文件: ```sql INSERT INTO TABLE FUNCTION gcs('http://bucket.amazonaws.com/my_bucket/file_{_partition_id}.csv', 'CSV', 'a String, b UInt32, c UInt32') PARTITION BY a VALUES ('x', 2, 3), ('x', 4, 5), ('y', 11, 12), ('y', 13, 14), ('z', 21, 22), ('z', 23, 24); ``` -最终数据写入三个文件:`file_x.csv`,`file_y.csv`,和 `file_z.csv`。 +结果是数据写入三个文件:`file_x.csv`、`file_y.csv` 和 `file_z.csv`。 -2. 在桶名称中使用分区 ID 在不同桶中创建文件: +2. 在存储桶名称中使用分区 ID 会在不同的存储桶中创建文件: ```sql INSERT INTO TABLE FUNCTION gcs('http://bucket.amazonaws.com/my_bucket_{_partition_id}/file.csv', 'CSV', 'a UInt32, b UInt32, c UInt32') PARTITION BY a VALUES (1, 2, 3), (1, 4, 5), (10, 11, 12), (10, 13, 14), (20, 21, 22), (20, 23, 24); ``` -最终数据写入三个不同桶中的文件:`my_bucket_1/file.csv`,`my_bucket_10/file.csv`,和 `my_bucket_20/file.csv`。 +结果是数据写入不同存储桶中的三个文件:`my_bucket_1/file.csv`、`my_bucket_10/file.csv` 和 `my_bucket_20/file.csv`。 -## 相关链接 {#related} +## 相关 {#related} - [S3 表函数](s3.md) - [S3 引擎](../../engines/table-engines/integrations/s3.md) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/gcs.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/gcs.md.hash index 68106a2b6ca..786b804e705 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/gcs.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/gcs.md.hash @@ -1 +1 @@ -5db694751b3809f9 +f903e504bcb1b311 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/generate.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/generate.md index 29162e38a34..aca33d7e6c2 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/generate.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/generate.md @@ -1,17 +1,18 @@ --- -'description': '生成具有给定架构的随机数据。允许用该数据填充测试表。并非所有类型都受支持。' +'description': '生成具有给定架构的随机数据。允许用该数据填充测试表。并非所有类型都得到支持。' 'sidebar_label': 'generateRandom' 'sidebar_position': 75 'slug': '/sql-reference/table-functions/generate' 'title': 'generateRandom' +'doc_type': 'reference' --- # generateRandom 表函数 -生成具有给定架构的随机数据。 -允许用这些数据填充测试表。 -并非所有类型都受支持。 +生成具有给定模式的随机数据。 +允许用这些数据填充测试表。 +并非所有类型都受到支持。 ## 语法 {#syntax} @@ -21,17 +22,17 @@ generateRandom(['name TypeName[, name TypeName]...', [, 'random_seed'[, 'max_str ## 参数 {#arguments} -| 参数 | 描述 | -|---------------------|------------------------------------------------------------------------------------------------| -| `name` | 对应列的名称。 | -| `TypeName` | 对应列的类型。 | -| `random_seed` | 手动指定随机种子以产生稳定的结果。如果为 `NULL`,则随机生成种子。 | -| `max_string_length` | 所有生成字符串的最大长度。默认为 `10`。 | -| `max_array_length` | 所有生成数组或映射的最大元素数量。默认为 `10`。 | +| 参数 | 描述 | +|------------------------|------------------------------------------------------------------------------------------------| +| `name` | 相应列的名称。 | +| `TypeName` | 相应列的类型。 | +| `random_seed` | 手动指定随机种子以生成稳定的结果。如果为 `NULL` — 种子将随机生成。 | +| `max_string_length` | 所有生成字符串的最大长度。默认值为 `10`。 | +| `max_array_length` | 所有生成数组或映射的最大元素数量。默认值为 `10`。 | ## 返回值 {#returned_value} -具有请求架构的表对象。 +具有请求模式的表对象。 ## 使用示例 {#usage-example} @@ -48,7 +49,7 @@ SELECT * FROM generateRandom('a Array(Int8), d Decimal32(4), c Tuple(DateTime64( ``` ```sql -CREATE TABLE random (a Array(Int8), d Decimal32(4), c Tuple(DateTime64(3), UUID)) engine=Memory; +CREATE TABLE random (a Array(Int8), d Decimal32(4), c Tuple(DateTime64(3), UUID)) ENGINE=Memory; INSERT INTO random SELECT * FROM generateRandom() LIMIT 2; SELECT * FROM random; ``` @@ -74,7 +75,7 @@ SELECT * FROM generateRandom(generateRandomStructure(4, 101), 101) LIMIT 3; └─────────────────────┴─────────────────────┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┴─────────────────────────────────────────┘ ``` -缺少 `structure` 参数(在这种情况下,结构是随机的): +缺少 `structure` 参数时(在这种情况下,结构为随机): ```sql SELECT * FROM generateRandom() LIMIT 3; @@ -88,7 +89,7 @@ SELECT * FROM generateRandom() LIMIT 3; └──────┴────────────┴────────────────────────┴─────────────────────────┴──────────┘ ``` -对于随机结构和随机数据,使用随机种子: +随机种子同时用于随机结构和随机数据: ```sql SELECT * FROM generateRandom(11) LIMIT 3; @@ -103,7 +104,7 @@ SELECT * FROM generateRandom(11) LIMIT 3; ``` :::note -`generateRandom(generateRandomStructure(), [random seed], max_string_length, max_array_length)` 在 `max_array_length` 足够大的情况下,可能会由于复杂类型(`Array`、`Tuple`、`Map`、`Nested`)的深层嵌套(最多16层)而生成非常庞大的输出。 +`generateRandom(generateRandomStructure(), [random seed], max_string_length, max_array_length)` 当 `max_array_length` 足够大时,可以由于复杂类型(`Array`、`Tuple`、`Map`、`Nested`)的可能深层嵌套(最多 16)而生成非常大的输出。 ::: ## 相关内容 {#related-content} diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/generate.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/generate.md.hash index 50f77644fff..2d54b26609d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/generate.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/generate.md.hash @@ -1 +1 @@ -176e60aa3bb51547 +99fbbcc0c44fc791 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/generateSeries.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/generateSeries.md deleted file mode 100644 index 820b4bf5530..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/generateSeries.md +++ /dev/null @@ -1,10 +0,0 @@ ---- -'description': 'TODO: 添加描述' -'sidebar_label': 'generateSeries' -'sidebar_position': 147 -'slug': '/sql-reference/table-functions/generateSeries' -'title': 'TODO: 添加标题' ---- - -### Alias To {#alias-to} -[生成序列](generate_series.md) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/generateSeries.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/generateSeries.md.hash deleted file mode 100644 index 9cf35da1079..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/generateSeries.md.hash +++ /dev/null @@ -1 +0,0 @@ -ae3e1469fb796a65 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/generate_series.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/generate_series.md index f34c095f444..26026d5a30d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/generate_series.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/generate_series.md @@ -3,7 +3,8 @@ 'sidebar_position': 146 'sidebar_label': 'generate_series' 'title': 'generate_series (generateSeries)' -'description': '返回一个包含单个 `generate_series` 列 (UInt64)的表,该列包含从起始到结束的整数(包括起始和结束)。' +'description': '返回一个单一的 `generate_series` 列 (UInt64) 的表,该列包含从开始到结束(包括开始和结束)的整数。' +'doc_type': 'reference' --- @@ -13,13 +14,13 @@ ## 语法 {#syntax} -返回一个只有单个 'generate_series' 列 (`UInt64`) 的表,该列包含从起始值到结束值(包含)之间的整数: +返回一个包含单个 'generate_series' 列 (`UInt64`) 的表,该列包含从 start 到 stop 的整数(包括 start 和 stop): ```sql generate_series(START, STOP) ``` -返回一个只有单个 'generate_series' 列 (`UInt64`) 的表,该列包含从起始值到结束值(包含)之间的整数,值之间的间隔由 `STEP` 指定: +返回一个包含单个 'generate_series' 列 (`UInt64`) 的表,该列包含从 start 到 stop 的整数(包括 start 和 stop),值之间的间隔由 `STEP` 给出: ```sql generate_series(START, STOP, STEP) @@ -34,7 +35,7 @@ SELECT * FROM numbers(10, 5); SELECT * FROM generate_series(10, 14); ``` -以下查询返回内容相同但列名不同的表(但第二个选项更高效): +而以下查询返回内容相同但列名不同的表(但第二个选项更高效): ```sql SELECT * FROM numbers(10, 11) WHERE number % 3 == (10 % 3); diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/generate_series.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/generate_series.md.hash index 99c91a4892b..1c76a5f633f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/generate_series.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/generate_series.md.hash @@ -1 +1 @@ -f8735b2f86370f66 +69c3ee4ec7ef2ccd diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/hdfs.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/hdfs.md index 46d4e91d6e8..6a29f17b458 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/hdfs.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/hdfs.md @@ -1,18 +1,19 @@ --- -'description': '从 HDFS 中的文件创建一个表。这个表函数与 url 和 file 表函数相似。' +'description': '从 HDFS 中的文件创建一个表。这个表函数类似于 url 和 file 表函数。' 'sidebar_label': 'hdfs' 'sidebar_position': 80 'slug': '/sql-reference/table-functions/hdfs' 'title': 'hdfs' +'doc_type': 'reference' --- import ExperimentalBadge from '@theme/badges/ExperimentalBadge'; import CloudNotSupportedBadge from '@theme/badges/CloudNotSupportedBadge'; -# hdfs 表函数 +# hdfs 表函数 -从 HDFS 中的文件创建一个表。此表函数类似于 [url](../../sql-reference/table-functions/url.md) 和 [file](../../sql-reference/table-functions/file.md) 表函数。 +从 HDFS 中的文件创建表。此表函数类似于 [url](../../sql-reference/table-functions/url.md) 和 [file](../../sql-reference/table-functions/file.md) 表函数。 ## 语法 {#syntax} @@ -22,19 +23,19 @@ hdfs(URI, format, structure) ## 参数 {#arguments} -| 参数 | 描述 | -|------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `URI` | HDFS 中文件的相对 URI。对于只读模式,文件路径支持以下通配符:`*`、`?`、`{abc,def}` 和 `{N..M}`,其中 `N` 和 `M` 是数字,`'abc'`、`'def'` 是字符串。 | -| `format` | 文件的 [format](/sql-reference/formats)。 | -| `structure`| 表的结构。格式为 `'column1_name column1_type, column2_name column2_type, ...'`。 | +| 参数 | 描述 | +|-----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `URI` | HDFS 中文件的相对 URI。文件路径在只读模式下支持以下通配符:`*`, `?`, `{abc,def}` 和 `{N..M}` 其中 `N`,`M` 为数字,`'abc', 'def'` 为字符串。 | +| `format` | 文件的 [格式](/sql-reference/formats)。 | +| `structure`| 表的结构。格式为 `'column1_name column1_type, column2_name column2_type, ...'`。 | ## 返回值 {#returned_value} -具有指定结构的表,用于读取或写入指定文件中的数据。 +一个具有指定结构的表,用于读取或写入指定文件中的数据。 **示例** -来自 `hdfs://hdfs1:9000/test` 的表并选择前两行: +来自 `hdfs://hdfs1:9000/test` 的表,并从中选择前两行: ```sql SELECT * @@ -51,19 +52,19 @@ LIMIT 2 ## 路径中的通配符 {#globs_in_path} -路径可以使用通配符。文件必须匹配整个路径模式,而不仅仅是后缀或前缀。 +路径可以使用通配符。文件必须与整个路径模式匹配,而不仅仅是后缀或前缀。 -- `*` — 代表任意多个字符,除了 `/`,但包括空字符串。 -- `**` — 代表文件夹中的所有文件,递归查找。 -- `?` — 代表任意单个字符。 -- `{some_string,another_string,yet_another_one}` — 替换任意字符串 `'some_string'`、`'another_string'`、`'yet_another_one'`。字符串可以包含 `/` 符号。 -- `{N..M}` — 代表任何数字 `>= N` 和 `<= M`。 +- `*` — 表示任意多个除 `/` 以外的字符,包括空字符串。 +- `**` — 表示文件夹内的所有文件,递归查找。 +- `?` — 表示一个任意字符。 +- `{some_string,another_string,yet_another_one}` — 替换为任何字符串 `'some_string', 'another_string', 'yet_another_one'`。字符串可以包含 `/` 符号。 +- `{N..M}` — 表示任何数字 `>= N` 且 `<= M`。 -带有 `{}` 的构造与 [remote](remote.md) 和 [file](file.md) 表函数类似。 +使用 `{}` 的构造与 [remote](remote.md) 和 [file](file.md) 表函数相似。 **示例** -1. 假设我们在 HDFS 上有几个文件,URI 如下: +1. 假设我们在 HDFS 上有几个具有以下 URI 的文件: - 'hdfs://hdfs1:9000/some_dir/some_file_1' - 'hdfs://hdfs1:9000/some_dir/some_file_2' @@ -91,12 +92,12 @@ FROM hdfs('hdfs://hdfs1:9000/{some,another}_dir/*', 'TSV', 'name String, value U ``` :::note -如果您的文件列表包含带前导零的数字范围,则分别为每个数字使用花括号构造,或使用 `?`。 +如果文件列表中包含带前导零的数字范围,请为每个数字分别使用带大括号的构造,或使用 `?`。 ::: **示例** -查询名为 `file000`、`file001`、...、`file999` 的文件中的数据: +查询名为 `file000`, `file001`, ... , `file999` 的文件中的数据: ```sql SELECT count(*) @@ -110,22 +111,22 @@ FROM hdfs('hdfs://hdfs1:9000/big_dir/file{0..9}{0..9}{0..9}', 'CSV', 'name Strin - `_size` — 文件的大小(以字节为单位)。类型:`Nullable(UInt64)`。如果大小未知,则值为 `NULL`。 - `_time` — 文件的最后修改时间。类型:`Nullable(DateTime)`。如果时间未知,则值为 `NULL`。 -## Hive 风格的分区 {#hive-style-partitioning} +## use_hive_partitioning 设置 {#hive-style-partitioning} -当设置 `use_hive_partitioning` 为 1 时,ClickHouse 将检测路径中的 Hive 风格分区(`/name=value/`),并允许在查询中使用分区列作为虚拟列。这些虚拟列将拥有与分区路径相同的名称,但以 `_` 开头。 +当设置 `use_hive_partitioning` 为 1 时,ClickHouse 将在路径中检测 Hive 风格的分区(`/name=value/`),并允许在查询中将分区列用作虚拟列。这些虚拟列将与分区路径中的名称相同,但以 `_` 开头。 **示例** -使用通过 Hive 风格分区创建的虚拟列 +使用虚拟列,创建于 Hive 风格分区 ```sql -SELECT * from HDFS('hdfs://hdfs1:9000/data/path/date=*/country=*/code=*/*.parquet') where _date > '2020-01-01' and _country = 'Netherlands' and _code = 42; +SELECT * FROM HDFS('hdfs://hdfs1:9000/data/path/date=*/country=*/code=*/*.parquet') WHERE _date > '2020-01-01' AND _country = 'Netherlands' AND _code = 42; ``` ## 存储设置 {#storage-settings} - [hdfs_truncate_on_insert](operations/settings/settings.md#hdfs_truncate_on_insert) - 允许在插入之前截断文件。默认情况下禁用。 -- [hdfs_create_new_file_on_insert](operations/settings/settings.md#hdfs_create_new_file_on_insert) - 在每次插入时如果格式有后缀,则允许创建新文件。默认情况下禁用。 +- [hdfs_create_new_file_on_insert](operations/settings/settings.md#hdfs_create_new_file_on_insert) - 允许在每次插入时创建一个新文件(如果格式有后缀)。默认情况下禁用。 - [hdfs_skip_empty_files](operations/settings/settings.md#hdfs_skip_empty_files) - 允许在读取时跳过空文件。默认情况下禁用。 ## 相关 {#related} diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/hdfs.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/hdfs.md.hash index 6f14b7a71a3..a04f3d24ec8 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/hdfs.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/hdfs.md.hash @@ -1 +1 @@ -d10e7f8a0e548ab0 +85ce03de8fc29dc5 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/hdfsCluster.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/hdfsCluster.md index 42f586c1758..c30be202ae7 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/hdfsCluster.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/hdfsCluster.md @@ -1,15 +1,16 @@ --- -'description': '允许在指定集群中的多个节点上并行处理来自 HDFS 的文件。' +'description': '允许从指定集群中的多个节点并行处理来自 HDFS 的文件。' 'sidebar_label': 'hdfsCluster' 'sidebar_position': 81 'slug': '/sql-reference/table-functions/hdfsCluster' 'title': 'hdfsCluster' +'doc_type': 'reference' --- # hdfsCluster 表函数 -允许从指定集群中的多个节点并行处理 HDFS 中的文件。在发起者上,它会创建与集群中所有节点的连接,揭示 HDFS 文件路径中的星号,并动态调度每个文件。在工作节点上,它询问发起者下一个要处理的任务并进行处理。这一过程会重复,直到所有任务完成。 +允许从指定集群中的多个节点并行处理 HDFS 中的文件。在发起者上,它创建与集群中所有节点的连接,暴露 HDFS 文件路径中的星号,并动态分派每个文件。在工作节点上,它向发起者请求处理的下一个任务并进行处理。这个过程会重复,直到所有任务完成。 ## 语法 {#syntax} @@ -19,20 +20,20 @@ hdfsCluster(cluster_name, URI, format, structure) ## 参数 {#arguments} -| 参数 | 描述 | -|-----------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `cluster_name` | 用于构建远程和本地服务器地址及连接参数集的集群名称。 | -| `URI` | 文件或一组文件的 URI。支持只读模式下的以下通配符: `*`, `**`, `?`, `{'abc','def'}` 和 `{N..M}` 其中 `N`, `M` — 数字,`abc`, `def` — 字符串。有关更多信息,请参见 [路径中的通配符](../../engines/table-engines/integrations/s3.md#wildcards-in-path)。 | -| `format` | 文件的 [格式](/sql-reference/formats)。 | -| `structure` | 表的结构。格式为 `'column1_name column1_type, column2_name column2_type, ...'`。 | +| 参数 | 描述 | +|-----------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `cluster_name` | 用于构建对远程和本地服务器的地址和连接参数集的集群名称。 | +| `URI` | 指向文件或一系列文件的 URI。在只读模式下支持以下通配符:`*`, `**`, `?`, `{'abc','def'}` 和 `{N..M}`,其中 `N`、`M` 是数字,`abc`、`def` 是字符串。有关更多信息,请参见 [路径中的通配符](../../engines/table-engines/integrations/s3.md#wildcards-in-path)。 | +| `format` | 文件的 [格式](/sql-reference/formats)。 | +| `structure` | 表的结构。格式为 `'column1_name column1_type, column2_name column2_type, ...'`。 | ## 返回值 {#returned_value} -具有指定结构的表,用于读取指定文件中的数据。 +一个具有指定结构的表,用于读取指定文件中的数据。 ## 示例 {#examples} -1. 假设我们有一个名为 `cluster_simple` 的 ClickHouse 集群,以及以下 URI 的几个文件在 HDFS 上: +1. 假设我们有一个名为 `cluster_simple` 的 ClickHouse 集群,以及以下 URI 的几个文件位于 HDFS 上: - 'hdfs://hdfs1:9000/some_dir/some_file_1' - 'hdfs://hdfs1:9000/some_dir/some_file_2' @@ -41,7 +42,7 @@ hdfsCluster(cluster_name, URI, format, structure) - 'hdfs://hdfs1:9000/another_dir/some_file_2' - 'hdfs://hdfs1:9000/another_dir/some_file_3' -2. 查询这些文件中的行数: +2. 查询这些文件的行数: ```sql SELECT count(*) @@ -56,7 +57,7 @@ FROM hdfsCluster('cluster_simple', 'hdfs://hdfs1:9000/{some,another}_dir/*', 'TS ``` :::note -如果您的文件列表包含带有前导零的数字范围,请为每个数字单独使用大括号构造,或使用 `?`。 +如果文件列表中包含带前导零的数字范围,请为每个数字单独使用带括号的结构或使用 `?`。 ::: ## 相关 {#related} diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/hdfsCluster.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/hdfsCluster.md.hash index 0cdcdd64d86..d8746d8234b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/hdfsCluster.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/hdfsCluster.md.hash @@ -1 +1 @@ -427365719f5f8fd3 +026c83b10b94310d diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/hudi.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/hudi.md index 75033e0cafa..346b0a42eb8 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/hudi.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/hudi.md @@ -1,15 +1,16 @@ --- -'description': '提供对存储在 Amazon S3 中的 Apache Hudi 表的只读表状接口。' +'description': '提供对 Amazon S3 中 Apache Hudi 表的只读表格接口。' 'sidebar_label': 'hudi' 'sidebar_position': 85 'slug': '/sql-reference/table-functions/hudi' 'title': 'hudi' +'doc_type': 'reference' --- # hudi 表函数 -提供对 Amazon S3 中 Apache [Hudi](https://hudi.apache.org/) 表的只读表状接口。 +提供对Amazon S3中Apache [Hudi](https://hudi.apache.org/) 表的只读表状接口。 ## 语法 {#syntax} @@ -19,19 +20,27 @@ hudi(url [,aws_access_key_id, aws_secret_access_key] [,format] [,structure] [,co ## 参数 {#arguments} -| 参数 | 描述 | -|------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `url` | 存储在 S3 中的现有 Hudi 表的存储桶 URL。 | -| `aws_access_key_id`, `aws_secret_access_key` | AWS 账户用户的长期凭据。您可以使用这些凭据来验证您的请求。这些参数是可选的。如果未指定凭据,则使用 ClickHouse 配置中的凭据。有关更多信息,请参见 [使用 S3 进行数据存储](/engines/table-engines/mergetree-family/mergetree.md/#table_engine-mergetree-s3)。 | -| `format` | 文件的 [格式](/interfaces/formats)。 | -| `structure` | 表的结构。格式为 `'column1_name column1_type, column2_name column2_type, ...'`。 | -| `compression` | 参数是可选的。支持的值:`none`, `gzip/gz`, `brotli/br`, `xz/LZMA`, `zstd/zst`。默认情况下,压缩将通过文件扩展名自动检测。 | +| 参数 | 描述 | +|------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `url` | 指向S3中现有Hudi表的桶URL。 | +| `aws_access_key_id`, `aws_secret_access_key` | 用于[AWS](https://aws.amazon.com/)账户用户的长期凭证。您可以使用这些凭证来验证您的请求。这些参数是可选的。如果未指定凭证,将使用ClickHouse配置中的凭证。有关更多信息,请参见[使用S3进行数据存储](/engines/table-engines/mergetree-family/mergetree.md/#table_engine-mergetree-s3)。 | +| `format` | 文件的[格式](/interfaces/formats)。 | +| `structure` | 表的结构。格式为`'column1_name column1_type, column2_name column2_type, ...'`。 | +| `compression` | 该参数是可选的。支持的值有:`none`,`gzip/gz`,`brotli/br`,`xz/LZMA`,`zstd/zst`。默认情况下,压缩类型将通过文件扩展名进行自动检测。 | ## 返回值 {#returned_value} -具有指定结构的表,以读取在 S3 中指定的 Hudi 表的数据。 +具有指定结构的表,用于读取S3中指定Hudi表的数据。 -## 相关 {#related} +## 虚拟列 {#virtual-columns} -- [Hudi 引擎](/engines/table-engines/integrations/hudi.md) -- [Hudi 集群表函数](/sql-reference/table-functions/hudiCluster.md) +- `_path` — 文件路径。类型:`LowCardinality(String)`。 +- `_file` — 文件名。类型:`LowCardinality(String)`。 +- `_size` — 文件大小(以字节为单位)。类型:`Nullable(UInt64)`。如果文件大小未知,则值为`NULL`。 +- `_time` — 文件的最后修改时间。类型:`Nullable(DateTime)`。如果时间未知,则值为`NULL`。 +- `_etag` — 文件的etag。类型:`LowCardinality(String)`。如果etag未知,则值为`NULL`。 + +## 相关内容 {#related} + +- [Hudi引擎](/engines/table-engines/integrations/hudi.md) +- [Hudi集群表函数](/sql-reference/table-functions/hudiCluster.md) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/hudi.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/hudi.md.hash index d90bcc9ae79..9b65ccd23d6 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/hudi.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/hudi.md.hash @@ -1 +1 @@ -059b47d532e8f760 +e3334997eadb32d7 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/hudiCluster.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/hudiCluster.md index e3f6407c5d9..6d06688eb34 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/hudiCluster.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/hudiCluster.md @@ -1,9 +1,10 @@ --- -'description': '对 hudi 表函数的扩展。允许在指定的集群中并行处理来自 Apache Hudi 表的文件,存储在 Amazon S3 中。' +'description': '对 hudi 表函数的扩展。允许在指定集群中的多个节点上并行处理来自 Apache Hudi 表的文件。' 'sidebar_label': 'hudiCluster' 'sidebar_position': 86 'slug': '/sql-reference/table-functions/hudiCluster' 'title': 'hudiCluster 表函数' +'doc_type': 'reference' --- @@ -11,7 +12,7 @@ 这是对 [hudi](sql-reference/table-functions/hudi.md) 表函数的扩展。 -允许在指定集群中的多个节点上并行处理存储在 Amazon S3 中的 Apache [Hudi](https://hudi.apache.org/) 表文件。在发起者处,它与集群中的所有节点建立连接,并动态分配每个文件。在工作节点,它向发起者请求下一个要处理的任务并执行。这个过程重复进行,直到所有任务完成。 +允许在指定集群中的多个节点上并行处理存储在 Amazon S3 中的 Apache [Hudi](https://hudi.apache.org/) 表中的文件。在发起器上,它会创建与集群中所有节点的连接,并动态调度每个文件。在工作节点上,它会询问发起器下一个要处理的任务,并处理它。此过程会重复,直到所有任务完成。 ## 语法 {#syntax} @@ -21,18 +22,26 @@ hudiCluster(cluster_name, url [,aws_access_key_id, aws_secret_access_key] [,form ## 参数 {#arguments} -| 参数 | 描述 | -|-----------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `cluster_name` | 用于构建一组远程和本地服务器地址及连接参数的集群名称。 | -| `url` | 指向 S3 中现有 Hudi 表的存储桶 URL。 | -| `aws_access_key_id`, `aws_secret_access_key` | [AWS](https://aws.amazon.com/) 账户用户的长期凭证。您可以使用这些凭证来验证请求。这些参数都是可选的。如果未指定凭证,则将使用 ClickHouse 配置中的凭证。有关更多信息,请参见[使用 S3 进行数据存储](/engines/table-engines/mergetree-family/mergetree.md/#table_engine-mergetree-s3)。 | -| `format` | 文件的 [格式](/interfaces/formats)。 | -| `structure` | 表的结构。格式为 `'column1_name column1_type, column2_name column2_type, ...'`。 | -| `compression` | 该参数是可选的。支持的值有:`none`、`gzip/gz`、`brotli/br`、`xz/LZMA`、`zstd/zst`。默认情况下,压缩将根据文件扩展名自动检测。 | +| 参数 | 描述 | +|----------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `cluster_name` | 用于构建用于连接远程和本地服务器的一组地址和连接参数的集群名称。 | +| `url` | 存储在 S3 中的现有 Hudi 表的存储桶 URL。 | +| `aws_access_key_id`, `aws_secret_access_key` | 用于 [AWS](https://aws.amazon.com/) 账户用户的长期凭证。您可以使用这些凭证来验证您的请求。这些参数是可选的。如果未指定凭证,则将使用 ClickHouse 配置中的凭证。有关更多信息,请参见 [使用 S3 进行数据存储](/engines/table-engines/mergetree-family/mergetree.md/#table_engine-mergetree-s3)。 | +| `format` | 文件的 [格式](/interfaces/formats)。 | +| `structure` | 表的结构。格式为 `'column1_name column1_type, column2_name column2_type, ...'`。 | +| `compression` | 参数是可选的。支持的值:`none`、`gzip/gz`、`brotli/br`、`xz/LZMA`、`zstd/zst`。默认情况下,压缩将通过文件扩展名自动检测。 | ## 返回值 {#returned_value} -返回一个具有指定结构的表,以便从指定 S3 中的 Hudi 表读取数据。 +返回一个具有指定结构的表,以从 S3 中指定的 Hudi 表读取数据。 + +## 虚拟列 {#virtual-columns} + +- `_path` — 文件路径。类型:`LowCardinality(String)`。 +- `_file` — 文件名称。类型:`LowCardinality(String)`。 +- `_size` — 文件大小(以字节为单位)。类型:`Nullable(UInt64)`。如果文件大小未知,则值为 `NULL`。 +- `_time` — 文件的最后修改时间。类型:`Nullable(DateTime)`。如果时间未知,则值为 `NULL`。 +- `_etag` — 文件的 etag。类型:`LowCardinality(String)`。如果 etag 未知,则值为 `NULL`。 ## 相关 {#related} diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/hudiCluster.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/hudiCluster.md.hash index c298b3b2422..9235be35c0f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/hudiCluster.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/hudiCluster.md.hash @@ -1 +1 @@ -27dace113cc607a6 +e2eba63d7bb23123 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/iceberg.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/iceberg.md index e42c6c20d87..fc13fc90e8a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/iceberg.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/iceberg.md @@ -1,15 +1,16 @@ --- -'description': '提供对存储在 Amazon S3、Azure、HDFS 或本地的 Apache Iceberg 表的只读表状接口。' -'sidebar_label': 'iceberg' +'description': '提供对存储在 Amazon S3、Azure、HDFS 或本地的 Apache Iceberg TABLE 的只读表式接口。' +'sidebar_label': '冰山' 'sidebar_position': 90 'slug': '/sql-reference/table-functions/iceberg' -'title': 'iceberg' +'title': '冰山' +'doc_type': 'reference' --- # iceberg 表函数 {#iceberg-table-function} -提供对存储在 Amazon S3、Azure、HDFS 或本地的 Apache [Iceberg](https://iceberg.apache.org/) 表的只读表接口。 +提供对存储在 Amazon S3、Azure、HDFS 或本地的 Apache [Iceberg](https://iceberg.apache.org/) 表进行只读的表格接口。 ## 语法 {#syntax} @@ -29,7 +30,7 @@ icebergLocal(named_collection[, option=value [,..]]) ## 参数 {#arguments} -参数的描述与表函数 `s3`、`azureBlobStorage`、`HDFS` 和 `file` 中参数的描述相符。 +参数描述与表函数 `s3`、`azureBlobStorage`、`HDFS` 和 `file` 中的参数描述一致。 `format` 代表 Iceberg 表中数据文件的格式。 ### 返回值 {#returned-value} @@ -43,12 +44,12 @@ SELECT * FROM icebergS3('http://test.s3.amazonaws.com/clickhouse-bucket/test_tab ``` :::important -ClickHouse 目前支持通过 `icebergS3`、`icebergAzure`、`icebergHDFS` 和 `icebergLocal` 表函数以及 `IcebergS3`、`icebergAzure`、`IcebergHDFS` 和 `IcebergLocal` 表引擎读取 Iceberg 格式的 v1 和 v2。 +ClickHouse 当前支持通过 `icebergS3`、`icebergAzure`、`icebergHDFS` 和 `icebergLocal` 表函数以及 `IcebergS3`、`icebergAzure`、`IcebergHDFS` 和 `IcebergLocal` 表引擎读取 Iceberg 格式的 v1 和 v2。 ::: ## 定义命名集合 {#defining-a-named-collection} -以下是配置命名集合以存储 URL 和凭据的示例: +以下是配置一个命名集合以存储 URL 和凭证的示例: ```xml @@ -70,22 +71,33 @@ DESCRIBE icebergS3(iceberg_conf, filename = 'test_table') ``` ## 模式演进 {#schema-evolution} -目前,通过 ClickHouse,您可以读取模式随时间变化的 iceberg 表。我们目前支持读取添加和删除列的表,以及列的顺序发生变化的表。您还可以将一个必需值的列更改为允许 NULL 的列。此外,我们支持简单类型的允许类型转换,即: + +目前,借助 CH,您可以读取模式随时间变化的 iceberg 表。我们当前支持读取添加和移除列的表,并支持列顺序的更改。您还可以将一个需要值的列更改为允许 NULL 的列。此外,我们支持简单类型的允许类型转换,例如: + * int -> long * float -> double * decimal(P, S) -> decimal(P', S),其中 P' > P。 -当前,无法更改嵌套结构或数组和地图中元素的类型。 +目前,不支持更改嵌套结构或数组和映射中元素的类型。 -## 分区修剪 {#partition-pruning} +## 分区剪枝 {#partition-pruning} -ClickHouse 支持在 SELECT 查询期间对 Iceberg 表进行分区修剪,这有助于通过跳过不相关的数据文件来优化查询性能。要启用分区修剪,需要设置 `use_iceberg_partition_pruning = 1`。有关 iceberg 分区修剪的更多信息,请访问 https://iceberg.apache.org/spec/#partitioning +ClickHouse 在针对 Iceberg 表的 SELECT 查询期间支持分区剪枝,这有助于通过跳过不相关的数据文件来优化查询性能。要启用分区剪枝,请设置 `use_iceberg_partition_pruning = 1`。有关 iceberg 分区剪枝的更多信息,请访问 https://iceberg.apache.org/spec/#partitioning ## 时间旅行 {#time-travel} ClickHouse 支持 Iceberg 表的时间旅行,允许您使用特定的时间戳或快照 ID 查询历史数据。 +## 处理删除行的表 {#deleted-rows} + +目前,仅支持具有 [位置删除](https://iceberg.apache.org/spec/#position-delete-files) 的 Iceberg 表。 + +以下删除方法 **不支持**: +- [相等删除](https://iceberg.apache.org/spec/#equality-delete-files) +- [删除向量](https://iceberg.apache.org/spec/#deletion-vectors)(在 v3 中引入) + ### 基本用法 {#basic-usage} + ```sql SELECT * FROM example_table ORDER BY 1 SETTINGS iceberg_timestamp_ms = 1714636800000 @@ -100,17 +112,17 @@ SETTINGS iceberg_snapshot_id = 3547395809148285433 ### 重要考虑事项 {#important-considerations} -- **快照** 通常在以下情况下创建: - - 新数据写入表时 - - 执行某种数据压缩 +* **快照** 通常在以下情况下创建: +* 向表中写入新数据 +* 执行某种数据压缩 -- **模式变化通常不会创建快照** - 这在使用经历模式演进的表进行时间旅行时会导致重要的行为。 +* **模式更改通常不创建快照** - 这在使用经历过模式演进的表的时间旅行时会产生重要的行为。 ### 示例场景 {#example-scenarios} -所有场景均在 Spark 中编写,因为 ClickHouse 目前不支持写入 Iceberg 表。 +所有场景均在 Spark 中编写,因为 CH 尚不支持写入 Iceberg 表。 -#### 场景 1: 模式变化而没有新的快照 {#scenario-1} +#### 场景 1:没有新快照的模式更改 {#scenario-1} 考虑以下操作序列: @@ -123,23 +135,23 @@ SETTINGS iceberg_snapshot_id = 3547395809148285433 USING iceberg OPTIONS ('format-version'='2') --- Insert data into the table +- - Insert data into the table INSERT INTO spark_catalog.db.time_travel_example VALUES (1, 'Mars') ts1 = now() // A piece of pseudo code --- Alter table to add a new column +- - Alter table to add a new column ALTER TABLE spark_catalog.db.time_travel_example ADD COLUMN (price double) ts2 = now() --- Insert data into the table +- - Insert data into the table INSERT INTO spark_catalog.db.time_travel_example VALUES (2, 'Venus', 100) ts3 = now() --- Query the table at each timestamp +- - Query the table at each timestamp SELECT * FROM spark_catalog.db.time_travel_example TIMESTAMP AS OF ts1; +------------+------------+ @@ -147,8 +159,6 @@ SETTINGS iceberg_snapshot_id = 3547395809148285433 +------------+------------+ | 1| Mars| +------------+------------+ - - SELECT * FROM spark_catalog.db.time_travel_example TIMESTAMP AS OF ts2; +------------+------------+ @@ -167,12 +177,12 @@ SETTINGS iceberg_snapshot_id = 3547395809148285433 +------------+------------+-----+ ``` -不同时间戳的查询结果: +在不同时间戳的查询结果: -- 在 ts1 和 ts2:仅出现原始的两列 -- 在 ts3:出现所有三列,第一行的价格为 NULL +* 在 ts1 和 ts2:仅显示原始的两列 +* 在 ts3:所有三列均显示,第一行的价格为 NULL -#### 场景 2: 历史与当前模式差异 {#scenario-2} +#### 场景 2:历史与当前模式差异 {#scenario-2} 当前时刻的时间旅行查询可能显示与当前表不同的模式: @@ -205,8 +215,6 @@ SETTINGS iceberg_snapshot_id = 3547395809148285433 -- Query the table at a current moment SELECT * FROM spark_catalog.db.time_travel_example_2; - - +------------+------------+-----+ |order_number|product_code|price| +------------+------------+-----+ @@ -214,11 +222,11 @@ SETTINGS iceberg_snapshot_id = 3547395809148285433 +------------+------------+-----+ ``` -这是因为 `ALTER TABLE` 不会创建新快照,而 Spark 在当前表上采用最新元数据文件的 `schema_id` 值,而不是快照。 +这是因为 `ALTER TABLE` 不会创建新快照,而对于当前表,Spark 从最新的元数据文件获取 `schema_id` 的值,而不是快照。 -#### 场景 3: 历史与当前模式差异 {#scenario-3} +#### 场景 3:历史与当前模式差异 {#scenario-3} -第二种情况是,在进行时间旅行时,您无法获取写入表之前的状态: +第二个情况是,在进行时间旅行时无法获取写入任何数据之前的表状态: ```sql -- Create a table @@ -235,55 +243,234 @@ SETTINGS iceberg_snapshot_id = 3547395809148285433 SELECT * FROM spark_catalog.db.time_travel_example_3 TIMESTAMP AS OF ts; -- Finises with error: Cannot find a snapshot older than ts. ``` -在 Clickhouse 中,该行为与 Spark 一致。您可以将 Spark 的选择查询在思维中替换为 Clickhouse 的选择查询,效果是相同的。 +在 Clickhouse 中,其行为与 Spark 一致。您可以将 Spark 的 Select 查询心里替换为 Clickhouse 的 Select 查询,它的工作方式是一样的。 ## 元数据文件解析 {#metadata-file-resolution} -在 ClickHouse 中使用 `iceberg` 表函数时,系统需要找到描述 Iceberg 表结构的正确 metadata.json 文件。以下是此解析过程的工作方式: +在 ClickHouse 中使用 `iceberg` 表函数时,系统需要定位描述 Iceberg 表结构的正确 metadata.json 文件。以下是该解析过程的工作原理: -### 候选项搜索(优先顺序) {#candidate-search} +### 候选搜索(按优先顺序) {#candidate-search} 1. **直接路径指定**: - * 如果您设置了 `iceberg_metadata_file_path`,系统将使用此确切路径,并将其与 Iceberg 表目录路径组合。 - * 提供此设置时,忽略所有其他解析设置。 +* 如果您设置了 `iceberg_metadata_file_path`,系统将使用该确切路径并与 Iceberg 表目录路径组合。 +* 当提供此设置时,将忽略所有其他解析设置。 2. **表 UUID 匹配**: - * 如果指定了 `iceberg_metadata_table_uuid`,系统将: - * 仅查看 `metadata` 目录中的 `.metadata.json` 文件 - * 筛选包含与您指定的 UUID(不区分大小写)匹配的 `table-uuid` 字段的文件 +* 如果指定了 `iceberg_metadata_table_uuid`,系统将: + * 仅查看 `metadata` 目录中的 `.metadata.json` 文件 + * 筛选包含与您指定的 UUID(不区分大小写)匹配的 `table-uuid` 字段的文件 3. **默认搜索**: - * 如果未提供上述设置,则 `metadata` 目录中的所有 `.metadata.json` 文件都成为候选项 +* 如果未提供上述任何一个设置,`metadata` 目录中的所有 `.metadata.json` 文件将成为候选文件 ### 选择最新文件 {#most-recent-file} 在使用上述规则识别候选文件后,系统确定哪个是最新的: -* 如果启用了 `iceberg_recent_metadata_file_by_last_updated_ms_field`: - * 选择具有最大 `last-updated-ms` 值的文件 +* 如果启用 `iceberg_recent_metadata_file_by_last_updated_ms_field`: +* 将选择 `last-updated-ms` 值最大的文件 * 否则: - * 选择具有最高版本号的文件 - * (版号以 `V` 的形式出现在格式为 `V.metadata.json` 或 `V-uuid.metadata.json` 的文件名中) +* 将选择版本号最高的文件 +* (版本在格式为 `V.metadata.json` 或 `V-uuid.metadata.json` 的文件名中显示为 `V`) -**注意**:所有提及的设置均为表函数设置(不是全局或查询级别的设置),并必须如下所示进行指定: +**注意**:所有提到的设置都是表函数设置(不是全局或查询级别的设置),必须按下面所示指定: ```sql SELECT * FROM iceberg('s3://bucket/path/to/iceberg_table', SETTINGS iceberg_metadata_table_uuid = 'a90eed4c-f74b-4e5b-b630-096fb9d09021'); ``` -**注意**:虽然 Iceberg Catalogs 通常处理元数据解析,但 ClickHouse 中的 `iceberg` 表函数直接将存储在 S3 中的文件解释为 Iceberg 表,因此理解这些解析规则非常重要。 +**注意**:虽然 Iceberg Catalogs 通常处理元数据解析,但 ClickHouse 中的 `iceberg` 表函数直接将存储在 S3 中的文件解释为 Iceberg 表,这就是理解这些解析规则的重要原因。 ## 元数据缓存 {#metadata-cache} -`Iceberg` 表引擎和表函数支持元数据缓存,存储清单文件、清单列表和元数据 JSON 的信息。缓存存储在内存中。此功能由设置 `use_iceberg_metadata_files_cache` 控制,默认为启用状态。 +`Iceberg` 表引擎和表函数支持元数据缓存,存储清单文件、清单列表和元数据 json 的信息。缓存存储在内存中。此功能由设置 `use_iceberg_metadata_files_cache` 控制,默认启用。 ## 别名 {#aliases} 表函数 `iceberg` 现在是 `icebergS3` 的别名。 +## 虚拟列 {#virtual-columns} + +- `_path` — 文件路径。类型:`LowCardinality(String)`。 +- `_file` — 文件名称。类型:`LowCardinality(String)`。 +- `_size` — 文件大小(以字节为单位)。类型:`Nullable(UInt64)`。如果文件大小未知,则值为 `NULL`。 +- `_time` — 文件最后修改时间。类型:`Nullable(DateTime)`。如果时间未知,则值为 `NULL`。 +- `_etag` — 文件的 etag。类型:`LowCardinality(String)`。如果 etag 未知,则值为 `NULL`。 + +## 写入 iceberg 表 {#writes-into-iceberg-table} + +从版本 25.7 开始,ClickHouse 支持对用户的 Iceberg 表进行修改。 + +目前这是一个实验性功能,因此您首先需要启用它: + +```sql +SET allow_experimental_insert_into_iceberg = 1; +``` + +### 创建表 {#create-iceberg-table} + +要创建您自己的空 Iceberg 表,请使用与读取相同的命令,但显式指定模式。 +写入支持来自 iceberg 规范的所有数据格式,如 Parquet、Avro、ORC。 + +### 示例 {#example-iceberg-writes-create} + +```sql +CREATE TABLE iceberg_writes_example +( + x Nullable(String), + y Nullable(Int32) +) +ENGINE = IcebergLocal('/home/scanhex12/iceberg_example/') +``` + +注意:要创建版本提示文件,请启用 `iceberg_use_version_hint` 设置。 +如果您想压缩 metadata.json 文件,请在 `iceberg_metadata_compression_method` 设置中指定编解码器名称。 + +### INSERT {#writes-inserts} + +创建新表后,您可以使用普通的 ClickHouse 语法插入数据。 + +### 示例 {#example-iceberg-writes-insert} + +```sql +INSERT INTO iceberg_writes_example VALUES ('Pavel', 777), ('Ivanov', 993); + +SELECT * +FROM iceberg_writes_example +FORMAT VERTICAL; + +Row 1: +────── +x: Pavel +y: 777 + +Row 2: +────── +x: Ivanov +y: 993 +``` + +### DELETE {#iceberg-writes-delete} + +在 ClickHouse 中,也支持在适合读取合并的格式中删除额外行。 +此查询将创建一个包含位置删除文件的新快照。 + +注意:如果您希望将来用其他 Iceberg 引擎(如 Spark)读取您的表,您需要禁用设置 `output_format_parquet_use_custom_encoder` 和 `output_format_parquet_parallel_encoding`。 +这是因为 Spark 通过 parquet 字段 ID 读取这些文件,而 ClickHouse 在启用这些标志时目前不支持写入字段 ID。 +我们计划在未来修复这种行为。 + +### 示例 {#example-iceberg-writes-delete} + +```sql +ALTER TABLE iceberg_writes_example DELETE WHERE x != 'Ivanov'; + +SELECT * +FROM iceberg_writes_example +FORMAT VERTICAL; + +Row 1: +────── +x: Ivanov +y: 993 +``` + +### 模式演进 {#iceberg-writes-schema-evolution} + +ClickHouse 允许您添加、删除或修改简单类型(非元组、非数组、非映射)的列。 + +### 示例 {#example-iceberg-writes-evolution} + +```sql +ALTER TABLE iceberg_writes_example MODIFY COLUMN y Nullable(Int64); +SHOW CREATE TABLE iceberg_writes_example; + + ┌─statement─────────────────────────────────────────────────┐ +1. │ CREATE TABLE default.iceberg_writes_example ↴│ + │↳( ↴│ + │↳ `x` Nullable(String), ↴│ + │↳ `y` Nullable(Int64) ↴│ + │↳) ↴│ + │↳ENGINE = IcebergLocal('/home/scanhex12/iceberg_example/') │ + └───────────────────────────────────────────────────────────┘ + +ALTER TABLE iceberg_writes_example ADD COLUMN z Nullable(Int32); +SHOW CREATE TABLE iceberg_writes_example; + + ┌─statement─────────────────────────────────────────────────┐ +1. │ CREATE TABLE default.iceberg_writes_example ↴│ + │↳( ↴│ + │↳ `x` Nullable(String), ↴│ + │↳ `y` Nullable(Int64), ↴│ + │↳ `z` Nullable(Int32) ↴│ + │↳) ↴│ + │↳ENGINE = IcebergLocal('/home/scanhex12/iceberg_example/') │ + └───────────────────────────────────────────────────────────┘ + +SELECT * +FROM iceberg_writes_example +FORMAT VERTICAL; + +Row 1: +────── +x: Ivanov +y: 993 +z: ᴺᵁᴸᴸ + +ALTER TABLE iceberg_writes_example DROP COLUMN z; +SHOW CREATE TABLE iceberg_writes_example; + ┌─statement─────────────────────────────────────────────────┐ +1. │ CREATE TABLE default.iceberg_writes_example ↴│ + │↳( ↴│ + │↳ `x` Nullable(String), ↴│ + │↳ `y` Nullable(Int64) ↴│ + │↳) ↴│ + │↳ENGINE = IcebergLocal('/home/scanhex12/iceberg_example/') │ + └───────────────────────────────────────────────────────────┘ + +SELECT * +FROM iceberg_writes_example +FORMAT VERTICAL; + +Row 1: +────── +x: Ivanov +y: 993 +``` + +### 压缩 {#iceberg-writes-compaction} + +ClickHouse 支持 Iceberg 表的压缩。当前,它可以在更新元数据时将位置删除文件合并为数据文件。之前的快照 ID 和时间戳保持不变,因此时间旅行功能仍然可以使用相同的值。 + +如何使用它: + +```sql +SET allow_experimental_iceberg_compaction = 1 + +OPTIMIZE TABLE iceberg_writes_example; + +SELECT * +FROM iceberg_writes_example +FORMAT VERTICAL; + +Row 1: +────── +x: Ivanov +y: 993 +``` + +## 带有目录的表 {#iceberg-writes-catalogs} + +上述所有写入功能也可与 REST 和 Glue 目录一起使用。 +要使用它们,请创建一个具有 `IcebergS3` 引擎的表,并提供必要的设置: + +```sql +CREATE TABLE `database_name.table_name` ENGINE = IcebergS3('http://minio:9000/warehouse-rest/table_name/', 'minio_access_key', 'minio_secret_key') +SETTINGS storage_catalog_type="rest", storage_warehouse="demo", object_storage_endpoint="http://minio:9000/warehouse-rest", storage_region="us-east-1", storage_catalog_url="http://rest:8181/v1", +``` + ## 另请参见 {#see-also} -- [Iceberg 引擎](/engines/table-engines/integrations/iceberg.md) -- [Iceberg 集群表函数](/sql-reference/table-functions/icebergCluster.md) +* [Iceberg 引擎](/engines/table-engines/integrations/iceberg.md) +* [Iceberg 集群表函数](/sql-reference/table-functions/icebergCluster.md) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/iceberg.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/iceberg.md.hash index a7a2c63eb1d..8b1e32364eb 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/iceberg.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/iceberg.md.hash @@ -1 +1 @@ -c95ccfccd533866d +f1b28ac1bd6a5634 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/icebergCluster.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/icebergCluster.md index 964b2f2a7fc..5457f81cb0a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/icebergCluster.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/icebergCluster.md @@ -1,9 +1,10 @@ --- -'description': '对iceberg表函数的扩展,允许从指定集群中的多个节点并行处理Apache Iceberg的文件。' +'description': '一个扩展 iceberg 表函数的功能,允许从指定集群中的多个节点并行处理 Apache Iceberg 的文件。' 'sidebar_label': 'icebergCluster' 'sidebar_position': 91 'slug': '/sql-reference/table-functions/icebergCluster' 'title': 'icebergCluster' +'doc_type': 'reference' --- @@ -11,7 +12,7 @@ 这是对 [iceberg](/sql-reference/table-functions/iceberg.md) 表函数的扩展。 -允许在指定集群的多个节点上并行处理来自 Apache [Iceberg](https://iceberg.apache.org/) 的文件。在发起者上,它创建与集群中所有节点的连接,并动态调度每个文件。在工作节点上,它向发起者请求下一个待处理的任务并进行处理。这个过程会重复进行,直到所有任务完成。 +允许从指定集群中的多个节点并行处理来自 Apache [Iceberg](https://iceberg.apache.org/) 的文件。发起者与集群中的所有节点建立连接,并动态分发每个文件。在工作节点上,它会向发起者请求下一个要处理的任务并进行处理。这一过程会重复,直到所有任务完成。 ## 语法 {#syntax} @@ -28,12 +29,12 @@ icebergHDFSCluster(cluster_name, named_collection[, option=value [,..]]) ## 参数 {#arguments} -- `cluster_name` — 用于构建远程和本地服务器地址及连接参数的集群名称。 -- 所有其他参数的描述与相应的 [iceberg](/sql-reference/table-functions/iceberg.md) 表函数中的参数描述一致。 +- `cluster_name` — 用于构建远程和本地服务器的地址和连接参数集合的集群名称。 +- 所有其他参数的描述与等效的 [iceberg](/sql-reference/table-functions/iceberg.md) 表函数中的参数描述相符。 **返回值** -一个具有指定结构的表,用于从指定 Iceberg 表的集群中读取数据。 +一个表,具有指定的结构,用于从指定的 Iceberg 表中读取来自集群的数据。 **示例** @@ -41,7 +42,15 @@ icebergHDFSCluster(cluster_name, named_collection[, option=value [,..]]) SELECT * FROM icebergS3Cluster('cluster_simple', 'http://test.s3.amazonaws.com/clickhouse-bucket/test_table', 'test', 'test') ``` -**另见** +## 虚拟列 {#virtual-columns} + +- `_path` — 文件的路径。类型: `LowCardinality(String)`。 +- `_file` — 文件的名称。类型: `LowCardinality(String)`。 +- `_size` — 文件的大小(以字节为单位)。类型: `Nullable(UInt64)`。如果文件大小未知,值为 `NULL`。 +- `_time` — 文件的最后修改时间。类型: `Nullable(DateTime)`。如果时间未知,值为 `NULL`。 +- `_etag` — 文件的 etag。类型: `LowCardinality(String)`。如果 etag 未知,值为 `NULL`。 + +**另请参见** - [Iceberg 引擎](/engines/table-engines/integrations/iceberg.md) - [Iceberg 表函数](sql-reference/table-functions/iceberg.md) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/icebergCluster.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/icebergCluster.md.hash index 6ae3e334945..d6869056680 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/icebergCluster.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/icebergCluster.md.hash @@ -1 +1 @@ -2377239e9f50a026 +b35fd403f61ae5fa diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/index.md index dc0f1fa481b..4a0f453a391 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/index.md @@ -1,9 +1,10 @@ --- -'description': 'Table Functions 的文档' +'description': '表函数的文档' 'sidebar_label': '表函数' 'sidebar_position': 1 'slug': '/sql-reference/table-functions/' 'title': '表函数' +'doc_type': 'reference' --- @@ -11,6 +12,62 @@ 表函数是构造表的方法。 + +| 页面 | 描述 | +|-----|-----| +| [azureBlobStorage](/sql-reference/table-functions/azureBlobStorage) | 提供了一个类似表的接口,用于选择/插入 Azure Blob Storage 中的文件。类似于 s3 函数。 | +| [azureBlobStorageCluster](/sql-reference/table-functions/azureBlobStorageCluster) | 允许在指定集群中的多个节点上并行处理来自 Azure Blob 存储的文件。 | +| [clusterAllReplicas](/sql-reference/table-functions/cluster) | 允许访问集群中所有分片(在 `remote_servers` 部分配置)而无需创建分布式表。 | +| [deltaLake](/sql-reference/table-functions/deltalake) | 提供了一个只读的类似表的接口,用于访问 Amazon S3 中的 Delta Lake 表。 | +| [deltaLakeCluster](/sql-reference/table-functions/deltalakeCluster) | 这是对 deltaLake 表函数的扩展。 | +| [dictionary](/sql-reference/table-functions/dictionary) | 以 ClickHouse 表的形式显示字典数据。与 Dictionary 引擎的工作方式相同。 | +| [executable](/engines/table-functions/executable) | `executable` 表函数基于您在脚本中定义的用户定义函数(UDF)的输出创建一个表,该函数将行输出到 **stdout**。 | +| [file](/sql-reference/table-functions/file) | 一个表引擎,提供一个类似表的接口,可以选择和插入文件,类似于 s3 表函数。在处理本地文件时使用 `file()`,在处理对象存储中的桶(如 S3、GCS 或 MinIO)时使用 `s3()`。 | +| [fileCluster](/sql-reference/table-functions/fileCluster) | 允许在集群内的多个节点上同时处理与指定路径匹配的文件。发起者建立与工作节点的连接,扩展文件路径中的通配符,并将文件读取任务委派给工作节点。每个工作节点都向发起者查询下一个要处理的文件,重复直到所有任务完成(所有文件都被读取)。 | +| [format](/sql-reference/table-functions/format) | 根据指定的输入格式解析来自参数的数据。如果未指定结构参数,则从数据中提取。 | +| [gcs](/sql-reference/table-functions/gcs) | 提供了一个类似表的接口,用于 `SELECT` 和 `INSERT` 数据从 Google Cloud Storage。需要 `Storage Object User` IAM 角色。 | +| [fuzzQuery](/sql-reference/table-functions/fuzzQuery) | 对给定的查询字符串进行随机变换。 | +| [fuzzJSON](/sql-reference/table-functions/fuzzJSON) | 对 JSON 字符串进行随机变换。 | +| [generateRandom](/sql-reference/table-functions/generate) | 生成带有给定模式的随机数据。允许用这些数据填充测试表。不支持所有类型。 | +| [mergeTreeProjection](/sql-reference/table-functions/mergeTreeProjection) | 表示 MergeTree 表中的某些投影的内容。可用于自省。 | +| [mergeTreeIndex](/sql-reference/table-functions/mergeTreeIndex) | 表示 MergeTree 表中索引和标记文件的内容。可用于自省。 | +| [hdfs](/sql-reference/table-functions/hdfs) | 从 HDFS 中的文件创建表。该表函数类似于 url 和 file 表函数。 | +| [hdfsCluster](/sql-reference/table-functions/hdfsCluster) | 允许从指定集群中的多个节点并行处理 HDFS 中的文件。 | +| [hudi](/sql-reference/table-functions/hudi) | 提供了一个只读的类似表的接口,用于访问 Amazon S3 中的 Apache Hudi 表。 | +| [ytsaurus](/sql-reference/table-functions/ytsaurus) | 该表函数允许从 YTsaurus 集群读取数据。 | +| [hudiCluster Table Function](/sql-reference/table-functions/hudiCluster) | 对 hudi 表函数的扩展。允许在指定集群中的多个节点上并行处理来自 Amazon S3 的 Apache Hudi 表中的文件。 | +| [iceberg](/sql-reference/table-functions/iceberg) | 提供了一个只读的类似表的接口,用于访问存储在 Amazon S3、Azure、HDFS 或本地的 Apache Iceberg 表。 | +| [icebergCluster](/sql-reference/table-functions/icebergCluster) | iceberg 表函数的扩展,允许在指定集群中多个节点上并行处理来自 Apache Iceberg 的文件。 | +| [input](/sql-reference/table-functions/input) | 表函数,允许有效地将以给定结构发送到服务器的数据转换并插入到具有另一结构的表中。 | +| [jdbc](/sql-reference/table-functions/jdbc) | 返回通过 JDBC 驱动程序连接的表。 | +| [merge](/sql-reference/table-functions/merge) | 创建一个临时 Merge 表。结构将通过使用其列的并集和推导共同类型从基础表中得出。 | +| [mongodb](/sql-reference/table-functions/mongodb) | 允许对存储在远程 MongoDB 服务器上的数据执行 `SELECT` 查询。 | +| [mysql](/sql-reference/table-functions/mysql) | 允许对存储在远程 MySQL 服务器上的数据执行 `SELECT` 和 `INSERT` 查询。 | +| [null](/sql-reference/table-functions/null) | 创建一个指定结构的临时表,使用 Null 表引擎。该函数用于便于测试编写和演示。 | +| [timeSeriesMetrics](/sql-reference/table-functions/timeSeriesMetrics) | timeSeriesMetrics 返回表 `db_name.time_series_table` 的度量表,其表引擎是 TimeSeries 引擎。 | +| [timeSeriesSelector](/sql-reference/table-functions/timeSeriesSelector) | 从时间序列表中读取由选择器过滤的时间序列,时间戳位于指定时间间隔内。 | +| [timeSeriesTags](/sql-reference/table-functions/timeSeriesTags) | timeSeriesTags 表函数返回表 `db_name.time_series_table` 的标签表,其表引擎是 TimeSeries 引擎。 | +| [prometheusQueryRange](/sql-reference/table-functions/prometheusQueryRange) | 使用来自时间序列表的数据评估一个 prometheus 查询。 | +| [zeros](/sql-reference/table-functions/zeros) | 用于测试目的的最快生成多行的方法。类似于 `system.zeros` 和 `system.zeros_mt` 系统表。 | +| [timeSeriesData](/sql-reference/table-functions/timeSeriesData) | timeSeriesData 返回表 `db_name.time_series_table` 使用的数据表,其表引擎是 TimeSeries。 | +| [numbers](/sql-reference/table-functions/numbers) | 返回一个包含可指定整数的单一 `number` 列的表。 | +| [prometheusQuery](/sql-reference/table-functions/prometheusQuery) | 使用来自时间序列表的数据评估一个 prometheus 查询。 | +| [generate_series (generateSeries)](/sql-reference/table-functions/generate_series) | 返回一个包含从起始到结束(含起止)的整数的单一 `generate_series` 列(UInt64)的表。 | +| [odbc](/sql-reference/table-functions/odbc) | 返回通过 ODBC 连接的表。 | +| [postgresql](/sql-reference/table-functions/postgresql) | 允许对存储在远程 PostgreSQL 服务器上的数据执行 `SELECT` 和 `INSERT` 查询。 | +| [redis](/sql-reference/table-functions/redis) | 该表函数允许将 ClickHouse 与 Redis 集成。 | +| [remote, remoteSecure](/sql-reference/table-functions/remote) | 表函数 `remote` 允许动态访问远程服务器,即无需创建分布式表。表函数 `remoteSecure` 与 `remote` 相同,但通过安全连接。 | +| [s3 Table Function](/sql-reference/table-functions/s3) | 提供了一个类似表的接口,用于选择/插入亚马逊 S3 和谷歌云存储中的文件。该表函数类似于 hdfs 函数,但提供 S3 特定功能。 | +| [s3Cluster](/sql-reference/table-functions/s3Cluster) | 对 s3 表函数的扩展,允许在指定集群中的多个节点上并行处理来自 Amazon S3 和 Google Cloud Storage 的文件。 | +| [sqlite](/sql-reference/table-functions/sqlite) | 允许对存储在 SQLite 数据库中的数据执行查询。 | +| [arrowFlight](/sql-reference/table-functions/arrowflight) | 允许对通过 Apache Arrow Flight 服务器公开的数据执行查询。 | +| [url](/sql-reference/table-functions/url) | 根据给定的 `format` 和 `structure` 从 `URL` 创建表 | +| [urlCluster](/sql-reference/table-functions/urlCluster) | 允许从指定集群中的多个节点并行处理 URL 中的文件。 | +| [view](/sql-reference/table-functions/view) | 将子查询转换为表。该函数实现视图。 | +| [values](/sql-reference/table-functions/values) | 创建一个临时存储,将值填充到列中。 | +| [loop](/sql-reference/table-functions/loop) | ClickHouse 中的 loop 表函数用于在无限循环中返回查询结果。 | + + ## 用法 {#usage} 表函数可以在 `SELECT` 查询的 [`FROM`](../../sql-reference/statements/select/from.md) 子句中使用。例如,您可以使用 `file` 表函数从本地机器上的文件中 `SELECT` 数据。 @@ -26,7 +83,7 @@ echo "1, 2, 3" > example.csv └────┴────┴────┘ ``` -您也可以使用表函数创建仅在当前查询中可用的临时表。例如: +您还可以使用表函数创建只在当前查询中可用的临时表。例如: ```sql title="Query" SELECT * FROM generateSeries(1,5); @@ -41,7 +98,7 @@ SELECT * FROM generateSeries(1,5); └─────────────────┘ ``` -查询完成时,表将被删除。 +当查询结束时,表将被删除。 表函数可以作为创建表的一种方式,使用以下语法: @@ -66,7 +123,7 @@ SELECT * FROM series; └─────────────────┘ ``` -最后,表函数可以用于向表中 `INSERT` 数据。例如,我们可以再次使用 `file` 表函数将之前示例中创建的表的内容写入磁盘上的文件: +最后,表函数可以用于向表中 `INSERT` 数据。例如,我们可以再次使用 `file` 表函数将前一个示例中创建的表的内容写入磁盘上的文件: ```sql INSERT INTO FUNCTION file('numbers.csv', 'CSV') SELECT * FROM series; @@ -82,5 +139,5 @@ cat numbers.csv ``` :::note -如果 [allow_ddl](/operations/settings/settings#allow_ddl) 设置被禁用,您无法使用表函数。 +如果禁用 [allow_ddl](/operations/settings/settings#allow_ddl) 设置,则无法使用表函数。 ::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/index.md.hash index 49a2011ffb4..5bd9a6d380b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/index.md.hash @@ -1 +1 @@ -c81851446dd54881 +04dc52f269f28f30 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/input.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/input.md index 29cc3aaa1b6..d1e601de44e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/input.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/input.md @@ -1,28 +1,28 @@ --- -'description': '表函数,允许有效地将以给定结构发送到服务器的数据转换并插入到具有另一结构的表中。' +'description': '表函数,可以有效地将发送到服务器的具有给定结构的数据转换并插入到具有另一结构的表中。' 'sidebar_label': '输入' 'sidebar_position': 95 'slug': '/sql-reference/table-functions/input' 'title': '输入' +'doc_type': 'reference' --- # input 表函数 -`input(structure)` - 表函数,允许有效地将以给定结构发送到服务器的数据转换并插入到另一种结构的表中。 +`input(structure)` - 表函数,可以有效地将发送到服务器的数据转换并插入到具有另一种结构的表中。 -`structure` - 发送到服务器的数据结构,格式为 `'column1_name column1_type, column2_name column2_type, ...'`。 -例如,`'id UInt32, name String'`。 +`structure` - 发送到服务器的数据结构,格式为 `'column1_name column1_type, column2_name column2_type, ...'`。例如,`'id UInt32, name String'`。 -此函数仅可在 `INSERT SELECT` 查询中使用一次,但行为类似于普通表函数(例如,可以在子查询中使用等)。 +此函数仅可以在 `INSERT SELECT` 查询中使用一次,但其余行为类似于普通表函数(例如,可以在子查询中使用等)。 -数据可以通过任何方式发送,就像普通的 `INSERT` 查询一样,并可以通过查询末尾指定的任何可用 [format](/sql-reference/formats) 传递(与普通的 `INSERT SELECT` 不同)。 +数据可以像普通的 `INSERT` 查询一样以任何方式发送,并且可以使用任何可用的 [format](/sql-reference/formats) 进行传递,该格式必须在查询末尾指定(与普通的 `INSERT SELECT` 不同)。 -此函数的主要特点是,当服务器从客户端接收数据时,它会根据 `SELECT` 子句中的表达式列表同时转换数据并插入目标表。不会创建包含所有传输数据的临时表。 +该函数的主要特点是当服务器从客户端接收到数据时,它同时根据 `SELECT` 子句中的表达式列表进行转换,并插入目标表。不会创建包含所有传输数据的临时表。 ## 示例 {#examples} -- 假设 `test` 表具有以下结构 `(a String, b String)`,而 `data.csv` 中的数据具有不同结构 `(col1 String, col2 Date, col3 Int32)`。将 `data.csv` 中的数据插入 `test` 表并同时进行转换的查询如下所示: +- 假设 `test` 表的结构为 `(a String, b String)`,而 `data.csv` 的数据结构为 `(col1 String, col2 Date, col3 Int32)`。将 `data.csv` 中的数据插入到 `test` 表的查询,看起来是这样的: @@ -30,7 +30,7 @@ $ cat data.csv | clickhouse-client --query="INSERT INTO test SELECT lower(col1), col3 * col3 FROM input('col1 String, col2 Date, col3 Int32') FORMAT CSV"; ``` -- 如果 `data.csv` 包含与表 `test` 相同结构的 `test_structure` 数据,那么这两个查询是等价的: +- 如果 `data.csv` 包含与表 `test` 相同结构 `test_structure` 的数据,则这两个查询是相等的: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/input.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/input.md.hash index 1d9108e3129..4a5d7d2a738 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/input.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/input.md.hash @@ -1 +1 @@ -6feb968a9ff77838 +416c2e32b95bbef3 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/jdbc.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/jdbc.md index 0f1bb52153f..a1a8772de8f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/jdbc.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/jdbc.md @@ -4,23 +4,34 @@ 'sidebar_position': 100 'slug': '/sql-reference/table-functions/jdbc' 'title': 'jdbc' +'doc_type': 'reference' --- # jdbc 表函数 :::note -clickhouse-jdbc-bridge 包含实验性代码,并且不再支持。它可能包含可靠性问题和安全漏洞。请自行承担风险使用它。 -ClickHouse 推荐使用 ClickHouse 内置的表函数,这为临时查询场景(如 Postgres、MySQL、MongoDB 等)提供了更好的替代方案。 +clickhouse-jdbc-bridge 包含实验性代码,不再支持。它可能包含可靠性问题和安全漏洞。使用时需自行承担风险。 +ClickHouse 推荐使用 ClickHouse 中的内置表函数,这些表函数为即席查询场景(Postgres, MySQL, MongoDB 等)提供了更好的替代方案。 ::: -`jdbc(datasource, schema, table)` - 返回通过 JDBC 驱动程序连接的表。 +JDBC 表函数返回通过 JDBC 驱动程序连接的表。 此表函数需要单独运行 [clickhouse-jdbc-bridge](https://github.com/ClickHouse/clickhouse-jdbc-bridge) 程序。 -它支持 Nullable 类型(基于查询的远程表的 DDL)。 +它支持 Nullable 类型(基于被查询的远程表的 DDL)。 + +## 语法 {#syntax} + +```sql +jdbc(datasource, external_database, external_table) +jdbc(datasource, external_table) +jdbc(named_collection) +``` ## 示例 {#examples} +可以指定模式,而不是外部数据库名称: + ```sql SELECT * FROM jdbc('jdbc:mysql://localhost:3306/?user=root&password=root', 'schema', 'table') ``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/jdbc.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/jdbc.md.hash index 29333ad8dc3..59811788d49 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/jdbc.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/jdbc.md.hash @@ -1 +1 @@ -cb33c0b276d492b6 +20b7e0a71937346f diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/loop.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/loop.md index fceb1f71c58..d3990a84ef4 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/loop.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/loop.md @@ -1,13 +1,14 @@ --- -'description': '在 ClickHouse 中,loop 表函数用于在无限循环中返回查询结果。' +'description': 'ClickHouse 中的 loop 表函数用于以无限循环的方式返回查询结果。' 'slug': '/sql-reference/table-functions/loop' 'title': '循环' +'doc_type': 'reference' --- -# loop Table Function +# loop 表函数 -## Syntax {#syntax} +## 语法 {#syntax} ```sql SELECT ... FROM loop(database, table); @@ -16,21 +17,21 @@ SELECT ... FROM loop(table); SELECT ... FROM loop(other_table_function(...)); ``` -## Arguments {#arguments} +## 参数 {#arguments} -| 参数 | 描述 | -|------------------------------|---------------------------------------------------------------------------------------------------------------------| -| `database` | 数据库名称。 | -| `table` | 表名称。 | -| `other_table_function(...)` | 其他表函数。示例:`SELECT * FROM loop(numbers(10));` 这里的 `other_table_function(...)` 是 `numbers(10)`。 | +| 参数 | 描述 | +|-----------------------------|----------------------------------------------------------------------------------------------------------------------| +| `database` | 数据库名称。 | +| `table` | 表名称。 | +| `other_table_function(...)` | 其他表函数。示例:`SELECT * FROM loop(numbers(10));` 这里的 `other_table_function(...)` 是 `numbers(10)`。 | -## Returned values {#returned_values} +## 返回值 {#returned_values} 无限循环以返回查询结果。 -## Examples {#examples} +## 示例 {#examples} -从 ClickHouse 中选择数据: +从 ClickHouse 选择数据: ```sql SELECT * FROM loop(test_database, test_table); diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/loop.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/loop.md.hash index ff961672ef6..561c338357c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/loop.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/loop.md.hash @@ -1 +1 @@ -59d318d8efb74e5f +2ad5392ff6a2aa5b diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/merge.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/merge.md index e251a34c528..e096be29a91 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/merge.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/merge.md @@ -1,15 +1,16 @@ --- -'description': '创建一个临时 Merge 表。该结构将通过使用其列的联合和推导共同类型从基础表中导出。' +'description': '创建一个临时的 Merge 表。该结构将通过对其列的联合和派生公共类型来从基础表中获取。' 'sidebar_label': '合并' 'sidebar_position': 130 'slug': '/sql-reference/table-functions/merge' 'title': '合并' +'doc_type': 'reference' --- # merge Table Function -创建一个临时 [Merge](../../engines/table-engines/special/merge.md) 表。该结构将通过对其列的联合以及推导公共类型来自底层表。 +创建一个临时 [Merge](../../engines/table-engines/special/merge.md) 表。该结构将通过使用其列的并集和推导公共类型从基础表中派生。 ## Syntax {#syntax} @@ -20,7 +21,7 @@ merge(['db_name',] 'tables_regexp') | Argument | Description | |-----------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `db_name` | 可能值(可选,默认是 `currentDatabase()`):
- 数据库名称,
- 返回数据库名称字符串的常数表达式,例如 `currentDatabase()`,
- `REGEXP(expression)`,其中 `expression` 是用于匹配数据库名称的正则表达式。 | +| `db_name` | 可选值(默认是 `currentDatabase()`):
- 数据库名称,
- 返回数据库名称字符串的常量表达式,例如 `currentDatabase()`,
- `REGEXP(expression)`,其中 `expression` 是与数据库名称匹配的正则表达式。 | | `tables_regexp` | 用于匹配指定数据库或数据库中的表名称的正则表达式。 | ## Related {#related} diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/merge.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/merge.md.hash index 9ce79ed5f1a..a6619c440e2 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/merge.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/merge.md.hash @@ -1 +1 @@ -d1aa70d38f6efc01 +cf9c863ea9baa427 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/mergeTreeIndex.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/mergeTreeIndex.md index c8b5af4309c..16fb394fe83 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/mergeTreeIndex.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/mergeTreeIndex.md @@ -1,41 +1,43 @@ --- -'description': '表示 MergeTree 表的索引和标记文件的内容。可以用于 introspection。' +'description': '表示 MergeTree 表的索引和标记文件的内容。它可以用于 introspection。' 'sidebar_label': 'mergeTreeIndex' 'sidebar_position': 77 'slug': '/sql-reference/table-functions/mergeTreeIndex' 'title': 'mergeTreeIndex' +'doc_type': 'reference' --- # mergeTreeIndex 表函数 -表示 MergeTree 表的索引和标记文件的内容。可以用于内省。 +表示 MergeTree 表的索引和标记文件的内容。可以用于内部观察。 ## 语法 {#syntax} ```sql -mergeTreeIndex(database, table, [with_marks = true]) +mergeTreeIndex(database, table [, with_marks = true] [, with_minmax = true]) ``` ## 参数 {#arguments} -| 参数 | 描述 | -|---------------|---------------------------------------------------| -| `database` | 要从中读取索引和标记的数据库名称。 | -| `table` | 要从中读取索引和标记的表名称。 | -| `with_marks` | 是否在结果中包含带标记的列。 | +| 参数 | 描述 | +|---------------|-------------------------------------------------| +| `database` | 要从中读取索引和标记的数据库名称。 | +| `table` | 要从中读取索引和标记的表名称。 | +| `with_marks` | 是否将带有标记的列包含到结果中。 | +| `with_minmax` | 是否将最小最大索引包含到结果中。 | ## 返回值 {#returned_value} -一个表对象,包含源表主键的列的值,带标记的列的值(如果启用)以及源表数据部分中所有可能文件的虚拟列: +一个表对象,包含源表的主索引值和最小最大索引值(如果启用)、所有可能的文件在源表的数据部分中的标记值的列以及虚拟列: - `part_name` - 数据部分的名称。 - `mark_number` - 数据部分中当前标记的编号。 - `rows_in_granule` - 当前粒度中的行数。 -在数据部分中如果缺少列或其某个子流的标记未被写入(例如在紧凑部分中),标记列可能包含 `(NULL, NULL)` 值。 +当数据部分中缺少列或其子流的标记未被写入(例如,在紧凑部分中)时,标记列可能包含 `(NULL, NULL)` 值。 -## 示例用法 {#usage-example} +## 使用示例 {#usage-example} ```sql CREATE TABLE test_table diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/mergeTreeIndex.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/mergeTreeIndex.md.hash index 364cdd74144..31251c77e2e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/mergeTreeIndex.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/mergeTreeIndex.md.hash @@ -1 +1 @@ -79a8bfb4f2e8321b +e5572fb7c0a25723 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/mergeTreeProjection.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/mergeTreeProjection.md index ff19e028d12..70114b560ca 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/mergeTreeProjection.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/mergeTreeProjection.md @@ -1,9 +1,10 @@ --- -'description': '表示MergeTree表中某些投影的内容。它可以用于自省。' +'description': '表示 MergeTree 表中某些投影的内容。它可以用于自省。' 'sidebar_label': 'mergeTreeProjection' 'sidebar_position': 77 'slug': '/sql-reference/table-functions/mergeTreeProjection' 'title': 'mergeTreeProjection' +'doc_type': 'reference' --- @@ -19,15 +20,15 @@ mergeTreeProjection(database, table, projection) ## 参数 {#arguments} -| 参数 | 描述 | -|--------------|-------------------------------------------------| -| `database` | 要从中读取投影的数据库名称。 | -| `table` | 要从中读取投影的表名称。 | -| `projection` | 要读取的投影。 | +| 参数 | 描述 | +|-------------|-----------------------------------------------| +| `database` | 要读取投影的数据库名称。 | +| `table` | 要读取投影的表名称。 | +| `projection`| 要读取的投影。 | ## 返回值 {#returned_value} -一个表对象,包含由给定投影提供的列。 +一个带有给定投影提供的列的表对象。 ## 使用示例 {#usage-example} diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/mergeTreeProjection.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/mergeTreeProjection.md.hash index 4742f4e64e1..278318f1cb1 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/mergeTreeProjection.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/mergeTreeProjection.md.hash @@ -1 +1 @@ -9cfe862ea922b28d +8d2927a79024fb86 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/mongodb.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/mongodb.md index 869c5be90cf..6d38016425b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/mongodb.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/mongodb.md @@ -1,9 +1,10 @@ --- -'description': '允许执行 `SELECT` 查询,查询存储在远程 MongoDB 服务器上的数据。' +'description': '允许执行 `SELECT` 查询以访问存储在远程 MongoDB 服务器上的数据。' 'sidebar_label': 'mongodb' 'sidebar_position': 135 'slug': '/sql-reference/table-functions/mongodb' 'title': 'mongodb' +'doc_type': 'reference' --- @@ -19,16 +20,16 @@ mongodb(host:port, database, collection, user, password, structure[, options[, o ## 参数 {#arguments} -| 参数 | 描述 | +| 参数 | 描述 | |---------------|--------------------------------------------------------------------------------------------------------| -| `host:port` | MongoDB 服务器地址。 | -| `database` | 远程数据库名称。 | -| `collection` | 远程集合名称。 | -| `user` | MongoDB 用户。 | -| `password` | 用户密码。 | -| `structure` | 从此函数返回的 ClickHouse 表的模式。 | +| `host:port` | MongoDB 服务器地址。 | +| `database` | 远程数据库名称。 | +| `collection` | 远程集合名称。 | +| `user` | MongoDB 用户。 | +| `password` | 用户密码。 | +| `structure` | 从此函数返回的 ClickHouse 表的架构。 | | `options` | MongoDB 连接字符串选项(可选参数)。 | -| `oid_columns` | 在 WHERE 子句中应视为 `oid` 的列的逗号分隔列表。默认是 `_id`。 | +| `oid_columns` | 在 WHERE 子句中应视为 `oid` 的列的逗号分隔列表。默认是 `_id`。 | :::tip 如果您使用的是 MongoDB Atlas 云服务,请添加以下选项: @@ -38,18 +39,18 @@ mongodb(host:port, database, collection, user, password, structure[, options[, o ``` ::: -您还可以通过 URI 连接: +您也可以通过 URI 连接: ```sql mongodb(uri, collection, structure[, oid_columns]) ``` -| 参数 | 描述 | +| 参数 | 描述 | |---------------|--------------------------------------------------------------------------------------------------------| -| `uri` | 连接字符串。 | -| `collection` | 远程集合名称。 | -| `structure` | 从此函数返回的 ClickHouse 表的模式。 | -| `oid_columns` | 在 WHERE 子句中应视为 `oid` 的列的逗号分隔列表。默认是 `_id`。 | +| `uri` | 连接字符串。 | +| `collection` | 远程集合名称。 | +| `structure` | 从此函数返回的 ClickHouse 表的架构。 | +| `oid_columns` | 在 WHERE 子句中应视为 `oid` 的列的逗号分隔列表。默认是 `_id`。 | ## 返回值 {#returned_value} @@ -87,7 +88,7 @@ SELECT * FROM mongodb( ) ``` -或者: +或: ```sql SELECT * FROM mongodb( @@ -100,4 +101,4 @@ SELECT * FROM mongodb( ## 相关 {#related} - [MongoDB 表引擎](engines/table-engines/integrations/mongodb.md) -- [将 MongoDB 用作字典源](sql-reference/dictionaries/index.md#mongodb) +- [将 MongoDB 作为字典源](sql-reference/dictionaries/index.md#mongodb) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/mongodb.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/mongodb.md.hash index c805495e501..2e4a28fdd5c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/mongodb.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/mongodb.md.hash @@ -1 +1 @@ -ddbd0f94084c710b +d97293cbcadb02a4 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/mysql.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/mysql.md index 52bfda2506e..21aa77ee712 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/mysql.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/mysql.md @@ -1,9 +1,10 @@ --- -'description': '允许 `SELECT` 和 `INSERT` 查询在存储在远程 MySQL 服务器上的数据上执行。' +'description': '允许 `SELECT` 和 `INSERT` 查询在存储于远程 MySQL 服务器上的数据上执行。' 'sidebar_label': 'mysql' 'sidebar_position': 137 'slug': '/sql-reference/table-functions/mysql' 'title': 'mysql' +'doc_type': 'reference' --- @@ -19,29 +20,29 @@ mysql({host:port, database, table, user, password[, replace_query, on_duplicate_ ## 参数 {#arguments} -| 参数 | 描述 | -|---------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `host:port` | MySQL 服务器地址。 | -| `database` | 远程数据库名称。 | -| `table` | 远程表名称。 | -| `user` | MySQL 用户。 | -| `password` | 用户密码。 | -| `replace_query` | 将 `INSERT INTO` 查询转换为 `REPLACE INTO` 的标志。可能的值:
- `0` - 查询作为 `INSERT INTO` 执行。
- `1` - 查询作为 `REPLACE INTO` 执行。 | -| `on_duplicate_clause` | 添加到 `INSERT` 查询的 `ON DUPLICATE KEY on_duplicate_clause` 表达式。只能在 `replace_query = 0` 时指定(如果同时传递 `replace_query = 1` 和 `on_duplicate_clause`,ClickHouse 会生成异常)。
示例:`INSERT INTO t (c1,c2) VALUES ('a', 2) ON DUPLICATE KEY UPDATE c2 = c2 + 1;`
此处的 `on_duplicate_clause` 是 `UPDATE c2 = c2 + 1`。请参阅 MySQL 文档以了解可以与 `ON DUPLICATE KEY` 子句一起使用的 `on_duplicate_clause`。 | +| 参数 | 描述 | +|----------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `host:port` | MySQL 服务器地址。 | +| `database` | 远程数据库名称。 | +| `table` | 远程表名称。 | +| `user` | MySQL 用户。 | +| `password` | 用户密码。 | +| `replace_query` | 将 `INSERT INTO` 查询转换为 `REPLACE INTO` 的标志。可能的值:
- `0` - 查询作为 `INSERT INTO` 执行。
- `1` - 查询作为 `REPLACE INTO` 执行。 | +| `on_duplicate_clause` | 添加到 `INSERT` 查询中的 `ON DUPLICATE KEY on_duplicate_clause` 表达式。仅在 `replace_query = 0` 时可以指定(如果同时传递 `replace_query = 1` 和 `on_duplicate_clause`,ClickHouse 会生成异常)。
示例:`INSERT INTO t (c1,c2) VALUES ('a', 2) ON DUPLICATE KEY UPDATE c2 = c2 + 1;`
`on_duplicate_clause` 这里是 `UPDATE c2 = c2 + 1`。请参阅 MySQL 文档以查找可以与 `ON DUPLICATE KEY` 子句一起使用的 `on_duplicate_clause`。 | -参数也可以通过 [命名集合](operations/named-collections.md) 进行传递。在这种情况下,`host` 和 `port` 应分开指定。这种方法建议在生产环境中使用。 +参数也可以通过 [命名集合](operations/named-collections.md) 传递。在这种情况下,`host` 和 `port` 应该单独指定。这种方法推荐用于生产环境。 -简单的 `WHERE` 子句,如 `=, !=, >, >=, <, <=` 目前在 MySQL 服务器上执行。 +简单的 `WHERE` 子句,如 `=, !=, >, >=, <, <=` 当前在 MySQL 服务器上执行。 -其余条件和 `LIMIT` 采样限制在查询到 MySQL 完成后仅在 ClickHouse 中执行。 +其余的条件和 `LIMIT` 采样约束在查询到 MySQL 完成后仅在 ClickHouse 中执行。 -支持多个副本,必须用 `|` 列出。例如: +支持多个副本,必须通过 `|` 列出。例如: ```sql SELECT name FROM mysql(`mysql{1|2|3}:3306`, 'mysql_database', 'mysql_table', 'user', 'password'); ``` -或者 +或 ```sql SELECT name FROM mysql(`mysql1:3306|mysql2:3306|mysql3:3306`, 'mysql_database', 'mysql_table', 'user', 'password'); @@ -49,14 +50,14 @@ SELECT name FROM mysql(`mysql1:3306|mysql2:3306|mysql3:3306`, 'mysql_database', ## 返回值 {#returned_value} -返回一个与原 MySQL 表具有相同列的表对象。 +一个具有与原 MySQL 表相同列的表对象。 :::note -MySQL 的某些数据类型可以映射到不同的 ClickHouse 类型 - 这通过查询级别的设置 [mysql_datatypes_support_level](operations/settings/settings.md#mysql_datatypes_support_level) 来解决。 +某些 MySQL 数据类型可以映射到不同的 ClickHouse 类型 - 这可以通过查询级设置 [mysql_datatypes_support_level](operations/settings/settings.md#mysql_datatypes_support_level) 解决。 ::: :::note -在 `INSERT` 查询中,为了区分表函数 `mysql(...)` 和带列名列表的表名,必须使用关键字 `FUNCTION` 或 `TABLE FUNCTION`。请参见下面的示例。 +在 `INSERT` 查询中,为了区分表函数 `mysql(...)` 和带有列名列表的表名称,您必须使用关键词 `FUNCTION` 或 `TABLE FUNCTION`。请参见下面的示例。 ::: ## 示例 {#examples} @@ -79,13 +80,13 @@ mysql> SELECT * FROM test; +--------+-------+ ``` -从 ClickHouse 中选择数据: +从 ClickHouse 选择数据: ```sql SELECT * FROM mysql('localhost:3306', 'test', 'test', 'bayonet', '123'); ``` -或者使用 [命名集合](operations/named-collections.md): +或使用 [命名集合](operations/named-collections.md): ```sql CREATE NAMED COLLECTION creds AS @@ -118,7 +119,7 @@ SELECT * FROM mysql('localhost:3306', 'test', 'test', 'bayonet', '123'); └────────┴───────┘ ``` -从 MySQL 表复制数据到 ClickHouse 表: +将数据从 MySQL 表复制到 ClickHouse 表: ```sql CREATE TABLE mysql_copy @@ -134,12 +135,12 @@ INSERT INTO mysql_copy SELECT * FROM mysql('host:port', 'database', 'table', 'user', 'password'); ``` -或者如果仅基于当前最大 ID 从 MySQL 复制增量批次: +或仅基于当前最大 id 从 MySQL 复制增量批次: ```sql INSERT INTO mysql_copy SELECT * FROM mysql('host:port', 'database', 'table', 'user', 'password') -WHERE id > (SELECT max(id) from mysql_copy); +WHERE id > (SELECT max(id) FROM mysql_copy); ``` ## 相关 {#related} diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/mysql.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/mysql.md.hash index e625a43255c..d2cf6235628 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/mysql.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/mysql.md.hash @@ -1 +1 @@ -7eeaf16908277275 +a8483f7b2b81cde0 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/null.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/null.md index b5b19582b0a..8bb96672a80 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/null.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/null.md @@ -1,15 +1,16 @@ --- -'description': '使用 Null 表引擎创建指定结构的临时表。此功能用于方便的测试编写和演示。' +'description': '使用 Null 表引擎创建指定结构的临时表。该函数用于方便测试编写和演示。' 'sidebar_label': 'null 函数' 'sidebar_position': 140 'slug': '/sql-reference/table-functions/null' 'title': 'null' +'doc_type': 'reference' --- # null 表函数 -创建一个具有指定结构的临时表,使用 [Null](../../engines/table-engines/special/null.md) 表引擎。根据 `Null` 引擎的属性,表数据被忽略,并且表在查询执行后立即被删除。该函数用于方便测试编写和演示。 +创建一个具有指定结构的临时表,使用 [Null](../../engines/table-engines/special/null.md) 表引擎。根据 `Null` 引擎的特性,表数据将被忽略,并且在查询执行后,表会立即被删除。此函数用于方便测试编写和演示。 ## 语法 {#syntax} @@ -19,11 +20,11 @@ null('structure') ## 参数 {#argument} -- `structure` — 列和列类型的列表。 [String](../../sql-reference/data-types/string.md)。 +- `structure` — 列及列类型的列表。 [String](../../sql-reference/data-types/string.md)。 ## 返回值 {#returned_value} -一个具有指定结构的临时 `Null` 引擎表。 +具有指定结构的临时 `Null` 引擎表。 ## 示例 {#example} diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/null.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/null.md.hash index 37d77f7a4dc..382c0e03be8 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/null.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/null.md.hash @@ -1 +1 @@ -e678383ade1fcc38 +9fbdf20bedbe25de diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/numbers.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/numbers.md index 39b943a8c8b..06c70f88212 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/numbers.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/numbers.md @@ -3,17 +3,18 @@ 'sidebar_position': 145 'sidebar_label': '数字' 'title': '数字' -'description': '返回包含可指定整数的单个 `number` 列的表。' +'description': '返回具有单个 `number` 列的表,该列包含可指定的整数。' +'doc_type': 'reference' --- -# numbers Table Function +# numbers 表函数 -`numbers(N)` – 返回一个包含单列 'number'(UInt64)的表,该列包含从 0 到 N-1 的整数。 -`numbers(N, M)` - 返回一个包含单列 'number'(UInt64)的表,该列包含从 N 到 (N + M - 1) 的整数。 -`numbers(N, M, S)` - 返回一个包含单列 'number'(UInt64)的表,该列包含从 N 到 (N + M - 1) 的整数,步长为 S。 +`numbers(N)` – 返回一个单列 'number'(UInt64)的表,该列包含从 0 到 N-1 的整数。 +`numbers(N, M)` - 返回一个单列 'number'(UInt64)的表,该列包含从 N 到 (N + M - 1) 的整数。 +`numbers(N, M, S)` - 返回一个单列 'number'(UInt64)的表,该列包含从 N 到 (N + M - 1) 的整数,步长为 S。 -与 `system.numbers` 表类似,它可以用于测试和生成连续值,`numbers(N, M)` 比 `system.numbers` 更高效。 +类似于 `system.numbers` 表,它可以用于测试和生成连续的值,`numbers(N, M)` 比 `system.numbers` 更高效。 以下查询是等效的: @@ -37,5 +38,5 @@ SELECT * FROM numbers(0, 20, 2); ```sql -- Generate a sequence of dates from 2010-01-01 to 2010-12-31 -select toDate('2010-01-01') + number as d FROM numbers(365); +SELECT toDate('2010-01-01') + number AS d FROM numbers(365); ``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/numbers.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/numbers.md.hash index 7ee971c369c..eed6101b8ed 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/numbers.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/numbers.md.hash @@ -1 +1 @@ -5a302ad16fb79546 +c6183255934f7f37 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/odbc.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/odbc.md index c5d4db51a67..48c04ce6c65 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/odbc.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/odbc.md @@ -4,6 +4,7 @@ 'sidebar_position': 150 'slug': '/sql-reference/table-functions/odbc' 'title': 'odbc' +'doc_type': 'reference' --- @@ -14,30 +15,34 @@ ## 语法 {#syntax} ```sql -odbc(connection_settings, external_database, external_table) +odbc(datasource, external_database, external_table) +odbc(datasource, external_table) +odbc(named_collection) ``` ## 参数 {#arguments} -| 参数 | 描述 | -|-----------------------|--------------------------------------------------------------------------| -| `connection_settings` | `odbc.ini` 文件中连接设置的节名称。 | -| `external_database` | 外部 DBMS 中数据库的名称。 | -| `external_table` | `external_database` 中表的名称。 | +| 参数 | 描述 | +|---------------------|------------------------------------------------------------------------| +| `datasource` | `odbc.ini` 文件中连接设置的节名称。 | +| `external_database` | 外部数据库管理系统中的数据库名称。 | +| `external_table` | `external_database` 中的表名称。 | -为了安全地实现 ODBC 连接,ClickHouse 使用单独的程序 `clickhouse-odbc-bridge`。如果 ODBC 驱动程序直接从 `clickhouse-server` 加载,驱动程序的问题可能会导致 ClickHouse 服务器崩溃。ClickHouse 在需要时会自动启动 `clickhouse-odbc-bridge`。ODBC 网桥程序与 `clickhouse-server` 从同一软件包中安装。 +这些参数也可以使用 [命名集合](operations/named-collections.md) 传递。 -外部表中带有 `NULL` 值的字段会转换为基础数据类型的默认值。例如,如果远程 MySQL 表字段具有 `INT NULL` 类型,则会转换为 0(ClickHouse `Int32` 数据类型的默认值)。 +为了安全地实现 ODBC 连接,ClickHouse 使用一个单独的程序 `clickhouse-odbc-bridge`。如果 ODBC 驱动程序直接从 `clickhouse-server` 加载,驱动程序的问题可能会导致 ClickHouse 服务器崩溃。ClickHouse 在需要时自动启动 `clickhouse-odbc-bridge`。ODBC 桥程序与 `clickhouse-server` 从同一包中安装。 + +外部表中具有 `NULL` 值的字段将转换为基本数据类型的默认值。例如,如果远程 MySQL 表字段具有 `INT NULL` 类型,它将转换为 0(ClickHouse `Int32` 数据类型的默认值)。 ## 使用示例 {#usage-example} **通过 ODBC 从本地 MySQL 安装获取数据** -此示例针对 Ubuntu Linux 18.04 和 MySQL 服务器 5.7 进行检查。 +此示例适用于 Ubuntu Linux 18.04 和 MySQL 服务器 5.7。 确保已安装 unixODBC 和 MySQL Connector。 -默认情况下(如果是从软件包安装的),ClickHouse 以用户 `clickhouse` 启动。因此,您需要在 MySQL 服务器中创建并配置此用户。 +默认情况下(如果从包安装),ClickHouse 以用户 `clickhouse` 启动。因此,您需要在 MySQL 服务器中创建和配置此用户。 ```bash $ sudo mysql @@ -61,7 +66,7 @@ USERNAME = clickhouse PASSWORD = clickhouse ``` -您可以使用 unixODBC 安装中的 `isql` 工具检查连接。 +您可以使用 unixODBC 安装中的 `isql` 实用程序检查连接。 ```bash $ isql -v mysqlconn @@ -106,7 +111,7 @@ SELECT * FROM odbc('DSN=mysqlconn', 'test', 'test') └────────┴──────────────┴───────┴────────────────┘ ``` -## 相关 {#see-also} +## 相关内容 {#see-also} - [ODBC 字典](/sql-reference/dictionaries#dbms) - [ODBC 表引擎](/engines/table-engines/integrations/odbc). diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/odbc.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/odbc.md.hash index 0ca6b88a730..9f5bc93f762 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/odbc.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/odbc.md.hash @@ -1 +1 @@ -c2bd4747270e4421 +fc38d8fff0a8609c diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/postgresql.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/postgresql.md index 46d83da9e3d..6c3273a42f8 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/postgresql.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/postgresql.md @@ -1,9 +1,10 @@ --- -'description': '允许 `SELECT` 和 `INSERT` 查询在存储在远程 PostgreSQL 服务器上的数据上执行。' +'description': '允许执行 `SELECT` 和 `INSERT` 查询,以便对存储在远程 PostgreSQL 服务器上的数据进行操作。' 'sidebar_label': 'postgresql' 'sidebar_position': 160 'slug': '/sql-reference/table-functions/postgresql' 'title': 'postgresql' +'doc_type': 'reference' --- @@ -19,40 +20,40 @@ postgresql({host:port, database, table, user, password[, schema, [, on_conflict] ## 参数 {#arguments} -| 参数 | 描述 | -|--------------|---------------------------------------------------------------------------| -| `host:port` | PostgreSQL 服务器地址。 | -| `database` | 远程数据库名称。 | -| `table` | 远程表名称。 | -| `user` | PostgreSQL 用户。 | -| `password` | 用户密码。 | -| `schema` | 非默认表模式。可选。 | -| `on_conflict`| 冲突解决策略。示例:`ON CONFLICT DO NOTHING`。可选。 | +| 参数 | 描述 | +|---------------|----------------------------------------------------------------------------| +| `host:port` | PostgreSQL 服务器地址。 | +| `database` | 远程数据库名称。 | +| `table` | 远程表名称。 | +| `user` | PostgreSQL 用户。 | +| `password` | 用户密码。 | +| `schema` | 非默认表架构。可选。 | +| `on_conflict` | 冲突解决策略。例如:`ON CONFLICT DO NOTHING`。可选。 | -参数也可以使用 [命名集合](operations/named-collections.md) 传递。在这种情况下,`host` 和 `port` 应该单独指定。这种方法推荐用于生产环境。 +参数也可以使用 [命名集合](operations/named-collections.md) 传递。在这种情况下,`host` 和 `port` 应该分开指定。建议在生产环境中采用这种方法。 ## 返回值 {#returned_value} -具有与原始 PostgreSQL 表相同列的表对象。 +一个表对象,其列与原始 PostgreSQL 表相同。 :::note -在 `INSERT` 查询中,为了区分表函数 `postgresql(...)` 和表名(带列名列表),必须使用关键字 `FUNCTION` 或 `TABLE FUNCTION`。请参见下面的示例。 +在 `INSERT` 查询中,为了区分表函数 `postgresql(...)` 和具有列名列表的表名称,必须使用关键字 `FUNCTION` 或 `TABLE FUNCTION`。请参阅下面的示例。 ::: ## 实现细节 {#implementation-details} -PostgreSQL 端的 `SELECT` 查询作为 `COPY (SELECT ...) TO STDOUT` 在只读 PostgreSQL 事务中运行,每个 `SELECT` 查询后提交。 +在 PostgreSQL 端的 `SELECT` 查询作为 `COPY (SELECT ...) TO STDOUT` 在只读 PostgreSQL 事务中运行,每个 `SELECT` 查询后都提交。 -简单的 `WHERE` 子句,如 `=`、`!=`、`>`、`>=`、`<`、`<=` 和 `IN` 在 PostgreSQL 服务器上执行。 +简单的 `WHERE` 子句,如 `=`、`!=`、`>`、`>=`、`<`、`<=` 和 `IN`,在 PostgreSQL 服务器上执行。 -所有连接、聚合、排序、`IN [ array ]` 条件和 `LIMIT` 采样约束仅在查询到 PostgreSQL 完成后在 ClickHouse 中执行。 +所有连接、聚合、排序、`IN [ array ]` 条件和 `LIMIT` 采样约束仅在查询完成后在 ClickHouse 中执行。 -PostgreSQL 端的 `INSERT` 查询作为 `COPY "table_name" (field1, field2, ... fieldN) FROM STDIN` 在 PostgreSQL 事务中运行,每个 `INSERT` 语句后自动提交。 +在 PostgreSQL 端的 `INSERT` 查询作为 `COPY "table_name" (field1, field2, ... fieldN) FROM STDIN` 在 PostgreSQL 事务中运行,每个 `INSERT` 语句后自动提交。 PostgreSQL 数组类型转换为 ClickHouse 数组。 :::note -请注意,在 PostgreSQL 中,像 Integer[] 这样的数组数据类型列可能在不同的行中包含不同维度的数组,但在 ClickHouse 中,所有行中仅允许具有相同维度的多维数组。 +请注意,在 PostgreSQL 中,像 Integer[] 这样的数组数据类型列可能在不同的行中包含不同维度的数组,但在 ClickHouse 中,仅允许所有行具有相同维度的多维数组。 ::: 支持多个副本,必须用 `|` 列出。例如: @@ -61,7 +62,7 @@ PostgreSQL 数组类型转换为 ClickHouse 数组。 SELECT name FROM postgresql(`postgres{1|2|3}:5432`, 'postgres_database', 'postgres_table', 'user', 'password'); ``` -或者 +或 ```sql SELECT name FROM postgresql(`postgres1:5431|postgres2:5432`, 'postgres_database', 'postgres_table', 'user', 'password'); @@ -94,13 +95,13 @@ postgresql> SELECT * FROM test; (1 row) ``` -使用普通参数从 ClickHouse 中选择数据: +使用普通参数从 ClickHouse 选择数据: ```sql SELECT * FROM postgresql('localhost:5432', 'test', 'test', 'postgresql_user', 'password') WHERE str IN ('test'); ``` -或者使用 [命名集合](operations/named-collections.md): +或使用 [命名集合](operations/named-collections.md): ```sql CREATE NAMED COLLECTION mypg AS @@ -118,7 +119,7 @@ SELECT * FROM postgresql(mypg, table='test') WHERE str IN ('test'); └────────┴──────────────┴───────┴──────┴────────────────┘ ``` -插入: +插入操作: ```sql INSERT INTO TABLE FUNCTION postgresql('localhost:5432', 'test', 'test', 'postgrsql_user', 'password') (int_id, float) VALUES (2, 3); @@ -154,4 +155,4 @@ CREATE TABLE pg_table_schema_with_dots (a UInt32) ### 使用 PeerDB 复制或迁移 Postgres 数据 {#replicating-or-migrating-postgres-data-with-with-peerdb} -> 除了表函数,您还可以始终使用 [PeerDB](https://docs.peerdb.io/introduction) 来从 Postgres 到 ClickHouse 设置持续的数据管道。PeerDB 是一个专门设计用于通过变更数据捕获 (CDC) 将数据从 Postgres 复制到 ClickHouse 的工具。 +> 除了表函数外,您始终可以使用 [PeerDB](https://docs.peerdb.io/introduction) by ClickHouse 来设置从 Postgres 到 ClickHouse 的持续数据管道。PeerDB 是一种专门设计用于使用更改数据捕获 (CDC) 将数据从 Postgres 复制到 ClickHouse 的工具。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/postgresql.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/postgresql.md.hash index f1772465913..de53b190a74 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/postgresql.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/postgresql.md.hash @@ -1 +1 @@ -6aa09f0844f9b71d +957698aa66f0d9f4 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/prometheusQuery.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/prometheusQuery.md new file mode 100644 index 00000000000..0b288842333 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/prometheusQuery.md @@ -0,0 +1,45 @@ +--- +'description': '使用来自 TimeSeries 表的数据评估 prometheus 查询。' +'sidebar_label': 'prometheusQuery' +'sidebar_position': 145 +'slug': '/sql-reference/table-functions/prometheusQuery' +'title': 'prometheusQuery' +'doc_type': 'reference' +--- + + +# prometheusQuery 表函数 + +使用来自时间序列表的数据来评估 prometheus 查询。 + +## 语法 {#syntax} + +```sql +prometheusQuery('db_name', 'time_series_table', 'promql_query', evaluation_time) +prometheusQuery(db_name.time_series_table, 'promql_query', evaluation_time) +prometheusQuery('time_series_table', 'promql_query', evaluation_time) +``` + +## 参数 {#arguments} + +- `db_name` - 存在时间序列表的数据库名称。 +- `time_series_table` - 时间序列表的名称。 +- `promql_query` - 采用 [PromQL 语法](https://prometheus.io/docs/prometheus/latest/querying/basics/) 编写的查询。 +- `evaluation_time` - 评估时间戳。要在当前时间评估查询,请使用 `now()` 作为 `evaluation_time`。 + +## 返回值 {#returned_value} + +该函数可以根据传递给参数 `promql_query` 的查询的结果类型返回不同的列: + +| 结果类型 | 结果列 | 示例 | +|----------|--------|------| +| vector | tags Array(Tuple(String, String)), timestamp TimestampType, value ValueType | prometheusQuery(mytable, 'up') | +| matrix | tags Array(Tuple(String, String)), time_series Array(Tuple(TimestampType, ValueType)) | prometheusQuery(mytable, 'up[1m]') | +| scalar | scalar ValueType | prometheusQuery(mytable, '1h30m') | +| string | string String | prometheusQuery(mytable, '"abc"') | + +## 示例 {#example} + +```sql +SELECT * FROM prometheusQuery(mytable, 'rate(http_requests{job="prometheus"}[10m])[1h:10m]', now()) +``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/prometheusQuery.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/prometheusQuery.md.hash new file mode 100644 index 00000000000..205a51b52c5 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/prometheusQuery.md.hash @@ -0,0 +1 @@ +43f135a73a1b1465 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/prometheusQueryRange.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/prometheusQueryRange.md new file mode 100644 index 00000000000..fb36611f783 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/prometheusQueryRange.md @@ -0,0 +1,47 @@ +--- +'description': '使用来自时间序列表的数据评估 prometheus 查询。' +'sidebar_label': 'prometheusQueryRange' +'sidebar_position': 145 +'slug': '/sql-reference/table-functions/prometheusQueryRange' +'title': 'prometheusQueryRange' +'doc_type': 'reference' +--- + + +# prometheusQuery 表函数 + +使用来自时间序列表的数据,在评估时间范围内评估 prometheus 查询。 + +## 语法 {#syntax} + +```sql +prometheusQueryRange('db_name', 'time_series_table', 'promql_query', start_time, end_time, step) +prometheusQueryRange(db_name.time_series_table, 'promql_query', start_time, end_time, step) +prometheusQueryRange('time_series_table', 'promql_query', start_time, end_time, step) +``` + +## 参数 {#arguments} + +- `db_name` - 包含时间序列表的数据库名称。 +- `time_series_table` - 一张时间序列表的名称。 +- `promql_query` - 使用 [PromQL 语法](https://prometheus.io/docs/prometheus/latest/querying/basics/) 编写的查询。 +- `start_time` - 评估范围的起始时间。 +- `end_time` - 评估范围的结束时间。 +- `step` - 从 `start_time` 到 `end_time` (包括)迭代评估时间所使用的步长。 + +## 返回值 {#returned_value} + +该函数可以根据传递给参数 `promql_query` 的查询结果类型返回不同的列: + +| 结果类型 | 结果列 | 示例 | +|-------------|----------------|---------| +| vector | tags Array(Tuple(String, String)), timestamp TimestampType, value ValueType | prometheusQuery(mytable, 'up') | +| matrix | tags Array(Tuple(String, String)), time_series Array(Tuple(TimestampType, ValueType)) | prometheusQuery(mytable, 'up[1m]') | +| scalar | scalar ValueType | prometheusQuery(mytable, '1h30m') | +| string | string String | prometheusQuery(mytable, '"abc"') | + +## 示例 {#example} + +```sql +SELECT * FROM prometheusQueryRange(mytable, 'rate(http_requests{job="prometheus"}[10m])[1h:10m]', now() - INTERVAL 10 MINUTES, now(), INTERVAL 1 MINUTE) +``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/prometheusQueryRange.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/prometheusQueryRange.md.hash new file mode 100644 index 00000000000..fb88c24b7e1 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/prometheusQueryRange.md.hash @@ -0,0 +1 @@ +10d4ba1a750acf1d diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/redis.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/redis.md index f2fda554fdc..149eb7eaf2a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/redis.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/redis.md @@ -4,12 +4,13 @@ 'sidebar_position': 170 'slug': '/sql-reference/table-functions/redis' 'title': 'redis' +'doc_type': 'reference' --- # redis 表函数 -此表函数允许将 ClickHouse 与 [Redis](https://redis.io/) 集成。 +该表函数允许将 ClickHouse 与 [Redis](https://redis.io/) 集成。 ## 语法 {#syntax} @@ -19,24 +20,24 @@ redis(host:port, key, structure[, db_index[, password[, pool_size]]]) ## 参数 {#arguments} -| 参数 | 描述 | -|---------------|-----------------------------------------------------------------------------------------------------| -| `host:port` | Redis 服务器地址,可以忽略端口,默认 Redis 端口 6379 将被使用。 | -| `key` | 列表中的任何列名。 | -| `structure` | 从此函数返回的 ClickHouse 表的模式。 | -| `db_index` | Redis db 索引范围为 0 到 15,默认为 0。 | -| `password` | 用户密码,默认为空字符串。 | -| `pool_size` | Redis 最大连接池大小,默认为 16。 | -| `primary` | 必须指定,只支持一个列作为主键。主键将以二进制格式序列化为 Redis 键。 | +| 参数 | 描述 | +|--------------|--------------------------------------------------------------------------------------| +| `host:port` | Redis 服务器地址,您可以忽略端口,将使用默认的 Redis 端口 6379。 | +| `key` | 列表中的任何列名。 | +| `structure` | 从此函数返回的 ClickHouse 表的模式。 | +| `db_index` | Redis 数据库索引,范围从 0 到 15,默认为 0。 | +| `password` | 用户密码,默认为空字符串。 | +| `pool_size` | Redis 最大连接池大小,默认为 16。 | +| `primary` | 必须指定,只支持主键中的一个列。主键将以二进制序列化为 Redis 键。 | -- 除主键外的列将按照对应顺序以二进制格式序列化为 Redis 值。 -- 如果查询的键相等或在过滤中,将优化为从 Redis 多键查找。如果查询没有过滤键,则会发生全表扫描,这是一个重操作。 +- 除主键外的列将按照对应顺序以二进制序列化为 Redis 值。 +- 带有等于键或在过滤中的查询将优化为从 Redis 进行多键查找。如果没有过滤键的查询将导致全表扫描,这是一个繁重的操作。 目前不支持 `redis` 表函数的 [命名集合](/operations/named-collections.md)。 ## 返回值 {#returned_value} -一个表对象,键作为 Redis 键,其他列打包为 Redis 值。 +一个表对象,其中键为 Redis 键,其他列打包在一起作为 Redis 值。 ## 使用示例 {#usage-example} @@ -50,7 +51,7 @@ SELECT * FROM redis( ) ``` -插入到 Redis: +插入到 Redis 中: ```sql INSERT INTO TABLE FUNCTION redis( @@ -62,4 +63,4 @@ INSERT INTO TABLE FUNCTION redis( ## 相关 {#related} - [`Redis` 表引擎](/engines/table-engines/integrations/redis.md) -- [将 redis 用作字典源](/sql-reference/dictionaries/index.md#redis) +- [将 redis 作为字典源](/sql-reference/dictionaries/index.md#redis) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/redis.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/redis.md.hash index fe2df51247f..8d2768573b9 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/redis.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/redis.md.hash @@ -1 +1 @@ -9a8e56650a38ba1d +71172158d4d29074 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/remote.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/remote.md index ca834129fa7..51639465847 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/remote.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/remote.md @@ -1,17 +1,19 @@ --- -'description': '表函数 `remote` 允许动态访问远程服务器,即无需创建分布式表。表函数 `remoteSecure` 与 `remote` 相同,但通过安全连接进行。' -'sidebar_label': 'remote' +'description': '表函数 `remote` 允许动态访问远程服务器,即不需要创建分布式表。表函数 `remoteSecure` 与 `remote` + 相同,但通过安全连接。' +'sidebar_label': '远程' 'sidebar_position': 175 'slug': '/sql-reference/table-functions/remote' -'title': 'remote, remoteSecure' +'title': '远程, remoteSecure' +'doc_type': 'reference' --- -# remote, remoteSecure 表函数 +# remote 和 remoteSecure 表函数 -表函数 `remote` 允许动态访问远程服务器,即在不创建 [Distributed](../../engines/table-engines/special/distributed.md) 表的情况下。表函数 `remoteSecure` 与 `remote` 相同,但通过安全连接进行访问。 +表函数 `remote` 允许实时访问远程服务器,即在不创建 [Distributed](../../engines/table-engines/special/distributed.md) 表的情况下。表函数 `remoteSecure` 与 `remote` 相同,但通过安全连接。 -这两个函数可以在 `SELECT` 和 `INSERT` 查询中使用。 +这两个函数都可以在 `SELECT` 和 `INSERT` 查询中使用。 ## 语法 {#syntax} @@ -26,16 +28,16 @@ remoteSecure(named_collection[, option=value [,..]]) ## 参数 {#parameters} -| 参数 | 描述 | -|------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `addresses_expr` | 远程服务器地址或生成多个远程服务器地址的表达式。格式: `host` 或 `host:port`。

`host` 可以指定为服务器名称或 IPv4 或 IPv6 地址。IPv6 地址必须用方括号括起来。

`port` 是远程服务器上的 TCP 端口。如果省略端口,则会使用表函数 `remote` 的服务器配置文件中的 [tcp_port](../../operations/server-configuration-parameters/settings.md#tcp_port)(默认为 9000)和表函数 `remoteSecure` 的 [tcp_port_secure](../../operations/server-configuration-parameters/settings.md#tcp_port_secure)(默认为 9440)。

对于 IPv6 地址,端口是必需的。

如果仅指定参数 `addresses_expr`,`db` 和 `table` 默认将使用 `system.one`。

类型:[String](../../sql-reference/data-types/string.md)。 | -| `db` | 数据库名称。类型:[String](../../sql-reference/data-types/string.md)。 | -| `table` | 表名。类型:[String](../../sql-reference/data-types/string.md)。 | -| `user` | 用户名。如果未指定,则使用 `default`。类型:[String](../../sql-reference/data-types/string.md)。 | -| `password` | 用户密码。如果未指定,则使用空密码。类型:[String](../../sql-reference/data-types/string.md)。 | -| `sharding_key` | 用于支持跨节点分发数据的分片键。例如:`insert into remote('127.0.0.1:9000,127.0.0.2', db, table, 'default', rand())`。类型:[UInt32](../../sql-reference/data-types/int-uint.md)。 | +| 参数 | 描述 | +|-----------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `addresses_expr` | 远程服务器地址或生成多个远程服务器地址的表达式。格式:`host` 或 `host:port`。

`host` 可以指定为服务器名称,或作为 IPv4 或 IPv6 地址。IPv6 地址必须用方括号指定。

`port` 是远程服务器上的 TCP 端口。如果省略端口,则使用表函数 `remote` 的配置文件中的 [tcp_port](../../operations/server-configuration-parameters/settings.md#tcp_port)(默认情况为 9000)和表函数 `remoteSecure` 的 [tcp_port_secure](../../operations/server-configuration-parameters/settings.md#tcp_port_secure)(默认情况为 9440)。

对于 IPv6 地址,必须指定端口。

如果仅指定参数 `addresses_expr`,则 `db` 和 `table` 默认使用 `system.one`。

类型:[String](../../sql-reference/data-types/string.md)。 | +| `db` | 数据库名称。类型:[String](../../sql-reference/data-types/string.md)。 | +| `table` | 表名称。类型:[String](../../sql-reference/data-types/string.md)。 | +| `user` | 用户名。如果未指定,则使用 `default`。类型:[String](../../sql-reference/data-types/string.md)。 | +| `password` | 用户密码。如果未指定,则使用空密码。类型:[String](../../sql-reference/data-types/string.md)。 | +| `sharding_key` | 支持跨节点分发数据的分片键。例如:`insert into remote('127.0.0.1:9000,127.0.0.2', db, table, 'default', rand())`。类型:[UInt32](../../sql-reference/data-types/int-uint.md)。 | -参数也可以通过 [命名集合](operations/named-collections.md) 传递。 +参数也可以使用 [命名集合](operations/named-collections.md) 传递。 ## 返回值 {#returned-value} @@ -43,14 +45,14 @@ remoteSecure(named_collection[, option=value [,..]]) ## 用法 {#usage} -由于表函数 `remote` 和 `remoteSecure` 在每次请求时都会重新建立连接,因此建议使用 `Distributed` 表。如果设置了主机名,则会进行名称解析,并且在与各种副本交互时不会计算错误。当处理大量查询时,始终提前创建 `Distributed` 表,而不是使用 `remote` 表函数。 +由于表函数 `remote` 和 `remoteSecure` 为每个请求重新建立连接,因此建议使用 `Distributed` 表。此外,如果设置了主机名,则会解决名称,并且在与各种副本工作时不会计入错误。当处理大量查询时,始终提前创建 `Distributed` 表,并且不要使用 `remote` 表函数。 -`remote` 表函数在以下情况下非常有用: +`remote` 表函数在以下情况下可能会很有用: -- 从一个系统迁移数据到另一个系统一次性操作 +- 从一个系统到另一个系统的一次性数据迁移 - 访问特定服务器进行数据比较、调试和测试,即临时连接。 -- 进行研究目的的各种 ClickHouse 集群之间的查询。 -- 手动进行的不频繁的分布式请求。 +- 进行各种 ClickHouse 集群之间的查询以进行研究。 +- 手动执行的不频繁分布式请求。 - 每次重新定义服务器集合的分布式请求。 ### 地址 {#addresses} @@ -66,7 +68,7 @@ localhost [2a02:6b8:0:1111::11]:9000 ``` -多个地址可以用逗号分隔。在这种情况下,ClickHouse 将使用分布式处理,并将查询发送到所有指定的地址(就像有不同数据的分片)。示例: +多个地址可以用逗号分隔。在这种情况下,ClickHouse 将使用分布式处理,并将查询发送到所有指定的地址(如具有不同数据的分片)。示例: ```text example01-01-1,example01-02-1 @@ -74,7 +76,7 @@ example01-01-1,example01-02-1 ## 示例 {#examples} -### 从远程服务器选择数据: {#selecting-data-from-a-remote-server} +### 从远程服务器选择数据: {#selecting-data-from-a-remote-server} ```sql SELECT * FROM remote('127.0.0.1', db.remote_engine_table) LIMIT 3; @@ -89,7 +91,7 @@ CREATE NAMED COLLECTION creds AS SELECT * FROM remote(creds, table='remote_engine_table') LIMIT 3; ``` -### 向远程服务器上的表插入数据: {#inserting-data-into-a-table-on-a-remote-server} +### 向远程服务器上的表插入数据: {#inserting-data-into-a-table-on-a-remote-server} ```sql CREATE TABLE remote_table (name String, value UInt32) ENGINE=Memory; @@ -97,9 +99,9 @@ INSERT INTO FUNCTION remote('127.0.0.1', currentDatabase(), 'remote_table') VALU SELECT * FROM remote_table; ``` -### 从一个系统迁移表到另一个系统: {#migration-of-tables-from-one-system-to-another} +### 从一个系统迁移表到另一个系统: {#migration-of-tables-from-one-system-to-another} -此示例使用来自示例数据集的一张表。 数据库为 `imdb`,表名为 `actors`。 +这个示例使用一个样本数据集中的表。数据库为 `imdb`,表为 `actors`。 #### 在源 ClickHouse 系统上(当前托管数据的系统) {#on-the-source-clickhouse-system-the-system-that-currently-hosts-the-data} @@ -116,9 +118,9 @@ show tables in imdb - 从源获取 CREATE TABLE 语句: ```sql -select create_table_query -from system.tables -where database = 'imdb' and table = 'actors' +SELECT create_table_query +FROM system.tables +WHERE database = 'imdb' AND table = 'actors' ``` 响应 @@ -140,7 +142,7 @@ CREATE TABLE imdb.actors (`id` UInt32, CREATE DATABASE imdb ``` -- 使用源中的 CREATE TABLE 语句创建目标: +- 使用源的 CREATE TABLE 语句创建目标: ```sql CREATE TABLE imdb.actors (`id` UInt32, @@ -151,9 +153,9 @@ CREATE TABLE imdb.actors (`id` UInt32, ORDER BY (id, first_name, last_name, gender); ``` -#### 回到源部署 {#back-on-the-source-deployment} +#### 回到源部署上 {#back-on-the-source-deployment} -插入到在远程系统上创建的新数据库和表中。您需要主机名、端口、用户名、密码、目标数据库和目标表。 +插入到在远程系统上创建的新数据库和表中。您需要主机、端口、用户名、密码、目标数据库和目标表。 ```sql INSERT INTO FUNCTION @@ -163,14 +165,14 @@ SELECT * from imdb.actors ## 通配符 {#globs-in-addresses} -大括号 `{ }` 中的模式用于生成一组分片并指定副本。如果有多个成对的大括号,则生成相应集合的笛卡尔积。 +大括号 `{ }` 中的模式用于生成一组分片和指定副本。如果有多个大括号对,则生成相应集合的笛卡尔积。 支持以下模式类型。 -- `{a,b,c}` - 表示任意一个替代字符串 `a`、`b` 或 `c`。该模式在第一个分片地址中替换为 `a`,在第二个分片地址中替换为 `b`,依此类推。例如,`example0{1,2}-1` 生成地址 `example01-1` 和 `example02-1`。 -- `{N..M}` - 一系列数字。此模式生成从 `N` 到(包括)`M` 的分片地址,索引递增。例如,`example0{1..2}-1` 生成 `example01-1` 和 `example02-1`。 -- `{0n..0m}` - 带有前导零的数字范围。此模式在索引中保留前导零。例如,`example{01..03}-1` 生成 `example01-1`、`example02-1` 和 `example03-1`。 +- `{a,b,c}` - 表示任意替代字符串 `a`、`b` 或 `c`。模式在第一个分片地址中替换为 `a`,在第二个分片地址中替换为 `b`,依此类推。例如,`example0{1,2}-1` 生成地址 `example01-1` 和 `example02-1`。 +- `{N..M}` - 一个数字范围。该模式生成具有递增索引从 `N` 到(包括) `M` 的分片地址。例如,`example0{1..2}-1` 生成 `example01-1` 和 `example02-1`。 +- `{0n..0m}` - 带有前导零的数字范围。该模式在索引中保留前导零。例如,`example{01..03}-1` 生成 `example01-1`、`example02-1` 和 `example03-1`。 - `{a|b}` - 由 `|` 分隔的任意数量的变体。该模式指定副本。例如,`example01-{1|2}` 生成副本 `example01-1` 和 `example01-2`。 -查询将发送到第一健康副本。然而,对于 `remote`,副本按当前在 [load_balancing](../../operations/settings/settings.md#load_balancing) 设置中设置的顺序进行迭代。 -生成的地址数量受到 [table_function_remote_max_addresses](../../operations/settings/settings.md#table_function_remote_max_addresses) 设置的限制。 +查询将发送到第一个健康的副本。但是,对于 `remote`,副本的迭代顺序是根据当前设置的 [load_balancing](../../operations/settings/settings.md#load_balancing) 设置进行的。 +生成的地址数量受限于 [table_function_remote_max_addresses](../../operations/settings/settings.md#table_function_remote_max_addresses) 设置。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/remote.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/remote.md.hash index b1f25287589..9395c5b186b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/remote.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/remote.md.hash @@ -1 +1 @@ -81ac7854ff7af557 +191d83b1be81fd4d diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/s3.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/s3.md index fed17774f4e..fe3e5cfd739 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/s3.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/s3.md @@ -1,5 +1,5 @@ --- -'description': '提供一个类表接口,用于在 Amazon S3 和 Google Cloud Storage 中选择/插入文件。这个表函数类似于 hdfs +'description': '提供一个类似表的接口来选择/插入在 Amazon S3 和 Google Cloud Storage 中的文件。这个表函数类似于 hdfs 函数,但提供 S3 特定的功能。' 'keywords': - 's3' @@ -9,6 +9,7 @@ 'sidebar_position': 180 'slug': '/sql-reference/table-functions/s3' 'title': 's3 表函数' +'doc_type': 'reference' --- import ExperimentalBadge from '@theme/badges/ExperimentalBadge'; @@ -17,42 +18,45 @@ import CloudNotSupportedBadge from '@theme/badges/CloudNotSupportedBadge'; # s3 表函数 -提供了一个类似表的接口来选择/插入 [Amazon S3](https://aws.amazon.com/s3/) 和 [Google Cloud Storage](https://cloud.google.com/storage/) 中的文件。该表函数类似于 [hdfs 函数](../../sql-reference/table-functions/hdfs.md),但提供特定于 S3 的功能。 +提供了一个类表接口,以从 [Amazon S3](https://aws.amazon.com/s3/) 和 [Google Cloud Storage](https://cloud.google.com/storage/) 选择/插入文件。这个表函数类似于 [hdfs 函数](../../sql-reference/table-functions/hdfs.md),但提供特定于 S3 的功能。 -如果您的集群中有多个副本,可以使用 [s3Cluster 函数](../../sql-reference/table-functions/s3Cluster.md) 来并行化插入。 +如果您的集群中有多个副本,可以使用 [s3Cluster 函数](../../sql-reference/table-functions/s3Cluster.md) 来并行插入。 -使用 `s3 表函数` 与 [`INSERT INTO...SELECT`](../../sql-reference/statements/insert-into#inserting-the-results-of-select) 时,数据以流式方式读取和插入。在从 S3 持续读取数据并传送到目标表的同时,只有几个数据块驻留在内存中。 +使用 `s3 表函数` 与 [`INSERT INTO...SELECT`](../../sql-reference/statements/insert-into#inserting-the-results-of-select) 时,数据以流式方式读取和插入。在从 S3 持续读取块并推送到目标表时,仅有少量数据块驻留在内存中。 ## 语法 {#syntax} ```sql -s3(url [, NOSIGN | access_key_id, secret_access_key, [session_token]] [,format] [,structure] [,compression_method],[,headers]) +s3(url [, NOSIGN | access_key_id, secret_access_key, [session_token]] [,format] [,structure] [,compression_method],[,headers], [,partition_strategy], [,partition_columns_in_data_file]) s3(named_collection[, option=value [,..]]) ``` :::tip GCS -S3 表函数通过使用 GCS XML API 和 HMAC 密钥与 Google Cloud Storage 集成。有关端点和 HMAC 的更多详细信息,请参阅 [Google 互操作性文档]( https://cloud.google.com/storage/docs/interoperability)。 +S3 表函数通过使用 GCS XML API 和 HMAC 密钥与 Google Cloud Storage 集成。有关端点和 HMAC 的更多详细信息,请参见 [Google 互操作性文档]( https://cloud.google.com/storage/docs/interoperability)。 -对于 GCS,请在 `access_key_id` 和 `secret_access_key` 的位置替换为您的 HMAC 密钥和 HMAC 秘钥。 +对于 GCS,在 `access_key_id` 和 `secret_access_key` 的地方替换为您的 HMAC 密钥和 HMAC 密码。 ::: **参数** `s3` 表函数支持以下普通参数: -| 参数 | 描述 | -|-----------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `url` | 带有文件路径的存储桶 URL。在只读模式下支持以下通配符:`*`,`**`,`?`,`{abc,def}` 和 `{N..M}`,其中 `N`,`M` 是数字,`'abc'`,`'def'` 是字符串。有关更多信息,请参见 [这里](../../engines/table-engines/integrations/s3.md#wildcards-in-path)。 | -| `NOSIGN` | 如果在凭据位置提供该关键字,则所有请求都不会被签名。 | -| `access_key_id` 和 `secret_access_key` | 指定用于给定端点的凭据的密钥。可选。 | -| `session_token` | 用于给定密钥的会话令牌。传递密钥时可选。 | -| `format` | 文件的 [格式](/sql-reference/formats)。 | -| `structure` | 表的结构。格式为 `'column1_name column1_type, column2_name column2_type, ...'`。 | -| `compression_method` | 参数是可选的。支持的值:`none`,`gzip` 或 `gz`,`brotli` 或 `br`,`xz` 或 `LZMA`,`zstd` 或 `zst`。默认情况下,它将通过文件扩展名自动检测压缩方法。 | -| `headers` | 参数是可选的。允许在 S3 请求中传递头。以 `headers(key=value)` 格式传递,例如 `headers('x-amz-request-payer' = 'requester')`。 | +| 参数 | 描述 | +|-----------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `url` | 包含文件路径的桶 url。在只读模式下支持以下通配符:`*`、`**`、`?`、`{abc,def}` 和 `{N..M}`,其中 `N`、`M` 是数字,`'abc'`、`'def'` 是字符串。有关更多信息,请见 [这里](../../engines/table-engines/integrations/s3.md#wildcards-in-path)。 | +| `NOSIGN` | 如果在凭据位置提供此关键字,则所有请求将不会被签名。 | +| `access_key_id` 和 `secret_access_key` | 指定用于给定端点的凭据的密钥。可选。 | +| `session_token` | 与给定密钥一起使用的会话令牌。传递密钥时可选。 | +| `format` | 文件的 [格式](/sql-reference/formats)。 | +| `structure` | 表的结构。格式为 `'column1_name column1_type, column2_name column2_type, ...'`。 | +| `compression_method` | 参数为可选。支持的值:`none`、`gzip` 或 `gz`、`brotli` 或 `br`、`xz` 或 `LZMA`、`zstd` 或 `zst`。默认情况下,它将根据文件扩展名自动检测压缩方法。 | +| `headers` | 参数为可选。允许在 S3 请求中传递头部。以 `headers(key=value)` 格式传递,例如 `headers('x-amz-request-payer' = 'requester')`。 | +| `partition_strategy` | 参数为可选。支持的值:`WILDCARD` 或 `HIVE`。`WILDCARD` 需要路径中有一个 `{_partition_id}`,该值将替换为分区密钥。`HIVE` 不允许通配符,假设路径是表根,并生成带有 Snowflake ID 作为文件名和文件格式作为扩展名的 Hive 风格分区目录。默认为 `WILDCARD`。 | +| `partition_columns_in_data_file` | 参数为可选。仅与 `HIVE` 分区策略一起使用。告诉 ClickHouse 是否期望在数据文件中写入分区列。默认为 `false`。 | +| `storage_class_name` | 参数为可选。支持的值:`STANDARD` 或 `INTELLIGENT_TIERING`。允许指定 [AWS S3 Intelligent Tiering](https://aws.amazon.com/s3/storage-classes/intelligent-tiering/)。默认为 `STANDARD`。 | :::note GCS -GCS URL 格式为:Google XML API 的端点与 JSON API 不同: +GCS url 的格式为因为 Google XML API 的端点不同于 JSON API: ```text https://storage.googleapis.com/// @@ -61,18 +65,18 @@ https://storage.googleapis.com/// 而不是 ~~https://storage.cloud.google.com~~。 ::: -参数也可以使用 [命名集合](operations/named-collections.md) 传递。在这种情况下,`url`,`access_key_id`,`secret_access_key`,`format`,`structure`,`compression_method` 的工作方式相同,并且支持一些额外参数: +还可以使用 [命名集合](operations/named-collections.md) 传递参数。在这种情况下,`url`、`access_key_id`、`secret_access_key`、`format`、`structure`、`compression_method` 的工作方式相同,并且支持一些额外的参数: -| 参数 | 描述 | -|---------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `filename` | 如果指定,将附加到 URL。 | -| `use_environment_credentials` | 默认为启用,允许使用环境变量 `AWS_CONTAINER_CREDENTIALS_RELATIVE_URI`,`AWS_CONTAINER_CREDENTIALS_FULL_URI`,`AWS_CONTAINER_AUTHORIZATION_TOKEN`,`AWS_EC2_METADATA_DISABLED` 传递额外参数。 | -| `no_sign_request` | 默认为禁用。 | -| `expiration_window_seconds` | 默认值为 120。 | +| 参数 | 描述 | +|-------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `filename` | 如果指定,将附加到 url。 | +| `use_environment_credentials` | 默认启用,允许使用环境变量 `AWS_CONTAINER_CREDENTIALS_RELATIVE_URI`、`AWS_CONTAINER_CREDENTIALS_FULL_URI`、`AWS_CONTAINER_AUTHORIZATION_TOKEN`、`AWS_EC2_METADATA_DISABLED` 传递额外的参数。 | +| `no_sign_request` | 默认禁用。 | +| `expiration_window_seconds` | 默认值为 120。 | ## 返回值 {#returned_value} -一个具有指定结构的表,用于读取或写入指定文件中的数据。 +一个具有指定结构的表,用于在指定文件中读取或写入数据。 ## 示例 {#examples} @@ -98,7 +102,7 @@ LIMIT 5; ``` :::note -ClickHouse 使用文件名扩展名来确定数据格式。例如,我们可以在不使用 `CSVWithNames` 的情况下运行上一个命令: +ClickHouse 使用文件名扩展名来确定数据的格式。例如,我们可以在没有 `CSVWithNames` 的情况下运行之前的命令: ```sql SELECT * @@ -108,12 +112,12 @@ FROM s3( LIMIT 5; ``` -ClickHouse 还可以确定文件的压缩方法。例如,如果文件以 `.csv.gz` 扩展名压缩,ClickHouse 会自动解压缩文件。 +ClickHouse 还可以确定文件的压缩方法。例如,如果文件以 `.csv.gz` 扩展名进行了压缩,ClickHouse 会自动解压缩文件。 ::: ## 用法 {#usage} -假设我们在 S3 上有几个文件,其 URI 如下: +假设我们在 S3 上有几个具有以下 URI 的文件: - 'https://clickhouse-public-datasets.s3.amazonaws.com/my-test-bucket-768/some_prefix/some_file_1.csv' - 'https://clickhouse-public-datasets.s3.amazonaws.com/my-test-bucket-768/some_prefix/some_file_2.csv' @@ -124,7 +128,7 @@ ClickHouse 还可以确定文件的压缩方法。例如,如果文件以 `.csv - 'https://clickhouse-public-datasets.s3.amazonaws.com/my-test-bucket-768/another_prefix/some_file_3.csv' - 'https://clickhouse-public-datasets.s3.amazonaws.com/my-test-bucket-768/another_prefix/some_file_4.csv' -计算以数字 1 到 3 结尾的文件中的行数: +计算文件中以数字 1 到 3 结尾的行数: ```sql SELECT count(*) @@ -151,10 +155,10 @@ FROM s3('https://datasets-documentation.s3.eu-west-3.amazonaws.com/my-test-bucke ``` :::tip -如果您的文件列表包含以零开头的数字范围,请为每个数字单独使用带花括号的结构,或使用 `?`。 +如果您的文件列表包含带有前导零的数字范围,请使用每个数字单独用大括号包裹的构造,或使用 `?`。 ::: -计算名为 `file-000.csv`,`file-001.csv`,...,`file-999.csv` 的文件中的总行数: +计算名为 `file-000.csv`、`file-001.csv`、...、`file-999.csv` 的文件的总行数: ```sql SELECT count(*) @@ -167,38 +171,37 @@ FROM s3('https://datasets-documentation.s3.eu-west-3.amazonaws.com/my-test-bucke └─────────┘ ``` -将数据插入到文件 `test-data.csv.gz` 中: +插入数据到文件 `test-data.csv.gz`: ```sql INSERT INTO FUNCTION s3('https://clickhouse-public-datasets.s3.amazonaws.com/my-test-bucket-768/test-data.csv.gz', 'CSV', 'name String, value UInt32', 'gzip') VALUES ('test-data', 1), ('test-data-2', 2); ``` -将数据从现有表插入到文件 `test-data.csv.gz` 中: +从现有表插入数据到文件 `test-data.csv.gz`: ```sql INSERT INTO FUNCTION s3('https://clickhouse-public-datasets.s3.amazonaws.com/my-test-bucket-768/test-data.csv.gz', 'CSV', 'name String, value UInt32', 'gzip') SELECT name, value FROM existing_table; ``` -Glob ** 可用于递归目录遍历。请考虑以下示例,它将递归获取 `my-test-bucket-768` 目录中的所有文件: +Glob ** 可用于递归目录遍历。考虑以下示例,它将递归地从 `my-test-bucket-768` 目录中获取所有文件: ```sql SELECT * FROM s3('https://clickhouse-public-datasets.s3.amazonaws.com/my-test-bucket-768/**', 'CSV', 'name String, value UInt32', 'gzip'); ``` -以下从 `my-test-bucket` 目录中的任何文件夹递归获取所有 `test-data.csv.gz` 文件: +下面从 `my-test-bucket` 目录中的任何文件夹中递归获取所有 `test-data.csv.gz` 文件: ```sql SELECT * FROM s3('https://clickhouse-public-datasets.s3.amazonaws.com/my-test-bucket-768/**/test-data.csv.gz', 'CSV', 'name String, value UInt32', 'gzip'); ``` -注意:可以在服务器配置文件中指定自定义 URL 映射器。例如: +注意。可以在服务器配置文件中指定自定义 URL 映射器。示例: ```sql SELECT * FROM s3('s3://clickhouse-public-datasets/my-test-bucket-768/**/test-data.csv.gz', 'CSV', 'name String, value UInt32', 'gzip'); ``` -URL `'s3://clickhouse-public-datasets/my-test-bucket-768/**/test-data.csv.gz'` 将替换为 `'http://clickhouse-public-datasets.s3.amazonaws.com/my-test-bucket-768/**/test-data.csv.gz'` - +URL `'s3://clickhouse-public-datasets/my-test-bucket-768/**/test-data.csv.gz'` 将被替换为 `'http://clickhouse-public-datasets.s3.amazonaws.com/my-test-bucket-768/**/test-data.csv.gz'`。 自定义映射器可以添加到 `config.xml` 中: ```xml @@ -227,9 +230,29 @@ FROM s3(creds, url='https://s3-object-url.csv') ## 分区写入 {#partitioned-write} -如果在向 `S3` 表插入数据时指定了 `PARTITION BY` 表达式,则会为每个分区值创建一个单独的文件。将数据分成单独的文件有助于提高读取操作的效率。 +### 分区策略 {#partition-strategy} -**示例** +仅支持 INSERT 查询。 + +`WILDCARD`(默认):在文件路径中将 `{_partition_id}` 通配符替换为实际的分区密钥。 + +`HIVE` 为读取和写入实现 Hive 风格分区。它使用以下格式生成文件:`//.`。 + +**`HIVE` 分区策略示例** + +```sql +INSERT INTO FUNCTION s3(s3_conn, filename='t_03363_function', format=Parquet, partition_strategy='hive') PARTITION BY (year, country) SELECT 2020 as year, 'Russia' as country, 1 as id; +``` + +```result +SELECT _path, * FROM s3(s3_conn, filename='t_03363_function/**.parquet'); + + ┌─_path──────────────────────────────────────────────────────────────────────┬─id─┬─country─┬─year─┐ +1. │ test/t_03363_function/year=2020/country=Russia/7351295896279887872.parquet │ 1 │ Russia │ 2020 │ + └────────────────────────────────────────────────────────────────────────────┴────┴─────────┴──────┘ +``` + +**`WILDCARD` 分区策略示例** 1. 在键中使用分区 ID 创建单独的文件: @@ -238,21 +261,20 @@ INSERT INTO TABLE FUNCTION s3('http://bucket.amazonaws.com/my_bucket/file_{_partition_id}.csv', 'CSV', 'a String, b UInt32, c UInt32') PARTITION BY a VALUES ('x', 2, 3), ('x', 4, 5), ('y', 11, 12), ('y', 13, 14), ('z', 21, 22), ('z', 23, 24); ``` -结果,数据被写入三个文件:`file_x.csv`,`file_y.csv` 和 `file_z.csv`。 +结果数据写入三个文件:`file_x.csv`、`file_y.csv` 和 `file_z.csv`。 -2. 在存储桶名称中使用分区 ID 创建不同存储桶中的文件: +2. 在桶名称中使用分区 ID 创建不同桶中的文件: ```sql INSERT INTO TABLE FUNCTION s3('http://bucket.amazonaws.com/my_bucket_{_partition_id}/file.csv', 'CSV', 'a UInt32, b UInt32, c UInt32') PARTITION BY a VALUES (1, 2, 3), (1, 4, 5), (10, 11, 12), (10, 13, 14), (20, 21, 22), (20, 23, 24); ``` -结果,数据被写入不同存储桶中的三个文件:`my_bucket_1/file.csv`,`my_bucket_10/file.csv` 和 `my_bucket_20/file.csv`。 +结果数据写入三个不同桶中的文件:`my_bucket_1/file.csv`、`my_bucket_10/file.csv` 和 `my_bucket_20/file.csv`。 -## 访问公共存储桶 {#accessing-public-buckets} +## 访问公共桶 {#accessing-public-buckets} -ClickHouse 尝试从许多不同类型的源获取凭据。 -有时,在访问某些公共存储桶时,可能会出现问题,导致客户端返回 `403` 错误。可以通过使用 `NOSIGN` 关键字避免此问题,强制客户端忽略所有凭据,并且不签名请求。 +ClickHouse 会尝试从许多不同类型的源获取凭据。有时,当访问一些公共桶时,会导致客户端返回 `403` 错误代码的问题。通过使用 `NOSIGN` 关键字可以避免此问题,强制客户端忽略所有凭据,并且不签名请求。 ```sql SELECT * @@ -264,35 +286,35 @@ FROM s3( LIMIT 5; ``` -## 使用 S3 凭据 (ClickHouse Cloud) {#using-s3-credentials-clickhouse-cloud} +## 使用 S3 凭证(ClickHouse Cloud) {#using-s3-credentials-clickhouse-cloud} -对于非公共存储桶,用户可以向该函数传递 `aws_access_key_id` 和 `aws_secret_access_key`。例如: +对于非公共桶,用户可以将 `aws_access_key_id` 和 `aws_secret_access_key` 传递给函数。例如: ```sql SELECT count() FROM s3('https://datasets-documentation.s3.eu-west-3.amazonaws.com/mta/*.tsv', '', '','TSVWithNames') ``` -这适合一次性访问或凭据容易轮换的情况。但是,不建议作为长期解决方案以进行重复访问或凭据敏感的情况。在这种情况下,我们建议用户依赖基于角色的访问。 +这适用于一次性访问或凭据可以轻松轮换的情况。然而,这不建议作为重复访问或凭据敏感的长期解决方案。在这种情况下,我们建议用户依赖基于角色的访问。 -ClickHouse Cloud 中的 S3 的基于角色的访问文档在 [这里](/cloud/security/secure-s3#access-your-s3-bucket-with-the-clickhouseaccess-role)。 +ClickHouse Cloud 的 S3 角色访问文档 [在这里](/cloud/security/secure-s3#access-your-s3-bucket-with-the-clickhouseaccess-role)。 -配置完成后,可以通过 `extra_credentials` 参数将 `roleARN` 传递给 s3 函数。例如: +配置后,可以通过 `extra_credentials` 参数将 `roleARN` 传递给 s3 函数。例如: ```sql SELECT count() FROM s3('https://datasets-documentation.s3.eu-west-3.amazonaws.com/mta/*.tsv','CSVWithNames',extra_credentials(role_arn = 'arn:aws:iam::111111111111:role/ClickHouseAccessRole-001')) ``` -更多示例可以在 [这里](/cloud/security/secure-s3#access-your-s3-bucket-with-the-clickhouseaccess-role) 找到。 +进一步的示例可以在 [这里](/cloud/security/secure-s3#access-your-s3-bucket-with-the-clickhouseaccess-role) 找到。 ## 处理归档 {#working-with-archives} -假设我们在 S3 上有几个归档文件,其 URI 如下: +假设我们在 S3 上有几个归档文件,具有以下 URI: - 'https://s3-us-west-1.amazonaws.com/umbrella-static/top-1m-2018-01-10.csv.zip' - 'https://s3-us-west-1.amazonaws.com/umbrella-static/top-1m-2018-01-11.csv.zip' - 'https://s3-us-west-1.amazonaws.com/umbrella-static/top-1m-2018-01-12.csv.zip' -可以使用 :: 从这些归档中提取数据。Glob 可以在 URL 部分和 :: 之后的部分中都使用(负责归档内部文件的名称)。 +可以使用::从这些归档中提取数据。通配符可以在 url 部分和::(负责归档内文件名的部分)后面部分使用。 ```sql SELECT * @@ -306,35 +328,35 @@ ClickHouse 支持三种归档格式: ZIP TAR 7Z -其中 ZIP 和 TAR 归档可以从任何支持的存储位置访问,但 7Z 归档只能从安装 ClickHouse 的本地文件系统读取。 +ZIP 和 TAR 归档可以从任何支持的存储位置访问,而 7Z 归档只能从安装 ClickHouse 的本地文件系统读取。 ::: ## 插入数据 {#inserting-data} -请注意,行只能插入到新文件中。没有合并周期或文件拆分操作。文件一旦写入,后续插入将失败。更多细节见 [这里](/integrations/s3#inserting-data)。 +注意,行只能插入到新文件中。没有合并周期或文件分割操作。一旦文件被写入,后续插入将失败。有关更多详细信息,请参见 [这里](/integrations/s3#inserting-data)。 ## 虚拟列 {#virtual-columns} -- `_path` — 文件的路径。类型:`LowCardinality(String)`。在归档情况下,显示格式为:`"{path_to_archive}::{path_to_file_inside_archive}"`。 -- `_file` — 文件名。类型:`LowCardinality(String)`。在归档情况下,显示归档内的文件名。 -- `_size` — 文件的字节大小。类型:`Nullable(UInt64)`。如果文件大小未知,则值为 `NULL`。在归档情况下,显示归档内文件的未压缩文件大小。 +- `_path` — 文件路径。类型:`LowCardinality(String)`。在归档的情况下,以格式:`"{path_to_archive}::{path_to_file_inside_archive}"` 显示。 +- `_file` — 文件名。类型:`LowCardinality(String)`。在归档的情况下,显示归档内的文件名。 +- `_size` — 文件大小(以字节为单位)。类型:`Nullable(UInt64)`。如果文件大小未知,则值为 `NULL`。在归档的情况下,显示归档内文件的未压缩大小。 - `_time` — 文件的最后修改时间。类型:`Nullable(DateTime)`。如果时间未知,则值为 `NULL`。 -## Hive 风格的分区 {#hive-style-partitioning} +## use_hive_partitioning 设置 {#hive-style-partitioning} -当设置 `use_hive_partitioning` 为 1 时,ClickHouse 将在路径中检测 Hive 风格的分区 (`/name=value/`) 并允许在查询中使用分区列作为虚拟列。这些虚拟列的名称与分区路径中的名称相同,但以 `_` 开头。 +这是 ClickHouse 在读取时解析 Hive 风格分区文件的提示。对写入没有影响。对于对称读取和写入,请使用 `partition_strategy` 参数。 -**示例** +当设置 `use_hive_partitioning` 为 1 时,ClickHouse 将在路径中检测 Hive 风格分区(`/name=value/`),并允许在查询中将分区列用作虚拟列。这些虚拟列将具有与分区路径中相同的名称,但以 `_` 开头。 -使用 Hive 风格分区创建的虚拟列 +**示例** ```sql -SELECT * from s3('s3://data/path/date=*/country=*/code=*/*.parquet') where date > '2020-01-01' and country = 'Netherlands' and code = 42; +SELECT * FROM s3('s3://data/path/date=*/country=*/code=*/*.parquet') WHERE date > '2020-01-01' AND country = 'Netherlands' AND code = 42; ``` -## 访问请求者支付存储桶 {#accessing-requester-pays-buckets} +## 访问请求者付费桶 {#accessing-requester-pays-buckets} -要访问请求者支付存储桶,必须在任何请求中传递头 `x-amz-request-payer = requester`。这可以通过将参数 `headers('x-amz-request-payer' = 'requester')` 传递给 s3 函数来实现。例如: +要访问请求者付费桶,必须在任何请求中传递头部 `x-amz-request-payer = requester`。这可以通过将参数 `headers('x-amz-request-payer' = 'requester')` 传递给 s3 函数来实现。例如: ```sql SELECT @@ -352,8 +374,8 @@ Peak memory usage: 192.27 KiB. ## 存储设置 {#storage-settings} -- [s3_truncate_on_insert](operations/settings/settings.md#s3_truncate_on_insert) - 允许在插入前截断文件。默认情况下禁用。 -- [s3_create_new_file_on_insert](operations/settings/settings.md#s3_create_new_file_on_insert) - 如果格式有后缀,则允许在每次插入时创建新文件。默认情况下禁用。 +- [s3_truncate_on_insert](operations/settings/settings.md#s3_truncate_on_insert) - 允许在插入之前截断文件。默认情况下禁用。 +- [s3_create_new_file_on_insert](operations/settings/settings.md#s3_create_new_file_on_insert) - 如果格式具有后缀,允许在每次插入时创建新文件。默认情况下禁用。 - [s3_skip_empty_files](operations/settings/settings.md#s3_skip_empty_files) - 允许在读取时跳过空文件。默认情况下启用。 ## 相关 {#related} diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/s3.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/s3.md.hash index df6697351cc..6fd062474da 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/s3.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/s3.md.hash @@ -1 +1 @@ -c889cc4cf09caf51 +3731d20e4ec262da diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/s3Cluster.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/s3Cluster.md index 2a5d181584f..2c3f21c46ad 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/s3Cluster.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/s3Cluster.md @@ -1,9 +1,11 @@ --- -'description': '对 s3 表函数的扩展,允许在指定集群中的多个节点并行处理来自 Amazon S3 和 Google Cloud Storage 的文件。' +'description': '对 s3 表函数的扩展,允许在指定集群中的多个节点上并行处理来自 Amazon S3 和 Google Cloud Storage + 的文件。' 'sidebar_label': 's3Cluster' 'sidebar_position': 181 'slug': '/sql-reference/table-functions/s3Cluster' 'title': 's3Cluster' +'doc_type': 'reference' --- @@ -11,7 +13,7 @@ 这是对 [s3](sql-reference/table-functions/s3.md) 表函数的扩展。 -允许在指定集群中的多个节点上并行处理来自 [Amazon S3](https://aws.amazon.com/s3/) 和 Google Cloud Storage [Google Cloud Storage](https://cloud.google.com/storage/) 的文件。在发起者处,它会创建与集群中所有节点的连接,披露 S3 文件路径中的星号,并动态分发每个文件。在工作节点上,它会询问发起者下一个要处理的任务并进行处理。这个过程会重复,直到所有任务完成。 +允许在指定集群中的多个节点上并行处理来自 [Amazon S3](https://aws.amazon.com/s3/) 和 Google Cloud Storage [Google Cloud Storage](https://cloud.google.com/storage/) 的文件。在发起者上,它创建与集群中所有节点的连接,披露 S3 文件路径中的星号,并动态分发每个文件。在工作节点上,它向发起者请求下一个要处理的任务并进行处理。这一过程将重复,直到所有任务完成。 ## 语法 {#syntax} @@ -22,35 +24,35 @@ s3Cluster(cluster_name, named_collection[, option=value [,..]]) ## 参数 {#arguments} -| 参数 | 描述 | -|----------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `cluster_name` | 用于构建远程和本地服务器地址及连接参数的集群名称。 | -| `url` | 文件或一组文件的路径。在只读模式下支持以下通配符:`*`、`**`、`?`、`{'abc','def'}` 和 `{N..M}`,其中 `N` 和 `M` 是数字,`abc` 和 `def` 是字符串。有关更多信息,请参见 [路径中的通配符](../../engines/table-engines/integrations/s3.md#wildcards-in-path)。 | -| `NOSIGN` | 如果在凭证位置提供此关键字,则所有请求将不被签名。 | -| `access_key_id` 和 `secret_access_key` | 用于指定与给定端点一起使用的凭证的密钥。可选。 | -| `session_token` | 用于给定密钥的会话令牌。在传递密钥时可选。 | -| `format` | 文件的 [格式](/sql-reference/formats)。 | -| `structure` | 表的结构。格式为 `'column1_name column1_type, column2_name column2_type, ...'`。 | -| `compression_method` | 参数是可选的。支持的值为:`none`、`gzip` 或 `gz`、`brotli` 或 `br`、`xz` 或 `LZMA`、`zstd` 或 `zst`。默认情况下,它会根据文件扩展名自动检测压缩方法。 | -| `headers` | 参数是可选的。允许在 S3 请求中传递头部。格式为 `headers(key=value)`,例如 `headers('x-amz-request-payer' = 'requester')`。有关用法示例,请参见 [这里](/sql-reference/table-functions/s3#accessing-requester-pays-buckets)。 | -| `extra_credentials` | 可选。可以通过此参数传递 `roleARN`。有关示例,请参见 [这里](/cloud/security/secure-s3#access-your-s3-bucket-with-the-clickhouseaccess-role)。 | - -参数也可以使用 [命名集合](operations/named-collections.md) 传递。在这种情况下,`url`、`access_key_id`、`secret_access_key`、`format`、`structure`、`compression_method` 的工作方式相同,并支持一些额外参数: - -| 参数 | 描述 | -|--------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `filename` | 如果指定,则附加到 URL 后面。 | -| `use_environment_credentials` | 默认启用,允许使用环境变量 `AWS_CONTAINER_CREDENTIALS_RELATIVE_URI`、`AWS_CONTAINER_CREDENTIALS_FULL_URI`、`AWS_CONTAINER_AUTHORIZATION_TOKEN`、`AWS_EC2_METADATA_DISABLED` 传递额外参数。 | -| `no_sign_request` | 默认禁用。 | -| `expiration_window_seconds` | 默认值为 120。 | +| 参数 | 描述 | +|---------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `cluster_name` | 用于构建远程和本地服务器地址和连接参数的集群名称。 | +| `url` | 文件或多个文件的路径。在只读模式下支持以下通配符:`*`、`**`、`?`、`{'abc','def'}` 和 `{N..M}`,其中 `N`、`M` — 数字,`abc`、`def` — 字符串。有关更多信息,请参见 [路径中的通配符](../../engines/table-engines/integrations/s3.md#wildcards-in-path)。 | +| `NOSIGN` | 如果在凭证的位置提供此关键字,则所有请求都将不被签名。 | +| `access_key_id` 和 `secret_access_key` | 指定与给定端点使用的凭证的密钥。可选。 | +| `session_token` | 与给定密钥一起使用的会话令牌。传递密钥时为可选项。 | +| `format` | 文件的 [格式](/sql-reference/formats)。 | +| `structure` | 表的结构。格式为 `'column1_name column1_type, column2_name column2_type, ...'`。 | +| `compression_method` | 参数是可选的。支持的值:`none`、`gzip` 或 `gz`、`brotli` 或 `br`、`xz` 或 `LZMA`、`zstd` 或 `zst`。默认情况下,将根据文件扩展名自动检测压缩方法。 | +| `headers` | 参数是可选的。允许在 S3 请求中传递头信息。以 `headers(key=value)` 的格式传入,例如 `headers('x-amz-request-payer' = 'requester')`。有关用法示例,请参见 [这里](/sql-reference/table-functions/s3#accessing-requester-pays-buckets)。 | +| `extra_credentials` | 可选。可以通过此参数传递 `roleARN`。有关示例,请参见 [这里](/cloud/security/secure-s3#access-your-s3-bucket-with-the-clickhouseaccess-role)。 | + +参数也可以使用 [命名集合](operations/named-collections.md) 进行传递。在这种情况下,`url`、`access_key_id`、`secret_access_key`、`format`、`structure`、`compression_method` 的工作方式相同,并支持一些额外参数: + +| 参数 | 描述 | +|---------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `filename` | 如果指定,则附加到 url。 | +| `use_environment_credentials` | 默认启用,允许使用环境变量传递额外参数 `AWS_CONTAINER_CREDENTIALS_RELATIVE_URI`、`AWS_CONTAINER_CREDENTIALS_FULL_URI`、`AWS_CONTAINER_AUTHORIZATION_TOKEN`、`AWS_EC2_METADATA_DISABLED`。 | +| `no_sign_request` | 默认禁用。 | +| `expiration_window_seconds` | 默认值为 120。 | ## 返回值 {#returned_value} -具有指定结构的表,用于读取或写入指定文件中的数据。 +具有指定结构的表,用于在指定文件中读取或写入数据。 ## 示例 {#examples} -选择 `/root/data/clickhouse` 和 `/root/data/database/` 文件夹中所有文件的数据,使用 `cluster_simple` 集群中的所有节点: +从 `cluster_simple` 集群中的 `/root/data/clickhouse` 和 `/root/data/database/` 文件夹中的所有文件选择数据: ```sql SELECT * FROM s3Cluster( @@ -63,10 +65,10 @@ SELECT * FROM s3Cluster( ) ORDER BY (name, value, polygon); ``` -计算 `cluster_simple` 集群中所有文件的总行数: +计算集群 `cluster_simple` 中所有文件的总行数: :::tip -如果您的文件列表包含带有前导零的数字范围,请分别为每个数字使用带括号的构造或使用 `?`。 +如果您的文件列表包含带有前导零的数字范围,请为每个数字单独使用带大括号的构造,或使用 `?`。 ::: 对于生产用例,建议使用 [命名集合](operations/named-collections.md)。以下是示例: @@ -83,9 +85,9 @@ SELECT count(*) FROM s3Cluster( ## 访问私有和公共桶 {#accessing-private-and-public-buckets} -用户可以使用与 s3 函数 [这里](/sql-reference/table-functions/s3#accessing-public-buckets) 相同的方法。 +用户可以使用相同的方法访问 s3 函数的 [公共桶](sql-reference/table-functions/s3#accessing-public-buckets)。 -## 优化性能 {#optimizing-performance} +## 性能优化 {#optimizing-performance} 有关优化 s3 函数性能的详细信息,请参见 [我们的详细指南](/integrations/s3/performance)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/s3Cluster.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/s3Cluster.md.hash index e55e3d02e79..74df3d2ea2c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/s3Cluster.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/s3Cluster.md.hash @@ -1 +1 @@ -1322c25a7106c157 +1523112720b640af diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/sqlite.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/sqlite.md index fb1e0e22db0..9604ffeff48 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/sqlite.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/sqlite.md @@ -1,9 +1,10 @@ --- -'description': '允许对存储在 SQLite DATABASE 中的数据执行查询。' +'description': '允许在存储在 SQLite DATABASE中的数据上执行查询。' 'sidebar_label': 'sqlite' 'sidebar_position': 185 'slug': '/sql-reference/table-functions/sqlite' 'title': 'sqlite' +'doc_type': 'reference' --- @@ -24,7 +25,7 @@ sqlite('db_path', 'table_name') ## 返回值 {#returned_value} -- 一个表对象,具有与原始 `SQLite` 表相同的列。 +- 一个与原始 `SQLite` 表具有相同列的表对象。 ## 示例 {#example} diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/sqlite.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/sqlite.md.hash index 789bf66c906..37197859222 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/sqlite.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/sqlite.md.hash @@ -1 +1 @@ -8485d6caf24639cf +8fcf1a044161011a diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/timeSeriesData.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/timeSeriesData.md index b810f9c5a46..5991d16397a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/timeSeriesData.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/timeSeriesData.md @@ -1,27 +1,28 @@ --- -'description': 'timeSeriesData 返回用于表 `db_name.time_series_table` 的数据表,该表引擎为 TimeSeries.' +'description': 'timeSeriesData 返回由表 `db_name.time_series_table` 使用的数据表,其表引擎是 TimeSeries.' 'sidebar_label': 'timeSeriesData' 'sidebar_position': 145 'slug': '/sql-reference/table-functions/timeSeriesData' 'title': 'timeSeriesData' +'doc_type': 'reference' --- # timeSeriesData 表函数 -`timeSeriesData(db_name.time_series_table)` - 返回由表 `db_name.time_series_table` 使用的 [数据](../../engines/table-engines/integrations/time-series.md#data-table) 表,该表引擎为 [TimeSeries](../../engines/table-engines/integrations/time-series.md): +`timeSeriesData(db_name.time_series_table)` - 返回由表 `db_name.time_series_table` 使用的 [data](../../engines/table-engines/integrations/time-series.md#data-table) 表,其表引擎为 [TimeSeries](../../engines/table-engines/integrations/time-series.md): ```sql CREATE TABLE db_name.time_series_table ENGINE=TimeSeries DATA data_table ``` -如果 _data_ 表是内部的,该函数也可以工作: +如果 _data_ 表是内部的,函数也可以正常工作: ```sql CREATE TABLE db_name.time_series_table ENGINE=TimeSeries DATA INNER UUID '01234567-89ab-cdef-0123-456789abcdef' ``` -以下查询是等效的: +以下查询是等价的: ```sql SELECT * FROM timeSeriesData(db_name.time_series_table); diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/timeSeriesData.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/timeSeriesData.md.hash index 2f811b75f19..e37fda12631 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/timeSeriesData.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/timeSeriesData.md.hash @@ -1 +1 @@ -20b27b41a37d4855 +a761d12a7181f179 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/timeSeriesMetrics.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/timeSeriesMetrics.md index 0f4f2b83fa5..1d17b0786e3 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/timeSeriesMetrics.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/timeSeriesMetrics.md @@ -1,22 +1,23 @@ --- -'description': 'timeSeriesMetrics 返回由表 `db_name.time_series_table` 使用的指标表,该表引擎为 TimeSeries +'description': 'timeSeriesMetrics 返回由表 `db_name.time_series_table` 使用的指标表,其表引擎是 TimeSeries 引擎。' 'sidebar_label': 'timeSeriesMetrics' 'sidebar_position': 145 'slug': '/sql-reference/table-functions/timeSeriesMetrics' 'title': 'timeSeriesMetrics' +'doc_type': 'reference' --- # timeSeriesMetrics 表函数 -`timeSeriesMetrics(db_name.time_series_table)` - 返回由表 `db_name.time_series_table` 使用的 [metrics](../../engines/table-engines/integrations/time-series.md#metrics-table) 表,该表的表引擎为 [TimeSeries](../../engines/table-engines/integrations/time-series.md) 引擎: +`timeSeriesMetrics(db_name.time_series_table)` - 返回由表 `db_name.time_series_table` 使用的 [metrics](../../engines/table-engines/integrations/time-series.md#metrics-table) 表,该表的引擎是 [TimeSeries](../../engines/table-engines/integrations/time-series.md) 引擎: ```sql CREATE TABLE db_name.time_series_table ENGINE=TimeSeries METRICS metrics_table ``` -如果 _metrics_ 表是内部的,该函数也能正常工作: +如果 _metrics_ 表是内部的,该函数也可以正常工作: ```sql CREATE TABLE db_name.time_series_table ENGINE=TimeSeries METRICS INNER UUID '01234567-89ab-cdef-0123-456789abcdef' diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/timeSeriesMetrics.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/timeSeriesMetrics.md.hash index a375c3408d9..c9ed14137c7 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/timeSeriesMetrics.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/timeSeriesMetrics.md.hash @@ -1 +1 @@ -ec10cffd0ca9a1e9 +29f1990247b88757 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/timeSeriesSelector.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/timeSeriesSelector.md new file mode 100644 index 00000000000..468757f7126 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/timeSeriesSelector.md @@ -0,0 +1,44 @@ +--- +'description': '从 TimeSeries 表中读取时间序列,通过选择器过滤,并且在指定的时间间隔内使用时间戳.' +'sidebar_label': 'timeSeriesSelector' +'sidebar_position': 145 +'slug': '/sql-reference/table-functions/timeSeriesSelector' +'title': 'timeSeriesSelector' +'doc_type': 'reference' +--- + + +# timeSeriesSelector 表函数 + +从按选择条件过滤的 TimeSeries 表中读取时间序列,并且时间戳在指定的区间内。这个函数类似于 [范围选择器](https://prometheus.io/docs/prometheus/latest/querying/basics/#range-vector-selectors),但它也用于实现 [即时选择器](https://prometheus.io/docs/prometheus/latest/querying/basics/#instant-vector-selectors)。 + +## 语法 {#syntax} + +```sql +timeSeriesSelector('db_name', 'time_series_table', 'instant_query', min_time, max_time) +timeSeriesSelector(db_name.time_series_table, 'instant_query', min_time, max_time) +timeSeriesSelector('time_series_table', 'instant_query', min_time, max_time) +``` + +## 参数 {#arguments} + +- `db_name` - 存在 TimeSeries 表的数据库名称。 +- `time_series_table` - TimeSeries 表的名称。 +- `instant_query` - 用 [PromQL 语法](https://prometheus.io/docs/prometheus/latest/querying/basics/#instant-vector-selectors) 编写的即时选择器,无需 `@` 或 `offset` 修饰符。 +- `min_time` - 开始时间戳,包含在内。 +- `max_time` - 结束时间戳,包含在内。 + +## 返回值 {#returned_value} + +该函数返回三列: +- `id` - 包含与指定选择器匹配的时间序列的标识符。 +- `timestamp` - 包含时间戳。 +- `value` - 包含值。 + +返回的数据没有特定的顺序。 + +## 示例 {#example} + +```sql +SELECT * FROM timeSeriesSelector(mytable, 'http_requests{job="prometheus"}', now() - INTERVAL 10 MINUTES, now()) +``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/timeSeriesSelector.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/timeSeriesSelector.md.hash new file mode 100644 index 00000000000..00550bae7c3 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/timeSeriesSelector.md.hash @@ -0,0 +1 @@ +6bf8ab038586ccaa diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/timeSeriesTags.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/timeSeriesTags.md index b99c79df8c3..90c4a5ee0f5 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/timeSeriesTags.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/timeSeriesTags.md @@ -1,22 +1,23 @@ --- -'description': 'timeSeriesTags 表函数返回使用的标签表 由表 `db_name.time_series_table`,其表引擎为 TimeSeries +'description': 'timeSeriesTags 表函数返回由表 `db_name.time_series_table` 使用的标签表,该表的引擎是 TimeSeries 引擎。' 'sidebar_label': 'timeSeriesTags' 'sidebar_position': 145 'slug': '/sql-reference/table-functions/timeSeriesTags' 'title': 'timeSeriesTags' +'doc_type': 'reference' --- # timeSeriesTags 表函数 -`timeSeriesTags(db_name.time_series_table)` - 返回由表 `db_name.time_series_table` 使用的 [tags](../../engines/table-engines/integrations/time-series.md#tags-table) 表,该表的引擎是 [TimeSeries](../../engines/table-engines/integrations/time-series.md) 引擎: +`timeSeriesTags(db_name.time_series_table)` - 返回由表 `db_name.time_series_table` 使用的 [tags](../../engines/table-engines/integrations/time-series.md#tags-table) 表,该表的表引擎为 [TimeSeries](../../engines/table-engines/integrations/time-series.md) 引擎: ```sql CREATE TABLE db_name.time_series_table ENGINE=TimeSeries TAGS tags_table ``` -如果 _tags_ 表是内部的,该函数也可以工作: +如果 _tags_ 表是内部的,则该函数也可以正常工作: ```sql CREATE TABLE db_name.time_series_table ENGINE=TimeSeries TAGS INNER UUID '01234567-89ab-cdef-0123-456789abcdef' diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/timeSeriesTags.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/timeSeriesTags.md.hash index 893778ebb42..67b6395fb54 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/timeSeriesTags.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/timeSeriesTags.md.hash @@ -1 +1 @@ -299850b77f1fccee +88b513c79c2f8629 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/url.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/url.md index 4934c09571e..71e59c88192 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/url.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/url.md @@ -1,9 +1,10 @@ --- -'description': '从 `URL` 创建一个表,使用给定的 `format` 和 `structure`' +'description': '根据给定的 `format` 和 `structure` 从 `URL` 创建一个表' 'sidebar_label': 'url' 'sidebar_position': 200 'slug': '/sql-reference/table-functions/url' 'title': 'url' +'doc_type': 'reference' --- import ExperimentalBadge from '@theme/badges/ExperimentalBadge'; @@ -12,9 +13,9 @@ import CloudNotSupportedBadge from '@theme/badges/CloudNotSupportedBadge'; # url 表函数 -`url` 函数从给定的 `URL` 创建一个具有指定 `format` 和 `structure` 的表。 +`url` 函数根据给定的 `format` 和 `structure` 从 `URL` 创建一个表。 -`url` 函数可以在数据的 `SELECT` 和 `INSERT` 查询中使用,数据来源于 [URL](../../engines/table-engines/special/url.md) 表。 +`url` 函数可以在 [URL](../../engines/table-engines/special/url.md) 表的数据的 `SELECT` 和 `INSERT` 查询中使用。 ## 语法 {#syntax} @@ -24,26 +25,26 @@ url(URL [,format] [,structure] [,headers]) ## 参数 {#parameters} -| 参数 | 描述 | -|------------|-------------------------------------------------------------------------------------------------------------------------------------------------------| -| `URL` | HTTP 或 HTTPS 服务器地址,能够接受 `GET` 或 `POST` 请求(分别对应 `SELECT` 或 `INSERT` 查询)。类型: [String](../../sql-reference/data-types/string.md)。 | -| `format` | 数据的 [Format](/sql-reference/formats)。类型: [String](../../sql-reference/data-types/string.md)。 | -| `structure`| 表结构,格式为 `'UserID UInt64, Name String'`。确定列名称和类型。类型: [String](../../sql-reference/data-types/string.md)。 | -| `headers` | 以 `'headers('key1'='value1', 'key2'='value2')'` 格式的头信息。可以为 HTTP 调用设置头信息。 | +| 参数 | 描述 | +|------------|-----------------------------------------------------------------------------------------------------------------------------------------------| +| `URL` | 单引号括起来的 HTTP 或 HTTPS 服务器地址,可以接受 `GET` 或 `POST` 请求(分别用于 `SELECT` 或 `INSERT` 查询)。类型: [String](../../sql-reference/data-types/string.md)。 | +| `format` | 数据的 [格式](/sql-reference/formats)。类型: [String](../../sql-reference/data-types/string.md)。 | +| `structure`| 表结构,格式为 `'UserID UInt64, Name String'`。确定列名和类型。类型: [String](../../sql-reference/data-types/string.md)。 | +| `headers` | 以 `'headers('key1'='value1', 'key2'='value2')'` 格式提供的头部信息。可以为 HTTP 请求设置头部。 | ## 返回值 {#returned_value} -一个具有指定格式和结构的表,并且数据来自定义的 `URL`。 +一个具有指定格式和结构,并包含来自定义 `URL` 数据的表。 ## 示例 {#examples} -从 HTTP 服务器获取包含 `String` 和 [UInt32](../../sql-reference/data-types/int-uint.md) 类型列的表的前 3 行,该服务器以 [CSV](../../interfaces/formats.md#csv) 格式响应。 +获取一个包含 `String` 类型和 [UInt32](../../sql-reference/data-types/int-uint.md) 类型列的表的前 3 行,该表来自以 [CSV](../../interfaces/formats.md#csv) 格式响应的 HTTP 服务器。 ```sql SELECT * FROM url('http://127.0.0.1:12345/', CSV, 'column1 String, column2 UInt32', headers('Accept'='text/csv; charset=utf-8')) LIMIT 3; ``` -将数据从 `URL` 插入到表中: +从 `URL` 向表中插入数据: ```sql CREATE TABLE test_table (column1 String, column2 UInt32) ENGINE=Memory; @@ -53,37 +54,37 @@ SELECT * FROM test_table; ## URL 中的通配符 {#globs-in-url} -大括号 `{ }` 中的模式用于生成一组分片或指定故障转移地址。支持的模式类型和示例见 [remote](remote.md#globs-in-addresses) 函数的描述。 -模式中的字符 `|` 用于指定故障转移地址。它们按模式中列出的顺序进行迭代。生成的地址数量受到 [glob_expansion_max_elements](../../operations/settings/settings.md#glob_expansion_max_elements) 设置的限制。 +大括号 `{ }` 中的模式用于生成一组分片或指定故障转移地址。支持的模式类型和示例请参见 [remote](remote.md#globs-in-addresses) 函数的描述。 +模式中的字符 `|` 用于指定故障转移地址。它们按照在模式中列出的顺序进行迭代。生成的地址数量由 [glob_expansion_max_elements](../../operations/settings/settings.md#glob_expansion_max_elements) 设置限制。 ## 虚拟列 {#virtual-columns} - `_path` — `URL` 的路径。类型: `LowCardinality(String)`。 - `_file` — `URL` 的资源名称。类型: `LowCardinality(String)`。 -- `_size` — 资源的字节大小。类型: `Nullable(UInt64)`。如果大小未知,值为 `NULL`。 -- `_time` — 文件的最后修改时间。类型: `Nullable(DateTime)`。如果时间未知,值为 `NULL`。 +- `_size` — 资源的字节大小。类型: `Nullable(UInt64)`。如果大小未知,则值为 `NULL`。 +- `_time` — 文件的最后修改时间。类型: `Nullable(DateTime)`。如果时间未知,则值为 `NULL`。 - `_headers` - HTTP 响应头。类型: `Map(LowCardinality(String), LowCardinality(String))`。 -## Hive 风格分区 {#hive-style-partitioning} +## use_hive_partitioning 设置 {#hive-style-partitioning} -当将 `use_hive_partitioning` 设置为 1 时,ClickHouse 会在路径中检测 Hive 风格的分区 (`/name=value/`),并允许在查询中将分区列用作虚拟列。这些虚拟列将与分区路径中的名称相同,但以 `_` 开头。 +当设置 `use_hive_partitioning` 为 1 时,ClickHouse 将在路径中检测到 Hive 风格的分区(`/name=value/`),并允许在查询中将分区列用作虚拟列。这些虚拟列将具有与分区路径中相同的名称,但以 `_` 开头。 **示例** 使用 Hive 风格分区创建的虚拟列 ```sql -SELECT * from url('http://data/path/date=*/country=*/code=*/*.parquet') where _date > '2020-01-01' and _country = 'Netherlands' and _code = 42; +SELECT * FROM url('http://data/path/date=*/country=*/code=*/*.parquet') WHERE _date > '2020-01-01' AND _country = 'Netherlands' AND _code = 42; ``` ## 存储设置 {#storage-settings} -- [engine_url_skip_empty_files](/operations/settings/settings.md#engine_url_skip_empty_files) - 允许在读取时跳过空文件。默认情况下禁用。 -- [enable_url_encoding](/operations/settings/settings.md#enable_url_encoding) - 允许启用/禁用 URI 中路径的解码/编码。默认情况下启用。 +- [engine_url_skip_empty_files](/operations/settings/settings.md#engine_url_skip_empty_files) - 允许在读取时跳过空文件。默认为禁用。 +- [enable_url_encoding](/operations/settings/settings.md#enable_url_encoding) - 允许启用/禁用 URI 路径的解码/编码。默认为启用。 ## 权限 {#permissions} -`url` 函数需要 `CREATE TEMPORARY TABLE` 权限。因此,无法用于具有 [readonly](/operations/settings/permissions-for-queries#readonly) = 1 设置的用户。至少需要 readonly = 2。 +`url` 函数需要 `CREATE TEMPORARY TABLE` 权限。因此,它将无法在 [readonly](/operations/settings/permissions-for-queries#readonly) = 1 设置的用户中使用。至少需要 readonly = 2。 ## 相关 {#related} diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/url.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/url.md.hash index 3f7b6c38197..4a6bd509166 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/url.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/url.md.hash @@ -1 +1 @@ -7ac5c0517a7752c9 +0cc9a29423a42b14 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/urlCluster.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/urlCluster.md index 60302e3213e..fc52b88f927 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/urlCluster.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/urlCluster.md @@ -1,15 +1,16 @@ --- -'description': '允许从指定集群的多个节点并行处理来自 URL 的文件。' +'description': '允许从指定的集群中的多个节点并行处理来自URL的文件。' 'sidebar_label': 'urlCluster' 'sidebar_position': 201 'slug': '/sql-reference/table-functions/urlCluster' 'title': 'urlCluster' +'doc_type': 'reference' --- # urlCluster 表函数 -允许从指定集群中的多个节点并行处理来自 URL 的文件。在发起者上,它创建与集群中所有节点的连接,公开 URL 文件路径中的星号,并动态分派每个文件。在工作节点上,它向发起者询问下一个需要处理的任务并进行处理。这个过程会重复,直到所有任务完成。 +允许从指定集群中的许多节点并行处理来自 URL 的文件。在发起者上,它会建立与集群中所有节点的连接,公开 URL 文件路径中的星号,并动态分发每个文件。在工作节点上,它会询问发起者下一个待处理的任务,并处理该任务。这个过程会重复,直到所有任务完成。 ## 语法 {#syntax} @@ -19,22 +20,22 @@ urlCluster(cluster_name, URL, format, structure) ## 参数 {#arguments} -| 参数 | 描述 | -|-----------------|--------------------------------------------------------------------------------------------------------------------------------------------------| -| `cluster_name` | 用于构建远程和本地服务器的地址和连接参数集合的集群名称。 | -| `URL` | 可以接受 `GET` 请求的 HTTP 或 HTTPS 服务器地址。类型: [String](../../sql-reference/data-types/string.md)。 | -| `format` | 数据的 [格式](/sql-reference/formats)。类型: [String](../../sql-reference/data-types/string.md)。 | -| `structure` | 表结构,格式为 `'UserID UInt64, Name String'`。确定列名和类型。类型: [String](../../sql-reference/data-types/string.md)。 | +| 参数 | 描述 | +|-----------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `cluster_name` | 用于构建对远程和本地服务器的地址和连接参数集的集群名称。 | +| `URL` | 可以接受 `GET` 请求的 HTTP 或 HTTPS 服务器地址。类型: [String](../../sql-reference/data-types/string.md)。 | +| `format` | 数据的 [格式](/sql-reference/formats)。类型: [String](../../sql-reference/data-types/string.md)。 | +| `structure` | 表结构,格式为 `'UserID UInt64, Name String'`。确定列名和类型。类型: [String](../../sql-reference/data-types/string.md)。 | ## 返回值 {#returned_value} -一个具有指定格式和结构、包含来自定义 `URL` 数据的表。 +具有指定格式和结构,并从定义的 `URL` 中获取数据的表。 ## 示例 {#examples} -获取来自返回 [CSV](../../interfaces/formats.md#csv) 格式的 HTTP 服务器的包含 `String` 和 [UInt32](../../sql-reference/data-types/int-uint.md) 类型列的表的前 3 行。 +从返回 [CSV](../../interfaces/formats.md#csv) 格式的 HTTP 服务器获取包含 `String` 和 [UInt32](../../sql-reference/data-types/int-uint.md) 类型列的表的前三行。 -1. 使用标准的 Python 3 工具创建一个基本的 HTTP 服务器并启动它: +1. 使用标准 Python 3 工具创建一个基本的 HTTP 服务器并启动它: ```python from http.server import BaseHTTPRequestHandler, HTTPServer @@ -58,10 +59,10 @@ SELECT * FROM urlCluster('cluster_simple','http://127.0.0.1:12345', CSV, 'column ## URL 中的通配符 {#globs-in-url} -大括号 `{ }` 中的模式用于生成一组分片或指定故障转移地址。支持的模式类型和示例见于 [remote](remote.md#globs-in-addresses) 函数的描述。 -模式中的字符 `|` 用于指定故障转移地址。它们以与模式中列出的顺序相同的顺序进行迭代。生成的地址数量受 [glob_expansion_max_elements](../../operations/settings/settings.md#glob_expansion_max_elements) 设置的限制。 +花括号 `{ }` 中的模式用于生成一组分片或指定故障转移地址。支持的模式类型和示例请参见 [remote](remote.md#globs-in-addresses) 函数的说明。 +模式中的字符 `|` 用于指定故障转移地址。它们按照模式中列出的顺序进行迭代。生成的地址数量受 [glob_expansion_max_elements](../../operations/settings/settings.md#glob_expansion_max_elements) 设置的限制。 -## 相关内容 {#related} +## 相关 {#related} -- [HDFS 引擎](../../engines/table-engines/special/url.md) -- [URL 表函数](../../sql-reference/table-functions/url.md) +- [HDFS 引擎](/engines/table-engines/integrations/hdfs) +- [URL 表函数](/engines/table-engines/special/url) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/urlCluster.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/urlCluster.md.hash index cb2458cd94d..dbec3915d4e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/urlCluster.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/urlCluster.md.hash @@ -1 +1 @@ -a49d05a529579781 +efb0e4529fd11fa2 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/values.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/values.md index b081ec76b31..c895211e83a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/values.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/values.md @@ -1,5 +1,5 @@ --- -'description': '创建临时存储,用于填充列的值。' +'description': '创建一个临时存储,用于填充列的值。' 'keywords': - 'values' - 'table function' @@ -7,18 +7,19 @@ 'sidebar_position': 210 'slug': '/sql-reference/table-functions/values' 'title': '值' +'doc_type': 'reference' --- -# Values Table Function {#values-table-function} +# Values 表函数 {#values-table-function} -`Values` 表函数允许您创建临时存储,以填充包含值的列。这对于快速测试或生成示例数据非常有用。 +`Values` 表函数允许您创建临时存储,以填充列的值。它对于快速测试或生成示例数据非常有用。 :::note -Values 是一个不区分大小写的函数。即,`VALUES` 或 `values` 都是有效的。 +Values 是一个不区分大小写的函数。即 `VALUES` 或 `values` 都是有效的。 ::: -## Syntax {#syntax} +## 语法 {#syntax} `VALUES` 表函数的基本语法为: @@ -37,23 +38,20 @@ VALUES( ) ``` -## Arguments {#arguments} +## 参数 {#arguments} -- `column1_name Type1, ...`(可选)。 [String](/sql-reference/data-types/string) - 指定列名和类型。如果此参数被省略,列将命名为 `c1`、`c2` 等。 -- `(value1_row1, value2_row1)`。[Tuples](/sql-reference/data-types/tuple) - 包含任何类型的值的元组。 +- `column1_name Type1, ...`(可选)。[String](/sql-reference/data-types/string) 指定列的名称和类型。如果省略此参数,列将被命名为 `c1`,`c2` 等。 +- `(value1_row1, value2_row1)`。[Tuples](/sql-reference/data-types/tuple) 包含任何类型的值。 :::note -用逗号分隔的元组也可以被单个值替代。在这种情况下, -每个值被视为新的一行。有关详细信息,请参见 [examples](#examples) 部分。 +用逗号分隔的元组也可以被单个值替代。在这种情况下,每个值被视作一行。有关详情,请参见 [示例](#examples) 部分。 ::: -## Returned value {#returned-value} +## 返回值 {#returned-value} -- 返回一个包含提供值的临时表。 +- 返回一个包含所提供值的临时表。 -## Examples {#examples} +## 示例 {#examples} ```sql title="Query" SELECT * @@ -121,8 +119,7 @@ FROM VALUES( └──────────┘ ``` -或者在不提供行规范的情况下(`'column1_name Type1, column2_name Type2, ...'` -在 [syntax](#syntax) 中),在这种情况下,列会被自动命名。 +或在不提供行规范的情况下(`'column1_name Type1, column2_name Type2, ...'` 在 [语法](#syntax) 中),在这种情况下,列会被自动命名。 例如: @@ -190,6 +187,6 @@ FROM VALUES( └──────────┘ ``` -## See also {#see-also} +## 另请参见 {#see-also} -- [Values format](/interfaces/formats/Values) +- [Values 格式](/interfaces/formats/Values) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/values.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/values.md.hash index ee25a3bab77..629eedaa387 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/values.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/values.md.hash @@ -1 +1 @@ -38c233d3a828bc6f +19582b5a179847fb diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/view.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/view.md index e6a02412d12..129ff10de96 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/view.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/view.md @@ -1,31 +1,32 @@ --- -'description': '将子查询转换为表。该函数实现视图。' +'description': '将子查询转换为一个 TABLE。此功能实现了 视图。' 'sidebar_label': '视图' 'sidebar_position': 210 'slug': '/sql-reference/table-functions/view' 'title': '视图' +'doc_type': 'reference' --- -# view 表函数 +# view Table Function -将子查询转换为一个表。该函数实现了视图(请参见 [CREATE VIEW](/sql-reference/statements/create/view))。生成的表不存储数据,而仅存储指定的 `SELECT` 查询。在从表中读取数据时,ClickHouse 执行查询并从结果中删除所有不必要的列。 +将子查询转换为一个表。该函数实现视图 (参见 [CREATE VIEW](/sql-reference/statements/create/view))。生成的表不存储数据,而只存储指定的 `SELECT` 查询。当从该表读取时,ClickHouse 执行查询并删除结果中所有不必要的列。 -## 语法 {#syntax} +## Syntax {#syntax} ```sql view(subquery) ``` -## 参数 {#arguments} +## Arguments {#arguments} - `subquery` — `SELECT` 查询。 -## 返回值 {#returned_value} +## Returned value {#returned_value} - 一个表。 -## 示例 {#examples} +## Examples {#examples} 输入表: @@ -65,6 +66,6 @@ SELECT * FROM remote(`127.0.0.1`, view(SELECT a, b, c FROM table_name)); SELECT * FROM cluster(`cluster_name`, view(SELECT a, b, c FROM table_name)); ``` -## 相关 {#related} +## Related {#related} -- [视图表引擎](/engines/table-engines/special/view/) +- [View Table Engine](/engines/table-engines/special/view/) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/view.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/view.md.hash index 6b058a4cd7a..04f4eab0517 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/view.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/view.md.hash @@ -1 +1 @@ -3906b4c7c61fa5ac +1bbd7cfc5bd203ac diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/ytsaurus.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/ytsaurus.md new file mode 100644 index 00000000000..395bcaa145b --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/ytsaurus.md @@ -0,0 +1,45 @@ +--- +'description': '该表函数允许从 YTsaurus 集群读取数据。' +'sidebar_label': 'ytsaurus' +'sidebar_position': 85 +'slug': '/sql-reference/table-functions/ytsaurus' +'title': 'ytsaurus' +'doc_type': 'reference' +--- + +import ExperimentalBadge from '@theme/badges/ExperimentalBadge'; + + +# ytsaurus 表函数 + + + +该表函数允许从 YTsaurus 集群中读取数据。 + +## 语法 {#syntax} + +```sql +ytsaurus(http_proxy_url, cypress_path, oauth_token, format) +``` + +:::info +这是一个实验性功能,未来版本可能会以不向后兼容的方式发生变化。 +启用 YTsaurus 表函数的使用 +与 [allow_experimental_ytsaurus_table_function](/operations/settings/settings#allow_experimental_ytsaurus_table_engine) 设置。 +输入命令 `set allow_experimental_ytsaurus_table_function = 1`。 +::: + +## 参数 {#arguments} + +- `http_proxy_url` — YTsaurus HTTP 代理的 URL。 +- `cypress_path` — 数据源的 Cypress 路径。 +- `oauth_token` — OAuth 令牌。 +- `format` — 数据源的 [format](/interfaces/formats)。 + +**返回值** + +一个具有指定结构的表,用于在 YTsaurus 集群中按指定的 YTsaurus Cypress 路径读取数据。 + +**另见** + +- [ytsaurus engine](/engines/table-engines/integrations/ytsaurus.md) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/ytsaurus.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/ytsaurus.md.hash new file mode 100644 index 00000000000..cb057da97f0 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/ytsaurus.md.hash @@ -0,0 +1 @@ +d14338ae11f5aff8 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/zeros.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/zeros.md index 34b451a2f86..aca3f862e8a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/zeros.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/zeros.md @@ -1,20 +1,21 @@ --- 'description': '用于测试目的,作为生成许多行的最快方法。类似于 `system.zeros` 和 `system.zeros_mt` 系统表。' -'sidebar_label': 'zeros' +'sidebar_label': '零' 'sidebar_position': 145 'slug': '/sql-reference/table-functions/zeros' -'title': 'zeros' +'title': '零' +'doc_type': 'reference' --- # zeros 表函数 -* `zeros(N)` – 返回一个包含单个 'zero' 列 (UInt8),该列包含整数 0 `N` 次 -* `zeros_mt(N)` – 与 `zeros` 相同,但使用多个线程。 +* `zeros(N)` – 返回一个包含单列 'zero'(UInt8)且包含整数 0 的表,长度为 `N` +* `zeros_mt(N)` – 与 `zeros` 相同,但使用多线程。 -该函数用于测试目的,是生成多行数据的最快方法。类似于 `system.zeros` 和 `system.zeros_mt` 系统表。 +该函数用于测试目的,是生成许多行的最快方法。类似于 `system.zeros` 和 `system.zeros_mt` 系统表。 -以下查询是等价的: +以下查询是等效的: ```sql SELECT * FROM zeros(10); diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/zeros.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/zeros.md.hash index bec12824fdf..b19e2ee7442 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/zeros.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/table-functions/zeros.md.hash @@ -1 +1 @@ -5a3cc73f5b630ace +8b298f70147e50b5 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/transactions.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/transactions.md index cfe81da4d83..77ba734ee64 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/transactions.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/transactions.md @@ -2,6 +2,7 @@ 'description': '页面描述 ClickHouse 中的事务性 (ACID) 支持' 'slug': '/guides/developer/transactional' 'title': '事务性 (ACID) 支持' +'doc_type': 'guide' --- import ExperimentalBadge from '@theme/badges/ExperimentalBadge'; @@ -10,58 +11,58 @@ import CloudNotSupportedBadge from '@theme/badges/CloudNotSupportedBadge'; # 事务(ACID)支持 -## 案例 1:向一个 MergeTree* 家族的表中的一个分区插入数据 {#case-1-insert-into-one-partition-of-one-table-of-the-mergetree-family} +## 情况 1: 向 MergeTree* 家族的一个表的一个分区中插入 {#case-1-insert-into-one-partition-of-one-table-of-the-mergetree-family} -如果插入的行被打包并作为单个块插入,则这是事务性的(ACID)(请参见注释): -- 原子性:插入成功或作为一个整体被拒绝:如果向客户端发送了确认,则表示所有行都已插入;如果向客户端发送了错误,则表示没有行被插入。 -- 一致性:如果没有违反表约束,则所有插入的行都已插入,插入成功;如果违反了约束,则没有行被插入。 -- 隔离性:并发客户端观察到表的一致快照——表的状态要么是插入尝试之前的状态,要么是成功插入后的状态;看不到部分状态。处于另一个事务内的客户端具有 [快照隔离](https://en.wikipedia.org/wiki/Snapshot_isolation),而事务外的客户端具有 [未提交读取](https://en.wikipedia.org/wiki/Isolation_(database_systems)#Read_uncommitted) 隔离级别。 -- 持久性:成功插入在响应客户端之前写入文件系统,可以在单个副本或多个副本上(由 `insert_quorum` 设置控制),ClickHouse 可以请求操作系统在存储介质上同步文件系统数据(由 `fsync_after_insert` 设置控制)。 -- 如果涉及物化视图,可以使用单个语句向多个表插入数据(来自客户端的插入是针对具有相关物化视图的表)。 +如果插入的行被打包并作为单个块插入,则这是事务性的(ACID)。请参见备注: +- 原子性:一个 INSERT 要么作为一个整体成功,要么被拒绝:如果确认发送到客户端,则所有行都被插入;如果发送错误到客户端,则没有插入任何行。 +- 一致性:如果没有违反表约束,则 INSERT 中的所有行都被插入并且成功;如果违反了约束,则没有插入任何行。 +- 隔离性:并发客户端观察到表的一致快照——表的状态要么是在 INSERT 尝试之前,要么是在成功的 INSERT 之后;没有看到部分状态。在另一个事务内的客户端具有 [快照隔离](https://en.wikipedia.org/wiki/Snapshot_isolation),而在事务外的客户端具有 [读取未提交](https://en.wikipedia.org/wiki/Isolation_(database_systems)#Read_uncommitted) 隔离级别。 +- 持久性:成功的 INSERT 在回答客户端之前写入文件系统,可以在单个副本或多个副本上(由 `insert_quorum` 设置控制),且 ClickHouse 可以请求操作系统在存储介质上同步文件系统数据(由 `fsync_after_insert` 设置控制)。 +- 如果涉及物化视图,使用一个语句向多个表插入是可能的(来自客户端的 INSERT 是到具有相关物化视图的表)。 -## 案例 2:向一个 MergeTree* 家族的表中的多个分区插入数据 {#case-2-insert-into-multiple-partitions-of-one-table-of-the-mergetree-family} +## 情况 2: 向 MergeTree* 家族的一个表的多个分区中插入 {#case-2-insert-into-multiple-partitions-of-one-table-of-the-mergetree-family} -与上面的案例 1 相同,增加以下细节: -- 如果表有许多分区,并且插入涉及多个分区,则对每个分区的插入都是独立的事务。 +与上述情况 1 相同,仅此细节: +- 如果表有多个分区且 INSERT 涉及多个分区,则向每个分区的插入是各自事务性的。 -## 案例 3:向一个 MergeTree* 家族的分布式表插入数据 {#case-3-insert-into-one-distributed-table-of-the-mergetree-family} +## 情况 3: 向 MergeTree* 家族的一个分布式表中插入 {#case-3-insert-into-one-distributed-table-of-the-mergetree-family} -与上面的案例 1 相同,增加以下细节: -- 向分布式表的插入不是整个事务,而对每个分片的插入是事务性的。 +与上述情况 1 相同,仅此细节: +- 向分布式表的插入不是整体事务性的,而向每个分片的插入是事务性的。 -## 案例 4:使用缓冲区表 {#case-4-using-a-buffer-table} +## 情况 4: 使用缓冲表 {#case-4-using-a-buffer-table} -- 向缓冲区表的插入既不是原子性也不是隔离性,也不是一致性或持久性。 +- 向缓冲表的插入既不是原子性的,也不是隔离的、一致的或持久的。 -## 案例 5:使用 async_insert {#case-5-using-async_insert} +## 情况 5: 使用 async_insert {#case-5-using-async_insert} -与上面的案例 1 相同,增加以下细节: -- 即使启用了 `async_insert` 并且将 `wait_for_async_insert` 设置为 1(默认值),也可确保原子性,但如果将 `wait_for_async_insert` 设置为 0,则不保证原子性。 +与上述情况 1 相同,仅此细节: +- 即使启用了 `async_insert` 并且将 `wait_for_async_insert` 设置为 1(默认值),也确保原子性,但如果将 `wait_for_async_insert` 设置为 0,则不保证原子性。 -## 注释 {#notes} -- 从客户端插入的某些数据格式的行在以下情况下打包为一个块: - - 插入格式是基于行的(如 CSV、TSV、值、JSONEachRow 等),并且数据包含少于 `max_insert_block_size` 行(默认约为 1,000,000)或在使用并行解析时包含少于 `min_chunk_bytes_for_parallel_parsing` 字节(默认 10 MB) - - 插入格式是基于列的(如 Native、Parquet、ORC 等),并且数据只包含一个数据块 -- 插入块的大小通常可能依赖于许多设置(例如:`max_block_size`、`max_insert_block_size`、`min_insert_block_size_rows`、`min_insert_block_size_bytes`、`preferred_block_size_bytes` 等) -- 如果客户端没有收到来自服务器的响应,客户端不知道事务是否成功,并且可以重复事务,使用精确一次的插入属性 -- ClickHouse 在内部使用 [MVCC](https://en.wikipedia.org/wiki/Multiversion_concurrency_control) 和 [快照隔离](https://en.wikipedia.org/wiki/Snapshot_isolation) 来处理并发事务 -- 即使在服务器崩溃/死亡的情况下,所有 ACID 属性也有效 -- 在典型设置中,应启用 insert_quorum 到不同的 AZ 或 fsync 以确保持久插入 -- 在 ACID 术语中,“一致性”并不涵盖分布式系统的语义,参见 https://jepsen.io/consistency ,由不同设置(select_sequential_consistency)控制 -- 此说明未涵盖允许进行全功能事务的新的事务功能,支持多个表、物化视图以及多个 SELECT 等(请参见下一个部分关于事务、提交和回滚的内容) +## 备注 {#notes} +- 从客户端以某种数据格式插入的行在以下情况下被打包成单个块: + - 插入格式是基于行的(如 CSV、TSV、Values、JSONEachRow 等),且数据包含的行数少于 `max_insert_block_size`(默认约 1,000,000)或字节数少于 `min_chunk_bytes_for_parallel_parsing`(默认10 MB),在使用并行解析的情况下(默认启用) + - 插入格式是基于列的(如 Native、Parquet、ORC 等),且数据只包含一个数据块。 +- 插入块的大小通常可能依赖于多个设置(例如:`max_block_size`、`max_insert_block_size`、`min_insert_block_size_rows`、`min_insert_block_size_bytes`、`preferred_block_size_bytes` 等)。 +- 如果客户端未收到服务器的答复,客户端不清楚事务是否成功,并且可以重复事务,使用精确一次插入属性。 +- ClickHouse 内部使用 [MVCC](https://en.wikipedia.org/wiki/Multiversion_concurrency_control) 结合 [快照隔离](https://en.wikipedia.org/wiki/Snapshot_isolation) 来处理并发事务。 +- 即使在服务器终止/崩溃的情况下,所有 ACID 属性仍然有效。 +- 在典型设置中,必须启用 `insert_quorum` 到不同的 AZ 或 `fsync` 以确保持久插入。 +- 在 ACID 术语中,“一致性”并不涵盖分布式系统的语义,详见 https://jepsen.io/consistency ,这由不同的设置控制(select_sequential_consistency)。 +- 本解释未涵盖允许在多个表、物化视图上进行全面事务的新增事务功能,涉及多个 SELECT 等(参见下一节关于事务、提交和回滚)。 ## 事务、提交和回滚 {#transactions-commit-and-rollback} -除了本文开头描述的功能外,ClickHouse 还实验性支持事务、提交和回滚功能。 +除了本文开头描述的功能外,ClickHouse 还对事务、提交和回滚功能提供实验性支持。 ### 要求 {#requirements} -- 部署 ClickHouse Keeper 或 ZooKeeper 来跟踪事务 -- 仅限原子数据库(默认) -- 仅限非复制的 MergeTree 表引擎 +- 部署 ClickHouse Keeper 或 ZooKeeper 来跟踪事务。 +- 仅适用于原子数据库(默认)。 +- 仅适用于非复制的 MergeTree 表引擎。 - 通过在 `config.d/transactions.xml` 中添加以下设置来启用实验性事务支持: ```xml @@ -69,14 +70,14 @@ import CloudNotSupportedBadge from '@theme/badges/CloudNotSupportedBadge'; ``` -### 注释 {#notes-1} -- 这是一个实验功能,预计会有变化。 -- 如果在事务期间发生异常,则无法提交事务。这包括所有异常,包括因拼写错误引起的 `UNKNOWN_FUNCTION` 异常。 -- 不支持嵌套事务;请结束当前事务并开始一个新事务。 +### 备注 {#notes-1} +- 这是一个实验性功能,可能会有变动。 +- 如果在事务期间发生异常,您无法提交事务。这包括所有异常,包括由于拼写错误引起的 `UNKNOWN_FUNCTION` 异常。 +- 不支持嵌套事务;请完成当前事务并启动一个新事务。 ### 配置 {#configuration} -这些示例是在启用了 ClickHouse Keeper 的单节点 ClickHouse 服务器上进行的。 +这些示例是在启用 ClickHouse Keeper 的单节点 ClickHouse 服务器上。 #### 启用实验性事务支持 {#enable-experimental-transaction-support} @@ -86,10 +87,10 @@ import CloudNotSupportedBadge from '@theme/badges/CloudNotSupportedBadge';
``` -#### 启用了 ClickHouse Keeper 的单个 ClickHouse 服务器节点的基本配置 {#basic-configuration-for-a-single-clickhouse-server-node-with-clickhouse-keeper-enabled} +#### 启用 ClickHouse Keeper 的单节点 ClickHouse 服务器的基本配置 {#basic-configuration-for-a-single-clickhouse-server-node-with-clickhouse-keeper-enabled} :::note -有关部署 ClickHouse 服务器和适当的 ClickHouse Keeper 节点法定人数的详细信息,请参见 [部署](/deployment-guides/terminology.md) 文档。这里显示的配置仅用于实验目的。 +有关部署 ClickHouse 服务器和适当的 ClickHouse Keeper 节点的配额详情,请参阅 [部署](/deployment-guides/terminology.md) 文档。这里显示的配置仅供实验用途。 ::: ```xml title=/etc/clickhouse-server/config.d/config.xml @@ -136,7 +137,7 @@ import CloudNotSupportedBadge from '@theme/badges/CloudNotSupportedBadge'; #### 验证实验性事务是否已启用 {#verify-that-experimental-transactions-are-enabled} -发出 `BEGIN TRANSACTION` 或 `START TRANSACTION`,后跟 `ROLLBACK` 以验证实验性事务是否已启用,并且 ClickHouse Keeper 已启用,因为它用于跟踪事务。 +发出 `BEGIN TRANSACTION` 或 `START TRANSACTION`,然后跟随 `ROLLBACK` 以验证实验性事务是否已启用,以及 ClickHouse Keeper 是否已启用(因为它用于跟踪事务)。 ```sql BEGIN TRANSACTION @@ -146,7 +147,7 @@ Ok. ``` :::tip -如果您看到以下错误,请检查您的配置文件以确保 `allow_experimental_transactions` 设置为 `1`(或其他非 `0` 或 `false` 的值)。 +如果您看到以下错误,请检查配置文件以确保 `allow_experimental_transactions` 设置为 `1`(或任何非 `0` 或 `false` 的值)。 ```response Code: 48. DB::Exception: Received from localhost:9000. @@ -154,13 +155,13 @@ DB::Exception: Transactions are not supported. (NOT_IMPLEMENTED) ``` -您还可以通过发出以下内容来检查 ClickHouse Keeper +您还可以通过发出以下命令检查 ClickHouse Keeper ```bash echo ruok | nc localhost 9181 ``` -ClickHouse Keeper 应该回复 `imok`。 +ClickHouse Keeper 应该以 `imok` 响应。 ::: ```sql @@ -171,10 +172,10 @@ ROLLBACK Ok. ``` -#### 创建测试表 {#create-a-table-for-testing} +#### 创建一个用于测试的表 {#create-a-table-for-testing} :::tip -表的创建不是事务性的。请在事务之外运行此 DDL 查询。 +表的创建不是事务性的。 请在事务外运行此 DDL 查询。 ::: ```sql @@ -190,7 +191,7 @@ ORDER BY n Ok. ``` -#### 开始一个事务并插入一行 {#begin-a-transaction-and-insert-a-row} +#### 开始事务并插入一行 {#begin-a-transaction-and-insert-a-row} ```sql BEGIN TRANSACTION @@ -220,12 +221,12 @@ FROM mergetree_table ``` :::note -您可以在事务内部查询表,并看到即使尚未提交,也插入了该行。 +您可以在事务内查询表,并看到行已插入,尽管它尚未被提交。 ::: #### 回滚事务,并再次查询表 {#rollback-the-transaction-and-query-the-table-again} -验证事务是否已回滚: +验证事务已回滚: ```sql ROLLBACK @@ -283,7 +284,7 @@ FROM mergetree_table ### 事务检查 {#transactions-introspection} -您可以通过查询 `system.transactions` 表来检查事务,但请注意,您无法在处于事务中的会话中查询该表。打开第二个 `clickhouse client` 会话以查询该表。 +您可以通过查询 `system.transactions` 表来检查事务,但请注意,您无法从正在事务中的会话查询该表。打开第二个 `clickhouse client` 会话来查询该表。 ```sql SELECT * @@ -301,6 +302,6 @@ is_readonly: 1 state: RUNNING ``` -## 更多细节 {#more-details} +## 更多详细信息 {#more-details} -请参阅此 [元问题](https://github.com/ClickHouse/ClickHouse/issues/48794),以获取更广泛的测试,并保持与进展的同步。 +请查看此 [元问题](https://github.com/ClickHouse/ClickHouse/issues/48794),以找到更广泛的测试并跟进进展。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/transactions.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/transactions.md.hash index 65c30375beb..7534ba387d7 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/transactions.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/transactions.md.hash @@ -1 +1 @@ -1990b36fabbeae6f +b24ed9ef186e6fb4 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/dense_rank.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/dense_rank.md index 79d20bb82ca..e9f5174e353 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/dense_rank.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/dense_rank.md @@ -4,18 +4,19 @@ 'sidebar_position': 7 'slug': '/sql-reference/window-functions/dense_rank' 'title': 'dense_rank' +'doc_type': 'reference' --- # dense_rank -在其分区内对当前行进行排名,不留空缺。换句话说,如果遇到的任何新行的值与之前行的一个值相等,则它将获得下一个连续的排名,而不会在排名中留空缺。 +在其分区内对当前行进行无间隙的排名。换句话说,如果遇到的新行的值等于之前某一行的值,则它将获得下一个连续的排名,而不会在排名中产生间隙。 -[rank](./rank.md) 函数提供了相同的行为,但在排名中会留有空缺。 +[rack](./rank.md) 函数提供相同的行为,但会在排名中产生间隙。 **语法** -别名: `denseRank`(区分大小写) +别名:`denseRank`(区分大小写) ```sql dense_rank () @@ -29,11 +30,11 @@ WINDOW window_name as ([[PARTITION BY grouping_column] [ORDER BY sorting_column] **返回值** -- 当前行在其分区内的数字,排名不留空缺。[UInt64](../data-types/int-uint.md)。 +- 当前行在其分区内的一个数字,排名无间隙。[UInt64](../data-types/int-uint.md)。 **示例** -以下示例基于视频教程 [在 ClickHouse 中的排名窗口函数](https://youtu.be/Yku9mmBYm_4?si=XIMu1jpYucCQEoXA) 中提供的示例。 +以下示例基于视频教学中的示例:[在 ClickHouse 中的排名窗口函数](https://youtu.be/Yku9mmBYm_4?si=XIMu1jpYucCQEoXA)。 查询: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/dense_rank.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/dense_rank.md.hash index b7122112ca6..a67c6595e74 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/dense_rank.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/dense_rank.md.hash @@ -1 +1 @@ -3221fa29e3bca4f4 +9b464de7aba78ba9 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/first_value.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/first_value.md index 36659ca9c8b..60cd7e08a06 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/first_value.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/first_value.md @@ -4,12 +4,13 @@ 'sidebar_position': 3 'slug': '/sql-reference/window-functions/first_value' 'title': 'first_value' +'doc_type': 'reference' --- # first_value -返回在其有序范围内评估的第一个值。默认情况下,NULL 参数会被跳过,但可以使用 `RESPECT NULLS` 修饰符来覆盖此行为。 +返回在其有序框架内评估的第一个值。默认情况下,NULL 参数会被跳过,但可以使用 `RESPECT NULLS` 修饰符来覆盖此行为。 **语法** @@ -34,13 +35,13 @@ WINDOW window_name as ([PARTITION BY grouping_column] [ORDER BY sorting_column]) **返回值** -- 在其有序范围内评估的第一个值。 +- 在其有序框架内评估的第一个值。 **示例** -在这个示例中,`first_value` 函数用于从虚构的英超足球运动员薪资数据集中找到工资最高的足球运动员。 +在此示例中,`first_value` 函数用于从虚构的英超联赛足球运动员薪资数据集中查找薪水最高的足球运动员。 -查询: +查询: ```sql DROP TABLE IF EXISTS salaries; @@ -69,7 +70,7 @@ SELECT player, salary, FROM salaries; ``` -结果: +结果: ```response ┌─player──────────┬─salary─┬─highest_paid_player─┐ diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/first_value.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/first_value.md.hash index 61387f21aff..993d605da60 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/first_value.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/first_value.md.hash @@ -1 +1 @@ -e9ace57e4d25413e +767bb198b31fb95d diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/index.md index a7beec70995..a6ae788c3b0 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/index.md @@ -4,43 +4,44 @@ 'sidebar_position': 1 'slug': '/sql-reference/window-functions/' 'title': '窗口函数' +'doc_type': 'reference' --- -# 窗口函数 +# 窗口函数 -窗口函数让您可以在与当前行相关的一组行上执行计算。您可以执行的一些计算类似于可以通过聚合函数完成的计算,但窗口函数不会导致行被聚合为单个输出 - 单独的行仍然会被返回。 +窗口函数允许您对与当前行相关的一组行执行计算。您可以进行的一些计算类似于通过聚合函数完成的操作,但窗口函数不会将行分组为单个输出 - 仍然返回各行。 ## 标准窗口函数 {#standard-window-functions} -ClickHouse 支持定义窗口和窗口函数的标准语法。下表指示当前是否支持某个功能。 +ClickHouse支持用于定义窗口和窗口函数的标准语法。下表指示某个特性是否当前支持。 -| 特性 | 是否支持? | -|---------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| 临时窗口规范 (`count(*) over (partition by id order by time desc)`) | ✅ | -| 涉及窗口函数的表达式,例如 `(count(*) over ()) / 2)` | ✅ | -| `WINDOW` 子句 (`select ... from table window w as (partition by id)`) | ✅ | -| `ROWS` 框架 | ✅ | -| `RANGE` 框架 | ✅ (默认) | -| 对 `DateTime` 的 `RANGE OFFSET` 框架使用 `INTERVAL` 语法 | ❌ (请改用秒数来指定 ( `RANGE` 可与任何数字类型一起使用)。) | -| `GROUPS` 框架 | ❌ | -| 计算框架内的聚合函数 (`sum(value) over (order by time)`) | ✅ (支持所有聚合函数) | -| `rank()`, `dense_rank()`, `row_number()` | ✅
别名:`denseRank()` | -| `percent_rank()` | ✅ 高效计算给定值在数据集的分区中的相对位置。此函数有效地替代了更冗长和计算密集型的手动 SQL 计算表达式 `ifNull((rank() OVER(PARTITION BY x ORDER BY y) - 1) / nullif(count(1) OVER(PARTITION BY x) - 1, 0), 0)`
别名:`percentRank()` | -| `lag/lead(value, offset)` | ❌
您可以使用以下一种解决方法:
1) `any(value) over (.... rows between preceding and preceding)`,或对 `lead` 使用 `following`
2) `lagInFrame/leadInFrame`,它们是类似的,但遵守窗口框架。要获得与 `lag/lead` 相同的行为,请使用 `rows between unbounded preceding and unbounded following` | -| ntile(buckets) | ✅
例如,指定窗口 (partition by x order by y rows between unbounded preceding and unbounded following)。 | +| 特性 | 是否支持? | +|--------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| 临时窗口规范 (`count(*) over (partition by id order by time desc)`) | ✅ | +| 涉及窗口函数的表达式,例如 `(count(*) over ()) / 2)` | ✅ | +| `WINDOW` 子句 (`select ... from table window w as (partition by id)`) | ✅ | +| `ROWS` 框架 | ✅ | +| `RANGE` 框架 | ✅ (默认) | +| `INTERVAL` 语法用于 `DateTime` `RANGE OFFSET` 框架 | ❌ (请改为指定秒数 (`RANGE` 适用于任何数值类型)。) | +| `GROUPS` 框架 | ❌ | +| 在框架中计算聚合函数 (`sum(value) over (order by time)`) | ✅ (支持所有聚合函数) | +| `rank()`, `dense_rank()`, `row_number()` | ✅
别名: `denseRank()` | +| `percent_rank()` | ✅ 高效计算数据集中某个值在分区内的相对排名。该函数有效替代更冗长且计算复杂的手动 SQL 计算,表示为 `ifNull((rank() OVER(PARTITION BY x ORDER BY y) - 1) / nullif(count(1) OVER(PARTITION BY x) - 1, 0), 0)`
别名: `percentRank()`| +| `lag/lead(value, offset)` | ✅
您还可以使用以下之一的变通方法:
1) `any(value) over (.... rows between preceding and preceding)` 或 `following` 用于 `lead`
2) `lagInFrame/leadInFrame`,类似,但遵循窗口框架。要获得与 `lag/lead` 相同的行为,使用 `rows between unbounded preceding and unbounded following` | +| ntile(buckets) | ✅
请指定窗口,例如 (partition by x order by y rows between unbounded preceding and unbounded following)。 | -## ClickHouse 特定窗口函数 {#clickhouse-specific-window-functions} +## ClickHouse特定窗口函数 {#clickhouse-specific-window-functions} -还有以下 ClickHouse 特定的窗口函数: +还有以下ClickHouse特定窗口函数: ### nonNegativeDerivative(metric_column, timestamp_column[, INTERVAL X UNITS]) {#nonnegativederivativemetric_column-timestamp_column-interval-x-units} -通过 `timestamp_column` 查找给定 `metric_column` 的非负导数。 -`INTERVAL` 可以省略,默认值为 `INTERVAL 1 SECOND`。 -对于每一行,计算值如下: -- 第一行为 `0`, -- 对于第 $i_{th}$ 行,值为 ${\text{metric}_i - \text{metric}_{i-1} \over \text{timestamp}_i - \text{timestamp}_{i-1}} * \text{interval}$。 +通过 `timestamp_column` 找到给定 `metric_column` 的非负导数。 +`INTERVAL` 可以省略,默认为 `INTERVAL 1 SECOND`。 +每行计算的值如下: +- 第1行为 `0`, +- ${\text{metric}_i - \text{metric}_{i-1} \over \text{timestamp}_i - \text{timestamp}_{i-1}} * \text{interval}$ 对于第 $i_{th}$ 行。 ## 语法 {#syntax} @@ -52,9 +53,9 @@ FROM table_name WINDOW window_name as ([[PARTITION BY grouping_column] [ORDER BY sorting_column]]) ``` -- `PARTITION BY` - 定义如何将结果集分成组。 -- `ORDER BY` - 定义在计算 aggregate_function 时如何对组内的行进行排序。 -- `ROWS or RANGE` - 定义框架的边界,aggregate_function 在框架内计算。 +- `PARTITION BY` - 定义如何将结果集分组。 +- `ORDER BY` - 定义在计算聚合函数期间如何对组内的行进行排序。 +- `ROWS or RANGE` - 定义框架的边界,聚合函数在框架内计算。 - `WINDOW` - 允许多个表达式使用相同的窗口定义。 ```text @@ -78,20 +79,20 @@ WINDOW window_name as ([[PARTITION BY grouping_column] [ORDER BY sorting_column] 这些函数只能用作窗口函数。 -- [`row_number()`](./row_number.md) - 在其分区内按从 1 开始给当前行编号。 -- [`first_value(x)`](./first_value.md) - 返回其有序框架内评估的第一个值。 -- [`last_value(x)`](./last_value.md) - 返回其有序框架内评估的最后一个值。 -- [`nth_value(x, offset)`](./nth_value.md) - 返回在其有序框架中与第 n 行(偏移)相对应的第一个非 NULL 值。 -- [`rank()`](./rank.md) - 在其分区内按间隔为当前行排名。 -- [`dense_rank()`](./dense_rank.md) - 在其分区内按当前行排名,不留间隔。 -- [`lagInFrame(x)`](./lagInFrame.md) - 返回在有序框架内比当前行向前偏移指定行数的行评估的值。 -- [`leadInFrame(x)`](./leadInFrame.md) - 返回在有序框架内比当前行向后偏移行的行评估的值。 +- [`row_number()`](./row_number.md) - 在其分区内为当前行编号,从1开始。 +- [`first_value(x)`](./first_value.md) - 返回在其有序框架内计算的第一个值。 +- [`last_value(x)`](./last_value.md) - 返回在其有序框架内计算的最后一个值。 +- [`nth_value(x, offset)`](./nth_value.md) - 返回在其有序框架内与第n行(偏移)相比较的第一个非NULL值。 +- [`rank()`](./rank.md) - 在其分区内对当前行进行排名,包括间隙。 +- [`dense_rank()`](./dense_rank.md) - 在其分区内对当前行进行排名,不包括间隙。 +- [`lagInFrame(x)`](./lagInFrame.md) - 返回在其有序框架内,当前行之前的指定物理偏移行计算的值。 +- [`leadInFrame(x)`](./leadInFrame.md) - 返回在其有序框架内,当前行之后的偏移行计算的值。 ## 示例 {#examples} -让我们看看如何使用窗口函数的一些示例。 +让我们来看一些如何使用窗口函数的示例。 -### 行编号 {#numbering-rows} +### 行号 {#numbering-rows} ```sql CREATE TABLE salaries @@ -151,7 +152,7 @@ FROM salaries; ### 聚合函数 {#aggregation-functions} -将每个球员的薪水与其团队的平均薪水进行比较。 +将每位球员的薪水与其团队的平均薪水进行比较。 ```sql SELECT @@ -173,7 +174,7 @@ FROM salaries; └─────────────────┴────────┴───────────────────────────┴─────────┴────────┘ ``` -将每个球员的薪水与其团队的最大薪水进行比较。 +将每位球员的薪水与其团队的最高薪水进行比较。 ```sql SELECT @@ -515,7 +516,7 @@ ORDER BY 以下示例解决常见的现实世界问题。 -### 每个部门的最高/总薪水 {#maximumtotal-salary-per-department} +### 每个部门的最大/总薪水 {#maximumtotal-salary-per-department} ```sql CREATE TABLE employees @@ -554,7 +555,7 @@ FROM FROM employees WINDOW wndw AS ( PARTITION BY department - rows BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) ORDER BY department ASC, @@ -612,7 +613,7 @@ ORDER BY └───────┴─────────────────────┴───────┴───────────────┘ ``` -### 移动/滑动平均(每 3 行) {#moving--sliding-average-per-3-rows} +### 移动/滑动平均(每3行) {#moving--sliding-average-per-3-rows} ```sql CREATE TABLE sensors @@ -660,7 +661,7 @@ ORDER BY └──────────┴─────────────────────┴───────┴───────────────────┘ ``` -### 移动/滑动平均(每 10 秒) {#moving--sliding-average-per-10-seconds} +### 移动/滑动平均(每10秒) {#moving--sliding-average-per-10-seconds} ```sql SELECT @@ -668,7 +669,7 @@ SELECT ts, value, avg(value) OVER (PARTITION BY metric ORDER BY ts - Range BETWEEN 10 PRECEDING AND CURRENT ROW) AS moving_avg_10_seconds_temp + RANGE BETWEEN 10 PRECEDING AND CURRENT ROW) AS moving_avg_10_seconds_temp FROM sensors ORDER BY metric ASC, @@ -686,9 +687,9 @@ ORDER BY └──────────┴─────────────────────┴───────┴────────────────────────────┘ ``` -### 移动/滑动平均(每 10 天) {#moving--sliding-average-per-10-days} +### 移动/滑动平均(每10天) {#moving--sliding-average-per-10-days} -温度以秒为精度存储,但使用 `Range` 和 `ORDER BY toDate(ts)` 我们形成一个大小为 10 个单位的框架,由于 `toDate(ts)`,单位为天。 +温度存储有秒精度,但使用 `Range` 和 `ORDER BY toDate(ts)` 我们形成一个大小为10单位的框架,并且因为 `toDate(ts)` 单位是天。 ```sql CREATE TABLE sensors @@ -719,7 +720,7 @@ SELECT ts, value, round(avg(value) OVER (PARTITION BY metric ORDER BY toDate(ts) - Range BETWEEN 10 PRECEDING AND CURRENT ROW),2) AS moving_avg_10_days_temp + RANGE BETWEEN 10 PRECEDING AND CURRENT ROW),2) AS moving_avg_10_days_temp FROM sensors ORDER BY metric ASC, @@ -741,17 +742,17 @@ ORDER BY └──────────────┴─────────────────────┴───────┴─────────────────────────┘ ``` -## 参考资料 {#references} +## 参考文献 {#references} ### GitHub 问题 {#github-issues} -窗口函数的初始支持路线图在 [此问题中](https://github.com/ClickHouse/ClickHouse/issues/18097)。 +窗口函数初步支持的路线图在 [此问题](https://github.com/ClickHouse/ClickHouse/issues/18097) 中。 所有与窗口函数相关的 GitHub 问题都有 [comp-window-functions](https://github.com/ClickHouse/ClickHouse/labels/comp-window-functions) 标签。 ### 测试 {#tests} -这些测试包含当前支持语法的示例: +这些测试包含目前支持语法的示例: https://github.com/ClickHouse/ClickHouse/blob/master/tests/performance/window_functions.xml @@ -775,9 +776,8 @@ https://dev.mysql.com/doc/refman/8.0/en/window-functions-usage.html https://dev.mysql.com/doc/refman/8.0/en/window-functions-frames.html - ## 相关内容 {#related-content} -- 博客:[在 ClickHouse 中处理时间序列数据](https://clickhouse.com/blog/working-with-time-series-data-and-functions-ClickHouse) -- 博客:[Git 提交序列的窗口和数组函数](https://clickhouse.com/blog/clickhouse-window-array-functions-git-commits) -- 博客:[将数据导入 ClickHouse - 第 3 部分 - 使用 S3](https://clickhouse.com/blog/getting-data-into-clickhouse-part-3-s3) +- 博客: [在ClickHouse中处理时间序列数据](https://clickhouse.com/blog/working-with-time-series-data-and-functions-ClickHouse) +- 博客: [用于Git提交序列的窗口和数组函数](https://clickhouse.com/blog/clickhouse-window-array-functions-git-commits) +- 博客: [将数据导入ClickHouse - 第三部分 - 使用S3](https://clickhouse.com/blog/getting-data-into-clickhouse-part-3-s3) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/index.md.hash index 5ad19a5a694..29baedbaa97 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/index.md.hash @@ -1 +1 @@ -586a552ae1ee045a +5904d497f8a17b9d diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/lag.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/lag.md new file mode 100644 index 00000000000..38e134bbfe9 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/lag.md @@ -0,0 +1,80 @@ +--- +'description': '关于 lag 窗口函数的文档' +'sidebar_label': 'lag' +'sidebar_position': 9 +'slug': '/sql-reference/window-functions/lag' +'title': '延迟' +'doc_type': 'reference' +--- + + +# lag + +返回在有序框架内,当前行之前的指定物理偏移所评估的值。 +此函数类似于 [`lagInFrame`](./lagInFrame.md),但始终使用 `ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING` 框架。 + +**语法** + +```sql +lag(x[, offset[, default]]) + OVER ([[PARTITION BY grouping_column] [ORDER BY sorting_column]] | [window_name]) +FROM table_name +WINDOW window_name as ([[PARTITION BY grouping_column] [ORDER BY sorting_column]) +``` + +有关窗口函数语法的更多详细信息,请参见:[窗口函数 - 语法](./index.md/#syntax)。 + +**参数** + +- `x` — 列名。 +- `offset` — 要应用的偏移量。[(U)Int*](../data-types/int-uint.md)。 (可选 - 默认值为 `1`)。 +- `default` — 如果计算的行超过窗口框架的边界,则返回的值。 (可选 - 省略时默认为列类型的默认值)。 + +**返回值** + +- 在有序框架内,当前行之前的指定物理偏移所评估的值。 + +**示例** + +此示例查看特定股票的历史数据,并使用 `lag` 函数计算每天的增量和股价收盘价的百分比变化。 + +```sql title="Query" +CREATE TABLE stock_prices +( + `date` Date, + `open` Float32, -- opening price + `high` Float32, -- daily high + `low` Float32, -- daily low + `close` Float32, -- closing price + `volume` UInt32 -- trade volume +) +Engine = Memory; + +INSERT INTO stock_prices FORMAT Values + ('2024-06-03', 113.62, 115.00, 112.00, 115.00, 438392000), + ('2024-06-04', 115.72, 116.60, 114.04, 116.44, 403324000), + ('2024-06-05', 118.37, 122.45, 117.47, 122.44, 528402000), + ('2024-06-06', 124.05, 125.59, 118.32, 121.00, 664696000), + ('2024-06-07', 119.77, 121.69, 118.02, 120.89, 412386000); +``` + +```sql title="Query" +SELECT + date, + close, + lag(close, 1, close) OVER (ORDER BY date ASC) AS previous_day_close, + COALESCE(ROUND(close - previous_day_close, 2)) AS delta, + COALESCE(ROUND((delta / previous_day_close) * 100, 2)) AS percent_change +FROM stock_prices +ORDER BY date DESC +``` + +```response title="Response" + ┌───────date─┬──close─┬─previous_day_close─┬─delta─┬─percent_change─┐ +1. │ 2024-06-07 │ 120.89 │ 121 │ -0.11 │ -0.09 │ +2. │ 2024-06-06 │ 121 │ 122.44 │ -1.44 │ -1.18 │ +3. │ 2024-06-05 │ 122.44 │ 116.44 │ 6 │ 5.15 │ +4. │ 2024-06-04 │ 116.44 │ 115 │ 1.44 │ 1.25 │ +5. │ 2024-06-03 │ 115 │ 115 │ 0 │ 0 │ + └────────────┴────────┴────────────────────┴───────┴────────────────┘ +``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/lag.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/lag.md.hash new file mode 100644 index 00000000000..c57ebb870c9 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/lag.md.hash @@ -0,0 +1 @@ +96796673a8ef6ccc diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/lagInFrame.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/lagInFrame.md index ebbd7efbca4..c5732222d34 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/lagInFrame.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/lagInFrame.md @@ -1,19 +1,20 @@ --- -'description': '关于lagInFrame窗口函数的文档' +'description': 'lagInFrame 窗口函数的文档' 'sidebar_label': 'lagInFrame' 'sidebar_position': 9 'slug': '/sql-reference/window-functions/lagInFrame' 'title': 'lagInFrame' +'doc_type': 'reference' --- # lagInFrame -返回在有序框架内当前行之前位于指定物理偏移行的值。 +返回一个值,该值是在有序框架中比当前行早指定物理偏移行的行中计算得出的。 :::warning -`lagInFrame` 的行为与标准 SQL 的 `lag` 窗口函数不同。 -Clickhouse 窗口函数 `lagInFrame` 尊重窗口框架。 +`lagInFrame` 的行为与标准 SQL 的 `lag` 窗口函数有所不同。 +Clickhouse 的窗口函数 `lagInFrame` 尊重窗口框架。 要获得与 `lag` 相同的行为,请使用 `ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING`。 ::: @@ -27,20 +28,20 @@ FROM table_name WINDOW window_name as ([[PARTITION BY grouping_column] [ORDER BY sorting_column]) ``` -有关窗口函数语法的更多细节,请参见:[窗口函数 - 语法](./index.md/#syntax)。 +有关窗口函数语法的更多详细信息,请参见:[窗口函数 - 语法](./index.md/#syntax)。 **参数** -- `x` — 列名。 -- `offset` — 要应用的偏移量。 [(U)Int*](../data-types/int-uint.md)。 (可选 - 默认值为 `1`)。 -- `default` — 如果计算出的行超过窗口框架的边界,则返回的值。 (可选 - 当省略时为列类型的默认值)。 +- `x` — 列名称。 +- `offset` — 要应用的偏移量。[(U)Int*](../data-types/int-uint.md)。(可选 - 默认值为 `1`)。 +- `default` — 如果计算的行超出了窗口框架的边界,则返回的值。(可选 - 省略时为列类型的默认值)。 **返回值** -- 在有序框架内当前行之前位于指定物理偏移行的值。 +- 在有序框架中位于当前行之前特定物理偏移的行中计算得出的值。 **示例** -此示例查看特定股票的历史数据,并使用 `lagInFrame` 函数计算股票收盘价的逐日变化和百分比变化。 +此示例查看特定股票的历史数据,并使用 `lagInFrame` 函数计算股票收盘价的逐日差异和百分比变化。 查询: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/lagInFrame.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/lagInFrame.md.hash index 5656970c1d2..021c4088c10 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/lagInFrame.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/lagInFrame.md.hash @@ -1 +1 @@ -b7c6d584cbd314ce +5190fd4dbbd6f983 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/last_value.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/last_value.md index 06d36e1d376..12b820e3063 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/last_value.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/last_value.md @@ -4,12 +4,13 @@ 'sidebar_position': 4 'slug': '/sql-reference/window-functions/last_value' 'title': 'last_value' +'doc_type': 'reference' --- # last_value -返回在其有序框架内计算的最后一个值。默认情况下,NULL 参数会被跳过,但可以使用 `RESPECT NULLS` 修饰符来覆盖此行为。 +返回在其排序框架内计算的最后一个值。默认情况下,NULL 参数会被跳过,但可以使用 `RESPECT NULLS` 修饰符来覆盖此行为。 **语法** @@ -21,24 +22,24 @@ FROM table_name WINDOW window_name as ([[PARTITION BY grouping_column] [ORDER BY sorting_column]) ``` -别名: `anyLast`. +别名: `anyLast`。 :::note -在 `first_value(column_name)` 后使用可选修饰符 `RESPECT NULLS` 将确保 NULL 参数不会被跳过。 -有关更多信息,请参见 [NULL 处理](../aggregate-functions/index.md/#null-processing) 。 +在 `first_value(column_name)` 后使用可选修饰符 `RESPECT NULLS` 将确保 `NULL` 参数不被跳过。 +有关更多信息,请参见 [NULL处理](../aggregate-functions/index.md/#null-processing)。 -别名: `lastValueRespectNulls` +别名: `lastValueRespectNulls` ::: -有关窗口函数语法的更多细节,请参见: [窗口函数 - 语法](./index.md/#syntax)。 +有关窗口函数语法的更多详细信息,请参见:[窗口函数 - 语法](./index.md/#syntax)。 **返回值** -- 在其有序框架内计算的最后一个值。 +- 在其排序框架内计算的最后一个值。 **示例** -在这个示例中,`last_value` 函数用于从虚构的英超足球运动员薪资数据集中找出薪资最低的足球运动员。 +在此示例中,使用 `last_value` 函数从英超联赛足球运动员的虚构薪资数据集中找到薪水最低的足球运动员。 查询: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/last_value.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/last_value.md.hash index a5a02409869..e71143aaed4 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/last_value.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/last_value.md.hash @@ -1 +1 @@ -fdda38e08d57324b +92807b767663549a diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/lead.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/lead.md new file mode 100644 index 00000000000..90d7f7710b2 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/lead.md @@ -0,0 +1,73 @@ +--- +'description': 'lead窗口函数的文档' +'sidebar_label': 'lead' +'sidebar_position': 10 +'slug': '/sql-reference/window-functions/lead' +'title': 'lead' +'doc_type': 'reference' +--- + + +# lead + +返回一个值,该值在有序框架内的当前行之后偏移行的行中进行评估。 +此函数类似于 [`leadInFrame`](./leadInFrame.md),但总是使用 `ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING` 框架。 + +**语法** + +```sql +lead(x[, offset[, default]]) + OVER ([[PARTITION BY grouping_column] [ORDER BY sorting_column]] | [window_name]) +FROM table_name +WINDOW window_name as ([[PARTITION BY grouping_column] [ORDER BY sorting_column]) +``` + +有关窗口函数语法的更多详细信息,请参见:[窗口函数 - 语法](./index.md/#syntax)。 + +**参数** + +- `x` — 列名称。 +- `offset` — 要应用的偏移量。 [(U)Int*](../data-types/int-uint.md)。 (可选 - 默认值为 `1`)。 +- `default` — 如果计算的行超出窗口框架的边界要返回的值。 (可选 - 省略时使用列类型的默认值)。 + +**返回值** + +- 在有序框架内的当前行之后偏移行的行中评估的值。 + +**示例** + +此示例查看诺贝尔奖获奖者的 [历史数据](https://www.kaggle.com/datasets/sazidthe1/nobel-prize-data),并使用 `lead` 函数返回物理类别的连续获奖者列表。 + +```sql title="Query" +CREATE OR REPLACE VIEW nobel_prize_laureates +AS SELECT * +FROM file('nobel_laureates_data.csv'); +``` + +```sql title="Query" +SELECT + fullName, + lead(year, 1, year) OVER (PARTITION BY category ORDER BY year ASC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS year, + category, + motivation +FROM nobel_prize_laureates +WHERE category = 'physics' +ORDER BY year DESC +LIMIT 9 +``` + +```response title="Query" + ┌─fullName─────────┬─year─┬─category─┬─motivation─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ +1. │ Anne L Huillier │ 2023 │ physics │ for experimental methods that generate attosecond pulses of light for the study of electron dynamics in matter │ +2. │ Pierre Agostini │ 2023 │ physics │ for experimental methods that generate attosecond pulses of light for the study of electron dynamics in matter │ +3. │ Ferenc Krausz │ 2023 │ physics │ for experimental methods that generate attosecond pulses of light for the study of electron dynamics in matter │ +4. │ Alain Aspect │ 2022 │ physics │ for experiments with entangled photons establishing the violation of Bell inequalities and pioneering quantum information science │ +5. │ Anton Zeilinger │ 2022 │ physics │ for experiments with entangled photons establishing the violation of Bell inequalities and pioneering quantum information science │ +6. │ John Clauser │ 2022 │ physics │ for experiments with entangled photons establishing the violation of Bell inequalities and pioneering quantum information science │ +7. │ Giorgio Parisi │ 2021 │ physics │ for the discovery of the interplay of disorder and fluctuations in physical systems from atomic to planetary scales │ +8. │ Klaus Hasselmann │ 2021 │ physics │ for the physical modelling of Earths climate quantifying variability and reliably predicting global warming │ +9. │ Syukuro Manabe │ 2021 │ physics │ for the physical modelling of Earths climate quantifying variability and reliably predicting global warming │ + └──────────────────┴──────┴──────────┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ +``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/lead.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/lead.md.hash new file mode 100644 index 00000000000..5f9739428d0 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/lead.md.hash @@ -0,0 +1 @@ +daf0f1c7aed9ce89 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/leadInFrame.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/leadInFrame.md index 939b07aeeb1..4bf2cef569a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/leadInFrame.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/leadInFrame.md @@ -1,19 +1,20 @@ --- -'description': 'leadInFrame 窗口函数的文档' +'description': 'leadInFrame窗口函数的文档' 'sidebar_label': 'leadInFrame' 'sidebar_position': 10 'slug': '/sql-reference/window-functions/leadInFrame' 'title': 'leadInFrame' +'doc_type': 'reference' --- # leadInFrame -返回在有序框架内当前行之后的偏移行所评估的值。 +返回在有序框架中,当前行之后偏移多行时计算得到的值。 :::warning -`leadInFrame` 的行为与标准 SQL 的 `lead` 窗口函数不同。 -Clickhouse 窗口函数 `leadInFrame` 遵循窗口框架。 +`leadInFrame` 的行为与标准 SQL `lead` 窗口函数不同。 +Clickhouse 窗口函数 `leadInFrame` 尊重窗口框架。 要获得与 `lead` 相同的行为,请使用 `ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING`。 ::: @@ -27,20 +28,20 @@ FROM table_name WINDOW window_name as ([[PARTITION BY grouping_column] [ORDER BY sorting_column]) ``` -有关窗口函数语法的更多详细信息,请参见:[窗口函数 - 语法](./index.md/#syntax)。 +有关窗口函数语法的更多细节,请参见:[窗口函数 - 语法](./index.md/#syntax)。 **参数** - `x` — 列名。 -- `offset` — 应用的偏移量。[(U)Int*](../data-types/int-uint.md)。 (可选 - 默认为 `1`)。 -- `default` — 如果计算的行超过窗口框架的边界,则返回的值。 (可选 - 省略时为列类型的默认值)。 +- `offset` — 要应用的偏移量。[(U)Int*](../data-types/int-uint.md)。(可选 - 默认为 `1`)。 +- `default` — 如果计算的行超出窗口框架的边界,则返回的值。(可选 - 省略时为列类型的默认值)。 **返回值** -- 在有序框架内当前行之后偏移行所评估的值。 +- 在有序框架中,当前行之后偏移多行时计算得到的值。 **示例** -该示例查看诺贝尔奖获奖者的 [历史数据](https://www.kaggle.com/datasets/sazidthe1/nobel-prize-data),并使用 `leadInFrame` 函数返回物理学类别中的连续获奖者列表。 +此示例查看诺贝尔奖获奖者的[历史数据](https://www.kaggle.com/datasets/sazidthe1/nobel-prize-data),并使用 `leadInFrame` 函数返回物理类别中连续获奖者的列表。 查询: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/leadInFrame.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/leadInFrame.md.hash index 8fb46c3dc92..3cd766493e0 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/leadInFrame.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/leadInFrame.md.hash @@ -1 +1 @@ -11694f295fa89c60 +a438d35c89309e84 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/nth_value.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/nth_value.md index 227d721cfa5..e6e4656a459 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/nth_value.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/nth_value.md @@ -1,15 +1,16 @@ --- -'description': 'nth_value 窗口函数的文档' +'description': 'nth_value窗口函数的文档' 'sidebar_label': 'nth_value' 'sidebar_position': 5 'slug': '/sql-reference/window-functions/nth_value' 'title': 'nth_value' +'doc_type': 'reference' --- # nth_value -返回在其有序框架中与第 n 行(偏移量)评估的第一个非 NULL 值。 +返回在其有序框架中相对于第 n 行(偏移量)评估的第一个非 NULL 值。 **语法** @@ -21,7 +22,7 @@ FROM table_name WINDOW window_name as ([[PARTITION BY grouping_column] [ORDER BY sorting_column]) ``` -有关窗口函数语法的更多详细信息,请参见:[窗口函数 - 语法](./index.md/#syntax)。 +有关窗口函数语法的更多细节,请参见:[窗口函数 - 语法](./index.md/#syntax)。 **参数** @@ -30,11 +31,11 @@ WINDOW window_name as ([[PARTITION BY grouping_column] [ORDER BY sorting_column] **返回值** -- 在其有序框架中与第 n 行(偏移量)评估的第一个非 NULL 值。 +- 在其有序框架中相对于第 n 行(偏移量)评估的第一个非 NULL 值。 **示例** -在此示例中,`nth-value` 函数用于从虚构的英超足球运动员薪资数据集中查找第三高的薪水。 +在此示例中,`nth-value` 函数用于从虚构的英超联赛足球运动员工资数据集中查找第三高的工资。 查询: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/nth_value.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/nth_value.md.hash index dd406fa9294..f85e438ae33 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/nth_value.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/nth_value.md.hash @@ -1 +1 @@ -cd12f519a7cfeff5 +4d82c4ed8f03871b diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/percent_rank.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/percent_rank.md index b5fa692b079..b2620d66097 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/percent_rank.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/percent_rank.md @@ -1,19 +1,20 @@ --- -'description': 'percent_rank窗口函数的文档' +'description': 'percent_rank 窗口函数的文档' 'sidebar_label': 'percent_rank' 'sidebar_position': 8 'slug': '/sql-reference/window-functions/percent_rank' 'title': 'percent_rank' +'doc_type': 'reference' --- # percent_rank -返回窗口分区内行的相对排名(即百分位)。 +返回窗口分区内行的相对排名(即百分位数)。 **语法** -别名:`percentRank`(区分大小写) +别名: `percentRank`(区分大小写) ```sql percent_rank () @@ -23,14 +24,13 @@ FROM table_name WINDOW window_name as ([PARTITION BY grouping_column] [ORDER BY sorting_column] RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) ``` -默认和必需的窗口框架定义是 `RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING`。 +默认和必要的窗口框架定义为 `RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING`。 -有关窗口函数语法的更多细节,请参见:[窗口函数 - 语法](./index.md/#syntax)。 +有关窗口函数语法的更多详细信息,请参见: [Window Functions - Syntax](./index.md/#syntax)。 **示例** - -查询: +查询: ```sql CREATE TABLE salaries @@ -58,7 +58,7 @@ SELECT player, salary, FROM salaries; ``` -结果: +结果: ```response diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/percent_rank.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/percent_rank.md.hash index de2869b48ec..32f9253181e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/percent_rank.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/percent_rank.md.hash @@ -1 +1 @@ -46256557535cf163 +ece97c3f36eedc02 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/rank.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/rank.md index 9b4adfe4c69..c646ca35c56 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/rank.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/rank.md @@ -1,17 +1,18 @@ --- -'description': 'rank 内幕函数的文档' +'description': 'rank窗口函数的文档' 'sidebar_label': 'rank' 'sidebar_position': 6 'slug': '/sql-reference/window-functions/rank' 'title': 'rank' +'doc_type': 'reference' --- # rank -在其分区内对当前行进行排名,允许存在间隙。换句话说,如果它遇到的任何行的值与之前某一行的值相等,则将获得与该之前行相同的排名。然后,下一行的排名等于前一行的排名加上与之前排名被授予次数相等的间隙。 +在其分区内对当前行进行排名,允许存在间隙。换句话说,如果它遇到的任何行的值与之前某行的值相等,则该行将获得与之前那行相同的排名。下一行的排名等于前一行的排名加上一个间隙,该间隙等于前一排名被赋予的次数。 -[dense_rank](./dense_rank.md) 函数提供相同的行为,但没有排名的间隙。 +[dense_rank](./dense_rank.md) 函数提供相同的行为,但在排名中不允许存在间隙。 **语法** @@ -23,15 +24,15 @@ FROM table_name WINDOW window_name as ([[PARTITION BY grouping_column] [ORDER BY sorting_column]) ``` -有关窗口函数语法的更多详细信息,请参见:[窗口函数 - 语法](./index.md/#syntax)。 +有关窗口函数语法的更多细节,请参见:[窗口函数 - 语法](./index.md/#syntax)。 **返回值** -- 当前行在其分区内的一个数字,包括间隙。 [UInt64](../data-types/int-uint.md)。 +- 当前行在其分区内的编号,包括间隙。 [UInt64](../data-types/int-uint.md)。 **示例** -以下示例基于视频教程中提供的示例 [在 ClickHouse 中的排名窗口函数](https://youtu.be/Yku9mmBYm_4?si=XIMu1jpYucCQEoXA)。 +以下示例基于视频教学中提供的示例:[在 ClickHouse 中的排名窗口函数](https://youtu.be/Yku9mmBYm_4?si=XIMu1jpYucCQEoXA)。 查询: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/rank.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/rank.md.hash index 60db3fc73f8..30ee691e315 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/rank.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/rank.md.hash @@ -1 +1 @@ -8249a68f5ab15db5 +4da4b099d50975e4 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/row_number.md b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/row_number.md index 25a22edee7d..6e14cb1c483 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/row_number.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/row_number.md @@ -1,15 +1,16 @@ --- -'description': '关于 row_number 窗口函数的文档' +'description': 'row_number 视窗函数的文档' 'sidebar_label': 'row_number' 'sidebar_position': 2 'slug': '/sql-reference/window-functions/row_number' 'title': 'row_number' +'doc_type': 'reference' --- # row_number -对当前行在其分区内进行编号,从1开始。 +为当前行在其分区内编号,从1开始。 **语法** @@ -25,11 +26,11 @@ WINDOW window_name as ([[PARTITION BY grouping_column] [ORDER BY sorting_column] **返回值** -- 当前行在其分区内的编号。 [UInt64](../data-types/int-uint.md)。 +- 当前行在其分区内的编号。[UInt64](../data-types/int-uint.md)。 **示例** -以下示例基于视频教学中提供的示例,[ClickHouse中的排名窗口函数](https://youtu.be/Yku9mmBYm_4?si=XIMu1jpYucCQEoXA)。 +以下示例基于视频教程中提供的示例:[ClickHouse中的排名窗口函数](https://youtu.be/Yku9mmBYm_4?si=XIMu1jpYucCQEoXA)。 查询: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/row_number.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/row_number.md.hash index 84476958d8a..ad04b1974b1 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/row_number.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/sql-reference/window-functions/row_number.md.hash @@ -1 +1 @@ -6a3e642c286bb335 +e91c1f9205002f0e diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/starter-guides/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/starter-guides/index.md index 2c6069fc4ef..67bc59fe31e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/starter-guides/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/starter-guides/index.md @@ -1,16 +1,17 @@ --- 'slug': '/starter-guides' 'title': '入门指南' -'description': '入门指南的着陆页' +'description': '入门指南的登录页面' 'pagination_prev': null 'pagination_next': null +'doc_type': 'landing-page' --- -在本节文档中,您将找到常见 SQL 查询的入门指南:`CREATE`、`INSERT`、`SELECT` 和变更操作 `UPDATE` 和 `DELETE`。 +在本节文档中,您将找到常见 SQL 查询的入门指南:`CREATE`、`INSERT`、`SELECT`,以及变更操作 `UPDATE` 和 `DELETE`。 -| 页面 | 描述 | +| 页面 | 描述 | |------------------------------------------------------------|------------------------------------------------------------------------| | [创建表](../guides/creating-tables.md) | 如何创建表的入门指南。 | -| [插入数据](../guides/inserting-data.md) | 如何向表中插入数据的入门指南。 | +| [插入数据](../guides/inserting-data.md) | 如何将数据插入表的入门指南。 | | [选择数据](../guides/writing-queries.md) | 如何从表中选择数据的入门指南。 | -| [更新和删除数据](../guides/developer/mutations.md) | 关于变更操作的入门指南 - 在 ClickHouse 中更新和删除数据。 | +| [更新和删除数据](../guides/developer/mutations.md) | 变更操作的入门指南 - 在 ClickHouse 中更新和删除数据。 | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/starter-guides/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/starter-guides/index.md.hash index e633fd2b25a..de515090391 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/starter-guides/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/starter-guides/index.md.hash @@ -1 +1 @@ -0c94b409207dbd9f +23132078bbe06c29 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/tips-and-tricks/community-wisdom.md b/i18n/zh/docusaurus-plugin-content-docs/current/tips-and-tricks/community-wisdom.md new file mode 100644 index 00000000000..e49aaac7bbe --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/tips-and-tricks/community-wisdom.md @@ -0,0 +1,42 @@ +--- +'sidebar_position': 1 +'slug': '/tips-and-tricks/community-wisdom' +'sidebar_label': '社区智慧' +'doc_type': 'landing-page' +'keywords': +- 'database tips' +- 'community wisdom' +- 'production troubleshooting' +- 'performance optimization' +- 'database debugging' +- 'clickhouse guides' +- 'real world examples' +- 'database best practices' +- 'meetup insights' +- 'production lessons' +- 'interactive tutorials' +- 'database solutions' +'title': 'ClickHouse社区智慧' +'description': '通过实际案例和经验教训,从ClickHouse社区中学习' +--- + + +# ClickHouse 社区智慧:来自会议的技巧与窍门 {#community-wisdom} + +*这些互动指南代表了数百次生产部署的集体智慧。每个可运行的示例帮助您使用真实的 GitHub 事件数据理解 ClickHouse 模式 - 练习这些概念以避免常见错误,加速您的成功。* + +将这些收集到的知识与我们的 [最佳实践](/best-practices) 指南结合,获得最佳的 ClickHouse 体验。 + +## 特定问题的快速跳转 {#problem-specific-quick-jumps} + +| 问题 | 文档 | 描述 | +|-----------|----------------------------------|----------------------------------------| +| **生产问题** | [调试见解](./debugging-insights.md) | 社区生产调试技巧 | +| **慢查询** | [性能优化](./performance-optimization.md) | 优化性能 | +| **物化视图** | [MV 双刃剑](./materialized-views.md) | 避免 10 倍存储实例 | +| **过多分区片段** | [过多分区片段](./too-many-parts.md) | 解决“过多分区片段”错误和性能下降问题 | +| **高成本** | [成本优化](./cost-optimization.md) | 优化成本 | +| **成功案例** | [成功案例](./success-stories.md) | ClickHouse 在成功使用案例中的示例 | + +**最后更新:** 根据 2024-2025 年社区会议的见解 +**贡献:** 发现错误或有新的经验教训?欢迎社区贡献 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/tips-and-tricks/community-wisdom.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/tips-and-tricks/community-wisdom.md.hash new file mode 100644 index 00000000000..b6789fbb8b1 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/tips-and-tricks/community-wisdom.md.hash @@ -0,0 +1 @@ +b55f23781b561147 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/tips-and-tricks/cost-optimization.md b/i18n/zh/docusaurus-plugin-content-docs/current/tips-and-tricks/cost-optimization.md new file mode 100644 index 00000000000..7ca5d3ce9cf --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/tips-and-tricks/cost-optimization.md @@ -0,0 +1,94 @@ +--- +'sidebar_position': 1 +'slug': '/community-wisdom/cost-optimization' +'sidebar_label': '成本优化' +'doc_type': 'guide' +'keywords': +- 'cost optimization' +- 'storage costs' +- 'partition management' +- 'data retention' +- 'storage analysis' +- 'database optimization' +- 'clickhouse cost reduction' +- 'storage hot spots' +- 'ttl performance' +- 'disk usage' +- 'compression strategies' +- 'retention analysis' +'title': '课程 - 成本优化' +'description': '来自 ClickHouse 社区会议的成本优化策略,包含真实的生产实例和经过验证的技术。' +--- + + +# 成本优化:来自社区的策略 {#cost-optimization} +*本指南是从社区聚会中获得的发现集合的一部分。本页面上的发现涵盖了与使用 ClickHouse 时优化成本相关的社区智慧,这些智慧在他们特定的经验和设置中效果良好。有关更多实际解决方案和见解,您可以 [按特定问题浏览](./community-wisdom.md)。* + +*了解 [ClickHouse Cloud 如何帮助管理运营成本](/cloud/overview)。* + +## 压缩策略:生产中的 LZ4 与 ZSTD {#compression-strategy} + +当 Microsoft Clarity 需要处理数百 TB 的数据时,他们发现压缩选择对成本产生了显著影响。在他们的规模上,每一点存储节省都是重要的,他们面临着经典的权衡:性能与存储成本之间的平衡。Microsoft Clarity 每月处理两 PB 的未压缩数据,跨所有账户处理约 60,000 次查询,覆盖八个节点,并为数百万个网站提供数十亿次页面浏览。在这种规模下,压缩策略成为一个关键的成本因素。 + +他们最初使用 ClickHouse 默认的 [LZ4](/sql-reference/statements/create/table#lz4) 压缩,但发现使用 [ZSTD](/sql-reference/statements/create/table#zstd) 可以实现显著的成本节省。虽然 LZ4 更快,但 ZSTD 在提供更好压缩的同时性能略慢。在测试两种方法后,他们做出了优先考虑存储节省的战略决策。结果显著:使用 ZSTD 压缩在大表上储存节省达 50%,对数据摄取和查询的性能影响可控。 + +**关键结果:** +- 通过 ZSTD 压缩实现大表 50% 的存储节省 +- 每月 2 PB 的数据处理能力 +- 对数据摄取和查询的性能影响可控 +- 在数百 TB 规模上显著降低成本 + +## 基于列的保留策略 {#column-retention} + +最强大的成本优化技术之一来自于分析哪些列实际上被使用。Microsoft Clarity 实施了利用 ClickHouse 内置遥测功能的复杂基于列的保留策略。ClickHouse 提供了按列的详细存储使用指标,以及全面的查询模式:哪些列被访问、访问频率、查询持续时间和整体使用统计。 + +这种数据驱动的方法使得关于保留政策和列生命周期管理的战略决策成为可能。通过分析这些遥测数据,微软可以识别数据存储热点——消耗大量空间但查询很少的列。对于这些低使用率的列,他们可以实施严格的保留策略,将存储时间从 30 个月减少到仅一个月,或者完全删除这些列(如果根本没有被查询)。这种选择性保留策略降低了存储成本,同时不影响用户体验。 + +**策略:** +- 使用 ClickHouse 遥测分析列的使用模式 +- 识别高存储、低查询的列 +- 实施选择性保留政策 +- 监控查询模式以做出数据驱动的决策 + +**相关文档** +- [管理数据 - 列级 TTL](/observability/managing-data) + +## 基于分区的数据管理 {#partition-management} + +Microsoft Clarity 发现分区策略对性能和操作简化都有影响。他们的做法是:按日期分区,按小时排序。这一策略不仅使清理效率得到提高,还带来多个额外好处——它简化了客户服务的计费计算,并支持针对行的删除的 GDPR 合规要求。 + +**主要好处:** +- 简单的数据清理(删除分区 vs 行逐一删除) +- 简化的计费计算 +- 通过分区消除实现更好的查询性能 +- 更简单的操作管理 + +**相关文档** +- [管理数据 - 分区](/observability/managing-data#partitions) + +## 字符串到整数转换策略 {#string-integer-conversion} + +分析平台常常面临一个存储挑战,即在数百万行中反复出现的分类数据。微软的工程团队在他们的搜索分析数据中遇到了这个问题,并开发出一种有效的解决方案,在受影响的数据集中实现了 60% 的存储减少。 + +在微软的网络分析系统中,搜索结果会触发不同类型的回答——天气卡、体育信息、新闻文章和事实回应。每个查询结果都用诸如 "weather_answer"、"sports_answer" 或 "factual_answer" 的描述性字符串进行标记。在处理数十亿次搜索查询的过程中,这些字符串在 ClickHouse 中被重复存储,占用了大量存储空间,并在查询期间要求进行昂贵的字符串比较。 + +微软实现了一个字符串到整数的映射系统,使用一个单独的 MySQL 数据库。它们不在 ClickHouse 中存储实际的字符串,而只存储整数 ID。当用户通过 UI 运行查询并请求 `weather_answer` 的数据时,他们的查询优化器首先查询 MySQL 映射表以获取相应的整数 ID,然后在发送给 ClickHouse 之前将查询转换为使用该整数。 + +这种架构保留了用户体验——用户在仪表板中仍然看到有意义的标签,如 `weather_answer`——而后端存储和查询则在更高效的整数上运行。映射系统透明地处理所有翻译,无需对用户界面或用户工作流程进行任何更改。 + +**主要好处:** +- 受影响的数据集存储减少 60% +- 整数比较的查询性能更快 +- 连接和聚合所需的内存使用减少 +- 大结果集的网络传输成本降低 + +:::note +这是一个专门用于 Microsoft Clarity 数据场景的示例。如果您将所有数据存储在 ClickHouse 中,或者没有将数据移动到 ClickHouse 的限制,请尝试使用 [字典](/dictionary) 。 +::: + +## 视频来源 {#video-sources} + +- **[Microsoft Clarity 和 ClickHouse](https://www.youtube.com/watch?v=rUVZlquVGw0)** - Microsoft Clarity 团队 +- **[Contentsquare 中的 ClickHouse 旅程](https://www.youtube.com/watch?v=zvuCBAl2T0Q)** - Doron Hoffman & Guram Sigua (ContentSquare) + +*这些社区成本优化见解展示了处理数百 TB 到 PB 数据的公司的策略,显示了减少 ClickHouse 运营成本的现实世界方法。* diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/tips-and-tricks/cost-optimization.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/tips-and-tricks/cost-optimization.md.hash new file mode 100644 index 00000000000..d848adb753a --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/tips-and-tricks/cost-optimization.md.hash @@ -0,0 +1 @@ +c7f1972e02e2f5df diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/tips-and-tricks/debugging-insights.md b/i18n/zh/docusaurus-plugin-content-docs/current/tips-and-tricks/debugging-insights.md new file mode 100644 index 00000000000..097c79a0f01 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/tips-and-tricks/debugging-insights.md @@ -0,0 +1,175 @@ +--- +'sidebar_position': 1 +'slug': '/community-wisdom/debugging-insights' +'sidebar_label': '调试洞见' +'doc_type': 'guide' +'keywords': +- 'clickhouse troubleshooting' +- 'clickhouse errors' +- 'slow queries' +- 'memory problems' +- 'connection issues' +- 'performance optimization' +- 'database errors' +- 'configuration problems' +- 'debug' +- 'solutions' +'title': '课程 - 调试洞见' +'description': '找到最常见的 ClickHouse 问题的解决方案,包括慢查询、内存错误、连接问题和配置问题。' +--- + + +# ClickHouse 操作:社区调试洞察 {#clickhouse-operations-community-debugging-insights} +*本指南是从社区见面会中获得的一系列发现的一部分。有关更多现实世界的解决方案和洞察,您可以 [按特定问题浏览](./community-wisdom.md)。* +*高运营成本困扰您吗?请查看 [成本优化](./cost-optimization.md) 社区洞察指南。* + +## 基本系统表 {#essential-system-tables} + +这些系统表对于生产调试至关重要: + +### system.errors {#system-errors} + +显示您 ClickHouse 实例中的所有活动错误。 + +```sql +SELECT name, value, changed +FROM system.errors +WHERE value > 0 +ORDER BY value DESC; +``` + +### system.replicas {#system-replicas} + +包含用于监控集群健康的复制延迟和状态信息。 + +```sql +SELECT database, table, replica_name, absolute_delay, queue_size, inserts_in_queue +FROM system.replicas +WHERE absolute_delay > 60 +ORDER BY absolute_delay DESC; +``` + +### system.replication_queue {#system-replication-queue} + +提供用于诊断复制问题的详细信息。 + +```sql +SELECT database, table, replica_name, position, type, create_time, last_exception +FROM system.replication_queue +WHERE last_exception != '' +ORDER BY create_time DESC; +``` + +### system.merges {#system-merges} + +显示当前的合并操作,并可以识别卡住的进程。 + +```sql +SELECT database, table, elapsed, progress, is_mutation, total_size_bytes_compressed +FROM system.merges +ORDER BY elapsed DESC; +``` + +### system.parts {#system-parts} + +对于监控部分计数和识别碎片问题至关重要。 + +```sql +SELECT database, table, count() as part_count +FROM system.parts +WHERE active = 1 +GROUP BY database, table +ORDER BY count() DESC; +``` + +## 常见生产问题 {#common-production-issues} + +### 磁盘空间问题 {#disk-space-problems} + +在复制设置中,磁盘空间耗尽会导致级联问题。当一个节点耗尽空间时,其他节点继续尝试与其同步,从而导致网络流量激增和混淆的症状。一位社区成员花了 4 小时调试,结果只是磁盘空间过低。请查看此 [查询](/knowledgebase/useful-queries-for-troubleshooting#show-disk-storage-number-of-parts-number-of-rows-in-systemparts-and-marks-across-databases) 以监控特定集群上的磁盘存储。 + +AWS 用户应注意,默认的一般用途 EBS 卷有 16TB 的限制。 + +### 部件过多错误 {#too-many-parts-error} + +小的频繁插入会造成性能问题。社区发现,插入速率超过每秒 10 次通常会触发“部件过多”错误,因为 ClickHouse 无法快速合并部件。 + +**解决方案:** +- 使用 30 秒或 200MB 的阈值进行批量数据处理 +- 启用 async_insert 进行自动分批 +- 使用缓冲表进行服务器端批处理 +- 配置 Kafka 以控制批量大小 + +[官方建议](/best-practices/selecting-an-insert-strategy#batch-inserts-if-synchronous):每次插入至少 1,000 行,理想状态下为 10,000 到 100,000。 + +### 时间戳无效问题 {#data-quality-issues} + +发送任意时间戳数据的应用程序会造成分区问题。这会导致具有不现实日期(例如 1998 或 2050 年)数据的分区,从而导致意外的存储行为。 + +### `ALTER` 操作风险 {#alter-operation-risks} + +在多 TB 表上进行大规模 `ALTER` 操作可能会消耗大量资源并可能锁定数据库。一位社区示例涉及在 14TB 数据上将一个整数更改为浮点数,这导致整个数据库被锁定,并需要从备份中重建。 + +**监控高成本变更:** + +```sql +SELECT database, table, mutation_id, command, parts_to_do, is_done +FROM system.mutations +WHERE is_done = 0; +``` + +首先在较小的数据集上测试模式更改。 + +## 内存和性能 {#memory-and-performance} + +### 外部聚合 {#external-aggregation} + +为内存密集型操作启用外部聚合。这虽然较慢,但可以防止由于溢出到磁盘而导致的内存不足崩溃。您可以通过使用 `max_bytes_before_external_group_by` 来实现,这将帮助防止在大型 `GROUP BY` 操作中出现内存不足崩溃。您可以在 [这里]( /operations/settings/settings#max_bytes_before_external_group_by) 了解更多关于此设置的信息。 + +```sql +SELECT + column1, + column2, + COUNT(*) as count, + SUM(value) as total +FROM large_table +GROUP BY column1, column2 +SETTINGS max_bytes_before_external_group_by = 1000000000; -- 1GB threshold +``` + +### 异步插入详细信息 {#async-insert-details} + +异步插入会自动在服务器端对小插入进行批处理以提高性能。您可以配置是否在返回确认之前等待数据写入磁盘——立即返回速度更快但耐久性较差。现代版本支持去重,以处理批次内的重复数据。 + +**相关文档** +- [选择插入策略](/best-practices/selecting-an-insert-strategy#asynchronous-inserts) + +### 分布式表配置 {#distributed-table-configuration} + +默认情况下,分布式表使用单线程插入。启用 `insert_distributed_sync` 进行并行处理并立即将数据发送到分片。 + +使用分布式表时监控临时数据的积累。 + +### 性能监控阈值 {#performance-monitoring-thresholds} + +社区建议的监控阈值: +- 每个分区的部件:最好少于 100 +- 延迟插入:应保持在零 +- 插入速率:为了最佳性能,限制在每秒约 1 次 + +**相关文档** +- [自定义分区键](/engines/table-engines/mergetree-family/custom-partitioning-key) + +## 快速参考 {#quick-reference} + +| 问题 | 检测 | 解决方案 | +|-------|-----------|----------| +| 磁盘空间 | 检查 `system.parts` 总字节 | 监控使用情况,规划扩展 | +| 部件过多 | 计算每个表的部件 | 批量插入,启用 async_insert | +| 复制延迟 | 检查 `system.replicas` 延迟 | 监控网络,重启副本 | +| 错误数据 | 验证分区日期 | 实施时间戳验证 | +| 卡住的变更 | 检查 `system.mutations` 状态 | 先在小数据上测试 | + +### 视频来源 {#video-sources} +- [操作 ClickHouse 的 10 个经验教训](https://www.youtube.com/watch?v=liTgGiTuhJE) +- [在 ClickHouse 中快速、并发和一致的异步插入](https://www.youtube.com/watch?v=AsMPEfN5QtM) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/tips-and-tricks/debugging-insights.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/tips-and-tricks/debugging-insights.md.hash new file mode 100644 index 00000000000..bb30c569d93 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/tips-and-tricks/debugging-insights.md.hash @@ -0,0 +1 @@ +b207b74e8b144423 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/tips-and-tricks/materialized-views.md b/i18n/zh/docusaurus-plugin-content-docs/current/tips-and-tricks/materialized-views.md new file mode 100644 index 00000000000..b929483fee7 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/tips-and-tricks/materialized-views.md @@ -0,0 +1,69 @@ +--- +'sidebar_position': 1 +'slug': '/tips-and-tricks/materialized-views' +'sidebar_label': '物化视图' +'doc_type': 'guide' +'keywords': +- 'clickhouse materialized views' +- 'materialized view optimization' +- 'materialized view storage issues' +- 'materialized view best practices' +- 'database aggregation patterns' +- 'materialized view anti-patterns' +- 'storage explosion problems' +- 'materialized view performance' +- 'database view optimization' +- 'aggregation strategy' +- 'materialized view troubleshooting' +- 'view storage overhead' +'title': '课程 - 物化视图' +'description': '现实世界中物化视图的例子,问题和解决方案' +--- + + +# 物化视图:它们如何成为一把双刃剑 {#materialized-views-the-double-edged-sword} + +*本指南是从社区聚会中获得的一系列发现的一部分。有关更多现实世界解决方案和见解,您可以 [按具体问题浏览](./community-wisdom.md)。* +*数据库受到过多分片的困扰?请查看 [过多分片](./too-many-parts.md) 社区见解指南。* +*了解更多关于 [物化视图](/materialized-views) 的信息。* + +## 10倍存储反模式 {#storage-antipattern} + +**真实的生产问题:** *“我们有一个物化视图。原始日志表约为20GB,但来自该日志表的视图膨胀到190GB,所以几乎是原始表大小的10倍。这是因为我们为每个属性创建了一行,而每个日志可以有10个属性。”* + +**规则:** 如果您的 `GROUP BY` 创建的行数超过它消除的行数,您正在构建一个昂贵的索引,而不是一个物化视图。 + +## 生产物化视图健康验证 {#mv-health-validation} + +此查询可以帮助您在创建物化视图之前预测它是否会压缩或膨胀您的数据。针对您的实际表和列运行它,以避免“190GB爆炸”的情况。 + +**它显示的内容:** +- **低聚合比**(\<10%) = 良好的物化视图,显著压缩 +- **高聚合比**(\>70%) = 不良的物化视图,存储膨胀风险 +- **存储倍增器** = 您的物化视图将增大/缩小的倍数 + +```sql +-- Replace with your actual table and columns +SELECT + count() as total_rows, + uniq(your_group_by_columns) as unique_combinations, + round(uniq(your_group_by_columns) / count() * 100, 2) as aggregation_ratio +FROM your_table +WHERE your_filter_conditions; + +-- If aggregation_ratio > 70%, reconsider your MV design +-- If aggregation_ratio < 10%, you'll get good compression +``` + +## 何时物化视图会成为问题 {#mv-problems} + +**需要监控的警告信号:** +- 插入延迟增加(之前10毫秒的查询现在需要100毫秒以上) +- “太多分片”错误出现得更频繁 +- 插入操作期间CPU激增 +- 插入超时以前没有发生过 + +您可以通过使用 `system.query_log` 比较添加物化视图前后的插入性能,以跟踪查询持续时间趋势。 + +## 视频来源 {#video-sources} +- [ClickHouse 在 CommonRoom - Kirill Sapchuk](https://www.youtube.com/watch?v=liTgGiTuhJE) - “对物化视图过于热情”和“20GB→190GB爆炸”案例研究的来源 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/tips-and-tricks/materialized-views.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/tips-and-tricks/materialized-views.md.hash new file mode 100644 index 00000000000..20939ca59d3 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/tips-and-tricks/materialized-views.md.hash @@ -0,0 +1 @@ +6838361c42803545 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/tips-and-tricks/performance-optimization.md b/i18n/zh/docusaurus-plugin-content-docs/current/tips-and-tricks/performance-optimization.md new file mode 100644 index 00000000000..6c961ce76e1 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/tips-and-tricks/performance-optimization.md @@ -0,0 +1,139 @@ +--- +'sidebar_position': 1 +'slug': '/community-wisdom/performance-optimization' +'sidebar_label': '性能优化' +'doc_type': 'guide' +'keywords': +- 'performance optimization' +- 'query performance' +- 'database tuning' +- 'slow queries' +- 'memory optimization' +- 'cardinality analysis' +- 'indexing strategies' +- 'aggregation optimization' +- 'sampling techniques' +- 'database performance' +- 'query analysis' +- 'performance troubleshooting' +'title': '课程 - 性能优化' +'description': '性能优化策略的实际案例' +--- + + +# 性能优化:社区测试策略 {#performance-optimization} +*本指南是从社区会议中获得的一系列发现的一部分。有关更多现实世界的解决方案和见解,您可以[按特定问题浏览](./community-wisdom.md)。* +*对物化视图有疑问吗?请查看[物化视图](./materialized-views.md)社区见解指南。* +*如果您遇到慢查询并希望获得更多示例,我们还有[查询优化](/optimize/query-optimization)指南。* + +## 按基数排序(从低到高) {#cardinality-ordering} +ClickHouse 的主索引在低基数列位于前面时效果最佳,这使其能够有效地跳过大块数据。基数高的列在键的后面提供了在这些块内的细粒度排序。从具有少量唯一值的列(如状态、类别、国家)开始,并以具有许多唯一值的列(如 user_id、时间戳、session_id)结束。 + +查看有关基数和主索引的更多文档: +- [选择主键](/best-practices/choosing-a-primary-key) +- [主索引](/primary-indexes) + +## 时间粒度重要性 {#time-granularity} +在使用时间戳的 ORDER BY 子句时,请考虑基数与精度的权衡。微秒级精度的时间戳会产生非常高的基数(几乎每行一个唯一值),这降低了 ClickHouse 的稀疏主索引的有效性。四舍五入的时间戳创建较低的基数,从而实现更好的索引跳过,但您会失去基于时间的查询的精度。 + +```sql runnable editable +-- Challenge: Try different time functions like toStartOfMinute or toStartOfWeek +-- Experiment: Compare the cardinality differences with your own timestamp data +SELECT + 'Microsecond precision' as granularity, + uniq(created_at) as unique_values, + 'Creates massive cardinality - bad for sort key' as impact +FROM github.github_events +WHERE created_at >= '2024-01-01' +UNION ALL +SELECT + 'Hour precision', + uniq(toStartOfHour(created_at)), + 'Much better for sort key - enables skip indexing' +FROM github.github_events +WHERE created_at >= '2024-01-01' +UNION ALL +SELECT + 'Day precision', + uniq(toStartOfDay(created_at)), + 'Best for reporting queries' +FROM github.github_events +WHERE created_at >= '2024-01-01'; +``` + +## 着重于单个查询,而非平均值 {#focus-on-individual-queries-not-averages} + +在调试 ClickHouse 性能时,不要依赖平均查询时间或整体系统指标。相反,要找出特定查询缓慢的原因。一个系统可能具有良好的平均性能,而单个查询却因内存耗尽、过滤不佳或高基数操作而变得缓慢。 + +据 ClickHouse 的首席技术官 Alexey 所说:*"正确的方法是问自己,为什么这个特别的查询耗时五秒……我不关心中位数和其他查询处理得快。我只关心我的查询"* + +当查询缓慢时,不要仅仅查看平均值。问“为什么这个特定的查询缓慢?”并检查实际的资源使用模式。 + +## 内存和行扫描 {#memory-and-row-scanning} + +Sentry 是一个以开发者为首的错误跟踪平台,每天处理来自 400 多万开发者的数十亿事件。他们的关键见解是:*"在这种特定情况下,驱动内存的分组键的基数"* - 高基数聚合会通过内存耗尽而损害性能,而不是行扫描。 + +当查询失败时,确定问题是内存问题(组太多)还是扫描问题(行太多)。 + +像 `GROUP BY user_id, error_message, url_path` 这样的查询为所有三种值的每个唯一组合创建一个单独的内存状态。随着用户、错误类型和 URL 路径的负载增加,您可能会轻松生成必须在内存中同时保持的数百万个聚合状态。 + +对于极端情况,Sentry 使用确定性抽样。10% 的样本将内存使用量减少 90%,同时保持大约 5% 的聚合精度: + +```sql +WHERE cityHash64(user_id) % 10 = 0 -- Always same 10% of users +``` + +这确保相同的用户在每个查询中出现,从而在时间段之间提供一致的结果。关键见解是:`cityHash64()` 为相同输入生成一致的哈希值,因此 `user_id = 12345` 总是会哈希到相同的值,确保该用户要么始终出现在您的 10% 样本中,要么从未出现 - 在查询之间没有闪烁。 + +## Sentry 的位掩码优化 {#bit-mask-optimization} + +在按高基数列(如 URL)聚合时,每个唯一值在内存中创建一个单独的聚合状态,导致内存耗尽。Sentry 的解决方案是:不按实际的 URL 字符串分组,而是按布尔表达式分组,以合并为位掩码。 + +这是您可以在自己表上尝试的查询,如果这种情况适用于您: + +```sql +-- Memory-Efficient Aggregation Pattern: Each condition = one integer per group +-- Key insight: sumIf() creates bounded memory regardless of data volume +-- Memory per group: N integers (N * 8 bytes) where N = number of conditions + +SELECT + your_grouping_column, + + -- Each sumIf creates exactly one integer counter per group + -- Memory stays constant regardless of how many rows match each condition + sumIf(1, your_condition_1) as condition_1_count, + sumIf(1, your_condition_2) as condition_2_count, + sumIf(1, your_text_column LIKE '%pattern%') as pattern_matches, + sumIf(1, your_numeric_column > threshold_value) as above_threshold, + + -- Complex multi-condition aggregations still use constant memory + sumIf(1, your_condition_1 AND your_text_column LIKE '%pattern%') as complex_condition_count, + + -- Standard aggregations for context + count() as total_rows, + avg(your_numeric_column) as average_value, + max(your_timestamp_column) as latest_timestamp + +FROM your_schema.your_table +WHERE your_timestamp_column >= 'start_date' + AND your_timestamp_column < 'end_date' +GROUP BY your_grouping_column +HAVING condition_1_count > minimum_threshold + OR condition_2_count > another_threshold +ORDER BY (condition_1_count + condition_2_count + pattern_matches) DESC +LIMIT 20 +``` + +您不是在内存中存储每个唯一字符串,而是将有关这些字符串的问题的答案存储为整数。无论数据多样性如何,聚合状态的大小都变得有限且微小。 + +来自 Sentry 工程团队的反馈:“这些重查询的速度提高了十倍以上,我们的内存使用降低了 100 倍(更重要的是,保持在一定范围内)。我们的最大客户在搜索回放时不再看到错误,我们现在可以支持任意规模的客户,而不会耗尽内存。” + +## 视频来源 {#video-sources} + +- [Lost in the Haystack - 优化高基数聚合](https://www.youtube.com/watch?v=paK84-EUJCA) - Sentry 在内存优化方面的生产经验教训 +- [ClickHouse 性能分析](https://www.youtube.com/watch?v=lxKbvmcLngo) - Alexey Milovidov 关于调试方法论 +- [ClickHouse 会议:查询优化技术](https://www.youtube.com/watch?v=JBomQk4Icjo) - 社区优化策略 + +**下一步阅读**: +- [查询优化指南](/optimize/query-optimization) +- [物化视图社区见解](./materialized-views.md) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/tips-and-tricks/performance-optimization.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/tips-and-tricks/performance-optimization.md.hash new file mode 100644 index 00000000000..ec4bc8c298e --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/tips-and-tricks/performance-optimization.md.hash @@ -0,0 +1 @@ +b582583654e632e6 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/tips-and-tricks/success-stories.md b/i18n/zh/docusaurus-plugin-content-docs/current/tips-and-tricks/success-stories.md new file mode 100644 index 00000000000..b6bcee84846 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/tips-and-tricks/success-stories.md @@ -0,0 +1,62 @@ +--- +'sidebar_position': 1 +'slug': '/community-wisdom/creative-use-cases' +'sidebar_label': '成功案例' +'doc_type': 'guide' +'keywords': +- 'clickhouse creative use cases' +- 'clickhouse success stories' +- 'unconventional database uses' +- 'clickhouse rate limiting' +- 'analytics database applications' +- 'clickhouse mobile analytics' +- 'customer-facing analytics' +- 'database innovation' +- 'clickhouse real-time applications' +- 'alternative database solutions' +- 'breaking database conventions' +- 'production success stories' +'title': '课程 - 创意应用案例' +'description': '寻找解决最常见的 ClickHouse 问题的方案,包括慢查询、内存错误、连接问题和配置问题。' +--- + + +# 成功案例 {#breaking-the-rules} + +*本指南是从社区聚会上获得的一系列发现的一部分。欲获取更多现实世界的解决方案和见解,你可以 [按特定问题浏览](./community-wisdom.md)。* +*需要在生产环境中调试问题的提示?查看 [调试见解](./debugging-insights.md) 社区指南。* + +这些故事展示了公司如何通过使用 ClickHouse 达到成功,甚至有些案例挑战了传统数据库类别,证明有时候“错误”的工具恰恰就是正确的解决方案。 + +## ClickHouse 作为限流器 {#clickhouse-rate-limiter} + +当 Craigslist 需要添加一层顶级限流以保护用户时,他们面临着每个工程团队都会遇到的相同决定 - 遵循传统智慧,使用 Redis,还是探索其他选择。Brad Lhotsky,Craigslist 的一名员工,知道 Redis 是标准选择 - 几乎所有的限流教程和在线示例都出于良好原因而使用 Redis。它在限流操作中有丰富的原语,建立了良好的模式,并有着经过验证的成功记录。但 Craigslist 与 Redis 的经验并没有匹配教科书的例子。*"我们与 Redis 的经验并不像你在电影中看到的那样......我们遇到了许多奇怪的维护问题,例如在 Redis 集群中重启节点后,前端会出现一些延迟尖峰。"* 对于一个重视维护简单性的团队来说,这些操作上的麻烦正在成为一个真正的问题。 + +因此,当 Brad 被问到限流需求时,他采取了不同的方式:*"我问我的老板,‘你对这个主意怎么看?我可以尝试用 ClickHouse 来解决吗?’"* 这个想法虽然不寻常 - 使用分析数据库来解决通常由缓存层问题解决的事情 - 但它满足了他们的核心需求:故障开放、不产生延迟惩罚,并且对小团队来说维护安全。该解决方案利用了他们现有的基础架构,访问日志已经通过 Kafka 流入 ClickHouse。通过直接分析访问日志数据中的请求模式,他们可以将限流规则注入到现有的 ACL API 中,而无需维护一个单独的 Redis 集群。虽然这种方法的延迟略高于 Redis,*“这在某种程度上是通过提前实例化该数据集来作弊”,*但查询仍在 100 毫秒以内完成。 + +**关键结果:** +- 相较于 Redis 基础设施,显著改善 +- 内置的 TTL 进行自动清理,消除了维护开销 +- SQL 灵活性使得复杂的限流规则超越简单计数器 +- 利用现有数据管道,而不需要单独的基础设施 + +## ClickHouse 用于客户分析 {#customer-analytics} + +当 ServiceNow 需要升级他们的移动分析平台时,他们面临一个简单的问题:*"我们为什么要替换一个有效的系统?"* ServiceNow 的 Amir Vaza 知道他们现有的系统是可靠的,但客户的需求正在超出其承载能力。*"更换一个现有可靠模型的动机实际上来自产品领域,"* Amir 解释道。ServiceNow 将移动分析作为他们针对网页、移动和聊天机器人的解决方案的一部分提供,但客户希望拥有超越预聚合数据的分析灵活性。 + +他们之前的系统使用了大约 30 个不同的表,这些表根据固定维度(应用程序、应用程序版本和平台)对预聚合数据进行分段。对于客户可以发送的自定义属性(键值对),他们为每个组创建了单独的计数器。虽然这种方法在快速仪表板性能上表现出色,但却有一个主要限制。*"虽然这对快速的价值细分很有帮助,但我提到的限制导致了大量分析上下文的丧失,"* Amir 指出。客户无法进行复杂的客户旅程分析或提出诸如“以搜索词 'research RSA token' 开始的会话有多少个”的问题,然后分析这些用户接下来做了什么。预聚合结构破坏了多步骤分析所需的顺序上下文,每个新的分析维度都需要工程工作进行预聚合和存储。 + +因此,当局限性变得明显时,ServiceNow 转向了 ClickHouse,完全消除了这些预计算约束。他们不再提前计算每个变量,而是将元数据分解为数据点,并将所有内容直接插入 ClickHouse。他们使用了 ClickHouse 的异步插入队列,Amir 称其为*"真正令人惊叹的,"*以高效地处理数据摄取。这样,客户现在可以创建自己的分段,以任何维度自由切片数据,并进行以前无法实现的复杂客户旅程分析。 + +**关键结果:** +- 在没有预计算的情况下,跨任何维度进行动态分段 +- 复杂的客户旅程分析变得可能 +- 客户可以创建自己的分段并自由切片数据 +- 新分析需求不再有工程瓶颈 + +## 视频来源 {#video-sources} + +- **[打破规则 - 用 ClickHouse 构建限流器](https://www.youtube.com/watch?v=wRwqrbUjRe4)** - Brad Lhotsky (Craigslist) +- **[ClickHouse 作为 ServiceNow 的分析解决方案](https://www.youtube.com/watch?v=b4Pmpx3iRK4)** - Amir Vaza (ServiceNow) + +*这些故事展示了质疑传统数据库智慧如何能引领突破性解决方案,重新定义分析数据库的可能性。* diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/tips-and-tricks/success-stories.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/tips-and-tricks/success-stories.md.hash new file mode 100644 index 00000000000..fea7e226c6b --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/tips-and-tricks/success-stories.md.hash @@ -0,0 +1 @@ +e12b836eda0c5438 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/tips-and-tricks/too-many-parts.md b/i18n/zh/docusaurus-plugin-content-docs/current/tips-and-tricks/too-many-parts.md new file mode 100644 index 00000000000..30960af3e48 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/tips-and-tricks/too-many-parts.md @@ -0,0 +1,76 @@ +--- +'sidebar_position': 1 +'slug': '/tips-and-tricks/too-many-parts' +'sidebar_label': '过多分区片段' +'doc_type': 'guide' +'keywords': +- 'clickhouse too many parts' +- 'too many parts error' +- 'clickhouse insert batching' +- 'part explosion problem' +- 'clickhouse merge performance' +- 'batch insert optimization' +- 'clickhouse async inserts' +- 'small insert problems' +- 'clickhouse parts management' +- 'insert performance optimization' +- 'clickhouse batching strategy' +- 'database insert patterns' +'title': '课程 - 过多分区片段问题' +'description': '过多分区片段的解决方案和预防措施' +--- + + +# 过多分区片段问题 {#the-too-many-parts-problem} +*本指南是从社区会议中获得的一系列发现的一部分。有关更多实际解决方案和见解,您可以[按特定问题浏览](./community-wisdom.md)。* +*需要更多性能优化建议吗?查看[性能优化](./performance-optimization.md)社区见解指南。* + +## 理解问题 {#understanding-the-problem} + +ClickHouse 会抛出“过多分区片段”错误,以防止严重的性能下降。小分区片段会导致多个问题:读取和合并更多文件时查询性能较差,内存使用增加因为每个分区片段都需要在内存中存储元数据,较小的数据块压缩效率降低,更多文件句柄和寻址操作加大了 I/O 开销,以及较慢的后台合并使合并调度器的工作量增加。 + +**相关文档** +- [MergeTree 引擎](/engines/table-engines/mergetree-family/mergetree) +- [分区片段](/parts) +- [分区片段系统表](/operations/system-tables/parts) + +## 及早识别问题 {#recognize-parts-problem} + +此查询通过分析所有活动表中的分区片段数量和大小来监控表碎片。它识别出可能需要合并优化的分区片段过多或过小的表。定期使用此查询,以在对查询性能产生影响之前捕捉到碎片问题。 + +```sql runnable editable +-- Challenge: Replace with your actual database and table names for production use +-- Experiment: Adjust the part count thresholds (1000, 500, 100) based on your system +SELECT + database, + table, + count() as total_parts, + sum(rows) as total_rows, + round(avg(rows), 0) as avg_rows_per_part, + min(rows) as min_rows_per_part, + max(rows) as max_rows_per_part, + round(sum(bytes_on_disk) / 1024 / 1024, 2) as total_size_mb, + CASE + WHEN count() > 1000 THEN 'CRITICAL - Too many parts (>1000)' + WHEN count() > 500 THEN 'WARNING - Many parts (>500)' + WHEN count() > 100 THEN 'CAUTION - Getting many parts (>100)' + ELSE 'OK - Reasonable part count' + END as parts_assessment, + CASE + WHEN avg(rows) < 1000 THEN 'POOR - Very small parts' + WHEN avg(rows) < 10000 THEN 'FAIR - Small parts' + WHEN avg(rows) < 100000 THEN 'GOOD - Medium parts' + ELSE 'EXCELLENT - Large parts' + END as part_size_assessment +FROM system.parts +WHERE active = 1 + AND database NOT IN ('system', 'information_schema') +GROUP BY database, table +ORDER BY total_parts DESC +LIMIT 20; +``` + +## 视频来源 {#video-sources} + +- [ClickHouse 中快速、并发和一致的异步插入](https://www.youtube.com/watch?v=AsMPEfN5QtM) - ClickHouse 团队成员解释异步插入和过多分区片段问题 +- [大规模生产 ClickHouse](https://www.youtube.com/watch?v=liTgGiTuhJE) - 观察平台的实际批处理策略 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/tips-and-tricks/too-many-parts.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/tips-and-tricks/too-many-parts.md.hash new file mode 100644 index 00000000000..27793824a23 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/tips-and-tricks/too-many-parts.md.hash @@ -0,0 +1 @@ +63669f1cf65a0384 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/tools-and-utilities/static-files-disk-uploader.md b/i18n/zh/docusaurus-plugin-content-docs/current/tools-and-utilities/static-files-disk-uploader.md index 9bc7c58515a..057b313d7f9 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/tools-and-utilities/static-files-disk-uploader.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/tools-and-utilities/static-files-disk-uploader.md @@ -7,16 +7,17 @@ - 'disk' - 'uploader' 'description': '提供 clickhouse-static-files-disk-uploader 工具的描述' +'doc_type': 'guide' --- # clickhouse-static-files-disk-uploader -输出包含指定 ClickHouse 表元数据的数据目录。该元数据可用于在不同服务器上创建一个仅包含由 `web` 磁盘支持的只读数据集的 ClickHouse 表。 +输出包含指定 ClickHouse 表元数据的数据目录。该元数据可用于在不同服务器上创建包含仅读数据集的 ClickHouse 表,该数据集由 `web` 磁盘支持。 -请勿使用此工具迁移数据。请使用 [`BACKUP` 和 `RESTORE` 命令](/operations/backup)。 +请勿使用此工具迁移数据。相反,请使用 [`BACKUP` 和 `RESTORE` 命令](/operations/backup)。 -## 用法 {#usage} +## 使用方法 {#usage} ```bash $ clickhouse static-files-disk-uploader [args] @@ -28,16 +29,16 @@ $ clickhouse static-files-disk-uploader [args] |---|---| |`-h`, `--help`|打印帮助信息| |`--metadata-path [path]`|包含指定表元数据的路径| -|`--test-mode`|启用 `test` 模式,向给定 URL 提交包含表元数据的 PUT 请求| +|`--test-mode`|启用 `test` 模式,该模式将表元数据以 PUT 请求提交到给定的 URL| |`--link`|创建符号链接,而不是将文件复制到输出目录| -|`--url [url]`|用于 `test` 模式的 web 服务器 URL| +|`--url [url]`|`test` 模式的网络服务器 URL| |`--output-dir [dir]`|在 `non-test` 模式下输出文件的目录| ## 检索指定表的元数据路径 {#retrieve-metadata-path-for-the-specified-table} 使用 `clickhouse-static-files-disk-uploader` 时,您必须获取所需表的元数据路径。 -1. 运行以下查询,指定您的目标表和数据库: +1. 运行以下查询,指定目标表和数据库:
@@ -47,7 +48,7 @@ SELECT data_paths WHERE name = 'mytable' AND database = 'default'; ``` -2. 这将返回指定表的数据目录路径: +2. 这应该会返回指定表的数据目录路径:
@@ -57,25 +58,25 @@ SELECT data_paths └───────────────────────────────────────────────────────┘ ``` -## 将表元数据目录输出到本地文件系统 {#output-table-metadata-directory-to-the-local-filesystem} +## 输出表元数据目录到本地文件系统 {#output-table-metadata-directory-to-the-local-filesystem} -使用目标输出目录 `output` 和给定元数据路径,执行以下命令: +使用目标输出目录 `output` 和给定的元数据路径,执行以下命令: ```bash $ clickhouse static-files-disk-uploader --output-dir output --metadata-path ./store/bcc/bccc1cfd-d43d-43cf-a5b6-1cda8178f1ee/ ``` -如果成功,您将看到以下消息,并且 `output` 目录应包含指定表的元数据: +如果成功,您应该看到以下消息,并且 `output` 目录应包含指定表的元数据: ```repsonse Data path: "/Users/john/store/bcc/bccc1cfd-d43d-43cf-a5b6-1cda8178f1ee", destination path: "output" ``` -## 将表元数据目录输出到外部 URL {#output-table-metadata-directory-to-an-external-url} +## 输出表元数据目录到外部 URL {#output-table-metadata-directory-to-an-external-url} -此步骤类似于将数据目录输出到本地文件系统,但附加了 `--test-mode` 标志。您必须通过 `--url` 标志指定目标 URL,而不是指定输出目录。 +此步骤与将数据目录输出到本地文件系统类似,但添加了 `--test-mode` 标志。您必须通过 `--url` 标志指定目标 URL,而不是指定输出目录。 -启用 `test` 模式后,表元数据目录将通过 PUT 请求上传到指定的 URL。 +启用 `test` 模式后,表元数据目录通过 PUT 请求上传到指定的 URL。 ```bash $ clickhouse static-files-disk-uploader --test-mode --url http://nginx:80/test1 --metadata-path ./store/bcc/bccc1cfd-d43d-43cf-a5b6-1cda8178f1ee/ @@ -83,6 +84,6 @@ $ clickhouse static-files-disk-uploader --test-mode --url http://nginx:80/test1 ## 使用表元数据目录创建 ClickHouse 表 {#using-the-table-metadata-directory-to-create-a-clickhouse-table} -一旦您拥有表元数据目录,就可以使用它在不同服务器上创建 ClickHouse 表。 +一旦您拥有表元数据目录,即可利用它在不同的服务器上创建 ClickHouse 表。 -请参阅 [这个 GitHub 仓库](https://github.com/ClickHouse/web-tables-demo) 显示的示例。在该示例中,我们使用 `web` 磁盘创建表,这允许我们将表附加到不同服务器上的数据集。 +请参见 [这个 GitHub 存储库](https://github.com/ClickHouse/web-tables-demo) 展示的演示。在示例中,我们使用 `web` 磁盘创建一个表,这允许我们将表附加到不同服务器上的数据集。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/tools-and-utilities/static-files-disk-uploader.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/tools-and-utilities/static-files-disk-uploader.md.hash index f6a11f53891..bed527ffcd6 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/tools-and-utilities/static-files-disk-uploader.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/tools-and-utilities/static-files-disk-uploader.md.hash @@ -1 +1 @@ -4aca542f031b077c +f895f09e66c914a2 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/troubleshooting/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/troubleshooting/index.md new file mode 100644 index 00000000000..009aa206ba7 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/troubleshooting/index.md @@ -0,0 +1,151 @@ +--- +'slug': '/troubleshooting' +'sidebar_label': '故障排除' +'doc_type': 'guide' +'keywords': +- 'clickhouse troubleshooting' +- 'clickhouse errors' +- 'database troubleshooting' +- 'clickhouse connection issues' +- 'memory limit exceeded' +- 'clickhouse performance problems' +- 'database error messages' +- 'clickhouse configuration issues' +- 'connection refused error' +- 'clickhouse debugging' +- 'database connection problems' +- 'troubleshooting guide' +'title': '故障排除常见问题' +'description': '查找最常见的 ClickHouse 问题的解决方案,包括慢查询、内存错误、连接问题和配置问题。' +--- + + +# 排查常见问题 {#troubleshooting-common-issues} + +遇到 ClickHouse 的问题吗?在这里找到常见问题的解决方案。 + +## 性能和错误 {#performance-and-errors} + +查询运行缓慢、超时,或者收到特定错误信息,例如“内存限制超出”或“连接被拒绝”。 + +
+显示性能和错误解决方案 + +### 查询性能 {#query-performance} +- [查找使用最多资源的查询](/knowledgebase/find-expensive-queries) +- [完整的查询优化指南](/docs/optimize/query-optimization) +- [优化 JOIN 操作](/docs/best-practices/minimize-optimize-joins) +- [运行诊断查询以查找瓶颈](/docs/knowledgebase/useful-queries-for-troubleshooting) +
+### 数据插入性能 {#data-insertion-performance} +- [加快数据插入速度](/docs/optimize/bulk-inserts) +- [设置异步插入](/docs/optimize/asynchronous-inserts) +
+### 高级分析工具 {#advanced-analysis-tools} + +- [检查正在运行的进程](/docs/knowledgebase/which-processes-are-currently-running) +- [监控系统性能](/docs/operations/system-tables/processes) +
+### 错误消息 {#error-messages} +- **"内存限制超出"** → [调试内存限制错误](/docs/guides/developer/debugging-memory-issues) +- **"连接被拒绝"** → [修复连接问题](#connections-and-authentication) +- **"登录失败"** → [设置用户、角色和权限](/docs/operations/access-rights) +- **"SSL 证书错误"** → [修复证书问题](/docs/knowledgebase/certificate_verify_failed_error) +- **"表/数据库错误"** → [数据库创建指南](/docs/sql-reference/statements/create/database) | [表 UUID 问题](/docs/engines/database-engines/atomic) +- **"网络超时"** → [网络故障排除](/docs/interfaces/http) +- **其他问题** → [跟踪集群中的错误](/docs/operations/system-tables/errors) +
+ +## 内存和资源 {#memory-and-resources} + +高内存使用、内存溢出崩溃或需要帮助调整 ClickHouse 部署的规模。 + +
+显示内存解决方案 + +### 内存调试和监控 {#memory-debugging-and-monitoring} + +- [识别内存使用情况](/docs/guides/developer/debugging-memory-issues) +- [检查当前内存使用](/docs/operations/system-tables/processes) +- [内存分配分析](/docs/operations/allocation-profiling) +- [分析内存使用模式](/docs/operations/system-tables/query_log) +
+### 内存配置 {#memory-configuration} + +- [配置内存限制](/docs/operations/settings/memory-overcommit) +- [服务器内存设置](/docs/operations/server-configuration-parameters/settings) +- [会话内存设置](/docs/operations/settings/settings) +
+### 扩展和调整大小 {#scaling-and-sizing} + +- [正确调整服务规模](/docs/operations/tips) +- [配置自动扩展](/docs/manage/scaling) + +
+ +## 连接和身份验证 {#connections-and-authentication} + +无法连接到 ClickHouse、身份验证失败、SSL 证书错误或客户端设置问题。 + +
+显示连接解决方案 + +### 基本连接问题 {#basic-connection-issues} +- [修复 HTTP 接口问题](/docs/interfaces/http) +- [处理 SSL 证书问题](/docs/knowledgebase/certificate_verify_failed_error) +- [用户身份验证设置](/docs/operations/access-rights) +
+### 客户端接口 {#client-interfaces} +- [原生 ClickHouse 客户端](/docs/interfaces/natives-clients-and-interfaces) +- [MySQL 接口问题](/docs/interfaces/mysql) +- [PostgreSQL 接口问题](/docs/interfaces/postgresql) +- [gRPC 接口配置](/docs/interfaces/grpc) +- [SSH 接口设置](/docs/interfaces/ssh) +
+### 网络和数据 {#network-and-data} +- [网络安全设置](/docs/operations/server-configuration-parameters/settings) +- [数据格式解析问题](/docs/interfaces/formats) + +
+ +## 设置和配置 {#setup-and-configuration} + +初始安装、服务器配置、数据库创建、数据摄取问题或复制设置。 + +
+显示设置和配置解决方案 + +### 初始设置 {#initial-setup} +- [配置服务器设置](/docs/operations/server-configuration-parameters/settings) +- [设置安全和访问控制](/docs/operations/access-rights) +- [正确配置硬件](/docs/operations/tips) +
+### 数据库管理 {#database-management} +- [创建和管理数据库](/docs/sql-reference/statements/create/database) +- [选择正确的表引擎](/docs/engines/table-engines) + +
+### 数据操作 {#data-operations} +- [优化批量数据插入](/docs/optimize/bulk-inserts) +- [处理数据格式问题](/docs/interfaces/formats) +- [设置流媒体数据管道](/docs/optimize/asynchronous-inserts) +- [提高 S3 集成性能](/docs/integrations/s3/performance) +
+### 高级配置 {#advanced-configuration} +- [设置数据复制](/docs/engines/table-engines/mergetree-family/replication) +- [配置分布式表](/docs/engines/table-engines/special/distributed) + +- [设置备份和恢复](/docs/operations/backup) +- [配置监控](/docs/operations/system-tables/overview) + +
+ +## 还需要帮助吗? {#still-need-help} + +如果找不到解决方案: + +1. **询问 AI** - 询问 AI以获取即时答案。 +1. **检查系统表** - [概述](/operations/system-tables/overview) +2. **查看服务器日志** - 查找 ClickHouse 日志中的错误消息 +3. **询问社区** - [加入我们的社区 Slack](https://clickhouse.com/slack),[GitHub 讨论](https://github.com/ClickHouse/ClickHouse/discussions) +4. **获得专业支持** - [ClickHouse Cloud 支持](https://clickhouse.com/support) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/troubleshooting/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/troubleshooting/index.md.hash new file mode 100644 index 00000000000..3d30ba5a187 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/troubleshooting/index.md.hash @@ -0,0 +1 @@ +25f9b0c7d7823412 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/tutorial.md b/i18n/zh/docusaurus-plugin-content-docs/current/tutorial.md index 90acaa402ff..b67fce1d743 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/tutorial.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/tutorial.md @@ -16,6 +16,7 @@ - 'new york' - 'nyc' 'show_related_blogs': true +'doc_type': 'guide' --- @@ -23,21 +24,21 @@ ## 概述 {#overview} -了解如何使用纽约市出租车示例数据集在 ClickHouse 中摄取和查询数据。 +了解如何使用纽约市出租车示例数据集在 ClickHouse 中导入和查询数据。 -### 先决条件 {#prerequisites} +### 前提条件 {#prerequisites} -您需要访问正在运行的 ClickHouse 服务才能完成本教程。有关说明,请参见 [快速入门](./quick-start.mdx) 指南。 +您需要访问正在运行的 ClickHouse 服务才能完成此教程。有关说明,请参阅 [快速入门](/get-started/quick-start) 指南。 ## 创建新表 {#create-a-new-table} -纽约市出租车数据集包含有关数百万次出租车乘车的详细信息,包括小费金额、过路费、支付类型等列。创建一个表以存储这些数据。 +纽约市出租车数据集包含有关数百万次出租车乘车的详细信息,列包括小费金额、税费、支付类型等。创建一个表来存储这些数据。 1. 连接到 SQL 控制台: -- 对于 ClickHouse Cloud,从下拉菜单中选择服务,然后从左侧导航菜单中选择 **SQL 控制台**。 -- 对于自管理的 ClickHouse,连接到 SQL 控制台,地址为 `https://_hostname_:8443/play`。请与您的 ClickHouse 管理员确认详细信息。 + - 对于 ClickHouse Cloud,从下拉菜单中选择一个服务,然后从左侧导航菜单中选择 **SQL 控制台**。 + - 对于自管理的 ClickHouse,连接到 SQL 控制台 `https://_hostname_:8443/play`。请与您的 ClickHouse 管理员确认详细信息。 2. 在 `default` 数据库中创建以下 `trips` 表: ```sql @@ -96,7 +97,7 @@ ORDER BY pickup_datetime; ## 添加数据集 {#add-the-dataset} -现在您已创建一个表,请从 S3 中的 CSV 文件添加纽约市出租车数据。 +现在您已经创建了一个表,从 S3 中的 CSV 文件中添加纽约市出租车数据。 1. 以下命令从 S3 中的两个不同文件 `trips_1.tsv.gz` 和 `trips_2.tsv.gz` 向您的 `trips` 表插入约 2,000,000 行: @@ -153,18 +154,18 @@ SELECT * FROM s3( ") SETTINGS input_format_try_infer_datetimes = 0 ``` -2. 等待 `INSERT` 完成。下载 150 MB 的数据可能需要一段时间。 +2. 等待 `INSERT` 完成。下载 150 MB 的数据可能需要一些时间。 -3. 插入完成后,验证其成功: +3. 插入完成后,验证它是否成功: ```sql SELECT count() FROM trips ``` - 此查询应返回 1,999,657 行。 + 该查询应返回 1,999,657 行。 ## 分析数据 {#analyze-the-data} -运行一些查询以分析数据。探索以下示例或尝试您自己的 SQL 查询。 +运行一些查询来分析数据。探索以下示例或尝试您自己的 SQL 查询。 - 计算平均小费金额: ```sql @@ -183,7 +184,7 @@ SELECT round(avg(tip_amount), 2) FROM trips

-- 根据乘客人数计算平均费用: +- 根据乘客数量计算平均费用: ```sql SELECT passenger_count, @@ -196,7 +197,7 @@ GROUP BY passenger_count 预期输出

- `passenger_count` 的范围从 0 到 9: + `passenger_count` 的范围是 0 到 9: ```response ┌─passenger_count─┬─average_total_amount─┐ @@ -216,7 +217,7 @@ GROUP BY passenger_count

-- 计算每个社区每天的接客数量: +- 计算每个社区每天的接送次数: ```sql SELECT pickup_date, @@ -247,7 +248,7 @@ ORDER BY pickup_date ASC

-- 计算每次行程的时长(以分钟为单位),然后按行程时长对结果进行分组: +- 计算每次行程的时长(分钟),然后按行程时长分组结果: ```sql SELECT avg(tip_amount) AS avg_tip, @@ -277,7 +278,7 @@ ORDER BY trip_minutes DESC

-- 显示每个社区每小时的接客数量: +- 显示每个社区按小时划分的接送次数: ```sql SELECT pickup_ntaname, @@ -332,8 +333,8 @@ ORDER BY pickup_ntaname, pickup_hour

- -7. 检索前往拉瓜地亚或约翰·F·肯尼迪机场的行程: + +7. 获取前往拉瓜迪亚或 JFK 机场的行程: ```sql SELECT pickup_datetime, @@ -377,22 +378,22 @@ ORDER BY pickup_datetime 字典是存储在内存中的键值对映射。有关详细信息,请参见 [字典](/sql-reference/dictionaries/index.md) -创建一个与您的 ClickHouse 服务中的表关联的字典。 -该表和字典基于一个包含纽约市每个社区行的 CSV 文件。 +创建一个与您 ClickHouse 服务中的表相关联的字典。 +表和字典基于包含纽约市每个社区行的 CSV 文件。 -这些社区与五个纽约市区(布朗克斯、布鲁克林、曼哈顿、皇后区和斯塔滕岛)以及纽瓦克机场(EWR)的名称对应。 +这些社区映射到五个纽约市行政区(布朗克斯、布鲁克林、曼哈顿、皇后区和史坦顿岛)以及纽瓦克机场(EWR)的名称。 -以下是您正在使用的以表格格式展示的 CSV 文件摘录。文件中的 `LocationID` 列映射到您 `trips` 表中的 `pickup_nyct2010_gid` 和 `dropoff_nyct2010_gid` 列: +以下是您用于表格的 CSV 文件的摘录。文件中的 `LocationID` 列映射到您的 `trips` 表中的 `pickup_nyct2010_gid` 和 `dropoff_nyct2010_gid` 列: | LocationID | Borough | Zone | service_zone | | ----------- | ----------- | ----------- | ----------- | | 1 | EWR | 纽瓦克机场 | EWR | - | 2 | 皇后区 | 牙买加湾 | 区域 | - | 3 | 布朗克斯 | 阿勒顿/佩勒姆花园 | 区域 | - | 4 | 曼哈顿 | 字母城市 | 黄色区域 | - | 5 | 斯塔滕岛 | 阿登高地 | 区域 | + | 2 | 皇后区 | 牙买加湾 | 行政区 | + | 3 | 布朗克斯 | 阿莱顿/佩勒姆花园 | 行政区 | + | 4 | 曼哈顿 | 字母城市 | 黄色区 | + | 5 | 史坦顿岛 | 阿登高地 | 行政区 | -1. 运行以下 SQL 命令,创建名为 `taxi_zone_dictionary` 的字典,并从 S3 中的 CSV 文件填充该字典。文件的 URL 为 `https://datasets-documentation.s3.eu-west-3.amazonaws.com/nyc-taxi/taxi_zone_lookup.csv`。 +1. 运行以下 SQL 命令,创建一个名为 `taxi_zone_dictionary` 的字典,并从 S3 中的 CSV 文件填充字典。该文件的 URL 为 `https://datasets-documentation.s3.eu-west-3.amazonaws.com/nyc-taxi/taxi_zone_lookup.csv`。 ```sql CREATE DICTIONARY taxi_zone_dictionary ( @@ -408,22 +409,22 @@ LAYOUT(HASHED_ARRAY()) ``` :::note - 将 `LIFETIME` 设置为 0 禁用自动更新,以避免对我们 S3 存储桶产生不必要的流量。在其他情况下,您可能会以不同的方式进行配置。有关详细信息,请参见 [使用 LIFETIME 刷新字典数据](/sql-reference/dictionaries#refreshing-dictionary-data-using-lifetime)。 + 将 `LIFETIME` 设置为 0 禁用自动更新,以避免不必要的流量到我们的 S3 存储桶。在其他情况下,您可能会以不同方式配置它。有关详细信息,请参见 [使用 LIFETIME 刷新字典数据](/sql-reference/dictionaries#refreshing-dictionary-data-using-lifetime)。 ::: -3. 验证其成功。以下查询应返回 265 行,或每个社区一行: +3. 验证其是否有效。以下应该返回 265 行,每个社区一行: ```sql SELECT * FROM taxi_zone_dictionary ``` -4. 使用 `dictGet` 函数 ([或其变体](./sql-reference/functions/ext-dict-functions.md)) 从字典中检索值。您需要输入字典的名称、所需的值和键(在我们的示例中是 `taxi_zone_dictionary` 的 `LocationID` 列)。 +4. 使用 `dictGet` 函数([或其变体](./sql-reference/functions/ext-dict-functions.md))从字典中检索值。您需要传入字典的名称、您想要的值和键(在我们的示例中是 `taxi_zone_dictionary` 的 `LocationID` 列)。 - 例如,以下查询返回 `LocationID` 为 132 的 `Borough`,对应于 JFK 机场: + 例如,以下查询返回 `LocationID` 为 132 的 `Borough`,该值对应于 JFK 机场: ```sql SELECT dictGet('taxi_zone_dictionary', 'Borough', 132) ``` - JFK 位于皇后区。注意检索值的时间几乎为 0: + JFK 位于皇后区。请注意,检索值的时间几乎为 0: ```response ┌─dictGet('taxi_zone_dictionary', 'Borough', 132)─┐ │ Queens │ @@ -432,7 +433,7 @@ SELECT dictGet('taxi_zone_dictionary', 'Borough', 132) 1 rows in set. Elapsed: 0.004 sec. ``` -5. 使用 `dictHas` 函数查看字典中是否存在键。例如,以下查询返回 `1`(在 ClickHouse 中表示 "true"): +5. 使用 `dictHas` 函数检查字典中是否存在某个键。例如,以下查询返回 `1`(在 ClickHouse 中表示 "true"): ```sql SELECT dictHas('taxi_zone_dictionary', 132) ``` @@ -442,7 +443,7 @@ SELECT dictHas('taxi_zone_dictionary', 132) SELECT dictHas('taxi_zone_dictionary', 4567) ``` -7. 使用 `dictGet` 函数在查询中检索区域名称。例如: +7. 在查询中使用 `dictGet` 函数检索行政区名称。例如: ```sql SELECT count(1) AS total, @@ -453,7 +454,7 @@ GROUP BY borough_name ORDER BY total DESC ``` - 此查询计算结束于拉瓜地亚或 JFK 机场的每个区的出租车行程数量。结果如下所示,请注意有相当多的行程的接客社区未知: + 此查询汇总了在拉瓜迪亚或 JFK 机场结束的每个行政区的出租车数量。结果如下,注意有相当多的行程来自未知接送社区: ```response ┌─total─┬─borough_name──┐ │ 23683 │ Unknown │ @@ -472,7 +473,7 @@ ORDER BY total DESC 编写一些将 `taxi_zone_dictionary` 与您的 `trips` 表连接的查询。 -1. 从一个简单的 `JOIN` 开始,其行为类似于上面的机场查询: +1. 从一个简单的 `JOIN` 开始,其作用类似于上面的机场查询: ```sql SELECT count(1) AS total, @@ -484,7 +485,7 @@ GROUP BY Borough ORDER BY total DESC ``` - 响应与使用 `dictGet` 查询的结果相同: + 响应与前面的 `dictGet` 查询看起来相同: ```response ┌─total─┬─Borough───────┐ │ 7053 │ Manhattan │ @@ -499,10 +500,10 @@ ORDER BY total DESC ``` :::note - 请注意,上述 `JOIN` 查询的输出与使用 `dictGetOrDefault` 的查询具有相同的结果(只是 "未知" 值未包含)。在后台,ClickHouse 实际上为 `taxi_zone_dictionary` 字典调用 `dictGet` 函数,但 `JOIN` 语法对于 SQL 开发人员更加熟悉。 + 请注意,上述 `JOIN` 查询的输出与之前使用 `dictGetOrDefault` 的查询相同(只是不包括 `Unknown` 值)。在后台,ClickHouse 实际上调用 `taxi_zone_dictionary` 字典的 `dictGet` 函数,但 `JOIN` 语法对 SQL 开发人员更为熟悉。 ::: -2. 此查询返回 1000 次最高小费的行程的行,然后将每一行与字典进行内连接: +2. 此查询返回小费金额最高的 1000 次行程的行,随后对每行与字典执行内部连接: ```sql SELECT * FROM trips @@ -513,16 +514,16 @@ ORDER BY tip_amount DESC LIMIT 1000 ``` :::note - 一般来说,我们在 ClickHouse 中较少使用 `SELECT *`。您应仅检索实际需要的列。然而,对于本示例而言,该查询的速度较慢。 + 通常,我们在 ClickHouse 中避免频繁使用 `SELECT *`。您应该仅检索实际需要的列。 ::: -## 后续步骤 {#next-steps} +## 下一步 {#next-steps} -通过以下文档了解更多有关 ClickHouse 的信息: +通过以下文档进一步了解 ClickHouse: -- [ClickHouse 中主索引的介绍](./guides/best-practices/sparse-primary-indexes.md):了解 ClickHouse 如何使用稀疏主索引有效地在查询期间定位相关数据。 +- [ClickHouse 中主索引的介绍](./guides/best-practices/sparse-primary-indexes.md):了解 ClickHouse 如何使用稀疏主索引在查询期间有效定位相关数据。 - [集成外部数据源](/integrations/index.mdx):查看数据源集成选项,包括文件、Kafka、PostgreSQL、数据管道等。 - [在 ClickHouse 中可视化数据](./integrations/data-visualization/index.md):将您最喜欢的 UI/BI 工具连接到 ClickHouse。 - [SQL 参考](./sql-reference/index.md):浏览 ClickHouse 中用于转换、处理和分析数据的 SQL 函数。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/tutorial.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/tutorial.md.hash index 2c91b06a02c..cf1f02b4634 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/tutorial.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/tutorial.md.hash @@ -1 +1 @@ -d455205da1420775 +f21d3e1d2171b9cb diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/AIChat/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/AIChat/index.md new file mode 100644 index 00000000000..f6ee1b539ef --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/AIChat/index.md @@ -0,0 +1,118 @@ +--- +'slug': '/use-cases/AI_ML/AIChat' +'sidebar_label': 'AI 聊天' +'title': '在 ClickHouse Cloud 中使用 AI 聊天' +'pagination_prev': null +'pagination_next': null +'description': '在 ClickHouse Cloud 控制台中启用和使用 AI Chat 功能的指南' +'keywords': +- 'AI' +- 'ClickHouse Cloud' +- 'Chat' +- 'SQL Console' +- 'Agent' +- 'Docs AI' +'show_related_blogs': true +'sidebar_position': 2 +'doc_type': 'guide' +--- + +import Link from '@docusaurus/Link'; +import Image from '@theme/IdealImage'; +import img_open from '@site/static/images/use-cases/AI_ML/AIChat/1_open_chat.png'; +import img_consent from '@site/static/images/use-cases/AI_ML/AIChat/2_consent.png'; +import img_modes from '@site/static/images/use-cases/AI_ML/AIChat/3_modes.png'; +import img_thinking from '@site/static/images/use-cases/AI_ML/AIChat/4_thinking.png'; +import img_history from '@site/static/images/use-cases/AI_ML/AIChat/5_history.png'; +import img_result_actions from '@site/static/images/use-cases/AI_ML/AIChat/6_result_actions.png'; +import img_new_tab from '@site/static/images/use-cases/AI_ML/AIChat/7_open_in_editor.png'; + + +# 在 ClickHouse Cloud 中使用 AI 聊天 + +> 本指南解释了如何在 ClickHouse Cloud 控制台中启用和使用 AI 聊天功能。 + + + +## 前提条件 {#prerequisites} + +1. 你必须拥有访问启用了 AI 功能的 ClickHouse Cloud 组织的权限(如果不可用,请联系你的组织管理员或支持人员)。 + +## 打开 AI 聊天面板 {#open-panel} + +1. 导航到一个 ClickHouse Cloud 服务。 +2. 在左侧边栏中,点击标记为“Ask AI”的闪光图标。 +3. (快捷方式)按 + ' (macOS)或 Ctrl + ' (Linux/Windows)来切换打开。 + + + +## 接受数据使用声明(首次使用) {#consent} + +1. 初次使用时,系统会弹出一个同意对话框,描述数据处理和第三方 LLM 子处理器。 +2. 审核并接受以继续。如果拒绝,面板将不会打开。 + + + +## 选择聊天模式 {#modes} + +AI 聊天当前支持: + +- **Agent**:基于架构 + 元数据的多步骤推理(服务必须处于活动状态)。 +- **Docs AI(询问)**:基于官方 ClickHouse 文档和最佳实践参考的 Q&A。 + +使用弹出框左下角的模式选择器进行切换。 + + + +## 撰写并发送消息 {#compose} + +1. 输入你的问题(例如:“创建一个物化视图以按用户聚合每日事件”)。 +2. 按 Enter 发送消息(使用 Shift + Enter 可插入换行)。 +3. 当模型正在处理时,你可以点击“停止”来中断。 + +## 理解 “Agent” 思考步骤 {#thinking-steps} + +在 Agent 模式下,你可能会看到可展开的中间“思考”或计划步骤。这些步骤提供了助手形成答案的透明度。根据需要折叠或展开。 + + + +## 开始新聊天 {#new-chats} + +点击“新聊天”按钮以清除上下文并开始一个新会话。 + +## 查看聊天记录 {#history} + +1. 下方部分列出了你最近的聊天记录。 +2. 选择先前的聊天以加载其消息。 +3. 使用垃圾桶图标删除对话。 + + + +## 使用生成的 SQL {#sql-actions} + +当助手返回 SQL 时: + +- 检查其正确性。 +- 点击“在编辑器中打开”将查询加载到新的 SQL 标签页中。 +- 在控制台内修改并执行。 + + + + + +## 停止或中断响应 {#interrupt} + +如果响应时间过长或偏离主题: + +1. 点击“停止”按钮(处理时可见)。 +2. 该消息将标记为中断;你可以完善你的提示并重新发送。 + +## 键盘快捷键 {#shortcuts} + +| 操作 | 快捷键 | +| ------ | -------- | +| 打开 AI 聊天 | `⌘ + '` / `Ctrl + '` | +| 发送消息 | `Enter` | +| 新行 | `Shift + Enter` | + + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/AIChat/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/AIChat/index.md.hash new file mode 100644 index 00000000000..e97cc53fa8b --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/AIChat/index.md.hash @@ -0,0 +1 @@ +f90edd20046cf51e diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/01_remote_mcp.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/01_remote_mcp.md new file mode 100644 index 00000000000..57b6529b398 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/01_remote_mcp.md @@ -0,0 +1,99 @@ +--- +'slug': '/use-cases/AI/MCP/remote_mcp' +'sidebar_label': 'ClickHouse Cloud 远程 MCP' +'title': '启用 ClickHouse Cloud 远程 MCP 服务器' +'pagination_prev': null +'pagination_next': null +'description': '本指南解释如何启用和使用 ClickHouse Cloud 远程 MCP' +'keywords': +- 'AI' +- 'ClickHouse Cloud' +- 'MCP' +'show_related_blogs': true +'sidebar_position': 1 +'doc_type': 'guide' +--- + +import {CardHorizontal} from '@clickhouse/click-ui/bundled' +import Link from '@docusaurus/Link'; +import Image from '@theme/IdealImage'; +import img1 from '@site/static/images/use-cases/AI_ML/MCP/1connectmcpmodal.png'; +import img2 from '@site/static/images/use-cases/AI_ML/MCP/2enable_mcp.png'; +import img3 from '@site/static/images/use-cases/AI_ML/MCP/3oauth.png'; +import img4 from '@site/static/images/use-cases/AI_ML/MCP/4oauth_success.png'; +import img5 from '@site/static/images/use-cases/AI_ML/MCP/5connected_mcp_claude.png'; +import img6 from '@site/static/images/use-cases/AI_ML/MCP/6slash_mcp_claude.png'; +import img7 from '@site/static/images/use-cases/AI_ML/MCP/7usage_mcp.png'; + + +# 启用 ClickHouse Cloud 远程 MCP 服务器 + +> 本指南解释了如何启用和使用 ClickHouse Cloud 远程 MCP 服务器。我们将在此示例中使用 Claude Code 作为 MCP 客户端,但可以使用任何支持 MCP 的 LLM 客户端。 + + + +## 为您的 ClickHouse Cloud 服务启用远程 MCP 服务器 {#enable-remote-mcp-server} + +1. 连接到您的 ClickHouse Cloud 服务,点击 `Connect` 按钮,并为您的服务启用远程 MCP 服务器 + + + + + +2. 从 `Connect` 视图或下方复制 ClickHouse Cloud MCP 服务器的 URL + +```bash +https://mcp.clickhouse.cloud/mcp +``` + +## 在 Claude Code 中添加 ClickHouse MCP 服务器 {#add-clickhouse-mcp-server-claude-code} + +1. 在您的工作目录中,运行以下命令,将 ClickHouse Cloud MCP 服务器配置添加到 Claude Code。在此示例中,我们将 Claude Code 配置中的 MCP 服务器命名为 `clickhouse_cloud` + +```bash +claude mcp add --transport http clickhouse_cloud https://mcp.clickhouse.cloud/mcp +``` + +1b. 根据使用的 MCP 客户端,您也可以直接编辑 JSON 配置 + +```json +{ + "mcpServers": { + "clickhouse-remote": { + "url": "https://mcp.clickhouse.cloud/mcp" + } + } +} +``` + +2. 在您的工作目录中启动 Claude Code + +```bash +[user@host ~/Documents/repos/mcp_test] $ claude +``` + +## 通过 OAuth 认证到 ClickHouse Cloud {#authenticate-via-oauth} + +1. Claude Code 在第一次会话中将打开一个浏览器窗口。否则,您也可以通过在 Claude Code 中运行 `/mcp` 命令并选择 `clickhouse_cloud` MCP 服务器来触发连接 + +2. 使用您的 ClickHouse Cloud 凭据进行认证 + + + + + +## 从 Claude Code 使用 ClickHouse Cloud 远程 MCP 服务器 {#use-rempte-mcp-from-claude-code} + +1. 在 Claude Code 中验证远程 MCP 服务器已连接 + + + + + +2. 恭喜!您现在可以从 Claude Code 使用 ClickHouse Cloud 远程 MCP 服务器 + + + +虽然这个示例使用了 Claude Code,但您可以通过遵循类似步骤,使用任何支持 MCP 的 LLM 客户端。 + + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/01_remote_mcp.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/01_remote_mcp.md.hash new file mode 100644 index 00000000000..fe782d6f46d --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/01_remote_mcp.md.hash @@ -0,0 +1 @@ +0580f1cf91eef6d8 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/02_claude-desktop.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/02_claude-desktop.md new file mode 100644 index 00000000000..f1454fb313d --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/02_claude-desktop.md @@ -0,0 +1,124 @@ +--- +'slug': '/use-cases/AI/MCP/claude-desktop' +'sidebar_label': '集成 Claude Desktop' +'title': '设置 ClickHouse MCP 服务器与 Claude Desktop' +'pagination_prev': null +'pagination_next': null +'description': '本指南解释如何将 Claude Desktop 设置为 ClickHouse MCP 服务器。' +'keywords': +- 'AI' +- 'Librechat' +- 'MCP' +'show_related_blogs': true +'doc_type': 'guide' +--- + +import {CardHorizontal} from '@clickhouse/click-ui/bundled' +import Link from '@docusaurus/Link'; +import Image from '@theme/IdealImage'; +import ClaudeDesktopConfig from '@site/static/images/use-cases/AI_ML/MCP/claude-desktop-config.png'; +import FindMCPServers from '@site/static/images/use-cases/AI_ML/MCP/find-mcp-servers.gif'; +import MCPPermission from '@site/static/images/use-cases/AI_ML/MCP/mcp-permission.png'; +import ClaudeConversation from '@site/static/images/use-cases/AI_ML/MCP/claude-conversation.png'; + + +# 使用 ClickHouse MCP 服务器与 Claude Desktop + +> 本指南解释了如何使用 uv 设置 Claude Desktop 与 ClickHouse MCP 服务器并连接到 ClickHouse 示例数据集。 + + + + + +## 安装 uv {#install-uv} + +您需要安装 [uv](https://docs.astral.sh/uv/) 才能按照本指南中的说明进行操作。 +如果您不想使用 uv,则需要更新 MCP 服务器配置以使用其他软件包管理器。 + +## 下载 Claude Desktop {#download-claude-desktop} + +您还需要安装 Claude Desktop 应用程序,可以从 [Claude Desktop 网站](https://claude.ai/desktop) 下载。 + +## 配置 ClickHouse MCP 服务器 {#configure-clickhouse-mcp-server} + +安装好 Claude Desktop 后,接下来是配置 [ClickHouse MCP 服务器](https://github.com/ClickHouse/mcp-clickhouse)。 +我们可以通过 [Claude Desktop 配置文件](https://claude.ai/docs/configuration) 来实现这一点。 + +要找到此文件,首先转到设置页面(在 Mac 上按 `Cmd+,`),然后单击左侧菜单中的 `Developer` 选项卡。 +您将看到以下屏幕,您需要单击 `Edit config` 按钮: + + + +这将带您进入包含配置文件 (`claude_desktop_config.json`) 的目录。 +第一次打开该文件时,它可能包含以下内容: + +```json +{ + "mcpServers": {} +} +``` + +`mcpServers` 字典以 MCP 服务器的名称作为键,以配置选项的字典作为值。 +例如,连接到 ClickHouse Playground 的 ClickHouse MCP 服务器配置如下所示: + +```json +{ + "mcpServers": { + "mcp-clickhouse": { + "command": "uv", + "args": [ + "run", + "--with", + "mcp-clickhouse", + "--python", + "3.10", + "mcp-clickhouse" + ], + "env": { + "CLICKHOUSE_HOST": "sql-clickhouse.clickhouse.com", + "CLICKHOUSE_PORT": "8443", + "CLICKHOUSE_USER": "demo", + "CLICKHOUSE_PASSWORD": "", + "CLICKHOUSE_SECURE": "true", + "CLICKHOUSE_VERIFY": "true", + "CLICKHOUSE_CONNECT_TIMEOUT": "30", + "CLICKHOUSE_SEND_RECEIVE_TIMEOUT": "30" + } + } + } +} +``` + +更新配置后,您需要重启 Claude Desktop 以使更改生效。 + +:::warning +根据您安装 `uv` 的方式,重启 Claude Desktop 时可能会收到以下错误: + +```text +MCP mcp-clickhouse: spawn uv ENOENT +``` + +如果发生这种情况,您需要更新 `command` 以包含 `uv` 的完整路径。例如,如果您是通过 Cargo 安装的,则路径为 `/Users//.cargo/bin/uv` +::: + +## 使用 ClickHouse MCP 服务器 {#using-clickhouse-mcp-server} + +重启 Claude Desktop 后,您可以通过单击 `Search and tools` 图标来找到 ClickHouse MCP 服务器: + + +
+ +您可以选择禁用所有或某些工具。 + +现在我们准备向 Claude 提问,这将导致它使用 ClickHouse MCP 服务器。 +例如,我们可以问它 `SQL playground 中最有趣的数据集是什么?`。 + +Claude 第一次调用 MCP 服务器时会要求我们确认使用每个工具: + + + +下面您可以看到一部分对话,其中包括对 ClickHouse MCP 服务器的一些工具调用: + + + +
diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/02_claude-desktop.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/02_claude-desktop.md.hash new file mode 100644 index 00000000000..3e9083e971b --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/02_claude-desktop.md.hash @@ -0,0 +1 @@ +f08299bb26c3f194 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/03_librechat.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/03_librechat.md new file mode 100644 index 00000000000..79bd14e59ef --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/03_librechat.md @@ -0,0 +1,227 @@ +--- +'slug': '/use-cases/AI/MCP/librechat' +'sidebar_label': '集成 LibreChat' +'title': '使用 Docker 设置 LibreChat 与 ClickHouse MCP 服务器' +'pagination_prev': null +'pagination_next': null +'description': '本指南解释了如何使用 Docker 设置 LibreChat 与 ClickHouse MCP 服务器。' +'keywords': +- 'AI' +- 'Librechat' +- 'MCP' +'show_related_blogs': true +'doc_type': 'guide' +--- + +import {CardHorizontal} from '@clickhouse/click-ui/bundled' +import Link from '@docusaurus/Link'; +import Image from '@theme/IdealImage'; +import LibreInterface from '@site/static/images/use-cases/AI_ML/MCP/librechat.png'; + + +# 使用 ClickHouse MCP 服务器与 LibreChat + +> 本指南解释了如何使用 Docker 设置 LibreChat 和 ClickHouse MCP 服务器,并将其连接到 ClickHouse 示例数据集。 + + + +## 安装 Docker {#install-docker} + +您需要 Docker 来运行 LibreChat 和 MCP 服务器。要获取 Docker: +1. 访问 [docker.com](https://www.docker.com/products/docker-desktop) +2. 下载适用于您的操作系统的 Docker desktop +3. 按照操作系统的说明安装 Docker +4. 打开 Docker Desktop 并确保其正在运行 +
+有关更多信息,请参见 [Docker 文档](https://docs.docker.com/get-docker/)。 + +## 克隆 LibreChat 仓库 {#clone-librechat-repo} + +打开终端(命令提示符、终端或 PowerShell),并使用以下命令克隆 +LibreChat 仓库: + +```bash +git clone https://github.com/danny-avila/LibreChat.git +cd LibreChat +``` + +## 创建并编辑 .env 文件 {#create-and-edit-env-file} + +从 `.env.example` 复制示例配置文件到 `.env`: + +```bash +cp .env.example .env +``` + +在您喜欢的文本编辑器中打开 `.env` 文件。您将看到许多流行 LLM 提供者的部分,包括 OpenAI、Anthropic、AWS bedrock 等,例如: + +```text title=".venv" +#============# + +# Anthropic # +#============# +#highlight-next-line +ANTHROPIC_API_KEY=user_provided + +# ANTHROPIC_MODELS=claude-opus-4-20250514,claude-sonnet-4-20250514,claude-3-7-sonnet-20250219,claude-3-5-sonnet-20241022,claude-3-5-haiku-20241022,claude-3-opus-20240229,claude-3-sonnet-20240229,claude-3-haiku-20240307 + +# ANTHROPIC_REVERSE_PROXY= +``` + +用您的 LLM 提供者的 API 密钥替换 `user_provided`。 + +:::note 使用本地 LLM +如果您没有 API 密钥,可以使用本地 LLM,例如 Ollama。稍后您将看到如何执行此操作,步骤为 ["安装 Ollama"](#add-local-llm-using-ollama)。现在不要修改 .env 文件,继续下一步。 +::: + +## 创建一个 librechat.yaml 文件 {#create-librechat-yaml-file} + +运行以下命令来创建一个新的 `librechat.yaml` 文件: + +```bash +cp librechat.example.yaml librechat.yaml +``` + +这创建了 LibreChat 的主要 [配置文件](https://www.librechat.ai/docs/configuration/librechat_yaml)。 + +## 将 ClickHouse MCP 服务器添加到 Docker compose {#add-clickhouse-mcp-server-to-docker-compose} + +接下来,我们将 ClickHouse MCP 服务器添加到 LibreChat Docker compose 文件中,以便 LLM 可以与 +[ClickHouse SQL playground](https://sql.clickhouse.com/) 进行交互。 + +创建一个名为 `docker-compose.override.yml` 的文件,并将以下配置添加到其中: + +```yml title="docker-compose.override.yml" +services: + api: + volumes: + - ./librechat.yaml:/app/librechat.yaml + mcp-clickhouse: + image: mcp/clickhouse + container_name: mcp-clickhouse + ports: + - 8001:8000 + extra_hosts: + - "host.docker.internal:host-gateway" + environment: + - CLICKHOUSE_HOST=sql-clickhouse.clickhouse.com + - CLICKHOUSE_USER=demo + - CLICKHOUSE_PASSWORD= + - CLICKHOUSE_MCP_SERVER_TRANSPORT=sse + - CLICKHOUSE_MCP_BIND_HOST=0.0.0.0 +``` + +如果您想探索自己的数据,可以使用 +[您自己的 ClickHouse Cloud 服务的主机、用户名和密码](https://clickhouse.com/docs/getting-started/quick-start/cloud#connect-with-your-app)。 + + + + + +## 在 librechat.yaml 中配置 MCP 服务器 {#configure-mcp-server-in-librechat-yaml} + +打开 `librechat.yaml` 并在文件末尾放置以下配置: + +```yml +mcpServers: + clickhouse-playground: + type: sse + url: http://host.docker.internal:8001/sse +``` + +这将配置 LibreChat 连接到运行在 Docker 上的 MCP 服务器。 + +找到以下行: + +```text title="librechat.yaml" +socialLogins: ['github', 'google', 'discord', 'openid', 'facebook', 'apple', 'saml'] +``` + +为了简化起见,我们暂时移除身份验证的要求: + +```text title="librechat.yaml" +socialLogins: [] +``` + +## 使用 Ollama 添加本地 LLM(可选) {#add-local-llm-using-ollama} + +### 安装 Ollama {#install-ollama} + +访问 [Ollama 网站](https://ollama.com/download),并为您的系统安装 Ollama。 + +安装完成后,您可以这样运行一个模型: + +```bash +ollama run qwen3:32b +``` + +如果模型尚不存在,这将把模型拉取到您的本地机器。 + +有关模型的列表,请参见 [Ollama library](https://ollama.com/library)。 + +### 在 librechat.yaml 中配置 Ollama {#configure-ollama-in-librechat-yaml} + +一旦模型下载完成,在 `librechat.yaml` 中配置它: + +```text title="librechat.yaml" +custom: + - name: "Ollama" + apiKey: "ollama" + baseURL: "http://host.docker.internal:11434/v1/" + models: + default: + [ + "qwen3:32b" + ] + fetch: false + titleConvo: true + titleModel: "current_model" + summarize: false + summaryModel: "current_model" + forcePrompt: false + modelDisplayLabel: "Ollama" +``` + +## 启动所有服务 {#start-all-services} + +在 LibreChat 项目文件的根目录中,运行以下命令以启动服务: + +```bash +docker compose up +``` + +等待所有服务完全运行。 + +## 在浏览器中打开 LibreChat {#open-librechat-in-browser} + +一旦所有服务都已启动并运行,打开浏览器并访问 `http://localhost:3080/` + +如果您还没有账户,请创建一个免费的 LibreChat 账户并登录。您现在应该 +看到连接到 ClickHouse MCP 服务器的 LibreChat 界面,另外,还可以连接您的本地 LLM。 + +在聊天界面中,选择 `clickhouse-playground` 作为您的 MCP 服务器: + + + +您现在可以提示 LLM 探索 ClickHouse 示例数据集。试试吧: + +```text title="Prompt" +What datasets do you have access to? +``` + +
diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/03_librechat.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/03_librechat.md.hash new file mode 100644 index 00000000000..fd338e649bb --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/03_librechat.md.hash @@ -0,0 +1 @@ +05b23057acf13ed1 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/04_anythingllm.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/04_anythingllm.md new file mode 100644 index 00000000000..c2557c55c90 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/04_anythingllm.md @@ -0,0 +1,127 @@ +--- +'slug': '/use-cases/AI/MCP/anythingllm' +'sidebar_label': '集成 AnythingLLM' +'title': '设置 ClickHouse MCP 服务器与 AnythingLLM 和 ClickHouse Cloud' +'pagination_prev': null +'pagination_next': null +'description': '本指南解释了如何使用 Docker 设置 AnythingLLM 与 ClickHouse MCP 服务器。' +'keywords': +- 'AI' +- 'AnythingLLM' +- 'MCP' +'show_related_blogs': true +'doc_type': 'guide' +--- + +import {CardHorizontal} from '@clickhouse/click-ui/bundled' +import Link from '@docusaurus/Link'; +import Image from '@theme/IdealImage'; +import Conversation from '@site/static/images/use-cases/AI_ML/MCP/allm_conversation.png'; +import MCPServers from '@site/static/images/use-cases/AI_ML/MCP/allm_mcp-servers.png'; +import ToolIcon from '@site/static/images/use-cases/AI_ML/MCP/alm_tool-icon.png'; + + +# 使用 ClickHouse MCP 服务器与 AnythingLLM + +> 本指南说明如何使用 Docker 设置 [AnythingLLM](https://anythingllm.com/) 与 ClickHouse MCP 服务器,并将其连接到 ClickHouse 示例数据集。 + + + +## 安装 Docker {#install-docker} + +您需要 Docker 才能运行 LibreChat 和 MCP 服务器。获取 Docker 的步骤如下: +1. 访问 [docker.com](https://www.docker.com/products/docker-desktop) +2. 下载适合您操作系统的 Docker desktop +3. 按照您操作系统的说明安装 Docker +4. 打开 Docker Desktop 并确保其正在运行 +
+有关更多信息,请参见 [Docker 文档](https://docs.docker.com/get-docker/)。 + +## 拉取 AnythingLLM Docker 镜像 {#pull-anythingllm-docker-image} + +运行以下命令,将 AnythingLLM Docker 镜像拉取到您的计算机上: + +```bash +docker pull anythingllm/anythingllm +``` + +## 设置存储位置 {#setup-storage-location} + +创建用于存储的目录并初始化环境文件: + +```bash +export STORAGE_LOCATION=$PWD/anythingllm && \ +mkdir -p $STORAGE_LOCATION && \ +touch "$STORAGE_LOCATION/.env" +``` + +## 配置 MCP 服务器配置文件 {#configure-mcp-server-config-file} + +创建 `plugins` 目录: + +```bash +mkdir -p "$STORAGE_LOCATION/plugins" +``` + +在 `plugins` 目录中创建名为 `anythingllm_mcp_servers.json` 的文件,并添加以下内容: + +```json +{ + "mcpServers": { + "mcp-clickhouse": { + "command": "uv", + "args": [ + "run", + "--with", + "mcp-clickhouse", + "--python", + "3.10", + "mcp-clickhouse" + ], + "env": { + "CLICKHOUSE_HOST": "sql-clickhouse.clickhouse.com", + "CLICKHOUSE_USER": "demo", + "CLICKHOUSE_PASSWORD": "" + } + } + } +} +``` + +如果您想要浏览自己的数据,可以使用您自己的 ClickHouse Cloud 服务的 [主机、用户名和密码](https://clickhouse.com/docs/getting-started/quick-start/cloud#connect-with-your-app) 进行操作。 + +## 启动 AnythingLLM Docker 容器 {#start-anythingllm-docker-container} + +运行以下命令以启动 AnythingLLM Docker 容器: + +```bash +docker run -p 3001:3001 \ +--cap-add SYS_ADMIN \ +-v ${STORAGE_LOCATION}:/app/server/storage \ +-v ${STORAGE_LOCATION}/.env:/app/server/.env \ +-e STORAGE_DIR="/app/server/storage" \ +mintplexlabs/anythingllm +``` + +一旦启动,您可以在浏览器中导航到 `http://localhost:3001`。 +选择您要使用的模型并提供您的 API 密钥。 + +## 等待 MCP 服务器启动 {#wait-for-mcp-servers-to-start-up} + +点击用户界面左下角的工具图标: + + + +点击 `Agent Skills`,并查看 `MCP Servers` 部分。 +等待直到您看到 `Mcp ClickHouse` 设置为 `On` + + + +## 使用 AnythingLLM 聊天 ClickHouse MCP 服务器 {#chat-with-clickhouse-mcp-server-with-anythingllm} + +现在我们准备开始聊天。 +要使 MCP 服务器可用于聊天,您需要在对话的第一条消息前加上 `@agent` 前缀。 + + + +
diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/04_anythingllm.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/04_anythingllm.md.hash new file mode 100644 index 00000000000..401778e6f2a --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/04_anythingllm.md.hash @@ -0,0 +1 @@ +991db4d0ec8e35ee diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/05_open-webui.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/05_open-webui.md new file mode 100644 index 00000000000..60fde6d3e43 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/05_open-webui.md @@ -0,0 +1,111 @@ +--- +'slug': '/use-cases/AI/MCP/open-webui' +'sidebar_label': '集成 Open WebUI' +'title': '使用 Open WebUI 和 ClickHouse Cloud 设置 ClickHouse MCP 服务器' +'pagination_prev': null +'pagination_next': null +'description': '本指南解释了如何使用 Docker 设置 Open WebUI 和 ClickHouse MCP 服务器。' +'keywords': +- 'AI' +- 'Open WebUI' +- 'MCP' +'show_related_blogs': true +'doc_type': 'guide' +--- + +import {CardHorizontal} from '@clickhouse/click-ui/bundled' +import Link from '@docusaurus/Link'; +import Image from '@theme/IdealImage'; +import Endpoints from '@site/static/images/use-cases/AI_ML/MCP/0_endpoints.png'; +import Settings from '@site/static/images/use-cases/AI_ML/MCP/1_settings.png'; +import ToolsPage from '@site/static/images/use-cases/AI_ML/MCP/2_tools_page.png'; +import AddTool from '@site/static/images/use-cases/AI_ML/MCP/3_add_tool.png'; +import ToolsAvailable from '@site/static/images/use-cases/AI_ML/MCP/4_tools_available.png'; +import ListOfTools from '@site/static/images/use-cases/AI_ML/MCP/5_list_of_tools.png'; +import Connections from '@site/static/images/use-cases/AI_ML/MCP/6_connections.png'; +import AddConnection from '@site/static/images/use-cases/AI_ML/MCP/7_add_connection.png'; +import OpenAIModels from '@site/static/images/use-cases/AI_ML/MCP/8_openai_models_more.png'; +import Conversation from '@site/static/images/use-cases/AI_ML/MCP/9_conversation.png'; + + +# 使用 ClickHouse MCP 服务器与 Open WebUI + +> 本指南解释了如何设置 [Open WebUI](https://github.com/open-webui/open-webui) 与 ClickHouse MCP 服务器,并将其连接到 ClickHouse 示例数据集。 + + + +## 安装 uv {#install-uv} + +您需要安装 [uv](https://docs.astral.sh/uv/) 来按照本指南中的说明进行操作。如果您不想使用 uv,则需要更新 MCP Server 配置以使用替代的包管理器。 + +## 启动 Open WebUI {#launch-open-webui} + +要启动 Open WebUI,您可以运行以下命令: + +```bash +uv run --with open-webui open-webui serve +``` + +导航到 http://localhost:8080/ 以查看 UI。 + +## 配置 ClickHouse MCP 服务器 {#configure-clickhouse-mcp-server} + +要设置 ClickHouse MCP 服务器,我们需要将 MCP 服务器转换为 Open API 端点。首先,让我们设置环境变量,以便我们可以连接到 ClickHouse SQL Playground: + +```bash +export CLICKHOUSE_HOST="sql-clickhouse.clickhouse.com" +export CLICKHOUSE_USER="demo" +export CLICKHOUSE_PASSWORD="" +``` + +然后,我们可以运行 `mcpo` 以创建 Open API 端点: + +```bash +uvx mcpo --port 8000 -- uv run --with mcp-clickhouse --python 3.10 mcp-clickhouse +``` + +您可以通过导航到 http://localhost:8000/docs 查看创建的端点列表。 + + + +要在 Open WebUI 中使用这些端点,我们需要导航到设置: + + + +点击 `Tools`: + + + +添加 http://localhost:8000 作为工具 URL: + + + +完成此操作后,我们应该在聊天栏的工具图标旁边看到 `1`: + + + +如果我们点击工具图标,就可以列出可用的工具: + + + +## 配置 OpenAI {#configure-openai} + +默认情况下,Open WebUI 与 Ollama 模型一起工作,但我们也可以添加与 OpenAI 兼容的端点。这些通过设置菜单进行配置,但这次我们需要点击 `Connections` 选项卡: + + + +让我们添加端点和我们的 OpenAI 密钥: + + + +然后,OpenAI 模型将在顶部菜单中可用: + + + +## 与 ClickHouse MCP 服务器进行聊天 {#chat-to-clickhouse-mcp-server} + +然后,我们可以进行对话,Open WebUI 在必要时将调用 MCP 服务器: + + + + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/05_open-webui.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/05_open-webui.md.hash new file mode 100644 index 00000000000..db3c1f90bc0 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/05_open-webui.md.hash @@ -0,0 +1 @@ +3b2c383ce62a19f7 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/06_ollama.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/06_ollama.md new file mode 100644 index 00000000000..cda12b5ad41 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/06_ollama.md @@ -0,0 +1,226 @@ +--- +'slug': '/use-cases/AI/MCP/ollama' +'sidebar_label': '集成 Ollama' +'title': '设置 ClickHouse MCP 服务器与 Ollama' +'pagination_prev': null +'pagination_next': null +'description': '本指南解释如何与 ClickHouse MCP 服务器设置 Ollama。' +'keywords': +- 'AI' +- 'Ollama' +- 'MCP' +'show_related_blogs': true +'doc_type': 'guide' +--- + +import {CardHorizontal} from '@clickhouse/click-ui/bundled' +import Link from '@docusaurus/Link'; +import Image from '@theme/IdealImage'; + + +# 使用 ClickHouse MCP 服务器与 Ollama + +> 本指南解释了如何将 ClickHouse MCP 服务器与 Ollama 一起使用。 + + + +## 安装 Ollama {#install-ollama} + +Ollama 是一个在您自己的机器上运行大型语言模型(LLMs)的库。 +它提供了 [丰富的模型可供选择](https://ollama.com/library),易于使用。 + +您可以从 [下载页面](https://ollama.com/download) 下载适用于 Mac、Windows 或 Linux 的 Ollama。 + +一旦运行 Ollama,它将在后台启动一个本地服务器,您可以用来运行模型。 +或者,您也可以通过运行 `ollama serve` 手动启动服务器。 + +安装完成后,您可以像这样将模型下载到您的机器: + +```bash +ollama pull qwen3:8b +``` + +如果该模型未在本地,则会将其下载到您的本地机器。 +下载完成后,您可以像这样运行该模型: + +```bash +ollama run qwen3:8b +``` + +:::note +只有 [支持工具的模型](https://ollama.com/search?c=tools) 才能与 MCP 服务器配合使用。 +::: + +我们可以像这样列出我们下载的模型: + +```bash +ollama ls +``` + +```text +NAME ID SIZE MODIFIED +qwen3:latest 500a1f067a9f 5.2 GB 3 days ago +``` + +我们可以使用以下命令查看有关我们下载的模型的更多信息: + +```bash +ollama show qwen3 +``` + +```text +Model + architecture qwen3 + parameters 8.2B + context length 40960 + embedding length 4096 + quantization Q4_K_M + +Capabilities + completion + tools + +Parameters + repeat_penalty 1 + stop "<|im_start|>" + stop "<|im_end|>" + temperature 0.6 + top_k 20 + top_p 0.95 + +License + Apache License + Version 2.0, January 2004 +``` + +从该输出中,我们可以看到默认的 qwen3 模型有超过 80 亿个参数。 + +## 安装 MCPHost {#install-mcphost} + +在写作时(2025年7月),没有原生功能可让 Ollama 与 MCP 服务器一起使用。 +不过,我们可以使用 [MCPHost](https://github.com/mark3labs/mcphost) 来让 Ollama 模型与 MCP 服务器一起运行。 + +MCPHost 是一个 Go 应用程序,因此您需要确保在您的机器上 [安装 Go](https://go.dev/doc/install)。 +然后,您可以通过运行以下命令安装 MCPHost: + +```bash +go install github.com/mark3labs/mcphost@latest +``` + +该二进制文件将安装在 `~/go/bin` 目录下,因此我们需要确保该目录在我们的路径中。 + +## 配置 ClickHouse MCP 服务器 {#configure-clickhouse-mcp-server} + +我们可以在 YAML 或 JSON 文件中使用 MCPHost 配置 MCP 服务器。 +MCPHost 将按照以下顺序在您的家目录中查找配置文件: + +1. `.mcphost.yml` 或 `.mcphost.json` (优先) +2. `.mcp.yml` 或 `.mcp.json` (向后兼容性) + +它使用的语法类似于标准 MCP 配置文件中的语法。 +以下是一个 ClickHouse MCP 服务器配置的示例,我们将其保存到 `~/.mcphost.json` 文件中: + +```json +{ + "mcpServers": { + "mcp-ch": { + "type": "local", + "command": ["uv", + "run", + "--with", + "mcp-clickhouse", + "--python", + "3.10", + "mcp-clickhouse" + ] + } + } +} +``` + +与标准 MCP 配置文件的主要区别在于,我们需要指定一个 `type`。 +该类型用于指示 MCP 服务器使用的传输类型。 + +* `local` → 标准输入输出传输 +* `remote` → 可流传输 +* `builtin` → 内部过程传输 + +我们还需要配置以下环境变量: + +```bash +export CLICKHOUSE_HOST=sql-clickhouse.clickhouse.com +export CLICKHOUSE_USER=demo +export CLICKHOUSE_PASSWORD="" +``` + +:::note +理论上,您应该能够在 MCP 配置文件的 `environment` 键下提供这些变量,但我们发现这样做不起作用。 +::: + +## 运行 MCPHost {#running-mcphost} + +配置好 ClickHouse MCP 服务器后,您可以通过运行以下命令运行 MCPHost: + +```bash +mcphost --model ollama:qwen3 +``` + +或者,如果您想使用特定的配置文件: + +```bash +mcphost --model ollama:qwen3 --config ~/.mcphost.json +``` + +:::warning +如果您不提供 `--model`,MCPHost 将在环境变量中查找 `ANTHROPIC_API_KEY`,并将使用 `anthropic:claude-sonnet-4-20250514` 模型。 +::: + +我们应该看到以下输出: + +```text +┃ ┃ +┃ Model loaded: ollama (qwen3) ┃ +┃ MCPHost System (09:52) ┃ +┃ ┃ + +┃ ┃ +┃ Model loaded successfully on GPU ┃ +┃ MCPHost System (09:52) ┃ +┃ ┃ + +┃ ┃ +┃ Loaded 3 tools from MCP servers ┃ +┃ MCPHost System (09:52) ┃ +┃ ┃ + +Enter your prompt (Type /help for commands, Ctrl+C to quit, ESC to cancel generation) +``` + +我们可以使用 `/servers` 命令列出 MCP 服务器: + +```text +┃ ┃ +┃ ## Configured MCP Servers ┃ +┃ ┃ +┃ 1. mcp-ch ┃ +┃ MCPHost System (10:00) ┃ +┃ +``` + +使用 `/tools` 列出可用的工具: + +```text +┃ ## Available Tools ┃ +┃ ┃ +┃ 1. mcp-ch__list_databases ┃ +┃ 2. mcp-ch__list_tables ┃ +┃ 3. mcp-ch__run_select_query +``` + +然后,我们可以向模型提出有关 ClickHouse SQL 演示环境中可用数据库/表的问题。 + +根据我们的经验,当使用较小的模型时(默认的 qwen3 模型有 80 亿个参数),您需要更具体地说明希望它执行的操作。 +例如,您需要明确要求它列出数据库和表,而不是直接要求它查询某个表。 +您可以通过使用大型模型(例如 qwen3:14b)来部分缓解此问题,但在消费类硬件上运行速度较慢。 + + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/06_ollama.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/06_ollama.md.hash new file mode 100644 index 00000000000..7a8c9a1deb1 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/06_ollama.md.hash @@ -0,0 +1 @@ +ad379b43124bc544 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/07_janai.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/07_janai.md new file mode 100644 index 00000000000..53cc5b4f922 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/07_janai.md @@ -0,0 +1,107 @@ +--- +'slug': '/use-cases/AI/MCP/janai' +'sidebar_label': '集成 Jan.ai' +'title': '设置 ClickHouse MCP 服务器与 Jan.ai' +'pagination_prev': null +'pagination_next': null +'description': '本指南解释了如何与 ClickHouse MCP 服务器设置 Jan.ai。' +'keywords': +- 'AI' +- 'Jan.ai' +- 'MCP' +'show_related_blogs': true +'doc_type': 'guide' +--- + +import {CardHorizontal} from '@clickhouse/click-ui/bundled' +import Link from '@docusaurus/Link'; +import Image from '@theme/IdealImage'; +import OpenAIModels from '@site/static/images/use-cases/AI_ML/MCP/0_janai_openai.png'; +import MCPServers from '@site/static/images/use-cases/AI_ML/MCP/1_janai_mcp_servers.png'; +import MCPServersList from '@site/static/images/use-cases/AI_ML/MCP/2_janai_mcp_servers_list.png'; +import MCPForm from '@site/static/images/use-cases/AI_ML/MCP/3_janai_add_mcp_server.png'; +import MCPEnabled from '@site/static/images/use-cases/AI_ML/MCP/4_janai_toggle.png'; +import MCPTool from '@site/static/images/use-cases/AI_ML/MCP/5_jani_tools.png'; +import Question from '@site/static/images/use-cases/AI_ML/MCP/6_janai_question.png'; +import MCPToolConfirm from '@site/static/images/use-cases/AI_ML/MCP/7_janai_tool_confirmation.png'; + +```jsx +import ToolsCalled from '@site/static/images/use-cases/AI_ML/MCP/8_janai_tools_called.png'; +import ToolsCalledExpanded from '@site/static/images/use-cases/AI_ML/MCP/9_janai_tools_called_expanded.png'; +import Result from '@site/static/images/use-cases/AI_ML/MCP/10_janai_result.png'; + + +# 使用 ClickHouse MCP 服务器与 Jan.ai + +> 本指南解释了如何将 ClickHouse MCP 服务器与 [Jan.ai](https://jan.ai/docs) 一起使用。 + + + +## 安装 Jan.ai {#install-janai} + +Jan.ai 是一个开源的 ChatGPT 替代品,支持 100% 离线运行。 +您可以为 [Mac](https://jan.ai/docs/desktop/mac)、[Windows](https://jan.ai/docs/desktop/windows) 或 [Linux](https://jan.ai/docs/desktop/linux) 下载 Jan.ai。 + +它是一个原生应用,因此下载后可以直接启动。 + +## 将 LLM 添加到 Jan.ai {#add-llm-to-janai} + +我们可以通过设置菜单启用模型。 + +要启用 OpenAI,我们需要提供一个 API 密钥,如下所示: + + + +## 启用 MCP 服务器 {#enable-mcp-servers} + +在撰写本文时,MCP 服务器是 Jan.ai 中的一项实验性功能。 +我们可以通过切换实验性功能来启用它们: + + + +一旦按下该切换开关,我们将在左侧菜单上看到 `MCP Servers`。 + +## 配置 ClickHouse MCP 服务器 {#configure-clickhouse-mcp-server} + +如果我们点击 `MCP Servers` 菜单,我们将看到可以连接到的 MCP 服务器列表: + + + +这些服务器默认都是禁用的,但我们可以通过点击切换开关来启用它们。 + +要安装 ClickHouse MCP 服务器,我们需要点击 `+` 图标,然后用以下信息填充表单: + + + +完成后,如果 ClickHouse 服务器尚未切换开启,我们需要切换它: + + + +ClickHouse MCP 服务器的工具现在将会在聊天对话框中可见: + + + +## 使用 Jan.ai 与 ClickHouse MCP 服务器聊天 {#chat-to-clickhouse-mcp-server} + +现在是时候讨论存储在 ClickHouse 中的一些数据了! +让我们提一个问题: + + + +Jan.ai将在调用工具之前要求确认: + + + +然后它将向我们显示已进行的工具调用列表: + + + +如果我们点击工具调用,我们可以查看调用的详细信息: + + + +然后在下面,我们会看到我们的结果: + + + + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/07_janai.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/07_janai.md.hash new file mode 100644 index 00000000000..156a8566a09 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/07_janai.md.hash @@ -0,0 +1 @@ +a8f17266302c1232 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/_category_.json b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/_category_.json new file mode 100644 index 00000000000..7d016b2974b --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/_category_.json @@ -0,0 +1,10 @@ +{ + "position": 5, + "label": "Integrate AI agent libraries", + "collapsible": true, + "collapsed": true, + "link": { + "type": "doc", + "id": "use-cases/AI_ML/MCP/ai_agent_libraries/index" + } +} diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/agno.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/agno.md new file mode 100644 index 00000000000..6d256eee573 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/agno.md @@ -0,0 +1,142 @@ +--- +'slug': '/use-cases/AI/MCP/ai-agent-libraries/agno' +'sidebar_label': '集成 Agno' +'title': '如何使用 Agno 和 ClickHouse MCP 服务器构建 AI Agent' +'pagination_prev': null +'pagination_next': null +'description': '学习如何使用 Agno 和 ClickHouse MCP 服务器构建 AI Agent' +'keywords': +- 'ClickHouse' +- 'MCP' +- 'Agno' +'show_related_blogs': true +'doc_type': 'guide' +--- + + +# 如何使用 Agno 和 ClickHouse MCP 服务器构建 AI Agent + +在本指南中,您将学习如何构建一个可以与 [ClickHouse 的 SQL 游乐场](https://sql.clickhouse.com/) 进行交互的 [Agno](https://github.com/agno-agi/agno) AI 代理,使用 [ClickHouse 的 MCP 服务器](https://github.com/ClickHouse/mcp-clickhouse)。 + +:::note 示例笔记本 +此示例可以在 [示例仓库](https://github.com/ClickHouse/examples/blob/main/ai/mcp/agno/agno.ipynb) 中找到作为笔记本。 +::: + +## 前提条件 {#prerequisites} +- 您需要在系统上安装 Python。 +- 您需要在系统上安装 `pip`。 +- 您需要一个 Anthropic API 密钥,或来自其他 LLM 提供商的 API 密钥。 + +您可以从 Python REPL 或通过脚本运行以下步骤。 + + + +## 安装库 {#install-libraries} + +通过运行以下命令安装 Agno 库: + +```python +!pip install -q --upgrade pip +!pip install -q agno +!pip install -q ipywidgets +``` + +## 设置凭据 {#setup-credentials} + +接下来,您需要提供您的 Anthropic API 密钥: + +```python +import os, getpass +os.environ["ANTHROPIC_API_KEY"] = getpass.getpass("Enter Anthropic API Key:") +``` + +```response title="Response" +Enter Anthropic API Key: ········ +``` + +:::note 使用其他 LLM 提供商 +如果您没有 Anthropic API 密钥,并希望使用其他 LLM 提供商, +您可以在 [DSPy 文档](https://dspy.ai/#__tabbed_1_1) 中找到设置凭据的说明。 +::: + +接下来,定义连接到 ClickHouse SQL 游乐场所需的凭据: + +```python +env = { + "CLICKHOUSE_HOST": "sql-clickhouse.clickhouse.com", + "CLICKHOUSE_PORT": "8443", + "CLICKHOUSE_USER": "demo", + "CLICKHOUSE_PASSWORD": "", + "CLICKHOUSE_SECURE": "true" +} +``` + +## 初始化 MCP 服务器和 Agno 代理 {#initialize-mcp-and-agent} + +现在将 ClickHouse MCP 服务器配置为指向 ClickHouse SQL 游乐场,并初始化我们的 Agno 代理并向其提问: + +```python +from agno.agent import Agent +from agno.tools.mcp import MCPTools +from agno.models.anthropic import Claude +``` + +```python +async with MCPTools(command="uv run --with mcp-clickhouse --python 3.13 mcp-clickhouse", env=env, timeout_seconds=60) as mcp_tools: + agent = Agent( + model=Claude(id="claude-3-5-sonnet-20240620"), + markdown=True, + tools = [mcp_tools] + ) +await agent.aprint_response("What's the most starred project in 2025?", stream=True) +``` + +```response title="Response" +▰▱▱▱▱▱▱ Thinking... +┏━ Message ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ +┃ ┃ +┃ What's the most starred project in 2025? ┃ +┃ ┃ +┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ +┏━ Tool Calls ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ +┃ ┃ +┃ • list_tables(database=github, like=%) ┃ +┃ • run_select_query(query=SELECT ┃ +┃ repo_name, ┃ +┃ SUM(count) AS stars_2025 ┃ +┃ FROM github.repo_events_per_day ┃ +┃ WHERE event_type = 'WatchEvent' ┃ +┃ AND created_at >= '2025-01-01' ┃ +┃ AND created_at < '2026-01-01' ┃ +┃ GROUP BY repo_name ┃ +┃ ORDER BY stars_2025 DESC ┃ +┃ LIMIT 1) ┃ +┃ ┃ +┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ +┏━ Response (34.9s) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ +┃ ┃ +┃ To answer your question about the most starred project in 2025, I'll need to query the ClickHouse database. ┃ +┃ However, before I can do that, I need to gather some information and make sure we're looking at the right data. ┃ +┃ Let me check the available databases and tables first.Thank you for providing the list of databases. I can see ┃ +┃ that there's a "github" database, which is likely to contain the information we're looking for. Let's check the ┃ +┃ tables in this database.Now that we have information about the tables in the github database, we can query the ┃ +┃ relevant data to answer your question about the most starred project in 2025. We'll use the repo_events_per_day ┃ +┃ table, which contains daily event counts for each repository, including star events (WatchEvents). ┃ +┃ ┃ +┃ Let's create a query to find the most starred project in 2025:Based on the query results, I can answer your ┃ +┃ question about the most starred project in 2025: ┃ +┃ ┃ +┃ The most starred project in 2025 was deepseek-ai/DeepSeek-R1, which received 84,962 stars during that year. ┃ +┃ ┃ +┃ This project, DeepSeek-R1, appears to be an AI-related repository from the DeepSeek AI organization. It gained ┃ +┃ significant attention and popularity among the GitHub community in 2025, earning the highest number of stars ┃ +┃ for any project during that year. ┃ +┃ ┃ +┃ It's worth noting that this data is based on the GitHub events recorded in the database, and it represents the ┃ +┃ stars (WatchEvents) accumulated specifically during the year 2025. The total number of stars for this project ┃ +┃ might be higher if we consider its entire lifespan. ┃ +┃ ┃ +┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ +``` + + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/agno.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/agno.md.hash new file mode 100644 index 00000000000..fa907b10e7f --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/agno.md.hash @@ -0,0 +1 @@ +b7cdc30f9a54b4ed diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/chainlit.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/chainlit.md new file mode 100644 index 00000000000..0b389be12ce --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/chainlit.md @@ -0,0 +1,70 @@ +--- +'slug': '/use-cases/AI/MCP/ai-agent-libraries/chainlit' +'sidebar_label': '集成 Chainlit' +'title': '如何使用 Chainlit 和 ClickHouse MCP 服务器构建 AI 代理' +'pagination_prev': null +'pagination_next': null +'description': '学习如何使用 Chainlit 与 ClickHouse MCP 服务器一起构建基于 LLM 的聊天应用' +'keywords': +- 'ClickHouse' +- 'MCP' +- 'Chainlit' +'show_related_blogs': true +'doc_type': 'guide' +--- + + +# 如何使用 Chainlit 和 ClickHouse MCP 服务器构建 AI 代理 + +本指南探讨如何将 Chainlit 强大的聊天界面框架与 ClickHouse 模型上下文协议 (MCP) 服务器相结合,以创建交互式数据应用程序。Chainlit 使您能够以最少的代码构建 AI 应用程序的对话接口,而 ClickHouse MCP 服务器则提供与 ClickHouse 高性能列式数据库的无缝集成。 + +## 前提条件 {#prerequisites} +- 您需要一个 Anthropic API 密钥 +- 您需要安装 [`uv`](https://docs.astral.sh/uv/getting-started/installation/) + +## 基本 Chainlit 应用 {#basic-chainlit-app} + +您可以通过运行以下代码查看基本聊天应用的示例: + +```sh +uv run --with anthropic --with chainlit chainlit run chat_basic.py -w -h +``` + +然后导航到 `http://localhost:8000` + +## 添加 ClickHouse MCP 服务器 {#adding-clickhouse-mcp-server} + +如果我们添加 ClickHouse MCP 服务器,事情会变得更加有趣。 +您需要更新 `.chainlit/config.toml` 文件,以允许使用 `uv` 命令: + +```toml +[features.mcp.stdio] + enabled = true + # Only the executables in the allow list can be used for MCP stdio server. + # Only need the base name of the executable, e.g. "npx", not "/usr/bin/npx". + # Please don't comment this line for now, we need it to parse the executable name. + allowed_executables = [ "npx", "uvx", "uv" ] +``` + +:::note config.toml +在 [examples repository](https://github.com/ClickHouse/examples/blob/main/ai/mcp/chainlit/.chainlit/config.toml) 中找到完整的 `config.toml` 文件 +::: + +有一些粘合代码可以使 MCP 服务器与 Chainlit 一起运行,因此我们需要运行以下命令来启动 Chainlit: + +```sh +uv run --with anthropic --with chainlit chainlit run chat_mcp.py -w -h +``` + +要添加 MCP 服务器,请单击聊天界面中的插件图标,然后添加以下命令以连接使用 ClickHouse SQL Playground: + +```sh +CLICKHOUSE_HOST=sql-clickhouse.clickhouse.com CLICKHOUSE_USER=demo CLICKHOUSE_PASSWORD= CLICKHOUSE_SECURE=true uv run --with mcp-clickhouse --python 3.13 mcp-clickhouse +``` + +如果您想使用自己的 ClickHouse 实例,可以调整环境变量的值。 + +然后您可以像这样向它提问: + +* 告诉我您可以查询的表 +* 关于纽约出租车的有趣事情是什么? diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/chainlit.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/chainlit.md.hash new file mode 100644 index 00000000000..604a19c657c --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/chainlit.md.hash @@ -0,0 +1 @@ +8dd2e099cb2e3308 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/copilotkit.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/copilotkit.md new file mode 100644 index 00000000000..0233fd89037 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/copilotkit.md @@ -0,0 +1,89 @@ +--- +'slug': '/use-cases/AI/MCP/ai-agent-libraries/copilotkit' +'sidebar_label': '集成 CopilotKit' +'title': '如何使用 CopilotKit 和 ClickHouse MCP 服务器构建 AI 代理' +'pagination_prev': null +'pagination_next': null +'description': '了解如何使用存储在 ClickHouse 中的数据以及 ClickHouse MCP 和 CopilotKit 构建代理应用程序' +'keywords': +- 'ClickHouse' +- 'MCP' +- 'copilotkit' +'show_related_blogs': true +'doc_type': 'guide' +--- + + +# 如何使用 CopilotKit 和 ClickHouse MCP 服务器构建 AI 代理 + +这是一个如何使用存储在 ClickHouse 中的数据构建代理应用的示例。它使用 [ClickHouse MCP Server](https://github.com/ClickHouse/mcp-clickhouse) 从 ClickHouse 查询数据并根据数据生成图表。 + +[CopilotKit](https://github.com/CopilotKit/CopilotKit) 被用来构建用户界面并提供与用户的聊天接口。 + +:::note 示例代码 +本示例的代码可以在 [examples repository](https://github.com/ClickHouse/examples/edit/main/ai/mcp/copilotkit) 中找到。 +::: + +## 先决条件 {#prerequisites} + +- `Node.js >= 20.14.0` +- `uv >= 0.1.0` + +## 安装依赖 {#install-dependencies} + +在本地克隆项目:`git clone https://github.com/ClickHouse/examples` 并导航到 `ai/mcp/copilotkit` 目录。 + +跳过此部分并运行脚本 `./install.sh` 以安装依赖。如果您希望手动安装依赖,请按照以下说明进行。 + +## 手动安装依赖 {#install-dependencies-manually} + +1. 安装依赖: + +运行 `npm install` 来安装 Node 依赖。 + +2. 安装 mcp-clickhouse: + +创建一个新文件夹 `external` 并将 mcp-clickhouse 仓库克隆到该目录中。 + +```sh +mkdir -p external +git clone https://github.com/ClickHouse/mcp-clickhouse external/mcp-clickhouse +``` + +安装 Python 依赖并添加 fastmcp CLI 工具。 + +```sh +cd external/mcp-clickhouse +uv sync +uv add fastmcp +``` + +## 配置应用程序 {#configure-the-application} + +将 `env.example` 文件复制到 `.env` 并编辑以提供您的 `ANTHROPIC_API_KEY`。 + +## 使用您自己的 LLM {#use-your-own-llm} + +如果您更愿意使用 Anthropic 以外的 LLM 提供者,您可以修改 Copilotkit 运行时以使用不同的 LLM 适配器。 +[这里](https://docs.copilotkit.ai/guides/bring-your-own-llm) 是支持的提供者列表。 + +## 使用您自己的 ClickHouse 集群 {#use-your-own-clickhouse-cluster} + +默认情况下,该示例配置为连接到 [ClickHouse 演示集群](https://sql.clickhouse.com/)。您也可以通过设置以下环境变量来使用您自己的 ClickHouse 集群: + +- `CLICKHOUSE_HOST` +- `CLICKHOUSE_PORT` +- `CLICKHOUSE_USER` +- `CLICKHOUSE_PASSWORD` +- `CLICKHOUSE_SECURE` + + +# 运行应用程序 {#run-the-application} + +运行 `npm run dev` 启动开发服务器。 + +您可以使用如下提示来测试代理: + +> “给我显示曼彻斯特最近 10 年的价格演变。” + +打开 [http://localhost:3000](http://localhost:3000) 通过浏览器查看结果。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/copilotkit.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/copilotkit.md.hash new file mode 100644 index 00000000000..67b35cecdaf --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/copilotkit.md.hash @@ -0,0 +1 @@ +e0f90f382c089d0a diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/dspy.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/dspy.md new file mode 100644 index 00000000000..d21493b020b --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/dspy.md @@ -0,0 +1,241 @@ +--- +'slug': '/use-cases/AI/MCP/ai-agent-libraries/DSPy' +'sidebar_label': '集成 DSPy' +'title': '如何使用 DSPy 和 ClickHouse MCP 服务器构建 AI 代理' +'pagination_prev': null +'pagination_next': null +'description': '学习如何使用 DSPy 和 ClickHouse MCP 服务器构建 AI 代理' +'keywords': +- 'ClickHouse' +- 'MCP' +- 'DSPy' +'show_related_blogs': true +'doc_type': 'guide' +--- + + +# 如何使用 DSPy 和 ClickHouse MCP 服务器构建 AI 代理 + +在本指南中,您将学习如何使用 [DSPy](https://github.com/langchain-ai/langgraph) 构建一个 AI 代理,该代理可以使用 [ClickHouse 的 SQL 游乐场](https://sql.clickhouse.com/) 与 [ClickHouse 的 MCP 服务器](https://github.com/ClickHouse/mcp-clickhouse) 进行交互。 + +## 前提条件 {#prerequisites} + +- 您需要在系统上安装 Python。 +- 您需要在系统上安装 `pip`。 +- 您需要一个 Anthropic API 密钥,或者来自其他 LLM 提供商的 API 密钥。 + +您可以在 Python REPL 中或通过脚本运行以下步骤。 + +:::note 示例笔记本 +此示例可在 [examples repository](https://github.com/ClickHouse/examples/blob/main/ai/mcp/dspy/dspy.ipynb) 中找到。 +::: + + + +## 安装库 {#install-libraries} + +使用 `pip` 运行以下命令以安装所需的库: + +```shell +!pip install -q --upgrade pip +!pip install -q dspy +!pip install -q mcp +``` + +## 设置凭据 {#setup-credentials} + +接下来,您需要提供您的 Anthropic API 密钥: + +```python +import os +os.environ["ANTHROPIC_API_KEY"] = getpass.getpass("Enter Anthropic API Key:") +``` + +:::note 使用其他 LLM 提供商 +如果您没有 Anthropic API 密钥,并且想使用其他 LLM 提供商, +您可以在 [DSPy docs](https://dspy.ai/#__tabbed_1_1) 中找到设置凭据的说明。 +::: + +接下来,定义连接到 ClickHouse SQL 游乐场所需的凭据: + +```python +env = { + "CLICKHOUSE_HOST": "sql-clickhouse.clickhouse.com", + "CLICKHOUSE_PORT": "8443", + "CLICKHOUSE_USER": "demo", + "CLICKHOUSE_PASSWORD": "", + "CLICKHOUSE_SECURE": "true" +} +``` + +## 初始化 MCP 服务器 {#initialize-mcp} + +现在配置 ClickHouse MCP 服务器,以指向 ClickHouse SQL 游乐场。 + +```python +from mcp import ClientSession, StdioServerParameters +from mcp.client.stdio import stdio_client +import dspy + +server_params = StdioServerParameters( + command="uv", + args=[ + 'run', + '--with', 'mcp-clickhouse', + '--python', '3.13', + 'mcp-clickhouse' + ], + env=env +) +``` + +## 初始化 LLM {#initialize-llm} + +接下来,用以下行初始化 LLM: + +```python +dspy.configure(lm=dspy.LM("anthropic/claude-sonnet-4-20250514")) +``` + +## 运行代理 {#run-the-agent} + +最后,初始化并运行代理: + +```python +class DataAnalyst(dspy.Signature): + """You are a data analyst. You'll be asked questions and you need to try to answer them using the tools you have access to. """ + + user_request: str = dspy.InputField() + process_result: str = dspy.OutputField( + desc=( + "Answer to the query" + ) + ) + +from utils import print_dspy_result + +async with stdio_client(server_params) as (read, write): + async with ClientSession(read, write) as session: + await session.initialize() + tools = await session.list_tools() + + dspy_tools = [] + for tool in tools.tools: + dspy_tools.append(dspy.Tool.from_mcp_tool(session, tool)) + + react = dspy.ReAct(DataAnalyst, tools=dspy_tools) + result = await react.acall(user_request="What's the most popular Amazon product category") + print_dspy_result(result) +``` + +```response title="Response" +================================================================================ +🤖 DSPy ReAct Result +================================================================================ + +📍 STEP 1 +---------------------------------------- +🧠 THINKING: I need to find information about Amazon product categories and determine which one is most popular. First, I should explore what databases are available to see if there's any Amazon-related data. + +🔧 TOOL: list_databases + +📊 RESULT: + amazon +bluesky +country +covid +default +dns +environmental +food +forex +geo +git +github +hackernews +imdb +logs +metrica +mgbench +mta +noaa +nyc_taxi +nypd +ontime +opensky +otel +otel_v2 +pypi +random +reddit +rubygems +sta... + +📍 STEP 2 +---------------------------------------- +🧠 THINKING: Great! I can see there's an "amazon" database available. This is exactly what I need to find information about Amazon product categories. Let me explore the tables in the amazon database to see what data is available. + +🔧 TOOL: list_tables + Args: {'database': 'amazon'} + +📊 RESULT: + { + "database": "amazon", + "name": "amazon_reviews", + "comment": "", + "columns": [ + { + "name": "review_date", + "type": "Date", + "default_type": "", + "default_expression": "",... + +📍 STEP 3 +---------------------------------------- +🧠 THINKING: Perfect! I found the amazon_reviews table which contains a product_category column. This table has over 150 million rows of Amazon review data, which should give me a good representation of product popularity. To find the most popular Amazon product category, I need to count the number of reviews per category and order them by count in descending order. The category with the most reviews would be considered the most popular. + +🔧 TOOL: run_select_query + Args: {'query': 'SELECT product_category, COUNT(*) as review_count FROM amazon.amazon_reviews GROUP BY product_category ORDER BY review_count DESC LIMIT 10'} + +📊 RESULT: + 1. Books: 19,530,930 reviews + 2. Digital_Ebook_Purchase: 17,622,107 reviews + 3. Wireless: 9,001,567 reviews + 4. PC: 6,908,245 reviews + 5. Home: 6,221,321 reviews + ... and 5 more + +📍 STEP 4 +---------------------------------------- +🧠 THINKING: Perfect! I have found the answer to the user's question. Based on the Amazon reviews data, I can clearly see that "Books" is the most popular Amazon product category with 19,530,930 reviews, followed by "Digital_Ebook_Purchase" with 17,622,107 reviews. The data shows a clear ranking of product categories by popularity based on the number of reviews each category has received. I now have all the information needed to answer the user's question. + +🔧 TOOL: finish + +📊 RESULT: + Completed. + +🎯 REASONING +---------------------------------------- +To answer the question about the most popular Amazon product category, I accessed the Amazon database and found a table called "amazon_reviews" with over 150 million review records. This table contains a "product_category" column that allows me to analyze product popularity based on review volume. I ran a query to count the number of reviews per product category and ordered them by count in descending order. The assumption here is that categories with more reviews indicate higher popularity, as more reviews typically correlate with more purchases and customer engagement. + +✅ FINAL RESULT +---------------------------------------- +Based on Amazon review data containing over 150 million records, the most popular Amazon product category is **Books** with 19,530,930 reviews. + +Here are the top 10 most popular Amazon product categories by review count: + +1. **Books** - 19,530,930 reviews +2. **Digital_Ebook_Purchase** - 17,622,107 reviews +3. **Wireless** - 9,001,567 reviews +4. **PC** - 6,908,245 reviews +5. **Home** - 6,221,321 reviews +6. **Apparel** - 5,906,085 reviews +7. **Health & Personal Care** - 5,331,239 reviews +8. **Beauty** - 5,115,462 reviews +9. **Video DVD** - 5,069,014 reviews +10. **Mobile_Apps** - 5,033,164 reviews + +It's interesting to note that Books and Digital Ebook Purchase (which are related categories) together account for over 37 million reviews, showing the strong popularity of reading materials on Amazon's platform. +================================================================================ +``` + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/dspy.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/dspy.md.hash new file mode 100644 index 00000000000..e61c6b8cc5e --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/dspy.md.hash @@ -0,0 +1 @@ +d4996ef802210ebf diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/index.md new file mode 100644 index 00000000000..c60d8185535 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/index.md @@ -0,0 +1,38 @@ +--- +'slug': '/use-cases/AI/MCP/ai-agent-libraries' +'title': '将 AI 代理库与 ClickHouse MCP 服务器结合' +'pagination_prev': null +'pagination_next': null +'description': '了解如何使用 DSPy 和 ClickHouse MCP 服务器构建 AI 代理' +'keywords': +- 'ClickHouse' +- 'Agno' +- 'Chainlit' +- 'MCP' +- 'DSPy' +- 'LangChain' +- 'LlamaIndex' +- 'OpenAI agents' +- 'PydanticAI' +- 'SlackBot' +- 'StreamLit' +'doc_type': 'guide' +--- + + +# 集成 AI 代理库与 ClickHouse MCP 服务器的指南 + + +| 页面 | 描述 | +|-----|-----| +| [如何使用 Streamlit 构建一个基于 ClickHouse 的 AI 代理](/use-cases/AI/MCP/ai-agent-libraries/streamlit-agent) | 了解如何使用 Streamlit 和 ClickHouse MCP 服务器构建基于 web 的 AI 代理 | +| [如何使用 ClickHouse MCP 服务器构建一个 LangChain/LangGraph AI 代理。](/use-cases/AI/MCP/ai-agent-libraries/langchain) | 了解如何构建一个可以与 ClickHouse 的 SQL 游乐场互动的 LangChain/LangGraph AI 代理,使用 ClickHouse 的 MCP 服务器。 | +| [如何使用 ClickHouse MCP 服务器构建一个 LlamaIndex AI 代理。](/use-cases/AI/MCP/ai-agent-libraries/llamaindex) | 了解如何构建一个可以与 ClickHouse MCP 服务器互动的 LlamaIndex AI 代理。 | +| [如何使用 ClickHouse MCP 服务器构建一个 PydanticAI 代理。](/use-cases/AI/MCP/ai-agent-libraries/pydantic-ai) | 了解如何构建一个可以与 ClickHouse MCP 服务器互动的 PydanticAI 代理。 | +| [如何使用 ClickHouse MCP 服务器构建一个 SlackBot 代理。](/use-cases/AI/MCP/ai-agent-libraries/slackbot) | 了解如何构建一个可以与 ClickHouse MCP 服务器互动的 SlackBot 代理。 | +| [如何与 ClickHouse MCP 服务器一起使用 Agno 构建 AI 代理](/use-cases/AI/MCP/ai-agent-libraries/agno) | 了解如何与 ClickHouse MCP 服务器一起使用 Agno 构建 AI 代理 | +| [如何与 ClickHouse MCP 服务器一起使用 Chainlit 构建 AI 代理](/use-cases/AI/MCP/ai-agent-libraries/chainlit) | 了解如何使用 Chainlit 构建基于 LLM 的聊天应用,并与 ClickHouse MCP 服务器结合使用 | +| [如何与 ClickHouse MCP 服务器一起使用 CopilotKit 构建 AI 代理](/use-cases/AI/MCP/ai-agent-libraries/copilotkit) | 了解如何使用 ClickHouse 存储的数据以及 ClickHouse MCP 和 CopilotKit 构建代理应用 | +| [如何与 ClickHouse MCP 服务器一起使用 DSPy 构建 AI 代理](/use-cases/AI/MCP/ai-agent-libraries/DSPy) | 了解如何与 ClickHouse MCP 服务器一起构建 AI 代理 | +| [如何使用 ClickHouse MCP 服务器构建 OpenAI 代理。](/use-cases/AI/MCP/ai-agent-libraries/openai-agents) | 了解如何构建一个可以与 ClickHouse MCP 服务器互动的 OpenAI 代理。 | + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/index.md.hash new file mode 100644 index 00000000000..95d055a3dce --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/index.md.hash @@ -0,0 +1 @@ +6479ffcd2f21ddee diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/langchain.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/langchain.md new file mode 100644 index 00000000000..a4e6bd7b4f4 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/langchain.md @@ -0,0 +1,192 @@ +--- +'slug': '/use-cases/AI/MCP/ai-agent-libraries/langchain' +'sidebar_label': '集成 Langchain' +'title': '如何使用 ClickHouse MCP 服务器构建 LangChain/LangGraph AI 代理' +'pagination_prev': null +'pagination_next': null +'description': '学习如何构建一个 LangChain/LangGraph AI 代理,该代理可以使用 ClickHouse 的 MCP 服务器与 ClickHouse + 的 SQL 游乐场进行交互。' +'keywords': +- 'ClickHouse' +- 'MCP' +- 'LangChain' +- 'LangGraph' +'show_related_blogs': true +'doc_type': 'guide' +--- + + +# 如何使用 ClickHouse MCP 服务器构建 LangChain/LangGraph AI 代理 + +在本指南中,您将学习如何构建一个可以使用 [ClickHouse 的 SQL 游乐场](https://sql.clickhouse.com/) 进行交互的 [LangChain/LangGraph](https://github.com/langchain-ai/langgraph) AI 代理,利用 [ClickHouse 的 MCP 服务器](https://github.com/ClickHouse/mcp-clickhouse)。 + +:::note 示例笔记本 +此示例可以在 [示例代码库](https://github.com/ClickHouse/examples/blob/main/ai/mcp/langchain/langchain.ipynb) 中找到作为笔记本。 +::: + +## 先决条件 {#prerequisites} +- 您需要在系统上安装 Python。 +- 您需要在系统上安装 `pip`。 +- 您需要一个 Anthropic API 密钥,或者来自其他 LLM 提供商的 API 密钥。 + +您可以通过 Python REPL 或脚本运行以下步骤。 + + + +## 安装库 {#install-libraries} + +通过运行以下命令安装所需的库: + +```python +!pip install -q --upgrade pip +!pip install -q langchain-mcp-adapters +!pip install -q langgraph +!pip install -q "langchain[anthropic]" +``` + +## 设置凭证 {#setup-credentials} + +接下来,您需要提供您的 Anthropic API 密钥: + +```python +import os, getpass +os.environ["ANTHROPIC_API_KEY"] = getpass.getpass("Enter Anthropic API Key:") +``` + +```response title="Response" +Enter Anthropic API Key: ········ +``` + +:::note 使用其他 LLM 提供商 +如果您没有 Anthropic API 密钥,并希望使用其他 LLM 提供商, +您可以在 [Langchain Providers 文档](https://python.langchain.com/docs/integrations/providers/) 中找到设置凭证的说明。 +::: + +## 初始化 MCP 服务器 {#initialize-mcp-and-agent} + +现在配置 ClickHouse MCP 服务器以指向 ClickHouse SQL 游乐场: + +```python +from mcp import ClientSession, StdioServerParameters +from mcp.client.stdio import stdio_client + +server_params = StdioServerParameters( + command="uv", + args=[ + "run", + "--with", "mcp-clickhouse", + "--python", "3.13", + "mcp-clickhouse" + ], + env={ + "CLICKHOUSE_HOST": "sql-clickhouse.clickhouse.com", + "CLICKHOUSE_PORT": "8443", + "CLICKHOUSE_USER": "demo", + "CLICKHOUSE_PASSWORD": "", + "CLICKHOUSE_SECURE": "true" + } +) +``` +## 配置流处理程序 {#configure-the-stream-handler} + +在与 Langchain 和 ClickHouse MCP 服务器一起工作时,查询结果通常作为流数据返回,而不是单个响应。对于大型数据集或可能需要时间处理的复杂分析查询,配置流处理程序非常重要。没有适当的处理,流式输出在您的应用程序中可能很难使用。 + +配置流输出的处理程序,以便更容易地使用: + +```python +class UltraCleanStreamHandler: + def __init__(self): + self.buffer = "" + self.in_text_generation = False + self.last_was_tool = False + + def handle_chunk(self, chunk): + event = chunk.get("event", "") + + if event == "on_chat_model_stream": + data = chunk.get("data", {}) + chunk_data = data.get("chunk", {}) + + # Only handle actual text content, skip tool invocation streams + if hasattr(chunk_data, 'content'): + content = chunk_data.content + if isinstance(content, str) and not content.startswith('{"'): + # Add space after tool completion if needed + if self.last_was_tool: + print(" ", end="", flush=True) + self.last_was_tool = False + print(content, end="", flush=True) + self.in_text_generation = True + elif isinstance(content, list): + for item in content: + if (isinstance(item, dict) and + item.get('type') == 'text' and + 'partial_json' not in str(item)): + text = item.get('text', '') + if text and not text.startswith('{"'): + # Add space after tool completion if needed + if self.last_was_tool: + print(" ", end="", flush=True) + self.last_was_tool = False + print(text, end="", flush=True) + self.in_text_generation = True + + elif event == "on_tool_start": + if self.in_text_generation: + print(f"\n🔧 {chunk.get('name', 'tool')}", end="", flush=True) + self.in_text_generation = False + + elif event == "on_tool_end": + print(" ✅", end="", flush=True) + self.last_was_tool = True +``` + +## 调用代理 {#call-the-agent} + +最后,调用您的代理,并询问谁向 ClickHouse 提交了最多的代码: + +```python +async with stdio_client(server_params) as (read, write): + async with ClientSession(read, write) as session: + await session.initialize() + tools = await load_mcp_tools(session) + agent = create_react_agent("anthropic:claude-sonnet-4-0", tools) + + handler = UltraCleanStreamHandler() + async for chunk in agent.astream_events( + {"messages": [{"role": "user", "content": "Who's committed the most code to ClickHouse?"}]}, + version="v1" + ): + handler.handle_chunk(chunk) + + print("\n") +``` + +您应该会看到类似以下的响应: + +```response title="Response" +I'll help you find who has committed the most code to ClickHouse by exploring the available databases and tables to locate git commit data. +🔧 list_databases ✅ I can see there's a `git` database which likely contains git commit information. Let me explore the tables in that database: +🔧 list_tables ✅ Perfect! I can see the `clickhouse_commits` table in the git database contains ClickHouse commit data with 80,644 commits. This table has information about each commit including the author, lines added/deleted, files modified, etc. Let me query this table to find who has committed the most code based on different metrics. +🔧 run_select_query ✅ Let me also look at just the lines added to see who has contributed the most new code: +🔧 run_select_query ✅ Based on the ClickHouse git commit data, **Alexey Milovidov** has committed the most code to ClickHouse by several measures: + +## Key Statistics: + +1. **Most Total Lines Changed**: Alexey Milovidov with **1,696,929 total lines changed** (853,049 added + 843,880 deleted) +2. **Most Lines Added**: Alexey Milovidov with **853,049 lines added** +3. **Most Commits**: Alexey Milovidov with **15,375 commits** +4. **Most Files Changed**: Alexey Milovidov with **73,529 files changed** + +## Top Contributors by Lines Added: + +1. **Alexey Milovidov**: 853,049 lines added (15,375 commits) +2. **s-kat**: 541,609 lines added (50 commits) +3. **Nikolai Kochetov**: 219,020 lines added (4,218 commits) +4. **alesapin**: 193,566 lines added (4,783 commits) +5. **Vitaly Baranov**: 168,807 lines added (1,152 commits) + +Alexey Milovidov is clearly the most prolific contributor to ClickHouse, which makes sense as he is one of the original creators and lead developers of the project. His contribution dwarfs others both in terms of total code volume and number of commits, with nearly 16,000 commits and over 850,000 lines of code added to the project. +``` + + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/langchain.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/langchain.md.hash new file mode 100644 index 00000000000..9b2e19c0e21 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/langchain.md.hash @@ -0,0 +1 @@ +e2c6aad22dfc0a13 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/llamaindex.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/llamaindex.md new file mode 100644 index 00000000000..e0dc70d02db --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/llamaindex.md @@ -0,0 +1,161 @@ +--- +'slug': '/use-cases/AI/MCP/ai-agent-libraries/llamaindex' +'sidebar_label': '集成 LlamaIndex' +'title': '如何使用 ClickHouse MCP Server 构建 LlamaIndex AI 代理。' +'pagination_prev': null +'pagination_next': null +'description': '学习如何构建可以与 ClickHouse MCP Server 交互的 LlamaIndex AI 代理。' +'keywords': +- 'ClickHouse' +- 'MCP' +- 'LlamaIndex' +'show_related_blogs': true +'doc_type': 'guide' +--- + + +# 如何使用 ClickHouse MCP 服务器构建 LlamaIndex AI 代理 + +在本指南中,您将学习如何构建一个可以使用 [ClickHouse 的 SQL 游乐场](https://sql.clickhouse.com/) 进行交互的 [LlamaIndex](https://docs.llamaindex.ai) AI 代理,使用 [ClickHouse 的 MCP 服务器](https://github.com/ClickHouse/mcp-clickhouse)。 + +:::note 示例笔记本 +此示例可以在 [示例仓库](https://github.com/ClickHouse/examples/blob/main/ai/mcp/llamaindex/llamaindex.ipynb) 中找到。 +::: + +## 前提条件 {#prerequisites} +- 您需要在系统上安装 Python。 +- 您需要在系统上安装 `pip`。 +- 您需要一个 Anthropic API 密钥,或来自其他 LLM 提供商的 API 密钥。 + +您可以通过 Python REPL 或脚本运行以下步骤。 + + + +## 安装库 {#install-libraries} + +通过运行以下命令安装所需的库: + +```python +!pip install -q --upgrade pip +!pip install -q llama-index +!pip install -q clickhouse-connect +!pip install -q llama-index-llms-anthropic +!pip install -q llama-index-tools-mcp +``` + +## 设置凭证 {#setup-credentials} + +接下来,您需要提供您的 Anthropic API 密钥: + +```python +import os, getpass +os.environ["ANTHROPIC_API_KEY"] = getpass.getpass("Enter Anthropic API Key:") +``` + +```response title="Response" +Enter Anthropic API Key: ········ +``` + +:::note 使用其他 LLM 提供商 +如果您没有 Anthropic API 密钥,并想使用其他 LLM 提供商,您可以在 [LlamaIndex "LLMs" 文档](https://docs.llamaindex.ai/en/stable/examples/) 中找到设置凭证的说明。 +::: + +## 初始化 MCP 服务器 {#initialize-mcp-and-agent} + +现在配置 ClickHouse MCP 服务器指向 ClickHouse SQL 游乐场。您需要将这些从 Python 函数转换为 Llama Index 工具: + +```python +from llama_index.tools.mcp import BasicMCPClient, McpToolSpec + +mcp_client = BasicMCPClient( + "uv", + args=[ + "run", + "--with", "mcp-clickhouse", + "--python", "3.13", + "mcp-clickhouse" + ], + env={ + "CLICKHOUSE_HOST": "sql-clickhouse.clickhouse.com", + "CLICKHOUSE_PORT": "8443", + "CLICKHOUSE_USER": "demo", + "CLICKHOUSE_PASSWORD": "", + "CLICKHOUSE_SECURE": "true" + } +) + +mcp_tool_spec = McpToolSpec( + client=mcp_client, +) + +tools = await mcp_tool_spec.to_tool_list_async() +``` +## 创建代理 {#create-agent} + +您现在准备创建一个访问这些工具的代理。将一次运行中的最大工具调用次数设置为 10。您可以根据需要修改此参数: + +```python +from llama_index.core.agent import AgentRunner, FunctionCallingAgentWorker + +agent_worker = FunctionCallingAgentWorker.from_tools( + tools=tools, + llm=llm, verbose=True, max_function_calls=10 +) +agent = AgentRunner(agent_worker) +``` + +## 初始化 LLM {#initialize-llm} + +使用以下代码初始化 Claude Sonnet 4.0 模型: + +```python +from llama_index.llms.anthropic import Anthropic +llm = Anthropic(model="claude-sonnet-4-0") +``` + +## 运行代理 {#run-agent} + +最后,您可以问代理一个问题: + +```python +response = agent.query("What's the most popular repository?") +``` + +返回的响应很长,因此在下面的示例响应中已被截断: + +```response title="Response" +Added user message to memory: What's the most popular repository? +=== LLM Response === +I'll help you find the most popular repository. Let me first explore the available databases and tables to understand the data structure. +=== Calling Function === +Calling function: list_databases with args: {} +=== Function Output === +meta=None content=[TextContent(type='text', text='amazon\nbluesky\ncountry\ncovid\ndefault\ndns\nenvironmental\nfood\nforex\ngeo\ngit\ngithub\nhackernews\nimdb\nlogs\nmetrica\nmgbench\nmta\nnoaa\nnyc_taxi\nnypd\nontime\nopensky\notel\notel_v2\npypi\nrandom\nreddit\nrubygems\nstackoverflow\nstar_schema\nstock\nsystem\ntw_weather\ntwitter\nuk\nwiki\nwords\nyoutube', annotations=None)] isError=False +=== LLM Response === +I can see there's a `github` database which likely contains repository data. Let me explore the tables in that database. +=== Calling Function === +Calling function: list_tables with args: {"database": "github"} +=== Function Output === +... +... +... +=== LLM Response === +Based on the GitHub data, **the most popular repository is `sindresorhus/awesome`** with **402,292 stars**. + +Here are the top 10 most popular repositories by star count: + +1. **sindresorhus/awesome** - 402,292 stars +2. **996icu/996.ICU** - 388,413 stars +3. **kamranahmedse/developer-roadmap** - 349,097 stars +4. **donnemartin/system-design-primer** - 316,524 stars +5. **jwasham/coding-interview-university** - 313,767 stars +6. **public-apis/public-apis** - 307,227 stars +7. **EbookFoundation/free-programming-books** - 298,890 stars +8. **facebook/react** - 286,034 stars +9. **vinta/awesome-python** - 269,320 stars +10. **freeCodeCamp/freeCodeCamp** - 261,824 stars + +The `sindresorhus/awesome` repository is a curated list of awesome lists, which explains its popularity as it serves as a comprehensive directory of resources across many different topics in software development. +``` + + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/llamaindex.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/llamaindex.md.hash new file mode 100644 index 00000000000..2596fe9d83d --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/llamaindex.md.hash @@ -0,0 +1 @@ +19441abd819427e4 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/openai-agents.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/openai-agents.md new file mode 100644 index 00000000000..600bba02f36 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/openai-agents.md @@ -0,0 +1,191 @@ +--- +'slug': '/use-cases/AI/MCP/ai-agent-libraries/openai-agents' +'sidebar_label': '集成 OpenAI' +'title': '如何构建一个使用 ClickHouse MCP Server 的 OpenAI 代理。' +'pagination_prev': null +'pagination_next': null +'description': '学习如何构建一个可以与 ClickHouse MCP Server 交互的 OpenAI 代理。' +'keywords': +- 'ClickHouse' +- 'MCP' +- 'OpenAI' +'show_related_blogs': true +'doc_type': 'guide' +--- + + +# 如何使用 ClickHouse MCP 服务器构建 OpenAI 代理 + +在本指南中,您将学习如何构建一个可以与 [ClickHouse 的 SQL 游乐场](https://sql.clickhouse.com/) 交互的 [OpenAI](https://github.com/openai/openai-agents-python) 代理,该代理使用 [ClickHouse 的 MCP 服务器](https://github.com/ClickHouse/mcp-clickhouse)。 + +:::note 示例笔记本 +该示例可以在 [示例存储库](https://github.com/ClickHouse/examples/blob/main/ai/mcp/openai-agents/openai-agents.ipynb) 中找到。 +::: + +## 先决条件 {#prerequisites} +- 您需要在系统上安装 Python。 +- 您需要在系统上安装 `pip`。 +- 您需要一个 OpenAI API 密钥。 + +您可以通过 Python REPL 或脚本运行以下步骤。 + + + +## 安装库 {#install-libraries} + +通过运行以下命令安装所需的库: + +```python +!pip install -q --upgrade pip +!pip install -q openai-agents +``` + +## 设置凭据 {#setup-credentials} + +接下来,您需要提供您的 OpenAI API 密钥: + +```python +import os, getpass +os.environ["OPENAI_API_KEY"] = getpass.getpass("Enter OpenAI API Key:") +``` + +```response title="Response" +Enter OpenAI API Key: ········ +``` + +## 初始化 MCP 服务器和 OpenAI 代理 {#initialize-mcp-and-agent} + +现在配置 ClickHouse MCP 服务器以指向 ClickHouse SQL 游乐场,初始化您的 OpenAI 代理并向其提问: + +```python +from agents.mcp import MCPServer, MCPServerStdio +from agents import Agent, Runner, trace +import json + +def simple_render_chunk(chunk): + """Simple version that just filters important events""" + + # Tool calls + if (hasattr(chunk, 'type') and + chunk.type == 'run_item_stream_event'): + + if chunk.name == 'tool_called': + tool_name = chunk.item.raw_item.name + args = chunk.item.raw_item.arguments + print(f"🔧 Tool: {tool_name}({args})") + + elif chunk.name == 'tool_output': + try: + # Handle both string and already-parsed output + if isinstance(chunk.item.output, str): + output = json.loads(chunk.item.output) + else: + output = chunk.item.output + + # Handle both dict and list formats + if isinstance(output, dict): + if output.get('type') == 'text': + text = output['text'] + if 'Error' in text: + print(f"❌ Error: {text}") + else: + print(f"✅ Result: {text[:100]}...") + elif isinstance(output, list) and len(output) > 0: + # Handle list format + first_item = output[0] + if isinstance(first_item, dict) and first_item.get('type') == 'text': + text = first_item['text'] + if 'Error' in text: + print(f"❌ Error: {text}") + else: + print(f"✅ Result: {text[:100]}...") + else: + # Fallback - just print the raw output + print(f"✅ Result: {str(output)[:100]}...") + + except (json.JSONDecodeError, AttributeError, KeyError) as e: + # Fallback to raw output if parsing fails + print(f"✅ Result: {str(chunk.item.output)[:100]}...") + + elif chunk.name == 'message_output_created': + try: + content = chunk.item.raw_item.content + if content and len(content) > 0: + print(f"💬 Response: {content[0].text}") + except (AttributeError, IndexError): + print(f"💬 Response: {str(chunk.item)[:100]}...") + + # Text deltas for streaming + elif (hasattr(chunk, 'type') and + chunk.type == 'raw_response_event' and + hasattr(chunk, 'data') and + hasattr(chunk.data, 'type') and + chunk.data.type == 'response.output_text.delta'): + print(chunk.data.delta, end='', flush=True) + +async with MCPServerStdio( + name="ClickHouse SQL Playground", + params={ + "command": "uv", + "args": [ + 'run', + '--with', 'mcp-clickhouse', + '--python', '3.13', + 'mcp-clickhouse' + ], + "env": env + }, client_session_timeout_seconds = 60 +) as server: + agent = Agent( + name="Assistant", + instructions="Use the tools to query ClickHouse and answer questions based on those files.", + mcp_servers=[server], + ) + + message = "What's the biggest GitHub project so far in 2025?" + print(f"\n\nRunning: {message}") + with trace("Biggest project workflow"): + result = Runner.run_streamed(starting_agent=agent, input=message, max_turns=20) + async for chunk in result.stream_events(): + simple_render_chunk(chunk) +``` + +```response title="Response" +Running: What's the biggest GitHub project so far in 2025? +🔧 Tool: list_databases({}) +✅ Result: amazon +bluesky +country +covid +default +dns +environmental +food +forex +geo +git +github +hackernews +imdb +log... +🔧 Tool: list_tables({"database":"github"}) +✅ Result: { + "database": "github", + "name": "actors_per_repo", + "comment": "", + "columns": [ + { + "... +🔧 Tool: run_select_query({"query":"SELECT repo_name, MAX(stars) FROM github.top_repos_mv"}) +✅ Result: { + "status": "error", + "message": "Query failed: HTTPDriver for https://sql-clickhouse.clickhouse.... +🔧 Tool: run_select_query({"query":"SELECT repo_name, stars FROM github.top_repos ORDER BY stars DESC LIMIT 1"}) +✅ Result: { + "repo_name": "sindresorhus/awesome", + "stars": 402893 +}... +The biggest GitHub project in 2025, based on stars, is "[sindresorhus/awesome](https://github.com/sindresorhus/awesome)" with 402,893 stars.💬 Response: The biggest GitHub project in 2025, based on stars, is "[sindresorhus/awesome](https://github.com/sindresorhus/awesome)" with 402,893 stars. +``` + + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/openai-agents.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/openai-agents.md.hash new file mode 100644 index 00000000000..ff267fc5a00 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/openai-agents.md.hash @@ -0,0 +1 @@ +ede135ae9b32b5d6 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/pydantic-ai.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/pydantic-ai.md new file mode 100644 index 00000000000..9c8ea102494 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/pydantic-ai.md @@ -0,0 +1,131 @@ +--- +'slug': '/use-cases/AI/MCP/ai-agent-libraries/pydantic-ai' +'sidebar_label': '集成 PydanticAI' +'title': '如何使用 ClickHouse MCP Server 构建 PydanticAI 代理。' +'pagination_prev': null +'pagination_next': null +'description': '学习如何构建一个可以与 ClickHouse MCP Server 交互的 PydanticAI 代理。' +'keywords': +- 'ClickHouse' +- 'MCP' +- 'PydanticAI' +'show_related_blogs': true +'doc_type': 'guide' +--- + + +# 如何使用 ClickHouse MCP 服务器构建 PydanticAI 代理 + +在本指南中,您将学习如何构建一个可以使用 [ClickHouse 的 SQL 游乐场](https://sql.clickhouse.com/) 与 [ClickHouse 的 MCP 服务器](https://github.com/ClickHouse/mcp-clickhouse) 交互的 [PydanticAI](https://ai.pydantic.dev/mcp/client/#__tabbed_1_1) 代理。 + +:::note 示例笔记本 +此示例可以在 [示例库](https://github.com/ClickHouse/examples/blob/main/ai/mcp/pydanticai/pydantic.ipynb) 中找到。 +::: + +## 先决条件 {#prerequisites} +- 您需要在系统上安装 Python。 +- 您需要在系统上安装 `pip`。 +- 您需要一个 Anthropic API 密钥,或者来自其他 LLM 提供商的 API 密钥。 + +您可以在 Python REPL 或通过脚本运行以下步骤。 + + + +## 安装库 {#install-libraries} + +通过运行以下命令安装所需的库: + +```python +!pip install -q --upgrade pip +!pip install -q "pydantic-ai-slim[mcp]" +!pip install -q "pydantic-ai-slim[anthropic]" # replace with the appropriate package if using a different LLM provider +``` + +## 设置凭证 {#setup-credentials} + +接下来,您需要提供您的 Anthropic API 密钥: + +```python +import os, getpass +os.environ["ANTHROPIC_API_KEY"] = getpass.getpass("Enter Anthropic API Key:") +``` + +```response title="Response" +Enter Anthropic API Key: ········ +``` + +:::note 使用其他 LLM 提供商 +如果您没有 Anthropic API 密钥,并且想要使用其他 LLM 提供商, +您可以在 [PydanticAI 文档](https://ai.pydantic.dev/models/) 中找到设置凭证的说明。 +::: + +接下来,定义连接到 ClickHouse SQL 游乐场所需的凭证: + +```python +env = { + "CLICKHOUSE_HOST": "sql-clickhouse.clickhouse.com", + "CLICKHOUSE_PORT": "8443", + "CLICKHOUSE_USER": "demo", + "CLICKHOUSE_PASSWORD": "", + "CLICKHOUSE_SECURE": "true" +} +``` + +## 初始化 MCP 服务器和 PydanticAI 代理 {#initialize-mcp} + +现在配置 ClickHouse MCP 服务器以指向 ClickHouse SQL 游乐场: + +```python +from pydantic_ai import Agent +from pydantic_ai.mcp import MCPServerStdio +from pydantic_ai.messages import ToolCallPart, ToolReturnPart + +server = MCPServerStdio( + 'uv', + args=[ + 'run', + '--with', 'mcp-clickhouse', + '--python', '3.13', + 'mcp-clickhouse' + ], + env=env +) +agent = Agent('anthropic:claude-sonnet-4-0', mcp_servers=[server]) +``` + +## 向代理提问 {#ask-agent} + +最后,您可以向代理提问: + +```python +async with agent.run_mcp_servers(): + result = await agent.run("Who's done the most PRs for ClickHouse?") + print(result.output) +``` + +您将收到类似如下的响应: + +```response title="Response" +Based on the data from the ClickHouse GitHub repository, here are the top contributors by number of pull requests created: + +**Top contributors to ClickHouse by PRs opened:** + +1. **alexey-milovidov** - 3,370 PRs opened +2. **azat** - 1,905 PRs opened +3. **rschu1ze** - 979 PRs opened +4. **alesapin** - 947 PRs opened +5. **tavplubix** - 896 PRs opened +6. **kssenii** - 871 PRs opened +7. **Avogar** - 805 PRs opened +8. **KochetovNicolai** - 700 PRs opened +9. **Algunenano** - 658 PRs opened +10. **kitaisreal** - 630 PRs opened + +**Alexey Milovidov** stands out as by far the most active contributor with over 3,370 pull requests opened, which is significantly more than any other contributor. This makes sense as Alexey Milovidov is one of the founders and lead developers of ClickHouse. + +The data also shows that alexey-milovidov has been very active in managing PRs, with 12,818 "closed" events (likely reviewing and closing PRs from other contributors) in addition to creating his own PRs. + +It's worth noting that I filtered out various robot/bot accounts that handle automated processes, focusing on human contributors to give you the most meaningful answer about who has contributed the most PRs to ClickHouse. +``` + + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/pydantic-ai.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/pydantic-ai.md.hash new file mode 100644 index 00000000000..f7333fe6f1c --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/pydantic-ai.md.hash @@ -0,0 +1 @@ +3864e977e30c061a diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/slackbot.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/slackbot.md new file mode 100644 index 00000000000..4c1a1c95dbc --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/slackbot.md @@ -0,0 +1,109 @@ +--- +'slug': '/use-cases/AI/MCP/ai-agent-libraries/slackbot' +'sidebar_label': '集成 SlackBot' +'title': '如何使用 ClickHouse MCP 服务器构建 SlackBot 代理。' +'pagination_prev': null +'pagination_next': null +'description': '学习如何构建一个可以与 ClickHouse MCP 服务器交互的 SlackBot 代理。' +'keywords': +- 'ClickHouse' +- 'MCP' +- 'Slack' +- 'SlackBot' +- 'PydanticAI' +'show_related_blogs': true +'doc_type': 'guide' +--- + + +# 如何使用 ClickHouse MCP 服务器构建 SlackBot 代理 + +在本指南中,您将学习如何构建一个 [SlackBot](https://slack.com/intl/en-gb/help/articles/202026038-An-introduction-to-Slackbot) 代理。 +该机器人允许您直接从 Slack 使用自然语言询问有关 ClickHouse 数据的问题。它使用 [ClickHouse MCP 服务器](https://github.com/ClickHouse/mcp-clickhouse) 和 [PydanticAI](https://ai.pydantic.dev/mcp/client/#__tabbed_1_1)。 + +:::note 示例项目 +此示例的代码可以在 [examples repository](https://github.com/ClickHouse/examples/blob/main/ai/mcp/slackbot/README.md) 中找到。 +::: + +## 前提条件 {#prerequisites} +- 您需要安装 [`uv`](https://docs.astral.sh/uv/getting-started/installation/) +- 您需要访问一个 Slack 工作区 +- 您需要一个 Anthropic API 密钥,或来自其他 LLM 提供商的 API 密钥 + + + +## 创建 Slack 应用 {#create-a-slack-app} + +1. 访问 [slack.com/apps](https://slack.com/apps) 并点击 `Create New App`。 +2. 选择 `From scratch` 选项并为您的应用命名。 +3. 选择您的 Slack 工作区。 + +## 将应用安装到您的工作区 {#install-the-app-to-your-workspace} + +接下来,您需要将上一步创建的应用添加到您的工作区。 +您可以遵循 Slack 文档中有关 ["Add apps to your Slack workspace"](https://slack.com/intl/en-gb/help/articles/202035138-Add-apps-to-your-Slack-workspace) 的说明。 + +## 配置 Slack 应用设置 {#configure-slack-app-settings} + +- 转到 `App Home` + - 在 `Show Tabs` → `Messages Tab`:启用 `Allow users to send Slash commands and messages from the messages tab` + - 转到 `Socket Mode` + - 启用 `Socket Mode` + - 记录 `Socket Mode Handler` 的值作为环境变量 `SLACK_APP_TOKEN` + - 转到 `OAuth & Permissions` + - 添加以下 `Bot Token Scopes`: + - `app_mentions:read` + - `assistant:write` + - `chat:write` + - `im:history` + - `im:read` + - `im:write` + - `channels:history` + - 将应用安装到您的工作区,并记录 `Bot User OAuth Token` 的值作为环境变量 `SLACK_BOT_TOKEN`。 + - 转到 `Event Subscriptions` + - 启用 `Events` + - 在 `Subscribe to bot events` 下,添加: + - `app_mention` + - `assistant_thread_started` + - `message:im` + - 保存更改 + +## 添加环境变量 (`.env`) {#add-env-vars} + +在项目根目录中创建一个 `.env` 文件,包含以下环境变量, +这些变量将允许您的应用连接到 [ClickHouse 的 SQL playground](https://sql.clickhouse.com/)。 + +```env +SLACK_BOT_TOKEN=your-slack-bot-token +SLACK_APP_TOKEN=your-slack-app-level-token +ANTHROPIC_API_KEY=your-anthropic-api-key +CLICKHOUSE_HOST=sql-clickhouse.clickhouse.com +CLICKHOUSE_PORT=8443 +CLICKHOUSE_USER=demo +CLICKHOUSE_PASSWORD= +CLICKHOUSE_SECURE=true +``` + +如果您愿意,可以将 ClickHouse 变量调整为使用您自己的 ClickHouse 服务器或云实例。 + +## 使用机器人 {#using-the-bot} + +1. **启动机器人:** + +```sh +uv run main.py +``` +2. **在 Slack 中:** + - 在频道中提及机器人:`@yourbot Who are the top contributors to the ClickHouse git repo?` + - 回复线程中的提及:`@yourbot how many contributions did these users make last week?` + - 私聊机器人:`Show me all tables in the demo database.` + +机器人会在线程中回复,使用所有之前线程消息作为上下文(如果适用)。 + +**线程上下文:** +在回复线程时,机器人会加载所有之前的消息(当前消息除外),并将其作为 AI 的上下文。 + +**工具使用:** +机器人仅使用通过 MCP 提供的工具(例如,架构发现、SQL 执行),并将始终显示使用的 SQL 及答案求解的摘要。 + + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/slackbot.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/slackbot.md.hash new file mode 100644 index 00000000000..44aee44b418 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/slackbot.md.hash @@ -0,0 +1 @@ +ecb6065622bb4f62 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/streamlit.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/streamlit.md new file mode 100644 index 00000000000..1bdc5869810 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/streamlit.md @@ -0,0 +1,225 @@ +--- +'slug': '/use-cases/AI/MCP/ai-agent-libraries/streamlit-agent' +'sidebar_label': '集成 Streamlit' +'title': '如何使用 Streamlit 构建 ClickHouse 支持的 AI 代理' +'pagination_prev': null +'pagination_next': null +'description': '学习如何使用 Streamlit 和 ClickHouse MCP 服务器构建基于网页的 AI 代理' +'keywords': +- 'ClickHouse' +- 'MCP' +- 'Streamlit' +- 'Agno' +- 'AI Agent' +'show_related_blogs': true +'doc_type': 'guide' +--- + + +# 如何构建一个基于 ClickHouse 的 AI 代理与 Streamlit + +在本指南中,您将学习如何使用 [Streamlit](https://streamlit.io/) 构建一个基于 web 的 AI 代理,该代理可以通过 [ClickHouse 的 SQL 游乐场](https://sql.clickhouse.com/) 与 [ClickHouse 的 MCP 服务器](https://github.com/ClickHouse/mcp-clickhouse) 和 [Agno](https://github.com/agno-agi/agno) 进行交互。 + +:::note 示例应用 +该示例创建了一个完整的 web 应用程序,为查询 ClickHouse 数据提供聊天界面。 +您可以在 [示例代码库](https://github.com/ClickHouse/examples/tree/main/ai/mcp/streamlit) 中找到此示例的源代码。 +::: + +## 准备工作 {#prerequisites} +- 您需要在系统上安装 Python。 + 您需要安装 [`uv`](https://docs.astral.sh/uv/getting-started/installation/) +- 您需要一个 Anthropic API 密钥,或者来自其他 LLM 提供者的 API 密钥 + +您可以执行以下步骤来创建您的 Streamlit 应用程序。 + + + +## 安装库 {#install-libraries} + +通过运行以下命令安装所需的库: + +```bash +pip install streamlit agno ipywidgets +``` + +## 创建工具文件 {#create-utilities} + +创建一个 `utils.py` 文件,其中包含两个工具函数。第一个是一个 +用于处理来自 Agno 代理的流响应的异步函数生成器。第二个是一个应用样式到 Streamlit +应用程序的函数: + +```python title="utils.py" +import streamlit as st +from agno.run.response import RunEvent, RunResponse + +async def as_stream(response): + async for chunk in response: + if isinstance(chunk, RunResponse) and isinstance(chunk.content, str): + if chunk.event == RunEvent.run_response: + yield chunk.content + +def apply_styles(): + st.markdown(""" + +
""", unsafe_allow_html=True) +``` + +## 设置凭据 {#setup-credentials} + +将您的 Anthropic API 密钥设置为环境变量: + +```bash +export ANTHROPIC_API_KEY="your_api_key_here" +``` + +:::note 使用其他 LLM 提供者 +如果您没有 Anthropic API 密钥,并且想使用其他 LLM 提供者, +您可以在 [Agno "集成" 文档](https://docs.agentops.ai/v2/integrations/ag2) 中找到设置凭据的说明。 +::: + +## 导入所需库 {#import-libraries} + +首先创建您的主要 Streamlit 应用程序文件(例如,`app.py`),并添加导入: + +```python +from utils import apply_styles + +import streamlit as st +from textwrap import dedent + +from agno.models.anthropic import Claude +from agno.agent import Agent +from agno.tools.mcp import MCPTools +from agno.storage.json import JsonStorage +from agno.run.response import RunEvent, RunResponse +from mcp.client.stdio import stdio_client, StdioServerParameters + +from mcp import ClientSession + +import asyncio +import threading +from queue import Queue +``` + +## 定义代理流函数 {#define-agent-function} + +添加连接到 [ClickHouse 的 SQL 游乐场](https://sql.clickhouse.com/) 并流式响应的主要代理函数: + +```python +async def stream_clickhouse_agent(message): + env = { + "CLICKHOUSE_HOST": "sql-clickhouse.clickhouse.com", + "CLICKHOUSE_PORT": "8443", + "CLICKHOUSE_USER": "demo", + "CLICKHOUSE_PASSWORD": "", + "CLICKHOUSE_SECURE": "true" + } + + server_params = StdioServerParameters( + command="uv", + args=[ + 'run', + '--with', 'mcp-clickhouse', + '--python', '3.13', + 'mcp-clickhouse' + ], + env=env + ) + + async with stdio_client(server_params) as (read, write): + async with ClientSession(read, write) as session: + mcp_tools = MCPTools(timeout_seconds=60, session=session) + await mcp_tools.initialize() + agent = Agent( + model=Claude(id="claude-3-5-sonnet-20240620"), + tools=[mcp_tools], + instructions=dedent("""\ + You are a ClickHouse assistant. Help users query and understand data using ClickHouse. + - Run SQL queries using the ClickHouse MCP tool + - Present results in markdown tables when relevant + - Keep output concise, useful, and well-formatted + """), + markdown=True, + show_tool_calls=True, + storage=JsonStorage(dir_path="tmp/team_sessions_json"), + add_datetime_to_instructions=True, + add_history_to_messages=True, + ) + chunks = await agent.arun(message, stream=True) + async for chunk in chunks: + if isinstance(chunk, RunResponse) and chunk.event == RunEvent.run_response: + yield chunk.content +``` + +## 添加同步封装函数 {#add-wrapper-functions} + +添加辅助函数以处理 Streamlit 中的异步流: + +```python +def run_agent_query_sync(message): + queue = Queue() + def run(): + asyncio.run(_agent_stream_to_queue(message, queue)) + queue.put(None) # Sentinel to end stream + threading.Thread(target=run, daemon=True).start() + while True: + chunk = queue.get() + if chunk is None: + break + yield chunk + +async def _agent_stream_to_queue(message, queue): + async for chunk in stream_clickhouse_agent(message): + queue.put(chunk) +``` + +## 创建 Streamlit 界面 {#create-interface} + +添加 Streamlit UI 组件和聊天功能: + +```python +st.title("A ClickHouse-backed AI agent") + +if st.button("💬 New Chat"): + st.session_state.messages = [] + st.rerun() + +apply_styles() + +if "messages" not in st.session_state: + st.session_state.messages = [] + +for message in st.session_state.messages: + with st.chat_message(message["role"]): + st.markdown(message["content"]) + +if prompt := st.chat_input("What is up?"): + st.session_state.messages.append({"role": "user", "content": prompt}) + with st.chat_message("user"): + st.markdown(prompt) + with st.chat_message("assistant"): + response = st.write_stream(run_agent_query_sync(prompt)) + st.session_state.messages.append({"role": "assistant", "content": response}) +``` + +## 运行应用程序 {#run-application} + +要启动您的 ClickHouse AI 代理 web 应用程序,您可以从终端运行以下命令: + +```bash +uv run \ + --with streamlit \ + --with agno \ + --with anthropic \ + --with mcp \ + streamlit run app.py --server.headless true +``` + +这将打开您的 web 浏览器并导航到 `http://localhost:8501`,您可以与您的 AI 代理进行交互,并向其询问有关 ClickHouse 的 SQL 游乐场中可用示例数据集的问题。 + +
diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/streamlit.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/streamlit.md.hash new file mode 100644 index 00000000000..c64b857a239 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/ai_agent_libraries/streamlit.md.hash @@ -0,0 +1 @@ +1faf3eba3c67ff33 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/index.md new file mode 100644 index 00000000000..8222fd4d75d --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/index.md @@ -0,0 +1,69 @@ +--- +'slug': '/use-cases/AI/MCP' +'sidebar_label': 'MCP' +'title': 'MCP 指南' +'pagination_prev': null +'pagination_next': null +'description': '此页面提供了对模型上下文协议 (MCP) 的介绍,并包含 MCP 指南的目录。' +'keywords': +- 'ClickHouse' +- 'MCP' +'show_related_blogs': true +'doc_type': 'guide' +--- + +import Image from '@theme/IdealImage'; +import overview from '@site/static/images/use-cases/AI_ML/MCP/mcp_overview.png'; + +[Model Context Protocol](https://www.anthropic.com/news/model-context-protocol) (MCP) 是由 Anthropic 开发的标准,使 AI 助手能够与外部系统无缝集成。该协议允许 AI 助手以安全和标准化的方式连接到数据源、API、数据库等。 + +MCP 在 AI 模型和各种服务之间创建了一个通用接口,消除了每个集成所需的自定义工具实现的需要。您可以将它视为专门为 AI 系统设计的通用 API 标准。 + +MCP 的主要优势在于 AI 库只需一次实现对协议的支持。之后,所有兼容 MCP 的服务便可立即访问,为 AI 库维护者节省了大量时间。 + +## MCP 的架构是什么? {#mcp-architecture} + +MCP 采用客户端-服务器架构: + +* 客户端(如 Claude Desktop、Cursor 或 VS Code)与 MCP 服务器建立连接。您可以在 [awesome-mcp-clients](https://github.com/punkpeye/awesome-mcp-clients?tab=readme-ov-file#windsurf) GitHub 存储库中查看客户端集合。 +* 服务器通过标准化接口公开工具和功能。您可以在 [awesome-mcp-servers](https://github.com/punkpeye/awesome-mcp-servers) GitHub 存储库中查看服务器集合。 +* AI 模型随后可以在需要时使用这些工具访问外部数据和功能。 + +下图展示了架构: + + + +## ClickHouse 有 MCP 服务器吗? {#clickhouse-mcp-server} + +有的! +[ClickHouse MCP Server](https://github.com/ClickHouse/mcp-clickhouse) 提供以下工具: + +* `run_select_query` - 在您的 ClickHouse 集群上执行 SQL 查询。 +* `list_databases` - 列出您 ClickHouse 集群上的所有数据库。 +* `list_tables` - 列出数据库中的所有表。 + +## 使用 ClickHouse MCP 服务器的指南 {#clickhouse-mcp-server-guides} + +以下是一些介绍如何使用 ClickHouse MCP 服务器的指南。 + + +| 页面 | 描述 | +|-----|-----| +| [启用 ClickHouse Cloud 远程 MCP 服务器](/use-cases/AI/MCP/remote_mcp) | 本指南解释如何启用和使用 ClickHouse Cloud 远程 MCP | +| [如何使用 Streamlit 构建 ClickHouse 支持的 AI 代理](/use-cases/AI/MCP/ai-agent-libraries/streamlit-agent) | 学习如何使用 Streamlit 和 ClickHouse MCP 服务器构建基于 Web 的 AI 代理 | +| [如何使用 ClickHouse MCP 服务器构建 LangChain/LangGraph AI 代理](/use-cases/AI/MCP/ai-agent-libraries/langchain) | 学习如何构建一个可以与 ClickHouse 的 SQL 游乐场交互的 LangChain/LangGraph AI 代理 | +| [如何使用 ClickHouse MCP 服务器构建 LlamaIndex AI 代理](/use-cases/AI/MCP/ai-agent-libraries/llamaindex) | 学习如何构建一个可以与 ClickHouse MCP 服务器交互的 LlamaIndex AI 代理 | +| [如何使用 ClickHouse MCP 服务器构建 PydanticAI 代理](/use-cases/AI/MCP/ai-agent-libraries/pydantic-ai) | 学习如何构建一个可以与 ClickHouse MCP 服务器交互的 PydanticAI 代理 | +| [如何使用 ClickHouse MCP 服务器构建 SlackBot 代理](/use-cases/AI/MCP/ai-agent-libraries/slackbot) | 学习如何构建一个可以与 ClickHouse MCP 服务器交互的 SlackBot 代理 | +| [如何使用 Agno 和 ClickHouse MCP 服务器构建 AI 代理](/use-cases/AI/MCP/ai-agent-libraries/agno) | 学习如何使用 Agno 和 ClickHouse MCP 服务器构建 AI 代理 | +| [如何使用 Chainlit 和 ClickHouse MCP 服务器构建 AI 代理](/use-cases/AI/MCP/ai-agent-libraries/chainlit) | 学习如何使用 Chainlit 和 ClickHouse MCP 服务器一起构建基于 LLM 的聊天应用 | +| [如何使用 CopilotKit 和 ClickHouse MCP 服务器构建 AI 代理](/use-cases/AI/MCP/ai-agent-libraries/copilotkit) | 学习如何使用 ClickHouse MCP 和 CopilotKit 构建一个使用 ClickHouse 中存储的数据的代理应用 | +| [如何使用 DSPy 和 ClickHouse MCP 服务器构建 AI 代理](/use-cases/AI/MCP/ai-agent-libraries/DSPy) | 学习如何使用 DSPy 和 ClickHouse MCP 服务器构建 AI 代理 | +| [如何使用 ClickHouse MCP 服务器构建 OpenAI 代理](/use-cases/AI/MCP/ai-agent-libraries/openai-agents) | 学习如何构建一个可以与 ClickHouse MCP 服务器交互的 OpenAI 代理 | +| [使用 AnythingLLM 和 ClickHouse Cloud 设置 ClickHouse MCP 服务器](/use-cases/AI/MCP/anythingllm) | 本指南解释如何使用 Docker 设置与 ClickHouse MCP 服务器的 AnythingLLM | +| [使用 Claude Desktop 设置 ClickHouse MCP 服务器](/use-cases/AI/MCP/claude-desktop) | 本指南解释如何与 ClickHouse MCP 服务器设置 Claude Desktop | +| [使用 Jan.ai 设置 ClickHouse MCP 服务器](/use-cases/AI/MCP/janai) | 本指南解释如何与 ClickHouse MCP 服务器设置 Jan.ai | +| [使用 LibreChat 和 ClickHouse Cloud 设置 ClickHouse MCP 服务器](/use-cases/AI/MCP/librechat) | 本指南解释如何使用 Docker 设置与 ClickHouse MCP 服务器的 LibreChat | +| [使用 Ollama 设置 ClickHouse MCP 服务器](/use-cases/AI/MCP/ollama) | 本指南解释如何与 ClickHouse MCP 服务器设置 Ollama | +| [使用 Open WebUI 和 ClickHouse Cloud 设置 ClickHouse MCP 服务器](/use-cases/AI/MCP/open-webui) | 本指南解释如何使用 Docker 设置与 ClickHouse MCP 服务器的 Open WebUI | + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/index.md.hash new file mode 100644 index 00000000000..b967c3450cc --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/MCP/index.md.hash @@ -0,0 +1 @@ +1900a0806f31d08a diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/ai-powered-sql-generation.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/ai-powered-sql-generation.md new file mode 100644 index 00000000000..3f03b82d7d9 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/ai-powered-sql-generation.md @@ -0,0 +1,193 @@ +--- +'slug': '/use-cases/AI/ai-powered-sql-generation' +'sidebar_label': 'AI驱动的 SQL 生成' +'title': 'AI驱动的 SQL 生成' +'pagination_prev': null +'pagination_next': null +'description': '本指南解释如何使用 AI 在 ClickHouse Client 或 clickhouse-local 中生成 SQL 查询。' +'keywords': +- 'AI' +- 'SQL generation' +'show_related_blogs': true +'doc_type': 'guide' +--- + +从 ClickHouse 25.7 开始,[ClickHouse Client](https://clickhouse.com/docs/interfaces/cli) 和 [clickhouse-local](https://clickhouse.com/docs/operations/utilities/clickhouse-local) 包含 [人工智能驱动的功能](https://clickhouse.com/docs/interfaces/cli#ai-sql-generation),可以将自然语言描述转换为 SQL 查询。此功能允许用户以纯文本描述其数据需求,系统随后将其翻译成相应的 SQL 语句。 + +这项功能对于那些可能不熟悉复杂 SQL 语法或需要快速生成探索性数据分析查询的用户特别有用。该功能适用于标准的 ClickHouse 表,并支持包括过滤、聚合和连接在内的常见查询模式。 + +它借助以下内置工具/函数实现这一点: + +* `list_databases` - 列出 ClickHouse 实例中所有可用的数据库 +* `list_tables_in_database` - 列出特定数据库中的所有表 +* `get_schema_for_table` - 获取特定表的 `CREATE TABLE` 语句(模式) + +## 先决条件 {#prerequisites} + +我们需要将 Anthropic 或 OpenAI 密钥添加为环境变量: + +```bash +export ANTHROPIC_API_KEY=your_api_key +export OPENAI_API_KEY=your_api_key +``` + +另外,您可以 [提供配置文件](https://clickhouse.com/docs/interfaces/cli#ai-sql-generation-configuration)。 + +## 连接到 ClickHouse SQL 游乐场 {#connecting-to-the-clickhouse-sql-playground} + +我们将使用 [ClickHouse SQL 游乐场](https://sql.clickhouse.com/) 探索此功能。 + +我们可以使用以下命令连接到 ClickHouse SQL 游乐场: + +```bash +clickhouse client -mn \ +--host sql-clickhouse.clickhouse.com \ +--secure \ +--user demo --password '' +``` + +:::note +我们假设您已经安装了 ClickHouse,但如果没有,请参考 [安装指南](https://clickhouse.com/docs/install) +::: + +## 用自然语言向 ClickHouse 提问 {#asking-clickhouse-questions-in-natural-language} + +现在是时候开始提问了! + +文本到 SQL 功能实际上是一个一次性查询生成工具。由于它不维护对话历史,因此在提问时要尽可能包含有用的上下文。请具体说明: + +时间段或日期范围 +您希望进行的分析类型(平均值、总和、排名等) +任何过滤标准 + +### 查找昂贵的房地产市场 {#finding-expensive-housing-markets} + +让我们首先提出有关房价的问题。SQL 游乐场包含一个英国房价数据集,人工智能会自动发现它: + +```sql +?? Can you tell me the most expensive place to buy a house in 2021?; +``` + +一旦我们按下回车键,我们将看到人工智能在尝试回答我们的问题时的思维过程。 + +```text +• Starting AI SQL generation with schema discovery... +───────────────────────────────────────────────── +🧠 thinking...[INFO] Text generation successful - model: claude-3-5-sonnet-latest, response_id: msg_01QpQd35ZD8HM9QSYFZuQ8Wh +🔧 Calling: list_databases [toolu_01...] +🧠 thinking✓ list_databases completed + └─ Found 37 databases: - amazon - bluesky - country - covid - default - dns - en... +🔧 Calling: list_databases [toolu_01...] +✓ list_databases completed + └─ Found 37 databases: - amazon - bluesky - country - covid - default - dns - en... +🧠 thinking[INFO] Text generation successful - model: claude-3-5-sonnet-latest, response_id: msg_016DxK8SMVKGrUPfFwi43AzE +🔧 Calling: list_tables_in_database [toolu_01...] + └─ Args: {"database":"uk"} +🧠 thinking.✓ list_tables_in_database completed + └─ Found 9 tables in database 'uk': - uk_codes - uk_postcode_to_iso - uk_price_p... +🔧 Calling: list_tables_in_database [toolu_01...] + └─ Args: {"database":"uk"} +✓ list_tables_in_database completed + └─ Found 9 tables in database 'uk': - uk_codes - uk_postcode_to_iso - uk_price_p... +🧠 thinking.[INFO] Text generation successful - model: claude-3-5-sonnet-latest, response_id: msg_015giF12wm619beNGC5aTrmw +🔧 Calling: get_schema_for_table [toolu_01...] + └─ Args: {"database":"uk","table":"uk_price_paid"} +✓ get_schema_for_table completed + └─ Schema for uk.uk_price_paid: CREATE TABLE uk.uk_price_paid ( `price` UInt... +🔧 Calling: get_schema_for_table [toolu_01...] + └─ Args: {"database":"uk","table":"uk_price_paid"} +🧠 thinking..✓ get_schema_for_table completed + └─ Schema for uk.uk_price_paid: CREATE TABLE uk.uk_price_paid ( `price` UInt... +🧠 thinking[INFO] Text generation successful - model: claude-3-5-sonnet-latest, response_id: msg_01HxT1HKbaTT3165Wx5bDtY9 +───────────────────────────────────────────────── +• ✨ SQL query generated successfully! +:) SELECT town, district, county, round(avg(price), 2) as avg_price, count() as total_sales FROM uk.uk_price_paid WHERE date >= '2021-01-01' AND date <= '2021-12-31' GROUP BY town, district, county HAVING total_sales >= 10 ORDER BY avg_price DESC LIMIT 10 +``` + +AI 遵循以下步骤: + +1. 模式发现 - 探索可用的数据库和表 +2. 表分析 - 检查相关表的结构 +3. 查询生成 - 根据您的问题和发现的模式创建 SQL + +我们可以看到它确实找到了 `uk_price_paid` 表并为我们生成了一个查询。如果我们运行该查询,将看到以下输出: + +```text +┌─town───────────┬─district───────────────┬─county──────────┬──avg_price─┬─total_sales─┐ +│ ILKLEY │ HARROGATE │ NORTH YORKSHIRE │ 4310200 │ 10 │ +│ LONDON │ CITY OF LONDON │ GREATER LONDON │ 4008117.32 │ 311 │ +│ LONDON │ CITY OF WESTMINSTER │ GREATER LONDON │ 2847409.81 │ 3984 │ +│ LONDON │ KENSINGTON AND CHELSEA │ GREATER LONDON │ 2331433.1 │ 2594 │ +│ EAST MOLESEY │ RICHMOND UPON THAMES │ GREATER LONDON │ 2244845.83 │ 12 │ +│ LEATHERHEAD │ ELMBRIDGE │ SURREY │ 2051836.42 │ 102 │ +│ VIRGINIA WATER │ RUNNYMEDE │ SURREY │ 1914137.53 │ 169 │ +│ REIGATE │ MOLE VALLEY │ SURREY │ 1715780.89 │ 18 │ +│ BROADWAY │ TEWKESBURY │ GLOUCESTERSHIRE │ 1633421.05 │ 19 │ +│ OXFORD │ SOUTH OXFORDSHIRE │ OXFORDSHIRE │ 1628319.07 │ 405 │ +└────────────────┴────────────────────────┴─────────────────┴────────────┴─────────────┘ +``` + +如果我们想提出后续问题,则需要从头开始提问。 + +### 查找大伦敦地区昂贵的房产 {#finding-expensive-properties-in-greater-london} + +由于该功能不维护对话历史,因此每个查询必须是自包含的。在提问后续问题时,您需要提供完整的上下文,而不是引用先前的查询。例如,在看到先前的结果后,我们可能希望专注于大伦敦地区的房产。我们需要包含完整上下文,而不是问“关于大伦敦地区怎么样?”: + +```sql +?? Can you tell me the most expensive place to buy a house in Greater London across the years?; +``` + +请注意,尽管它刚刚检查过这些数据,人工智能仍然经历相同的发现过程: + +```text +• Starting AI SQL generation with schema discovery... +───────────────────────────────────────────────── +🧠 thinking[INFO] Text generation successful - model: claude-3-5-sonnet-latest, response_id: msg_012m4ayaSHTYtX98gxrDy1rz +🔧 Calling: list_databases [toolu_01...] +✓ list_databases completed + └─ Found 37 databases: - amazon - bluesky - country - covid - default - dns - en... +🔧 Calling: list_databases [toolu_01...] +🧠 thinking.✓ list_databases completed + └─ Found 37 databases: - amazon - bluesky - country - covid - default - dns - en... +🧠 thinking.[INFO] Text generation successful - model: claude-3-5-sonnet-latest, response_id: msg_01KU4SZRrJckutXUzfJ4NQtA +🔧 Calling: list_tables_in_database [toolu_01...] + └─ Args: {"database":"uk"} +🧠 thinking..✓ list_tables_in_database completed + └─ Found 9 tables in database 'uk': - uk_codes - uk_postcode_to_iso - uk_price_p... +🔧 Calling: list_tables_in_database [toolu_01...] + └─ Args: {"database":"uk"} +✓ list_tables_in_database completed + └─ Found 9 tables in database 'uk': - uk_codes - uk_postcode_to_iso - uk_price_p... +🧠 thinking[INFO] Text generation successful - model: claude-3-5-sonnet-latest, response_id: msg_01X9CnxoBpbD2xj2UzuRy2is +🔧 Calling: get_schema_for_table [toolu_01...] + └─ Args: {"database":"uk","table":"uk_price_paid"} +🧠 thinking.✓ get_schema_for_table completed + └─ Schema for uk.uk_price_paid: CREATE TABLE uk.uk_price_paid ( `price` UInt... +🔧 Calling: get_schema_for_table [toolu_01...] + └─ Args: {"database":"uk","table":"uk_price_paid"} +✓ get_schema_for_table completed + └─ Schema for uk.uk_price_paid: CREATE TABLE uk.uk_price_paid ( `price` UInt... +🧠 thinking...[INFO] Text generation successful - model: claude-3-5-sonnet-latest, response_id: msg_01QTMypS1XuhjgVpDir7N9wD +───────────────────────────────────────────────── +• ✨ SQL query generated successfully! +:) SELECT district, toYear(date) AS year, round(avg(price), 2) AS avg_price, count() AS total_sales FROM uk.uk_price_paid WHERE county = 'GREATER LONDON' GROUP BY district, year HAVING total_sales >= 10 ORDER BY avg_price DESC LIMIT 10; +``` + +这生成了一个更加针对性强的查询,专门过滤大伦敦地区的结果并按年份分解结果。查询的输出如下所示: + +```text +┌─district────────────┬─year─┬───avg_price─┬─total_sales─┐ +│ CITY OF LONDON │ 2019 │ 14504772.73 │ 299 │ +│ CITY OF LONDON │ 2017 │ 6351366.11 │ 367 │ +│ CITY OF LONDON │ 2016 │ 5596348.25 │ 243 │ +│ CITY OF LONDON │ 2023 │ 5576333.72 │ 252 │ +│ CITY OF LONDON │ 2018 │ 4905094.54 │ 523 │ +│ CITY OF LONDON │ 2021 │ 4008117.32 │ 311 │ +│ CITY OF LONDON │ 2025 │ 3954212.39 │ 56 │ +│ CITY OF LONDON │ 2014 │ 3914057.39 │ 416 │ +│ CITY OF LONDON │ 2022 │ 3700867.19 │ 290 │ +│ CITY OF WESTMINSTER │ 2018 │ 3562457.76 │ 3346 │ +└─────────────────────┴──────┴─────────────┴─────────────┘ +``` + +伦敦市始终出现在最昂贵的地区!您会注意到,人工智能创建了一个合理的查询,尽管结果是按平均价格排序而不是按时间顺序排列。为了进行年度分析,我们可以将问题精炼为具体询问“每年最昂贵的地区”,以获得分组不同的结果。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/ai-powered-sql-generation.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/ai-powered-sql-generation.md.hash new file mode 100644 index 00000000000..0c8133be328 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/ai-powered-sql-generation.md.hash @@ -0,0 +1 @@ +523004c01e055c8f diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/index.md new file mode 100644 index 00000000000..c0a062ba312 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/index.md @@ -0,0 +1,25 @@ +--- +'description': '机器学习与GenAI用例指南的登录页面' +'pagination_prev': null +'pagination_next': null +'slug': '/use-cases/AI/ask-ai' +'title': '机器学习与GenAI' +'keywords': +- 'machine learning' +- 'genAI' +- 'AI' +'doc_type': 'landing-page' +--- + + +# 机器学习与生成式人工智能 + +ClickHouse 是一个理想的实时数据库,用于支持机器学习工作负载。 +借助 ClickHouse,释放生成式人工智能(GenAI)分析数据变得前所未有的简单。 +在本节中,您将找到一些关于 ClickHouse 如何用于机器学习和生成式人工智能的指南。 + +| 章节 | 描述 | +|------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------| +| [AI 聊天](/use-cases/AI_ML/AIChat) | 本指南解释了如何在 ClickHouse Cloud 控制台中启用和使用 AI 聊天功能。 | +| [模型上下文协议](/use-cases/AI/MCP) | 一系列指南,帮助您使用 ClickHouse 设置模型上下文协议(MCP)。 | +| [AI 驱动的 SQL 生成](/use-cases/AI/ai-powered-sql-generation) | 此功能允许用户以自然语言描述其数据需求,系统随后将其转换为相应的 SQL 语句。 | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/index.md.hash new file mode 100644 index 00000000000..7f6b0ef8af4 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/index.md.hash @@ -0,0 +1 @@ +89482caf52e9782f diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/jupyter-notebook.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/jupyter-notebook.md new file mode 100644 index 00000000000..b2f007e0e83 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/jupyter-notebook.md @@ -0,0 +1,336 @@ +--- +'slug': '/use-cases/AI/jupyter-notebook' +'sidebar_label': '在 Jupyter 笔记本中使用 chDB 探索数据' +'title': '在 Jupyter 笔记本中使用 chDB 探索数据' +'description': '本指南解释了如何设置和使用 chDB 在 Jupyter 笔记本中探索来自 ClickHouse Cloud 或本地文件的数据' +'keywords': +- 'ML' +- 'Jupyer' +- 'chDB' +- 'pandas' +'doc_type': 'guide' +--- + +import Image from '@theme/IdealImage'; +import image_1 from '@site/static/images/use-cases/AI_ML/jupyter/1.png'; +import image_2 from '@site/static/images/use-cases/AI_ML/jupyter/2.png'; +import image_3 from '@site/static/images/use-cases/AI_ML/jupyter/3.png'; +import image_4 from '@site/static/images/use-cases/AI_ML/jupyter/4.png'; +import image_5 from '@site/static/images/use-cases/AI_ML/jupyter/5.png'; +import image_6 from '@site/static/images/use-cases/AI_ML/jupyter/6.png'; +import image_7 from '@site/static/images/use-cases/AI_ML/jupyter/7.png'; +import image_8 from '@site/static/images/use-cases/AI_ML/jupyter/8.png'; +import image_9 from '@site/static/images/use-cases/AI_ML/jupyter/9.png'; + + +# 使用 Jupyter Notebook 和 chDB 探索数据 + +在本指南中,您将学习如何使用 [chDB](/chdb) —— 一个由 ClickHouse 支持的快速内置 SQL OLAP 引擎——在 Jupyter Notebook 中探索 ClickHouse Cloud 数据集。 + +**前提条件**: +- 一个虚拟环境 +- 一个正在运行的 ClickHouse Cloud 服务和您的 [连接详情](/cloud/guides/sql-console/gather-connection-details) + +**您将学习:** +- 使用 chDB 从 Jupyter Notebook 连接到 ClickHouse Cloud +- 查询远程数据集并将结果转换为 Pandas DataFrame +- 将云数据与本地 CSV 文件结合进行分析 +- 使用 matplotlib 可视化数据 + +我们将使用在 ClickHouse Cloud 上可用的英国房产价格数据集作为起始数据集之一。 +它包含了1995年至2024年间在英国出售房屋的价格数据。 + +## 设置 {#setup} + +要将此数据集添加到现有的 ClickHouse Cloud 服务中,请使用您的帐户信息登录 [console.clickhouse.cloud](https://console.clickhouse.cloud/)。 + +在左侧菜单中,点击 `数据源`。然后点击 `预定义示例数据`: + + + +在英国房产价格支付数据(4GB)卡片中选择 `开始使用`: + + + +然后点击 `导入数据集`: + + + +ClickHouse 将自动在 `default` 数据库中创建 `pp_complete` 表,并用2892万行价格点数据填充该表。 + +为了减少暴露您凭据的可能性,我们建议将您的 Cloud 用户名和密码添加为本地计算机上的环境变量。 +在终端中运行以下命令以将您的用户名和密码添加为环境变量: + +```bash +export CLICKHOUSE_USER=default +export CLICKHOUSE_PASSWORD=your_actual_password +``` + +:::note +上面的环境变量仅在您的终端会话期间有效。 +要永久设置它们,请将其添加到您的 shell 配置文件中。 +::: + +现在激活您的虚拟环境。 +在您的虚拟环境中,使用以下命令安装 Jupyter Notebook: + +```python +pip install notebook +``` + +使用以下命令启动 Jupyter Notebook: + +```python +jupyter notebook +``` + +新的浏览器窗口应在 `localhost:8888` 打开并显示 Jupyter 界面。 +点击 `文件` > `新建` > `笔记本` 创建一个新的 Notebook。 + + + +您将被提示选择一个内核。 +选择您可用的任何 Python 内核,在此示例中我们将选择 `ipykernel`: + + + +在一个空白单元格中,您可以输入以下命令安装 chDB,我们将使用它连接到我们的远程 ClickHouse Cloud 实例: + +```python +pip install chdb +``` + +您现在可以导入 chDB,并运行一个简单的查询来检查一切是否设置正确: + +```python +import chdb + +result = chdb.query("SELECT 'Hello, ClickHouse!' as message") +print(result) +``` + +## 探索数据 {#exploring-the-data} + +在设置好英国房产价格数据集并在 Jupyter Notebook 中运行 chDB 后,我们现在可以开始探索我们的数据。 + +我们假设我们有兴趣检查某个特定区域(例如首都伦敦)的价格随时间的变化。 +ClickHouse 的 [`remoteSecure`](/sql-reference/table-functions/remote) 函数使您可以轻松从 ClickHouse Cloud 检索数据。 +您可以指示 chDB 将此数据作为 Pandas 数据帧返回——这是一个方便且熟悉的数据处理方式。 + +编写以下查询以从您的 ClickHouse Cloud 服务中获取英国价格支付数据,并将其转换为 `pandas.DataFrame`: + +```python +import os +from dotenv import load_dotenv +import chdb +import pandas as pd +import matplotlib.pyplot as plt +import matplotlib.dates as mdates + + +# Load environment variables from .env file +load_dotenv() + +username = os.environ.get('CLICKHOUSE_USER') +password = os.environ.get('CLICKHOUSE_PASSWORD') + +query = f""" +SELECT + toYear(date) AS year, + avg(price) AS avg_price +FROM remoteSecure( +'****.europe-west4.gcp.clickhouse.cloud', +default.pp_complete, +'{username}', +'{password}' +) +WHERE town = 'LONDON' +GROUP BY toYear(date) +ORDER BY year; +""" + +df = chdb.query(query, "DataFrame") +df.head() +``` + +在上面的代码片段中,`chdb.query(query, "DataFrame")` 运行指定的查询,并将结果输出到终端作为 Pandas DataFrame。 +在查询中,我们使用 `remoteSecure` 函数连接到 ClickHouse Cloud。 +`remoteSecure` 函数接受以下参数: +- 连接字符串 +- 要使用的数据库和表的名称 +- 您的用户名 +- 您的密码 + +作为安全最佳实践,您应该优先使用环境变量来设置用户名和密码参数,而不是直接在函数中指定,尽管如果您愿意,也可以这样做。 + +`remoteSecure` 函数连接到远程 ClickHouse Cloud 服务,运行查询并返回结果。 +根据您的数据大小,这可能需要几秒钟。 +在这种情况下,我们返回每年的平均价格点,并按 `town='LONDON'` 进行筛选。 +结果然后存储为名为 `df` 的 DataFrame。 + +`df.head` 仅显示返回数据的前几行: + + + +在一个新的单元格中运行以下命令以检查列的类型: + +```python +df.dtypes +``` + +```response +year uint16 +avg_price float64 +dtype: object +``` + +注意到虽然在 ClickHouse 中 `date` 的类型是 `Date`,但在生成的数据框中它的类型是 `uint16`。 +chDB 在返回 DataFrame 时会自动推断最合适的类型。 + +现在,我们的数据以熟悉的形式可用,让我们探索伦敦的房产价格随时间的变化。 + +在新单元格中,运行以下命令使用 matplotlib 绘制伦敦的时间与价格的简单图表: + +```python +plt.figure(figsize=(12, 6)) +plt.plot(df['year'], df['avg_price'], marker='o') +plt.xlabel('Year') +plt.ylabel('Price (£)') +plt.title('Price of London property over time') + + +# Show every 2nd year to avoid crowding +years_to_show = df['year'][::2] # Every 2nd year +plt.xticks(years_to_show, rotation=45) + +plt.grid(True, alpha=0.3) +plt.tight_layout() +plt.show() +``` + + + +也许并不奇怪,伦敦的房产价格随着时间的大幅上涨。 + +一位同事数据科学家给我们发送了一个 .csv 文件,里面包含额外的与住房相关的变量,并对 +伦敦的房屋销售数量随时间的变化感到好奇。 +让我们将其中的一些与房价进行绘制,看看能否发现任何关联。 + +您可以使用 `file` 表引擎直接读取本地计算机上的文件。 +在新单元格内,运行以下命令以从本地 .csv 文件创建一个新的 DataFrame。 + +```python +query = f""" +SELECT + toYear(date) AS year, + sum(houses_sold)*1000 + FROM file('/Users/datasci/Desktop/housing_in_london_monthly_variables.csv') +WHERE area = 'city of london' AND houses_sold IS NOT NULL +GROUP BY toYear(date) +ORDER BY year; +""" + +df_2 = chdb.query(query, "DataFrame") +df_2.head() +``` + +
+一步读取多个源 +也可以通过一步操作从多个源进行读取。您可以使用下面的查询,通过 `JOIN` 来实现: + +```python +query = f""" +SELECT + toYear(date) AS year, + avg(price) AS avg_price, housesSold +FROM remoteSecure( +'****.europe-west4.gcp.clickhouse.cloud', +default.pp_complete, +'{username}', +'{password}' +) AS remote +JOIN ( + SELECT + toYear(date) AS year, + sum(houses_sold)*1000 AS housesSold + FROM file('/Users/datasci/Desktop/housing_in_london_monthly_variables.csv') + WHERE area = 'city of london' AND houses_sold IS NOT NULL + GROUP BY toYear(date) + ORDER BY year +) AS local ON local.year = remote.year +WHERE town = 'LONDON' +GROUP BY toYear(date) +ORDER BY year; +""" +``` +
+ + + +虽然我们缺少2020年以后的数据,但我们可以绘制1995年至2019年间的两个数据集。 +在新单元格中运行以下命令: + +```python + +# Create a figure with two y-axes +fig, ax1 = plt.subplots(figsize=(14, 8)) + + +# Plot houses sold on the left y-axis +color = 'tab:blue' +ax1.set_xlabel('Year') +ax1.set_ylabel('Houses Sold', color=color) +ax1.plot(df_2['year'], df_2['houses_sold'], marker='o', color=color, label='Houses Sold', linewidth=2) +ax1.tick_params(axis='y', labelcolor=color) +ax1.grid(True, alpha=0.3) + + +# Create a second y-axis for price data +ax2 = ax1.twinx() +color = 'tab:red' +ax2.set_ylabel('Average Price (£)', color=color) + + +# Plot price data up until 2019 +ax2.plot(df[df['year'] <= 2019]['year'], df[df['year'] <= 2019]['avg_price'], marker='s', color=color, label='Average Price', linewidth=2) +ax2.tick_params(axis='y', labelcolor=color) + + +# Format price axis with currency formatting +ax2.yaxis.set_major_formatter(plt.FuncFormatter(lambda x, p: f'£{x:,.0f}')) + + +# Set title and show every 2nd year +plt.title('London Housing Market: Sales Volume vs Prices Over Time', fontsize=14, pad=20) + + +# Use years only up to 2019 for both datasets +all_years = sorted(list(set(df_2[df_2['year'] <= 2019]['year']).union(set(df[df['year'] <= 2019]['year'])))) +years_to_show = all_years[::2] # Every 2nd year +ax1.set_xticks(years_to_show) +ax1.set_xticklabels(years_to_show, rotation=45) + + +# Add legends +ax1.legend(loc='upper left') +ax2.legend(loc='upper right') + +plt.tight_layout() +plt.show() +``` + + + +从绘制的数据中,我们看到在1995年,销售量约为160,000,并迅速激增,并在1999年达到峰值约540,000。 +之后,销量在2000年代中期急剧下降,在2007-2008年金融危机期间大幅下跌,降至约140,000。 +另一方面,价格从1995年的约150,000英镑稳步、持续增长,到2005年的约300,000英镑。 +2012年后增长显著加速,从约400,000英镑迅速上升到2019年的超过1,000,000英镑。 +与销售量不同,价格对2008年危机的影响微乎其微,保持了上涨的趋势。哦不! + +## 总结 {#summary} + +本指南展示了 chDB 如何通过将 ClickHouse Cloud 与本地数据源连接,实现 Jupyter Notebook 中无缝的数据探索。 +通过使用英国房产价格数据集,我们展示了如何使用 `remoteSecure()` 函数查询远程 ClickHouse Cloud 数据,使用 `file()` 表引擎读取本地 CSV 文件,并直接将结果转换为 Pandas DataFrame 进行分析和可视化。 +通过 chDB,数据科学家可以结合使用 ClickHouse 强大的 SQL 功能和熟悉的 Python 工具,如 Pandas 和 matplotlib,轻松结合多个数据源进行全面分析。 + +虽然许多位在伦敦的数据科学家可能无法在短期内负担得起自己的房屋或公寓,但至少他们可以分析将他们排除在外的市场! diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/jupyter-notebook.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/jupyter-notebook.md.hash new file mode 100644 index 00000000000..ce2aa0f3160 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/AI_ML/jupyter-notebook.md.hash @@ -0,0 +1 @@ +299bfc36d4283aa0 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/data_lake/glue_catalog.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/data_lake/glue_catalog.md index 6b84ee7c7a8..06d6d45d42d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/data_lake/glue_catalog.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/data_lake/glue_catalog.md @@ -4,34 +4,35 @@ 'title': 'AWS Glue Catalog' 'pagination_prev': null 'pagination_next': null -'description': '在本指南中,我们将引导您使用 ClickHouse 和 AWS Glue 数据目录查询 S3 桶中的数据。' +'description': '在本指南中,我们将指导您通过使用 ClickHouse 和 AWS Glue 数据目录查询 S3 存储桶中的数据的步骤。' 'keywords': - 'Glue' - 'Data Lake' 'show_related_blogs': true +'doc_type': 'guide' --- import ExperimentalBadge from '@theme/badges/ExperimentalBadge'; -ClickHouse 支持与多个目录(Unity、Glue、Polaris 等)的集成。在本指南中,我们将引导您通过 ClickHouse 和 Glue 数据目录查询您在 S3 桶中的数据。 +ClickHouse 支持与多个目录的集成(Unity、Glue、Polaris 等)。在本指南中,我们将引导您通过使用 ClickHouse 和 Glue 数据目录查询 S3 存储桶中的数据的步骤。 :::note Glue 支持多种不同的表格式,但此集成仅支持 Iceberg 表。 ::: -## 在 AWS 中配置 Glue {#configuring} +## 配置 AWS 中的 Glue {#configuring} -要连接到 Glue 目录,您需要识别目录的区域并提供访问密钥和 Secret 密钥。 +要连接到 Glue 目录,您需要确定目录所在的区域,并提供访问密钥和秘密密钥。 :::note -目前,Glue 目录仅支持访问密钥和 Secret 密钥,但我们将来会支持其他身份验证方式。 +目前,Glue 目录仅支持访问密钥和秘密密钥,但我们将在未来支持其他认证方法。 ::: ## 在 Glue 数据目录与 ClickHouse 之间建立连接 {#connecting} -在配置好 Unity Catalog 和身份验证后,建立 ClickHouse 与 Unity Catalog 之间的连接。 +在配置好您的 Unity 目录并进行身份验证后,建立 ClickHouse 与 Unity 目录之间的连接。 ```sql title="Query" CREATE DATABASE glue @@ -45,7 +46,7 @@ SETTINGS ## 使用 ClickHouse 查询 Glue 数据目录 {#query-glue-catalog} -现在连接已经建立,您可以开始查询 Glue: +连接建立后,您可以开始查询 Glue: ```sql title="Query" USE glue; @@ -61,7 +62,7 @@ SHOW TABLES; └────────────────────────────────────────┘ ``` -您可以看到,上面的某些表不是 Iceberg 表,例如 `iceberg-benchmark.hitsparquet`。您将无法查询这些表,因为目前仅支持 Iceberg。 +您可以看到上面的一些表不是 Iceberg 表,例如 `iceberg-benchmark.hitsparquet`。您无法查询这些表,因为目前仅支持 Iceberg。 要查询一个表: @@ -70,10 +71,10 @@ SELECT count(*) FROM `iceberg-benchmark.hitsiceberg`; ``` :::note -由于 ClickHouse 不支持多个命名空间,因此需要使用反引号。 +反引号是必需的,因为 ClickHouse 不支持多个命名空间。 ::: -要检查表的 DDL,请运行以下查询: +要查看表的 DDL,请运行以下查询: ```sql SHOW CREATE TABLE `iceberg-benchmark.hitsiceberg`; @@ -195,7 +196,7 @@ SHOW CREATE TABLE `iceberg-benchmark.hitsiceberg`; ## 将数据从数据湖加载到 ClickHouse 中 {#loading-data-into-clickhouse} -如果您需要将数据从 Databricks 加载到 ClickHouse,请首先创建一个本地 ClickHouse 表: +如果您需要将数据从 Databricks 加载到 ClickHouse 中,请首先创建一个本地 ClickHouse 表: ```sql title="Query" CREATE TABLE hits diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/data_lake/glue_catalog.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/data_lake/glue_catalog.md.hash index a8585274171..c94798e942d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/data_lake/glue_catalog.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/data_lake/glue_catalog.md.hash @@ -1 +1 @@ -afc238195270a706 +54d4983f469bb857 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/data_lake/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/data_lake/index.md index 719e07589f0..7d8bee50238 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/data_lake/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/data_lake/index.md @@ -1,5 +1,5 @@ --- -'description': '数据湖用例指南的登录页' +'description': '数据湖用例指南的登陆页面' 'pagination_prev': null 'pagination_next': null 'slug': '/use-cases/data-lake' @@ -8,11 +8,16 @@ - 'data lake' - 'glue' - 'unity' +- 'rest' +'doc_type': 'landing-page' --- -ClickHouse 支持与多个目录的集成(Unity, Glue, Polaris 等)。 +ClickHouse 支持与多个目录的集成(Unity、Glue、REST、Polaris 等)。 | 页面 | 描述 | |-----|-----| -| [使用 ClickHouse 和 Glue 数据目录查询 S3 中的数据](/use-cases/data-lake/glue-catalog) | 使用 ClickHouse 和 Glue 数据目录查询您在 S3 存储桶中的数据。 | -| [使用 ClickHouse 和 Unity 数据目录查询 S3 中的数据](/use-cases/data-lake/unity-catalog) | 使用 Unity 目录查询您的数据。 | +| [使用 ClickHouse 和 Glue 数据目录在 S3 中查询数据](/use-cases/data-lake/glue-catalog) | 使用 ClickHouse 和 Glue 数据目录查询您在 S3 存储桶中的数据。 | +| [使用 ClickHouse 和 Unity 数据目录在 S3 中查询数据](/use-cases/data-lake/unity-catalog) | 使用 Unity 目录查询您的数据。 | +| [使用 ClickHouse 和 REST 目录在 S3 中查询数据](/use-cases/data-lake/rest-catalog) | 使用 REST 目录(Tabular.io)查询您的数据。 | +| [使用 ClickHouse 和 Lakekeeper 目录在 S3 中查询数据](/use-cases/data-lake/lakekeeper-catalog) | 使用 Lakekeeper 目录查询您的数据。 | +| [使用 ClickHouse 和 Nessie 目录在 S3 中查询数据](/use-cases/data-lake/nessie-catalog) | 使用 Nessie 目录和类似 Git 的数据版本控制查询您的数据。 | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/data_lake/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/data_lake/index.md.hash index a764aa5a0c0..ca6fb6822f1 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/data_lake/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/data_lake/index.md.hash @@ -1 +1 @@ -dffed2cf4386ea02 +6071462dc8e7b2e6 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/data_lake/lakekeeper_catalog.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/data_lake/lakekeeper_catalog.md new file mode 100644 index 00000000000..a30d5d6f187 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/data_lake/lakekeeper_catalog.md @@ -0,0 +1,370 @@ +--- +'slug': '/use-cases/data-lake/lakekeeper-catalog' +'sidebar_label': 'Lakekeeper 目录' +'title': 'Lakekeeper 目录' +'pagination_prev': null +'pagination_next': null +'description': '在本指南中,我们将带您了解使用 ClickHouse 和 Lakekeeper 目录查询数据的步骤。' +'keywords': +- 'Lakekeeper' +- 'REST' +- 'Tabular' +- 'Data Lake' +- 'Iceberg' +'show_related_blogs': true +'doc_type': 'guide' +--- + +import ExperimentalBadge from '@theme/badges/ExperimentalBadge'; + + + +:::note +与 Lakekeeper 目录的集成仅适用于 Iceberg 表。此集成支持 AWS S3 和其他云存储提供商。 +::: + +ClickHouse 支持与多个目录(Unity、Glue、REST、Polaris 等)的集成。本指南将引导您使用 ClickHouse 查询数据,并使用 [Lakekeeper](https://docs.lakekeeper.io/) 目录。 + +Lakekeeper 是一个开源的 Apache Iceberg REST 目录实现,提供: +- **Rust 原生** 实现,具有高性能和可靠性 +- **REST API** 符合 Iceberg REST 目录规范 +- **云存储** 与兼容 S3 的存储集成 + +:::note +由于此功能是实验性的,您需要使用以下命令启用它: +`SET allow_experimental_database_iceberg = 1;` +::: + +## 本地开发设置 {#local-development-setup} + +对于本地开发和测试,您可以使用容器化的 Lakekeeper 设置。此方法非常适合学习、原型设计和开发环境。 + +### 先决条件 {#local-prerequisites} + +1. **Docker 和 Docker Compose**:确保已安装并运行 Docker +2. **示例设置**:您可以使用 Lakekeeper docker-compose 设置 + +### 设置本地 Lakekeeper 目录 {#setting-up-local-lakekeeper-catalog} + +您可以使用官方的 [Lakekeeper docker-compose 设置](https://github.com/lakekeeper/lakekeeper/tree/main/examples/minimal),该设置提供了一个完整的环境,包括 Lakekeeper、PostgreSQL 元数据后端和 MinIO 对象存储。 + +**步骤 1:** 创建一个新文件夹以运行示例,然后创建一个文件 `docker-compose.yml`,配置如下: + +```yaml +version: '3.8' + +services: + lakekeeper: + image: quay.io/lakekeeper/catalog:latest + environment: + - LAKEKEEPER__PG_ENCRYPTION_KEY=This-is-NOT-Secure! + - LAKEKEEPER__PG_DATABASE_URL_READ=postgresql://postgres:postgres@db:5432/postgres + - LAKEKEEPER__PG_DATABASE_URL_WRITE=postgresql://postgres:postgres@db:5432/postgres + - RUST_LOG=info + command: ["serve"] + healthcheck: + test: ["CMD", "/home/nonroot/lakekeeper", "healthcheck"] + interval: 1s + timeout: 10s + retries: 10 + start_period: 30s + depends_on: + migrate: + condition: service_completed_successfully + db: + condition: service_healthy + minio: + condition: service_healthy + ports: + - 8181:8181 + networks: + - iceberg_net + + migrate: + image: quay.io/lakekeeper/catalog:latest-main + environment: + - LAKEKEEPER__PG_ENCRYPTION_KEY=This-is-NOT-Secure! + - LAKEKEEPER__PG_DATABASE_URL_READ=postgresql://postgres:postgres@db:5432/postgres + - LAKEKEEPER__PG_DATABASE_URL_WRITE=postgresql://postgres:postgres@db:5432/postgres + - RUST_LOG=info + restart: "no" + command: ["migrate"] + depends_on: + db: + condition: service_healthy + networks: + - iceberg_net + + bootstrap: + image: curlimages/curl + depends_on: + lakekeeper: + condition: service_healthy + restart: "no" + command: + - -w + - "%{http_code}" + - "-X" + - "POST" + - "-v" + - "http://lakekeeper:8181/management/v1/bootstrap" + - "-H" + - "Content-Type: application/json" + - "--data" + - '{"accept-terms-of-use": true}' + - "-o" + - "/dev/null" + networks: + - iceberg_net + + initialwarehouse: + image: curlimages/curl + depends_on: + lakekeeper: + condition: service_healthy + bootstrap: + condition: service_completed_successfully + restart: "no" + command: + - -w + - "%{http_code}" + - "-X" + - "POST" + - "-v" + - "http://lakekeeper:8181/management/v1/warehouse" + - "-H" + - "Content-Type: application/json" + - "--data" + - '{"warehouse-name": "demo", "project-id": "00000000-0000-0000-0000-000000000000", "storage-profile": {"type": "s3", "bucket": "warehouse-rest", "key-prefix": "", "assume-role-arn": null, "endpoint": "http://minio:9000", "region": "local-01", "path-style-access": true, "flavor": "minio", "sts-enabled": true}, "storage-credential": {"type": "s3", "credential-type": "access-key", "aws-access-key-id": "minio", "aws-secret-access-key": "ClickHouse_Minio_P@ssw0rd"}}' + - "-o" + - "/dev/null" + networks: + - iceberg_net + + db: + image: bitnami/postgresql:16.3.0 + environment: + - POSTGRESQL_USERNAME=postgres + - POSTGRESQL_PASSWORD=postgres + - POSTGRESQL_DATABASE=postgres + healthcheck: + test: ["CMD-SHELL", "pg_isready -U postgres -p 5432 -d postgres"] + interval: 2s + timeout: 10s + retries: 5 + start_period: 10s + volumes: + - postgres_data:/bitnami/postgresql + networks: + - iceberg_net + + minio: + image: bitnami/minio:2025.4.22 + environment: + - MINIO_ROOT_USER=minio + - MINIO_ROOT_PASSWORD=ClickHouse_Minio_P@ssw0rd + - MINIO_API_PORT_NUMBER=9000 + - MINIO_CONSOLE_PORT_NUMBER=9001 + - MINIO_SCHEME=http + - MINIO_DEFAULT_BUCKETS=warehouse-rest + networks: + iceberg_net: + aliases: + - warehouse-rest.minio + ports: + - "9002:9000" + - "9003:9001" + healthcheck: + test: ["CMD", "mc", "ls", "local", "|", "grep", "warehouse-rest"] + interval: 2s + timeout: 10s + retries: 3 + start_period: 15s + volumes: + - minio_data:/bitnami/minio/data + + clickhouse: + image: clickhouse/clickhouse-server:head + container_name: lakekeeper-clickhouse + user: '0:0' # Ensures root permissions + ports: + - "8123:8123" + - "9000:9000" + volumes: + - clickhouse_data:/var/lib/clickhouse + - ./clickhouse/data_import:/var/lib/clickhouse/data_import # Mount dataset folder + networks: + - iceberg_net + environment: + - CLICKHOUSE_DB=default + - CLICKHOUSE_USER=default + - CLICKHOUSE_DO_NOT_CHOWN=1 + - CLICKHOUSE_PASSWORD= + depends_on: + lakekeeper: + condition: service_healthy + minio: + condition: service_healthy + +volumes: + postgres_data: + minio_data: + clickhouse_data: + +networks: + iceberg_net: + driver: bridge +``` + +**步骤 2:** 运行以下命令以启动服务: + +```bash +docker compose up -d +``` + +**步骤 3:** 等待所有服务就绪。您可以检查日志: + +```bash +docker-compose logs -f +``` + +:::note +Lakekeeper 设置要求首先将示例数据加载到 Iceberg 表中。在通过 ClickHouse 查询它们之前,请确保环境已创建并填充了表。表的可用性取决于特定的 docker-compose 设置和示例数据加载脚本。 +::: + +### 连接到本地 Lakekeeper 目录 {#connecting-to-local-lakekeeper-catalog} + +连接到您的 ClickHouse 容器: + +```bash +docker exec -it lakekeeper-clickhouse clickhouse-client +``` + +然后创建与 Lakekeeper 目录的数据库连接: + +```sql +SET allow_experimental_database_iceberg = 1; + +CREATE DATABASE demo +ENGINE = DataLakeCatalog('http://lakekeeper:8181/catalog', 'minio', 'ClickHouse_Minio_P@ssw0rd') +SETTINGS catalog_type = 'rest', storage_endpoint = 'http://minio:9002/warehouse-rest', warehouse = 'demo' +``` + +## 使用 ClickHouse 查询 Lakekeeper 目录表 {#querying-lakekeeper-catalog-tables-using-clickhouse} + +现在连接已建立,您可以开始通过 Lakekeeper 目录进行查询。例如: + +```sql +USE demo; + +SHOW TABLES; +``` + +如果您的设置包含示例数据(例如出租车数据集),您应该看到类似的表: + +```sql title="Response" +┌─name──────────┐ +│ default.taxis │ +└───────────────┘ +``` + +:::note +如果您没有看到任何表,通常意味着: +1. 环境尚未创建示例表 +2. Lakekeeper 目录服务未完全初始化 +3. 示例数据加载过程尚未完成 + +您可以检查 Spark 日志以查看表创建进度: +```bash +docker-compose logs spark +``` +::: + +要查询一个表(如果可用): + +```sql +SELECT count(*) FROM `default.taxis`; +``` + +```sql title="Response" +┌─count()─┐ +│ 2171187 │ +└─────────┘ +``` + +:::note 反引号要求 +反引号是必需的,因为 ClickHouse 不支持多个命名空间。 +::: + +要检查表的 DDL: + +```sql +SHOW CREATE TABLE `default.taxis`; +``` + +```sql title="Response" +┌─statement─────────────────────────────────────────────────────────────────────────────────────┐ +│ CREATE TABLE demo.`default.taxis` │ +│ ( │ +│ `VendorID` Nullable(Int64), │ +│ `tpep_pickup_datetime` Nullable(DateTime64(6)), │ +│ `tpep_dropoff_datetime` Nullable(DateTime64(6)), │ +│ `passenger_count` Nullable(Float64), │ +│ `trip_distance` Nullable(Float64), │ +│ `RatecodeID` Nullable(Float64), │ +│ `store_and_fwd_flag` Nullable(String), │ +│ `PULocationID` Nullable(Int64), │ +│ `DOLocationID` Nullable(Int64), │ +│ `payment_type` Nullable(Int64), │ +│ `fare_amount` Nullable(Float64), │ +│ `extra` Nullable(Float64), │ +│ `mta_tax` Nullable(Float64), │ +│ `tip_amount` Nullable(Float64), │ +│ `tolls_amount` Nullable(Float64), │ +│ `improvement_surcharge` Nullable(Float64), │ +│ `total_amount` Nullable(Float64), │ +│ `congestion_surcharge` Nullable(Float64), │ +│ `airport_fee` Nullable(Float64) │ +│ ) │ +│ ENGINE = Iceberg('http://minio:9002/warehouse-rest/warehouse/default/taxis/', 'minio', '[HIDDEN]') │ +└───────────────────────────────────────────────────────────────────────────────────────────────┘ +``` + +## 将数据从您的数据湖加载到 ClickHouse {#loading-data-from-your-data-lake-into-clickhouse} + +如果您需要将数据从 Lakekeeper 目录加载到 ClickHouse,请首先创建一个本地 ClickHouse 表: + +```sql +CREATE TABLE taxis +( + `VendorID` Int64, + `tpep_pickup_datetime` DateTime64(6), + `tpep_dropoff_datetime` DateTime64(6), + `passenger_count` Float64, + `trip_distance` Float64, + `RatecodeID` Float64, + `store_and_fwd_flag` String, + `PULocationID` Int64, + `DOLocationID` Int64, + `payment_type` Int64, + `fare_amount` Float64, + `extra` Float64, + `mta_tax` Float64, + `tip_amount` Float64, + `tolls_amount` Float64, + `improvement_surcharge` Float64, + `total_amount` Float64, + `congestion_surcharge` Float64, + `airport_fee` Float64 +) +ENGINE = MergeTree() +PARTITION BY toYYYYMM(tpep_pickup_datetime) +ORDER BY (VendorID, tpep_pickup_datetime, PULocationID, DOLocationID); +``` + +然后通过 `INSERT INTO SELECT` 从您的 Lakekeeper 目录表加载数据: + +```sql +INSERT INTO taxis +SELECT * FROM demo.`default.taxis`; +``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/data_lake/lakekeeper_catalog.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/data_lake/lakekeeper_catalog.md.hash new file mode 100644 index 00000000000..7ffb7caa53a --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/data_lake/lakekeeper_catalog.md.hash @@ -0,0 +1 @@ +61d991a38b8260f6 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/data_lake/nessie_catalog.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/data_lake/nessie_catalog.md new file mode 100644 index 00000000000..fc8bbb4438b --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/data_lake/nessie_catalog.md @@ -0,0 +1,290 @@ +--- +'slug': '/use-cases/data-lake/nessie-catalog' +'sidebar_label': 'Nessie 目录' +'title': 'Nessie 目录' +'pagination_prev': null +'pagination_next': null +'description': '在本指南中,我们将引导您通过使用 ClickHouse 和 Nessie 目录查询您的数据的步骤。' +'keywords': +- 'Nessie' +- 'REST' +- 'Transactional' +- 'Data Lake' +- 'Iceberg' +- 'Git-like' +'show_related_blogs': true +'doc_type': 'guide' +--- + +import ExperimentalBadge from '@theme/badges/ExperimentalBadge'; + + + +:::note +与 Nessie Catalog 的集成仅与 Iceberg 表兼容。 +该集成支持 AWS S3 及其他云存储提供商。 +::: + +ClickHouse 支持与多个目录(Unity、Glue、REST、Polaris 等)的集成。本指南将指导您如何使用 ClickHouse 与[Nessie](https://projectnessie.org/)目录查询数据。 + +Nessie 是一个开源的事务性目录,适用于数据湖,提供: +- **受 Git 启发的** 数据版本控制,具有分支和提交功能 +- **跨表事务**和可见性保证 +- **与 Iceberg REST 目录规范**兼容的 REST API +- **开放数据湖**方法,支持 Hive、Spark、Dremio、Trino 等 +- **生产就绪的** Docker 或 Kubernetes 部署 + +:::note +由于此功能为实验性,您需要通过以下方式启用它: +`SET allow_experimental_database_iceberg = 1;` +::: + +## 本地开发设置 {#local-development-setup} + +对于本地开发和测试,您可以使用容器化的 Nessie 设置。这种方法非常适合学习、原型开发和开发环境。 + +### 先决条件 {#local-prerequisites} + +1. **Docker 和 Docker Compose**:确保已安装并正在运行 Docker +2. **示例设置**:您可以使用官方的 Nessie docker-compose 设置 + +### 设置本地 Nessie 目录 {#setting-up-local-nessie-catalog} + +您可以使用官方的 [Nessie docker-compose 设置](https://projectnessie.org/guides/setting-up/),该设置提供了一个完整的环境,包括 Nessie、内存版本库和用于对象存储的 MinIO。 + +**步骤 1:** 创建一个新的文件夹以运行示例,然后创建一个文件 `docker-compose.yml`,配置如下: + +```yaml +version: '3.8' + +services: + nessie: + image: ghcr.io/projectnessie/nessie:latest + ports: + - "19120:19120" + environment: + - nessie.version.store.type=IN_MEMORY + - nessie.catalog.default-warehouse=warehouse + - nessie.catalog.warehouses.warehouse.location=s3://my-bucket/ + - nessie.catalog.service.s3.default-options.endpoint=http://minio:9000/ + - nessie.catalog.service.s3.default-options.access-key=urn:nessie-secret:quarkus:nessie.catalog.secrets.access-key + - nessie.catalog.service.s3.default-options.path-style-access=true + - nessie.catalog.service.s3.default-options.auth-type=STATIC + - nessie.catalog.secrets.access-key.name=admin + - nessie.catalog.secrets.access-key.secret=password + - nessie.catalog.service.s3.default-options.region=us-east-1 + - nessie.server.authentication.enabled=false + depends_on: + minio: + condition: service_healthy + networks: + - iceberg_net + + minio: + image: quay.io/minio/minio + ports: + - "9002:9000" + - "9003:9001" + environment: + - MINIO_ROOT_USER=admin + - MINIO_ROOT_PASSWORD=password + - MINIO_REGION=us-east-1 + healthcheck: + test: ["CMD", "mc", "ready", "local"] + interval: 5s + timeout: 10s + retries: 5 + start_period: 30s + entrypoint: > + /bin/sh -c " + minio server /data --console-address ':9001' & + sleep 10; + mc alias set myminio http://localhost:9000 admin password; + mc mb myminio/my-bucket --ignore-existing; + tail -f /dev/null" + networks: + - iceberg_net + + clickhouse: + image: clickhouse/clickhouse-server:head + container_name: nessie-clickhouse + user: '0:0' # Ensures root permissions + ports: + - "8123:8123" + - "9000:9000" + volumes: + - clickhouse_data:/var/lib/clickhouse + - ./clickhouse/data_import:/var/lib/clickhouse/data_import # Mount dataset folder + networks: + - iceberg_net + environment: + - CLICKHOUSE_DB=default + - CLICKHOUSE_USER=default + - CLICKHOUSE_DO_NOT_CHOWN=1 + - CLICKHOUSE_PASSWORD= + depends_on: + nessie: + condition: service_started + minio: + condition: service_healthy + +volumes: + clickhouse_data: + +networks: + iceberg_net: + driver: bridge +``` + +**步骤 2:** 运行以下命令以启动服务: + +```bash +docker compose up -d +``` + +**步骤 3:** 等待所有服务准备就绪。您可以检查日志: + +```bash +docker-compose logs -f +``` + +:::note +Nessie 设置使用内存版本库,要求首先将示例数据加载到 Iceberg 表中。在通过 ClickHouse 尝试查询它们之前,请确保环境已经创建并填充了表。 +::: + +### 连接到本地 Nessie 目录 {#connecting-to-local-nessie-catalog} + +连接到您的 ClickHouse 容器: + +```bash +docker exec -it nessie-clickhouse clickhouse-client +``` + +然后创建到 Nessie 目录的数据库连接: + +```sql +SET allow_experimental_database_iceberg = 1; + +CREATE DATABASE demo +ENGINE = DataLakeCatalog('http://nessie:19120/iceberg', 'admin', 'password') +SETTINGS catalog_type = 'rest', storage_endpoint = 'http://minio:9002/my-bucket', warehouse = 'warehouse' +``` + +## 使用 ClickHouse 查询 Nessie 目录表 {#querying-nessie-catalog-tables-using-clickhouse} + +现在连接已建立,您可以开始通过 Nessie 目录进行查询。例如: + +```sql +USE demo; + +SHOW TABLES; +``` + +如果您的设置包括示例数据(例如出租车数据集),您应该会看到如下表: + +```sql title="Response" +┌─name──────────┐ +│ default.taxis │ +└───────────────┘ +``` + +:::note +如果您没有看到任何表,通常意味着: +1. 环境尚未创建示例表 +2. Nessie 目录服务尚未完全初始化 +3. 示例数据加载过程尚未完成 + +您可以检查 Nessie 日志以查看目录活动: +```bash +docker-compose logs nessie +``` +::: + +要查询表(如果可用): + +```sql +SELECT count(*) FROM `default.taxis`; +``` + +```sql title="Response" +┌─count()─┐ +│ 2171187 │ +└─────────┘ +``` + +:::note 需要反引号 +需要反引号,因为 ClickHouse 不支持多个命名空间。 +::: + +要检查表的 DDL: + +```sql +SHOW CREATE TABLE `default.taxis`; +``` + +```sql title="Response" +┌─statement─────────────────────────────────────────────────────────────────────────────────────┐ +│ CREATE TABLE demo.`default.taxis` │ +│ ( │ +│ `VendorID` Nullable(Int64), │ +│ `tpep_pickup_datetime` Nullable(DateTime64(6)), │ +│ `tpep_dropoff_datetime` Nullable(DateTime64(6)), │ +│ `passenger_count` Nullable(Float64), │ +│ `trip_distance` Nullable(Float64), │ +│ `RatecodeID` Nullable(Float64), │ +│ `store_and_fwd_flag` Nullable(String), │ +│ `PULocationID` Nullable(Int64), │ +│ `DOLocationID` Nullable(Int64), │ +│ `payment_type` Nullable(Int64), │ +│ `fare_amount` Nullable(Float64), │ +│ `extra` Nullable(Float64), │ +│ `mta_tax` Nullable(Float64), │ +│ `tip_amount` Nullable(Float64), │ +│ `tolls_amount` Nullable(Float64), │ +│ `improvement_surcharge` Nullable(Float64), │ +│ `total_amount` Nullable(Float64), │ +│ `congestion_surcharge` Nullable(Float64), │ +│ `airport_fee` Nullable(Float64) │ +│ ) │ +│ ENGINE = Iceberg('http://localhost:9002/my-bucket/default/taxis/', 'admin', '[HIDDEN]') │ +└───────────────────────────────────────────────────────────────────────────────────────────────┘ +``` + +## 从数据湖将数据加载到 ClickHouse {#loading-data-from-your-data-lake-into-clickhouse} + +如果您需要从 Nessie 目录将数据加载到 ClickHouse,请首先创建一个本地 ClickHouse 表: + +```sql +CREATE TABLE taxis +( + `VendorID` Int64, + `tpep_pickup_datetime` DateTime64(6), + `tpep_dropoff_datetime` DateTime64(6), + `passenger_count` Float64, + `trip_distance` Float64, + `RatecodeID` Float64, + `store_and_fwd_flag` String, + `PULocationID` Int64, + `DOLocationID` Int64, + `payment_type` Int64, + `fare_amount` Float64, + `extra` Float64, + `mta_tax` Float64, + `tip_amount` Float64, + `tolls_amount` Float64, + `improvement_surcharge` Float64, + `total_amount` Float64, + `congestion_surcharge` Float64, + `airport_fee` Float64 +) +ENGINE = MergeTree() +PARTITION BY toYYYYMM(tpep_pickup_datetime) +ORDER BY (VendorID, tpep_pickup_datetime, PULocationID, DOLocationID); +``` + +然后通过 `INSERT INTO SELECT` 从 Nessie 目录表加载数据: + +```sql +INSERT INTO taxis +SELECT * FROM demo.`default.taxis`; +``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/data_lake/nessie_catalog.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/data_lake/nessie_catalog.md.hash new file mode 100644 index 00000000000..fb9c7d2d468 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/data_lake/nessie_catalog.md.hash @@ -0,0 +1 @@ +edc281272648ebd2 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/data_lake/rest_catalog.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/data_lake/rest_catalog.md new file mode 100644 index 00000000000..55e646f0833 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/data_lake/rest_catalog.md @@ -0,0 +1,232 @@ +--- +'slug': '/use-cases/data-lake/rest-catalog' +'sidebar_label': 'REST Catalog' +'title': 'REST Catalog' +'pagination_prev': null +'pagination_next': null +'description': '在本指南中,我们将带您了解如何使用 ClickHouse 和 REST Catalog 查询您的数据。' +'keywords': +- 'REST' +- 'Tabular' +- 'Data Lake' +- 'Iceberg' +'show_related_blogs': true +'doc_type': 'guide' +--- + +import ExperimentalBadge from '@theme/badges/ExperimentalBadge'; + + + +:::note +与 REST 目录的集成仅适用于 Iceberg 表。 +此集成支持 AWS S3 和其他云存储提供商。 +::: + +ClickHouse 支持与多个目录的集成(Unity、Glue、REST、Polaris 等)。本指南将引导您通过使用 ClickHouse 和 [REST Catalog](https://github.com/apache/iceberg/blob/main/open-api/rest-catalog-open-api.yaml/) 规范查询您的数据。 + +REST Catalog 是 Iceberg 目录的标准化 API 规范,支持多个平台,包括: +- **本地开发环境**(使用 docker-compose 设置) +- **托管服务** 如 Tabular.io +- **自托管的** REST 目录实现 + +:::note +由于此功能处于实验阶段,您需要使用以下命令启用它: +`SET allow_experimental_database_iceberg = 1;` +::: + +## 本地开发设置 {#local-development-setup} + +对于本地开发和测试,您可以使用容器化的 REST 目录设置。这种方法非常适合学习、原型设计和开发环境。 + +### 先决条件 {#local-prerequisites} + +1. **Docker 和 Docker Compose**:确保 Docker 已安装并正在运行 +2. **示例设置**:您可以使用各种 docker-compose 设置(请参阅下面的替代 Docker 镜像) + +### 设置本地 REST 目录 {#setting-up-local-rest-catalog} + +您可以使用各种容器化的 REST 目录实现,例如 **[Databricks docker-spark-iceberg](https://github.com/databricks/docker-spark-iceberg/blob/main/docker-compose.yml?ref=blog.min.io)**,该实现提供了一个完整的 Spark + Iceberg + REST 目录环境,适合使用 docker-compose 测试 Iceberg 集成。 + +**步骤 1:** 在运行示例的文件夹中创建一个新文件夹,然后创建一个名为 `docker-compose.yml` 的文件,并使用 [Databricks docker-spark-iceberg](https://github.com/databricks/docker-spark-iceberg/blob/main/docker-compose.yml?ref=blog.min.io) 的配置。 + +**步骤 2:** 接下来,创建一个名为 `docker-compose.override.yml` 的文件,并将以下 ClickHouse 容器配置放入其中: + +```yaml +version: '3.8' + +services: + clickhouse: + image: clickhouse/clickhouse-server:25.5.6 + container_name: clickhouse + user: '0:0' # Ensures root permissions + ports: + - "8123:8123" + - "9002:9000" + volumes: + - ./clickhouse:/var/lib/clickhouse + - ./clickhouse/data_import:/var/lib/clickhouse/data_import # Mount dataset folder + networks: + - iceberg_net + environment: + - CLICKHOUSE_DB=default + - CLICKHOUSE_USER=default + - CLICKHOUSE_DO_NOT_CHOWN=1 + - CLICKHOUSE_PASSWORD= +``` + +**步骤 3:** 运行以下命令以启动服务: + +```bash +docker compose up +``` + +**步骤 4:** 等待所有服务准备好。您可以检查日志: + +```bash +docker-compose logs -f +``` + +:::note +REST 目录设置需要首先加载示例数据到 Iceberg 表中。在尝试通过 ClickHouse 查询它们之前,请确保 Spark 环境已创建并填充了表。表的可用性取决于特定的 docker-compose 设置和示例数据加载脚本。 +::: + +### 连接到本地 REST 目录 {#connecting-to-local-rest-catalog} + +连接到您的 ClickHouse 容器: + +```bash +docker exec -it clickhouse clickhouse-client +``` + +然后创建到 REST 目录的数据库连接: + +```sql +SET allow_experimental_database_iceberg = 1; + +CREATE DATABASE demo +ENGINE = DataLakeCatalog('http://rest:8181/v1', 'admin', 'password') +SETTINGS + catalog_type = 'rest', + storage_endpoint = 'http://minio:9000/lakehouse', + warehouse = 'demo' +``` + +## 使用 ClickHouse 查询 REST 目录表 {#querying-rest-catalog-tables-using-clickhouse} + +现在连接已建立,您可以开始通过 REST 目录进行查询。例如: + +```sql +USE demo; + +SHOW TABLES; +``` + +如果您的设置包含示例数据(例如出租车数据集),您应该能够看到如下表格: + +```sql title="Response" +┌─name──────────┐ +│ default.taxis │ +└───────────────┘ +``` + +:::note +如果您未看到任何表,这通常意味着: +1. Spark 环境尚未创建示例表 +2. REST 目录服务尚未完全初始化 +3. 示例数据加载过程尚未完成 + +您可以检查 Spark 日志以查看表创建进度: +```bash +docker-compose logs spark +``` +::: + +要查询表(如果可用): + +```sql +SELECT count(*) FROM `default.taxis`; +``` + +```sql title="Response" +┌─count()─┐ +│ 2171187 │ +└─────────┘ +``` + +:::note 需要反引号 +需要反引号,因为 ClickHouse 不支持多个命名空间。 +::: + +要检查表 DDL: + +```sql +SHOW CREATE TABLE `default.taxis`; +``` + +```sql title="Response" +┌─statement─────────────────────────────────────────────────────────────────────────────────────┐ +│ CREATE TABLE demo.`default.taxis` │ +│ ( │ +│ `VendorID` Nullable(Int64), │ +│ `tpep_pickup_datetime` Nullable(DateTime64(6)), │ +│ `tpep_dropoff_datetime` Nullable(DateTime64(6)), │ +│ `passenger_count` Nullable(Float64), │ +│ `trip_distance` Nullable(Float64), │ +│ `RatecodeID` Nullable(Float64), │ +│ `store_and_fwd_flag` Nullable(String), │ +│ `PULocationID` Nullable(Int64), │ +│ `DOLocationID` Nullable(Int64), │ +│ `payment_type` Nullable(Int64), │ +│ `fare_amount` Nullable(Float64), │ +│ `extra` Nullable(Float64), │ +│ `mta_tax` Nullable(Float64), │ +│ `tip_amount` Nullable(Float64), │ +│ `tolls_amount` Nullable(Float64), │ +│ `improvement_surcharge` Nullable(Float64), │ +│ `total_amount` Nullable(Float64), │ +│ `congestion_surcharge` Nullable(Float64), │ +│ `airport_fee` Nullable(Float64) │ +│ ) │ +│ ENGINE = Iceberg('http://minio:9000/lakehouse/warehouse/default/taxis/', 'admin', '[HIDDEN]') │ +└───────────────────────────────────────────────────────────────────────────────────────────────┘ +``` + +## 从数据湖加载数据到 ClickHouse {#loading-data-from-your-data-lake-into-clickhouse} + +如果您需要将数据从 REST 目录加载到 ClickHouse,请首先创建一个本地 ClickHouse 表: + +```sql +CREATE TABLE taxis +( + `VendorID` Int64, + `tpep_pickup_datetime` DateTime64(6), + `tpep_dropoff_datetime` DateTime64(6), + `passenger_count` Float64, + `trip_distance` Float64, + `RatecodeID` Float64, + `store_and_fwd_flag` String, + `PULocationID` Int64, + `DOLocationID` Int64, + `payment_type` Int64, + `fare_amount` Float64, + `extra` Float64, + `mta_tax` Float64, + `tip_amount` Float64, + `tolls_amount` Float64, + `improvement_surcharge` Float64, + `total_amount` Float64, + `congestion_surcharge` Float64, + `airport_fee` Float64 +) +ENGINE = MergeTree() +PARTITION BY toYYYYMM(tpep_pickup_datetime) +ORDER BY (VendorID, tpep_pickup_datetime, PULocationID, DOLocationID); +``` + +然后通过 `INSERT INTO SELECT` 从您的 REST 目录表加载数据: + +```sql +INSERT INTO taxis +SELECT * FROM demo.`default.taxis`; +``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/data_lake/rest_catalog.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/data_lake/rest_catalog.md.hash new file mode 100644 index 00000000000..bf021c61ed1 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/data_lake/rest_catalog.md.hash @@ -0,0 +1 @@ +122c195c91f5c856 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/data_lake/unity_catalog.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/data_lake/unity_catalog.md index 3127c620113..a75195dda52 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/data_lake/unity_catalog.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/data_lake/unity_catalog.md @@ -4,11 +4,12 @@ 'title': 'Unity Catalog' 'pagination_prev': null 'pagination_next': null -'description': '在本指南中,我们将带您了解如何使用 ClickHouse 和 Unity Catalog 查询 S3 存储桶中的数据。' +'description': '在本指南中,我们将引导您完成使用 ClickHouse 和 Unity Catalog 查询 S3 存储桶中数据的步骤。' 'keywords': - 'Unity' - 'Data Lake' 'show_related_blogs': true +'doc_type': 'guide' --- import ExperimentalBadge from '@theme/badges/ExperimentalBadge'; @@ -16,29 +17,34 @@ import ExperimentalBadge from '@theme/badges/ExperimentalBadge'; :::note -与 Unity Catalog 的集成适用于托管和外部表。 -目前此集成仅在 AWS 上受支持。 +与 Unity Catalog 的集成适用于管理表和外部表。 +此集成当前仅支持 AWS。 ::: -ClickHouse 支持与多个目录(Unity、Glue、Polaris 等)的集成。本指南将引导您通过 ClickHouse 查询由 Databricks 管理的数据,并使用 [Unity Catalog](https://www.databricks.com/product/unity-catalog) 。 +ClickHouse 支持与多个目录(如 Unity、Glue、Polaris 等)的集成。本指南将引导您通过 ClickHouse 查询由 Databricks 管理的数据以及 [Unity Catalog](https://www.databricks.com/product/unity-catalog)。 -Databricks 支持多种数据格式用于其数据湖房。通过 ClickHouse,您可以将 Unity Catalog 表查询为 Delta 和 Iceberg。 +Databricks 支持其数据湖屋的多种数据格式。使用 ClickHouse,您可以将 Unity Catalog 表作为 Delta 和 Iceberg 进行查询。 + +:::note +由于此功能处于实验阶段,您需要使用以下命令启用它: +`SET allow_experimental_database_unity_catalog = 1;` +::: ## 在 Databricks 中配置 Unity {#configuring-unity-in-databricks} -为了让 ClickHouse 与 Unity Catalog 互动,您需要确保 Unity Catalog 配置允许与外部读取器的互动。这可以通过遵循 [“启用外部数据访问 Unity Catalog”](https://docs.databricks.com/aws/en/external-access/admin) 指南来实现。 +为了让 ClickHouse 与 Unity Catalog 进行交互,您需要确保 Unity Catalog 已配置为允许外部读取器进行交互。这可以通过遵循 [“启用对 Unity Catalog 的外部数据访问”](https://docs.databricks.com/aws/en/external-access/admin) 指南来实现。 -除了启用外部访问外,请确保配置集成的主体在包含表的模式上具有 `EXTERNAL USE SCHEMA` [特权](https://docs.databricks.com/aws/en/external-access/admin#external-schema)。 +除了启用外部访问外,还需要确保配置集成的主体在包含表的模式上具有 `EXTERNAL USE SCHEMA` [权限](https://docs.databricks.com/aws/en/external-access/admin#external-schema)。 -一旦您的目录配置完成,您必须为 ClickHouse 生成凭据。可以根据您与 Unity 的互动模式使用两种不同的方法: +一旦您的目录配置完成,您必须为 ClickHouse 生成凭证。可以根据与 Unity 的交互模式使用两种不同的方法: -* 对于 Iceberg 客户端,使用服务主体进行 [身份验证](https://docs.databricks.com/aws/en/dev-tools/auth/oauth-m2m)。 +* 对于 Iceberg 客户端,使用作为 [服务主体](https://docs.databricks.com/aws/en/dev-tools/auth/oauth-m2m) 的身份验证。 -* 对于 Delta 客户端,使用个人访问令牌( [PAT](https://docs.databricks.com/aws/en/dev-tools/auth/pat))。 +* 对于 Delta 客户端,使用个人访问令牌 ([PAT](https://docs.databricks.com/aws/en/dev-tools/auth/pat))。 ## 在 Unity Catalog 和 ClickHouse 之间创建连接 {#creating-a-connection-between-unity-catalog-and-clickhouse} -配置好 Unity Catalog 并设置好身份验证后,建立 ClickHouse 和 Unity Catalog 之间的连接。 +在配置好 Unity Catalog 并完成身份验证后,建立 ClickHouse 与 Unity Catalog 之间的连接。 ### 读取 Delta {#read-delta} @@ -59,7 +65,7 @@ oauth_server_uri = 'https://.cloud.databricks.com/oidc/v1/token', ## 使用 ClickHouse 查询 Unity Catalog 表 {#querying-unity-catalog-tables-using-clickhouse} -连接建立后,您可以开始通过 Unity Catalog 查询。例如: +现在连接已建立,您可以开始通过 Unity Catalog 进行查询。例如: ```sql USE unity; @@ -101,7 +107,7 @@ SHOW TABLES; └────────────────────────────────────────────────────┘ ``` -如果您使用 Iceberg 客户端,则仅会显示启用了 Uniform 的 Delta 表: +如果您使用的是 Iceberg 客户端,则仅会显示启用 Uniform 的 Delta 表: ```sql SHOW TABLES @@ -111,14 +117,14 @@ SHOW TABLES └────────────────────┘ ``` -要查询表: +要查询一个表: ```sql SELECT count(*) FROM `uniform.delta_hits` ``` -:::note 需要反引号 -需要反引号,因为 ClickHouse 不支持多个命名空间。 +:::note 反引号要求 +反引号是必需的,因为 ClickHouse 不支持多个命名空间。 ::: 要检查表的 DDL: @@ -147,9 +153,9 @@ ENGINE = Iceberg('s3://); ``` -## 将数据从数据湖加载到 ClickHouse {#loading-data-from-your-data-lake-into-clickhouse} +## 从您的数据湖加载数据到 ClickHouse {#loading-data-from-your-data-lake-into-clickhouse} -如果您需要将数据从 Databricks 加载到 ClickHouse,请首先创建一个本地 ClickHouse 表: +如果您需要从 Databricks 加载数据到 ClickHouse,请首先创建一个本地 ClickHouse 表: ```sql CREATE TABLE hits @@ -172,7 +178,7 @@ CREATE TABLE hits PRIMARY KEY (CounterID, EventDate, UserID, EventTime, WatchID); ``` -然后通过 `INSERT INTO SELECT` 从 Unity Catalog 表中加载数据: +然后通过 `INSERT INTO SELECT` 从您的 Unity Catalog 表加载数据: ```sql INSERT INTO hits SELECT * FROM unity_uniform.`uniform.delta_hits`; diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/data_lake/unity_catalog.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/data_lake/unity_catalog.md.hash index 2b29296684e..29605562c87 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/data_lake/unity_catalog.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/data_lake/unity_catalog.md.hash @@ -1 +1 @@ -7a03ddb4a0a1f99a +1232ebd9ea307aa6 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/index.md index 7bc300628fc..6ae2c120c21 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/index.md @@ -3,13 +3,15 @@ 'title': '使用案例指南' 'pagination_prev': null 'pagination_next': null -'description': '使用案例指南的登录页面' +'description': '使用案例指南的着陆页' +'doc_type': 'landing-page' --- -在这一部分文档中,您可以找到我们的使用案例指南。 +在本节文档中,您可以找到我们的使用案例指南。 -| 页面 | 描述 | -|-----------------------------------------|---------------------------------------------------------------------| -| [Observability](observability/index.md) | 有关如何设置和使用 ClickHouse 进行观察的使用案例指南 | -| [Time-Series](time-series/index.md) | 有关如何设置和使用 ClickHouse 进行时间序列分析的使用案例指南 | -| [Data Lake](data_lake/index.md) | 有关 ClickHouse 中数据湖的使用案例指南 | +| 页面 | 描述 | +|--------------------------------|-------------------------------------------------------------------------------| +| [可观察性](observability/index.md) | 如何设置和使用 ClickHouse 进行可观察性的使用案例指南 | +| [时间序列](time-series/index.md) | 如何设置和使用 ClickHouse 进行时间序列的使用案例指南 | +| [数据湖](data_lake/index.md) | 在 ClickHouse 中的数据湖使用案例指南 | +| [机器学习与生成式人工智能](/use-cases/AI/ask-ai) | ClickHouse 的机器学习和生成式人工智能应用的使用案例指南 | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/index.md.hash index 12b6ba839d7..7319021595c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/index.md.hash @@ -1 +1 @@ -11515e545d5f2858 +5081d8ef921e3f11 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/build-your-own/demo-application.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/build-your-own/demo-application.md index 99153b83cf6..65b4d1fced0 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/build-your-own/demo-application.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/build-your-own/demo-application.md @@ -1,6 +1,6 @@ --- 'title': '演示应用程序' -'description': '用于可观测性的演示应用程序' +'description': '用于可观察性的演示应用程序' 'slug': '/observability/demo-application' 'keywords': - 'observability' @@ -10,6 +10,7 @@ - 'OpenTelemetry' - 'Grafana' - 'OTel' +'doc_type': 'guide' --- -OpenTelemetry 项目包含一个 [演示应用程序](https://opentelemetry.io/docs/demo/)。一个维护的该应用程序的分支,使用 ClickHouse 作为日志和跟踪的数据源,可以在 [这里](https://github.com/ClickHouse/opentelemetry-demo) 找到。可以按照 [官方演示说明](https://opentelemetry.io/docs/demo/docker-deployment/) 使用 docker 部署此演示。除了 [现有组件](https://opentelemetry.io/docs/demo/collector-data-flow-dashboard/)之外,将部署一个 ClickHouse 实例,用于日志和跟踪的存储。 +OpenTelemetry 项目包括一个 [演示应用程序](https://opentelemetry.io/docs/demo/)。一个维护中的该应用程序的分支,以 ClickHouse 作为日志和追踪的数据源,可以在 [这里](https://github.com/ClickHouse/opentelemetry-demo) 找到。可以按照 [官方演示说明](https://opentelemetry.io/docs/demo/docker-deployment/) 使用 Docker 部署此演示。在 [现有组件](https://opentelemetry.io/docs/demo/collector-data-flow-dashboard/) 的基础上,将部署一个 ClickHouse 实例并用于日志和追踪的存储。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/build-your-own/demo-application.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/build-your-own/demo-application.md.hash index d81a420bceb..cb4388e2678 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/build-your-own/demo-application.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/build-your-own/demo-application.md.hash @@ -1 +1 @@ -fe03fac75fa6a566 +565ac91ae89a3c4e diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/build-your-own/grafana.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/build-your-own/grafana.md index f25e5349ead..249fdf9041b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/build-your-own/grafana.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/build-your-own/grafana.md @@ -11,6 +11,7 @@ - 'Grafana' - 'OTel' 'show_related_blogs': true +'doc_type': 'guide' --- import observability_15 from '@site/static/images/use-cases/observability/observability-15.png'; @@ -28,30 +29,29 @@ import Image from '@theme/IdealImage'; # 使用 Grafana 和 ClickHouse 进行可观察性 -Grafana 是 ClickHouse 中可观察性数据的首选可视化工具。这是通过使用官方的 ClickHouse 插件实现的。用户可以按照 [这里](/integrations/grafana) 的安装说明进行操作。 +Grafana 是 ClickHouse 中可观察性数据的首选可视化工具。通过使用 Grafana 的官方 ClickHouse 插件来实现。用户可以按照 [此处](/integrations/grafana) 的安装说明进行操作。 -该插件的 V4 版本使日志和追踪成为新版查询构建器体验中的第一公民。这减少了 SRE 需要编写 SQL 查询的需求,并简化了基于 SQL 的可观察性,推动了这一新兴范例的发展。 -其中一部分工作是将 OpenTelemetry (OTel) 置于插件的核心,因为我们相信这将是未来几年 SQL 基于可观察性的基础,以及数据将如何被收集。 +插件 V4 使日志和跟踪成为新查询构建器体验中的一等公民。这减少了 SREs 编写 SQL 查询的需要,简化了基于 SQL 的可观察性,推动了这一新兴范式的发展。其中一部分是将 OpenTelemetry (OTel) 放在插件的核心位置,因为我们相信这将成为未来几年基于 SQL 的可观察性的基础以及数据收集的方式。 ## OpenTelemetry 集成 {#open-telemetry-integration} -在 Grafana 中配置 ClickHouse 数据源时,插件允许用户为日志和追踪指定一个默认数据库和表,并确定这些表是否遵循 OTel 架构。这使插件能够返回正确的列,以便在 Grafana 中正确渲染日志和追踪。如果您对默认的 OTel 架构进行了更改,并希望使用自己的列名,可以进行相应指定。对于像时间 (`Timestamp`)、日志级别 (`SeverityText`) 或消息体 (`Body`) 等列的默认 OTel 列名的使用,则无需做出更改。 +在 Grafana 中配置 ClickHouse 数据源时,插件允许用户指定日志和跟踪的默认数据库和表,以及这些表是否符合 OTel 架构。这使插件能够返回在 Grafana 中正确呈现日志和跟踪所需的列。如果您对默认 OTel 架构进行了更改并希望使用自己的列名,可以进行相应的指定。对于时间(`Timestamp`)、日志级别(`SeverityText`)或消息体(`Body`)等列,使用默认的 OTel 列名不需要进行更改。 -:::note HTTP 或本机 -用户可以通过 HTTP 或本机协议将 Grafana 连接到 ClickHouse。后一种方式提供了边际性能优势,但在 Grafana 用户发出的聚合查询中,可能不那么明显。相反,HTTP 协议通常更容易供用户代理和检查。 +:::note HTTP 或原生协议 +用户可以通过 HTTP 或原生协议将 Grafana 连接到 ClickHouse。后者提供了边际性能优势,但在 Grafana 用户发出的聚合查询中可能不显著。相反,HTTP 协议通常更简单,便于用户进行代理和检查。 ::: -日志配置需要时间、日志级别和消息列,以便正确渲染日志。 +日志配置需要一个时间、日志级别和消息列,以便日志能够正确呈现。 -追踪配置稍微复杂一些(完整列表请参考 [这里](/engines/table-engines/mergetree-family/mergetree#mergetree-data-storage))。这里需要的列是为了使后续查询能够构建完整的追踪剖面。这些查询假设数据的结构与 OTel 相似,因此偏离标准架构显著的用户将需要使用视图来从这一特性受益。 +跟踪配置稍微复杂一些(完整列表见 [这里](/engines/table-engines/mergetree-family/mergetree#mergetree-data-storage))。这里所需的列是为了使随后的查询能够构建完整的跟踪概况,这些查询假设数据结构与 OTel 相似,因此显著偏离标准架构的用户需要使用视图才能使用此功能。 -配置完成后,用户可以访问 [Grafana Explore](https://grafana.com/docs/grafana/latest/explore/) 开始搜索日志和追踪。 +配置完成后,用户可以导航到 [Grafana Explore](https://grafana.com/docs/grafana/latest/explore/) 并开始搜索日志和跟踪。 ## 日志 {#logs} -如果遵循 Grafana 对日志的要求,用户可以在查询构建器中选择 `Query Type: Log` 并点击 `Run Query`。查询构建器将制定一个查询来列出日志,并确保正确渲染,例如: +如果遵循 Grafana 对日志的要求,用户可以在查询构建器中选择 `Query Type: Log` 并点击 `Run Query`。查询构建器将生成一个查询以列出日志并确保它们正确呈现,例如: ```sql SELECT Timestamp as timestamp, Body as body, SeverityText as level, TraceId as traceID FROM "default"."otel_logs" WHERE ( timestamp >= $__fromTime AND timestamp <= $__toTime ) ORDER BY timestamp DESC LIMIT 1000 @@ -59,17 +59,17 @@ SELECT Timestamp as timestamp, Body as body, SeverityText as level, TraceId as t -查询构建器提供了简单的手段来修改查询,避免用户需要编写 SQL。可以从查询构建器中进行过滤,包括查找包含关键词的日志。希望编写更复杂查询的用户可以切换到 SQL 编辑器。如果返回了适当的列,并且将 `logs` 选择为查询类型,结果将按日志渲染。日志渲染所需的列在 [这里](https://grafana.com/developers/plugin-tools/tutorials/build-a-logs-data-source-plugin#logs-data-frame-format) 列出。 +查询构建器提供了一种简单的方法来修改查询,避免用户编写 SQL 的需要。过滤,包括查找包含关键字的日志,可以在查询构建器中执行。希望编写更复杂查询的用户可以切换到 SQL 编辑器。只要返回适当的列,并选择 `logs` 作为查询类型,结果将被呈现为日志。用于日志呈现的必需列在 [这里](https://grafana.com/developers/plugin-tools/tutorials/build-a-logs-data-source-plugin#logs-data-frame-format) 列出。 -### 日志到追踪 {#logs-to-traces} +### 日志到跟踪 {#logs-to-traces} -如果日志包含追踪 ID,用户可以通过特定日志行导航到对应的追踪。 +如果日志包含跟踪 ID,用户可以从特定日志行导航到对应的跟踪。 -## 追踪 {#traces} +## 跟踪 {#traces} -类似于上述日志体验,如果满足 Grafana 渲染追踪所需的列(例如,通过使用 OTel 架构),查询构建器能够自动制定必要的查询。通过选择 `Query Type: Traces` 并点击 `Run Query`,将生成并执行一个类似于以下的查询(具体取决于你配置的列 - 以下假设使用 OTel): +与上述日志体验类似,如果满足 Grafana 渲染跟踪所需的列(例如,通过使用 OTel 架构),查询构建器能够自动生成必要的查询。通过选择 `Query Type: Traces` 并点击 `Run Query`,将生成并执行一个类似于以下的查询(根据您的配置列 - 以下假设使用 OTel): ```sql SELECT "TraceId" as traceID, @@ -84,33 +84,33 @@ WHERE ( Timestamp >= $__fromTime AND Timestamp <= $__toTime ) ORDER BY Timestamp DESC, Duration DESC LIMIT 1000 ``` -该查询返回 Grafana 预期的列名,渲染出如下所示的追踪表格。可以不需要编写 SQL 来对持续时间或其他列进行过滤。 +此查询返回 Grafana 期望的列名,渲染如下所示的跟踪表格。可以在不编写 SQL 的情况下对持续时间或其他列进行过滤。 希望编写更复杂查询的用户可以切换到 `SQL Editor`。 -### 查看追踪详情 {#view-trace-details} +### 查看跟踪详情 {#view-trace-details} -如上所示,追踪 ID 被渲染为可点击的链接。单击追踪 ID,用户可以选择通过链接 `View Trace` 查看相关的 spans。这将发出以下查询(假设 OTel 列),以检索所需结构的 spans,并将结果渲染为瀑布图。 +如上所示,跟踪 ID 被呈现为可点击的链接。点击跟踪 ID 后,用户可以选择通过链接 `View Trace` 查看相关的 span。这将发出以下查询(假设 OTel 列)以检索所需结构的 spans,结果呈现为瀑布图。 ```sql -WITH '' as trace_id, +WITH '' AS trace_id, (SELECT min(Start) FROM "default"."otel_traces_trace_id_ts" - WHERE TraceId = trace_id) as trace_start, + WHERE TraceId = trace_id) AS trace_start, (SELECT max(End) + 1 FROM "default"."otel_traces_trace_id_ts" - WHERE TraceId = trace_id) as trace_end -SELECT "TraceId" as traceID, - "SpanId" as spanID, - "ParentSpanId" as parentSpanID, - "ServiceName" as serviceName, - "SpanName" as operationName, - "Timestamp" as startTime, - multiply("Duration", 0.000001) as duration, + WHERE TraceId = trace_id) AS trace_end +SELECT "TraceId" AS traceID, + "SpanId" AS spanID, + "ParentSpanId" AS parentSpanID, + "ServiceName" AS serviceName, + "SpanName" AS operationName, + "Timestamp" AS startTime, + multiply("Duration", 0.000001) AS duration, arrayMap(key -> map('key', key, 'value',"SpanAttributes"[key]), - mapKeys("SpanAttributes")) as tags, + mapKeys("SpanAttributes")) AS tags, arrayMap(key -> map('key', key, 'value',"ResourceAttributes"[key]), - mapKeys("ResourceAttributes")) as serviceTags + mapKeys("ResourceAttributes")) AS serviceTags FROM "default"."otel_traces" WHERE traceID = trace_id AND startTime >= trace_start @@ -119,19 +119,19 @@ LIMIT 1000 ``` :::note -注意上面的查询使用物化视图 `otel_traces_trace_id_ts` 进行追踪 ID 查询。有关更多细节,请参见 [加速查询 - 使用物化视图进行查找](/use-cases/observability/schema-design#using-materialized-views-incremental--for-fast-lookups)。 +请注意,以上查询使用物化视图 `otel_traces_trace_id_ts` 来执行跟踪 ID 查找。有关更多详细信息,请参阅 [加速查询 - 使用物化视图进行查找](/use-cases/observability/schema-design#using-materialized-views-incremental--for-fast-lookups)。 ::: -### 追踪到日志 {#traces-to-logs} +### 跟踪到日志 {#traces-to-logs} -如果日志包含追踪 ID,用户可以从追踪导航到其相关的日志。要查看日志,单击追踪 ID 并选择 `View Logs`。这将发出以下查询,假设使用默认的 OTel 列。 +如果日志包含跟踪 ID,用户可以从跟踪转到其关联的日志。要查看日志,请点击一个跟踪 ID 并选择 `View Logs`。这将发出以下查询,假设使用默认 OTel 列。 ```sql -SELECT Timestamp as "timestamp", - Body as "body", SeverityText as "level", - TraceId as "traceID" FROM "default"."otel_logs" +SELECT Timestamp AS "timestamp", + Body AS "body", SeverityText AS "level", + TraceId AS "traceID" FROM "default"."otel_logs" WHERE ( traceID = '' ) ORDER BY timestamp ASC LIMIT 1000 ``` @@ -140,17 +140,17 @@ ORDER BY timestamp ASC LIMIT 1000 ## 仪表板 {#dashboards} -用户可以在 Grafana 中使用 ClickHouse 数据源构建仪表板。我们建议查阅 Grafana 和 ClickHouse 的 [数据源文档](https://github.com/grafana/clickhouse-datasource) 以获取更多信息,特别是 [宏的概念](https://github.com/grafana/clickhouse-datasource?tab=readme-ov-file#macros) 和 [变量](https://grafana.com/docs/grafana/latest/dashboards/variables/)。 +用户可以在 Grafana 中使用 ClickHouse 数据源构建仪表板。我们建议参考 Grafana 和 ClickHouse 的 [数据源文档](https://github.com/grafana/clickhouse-datasource) 以获取更多细节,特别是 [宏的概念](https://github.com/grafana/clickhouse-datasource?tab=readme-ov-file#macros) 和 [变量](https://grafana.com/docs/grafana/latest/dashboards/variables/)。 -该插件提供了多个开箱即用的仪表板,包括一个示例仪表板“简单 ClickHouse OTel 仪表板”,用于符合 OTel 规范的日志和追踪数据。这要求用户遵循 OTel 的默认列名,且可以从数据源配置中安装。 +该插件提供了多个开箱即用的仪表板,包括一个示例仪表板“简单 ClickHouse OTel 仪表板”,用于符合 OTel 规范的日志和跟踪数据。这要求用户遵循 OTel 的默认列名,并可以从数据源配置中安装。 -我们在下面提供一些构建可视化的简单技巧。 +我们提供了一些构建可视化的简单技巧如下。 ### 时间序列 {#time-series} -除了统计数据,折线图是可观察性用例中最常用的可视化形式。如果查询返回一个名为 `time` 的 `datetime` 字段和一个数值列,Clickhouse 插件将自动渲染一个折线图。例如: +与统计数据一起,折线图是可观察性用例中最常见的可视化形式。如果查询返回一个名为 `time` 的 `datetime` 和一个数值列,Clickhouse 插件将自动渲染为折线图。例如: ```sql SELECT @@ -169,10 +169,10 @@ LIMIT 100000 ### 多线图 {#multi-line-charts} -只要满足以下条件,查询将自动渲染多线图: +在满足以下条件的情况下,查询将自动渲染为多线图: - 字段 1:别名为时间的 datetime 字段 -- 字段 2:用于分组的值。应该是字符串。 +- 字段 2:要分组的值。这应该是一个字符串。 - 字段 3+:指标值 例如: @@ -194,7 +194,7 @@ LIMIT 100000 ### 可视化地理数据 {#visualizing-geo-data} -我们已在前面的部分探讨了如何使用 IP 字典丰富可观察性数据的地理坐标。假设您有 `latitude` 和 `longitude` 列,可使用 `geohashEncode` 函数对可观察性进行可视化。这将生成与 Grafana Geo Map 图表兼容的地理散列。以下是示例查询和可视化: +我们在早期部分探讨了使用 IP 字典丰富可观察性数据与地理坐标的方式。假设您有 `latitude` 和 `longitude` 列,可以使用 `geohashEncode` 函数来可视化可观察性。这将生成适用于 Grafana 地图图表的地理哈希。下面是示例查询和可视化: ```sql WITH coords AS diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/build-your-own/grafana.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/build-your-own/grafana.md.hash index d9bb98f85db..55a1ba98cbd 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/build-your-own/grafana.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/build-your-own/grafana.md.hash @@ -1 +1 @@ -3baa083c9aa18cd5 +04b5c4a8dbbee142 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/build-your-own/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/build-your-own/index.md index dc42067057f..42be84112a0 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/build-your-own/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/build-your-own/index.md @@ -1,18 +1,19 @@ --- 'slug': '/use-cases/observability/build-your-own' -'title': '构建自己的可观察性技术栈' +'title': '构建你自己的可观察性堆栈' 'pagination_prev': null 'pagination_next': null -'description': '着陆页,构建自己的可观察性技术栈' +'description': '构建你自己的可观察性堆栈的登录页面' +'doc_type': 'landing-page' --- -这份指南帮助您构建一个以 ClickHouse 为基础的自定义可观察性栈。了解如何为日志、指标和跟踪设计、实施和优化您的可观察性解决方案,并提供实用示例和最佳实践。 +这个指南帮助您构建一个以 ClickHouse 为基础的自定义可观察性堆栈。了解如何为日志、指标和跟踪设计、实施和优化您的可观察性解决方案,并提供实际示例和最佳实践。 | 页面 | 描述 | |-------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [介绍](/use-cases/observability/introduction) | 本指南旨在帮助希望使用 ClickHouse 构建自己可观察性解决方案的用户,重点关注日志和跟踪。 | -| [模式设计](/use-cases/observability/schema-design) | 了解为什么建议用户为日志和跟踪创建自己的模式,以及一些最佳实践。 | -| [管理数据](/observability/managing-data) | 用于可观察性的 ClickHouse 部署通常涉及大型数据集,需要进行管理。ClickHouse 提供了帮助数据管理的功能。 | -| [集成 OpenTelemetry](/observability/integrating-opentelemetry) | 使用 OpenTelemetry 收集和导出与 ClickHouse 的日志和跟踪。 | +| [架构设计](/use-cases/observability/schema-design) | 了解为什么建议用户为日志和跟踪创建自己的架构,以及一些最佳实践。 | +| [管理数据](/observability/managing-data) | 用于可观察性的 ClickHouse 部署通常涉及大型数据集,这些数据集需要进行管理。ClickHouse 提供了有助于数据管理的功能。 | +| [集成 OpenTelemetry](/observability/integrating-opentelemetry) | 使用 OpenTelemetry 通过 ClickHouse 收集和导出日志和跟踪。 | | [使用可视化工具](/observability/grafana) | 了解如何使用 ClickHouse 的可观察性可视化工具,包括 HyperDX 和 Grafana。 | -| [演示应用](/observability/demo-application) | 探索已 fork 的 OpenTelemetry 演示应用,以便与 ClickHouse 一起使用进行日志和跟踪。 | +| [演示应用程序](/observability/demo-application) | 探索 OpenTelemetry 演示应用程序,该程序已被分叉以支持与 ClickHouse 一起用于日志和跟踪。 | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/build-your-own/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/build-your-own/index.md.hash index 57081fcb6c4..c59bd48d850 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/build-your-own/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/build-your-own/index.md.hash @@ -1 +1 @@ -0cc39d2a5c6a4399 +a71c1b0c591da0f2 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/build-your-own/integrating-opentelemetry.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/build-your-own/integrating-opentelemetry.md index d5209c6f488..4ce50e12e12 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/build-your-own/integrating-opentelemetry.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/build-your-own/integrating-opentelemetry.md @@ -1,11 +1,12 @@ --- 'title': '整合 OpenTelemetry' -'description': '整合 OpenTelemetry 和 ClickHouse 实现可观察性' +'description': '整合 OpenTelemetry 和 ClickHouse 以实现可观察性' 'slug': '/observability/integrating-opentelemetry' 'keywords': - 'Observability' - 'OpenTelemetry' 'show_related_blogs': true +'doc_type': 'guide' --- import observability_3 from '@site/static/images/use-cases/observability/observability-3.png'; @@ -18,78 +19,73 @@ import observability_9 from '@site/static/images/use-cases/observability/observa import Image from '@theme/IdealImage'; -# 集成 OpenTelemetry 进行数据收集 +# 集成 OpenTelemetry 以进行数据收集 -任何可观察性解决方案都需要一种收集和导出日志与跟踪的方法。为此,ClickHouse 推荐[OpenTelemetry (OTel) 项目](https://opentelemetry.io/)。 +任何可观察性解决方案都需要收集和导出日志和跟踪的手段。为此,ClickHouse 推荐[OpenTelemetry (OTel) 项目](https://opentelemetry.io/)。 -“OpenTelemetry 是一个可观察性框架和工具包,旨在创建和管理遥测数据,如跟踪、指标和日志。” +“OpenTelemetry 是一个可观察性框架和工具包,旨在创建和管理遥测数据,例如跟踪、度量和日志。” -与 ClickHouse 或 Prometheus 不同,OpenTelemetry 不是一个可观察性后端,而是专注于遥测数据的生成、收集、管理和导出。虽然 OpenTelemetry 的初始目标是让用户能够使用特定语言的 SDK 轻松地对其应用程序或系统进行插桩,但它已扩展为通过 OpenTelemetry 收集器进行日志收集——这是一个接收、处理并导出遥测数据的代理或代理。 +与 ClickHouse 或 Prometheus 不同,OpenTelemetry 不是一个可观察性后端,而是专注于遥测数据的生成、收集、管理和导出。虽然 OpenTelemetry 的初衷是让用户能够轻松使用特定语言的 SDK 对他们的应用程序或系统进行仪器化,但它已经扩展到通过 OpenTelemetry 收集器收集日志——一个接收、处理和导出遥测数据的代理或代理。 ## ClickHouse 相关组件 {#clickhouse-relevant-components} -OpenTelemetry 包含多个组件。除了提供数据和 API 规范、标准化协议以及字段/列的命名约定外,OTel 提供了两个构建可观察性解决方案的基本能力,这些能力与 ClickHouse 有关: +OpenTelemetry 包含多个组件。除了提供数据和 API 规范、标准化协议以及字段/列的命名约定外,OTel 还提供了两种功能,这些功能对于使用 ClickHouse 构建可观察性解决方案至关重要: -- [OpenTelemetry Collector](https://opentelemetry.io/docs/collector/) 是一个接收、处理和导出遥测数据的代理。基于 ClickHouse 的解决方案使用该组件进行日志收集和事件处理,在批量和插入之前进行处理。 -- [语言 SDKs](https://opentelemetry.io/docs/languages/) 实现了规范、API 和遥测数据的导出。这些 SDK 有效地确保了应用程序代码中正确记录了跟踪,生成组成的跨度,并通过元数据确保在服务之间传播上下文,从而形成分布式跟踪并确保跨度可以进行关联。这些 SDK得到了一个生态系统的支持,该生态系统自动实现了常见的库和框架,因此用户不需要更改其代码,即可获得开箱即用的插桩。 +- [OpenTelemetry 收集器](https://opentelemetry.io/docs/collector/) 是一个代理,它接收、处理并导出遥测数据。基于 ClickHouse 的解决方案使用该组件来进行日志收集和事件处理,然后进行批处理和插入。 +- [语言 SDK](https://opentelemetry.io/docs/languages/) 实现了规范、API 和遥测数据的导出。这些 SDK 有效确保在应用程序的代码中正确记录跟踪,生成组成的跨度并确保上下文通过元数据在服务之间传播,从而形成分布式跟踪并确保跨度可以相关联。这些 SDK 得到了自动实现公共库和框架的生态系统的补充,因此用户不需要更改他们的代码即可获得开箱即用的仪器。 -基于 ClickHouse 的可观察性解决方案利用了这两个工具。 +一个基于 ClickHouse 的可观察性解决方案利用了这两种工具。 +## 分发 {#distributions} -## 分发版本 {#distributions} +OpenTelemetry 收集器有[多种分发](https://github.com/open-telemetry/opentelemetry-collector-releases?tab=readme-ov-file)。文件日志接收器和 ClickHouse 导出器——对于 ClickHouse 解决方案所需的,只存在于[OpenTelemetry Collector Contrib Distro](https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-contrib)。 -OpenTelemetry 收集器具有[多个分发版本](https://github.com/open-telemetry/opentelemetry-collector-releases?tab=readme-ov-file)。与 ClickHouse 解决方案所需的 filelog 接收器和 ClickHouse 导出器仅存在于[OpenTelemetry Collector Contrib Distro](https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-contrib)中。 +此分发包含许多组件,允许用户尝试各种配置。但是,在生产环境中,建议将收集器限制为仅包含环境所需的组件。这么做的一些原因包括: -该分发版本包含多个组件,允许用户尝试各种配置。但是,在生产环境中,建议将收集器限制为仅包含每个环境所需的组件。这样做的几个原因: - -- 减少收集器的大小,减少收集器的部署时间 +- 减少收集器的大小,减小收集器的部署时间 - 通过减少可用攻击面提高收集器的安全性 -构建[自定义收集器](https://opentelemetry.io/docs/collector/custom-collector/)可以使用 [OpenTelemetry Collector Builder](https://github.com/open-telemetry/opentelemetry-collector/tree/main/cmd/builder) 实现。 - -## 使用 OTel 摄取数据 {#ingesting-data-with-otel} - +构建[自定义收集器](https://opentelemetry.io/docs/collector/custom-collector/)可以使用[OpenTelemetry Collector Builder](https://github.com/open-telemetry/opentelemetry-collector/tree/main/cmd/builder)实现。 +## 使用 OTel 收集数据 {#ingesting-data-with-otel} ### 收集器部署角色 {#collector-deployment-roles} -为了收集日志并将其插入 ClickHouse,我们建议使用 OpenTelemetry Collector。OpenTelemetry Collector 可以以两种主要角色部署: - -- **代理** - 代理实例在边缘收集数据,如在服务器或 Kubernetes 节点上,或直接从使用 OpenTelemetry SDK 插桩的应用程序接收事件。在后面的情况下,代理实例与应用程序一起运行,或与应用程序在同一主机上(如旁路代理或守护进程集)。代理可以直接将其数据发送到 ClickHouse,或发送到网关实例。在前一种情况下,这被称为[代理部署模式](https://opentelemetry.io/docs/collector/deployment/agent/)。 -- **网关** - 网关实例提供独立服务(例如,Kubernetes 中的部署),通常按集群、数据中心或区域提供。这些实例通过单个 OTLP 端点接收来自应用程序(或其他收集器作为代理)的事件。通常会部署一组网关实例,并使用开箱即用的负载均衡器在它们之间分配负载。如果所有代理和应用程序将其信号发送到此单个端点,通常称为[网关部署模式](https://opentelemetry.io/docs/collector/deployment/gateway/)。 +为收集日志并将其插入 ClickHouse,建议使用 OpenTelemetry 收集器。OpenTelemetry 收集器可以以两种主要角色进行部署: -在下面,我们假设一个简单的代理收集器,将事件直接发送到 ClickHouse。有关使用网关的更多详细信息及其适用情况,请参阅[使用网关进行扩展](#scaling-with-gateways)。 +- **代理** - 代理实例在边缘收集数据,例如在服务器或 Kubernetes 节点上,或直接从应用程序接收事件——这些应用程序使用 OpenTelemetry SDK 进行了仪器化。在后者的情况下,代理实例与应用程序一起运行或与应用程序在同一主机上运行(例如作为边车或 DaemonSet)。代理可以将其数据直接发送到 ClickHouse,也可以发送到网关实例。在前一种情况下,这被称为[代理部署模式](https://opentelemetry.io/docs/collector/deployment/agent/)。 +- **网关** - 网关实例提供独立的服务(例如,在 Kubernetes 中的部署),通常按集群、数据中心或区域配置。这些实例通过单个 OTLP 端点接收来自应用程序(或其他收集器作为代理)的事件。通常会部署一组网关实例,并使用开箱即用的负载均衡器在它们之间分配负载。如果所有代理和应用程序将其信号发送到此单一端点,则通常称为[网关部署模式](https://opentelemetry.io/docs/collector/deployment/gateway/)。 +以下假设一个简单的代理收集器,将其事件直接发送到 ClickHouse。有关使用网关及其适用时机的更多详细信息,请参阅[与网关的扩展](#scaling-with-gateways)。 ### 收集日志 {#collecting-logs} -使用收集器的主要优点是它允许您的服务快速卸载数据,让收集器处理额外的处理,例如重试、批处理、加密或甚至敏感数据过滤。 +使用收集器的主要优点是它可以让你的服务快速卸载数据,让收集器负责额外处理,例如重试、批处理、加密或甚至敏感数据过滤。 -收集器使用术语[接收器](https://opentelemetry.io/docs/collector/configuration/#receivers)、[处理器](https://opentelemetry.io/docs/collector/configuration/#processors)和[导出器](https://opentelemetry.io/docs/collector/configuration/#exporters)来表示其三个主要处理阶段。接收器用于数据收集,可以是拉取或推送式。处理器则提供了对消息进行转换和增强的能力。导出器负责将数据发送到下游服务。虽然理论上可以是另一个收集器,但我们假设所有数据都直接发送到 ClickHouse,用于下面的初步讨论。 +收集器使用术语[接收器](https://opentelemetry.io/docs/collector/configuration/#receivers)、[处理器](https://opentelemetry.io/docs/collector/configuration/#processors)和[导出器](https://opentelemetry.io/docs/collector/configuration/#exporters)来描述其三个主要处理阶段。接收器用于数据收集,可以是基于拉取或推送。处理器提供执行转换和消息丰富的能力。导出器负责将数据发送到下游服务。虽然理论上可以将该服务发送到另一个收集器,但我们假设所有数据直接发送到 ClickHouse,以进行以下初步讨论。 -我们建议用户熟悉完整的接收器、处理器和导出器集。 +我们建议用户熟悉完整的接收器、处理器和导出器集合。 -收集器提供了两个主要接收器用于收集日志: +收集器提供两个主要接收器用于收集日志: -**通过 OTLP** - 在这种情况下,日志通过 OTLP 协议直接从 OpenTelemetry SDK 发送(推送)到收集器。[OpenTelemetry 演示](https://opentelemetry.io/docs/demo/)采用这种方法,每种语言中的 OTLP 导出器假设本地收集器端点。在这种情况下,收集器必须配置为使用 OTLP 接收器——请参见上面的[演示配置](https://github.com/ClickHouse/opentelemetry-demo/blob/main/src/otelcollector/otelcol-config.yml#L5-L12)。这种方法的优点是日志数据将自动包含 Trace Id,因此用户可以稍后识别特定日志的跟踪,反之亦然。 +**通过 OTLP** - 在这种情况下,日志通过 OTLP 协议直接从 OpenTelemetry SDK 发送(推送)到收集器。[OpenTelemetry 演示](https://opentelemetry.io/docs/demo/)采用这种方法,每种语言中的 OTLP 导出器假定 local 收集器端点。在这种情况下,收集器必须配置为使用 OTLP 接收器——请参见上面的[演示以获取配置](https://github.com/ClickHouse/opentelemetry-demo/blob/main/src/otelcollector/otelcol-config.yml#L5-L12)。该方法的优势是日志数据将自动包含 Trace Id,从而允许用户稍后识别特定日志的跟踪,反之亦然。 -此方法要求用户使用其[适当的语言 SDK](https://opentelemetry.io/docs/languages/)对其代码进行插桩。 +此方法要求用户使用其[适当语言的 SDK](https://opentelemetry.io/docs/languages/)对代码进行仪器化。 -- **通过 Filelog 接收器抓取** - 此接收器对磁盘上的文件进行跟踪,并形成日志消息,将其发送到 ClickHouse。该接收器处理复杂任务,例如检测多行消息、处理日志翻转、为重启提供检查点的鲁棒性,以及提取结构。此接收器还可以跟踪 Docker 和 Kubernetes 容器日志,可以作为 helm 图表部署,并[从中提取结构](https://opentelemetry.io/blog/2024/otel-collector-container-log-parser/),并用 pod 细节增补。 +- **通过文件日志接收器抓取** - 此接收器在磁盘上跟踪文件并形成日志消息,将这些消息发送到 ClickHouse。此接收器处理复杂任务,例如检测多行消息、处理日志回滚、检查点以实现重启的健壮性以及提取结构。此接收器还能够跟踪 Docker 和 Kubernetes 容器日志,可以作为 helm 图表部署,[从中提取结构](https://opentelemetry.io/blog/2024/otel-collector-container-log-parser/)并丰富其中的 pod 详细信息。 - + -**大多数部署将同时使用上述接收器的组合。我们建议用户阅读[收集器文档](https://opentelemetry.io/docs/collector/)并熟悉基本概念,以及[配置结构](https://opentelemetry.io/docs/collector/configuration/)和[安装方法](https://opentelemetry.io/docs/collector/installation/)。** +**大多数部署将使用上述接收器的组合。我们建议用户阅读[收集器文档](https://opentelemetry.io/docs/collector/)并熟悉基本概念,以及[配置结构](https://opentelemetry.io/docs/collector/configuration/)和[安装方法](https://opentelemetry.io/docs/collector/installation/)。** :::note 提示: `otelbin.io` -[`otelbin.io`](https://www.otelbin.io/) 用于验证和可视化配置。 +[`otelbin.io`](https://www.otelbin.io/) 对于验证和可视化配置非常有用。 ::: - -## 结构化与非结构化 {#structured-vs-unstructured} +## 结构化日志与非结构化日志 {#structured-vs-unstructured} 日志可以是结构化的或非结构化的。 -结构化日志将使用 JSON 等数据格式,定义元数据字段,如 HTTP 代码和源 IP 地址。 +结构化日志将使用 JSON 等数据格式,定义元数据字段,例如 http 代码和源 IP 地址。 ```json { @@ -103,28 +99,27 @@ OpenTelemetry 收集器具有[多个分发版本](https://github.com/open-teleme } ``` -非结构化日志虽然通常也具有某种内在结构,能够通过正则表达式模式提取,但日志将纯粹表示为字符串。 +非结构化日志虽然也通常具有通过正则表达式模式提取的某种内在结构,但将日志纯粹表示为字符串。 ```response 54.36.149.41 - - [22/Jan/2019:03:56:14 +0330] "GET /filter/27|13%20%D9%85%DA%AF%D8%A7%D9%BE%DB%8C%DA%A9%D8%B3%D9%84,27|%DA%A9%D9%85%D8%AA%D8%B1%20%D8%A7%D8%B2%205%20%D9%85%DA%AF%D8%A7%D9%BE%DB%8C%DA%A9%D8%B3%D9%84,p53 HTTP/1.1" 200 30577 "-" "Mozilla/5.0 (compatible; AhrefsBot/6.1; +http://ahrefs.com/robot/)" "-" ``` -我们建议用户尽可能使用结构化日志,并以 JSON(即 ndjson)记录。这将简化后续处理日志的要求,在发送到 ClickHouse 之前使用[收集器处理器](https://opentelemetry.io/docs/collector/configuration/#processors)或在插入时使用物化视图。结构化日志最终将节省后续的处理资源,减少您在 ClickHouse 解决方案中所需的 CPU。 - +我们建议用户在可能的情况下使用结构化日志并以 JSON(即 ndjson)记录。这将简化后续日志的处理,无论是通过[收集器处理器](https://opentelemetry.io/docs/collector/configuration/#processors)在发送到 ClickHouse 之前,还是在插入时使用物化视图。结构化日志最终将节省后续处理资源,减少 ClickHouse 解决方案中所需的 CPU。 ### 示例 {#example} -作为示例,我们提供一个结构化(JSON)和非结构化日志数据集,每个数据集约有 10m 行,可以通过以下链接获得: +作为示例,我们提供了一个结构化(JSON)和一个非结构化日志数据集,每个数据集大约有 1000 万行,可以在以下链接中获得: - [非结构化](https://datasets-documentation.s3.eu-west-3.amazonaws.com/http_logs/access-unstructured.log.gz) - [结构化](https://datasets-documentation.s3.eu-west-3.amazonaws.com/http_logs/access-structured.log.gz) -我们使用结构化数据集作为下面的示例。确保下载该文件并解压以重现以下示例。 +我们将在下面的示例中使用结构化数据集。确保下载并解压此文件以重现以下示例。 -以下是 OTel Collector 的简单配置,读取这些文件,使用 filelog 接收器,并将结果消息输出到 stdout。我们使用[`json_parser`](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/pkg/stanza/docs/operators/json_parser.md) 操作符,因为我们的日志是结构化的。修改路径以指向 access-structured.log 文件。 +以下是 OTel 收集器的简单配置,它读取磁盘上的这些文件,使用文件日志接收器,并将结果消息输出到 stdout。由于我们的日志是结构化的,我们使用[`json_parser`](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/pkg/stanza/docs/operators/json_parser.md)操作符。请修改访问结构化.log 文件的路径。 -:::note 考虑 ClickHouse 进行解析 -以下示例从日志中提取时间戳。这需要使用 `json_parser` 操作符,该操作符将整个日志行转换为 JSON 字符串,并将结果放置在 `LogAttributes` 中。这可能计算开销较大,[并且可以在 ClickHouse 中更高效地完成](https://clickhouse.com/blog/worlds-fastest-json-querying-tool-clickhouse-local) - [使用 SQL 提取结构](/use-cases/observability/schema-design#extracting-structure-with-sql)。一个等效的非结构化示例,使用[`regex_parser`](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/pkg/stanza/docs/operators/regex_parser.md) 实现这一点,可以在[这里](https://pastila.nl/?01da7ee2/2ffd3ba8124a7d6e4ddf39422ad5b863#swBkiAXvGP7mRPgbuzzHFA==)找到。 +:::note 请考虑使用 ClickHouse 进行解析 +下面的示例提取了日志中的时间戳。这需要使用 `json_parser` 操作符,该操作符将整个日志行转换为 JSON 字符串,并将结果放置在 `LogAttributes` 中。这可能是计算密集型的,并且[可以在 ClickHouse 中更高效地完成](https://clickhouse.com/blog/worlds-fastest-json-querying-tool-clickhouse-local) - [使用 SQL 提取结构](/use-cases/observability/schema-design#extracting-structure-with-sql)。可以在[这里](https://pastila.nl/?01da7ee2/2ffd3ba8124a7d6e4ddf39422ad5b863#swBkiAXvGP7mRPgbuzzHFA==)找到相应的非结构化示例,该示例使用[`regex_parser`](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/pkg/stanza/docs/operators/regex_parser.md)来实现这一点。 ::: **[config-structured-logs.yaml](https://www.otelbin.io/#config=receivers%3A*N_filelog%3A*N___include%3A*N_____-_%2Fopt%2Fdata%2Flogs%2Faccess-structured.log*N___start*_at%3A_beginning*N___operators%3A*N_____-_type%3A_json*_parser*N_______timestamp%3A*N_________parse*_from%3A_attributes.time*_local*N_________layout%3A_*%22*.Y-*.m-*.d_*.H%3A*.M%3A*.S*%22*N*N*Nprocessors%3A*N__batch%3A*N____timeout%3A_5s*N____send*_batch*_size%3A_1*N*N*Nexporters%3A*N_logging%3A*N___loglevel%3A_debug*N*N*Nservice%3A*N_pipelines%3A*N___logs%3A*N_____receivers%3A_%5Bfilelog%5D*N_____processors%3A_%5Bbatch%5D*N_____exporters%3A_%5Blogging%5D%7E)** @@ -155,9 +150,9 @@ service: exporters: [logging] ``` -用户可以遵循[官方说明](https://opentelemetry.io/docs/collector/installation/)在本地安装收集器。重要的是,确保说明已修改为使用[contrib 分发版本](https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-contrib)(该版本包含 `filelog` 接收器),例如,而不是 `otelcol_0.102.1_darwin_arm64.tar.gz`,用户将下载 `otelcol-contrib_0.102.1_darwin_arm64.tar.gz`。可以在[这里](https://github.com/open-telemetry/opentelemetry-collector-releases/releases)找到发布版本。 +用户可以遵循[官方说明](https://opentelemetry.io/docs/collector/installation/)在本地安装收集器。重要的是,确保说明已修改为使用[contrib 分发](https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-contrib)(其中包含 `filelog` 接收器),例如而不是 `otelcol_0.102.1_darwin_arm64.tar.gz`,用户将下载 `otelcol-contrib_0.102.1_darwin_arm64.tar.gz`。发布版本可以在[这里](https://github.com/open-telemetry/opentelemetry-collector-releases/releases)找到。 -安装完成后,可以使用以下命令运行 OTel Collector: +安装后,可以使用以下命令运行 OTel 收集器: ```bash ./otelcol-contrib --config config-logs.yaml @@ -190,33 +185,30 @@ Span ID: Flags: 0 ``` -以上表示一个由 OTel 收集器生成的单个日志消息。我们将在后面的部分中将这些相同的消息摄取到 ClickHouse 中。 +上面的日志消息表示由 OTel 收集器生成的单个日志消息。我们将在后面的部分将这些相同的消息导入 ClickHouse。 -日志消息的完整架构,以及在使用其他接收器时可能存在的附加列,保留在[这里](https://opentelemetry.io/docs/specs/otel/logs/data-model/)。**我们强烈建议用户熟悉该架构。** +日志消息的完整架构,以及如果使用其他接收器可能存在的额外列,维护在[这里](https://opentelemetry.io/docs/specs/otel/logs/data-model/)。**我们强烈建议用户熟悉此架构。** -这里的关键是日志行本身作为字符串保存在 `Body` 字段中,而 JSON 已通过 `json_parser` 自动提取到 Attributes 字段。用于提取时间戳的相同[操作符](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/pkg/stanza/docs/operators/README.md#what-operators-are-available)已被用来提取到相应的 `Timestamp` 列中。有关使用 OTel 处理日志的建议,请参见[处理](#processing---filtering-transforming-and-enriching)。 +关键在于日志行本身作为字符串保存在 `Body` 字段内,但 JSON 已通过 `json_parser` 自动提取到 `Attributes` 字段。此同一[操作符](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/pkg/stanza/docs/operators/README.md#what-operators-are-available)已用于将时间戳提取到适当的 `Timestamp` 列。有关使用 OTel 处理日志的建议,请参阅[处理](#processing---filtering-transforming-and-enriching)。 :::note 操作符 -操作符是日志处理的最基本单元。每个操作符履行单一责任,例如从文件中读取行或从字段解析 JSON。操作符在管道中串联使用,以实现所需的结果。 +操作符是日志处理的最基本单位。每个操作符履行单一责任,例如从文件中读取行或从字段解析 JSON。操作符然后在管道中链接在一起以实现所需的结果。 ::: -上述消息没有 `TraceID` 或 `SpanID` 字段。如果存在,例如,在用户实现[分布式跟踪](https://opentelemetry.io/docs/concepts/observability-primer/#distributed-traces)时,可以使用上述相同技术从 JSON 中提取这些字段。 - -对于需要收集本地或 Kubernetes 日志文件的用户,我们建议用户熟悉[filelog 接收器](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/receiver/filelogreceiver/README.md#configuration)的可用配置选项,以及[偏移量](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/filelogreceiver#offset-tracking)和[多行日志解析的处理方式](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/filelogreceiver#example---multiline-logs-parsing)。 +上述消息没有 `TraceID` 或 `SpanID` 字段。如果存在,例如在用户实现[分布式跟踪](https://opentelemetry.io/docs/concepts/observability-primer/#distributed-traces)的情况,使用上面显示的相同技术可以从 JSON 中提取这些字段。 +对于需要收集本地或 Kubernetes 日志文件的用户,我们建议用户熟悉[文件日志接收器](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/receiver/filelogreceiver/README.md#configuration)可用的配置选项,以及[偏移量](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/filelogreceiver#offset-tracking)和[多行日志解析的处理](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/filelogreceiver#example---multiline-logs-parsing)。 ## 收集 Kubernetes 日志 {#collecting-kubernetes-logs} -对于 Kubernetes 日志的收集,我们建议参考[OpenTelemetry 文档指南](https://opentelemetry.io/docs/kubernetes/)。推荐使用[Kubernetes 属性处理器](https://opentelemetry.io/docs/kubernetes/collector/components/#kubernetes-attributes-processor)来增强日志和指标,以便使用 pod 元数据。这可能会生成动态元数据,例如,存储在列 `ResourceAttributes` 中的标签。ClickHouse 当前对该列使用 `Map(String, String)` 类型。有关处理和优化此类型的更多详细信息,请参见[使用 Maps](/use-cases/observability/schema-design#using-maps)和[从 maps 中提取](/use-cases/observability/schema-design#extracting-from-maps)。 - +对于 Kubernetes 日志的收集,我们建议参考[OpenTelemetry 文档指南](https://opentelemetry.io/docs/kubernetes/)。建议使用[Kubernetes 属性处理器](https://opentelemetry.io/docs/kubernetes/collector/components/#kubernetes-attributes-processor)来丰富日志和指标,并添加 pod 元数据。这可能会产生动态元数据,例如存储在列 `ResourceAttributes` 中的标签。 ClickHouse 目前为此列使用类型 `Map(String, String)`。有关处理和优化此类型的更多详细信息,请参见[使用 Maps](/use-cases/observability/schema-design#using-maps)和[从地图中提取](/use-cases/observability/schema-design#extracting-from-maps)。 ## 收集跟踪 {#collecting-traces} -对于希望对其代码进行插桩和收集跟踪的用户,我们建议按照官方[OTel 文档](https://opentelemetry.io/docs/languages/)进行操作。 - -为了将事件发送到 ClickHouse,用户需要部署一个 OTel 收集器,以通过适当的接收器通过 OTLP 协议接收跟踪事件。OpenTelemetry 演示提供了[每种支持的语言插桩的示例](https://opentelemetry.io/docs/demo/)及向收集器发送事件。以下是将事件输出到 stdout 的适当收集器配置示例: +对于希望对代码进行仪器并收集跟踪的用户,我们建议遵循官方[OTel 文档](https://opentelemetry.io/docs/languages/)。 +为了将事件发送到 ClickHouse,用户需要部署 OTel 收集器以通过相应的接收器通过 OTLP 协议接收跟踪事件。OpenTelemetry 演示提供了一个[为每种受支持语言进行仪器的示例](https://opentelemetry.io/docs/demo/)并将事件发送到收集器。下面显示了一个适当的收集器配置示例,该配置将事件输出到 stdout: ### 示例 {#example-1} -由于跟踪必须通过 OTLP 接收,我们使用[`telemetrygen`](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/cmd/telemetrygen) 工具生成跟踪数据。请按照[这里](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/cmd/telemetrygen)的说明进行安装。 +由于跟踪必须通过 OTLP 接收,因此我们使用[`telemetrygen`](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/cmd/telemetrygen)工具生成跟踪数据。请遵循[此处](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/cmd/telemetrygen)的说明进行安装。 以下配置在 OTLP 接收器上接收跟踪事件,然后将其发送到 stdout。 @@ -248,13 +240,13 @@ service: ./otelcol-contrib --config config-traces.yaml ``` -使用 `telemetrygen` 向收集器发送跟踪事件: +通过 `telemetrygen` 发送跟踪事件到收集器: ```bash $GOBIN/telemetrygen traces --otlp-insecure --traces 300 ``` -这将导致类似于下面示例的跟踪消息输出到 stdout: +这将产生类似于下面示例的跟踪消息,并输出到 stdout: ```response Span #86 @@ -272,31 +264,29 @@ Attributes: -> peer.service: Str(telemetrygen-client) ``` -以上表示一个由 OTel 收集器生成的单个跟踪消息。我们将在后面的部分中将这些相同的消息摄取到 ClickHouse 中。 - -跟踪消息的完整架构保留在[这里](https://opentelemetry.io/docs/concepts/signals/traces/)。我们强烈建议用户熟悉该架构。 - -## 处理 - 过滤、变换和增强 {#processing---filtering-transforming-and-enriching} +上述内容表示由 OTel 收集器生成的单条跟踪消息。我们将在后面的部分将这些相同的消息导入 ClickHouse。 -如前面设置日志事件时间戳的示例所示,用户不可避免地会想要过滤、变换和增强事件消息。可以使用 OpenTelemetry 中的多种能力实现: +跟踪消息的完整架构在[这里](https://opentelemetry.io/docs/concepts/signals/traces/)中维护。我们强烈建议用户熟悉此架构。 +## 处理 - 过滤、转换和丰富 {#processing---filtering-transforming-and-enriching} -- **处理器** - 处理器处理由[接收器收集的数据,并在发送到导出器之前对其进行修改或转换](https://opentelemetry.io/docs/collector/transforming-telemetry/)。处理器按配置的顺序应用于收集器配置的 `processors` 部分。这些是可选的,但通常推荐使用最小集[(推荐处理器)](https://github.com/open-telemetry/opentelemetry-collector/tree/main/processor#recommended-processors)。使用 OTel 收集器与 ClickHouse,我们建议将处理器限制为: +如前面的示例中所示,设置日志事件的时间戳后,用户无疑希望过滤、转换和丰富事件消息。这可以通过 OpenTelemetry 中的多个功能实现: - - [memory_limiter](https://github.com/open-telemetry/opentelemetry-collector/blob/main/processor/memorylimiterprocessor/README.md) 用于防止收集器出现内存不足的情况。有关建议,请参见[估算资源](#estimating-resources)。 - - 任何基于上下文进行增强的处理器。例如,[Kubernetes 属性处理器](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/k8sattributesprocessor)允许自动设置跨度、指标和日志资源属性,以及 k8s 元数据,例如,用其源 Pod ID 增强事件。 - - 如果需要进行跟踪,可使用[尾部或头部采样](https://opentelemetry.io/docs/concepts/sampling/)。 - - [基本过滤](https://opentelemetry.io/docs/collector/transforming-telemetry/) - 如果无法通过操作符执行,则丢弃不必要的事件(见下文)。 - - [批处理](https://github.com/open-telemetry/opentelemetry-collector/tree/main/processor/batchprocessor) - 在与 ClickHouse 交互时至关重要,以确保以批次方式发送数据。请参见[“导出到 ClickHouse”](#exporting-to-clickhouse)。 +- **处理器** - 处理器从[接收器获取数据并修改或转换](https://opentelemetry.io/docs/collector/transforming-telemetry/)它,然后将其发送到导出器。处理器按配置的顺序应用于收集器配置的 `processors` 部分。这些是可选的,但通常建议的最小集是[通常推荐](https://github.com/open-telemetry/opentelemetry-collector/tree/main/processor#recommended-processors)。在将 OTel 收集器与 ClickHouse 一起使用时,我们建议将处理器限制为: -- **操作符** - [操作符](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/pkg/stanza/docs/operators/README.md)提供了接收器可用的最基本处理单元。支持基本解析,允许设置严重性和时间戳等字段。这里支持 JSON 和正则表达式解析,以及事件过滤和基本转换。我们建议在这里进行事件过滤。 + - [memory_limiter](https://github.com/open-telemetry/opentelemetry-collector/blob/main/processor/memorylimiterprocessor/README.md)用于防止收集器出现内存不足的情况。请参阅[估算资源](#estimating-resources)以获取建议。 + - 任何基于上下文的丰富处理器。例如,[Kubernetes 属性处理器](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/k8sattributesprocessor)允许使用 k8s 元数据自动设置跨度、指标和日志资源属性,例如使用其源 pod id 丰富事件。 + - 如果需要跟踪,也可以使用[尾部或头部采样](https://opentelemetry.io/docs/concepts/sampling/)。 + - [基本过滤](https://opentelemetry.io/docs/collector/transforming-telemetry/) - 如果无法通过操作符实现,则丢弃不需要的事件(见下文)。 + - [批处理](https://github.com/open-telemetry/opentelemetry-collector/tree/main/processor/batchprocessor) - 在与 ClickHouse 交互时确保数据以批处理形式发送时是必需的。请参见[“导出到 ClickHouse”](#exporting-to-clickhouse)。 -我们建议用户避免使用操作符或[变换处理器](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/processor/transformprocessor/README.md)进行过多的事件处理。这些可能会消耗大量内存和 CPU,尤其是 JSON 解析。所有处理都可以在 ClickHouse 插入时使用物化视图和列完成,某些例外情况 - 特别是与上下文相关的增强,例如添加 k8s 元数据。有关更多详细信息,请参见[使用 SQL 提取结构](/use-cases/observability/schema-design#extracting-structure-with-sql)。 +- **操作符** - [操作符](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/pkg/stanza/docs/operators/README.md)提供了接收器中可用的最基本的处理单元。支持基本解析,允许设置如 Severity 和 Timestamp 等字段。此处支持 JSON 和正则表达式解析,以及事件过滤和基本转换。我们建议在此处执行事件过滤。 -如果使用 OTel 收集器进行处理,我们建议在网关实例上执行变换,并最小化代理实例上的工作量。这将确保服务器边缘运行的代理所需的资源尽可能少。通常,我们看到用户只执行过滤(以最小化不必要的网络使用)、时间戳设置(通过操作符)和增强,这些都需要在代理中处理上下文。例如,如果网关实例驻留在另一个 Kubernetes 集群中,k8s 增强将需要在代理中进行。 +我们建议用户避免大量使用操作符或[转换处理器](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/processor/transformprocessor/README.md)进行事件处理。这可能会产生相当大的内存和 CPU 开销,尤其是 JSON 解析。在 ClickHouse 中进行所有处理在插入时间使用物化视图是可能的,虽然有一些例外,特别是上下文感知的丰富,例如添加 k8s 元数据。有关更多详细信息,请参见[使用 SQL 提取结构](/use-cases/observability/schema-design#extracting-structure-with-sql)。 +如果通过 OTel 收集器进行处理,我们建议在网关实例中进行转换,并最小化在代理实例中进行的工作。这将确保在边缘运行的代理(例如服务器)所需的资源尽可能少。通常,我们看到用户仅执行过滤(以最小化不必要的网络使用)、时间戳设置(通过操作符)和需要上下文的丰富处理。例如,如果网关实例位于不同的 Kubernetes 集群中,k8s 丰富将需要在代理中发生。 ### 示例 {#example-2} -以下配置显示了对非结构化日志文件的收集。请注意使用操作符从日志行中提取结构(`regex_parser`)和过滤事件,以及使用处理器批处理事件并限制内存使用。 +以下配置显示了对非结构化日志文件的收集。请注意使用操作符从日志行中提取结构(`regex_parser`)以及过滤事件,以及使用处理器批处理事件并限制内存使用。 [config-unstructured-logs-with-processor.yaml](https://www.otelbin.io/#config=receivers%3A*N_filelog%3A*N___include%3A*N_____-_%2Fopt%2Fdata%2Flogs%2Faccess-unstructured.log*N___start*_at%3A_beginning*N___operators%3A*N_____-_type%3A_regex*_parser*N_______regex%3A_*%22%5E*C*QP*Lip*G%5B*Bd.%5D*P*D*Bs*P-*Bs*P-*Bs*P*B%5B*C*QP*Ltimestamp*G%5B%5E*B%5D%5D*P*D*B%5D*Bs*P%22*C*QP*Lmethod*G%5BA-Z%5D*P*D*Bs*P*C*QP*Lurl*G%5B%5E*Bs%5D*P*D*Bs*PHTTP%2F%5B%5E*Bs%5D*P%22*Bs*P*C*QP*Lstatus*G*Bd*P*D*Bs*P*C*QP*Lsize*G*Bd*P*D*Bs*P%22*C*QP*Lreferrer*G%5B%5E%22%5D***D%22*Bs*P%22*C*QP*Luser*_agent*G%5B%5E%22%5D***D%22*%22*N_______timestamp%3A*N_________parse*_from%3A_attributes.timestamp*N_________layout%3A_*%22*.d%2F*.b%2F*.Y%3A*.H%3A*.M%3A*.S_*.z*%22*N_________*H22%2FJan%2F2019%3A03%3A56%3A14_*P0330*N*N*Nprocessors%3A*N_batch%3A*N___timeout%3A_1s*N___send*_batch*_size%3A_100*N_memory*_limiter%3A*N___check*_interval%3A_1s*N___limit*_mib%3A_2048*N___spike*_limit*_mib%3A_256*N*N*Nexporters%3A*N_logging%3A*N___loglevel%3A_debug*N*N*Nservice%3A*N_pipelines%3A*N___logs%3A*N_____receivers%3A_%5Bfilelog%5D*N_____processors%3A_%5Bbatch%2C_memory*_limiter%5D*N_____exporters%3A_%5Blogging%5D%7E) @@ -335,16 +325,15 @@ service: ```bash ./otelcol-contrib --config config-unstructured-logs-with-processor.yaml ``` - ## 导出到 ClickHouse {#exporting-to-clickhouse} -导出器将数据发送到一个或多个后端或目标。导出器可以基于拉取或推送。为了将事件发送到 ClickHouse,用户需要使用推送式[ClickHouse 导出器](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/exporter/clickhouseexporter/README.md)。 +导出器将数据发送到一个或多个后端或目的地。导出器可以是基于拉取或推送的。为了将事件发送到 ClickHouse,用户需要使用基于推送的[ClickHouse 导出器](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/exporter/clickhouseexporter/README.md)。 :::note 使用 OpenTelemetry Collector Contrib -ClickHouse 导出器是[OpenTelemetry Collector Contrib](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main)的一部分,而不是核心分发版本。用户可以使用贡献版本或[构建自己的收集器](https://opentelemetry.io/docs/collector/custom-collector/)。 +ClickHouse 导出器是[OpenTelemetry Collector Contrib](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main)的一部分,而不是核心分发。用户可以使用 contrib 分发或[构建自己的收集器](https://opentelemetry.io/docs/collector/custom-collector/)。 ::: -完整的配置文件如下所示。 +下面是完整的配置文件。 [clickhouse-config.yaml](https://www.otelbin.io/#config=receivers%3A*N_filelog%3A*N___include%3A*N_____-_%2Fopt%2Fdata%2Flogs%2Faccess-structured.log*N___start*_at%3A_beginning*N___operators%3A*N_____-_type%3A_json*_parser*N_______timestamp%3A*N_________parse*_from%3A_attributes.time*_local*N_________layout%3A_*%22*.Y-*.m-*.d_*.H%3A*.M%3A*.S*%22*N_otlp%3A*N____protocols%3A*N______grpc%3A*N________endpoint%3A_0.0.0.0%3A4317*N*Nprocessors%3A*N_batch%3A*N___timeout%3A_5s*N___send*_batch*_size%3A_5000*N*Nexporters%3A*N_clickhouse%3A*N___endpoint%3A_tcp%3A%2F%2Flocalhost%3A9000*Qdial*_timeout*E10s*Acompress*Elz4*Aasync*_insert*E1*N___*H_ttl%3A_72h*N___traces*_table*_name%3A_otel*_traces*N___logs*_table*_name%3A_otel*_logs*N___create*_schema%3A_true*N___timeout%3A_5s*N___database%3A_default*N___sending*_queue%3A*N_____queue*_size%3A_1000*N___retry*_on*_failure%3A*N_____enabled%3A_true*N_____initial*_interval%3A_5s*N_____max*_interval%3A_30s*N_____max*_elapsed*_time%3A_300s*N*Nservice%3A*N_pipelines%3A*N___logs%3A*N_____receivers%3A_%5Bfilelog%5D*N_____processors%3A_%5Bbatch%5D*N_____exporters%3A_%5Bclickhouse%5D*N___traces%3A*N____receivers%3A_%5Botlp%5D*N____processors%3A_%5Bbatch%5D*N____exporters%3A_%5Bclickhouse%5D%7E&distro=otelcol-contrib%7E&distroVersion=v0.103.1%7E) @@ -384,7 +373,6 @@ exporters: max_interval: 30s max_elapsed_time: 300s - service: pipelines: logs: @@ -399,32 +387,32 @@ service: 请注意以下关键设置: -- **pipelines** - 上述配置强调了使用[管道](https://opentelemetry.io/docs/collector/configuration/#pipelines),包括一组接收器、处理器和导出器,其中包含日志和跟踪的管道。 -- **endpoint** - 通过 `endpoint` 参数配置与 ClickHouse 的通信。连接字符串 `tcp://localhost:9000?dial_timeout=10s&compress=lz4&async_insert=1` 导致通过 TCP 进行通信。如果用户出于流量切换原因更喜欢使用 HTTP,请按[此处](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/exporter/clickhouseexporter/README.md#configuration-options)所述修改此连接字符串。完整的连接详细信息,能够在此连接字符串中指定用户名和密码,在[此处](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/exporter/clickhouseexporter/README.md#configuration-options)进行详细说明。 +- **管道** - 上述配置突出了使用[管道](https://opentelemetry.io/docs/collector/configuration/#pipelines),其中包含一组接收器、处理器和导出器,分别用于日志和跟踪。 +- **端点** - 通过 `endpoint` 参数配置与 ClickHouse 的通信。连接字符串 `tcp://localhost:9000?dial_timeout=10s&compress=lz4&async_insert=1` 会导致通过 TCP 进行通信。如果用户出于流量切换原因更喜欢 HTTP,可以按照[这里](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/exporter/clickhouseexporter/README.md#configuration-options)所述修改此连接字符串。有关完整的连接详细信息,以及在此连接字符串中指定用户名和密码的能力,请参见[这里](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/exporter/clickhouseexporter/README.md#configuration-options)。 -**重要:** 请注意,上述连接字符串启用了压缩(lz4)和异步插入。我们建议始终启用这两项。有关异步插入的更多详细信息,请参见[批处理](#batching)。压缩应始终指定,并且在较旧版本的导出器中不会默认启用。 +**重要:** 请注意,以上连接字符串同时启用了压缩(lz4)以及异步插入。我们建议始终启用两者。有关异步插入的更多详细信息,请参见[批处理](#batching)。应该始终指定压缩,并且在旧版本的导出器中默认情况下不会启用。 -- **ttl** - 这里的值决定数据的保留时间。有关更多细节,请参见“管理数据”。这应指定为小时的时间单位,例如 72h。我们在下面的示例中禁用 TTL,因为我们的数据来自 2019 年,插入后将被 ClickHouse 立即删除。 -- **traces_table_name** 和 **logs_table_name** - 确定日志和跟踪表的名称。 -- **create_schema** - 确定是否在启动时使用默认架构创建表。对于入门应默认为 true。用户应将其设置为 false,并定义自己的架构。 +- **ttl** - 此值确定数据保留多长时间。更多详细信息见“管理数据”。此值应指定为小时的时间单位,例如 72h。我们在下面的示例中禁用 TTL,因为我们的数据来自 2019 年,并且如果插入将被 ClickHouse 立即删除。 +- **traces_table_name** 和 **logs_table_name** - 决定日志和跟踪表的名称。 +- **create_schema** - 决定启动时是否创建默认模式的表。默认情况下设置为 true 以便于入门。用户应将其设置为 false 并定义自己的架构。 - **database** - 目标数据库。 - **retry_on_failure** - 设置以确定是否应尝试失败的批次。 -- **batch** - 批处理处理器确保以批量形式发送事件。我们建议将值设置为 5000 左右,超时时间为 5 秒。达到这两个限制中的任何一个将启动一批数据刷新到导出器。降低这些值将意味着较低延迟的管道,在更早的时间内提供可查询的数据,代价是向 ClickHouse 发送更多的连接和批次。如果用户未使用[异步插入](https://clickhouse.com/blog/asynchronous-data-inserts-in-clickhouse),则不建议这样,因为这可能导致 ClickHouse 中的[分区片段过多](https://clickhouse.com/blog/common-getting-started-issues-with-clickhouse#1-too-many-parts)。相反,如果用户正在使用异步插入,则查询可用的数据也将取决于异步插入设置——尽管数据仍然会更早地从连接器刷新。有关更多详细信息,请参见[批处理](#batching)。 -- **sending_queue** - 控制发送队列的大小。队列中的每个项目都包含一批。如果超过此队列,例如由于 ClickHouse 不可达但事件仍然到达,则将丢弃批次。 +- **batch** - 批处理处理器确保事件以批处理形式发送。我们建议的值约为 5000,并超时为 5 秒。达到这两个值中的任何一个将触发批量刷新到导出器。降低这些值将意味着较低延迟的管道,数据可以更早获得查询,但会导致更多连接和批量发送到 ClickHouse。如果用户不使用[异步插入](https://clickhouse.com/blog/asynchronous-data-inserts-in-clickhouse),则不建议这样做,因为这可能会导致[分区片段过多](https://clickhouse.com/blog/common-getting-started-issues-with-clickhouse#1-too-many-parts)的问题。相反,如果用户正在使用异步插入,则可用于查询的数据的可用性也将取决于异步插入设置——尽管数据将更早地从连接器刷新。有关更多详细信息,请参见[批处理](#batching)。 +- **sending_queue** - 控制发送队列的大小。队列中的每个项目都包含一个批次。如果由于 ClickHouse 不可访问但事件仍在到达而超过此队列,批次将被丢弃。 -假设用户已提取结构化日志文件并运行[本地 ClickHouse 实例](/install)(使用默认身份验证),用户可以通过以下命令运行此配置: +假设用户已提取结构化日志文件并且有一个正在运行的[本地 ClickHouse 实例](/install)(使用默认身份验证),用户可以通过以下命令运行此配置: ```bash ./otelcol-contrib --config clickhouse-config.yaml ``` -要向此收集器发送跟踪数据,请使用 `telemetrygen` 工具运行以下命令: +要将跟踪数据发送到此收集器,请使用 `telemetrygen` 工具运行以下命令: ```bash $GOBIN/telemetrygen traces --otlp-insecure --traces 300 ``` -一旦运行,使用简单查询确认日志事件的存在: +一旦运行,通过简单查询确认日志事件是否存在: ```sql SELECT * @@ -453,7 +441,6 @@ LogAttributes: {'referer':'https://www.zanbil.ir/filter/p3%2Cb2','log.f 1 row in set. Elapsed: 0.012 sec. Processed 5.04 thousand rows, 4.62 MB (414.14 thousand rows/s., 379.48 MB/s.) Peak memory usage: 5.41 MiB. - Likewise, for trace events, users can check the `otel_traces` table: SELECT * @@ -488,13 +475,13 @@ Links.Attributes: [] ``` ## 开箱即用的架构 {#out-of-the-box-schema} -默认情况下,ClickHouse 导出器会为日志和跟踪创建目标日志表。可以通过设置 `create_schema` 来禁用此功能。此外,日志表和跟踪表的名称可以通过上述设置从其默认值 `otel_logs` 和 `otel_traces` 进行修改。 +默认情况下,ClickHouse 导出程序为日志和跟踪创建了目标日志表。这可以通过设置 `create_schema` 禁用。此外,日志表和跟踪表的名称可以通过上述设置从默认的 `otel_logs` 和 `otel_traces` 修改。 :::note -在下面的架构中,我们假设已启用 TTL(生存时间),值为 72 小时。 +在下面的架构中,我们假设已启用 TTL,时间为 72小时。 ::: -日志的默认架构如下所示(`otelcol-contrib v0.102.1`): +日志的默认架构如下所示(`otelcol-contrib v0.102.1`): ```sql CREATE TABLE default.otel_logs @@ -530,18 +517,18 @@ TTL toDateTime(Timestamp) + toIntervalDay(3) SETTINGS ttl_only_drop_parts = 1 ``` -此处的列与 OTel 官方文档中记录的日志规范相对应,可以在 [这里](https://opentelemetry.io/docs/specs/otel/logs/data-model/) 找到。 +这些列与 OTel 官方规范中记录的日志相对应,具体文档见 [这里](https://opentelemetry.io/docs/specs/otel/logs/data-model/)。 -有关此架构的一些重要说明: +关于此架构的一些重要说明: -- 默认情况下,表按日期进行分区,使用 `PARTITION BY toDate(Timestamp)`。这使得删除过期数据变得高效。 -- TTL 通过 `TTL toDateTime(Timestamp) + toIntervalDay(3)` 设置,并与收集器配置中设置的值相对应。[`ttl_only_drop_parts=1`](/operations/settings/merge-tree-settings#ttl_only_drop_parts) 表示仅在所有包含的行都过期时才删除整个分片。这比在分片内删除行更有效,因为后者需要昂贵的删除操作。我们建议始终将此设置为 1。有关更多详细信息,请参见 [带 TTL 的数据管理](/observability/managing-data#data-management-with-ttl-time-to-live)。 -- 表使用经典的 [`MergeTree` 引擎](/engines/table-engines/mergetree-family/mergetree)。这对于日志和追踪是推荐的,通常不需要更改。 -- 表按 `ORDER BY (ServiceName, SeverityText, toUnixTimestamp(Timestamp), TraceId)` 进行排序。这意味着查询将在 `ServiceName`、`SeverityText`、`Timestamp` 和 `TraceId` 上进行了优化 - 列表中较早的列过滤速度会比后面的列快,例如按 `ServiceName` 过滤将显著快于按 `TraceId` 过滤。用户应根据他们期望的访问模式修改此排序 - 请参阅 [选择主键](/use-cases/observability/schema-design#choosing-a-primary-ordering-key)。 -- 上述架构对列应用 `ZSTD(1)`。这为日志提供了最佳压缩。用户可以在压缩中增加 ZSTD 压缩级别(高于默认值1)以实现更好的压缩,尽管这通常收益不大。在插入时增加此值会导致更高的 CPU 开销(在压缩阶段),尽管解压缩(因此查询)应保持可比。有关更多细节,请参见 [这里](https://clickhouse.com/blog/optimize-clickhouse-codecs-compression-schema)。对时间戳还应用了额外的 [增量编码](/sql-reference/statements/create/table#delta),旨在减少其在磁盘上的大小。 -- 请注意 [`ResourceAttributes`](https://opentelemetry.io/docs/specs/otel/resource/sdk/)、[`LogAttributes`](https://opentelemetry.io/docs/specs/otel/logs/data-model/#field-attributes) 和 [`ScopeAttributes`](https://opentelemetry.io/docs/specs/otel/logs/data-model/#field-instrumentationscope) 是映射。用户应熟悉它们之间的区别。有关如何访问这些映射及优化访问其中键的方法,请参见 [使用映射](/use-cases/observability/schema-design#using-maps)。 -- 此处的其他大多数类型,例如 `ServiceName` 作为 LowCardinality 进行了优化。请注意,`Body`,作为我们的示例日志中的 JSON,被存储为字符串。 -- Bloom 筛选器应用于映射的键和值以及 `Body` 列。这些旨在改善访问这些列的查询时间,但通常不是必需的。有关更多信息,请参见 [二级/数据跳过索引](/use-cases/observability/schema-design#secondarydata-skipping-indices)。 +- 默认情况下,表按日期分区,使用 `PARTITION BY toDate(Timestamp)`。这使得删除过期数据更高效。 +- TTL 设置为 `TTL toDateTime(Timestamp) + toIntervalDay(3)`,并对应于收集器配置中设置的值。 [`ttl_only_drop_parts=1`](/operations/settings/merge-tree-settings#ttl_only_drop_parts) 表示只有在所有包含的行过期时,整个部分才会被删除。这比在部分内删除行更高效,因为后者涉及高开销的删除。我们建议始终设置此项。有关更多细节,请参见 [使用 TTL 进行数据管理](/observability/managing-data#data-management-with-ttl-time-to-live)。 +- 表使用经典的 [`MergeTree` 引擎](/engines/table-engines/mergetree-family/mergetree)。这对于日志和跟踪是推荐的,不应更改。 +- 表按 `ORDER BY (ServiceName, SeverityText, toUnixTimestamp(Timestamp), TraceId)` 排序。这意味着查询将针对 `ServiceName`、`SeverityText`、`Timestamp` 和 `TraceId` 上的过滤器进行优化 - 列表中前面的列过滤速度会比后面的列快,例如按 `ServiceName` 过滤的速度显著快于按 `TraceId` 过滤。用户应根据预期的访问模式修改此排序 - 请参见 [选择主键](/use-cases/observability/schema-design#choosing-a-primary-ordering-key)。 +- 上述架构对列应用了 `ZSTD(1)`。这为日志提供了最佳的压缩。用户可以增加 ZSTD 压缩级别(高于默认的 1)以实现更好的压缩,尽管这通常没有好处。增加此值将在插入时(在压缩期间)导致更大的 CPU 开销,尽管解压缩(从而查询)应该保持可比较。有关更多详情,请参见 [这里](https://clickhouse.com/blog/optimize-clickhouse-codecs-compression-schema)。同时,对 `Timestamp` 应用了额外的 [增量编码](/sql-reference/statements/create/table#delta),旨在减少其在磁盘上的大小。 +- 注意 [`ResourceAttributes`](https://opentelemetry.io/docs/specs/otel/resource/sdk/)、[`LogAttributes`](https://opentelemetry.io/docs/specs/otel/logs/data-model/#field-attributes) 和 [`ScopeAttributes`](https://opentelemetry.io/docs/specs/otel/logs/data-model/#field-instrumentationscope) 是映射。用户应该熟悉它们之间的区别。有关如何访问这些映射及优化访问键的方法,请参见 [使用映射](/use-cases/observability/schema-design#using-maps)。 +- 这里的大多数其他类型,例如 `ServiceName` 作为 LowCardinality,都经过了优化。请注意,`Body` 在我们的示例日志中是 JSON,存储为字符串。 +- 对映射的键和值以及 `Body` 列应用了布隆过滤器。这些旨在提高访问这些列的查询时间,但通常不是必需的。请参见 [二级/数据跳过索引](/use-cases/observability/schema-design#secondarydata-skipping-indices)。 ```sql CREATE TABLE default.otel_traces @@ -582,68 +569,68 @@ TTL toDateTime(Timestamp) + toIntervalDay(3) SETTINGS ttl_only_drop_parts = 1 ``` -同样,这将与 OTel 官方文档中记录的跟踪对应的列相关联,可以在 [这里](https://opentelemetry.io/docs/specs/otel/trace/api/) 找到。此架构采用许多与上述日志架构相同的设置,并附加了特定于跨度的 Link 列。 +同样,这将与记录在 [这里](https://opentelemetry.io/docs/specs/otel/trace/api/) 中的 OTel 官方规范对应的跟踪列相关联。这里的架构采用了与上述日志架构相同的许多设置,并且具有适用于跨度的附加链接列。 -我们建议用户禁用自动架构创建,并手动创建表。这允许修改主键和二级键,并增加引入额外列以优化查询性能的机会。有关更多详细信息,请参见 [架构设计](/use-cases/observability/schema-design)。 +我们建议用户禁用自动架构创建并手动创建他们的表。这允许修改主键和次键,并提供了引入额外列以优化查询性能的机会。有关更多详细信息,请参见 [架构设计](/use-cases/observability/schema-design)。 ## 优化插入 {#optimizing-inserts} -为了在获取强一致性保证的同时实现高插入性能,用户在通过收集器将可观察性数据插入 ClickHouse 时应遵循一些简单规则。通过正确配置 OTel 收集器,以下规则应当易于遵循。这还可以避免用户在首次使用 ClickHouse 时遇到的 [常见问题](https://clickhouse.com/blog/common-getting-started-issues-with-clickhouse)。 -### 批量处理 {#batching} +为了在获得强一致性保证的同时实现高插入性能,用户应在通过收集器将可观测性数据插入 ClickHouse 时遵循简单规则。正确配置 OTel 收集器后,遵循以下规则应简单明了。这还可以避免用户第一次使用 ClickHouse 时遇到的 [常见问题](https://clickhouse.com/blog/common-getting-started-issues-with-clickhouse)。 +### 批处理 {#batching} -默认情况下,发送到 ClickHouse 的每个插入都会导致 ClickHouse 立即创建一个包含插入数据及其他需要存储的元数据的存储部分。因此,与发送大量每个包含较少数据的插入相比,发送包含更多数据的较少插入会减少所需的写入次数。我们建议一次插入至少 1,000 行的数据。更多详细信息请参见 [这里](https://clickhouse.com/blog/asynchronous-data-inserts-in-clickhouse#data-needs-to-be-batched-for-optimal-performance)。 +默认情况下,发送到 ClickHouse 的每个插入会导致 ClickHouse 立即创建一个包含来自插入的数据以及其他需要存储的元数据的存储部分。因此,发送较少的插入而每个插入包含更多的数据,相比于发送更多的插入而每个插入包含较少的数据,将减少所需的写入次数。我们建议每次插入相当大的批次,至少为 1,000 行。有关更多详细信息,请 [点击这里](https://clickhouse.com/blog/asynchronous-data-inserts-in-clickhouse#data-needs-to-be-batched-for-optimal-performance)。 -默认情况下,插入到 ClickHouse 是同步的且在相同情况下是幂等的。对于合并树引擎系列的表,ClickHouse 默认会自动 [去重插入](https://clickhouse.com/blog/common-getting-started-issues-with-clickhouse#5-deduplication-at-insert-time)。这意味着在以下情况中插入是容错的: +默认情况下,对 ClickHouse 的插入是同步的,如果相同则为幂等的。对于 MergeTree 引擎系列的表,ClickHouse 默认会自动 [去重插入](https://clickhouse.com/blog/common-getting-started-issues-with-clickhouse#5-deduplication-at-insert-time)。这意味着在以下情况下,插入是宽容的: -- (1) 如果接收数据的节点出现问题,插入查询将超时(或出现更具体的错误),并不会收到确认。 -- (2) 如果数据被节点写入,但由于网络中断无法返回确认给查询的发送者,则发送者将收到超时或网络错误。 +- (1) 如果接收数据的节点出现问题,插入查询将超时(或获取更具体的错误),且不会收到确认。 +- (2) 如果数据已由节点写入,但由于网络中断无法将确认返回给查询的发送者,则发送者将收到超时或网络错误。 -从收集器的视角来看,(1) 和 (2) 可能很难区分。然而,在这两种情况下,未确认的插入可以立即重试。只要重试的插入查询包含相同的数据且顺序相同,ClickHouse 将自动忽略重试的插入,如果(未确认的)原始插入成功。 +从收集器的角度来看,(1) 和 (2) 可能很难区分。然而,在这两种情况下,未确认的插入可以立即重试。只要重试的插入查询包含相同的数据且顺序相同,如果(未确认的)原始插入成功,ClickHouse 将会自动忽略重试的插入。 -我们建议用户使用之前配置中显示的 [批处理处理器](https://github.com/open-telemetry/opentelemetry-collector/blob/main/processor/batchprocessor/README.md) 来满足上述要求。这确保插入作为一致的行批次发送,满足上述要求。如果收集器预计将具有高吞吐量(每秒事件),并且每次插入可以发送至少 5000 事件,则通常这是管道中所需的唯一批量。在这种情况下,收集器将在批处理器的 `timeout` 达到之前刷新批量,确保管道的端到端延迟保持较低,并且批量大小一致。 +我们建议用户使用之前配置中显示的 [批处理器](https://github.com/open-telemetry/opentelemetry-collector/blob/main/processor/batchprocessor/README.md) 满足以上要求。这确保插入以满足这些要求的一致批次的行发送。如果预计收集器将具有高吞吐量(每秒事件),并且每个插入可以发送至少 5000 个事件,这通常是管道中所需的唯一批处理。在这种情况下,收集器将在批处理器的 `timeout` 到达之前刷新批次,确保管道的端到端延迟保持较低,并且批次保持一致的大小。 ### 使用异步插入 {#use-asynchronous-inserts} -通常,当收集器的吞吐量较低时,用户被迫发送较小的批量,但他们仍期望数据在最低端到端延迟内到达 ClickHouse。在这种情况下,当批处理器的 `timeout` 到期时,将发送小批量。这可能会导致问题,这时需要异步插入。该情况通常出现在 **以代理角色配置的收集器直接发送到 ClickHouse** 的情况下。网关通过充当聚合器可以缓解这个问题 - 请参见 [使用网关扩展]("#scaling-with-gateways")。 +通常,当收集器的吞吐量较低时,用户被迫发送较小的批次,但仍希望数据在最低的端到端延迟内到达 ClickHouse。在这种情况下,当批处理器的 `timeout` 到期时会发送小批次。这可能会导致问题,并且在需要异步插入时出现。这种情况通常发生在 **处于代理角色的收集器被配置为直接发送到 ClickHouse**。网关通过充当聚合器可以缓解此问题 - 请参见 [使用网关进行扩展](#scaling-with-gateways)。 -如果无法确保大批量,用户可以通过 [异步插入](/best-practices/selecting-an-insert-strategy#asynchronous-inserts) 将批量处理委托给 ClickHouse。通过异步插入,数据首先插入到缓冲区,然后再将其写入数据库存储。 +如果不能保证大批次,用户可以通过使用 [异步插入](/best-practices/selecting-an-insert-strategy#asynchronous-inserts) Delegating 到 ClickHouse 来进行批处理。使用异步插入,数据首先插入缓冲区,然后稍后或异步写入数据库存储。 -使用 [启用异步插入](/optimize/asynchronous-inserts#enabling-asynchronous-inserts),当 ClickHouse ① 接收到插入查询时,查询的数据会 ② 立即写入到内存缓冲区。当 ③ 进行下一个缓冲区刷新时,缓冲区的数据会 [排序](/guides/best-practices/sparse-primary-indexes#data-is-stored-on-disk-ordered-by-primary-key-columns) 并作为部分写入数据库存储。请注意,在刷新到数据库存储之前,数据不可通过查询进行搜索;缓冲区刷新是 [可配置的](/optimize/asynchronous-inserts)。 +开启 [异步插入](/optimize/asynchronous-inserts#enabling-asynchronous-inserts) 时,当 ClickHouse ① 接收到插入查询时,查询的数据会首先 ② 立即写入一个内存缓冲区。当 ③ 下一个缓冲区刷新发生时,缓冲区的数据会 [排序](/guides/best-practices/sparse-primary-indexes#data-is-stored-on-disk-ordered-by-primary-key-columns) 并作为一个部分写入数据库存储。注意,在刷新到数据库存储之前,数据不能通过查询搜索;缓冲区刷新是 [可配置的](/optimize/asynchronous-inserts)。 -要为收集器启用异步插入,请将 `async_insert=1` 添加到连接字符串中。我们建议用户使用 `wait_for_async_insert=1`(默认)以获得交付保证 - 有关更多详细信息,请参见 [这里](https://clickhouse.com/blog/asynchronous-data-inserts-in-clickhouse)。 +要为收集器启用异步插入,请在连接字符串中添加 `async_insert=1`。我们建议用户使用 `wait_for_async_insert=1`(默认值)以获得交付保证 - 详情请见 [这里](https://clickhouse.com/blog/asynchronous-data-inserts-in-clickhouse)。 -一旦 ClickHouse 的缓冲区被刷新,异步插入的数据就会被插入。这发生在超过 [`async_insert_max_data_size`](/operations/settings/settings#async_insert_max_data_size) 后,或在首次 INSERT 查询后的 [`async_insert_busy_timeout_ms`](/operations/settings/settings#async_insert_max_data_size) 毫秒后。如果 `async_insert_stale_timeout_ms` 设置为非零值,则在最后一个查询后的 `async_insert_stale_timeout_ms` 毫秒后会插入数据。用户可以调整这些设置以控制管道的端到端延迟。可以在 [这里](/operations/settings/settings#async_insert) 找到用于调整缓冲区刷新的其他设置。通常,默认值是合适的。 +异步插入的数据在 ClickHouse 缓存被刷新后插入。这发生在超过 [`async_insert_max_data_size`](/operations/settings/settings#async_insert_max_data_size) 或自第一次 INSERT 查询以来经过 [`async_insert_busy_timeout_ms`](/operations/settings/settings#async_insert_max_data_size) 毫秒后。如果 `async_insert_stale_timeout_ms` 设置为非零值,则在上次查询以来的 `async_insert_stale_timeout_ms 毫秒` 后插入数据。用户可以调整这些设置以控制管道的端到端延迟。更多可用于调整缓冲区刷新的设置记录在 [这里](/operations/settings/settings#async_insert)。通常,默认设置是合适的。 :::note 考虑自适应异步插入 -在使用的代理数量较少、吞吐量较低但具有严格端到端延迟要求的情况下,[自适应异步插入](https://clickhouse.com/blog/clickhouse-release-24-02#adaptive-asynchronous-inserts) 可能会很有用。通常,这些不适用于高吞吐量的可观察性用例,如 ClickHouse 所示。 +在低数量代理同时使用、吞吐量低而对端到端延迟要求严格的情况下,[自适应异步插入](https://clickhouse.com/blog/clickhouse-release-24-02#adaptive-asynchronous-inserts) 可能会很有用。一般而言,这些不适用于高吞吐量的可观测性用例,如 ClickHouse 所示。 ::: -最后,使用异步插入时,之前与 ClickHouse 的同步插入相关的去重行为默认不启用。如有需要,请参见设置 [`async_insert_deduplicate`](/operations/settings/settings#async_insert_deduplicate)。 +最后,使用异步插入时,与 ClickHouse 的同步插入相关的之前的去重行为默认未启用。如有需要,请查看设置 [`async_insert_deduplicate`](/operations/settings/settings#async_insert_deduplicate)。 -有关配置此功能的完整详细信息,请参见 [这里](/optimize/asynchronous-inserts#enabling-asynchronous-inserts),更深入的信息请参见 [这里](https://clickhouse.com/blog/asynchronous-data-inserts-in-clickhouse)。 +有关配置此功能的完整信息,请见 [这里](/optimize/asynchronous-inserts#enabling-asynchronous-inserts),并在 [这里](https://clickhouse.com/blog/asynchronous-data-inserts-in-clickhouse) 深入了解。 ## 部署架构 {#deployment-architectures} -在使用 OTel 收集器与 ClickHouse 的情况下,有几种部署架构是可能的。我们在下面描述每种架构及其适用情况。 +使用 OTel 收集器与 Clickhouse 时,可能有几种部署架构。我们将在下面描述每种架构以及其可能适用的情况。 ### 仅代理 {#agents-only} -在仅代理的架构中,用户将 OTel 收集器部署为边缘代理。这些代理接收来自本地应用程序的跟踪信息(例如,作为侧车容器)并从服务器和 Kubernetes 节点收集日志。在此模式下,代理直接将数据发送到 ClickHouse。 +在仅代理的架构中,用户将 OTel 收集器部署为代理到边缘。这些代理接收来自本地应用程序(例如,作为边车容器)的跟踪,并从服务器和 Kubernetes 节点收集日志。在此模式下,代理将数据直接发送到 ClickHouse。 -此架构适合小型到中型部署。其主要优点是它不需要额外的硬件,并且保持 ClickHouse 可观察性解决方案的总体资源占用最小,应用程序与收集器之间的映射简单。 +此架构适合小型到中型的部署。其主要优点是它不需要额外的硬件,并且保持 ClickHouse 可观测性解决方案的总资源占用最小,应用程序与收集器之间的映射简单。 -一旦代理数量超过几百,用户应考虑迁移到基于网关的架构。此架构有几个缺点,使其难以扩展: +一旦代理数量超过几百,用户应该考虑迁移到基于网关的架构。此架构有几个缺点,使其难以扩展: -- **连接扩展** - 每个代理将与 ClickHouse 建立连接。尽管 ClickHouse 具有维护数百(如果不是数千个)并发插入连接的能力,但这最终将成为限制因素,并使插入效率降低 - 即 ClickHouse 维护连接将消耗更多资源。使用网关可以最小化连接数量,使插入更加高效。 -- **边缘处理** - 在此架构中,任何转换或事件处理都必须在边缘或在 ClickHouse 中进行。这不仅具有限制性,还可能意味着需要复杂的 ClickHouse 物化视图,或者将大量计算推送到边缘 - 而在这里,关键服务可能会受到影响,并且资源稀缺。 -- **小批次和延迟** - 代理收集器可能单独收集非常少的事件。这通常意味着它们需要配置为定期刷新以满足交付服务水平协议。这可能导致收集器将小批量发送到 ClickHouse。虽然这是一个缺点,但可以通过异步插入来缓解 - 请参见 [优化插入](#optimizing-inserts)。 -### 与网关扩展 {#scaling-with-gateways} +- **连接扩展** - 每个代理将与 ClickHouse 建立连接。虽然 ClickHouse 能够维持数百(如果不是数千个)并发插入连接,但这最终将成为限制因素,并使插入效率降低 - 也就是说,ClickHouse 维护连接所需的资源会更多。使用网关可以最小化连接数量并提高插入效率。 +- **边缘处理** - 在此架构中,必须在边缘或 ClickHouse 中执行任何转换或事件处理。这不仅限制了代理的功能,还可能意味着复杂的 ClickHouse 物化视图或将大量计算推向边缘 - 在那里可能会影响关键服务且资源稀缺。 +- **小批次和延迟** - 代理收集器可能单独收集的事件非常有限。这通常意味着它们需要配置为在设定的时间间隔内刷新以满足交付 SLA。这可能会导致收集器向 ClickHouse 发送小批次。虽然这是一个缺点,但可以通过异步插入来缓解 - 请参见 [优化插入](#optimizing-inserts)。 +### 使用网关进行扩展 {#scaling-with-gateways} -OTel 收集器可以作为网关实例进行部署,以解决上述限制。这些提供了一个独立的服务,通常按数据中心或地区划分。这些通过单个 OTLP 端点接收来自应用程序(或其他处于代理角色的收集器)的事件。通常会部署一组网关实例,并使用现成的负载均衡器在它们之间分配负载。 +OTel 收集器可以作为网关实例部署,以解决上述限制。这些提供独立服务,通常每个数据中心或每个区域。这些通过单个 OTLP 端点接收来自应用程序(或其他处于代理角色的收集器)的事件。通常会部署一组网关实例,并使用开箱即用的负载均衡器在它们之间分配负载。 -该架构的目标是将计算密集型处理从代理处卸载,从而最小化它们的资源使用。这些网关可以执行本应由代理执行的转换任务。此外,通过聚合来自多个代理的事件,网关可以确保将大型批量发送到 ClickHouse - 从而实现高效插入。这些网关收集器可以很容易地随着代理的增加和事件吞吐量的增加而扩展。以下是示例网关配置,以及消费示例结构化日志文件的相关代理配置。请注意在代理与网关之间使用 OTLP 进行通信。 +此架构的目标是将计算密集型处理卸载掉代理,从而最大限度地减少它们的资源使用。这些网关可以执行原本需要由代理完成的转换任务。此外,通过聚合来自多个代理的事件,网关可以确保将大批次发送到 ClickHouse - 实现高效插入。这些网关收集器可以随着添加更多代理和增加事件吞吐量而轻松扩展。下面显示的是一个示例网关配置,以及一个关联的代理配置,后者消耗示例结构化日志文件。注意使用 OTLP 作为代理和网关之间的通信。 [clickhouse-agent-config.yaml](https://www.otelbin.io/#config=receivers%3A*N_filelog%3A*N___include%3A*N_____-_%2Fopt%2Fdata%2Flogs%2Faccess-structured.log*N___start*_at%3A_beginning*N___operators%3A*N_____-_type%3A_json*_parser*N_______timestamp%3A*N_________parse*_from%3A_attributes.time*_local*N_________layout%3A_*%22*.Y-*.m-*.d_*.H%3A*.M%3A*.S*%22*N*Nprocessors%3A*N_batch%3A*N___timeout%3A_5s*N___send*_batch*_size%3A_1000*N*Nexporters%3A*N_otlp%3A*N___endpoint%3A_localhost%3A4317*N___tls%3A*N_____insecure%3A_true_*H_Set_to_false_if_you_are_using_a_secure_connection*N*Nservice%3A*N_telemetry%3A*N___metrics%3A*N_____address%3A_0.0.0.0%3A9888_*H_Modified_as_2_collectors_running_on_same_host*N_pipelines%3A*N___logs%3A*N_____receivers%3A_%5Bfilelog%5D*N_____processors%3A_%5Bbatch%5D*N_____exporters%3A_%5Botlp%5D%7E&distro=otelcol-contrib%7E&distroVersion=v0.103.1%7E) @@ -714,39 +701,39 @@ service: exporters: [clickhouse] ``` -可以使用以下命令运行这些配置。 +这些配置可以使用以下命令运行。 ```bash ./otelcol-contrib --config clickhouse-gateway-config.yaml ./otelcol-contrib --config clickhouse-agent-config.yaml ``` -此架构的主要缺点是相关的成本和管理一组收集器的开销。 +此架构的主要缺点是管理一组收集器的相关成本和开销。 -有关如何管理较大的基于网关的架构的示例,以及相关的学习,我们建议查看这篇 [博客](https://clickhouse.com/blog/building-a-logging-platform-with-clickhouse-and-saving-millions-over-datadog)。 +有关管理较大基于网关的架构及相关学习的示例,我们推荐这篇 [博客文章](https://clickhouse.com/blog/building-a-logging-platform-with-clickhouse-and-saving-millions-over-datadog)。 ### 添加 Kafka {#adding-kafka} -读者可能会注意到上述架构未使用 Kafka 作为消息队列。 +读者可能会注意到上述架构没有使用 Kafka 作为消息队列。 -使用 Kafka 队列作为消息缓冲区是一种在日志架构中常见的设计模式,由 ELK 堆栈所普及。它提供了一些好处;主要是它有助于提供更强的消息传递保证,并有助于处理背压。消息从收集代理发送到 Kafka 并写入磁盘。理论上,集群的 Kafka 实例应该提供高吞吐量的消息缓冲,因为它以线性方式写入数据到磁盘的计算开销小于解析和处理消息 - 在 Elastic 中,例如,标记化和索引需要大量开销。将数据移离代理还降低了因源处的日志轮换而丢失消息的风险。最后,它提供了一些消息重放和跨区域复制的能力,这对某些用例可能是有吸引力的。 +使用 Kafka 阈列作为消息缓冲区是一种在日志架构中常见的设计模式,被 ELK 堆栈推广。它提供了几个好处;主要是,它有助于提供更强的消息交付保证,并有助于处理背压。消息从收集代理发送到 Kafka,然后写入磁盘。在理论上,集群 Kafka 实例应该提供高吞吐量的消息缓冲,因为将数据线性写入磁盘所需的计算开销小于解析和处理消息 - 例如,在 Elastic 中,标记化和索引会产生较大的开销。通过将数据从代理处移开,您还会减少由于源的日志轮换而丢失消息的风险。最后,它还提供了一些消息重放和跨区域复制功能,这可能对某些用例具有吸引力。 -然而,ClickHouse 可以非常快速地处理数据插入 - 在适度硬件上每秒数百万行。来自 ClickHouse 的背压是 **罕见** 的。通常,利用 Kafka 队列意味着更多的架构复杂性和成本。如果您能接受日志不需要与银行交易和其他关键数据相同的交付保证原则,我们建议避免 Kafka 的复杂性。 +然而,ClickHouse 可以非常快速地处理数据插入 - 在中等硬件上可达每秒数百万行。ClickHouse 的背压是 **罕见的**。通常,利用 Kafka 阈列意味着增加架构复杂性和成本。如果您能够接受日志不需要与银行交易和其他关键数据相同的交付保证的原则,我们建议避免 Kafka 的复杂性。 -但是,如果您需要高交付保证或重放数据的能力(可能是面向多个源),Kafka 可以作为有用的架构补充。 +但是,如果您需要高交付保证或重放数据的能力(潜在的多源),Kafka 可以成为一个有用的架构补充。 -在这种情况下,OTel 代理可以配置为通过 [Kafka 导出器](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/exporter/kafkaexporter/README.md) 将数据发送到 Kafka。然后,网关实例使用 [Kafka 接收器](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/receiver/kafkareceiver/README.md) 消费消息。我们建议参考 Confluent 和 OTel 文档以获取更多详细信息。 -### 估算资源 {#estimating-resources} +在这种情况下,可以通过 [Kafka 导出器](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/exporter/kafkaexporter/README.md) 配置 OTel 代理将数据发送到 Kafka。网关实例转而使用 [Kafka 接收器](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/receiver/kafkareceiver/README.md) 消费消息。对于更多详细信息,我们推荐 Confluent 和 OTel 文档。 +### 资源估算 {#estimating-resources} -OTel 收集器的资源需求将取决于事件吞吐量、消息的大小和执行的处理量。OpenTelemetry 项目维护了 [用户基准](https://opentelemetry.io/docs/collector/benchmarks/),可用于估算资源需求。 +OTel 收集器的资源需求将取决于事件吞吐量、消息大小和执行的处理量。OpenTelemetry 项目维护了 [基准测试用户](https://opentelemetry.io/docs/collector/benchmarks/) 可用以估算资源需求。 -[根据我们的经验](https://clickhouse.com/blog/building-a-logging-platform-with-clickhouse-and-saving-millions-over-datadog#architectural-overview),一个拥有 3 核心和 12GB RAM 的网关实例可以处理大约每秒 60,000 个事件。这假设有一个最小的处理管道,负责重命名字段且没有正则表达式。 +[根据我们的经验](https://clickhouse.com/blog/building-a-logging-platform-with-clickhouse-and-saving-millions-over-datadog#architectural-overview),具有 3 个核心和 12GB RAM 的网关实例可以处理大约每秒 60,000 个事件。这假设有一个负责重命名字段的最小处理管道,并且没有正则表达式。 -对于负责将事件传输到网关的代理实例,并只为事件设置时间戳,我们建议用户根据预期的每秒日志数量进行资源配置。以下是用户可以作为起点的近似数字: +对于负责将事件运输到网关的代理实例,仅需设置事件的时间戳,我们建议根据预期的每秒日志数量进行规模调整。以下数字代表用户可以作为起点使用的近似数字: -| 日志记录速率 | 收集器代理所需资源 | -|--------------|---------------------| -| 1k/秒 | 0.2 CPU, 0.2 GiB | -| 5k/秒 | 0.5 CPU, 0.5 GiB | -| 10k/秒 | 1 CPU, 1 GiB | +| 日志率 | 收集器代理所需的资源 | +|---------------|---------------------| +| 1k/秒 | 0.2 CPU, 0.2 GiB | +| 5k/秒 | 0.5 CPU, 0.5 GiB | +| 10k/秒 | 1 CPU, 1 GiB | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/build-your-own/integrating-opentelemetry.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/build-your-own/integrating-opentelemetry.md.hash index b8dd37b6fb4..a90ad5947c7 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/build-your-own/integrating-opentelemetry.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/build-your-own/integrating-opentelemetry.md.hash @@ -1 +1 @@ -18e008ccd46e02fb +ad06959abbeebc7b diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/build-your-own/introduction.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/build-your-own/introduction.md index 174b4cb32b1..a7255e4619b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/build-your-own/introduction.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/build-your-own/introduction.md @@ -1,6 +1,6 @@ --- 'title': '介绍' -'description': '使用 ClickHouse 作为可观察性解决方案' +'description': '使用 ClickHouse 作为观察解决方案' 'slug': '/use-cases/observability/introduction' 'keywords': - 'observability' @@ -11,6 +11,7 @@ - 'Grafana' - 'OTel' 'show_related_blogs': true +'doc_type': 'guide' --- import observability_1 from '@site/static/images/use-cases/observability/observability-1.png'; @@ -18,90 +19,88 @@ import observability_2 from '@site/static/images/use-cases/observability/observa import Image from '@theme/IdealImage'; -# 使用 ClickHouse 进行可观测性 +# 使用 ClickHouse 进行可观察性 ## 引言 {#introduction} -本指南旨在为希望使用 ClickHouse 构建基于 SQL 的可观测性解决方案的用户提供指导,重点关注日志和追踪。这涵盖了构建自己解决方案的各个方面,包括数据摄取、为访问模式优化架构和从非结构化日志中提取结构。 +本指南旨在为希望使用 ClickHouse 构建自己的基于 SQL 的可观察性解决方案的用户提供帮助,重点关注日志和跟踪。内容涵盖了构建您自己的解决方案的所有方面,包括数据摄取、优化访问模式的模式以及从非结构化日志中提取结构的考虑。 -单靠 ClickHouse 并不是一个即插即用的可观测性解决方案。然而,它可以作为一个高效的存储引擎用于可观测性数据,具备无与伦比的压缩率和闪电般快速的查询响应时间。为了使用户能够在可观测性解决方案中使用 ClickHouse,需要一个用户界面和数据收集框架。目前我们推荐使用 **Grafana** 来可视化可观测性信号,而 **OpenTelemetry** 用于数据收集(两者都是官方支持的集成)。 +ClickHouse 本身并不是可观察性的现成解决方案。然而,它可以作为一个高效的存储引擎,用于可观察性数据,具备无与伦比的压缩率和闪电般的查询响应时间。为了让用户在可观察性解决方案中使用 ClickHouse,既需要用户界面,也需要数据收集框架。目前,我们建议使用 **Grafana** 来可视化可观察性信号,以及使用 **OpenTelemetry** 来收集数据(两者都是官方支持的集成)。
:::note 不仅仅是 OpenTelemetry -虽然我们推荐使用 OpenTelemetry (OTel)项目进行数据收集,但也可以使用其他框架和工具产生类似的架构,例如 Vector 和 Fluentd (参见 [示例](https://clickhouse.com/blog/kubernetes-logs-to-clickhouse-fluent-bit) 使用 Fluent Bit)。还存在其他可视化工具,包括 Superset 和 Metabase。 +尽管我们的建议是使用 OpenTelemetry (OTel) 项目进行数据收集,但也可以使用其他框架和工具(例如 Vector 和 Fluentd)构建类似的架构(参见 [一个示例](https://clickhouse.com/blog/kubernetes-logs-to-clickhouse-fluent-bit)使用 Fluent Bit)。还存在其他可视化工具,包括 Superset 和 Metabase。 ::: ## 为什么使用 ClickHouse? {#why-use-clickhouse} -任何集中式可观测性存储的最重要特征是能快速聚合、分析和搜索来自各种来源的大量日志数据。这种集中化简化了故障排除,使得更容易找出服务中断的根本原因。 +任何集中式可观察性存储的最重要特点是能够快速聚合、分析和搜索来自不同源的海量日志数据。这种集中化简化了故障排除,使得更容易找出服务中断的根本原因。 -由于用户越来越关注成本,并发现这些即插即用产品的成本高而且不可预测,相比于它们所带来的价值,经济高效且可预测的日志存储比以往任何时候都更有价值,而查询性能令人满意。 +随着用户对价格的敏感度增加,以及相比于它们带来的价值,这些现成产品的成本被认为较高且不可预测,成本效益高且可预测的日志存储,在查询性能可接受的情况下,比以往任何时候都更有价值。 -由于其性能和成本效率,ClickHouse 已成为可观测性产品中日志和追踪存储引擎的事实标准。 +由于其性能和成本效益,ClickHouse 在可观察性产品中的日志和跟踪存储引擎中已成为事实上的标准。 -更具体地说,以下几点表明 ClickHouse 特别适合用于存储可观测性数据: +更具体地说,以下几点使 ClickHouse 特别适合存储可观察性数据: -- **压缩** - 可观测性数据通常包含其值取自于不同集合的字段,例如 HTTP 代码或服务名称。ClickHouse 的列式存储,数据以排序方式存储,使得这些数据能够极为有效地压缩——特别是结合一系列针对时间序列数据的专用编解码器。与其他数据存储不同,后者通常需要与原始数据大小相等的存储空间(通常为 JSON 格式),ClickHouse 平均可以将日志和追踪压缩至 14 倍以上。除了为大型可观测性安装提供显著的存储节约外,这种压缩还加速了查询,因为需要从磁盘读取的数据量减少。 -- **快速聚合** - 可观测性解决方案通常涉及通过图表可视化数据,例如显示错误率的线图或显示流量来源的条形图。聚合或 GROUP BY 对于驱动这些图表至关重要,当在故障诊断工作流程中应用过滤器时,也必须快速和响应。ClickHouse 的列式格式结合向量化查询执行引擎非常适合快速聚合,稀疏索引允许根据用户的操作快速过滤数据。 -- **快速线性扫描** - 虽然替代技术依赖于倒排索引来快速查询日志,但这不可避免地导致高磁盘和资源利用率。虽然 ClickHouse 提供了倒排索引作为附加可选索引类型,但线性扫描是高度并行化的,并利用机器上所有可用的核心(除非另行配置)。这可能允许每秒扫描数十 GB(压缩)以寻找匹配的 [高度优化的文本匹配操作符](/sql-reference/functions/string-search-functions)。 -- **SQL 的熟悉性** - SQL 是所有工程师都熟悉的通用语言。经过超过 50 年的发展,SQL 已证明自己是数据分析的事实标准语言,并仍然是 [第三大流行编程语言](https://clickhouse.com/blog/the-state-of-sql-based-observability#lingua-franca)。可观测性只是另一个数据问题,SQL 在这里是理想的选择。 -- **分析函数** - ClickHouse 扩展 ANSI SQL,引入了旨在简化 SQL 查询的分析函数。这些功能对于执行根本原因分析的用户至关重要,数据需要被切片和切块。 -- **二级索引** - ClickHouse 支持二级索引,例如布隆过滤器,以加速特定的查询配置。这些索引可以在列级别可选启用,赋予用户细粒度的控制,并允许他们评估成本-性能的好处。 -- **开源和开放标准** - 作为开源数据库,ClickHouse 采用开放标准,例如 OpenTelemetry。能参与和积极贡献项目的能力具有吸引力,同时避免了供应商锁定的挑战。 +- **压缩** - 可观察性数据通常包含从不同集合中提取的字段值,例如 HTTP 代码或服务名称。ClickHouse 的列式存储意味着这些数据可以很好地压缩,尤其是与一系列专门的时间序列数据编解码器结合时。与其他数据存储不同,后者通常需要与原始数据大小一样多的存储空间(典型格式为 JSON),ClickHouse 在平均压缩日志和跟踪时可达到 14 倍以上。除了为大型可观察性安装提供显著的存储节省外,这种压缩还帮助加速查询,因为读取的磁盘数据更少。 +- **快速聚合** - 可观察性解决方案通常涉及通过图表进行数据可视化,例如显示错误率的线或显示流量来源的条形图。聚合或 GROUP BY 是驱动这些图表的基本内容,也必须在工作流中应用过滤器进行故障诊断时快速响应。ClickHouse 的列式格式结合向量化查询执行引擎非常适合快速聚合,稀疏索引允许在用户操作响应中快速过滤数据。 +- **快速线性扫描** - 虽然替代技术依赖于倒排索引来快速查询日志,但这不可避免地导致高磁盘和资源利用率。虽然 ClickHouse 提供倒排索引作为可选的附加索引类型,但线性扫描是高度并行化的,并使用机器上所有可用的核心(除非另有配置)。这可能允许每秒扫描 10 GB/s 的压缩数据以查找匹配项,与 [高度优化的文本匹配运算符](/sql-reference/functions/string-search-functions)结合使用。 +- **SQL 的熟悉度** - SQL 是所有工程师都熟悉的通用语言。经过 50 多年的发展,它已经证明自己是数据分析的事实标准语言,并且仍然是 [第三大最流行的编程语言](https://clickhouse.com/blog/the-state-of-sql-based-observability#lingua-franca)。可观察性只不过是 SQL 理想的数据问题。 +- **分析函数** - ClickHouse 扩展了 ANSI SQL,提供了旨在简化 SQL 查询的分析函数。这些函数对于进行根本原因分析的用户至关重要,因为数据需要切片和切块。 +- **二级索引** - ClickHouse 支持二级索引,如布隆过滤器,以加速特定的查询配置。用户可以在列级别选择性启用这些索引,提供细粒度控制,并允许用户评估成本效益。 +- **开源与开放标准** - 作为一个开源数据库,ClickHouse 采用 OpenTelemetry 等开放标准。能够参与和积极参与项目是其吸引力,同时避免了供应商锁定的挑战。 -## 何时使用 ClickHouse 进行可观测性 {#when-should-you-use-clickhouse-for-observability} +## 何时使用 ClickHouse 进行可观察性 {#when-should-you-use-clickhouse-for-observability} -使用 ClickHouse 进行可观测性数据要求用户接受基于 SQL 的可观测性。我们推荐 [这篇博客文章](https://clickhouse.com/blog/the-state-of-sql-based-observability) 了解基于 SQL 的可观测性历史,但总结如下: +使用 ClickHouse 处理可观察性数据需要用户接受基于 SQL 的可观察性。我们推荐 [这篇博客文章](https://clickhouse.com/blog/the-state-of-sql-based-observability) 作为基于 SQL 的可观察性的历史总结,但总而言之: -如果您或您的团队: +如果以下情况适合您,基于 SQL 的可观察性会很适合您: -- 熟悉 SQL (或想学习它) -- 偏好遵循开放标准如 OpenTelemetry,以避免被锁定并实现可扩展性。 -- 愿意运行一个由开源创新推动的生态系统,从数据收集到存储和可视化。 -- 设想可管理的可观测性数据量的中等或大幅增长(甚至非常大) -- 希望控制 TCO (总拥有成本),避免不断上涨的可观测性成本。 -- 无法或不想因管理成本而在可观测性数据上面临较短的数据保留期。 +- 您或您的团队熟悉 SQL(或想要学习它) +- 您更愿意遵循开放标准,如 OpenTelemetry,以避免锁定并实现可扩展性。 +- 您愿意运行一个由开源创新从收集到存储和可视化驱动的生态系统。 +- 您预见到在管理下会有中到大规模的可观察性数据增长(甚至非常大)。 +- 您想控制 TCO(总拥有成本)并避免可观察性成本飙升。 +- 您无法或不想为您的可观察性数据设定小的数据保留期限以管理成本。 -那么,基于 SQL 的可观测性适合您。 - -如果您: +如果以下情况适合您,则基于 SQL 的可观察性可能不适合您: - 学习(或生成!)SQL 对您或您的团队没有吸引力。 -- 寻找打包的、端到端的可观测性体验。 -- 您的可观测性数据量太小,无法产生任何显著的差异(例如 <150 GiB),并且没有预期增长。 -- 您的用例是以指标为重的并且需要 PromQL。在这种情况下,您仍然可以将 ClickHouse 用于日志和追踪,同时使用 Prometheus 处理指标,在呈现层使用 Grafana 统一。 -- 更倾向于等待生态系统进一步成熟,基于 SQL 的可观测性变得更为一体化。 +- 您在寻找一个打包的、端到端的可观察性体验。 +- 您的可观察性数据量太小,以至于没有明显的差异(例如 <150 GiB),并且预计不会增长。 +- 您的用例偏重于指标并需要 PromQL。在这种情况下,您仍然可以在 ClickHouse 中使用日志和跟踪,同时使用 Prometheus 来处理指标,将其在展示层与 Grafana 统一。 +- 您更倾向于等待生态系统更加成熟,基于 SQL 的可观察性变得更具完成度。 -## 日志和追踪 {#logs-and-traces} +## 日志和跟踪 {#logs-and-traces} -可观测性用例有三个独特支柱:日志、追踪和指标。每个支柱都有不同的数据类型和访问模式。 +可观察性用例有三个不同的支柱:日志、跟踪和指标。每个支柱都有不同的数据类型和访问模式。 -我们当前推荐 ClickHouse 用于存储两种类型的可观测性数据: +我们目前推荐 ClickHouse 用于存储两种类型的可观察性数据: -- **日志** - 日志是事件在系统内发生时的时间戳记录,捕捉关于软件操作不同方面的详细信息。日志中的数据通常是非结构化或半结构化的,可以包括错误消息、用户活动日志、系统更改和其他事件。日志对故障排除、异常检测以及理解系统内导致问题的具体事件至关重要。 +- **日志** - 日志是系统中发生事件的时间戳记录,捕捉有关软件操作各个方面的详细信息。日志中的数据通常是非结构化或半结构化的,可能包括错误消息、用户活动日志、系统更改和其他事件。日志对于故障排除、异常检测和理解导致系统问题的特定事件至关重要。 ```response 54.36.149.41 - - [22/Jan/2019:03:56:14 +0330] "GET /filter/27|13%20%D9%85%DA%AF%D8%A7%D9%BE%DB%8C%DA%A9%D8%B3%D9%84,27|%DA%A9%D9%85%D8%AA%D8%B1%20%D8%A7%D8%B2%205%20%D9%85%DA%AF%D8%A7%D9%BE%DB%8C%DA%A9%D8%B3%D9%84,p53 HTTP/1.1" 200 30577 "-" "Mozilla/5.0 (compatible; AhrefsBot/6.1; +http://ahrefs.com/robot/)" "-" ``` -- **追踪** - 追踪记录请求在分布式系统中穿越不同服务的过程,详细说明这些请求的路径和性能。追踪中的数据高度结构化,由跨度和追踪组成,描绘请求经过的每个步骤,包括时间信息。追踪提供了对系统性能的宝贵见解,帮助识别瓶颈、延迟问题,并优化微服务的效率。 +- **跟踪** - 跟踪捕捉请求在分布式系统中通过不同服务的过程,详细说明这些请求的路径和性能。跟踪中的数据是高度结构化的,由跨度和跟踪组成,描绘了请求经过的每一个步骤,包括时间信息。跟踪提供了对系统性能的宝贵洞察,帮助识别瓶颈、延迟问题,并优化微服务的效率。 :::note 指标 -虽然 ClickHouse 可以用来存储指标数据,但这一支柱在 ClickHouse 中相对不成熟,缺少对 Prometheus 数据格式和 PromQL 的支持。 +虽然 ClickHouse 可用于存储指标数据,但该支柱在 ClickHouse 中尚不成熟,尚待支持 Prometheus 数据格式和 PromQL 等功能。 ::: ### 分布式追踪 {#distributed-tracing} -分布式追踪是可观测性的关键特性。分布式追踪,简单称为追踪,映射请求在系统中的旅程。请求将由最终用户或应用程序发起,并在整个系统中传播,通常导致微服务之间的流动。通过记录这个序列,并允许随后的事件相关联,它使得可观测性用户或 SRE 能够诊断应用流程中的问题,无论架构多么复杂或无服务器。 +分布式追踪是可观察性的重要特性。分布式追踪,也就是简单的追踪,映射了请求在系统中的旅程。请求将来自最终用户或应用程序,并在系统中传播,通常导致微服务之间的一系列动作。通过记录这个顺序,并允许后续事件关联,它使可观察性用户或 SRE 能够诊断应用程序流程中的问题,无论架构如何复杂或无服务器。 -每个追踪由若干跨度组成,初始跨度与请求关联,称为根跨度。该根跨度捕获整个请求的开始和结束。根下的后续跨度提供对请求过程中发生的各种步骤或操作的详细见解。没有追踪,在分布式系统中诊断性能问题可能极为困难。追踪通过详细描述请求在系统中移动过程中的事件序列,简化了调试和理解分布式系统的过程。 +每个追踪由多个跨度组成,与请求相关的初始跨度称为根跨度。这个根跨度捕获整个请求的开始和结束。后续的跨度提供有关请求过程中发生的各个步骤或操作的详细见解。没有追踪,在分布式系统中诊断性能问题可能极其困难。追踪通过详细说明请求在系统中移动时的事件顺序,简化了调试和理解分布式系统的过程。 -大多数可观测性供应商将这些信息可视化为瀑布图,相对时间使用相应大小的水平条显示。例如,在 Grafana 中: +大多数可观察性供应商将此信息可视化为瀑布图,使用相对时间显示相应大小的水平条。例如,在 Grafana 中: -对于需要深入理解日志和追踪概念的用户,我们强烈推荐 [OpenTelemetry 文档](https://opentelemetry.io/docs/concepts/)。 +对于需要深入熟悉日志和跟踪概念的用户,我们强烈推荐 [OpenTelemetry 文档](https://opentelemetry.io/docs/concepts/)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/build-your-own/introduction.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/build-your-own/introduction.md.hash index 4ef9b311745..02d412bd456 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/build-your-own/introduction.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/build-your-own/introduction.md.hash @@ -1 +1 @@ -db42eff8480ae71e +23bee9a87ef668a9 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/build-your-own/managing-data.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/build-your-own/managing-data.md index 82bb42c5c18..2def7993af7 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/build-your-own/managing-data.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/build-your-own/managing-data.md @@ -1,6 +1,6 @@ --- 'title': '管理数据' -'description': '用于可观察性的管理数据' +'description': '用于可观测性的管理数据' 'slug': '/observability/managing-data' 'keywords': - 'observability' @@ -11,26 +11,26 @@ - 'Grafana' - 'OTel' 'show_related_blogs': true +'doc_type': 'guide' --- import observability_14 from '@site/static/images/use-cases/observability/observability-14.png'; import Image from '@theme/IdealImage'; +# 管理数据 -# 数据管理 - -用于可观察性的 ClickHouse 部署不可避免地涉及大量数据集,这些数据集需要进行管理。ClickHouse 提供多种功能以协助数据管理。 +用于可观察性的 ClickHouse 部署不可避免地涉及大量数据集,这需要进行管理。ClickHouse 提供了一系列功能以协助进行数据管理。 ## 分区 {#partitions} -ClickHouse 中的分区允许根据列或 SQL 表达式在磁盘上逻辑上分隔数据。通过逻辑上分隔数据,每个分区可以独立操作,例如删除。这使得用户能够有效地在存储层之间移动分区,从而有效地过期数据或从集群中删除数据 [expire data/efficiently delete from a cluster](/sql-reference/statements/alter/partition)。 +在 ClickHouse 中,分区允许根据列或 SQL 表达式在磁盘上逻辑上分离数据。通过逻辑分离数据,每个分区可以独立操作,例如被删除。这使得用户可以在存储层之间高效地移动分区,从而高效地[过期数据/从集群中高效删除](/sql-reference/statements/alter/partition)。 -分区在表最初定义时通过 `PARTITION BY` 子句指定。该子句可以包含任何列的 SQL 表达式,其结果将定义一行被发送到的分区。 +分区在表初始定义时通过 `PARTITION BY` 子句指定。此子句可以包含对任意列的 SQL 表达式,其结果将定义一行被发送到哪个分区。 - + -数据片段在磁盘上与每个分区逻辑上相关联(通过共同的文件夹名称前缀),可以单独查询。下面的示例中,默认的 `otel_logs` 模式按天分区,使用表达式 `toDate(Timestamp)`。随着行被插入到 ClickHouse 中,该表达式将针对每一行进行评估,并在存在时路由到结果分区(如果该行是一天中的第一行,则会创建该分区)。 +数据部分在磁盘上与每个分区逻辑上关联(通过一个共同的文件夹名称前缀),并可以单独查询。以下示例中,默认的 `otel_logs` 模式通过使用表达式 `toDate(Timestamp)` 按天分区。当数据行插入到 ClickHouse 中时,此表达式将被评估针对每一行,并且如果存在,则路由到相应的分区(如果该行是某一天的第一行,则将创建该分区)。 ```sql CREATE TABLE default.otel_logs @@ -42,9 +42,9 @@ PARTITION BY toDate(Timestamp) ORDER BY (ServiceName, SeverityText, toUnixTimestamp(Timestamp), TraceId) ``` -可以在分区上执行 [多种操作](/sql-reference/statements/alter/partition),包括 [备份](/sql-reference/statements/alter/partition#freeze-partition)、[列操作](/sql-reference/statements/alter/partition#clear-column-in-partition)、突变 [更改](/sql-reference/statements/alter/partition#update-in-partition)/[删除](/sql-reference/statements/alter/partition#delete-in-partition) 行的数据以及 [索引清除(例如,二级索引)](/sql-reference/statements/alter/partition#clear-index-in-partition)。 +可以对分区执行[多种操作](/sql-reference/statements/alter/partition),包括[备份](/sql-reference/statements/alter/partition#freeze-partition)、[列操作](/sql-reference/statements/alter/partition#clear-column-in-partition)、变更[修改](/sql-reference/statements/alter/partition#update-in-partition)/[删除](/sql-reference/statements/alter/partition#delete-in-partition)数据(按行)和[索引清除(例如,次级索引)](/sql-reference/statements/alter/partition#clear-index-in-partition)。 -例如,假设我们的 `otel_logs` 表按天分区。如果填充结构化日志数据集,它将包含几天的数据: +作为一个例子,假设我们的 `otel_logs` 表按天进行分区。如果填充了结构化日志数据集,则会包含几天的数据: ```sql SELECT Timestamp::Date AS day, @@ -65,7 +65,7 @@ ORDER BY c DESC Peak memory usage: 4.41 MiB. ``` -可以使用简单的系统表查询来查找当前分区: +当前分区可以使用简单的系统表查询找到: ```sql SELECT DISTINCT partition @@ -83,7 +83,7 @@ WHERE `table` = 'otel_logs' 5 rows in set. Elapsed: 0.005 sec. ``` -我们可能还有另一个表 `otel_logs_archive`,用于存储较旧的数据。数据可以按照分区有效地移动到此表(这仅是元数据的变化)。 +我们可能还有另一个表 `otel_logs_archive`,用于存储旧数据。可以通过分区高效地将数据移动到此表(这只是一个元数据更改)。 ```sql CREATE TABLE otel_logs_archive AS otel_logs @@ -122,13 +122,13 @@ ORDER BY c DESC Peak memory usage: 4.99 MiB. ``` -这与其他技术形成对比,这些技术需要使用 `INSERT INTO SELECT` 并将数据重新写入新的目标表。 +这与其他技术形成对比,后者需要使用 `INSERT INTO SELECT` 并将数据重新写入新目标表。 :::note 移动分区 -[在表之间移动分区](/sql-reference/statements/alter/partition#move-partition-to-table) 需要满足多个条件,尤其是表必须具有相同的结构、分区键、主键以及索引/投影。在 `ALTER` DDL 中如何指定分区的详细说明可以在 [这里](/sql-reference/statements/alter/partition#how-to-set-partition-expression) 找到。 +[在表之间移动分区](/sql-reference/statements/alter/partition#move-partition-to-table)需要满足多个条件,其中包括表必须具有相同的结构、分区键、主键和索引/投影。关于如何在 `ALTER` DDL 中指定分区的详细说明可以在[这里](/sql-reference/statements/alter/partition#how-to-set-partition-expression)找到。 ::: -此外,数据可以按分区有效地删除。这比替代技术(突变或轻量级删除)更具资源效率,应该优先考虑。 +此外,可以按分区高效地删除数据。这比其他技术(变更或轻量级删除)更有效率,并且应该优先考虑。 ```sql ALTER TABLE otel_logs @@ -148,32 +148,31 @@ ORDER BY c DESC ``` :::note -当使用设置 [`ttl_only_drop_parts=1`](/operations/settings/merge-tree-settings#ttl_only_drop_parts) 时,此功能被 TTL 利用。有关详细信息,请参见 [使用 TTL 进行数据管理](#data-management-with-ttl-time-to-live)。 +当使用设置 [`ttl_only_drop_parts=1`](/operations/settings/merge-tree-settings#ttl_only_drop_parts) 时,该功能已被 TTL 利用。有关详细信息,请参见[使用 TTL 进行数据管理](#data-management-with-ttl-time-to-live)。 ::: - ### 应用 {#applications} -上述示例说明了如何有效地按分区移动和操作数据。实际上,用户可能在可观察性用例中最频繁地利用分区操作的两种情况: +上述内容说明了如何通过分区高效地移动和操作数据。在实际操作中,用户可能在可观察性用例中最频繁使用分区操作以用于两个场景: -- **分层架构** - 在存储层之间移动数据(参考 [存储层](#storage-tiers)),从而构建热冷架构。 -- **有效删除** - 当数据达到指定的 TTL(参考 [使用 TTL 进行数据管理](#data-management-with-ttl-time-to-live)) +- **分层架构** - 在存储层之间移动数据(见[存储层](#storage-tiers)),从而构建热-冷架构。 +- **高效删除** - 当数据达到指定的 TTL 时(见[使用 TTL 进行数据管理](#data-management-with-ttl-time-to-live)) -以下我们将详细探讨这两种情况。 +我们将在下面详细探讨这两点。 ### 查询性能 {#query-performance} -虽然分区可以协助提高查询性能,但这在很大程度上取决于访问模式。如果查询仅针对少数几个分区(理想情况下是一个),性能可能会有所提升。这通常只有在分区键不在主键中且您正在按其过滤时才有用。但是,需要覆盖许多分区的查询性能可能比不使用分区的性能更差(因为可能存在更多的片段)。如果分区键已经是主键中的一个早期条目,针对单个分区的好处将更加微不足道。分区还可以用于 [优化 GROUP BY 查询](/engines/table-engines/mergetree-family/custom-partitioning-key#group-by-optimisation-using-partition-key),如果每个分区中的值是唯一的。然而,通常用户应该确保主键已优化,仅在访问模式访问数据的特定可预测子集时考虑将分区作为查询优化技术,例如按日分区,并且大多数查询在过去的一天内。有关此行为的示例,请参见 [这里](https://medium.com/datadenys/using-partitions-in-clickhouse-3ea0decb89c4)。 +虽然分区可以帮助提高查询性能,但这在很大程度上取决于访问模式。如果查询只针对少数几个分区(理想情况下为一个),性能可能会有所改善。仅当分区键不在主键中而且您按其过滤时,这通常是有用的。但是,覆盖许多分区的查询可能会比不使用分区的性能更差(因为可能有更多部分)。如果分区键已经是主键中的早期条目,则单个分区的目标优势将显得微不足道甚至不存在。如果每个分区中的值是唯一的,分区还可以用于[优化 GROUP BY 查询](/engines/table-engines/mergetree-family/custom-partitioning-key#group-by-optimisation-using-partition-key)。但一般来说,用户应确保主键得到优化,并仅在访问模式访问特定可预测数据子集的特殊情况下考虑将分区作为查询优化技术,例如按天分区,而大多数查询集中在最后一天。有关此行为的示例,请参见[这里](https://medium.com/datadenys/using-partitions-in-clickhouse-3ea0decb89c4)。 ## 使用 TTL(生存时间)进行数据管理 {#data-management-with-ttl-time-to-live} -生存时间(TTL)是 ClickHouse 支持的可观察性解决方案中有效数据保留和管理的重要特性,特别是考虑到大量数据持续生成。在 ClickHouse 中实施 TTL 允许自动过期和删除较旧数据,确保以最佳方式使用存储并在无需手动干预的情况下维护性能。此功能对于保持数据库精简、降低存储成本,并确保查询维持快速和高效至关重要,通过专注于最相关和最新的数据。此外,它有助于遵循数据保留政策,通过系统地管理数据生命周期,从而增强可观察性解决方案的整体可持续性和可扩展性。 +生存时间(TTL)是由 ClickHouse 提供的可观察性解决方案中的关键特性,用于高效的数据保留和管理,尤其是考虑到大量数据不断生成。 在 ClickHouse 中实施 TTL 使得旧数据的自动过期和删除成为可能,从而确保存储被最佳利用,且性能在没有人工干预的情况下维持。这一能力对保持数据库高效,减少存储成本,并确保查询专注于最相关和最新的数据,使其保持快速高效至关重要。此外,它通过系统地管理数据生命周期,帮助满足数据保留政策,从而提升可观察性解决方案的整体可持续性和可扩展性。 -TTL 可以在 ClickHouse 中指定在表级或列级。 +TTL 可以在 ClickHouse 中针对表或列级别指定。 ### 表级 TTL {#table-level-ttl} -日志和跟踪的默认模式包括一个 TTL,以在指定时间段后使数据过期。这在 ClickHouse 导出程序中通过 `ttl` 键指定,例如: +日志和跟踪的默认模式包括在指定时间段后过期数据的 TTL。这在 ClickHouse 导出器中通过 `ttl` 键指定,例如: ```yaml exporters: @@ -182,7 +181,7 @@ exporters: ttl: 72h ``` -此语法当前支持 [Golang Duration syntax](https://pkg.go.dev/time#ParseDuration)。**我们建议用户使用 `h` 并确保这与分区周期保持一致。例如,如果您按天分区,请确保它是天数的倍数,例如 24h、48h、72h。** 这将自动确保将 TTL 子句添加到表中,例如:如果 `ttl: 96h`。 +该语法当前支持 [Golang Duration 语法](https://pkg.go.dev/time#ParseDuration)。**我们建议用户使用 `h` 并确保这与分区期对齐。例如,如果按天分区,确保它是天数的倍数,例如 24h、48h、72h。** 这将自动确保将 TTL 子句添加到表中,例如如果 `ttl: 96h`。 ```sql PARTITION BY toDate(Timestamp) @@ -191,17 +190,17 @@ TTL toDateTime(Timestamp) + toIntervalDay(4) SETTINGS ttl_only_drop_parts = 1 ``` -默认情况下,当 ClickHouse [合并数据片段](/engines/table-engines/mergetree-family/mergetree#mergetree-data-storage) 时,将删除过期 TTL 的数据。当 ClickHouse 检测到数据已过期时,执行一个非计划的合并。 +默认情况下,过期 TTL 的数据在 ClickHouse [合并数据部分](/engines/table-engines/mergetree-family/mergetree#mergetree-data-storage) 时被删除。当 ClickHouse 检测到数据过期时,它会执行非定期合并。 :::note 定期 TTL -TTL 不是立即应用的,而是按计划应用的,如上所述。MergeTree 表设置 `merge_with_ttl_timeout` 设置在带有删除 TTL 的合并重复之前的最小延迟(以秒为单位)。默认值为 14400 秒(4 小时)。但这只是最低延迟,可能需要更长时间才能触发 TTL 合并。如果该值过低,将执行许多非计划合并,这可能会消耗大量资源。可以使用命令 `ALTER TABLE my_table MATERIALIZE TTL` 强制执行 TTL 过期。 +TTL 不会立即应用,而是根据计划应用,如上所述。MergeTree 表设置 `merge_with_ttl_timeout` 设置重复合并带有删除 TTL 的最小延迟(以秒为单位)。默认值为 14400 秒(4 小时)。但这只是最小延迟,它可能会花费更长时间才能触发 TTL 合并。如果值设置得过低,将会进行许多非定期合并,这可能会消耗大量资源。可以使用命令 `ALTER TABLE my_table MATERIALIZE TTL` 强制执行 TTL 到期。 ::: -**重要:我们建议使用设置 [`ttl_only_drop_parts=1`](/operations/settings/merge-tree-settings#ttl_only_drop_parts)**(由默认模式应用)。启用此设置后,ClickHouse 会在所有行都过期时丢弃整个部分。丢弃整个部分而不是部分清理 TTL-d 行(通过资源密集型突变实现,当 `ttl_only_drop_parts=0`)允许更短的 `merge_with_ttl_timeout` 时间和对系统性能的较低影响。如果数据按您执行 TTL 过期的相同单元分区,例如天,则部分将自然仅包含定义区间内的数据。这将确保 `ttl_only_drop_parts=1` 可以被有效地应用。 +**重要:我们建议使用设置 [`ttl_only_drop_parts=1`](/operations/settings/merge-tree-settings#ttl_only_drop_parts)**(应用于默认模式)。启用此设置时,ClickHouse 在所有行均过期时会丢弃整个部分。丢弃整个部分而不是对 TTL 的行进行部分清理(通过资源密集型变更实现,当 `ttl_only_drop_parts=0` 时),可以缩短 `merge_with_ttl_timeout` 的时间并降低对系统性能的影响。如果数据按您进行 TTL 过期的相同单位(例如天)进行分区,则部分将自然仅包含来自定义间隔的数据。这将确保可以高效应用 `ttl_only_drop_parts=1`。 ### 列级 TTL {#column-level-ttl} -上述示例在表级过期数据。用户还可以在列级过期数据。随着数据老化,这可以用于删除在调查中其值无法 justify 的资源开销的列。例如,我们建议保留 `Body` 列,以防添加新动态元数据,而在插入时尚未提取,例如新的 Kubernetes 标签。在一段时间后,例如 1 个月,可能显然该附加元数据没有用处 - 从而限制了保留 `Body` 列的价值。 +上述示例在表级别过期数据。用户还可以在列级别过期数据。随着数据老化,可以用来删除在调查中其值不值得保留其资源开销的列。例如,我们建议保留 `Body` 列,以防在插入时未提取的新动态元数据,例如新的 Kubernetes 标签。在一段时间后,例如 1 个月,可能会明显发现这些额外的元数据没有用,从而限制了保留 `Body` 列的价值。 下面,我们展示如何在 30 天后删除 `Body` 列。 @@ -217,14 +216,14 @@ ORDER BY (ServiceName, Timestamp) ``` :::note -指定列级 TTL 要求用户指定自己的模式。这不能在 OTel 收集器中指定。 +指定列级 TTL 需要用户自行指定模式。此设置不能在 OTel 收集器中指定。 ::: ## 重新压缩数据 {#recompressing-data} -虽然我们通常推荐在观察数据集上使用 `ZSTD(1)`,用户可以尝试不同的压缩算法或更高的压缩级别,例如 `ZSTD(3)`。除了可以在架构创建时指定此设置外,压缩设置还可以在设置的时间段后更改。如果编解码器或压缩算法改善了压缩但导致查询性能下降,这可能是合适的。这种权衡可能在较旧的数据上是不可接受的,因为这些数据的查询频率较低,而对于最近的数据,则更常用于调查。 +虽然我们通常建议对可观察性数据集使用 `ZSTD(1)`,但用户可以尝试不同的压缩算法或更高的压缩级别,例如 `ZSTD(3)`。除了可以在模式创建时指定此项外,还可以配置在设定的时间段后进行更改。如果编解码器或压缩算法能够改善压缩,但导致查询性能下降,这可能是合适的。这种权衡可能在旧数据的情况下是可接受的,因为其查询频率较低,但对于频繁在调查中使用的最近数据,则不适用。 -以下是一个示例,我们在 4 天后使用 `ZSTD(3)` 压缩数据,而不是删除它。 +下面的示例中,我们在 4 天后使用 `ZSTD(3)` 压缩数据,而不是删除它。 ```sql CREATE TABLE default.otel_logs_v2 @@ -253,36 +252,36 @@ TTL Timestamp + INTERVAL 4 DAY RECOMPRESS CODEC(ZSTD(3)) ``` :::note 评估性能 -我们建议用户始终评估不同压缩级别和算法的插入和查询性能影响。例如,增量编解码器对于时间戳的压缩可能非常有用。但是,如果这些是主键的一部分,则过滤性能可能会受到影响。 +我们建议用户始终评估不同压缩级别和算法对插入和查询性能的影响。例如,增量编解码器在压缩时间戳时可能很有帮助。然而,如果这些是主键的一部分,则过滤性能可能会下降。 ::: -有关配置 TTL 的进一步详细信息和示例可以在 [这里](/engines/table-engines/mergetree-family/mergetree#table_engine-mergetree-multiple-volumes) 找到。有关如何为表和列添加和修改 TTL 的示例,请参考 [这里](/engines/table-engines/mergetree-family/mergetree#table_engine-mergetree-ttl)。关于 TTL 如何使热-温-冷存储层次结构,详见 [存储层](#storage-tiers)。 +有关配置 TTL 的进一步详情和示例可以在[这里](/engines/table-engines/mergetree-family/mergetree#table_engine-mergetree-multiple-volumes)找到。有关如何为表和列添加和修改 TTL 的示例,可以在[这里](/engines/table-engines/mergetree-family/mergetree#table_engine-mergetree-ttl)找到。有关 TTL 如何启用存储层次结构如热-温冷架构的信息,请参见[存储层](#storage-tiers)。 ## 存储层 {#storage-tiers} -在 ClickHouse 中,用户可以在不同的磁盘上创建存储层,例如:在 SSD 上存储热/最近的数据,而将较旧的数据放在 S3 上。这种架构允许对较旧的数据使用更便宜的存储,因为其查询 SLAs 较高,因为在调查中不常使用它。 +在 ClickHouse 中,用户可以在不同的磁盘上创建存储层,例如,在 SSD 上存储热/近期数据,而在 S3 上存储旧数据。这种架构允许对旧数据使用较便宜的存储,由于其在调查中使用频率较低,因此具有较高的查询 SLA。 :::note 与 ClickHouse Cloud 无关 -ClickHouse Cloud 使用单个数据副本,该副本由 S3 支持,具有基于 SSD 的节点缓存。因此,在 ClickHouse Cloud 中不需要存储层。 +ClickHouse Cloud 使用 S3 上的单一数据副本,并具有 SSD 支持的节点缓存。因此,在 ClickHouse Cloud 中不需要存储层。 ::: -创建存储层需要用户创建磁盘,然后使用这些磁盘制定存储策略,在表创建时可以指定卷。数据可以根据填充率、部分大小和卷优先级在磁盘之间自动移动。进一步的详细信息可以在 [这里](/engines/table-engines/mergetree-family/mergetree#table_engine-mergetree-multiple-volumes) 找到。 +创建存储层要求用户创建磁盘,然后用于形成存储策略,在创建表时可以指定卷。数据可以根据填充率、部分大小和卷优先级自动在磁盘之间移动。有关进一步细节,请参见[这里](/engines/table-engines/mergetree-family/mergetree#table_engine-mergetree-multiple-volumes)。 -虽然可以使用 `ALTER TABLE MOVE PARTITION` 命令手动在磁盘之间移动数据,但通过 TTL 也可以控制卷之间的数据移动。完好的示例可以在 [这里](/guides/developer/ttl#implementing-a-hotwarmcold-architecture) 找到。 +虽然可以使用 `ALTER TABLE MOVE PARTITION` 命令手动在磁盘之间移动数据,但也可以使用 TTL 控制数据在卷之间的移动。完整示例可以在[这里](/guides/developer/ttl#implementing-a-hotwarmcold-architecture)找到。 -## 管理架构更改 {#managing-schema-changes} +## 管理模式变化 {#managing-schema-changes} -日志和跟踪架构在系统生命周期内不可避免地会发生变化,例如:因为用户监视具有不同元数据或 pod 标签的新系统。通过使用 OTel 架构生成数据,并以结构化格式捕获原始事件数据,ClickHouse 架构将对这些变化具有稳健性。不过,随着新元数据的可用和查询访问模式的变化,用户希望更新架构以反映这些变化。 +日志和追踪模式在系统的生命周期中不可避免地会发生变化,例如,用户监控具有不同元数据或 pod 标签的新系统。通过使用 OTel 模式生成数据,并以结构化格式捕获原始事件数据,ClickHouse 的模式在这些变化中将是稳健的。然而,随着新元数据的可用性增加和查询访问模式的变化,用户将希望更新模式以反映这些变化。 -为了避免在架构更改期间停机,用户有几种选项,我们将在下面介绍。 +为了避免在模式变化期间出现停机,用户有几种选择,下面我们将介绍。 ### 使用默认值 {#use-default-values} -可以使用 [`DEFAULT` 值](/sql-reference/statements/create/table#default) 添加列到架构中。如果在 INSERT 期间未指定,则使用指定的默认值。 +可以使用 [`DEFAULT` 值](/sql-reference/statements/create/table#default) 将列添加到模式中。如果在 INSERT 时未指定,则会使用指定的默认值。 -在修改任何物化视图变换逻辑或 OTel 收集器配置之前,可以进行架构更改,这会导致这些新列被发送。 +在修改任何物化视图转换逻辑或 OTel 收集器配置之前,可以进行模式更改,这会导致将这些新列发送。 -架构更改后,用户可以重新配置 OTel 收集器。假设用户使用 ["使用 SQL 提取结构"](/docs/use-cases/observability/schema-design#extracting-structure-with-sql) 中概述的推荐过程,其中 OTel 收集器将其数据发送到 Null 数据表引擎,具有负责提取目标架构并将结果发送到目标表以进行存储的物化视图,可以使用 [`ALTER TABLE ... MODIFY QUERY` 语法](/sql-reference/statements/alter/view) 修改视图。假设我们有如下目标表及其相应的物化视图(类似于在 "使用 SQL 提取结构" 中所用)从 OTel 结构化日志中提取目标架构: +一旦模式发生变化,用户可以重新配置 OTel 收集器。假设用户使用的是 ["使用 SQL 提取结构"](/docs/use-cases/observability/schema-design#extracting-structure-with-sql) 中推荐的过程,其中 OTel 收集器将其数据发送到 Null 表引擎,具有负责提取目标模式并将结果发送到目标表进行存储的物化视图,可以使用 [`ALTER TABLE ... MODIFY QUERY` 语法](/sql-reference/statements/alter/view) 修改视图。假设我们有以下目标表及其对应的物化视图(类似于在 "使用 SQL 提取结构" 中使用的),用于从 OTel 结构化日志中提取目标模式: ```sql CREATE TABLE default.otel_logs_v2 @@ -328,14 +327,14 @@ SELECT FROM otel_logs ``` -假设我们希望从 `LogAttributes` 中提取一个新列 `Size`。我们可以使用 `ALTER TABLE` 将其添加到架构中,指定默认值: +假设我们希望从 `LogAttributes` 提取一个新列 `Size`。我们可以使用 `ALTER TABLE` 将其添加到我们的模式中,指定默认值: ```sql ALTER TABLE otel_logs_v2 (ADD COLUMN `Size` UInt64 DEFAULT JSONExtractUInt(Body, 'size')) ``` -在上述示例中,我们将默认值指定为 `LogAttributes` 中的 `size` 键(如果不存在则为 0)。这意味着访问此列的查询必须访问 Map,因此会变慢。我们也可以轻松地将此设置为常量,例如 0,从而降低后续对没有值的行的查询成本。查询该表显示值按预期从 Map 中填充: +在上面的示例中,我们将默认值指定为 `LogAttributes` 中的 `size` 键(如果不存在,则为 0)。这意味着对这种列访问但未插入值的行的查询必须访问 Map,因此会更慢。我们还可以轻松地将其指定为常量,例如 0,从而降低对未插入值的行后续查询的成本。查询此表显示该值按预期从 Map 中填充: ```sql SELECT Size @@ -352,7 +351,7 @@ LIMIT 5 5 rows in set. Elapsed: 0.012 sec. ``` -为了确保此值对所有未来数据进行插入,我们可以使用如下的 `ALTER TABLE` 语法修改我们的物化视图: +为了确保该值对所有未来数据进行插入,我们可以使用以下所示的 `ALTER TABLE` 语法修改我们的物化视图: ```sql ALTER TABLE otel_logs_mv @@ -378,13 +377,13 @@ SELECT FROM otel_logs ``` -随后的行将在插入时具有填充的 `Size` 列。 +随后的行将在插入时填充 `Size` 列。 ### 创建新表 {#create-new-tables} -作为上述过程的替代,用户可以简单地创建一个具有新架构的目标表。然后,任何物化视图可以修改为使用新表,使用上述的 `ALTER TABLE MODIFY QUERY`。通过这种方法,用户可以对其表进行版本控制,例如 `otel_logs_v3`。 +作为上述过程的替代,用户可以简单地创建一个带有新模式的新目标表。然后可以修改任何物化视图以使用新表,使用上述 `ALTER TABLE MODIFY QUERY`。通过这种方法,用户可以对表进行版本控制,例如 `otel_logs_v3`。 -这种方法使用户拥有多个表可供查询。为了在表之间进行查询,用户可以使用 [`merge` 函数](/sql-reference/table-functions/merge),该函数接受通配符模式作为表名称。以下是我们通过查询 `otel_logs` 表的 v2 和 v3 进行演示: +这种方法会让用户面临多个表的查询。要跨多个表查询,用户可以使用 [`merge` 函数](/sql-reference/table-functions/merge),该函数接受表名的通配符模式。我们在下面展示如何查询 `otel_logs` 表的 v2 和 v3: ```sql SELECT Status, count() AS c @@ -404,7 +403,7 @@ LIMIT 5 5 rows in set. Elapsed: 0.137 sec. Processed 41.46 million rows, 82.92 MB (302.43 million rows/s., 604.85 MB/s.) ``` -如果用户希望避免使用 `merge` 函数并向最终用户提供一个结合了多个表的表,则可以使用 [Merge 表引擎](/engines/table-engines/special/merge)。我们在下面演示: +如果用户希望避免使用 `merge` 函数并向最终用户展示一个结合多个表的表,可以使用 [合并表引擎](/engines/table-engines/special/merge)。我们在下面展示: ```sql CREATE TABLE otel_logs_merged @@ -427,7 +426,7 @@ LIMIT 5 5 rows in set. Elapsed: 0.073 sec. Processed 41.46 million rows, 82.92 MB (565.43 million rows/s., 1.13 GB/s.) ``` -每当添加新表时,都可以使用 `EXCHANGE` 表语法进行更新。例如,要添加一个 v4 表,我们可以创建一个新表并与先前版本原子地交换。 +只要创建一个新表并以原子方式与前一个版本交换,即可在添加新表时进行更新。 ```sql CREATE TABLE otel_logs_merged_temp diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/build-your-own/managing-data.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/build-your-own/managing-data.md.hash index a15ca60d518..090115f6f20 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/build-your-own/managing-data.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/build-your-own/managing-data.md.hash @@ -1 +1 @@ -f56605d633d7221f +bdb7c8a65cba36ba diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/build-your-own/schema-design.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/build-your-own/schema-design.md index de2b0aeee33..33cb5d789c6 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/build-your-own/schema-design.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/build-your-own/schema-design.md @@ -1,6 +1,6 @@ --- -'title': '模式设计' -'description': '为可观察性设计模式设计' +'title': '架构设计' +'description': '为可观察性设计架构设计' 'keywords': - 'observability' - 'logs' @@ -11,6 +11,7 @@ - 'OTel' 'slug': '/use-cases/observability/schema-design' 'show_related_blogs': true +'doc_type': 'guide' --- import observability_10 from '@site/static/images/use-cases/observability/observability-10.png'; @@ -20,30 +21,30 @@ import observability_13 from '@site/static/images/use-cases/observability/observ import Image from '@theme/IdealImage'; -# 设计可观察性的模式 +# 设计可观测性架构 -我们建议用户始终创建自己的日志和跟踪的模式,原因如下: +我们建议用户始终为日志和追踪创建自己的架构,原因如下: -- **选择主键** - 默认模式使用针对特定访问模式优化的 `ORDER BY`。您的访问模式不太可能与此一致。 -- **提取结构** - 用户可能希望从现有列中提取新列,例如 `Body` 列。这可以使用物化列来实现(在更复杂的情况下使用物化视图)。这需要模式更改。 -- **优化映射** - 默认模式使用 Map 类型存储属性。这些列允许存储任意元数据。尽管这是一个基本功能,因为事件中的元数据通常没有预先定义,因此无法在类似 ClickHouse 的强类型数据库中存储,但访问 map 键及其值的效率不如访问普通列的效率。因此,我们通过修改模式来解决这个问题,并确保最常访问的 map 键是顶级列 - 见 ["使用 SQL 提取结构"](#extracting-structure-with-sql)。这也需要模式更改。 -- **简化 map 键访问** - 访问 map 中的键需要更详细的语法。用户可以通过别名来缓解此问题。见 ["使用别名"](#using-aliases) 以简化查询。 -- **二级索引** - 默认模式使用二级索引加速对 Maps 的访问并加速文本查询。这通常是不必要的,并且会增加额外的磁盘空间。可以使用,但应进行测试以确保需要。见 ["二级 / 数据跳过索引"](#secondarydata-skipping-indices)。 -- **使用编解码器** - 如果用户了解预期数据并有证据表明这可以改善压缩,可以自定义列的编解码器。 +- **选择主键** - 默认架构使用优化特定访问模式的`ORDER BY`。您的访问模式不太可能与此对齐。 +- **提取结构** - 用户可能希望从现有列(例如`Body`列)中提取新列。可以使用物化列(在更复杂的情况下使用物化视图)实现。这需要对架构进行更改。 +- **优化映射** - 默认架构使用Map类型存储属性。这些列允许存储任意元数据。虽然这是必要的能力,因为事件的元数据通常在前期未被定义,因此无法存储在像ClickHouse这样的强类型数据库中,但访问映射键及其值的效率不如访问普通列。我们通过修改架构并确保最常访问的映射键是顶级列来解决此问题 - 参见 ["使用SQL提取结构"](#extracting-structure-with-sql)。这需要架构更改。 +- **简化映射键访问** - 访问映射中的键需要更详细的语法。用户可以使用别名减轻此问题。请参见 ["使用别名"](#using-aliases) 来简化查询。 +- **二级索引** - 默认架构使用二级索引来加速对Map的访问并加速文本查询。这通常不是必需的,且会占用额外的磁盘空间。可以使用,但应该进行测试以确保它们是必要的。参见 ["二级/数据跳过索引"](#secondarydata-skipping-indices)。 +- **使用编码器** - 如果用户理解预期的数据并有证据表明这会改善压缩,他们可能希望自定义列的编码器。 _我们将在下面详细描述上述每个用例。_ -**重要提示:** 虽然鼓励用户扩展和修改他们的模式以实现最佳压缩和查询性能,但他们应尽可能遵循核心列的 OTel 模式命名。ClickHouse Grafana 插件假定存在一些基本的 OTel 列以协助查询构建,例如 Timestamp 和 SeverityText。日志和跟踪所需的列在这里有文档记录 [[1]](https://grafana.com/developers/plugin-tools/tutorials/build-a-logs-data-source-plugin#logs-data-frame-format)[[2]](https://grafana.com/docs/grafana/latest/explore/logs-integration/) 和 [这里](https://grafana.com/docs/grafana/latest/explore/trace-integration/#data-frame-structure)。您可以选择更改这些列名,覆盖插件配置中的默认值。 -## 使用 SQL 提取结构 {#extracting-structure-with-sql} +**重要提示:** 虽然鼓励用户扩展和修改他们的架构以实现最佳的压缩和查询性能,但他们应尽可能遵循核心列的OTel架构命名。ClickHouse Grafana插件假定存在一些基本的OTel列以帮助构建查询,例如Timestamp和SeverityText。日志和追踪所需的列在这里有文档记录 [[1]](https://grafana.com/developers/plugin-tools/tutorials/build-a-logs-data-source-plugin#logs-data-frame-format)[[2]](https://grafana.com/docs/grafana/latest/explore/logs-integration/) 和 [这里](https://grafana.com/docs/grafana/latest/explore/trace-integration/#data-frame-structure)。您可以选择更改这些列名,覆盖插件配置中的默认值。 +## 使用SQL提取结构 {#extracting-structure-with-sql} -无论是摄取结构化还是非结构化日志,用户通常需要具备以下能力: +无论是摄取结构化日志还是非结构化日志,用户通常需要以下能力: -- **从字符串 blob 中提取列**。查询这些列将比在查询时使用字符串操作更快。 -- **从 maps 中提取键**。默认模式将任意属性放入 Map 类型的列中。此类型提供无模式的能力,具有用户在定义日志和跟踪时无需预定义属性列的优势 - 通常在从 Kubernetes 收集日志并希望确保 Pod 标签在以后搜索时保留时,这是不可能的。访问 map 键及其值的速度不如在普通 ClickHouse 列上查询。因此,从 maps 提取键到根表列通常是可取的。 +- **从字符串blob中提取列**。查询这些将比使用查询时的字符串操作更快。 +- **从映射中提取键**。默认架构将任意属性置于Map类型的列中。此类型提供无架构能力,用户在定义日志和追踪时不需要预先定义属性列 - 收集Kubernetes日志时,这通常是不可能的,并且希望保留pod标签以便后续搜索。从映射中访问键及其值的速度慢于查询正常的ClickHouse列。因此,提取映射中的键到根表列通常是可取的。 考虑以下查询: -假设我们希望统计接收最多 POST 请求的网址路径,使用结构化日志。JSON blob 存储在 `Body` 列中作为字符串。此外,如果用户在收集器中启用了 json_parser,它也可能存储在 `LogAttributes` 列中作为 `Map(String, String)`。 +假设我们希望计算网站上接收最多POST请求的URL路径。JSON blob存储在`Body`列中,作为字符串。同时,如果用户在收集器中启用了json_parser,它也可能存储在`LogAttributes`列中,作为`Map(String, String)`。 ```sql SELECT LogAttributes @@ -57,7 +58,7 @@ Body: {"remote_addr":"54.36.149.41","remote_user":"-","run_time":"0"," LogAttributes: {'status':'200','log.file.name':'access-structured.log','request_protocol':'HTTP/1.1','run_time':'0','time_local':'2019-01-22 00:26:14.000','size':'30577','user_agent':'Mozilla/5.0 (compatible; AhrefsBot/6.1; +http://ahrefs.com/robot/)','referer':'-','remote_user':'-','request_type':'GET','request_path':'/filter/27|13 ,27| 5 ,p53','remote_addr':'54.36.149.41'} ``` -假设 `LogAttributes` 可用,查询以统计网站接收最多 POST 请求的 URL 路径: +假设`LogAttributes`可用,查询计算该网站上接收最多POST请求的URL路径如下: ```sql SELECT path(LogAttributes['request_path']) AS path, count() AS c @@ -79,12 +80,12 @@ LIMIT 5 Peak memory usage: 153.71 MiB. ``` -请注意此处使用 map 语法,例如 `LogAttributes['request_path']` 和用于去除 URL 查询参数的 [`path` 函数](/sql-reference/functions/url-functions#path)。 +注意此处使用的映射语法,例如`LogAttributes['request_path']`,以及[`path`函数](/sql-reference/functions/url-functions#path)用于剥离URL中的查询参数。 -如果用户在收集器中没有启用 JSON 解析,则 `LogAttributes` 将为空,迫使我们使用 [JSON 函数](/sql-reference/functions/json-functions) 从字符串 `Body` 中提取列。 +如果用户未在收集器中启用JSON解析,则`LogAttributes`将为空,迫使我们使用[JSON函数](/sql-reference/functions/json-functions) 从字符串`Body`中提取列。 -:::note 请优先考虑 ClickHouse 进行解析 -我们通常建议用户在 ClickHouse 中对结构化日志进行 JSON 解析。我们相信 ClickHouse 是最快的 JSON 解析实现。然而,我们认识到用户可能希望将日志发送到其他源,并且不希望此逻辑驻留在 SQL 中。 +:::note 优先使用ClickHouse进行解析 +我们通常建议用户在ClickHouse中对结构化日志进行JSON解析。我们相信ClickHouse是最快的JSON解析实现。然而,我们认识到用户可能希望将日志发送到其他来源,并且不希望此逻辑驻留在SQL中。 ::: ```sql @@ -107,7 +108,7 @@ LIMIT 5 Peak memory usage: 172.30 MiB. ``` -现在考虑非结构化日志的情况: +现在考虑对非结构化日志执行相同操作: ```sql SELECT Body, LogAttributes @@ -121,7 +122,7 @@ Body: 151.233.185.144 - - [22/Jan/2019:19:08:54 +0330] "GET /image/105 LogAttributes: {'log.file.name':'access-unstructured.log'} ``` -对非结构化日志的类似查询需要通过 [`extractAllGroupsVertical` 函数](/sql-reference/functions/string-search-functions#extractallgroupsvertical) 使用正则表达式。 +针对非结构化日志的类似查询需要通过[`extractAllGroupsVertical`函数](/sql-reference/functions/string-search-functions#extractallgroupsvertical)使用正则表达式。 ```sql SELECT @@ -148,29 +149,28 @@ LIMIT 5 5 rows in set. Elapsed: 1.953 sec. Processed 10.37 million rows, 3.59 GB (5.31 million rows/s., 1.84 GB/s.) ``` -解析非结构化日志查询的复杂性和成本增加(注意性能差异)是我们建议用户始终在可能的情况下使用结构化日志的原因。 +解析非结构化日志的查询复杂性和成本增加(注意性能差异)是我们建议用户始终在可能的情况下使用结构化日志的原因。 :::note 考虑字典 -上述查询可以通过利用正则表达式字典进行优化。有关详细信息,请参见 [使用字典](#using-dictionaries)。 +上述查询可以优化以利用正则表达式字典。有关详细信息,请参见 [使用字典](#using-dictionaries)。 ::: -这两种用例都可以通过将上述查询逻辑移动到插入时来满足。我们在下面探讨几种方法,强调何时使用每种方法是合适的。 +这两个用例都可以使用ClickHouse通过将上述查询逻辑移到插入时间来满足。我们在下面探讨几种方法,突出每种方法何时适用。 -:::note 使用 OTel 还是 ClickHouse 进行处理? -用户还可以使用 OTel Collector 处理器和操作符进行处理,具体说明见 [此处](/observability/integrating-opentelemetry#processing---filtering-transforming-and-enriching)。在大多数情况下,用户会发现 ClickHouse 在资源效率和速度方面显著优于收集器的处理器。在 SQL 中执行所有事件处理的主要缺点是将您的解决方案与 ClickHouse 绑定在一起。例如,用户可能希望从 OTel 收集器发送处理后的日志到替代目的地,例如 S3。 +:::note 处理时使用OTel或ClickHouse? +用户还可以使用OTel Collector处理器和操作符进行处理,如[这里](https://observability/integrating-opentelemetry#processing---filtering-transforming-and-enriching)所述。在大多数情况下,用户会发现ClickHouse在资源效率和速度上显著优于收集器的处理器。在SQL中执行所有事件处理的主要缺点是将解决方案与ClickHouse耦合。例如,用户可能希望将处理后的日志发送到OTel收集器的替代目标,例如S3。 ::: ### 物化列 {#materialized-columns} -物化列提供了从其他列提取结构的最简单解决方案。这些列的值始终在插入时计算,并且无法在 INSERT 查询中指定。 +物化列提供了从其他列提取结构的最简单解决方案。此类列的值将在插入时间始终计算,并且不能在INSERT查询中指定。 -:::note 额外开销 -物化列会导致额外的存储开销,因为这些值在插入时被提取到新列中并存储在磁盘上。 +:::note 开销 +物化列会产生额外的存储开销,因为在插入时间将值提取到新的列中。 ::: +物化列支持任何ClickHouse表达式,并且可以利用任何处理字符串的分析函数(包括[正则表达式和查找](/sql-reference/functions/string-search-functions))和[URLs](/sql-reference/functions/url-functions),执行[类型转换](/sql-reference/functions/type-conversion-functions)、[从JSON提取值](/sql-reference/functions/json-functions)或[数学运算](/sql-reference/functions/math-functions)。 -物化列支持任何 ClickHouse 表达式,并可以利用任何用于 [处理字符串](/sql-reference/functions/string-functions)(包括 [正则表达式和搜索](/sql-reference/functions/string-search-functions))和 [URL](/sql-reference/functions/url-functions) 的分析函数,执行 [类型转换](/sql-reference/functions/type-conversion-functions)、[从 JSON 中提取值](/sql-reference/functions/json-functions) 或 [数学运算](/sql-reference/functions/math-functions)。 - -我们建议对基本处理使用物化列。它们对于从 maps 中提取值、将其提升为根列和进行类型转换非常有用。它们在非常基本的模式中或与物化视图结合使用时通常最有用。考虑以下从收集器提取 JSON 到 `LogAttributes` 列的日志模式: +我们建议将物化列用于基本处理。它们对于从映射中提取值、将它们提升为根列和执行类型转换特别有用。当在非常基本的架构中使用或与物化视图结合使用时,它们通常最有用。考虑以下架构,由收集器将JSON提取到`LogAttributes`列中: ```sql CREATE TABLE otel_logs @@ -199,9 +199,9 @@ PARTITION BY toDate(Timestamp) ORDER BY (ServiceName, SeverityText, toUnixTimestamp(Timestamp), TraceId) ``` -使用 JSON 函数从字符串 `Body` 中提取的等效模式可以在 [这里](https://pastila.nl/?005cbb97/513b174a7d6114bf17ecc657428cf829#gqoOOiomEjIiG6zlWhE+Sg==) 找到。 +使用JSON函数从字符串`Body`提取的等效架构可以在[这里](https://pastila.nl/?005cbb97/513b174a7d6114bf17ecc657428cf829#gqoOOiomEjIiG6zlWhE+Sg==)找到。 -我们的三列物化视图提取请求页面、请求类型和引荐者域。这些访问 map 键并对其值应用函数。随后我们的查询显著更快: +我们的三个物化列提取请求页面、请求类型和引用者域。这些访问映射键并对其值应用函数。我们后续的查询显著更快: ```sql SELECT RequestPage AS path, count() AS c @@ -224,26 +224,25 @@ Peak memory usage: 3.16 MiB. ``` :::note -物化列默认不会在 `SELECT *` 中返回。这是为了保持 `SELECT *` 的结果始终可以通过 INSERT 重新插入到表中的不变性。可以通过设置 `asterisk_include_materialized_columns=1` 禁用此行为,并可在 Grafana 中启用(请参见数据源配置中的 `Additional Settings -> Custom Settings`)。 +物化列默认不会在`SELECT *`中返回。这是为了保持`SELECT *`的结果始终可以通过INSERT插入回表中的不变性。可以通过设置`asterisk_include_materialized_columns=1`来禁用此行为,并且可以在Grafana中启用(请参见数据源配置中的`附加设置 -> 自定义设置`)。 ::: ## 物化视图 {#materialized-views} -[物化视图](/materialized-views) 提供了一种更强大的方式将 SQL 过滤和转换应用于日志和跟踪。 +[物化视图](/materialized-views)提供了一种更强大的方式来对日志和追踪应用SQL过滤和变换。 -物化视图允许用户将计算的成本从查询时间转移到插入时间。 ClickHouse 物化视图只是一个触发器,根据插入到表中的数据块运行查询。该查询的结果插入到第二个“目标”表中。 +物化视图允许用户将计算的成本从查询时间转移到插入时间。ClickHouse物化视图只是一种触发器,在数据块插入表时执行查询。该查询的结果插入第二个“目标”表中。 :::note 实时更新 -ClickHouse 中的物化视图在数据流入基础表时实时更新,功能更像是不断更新的索引。相比之下,在其他数据库中,物化视图通常是查询的静态快照,必须刷新(类似于 ClickHouse 可刷新的物化视图)。 +在ClickHouse中,物化视图会实时更新,因为数据流入它们所基于的表,功能更像是不断更新的索引。相比之下,在其他数据库中,物化视图通常是查询的静态快照,必须刷新(类似于ClickHouse的可刷新的物化视图)。 ::: +物化视图关联的查询理论上可以是任何查询,其中包括聚合,但[存在与连接的限制](https://clickhouse.com/blog/using-materialized-views-in-clickhouse#materialized-views-and-joins)。对于日志和追踪所需的转换和过滤工作负载,用户可以考虑任何`SELECT`语句是可能的。 -与物化视图相关的查询理论上可以是任何查询,包括聚合,尽管 [连接存在限制](https://clickhouse.com/blog/using-materialized-views-in-clickhouse#materialized-views-and-joins)。对于日志和跟踪所需的转换和过滤工作负载,用户可以考虑任何 `SELECT` 语句均可行。 - -用户应记住,查询只是对插入到表(源表)中的行执行的一个触发器,结果发送到一个新表(目标表)。 +用户应记住该查询只是一种触发器,针对插入表的行(源表)执行,结果发送到新表(目标表)。 -为了确保我们不在源表和目标表中重复持久化数据,我们可以将源表的表引擎更改为 [Null 表引擎](/engines/table-engines/special/null),保留原始模式。我们的 OTel 收集器将继续向该表发送数据。例如,对于日志,`otel_logs` 表变为: +为了确保我们不在源表和目标表中重复持久化数据,我们可以将源表的表更改为[Null表引擎](/engines/table-engines/special/null),保持原始架构。我们的OTel收集器将继续将数据发送到此表。例如,对于日志,`otel_logs`表变为: ```sql CREATE TABLE otel_logs @@ -266,9 +265,9 @@ CREATE TABLE otel_logs ) ENGINE = Null ``` -Null 表引擎是一种强大的优化 - 想象它像是 `/dev/null`。此表不会存储任何数据,但任何附加的物化视图仍将在插入的行上执行,然后被丢弃。 +Null表引擎是一种强大的优化 - 想想它就像是`/dev/null`。该表不会存储任何数据,但任何附加的物化视图仍将在插入的行上执行,然后被丢弃。 -考虑以下查询。这将我们的行转换为希望保留的格式,从 `LogAttributes` 中提取所有列(我们假设这已由使用 `json_parser` 操作符的收集器设置),设置 `SeverityText` 和 `SeverityNumber`(基于一些简单的条件和对 [这些列](https://opentelemetry.io/docs/specs/otel/logs/data-model/#field-severitytext) 的定义)。在这种情况下,我们还只选择我们知道会被填充的列 - 忽略 `TraceId`、`SpanId` 和 `TraceFlags` 等列。 +考虑以下查询。该查询将我们的行转换为我们希望保留的格式,提取所有列来自`LogAttributes`(我们假设收集器使用`json_parser`操作符设置了此列),设置`SeverityText`和`SeverityNumber`(基于一些简单的条件和[这些列的定义](https://opentelemetry.io/docs/specs/otel/logs/data-model/#field-severitytext))。在这种情况下,我们还仅选择我们知道会被填充的列 - 忽略`TraceId`、`SpanId`和`TraceFlags`等列。 ```sql SELECT @@ -316,10 +315,10 @@ SeverityNumber: 9 1 row in set. Elapsed: 0.027 sec. ``` -我们还提取了上面的 `Body` 列 - 以防后续添加未被 SQL 提取的额外属性。该列在 ClickHouse 中应压缩良好,并将很少被访问,因此不会影响查询性能。最后,我们将 Timestamp 减少为 DateTime(以节省空间 - 见 ["优化类型"](#optimizing-types))进行类型转换。 +我们还提取了上述的`Body`列 - 以防后续添加了未通过我们的SQL提取的其他属性。此列在ClickHouse中应该能很好地压缩,并且很少访问,因此不会影响查询性能。最后,我们将Timestamp缩减为DateTime(以节省空间 - 参见 ["优化类型"](#optimizing-types)),进行类型转换。 -:::note 条件 -注意上面用于提取 `SeverityText` 和 `SeverityNumber` 的 [条件](https://sql-reference/functions/conditional-functions)。这些在制定复杂条件和检查 map 中的值是否设置时非常有用 - 我们天真地假设 `LogAttributes` 中的所有键都存在。我们建议用户熟悉它们 - 除了处理 [null 值](https://sql-reference/functions/functions-for-nulls) 的函数外,它们是日志解析中的好帮手! +:::note 条件表达式 +注意上面提取`SeverityText`和`SeverityNumber`的[条件函数](/sql-reference/functions/conditional-functions)。它们对制定复杂条件和检查映射中的值是否设置极为有用 - 我们天真地假设所有键都存在於`LogAttributes`中。我们建议用户熟悉它们 - 它们在日志解析中有助于处理[空值](/sql-reference/functions/functions-for-nulls)的函数! ::: 我们需要一个表来接收这些结果。下面的目标表与上述查询匹配: @@ -349,14 +348,13 @@ ENGINE = MergeTree ORDER BY (ServiceName, Timestamp) ``` -这里选择的类型基于 ["优化类型"](#optimizing-types) 中讨论的优化。 +这里选择的类型基于在["优化类型"](#optimizing-types)中讨论的优化。 :::note -请注意,我们显著改变了我们的模式。实际上,用户可能还希望保留跟踪列以及 `ResourceAttributes` 列(这通常包含 Kubernetes 元数据)。Grafana 可以利用跟踪列提供日志和跟踪之间的链接功能 - 见 ["使用 Grafana"](/observability/grafana)。 +注意我们如何显著改变了我们的架构。实际上,用户可能还会有他们希望保留的Trace列以及`ResourceAttributes`列(这通常包含Kubernetes元数据)。Grafana可以利用trace列提供日志和追踪之间的链接功能 - 参见 ["使用Grafana"](/observability/grafana)。 ::: - -下面,我们创建一个物化视图 `otel_logs_mv`,它在 `otel_logs` 表上执行上述选择,并将结果发送到 `otel_logs_v2`。 +接下来,我们创建一个物化视图`otel_logs_mv`,它为`otel_logs`表执行上述选择,并将结果发送到`otel_logs_v2`。 ```sql CREATE MATERIALIZED VIEW otel_logs_mv TO otel_logs_v2 AS @@ -381,11 +379,11 @@ SELECT FROM otel_logs ``` -上面的内容如下图所示: +上面的内容如下所示: -如果我们现在重新启动在 ["导出到 ClickHouse"](/observability/integrating-opentelemetry#exporting-to-clickhouse)中使用的收集器配置,数据将以我们期望的格式出现在 `otel_logs_v2` 中。请注意使用了带类型的 JSON 提取函数。 +如果我们现在重新启动在["导出到ClickHouse"](/observability/integrating-opentelemetry#exporting-to-clickhouse)中使用的收集器配置,数据将以我们期望的格式出现在`otel_logs_v2`中。注意使用了类型化的JSON提取函数。 ```sql SELECT * @@ -416,7 +414,7 @@ SeverityNumber: 9 1 row in set. Elapsed: 0.010 sec. ``` -一个等效的物化视图,通过使用 JSON 函数从 `Body` 列中提取列如下所示: +等效的物化视图,通过使用JSON函数从`Body`列中提取列也如下所示: ```sql CREATE MATERIALIZED VIEW otel_logs_mv TO otel_logs_v2 AS @@ -441,38 +439,38 @@ FROM otel_logs ``` ### 注意类型 {#beware-types} -上述物化视图依赖于隐式转换 - 尤其是在使用 `LogAttributes` map 的情况下。ClickHouse 通常会透明地将提取的值转换为目标表类型,减少所需的语法。然而,我们建议用户在使用目标表与相同模式的 [`INSERT INTO`](/sql-reference/statements/insert-into) 语句的视图 `SELECT` 语句时始终测试他们的视图。这应确认类型正确处理。特别关注以下情况: +上述物化视图依赖于隐式转换 - 特别是在使用`LogAttributes`映射的情况下。ClickHouse通常会透明地将提取的值转换为目标表类型,从而减少所需的语法。然而,我们建议用户始终通过使用视图的`SELECT`语句和使用相同架构的[`INSERT INTO`](/sql-reference/statements/insert-into)语句来测试它们的视图。这应确认类型处理正确。应特别注意以下情况: -- 如果 map 中不存在某个键,将返回空字符串。在数值的情况下,用户需要将这些映射到适当的值。这可以通过 [条件](https://sql-reference/functions/conditional-functions) 实现,例如 `if(LogAttributes['status'] = ", 200, LogAttributes['status'])` 或 [类型转换函数](https://sql-reference/functions/type-conversion-functions),如果默认值可以接受,例如 `toUInt8OrDefault(LogAttributes['status'] )` -- 某些类型不会始终被转换,例如数值的字符串表示不会被转换为枚举值。 -- JSON 提取函数在找不到值时会返回其类型的默认值。确保这些值是合理的! +- 如果映射中不存在某个键,则将返回空字符串。在数值的情况下,用户需要将其映射到适当的值。可以通过[条件函数](/sql-reference/functions/conditional-functions)实现,例如`if(LogAttributes['status'] = ", 200, LogAttributes['status'])`,或使用[类型转换函数](/sql-reference/functions/type-conversion-functions),如果默认值可以接受,例如`toUInt8OrDefault(LogAttributes['status'] )`。 +- 某些类型不会总是被转换,例如数值的字符串表示不会被转换为枚举值。 +- JSON提取函数在未找到值时会返回默认值。确保这些值合理! -:::note 避免 Nullable -避免在 Clickhouse 中使用 [Nullable](/sql-reference/data-types/nullable) 处理可观察性数据。在日志和跟踪中,通常不需要区分空和 null。此特性会导致额外的存储开销,并会对查询性能产生负面影响。有关详细信息,请参见 [这里](/data-modeling/schema-design#optimizing-types)。 +:::note 避免Nullable +避免在ClickHouse的可观测性数据中使用[Nullable](/sql-reference/data-types/nullable)。在日志和追踪中,区分空值和null值通常不是必需的。此功能会占用额外的存储开销,并会对查询性能产生负面影响。更多详情请参见[这里](/data-modeling/schema-design#optimizing-types)。 ::: ## 选择主(排序)键 {#choosing-a-primary-ordering-key} -一旦您提取了所需的列,您就可以开始优化排序/主键。 +一旦您提取了所需的列,就可以开始优化您的排序/主键。 -可以应用一些简单的规则来帮助选择排序键。以下项目有时可能会发生冲突,因此请按顺序考虑这些。用户可以从这一过程中识别出多个键,通常 4-5 个就足够: +可以应用一些简单的规则来帮助选择排序键。以下几点有时可能会冲突,因此请按顺序考虑这些。用户可以通过此过程识别出多个键,通常4到5个就够了: -1. 选择与常见过滤器和访问模式对齐的列。如果用户通常通过特定列筛选来开始可观察性调查,例如 Pod 名称,那么在 `WHERE` 子句中将频繁使用该列。优先包括这些列,而不是使用较少的列。 -2. 优先选择帮助在过滤时排除大量总行的列,从而减少需要读取的数据量。服务名称和状态代码通常是不错的候选者 - 在后者的情况下,仅当用户根据排除大多数行的值进行过滤时,例如,按 200 过滤在大多数系统中会匹配大多数行,而与 500 错误相对应的则是小子集。 -3. 优先选择可能与表中的其他列高度相关的列。这将帮助确保这些值也被连续存储,从而改善压缩。 -4. 对于排序键中列的 `GROUP BY` 和 `ORDER BY` 操作可以更有效地使用内存。 +1. 选择与常用的过滤器和访问模式一致的列。如果用户通常通过特定列进行可观测性调查(例如pod名称),则此列将频繁用于`WHERE`子句。优先将这些包含在您的键中,而不是那些使用频率较低的列。 +2. 优先选择在过滤时能够排除大量总行的列,从而减少需要读取的数据量。服务名称和状态码通常是良好的候选者 - 在后者情况下,仅当用户根据排除大部分行的值来过滤时,例如,按200s过滤在大多数系统中将匹配大部分行,而500错误则可能相应地对应于小部分。 +3. 优先选择与表中其他列高度相关的列。这有助于确保这些值也被连续存储,从而改善压缩效果。 +4. 在排序键中,对列的`GROUP BY`和`ORDER BY`操作可以更高效地使用内存。
-在确定排序键的列子集后,必须按特定顺序进行声明。此顺序可能会显著影响查询中二级键列的过滤效率以及表的数据文件的压缩比。一般而言,**最好按基数的升序排列键**。这应该与在排序键中后面的列的过滤效率低于在元组中前面的列的过滤效率之间进行权衡。权衡这些行为并考虑访问模式。最重要的是,测试变体。欲了解排序键及其优化的进一步理解,我们推荐 [这篇文章](/guides/best-practices/sparse-primary-indexes)。 +在识别出排序键的列子集后,必须按特定顺序声明它们。此顺序可以显著影响查询中对二级键列过滤的效率以及表数据文件的压缩比。一般来说,**最好按基数升序排序键**。这应该与排序键中晚出现的列的过滤效率低于早出现列的事实相平衡。平衡这些行为并考虑您的访问模式。最重要的是,测试变体。为了进一步了解排序键以及如何优化它们,建议参考[这篇文章](/guides/best-practices/sparse-primary-indexes)。 -:::note 结构优先 -我们建议在结构化日志后决定您的排序键。不要在排序键或 JSON 提取表达式中使用属性 maps 的键。确保将排序键作为根列放在表中。 +:::note 首先结构化 +我们建议在结构化日志后再决定您的排序键。不要在属性映射中使用键作为排序键或JSON提取表达式。确保您的排序键作为根列在表中。 ::: ## 使用映射 {#using-maps} -早期示例显示了使用 map 语法 `map['key']` 访问 `Map(String, String)` 列中的值。除了使用 map 表示法访问嵌套键外,还有可用于过滤或选择这些列的专用 ClickHouse [map 函数](/sql-reference/functions/tuple-map-functions#mapkeys)。 +早期示例显示使用映射语法`map['key']`访问`Map(String, String)`列中的值。除了使用映射符号访问嵌套键外,专门的ClickHouse [映射函数](/sql-reference/functions/tuple-map-functions#mapkeys)可以用于过滤或选择这些列。 -例如,以下查询使用 [`mapKeys` 函数](/sql-reference/functions/tuple-map-functions#mapkeys) 识别 `LogAttributes` 列中可用的所有唯一键,随后使用 [`groupArrayDistinctArray` 函数](/sql-reference/aggregate-functions/combinators)(一个组合器)。 +例如,以下查询使用[`mapKeys`函数](/sql-reference/functions/tuple-map-functions#mapkeys)识别`LogAttributes`列中所有唯一键,然后使用[`groupArrayDistinctArray`函数](/sql-reference/aggregate-functions/combinators)(一个组合器): ```sql SELECT groupArrayDistinctArray(mapKeys(LogAttributes)) @@ -487,14 +485,14 @@ groupArrayDistinctArray(mapKeys(LogAttributes)): ['remote_user','run_time','requ Peak memory usage: 71.90 MiB. ``` -:::note 避免使用点 -我们不建议在 Map 列名中使用点,可能会弃用其用法。请使用 `_`。 +:::note 避免点 +我们不建议在Map列名中使用点,并可能停止使用它。使用`_`。 ::: ## 使用别名 {#using-aliases} -查询 map 类型的速度比查询普通列的速度慢 - 见 ["加速查询"](#accelerating-queries)。此外,语法更复杂,用户编写时可能会感到繁琐。为了解决这个后续问题,我们建议使用别名列。 +查询映射类型的速度比查询普通列慢 - 参见 ["加速查询"](#accelerating-queries)。此外,语法也更复杂,对于用户来说可能很麻烦。为了应对这一问题,我们建议使用别名列。 -别名列在查询时计算,并且不存储在表中。因此,不可能向这种类型的列中插入值。使用别名,我们可以引用 map 键并简化语法,将 map 项目透明地显示为普通列。考虑以下示例: +别名列在查询时计算,并不存储在表中。因此,不可能向这种类型的列插入值。使用别名,我们可以引用映射键并简化语法,透明地将映射条目公开为普通列。考虑以下示例: ```sql CREATE TABLE otel_logs @@ -524,7 +522,7 @@ PARTITION BY toDate(Timestamp) ORDER BY (ServiceName, Timestamp) ``` -我们有几个物化列和一个 `ALIAS` 列 `RemoteAddr`,它访问 map `LogAttributes`。现在,我们可以通过这个列查询 `LogAttributes['remote_addr']` 的值,从而简化我们的查询,即: +我们有几个物化列和一个别名列`RemoteAddr`,它访问映射`LogAttributes`。我们现在可以通过此列查询`LogAttributes['remote_addr']`的值,从而简化我们的查询,即: ```sql SELECT RemoteAddr @@ -542,7 +540,7 @@ LIMIT 5 5 rows in set. Elapsed: 0.011 sec. ``` -此外,通过 `ALTER TABLE` 命令添加 `ALIAS` 非常简单。这些列立即可用,例如: +此外,通过`ALTER TABLE`命令添加`ALIAS`非常简单。这些列立即可用,例如: ```sql ALTER TABLE default.otel_logs @@ -563,54 +561,54 @@ LIMIT 5 5 rows in set. Elapsed: 0.014 sec. ``` -:::note 默认情况下不包括别名 -默认情况下,`SELECT *` 不包括 ALIAS 列。可以通过设置 `asterisk_include_alias_columns=1` 禁用此行为。 +:::note 默认排除别名 +默认情况下,`SELECT *`排除别名列。可以通过设置`asterisk_include_alias_columns=1`来禁用此行为。 ::: ## 优化类型 {#optimizing-types} -[Clickhouse 的一般最佳实践](/data-modeling/schema-design#optimizing-types) 适用于 ClickHouse 的用例。 -## 使用编解码器 {#using-codecs} +[一般的Clickhouse最佳实践](/data-modeling/schema-design#optimizing-types)同样适用于ClickHouse的使用情况。 +## 使用编码器 {#using-codecs} -除了类型优化,用户在尝试优化 ClickHouse 可观察性模式的压缩时,可以遵循 [编解码器的通用最佳实践](/data-compression/compression-in-clickhouse#choosing-the-right-column-compression-codec)。 +除了类型优化,用户在试图优化ClickHouse可观测性架构的压缩时,可以遵循[编码器的一般最佳实践](/data-compression/compression-in-clickhouse#choosing-the-right-column-compression-codec)。 -一般而言,用户会发现 `ZSTD` 编解码器对日志和追踪数据集非常适用。将压缩值从默认值 1 增加可能会改善压缩。然而,这应进行测试,因为更高的值在插入时会增加 CPU 开销。通常,我们看到提高这个值的收益很小。 +一般来说,用户会发现`ZSTD`编码器非常适用于日志和追踪数据集。将压缩值从默认的1增加可能会改善压缩效果。然而,这需要进行测试,因为更高的值在插入时会产生更大的CPU开销。通常,我们看到很少的收益来自增加此值。 -此外,虽然时间戳在压缩方面受益于增量编码,但如果该列用于主键/排序键,查询性能可能会变慢。我们建议用户权衡相应的压缩与查询性能之间的权衡。 +此外,虽然时间戳在压缩方面受益于增量编码,但如果此列用于主键/排序键,将会导致查询性能缓慢。我们建议用户评估相应的压缩与查询性能的权衡。 ## 使用字典 {#using-dictionaries} -[字典](/sql-reference/dictionaries) 是 ClickHouse 的一个 [关键特性](https://clickhouse.com/blog/faster-queries-dictionaries-clickhouse),提供来自各种内部和外部 [源](https://sql-reference/dictionaries#dictionary-sources) 的数据的内存中 [键值](https://en.wikipedia.org/wiki/Key%E2%80%93value_database) 表示,优化以获得超低延迟的查找查询。 +[字典](/sql-reference/dictionaries)是ClickHouse的一个[关键特性](https://clickhouse.com/blog/faster-queries-dictionaries-clickhouse),提供了来自各种内部和外部[数据源](/sql-reference/dictionaries#dictionary-sources)的内存[key-value](https://en.wikipedia.org/wiki/Key%E2%80%93value_database)表示,优化了超低延迟查找查询。 - + -这在各种场景中都很方便,可以在不减慢摄取过程的情况下动态丰富摄取的数据,并提高查询的总体性能,尤其是连接查询受益匪浅。 -虽然在可观察性用例中很少需要连接,但字典仍可以在插入和查询时用于丰富目的。我们提供了以下两方面的示例。 +这在多种场景中非常方便,从在不减慢摄取过程的情况下动态丰富摄取数据到改善查询总体性能,特别是JOIN受益。 +虽然在可观测性用例中,几乎不需要JOIN,但字典对于富化的目的仍然非常有用 - 在插入和查询时间都有用。我们在下面提供了两者的示例。 -:::note 加速连接 -对加速连接感兴趣的用户可以在 [这里](https://dictionary) 查找更多详细信息。 +:::note 加速JOIN +对加速字典JOIN感兴趣的用户可以在[这里](/dictionary)找到更多详细信息。 ::: -### 插入时间 vs 查询时间 {#insert-time-vs-query-time} +### 插入时间与查询时间 {#insert-time-vs-query-time} -字典可以在查询时间或插入时间用于丰富数据集。这些方法各有优缺点。总结: +字典可以用于在查询时间或插入时间丰富数据集。这两种方法各有其优缺点。总结如下: -- **插入时间** - 如果丰富值不变且存在于可以用来填充字典的外部源中,这通常是适当的。在这种情况下,在插入时间丰富行可以避免在查询时间查找字典。这样做的代价是插入性能以及额外的存储开销,因为丰富的值将被存储为列。 -- **查询时间** - 如果字典中的值经常变化,查询时间查找通常更为适用。这可以避免在映射值变化时更新列(和重写数据)。这种灵活性是以查询时间查找成本为代价的。当需要查找许多行时,例如在过滤子句中使用字典查找,该查询时间成本通常是显著的。对于结果丰富,即在 `SELECT` 中,通常不会感受到这种开销。 +- **插入时间** - 如果富集值不变并存在于可以用于填充字典的外部源中,通常这是合适的。在这种情况下,在插入时间丰富行可避免查询时间对字典的查找。这会以插入性能为代价,以及额外的存储开销,因为丰富的值将作为列存储。 +- **查询时间** - 如果字典中的值经常变化,查询时间查找通常更为适用。这可以避免需要更新列(并重写数据)如果映射的值发生变化。这种灵活性以查询时间查找成本为代价。如果需要许多行进行查找,例如在过滤子句中使用字典查找,通常此查询时间成本是明显的。对于结果丰富,即在`SELECT`中,这种开销通常不明显。 -我们建议用户熟悉字典的基础知识。字典提供了一个内存中的查找表,可以使用专用 [专业函数](/sql-reference/functions/ext-dict-functions#dictgetall) 检索值。 +我们建议用户熟悉字典的基础知识。字典提供一个内存查找表,从中可以使用专用[专业函数](/sql-reference/functions/ext-dict-functions#dictgetall)检索值。 -有关简单丰富示例,参见 [字典指南](https://dictionary)。在下面,我们重点介绍常见的可观察性丰富任务。 -### 使用 IP 字典 {#using-ip-dictionaries} +有关简单富化示例,请参见[这里](/dictionary)的字典指南。下面,我们重点关注常见的可观测性富化任务。 +### 使用IP字典 {#using-ip-dictionaries} -使用 IP 地址将日志和跟踪的纬度和经度值进行地理丰富是一个常见的可观察性要求。我们可以使用 `ip_trie` 结构字典来实现这一点。 +使用IP地址通过纬度和经度值丰富日志和追踪是一个常见的可观测性需求。我们可以使用结构化字典`ip_trie`实现这一点。 -我们使用公开可用的 [DB-IP 城市级数据集](https://github.com/sapics/ip-location-db#db-ip-database-update-monthly),该数据集由 [DB-IP.com](https://db-ip.com/) 提供,遵循 [CC BY 4.0 许可](https://creativecommons.org/licenses/by/4.0/) 的条款。 +我们使用公开提供的[DB-IP城市级数据集](https://github.com/sapics/ip-location-db#db-ip-database-update-monthly),由[DB-IP.com](https://db-ip.com/)根据[CC BY 4.0许可证](https://creativecommons.org/licenses/by/4.0/)提供。 -从 [readme](https://github.com/sapics/ip-location-db#csv-format) 中,我们可以看到数据的结构如下: +从[自述文件](https://github.com/sapics/ip-location-db#csv-format)中,我们可以看到数据的结构如下: ```csv | ip_range_start | ip_range_end | country_code | state1 | state2 | city | postcode | latitude | longitude | timezone | ``` -根据该结构,让我们通过 [url()](/sql-reference/table-functions/url) 表函数快速查看数据: +根据这个结构,让我们先使用[url()](/sql-reference/table-functions/url)表函数窥探数据: ```sql SELECT * @@ -631,7 +629,7 @@ longitude: 153.017 timezone: ᴺᵁᴸᴸ ``` -为了简化操作,让我们使用 [`URL()`](/engines/table-engines/special/url) 表引擎创建一个 ClickHouse 表对象,带上我们的字段名,并确认总行数: +为了方便我们,将使用[`URL()`](/engines/table-engines/special/url)表引擎创建ClickHouse表对象,带有我们的字段名称,并确认总行数: ```sql CREATE TABLE geoip_url( @@ -645,7 +643,7 @@ CREATE TABLE geoip_url( latitude Float64, longitude Float64, timezone Nullable(String) -) engine=URL('https://raw.githubusercontent.com/sapics/ip-location-db/master/dbip-city/dbip-city-ipv4.csv.gz', 'CSV') +) ENGINE=URL('https://raw.githubusercontent.com/sapics/ip-location-db/master/dbip-city/dbip-city-ipv4.csv.gz', 'CSV') select count() from geoip_url; @@ -654,23 +652,23 @@ select count() from geoip_url; └─────────┘ ``` -由于我们的 `ip_trie` 字典要求使用 CIDR 表示 IP 地址范围,因此我们需要转换 `ip_range_start` 和 `ip_range_end`。 +因为我们的`ip_trie`字典需要以CIDR表示IP地址范围,我们需要转换`ip_range_start`和`ip_range_end`。 -可以通过以下查询简洁地计算每个范围的 CIDR: +这个范围的CIDR可以通过以下查询简洁地计算: ```sql -with - bitXor(ip_range_start, ip_range_end) as xor, - if(xor != 0, ceil(log2(xor)), 0) as unmatched, - 32 - unmatched as cidr_suffix, - toIPv4(bitAnd(bitNot(pow(2, unmatched) - 1), ip_range_start)::UInt64) as cidr_address -select +WITH + bitXor(ip_range_start, ip_range_end) AS xor, + if(xor != 0, ceil(log2(xor)), 0) AS unmatched, + 32 - unmatched AS cidr_suffix, + toIPv4(bitAnd(bitNot(pow(2, unmatched) - 1), ip_range_start)::UInt64) AS cidr_address +SELECT ip_range_start, ip_range_end, - concat(toString(cidr_address),'/',toString(cidr_suffix)) as cidr -from + concat(toString(cidr_address),'/',toString(cidr_suffix)) AS cidr +FROM geoip_url -limit 4; +LIMIT 4; ┌─ip_range_start─┬─ip_range_end─┬─cidr───────┐ │ 1.0.0.0 │ 1.0.0.255 │ 1.0.0.0/24 │ @@ -683,10 +681,10 @@ limit 4; ``` :::note -在上述查询中发生了很多事情。那些感兴趣的人可以阅读这个精彩的 [解释](https://clickhouse.com/blog/geolocating-ips-in-clickhouse-and-grafana#using-bit-functions-to-convert-ip-ranges-to-cidr-notation)。否则请接受上述内容计算了 IP 范围的 CIDR。 +上面的查询做了很多事情。对此感兴趣的人可以阅读这个优秀的[解释](https://clickhouse.com/blog/geolocating-ips-in-clickhouse-and-grafana#using-bit-functions-to-convert-ip-ranges-to-cidr-notation)。否则,请接受上述计算IP范围的CIDR。 ::: -为了我们的目的,我们只需要 IP 范围、国家代码和坐标,因此让我们创建一个新表并插入我们的 Geo IP 数据: +就我们的目的而言,我们只需要IP范围、国家代码和坐标,因此让我们创建一个新表并插入我们的Geo IP数据: ```sql CREATE TABLE geoip @@ -713,7 +711,7 @@ SELECT FROM geoip_url ``` -为了在 ClickHouse 中执行低延迟 IP 查找,我们将利用字典来存储我们在内存中进行 IP 数据的键 - 属性映射。 ClickHouse 提供了一个 `ip_trie` [字典结构](/sql-reference/dictionaries#ip_trie),将我们的网络前缀(CIDR 块)映射到坐标和国家代码。以下查询指定了一个使用此布局和以上表作为源的字典。 +为了在ClickHouse中执行低延迟的IP查找,我们将利用字典在内存中存储关键->属性映射,以供我们的Geo IP数据。ClickHouse提供了一个`ip_trie` [字典结构](/sql-reference/dictionaries#ip_trie),用于将我们的网络前缀(CIDR块)映射到坐标和国家代码。以下查询指定使用这种布局和上述表作为源的字典。 ```sql CREATE DICTIONARY ip_trie ( @@ -728,7 +726,7 @@ layout(ip_trie) lifetime(3600); ``` -我们可以从字典中选择行并确认此数据集可供查询: +我们可以从字典中选择行并确认该数据集可用于查找: ```sql SELECT * FROM ip_trie LIMIT 3 @@ -743,10 +741,10 @@ SELECT * FROM ip_trie LIMIT 3 ``` :::note 定期刷新 -ClickHouse 中的字典会根据底层表数据和使用的生命周期子句进行定期刷新。要更新我们的 Geo IP 字典以反映 DB-IP 数据集中的最新更改,我们只需将数据从 geoip_url 远程表重新插入到我们的 `geoip` 表中,并应用转换。 +ClickHouse中的字典会根据底层表数据和上述使用的生命周期子句定期刷新。为了更新我们的Geo IP字典以反映DB-IP数据集的最新变化,我们只需将geoip_url远程表中的数据重新插入到我们的`geoip`表中,并应用转换。 ::: -现在我们已经将 Geo IP 数据加载到我们的 `ip_trie` 字典中(也方便地命名为 `ip_trie`),我们可以用它进行 IP 地理定位。这可以使用 [`dictGet()` 函数](/sql-reference/functions/ext-dict-functions) 实现,如下所示: +现在我们已经将Geo IP数据加载到`ip_trie`字典(方便地也命名为`ip_trie`)中,我们可以使用它进行IP地理位置。这可以通过如下使用[`dictGet()`函数](/sql-reference/functions/ext-dict-functions)实现: ```sql SELECT dictGet('ip_trie', ('country_code', 'latitude', 'longitude'), CAST('85.242.48.167', 'IPv4')) AS ip_details @@ -758,9 +756,9 @@ SELECT dictGet('ip_trie', ('country_code', 'latitude', 'longitude'), CAST('85.24 1 row in set. Elapsed: 0.003 sec. ``` -请注意此处的检索速度。这使我们能够丰富日志。在这种情况下,我们选择**执行查询时间丰富**。 +注意此处的检索速度。这使我们能够丰富日志。在这种情况下,我们选择**进行查询时间富化**。 -回到最初的日志数据集,我们可以利用上述信息按国家聚合日志。以下假定我们使用早期物化视图的结果模式,该模式提取了 `RemoteAddress` 列。 +返回到我们原始的日志数据集,我们可以利用上述内容按国家聚合我们的日志。以下假设我们使用来自早期物化视图的架构,其中提取了`RemoteAddress`列。 ```sql SELECT dictGet('ip_trie', 'country_code', tuple(RemoteAddress)) AS country, @@ -783,7 +781,7 @@ LIMIT 5 Peak memory usage: 1.16 MiB. ``` -由于 IP 到地理位置的映射可能会改变,用户可能希望在请求发出时了解请求来源,而不是当前同一地址的地理位置。因此,在这里可能更倾向于索引时间丰富。这可以使用物化列或在物化视图的选择中完成,如下所示: +由于IP到地理位置的映射可能会改变,用户可能希望了解请求发起时的位置 - 而不是同一地址当前的地理位置。因此,此处通常更为优先的是索引时间富化。这可以通过如下所示的物化列或物化视图的选择完成: ```sql CREATE TABLE otel_logs_v2 @@ -814,21 +812,21 @@ ORDER BY (ServiceName, Timestamp) ``` :::note 定期更新 -用户可能希望根据新数据定期更新 IP 丰富字典。这可以通过字典的 `LIFETIME` 子句来实现,这将导致字典定期从底层表重新加载。要更新底层表,请参见 ["可刷新的物化视图"](/materialized-view/refreshable-materialized-view)。 +用户可能希望IP富化字典定期更新,以便根据新数据进行更新。这可以通过字典的`LIFETIME`子句实现,该子句会导致字典定期从底层表中重新加载。要更新底层表,参见["可刷新的物化视图"](/materialized-view/refreshable-materialized-view)。 ::: -上述国家和坐标提供了超出按国家分组和过滤的可视化能力。有关启发,请参见 ["可视化地理数据"](/observability/grafana#visualizing-geo-data)。 +上述国家和坐标提供了超越按国家分组和过滤的可视化能力。获得灵感,请参见["可视化地理数据"](/observability/grafana#visualizing-geo-data)。 ### 使用正则表达式字典(用户代理解析) {#using-regex-dictionaries-user-agent-parsing} -解析 [用户代理字符串](https://en.wikipedia.org/wiki/User_agent) 是经典的正则表达式问题,在基于日志和跟踪的数据集中是一个常见的需求。 ClickHouse 提供了使用正则表达式树字典高效解析用户代理。 +解析[用户代理字符串](https://en.wikipedia.org/wiki/User_agent)是经典的正则表达式问题,也是基于日志和追踪数据集的常见需求。ClickHouse提供使用正则表达式树字典高效解析用户代理的功能。 -正则表达式树字典在 ClickHouse 开源中使用 YAMLRegExpTree 字典源类型定义,提供了指向包含正则表达式树的 YAML 文件的路径。如果您希望提供自己的正则表达式字典,要求的结构细节可以在 [这里](/sql-reference/dictionaries#use-regular-expression-tree-dictionary-in-clickhouse-open-source) 找到。下面我们关注使用 [uap-core](https://github.com/ua-parser/uap-core) 进行用户代理解析,并加载我们的字典以支持 CSV 格式。此方法与 OSS 和 ClickHouse Cloud 兼容。 +正则表达式树字典在ClickHouse开源中使用YAMLRegExpTree字典源类型定义,该类型提供包含正则表达式树的YAML文件路径。如果您希望提供自己的正则表达式字典,可以在[这里](/sql-reference/dictionaries#use-regular-expression-tree-dictionary-in-clickhouse-open-source)找到所需结构的详细信息。下面我们重点关注使用[uap-core](https://github.com/ua-parser/uap-core)解析用户代理并加载我们支持的CSV格式的字典。这种方法与OSS和ClickHouse Cloud兼容。 :::note -在下面的示例中,我们使用 2024 年 6 月的最新 uap-core 用户代理解析的正则表达式快照。可以在 [这里](https://raw.githubusercontent.com/ua-parser/uap-core/master/regexes.yaml) 找到最新文件,该文件不定期更新。用户可以按照 [这里](https://sql-reference/dictionaries#collecting-attribute-values) 的步骤加载到下面使用的 CSV 文件中。 +在以下示例中,我们使用2024年6月的最新uap-core用户代理解析的正则表达式快照。最新文件(会偶尔更新)可在[这里](https://raw.githubusercontent.com/ua-parser/uap-core/master/regexes.yaml)找到。用户可以遵循[这里](/sql-reference/dictionaries#collecting-attribute-values)中的步骤加载下面使用的CSV文件。 ::: -创建以下内存表。这些表保存我们用于解析设备、浏览器和操作系统的正则表达式。 +创建以下内存表。它们存储我们用于解析设备、浏览器和操作系统的正则表达式。 ```sql CREATE TABLE regexp_os @@ -859,7 +857,7 @@ CREATE TABLE regexp_device ) ENGINE=Memory; ``` -这些表可以从以下公开托管的 CSV 文件中填充,使用 URL 表函数: +这些表可以使用URL表函数从以下公开托管的CSV文件填充: ```sql INSERT INTO regexp_os SELECT * FROM s3('https://datasets-documentation.s3.eu-west-3.amazonaws.com/user_agent_regex/regexp_os.csv', 'CSV', 'id UInt64, parent_id UInt64, regexp String, keys Array(String), values Array(String)') @@ -869,7 +867,7 @@ INSERT INTO regexp_device SELECT * FROM s3('https://datasets-documentation.s3.eu INSERT INTO regexp_browser SELECT * FROM s3('https://datasets-documentation.s3.eu-west-3.amazonaws.com/user_agent_regex/regexp_browser.csv', 'CSV', 'id UInt64, parent_id UInt64, regexp String, keys Array(String), values Array(String)') ``` -随着内存表的填充,我们可以加载我们的正则表达式字典。请注意,我们需要将键值指定为列 - 这些将是我们可以从用户代理中提取的属性。 +随着我们的内存表的填充,我们可以加载我们的正则表达式字典。请注意,我们需要将键值指定为列 - 这些将是我们可以从用户代理提取的属性。 ```sql CREATE DICTIONARY regexp_os_dict @@ -911,7 +909,7 @@ LIFETIME(0) LAYOUT(regexp_tree); ``` -加载完这些字典后,我们可以提供一个示例用户代理并测试我们新的字典提取能力: +加载这些字典后,我们可以提供一个示例用户代理并测试我们新的字典提取能力: ```sql WITH 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:127.0) Gecko/20100101 Firefox/127.0' AS user_agent @@ -927,9 +925,9 @@ SELECT 1 row in set. Elapsed: 0.003 sec. ``` -鉴于与用户代理相关的规则很少会变更,字典只需在响应新的浏览器、操作系统和设备时进行更新,因此在插入时间执行此提取是有意义的。 +考虑到围绕用户代理的规则几乎不会改变,字典只需在响应新浏览器、操作系统和设备时更新,因此在插入时执行此提取是有意义的。 -我们可以使用物化列或物化视图来执行此操作。下面我们修改之前使用的物化视图: +我们可以使用物化列或物化视图来完成此工作。下面我们修改之前使用的物化视图: ```sql CREATE MATERIALIZED VIEW otel_logs_mv TO otel_logs_v2 @@ -957,7 +955,7 @@ AS SELECT FROM otel_logs ``` -这要求我们修改目标表 `otel_logs_v2` 的模式: +这要求我们修改目标表`otel_logs_v2`的架构: ```sql CREATE TABLE default.otel_logs_v2 @@ -987,7 +985,7 @@ ENGINE = MergeTree ORDER BY (ServiceName, Timestamp, Status) ``` -重新启动收集器并根据之前记录的步骤摄取结构化日志后,我们可以查询我们新提取的 Device、Browser 和 Os 列。 +在重新启动收集器并根据早期记录的步骤摄取结构化日志后,我们可以查询新提取的Device、Browser和Os列。 ```sql SELECT Device, Browser, Os @@ -1002,8 +1000,8 @@ Browser: ('AhrefsBot','6','1') Os: ('Other','0','0','0') ``` -:::note 元组用于复杂结构 -请注意这些用户代理列中使用的元组。对于已知层次的复杂结构,推荐使用元组。子列的性能与常规列相同(与 map 键不同),同时允许异构类型。 +:::note 用于复杂结构的元组 +注意这些用户代理列使用元组。元组建议用于结构已知的复杂结构。子列提供与常规列相同的性能(与映射键不同),同时允许异构类型。 ::: ### 进一步阅读 {#further-reading} @@ -1014,12 +1012,12 @@ Os: ('Other','0','0','0') - [字典](/sql-reference/dictionaries) ## 加速查询 {#accelerating-queries} -ClickHouse 支持多种加速查询性能的技术。以下方法应仅在选择适当的主键/排序键,以优化最常见的访问模式并最大化压缩后考虑。这通常会对性能产生最大的影响,同时付出最少的努力。 +ClickHouse 支持多种加速查询性能的技术。在选择合适的主键/排序键以优化最常见的访问模式并最大化压缩后,以下方法应被考虑。这通常对性能的影响最大,同时投入的精力最少。 ### 使用物化视图(增量)进行聚合 {#using-materialized-views-incremental-for-aggregations} -在前面的部分中,我们探讨了物化视图在数据转换和过滤中的使用。然而,物化视图也可以用于在插入时预计算聚合并存储结果。该结果可以与后续插入的结果进行更新,因此有效地允许在插入时预计算聚合。 +在前面的部分中,我们探索了物化视图在数据转换和过滤中的使用。然而,物化视图还可以用于在插入时预计算聚合并存储结果。这个结果可以使用后续插入的结果进行更新,从而有效地允许在插入时预计算聚合。 -这里的主要思想是,结果通常会是原始数据的较小表示(在聚合的情况下是部分草图)。当与更简单的查询结合以从目标表中读取结果时,查询时间将比对原始数据执行相同计算要快。 +这里的主要想法是,结果通常会比原始数据小(在聚合情况下是部分快照)。当结合更简单的查询从目标表中读取结果时,查询时间将比在原始数据上执行相同计算的速度更快。 考虑以下查询,我们使用结构化日志计算每小时的总流量: @@ -1043,15 +1041,15 @@ LIMIT 5 Peak memory usage: 1.40 MiB. ``` -我们可以想象,这可能是用户在 Grafana 中绘制的常见折线图。这个查询无疑非常快——数据集只有 1000 万行,而 ClickHouse 很快速!然而,如果我们将其扩展到数十亿和万亿行,我们希望理想地保持这个查询性能。 +我们可以想象这可能是用户在 Grafana 上绘制的常见折线图。这个查询确实非常快 - 数据集只有 1000 万行,而 ClickHouse 的速度很快!但是,如果我们将其扩展到数十亿和数万亿行,我们理想上希望维持这种查询性能。 :::note -如果我们使用 `otel_logs_v2` 表,这个查询的速度将快 10 倍,该表源自我们之前的物化视图,它从 `LogAttributes` 映射中提取大小键。我们在这里使用原始数据仅用于说明,并建议在这是常见查询时使用之前的视图。 +如果我们使用之前物化视图生成的 `otel_logs_v2` 表,这个查询将快 10 倍,该表从 `LogAttributes` map 中提取大小键。我们在这里使用原始数据仅供说明,并建议如果这是一个常见查询,使用之前的视图。 ::: -如果我们希望使用物化视图在插入时计算,需要一个表来接收结果。该表每小时只应保留 1 行。如果接收到现有小时的更新,则其他列应合并到现有小时的行中。为了使增量状态合并,必须为其他列存储部分状态。 +如果我们希望在插入时使用物化视图来计算这一点,则需要一个表来接收结果。该表应仅保持每小时 1 行。如果对现有小时收到更新,则应将其他列合并到现有小时的行中。为了实现增量状态的合并,必须为其他列存储部分状态。 -这需要 ClickHouse 中的一种特殊引擎:SummingMergeTree。它会将所有具有相同排序键的行替换为一个行,其中包含数值列的汇总值。以下表格将合并任何具有相同日期的行,对任何数值列进行求和。 +这需要 ClickHouse 中的一种特殊引擎类型:SummingMergeTree。它通过将具有相同排序键的所有行替换为一行,其中包含数值列的和。以下表将合并任何具有相同日期的行,求和任何数值列。 ```sql CREATE TABLE bytes_per_hour @@ -1063,7 +1061,7 @@ ENGINE = SummingMergeTree ORDER BY Hour ``` -为了演示我们的物化视图,假设我们的 `bytes_per_hour` 表为空且尚未接收任何数据。我们的物化视图在插入到 `otel_logs` 时对数据执行上述 `SELECT`(这将在配置块的大小上执行),结果发送到 `bytes_per_hour`。语法如下所示: +为了演示我们的物化视图,假设我们的 `bytes_per_hour` 表是空的,还未接收任何数据。我们的物化视图对 `otel_logs` 中插入的数据执行上述 `SELECT`(这将在配置大小的块上执行),结果发送到 `bytes_per_hour`。语法如下所示: ```sql CREATE MATERIALIZED VIEW bytes_per_hour_mv TO bytes_per_hour AS @@ -1073,9 +1071,9 @@ FROM otel_logs GROUP BY Hour ``` -这里的 `TO` 子句是关键,表示结果将发送到即 `bytes_per_hour`。 +这里的 `TO` 子句是关键,表示结果将发送到哪个地方,即 `bytes_per_hour`。 -如果我们重启 OTel Collector 并重新发送日志,`bytes_per_hour` 表将逐步填充上述查询结果。完成后,我们可以确认 `bytes_per_hour` 的大小 - 每小时将有 1 行: +如果我们重新启动 OTel Collector 并重新发送日志,`bytes_per_hour` 表将增量填充上述查询结果。完成后,我们可以确认 `bytes_per_hour` 的大小 - 我们每小时应有 1 行: ```sql SELECT count() @@ -1089,14 +1087,14 @@ FINAL 1 row in set. Elapsed: 0.039 sec. ``` -通过存储查询的结果,我们有效地将行数从 1000 万(在 `otel_logs` 中)减少到 113。关键在于,如果新的日志插入到 `otel_logs` 表中,则新值将被发送到 `bytes_per_hour` 的相应小时,并将在后台异步自动合并——通过每小时只保留一行,`bytes_per_hour` 将始终保持小且最新。 +通过存储我们的查询结果,我们实际上将行数从 `otel_logs` 中的 1000 万减少到 113。关键是,如果新的日志被插入到 `otel_logs` 表中,新值将被发送到各自小时的 `bytes_per_hour`,在那里它们将被自动异步合并 - 通过保持每小时一行,`bytes_per_hour` 将始终保持小且最新。 -由于行的合并是异步的,当用户查询时每小时可能会有多行。为了确保在查询时合并所有未完成的行,我们有两个选择: +由于行的合并是异步的,因此在用户查询时,每小时可能会有多于一行。为了确保所有未完成的行在查询时被合并,我们有两个选项: -- 在表名上使用 [`FINAL` 修饰符](/sql-reference/statements/select/from#final-modifier)(正如我们在上面的计数查询中所做)。 -- 按用于我们的最终表的排序键进行聚合,即时间戳并对指标进行求和。 +- 在表名上使用 [`FINAL` 修饰符](/sql-reference/statements/select/from#final-modifier)(这在上面的计数查询中使用了)。 +- 按照我们最终表中使用的排序键进行聚合,即时间戳并求和度量。 -通常,第二个选项效率更高且更灵活(该表可以用于其他用途),但第一个选项对某些查询更简单。我们下面展示了两者: +通常,第二个选项更高效和灵活(该表可以用于其他用途),但第一个选项对于某些查询来说可能更简单。我们在下面同时展示两者: ```sql SELECT @@ -1136,16 +1134,16 @@ LIMIT 5 5 rows in set. Elapsed: 0.005 sec. ``` -这将我们的查询速度从 0.6 秒提高到 0.008 秒,超过 75 倍! +这将我们的查询速度从 0.6 秒提升到 0.008 秒 - 超过 75 倍! :::note -在更大数据集和更复杂的查询中,这些节省可能会更大。请参见 [这里](https://github.com/ClickHouse/clickpy) 以获取示例。 +在大数据集和更复杂的查询中,节省可能会更大。请参阅 [这里](https://github.com/ClickHouse/clickpy) 的示例。 ::: -#### 一个更复杂的示例 {#a-more-complex-example} +#### 更复杂的例子 {#a-more-complex-example} -上述示例使用 [SummingMergeTree](/engines/table-engines/mergetree-family/summingmergetree) 聚合每小时的简单计数。超出简单求和的统计需要不同的目标表引擎:[AggregatingMergeTree](/engines/table-engines/mergetree-family/aggregatingmergetree)。 +上述示例使用 [SummingMergeTree](/engines/table-engines/mergetree-family/summingmergetree) 聚合每小时的简单计数。超出简单求和的统计要求一种不同的目标表引擎:[AggregatingMergeTree](/engines/table-engines/mergetree-family/aggregatingmergetree)。 -假设我们希望计算每天的唯一 IP 地址数量(或唯一用户数量)。对此的查询如下: +假设我们希望计算每天唯一 IP 地址(或唯一用户)的数量。查询如下: ```sql SELECT toStartOfHour(Timestamp) AS Hour, uniq(LogAttributes['remote_addr']) AS UniqueUsers @@ -1161,7 +1159,7 @@ ORDER BY Hour DESC 113 rows in set. Elapsed: 0.667 sec. Processed 10.37 million rows, 4.73 GB (15.53 million rows/s., 7.09 GB/s.) ``` -为了保持增量更新的基数计算,需要使用 AggregatingMergeTree。 +为了保持增量更新的基数计数,需要使用 AggregatingMergeTree。 ```sql CREATE TABLE unique_visitors_per_hour @@ -1173,9 +1171,9 @@ ENGINE = AggregatingMergeTree ORDER BY Hour ``` -为了确保 ClickHouse 知道将存储汇总状态,我们将 `UniqueUsers` 列定义为类型 [`AggregateFunction`](/sql-reference/data-types/aggregatefunction),指定部分状态的函数源(uniq)和源列的类型(IPv4)。与 SummingMergeTree 一样,具有相同 `ORDER BY` 键值的行将被合并(上面的例子中的小时)。 +为了确保 ClickHouse 知道聚合状态将被存储,我们将 `UniqueUsers` 列定义为类型 [`AggregateFunction`](/sql-reference/data-types/aggregatefunction),指定部分状态的功能源(uniq)和源列的类型(IPv4)。像 SummingMergeTree 一样,具有相同 `ORDER BY` 键值的行将被合并(上面的例子中的小时)。 -相关的物化视图使用上面的查询: +相关的物化视图使用早期查询: ```sql CREATE MATERIALIZED VIEW unique_visitors_per_hour_mv TO unique_visitors_per_hour AS @@ -1186,9 +1184,9 @@ GROUP BY Hour ORDER BY Hour DESC ``` -注意我们在聚合函数的末尾添加了后缀 `State`。这确保返回函数的聚合状态而不是最终结果。这将包含额外的信息,以便允许该部分状态与其他状态合并。 +注意我们在聚合函数的末尾附加了后缀 `State`。这确保返回的是函数的聚合状态而不是最终结果。这将包含额外的信息以允许该部分状态与其他状态合并。 -一旦通过 Collector 重启重新加载数据,我们可以确认 `unique_visitors_per_hour` 表中可用 113 行。 +一旦数据通过 Collector 重启重新加载,我们可以确认 `unique_visitors_per_hour` 表中有 113 行。 ```sql SELECT count() @@ -1201,7 +1199,7 @@ FINAL 1 row in set. Elapsed: 0.009 sec. ``` -我们的最终查询需要利用我们函数的 Merge 后缀(因为列存储部分聚合状态): +我们的最终查询需要利用 Merge 后缀进行我们的函数(因为列存储部分聚合状态): ```sql SELECT Hour, uniqMerge(UniqueUsers) AS UniqueUsers @@ -1217,10 +1215,10 @@ ORDER BY Hour DESC 113 rows in set. Elapsed: 0.027 sec. ``` -注意我们在此处使用 `GROUP BY` 而不是使用 `FINAL`。 +注意,我们在这里使用 `GROUP BY` 而不是使用 `FINAL`。 ### 使用物化视图(增量)进行快速查找 {#using-materialized-views-incremental--for-fast-lookups} -用户在选择 ClickHouse 排序键时应考虑他们的访问模式,以及在过滤和聚合子句中频繁使用的列。这在可观察性用例中可能是有限制的,因为用户有更多多样化的访问模式,无法在一组列中封装。这在默认 OTel 模式的内置示例中得到了很好的说明。考虑跟踪的默认模式: +用户在选择 ClickHouse 排序键时应考虑他们的访问模式与经常用于过滤和聚合子句的列。这在可观察性用例中可能是有约束的,用户有更加多样化的访问模式,无法在一组列中呈现。这在内置于默认 OTel 模式的一个示例中得到了很好的说明。考虑默认的跟踪模式: ```sql CREATE TABLE otel_traces @@ -1259,9 +1257,9 @@ PARTITION BY toDate(Timestamp) ORDER BY (ServiceName, SpanName, toUnixTimestamp(Timestamp), TraceId) ``` -该模式针对按 `ServiceName`、`SpanName` 和 `Timestamp` 进行过滤进行了优化。在跟踪中,用户还需要能够通过特定的 `TraceId` 进行查找并检索相关跟踪的跨度。虽然这一点在排序键中存在,但它在末尾的位置意味着 [过滤效率将不如](https://guides/best-practices/sparse-primary-indexes#ordering-key-columns-efficiently),并且在检索单个跟踪时可能需要扫描大量数据。 +此模式针对 `ServiceName`、`SpanName` 和 `Timestamp` 的过滤进行了优化。在跟踪中,用户还需要根据特定 `TraceId` 进行查找,并检索相关跟踪的跨度。虽然这存在于排序键中,但它的位置在末尾意味着 [过滤的效率将不会那么高](/guides/best-practices/sparse-primary-indexes#ordering-key-columns-efficiently),并且在检索单个跟踪时很可能需要扫描大量数据。 -OTel 收集器还安装了一个物化视图和相关的表来解决这个问题。表和视图如下所示: +OTel Collector 还安装了一个物化视图和相关表来解决这个挑战。表和视图如下所示: ```sql CREATE TABLE otel_traces_trace_id_ts @@ -1274,7 +1272,6 @@ CREATE TABLE otel_traces_trace_id_ts ENGINE = MergeTree ORDER BY (TraceId, toUnixTimestamp(Start)) - CREATE MATERIALIZED VIEW otel_traces_trace_id_ts_mv TO otel_traces_trace_id_ts ( `TraceId` String, @@ -1290,7 +1287,7 @@ WHERE TraceId != '' GROUP BY TraceId ``` -该视图有效确保表 `otel_traces_trace_id_ts` 具有跟踪的最小和最大时间戳。这个按 `TraceId` 排序的表允许高效检索这些时间戳。这些时间戳范围可以在查询主 `otel_traces` 表时使用。更具体地说,当通过其 ID 检索跟踪时,Grafana 使用以下查询: +该视图有效地确保表 `otel_traces_trace_id_ts` 的最小和最大时间戳适用于该跟踪。该表按 `TraceId` 排序,允许高效检索这些时间戳。此时间戳范围可以在查询主 `otel_traces` 表时使用。更具体地说,在通过 id 检索跟踪时,Grafana 使用以下查询: ```sql WITH 'ae9226c78d1d360601e6383928e4d22d' AS trace_id, @@ -1319,28 +1316,28 @@ WHERE (traceID = trace_id) AND (startTime >= trace_start) AND (startTime <= trac LIMIT 1000 ``` -此处的 CTE 确定跟踪 ID `ae9226c78d1d360601e6383928e4d22d` 的最小和最大时间戳,然后使用此信息过滤主 `otel_traces` 的相关跨度。 +CTE 在此处识别跟踪 id `ae9226c78d1d360601e6383928e4d22d` 的最小和最大时间戳,然后使用此信息过滤主 `otel_traces` 的相关跨度。 -可以对类似的访问模式应用相同的方法。我们在数据建模 [这里](/materialized-view/incremental-materialized-view#lookup-table) 探讨了类似的示例。 +这个相同的方法可以应用于类似的访问模式。我们在这里探讨一个类似的示例 [在数据建模中](/materialized-view/incremental-materialized-view#lookup-table)。 ### 使用投影 {#using-projections} -ClickHouse 投影允许用户为表指定多个 `ORDER BY` 子句。 +ClickHouse 投影允许用户为一个表指定多个 `ORDER BY` 子句。 -在前面的部分中,我们探讨了物化视图如何在 ClickHouse 中用于预计算聚合、转换行以及优化可观察性查询以适应不同的访问模式。 +在之前的部分中,我们探索了物化视图如何在 ClickHouse 中用于预计算聚合、转换行并优化可观察性查询以适应不同的访问模式。 -我们提供了一个示例,其中物化视图将行发送到目标表,该表的排序键不同于接收插入的原始表,以便在通过跟踪 ID 查找时优化。 +我们提供了一个示例,其中物化视图将行发送到目标表,该目标表的排序键与接收插入的原始表不同,以便优化按跟踪 id 的查找。 -投影可用于解决相同的问题,使用户能够对不属于主键的列的查询进行优化。 +投影可以用于解决相同的问题,使用户能够针对不属于主键的列的查询进行优化。 -理论上,这种能力可以用于为一个表提供多个排序键,具有一个显著的缺点:数据重复。具体而言,数据需要按照主主键的顺序写入,并且还需要按照每个投影指定的顺序写入。这将减慢插入速度,并消耗更多的磁盘空间。 +理论上,此功能可用于为一个表提供多个排序键,具有一个明显的缺点:数据重复。具体来说,除了为每个投影指定的顺序之外,数据还需要按照主主键的顺序进行写入。这将减慢插入速度并占用更多磁盘空间。 -:::note 投影 vs 物化视图 -投影提供了许多与物化视图相同的功能,但应谨慎使用,后者通常更受偏爱。用户应了解缺点以及何时适用。例如,虽然可以使用投影进行预计算聚合,但我们建议用户使用物化视图来实现这一目标。 +:::note 投影与物化视图 +投影提供了与物化视图相同的许多能力,但应谨慎使用,并且后者通常更受欢迎。用户应该了解缺点以及何时适用。例如,虽然可以使用投影进行预计算聚合,但我们建议用户使用物化视图来完成此操作。 ::: -考虑以下查询,它通过 500 错误码过滤我们的 `otel_logs_v2` 表。这可能是用户在记录中希望按错误代码过滤的常见访问模式: +考虑以下查询,它根据 500 错误代码过滤我们的 `otel_logs_v2` 表。这很可能是日志记录中用户希望按错误代码过滤的常见访问模式: ```sql SELECT Timestamp, RequestPath, Status, RemoteAddress, UserAgent @@ -1355,10 +1352,10 @@ Peak memory usage: 56.54 MiB. ``` :::note 使用 Null 测量性能 -我们这里不使用 `FORMAT Null` 打印结果。这强制所有结果被读取但不返回,从而防止因 LIMIT 导致查询的提前终止。这仅仅是为了展示扫描 1000 万行所需的时间。 +我们在这里使用 `FORMAT Null` 不打印结果。这会强制读取所有结果但不返回,从而防止由于 LIMIT 导致查询的提前终止。这只是为了显示扫描所有 1000 万行所需的时间。 ::: -上述查询需要根据我们选择的排序键 `(ServiceName, Timestamp)` 进行线性扫描。虽然我们可以将 `Status` 添加到排序键的末尾,以提高上述查询的性能,但我们也可以添加一个投影。 +上述查询需要使用我们选择的排序键 `(ServiceName, Timestamp)` 进行线性扫描。虽然我们可以将 `Status` 添加到排序键的末尾,从而提高上述查询的性能,但我们也可以添加一个投影。 ```sql ALTER TABLE otel_logs_v2 ( @@ -1371,7 +1368,7 @@ ALTER TABLE otel_logs_v2 ( ALTER TABLE otel_logs_v2 MATERIALIZE PROJECTION status ``` -注意我们必须先创建投影,然后对其进行物化。后者的命令会导致数据在磁盘上以两种不同的顺序存储两次。如果在创建数据时定义投影,如下所示,将在插入时自动维护。 +注意,我们必须首先创建投影,然后使其物化。这个后续命令会导致数据在两种不同顺序下被存储两次。我们在创建数据时也可以定义投影,如下所示,并将在数据插入时自动维护。 ```sql CREATE TABLE otel_logs_v2 @@ -1403,7 +1400,7 @@ ENGINE = MergeTree ORDER BY (ServiceName, Timestamp) ``` -重要的是,如果通过 `ALTER` 创建投影,则在发出 `MATERIALIZE PROJECTION` 命令时,它的创建是异步的。用户可以通过以下查询确认该操作的进度,等待 `is_done=1`。 +重要的是,如果通过 `ALTER` 创建投影,则在发出 `MATERIALIZE PROJECTION` 命令时创建是异步的。用户可以通过以下查询确认此操作的进度,等待 `is_done=1`。 ```sql SELECT parts_to_do, is_done, latest_fail_reason @@ -1417,7 +1414,7 @@ WHERE (`table` = 'otel_logs_v2') AND (command LIKE '%MATERIALIZE%') 1 row in set. Elapsed: 0.008 sec. ``` -如果我们重复上述查询,可以看到性能在付出额外存储成本的情况下显著改善(有关如何测量这一点,请参见 ["测量表的大小和压缩"](#measuring-table-size--compression))。 +如果我们重复上述查询,可以看到性能显著提高,但代价是额外的存储(参见 ["测量表大小和压缩"](#measuring-table-size--compression) 以了解如何进行测量)。 ```sql SELECT Timestamp, RequestPath, Status, RemoteAddress, UserAgent @@ -1429,21 +1426,21 @@ FORMAT `Null` Peak memory usage: 27.85 MiB. ``` -在上面的示例中,我们在投影中指定了早期查询中使用的列。这意味着这些指定的列将按状态存储在磁盘上。如果我们在这里使用 `SELECT *`,则所有列都将被存储。虽然这会使更多查询(使用任何子集列)受益于投影,但将产生额外的存储成本。有关磁盘空间和压缩的测量,请参见 ["测量表的大小和压缩"](#measuring-table-size--compression)。 +在上述示例中,我们在投影中指定了早期查询中使用的列。这将意味着只有这些指定的列将按状态有序地存储在磁盘上。如果相反,我们在这里使用 `SELECT *`,则所有列都将被存储。虽然这将允许更多查询(使用任意列的子集)从投影中受益,但将产生额外的存储。在测量磁盘空间和压缩时,请参见 ["测量表大小和压缩"](#measuring-table-size--compression)。 ### 二级/数据跳过索引 {#secondarydata-skipping-indices} -无论如何,如果在 ClickHouse 中主键的调优良好,一些查询不可避免地会需要全表扫描。虽然可以通过使用物化视图(以及对于某些查询使用投影)来减轻这一问题,但这些需要额外的维护,用户必须了解它们的可用性以确保它们被利用。虽然传统关系数据库通过二级索引解决了这一问题,但在列式数据库如 ClickHouse 中,这些是无效的。相反,ClickHouse 使用“跳过”索引,通过允许数据库跳过大量不匹配值的数据块,显著提高查询性能。 +无论 ClickHouse 中主键调整得多么完美,某些查询不可避免地需要全表扫描。虽然这可以通过使用物化视图(以及某些查询的投影)来缓解,但这些需要额外的维护,并且用户需要意识到它们的可用性以确保有效利用。传统关系数据库通过二级索引来解决这个问题,但在像 ClickHouse 这样的列式数据库中,这些是无效的。相反,ClickHouse 使用“跳过”索引,它可以通过允许数据库跳过没有匹配值的大数据块,显著提高查询性能。 -默认的 OTel 模式使用二级索引来加速对地图的访问。虽然我们发现这些通常无效,并不建议将它们复制到自定义模式中,但跳过索引仍然可以是有用的。 +默认的 OTel 模式在尝试加速对映射访问的访问时使用二级索引。虽然我们发现这些通常无效,并不推荐将它们复制到你的自定义模式中,但跳过索引仍然可以有用。 -用户在尝试应用它们之前,应阅读并理解 [二级索引指南](/optimize/skipping-indexes)。 +用户应在尝试使用它们之前阅读并理解 [二级索引指南](/optimize/skipping-indexes)。 -**通常,当主键与目标的非主列/表达式之间存在强相关性,并且用户查找稀有值时,即那些在许多粒度中不会出现的值,它们是有效的。** +**一般来说,当主键与目标的非主列/表达式之间存在强相关性,并且用户在查找稀有值时即不会出现在多个粒度中,使用它们效果较好。** ### 文本搜索的布隆过滤器 {#bloom-filters-for-text-search} -对于可观察性查询,当用户需要执行文本搜索时,二级索引会很有用。具体而言,基于 ngram 和 token 的布隆过滤器索引 [`ngrambf_v1`](/optimize/skipping-indexes#bloom-filter-types) 和 [`tokenbf_v1`](/optimize/skipping-indexes#bloom-filter-types) 可用于加速对字符串列的搜索,使用操作符 `LIKE`、`IN` 和 hasToken。重要的是,基于 token 的索引使用非字母数字字符作为分隔符生成 token。这意味着在查询时只能匹配 token(或完整单词)。对于更细粒度的匹配,可以使用 [N-gram 布隆过滤器](/optimize/skipping-indexes#bloom-filter-types)。该过滤器将字符串拆分为指定大小的 ngram,从而允许子词匹配。 +对于可观察性查询,当用户需要执行文本搜索时,二级索引可能很有用。具体来说,以 ngram 和基于 token 的布隆过滤器索引 [`ngrambf_v1`](/optimize/skipping-indexes#bloom-filter-types) 和 [`tokenbf_v1`](/optimize/skipping-indexes#bloom-filter-types) 可以用于加速对 String 列的搜索,使用操作符 `LIKE`、`IN` 和 hasToken。重要的是,基于 token 的索引使用非字母数字字符作为分隔符生成 tokens。这意味着只能在查询时匹配 tokens(或整个单词)。对于更精细的匹配,可以使用 [N-gram 布隆过滤器](/optimize/skipping-indexes#bloom-filter-types)。它将字符串拆分成指定大小的 ngrams,从而允许进行子词匹配。 -为了评估将要生成的 token 及其匹配,可以使用 `tokens` 函数: +为了评估将要产生并因此被匹配的 tokens,可以使用 `tokens` 函数: ```sql SELECT tokens('https://www.zanbil.ir/m/filter/b113') @@ -1455,7 +1452,7 @@ SELECT tokens('https://www.zanbil.ir/m/filter/b113') 1 row in set. Elapsed: 0.008 sec. ``` -`ngram` 函数提供了类似的能力,其中可以将 `ngram` 大小指定为第二个参数: +`ngram` 函数提供类似的功能,可以将 ngram 大小作为第二个参数指定: ```sql SELECT ngrams('https://www.zanbil.ir/m/filter/b113', 3) @@ -1467,11 +1464,11 @@ SELECT ngrams('https://www.zanbil.ir/m/filter/b113', 3) 1 row in set. Elapsed: 0.008 sec. ``` -:::note 反向索引 -ClickHouse 还对反向索引作为二级索引提供实验性支持。我们目前不建议将其用于日志数据集,但预计它们将取代基于 token 的布隆过滤器,成为生产就绪状态。 +:::note 倒排索引 +ClickHouse 还实验性地支持作为二级索引的倒排索引。我们目前不推荐这些用于日志数据集,但预计它们将在准备好生产环境时替代基于 token 的布隆过滤器。 ::: -在这个示例中,我们使用结构化日志数据集。假设我们希望计算 `Referer` 列中包含 `ultra` 的日志数量。 +为了本示例的目的,我们使用结构化日志数据集。假设我们希望计算其中 `Referer` 列包含 `ultra` 的日志。 ```sql SELECT count() @@ -1513,9 +1510,9 @@ ENGINE = MergeTree ORDER BY (Timestamp) ``` -索引 `ngrambf_v1(3, 10000, 3, 7)` 这里有四个参数。最后一个参数(值为 7)表示一个种子。其他参数表示 ngram 大小(3)、值 `m`(过滤器大小)以及哈希函数的数量 `k`(7)。`k` 和 `m` 需要调整,基于唯一 ngram/token 的数量和过滤器产生真实负值的概率 - 从而确认某个值不在某个粒度中。我们建议使用 [这些函数](/engines/table-engines/mergetree-family/mergetree#bloom-filter) 来帮助确定这些值。 +索引 `ngrambf_v1(3, 10000, 3, 7)` 这里需要四个参数。最后一个参数(值为 7)代表种子。其他参数代表 ngram 大小(3)、值 `m`(过滤器大小)以及哈希函数数量 `k`(7)。`k` 和 `m` 需要调整,并将基于唯一 ngrams/tokens 的数量以及过滤器结果为真负的概率 - 从而确认值不在粒度中。我们推荐 [这些函数](/engines/table-engines/mergetree-family/mergetree#bloom-filter) 来帮助确定这些值。 -如果调整得当,这里的加速可能会非常显著: +如果调整正确,这里的加速可以是显著的: ```sql SELECT count() @@ -1529,13 +1526,13 @@ WHERE Referer LIKE '%ultra%' Peak memory usage: 129.60 KiB. ``` -:::note 示例仅供参考 -以上仅供说明。我们建议用户在插入时从日志中提取结构,而不是尝试使用基于 token 的布隆过滤器来优化文本搜索。然而,有些情况下用户可能会有堆栈跟踪或其他庞大的字符串,在这些情况下,文本搜索由于结构不确定性可能是有用的。 +:::note 示例仅 +上述内容仅供说明。我们建议用户在插入时从日志中提取结构,而不是尝试使用基于 token 的布隆过滤器优化文本搜索。然而,在用户处理堆栈跟踪或其他大字符串的情况下,文本搜索可能会由于结构不那么确定而有用。 ::: -使用布隆过滤器的一些一般指导原则: +关于使用布隆过滤器的一些一般指南: -布隆的目标是过滤 [粒度](/guides/best-practices/sparse-primary-indexes#clickhouse-index-design),从而避免加载某列的所有值并进行线性扫描。可以使用 `EXPLAIN` 子句,并设置参数 `indexes=1`,来识别已跳过的粒度数量。请考虑以下原始表 `otel_logs_v2` 和带有 ngram 布隆过滤器的表 `otel_logs_bloom` 的响应。 +布隆的目标是过滤 [粒度](/guides/best-practices/sparse-primary-indexes#clickhouse-index-design),从而避免需要加载列的所有值并执行线性扫描。可以使用 `EXPLAIN` 子句,并带有参数 `indexes=1`,来识别跳过的粒度数量。考虑下面对原始表 `otel_logs_v2` 和使用 ngram 布隆过滤器的表 `otel_logs_bloom` 的响应。 ```sql EXPLAIN indexes = 1 @@ -1558,7 +1555,6 @@ WHERE Referer LIKE '%ultra%' 10 rows in set. Elapsed: 0.016 sec. - EXPLAIN indexes = 1 SELECT count() FROM otel_logs_bloom @@ -1583,7 +1579,7 @@ WHERE Referer LIKE '%ultra%' └────────────────────────────────────────────────────────────────────┘ ``` -布隆过滤器通常仅在其大小小于列本身时才能更快。如果它更大,那么在性能上可能几乎没有好处。通过以下查询比较过滤器和列的大小: +布隆过滤器通常只有在它的大小小于列本身时才会更快。如果它更大,则可能会几乎没有性能提升。可以使用以下查询比较过滤器和列的大小: ```sql SELECT @@ -1602,7 +1598,6 @@ ORDER BY sum(data_compressed_bytes) DESC 1 row in set. Elapsed: 0.018 sec. - SELECT `table`, formatReadableSize(data_compressed_bytes) AS compressed_size, @@ -1617,20 +1612,20 @@ WHERE `table` = 'otel_logs_bloom' 1 row in set. Elapsed: 0.004 sec. ``` -在上述示例中,我们可以看到二级布隆过滤器索引的大小为 12MB - 几乎是该列压缩大小 56MB 的五分之一。 +在上述示例中,我们可以看到二级布隆过滤器索引的大小为 12MB - 比列本身的压缩大小 56MB 小了将近 5 倍。 -布隆过滤器可能需要显著调整。我们建议遵循 [这里的说明](/engines/table-engines/mergetree-family/mergetree#bloom-filter),这些说明在识别最佳设置时可能会很有用。布隆过滤器在插入和合并时也可能是昂贵的。用户在将布隆过滤器添加到生产之前,应评估其对插入性能的影响。 +布隆过滤器可能需要显著的调整。我们建议遵循 [这里](/engines/table-engines/mergetree-family/mergetree#bloom-filter) 的注释,这些注释可以在识别最佳设置时提供帮助。布隆过滤器在插入和合并时也可能很昂贵。用户在向生产中添加布隆过滤器之前,应评估其对插入性能的影响。 -有关二级跳过索引的更多详细信息,可以在 [这里](https://optimize/skipping-indexes#skip-index-functions) 找到。 +有关二次跳过索引的更多细节,请参见 [这里](/optimize/skipping-indexes#skip-index-functions)。 ### 从映射中提取 {#extracting-from-maps} -Map 类型在 OTel 模式中普遍存在。此类型要求值和键具有相同的类型——对于 Kubernetes 标签等元数据来说足够。当查询 Map 类型的子键时,整个父列会被加载。如果映射中有许多键,这会产生显著的查询惩罚,因为需要从磁盘读取的数据比键作为列存在时要多。 +Map 类型在 OTel 模式中广泛存在。此类型要求值和键具有相同的类型 - 适用于 Kubernetes 标签等元数据。请注意,当查询 Map 类型的子键时,会加载整个父列。如果映射具有许多键,这可能会引起显著的查询罚款,因为需要从磁盘读取的数据比键存在为列时要多。 -如果您经常查询特定的键,请考虑将其移动到根部的专用列中。这通常是响应于常见访问模式和部署后进行的任务,可能在生产之前难以预测。有关如何在部署后修改架构,请参见 ["管理架构变化"](/observability/managing-data#managing-schema-changes)。 -## 测量表的大小和压缩 {#measuring-table-size--compression} +如果您经常查询特定键,请考虑将其移动到根级别的专用列中。这通常是在响应常见访问模式并部署后进行的任务,并可能在生产之前难以预测。请参阅 ["管理架构变更"](/observability/managing-data#managing-schema-changes) 以了解如何在部署后修改架构。 +## 测量表大小和压缩 {#measuring-table-size--compression} -ClickHouse 被用于可观察性的一个主要原因是压缩。 +ClickHouse 用于可观察性的主要原因之一是压缩。 -它不仅能显著降低存储成本,更少的数据在磁盘上意味着更少的 I/O 和更快的查询及插入。I/O 的减少将超出任何压缩算法与 CPU 的开销。因此,在确保 ClickHouse 查询快速时,数据压缩的改善应该是首要关注点。 +除了显著降低存储成本外,磁盘上较少的数据意味着较少的 I/O 和更快的查询与插入。I/O 的减少将超过任何压缩算法相对于 CPU 的开销。因此,提高数据的压缩性能应成为确保 ClickHouse 查询快速的首要重点。 -有关测量压缩的详细信息,请参见 [这里](/data-compression/compression-in-clickhouse)。 +关于压缩测量的详细信息可以在 [这里](/data-compression/compression-in-clickhouse) 找到。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/build-your-own/schema-design.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/build-your-own/schema-design.md.hash index 71cf479cf07..165b9343a8a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/build-your-own/schema-design.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/build-your-own/schema-design.md.hash @@ -1 +1 @@ -2eec7d14eddb2423 +6695e55e351d2af7 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/alerts.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/alerts.md index 7bd94282428..2ddb340a315 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/alerts.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/alerts.md @@ -5,6 +5,7 @@ 'pagination_prev': null 'pagination_next': null 'description': '使用 ClickStack 的警报' +'doc_type': 'guide' --- import Image from '@theme/IdealImage'; @@ -12,24 +13,24 @@ import search_alert from '@site/static/images/use-cases/observability/search_ale ## 搜索警报 {#search-alerts} -在输入一个 [搜索](/use-cases/observability/clickstack/search) 后,您可以创建一个警报,当匹配搜索的事件(日志或跨度)数量超过或低于某个阈值时通知您。 +在输入了一个 [搜索](/use-cases/observability/clickstack/search) 后,您可以创建一个警报,当匹配该搜索的事件(日志或跨度)数量超过或低于某个阈值时接收通知。 ### 创建警报 {#creating-an-alert} 您可以通过点击 `Search` 页面右上角的 `Alerts` 按钮来创建警报。 -在此,您可以为警报命名,并设置阈值、持续时间和通知方法(Slack、电子邮件、PagerDuty 或 Slack webhook)。 +在这里,您可以为警报命名,并设置阈值、持续时间和通知方式(Slack、Email、PagerDuty 或 Slack webhook)。 -`grouped by` 值允许搜索处于聚合状态,例如 `ServiceName`,从而允许同一搜索触发多个潜在警报。 +`grouped by` 值允许搜索进行聚合,例如 `ServiceName`,因此允许基于同一搜索触发多个潜在警报。 ### 常见警报场景 {#common-alert-scenarios} -以下是一些您可以使用 HyperDX 的常见警报场景: +以下是您可以使用 HyperDX 的一些常见警报场景: -**错误:** 我们首先建议为默认的 `All Error Events` 和 `HTTP Status >= 400` 保存的搜索设置警报,以便在发生过多错误时通知您。 +**错误:** 我们首先建议为默认的 `All Error Events` 和 `HTTP Status >= 400` 保存的搜索设置警报,以便在发生过多错误时收到通知。 -**慢操作:** 您可以设置一个搜索以查找慢操作(例如 `duration:>5000`),并在发生过多慢操作时发出警报。 +**慢操作:** 您可以设置一个搜索以监视慢操作(例如 `duration:>5000`),并在发生过多慢操作时发出警报。 -**用户事件:** 您还可以设置警报,以便在新用户注册或执行关键用户操作时通知面向客户的团队。 +**用户事件:** 您还可以为面向客户的团队设置警报,以便在新用户注册或执行关键用户操作时收到通知。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/alerts.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/alerts.md.hash index 218e996e577..08461b8f95b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/alerts.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/alerts.md.hash @@ -1 +1 @@ -7ead5b6d71dcb501 +6ba68048ea55f30a diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/architecture.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/architecture.md index fe927b46dbe..80d8c134040 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/architecture.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/architecture.md @@ -2,62 +2,63 @@ 'slug': '/use-cases/observability/clickstack/architecture' 'pagination_prev': null 'pagination_next': null -'description': 'ClickStack 的架构 - ClickHouse 可观测性堆栈' +'description': 'ClickStack 的架构 - ClickHouse 观察性堆栈' 'title': '架构' +'doc_type': 'reference' --- import Image from '@theme/IdealImage'; import architecture from '@site/static/images/use-cases/observability/clickstack-architecture.png'; -The ClickStack architecture is built around three core components: **ClickHouse**, **HyperDX**, and a **OpenTelemetry (OTel) collector**. A **MongoDB** instance provides storage for the application state. Together, they provide a high-performance, open-source observability stack optimized for logs, metrics, and traces. +ClickStack 架构围绕三个核心组件构建:**ClickHouse**、**HyperDX** 和 **OpenTelemetry (OTel) 收集器**。一个 **MongoDB** 实例为应用状态提供存储。它们共同提供了一个高性能、开源的可观察性栈,优化用于日志、指标和追踪。 -## Architecture Overview {#architecture-overview} +## 架构概述 {#architecture-overview} -## ClickHouse: The database engine {#clickhouse} +## ClickHouse: 数据库引擎 {#clickhouse} -在 ClickStack 的核心是 ClickHouse,一个专为实时分析而设计的列式数据库。它支持观察数据的摄取和查询,使得: +ClickStack 的核心是 ClickHouse,这是一款面向实时分析的大规模列式数据库。它支持可观察性数据的摄取和查询,使得: -- 在数 TB 事件中进行亚秒级搜索 -- 每天摄取数十亿高基数记录 -- 在观察数据上实现至少 10 倍的高压缩率 -- 原生支持半结构化 JSON 数据,允许动态模式演变 -- 拥有数百个内置分析函数的强大 SQL 引擎 +- 以亚秒级的速度搜索数TB的事件 +- 每天摄取数十亿的高基数记录 +- 可观察性数据的压缩率至少达到10倍 +- 对半结构化 JSON 数据的原生支持,允许动态架构演变 +- 具有数百个内置分析函数的强大 SQL 引擎 -ClickHouse 将观察数据处理为宽事件,允许在单一统一结构中深入关联日志、指标和追踪。 +ClickHouse 将可观察性数据视为宽事件,允许在单一统一结构中对日志、指标和追踪进行深度关联。 -## OpenTelemetry collector: data ingestion {#open-telemetry-collector} +## OpenTelemetry 收集器:数据摄取 {#open-telemetry-collector} -ClickStack 包含一个预配置的 OpenTelemetry (OTel) 收集器,以开放且标准化的方式摄取遥测数据。用户可以通过以下方式使用 OTLP 协议发送数据: +ClickStack 包含一个预配置的 OpenTelemetry (OTel) 收集器,以开放、标准化的方式摄取遥测数据。用户可以通过以下方式使用 OTLP 协议发送数据: - gRPC(端口 `4317`) - HTTP(端口 `4318`) -收集器以高效批量方式将遥测数据导出到 ClickHouse。它支持每个数据源的优化表模式,确保所有信号类型的可伸缩性能。 +收集器以高效的批量方式将遥测数据导出到 ClickHouse。它支持每个数据源的优化表架构,确保所有信号类型间可扩展的性能。 -## HyperDX: The interface {#hyperdx} +## HyperDX: 界面 {#hyperdx} HyperDX 是 ClickStack 的用户界面。它提供: - 自然语言和 Lucene 风格的搜索 -- 实时调试的实时尾部跟踪 +- 实时调试的实时尾追 - 日志、指标和追踪的统一视图 -- 前端可观察性的会话重放 +- 前端可观察性的会话回放 - 仪表板创建和警报配置 - 用于高级分析的 SQL 查询接口 -HyperDX 专为 ClickHouse 设计,将强大的搜索与直观的工作流程结合在一起,使用户能够快速发现异常、调查问题及获得洞察。 +HyperDX 专为 ClickHouse 设计,将强大的搜索功能与直观的工作流程结合在一起,使用户能够快速发现异常、调查问题并获得洞见。 -## MongoDB: application state {#mongo} +## MongoDB: 应用状态 {#mongo} -ClickStack 使用 MongoDB 存储应用级状态,包括: +ClickStack 使用 MongoDB 来存储应用级状态,包括: - 仪表板 - 警报 -- 用户配置文件 -- 已保存的可视化 +- 用户资料 +- 保存的可视化 -这种将状态与事件数据分开的设计确保了性能和可扩展性,同时简化了备份和配置。 +将状态与事件数据分离确保了性能和可扩展性,同时简化了备份和配置。 -这种模块化架构使 ClickStack 能够提供一个开箱即用的可观察性平台,快速、灵活且开源。 +这种模块化架构使 ClickStack 能够提供一个即插即用的可观察性平台,快速、灵活且开源。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/architecture.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/architecture.md.hash index 1f6697d7dd2..68fce933441 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/architecture.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/architecture.md.hash @@ -1 +1 @@ -dbf7236f6def2bb1 +8277c81e0bac5bc2 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/config.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/config.md index 1849913b509..28f81b544a8 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/config.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/config.md @@ -3,30 +3,31 @@ 'title': '配置选项' 'pagination_prev': null 'pagination_next': null -'description': 'ClickStack 的配置选项 - ClickHouse 观察性堆栈' +'description': 'ClickStack 的配置选项 - ClickHouse 可观察性栈' +'doc_type': 'reference' --- import Image from '@theme/IdealImage'; import hyperdx_25 from '@site/static/images/use-cases/observability/hyperdx-25.png'; import hyperdx_26 from '@site/static/images/use-cases/observability/hyperdx-26.png'; -以下是 ClickStack 每个组件可用的配置选项: +以下是 ClickStack 各组件可用的配置选项: ## 修改设置 {#modifying-settings} ### Docker {#docker} -如果使用[一体化](/use-cases/observability/clickstack/deployment/all-in-one)、[仅限 HyperDX](/use-cases/observability/clickstack/deployment/hyperdx-only) 或 [本地模式](/use-cases/observability/clickstack/deployment/local-mode-only),只需通过环境变量传递所需的设置,例如: +如果使用 [All in One](/use-cases/observability/clickstack/deployment/all-in-one)、 [HyperDX Only](/use-cases/observability/clickstack/deployment/hyperdx-only) 或 [Local Mode](/use-cases/observability/clickstack/deployment/local-mode-only),只需通过环境变量传递所需的设置,例如: -```bash +```shell docker run -e HYPERDX_LOG_LEVEL='debug' -p 8080:8080 -p 4317:4317 -p 4318:4318 docker.hyperdx.io/hyperdx/hyperdx-all-in-one ``` ### Docker Compose {#docker-compose} -如果使用 [Docker Compose](/use-cases/observability/clickstack/deployment/docker-compose) 部署指南,可以使用 [`.env`](https://github.com/hyperdxio/hyperdx/blob/main/.env) 文件来修改设置。 +如果使用 [Docker Compose](/use-cases/observability/clickstack/deployment/docker-compose) 部署指南,可以使用 [`.env`](https://github.com/hyperdxio/hyperdx/blob/main/.env) 文件修改设置。 -或者,明确地在 [`docker-compose.yaml`](https://github.com/hyperdxio/hyperdx/blob/main/docker-compose.yml) 文件中覆盖设置,例如: +或者,可以在 [`docker-compose.yaml`](https://github.com/hyperdxio/hyperdx/blob/main/docker-compose.yml) 文件中显式覆盖设置,例如: 示例: ```yaml @@ -40,11 +41,11 @@ services: ### Helm {#helm} -#### 自定义值 (可选) {#customizing-values} +#### 自定义值(可选) {#customizing-values} -您可以使用 `--set` 标志来自定义设置,例如: +您可以使用 `--set` 标志自定义设置,例如: -```bash +```shell helm install my-hyperdx hyperdx/hdx-oss-v2 \ --set replicaCount=2 \ --set resources.limits.cpu=500m \ @@ -62,7 +63,7 @@ helm install my-hyperdx hyperdx/hdx-oss-v2 \ 或者编辑 `values.yaml`。要检索默认值: -```sh +```shell helm show values hyperdx/hdx-oss-v2 > values.yaml ``` @@ -97,298 +98,313 @@ ingress: HyperDX 依赖用户为每种可观察性数据类型/支柱定义源: -- `日志` -- `追踪` -- `指标` -- `会话` +- `Logs` +- `Traces` +- `Metrics` +- `Sessions` -此配置可以在应用程序中的 `团队设置 -> 源` 内完成,如下所示(针对日志): +此配置可以在应用程序中通过 `Team Settings -> Sources` 完成,如下所示以获取日志为例: - + -每个源在创建时至少需要指定一个表,以及一组列,以允许 HyperDX 查询数据。 +每个源在创建时都需要至少指定一个表,以及一组允许 HyperDX 查询数据的列。 -如果使用 [默认的 OpenTelemetry (OTel) 架构](/observability/integrating-opentelemetry#out-of-the-box-schema) 与 ClickStack 一起分发,则这些列可以为每个源自动推导。如果 [修改架构](#clickhouse) 或使用自定义架构,用户需要指定并更新这些映射。 +如果使用 [default OpenTelemetry (OTel) schema](/observability/integrating-opentelemetry#out-of-the-box-schema),ClickStack 分发的这些列可以为每个源自动推导。如果 [modifying the schema](#clickhouse) 或使用自定义架构,用户需要指定和更新这些映射。 :::note -与 ClickStack 一起分发的 ClickHouse 的默认架构是为 OTel 收集器创建的 [ClickHouse 导出器](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/exporter/clickhouseexporter) 的架构。这些列名与 OTel 官方规范文档中的详细说明 [here](https://opentelemetry.io/docs/specs/otel/logs/data-model/) 相对应。 +ClickStack 附带的 ClickHouse 默认架构是由 [ClickHouse exporter for the OTel collector](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/exporter/clickhouseexporter) 创建的架构。这些列名与 OTel 官方规范文档 [此处](https://opentelemetry.io/docs/specs/otel/logs/data-model/) 中的相关。 ::: -每个源可用以下设置: +以下设置适用于每个源: #### 日志 {#logs} -| 设置 | 描述 | 必须 | 默认架构中推导 | 推导值 | -|-------------------------------|-------------------------------------------------------------------------------------------------------------------------|------------|-----------------|-------------------------------------------------| -| `名称` | 源名称。 | 是 | 否 | – | -| `服务器连接` | 服务器连接名称。 | 是 | 否 | `Default` | -| `数据库` | ClickHouse 数据库名称。 | 是 | 是 | `default` | -| `表` | 目标表名。如果使用默认架构,则设置为 `otel_logs`。 | 是 | 否 | | -| `时间戳列` | 作为主键一部分的日期时间列或表达式。 | 是 | 是 | `TimestampTime` | -| `默认选择` | 默认搜索结果中显示的列。 | 是 | 是 | `Timestamp`, `ServiceName`, `SeverityText`, `Body` | -| `服务名称表达式` | 表达式或列,用于获取服务名称。 | 是 | 是 | `ServiceName` | -| `日志级别表达式` | 表达式或列,用于获取日志级别。 | 是 | 是 | `SeverityText` | -| `主体表达式` | 表达式或列,用于日志消息。 | 是 | 是 | `Body` | -| `日志属性表达式` | 表达式或列,用于自定义日志属性。 | 是 | 是 | `LogAttributes` | -| `资源属性表达式` | 表达式或列,用于资源级别的属性。 | 是 | 是 | `ResourceAttributes` | -| `显示的时间戳列` | 用于 UI 显示的时间戳列。 | 是 | 是 | `ResourceAttributes` | -| `相关指标源` | 关联的指标源(例如:HyperDX 指标)。 | 否 | 否 | – | -| `相关追踪源` | 关联的追踪源(例如:HyperDX 追踪)。 | 否 | 否 | – | -| `追踪 ID 表达式` | 用于提取追踪 ID 的表达式或列。 | 是 | 是 | `TraceId` | -| `跨度 ID 表达式` | 用于提取跨度 ID 的表达式或列。 | 是 | 是 | `SpanId` | -| `隐式列表达式` | 如果未指定字段则用于全文搜索的列(Lucene 风格),通常是日志主体。 | 是 | 是 | `Body` | - -#### 追踪 {#traces} - -| 设置 | 描述 | 必须 | 默认架构中推导 | 推导值 | -|--------------------------------|-------------------------------------------------------------------------------------------------------------------------|------------|-----------------|-----------------| -| `名称` | 源名称。 | 是 | 否 | – | -| `服务器连接` | 服务器连接名称。 | 是 | 否 | `Default` | -| `数据库` | ClickHouse 数据库名称。 | 是 | 是 | `default` | -| `表` | 目标表名。如果使用默认架构,则设置为 `otel_traces`。 | 是 | 是 | - | -| `时间戳列` | 作为主键一部分的日期时间列或表达式。 | 是 | 是 | `Timestamp` | -| `时间戳` | `时间戳列` 的别名。 | 是 | 是 | `Timestamp` | -| `默认选择` | 默认搜索结果中显示的列。 | 是 | 是 | `Timestamp, ServiceName as service, StatusCode as level, round(Duration / 1e6) as duration, SpanName` | -| `持续时间表达式` | 计算跨度持续时间的表达式。 | 是 | 是 | `Duration` | -| `持续时间精度` | 持续时间表达式的精度(例如,纳秒、微秒)。 | 是 | 是 | ns | -| `追踪 ID 表达式` | 用于追踪 ID 的表达式或列。 | 是 | 是 | `TraceId` | -| `跨度 ID 表达式` | 用于跨度 ID 的表达式或列。 | 是 | 是 | `SpanId` | -| `父跨度 ID 表达式` | 用于父跨度 ID 的表达式或列。 | 是 | 是 | `ParentSpanId` | -| `跨度名称表达式` | 用于跨度名称的表达式或列。 | 是 | 是 | `SpanName` | -| `跨度类型表达式` | 用于跨度类型的表达式或列(例如:客户端、服务器)。 | 是 | 是 | `SpanKind` | -| `相关日志源` | 可选。关联的日志源(例如:HyperDX 日志)。 | 否 | 否 | – | -| `相关会话源` | 可选。关联的会话源。 | 否 | 否 | – | -| `相关指标源` | 可选。关联的指标源(例如:HyperDX 指标)。 | 否 | 否 | – | -| `状态代码表达式` | 用于跨度状态代码的表达式。 | 是 | 是 | `StatusCode` | -| `状态消息表达式` | 用于跨度状态消息的表达式。 | 是 | 是 | `StatusMessage` | -| `服务名称表达式` | 表达式或列,用于服务名称。 | 是 | 是 | `ServiceName` | -| `资源属性表达式` | 表达式或列,用于资源级别的属性。 | 是 | 是 | `ResourceAttributes` | -| `事件属性表达式` | 表达式或列,用于事件属性。 | 是 | 是 | `SpanAttributes` | -| `跨度事件表达式` | 提取跨度事件的表达式。通常是 `Nested` 类型列。这允许使用支持的语言 SDK 渲染异常堆栈跟踪。 | 是 | 是 | `Events` | -| `隐式列表达式` | 如果未指定字段则用于全文搜索的列(Lucene 风格)。通常是日志主体。 | 是 | 是 | `SpanName` | +| 设置 | 描述 | 必需 | 在默认架构中推导 | 推导值 | +|----------------------------------|--------------------------------------------------------------------------------------------------------------------------|------------|---------------------|---------------------------------------------| +| `Name` | 源名称。 | 是 | 否 | – | +| `Server Connection` | 服务器连接名称。 | 是 | 否 | `Default` | +| `Database` | ClickHouse 数据库名称。 | 是 | 是 | `default` | +| `Table` | 目标表名称。如果使用默认架构,则设置为 `otel_logs`。 | 是 | 否 | | +| `Timestamp Column` | 作为主键一部分的时间戳列或表达式。 | 是 | 是 | `TimestampTime` | +| `Default Select` | 默认搜索结果中显示的列。 | 是 | 是 | `Timestamp`, `ServiceName`, `SeverityText`, `Body` | +| `Service Name Expression` | 服务名称的表达式或列。 | 是 | 是 | `ServiceName` | +| `Log Level Expression` | 日志级别的表达式或列。 | 是 | 是 | `SeverityText` | +| `Body Expression` | 日志消息的表达式或列。 | 是 | 是 | `Body` | +| `Log Attributes Expression` | 自定义日志属性的表达式或列。 | 是 | 是 | `LogAttributes` | +| `Resource Attributes Expression` | 资源级别属性的表达式或列。 | 是 | 是 | `ResourceAttributes` | +| `Displayed Timestamp Column` | 用于 UI 显示的时间戳列。 | 是 | 是 | `ResourceAttributes` | +| `Correlated Metric Source` | 关联的指标源(例如 HyperDX 指标)。 | 否 | 否 | – | +| `Correlated Trace Source` | 关联的跟踪源(例如 HyperDX 跟踪)。 | 否 | 否 | – | +| `Trace Id Expression` | 用于提取跟踪 ID 的表达式或列。 | 是 | 是 | `TraceId` | +| `Span Id Expression` | 用于提取跨度 ID 的表达式或列。 | 是 | 是 | `SpanId` | +| `Implicit Column Expression` | 用于全文搜索的列,如果没有指定字段(Lucene 风格)。通常是日志主体。 | 是 | 是 | `Body` | + +#### 跟踪 {#traces} + +| 设置 | 描述 | 必需 | 在默认架构中推导 | 推导值 | +|-----------------------------------|-------------------------------------------------------------------------------------------|------------|---------------------|--------------------| +| `Name` | 源名称。 | 是 | 否 | – | +| `Server Connection` | 服务器连接名称。 | 是 | 否 | `Default` | +| `Database` | ClickHouse 数据库名称。 | 是 | 是 | `default` | +| `Table` | 目标表名称。如果使用默认架构,则设置为 `otel_traces`。 | 是 | 是 | - | +| `Timestamp Column` | 作为主键一部分的时间戳列或表达式。 | 是 | 是 | `Timestamp` | +| `Timestamp` | `Timestamp Column` 的别名。 | 是 | 是 | `Timestamp` | +| `Default Select` | 默认搜索结果中显示的列。 | 是 | 是 | `Timestamp, ServiceName as service, StatusCode as level, round(Duration / 1e6) as duration, SpanName` | +| `Duration Expression` | 用于计算跨度持续时间的表达式。 | 是 | 是 | `Duration` | +| `Duration Precision` | 持续时间表达式的精度(例如,纳秒、微秒)。 | 是 | 是 | ns | +| `Trace Id Expression` | 跟踪 ID 的表达式或列。 | 是 | 是 | `TraceId` | +| `Span Id Expression` | 跨度 ID 的表达式或列。 | 是 | 是 | `SpanId` | +| `Parent Span Id Expression` | 父跨度 ID 的表达式或列。 | 是 | 是 | `ParentSpanId` | +| `Span Name Expression` | 跨度名称的表达式或列。 | 是 | 是 | `SpanName` | +| `Span Kind Expression` | 跨度类型的表达式或列(例如,客户端、服务器)。 | 是 | 是 | `SpanKind` | +| `Correlated Log Source` | 可选。关联的日志源(例如,HyperDX 日志)。 | 否 | 否 | – | +| `Correlated Session Source` | 可选。关联的会话源。 | 否 | 否 | – | +| `Correlated Metric Source` | 可选。关联的指标源(例如,HyperDX 指标)。 | 否 | 否 | – | +| `Status Code Expression` | 跨度状态代码的表达式。 | 是 | 是 | `StatusCode` | +| `Status Message Expression` | 跨度状态消息的表达式。 | 是 | 是 | `StatusMessage` | +| `Service Name Expression` | 服务名称的表达式或列。 | 是 | 是 | `ServiceName` | +| `Resource Attributes Expression` | 资源级别属性的表达式或列。 | 是 | 是 | `ResourceAttributes`| +| `Event Attributes Expression` | 事件属性的表达式或列。 | 是 | 是 | `SpanAttributes` | +| `Span Events Expression` | 提取跨度事件的表达式。通常是 `Nested` 类型的列。这允许与支持的语言 SDK 渲染异常堆栈跟踪。 | 是 | 是 | `Events` | +| `Implicit Column Expression` | 用于全文搜索的列,如果没有指定字段(Lucene 风格)。通常是日志主体。 | 是 | 是 | `SpanName` | #### 指标 {#metrics} -| 设置 | 描述 | 必须 | 默认架构中推导 | 推导值 | -|------------------------------|---------------------------------------------------------------------------------------------------------------|------------|-----------------|---------------------| -| `名称` | 源名称。 | 是 | 否 | – | -| `服务器连接` | 服务器连接名称。 | 是 | 否 | `Default` | -| `数据库` | ClickHouse 数据库名称。 | 是 | 是 | `default` | -| `仪表表` | 存储仪表类型指标的表。 | 是 | 否 | `otel_metrics_gauge` | -| `直方图表` | 存储直方图类型指标的表。 | 是 | 否 | `otel_metrics_histogram` | -| `总和表` | 存储总和类型(计数器)指标的表。 | 是 | 否 | `otel_metrics_sum` | -| `相关日志源` | 可选。关联的日志源(例如:HyperDX 日志)。 | 否 | 否 | – | +| 设置 | 描述 | 必需 | 在默认架构中推导 | 推导值 | +|-----------------------|-------------------------------------------------------------------------------------------|------------|---------------------|-----------------------| +| `Name` | 源名称。 | 是 | 否 | – | +| `Server Connection` | 服务器连接名称。 | 是 | 否 | `Default` | +| `Database` | ClickHouse 数据库名称。 | 是 | 是 | `default` | +| `Gauge Table` | 存储测量类型指标的表。 | 是 | 否 | `otel_metrics_gauge` | +| `Histogram Table` | 存储直方图类型指标的表。 | 是 | 否 | `otel_metrics_histogram` | +| `Sum Table` | 存储总和类型(计数器)指标的表。 | 是 | 否 | `otel_metrics_sum` | +| `Correlated Log Source` | 可选。关联的日志源(例如,HyperDX 日志)。 | 否 | 否 | – | #### 会话 {#settings} -| 设置 | 描述 | 必须 | 默认架构中推导 | 推导值 | -|-------------------------------|----------------------------------------------------------------------------------------------------------------|------------|-----------------|---------------------| -| `名称` | 源名称。 | 是 | 否 | – | -| `服务器连接` | 服务器连接名称。 | 是 | 否 | `Default` | -| `数据库` | ClickHouse 数据库名称。 | 是 | 是 | `default` | -| `表` | 会话数据的目标表名。在使用默认架构时,设置为 `hyperdx_sessions`。 | 是 | 是 | - | -| `时间戳列` | 作为主键一部分的日期时间列或表达式。 | 是 | 是 | `TimestampTime` | -| `日志属性表达式` | 从会话数据中提取日志级别属性的表达式。 | 是 | 是 | `LogAttributes` | -| `LogAttributes` | 用于存储日志属性的别名或字段引用。 | 是 | 是 | `LogAttributes` | -| `资源属性表达式` | 提取资源级别元数据的表达式。 | 是 | 是 | `ResourceAttributes` | -| `相关追踪源` | 可选。用于会话关联的关联追踪源。 | 否 | 否 | – | -| `隐式列表达式` | 如果未指定字段,则用于全文搜索的列(例如 Lucene 风格查询解析)。 | 是 | 是 | `Body` | +| 设置 | 描述 | 必需 | 在默认架构中推导 | 推导值 | +|------------------------------------|----------------------------------------------------------------------------------------------|------------|---------------------|--------------------| +| `Name` | 源名称。 | 是 | 否 | – | +| `Server Connection` | 服务器连接名称。 | 是 | 否 | `Default` | +| `Database` | ClickHouse 数据库名称。 | 是 | 是 | `default` | +| `Table` | 会话数据的目标表。目标表名称。如果使用默认架构,则设置为 `hyperdx_sessions`。 | 是 | 是 | - | +| `Timestamp Column` | 作为主键一部分的时间戳列或表达式。 | 是 | 是 | `TimestampTime` | +| `Log Attributes Expression` | 从会话数据中提取日志级别属性的表达式。 | 是 | 是 | `LogAttributes` | +| `LogAttributes` | 用于存储日志属性的别名或字段引用。 | 是 | 是 | `LogAttributes` | +| `Resource Attributes Expression` | 用于提取资源级别元数据的表达式。 | 是 | 是 | `ResourceAttributes`| +| `Correlated Trace Source` | 可选。用于会话关联的跟踪源。 | 否 | 否 | – | +| `Implicit Column Expression` | 如果未指定字段(例如,Lucene 样式查询解析),则用于全文搜索的列。 | 是 | 是 | `Body` | -### 相关源 {#correlated-sources} +### 关联源 {#correlated-sources} -要在 ClickStack 中启用完整的跨源关联,用户必须配置日志、追踪、指标和会话的相关源。这使 HyperDX 能够关联相关数据,并在呈现事件时提供丰富的上下文。 +要在 ClickStack 中启用完全的跨源关联,用户必须为日志、跟踪、指标和会话配置关联源。这使得 HyperDX 能够关联相关数据,并在呈现事件时提供丰富的上下文。 -- `日志`:可以与追踪和指标关联。 -- `追踪`:可以与日志、会话和指标关联。 -- `指标`:可以与日志关联。 -- `会话`:可以与追踪关联。 +- `Logs`:可以与跟踪和指标关联。 +- `Traces`:可以与日志、会话和指标关联。 +- `Metrics`:可以与日志关联。 +- `Sessions`:可以与跟踪关联。 -通过设置这些关联,HyperDX 可以,例如,在追踪旁边呈现相关日志或列出与会话相关的指标异常。正确的配置确保了统一且有上下文的可观察性体验。 +通过设置这些关联,HyperDX 可以例如在跟踪旁边呈现相关日志或显示与会话相关的指标异常。正确的配置确保统一和上下文丰富的可观察性体验。 -例如,以下是配置了相关源的日志源: +例如,以下是配置了关联源的日志源: - + ### 应用程序配置设置 {#application-configuration-settings} +:::note HyperDX 在 ClickHouse Cloud 中 +当 HyperDX 在 ClickHouse Cloud 中管理时,这些设置无法修改。 +::: + - `HYPERDX_API_KEY` - - **默认值:** 无(必需) - - **描述:** HyperDX API 的身份验证密钥。 - - **指导:** - - 传感器和日志记录所需 - - 本地开发中,可以是任何非空值 - - 对于生产环境,使用安全的唯一密钥 - - 账户创建后可从团队设置页面获取 + - **默认值:** 无(必需) + - **描述:** HyperDX API 的身份验证密钥。 + - **指导:** + - 为遥测和日志记录所需 + - 在本地开发中,可以是任何非空值 + - 对于生产,使用安全的唯一密钥 + - 在创建帐户后可以从团队设置页面获取 - `HYPERDX_LOG_LEVEL` - - **默认值:** `info` - - **描述:** 设置日志详细级别。 - - **选项:** `debug`, `info`, `warn`, `error` - - **指导:** - - 在故障排除时使用 `debug` - - 正常操作使用 `info` - - 生产环境中使用 `warn` 或 `error` 以减少日志数量 + - **默认值:** `info` + - **描述:** 设置日志的详细程度级别。 + - **选项:** `debug`, `info`, `warn`, `error` + - **指导:** + - 在故障排除时使用 `debug` + - 正常操作使用 `info` + - 在生产中使用 `warn` 或 `error` 来减少日志量 - `HYPERDX_API_PORT` - - **默认值:** `8000` - - **描述:** HyperDX API 服务器的端口。 - - **指导:** - - 确保此端口在您的主机上可用 - - 如果有端口冲突,请更改 - - 必须与 API 客户端配置中的端口匹配 + - **默认值:** `8000` + - **描述:** HyperDX API 服务器的端口。 + - **指导:** + - 确保该端口在主机上可用 + - 如果端口冲突,请更改 + - 必须与 API 客户端配置中的端口相匹配 - `HYPERDX_APP_PORT` - - **默认值:** `8000` - - **描述:** HyperDX 前端应用程序的端口。 - - **指导:** - - 确保此端口在您的主机上可用 - - 如果有端口冲突,请更改 - - 必须可以从您的浏览器访问 + - **默认值:** `8000` + - **描述:** HyperDX 前端应用程序的端口。 + - **指导:** + - 确保该端口在主机上可用 + - 如果端口冲突,请更改 + - 必须可以从浏览器访问 - `HYPERDX_APP_URL` - - **默认值:** `http://localhost` - - **描述:** 前端应用程序的基本 URL。 - - **指导:** - - 在生产环境中设置为您的域名 - - 包含协议(http/https) - - 不要包含尾部斜杠 + - **默认值:** `http://localhost` + - **描述:** 前端应用程序的基本 URL。 + - **指导:** + - 在生产中设置为您的域 + - 包含协议(http/https) + - 不要包括尾部斜杠 - `MONGO_URI` - - **默认值:** `mongodb://db:27017/hyperdx` - - **描述:** MongoDB 连接字符串。 - - **指导:** - - 在使用 Docker 的本地开发中使用默认值 - - 在生产环境中,使用安全连接字符串 - - 如果需要,包含身份验证 - - 示例: `mongodb://user:pass@host:port/db` + - **默认值:** `mongodb://db:27017/hyperdx` + - **描述:** MongoDB 连接字符串。 + - **指导:** + - 在本地开发时使用 Docker 的默认值 + - 对于生产,使用安全的连接字符串 + - 如果需要,包含身份验证 + - 示例:`mongodb://user:pass@host:port/db` - `MINER_API_URL` - - **默认值:** `http://miner:5123` - - **描述:** 日志模式挖掘服务的 URL。 - - **指导:** - - 在使用 Docker 的本地开发中使用默认值 - - 在生产环境中设置为您的挖矿服务 URL - - 必须可以从 API 服务访问 + - **默认值:** `http://miner:5123` + - **描述:** 日志模式挖掘服务的 URL。 + - **指导:** + - 在本地开发时使用 Docker 的默认值 + - 在生产环境中设置为您的挖掘服务 URL + - 必须可以从 API 服务访问 - `FRONTEND_URL` - - **默认值:** `http://localhost:3000` - - **描述:** 前端应用程序的 URL。 - - **指导:** - - 在本地开发中使用默认值 - - 在生产环境中设置为您的域名 - - 必须可以从 API 服务访问 + - **默认值:** `http://localhost:3000` + - **描述:** 前端应用程序的 URL。 + - **指导:** + - 在本地开发时使用默认值 + - 在生产中设置为您的域 + - 必须可以从 API 服务访问 - `OTEL_SERVICE_NAME` - - **默认值:** `hdx-oss-api` - - **描述:** OpenTelemetry 仪表化的服务名称。 - - **指导:** - - 使用描述性名称来表示您的 HyperDX 服务。如果 HyperDX 自我仪表化,则适用。 - - 有助于识别传感器数据中的 HyperDX 服务 + - **默认值:** `hdx-oss-api` + - **描述:** OpenTelemetry 插件的服务名称。 + - **指导:** + - 使用描述性的名称为您的 HyperDX 服务。如果 HyperDX 自我插桩,则适用。 + - 有助于在遥测数据中识别 HyperDX 服务 - `NEXT_PUBLIC_OTEL_EXPORTER_OTLP_ENDPOINT` - - **默认值:** `http://localhost:4318` - - **描述:** OpenTelemetry 收集器端点。 - - **指导:** - - 与自我仪表化的 HyperDX 相关。 - - 本地开发中使用默认值 - - 在生产中设置为您的收集器 URL - - 必须可以从您的 HyperDX 服务访问 + - **默认值:** `http://localhost:4318` + - **描述:** OpenTelemetry 收集器端点。 + - **指导:** + - 与自我插桩的 HyperDX 相关。 + - 在本地开发时使用默认值 + - 在生产中设置为您的收集器 URL + - 必须可以从 HyperDX 服务访问 - `USAGE_STATS_ENABLED` - - **默认值:** `true` - - **描述:** 切换使用统计信息收集。 - - **指导:** - - 设置为 `false` 以禁用使用跟踪 - - 对于隐私敏感的部署有用 - - 默认是 `true`,以改善产品 + - **默认值:** `true` + - **描述:** 切换使用统计信息的收集。 + - **指导:** + - 设置为 `false` 以禁用使用跟踪 + - 对于隐私敏感的部署很有用 + - 默认值为 `true` 以改善产品 - `IS_OSS` - - **默认值:** `true` - - **描述:** 表示是否在 OSS 模式下运行。 - - **指导:** - - 对于开源部署保持为 `true` - - 对于企业部署设置为 `false` - - 影响功能可用性 + - **默认值:** `true` + - **描述:** 表示是否在 OSS 模式下运行。 + - **指导:** + - 对于开源部署保持为 `true` + - 对于企业部署设置为 `false` + - 影响功能可用性 - `IS_LOCAL_MODE` - - **默认值:** `false` - - **描述:** 表示是否在本地模式下运行。 - - **指导:** - - 将设置为 `true` 以进行本地开发 - - 禁用某些生产功能 - - 适用于测试和开发 + - **默认值:** `false` + - **描述:** 表示是否在本地模式下运行。 + - **指导:** + - 设置为 `true` 以进行本地开发 + - 禁用某些生产功能 + - 对于测试和开发非常有用 - `EXPRESS_SESSION_SECRET` - - **默认值:** `hyperdx is cool 👋` - - **描述:** Express 会话管理的密钥。 - - **指导:** - - 在生产中进行更改 - - 使用强随机字符串 - - 保持机密和安全 + - **默认值:** `hyperdx is cool 👋` + - **描述:** Express 会话管理的密钥。 + - **指导:** + - 在生产中更改 + - 使用强随机字符串 + - 保持机密和安全 - `ENABLE_SWAGGER` - - **默认值:** `false` - - **描述:** 切换 Swagger API 文档。 - - **指导:** - - 设置为 `true` 启用 API 文档 - - 对于开发和测试有用 - - 在生产中禁用 - + - **默认值:** `false` + - **描述:** 切换 Swagger API 文档。 + - **指导:** + - 设置为 `true` 以启用 API 文档 + - 对于开发和测试很有用 + - 在生产中禁用 + +- `BETA_CH_OTEL_JSON_SCHEMA_ENABLED` + - **默认值:** `false` + - **描述:** 启用 HyperDX 中 JSON 类型的 Beta 支持。另请参阅 [`OTEL_AGENT_FEATURE_GATE_ARG`](#otel-collector) 以启用 OTel 收集器中的 JSON 支持。 + - **指导:** + - 设置为 `true` 以在 ClickStack 中启用 JSON 支持。 ## OpenTelemetry 收集器 {#otel-collector} -有关更多详细信息,请参阅 ["ClickStack OpenTelemetry Collector"](/use-cases/observability/clickstack/ingesting-data/otel-collector)。 +有关更多详细信息,请参见 ["ClickStack OpenTelemetry Collector"](/use-cases/observability/clickstack/ingesting-data/otel-collector)。 - `CLICKHOUSE_ENDPOINT` - - **默认值:** 如果是独立映像则为*无(必需)*。如果是一体化或 Docker Compose 分布,则设置为集成的 ClickHouse 实例。 - - **描述:** 将监控数据导出到的 ClickHouse 实例的 HTTPS URL。 + - **默认值:** *无(必需)* 如果是独立镜像。如果是 All-in-one 或 Docker Compose 分发,则设置为集成的 ClickHouse 实例。 + - **描述:** 要导出遥测数据的 ClickHouse 实例的 HTTPS URL。 - **指导:** - 必须是完整的 HTTPS 端点,包括端口(例如,`https://clickhouse.example.com:8443`) - - 收集器发送数据到 ClickHouse 时必需 + - 收集器向 ClickHouse 发送数据时必需 - `CLICKHOUSE_USER` - **默认值:** `default` - **描述:** 用于与 ClickHouse 实例进行身份验证的用户名。 - **指导:** - - 确保用户具有 `INSERT` 和 `CREATE TABLE` 权限 - - 建议为数据摄取创建一个专用用户 + - 确保该用户具有 `INSERT` 和 `CREATE TABLE` 权限 + - 建议为提取创建专用用户 - `CLICKHOUSE_PASSWORD` - **默认值:** *无(如果启用身份验证,则必需)* - **描述:** 指定 ClickHouse 用户的密码。 - **指导:** - - 如果用户帐户设置了密码,则必需 - - 在生产部署中安全地存储 + - 如果用户帐户设置了密码,则为必需 + - 在生产部署中通过密钥安全存储 - `HYPERDX_LOG_LEVEL` - **默认值:** `info` - - **描述:** 收集器的日志详细级别。 + - **描述:** 收集器的日志详细程度级别。 - **指导:** - - 接受 `debug`, `info`, `warn`, `error` 等值 + - 接受类似 `debug`、`info`、`warn`、`error` 的值 - 在故障排除期间使用 `debug` - `OPAMP_SERVER_URL` - - **默认值:** 如果是独立映像,则*无(必需)*。如果是一体化或 Docker Compose 分布,则指向已部署的 HyperDX 实例。 - - **描述:** 用于管理收集器的 OpAMP 服务器的 URL(例如:HyperDX 实例)。默认端口为 `4320`。 + - **默认值:** *无(必需)* 如果是独立镜像。如果是 All-in-one 或 Docker Compose 分发,则指向部署的 HyperDX 实例。 + - **描述:** 用于管理收集器的 OpAMP 服务器的 URL(例如,HyperDX 实例)。默认端口为 `4320`。 - **指导:** - 必须指向您的 HyperDX 实例 - - 启用动态配置和安全摄取 + - 启用动态配置和安全提取 - `HYPERDX_OTEL_EXPORTER_CLICKHOUSE_DATABASE` - **默认值:** `default` - - **描述:** 收集器写入监控数据的 ClickHouse 数据库。 + - **描述:** 收集器将遥测数据写入的 ClickHouse 数据库。 - **指导:** - - 如果使用自定义数据库名称,请设置 - - 确保指定用户对该数据库有访问权限 + - 如果使用自定义数据库名称,则设置 + - 确保所指定的用户对该数据库有访问权限 + +- `OTEL_AGENT_FEATURE_GATE_ARG` + - **默认值:** `<空字符串>` + - **描述:** 启用收集器中的功能标志。如果设置为 `--feature-gates=clickhouse.json` 则启用收集器中的 JSON 类型的 Beta 支持,确保创建具有该类型的架构。另请参见 [`BETA_CH_OTEL_JSON_SCHEMA_ENABLED`](#hyperdx) 以在 HyperDX 中启用 JSON 支持。 + - **指导:** + - 设置为 `true` 以在 ClickStack 中启用 JSON 支持。 ## ClickHouse {#clickhouse} -ClickStack 附带了默认的 ClickHouse 配置,旨在支持多 TB 的规模,但用户可以自由修改和优化以适应其工作负载。 +ClickStack 附带的默认 ClickHouse 配置旨在用于多 TB 规模,但用户可以自由修改和优化以适应其工作负载。 -为了有效调整 ClickHouse,用户应了解关键存储概念,如 [parts](/parts)、[partitions](/partitions)、[shards and replicas](/shards),以及 [merges](/merges) 在插入时如何发生。我们建议回顾[主索引](/primary-indexes)、[稀疏二级索引](/optimize/skipping-indexes)和数据跳过索引的基础知识,以及[管理数据生命周期](/observability/managing-data)的技术,例如,使用 TTL 生命周期。 +要有效调整 ClickHouse,用户应了解关键存储概念,例如 [parts](/parts)、[partitions](/partitions)、[shards and replicas](/shards),以及如何在插入时发生 [merges](/merges)。我们建议查看 [primary indices](/primary-indexes)、[sparse secondary indices](/optimize/skipping-indexes) 和数据跳过索引的基本知识,以及使用 TTL 生命周期管理数据生命周期的技术。 -ClickStack 支持 [架构自定义](/use-cases/observability/schema-design) - 用户可以修改列类型、提取新字段(例如:从日志中)、应用编解码器和字典,并使用投影加速查询。 +ClickStack 支持 [schema customization](/use-cases/observability/schema-design) - 用户可以修改列类型、提取新字段(例如,从日志中)、应用编解码器和字典,并使用投影加速查询。 -此外,可以使用物化视图[在摄取期间转换或过滤数据](/use-cases/observability/schema-design#materialized-columns),前提是数据被写入视图的源表,并且应用程序从目标表中读取。 +此外,物化视图可以用于 [transform or filter data during ingestion](/use-cases/observability/schema-design#materialized-columns),前提是数据写入视图的源表,并且应用程序从目标表读取。 -有关更多详细信息,请参考 ClickHouse 文档中的架构设计、索引策略和数据管理最佳实践 - 大多数均直接适用于 ClickStack 部署。 +有关更多详细信息,请参阅 ClickHouse 文档中的架构设计、索引策略和数据管理最佳实践 - 大多数内容直接适用于 ClickStack 部署。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/config.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/config.md.hash index 8b2aa50ebe8..fe9cd4692cb 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/config.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/config.md.hash @@ -1 +1 @@ -79647c8370fbfdcd +8978aa12bc5bc51c diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/dashboards.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/dashboards.md new file mode 100644 index 00000000000..ac444da3771 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/dashboards.md @@ -0,0 +1,205 @@ +--- +'slug': '/use-cases/observability/clickstack/dashboards' +'title': '使用 ClickStack 的可视化和仪表板' +'sidebar_label': '仪表板' +'pagination_prev': null +'pagination_next': null +'description': '使用 ClickStack 的可视化和仪表板' +'doc_type': 'guide' +--- + +import Image from '@theme/IdealImage'; +import visualization_1 from '@site/static/images/use-cases/observability/hyperdx-visualization-1.png'; +import visualization_2 from '@site/static/images/use-cases/observability/hyperdx-visualization-2.png'; +import visualization_3 from '@site/static/images/use-cases/observability/hyperdx-visualization-3.png'; +import dashboard_1 from '@site/static/images/use-cases/observability/hyperdx-dashboard-1.png'; +import dashboard_2 from '@site/static/images/use-cases/observability/hyperdx-dashboard-2.png'; +import dashboard_3 from '@site/static/images/use-cases/observability/hyperdx-dashboard-3.png'; +import dashboard_4 from '@site/static/images/use-cases/observability/hyperdx-dashboard-4.png'; +import dashboard_5 from '@site/static/images/use-cases/observability/hyperdx-dashboard-5.png'; +import dashboard_filter from '@site/static/images/use-cases/observability/hyperdx-dashboard-filter.png'; +import dashboard_save from '@site/static/images/use-cases/observability/hyperdx-dashboard-save.png'; +import dashboard_search from '@site/static/images/use-cases/observability/hyperdx-dashboard-search.png'; +import dashboard_edit from '@site/static/images/use-cases/observability/hyperdx-dashboard-edit.png'; +import dashboard_clickhouse from '@site/static/images/use-cases/observability/hyperdx-dashboard-clickhouse.png'; +import dashboard_services from '@site/static/images/use-cases/observability/hyperdx-dashboard-services.png'; +import dashboard_kubernetes from '@site/static/images/use-cases/observability/hyperdx-dashboard-kubernetes.png'; + +ClickStack 支持事件的可视化,并内置支持在 HyperDX 中进行图表绘制。这些图表可以添加到仪表板中,与其他用户共享。 + +可视化可以从跟踪、度量、日志或任何用户定义的宽事件模式中创建。 + +## 创建可视化 {#creating-visualizations} + +HyperDX 中的 **Chart Explorer** 界面允许用户可视化度量、跟踪和日志,方便地创建数据分析的快速可视化。此界面在创建仪表板时也会重用。以下部分介绍了使用 Chart Explorer 创建可视化的过程。 + +每个可视化都从选择 **数据源** 开始,接着选择 **度量**,可以添加可选的 **过滤表达式** 和 **分组** 字段。从概念上讲,HyperDX 中的可视化底层映射到 SQL `GROUP BY` 查询 — 用户定义跨所选维度的度量以聚合。 + +例如,您可以根据服务名称绘制错误数量 (`count()`) 的图表。 + +在以下示例中,我们使用在 [sql.clickhouse.com](https://sql.clickhouse.com) 上提供的远程数据集,如指南 ["Remote Demo Dataset"](/use-cases/observability/clickstack/getting-started/remote-demo-data) 中所描述。**用户还可以通过访问 [play-clickstack.clickhouse.com](https://play-clickstack.clickhouse.com) 重现这些示例。** + + + +### 导航到 Chart Explorer {#navigate-chart-explorer} + +从左侧菜单中选择 `Chart Explorer`。 + + + +### 创建可视化 {#create-visualization} + +在下面的示例中,我们根据服务名称绘制平均请求时长的随时间变化的图表。这需要用户指定一个度量、一列(可以是 SQL 表达式)和一个聚合字段。 + +从顶部菜单中选择 `Line/Bar` 可视化类型,然后选择 `Traces`(或如果使用 [play-clickstack.clickhouse.com](https://play-clickstack.clickhouse.com),选择 `Demo Traces`)数据集。填写以下值: + +- Metric: `Average` +- Column: `Duration/1000` +- Where: `` +- Group By: `ServiceName` +- Alias: `Average Time` + + + +注意,用户可以使用 SQL `WHERE` 子句或 Lucene 语法过滤事件,并设置要可视化事件的时间范围。也支持多个系列。 + +例如,通过添加过滤器 `ServiceName:"frontend"` 来按服务 `frontend` 进行过滤。通过点击 `Add Series` 添加第二个系列,以 `Count` 为别名显示随时间变化的事件计数。 + + + +:::note +可视化可以从任何数据源创建 — 无论是度量、跟踪还是日志。ClickStack 将所有这些视为宽事件。任何 **数值列** 都可以随时间绘制,**字符串**、**日期**或 **数值** 列可用于分组。 + +这种统一的方法使用户能够使用一致且灵活的模型在各种遥测类型之间构建仪表板。 +::: + + + +## 创建仪表板 {#creating-dashboards} + +仪表板提供了一种将相关可视化分组的方式,使用户能够并排比较度量并探索模式,以识别其系统中潜在的根本原因。这些仪表板可以用于临时调查,或保存用于持续监控。 + +全局过滤器可以在仪表板级别应用,自动传播到该仪表板内的所有可视化。这允许在图表之间一致地深入挖掘,并简化跨服务和遥测类型的事件关联。 + +我们在下面创建一个包含两个可视化的仪表板,使用日志和跟踪数据源。这些步骤可以在 [play-clickstack.clickhouse.com](https://play-clickstack.clickhouse.com) 或通过连接到托管在 [sql.clickhouse.com](https://sql.clickhouse.com) 上的数据集本地重现,如指南 ["Remote Demo Dataset"](/use-cases/observability/clickstack/getting-started/remote-demo-data) 中所述。 + + + +### 导航到仪表板 {#navigate-dashboards} + +从左侧菜单中选择 `Dashboards`。 + + + +默认情况下,仪表板是临时的,以支持临时调查。 + +如果使用您自己的 HyperDX 实例,您可以确保稍后可以保存此仪表板,通过点击 `Create New Saved Dashboard`。如果使用只读环境 [play-clickstack.clickhouse.com](https://play-clickstack.clickhouse.com),则此选项将不可用。 + +### 创建可视化 – 按服务的平均请求时间 {#create-a-tile} + +选择 `Add New Tile` 打开可视化创建面板。 + +从顶部菜单中选择 `Line/Bar` 可视化类型,然后选择 `Traces`(或如果使用 [play-clickstack.clickhouse.com](https://play-clickstack.clickhouse.com),选择 `Demo Traces`)数据集。填写以下值以创建图表,显示按服务名称平均请求时长随时间的变化: + +- Chart Name: `Average duration by service` +- Metric: `Average` +- Column: `Duration/1000` +- Where: `` +- Group By: `ServiceName` +- Alias: `Average Time` + +点击 **play** 按钮后,再点击 `Save`。 + + + +调整可视化大小,使其占据仪表板的整个宽度。 + + + +### 创建可视化 – 按服务的事件随时间变化 {#create-a-tile-2} + +选择 `Add New Tile` 打开可视化创建面板。 + +从顶部菜单中选择 `Line/Bar` 可视化类型,然后选择 `Logs`(或如果使用 [play-clickstack.clickhouse.com](https://play-clickstack.clickhouse.com),选择 `Demo Logs`)数据集。填写以下值以创建图表,显示按服务名称的事件随时间变化的计数: + +- Chart Name: `Event count by service` +- Metric: `Count of Events` +- Where: `` +- Group By: `ServiceName` +- Alias: `Count of events` + +点击 **play** 按钮后,再点击 `Save`。 + + + +调整可视化大小,使其占据仪表板的整个宽度。 + + + +### 过滤仪表板 {#filter-dashboards} + +Lucene 或 SQL 过滤器,以及时间范围,可以在仪表板级别应用,并将自动传播到所有可视化。 + + + +为演示,应用 Lucene 过滤器 `ServiceName:"frontend"` 到仪表板,并修改时间窗口以覆盖过去 3 小时。请注意,图表现在仅反映来自 `frontend` 服务的数据。 + +仪表板将自动保存。要设置仪表板名称,请选择标题并在点击 `Save Name` 之前进行修改。 + + + + + +## 仪表板 - 编辑可视化 {#dashboards-editing-visualizations} + +要删除、编辑或复制可视化,请将鼠标悬停在其上并使用相应的操作按钮。 + + + +## 仪表板列表和搜索 {#dashboard-listing-search} + +仪表板可从左侧菜单访问,并内置搜索以快速定位特定仪表板。 + + + +## 预设 {#presets} + +HyperDX 部署时带有开箱即用的仪表板。 + +### ClickHouse 仪表板 {#clickhouse-dashboard} + +此仪表板提供监控 ClickHouse 的可视化。要导航到此仪表板,请从左侧菜单中选择它。 + + + +此仪表板使用标签将 **选择**、**插入** 和 **ClickHouse 基础设施** 的监控分开。 + +:::note 需要系统表访问权限 +此仪表板查询 ClickHouse [系统表](/operations/system-tables) 以暴露关键度量。以下权限是必需的: + +`GRANT SHOW COLUMNS, SELECT(CurrentMetric_MemoryTracking, CurrentMetric_S3Requests, ProfileEvent_OSCPUVirtualTimeMicroseconds, ProfileEvent_OSReadChars, ProfileEvent_OSWriteChars, ProfileEvent_S3GetObject, ProfileEvent_S3ListObjects, ProfileEvent_S3PutObject, ProfileEvent_S3UploadPart, event_time) ON system.metric_log` + +`GRANT SHOW COLUMNS, SELECT(active, database, partition, rows, table) ON system.parts` + +`GRANT SHOW COLUMNS, SELECT(event_date, event_time, memory_usage, normalized_query_hash, query, query_duration_ms, query_kind, read_rows, tables, type, written_bytes, written_rows) ON system.query_log` + +`GRANT SHOW COLUMNS, SELECT(event_date, event_time, hostname, metric, value) ON system.transposed_metric_log` +::: + +### 服务仪表板 {#services-dashboard} + +服务仪表板根据跟踪数据展示当前活动的服务。这要求用户收集了跟踪数据并配置了有效的 Traces 数据源。 + +服务名称会从跟踪数据中自动检测,并将一系列预构建的可视化组织在三个标签中:HTTP 服务、数据库和错误。 + +可视化可以使用 Lucene 或 SQL 语法过滤,时间窗口也可以调整以进行针对性分析。 + + + +### Kubernetes 仪表板 {#kubernetes-dashboard} + +此仪表板允许用户查看通过 OpenTelemetry 收集的 Kubernetes 事件。它包含高级过滤选项,用户可以按 Kubernetes Pod、Deployment、Node 名称、Namespace 和 Cluster 进行过滤,以及执行自由文本搜索。 + +Kubernetes 数据分为三个标签,便于导航:Pods、Nodes 和 Namespaces。 + + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/dashboards.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/dashboards.md.hash new file mode 100644 index 00000000000..5fba7698f8e --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/dashboards.md.hash @@ -0,0 +1 @@ +cd5782f5fc901421 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/_snippets/_json_support.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/_snippets/_json_support.md new file mode 100644 index 00000000000..20f2a4464a6 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/_snippets/_json_support.md @@ -0,0 +1,14 @@ +import BetaBadge from '@theme/badges/BetaBadge'; + +## JSON 类型支持 {#json-type-support} + + + +ClickStack 自版本 `2.0.4` 起开始对 [JSON 类型](/interfaces/formats/JSON) 提供测试支持。 + +有关此类型的好处,请参见 [JSON 类型的好处](/use-cases/observability/clickstack/ingesting-data/otel-collector#benefits-json-type)。 + +为了启用对 JSON 类型的支持,用户必须设置以下环境变量: + +- `OTEL_AGENT_FEATURE_GATE_ARG='--feature-gates=clickhouse.json'` - 在 OTel 收集器中启用支持,确保使用 JSON 类型创建模式。 +- `BETA_CH_OTEL_JSON_SCHEMA_ENABLED=true` - 在 HyperDX 应用程序中启用支持,允许查询 JSON 数据。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/_snippets/_json_support.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/_snippets/_json_support.md.hash new file mode 100644 index 00000000000..81a267055a6 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/_snippets/_json_support.md.hash @@ -0,0 +1 @@ +9abe33be78673cc9 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/_snippets/otel-cloud-config.yaml b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/_snippets/otel-cloud-config.yaml new file mode 100644 index 00000000000..c8244181c49 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/_snippets/otel-cloud-config.yaml @@ -0,0 +1,147 @@ +receivers: + otlp/hyperdx: + protocols: + grpc: + include_metadata: true + endpoint: '0.0.0.0:4317' + http: + cors: + allowed_origins: ['*'] + allowed_headers: ['*'] + include_metadata: true + endpoint: '0.0.0.0:4318' +processors: + transform: + log_statements: + - context: log + error_mode: ignore + statements: + # JSON parsing: Extends log attributes with the fields from structured log body content, either as an OTEL map or + # as a string containing JSON content. + - set(log.cache, ExtractPatterns(log.body, "(?P<0>(\\{.*\\}))")) where + IsString(log.body) + - merge_maps(log.attributes, ParseJSON(log.cache["0"]), "upsert") + where IsMap(log.cache) + - flatten(log.attributes) where IsMap(log.cache) + - merge_maps(log.attributes, log.body, "upsert") where IsMap(log.body) + - context: log + error_mode: ignore + conditions: + - severity_number == 0 and severity_text == "" + statements: + # Infer: extract the first log level keyword from the first 256 characters of the body + - set(log.cache["substr"], log.body.string) where Len(log.body.string) + < 256 + - set(log.cache["substr"], Substring(log.body.string, 0, 256)) where + Len(log.body.string) >= 256 + - set(log.cache, ExtractPatterns(log.cache["substr"], + "(?i)(?P<0>(alert|crit|emerg|fatal|error|err|warn|notice|debug|dbug|trace))")) + # Infer: detect FATAL + - set(log.severity_number, SEVERITY_NUMBER_FATAL) where + IsMatch(log.cache["0"], "(?i)(alert|crit|emerg|fatal)") + - set(log.severity_text, "fatal") where log.severity_number == + SEVERITY_NUMBER_FATAL + # Infer: detect ERROR + - set(log.severity_number, SEVERITY_NUMBER_ERROR) where + IsMatch(log.cache["0"], "(?i)(error|err)") + - set(log.severity_text, "error") where log.severity_number == + SEVERITY_NUMBER_ERROR + # Infer: detect WARN + - set(log.severity_number, SEVERITY_NUMBER_WARN) where + IsMatch(log.cache["0"], "(?i)(warn|notice)") + - set(log.severity_text, "warn") where log.severity_number == + SEVERITY_NUMBER_WARN + # Infer: detect DEBUG + - set(log.severity_number, SEVERITY_NUMBER_DEBUG) where + IsMatch(log.cache["0"], "(?i)(debug|dbug)") + - set(log.severity_text, "debug") where log.severity_number == + SEVERITY_NUMBER_DEBUG + # Infer: detect TRACE + - set(log.severity_number, SEVERITY_NUMBER_TRACE) where + IsMatch(log.cache["0"], "(?i)(trace)") + - set(log.severity_text, "trace") where log.severity_number == + SEVERITY_NUMBER_TRACE + # Infer: else + - set(log.severity_text, "info") where log.severity_number == 0 + - set(log.severity_number, SEVERITY_NUMBER_INFO) where log.severity_number == 0 + - context: log + error_mode: ignore + statements: + # Normalize the severity_text case + - set(log.severity_text, ConvertCase(log.severity_text, "lower")) + resourcedetection: + detectors: + - env + - system + - docker + timeout: 5s + override: false + batch: + memory_limiter: + # 80% of maximum memory up to 2G, adjust for low memory environments + limit_mib: 1500 + # 25% of limit up to 2G, adjust for low memory environments + spike_limit_mib: 512 + check_interval: 5s +connectors: + routing/logs: + default_pipelines: [logs/out-default] + error_mode: ignore + table: + - context: log + statement: route() where IsMatch(attributes["rr-web.event"], ".*") + pipelines: [logs/out-rrweb] +exporters: + debug: + verbosity: detailed + sampling_initial: 5 + sampling_thereafter: 200 + clickhouse/rrweb: + database: ${env:CLICKHOUSE_DATABASE} + endpoint: ${env:CLICKHOUSE_ENDPOINT} + password: ${env:CLICKHOUSE_PASSWORD} + username: ${env:CLICKHOUSE_USER} + ttl: 720h + logs_table_name: hyperdx_sessions + timeout: 5s + retry_on_failure: + enabled: true + initial_interval: 5s + max_interval: 30s + max_elapsed_time: 300s + clickhouse: + database: ${env:CLICKHOUSE_DATABASE} + endpoint: ${env:CLICKHOUSE_ENDPOINT} + password: ${env:CLICKHOUSE_PASSWORD} + username: ${env:CLICKHOUSE_USER} + ttl: 720h + timeout: 5s + retry_on_failure: + enabled: true + initial_interval: 5s + max_interval: 30s + max_elapsed_time: 300s +extensions: + health_check: + endpoint: :13133 +service: + pipelines: + traces: + receivers: [otlp/hyperdx] + processors: [memory_limiter, batch] + exporters: [clickhouse] + metrics: + receivers: [otlp/hyperdx] + processors: [memory_limiter, batch] + exporters: [clickhouse] + logs/in: + receivers: [otlp/hyperdx] + exporters: [routing/logs] + logs/out-default: + receivers: [routing/logs] + processors: [memory_limiter, transform, batch] + exporters: [clickhouse] + logs/out-rrweb: + receivers: [routing/logs] + processors: [memory_limiter, batch] + exporters: [clickhouse/rrweb] diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/all-in-one.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/all-in-one.md index a6b047e304b..e841c56a9bc 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/all-in-one.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/all-in-one.md @@ -4,26 +4,28 @@ 'pagination_prev': null 'pagination_next': null 'sidebar_position': 0 -'description': '使用一体化部署 ClickStack - ClickHouse 观察性堆栈' +'description': '使用 All In One 部署 ClickStack - ClickHouse 观察性堆栈' +'doc_type': 'guide' --- +import JSONSupport from '@site/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/_snippets/_json_support.md'; import Image from '@theme/IdealImage'; import hyperdx_login from '@site/static/images/use-cases/observability/hyperdx-login.png'; import hyperdx_logs from '@site/static/images/use-cases/observability/hyperdx-logs.png'; -这个综合的 Docker 镜像捆绑了所有 ClickStack 组件: +这个综合的 Docker 镜像包含所有 ClickStack 组件: * **ClickHouse** * **HyperDX** * **OpenTelemetry (OTel) 收集器**(在端口 `4317` 和 `4318` 上暴露 OTLP) * **MongoDB**(用于持久化应用状态) -此选项包含身份验证,允许在会话和用户之间持久保存仪表板、警报和保存的搜索。 +此选项包括身份验证,使仪表板、警报和保存的查询在会话和用户之间保持一致。 -### 适用场景 {#suitable-for} +### 适合的场景 {#suitable-for} * 演示 -* 全栈的本地测试 +* 完整堆栈的本地测试 ## 部署步骤 {#deployment-steps}
@@ -32,35 +34,35 @@ import hyperdx_logs from '@site/static/images/use-cases/observability/hyperdx-lo ### 使用 Docker 部署 {#deploy-with-docker} -以下命令将运行一个 OpenTelemetry 收集器(在端口 4317 和 4318 上)和 HyperDX 界面(在端口 8080 上)。 +下面的命令将运行一个 OpenTelemetry 收集器(在端口 4317 和 4318 上)和 HyperDX 用户界面(在端口 8080 上)。 -```bash +```shell docker run -p 8080:8080 -p 4317:4317 -p 4318:4318 docker.hyperdx.io/hyperdx/hyperdx-all-in-one ``` -### 访问 HyperDX 界面 {#navigate-to-hyperdx-ui} +### 访问 HyperDX 用户界面 {#navigate-to-hyperdx-ui} -访问 [http://localhost:8080](http://localhost:8080) 以访问 HyperDX 界面。 +访问 [http://localhost:8080](http://localhost:8080) 来访问 HyperDX 用户界面。 创建一个用户,提供符合要求的用户名和密码。 -点击 `Create` 后,将为集成的 ClickHouse 实例创建数据源。 +单击 `Create` 后,将为集成的 ClickHouse 实例创建数据源。 -有关使用替代 ClickHouse 实例的示例,请参见 ["创建 ClickHouse Cloud 连接"](/use-cases/observability/clickstack/getting-started#create-a-cloud-connection)。 +有关使用替代 ClickHouse 实例的示例,请参见 [“创建 ClickHouse Cloud 连接”](/use-cases/observability/clickstack/getting-started#create-a-cloud-connection)。 ### 数据摄取 {#ingest-data} -要摄取数据,请参见 ["数据摄取"](/use-cases/observability/clickstack/ingesting-data)。 +要摄取数据,请参见 [“数据摄取”](/use-cases/observability/clickstack/ingesting-data)。 ## 持久化数据和设置 {#persisting-data-and-settings} -为了在容器重启之间持久保存数据和设置,用户可以修改上述 docker 命令以挂载路径 `/data/db`、`/var/lib/clickhouse` 和 `/var/log/clickhouse-server`。例如: +为了在容器重启之间持久化数据和设置,用户可以修改上述 Docker 命令以挂载路径 `/data/db`、`/var/lib/clickhouse` 和 `/var/log/clickhouse-server`。例如: -```bash +```shell # ensure directories exist mkdir -p .volumes/db .volumes/ch_data .volumes/ch_logs @@ -78,28 +80,28 @@ docker run \ ## 部署到生产环境 {#deploying-to-production} -由于以下原因,此选项不应部署到生产环境: +此选项不应部署到生产环境,原因如下: -- **无持久存储:** 所有数据都使用 Docker 原生的覆盖文件系统存储。该设置不支持大规模的性能,如果容器被移除或重启,数据将丢失——除非用户 [挂载所需的文件路径](#persisting-data-and-settings)。 -- **缺乏组件隔离:** 所有组件在一个 Docker 容器内运行。这阻止了独立的扩展和监控,并对所有进程全局应用任何 `cgroup` 限制。因此,组件可能会争夺 CPU 和内存。 +- **非持久性存储:**所有数据使用 Docker 本地的覆盖文件系统存储。此设置不支持大规模性能,如果删除或重启容器,将会丢失数据——除非用户 [挂载所需文件路径](#persisting-data-and-settings)。 +- **缺乏组件隔离:**所有组件在单个 Docker 容器中运行。这阻止了独立扩展和监视,并将任何 `cgroup` 限制全局应用于所有进程。因此,组件可能会争夺 CPU 和内存。 ## 自定义端口 {#customizing-ports-deploy} -如果需要自定义 HyperDX 本地运行的应用(8080)或 API(8000)端口,则需要修改 `docker run` 命令以转发适当的端口并设置一些环境变量。 +如果您需要自定义 HyperDX 本地运行的应用程序(8080)或 API(8000)端口,您需要修改 `docker run` 命令以转发相应的端口并设置几个环境变量。 -自定义 OpenTelemetry 端口可以通过修改端口转发标志简单更改。例如,将 `-p 4318:4318` 替换为 `-p 4999:4318` 以将 OpenTelemetry HTTP 端口更改为 4999。 +自定义 OpenTelemetry 端口可以通过修改端口转发标志轻松更改。例如,将 `-p 4318:4318` 替换为 `-p 4999:4318` 将 OpenTelemetry HTTP 端口更改为 4999。 -```bash +```shell docker run -p 8080:8080 -p 4317:4317 -p 4999:4318 docker.hyperdx.io/hyperdx/hyperdx-all-in-one ``` ## 使用 ClickHouse Cloud {#using-clickhouse-cloud} -此发行版可与 ClickHouse Cloud 一起使用。虽然本地的 ClickHouse 实例仍将被部署(并被忽略),但 OTel 收集器可以通过设置环境变量 `CLICKHOUSE_ENDPOINT`、`CLICKHOUSE_USER` 和 `CLICKHOUSE_PASSWORD` 来配置为使用 ClickHouse Cloud 实例。 +此发行版可以与 ClickHouse Cloud 一起使用。虽然仍将部署本地的 ClickHouse 实例(并被忽略),但 OTel 收集器可以通过设置环境变量 `CLICKHOUSE_ENDPOINT`、`CLICKHOUSE_USER` 和 `CLICKHOUSE_PASSWORD` 来配置使用 ClickHouse Cloud 实例。 例如: -```bash +```shell export CLICKHOUSE_ENDPOINT= export CLICKHOUSE_USER= export CLICKHOUSE_PASSWORD= @@ -107,10 +109,18 @@ export CLICKHOUSE_PASSWORD= docker run -e CLICKHOUSE_ENDPOINT=${CLICKHOUSE_ENDPOINT} -e CLICKHOUSE_USER=default -e CLICKHOUSE_PASSWORD=${CLICKHOUSE_PASSWORD} -p 8080:8080 -p 4317:4317 -p 4318:4318 docker.hyperdx.io/hyperdx/hyperdx-all-in-one ``` -`CLICKHOUSE_ENDPOINT` 应为 ClickHouse Cloud 的 HTTPS 端点,包括端口 `8443`,例如 `https://mxl4k3ul6a.us-east-2.aws.clickhouse.com:8443` +`CLICKHOUSE_ENDPOINT` 应为 ClickHouse Cloud HTTPS 端点,包括端口 `8443`,例如 `https://mxl4k3ul6a.us-east-2.aws.clickhouse.com:8443` -连接到 HyperDX 界面后,导航至 [`Team Settings`](http://localhost:8080/team) 并创建与您的 ClickHouse Cloud 服务的连接——然后是所需的来源。有关示例流程,请参见 [此处](/use-cases/observability/clickstack/getting-started#create-a-cloud-connection)。 +连接到 HyperDX 用户界面后,访问 [`Team Settings`](http://localhost:8080/team),并创建到您的 ClickHouse Cloud 服务的连接,随后添加所需的数据源。有关示例流程,请参见 [这里](/use-cases/observability/clickstack/getting-started#create-a-cloud-connection)。 ## 配置 OpenTelemetry 收集器 {#configuring-collector} -如果需要,可以修改 OTel 收集器配置——请参见 ["修改配置"](/use-cases/observability/clickstack/ingesting-data/otel-collector#modifying-otel-collector-configuration)。 +如有需要,可以修改 OTel 收集器配置 - 请参见 [“修改配置”](/use-cases/observability/clickstack/ingesting-data/otel-collector#modifying-otel-collector-configuration)。 + + + +例如: + +```shell +docker run -e OTEL_AGENT_FEATURE_GATE_ARG='--feature-gates=clickhouse.json' -e BETA_CH_OTEL_JSON_SCHEMA_ENABLED=true -p 8080:8080 -p 4317:4317 -p 4318:4318 docker.hyperdx.io/hyperdx/hyperdx-all-in-one +``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/all-in-one.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/all-in-one.md.hash index 2c39236d8e2..be7d03cee83 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/all-in-one.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/all-in-one.md.hash @@ -1 +1 @@ -3baa0438ed46227f +44c06a57e7d42607 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/docker-compose.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/docker-compose.md index 5f861f7ae37..7a0120b48a9 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/docker-compose.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/docker-compose.md @@ -3,50 +3,52 @@ 'title': 'Docker Compose' 'pagination_prev': null 'pagination_next': null -'sidebar_position': 2 -'description': '使用 Docker Compose 部署 ClickStack - ClickHouse 观察能力栈' +'sidebar_position': 3 +'description': '使用 Docker Compose 部署 ClickStack - ClickHouse 观察栈' +'doc_type': 'guide' --- import Image from '@theme/IdealImage'; import hyperdx_login from '@site/static/images/use-cases/observability/hyperdx-login.png'; import hyperdx_logs from '@site/static/images/use-cases/observability/hyperdx-logs.png'; +import JSONSupport from '@site/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/_snippets/_json_support.md'; -所有 ClickStack 组件作为单独的 Docker 镜像分发: +所有 ClickStack 组件均作为单独的 Docker 镜像分发: * **ClickHouse** * **HyperDX** * **OpenTelemetry (OTel) collector** * **MongoDB** -这些镜像可以结合使用 Docker Compose 在本地部署。 +这些镜像可以使用 Docker Compose 组合并本地部署。 -Docker Compose 根据默认的 `otel-collector` 设置暴露了额外的端口,用于可观察性和数据摄取: +Docker Compose 根据默认的 `otel-collector` 设置暴露额外的端口用于可观察性和数据接收: -- `13133`:用于 `health_check` 扩展的健康检查端点 -- `24225`:用于日志摄取的 Fluentd 接收端 -- `4317`:OTLP gRPC 接收端(标准用于跟踪、日志和指标) -- `4318`:OTLP HTTP 接收端(gRPC 的替代方案) -- `8888`:用于监控收集器本身的 Prometheus 指标端点 +- `13133`: `health_check` 扩展的健康检查端点 +- `24225`: 用于日志接收的 Fluentd 接收器 +- `4317`: OTLP gRPC 接收器(用于跟踪、日志和指标的标准) +- `4318`: OTLP HTTP 接收器(gRPC 的替代方案) +- `8888`: 用于监控收集器自身的 Prometheus 指标端点 -这些端口使得可以与各种遥测源集成,并使 OpenTelemetry collector 适用于多样化的数据摄取需求。 +这些端口可以与各种遥测源集成,并使 OpenTelemetry collector 满足多样的数据接收需求,从而具备生产就绪的能力。 -### 适用于 {#suitable-for} +### 适用场景 {#suitable-for} * 本地测试 * 概念验证 -* 生产部署时不需要故障容错且单台服务器足以托管所有 ClickHouse 数据 -* 当部署 ClickStack 但单独托管 ClickHouse 时,例如使用 ClickHouse Cloud。 +* 生产部署,不要求容错,单台服务器即可托管所有 ClickHouse 数据 +* 部署 ClickStack,但单独托管 ClickHouse,例如使用 ClickHouse Cloud。 ## 部署步骤 {#deployment-steps}
-### 克隆仓库 {#clone-the-repo} +### 克隆 Repo {#clone-the-repo} -要通过 Docker Compose 部署,克隆 HyperDX 仓库,进入目录并运行 `docker-compose up`: +要使用 Docker Compose 部署,请克隆 HyperDX repo,切换到该目录并运行 `docker-compose up`: -```bash +```shell git clone git@github.com:hyperdxio/hyperdx.git cd hyperdx @@ -57,11 +59,11 @@ docker compose up ### 访问 HyperDX UI {#navigate-to-hyperdx-ui} -访问 [http://localhost:8080](http://localhost:8080) 以访问 HyperDX UI。 +访问 [http://localhost:8080](http://localhost:8080) 来访问 HyperDX UI。 -创建一个用户,提供符合要求的用户名和密码。 +创建用户,提供符合要求的用户名和密码。 -单击 `Create` 后,将为使用 Helm 图表部署的 ClickHouse 实例创建数据源。 +单击 `Create` 后,将为通过 Helm chart 部署的 ClickHouse 实例创建数据源。 :::note 覆盖默认连接 您可以覆盖与集成的 ClickHouse 实例的默认连接。有关详细信息,请参见 ["使用 ClickHouse Cloud"](#using-clickhouse-cloud)。 @@ -75,9 +77,9 @@ docker compose up 要连接到已部署的 ClickHouse 实例,只需单击 **Create** 并接受默认设置。 -如果您更喜欢连接到自己的 **外部 ClickHouse 集群**,例如 ClickHouse Cloud,您可以手动输入连接凭据。 +如果您希望连接到自己的 **外部 ClickHouse 集群**,例如 ClickHouse Cloud,可以手动输入连接凭据。 -如果系统提示您创建源,请保留所有默认值,并在 `Table` 字段中填写 `otel_logs`。所有其他设置应自动检测,您可以单击 `Save New Source`。 +如果提示您创建数据源,请保留所有默认值,并将 `Table` 字段填入值 `otel_logs`。所有其他设置应自动检测,允许您单击 `Save New Source`。 @@ -87,7 +89,7 @@ docker compose up 用户可以通过环境变量文件修改堆栈的设置,例如使用的版本: -```bash +```shell user@example-host hyperdx % cat .env # Used by docker-compose.yml @@ -122,16 +124,16 @@ HYPERDX_OTEL_EXPORTER_CLICKHOUSE_DATABASE=default ### 配置 OpenTelemetry collector {#configuring-collector} -如果需要,可以修改 OTel 收集器的配置 - 请参阅 ["修改配置"](/use-cases/observability/clickstack/ingesting-data/otel-collector#modifying-otel-collector-configuration)。 +如果需要,可以修改 OTel collector 配置 - 请参见 ["修改配置"](/use-cases/observability/clickstack/ingesting-data/otel-collector#modifying-otel-collector-configuration)。 ## 使用 ClickHouse Cloud {#using-clickhouse-cloud} -此发行版可与 ClickHouse Cloud 一起使用。用户应: +此发行版可以与 ClickHouse Cloud 一起使用。用户应: -- 从 [`docker-compose.yaml`](https://github.com/hyperdxio/hyperdx/blob/86465a20270b895320eb21dca13560b65be31e68/docker-compose.yml#L89) 文件中删除 ClickHouse 服务。如果进行测试,这是可选的,因为已部署的 ClickHouse 实例将被简单忽略 - 尽管会浪费本地资源。如果删除服务,请确保删除对该服务的 [任何引用](https://github.com/hyperdxio/hyperdx/blob/86465a20270b895320eb21dca13560b65be31e68/docker-compose.yml#L65),例如 `depends_on`。 -- 修改 OTel 收集器以使用 ClickHouse Cloud 实例,方法是在 compose 文件中设置环境变量 `CLICKHOUSE_ENDPOINT`、`CLICKHOUSE_USER` 和 `CLICKHOUSE_PASSWORD`。具体来说,将环境变量添加到 OTel 收集器服务: +- 从 `docker-compose.yaml` 文件中删除 ClickHouse 服务。如果进行测试,这一操作是可选的,因为所部署的 ClickHouse 实例将被简单忽略——尽管会浪费本地资源。如果删除服务,请确保移除任何对该服务的引用,如 `depends_on`。 +- 修改 OTel collector,以通过在 compose 文件中设置环境变量 `CLICKHOUSE_ENDPOINT`、`CLICKHOUSE_USER` 和 `CLICKHOUSE_PASSWORD` 来使用 ClickHouse Cloud 实例。具体而言,将环境变量添加到 OTel collector 服务: -```bash +```shell otel-collector: image: ${OTEL_COLLECTOR_IMAGE_NAME}:${IMAGE_VERSION} environment: @@ -152,6 +154,31 @@ otel-collector: - internal ``` - `CLICKHOUSE_ENDPOINT` 应为 ClickHouse Cloud 的 HTTPS 端点,包括端口 `8443`,例如 `https://mxl4k3ul6a.us-east-2.aws.clickhouse.com:8443` + `CLICKHOUSE_ENDPOINT` 应该是 ClickHouse Cloud HTTPS 端点,包括端口 `8443`,例如 `https://mxl4k3ul6a.us-east-2.aws.clickhouse.com:8443` -- 在连接到 HyperDX UI 并创建与 ClickHouse 的连接时,请使用您在 Cloud 的凭据。 +- 连接到 HyperDX UI 并创建与 ClickHouse 的连接时,使用您的 Cloud 凭据。 + + + +要设置这些,请修改 `docker-compose.yaml` 中相关服务: + +```yaml +app: + image: ${HDX_IMAGE_REPO}/${IMAGE_NAME_DOCKERHUB}:${IMAGE_VERSION} + ports: + - ${HYPERDX_API_PORT}:${HYPERDX_API_PORT} + - ${HYPERDX_APP_PORT}:${HYPERDX_APP_PORT} + environment: + BETA_CH_OTEL_JSON_SCHEMA_ENABLED: true # enable JSON + FRONTEND_URL: ${HYPERDX_APP_URL}:${HYPERDX_APP_PORT} + HYPERDX_API_KEY: ${HYPERDX_API_KEY} + HYPERDX_API_PORT: ${HYPERDX_API_PORT} + # truncated for brevity + +otel-collector: + image: ${HDX_IMAGE_REPO}/${OTEL_COLLECTOR_IMAGE_NAME_DOCKERHUB}:${IMAGE_VERSION} + environment: + OTEL_AGENT_FEATURE_GATE_ARG: '--feature-gates=clickhouse.json' # enable JSON + CLICKHOUSE_ENDPOINT: 'tcp://ch-server:9000?dial_timeout=10s' + # truncated for brevity +``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/docker-compose.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/docker-compose.md.hash index 4a7199ae376..036bd65706f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/docker-compose.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/docker-compose.md.hash @@ -1 +1 @@ -be596ca863a61b71 +06164e01cdc1b39a diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/helm.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/helm.md index f153ce8ea45..eeececca743 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/helm.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/helm.md @@ -3,116 +3,117 @@ 'title': 'Helm' 'pagination_prev': null 'pagination_next': null -'sidebar_position': 1 -'description': '使用 Helm 部署 ClickStack - ClickHouse 监控堆栈' +'sidebar_position': 2 +'description': '使用 Helm 部署 ClickStack - ClickHouse 观察堆栈' +'doc_type': 'guide' --- import Image from '@theme/IdealImage'; import hyperdx_24 from '@site/static/images/use-cases/observability/hyperdx-24.png'; import hyperdx_login from '@site/static/images/use-cases/observability/hyperdx-login.png'; +import JSONSupport from '@site/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/_snippets/_json_support.md'; -The helm chart for HyperDX can be found [here](https://github.com/hyperdxio/helm-charts) and is the **recommended** method for production deployments. +可以在 [这里](https://github.com/hyperdxio/helm-charts) 找到 HyperDX 的 Helm chart,这是用于生产部署的**推荐**方法。 -By default, the Helm chart provisions all core components, including: +默认情况下,Helm chart 将配置所有核心组件,包括: -***ClickHouse** -***HyperDX** -***OpenTelemetry (OTel) collector** -***MongoDB** (for persistent application state) +* **ClickHouse** +* **HyperDX** +* **OpenTelemetry (OTel) 收集器** +* **MongoDB**(用于持久化应用状态) -However, it can be easily customized to integrate with an existing ClickHouse deployment - for example, one hosted in **ClickHouse Cloud**. +然而,它可以轻松自定义以与现有的 ClickHouse 部署集成,例如,托管在 **ClickHouse Cloud** 中的实例。 -The chart supports standard Kubernetes best practices, including: +该 chart 支持标准的 Kubernetes 最佳实践,包括: -- Environment-specific configuration via `values.yaml` -- Resource limits and pod-level scaling -- TLS and ingress configuration -- Secrets management and authentication setup +- 通过 `values.yaml` 进行特定环境的配置 +- 资源限制和 pod 级别扩展 +- TLS 和入口配置 +- 秘密管理和身份验证设置 -### Suitable for {#suitable-for} +### 适合 {#suitable-for} -* Proof of concepts -* Production +* 概念验证 +* 生产 -## Deployment steps {#deployment-steps} +## 部署步骤 {#deployment-steps}
-### Prerequisites {#prerequisites} +### 先决条件 {#prerequisites} - [Helm](https://helm.sh/) v3+ -- Kubernetes 集群 (推荐 v1.20+) -- `kubectl` 配置以与您的集群进行交互 +- Kubernetes 集群(建议 v1.20+) +- 配置好的 `kubectl` 用于与您的集群互动 -### Add the HyperDX Helm Repository {#add-the-hyperdx-helm-repository} +### 添加 HyperDX Helm 仓库 {#add-the-hyperdx-helm-repository} -Add the HyperDX Helm repository: +添加 HyperDX Helm 仓库: -```sh +```shell helm repo add hyperdx https://hyperdxio.github.io/helm-charts helm repo update ``` -### Installing HyperDX {#installing-hyperdx} +### 安装 HyperDX {#installing-hyperdx} -To install the HyperDX chart with default values: +要使用默认值安装 HyperDX chart,请执行: -```sh +```shell helm install my-hyperdx hyperdx/hdx-oss-v2 ``` -### Verify the installation {#verify-the-installation} +### 验证安装 {#verify-the-installation} -Verify the installation: +验证安装: -```bash +```shell kubectl get pods -l "app.kubernetes.io/name=hdx-oss-v2" ``` -When all pods are ready, proceed. +当所有 pods 就绪后,继续。 -### Forward ports {#forward-ports} +### 转发端口 {#forward-ports} -Port forwarding allows us to access and set up HyperDX. Users deploying to production should instead expose the service via an ingress or load balancer to ensure proper network access, TLS termination, and scalability. Port forwarding is best suited for local development or one-off administrative tasks, not long-term or high-availability environments. +端口转发允许我们访问和设置 HyperDX。部署到生产的用户应该通过入口或负载均衡器公开服务,以确保适当的网络访问、TLS 终止和可扩展性。端口转发最适合本地开发或一次性管理任务,而不适合长期或高可用性环境。 -```bash +```shell kubectl port-forward \ pod/$(kubectl get pod -l app.kubernetes.io/name=hdx-oss-v2 -o jsonpath='{.items[0].metadata.name}') \ 8080:3000 ``` -### Navigate to the UI {#navigate-to-the-ui} +### 导航到 UI {#navigate-to-the-ui} -Visit [http://localhost:8080](http://localhost:8080) to access the HyperDX UI. +访问 [http://localhost:8080](http://localhost:8080) 以访问 HyperDX UI。 -Create a user, providing a username and password which meets the requirements. +创建一个用户,提供符合要求的用户名和密码。 +点击 `Create` 时,将为通过 Helm chart 部署的 ClickHouse 实例创建数据源。 -On clicking `Create`, data sources will be created for the ClickHouse instance deployed with the Helm chart. - -:::note Overriding default connection -You can override the default connection to the integrated ClickHouse instance. For details, see ["Using ClickHouse Cloud"](#using-clickhouse-cloud). +:::note 覆盖默认连接 +您可以覆盖与集成的 ClickHouse 实例的默认连接。详细信息请参阅 ["使用 ClickHouse Cloud"](#using-clickhouse-cloud)。 ::: -For an example of using an alternative ClickHouse instance, see ["Create a ClickHouse Cloud connection"](/use-cases/observability/clickstack/getting-started#create-a-cloud-connection). +有关使用替代 ClickHouse 实例的示例,请参见 ["创建 ClickHouse Cloud 连接"](/use-cases/observability/clickstack/getting-started#create-a-cloud-connection)。 -### Customizing values (Optional) {#customizing-values} +### 自定义值(可选) {#customizing-values} -You can customize settings by using `--set` flags. For example: +您可以使用 `--set` 标志自定义设置。例如: -```bash +```shell helm install my-hyperdx hyperdx/hdx-oss-v2 --set key=value Alternatively, edit the `values.yaml`. To retrieve the default values: -```sh +```shell helm show values hyperdx/hdx-oss-v2 > values.yaml ``` -Example config: +示例配置: ```yaml replicaCount: 2 @@ -134,20 +135,19 @@ ingress: pathType: ImplementationSpecific ``` -```bash +```shell helm install my-hyperdx hyperdx/hdx-oss-v2 -f values.yaml ``` -### Using Secrets (Optional) {#using-secrets} - -For handling sensitive data such as API keys or database credentials, use Kubernetes secrets. The HyperDX Helm charts provide default secret files that you can modify and apply to your cluster. +### 使用秘密(可选) {#using-secrets} -#### Using Pre-Configured Secrets {#using-pre-configured-secrets} +对于处理敏感数据(例如 API 密钥或数据库凭据),请使用 Kubernetes secrets。HyperDX Helm charts 提供默认的秘密文件,您可以修改并应用到您的集群。 -The Helm chart includes a default secret template located at [`charts/hdx-oss-v2/templates/secrets.yaml`](https://github.com/hyperdxio/helm-charts/blob/main/charts/hdx-oss-v2/templates/secrets.yaml). This file provides a base structure for managing secrets. +#### 使用预配置的秘密 {#using-pre-configured-secrets} +Helm chart 包含一个位于 [`charts/hdx-oss-v2/templates/secrets.yaml`](https://github.com/hyperdxio/helm-charts/blob/main/charts/hdx-oss-v2/templates/secrets.yaml) 的默认秘密模板。该文件提供管理秘密的基本结构。 -If you need to manually apply a secret, modify and apply the provided `secrets.yaml` template: +如果您需要手动应用一个秘密,请修改并应用提供的 `secrets.yaml` 模板: ```yaml apiVersion: v1 @@ -161,24 +161,24 @@ data: API_KEY: ``` -Apply the secret to your cluster: +将秘密应用到您的集群: -```sh +```shell kubectl apply -f secrets.yaml ``` -#### Creating a Custom Secret {#creating-a-custom-secret} +#### 创建自定义秘密 {#creating-a-custom-secret} -If you prefer, you can create a custom Kubernetes secret manually: +如果更喜欢,您可以手动创建一个自定义的 Kubernetes 秘密: -```sh +```shell kubectl create secret generic hyperdx-secret \ --from-literal=API_KEY=my-secret-api-key ``` -#### Referencing a Secret {#referencing-a-secret} +#### 引用秘密 {#referencing-a-secret} -To reference a secret in `values.yaml`: +要在 `values.yaml` 中引用一个秘密: ```yaml hyperdx: @@ -191,11 +191,11 @@ hyperdx: -## Using ClickHouse Cloud {#using-clickhouse-cloud} +## 使用 ClickHouse Cloud {#using-clickhouse-cloud} -If using ClickHouse Cloud, users disable the ClickHouse instance deployed by the Helm chart and specify the Cloud 凭据: +如果使用 ClickHouse Cloud 用户禁用通过 Helm chart 部署的 ClickHouse 实例并指定 Cloud 凭据: -```bash +```shell # specify ClickHouse Cloud credentials export CLICKHOUSE_URL= # full https url @@ -207,7 +207,7 @@ export CLICKHOUSE_PASSWORD= helm install myrelease hyperdx-helm --set clickhouse.enabled=false --set clickhouse.persistence.enabled=false --set otel.clickhouseEndpoint=${CLICKHOUSE_URL} --set clickhouse.config.users.otelUser=${CLICKHOUSE_USER} --set clickhouse.config.users.otelUserPassword=${CLICKHOUSE_PASSWORD} ``` -Alternatively, use a `values.yaml` file: +或者,使用 `values.yaml` 文件: ```yaml clickhouse: @@ -221,9 +221,21 @@ clickhouse: otel: clickhouseEndpoint: ${CLICKHOUSE_URL} + +hyperdx: + defaultConnections: | + [ + { + "name": "External ClickHouse", + "host": "http://your-clickhouse-server:8123", + "port": 8123, + "username": "your-username", + "password": "your-password" + } + ] ``` -```bash +```shell helm install my-hyperdx hyperdx/hdx-oss-v2 -f values.yaml # or if installed... @@ -231,67 +243,95 @@ helm install my-hyperdx hyperdx/hdx-oss-v2 -f values.yaml # helm upgrade my-hyperdx hyperdx/hdx-oss-v2 -f values.yaml ``` +## 生产注意事项 {#production-notes} -## Production notes {#production-notes} - -By default, this chart also installs ClickHouse and the OTel collector. However, for production, it is recommended that you manage ClickHouse and the OTel collector separately. +默认情况下,该 chart 还会安装 ClickHouse 和 OTel 收集器。然而,对于生产而言,建议您单独管理 ClickHouse 和 OTel 收集器。 -To disable ClickHouse and the OTel collector, set the following values: +要禁用 ClickHouse 和 OTel 收集器,请设置以下值: -```bash +```shell helm install myrelease hyperdx-helm --set clickhouse.enabled=false --set clickhouse.persistence.enabled=false --set otel.enabled=false ``` -## Task Configuration {#task-configuration} +## 任务配置 {#task-configuration} -By default, there is one task in the chart setup as a cronjob, responsible for checking whether alerts should fire. Here are its configuration options: +默认情况下,chart 设置中有一个作为 cronjob 的任务,负责检查是否应该触发警报。以下是其配置选项: -| Parameter | Description | Default | +| 参数 | 描述 | 默认值 | |-----------|-------------|---------| -| `tasks.enabled` | Enable/Disable cron tasks in the cluster. By default, the HyperDX image will run cron tasks in the process. Change to true if you'd rather use a separate cron task in the cluster. | `false` | -| `tasks.checkAlerts.schedule` | Cron schedule for the check-alerts task | `*/1 * * * *` | -| `tasks.checkAlerts.resources` | Resource requests and limits for the check-alerts task | See `values.yaml` | +| `tasks.enabled` | 启用/禁用集群中的 cron 任务。默认情况下,HyperDX 镜像将在进程中运行 cron 任务。如果您更愿意在集群中使用单独的 cron 任务,请更改为 true。 | `false` | +| `tasks.checkAlerts.schedule` | check-alerts 任务的 cron 调度 | `*/1 * * * *` | +| `tasks.checkAlerts.resources` | check-alerts 任务的资源请求和限制 | 见 `values.yaml` | -## Upgrading the Chart {#upgrading-the-chart} +## 升级 chart {#upgrading-the-chart} -To upgrade to a newer version: +要升级到较新版本: -```sh +```shell helm upgrade my-hyperdx hyperdx/hdx-oss-v2 -f values.yaml ``` -To check available chart versions: +要检查可用的 chart 版本: -```sh +```shell helm search repo hyperdx ``` -## Uninstalling HyperDX {#uninstalling-hyperdx} +## 卸载 HyperDX {#uninstalling-hyperdx} -To remove the deployment: +要删除部署: -```sh +```shell helm uninstall my-hyperdx ``` -This will remove all resources associated with the release, but persistent data (if any) may remain. +这将删除与发布相关的所有资源,但持久数据(如果有)可能会保留。 -## Troubleshooting {#troubleshooting} +## 故障排除 {#troubleshooting} -### Checking Logs {#checking-logs} +### 检查日志 {#checking-logs} -```sh +```shell kubectl logs -l app.kubernetes.io/name=hdx-oss-v2 ``` -### Debugging a Failed Install {#debugging-a-failed-instance} +### 调试失败的安装 {#debugging-a-failed-instance} -```sh +```shell helm install my-hyperdx hyperdx/hdx-oss-v2 --debug --dry-run ``` -### Verifying Deployment {#verifying-deployment} +### 验证部署 {#verifying-deployment} -```sh +```shell kubectl get pods -l app.kubernetes.io/name=hdx-oss-v2 ``` + + + +用户可以通过参数或 `values.yaml` 设置这些环境变量,例如: + +*values.yaml* + +```yaml +hyperdx: + ... + env: + - name: BETA_CH_OTEL_JSON_SCHEMA_ENABLED + value: "true" + +otel: + ... + env: + - name: OTEL_AGENT_FEATURE_GATE_ARG + value: "--feature-gates=clickhouse.json" +``` + +或通过 `--set`: + +```shell +helm install myrelease hyperdx-helm --set "hyperdx.env[0].name=BETA_CH_OTEL_JSON_SCHEMA_ENABLED" \ + --set "hyperdx.env[0].value=true" \ + --set "otel.env[0].name=OTEL_AGENT_FEATURE_GATE_ARG" \ + --set "otel.env[0].value=--feature-gates=clickhouse.json" +``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/helm.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/helm.md.hash index fb815a56acc..0cd11265465 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/helm.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/helm.md.hash @@ -1 +1 @@ -42a911c8dd3cf405 +cd038b74afd1842c diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/hyperdx-clickhouse-cloud.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/hyperdx-clickhouse-cloud.md new file mode 100644 index 00000000000..5d4dcd478f0 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/hyperdx-clickhouse-cloud.md @@ -0,0 +1,336 @@ +--- +'slug': '/use-cases/observability/clickstack/deployment/hyperdx-clickhouse-cloud' +'title': 'ClickHouse Cloud' +'pagination_prev': null +'pagination_next': null +'sidebar_position': 1 +'description': '使用 ClickHouse Cloud 部署 ClickStack' +'doc_type': 'guide' +--- + +import Image from '@theme/IdealImage'; +import PrivatePreviewBadge from '@theme/badges/PrivatePreviewBadge'; +import BetaBadge from '@theme/badges/BetaBadge'; +import cloud_connect from '@site/static/images/use-cases/observability/clickhouse_cloud_connection.png'; +import hyperdx_cloud from '@site/static/images/use-cases/observability/hyperdx_cloud.png'; +import hyperdx_cloud_landing from '@site/static/images/use-cases/observability/hyperdx_cloud_landing.png'; +import hyperdx_cloud_datasource from '@site/static/images/use-cases/observability/hyperdx_cloud_datasource.png'; +import hyperdx_create_new_source from '@site/static/images/use-cases/observability/hyperdx_create_new_source.png'; +import hyperdx_create_trace_datasource from '@site/static/images/use-cases/observability/hyperdx_create_trace_datasource.png'; + + + +该选项旨在为使用 ClickHouse Cloud 的用户提供服务。在这种部署模式下,ClickHouse 和 HyperDX 都托管在 ClickHouse Cloud 中,从而减少用户自我托管的组件数量。 + +除了减少基础设施管理外,此部署模式还确保身份验证与 ClickHouse Cloud SSO/SAML 集成。与自托管部署不同,此模式无需配置 MongoDB 实例来存储应用程序状态,例如仪表板、已保存的搜索、用户设置和警报。 + +在此模式下,数据摄取完全由用户负责。您可以使用自己托管的 OpenTelemetry 收集器、客户端库的直接摄取、ClickHouse 原生表引擎(例如 Kafka 或 S3)、ETL 管道或 ClickPipes(ClickHouse Cloud 的托管摄取服务)将数据摄取到 ClickHouse Cloud。这种方法提供了操作 ClickStack 最简单且性能最佳的方式。 + +### 适用场景 {#suitable-for} + +该部署模式非常适合以下场景: + +1. 您已经在 ClickHouse Cloud 中拥有可观察性数据,并希望使用 HyperDX 对其进行可视化。 +2. 您运营着大型可观察性部署,需要 ClickStack 和 ClickHouse Cloud 提供的专用性能和可扩展性。 +3. 您已经在分析中使用 ClickHouse Cloud,希望通过 ClickStack 插件库为应用程序提供监控功能——将数据发送到同一集群。在这种情况下,我们建议使用 [warehouses](/cloud/reference/warehouses) 来隔离可观察性工作负载的计算。 + +## 部署步骤 {#deployment-steps} + +以下指南假设您已创建 ClickHouse Cloud 服务。如果您尚未创建任何服务,请按照我们的快速入门指南中的 ["创建 ClickHouse 服务"](/getting-started/quick-start/cloud#1-create-a-clickhouse-service) 步骤进行操作。 + + + +### 复制服务凭据(可选) {#copy-service-credentials} + +**如果您希望可视化已有的可观察性事件,则可以跳过此步骤。** + +导航到主要服务列表,选择您打算进行可视化的可观察性事件的服务。 + +从导航菜单中按 `Connect` 按钮。将打开一个模态窗口,提供您服务的凭据以及通过不同接口和语言进行连接的一组指令。从下拉菜单中选择 `HTTPS` 并记录连接端点和凭据。 + + + +### 部署 Open Telemetry 收集器(可选) {#deploy-otel-collector} + +**如果您希望可视化已有的可观察性事件,则可以跳过此步骤。** + +此步骤确保使用 Open Telemetry (OTel) 模式创建表,这样可以无缝地用于在 HyperDX 中创建数据源。它还提供了一个 OLTP 端点,可用于加载 [示例数据集](/use-cases/observability/clickstack/sample-datasets) 并将 OTel 事件发送至 ClickStack。 + +:::note 使用标准 Open Telemetry 收集器 +以下指令使用 OTel 收集器的标准发行版,而不是 ClickStack 发行版。后者需要 OpAMP 服务器进行配置。目前在私人预览中不支持此功能。以下配置复制了 ClickStack 收集器的发行版使用的版本,提供了一个 OTLP 端点,可以将事件发送到此端点。 +::: + +下载 OTel 收集器的配置: + +```bash +curl -O https://raw.githubusercontent.com/ClickHouse/clickhouse-docs/refs/heads/main/docs/use-cases/observability/clickstack/deployment/_snippets/otel-cloud-config.yaml +``` + +
+otel-cloud-config.yaml + +```yaml file=docs/use-cases/observability/clickstack/deployment/_snippets/otel-cloud-config.yaml +receivers: + otlp/hyperdx: + protocols: + grpc: + include_metadata: true + endpoint: '0.0.0.0:4317' + http: + cors: + allowed_origins: ['*'] + allowed_headers: ['*'] + include_metadata: true + endpoint: '0.0.0.0:4318' +processors: + transform: + log_statements: + - context: log + error_mode: ignore + statements: + # JSON parsing: Extends log attributes with the fields from structured log body content, either as an OTEL map or + # as a string containing JSON content. + - set(log.cache, ExtractPatterns(log.body, "(?P<0>(\\{.*\\}))")) where + IsString(log.body) + - merge_maps(log.attributes, ParseJSON(log.cache["0"]), "upsert") + where IsMap(log.cache) + - flatten(log.attributes) where IsMap(log.cache) + - merge_maps(log.attributes, log.body, "upsert") where IsMap(log.body) + - context: log + error_mode: ignore + conditions: + - severity_number == 0 and severity_text == "" + statements: + # Infer: extract the first log level keyword from the first 256 characters of the body + - set(log.cache["substr"], log.body.string) where Len(log.body.string) + < 256 + - set(log.cache["substr"], Substring(log.body.string, 0, 256)) where + Len(log.body.string) >= 256 + - set(log.cache, ExtractPatterns(log.cache["substr"], + "(?i)(?P<0>(alert|crit|emerg|fatal|error|err|warn|notice|debug|dbug|trace))")) + # Infer: detect FATAL + - set(log.severity_number, SEVERITY_NUMBER_FATAL) where + IsMatch(log.cache["0"], "(?i)(alert|crit|emerg|fatal)") + - set(log.severity_text, "fatal") where log.severity_number == + SEVERITY_NUMBER_FATAL + # Infer: detect ERROR + - set(log.severity_number, SEVERITY_NUMBER_ERROR) where + IsMatch(log.cache["0"], "(?i)(error|err)") + - set(log.severity_text, "error") where log.severity_number == + SEVERITY_NUMBER_ERROR + # Infer: detect WARN + - set(log.severity_number, SEVERITY_NUMBER_WARN) where + IsMatch(log.cache["0"], "(?i)(warn|notice)") + - set(log.severity_text, "warn") where log.severity_number == + SEVERITY_NUMBER_WARN + # Infer: detect DEBUG + - set(log.severity_number, SEVERITY_NUMBER_DEBUG) where + IsMatch(log.cache["0"], "(?i)(debug|dbug)") + - set(log.severity_text, "debug") where log.severity_number == + SEVERITY_NUMBER_DEBUG + # Infer: detect TRACE + - set(log.severity_number, SEVERITY_NUMBER_TRACE) where + IsMatch(log.cache["0"], "(?i)(trace)") + - set(log.severity_text, "trace") where log.severity_number == + SEVERITY_NUMBER_TRACE + # Infer: else + - set(log.severity_text, "info") where log.severity_number == 0 + - set(log.severity_number, SEVERITY_NUMBER_INFO) where log.severity_number == 0 + - context: log + error_mode: ignore + statements: + # Normalize the severity_text case + - set(log.severity_text, ConvertCase(log.severity_text, "lower")) + resourcedetection: + detectors: + - env + - system + - docker + timeout: 5s + override: false + batch: + memory_limiter: + # 80% of maximum memory up to 2G, adjust for low memory environments + limit_mib: 1500 + # 25% of limit up to 2G, adjust for low memory environments + spike_limit_mib: 512 + check_interval: 5s +connectors: + routing/logs: + default_pipelines: [logs/out-default] + error_mode: ignore + table: + - context: log + statement: route() where IsMatch(attributes["rr-web.event"], ".*") + pipelines: [logs/out-rrweb] +exporters: + debug: + verbosity: detailed + sampling_initial: 5 + sampling_thereafter: 200 + clickhouse/rrweb: + database: ${env:CLICKHOUSE_DATABASE} + endpoint: ${env:CLICKHOUSE_ENDPOINT} + password: ${env:CLICKHOUSE_PASSWORD} + username: ${env:CLICKHOUSE_USER} + ttl: 720h + logs_table_name: hyperdx_sessions + timeout: 5s + retry_on_failure: + enabled: true + initial_interval: 5s + max_interval: 30s + max_elapsed_time: 300s + clickhouse: + database: ${env:CLICKHOUSE_DATABASE} + endpoint: ${env:CLICKHOUSE_ENDPOINT} + password: ${env:CLICKHOUSE_PASSWORD} + username: ${env:CLICKHOUSE_USER} + ttl: 720h + timeout: 5s + retry_on_failure: + enabled: true + initial_interval: 5s + max_interval: 30s + max_elapsed_time: 300s +extensions: + health_check: + endpoint: :13133 +service: + pipelines: + traces: + receivers: [otlp/hyperdx] + processors: [memory_limiter, batch] + exporters: [clickhouse] + metrics: + receivers: [otlp/hyperdx] + processors: [memory_limiter, batch] + exporters: [clickhouse] + logs/in: + receivers: [otlp/hyperdx] + exporters: [routing/logs] + logs/out-default: + receivers: [routing/logs] + processors: [memory_limiter, transform, batch] + exporters: [clickhouse] + logs/out-rrweb: + receivers: [routing/logs] + processors: [memory_limiter, batch] + exporters: [clickhouse/rrweb] + +``` + +
+ +使用以下 Docker 命令部署收集器,将各环境变量设置为之前记录的连接设置,并根据您的操作系统使用适当的命令。 + +```bash + +# modify to your cloud endpoint +export CLICKHOUSE_ENDPOINT= +export CLICKHOUSE_PASSWORD= + +# optionally modify +export CLICKHOUSE_DATABASE=default + + +# osx +docker run --rm -it \ + -p 4317:4317 -p 4318:4318 \ + -e CLICKHOUSE_ENDPOINT=${CLICKHOUSE_ENDPOINT} \ + -e CLICKHOUSE_USER=default \ + -e CLICKHOUSE_PASSWORD=${CLICKHOUSE_PASSWORD} \ + -e CLICKHOUSE_DATABASE=${CLICKHOUSE_DATABASE} \ + --user 0:0 \ + -v "$(pwd)/otel-cloud-collector.yaml":/etc/otel/config.yaml \ + -v /var/log:/var/log:ro \ + -v /private/var/log:/private/var/log:ro \ + otel/opentelemetry-collector-contrib:latest \ + --config /etc/otel/config.yaml + + +# linux command + + +# docker run --network=host --rm -it \ + +# -e CLICKHOUSE_ENDPOINT=${CLICKHOUSE_ENDPOINT} \ + +# -e CLICKHOUSE_USER=default \ + +# -e CLICKHOUSE_PASSWORD=${CLICKHOUSE_PASSWORD} \ + +# -e CLICKHOUSE_DATABASE=${CLICKHOUSE_DATABASE} \ + +# --user 0:0 \ + +# -v "$(pwd)/otel-cloud-config.yaml":/etc/otel/config.yaml \ + +# -v /var/log:/var/log:ro \ + +# -v /private/var/log:/private/var/log:ro \ + +# otel/opentelemetry-collector-contrib:latest \ + +# --config /etc/otel/config.yaml +``` + +:::note +在生产环境中,我们建议为数据摄取创建一个专用用户,并限制访问数据库和表的权限。有关详细信息,请参见 ["数据库和摄取用户"](/use-cases/observability/clickstack/production#database-ingestion-user)。 +::: + +### 连接到 HyperDX {#connect-to-hyperdx} + +选择您的服务,然后从左侧菜单中选择 `HyperDX`。 + + + +您无需创建用户,将自动进行身份验证,然后提示您创建数据源。 + +对于仅希望探索 HyperDX 界面的用户,我们建议使用我们的 [示例数据集](/use-cases/observability/clickstack/sample-datasets),这些数据集使用 OTel 数据。 + + + +### 创建数据源 {#create-a-datasource} + +HyperDX 是 Open Telemetry 原生的,但并不是 Open Telemetry 专有的 - 用户可以根据需要使用自己的表模式。 + +#### 使用 Open Telemetry 模式 {#using-otel-schemas} + +如果您使用上述 OTel 收集器在 ClickHouse 内创建数据库和表,则保留创建源模型中的所有默认值,在 `Table` 字段中填写 `otel_logs` 以创建日志源。所有其他设置应自动检测,允许您单击 `Save New Source`。 + + + +要为跟踪和 OTel 指标创建源,用户可以从顶部菜单选择 `Create New Source`。 + + + +在此处,选择所需的源类型,然后选择适当的表,例如,对于跟踪,选择表 `otel_traces`。所有设置都应自动检测。 + + + +:::note 关联源 +请注意,ClickStack 中的不同数据源,例如日志和跟踪,可以相互关联。为了实现这一点,每个源都需要额外配置。例如,在日志源中,您可以指定相应的跟踪源,而在跟踪源中,则可以指定相应的日志源。有关详细信息,请参见 ["关联源"](/use-cases/observability/clickstack/config#correlated-sources)。 +::: + +#### 使用自定义模式 {#using-custom-schemas} + +希望将 HyperDX 连接到现有服务且拥有数据的用户可以根据需要完成数据库和表的设置。如果数据表符合 ClickHouse 的 Open Telemetry 模式,设置将被自动检测。 + +如果使用您自己的模式,我们建议创建日志源,并确保指定必需的字段 - 有关详细信息,请参见 ["日志源设置"](/use-cases/observability/clickstack/config#logs)。 + +
+ +## JSON 类型支持 {#json-type-support} + + + +ClickStack 从版本 `2.0.4` 开始支持 [JSON 类型](/interfaces/formats/JSON) 的测试版。 + +有关此类型的好处,请参见 [JSON 类型的好处](/use-cases/observability/clickstack/ingesting-data/otel-collector#benefits-json-type)。 + +为了启用对 JSON 类型的支持,用户必须设置以下环境变量: + +- `OTEL_AGENT_FEATURE_GATE_ARG='--feature-gates=clickhouse.json'` - 在 OTel 收集器中启用支持,确保使用 JSON 类型创建模式。 + +此外,用户应联系 support@clickhouse.com 确保其 ClickHouse Cloud 服务上启用了 JSON。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/hyperdx-clickhouse-cloud.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/hyperdx-clickhouse-cloud.md.hash new file mode 100644 index 00000000000..740cc122645 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/hyperdx-clickhouse-cloud.md.hash @@ -0,0 +1 @@ +e31ecd3b09de31cd diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/hyperdx-only.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/hyperdx-only.md index 09c23dc6d1c..f4a125094b2 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/hyperdx-only.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/hyperdx-only.md @@ -1,28 +1,30 @@ --- 'slug': '/use-cases/observability/clickstack/deployment/hyperdx-only' -'title': 'HyperDX 仅限' +'title': 'HyperDX 仅适用' 'pagination_prev': null 'pagination_next': null 'sidebar_position': 4 'description': '仅部署 HyperDX' +'doc_type': 'guide' --- import Image from '@theme/IdealImage'; import hyperdx_login from '@site/static/images/use-cases/observability/hyperdx-login.png'; import hyperdx_logs from '@site/static/images/use-cases/observability/hyperdx-logs.png'; import hyperdx_2 from '@site/static/images/use-cases/observability/hyperdx-2.png'; +import JSONSupport from '@site/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/_snippets/_json_support.md'; -这个选项是为已经运行的 ClickHouse 实例并填充了可观察性或事件数据的用户设计的。 +该选项旨在为已经运行的 ClickHouse 实例并填充了可观察性或事件数据的用户提供支持。 -HyperDX 可以独立于其余堆栈使用,并且与任何数据架构兼容 - 不仅仅是 OpenTelemetry (OTel)。这使得它适用于已经在 ClickHouse 上构建的自定义可观察性管道。 +HyperDX 可以独立于其他堆栈使用,并且与任何数据模式兼容 - 不仅限于 OpenTelemetry (OTel)。这使其适合已经在 ClickHouse 上构建的自定义可观察性管道。 -要启用完整功能,您必须提供一个 MongoDB 实例来存储应用程序状态,包括仪表板、保存的搜索、用户设置和警报。 +为启用完整功能,您必须提供一个 MongoDB 实例用于存储应用程序状态,包括仪表板、保存的搜索、用户设置和警报。 -在这种模式下,数据摄取完全由用户负责。您可以使用自己托管的 OpenTelemetry 收集器、从客户端库直接摄取、ClickHouse 原生表引擎(如 Kafka 或 S3)、ETL 管道或管理的摄取服务(如 ClickPipes)将数据导入 ClickHouse。此方法提供了最大的灵活性,适合那些已经在操作 ClickHouse 的团队,并希望在其上层叠加 HyperDX 进行可视化、搜索和警报。 +在此模式下,数据摄取完全由用户负责。您可以通过自己的托管 OpenTelemetry 收集器、客户端库的直接摄取、ClickHouse 原生表引擎(例如 Kafka 或 S3)、ETL 管道或像 ClickPipes 这样的托管摄取服务将数据摄取到 ClickHouse。该方法提供了最大的灵活性,适合已经操作 ClickHouse 并希望在其上添加 HyperDX 以进行可视化、搜索和警报的团队。 ### 适合 {#suitable-for} -- 现有的 ClickHouse 用户 +- 现有 ClickHouse 用户 - 自定义事件管道 ## 部署步骤 {#deployment-steps} @@ -34,40 +36,48 @@ HyperDX 可以独立于其余堆栈使用,并且与任何数据架构兼容 - 运行以下命令,根据需要修改 `YOUR_MONGODB_URI`。 -```bash +```shell docker run -e MONGO_URI=mongodb://YOUR_MONGODB_URI -p 8080:8080 docker.hyperdx.io/hyperdx/hyperdx ``` -### 访问 HyperDX 用户界面 {#navigate-to-hyperdx-ui} +### 导航到 HyperDX UI {#navigate-to-hyperdx-ui} -访问 [http://localhost:8080](http://localhost:8080) 以访问 HyperDX 用户界面。 +访问 [http://localhost:8080](http://localhost:8080) 以访问 HyperDX UI。 创建一个用户,提供符合要求的用户名和密码。 -单击 `Create` 后,系统将提示您输入连接详细信息。 +点击 `Create` 后,您将被提示输入连接详情。 -### 完善连接详细信息 {#complete-connection-details} +### 完成连接详情 {#complete-connection-details} 连接到您自己的外部 ClickHouse 集群,例如 ClickHouse Cloud。 -如果提示您创建源,请保留所有默认值,并在 `Table` 字段中填写 `otel_logs`。所有其他设置应自动检测,使您可以点击 `Save New Source`。 +如果被提示创建源,请保留所有默认值,并在 `Table` 字段中填写值 `otel_logs`。所有其他设置应自动检测,您可以点击 `Save New Source`。 :::note 创建源 -创建源需要在 ClickHouse 中存在表。如果您没有数据,我们建议部署 ClickStack OpenTelemetry 收集器以创建表。 +创建源需要在 ClickHouse 中存在表。如果没有数据,我们建议部署 ClickStack OpenTelemetry 收集器来创建表。 :::
## 使用 Docker Compose {#using-docker-compose} -用户可以修改 [Docker Compose 配置](/use-cases/observability/clickstack/deployment/docker-compose) 以实现与本指南相同的效果,从清单中删除 OTel 收集器和 ClickHouse 实例。 +用户可以修改 [Docker Compose 配置](/use-cases/observability/clickstack/deployment/docker-compose),以达到本指南所示的相同效果,从清单中移除 OTel 收集器和 ClickHouse 实例。 ## ClickStack OpenTelemetry 收集器 {#otel-collector} -即使您管理自己的 OpenTelemetry 收集器,而不依赖于堆栈中的其他组件,我们仍建议使用 ClickStack 版本的收集器。这确保了使用默认架构并应用最佳实践进行摄取。 +即使您管理自己的 OpenTelemetry 收集器,而不依赖于堆栈中的其他组件,我们仍然建议使用 ClickStack 发行版的收集器。这确保使用默认模式并应用摄取的最佳实践。 -有关部署和配置独立收集器的详细信息,请参见 ["使用 OpenTelemetry 摄取"](/use-cases/observability/clickstack/ingesting-data/otel-collector#modifying-otel-collector-configuration)。 +有关部署和配置独立收集器的详细信息,请参见 [“使用 OpenTelemetry 摄取”](/use-cases/observability/clickstack/ingesting-data/otel-collector#modifying-otel-collector-configuration)。 + + + +对于仅限 HyperDX 的图像,用户只需设置 `BETA_CH_OTEL_JSON_SCHEMA_ENABLED=true` 参数,例如: + +```shell +docker run -e BETA_CH_OTEL_JSON_SCHEMA_ENABLED=true -e MONGO_URI=mongodb://YOUR_MONGODB_URI -p 8080:8080 docker.hyperdx.io/hyperdx/hyperdx +``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/hyperdx-only.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/hyperdx-only.md.hash index 2c761465d9d..944a3b8cf69 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/hyperdx-only.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/hyperdx-only.md.hash @@ -1 +1 @@ -9e014fda80fec793 +433e51b84bec7277 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/index.md index 0b34ccb4e10..7535f32f260 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/index.md @@ -3,17 +3,19 @@ 'title': '部署选项' 'pagination_prev': null 'pagination_next': null -'description': '部署 ClickStack - ClickHouse 可观察性栈' +'description': '部署 ClickStack - ClickHouse 可观察性堆栈' +'doc_type': 'reference' --- -ClickStack 提供多种部署选项以适应不同的用例。 +ClickStack 提供多种部署选项以适应不同的使用场景。 -以下是对每个部署选项的总结。 [入门指南](/use-cases/observability/clickstack/getting-started) 特别演示了选项 1 和 2。它们在此处包含以求完整。 +以下是每个部署选项的总结。 [入门指南](/use-cases/observability/clickstack/getting-started) 特别演示了选项 1 和 2。它们在这里列出以便完整性。 -| 名称 | 描述 | 适用对象 | 限制 | 示例链接 | -|------------------|----------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------| -| All-in-One | 单个 Docker 容器,捆绑了所有 ClickStack 组件。 | 演示、局部全栈测试 | 不推荐用于生产 | [All-in-One](/use-cases/observability/clickstack/deployment/all-in-one) | -| Helm | 官方的 Helm 图表,用于基于 Kubernetes 的部署。支持 ClickHouse Cloud 和生产扩展。 | Kubernetes 上的生产部署 | 需要 Kubernetes 知识,需通过 Helm 进行自定义 | [Helm](/use-cases/observability/clickstack/deployment/helm) | -| Docker Compose | 通过 Docker Compose 单独部署每个 ClickStack 组件。 | 本地测试、概念验证、在单个服务器上的生产、自管理 ClickHouse | 无容错能力,需要管理多个容器 | [Docker Compose](/use-cases/observability/clickstack/deployment/docker-compose) | -| HyperDX Only | 独立使用 HyperDX,并使用您自己的 ClickHouse 和架构。 | 现有 ClickHouse 用户、自定义事件管道 | 不包括 ClickHouse,用户必须管理数据摄取和架构 | [HyperDX Only](/use-cases/observability/clickstack/deployment/hyperdx-only) | -| Local Mode Only | 完全在浏览器中运行,使用本地存储。没有后端或持久性。 | 演示、调试、与 HyperDX 的开发 | 无身份验证,无持久性,无警报,仅限单用户 | [Local Mode Only](/use-cases/observability/clickstack/deployment/local-mode-only) | +| 名称 | 描述 | 适合于 | 限制 | 示例链接 | +|--------------------|--------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------| +| All-in-One | 单个 Docker 容器,包含所有 ClickStack 组件。 | 生产部署,演示,概念验证 | 不推荐用于生产 | [All-in-One](/use-cases/observability/clickstack/deployment/all-in-one) | +| ClickHouse Cloud | 在 ClickHouse Cloud 中托管的 ClickHouse 和 HyperDX。 | 演示,本地全栈测试 | 不推荐用于生产 | [All-in-One](/use-cases/observability/clickstack/deployment/hyperdx-clickhouse-cloud) | +| Helm | 用于基于 Kubernetes 的部署的官方 Helm 图表。支持 ClickHouse Cloud 和生产扩展。 | 在 Kubernetes 上进行生产部署 | 需要 Kubernetes 知识,通过 Helm 进行自定义 | [Helm](/use-cases/observability/clickstack/deployment/helm) | +| Docker Compose | 通过 Docker Compose 单独部署每个 ClickStack 组件。 | 本地测试,概念验证,单服务器上的生产,BYO ClickHouse | 无故障容错,需要管理多个容器 | [Docker Compose](/use-cases/observability/clickstack/deployment/docker-compose) | +| HyperDX Only | 独立使用 HyperDX,配合您自己的 ClickHouse 和模式。 | 现有 ClickHouse 用户,自定义事件管道 | 不包含 ClickHouse,用户必须管理数据摄取和模式 | [HyperDX Only](/use-cases/observability/clickstack/deployment/hyperdx-only) | +| Local Mode Only | 完全在浏览器中运行,使用本地存储。没有后端或持久化。 | 演示,调试,开发时使用 HyperDX | 没有身份验证,没有持久性,没有警报,仅限单用户 | [Local Mode Only](/use-cases/observability/clickstack/deployment/local-mode-only) | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/index.md.hash index 78e17b8b798..1c4bd104e30 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/index.md.hash @@ -1 +1 @@ -5c119953df65a609 +3fb7d63b6d2ca6eb diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/local-mode-only.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/local-mode-only.md index 4c460d81a6c..dfee3f38484 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/local-mode-only.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/local-mode-only.md @@ -1,23 +1,28 @@ --- 'slug': '/use-cases/observability/clickstack/deployment/local-mode-only' -'title': '本地模式仅限' +'title': '仅本地模式' 'pagination_prev': null 'pagination_next': null 'sidebar_position': 5 -'description': '仅使用本地模式部署 ClickStack - ClickHouse 可观察性栈' +'description': '仅使用本地模式部署 ClickStack - ClickHouse 观察性栈' +'doc_type': 'guide' --- import Image from '@theme/IdealImage'; import hyperdx_logs from '@site/static/images/use-cases/observability/hyperdx-logs.png'; import hyperdx_2 from '@site/static/images/use-cases/observability/hyperdx-2.png'; +import JSONSupport from '@site/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/_snippets/_json_support.md'; -此模式包括用户界面,所有应用程序状态在浏览器中本地存储。 +类似于 [全能图像](/use-cases/observability/clickstack/deployment/docker-compose),这个综合性的 Docker 镜像捆绑了所有 ClickStack 组件: -**此 HyperDX 发行版禁用了用户身份验证** +* **ClickHouse** +* **HyperDX** +* **OpenTelemetry (OTel) 收集器**(在端口 `4317` 和 `4318` 暴露 OTLP) +* **MongoDB**(用于持久的应用状态) -它不包括 MongoDB 实例,这意味着仪表板、保存的搜索和警报在不同用户之间不会持久化。 +**然而,此版本的 HyperDX 禁用了用户身份验证** -### 适合 {#suitable-for} +### 适用于 {#suitable-for} * 演示 * 调试 @@ -30,24 +35,32 @@ import hyperdx_2 from '@site/static/images/use-cases/observability/hyperdx-2.png ### 使用 Docker 部署 {#deploy-with-docker} -本地模式仅部署 HyperDX 用户界面,访问端口 8080。 +本地模式在端口 8080 上部署 HyperDX 用户界面。 -```bash +```shell docker run -p 8080:8080 docker.hyperdx.io/hyperdx/hyperdx-local ``` -### 导航到 HyperDX 用户界面 {#navigate-to-hyperdx-ui} +### 访问 HyperDX 用户界面 {#navigate-to-hyperdx-ui} 访问 [http://localhost:8080](http://localhost:8080) 以访问 HyperDX 用户界面。 -**您不会被提示创建用户,因为此部署模式未启用身份验证。** +**您将不会被提示创建用户,因为在此部署模式下未启用身份验证。** 连接到您自己的外部 ClickHouse 集群,例如 ClickHouse Cloud。 -创建一个源,保留所有默认值,将 `Table` 字段填写为 `otel_logs`。所有其他设置应自动检测,您可以点击 `Save New Source`。 +创建一个源,保留所有默认值,并在 `Table` 字段中填写值 `otel_logs`。所有其他设置应自动检测,让您可以点击 `保存新源`。 + + + +对于仅本地模式的镜像,用户只需设置 `BETA_CH_OTEL_JSON_SCHEMA_ENABLED=true` 参数,例如: + +```shell +docker run -e BETA_CH_OTEL_JSON_SCHEMA_ENABLED=true -p 8080:8080 docker.hyperdx.io/hyperdx/hyperdx-local +``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/local-mode-only.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/local-mode-only.md.hash index 832e55e9843..201f4d9415e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/local-mode-only.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/deployment/local-mode-only.md.hash @@ -1 +1 @@ -416ed5a3a916dc0a +97b23d20f23c3eb3 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/event_deltas.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/event_deltas.md new file mode 100644 index 00000000000..9483cd3e425 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/event_deltas.md @@ -0,0 +1,67 @@ +--- +'slug': '/use-cases/observability/clickstack/event_deltas' +'title': '与 ClickStack 的事件增量' +'sidebar_label': '事件增量' +'pagination_prev': null +'pagination_next': null +'description': '与 ClickStack 的事件增量' +'doc_type': 'guide' +--- + +import Image from '@theme/IdealImage'; +import event_deltas from '@site/static/images/use-cases/observability/hyperdx-demo/step_17.png'; +import event_deltas_no_selected from '@site/static/images/use-cases/observability/event_deltas_no_selected.png'; +import event_deltas_highlighted from '@site/static/images/use-cases/observability/event_deltas_highlighted.png'; +import event_deltas_selected from '@site/static/images/use-cases/observability/event_deltas_selected.png'; +import event_deltas_issue from '@site/static/images/use-cases/observability/event_deltas_issue.png'; +import event_deltas_outliers from '@site/static/images/use-cases/observability/event_deltas_outliers.png'; +import event_deltas_separation from '@site/static/images/use-cases/observability/event_deltas_separation.png'; +import event_deltas_inappropriate from '@site/static/images/use-cases/observability/event_deltas_inappropriate.png'; + +Event Deltas in ClickStack 是一个以跟踪为中心的功能,能够自动分析跟踪的属性,以揭示性能退化时发生了什么变化。通过比较正常与慢速跟踪在一个语料库中的延迟分布,ClickStack 突出显示了哪些属性与差异最相关——无论是新的部署版本、特定的端点,还是特定的用户 ID。 + +在手动筛选跟踪数据的过程中,事件增量可以揭示在两个数据子集之间驱动延迟差异的关键属性,这使得诊断回归和精准定位根本原因变得更加容易。此功能使您能够可视化原始跟踪,并立即看到影响性能变化的因素,加快事件响应,并减少平均解决时间。 + + + +## 使用事件增量 {#using-event-deltas} + +事件增量可以通过 ClickStack 中选择 `Trace` 类型数据源的 **Search** 面板直接使用。 + +从左上角的 **Analysis Mode** 选择器中,选择 **Event Deltas**(选定 `Trace` 数据源)以切换到标准结果表,该表将跨度显示为行。 + + + +此视图呈现了随时间变化的跨度分布,显示延迟如何随数量变化而变化。纵轴表示延迟,而颜色表示在给定点的跟踪密度,亮黄色区域对应着更高的跟踪浓度。通过这个可视化,用户可以迅速看到跨度在延迟和计数之间的分布情况,使识别性能变化或异常变得更加容易。 + + + +然后用户可以选择可视化中的某个区域——理想情况下是具有较长持续时间跨度和足够密度的区域,并随后选择 **Filter by Selection**。这将指定用于分析的“异常值”。事件增量随后将识别与这个异常子集中的那些跨度最相关的列和关键值。通过关注具有重要异常值的区域,ClickStack 突出显示了使此子集与整体语料库区分开来的独特值,揭示了与观察到的性能差异最相关的属性。 + + + +对于每一列,ClickStack 识别那些明显偏向于所选异常子集的值。换句话说,当某个值出现在一列中时,如果它主要出现在异常值中而不是整体数据集(正常值)中,它会被突出显示为重要。具有最强偏差的列将首先列出,揭示与异常跨度最强相关的属性,并将其与基线行为区分开来。 + + + +考虑上面的示例,其中 `SpanAttributes.app.payment.card_type` 列已被显示。这里,事件增量分析显示 `29%` 的正常值使用 MasterCard,而异常值中为 `0%`,而 `100%` 的异常值使用 Visa,正常值中为 `71%`。这表明 Visa 卡类型与异常的高延迟跟踪高度相关,而 MasterCard 仅出现在正常子集中。 + + + +反之,完全与正常值关联的值也许同样有趣。在上面的示例中,错误 `Visa Cash Full` 完全出现在正常值中,而在异常跨度中完全缺失。在这种情况下,延迟始终低于约 50 毫秒,表明此错误与低延迟相关。 + +## 事件增量的工作原理 {#how-event-deltas-work} + +事件增量通过发出两个查询来工作:一个针对所选的异常区域,另一个针对正常区域。每个查询被限制在适当的持续时间和时间窗口。接下来,检查两个结果集中的事件样本,并识别在异常值中主要出现的值集中度高的列。首先显示的是只在异常子集中出现 100% 值的列,从而突出显示观察到差异中最负责任的属性。 + +## 推荐 {#recommendations} + +事件增量在分析集中于特定服务时效果最佳。多个服务之间的延迟可能差异很大,这使得识别最为关键的异常值的列和值变得更加困难。在启用事件增量之前,请将跨度过滤到延迟分布预计相似的集合中。目标分析那些广泛的延迟变异不寻常的集合,以获取最有用的洞察,避免那些变异是常态的情况(例如两个不同的服务)。 + +选择区域时,用户应针对明确显示慢速与快速持续时间分布的子集,允许高延迟跨度被清晰隔离以供分析。例如,请注意下面选择的区域明确捕获了一组慢速跨度供分析。 + + + +反之,以下数据集在使用事件增量时难以以有用的方式进行分析。 + + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/event_deltas.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/event_deltas.md.hash new file mode 100644 index 00000000000..3d7e4b1c722 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/event_deltas.md.hash @@ -0,0 +1 @@ +e9866694cdd49780 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/event_patterns.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/event_patterns.md new file mode 100644 index 00000000000..61bc3ab356b --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/event_patterns.md @@ -0,0 +1,39 @@ +--- +'slug': '/use-cases/observability/clickstack/event_patterns' +'title': '与 ClickStack 的事件模式' +'sidebar_label': '事件模式' +'pagination_prev': null +'pagination_next': null +'description': '与 ClickStack 的事件模式' +'doc_type': 'guide' +--- + +import Image from '@theme/IdealImage'; +import event_patterns from '@site/static/images/use-cases/observability/event_patterns.png'; +import event_patterns_highlight from '@site/static/images/use-cases/observability/event_patterns_highlight.png'; + +Event patterns in ClickStack 允许您通过自动聚类相似的消息,快速理解大量的日志或追踪,因此您只需审查少量有意义的组,而无需逐条查找数百万个单独的事件。 + + + +这使得识别哪些错误或警告是新的,哪些是重复出现的,以及哪些导致日志量激增变得更加容易。由于模式是动态生成的,您无需定义正则表达式或维护解析规则 - ClickStack 会自动适应您的事件,无论其格式如何。 + +除了事件响应,这种高层次的视图还帮助您识别噪声日志源,这些源可以被修剪以减少成本,发现服务产生的不同类型的日志,以及更快速地回答系统是否已经发出您关心的信号。 + +## 访问事件模式 {#accessing-event-patterns} + +事件模式可以直接通过 ClickStack 中的 **Search** 面板访问。 + +从左上角的 **Analysis Mode** 选择器中,选择 **Event Patterns** 以切换到聚类相似事件的视图,而不是标准结果表。 + + + +这为默认的 **Results Table** 提供了一种替代方案,允许用户滚动浏览每个单独的日志或追踪。 + +## 建议 {#recommendations} + +事件模式在应用于 **缩小的子集** 数据时效果最佳。例如,在启用事件模式之前过滤到单个服务,通常会比在数千个服务上同时应用模式更易于浮现出相关和有趣的消息。 + +它们对于总结错误消息尤为强大,其中重复的错误(具有不同的 ID 或有效负载)被聚合成简明的集群。 + +有关实时示例,请查看事件模式在 [Remote Demo Dataset](/use-cases/observability/clickstack/getting-started/remote-demo-data#identify-error-patterns) 中的使用情况。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/event_patterns.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/event_patterns.md.hash new file mode 100644 index 00000000000..038f72f34f4 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/event_patterns.md.hash @@ -0,0 +1 @@ +0a5c8c5070098d41 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/example-datasets/_snippets/_demo.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/example-datasets/_snippets/_demo.md new file mode 100644 index 00000000000..ffbaada929e --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/example-datasets/_snippets/_demo.md @@ -0,0 +1,15 @@ +import Image from '@theme/IdealImage'; +import architecture from '@site/static/images/use-cases/observability/hyperdx-demo/architecture.png'; + +### Demo Architecture {#demo-architecture} + +该演示由使用不同编程语言编写的微服务组成,这些微服务通过 gRPC 和 HTTP 相互通信,还有一个使用 Locust 模拟用户流量的负载生成器。为此演示提供的原始源代码已修改为使用 [ClickStack instrumentation](/use-cases/observability/clickstack/sdks)。 + + + +_来源: https://opentelemetry.io/docs/demo/architecture/_ + +关于该演示的更多详细信息可以在以下链接中找到: + +- [OpenTelemetry documentation](https://opentelemetry.io/docs/demo/) +- [ClickStack maintained fork](https://github.com/ClickHouse/opentelemetry-demo) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/example-datasets/_snippets/_demo.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/example-datasets/_snippets/_demo.md.hash new file mode 100644 index 00000000000..50633fde8e6 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/example-datasets/_snippets/_demo.md.hash @@ -0,0 +1 @@ +42307e84ae2890cd diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/example-datasets/_snippets/k8s_daemonset.yaml b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/example-datasets/_snippets/k8s_daemonset.yaml new file mode 100644 index 00000000000..ec5b91ecbc6 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/example-datasets/_snippets/k8s_daemonset.yaml @@ -0,0 +1,100 @@ +# daemonset.yaml +mode: daemonset + +image: + repository: otel/opentelemetry-collector-contrib + tag: 0.123.0 + +# Required to use the kubeletstats cpu/memory utilization metrics +clusterRole: + create: true + rules: + - apiGroups: + - '' + resources: + - nodes/proxy + verbs: + - get + +presets: + logsCollection: + enabled: true + hostMetrics: + enabled: true + # Configures the Kubernetes Processor to add Kubernetes metadata. + # Adds the k8sattributes processor to all the pipelines and adds the necessary rules to ClusterRole. + # More Info: https://opentelemetry.io/docs/kubernetes/collector/components/#kubernetes-attributes-processor + kubernetesAttributes: + enabled: true + # When enabled the processor will extra all labels for an associated pod and add them as resource attributes. + # The label's exact name will be the key. + extractAllPodLabels: true + # When enabled the processor will extra all annotations for an associated pod and add them as resource attributes. + # The annotation's exact name will be the key. + extractAllPodAnnotations: true + # Configures the collector to collect node, pod, and container metrics from the API server on a kubelet.. + # Adds the kubeletstats receiver to the metrics pipeline and adds the necessary rules to ClusterRole. + # More Info: https://opentelemetry.io/docs/kubernetes/collector/components/#kubeletstats-receiver + kubeletMetrics: + enabled: true + +extraEnvs: + - name: HYPERDX_API_KEY + valueFrom: + secretKeyRef: + name: hyperdx-secret + key: HYPERDX_API_KEY + optional: true + - name: YOUR_OTEL_COLLECTOR_ENDPOINT + valueFrom: + configMapKeyRef: + name: otel-config-vars + key: YOUR_OTEL_COLLECTOR_ENDPOINT + +config: + receivers: + # Configures additional kubelet metrics + kubeletstats: + collection_interval: 20s + auth_type: 'serviceAccount' + endpoint: '${env:K8S_NODE_NAME}:10250' + insecure_skip_verify: true + metrics: + k8s.pod.cpu_limit_utilization: + enabled: true + k8s.pod.cpu_request_utilization: + enabled: true + k8s.pod.memory_limit_utilization: + enabled: true + k8s.pod.memory_request_utilization: + enabled: true + k8s.pod.uptime: + enabled: true + k8s.node.uptime: + enabled: true + k8s.container.cpu_limit_utilization: + enabled: true + k8s.container.cpu_request_utilization: + enabled: true + k8s.container.memory_limit_utilization: + enabled: true + k8s.container.memory_request_utilization: + enabled: true + container.uptime: + enabled: true + + exporters: + otlphttp: + endpoint: "${env:YOUR_OTEL_COLLECTOR_ENDPOINT}" + compression: gzip + headers: + authorization: "${env:HYPERDX_API_KEY}" + + service: + pipelines: + logs: + exporters: + - otlphttp + metrics: + exporters: + - otlphttp diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/example-datasets/_snippets/k8s_deployment.yaml b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/example-datasets/_snippets/k8s_deployment.yaml new file mode 100644 index 00000000000..49bc6675bd3 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/example-datasets/_snippets/k8s_deployment.yaml @@ -0,0 +1,58 @@ +# deployment.yaml +mode: deployment + +image: + repository: otel/opentelemetry-collector-contrib + tag: 0.123.0 + +# We only want one of these collectors - any more and we'd produce duplicate data +replicaCount: 1 + +presets: + kubernetesAttributes: + enabled: true + # When enabled the processor will extra all labels for an associated pod and add them as resource attributes. + # The label's exact name will be the key. + extractAllPodLabels: true + # When enabled the processor will extra all annotations for an associated pod and add them as resource attributes. + # The annotation's exact name will be the key. + extractAllPodAnnotations: true + # Configures the collector to collect kubernetes events. + # Adds the k8sobject receiver to the logs pipeline and collects kubernetes events by default. + # More Info: https://opentelemetry.io/docs/kubernetes/collector/components/#kubernetes-objects-receiver + kubernetesEvents: + enabled: true + # Configures the Kubernetes Cluster Receiver to collect cluster-level metrics. + # Adds the k8s_cluster receiver to the metrics pipeline and adds the necessary rules to ClusteRole. + # More Info: https://opentelemetry.io/docs/kubernetes/collector/components/#kubernetes-cluster-receiver + clusterMetrics: + enabled: true + +extraEnvs: + - name: HYPERDX_API_KEY + valueFrom: + secretKeyRef: + name: hyperdx-secret + key: HYPERDX_API_KEY + optional: true + - name: YOUR_OTEL_COLLECTOR_ENDPOINT + valueFrom: + configMapKeyRef: + name: otel-config-vars + key: YOUR_OTEL_COLLECTOR_ENDPOINT + +config: + exporters: + otlphttp: + endpoint: "${env:YOUR_OTEL_COLLECTOR_ENDPOINT}" + compression: gzip + headers: + authorization: "${env:HYPERDX_API_KEY}" + service: + pipelines: + logs: + exporters: + - otlphttp + metrics: + exporters: + - otlphttp diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/example-datasets/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/example-datasets/index.md index 88483d649e9..18ca094b486 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/example-datasets/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/example-datasets/index.md @@ -4,12 +4,13 @@ 'pagination_prev': null 'pagination_next': null 'description': '开始使用 ClickStack 和示例数据集' +'doc_type': 'landing-page' --- -这一部分提供了各种示例数据集和示例,以帮助您开始使用 ClickStack。这些示例展示了在 ClickStack 中处理可观察性数据的不同方法,从本地开发到生产场景。 +这一部分提供了各种示例数据集和示例,以帮助您入门 ClickStack。这些示例展示了在 ClickStack 中处理可观察性数据的不同方法,从本地开发到生产场景。 | 数据集 | 描述 | |---------|-------------| -| [示例数据](sample-data.md) | 加载一个包含来自我们演示环境的日志、跟踪和指标的示例数据集 | +| [示例数据](sample-data.md) | 加载来自我们演示环境的包含日志、跟踪和指标的示例数据集 | | [本地数据](local-data.md) | 收集本地系统指标和日志,并将其发送到 ClickStack 进行分析 | | [远程演示数据](remote-demo-data.md) | 连接到我们的远程演示集群并探索一个问题 | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/example-datasets/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/example-datasets/index.md.hash index eab212f3cfb..7c03593d178 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/example-datasets/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/example-datasets/index.md.hash @@ -1 +1 @@ -923a5072b986fc63 +ec0c76403f1984a9 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/example-datasets/kubernetes.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/example-datasets/kubernetes.md new file mode 100644 index 00000000000..17f3b0fbcdd --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/example-datasets/kubernetes.md @@ -0,0 +1,540 @@ +--- +'slug': '/use-cases/observability/clickstack/getting-started/kubernetes' +'title': '监视 Kubernetes' +'sidebar_position': 1 +'pagination_prev': null +'pagination_next': null +'description': '开始使用 ClickStack 和监视 Kubernetes' +'doc_type': 'guide' +--- + +import Image from '@theme/IdealImage'; +import DemoArchitecture from '@site/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/example-datasets/_snippets/_demo.md'; +import hyperdx_login from '@site/static/images/use-cases/observability/hyperdx-login.png'; +import hyperdx_kubernetes_data from '@site/static/images/use-cases/observability/hyperdx-kubernetes-data.png'; +import copy_api_key from '@site/static/images/use-cases/observability/copy_api_key.png'; +import hyperdx_cloud_datasource from '@site/static/images/use-cases/observability/hyperdx_cloud_datasource.png'; +import hyperdx_create_new_source from '@site/static/images/use-cases/observability/hyperdx_create_new_source.png'; +import hyperdx_create_trace_datasource from '@site/static/images/use-cases/observability/hyperdx_create_trace_datasource.png'; +import dashboard_kubernetes from '@site/static/images/use-cases/observability/hyperdx-dashboard-kubernetes.png'; + +本指南允许您从 Kubernetes 系统收集日志和指标,并将其发送到 **ClickStack** 进行可视化和分析。对于演示数据,我们可选地使用 ClickStack 的官方 Open Telemetry 演示的分叉。 + + + +## 前提条件 {#prerequisites} + +本指南要求您具备: + +- 一个 **Kubernetes 集群**(推荐使用 v1.20+),至少在一个节点上具备 32 GiB 的内存和 100GB 的磁盘空间用于 ClickHouse。 +- **[Helm](https://helm.sh/)** v3+ +- 配置好的 **`kubectl`**,以与您的集群进行交互 + +## 部署选项 {#deployment-options} + +您可以使用以下任一部署选项遵循本指南: + +- **自托管**:完全在您的 Kubernetes 集群中部署 ClickStack,包括: + - ClickHouse + - HyperDX + - MongoDB(用于仪表板状态和配置) + +- **云托管**:使用 **ClickHouse Cloud**,而 HyperDX 在外部管理。这消除了必须在您的集群内部运行 ClickHouse 或 HyperDX 的需要。 + +为了模拟应用流量,您可以选择性地部署 ClickStack 的 [**OpenTelemetry 演示应用**](https://github.com/ClickHouse/opentelemetry-demo) 的分叉。这会生成包括日志、指标和跟踪的遥测数据。如果您已经在集群中运行工作负载,可以跳过此步骤,监控现有的 pods、节点和容器。 + + + +### 安装 cert-manager(可选) {#install-cert-manager} + +如果您的设置需要 TLS 证书,请使用 Helm 安装 [cert-manager](https://cert-manager.io/): + +```shell + +# Add Cert manager repo + +helm repo add jetstack https://charts.jetstack.io + +helm install cert-manager jetstack/cert-manager --namespace cert-manager --create-namespace --set startupapicheck.timeout=5m --set installCRDs=true --set global.leaderElection.namespace=cert-manager +``` + +### 部署 OpenTelemetry 演示(可选) {#deploy-otel-demo} + +此 **步骤是可选的,旨在针对没有现有 pods 进行监控的用户**。虽然在 Kubernetes 环境中已经部署现有服务的用户可以跳过此步骤,但该演示确实包括生成跟踪和会话重放数据的仪器化微服务 - 允许用户探索 ClickStack 的所有功能。 + +以下在 Kubernetes 集群内部署 ClickStack 的 OpenTelemetry 演示应用程序堆栈,旨在进行可观察性测试和展示仪器化。它包括后端微服务、负载生成器、遥测管道、支持基础设施(例如 Kafka、Redis)以及与 ClickStack 的 SDK 集成。 + +所有服务都部署在 `otel-demo` 命名空间中。每个部署包括: + +- 使用 OTel 和 ClickStack SDK 进行自动仪器化,用于跟踪、指标和日志。 +- 所有服务将其仪器化发送到 `my-hyperdx-hdx-oss-v2-otel-collector` OpenTelemetry 收集器(尚未部署) +- [将资源标签转发](/use-cases/observability/clickstack/ingesting-data/kubernetes#forwarding-resouce-tags-to-pods) 通过环境变量 `OTEL_RESOURCE_ATTRIBUTES` 来关联日志、指标和跟踪。 + +```shell +## download demo Kubernetes manifest file +curl -O https://raw.githubusercontent.com/ClickHouse/opentelemetry-demo/refs/heads/main/kubernetes/opentelemetry-demo.yaml + +# wget alternative + +# wget https://raw.githubusercontent.com/ClickHouse/opentelemetry-demo/refs/heads/main/kubernetes/opentelemetry-demo.yaml +kubectl apply --namespace otel-demo -f opentelemetry-demo.yaml +``` + +在演示部署时,请确认所有 pods 已成功创建并处于 `Running` 状态: + +```shell +kubectl get pods -n=otel-demo + +NAME READY STATUS RESTARTS AGE +accounting-fd44f4996-fcl4k 1/1 Running 0 13m +ad-769f968468-qq8mw 1/1 Running 0 13m +artillery-loadgen-7bc4bdf47d-5sb96 1/1 Running 0 13m +cart-5b4c98bd8-xm7m2 1/1 Running 0 13m +checkout-784f69b785-cnlpp 1/1 Running 0 13m +currency-fd7775b9c-rf6cr 1/1 Running 0 13m +email-5c54598f99-2td8s 1/1 Running 0 13m +flagd-5466775df7-zjb4x 2/2 Running 0 13m +fraud-detection-5769fdf75f-cjvgh 1/1 Running 0 13m +frontend-6dcb696646-fmcdz 1/1 Running 0 13m +frontend-proxy-7b8f6cd957-s25qj 1/1 Running 0 13m +image-provider-5fdb455756-fs4xv 1/1 Running 0 13m +kafka-7b6666866d-xfzn6 1/1 Running 0 13m +load-generator-57cbb7dfc9-ncxcf 1/1 Running 0 13m +payment-6d96f9bcbd-j8tj6 1/1 Running 0 13m +product-catalog-7fb77f9c78-49bhj 1/1 Running 0 13m +quote-576c557cdf-qn6pr 1/1 Running 0 13m +recommendation-546cc68fdf-8x5mm 1/1 Running 0 13m +shipping-7fc69f7fd7-zxrx6 1/1 Running 0 13m +valkey-cart-5f7b667bb7-gl5v4 1/1 Running 0 13m +``` + + + +### 添加 ClickStack Helm 图表仓库 {#add-helm-clickstack} + +要部署 ClickStack,我们使用 [官方 Helm 图表](https://clickhouse.com/docs/use-cases/observability/clickstack/deployment/helm)。 + +这要求我们添加 HyperDX Helm 仓库: + +```shell +helm repo add hyperdx https://hyperdxio.github.io/helm-charts +helm repo update +``` + +### 部署 ClickStack {#deploy-clickstack} + +安装 Helm 图表后,您可以将 ClickStack 部署到您的集群。您可以运行所有组件,包括 ClickHouse 和 HyperDX,或者使用 ClickHouse Cloud,在该环境下 HyperDX 也作为托管服务提供。 +
+ +
+自管理部署 + +以下命令将 ClickStack 安装到 `otel-demo` 命名空间中。该 helm 图表部署: + +- 一个 ClickHouse 实例 +- HyperDX +- ClickStack 版本的 OTel 收集器 +- 用于存储 HyperDX 应用状态的 MongoDB + +:::note +您可能需要根据您的 Kubernetes 集群配置调整 `storageClassName`。 +::: + +未部署 OTel 演示的用户可以对此进行修改,选择适当的命名空间。 + +```shell +helm install my-hyperdx hyperdx/hdx-oss-v2 --set clickhouse.persistence.dataSize=100Gi --set global.storageClassName="standard-rwo" -n otel-demo +``` + +:::warning ClickStack 生产环境 + +此图表还安装 ClickHouse 和 OTel 收集器。在生产环境中,建议您使用 clickhouse 和 OTel 收集器操作器和/或使用 ClickHouse Cloud。 + +要禁用 clickhouse 和 OTel 收集器,请设置以下值: + +```shell +helm install myrelease --set clickhouse.enabled=false --set clickhouse.persistence.enabled=false --set otel.enabled=false +``` + +::: + +
+ +
+使用 ClickHouse Cloud + +如果您更愿意使用 ClickHouse Cloud,您可以部署 ClickStack 并 [禁用包含的 ClickHouse](https://clickhouse.com/docs/use-cases/observability/clickstack/deployment/helm#using-clickhouse-cloud)。 + +:::note +该图表当前始终部署 HyperDX 和 MongoDB。虽然这些组件提供了替代访问路径,但它们与 ClickHouse Cloud 身份验证未集成。这些组件旨在为此部署模型中的管理员提供 [访问安全的摄取密钥](#retrieve-ingestion-api-key),以便通过部署的 OTel 收集器进行摄取,但不应对最终用户开放。 +::: + +```shell + +# specify ClickHouse Cloud credentials +export CLICKHOUSE_URL= # full https url +export CLICKHOUSE_USER= +export CLICKHOUSE_PASSWORD= + +helm install my-hyperdx hyperdx/hdx-oss-v2 --set clickhouse.enabled=false --set clickhouse.persistence.enabled=false --set otel.clickhouseEndpoint=${CLICKHOUSE_URL} --set clickhouse.config.users.otelUser=${CLICKHOUSE_USER} --set clickhouse.config.users.otelUserPassword=${CLICKHOUSE_PASSWORD} --set global.storageClassName="standard-rwo" -n otel-demo +``` + +
+ +要验证部署状态,请运行以下命令并确认所有组件处于 `Running` 状态。请注意,对于使用 ClickHouse Cloud 的用户,ClickHouse 将不在其中: + +```shell +kubectl get pods -l "app.kubernetes.io/name=hdx-oss-v2" -n otel-demo + +NAME READY STATUS RESTARTS AGE +my-hyperdx-hdx-oss-v2-app-78876d79bb-565tb 1/1 Running 0 14m +my-hyperdx-hdx-oss-v2-clickhouse-57975fcd6-ggnz2 1/1 Running 0 14m +my-hyperdx-hdx-oss-v2-mongodb-984845f96-czb6m 1/1 Running 0 14m +my-hyperdx-hdx-oss-v2-otel-collector-64cf698f5c-8s7qj 1/1 Running 0 14m +``` + +### 访问 HyperDX UI {#access-the-hyperdx-ui} + +:::note +即使使用 ClickHouse Cloud,在 Kubernetes 集群中部署的本地 HyperDX 实例仍然是必要的。它提供了一个由与 HyperDX 一起捆绑的 OpAMP 服务器管理的摄取密钥,通过部署的 OTel 收集器进行安全摄取 - 这种功能在 ClickHouse Cloud 托管版本中当前不可用。 +::: + +出于安全原因,服务使用 `ClusterIP`,默认情况下不对外暴露。 + +要访问 HyperDX UI,从 3000 转发到本地端口 8080。 + +```shell +kubectl port-forward \ + pod/$(kubectl get pod -l app.kubernetes.io/name=hdx-oss-v2 -o jsonpath='{.items[0].metadata.name}' -n otel-demo) \ + 8080:3000 \ + -n otel-demo +``` + +导航到 [http://localhost:8080](http://localhost:8080) 以访问 HyperDX UI。 + +创建一个用户,提供满足复杂性要求的用户名和密码。 + + + +### 检索摄取 API 密钥 {#retrieve-ingestion-api-key} + +通过 ClickStack 收集器部署的 OTel 收集器的摄取是使用摄取密钥安全的。 + +导航到 [`Team Settings`](http://localhost:8080/team) 并从 `API Keys` 部分复制 `Ingestion API Key`。此 API 密钥确保通过 OpenTelemetry 收集器的数据摄取是安全的。 + + + +### 创建 API 密钥 Kubernetes Secret {#create-api-key-kubernetes-secret} + +使用摄取 API 密钥以及包含 ClickStack helm 图表中部署的 OTel 收集器位置的配置映射创建一个新的 Kubernetes secret。后续组件将使用此信息允许数据摄取到部署的 ClickStack Helm 图表中: + +```shell + +# create secret with the ingestion API key +kubectl create secret generic hyperdx-secret \ +--from-literal=HYPERDX_API_KEY= \ +-n otel-demo + + +# create a ConfigMap pointing to the ClickStack OTel collector deployed above +kubectl create configmap -n=otel-demo otel-config-vars --from-literal=YOUR_OTEL_COLLECTOR_ENDPOINT=http://my-hyperdx-hdx-oss-v2-otel-collector:4318 +``` + +重新启动 OpenTelemetry 演示应用程序的 pods,以考虑摄取 API 密钥。 + +```shell +kubectl rollout restart deployment -n otel-demo -l app.kubernetes.io/part-of=opentelemetry-demo +``` + +来自演示服务的跟踪和日志数据现在应开始流入 HyperDX。 + + + +### 添加 OpenTelemetry Helm 仓库 {#add-otel-helm-repo} + +为了收集 Kubernetes 指标,我们将部署一个标准的 OTel 收集器,并配置它以通过上述摄取 API 密钥安全地发送数据到我们的 ClickStack 收集器。 + +这要求我们安装 OpenTelemetry Helm 仓库: + +```shell + +# Add Otel Helm repo +helm repo add open-telemetry https://open-telemetry.github.io/opentelemetry-helm-charts +``` + +### 部署 Kubernetes 收集器组件 {#deploy-kubernetes-collector-components} + +为了从集群本身及每个节点收集日志和指标,我们需要部署两个单独的 OpenTelemetry 收集器,每个收集器都有其自己的清单。这两个提供的清单 - `k8s_deployment.yaml` 和 `k8s_daemonset.yaml` - 协同工作以收集来自您的 Kubernetes 集群的全面遥测数据。 + +- `k8s_deployment.yaml` 部署一个 **单个 OpenTelemetry Collector 实例**,负责收集 **集群范围内的事件和元数据**。它收集 Kubernetes 事件、集群指标,并通过 pod 标签和注释丰富遥测数据。此收集器作为独立部署运行,具有单个副本以避免重复数据。 + +- `k8s_daemonset.yaml` 部署一个 **基于 DaemonSet 的收集器**,在集群中的每个节点上运行。它收集 **节点级别和 pod 级别的指标**,以及容器日志,使用 `kubeletstats`、`hostmetrics` 和 Kubernetes 属性处理器等组件。这些收集器使用元数据丰富日志,并通过 OTLP 导出器将其发送到 HyperDX。 + +这两个清单一起使整个集群的可观察性成为可能,从基础设施到应用程序级别的遥测,并将丰富的数据发送到 ClickStack 进行集中分析。 + +首先,作为部署安装收集器: + +```shell + +# download manifest file +curl -O https://raw.githubusercontent.com/ClickHouse/clickhouse-docs/refs/heads/main/docs/use-cases/observability/clickstack/example-datasets/_snippets/k8s_deployment.yaml + +# install the helm chart +helm install --namespace otel-demo k8s-otel-deployment open-telemetry/opentelemetry-collector -f k8s_deployment.yaml +``` + +
+k8s_deployment.yaml + +```yaml + +# k8s_deployment.yaml +mode: deployment + +image: + repository: otel/opentelemetry-collector-contrib + tag: 0.123.0 + + +# We only want one of these collectors - any more and we'd produce duplicate data +replicaCount: 1 + +presets: + kubernetesAttributes: + enabled: true + # When enabled, the processor will extract all labels for an associated pod and add them as resource attributes. + # The label's exact name will be the key. + extractAllPodLabels: true + # When enabled, the processor will extract all annotations for an associated pod and add them as resource attributes. + # The annotation's exact name will be the key. + extractAllPodAnnotations: true + # Configures the collector to collect Kubernetes events. + # Adds the k8sobject receiver to the logs pipeline and collects Kubernetes events by default. + # More Info: https://opentelemetry.io/docs/kubernetes/collector/components/#kubernetes-objects-receiver + kubernetesEvents: + enabled: true + # Configures the Kubernetes Cluster Receiver to collect cluster-level metrics. + # Adds the k8s_cluster receiver to the metrics pipeline and adds the necessary rules to ClusteRole. + # More Info: https://opentelemetry.io/docs/kubernetes/collector/components/#kubernetes-cluster-receiver + clusterMetrics: + enabled: true + +extraEnvs: + - name: HYPERDX_API_KEY + valueFrom: + secretKeyRef: + name: hyperdx-secret + key: HYPERDX_API_KEY + optional: true + - name: YOUR_OTEL_COLLECTOR_ENDPOINT + valueFrom: + configMapKeyRef: + name: otel-config-vars + key: YOUR_OTEL_COLLECTOR_ENDPOINT + +config: + exporters: + otlphttp: + endpoint: "${env:YOUR_OTEL_COLLECTOR_ENDPOINT}" + compression: gzip + headers: + authorization: "${env:HYPERDX_API_KEY}" + service: + pipelines: + logs: + exporters: + - otlphttp + metrics: + exporters: + - otlphttp +``` + +
+ +接下来,作为 DaemonSet 部署收集器以处理节点和 pod 级别的指标和日志: + +```shell + +# download manifest file +curl -O https://raw.githubusercontent.com/ClickHouse/clickhouse-docs/refs/heads/main/docs/use-cases/observability/clickstack/example-datasets/_snippets/k8s_daemonset.yaml + +# install the helm chart +helm install --namespace otel-demo k8s-otel-daemonset open-telemetry/opentelemetry-collector -f k8s_daemonset.yaml +``` + +
+ + +`k8s_daemonset.yaml` + + +```yaml + +# k8s_daemonset.yaml +mode: daemonset + +image: + repository: otel/opentelemetry-collector-contrib + tag: 0.123.0 + + +# Required to use the kubeletstats cpu/memory utilization metrics +clusterRole: + create: true + rules: + - apiGroups: + - '' + resources: + - nodes/proxy + verbs: + - get + +presets: + logsCollection: + enabled: true + hostMetrics: + enabled: true + # Configures the Kubernetes Processor to add Kubernetes metadata. + # Adds the k8sattributes processor to all the pipelines and adds the necessary rules to ClusterRole. + # More Info: https://opentelemetry.io/docs/kubernetes/collector/components/#kubernetes-attributes-processor + kubernetesAttributes: + enabled: true + # When enabled, the processor will extract all labels for an associated pod and add them as resource attributes. + # The label's exact name will be the key. + extractAllPodLabels: true + # When enabled, the processor will extract all annotations for an associated pod and add them as resource attributes. + # The annotation's exact name will be the key. + extractAllPodAnnotations: true + # Configures the collector to collect node, pod, and container metrics from the API server on a kubelet.. + # Adds the kubeletstats receiver to the metrics pipeline and adds the necessary rules to ClusterRole. + # More Info: https://opentelemetry.io/docs/kubernetes/collector/components/#kubeletstats-receiver + kubeletMetrics: + enabled: true + +extraEnvs: + - name: HYPERDX_API_KEY + valueFrom: + secretKeyRef: + name: hyperdx-secret + key: HYPERDX_API_KEY + optional: true + - name: YOUR_OTEL_COLLECTOR_ENDPOINT + valueFrom: + configMapKeyRef: + name: otel-config-vars + key: YOUR_OTEL_COLLECTOR_ENDPOINT + +config: + receivers: + # Configures additional kubelet metrics + kubeletstats: + collection_interval: 20s + auth_type: 'serviceAccount' + endpoint: '${env:K8S_NODE_NAME}:10250' + insecure_skip_verify: true + metrics: + k8s.pod.cpu_limit_utilization: + enabled: true + k8s.pod.cpu_request_utilization: + enabled: true + k8s.pod.memory_limit_utilization: + enabled: true + k8s.pod.memory_request_utilization: + enabled: true + k8s.pod.uptime: + enabled: true + k8s.node.uptime: + enabled: true + k8s.container.cpu_limit_utilization: + enabled: true + k8s.container.cpu_request_utilization: + enabled: true + k8s.container.memory_limit_utilization: + enabled: true + k8s.container.memory_request_utilization: + enabled: true + container.uptime: + enabled: true + + exporters: + otlphttp: + endpoint: "${env:YOUR_OTEL_COLLECTOR_ENDPOINT}" + compression: gzip + headers: + authorization: "${env:HYPERDX_API_KEY}" + + service: + pipelines: + logs: + exporters: + - otlphttp + metrics: + exporters: + - otlphttp +``` + +
+ +### 在 HyperDX 中探索 Kubernetes 数据 {#explore-kubernetes-data-hyperdx} + +导航到您的 HyperDX UI - 使用您 Kubernetes 部署的实例或通过 ClickHouse Cloud。 + +

+

+使用 ClickHouse Cloud + +如果使用 ClickHouse Cloud,只需登录到您的 ClickHouse Cloud 服务,并从左侧菜单中选择 "HyperDX"。您将被自动认证,不需要创建用户。 + +当提示创建数据源时,保留创建源模型中的所有默认值,在表字段中填写值 `otel_logs` - 以创建一个日志源。所有其他设置应被自动检测,您可以点击 `Save New Source`。 + + + +您还需要为跟踪和指标创建数据源。 + +例如,要为跟踪和 OTel 指标创建源,用户可以从顶部菜单中选择 `Create New Source`。 + + + +从这里,选择所需的源类型,然后选择相应的表,例如对于跟踪,选择表 `otel_traces`。所有设置应被自动检测。 + + + +:::note 关联源 +请注意,在 ClickStack 中不同的数据源—例如日志和跟踪—可以彼此关联。要启用此功能,每个源需要额外配置。例如,在日志源中,您可以指定相应的跟踪源,而在跟踪源中反之亦然。有关详细信息,请参见 "关联源"。 +::: + +
+ +
+ +使用自管理部署 + +要访问本地部署的 HyperDX,您可以使用本地命令进行端口转发,并访问 HyperDX,地址为 [http://localhost:8080](http://localhost:8080)。 + +```shell +kubectl port-forward \ + pod/$(kubectl get pod -l app.kubernetes.io/name=hdx-oss-v2 -o jsonpath='{.items[0].metadata.name}' -n otel-demo) \ + 8080:3000 \ + -n otel-demo +``` + +:::note ClickStack 生产环境 +在生产环境中,如果您不在 ClickHouse Cloud 中使用 HyperDX,建议使用 TLS 的 ingress。例如: + +```shell +helm upgrade my-hyperdx hyperdx/hdx-oss-v2 \ +--set hyperdx.ingress.enabled=true \ +--set hyperdx.ingress.host=your-domain.com \ +--set hyperdx.ingress.tls.enabled=true +``` +:::: + +
+ +要探索 Kubernetes 数据,导航到专用仪表板 `/kubernetes`,例如 [http://localhost:8080/kubernetes](http://localhost:8080/kubernetes)。 + +每个选项卡,Pods、Nodes 和 Namespaces,都应该填充数据。 + +
+ + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/example-datasets/kubernetes.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/example-datasets/kubernetes.md.hash new file mode 100644 index 00000000000..d65175201a0 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/example-datasets/kubernetes.md.hash @@ -0,0 +1 @@ +254059999c5b5042 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/example-datasets/local-data.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/example-datasets/local-data.md index ebe8c6dda9c..e83fc99ddf6 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/example-datasets/local-data.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/example-datasets/local-data.md @@ -4,7 +4,8 @@ 'sidebar_position': 1 'pagination_prev': null 'pagination_next': null -'description': '开始使用 ClickStack 的本地和系统数据以及指标' +'description': '开始使用 ClickStack 本地和系统数据以及指标' +'doc_type': 'guide' --- import Image from '@theme/IdealImage'; @@ -17,31 +18,39 @@ import hyperdx_22 from '@site/static/images/use-cases/observability/hyperdx-22.p import hyperdx_23 from '@site/static/images/use-cases/observability/hyperdx-23.png'; import copy_api_key from '@site/static/images/use-cases/observability/copy_api_key.png'; -This getting started guide allows you collect local logs and metrics from your system, sending them to ClickStack for visualization and analysis. +这个入门指南允许您收集系统中的本地日志和指标,并将其发送到 ClickStack 进行可视化和分析。 -**此示例仅适用于 OS X 和 Linux 系统** +**此示例仅在 OSX 和 Linux 系统上有效** -The following example assumes you have started ClickStack using the [instructions for the all-in-one image](/use-cases/observability/clickstack/getting-started) and connected to the [local ClickHouse instance](/use-cases/observability/clickstack/getting-started#complete-connection-credentials) or a [ClickHouse Cloud instance](/use-cases/observability/clickstack/getting-started#create-a-cloud-connection). +以下示例假设您已根据[一体化镜像的说明](/use-cases/observability/clickstack/getting-started)启动了 ClickStack,并连接到[本地 ClickHouse 实例](/use-cases/observability/clickstack/getting-started#complete-connection-credentials)或[ClickHouse Cloud 实例](/use-cases/observability/clickstack/getting-started#create-a-cloud-connection)。 + +:::note HyperDX 在 ClickHouse Cloud 中 +此示例数据集也可与 HyperDX 在 ClickHouse Cloud 中一起使用,仅需对流程进行少量调整。如果在 ClickHouse Cloud 中使用 HyperDX,则用户需要本地运行 Open Telemetry 收集器,如[此部署模型的入门指南](/use-cases/observability/clickstack/deployment/hyperdx-clickhouse-cloud)中所述。 +::: -## Navigate to the HyperDX UI {#navigate-to-the-hyperdx-ui} +## 导航到 HyperDX UI {#navigate-to-the-hyperdx-ui} + +访问 [http://localhost:8080](http://localhost:8080) 以访问本地部署的 HyperDX UI。如果在 ClickHouse Cloud 中使用 HyperDX,请从左侧菜单中选择您的服务和 `HyperDX`。 -Visit [http://localhost:8080](http://localhost:8080) to access the HyperDX UI. +## 复制数据摄取 API 密钥 {#copy-ingestion-api-key} -## Copy ingestion API key {#copy-ingestion-api-key} +:::note HyperDX 在 ClickHouse Cloud 中 +如果使用 HyperDX 在 ClickHouse Cloud 中,则此步骤不是必需的。 +::: -Navigate to [`Team Settings`](http://localhost:8080/team) and copy the `Ingestion API Key` from the `API Keys` section. This API key ensures data ingestion through the OpenTelemetry collector is secure. +导航到 [`团队设置`](http://localhost:8080/team) 并从 `API 密钥` 部分复制 `数据摄取 API 密钥`。此 API 密钥确保通过 OpenTelemetry 收集器进行数据摄取的安全。 - + -## Create a local OpenTelemetry configuration {#create-otel-configuration} +## 创建本地 OpenTelemetry 配置 {#create-otel-configuration} -Create a `otel-file-collector.yaml` file with the following content. +创建一个名为 `otel-local-file-collector.yaml` 的文件,内容如下。 -**重要**: Populate the value `` with your ingestion API key copied above. +**重要**:将值 `` 替换为您上述复制的数据摄取 API 密钥(在 ClickHouse Cloud 中的 HyperDX 不需要)。 -```yml +```yaml receivers: filelog: include: @@ -49,6 +58,7 @@ receivers: - /var/log/syslog - /var/log/messages - /private/var/log/*.log # macOS + - /tmp/all_events.log # macos - see below start_at: beginning # modify to collect new files only hostmetrics: @@ -107,62 +117,66 @@ service: exporters: [otlp] ``` -This configuration collects system logs and metric for OSX and Linux systems, sending the results to ClickStack via the OTLP endpoint on port 4317. +该配置会收集 OSX 和 Linux 系统的系统日志和指标,通过 OTLP 端点在 4317 端口将结果发送到 ClickStack。 -:::note Ingestion timestamps -This configuration adjusts timestamps at ingest, assigning an updated time value to each event. Users should ideally [preprocess or parse timestamps](/use-cases/observability/clickstack/ingesting-data/otel-collector#processing-filtering-transforming-enriching) using OTel processors or operators in their log files to ensure accurate event time is retained. +:::note 摄取时间戳 +该配置在摄取时调整时间戳,为每个事件分配更新的时间值。用户理想情况下应该使用 OTel 处理器或操作符在日志文件中[预处理或解析时间戳](/use-cases/observability/clickstack/ingesting-data/otel-collector#processing-filtering-transforming-enriching),以确保保留准确的事件时间。 -With this example setup, if the receiver or file processor is configured to start at the beginning of the file, all existing log entries will be assigned the same adjusted timestamp - the time of processing rather than the original event time. Any new events appended to the file will receive timestamps approximating their actual generation time. +在此示例设置中,如果接收器或文件处理器配置为从文件的开头开始,则所有现有日志条目将被分配相同的调整时间戳——处理时间而不是原始事件时间。任何追加到文件的新事件将获得接近其实际生成时间的时间戳。 -To avoid this behavior, you can set the start position to `end` in the receiver configuration. This ensures only new entries are ingested and timestamped near their true arrival time. +要避免这种行为,可以在接收器配置中将起始位置设置为 `end`。这确保仅摄取并时间标记新的条目,接近其真实到达时间。 ::: -For more details on the OpenTelemetry (OTel) configuration structure, we recommend [the official guide](https://opentelemetry.io/docs/collector/configuration/). +有关 OpenTelemetry (OTel) 配置结构的更多详细信息,我们建议查看[官方指南](https://opentelemetry.io/docs/collector/configuration/)。 + +:::note OSX 的详细日志 +希望在 OSX 上获取更详细日志的用户可以在启动下面的收集器之前运行命令 `log stream --debug --style ndjson >> /tmp/all_events.log`。这将捕获详细的操作系统日志到文件 `/tmp/all_events.log`,该文件已包含在上述配置中。 +::: -## Start the collector {#start-the-collector} +## 启动收集器 {#start-the-collector} -Run the following docker command to start an instance of the OTel collector. +运行以下 Docker 命令以启动 OTel 收集器的实例。 -```bash +```shell docker run --network=host --rm -it \ --user 0:0 \ - -v "$(pwd)/otel-file-collector.yaml":/etc/otel/config.yaml \ + -v "$(pwd)/otel-local-file-collector.yaml":/etc/otel/config.yaml \ -v /var/log:/var/log:ro \ -v /private/var/log:/private/var/log:ro \ otel/opentelemetry-collector-contrib:latest \ --config /etc/otel/config.yaml ``` -:::note Root user -We run the collector as the root user to access all system logs—this is necessary to capture logs from protected paths on Linux-based systems. However, this approach is not recommended for production. In production environments, the OpenTelemetry Collector should be deployed as a local agent with only the minimal permissions required to access the intended log sources. +:::note 根用户 +我们以根用户身份运行收集器,以访问所有系统日志——这在 Linux 系统上捕获受保护路径的日志是必要的。然而,这种方法不推荐用于生产环境。在生产环境中,OpenTelemetry 收集器应该作为本地代理部署,只需具有必要的最小权限以访问预定的日志源。 ::: -The collector will immediately begin collecting local system logs and metrics. +收集器将立即开始收集本地系统日志和指标。 -## Explore system logs {#explore-system-logs} +## 浏览系统日志 {#explore-system-logs} -Navigate to the HyperDX UI. The search UI should be populated with local system logs. Expand the filters to select the `system.log`: +导航到 HyperDX UI。搜索 UI 应该填充本地系统日志。扩展过滤器以选择 `system.log`: - + -## Explore system metrics {#explore-system-metrics} +## 浏览系统指标 {#explore-system-metrics} -We can explore our metrics using charts. +我们可以通过图表浏览我们的指标。 -Navigate to the Chart Explorer via the left menu. Select the source `Metrics` and `Maximum` as the aggregation type. +通过左侧菜单导航到图表浏览器。选择源 `Metrics` 和聚合类型 `Maximum`。 -For the `Select a Metric` menu simply type `memory` before selecting `system.memory.utilization (Gauge)`. +在 `选择指标` 菜单中简单输入 `memory`,然后选择 `system.memory.utilization (Gauge)`。 -Press the run button to visualize your memory utilization over time. +按运行按钮以可视化您的内存使用情况随时间的变化。 - + -Note the number is returned as a floating point `%`. To render it more clearly, select `Set number format`. +请注意,数字以浮点 `%` 形式返回。为了清晰呈现,选择 `设置数字格式`。 - + -From the subsequent menu you can select `Percentage` from the `Output format` drop down before clicking `Apply`. +在后续菜单中,您可以从 `输出格式` 下拉菜单中选择 `百分比`,然后单击 `应用`。 - + diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/example-datasets/local-data.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/example-datasets/local-data.md.hash index f0daba88a3b..b3b13629328 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/example-datasets/local-data.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/example-datasets/local-data.md.hash @@ -1 +1 @@ -606be5301b282f4d +082fdf86b69a9fc4 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/example-datasets/remote-demo-data.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/example-datasets/remote-demo-data.md index 8106301f201..58664873ee3 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/example-datasets/remote-demo-data.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/example-datasets/remote-demo-data.md @@ -5,6 +5,7 @@ 'pagination_prev': null 'pagination_next': null 'description': '开始使用 ClickStack 和远程演示数据集' +'doc_type': 'guide' --- import Image from '@theme/IdealImage'; @@ -34,280 +35,280 @@ import step_21 from '@site/static/images/use-cases/observability/hyperdx-demo/st import step_22 from '@site/static/images/use-cases/observability/hyperdx-demo/step_22.png'; import step_23 from '@site/static/images/use-cases/observability/hyperdx-demo/step_23.png'; import step_24 from '@site/static/images/use-cases/observability/hyperdx-demo/step_24.png'; -import architecture from '@site/static/images/use-cases/observability/hyperdx-demo/architecture.png'; import demo_sources from '@site/static/images/use-cases/observability/hyperdx-demo//demo_sources.png'; import edit_connection from '@site/static/images/use-cases/observability/edit_connection.png'; +import DemoArchitecture from '@site/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/example-datasets/_snippets/_demo.md'; -**以下指南假设您已使用 [一体化镜像的说明](/use-cases/observability/clickstack/getting-started) 或 [仅本地模式](/use-cases/observability/clickstack/deployment/local-mode-only) 部署了 ClickStack,并完成了初始用户创建。** +**以下指南假定您已使用[一体化镜像说明](/use-cases/observability/clickstack/getting-started)或[仅本地模式](/use-cases/observability/clickstack/deployment/local-mode-only)部署了ClickStack,并完成了初始用户创建。或者,用户可以跳过所有本地设置,直接连接到我们托管的ClickStack演示[play-clickstack.clickhouse.com](https://play-clickstack.clickhouse.com),该演示使用此数据集。** -本入门指南使用一个可在演示服务器上访问的数据集,该数据集在用户首次部署 HyperDX 时可以使用。该数据集托管在公共 ClickHouse 实例上,网址为 [sql.clickhouse.com](https://sql.clickhouse.com)。 +本指南使用在公共ClickHouse游乐场上托管的示例数据集,可以从您的本地ClickStack部署连接到该数据集:[sql.clickhouse.com](https://sql.clickhouse.com)。 -它包含从 ClickHouse 版本的官方 OpenTelemetry(OTel)演示中捕获的大约 40 小时的数据。数据每晚重放,时间戳调整为当前时间窗口,允许用户利用 HyperDX 的集成日志、跟踪和指标来探索系统行为。 - -:::note 数据变体 -由于数据集从每天午夜重放,因此确切的可视化效果可能会因您探索演示的时间而异。 +:::warning 在ClickHouse Cloud中不支持HyperDX +当HyperDX托管在ClickHouse Cloud时,不支持远程数据库。因此,此数据集不受支持。 ::: -## 演示场景 {#demo-scenario} +该数据集包含大约40小时的数据,这些数据是从ClickHouse版本的官方OpenTelemetry (OTel)演示中捕获的。数据在晚上重播,时间戳调整为当前时间范围,允许用户使用HyperDX集成的日志、跟踪和指标来探索系统行为。 -在本次演示中,我们调查一个涉及销售望远镜及相关配件的电子商务网站的事件。 +:::note 数据变化 +由于数据集每天从午夜开始重播,确切的可视化可能会根据您何时探索演示而有所不同。 +::: -客户支持团队报告称,用户在结帐时遇到支付完成问题。该问题已上报给网站可靠性工程(SRE)团队进行调查。 +## 演示场景 {#demo-scenario} -SRE 团队将使用 HyperDX 分析日志、跟踪和指标来诊断和解决问题,然后审查会话数据,以确认他们的结论是否与实际用户行为一致。 +在此演示中,我们调查一个涉及销售望远镜及相关配件的电子商务网站的事件。 -## 演示架构 {#demo-architecture} +客户支持团队报告用户在结账时遇到完成付款的问题。该问题已升级至网站可靠性工程(SRE)团队进行调查。 -此演示重用官方 OpenTelemetry 演示。它由用不同编程语言编写的微服务组成,这些微服务通过 gRPC 和 HTTP 相互通信,还有一个使用 Locust 生成虚拟用户流量的负载生成器。 +使用HyperDX,SRE团队将分析日志、跟踪和指标以诊断和解决问题,然后审查会话数据以确认他们的结论是否与实际用户行为一致。 - +## Open Telemetry演示 {#otel-demo} -_版权: https://opentelemetry.io/docs/demo/architecture/_ +此演示使用[ClickStack维护的官方OpenTelemetry演示的分支](https://github.com/ClickHouse/opentelemetry-demo)。 -有关演示的更多细节,请参阅 [官方 OpenTelemetry 文档](https://opentelemetry.io/docs/demo/)。 + ## 演示步骤 {#demo-steps} -**我们已经使用 [ClickStack SDKs](/use-cases/observability/clickstack/sdks) 对此次演示进行了注入,在 Kubernetes 中部署了服务,并收集了指标和日志。** +**我们已使用[ClickStack SDKs](/use-cases/observability/clickstack/sdks)为本演示进行了仪器化,服务已在Kubernetes中部署,并收集了指标和日志。** ### 连接到演示服务器 {#connect-to-the-demo-server} :::note 仅本地模式 -如果您在本地模式中部署时点击了 `连接到演示服务器`,可以跳过此步骤。如果使用此模式,数据源将以 `Demo_` 为前缀,例如 `Demo_Logs` +如果您在本地模式下部署时单击了`连接到演示服务器`,则可以跳过此步骤。如果使用此模式,数据源将以`Demo_`为前缀,例如`Demo_Logs`。 ::: -导航到 `团队设置` 并点击 `编辑` 以修改 `本地连接`: +导航到`团队设置`,并单击`编辑`以修改`本地连接`: -将连接名称更改为 `Demo`,并按照以下演示服务器的连接详细信息填写后续表单: +将连接重命名为`Demo`,并填写后续表单,使用以下演示服务器的连接详细信息: -- `连接名称`: `Demo` -- `主机`: `https://sql-clickhouse.clickhouse.com` -- `用户名`: `otel_demo` -- `密码`: 保持为空 +- `连接名称`:`Demo` +- `主机`:`https://sql-clickhouse.clickhouse.com` +- `用户名`:`otel_demo` +- `密码`:保留为空 ### 修改数据源 {#modify-sources} :::note 仅本地模式 -如果您在本地模式中部署时点击了 `连接到演示服务器`,可以跳过此步骤。如果使用此模式,数据源将以 `Demo_` 为前缀,例如 `Demo_Logs` +如果您在本地模式下部署时单击了`连接到演示服务器`,则可以跳过此步骤。如果使用此模式,数据源将以`Demo_`为前缀,例如`Demo_Logs`。 ::: -向上滚动到 `数据源`,并修改每个数据源 `日志`、`跟踪`、`指标` 和 `会话`,使其使用 `otel_v2` 数据库。 +向上滚动到`数据源`,并修改每个数据源——`日志`、`跟踪`、`指标`和`会话`——以使用`otel_v2`数据库。 :::note -您可能需要重新加载页面,以确保每个数据源中列出所有数据库。 +您可能需要重新加载页面以确保每个数据源中列出了完整的数据库列表。 ::: ### 调整时间范围 {#adjust-the-timeframe} -使用右上角的时间选择器,将时间调整为显示过去 `1天` 的所有数据。 +使用右上角的时间选择器,将时间调整为显示过去`1天`的所有数据。 -您可能会在概述条形图中观察到错误数量的微小差异,多根连续条形中的红色部分有所增加。 +您可能会注意到概述条形图中错误数量的微小差异,在几个连续的条形图中红色有所增加。 :::note -条形图的位置可能因您查询数据集的时间而有所不同。 +条形图的位置将根据您查询数据集的时间而有所不同。 ::: -### 过滤错误 {#filter-to-errors} +### 筛选错误 {#filter-to-errors} -为了突出错误的发生,请使用 `SeverityText` 过滤器并选择 `错误`,以仅显示错误级别的条目。 +为了突出错误的发生,使用`SeverityText`过滤器并选择`error`,仅显示错误级别的条目。 -错误应该更加明显: +错误应更加明显: ### 识别错误模式 {#identify-error-patterns} -借助 HyperDX 的聚类功能,您可以自动识别错误并将其分组为有意义的模式。这在处理大量日志和跟踪时加速了用户分析。要使用此功能,请从左侧面板的 `分析模式` 菜单中选择 `事件模式`。 +通过HyperDX的聚类功能,您可以自动识别错误并将其分组为有意义的模式。这加速了在处理大量日志和跟踪时的用户分析。要使用此功能,请从左侧面板的`分析模式`菜单中选择`事件模式`。 -错误集群揭示了与支付失败相关的问题,包括一个名为 `未能下订单` 的模式。附加集群还表明存在信用卡收费和缓存已满的问题。 +错误聚类显示与支付失败相关的问题,包括命名模式`无法下订单`。其他聚类还表明存在收费和缓存满的问题。 -请注意,这些错误集群可能源自不同的服务。 +请注意,这些错误聚类可能来自不同服务。 ### 探索错误模式 {#explore-error-pattern} -点击最明显的错误集群,它与我们报告的用户能够完成支付的问题相关:`未能下订单`。 +单击与我们报告的用户无法完成付款问题相关的最明显错误聚类:`无法下订单`。 -这将显示与 `前端` 服务关联的此错误的所有发生实例的列表: +这将显示与`frontend`服务相关的此错误的所有发生列表: -选择任何一个结果错误。日志元数据将详细显示。向下滚动 `概览` 和 `列值`,表明由于缓存问题导致的信用卡收费失败: +选择任何结果错误。日志元数据将详细显示。浏览`概述`和`列值`部分表明,由于缓存问题导致收费卡的问题: -`未能收费:无法收费信用卡:rpc 错误:代码 = Unknown 描述 = Visa 缓存已满:无法添加新项目。` +`失败充卡:无法充卡:rpc错误:代码=未知描述=Visa缓存已满:无法添加新项目。` -### 探索基础设施 {#explore-the-infrastructure} +### 探索基础架构 {#explore-the-infrastructure} -我们已识别出与缓存相关的错误,这可能导致支付失败。我们仍需要确定此问题在我们的微服务架构中来源于哪里。 +我们已确定一个与缓存相关的错误可能导致支付失败。我们仍需确定此问题在我们的微服务架构中来自何处。 -鉴于缓存问题,调查基础设施是合乎逻辑的 - 可能我们在相关 Pods 中存在内存问题?在 ClickStack 中,日志和指标是统一的,并在上下文中显示,使快速查找根本原因变得更加容易。 +考虑到缓存问题,调查基础架构是有意义的——关联的pod中是否可能存在内存问题?在ClickStack中,日志和指标是统一的并且以上下文方式显示,使得快速发现根本原因变得更加容易。 -选择 `基础设施` 标签以查看与 `前端` 服务的底层 Pods 相关的指标,并扩大时间范围至 `1天`: +选择`基础架构`标签以查看与`frontend`服务相关的基础架构pod的指标,并将时间范围扩大到`1d`: -问题似乎与基础设施无关 - 在该时间段内没有指标显著变化:无论是在错误发生之前还是之后。关闭基础设施标签。 +该问题似乎与基础架构无关 - 在错误发生的时间段内,没有指标显著变化:之前或之后。关闭基础架构标签。 ### 探索跟踪 {#explore-a-trace} -在 ClickStack 中,跟踪也会自动与日志和指标相关联。让我们探索与我们选择的日志相关的跟踪,以识别责任服务。 +在ClickStack中,跟踪也会自动与日志和指标相关联。让我们探索与我们的选择日志相关的跟踪,以识别负责的服务。 -选择 `跟踪` 以可视化相关跟踪。向下滚动,通过后续视图,我们可以看到 HyperDX 如何能够在微服务之间可视化分布式跟踪,连接每个服务中的跨度。一次支付明显涉及多个微服务,包括执行结账和货币转换的服务。 +选择`跟踪`以可视化相关的跟踪。向下滚动浏览后续视图,我们可以看到HyperDX如何能够在微服务中可视化分布式跟踪,连接每个服务中的跨度。一个支付显然涉及多个微服务,包括处理结账和货币转换的服务。 -向下滚动到视图底部,我们可以看到 `支付` 服务导致了错误,这反过来又向上传播至调用链。 +向下滚动该视图的底部,我们可以看到`payment`服务导致了错误,导致错误回溯。 -### 搜索跟踪 {#searching-traces} +### 搜索跟踪 {#searching-traces} -我们已经确定用户由于支付服务中的缓存问题未能完成购买。让我们更详细地探索此服务的跟踪,以查看是否可以了解更多关于根本原因的信息。 +我们已确定用户因支付服务中的缓存问题无法完成购买。让我们更详细地探索此服务的跟踪,以了解根本原因。 -通过选择 `搜索` 切换到主搜索视图。为 `跟踪` 切换数据源,选择 `结果表` 视图。**确保时间跨度仍然在过去一天内。** +通过选择`搜索`切换到主要搜索视图。切换`Traces`的数据源,并选择`结果表`视图。**确保时间段仍然覆盖过去一天。** -该视图显示了过去一天内的所有跟踪。我们知道问题起源于支付服务,因此将 `ServiceName` 过滤器应用于 `支付`。 +该视图显示过去一天的所有跟踪。我们知道问题来源于我们的支付服务,因此将`支付`过滤器应用于`ServiceName`。 -如果我们选择 `事件模式` 对跟踪应用事件聚类,我们可以立刻看到支付服务中的缓存问题。 +如果我们通过选择`事件模式`将事件聚类应用于跟踪,我们可以立即看到与`支付`服务相关的缓存问题。 -### 为跟踪探索基础设施 {#explore-infrastructure-for-a-trace} +### 探索跟踪的基础架构 {#explore-infrastructure-for-a-trace} -通过单击 `结果表` 切换到结果视图。使用 `StatusCode` 过滤器和 `错误` 值进行错误过滤。 +通过单击`结果表`切换到结果视图。使用`StatusCode`过滤器和`错误`值筛选错误。 -选择 `错误:Visa 缓存已满:无法添加新项目。` 错误,切换到 `基础设施` 标签并将时间跨度扩大至 `1天`。 +选择一个`错误:Visa缓存已满:无法添加新项目。`错误,切换到`基础架构`标签并将时间段扩大到`1d`。 -通过将跟踪与指标关联,我们可以看到内存和 CPU 随着 `支付` 服务的增加而上升,然后下降到 `0`(我们可以将其归因于 Pod 重启) - 这表明缓存问题引发了资源问题。我们可以预期这影响了支付完成时间。 +通过将跟踪与指标关联,我们可以看到`payment`服务的内存和CPU在崩溃之前增加到`0`(我们可以将此归因于pod重启)—暗示缓存问题导致资源问题。我们可以预期这影响了支付完成的时间。 -### 事件增量以加快解决时间 {#event-deltas-for-faster-resolution} +### 事件增量以加快解决 {#event-deltas-for-faster-resolution} -事件增量通过将性能或错误率的变化归因于特定数据子集,帮助揭示异常 - 使快速定位根本原因变得更容易。 +事件增量通过将性能或错误率的变化归因于特定的数据子集来帮助发现异常——使得更容易快速找到根本原因。 -虽然我们知道 `支付` 服务存在缓存问题,导致资源消耗增加,但我们尚未完全确定根本原因。 +虽然我们知道`payment`服务存在缓存问题,导致资源消耗增加,但尚未完全识别根本原因。 -返回结果表视图,选择包含错误的时间段以限制数据。确保您选择错误之前和之后的若干小时(问题可能仍在发生): +返回到结果表视图,选择包含错误的时间段以限制数据。确保您选择错误左侧和错误之后的几个小时(该问题可能仍在发生): -移除错误过滤器,并从左侧 `分析模式` 菜单中选择 `事件增量`。 +移除错误过滤器,然后从左侧的`分析模式`菜单中选择`事件增量`。 -顶部面板显示了时间分布,颜色指示事件密度(跨度的数量)。主要集中之外的事件子集通常是值得调查的。 +顶部面板显示时间分布,颜色表示事件密度(跨度数量)。主要集中之外的事件子集通常是值得调查的。 -如果我们选择持续时间大于 `200ms` 的事件,并应用 `按选择过滤` 的过滤器,我们可以将分析限制在较慢的事件: +如果我们选择持续时间大于`200ms`的事件,并应用过滤器`按选择过滤`,我们可以将分析限制为较慢的事件: -对数据子集进行分析后,我们可以看到大多数性能峰值都与 `visa` 交易相关。 +通过对数据子集进行分析,我们可以看到大多数性能尖峰与`visa`交易相关。 -### 使用图表获取更多上下文 {#using-charts-for-more-context} +### 使用图表以获得更多上下文 {#using-charts-for-more-context} -在 ClickStack 中,我们可以从日志、跟踪或指标中图示任何数值,以获取更多的上下文。 +在ClickStack中,我们可以从日志、跟踪或指标中绘制任何数值以获得更多上下文。 -我们已确立: +我们已确定: -- 我们的问题出在支付服务 -- 缓存已满 +- 我们的问题出在支付服务上 +- 一个缓存已满 - 这导致资源消耗增加 -- 该问题阻止了 Visa 支付的完成 - 或至少导致其完成时间很长。 +- 该问题阻止了Visa支付完成——或者至少导致其完成时间过长。
-从左侧菜单中选择 `图表浏览器`。填写以下值以按照图表类型显示支付完成所需的时间: +从左侧菜单中选择`图表浏览器`。完成以下值以按图表类型绘制支付完成所需时间: -- `数据源`: `跟踪` -- `指标`: `最大` -- `SQL 列`: `持续时间` -- `条件`: `ServiceName: payment` -- `时间段`: `过去 1 天` +- `数据源`:`Traces` +- `指标`:`最大值` +- `SQL列`:`持续时间` +- `条件`:`ServiceName: payment` +- `时间跨度`:`过去1天`
-点击 `▶️` 会显示支付性能随时间的减退情况。 +单击`▶️`将显示支付性能随时间的下降情况。 -如果我们将 `分组依据` 设置为 `SpanAttributes['app.payment.card_type']`(只需输入 `card` 进行自动完成功能),我们可以看到与万事达卡相比,Visa 交易的服务性能如何衰退: +如果我们将`按`设置为`SpanAttributes['app.payment.card_type']`(只需键入`card`以自动完成),我们可以看到Visa交易相对于万事达卡交易的服务性能如何下降: -注意,一旦出现错误,响应会以 `0s` 返回。 +请注意,一旦出现错误,响应返回时间为`0s`。 -### 更深入探索指标的上下文 {#exploring-metrics-for-more-context} +### 探索指标以获得更多上下文 {#exploring-metrics-for-more-context} -最后,让我们将缓存大小作为指标绘图,以查看它随时间的变化,从而提供更好的上下文。 +最后,让我们将缓存大小绘制为指标,以查看其随时间的变化,从而为我们提供更多上下文。 -填写以下值: +完成以下值: -- `数据源`: `指标` -- `指标`: `最大` -- `SQL 列`: `visa_validation_cache.size (gauge)`(只需输入 `cache` 进行自动完成功能) -- `条件`: `ServiceName: payment` -- `分组依据`: `` +- `数据源`:`Metrics` +- `指标`:`最大值` +- `SQL列`:`visa_validation_cache.size (gauge)`(只需键入`cache`以自动完成) +- `条件`:`ServiceName: payment` +- `按`:`` -我们可以看到缓存大小在 4-5 小时内增加(可能是在软件部署后),然后达到最大值 `100,000`。通过 `匹配事件示例`,我们可以看到我们的错误与缓存达到此限制相关,之后记录的大小为 `0`,响应也返回为 `0s`。 +我们可以看到缓存大小在4-5小时内增加(可能是在软件部署之后),然后达到最大大小`100,000`。从`匹配事件示例`中可以看到,我们的错误与缓存达到此限制相关,其中记录为`0`的大小,同时响应也返回为`0s`。 -总之,通过探索日志、跟踪和最后的指标,我们得出以下结论: +总结,通过探索日志、跟踪的最后指标,我们得出以下结论: -- 我们的问题出在支付服务 -- 由于可能的部署,服务行为发生变化,导致 Visa 缓存在 4-5 小时内缓慢增加 - 达到最大值 `100,000`。 -- 这导致缓存增长时资源消耗增加 - 很可能由于实现不佳 -- 随着缓存的增长,Visa 支付的性能下降 -- 当达到最大尺寸时,缓存拒绝支付并报告其大小为 `0`。 +- 我们的问题出在支付服务上 +- 服务行为的变化,可能是由于部署,导致Visa缓存在4-5小时内逐渐增加,达到最大大小`100,000`。 +- 这导致随着缓存大小的增长资源消耗增加——可能是由于一个糟糕的实现 +- 随着缓存的增长,Visa支付的性能下降 +- 当达到最大大小时,缓存拒绝支付并报告其大小为`0`。 -### 使用会话 {#using-sessions} +### 使用会话 {#using-sessions} -会话让我可以重播用户体验,从用户的角度提供有关错误如何发生的可视化说明。尽管通常不用于诊断根本原因,但它们在确认客户支持报告的问题时很有价值,还可以作为更深入调查的起点。 +会话允许我们重放用户体验,从用户的角度提供有关错误发生方式的可视化说明。虽然通常不用于诊断根本原因,但它们对确认客户支持报告的问题非常有价值,并可作为更深入调查的起点。 -在 HyperDX 中,会话与跟踪和日志相关联,提供有关根本原因的完整视图。 +在HyperDX中,会话与跟踪和日志相关联,提供对根本原因的完整视图。 -例如,如果支持团队提供了遇到支付问题的用户电子邮件 `Braulio.Roberts23@hotmail.com`,通常更有效的做法是先查看他们的会话,而不是直接搜索日志或跟踪。 +例如,如果支持团队提供了遇到付款问题的用户的电子邮件`Braulio.Roberts23@hotmail.com`——从他们的会话开始通常比直接搜索日志或跟踪更有效。 -从左侧菜单导航到 `客户端会话` 标签,确保数据源设置为 `会话`,时间范围设置为 `过去 1天`: +从左侧菜单导航到`客户会话`标签,确保数据源设置为`会话`,时间段设置为`过去1天`: -搜索 `SpanAttributes.userEmail: Braulio` 找到我们的客户会话。选择该会话将显示该客户会话的浏览器事件和关联跨度在左侧,用户的浏览器体验将重新渲染在右侧: +搜索`SpanAttributes.userEmail: Braulio`以找到我们客户的会话。选择该会话将显示左侧客户会话的浏览器事件和相关跨度,同时右侧重新渲染用户的浏览器体验: -### 重播会话 {#replaying-sessions} +### 重放会话 {#replaying-sessions} -通过按 ▶️ 按钮来重播会话。在 `高亮` 和 `所有事件` 之间切换,允许不同程度的跨度粒度,其中前者突出显示关键事件和错误。 +通过按 ▶️ 按钮重放会话。切换`高亮`和`所有事件`之间可以实现不同程度的跨度粒度,前者突出显示关键事件和错误。 -如果我们向下滚动到跨度的底部,可以看到一个与 `/api/checkout` 相关的 `500` 错误。为这个特定跨度按 ▶️ 按钮将重播移动到会话的这一点,让我们确认客户体验 - 支付似乎就是无法完成,没有错误显示。 +如果我们向下滚动到跨度的底部,我们可以看到与`/api/checkout`相关的`500`错误。选择该特定跨度的▶️按钮将回放移动到会话中的这一点,让我们确认客户的体验——付款似乎无法成功,并且没有错误显示。 -选择这个跨度我们可以确认这是由内部错误引起的。通过点击 `跟踪` 标签并滚动浏览连接的跨度,我们能够确认客户确实是我们缓存问题的受害者。 +通过选择该跨度我们可以确认这是由内部错误引起的。通过单击`跟踪`标签并滚动连接的跨度,我们能够确认客户确实是我们的缓存问题的受害者。
-该演示通过处理电子商务应用中的支付失败事件,展示了 ClickStack 如何通过统一的日志、跟踪、指标和会话重播帮助揭示根本原因 - 探索我们的 [其他入门指南](/use-cases/observability/clickstack/sample-datasets),深入了解特定功能。 +本演示展示了一个真实世界事件,涉及电子商务应用中支付失败的问题,展示了ClickStack如何通过统一的日志、跟踪、指标和会话重放帮助发现根本原因——探索我们的[其他入门指南](/use-cases/observability/clickstack/sample-datasets),深入了解特定功能。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/example-datasets/remote-demo-data.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/example-datasets/remote-demo-data.md.hash index 11ca9509409..3a3bec1447a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/example-datasets/remote-demo-data.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/example-datasets/remote-demo-data.md.hash @@ -1 +1 @@ -3ee001a8e1f366c5 +fdfeea446d68bc0b diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/example-datasets/sample-data.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/example-datasets/sample-data.md index 75771974731..34d4c7b13c1 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/example-datasets/sample-data.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/example-datasets/sample-data.md @@ -5,6 +5,7 @@ 'pagination_prev': null 'pagination_next': null 'description': '开始使用 ClickStack 和一个包含日志、会话、跟踪和指标的示例数据集' +'doc_type': 'guide' --- import Image from '@theme/IdealImage'; @@ -32,19 +33,27 @@ import copy_api_key from '@site/static/images/use-cases/observability/copy_api_k # ClickStack - 示例日志、跟踪和指标 {#clickstack-sample-dataset} -以下示例假设您已经使用 [全功能图像的说明](/use-cases/observability/clickstack/getting-started) 启动了 ClickStack,并连接到 [本地 ClickHouse 实例](/use-cases/observability/clickstack/getting-started#complete-connection-credentials) 或 [ClickHouse Cloud 实例](/use-cases/observability/clickstack/getting-started#create-a-cloud-connection)。 +以下示例假设您已按照 [一体化镜像的说明](/use-cases/observability/clickstack/getting-started) 启动 ClickStack,并连接到 [本地 ClickHouse 实例](/use-cases/observability/clickstack/getting-started#complete-connection-credentials) 或 [ClickHouse Cloud 实例](/use-cases/observability/clickstack/getting-started#create-a-cloud-connection)。 + +:::note HyperDX 在 ClickHouse Cloud +此示例数据集也可以与 ClickHouse Cloud 中的 HyperDX 一起使用,仅需对流程进行稍微调整。如使用 ClickHouse Cloud 中的 HyperDX,用户需要本地运行 Open Telemetry 收集器,如 [此部署模型的入门指南](/use-cases/observability/clickstack/deployment/hyperdx-clickhouse-cloud) 中所述。 +::: -## 导航到 HyperDX UI {#navigate-to-the-hyperdx-ui} +## 导航至 HyperDX UI {#navigate-to-the-hyperdx-ui} -访问 [http://localhost:8080](http://localhost:8080) 以访问 HyperDX UI。 +如果在本地部署,请访问 [http://localhost:8080](http://localhost:8080) 以访问 HyperDX UI。如果在 ClickHouse Cloud 中使用 HyperDX,请从左侧菜单中选择您的服务和 `HyperDX`。 ## 复制摄取 API 密钥 {#copy-ingestion-api-key} -导航到 [`团队设置`](http://localhost:8080/team) 并从 `API 密钥` 部分复制 `摄取 API 密钥`。此 API 密钥确保通过 OpenTelemetry 收集器进行数据摄取的安全性。 +:::note HyperDX 在 ClickHouse Cloud +如果在 ClickHouse Cloud 中使用 HyperDX,此步骤并不是必需的,因为目前不支持摄取密钥。 +::: + +导航至 [`Team Settings`](http://localhost:8080/team),从 `API Keys` 部分复制 `Ingestion API Key`。此 API 密钥确保通过 OpenTelemetry 收集器的数据摄取是安全的。 @@ -54,7 +63,7 @@ import copy_api_key from '@site/static/images/use-cases/observability/copy_api_k [示例数据](https://storage.googleapis.com/hyperdx/sample.tar.gz) -```bash +```shell # curl curl -O https://storage.googleapis.com/hyperdx/sample.tar.gz @@ -64,23 +73,27 @@ curl -O https://storage.googleapis.com/hyperdx/sample.tar.gz # wget https://storage.googleapis.com/hyperdx/sample.tar.gz ``` -此文件包含来自我们公共 [OpenTelemetry 演示](http://example.com) 的示例日志、指标和跟踪——一个简单的微服务电子商务商店。将此文件复制到您选择的目录中。 +此文件包含我们的公共 [OpenTelemetry 演示](https://github.com/ClickHouse/opentelemetry-demo) 中的示例日志、指标和跟踪 - 一个简单的微服务电子商务商店。将此文件复制到您选择的目录中。 ## 加载示例数据 {#load-sample-data} -要加载这些数据,我们只需将其发送到已部署的 OpenTelemetry (OTel) 收集器的 HTTP 端点。 +要加载此数据,我们只需将其发送到已部署的 OpenTelemetry (OTel) 收集器的 HTTP 端点。 首先,导出上面复制的 API 密钥。 -```bash +:::note HyperDX 在 ClickHouse Cloud +如果在 ClickHouse Cloud 中使用 HyperDX,此步骤并不是必需的,因为目前不支持摄取密钥。 +::: + +```shell # export API key export CLICKSTACK_API_KEY= ``` -运行以下命令将数据发送到 OTel 收集器: +运行以下命令将数据发送至 OTel 收集器: -```bash +```shell for filename in $(tar -tf sample.tar.gz); do endpoint="http://localhost:4318/v1/${filename%.json}" echo "loading ${filename%.json}" @@ -93,77 +106,77 @@ for filename in $(tar -tf sample.tar.gz); do done ``` -这模拟了 OLTP 日志、跟踪和指标源将数据发送到 OTel 收集器。在生产环境中,这些源可能是语言客户端,甚至是其他 OTel 收集器。 +这模拟了 OTLP 日志、跟踪和指标源向 OTel 收集器发送数据。在生产环境中,这些源可以是语言客户端,甚至是其他 OTel 收集器。 -返回到 `搜索` 视图,您应该看到数据已经开始加载: +返回到 `Search` 视图,您应该看到数据已开始加载(如果数据未呈现,请将时间范围调整为 `Last 1 hour`): -数据加载将需要几分钟。在继续执行下一步之前,请确保加载已完成。 +数据加载将需要几分钟。请等待加载完成后再进行下一步。 ## 探索会话 {#explore-sessions} -假设我们收到报告,用户在支付商品时遇到问题。我们可以使用 HyperDX 的会话回放功能查看他们的体验。 +假设我们收到报告,用户在支付商品时遇到问题。我们可以使用 HyperDX 的会话重放功能查看他们的体验。 -从左侧菜单中选择 [`客户端会话`](http://localhost:8080/sessions?from=1747312320000&to=1747312920000&sessionSource=l1324572572)。 +从左侧菜单选择 [`Client Sessions`](http://localhost:8080/sessions?from=1747312320000&to=1747312920000&sessionSource=l1324572572)。 -此视图允许我们查看电子商务商店的前端会话。在用户结账并尝试完成购买之前,会话保持匿名。 +此视图允许我们查看电子商务商店的前端会话。会话在用户结账并尝试完成购买之前保持匿名。 -请注意,某些包含电子邮件的会话有一个关联的错误,可能确认了交易失败的报告。 +请注意,一些带有电子邮件的会话有相关错误,可能确认了未完成交易的报告。 -选择一个有故障和相关电子邮件的跟踪。随后的视图允许我们回放用户的会话并查看他们的问题。按播放观看会话。 +选择一个失败的跟踪和关联的电子邮件。随后视图允许我们重放用户的会话并审查他们的问题。按播放键观看会话。 -回放显示用户浏览网站、将商品添加到购物车。可以自由跳到会话后期,他们尝试完成支付。 +重放展示了用户浏览网站并将商品添加到购物车的过程。请随意跳到会话稍后的部分,他们尝试完成付款。 :::tip -任何错误都在时间轴上用红色标记。 +任何错误在时间线上都以红色注释。 ::: -用户无法下订单,没有明显的错误。向下滚动到左侧面板的底部,查看用户浏览器中的网络和控制台事件。您会注意到在进行 `/api/checkout` 调用时出现了 500 错误。 +用户无法下订单,没有明显的错误。向下滚动左侧面板,其中包含用户浏览器的网络和控制台事件。您会发现,在进行 `/api/checkout` 调用时抛出了一个 500 错误。 -选择此 `500` 错误。`概览` 和 `列值` 都没有指示问题的来源,除了这个错误是意料之外的,导致了 `内部错误`。 +选择此 `500` 错误。`Overview` 和 `Column Values` 皆未表明问题的根源,仅说明该错误是意外的,导致出现 `Internal Error`。 ## 探索跟踪 {#explore-traces} -导航到 `跟踪` 标签以查看完整的分布式跟踪。 +导航到 `Trace` 标签以查看完整的分布式跟踪。 -向下滚动跟踪以查看错误的来源——`checkout` 服务跨度。选择 `Payment` 服务跨度。 +向下滚动跟踪以查看错误的来源 - `checkout` 服务范围。选择 `Payment` 服务范围。 -选择 `列值` 标签并向下滚动。我们可以看到问题与缓存满有关。 +选择 `Column Values` 标签并向下滚动。我们可以看到问题与缓存已满有关。 -向上滚动并返回到跟踪,我们可以看到日志与跨度有关联,这得益于之前的配置。这些提供了进一步的背景。 +向上滚动并返回到跟踪,我们可以看到日志与范围相关联,这要归功于我们之前的配置。这些日志提供了进一步的上下文。 -我们已确定在支付服务中缓存正在被填满,这阻止了支付的完成。 +我们已经确定在支付服务中缓存溢出,阻止了支付完成。 ## 探索日志 {#explore-logs} -有关更多详细信息,我们可以返回到 [`搜索` 视图](http://localhost:8080/search): +为了获得更多细节,我们可以返回到 [`Search` 视图](http://localhost:8080/search): -从源中选择 `日志` 并应用到 `payment` 服务的过滤器。 +从来源中选择 `Logs`,并对 `payment` 服务应用过滤器。 -我们可以看到尽管问题较新,但受影响的支付数量很高。此外,与 visa 支付相关的缓存似乎正在造成问题。 +我们可以看到尽管问题很新,但受影响的支付数量却很高。此外,似乎与 Visa 支付相关的缓存出现了问题。 ## 图表指标 {#chart-metrics} -尽管代码中显然引入了错误,但我们可以使用指标确认缓存的大小。导航到 `图表浏览器` 视图。 +虽然代码中显然引入了错误,但我们可以使用指标来确认缓存大小。导航到 `Chart Explorer` 视图。 -选择 `指标` 作为数据源。完成图表构建器以绘制 `visa_validation_cache.size (Gauge)` 的 `最大值` 并按播放按钮。缓存显然在达到最大大小之前不断增加,之后生成了错误。 +选择 `Metrics` 作为数据源。完成图表构建器以绘制 `visa_validation_cache.size (Gauge)` 的 `Maximum`,然后按播放按钮。在达到最大大小之后,错误明显产生了。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/example-datasets/sample-data.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/example-datasets/sample-data.md.hash index ed9cac498fa..c8af86841ee 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/example-datasets/sample-data.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/example-datasets/sample-data.md.hash @@ -1 +1 @@ -ebf0ad846da9d328 +6ac4d14784d914c6 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/getting-started.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/getting-started.md index de54c5bac2f..22f9eea1077 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/getting-started.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/getting-started.md @@ -4,7 +4,8 @@ 'sidebar_label': '开始使用' 'pagination_prev': null 'pagination_next': 'use-cases/observability/clickstack/example-datasets/index' -'description': '开始使用 ClickStack - ClickHouse 观察性堆栈' +'description': '开始使用 ClickStack - ClickHouse 观察性栈' +'doc_type': 'guide' --- import Image from '@theme/IdealImage'; @@ -25,30 +26,30 @@ Getting started with **ClickStack** is straightforward thanks to the availabilit ## Local deployment {#local-deployment} -The simplest option is a **single-image distribution** that includes all core components of the stack bundled together: +最简单的选项是**单镜像分发**,它将堆栈的所有核心组件捆绑在一起: - **HyperDX UI** - **OpenTelemetry (OTel) collector** - **ClickHouse** -This all-in-one image allows you to launch the full stack with a single command, making it ideal for testing, experimentation, or quick local deployments. +这个一体化镜像让您可以通过一条命令启动整个堆栈,非常适合测试、实验或快速本地部署。 ### Deploy stack with docker {#deploy-stack-with-docker} -The following will run an OpenTelemetry collector (on port 4317 and 4318) and the HyperDX UI (on port 8080). +以下命令将运行一个 OpenTelemetry collector(在端口 4317 和 4318 上)以及 HyperDX UI(在端口 8080 上)。 -```bash +```shell docker run -p 8080:8080 -p 4317:4317 -p 4318:4318 docker.hyperdx.io/hyperdx/hyperdx-all-in-one ``` :::note Persisting data and settings -To persist data and settings across restarts of the container, users can modify the above docker command to mount the paths `/data/db`, `/var/lib/clickhouse` and `/var/log/clickhouse-server`. +为了在容器重启之间保持数据和设置,用户可以修改上述 docker 命令以挂载路径 `/data/db`、`/var/lib/clickhouse` 和 `/var/log/clickhouse-server`。 -For example: +例如: -```bash +```shell # modify command to mount paths docker run \ @@ -64,131 +65,131 @@ docker run \ ### Navigate to the HyperDX UI {#navigate-to-hyperdx-ui} -Visit [http://localhost:8080](http://localhost:8080) to access the HyperDX UI. +访问 [http://localhost:8080](http://localhost:8080) 来访问 HyperDX UI。 -Create a user, providing a username and password that meets the complexity requirements. +创建一个用户,提供符合复杂性要求的用户名和密码。 -HyperDX will automatically connect to the local cluster and create data sources for the logs, traces, metrics, and sessions - allowing you to explore the product immediately. +HyperDX 将自动连接到本地集群并为日志、跟踪、指标和会话创建数据源 - 让您能立即探索产品。 ### Explore the product {#explore-the-product} -With the stack deployed, try one of our same datasets. +在堆栈部署后,尝试我们的一些相同数据集。 -To continue using the local cluster: +要继续使用本地集群: -- [Example dataset](/use-cases/observability/clickstack/getting-started/sample-data) - Load an example dataset from our public demo. Diagnose a simple issue. -- [Local files and metrics](/use-cases/observability/clickstack/getting-started/local-data) - Load local files and monitor system on OSX or Linux using a local OTel collector. +- [Example dataset](/use-cases/observability/clickstack/getting-started/sample-data) - 从我们的公共演示加载示例数据集。诊断一个简单的问题。 +- [Local files and metrics](/use-cases/observability/clickstack/getting-started/local-data) - 加载本地文件并使用本地 OTel collector 在 OSX 或 Linux 上监控系统。
-Alternatively, you can connect to a demo cluster where you can explore a larger dataset: +或者,您可以连接到一个演示集群,在那里您可以探索更大的数据集: -- [Remote demo dataset](/use-cases/observability/clickstack/getting-started/remote-demo-data) - Explore a demo dataset in our demo ClickHouse service. +- [Remote demo dataset](/use-cases/observability/clickstack/getting-started/remote-demo-data) - 在我们的演示 ClickHouse 服务中探索演示数据集。
## Deploy with ClickHouse Cloud {#deploy-with-clickhouse-cloud} -Users can deploy ClickStack against ClickHouse Cloud, benefiting from a fully managed, secure backend while retaining complete control over ingestion, schema, and observability workflows. +用户可以针对 ClickHouse Cloud 部署 ClickStack,受益于完全托管的安全后端,同时保留对数据摄取、模式和可观察性工作流的完全控制。 ### Create a ClickHouse Cloud service {#create-a-service} -Follow the [getting started guide for ClickHouse Cloud](/cloud/get-started/cloud-quick-start#1-create-a-clickhouse-service) to create a service. +请遵循 [getting started guide for ClickHouse Cloud](/getting-started/quick-start/cloud#1-create-a-clickhouse-service) 来创建服务。 ### Copy connection details {#copy-cloud-connection-details} -To find the connection details for HyperDX, navigate to the ClickHouse Cloud console and click the Connect button on the sidebar. +要查找 HyperDX 的连接详细信息,请导航到 ClickHouse Cloud 控制台并单击侧边栏上的 Connect 按钮。 -Copy the HTTP connection details, specifically the HTTPS endpoint (`endpoint`) and password. +复制 HTTP 连接详细信息,特别是 HTTPS 端点(`endpoint`)和密码。 :::note Deploying to production -While we will use the `default` user to connect HyperDX, we recommend creating a dedicated user when [going to production](/use-cases/observability/clickstack/production#create-a-user). +虽然我们将使用 `default` 用户连接 HyperDX,但我们建议在 [去生产时](/use-cases/observability/clickstack/production#create-a-user) 创建一个专用用户。 ::: ### Deploy with docker {#deploy-with-docker} -Open a terminal and export the credentials copied above: +打开终端并导出上面复制的凭据: -```bash +```shell export CLICKHOUSE_USER=default export CLICKHOUSE_ENDPOINT= export CLICKHOUSE_PASSWORD= ``` -Run the following docker command: +运行以下 docker 命令: -```bash +```shell docker run -e CLICKHOUSE_ENDPOINT=${CLICKHOUSE_ENDPOINT} -e CLICKHOUSE_USER=default -e CLICKHOUSE_PASSWORD=${CLICKHOUSE_PASSWORD} -p 8080:8080 -p 4317:4317 -p 4318:4318 docker.hyperdx.io/hyperdx/hyperdx-all-in-one ``` -This will expose an OpenTelemetry collector (on port 4317 and 4318), and the HyperDX UI (on port 8080). +这将暴露一个 OpenTelemetry collector(在端口 4317 和 4318 上)和 HyperDX UI(在端口 8080 上)。 ### Navigate to the HyperDX UI {#navigate-to-hyperdx-ui-cloud} -Visit [http://localhost:8080](http://localhost:8080) to access the HyperDX UI. +访问 [http://localhost:8080](http://localhost:8080) 来访问 HyperDX UI。 -Create a user, providing a username and password which meets the complexity requirements. +创建一个用户,提供符合复杂性要求的用户名和密码。 ### Create a ClickHouse Cloud connection {#create-a-cloud-connection} -Navigate to `Team Settings` and click `Edit` for the `Local Connection`: +导航到 `Team Settings` 并点击 `Edit` 以获取 `Local Connection`: -Rename the connection to `Cloud` and complete the subsequent form with your ClickHouse Cloud service credentials before clicking `Save`: +将连接重命名为 `Cloud` 并在单击 `Save` 之前填写后续表单与您的 ClickHouse Cloud 服务凭据: ### Explore the product {#explore-the-product-cloud} -With the stack deployed, try one of our same datasets. +在堆栈部署后,尝试我们的一些相同数据集。 -- [Example dataset](/use-cases/observability/clickstack/getting-started/sample-data) - Load an example dataset from our public demo. Diagnose a simple issue. -- [Local files and metrics](/use-cases/observability/clickstack/getting-started/local-data) - Load local files and monitor the system on OSX or Linux using a local OTel collector. +- [Example dataset](/use-cases/observability/clickstack/getting-started/sample-data) - 从我们的公共演示加载示例数据集。诊断一个简单的问题。 +- [Local files and metrics](/use-cases/observability/clickstack/getting-started/local-data) - 加载本地文件并使用本地 OTel collector 在 OSX 或 Linux 上监控系统。 ## Local mode {#local-mode} -Local mode is a way to deploy HyperDX without a database or OTel collector. You can connect directly to a ClickHouse server from your browser directly, with configuration stored locally in your browser's local or session storage. This image **only** includes the HyperDX UI. +本地模式是一种在不需要身份验证的情况下部署 HyperDX 的方式。 -Authentication is not supported. +不支持身份验证。 -This mode is intended to be used for quick testing, development, demos and debugging use cases where deploying a full HyperDX instance is not necessary. +此模式旨在用于快速测试、开发、演示以及调试用例,其中不需要身份验证和设置持久化。 -### Hosted Version {#hosted-version} +### Hosted version {#hosted-version} -You can use a hosted version of HyperDX in local mode available at [play.hyperdx.io](https://play.hyperdx.io). +您可以使用可在 [play.hyperdx.io](https://play.hyperdx.io) 中提供的本地模式托管版本。 -### Self-Hosted Version {#self-hosted-version} +### Self-hosted version {#self-hosted-version} ### Run with docker {#run-local-with-docker} -The self-hosted local mode image comes with an OpenTelemetry collector and a ClickHouse server pre-configured as well. This makes it easy to consume telemetry data from your applications and visualize it in HyperDX with minimal external setup. To get started with the self-hosted version, simply run the Docker container with the appropriate ports forwarded: +自托管本地模式镜像预配置了 OpenTelemetry collector 和 ClickHouse 服务器。这使得从您的应用中获取遥测数据并在 HyperDX 中可视化变得简单,外部设置最少。要开始使用自托管版本,只需运行 Docker 容器并转发相应的端口: -```bash +```shell docker run -p 8080:8080 docker.hyperdx.io/hyperdx/hyperdx-local ``` -You will not be promoted to create a user as local mode does not include authentication. +您将不会被提示创建用户,因为本地模式不包括身份验证。 ### Complete connection credentials {#complete-connection-credentials} -To connect to your own **external ClickHouse cluster**, you can manually enter your connection credentials. +要连接到您自己的**外部 ClickHouse 集群**,您可以手动输入连接凭据。 -Alternatively, for a quick exploration of the product, you can also click **Connect to Demo Server** to access preloaded datasets and try ClickStack with no setup required. +或者,若要快速探索产品,您还可以单击**Connect to Demo Server**来访问预加载的数据集,无需设置即可尝试 ClickStack。 -If connecting to the demo server, users can explore the dataset with the [demo dataset instructions](/use-cases/observability/clickstack/getting-started/remote-demo-data). +如果连接到演示服务器,用户可以使用 [demo dataset instructions](/use-cases/observability/clickstack/getting-started/remote-demo-data) 探索数据集。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/getting-started.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/getting-started.md.hash index 219f315860a..b78b165dd74 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/getting-started.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/getting-started.md.hash @@ -1 +1 @@ -aeb36f2f36154a5e +5625d742f8be6263 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/index.md index 63cc5f1e0b7..31131230142 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/index.md @@ -1,21 +1,22 @@ --- 'slug': '/use-cases/observability/clickstack' -'title': 'ClickStack - ClickHouse 观察性堆栈' +'title': 'ClickStack - ClickHouse 可观察性栈' 'pagination_prev': null 'pagination_next': null -'description': 'ClickHouse 观察性堆栈的着陆页' +'description': 'ClickHouse 可观察性栈的着陆页' +'doc_type': 'landing-page' --- -**ClickStack** 是一个基于 ClickHouse 和 OpenTelemetry (OTel) 的生产级可观测性平台,统一了日志、跟踪、指标和会话,提供单一高性能解决方案。旨在监控和调试复杂系统,ClickStack 使开发者和 SRE 能够端到端地追踪问题,无需在工具之间切换或手动使用时间戳或关联 ID 拼凑数据。 +**ClickStack** 是一个生产级可观察性平台,基于 ClickHouse 和 OpenTelemetry (OTel) 构建,统一了日志、跟踪、指标和会话,提供单一高性能解决方案。ClickStack 旨在监控和调试复杂系统,使开发人员和 SRE 能够在不切换工具或手动通过时间戳或关联 ID 拼接数据的情况下,端到端追踪问题。 -| Section | Description | +| 部分 | 描述 | |---------|-------------| -| [概述](/use-cases/observability/clickstack/overview) | ClickStack 及其关键特性的介绍 | -| [入门指南](/use-cases/observability/clickstack/getting-started) | 快速入门指南和基本设置说明 | -| [示例数据集](/use-cases/observability/clickstack/sample-datasets) | 示例数据集和使用案例 | +| [概述](/use-cases/observability/clickstack/overview) | ClickStack 及其主要特性的介绍 | +| [入门](/use-cases/observability/clickstack/getting-started) | 快速入门指南和基本设置说明 | +| [示例数据集](/use-cases/observability/clickstack/sample-datasets) | 示例数据集和用例 | | [架构](/use-cases/observability/clickstack/architecture) | 系统架构和组件概述 | | [部署](/use-cases/observability/clickstack/deployment) | 部署指南和选项 | | [配置](/use-cases/observability/clickstack/config) | 详细的配置选项和设置 | -| [数据摄取](/use-cases/observability/clickstack/ingesting-data) | 向 ClickStack 摄取数据的指南 | -| [搜索](/use-cases/observability/clickstack/search) | 如何搜索和查询您的可观测性数据 | +| [数据摄取](/use-cases/observability/clickstack/ingesting-data) | 将数据摄取到 ClickStack 的指南 | +| [搜索](/use-cases/observability/clickstack/search) | 如何搜索和查询您的可观察性数据 | | [生产](/use-cases/observability/clickstack/production) | 生产部署的最佳实践 | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/index.md.hash index 0805b5cad5c..704ec762673 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/index.md.hash @@ -1 +1 @@ -6917adb8dd46a9f0 +4efdc0514f1ed62c diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/collector.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/collector.md index 92835dd89be..b3eaae17a1a 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/collector.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/collector.md @@ -2,78 +2,80 @@ 'slug': '/use-cases/observability/clickstack/ingesting-data/otel-collector' 'pagination_prev': null 'pagination_next': null -'description': 'ClickStack 的 OpenTelemetry 收集器 - ClickHouse 可观察性堆栈' +'description': '用于 ClickStack 的 OpenTelemetry 收集器 - ClickHouse 可观察性栈' 'sidebar_label': 'OpenTelemetry Collector' 'title': 'ClickStack OpenTelemetry Collector' +'doc_type': 'guide' --- import Image from '@theme/IdealImage'; +import BetaBadge from '@theme/badges/BetaBadge'; import observability_6 from '@site/static/images/use-cases/observability/observability-6.png'; import observability_8 from '@site/static/images/use-cases/observability/observability-8.png'; import clickstack_with_gateways from '@site/static/images/use-cases/observability/clickstack-with-gateways.png'; import clickstack_with_kafka from '@site/static/images/use-cases/observability/clickstack-with-kafka.png'; import ingestion_key from '@site/static/images/use-cases/observability/ingestion-keys.png'; -This page includes details on configuring the official ClickStack OpenTelemetry (OTel) collector. +此页面包含有关配置官方 ClickStack OpenTelemetry (OTel) 收集器的详细信息。 -## Collector roles {#collector-roles} +## 收集器角色 {#collector-roles} -OpenTelemetry collectors can be deployed in two principal roles: +OpenTelemetry 收集器可以以两种主要角色部署: -- **Agent** - Agent实例在边缘收集数据,例如在服务器或Kubernetes节点上,或者直接从用OpenTelemetry SDK进行仪器化的应用程序接收事件。在后者的情况下,代理实例与应用程序一起运行或在与应用程序相同的主机上运行(例如,作为旁车或DaemonSet)。代理可以将其数据直接发送到ClickHouse或发送到网关实例。在前一种情况下,这被称为[代理部署模式](https://opentelemetry.io/docs/collector/deployment/agent/)。 +- **代理** - 代理实例在边缘收集数据,例如在服务器或 Kubernetes 节点上,或直接从应用程序接收事件 - 这些应用程序通过 OpenTelemetry SDK 进行工具化。在后者中,代理实例与应用程序一起运行,或者与应用程序在同一主机上运行(例如作为侧车或 DaemonSet)。代理可以直接将数据发送到 ClickHouse 或发送到网关实例。在前一种情况下,这被称为 [代理部署模式](https://opentelemetry.io/docs/collector/deployment/agent/)。 -- **Gateway** - 网关实例提供一个独立服务(例如,Kubernetes中的部署),通常按集群、数据中心或区域划分。这些实例通过单个OTLP端点接收来自应用程序(或作为代理的其他收集器)的事件。通常,部署一组网关实例,使用开箱即用的负载均衡器在它们之间分配负载。如果所有代理和应用程序都将其信号发送到这个单一的端点,通常被称为[网关部署模式](https://opentelemetry.io/docs/collector/deployment/gateway/)。 +- **网关** - 网关实例提供独立服务(例如,在 Kubernetes 中的部署),通常按集群、数据中心或区域提供。这些实例通过单个 OTLP 端点接收来自应用程序(或作为代理的其他收集器)的事件。通常会部署一组网关实例,并使用开箱即用的负载均衡器在它们之间分配负载。如果所有代理和应用程序都将其信号发送到这个单一端点,通常被称为 [网关部署模式](https://opentelemetry.io/docs/collector/deployment/gateway/)。 -**重要提示:包括在ClickStack的默认分发版中的收集器假定如下所述的[网关角色](#collector-roles),接收来自代理或SDK的数据。** +**重要:包括在 ClickStack 的默认分发中,收集器假定如下所述的 [网关角色](#collector-roles),接收来自代理或 SDK 的数据。** -部署OTel收集器作为代理的用户通常会使用[收集器的默认contrib分发版](https://github.com/open-telemetry/opentelemetry-collector-contrib),而不是ClickStack版本,但也可以自由使用其他OTLP兼容的技术,例如[Fluentd](https://www.fluentd.org/)和[Vector](https://vector.dev/)。 +以代理角色部署 OTel 收集器的用户通常使用 [收集器的默认贡献分发版](https://github.com/open-telemetry/opentelemetry-collector-contrib),而不是 ClickStack 版本,但可以自由使用其他兼容 OTLP 的技术,例如 [Fluentd](https://www.fluentd.org/) 和 [Vector](https://vector.dev/)。 -## Deploying the collector {#configuring-the-collector} +## 部署收集器 {#configuring-the-collector} -如果您是在单独部署中管理自己的OpenTelemetry收集器——例如使用仅HyperDX的发行版——我们[建议仍然使用官方的ClickStack发行版的收集器](/use-cases/observability/clickstack/deployment/hyperdx-only#otel-collector)作为网关角色,但如果您选择使用自己的,则确保它包括[ClickHouse导出器](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/exporter/clickhouseexporter)。 +如果您在独立部署中管理自己的 OpenTelemetry 收集器 - 例如,使用仅限 HyperDX 的发行版 - 我们 [建议仍然使用官方 ClickStack 的收集器分发版](/use-cases/observability/clickstack/deployment/hyperdx-only#otel-collector) 作为可能的网关角色,但如果您选择自带,请确保它包含 [ClickHouse 导出器](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/exporter/clickhouseexporter)。 -### Standalone {#standalone} +### 独立模式 {#standalone} -要以独立模式部署ClickStack分发版的OTel连接器,请运行以下docker命令: +要在独立模式下部署 ClickStack 发行版的 OTel 连接器,请运行以下 docker 命令: -```bash +```shell docker run -e OPAMP_SERVER_URL=${OPAMP_SERVER_URL} -e CLICKHOUSE_ENDPOINT=${CLICKHOUSE_ENDPOINT} -e CLICKHOUSE_USER=default -e CLICKHOUSE_PASSWORD=${CLICKHOUSE_PASSWORD} -p 8080:8080 -p 4317:4317 -p 4318:4318 docker.hyperdx.io/hyperdx/hyperdx-otel-collector ``` -请注意,我们可以通过环境变量`CLICKHOUSE_ENDPOINT`、`CLICKHOUSE_USERNAME`和`CLICKHOUSE_PASSWORD`覆盖目标ClickHouse实例。`CLICKHOUSE_ENDPOINT`应为完整的ClickHouse HTTP端点,包括协议和端口——例如,`http://localhost:8123`。 +请注意,我们可以使用环境变量 `CLICKHOUSE_ENDPOINT`、`CLICKHOUSE_USERNAME` 和 `CLICKHOUSE_PASSWORD` 重写目标 ClickHouse 实例。`CLICKHOUSE_ENDPOINT` 应该是完整的 ClickHouse HTTP 端点,包括协议和端口 - 例如 `http://localhost:8123`。 -**这些环境变量可以与包括连接器的任何docker分发版一起使用。** +**这些环境变量可以与包含连接器的任何 docker 发行版一起使用。** -`OPAMP_SERVER_URL`应指向您的HyperDX部署——例如,`http://localhost:4320`。HyperDX在端口`4320`的`/v1/opamp`上公开一个OpAMP(开放代理管理协议)服务器。确保从运行HyperDX的容器中暴露此端口(例如,使用`-p 4320:4320`)。 +`OPAMP_SERVER_URL` 应指向您的 HyperDX 部署 - 例如 `http://localhost:4320`。HyperDX 默认在端口 `4320` 的 `/v1/opamp` 上暴露一个 OpAMP(开放代理管理协议)服务器。确保从运行 HyperDX 的容器中暴露此端口(例如,使用 `-p 4320:4320`)。 -:::note Exposing and connecting to the OpAMP port -为了使收集器能够连接到OpAMP端口,必须从HyperDX容器中暴露它,例如`-p 4320:4320`。对于本地测试,OSX用户可以设置`OPAMP_SERVER_URL=http://host.docker.internal:4320`。Linux用户可以使用`--network=host`启动收集器容器。 +:::note 暴露并连接到 OpAMP 端口 +为了让收集器连接到 OpAMP 端口,必须通过 HyperDX 容器暴露该端口,例如 `-p 4320:4320`。对于本地测试,OSX 用户可以设置 `OPAMP_SERVER_URL=http://host.docker.internal:4320`。Linux 用户可以使用 `--network=host` 启动收集器容器。 ::: -用户在生产中应使用具有[适当凭据](/use-cases/observability/clickstack/ingesting-data/otel-collector#creating-an-ingestion-user)的用户。 +用户在生产中应使用 [适当凭据的用户](/use-cases/observability/clickstack/ingesting-data/otel-collector#creating-an-ingestion-user)。 -### Modifying configuration {#modifying-otel-collector-configuration} +### 修改配置 {#modifying-otel-collector-configuration} -#### Using docker {#using-docker} +#### 使用 docker {#using-docker} -所有包含OpenTelemetry收集器的docker镜像均可通过环境变量`OPAMP_SERVER_URL`、`CLICKHOUSE_ENDPOINT`、`CLICKHOUSE_USERNAME`和`CLICKHOUSE_PASSWORD`配置为使用ClickHouse实例: +所有包含 OpenTelemetry 收集器的 docker 镜像都可以通过环境变量 `OPAMP_SERVER_URL`、`CLICKHOUSE_ENDPOINT`、`CLICKHOUSE_USERNAME` 和 `CLICKHOUSE_PASSWORD` 配置为使用 ClickHouse 实例: -例如,全能图像: +例如,所有功能合并的镜像: -```bash +```shell export OPAMP_SERVER_URL= export CLICKHOUSE_ENDPOINT= export CLICKHOUSE_USER= export CLICKHOUSE_PASSWORD= ``` -```bash +```shell docker run -e OPAMP_SERVER_URL=${OPAMP_SERVER_URL} -e CLICKHOUSE_ENDPOINT=${CLICKHOUSE_ENDPOINT} -e CLICKHOUSE_USER=default -e CLICKHOUSE_PASSWORD=${CLICKHOUSE_PASSWORD} -p 8080:8080 -p 4317:4317 -p 4318:4318 docker.hyperdx.io/hyperdx/hyperdx-all-in-one ``` #### Docker Compose {#docker-compose-otel} -使用Docker Compose,使用与上述相同的环境变量修改收集器配置: +使用 Docker Compose,通过上面相同的环境变量修改收集器配置: ```yaml otel-collector: @@ -95,33 +97,33 @@ otel-collector: - internal ``` -### Advanced configuration {#advanced-configuration} +### 高级配置 {#advanced-configuration} -当前,ClickStack分发版的OTel收集器不支持修改其配置文件。如果您需要更复杂的配置,例如[配置TLS](#securing-the-collector),或修改批量大小,我们建议您复制并修改[默认配置](https://github.com/hyperdxio/hyperdx/blob/main/docker/otel-collector/config.yaml),并使用文档中描述的ClickHouse导出器部署您自己的OTel收集器[这里](/observability/integrating-opentelemetry#exporting-to-clickhouse)和[这里](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/exporter/clickhouseexporter/README.md#configuration-options)。 +目前,ClickStack 发行版的 OTel 收集器不支持修改其配置文件。如果您需要更复杂的配置,例如 [配置 TLS](#securing-the-collector),或修改批处理大小,我们建议复制和修改 [默认配置](https://github.com/hyperdxio/hyperdx/blob/main/docker/otel-collector/config.yaml),并使用文档中记录的 ClickHouse 导出器自行部署 OTel 收集器 [在这里](/observability/integrating-opentelemetry#exporting-to-clickhouse) 和 [这里](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/exporter/clickhouseexporter/README.md#configuration-options)。 -默认的ClickStack配置对于OpenTelemetry(OTel)收集器可以在[这里](https://github.com/hyperdxio/hyperdx/blob/main/docker/otel-collector/config.yaml)找到。 +OpenTelemetry (OTel) 收集器的默认 ClickStack 配置可以在 [这里](https://github.com/hyperdxio/hyperdx/blob/main/docker/otel-collector/config.yaml) 找到。 -#### Configuration structure {#configuration-structure} +#### 配置结构 {#configuration-structure} -有关配置OTel收集器的详细信息,包括[`receivers`](https://opentelemetry.io/docs/collector/transforming-telemetry/),[`operators`](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/pkg/stanza/docs/operators/README.md)和[`processors`](https://opentelemetry.io/docs/collector/configuration/#processors),我们建议参考[官方OpenTelemetry收集器文档](https://opentelemetry.io/docs/collector/configuration)。 +有关配置 OTel 收集器的详细信息,包括 [`receivers`](https://opentelemetry.io/docs/collector/transforming-telemetry/)、[`operators`](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/pkg/stanza/docs/operators/README.md) 和 [`processors`](https://opentelemetry.io/docs/collector/configuration/#processors),我们建议参考 [官方 OpenTelemetry 收集器文档](https://opentelemetry.io/docs/collector/configuration)。 -## Securing the collector {#securing-the-collector} +## 保护收集器 {#securing-the-collector} -ClickStack发行版的OpenTelemetry收集器包含对OpAMP(开放代理管理协议)的内置支持,使用它来安全地配置和管理OTLP端点。在启动时,用户必须提供`OPAMP_SERVER_URL`环境变量——这应指向HyperDX应用程序,该应用程序在`/v1/opamp`处托管OpAMP API。 +ClickStack 发行版的 OpenTelemetry 收集器包括对 OpAMP(开放代理管理协议)的内置支持,它用于安全配置和管理 OTLP 端点。启动时,用户必须提供 `OPAMP_SERVER_URL` 环境变量 - 这应指向 HyperDX 应用程序,该应用程序在 `/v1/opamp` 处托管 OpAMP API。 -该集成确保OTLP端点使用在HyperDX应用程序部署时创建的自动生成的摄取API密钥进行安全保护。发送到收集器的所有遥测数据必须包括该API密钥以进行身份验证。您可以在HyperDX应用程序的`团队设置→API密钥`下找到密钥。 +此集成确保 OTLP 端点通过在 HyperDX 应用程序部署时生成的自动生成的接收 API 密钥进行保护。发送到收集器的所有遥测数据必须包括此 API 密钥以进行身份验证。您可以在 HyperDX 应用程序的 `团队设置 → API 密钥` 中找到此密钥。 为了进一步保护您的部署,我们建议: -- 配置收集器通过HTTPS与ClickHouse通信。 -- 创建一个具有有限权限的专用用户进行摄取——见下文。 -- 为OTLP端点启用TLS,以确保SDK/代理与收集器之间的加密通信。**目前,这要求用户部署收集器的默认分发版并自己管理配置**。 +- 配置收集器通过 HTTPS 与 ClickHouse 通信。 +- 创建一个具有有限权限的专用接收用户 - 见下文。 +- 启用 OTLP 端点的 TLS,确保 SDK/代理与收集器之间的加密通信。**目前,这要求用户自行部署收集器的默认分发版并管理配置**。 -### Creating an ingestion user {#creating-an-ingestion-user} +### 创建接收用户 {#creating-an-ingestion-user} -我们建议为OTel收集器创建一个专用数据库和用户,以便将数据摄取到ClickHouse。该用户应具备创建和插入[ClickStack创建和使用的表](/use-cases/observability/clickstack/ingesting-data/schemas)的能力。 +我们建议为 OTel 收集器在 ClickHouse 中创建一个专用数据库和用户用于接收。这应该具有在 [ClickStack 创建和使用的表中创建和插入的能力](/use-cases/observability/clickstack/ingesting-data/schemas)。 ```sql CREATE DATABASE otel; @@ -129,40 +131,38 @@ CREATE USER hyperdx_ingest IDENTIFIED WITH sha256_password BY 'ClickH0u3eRocks12 GRANT SELECT, INSERT, CREATE TABLE, CREATE VIEW ON otel.* TO hyperdx_ingest; ``` -这假定收集器已配置为使用数据库`otel`。可以通过环境变量`HYPERDX_OTEL_EXPORTER_CLICKHOUSE_DATABASE`控制这一点。将此变量传递给托管收集器的镜像[类似其他环境变量](#modifying-otel-collector-configuration)。 +这假设收集器已配置为使用数据库 `otel`。可以通过环境变量 `HYPERDX_OTEL_EXPORTER_CLICKHOUSE_DATABASE` 控制此项。将此项传递给托管收集器的镜像 [类似于其他环境变量](#modifying-otel-collector-configuration)。 -## Processing - filtering, transforming, and enriching {#processing-filtering-transforming-enriching} +## 处理 - 过滤、转换和丰富 {#processing-filtering-transforming-enriching} -用户在摄取过程中无疑希望过滤、转换和丰富事件消息。由于ClickStack连接器的配置无法修改,我们建议需要进一步事件过滤和处理的用户: +用户通常希望在接收过程中过滤、转换和丰富事件消息。由于 ClickStack 连接器的配置无法修改,我们建议需要进一步事件过滤和处理的用户: -- 部署自己的OTel收集器版本来执行过滤和处理,通过OTLP将事件发送到ClickStack收集器以便摄取到ClickHouse。 -- 部署自己的OTel收集器版本,并使用ClickHouse导出器直接将事件发送到ClickHouse。 +- 部署自己版本的 OTel 收集器,执行过滤和处理,通过 OTLP 将事件发送到 ClickStack 收集器以接收进入 ClickHouse。 +- 部署自己版本的 OTel 收集器,直接使用 ClickHouse 导出器将事件发送到 ClickHouse。 -如果使用OTel收集器进行处理,我们建议在网关实例上执行转换,并尽量减少在代理实例上进行的工作。这将确保运行在服务器上的边缘代理所需的资源尽可能最小。通常,我们看到用户仅执行过滤(以最小化不必要的网络使用)、时间戳设置(通过运算符)和丰富,这需要在代理中提供上下文。例如,如果网关实例位于不同的Kubernetes集群中,k8s丰富将在代理中进行。 +如果通过 OTel 收集器进行处理,我们建议在网关实例执行转换任务,并尽量减少在代理实例上进行的任何工作。这将确保在边缘运行的代理所需的资源尽可能少。通常,我们看到用户仅执行过滤(以最小化不必要的网络使用)、时间戳设置(通过运算符)和丰富,这需要代理中的上下文。例如,如果网关实例位于不同的 Kubernetes 集群中,将需要在代理中进行 k8s 丰富。 -OpenTelemetry支持以下处理和过滤功能,供用户利用: +OpenTelemetry 支持以下处理和过滤特性,用户可以利用: -- **Processors** - 处理器提取收集自[`receivers`](https://opentelemetry.io/docs/collector/transforming-telemetry/)的数据,并在发送到导出器之前进行修改或转换。处理器按配置文件中的`processors`部分的顺序应用。这些是可选的,但通常推荐使用最小集合[通常](https://github.com/open-telemetry/opentelemetry-collector/tree/main/processor#recommended-processors)。当将OTel收集器与ClickHouse一起使用时,我们建议限制处理器为: +- **处理器** - 处理器从 [接收器收集的数据并修改或转换](https://opentelemetry.io/docs/collector/transforming-telemetry/) 后发送到导出器。处理器按配置在收集器配置的 `processors` 部分中的顺序应用。这些是可选的,但通常建议最小集合为 [推荐处理器](https://github.com/open-telemetry/opentelemetry-collector/tree/main/processor#recommended-processors)。在与 ClickHouse 一起使用 OTel 收集器时,我们建议将处理器限制为: -- [memory_limiter](https://github.com/open-telemetry/opentelemetry-collector/blob/main/processor/memorylimiterprocessor/README.md),用来防止收集器出现内存不足的情况。有关建议,请参见[估计资源](#estimating-resources)。 -- 任何基于上下文进行丰富的处理器。例如,[Kubernetes Attributes Processor](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/k8sattributesprocessor)允许使用k8s元数据自动设置跨度、指标和日志资源属性,例如为事件丰富源pod的ID。 -- 如有必要,[尾部或头部采样](https://opentelemetry.io/docs/concepts/sampling/)。 -- [基本过滤](https://opentelemetry.io/docs/collector/transforming-telemetry/) - 丢弃不需要的事件,如果不能通过运算符(见下文)来完成。 -- [Batching](https://github.com/open-telemetry/opentelemetry-collector/tree/main/processor/batchprocessor) - 在与ClickHouse一起工作时至关重要,以确保数据以批量方式发送。请参见[“优化插入”](#optimizing-inserts)。 +- 使用 [memory_limiter](https://github.com/open-telemetry/opentelemetry-collector/blob/main/processor/memorylimiterprocessor/README.md) 防止收集器出现内存不足问题。有关建议,请参见 [估算资源](#estimating-resources)。 +- 任何基于上下文进行丰富的处理器。例如, [Kubernetes Attributes Processor](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/k8sattributesprocessor) 允许自动设置跨度、度量和日志资源属性,使用 k8s 元数据丰富事件,例如通过源 pod ID 丰富事件。 +- 如果需要针对跟踪的 [尾部或头部抽样](https://opentelemetry.io/docs/concepts/sampling/)。 +- [基本过滤](https://opentelemetry.io/docs/collector/transforming-telemetry/) - 如果无法通过运算符(见下文)执行,丢弃不需要的事件。 +- [批量处理](https://github.com/open-telemetry/opentelemetry-collector/tree/main/processor/batchprocessor) - 在与 ClickHouse 一起工作时确保以批处理方式发送数据的关键。请参阅 ["优化插入"](#optimizing-inserts)。 -- **Operators** - [操作符](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/pkg/stanza/docs/operators/README.md)提供了接收器可用的最基本处理单元。支持基本解析,允许设置诸如严重性和时间戳等字段。支持JSON和正则表达式解析,以及事件过滤和基本转换。我们建议在这里执行事件过滤。 +- **运算符** - [运算符](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/pkg/stanza/docs/operators/README.md) 提供接收器可用的最基本的处理单元。支持基本解析,允许设置字段如严重性和时间戳。支持 JSON 和正则表达式的解析,以及事件过滤和基本转换。我们建议在此执行事件过滤。 -我们建议用户避免使用运算符或[转换处理器](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/processor/transformprocessor/README.md)进行过多的事件处理。这可能会引起相当大的内存和CPU开销,特别是JSON解析。在插入时,可以在ClickHouse中执行所有处理,但有一些例外,特别是上下文感知的丰富,例如添加k8s元数据。有关更多详细信息,请参见[使用SQL提取结构](/use-cases/observability/schema-design#extracting-structure-with-sql)。 +我们建议用户避免使用运算符或 [转换处理器](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/processor/transformprocessor/README.md) 进行过量的事件处理。这可能会造成 considerable memory 和 CPU 开销,特别是 JSON 解析。在插入时可以在 ClickHouse 中进行所有处理, materialized views 和具有一些例外的列 - 特别是上下文感知丰富,例如添加 k8s 元数据。有关更多详细信息,请参见 [使用 SQL 提取结构](/use-cases/observability/schema-design#extracting-structure-with-sql)。 -### Example {#example-processing} +### 例子 {#example-processing} -以下配置显示了如何收集此[非结构化日志文件](https://datasets-documentation.s3.eu-west-3.amazonaws.com/http_logs/access-unstructured.log.gz)。此配置可以由在代理角色中的收集器使用,将数据发送到ClickStack网关。 +以下配置显示了如何收集此 [非结构化日志文件](https://datasets-documentation.s3.eu-west-3.amazonaws.com/http_logs/access-unstructured.log.gz)。此配置可以被在代理角色中发送数据到 ClickStack 网关的收集器使用。 -注意使用运算符从日志行中提取结构(`regex_parser`)和过滤事件,以及使用处理器批量事件并限制内存使用。 +注意使用运算符从日志行提取结构(`regex_parser`)和过滤事件,以及使用处理器对事件进行批处理和限制内存使用。 -```yaml - -# config-unstructured-logs-with-processor.yaml +```yaml file=code_snippets/ClickStack/config-unstructured-logs-with-processor.yaml receivers: filelog: include: @@ -206,87 +206,171 @@ service: receivers: [filelog] processors: [batch] exporters: [otlphttp/hdx] + ``` -请注意,在任何OTLP通信中需要包含包含您摄取API密钥的[授权头](#securing-the-collector)。 +请注意,在任何 OTLP 通信中需要包含 [包含您的接收 API 密钥的授权头](#securing-the-collector)。 -有关更高级的配置,我们建议查看[OpenTelemetry收集器文档](https://opentelemetry.io/docs/collector/)。 +有关更高级的配置,我们建议查看 [OpenTelemetry 收集器文档](https://opentelemetry.io/docs/collector/)。 -## Optimizing inserts {#optimizing-inserts} +## 优化插入 {#optimizing-inserts} -为了在获得强一致性保证的同时实现高插入性能,用户在通过ClickStack收集器将可观察性数据插入到ClickHouse时,应遵循简单规则。通过正确配置OTel收集器,以下规则应易于遵循。这还避免了用户在第一次使用ClickHouse时遇到的[常见问题](https://clickhouse.com/blog/common-getting-started-issues-with-clickhouse)。 +为了在将可观察性数据通过 ClickStack 收集器插入 ClickHouse 时实现高插入性能,同时获得强一致性保证,用户在插入时应遵循一些简单规则。通过正确配置 OTel 收集器,以下规则应该容易遵循。这也避免了用户在首次使用 ClickHouse 时遇到的 [常见问题](https://clickhouse.com/blog/common-getting-started-issues-with-clickhouse)。 -### Batching {#batching} +### 批处理 {#batching} -默认情况下,发送到ClickHouse的每个插入都会导致ClickHouse立即创建一个存储部分,其中包含插入的数据及其他需要存储的元数据。因此,发送较小数量的插入(每个插入含有更多数据),与发送较大数量的插入(每个插入含有较少数据)相比,将减少所需的写入次数。我们建议以至少1000行的较大批量插入数据。进一步详细信息[此处](https://clickhouse.com/blog/asynchronous-data-inserts-in-clickhouse#data-needs-to-be-batched-for-optimal-performance)。 +默认情况下,每个插入到 ClickHouse 的请求都会导致 ClickHouse 立即创建一个存储部分,其中包含插入的数据以及需要存储的其他元数据。因此,发送较小数量的插入,每个插入包含更多数据,相比之下发送较多数量的插入,每个插入包含较少数据,将减少所需的写入次数。我们建议以至少 1,000 行的相当大批量插入数据。有关更进一步的信息,请参见 [这里](https://clickhouse.com/blog/asynchronous-data-inserts-in-clickhouse#data-needs-to-be-batched-for-optimal-performance)。 -默认情况下,插入ClickHouse是同步的,并且如果相同则是幂等的。对于merge tree引擎家族的表,ClickHouse默认会自动[去重插入](https://clickhouse.com/blog/common-getting-started-issues-with-clickhouse#5-deduplication-at-insert-time)。这意味着在以下情况下插入是容错的: +默认情况下,插入到 ClickHouse 是同步且相同的时是幂等的。对于 MergeTree 引擎系列的表,ClickHouse 默认情况下会自动 [去重插入](https://clickhouse.com/blog/common-getting-started-issues-with-clickhouse#5-deduplication-at-insert-time)。这意味着在以下情况下,插入是容忍的: -- (1) 如果接收数据的节点出现问题,插入查询将超时(或出现更具体的错误),并不会收到确认。 -- (2) 如果数据已被节点写入,但由于网络中断无法将确认返回给查询的发送者,则发送者将获得超时或网络错误。 +- (1) 如果接收数据的节点出现问题,插入查询将超时(或收到更具体的错误),并且不会收到确认。 +- (2) 如果数据已由节点写入,但由于网络中断无法将确认返回给查询发送方,发送方将获得超时或网络错误。 -从收集器的角度来看,(1)和(2)可能难以区分。然而,在这两种情况下,未确认的插入可以立即重试。只要重试的插入查询包含相同的数据以相同的顺序,ClickHouse将在原始(未确认的)插入成功时自动忽略重试的插入。 +从收集器的角度来看,(1) 和 (2) 可能难以区分。然而,在两种情况下,未确认的插入可以立即重试。只要重试的插入查询包含相同的数据且顺序相同,即使原始(未确认的)插入成功,ClickHouse 也会自动忽略重试的插入。 -因此,ClickStack分发版的OTel收集器使用批[batch处理器](https://github.com/open-telemetry/opentelemetry-collector/blob/main/processor/batchprocessor/README.md)。这确保了插入作为一致的行批量发送,以满足上述要求。如果预计收集器将具有高吞吐量(每秒事件),并且每个插入至少可以发送5000个事件,通常这就是管道中唯一需要的批处理。在这种情况下,收集器将在达到批处理器的`timeout`之前刷新批次,确保管道的端到端延迟保持低,并保持批次一致的大小。 +因此,ClickStack 发行版的 OTel 收集器使用 [批处理处理器](https://github.com/open-telemetry/opentelemetry-collector/blob/main/processor/batchprocessor/README.md)。这确保插入作为一致的行批次发送,以满足上述要求。如果预计收集器的吞吐量很高(事件每秒),并且每次插入可以发送至少 5000 个事件,那么通常这就是管道中所需的唯一批处理。在这种情况下,收集器将在达到批处理处理器的 `timeout` 之前刷新批量,确保管道的端到端延迟保持低且批次大小一致。 -### Use Asynchronous inserts {#use-asynchronous-inserts} +### 使用异步插入 {#use-asynchronous-inserts} -通常,当收集器的吞吐量较低时,用户被迫发送较小的批次,而他们仍希望数据在最低端到端延迟内到达ClickHouse。在这种情况下,当批处理器的`timeout`到期时,将发送小批量。这可能会导致问题,这时需要异步插入。如果用户将数据发送到充当网关的ClickStack收集器,这个问题很少发生——通过充当聚合器,它们减轻了这个问题——见[收集器角色](#collector-roles)。 +通常,当收集器的吞吐量低时,用户被迫发送较小的批量,而他们仍然期望数据在最低的端到端延迟内到达 ClickHouse。在这种情况下,当批处理处理器的 `timeout` 到期时,会发送小批量。这可能会导致问题,并且这是需要异步插入的情况。如果用户向充当网关的 ClickStack 收集器发送数据,就会较少出现这个问题 - 作为聚合器,它们缓解了这个问题 - 请参见 [收集器角色](#collector-roles)。 -如果无法保证大型批量,用户可以使用[异步插入](/best-practices/selecting-an-insert-strategy#asynchronous-inserts)将批处理委托给ClickHouse。在异步插入时,数据首先插入到缓冲区中,然后在稍后或异步写入到数据库存储中。 +如果大批量无法得到保证,用户可以使用 [异步插入](/best-practices/selecting-an-insert-strategy#asynchronous-inserts) 将批处理委托给 ClickHouse。使用异步插入时,数据首先插入到缓冲区,然后在稍后或异步地写入到数据库存储。 -启用[异步插入](/optimize/asynchronous-inserts#enabling-asynchronous-inserts)后,当ClickHouse ① 接收到一个插入查询时,查询的数据会 ② 立即写入到内存缓冲区。在 ③ 下次缓冲区刷新时,缓冲区的数据将[排序](/guides/best-practices/sparse-primary-indexes#data-is-stored-on-disk-ordered-by-primary-key-columns)并写入数据库存储作为一个部分。请注意,在刷新到数据库存储之前,数据不能通过查询检索;缓冲区刷新是[可配置的](/optimize/asynchronous-inserts)。 +如果 [启用异步插入](/optimize/asynchronous-inserts#enabling-asynchronous-inserts),当 ClickHouse ① 收到插入查询时,该查询的数据会立即写入内存缓冲区。然后当 ③ 下一个缓冲区刷新发生时,缓冲区的数据会 [排序](/guides/best-practices/sparse-primary-indexes#data-is-stored-on-disk-ordered-by-primary-key-columns) 并作为部分写入数据库存储。请注意,在刷新到数据库存储之前,数据在查询中不可搜索;缓冲区刷新是 [可配置的](/optimize/asynchronous-inserts)。 -要为收集器启用异步插入,请在连接字符串中添加`async_insert=1`。我们建议用户使用`wait_for_async_insert=1`(默认值)以确保交付保证——有关进一步详细信息,请查看[此处](https://clickhouse.com/blog/asynchronous-data-inserts-in-clickhouse)。 +要为收集器启用异步插入,请将 `async_insert=1` 添加到连接字符串中。我们建议用户使用 `wait_for_async_insert=1`(默认值)以获得交付保证 - 查询详情请见 [这里](https://clickhouse.com/blog/asynchronous-data-inserts-in-clickhouse)。 -异步插入中的数据在ClickHouse缓冲区被刷新时插入。这发生在超过[`async_insert_max_data_size`](/operations/settings/settings#async_insert_max_data_size)或从第一次INSERT查询起经过[`async_insert_busy_timeout_ms`](/operations/settings/settings#async_insert_max_data_size)毫秒之后。如果设置了`async_insert_stale_timeout_ms`为非零值,则数据在最后一个查询之后的`async_insert_stale_timeout_ms毫秒`后插入。用户可以调整这些设置以控制其管道的端到端延迟。有关可以用于调整缓冲区刷新设置的进一步文档,请见[此处](/operations/settings/settings#async_insert)。通常,默认值是合适的。 +异步插入的数据在 ClickHouse 缓冲区刷新后插入。这发生在超过 [`async_insert_max_data_size`](/operations/settings/settings#async_insert_max_data_size) 或在第一次 INSERT 查询以来超过 [`async_insert_busy_timeout_ms`](/operations/settings/settings#async_insert_max_data_size) 毫秒的情况下。如果设置 `async_insert_stale_timeout_ms` 为非零值,则数据将在上次查询以来的 `async_insert_stale_timeout_ms 毫秒` 后插入。用户可以调整这些设置以控制其管道的端到端延迟。有关可以用来调整缓冲区刷新的进一步设置,请在 [这里](/operations/settings/settings#async_insert) 查看。通常,默认值是合适的。 -:::note Consider Adaptive Asynchronous Inserts -在使用低数量代理的情况下,吞吐量较低,但有严格的端到端延迟要求,[自适应异步插入](https://clickhouse.com/blog/clickhouse-release-24-02#adaptive-asynchronous-inserts)可能有用。通常,这些不适用于高吞吐量可观察性用例,如ClickHouse。 +:::note 考虑自适应异步插入 +在少量代理使用且吞吐量低,但具有严格的端到端延迟要求的情况下,自适应异步插入可能会有用。通常,这些不适用于高吞吐量的可观察性用例,如 ClickHouse。 ::: -最后,先前与ClickHouse的同步插入相关的去重行为在使用异步插入时默认为未启用。如果需要,请参见设置[`async_insert_deduplicate`](/operations/settings/settings#async_insert_deduplicate)。 +最后,当使用异步插入时,不会默认启用与同步插入到 ClickHouse 相关的去重行为。如果需要,请参见设置 [`async_insert_deduplicate`](/operations/settings/settings#async_insert_deduplicate)。 -有关配置此功能的完整细节,请参见此[文档页面](/optimize/asynchronous-inserts#enabling-asynchronous-inserts),或查阅深度讨论[博客文章](https://clickhouse.com/blog/asynchronous-data-inserts-in-clickhouse)。 +有关配置此功能的完整详细信息,请参见此 [文档页面](/optimize/asynchronous-inserts#enabling-asynchronous-inserts),或深入的 [博客文章](https://clickhouse.com/blog/asynchronous-data-inserts-in-clickhouse)。 -## Scaling {#scaling} +## 扩展 {#scaling} -ClickStack OTel收集器充当网关实例——见[收集器角色](#collector-roles)。这些提供独立服务,通常按数据中心或区域划分。这些实例通过单个OTLP端点接收来自应用程序(或作为代理的其他收集器)的事件。通常,部署一组收集器实例,使用开箱即用的负载均衡器在它们之间分配负载。 +ClickStack OTel 收集器充当网关实例 - 请参见 [收集器角色](#collector-roles)。这些提供独立服务,通常按数据中心或区域提供。这些通过单个 OTLP 端点接收来自应用程序(或在代理角色中的其他收集器)的事件。通常会部署一组收集器实例,并使用开箱即用的负载均衡器在它们之间分配负载。 -此架构的目标是将计算密集型处理从代理中卸载,从而最小化其资源使用。这些ClickStack网关可以执行本来需要由代理完成的转换任务。此外,通过聚合来自多个代理的事件,网关可以确保将较大的批量发送到ClickHouse——从而允许高效插入。随着增加更多代理和SDK源以及事件吞吐量的增加,这些网关收集器可以轻松扩展。 +此架构的目标是将计算密集型处理从代理中卸载,从而最小化它们的资源使用。这些 ClickStack 网关可以执行本来需要代理进行的转换任务。此外,网关可以聚合来自许多代理的事件,确保以大批量发送到 ClickHouse - 允许高效插入。这些网关收集器可以轻松扩展,以便随着添加更多代理和 SDK 源并增加事件吞吐量。 -### Adding Kafka {#adding-kafka} +### 添加 Kafka {#adding-kafka} -读者可能会注意到上述架构未使用Kafka作为消息队列。 +读者可能会注意到上述架构没有使用 Kafka 作为消息队列。 -使用Kafka队列作为消息缓冲区是日志架构中常见的设计模式,并由ELK堆栈推广。它提供了一些好处:主要是,它有助于提供更强的消息交付保证,并有助于处理回压。消息从收集代理发送到Kafka并写入磁盘。理论上,集群化的Kafka实例应提供高吞吐量的消息缓冲区,因为将数据线性写入磁盘的计算开销小于解析和处理消息。例如,在Elastic中,标记化和索引会产生显著的开销。通过将数据从代理中移走,您还减少了由于源处的日志轮转而丢失消息的风险。最后,它还提供了一些消息重放和跨区域复制的能力,这可能对某些用例具有吸引力。 +使用 Kafka 队列作为消息缓冲区是在日志架构中看到的一种流行设计模式,并由 ELK 堆栈推广。它提供了一些好处:主要是,它有助于提供更强的消息交付保证,并有助于处理反馈压力。消息从收集代理发送到 Kafka 并写入磁盘。理论上,集群 Kafka 实例应提供高吞吐量的消息缓冲,因为它比解析和处理消息开销更小,线性写入数据到磁盘的效率更高。在 Elastic 中,例如, tokenization 和索引会造成显著开销。通过将数据移出代理,您也就减少了因源头日志轮替而丢失消息的风险。最后,它提供了一些消息重发和跨区域复制能力,这对某些用例可能具有吸引力。 -然而,ClickHouse能够非常快速地处理数据插入——在中等硬件上,每秒数百万行。来自ClickHouse的回压是罕见的。通常,利用Kafka队列意味着更多的架构复杂性和成本。如果您能够接受日志不需要与银行交易和其他关键任务数据相同的交付保证的原则,我们建议避免Kafka的复杂性。 +但是,ClickHouse 可以非常快速地处理数据的插入 - 在适度硬件上每秒数百万行。ClickHouse 的反馈压力是罕见的。通常,利用 Kafka 队列意味着更多的架构复杂性和成本。如果您能接受日志与银行交易和其他关键数据不需要相同的交付保证这一原则,那么我们建议避免 Kafka 的复杂性。 -但是,如果您需要高交付保证或重放数据的能力(可能是多源的),Kafka可以是一个有用的架构补充。 +但是,如果您需要高交付保证或能够重放数据(可能给多个源),Kafka 可以是一个有用的架构补充。 -在这种情况下,可以配置OTel代理通过[Kafka导出器](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/exporter/kafkaexporter/README.md)将数据发送到Kafka。网关实例则使用[Kafka接收器](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/receiver/kafkareceiver/README.md)消费消息。我们推荐参考Confluent和OTel文档以获取更多详细信息。 +在这种情况下,可以配置 OTel 代理通过 [Kafka 导出器](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/exporter/kafkaexporter/README.md) 将数据发送到 Kafka。网关实例反过来使用 [Kafka 接收器](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/receiver/kafkareceiver/README.md) 消费消息。我们建议查看 Confluent 和 OTel 文档以获取更多详细信息。 + +:::note OTel 收集器配置 +ClickStack OpenTelemetry 收集器发行版无法与 Kafka 一起使用,因为它需要配置修改。用户需要使用 ClickHouse 导出器部署默认的 OTel 收集器。 +::: + +## 估算资源 {#estimating-resources} + +OTel 收集器的资源需求将取决于事件吞吐量、消息大小和处理量。OpenTelemetry 项目维护 [基准](https://opentelemetry.io/docs/collector/benchmarks/),用户可以用来估算资源需求。 + +[根据我们的经验](https://clickhouse.com/blog/building-a-logging-platform-with-clickhouse-and-saving-millions-over-datadog#architectural-overview),具有 3 个核心和 12GB RAM 的 ClickStack 网关实例可以处理约 60,000 个事件每秒。这假设一个负责重命名字段的最小处理管道,并且没有正则表达式。 + +对于负责将事件发送到网关的代理实例,只需设置事件的时间戳,我们建议用户根据预期的每秒日志数量来进行大小选择。以下代表用户可以作为起点使用的近似值: + +| 日志采集率 | 收集器代理的资源 | +|--------------|------------------------------| +| 1k/秒 | 0.2CPU,0.2GiB | +| 5k/秒 | 0.5 CPU,0.5GiB | +| 10k/秒 | 1 CPU,1GiB | + +## JSON 支持 {#json-support} -:::note OTel collector configuration -ClickStack OpenTelemetry收集器分发版不能与Kafka一起使用,因为它需要配置修改。用户需要使用ClickHouse导出器部署默认的OTel收集器。 + + +ClickStack 从版本 `2.0.4` 开始对 [JSON 类型](/interfaces/formats/JSON) 提供 beta 支持。 + +### JSON 类型的好处 {#benefits-json-type} + +JSON 类型为 ClickStack 用户提供了以下好处: + +- **类型保留** - 数字保持数字,布尔值保持布尔值 - 不再将所有内容扁平化为字符串。这意味着更少的类型转换,更简单的查询,以及更准确的聚合。 +- **路径级别列** - 每个 JSON 路径成为自己的子列,减少 I/O。查询仅读取所需的字段,相比于旧的 Map 类型,大幅提高了性能,因为只有在查询特定字段时才需要读取整个列。 +- **深度嵌套自然有效** - 自然处理复杂的、深层嵌套的结构,而无需像 Map 类型那样手动扁平化及后续尴尬的 JSONExtract 函数。 +- **动态、演变的模式** - 非常适合可观察性数据,因为团队随着时间的推移添加新的标签和属性。JSON 会自动处理这些变化,无需模式迁移。 +- **更快的查询,降低内存** - 针对 `LogAttributes` 等属性的典型聚合,减少读取 5-10 倍的数据,实现显著加速,减少查询时间和内存峰值使用。 +- **简单管理** - 不需要为了性能而预先材料化列。每个字段成为自己的子列,提供与原生 ClickHouse 列相同的速度。 + +### 启用 JSON 支持 {#enabling-json-support} + +要为收集器启用此支持,请在任何包含收集器的部署中设置环境变量 `OTEL_AGENT_FEATURE_GATE_ARG='--feature-gates=clickhouse.json'`。这确保在 ClickHouse 中使用 JSON 类型创建模式。 + +:::note HyperDX 支持 +为了查询 JSON 类型,支持还必须通过环境变量 `BETA_CH_OTEL_JSON_SCHEMA_ENABLED=true` 在 HyperDX 应用层启用。 ::: -## Estimating resources {#estimating-resources} +例如: + +```shell +docker run -e OTEL_AGENT_FEATURE_GATE_ARG='--feature-gates=clickhouse.json' -e OPAMP_SERVER_URL=${OPAMP_SERVER_URL} -e CLICKHOUSE_ENDPOINT=${CLICKHOUSE_ENDPOINT} -e CLICKHOUSE_USER=default -e CLICKHOUSE_PASSWORD=${CLICKHOUSE_PASSWORD} -p 8080:8080 -p 4317:4317 -p 4318:4318 docker.hyperdx.io/hyperdx/hyperdx-otel-collector +``` -OTel收集器的资源要求取决于事件吞吐量、消息大小和执行的处理量。OpenTelemetry项目维护着[用户](https://opentelemetry.io/docs/collector/benchmarks/)可以用来估算资源要求的基准测试。 +### 从基于 Map 的模式迁移到 JSON 类型 {#migrating-from-map-based-schemas-to-json} + +:::重要 向后兼容性 +[JSON 类型](/interfaces/formats/JSON) 与现有的基于 Map 的模式不向后兼容。将使用 `JSON` 类型创建新表。 +::: -[根据我们的经验](https://clickhouse.com/blog/building-a-logging-platform-with-clickhouse-and-saving-millions-over-datadog#architectural-overview),具有3个核心和12GB RAM的ClickStack网关实例可以处理约60k每秒的事件。假设处理管道最小,只负责重命名字段,而不使用正则表达式。 +要从基于 Map 的模式迁移,请按照以下步骤操作: -对于负责将事件传送到网关的代理实例,并且仅设置事件的时间戳,我们建议用户根据预期的日志每秒进行调整。以下是用户可以使用的起始点的近似数字: + -| 日志记录速率 | 收集代理的资源 | -|--------------|------------------| -| 1k/秒 | 0.2CPU, 0.2GiB | -| 5k/秒 | 0.5 CPU, 0.5GiB | -| 10k/秒 | 1 CPU, 1GiB | +#### 停止 OTel 收集器 {#stop-the-collector} + +#### 重命名现有表并更新数据源 {#rename-existing-tables-sources} + +重命名现有表并更新 HyperDX 中的数据源。 + +例如: + +```sql +RENAME TABLE otel_logs TO otel_logs_map; +RENAME TABLE otel_metrics TO otel_metrics_map; +``` + +#### 部署收集器 {#deploy-the-collector} + +设置 `OTEL_AGENT_FEATURE_GATE_ARG` 部署收集器。 + +#### 使用 JSON 模式支持重启 HyperDX 容器 {#restart-the-hyperdx-container} + +```shell +export BETA_CH_OTEL_JSON_SCHEMA_ENABLED=true +``` + +#### 创建新的数据源 {#create-new-data-sources} + +在 HyperDX 中创建新的数据源,指向 JSON 表。 + + + +#### 迁移现有数据(可选) {#migrating-existing-data} + +要将旧数据移动到新的 JSON 表中: + +```sql +INSERT INTO otel_logs SELECT * FROM otel_logs_map; +INSERT INTO otel_metrics SELECT * FROM otel_metrics_map; +``` + +:::警告 +建议仅用于小于 ~100 亿行的数据集。先前使用 Map 类型存储的数据未能保留类型精度(所有值均为字符串)。因此,这些旧数据将在新模式中表现为字符串,直到过期,前端可能需要一些转换。新数据将使用 JSON 类型保留类型。 +::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/collector.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/collector.md.hash index 7be3ffa529a..fd5fad0b302 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/collector.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/collector.md.hash @@ -1 +1 @@ -07584ebec72630e2 +f4e0d7d8f48b5766 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/index.md index 2964aaf0e3b..023c2cfc824 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/index.md @@ -2,17 +2,18 @@ 'slug': '/use-cases/observability/clickstack/ingesting-data' 'pagination_prev': null 'pagination_next': null -'description': '数据摄取用于 ClickStack - ClickHouse 监控栈' -'title': '摄取数据' +'description': '为 ClickStack 进行数据摄取 - ClickHouse 观察性堆栈' +'title': '数据摄取' +'doc_type': 'landing-page' --- -ClickStack 提供多种方法将可观察性数据导入到您的 ClickHouse 实例中。无论您是收集日志、指标、跟踪还是会话数据,都可以使用 OpenTelemetry (OTel) 收集器作为统一的导入点,或者利用特定平台的集成来满足特定用例。 +ClickStack 提供多种方式将可观察性数据摄取到您的 ClickHouse 实例中。无论您是在收集日志、指标、跟踪还是会话数据,都可以使用 OpenTelemetry (OTel) 收集器作为统一的摄取点,或利用特定平台的集成以满足特定用例。 | 部分 | 描述 | |------|-------------| -| [概述](/use-cases/observability/clickstack/ingesting-data/overview) | 数据导入方法和架构的介绍 | -| [使用 OpenTelemetry 导入数据](/use-cases/observability/clickstack/ingesting-data/opentelemetry) | 为使用 OpenTelemetry 并希望快速与 ClickStack 集成的用户提供支持 | -| [OpenTelemetry 收集器](/use-cases/observability/clickstack/ingesting-data/otel-collector) | ClickStack OpenTelemetry 收集器的高级细节 | +| [概述](/use-cases/observability/clickstack/ingesting-data/overview) | 数据摄取方法和架构介绍 | +| [使用 OpenTelemetry 摄取数据](/use-cases/observability/clickstack/ingesting-data/opentelemetry) | 面向使用 OpenTelemetry 并希望快速与 ClickStack 集成的用户 | +| [OpenTelemetry 收集器](/use-cases/observability/clickstack/ingesting-data/otel-collector) | ClickStack OpenTelemetry 收集器的高级详情 | | [Kubernetes](/use-cases/observability/clickstack/ingesting-data/kubernetes) | 从 Kubernetes 集群收集可观察性数据的指南 | -| [表和模式](/use-cases/observability/clickstack/ingesting-data/schemas) | ClickHouse 表及其模式的概述,这些表由 ClickStack 使用 | -| [语言 SDKs](/use-cases/observability/clickstack/sdks) | 用于仪器编程语言和收集遥测数据的 ClickStack SDKs | +| [表和模式](/use-cases/observability/clickstack/ingesting-data/schemas) | ClickStack 使用的 ClickHouse 表及其模式概述 | +| [语言 SDKs](/use-cases/observability/clickstack/sdks) | ClickStack SDK,用于工具编程语言和收集遥测数据 | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/index.md.hash index 5c91a69a568..a0d62f27cb9 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/index.md.hash @@ -1 +1 @@ -8e542f53ad092fd4 +01d8a24099e63751 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/kubernetes.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/kubernetes.md index fdbf413ba82..02a72ff5670 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/kubernetes.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/kubernetes.md @@ -2,30 +2,57 @@ 'slug': '/use-cases/observability/clickstack/ingesting-data/kubernetes' 'pagination_prev': null 'pagination_next': null -'description': 'Kubernetes 集成用于 ClickStack - ClickHouse 观察性栈' +'description': 'Kubernetes 集成用于 ClickStack - ClickHouse 可观察性栈' 'title': 'Kubernetes' +'doc_type': 'guide' --- -ClickStack 使用 OpenTelemetry (OTel) 收集器从 Kubernetes 集群中收集日志、指标和 Kubernetes 事件,并将它们转发到 ClickStack。我们支持原生的 OTel 日志格式,并且不需要额外的供应商特定配置。 +ClickStack 使用 OpenTelemetry (OTel) 收集器从 Kubernetes 集群收集日志、指标和 Kubernetes 事件,并将其转发到 ClickStack。我们支持原生的 OTel 日志格式,且无需额外的供应商特定配置。 -本指南集成了以下内容: +本指南整合了以下内容: - **日志** - **基础设施指标** :::note -要发送应用级别的指标或 APM/追踪,您还需要将相应的语言集成添加到您的应用程序中。 +要发送应用级别指标或 APM/跟踪,您还需要将相应的语言集成添加到您的应用程序中。 ::: -## 创建 OTel Helm Chart 配置文件 {#creating-the-otel-helm-chart-config-files} +以下指南假设您已部署一个 [作为网关的 ClickStack OTel 收集器](/use-cases/observability/clickstack/ingesting-data/otel-collector),并使用了一个安全的接收 API 密钥。 -为了从每个节点和集群本身收集日志和指标,我们需要部署两个单独的 OpenTelemetry 收集器。一个将作为 DaemonSet 部署,以从每个节点收集日志和指标,另一个将作为部署部署,以收集集群本身的日志和指标。 +## 创建 OTel Helm 图表配置文件 {#creating-the-otel-helm-chart-config-files} + +为了从每个节点和集群本身收集日志和指标,我们需要部署两个独立的 OpenTelemetry 收集器。一个将作为 DaemonSet 部署,以从每个节点收集日志和指标,另一个将作为部署进行收集集群本身的日志和指标。 + +### 创建 API 密钥秘密 {#create-api-key-secret} + +使用来自 HyperDX 的 [接收 API 密钥](/use-cases/observability/clickstack/ingesting-data/opentelemetry#sending-otel-data) 创建一个新的 Kubernetes 秘密。这将被下面安装的组件用来安全地接收到您的 ClickStack OTel 收集器中: + +```shell +kubectl create secret generic hyperdx-secret \ +--from-literal=HYPERDX_API_KEY= \ +``` + +此外,创建一个配置映射,指定您的 ClickStack OTel 收集器的位置: + +```shell +kubectl create configmap -n=otel-demo otel-config-vars --from-literal=YOUR_OTEL_COLLECTOR_ENDPOINT= + +# e.g. kubectl create configmap -n=otel-demo otel-config-vars --from-literal=YOUR_OTEL_COLLECTOR_ENDPOINT=http://my-hyperdx-hdx-oss-v2-otel-collector:4318 +``` ### 创建 DaemonSet 配置 {#creating-the-daemonset-configuration} DaemonSet 将从集群中的每个节点收集日志和指标,但不会收集 Kubernetes 事件或集群范围的指标。 -创建一个名为 `daemonset.yaml` 的文件,内容如下: +下载 DaemonSet 清单: + +```shell +curl -O https://raw.githubusercontent.com/ClickHouse/clickhouse-docs/refs/heads/main/docs/use-cases/observability/clickstack/example-datasets/_snippets/k8s_daemonset.yaml +``` +
+ +`k8s_daemonset.yaml` ```yaml @@ -66,6 +93,19 @@ presets: kubeletMetrics: enabled: true +extraEnvs: + - name: HYPERDX_API_KEY + valueFrom: + secretKeyRef: + name: hyperdx-secret + key: HYPERDX_API_KEY + optional: true + - name: YOUR_OTEL_COLLECTOR_ENDPOINT + valueFrom: + configMapKeyRef: + name: otel-config-vars + key: YOUR_OTEL_COLLECTOR_ENDPOINT + config: receivers: # Configures additional kubelet metrics @@ -100,9 +140,9 @@ config: exporters: otlphttp: - endpoint: 'https://in-otel.hyperdx.io' + endpoint: "${env:YOUR_OTEL_COLLECTOR_ENDPOINT}" headers: - authorization: '' + authorization: "${env:HYPERDX_API_KEY}" compression: gzip service: @@ -115,19 +155,32 @@ config: - otlphttp ``` +
+ ### 创建部署配置 {#creating-the-deployment-configuration} 为了收集 Kubernetes 事件和集群范围的指标,我们需要将一个单独的 OpenTelemetry 收集器作为部署进行部署。 -创建一个名为 `deployment.yaml` 的文件,内容如下: +下载部署清单: + +```shell +curl -O https://raw.githubusercontent.com/ClickHouse/clickhouse-docs/refs/heads/main/docs/use-cases/observability/clickstack/example-datasets/_snippets/k8s_deployment.yaml +``` + +
+k8s_deployment.yaml -```yaml copy +```yaml # deployment.yaml mode: deployment +image: + repository: otel/opentelemetry-collector-contrib + tag: 0.123.0 -# We only want one of these collectors - any more, and we'd produce duplicate data + +# We only want one of these collectors - any more and we'd produce duplicate data replicaCount: 1 presets: @@ -139,9 +192,9 @@ presets: # When enabled the processor will extra all annotations for an associated pod and add them as resource attributes. # The annotation's exact name will be the key. extractAllPodAnnotations: true - # Configures the collector to collect Kubernetes events. - # Adds the k8sobject receiver to the logs pipeline and collects Kubernetes events by default. - # More info: https://opentelemetry.io/docs/kubernetes/collector/components/#kubernetes-objects-receiver + # Configures the collector to collect kubernetes events. + # Adds the k8sobject receiver to the logs pipeline and collects kubernetes events by default. + # More Info: https://opentelemetry.io/docs/kubernetes/collector/components/#kubernetes-objects-receiver kubernetesEvents: enabled: true # Configures the Kubernetes Cluster Receiver to collect cluster-level metrics. @@ -150,14 +203,26 @@ presets: clusterMetrics: enabled: true +extraEnvs: + - name: HYPERDX_API_KEY + valueFrom: + secretKeyRef: + name: hyperdx-secret + key: HYPERDX_API_KEY + optional: true + - name: YOUR_OTEL_COLLECTOR_ENDPOINT + valueFrom: + configMapKeyRef: + name: otel-config-vars + key: YOUR_OTEL_COLLECTOR_ENDPOINT + config: exporters: otlphttp: - endpoint: 'https://in-otel.hyperdx.io' - headers: - authorization: '' + endpoint: "${env:YOUR_OTEL_COLLECTOR_ENDPOINT}" compression: gzip - + headers: + authorization: "${env:HYPERDX_API_KEY}" service: pipelines: logs: @@ -168,30 +233,32 @@ config: - otlphttp ``` +
+ ## 部署 OpenTelemetry 收集器 {#deploying-the-otel-collector} 现在可以使用 [OpenTelemetry Helm Chart](https://github.com/open-telemetry/opentelemetry-helm-charts/tree/main/charts/opentelemetry-collector) 在您的 Kubernetes 集群中部署 OpenTelemetry 收集器。 添加 OpenTelemetry Helm 仓库: -```bash copy +```shell helm repo add open-telemetry https://open-telemetry.github.io/opentelemetry-helm-charts # Add OTel Helm repo ``` 使用上述配置安装图表: -```bash copy -helm install my-opentelemetry-collector-deployment open-telemetry/opentelemetry-collector -f deployment.yaml -helm install my-opentelemetry-collector-daemonset open-telemetry/opentelemetry-collector -f daemonset.yaml +```shell copy +helm install my-opentelemetry-collector-deployment open-telemetry/opentelemetry-collector -f k8s_deployment.yaml +helm install my-opentelemetry-collector-daemonset open-telemetry/opentelemetry-collector -f k8s_daemonset.yaml ``` -现在,您的 Kubernetes 集群中的指标、日志和 Kubernetes 事件应该出现在 HyperDX 中。 +现在,来自您 Kubernetes 集群的指标、日志和 Kubernetes 事件应该会出现在 HyperDX 中。 -## 转发资源标签到 Pods(推荐) {#forwarding-resouce-tags-to-pods} +## 转发资源标签到 pods(推荐) {#forwarding-resouce-tags-to-pods} -为了将应用级别的日志、指标和追踪与 Kubernetes 元数据(例如 pod 名称、命名空间等)关联起来,您需要使用 `OTEL_RESOURCE_ATTRIBUTES` 环境变量将 Kubernetes 元数据转发到您的应用程序。 +为了将应用级别的日志、指标和跟踪与 Kubernetes 元数据(例如 pod 名称、命名空间等)相关联,您将希望通过 `OTEL_RESOURCE_ATTRIBUTES` 环境变量将 Kubernetes 元数据转发到您的应用程序。 -以下是一个示例部署,通过环境变量将 Kubernetes 元数据转发到应用程序: +以下是一个示例部署,使用环境变量将 Kubernetes 元数据转发到应用程序: ```yaml diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/kubernetes.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/kubernetes.md.hash index 8013d502d1a..c2c1bb3f6ad 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/kubernetes.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/kubernetes.md.hash @@ -1 +1 @@ -a83f994c4d51f340 +b4235b7b5950fb11 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/opentelemetry.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/opentelemetry.md index 57ec9f9ffca..25869b98378 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/opentelemetry.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/opentelemetry.md @@ -2,22 +2,23 @@ 'slug': '/use-cases/observability/clickstack/ingesting-data/opentelemetry' 'pagination_prev': null 'pagination_next': null -'description': '使用 OpenTelemetry 进行数据摄取以支持 ClickStack - ClickHouse 可观察性栈' +'description': '使用 OpenTelemetry 进行数据摄取以支持 ClickStack - ClickHouse 可观测性栈' 'title': '使用 OpenTelemetry 进行数据摄取' +'doc_type': 'guide' --- import Image from '@theme/IdealImage'; import ingestion_key from '@site/static/images/use-cases/observability/ingestion-keys.png'; -所有数据通过 **OpenTelemetry (OTel) 收集器** 实例被输入到 ClickStack 中,该实例作为日志、指标、追踪和会话数据的主要入口点。我们建议为此实例使用官方 [ClickStack 发行版](#installing-otel-collector) 的收集器。 +所有数据都通过一个 **OpenTelemetry (OTel) 收集器** 实例导入到 ClickStack,该实例作为日志、指标、跟踪和会话数据的主要入口点。我们推荐为此实例使用官方的 [ClickStack 分发版](#installing-otel-collector) 收集器。 -用户通过 [语言 SDKs](/use-cases/observability/clickstack/sdks) 或通过收集基础设施指标和日志的数据收集代理(例如以 [代理](/use-cases/observability/clickstack/ingesting-data/otel-collector#collector-roles) 角色运行的 OTel 收集器或其他技术,如 [Fluentd](https://www.fluentd.org/) 或 [Vector](https://vector.dev/))向该收集器发送数据。 +用户可以通过 [语言 SDK](/use-cases/observability/clickstack/sdks) 向这个收集器发送数据,或通过收集基础设施指标和日志的数据收集代理(例如,OTel 收集器在 [代理](/use-cases/observability/clickstack/ingesting-data/otel-collector#collector-roles) 角色或其他技术如 [Fluentd](https://www.fluentd.org/) 或 [Vector](https://vector.dev/))进行发送。 ## 安装 ClickStack OpenTelemetry 收集器 {#installing-otel-collector} -ClickStack OpenTelemetry 收集器包含在大多数 ClickStack 发行版中,包括: +ClickStack OpenTelemetry 收集器包含在大多数 ClickStack 分发版中,包括: -- [一体化](/use-cases/observability/clickstack/deployment/all-in-one) +- [一体化版](/use-cases/observability/clickstack/deployment/all-in-one) - [Docker Compose](/use-cases/observability/clickstack/deployment/docker-compose) - [Helm](/use-cases/observability/clickstack/deployment/helm) @@ -25,41 +26,41 @@ ClickStack OpenTelemetry 收集器包含在大多数 ClickStack 发行版中, ClickStack OTel 收集器也可以独立部署,与堆栈的其他组件无关。 -如果您使用的是 [仅限 HyperDX](/use-cases/observability/clickstack/deployment/hyperdx-only) 发行版,则需要自己将数据发送到 ClickHouse。这可以通过以下方式实现: +如果你使用的是 [仅 HyperDX](/use-cases/observability/clickstack/deployment/hyperdx-only) 分发版,你需要自己负责将数据送入 ClickHouse。可以通过以下方式完成: -- 运行自己的 OpenTelemetry 收集器并指向 ClickHouse - 请参见下文。 -- 使用其他工具(如 [Vector](https://vector.dev/)、[Fluentd](https://www.fluentd.org/) 等)直接发送到 ClickHouse,甚至使用默认的 [OTel contrib 收集器发行版](https://github.com/open-telemetry/opentelemetry-collector-contrib)。 +- 运行你自己的 OpenTelemetry 收集器并将其指向 ClickHouse - 请见下文。 +- 使用其他工具直接发送到 ClickHouse,例如 [Vector](https://vector.dev/)、[Fluentd](https://www.fluentd.org/) 等,或甚至是默认的 [OTel contrib 收集器分发版](https://github.com/open-telemetry/opentelemetry-collector-contrib)。 :::note 我们建议使用 ClickStack OpenTelemetry 收集器 -这使用户能够受益于标准化的数据输入、强制的架构以及与 HyperDX UI 的开箱即用兼容性。使用默认架构可以实现自动源检测和预配置列映射。 +这使得用户能够受益于标准化的导入、强制执行的架构以及与 HyperDX UI 的开箱即用兼容性。使用默认架构可以自动检测源并预配置列映射。 ::: 有关更多详细信息,请参见 ["部署收集器"](/use-cases/observability/clickstack/ingesting-data/otel-collector)。 ## 发送 OpenTelemetry 数据 {#sending-otel-data} -要将数据发送到 ClickStack,请将您的 OpenTelemetry 工具指向 OpenTelemetry 收集器提供的以下端点: +要将数据发送到 ClickStack,请将你的 OpenTelemetry 仪器指向 OpenTelemetry 收集器提供的以下端点: - **HTTP (OTLP):** `http://localhost:4318` - **gRPC (OTLP):** `localhost:4317` -对于大多数支持 OpenTelemetry 的 [语言 SDKs](/use-cases/observability/clickstack/sdks) 和遥测库,用户只需在您的应用程序中设置 `OTEL_EXPORTER_OTLP_ENDPOINT` 环境变量: +对于大多数支持 OpenTelemetry 的 [语言 SDK](/use-cases/observability/clickstack/sdks) 和遥测库,用户可以简单地在应用程序中设置 `OTEL_EXPORTER_OTLP_ENDPOINT` 环境变量: -```bash +```shell export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318 ``` -此外,还需要包含一个包含 API 输入密钥的授权头。您可以在 HyperDX 应用程序的 `团队设置 → API 密钥` 中找到该密钥。 +此外,需要包含一个包含 API 导入密钥的授权头。您可以在 HyperDX 应用的 `团队设置 → API 密钥` 中找到该密钥。 - + -对于语言 SDKs,可以通过 `init` 函数或通过 `OTEL_EXPORTER_OTLP_HEADERS` 环境变量来设置,例如: +对于语言 SDK,可以通过 `init` 函数或 `OTEL_EXPORTER_OTLP_HEADERS` 环境变量设置,例如: -```bash +```shell OTEL_EXPORTER_OTLP_HEADERS='authorization=' ``` -代理同样应在任何 OTLP 通信中包含此授权头。例如,如果在代理角色中部署 [OTel 收集器的 contrib 发行版](https://github.com/open-telemetry/opentelemetry-collector-contrib),它们可以使用 OTLP 导出器。下面是一个示例代理配置,消费此 [结构化日志文件](https://datasets-documentation.s3.eu-west-3.amazonaws.com/http_logs/access-structured.log.gz),请注意需要指定授权密钥 - 请参见 ``。 +代理也应在任何 OTLP 通信中包含此授权头。例如,如果在代理角色中部署 [OTel 收集器的 contrib 分发版](https://github.com/open-telemetry/opentelemetry-collector-contrib),他们可以使用 OTLP 导出器。下面是一个消耗此 [结构化日志文件](https://datasets-documentation.s3.eu-west-3.amazonaws.com/http_logs/access-structured.log.gz) 的示例代理配置。注意需要指定授权密钥 - 参考 ``。 ```yaml diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/opentelemetry.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/opentelemetry.md.hash index f5eeb2e3106..ef4fb6eaae9 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/opentelemetry.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/opentelemetry.md.hash @@ -1 +1 @@ -dba5fd27d00f4f57 +917984bb3130be45 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/overview.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/overview.md index c41fa3796cb..14ed9605a5e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/overview.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/overview.md @@ -5,29 +5,30 @@ 'sidebar_position': 0 'pagination_prev': null 'pagination_next': 'use-cases/observability/clickstack/ingesting-data/opentelemetry' -'description': '用于将数据导入 ClickStack 的概述' +'description': '将数据导入 ClickStack 的概述' +'doc_type': 'guide' --- import Image from '@theme/IdealImage'; import architecture_with_flow from '@site/static/images/use-cases/observability/simple-architecture-with-flow.png'; -所有数据通过 **OpenTelemetry (OTel) 收集器** 输入到 ClickStack,该收集器充当日志、指标、跟踪和会话数据的主要入口点。 +所有数据都通过一个 **OpenTelemetry (OTel) 收集器** 导入到 ClickStack 中,该收集器作为日志、指标、跟踪和会话数据的主要入口点。 - + -该收集器暴露两个 OTLP 端点: +该收集器暴露了两个 OTLP 端点: - **HTTP** - 端口 `4318` - **gRPC** - 端口 `4317` -用户可以直接从 [语言 SDKs](/use-cases/observability/clickstack/sdks) 或兼容 OTel 的数据收集代理(例如,收集基础设施指标和日志的其他 OTel 收集器)发送数据到这些端点。 +用户可以直接从 [语言 SDKs](/use-cases/observability/clickstack/sdks) 或 OTel 兼容的数据收集代理(例如,收集基础设施指标和日志的其他 OTel 收集器)将数据发送到这些端点。 更具体地说: -- [**语言 SDKs**](/use-cases/observability/clickstack/sdks) 负责从您的应用程序内收集遥测数据 - 最显著的是 **跟踪** 和 **日志** - 并通过 OTLP 端点将这些数据导出到 OpenTelemetry 收集器,该收集器处理数据的输入到 ClickHouse。有关 ClickStack 提供的语言 SDKs 的更多详细信息,请参见 [SDKs](/use-cases/observability/clickstack/sdks)。 +- [**语言 SDKs**](/use-cases/observability/clickstack/sdks) 负责从您的应用程序内部收集遥测数据,最显著的是 **跟踪** 和 **日志**,并通过 OTLP 端点将这些数据导出到 OpenTelemetry 收集器,该收集器处理导入到 ClickHouse 的数据。如需了解 ClickStack 提供的语言 SDKs 的更多详细信息,请参见 [SDKs](/use-cases/observability/clickstack/sdks)。 -- **数据收集代理** 是部署在边缘的代理——在服务器、Kubernetes 节点或与应用程序一起运行。它们收集基础设施遥测数据(例如日志、指标),或直接从使用 SDKs 工具的应用程序接收事件。在这种情况下,代理与应用程序运行在同一主机上,通常作为侧车或 DaemonSet。这些代理将数据转发到中央 ClickStack OTel 收集器,该收集器充当 [网关](/use-cases/observability/clickstack/ingesting-data/otel-collector#collector-roles),通常每个集群、数据中心或区域部署一次。[网关](/use-cases/observability/clickstack/ingesting-data/otel-collector#collector-roles) 接收来自代理或应用程序的 OTLP 事件并处理数据的输入到 ClickHouse。有关更多详细信息,请参见 [OTel 收集器](/use-cases/observability/clickstack/ingesting-data/otel-collector)。这些代理可以是其他 OTel 收集器的实例或替代技术,如 [Fluentd](https://www.fluentd.org/) 或 [Vector](https://vector.dev/)。 +- **数据收集代理** 是在边缘部署的代理——在服务器、Kubernetes 节点或与应用程序并行运行。它们收集基础设施遥测(例如,日志、指标)或直接从使用 SDK 的应用程序接收事件。在这种情况下,代理在与应用程序相同的主机上运行,通常作为一个边车或 DaemonSet。这些代理将数据转发到中央 ClickStack OTel 收集器,该收集器充当 [网关](/use-cases/observability/clickstack/ingesting-data/otel-collector#collector-roles),通常在每个集群、数据中心或区域中部署一次。[网关](/use-cases/observability/clickstack/ingesting-data/otel-collector#collector-roles) 从代理或应用程序接收 OTLP 事件并处理导入到 ClickHouse 的数据。有关更多详细信息,请参见 [OTel 收集器](/use-cases/observability/clickstack/ingesting-data/otel-collector)。这些代理可以是其他 OTel 收集器的实例或替代技术,如 [Fluentd](https://www.fluentd.org/) 或 [Vector](https://vector.dev/)。 :::note OpenTelemetry 兼容性 -虽然 ClickStack 提供自己的语言 SDKs 和定制的 OpenTelemetry,具有增强的遥测和功能,用户还可以无缝使用现有的 OpenTelemetry SDKs 和代理。 +虽然 ClickStack 提供了自己的语言 SDKs 和自定义的 OpenTelemetry,具有增强的遥测和功能,但用户也可以无缝使用现有的 OpenTelemetry SDKs 和代理。 ::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/overview.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/overview.md.hash index e755b4c6ebe..a3178f438e8 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/overview.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/overview.md.hash @@ -1 +1 @@ -a7455698fef81d57 +710782865efb3376 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/schemas.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/schemas.md index 23eca963820..3a70075e6a3 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/schemas.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/schemas.md @@ -2,16 +2,17 @@ 'slug': '/use-cases/observability/clickstack/ingesting-data/schemas' 'pagination_prev': null 'pagination_next': null -'description': 'ClickStack使用的表和架构 - ClickHouse可观察性堆栈' -'sidebar_label': '表和架构' -'title': 'ClickStack使用的表和架构' +'description': 'ClickStack 使用的表和模式 - ClickHouse 可观察性堆栈' +'sidebar_label': '表和模式' +'title': 'ClickStack 使用的表和模式' +'doc_type': 'reference' --- -The ClickStack OpenTelemetry (OTel) 收集器使用 [ClickHouse 导出器](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/exporter/clickhouseexporter/README.md) 在 ClickHouse 中创建表并插入数据。 +The ClickStack OpenTelemetry (OTel) collector uses the [ClickHouse exporter](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/exporter/clickhouseexporter/README.md) to create tables in ClickHouse and insert data. -在 `default` 数据库中为每种数据类型创建以下表。用户可以通过修改环境变量 `HYPERDX_OTEL_EXPORTER_CLICKHOUSE_DATABASE` 来更改目标数据库,以便托管 OTel 收集器的镜像。 +The following tables are created for each data type in the `default` database. Users can change this target database by modifying the environment variable `HYPERDX_OTEL_EXPORTER_CLICKHOUSE_DATABASE` for the image hosting the OTel collector. -## 日志 {#logs} +## Logs {#logs} ```sql CREATE TABLE otel_logs @@ -47,7 +48,7 @@ PRIMARY KEY (ServiceName, TimestampTime) ORDER BY (ServiceName, TimestampTime, Timestamp) ``` -## 跟踪 {#traces} +## Traces {#traces} ```sql CREATE TABLE otel_traces @@ -86,9 +87,9 @@ PARTITION BY toDate(Timestamp) ORDER BY (ServiceName, SpanName, toDateTime(Timestamp)) ``` -## 指标 {#metrics} +## Metrics {#metrics} -### 计量指标 {#gauge} +### Gauge metrics {#gauge} ```sql CREATE TABLE otel_metrics_gauge @@ -126,7 +127,7 @@ PARTITION BY toDate(TimeUnix) ORDER BY (ServiceName, MetricName, Attributes, toUnixTimestamp64Nano(TimeUnix)) ``` -### 总和指标 {#sum} +### Sum metrics {#sum} ```sql CREATE TABLE otel_metrics_sum @@ -166,7 +167,7 @@ PARTITION BY toDate(TimeUnix) ORDER BY (ServiceName, MetricName, Attributes, toUnixTimestamp64Nano(TimeUnix)) ``` -### 直方图指标 {#histogram} +### Histogram metrics {#histogram} ```sql CREATE TABLE otel_metrics_histogram @@ -208,14 +209,16 @@ CREATE TABLE otel_metrics_histogram ENGINE = SharedMergeTree('/clickhouse/tables/{uuid}/{shard}', '{replica}') PARTITION BY toDate(TimeUnix) ORDER BY (ServiceName, MetricName, Attributes, toUnixTimestamp64Nano(TimeUnix)) -SETTINGS index_granularity = 8192" ``` -### 指数直方图 {#exponential-histograms} +### Exponential histograms {#exponential-histograms} + +:::note +HyperDX 目前不支持获取/显示指数直方图指标。用户可以在指标源中配置它们,但未来将会有支持。 +::: ```sql -CREATE TABLE otel_metrics_histogram -( +CREATE TABLE otel_metrics_exponentialhistogram ( `ResourceAttributes` Map(LowCardinality(String), String) CODEC(ZSTD(1)), `ResourceSchemaUrl` String CODEC(ZSTD(1)), `ScopeName` String CODEC(ZSTD(1)), @@ -228,18 +231,24 @@ CREATE TABLE otel_metrics_histogram `MetricDescription` String CODEC(ZSTD(1)), `MetricUnit` String CODEC(ZSTD(1)), `Attributes` Map(LowCardinality(String), String) CODEC(ZSTD(1)), - `StartTimeUnix` DateTime64(9) CODEC(Delta(8), ZSTD(1)), - `TimeUnix` DateTime64(9) CODEC(Delta(8), ZSTD(1)), - `Count` UInt64 CODEC(Delta(8), ZSTD(1)), + `StartTimeUnix` DateTime64(9) CODEC(Delta, ZSTD(1)), + `TimeUnix` DateTime64(9) CODEC(Delta, ZSTD(1)), + `Count` UInt64 CODEC(Delta, ZSTD(1)), `Sum` Float64 CODEC(ZSTD(1)), - `BucketCounts` Array(UInt64) CODEC(ZSTD(1)), - `ExplicitBounds` Array(Float64) CODEC(ZSTD(1)), - `Exemplars.FilteredAttributes` Array(Map(LowCardinality(String), String)) CODEC(ZSTD(1)), - `Exemplars.TimeUnix` Array(DateTime64(9)) CODEC(ZSTD(1)), - `Exemplars.Value` Array(Float64) CODEC(ZSTD(1)), - `Exemplars.SpanId` Array(String) CODEC(ZSTD(1)), - `Exemplars.TraceId` Array(String) CODEC(ZSTD(1)), - `Flags` UInt32 CODEC(ZSTD(1)), + `Scale` Int32 CODEC(ZSTD(1)), + `ZeroCount` UInt64 CODEC(ZSTD(1)), + `PositiveOffset` Int32 CODEC(ZSTD(1)), + `PositiveBucketCounts` Array(UInt64) CODEC(ZSTD(1)), + `NegativeOffset` Int32 CODEC(ZSTD(1)), + `NegativeBucketCounts` Array(UInt64) CODEC(ZSTD(1)), + `Exemplars` Nested ( + FilteredAttributes Map(LowCardinality(String), String), + TimeUnix DateTime64(9), + Value Float64, + SpanId String, + TraceId String + ) CODEC(ZSTD(1)), + `Flags` UInt32 CODEC(ZSTD(1)), `Min` Float64 CODEC(ZSTD(1)), `Max` Float64 CODEC(ZSTD(1)), `AggregationTemporality` Int32 CODEC(ZSTD(1)), @@ -255,7 +264,7 @@ PARTITION BY toDate(TimeUnix) ORDER BY (ServiceName, MetricName, Attributes, toUnixTimestamp64Nano(TimeUnix)) ``` -### 概要表 {#summary-table} +### Summary table {#summary-table} ```sql CREATE TABLE otel_metrics_summary @@ -291,7 +300,7 @@ PARTITION BY toDate(TimeUnix) ORDER BY (ServiceName, MetricName, Attributes, toUnixTimestamp64Nano(TimeUnix)) ``` -## 会话 {#sessions} +## Sessions {#sessions} ```sql CREATE TABLE hyperdx_sessions diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/schemas.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/schemas.md.hash index e1b339cdfc0..88d17172eee 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/schemas.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/schemas.md.hash @@ -1 +1 @@ -b18f62e7cbc925ce +fc17ee779bc9fb1a diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/aws-lambda.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/aws-lambda.md new file mode 100644 index 00000000000..13804e7e290 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/aws-lambda.md @@ -0,0 +1,260 @@ +--- +'slug': '/use-cases/observability/clickstack/sdks/aws_lambda' +'pagination_prev': null +'pagination_next': null +'sidebar_position': 6 +'description': 'AWS Lambda 用于 ClickStack - ClickHouse 可观察性堆栈' +'title': 'AWS Lambda' +'doc_type': 'guide' +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +**本指南集成了:** + +
+ + + + + + + +
✅ 日志✅ 指标✅ 跟踪
+ +## 安装 OpenTelemetry Lambda 层 {#installing-the-otel-lambda-layers} + +OpenTelemetry 项目提供了单独的 Lambda 层,以: + +1. 使用 OpenTelemetry 自动仪器化自动仪器化您的 Lambda 函数代码。 +2. 将收集到的日志、指标和跟踪转发到 ClickStack。 + +### 添加特定语言的自动仪器化层 {#adding-language-specific-auto-instrumentation} + +特定语言的自动仪器化 Lambda 层自动使用适用于您特定语言的 OpenTelemetry 自动仪器化包来仪器化您的 Lambda 函数代码。 + +每种语言和区域都有其自己的层 ARN。 + +如果您的 Lambda 已经使用 OpenTelemetry SDK 进行了仪器化,您可以跳过此步骤。 + +**开始使用**: + +1. 在 Layers 部分点击“添加层” +2. 选择指定 ARN,并根据语言选择正确的 ARN,确保将 `` 替换为您的区域(例如 `us-east-2`): + + + + +```shell +arn:aws:lambda::184161586896:layer:opentelemetry-nodejs-0_7_0:1 +``` + + + + +```shell copy +arn:aws:lambda::184161586896:layer:opentelemetry-python-0_7_0:1 +``` + + + + + +```shell copy +arn:aws:lambda::184161586896:layer:opentelemetry-javaagent-0_6_0:1 +``` + + + + + +```shell copy +arn:aws:lambda::184161586896:layer:opentelemetry-ruby-0_1_0:1 +``` + + + + + +_最新的层释放可以在 [OpenTelemetry Lambda Layers GitHub 仓库](https://github.com/open-telemetry/opentelemetry-lambda/releases) 中找到。_ + +3. 在您的 Lambda 函数的“配置” > “环境变量”下配置以下环境变量。 + + + + +```shell +OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318 +AWS_LAMBDA_EXEC_WRAPPER=/opt/otel-handler +OTEL_PROPAGATORS=tracecontext +OTEL_TRACES_SAMPLER=always_on +``` + + + + +```shell +OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318 +AWS_LAMBDA_EXEC_WRAPPER=/opt/otel-instrument +OTEL_PROPAGATORS=tracecontext +OTEL_TRACES_SAMPLER=always_on +``` + + + + + +```shell +OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318 +AWS_LAMBDA_EXEC_WRAPPER=/opt/otel-handler +OTEL_PROPAGATORS=tracecontext +OTEL_TRACES_SAMPLER=always_on +``` + + + + + +```shell +OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318 +AWS_LAMBDA_EXEC_WRAPPER=/opt/otel-handler +OTEL_PROPAGATORS=tracecontext +OTEL_TRACES_SAMPLER=always_on +``` + + + + + +### 安装 OpenTelemetry 收集器 Lambda 层 {#installing-the-otel-collector-layer} + +收集器 Lambda 层允许您将日志、指标和跟踪从您的 Lambda 函数转发到 ClickStack,而不会受到出口延迟的影响,影响响应时间。 + +**要安装收集器层**: + +1. 在 Layers 部分点击“添加层” +2. 选择指定 ARN,并根据架构选择正确的 ARN,确保将 `` 替换为您的区域(例如 `us-east-2`): + + + + + +```shell +arn:aws:lambda::184161586896:layer:opentelemetry-collector-amd64-0_8_0:1 +``` + + + + + +```shell +arn:aws:lambda::184161586896:layer:opentelemetry-collector-arm64-0_8_0:1 +``` + + + + + +3. 将以下 `collector.yaml` 文件添加到您的项目中,以配置收集器将数据发送到 ClickStack: + +```yaml + +# collector.yaml +receivers: + otlp: + protocols: + grpc: + endpoint: 'localhost:4317' + http: + endpoint: 'localhost:4318' + +processors: + batch: + decouple: + +exporters: + otlphttp: + endpoint: " + headers: + authorization: + compression: gzip + +service: + pipelines: + traces: + receivers: [otlp] + processors: [batch, decouple] + exporters: [otlphttp] + metrics: + receivers: [otlp] + processors: [batch, decouple] + exporters: [otlphttp] + logs: + receivers: [otlp] + processors: [batch, decouple] + exporters: [otlphttp] +``` + +4. 添加以下环境变量: + +```shell +OPENTELEMETRY_COLLECTOR_CONFIG_FILE=/var/task/collector.yaml +``` + +## 检查安装 {#checking-the-installation} + +在部署层之后,您现在应该能够在 HyperDX 中看到自动收集的来自您的 Lambda 函数的跟踪。`decouple` 和 `batching` 处理器可能会在遥测收集过程中引入延迟,因此跟踪的显示可能会延迟。要发出自定义日志或指标,您需要使用特定于语言的 OpenTelemetry SDK 对您的代码进行仪器化。 + +## 故障排除 {#troubleshoting} + +### 自定义仪器化未发送 {#custom-instrumentation-not-sending} + +如果您没有看到手动定义的跟踪或其他遥测,您可能正在使用不兼容版本的 OpenTelemetry API 包。确保您的 OpenTelemetry API 包版本至少与 AWS Lambda 中包含的版本相同或更低。 + +### 启用 SDK 调试日志 {#enabling-sdk-debug-logs} + +将 `OTEL_LOG_LEVEL` 环境变量设置为 `DEBUG` 以启用来自 OpenTelemetry SDK 的调试日志。这将帮助确保自动仪器化层正在正确仪器化您的应用程序。 + +### 启用收集器调试日志 {#enabling-collector-debug-logs} + +要调试收集器问题,您可以通过修改收集器配置文件来启用调试日志,添加 `logging` 导出器并将遥测日志级别设置为 `debug`,以启用来自收集器 Lambda 层的更详细日志记录。 + +```yaml + +# collector.yaml +receivers: + otlp: + protocols: + grpc: + endpoint: 'localhost:4317' + http: + endpoint: 'localhost:4318' + +exporters: + logging: + verbosity: detailed + otlphttp: + endpoint: "https://in-otel.hyperdx.io" + headers: + authorization: + compression: gzip + +service: + telemetry: + logs: + level: "debug" + pipelines: + traces: + receivers: [otlp] + processors: [batch, decouple] + exporters: [otlphttp, logging] + metrics: + receivers: [otlp] + processors: [batch, decouple] + exporters: [otlphttp, logging] + logs: + receivers: [otlp] + processors: [batch, decouple] + exporters: [otlphttp, logging] +``` diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/aws-lambda.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/aws-lambda.md.hash new file mode 100644 index 00000000000..b7a46924c19 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/aws-lambda.md.hash @@ -0,0 +1 @@ +1496446906f3647b diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/browser.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/browser.md index b629a5144f7..9f933b3ea2e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/browser.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/browser.md @@ -3,42 +3,47 @@ 'pagination_prev': null 'pagination_next': null 'sidebar_position': 0 -'description': '浏览器 SDK 用于 ClickStack - ClickHouse 可观察性堆栈' +'description': 'ClickStack 的浏览器 SDK - ClickHouse 观测堆栈' 'title': '浏览器 JS' +'doc_type': 'guide' --- import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; -The ClickStack browser SDK允许您为前端应用程序添加监控功能,向ClickStack发送事件。这使您能够在单一时间轴中查看网络请求和异常以及后端事件。 +The ClickStack browser SDK allows you to instrument your frontend application to +send events to ClickStack. This allows you to view network +requests and exceptions alongside backend events in a single timeline. -此外,它将自动捕获并关联会话重放数据,因此您可以直观地逐步调试用户在使用您的应用程序时所看到的内容。 +Additionally, it'll automatically capture and correlate session replay data, so +you can visually step through and debug what a user was seeing while using your +application. -本指南集成了以下内容: +This guide integrates the following: - **控制台日志** - **会话重放** - **XHR/Fetch/Websocket 请求** - **异常** -## 获取开始 {#getting-started} +## 入门 {#getting-started}
-**通过包导入安装 (推荐)** +**通过包导入安装(推荐)** 使用以下命令安装 [browser package](https://www.npmjs.com/package/@hyperdx/browser)。 -```bash +```shell npm install @hyperdx/browser ``` **初始化 ClickStack** -```js +```javascript import HyperDX from '@hyperdx/browser'; HyperDX.init({ @@ -54,11 +59,11 @@ HyperDX.init({ -**通过脚本标签安装 (备用)** +**通过脚本标签安装(替代方法)** -您还可以通过脚本标签包含并安装脚本,而不是通过NPM安装。如果这样做,将会暴露 `HyperDX` 全局变量,并可以像 NPM 包一样使用。 +您也可以通过脚本标签而不是通过 NPM 安装来包含和安装脚本。这将暴露 `HyperDX` 全局变量,并可以与 NPM 包以相同的方式使用。 -如果您的网站不是使用打包工具构建的,推荐使用这种方式。 +如果您的网站当前不是使用捆绑工具构建的,建议使用此方法。 ```html @@ -75,29 +80,28 @@ HyperDX.init({ - ### 选项 {#options} - `apiKey` - 您的 ClickStack 数据接收 API 密钥。 - `service` - 事件在 HyperDX UI 中显示的服务名称。 -- `tracePropagationTargets` - 用于匹配 HTTP 请求的正则表达式模式列表,以链接前端和后端跟踪,它将为匹配任何模式的所有请求添加一个额外的 `traceparent` 头。此项应设置为您的后端 API 域名(例如:`api.yoursite.com`)。 +- `tracePropagationTargets` - 匹配 HTTP 请求的正则表达式模式列表,以链接前端和后端追踪,它将向所有匹配任何模式的请求添加额外的 `traceparent` 头。此值应设置为您的后端 API 域(例如 `api.yoursite.com`)。 - `consoleCapture` - (可选)捕获所有控制台日志(默认 `false`)。 -- `advancedNetworkCapture` - (可选)捕获完整的请求/响应头和主体(默认 `false`)。 -- `url` - (可选)OpenTelemetry 收集器 URL,仅对自托管实例需要。 +- `advancedNetworkCapture` - (可选)捕获完整的请求/响应头和主体(默认 false)。 +- `url` - (可选)OpenTelemetry 收集器 URL,仅需要用于自托管实例。 - `maskAllInputs` - (可选)是否在会话重放中掩盖所有输入字段(默认 `false`)。 - `maskAllText` - (可选)是否在会话重放中掩盖所有文本(默认 `false`)。 -- `disableIntercom` - (可选)是否禁用 Intercom 集成(默认 `false`)。 -- `disableReplay` - (可选)是否禁用会话重放(默认 `false`)。 +- `disableIntercom` - (可选)是否禁用 Intercom 集成(默认 `false`) +- `disableReplay` - (可选)是否禁用会话重放(默认 `false`) -## 附加配置 {#additional-configuration} +## 其他配置 {#additional-configuration} ### 附加用户信息或元数据 {#attach-user-information-or-metadata} -附加用户信息将允许您在 HyperDX UI 中搜索/过滤会话和事件。此操作可以在客户端会话的任何时刻调用。当前客户端会话和在调用之后发送的所有事件将与用户信息关联。 +附加用户信息将允许您在 HyperDX UI 中搜索/过滤会话和事件。此操作可以在客户端会话的任何时候调用。当前客户端会话及呼叫后发送的所有事件将与用户信息关联。 -`userEmail`、`userName` 和 `teamName` 将相应地填充会话 UI,但可以省略。可以指定任何其他附加值,并用于搜索事件。 +`userEmail`、`userName` 和 `teamName` 将在会话 UI 中填充相应的值,但可以省略。可以指定并使用任何其他附加值来搜索事件。 -```js +```javascript HyperDX.setGlobalAttributes({ userId: user.id, userEmail: user.email, @@ -109,9 +113,9 @@ HyperDX.setGlobalAttributes({ ### 自动捕获 React 错误边界错误 {#auto-capture-react-error-boundary-errors} -如果您正在使用 React,可以通过将您的错误边界组件传递给 `attachToReactErrorBoundary` 函数来自动捕获发生在 React 错误边界内的错误。 +如果您使用 React,可以通过将您的错误边界组件传入 `attachToReactErrorBoundary` 函数,自动捕获发生在 React 错误边界中的错误。 -```js +```javascript // Import your ErrorBoundary (we're using react-error-boundary as an example) import { ErrorBoundary } from 'react-error-boundary'; @@ -122,11 +126,11 @@ HyperDX.attachToReactErrorBoundary(ErrorBoundary); ### 发送自定义操作 {#send-custom-actions} -要明确跟踪特定的应用程序事件(例如:注册、提交等),您可以调用 `addAction` 函数,传递事件名称和可选事件元数据。 +要显式跟踪特定应用事件(例如注册、提交等),可以调用 `addAction` 函数,并传入事件名称和可选事件元数据。 示例: -```js +```javascript HyperDX.addAction('Form-Completed', { formId: 'signup-form', formName: 'Signup Form', @@ -136,19 +140,19 @@ HyperDX.addAction('Form-Completed', { ### 动态启用网络捕获 {#enable-network-capture-dynamically} -要动态启用或禁用网络捕获,只需按需调用 `enableAdvancedNetworkCapture` 或 `disableAdvancedNetworkCapture` 函数。 +要动态启用或禁用网络捕获,只需在需要时调用 `enableAdvancedNetworkCapture` 或 `disableAdvancedNetworkCapture` 函数。 -```js +```javascript HyperDX.enableAdvancedNetworkCapture(); ``` ### 为 CORS 请求启用资源计时 {#enable-resource-timing-for-cors-requests} -如果您的前端应用程序向不同的域发出 API 请求,您可以选择启用 `Timing-Allow-Origin`[header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Timing-Allow-Origin)随请求发送。这将允许 ClickStack 捕获请求的细粒度资源计时信息,例如 DNS 查找、响应下载等,通过 [`PerformanceResourceTiming`](https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming)。 +如果您的前端应用程序向不同域发出 API 请求,您可以选择性地启用 `Timing-Allow-Origin`[header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Timing-Allow-Origin) 以与请求一起发送。这将允许 ClickStack 捕获细粒度的资源计时信息,如 DNS 查找、响应下载等,通过 [`PerformanceResourceTiming`](https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming)。 -如果您使用 `express` 和 `cors` 包,可以使用以下代码片段来启用该头: +如果您在使用 `express` 和 `cors` 包,您可以使用以下代码片段来启用头: -```js +```javascript var cors = require('cors'); var onHeaders = require('on-headers'); diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/browser.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/browser.md.hash index 76a18d2ea89..253eab3cf61 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/browser.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/browser.md.hash @@ -1 +1 @@ -1f6ea0bb77f4c02b +0330ded1220b12cf diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/deno.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/deno.md index 0f442747ddb..a8c1c9c66b2 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/deno.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/deno.md @@ -3,21 +3,22 @@ 'pagination_prev': null 'pagination_next': null 'sidebar_position': 6 -'description': 'Deno SDK for ClickStack - ClickHouse 观察性堆栈' +'description': 'Deno SDK 用于 ClickStack - ClickHouse 观察性堆栈' 'title': 'Deno' +'doc_type': 'guide' --- -该指南集成了以下内容: +本指南整合了以下内容: - **日志** :::note -当前仅支持 OpenTelemetry 日志记录。有关跟踪支持,请 [参阅以下指南](https://dev.to/grunet/leveraging-opentelemetry-in-deno-45bj#a-minimal-interesting-example)。 +当前仅支持 OpenTelemetry 日志记录。如需支持跟踪,请[查看以下指南](https://dev.to/grunet/leveraging-opentelemetry-in-deno-45bj#a-minimal-interesting-example)。 ::: ## 日志 {#logging} -通过导出自定义记录器来支持日志记录,适用于 `std/log` 模块。 +通过为 `std/log` 模块导出自定义日志记录器来支持日志记录。 **示例用法:** @@ -43,7 +44,7 @@ log.getLogger('my-otel-logger').info('Hello from Deno!'); ### 运行应用程序 {#run-the-application} -```sh +```shell OTEL_EXPORTER_OTLP_HEADERS="authorization=" \ OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318 \ OTEL_SERVICE_NAME="" \ diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/deno.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/deno.md.hash index ea7d2d53125..f2db00c7b4c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/deno.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/deno.md.hash @@ -1 +1 @@ -df95bf7c6031a4cb +34a4c347c4db00b1 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/elixir.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/elixir.md index 74cd149380a..eefeecadccd 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/elixir.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/elixir.md @@ -3,8 +3,9 @@ 'pagination_prev': null 'pagination_next': null 'sidebar_position': 1 -'description': 'Elixir SDK 用于 ClickStack - ClickHouse 观察性堆栈' +'description': 'Elixir SDK 用于 ClickStack - ClickHouse 可观察性堆栈' 'title': 'Elixir' +'doc_type': 'guide' --- @@ -16,13 +17,13 @@
-_🚧 OpenTelemetry 指标和跟踪工具即将推出!_ +_🚧 OpenTelemetry 指标和跟踪仪表 instrumentation 即将推出!_ -## 开始使用 {#getting-started} +## 入门 {#getting-started} -### 安装 ClickStack 日志记录后端包 {#install-hyperdx-logger-backend-package} +### 安装 ClickStack 日志后端包 {#install-hyperdx-logger-backend-package} -通过在 `mix.exs` 中将 `hyperdx` 添加到你的依赖列表,可以安装该包: +可以通过将 `hyperdx` 添加到 `mix.exs` 中的依赖列表来安装该包: ```elixir def deps do @@ -34,7 +35,7 @@ end ### 配置日志记录器 {#configure-logger} -在你的 `config.exs` 文件中添加以下内容: +在 `config.exs` 文件中添加以下内容: ```elixir @@ -47,11 +48,11 @@ config :logger, ### 配置环境变量 {#configure-environment-variables} -随后你需要在你的 shell 中配置以下环境变量,以将遥测数据发送到 ClickStack: +之后,您需要在 shell 中配置以下环境变量,以将遥测数据发送到 ClickStack: -```bash +```shell export HYPERDX_API_KEY='' \ OTEL_SERVICE_NAME='' ``` -_`OTEL_SERVICE_NAME` 环境变量用于在 HyperDX 应用中识别你的服务,它可以是你想要的任何名称。_ +_`OTEL_SERVICE_NAME` 环境变量用于在 HyperDX 应用中识别您的服务,您可以使用任意名称。_ diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/elixir.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/elixir.md.hash index 7c17b2a8cce..b81decd477d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/elixir.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/elixir.md.hash @@ -1 +1 @@ -02191870cce35355 +f33d8382c026bed0 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/golang.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/golang.md index 8c2f9193fd4..d4a6d2984eb 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/golang.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/golang.md @@ -3,46 +3,47 @@ 'pagination_prev': null 'pagination_next': null 'sidebar_position': 2 -'description': 'Golang SDK 用于 ClickStack - ClickHouse 观测栈' +'description': 'Golang SDK 用于 ClickStack - ClickHouse 观察栈' 'title': 'Golang' +'doc_type': 'guide' --- -ClickStack 使用 OpenTelemetry 标准来收集遥测数据(日志和追踪)。追踪是通过自动仪表化自动生成的,因此不需要手动仪表化即可从追踪中获取价值。 +ClickStack使用OpenTelemetry标准来收集遥测数据(日志和跟踪)。跟踪是通过自动插装自动生成的,因此不需要手动插装即可从跟踪中获取价值。 -**本指南整合了:** +**本指南集成了:** - - + +
✅ 日志✅ 度量✅ 追踪✅ 指标✅ 跟踪
## 开始使用 {#getting-started} -### 安装 OpenTelemetry 仪表化包 {#install-opentelemetry} +### 安装OpenTelemetry插装包 {#install-opentelemetry} -要安装 OpenTelemetry 和 HyperDX Go 包,请使用下面的命令。建议查看[当前的仪表化包](https://github.com/open-telemetry/opentelemetry-go-contrib/tree/v1.4.0/instrumentation#instrumentation-packages)并安装必要的包,以确保追踪信息正确附加。 +要安装OpenTelemetry和HyperDX Go包,请使用以下命令。建议查看[当前插装包](https://github.com/open-telemetry/opentelemetry-go-contrib/tree/v1.4.0/instrumentation#instrumentation-packages),并安装必要的包以确保追踪信息正确附加。 -```bash +```shell go get -u go.opentelemetry.io/otel go get -u github.com/hyperdxio/otel-config-go go get -u github.com/hyperdxio/opentelemetry-go go get -u github.com/hyperdxio/opentelemetry-logs-go ``` -### 原生 HTTP 服务器示例 (net/http) {#native-http-server-example} +### 原生HTTP服务器示例(net/http) {#native-http-server-example} -在此示例中,我们将使用 `net/http/otelhttp`。 +在此示例中,我们将使用`net/http/otelhttp`。 -```sh +```shell go get -u go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp ``` -请参考注释部分了解如何对您的 Go 应用程序进行仪表化。 +请参阅注释部分以了解如何插装您的Go应用程序。 ```go @@ -142,16 +143,15 @@ func ExampleHandler(w http.ResponseWriter, r *http.Request) { } ``` +### Gin应用程序示例 {#gin-application-example} -### Gin 应用程序示例 {#gin-application-example} +在此示例中,我们将使用`gin-gonic/gin`。 -在此示例中,我们将使用 `gin-gonic/gin`。 - -```sh +```shell go get -u go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin ``` -请参考注释部分了解如何对您的 Go 应用程序进行仪表化。 +请参阅注释部分以了解如何插装您的Go应用程序。 ```go @@ -227,16 +227,15 @@ func main() { } ``` - ### 配置环境变量 {#configure-environment-variables} -之后,您需要在您的 shell 中配置以下环境变量,以便将遥测数据发送到 ClickStack: +之后,您需要在Shell中配置以下环境变量,以将遥测信息发送到ClickStack: -```sh +```shell export OTEL_EXPORTER_OTLP_ENDPOINT=https://localhost:4318 \ OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf \ OTEL_SERVICE_NAME='' \ OTEL_EXPORTER_OTLP_HEADERS='authorization=' ``` -`OTEL_EXPORTER_OTLP_HEADERS` 环境变量包含可通过 HyperDX 应用在 `团队设置 → API 密钥` 中获得的 API 密钥。 +`OTEL_EXPORTER_OTLP_HEADERS`环境变量包含可通过HyperDX应用程序在`团队设置 → API密钥`中获得的API密钥。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/golang.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/golang.md.hash index 82fd2a77b7d..ed28423ae7d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/golang.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/golang.md.hash @@ -1 +1 @@ -b4785800a5497827 +8622da699fa4c320 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/index.md index b42f6a4b56f..ce4ccc1094d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/index.md @@ -2,66 +2,68 @@ 'slug': '/use-cases/observability/clickstack/sdks' 'pagination_prev': null 'pagination_next': null -'description': '编程语言 SDKs 用于 ClickStack - ClickHouse 可观察性栈' -'title': '编程语言 SDKs' +'description': '语言 SDK 用于 ClickStack - ClickHouse 观察性堆栈' +'title': '语言 SDK' +'doc_type': 'guide' --- -用户通常通过 **OpenTelemetry (OTel) 收集器** 将数据发送到 ClickStack,数据可以直接来自语言 SDK 或通过充当代理的中间 OpenTelemetry 收集器,例如收集基础设施指标和日志。 +数据通常通过 **OpenTelemetry (OTel) 收集器** 发送到 ClickStack,数据可直接来自语言 SDK,或通过充当代理的中间 OpenTelemetry 收集器,例如收集基础设施指标和日志。 -语言 SDK 负责从您的应用程序内部收集遥测数据,尤其是 **跟踪** 和 **日志**,并通过 OTLP 端点将这些数据导出到 OpenTelemetry 收集器,该收集器负责将数据摄取到 ClickHouse 中。 +语言 SDK 负责从您的应用程序内部收集遥测数据,最显著的是 **跟踪(traces)** 和 **日志(logs)**,并通过 OTLP 端点将这些数据导出到 OpenTelemetry 收集器,该收集器处理数据的摄取到 ClickHouse。 -在基于浏览器的环境中,SDK 还可能负责收集 **会话数据**,包括用户界面事件、点击和导航,从而实现用户会话的重放。 +在基于浏览器的环境中,SDK 还可能负责收集 **会话数据(session data)**,包括 UI 事件、点击和导航,从而使用户会话可以重放。 ## 工作原理 {#how-it-works} 1. 您的应用程序使用 ClickStack SDK(例如,Node.js、Python、Go)。这些 SDK 基于 OpenTelemetry SDK,并具有额外的功能和可用性增强。 2. SDK 通过 OTLP(HTTP 或 gRPC)收集并导出跟踪和日志。 -3. OpenTelemetry 收集器接收遥测数据,并通过配置的导出程序将其写入 ClickHouse。 +3. OpenTelemetry 收集器接收遥测数据并通过配置的导出器将其写入 ClickHouse。 ## 支持的语言 {#supported-languages} :::note OpenTelemetry 兼容性 -虽然 ClickStack 提供其自己的语言 SDK,附带增强的遥测和功能,但用户也可以无缝使用现有的 OpenTelemetry SDK。 +虽然 ClickStack 提供了自己增强的遥测和功能的语言 SDK,但您也可以无缝使用他们现有的 OpenTelemetry SDK。 :::
-| 语言 | 描述 | 链接 | -|------------|------------------------------------------|-------------------------------------------------------------------| -| 浏览器 | 用于基于浏览器应用程序的 JavaScript SDK | [文档](/use-cases/observability/clickstack/sdks/browser) | -| Elixir | Elixir 应用程序 | [文档](/use-cases/observability/clickstack/sdks/elixir) | -| Go | Go 应用程序和微服务 | [文档](/use-cases/observability/clickstack/sdks/golang) | -| Java | Java 应用程序 | [文档](/use-cases/observability/clickstack/sdks/java) | -| NestJS | NestJS 应用程序 | [文档](/use-cases/observability/clickstack/sdks/nestjs) | -| Next.js | Next.js 应用程序 | [文档](/use-cases/observability/clickstack/sdks/nextjs) | -| Node.js | 用于服务器端应用程序的 JavaScript 运行时 | [文档](/use-cases/observability/clickstack/sdks/nodejs) | -| Deno | Deno 应用程序 | [文档](/use-cases/observability/clickstack/sdks/deno) | -| Python | Python 应用程序和 Web 服务 | [文档](/use-cases/observability/clickstack/sdks/python) | -| React Native| React Native 移动应用程序 | [文档](/use-cases/observability/clickstack/sdks/react-native) | -| Ruby | Ruby on Rails 应用程序和 Web 服务 | [文档](/use-cases/observability/clickstack/sdks/ruby-on-rails) | - -## 使用 API 密钥进行安全保护 {#securing-api-key} - -为了通过 OTel 收集器将数据发送到 ClickStack,SDK 需要指定一个摄取 API 密钥。可以通过 SDK 中的 `init` 函数或 `OTEL_EXPORTER_OTLP_HEADERS` 环境变量进行设置: - -```bash +| 语言 | 描述 | 链接 | +|------|------|------| +| AWS Lambda | 监控您的 AWS Lambda 函数 | [文档](/use-cases/observability/clickstack/sdks/aws_lambda) | +| 浏览器 | 用于基于浏览器的应用程序的 JavaScript SDK | [文档](/use-cases/observability/clickstack/sdks/browser) | +| Elixir | Elixir 应用程序 | [文档](/use-cases/observability/clickstack/sdks/elixir) | +| Go | Go 应用程序和微服务 | [文档](/use-cases/observability/clickstack/sdks/golang) | +| Java | Java 应用程序 | [文档](/use-cases/observability/clickstack/sdks/java) | +| NestJS | NestJS 应用程序 | [文档](/use-cases/observability/clickstack/sdks/nestjs) | +| Next.js | Next.js 应用程序 | [文档](/use-cases/observability/clickstack/sdks/nextjs) | +| Node.js | 用于服务器端应用程序的 JavaScript 运行时 | [文档](/use-cases/observability/clickstack/sdks/nodejs) | +| Deno | Deno 应用程序 | [文档](/use-cases/observability/clickstack/sdks/deno) | +| Python | Python 应用程序和网络服务 | [文档](/use-cases/observability/clickstack/sdks/python) | +| React Native | React Native 移动应用 | [文档](/use-cases/observability/clickstack/sdks/react-native) | +| Ruby | Ruby on Rails 应用程序和网络服务 | [文档](/use-cases/observability/clickstack/sdks/ruby-on-rails) | + +## 使用 API 密钥进行安全设置 {#securing-api-key} + +为了通过 OTel 收集器将数据发送到 ClickStack,SDK 需要指定一个摄取 API 密钥。这可以通过 SDK 中的 `init` 函数或者 `OTEL_EXPORTER_OTLP_HEADERS` 环境变量进行设置: + +```shell OTEL_EXPORTER_OTLP_HEADERS='authorization=' ``` -该 API 密钥由 HyperDX 应用生成,可以在应用中的 `团队设置 → API 密钥` 中找到。 +此 API 密钥由 HyperDX 应用生成,并且可以通过应用中的 `团队设置 → API 密钥` 获得。 -对于大多数支持 OpenTelemetry 的 [语言 SDK](/use-cases/observability/clickstack/sdks) 和遥测库,用户只需在应用程序中设置 `OTEL_EXPORTER_OTLP_ENDPOINT` 环境变量,或在初始化 SDK 时指定: +对于大多数 [语言 SDK](/use-cases/observability/clickstack/sdks) 和支持 OpenTelemetry 的遥测库,您可以简单地在应用中设置 `OTEL_EXPORTER_OTLP_ENDPOINT` 环境变量,或者在初始化 SDK 时指定它: -```bash +```shell export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318 ``` ## Kubernetes 集成 {#kubernetes-integration} -所有 SDK 支持在 Kubernetes 环境中运行时与 Kubernetes 元数据(如 pod 名称、命名空间等)的自动关联。这使您能够: +所有 SDK 都支持在 Kubernetes 环境中自动关联 Kubernetes 元数据(pod 名称、命名空间等)。这使您能够: -- 查看与您的服务相关联的 Pods 和节点的 Kubernetes 指标 -- 将应用程序日志和跟踪与基础设施指标关联 -- 跟踪整个 Kubernetes 集群的资源使用情况和性能 +- 查看与您的服务相关的 pod 和节点的 Kubernetes 指标 +- 将应用日志和跟踪与基础设施指标相关联 +- 跟踪 Kubernetes 集群中的资源使用和性能 -要启用此功能,请配置 OpenTelemetry 收集器以将资源标签转发至 Pods。有关详细设置说明,请参阅 [Kubernetes 集成指南](/use-cases/observability/clickstack/ingesting-data/kubernetes#forwarding-resouce-tags-to-pods)。 +要启用此功能,请配置 OpenTelemetry 收集器以将资源标签转发到 pods。请参见 [Kubernetes 集成指南](/use-cases/observability/clickstack/ingesting-data/kubernetes#forwarding-resouce-tags-to-pods) 获取详细的设置说明。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/index.md.hash index 1b939ea0292..c8a397b0471 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/index.md.hash @@ -1 +1 @@ -22fa04a7179cb5d3 +1cb8cf0db08a2b84 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/java.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/java.md index 236a7e9ae69..7c2bca66e8e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/java.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/java.md @@ -3,11 +3,12 @@ 'pagination_prev': null 'pagination_next': null 'sidebar_position': 3 -'description': 'Java SDK 为 ClickStack - ClickHouse 可观察性栈' +'description': 'Java SDK用于ClickStack - ClickHouse可观察性堆栈' 'title': 'Java' +'doc_type': 'guide' --- -ClickStack使用OpenTelemetry标准收集遥测数据(日志和跟踪)。跟踪是通过自动仪器生成的,因此不需要手动仪器就可以从跟踪中获得价值。 +ClickStack 使用 OpenTelemetry 标准来收集遥测数据(日志和跟踪)。跟踪是通过自动仪表化自动生成的,因此不需要手动仪表化即可从跟踪中获得价值。 **本指南集成:** @@ -24,23 +25,23 @@ ClickStack使用OpenTelemetry标准收集遥测数据(日志和跟踪)。跟 ## 开始使用 {#getting-started} :::note -目前,此集成仅与 **Java 8+** 兼容 +目前,该集成仅与 **Java 8+** 兼容 ::: -### 下载OpenTelemetry Java代理 {#download-opentelemtry-java-agent} +### 下载 OpenTelemetry Java 代理 {#download-opentelemtry-java-agent} 下载 [`opentelemetry-javaagent.jar`](https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar) -并将JAR放置在您首选的目录中。JAR文件包含代理和仪器库。您也可以使用以下命令下载代理: +并将 JAR 文件放在您首选的目录中。JAR 文件包含代理和仪表化库。您还可以使用以下命令下载代理: -```bash +```shell curl -L -O https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar ``` ### 配置环境变量 {#configure-environment-variables} -之后,您需要在Shell中配置以下环境变量,以便将遥测数据发送到ClickStack: +之后,您需要在您的 shell 中配置以下环境变量,以将遥测数据发送到 ClickStack: -```bash +```shell export JAVA_TOOL_OPTIONS="-javaagent:PATH/TO/opentelemetry-javaagent.jar" \ OTEL_EXPORTER_OTLP_ENDPOINT=https://localhost:4318 \ OTEL_EXPORTER_OTLP_HEADERS='authorization=' \ @@ -49,14 +50,14 @@ OTEL_LOGS_EXPORTER=otlp \ OTEL_SERVICE_NAME='' ``` -_`OTEL_SERVICE_NAME` 环境变量用于在HyperDX应用中识别您的服务,可以是您想要的任何名称。_ +_`OTEL_SERVICE_NAME` 环境变量用于在 HyperDX 应用中识别您的服务,可以是您想要的任何名称。_ -`OTEL_EXPORTER_OTLP_HEADERS` 环境变量包含通过HyperDX应用在 `团队设置 → API密钥` 中可用的API密钥。 +`OTEL_EXPORTER_OTLP_HEADERS` 环境变量包含通过 HyperDX 应用在 `团队设置 → API 密钥` 中提供的 API 密钥。 -### 使用OpenTelemetry Java代理运行应用 {#run-the-application-with-otel-java-agent} +### 使用 OpenTelemetry Java 代理运行应用 {#run-the-application-with-otel-java-agent} -```sh +```shell java -jar target/ ```
-在此处阅读有关Java OpenTelemetry仪器的更多信息:[https://opentelemetry.io/docs/instrumentation/java/](https://opentelemetry.io/docs/instrumentation/java/) +有关 Java OpenTelemetry 仪表化的更多信息,请参阅:[https://opentelemetry.io/docs/instrumentation/java/](https://opentelemetry.io/docs/instrumentation/java/) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/java.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/java.md.hash index 6c81ece9541..292ac231c0f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/java.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/java.md.hash @@ -1 +1 @@ -9e8b0edcb6f6125a +d1888d17ddebdf2d diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/nestjs.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/nestjs.md index ce8a20029cf..4c2c6dfab23 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/nestjs.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/nestjs.md @@ -3,13 +3,14 @@ 'pagination_prev': null 'pagination_next': null 'sidebar_position': 4 -'description': 'NestJS SDK 用于 ClickStack - ClickHouse 可观测性堆栈' +'description': 'NestJS SDK 用于 ClickStack - ClickHouse 可观察性栈' 'title': 'NestJS' +'doc_type': 'guide' --- -The ClickStack NestJS 集成允许您创建一个日志记录器或使用默认日志记录器将日志发送到 ClickStack(由 [nest-winston](https://www.npmjs.com/package/nest-winston?activeTab=readme) 提供支持)。 +The ClickStack NestJS integration allows you to create a logger or use the default logger to send logs to ClickStack (powered by [nest-winston](https://www.npmjs.com/package/nest-winston?activeTab=readme)). -**本指南集成:** +**本指南集成了:** @@ -23,11 +24,11 @@ The ClickStack NestJS 集成允许您创建一个日志记录器或使用默认 _要发送指标或 APM/跟踪,您还需要将相应的语言集成添加到您的应用程序中。_ -## 开始使用 {#getting-started} +## 开始 {#getting-started} -将 `HyperDXNestLoggerModule` 导入根 `AppModule` 并使用 `forRoot()` 方法进行配置。 +将 `HyperDXNestLoggerModule` 导入根 `AppModule`,并使用 `forRoot()` 方法进行配置。 -```js +```javascript import { Module } from '@nestjs/common'; import { HyperDXNestLoggerModule } from '@hyperdx/node-logger'; @@ -43,9 +44,9 @@ import { HyperDXNestLoggerModule } from '@hyperdx/node-logger'; export class AppModule {} ``` -之后,winston 实例将可以通过 `HDX_LOGGER_MODULE_PROVIDER` 注入令牌在整个项目中注入: +之后,winston 实例将可用于通过 `HDX_LOGGER_MODULE_PROVIDER` 注入令牌在整个项目中进行注入: -```js +```javascript import { Controller, Inject } from '@nestjs/common'; import { HyperDXNestLoggerModule, HyperDXNestLogger } from '@hyperdx/node-logger'; @@ -62,19 +63,19 @@ export class CatsController { } ``` -### 替换 Nest 日志记录器(也用于引导) {#replacing-the-nest-logger} +### 替换 Nest 日志记录器(引导时也适用) {#replacing-the-nest-logger} :::note 重要 -这样做会放弃依赖注入,这意味着不再需要使用 `forRoot` 和 `forRootAsync`。请将它们从您的主模块中移除。 +这样做后,您放弃了依赖注入,这意味着不需要使用 `forRoot` 和 `forRootAsync`,并且不应该使用它们。将它们从您的主要模块中删除。 ::: -使用依赖注入有一个小缺点。Nest 必须首先引导应用程序(实例化模块和提供者,注入依赖项等),在此过程中 `HyperDXNestLogger` 的实例尚不可用,这意味着 Nest 会退回到内部日志记录器。 +使用依赖注入有一个小缺点。Nest 必须首先引导应用程序(实例化模块和提供者,注入依赖关系等),在此过程中 `HyperDXNestLogger` 的实例尚不可用,这意味着 Nest 会回退到内部日志记录器。 -解决方案是使用 `createLogger` 函数在应用程序生命周期之外创建日志记录器,并将其传递给 `NestFactory.create`。然后 Nest 会将我们的自定义日志记录器(`createLogger` 方法返回的相同实例)包装到 Logger 类中,并将所有调用转发给它: +一种解决方案是在应用程序生命周期之外创建日志记录器,使用 `createLogger` 函数,并将其传递给 `NestFactory.create`。Nest 将包裹我们自定义日志记录器(`createLogger` 方法返回的相同实例)到 Logger 类中,转发所有调用给它: 在 `main.ts` 文件中创建日志记录器 -```js +```javascript import { HyperDXNestLoggerModule } from '@hyperdx/node-logger'; async function bootstrap() { @@ -90,9 +91,9 @@ async function bootstrap() { bootstrap(); ``` -修改您的主模块以提供 Logger 服务: +将您的主模块更改为提供 Logger 服务: -```js +```javascript import { Logger, Module } from '@nestjs/common'; @Module({ @@ -101,9 +102,9 @@ import { Logger, Module } from '@nestjs/common'; export class AppModule {} ``` -然后通过使用 `@nestjs/common` 中的 Logger 进行类型提示,简单地注入日志记录器: +然后只需通过类型提示将日志记录器注入,使用 `@nestjs/common` 中的 Logger: -```js +```javascript import { Controller, Logger } from '@nestjs/common'; @Controller('cats') diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/nestjs.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/nestjs.md.hash index d1ffa7b3081..071fa23da48 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/nestjs.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/nestjs.md.hash @@ -1 +1 @@ -7069643bd3c9d56e +873e249fb1efaa4e diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/nextjs.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/nextjs.md index ba6da155240..c612fe95590 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/nextjs.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/nextjs.md @@ -3,33 +3,34 @@ 'pagination_prev': null 'pagination_next': null 'sidebar_position': 4 -'description': 'Next.js SDK for ClickStack - ClickHouse 观察堆栈' +'description': 'Next.js SDK 用于 ClickStack - ClickHouse 观察堆栈' 'title': 'Next.js' +'doc_type': 'guide' --- import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; -ClickStack 可以从你在 Next 13.2+ 的 [Next.js 无服务器函数](https://nextjs.org/docs/pages/building-your-application/optimizing/open-telemetry#manual-opentelemetry-configuration) 中提取原生 OpenTelemetry 跟踪。 +ClickStack 可以从你的 [Next.js 无服务器函数](https://nextjs.org/docs/pages/building-your-application/optimizing/open-telemetry#manual-opentelemetry-configuration) 中摄取原生的 OpenTelemetry 跟踪,适用于 Next 13.2 及更高版本。 -本指南整合了: +本指南集成了: - **控制台日志** - **跟踪** :::note -如果你在寻找会话重放/浏览器端监控,你需要安装 [浏览器集成](/use-cases/observability/clickstack/sdks/browser) 。 +如果你正在寻找会话重放/浏览器端监控,建议安装 [浏览器集成](/use-cases/observability/clickstack/sdks/browser)。 ::: ## 安装 {#installing} -### 启用仪器钩子(v15 及以下版本必需) {#enable-instrumentation-hook} +### 启用仪器化钩子(v15 及以下版本所需) {#enable-instrumentation-hook} -要开始,你需要通过在你的 `next.config.js` 中设置 `experimental.instrumentationHook = true;` 来启用 Next.js 仪器钩子。 +要开始,你需要在 `next.config.js` 中设置 `experimental.instrumentationHook = true;` 以启用 Next.js 的仪器化钩子。 **示例:** -```js +```javascript const nextConfig = { experimental: { instrumentationHook: true, @@ -55,25 +56,25 @@ module.exports = nextConfig; -```bash +```shell npm install @hyperdx/node-opentelemetry ``` -```bash +```shell yarn add @hyperdx/node-opentelemetry ``` -### 创建仪器文件 {#create-instrumentation-files} +### 创建仪器化文件 {#create-instrumentation-files} -在你的 Next.js 项目根目录中创建一个名为 `instrumentation.ts`(或 `.js`)的文件,内容如下: +在你的 Next.js 项目根目录下创建一个名为 `instrumentation.ts`(或 `.js`)的文件,并包含以下内容: -```js +```javascript export async function register() { if (process.env.NEXT_RUNTIME === 'nodejs') { const { init } = await import('@hyperdx/node-opentelemetry'); @@ -86,11 +87,11 @@ export async function register() { } ``` -这将允许 Next.js 导入任何无服务器函数调用的 OpenTelemetry 仪器。 +这将允许 Next.js 导入任何无服务器函数调用的 OpenTelemetry 仪器化。 ### 配置环境变量 {#configure-environment-variables} -如果你直接将跟踪发送到 ClickStack,你需要使用以下环境变量启动你的 Next.js 服务器,以将 spans 指向 OTel 收集器: +如果你直接将跟踪发送到 ClickStack,你需要以以下环境变量启动你的 Next.js 服务器,以指向 OTel 收集器: ```sh copy HYPERDX_API_KEY= \ @@ -99,4 +100,4 @@ OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318 npm run dev ``` -如果你在 Vercel 上部署,确保所有上述环境变量已为你的部署配置。 +如果你在 Vercel 部署,请确保为你的部署配置上述所有环境变量。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/nextjs.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/nextjs.md.hash index 605f4d68416..5e242a1c950 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/nextjs.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/nextjs.md.hash @@ -1 +1 @@ -4b771f29b3f7a7bb +3ff393c99facccab diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/nodejs.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/nodejs.md index 868f5e1c68f..05a68089626 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/nodejs.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/nodejs.md @@ -3,14 +3,15 @@ 'pagination_prev': null 'pagination_next': null 'sidebar_position': 5 -'description': 'Node.js SDK 用于 ClickStack - ClickHouse 观察堆栈' +'description': 'Node.js SDK 用于 ClickStack - ClickHouse 可观测性堆栈' 'title': 'Node.js' +'doc_type': 'guide' --- import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; -ClickStack 使用 OpenTelemetry 标准来收集遥测数据(日志、指标、跟踪和异常)。跟踪通过自动仪器生成,因此不需要手动仪器来获取跟踪的价值。 +ClickStack 使用 OpenTelemetry 标准收集遥测数据(日志、指标、跟踪和异常)。跟踪通过自动仪器化自动生成,因此不需要手动仪器化即可从跟踪中获取价值。 本指南集成了: @@ -21,21 +22,21 @@ ClickStack 使用 OpenTelemetry 标准来收集遥测数据(日志、指标、 ## 入门 {#getting-started} -### 安装 HyperDX OpenTelemetry 仪器包 {#install-hyperdx-opentelemetry-instrumentation-package} +### 安装 HyperDX OpenTelemetry 仪器化包 {#install-hyperdx-opentelemetry-instrumentation-package} -使用以下命令来安装 [ClickStack OpenTelemetry 包](https://www.npmjs.com/package/@hyperdx/node-opentelemetry)。 +使用以下命令安装 [ClickStack OpenTelemetry 包](https://www.npmjs.com/package/@hyperdx/node-opentelemetry)。 -```bash +```shell npm install @hyperdx/node-opentelemetry ``` -```bash +```shell yarn add @hyperdx/node-opentelemetry ``` @@ -49,7 +50,7 @@ yarn add @hyperdx/node-opentelemetry -```js +```javascript const HyperDX = require('@hyperdx/node-opentelemetry'); HyperDX.init({ @@ -61,7 +62,7 @@ HyperDX.init({ -```js +```javascript import * as HyperDX from '@hyperdx/node-opentelemetry'; HyperDX.init({ @@ -77,12 +78,12 @@ HyperDX.init({ ### 设置日志收集 {#setup-log-collection} -默认情况下,`console.*` 日志会被收集。如果您使用的是 `winston` 或 `pino` 等记录器,您需要向记录器添加一个传输,以将日志发送到 ClickStack。如果您使用其他类型的记录器,请 [联系我们](mailto:support@clickhouse.com) 或查看我们的某些平台集成(例如 [Kubernetes](/use-cases/observability/clickstack/ingesting-data/kubernetes))。 +默认情况下,`console.*` 日志会被收集。如果您使用的是 `winston` 或 `pino` 等日志记录器,则需要向日志记录器添加传输,以将日志发送到 ClickStack。如果您使用其他类型的日志记录器,可以 [联系](mailto:support@clickhouse.com) 或探索我们的平台集成(如 [Kubernetes](/use-cases/observability/clickstack/ingesting-data/kubernetes))。 -如果您将 `winston` 作为记录器使用,您需要在记录器中添加以下传输。 +如果您使用 `winston` 作为日志记录器,则需要将以下传输添加到您的日志记录器中。 ```typescript import winston from 'winston'; @@ -105,7 +106,7 @@ export default logger; -如果您将 `pino` 作为记录器使用,您需要在记录器中添加以下传输,并指定一个 `mixin` 来将日志与跟踪进行关联。 +如果您使用 `pino` 作为日志记录器,则需要将以下传输添加到您的日志记录器,并指定一个 `mixin` 以将日志与跟踪关联。 ```typescript import pino from 'pino'; @@ -128,9 +129,9 @@ export default logger; -默认情况下,`console.*` 方法开箱即用,无需额外配置。 +默认情况下,`console.*` 方法开箱即用地支持。无需额外配置。 -您可以通过将 `HDX_NODE_CONSOLE_CAPTURE` 环境变量设置为 0 或将 `consoleCapture: false` 传递给 `init` 函数来禁用此功能。 +您可以通过将 `HDX_NODE_CONSOLE_CAPTURE` 环境变量设置为 0 或向 `init` 函数传递 `consoleCapture: false` 来禁用此功能。 @@ -144,7 +145,7 @@ ClickStack SDK 可以自动捕获应用程序中的未捕获异常和错误, -```js +```javascript const HyperDX = require('@hyperdx/node-opentelemetry'); HyperDX.init({ apiKey: 'YOUR_INGESTION_API_KEY', @@ -164,7 +165,7 @@ app.listen(3000); -```js +```javascript const Koa = require("koa"); const Router = require("@koa/router"); const HyperDX = require('@hyperdx/node-opentelemetry'); @@ -186,7 +187,7 @@ app.listen(3030); -```js +```javascript const HyperDX = require('@hyperdx/node-opentelemetry'); function myErrorHandler(error, req, res, next) { @@ -198,19 +199,19 @@ function myErrorHandler(error, req, res, next) { -## 疑难解答 {#troubleshooting} +## 故障排除 {#troubleshooting} -如果您遇到 SDK 的问题,可以通过将 `OTEL_LOG_LEVEL` 环境变量设置为 `debug` 来启用详细日志记录。 +如果您在使用 SDK 时遇到问题,可以通过将 `OTEL_LOG_LEVEL` 环境变量设置为 `debug` 来启用详细日志记录。 -```sh +```shell export OTEL_LOG_LEVEL=debug ``` -## 高级仪器配置 {#advanced-instrumentation-configuration} +## 高级仪器化配置 {#advanced-instrumentation-configuration} ### 捕获控制台日志 {#capture-console-logs} -默认情况下,ClickStack SDK 将捕获控制台日志。您可以通过将 `HDX_NODE_CONSOLE_CAPTURE` 环境变量设置为 0 来禁用它。 +默认情况下,ClickStack SDK 会捕获控制台日志。您可以通过将 `HDX_NODE_CONSOLE_CAPTURE` 环境变量设置为 0 来禁用它。 ```sh copy export HDX_NODE_CONSOLE_CAPTURE=0 @@ -218,13 +219,13 @@ export HDX_NODE_CONSOLE_CAPTURE=0 ### 附加用户信息或元数据 {#attach-user-information-or-metadata} -为了轻松标记与给定属性或标识符(例如用户ID或电子邮件)相关的所有事件,您可以调用 `setTraceAttributes` 函数,该函数将在调用后使用声明的属性标记与当前跟踪关联的每个日志/跨度。建议在给定请求/跟踪内尽早调用此函数(例如,在 Express 中间件栈尽早)。 +为了轻松标记与给定属性或标识符(例如用户 ID 或电子邮件)相关的所有事件,您可以调用 `setTraceAttributes` 函数,它将在调用后为与当前跟踪相关的每个日志/span 标记声明的属性。建议在给定请求/跟踪中尽早调用此函数(例如,在 Express 中间件栈中尽早)。 -这是确保所有日志/跨度自动标记正确标识符以便于稍后搜索的便捷方法,而无需手动标记和传播标识符。 +这是一种便捷的方式,确保所有日志/spans 自动标记了正确的标识符,以便在以后进行搜索,而无需手动标记和传播标识符。 -`userId`、`userEmail`、`userName` 和 `teamName` 会填充会话 UI 中的相应值,但可以省略。可以指定任何其他额外值并用于搜索事件。 +`userId`、`userEmail`、`userName` 和 `teamName` 将填充会话 UI 以显示相应的值,但可以省略。还可以指定和使用其他附加值来搜索事件。 -```ts +```typescript import * as HyperDX from '@hyperdx/node-opentelemetry'; app.use((req, res, next) => { @@ -240,25 +241,25 @@ app.use((req, res, next) => { }); ``` -确保通过将 `HDX_NODE_BETA_MODE` 环境变量设置为 1 或将 `betaMode: true` 传递给 `init` 函数来启用 beta 模式,以启用跟踪属性。 +确保通过将 `HDX_NODE_BETA_MODE` 环境变量设置为 1 或向 `init` 函数传递 `betaMode: true` 来启用 beta 模式,以启用跟踪属性。 -```sh +```shell export HDX_NODE_BETA_MODE=1 ``` ### Google Cloud Run {#google-cloud-run} -如果您在 Google Cloud Run 上运行应用程序,Cloud Trace 会自动将采样标头注入到传入请求中,目前限制每个实例为每秒 0.1 个请求的跟踪。 +如果您在 Google Cloud Run 上运行应用程序,Cloud Trace 会自动将采样头注入到传入请求中,并且当前限制每个实例的跟踪采样为每秒 0.1 个请求。 `@hyperdx/node-opentelemetry` 包默认将采样率覆盖为 1.0。 -要更改此行为或配置其他 OpenTelemetry 安装,您可以手动配置环境变量 `OTEL_TRACES_SAMPLER=parentbased_always_on` 和 `OTEL_TRACES_SAMPLER_ARG=1` 以实现相同的结果。 +要更改此行为或配置其他 OpenTelemetry 安装,您可以手动配置环境变量 `OTEL_TRACES_SAMPLER=parentbased_always_on` 和 `OTEL_TRACES_SAMPLER_ARG=1` 来实现相同的结果。 -要了解更多信息,并强制跟踪特定请求,请参阅 [Google Cloud Run 文档](https://cloud.google.com/run/docs/trace)。 +要了解更多信息并强制跟踪特定请求,请参阅 [Google Cloud Run 文档](https://cloud.google.com/run/docs/trace)。 -### 自动仪器库 {#auto-instrumented-libraries} +### 自动仪器化库 {#auto-instrumented-libraries} -以下库将通过 SDK 自动进行仪器(跟踪): +以下库将由 SDK 自动仪器化(跟踪): - [`dns`](https://nodejs.org/dist/latest/docs/api/dns.html) - [`express`](https://www.npmjs.com/package/express) @@ -282,19 +283,19 @@ export HDX_NODE_BETA_MODE=1 ### 使用 ClickStack OpenTelemetry CLI 运行应用程序 {#run-the-application-with-cli} -或者,您可以使用 `opentelemetry-instrument` CLI 或使用 Node.js `--require` 标志在不进行任何代码更改的情况下自动仪器您的应用程序。CLI 安装公开了更广泛的自动仪器库和框架。 +另外,您可以使用 `opentelemetry-instrument` CLI 或使用 Node.js `--require` 标志来在不进行任何代码更改的情况下自动仪器化您的应用程序。CLI 安装提供了更广泛的自动仪器化库和框架。 -```bash +```shell HYPERDX_API_KEY='' OTEL_SERVICE_NAME='' npx opentelemetry-instrument index.js ``` -```bash +```shell HYPERDX_API_KEY='' OTEL_SERVICE_NAME='' ts-node -r '@hyperdx/node-opentelemetry/build/src/tracing' index.js ``` @@ -302,7 +303,7 @@ HYPERDX_API_KEY='' OTEL_SERVICE_NAME='' ts-no -```js +```javascript // Import this at the very top of the first file loaded in your application // You'll still specify your API key via the `HYPERDX_API_KEY` environment variable import { initSDK } from '@hyperdx/node-opentelemetry'; @@ -317,21 +318,21 @@ initSDK({ -_`OTEL_SERVICE_NAME` 环境变量用于在 HyperDX 应用中标识您的服务,可以是您想要的任何名称。_ +_`OTEL_SERVICE_NAME` 环境变量用于在 HyperDX 应用中识别您的服务,可以是您想要的任何名称。_ ### 启用异常捕获 {#enabling-exception-capturing} 要启用未捕获异常捕获,您需要将 `HDX_NODE_EXPERIMENTAL_EXCEPTION_CAPTURE` 环境变量设置为 1。 -```sh +```shell HDX_NODE_EXPERIMENTAL_EXCEPTION_CAPTURE=1 ``` -之后,自动捕获来自 Express、Koa 的异常或手动捕获异常,请按照上面 [设置错误收集](#setup-error-collection) 部分中的说明进行操作。 +之后,自动捕获来自 Express、Koa 的异常,或者手动捕获异常,请遵循上面[设置错误收集](#setup-error-collection)部分中的说明。 -### 自动仪器库 {#auto-instrumented-libraries-2} +### 自动仪器化库 {#auto-instrumented-libraries-2} -以下库将通过上述安装方法自动进行仪器(跟踪): +以下库将通过上述安装方法自动仪器化(跟踪): - [`amqplib`](https://www.npmjs.com/package/amqplib) - [`AWS Lambda Functions`](https://docs.aws.amazon.com/lambda/latest/dg/nodejs-handler.html) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/nodejs.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/nodejs.md.hash index ab75117b2eb..a306ba9fcd1 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/nodejs.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/nodejs.md.hash @@ -1 +1 @@ -1e3169a1b8acc91f +e3e6eacf8e1f03f4 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/python.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/python.md index 4bb84840430..6ee027383b1 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/python.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/python.md @@ -3,14 +3,15 @@ 'pagination_prev': null 'pagination_next': null 'sidebar_position': 7 -'description': 'Python用于ClickStack - ClickHouse可观察性堆栈' +'description': 'Python 用于 ClickStack - ClickHouse 可观察性栈' 'title': 'Python' +'doc_type': 'guide' --- import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; -ClickStack 使用 OpenTelemetry 标准收集遥测数据(日志和跟踪)。跟踪是通过自动仪器生成的,因此不需要手动仪器就能从跟踪中获取价值。 +ClickStack 使用 OpenTelemetry 标准收集遥测数据(日志和跟踪)。跟踪是通过自动仪器生成的,因此不需要手动仪器就可以从跟踪中获取价值。 本指南集成了: @@ -18,39 +19,39 @@ ClickStack 使用 OpenTelemetry 标准收集遥测数据(日志和跟踪)。 - **指标** - **跟踪** -## 入门 {#getting-started} +## 开始使用 {#getting-started} ### 安装 ClickStack OpenTelemetry 仪器包 {#install-clickstack-otel-instrumentation-package} -使用以下命令安装 [ClickStack OpenTelemetry package](https://pypi.org/project/hyperdx-opentelemetry/)。 +使用以下命令安装 [ClickStack OpenTelemetry 包](https://pypi.org/project/hyperdx-opentelemetry/)。 -```bash +```shell pip install hyperdx-opentelemetry ``` -安装 Python 应用程序使用的包的 OpenTelemetry 自动仪器库。我们建议您使用与 OpenTelemetry Python SDK 一起提供的 `opentelemetry-bootstrap` 工具来扫描您的应用程序包并生成可用库的列表。 +为您的 Python 应用程序安装 OpenTelemetry 自动仪器库。我们建议您使用与 OpenTelemetry Python SDK 一起提供的 `opentelemetry-bootstrap` 工具来扫描您的应用程序包并生成可用库的列表。 -```bash +```shell opentelemetry-bootstrap -a install ``` ### 配置环境变量 {#configure-environment-variables} -之后,您需要在 Shell 中配置以下环境变量,以将遥测数据发送到 ClickStack: +然后,您需要在 shell 中配置以下环境变量以将遥测数据发送到 ClickStack: -```bash +```shell export HYPERDX_API_KEY='' \ OTEL_SERVICE_NAME='' \ OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318 ``` -_`OTEL_SERVICE_NAME` 环境变量用于在 HyperDX 应用程序中识别您的服务,可以是您想要的任何名称。_ +_`OTEL_SERVICE_NAME` 环境变量用于在 HyperDX 应用中标识您的服务,可以是您想要的任何名称。_ ### 使用 OpenTelemetry Python 代理运行应用程序 {#run-the-application-with-otel-python-agent} -现在您可以用 OpenTelemetry Python 代理(`opentelemetry-instrument`)运行应用程序。 +现在,您可以使用 OpenTelemetry Python 代理 (`opentelemetry-instrument`) 运行应用程序。 -```bash +```shell opentelemetry-instrument python app.py ``` @@ -58,7 +59,7 @@ opentelemetry-instrument python app.py 在这种情况下,OpenTelemetry Python 代理需要额外的更改才能正常工作。 -要为使用预分叉 Web 服务器模式的应用程序服务器配置 OpenTelemetry,请确保在后分叉钩子中调用 `configure_opentelemetry` 方法。 +要为使用预先分叉 web 服务器模式的应用程序服务器配置 OpenTelemetry,请确保在后续钩子中调用 `configure_opentelemetry` 方法。 @@ -85,7 +86,7 @@ def init_tracing(): -OpenTelemetry [目前不适用于](https://github.com/open-telemetry/opentelemetry-python-contrib/issues/385) 使用 `--reload` 标志或多工作进程(`--workers`)运行的 `uvicorn`。我们建议在测试时禁用这些标志,或使用 Gunicorn。 +OpenTelemetry [目前不支持](https://github.com/open-telemetry/opentelemetry-python-contrib/issues/385) 带有 `--reload` 标志或多个工作进程(`--workers`)的 `uvicorn`。我们建议在测试时禁用这些标志,或使用 Gunicorn。 @@ -95,17 +96,17 @@ OpenTelemetry [目前不适用于](https://github.com/open-telemetry/opentelemet #### 网络捕获 {#network-capture} -通过启用网络捕获功能,开发人员能够有效调试 HTTP 请求头和主体负载。这可以通过将 `HYPERDX_ENABLE_ADVANCED_NETWORK_CAPTURE` 标志设置为 1 来轻松实现。 +通过启用网络捕获功能,开发人员能够有效调试 HTTP 请求头和主体负载。只需将 `HYPERDX_ENABLE_ADVANCED_NETWORK_CAPTURE` 标志设置为 1 即可实现。 -```bash +```shell export HYPERDX_ENABLE_ADVANCED_NETWORK_CAPTURE=1 ``` ## 故障排除 {#troubleshooting} -### 日志未按日志级别显示 {#logs-not-appearing-due-to-log-level} +### 日志未出现的原因 {#logs-not-appearing-due-to-log-level} -默认情况下,OpenTelemetry 日志处理程序使用 `logging.NOTSET` 级别,默认为 WARNING 级别。您可以在创建记录器时指定日志级别: +默认情况下,OpenTelemetry 日志处理程序使用 `logging.NOTSET` 级别,默认设置为 WARNING 级别。您可以在创建日志记录器时指定日志级别: ```python import logging @@ -116,11 +117,11 @@ logger.setLevel(logging.DEBUG) ### 导出到控制台 {#exporting-to-the-console} -OpenTelemetry Python SDK 通常会在发生错误时在控制台中显示错误。但是,如果您没有遇到任何错误,但注意到您的数据未按预期出现在 HyperDX 中,则可以选择启用调试模式。当调试模式激活时,所有遥测将打印到控制台,允许您验证应用程序是否已正确仪器化并包含预期的数据。 +当发生错误时,OpenTelemetry Python SDK 通常会在控制台中显示错误。不过,如果您没有遇到任何错误,但发现您的数据未按预期出现在 HyperDX 中,您可以选择启用调试模式。当调试模式激活时,所有遥测数据将打印到控制台,允许您验证应用程序是否已正确使用预期数据进行仪器化。 -```bash +```shell export DEBUG=true ``` -阅读有关 Python OpenTelemetry 仪器的更多信息,请访问: +有关 Python OpenTelemetry 仪器化的更多信息,请访问: [https://opentelemetry.io/docs/instrumentation/python/manual/](https://opentelemetry.io/docs/instrumentation/python/manual/) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/python.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/python.md.hash index f97bddd920d..23b51295815 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/python.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/python.md.hash @@ -1 +1 @@ -65b44a669015ea64 +b3018a555381425d diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/react-native.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/react-native.md index d3e12169bea..d2404575c4d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/react-native.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/react-native.md @@ -5,29 +5,30 @@ 'sidebar_position': 7 'description': 'React Native SDK 用于 ClickStack - ClickHouse 可观察性堆栈' 'title': 'React Native' +'doc_type': 'guide' --- -The ClickStack React Native SDK 允许您对您的 React Native 应用进行仪器以向 ClickStack 发送事件。这使您能够在单一时间线上查看移动网络请求和异常以及后端事件。 +The ClickStack React Native SDK 允许您对您的 React Native 应用进行插桩,以发送事件到 ClickStack。这使您能够在单一的时间线上查看移动网络请求和异常,以及后端事件。 本指南集成了: - **XHR/Fetch 请求** -## 开始使用 {#getting-started} +## 开始 {#getting-started} ### 通过 NPM 安装 {#install-via-npm} -使用以下命令安装 [ClickStack React Native package](https://www.npmjs.com/package/@hyperdx/otel-react-native)。 +使用以下命令安装 [ClickStack React Native 包](https://www.npmjs.com/package/@hyperdx/otel-react-native)。 -```bash +```shell npm install @hyperdx/otel-react-native ``` ### 初始化 ClickStack {#initialize-clickstack} -尽早在您的应用生命周期初始化库: +尽早在您的应用生命周期中初始化库: -```js +```javascript import { HyperDXRum } from '@hyperdx/otel-react-native'; HyperDXRum.init({ @@ -39,11 +40,11 @@ HyperDXRum.init({ ### 附加用户信息或元数据(可选) {#attach-user-information-metadata} -附加用户信息将允许您在 HyperDX 中搜索/过滤会话和事件。可以在客户端会话的任何时刻调用此操作。当前的客户端会话及其后发送的所有事件将与用户信息相关联。 +附加用户信息将允许您在 HyperDX 中搜索/过滤会话和事件。这可以在客户端会话的任何时候调用。当前客户端会话及所有在调用后发送的事件将与用户信息相关联。 -`userEmail`、`userName` 和 `teamName` 将用相应的值填充会话 UI,但可以省略。任何其他额外值也可以指定并用于搜索事件。 +`userEmail`、`userName` 和 `teamName` 将填充会话 UI,显示相应的值,但可以省略。可以指定其他附加值,并用于搜索事件。 -```js +```javascript HyperDXRum.setGlobalAttributes({ userId: user.id, userEmail: user.email, @@ -53,11 +54,11 @@ HyperDXRum.setGlobalAttributes({ }); ``` -### 为低版本仪器化 {#instrument-lower-versions} +### 插桩较低版本 {#instrument-lower-versions} -要为运行在低于 0.68 的 React Native 版本的应用进行仪器,请编辑您的 `metro.config.js` 文件以强迫 metro 使用特定于浏览器的包。例如: +要对运行在低于 0.68 版本的 React Native 应用进行插桩,请编辑您的 `metro.config.js` 文件,以强制 metro 使用特定于浏览器的包。例如: -```js +```javascript const defaultResolver = require('metro-resolver'); module.exports = { @@ -101,9 +102,9 @@ module.exports = { 支持 [react-navigation](https://github.com/react-navigation/react-navigation) 版本 5 和 6。 -以下示例演示了如何仪器化导航: +以下示例展示了如何对导航进行插桩: -```js +```javascript import { startNavigationTracking } from '@hyperdx/otel-react-native'; export default function App() { diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/react-native.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/react-native.md.hash index c6eb8766f92..e42ae63c295 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/react-native.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/react-native.md.hash @@ -1 +1 @@ -c8d59e7699511be3 +da5e74573878fd75 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/ruby.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/ruby.md index 6b206d52f05..927471833cc 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/ruby.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/ruby.md @@ -3,39 +3,40 @@ 'pagination_prev': null 'pagination_next': null 'sidebar_position': 7 -'description': 'Ruby on Rails SDK 用于 ClickStack - ClickHouse 观察性堆栈' +'description': 'Ruby on Rails SDK 用于 ClickStack - ClickHouse 可观察性堆栈' 'title': 'Ruby on Rails' +'doc_type': 'guide' --- -此指南整合了: +以下指南整合了:
- +
✖️ 日志 ✖️ ️️指标✅ 跟踪✅ 追踪
-_要将日志发送到 ClickStack,请通过 [OpenTelemetry 收集器](/use-cases/observability/clickstack/ingesting-data/otel-collector) 发送日志。_ +_要将日志发送到 ClickStack,请通过 [OpenTelemetry collector](/use-cases/observability/clickstack/ingesting-data/otel-collector) 发送日志。_ -## 入门 {#getting-started} +## 开始使用 {#getting-started} ### 安装 OpenTelemetry 包 {#install-otel-packages} 使用以下命令安装 OpenTelemetry 包。 -```bash +```shell bundle add opentelemetry-sdk opentelemetry-instrumentation-all opentelemetry-exporter-otlp ``` -### 配置 OpenTelemetry + 日志格式化器 {#configure-otel-logger-formatter} +### 配置 OpenTelemetry + 日志格式器 {#configure-otel-logger-formatter} -接下来,您需要初始化 OpenTelemetry 跟踪仪器并配置 Rails 日志记录器的日志消息格式化器,以便日志可以自动与跟踪关联在一起。没有自定义格式化器,日志将不会在 ClickStack 中自动关联在一起。 +接下来,您需要初始化 OpenTelemetry 跟踪仪器,并为 Rails 日志记录器配置日志消息格式器,以便日志可以自动与追踪关联。如果没有自定义格式器,日志将无法在 ClickStack 中自动关联在一起。 -在 `config/initializers` 文件夹中,创建一个名为 `hyperdx.rb` 的文件,并添加以下内容: +在 `config/initializers` 文件夹中,创建一个名为 `hyperdx.rb` 的文件,并将以下内容添加到其中: ```ruby @@ -71,9 +72,9 @@ end ### 配置环境变量 {#configure-environment-variables} -之后,您需要在终端配置以下环境变量,以将遥测数据发送到 ClickStack: +然后您需要在您的 shell 中配置以下环境变量,以将遥测数据发送到 ClickStack: -```bash +```shell export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318 \ OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf \ OTEL_SERVICE_NAME='' \ @@ -82,4 +83,4 @@ OTEL_EXPORTER_OTLP_HEADERS='authorization=' _`OTEL_SERVICE_NAME` 环境变量用于在 HyperDX 应用中识别您的服务,可以是您想要的任何名称。_ -`OTEL_EXPORTER_OTLP_HEADERS` 环境变量包含通过 HyperDX 应用在 `团队设置 → API 密钥` 中可用的 API 密钥。 +`OTEL_EXPORTER_OTLP_HEADERS` 环境变量包含可通过 HyperDX 应用在 `团队设置 → API 密钥` 中找到的 API 密钥。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/ruby.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/ruby.md.hash index b98793c14c6..b92ade3422e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/ruby.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ingesting-data/sdks/ruby.md.hash @@ -1 +1 @@ -40b0034d0e7771ce +cbdaca7e96d4a825 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/elastic/concepts.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/elastic/concepts.md new file mode 100644 index 00000000000..ea446df15c7 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/elastic/concepts.md @@ -0,0 +1,238 @@ +--- +'slug': '/use-cases/observability/clickstack/migration/elastic/concepts' +'title': 'ClickStack和Elastic中的等效概念' +'pagination_prev': null +'pagination_next': null +'sidebar_label': '等效概念' +'sidebar_position': 1 +'description': '等效概念 - ClickStack和Elastic' +'show_related_blogs': true +'keywords': +- 'Elasticsearch' +'doc_type': 'reference' +--- + +import Image from '@theme/IdealImage'; +import elasticsearch from '@site/static/images/use-cases/observability/elasticsearch.png'; +import clickhouse from '@site/static/images/use-cases/observability/clickhouse.png'; +import clickhouse_execution from '@site/static/images/use-cases/observability/clickhouse-execution.png'; +import elasticsearch_execution from '@site/static/images/use-cases/observability/elasticsearch-execution.png'; +import elasticsearch_transforms from '@site/static/images/use-cases/observability/es-transforms.png'; +import clickhouse_mvs from '@site/static/images/use-cases/observability/ch-mvs.png'; + +## Elastic Stack与ClickStack的对比 {#elastic-vs-clickstack} + +Elastic Stack和ClickStack都涵盖了可观察性平台的核心角色,但它们在设计理念上有所不同。这些角色包括: + +- **UI和警报**:用于查询数据、构建仪表板和管理警报的工具。 +- **存储和查询引擎**:负责存储可观察性数据和处理分析查询的后台系统。 +- **数据收集和ETL**:收集遥测数据并在摄取之前处理它的代理和管道。 + +下面的表格概述了每个栈如何将其组件映射到这些角色: + +| **角色** | **Elastic Stack** | **ClickStack** | **备注** | +|--------------------------|--------------------------------------------------|--------------------------------------------------|--------------| +| **UI和警报** | **Kibana** — 仪表板、搜索和警报 | **HyperDX** — 实时UI、搜索和警报 | 两者作为用户的主要界面,包括可视化和警报管理。HyperDX是专为可观察性而构建,并紧密结合OpenTelemetry语义。 | +| **存储和查询引擎** | **Elasticsearch** — JSON文档存储,带有倒排索引 | **ClickHouse** — 列式数据库,带有矢量化引擎 | Elasticsearch使用为搜索优化的倒排索引;ClickHouse使用列式存储和SQL为结构化和半结构化数据提供高速分析。 | +| **数据收集** | **Elastic Agent**、**Beats**(例如Filebeat、Metricbeat) | **OpenTelemetry Collector**(边缘 + 网关) | Elastic支持自定义发货者和由Fleet管理的统一代理。ClickStack依赖OpenTelemetry,允许与供应商无关的数据收集和处理。 | +| **工具包SDK** | **Elastic APM agents**(专有) | **OpenTelemetry SDKs**(由ClickStack分发) | Elastic SDK与Elastic Stack绑定。ClickStack基于OpenTelemetry SDKs构建,支持主要语言的日志、指标和追踪。 | +| **ETL / 数据处理** | **Logstash**,摄取管道 | **OpenTelemetry Collector** + ClickHouse物化视图 | Elastic使用摄取管道和Logstash进行转化。ClickStack通过物化视图和OTel collector处理器将计算推到插入时间,有效地增量转换数据。 | +| **架构理念** | 垂直集成,专有代理和格式 | 基于开放标准,松耦合组件 | Elastic构建了一个紧密集成的生态系统。ClickStack强调模块化和标准(OpenTelemetry、SQL、对象存储)的灵活性和成本效率。 | + +ClickStack强调开放标准和互操作性,从收集到UI完全基于OpenTelemetry。相比之下,Elastic提供了一个紧密耦合但更垂直集成的生态系统,采用专有代理和格式。 + +鉴于**Elasticsearch**和**ClickHouse**是各自堆栈中负责数据存储、处理和查询的核心引擎,了解它们的区别至关重要。这些系统支撑了整个可观察性架构的性能、可扩展性和灵活性。接下来的部分将探讨Elasticsearch和ClickHouse之间的关键差异,包括它们如何建模数据、处理摄取、执行查询和管理存储。 +## Elasticsearch与ClickHouse的对比 {#elasticsearch-vs-clickhouse} + +ClickHouse和Elasticsearch使用不同的底层模型组织和查询数据,但许多核心概念服务于类似的目的。本节概述了熟悉Elastic的用户的关键等价项,并将其映射到ClickHouse的对应项。尽管术语不同,大多数可观察性工作流可以在ClickStack中重现——通常更为高效。 +### 核心结构概念 {#core-structural-concepts} + +| **Elasticsearch** | **ClickHouse / SQL** | **描述** | +|-------------------|----------------------|------------------| +| **字段** | **列** | 数据的基本单元,包含一个或多个特定类型的值。Elasticsearch字段可以存储原始值以及数组和对象。字段只能有一种类型。ClickHouse也支持数组和对象(`Tuples`、`Maps`、`Nested`),以及动态类型,如[`Variant`](/sql-reference/data-types/variant)和[`Dynamic`](/sql-reference/data-types/dynamic),允许列具有多种类型。 | +| **文档** | **行** | 字段(列)的集合。Elasticsearch文档默认更灵活,可以根据数据动态添加新字段(类型从中推断)。ClickHouse行在默认情况下是模式绑定的,用户需要插入行或子集的所有列。ClickHouse中的[`JSON`](/integrations/data-formats/json/overview)类型支持根据插入数据创建相应的半结构化动态列。 | +| **索引** | **表** | 查询执行和存储的单位。在两个系统中,查询都是针对索引或表运行,存储行/文档。 | +| *隐式* | 模式(SQL) | SQL模式将表分组到命名空间,通常用于访问控制。Elasticsearch和ClickHouse不具备模式,但都支持通过角色和RBAC进行行和表级安全性。 | +| **集群** | **集群 / 数据库** | Elasticsearch集群是管理一个或多个索引的运行实例。在ClickHouse中,数据库在逻辑命名空间内组织表,提供与Elasticsearch中集群相同的逻辑分组。ClickHouse集群是一组分布式节点,类似于Elasticsearch,但与数据本身解耦且独立。 | +### 数据建模和灵活性 {#data-modeling-and-flexibility} + +Elasticsearch因其通过[动态映射](https://www.elastic.co/docs/manage-data/data-store/mapping/dynamic-mapping)实现的模式灵活性而闻名。字段随着文档的摄取而创建,并且类型自动推断——除非明确指定模式。ClickHouse默认更严格——表是以显式模式定义的——但通过[`Dynamic`](/sql-reference/data-types/dynamic)、[`Variant`](/sql-reference/data-types/variant)和[`JSON`](/integrations/data-formats/json/overview)类型提供灵活性。这些类型支持半结构化数据的摄取,动态列创建和类型推断与Elasticsearch类似。类似地,[`Map`](/sql-reference/data-types/map)类型允许存储任意键值对——不过对键和值都强制执行单一类型。 + +ClickHouse对类型灵活性的处理更加透明和受控。与可能因类型冲突而导致摄入错误的Elasticsearch不同,ClickHouse允许[`Variant`](/sql-reference/data-types/variant)列中的混合类型数据,并通过使用[`JSON`](/integrations/data-formats/json/overview)类型支持模式演变。 + +如果不使用[`JSON`](/integrations/data-formats/json/overview),模式是静态定义的。如果未为行提供值,它们将被定义为[`Nullable`](/sql-reference/data-types/nullable)(在ClickStack中不使用)或恢复为该类型的默认值,例如`String`的空值。 +### 摄取和转换 {#ingestion-and-transformation} + +Elasticsearch使用摄取管道与处理器(例如`enrich`,`rename`,`grok`)在索引之前转换文档。在ClickHouse中,类似的功能通过[**增量物化视图**](/materialized-view/incremental-materialized-view)实现,这可以[过滤、转换](/materialized-view/incremental-materialized-view#filtering-and-transformation)或[增强](/materialized-view/incremental-materialized-view#lookup-table)传入的数据,并将结果插入目标表。如果只需要物化视图的输出被存储,可以插入到`Null`表引擎。这意味着只有物化视图的结果会保留,而原始数据被丢弃——从而节省存储空间。 + +对于增强,Elasticsearch支持专用的[增强处理器](https://www.elastic.co/docs/reference/enrich-processor/enrich-processor)为文档添加上下文。在ClickHouse中,[**字典**](/dictionary)可以在[查询时间](/dictionary#query-time-enrichment)和[摄取时间](/dictionary#index-time-enrichment)用于增强行——例如,用于[将IP映射到位置](/use-cases/observability/schema-design#using-ip-dictionaries)或在插入时应用[用户代理查找](/use-cases/observability/schema-design#using-regex-dictionaries-user-agent-parsing)。 +### 查询语言 {#query-languages} + +Elasticsearch支持多种查询语言,包括[DSL](https://www.elastic.co/docs/explore-analyze/query-filter/languages/querydsl)、[ES|QL](https://www.elastic.co/docs/explore-analyze/query-filter/languages/esql)、[EQL](https://www.elastic.co/docs/explore-analyze/query-filter/languages/eql)和[KQL](https://www.elastic.co/docs/explore-analyze/query-filter/languages/kql)(Lucene风格)查询,但对连接的支持有限——只有通过[`ES|QL`](https://www.elastic.co/guide/en/elasticsearch/reference/8.x/esql-commands.html#esql-lookup-join)可以进行**左外连接**。ClickHouse支持**完整的SQL语法**,包括[所有连接类型](/sql-reference/statements/select/join#supported-types-of-join)、[窗口函数](/sql-reference/window-functions)、子查询(以及相关子查询)和CTE。这是需要关联可观察性信号与业务或基础设施数据的用户的一大优势。 + +在ClickStack中,[HyperDX提供与Lucene兼容的搜索界面](/use-cases/observability/clickstack/search)以便于过渡,同时通过ClickHouse后端提供完整的SQL支持。该语法可与[Elastic查询字符串](https://www.elastic.co/docs/reference/query-languages/query-dsl/query-dsl-query-string-query#query-string-syntax)语法进行比较。有关此语法的确切比较,请参见["ClickStack与Elastic中的搜索"](/use-cases/observability/clickstack/migration/elastic/search)。 +### 文件格式和接口 {#file-formats-and-interfaces} + +Elasticsearch支持JSON(和[有限的CSV](https://www.elastic.co/docs/reference/enrich-processor/csv-processor))摄取。ClickHouse支持超过**70种文件格式**,包括Parquet、Protobuf、Arrow、CSV等——用于摄取和导出。这使得与外部管道和工具的集成更加便捷。 + +两个系统都提供REST API,但ClickHouse还提供**原生协议**以实现低延迟、高吞吐量的交互。原生接口比HTTP支持查询进度、压缩和流式传输,更加高效,是大多数生产摄取的默认模式。 +### 索引与存储 {#indexing-and-storage} + +Elasticsearch + +分片的概念是Elasticsearch可扩展性模型的基础。每个 ① [**索引**](https://www.elastic.co/blog/what-is-an-elasticsearch-index)被划分为**分片**,每个分片是物理Lucene索引,存储为磁盘上的段。一个分片可以有一个或多个称为副本分片的物理副本以保证弹性。为了实现可扩展性,分片和副本可以分布在多个节点之间。单个分片 ② 由一个或多个不可变段组成。段是Lucene的基本索引结构,这是提供索引和搜索功能的Java库,Elasticsearch基于该库开发。 + +:::note Elasticsearch中的插入处理 +Ⓐ 新插入的文档 Ⓑ 首先进入一个默认每秒刷新一次的内存索引缓冲区。使用路由公式确定冲刷文档的目标分片,并在磁盘上为该分片写入新段。为了提高查询效率并实现已删除或更新文档的物理删除,段会在后台不断合并为更大的段,直到达到最大大小5GB。然而,仍然可以强制合并为更大的段。 +::: + +Elasticsearch建议将分片大小设置为约[50GB或2亿文档](https://www.elastic.co/docs/deploy-manage/production-guidance/optimize-performance/size-shards),因为存在[JVM堆和元数据开销](https://www.elastic.co/docs/deploy-manage/production-guidance/optimize-performance/size-shards#each-shard-has-overhead)。每个分片还有[最多20亿文档](https://www.elastic.co/docs/deploy-manage/production-guidance/optimize-performance/size-shards#troubleshooting-max-docs-limit)的硬限制。Elasticsearch对各个分片的查询进行并行化处理,但每个分片使用**单线程**进行处理,使得分片过多既昂贵又适得其反。这在本质上将分片与可扩展性紧密耦合,需要更多的分片(和节点)以提升性能。 + +Elasticsearch将所有字段索引到[**倒排索引**](https://www.elastic.co/docs/manage-data/data-store/index-basics)中以实现快速搜索,可选择使用[**文档值**](https://www.elastic.co/docs/reference/elasticsearch/mapping-reference/doc-values)进行聚合、排序和脚本字段访问。数值和地理字段使用[块K-D树](https://users.cs.duke.edu/~pankaj/publications/papers/bkd-sstd.pdf)进行地理空间数据和数字、日期范围的搜索。 + +重要的是,Elasticsearch在[`_source`](https://www.elastic.co/docs/reference/elasticsearch/mapping-reference/mapping-source-field)中存储完整的原始文档(用`LZ4`、`Deflate`或`ZSTD`压缩),而ClickHouse不存储单独的文档表示。数据在查询时从列中重构,节省存储空间。这种相同的能力也可以通过Elasticsearch使用[合成的`_source`](https://www.elastic.co/docs/reference/elasticsearch/mapping-reference/mapping-source-field#synthetic-source)实现,但有一些[限制](https://www.elastic.co/docs/reference/elasticsearch/mapping-reference/mapping-source-field#synthetic-source-restrictions)。禁用`_source`的做法也有[影响](https://www.elastic.co/docs/reference/elasticsearch/mapping-reference/mapping-source-field#include-exclude),这些影响对ClickHouse没有适用性。 + +在Elasticsearch中,[索引映射](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping.html)(相当于ClickHouse的表模式)控制字段的类型和用于这种持久性与查询的数据结构。 + +相比之下,ClickHouse是**列式**的——每列独立存储,但始终按表的主键/排序键排序。这种排序使[稀疏主索引](/primary-indexes)成为可能,允许ClickHouse在查询执行期间有效跳过数据。当查询按主键字段过滤时,ClickHouse仅读取每列的相关部分,显著减少磁盘I/O并提高性能——即使没有对每列进行完整索引。 + +ClickHouse + +ClickHouse还支持[**跳过索引**](/optimize/skipping-indexes),通过预计算所选列的索引数据来加速过滤。这些必须显式定义,但可以显著提高性能。此外,ClickHouse允许用户为每列指定[压缩编解码器](/use-cases/observability/schema-design#using-codecs)和压缩算法——这是Elasticsearch不支持的(其[压缩](https://www.elastic.co/docs/reference/elasticsearch/index-settings/index-modules)仅适用于`_source` JSON存储)。 + +ClickHouse也支持分片,但其模型旨在偏向**垂直扩展**。单个分片可以存储**万亿行**,并在内存、CPU和磁盘允许的情况下继续高效运行。与Elasticsearch不同,分片没有**硬行限制**。ClickHouse中的分片是逻辑的——有效地是单独的表——除非数据集超过单个节点的容量,否则不需要分区。这通常由于磁盘大小限制而发生,在这种情况下,只有当需要水平扩展时,① 才引入分片——从而减少复杂性和开销。在这种情况下,类似于Elasticsearch,一个分片将包含数据的子集。单个分片中的数据组织为包含多个数据结构的② 不可变数据部分。 + +ClickHouse分片内的处理是**完全并行化**的,鼓励用户纵向扩展以避免与跨节点移动数据相关的网络成本。 + +:::note ClickHouse中的插入处理 +ClickHouse中的插入默认是**同步的**——写入只有在提交后才会被确认——但可以配置为**异步插入**以匹配类似Elastic的缓冲和批处理。如果使用[异步数据插入](https://clickhouse.com/blog/asynchronous-data-inserts-in-clickhouse),Ⓐ 新插入的行首先进入Ⓑ 默认每200毫秒刷新一次的内存插入缓冲区。如果使用多个分片,则使用[分布式表](/engines/table-engines/special/distributed)将新插入的行路由到其目标分片。为该分片在磁盘上写入一个新部分。 +::: +### 分布与复制 {#distribution-and-replication} + +虽然Elasticsearch和ClickHouse都使用集群、分片和副本来确保可扩展性和容错能力,但它们的实现和性能特征差异显著。 + +Elasticsearch使用**主-副本**模型进行复制。当数据写入主分片时,它会同步复制到一个或多个副本。这些副本本身就是分布在节点之间以确保冗余的完整分片。Elasticsearch仅在所有所需副本确认操作后才会确认写入——这个模型提供接近**顺序一致性**的保证,尽管在完全同步之前,副本上可能会发生**脏读取**。一个**主节点**协调集群,管理分片分配、健康状况和领导者选举。 + +相反,ClickHouse默认采用**最终一致性**,由**Keeper**协调——这是ZooKeeper的轻量级替代品。写入可以直接发送到任何副本,或者通过[**分布式表**](/engines/table-engines/special/distributed)发送,后者自动选择副本。复制是异步的——更改在写入确认后传播到其他副本。对于更严格的保证,ClickHouse[支持**顺序一致性**](/migrations/postgresql/appendix#sequential-consistency),在所有副本都提交后才确认写入,虽然由于其性能影响很少使用。分布式表统一跨多个分片的访问,将`SELECT`查询转发到所有分片并合并结果。对于`INSERT`操作,它们通过均匀路由数据来平衡负载。ClickHouse的复制高度灵活:任何副本(一个分片的副本)都可以接受写入,所有更改都以异步方式同步到其他副本。这种架构容许在故障或维护期间不中断查询服务,重新同步自动处理——消除了对数据层的主-副本强制执行的需求。 + +:::note ClickHouse Cloud +在**ClickHouse Cloud**中,架构引入了一种无共享计算模型,其中单个**分片由对象存储**支持。这取代了基于副本的传统高可用性,允许多个节点同时**读取和写入**分片。存储与计算的分离使得弹性扩展成为可能,而无需显式的副本管理。 +::: + +总结如下: + +- **Elastic**:分片是与JVM内存相关的物理Lucene结构。过度分片会引入性能惩罚。复制是同步的,由主节点协调。 +- **ClickHouse**:分片是逻辑的且垂直可扩展,具有高度有效的本地执行。复制是异步的(但可以是顺序的),协调轻量。 + +最终,ClickHouse通过最小化对分片调优的需求,在规模上更偏向于简化和性能,同时在需要时提供强一致性保证。 +### 去重与路由 {#deduplication-and-routing} + +Elasticsearch根据其`_id`对文档进行去重,相应地将它们路由到分片。ClickHouse不存储默认行标识符,但支持**插入时去重**,允许用户安全地重试失败的插入。为了获得更多控制,`ReplacingMergeTree`和其他表引擎允许按特定列去重。 + +Elasticsearch中的索引路由确保特定文档始终路由到特定分片。在ClickHouse中,用户可以定义**分片键**,或使用`Distributed`表实现类似的数据本地性。 +### 聚合与执行模型 {#aggregations-execution-model} + +虽然两个系统都支持数据聚合,但ClickHouse提供显著[更多的函数](/sql-reference/aggregate-functions/reference),包括统计、近似和专有分析函数。 + +在可观察性用例中,聚合最常见的应用之一是计算特定日志消息或事件发生的频率(并在频率异常时发出警报)。 + +Elasticsearch中相当于ClickHouse `SELECT count(*) FROM ... GROUP BY ...` SQL查询的是[术语聚合](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html),这是Elasticsearch的[桶聚合](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket.html)。 + +ClickHouse的`GROUP BY`与`count(*)`和Elasticsearch的术语聚合在功能上通常是等价的,但在实现、性能和结果质量上有着广泛的差异。 + +在Elasticsearch中,这种聚合在“top-N”查询中[估算结果](https://www.elastic.co/docs/reference/aggregations/search-aggregations-bucket-terms-aggregation#terms-agg-doc-count-error)(例如,按计数排序的前10个主机),当查询的数据跨多个分片时。这种估算提高了速度,但可能会影响准确性。用户可以通过[检查`doc_count_error_upper_bound`](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html#terms-agg-doc-count-error)和增加`shard_size`参数来减少此错误——这增加了内存使用并降低了查询性能。 + +Elasticsearch还要求所有桶聚合都需要设置[`size`](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html#search-aggregations-bucket-terms-aggregation-size)——没有办法返回所有唯一组而不显式设置限制。高基数聚合会面临[`max_buckets`限制](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-settings.html#search-settings-max-buckets)或需要使用[复合聚合](https://www.elastic.co/docs/reference/aggregations/bucket/composite-aggregation)进行分页,这往往复杂且效率较低。 + +相比之下,ClickHouse的精确聚合开箱即用。像`count(*)`这样的函数在不需要配置调整的情况下返回准确的结果,使查询行为更简单和可预测。 + +ClickHouse没有大小限制。您可以在大型数据集上执行无界的组聚合查询。如果超出内存阈值,ClickHouse[可以溢出到磁盘](https://clickhouse.com/docs/en/sql-reference/statements/select/group-by#group-by-in-external-memory)。按主键前缀进行分组的聚合尤其高效,通常运行时所需的内存消耗最小。 +#### 执行模型 {#execution-model} + +上述差异可以归因于Elasticsearch和ClickHouse的执行模型,它们在查询执行和并行性方面采用了根本不同的方法。 + +ClickHouse旨在最大化现代硬件的效率。默认情况下,ClickHouse在具有N个CPU核心的机器上以N个并发执行通道运行SQL查询: + +ClickHouse execution + +在单节点上,执行通道将数据划分为独立的范围,允许在CPU线程上并行处理。这包括过滤、聚合和排序。每个通道的本地结果最终被合并,并在查询包含限制子句时应用限制操作符。 + +查询执行通过以下方式进一步并行化: +1. **SIMD矢量化**:在列式数据上的操作使用[CPU SIMD指令](https://en.wikipedia.org/wiki/Single_instruction,_multiple_data)(例如,[AVX512](https://en.wikipedia.org/wiki/AVX-512)),允许对值进行批处理。 +2. **集群级并行性**:在分布式设置中,每个节点本地执行查询处理。来自各个节点的[部分聚合状态](https://clickhouse.com/blog/aggregate-functions-combinators-in-clickhouse-for-arrays-maps-and-states#working-with-aggregation-states)被流式传输到发起节点并合并。如果查询的`GROUP BY`键与分片键对齐,可以[大幅减少或完全避免合并](/operations/settings/settings#distributed_group_by_no_merge)。 +
+该模型能够在核心和节点之间有效扩展,使ClickHouse非常适合大规模分析。使用*部分聚合状态*使来自不同线程和节点的中间结果可以无损合并。 + +相比之下,Elasticsearch为大多数聚合分配一个线程到每个分片,无论可用的CPU核心数量。这些线程返回分片本地的top-N结果,这些结果在协调节点上合并。这种方式可能会低效利用系统资源,并引入潜在的全局聚合不准确性,尤其是当频繁出现的术语分散在多个分片时。通过增加`shard_size`参数可以改善准确性,但会增加内存使用和查询延迟。 + +Elasticsearch execution + +总之,ClickHouse以更细粒度的并行性和对硬件资源的更大控制来执行聚合和查询,而Elasticsearch则依赖于基于分片的执行,约束更为严格。 + +有关各自技术中聚合机制的更多详细信息,我们推荐博客文章["ClickHouse vs. Elasticsearch: The Mechanics of Count Aggregations"](https://clickhouse.com/blog/clickhouse_vs_elasticsearch_mechanics_of_count_aggregations#elasticsearch)。 +### 数据管理 {#data-management} + +Elasticsearch和ClickHouse在管理时间序列可观察性数据方面采取了根本不同的方法——特别是在数据保留、轮换和分层存储方面。 +#### 索引生命周期管理与原生TTL {#lifecycle-vs-ttl} + +在Elasticsearch中,长期数据管理通过**索引生命周期管理(ILM)**和**数据流**来处理。这些功能允许用户定义管理何时轮换索引的策略(例如,在达到某个大小或年龄后),何时将旧索引移动到低成本存储(例如,温暖或寒冷级别),以及何时最终删除它们。这是必要的,因为Elasticsearch不**支持重新分片**,且分片不会无限增长而不降低性能。为了管理分片大小,并支持高效删除,必须定期创建新索引并移除旧索引——有效地在索引级别轮换数据。 + +ClickHouse采取不同的方法。数据通常存储在**单个表中**,并使用**TTL(存活时间)表达式**在列或分区级别进行管理。数据可以按日期**进行分区**,允许高效删除,而无需创建新表或执行索引轮换。随着数据的老化并满足TTL条件,ClickHouse将自动删除数据——无需额外的基础设施来管理轮换。 +#### 存储层次和热-温架构 {#storage-tiers} + +Elasticsearch支持**热-温-冷-冻结**存储架构,其中数据在不同性能特征的存储层之间移动。这通常通过ILM配置,并与集群中的节点角色相关。 + +ClickHouse通过原生表引擎(如`MergeTree`)支持**分层存储**,可以根据自定义规则自动在不同【卷】之间移动旧数据(例如,从SSD到HDD再到对象存储)。这可以模仿Elastic的热-温-冷方法——但无需管理多个节点角色或集群的复杂度。 + +:::note ClickHouse Cloud +在**ClickHouse Cloud**中,这变得更加无缝:所有数据存储在**对象存储(例如S3)**上,并且计算被解耦。数据可以保留在对象存储中,直到被查询,此时会被提取并在本地(或在分布式缓存中)缓存——提供与Elastic的冻结层相同的成本特征,但具有更好的性能特征。这种方法意味着不需要在存储层之间移动数据,从而使热-温架构变得冗余。 +::: +### Rollups vs incremental aggregates {#rollups-vs-incremental-aggregates} + +在Elasticsearch中,**rollups**或**aggregates**是通过一种叫做[**transforms**](https://www.elastic.co/guide/en/elasticsearch/reference/current/transforms.html)的机制实现的。这些机制用于在固定时间间隔(例如,每小时或每天)内使用**滑动窗口**模型汇总时间序列数据。这些配置为定期后台作业,从一个索引聚合数据并将结果写入一个单独的**rollup index**。这有助于通过避免重复扫描高基数原始数据来降低长时间查询的成本。 + +下面的图示抽象性地描绘了transform是如何工作的(请注意,我们使用蓝色表示所有属于同一桶的文档,我们希望预先计算其聚合值): + +Elasticsearch transforms + +连续transform使用基于可配置检查间隔时间的transform [checkpoints](https://www.elastic.co/guide/en/elasticsearch/reference/current/transform-checkpoints.html)(transform [frequency](https://www.elastic.co/guide/en/elasticsearch/reference/current/put-transform.html)的默认值为1分钟)。在上面的图中,我们假设在检查间隔时间到期后创建一个新的检查点。现在,Elasticsearch检查transform的源索引的变化,并检测到自上一个检查点以来存在三个新的`blue`文档(11、12和13)。因此,源索引被过滤为所有已有的`blue`文档,并且通过[复合聚合](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-composite-aggregation.html)(利用结果[分页](https://www.elastic.co/guide/en/elasticsearch/reference/current/paginate-search-results.html)),重新计算聚合值(目标索引被用新文档替换,更新包含先前聚合值的文档)。同样,在②和③处,通过检查变化并重新计算属于同一'blue'桶的所有现有文档的聚合值来处理新的检查点。 + +ClickHouse采取根本不同的方法。与其定期重新聚合数据,ClickHouse支持**增量物化视图**,在**插入时间**对数据进行变换和聚合。当新数据写入源表时,物化视图对仅新**插入的块**执行预定义的SQL聚合查询,并将聚合结果写入目标表。 + +这种模型得益于ClickHouse对[**部分聚合状态**](https://clickhouse.com/docs/en/sql-reference/data-types/aggregatefunction)的支持——聚合函数的中间表示可以被存储和后续合并。这使得用户能够维护部分聚合结果,这些结果查询速度快且更新成本低。由于聚合在数据到达时发生,因此无需运行昂贵的定期作业或重新汇总旧数据。 + +我们抽象地勾勒了增量物化视图的机制(请注意,我们使用蓝色表示所有属于同一组的行,我们希望预先计算其聚合值): + +ClickHouse Materialized Views + +在上面的图中,物化视图的源表已经包含一个数据部分,存储一些属于同一组的`blue`行(1到10)。对于这个组,物化视图的目标表中也已经存在一个数据部分,存储`blue`组的[部分聚合状态](https://www.youtube.com/watch?v=QDAJTKZT8y4)。当在源表中进行①②③插入新行时,为每个插入创建一个相应的源表数据部分,并且针对每个新插入的行块并行计算并插入部分聚合状态以数据部分的形式到物化视图的目标表中。在后台部分合并过程中,部分聚合状态被合并,从而实现增量数据聚合。 + +请注意,所有[聚合函数](https://clickhouse.com/docs/en/sql-reference/aggregate-functions/reference)(超过90个),包括与聚合函数[组合器](https://www.youtube.com/watch?v=7ApwD0cfAFI)的组合,均支持[部分聚合状态](https://clickhouse.com/docs/en/sql-reference/data-types/aggregatefunction)。 + +有关Elasticsearch与ClickHouse在增量聚合方面的更具体示例,请参见此[示例](https://github.com/ClickHouse/examples/tree/main/blog-examples/clickhouse-vs-elasticsearch/continuous-data-transformation#continuous-data-transformation-example)。 + +ClickHouse方法的优点包括: + +- **始终最新的聚合**:物化视图始终与源表同步。 +- **无后台作业**:聚合在插入时间推送,而非查询时间。 +- **更好的实时性能**:适用于观察工作负载和需要即时更新聚合的实时分析。 +- **可组合性**:物化视图可以与其他视图和表层次分离或联接,以加速更复杂的查询。 +- **不同的TTL**:可以对物化视图的源表和目标表应用不同的TTL设置。 + +此模型对于需要计算每分钟错误率、延迟或前N名分解等指标的观察用例非常强大,无需在每个查询中扫描数十亿的原始记录。 + +### Lakehouse support {#lakehouse-support} + +ClickHouse和Elasticsearch在lakehouse集成方面采取根本不同的方法。ClickHouse是一个完整的查询执行引擎,能够对如[Iceberg](/sql-reference/table-functions/iceberg)和[Delta Lake](/sql-reference/table-functions/deltalake)这样的lakehouse格式执行查询,同时也能与数据湖目录如[AWS Glue](/use-cases/data-lake/glue-catalog)和[Unity catalog](/use-cases/data-lake/unity-catalog)集成。这些格式依赖于高效查询[Parquet](/interfaces/formats/Parquet)文件,ClickHouse完全支持这种格式。ClickHouse可以直接读取Iceberg和Delta Lake表,从而实现与现代数据湖架构的无缝集成。 + +相反,Elasticsearch与其内部数据格式和基于Lucene的存储引擎紧密耦合。它无法直接查询lakehouse格式或Parquet文件,限制其参与现代数据湖架构的能力。Elasticsearch需要将数据转换并加载到其专有格式中,才能进行查询。 + +ClickHouse的lakehouse能力不仅限于读取数据: + +- **数据目录集成**:ClickHouse支持与数据目录的集成,如[AWS Glue](/use-cases/data-lake/glue-catalog),实现对对象存储中表的自动发现和访问。 +- **对象存储支持**:原生支持查询驻留在[S3](/engines/table-engines/integrations/s3)、[GCS](/sql-reference/table-functions/gcs)和[Azure Blob Storage](/engines/table-engines/integrations/azureBlobStorage)中的数据,而无需移动数据。 +- **查询联合**:能够跨多个来源关联数据,包括lakehouse表、传统数据库和ClickHouse表,使用[外部字典](/dictionary)和[表函数](/sql-reference/table-functions)。 +- **增量加载**:支持从lakehouse表持续加载数据到本地[MergeTree](/engines/table-engines/mergetree-family/mergetree)表,使用[S3Queue](/engines/table-engines/integrations/s3queue)和[ClickPipes](/integrations/clickpipes)等功能。 +- **性能优化**:利用[集群函数](/sql-reference/table-functions/cluster)在lakehouse数据上进行分布式查询执行,以提高性能。 + +这些能力使ClickHouse成为采用lakehouse架构的组织的自然选择,允许它们利用数据湖的灵活性和列式数据库的性能。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/elastic/concepts.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/elastic/concepts.md.hash new file mode 100644 index 00000000000..b395709fd02 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/elastic/concepts.md.hash @@ -0,0 +1 @@ +005d87ca4834a8e6 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/elastic/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/elastic/index.md new file mode 100644 index 00000000000..e3997428355 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/elastic/index.md @@ -0,0 +1,23 @@ +--- +'slug': '/use-cases/observability/clickstack/migration/elastic' +'title': '迁移到 ClickStack 从 Elastic' +'pagination_prev': null +'pagination_next': null +'description': '着陆页迁移到 ClickHouse 可观察性栈 从 Elastic' +'show_related_blogs': true +'keywords': +- 'Elasticsearch' +'doc_type': 'landing-page' +--- + +该指南提供了从 Elastic Stack 迁移到 ClickStack 的综合方法。我们专注于一种并行操作策略,旨在降低风险,同时利用 ClickHouse 在可观察性工作负载中的优势。 + +| 部分 | 描述 | +|------|------| +| [简介](/use-cases/observability/clickstack/migration/elastic/intro) | 迁移过程和关键考虑因素的概述 | +| [概念](/use-cases/observability/clickstack/migration/elastic/concepts) | 理解 Elastic 和 ClickStack 之间的等效概念 | +| [类型](/use-cases/observability/clickstack/migration/elastic/types) | 将 Elasticsearch 类型映射到 ClickHouse 等效项 | +| [搜索](/use-cases/observability/clickstack/migration/elastic/search) | 比较搜索能力和查询语法 | +| [数据迁移](/use-cases/observability/clickstack/migration/elastic/migrating-data) | 数据迁移和并行操作的策略 | +| [迁移代理](/use-cases/observability/clickstack/migration/elastic/migrating-agents) | 从 Elastic 代理过渡到 OpenTelemetry | +| [迁移 SDK](/use-cases/observability/clickstack/migration/elastic/migrating-sdks) | 用 OpenTelemetry SDK 替换 Elastic APM 代理 | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/elastic/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/elastic/index.md.hash new file mode 100644 index 00000000000..1b480c5d23c --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/elastic/index.md.hash @@ -0,0 +1 @@ +e749e75072c87861 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/elastic/intro.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/elastic/intro.md new file mode 100644 index 00000000000..8515f5a1cb2 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/elastic/intro.md @@ -0,0 +1,33 @@ +--- +'slug': '/use-cases/observability/clickstack/migration/elastic/intro' +'title': '从 Elastic 迁移到 ClickStack' +'pagination_prev': null +'pagination_next': null +'sidebar_label': '概述' +'sidebar_position': 0 +'description': '从 Elastic 迁移到 ClickHouse 可观察性堆栈的概述' +'show_related_blogs': true +'keywords': +- 'Elasticsearch' +'doc_type': 'guide' +--- + +## 从 Elastic 迁移到 ClickStack {#migrating-to-clickstack-from-elastic} + +本指南旨在帮助从 Elastic Stack 迁移的用户——特别是那些使用 Kibana 监控通过 Elastic Agent 收集并存储在 Elasticsearch 中的日志、追踪和指标的用户。它概述了 ClickStack 中的等效概念和数据类型,解释了如何将基于 Kibana Lucene 的查询转换为 HyperDX 的语法,并提供有关迁移数据和代理的指导,以确保顺利过渡。 + +在开始迁移之前,了解 ClickStack 与 Elastic Stack 之间的权衡是很重要的。 + +如果您考虑迁移到 ClickStack,可以考虑以下因素: + +- 您正在摄取大量的可观察性数据,并发现由于低效的压缩和糟糕的资源利用,Elastic 的成本高昂。ClickStack 可以显著降低存储和计算成本——提供至少 10 倍的原始数据压缩。 +- 您在大规模搜索性能较差或面临摄取瓶颈。 +- 您希望使用 SQL 将可观察性信号与业务数据相关联,从而统一可观察性和分析工作流。 +- 您致力于 OpenTelemetry,并希望避免厂商锁定。 +- 您希望利用 ClickHouse Cloud 中存储和计算的分离,实现几乎无限的扩展——在闲置期间仅为摄取计算和对象存储付款。 + +然而,如果以下情况适用,则 ClickStack 可能不适合您: + +- 您主要将可观察性数据用于安全用例,并需要侧重于 SIEM 的产品。 +- 通用分析是您的工作流程中的关键部分。 +- 您需要一个商业智能(BI)仪表盘平台。ClickStack 有意为 SRE 和开发人员设计了意见明确的可视化工作流,并未被设计为商业智能(BI)工具。对于具有等效功能的情况,我们建议使用 [Grafana with the ClickHouse plugin](/integrations/grafana) 或 [Superset](/integrations/superset)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/elastic/intro.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/elastic/intro.md.hash new file mode 100644 index 00000000000..0ece6f67502 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/elastic/intro.md.hash @@ -0,0 +1 @@ +f300ad4d45963172 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/elastic/migrating-agents.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/elastic/migrating-agents.md new file mode 100644 index 00000000000..736ded352dd --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/elastic/migrating-agents.md @@ -0,0 +1,421 @@ +--- +'slug': '/use-cases/observability/clickstack/migration/elastic/migrating-agents' +'title': '从 Elastic 迁移代理' +'pagination_prev': null +'pagination_next': null +'sidebar_label': '迁移代理' +'sidebar_position': 5 +'description': '从 Elastic 迁移代理' +'show_related_blogs': true +'keywords': +- 'ClickStack' +'doc_type': 'guide' +--- + +import Image from '@theme/IdealImage'; +import ingestion_key from '@site/static/images/use-cases/observability/ingestion-keys.png'; +import add_logstash_output from '@site/static/images/use-cases/observability/add-logstash-output.png'; +import agent_output_settings from '@site/static/images/use-cases/observability/agent-output-settings.png'; +import migrating_agents from '@site/static/images/use-cases/observability/clickstack-migrating-agents.png'; + +## 从 Elastic 迁移代理 {#migrating-agents-from-elastic} + +Elastic Stack 提供多种可观察性数据收集代理。具体包括: + +- [Beats 家族](https://www.elastic.co/beats) - 如 [Filebeat](https://www.elastic.co/beats/filebeat)、[Metricbeat](https://www.elastic.co/beats/metricbeat) 和 [Packetbeat](https://www.elastic.co/beats/packetbeat) - 所有这些均基于 `libbeat` 库。此类 Beats 支持通过 Lumberjack 协议 [将数据发送到 Elasticsearch、Kafka、Redis 或 Logstash](https://www.elastic.co/docs/reference/beats/filebeat/configuring-output)。 +- [`Elastic Agent`](https://www.elastic.co/elastic-agent) 提供一个统一的代理,能够收集日志、指标和跟踪信息。此代理可通过 [Elastic Fleet Server](https://www.elastic.co/docs/reference/fleet/manage-elastic-agents-in-fleet) 进行集中管理,并支持输出到 Elasticsearch、Logstash、Kafka 或 Redis。 +- Elastic 还提供了 [OpenTelemetry Collector - EDOT](https://www.elastic.co/docs/reference/opentelemetry) 的发行版本。虽然目前无法通过 Fleet Server 进行编排,但它为迁移到 ClickStack 的用户提供了更灵活和开放的路径。 + +最佳的迁移路径取决于当前使用的代理。在接下来的部分中,我们将记录每种主要代理类型的迁移选项。我们的目标是在可能的情况下,最小化摩擦,并允许用户在过渡期间继续使用他们现有的代理。 + +## 首选迁移路径 {#prefered-migration-path} + +在可能的情况下,我们建议将所有日志、指标和跟踪收集迁移到 [OpenTelemetry (OTel) Collector](https://opentelemetry.io/docs/collector/),并在 [边缘以代理角色](/use-cases/observability/clickstack/ingesting-data/otel-collector#collector-roles) 部署收集器。这代表了发送数据的最有效方式,避免了架构复杂性和数据转换。 + +:::note 为什么选择 OpenTelemetry Collector? +OpenTelemetry Collector 提供了一种可持续且不依赖于供应商的可观察性数据摄取解决方案。我们认识到,一些组织操作的 Elastic 代理数量达到数千甚至上万。对于这些用户,保持与现有代理基础设施的兼容性可能至关重要。本文件旨在支持这一点,同时帮助团队逐步过渡到基于 OpenTelemetry 的收集。 +::: + +## ClickHouse OpenTelemetry 端点 {#clickhouse-otel-endpoint} + +所有数据通过 **OpenTelemetry (OTel) collector** 实例摄取到 ClickStack,这作为日志、指标、跟踪和会话数据的主要入口点。我们推荐使用官方的 [ClickStack 发行版](/use-cases/observability/clickstack/ingesting-data/opentelemetry#installing-otel-collector) 来部署此实例,如果该发行版尚未 [已捆绑在你的 ClickStack 部署模型中](/use-cases/observability/clickstack/deployment)。 + +用户可以通过 [语言 SDKs](/use-cases/observability/clickstack/sdks) 或通过收集基础设施指标和日志的数据收集代理(如在 [agent](/use-cases/observability/clickstack/ingesting-data/otel-collector#collector-roles) 角色下的 OTel collectors 或其他技术,例如 [Fluentd](https://www.fluentd.org/) 或 [Vector](https://vector.dev/))向该收集器发送数据。 + +**我们假设该收集器可用于所有代理迁移步骤**。 + +## 从 beats 迁移 {#migrating-to-beats} + +具有广泛 Beats 部署的用户在迁移到 ClickStack 时可能希望保留这些部署。 + +**目前此选项仅在 Filebeat 上进行了测试,因此仅适用于日志。** + +Beats 代理使用 [Elastic Common Schema (ECS)](https://www.elastic.co/docs/reference/ecs),该架构目前正在与 ClickStack 使用的 [OpenTelemetry](https://github.com/open-telemetry/opentelemetry-specification/blob/main/oteps/0199-support-elastic-common-schema-in-opentelemetry.md) 规范合并。然而,这些 [架构仍然存在显著差异](https://www.elastic.co/docs/reference/ecs/ecs-otel-alignment-overview),用户目前需要在数据摄取到 ClickStack 之前将 ECS 格式事件转换为 OpenTelemetry 格式。 + +我们建议使用 [Vector](https://vector.dev) 执行此转换,Vector 是一个轻量级且高性能的可观察性数据管道,支持名为 Vector Remap Language (VRL) 的强大转换语言。 + +如果你的 Filebeat 代理配置为将数据发送到 Kafka - Beats 支持的输出 - Vector 可以从 Kafka 中消耗这些事件,使用 VRL 应用架构转换,然后通过 OTLP 将其转发到与 ClickStack 一起分发的 OpenTelemetry Collector。 + +另外,Vector 还支持通过 Logstash 使用的 Lumberjack 协议接收事件。这使得 Beats 代理可以直接将数据发送到 Vector,在这里可以在转发到 ClickStack OpenTelemetry Collector 之前应用相同的转换处理。 + +以下是这两种架构的示意图。 + +Migrating agents + +在以下示例中,我们提供配置 Vector 以通过 Lumberjack 协议接收 Filebeat 日志事件的初始步骤。我们提供 VRL 用于将传入的 ECS 事件映射到 OTel 规范,然后通过 OTLP 将这些事件发送到 ClickStack OpenTelemetry collector。通过 Kafka 消费事件的用户可以将 Vector Logstash 源替换为 [Kafka 源](https://vector.dev/docs/reference/configuration/sources/kafka/) - 其他所有步骤保持不变。 + + + +### 安装 vector {#install-vector} + +使用 [官方安装指南](https://vector.dev/docs/setup/installation/) 安装 Vector。 + +这可以安装在与 Elastic Stack OTel collector 相同的实例上。 + +用户在 [将 Vector 投入生产](https://vector.dev/docs/setup/going-to-prod/) 时,可以遵循架构和安全方面的最佳实践。 + +### 配置 vector {#configure-vector} + +Vector 应配置为通过 Lumberjack 协议接收事件,模仿 Logstash 实例。这可以通过为 Vector 配置 [`logstash` 源](https://vector.dev/docs/reference/configuration/sources/logstash/) 来实现: + +```yaml +sources: + beats: + type: logstash + address: 0.0.0.0:5044 + tls: + enabled: false # Set to true if you're using TLS + # The files below are generated from the steps at https://www.elastic.co/docs/reference/fleet/secure-logstash-connections#generate-logstash-certs + # crt_file: logstash.crt + # key_file: logstash.key + # ca_file: ca.crt + # verify_certificate: true +``` + +:::note TLS 配置 +如果需要双向 TLS,请使用 Elastic 指南 ["为 Logstash 输出配置 SSL/TLS"](https://www.elastic.co/docs/reference/fleet/secure-logstash-connections#use-ls-output) 生成证书和密钥。这些可以在配置中指定,如上所示。 +::: + +事件将以 ECS 格式接收。这些可以使用 Vector Remap Language (VRL) 转换器转换为 OpenTelemetry 架构。该转换器的配置非常简单,脚本文件保存在单独文件中: + +```yaml +transforms: + remap_filebeat: + inputs: ["beats"] + type: "remap" + file: 'beat_to_otel.vrl' +``` + +请注意,它接收来自上述 `beats` 源的事件。我们的重映射脚本如下所示。该脚本仅在日志事件上进行了测试,但可以作为其他格式的基础。 + +
+VRL - ECS 转 OTel + +```javascript + +# Define keys to ignore at root level +ignored_keys = ["@metadata"] + + +# Define resource key prefixes +resource_keys = ["host", "cloud", "agent", "service"] + + +# Create separate objects for resource and log record fields +resource_obj = {} +log_record_obj = {} + + +# Copy all non-ignored root keys to appropriate objects +root_keys = keys(.) +for_each(root_keys) -> |_index, key| { + if !includes(ignored_keys, key) { + val, err = get(., [key]) + if err == null { + # Check if this is a resource field + is_resource = false + if includes(resource_keys, key) { + is_resource = true + } + + # Add to appropriate object + if is_resource { + resource_obj = set(resource_obj, [key], val) ?? resource_obj + } else { + log_record_obj = set(log_record_obj, [key], val) ?? log_record_obj + } + } + } +} + + +# Flatten both objects separately +flattened_resources = flatten(resource_obj, separator: ".") +flattened_logs = flatten(log_record_obj, separator: ".") + + +# Process resource attributes +resource_attributes = [] +resource_keys_list = keys(flattened_resources) +for_each(resource_keys_list) -> |_index, field_key| { + field_value, err = get(flattened_resources, [field_key]) + if err == null && field_value != null { + attribute, err = { + "key": field_key, + "value": { + "stringValue": to_string(field_value) + } + } + if (err == null) { + resource_attributes = push(resource_attributes, attribute) + } + } +} + + +# Process log record attributes +log_attributes = [] +log_keys_list = keys(flattened_logs) +for_each(log_keys_list) -> |_index, field_key| { + field_value, err = get(flattened_logs, [field_key]) + if err == null && field_value != null { + attribute, err = { + "key": field_key, + "value": { + "stringValue": to_string(field_value) + } + } + if (err == null) { + log_attributes = push(log_attributes, attribute) + } + } +} + + +# Get timestamp for timeUnixNano (convert to nanoseconds) +timestamp_nano = if exists(.@timestamp) { + to_unix_timestamp!(parse_timestamp!(.@timestamp, format: "%Y-%m-%dT%H:%M:%S%.3fZ"), unit: "nanoseconds") +} else { + to_unix_timestamp(now(), unit: "nanoseconds") +} + + +# Get message/body field +body_value = if exists(.message) { + to_string!(.message) +} else if exists(.body) { + to_string!(.body) +} else { + "" +} + + +# Create the OpenTelemetry structure +. = { + "resourceLogs": [ + { + "resource": { + "attributes": resource_attributes + }, + "scopeLogs": [ + { + "scope": {}, + "logRecords": [ + { + "timeUnixNano": to_string(timestamp_nano), + "severityNumber": 9, + "severityText": "info", + "body": { + "stringValue": body_value + }, + "attributes": log_attributes + } + ] + } + ] + } + ] +} +``` + +
+ +最后,经过转换的事件可以通过 OpenTelemetry collector 通过 OTLP 发送到 ClickStack。这需要在 Vector 中配置 OTLP 接收器,该接收器从 `remap_filebeat` 转换中获取事件作为输入: + +```yaml +sinks: + otlp: + type: opentelemetry + inputs: [remap_filebeat] # receives events from a remap transform - see below + protocol: + type: http # Use "grpc" for port 4317 + uri: http://localhost:4318/v1/logs # logs endpoint for the OTel collector + method: post + encoding: + codec: json + framing: + method: newline_delimited + headers: + content-type: application/json + authorization: ${YOUR_INGESTION_API_KEY} +``` + +这里的 `YOUR_INGESTION_API_KEY` 是由 ClickStack 生成的。您可以在 HyperDX 应用程序的 `Team Settings → API Keys` 中找到该密钥。 + +Ingestion keys + +我们的最终完整配置如下所示: + +```yaml +sources: + beats: + type: logstash + address: 0.0.0.0:5044 + tls: + enabled: false # Set to true if you're using TLS + #crt_file: /data/elasticsearch-9.0.1/logstash/logstash.crt + #key_file: /data/elasticsearch-9.0.1/logstash/logstash.key + #ca_file: /data/elasticsearch-9.0.1/ca/ca.crt + #verify_certificate: true + +transforms: + remap_filebeat: + inputs: ["beats"] + type: "remap" + file: 'beat_to_otel.vrl' + +sinks: + otlp: + type: opentelemetry + inputs: [remap_filebeat] + protocol: + type: http # Use "grpc" for port 4317 + uri: http://localhost:4318/v1/logs + method: post + encoding: + codec: json + framing: + method: newline_delimited + headers: + content-type: application/json +``` + +### 配置 Filebeat {#configure-filebeat} + +现有的 Filebeat 安装只需要修改以将其事件发送到 Vector。这需要配置一个 Logstash 输出 - 再次可以选择配置 TLS: + +```yaml + +# ------------------------------ Logstash Output ------------------------------- +output.logstash: + # The Logstash hosts + hosts: ["localhost:5044"] + + # Optional SSL. By default is off. + # List of root certificates for HTTPS server verifications + #ssl.certificate_authorities: ["/etc/pki/root/ca.pem"] + + # Certificate for SSL client authentication + #ssl.certificate: "/etc/pki/client/cert.pem" + + # Client Certificate Key + #ssl.key: "/etc/pki/client/cert.key" +``` + +
+ +## 从 Elastic Agent 迁移 {#migrating-from-elastic-agent} + +Elastic Agent 将不同的 Elastic Beats 整合到一个软件包中。该代理与 [Elastic Fleet](https://www.elastic.co/docs/reference/fleet/fleet-server) 集成,允许其进行集中编排和配置。 + +已经部署 Elastic Agents 的用户有几种迁移路径: + +- 配置代理通过 Lumberjack 协议发送到 Vector 端点。**目前此选项仅对收集日志数据的 Elastic Agent 进行了测试。** 跨 Fleet UI 在 Kibana 中可以进行集中配置。 +- [以 Elastic OpenTelemetry Collector (EDOT) 运行代理](https://www.elastic.co/docs/reference/fleet/otel-agent)。Elastic Agent 包括一个嵌入的 EDOT Collector,允许你对应用程序和基础设施进行一次性编码,并将数据发送到多个供应商和后端。在此配置中,用户只需配置 EDOT collector 通过 OTLP 将事件转发到 ClickStack OTel collector。**这种方法支持所有事件类型。** + +我们在下面演示这两个选项。 + +### 通过 Vector 发送数据 {#sending-data-via-vector} + + + +#### 安装和配置 Vector {#install-configure-vector} + +使用 [迁移 Filebeat 的相同步骤](#install-vector) 安装和配置 Vector。 + +#### 配置 Elastic Agent {#configure-elastic-agent} + +Elastic Agent 需要配置为通过 Logstash 协议 Lumberjack 发送数据。这是一种 [受支持的部署模式](https://www.elastic.co/docs/manage-data/ingest/ingest-reference-architectures/ls-networkbridge),可以通过 Fleet 或 [通过代理配置文件 `elastic-agent.yaml`](https://www.elastic.co/docs/reference/fleet/logstash-output) 配置(如果不通过 Fleet 部署)。 + +可以通过在 Kibana 中添加 [Output 到 Fleet](https://www.elastic.co/docs/reference/fleet/fleet-settings#output-settings) 来实现中央配置。 + +Add Logstash output + +此输出可以在 [代理策略](https://www.elastic.co/docs/reference/fleet/agent-policy) 中使用。这将自动意味着任何使用该策略的代理都将其数据发送到 Vector。 + +Agent settings + +由于这需要在 TLS 上配置安全通信,我们建议遵循指南 ["为 Logstash 输出配置 SSL/TLS"](https://www.elastic.co/docs/reference/fleet/secure-logstash-connections#use-ls-output),用户可以假设其 Vector 实例充当 Logstash。 + +请注意,这要求用户在 Vector 中也配置 Logstash 源以支持双向 TLS。使用 [指南](https://www.elastic.co/docs/reference/fleet/secure-logstash-connections#generate-logstash-certs) 中生成的密钥和证书正确配置输入。 + +```yaml +sources: + beats: + type: logstash + address: 0.0.0.0:5044 + tls: + enabled: true # Set to true if you're using TLS. + # The files below are generated from the steps at https://www.elastic.co/docs/reference/fleet/secure-logstash-connections#generate-logstash-certs + crt_file: logstash.crt + key_file: logstash.key + ca_file: ca.crt + verify_certificate: true +``` + + + +### 将 Elastic Agent 作为 OpenTelemetry collector 运行 {#run-agent-as-otel} + +Elastic Agent 包含一个嵌入的 EDOT Collector,允许你对应用程序和基础设施进行一次性编码,并将数据发送到多个供应商和后端。 + +:::note 代理集成和编排 +运行与 Elastic Agent 一起分发的 EDOT collector 的用户将无法利用 [代理提供的现有集成](https://www.elastic.co/docs/reference/fleet/manage-integrations)。此外,collector 不能由 Fleet 进行集中管理 - 迫使用户以 [独立模式](https://www.elastic.co/docs/reference/fleet/configure-standalone-elastic-agents) 运行代理,自行管理配置。 +::: + +要使用 EDOT collector 运行 Elastic Agent,请参阅 [官方 Elastic 指南](https://www.elastic.co/docs/reference/fleet/otel-agent-transform)。与指南中指示的 Elastic 端点配置不同,删除现有的 `exporters` 并配置 OTLP 输出 - 将数据发送到 ClickStack OpenTelemetry collector。例如,exporters 的配置变为: + +```yaml +exporters: + # Exporter to send logs and metrics to Elasticsearch Managed OTLP Input + otlp: + endpoint: localhost:4317 + headers: + authorization: ${YOUR_INGESTION_API_KEY} + tls: + insecure: true +``` + +这里的 `YOUR_INGESTION_API_KEY` 是由 ClickStack 生成的。您可以在 HyperDX 应用程序的 `Team Settings → API Keys` 中找到该密钥。 + +Ingestion keys + +如果 Vector 已配置使用双向 TLS,并且证书和密钥是使用来自 ["为 Logstash 输出配置 SSL/TLS"](https://www.elastic.co/docs/reference/fleet/secure-logstash-connections#use-ls-output) 的步骤生成的,则需要相应配置 `otlp` exporter,例如: + +```yaml +exporters: + # Exporter to send logs and metrics to Elasticsearch Managed OTLP Input + otlp: + endpoint: localhost:4317 + headers: + authorization: ${YOUR_INGESTION_API_KEY} + tls: + insecure: false + ca_file: /path/to/ca.crt + cert_file: /path/to/client.crt + key_file: /path/to/client.key +``` + +## 从 Elastic OpenTelemetry collector 迁移 {#migrating-from-elastic-otel-collector} + +已经运行 [Elastic OpenTelemetry Collector (EDOT)](https://www.elastic.co/docs/reference/opentelemetry) 的用户可以简单地重新配置其代理,通过 OTLP 发送到 ClickStack OpenTelemetry collector。相关步骤与上述 [将 Elastic Agent 作为 OpenTelemetry collector](#run-agent-as-otel) 的步骤相同。该方法可用于所有数据类型。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/elastic/migrating-agents.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/elastic/migrating-agents.md.hash new file mode 100644 index 00000000000..4e280001e39 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/elastic/migrating-agents.md.hash @@ -0,0 +1 @@ +ad86d3fda5727254 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/elastic/migrating-data.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/elastic/migrating-data.md new file mode 100644 index 00000000000..d19473cb9c8 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/elastic/migrating-data.md @@ -0,0 +1,655 @@ +--- +'slug': '/use-cases/observability/clickstack/migration/elastic/migrating-data' +'title': '从 Elastic 迁移数据到 ClickStack' +'pagination_prev': null +'pagination_next': null +'sidebar_label': '迁移数据' +'sidebar_position': 4 +'description': '从 Elastic 迁移数据到 ClickHouse 观察性堆栈' +'show_related_blogs': true +'keywords': +- 'ClickStack' +'doc_type': 'guide' +--- + +## 并行操作策略 {#parallel-operation-strategy} + +在从 Elastic 迁移到 ClickStack 的可观察性用例时,我们建议采用 **并行操作** 方法,而不是试图迁移历史数据。这种策略有几个优势: + +1. **最小风险**:通过同时运行两个系统,您可以在验证 ClickStack 并让用户熟悉新系统的同时,保持对现有数据和仪表板的访问。 +2. **自然数据过期**:大多数可观察性数据的保留期有限(通常为 30 天或更短),这使得数据从 Elastic 过期时实现自然过渡。 +3. **简化迁移**:无需复杂的数据传输工具或流程来在系统之间移动历史数据。 +
+:::note 迁移数据 +我们在 ["迁移数据"](#migrating-data) 部分演示了将重要数据从 Elasticsearch 迁移到 ClickHouse 的方法。由于 Elasticsearch 在以 JSON 格式导出时效率有限,因此不应将其用于更大的数据集。 +::: + +### 实施步骤 {#implementation-steps} + +1. **配置双重摄取** +
+设置数据收集管道以同时将数据发送到 Elastic 和 ClickStack。 + +如何实现这一点取决于您当前用于收集的代理 - 请参阅 ["迁移代理"](/use-cases/observability/clickstack/migration/elastic/migrating-agents)。 + +2. **调整保留期** +
+配置 Elastic 的 TTL 设置以匹配您所需的保留期。设置 ClickStack 的 [TTL](/use-cases/observability/clickstack/production#configure-ttl) 以保持相同时间段的数据。 + +3. **验证和比较**: +
+- 对两个系统运行查询,以确保数据一致性 +- 比较查询性能和结果 +- 将仪表板和警报迁移到 ClickStack。这目前是一个手动过程。 +- 验证所有关键仪表板和警报在 ClickStack 中按预期工作 + +4. **逐步过渡**: +
+- 随着数据自然从 Elastic 过期,用户将越来越依赖 ClickStack +- 一旦对 ClickStack 建立了信心,您可以开始重定向查询和仪表板 + +### 长期保留 {#long-term-retention} + +对于需要更长保留期的组织: + +- 继续同时运行两个系统,直到所有数据从 Elastic 过期 +- ClickStack 的 [分层存储](/engines/table-engines/mergetree-family/mergetree#table_engine-mergetree-multiple-volumes) 功能可以帮助有效管理长期数据。 +- 考虑使用 [物化视图](/materialized-view/incremental-materialized-view) 来保持聚合或过滤的历史数据,同时允许原始数据过期。 + +### 迁移时间表 {#migration-timeline} + +迁移时间表将取决于您的数据保留要求: + +- **30 天保留**:迁移可以在一个月内完成。 +- **更长的保留**:继续并行操作,直到数据从 Elastic 过期。 +- **历史数据**:如果绝对必要,考虑使用 [迁移数据](#migrating-data) 导入特定的历史数据。 + +## 迁移设置 {#migration-settings} + +在从 Elastic 迁移到 ClickStack 时,您的索引和存储设置需要调整以适应 ClickHouse 的架构。虽然 Elasticsearch 依赖于横向扩展和分片以提高性能和容错,因此默认有多个分片,ClickHouse 经过优化,适合纵向扩展,通常在较少的分片下性能最佳。 + +### 推荐设置 {#recommended-settings} + +我们建议从 **单个分片** 开始,并进行纵向扩展。这种配置适合大多数可观察性工作负载,并简化了管理和查询性能调优。 + +- **[ClickHouse Cloud](https://clickhouse.com/cloud)**:默认使用单分片,多副本架构。存储和计算独立扩展,适合可观察性用例的不可预测摄取模式和重读取工作负载。 +- **ClickHouse OSS**:在自管理部署中,我们建议: + - 从单个分片开始 + - 通过增加 CPU 和内存进行纵向扩展 + - 使用 [分层存储](/observability/managing-data#storage-tiers) 用 S3 兼容对象存储扩展本地磁盘 + - 如果需要高可用性,请使用 [`ReplicatedMergeTree`](/engines/table-engines/mergetree-family/replication) + - 在可观察性工作负载中,通常 1 个副本的分片 (/engines/table-engines/mergetree-family/replication) 就足够了。 + +### 何时分片 {#when-to-shard} + +如果: + +- 您的摄取速率超过单个节点的容量(通常 >500K 行/秒) +- 您需要租户隔离或区域数据分离 +- 您的总数据集对于单台服务器来说太大,即使使用对象存储 + +如果您确实需要分片,请参考 [横向扩展](/architecture/horizontal-scaling) 获取有关分片键和分布式表设置的指导。 + +### 保留和 TTL {#retention-and-ttl} + +ClickHouse 使用 [TTL 子句](/use-cases/observability/clickstack/production#configure-ttl) 管理 MergeTree 表的数据过期。 TTL 策略可以: + +- 自动删除过期数据 +- 将旧数据移动到冷对象存储 +- 仅在快速磁盘上保留最近、经常查询的日志 + +我们建议将 ClickHouse 的 TTL 配置与现有的 Elastic 保留策略对齐,以在迁移过程中保持一致的数据生命周期。有关示例,请参见 [ClickStack 生产环境的 TTL 设置](/use-cases/observability/clickstack/production#configure-ttl)。 + +## 迁移数据 {#migrating-data} + +虽然我们建议对大多数可观察性数据采用并行操作,但在某些特定情况下,可能需要直接将数据从 Elasticsearch 迁移到 ClickHouse: + +- 用于数据增强的小型查找表(例如,用户映射、服务目录) +- 存储在 Elasticsearch 中的业务数据,需要与可观察性数据关联,ClickHouse 的 SQL 能力和商业智能集成使得维护和查询该数据比 Elasticsearch 的查询选项更容易。 +- 迁移过程中需要保留的配置数据 + +这种方法只能用于 1000 万行以下的数据集,因为 Elasticsearch 的导出能力仅限于通过 HTTP 导出的 JSON,对于更大的数据集扩展性差。 + +以下步骤允许将单个 Elasticsearch 索引从 ClickHouse 迁移。 + + + +### 迁移架构 {#migrate-scheme} + +为从 Elasticsearch 迁移的索引在 ClickHouse 中创建一个表。用户可以将 [Elasticsearch 类型映射到他们的 ClickHouse](/use-cases/observability/clickstack/migration/elastic/types) 对应类型。或者,用户可以仅依赖 ClickHouse 中的 JSON 数据类型,数据插入时会动态创建适当类型的列。 + +考虑以下包含 `syslog` 数据的 Elasticsearch 映射: + +
+Elasticsearch 映射 + +```javascripton +GET .ds-logs-system.syslog-default-2025.06.03-000001/_mapping +{ + ".ds-logs-system.syslog-default-2025.06.03-000001": { + "mappings": { + "_meta": { + "managed_by": "fleet", + "managed": true, + "package": { + "name": "system" + } + }, + "_data_stream_timestamp": { + "enabled": true + }, + "dynamic_templates": [], + "date_detection": false, + "properties": { + "@timestamp": { + "type": "date", + "ignore_malformed": false + }, + "agent": { + "properties": { + "ephemeral_id": { + "type": "keyword", + "ignore_above": 1024 + }, + "id": { + "type": "keyword", + "ignore_above": 1024 + }, + "name": { + "type": "keyword", + "fields": { + "text": { + "type": "match_only_text" + } + } + }, + "type": { + "type": "keyword", + "ignore_above": 1024 + }, + "version": { + "type": "keyword", + "ignore_above": 1024 + } + } + }, + "cloud": { + "properties": { + "account": { + "properties": { + "id": { + "type": "keyword", + "ignore_above": 1024 + } + } + }, + "availability_zone": { + "type": "keyword", + "ignore_above": 1024 + }, + "image": { + "properties": { + "id": { + "type": "keyword", + "ignore_above": 1024 + } + } + }, + "instance": { + "properties": { + "id": { + "type": "keyword", + "ignore_above": 1024 + } + } + }, + "machine": { + "properties": { + "type": { + "type": "keyword", + "ignore_above": 1024 + } + } + }, + "provider": { + "type": "keyword", + "ignore_above": 1024 + }, + "region": { + "type": "keyword", + "ignore_above": 1024 + }, + "service": { + "properties": { + "name": { + "type": "keyword", + "fields": { + "text": { + "type": "match_only_text" + } + } + } + } + } + } + }, + "data_stream": { + "properties": { + "dataset": { + "type": "constant_keyword", + "value": "system.syslog" + }, + "namespace": { + "type": "constant_keyword", + "value": "default" + }, + "type": { + "type": "constant_keyword", + "value": "logs" + } + } + }, + "ecs": { + "properties": { + "version": { + "type": "keyword", + "ignore_above": 1024 + } + } + }, + "elastic_agent": { + "properties": { + "id": { + "type": "keyword", + "ignore_above": 1024 + }, + "snapshot": { + "type": "boolean" + }, + "version": { + "type": "keyword", + "ignore_above": 1024 + } + } + }, + "event": { + "properties": { + "agent_id_status": { + "type": "keyword", + "ignore_above": 1024 + }, + "dataset": { + "type": "constant_keyword", + "value": "system.syslog" + }, + "ingested": { + "type": "date", + "format": "strict_date_time_no_millis||strict_date_optional_time||epoch_millis", + "ignore_malformed": false + }, + "module": { + "type": "constant_keyword", + "value": "system" + }, + "timezone": { + "type": "keyword", + "ignore_above": 1024 + } + } + }, + "host": { + "properties": { + "architecture": { + "type": "keyword", + "ignore_above": 1024 + }, + "containerized": { + "type": "boolean" + }, + "hostname": { + "type": "keyword", + "ignore_above": 1024 + }, + "id": { + "type": "keyword", + "ignore_above": 1024 + }, + "ip": { + "type": "ip" + }, + "mac": { + "type": "keyword", + "ignore_above": 1024 + }, + "name": { + "type": "keyword", + "ignore_above": 1024 + }, + "os": { + "properties": { + "build": { + "type": "keyword", + "ignore_above": 1024 + }, + "codename": { + "type": "keyword", + "ignore_above": 1024 + }, + "family": { + "type": "keyword", + "ignore_above": 1024 + }, + "kernel": { + "type": "keyword", + "ignore_above": 1024 + }, + "name": { + "type": "keyword", + "fields": { + "text": { + "type": "match_only_text" + } + } + }, + "platform": { + "type": "keyword", + "ignore_above": 1024 + }, + "type": { + "type": "keyword", + "ignore_above": 1024 + }, + "version": { + "type": "keyword", + "ignore_above": 1024 + } + } + } + } + }, + "input": { + "properties": { + "type": { + "type": "keyword", + "ignore_above": 1024 + } + } + }, + "log": { + "properties": { + "file": { + "properties": { + "path": { + "type": "keyword", + "fields": { + "text": { + "type": "match_only_text" + } + } + } + } + }, + "offset": { + "type": "long" + } + } + }, + "message": { + "type": "match_only_text" + }, + "process": { + "properties": { + "name": { + "type": "keyword", + "fields": { + "text": { + "type": "match_only_text" + } + } + }, + "pid": { + "type": "long" + } + } + }, + "system": { + "properties": { + "syslog": { + "type": "object" + } + } + } + } + } + } +} +``` +
+ +相应的 ClickHouse 表结构: + +
+ClickHouse 结构 + +```sql +SET enable_json_type = 1; + +CREATE TABLE logs_system_syslog +( + `@timestamp` DateTime, + `agent` Tuple( + ephemeral_id String, + id String, + name String, + type String, + version String), + `cloud` Tuple( + account Tuple( + id String), + availability_zone String, + image Tuple( + id String), + instance Tuple( + id String), + machine Tuple( + type String), + provider String, + region String, + service Tuple( + name String)), + `data_stream` Tuple( + dataset String, + namespace String, + type String), + `ecs` Tuple( + version String), + `elastic_agent` Tuple( + id String, + snapshot UInt8, + version String), + `event` Tuple( + agent_id_status String, + dataset String, + ingested DateTime, + module String, + timezone String), + `host` Tuple( + architecture String, + containerized UInt8, + hostname String, + id String, + ip Array(Variant(IPv4, IPv6)), + mac Array(String), + name String, + os Tuple( + build String, + codename String, + family String, + kernel String, + name String, + platform String, + type String, + version String)), + `input` Tuple( + type String), + `log` Tuple( + file Tuple( + path String), + offset Int64), + `message` String, + `process` Tuple( + name String, + pid Int64), + `system` Tuple( + syslog JSON) +) +ENGINE = MergeTree +ORDER BY (`host.name`, `@timestamp`) +``` + +
+ +注意: + +- 元组用于表示嵌套结构,而不是点符号 +- 根据映射使用适当的 ClickHouse 类型: + - `keyword` → `String` + - `date` → `DateTime` + - `boolean` → `UInt8` + - `long` → `Int64` + - `ip` → `Array(Variant(IPv4, IPv6))`。我们在这里使用 [`Variant(IPv4, IPv6)`](/sql-reference/data-types/variant),因为该字段包含 [`IPv4`](/sql-reference/data-types/ipv4) 和 [`IPv6`](/sql-reference/data-types/ipv6) 的混合。 + - `object` → `JSON` 用于结构不可预测的 syslog 对象。 +- 列 `host.ip` 和 `host.mac` 是显式的 `Array` 类型,而不是在 Elasticsearch 中所有类型都是数组。 +- 添加了使用时间戳和主机名的 `ORDER BY` 子句,以便于基于时间的查询 +- 用于日志数据的引擎类型是 `MergeTree`,这对于日志数据是最佳选择 + +**这种静态定义架构和选择性使用 JSON 类型的方法 [是推荐的](/integrations/data-formats/json/schema#handling-semi-structured-dynamic-structures)。** + +这种严格的架构有许多好处: + +- **数据验证** – 强制实施严格的架构可以避免在特定结构之外的列爆炸风险。 +- **避免列爆炸的风险**:尽管 JSON 类型可以扩展到潜在数千个列,子列存储为专用列,这可能导致列文件爆炸,生成过多的列文件影响性能。为缓解这个问题,JSON 所使用的底层 [动态类型](/sql-reference/data-types/dynamic) 提供了一个 [`max_dynamic_paths`](/sql-reference/data-types/newjson#reading-json-paths-as-sub-columns) 参数,限制存储为单独列文件的唯一路径数量。一旦达到阈值,额外路径将以紧凑编码格式存储在共享列文件中,从而在保持性能和存储效率的同时支持灵活的数据摄取。不过,访问此共享列文件的性能不佳。请注意,JSON 列可以与 [类型提示](/integrations/data-formats/json/schema#using-type-hints-and-skipping-paths) 一起使用。“提示”列将提供与专用列相同的性能。 +- **简化路径和类型的反查**:尽管 JSON 类型支持 [反查函数](/sql-reference/data-types/newjson#introspection-functions) 来确定已推断的类型和路径,静态结构可以更容易地进行探索,例如使用 `DESCRIBE`。 +
+或者,用户可以简单地创建一个包含一个 `JSON` 列的表。 + +```sql +SET enable_json_type = 1; + +CREATE TABLE syslog_json +( + `json` JSON(`host.name` String, `@timestamp` DateTime) +) +ENGINE = MergeTree +ORDER BY (`json.host.name`, `json.@timestamp`) +``` + +:::note +我们在 JSON 定义中为 `host.name` 和 `timestamp` 列提供了类型提示,因为我们在排序/主键中使用它。这有助于 ClickHouse 知道这个列不会为 null,并确保它知道使用哪个子列(每种类型可能有多个,所以否则会不明确)。 +::: + +后一种方法虽然更简单,但最适合原型和数据工程任务。对于生产环境,仅在必要时对动态子结构使用 `JSON`。 + +有关如何在架构中使用 JSON 类型的更多详细信息,以及如何有效应用它,我们推荐 ["设计您的架构"](/integrations/data-formats/json/schema) 指南。 + +### 安装 `elasticdump` {#install-elasticdump} + +我们推荐使用 [`elasticdump`](https://github.com/elasticsearch-dump/elasticsearch-dump) 从 Elasticsearch 导出数据。该工具需要 `node`,并应安装在与 Elasticsearch 和 ClickHouse 网络接近的机器上。我们建议为大多数导出使用至少 4 核心和 16GB RAM 的专用服务器。 + +```shell +npm install elasticdump -g +``` + +`elasticdump` 在数据迁移中提供了几个优点: + +- 它直接与 Elasticsearch REST API 交互,确保数据导出正确。 +- 在导出过程中使用时间点 (PIT) API 维持数据一致性 - 这会在特定时刻创建数据的一致快照。 +- 将数据直接导出为 JSON 格式,可以流式传输到 ClickHouse 客户端以进行插入。 + +在可能的情况下,我们建议在同一可用区域或数据中心运行 ClickHouse、Elasticsearch 和 `elasticdump`,以最小化网络出口并最大化吞吐量。 + +### 安装 ClickHouse 客户端 {#install-clickhouse-client} + +确保在 `elasticdump` 所在的服务器上 [安装 ClickHouse](/install)。**请勿启动 ClickHouse 服务器** - 这些步骤仅需要客户端。 + +### 流式传输数据 {#stream-data} + +要在 Elasticsearch 和 ClickHouse 之间流式传输数据,请使用 `elasticdump` 命令 - 将输出直接管道到 ClickHouse 客户端。以下示例将数据插入我们结构良好的表 `logs_system_syslog` 中。 + +```shell + +# export url and credentials +export ELASTICSEARCH_INDEX=.ds-logs-system.syslog-default-2025.06.03-000001 +export ELASTICSEARCH_URL= +export ELASTICDUMP_INPUT_USERNAME= +export ELASTICDUMP_INPUT_PASSWORD= +export CLICKHOUSE_HOST= +export CLICKHOUSE_PASSWORD= +export CLICKHOUSE_USER=default + + +# command to run - modify as required +elasticdump --input=${ELASTICSEARCH_URL} --type=data --input-index ${ELASTICSEARCH_INDEX} --output=$ --sourceOnly --searchAfter --pit=true | +clickhouse-client --host ${CLICKHOUSE_HOST} --secure --password ${CLICKHOUSE_PASSWORD} --user ${CLICKHOUSE_USER} --max_insert_block_size=1000 \ +--min_insert_block_size_bytes=0 --min_insert_block_size_rows=1000 --query="INSERT INTO test.logs_system_syslog FORMAT JSONEachRow" +``` + +注意 `elasticdump` 的以下标志: + +- `type=data` - 限制响应仅为 Elasticsearch 中的文档内容。 +- `input-index` - 我们的 Elasticsearch 输入索引。 +- `output=$` - 将所有结果重定向到 stdout。 +- `sourceOnly` 标志确保我们在响应中省略元数据字段。 +- `searchAfter` 标志使用 [`searchAfter` API](https://www.elastic.co/docs/reference/elasticsearch/rest-apis/paginate-search-results#search-after) 有效分页结果。 +- `pit=true` 以确保使用 [时间点 API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-open-point-in-time) 在查询之间获取一致结果。 +
+我们 ClickHouse 客户端的参数(除了凭证): + +- `max_insert_block_size=1000` - ClickHouse 客户端将在达到此行数时发送数据。增加会提高吞吐量,但会增加形成一个块的时间,从而延长数据在 ClickHouse 中出现的时间。 +- `min_insert_block_size_bytes=0` - 关闭按字节进行的服务器块压缩。 +- `min_insert_block_size_rows=1000` - 在服务器端对客户端的块进行压缩。在这种情况下,我们将其设置为 `max_insert_block_size`,因此行会立即出现。增加以提高吞吐量。 +- `query="INSERT INTO logs_system_syslog FORMAT JSONAsRow"` - 将数据插入 [JSONEachRow 格式](/integrations/data-formats/json/other-formats)。如果发送到结构良好的架构,如 `logs_system_syslog`,这非常合适。 +
+**用户可以期望每秒的吞吐量在数千行的数量级。** + +:::note 插入单个 JSON 行 +如果要插入单个 JSON 列(请参见上面的 `syslog_json` 架构),可以使用相同的插入命令。然而,用户必须指定 `JSONAsObject` 作为格式,而不是 `JSONEachRow`,例如: + +```shell +elasticdump --input=${ELASTICSEARCH_URL} --type=data --input-index ${ELASTICSEARCH_INDEX} --output=$ --sourceOnly --searchAfter --pit=true | +clickhouse-client --host ${CLICKHOUSE_HOST} --secure --password ${CLICKHOUSE_PASSWORD} --user ${CLICKHOUSE_USER} --max_insert_block_size=1000 \ +--min_insert_block_size_bytes=0 --min_insert_block_size_rows=1000 --query="INSERT INTO test.logs_system_syslog FORMAT JSONAsObject" +``` + +有关更多详细信息,请参见 ["将 JSON 作为对象读取"](/integrations/data-formats/json/other-formats#reading-json-as-an-object)。 +::: + +### 转换数据(可选) {#transform-data} + +上述命令假设 Elasticsearch 字段与 ClickHouse 列之间存在 1:1 配置。用户通常需要在插入 ClickHouse 之前过滤和转换 Elasticsearch 数据。 + +这可以使用 [`input`](/sql-reference/table-functions/input) 表函数来实现,该函数允许我们在 stdout 上执行任何 `SELECT` 查询。 + +假设我们希望仅存储之前数据中的 `timestamp` 和 `hostname` 字段。 ClickHouse 架构: + +```sql +CREATE TABLE logs_system_syslog_v2 +( + `timestamp` DateTime, + `hostname` String +) +ENGINE = MergeTree +ORDER BY (hostname, timestamp) +``` + +要从 `elasticdump` 插入到该表中,我们可以简单地使用 `input` 表函数 - 使用 JSON 类型动态检测和选择所需列。请注意,此 `SELECT` 查询可以很容易包含过滤条件。 + +```shell +elasticdump --input=${ELASTICSEARCH_URL} --type=data --input-index ${ELASTICSEARCH_INDEX} --output=$ --sourceOnly --searchAfter --pit=true | +clickhouse-client --host ${CLICKHOUSE_HOST} --secure --password ${CLICKHOUSE_PASSWORD} --user ${CLICKHOUSE_USER} --max_insert_block_size=1000 \ +--min_insert_block_size_bytes=0 --min_insert_block_size_rows=1000 --query="INSERT INTO test.logs_system_syslog_v2 SELECT json.\`@timestamp\` as timestamp, json.host.hostname as hostname FROM input('json JSON') FORMAT JSONAsObject" +``` + +请注意需要转义 `@timestamp` 字段名称并使用 `JSONAsObject` 输入格式。 + +
diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/elastic/migrating-data.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/elastic/migrating-data.md.hash new file mode 100644 index 00000000000..785ae5e15af --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/elastic/migrating-data.md.hash @@ -0,0 +1 @@ +311aaf8b5e9e5ef3 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/elastic/migrating-sdks.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/elastic/migrating-sdks.md new file mode 100644 index 00000000000..6b5bc7b9118 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/elastic/migrating-sdks.md @@ -0,0 +1,54 @@ +--- +'slug': '/use-cases/observability/clickstack/migration/elastic/migrating-sdks' +'title': '从 Elastic 迁移 SDKs' +'pagination_prev': null +'pagination_next': null +'sidebar_label': '迁移 SDKs' +'sidebar_position': 6 +'description': '从 Elastic 迁移 SDKs' +'show_related_blogs': true +'keywords': +- 'ClickStack' +'doc_type': 'guide' +--- + +import Image from '@theme/IdealImage'; +import ingestion_key from '@site/static/images/use-cases/observability/ingestion-keys.png'; + +The Elastic Stack 提供两种语言 SDK 用于对应用进行监控: + +1. **[Elastic 官方 APM 代理](https://www.elastic.co/docs/reference/apm-agents/)** – 这些是专门为 Elastic Stack 构建的 SDK。目前尚无直接的迁移路径。使用这些 SDK 的应用需要使用相应的 [ClickStack SDKs](/use-cases/observability/clickstack/sdks) 重新进行监控。 + +2. **[Elastic OpenTelemetry 发行版 (EDOT SDKs)](https://www.elastic.co/docs/reference/opentelemetry/edot-sdks/)** – 这些是 Elastic 的标准 OpenTelemetry SDK 的发行版,支持 .NET、Java、Node.js、PHP 和 Python。如果您的应用已经在使用 EDOT SDK,则无需重新进行监控。相反,您只需重新配置 SDK 以将遥测数据导出到 ClickStack 中包含的 OTLP Collector。有关更多详细信息,请参见 ["迁移 EDOT SDKs"](#migrating-edot-sdks)。 + +:::note 尽量使用 ClickStack SDKs +虽然支持标准的 OpenTelemetry SDK,但我们强烈建议使用每种语言的 [**ClickStack 分发的 SDKs**](/use-cases/observability/clickstack/sdks)。这些发行版包含额外的监控、增强的默认值和设计与 ClickStack 管道和 HyperDX UI 无缝协作的自定义扩展。通过使用 ClickStack SDKs,您可以解锁一些高级功能,例如异常堆栈跟踪,这些在标准的 OpenTelemetry 或 EDOT SDK 中不可用。 +::: + +## 迁移 EDOT SDKs {#migrating-edot-sdks} + +与基于 ClickStack 的 OpenTelemetry SDK 类似,Elastic OpenTelemetry SDK 发行版(EDOT SDKs)是官方 OpenTelemetry SDK 的定制版本。例如,[EDOT Python SDK](https://www.elastic.co/docs/reference/opentelemetry/edot-sdks/python/) 是 [OpenTelemetry Python SDK](https://opentelemetry.io/docs/languages/python/) 的供应商定制分发,旨在与 Elastic Observability 无缝协作。 + +由于这些 SDK 基于标准的 OpenTelemetry 库,迁移到 ClickStack 十分简单 - 无需重新监控。您只需调整配置,将遥测数据指向 ClickStack OpenTelemetry Collector。 + +配置遵循标准的 OpenTelemetry 机制。对于 Python,通常通过环境变量来完成,如 [OpenTelemetry 零代码监控文档](https://opentelemetry.io/docs/zero-code/python/configuration/) 中所述。 + +一个典型的 EDOT SDK 配置可能如下所示: + +```shell +export OTEL_RESOURCE_ATTRIBUTES=service.name= +export OTEL_EXPORTER_OTLP_ENDPOINT=https://my-deployment.ingest.us-west1.gcp.cloud.es.io +export OTEL_EXPORTER_OTLP_HEADERS="Authorization=ApiKey P....l" +``` + +要迁移到 ClickStack,请更新端点以指向本地 OTLP Collector,并更改授权头: + +```shell +export OTEL_RESOURCE_ATTRIBUTES=service.name= +export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318 +export OTEL_EXPORTER_OTLP_HEADERS="authorization=" +``` + +您的数据摄取 API 密钥由 HyperDX 应用生成,可以在团队设置 → API 密钥下找到。 + +数据摄取密钥 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/elastic/migrating-sdks.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/elastic/migrating-sdks.md.hash new file mode 100644 index 00000000000..983e52df7d6 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/elastic/migrating-sdks.md.hash @@ -0,0 +1 @@ +50083fd62ef59937 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/elastic/search.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/elastic/search.md new file mode 100644 index 00000000000..b583d3c8517 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/elastic/search.md @@ -0,0 +1,71 @@ +--- +'slug': '/use-cases/observability/clickstack/migration/elastic/search' +'title': '在 ClickStack 和 Elastic 中搜索' +'pagination_prev': null +'pagination_next': null +'sidebar_label': '搜索' +'sidebar_position': 3 +'description': '在 ClickStack 和 Elastic 中搜索' +'doc_type': 'guide' +--- + +import Image from '@theme/IdealImage'; +import hyperdx_search from '@site/static/images/use-cases/observability/hyperdx-search.png'; +import hyperdx_sql from '@site/static/images/use-cases/observability/hyperdx-sql.png'; + +## 在 ClickStack 和 Elastic 中搜索 {#search-in-clickstack-and-elastic} + +ClickHouse 是一个从底层为高性能分析工作负载设计的 SQL 本地引擎。相比之下,Elasticsearch 提供一种类似 SQL 的接口,将 SQL 转换为基础的 Elasticsearch 查询 DSL — 这意味着它不是一等公民,并且 [功能对等性](https://www.elastic.co/docs/explore-analyze/query-filter/languages/sql-limitations) 有所限制。 + +ClickHouse 不仅支持完整的 SQL,还扩展了一系列以可观察性为中心的功能,例如 [`argMax`](/sql-reference/aggregate-functions/reference/argmax)、[`histogram`](/sql-reference/aggregate-functions/parametric-functions#histogram) 和 [`quantileTiming`](/sql-reference/aggregate-functions/reference/quantiletiming),简化结构化日志、指标和追踪的查询。 + +对于简单的日志和追踪探索,HyperDX 提供一种 [Lucene 风格的语法](/use-cases/observability/clickstack/search),用于直观的基于文本的字段值查询、范围、通配符等。这与 Elasticsearch 中的 [Lucene 语法](https://www.elastic.co/docs/reference/query-languages/query-dsl/query-dsl-query-string-query#query-string-syntax) 和 [Kibana 查询语言](https://www.elastic.co/docs/reference/query-languages/kql) 的某些元素是相似的。 + +搜索 + +HyperDX 的搜索接口支持这种熟悉的语法,但在背后将其转换为高效的 SQL `WHERE` 子句,使 Kibana 用户的体验更加亲切,同时仍允许用户在需要时利用 SQL 的强大功能。这使用户能够充分利用 ClickHouse 中的 [字符串搜索函数](/sql-reference/functions/string-search-functions)、[相似性函数](/sql-reference/functions/string-functions#stringjaccardindex) 和 [日期时间函数](/sql-reference/functions/date-time-functions)。 + +SQL + +下面,我们比较 ClickStack 和 Elasticsearch 的 Lucene 查询语言。 + +## ClickStack 搜索语法与 Elasticsearch 查询字符串 {#hyperdx-vs-elasticsearch-query-string} + +HyperDX 和 Elasticsearch 都提供灵活的查询语言,以实现直观的日志和追踪过滤。虽然 Elasticsearch 的查询字符串与其 DSL 和索引引擎紧密集成,但 HyperDX 支持一种受到 Lucene 启发的语法,在后端转换为 ClickHouse SQL。下表概述了两种系统中常见搜索模式的行为,突出语法之间的相似性和后端执行的差异。 + +| **特性** | **HyperDX 语法** | **Elasticsearch 语法** | **备注** | +|-------------------------|----------------------------------------|----------------------------------------|--------------| +| 自由文本搜索 | `error` | `error` | 在所有索引字段中匹配;在 ClickStack 中,这被重写为多字段 SQL `ILIKE`。 | +| 字段匹配 | `level:error` | `level:error` | 语法完全相同。HyperDX 在 ClickHouse 中匹配确切的字段值。 | +| 短语搜索 | `"disk full"` | `"disk full"` | 引号文本匹配确切序列;ClickHouse 使用字符串相等或 `ILIKE`。 | +| 字段短语匹配 | `message:"disk full"` | `message:"disk full"` | 转换为 SQL `ILIKE` 或精确匹配。 | +| OR 条件 | `error OR warning` | `error OR warning` | 逻辑 OR 术语;两个系统都原生支持此功能。 | +| AND 条件 | `error AND db` | `error AND db` | 均转换为交集;用户语法没有区别。 | +| 否定 | `NOT error` 或 `-error` | `NOT error` 或 `-error` | 否定的支持相同;HyperDX 转换为 SQL `NOT ILIKE`。 | +| 分组 | `(error OR fail) AND db` | `(error OR fail) AND db` | 两者中的标准布尔分组。 | +| 通配符 | `error*` 或 `*fail*` | `error*`, `*fail*` | HyperDX 支持前导/尾随通配符;为了性能,ES 默认禁用前导通配符。术语内的通配符不被支持,例如 `f*ail`。通配符必须与字段匹配一起应用。| +| 范围(数字/日期) | `duration:[100 TO 200]` | `duration:[100 TO 200]` | HyperDX 使用 SQL `BETWEEN`;Elasticsearch 扩展为范围查询。范围中的无界 `*` 不被支持,例如 `duration:[100 TO *]`。如有需要,请使用下面的 `无界范围`。| +| 无界范围(数字/日期) | `duration:>10` 或 `duration:>=10` | `duration:>10` 或 `duration:>=10` | HyperDX 使用标准 SQL 运算符 | +| 包含/排除 | `duration:{100 TO 200}`(排除) | 相同 | 大括号表明排除边界。范围中的 `*` 不被支持。例如 `duration:[100 TO *]`| +| 存在检查 | 不适用 | `_exists_:user` 或 `field:*` | `_exists_` 不被支持。对于 `Map` 列如 `LogAttributes`,使用 `LogAttributes.log.file.path: *`。对于根列,这些列必须存在,如果没有被包含在事件中,则会有默认值。要搜索默认值或缺失列,使用与 Elasticsearch 相同的语法 ` ServiceName:*` 或 `ServiceName != ''`。 | +| 正则匹配 | `match` 函数 | `name:/joh?n(ath[oa]n)/` | 当前在 Lucene 语法中不支持。用户可以使用 SQL 和 [`match`](/sql-reference/functions/string-search-functions#match) 函数或其他 [字符串搜索函数](/sql-reference/functions/string-search-functions)。| +| 模糊匹配 | `editDistance('quikc', field) = 1` | `quikc~` | 当前在 Lucene 语法中不支持。可以在 SQL 中使用距离函数,例如 `editDistance('rror', SeverityText) = 1` 或 [其他相似性函数](/sql-reference/functions/string-functions#jarosimilarity)。 | +| 邻近搜索 | 不支持 | `"fox quick"~5` | 当前在 Lucene 语法中不支持。 | +| 提升 | `quick^2 fox` | `quick^2 fox` | 目前在 HyperDX 中不支持。 | +| 字段通配符 | `service.*:error` | `service.*:error` | 目前在 HyperDX 中不支持。 | +| 转义特殊字符 | 使用 `\` 转义保留字符 | 相同 | 对保留符号需要进行转义。 | + +## 存在/缺失差异 {#empty-value-differences} + +与 Elasticsearch 不同,在 Elasticsearch 中,字段可以完全从事件中省略,因此真正的 “不存在”,ClickHouse 要求表模式中的所有列都必须存在。如果在插入事件中未提供字段: + +- 对于 [`Nullable`](/sql-reference/data-types/nullable) 字段,它将被设置为 `NULL`。 +- 对于非可空字段(默认),它将填充默认值(通常为空字符串、0 或等效)。 + +在 ClickStack 中,我们使用后者,因为 [`Nullable`](/sql-reference/data-types/nullable) [不推荐使用](/optimize/avoid-nullable-columns)。 + +这种行为意味着在 Elasticsearch 意义上检查字段是否“存在”并不直接支持。 + +相反,用户可以使用 `field:*` 或 `field != ''` 来检查非空值的存在。因此,无法区分真正缺失和显式为空的字段。 + +在实践中,这种差异很少导致可观察性用例问题,但在两个系统之间转换查询时,牢记这一点是很重要的。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/elastic/search.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/elastic/search.md.hash new file mode 100644 index 00000000000..1dff4fb6fad --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/elastic/search.md.hash @@ -0,0 +1 @@ +ab8f5e661f971f0d diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/elastic/types.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/elastic/types.md new file mode 100644 index 00000000000..1aa352a752d --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/elastic/types.md @@ -0,0 +1,75 @@ +--- +'slug': '/use-cases/observability/clickstack/migration/elastic/types' +'title': '映射类型' +'pagination_prev': null +'pagination_next': null +'sidebar_label': '类型' +'sidebar_position': 2 +'description': 'ClickHouse 和 Elasticsearch 中的映射类型' +'show_related_blogs': true +'keywords': +- 'JSON' +- 'Codecs' +'doc_type': 'reference' +--- + +Elasticsearch 和 ClickHouse 支持多种数据类型,但它们的底层存储和查询模型是根本不同的。本节将常用的 Elasticsearch 字段类型映射到其对应的 ClickHouse 类型(如适用),并提供上下文来帮助指导迁移。若没有对应的类型,将在注释中提供替代方案或说明。 + +| **Elasticsearch 类型** | **ClickHouse 等效类型** | **注释** | +|-------------------------------|------------------------------|--------------| +| `boolean` | [`UInt8`](/sql-reference/data-types/int-uint) 或 [`Bool`](/sql-reference/data-types/boolean) | ClickHouse 在较新版本中支持将 `Boolean` 作为 `UInt8` 的别名。 | +| `keyword` | [`String`](/sql-reference/data-types/string) | 用于精确匹配过滤、分组和排序。 | +| `text` | [`String`](/sql-reference/data-types/string) | ClickHouse 的全文搜索功能有限;标记化需要使用 `tokens` 函数结合数组函数的自定义逻辑。 | +| `long` | [`Int64`](/sql-reference/data-types/int-uint) | 64 位有符号整数。 | +| `integer` | [`Int32`](/sql-reference/data-types/int-uint) | 32 位有符号整数。 | +| `short` | [`Int16`](/sql-reference/data-types/int-uint) | 16 位有符号整数。 | +| `byte` | [`Int8`](/sql-reference/data-types/int-uint) | 8 位有符号整数。 | +| `unsigned_long` | [`UInt64`](/sql-reference/data-types/int-uint) | 无符号 64 位整数。 | +| `double` | [`Float64`](/sql-reference/data-types/float) | 64 位浮点数。 | +| `float` | [`Float32`](/sql-reference/data-types/float) | 32 位浮点数。 | +| `half_float` | [`Float32`](/sql-reference/data-types/float) 或 [`BFloat16`](/sql-reference/data-types/float) | 最接近的等效类型。ClickHouse 不支持 16 位浮点数。ClickHouse 有一个 `BFloat16` - 这与半浮点数 IEE-754 不同:半浮点数提供更高的精度,但范围较小,而 bfloat16 为了更宽泛的范围而牺牲了精度,使其更适合机器学习工作负载。 | +| `scaled_float` | [`Decimal(x, y)`](/sql-reference/data-types/decimal) | 存储定点数值。 | +| `date` | [`DateTime`](/sql-reference/data-types/datetime) | 精确到秒的等效日期类型。 | +| `date_nanos` | [`DateTime64`](/sql-reference/data-types/datetime64) | ClickHouse 支持以纳秒精度的 `DateTime64(9)`。 | +| `binary` | [`String`](/sql-reference/data-types/string), [`FixedString(N)`](/sql-reference/data-types/fixedstring) | 二进制字段需要进行 base64 解码。 | +| `ip` | [`IPv4`](/sql-reference/data-types/ipv4), [`IPv6`](/sql-reference/data-types/ipv6) | 提供原生的 `IPv4` 和 `IPv6` 类型。 | +| `object` | [`Nested`](/sql-reference/data-types/nested-data-structures/nested), [`Map`](/sql-reference/data-types/map), [`Tuple`](/sql-reference/data-types/tuple), [`JSON`](/sql-reference/data-types/newjson) | ClickHouse 可以使用 [`Nested`](/sql-reference/data-types/nested-data-structures/nested) 或 [`JSON`](/sql-reference/data-types/newjson) 模拟类似 JSON 的对象。 | +| `flattened` | [`String`](/sql-reference/data-types/string) | Elasticsearch 中的扁平化类型将整个 JSON 对象存储为单个字段,从而允许灵活、无模式的访问嵌套键,而无需完整映射。在 ClickHouse 中,可以使用 String 类型实现类似的功能,但需要在物化视图中进行处理。 | +| `nested` | [`Nested`](/sql-reference/data-types/nested-data-structures/nested) | ClickHouse 的 `Nested` 列提供了类似的语义,用于分组子字段,假设用户使用 `flatten_nested=0`。 | +| `join` | NA | 没有直接的父子关系概念。在 ClickHouse 中不需要,因为支持跨表连接。 | +| `alias` | [`Alias`](/sql-reference/statements/create/table#alias) 列修饰符 | 别名 [受到支持](/sql-reference/statements/create/table#alias),可以通过字段修饰符使用。可以对这些别名应用函数,例如 `size String ALIAS formatReadableSize(size_bytes)` | +| `range` types (`*_range`) | [`Tuple(start, end)`](/sql-reference/data-types/tuple) 或 [`Array(T)`](/sql-reference/data-types/array) | ClickHouse 没有原生范围类型,但可以使用 [`Tuple(start, end)`](/sql-reference/data-types/tuple) 或 [`Array`](/sql-reference/data-types/array) 结构表示数值和日期范围。对于 IP 范围 (`ip_range`),将 CIDR 值存储为 `String` 并使用像 `isIPAddressInRange()` 的函数进行评估。或者,可以考虑使用 `ip_trie` 基于查找字典进行高效过滤。 | +| `aggregate_metric_double` | [`AggregateFunction(...)`](/sql-reference/data-types/aggregatefunction) 和 [`SimpleAggregateFunction(...)`](/sql-reference/data-types/simpleaggregatefunction) | 使用汇聚函数状态和物化视图来建模预汇聚指标。所有聚合函数都支持聚合状态。| +| `histogram` | [`Tuple(Array(Float64), Array(UInt64))`](/sql-reference/data-types/tuple) | 使用数组或自定义模式手动表示桶和计数。 | +| `annotated-text` | [`String`](/sql-reference/data-types/string) | 不支持实体感知搜索或注释的内置支持。 | +| `completion`, `search_as_you_type` | NA | 没有原生的自动完成或建议引擎。可以通过 `String` 和 [搜索函数](/sql-reference/functions/string-search-functions) 来重现。 | +| `semantic_text` | NA | 没有原生的语义搜索 - 生成嵌入并使用向量搜索。 | +| `token_count` | [`Int32`](/sql-reference/data-types/int-uint) | 在数据摄取过程中使用,以手动计算标记计数,例如 `length(tokens())`,例如使用物化列 | +| `dense_vector` | [`Array(Float32)`](/sql-reference/data-types/array) | 使用数组存储嵌入 | +| `sparse_vector` | [`Map(UInt32, Float32)`](/sql-reference/data-types/map) | 使用映射模拟稀疏向量。不支持原生稀疏向量。 | +| `rank_feature` / `rank_features` | [`Float32`](/sql-reference/data-types/float), [`Array(Float32)`](/sql-reference/data-types/array) | 没有原生的查询时间加权,但可以在评分逻辑中手动建模。 | +| `geo_point` | [`Tuple(Float64, Float64)`](/sql-reference/data-types/tuple) 或 [`Point`](/sql-reference/data-types/geo#point) | 使用 (纬度, 经度) 的元组。[`Point`](/sql-reference/data-types/geo#point) 作为 ClickHouse 类型可用。 | +| `geo_shape`, `shape` | [`Ring`](/sql-reference/data-types/geo#ring), [`LineString`](/sql-reference/data-types/geo#linestring), [`MultiLineString`](/sql-reference/data-types/geo#multilinestring), [`Polygon`](/sql-reference/data-types/geo#polygon), [`MultiPolygon`](/sql-reference/data-types/geo#multipolygon) | 原生支持地理形状和空间索引。 | +| `percolator` | NA | 没有索引查询的概念。使用标准 SQL + 增量物化视图代替。 | +| `version` | [`String`](/sql-reference/data-types/string) | ClickHouse 没有原生的版本类型。将版本作为字符串存储,并在需要时使用自定义 UDF 函数执行语义比较。如果需要范围查询,考虑标准化为数字格式。 | + +### 注释 {#notes} + +- **数组**:在 Elasticsearch 中,所有字段原生支持数组。在 ClickHouse 中,数组必须显式定义(例如,`Array(String)`),其优势在于可以访问和查询特定位置,例如 `an_array[1]`。 +- **多字段**:Elasticsearch 允许以 [多种方式对相同字段进行索引](https://www.elastic.co/docs/reference/elasticsearch/mapping-reference/multi-fields#_multi_fields_with_multiple_analyzers)(例如,`text` 和 `keyword`)。在 ClickHouse 中,此模式必须通过单独的列或视图建模。 +- **Map 和 JSON 类型** - 在 ClickHouse 中,[`Map`](/sql-reference/data-types/map) 类型常用于建模动态键值结构,例如 `resourceAttributes` 和 `logAttributes`。此类型通过允许在运行时添加任意键来实现无模式的灵活摄取 - 在精神上与 Elasticsearch 中的 JSON 对象类似。然而,有几个重要的限制需要考虑: + + - **统一值类型**:ClickHouse [`Map`](/sql-reference/data-types/map) 列必须具有一致的值类型(例如,`Map(String, String)`)。不支持混合类型值,除非进行强制转换。 + - **性能成本**:访问 [`Map`](/sql-reference/data-types/map) 中的任何键都需要将整个映射加载到内存中,这可能会对性能产生不利影响。 + - **没有子列**:与 JSON 不同,[`Map`](/sql-reference/data-types/map) 中的键并不表示真实的子列,这限制了 ClickHouse 在编制索引、压缩和高效查询方面的能力。 + + 鉴于这些限制,ClickStack 正在从 [`Map`](/sql-reference/data-types/map) 迁移到 ClickHouse 加强版的 [`JSON`](/sql-reference/data-types/newjson) 类型。[`JSON`](/sql-reference/data-types/newjson) 类型解决了 `Map` 的许多缺点: + + - **真正的列式存储**:每个 JSON 路径作为子列存储,允许高效的压缩、过滤和向量化查询执行。 + - **混合类型支持**:不同的数据类型(例如,整数、字符串、数组)可以在同一路径下共存,而无需强制转换或类型统一。 + - **文件系统可扩展性**:动态键(`max_dynamic_paths`)和类型(`max_dynamic_types`)的内部限制防止了列文件在磁盘上的爆炸,即使具有高基数的键集也如此。 + - **密集存储**:空值和缺失值被稀疏存储以避免不必要的开销。 + + [`JSON`](/sql-reference/data-types/newjson) 类型特别适合可观察性工作负载,提供了无模式摄取的灵活性,以及本地 ClickHouse 类型的性能和可扩展性 - 使其成为动态属性字段中 [`Map`](/sql-reference/data-types/map) 的理想替代品。 + + 有关 JSON 类型的进一步详细信息,我们建议参阅 [JSON 指南](https://clickhouse.com/docs/integrations/data-formats/json/overview) 和 ["我们是如何为 ClickHouse 构建一种新的强大的 JSON 数据类型的"](https://clickhouse.com/blog/a-new-powerful-json-data-type-for-clickhouse)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/elastic/types.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/elastic/types.md.hash new file mode 100644 index 00000000000..788081f9cf6 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/elastic/types.md.hash @@ -0,0 +1 @@ +a1a15ebe196ee1b4 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/index.md new file mode 100644 index 00000000000..270e05baaef --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/index.md @@ -0,0 +1,15 @@ +--- +'slug': '/use-cases/observability/clickstack/migration' +'title': '从其他可观察性解决方案迁移到 ClickStack' +'pagination_prev': null +'pagination_next': null +'sidebar_label': '迁移指南' +'description': '从其他可观察性解决方案迁移到 ClickStack' +'doc_type': 'guide' +--- + +该部分提供了从各种可观察性解决方案迁移到 ClickStack 的全面指南。每个指南都包含详细的说明,指导您在保持操作持续性的同时过渡数据、代理和工作流程。 + +| 技术 | 描述 | +|------------|-------------| +| [Elastic Stack](/use-cases/observability/clickstack/migration/elastic) | 完整的指南,涵盖从 Elastic Stack 迁移到 ClickStack 的数据迁移、代理过渡和搜索功能 | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/index.md.hash new file mode 100644 index 00000000000..9fdd4cba661 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/migration/index.md.hash @@ -0,0 +1 @@ +449b2887db5a5378 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/overview.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/overview.md index 175843e650d..bcbab841be7 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/overview.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/overview.md @@ -1,97 +1,100 @@ --- 'slug': '/use-cases/observability/clickstack/overview' -'title': 'ClickStack - ClickHouse 观察堆栈' +'title': 'ClickStack - The ClickHouse 可观察性栈' 'sidebar_label': '概述' 'pagination_prev': null 'pagination_next': 'use-cases/observability/clickstack/getting-started' -'description': '关于 ClickStack - ClickHouse 观察堆栈的概述' +'description': 'ClickStack - The ClickHouse 可观察性栈的概述' +'doc_type': 'guide' --- import Image from '@theme/IdealImage'; import architecture from '@site/static/images/use-cases/observability/clickstack-simple-architecture.png'; import landing_image from '@site/static/images/use-cases/observability/hyperdx-landing.png'; -Landing page +首页 -**ClickStack** 是一个基于 ClickHouse 的生产级可观察性平台,将日志、跟踪、指标和会话统一为一个高性能的解决方案。它旨在监控和调试复杂系统,使开发人员和 SRE 能够端到端地追踪问题,而无需在工具之间切换或手动使用时间戳或关联 ID 拼接数据。 +**ClickStack** 是一个基于 ClickHouse 构建的生产级可观察性平台,将日志、追踪、指标和会话统一在一个高性能解决方案中。ClickStack 旨在监控和调试复杂系统,使开发人员和 SRE 能够在不切换工具或手动使用时间戳或关联 ID 拼接数据的情况下端到端地追踪问题。 -ClickStack 的核心是一个简单而强大的理念:所有可观察性数据都应该作为宽广、丰富的事件进行摄取。这些事件按数据类型存储在 ClickHouse 表中——日志、跟踪、指标和会话——但在数据库层面上仍然可以完全查询和交叉关联。 +ClickStack 的核心是一个简单但强大的理念:所有可观察性数据应以宽、丰富的事件形式进行摄取。这些事件按数据类型存储在 ClickHouse 表中——日志、追踪、指标和会话——但在数据库级别仍然是完全可查询和可交叉关联的。 -ClickStack 通过利用 ClickHouse 的列式架构、本地 JSON 支持和完全并行的执行引擎,能够高效处理高基数工作负载。这使得对大数据集进行亚秒查询、快速的广时间范围聚合和对单个跟踪的深度检查成为可能。JSON 以压缩的列式格式存储,允许架构演变而无需手动干预或预先定义。 +ClickStack 构建于 ClickHouse 的列式架构、原生 JSON 支持和完全并行化的执行引擎之上,能够高效处理高基数工作负载。这使得在大规模数据集上的查询时间在毫秒级,快速聚合跨越宽时间范围,深入检查单个追踪成为可能。JSON 以压缩的列式格式存储,允许模式演变而无需手动干预或预先定义。 ## 特性 {#features} -该堆栈包括几个旨在调试和根本原因分析的关键特性: +这个堆栈包含几个关键特性,旨在用于调试和根本原因分析: -- 在一个地方关联/搜索日志、指标、会话重放和跟踪 -- 无架构依赖,适用于现有的 ClickHouse 架构 -- 针对 ClickHouse 优化的超快速搜索和可视化 -- 直观的全文搜索和属性搜索语法(如 `level:err`),SQL 可选! -- 分析异常中的趋势和事件差异 +- 关联/搜索日志、指标、会话回放和追踪,所有内容集中在一个地方 +- 与模式无关,适用于现有的 ClickHouse 模式 +- 针对 ClickHouse 优化的闪电般快速的搜索与可视化 +- 直观的全文搜索和属性搜索语法(例如 `level:err`),SQL 可选 +- 通过事件增量分析异常趋势 - 只需几次点击即可设置警报 -- 在没有复杂查询语言的情况下仪表盘高基数事件 -- 本地 JSON 字符串查询 -- 实时获取最新事件的日志和跟踪 +- 在不复杂查询语言的情况下高效展示高基数事件 +- 原生 JSON 字符串查询 +- 实时尾随日志和追踪,以始终获取最新事件 - 开箱即用的 OpenTelemetry (OTel) 支持 -- 监控从 HTTP 请求到数据库查询的健康和性能(APM) -- 用于识别异常和性能回归的事件差异 +- 从 HTTP 请求到数据库查询(APM)监控健康和性能 +- 用于识别异常和性能回归的事件增量 - 日志模式识别 ## 组件 {#components} ClickStack 由三个核心组件组成: -1. **HyperDX UI** – 专为探索和可视化可观察性数据而设计的前端 -2. **OpenTelemetry collector** – 一个定制构建的、预配置的收集器,具有针对日志、跟踪和指标的立场导向架构 +1. **HyperDX UI** – 旨在探索和可视化可观察性数据的专用前端 +2. **OpenTelemetry collector** – 预配置的自定义收集器,具有用于日志、追踪和指标的意见化模式 3. **ClickHouse** – 堆栈核心的高性能分析数据库 -这些组件可以独立或一起部署。同时,还提供浏览器托管的 HyperDX UI 版本,允许用户在没有额外基础设施的情况下连接到现有的 ClickHouse 部署。 +这些组件可以独立或一起部署。HyperDX UI 还提供浏览器托管版本,允许用户连接到现有的 ClickHouse 部署,而无需额外的基础设施。 -要开始使用,请访问 [入门指南](/use-cases/observability/clickstack/getting-started),然后加载 [示例数据集](/use-cases/observability/clickstack/sample-datasets)。您还可以查阅 [部署选项](/use-cases/observability/clickstack/deployment) 和 [生产最佳实践](/use-cases/observability/clickstack/production) 的文档。 +要开始使用,请访问 [入门指南](/use-cases/observability/clickstack/getting-started),然后加载 [示例数据集](/use-cases/observability/clickstack/sample-datasets)。您还可以查看有关 [部署选项](/use-cases/observability/clickstack/deployment) 和 [生产最佳实践](/use-cases/observability/clickstack/production) 的文档。 ## 原则 {#clickstack-principles} -ClickStack 是根据一组核心原则设计的,这些原则优先考虑可观察性堆栈每一层的易用性、性能和灵活性: +ClickStack 的设计遵循一套核心原则,以优先考虑易用性、性能和灵活性,贯穿可观察性堆栈的每一层: -### 数分钟内轻松设置 {#clickstack-easy-to-setup} +### 几分钟内轻松设置 {#clickstack-easy-to-setup} -ClickStack 与任何 ClickHouse 实例和架构开箱即用,所需配置最少。无论您是全新启动还是与现有设置集成,您都可以在几分钟内启动和运行。 +ClickStack 可以与任何 ClickHouse 实例和模式开箱即用,所需配置极少。无论您是从零开始还是与现有设置集成,都可以在几分钟内启动并运行。 -### 用户友好且专用 {#user-friendly-purpose-built} +### 用户友好,专为目的而建 {#user-friendly-purpose-built} -HyperDX UI 同时支持 SQL 和 Lucene 风格的语法,让用户可以选择适合其工作流程的查询接口。专为可观察性而构建,UI 被优化为帮助团队快速识别根本原因,并轻松浏览复杂数据。 +HyperDX UI 支持 SQL 和 Lucene 风格语法,允许用户选择适合其工作流的查询接口。专为可观察性设计,UI 优化为帮助团队快速识别根本原因,并无缝导航复杂的数据。 ### 端到端可观察性 {#end-to-end-observability} -ClickStack 提供全栈可见性,从前端用户会话到后端基础设施指标、应用程序日志和分布式跟踪。这种统一视图使整个系统的深度关联和分析成为可能。 +ClickStack 提供全面的可见度,从前端用户会话到后端基础设施指标、应用程序日志和分布式追踪。此统一视图实现了整个系统的深度关联和分析。 -### 为 ClickHouse 构建 {#built-for-clickhouse} +### 为 ClickHouse 而建 {#built-for-clickhouse} -堆栈的每一层都旨在充分发挥 ClickHouse 的能力。查询经过优化以利用 ClickHouse 的分析函数和列式引擎,确保在海量数据上快速搜索和聚合。 +堆栈的每一层都旨在充分利用 ClickHouse 的能力。查询经过优化,以利用 ClickHouse 的分析函数和列式引擎,确保在大规模数据上快速搜索和聚合。 -### 原生支持 OpenTelemetry {#open-telemetry-native} +### 原生 OpenTelemetry {#open-telemetry-native} -ClickStack 与 OpenTelemetry 原生集成,通过 OpenTelemetry 收集器端点摄取所有数据。对于高级用户,它还支持使用本地文件格式、自定义管道或第三方工具(如 Vector)直接摄取到 ClickHouse。 +ClickStack 与 OpenTelemetry 原生集成,通过 OpenTelemetry collector 端点摄取所有数据。对于高级用户,它还支持使用原生文件格式、自定义管道或像 Vector 这样的第三方工具直接摄取到 ClickHouse。 ### 开源且完全可定制 {#open-source-and-customizable} -ClickStack 完全开源,可以在任何地方部署。架构灵活且可用户修改,UI 被设计为可配置到自定义架构,无需更改。所有组件——包括收集器、ClickHouse 及 UI - 都可以独立扩展,以满足摄取、查询或存储需求。 +ClickStack 完全开源,可以部署在任何地方。模式灵活且可用户修改,UI 可以配置为与自定义模式兼容,无需更改。所有组件——包括收集器、ClickHouse 和 UI——都可以独立扩展,以满足摄取、查询或存储需求。 ## 架构概述 {#architectural-overview} -Simple architecture +简单架构 ClickStack 由三个核心组件组成: 1. **HyperDX UI** - 一个用户友好的界面,专为可观察性而构建。它支持 Lucene 风格和 SQL 查询、交互式仪表板、警报、跟踪探索等——所有这些都针对 ClickHouse 作为后端进行了优化。 + 一个用户友好的可观察性界面。它支持 Lucene 风格和 SQL 查询、交互式仪表板、警报、追踪探索等——全部优化 ClickHouse 作为后端。 2. **OpenTelemetry collector** - 一个定制构建的收集器,配置有针对 ClickHouse 摄取优化的立场导向架构。它通过 OpenTelemetry 协议接收日志、指标和跟踪,并使用高效的批量插入直接写入 ClickHouse。 + 一个自定义构建的收集器,配置了针对 ClickHouse 摄取优化的意见化模式。它通过 OpenTelemetry 协议接收日志、指标和追踪,并使用高效的批量插入直接写入 ClickHouse。 3. **ClickHouse** - 高性能分析数据库,作为宽广事件的中央数据存储。ClickHouse 利用其列式引擎和对 JSON 的本地支持,强大驱动快速搜索、过滤和大规模聚合。 + 作为宽事件中心数据存储的高性能分析数据库。ClickHouse 利用其列式引擎和原生支持 JSON,实现快速搜索、过滤和大规模聚合。 -除了这三个组件,ClickStack 还使用 **MongoDB 实例** 来存储应用状态,例如仪表板、用户帐户和配置设置。 +除了这三个组件,ClickStack 还使用 **MongoDB 实例** 存储应用程序状态,如仪表板、用户帐户和配置设置。 完整的架构图和部署细节可以在 [架构部分](/use-cases/observability/clickstack/architecture) 找到。 + +对于有兴趣将 ClickStack 部署到生产环境的用户,我们建议阅读 ["生产指南"](/use-cases/observability/clickstack/production)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/overview.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/overview.md.hash index 46965b592bc..e84ee3cd113 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/overview.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/overview.md.hash @@ -1 +1 @@ -5e7d0a136da76ef2 +7143b498ed6c9d35 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/production.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/production.md index 3a3518addf0..79e0dfc05e2 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/production.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/production.md @@ -1,10 +1,11 @@ --- 'slug': '/use-cases/observability/clickstack/production' -'title': '进入生产环境' +'title': '投入生产' 'sidebar_label': '生产' 'pagination_prev': null 'pagination_next': null -'description': '与 ClickStack 一起进入生产环境' +'description': '使用 ClickStack 投入生产' +'doc_type': 'guide' --- import Image from '@theme/IdealImage'; @@ -13,15 +14,15 @@ import hyperdx_cloud from '@site/static/images/use-cases/observability/hyperdx-c import ingestion_key from '@site/static/images/use-cases/observability/ingestion-keys.png'; import hyperdx_login from '@site/static/images/use-cases/observability/hyperdx-login.png'; -When deploying ClickStack in production, there are several additional considerations to ensure security, stability, and correct configuration. +当在生产环境中部署 ClickStack 时,还有几个额外的考虑因素,以确保安全性、稳定性和正确配置。 -## Network and Port Security {#network-security} +## 网络和端口安全 {#network-security} -通过默认设置,Docker Compose 会在主机上暴露端口,使它们可以从容器外部访问 - 即使启用了像 `ufw` (Uncomplicated Firewall) 这样的工具。 此行为是由于 Docker 网络堆栈,在未明确配置的情况下可以绕过主机级防火墙规则。 +默认情况下,Docker Compose 在主机上暴露端口,使其可以从容器外部访问——即使像 `ufw`(简单防火墙)这样的工具已启用。这种行为是由于 Docker 网络堆栈,它可以绕过主机级防火墙规则,除非明确配置。 -**建议:** +**推荐:** -仅暴露生产使用所需的端口。通常包括 OTLP 端点、API 服务器和前端。 +只暴露实际用于生产的端口。通常为 OTLP 端点、API 服务器和前端。 例如,在 `docker-compose.yml` 文件中移除或注释掉不必要的端口映射: @@ -34,13 +35,13 @@ ports: # Avoid exposing internal ports like ClickHouse 8123 or MongoDB 27017. ``` -有关隔离容器和加强访问控制的详细信息,请参阅 [Docker networking documentation](https://docs.docker.com/network/)。 +有关隔离容器和增强访问控制的详细信息,请参阅 [Docker 网络文档](https://docs.docker.com/network/)。 -## Session Secret Configuration {#session-secret} +## 会话密钥配置 {#session-secret} -在生产环境中,必须为 `EXPRESS_SESSION_SECRET` 环境变量设置一个强大且随机的值,以保护会话数据并防止篡改。 +在生产中,您必须为 `EXPRESS_SESSION_SECRET` 环境变量设置一个强大且随机的值,以保护会话数据并防止篡改。 -以下是如何将其添加到您的应用服务 `docker-compose.yml` 文件中的示例: +以下是如何将其添加到应用服务的 `docker-compose.yml` 文件中的方法: ```yaml app: @@ -68,96 +69,100 @@ app: - db1 ``` -您可以使用 openssl 生成强密钥: +您可以使用 openssl 生成一个强大的密钥: -```bash +```shell openssl rand -hex 32 ``` -避免将密钥提交到源代码控制。 在生产中,考虑使用环境变量管理工具(例如 Docker Secrets、HashiCorp Vault 或特定于环境的 CI/CD 配置)。 +避免将秘密提交到源代码控制中。在生产中,考虑使用环境变量管理工具(例如 Docker Secrets、HashiCorp Vault 或特定环境的 CI/CD 配置)。 -## Secure ingestion {#secure-ingestion} +## 安全数据接收 {#secure-ingestion} -所有数据摄取都应通过 ClickStack 的 OpenTelemetry (OTel) 收集器暴露的 OTLP 端口进行。默认情况下,这需要在启动时生成一个安全的摄取 API 密钥。此密钥在将数据发送到 OTel 端口时是必需的,可以在 HyperDX UI 下的 `Team Settings → API Keys` 找到。 +所有数据接收应通过 ClickStack 分发的 OpenTelemetry(OTel)收集器公开的 OTLP 端口进行。默认情况下,这需要在启动时生成一个安全接收 API 密钥。在将数据发送到 OTel 端口时需要此密钥,可以在 HyperDX UI 中的 `团队设置 → API 密钥` 下找到。 -Ingestion keys +接收密钥 -此外,我们建议为 OTLP 端点启用 TLS 并创建一个 [dedicated user for ClickHouse ingestion](#database-ingestion-user)。 +此外,我们建议为 OTLP 端点启用 TLS,并创建一个 [点击量接收用户](#database-ingestion-user)。 ## ClickHouse {#clickhouse} -对于生产部署,我们建议使用 [ClickHouse Cloud](https://clickhouse.com/cloud),它默认采用行业标准的 [security practices](/cloud/security) - 包括 [enhanced encryption](/cloud/security/cmek)、[authentication and connectivity](/cloud/security/connectivity) 和 [managed access controls](/cloud/security/cloud-access-management)。请参阅 ["ClickHouse Cloud"](#clickhouse-cloud-production) 获取使用 ClickHouse Cloud 和最佳实践的分步指南。 +对于生产部署,我们建议使用 [ClickHouse Cloud](https://clickhouse.com/cloud),默认应用行业标准的 [安全实践](/cloud/security/shared-responsibility-model)——包括 [增强加密](/cloud/security/cmek)、[身份验证和连接](/cloud/security/connectivity)以及 [托管访问控制](/cloud/security/cloud-access-management)。有关使用 ClickHouse Cloud 的逐步指南,请参见 ["ClickHouse Cloud"](#clickhouse-cloud-production)。 -### User Permissions {#user-permissions} +### 用户权限 {#user-permissions} -#### HyperDX user {#hyperdx-user} +#### HyperDX 用户 {#hyperdx-user} -HyperDX 的 ClickHouse 用户只需是一个 `readonly` 用户,并且能够更改以下设置: +HyperDX 的 ClickHouse 用户只需是一个具有访问以下设置权限的 `readonly` 用户: -- `max_rows_to_read`(至少达到 100 万) +- `max_rows_to_read`(至少为 100 万) - `read_overflow_mode` - `cancel_http_readonly_queries_on_client_close` - `wait_end_of_query` -在 OSS 和 ClickHouse Cloud 中,默认用户 `default` 将具备这些权限,但我们建议您创建一个具有这些权限的新用户。 +默认情况下,OSS 和 ClickHouse Cloud 中的 `default` 用户将拥有这些权限,但我们建议您创建一个具有这些权限的新用户。 -#### Database and ingestion user {#database-ingestion-user} +#### 数据库和接收用户 {#database-ingestion-user} -我们建议为 OTel 收集器创建一个专用用户,以便向 ClickHouse 进行摄取并确保数据发送到特定数据库,例如 `otel`。有关更多细节,请参阅 ["Creating an ingestion user"](/use-cases/observability/clickstack/ingesting-data/otel-collector#creating-an-ingestion-user)。 +我们建议为 OTel 收集器创建一个专用用户,用于将数据接入 ClickHouse,并确保数据发送到特定数据库,例如 `otel`。有关详细信息,请参见 ["创建接收用户"](/use-cases/observability/clickstack/ingesting-data/otel-collector#creating-an-ingestion-user)。 -### Self-managed security {#self-managed-security} +### 自管理安全 {#self-managed-security} -如果您管理自己的 ClickHouse 实例,启用 **SSL/TLS**、强制身份验证,并遵循加强访问控制的最佳实践是至关重要的。请参阅 [this blog post](https://www.wiz.io/blog/clickhouse-and-wiz) 了解有关实际错误配置及如何避免它们的背景信息。 +如果您管理自己的 ClickHouse 实例,则必须启用 **SSL/TLS**,强制身份验证,并遵循增强访问的最佳实践。有关真实世界误配置的上下文信息以及如何避免它们,请参见 [这篇博客文章](https://www.wiz.io/blog/clickhouse-and-wiz)。 -ClickHouse OSS 提供了强大的安全功能,但需要配置: +ClickHouse OSS 提供了开箱即用的强大安全功能。然而,这些需要配置: -- 通过 `tcp_port_secure` 和 `` 在 `config.xml` 中 **使用 SSL/TLS**。请参阅 [guides/sre/configuring-ssl](/guides/sre/configuring-ssl)。 -- 为 `default` 用户 **设置强密码** 或禁用它。 -- **避免外部暴露 ClickHouse**,除非明确打算。默认情况下,ClickHouse 仅绑定到 `localhost`,除非修改 `listen_host`。 -- 使用如密码、证书、SSH 密钥或 [external authenticators](/operations/external-authenticators) 等 **身份验证方法**。 -- 使用 IP 过滤和 `HOST` 子句 **限制访问**。请参阅 [sql-reference/statements/create/user#user-host](/sql-reference/statements/create/user#user-host)。 -- 启用 **基于角色的访问控制 (RBAC)** 以授予细粒度权限。请参阅 [operations/access-rights](/operations/access-rights)。 -- 使用 [quotas](/operations/quotas)、[settings profiles](/operations/settings/settings-profiles) 和只读模式 **强制执行配额和限制**。 +- **通过 `tcp_port_secure` 和 `` 使用 SSL/TLS** 在 `config.xml` 中。请参阅 [guides/sre/configuring-ssl](/guides/sre/configuring-ssl)。 +- **为 `default` 用户设置强密码** 或禁用密码。 +- **避免将 ClickHouse 公开**,除非明确打算。默认情况下,ClickHouse 仅绑定到 `localhost`,除非修改 `listen_host`。 +- **使用身份验证方法**,例如密码、证书、SSH 密钥或 [外部身份验证程序](/operations/external-authenticators)。 +- **使用 IP 过滤和 `HOST` 子句限制访问**。请参阅 [sql-reference/statements/create/user#user-host](/sql-reference/statements/create/user#user-host)。 +- **启用基于角色的访问控制 (RBAC)** 授予细粒度权限。请参阅 [operations/access-rights](/operations/access-rights)。 +- **实施配额和限制**,使用 [quotas](/operations/quotas)、[settings profiles](/operations/settings/settings-profiles) 和只读模式。 - **加密静态数据** 并使用安全外部存储。请参阅 [operations/storing-data](/operations/storing-data) 和 [cloud/security/CMEK](/cloud/security/cmek)。 -- **避免硬编码凭证。** 在 ClickHouse Cloud 中使用 [named collections](/operations/named-collections) 或 IAM 角色。 -- 使用 [system logs](/operations/system-tables/query_log) 和 [session logs](/operations/system-tables/session_log) **审计访问和查询**。 +- **避免硬编码凭据。** 使用 [named collections](/operations/named-collections) 或 ClickHouse Cloud 中的 IAM 角色。 +- **使用 [system logs](/operations/system-tables/query_log) 和 [session logs](/operations/system-tables/session_log) 审计访问和查询**。 -另请参见 [external authenticators](/operations/external-authenticators) 和 [query complexity settings](/operations/settings/query-complexity) 以管理用户并确保查询/资源限制。 +有关管理用户和确保查询/资源限制的更多信息,请参见 [external authenticators](/operations/external-authenticators) 和 [query complexity settings](/operations/settings/query-complexity)。 -## MongoDB Guidelines {#mongodb-guidelines} +### 配置生存时间 (TTL) {#configure-ttl} -遵循官方 [MongoDB security checklist](https://www.mongodb.com/docs/manual/administration/security-checklist/)。 +确保 [生存时间 (TTL)](/use-cases/observability/clickstack/ttl) 已为您的 ClickStack 部署 [正确配置](/use-cases/observability/clickstack/ttl#modifying-ttl)。这控制数据保留的时间——默认值为 3 天,通常需要修改。 + +## MongoDB 指南 {#mongodb-guidelines} + +遵循官方的 [MongoDB 安全检查清单](https://www.mongodb.com/docs/manual/administration/security-checklist/)。 ## ClickHouse Cloud {#clickhouse-cloud-production} -以下是使用 ClickHouse Cloud 的 ClickStack 简单部署,它符合最佳实践。 +以下代表使用 ClickHouse Cloud 的 ClickStack 简单部署,符合最佳实践。 -### Create a service {#create-a-service} +### 创建服务 {#create-a-service} -遵循 [getting started guide for ClickHouse Cloud](/cloud/get-started/cloud-quick-start#1-create-a-clickhouse-service) 创建服务。 +请遵循 [ClickHouse Cloud 的入门指南](/getting-started/quick-start/cloud/#1-create-a-clickhouse-service) 创建服务。 -### Copy connection details {#copy-connection-details} +### 复制连接详情 {#copy-connection-details} -要找到 HyperDX 的连接详细信息,请导航到 ClickHouse Cloud 控制台并单击侧边栏的 Connect 按钮,记录具体的 HTTP 连接详细信息,特别是 url。 +要查找 HyperDX 的连接详情,请导航到 ClickHouse Cloud 控制台,并单击侧边栏上的 连接 按钮,记录 HTTP 连接详情,特别是 URL。 -**虽然您可以使用此步骤中显示的默认用户名和密码来连接 HyperDX,但我们建议创建一个专用用户 - 请参见下文** +**虽然您可以使用此步骤中显示的默认用户名和密码连接 HyperDX,但我们建议创建一个专用用户 - 见下文** -Connect Cloud +连接云 -### Create a HyperDX user {#create-a-user} +### 创建 HyperDX 用户 {#create-a-user} -我们建议您为 HyperDX 创建一个专用用户。在 [Cloud SQL console](/cloud/get-started/sql-console) 中运行以下 SQL 命令,提供符合复杂性要求的安全密码: +我们建议您为 HyperDX 创建一个专用用户。在 [Cloud SQL 控制台](/cloud/get-started/sql-console) 中运行以下 SQL 命令,提供符合复杂性要求的安全密码: ```sql CREATE USER hyperdx IDENTIFIED WITH sha256_password BY '' SETTINGS PROFILE 'readonly'; GRANT sql_console_read_only TO hyperdx; ``` -### Prepare for ingestion user {#prepare-for-ingestion} +### 准备接收用户 {#prepare-for-ingestion} -为数据创建一个 `otel` 数据库,并创建一个具有有限权限的 `hyperdx_ingest` 用户进行数据摄取。 +为数据创建一个 `otel` 数据库,并创建一个 `hyperdx_ingest` 用户用于数据接收,并设置有限权限。 ```sql CREATE DATABASE otel; @@ -165,34 +170,34 @@ CREATE USER hyperdx_ingest IDENTIFIED WITH sha256_password BY 'ClickH0u3eRocks12 GRANT SELECT, INSERT, CREATE TABLE, CREATE VIEW ON otel.* TO hyperdx_ingest; ``` -### Deploy ClickStack {#deploy-clickstack} +### 部署 ClickStack {#deploy-clickstack} -部署 ClickStack - 优选使用 [Helm](/use-cases/observability/clickstack/deployment/helm) 或 [Docker Compose](/use-cases/observability/clickstack/deployment/docker-compose) 部署模型(经过修改以排除 ClickHouse)。 +部署 ClickStack - 最好采用 [Helm](/use-cases/observability/clickstack/deployment/helm) 或 [Docker Compose](/use-cases/observability/clickstack/deployment/docker-compose)(修改以排除 ClickHouse)部署模型。 -:::note Deploying components separately -高级用户可以将 [OTel collector](/use-cases/observability/clickstack/ingesting-data/opentelemetry#standalone) 和 [HyperDX](/use-cases/observability/clickstack/deployment/hyperdx-only) 以各自的独立部署模式单独部署。 +:::note 单独部署组件 +高级用户可以单独部署 [OTel 收集器](/use-cases/observability/clickstack/ingesting-data/opentelemetry#standalone) 和 [HyperDX](/use-cases/observability/clickstack/deployment/hyperdx-only),并使用各自的独立部署模式。 ::: -有关使用 ClickHouse Cloud 的 Helm 图表的说明,请参见 [这里](/use-cases/observability/clickstack/deployment/helm#using-clickhouse-cloud)。 Docker Compose 的等效说明可在 [这里](/use-cases/observability/clickstack/deployment/docker-compose)找到。 +有关使用 Helm chart 与 ClickHouse Cloud 的说明,请参见 [这里](/use-cases/observability/clickstack/deployment/helm#using-clickhouse-cloud)。Docker Compose 的同类说明可以在 [这里](/use-cases/observability/clickstack/deployment/docker-compose) 找到。 -### Navigate to the HyperDX UI {#navigate-to-hyperdx-ui} +### 导航到 HyperDX UI {#navigate-to-hyperdx-ui} 访问 [http://localhost:8080](http://localhost:8080) 以访问 HyperDX UI。 -创建用户,提供符合要求的用户名和密码。 +创建用户,提供满足要求的用户名和密码。 HyperDX UI -单击 `Create` 时,系统将提示输入连接详细信息。 +单击 `创建` 后,系统会提示您输入连接详情。 -### Connect to ClickHouse Cloud {#connect-to-clickhouse-cloud} +### 连接到 ClickHouse Cloud {#connect-to-clickhouse-cloud} -使用之前创建的凭证,完成连接详细信息并单击 `Create`。 +使用之前创建的凭据,填写连接详情并单击 `创建`。 HyperDX Cloud -### Send data to ClickStack {#send-data} +### 发送数据到 ClickStack {#send-data} -要将数据发送到 ClickStack,请参阅 ["Sending OpenTelemetry data"](/use-cases/observability/clickstack/ingesting-data/opentelemetry#sending-otel-data)。 +要将数据发送到 ClickStack,请查看 ["发送 OpenTelemetry 数据"](/use-cases/observability/clickstack/ingesting-data/opentelemetry#sending-otel-data)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/production.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/production.md.hash index 14637ec1c63..05396fe8323 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/production.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/production.md.hash @@ -1 +1 @@ -dbfcbba555415336 +b099ea8593ff55e8 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/search.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/search.md index 9f4c5967315..c930400034c 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/search.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/search.md @@ -5,21 +5,22 @@ 'pagination_prev': null 'pagination_next': null 'description': '使用 ClickStack 搜索' +'doc_type': 'guide' --- import Image from '@theme/IdealImage'; import hyperdx_27 from '@site/static/images/use-cases/observability/hyperdx-27.png'; -ClickStack 允许您对事件(日志和跟踪)进行全文搜索。您可以通过输入与您的事件匹配的关键字来开始搜索。例如,如果您的日志包含“Error”,您只需在搜索框中输入“Error”即可找到它。 +ClickStack 允许您对事件(日志和追踪)进行全文搜索。您只需输入与您的事件匹配的关键字即可开始搜索。例如,如果您的日志包含“Error”,您只需在搜索栏中输入“Error”即可找到它。 -这种相同的搜索语法也用于通过仪表板和图表过滤事件。 +相同的搜索语法也用于通过仪表板和图表过滤事件。 ## 自然语言搜索语法 {#natural-language-syntax} - 搜索不区分大小写 -- 默认情况下,搜索按完整单词匹配(例如,`Error` 将匹配 `Error here`,但不会匹配 `Errors here`)。您可以用通配符包围一个单词,以匹配部分单词(例如,`*Error*` 将匹配 `AnyError` 和 `AnyErrors`) -- 搜索术语可以任意顺序搜索(例如,`Hello World` 将匹配包含 `Hello World` 和 `World Hello` 的日志) -- 您可以使用 `NOT` 或 `-` 来排除关键字(例如,`Error NOT Exception` 或 `Error -Exception`) +- 默认情况下,搜索按完整单词匹配(例如,`Error` 会匹配 `Error here`,但不会匹配 `Errors here`)。您可以使用通配符包围一个单词以匹配部分单词(例如,`*Error*` 会匹配 `AnyError` 和 `AnyErrors`) +- 搜索词的顺序可以任意(例如,`Hello World` 会匹配包含 `Hello World` 和 `World Hello` 的日志) +- 您可以使用 `NOT` 或 `-` 排除关键字(例如,`Error NOT Exception` 或 `Error -Exception`) - 您可以使用 `AND` 和 `OR` 来组合多个关键字(例如,`Error OR Exception`) - 精确匹配可以通过双引号完成(例如,`"Error tests not found"`) @@ -27,21 +28,21 @@ ClickStack 允许您对事件(日志和跟踪)进行全文搜索。您可以 ### 列/属性搜索 {#column-search} -- 您可以通过使用 `column:value` 来搜索列和 JSON/map 属性(例如,`level:Error`,`service:app`) -- 您可以通过使用比较运算符(`>`、`<`、`>=`、`<=`)来搜索值的范围(例如,`Duration:>1000`) -- 您可以通过使用 `property:*` 来搜索属性的存在性(例如,`duration:*`) +- 您可以通过使用 `column:value` 搜索列和 JSON/map 属性(例如,`level:Error`,`service:app`) +- 您可以使用比较运算符 (`>`,`<`,`>=`,`<=`) 搜索值范围(例如,`Duration:>1000`) +- 您可以通过使用 `property:*` 搜索属性的存在(例如,`duration:*`) ## 时间输入 {#time-input} - 时间输入接受自然语言输入(例如,`1 hour ago`,`yesterday`,`last week`) -- 指定单个时间点将导致从该时间点搜索到现在。 -- 时间范围在搜索时将始终转换为解析后的时间范围,以便于调试时间查询。 -- 您还可以突出显示直方图条以缩放到特定时间范围。 +- 指定单个时间点将导致从该时间点到现在的搜索。 +- 时间范围总是会在搜索时转换为解析后的时间范围,以便于调试时间查询。 +- 您也可以突出显示直方图条以缩放到特定时间范围。 ## SQL 搜索语法 {#sql-syntax} -您可以选择将搜索输入切换为 SQL 模式。这将接受任何有效的 SQL WHERE 子句进行搜索。这对于复杂查询很有用,这些查询无法用 Lucene 语法表达。 +您可以选择切换搜索输入到 SQL 模式。这将接受任何有效的 SQL WHERE 子句进行搜索。这对于无法用 Lucene 语法表达的复杂查询非常有用。 -## SELECT 语句 {#select-statement} +## 选择语句 {#select-statement} -要指定在搜索结果中显示的列,您可以使用 `SELECT` 输入。这是在搜索页面中选择列的 SQL SELECT 表达式。此时不支持别名(例如,您不能使用 `column as "alias"`)。 +要指定在搜索结果中显示的列,您可以使用 `SELECT` 输入。这是搜索页面中要选择的列的 SQL SELECT 表达式。目前不支持别名(例如,您不能使用 `column as "alias"`)。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/search.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/search.md.hash index 657532a1cf4..34b0780b984 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/search.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/search.md.hash @@ -1 +1 @@ -c8854367c77255ce +d67f823b45eb448b diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ttl.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ttl.md new file mode 100644 index 00000000000..9241d8d96fc --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ttl.md @@ -0,0 +1,115 @@ +--- +'slug': '/use-cases/observability/clickstack/ttl' +'title': '管理生存时间 (TTL)' +'sidebar_label': '管理生存时间 (TTL)' +'pagination_prev': null +'pagination_next': null +'description': '使用 ClickStack 管理生存时间 (TTL)' +'doc_type': 'guide' +--- + +import observability_14 from '@site/static/images/use-cases/observability/observability-14.png'; +import Image from '@theme/IdealImage'; + +## TTL in ClickStack {#ttl-clickstack} + +生存时间 (TTL) 是 ClickStack 中一个关键特性,旨在有效管理和保留数据,尤其是在大量数据不断生成的情况下。TTL 允许自动过期和删除旧数据,确保存储得到最佳利用,同时不需要人工干预来维持性能。这一能力对保持数据库的轻量化、降低存储成本、以及确保查询速度快且高效,因而专注于最相关和最新的数据至关重要。此外,它通过系统管理数据生命周期,有助于遵守数据保留政策,从而增强可观察解决方案的整体可持续性和可扩展性。 + +**默认情况下,ClickStack 会保留数据 3 天。要修改此设置,请参见 ["Modifying TTL"](#modifying-ttl)。** + +在 ClickHouse 中,TTL 是在表级别控制的。例如,日志的模式如下所示: + +```sql +CREATE TABLE default.otel_logs +( + `Timestamp` DateTime64(9) CODEC(Delta(8), ZSTD(1)), + `TimestampTime` DateTime DEFAULT toDateTime(Timestamp), + `TraceId` String CODEC(ZSTD(1)), + `SpanId` String CODEC(ZSTD(1)), + `TraceFlags` UInt8, + `SeverityText` LowCardinality(String) CODEC(ZSTD(1)), + `SeverityNumber` UInt8, + `ServiceName` LowCardinality(String) CODEC(ZSTD(1)), + `Body` String CODEC(ZSTD(1)), + `ResourceSchemaUrl` LowCardinality(String) CODEC(ZSTD(1)), + `ResourceAttributes` Map(LowCardinality(String), String) CODEC(ZSTD(1)), + `ScopeSchemaUrl` LowCardinality(String) CODEC(ZSTD(1)), + `ScopeName` String CODEC(ZSTD(1)), + `ScopeVersion` LowCardinality(String) CODEC(ZSTD(1)), + `ScopeAttributes` Map(LowCardinality(String), String) CODEC(ZSTD(1)), + `LogAttributes` Map(LowCardinality(String), String) CODEC(ZSTD(1)), + INDEX idx_trace_id TraceId TYPE bloom_filter(0.001) GRANULARITY 1, + INDEX idx_res_attr_key mapKeys(ResourceAttributes) TYPE bloom_filter(0.01) GRANULARITY 1, + INDEX idx_res_attr_value mapValues(ResourceAttributes) TYPE bloom_filter(0.01) GRANULARITY 1, + INDEX idx_scope_attr_key mapKeys(ScopeAttributes) TYPE bloom_filter(0.01) GRANULARITY 1, + INDEX idx_scope_attr_value mapValues(ScopeAttributes) TYPE bloom_filter(0.01) GRANULARITY 1, + INDEX idx_log_attr_key mapKeys(LogAttributes) TYPE bloom_filter(0.01) GRANULARITY 1, + INDEX idx_log_attr_value mapValues(LogAttributes) TYPE bloom_filter(0.01) GRANULARITY 1, + INDEX idx_body Body TYPE tokenbf_v1(32768, 3, 0) GRANULARITY 8 +) +ENGINE = MergeTree +PARTITION BY toDate(TimestampTime) +PRIMARY KEY (ServiceName, TimestampTime) +ORDER BY (ServiceName, TimestampTime, Timestamp) +TTL TimestampTime + toIntervalDay(3) +SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1 +``` + +ClickHouse 中的分区允许数据根据列或 SQL 表达式在磁盘上进行逻辑分离。通过逻辑分离数据,每个分区可以独立操作,例如在根据 TTL 策略过期时进行删除。 + +如上例所示,分区在表最初通过 `PARTITION BY` 子句定义时指定。此子句可以包含任何列的 SQL 表达式,结果将定义一行数据发送到哪个分区。这会导致数据与磁盘上每个分区通过一个共同的文件夹名称前缀逻辑关联,从而可以独立查询。对于上述示例,默认的 `otel_logs` 模式使用表达式 `toDate(Timestamp)` 按天进行分区。当行数据插入 ClickHouse 时,此表达式会对每行进行评估,并在结果分区存在时将其路由到该分区(如果该行是某天的第一行,将会创建该分区)。有关分区及其其他应用的详细信息,请参见 ["Table Partitions"](/partitions)。 + +Partitions + +表模式还包括 `TTL TimestampTime + toIntervalDay(3)` 和设置 `ttl_only_drop_parts = 1`。前者确保数据在超过 3 天后将被删除。设置 `ttl_only_drop_parts = 1` 强制仅删除所有数据均已过期的数据分区(而不是试图部分删除行)。通过分区确保来自不同日期的数据从未“合并”,因此可以有效地删除数据。 + +:::important `ttl_only_drop_parts` +我们建议始终使用设置 [`ttl_only_drop_parts=1`](/operations/settings/merge-tree-settings#ttl_only_drop_parts)。启用此设置时,ClickHouse 会在所有行过期时删除整个分区。与部分清理 TTL 行(通过资源密集型突变实现,当 `ttl_only_drop_parts=0` 时)相比,删除整个分区允许更短的 `merge_with_ttl_timeout` 时间并降低对系统性能的影响。如果数据按您执行 TTL 过期的相同单位进行分区,比如天,分区自然只会包含来自定义时间间隔的数据。这将确保可以高效地应用 `ttl_only_drop_parts=1`。 +::: + +默认情况下,具有过期 TTL 的数据会在 ClickHouse [合并数据分区](/engines/table-engines/mergetree-family/mergetree#mergetree-data-storage) 时被移除。当 ClickHouse 检测到数据过期时,会执行一个非计划的合并。 + +:::note TTL schedule +TTL 不是立即应用的,而是按照计划进行,如上所述。MergeTree 表设置 `merge_with_ttl_timeout` 设置在使用删除 TTL 之前重复合并的最小延迟(以秒为单位)。默认值为 14400 秒(4 小时)。但这只是最小延迟,触发 TTL 合并可能需要更长时间。如果值设置得过低,会执行许多非计划的合并,这可能会消耗大量资源。可以使用命令 `ALTER TABLE my_table MATERIALIZE TTL` 强制执行 TTL 过期。 +::: + +## Modifying TTL {#modifying-ttl} + +要修改 TTL,用户可以选择以下两种方式: + +1. **修改表模式(推荐)**。这需要连接到 ClickHouse 实例,例如使用 [clickhouse-client](/interfaces/cli) 或 [Cloud SQL Console](/cloud/get-started/sql-console)。例如,我们可以使用以下 DDL 修改 `otel_logs` 表的 TTL: + +```sql +ALTER TABLE default.otel_logs +MODIFY TTL TimestampTime + toIntervalDay(7); +``` + +2. **修改 OTel 收集器**。ClickStack OpenTelemetry 收集器如果表不存在则会在 ClickHouse 中创建表。这是通过 ClickHouse 导出器实现的,该导出器本身公开了一个用于控制默认 TTL 表达式的 `ttl` 参数,例如: + +```yaml +exporters: + clickhouse: + endpoint: tcp://localhost:9000?dial_timeout=10s&compress=lz4&async_insert=1 + ttl: 72h +``` + +### Column level TTL {#column-level-ttl} + +上述示例在表级别上过期数据。用户还可以在列级别上过期数据。随着数据的老化,可以用于删除在调查中其值不值得保留的列。例如,我们建议保留 `Body` 列,以防在插入时尚未提取新的动态元数据,例如新的 Kubernetes 标签。在一段时间后,例如 1 个月,可能会明显发现这些额外的元数据没有用处,从而限制了保留 `Body` 列的价值。 + +下面,我们展示了如何在 30 天后删除 `Body` 列。 + +```sql +CREATE TABLE otel_logs_v2 +( + `Body` String TTL Timestamp + INTERVAL 30 DAY, + `Timestamp` DateTime, + ... +) +ENGINE = MergeTree +ORDER BY (ServiceName, Timestamp) +``` + +:::note +指定列级 TTL 要求用户提供自己的模式。这不能在 OTel 收集器中指定。 +::: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ttl.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ttl.md.hash new file mode 100644 index 00000000000..021039d5458 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/clickstack/ttl.md.hash @@ -0,0 +1 @@ +7f29ab9e1e7cae92 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/demo-application.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/demo-application.md.hash deleted file mode 100644 index 1fdfbd334fe..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/demo-application.md.hash +++ /dev/null @@ -1 +0,0 @@ -27ca92facdde6dda diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/grafana.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/grafana.md.hash deleted file mode 100644 index dc0fd1bcac0..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/grafana.md.hash +++ /dev/null @@ -1 +0,0 @@ -613e489aa8fcecad diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/index.md index 0261bbda3fd..1c800669da0 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/index.md @@ -3,7 +3,7 @@ 'title': '可观察性' 'pagination_prev': null 'pagination_next': null -'description': '可观察性用例指南的登陆页面' +'description': '可观察性用例指南的登录页面' 'keywords': - 'observability' - 'logs' @@ -12,38 +12,38 @@ - 'OpenTelemetry' - 'Grafana' - 'OTel' +'doc_type': 'guide' --- -ClickHouse 为可观察性提供无与伦比的速度、规模和成本效率。本指南根据您的需求提供了两条路径: +ClickHouse 提供了无与伦比的速度、规模和成本效率,用于可观测性。该指南根据您的需求提供了两条路径: -## ClickStack - ClickHouse 可观察性堆栈 {#clickstack} +## ClickStack - ClickHouse 可观测性堆栈 {#clickstack} -ClickHouse 可观察性堆栈是我们**推荐的方法**,适用于大多数用户。 +ClickHouse 可观测性堆栈是我们 **推荐的方法**,适用于大多数用户。 -**ClickStack** 是一个基于 ClickHouse 和 OpenTelemetry (OTel) 的生产级可观察性平台,将日志、跟踪、指标和会话统一在一个高性能的可扩展解决方案中,从单节点部署到**多PB**规模均可适用。 - -| 部分 | 描述 | -|-----------------------------|------------------------------------------| -| [概述](/use-cases/observability/clickstack/overview) | ClickStack 及其主要功能的介绍 | -| [入门](/use-cases/observability/clickstack/getting-started) | 快速入门指南和基本设置说明 | -| [示例数据集](/use-cases/observability/clickstack/sample-datasets) | 示例数据集和用例 | -| [架构](/use-cases/observability/clickstack/architecture) | 系统架构和组件概述 | -| [部署](/use-cases/observability/clickstack/deployment) | 部署指南及选项 | -| [配置](/use-cases/observability/clickstack/config) | 详细的配置选项和设置 | -| [数据摄取](/use-cases/observability/clickstack/ingesting-data) | 将数据摄取到 ClickStack 的指南 | -| [搜索](/use-cases/observability/clickstack/search) | 如何搜索和查询您的可观察性数据 | -| [生产](/use-cases/observability/clickstack/production) | 生产部署的最佳实践 | +**ClickStack** 是一个生产级的可观测性平台,建立在 ClickHouse 和 OpenTelemetry (OTel) 之上,统一了日志、跟踪、指标和会话,形成一个高性能的可扩展解决方案,适用于从单节点部署到 **多 PB** 规模。 +| 部分 | 描述 | +|-----------------------------------|-------------------------------------------| +| [概述](/use-cases/observability/clickstack/overview) | ClickStack 及其主要特征的介绍 | +| [入门](/use-cases/observability/clickstack/getting-started) | 快速入门指南和基本设置说明 | +| [示例数据集](/use-cases/observability/clickstack/sample-datasets) | 示例数据集和用例 | +| [架构](/use-cases/observability/clickstack/architecture) | 系统架构和组件概述 | +| [部署](/use-cases/observability/clickstack/deployment) | 部署指南和选项 | +| [配置](/use-cases/observability/clickstack/config) | 详细的配置选项和设置 | +| [数据摄取](/use-cases/observability/clickstack/ingesting-data) | 将数据摄取到 ClickStack 的指南 | +| [搜索](/use-cases/observability/clickstack/search) | 如何搜索和查询您的可观测性数据 | +| [生产](/use-cases/observability/clickstack/production) | 生产部署的最佳实践 | ## 自建堆栈 {#build-your-own-stack} -对于具有**自定义需求**的用户——例如高度专业化的摄取管道、模式设计或极端的扩展需求——我们提供指导,以帮助您以 ClickHouse 作为核心数据库构建自定义可观察性堆栈。 +对于具有 **定制需求** 的用户 — 例如高度专业化的摄取管道、模式设计或极限扩展需求 — 我们提供指导,以构建以 ClickHouse 为核心数据库的自定义可观测性堆栈。 -| 页面 | 描述 | -|-----------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| [介绍](/use-cases/observability/introduction) | 本指南旨在帮助希望使用 ClickHouse 构建自己的可观察性解决方案的用户,重点关注日志和跟踪。 | -| [模式设计](/use-cases/observability/schema-design) | 了解为什么建议用户为日志和跟踪创建自己的模式,以及这样做的一些最佳实践。 | -| [管理数据](/observability/managing-data) | ClickHouse 的可观察性部署必然涉及大型数据集,需要进行管理。ClickHouse 提供了数据管理的功能以助力于此。 | -| [集成 OpenTelemetry](/observability/integrating-opentelemetry) | 使用 OpenTelemetry 在 ClickHouse 中收集和导出日志和跟踪。 | -| [使用可视化工具](/observability/grafana) | 了解如何使用可观察性可视化工具为 ClickHouse 提供支持,包括 HyperDX 和 Grafana。 | -| [演示应用程序](/observability/demo-application) | 探索 OpenTelemetry 演示应用程序,该应用程序分支已调整为与 ClickHouse 一起处理日志和跟踪。 | +| 页面 | 描述 | +|-------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| [介绍](/use-cases/observability/introduction) | 本指南旨在帮助用户构建自己的可观测性解决方案,使用 ClickHouse,重点关注日志和跟踪。 | +| [模式设计](/use-cases/observability/schema-design) | 了解为何推荐用户为日志和跟踪创建自己的模式,以及一些最佳实践。 | +| [管理数据](/observability/managing-data) | ClickHouse在可观测性的部署不可避免地涉及大量数据集,需要进行管理。ClickHouse 提供了一些特性来协助数据管理。 | +| [集成 OpenTelemetry](/observability/integrating-opentelemetry) | 使用 OpenTelemetry 在 ClickHouse 中收集和导出日志和跟踪。 | +| [使用可视化工具](/observability/grafana) | 了解如何使用可观测性可视化工具,如 HyperDX 和 Grafana 来支持 ClickHouse。 | +| [演示应用](/observability/demo-application) | 探索与 ClickHouse 兼容的 OpenTelemetry 演示应用程序。 | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/index.md.hash index 4bc0d7325ca..4598a64e335 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/index.md.hash @@ -1 +1 @@ -158225792c3ab482 +0f44f8b01c224060 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/integrating-opentelemetry.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/integrating-opentelemetry.md.hash deleted file mode 100644 index 8a1b9d16104..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/integrating-opentelemetry.md.hash +++ /dev/null @@ -1 +0,0 @@ -4a08dfee40be368f diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/introduction.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/introduction.md.hash deleted file mode 100644 index f179834a678..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/introduction.md.hash +++ /dev/null @@ -1 +0,0 @@ -edd0c90518025361 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/managing-data.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/managing-data.md.hash deleted file mode 100644 index 3e738ddca48..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/managing-data.md.hash +++ /dev/null @@ -1 +0,0 @@ -ff28c4c78c6d1498 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/schema-design.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/schema-design.md.hash deleted file mode 100644 index b7a643cfdab..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/observability/schema-design.md.hash +++ /dev/null @@ -1 +0,0 @@ -0102bfe4916136e1 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/date-time-data-types.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/01_date-time-data-types.md similarity index 69% rename from i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/date-time-data-types.md rename to i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/01_date-time-data-types.md index b6c50b3f591..0fe8ebd7553 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/date-time-data-types.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/01_date-time-data-types.md @@ -7,24 +7,25 @@ - 'Time Series' - 'DateTime' 'show_related_blogs': true +'doc_type': 'reference' --- # 日期和时间数据类型 -拥有全面的日期和时间类型对于有效的时间序列数据管理是必要的,而 ClickHouse 正好提供了这一点。 -从紧凑的日期表示到具有纳秒精度的高精度时间戳,这些类型旨在平衡存储效率与不同时间序列应用程序的实际需求。 +拥有全面的日期和时间类型对于有效的时间序列数据管理是必要的,而 ClickHouse 正是提供了这一点。 +从紧凑的日期表示到以纳秒精度的高精度时间戳,这些类型旨在平衡存储效率与不同时间序列应用的实际需求。 -无论您是在处理历史财务数据、物联网传感器读数,还是未来日期事件,ClickHouse 的日期和时间类型都提供了处理各种时间数据场景所需的灵活性。 -支持的类型范围使您能够在保持所需精度的同时优化存储空间和查询性能。 +无论您是在处理历史金融数据、物联网传感器读数,还是未来日期的事件,ClickHouse 的日期和时间类型都提供了处理各种时间数据场景所需的灵活性。 +支持的类型范围使您能够在优化存储空间和查询性能的同时,保持您用例所需的精度。 -* [`Date`](/sql-reference/data-types/date) 类型在大多数情况下应该足够。该类型需要 2 字节来存储一个日期,并将范围限制在 `[1970-01-01, 2149-06-06]`。 +* [`Date`](/sql-reference/data-types/date) 类型在大多数情况下都是足够的。此类型需要 2 个字节来存储一个日期,限制范围为 `[1970-01-01, 2149-06-06]`。 -* [`Date32`](/sql-reference/data-types/date32) 覆盖更广泛的日期范围。它需要 4 字节来存储一个日期,并将范围限制在 `[1900-01-01, 2299-12-31]`。 +* [`Date32`](/sql-reference/data-types/date32) 覆盖了更广泛的日期范围。它需要 4 个字节来存储一个日期,限制范围为 `[1900-01-01, 2299-12-31]`。 -* [`DateTime`](/sql-reference/data-types/datetime) 存储的日期时间值具有秒级精度,范围为 `[1970-01-01 00:00:00, 2106-02-07 06:28:15]`,每个值需要 4 字节。 +* [`DateTime`](/sql-reference/data-types/datetime) 存储秒精度的日期时间值,范围为 `[1970-01-01 00:00:00, 2106-02-07 06:28:15]`。它需要每个值 4 个字节。 -* 对于需要更高精度的情况,可以使用 [`DateTime64`](/sql-reference/data-types/datetime64)。这允许存储具有高达纳秒精度的时间,范围为 `[1900-01-01 00:00:00, 2299-12-31 23:59:59.99999999]`。每个值需要 8 字节。 +* 对于需要更多精度的情况,可以使用 [`DateTime64`](/sql-reference/data-types/datetime64)。这允许以纳秒精度存储时间,范围为 `[1900-01-01 00:00:00, 2299-12-31 23:59:59.99999999]`。它每个值需要 8 个字节。 让我们创建一个存储各种日期类型的表: @@ -41,7 +42,7 @@ ENGINE = MergeTree ORDER BY tuple(); ``` -我们可以使用 [`now()`](/sql-reference/functions/date-time-functions#now) 函数返回当前时间,使用 [`now64()`](/sql-reference/functions/date-time-functions#now64) 以指定的精度获取当前时间作为第一个参数。 +我们可以使用 [`now()`](/sql-reference/functions/date-time-functions#now) 函数返回当前时间,并使用 [`now64()`](/sql-reference/functions/date-time-functions#now64) 通过第一个参数以指定精度获取时间。 ```sql INSERT INTO dates @@ -52,7 +53,7 @@ SELECT now(), now64(9) + toIntervalYear(200); ``` -这将根据列类型相应地填充我们的列: +这将根据列类型相应填充我们的列: ```sql SELECT * FROM dates @@ -71,7 +72,7 @@ very_precise_datetime: 2025-03-12 11:39:07.196724000 ## 时区 {#time-series-timezones} -许多用例要求同时存储时区。我们可以将时区设为 `DateTime` 或 `DateTime64` 类型的最后一个参数: +许多用例还需要存储时区。我们可以将时区设为 `DateTime` 或 `DateTime64` 类型的最后一个参数: ```sql CREATE TABLE dtz @@ -86,7 +87,7 @@ ENGINE = MergeTree ORDER BY id; ``` -在我们的 DDL 中定义了时区后,现在可以使用不同的时区插入时间: +在我们的 DDL 中定义了时区后,我们现在可以使用不同的时区插入时间: ```sql INSERT INTO dtz @@ -103,7 +104,7 @@ SELECT 2, toDateTime64('2022-12-12 12:13:15.123456789', 9); ``` -现在让我们看一下我们的表中有什么: +现在让我们查看一下我们的表中有什么内容: ```sql SELECT dt_1, dt64_1, dt_2, dt64_2 @@ -131,12 +132,12 @@ dt64_2: 2022-12-12 12:13:15.123456789 * `dt_1` 和 `dt64_1` 在查询时自动转换为 `Europe/Berlin`。 * `dt_2` 和 `dt64_2` 没有指定时区,因此使用服务器的本地时区,在这种情况下是 `Europe/London`。 -在第二行中,我们插入了所有没有时区的值,因此使用了服务器的本地时区。 -与第一行一样,`dt_1` 和 `dt_3` 被转换为 `Europe/Berlin`,而 `dt_2` 和 `dt64_2` 则使用服务器的本地时区。 +在第二行中,我们插入的所有值都没有时区,因此使用了服务器的本地时区。 +与第一行一样,`dt_1` 和 `dt_3` 被转换为 `Europe/Berlin`,而 `dt_2` 和 `dt64_2` 使用了服务器的本地时区。 ## 日期和时间函数 {#time-series-date-time-functions} -ClickHouse 还提供了一组函数,让我们可以在不同的数据类型之间进行转换。 +ClickHouse 还提供了一组函数,允许我们在不同数据类型之间进行转换。 例如,我们可以使用 [`toDate`](/sql-reference/functions/type-conversion-functions#todate) 将 `DateTime` 值转换为 `Date` 类型: @@ -178,7 +179,7 @@ date_only: 2025-03-12 12:35:01.000 toTypeName(date_only): DateTime64(3) ``` -我们可以使用 [`toDateTime`](/sql-reference/functions/type-conversion-functions#todatetime) 将 `Date` 或 `DateTime64` 还原为 `DateTime`: +我们可以使用 [`toDateTime`](/sql-reference/functions/type-conversion-functions#todatetime) 从 `Date` 或 `DateTime64` 回到 `DateTime`: ```sql SELECT diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/01_date-time-data-types.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/01_date-time-data-types.md.hash new file mode 100644 index 00000000000..fdfef05f4c2 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/01_date-time-data-types.md.hash @@ -0,0 +1 @@ +feca37d657fb7d49 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/basic-operations.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/02_basic-operations.md similarity index 74% rename from i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/basic-operations.md rename to i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/02_basic-operations.md index a2f4e63969f..343df7ec0eb 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/basic-operations.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/02_basic-operations.md @@ -1,23 +1,24 @@ --- 'title': '基本操作 - 时间序列' 'sidebar_label': '基本操作' -'description': 'ClickHouse 中的基本时间序列操作。' +'description': '在 ClickHouse 中的基本时间序列操作。' 'slug': '/use-cases/time-series/basic-operations' 'keywords': - 'time-series' 'show_related_blogs': true +'doc_type': 'guide' --- -# 基本时间序列操作 +# 基本的时间序列操作 -ClickHouse 提供了多种方法来处理时间序列数据,允许您在不同时间段内聚合、分组和分析数据点。 +ClickHouse 提供了多种方法来处理时间序列数据,使您能够对不同时间段的数据点进行聚合、分组和分析。 本节涵盖了在处理基于时间的数据时常用的基本操作。 -常见的操作包括按时间间隔分组数据、处理时间序列数据中的缺口以及计算时间段之间的变化。 +常见操作包括按时间间隔对数据进行分组、处理时间序列数据中的间隙,以及计算时间段之间的变化。 这些操作可以使用标准 SQL 语法结合 ClickHouse 内置的时间函数来执行。 -我们将使用 Wikistat(维基百科页面查看数据)数据集来探索 ClickHouse 的时间序列查询能力: +我们将探索 ClickHouse 的时间序列查询功能,使用 Wikistat(维基百科页面浏览数据)数据集: ```sql CREATE TABLE wikistat @@ -32,7 +33,7 @@ ENGINE = MergeTree ORDER BY (time); ``` -首先,让我们用 10 亿条记录填充这个表: +让我们用 10 亿条记录填充这个表: ```sql INSERT INTO wikistat @@ -43,7 +44,7 @@ LIMIT 1e9; ## 按时间桶聚合 {#time-series-aggregating-time-bucket} -最常见的需求是基于时间段聚合数据,例如获取每天的总点击量: +最常见的需求是基于时间段聚合数据,例如,获取每一天的总点击量: ```sql SELECT @@ -65,8 +66,7 @@ LIMIT 5; └────────────┴──────────┘ ``` -我们在这里使用了 [`toDate()`](/sql-reference/functions/type-conversion-functions#todate) 函数,该函数将指定的时间转换为日期类型。 -或者,我们可以按小时进行分批,并过滤特定日期: +我们在这里使用了 [`toDate()`](/sql-reference/functions/type-conversion-functions#todate) 函数,它将指定的时间转换为日期类型。或者,我们可以按小时分批并在特定日期上进行过滤: ```sql SELECT @@ -89,15 +89,15 @@ LIMIT 5; └─────────────────────┴────────┘ ``` -这里使用的 [`toStartOfHour()`](/docs/sql-reference/functions/date-time-functions#tostartofhour) 函数将给定的时间转换为小时的开始时间。 -您还可以按年、季度、月份或天进行分组。 +这里使用的 [`toStartOfHour()`](/docs/sql-reference/functions/date-time-functions#toStartOfHour) 函数将给定时间转换为小时的开始时间。 +您还可以按年、季度、月或日分组。 ## 自定义分组间隔 {#time-series-custom-grouping-intervals} -我们甚至可以按任意间隔分组,例如,使用 5 分钟的间隔通过 [`toStartOfInterval()`](/docs/sql-reference/functions/date-time-functions#tostartofinterval) 函数。 +我们甚至可以按任意间隔分组,例如,使用 [`toStartOfInterval()`](/docs/sql-reference/functions/date-time-functions#toStartOfInterval) 函数按 5 分钟分组。 -假设我们想按 4 小时的间隔进行分组。 -我们可以使用 [`INTERVAL`](/docs/sql-reference/data-types/special-data-types/interval) 子句来指定分组间隔: +假设我们想按 4 小时的间隔进行分组。 +我们可以使用 [`INTERVAL`](/docs/sql-reference/data-types/special-data-types/interval) 子句指定分组间隔: ```sql SELECT @@ -136,10 +136,9 @@ LIMIT 6; └─────────────────────┴─────────┘ ``` -## 填充空组 {#time-series-filling-empty-groups} +## 填充空的分组 {#time-series-filling-empty-groups} -在许多情况下,我们处理的是稀疏数据,其中某些间隔缺失。这会导致空桶。 -让我们取以下示例,在该示例中按 1 小时的间隔分组数据。这将输出以下统计数据,但有些小时缺少值: +在很多情况下,我们处理稀疏数据,某些间隔缺失。这导致空桶的产生。让我们来看以下例子,我们按 1 小时的间隔对数据进行分组。这将输出以下统计信息,其中一些小时缺失值: ```sql SELECT @@ -176,8 +175,7 @@ ORDER BY hour ASC; └─────────────────────┴───────────┘ ``` -ClickHouse 提供了 [`WITH FILL`](/docs/guides/developer/time-series-filling-gaps#with-fill) 修饰符来解决此问题。 -这将用零填充所有空小时,以帮助我们更好地理解随时间的分布: +ClickHouse 提供了 [`WITH FILL`](/docs/guides/developer/time-series-filling-gaps#with-fill) 修饰符来解决这个问题。这将用零填充所有空缺的小时,从而使我们更好地了解随时间的分布: ```sql SELECT @@ -220,11 +218,11 @@ ORDER BY hour ASC WITH FILL STEP toIntervalHour(1); ## 滚动时间窗口 {#time-series-rolling-time-windows} -有时,我们不想处理间隔的开始(如一天或一小时的开始),而是窗口间隔。 -假设我们想了解一个窗口的总点击量,而不是根据天,而是基于从下午 6 点开始的 24 小时周期。 +有时候,我们不想处理间隔的开始(如一天或一小时的开始),而是窗口间隔。 +假设我们想理解某个窗口的总点击量,而不是基于天,而是基于从下午 6 点开始的 24 小时周期。 -我们可以使用 [`date_diff()`](/docs/sql-reference/functions/date-time-functions#date_diff) 函数计算参考时间与每条记录时间之间的差异。 -在这种情况下,`day` 列将表示天数的差异(例如,一天前、两天前等): +我们可以使用 [`date_diff()`](/docs/sql-reference/functions/date-time-functions#timeDiff) 函数计算参考时间与每条记录时间之间的差异。 +在这种情况下,`day` 列将表示天数差异(例如,1 天前、2 天前等): ```sql SELECT diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/02_basic-operations.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/02_basic-operations.md.hash new file mode 100644 index 00000000000..99755f9f914 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/02_basic-operations.md.hash @@ -0,0 +1 @@ +826b950ccc39c08c diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/analysis-functions.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/03_analysis-functions.md similarity index 74% rename from i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/analysis-functions.md rename to i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/03_analysis-functions.md index be0156cb107..368abd3e3df 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/analysis-functions.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/03_analysis-functions.md @@ -1,34 +1,35 @@ --- -'title': '分析功能 - 时间序列' -'sidebar_label': '分析功能' +'title': '分析函数 - 时间序列' +'sidebar_label': '分析函数' 'description': '用于分析 ClickHouse 中时间序列数据的函数。' 'slug': '/use-cases/time-series/analysis-functions' 'keywords': - 'time-series' 'show_related_blogs': true +'doc_type': 'reference' --- # 时间序列分析函数 -在 ClickHouse 中,时间序列分析可以使用标准 SQL 聚合和窗口函数进行。 +在 ClickHouse 中,时间序列分析可以使用标准 SQL 聚合和窗口函数来执行。 在处理时间序列数据时,您通常会遇到三种主要类型的指标: -* 持续单调增加的计数器指标(如页面浏览量或总事件数) -* 表示时点测量值的测量指标,这些值可以上升或下降(如 CPU 使用率或温度) -* 采样观察值并将其计入桶中的直方图(如请求持续时间或响应大小) +* 随时间单调增加的计数器指标(如页面浏览量或总事件数) +* 表示瞬时测量且可上下波动的计量指标(如 CPU 使用率或温度) +* 采样观测值并将其计数到桶中的直方图(如请求时长或响应大小) -这些指标的常见分析模式包括比较不同时期之间的值、计算累积总额、确定变化率和分析分布。 -所有这些都可以通过聚合、窗口函数(如 `sum() OVER`)和专用函数(如 `histogram()`)的组合来实现。 +这些指标的常见分析模式包括比较周期之间的值、计算累积总数、确定变化率和分析分布。 +这些都可以通过聚合、窗口函数如 `sum() OVER` 的组合以及像 `histogram()` 这样的专用函数来实现。 -## 逐期变化分析 {#time-series-period-over-period-changes} +## 周期间变化 {#time-series-period-over-period-changes} -在分析时间序列数据时,我们常常需要了解值在不同时间段之间如何变化。 -这对测量指标和计数器指标都是至关重要的。 -[`lagInFrame`](/docs/sql-reference/window-functions/lagInFrame) 窗口函数可以让我们访问上一个周期的值,以计算这些变化。 +在分析时间序列数据时,我们通常需要了解值在时间段之间是如何变化的。 +这对计量和计数器指标都是必不可少的。 +[`lagInFrame`](/docs/sql-reference/window-functions/lagInFrame) 窗口函数使我们能够访问前一个时间段的值,以计算这些变化。 -以下查询通过计算“奇怪的阿尔”扬科维奇 Wikipedia 页面每日视图的日变化来演示这一点。 -趋势列显示与前一天相比,流量是增加(正值)还是减少(负值),帮助识别活动中的异常高峰或下降。 +以下查询通过计算 “Weird Al” Yankovic 的维基百科页面的日变化量来演示这一点。 +趋势列显示与前一天相比,流量是增加(正值)还是减少(负值),帮助识别活动中的异常激增或下降。 ```sql SELECT @@ -57,12 +58,12 @@ LIMIT 10; └────────────┴──────┴──────┴───────┘ ``` -## 累计值 {#time-series-cumulative-values} +## 累积值 {#time-series-cumulative-values} 计数器指标自然随时间累积。 -为了分析这种累积增长,我们可以使用窗口函数计算运行总额。 +要分析这种累积增长,我们可以使用窗口函数计算运行总数。 -以下查询通过使用 `sum() OVER` 子句创建运行总额,而 `bar()` 函数提供增长的可视化表示。 +以下查询通过使用 `sum() OVER` 子句来创建运行总数,而 `bar()` 函数提供了增长的可视化表示。 ```sql SELECT @@ -92,11 +93,11 @@ LIMIT 10; └────────────┴──────┴───────┴───────────────────┘ ``` -## 比率计算 {#time-series-rate-calculations} +## 速率计算 {#time-series-rate-calculations} -在分析时间序列数据时,了解单位时间内的事件发生率通常是有用的。 -该查询通过将每小时的总数除以一小时内的秒数(3600)来计算每秒的页面浏览量比率。 -可视化条形图有助于识别活动的高峰时段。 +在分析时间序列数据时,了解单位时间内事件的发生率往往很有用。 +此查询通过将每小时总数除以每小时的秒数(3600)来计算每秒的页面浏览量。 +可视化条形图帮助识别活动的高峰时段。 ```sql SELECT @@ -127,9 +128,9 @@ LIMIT 10; ## 直方图 {#time-series-histograms} -时间序列数据的一个流行用例是根据追踪事件构建直方图。 -假设我们想了解根据总点击数对页面的分布,仅包含超过 10,000 次点击的页面。 -我们可以使用 `histogram()` 函数基于箱的数量自动生成自适应直方图: +时间序列数据的一个流行用例是根据跟踪事件构建直方图。 +假设我们想了解基于总点击量的多个页面的分布情况,仅包括点击量超过 10,000 的页面。 +我们可以使用 `histogram()` 函数根据桶的数量自动生成自适应直方图: ```sql SELECT @@ -153,7 +154,7 @@ Row 1: hist: [(10033,23224.55065359477,60.625),(23224.55065359477,37855.38888888889,15.625),(37855.38888888889,52913.5,3.5),(52913.5,69438,1.25),(69438,83102.16666666666,1.25),(83102.16666666666,94267.66666666666,2.5),(94267.66666666666,116778,1.25),(116778,186175.75,1.125),(186175.75,946963.25,1.75),(946963.25,1655250,1.125)] ``` -然后我们可以使用 [`arrayJoin()`](/docs/sql-reference/functions/array-join) 来处理数据,并使用 `bar()` 来可视化它: +然后,我们可以使用 [`arrayJoin()`](/docs/sql-reference/functions/array-join) 来处理数据,并用 `bar()` 进行可视化: ```sql WITH histogram(10)(hits) AS hist diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/03_analysis-functions.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/03_analysis-functions.md.hash new file mode 100644 index 00000000000..f1fdd944a2c --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/03_analysis-functions.md.hash @@ -0,0 +1 @@ +fdd086d9394cadea diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/storage-efficiency.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/04_storage-efficiency.md similarity index 57% rename from i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/storage-efficiency.md rename to i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/04_storage-efficiency.md index 41c15138db6..79508ae9776 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/storage-efficiency.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/04_storage-efficiency.md @@ -6,18 +6,19 @@ 'keywords': - 'time-series' 'show_related_blogs': true +'doc_type': 'guide' --- # 时间序列存储效率 -在探索如何查询我们的维基百科统计数据集后,接下来让我们关注在 ClickHouse 中优化其存储效率。 -本节演示了在保持查询性能的同时减少存储需求的实际技术。 +在探索如何查询我们的维基百科统计数据集后,让我们专注于优化其在 ClickHouse 中的存储效率。 +本节演示了在维护查询性能的同时减少存储需求的实际技术。 ## 类型优化 {#time-series-type-optimization} -优化存储效率的一般方法是使用最优的数据类型。 -让我们来看一下 `project` 和 `subproject` 列。这些列的数据类型为 String,但具有相对较少的唯一值: +优化存储效率的一般方法是使用最佳数据类型。 +让我们看一下 `project` 和 `subproject` 列。这些列的数据类型是 String,但具有相对较少的唯一值: ```sql SELECT @@ -32,7 +33,7 @@ FROM wikistat; └───────────────┴──────────────────┘ ``` -这意味着我们可以使用 LowCardinality() 数据类型,它使用基于字典的编码。这使得 ClickHouse 存储内部值 ID 而不是原始字符串值,从而节省了大量空间: +这意味着我们可以使用 LowCardinality() 数据类型,它使用基于字典的编码。这使得 ClickHouse 存储内部值 ID,而不是原始字符串值,从而节省了大量空间: ```sql ALTER TABLE wikistat @@ -40,7 +41,7 @@ MODIFY COLUMN `project` LowCardinality(String), MODIFY COLUMN `subproject` LowCardinality(String) ``` -我们还对 hits 列使用了 UInt64 类型,该类型占用 8 字节,但其最大值相对较小: +我们还使用了 UInt64 类型的 hits 列,它占用 8 字节,但最大值相对较小: ```sql SELECT max(hits) @@ -53,32 +54,31 @@ FROM wikistat; └───────────┘ ``` -考虑到这个值,我们可以使用 UInt32 替代,它只占用 4 字节,并允许我们存储最大值约为 ~4b: +考虑到这个值,我们可以改用 UInt32,它只占用 4 字节,并允许我们存储最多 ~4b 的最大值: ```sql ALTER TABLE wikistat MODIFY COLUMN `hits` UInt32; ``` -这将使该列在内存中的大小至少减少 2 倍。 请注意,由于压缩,磁盘上的大小将保持不变。 但是要小心,选择不太小的数据类型! +这将使此列在内存中的大小减少至少 2 倍。请注意,由于压缩,磁盘上的大小将保持不变。但要小心,选择不要太小的数据类型! -## 专用编解码器 {#time-series-specialized-codecs} +## 专用编码器 {#time-series-specialized-codecs} -当我们处理序列数据时,例如时间序列,我们可以通过使用特殊的编解码器进一步提高存储效率。 -其一般思想是存储值之间的变化,而不是绝对值本身,这在处理缓慢变化的数据时所需空间大大减少: +当我们处理顺序数据时,例如时间序列,我们可以通过使用专用编码器进一步提高存储效率。 +一般的想法是存储值之间的变化,而不是绝对值,这在处理缓慢变化的数据时所需的空间会减少很多: ```sql ALTER TABLE wikistat MODIFY COLUMN `time` CODEC(Delta, ZSTD); ``` -我们对时间列使用了 Delta 编解码器,这是适合时间序列数据的良好选择。 +我们对时间列使用了 Delta 编码,这是时间序列数据的良好选择。 -正确的排序键也可以节省磁盘空间。 -由于我们通常希望按照路径进行过滤,因此我们将 `path` 添加到排序键中。 -这需要重新创建表。 +正确的排序键也可以节省磁盘空间。 +由于我们通常希望按路径进行过滤,我们将 `path` 添加到排序键中。这需要重新创建表。 -下面我们可以看到初始表和优化表的 `CREATE` 命令: +下面我们可以看到我们初始表和优化表的 `CREATE` 命令: ```sql CREATE TABLE wikistat @@ -106,7 +106,7 @@ ENGINE = MergeTree ORDER BY (path, time); ``` -让我们看一下每个表中的数据占用的空间量: +让我们看看每个表中数据所占用的空间量: ```sql SELECT @@ -126,4 +126,4 @@ GROUP BY ALL; └────────────────────┴──────────────┴────────────┴───────┘ ``` -优化后的表在压缩形式下占用的空间仅略超过原来的 4 倍。 +优化表在压缩形式下所占的空间仅为原来的四分之一多一点。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/04_storage-efficiency.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/04_storage-efficiency.md.hash new file mode 100644 index 00000000000..47e29c6f69c --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/04_storage-efficiency.md.hash @@ -0,0 +1 @@ +2aa81f27aa971191 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/query-performance.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/05_query-performance.md similarity index 71% rename from i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/query-performance.md rename to i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/05_query-performance.md index 47f8b8d5700..777cd2846f3 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/query-performance.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/05_query-performance.md @@ -1,25 +1,26 @@ --- 'title': '查询性能 - 时间序列' 'sidebar_label': '查询性能' -'description': '提高时间序列 查询 性能' +'description': '改善时间序列查询性能' 'slug': '/use-cases/time-series/query-performance' 'keywords': - 'time-series' 'show_related_blogs': true +'doc_type': 'guide' --- # 时间序列查询性能 -在优化存储之后,下一步是提高查询性能。 -本节探讨两种关键技术:优化 `ORDER BY` 键和使用物化视图。 -我们将看到这些方法如何将查询时间从几秒减少到毫秒级。 +在优化存储之后,下一步是改善查询性能。 +本节探讨了两种关键技术:优化 `ORDER BY` 键和使用物化视图。 +我们将看到这些方法如何将查询时间从秒减少到毫秒。 ## 优化 ORDER BY 键 {#time-series-optimize-order-by} -在尝试其他优化之前,您应该优化它们的排序键,以确保 ClickHouse 产生最快的结果。 -选择正确的键在很大程度上取决于您将要运行的查询。假设我们的大多数查询都是通过 `project` 和 `subproject` 列进行过滤。 -在这种情况下,将它们添加到排序键中是一个好主意 — 以及时间列,因为我们也会通过时间进行查询: +在尝试其他优化之前,应首先优化其排序键,以确保 ClickHouse 能够生成最快的结果。 +选择合适的键在很大程度上取决于您要运行的查询。假设我们的大多数查询根据 `project` 和 `subproject` 列进行过滤。 +在这种情况下,将它们添加到排序键中是个好主意——同时也要包含时间列,因为我们也在按时间查询: 让我们创建另一个版本的表,其列类型与 `wikistat` 相同,但按 `(project, subproject, time)` 排序。 @@ -36,7 +37,7 @@ ENGINE = MergeTree ORDER BY (project, subproject, time); ``` -现在,让我们比较多个查询,以了解我们的排序键表达式对性能的重要性。请注意,我们尚未应用之前的数据类型和编解码优化,因此查询性能差异仅基于排序顺序。 +接下来,让我们比较多个查询,以了解我们的排序键表达式对性能的重要性。请注意,我们尚未应用之前的数据类型和编解码优化,因此任何查询性能差异仅基于排序顺序。 @@ -105,12 +106,14 @@ LIMIT 10; + +
2.968 秒 0.010 秒
## 物化视图 {#time-series-materialized-views} -另一个选项是使用物化视图来聚合和存储热门查询的结果。可以查询这些结果,而不是原始表。假设以下查询在我们的情况下经常执行: +另一种选择是使用物化视图来聚合和存储热门查询的结果。这些结果可以替代原始表进行查询。假设以下查询在我们这个案例中经常被执行: ```sql SELECT path, SUM(hits) AS v @@ -166,11 +169,11 @@ FROM wikistat GROUP BY path, month; ``` -### 回填目标表 {#time-series-backfill-destination-table} +### 填充目标表 {#time-series-backfill-destination-table} -此目标表将在向 `wikistat` 表中插入新记录时填充,因此我们需要进行一些 [回填](/docs/data-modeling/backfilling)。 +这个目标表仅会在向 `wikistat` 表插入新记录时被填充,因此我们需要进行一些 [后填充](/docs/data-modeling/backfilling)。 -最简单的方法是使用 [`INSERT INTO SELECT`](/docs/sql-reference/statements/insert-into#inserting-the-results-of-select) 语句,直接将结果插入到物化视图的目标表 [通过](https://github.com/ClickHouse/examples/tree/main/ClickHouse_vs_ElasticSearch/DataAnalytics#variant-1---directly-inserting-into-the-target-table-by-using-the-materialized-views-transformation-query) 视图的 SELECT 查询 (转换): +最简单的方法是使用 [`INSERT INTO SELECT`](/docs/sql-reference/statements/insert-into#inserting-the-results-of-select) 语句直接插入到物化视图的目标表中,同时 [使用](https://github.com/ClickHouse/examples/tree/main/ClickHouse_vs_ElasticSearch/DataAnalytics#variant-1---directly-inserting-into-the-target-table-by-using-the-materialized-views-transformation-query) 视图的 SELECT 查询(转化): ```sql INSERT INTO wikistat_top @@ -182,14 +185,14 @@ FROM wikistat GROUP BY path, month; ``` -根据原始数据集的基数(我们有 10亿行!),这可能是一个内存密集的方案。或者,您可以使用一种占用最小内存的变体: +根据原始数据集的基数(我们有 10 亿行!),这可能是一个内存密集的方法。或者,您可以使用一种需要最少内存的变体: -* 创建一个 Null 表引擎的临时表 +* 创建一个使用 Null 表引擎的临时表 * 将通常使用的物化视图的副本连接到该临时表 -* 使用 INSERT INTO SELECT 查询,将所有数据从原始数据集复制到该临时表 +* 使用 INSERT INTO SELECT 查询,将原始数据集中的所有数据复制到该临时表 * 删除临时表和临时物化视图。 -通过这种方法,原始数据集的行以块的方式复制到临时表(该表不存储任何这些行),对于每个块的行,计算部分状态并写入目标表,这些状态在后台被逐步合并。 +通过这种方法,原始数据集中的行按块复制到临时表(该表不存储这些行),对于每块行,计算并写入目标表的部分状态,而这些状态在后台逐步合并。 ```sql CREATE TABLE wikistat_backfill @@ -203,7 +206,7 @@ CREATE TABLE wikistat_backfill ENGINE = Null; ``` -接下来,我们将创建一个物化视图,从 `wikistat_backfill` 读取并写入 `wikistat_top`。 +接下来,我们将创建一个物化视图,从 `wikistat_backfill` 读取并写入 `wikistat_top` ```sql CREATE MATERIALIZED VIEW wikistat_backfill_top_mv @@ -217,7 +220,7 @@ FROM wikistat_backfill GROUP BY path, month; ``` -然后最后,我们将从初始的 `wikistat` 表填充 `wikistat_backfill`: +然后,最后,我们将从初始的 `wikistat` 表填充 `wikistat_backfill`: ```sql INSERT INTO wikistat_backfill @@ -225,14 +228,14 @@ SELECT * FROM wikistat; ``` -一旦那个查询完成,我们可以删除回填表和物化视图: +一旦查询完成,我们可以删除后填充表和物化视图: ```sql DROP VIEW wikistat_backfill_top_mv; DROP TABLE wikistat_backfill; ``` -现在我们可以查询物化视图,而不是原始表: +现在,我们可以查询物化视图,而不是原始表: ```sql SELECT path, sum(hits) AS hits @@ -261,4 +264,4 @@ LIMIT 10; ``` 我们的性能提升非常显著。 -之前计算这个查询的答案需要稍微超过 2 秒,而现在仅需 4 毫秒。 +之前计算这个查询的答案需要超过 2 秒,现在只需 4 毫秒。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/05_query-performance.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/05_query-performance.md.hash new file mode 100644 index 00000000000..784c9116be0 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/05_query-performance.md.hash @@ -0,0 +1 @@ +b4fc30fe1318615e diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/06_materialized-view-rollup.mdx b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/06_materialized-view-rollup.mdx new file mode 100644 index 00000000000..be16a8917ce --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/06_materialized-view-rollup.mdx @@ -0,0 +1,255 @@ +--- +'title': '使用物化视图构建快速时间序列分析的汇总' +'slug': '/knowledgebase/materialized-view-rollup-timeseries' +'description': '端到端示例,创建原始事件表、汇总表和用于低延迟分析的物化视图。' +'keywords': +- 'materialized view' +- 'rollup' +- 'aggregate' +- 'timeseries' +- 'tutorial' +'doc_type': 'guide' +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +> 本教程向您展示如何维护来自高流量事件表的预聚合汇总,使用 [**物化视图**](/materialized-views)。您将创建三个对象:一个原始表、一个汇总表,以及自动写入汇总的物化视图。 + +## 何时使用此模式 {#when-to-use} + +在以下情况下使用此模式: +- 您有一个 **只追加事件流**(点击、页面浏览、物联网、日志)。 +- 大多数查询是针对时间范围的 **聚合**(每分钟/小时/天)。 +- 您希望在不重新扫描所有原始行的情况下实现 **一致的亚秒读取**。 + + + +## 创建原始事件表 {#create-raw-events-table} + +```sql +CREATE TABLE events_raw +( + event_time DateTime, + user_id UInt64, + country LowCardinality(String), + event_type LowCardinality(String), + value Float64 +) +ENGINE = MergeTree +PARTITION BY toYYYYMM(event_time) +ORDER BY (event_time, user_id) +TTL event_time + INTERVAL 90 DAY DELETE +``` + +**注意** + +- `PARTITION BY toYYYYMM(event_time)` 保持分区小且易于删除。 +- `ORDER BY (event_time, user_id)` 支持时间边界查询 + 二级过滤。 +- `LowCardinality(String)` 为分类维度节省内存。 +- `TTL` 在 90 天后清理原始数据(根据您的保留要求进行调整)。 + +## 设计汇总(聚合)表 {#design-rollup} + +我们将预聚合到 **每小时** 的粒度。 +选择您的粒度以匹配最常见的分析窗口。 + +```sql +CREATE TABLE events_rollup_1h +( + bucket_start DateTime, -- start of the hour + country LowCardinality(String), + event_type LowCardinality(String), + users_uniq AggregateFunction(uniqExact, UInt64), + value_sum AggregateFunction(sum, Float64), + value_avg AggregateFunction(avg, Float64), + events_count AggregateFunction(count) +) +ENGINE = AggregatingMergeTree +PARTITION BY toYYYYMM(bucket_start) +ORDER BY (bucket_start, country, event_type) +``` + +我们存储 **聚合状态**(例如,`AggregateFunction(sum, ...)`),它紧凑地表示部分聚合,并可以在稍后合并或最终确定。 + +## 创建填充汇总的物化视图 {#create-materialized-view-to-populate-rollup} + +这个物化视图在插入 `events_raw` 时自动触发,并将 **聚合状态** 写入汇总。 + +```sql +CREATE MATERIALIZED VIEW mv_events_rollup_1h +TO events_rollup_1h +AS +SELECT + toStartOfHour(event_time) AS bucket_start, + country, + event_type, + uniqExactState(user_id) AS users_uniq, + sumState(value) AS value_sum, + avgState(value) AS value_avg, + countState() AS events_count +FROM events_raw +GROUP BY bucket_start, country, event_type; +``` + +## 插入一些示例数据 {#insert-some-sample-data} + +插入一些示例数据: + +```sql +INSERT INTO events_raw VALUES + (now() - INTERVAL 4 SECOND, 101, 'US', 'view', 1), + (now() - INTERVAL 3 SECOND, 101, 'US', 'click', 1), + (now() - INTERVAL 2 SECOND, 202, 'DE', 'view', 1), + (now() - INTERVAL 1 SECOND, 101, 'US', 'view', 1); +``` + +## 查询汇总 {#querying-the-rollup} + +您可以在读取时 **合并** 状态,或 **最终确定** 它们: + + + + +```sql +SELECT + bucket_start, + country, + event_type, + uniqExactMerge(users_uniq) AS users, + sumMerge(value_sum) AS value_sum, + avgMerge(value_avg) AS value_avg, + countMerge(events_count) AS events +FROM events_rollup_1h +WHERE bucket_start >= now() - INTERVAL 1 DAY +GROUP BY ALL +ORDER BY bucket_start, country, event_type; +``` + + + + +```sql +SELECT + bucket_start, + country, + event_type, + uniqExactMerge(users_uniq) AS users, + sumMerge(value_sum) AS value_sum, + avgMerge(value_avg) AS value_avg, + countMerge(events_count) AS events +FROM events_rollup_1h +WHERE bucket_start >= now() - INTERVAL 1 DAY +GROUP BY ALL +ORDER BY bucket_start, country, event_type +SETTINGS final = 1; -- or use SELECT ... FINAL +``` + + + + +
+:::tip +如果您希望读取始终命中汇总,您可以创建第二个 **物化视图**,将 *最终确定* 的数字写入同一小时粒度的“普通” `MergeTree` 表。 +状态提供更大的灵活性,而最终确定的数字提供稍微简化的读取。 +::: + +## 针对主键中的字段过滤以获得最佳性能 {#filtering-performance} + +您可以使用 `EXPLAIN` 命令查看索引如何用于修剪数据: + +```sql title="Query" +EXPLAIN indexes=1 +SELECT * +FROM events_rollup_1h +WHERE bucket_start BETWEEN now() - INTERVAL 3 DAY AND now() + AND country = 'US'; +``` + +```response title="Response" + ┌─explain────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ +1. │ Expression ((Project names + Projection)) │ +2. │ Expression │ +3. │ ReadFromMergeTree (default.events_rollup_1h) │ +4. │ Indexes: │ +5. │ MinMax │ +6. │ Keys: │ +7. │ bucket_start │ +8. │ Condition: and((bucket_start in (-Inf, 1758550242]), (bucket_start in [1758291042, +Inf))) │ +9. │ Parts: 1/1 │ +10. │ Granules: 1/1 │ +11. │ Partition │ +12. │ Keys: │ +13. │ toYYYYMM(bucket_start) │ +14. │ Condition: and((toYYYYMM(bucket_start) in (-Inf, 202509]), (toYYYYMM(bucket_start) in [202509, +Inf))) │ +15. │ Parts: 1/1 │ +16. │ Granules: 1/1 │ +17. │ PrimaryKey │ +18. │ Keys: │ +19. │ bucket_start │ +20. │ country │ +21. │ Condition: and((country in ['US', 'US']), and((bucket_start in (-Inf, 1758550242]), (bucket_start in [1758291042, +Inf)))) │ +22. │ Parts: 1/1 │ +23. │ Granules: 1/1 │ + └────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ +``` + +上面的查询执行计划显示正在使用三种类型的索引: +一个 MinMax 索引、一个分区索引和一个主键索引。 +每个索引使用我们主键中指定的字段:`(bucket_start, country, event_type)`。 +为了获得最佳过滤性能,您需要确保查询利用主键字段来修剪数据。 + +## 常见变体 {#common-variations} + +- **不同的粒度**:添加每日汇总: + +```sql +CREATE TABLE events_rollup_1d +( + bucket_start Date, + country LowCardinality(String), + event_type LowCardinality(String), + users_uniq AggregateFunction(uniqExact, UInt64), + value_sum AggregateFunction(sum, Float64), + value_avg AggregateFunction(avg, Float64), + events_count AggregateFunction(count) +) +ENGINE = AggregatingMergeTree +PARTITION BY toYYYYMM(bucket_start) +ORDER BY (bucket_start, country, event_type); +``` + +然后是第二个物化视图: + +```sql +CREATE MATERIALIZED VIEW mv_events_rollup_1d +TO events_rollup_1d +AS +SELECT + toDate(event_time) AS bucket_start, + country, + event_type, + uniqExactState(user_id), + sumState(value), + avgState(value), + countState() +FROM events_raw +GROUP BY ALL; +``` + +- **压缩**:对大列应用编解码器(例如:`Codec(ZSTD(3))`)在原始表上。 +- **成本控制**:将重的保留推向原始表,保持长寿命汇总。 +- **回填**:在加载历史数据时,插入到 `events_raw` 并让物化视图自动构建汇总。对于现有行,如果适合,请在创建物化视图时使用 `POPULATE` 或 `INSERT SELECT`。 + +## 清理和保留 {#clean-up-and-retention} + +- 增加原始数据的 TTL(例如,30/90 天),但保持汇总的数据时间更长(例如,1 年)。 +- 如果启用了分层,您还可以使用 **TTL 移动** 旧片段到更便宜的存储。 + +## 故障排除 {#troubleshooting} + +- 物化视图未更新?检查插入是否进入 **events_raw**(而不是汇总表),以及物化视图目标是否正确(`TO events_rollup_1h`)。 +- 查询缓慢?确认它们命中汇总(直接查询汇总表),并且时间过滤与汇总粒度对齐。 +- 回填不匹配?使用 `SYSTEM FLUSH LOGS` 并检查 `system.query_log` / `system.parts` 确认插入和合并。 + +
diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/06_materialized-view-rollup.mdx.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/06_materialized-view-rollup.mdx.hash new file mode 100644 index 00000000000..5476f61e23c --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/06_materialized-view-rollup.mdx.hash @@ -0,0 +1 @@ +762b23f024efa9eb diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/analysis-functions.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/analysis-functions.md.hash deleted file mode 100644 index 63c273dbd87..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/analysis-functions.md.hash +++ /dev/null @@ -1 +0,0 @@ -dec66b1fff8499f7 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/basic-operations.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/basic-operations.md.hash deleted file mode 100644 index 9e806575335..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/basic-operations.md.hash +++ /dev/null @@ -1 +0,0 @@ -36cb05a55797a97d diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/date-time-data-types.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/date-time-data-types.md.hash deleted file mode 100644 index c266e876fc0..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/date-time-data-types.md.hash +++ /dev/null @@ -1 +0,0 @@ -d347361d4498e597 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/index.md index 808771df931..0f85c8e2b1e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/index.md @@ -1,23 +1,24 @@ --- -'description': '用于时间序列用例指南的 INDEX 页面。' +'description': '时间序列用例指南的索引页。' 'slug': '/use-cases/time-series' 'title': '时间序列' 'pagination_prev': null 'pagination_next': null +'doc_type': 'guide' --- -欢迎来到我们的时间序列用例指南。在本指南中,您将学习如何设置和使用 ClickHouse 进行时间序列分析。 +欢迎来到我们的时间序列用例指南。在本指南中,您将学习如何设置并使用 ClickHouse 进行时间序列处理。 -时间序列数据在现代分析中无处不在。从系统指标和应用日志到业务事件和传感器读数,随着时间收集的数据点帮助我们理解系统和过程中的趋势、模式和异常。 +时间序列数据在现代分析中随处可见。从系统指标和应用程序日志到业务事件和传感器读数,随时间收集的数据点帮助我们了解系统和流程中的趋势、模式和异常。 -ClickHouse 擅长处理时间序列数据,提供强大的存储和分析功能。无论您是在构建简单的监控仪表板,还是实时处理 PB 级的传感器数据,ClickHouse 都提供所需的工具和性能。 +ClickHouse 在处理时间序列数据方面表现出色,提供强大的存储和分析功能。无论您是在构建简单的监控仪表板还是实时处理 PB 级的传感器数据,ClickHouse 都提供您所需的工具和性能。 -本指南将带您了解在 ClickHouse 中处理时间序列数据所需知道的一切,从基本概念到高级优化技术。您将学习如何: +本指南将带您了解有关在 ClickHouse 中处理时间序列数据的所有知识,从基本概念到高级优化技术。您将学习如何: -* [为您的用例选择合适的日期和时间数据类型](./date-time-data-types.md) -* [执行常见的时间序列操作和聚合](./basic-operations.md) -* [对基于时间的数据应用专业分析函数](./analysis-functions.md) -* [优化时间数据的存储效率](./storage-efficiency.md) -* [调整时间序列工作负载的查询性能](./query-performance.md) +* [为您的用例选择合适的日期和时间数据类型](/use-cases/time-series/date-time-data-types) +* [执行常见的时间序列操作和聚合](/use-cases/time-series/basic-operations) +* [应用针对基于时间数据的专业分析函数](/use-cases/time-series/analysis-functions) +* [优化时间数据的存储效率](/use-cases/time-series/storage-efficiency) +* [调整时间序列工作负载的查询性能](/use-cases/time-series/query-performance) -无论您是时间序列分析的新手,还是希望优化现有实现,本指南将帮助您充分利用 ClickHouse 的时间序列功能。 +无论您是刚接触时间序列分析,还是希望优化现有的实现,本指南都将帮助您充分发挥 ClickHouse 的时间序列能力。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/index.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/index.md.hash index 5e90ebcd4e0..9860bc9d154 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/index.md.hash +++ b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/index.md.hash @@ -1 +1 @@ -d2f4f979431b53cb +11ef0af55147eb22 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/query-performance.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/query-performance.md.hash deleted file mode 100644 index e7d071aff04..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/query-performance.md.hash +++ /dev/null @@ -1 +0,0 @@ -cbc25e3e02895fa2 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/storage-efficiency.md.hash b/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/storage-efficiency.md.hash deleted file mode 100644 index b21c53b6e4a..00000000000 --- a/i18n/zh/docusaurus-plugin-content-docs/current/use-cases/time-series/storage-efficiency.md.hash +++ /dev/null @@ -1 +0,0 @@ -4dfe50d9c619eebb diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/whats-new/changelog/2017.md b/i18n/zh/docusaurus-plugin-content-docs/current/whats-new/changelog/2017.md index 65fbd254699..b4062c984cf 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/whats-new/changelog/2017.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/whats-new/changelog/2017.md @@ -4,6 +4,7 @@ sidebar_position: 10 sidebar_label: '2017' title: '2017 Changelog' description: 'Changelog for 2017' +doc_type: 'changelog' --- ### ClickHouse Release 1.1.54327, 2017-12-21 {#clickhouse-release-1-1-54327-2017-12-21} diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/whats-new/changelog/2018.md b/i18n/zh/docusaurus-plugin-content-docs/current/whats-new/changelog/2018.md index 8f730d6baf7..ed37477fde9 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/whats-new/changelog/2018.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/whats-new/changelog/2018.md @@ -4,6 +4,7 @@ sidebar_position: 9 sidebar_label: '2018' title: '2018 Changelog' description: 'Changelog for 2018' +doc_type: 'changelog' --- ## ClickHouse Release 18.16 {#clickhouse-release-18-16} diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/whats-new/changelog/2019.md b/i18n/zh/docusaurus-plugin-content-docs/current/whats-new/changelog/2019.md index 21de463a3e5..95e699e6604 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/whats-new/changelog/2019.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/whats-new/changelog/2019.md @@ -4,6 +4,7 @@ sidebar_position: 8 sidebar_label: '2019' title: '2019 Changelog' description: 'Changelog for 2019' +doc_type: 'changelog' --- ## ClickHouse Release 19.17 {#clickhouse-release-v19-17} diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/whats-new/changelog/2020.md b/i18n/zh/docusaurus-plugin-content-docs/current/whats-new/changelog/2020.md index 4a2f7bd00a3..c4be50ead1f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/whats-new/changelog/2020.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/whats-new/changelog/2020.md @@ -4,6 +4,7 @@ sidebar_position: 7 sidebar_label: '2020' title: '2020 Changelog' description: 'Changelog for 2020' +doc_type: 'changelog' --- ### ClickHouse release 20.12 {#clickhouse-release-2012} @@ -23,7 +24,6 @@ description: 'Changelog for 2020' * Update timezones info to 2020e. [#18531](https://github.com/ClickHouse/ClickHouse/pull/18531) ([alesapin](https://github.com/alesapin)). - ### ClickHouse release v20.12.4.5-stable, 2020-12-24 {#clickhouse-release-v201245-stable-2020-12-24} #### Bug Fix {#bug-fix-1} @@ -37,7 +37,6 @@ description: 'Changelog for 2020' * Fixed possible segfault in `topK` aggregate function. This closes [#17404](https://github.com/ClickHouse/ClickHouse/issues/17404). [#17845](https://github.com/ClickHouse/ClickHouse/pull/17845) ([Maksim Kita](https://github.com/kitaisreal)). * Fixed empty `system.stack_trace` table when server is running in daemon mode. [#17630](https://github.com/ClickHouse/ClickHouse/pull/17630) ([Amos Bird](https://github.com/amosbird)). - ### ClickHouse release v20.12.3.3-stable, 2020-12-13 {#clickhouse-release-v201233-stable-2020-12-13} #### Backward Incompatible Change {#backward-incompatible-change} @@ -158,7 +157,6 @@ description: 'Changelog for 2020' * Fix UBSan report in cache dictionaries. This closes [#12641](https://github.com/ClickHouse/ClickHouse/issues/12641). [#16763](https://github.com/ClickHouse/ClickHouse/pull/16763) ([alexey-milovidov](https://github.com/alexey-milovidov)). * Fix UBSan report when trying to convert infinite floating point number to integer. This closes [#14190](https://github.com/ClickHouse/ClickHouse/issues/14190). [#16677](https://github.com/ClickHouse/ClickHouse/pull/16677) ([alexey-milovidov](https://github.com/alexey-milovidov)). - ## ClickHouse release 20.11 {#clickhouse-release-2011} ### ClickHouse release v20.11.7.16-stable, 2021-03-02 {#clickhouse-release-v2011716-stable-2021-03-02} @@ -223,8 +221,6 @@ description: 'Changelog for 2020' * Update timezones info to 2020e. [#18531](https://github.com/ClickHouse/ClickHouse/pull/18531) ([alesapin](https://github.com/alesapin)). - - ### ClickHouse release v20.11.6.6-stable, 2020-12-24 {#clickhouse-release-v201166-stable-2020-12-24} #### Bug Fix {#bug-fix-4} @@ -270,14 +266,12 @@ description: 'Changelog for 2020' * Fixed inconsistent behavior caused by `select_sequential_consistency` for optimized trivial count query and system.tables. [#16309](https://github.com/ClickHouse/ClickHouse/pull/16309) ([Hao Chen](https://github.com/haoch)). * Throw error when use ColumnTransformer replace non exist column. [#16183](https://github.com/ClickHouse/ClickHouse/pull/16183) ([hexiaoting](https://github.com/hexiaoting)). - ### ClickHouse release v20.11.3.3-stable, 2020-11-13 {#clickhouse-release-v201133-stable-2020-11-13} #### Bug Fix {#bug-fix-5} * Fix rare silent crashes when query profiler is on and ClickHouse is installed on OS with glibc version that has (supposedly) broken asynchronous unwind tables for some functions. This fixes [#15301](https://github.com/ClickHouse/ClickHouse/issues/15301). This fixes [#13098](https://github.com/ClickHouse/ClickHouse/issues/13098). [#16846](https://github.com/ClickHouse/ClickHouse/pull/16846) ([alexey-milovidov](https://github.com/alexey-milovidov)). - ### ClickHouse release v20.11.2.1, 2020-11-11 {#clickhouse-release-v201121-2020-11-11} #### Backward Incompatible Change {#backward-incompatible-change-1} @@ -397,7 +391,6 @@ description: 'Changelog for 2020' * Simplify Sys/V init script. [#14135](https://github.com/ClickHouse/ClickHouse/pull/14135) ([alexey-milovidov](https://github.com/alexey-milovidov)). * Added `boost::program_options` to `db_generator` in order to increase its usability. This closes [#15940](https://github.com/ClickHouse/ClickHouse/issues/15940). [#15973](https://github.com/ClickHouse/ClickHouse/pull/15973) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)). - ## ClickHouse release 20.10 {#clickhouse-release-2010} ### ClickHouse release v20.10.7.4-stable, 2020-12-24 {#clickhouse-release-v201074-stable-2020-12-24} @@ -439,7 +432,6 @@ description: 'Changelog for 2020' * Fixed uncontrolled growth of `TDigest`. [#16680](https://github.com/ClickHouse/ClickHouse/pull/16680) ([hrissan](https://github.com/hrissan)). * Fixed remote query failure when using suffix `if` in Aggregate function. This fixes [#16574](https://github.com/ClickHouse/ClickHouse/issues/16574) fixes [#16231](https://github.com/ClickHouse/ClickHouse/issues/16231) [#16610](https://github.com/ClickHouse/ClickHouse/pull/16610) ([Winter Zhang](https://github.com/zhang2014)). - ### ClickHouse release v20.10.4.1-stable, 2020-11-13 {#clickhouse-release-v201041-stable-2020-11-13} #### Bug Fix {#bug-fix-8} @@ -457,7 +449,6 @@ description: 'Changelog for 2020' * Workaround for use S3 with nginx server as proxy. Nginx currenty does not accept urls with empty path like http://domain.com?delete, but vanilla aws-sdk-cpp produces this kind of urls. This commit uses patched aws-sdk-cpp version, which makes urls with "/" as path in this cases, like http://domain.com/?delete. [#16813](https://github.com/ClickHouse/ClickHouse/pull/16813) ([ianton-ru](https://github.com/ianton-ru)). - ### ClickHouse release v20.10.3.30, 2020-10-28 {#clickhouse-release-v2010330-2020-10-28} #### Backward Incompatible Change {#backward-incompatible-change-2} @@ -668,7 +659,6 @@ description: 'Changelog for 2020' * Use std::filesystem::path in ConfigProcessor for concatenating file paths. [#14558](https://github.com/ClickHouse/ClickHouse/pull/14558) ([Bharat Nallan](https://github.com/bharatnc)). * Fix debug assertion in `bitShiftLeft()` when called with negative big integer. [#14697](https://github.com/ClickHouse/ClickHouse/pull/14697) ([Artem Zuikov](https://github.com/4ertus2)). - ## ClickHouse release 20.9 {#clickhouse-release-209} ### ClickHouse release v20.9.7.11-stable, 2020-12-07 {#clickhouse-release-v209711-stable-2020-12-07} @@ -702,7 +692,6 @@ description: 'Changelog for 2020' * Update embedded timezone data to version 2020d (also update cctz to the latest master). [#17204](https://github.com/ClickHouse/ClickHouse/pull/17204) ([filimonov](https://github.com/filimonov)). - ### ClickHouse release v20.9.6.14-stable, 2020-11-20 {#clickhouse-release-v209614-stable-2020-11-20} #### Improvement {#improvement-5} @@ -724,7 +713,6 @@ description: 'Changelog for 2020' * fixes [#16574](https://github.com/ClickHouse/ClickHouse/issues/16574) fixes [#16231](https://github.com/ClickHouse/ClickHouse/issues/16231) fix remote query failure when using 'if' suffix aggregate function. [#16610](https://github.com/ClickHouse/ClickHouse/pull/16610) ([Winter Zhang](https://github.com/zhang2014)). * Query is finished faster in case of exception. Cancel execution on remote replicas if exception happens. [#15578](https://github.com/ClickHouse/ClickHouse/pull/15578) ([Azat Khuzhin](https://github.com/azat)). - ### ClickHouse release v20.9.5.5-stable, 2020-11-13 {#clickhouse-release-v20955-stable-2020-11-13} #### Bug Fix {#bug-fix-12} @@ -737,7 +725,6 @@ description: 'Changelog for 2020' * Fixed the inconsistent behaviour when a part of return data could be dropped because the set for its filtration wasn't created. [#16308](https://github.com/ClickHouse/ClickHouse/pull/16308) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)). * Fix bug with MySQL database. When MySQL server used as database engine is down some queries raise Exception, because they try to get tables from disabled server, while it's unnecessary. For example, query `SELECT ... FROM system.parts` should work only with MergeTree tables and don't touch MySQL database at all. [#16032](https://github.com/ClickHouse/ClickHouse/pull/16032) ([Kruglov Pavel](https://github.com/Avogar)). - ### ClickHouse release v20.9.4.76-stable (2020-10-29) {#clickhouse-release-v209476-stable-2020-10-29} #### Bug Fix {#bug-fix-13} @@ -771,7 +758,6 @@ description: 'Changelog for 2020' * Now it's allowed to execute `ALTER ... ON CLUSTER` queries regardless of the `` setting in cluster config. [#16075](https://github.com/ClickHouse/ClickHouse/pull/16075) ([alesapin](https://github.com/alesapin)). * Unfold `{database}`, `{table}` and `{uuid}` macros in `ReplicatedMergeTree` arguments on table creation. [#16160](https://github.com/ClickHouse/ClickHouse/pull/16160) ([tavplubix](https://github.com/tavplubix)). - ### ClickHouse release v20.9.3.45-stable (2020-10-09) {#clickhouse-release-v209345-stable-2020-10-09} #### Bug Fix {#bug-fix-14} @@ -802,7 +788,6 @@ description: 'Changelog for 2020' * Now it's possible to change the type of version column for `VersionedCollapsingMergeTree` with `ALTER` query. [#15442](https://github.com/ClickHouse/ClickHouse/pull/15442) ([alesapin](https://github.com/alesapin)). - ### ClickHouse release v20.9.2.20, 2020-09-22 {#clickhouse-release-v209220-2020-09-22} #### Backward Incompatible Change {#backward-incompatible-change-3} @@ -877,8 +862,6 @@ description: 'Changelog for 2020' * Fix the logic in backport script. In previous versions it was triggered for any labels of 100% red color. It was strange. [#14433](https://github.com/ClickHouse/ClickHouse/pull/14433) ([alexey-milovidov](https://github.com/alexey-milovidov)). * Integration tests use default base config. All config changes are explicit with main_configs, user_configs and dictionaries parameters for instance. [#13647](https://github.com/ClickHouse/ClickHouse/pull/13647) ([Ilya Yatsishin](https://github.com/qoega)). - - ## ClickHouse release 20.8 {#clickhouse-release-208} ### ClickHouse release v20.8.12.2-lts, 2021-01-16 {#clickhouse-release-v208122-lts-2021-01-16} @@ -888,7 +871,6 @@ description: 'Changelog for 2020' * Fix *If combinator with unary function and Nullable types. [#18806](https://github.com/ClickHouse/ClickHouse/pull/18806) ([Azat Khuzhin](https://github.com/azat)). * Restrict merges from wide to compact parts. In case of vertical merge it led to broken result part. [#18381](https://github.com/ClickHouse/ClickHouse/pull/18381) ([Anton Popov](https://github.com/CurtizJ)). - ### ClickHouse release v20.8.11.17-lts, 2020-12-25 {#clickhouse-release-v2081117-lts-2020-12-25} #### Bug Fix {#bug-fix-17} @@ -897,7 +879,6 @@ description: 'Changelog for 2020' * Fixed `value is too short` error when executing `toType(...)` functions (`toDate`, `toUInt32`, etc) with argument of type `Nullable(String)`. Now such functions return `NULL` on parsing errors instead of throwing exception. Fixes [#7673](https://github.com/ClickHouse/ClickHouse/issues/7673). [#18445](https://github.com/ClickHouse/ClickHouse/pull/18445) ([tavplubix](https://github.com/tavplubix)). * Fix possible crashes in aggregate functions with combinator `Distinct`, while using two-level aggregation. Fixes [#17682](https://github.com/ClickHouse/ClickHouse/issues/17682). [#18365](https://github.com/ClickHouse/ClickHouse/pull/18365) ([Anton Popov](https://github.com/CurtizJ)). - ### ClickHouse release v20.8.10.13-lts, 2020-12-24 {#clickhouse-release-v2081013-lts-2020-12-24} #### Bug Fix {#bug-fix-18} @@ -922,7 +903,6 @@ description: 'Changelog for 2020' * Fixed the issue when query optimization was producing wrong result if query contains `ARRAY JOIN`. [#17887](https://github.com/ClickHouse/ClickHouse/pull/17887) ([sundyli](https://github.com/sundy-li)). * Query is finished faster in case of exception. Cancel execution on remote replicas if exception happens. [#15578](https://github.com/ClickHouse/ClickHouse/pull/15578) ([Azat Khuzhin](https://github.com/azat)). - ### ClickHouse release v20.8.6.6-lts, 2020-11-13 {#clickhouse-release-v20866-lts-2020-11-13} #### Bug Fix {#bug-fix-19} @@ -935,7 +915,6 @@ description: 'Changelog for 2020' * Fixed the inconsistent behaviour when a part of return data could be dropped because the set for its filtration wasn't created. [#16308](https://github.com/ClickHouse/ClickHouse/pull/16308) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)). * Fix bug with MySQL database. When MySQL server used as database engine is down some queries raise Exception, because they try to get tables from disabled server, while it's unnecessary. For example, query `SELECT ... FROM system.parts` should work only with MergeTree tables and don't touch MySQL database at all. [#16032](https://github.com/ClickHouse/ClickHouse/pull/16032) ([Kruglov Pavel](https://github.com/Avogar)). - ### ClickHouse release v20.8.5.45-lts, 2020-10-29 {#clickhouse-release-v208545-lts-2020-10-29} #### Bug Fix {#bug-fix-20} @@ -969,7 +948,6 @@ description: 'Changelog for 2020' * Now it's allowed to execute `ALTER ... ON CLUSTER` queries regardless of the `` setting in cluster config. [#16075](https://github.com/ClickHouse/ClickHouse/pull/16075) ([alesapin](https://github.com/alesapin)). * Unfold `{database}`, `{table}` and `{uuid}` macros in `ReplicatedMergeTree` arguments on table creation. [#16159](https://github.com/ClickHouse/ClickHouse/pull/16159) ([tavplubix](https://github.com/tavplubix)). - ### ClickHouse release v20.8.4.11-lts, 2020-10-09 {#clickhouse-release-v208411-lts-2020-10-09} #### Bug Fix {#bug-fix-21} @@ -1004,7 +982,6 @@ description: 'Changelog for 2020' * Now it's possible to change the type of version column for `VersionedCollapsingMergeTree` with `ALTER` query. [#15442](https://github.com/ClickHouse/ClickHouse/pull/15442) ([alesapin](https://github.com/alesapin)). - ### ClickHouse release v20.8.3.18-stable, 2020-09-18 {#clickhouse-release-v208318-stable-2020-09-18} #### Bug Fix {#bug-fix-22} @@ -1026,7 +1003,6 @@ description: 'Changelog for 2020' * Speed up server shutdown process if there are ongoing S3 requests. [#14496](https://github.com/ClickHouse/ClickHouse/pull/14496) ([Pavel Kovalenko](https://github.com/Jokser)). * Support custom codecs in compact parts. [#12183](https://github.com/ClickHouse/ClickHouse/pull/12183) ([Anton Popov](https://github.com/CurtizJ)). - ### ClickHouse release v20.8.2.3-stable, 2020-09-08 {#clickhouse-release-v20823-stable-2020-09-08} #### Backward Incompatible Change {#backward-incompatible-change-4} @@ -1167,7 +1143,6 @@ description: 'Changelog for 2020' * Skip PR's from robot-clickhouse. [#13489](https://github.com/ClickHouse/ClickHouse/pull/13489) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)). * Move Dockerfiles from integration tests to `docker/test` directory. docker_compose files are available in `runner` docker container. Docker images are built in CI and not in integration tests. [#13448](https://github.com/ClickHouse/ClickHouse/pull/13448) ([Ilya Yatsishin](https://github.com/qoega)). - ## ClickHouse release 20.7 {#clickhouse-release-207} ### ClickHouse release v20.7.2.30-stable, 2020-08-31 {#clickhouse-release-v207230-stable-2020-08-31} @@ -1361,7 +1336,6 @@ description: 'Changelog for 2020' * Add compiler option to control that stack frames are not too large. This will help to run the code in fibers with small stack size. [#11524](https://github.com/ClickHouse/ClickHouse/pull/11524) ([alexey-milovidov](https://github.com/alexey-milovidov)). * Update gitignore-files. [#13447](https://github.com/ClickHouse/ClickHouse/pull/13447) ([vladimir-golovchenko](https://github.com/vladimir-golovchenko)). - ## ClickHouse release 20.6 {#clickhouse-release-206} ### ClickHouse release v20.6.3.28-stable {#clickhouse-release-v206328-stable} @@ -1546,7 +1520,6 @@ description: 'Changelog for 2020' * Install `ca-certificates` before the first `apt-get update` in Dockerfile. [#12095](https://github.com/ClickHouse/ClickHouse/pull/12095) ([Ivan Blinkov](https://github.com/blinkov)). - ### ClickHouse release v20.5.2.7-stable 2020-07-02 {#clickhouse-release-v20527-stable-2020-07-02} #### Backward Incompatible Change {#backward-incompatible-change-7} @@ -1900,7 +1873,6 @@ description: 'Changelog for 2020' * Fix FreeBSD build. [#10150](https://github.com/ClickHouse/ClickHouse/pull/10150) ([Ivan](https://github.com/abyss7)). * Add new build for query tests using pytest framework. [#10039](https://github.com/ClickHouse/ClickHouse/pull/10039) ([Ivan](https://github.com/abyss7)). - ## ClickHouse release v20.4 {#clickhouse-release-v204} ### ClickHouse release v20.4.8.99-stable 2020-08-10 {#clickhouse-release-v204899-stable-2020-08-10} @@ -1976,7 +1948,6 @@ description: 'Changelog for 2020' * Install `ca-certificates` before the first `apt-get update` in Dockerfile. [#12095](https://github.com/ClickHouse/ClickHouse/pull/12095) ([Ivan Blinkov](https://github.com/blinkov)). - ### ClickHouse release v20.4.6.53-stable 2020-06-25 {#clickhouse-release-v204653-stable-2020-06-25} #### Bug Fix {#bug-fix-29} @@ -2016,7 +1987,6 @@ description: 'Changelog for 2020' * Fix several non significant errors in unit tests. [#11262](https://github.com/ClickHouse/ClickHouse/pull/11262) ([alesapin](https://github.com/alesapin)). * Fix (false) MSan report in MergeTreeIndexFullText. The issue first appeared in [#9968](https://github.com/ClickHouse/ClickHouse/issues/9968). [#10801](https://github.com/ClickHouse/ClickHouse/pull/10801) ([alexey-milovidov](https://github.com/alexey-milovidov)). - ### ClickHouse release v20.4.5.36-stable 2020-06-10 {#clickhouse-release-v204536-stable-2020-06-10} #### Bug Fix {#bug-fix-30} @@ -2381,10 +2351,8 @@ No changes compared to v20.4.3.16-stable. * Add support for `clang-tidy` in `packager` script. [#9625](https://github.com/ClickHouse/ClickHouse/pull/9625) ([alexey-milovidov](https://github.com/alexey-milovidov)) * Add ability to use unbundled msgpack. [#10168](https://github.com/ClickHouse/ClickHouse/pull/10168) ([Azat Khuzhin](https://github.com/azat)) - ## ClickHouse release v20.3 {#clickhouse-release-v203} - ### ClickHouse release v20.3.21.2-lts, 2020-11-02 {#clickhouse-release-v203212-lts-2020-11-02} #### Bug Fix {#bug-fix-33} @@ -2393,7 +2361,6 @@ No changes compared to v20.4.3.16-stable. * Fix incorrect empty result for query from `Distributed` table if query has `WHERE`, `PREWHERE` and `GLOBAL IN`. Fixes [#15792](https://github.com/ClickHouse/ClickHouse/issues/15792). [#15933](https://github.com/ClickHouse/ClickHouse/pull/15933) ([Nikolai Kochetov](https://github.com/KochetovNicolai)). * Fix missing or excessive headers in `TSV/CSVWithNames` formats. This fixes [#12504](https://github.com/ClickHouse/ClickHouse/issues/12504). [#13343](https://github.com/ClickHouse/ClickHouse/pull/13343) ([Azat Khuzhin](https://github.com/azat)). - ### ClickHouse release v20.3.20.6-lts, 2020-10-09 {#clickhouse-release-v203206-lts-2020-10-09} #### Bug Fix {#bug-fix-34} @@ -2404,7 +2371,6 @@ No changes compared to v20.4.3.16-stable. * Fix to make predicate push down work when subquery contains finalizeAggregation function. Fixes [#14847](https://github.com/ClickHouse/ClickHouse/issues/14847). [#14937](https://github.com/ClickHouse/ClickHouse/pull/14937) ([filimonov](https://github.com/filimonov)). * Concurrent `ALTER ... REPLACE/MOVE PARTITION ...` queries might cause deadlock. It's fixed. [#13626](https://github.com/ClickHouse/ClickHouse/pull/13626) ([tavplubix](https://github.com/tavplubix)). - ### ClickHouse release v20.3.19.4-lts, 2020-09-18 {#clickhouse-release-v203194-lts-2020-09-18} #### Bug Fix {#bug-fix-35} @@ -2417,7 +2383,6 @@ No changes compared to v20.4.3.16-stable. * Support custom codecs in compact parts. [#12183](https://github.com/ClickHouse/ClickHouse/pull/12183) ([Anton Popov](https://github.com/CurtizJ)). - ### ClickHouse release v20.3.18.10-lts, 2020-09-08 {#clickhouse-release-v2031810-lts-2020-09-08} #### Bug Fix {#bug-fix-36} @@ -2441,7 +2406,6 @@ No changes compared to v20.4.3.16-stable. * Fix UBSan report (adding zero to nullptr) in HashTable that appeared after migration to clang-10. [#10638](https://github.com/ClickHouse/ClickHouse/pull/10638) ([alexey-milovidov](https://github.com/alexey-milovidov)). - ### ClickHouse release v20.3.17.173-lts, 2020-08-15 {#clickhouse-release-v20317173-lts-2020-08-15} #### Bug Fix {#bug-fix-37} @@ -2451,7 +2415,6 @@ No changes compared to v20.4.3.16-stable. * Fix queries with constant columns and `ORDER BY` prefix of primary key. [#13396](https://github.com/ClickHouse/ClickHouse/pull/13396) ([Anton Popov](https://github.com/CurtizJ)). * Return passed number for numbers with MSB set in roundUpToPowerOfTwoOrZero(). [#13234](https://github.com/ClickHouse/ClickHouse/pull/13234) ([Azat Khuzhin](https://github.com/azat)). - ### ClickHouse release v20.3.16.165-lts 2020-08-10 {#clickhouse-release-v20316165-lts-2020-08-10} #### Bug Fix {#bug-fix-38} @@ -2515,7 +2478,6 @@ No changes compared to v20.4.3.16-stable. * Index not used for IN operator with literals, performance regression introduced around v19.3. This fixes [#10574](https://github.com/ClickHouse/ClickHouse/issues/10574). [#12062](https://github.com/ClickHouse/ClickHouse/pull/12062) ([nvartolomei](https://github.com/nvartolomei)). - ### ClickHouse release v20.3.12.112-lts 2020-06-25 {#clickhouse-release-v20312112-lts-2020-06-25} #### Bug Fix {#bug-fix-39} @@ -2543,7 +2505,6 @@ No changes compared to v20.4.3.16-stable. * Fix memory leak when exception is thrown in the middle of aggregation with -State functions. This fixes [#8995](https://github.com/ClickHouse/ClickHouse/issues/8995). [#11496](https://github.com/ClickHouse/ClickHouse/pull/11496) ([alexey-milovidov](https://github.com/alexey-milovidov)). * Fix wrong results of distributed queries when alias could override qualified column name. Fixes [#9672](https://github.com/ClickHouse/ClickHouse/issues/9672) [#9714](https://github.com/ClickHouse/ClickHouse/issues/9714). [#9972](https://github.com/ClickHouse/ClickHouse/pull/9972) ([Artem Zuikov](https://github.com/4ertus2)). - ### ClickHouse release v20.3.11.97-lts 2020-06-10 {#clickhouse-release-v2031197-lts-2020-06-10} #### New Feature {#new-feature-9} @@ -2628,7 +2589,6 @@ No changes compared to v20.4.3.16-stable. * Fixed improper shutdown of `Distributed` storage. [#10491](https://github.com/ClickHouse/ClickHouse/pull/10491) ([Azat Khuzhin](https://github.com/azat)). * Fixed numeric overflow in `simpleLinearRegression` over large integers. [#10474](https://github.com/ClickHouse/ClickHouse/pull/10474) ([hcz](https://github.com/hczhcz)). - #### Build/Testing/Packaging Improvement {#buildtestingpackaging-improvement-18} * Fix UBSan report in LZ4 library. [#10631](https://github.com/ClickHouse/ClickHouse/pull/10631) ([alexey-milovidov](https://github.com/alexey-milovidov)). @@ -2641,7 +2601,6 @@ No changes compared to v20.4.3.16-stable. * Fix error `the BloomFilter false positive must be a double number between 0 and 1` [#10551](https://github.com/ClickHouse/ClickHouse/issues/10551). [#10569](https://github.com/ClickHouse/ClickHouse/pull/10569) ([Winter Zhang](https://github.com/zhang2014)). - ### ClickHouse release v20.3.8.53, 2020-04-23 {#clickhouse-release-v203853-2020-04-23} #### Bug Fix {#bug-fix-43} @@ -2717,7 +2676,6 @@ No changes compared to v20.4.3.16-stable. * Fix integration test `test_settings_constraints`. [#9962](https://github.com/ClickHouse/ClickHouse/pull/9962) ([Vitaly Baranov](https://github.com/vitlibar)). * Removed dependency on `clock_getres`. [#9833](https://github.com/ClickHouse/ClickHouse/pull/9833) ([alexey-milovidov](https://github.com/alexey-milovidov)). - ### ClickHouse release v20.3.5.21, 2020-03-27 {#clickhouse-release-v203521-2020-03-27} #### Bug Fix {#bug-fix-46} @@ -2736,14 +2694,12 @@ No changes compared to v20.4.3.16-stable. * Remove order by stage from mutations because we read from a single ordered part in a single thread. Also add check that the order of rows in mutation is ordered in sorting key order and this order is not violated. [#9886](https://github.com/ClickHouse/ClickHouse/pull/9886) ([alesapin](https://github.com/alesapin)). - ### ClickHouse release v20.3.4.10, 2020-03-20 {#clickhouse-release-v203410-2020-03-20} #### Bug Fix {#bug-fix-47} * This release also contains all bug fixes from 20.1.8.41 * Fix missing `rows_before_limit_at_least` for queries over http (with processors pipeline). This fixes [#9730](https://github.com/ClickHouse/ClickHouse/issues/9730). [#9757](https://github.com/ClickHouse/ClickHouse/pull/9757) ([Nikolai Kochetov](https://github.com/KochetovNicolai)) - ### ClickHouse release v20.3.3.6, 2020-03-17 {#clickhouse-release-v20336-2020-03-17} #### Bug Fix {#bug-fix-48} @@ -2989,7 +2945,6 @@ No changes compared to v20.4.3.16-stable. * Upgrade librdkafka to v1.3.0. Enable bundled `rdkafka` and `gsasl` libraries on Mac OS X. [#9000](https://github.com/ClickHouse/ClickHouse/pull/9000) ([Andrew Onyshchuk](https://github.com/oandrew)) * build fix on GCC 9.2.0 [#9306](https://github.com/ClickHouse/ClickHouse/pull/9306) ([vxider](https://github.com/Vxider)) - ## ClickHouse release v20.1 {#clickhouse-release-v201} ### ClickHouse release v20.1.16.120-stable 2020-60-26 {#clickhouse-release-v20116120-stable-2020-60-26} @@ -3011,21 +2966,18 @@ No changes compared to v20.4.3.16-stable. * Fix memory leak when exception is thrown in the middle of aggregation with -State functions. This fixes [#8995](https://github.com/ClickHouse/ClickHouse/issues/8995). [#11496](https://github.com/ClickHouse/ClickHouse/pull/11496) ([alexey-milovidov](https://github.com/alexey-milovidov)). * Fix usage of primary key wrapped into a function with 'FINAL' modifier and 'ORDER BY' optimization. [#10715](https://github.com/ClickHouse/ClickHouse/pull/10715) ([Anton Popov](https://github.com/CurtizJ)). - ### ClickHouse release v20.1.15.109-stable 2020-06-19 {#clickhouse-release-v20115109-stable-2020-06-19} #### Bug Fix {#bug-fix-51} * Fix excess lock for structure during alter. [#11790](https://github.com/ClickHouse/ClickHouse/pull/11790) ([alesapin](https://github.com/alesapin)). - ### ClickHouse release v20.1.14.107-stable 2020-06-11 {#clickhouse-release-v20114107-stable-2020-06-11} #### Bug Fix {#bug-fix-52} * Fix error `Size of offsets does not match size of column` for queries with `PREWHERE column in (subquery)` and `ARRAY JOIN`. [#11580](https://github.com/ClickHouse/ClickHouse/pull/11580) ([Nikolai Kochetov](https://github.com/KochetovNicolai)). - ### ClickHouse release v20.1.13.105-stable 2020-06-10 {#clickhouse-release-v20113105-stable-2020-06-10} #### Bug Fix {#bug-fix-53} @@ -3067,7 +3019,6 @@ No changes compared to v20.4.3.16-stable. * Fix SELECT of column ALIAS which default expression type different from column type. [#10563](https://github.com/ClickHouse/ClickHouse/pull/10563) ([Azat Khuzhin](https://github.com/azat)). * * Implemented comparison between DateTime64 and String values (just like for DateTime). [#10560](https://github.com/ClickHouse/ClickHouse/pull/10560) ([Vasily Nemkov](https://github.com/Enmk)). - ### ClickHouse release v20.1.12.86, 2020-05-26 {#clickhouse-release-v2011286-2020-05-26} #### Bug Fix {#bug-fix-54} @@ -3096,7 +3047,6 @@ No changes compared to v20.4.3.16-stable. * Added CA certificates to clickhouse-server docker image. [#10476](https://github.com/ClickHouse/ClickHouse/pull/10476) ([filimonov](https://github.com/filimonov)). - ### ClickHouse release v20.1.10.70, 2020-04-17 {#clickhouse-release-v2011070-2020-04-17} #### Bug Fix {#bug-fix-55} @@ -3175,7 +3125,6 @@ No changes compared to v20.4.3.16-stable. * Exception handling now works correctly on Windows Subsystem for Linux. See https://github.com/ClickHouse-Extras/libunwind/pull/3 This fixes [#6480](https://github.com/ClickHouse/ClickHouse/issues/6480) [#9564](https://github.com/ClickHouse/ClickHouse/pull/9564) ([sobolevsv](https://github.com/sobolevsv)) - ### ClickHouse release v20.1.6.30, 2020-03-05 {#clickhouse-release-v201630-2020-03-05} #### Bug Fix {#bug-fix-59} diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/whats-new/changelog/2021.md b/i18n/zh/docusaurus-plugin-content-docs/current/whats-new/changelog/2021.md index f107acb1791..092f4749451 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/whats-new/changelog/2021.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/whats-new/changelog/2021.md @@ -4,6 +4,7 @@ sidebar_position: 6 sidebar_label: '2021' title: '2021 Changelog' description: 'Changelog for 2021' +doc_type: 'changelog' --- ### ClickHouse release v21.12, 2021-12-15 {#clickhouse-release-v2112-2021-12-15} @@ -183,7 +184,6 @@ description: 'Changelog for 2021' * Initial support for risc-v. See development/build-cross-riscv for quirks and build command that was tested. [#31309](https://github.com/ClickHouse/ClickHouse/pull/31309) ([Vladimir Smirnov](https://github.com/Civil)). * Support compile in arm machine with parameter "-DENABLE_TESTS=OFF". [#31007](https://github.com/ClickHouse/ClickHouse/pull/31007) ([zhanghuajie](https://github.com/zhanghuajieHIT)). - ### ClickHouse release v21.11, 2021-11-09 {#clickhouse-release-v2111-2021-11-09} #### Backward Incompatible Change {#backward-incompatible-change-1} @@ -345,7 +345,6 @@ description: 'Changelog for 2021' * Fix shutdown of `AccessControlManager` to fix flaky test. [#29951](https://github.com/ClickHouse/ClickHouse/pull/29951) ([Vitaly Baranov](https://github.com/vitlibar)). * Fix failed assertion in reading from `HDFS`. Update libhdfs3 library to be able to run in tests in debug. Closes [#29251](https://github.com/ClickHouse/ClickHouse/issues/29251). Closes [#27814](https://github.com/ClickHouse/ClickHouse/issues/27814). [#29276](https://github.com/ClickHouse/ClickHouse/pull/29276) ([Kseniia Sumarokova](https://github.com/kssenii)). - #### Build/Testing/Packaging Improvement {#buildtestingpackaging-improvement-1} * Add support for FreeBSD builds for Aarch64 machines. [#29952](https://github.com/ClickHouse/ClickHouse/pull/29952) ([MikaelUrankar](https://github.com/MikaelUrankar)). @@ -449,7 +448,6 @@ description: 'Changelog for 2021' * Fix invalid constant type conversion when Nullable or LowCardinality primary key is used. [#28636](https://github.com/ClickHouse/ClickHouse/pull/28636) ([Amos Bird](https://github.com/amosbird)). * Fix "Column is not under aggregate function and not in GROUP BY" with PREWHERE (Fixes: [#28461](https://github.com/ClickHouse/ClickHouse/issues/28461)). [#28502](https://github.com/ClickHouse/ClickHouse/pull/28502) ([Azat Khuzhin](https://github.com/azat)). - ### ClickHouse release v21.10, 2021-10-16 {#clickhouse-release-v2110-2021-10-16} #### Backward Incompatible Change {#backward-incompatible-change-2} @@ -550,8 +548,6 @@ description: 'Changelog for 2021' * Print out git status information at CMake configure stage. [#28047](https://github.com/ClickHouse/ClickHouse/pull/28047) ([Braulio Valdivielso Martínez](https://github.com/BraulioVM)). * Temporarily switched ubuntu apt repository to mirror ru.archive.ubuntu.com as the default one (archive.ubuntu.com) is not responding from our CI. [#28016](https://github.com/ClickHouse/ClickHouse/pull/28016) ([Ilya Yatsishin](https://github.com/qoega)). - - ### ClickHouse release v21.9, 2021-09-09 {#clickhouse-release-v219-2021-09-09} #### Backward Incompatible Change {#backward-incompatible-change-3} @@ -760,7 +756,6 @@ description: 'Changelog for 2021' * Fix linking of auxiliar programs when using dynamic libraries. [#26958](https://github.com/ClickHouse/ClickHouse/pull/26958) ([Raúl Marín](https://github.com/Algunenano)). * Update RocksDB to `2021-07-16` master. [#26411](https://github.com/ClickHouse/ClickHouse/pull/26411) ([alexey-milovidov](https://github.com/alexey-milovidov)). - ### ClickHouse release v21.8, 2021-08-12 {#clickhouse-release-v218-2021-08-12} #### Upgrade Notes {#upgrade-notes} @@ -862,7 +857,6 @@ description: 'Changelog for 2021' * Fix some fuzzed msan crash. Fixes [#22517](https://github.com/ClickHouse/ClickHouse/issues/22517). [#26428](https://github.com/ClickHouse/ClickHouse/pull/26428) ([Nikolai Kochetov](https://github.com/KochetovNicolai)). * Update `chown` cmd check in `clickhouse-server` docker entrypoint. It fixes error 'cluster pod restart failed (or timeout)' on Kubernetes. [#26545](https://github.com/ClickHouse/ClickHouse/pull/26545) ([Ky Li](https://github.com/Kylinrix)). - ### ClickHouse release v21.7, 2021-07-09 {#clickhouse-release-v217-2021-07-09} #### Backward Incompatible Change {#backward-incompatible-change-4} @@ -989,7 +983,7 @@ description: 'Changelog for 2021' * Fix limit/offset settings for distributed queries (ignore on the remote nodes). [#24940](https://github.com/ClickHouse/ClickHouse/pull/24940) ([Azat Khuzhin](https://github.com/azat)). * Fix possible heap-buffer-overflow in `Arrow` format. [#24922](https://github.com/ClickHouse/ClickHouse/pull/24922) ([Kruglov Pavel](https://github.com/Avogar)). * Fixed possible error 'Cannot read from istream at offset 0' when reading a file from DiskS3 (S3 virtual filesystem is an experimental feature under development that should not be used in production). [#24885](https://github.com/ClickHouse/ClickHouse/pull/24885) ([Pavel Kovalenko](https://github.com/Jokser)). -* Fix "Missing columns" exception when joining Distributed Materialized View. [#24870](https://github.com/ClickHouse/ClickHouse/pull/24870) ([Azat Khuzhin](https://github.com/azat)). +* Fix "Missing columns" exception when joining distributed materialized view. [#24870](https://github.com/ClickHouse/ClickHouse/pull/24870) ([Azat Khuzhin](https://github.com/azat)). * Allow `NULL` values in postgresql compatibility protocol. Closes [#22622](https://github.com/ClickHouse/ClickHouse/issues/22622). [#24857](https://github.com/ClickHouse/ClickHouse/pull/24857) ([Kseniia Sumarokova](https://github.com/kssenii)). * Fix bug when exception `Mutation was killed` can be thrown to the client on mutation wait when mutation not loaded into memory yet. [#24809](https://github.com/ClickHouse/ClickHouse/pull/24809) ([alesapin](https://github.com/alesapin)). * Fixed bug in deserialization of random generator state with might cause some data types such as `AggregateFunction(groupArraySample(N), T))` to behave in a non-deterministic way. [#24538](https://github.com/ClickHouse/ClickHouse/pull/24538) ([tavplubix](https://github.com/tavplubix)). @@ -1000,7 +994,7 @@ description: 'Changelog for 2021' * When user authentication is managed by LDAP. Fixed potential deadlock that can happen during LDAP role (re)mapping, when LDAP group is mapped to a nonexistent local role. [#24431](https://github.com/ClickHouse/ClickHouse/pull/24431) ([Denis Glazachev](https://github.com/traceon)). * In "multipart/form-data" message consider the CRLF preceding a boundary as part of it. Fixes [#23905](https://github.com/ClickHouse/ClickHouse/issues/23905). [#24399](https://github.com/ClickHouse/ClickHouse/pull/24399) ([Ivan](https://github.com/abyss7)). * Fix drop partition with intersect fake parts. In rare cases there might be parts with mutation version greater than current block number. [#24321](https://github.com/ClickHouse/ClickHouse/pull/24321) ([Amos Bird](https://github.com/amosbird)). -* Fixed a bug in moving Materialized View from Ordinary to Atomic database (`RENAME TABLE` query). Now inner table is moved to new database together with Materialized View. Fixes [#23926](https://github.com/ClickHouse/ClickHouse/issues/23926). [#24309](https://github.com/ClickHouse/ClickHouse/pull/24309) ([tavplubix](https://github.com/tavplubix)). +* Fixed a bug in moving materialized view from Ordinary to Atomic database (`RENAME TABLE` query). Now inner table is moved to new database together with materialized view. Fixes [#23926](https://github.com/ClickHouse/ClickHouse/issues/23926). [#24309](https://github.com/ClickHouse/ClickHouse/pull/24309) ([tavplubix](https://github.com/tavplubix)). * Allow empty HTTP headers. Fixes [#23901](https://github.com/ClickHouse/ClickHouse/issues/23901). [#24285](https://github.com/ClickHouse/ClickHouse/pull/24285) ([Ivan](https://github.com/abyss7)). * Correct processing of mutations (ALTER UPDATE/DELETE) in Memory tables. Closes [#24274](https://github.com/ClickHouse/ClickHouse/issues/24274). [#24275](https://github.com/ClickHouse/ClickHouse/pull/24275) ([flynn](https://github.com/ucasfl)). * Make column LowCardinality property in JOIN output the same as in the input, close [#23351](https://github.com/ClickHouse/ClickHouse/issues/23351), close [#20315](https://github.com/ClickHouse/ClickHouse/issues/20315). [#24061](https://github.com/ClickHouse/ClickHouse/pull/24061) ([Vladimir](https://github.com/vdimir)). @@ -1018,7 +1012,6 @@ description: 'Changelog for 2021' * Ubuntu 20.04 is now used to run integration tests, docker-compose version used to run integration tests is updated to 1.28.2. Environment variables now take effect on docker-compose. Rework test_dictionaries_all_layouts_separate_sources to allow parallel run. [#20393](https://github.com/ClickHouse/ClickHouse/pull/20393) ([Ilya Yatsishin](https://github.com/qoega)). * Fix TOCTOU error in installation script. [#25277](https://github.com/ClickHouse/ClickHouse/pull/25277) ([alexey-milovidov](https://github.com/alexey-milovidov)). - ### ClickHouse release 21.6, 2021-06-05 {#clickhouse-release-216-2021-06-05} #### Backward Incompatible Change {#backward-incompatible-change-5} @@ -1109,7 +1102,7 @@ description: 'Changelog for 2021' * Fixed the behavior when query `SYSTEM RESTART REPLICA` or `SYSTEM SYNC REPLICA` is being processed infinitely. This was detected on server with extremely little amount of RAM. [#24457](https://github.com/ClickHouse/ClickHouse/pull/24457) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)). * Fix incorrect monotonicity of `toWeek` function. This fixes [#24422](https://github.com/ClickHouse/ClickHouse/issues/24422) . This bug was introduced in [#5212](https://github.com/ClickHouse/ClickHouse/pull/5212), and was exposed later by smarter partition pruner. [#24446](https://github.com/ClickHouse/ClickHouse/pull/24446) ([Amos Bird](https://github.com/amosbird)). * Fix drop partition with intersect fake parts. In rare cases there might be parts with mutation version greater than current block number. [#24321](https://github.com/ClickHouse/ClickHouse/pull/24321) ([Amos Bird](https://github.com/amosbird)). -* Fixed a bug in moving Materialized View from Ordinary to Atomic database (`RENAME TABLE` query). Now inner table is moved to new database together with Materialized View. Fixes [#23926](https://github.com/ClickHouse/ClickHouse/issues/23926). [#24309](https://github.com/ClickHouse/ClickHouse/pull/24309) ([tavplubix](https://github.com/tavplubix)). +* Fixed a bug in moving materialized view from Ordinary to Atomic database (`RENAME TABLE` query). Now inner table is moved to new database together with materialized view. Fixes [#23926](https://github.com/ClickHouse/ClickHouse/issues/23926). [#24309](https://github.com/ClickHouse/ClickHouse/pull/24309) ([tavplubix](https://github.com/tavplubix)). * Allow empty HTTP headers in client requests. Fixes [#23901](https://github.com/ClickHouse/ClickHouse/issues/23901). [#24285](https://github.com/ClickHouse/ClickHouse/pull/24285) ([Ivan](https://github.com/abyss7)). * Set `max_threads = 1` to fix mutation fail of `Memory` tables. Closes [#24274](https://github.com/ClickHouse/ClickHouse/issues/24274). [#24275](https://github.com/ClickHouse/ClickHouse/pull/24275) ([flynn](https://github.com/ucasFL)). * Fix typo in implementation of `Memory` tables, this bug was introduced at [#15127](https://github.com/ClickHouse/ClickHouse/issues/15127). Closes [#24192](https://github.com/ClickHouse/ClickHouse/issues/24192). [#24193](https://github.com/ClickHouse/ClickHouse/pull/24193) ([张中南](https://github.com/plugine)). @@ -1147,7 +1140,6 @@ description: 'Changelog for 2021' * Remove a source of nondeterminism from build. Now builds at different point of time will produce byte-identical binaries. Partially addressed [#22113](https://github.com/ClickHouse/ClickHouse/issues/22113). [#23559](https://github.com/ClickHouse/ClickHouse/pull/23559) ([alexey-milovidov](https://github.com/alexey-milovidov)). * Add simple tool for benchmarking (Zoo)Keeper. [#23038](https://github.com/ClickHouse/ClickHouse/pull/23038) ([alesapin](https://github.com/alesapin)). - ## ClickHouse release 21.5, 2021-05-20 {#clickhouse-release-215-2021-05-20} #### Backward Incompatible Change {#backward-incompatible-change-6} @@ -1245,7 +1237,7 @@ description: 'Changelog for 2021' * Correct aliases handling if subquery was optimized to constant. Fixes [#22924](https://github.com/ClickHouse/ClickHouse/issues/22924). Fixes [#10401](https://github.com/ClickHouse/ClickHouse/issues/10401). [#23191](https://github.com/ClickHouse/ClickHouse/pull/23191) ([Maksim Kita](https://github.com/kitaisreal)). * Server might fail to start if `data_type_default_nullable` setting is enabled in default profile, it's fixed. Fixes [#22573](https://github.com/ClickHouse/ClickHouse/issues/22573). [#23185](https://github.com/ClickHouse/ClickHouse/pull/23185) ([tavplubix](https://github.com/tavplubix)). * Fixed a crash on shutdown which happened because of wrong accounting of current connections. [#23154](https://github.com/ClickHouse/ClickHouse/pull/23154) ([Vitaly Baranov](https://github.com/vitlibar)). -* Fixed `Table .inner_id... doesn't exist` error when selecting from Materialized View after detaching it from Atomic database and attaching back. [#23047](https://github.com/ClickHouse/ClickHouse/pull/23047) ([tavplubix](https://github.com/tavplubix)). +* Fixed `Table .inner_id... doesn't exist` error when selecting from materialized view after detaching it from Atomic database and attaching back. [#23047](https://github.com/ClickHouse/ClickHouse/pull/23047) ([tavplubix](https://github.com/tavplubix)). * Fix error `Cannot find column in ActionsDAG result` which may happen if subquery uses `untuple`. Fixes [#22290](https://github.com/ClickHouse/ClickHouse/issues/22290). [#22991](https://github.com/ClickHouse/ClickHouse/pull/22991) ([Nikolai Kochetov](https://github.com/KochetovNicolai)). * Fix usage of constant columns of type `Map` with nullable values. [#22939](https://github.com/ClickHouse/ClickHouse/pull/22939) ([Anton Popov](https://github.com/CurtizJ)). * fixed `formatDateTime()` on `DateTime64` and "%C" format specifier fixed `toDateTime64()` for large values and non-zero scale. [#22937](https://github.com/ClickHouse/ClickHouse/pull/22937) ([Vasily Nemkov](https://github.com/Enmk)). @@ -1286,7 +1278,6 @@ description: 'Changelog for 2021' * Avoid UB in `*Log` engines for rwlock unlock due to unlock from another thread. [#22583](https://github.com/ClickHouse/ClickHouse/pull/22583) ([Azat Khuzhin](https://github.com/azat)). * Fixed UB by unlocking the rwlock of the TinyLog from the same thread. [#22560](https://github.com/ClickHouse/ClickHouse/pull/22560) ([Azat Khuzhin](https://github.com/azat)). - ## ClickHouse release 21.4 {#clickhouse-release-214} ### ClickHouse release 21.4.1 2021-04-12 {#clickhouse-release-2141-2021-04-12} @@ -1302,7 +1293,6 @@ description: 'Changelog for 2021' * It's not possible to rollback to older ClickHouse version after executing `ALTER ... ATTACH` query in new version as the old servers would fail to pass the `ATTACH_PART` entry in the replicated log. * In this version, empty `` will block all access to remote hosts while in previous versions it did nothing. If you want to keep old behaviour and you have empty `remote_url_allow_hosts` element in configuration file, remove it. [#20058](https://github.com/ClickHouse/ClickHouse/pull/20058) ([Vladimir Chebotarev](https://github.com/excitoon)). - #### New Feature {#new-feature-7} * Extended range of `DateTime64` to support dates from year 1925 to 2283. Improved support of `DateTime` around zero date (`1970-01-01`). [#9404](https://github.com/ClickHouse/ClickHouse/pull/9404) ([alexey-milovidov](https://github.com/alexey-milovidov), [Vasily Nemkov](https://github.com/Enmk)). Not every time and date functions are working for extended range of dates. @@ -1439,7 +1429,6 @@ description: 'Changelog for 2021' * Fix macOS shared lib build. [#20184](https://github.com/ClickHouse/ClickHouse/pull/20184) ([nvartolomei](https://github.com/nvartolomei)). * Add `ctime` option to `zookeeper-dump-tree`. It allows to dump node creation time. [#21842](https://github.com/ClickHouse/ClickHouse/pull/21842) ([Ilya](https://github.com/HumanUser)). - ## ClickHouse release 21.3 (LTS) {#clickhouse-release-213-lts} ### ClickHouse release v21.3, 2021-03-12 {#clickhouse-release-v213-2021-03-12} @@ -1595,7 +1584,6 @@ description: 'Changelog for 2021' * Fixed port clash from test_storage_kerberized_hdfs test. [#19974](https://github.com/ClickHouse/ClickHouse/pull/19974) ([Ilya Yatsishin](https://github.com/qoega)). * Print `stdout` and `stderr` to log when failed to start docker in integration tests. Before this PR there was a very short error message in this case which didn't help to investigate the problems. [#20631](https://github.com/ClickHouse/ClickHouse/pull/20631) ([Vitaly Baranov](https://github.com/vitlibar)). - ## ClickHouse release 21.2 {#clickhouse-release-212} ### ClickHouse release v21.2.2.8-stable, 2021-02-07 {#clickhouse-release-v21228-stable-2021-02-07} @@ -1722,7 +1710,6 @@ description: 'Changelog for 2021' * Fix data type convert issue for MySQL engine. [#18124](https://github.com/ClickHouse/ClickHouse/pull/18124) ([bo zeng](https://github.com/mis98zb)). * Fix clickhouse-client abort exception while executing only `select`. [#19790](https://github.com/ClickHouse/ClickHouse/pull/19790) ([taiyang-li](https://github.com/taiyang-li)). - #### Build/Testing/Packaging Improvement {#buildtestingpackaging-improvement-9} * Run [SQLancer](https://twitter.com/RiggerManuel/status/1352345625480884228) (logical SQL fuzzer) in CI. [#19006](https://github.com/ClickHouse/ClickHouse/pull/19006) ([Ilya Yatsishin](https://github.com/qoega)). @@ -1740,7 +1727,6 @@ description: 'Changelog for 2021' * Fix potential nullptr dereference in table function `VALUES`. [#19357](https://github.com/ClickHouse/ClickHouse/pull/19357) ([alexey-milovidov](https://github.com/alexey-milovidov)). * Avoid UBSan reports in `arrayElement` function, `substring` and `arraySum`. Fixes [#19305](https://github.com/ClickHouse/ClickHouse/issues/19305). Fixes [#19287](https://github.com/ClickHouse/ClickHouse/issues/19287). This closes [#19336](https://github.com/ClickHouse/ClickHouse/issues/19336). [#19347](https://github.com/ClickHouse/ClickHouse/pull/19347) ([alexey-milovidov](https://github.com/alexey-milovidov)). - ## ClickHouse release 21.1 {#clickhouse-release-211} ### ClickHouse release v21.1.3.32-stable, 2021-02-03 {#clickhouse-release-v211332-stable-2021-02-03} @@ -1764,15 +1750,13 @@ description: 'Changelog for 2021' * Uninitialized memory read was possible in encrypt/decrypt functions if empty string was passed as IV. This closes [#19391](https://github.com/ClickHouse/ClickHouse/issues/19391). [#19397](https://github.com/ClickHouse/ClickHouse/pull/19397) ([alexey-milovidov](https://github.com/alexey-milovidov)). * Fix possible buffer overflow in Uber H3 library. See https://github.com/uber/h3/issues/392. This closes [#19219](https://github.com/ClickHouse/ClickHouse/issues/19219). [#19383](https://github.com/ClickHouse/ClickHouse/pull/19383) ([alexey-milovidov](https://github.com/alexey-milovidov)). * Fix system.parts _state column (LOGICAL_ERROR when querying this column, due to incorrect order). [#19346](https://github.com/ClickHouse/ClickHouse/pull/19346) ([Azat Khuzhin](https://github.com/azat)). -* Fixed possible wrong result or segfault on aggregation when Materialized View and its target table have different structure. Fixes [#18063](https://github.com/ClickHouse/ClickHouse/issues/18063). [#19322](https://github.com/ClickHouse/ClickHouse/pull/19322) ([tavplubix](https://github.com/tavplubix)). +* Fixed possible wrong result or segfault on aggregation when materialized view and its target table have different structure. Fixes [#18063](https://github.com/ClickHouse/ClickHouse/issues/18063). [#19322](https://github.com/ClickHouse/ClickHouse/pull/19322) ([tavplubix](https://github.com/tavplubix)). * Fix error `Cannot convert column now64() because it is constant but values of constants are different in source and result`. Continuation of [#7156](https://github.com/ClickHouse/ClickHouse/issues/7156). [#19316](https://github.com/ClickHouse/ClickHouse/pull/19316) ([Nikolai Kochetov](https://github.com/KochetovNicolai)). * Fix bug when concurrent `ALTER` and `DROP` queries may hang while processing ReplicatedMergeTree table. [#19237](https://github.com/ClickHouse/ClickHouse/pull/19237) ([alesapin](https://github.com/alesapin)). * Fixed `There is no checkpoint` error when inserting data through http interface using `Template` or `CustomSeparated` format. Fixes [#19021](https://github.com/ClickHouse/ClickHouse/issues/19021). [#19072](https://github.com/ClickHouse/ClickHouse/pull/19072) ([tavplubix](https://github.com/tavplubix)). * Disable constant folding for subqueries on the analysis stage, when the result cannot be calculated. [#18446](https://github.com/ClickHouse/ClickHouse/pull/18446) ([Azat Khuzhin](https://github.com/azat)). * Mutation might hang waiting for some non-existent part after `MOVE` or `REPLACE PARTITION` or, in rare cases, after `DETACH` or `DROP PARTITION`. It's fixed. [#15537](https://github.com/ClickHouse/ClickHouse/pull/15537) ([tavplubix](https://github.com/tavplubix)). - - ### ClickHouse release v21.1.2.15-stable 2021-01-18 {#clickhouse-release-v211215-stable-2021-01-18} #### Backward Incompatible Change {#backward-incompatible-change-10} @@ -1803,7 +1787,7 @@ description: 'Changelog for 2021' * Add functions `countMatches`/`countMatchesCaseInsensitive`. [#17459](https://github.com/ClickHouse/ClickHouse/pull/17459) ([Azat Khuzhin](https://github.com/azat)). * Implement `countSubstrings()`/`countSubstringsCaseInsensitive()`/`countSubstringsCaseInsensitiveUTF8()` (Count the number of substring occurrences). [#17347](https://github.com/ClickHouse/ClickHouse/pull/17347) ([Azat Khuzhin](https://github.com/azat)). * Add information about used databases, tables and columns in system.query_log. Add `query_kind` and `normalized_query_hash` fields. [#17726](https://github.com/ClickHouse/ClickHouse/pull/17726) ([Amos Bird](https://github.com/amosbird)). -* Add a setting `optimize_on_insert`. When enabled, do the same transformation for INSERTed block of data as if merge was done on this block (e.g. Replacing, Collapsing, Aggregating...). This setting is enabled by default. This can influence Materialized View and MaterializeMySQL behaviour (see detailed description). This closes [#10683](https://github.com/ClickHouse/ClickHouse/issues/10683). [#16954](https://github.com/ClickHouse/ClickHouse/pull/16954) ([Kruglov Pavel](https://github.com/Avogar)). +* Add a setting `optimize_on_insert`. When enabled, do the same transformation for INSERTed block of data as if merge was done on this block (e.g. Replacing, Collapsing, Aggregating...). This setting is enabled by default. This can influence materialized view and MaterializeMySQL behaviour (see detailed description). This closes [#10683](https://github.com/ClickHouse/ClickHouse/issues/10683). [#16954](https://github.com/ClickHouse/ClickHouse/pull/16954) ([Kruglov Pavel](https://github.com/Avogar)). * Kerberos Authenticaiton for HDFS. [#16621](https://github.com/ClickHouse/ClickHouse/pull/16621) ([Ilya Golshtein](https://github.com/ilejn)). * Support `SHOW SETTINGS` statement to show parameters in system.settings. `SHOW CHANGED SETTINGS` and `LIKE/ILIKE` clause are also supported. [#18056](https://github.com/ClickHouse/ClickHouse/pull/18056) ([Jianmei Zhang](https://github.com/zhangjmruc)). * Function `position` now supports `POSITION(needle IN haystack)` synax for SQL compatibility. This closes [#18701](https://github.com/ClickHouse/ClickHouse/issues/18701). ... [#18779](https://github.com/ClickHouse/ClickHouse/pull/18779) ([Jianmei Zhang](https://github.com/zhangjmruc)). @@ -1832,14 +1816,12 @@ description: 'Changelog for 2021' * Added `query` parameter for `clickhouse-benchmark`. [#17832](https://github.com/ClickHouse/ClickHouse/pull/17832) ([Maksim Kita](https://github.com/kitaisreal)). * `EXPLAIN AST` now support queries other then `SELECT`. [#18136](https://github.com/ClickHouse/ClickHouse/pull/18136) ([taiyang-li](https://github.com/taiyang-li)). - #### Experimental Feature {#experimental-feature-8} * Added functions for calculation of minHash and simHash of text n-grams and shingles. They are intended for semi-duplicate search. Also functions `bitHammingDistance` and `tupleHammingDistance` are added. [#7649](https://github.com/ClickHouse/ClickHouse/pull/7649) ([flynn](https://github.com/ucasFL)). * Add new data type `Map`. See [#1841](https://github.com/ClickHouse/ClickHouse/issues/1841). First version for Map only supports `String` type of key and value. [#15806](https://github.com/ClickHouse/ClickHouse/pull/15806) ([hexiaoting](https://github.com/hexiaoting)). * Implement alternative SQL parser based on ANTLR4 runtime and generated from EBNF grammar. [#11298](https://github.com/ClickHouse/ClickHouse/pull/11298) ([Ivan](https://github.com/abyss7)). - #### Performance Improvement {#performance-improvement-10} * New IP Dictionary implementation with lower memory consumption, improved performance for some cases, and fixed bugs. [#16804](https://github.com/ClickHouse/ClickHouse/pull/16804) ([vdimir](https://github.com/vdimir)). @@ -1864,7 +1846,6 @@ description: 'Changelog for 2021' * Support for async tasks in `PipelineExecutor`. Initial support of async sockets for remote queries. [#17868](https://github.com/ClickHouse/ClickHouse/pull/17868) ([Nikolai Kochetov](https://github.com/KochetovNicolai)). * Allow to use `optimize_move_to_prewhere` optimization with compact parts, when sizes of columns are unknown. [#17330](https://github.com/ClickHouse/ClickHouse/pull/17330) ([Anton Popov](https://github.com/CurtizJ)). - #### Improvement {#improvement-10} * Avoid deadlock when executing INSERT SELECT into itself from a table with `TinyLog` or `Log` table engines. This closes [#6802](https://github.com/ClickHouse/ClickHouse/issues/6802). This closes [#18691](https://github.com/ClickHouse/ClickHouse/issues/18691). This closes [#16812](https://github.com/ClickHouse/ClickHouse/issues/16812). This closes [#14570](https://github.com/ClickHouse/ClickHouse/issues/14570). [#15260](https://github.com/ClickHouse/ClickHouse/pull/15260) ([alexey-milovidov](https://github.com/alexey-milovidov)). @@ -1927,7 +1908,6 @@ description: 'Changelog for 2021' * Fix never worked `fsync_part_directory`/`fsync_after_insert`/`in_memory_parts_insert_sync` (experimental feature). [#18845](https://github.com/ClickHouse/ClickHouse/pull/18845) ([Azat Khuzhin](https://github.com/azat)). * Allow using `Atomic` engine for nested database of `MaterializeMySQL` engine. [#14849](https://github.com/ClickHouse/ClickHouse/pull/14849) ([tavplubix](https://github.com/tavplubix)). - #### Bug Fix {#bug-fix-10} * Fix the issue when server can stop accepting connections in very rare cases. [#17542](https://github.com/ClickHouse/ClickHouse/pull/17542) (Amos Bird, [alexey-milovidov](https://github.com/alexey-milovidov)). @@ -2018,7 +1998,6 @@ description: 'Changelog for 2021' * Throw error when `REPLACE` column transformer operates on non existing column. [#16183](https://github.com/ClickHouse/ClickHouse/pull/16183) ([hexiaoting](https://github.com/hexiaoting)). * Throw exception in case of not equi-join ON expression in RIGH|FULL JOIN. [#15162](https://github.com/ClickHouse/ClickHouse/pull/15162) ([Artem Zuikov](https://github.com/4ertus2)). - #### Build/Testing/Packaging Improvement {#buildtestingpackaging-improvement-10} * Add simple integrity check for ClickHouse binary. It allows to detect corruption due to faulty hardware (bit rot on storage media or bit flips in RAM). [#18811](https://github.com/ClickHouse/ClickHouse/pull/18811) ([alexey-milovidov](https://github.com/alexey-milovidov)). @@ -2052,5 +2031,4 @@ description: 'Changelog for 2021' * Minor improvement for path concatenation of zookeeper paths inside DDLWorker. [#17767](https://github.com/ClickHouse/ClickHouse/pull/17767) ([Bharat Nallan](https://github.com/bharatnc)). * Allow to reload symbols from debug file. This PR also fixes a build-id issue. [#17637](https://github.com/ClickHouse/ClickHouse/pull/17637) ([Amos Bird](https://github.com/amosbird)). - ## [Changelog for 2020](./2020.md) {#changelog-for-2020} diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/whats-new/changelog/2022.md b/i18n/zh/docusaurus-plugin-content-docs/current/whats-new/changelog/2022.md index 1b9fc200cc1..adeae8e0200 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/whats-new/changelog/2022.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/whats-new/changelog/2022.md @@ -4,6 +4,7 @@ sidebar_position: 5 sidebar_label: '2022' title: '2022 Changelog' description: 'Changelog for 2022' +doc_type: 'changelog' --- ### ClickHouse release 22.12, 2022-12-15 {#a-id2212a-clickhouse-release-2212-2022-12-15} @@ -95,7 +96,7 @@ Refer to this issue on GitHub for more details: https://github.com/ClickHouse/Cl * Fix functions `arrayFirstOrNull` and `arrayLastOrNull` or null when the array contains `Nullable` elements. [#43274](https://github.com/ClickHouse/ClickHouse/pull/43274) ([Duc Canh Le](https://github.com/canhld94)). * Fix incorrect `UserTimeMicroseconds`/`SystemTimeMicroseconds` accounting related to Kafka tables. [#42791](https://github.com/ClickHouse/ClickHouse/pull/42791) ([Azat Khuzhin](https://github.com/azat)). * Do not suppress exceptions in `web` disks. Fix retries for the `web` disk. [#42800](https://github.com/ClickHouse/ClickHouse/pull/42800) ([Azat Khuzhin](https://github.com/azat)). -* Fixed (logical) race condition between inserts and dropping materialized views. A race condition happened when a Materialized View was dropped at the same time as an INSERT, where the MVs were present as a dependency of the insert at the begining of the execution, but the table has been dropped by the time the insert chain tries to access it, producing either an `UNKNOWN_TABLE` or `TABLE_IS_DROPPED` exception, and stopping the insertion. After this change, we avoid these exceptions and just continue with the insert if the dependency is gone. [#43161](https://github.com/ClickHouse/ClickHouse/pull/43161) ([AlfVII](https://github.com/AlfVII)). +* Fixed (logical) race condition between inserts and dropping materialized views. A race condition happened when a materialized view was dropped at the same time as an INSERT, where the MVs were present as a dependency of the insert at the begining of the execution, but the table has been dropped by the time the insert chain tries to access it, producing either an `UNKNOWN_TABLE` or `TABLE_IS_DROPPED` exception, and stopping the insertion. After this change, we avoid these exceptions and just continue with the insert if the dependency is gone. [#43161](https://github.com/ClickHouse/ClickHouse/pull/43161) ([AlfVII](https://github.com/AlfVII)). * Fix undefined behavior in the `quantiles` function, which might lead to uninitialized memory. Found by fuzzer. This closes [#44066](https://github.com/ClickHouse/ClickHouse/issues/44066). [#44067](https://github.com/ClickHouse/ClickHouse/pull/44067) ([Alexey Milovidov](https://github.com/alexey-milovidov)). * Additional check on zero uncompressed size is added to `CompressionCodecDelta`. [#43255](https://github.com/ClickHouse/ClickHouse/pull/43255) ([Nikita Taranov](https://github.com/nickitat)). * Flatten arrays from Parquet to avoid an issue with inconsistent data in arrays. These incorrect files can be generated by Apache Iceberg. [#43297](https://github.com/ClickHouse/ClickHouse/pull/43297) ([Arthur Passos](https://github.com/arthurpassos)). @@ -707,7 +708,6 @@ Refer to this issue on GitHub for more details: https://github.com/ClickHouse/Cl * A fix for reverse DNS resolution. [#40134](https://github.com/ClickHouse/ClickHouse/pull/40134) ([Arthur Passos](https://github.com/arthurpassos)). * Fix unexpected result `arrayDifference` of `Array(UInt32). [#40211](https://github.com/ClickHouse/ClickHouse/pull/40211) ([Duc Canh Le](https://github.com/canhld94)). - ### ClickHouse release 22.7, 2022-07-21 {#a-id227a-clickhouse-release-227-2022-07-21} #### Upgrade Notes {#upgrade-notes-1} @@ -1201,7 +1201,6 @@ Refer to this issue on GitHub for more details: https://github.com/ClickHouse/Cl * Fix ALTER DROP COLUMN of nested column with compact parts (i.e. `ALTER TABLE x DROP COLUMN n`, when there is column `n.d`). [#35797](https://github.com/ClickHouse/ClickHouse/pull/35797) ([Azat Khuzhin](https://github.com/azat)). * Fix substring function range error length when `offset` and `length` is negative constant and `s` is not constant. [#33861](https://github.com/ClickHouse/ClickHouse/pull/33861) ([RogerYK](https://github.com/RogerYK)). - ### ClickHouse release 22.4, 2022-04-19 {#a-id224a-clickhouse-release-224-2022-04-19} #### Backward Incompatible Change {#backward-incompatible-change-5} @@ -1353,7 +1352,6 @@ Refer to this issue on GitHub for more details: https://github.com/ClickHouse/Cl * Fix mutations in tables with enabled sparse columns. [#35284](https://github.com/ClickHouse/ClickHouse/pull/35284) ([Anton Popov](https://github.com/CurtizJ)). * Do not delay final part writing by default (fixes possible `Memory limit exceeded` during `INSERT` by adding `max_insert_delayed_streams_for_parallel_write` with default to 1000 for writes to s3 and disabled as before otherwise). [#34780](https://github.com/ClickHouse/ClickHouse/pull/34780) ([Azat Khuzhin](https://github.com/azat)). - ### ClickHouse release v22.3-lts, 2022-03-17 {#a-id223a-clickhouse-release-v223-lts-2022-03-17} #### Backward Incompatible Change {#backward-incompatible-change-6} @@ -1481,7 +1479,6 @@ Refer to this issue on GitHub for more details: https://github.com/ClickHouse/Cl * Fix incorrect result of trivial count query when part movement feature is used [#34089](https://github.com/ClickHouse/ClickHouse/issues/34089). [#34385](https://github.com/ClickHouse/ClickHouse/pull/34385) ([nvartolomei](https://github.com/nvartolomei)). * Fix inconsistency of `max_query_size` limitation in distributed subqueries. [#34078](https://github.com/ClickHouse/ClickHouse/pull/34078) ([Chao Ma](https://github.com/godliness)). - ### ClickHouse release v22.2, 2022-02-17 {#a-id222a-clickhouse-release-v222-2022-02-17} #### Upgrade Notes {#upgrade-notes-3} @@ -1657,7 +1654,6 @@ Refer to this issue on GitHub for more details: https://github.com/ClickHouse/Cl * Fix issue [#18206](https://github.com/ClickHouse/ClickHouse/issues/18206). [#33977](https://github.com/ClickHouse/ClickHouse/pull/33977) ([Vitaly Baranov](https://github.com/vitlibar)). * This PR allows using multiple LDAP storages in the same list of user directories. It worked earlier but was broken because LDAP tests are disabled (they are part of the testflows tests). [#33574](https://github.com/ClickHouse/ClickHouse/pull/33574) ([Vitaly Baranov](https://github.com/vitlibar)). - ### ClickHouse release v22.1, 2022-01-18 {#a-id221a-clickhouse-release-v221-2022-01-18} #### Upgrade Notes {#upgrade-notes-4} @@ -1684,7 +1680,6 @@ Refer to this issue on GitHub for more details: https://github.com/ClickHouse/Cl * Add function `decodeURLFormComponent` slightly different to `decodeURLComponent`. Close [#10298](https://github.com/ClickHouse/ClickHouse/issues/10298). [#33451](https://github.com/ClickHouse/ClickHouse/pull/33451) ([SuperDJY](https://github.com/cmsxbc)). * Allow to split `GraphiteMergeTree` rollup rules for plain/tagged metrics (optional rule_type field). [#33494](https://github.com/ClickHouse/ClickHouse/pull/33494) ([Michail Safronov](https://github.com/msaf1980)). - #### Performance Improvement {#performance-improvement-11} * Support moving conditions to `PREWHERE` (setting `optimize_move_to_prewhere`) for tables of `Merge` engine if its all underlying tables supports `PREWHERE`. [#33300](https://github.com/ClickHouse/ClickHouse/pull/33300) ([Anton Popov](https://github.com/CurtizJ)). @@ -1700,7 +1695,6 @@ Refer to this issue on GitHub for more details: https://github.com/ClickHouse/Cl * Optimize selecting of MergeTree parts that can be moved between volumes. [#33225](https://github.com/ClickHouse/ClickHouse/pull/33225) ([OnePiece](https://github.com/zhongyuankai)). * Fix `sparse_hashed` dict performance with sequential keys (wrong hash function). [#32536](https://github.com/ClickHouse/ClickHouse/pull/32536) ([Azat Khuzhin](https://github.com/azat)). - #### Experimental Feature {#experimental-feature-10} * Parallel reading from multiple replicas within a shard during distributed query without using sample key. To enable this, set `allow_experimental_parallel_reading_from_replicas = 1` and `max_parallel_replicas` to any number. This closes [#26748](https://github.com/ClickHouse/ClickHouse/issues/26748). [#29279](https://github.com/ClickHouse/ClickHouse/pull/29279) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)). @@ -1713,7 +1707,6 @@ Refer to this issue on GitHub for more details: https://github.com/ClickHouse/Cl * Fix ACL with explicit digit hash in `clickhouse-keeper`: now the behavior consistent with ZooKeeper and generated digest is always accepted. [#33249](https://github.com/ClickHouse/ClickHouse/pull/33249) ([小路](https://github.com/nicelulu)). [#33246](https://github.com/ClickHouse/ClickHouse/pull/33246). * Fix unexpected projection removal when detaching parts. [#32067](https://github.com/ClickHouse/ClickHouse/pull/32067) ([Amos Bird](https://github.com/amosbird)). - #### Improvement {#improvement-11} * Now date time conversion functions that generates time before `1970-01-01 00:00:00` will be saturated to zero instead of overflow. [#29953](https://github.com/ClickHouse/ClickHouse/pull/29953) ([Amos Bird](https://github.com/amosbird)). It also fixes a bug in index analysis if date truncation function would yield result before the Unix epoch. @@ -1760,7 +1753,6 @@ Refer to this issue on GitHub for more details: https://github.com/ClickHouse/Cl * Updating `modification_time` for data part in `system.parts` after part movement [#32964](https://github.com/ClickHouse/ClickHouse/issues/32964). [#32965](https://github.com/ClickHouse/ClickHouse/pull/32965) ([save-my-heart](https://github.com/save-my-heart)). * Potential issue, cannot be exploited: integer overflow may happen in array resize. [#33024](https://github.com/ClickHouse/ClickHouse/pull/33024) ([varadarajkumar](https://github.com/varadarajkumar)). - #### Build/Testing/Packaging Improvement {#buildtestingpackaging-improvement-11} * Add packages, functional tests and Docker builds for AArch64 (ARM) version of ClickHouse. [#32911](https://github.com/ClickHouse/ClickHouse/pull/32911) ([Mikhail f. Shiryaev](https://github.com/Felixoid)). [#32415](https://github.com/ClickHouse/ClickHouse/pull/32415) @@ -1775,7 +1767,6 @@ Refer to this issue on GitHub for more details: https://github.com/ClickHouse/Cl * Inject git information into clickhouse binary file. So we can get source code revision easily from clickhouse binary file. [#33124](https://github.com/ClickHouse/ClickHouse/pull/33124) ([taiyang-li](https://github.com/taiyang-li)). * Remove obsolete code from ConfigProcessor. Yandex specific code is not used anymore. The code contained one minor defect. This defect was reported by [Mallik Hassan](https://github.com/SadiHassan) in [#33032](https://github.com/ClickHouse/ClickHouse/issues/33032). This closes [#33032](https://github.com/ClickHouse/ClickHouse/issues/33032). [#33026](https://github.com/ClickHouse/ClickHouse/pull/33026) ([alexey-milovidov](https://github.com/alexey-milovidov)). - #### Bug Fix (user-visible misbehavior in official stable or prestable release) {#bug-fix-user-visible-misbehavior-in-official-stable-or-prestable-release-4} * Several fixes for format parsing. This is relevant if `clickhouse-server` is open for write access to adversary. Specifically crafted input data for `Native` format may lead to reading uninitialized memory or crash. This is relevant if `clickhouse-server` is open for write access to adversary. [#33050](https://github.com/ClickHouse/ClickHouse/pull/33050) ([Heena Bansal](https://github.com/HeenaBansal2009)). Fixed Apache Avro Union type index out of boundary issue in Apache Avro binary format. [#33022](https://github.com/ClickHouse/ClickHouse/pull/33022) ([Harry Lee](https://github.com/HarryLeeIBM)). Fix null pointer dereference in `LowCardinality` data when deserializing `LowCardinality` data in the Native format. [#33021](https://github.com/ClickHouse/ClickHouse/pull/33021) ([Harry Lee](https://github.com/HarryLeeIBM)). @@ -1789,7 +1780,7 @@ Refer to this issue on GitHub for more details: https://github.com/ClickHouse/Cl * Out of band `offset` and `limit` settings may be applied incorrectly for views. Close [#33289](https://github.com/ClickHouse/ClickHouse/issues/33289) [#33518](https://github.com/ClickHouse/ClickHouse/pull/33518) ([hexiaoting](https://github.com/hexiaoting)). * Fix an exception `Block structure mismatch` which may happen during insertion into table with default nested `LowCardinality` column. Fixes [#33028](https://github.com/ClickHouse/ClickHouse/issues/33028). [#33504](https://github.com/ClickHouse/ClickHouse/pull/33504) ([Nikolai Kochetov](https://github.com/KochetovNicolai)). * Fix dictionary expressions for `range_hashed` range min and range max attributes when created using DDL. Closes [#30809](https://github.com/ClickHouse/ClickHouse/issues/30809). [#33478](https://github.com/ClickHouse/ClickHouse/pull/33478) ([Maksim Kita](https://github.com/kitaisreal)). -* Fix possible use-after-free for INSERT into Materialized View with concurrent DROP ([Azat Khuzhin](https://github.com/azat)). +* Fix possible use-after-free for INSERT into materialized view with concurrent DROP ([Azat Khuzhin](https://github.com/azat)). * Do not try to read pass EOF (to workaround for a bug in the Linux kernel), this bug can be reproduced on kernels (3.14..5.9), and requires `index_granularity_bytes=0` (i.e. turn off adaptive index granularity). [#33372](https://github.com/ClickHouse/ClickHouse/pull/33372) ([Azat Khuzhin](https://github.com/azat)). * The commands `SYSTEM SUSPEND` and `SYSTEM ... THREAD FUZZER` missed access control. It is fixed. Author: Kevin Michel. [#33333](https://github.com/ClickHouse/ClickHouse/pull/33333) ([alexey-milovidov](https://github.com/alexey-milovidov)). * Fix when `COMMENT` for dictionaries does not appear in `system.tables`, `system.dictionaries`. Allow to modify the comment for `Dictionary` engine. Closes [#33251](https://github.com/ClickHouse/ClickHouse/issues/33251). [#33261](https://github.com/ClickHouse/ClickHouse/pull/33261) ([Maksim Kita](https://github.com/kitaisreal)). @@ -1834,5 +1825,4 @@ Refer to this issue on GitHub for more details: https://github.com/ClickHouse/Cl * Fix possible crash (or incorrect result) in case of `LowCardinality` arguments of window function. Fixes [#31114](https://github.com/ClickHouse/ClickHouse/issues/31114). [#31888](https://github.com/ClickHouse/ClickHouse/pull/31888) ([Nikolai Kochetov](https://github.com/KochetovNicolai)). * Fix hang up with command `DROP TABLE system.query_log sync`. [#33293](https://github.com/ClickHouse/ClickHouse/pull/33293) ([zhanghuajie](https://github.com/zhanghuajieHIT)). - ## [Changelog for 2021](./2021.md) {#changelog-for-2021} diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/whats-new/changelog/2023.md b/i18n/zh/docusaurus-plugin-content-docs/current/whats-new/changelog/2023.md index a83bf471a07..11058c59dce 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/whats-new/changelog/2023.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/whats-new/changelog/2023.md @@ -4,6 +4,7 @@ sidebar_position: 4 sidebar_label: '2023' title: '2023 Changelog' description: 'Changelog for 2023' +doc_type: 'changelog' --- ### Table of Contents {#table-of-contents} @@ -160,7 +161,6 @@ description: 'Changelog for 2023' * Fix a slow-down of CREATE VIEW with an enormous number of subqueries [#58220](https://github.com/ClickHouse/ClickHouse/pull/58220) ([Tao Wang](https://github.com/wangtZJU)). * Fix parallel parsing for JSONCompactEachRow [#58181](https://github.com/ClickHouse/ClickHouse/pull/58181) ([Alexey Milovidov](https://github.com/alexey-milovidov)). [#58250](https://github.com/ClickHouse/ClickHouse/pull/58250) ([Kruglov Pavel](https://github.com/Avogar)). - ### ClickHouse release 23.11, 2023-12-06 {#2311} #### Backward Incompatible Change {#backward-incompatible-change-1} @@ -370,7 +370,6 @@ description: 'Changelog for 2023' * MergeTree mutations reuse source part index granularity [#57352](https://github.com/ClickHouse/ClickHouse/pull/57352) ([Maksim Kita](https://github.com/kitaisreal)). * FS cache: add a limit for background download [#57424](https://github.com/ClickHouse/ClickHouse/pull/57424) ([Kseniia Sumarokova](https://github.com/kssenii)). - ### ClickHouse release 23.10, 2023-11-02 {#2310} #### Backward Incompatible Change {#backward-incompatible-change-2} @@ -549,7 +548,6 @@ description: 'Changelog for 2023' * Fix schema cache for fallback JSON->JSONEachRow with changed settings [#56172](https://github.com/ClickHouse/ClickHouse/pull/56172) ([Kruglov Pavel](https://github.com/Avogar)). * Add error handler to odbc-bridge [#56185](https://github.com/ClickHouse/ClickHouse/pull/56185) ([Yakov Olkhovskiy](https://github.com/yakov-olkhovskiy)). - ### ClickHouse release 23.9, 2023-09-28 {#239} #### Backward Incompatible Change {#backward-incompatible-change-3} @@ -716,7 +714,6 @@ description: 'Changelog for 2023' * Fix: insert quorum w/o keeper retries [#55026](https://github.com/ClickHouse/ClickHouse/pull/55026) ([Igor Nikonov](https://github.com/devcrafter)). * Fix simple state with nullable [#55030](https://github.com/ClickHouse/ClickHouse/pull/55030) ([Pedro Riera](https://github.com/priera)). - ### ClickHouse release 23.8 LTS, 2023-08-31 {#238} #### Backward Incompatible Change {#backward-incompatible-change-4} @@ -1111,7 +1108,6 @@ description: 'Changelog for 2023' * Fix lightweight delete after drop of projection [#52517](https://github.com/ClickHouse/ClickHouse/pull/52517) ([Anton Popov](https://github.com/CurtizJ)). * Fix possible error "Cannot drain connections: cancel first" [#52585](https://github.com/ClickHouse/ClickHouse/pull/52585) ([Kruglov Pavel](https://github.com/Avogar)). - ### ClickHouse release 23.6, 2023-06-29 {#236} #### Backward Incompatible Change {#backward-incompatible-change-6} @@ -1211,7 +1207,6 @@ description: 'Changelog for 2023' * Fix fuzzer failure in ActionsDAG [#51301](https://github.com/ClickHouse/ClickHouse/pull/51301) ([Alexey Milovidov](https://github.com/alexey-milovidov)). * Remove garbage from function `transform` [#51350](https://github.com/ClickHouse/ClickHouse/pull/51350) ([Alexey Milovidov](https://github.com/alexey-milovidov)). - ### ClickHouse release 23.5, 2023-06-08 {#235} #### Upgrade Notes {#upgrade-notes} @@ -1906,7 +1901,7 @@ description: 'Changelog for 2023' * Functions "multi[Fuzzy]Match(Any|AnyIndex|AllIndices}" now reject regexes which will likely evaluate very slowly in vectorscan. [#46167](https://github.com/ClickHouse/ClickHouse/pull/46167) ([Robert Schulze](https://github.com/rschu1ze)). * When `insert_null_as_default` is enabled and column doesn't have defined default value, the default of column type will be used. Also this PR fixes using default values on nulls in case of LowCardinality columns. [#46171](https://github.com/ClickHouse/ClickHouse/pull/46171) ([Kruglov Pavel](https://github.com/Avogar)). * Prefer explicitly defined access keys for S3 clients. If `use_environment_credentials` is set to `true`, and the user has provided the access key through query or config, they will be used instead of the ones from the environment variable. [#46191](https://github.com/ClickHouse/ClickHouse/pull/46191) ([Antonio Andelic](https://github.com/antonio2368)). -* Add an alias "DATE_FORMAT()" for function "formatDateTime()" to improve compatibility with MySQL's SQL dialect, extend function `formatDateTime` with substitutions "a", "b", "c", "h", "i", "k", "l" "r", "s", "W". ### Documentation entry for user-facing changes User-readable short description: `DATE_FORMAT` is an alias of `formatDateTime`. Formats a Time according to the given Format string. Format is a constant expression, so you cannot have multiple formats for a single result column. (Provide link to [formatDateTime](/sql-reference/functions/date-time-functions/#formatdatetime)). [#46302](https://github.com/ClickHouse/ClickHouse/pull/46302) ([Jake Bamrah](https://github.com/JakeBamrah)). +* Add an alias "DATE_FORMAT()" for function "formatDateTime()" to improve compatibility with MySQL's SQL dialect, extend function `formatDateTime` with substitutions "a", "b", "c", "h", "i", "k", "l" "r", "s", "W". ### Documentation entry for user-facing changes User-readable short description: `DATE_FORMAT` is an alias of `formatDateTime`. Formats a Time according to the given Format string. Format is a constant expression, so you cannot have multiple formats for a single result column. (Provide link to [formatDateTime](/sql-reference/functions/date-time-functions/#formatDateTime)). [#46302](https://github.com/ClickHouse/ClickHouse/pull/46302) ([Jake Bamrah](https://github.com/JakeBamrah)). * Add `ProfileEvents` and `CurrentMetrics` about the callback tasks for parallel replicas (`s3Cluster` and `MergeTree` tables). [#46313](https://github.com/ClickHouse/ClickHouse/pull/46313) ([Alexey Milovidov](https://github.com/alexey-milovidov)). * Add support for `DELETE` and `UPDATE` for tables using `KeeperMap` storage engine. [#46330](https://github.com/ClickHouse/ClickHouse/pull/46330) ([Antonio Andelic](https://github.com/antonio2368)). * Allow writing RENAME queries with query parameters. Resolves [#45778](https://github.com/ClickHouse/ClickHouse/issues/45778). [#46407](https://github.com/ClickHouse/ClickHouse/pull/46407) ([Nikolay Degterinsky](https://github.com/evillique)). @@ -1916,7 +1911,6 @@ description: 'Changelog for 2023' * Support for IN clause with parameter in parameterized views. [#46583](https://github.com/ClickHouse/ClickHouse/pull/46583) ([SmitaRKulkarni](https://github.com/SmitaRKulkarni)). * Do not load named collections on server startup (load them on first access instead). [#46607](https://github.com/ClickHouse/ClickHouse/pull/46607) ([Kseniia Sumarokova](https://github.com/kssenii)). - #### Build/Testing/Packaging Improvement {#buildtestingpackaging-improvement-10} * Introduce GWP-ASan implemented by the LLVM runtime. This closes [#27039](https://github.com/ClickHouse/ClickHouse/issues/27039). [#45226](https://github.com/ClickHouse/ClickHouse/pull/45226) ([Han Fei](https://github.com/hanfei1991)). * We want to make our tests less stable and more flaky: add randomization for merge tree settings in tests. [#38983](https://github.com/ClickHouse/ClickHouse/pull/38983) ([Anton Popov](https://github.com/CurtizJ)). @@ -1929,7 +1923,6 @@ description: 'Changelog for 2023' * Raised the minimum Clang version needed to build ClickHouse from 12 to 15. [#46710](https://github.com/ClickHouse/ClickHouse/pull/46710) ([Robert Schulze](https://github.com/rschu1ze)). * Upgrade Intel QPL from v0.3.0 to v1.0.0 2. Build libaccel-config and link it statically to QPL library instead of dynamically. [#45809](https://github.com/ClickHouse/ClickHouse/pull/45809) ([jasperzhu](https://github.com/jinjunzh)). - #### Bug Fix (user-visible misbehavior in official stable release) {#bug-fix-user-visible-misbehavior-in-official-stable-release} * Flush data exactly by `rabbitmq_flush_interval_ms` or by `rabbitmq_max_block_size` in `StorageRabbitMQ`. Closes [#42389](https://github.com/ClickHouse/ClickHouse/issues/42389). Closes [#45160](https://github.com/ClickHouse/ClickHouse/issues/45160). [#44404](https://github.com/ClickHouse/ClickHouse/pull/44404) ([Kseniia Sumarokova](https://github.com/kssenii)). @@ -1976,7 +1969,6 @@ description: 'Changelog for 2023' * Allocated during asynchronous inserts memory buffers were deallocated in the global context and MemoryTracker counters for corresponding user and query were not updated correctly. That led to false positive OOM exceptions. [#46622](https://github.com/ClickHouse/ClickHouse/pull/46622) ([Dmitry Novik](https://github.com/novikd)). * Updated to not clear on_expression from table_join as its used by future analyze runs resolves [#45185](https://github.com/ClickHouse/ClickHouse/issues/45185). [#46487](https://github.com/ClickHouse/ClickHouse/pull/46487) ([SmitaRKulkarni](https://github.com/SmitaRKulkarni)). - ### ClickHouse release 23.1, 2023-01-26 {#231} ### ClickHouse release 23.1 {#clickhouse-release-231} @@ -1990,7 +1982,6 @@ description: 'Changelog for 2023' * Forbid paths in timezone names. For example, a timezone name like `/usr/share/zoneinfo/Asia/Aden` is not allowed; the IANA timezone database name like `Asia/Aden` should be used. [#44225](https://github.com/ClickHouse/ClickHouse/pull/44225) ([Kruglov Pavel](https://github.com/Avogar)). * Queries combining equijoin and constant expressions (e.g., `JOIN ON t1.x = t2.x AND 1 = 1`) are forbidden due to incorrect results. [#44016](https://github.com/ClickHouse/ClickHouse/pull/44016) ([Vladimir C](https://github.com/vdimir)). - #### New Feature {#new-feature-11} * Dictionary source for extracting keys by traversing regular expressions tree. It can be used for User-Agent parsing. [#40878](https://github.com/ClickHouse/ClickHouse/pull/40878) ([Vage Ogannisian](https://github.com/nooblose)). [#43858](https://github.com/ClickHouse/ClickHouse/pull/43858) ([Han Fei](https://github.com/hanfei1991)). * Added parametrized view functionality, now it's possible to specify query parameters for the View table engine. resolves [#40907](https://github.com/ClickHouse/ClickHouse/issues/40907). [#41687](https://github.com/ClickHouse/ClickHouse/pull/41687) ([SmitaRKulkarni](https://github.com/SmitaRKulkarni)). diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/whats-new/changelog/2024.md b/i18n/zh/docusaurus-plugin-content-docs/current/whats-new/changelog/2024.md index d74962ebe45..6c28c3cab7b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/whats-new/changelog/2024.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/whats-new/changelog/2024.md @@ -4,6 +4,7 @@ sidebar_position: 3 sidebar_label: '2024' title: '2024 Changelog' description: 'Changelog for 2024' +doc_type: 'changelog' --- ### Table of Contents {#table-of-contents} @@ -137,7 +138,6 @@ description: 'Changelog for 2024' * Split large translation units to avoid compilation failures due to memory/cpu limitations. [#72352](https://github.com/ClickHouse/ClickHouse/pull/72352) ([Yakov Olkhovskiy](https://github.com/yakov-olkhovskiy)). * OSX: Build with ICU support, which enables collations, charset conversions and other localization features. [#73083](https://github.com/ClickHouse/ClickHouse/pull/73083) ([Raúl Marín](https://github.com/Algunenano)). - ### ClickHouse release 24.11, 2024-11-26 {#a-id2411a-clickhouse-release-2411-2024-11-26} #### Backward Incompatible Change {#backward-incompatible-change-1} @@ -451,7 +451,6 @@ description: 'Changelog for 2024' * Fix a logical error due to negative zeros in the two-level hash table. This closes [#70973](https://github.com/ClickHouse/ClickHouse/issues/70973). [#70979](https://github.com/ClickHouse/ClickHouse/pull/70979) ([Alexey Milovidov](https://github.com/alexey-milovidov)). * Fix `limit by`, `limit with ties` for distributed and parallel replicas. [#70880](https://github.com/ClickHouse/ClickHouse/pull/70880) ([Nikita Taranov](https://github.com/nickitat)). - ### ClickHouse release 24.9, 2024-09-26 {#a-id249a-clickhouse-release-249-2024-09-26} #### Backward Incompatible Change {#backward-incompatible-change-3} @@ -613,7 +612,6 @@ description: 'Changelog for 2024' * Use tryconvertfieldtotype in gethyperrectangleforrowgroup. [#69745](https://github.com/ClickHouse/ClickHouse/pull/69745) ([Miсhael Stetsyuk](https://github.com/mstetsyuk)). * Revert "Fix prewhere without columns and without adaptive index granularity (almost w/o anything)"'. Due to the reverted changes some errors might happen when reading data parts produced by old CH releases (presumably 2021 or older). [#68897](https://github.com/ClickHouse/ClickHouse/pull/68897) ([Alexander Gololobov](https://github.com/davenger)). - ### ClickHouse release 24.8 LTS, 2024-08-20 {#a-id248a-clickhouse-release-248-lts-2024-08-20} #### Backward Incompatible Change {#backward-incompatible-change-4} @@ -758,7 +756,6 @@ description: 'Changelog for 2024' * Try fix postgres crash when query is cancelled. [#68288](https://github.com/ClickHouse/ClickHouse/pull/68288) ([Kseniia Sumarokova](https://github.com/kssenii)). * Fix missing sync replica mode in query `SYSTEM SYNC REPLICA`. [#68326](https://github.com/ClickHouse/ClickHouse/pull/68326) ([Duc Canh Le](https://github.com/canhld94)). - ### ClickHouse release 24.7, 2024-07-30 {#a-id247a-clickhouse-release-247-2024-07-30} #### Backward Incompatible Change {#backward-incompatible-change-5} @@ -1239,12 +1236,11 @@ description: 'Changelog for 2024' * Fix analyzer: only interpolate expression should be used for DAG [#64096](https://github.com/ClickHouse/ClickHouse/pull/64096) ([Yakov Olkhovskiy](https://github.com/yakov-olkhovskiy)). * Fix azure backup writing multipart blocks by 1 MiB (read buffer size) instead of `max_upload_part_size` (in non-native copy case) [#64117](https://github.com/ClickHouse/ClickHouse/pull/64117) ([Kseniia Sumarokova](https://github.com/kssenii)). * Correctly fallback during backup copy [#64153](https://github.com/ClickHouse/ClickHouse/pull/64153) ([Antonio Andelic](https://github.com/antonio2368)). -* Prevent LOGICAL_ERROR on CREATE TABLE as Materialized View [#64174](https://github.com/ClickHouse/ClickHouse/pull/64174) ([Raúl Marín](https://github.com/Algunenano)). +* Prevent LOGICAL_ERROR on CREATE TABLE as materialized view [#64174](https://github.com/ClickHouse/ClickHouse/pull/64174) ([Raúl Marín](https://github.com/Algunenano)). * Query Cache: Consider identical queries against different databases as different [#64199](https://github.com/ClickHouse/ClickHouse/pull/64199) ([Robert Schulze](https://github.com/rschu1ze)). * Ignore `text_log` for Keeper [#64218](https://github.com/ClickHouse/ClickHouse/pull/64218) ([Antonio Andelic](https://github.com/antonio2368)). * Fix Logical error: Bad cast for Buffer table with prewhere. [#64388](https://github.com/ClickHouse/ClickHouse/pull/64388) ([Nikolai Kochetov](https://github.com/KochetovNicolai)). - ### ClickHouse release 24.4, 2024-04-30 {#a-id244a-clickhouse-release-244-2024-04-30} #### Upgrade Notes {#upgrade-notes} @@ -1405,7 +1401,6 @@ description: 'Changelog for 2024' * Set server name for SSL handshake in MongoDB engine [#63122](https://github.com/ClickHouse/ClickHouse/pull/63122) ([Alexander Gololobov](https://github.com/davenger)). * Use user specified db instead of "config" for MongoDB wire protocol version check [#63126](https://github.com/ClickHouse/ClickHouse/pull/63126) ([Alexander Gololobov](https://github.com/davenger)). - ### ClickHouse release 24.3 LTS, 2024-03-27 {#a-id243a-clickhouse-release-243-lts-2024-03-27} #### Upgrade Notes {#upgrade-notes-1} @@ -1588,7 +1583,7 @@ description: 'Changelog for 2024' * Fix for the materialized view security issue, which allowed a user to insert into a table without required grants for that. Fix validates that the user has permission to insert not only into a materialized view but also into all underlying tables. This means that some queries, which worked before, now can fail with `Not enough privileges`. To address this problem, the release introduces a new feature of SQL security for views https://clickhouse.com/docs/sql-reference/statements/create/view#sql_security. [#54901](https://github.com/ClickHouse/ClickHouse/pull/54901) [#60439](https://github.com/ClickHouse/ClickHouse/pull/60439) ([pufit](https://github.com/pufit)). #### New Feature {#new-feature-10} -* Added new syntax which allows to specify definer user in View/Materialized View. This allows to execute selects/inserts from views without explicit grants for underlying tables. So, a View will encapsulate the grants. [#54901](https://github.com/ClickHouse/ClickHouse/pull/54901) [#60439](https://github.com/ClickHouse/ClickHouse/pull/60439) ([pufit](https://github.com/pufit)). +* Added new syntax which allows to specify definer user in view/materialized view. This allows to execute selects/inserts from views without explicit grants for underlying tables. So, a View will encapsulate the grants. [#54901](https://github.com/ClickHouse/ClickHouse/pull/54901) [#60439](https://github.com/ClickHouse/ClickHouse/pull/60439) ([pufit](https://github.com/pufit)). * Try to detect file format automatically during schema inference if it's unknown in `file/s3/hdfs/url/azureBlobStorage` engines. Closes [#50576](https://github.com/ClickHouse/ClickHouse/issues/50576). [#59092](https://github.com/ClickHouse/ClickHouse/pull/59092) ([Kruglov Pavel](https://github.com/Avogar)). * Implement auto-adjustment for asynchronous insert timeouts. The following settings are introduced: async_insert_poll_timeout_ms, async_insert_use_adaptive_busy_timeout, async_insert_busy_timeout_min_ms, async_insert_busy_timeout_max_ms, async_insert_busy_timeout_increase_rate, async_insert_busy_timeout_decrease_rate. [#58486](https://github.com/ClickHouse/ClickHouse/pull/58486) ([Julia Kartseva](https://github.com/jkartseva)). * Allow to set up a quota for maximum sequential login failures. [#54737](https://github.com/ClickHouse/ClickHouse/pull/54737) ([Alexey Gerasimchuck](https://github.com/Demilivor)). @@ -1733,7 +1728,6 @@ description: 'Changelog for 2024' * Fix OptimizeDateOrDateTimeConverterWithPreimageVisitor with null arguments [#60453](https://github.com/ClickHouse/ClickHouse/pull/60453) ([Raúl Marín](https://github.com/Algunenano)). * Fixed a minor bug that prevented distributed table queries sent from either KQL or PRQL dialect clients to be executed on replicas. [#59674](https://github.com/ClickHouse/ClickHouse/issues/59674). [#60470](https://github.com/ClickHouse/ClickHouse/pull/60470) ([Alexey Milovidov](https://github.com/alexey-milovidov)) [#59674](https://github.com/ClickHouse/ClickHouse/pull/59674) ([Austin Kothig](https://github.com/kothiga)). - ### ClickHouse release 24.1, 2024-01-30 {#a-id241a-clickhouse-release-241-2024-01-30} #### Backward Incompatible Change {#backward-incompatible-change-9} diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/whats-new/changelog/cloud.md b/i18n/zh/docusaurus-plugin-content-docs/current/whats-new/changelog/cloud.md index dd3faf69c73..89a9fd594fa 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/whats-new/changelog/cloud.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/whats-new/changelog/cloud.md @@ -4,6 +4,7 @@ sidebar_label: 'Cloud' title: 'Cloud Changelog' slug: /whats-new/changelog/cloud description: 'Learn about Cloud Changelog' +doc_type: 'changelog' --- # Cloud Changelog diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/whats-new/changelog/index.md b/i18n/zh/docusaurus-plugin-content-docs/current/whats-new/changelog/index.md index 4a14fcb7dbf..84afb5ddc50 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/whats-new/changelog/index.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/whats-new/changelog/index.md @@ -5,5 +5,1888 @@ slug: /whats-new/changelog/ sidebar_position: 2 sidebar_label: '2025' title: '2025 Changelog' +doc_type: 'changelog' --- +### Table of Contents +**[ClickHouse release v25.9, 2025-09-25](#259)**
+**[ClickHouse release v25.8 LTS, 2025-08-28](#258)**
+**[ClickHouse release v25.7, 2025-07-24](#257)**
+**[ClickHouse release v25.6, 2025-06-26](#256)**
+**[ClickHouse release v25.5, 2025-05-22](#255)**
+**[ClickHouse release v25.4, 2025-04-22](#254)**
+**[ClickHouse release v25.3 LTS, 2025-03-20](#253)**
+**[ClickHouse release v25.2, 2025-02-27](#252)**
+**[ClickHouse release v25.1, 2025-01-28](#251)**
+**[Changelog for 2024](https://clickhouse.com/docs/whats-new/changelog/2024/)**
+**[Changelog for 2023](https://clickhouse.com/docs/whats-new/changelog/2023/)**
+**[Changelog for 2022](https://clickhouse.com/docs/whats-new/changelog/2022/)**
+**[Changelog for 2021](https://clickhouse.com/docs/whats-new/changelog/2021/)**
+**[Changelog for 2020](https://clickhouse.com/docs/whats-new/changelog/2020/)**
+**[Changelog for 2019](https://clickhouse.com/docs/whats-new/changelog/2019/)**
+**[Changelog for 2018](https://clickhouse.com/docs/whats-new/changelog/2018/)**
+**[Changelog for 2017](https://clickhouse.com/docs/whats-new/changelog/2017/)**
+ + +### ClickHouse release 25.9, 2025-09-25 {#259} + +#### Backward Incompatible Change +* Disable nonsensical binary operations with IPv4/IPv6: Plus / minus of a IPv4/IPv6 with a non-integer type is disabled. Before it would allow operations with floating types and throw logical errors with some other types (such as DateTime). [#86336](https://github.com/ClickHouse/ClickHouse/pull/86336) ([Raúl Marín](https://github.com/Algunenano)). +* Deprecate setting `allow_dynamic_metadata_for_data_lakes`. Now all iceberg tables try to fetch up-to-date table schema from storage before executing of each query. [#86366](https://github.com/ClickHouse/ClickHouse/pull/86366) ([Daniil Ivanik](https://github.com/divanik)). +* Changed resolving of the coalesced column from `OUTER JOIN ... USING` clause to be more consistent: previously, when selecting both the USING column and qualified columns (`a, t1.a, t2.a`) in a OUTER JOIN, the USING column would incorrectly be resolved to `t1.a`, showing 0/NULL for rows from the right table with no left match. Now identifiers from USING clause are always resolved to the coalesced column, while qualified identifiers resolve to the non-coalesced columns, regardless of which other identifiers are present in the query. For example: ```sql SELECT a, t1.a, t2.a FROM (SELECT 1 as a WHERE 0) t1 FULL JOIN (SELECT 2 as a) t2 USING (a) -- Before: a=0, t1.a=0, t2.a=2 (incorrect - 'a' resolved to t1.a) -- After: a=2, t1.a=0, t2.a=2 (correct - 'a' is coalesced). [#80848](https://github.com/ClickHouse/ClickHouse/pull/80848) ([Vladimir Cherkasov](https://github.com/vdimir)). +* Increase replicated deduplication window up to 10000. This is fully compatible, but we can imagine scenarios when this change could lead to high resource consumption in the presence of a large number of tables. [#86820](https://github.com/ClickHouse/ClickHouse/pull/86820) ([Sema Checherinda](https://github.com/CheSema)). + +#### New Feature +* Users can now use NATS JetStream to consume messages by specifying the new settings of `nats_stream` and `nats_consumer` for the NATS engine. [#84799](https://github.com/ClickHouse/ClickHouse/pull/84799) ([Dmitry Novikov](https://github.com/dmitry-sles-novikov)). +* Added support for authentication and SSL in the `arrowFlight` table function. [#87120](https://github.com/ClickHouse/ClickHouse/pull/87120) ([Vitaly Baranov](https://github.com/vitlibar)). +* Add new parameter to `S3` table engine and `s3` table function named `storage_class_name` which allows to specify intelligent tiring supported by AWS. Supported both in key-value format and in positional (deprecated) format). [#87122](https://github.com/ClickHouse/ClickHouse/pull/87122) ([alesapin](https://github.com/alesapin)). +* `ALTER UPDATE` for Iceberg table engine. [#86059](https://github.com/ClickHouse/ClickHouse/pull/86059) ([scanhex12](https://github.com/scanhex12)). +* Add system table `iceberg_metadata_log` to retrieve Iceberg metadata files during SELECT statements. [#86152](https://github.com/ClickHouse/ClickHouse/pull/86152) ([scanhex12](https://github.com/scanhex12)). +* `Iceberg` and `DeltaLake` tables support custom disk configuration via storage level setting `disk`. [#86778](https://github.com/ClickHouse/ClickHouse/pull/86778) ([scanhex12](https://github.com/scanhex12)). +* Support Azure for data lakes disks. [#87173](https://github.com/ClickHouse/ClickHouse/pull/87173) ([scanhex12](https://github.com/scanhex12)). +* Support `Unity` catalog on top of Azure blob storage. [#80013](https://github.com/ClickHouse/ClickHouse/pull/80013) ([Smita Kulkarni](https://github.com/SmitaRKulkarni)). +* Support more formats (`ORC`, `Avro`) in `Iceberg` writes. This closes [#86179](https://github.com/ClickHouse/ClickHouse/issues/86179). [#87277](https://github.com/ClickHouse/ClickHouse/pull/87277) ([scanhex12](https://github.com/scanhex12)). +* Add a new system table `database_replicas` with information about database replicas. [#83408](https://github.com/ClickHouse/ClickHouse/pull/83408) ([Konstantin Morozov](https://github.com/k-morozov)). +* Added function `arrayExcept` that subtracts one array as a set from another. [#82368](https://github.com/ClickHouse/ClickHouse/pull/82368) ([Joanna Hulboj](https://github.com/jh0x)). +* Adds a new `system.aggregated_zookeeper_log` table. The table contains statistics (e.g. number of operations, average latency, errors) of ZooKeeper operations grouped by session id, parent path and operation type, and periodically flushed to disk. [#85102](https://github.com/ClickHouse/ClickHouse/pull/85102) [#87208](https://github.com/ClickHouse/ClickHouse/pull/87208) ([Miсhael Stetsyuk](https://github.com/mstetsyuk)). +* A new function, `isValidASCII`. Returns 1 if the input string or FixedString contains only ASCII bytes (0x00–0x7F) else 0. Closes [#85377](https://github.com/ClickHouse/ClickHouse/issues/85377). ... [#85786](https://github.com/ClickHouse/ClickHouse/pull/85786) ([rajat mohan](https://github.com/rajatmohan22)). +* Boolean settings can be specified without arguments, e.g., `SET use_query_cache;`, which is equivalent to setting it to true. [#85800](https://github.com/ClickHouse/ClickHouse/pull/85800) ([thraeka](https://github.com/thraeka)). +* New configuration options: `logger.startupLevel` & `logger.shutdownLevel` allow for overriding the log level during the startup & shutdown of Clickhouse respectively. [#85967](https://github.com/ClickHouse/ClickHouse/pull/85967) ([Lennard Eijsackers](https://github.com/Blokje5)). +* Aggregate functions `timeSeriesChangesToGrid` and `timeSeriesResetsToGrid`. Behaves similarly to `timeSeriesRateToGrid`, accepting parameters for start timestamp, end timestamp, step, and look back window, as well as two arguments for the timestamps and values, but requiring at least 1 sample per window instead of 2. Calculates a PromQL `changes`/`resets`, counting the number of times the sample value changes or decreases in the specified window for each timestamp in the time grid defined by the parameters. The return type is `Array(Nullable(Float64))`. [#86010](https://github.com/ClickHouse/ClickHouse/pull/86010) ([Stephen Chi](https://github.com/stephchi0)). +* Allows users to create temporary views with a similar syntax to temporary tables (`CREATE TEMPORARY VIEW`). [#86432](https://github.com/ClickHouse/ClickHouse/pull/86432) ([Aly Kafoury](https://github.com/AlyHKafoury)). +* Add warnings for CPU and memory usage to the `system.warnings` table. [#86838](https://github.com/ClickHouse/ClickHouse/pull/86838) ([Bharat Nallan](https://github.com/bharatnc)). +* Support the `oneof` indicator in `Protobuf` inputs. A special column may be used to indicate the presence of part of oneof. If a message contains [oneof](https://protobuf.dev/programming-guides/proto3/#oneof) and `input_format_protobuf_oneof_presence` is set, ClickHouse fills column that indicates which field of oneof was found. [#82885](https://github.com/ClickHouse/ClickHouse/pull/82885) ([Ilya Golshtein](https://github.com/ilejn)). +* Improve allocation profiling based on jemalloc's internal tooling. Global jemalloc profiler can now be enabled with config `jemalloc_enable_global_profiler`. Sampled global allocations and deallocations can be stored in `system.trace_log` under `JemallocSample` type by enabling config `jemalloc_collect_global_profile_samples_in_trace_log`. Jemalloc profiling can now be enabled for each query independently using setting `jemalloc_enable_profiler`. Storing samples in `system.trace_log` can be controlled per query using setting `jemalloc_collect_profile_samples_in_trace_log`. Update jemalloc to newer version. [#85438](https://github.com/ClickHouse/ClickHouse/pull/85438) ([Antonio Andelic](https://github.com/antonio2368)). +* A new setting to delete files on dropping Iceberg tables. This closes [#86211](https://github.com/ClickHouse/ClickHouse/issues/86211). [#86501](https://github.com/ClickHouse/ClickHouse/pull/86501) ([scanhex12](https://github.com/scanhex12)). + +#### Experimental Feature +* The inverted text index was reworked from scratch to be scalable for datasets that don't fit into RAM. [#86485](https://github.com/ClickHouse/ClickHouse/pull/86485) ([Anton Popov](https://github.com/CurtizJ)). +* Join reordering now uses statistics. The feature can be enabled by setting `allow_statistics_optimize = 1` and `query_plan_optimize_join_order_limit = 10`. [#86822](https://github.com/ClickHouse/ClickHouse/pull/86822) ([Han Fei](https://github.com/hanfei1991)). +* Support `alter table ... materialize statistics all` will materialize all the statistics of a table. [#87197](https://github.com/ClickHouse/ClickHouse/pull/87197) ([Han Fei](https://github.com/hanfei1991)). + +#### Performance Improvement +* Support filtering data parts using skip indexes during reading to reduce unnecessary index reads. Controlled by the new setting `use_skip_indexes_on_data_read` (disabled by default). This addresses [#75774](https://github.com/ClickHouse/ClickHouse/issues/75774). This includes some common groundwork shared with [#81021](https://github.com/ClickHouse/ClickHouse/issues/81021). [#81526](https://github.com/ClickHouse/ClickHouse/pull/81526) ([Amos Bird](https://github.com/amosbird)). +* Added JOIN order optimization that can automatically reorder JOINs for better performance (controlled by `query_plan_optimize_join_order_limit` setting). Note that the join order optimization currently has limited statistics support and primarily relies on row count estimates from storage engines - more sophisticated statistics collection and cardinality estimation will be added in future releases. **If you encounter issues with JOIN queries after upgrading**, you can temporarily disable the new implementation by setting `SET query_plan_use_new_logical_join_step = 0` and report the issue for investigation. **Note about resolution of identifiers from USING clause**: Changed resolving of the coalesced column from `OUTER JOIN ... USING` clause to be more consistent: previously, when selecting both the USING column and qualified columns (`a, t1.a, t2.a`) in a OUTER JOIN, the USING column would incorrectly be resolved to `t1.a`, showing 0/NULL for rows from the right table with no left match. Now identifiers from USING clause are always resolved to the coalesced column, while qualified identifiers resolve to the non-coalesced columns, regardless of which other identifiers are present in the query. For example: ```sql SELECT a, t1.a, t2.a FROM (SELECT 1 as a WHERE 0) t1 FULL JOIN (SELECT 2 as a) t2 USING (a) -- Before: a=0, t1.a=0, t2.a=2 (incorrect - 'a' resolved to t1.a) -- After: a=2, t1.a=0, t2.a=2 (correct - 'a' is coalesced). [#80848](https://github.com/ClickHouse/ClickHouse/pull/80848) ([Vladimir Cherkasov](https://github.com/vdimir)). +* Distributed `INSERT SELECT` for data lakes. [#86783](https://github.com/ClickHouse/ClickHouse/pull/86783) ([scanhex12](https://github.com/scanhex12)). +* Improve PREWHERE optimization for conditions like `func(primary_column) = 'xx'` and `column in (xxx)`. [#85529](https://github.com/ClickHouse/ClickHouse/pull/85529) ([李扬](https://github.com/taiyang-li)). +* Implemented rewriting of JOIN: 1. Convert `LEFT ANY JOIN` and `RIGHT ANY JOIN` to `SEMI`/`ANTI` JOIN if the filter condition is always false for matched or non-matched rows. This optimization is controlled by a new setting `query_plan_convert_any_join_to_semi_or_anti_join`. 2. Convert `FULL ALL JOIN` to `LEFT ALL` or `RIGHT ALL` JOIN if the filter condition is always false for non-matched rows from one side. [#86028](https://github.com/ClickHouse/ClickHouse/pull/86028) ([Dmitry Novik](https://github.com/novikd)). +* Improved performance of vertical merges after executing a lightweight delete. [#86169](https://github.com/ClickHouse/ClickHouse/pull/86169) ([Anton Popov](https://github.com/CurtizJ)). +* `HashJoin` performance optimised slightly in the case of `LEFT/RIGHT` join having a lot of unmatched rows. [#86312](https://github.com/ClickHouse/ClickHouse/pull/86312) ([Nikita Taranov](https://github.com/nickitat)). +* Radix sort: help the compiler use SIMD and do better prefetching. Uses dynamic dispatch to use software prefetching with Intel CPUs only. Continues the work by @taiyang-li in https://github.com/ClickHouse/ClickHouse/pull/77029. [#86378](https://github.com/ClickHouse/ClickHouse/pull/86378) ([Raúl Marín](https://github.com/Algunenano)). +* Improves performance of short queries with lots of parts in tables (by optimizing `MarkRanges` by using `devector` over `deque`). [#86933](https://github.com/ClickHouse/ClickHouse/pull/86933) ([Azat Khuzhin](https://github.com/azat)). +* Improved performance of applying patch parts in the join mode. [#87094](https://github.com/ClickHouse/ClickHouse/pull/87094) ([Anton Popov](https://github.com/CurtizJ)). +* Added setting `query_condition_cache_selectivity_threshold` (default value: 1.0) which excludes scan results of predicates with low selectivity from insertion into the query condition cache. This allows to reduce the memory consumption of the query condition cache at the cost of a worse cache hit rate. [#86076](https://github.com/ClickHouse/ClickHouse/pull/86076) ([zhongyuankai](https://github.com/zhongyuankai)). +* Reduce memory usage in Iceberg writes. [#86544](https://github.com/ClickHouse/ClickHouse/pull/86544) ([scanhex12](https://github.com/scanhex12)). + +#### Improvement +* Support writing multiple data files in Iceberg in a single insertion. Add new settings, `iceberg_insert_max_rows_in_data_file` and `iceberg_insert_max_bytes_in_data_file` to control the limits. [#86275](https://github.com/ClickHouse/ClickHouse/pull/86275) ([scanhex12](https://github.com/scanhex12)). +* Add rows/bytes limit for inserted data files in delta lake. Controlled by settings `delta_lake_insert_max_rows_in_data_file` and `delta_lake_insert_max_bytes_in_data_file`. [#86357](https://github.com/ClickHouse/ClickHouse/pull/86357) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Support more types for partitions in Iceberg writes. This closes [#86206](https://github.com/ClickHouse/ClickHouse/issues/86206). [#86298](https://github.com/ClickHouse/ClickHouse/pull/86298) ([scanhex12](https://github.com/scanhex12)). +* Make S3 retry strategy configurable and make settings of S3 disk can be hot reload if change the config XML file. [#82642](https://github.com/ClickHouse/ClickHouse/pull/82642) ([RinChanNOW](https://github.com/RinChanNOWWW)). +* Improved S3(Azure)Queue table engine to allow it to survive zookeeper connection loss without potential duplicates. Requires enabling S3Queue setting `use_persistent_processing_nodes` (changeable by `ALTER TABLE MODIFY SETTING`). [#85995](https://github.com/ClickHouse/ClickHouse/pull/85995) ([Kseniia Sumarokova](https://github.com/kssenii)). +* You can use query parameters after `TO` when creating a materialized view, for example: `CREATE MATERIALIZED VIEW mv TO {to_table:Identifier} AS SELECT * FROM src_table`. [#84899](https://github.com/ClickHouse/ClickHouse/pull/84899) ([Diskein](https://github.com/Diskein)). +* Give more clear instruction for users when incorrect settings are specified for the `Kafka2` table engine. [#83701](https://github.com/ClickHouse/ClickHouse/pull/83701) ([János Benjamin Antal](https://github.com/antaljanosbenjamin)). +* It's no longer possible to specify time zones for the `Time` type (it didn't make sense). [#84689](https://github.com/ClickHouse/ClickHouse/pull/84689) ([Yarik Briukhovetskyi](https://github.com/yariks5s)). +* Simplified (and avoided some bugs) a logic related to parsing Time/Time64 in the `best_effort` mode. [#84730](https://github.com/ClickHouse/ClickHouse/pull/84730) ([Yarik Briukhovetskyi](https://github.com/yariks5s)). +* Added `deltaLakeAzureCluster` function (similar to `deltaLakeAzure` for the cluster mode) and `deltaLakeS3Cluster` (alias to `deltaLakeCluster`) function. Resolves [#85358](https://github.com/ClickHouse/ClickHouse/issues/85358). [#85547](https://github.com/ClickHouse/ClickHouse/pull/85547) ([Smita Kulkarni](https://github.com/SmitaRKulkarni)). +* Apply `azure_max_single_part_copy_size` setting for normal copy operations in the same way as for backup. [#85767](https://github.com/ClickHouse/ClickHouse/pull/85767) ([Ilya Golshtein](https://github.com/ilejn)). +* Slow down S3 client threads on retryable errors in S3 Object Storage. This extends the previous setting `backup_slow_all_threads_after_retryable_s3_error` to S3 disks and renames it to the more general `s3_slow_all_threads_after_retryable_error`. [#85918](https://github.com/ClickHouse/ClickHouse/pull/85918) ([Julia Kartseva](https://github.com/jkartseva)). +* Mark settings allow_experimental_variant/dynamic/json and enable_variant/dynamic/json as obsolete. Now all three types are enabled unconditionally. [#85934](https://github.com/ClickHouse/ClickHouse/pull/85934) ([Pavel Kruglov](https://github.com/Avogar)). +* Support filtering by complete URL string (`full_url` directive) in `http_handlers` (including schema and host:port). [#86155](https://github.com/ClickHouse/ClickHouse/pull/86155) ([Azat Khuzhin](https://github.com/azat)). +* Add a new setting, `allow_experimental_delta_lake_writes`. [#86180](https://github.com/ClickHouse/ClickHouse/pull/86180) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Fix detection of systemd in init.d script (fixes "Install packages" check). [#86187](https://github.com/ClickHouse/ClickHouse/pull/86187) ([Azat Khuzhin](https://github.com/azat)). +* Add a new `startup_scripts_failure_reason` dimensional metric. This metric is needed to distinguish between different error types that result in failing startup scripts. In particular, for alerting purposes, we need to distinguish between transient (e.g., `MEMORY_LIMIT_EXCEEDED` or `KEEPER_EXCEPTION`) and non-transient errors. [#86202](https://github.com/ClickHouse/ClickHouse/pull/86202) ([Miсhael Stetsyuk](https://github.com/mstetsyuk)). +* Allow to omit `identity` function for partition for Iceberg table. [#86314](https://github.com/ClickHouse/ClickHouse/pull/86314) ([scanhex12](https://github.com/scanhex12)). +* Add ability to enable JSON logging only for specific channel, for this set `logger.formatting.channel` to one of `syslog`/`console`/`errorlog`/`log`. [#86331](https://github.com/ClickHouse/ClickHouse/pull/86331) ([Azat Khuzhin](https://github.com/azat)). +* Allow using native numbers in `WHERE`. They are already allowed to be arguments of logical functions. This simplifies filter-push-down and move-to-prewhere optimizations. [#86390](https://github.com/ClickHouse/ClickHouse/pull/86390) ([Nikolai Kochetov](https://github.com/KochetovNicolai)). +* Fixed error in case of executing `SYSTEM DROP REPLICA` against a Catalog with corrupted metadata. [#86391](https://github.com/ClickHouse/ClickHouse/pull/86391) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)). +* Add extra retries for disk access check (`skip_access_check = 0`) in Azure because it may be provisioning access for quite a long time. [#86419](https://github.com/ClickHouse/ClickHouse/pull/86419) ([Alexander Tokmakov](https://github.com/tavplubix)). +* Make the staleness window in `timeSeries*()` functions left-open and right-closed. [#86588](https://github.com/ClickHouse/ClickHouse/pull/86588) ([Vitaly Baranov](https://github.com/vitlibar)). +* Add `FailedInternal*Query` profile events. [#86627](https://github.com/ClickHouse/ClickHouse/pull/86627) ([Shane Andrade](https://github.com/mauidude)). +* Fixes handling of users with a dot in the name when added via config file. [#86633](https://github.com/ClickHouse/ClickHouse/pull/86633) ([Mikhail Koviazin](https://github.com/mkmkme)). +* Add asynchronous metric for memory usage in queries (`QueriesMemoryUsage` and `QueriesPeakMemoryUsage`). [#86669](https://github.com/ClickHouse/ClickHouse/pull/86669) ([Azat Khuzhin](https://github.com/azat)). +* You can use `clickhouse-benchmark --precise` flag for more precise reporting of QPS and other per-interval metrics. It helps to get consistent QPS in case if durations of queries are comparable to the reporting interval `--delay D`. [#86684](https://github.com/ClickHouse/ClickHouse/pull/86684) ([Sergei Trifonov](https://github.com/serxa)). +* Make nice values of Linux threads configurable to assign some threads (merge/mutate, query, materialized view, zookeeper client) higher or lower priorities. [#86703](https://github.com/ClickHouse/ClickHouse/pull/86703) ([Miсhael Stetsyuk](https://github.com/mstetsyuk)). +* Fix misleading “specified upload does not exist” error, which occurs when the original exception is lost in multipart upload because of a race condition. [#86725](https://github.com/ClickHouse/ClickHouse/pull/86725) ([Julia Kartseva](https://github.com/jkartseva)). +* Limit query plan description in the `EXPLAIN` query. Do not calculate the description for queries other than `EXPLAIN`. Added a steeing `query_plan_max_step_description_length`. [#86741](https://github.com/ClickHouse/ClickHouse/pull/86741) ([Nikolai Kochetov](https://github.com/KochetovNicolai)). +* Add ability to tune pending signals in attempt to overcome CANNOT_CREATE_TIMER (for query profilers, `query_profiler_real_time_period_ns`/`query_profiler_cpu_time_period_ns`). And also collect `SigQ` from the `/proc/self/status` for introspection (if `ProcessSignalQueueSize` is near to `ProcessSignalQueueLimit`, then you will likely get `CANNOT_CREATE_TIMER` errors). [#86760](https://github.com/ClickHouse/ClickHouse/pull/86760) ([Azat Khuzhin](https://github.com/azat)). +* Improve performance of `RemoveRecursive` request in Keeper. [#86789](https://github.com/ClickHouse/ClickHouse/pull/86789) ([Antonio Andelic](https://github.com/antonio2368)). +* Remove extra whitespace in `PrettyJSONEachRow` during JSON type output. [#86819](https://github.com/ClickHouse/ClickHouse/pull/86819) ([Pavel Kruglov](https://github.com/Avogar)). +* Now we write blobs sizes of for `prefix.path` when directory is removed for plain rewriteable disk. [#86908](https://github.com/ClickHouse/ClickHouse/pull/86908) ([alesapin](https://github.com/alesapin)). +* Support performance tests against remote ClickHouse instances, including ClickHouse Cloud. Usage example: `tests/performance/scripts/perf.py tests/performance/math.xml --runs 10 --user --password --host --port --secure`. [#86995](https://github.com/ClickHouse/ClickHouse/pull/86995) ([Raufs Dunamalijevs](https://github.com/rienath)). +* Respect memory limits in some places that are known to allocate significant (>16MiB) amount of memory (sorting, async inserts, file log). [#87035](https://github.com/ClickHouse/ClickHouse/pull/87035) ([Azat Khuzhin](https://github.com/azat)). +* Throw an exception if setting `network_compression_method` is not a supported generic codec. [#87097](https://github.com/ClickHouse/ClickHouse/pull/87097) ([Robert Schulze](https://github.com/rschu1ze)). +* System table `system.query_cache` now returns _all_ query result cache entries, whereas it previously returned only shared entries or non-shared entries of the same user and role. That is okay as non-shared entries are supposed to not reveal _query results_, whereas `system.query_cache` returns _query strings_. This makes the behavior of the system table more similar to `system.query_log`. [#87104](https://github.com/ClickHouse/ClickHouse/pull/87104) ([Robert Schulze](https://github.com/rschu1ze)). +* Enable short circuit evaluation for `parseDateTime` function. [#87184](https://github.com/ClickHouse/ClickHouse/pull/87184) ([Pavel Kruglov](https://github.com/Avogar)). +* Add a new column `statistics` in `system.parts_columns`. [#87259](https://github.com/ClickHouse/ClickHouse/pull/87259) ([Han Fei](https://github.com/hanfei1991)). + +#### Bug Fix (user-visible misbehavior in an official stable release) +* The results of alter queries are only validated on the initiator node for replicated databases and internally replicated tables. This will fix situations where an already committed alter query could get stuck on other nodes. [#83849](https://github.com/ClickHouse/ClickHouse/pull/83849) ([János Benjamin Antal](https://github.com/antaljanosbenjamin)). +* Limit the number of tasks of each type in `BackgroundSchedulePool`. Avoid situations when all slots are occupied by task of one type, while other tasks are starving. Also avoids deadlocks when tasks wait for each other. This is controlled by `background_schedule_pool_max_parallel_tasks_per_type_ratio` server setting. [#84008](https://github.com/ClickHouse/ClickHouse/pull/84008) ([Alexander Tokmakov](https://github.com/tavplubix)). +* Shutdown tables properly when recovering database replica. Improper shutdown would lead to LOGICAL_ERROR for some table engines during database replica recovery. [#84744](https://github.com/ClickHouse/ClickHouse/pull/84744) ([Antonio Andelic](https://github.com/antonio2368)). +* Check access rights during typo correction hints generation for the database name. [#85371](https://github.com/ClickHouse/ClickHouse/pull/85371) ([Dmitry Novik](https://github.com/novikd)). +* 1. LowCardinality for hive columns 2. Fill hive columns before virtual columns (required for https://github.com/ClickHouse/ClickHouse/pull/81040) 3. LOGICAL_ERROR on empty format for hive [#85528](https://github.com/ClickHouse/ClickHouse/issues/85528) 4. Fix check for hive partition columns being the only columns 5. Assert all hive columns are specified in the schema 6. Partial fix for parallel_replicas_cluster with hive 7. Use ordered container in extractkeyValuePairs for hive utils (required for https://github.com/ClickHouse/ClickHouse/pull/81040). [#85538](https://github.com/ClickHouse/ClickHouse/pull/85538) ([Arthur Passos](https://github.com/arthurpassos)). +* Prevent unnecessary optimization of the first argument of `IN` functions sometimes resulting in error when array mapping is used. [#85546](https://github.com/ClickHouse/ClickHouse/pull/85546) ([Yakov Olkhovskiy](https://github.com/yakov-olkhovskiy)). +* Mapping between iceberg source ids and parquet names was not adjusted to the schema when the parquet file was written. This PR processes schema relevant for each iceberg data file, not a current one. [#85829](https://github.com/ClickHouse/ClickHouse/pull/85829) ([Daniil Ivanik](https://github.com/divanik)). +* Fix reading file size separately from opening it. Relates to https://github.com/ClickHouse/ClickHouse/pull/33372, which was introduced in response to a bug in Linux kernels prior to `5.10` release. [#85837](https://github.com/ClickHouse/ClickHouse/pull/85837) ([Konstantin Bogdanov](https://github.com/thevar1able)). +* ClickHouse Keeper no longer fails to start on systems where IPv6 is disabled at the kernel level (e.g., RHEL with ipv6.disable=1). It now attempts to fall back to an IPv4 listener if the initial IPv6 listener fails. [#85901](https://github.com/ClickHouse/ClickHouse/pull/85901) ([jskong1124](https://github.com/jskong1124)). +* This PR closes [#77990](https://github.com/ClickHouse/ClickHouse/issues/77990). Add TableFunctionRemote support for parallel replicas in globalJoin. [#85929](https://github.com/ClickHouse/ClickHouse/pull/85929) ([zoomxi](https://github.com/zoomxi)). +* Fix null pointer in orcschemareader::initializeifneeded(). this pr addresses the following issue: [#85292](https://github.com/ClickHouse/ClickHouse/issues/85292) ### documentation entry for user-facing changes. [#85951](https://github.com/ClickHouse/ClickHouse/pull/85951) ([yanglongwei](https://github.com/ylw510)). +* Add a check to allow correlated subqueries in the FROM clause only if they use columns from the outer query. Fixes [#85469](https://github.com/ClickHouse/ClickHouse/issues/85469). Fixes [#85402](https://github.com/ClickHouse/ClickHouse/issues/85402). [#85966](https://github.com/ClickHouse/ClickHouse/pull/85966) ([Dmitry Novik](https://github.com/novikd)). +* Fix alter update of a column with a subcolumn used in other column materialized expression. Previously materialized column with subcolumn in its expression was not updated properly. [#85985](https://github.com/ClickHouse/ClickHouse/pull/85985) ([Pavel Kruglov](https://github.com/Avogar)). +* Forbid altering columns whose subcolumns are used in PK or partition expression. [#86005](https://github.com/ClickHouse/ClickHouse/pull/86005) ([Pavel Kruglov](https://github.com/Avogar)). +* Fix reading subcolumns with non-default column mapping mode in storage DeltaLake. [#86064](https://github.com/ClickHouse/ClickHouse/pull/86064) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Fix using wrong default values for path with Enum hint inside JSON. [#86065](https://github.com/ClickHouse/ClickHouse/pull/86065) ([Pavel Kruglov](https://github.com/Avogar)). +* DataLake hive catalog url parsing with input sanitisation. Closes [#86018](https://github.com/ClickHouse/ClickHouse/issues/86018). [#86092](https://github.com/ClickHouse/ClickHouse/pull/86092) ([rajat mohan](https://github.com/rajatmohan22)). +* Fix logical error during filesystem cache dynamic resize. Closes [#86122](https://github.com/ClickHouse/ClickHouse/issues/86122). Closes https://github.com/ClickHouse/clickhouse-core-incidents/issues/473. [#86130](https://github.com/ClickHouse/ClickHouse/pull/86130) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Use `NonZeroUInt64` for `logs_to_keep` in DatabaseReplicatedSettings. [#86142](https://github.com/ClickHouse/ClickHouse/pull/86142) ([Tuan Pham Anh](https://github.com/tuanpach)). +* Exception was thrown by a `FINAL` query with skip index if the table (e.g `ReplacingMergeTree`) was created with setting`index_granularity_bytes = 0`. That exception has been fixed now. [#86147](https://github.com/ClickHouse/ClickHouse/pull/86147) ([Shankar Iyer](https://github.com/shankar-iyer)). +* Removes UB and fixes problems with parsing of Iceberg partition expression. [#86166](https://github.com/ClickHouse/ClickHouse/pull/86166) ([Daniil Ivanik](https://github.com/divanik)). +* Fix crash in case of const and non-const blocks in one INSERT. [#86230](https://github.com/ClickHouse/ClickHouse/pull/86230) ([Azat Khuzhin](https://github.com/azat)). +* Process includes from `/etc/metrika.xml` as a default when creating disks from SQL. [#86232](https://github.com/ClickHouse/ClickHouse/pull/86232) ([alekar](https://github.com/alekar)). +* Fix accurateCastOrNull/accurateCastOrDefault from String to JSON. [#86240](https://github.com/ClickHouse/ClickHouse/pull/86240) ([Pavel Kruglov](https://github.com/Avogar)). +* Support directories without '/' in iceberg engine. [#86249](https://github.com/ClickHouse/ClickHouse/pull/86249) ([scanhex12](https://github.com/scanhex12)). +* Fix crash with replaceRegex, a FixedString haystack and an empty needle. [#86270](https://github.com/ClickHouse/ClickHouse/pull/86270) ([Raúl Marín](https://github.com/Algunenano)). +* Fix crash during ALTER UPDATE Nullable(JSON). [#86281](https://github.com/ClickHouse/ClickHouse/pull/86281) ([Pavel Kruglov](https://github.com/Avogar)). +* Fix missing column definer in system.tables. [#86295](https://github.com/ClickHouse/ClickHouse/pull/86295) ([Raúl Marín](https://github.com/Algunenano)). +* Fix cast from LowCardinality(Nullable(T)) to Dynamic. [#86365](https://github.com/ClickHouse/ClickHouse/pull/86365) ([Pavel Kruglov](https://github.com/Avogar)). +* Fix logical error during writes to DeltaLake. Closes [#86175](https://github.com/ClickHouse/ClickHouse/issues/86175). [#86367](https://github.com/ClickHouse/ClickHouse/pull/86367) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Fix `416 The range specified is invalid for the current size of the resource. The range specified is invalid for the current size of the resource` when reading empty blobs from Azure blob storage for plain_rewritable disk. [#86400](https://github.com/ClickHouse/ClickHouse/pull/86400) ([Julia Kartseva](https://github.com/jkartseva)). +* Fix GROUP BY Nullable(JSON). [#86410](https://github.com/ClickHouse/ClickHouse/pull/86410) ([Pavel Kruglov](https://github.com/Avogar)). +* Fixed a bug in Materialized Views: an MV might not work if it was created, dropped, and then created again with the same name. [#86413](https://github.com/ClickHouse/ClickHouse/pull/86413) ([Alexander Tokmakov](https://github.com/tavplubix)). +* Fail if all replicas are unavailable when reading from *cluster functions. [#86414](https://github.com/ClickHouse/ClickHouse/pull/86414) ([Julian Maicher](https://github.com/jmaicher)). +* Fix leaking of `MergesMutationsMemoryTracking` due to `Buffer` tables and fix `query_views_log` for streaming from `Kafka` (and others). [#86422](https://github.com/ClickHouse/ClickHouse/pull/86422) ([Azat Khuzhin](https://github.com/azat)). +* Fix show tables after dropping reference table of alias storage. [#86433](https://github.com/ClickHouse/ClickHouse/pull/86433) ([RinChanNOW](https://github.com/RinChanNOWWW)). +* Fix missing chunk header when send_chunk_header is enabled and UDF is invoked via HTTP protocol. [#86469](https://github.com/ClickHouse/ClickHouse/pull/86469) ([Vladimir Cherkasov](https://github.com/vdimir)). +* Fix possible deadlock in case of jemalloc profile flushes enabled. [#86473](https://github.com/ClickHouse/ClickHouse/pull/86473) ([Azat Khuzhin](https://github.com/azat)). +* Fix reading subcolumns in DeltaLake table engine. Closes [#86204](https://github.com/ClickHouse/ClickHouse/issues/86204). [#86477](https://github.com/ClickHouse/ClickHouse/pull/86477) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Handling loopback host ID properly to avoid collision when processing DDL tasks:. [#86479](https://github.com/ClickHouse/ClickHouse/pull/86479) ([Tuan Pham Anh](https://github.com/tuanpach)). +* Fix detach/attach for postgres database engine tables with numeric/decimal columns. [#86480](https://github.com/ClickHouse/ClickHouse/pull/86480) ([Julian Maicher](https://github.com/jmaicher)). +* Fix use of uninitialized memory in getSubcolumnType. [#86498](https://github.com/ClickHouse/ClickHouse/pull/86498) ([Raúl Marín](https://github.com/Algunenano)). +* Functions `searchAny` and `searchAll` when called with empty needles now return `true` (aka. "matches everything"). Previously, they returned `false`. (issue [#86300](https://github.com/ClickHouse/ClickHouse/issues/86300)). [#86500](https://github.com/ClickHouse/ClickHouse/pull/86500) ([Elmi Ahmadov](https://github.com/ahmadov)). +* Fix function `timeSeriesResampleToGridWithStaleness()` when the first bucket has no value. [#86507](https://github.com/ClickHouse/ClickHouse/pull/86507) ([Vitaly Baranov](https://github.com/vitlibar)). +* Fix crash caused by `merge_tree_min_read_task_size` being set to 0. [#86527](https://github.com/ClickHouse/ClickHouse/pull/86527) ([yanglongwei](https://github.com/ylw510)). +* While reading takes format for each data file from Iceberg metadata (earlier it was taken from table arguments). [#86529](https://github.com/ClickHouse/ClickHouse/pull/86529) ([Daniil Ivanik](https://github.com/divanik)). +* Ignore exceptions during flushing log on shutdown and make shutdown more safe (to avoid SIGSEGV). [#86546](https://github.com/ClickHouse/ClickHouse/pull/86546) ([Azat Khuzhin](https://github.com/azat)). +* Fix Backup db engine raising exception on query with zero sized part files. [#86563](https://github.com/ClickHouse/ClickHouse/pull/86563) ([Max Justus Spransy](https://github.com/maxjustus)). +* Fix missing chunk header when send_chunk_header is enabled and UDF is invoked via HTTP protocol. [#86606](https://github.com/ClickHouse/ClickHouse/pull/86606) ([Vladimir Cherkasov](https://github.com/vdimir)). +* Fix S3Queue logical error "Expected current processor {} to be equal to {}", which happened because of keeper session expiration. [#86615](https://github.com/ClickHouse/ClickHouse/pull/86615) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Nullablity bugs in insert and pruning. This closes [#86407](https://github.com/ClickHouse/ClickHouse/issues/86407). [#86630](https://github.com/ClickHouse/ClickHouse/pull/86630) ([scanhex12](https://github.com/scanhex12)). +* Do not disable file system cache if Iceberg metadata cache is disabled. [#86635](https://github.com/ClickHouse/ClickHouse/pull/86635) ([Daniil Ivanik](https://github.com/divanik)). +* Fixed 'Deadlock in Parquet::ReadManager (single-threaded)' error in parquet reader v3. [#86644](https://github.com/ClickHouse/ClickHouse/pull/86644) ([Michael Kolupaev](https://github.com/al13n321)). +* Fix support for IPv6 in `listen_host` for ArrowFlight. [#86664](https://github.com/ClickHouse/ClickHouse/pull/86664) ([Vitaly Baranov](https://github.com/vitlibar)). +* Fix shutdown in `ArrowFlight` handler. This PR fixes [#86596](https://github.com/ClickHouse/ClickHouse/issues/86596). [#86665](https://github.com/ClickHouse/ClickHouse/pull/86665) ([Vitaly Baranov](https://github.com/vitlibar)). +* Fix distributed queries with `describe_compact_output=1`. [#86676](https://github.com/ClickHouse/ClickHouse/pull/86676) ([Azat Khuzhin](https://github.com/azat)). +* Fix window definition parsing and applying query parameters. [#86720](https://github.com/ClickHouse/ClickHouse/pull/86720) ([Azat Khuzhin](https://github.com/azat)). +* Fix exception `Partition strategy wildcard can not be used without a '_partition_id' wildcard.` when creating a table with `PARTITION BY`, but without partition wildcard, which used to work in versions before 25.8. Closes https://github.com/ClickHouse/clickhouse-private/issues/37567. [#86748](https://github.com/ClickHouse/ClickHouse/pull/86748) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Fix LogicalError if parallel queries are trying to acquire single lock. [#86751](https://github.com/ClickHouse/ClickHouse/pull/86751) ([Pervakov Grigorii](https://github.com/GrigoryPervakov)). +* Fix writing NULL into JSON shared data in RowBinary input format and add some additional validations in ColumnObject. [#86812](https://github.com/ClickHouse/ClickHouse/pull/86812) ([Pavel Kruglov](https://github.com/Avogar)). +* Fix empty Tuple permutation with limit. [#86828](https://github.com/ClickHouse/ClickHouse/pull/86828) ([Pavel Kruglov](https://github.com/Avogar)). +* Do not use separate keeper node for persistent processing nodes. Fix for https://github.com/ClickHouse/ClickHouse/pull/85995. Closes [#86406](https://github.com/ClickHouse/ClickHouse/issues/86406). [#86841](https://github.com/ClickHouse/ClickHouse/pull/86841) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Fix TimeSeries engine table breaking creation of new replica in Replicated Database. [#86845](https://github.com/ClickHouse/ClickHouse/pull/86845) ([Nikolay Degterinsky](https://github.com/evillique)). +* Fix querying `system.distributed_ddl_queue` in cases where tasks are missing certain Keeper nodes. [#86848](https://github.com/ClickHouse/ClickHouse/pull/86848) ([Antonio Andelic](https://github.com/antonio2368)). +* Fix seeking at the end of the decompressed block. [#86906](https://github.com/ClickHouse/ClickHouse/pull/86906) ([Pavel Kruglov](https://github.com/Avogar)). +* Process exception which is thrown during asyncronous execution of Iceberg Iterator. [#86932](https://github.com/ClickHouse/ClickHouse/pull/86932) ([Daniil Ivanik](https://github.com/divanik)). +* Fix saving of big preprocessed XML configs. [#86934](https://github.com/ClickHouse/ClickHouse/pull/86934) ([c-end](https://github.com/c-end)). +* Fix date field populating in system.iceberg_metadata_log table. [#86961](https://github.com/ClickHouse/ClickHouse/pull/86961) ([Daniil Ivanik](https://github.com/divanik)). +* Fixed infinite recalculation of `TTL` with `WHERE`. [#86965](https://github.com/ClickHouse/ClickHouse/pull/86965) ([Anton Popov](https://github.com/CurtizJ)). +* Fixed possible incorrect result of `uniqExact` function with `ROLLUP` and `CUBE` modifiers. [#87014](https://github.com/ClickHouse/ClickHouse/pull/87014) ([Nikita Taranov](https://github.com/nickitat)). +* Fix resolving table schema with `url()` table function when `parallel_replicas_for_cluster_functions` setting is set to 1. [#87029](https://github.com/ClickHouse/ClickHouse/pull/87029) ([Konstantin Bogdanov](https://github.com/thevar1able)). +* Correctly cast output of PREWHERE after splitting it into multiple steps. [#87040](https://github.com/ClickHouse/ClickHouse/pull/87040) ([Antonio Andelic](https://github.com/antonio2368)). +* Fixed lightweight updates with `ON CLUSTER` clause. [#87043](https://github.com/ClickHouse/ClickHouse/pull/87043) ([Anton Popov](https://github.com/CurtizJ)). +* Fix compatibility of some aggregate function states with String argument. [#87049](https://github.com/ClickHouse/ClickHouse/pull/87049) ([Pavel Kruglov](https://github.com/Avogar)). +* Fixes an issue where model name from OpenAI wasn't passed through. [#87100](https://github.com/ClickHouse/ClickHouse/pull/87100) ([Kaushik Iska](https://github.com/iskakaushik)). +* EmbeddedRocksDB: Path must be inside user_files. [#87109](https://github.com/ClickHouse/ClickHouse/pull/87109) ([Raúl Marín](https://github.com/Algunenano)). +* Fix KeeperMap tables created before 25.1, leaving data in ZooKeeper after the DROP query. [#87112](https://github.com/ClickHouse/ClickHouse/pull/87112) ([Nikolay Degterinsky](https://github.com/evillique)). +* Fix maps and arrays field ids reading parquet. [#87136](https://github.com/ClickHouse/ClickHouse/pull/87136) ([scanhex12](https://github.com/scanhex12)). +* Fix reading array with array sizes subcolumn in lazy materialization. [#87139](https://github.com/ClickHouse/ClickHouse/pull/87139) ([Pavel Kruglov](https://github.com/Avogar)). +* Fix CASE function with Dynamic arguments. [#87177](https://github.com/ClickHouse/ClickHouse/pull/87177) ([Pavel Kruglov](https://github.com/Avogar)). +* Fix reading empty array from empty string in CSV. [#87182](https://github.com/ClickHouse/ClickHouse/pull/87182) ([Pavel Kruglov](https://github.com/Avogar)). +* Fix possible wrong result of non-correlated `EXISTS`. It was broken with `execute_exists_as_scalar_subquery=1` which was introduced in https://github.com/ClickHouse/ClickHouse/pull/85481 and affects `25.8`. Fixes [#86415](https://github.com/ClickHouse/ClickHouse/issues/86415). [#87207](https://github.com/ClickHouse/ClickHouse/pull/87207) ([Nikolai Kochetov](https://github.com/KochetovNicolai)). +* Throws an error if iceberg_metadata_log is not configured, but user tries to get debug iceberg metadata info. Fixes nullptr access. [#87250](https://github.com/ClickHouse/ClickHouse/pull/87250) ([Daniil Ivanik](https://github.com/divanik)). + +#### Build/Testing/Packaging Improvement +* Fix compatibility with abseil-cpp 20250814.0, https://github.com/abseil/abseil-cpp/issues/1923. [#85970](https://github.com/ClickHouse/ClickHouse/pull/85970) ([Yuriy Chernyshov](https://github.com/georgthegreat)). +* Put building standalone WASM lexer under a flag. [#86505](https://github.com/ClickHouse/ClickHouse/pull/86505) ([Konstantin Bogdanov](https://github.com/thevar1able)). +* Fix crc32c build on older ARM CPUs without support for the `vmull_p64` instruction. [#86521](https://github.com/ClickHouse/ClickHouse/pull/86521) ([Pablo Marcos](https://github.com/pamarcos)). +* Use `openldap` 2.6.10. [#86623](https://github.com/ClickHouse/ClickHouse/pull/86623) ([Konstantin Bogdanov](https://github.com/thevar1able)). +* Do not try to intercept `memalign` on darwin. [#86769](https://github.com/ClickHouse/ClickHouse/pull/86769) ([Konstantin Bogdanov](https://github.com/thevar1able)). +* Use `krb5` 1.22.1-final. [#86836](https://github.com/ClickHouse/ClickHouse/pull/86836) ([Konstantin Bogdanov](https://github.com/thevar1able)). +* Fix unpacking Rust crate names in `list-licenses.sh`. [#87305](https://github.com/ClickHouse/ClickHouse/pull/87305) ([Konstantin Bogdanov](https://github.com/thevar1able)). + + +### ClickHouse release 25.8 LTS, 2025-08-28 {#258} + +#### Backward Incompatible Change +* Infer `Array(Dynamic)` instead of unnamed `Tuple` for arrays of values with different types in JSON. To use the previous behaviour, disable setting `input_format_json_infer_array_of_dynamic_from_array_of_different_types`. [#80859](https://github.com/ClickHouse/ClickHouse/pull/80859) ([Pavel Kruglov](https://github.com/Avogar)). +* Move S3 latency metrics to histograms for homogeneity and simplicity. [#82305](https://github.com/ClickHouse/ClickHouse/pull/82305) ([Miсhael Stetsyuk](https://github.com/mstetsyuk)). +* Require backticks around identifiers with dots in default expressions to prevent them from being parsed as compound identifiers. [#83162](https://github.com/ClickHouse/ClickHouse/pull/83162) ([Pervakov Grigorii](https://github.com/GrigoryPervakov)). +* Lazy materialization is enabled only with analyzer (which is the default) to avoid maintenance without analyzer, — which, in our experience, have some issues (for example, when using `indexHint()` in conditions). [#83791](https://github.com/ClickHouse/ClickHouse/pull/83791) ([Igor Nikonov](https://github.com/devcrafter)). +* Write values of `Enum` type as `BYTE_ARRAY` with `ENUM` logical type in Parquet output format by default. [#84169](https://github.com/ClickHouse/ClickHouse/pull/84169) ([Pavel Kruglov](https://github.com/Avogar)). +* Enable MergeTree setting `write_marks_for_substreams_in_compact_parts` by default. It significantly improves performance of subcolumns reading from newly created Compact parts. Servers with version less then 25.5 won't be able to read new Compact parts. [#84171](https://github.com/ClickHouse/ClickHouse/pull/84171) ([Pavel Kruglov](https://github.com/Avogar)). +* The previous `concurrent_threads_scheduler` default value was `round_robin`, which proved unfair in the presence of a high number of single-threaded queries (e.g., INSERTs). This change makes a safer alternative `fair_round_robin` scheduler, the default. [#84747](https://github.com/ClickHouse/ClickHouse/pull/84747) ([Sergei Trifonov](https://github.com/serxa)). +* ClickHouse supports PostgreSQL-style heredoc syntax: `$tag$ string contents... $tag$`, also known as dollar-quoted string literals. In previous versions, there were fewer restrictions on tags: they could contain arbitrary characters, including punctuation and whitespace. This introduces parsing ambiguity with identifiers that can also start with a dollar character. At the same time, PostgreSQL only allows word characters for tags. To resolve the problem, we now restrict heredoc tags only to contain word characters. Closes [#84731](https://github.com/ClickHouse/ClickHouse/issues/84731). [#84846](https://github.com/ClickHouse/ClickHouse/pull/84846) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* The functions `azureBlobStorage`, `deltaLakeAzure`, and `icebergAzure` have been updated to properly validate `AZURE` permissions. All cluster-variant functions (`-Cluster` functions) now verify permissions against their corresponding non-clustered counterparts. Additionally, the `icebergLocal` and `deltaLakeLocal` functions now enforce `FILE` permission checks. [#84938](https://github.com/ClickHouse/ClickHouse/pull/84938) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)). +* Enables `allow_dynamic_metadata_for_data_lakes` setting (Table Engine level setting) by default. [#85044](https://github.com/ClickHouse/ClickHouse/pull/85044) ([Daniil Ivanik](https://github.com/divanik)). +* Disable quoting 64 bit integers in JSON formats by default. [#74079](https://github.com/ClickHouse/ClickHouse/pull/74079) ([Pavel Kruglov](https://github.com/Avogar)) + +#### New Feature +* Basic support for the PromQL dialect is added. To use it, set `dialect='promql'` in clickhouse-client, point it to the TimeSeries table using the setting `promql_table_name='X'` and execute queries like `rate(ClickHouseProfileEvents_ReadCompressedBytes[1m])[5m:1m]`. In addition you can wrap the PromQL query with SQL: `SELECT * FROM prometheusQuery('up', ...);`. So far only functions `rate`, `delta` and `increase` are supported. No unary/binary operators. No HTTP API. [#75036](https://github.com/ClickHouse/ClickHouse/pull/75036) ([Vitaly Baranov](https://github.com/vitlibar)). +* AI Powered SQL generation can now infer from env ANTHROPIC_API_KEY and OPENAI_API_KEY if available, this is to make it so that we can have a zero config option to use this feature. [#83787](https://github.com/ClickHouse/ClickHouse/pull/83787) ([Kaushik Iska](https://github.com/iskakaushik)). +* Implement support for [ArrowFlight RPC](https://arrow.apache.org/docs/format/Flight.html) protocol by adding: - new table function `arrowflight`. [#74184](https://github.com/ClickHouse/ClickHouse/pull/74184) ([zakr600](https://github.com/zakr600)). +* Now all tables support the `_table` virtual column (not only tables with the `Merge` engine), which is especially useful for queries with UNION ALL. [#63665](https://github.com/ClickHouse/ClickHouse/pull/63665) ([Xiaozhe Yu](https://github.com/wudidapaopao)). +* Allow to use any storage policy (i.e. object storage, such as S3) for external aggregation/sorting. [#84734](https://github.com/ClickHouse/ClickHouse/pull/84734) ([Azat Khuzhin](https://github.com/azat)). +* Implement AWS S3 authentication with an explicitly provided IAM role. Implement OAuth for GCS. These features were recently only available in ClickHouse Cloud and are now open-sourced. Synchronize some interfaces such as serialization of the connection parameters for object storages. [#84011](https://github.com/ClickHouse/ClickHouse/pull/84011) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Support position deletes for Iceberg TableEngine. [#83094](https://github.com/ClickHouse/ClickHouse/pull/83094) ([Daniil Ivanik](https://github.com/divanik)). +* Support Iceberg Equality Deletes. [#85843](https://github.com/ClickHouse/ClickHouse/pull/85843) ([Han Fei](https://github.com/hanfei1991)). +* Iceberg writes for create. Closes [#83927](https://github.com/ClickHouse/ClickHouse/issues/83927). [#83983](https://github.com/ClickHouse/ClickHouse/pull/83983) ([Konstantin Vedernikov](https://github.com/scanhex12)). +* Glue catalogs for writes. [#84136](https://github.com/ClickHouse/ClickHouse/pull/84136) ([Konstantin Vedernikov](https://github.com/scanhex12)). +* Iceberg Rest catalogs for writes. [#84684](https://github.com/ClickHouse/ClickHouse/pull/84684) ([Konstantin Vedernikov](https://github.com/scanhex12)). +* Merge all iceberg position delete files into data files. This will reduce amount and sizes of parquet files in iceberg storage. Syntax: `OPTIMIZE TABLE table_name`. [#85250](https://github.com/ClickHouse/ClickHouse/pull/85250) ([Konstantin Vedernikov](https://github.com/scanhex12)). +* Support `drop table` for iceberg (Removing from REST/Glue catalogs + removing metadata about table). [#85395](https://github.com/ClickHouse/ClickHouse/pull/85395) ([Konstantin Vedernikov](https://github.com/scanhex12)). +* Support alter delete mutations for iceberg in merge-on-read format. [#85549](https://github.com/ClickHouse/ClickHouse/pull/85549) ([Konstantin Vedernikov](https://github.com/scanhex12)). +* Support writes into DeltaLake. Closes [#79603](https://github.com/ClickHouse/ClickHouse/issues/79603). [#85564](https://github.com/ClickHouse/ClickHouse/pull/85564) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Added setting `delta_lake_snapshot_version` to allow reading specific snapshot version in table engine `DeltaLake`. [#85295](https://github.com/ClickHouse/ClickHouse/pull/85295) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Write more iceberg statistics (column sizes, lower and upper bounds) in metadata (manifest entries) for min-max pruning. [#85746](https://github.com/ClickHouse/ClickHouse/pull/85746) ([Konstantin Vedernikov](https://github.com/scanhex12)). +* Support add/drop/modify columns in iceberg for simple types. [#85769](https://github.com/ClickHouse/ClickHouse/pull/85769) ([Konstantin Vedernikov](https://github.com/scanhex12)). +* Iceberg: support writing version-hint file. This closes [#85097](https://github.com/ClickHouse/ClickHouse/issues/85097). [#85130](https://github.com/ClickHouse/ClickHouse/pull/85130) ([Konstantin Vedernikov](https://github.com/scanhex12)). +* Views, created by ephemeral users, will now store a copy of an actual user and will no longer be invalidated after the ephemeral user is deleted. [#84763](https://github.com/ClickHouse/ClickHouse/pull/84763) ([pufit](https://github.com/pufit)). +* The vector similarity index now supports binary quantization. Binary quantization significantly reduces the memory consumption and speeds up the process of building a vector index (due to faster distance calculation). Also, the existing setting `vector_search_postfilter_multiplier `was made obsolete and replaced by a more general setting : `vector_search_index_fetch_multiplier`. [#85024](https://github.com/ClickHouse/ClickHouse/pull/85024) ([Shankar Iyer](https://github.com/shankar-iyer)). +* Allow key value arguments in `s3` or `s3Cluster` table engine/function, e.g. for example `s3('url', CSV, structure = 'a Int32', compression_method = 'gzip')`. [#85134](https://github.com/ClickHouse/ClickHouse/pull/85134) ([Kseniia Sumarokova](https://github.com/kssenii)). +* A new system table to keep erroneous incoming messages from engines like kafka ("dead letter queue"). [#68873](https://github.com/ClickHouse/ClickHouse/pull/68873) ([Ilya Golshtein](https://github.com/ilejn)). +* The new SYSTEM RESTORE DATABASE REPLICA for Replicated databases, similar to the existing functionality for restore in ReplicatedMergeTree. [#73100](https://github.com/ClickHouse/ClickHouse/pull/73100) ([Konstantin Morozov](https://github.com/k-morozov)). +* PostgreSQL protocol now supports the `COPY` command. [#74344](https://github.com/ClickHouse/ClickHouse/pull/74344) ([Konstantin Vedernikov](https://github.com/scanhex12)). +* Support C# client for mysql protocol. This closes [#83992](https://github.com/ClickHouse/ClickHouse/issues/83992). [#84397](https://github.com/ClickHouse/ClickHouse/pull/84397) ([Konstantin Vedernikov](https://github.com/scanhex12)). +* Add support for hive partition style reads and writes. [#76802](https://github.com/ClickHouse/ClickHouse/pull/76802) ([Arthur Passos](https://github.com/arthurpassos)). +* Add `zookeeper_connection_log` system table to store historical information about ZooKeeper connections. [#79494](https://github.com/ClickHouse/ClickHouse/pull/79494) ([János Benjamin Antal](https://github.com/antaljanosbenjamin)). +* Server setting `cpu_slot_preemption` enables preemptive CPU scheduling for workloads and ensures max-min fair allocation of CPU time among workloads. New workload settings for CPU throttling are added: `max_cpus`, `max_cpu_share` and `max_burst_cpu_seconds`. More details: https://clickhouse.com/docs/operations/workload-scheduling#cpu_scheduling. [#80879](https://github.com/ClickHouse/ClickHouse/pull/80879) ([Sergei Trifonov](https://github.com/serxa)). +* Drop TCP connection after a configured number of queries or time threshold. This makes sense for a more uniform connection distribution between cluster nodes behind a load balancer. Resolves [#68000](https://github.com/ClickHouse/ClickHouse/issues/68000). [#81472](https://github.com/ClickHouse/ClickHouse/pull/81472) ([Kenny Sun](https://github.com/hwabis)). +* Parallel replicas now support using projections for queries. [#82659](https://github.com/ClickHouse/ClickHouse/issues/82659). [#82807](https://github.com/ClickHouse/ClickHouse/pull/82807) ([zoomxi](https://github.com/zoomxi)). +* Support DESCRIBE SELECT in addition to DESCRIBE (SELECT ...). [#82947](https://github.com/ClickHouse/ClickHouse/pull/82947) ([Yarik Briukhovetskyi](https://github.com/yariks5s)). +* Force secure connection for mysql_port and postgresql_port. [#82962](https://github.com/ClickHouse/ClickHouse/pull/82962) ([tiandiwonder](https://github.com/tiandiwonder)). +* Users can now do case-insensitive JSON key lookups using `JSONExtractCaseInsensitive` (and other variants of `JSONExtract`). [#83770](https://github.com/ClickHouse/ClickHouse/pull/83770) ([Alistair Evans](https://github.com/alistairjevans)). +* Introduction of `system.completions` table. Closes [#81889](https://github.com/ClickHouse/ClickHouse/issues/81889). [#83833](https://github.com/ClickHouse/ClickHouse/pull/83833) ([|2ustam](https://github.com/RuS2m)). +* Added a new function `nowInBlock64`. Example usage: `SELECT nowInBlock64(6)` returns `2025-07-29 17:09:37.775725`. [#84178](https://github.com/ClickHouse/ClickHouse/pull/84178) ([Halersson Paris](https://github.com/halersson)). +* Add extra_credentials to AzureBlobStorage to authenticate with client_id and tenant_id. [#84235](https://github.com/ClickHouse/ClickHouse/pull/84235) ([Pablo Marcos](https://github.com/pamarcos)). +* Added function `dateTimeToUUIDv7` to convert a DateTime value to a UUIDv7. Example usage: `SELECT dateTimeToUUIDv7(toDateTime('2025-08-15 18:57:56'))` returns `0198af18-8320-7a7d-abd3-358db23b9d5c`. [#84319](https://github.com/ClickHouse/ClickHouse/pull/84319) ([samradovich](https://github.com/samradovich)). +* `timeSeriesDerivToGrid` and `timeSeriesPredictLinearToGrid` aggregate functions to re-sample data to a time grid defined by the specified start timestamp, end timestamp, and step; calculates PromQL-like `deriv` and `predict_linear`, respectively. [#84328](https://github.com/ClickHouse/ClickHouse/pull/84328) ([Stephen Chi](https://github.com/stephchi0)). +* Add two new TimeSeries functions: - `timeSeriesRange(start_timestamp, end_timestamp, step)`, - `timeSeriesFromGrid(start_timestamp, end_timestamp, step, values)`,. [#85435](https://github.com/ClickHouse/ClickHouse/pull/85435) ([Vitaly Baranov](https://github.com/vitlibar)). +* New syntax added `GRANT READ ON S3('s3://foo/.*') TO user`. [#84503](https://github.com/ClickHouse/ClickHouse/pull/84503) ([pufit](https://github.com/pufit)). +* Added `Hash` as a new output format. It calculates a single hash value for all columns and rows of the result. This is useful for calculating a "fingerprint" of the result, for example, in use cases where data transfer is a bottleneck. Example: `SELECT arrayJoin(['abc', 'def']), 42 FORMAT Hash` returns `e5f9e676db098fdb9530d2059d8c23ef`. [#84607](https://github.com/ClickHouse/ClickHouse/pull/84607) ([Robert Schulze](https://github.com/rschu1ze)). +* Add the ability to set up arbitrary watches in Keeper Multi queries. [#84964](https://github.com/ClickHouse/ClickHouse/pull/84964) ([Mikhail Artemenko](https://github.com/Michicosun)). +* Adds an option `--max-concurrency` for the `clickhouse-benchmark` tool that enables a mode with a gradual increase in the number of parallel queries. [#85623](https://github.com/ClickHouse/ClickHouse/pull/85623) ([Sergei Trifonov](https://github.com/serxa)). +* TODO: what's that? Support partially aggregated metrics. [#85328](https://github.com/ClickHouse/ClickHouse/pull/85328) ([Mikhail Artemenko](https://github.com/Michicosun)). + +#### Experimental Feature +* Enable correlated subqueries support by default, they are no longer experimental. [#85107](https://github.com/ClickHouse/ClickHouse/pull/85107) ([Dmitry Novik](https://github.com/novikd)). +* Unity, Glue, Rest, and Hive Metastore data lake catalogs are promoted from experimental to beta. [#85848](https://github.com/ClickHouse/ClickHouse/pull/85848) ([Melvyn Peignon](https://github.com/melvynator)). +* Lightweight updates and deletes are promoted from experimental to beta. +* Approximate vector search with vector similarity indexes is now GA. [#85888](https://github.com/ClickHouse/ClickHouse/pull/85888) ([Robert Schulze](https://github.com/rschu1ze)). +* Ytsaurus table engine and table function. [#77606](https://github.com/ClickHouse/ClickHouse/pull/77606) ([MikhailBurdukov](https://github.com/MikhailBurdukov)). +* Previously, the text index data would be separated into multiple segments (each segment size by default was 256 MiB). This might reduce the memory consumption while building the text index, however this increases the space requirement on the disk and increase the query response time. [#84590](https://github.com/ClickHouse/ClickHouse/pull/84590) ([Elmi Ahmadov](https://github.com/ahmadov)). + +#### Performance Improvement +* New parquet reader implementation. It's generally faster and supports page-level filter pushdown and PREWHERE. Currently experimental. Use setting `input_format_parquet_use_native_reader_v3` to enable. [#82789](https://github.com/ClickHouse/ClickHouse/pull/82789) ([Michael Kolupaev](https://github.com/al13n321)). +* Replaced the official HTTP transport in Azure library with our own HTTP client implementation for Azure Blob Storage. Introduced multiple settings for this clients which mirror settings from S3. Introduced aggressive connection timeouts for both Azure and S3. Improved introspection into Azure profile events and metrics. New client is enabled by default, provide much better latencies for cold queries on top of Azure Blob Storage. Old `Curl` client can be returned back by setting `azure_sdk_use_native_client=false`. [#83294](https://github.com/ClickHouse/ClickHouse/pull/83294) ([alesapin](https://github.com/alesapin)). The previous, official implementation of Azure client was unsuitable for production due to terrible latency spikes, ranging from five seconds to minutes. We have ditched that terrible implementation and are very proud of that. +* Processes indexes in increasing order of file size. The net index ordering prioritizes minmax and vector indexes (due to simplicity and selectivity respectively), and small indexes thereafter. Within the minmax/vector indexes smaller indexes are also preferred. [#84094](https://github.com/ClickHouse/ClickHouse/pull/84094) ([Maruth Goyal](https://github.com/maruthgoyal)). +* Enable MergeTree setting `write_marks_for_substreams_in_compact_parts` by default. It significantly improves performance of subcolumns reading from newly created Compact parts. Servers with version less then 25.5 won't be able to read new Compact parts. [#84171](https://github.com/ClickHouse/ClickHouse/pull/84171) ([Pavel Kruglov](https://github.com/Avogar)). +* `azureBlobStorage` table engine: cache and reuse managed identity authentication tokens when possible to avoid throttling. [#79860](https://github.com/ClickHouse/ClickHouse/pull/79860) ([Nick Blakely](https://github.com/niblak)). +* `ALL` `LEFT/INNER` JOINs will be automatically converted to `RightAny` if the right side is functionally determined by the join key columns (all rows have unique join key values). [#84010](https://github.com/ClickHouse/ClickHouse/pull/84010) ([Nikita Taranov](https://github.com/nickitat)). +* Add `max_joined_block_size_bytes` in addition to `max_joined_block_size_rows` to limit the memory usage of JOINs with heavy columns. [#83869](https://github.com/ClickHouse/ClickHouse/pull/83869) ([Nikolai Kochetov](https://github.com/KochetovNicolai)). +* Added new logic (controlled by the setting `enable_producing_buckets_out_of_order_in_aggregation`, enabled by default) that allows sending some buckets out of order during memory-efficient aggregation. When some aggregation buckets take significantly longer to merge than others, it improves performance by allowing the initiator to merge buckets with higher bucket id-s in the meantime. The downside is potentially higher memory usage (shouldn't be significant). [#80179](https://github.com/ClickHouse/ClickHouse/pull/80179) ([Nikita Taranov](https://github.com/nickitat)). +* Introduced the `optimize_rewrite_regexp_functions` setting (enabled by default), which allows the optimizer to rewrite certain `replaceRegexpAll`, `replaceRegexpOne`, and `extract` calls into simpler and more efficient forms when specific regular expression patterns are detected. (issue [#81981](https://github.com/ClickHouse/ClickHouse/issues/81981)). [#81992](https://github.com/ClickHouse/ClickHouse/pull/81992) ([Amos Bird](https://github.com/amosbird)). +* Process `max_joined_block_rows` outside of hash JOIN main loop. Slightly better performance for ALL JOIN. [#83216](https://github.com/ClickHouse/ClickHouse/pull/83216) ([Nikolai Kochetov](https://github.com/KochetovNicolai)). +* Process higher granularity min-max indexes first. Closes [#75381](https://github.com/ClickHouse/ClickHouse/issues/75381). [#83798](https://github.com/ClickHouse/ClickHouse/pull/83798) ([Maruth Goyal](https://github.com/maruthgoyal)). +* Make `DISTINCT` window aggregates run in linear time and fix a bug in `sumDistinct`. Closes [#79792](https://github.com/ClickHouse/ClickHouse/issues/79792). Closes [#52253](https://github.com/ClickHouse/ClickHouse/issues/52253). [#79859](https://github.com/ClickHouse/ClickHouse/pull/79859) ([Nihal Z. Miaji](https://github.com/nihalzp)). +* Vector search queries using a vector similarity index complete with lower latency due to reduced storage reads and reduced CPU usage. [#83803](https://github.com/ClickHouse/ClickHouse/pull/83803) ([Shankar Iyer](https://github.com/shankar-iyer)). +* Rendezvous hashing for improve cache locality of workload distribution among parallel replicas. [#82511](https://github.com/ClickHouse/ClickHouse/pull/82511) ([Anton Ivashkin](https://github.com/ianton-ru)). +* Implement addManyDefaults for If combinators, so now aggregate functions with If combinators work faster. [#83870](https://github.com/ClickHouse/ClickHouse/pull/83870) ([Raúl Marín](https://github.com/Algunenano)). +* Calculate serialized key columnarly when group by multiple string or number columns. [#83884](https://github.com/ClickHouse/ClickHouse/pull/83884) ([李扬](https://github.com/taiyang-li)). +* Eliminated full scans for the cases when index analysis results in empty ranges for parallel replicas reading. [#84971](https://github.com/ClickHouse/ClickHouse/pull/84971) ([Eduard Karacharov](https://github.com/korowa)). +* Try -falign-functions=64 in attempt for more stable perf tests. [#83920](https://github.com/ClickHouse/ClickHouse/pull/83920) ([Azat Khuzhin](https://github.com/azat)). +* The bloom filter index is now used for conditions like `has([c1, c2, ...], column)`, where `column` is not of an `Array` type. This improves performance for such queries, making them as efficient as the `IN` operator. [#83945](https://github.com/ClickHouse/ClickHouse/pull/83945) ([Doron David](https://github.com/dorki)). +* Reduce unnecessary memcpy calls in CompressedReadBufferBase::readCompressedData. [#83986](https://github.com/ClickHouse/ClickHouse/pull/83986) ([Raúl Marín](https://github.com/Algunenano)). +* Optimize `largestTriangleThreeBuckets` by removing temporary data. [#84479](https://github.com/ClickHouse/ClickHouse/pull/84479) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Optimize string deserialization by simplifying the code. Closes [#38564](https://github.com/ClickHouse/ClickHouse/issues/38564). [#84561](https://github.com/ClickHouse/ClickHouse/pull/84561) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Fixed the calculation of the minimal task size for parallel replicas. [#84752](https://github.com/ClickHouse/ClickHouse/pull/84752) ([Nikita Taranov](https://github.com/nickitat)). +* Improved performance of applying patch parts in `Join` mode. [#85040](https://github.com/ClickHouse/ClickHouse/pull/85040) ([Anton Popov](https://github.com/CurtizJ)). +* Remove zero byte. Closes [#85062](https://github.com/ClickHouse/ClickHouse/issues/85062). A few minor bugs were fixed. Functions `structureToProtobufSchema`, `structureToCapnProtoSchema` didn't correctly put a zero-terminating byte and were using a newline instead of it. That was leading to a missing newline in the output, and could lead to buffer overflows while using other functions that depend on the zero byte (such as `logTrace`, `demangle`, `extractURLParameter`, `toStringCutToZero`, and `encrypt`/`decrypt`). The `regexp_tree` dictionary layout didn't support processing strings with zero bytes. The `formatRowNoNewline` function, called with `Values` format or with any other format without a newline at the end of rows, erroneously cuts the last character of the output. Function `stem` contained an exception-safety error that could lead to a memory leak in a very rare scenario. The `initcap` function worked in the wrong way for `FixedString` arguments: it didn't recognize the start of the word at the start of the string if the previous string in a block ended with a word character. Fixed a security vulnerability of the Apache `ORC` format, which could lead to the exposure of uninitialized memory. Changed behavior of the function `replaceRegexpAll` and the corresponding alias, `REGEXP_REPLACE`: now it can do an empty match at the end of the string even if the previous match processed the whole string, such as in the case of `^a*|a*$` or `^|.*` - this corresponds to the semantic of JavaScript, Perl, Python, PHP, Ruby, but differs to the semantic of PostgreSQL. Implementation of many functions has been simplified and optimized. Documentation for several functions was wrong and has now been fixed. Keep in mind that the output of `byteSize` for String columns and complex types, which consisted of String columns, has changed (from 9 bytes per empty string to 8 bytes per empty string), and this is normal. [#85063](https://github.com/ClickHouse/ClickHouse/pull/85063) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Optimize the materialization of constants in cases when we do this materialization only to return a single row. [#85071](https://github.com/ClickHouse/ClickHouse/pull/85071) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Improve parallel files processing with delta-kernel-rs backend. [#85642](https://github.com/ClickHouse/ClickHouse/pull/85642) ([Azat Khuzhin](https://github.com/azat)). +* A new setting, enable_add_distinct_to_in_subqueries, has been introduced. When enabled, ClickHouse will automatically add DISTINCT to subqueries in IN clauses for distributed queries. This can significantly reduce the size of temporary tables transferred between shards and improve network efficiency. Note: This is a trade-off—while network transfer is reduced, additional merging (deduplication) work is required on each node. Enable this setting when network transfer is a bottleneck and the merging cost is acceptable. [#81908](https://github.com/ClickHouse/ClickHouse/pull/81908) ([fhw12345](https://github.com/fhw12345)). +* Reduce query memory tracking overhead for executable user-defined functions. [#83929](https://github.com/ClickHouse/ClickHouse/pull/83929) ([Eduard Karacharov](https://github.com/korowa)). +* Implement internal `delta-kernel-rs` filtering (statistics and partition pruning) in storage `DeltaLake`. [#84006](https://github.com/ClickHouse/ClickHouse/pull/84006) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Disable skipping indexes that depend on columns updated on the fly or by patch parts more granularly. Now, skipping indexes are not used only in parts affected by on-the-fly mutations or patch parts; previously, those indexes were disabled for all parts. [#84241](https://github.com/ClickHouse/ClickHouse/pull/84241) ([Anton Popov](https://github.com/CurtizJ)). +* Allocate the minimum amount of memory needed for encrypted_buffer for encrypted named collections. [#84432](https://github.com/ClickHouse/ClickHouse/pull/84432) ([Pablo Marcos](https://github.com/pamarcos)). +* Improved support for bloom filter indexes (regular, ngram, and token) to be utilized when the first argument is a constant array (the set) and the second is the indexed column (the subset), enabling more efficient query execution. [#84700](https://github.com/ClickHouse/ClickHouse/pull/84700) ([Doron David](https://github.com/dorki)). +* Reduce contention on storage lock in Keeper. [#84732](https://github.com/ClickHouse/ClickHouse/pull/84732) ([Antonio Andelic](https://github.com/antonio2368)). +* Add missing support of `read_in_order_use_virtual_row` for `WHERE`. It allows to skip reading more parts for queries with filters that were not fully pushed to `PREWHERE`. [#84835](https://github.com/ClickHouse/ClickHouse/pull/84835) ([Nikolai Kochetov](https://github.com/KochetovNicolai)). +* Allows asynchronously iterating objects from Iceberg table without storing objects for each data file explicitly. [#85369](https://github.com/ClickHouse/ClickHouse/pull/85369) ([Daniil Ivanik](https://github.com/divanik)). +* Execute non-correlated `EXISTS` as a scalar subquery. This allows using a scalar subquery cache and constant-folding the result, which is helpful for indexes. For compatibility, the new setting `execute_exists_as_scalar_subquery=1` is added. [#85481](https://github.com/ClickHouse/ClickHouse/pull/85481) ([Nikolai Kochetov](https://github.com/KochetovNicolai)). + +#### Improvement +* Add `database_replicated` settings defining the default values of DatabaseReplicatedSettings. If the setting is not present in the Replicated DB create query, the value from this setting is used. [#85127](https://github.com/ClickHouse/ClickHouse/pull/85127) ([Tuan Pham Anh](https://github.com/tuanpach)). +* Made the table columns in the web UI (play) resizable. [#84012](https://github.com/ClickHouse/ClickHouse/pull/84012) ([Doron David](https://github.com/dorki)). +* Support compressed `.metadata.json` file via `iceberg_metadata_compression_method` setting. It supports all clickhouse compression methods. This closes [#84895](https://github.com/ClickHouse/ClickHouse/issues/84895). [#85196](https://github.com/ClickHouse/ClickHouse/pull/85196) ([Konstantin Vedernikov](https://github.com/scanhex12)). +* Show the number of ranges to be read in the output of `EXPLAIN indexes = 1`. [#79938](https://github.com/ClickHouse/ClickHouse/pull/79938) ([Christoph Wurm](https://github.com/cwurm)). +* Introduce settings to set ORC compression block size, and update its default value from 64KB to 256KB to keep consistent with spark or hive. [#80602](https://github.com/ClickHouse/ClickHouse/pull/80602) ([李扬](https://github.com/taiyang-li)). +* Add `columns_substreams.txt` file to Wide part to track all substreams stored in the part. It helps to track dynamic streams in JSON and Dynamic types and so avoid reading sample of these columns to get the list of dynamic streams (for example for columns sizes calculation). Also now all dynamic streams are reflected in `system.parts_columns`. [#81091](https://github.com/ClickHouse/ClickHouse/pull/81091) ([Pavel Kruglov](https://github.com/Avogar)). +* Add a CLI flag --show_secrets to clickhouse format to hide sensitive data by default. [#81524](https://github.com/ClickHouse/ClickHouse/pull/81524) ([Nikolai Ryzhov](https://github.com/Dolaxom)). +* S3 read and write requests are throttled on the HTTP socket level (instead of whole S3 requests) to avoid issues with `max_remote_read_network_bandwidth_for_server` and `max_remote_write_network_bandwidth_for_server` throttling. [#81837](https://github.com/ClickHouse/ClickHouse/pull/81837) ([Sergei Trifonov](https://github.com/serxa)). +* Allow to mix different collations for the same column in different windows (for window functions). [#82877](https://github.com/ClickHouse/ClickHouse/pull/82877) ([Yakov Olkhovskiy](https://github.com/yakov-olkhovskiy)). +* Add a tool to simulate, visualize and compare merge selectors. [#71496](https://github.com/ClickHouse/ClickHouse/pull/71496) ([Sergei Trifonov](https://github.com/serxa)). +* Add support of `remote*` table functions with parallel replicas if cluster is provided in `address_expression` argument. Also, fixes [#73295](https://github.com/ClickHouse/ClickHouse/issues/73295). [#82904](https://github.com/ClickHouse/ClickHouse/pull/82904) ([Igor Nikonov](https://github.com/devcrafter)). +* Set all log messages for writing backup files to TRACE. [#82907](https://github.com/ClickHouse/ClickHouse/pull/82907) ([Hans Krutzer](https://github.com/hkrutzer)). +* User-defined functions with unusual names and codecs can be formatted inconsistently by the SQL formatter. This closes [#83092](https://github.com/ClickHouse/ClickHouse/issues/83092). [#83644](https://github.com/ClickHouse/ClickHouse/pull/83644) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Users can now use Time and Time64 types inside the JSON type. [#83784](https://github.com/ClickHouse/ClickHouse/pull/83784) ([Yarik Briukhovetskyi](https://github.com/yariks5s)). +* Joins with parallel replicas now use the join logical step. In case of any issues with join queries using parallel replicas, try `SET query_plan_use_new_logical_join_step=0` and report an issue. [#83801](https://github.com/ClickHouse/ClickHouse/pull/83801) ([Vladimir Cherkasov](https://github.com/vdimir)). +* Fix compatibility for cluster_function_process_archive_on_multiple_nodes. [#83968](https://github.com/ClickHouse/ClickHouse/pull/83968) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Support changing mv insert settings on `S3Queue` table level. Added new `S3Queue` level settings: `min_insert_block_size_rows_for_materialized_views` and `min_insert_block_size_bytes_for_materialized_views`. By default profile level settings will be used and `S3Queue` level settings will override those. [#83971](https://github.com/ClickHouse/ClickHouse/pull/83971) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Added profile event `MutationAffectedRowsUpperBound` that shows the number of affected rows in a mutation (e.g., the total number of rows that satisfy the condition in `ALTER UPDATE` or `ALTER DELETE` query. [#83978](https://github.com/ClickHouse/ClickHouse/pull/83978) ([Anton Popov](https://github.com/CurtizJ)). +* Use information from cgroup (if applicable, i.e. `memory_worker_use_cgroup` and cgroups are available) to adjust memory tracker (`memory_worker_correct_memory_tracker`). [#83981](https://github.com/ClickHouse/ClickHouse/pull/83981) ([Azat Khuzhin](https://github.com/azat)). +* MongoDB: Implicit parsing of strings to numeric types. Previously, if a string value was received from a MongoDB source for a numeric column in a ClickHouse table, an exception was thrown. Now, the engine attempts to parse the numeric value from the string automatically. Closes [#81167](https://github.com/ClickHouse/ClickHouse/issues/81167). [#84069](https://github.com/ClickHouse/ClickHouse/pull/84069) ([Kirill Nikiforov](https://github.com/allmazz)). +* Highlight digit groups in `Pretty` formats for `Nullable` numbers. [#84070](https://github.com/ClickHouse/ClickHouse/pull/84070) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Dashboard: the tooltip will not overflow the container at the top. [#84072](https://github.com/ClickHouse/ClickHouse/pull/84072) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Slightly better-looking dots on the dashboard. [#84074](https://github.com/ClickHouse/ClickHouse/pull/84074) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Dashboard now has a slightly better favicon. [#84076](https://github.com/ClickHouse/ClickHouse/pull/84076) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Web UI: Give browsers a chance to save the password. Also, it will remember the URL values. [#84087](https://github.com/ClickHouse/ClickHouse/pull/84087) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Add support for applying extra ACL on specific Keeper nodes using `apply_to_children` config. [#84137](https://github.com/ClickHouse/ClickHouse/pull/84137) ([Antonio Andelic](https://github.com/antonio2368)). +* Fix usage of "compact" Variant discriminators serialization in MergeTree. Perviously it wasn't used in some cases when it could be used. [#84141](https://github.com/ClickHouse/ClickHouse/pull/84141) ([Pavel Kruglov](https://github.com/Avogar)). +* Added a server setting, `logs_to_keep` to database replicated settings, that allows changing the default `logs_to_keep` parameter for replicated databases. Lower values reduce the number of ZNodes (especially if there are many databases), while higher values allow a missing replica to catch up after a longer period of time. [#84183](https://github.com/ClickHouse/ClickHouse/pull/84183) ([Alexey Khatskevich](https://github.com/Khatskevich)). +* Add a setting `json_type_escape_dots_in_keys` to escape dots in JSON keys during JSON type parsing. The setting is disabled by default. [#84207](https://github.com/ClickHouse/ClickHouse/pull/84207) ([Pavel Kruglov](https://github.com/Avogar)). +* Check if connection is cancelled before checking for EOF to prevent reading from closed connection. Fixes [#83893](https://github.com/ClickHouse/ClickHouse/issues/83893). [#84227](https://github.com/ClickHouse/ClickHouse/pull/84227) ([Raufs Dunamalijevs](https://github.com/rienath)). +* Slightly better colors of text selection in Web UI. The difference is significant only for selected table cells in the dark mode. In previous versions, there was not enough contrast between the text and the selection background. [#84258](https://github.com/ClickHouse/ClickHouse/pull/84258) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Improved server shutdown handling for client connections by simplifying internal checks. [#84312](https://github.com/ClickHouse/ClickHouse/pull/84312) ([Raufs Dunamalijevs](https://github.com/rienath)). +* Added a setting `delta_lake_enable_expression_visitor_logging` to turn off expression visitor logs as they can be too verbose even for test log level when debugging something. [#84315](https://github.com/ClickHouse/ClickHouse/pull/84315) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Cgroup-level and system-wide metrics are reported now altogether. Cgroup-level metrics have names `CGroup` and OS-level metrics (collected from procfs) have names `OS`. [#84317](https://github.com/ClickHouse/ClickHouse/pull/84317) ([Nikita Taranov](https://github.com/nickitat)). +* Slightly better charts in Web UI. Not much, but better. [#84326](https://github.com/ClickHouse/ClickHouse/pull/84326) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Change the default of the Replicated database setting `max_retries_before_automatic_recovery` to 10, so it will recover faster in some cases. [#84369](https://github.com/ClickHouse/ClickHouse/pull/84369) ([Alexander Tokmakov](https://github.com/tavplubix)). +* Fix formatting of CREATE USER with query parameters (i.e. `CREATE USER {username:Identifier} IDENTIFIED WITH no_password`). [#84376](https://github.com/ClickHouse/ClickHouse/pull/84376) ([Azat Khuzhin](https://github.com/azat)). +* Introduce `backup_restore_s3_retry_initial_backoff_ms`, `backup_restore_s3_retry_max_backoff_ms`, `backup_restore_s3_retry_jitter_factor` to configure the S3 retry backoff strategy used during backup and restore operations. [#84421](https://github.com/ClickHouse/ClickHouse/pull/84421) ([Julia Kartseva](https://github.com/jkartseva)). +* S3Queue ordered mode fix: quit earlier if shutdown was called. [#84463](https://github.com/ClickHouse/ClickHouse/pull/84463) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Support iceberg writes to read from pyiceberg. [#84466](https://github.com/ClickHouse/ClickHouse/pull/84466) ([Konstantin Vedernikov](https://github.com/scanhex12)). +* Allow set values type casting when pushing down `IN` / `GLOBAL IN` filters over KeyValue storage primary keys (e.g., EmbeddedRocksDB, KeeperMap). [#84515](https://github.com/ClickHouse/ClickHouse/pull/84515) ([Eduard Karacharov](https://github.com/korowa)). +* Bump chdig to [25.7.1](https://github.com/azat/chdig/releases/tag/v25.7.1). [#84521](https://github.com/ClickHouse/ClickHouse/pull/84521) ([Azat Khuzhin](https://github.com/azat)). +* Low-level errors during UDF execution now fail with error code `UDF_EXECUTION_FAILED`, whereas previously different error codes could be returned. [#84547](https://github.com/ClickHouse/ClickHouse/pull/84547) ([Xu Jia](https://github.com/XuJia0210)). +* Add `get_acl` command to KeeperClient. [#84641](https://github.com/ClickHouse/ClickHouse/pull/84641) ([Antonio Andelic](https://github.com/antonio2368)). +* Adds snapshot version to data lake table engines. [#84659](https://github.com/ClickHouse/ClickHouse/pull/84659) ([Pete Hampton](https://github.com/pjhampton)). +* Add a dimensional metric for the size of `ConcurrentBoundedQueue`, labelled by the queue type (i.e. what the queue is there for) and queue id (i.e. randomly generated id for the current instance of the queue). [#84675](https://github.com/ClickHouse/ClickHouse/pull/84675) ([Miсhael Stetsyuk](https://github.com/mstetsyuk)). +* The `system.columns` table now provides `column` as an alias for the existing `name` column. [#84695](https://github.com/ClickHouse/ClickHouse/pull/84695) ([Yunchi Pang](https://github.com/yunchipang)). +* New MergeTree setting `search_orphaned_parts_drives` to limit scope to look for parts e.g. by disks with local metadata. [#84710](https://github.com/ClickHouse/ClickHouse/pull/84710) ([Ilya Golshtein](https://github.com/ilejn)). +* Add 4LW in Keeper, `lgrq`, for toggling request logging of received requests. [#84719](https://github.com/ClickHouse/ClickHouse/pull/84719) ([Antonio Andelic](https://github.com/antonio2368)). +* Match external auth forward_headers in case-insensitive way. [#84737](https://github.com/ClickHouse/ClickHouse/pull/84737) ([ingodwerust](https://github.com/ingodwerust)). +* The `encrypt_decrypt` tool now supports encrypted ZooKeeper connections. [#84764](https://github.com/ClickHouse/ClickHouse/pull/84764) ([Roman Vasin](https://github.com/rvasin)). +* Add format string column to `system.errors`. This column is needed to group by the same error type in alerting rules. [#84776](https://github.com/ClickHouse/ClickHouse/pull/84776) ([Miсhael Stetsyuk](https://github.com/mstetsyuk)). +* Updated `clickhouse-format` to accept `--highlight` as an alias for `--hilite`. - Updated `clickhouse-client` to accept `--hilite` as an alias for `--highlight`. - Updated `clickhouse-format` documentation to reflect the change. [#84806](https://github.com/ClickHouse/ClickHouse/pull/84806) ([Rishabh Bhardwaj](https://github.com/rishabh1815769)). +* Fix iceberg reading by field ids for complex types. [#84821](https://github.com/ClickHouse/ClickHouse/pull/84821) ([Konstantin Vedernikov](https://github.com/scanhex12)). +* Introduce a new `backup_slow_all_threads_after_retryable_s3_error` setting to reduce pressure on S3 during retry storms caused by errors such as `SlowDown`, by slowing down all threads once a single retryable error is observed. [#84854](https://github.com/ClickHouse/ClickHouse/pull/84854) ([Julia Kartseva](https://github.com/jkartseva)). +* Skip creating and renaming the old temp table of non-append RMV DDLs in Replicated DBs. [#84858](https://github.com/ClickHouse/ClickHouse/pull/84858) ([Tuan Pham Anh](https://github.com/tuanpach)). +* Limit Keeper log entry cache size by number of entries using `keeper_server.coordination_settings.latest_logs_cache_entry_count_threshold` and `keeper_server.coordination_settings.commit_logs_cache_entry_count_threshold`. [#84877](https://github.com/ClickHouse/ClickHouse/pull/84877) ([Antonio Andelic](https://github.com/antonio2368)). +* Allow using `simdjson` on unsupported architectures (previously leads to `CANNOT_ALLOCATE_MEMORY` errors). [#84966](https://github.com/ClickHouse/ClickHouse/pull/84966) ([Azat Khuzhin](https://github.com/azat)). +* Async logging: Make limits tuneable and add introspection. [#85105](https://github.com/ClickHouse/ClickHouse/pull/85105) ([Raúl Marín](https://github.com/Algunenano)). +* Collect all removed objects to execute single object storage remove operation. [#85316](https://github.com/ClickHouse/ClickHouse/pull/85316) ([Mikhail Artemenko](https://github.com/Michicosun)). +* Iceberg's current implementation of positional delete files keeps all data in RAM. This can be quite expensive if the positional delete files are large, which is often the case. My implementation keeps only the last row-group of Parquet delete files in RAM, which is significantly cheaper. [#85329](https://github.com/ClickHouse/ClickHouse/pull/85329) ([Konstantin Vedernikov](https://github.com/scanhex12)). +* chdig: fix leftovers on the screen, fix crash after edit query in editor, search in `path` for `editor`, update to [25.8.1](https://github.com/azat/chdig/releases/tag/v25.8.1). [#85341](https://github.com/ClickHouse/ClickHouse/pull/85341) ([Azat Khuzhin](https://github.com/azat)). +* Add missing `partition_columns_in_data_file` to azure configuration. [#85373](https://github.com/ClickHouse/ClickHouse/pull/85373) ([Arthur Passos](https://github.com/arthurpassos)). +* Allow zero step in functions `timeSeries*ToGrid` This is part of [#75036](https://github.com/ClickHouse/ClickHouse/pull/75036). [#85390](https://github.com/ClickHouse/ClickHouse/pull/85390) ([Vitaly Baranov](https://github.com/vitlibar)). +* Added show_data_lake_catalogs_in_system_tables flag to manage adding data lake tables in system.tables. Resolves [#85384](https://github.com/ClickHouse/ClickHouse/issues/85384). [#85411](https://github.com/ClickHouse/ClickHouse/pull/85411) ([Smita Kulkarni](https://github.com/SmitaRKulkarni)). +* Added support for macro expansion in `remote_fs_zero_copy_zookeeper_path`. [#85437](https://github.com/ClickHouse/ClickHouse/pull/85437) ([Mikhail Koviazin](https://github.com/mkmkme)). +* AI in clickhouse-client will look slightly better. [#85447](https://github.com/ClickHouse/ClickHouse/pull/85447) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Enable trace_log.symbolize for old deployments by default. [#85456](https://github.com/ClickHouse/ClickHouse/pull/85456) ([Azat Khuzhin](https://github.com/azat)). +* Support resolution of more cases for compound identifiers. Particularly, it improves the compatibility of `ARRAY JOIN` with the old analyzer. Introduce a new setting `analyzer_compatibility_allow_compound_identifiers_in_unflatten_nested` to keep the old behaviour. [#85492](https://github.com/ClickHouse/ClickHouse/pull/85492) ([Nikolai Kochetov](https://github.com/KochetovNicolai)). +* Ignore UNKNOWN_DATABASE while obtaining table columns sizes for system.columns. [#85632](https://github.com/ClickHouse/ClickHouse/pull/85632) ([Azat Khuzhin](https://github.com/azat)). +* Added a limit (table setting `max_uncompressed_bytes_in_patches`) for total uncompressed bytes in patch parts. It prevents significant slowdowns of SELECT queries after lightweight updates and prevents possible misuse of lightweight updates. [#85641](https://github.com/ClickHouse/ClickHouse/pull/85641) ([Anton Popov](https://github.com/CurtizJ)). +* Add a `parameter` column to `system.grants` to determine source type for `GRANT READ/WRITE` and the table engine for `GRANT TABLE ENGINE`. [#85643](https://github.com/ClickHouse/ClickHouse/pull/85643) ([MikhailBurdukov](https://github.com/MikhailBurdukov)). +* Fix parsing of a trailing comma in columns of the CREATE DICTIONARY query after a column with parameters, for example, Decimal(8). Closes [#85586](https://github.com/ClickHouse/ClickHouse/issues/85586). [#85653](https://github.com/ClickHouse/ClickHouse/pull/85653) ([Nikolay Degterinsky](https://github.com/evillique)). +* Support inner arrays for the function `nested`. [#85719](https://github.com/ClickHouse/ClickHouse/pull/85719) ([Nikolai Kochetov](https://github.com/KochetovNicolai)). +* All the allocations done by external libraries are now visible to ClickHouse's memory tracker and accounted properly. This may result in "increased" reported memory usage for certain queries or failures with `MEMORY_LIMIT_EXCEEDED`. [#84082](https://github.com/ClickHouse/ClickHouse/pull/84082) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)). + +#### Bug Fix (user-visible misbehavior in an official stable release) + +* This pr fixes the metadata resolution when querying iceberg tables through rest catalog. ... [#80562](https://github.com/ClickHouse/ClickHouse/pull/80562) ([Saurabh Kumar Ojha](https://github.com/saurabhojha)). +* Fix markReplicasActive in DDLWorker and DatabaseReplicatedDDLWorker. [#81395](https://github.com/ClickHouse/ClickHouse/pull/81395) ([Tuan Pham Anh](https://github.com/tuanpach)). +* Fix rollback of Dynamic column on parsing failure. [#82169](https://github.com/ClickHouse/ClickHouse/pull/82169) ([Pavel Kruglov](https://github.com/Avogar)). +* If function `trim` called with all-constant inputs now produces a constant output string. (Bug [#78796](https://github.com/ClickHouse/ClickHouse/issues/78796)). [#82900](https://github.com/ClickHouse/ClickHouse/pull/82900) ([Robert Schulze](https://github.com/rschu1ze)). +* Fix logical error with duplicate subqueries when `optimize_syntax_fuse_functions` is enabled, close [#75511](https://github.com/ClickHouse/ClickHouse/issues/75511). [#83300](https://github.com/ClickHouse/ClickHouse/pull/83300) ([Vladimir Cherkasov](https://github.com/vdimir)). +* Fixed incorrect result of queries with `WHERE ... IN ()` clause and enabled query condition cache (setting `use_query_condition_cache`). [#83445](https://github.com/ClickHouse/ClickHouse/pull/83445) ([LB7666](https://github.com/acking-you)). +* Historically, `gcs` function did not require any access to use. Now it will check `GRANT READ ON S3` permission for usage. Closes [#70567](https://github.com/ClickHouse/ClickHouse/issues/70567). [#83503](https://github.com/ClickHouse/ClickHouse/pull/83503) ([pufit](https://github.com/pufit)). +* Skip unavailable nodes during INSERT SELECT from s3Cluster() into replicated MergeTree. [#83676](https://github.com/ClickHouse/ClickHouse/pull/83676) ([Igor Nikonov](https://github.com/devcrafter)). +* Fix write with append (in MergeTree used for experimental transactions) with `plain_rewritable`/`plain` metadata types, previously they were simply ignored. [#83695](https://github.com/ClickHouse/ClickHouse/pull/83695) ([Tuan Pham Anh](https://github.com/tuanpach)). +* Mask Avro schema registry authentication details to be not visible to user or in logs. [#83713](https://github.com/ClickHouse/ClickHouse/pull/83713) ([János Benjamin Antal](https://github.com/antaljanosbenjamin)). +* Fix the issue where, if a MergeTree table is created with `add_minmax_index_for_numeric_columns=1` or `add_minmax_index_for_string_columns=1`, the index is later materialized during an ALTER operation, and it prevents the Replicated database from initializing correctly on a new replica. [#83751](https://github.com/ClickHouse/ClickHouse/pull/83751) ([Nikolay Degterinsky](https://github.com/evillique)). +* Fixed parquet writer outputting incorrect statistics (min/max) for Decimal types. [#83754](https://github.com/ClickHouse/ClickHouse/pull/83754) ([Michael Kolupaev](https://github.com/al13n321)). +* Fix sort of NaN values in `LowCardinality(Float32|Float64|BFloat16)` type. [#83786](https://github.com/ClickHouse/ClickHouse/pull/83786) ([Pervakov Grigorii](https://github.com/GrigoryPervakov)). +* When restoring from backup, the definer user may not be backed up, which will cause the whole backup to be broken. To fix this, we postpone the permissions check on the target table's creation during restore and only check it during runtime. [#83818](https://github.com/ClickHouse/ClickHouse/pull/83818) ([pufit](https://github.com/pufit)). +* Fix crash in client due to connection left in disconnected state after bad INSERT. [#83842](https://github.com/ClickHouse/ClickHouse/pull/83842) ([Azat Khuzhin](https://github.com/azat)). +* Allow referencing any table in `view(...)` argument of `remote` table function with enabled analyzer. Fixes [#78717](https://github.com/ClickHouse/ClickHouse/issues/78717). Fixes [#79377](https://github.com/ClickHouse/ClickHouse/issues/79377). [#83844](https://github.com/ClickHouse/ClickHouse/pull/83844) ([Dmitry Novik](https://github.com/novikd)). +* Onprogress call in jsoneachrowwithprogress is synchronized with finalization. [#83879](https://github.com/ClickHouse/ClickHouse/pull/83879) ([Sema Checherinda](https://github.com/CheSema)). +* This closes [#81303](https://github.com/ClickHouse/ClickHouse/issues/81303). [#83892](https://github.com/ClickHouse/ClickHouse/pull/83892) ([Konstantin Vedernikov](https://github.com/scanhex12)). +* Fix colorSRGBToOKLCH/colorOKLCHToSRGB for mix of const and non-const args. [#83906](https://github.com/ClickHouse/ClickHouse/pull/83906) ([Azat Khuzhin](https://github.com/azat)). +* Fix writing JSON paths with NULL values in RowBinary format. [#83923](https://github.com/ClickHouse/ClickHouse/pull/83923) ([Pavel Kruglov](https://github.com/Avogar)). +* Overflow large values (>2106-02-07) when casting from Date to DateTime64 is fixed. [#83982](https://github.com/ClickHouse/ClickHouse/pull/83982) ([Yarik Briukhovetskyi](https://github.com/yariks5s)). +* Always apply `filesystem_prefetches_limit` (not only from `MergeTreePrefetchedReadPool`). [#83999](https://github.com/ClickHouse/ClickHouse/pull/83999) ([Azat Khuzhin](https://github.com/azat)). +* Fix rare bug when `MATERIALIZE COLUMN` query could lead to unexpected files in `checksums.txt` and eventually detached data parts. [#84007](https://github.com/ClickHouse/ClickHouse/pull/84007) ([alesapin](https://github.com/alesapin)). +* Fix the logical error `Expected single dictionary argument for function` while doing JOIN on an inequality condition when one of the columns is `LowCardinality` and the other is a constant. Closes [#81779](https://github.com/ClickHouse/ClickHouse/issues/81779). [#84019](https://github.com/ClickHouse/ClickHouse/pull/84019) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Fix crash with clickhouse client when used in interactive mode with syntax highlighting. [#84025](https://github.com/ClickHouse/ClickHouse/pull/84025) ([Bharat Nallan](https://github.com/bharatnc)). +* Fixed wrong results when the query condition cache is used in conjunction with recursive CTEs (issue [#81506](https://github.com/ClickHouse/ClickHouse/issues/81506)). [#84026](https://github.com/ClickHouse/ClickHouse/pull/84026) ([zhongyuankai](https://github.com/zhongyuankai)). +* Handle exceptions properly in periodic parts refresh. [#84083](https://github.com/ClickHouse/ClickHouse/pull/84083) ([Azat Khuzhin](https://github.com/azat)). +* Fix filter merging into JOIN condition in cases when equality operands have different types or they reference constants. Fixes [#83432](https://github.com/ClickHouse/ClickHouse/issues/83432). [#84145](https://github.com/ClickHouse/ClickHouse/pull/84145) ([Dmitry Novik](https://github.com/novikd)). +* Fix rare clickhouse crash when table has projection, `lightweight_mutation_projection_mode = 'rebuild'` and user execute lighweight delete which deletes ALL rows from any block in table. [#84158](https://github.com/ClickHouse/ClickHouse/pull/84158) ([alesapin](https://github.com/alesapin)). +* Fix deadlock caused by background cancellation checker thread. [#84203](https://github.com/ClickHouse/ClickHouse/pull/84203) ([Antonio Andelic](https://github.com/antonio2368)). +* Fix infinite recursive analysis of invalid `WINDOW` definitions. Fixes [#83131](https://github.com/ClickHouse/ClickHouse/issues/83131). [#84242](https://github.com/ClickHouse/ClickHouse/pull/84242) ([Dmitry Novik](https://github.com/novikd)). +* Fixed a bug that was causing incorrect Bech32 Encoding and Decoding. The bug wasn't caught originally due to an online implementation of the algorithm used for testing having the same issue. [#84257](https://github.com/ClickHouse/ClickHouse/pull/84257) ([George Larionov](https://github.com/george-larionov)). +* Fixed incorrect construction of empty tuples in the `array()` function. This fixes [#84202](https://github.com/ClickHouse/ClickHouse/issues/84202). [#84297](https://github.com/ClickHouse/ClickHouse/pull/84297) ([Amos Bird](https://github.com/amosbird)). +* Fix `LOGICAL_ERROR` for queries with parallel replicas and multiple INNER joins followed by RIGHT join. Do not use parallel replicas for such queries. [#84299](https://github.com/ClickHouse/ClickHouse/pull/84299) ([Vladimir Cherkasov](https://github.com/vdimir)). +* Previously, `set` indexes didn't consider `Nullable` columns while checking if granules passed the filter (issue [#75485](https://github.com/ClickHouse/ClickHouse/issues/75485)). [#84305](https://github.com/ClickHouse/ClickHouse/pull/84305) ([Elmi Ahmadov](https://github.com/ahmadov)). +* Now ClickHouse read tables from Glue Catalog where table type specified in lower case. [#84316](https://github.com/ClickHouse/ClickHouse/pull/84316) ([alesapin](https://github.com/alesapin)). +* Do not try to substitute table functions to its cluster alternative in presence of a JOIN or subquery. [#84335](https://github.com/ClickHouse/ClickHouse/pull/84335) ([Konstantin Bogdanov](https://github.com/thevar1able)). +* Fix logger usage in `IAccessStorage`. [#84365](https://github.com/ClickHouse/ClickHouse/pull/84365) ([Konstantin Bogdanov](https://github.com/thevar1able)). +* Fixed a logical error in lightweight updates that update all columns in the table. [#84380](https://github.com/ClickHouse/ClickHouse/pull/84380) ([Anton Popov](https://github.com/CurtizJ)). +* Codec `DoubleDelta` codec can now only be applied to columns of numeric type. In particular `FixedString` columns can no longer be compressed using `DoubleDelta`. (fixes [#80220](https://github.com/ClickHouse/ClickHouse/issues/80220)). [#84383](https://github.com/ClickHouse/ClickHouse/pull/84383) ([Jimmy Aguilar Mena](https://github.com/Ergus)). +* The comparison against nan value was not using the correct ranges during `MinMax` index evaluation. [#84386](https://github.com/ClickHouse/ClickHouse/pull/84386) ([Elmi Ahmadov](https://github.com/ahmadov)). +* Fix reading Variant column with lazy materialization. [#84400](https://github.com/ClickHouse/ClickHouse/pull/84400) ([Pavel Kruglov](https://github.com/Avogar)). +* Make `zoutofmemory` hardware error, otherwise it will throw logical error. see https://github.com/clickhouse/clickhouse-core-incidents/issues/877. [#84420](https://github.com/ClickHouse/ClickHouse/pull/84420) ([Han Fei](https://github.com/hanfei1991)). +* Fixed server crash when a user created with `no_password` attempts to login after the server setting `allow_no_password` was changed to 0. [#84426](https://github.com/ClickHouse/ClickHouse/pull/84426) ([Shankar Iyer](https://github.com/shankar-iyer)). +* Fix out-of-order writes to Keeper changelog. Previously, we could have in-flight writes to changelog, but rollback could cause concurrent change of the destination file. This would lead to inconsistent logs, and possible data loss. [#84434](https://github.com/ClickHouse/ClickHouse/pull/84434) ([Antonio Andelic](https://github.com/antonio2368)). +* Now if all TTL are removed from table MergeTree will do nothing related to TTL. [#84441](https://github.com/ClickHouse/ClickHouse/pull/84441) ([alesapin](https://github.com/alesapin)). +* Parallel distributed INSERT SELECT with LIMIT was allowed which is not correct, it leads to data duplication in target table. [#84477](https://github.com/ClickHouse/ClickHouse/pull/84477) ([Igor Nikonov](https://github.com/devcrafter)). +* Fix pruning files by virtual column in data lakes. [#84520](https://github.com/ClickHouse/ClickHouse/pull/84520) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Fix leaks for keeper with rocksdb storage (iterators was not destroyed). [#84523](https://github.com/ClickHouse/ClickHouse/pull/84523) ([Azat Khuzhin](https://github.com/azat)). +* Fix ALTER MODIFY ORDER BY not validating TTL columns in sorting keys. TTL columns are now properly rejected when used in ORDER BY clauses during ALTER operations, preventing potential table corruption. [#84536](https://github.com/ClickHouse/ClickHouse/pull/84536) ([xiaohuanlin](https://github.com/xiaohuanlin)). +* Change pre-25.5 value of `allow_experimental_delta_kernel_rs` to `false` for compatibility. [#84587](https://github.com/ClickHouse/ClickHouse/pull/84587) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Stops taking schema from manifest files but stores relevant schemas for each snapshot independently. Infer relevant schema for each data file from its corresponding snapshot. Previous behaviour violated Iceberg specification for manifest files entries with existing status. [#84588](https://github.com/ClickHouse/ClickHouse/pull/84588) ([Daniil Ivanik](https://github.com/divanik)). +* Fixed issue where Keeper setting `rotate_log_storage_interval = 0` would cause ClickHouse to crash. (issue [#83975](https://github.com/ClickHouse/ClickHouse/issues/83975)). [#84637](https://github.com/ClickHouse/ClickHouse/pull/84637) ([George Larionov](https://github.com/george-larionov)). +* Fix logical error from S3Queue "Table is already registered". Closes [#84433](https://github.com/ClickHouse/ClickHouse/issues/84433). Broken after https://github.com/ClickHouse/ClickHouse/pull/83530. [#84677](https://github.com/ClickHouse/ClickHouse/pull/84677) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Lock 'mutex' when getting zookeeper from 'view' in RefreshTask. [#84699](https://github.com/ClickHouse/ClickHouse/pull/84699) ([Tuan Pham Anh](https://github.com/tuanpach)). +* Fix `CORRUPTED_DATA` error when lazy columns are used with external sort. [#84738](https://github.com/ClickHouse/ClickHouse/pull/84738) ([János Benjamin Antal](https://github.com/antaljanosbenjamin)). +* Fix column pruning with delta-kernel in storage `DeltaLake`. Closes [#84543](https://github.com/ClickHouse/ClickHouse/issues/84543). [#84745](https://github.com/ClickHouse/ClickHouse/pull/84745) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Refresh credentials in delta-kernel in storage DeltaLake. [#84751](https://github.com/ClickHouse/ClickHouse/pull/84751) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Fix starting superfluous internal backups after connection problems. [#84755](https://github.com/ClickHouse/ClickHouse/pull/84755) ([Vitaly Baranov](https://github.com/vitlibar)). +* Fixed issue where querying a delayed remote source could result in vector out of bounds. [#84820](https://github.com/ClickHouse/ClickHouse/pull/84820) ([George Larionov](https://github.com/george-larionov)). +* The `ngram` and `no_op` tokenizers no longer crash the (experimental) text index for empty input tokens. [#84849](https://github.com/ClickHouse/ClickHouse/pull/84849) ([Robert Schulze](https://github.com/rschu1ze)). +* Fixed lightweight updates for tables with `ReplacingMergeTree` and `CollapsingMergeTree` engines. [#84851](https://github.com/ClickHouse/ClickHouse/pull/84851) ([Anton Popov](https://github.com/CurtizJ)). +* Correctly store all settings in table metadata for tables using object queue engine. [#84860](https://github.com/ClickHouse/ClickHouse/pull/84860) ([Antonio Andelic](https://github.com/antonio2368)). +* Fix total watches count returned by Keeper. [#84890](https://github.com/ClickHouse/ClickHouse/pull/84890) ([Antonio Andelic](https://github.com/antonio2368)). +* Fixed lightweight updates for tables with `ReplicatedMergeTree` engine created on servers with a version lower than 25.7. [#84933](https://github.com/ClickHouse/ClickHouse/pull/84933) ([Anton Popov](https://github.com/CurtizJ)). +* Fixed lightweight updates for tables with non-replicated `MergeTree` engine after running a `ALTER TABLE ... REPLACE PARTITION` query. [#84941](https://github.com/ClickHouse/ClickHouse/pull/84941) ([Anton Popov](https://github.com/CurtizJ)). +* Fixes column name generation for boolean literals to use "true"/"false" instead of "1"/"0", preventing column name conflicts between boolean and integer literals in queries. [#84945](https://github.com/ClickHouse/ClickHouse/pull/84945) ([xiaohuanlin](https://github.com/xiaohuanlin)). +* Fix memory tracking drift from background schedule pool and executor. [#84946](https://github.com/ClickHouse/ClickHouse/pull/84946) ([Azat Khuzhin](https://github.com/azat)). +* Fix potential inaccurate sorting issues in the Merge table engine. [#85025](https://github.com/ClickHouse/ClickHouse/pull/85025) ([Xiaozhe Yu](https://github.com/wudidapaopao)). +* Implement missing APIs for DiskEncrypted. [#85028](https://github.com/ClickHouse/ClickHouse/pull/85028) ([Azat Khuzhin](https://github.com/azat)). +* Add a check if a correlated subquery is used in a distributed context to avoid a crash. Fixes [#82205](https://github.com/ClickHouse/ClickHouse/issues/82205). [#85030](https://github.com/ClickHouse/ClickHouse/pull/85030) ([Dmitry Novik](https://github.com/novikd)). +* Now Iceberg doesn't try to cache relevant snapshot version between select queries and always try to resolve snapshot honestly. Earlier attempt to cache iceberg snapshot led to problems with usage of Iceberg table with time travel. [#85038](https://github.com/ClickHouse/ClickHouse/pull/85038) ([Daniil Ivanik](https://github.com/divanik)). +* Fixed double-free in `AzureIteratorAsync`. [#85064](https://github.com/ClickHouse/ClickHouse/pull/85064) ([Nikita Taranov](https://github.com/nickitat)). +* Improve error message on attempt to create user identified with JWT. [#85072](https://github.com/ClickHouse/ClickHouse/pull/85072) ([Konstantin Bogdanov](https://github.com/thevar1able)). +* Fixed cleanup of patch parts in `ReplicatedMergeTree`. Previously, the result of a lightweight update may temporarily not be visible on the replica until the merged or mutated part that materializes the patch parts is downloaded from another replica. [#85121](https://github.com/ClickHouse/ClickHouse/pull/85121) ([Anton Popov](https://github.com/CurtizJ)). +* Fixing illegal_type_of_argument in mv when types are different. [#85135](https://github.com/ClickHouse/ClickHouse/pull/85135) ([Sema Checherinda](https://github.com/CheSema)). +* Fix segfault in delta-kernel implementation. [#85160](https://github.com/ClickHouse/ClickHouse/pull/85160) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Fix recovering replicated databases when moving the metadata file takes a long time. [#85177](https://github.com/ClickHouse/ClickHouse/pull/85177) ([Tuan Pham Anh](https://github.com/tuanpach)). +* Fix `Not-ready Set` for `IN (subquery)` inside `additional_table_filters expression` setting. [#85210](https://github.com/ClickHouse/ClickHouse/pull/85210) ([Nikolai Kochetov](https://github.com/KochetovNicolai)). +* Get rid of unnecessary `getStatus()` calls during SYSTEM DROP REPLICA queries. Fixes the case when a table is dropped in the background, and the `Shutdown for storage is called` exception is thrown. [#85220](https://github.com/ClickHouse/ClickHouse/pull/85220) ([Nikolay Degterinsky](https://github.com/evillique)). +* Fix race in `DeltaLake` engine delta-kernel implementation. [#85221](https://github.com/ClickHouse/ClickHouse/pull/85221) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Fix reading partitioned data with disabled delta-kernel in `DeltaLake` engine. It was broken in 25.7 (https://github.com/ClickHouse/ClickHouse/pull/81136). [#85223](https://github.com/ClickHouse/ClickHouse/pull/85223) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Added missing table name length checks in CREATE OR REPLACE and RENAME queries. [#85326](https://github.com/ClickHouse/ClickHouse/pull/85326) ([Michael Kolupaev](https://github.com/al13n321)). +* Fix the creation of RMV on a new replica of the Replicated database if DEFINER is dropped. [#85327](https://github.com/ClickHouse/ClickHouse/pull/85327) ([Nikolay Degterinsky](https://github.com/evillique)). +* Fix iceberg writes for complex types. [#85330](https://github.com/ClickHouse/ClickHouse/pull/85330) ([Konstantin Vedernikov](https://github.com/scanhex12)). +* Writing lower and upper bounds are not supported for complex types. [#85332](https://github.com/ClickHouse/ClickHouse/pull/85332) ([Konstantin Vedernikov](https://github.com/scanhex12)). +* Fix logical error while reading from object storage functions through Distributed table or remote table function. Fixes: [#84658](https://github.com/ClickHouse/ClickHouse/issues/84658), Fixes [#85173](https://github.com/ClickHouse/ClickHouse/issues/85173), Fixes [#52022](https://github.com/ClickHouse/ClickHouse/issues/52022). [#85359](https://github.com/ClickHouse/ClickHouse/pull/85359) ([alesapin](https://github.com/alesapin)). +* Fix backup of parts with broken projections. [#85362](https://github.com/ClickHouse/ClickHouse/pull/85362) ([Antonio Andelic](https://github.com/antonio2368)). +* Forbid using `_part_offset` column in projection in releases until it is stabilized. [#85372](https://github.com/ClickHouse/ClickHouse/pull/85372) ([Sema Checherinda](https://github.com/CheSema)). +* Fix crash and data corruption during ALTER UPDATE for JSON. [#85383](https://github.com/ClickHouse/ClickHouse/pull/85383) ([Pavel Kruglov](https://github.com/Avogar)). +* Queries with parallel replicas which uses reading reverse in order optimization can produce incorrect result. [#85406](https://github.com/ClickHouse/ClickHouse/pull/85406) ([Igor Nikonov](https://github.com/devcrafter)). +* Fix possible UB (crashes) in case of MEMORY_LIMIT_EXCEEDED during String deserialization. [#85440](https://github.com/ClickHouse/ClickHouse/pull/85440) ([Azat Khuzhin](https://github.com/azat)). +* Fix incorrect metrics KafkaAssignedPartitions and KafkaConsumersWithAssignment. [#85494](https://github.com/ClickHouse/ClickHouse/pull/85494) ([Ilya Golshtein](https://github.com/ilejn)). +* Fixed processed bytes stat being underestimated when PREWHERE (explicit or automatic) is used. [#85495](https://github.com/ClickHouse/ClickHouse/pull/85495) ([Michael Kolupaev](https://github.com/al13n321)). +* Fix early return condition for S3 request rate slowdown: require either s3_slow_all_threads_after_network_error or backup_slow_all_threads_after_retryable_s3_error to be true to enable slowdown behavior when all threads are paused due to a retryable error, instead of requiring both. [#85505](https://github.com/ClickHouse/ClickHouse/pull/85505) ([Julia Kartseva](https://github.com/jkartseva)). +* This pr fixes the metadata resolution when querying iceberg tables through rest catalog. ... [#85531](https://github.com/ClickHouse/ClickHouse/pull/85531) ([Saurabh Kumar Ojha](https://github.com/saurabhojha)). +* Fixed rare crash in asynchronous inserts that change settings `log_comment` or `insert_deduplication_token`. [#85540](https://github.com/ClickHouse/ClickHouse/pull/85540) ([Anton Popov](https://github.com/CurtizJ)). +* Parameters like date_time_input_format were ignored when using HTTP with multipart/form-data. [#85570](https://github.com/ClickHouse/ClickHouse/pull/85570) ([Sema Checherinda](https://github.com/CheSema)). +* Fix secrets masking in icebergS3Cluster and icebergAzureCluster table functions. [#85658](https://github.com/ClickHouse/ClickHouse/pull/85658) ([MikhailBurdukov](https://github.com/MikhailBurdukov)). +* Fix precision loss in `JSONExtract` when converting JSON numbers to Decimal types. Now numeric JSON values preserve their exact decimal representation, avoiding floating-point rounding errors. [#85665](https://github.com/ClickHouse/ClickHouse/pull/85665) ([ssive7b](https://github.com/ssive7b)). +* Fixed `LOGICAL_ERROR` when using `COMMENT COLUMN IF EXISTS` in the same `ALTER` statement after `DROP COLUMN`. The `IF EXISTS` clause now correctly skips the comment operation when the column has been dropped within the same statement. [#85688](https://github.com/ClickHouse/ClickHouse/pull/85688) ([xiaohuanlin](https://github.com/xiaohuanlin)). +* Fix reading count from cache for delta lake. [#85704](https://github.com/ClickHouse/ClickHouse/pull/85704) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Fix coalescing merge tree segfault for large strings. This closes [#84582](https://github.com/ClickHouse/ClickHouse/issues/84582). [#85709](https://github.com/ClickHouse/ClickHouse/pull/85709) ([Konstantin Vedernikov](https://github.com/scanhex12)). +* Update metadata timestamp in iceberg writes. [#85711](https://github.com/ClickHouse/ClickHouse/pull/85711) ([Konstantin Vedernikov](https://github.com/scanhex12)). +* Using `distributed_depth` as an indicator of *Cluster function was incorrect and may lead to data duplication; use `client_info.collaborate_with_initiator` instead. [#85734](https://github.com/ClickHouse/ClickHouse/pull/85734) ([Konstantin Bogdanov](https://github.com/thevar1able)). +* Spark can't read position delete files. [#85762](https://github.com/ClickHouse/ClickHouse/pull/85762) ([Konstantin Vedernikov](https://github.com/scanhex12)). +* Fix send_logs_source_regexp (after async logging refactoring in [#85105](https://github.com/ClickHouse/ClickHouse/issues/85105)). [#85797](https://github.com/ClickHouse/ClickHouse/pull/85797) ([Azat Khuzhin](https://github.com/azat)). +* Fix possible inconsistency for dictionaries with update_field on MEMORY_LIMIT_EXCEEDED errors. [#85807](https://github.com/ClickHouse/ClickHouse/pull/85807) ([Azat Khuzhin](https://github.com/azat)). +* Support global constants from `WITH` statement for the parallel distributed `INSERT SELECT` with the `Distributed` destination table. Before, the query could throw an `Unknown expression identifier` error. [#85811](https://github.com/ClickHouse/ClickHouse/pull/85811) ([Nikolai Kochetov](https://github.com/KochetovNicolai)). +* Mask credentials for `deltaLakeAzure`, `deltaLakeCluster`, `icebergS3Cluster` and `icebergAzureCluster`. [#85889](https://github.com/ClickHouse/ClickHouse/pull/85889) ([Julian Maicher](https://github.com/jmaicher)). +* Fix logical error on attempt to `CREATE ... AS (SELECT * FROM s3Cluster(...))` with `DatabaseReplicated`. [#85904](https://github.com/ClickHouse/ClickHouse/pull/85904) ([Konstantin Bogdanov](https://github.com/thevar1able)). +* Fixes HTTP requests made by the `url()` table function to properly include port numbers in the Host header when accessing non-standard ports. This resolves authentication failures when using presigned URLs with S3-compatible services like MinIO running on custom ports, which is common in development environments. (Fixes [#85898](https://github.com/ClickHouse/ClickHouse/issues/85898)). [#85921](https://github.com/ClickHouse/ClickHouse/pull/85921) ([Tom Quist](https://github.com/tomquist)). +* Now unity catalog will ignore schemas with weird data types in case of non-delta tables. Fixes [#85699](https://github.com/ClickHouse/ClickHouse/issues/85699). [#85950](https://github.com/ClickHouse/ClickHouse/pull/85950) ([alesapin](https://github.com/alesapin)). +* Fix nullability of fields in iceberg. [#85977](https://github.com/ClickHouse/ClickHouse/pull/85977) ([Konstantin Vedernikov](https://github.com/scanhex12)). +* Fixed a bug in `Replicated` database recovery: if a table name contains the `%` symbol, it could re-create the table with a different name during recovery. [#85987](https://github.com/ClickHouse/ClickHouse/pull/85987) ([Alexander Tokmakov](https://github.com/tavplubix)). +* Fix backup restores failing due to `BACKUP_ENTRY_NOT_FOUND` error when restoring an empty `Memory` table. [#86012](https://github.com/ClickHouse/ClickHouse/pull/86012) ([Julia Kartseva](https://github.com/jkartseva)). +* Add checks for sharding_key during ALTER of the Distributed table. Previously incorrect ALTER would break the table definition and server restart. [#86015](https://github.com/ClickHouse/ClickHouse/pull/86015) ([Nikolay Degterinsky](https://github.com/evillique)). +* Don't create empty iceberg delete file. [#86061](https://github.com/ClickHouse/ClickHouse/pull/86061) ([Konstantin Vedernikov](https://github.com/scanhex12)). +* Fix large setting values breaking S3Queue tables and replica restart. [#86074](https://github.com/ClickHouse/ClickHouse/pull/86074) ([Nikolay Degterinsky](https://github.com/evillique)). + +#### Build/Testing/Packaging Improvement +* Use encrypted disks for tests with S3 by default. [#59898](https://github.com/ClickHouse/ClickHouse/pull/59898) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)). +* Use `clickhouse` binary in integrations tests to get unstripped debug symbols. [#83779](https://github.com/ClickHouse/ClickHouse/pull/83779) ([Mikhail f. Shiryaev](https://github.com/Felixoid)). +* Bumped the internal libxml2 from 2.14.4 to 2.14.5. [#84230](https://github.com/ClickHouse/ClickHouse/pull/84230) ([Robert Schulze](https://github.com/rschu1ze)). +* Bumped internal curl from 8.14.0 to 8.15.0. [#84231](https://github.com/ClickHouse/ClickHouse/pull/84231) ([Robert Schulze](https://github.com/rschu1ze)). +* Now we use less memory for caches in CI and have better tests for eviction. [#84676](https://github.com/ClickHouse/ClickHouse/pull/84676) ([alesapin](https://github.com/alesapin)). + + +### ClickHouse release 25.7, 2025-07-24 {#257} + +#### Backward Incompatible Change +* Changes to `extractKeyValuePairs` function: introduce a new argument `unexpected_quoting_character_strategy` that controls what happens when a `quoting_character` is unexpectedly found when reading a non quoted key or value. The value can be one of: `invalid`, `accept` or `promote`. Invalid will discard the key and go back to waiting key state. Accept will treat it as part of the key. Promote will discard previous character and start parsing as a quoted key. In addition, after parsing a quoted value, only parse the next key if a pair delimiter is found. [#80657](https://github.com/ClickHouse/ClickHouse/pull/80657) ([Arthur Passos](https://github.com/arthurpassos)). +* Support zero-byte match in `countMatches` function. Users who like to retain the old behavior can enable setting `count_matches_stop_at_empty_match`. [#81676](https://github.com/ClickHouse/ClickHouse/pull/81676) ([Elmi Ahmadov](https://github.com/ahmadov)). +* Use server-wide throttlers for local (`max_local_read_bandwidth_for_server` and `max_local_write_bandwidth_for_server`) and remote (`max_remote_read_network_bandwidth_for_server` and `max_remote_write_network_bandwidth_for_server`) when generating BACKUPs in addition to their dedicated server settings (`max_backup_bandwidth_for_server`, `max_mutations_bandwidth_for_server` and `max_merges_bandwidth_for_server`). [#81753](https://github.com/ClickHouse/ClickHouse/pull/81753) ([Sergei Trifonov](https://github.com/serxa)). +* Forbid the creation of a table without insertable columns. [#81835](https://github.com/ClickHouse/ClickHouse/pull/81835) ([Pervakov Grigorii](https://github.com/GrigoryPervakov)). +* Parallelize cluster functions by files within archives. In previous versions, the whole archive (such as zip, tar, or 7z) was a unit of work. Added a new setting `cluster_function_process_archive_on_multiple_nodes`, by default equal to `true`. If set to `true`, increases performance of processing archives in cluster functions. Should be set to `false` for compatibility and to avoid errors during upgrade to 25.7+ if using cluster functions with archives on earlier versions. [#82355](https://github.com/ClickHouse/ClickHouse/pull/82355) ([Kseniia Sumarokova](https://github.com/kssenii)). +* `SYSTEM RESTART REPLICAS` query led to the wakeup of tables in the Lazy database, even without access to that database, and it happened while these tables were being concurrently dropped. Note: Now `SYSTEM RESTART REPLICAS` will only restart replicas in the databases where you have permission to `SHOW TABLES`, which is natural. [#83321](https://github.com/ClickHouse/ClickHouse/pull/83321) ([Alexey Milovidov](https://github.com/alexey-milovidov)). + +#### New Feature +* Added support for lightweight updates for `MergeTree`-family tables. Lightweight updates can be used by a new syntax: `UPDATE SET col1 = val1, col2 = val2, ... WHERE `. Added implementation of lightweight deletes via lightweight updates. It can be enabled by setting `lightweight_delete_mode = 'lightweight_update'`. [#82004](https://github.com/ClickHouse/ClickHouse/pull/82004) ([Anton Popov](https://github.com/CurtizJ)). +* Support complex types in Iceberg schema evolution. [#73714](https://github.com/ClickHouse/ClickHouse/pull/73714) ([Konstantin Vedernikov](https://github.com/scanhex12)). +* Introduce support for INSERTs into Iceberg tables. [#82692](https://github.com/ClickHouse/ClickHouse/pull/82692) ([Konstantin Vedernikov](https://github.com/scanhex12)). +* Read Iceberg data files by field ids. This improves compatibility with Iceberg: the fields can be renamed in the metadata while being mapped to the different names in the underlying Parquet files. This closes [#83065](https://github.com/ClickHouse/ClickHouse/issues/83065). [#83653](https://github.com/ClickHouse/ClickHouse/pull/83653) ([Konstantin Vedernikov](https://github.com/scanhex12)). +* Now clickhouse supports compressed `metadata.json` files for Iceberg. Fixes [#70874](https://github.com/ClickHouse/ClickHouse/issues/70874). [#81451](https://github.com/ClickHouse/ClickHouse/pull/81451) ([alesapin](https://github.com/alesapin)). +* Support `TimestampTZ` in Glue catalog. This closes [#81654](https://github.com/ClickHouse/ClickHouse/issues/81654). [#83132](https://github.com/ClickHouse/ClickHouse/pull/83132) ([Konstantin Vedernikov](https://github.com/scanhex12)). +* Add AI-powered SQL generation to ClickHouse client. Users can now generate SQL queries from natural language descriptions by prefixing their query with `??`. Supports OpenAI and Anthropic providers with automatic schema discovery. [#83314](https://github.com/ClickHouse/ClickHouse/pull/83314) ([Kaushik Iska](https://github.com/iskakaushik)). +* Add a function to write Geo types into WKB format. [#82935](https://github.com/ClickHouse/ClickHouse/pull/82935) ([Konstantin Vedernikov](https://github.com/scanhex12)). +* Introduced two new access types: `READ` and `WRITE` for sources and deprecates all previous access types related to sources. Before `GRANT S3 ON *.* TO user`, now: `GRANT READ, WRITE ON S3 TO user`. This also allows to separate `READ` and `WRITE` permissions for sources, e.g.: `GRANT READ ON * TO user`, `GRANT WRITE ON S3 TO user`. The feature is controlled by a setting `access_control_improvements.enable_read_write_grants` and disabled by default. [#73659](https://github.com/ClickHouse/ClickHouse/pull/73659) ([pufit](https://github.com/pufit)). +* NumericIndexedVector: new vector data-structure backed by bit-sliced, Roaring-bitmap compression, together with more than 20 functions for building, analysing and point-wise arithmetic. Can cut storage and speed up joins, filters and aggregations on sparse data. Implements [#70582](https://github.com/ClickHouse/ClickHouse/issues/70582) and [“Large-Scale Metric Computation in Online Controlled Experiment Platform” paper](https://arxiv.org/abs/2405.08411) by T. Xiong and Y. Wang from VLDB 2024. [#74193](https://github.com/ClickHouse/ClickHouse/pull/74193) ([FriendLey](https://github.com/FriendLey)). +* The workload setting `max_waiting_queries` is now supported. It can be used to limit the size of the query queue. If the limit is reached, all subsequent queries will be terminated with the `SERVER_OVERLOADED` error. [#81250](https://github.com/ClickHouse/ClickHouse/pull/81250) ([Oleg Doronin](https://github.com/dorooleg)). +* Add financial functions: `financialInternalRateOfReturnExtended` (`XIRR`), `financialInternalRateOfReturn` (`IRR`), `financialNetPresentValueExtended` (`XNPV`), `financialNetPresentValue` (`NPV`). [#81599](https://github.com/ClickHouse/ClickHouse/pull/81599) ([Joanna Hulboj](https://github.com/jh0x)). +* Add the geospatial functions `polygonsIntersectCartesian` and `polygonsIntersectSpherical` to check if two polygons intersect. [#81882](https://github.com/ClickHouse/ClickHouse/pull/81882) ([Paul Lamb](https://github.com/plamb)). +* Support `_part_granule_offset` virtual column in MergeTree-family tables. This column indicates the zero-based index of the granule/mark each row belongs to within its data part. This addresses [#79572](https://github.com/ClickHouse/ClickHouse/issues/79572). [#82341](https://github.com/ClickHouse/ClickHouse/pull/82341) ([Amos Bird](https://github.com/amosbird)). [#82341](https://github.com/ClickHouse/ClickHouse/pull/82341) ([Amos Bird](https://github.com/amosbird)) +* Added SQL functions `colorSRGBToOkLCH` and `colorOkLCHToSRGB` for converting colours between the sRGB and OkLCH colour spaces. [#83679](https://github.com/ClickHouse/ClickHouse/pull/83679) ([Fgrtue](https://github.com/Fgrtue)). +* Allow parameters in `CREATE USER` queries for usernames. [#81387](https://github.com/ClickHouse/ClickHouse/pull/81387) ([Diskein](https://github.com/Diskein)). +* The `system.formats` table now contains extended information about formats, such as HTTP content type, the capabilities of schema inference, etc. [#81505](https://github.com/ClickHouse/ClickHouse/pull/81505) ([Alexey Milovidov](https://github.com/alexey-milovidov)). + +#### Experimental Feature +* Added functions `searchAny` and `searchAll` which are general purpose tools to search text indexes. [#80641](https://github.com/ClickHouse/ClickHouse/pull/80641) ([Elmi Ahmadov](https://github.com/ahmadov)). +* The text index now supports the new `split` tokenizer. [#81752](https://github.com/ClickHouse/ClickHouse/pull/81752) ([Elmi Ahmadov](https://github.com/ahmadov)). +* Changed the default index granularity value for `text` indexes to 64. This improves the expected performance for the average test query in internal benchmarks. [#82162](https://github.com/ClickHouse/ClickHouse/pull/82162) ([Jimmy Aguilar Mena](https://github.com/Ergus)). +* The 256-bit bitmap stores the outgoing labels of a state ordered, but outgoing states are saved into disk in the order they appear in the hash table. Therefore, a label would point to a wrong next state while reading from disk. [#82783](https://github.com/ClickHouse/ClickHouse/pull/82783) ([Elmi Ahmadov](https://github.com/ahmadov)). +* Enable zstd compression for FST tree blob in text indices. [#83093](https://github.com/ClickHouse/ClickHouse/pull/83093) ([Elmi Ahmadov](https://github.com/ahmadov)). +* Promote vector similarity index to beta. Introduced alias setting `enable_vector_similarity_index` which must be enabled to use the vector similarity index. [#83459](https://github.com/ClickHouse/ClickHouse/pull/83459) ([Robert Schulze](https://github.com/rschu1ze)). +* Removed experimental `send_metadata` logic related to experimental zero-copy replication. It wasn't ever used and nobody supports this code. Since there were even no tests related to it, there is a high chance that it's broken long time ago. [#82508](https://github.com/ClickHouse/ClickHouse/pull/82508) ([alesapin](https://github.com/alesapin)). +* Integrate `StorageKafka2` to `system.kafka_consumers`. [#82652](https://github.com/ClickHouse/ClickHouse/pull/82652) ([János Benjamin Antal](https://github.com/antaljanosbenjamin)). +* Estimate complex CNF/DNF, for example, `(a < 1 and a > 0) or b = 3`, by statistics. [#82663](https://github.com/ClickHouse/ClickHouse/pull/82663) ([Han Fei](https://github.com/hanfei1991)). + +#### Performance Improvement +* Introduce async logging. When logs are output to a slow device, it no longer delays queries. [#82516](https://github.com/ClickHouse/ClickHouse/pull/82516) ([Raúl Marín](https://github.com/Algunenano)). Limit the max number of entries that are hold in the queue. [#83214](https://github.com/ClickHouse/ClickHouse/pull/83214) ([Raúl Marín](https://github.com/Algunenano)). +* Parallel distributed INSERT SELECT is enabled by default in mode where INSERT SELECT executed on each shard independently, see `parallel_distributed_insert_select` setting. [#83040](https://github.com/ClickHouse/ClickHouse/pull/83040) ([Igor Nikonov](https://github.com/devcrafter)). +* When the aggregation query contains only a single `count()` function on a not-`Nullable` column, the aggregation logic is fully inlined during hash table probing. This avoids allocating and maintaining any aggregation state, significantly reducing memory usage and CPU overhead. This partially addresses [#81982](https://github.com/ClickHouse/ClickHouse/issues/81982). [#82104](https://github.com/ClickHouse/ClickHouse/pull/82104) ([Amos Bird](https://github.com/amosbird)). +* Performance of `HashJoin` optimised by removing the additional loop over hash maps in the typical case of only one key column, also `null_map` and `join_mask` checks are eliminated when they're always `true`/`false`. [#82308](https://github.com/ClickHouse/ClickHouse/pull/82308) ([Nikita Taranov](https://github.com/nickitat)). +* Trivial optimization for `-If` combinator. [#78454](https://github.com/ClickHouse/ClickHouse/pull/78454) ([李扬](https://github.com/taiyang-li)). +* Vector search queries using a vector similarity index complete with lower latency due to reduced storage reads and reduced CPU usage. [#79103](https://github.com/ClickHouse/ClickHouse/pull/79103) ([Shankar Iyer](https://github.com/shankar-iyer)). +* Respect `merge_tree_min_{rows,bytes}_for_seek` in `filterPartsByQueryConditionCache` to align it with other methods filtering by indexes. [#80312](https://github.com/ClickHouse/ClickHouse/pull/80312) ([李扬](https://github.com/taiyang-li)). +* Make the pipeline after the `TOTALS` step multithreaded. [#80331](https://github.com/ClickHouse/ClickHouse/pull/80331) ([UnamedRus](https://github.com/UnamedRus)). +* Fix filter by key for `Redis` and `KeeperMap` storages. [#81833](https://github.com/ClickHouse/ClickHouse/pull/81833) ([Pervakov Grigorii](https://github.com/GrigoryPervakov)). +* Add new setting `min_joined_block_size_rows` (analogous to `min_joined_block_size_bytes`; defaults to 65409) to control the minimum block size (in rows) for JOIN input and output blocks (if the join algorithm supports it). Small blocks will be squashed. [#81886](https://github.com/ClickHouse/ClickHouse/pull/81886) ([Nikita Taranov](https://github.com/nickitat)). +* `ATTACH PARTITION` no longer leads to the dropping of all caches. [#82377](https://github.com/ClickHouse/ClickHouse/pull/82377) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Optimize the generated plan for correlated subqueries by removing redundant JOIN operations using equivalence classes. If there are equivalent expressions for all correlated columns, `CROSS JOIN` is not produced if `query_plan_correlated_subqueries_use_substitution` setting is enabled. [#82435](https://github.com/ClickHouse/ClickHouse/pull/82435) ([Dmitry Novik](https://github.com/novikd)). +* Read only required columns in correlated subquery when it appears to be an argument of function `EXISTS`. [#82443](https://github.com/ClickHouse/ClickHouse/pull/82443) ([Dmitry Novik](https://github.com/novikd)). +* Speedup comparisons of query trees during the query analysis a bit. [#82617](https://github.com/ClickHouse/ClickHouse/pull/82617) ([Nikolai Kochetov](https://github.com/KochetovNicolai)). +* Add alignment in the Counter of ProfileEvents to reduce false sharing. [#82697](https://github.com/ClickHouse/ClickHouse/pull/82697) ([Jiebin Sun](https://github.com/jiebinn)). +* The optimizations for `null_map` and `JoinMask` from [#82308](https://github.com/ClickHouse/ClickHouse/issues/82308) were applied to the case of JOIN with multiple disjuncts. Also, the `KnownRowsHolder` data structure was optimized. [#83041](https://github.com/ClickHouse/ClickHouse/pull/83041) ([Nikita Taranov](https://github.com/nickitat)). +* Plain `std::vector` is used for join flags to avoid calculating a hash on each access to flags. [#83043](https://github.com/ClickHouse/ClickHouse/pull/83043) ([Nikita Taranov](https://github.com/nickitat)). +* Don't pre-allocate memory for result columns beforehand when `HashJoin` uses `lazy` output mode. It is suboptimal, especially when the number of matches is low. Moreover, we know the exact amount of matches after joining is done, so we can preallocate more precisely. [#83304](https://github.com/ClickHouse/ClickHouse/pull/83304) ([Nikita Taranov](https://github.com/nickitat)). +* Minimize memory copy in port headers during pipeline construction. Original [PR](https://github.com/ClickHouse/ClickHouse/pull/70105) by [heymind](https://github.com/heymind). [#83381](https://github.com/ClickHouse/ClickHouse/pull/83381) ([Raúl Marín](https://github.com/Algunenano)). +* Improve the startup of clickhouse-keeper when it uses rocksdb storage. [#83390](https://github.com/ClickHouse/ClickHouse/pull/83390) ([Antonio Andelic](https://github.com/antonio2368)). +* Avoid holding the lock while creating storage snapshot data to reduce lock contention with high concurrent load. [#83510](https://github.com/ClickHouse/ClickHouse/pull/83510) ([Duc Canh Le](https://github.com/canhld94)). +* Improved performance of the `ProtobufSingle` input format by reusing the serializer when no parsing errors occur. [#83613](https://github.com/ClickHouse/ClickHouse/pull/83613) ([Eduard Karacharov](https://github.com/korowa)). +* Improve the performance of pipeline building that speeds up short queries. [#83631](https://github.com/ClickHouse/ClickHouse/pull/83631) ([Raúl Marín](https://github.com/Algunenano)). +* Optimize `MergeTreeReadersChain::getSampleBlock` that speeds up short queries. [#83875](https://github.com/ClickHouse/ClickHouse/pull/83875) ([Raúl Marín](https://github.com/Algunenano)). +* Speedup tables listing in data catalogs by asynchronous requests. [#81084](https://github.com/ClickHouse/ClickHouse/pull/81084) ([alesapin](https://github.com/alesapin)). +* Introduce jitter to the S3 retry mechanism when the `s3_slow_all_threads_after_network_error` configuration is enabled. [#81849](https://github.com/ClickHouse/ClickHouse/pull/81849) ([zoomxi](https://github.com/zoomxi)). + +#### Improvement +* Color parenthesis in multiple colors for better readability. [#82538](https://github.com/ClickHouse/ClickHouse/pull/82538) ([Konstantin Bogdanov](https://github.com/thevar1able)). +* Highlight metacharacters in LIKE/REGEXP patterns as you type. We already have it in `clickhouse-format` and in the echo in `clickhouse-client`, but now it is done in the command prompt as well. [#82871](https://github.com/ClickHouse/ClickHouse/pull/82871) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Highlighting in `clickhouse-format` and in the client's echo will work in the same way as the highlighting in the command line prompt. [#82874](https://github.com/ClickHouse/ClickHouse/pull/82874) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Now `plain_rewritable` disks are allowed as disks for database metadata. Implement methods `moveFile` and `replaceFile` in `plain_rewritable` to support it as a database disk. [#79424](https://github.com/ClickHouse/ClickHouse/pull/79424) ([Tuan Pham Anh](https://github.com/tuanpach)). +* Allow backups for `PostgreSQL`, `MySQL` and `DataLake` databases. A backup of such a database would only save the definition and not the data inside of it. [#79982](https://github.com/ClickHouse/ClickHouse/pull/79982) ([Nikolay Degterinsky](https://github.com/evillique)). +* Setting `allow_experimental_join_condition` marked as obsolete, because it is now always allowed. [#80566](https://github.com/ClickHouse/ClickHouse/pull/80566) ([Vladimir Cherkasov](https://github.com/vdimir)). +* Add pressure metrics to ClickHouse async metrics. [#80779](https://github.com/ClickHouse/ClickHouse/pull/80779) ([Xander Garbett](https://github.com/Garbett1)). +* Added metrics `MarkCacheEvictedBytes`, `MarkCacheEvictedMarks`, `MarkCacheEvictedFiles` for tracking evictions from the mark cache. (issue [#60989](https://github.com/ClickHouse/ClickHouse/issues/60989)). [#80799](https://github.com/ClickHouse/ClickHouse/pull/80799) ([Shivji Kumar Jha](https://github.com/shiv4289)). +* Support writing Parquet enum as byte array as the [spec](https://github.com/apache/parquet-format/blob/master/LogicalTypes.md#enum) dictates. [#81090](https://github.com/ClickHouse/ClickHouse/pull/81090) ([Arthur Passos](https://github.com/arthurpassos)). +* An improvement for `DeltaLake` table engine: delta-kernel-rs has `ExpressionVisitor` API which is implemented in this PR and is applied to partition column expressions transform (it will replace an old deprecated within the delta-kernel-rs way, which was used before in our code). In the future this `ExpressionVisitor` will also allow to implement statistics based pruning and some delta-lake proprietary features. Additionally the purpose of this change is to support partition pruning in `DeltaLakeCluster` table engine (the result of a parsed expression - ActionsDAG - will be serialized and sent from the initiator along with the data path, because this kind of information, which is needed for pruning, is only available as meta information on data files listing, which is done by initiator only, but it has to be applied to data on each reading server). [#81136](https://github.com/ClickHouse/ClickHouse/pull/81136) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Preserve element names when deriving supertypes for named tuples. [#81345](https://github.com/ClickHouse/ClickHouse/pull/81345) ([lgbo](https://github.com/lgbo-ustc)). +* Count consumed messages manually to avoid depending on previous committed offset in StorageKafka2. [#81662](https://github.com/ClickHouse/ClickHouse/pull/81662) ([János Benjamin Antal](https://github.com/antaljanosbenjamin)). +* Added `clickhouse-keeper-utils`, a new command-line tool for managing and analyzing ClickHouse Keeper data. The tool supports dumping state from snapshots and changelogs, analyzing changelog files, and extracting specific log ranges. [#81677](https://github.com/ClickHouse/ClickHouse/pull/81677) ([Antonio Andelic](https://github.com/antonio2368)). +* The total and per-user network throttlers are never reset, which ensures that `max_network_bandwidth_for_all_users` and `max_network_bandwidth_for_all_users` limits are never exceeded. [#81729](https://github.com/ClickHouse/ClickHouse/pull/81729) ([Sergei Trifonov](https://github.com/serxa)). +* Support writing geoparquets as output format. [#81784](https://github.com/ClickHouse/ClickHouse/pull/81784) ([Konstantin Vedernikov](https://github.com/scanhex12)). +* Forbid to start `RENAME COLUMN` alter mutation if it will rename some column that right now affected by incomplete data mutation. [#81823](https://github.com/ClickHouse/ClickHouse/pull/81823) ([Mikhail Artemenko](https://github.com/Michicosun)). +* Header Connection is send at the end of headers. When we know is the connection should be preserved. [#81951](https://github.com/ClickHouse/ClickHouse/pull/81951) ([Sema Checherinda](https://github.com/CheSema)). +* Tune TCP servers queue (64 by default) based on listen_backlog (4096 by default). [#82045](https://github.com/ClickHouse/ClickHouse/pull/82045) ([Azat Khuzhin](https://github.com/azat)). +* Add ability to reload `max_local_read_bandwidth_for_server` and `max_local_write_bandwidth_for_server` on fly without restart server. [#82083](https://github.com/ClickHouse/ClickHouse/pull/82083) ([Kai Zhu](https://github.com/nauu)). +* Add support for clearing all warnings from the `system.warnings` table using `TRUNCATE TABLE system.warnings`. [#82087](https://github.com/ClickHouse/ClickHouse/pull/82087) ([Vladimir Cherkasov](https://github.com/vdimir)). +* Fix partition pruning with data lake cluster functions. [#82131](https://github.com/ClickHouse/ClickHouse/pull/82131) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Fix reading partitioned data in DeltaLakeCluster table function. In this PR cluster functions protocol version is increased, allowing to send extra info from initiator to replicas. This extra info contains delta-kernel transform expression, which is needed to parse partition columns (and some other staff in the future, like generated columns, etc). [#82132](https://github.com/ClickHouse/ClickHouse/pull/82132) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Function `reinterpret` function now supports conversion to `Array(T)` where `T` is a fixed-size data type (issue [#82621](https://github.com/ClickHouse/ClickHouse/issues/82621)). [#83399](https://github.com/ClickHouse/ClickHouse/pull/83399) ([Shankar Iyer](https://github.com/shankar-iyer)). +* Now database Datalake throw more convenient exception. Fixes [#81211](https://github.com/ClickHouse/ClickHouse/issues/81211). [#82304](https://github.com/ClickHouse/ClickHouse/pull/82304) ([alesapin](https://github.com/alesapin)). +* Improve CROSS JOIN by returning false from `HashJoin::needUsedFlagsForPerRightTableRow`. [#82379](https://github.com/ClickHouse/ClickHouse/pull/82379) ([lgbo](https://github.com/lgbo-ustc)). +* Allow write/read map columns as Array of Tuples. [#82408](https://github.com/ClickHouse/ClickHouse/pull/82408) ([MikhailBurdukov](https://github.com/MikhailBurdukov)). +* List the licenses of [Rust](https://clickhouse.com/blog/rust) crates in `system.licenses`. [#82440](https://github.com/ClickHouse/ClickHouse/pull/82440) ([Raúl Marín](https://github.com/Algunenano)). +* Macros like `{uuid}` can now be used in the `keeper_path` setting of the S3Queue table engine. [#82463](https://github.com/ClickHouse/ClickHouse/pull/82463) ([Nikolay Degterinsky](https://github.com/evillique)). +* Keeper improvement: move changelog files between disk in a background thread. Previously, moving changelog to a different disk would block Keeper globally until the move is finished. This lead to performance degradation if moving is a long operation (e.g. to S3 disk). [#82485](https://github.com/ClickHouse/ClickHouse/pull/82485) ([Antonio Andelic](https://github.com/antonio2368)). +* Keeper improvement: add new config `keeper_server.cleanup_old_and_ignore_new_acl`. If enabled, all nodes will have their ACLs cleared while ACL for new requests will be ignored. If the goal is to completely remove ACL from nodes, it's important to leave the config enabled until a new snapshot is created. [#82496](https://github.com/ClickHouse/ClickHouse/pull/82496) ([Antonio Andelic](https://github.com/antonio2368)). +* Added a new server setting `s3queue_disable_streaming` which disables streaming in tables with S3Queue table engine. This setting is changeable without server restart. [#82515](https://github.com/ClickHouse/ClickHouse/pull/82515) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Refactor dynamic resize feature of filesystem cache. Added more logs for introspection. [#82556](https://github.com/ClickHouse/ClickHouse/pull/82556) ([Kseniia Sumarokova](https://github.com/kssenii)). +* `clickhouse-server` without a configuration file will also listen to the PostgreSQL port 9005, like with the default config. [#82633](https://github.com/ClickHouse/ClickHouse/pull/82633) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* In `ReplicatedMergeTree::executeMetadataAlter`, we get the StorageID, and without taking DDLGuard, we try to call `IDatabase::alterTable`. In between this time we could have technically exchanged the table in question with another table, so when we get the definiton we would get the wrong one. To avoid this we add a separate check for UUIDs to match when we try to call `IDatabase::alterTable`. [#82666](https://github.com/ClickHouse/ClickHouse/pull/82666) ([Nikolay Degterinsky](https://github.com/evillique)). +* When attaching a database with a read-only remote disk, manually add table UUIDs into DatabaseCatalog. [#82670](https://github.com/ClickHouse/ClickHouse/pull/82670) ([Tuan Pham Anh](https://github.com/tuanpach)). +* Prevent user from using `nan` and `inf` with `NumericIndexedVector`. Fixes [#82239](https://github.com/ClickHouse/ClickHouse/issues/82239) and a little more. [#82681](https://github.com/ClickHouse/ClickHouse/pull/82681) ([Raufs Dunamalijevs](https://github.com/rienath)). +* Do not omit zero values in the `X-ClickHouse-Progress` and `X-ClickHouse-Summary` header formats. [#82727](https://github.com/ClickHouse/ClickHouse/pull/82727) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)). +* Keeper improvement: support specific permissions for world:anyone ACL. [#82755](https://github.com/ClickHouse/ClickHouse/pull/82755) ([Antonio Andelic](https://github.com/antonio2368)). +* Do not allow `RENAME COLUMN` or `DROP COLUMN` involving explicitly listed columns to sum in SummingMergeTree. Closes [#81836](https://github.com/ClickHouse/ClickHouse/issues/81836). [#82821](https://github.com/ClickHouse/ClickHouse/pull/82821) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Improve the precision of conversion from `Decimal` to `Float32`. Implement conversion from `Decimal` to `BFloat16`. Closes [#82660](https://github.com/ClickHouse/ClickHouse/issues/82660). [#82823](https://github.com/ClickHouse/ClickHouse/pull/82823) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Scrollbars in the Web UI will look slightly better. [#82869](https://github.com/ClickHouse/ClickHouse/pull/82869) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* `clickhouse-server` with embedded configuration will allow using the Web UI by providing an HTTP OPTIONS response. [#82870](https://github.com/ClickHouse/ClickHouse/pull/82870) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Add support for specifying extra Keeper ACL for paths in config. If you want to add extra ACL for a specific path you define it in the config under `zookeeper.path_acls`. [#82898](https://github.com/ClickHouse/ClickHouse/pull/82898) ([Antonio Andelic](https://github.com/antonio2368)). +* Now mutations snapshot will be built from the visible parts snapshot. Also mutation counters used in snapshot will be recalculated from the included mutations. [#82945](https://github.com/ClickHouse/ClickHouse/pull/82945) ([Mikhail Artemenko](https://github.com/Michicosun)). +* Adds ProfileEvent when Keeper rejects a write due to soft memory limit. [#82963](https://github.com/ClickHouse/ClickHouse/pull/82963) ([Xander Garbett](https://github.com/Garbett1)). +* Add columns `commit_time`, `commit_id` to `system.s3queue_log`. [#83016](https://github.com/ClickHouse/ClickHouse/pull/83016) ([Kseniia Sumarokova](https://github.com/kssenii)). +* In some cases, we need to have multiple dimensions to our metrics. For example, counting failed merges or mutations by error codes rather than having a single counter. Introduce `system.dimensional_metrics`, which does precisely that and adds the first dimensional metric called `failed_merges`. [#83030](https://github.com/ClickHouse/ClickHouse/pull/83030) ([Miсhael Stetsyuk](https://github.com/mstetsyuk)). +* Consolidate unknown settings warnings in clickhouse client and log them as a summary. [#83042](https://github.com/ClickHouse/ClickHouse/pull/83042) ([Bharat Nallan](https://github.com/bharatnc)). +* Clickhouse client now reports the local port when connection error happens. [#83050](https://github.com/ClickHouse/ClickHouse/pull/83050) ([Jianfei Hu](https://github.com/incfly)). +* Slightly better error handling in `AsynchronousMetrics`. If the `/sys/block` directory exists but is not accessible, the server will start without monitoring the block devices. Closes [#79229](https://github.com/ClickHouse/ClickHouse/issues/79229). [#83115](https://github.com/ClickHouse/ClickHouse/pull/83115) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Shutdown SystemLogs after ordinary tables (and before system tables, instead of before ordinary). [#83134](https://github.com/ClickHouse/ClickHouse/pull/83134) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Add logs for `S3Queue` shutdown process. [#83163](https://github.com/ClickHouse/ClickHouse/pull/83163) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Possibility to parse `Time` and `Time64` as `MM:SS`, `M:SS`, `SS`, or `S`. [#83299](https://github.com/ClickHouse/ClickHouse/pull/83299) ([Yarik Briukhovetskyi](https://github.com/yariks5s)). +* When `distributed_ddl_output_mode='*_only_active'`, don't wait for new or recovered replicas that have replication lag bigger than `max_replication_lag_to_enqueue`. This should help to avoid `DDL task is not finished on some hosts` when a new replica becomes active after finishing initialization or recovery, but it accumulated huge replication log while initializing. Also, implement `SYSTEM SYNC DATABASE REPLICA STRICT` query that waits for replication log to become below `max_replication_lag_to_enqueue`. [#83302](https://github.com/ClickHouse/ClickHouse/pull/83302) ([Alexander Tokmakov](https://github.com/tavplubix)). +* Do not output too long descriptions of expression actions in exception messages. Closes [#83164](https://github.com/ClickHouse/ClickHouse/issues/83164). [#83350](https://github.com/ClickHouse/ClickHouse/pull/83350) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Add ability to parse part's prefix and suffix and also check coverage for non constant columns. [#83377](https://github.com/ClickHouse/ClickHouse/pull/83377) ([Mikhail Artemenko](https://github.com/Michicosun)). +* Unify parameter names in ODBC and JDBC when using named collections. [#83410](https://github.com/ClickHouse/ClickHouse/pull/83410) ([Andrey Zvonov](https://github.com/zvonand)). +* When the storage is shutting down, `getStatus` throws an `ErrorCodes::ABORTED` exception. Previously, this would fail the select query. Now we catch the `ErrorCodes::ABORTED` exceptions and intentionally ignore them instead. [#83435](https://github.com/ClickHouse/ClickHouse/pull/83435) ([Miсhael Stetsyuk](https://github.com/mstetsyuk)). +* Add process resource metrics (such as `UserTimeMicroseconds`, `SystemTimeMicroseconds`, `RealTimeMicroseconds`) to part_log profile events for `MergeParts` entries. [#83460](https://github.com/ClickHouse/ClickHouse/pull/83460) ([Vladimir Cherkasov](https://github.com/vdimir)). +* Enable `create_if_not_exists`, `check_not_exists`, `remove_recursive` feature flags in Keeper by default which enable new types of requests. [#83488](https://github.com/ClickHouse/ClickHouse/pull/83488) ([Antonio Andelic](https://github.com/antonio2368)). +* Shutdown S3(Azure/etc)Queue streaming before shutting down any tables on server shutdown. [#83530](https://github.com/ClickHouse/ClickHouse/pull/83530) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Enable `Date`/`Date32` as integers in `JSON` input formats. [#83597](https://github.com/ClickHouse/ClickHouse/pull/83597) ([MikhailBurdukov](https://github.com/MikhailBurdukov)). +* Made exception messages for certain situations for loading and adding projections easier to read. [#83728](https://github.com/ClickHouse/ClickHouse/pull/83728) ([Robert Schulze](https://github.com/rschu1ze)). +* Introduce a configuration option to skip binary checksum integrity checks for `clickhouse-server`. Resolves [#83637](https://github.com/ClickHouse/ClickHouse/issues/83637). [#83749](https://github.com/ClickHouse/ClickHouse/pull/83749) ([Rafael Roquetto](https://github.com/rafaelroquetto)). + +#### Bug Fix (user-visible misbehavior in an official stable release) +* Fix the wrong default value for the `--reconnect` option in `clickhouse-benchmark`. It was changed by mistake in [#79465](https://github.com/ClickHouse/ClickHouse/issues/79465). [#82677](https://github.com/ClickHouse/ClickHouse/pull/82677) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Fix inconsistent formatting of `CREATE DICTIONARY`. Closes [#82105](https://github.com/ClickHouse/ClickHouse/issues/82105). [#82829](https://github.com/ClickHouse/ClickHouse/pull/82829) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Fix inconsistent formatting of TTL when it contains a `materialize` function. Closes [#82828](https://github.com/ClickHouse/ClickHouse/issues/82828). [#82831](https://github.com/ClickHouse/ClickHouse/pull/82831) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Fix inconsistent formatting of EXPLAIN AST in a subquery when it contains output options such as INTO OUTFILE. Closes [#82826](https://github.com/ClickHouse/ClickHouse/issues/82826). [#82840](https://github.com/ClickHouse/ClickHouse/pull/82840) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Fix inconsistent formatting of parenthesized expressions with aliases in the context when no aliases are allowed. Closes [#82836](https://github.com/ClickHouse/ClickHouse/issues/82836). Closes [#82837](https://github.com/ClickHouse/ClickHouse/issues/82837). [#82867](https://github.com/ClickHouse/ClickHouse/pull/82867) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Use the proper error code when multiplying an aggregate function state with IPv4. Closes [#82817](https://github.com/ClickHouse/ClickHouse/issues/82817). [#82818](https://github.com/ClickHouse/ClickHouse/pull/82818) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Fix logical error in filesystem cache: "Having zero bytes but range is not finished". [#81868](https://github.com/ClickHouse/ClickHouse/pull/81868) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Recalculate the min-max index when TTL reduces rows to ensure the correctness of algorithms relying on it, such as `minmax_count_projection`. This resolves [#77091](https://github.com/ClickHouse/ClickHouse/issues/77091). [#77166](https://github.com/ClickHouse/ClickHouse/pull/77166) ([Amos Bird](https://github.com/amosbird)). +* For queries with combination of `ORDER BY ... LIMIT BY ... LIMIT N`, when ORDER BY is executed as a PartialSorting, the counter `rows_before_limit_at_least` now reflects the number of rows consumed by LIMIT clause instead of number of rows consumed by sorting transform. [#78999](https://github.com/ClickHouse/ClickHouse/pull/78999) ([Eduard Karacharov](https://github.com/korowa)). +* Fix excessive granule skipping for filtering over token/ngram indexes with regexp which contains alternation and non-literal first alternative. [#79373](https://github.com/ClickHouse/ClickHouse/pull/79373) ([Eduard Karacharov](https://github.com/korowa)). +* Fix logical error with `<=>` operator and Join storage, now query returns proper error code. [#80165](https://github.com/ClickHouse/ClickHouse/pull/80165) ([Vladimir Cherkasov](https://github.com/vdimir)). +* Fix a crash in the `loop` function when used with the `remote` function family. Ensure the LIMIT clause is respected in `loop(remote(...))`. [#80299](https://github.com/ClickHouse/ClickHouse/pull/80299) ([Julia Kartseva](https://github.com/jkartseva)). +* Fix incorrect behavior of `to_utc_timestamp` and `from_utc_timestamp` functions when handling dates before Unix epoch (1970-01-01) and after maximum date (2106-02-07 06:28:15). Now these functions properly clamp values to epoch start and maximum date respectively. [#80498](https://github.com/ClickHouse/ClickHouse/pull/80498) ([Surya Kant Ranjan](https://github.com/iit2009046)). +* For some queries executed with parallel replicas, reading in order optimization(s) could be applied on initiator while can't be applied on remote nodes. It leads to different reading modes used by parallel replicas coordinator (on initiator) and on remoted nodes, which is a logical error. [#80652](https://github.com/ClickHouse/ClickHouse/pull/80652) ([Igor Nikonov](https://github.com/devcrafter)). +* Fix logical error during materialize projection when column type was changed to Nullable. [#80741](https://github.com/ClickHouse/ClickHouse/pull/80741) ([Pavel Kruglov](https://github.com/Avogar)). +* Fix incorrect TTL recalculation in TTL GROUP BY when updating TTL. [#81222](https://github.com/ClickHouse/ClickHouse/pull/81222) ([Evgeniy Ulasik](https://github.com/H0uston)). +* Fixed Parquet bloom filter incorrectly applying condition like `WHERE function(key) IN (...)` as if it were `WHERE key IN (...)`. [#81255](https://github.com/ClickHouse/ClickHouse/pull/81255) ([Michael Kolupaev](https://github.com/al13n321)). +* Fixed possible crash in `Aggregator` in case of exception during merge. [#81450](https://github.com/ClickHouse/ClickHouse/pull/81450) ([Nikita Taranov](https://github.com/nickitat)). +* Fixed `InterpreterInsertQuery::extendQueryLogElemImpl` to add backquotes to database and table names when needed (f.g., when names contain special characters like `-`). [#81528](https://github.com/ClickHouse/ClickHouse/pull/81528) ([Ilia Shvyrialkin](https://github.com/Harzu)). +* Fix `IN` execution with `transform_null_in=1` with null in the left argument and non-nullable subquery result. [#81584](https://github.com/ClickHouse/ClickHouse/pull/81584) ([Pavel Kruglov](https://github.com/Avogar)). +* Don't validate experimental/suspicious types in default/materialize expression execution during reading from existing table. [#81618](https://github.com/ClickHouse/ClickHouse/pull/81618) ([Pavel Kruglov](https://github.com/Avogar)). +* Fix "Context has expired" during merges when dict used in TTL expression. [#81690](https://github.com/ClickHouse/ClickHouse/pull/81690) ([Azat Khuzhin](https://github.com/azat)). +* Fix monotonicity of the cast function. [#81722](https://github.com/ClickHouse/ClickHouse/pull/81722) ([zoomxi](https://github.com/zoomxi)). +* Fix the issue where required columns are not read during scalar correlated subquery processing. Fixes [#81716](https://github.com/ClickHouse/ClickHouse/issues/81716). [#81805](https://github.com/ClickHouse/ClickHouse/pull/81805) ([Dmitry Novik](https://github.com/novikd)). +* In previous versions, the server returned excessive content for requests to `/js`. This closes [#61890](https://github.com/ClickHouse/ClickHouse/issues/61890). [#81895](https://github.com/ClickHouse/ClickHouse/pull/81895) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Previously, `MongoDB` table engine definitions could include a path component in the `host:port` argument which was silently ignored. The mongodb integration refuses to load such tables. With this fix *we allow loading such tables and ignore path component* if `MongoDB` engine has five arguments, using the database name from arguments. *Note:* The fix is not applied for newly created tables or queries with `mongo` table function, as well as for dictionary sources and named collections. [#81942](https://github.com/ClickHouse/ClickHouse/pull/81942) ([Vladimir Cherkasov](https://github.com/vdimir)). +* Fixed possible crash in `Aggregator` in case of exception during merge. [#82022](https://github.com/ClickHouse/ClickHouse/pull/82022) ([Nikita Taranov](https://github.com/nickitat)). +* Fix filter analysis when only a constant alias column is used in the query. Fixes [#79448](https://github.com/ClickHouse/ClickHouse/issues/79448). [#82037](https://github.com/ClickHouse/ClickHouse/pull/82037) ([Dmitry Novik](https://github.com/novikd)). +* Fix LOGICAL_ERROR and following crash when using the same column in the TTL for GROUP BY and SET. [#82054](https://github.com/ClickHouse/ClickHouse/pull/82054) ([Pablo Marcos](https://github.com/pamarcos)). +* Fix S3 table function argument validation in secret masking, preventing possible `LOGICAL_ERROR`, close [#80620](https://github.com/ClickHouse/ClickHouse/issues/80620). [#82056](https://github.com/ClickHouse/ClickHouse/pull/82056) ([Vladimir Cherkasov](https://github.com/vdimir)). +* Fix data races in Iceberg. [#82088](https://github.com/ClickHouse/ClickHouse/pull/82088) ([Azat Khuzhin](https://github.com/azat)). +* Fix `DatabaseReplicated::getClusterImpl`. If the first element (or elements) of `hosts` has `id == DROPPED_MARK` and there are no other elements for the same shard, the first element of `shards` will be an empty vector, leading to `std::out_of_range`. [#82093](https://github.com/ClickHouse/ClickHouse/pull/82093) ([Miсhael Stetsyuk](https://github.com/mstetsyuk)). +* Fixing copy-paste error in arraySimilarity, disallowing the use of UInt32 and Int32 weights. Update tests and docs. [#82103](https://github.com/ClickHouse/ClickHouse/pull/82103) ([Mikhail f. Shiryaev](https://github.com/Felixoid)). +* Fix the `Not found column` error for queries with `arrayJoin` under `WHERE` condition and `IndexSet`. [#82113](https://github.com/ClickHouse/ClickHouse/pull/82113) ([Nikolai Kochetov](https://github.com/KochetovNicolai)). +* Fix bug in glue catalog integration. Now clickhouse can read tables with nested data types where some of subcolumns contain decimals, for example: `map`. Fixes [#81301](https://github.com/ClickHouse/ClickHouse/issues/81301). [#82114](https://github.com/ClickHouse/ClickHouse/pull/82114) ([alesapin](https://github.com/alesapin)). +* Fix performance degradation in SummingMergeTree that was intorduced in 25.5 in https://github.com/ClickHouse/ClickHouse/pull/79051. [#82130](https://github.com/ClickHouse/ClickHouse/pull/82130) ([Pavel Kruglov](https://github.com/Avogar)). +* When passing settings over uri the last value is considered. [#82137](https://github.com/ClickHouse/ClickHouse/pull/82137) ([Sema Checherinda](https://github.com/CheSema)). +* Fix "Context has expired" for Iceberg. [#82146](https://github.com/ClickHouse/ClickHouse/pull/82146) ([Azat Khuzhin](https://github.com/azat)). +* Fix possible deadlock for remote queries when server is under memory pressure. [#82160](https://github.com/ClickHouse/ClickHouse/pull/82160) ([Kirill](https://github.com/kirillgarbar)). +* Fixes overflow in `numericIndexedVectorPointwiseAdd`, `numericIndexedVectorPointwiseSubtract`, `numericIndexedVectorPointwiseMultiply`, `numericIndexedVectorPointwiseDivide` functions that happened when we applied them to large numbers. [#82165](https://github.com/ClickHouse/ClickHouse/pull/82165) ([Raufs Dunamalijevs](https://github.com/rienath)). +* Fix a bug in table dependencies causing Materialized Views to miss INSERT queries. [#82222](https://github.com/ClickHouse/ClickHouse/pull/82222) ([Nikolay Degterinsky](https://github.com/evillique)). +* Fix possible data-race between suggestion thread and main client thread. [#82233](https://github.com/ClickHouse/ClickHouse/pull/82233) ([Azat Khuzhin](https://github.com/azat)). +* Now ClickHouse can read iceberg tables from Glue catalog after schema evolution. Fixes [#81272](https://github.com/ClickHouse/ClickHouse/issues/81272). [#82301](https://github.com/ClickHouse/ClickHouse/pull/82301) ([alesapin](https://github.com/alesapin)). +* Fix the validation of async metrics settings `asynchronous_metrics_update_period_s` and `asynchronous_heavy_metrics_update_period_s`. [#82310](https://github.com/ClickHouse/ClickHouse/pull/82310) ([Bharat Nallan](https://github.com/bharatnc)). +* Fix logical error when resolving matcher in query with multiple JOINs, close [#81969](https://github.com/ClickHouse/ClickHouse/issues/81969). [#82421](https://github.com/ClickHouse/ClickHouse/pull/82421) ([Vladimir Cherkasov](https://github.com/vdimir)). +* Add expiration to AWS ECS token so it can be reloaded. [#82422](https://github.com/ClickHouse/ClickHouse/pull/82422) ([Konstantin Bogdanov](https://github.com/thevar1able)). +* Fixes a bug for `NULL` arguments in `CASE` function. [#82436](https://github.com/ClickHouse/ClickHouse/pull/82436) ([Yarik Briukhovetskyi](https://github.com/yariks5s)). +* Fix data-races in client (by not using global context) and `session_timezone` overrides (previously in case of `session_timezone` was set in i.e. `users.xml`/client options to non empty and in query context to empty, then, value from `users.xml` was used, while this is wrong, now query context will always have a priority over global context). [#82444](https://github.com/ClickHouse/ClickHouse/pull/82444) ([Azat Khuzhin](https://github.com/azat)). +* Fix disabling boundary alignment for cached buffer in external table engines. It was broken in https://github.com/ClickHouse/ClickHouse/pull/81868. [#82493](https://github.com/ClickHouse/ClickHouse/pull/82493) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Fix the crash if key-value storage is joined with a type-casted key. [#82497](https://github.com/ClickHouse/ClickHouse/pull/82497) ([Pervakov Grigorii](https://github.com/GrigoryPervakov)). +* Fix hiding named collection values in logs/query_log. Closes [#82405](https://github.com/ClickHouse/ClickHouse/issues/82405). [#82510](https://github.com/ClickHouse/ClickHouse/pull/82510) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Fix a possible crash in logging while terminating a session as the user_id might sometimes be empty. [#82513](https://github.com/ClickHouse/ClickHouse/pull/82513) ([Bharat Nallan](https://github.com/bharatnc)). +* Fixes cases where parsing of Time could cause msan issues. This fixes: [#82477](https://github.com/ClickHouse/ClickHouse/issues/82477). [#82514](https://github.com/ClickHouse/ClickHouse/pull/82514) ([Yarik Briukhovetskyi](https://github.com/yariks5s)). +* Disallow setting `threadpool_writer_pool_size` to zero to ensure that server operations don't get stuck. [#82532](https://github.com/ClickHouse/ClickHouse/pull/82532) ([Bharat Nallan](https://github.com/bharatnc)). +* Fix `LOGICAL_ERROR` during row policy expression analysis for correlated columns. [#82618](https://github.com/ClickHouse/ClickHouse/pull/82618) ([Dmitry Novik](https://github.com/novikd)). +* Fix incorrect usage of parent metadata in `mergeTreeProjection` table function when `enable_shared_storage_snapshot_in_query = 1`. This is for [#82634](https://github.com/ClickHouse/ClickHouse/issues/82634). [#82638](https://github.com/ClickHouse/ClickHouse/pull/82638) ([Amos Bird](https://github.com/amosbird)). +* Functions `trim{Left,Right,Both}` now support input strings of type "FixedString(N)". For example, `SELECT trimBoth(toFixedString('abc', 3), 'ac')` now works. [#82691](https://github.com/ClickHouse/ClickHouse/pull/82691) ([Robert Schulze](https://github.com/rschu1ze)). +* In AzureBlobStorage, for native copy we compare authentication methods, during which if we get an exception, updated the code to fallback to read and copy (i.e. non native copy). [#82693](https://github.com/ClickHouse/ClickHouse/pull/82693) ([Smita Kulkarni](https://github.com/SmitaRKulkarni)). +* Fix deserialization of `groupArraySample`/`groupArrayLast` in case of empty elements (deserialization could skip part of the binary if the input was empty, this can lead to corruption during data read and UNKNOWN_PACKET_FROM_SERVER in TCP protocol). This does not affect numbers and date time types. [#82763](https://github.com/ClickHouse/ClickHouse/pull/82763) ([Pedro Ferreira](https://github.com/PedroTadim)). +* Fix backup of an empty `Memory` table, causing the backup restore to fail with with `BACKUP_ENTRY_NOT_FOUND` error. [#82791](https://github.com/ClickHouse/ClickHouse/pull/82791) ([Julia Kartseva](https://github.com/jkartseva)). +* Fix exception safety in union/intersect/except_default_mode rewrite. Closes [#82664](https://github.com/ClickHouse/ClickHouse/issues/82664). [#82820](https://github.com/ClickHouse/ClickHouse/pull/82820) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Keep track of the number of async tables loading jobs. If there are some running jobs, do not update `tail_ptr` in `TransactionLog::removeOldEntries`. [#82824](https://github.com/ClickHouse/ClickHouse/pull/82824) ([Tuan Pham Anh](https://github.com/tuanpach)). +* Fix data races in Iceberg. [#82841](https://github.com/ClickHouse/ClickHouse/pull/82841) ([Azat Khuzhin](https://github.com/azat)). +* Setting `use_skip_indexes_if_final_exact_mode` optimization (introduced in 25.6) could fail to select a relevant candidate range depending upon `MergeTree` engine settings / data distribution. That has been resolved now. [#82879](https://github.com/ClickHouse/ClickHouse/pull/82879) ([Shankar Iyer](https://github.com/shankar-iyer)). +* Set salt for auth data when parsing from AST with type SCRAM_SHA256_PASSWORD. [#82888](https://github.com/ClickHouse/ClickHouse/pull/82888) ([Tuan Pham Anh](https://github.com/tuanpach)). +* When using a non-caching Database implementation, the metadata of the corresponding table is deleted after the columns are returned and the reference is invalidated. [#82939](https://github.com/ClickHouse/ClickHouse/pull/82939) ([buyval01](https://github.com/buyval01)). +* Fix filter modification for queries with a JOIN expression with a table with storage `Merge`. Fixes [#82092](https://github.com/ClickHouse/ClickHouse/issues/82092). [#82950](https://github.com/ClickHouse/ClickHouse/pull/82950) ([Dmitry Novik](https://github.com/novikd)). +* Fix LOGICAL_ERROR in QueryMetricLog: Mutex cannot be NULL. [#82979](https://github.com/ClickHouse/ClickHouse/pull/82979) ([Pablo Marcos](https://github.com/pamarcos)). +* Fixed incorrect output of function `formatDateTime` when formatter `%f` is used together with variable-size formatters (e.g. `%M`). [#83020](https://github.com/ClickHouse/ClickHouse/pull/83020) ([Robert Schulze](https://github.com/rschu1ze)). +* Fix performance degradation with the enabled analyzer when secondary queries always read all columns from the VIEWs. Fixes [#81718](https://github.com/ClickHouse/ClickHouse/issues/81718). [#83036](https://github.com/ClickHouse/ClickHouse/pull/83036) ([Dmitry Novik](https://github.com/novikd)). +* Fix misleading error message when restoring a backup on a read-only disk. [#83051](https://github.com/ClickHouse/ClickHouse/pull/83051) ([Julia Kartseva](https://github.com/jkartseva)). +* Do not check for cyclic dependencies on create table with no dependencies. It fixes performance degradation of the use cases with creation of thousands of tables that was introduced in https://github.com/ClickHouse/ClickHouse/pull/65405. [#83077](https://github.com/ClickHouse/ClickHouse/pull/83077) ([Pavel Kruglov](https://github.com/Avogar)). +* Fixes issue with implicit reading of negative Time values into the table and make the docs not confusing. [#83091](https://github.com/ClickHouse/ClickHouse/pull/83091) ([Yarik Briukhovetskyi](https://github.com/yariks5s)). +* Do not use unrelated parts of a shared dictionary in the `lowCardinalityKeys` function. [#83118](https://github.com/ClickHouse/ClickHouse/pull/83118) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Fix the regression in use of subcolumns with Materialized Views. This fixes: [#82784](https://github.com/ClickHouse/ClickHouse/issues/82784). [#83221](https://github.com/ClickHouse/ClickHouse/pull/83221) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)). +* Fix crash in client due to connection left in disconnected state after bad INSERT. [#83253](https://github.com/ClickHouse/ClickHouse/pull/83253) ([Azat Khuzhin](https://github.com/azat)). +* Fix crash when calculating the size of a block with empty columns. [#83271](https://github.com/ClickHouse/ClickHouse/pull/83271) ([Raúl Marín](https://github.com/Algunenano)). +* Fix possible crash in Variant type in UNION. [#83295](https://github.com/ClickHouse/ClickHouse/pull/83295) ([Pavel Kruglov](https://github.com/Avogar)). +* Fix LOGICAL_ERROR in clickhouse-local for unsupported SYSTEM queries. [#83333](https://github.com/ClickHouse/ClickHouse/pull/83333) ([Surya Kant Ranjan](https://github.com/iit2009046)). +* Fix `no_sign_request` for S3 client. It can be used to explicitly avoid signing S3 requests. It can also be defined for specific endpoints using endpoint-based settings. [#83379](https://github.com/ClickHouse/ClickHouse/pull/83379) ([Antonio Andelic](https://github.com/antonio2368)). +* Fixes a crash that may happen for a query with a setting 'max_threads=1' when executed under load with CPU scheduling enabled. [#83387](https://github.com/ClickHouse/ClickHouse/pull/83387) ([Fan Ziqi](https://github.com/f2quantum)). +* Fix `TOO_DEEP_SUBQUERIES` exception when CTE definition references another table expression with the same name. [#83413](https://github.com/ClickHouse/ClickHouse/pull/83413) ([Dmitry Novik](https://github.com/novikd)). +* Fix incorrect behavior when executing `REVOKE S3 ON system.*` revokes S3 permissions for `*.*`. This fixes [#83417](https://github.com/ClickHouse/ClickHouse/issues/83417). [#83420](https://github.com/ClickHouse/ClickHouse/pull/83420) ([pufit](https://github.com/pufit)). +* Do not share async_read_counters between queries. [#83423](https://github.com/ClickHouse/ClickHouse/pull/83423) ([Azat Khuzhin](https://github.com/azat)). +* Disable parallel replicas when a subquery contains the FINAL. [#83455](https://github.com/ClickHouse/ClickHouse/pull/83455) ([zoomxi](https://github.com/zoomxi)). +* Resolve minor integer overflow in configuration of setting `role_cache_expiration_time_seconds` (issue [#83374](https://github.com/ClickHouse/ClickHouse/issues/83374)). [#83461](https://github.com/ClickHouse/ClickHouse/pull/83461) ([wushap](https://github.com/wushap)). +* Fix a bug introduced in https://github.com/ClickHouse/ClickHouse/pull/79963. When inserting into an MV with a definer, the permission check should use the definer's grants. This fixes [#79951](https://github.com/ClickHouse/ClickHouse/issues/79951). [#83502](https://github.com/ClickHouse/ClickHouse/pull/83502) ([pufit](https://github.com/pufit)). +* Disable bounds-based file pruning for iceberg array element and iceberg map values, including all their nested subfields. [#83520](https://github.com/ClickHouse/ClickHouse/pull/83520) ([Daniil Ivanik](https://github.com/divanik)). +* Fix possible file cache not initialized errors when it's used as a temporary data storage. [#83539](https://github.com/ClickHouse/ClickHouse/pull/83539) ([Bharat Nallan](https://github.com/bharatnc)). +* Keeper fix: update total watch count correctly when ephemeral nodes are deleted on session close. [#83583](https://github.com/ClickHouse/ClickHouse/pull/83583) ([Antonio Andelic](https://github.com/antonio2368)). +* Fix incorrect memory around max_untracked_memory. [#83607](https://github.com/ClickHouse/ClickHouse/pull/83607) ([Azat Khuzhin](https://github.com/azat)). +* INSERT SELECT with UNION ALL could lead to a null pointer dereference in a corner case. This closes [#83618](https://github.com/ClickHouse/ClickHouse/issues/83618). [#83643](https://github.com/ClickHouse/ClickHouse/pull/83643) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Disallow zero value for max_insert_block_size as it could cause logical error. [#83688](https://github.com/ClickHouse/ClickHouse/pull/83688) ([Bharat Nallan](https://github.com/bharatnc)). +* Fix endless loop in estimateCompressionRatio() with block_size_bytes=0. [#83704](https://github.com/ClickHouse/ClickHouse/pull/83704) ([Azat Khuzhin](https://github.com/azat)). +* Fix `IndexUncompressedCacheBytes`/`IndexUncompressedCacheCells`/`IndexMarkCacheBytes`/`IndexMarkCacheFiles` metrics (previously they were included into metric w/o `Cache` prefix). [#83730](https://github.com/ClickHouse/ClickHouse/pull/83730) ([Azat Khuzhin](https://github.com/azat)). +* Fix possible abort (due to joining threads from the task) and hopefully hungs (in unit tests) during `BackgroundSchedulePool` shutdown. [#83769](https://github.com/ClickHouse/ClickHouse/pull/83769) ([Azat Khuzhin](https://github.com/azat)). +* Introduce backward compatibility setting to allow new analyzer to reference outer alias in WITH clause in the case of name clashes. Fixes [#82700](https://github.com/ClickHouse/ClickHouse/issues/82700). [#83797](https://github.com/ClickHouse/ClickHouse/pull/83797) ([Dmitry Novik](https://github.com/novikd)). +* Fix deadlock on shutdown due to recursive context locking during library bridge cleanup. [#83824](https://github.com/ClickHouse/ClickHouse/pull/83824) ([Azat Khuzhin](https://github.com/azat)). + +#### Build/Testing/Packaging Improvement +* Build a minimal C library (10 KB) for the ClickHouse lexer. This is needed for [#80977](https://github.com/ClickHouse/ClickHouse/issues/80977). [#81347](https://github.com/ClickHouse/ClickHouse/pull/81347) ([Alexey Milovidov](https://github.com/alexey-milovidov)). Add test for standalone lexer, add test tag `fasttest-only`. [#82472](https://github.com/ClickHouse/ClickHouse/pull/82472) ([Yakov Olkhovskiy](https://github.com/yakov-olkhovskiy)). +* Add a check for Nix submodule inputs. [#81691](https://github.com/ClickHouse/ClickHouse/pull/81691) ([Konstantin Bogdanov](https://github.com/thevar1able)). +* Fix a list of problems that can occur when trying to run integration tests on a localhost. [#82135](https://github.com/ClickHouse/ClickHouse/pull/82135) ([Oleg Doronin](https://github.com/dorooleg)). +* Compile SymbolIndex on Mac and FreeBSD. (But it will work only on ELF systems, Linux and FreeBSD). [#82347](https://github.com/ClickHouse/ClickHouse/pull/82347) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Bumped Azure SDK to v1.15.0. [#82747](https://github.com/ClickHouse/ClickHouse/pull/82747) ([Smita Kulkarni](https://github.com/SmitaRKulkarni)). +* Add storage module from google-cloud-cpp to build system. [#82881](https://github.com/ClickHouse/ClickHouse/pull/82881) ([Pablo Marcos](https://github.com/pamarcos)). +* Change `Dockerfile.ubuntu` for clickhouse-server to fit requirements in Docker Official Library. [#83039](https://github.com/ClickHouse/ClickHouse/pull/83039) ([Mikhail f. Shiryaev](https://github.com/Felixoid)). +* A follow-up for [#83158](https://github.com/ClickHouse/ClickHouse/issues/83158) to fix uploading builds to `curl clickhouse.com`. [#83463](https://github.com/ClickHouse/ClickHouse/pull/83463) ([Mikhail f. Shiryaev](https://github.com/Felixoid)). +* Adding `busybox` binary and install tools in `clickhouse/clickhouse-server` and official `clickhouse` images. [#83735](https://github.com/ClickHouse/ClickHouse/pull/83735) ([Mikhail f. Shiryaev](https://github.com/Felixoid)). +* Added support for the `CLICKHOUSE_HOST` environment variable to specify the ClickHouse server host, aligning with existing `CLICKHOUSE_USER` and `CLICKHOUSE_PASSWORD` environment variables. This allows for easier configuration without modifying client or configuration files directly. [#83659](https://github.com/ClickHouse/ClickHouse/pull/83659) ([Doron David](https://github.com/dorki)). + + +### ClickHouse release 25.6, 2025-06-26 {#256} + +#### Backward Incompatible Change +* Previously, function `countMatches` would stop counting at the first empty match even if the pattern accepts it. To overcome this issue, `countMatches` now continues execution by advancing by a single character when an empty match occurs. Users who like to retain the old behavior can enable setting `count_matches_stop_at_empty_match`. [#81676](https://github.com/ClickHouse/ClickHouse/pull/81676) ([Elmi Ahmadov](https://github.com/ahmadov)). +* Minor: Force `backup_threads` and `restore_threads` server settings to be non zero. [#80224](https://github.com/ClickHouse/ClickHouse/pull/80224) ([Raúl Marín](https://github.com/Algunenano)). +* Minor: Fix `bitNot` for `String` will return a zero-terminated string in the internal memory representation. This should not affect any user visible behavior, however the author wanted to highlight this change. [#80791](https://github.com/ClickHouse/ClickHouse/pull/80791) ([Azat Khuzhin](https://github.com/azat)). + +#### New Feature +* New data types: `Time` (\[H\]HH:MM:SS) and `Time64` (\[H\]HH:MM:SS\[.fractional\]), and some basic cast functions and functions to interact with other data types. Added settings for compatibility with the existing function `toTime`. The setting `use_legacy_to_time` is set to keep the old behavior for now. [#81217](https://github.com/ClickHouse/ClickHouse/pull/81217) ([Yarik Briukhovetskyi](https://github.com/yariks5s)). Support comparison between Time/Time64. [#80327](https://github.com/ClickHouse/ClickHouse/pull/80327) ([Yarik Briukhovetskyi](https://github.com/yariks5s)). +* A new CLI tool, [`chdig`](https://github.com/azat/chdig/) - TUI interface for ClickHouse (top like) as part of ClickHouse. [#79666](https://github.com/ClickHouse/ClickHouse/pull/79666) ([Azat Khuzhin](https://github.com/azat)). +* Support `disk` setting for `Atomic` and `Ordinary` database engines, specifying the disk to store table metadata files. [#80546](https://github.com/ClickHouse/ClickHouse/pull/80546) ([Tuan Pham Anh](https://github.com/tuanpach)). This allows attaching databases from external sources. +* A new type of MergeTree, `CoalescingMergeTree` - the engine takes the first non-Null value during background merges. This closes [#78869](https://github.com/ClickHouse/ClickHouse/issues/78869). [#79344](https://github.com/ClickHouse/ClickHouse/pull/79344) ([scanhex12](https://github.com/scanhex12)). +* Support functions to read WKB ("Well-Known Binary" is a format for binary encoding of various geometry types, used in GIS applications). See [#43941](https://github.com/ClickHouse/ClickHouse/issues/43941). [#80139](https://github.com/ClickHouse/ClickHouse/pull/80139) ([scanhex12](https://github.com/scanhex12)). +* Added query slot scheduling for workloads, see [workload scheduling](https://clickhouse.com/docs/operations/workload-scheduling#query_scheduling) for details. [#78415](https://github.com/ClickHouse/ClickHouse/pull/78415) ([Sergei Trifonov](https://github.com/serxa)). +* `timeSeries*` helper functions to speedup some scenarios when working with time series data: - re-sample the data to the time grid with specified start timestamp, end timestamp and step - calculate PromQL-like `delta`, `rate`, `idelta` and `irate`. [#80590](https://github.com/ClickHouse/ClickHouse/pull/80590) ([Alexander Gololobov](https://github.com/davenger)). +* Add `mapContainsValuesLike`/`mapContainsValues`/`mapExtractValuesLike` functions to filter on map values and their support in bloom filter based indexes. [#78171](https://github.com/ClickHouse/ClickHouse/pull/78171) ([UnamedRus](https://github.com/UnamedRus)). +* Now settings constraints can specify a set of disallowed values. [#78499](https://github.com/ClickHouse/ClickHouse/pull/78499) ([Bharat Nallan](https://github.com/bharatnc)). +* Added a setting `enable_shared_storage_snapshot_in_query` to enable sharing the same storage snapshot across all subqueries in a single query. This ensures consistent reads from the same table, even when the table is referenced multiple times within a query. [#79471](https://github.com/ClickHouse/ClickHouse/pull/79471) ([Amos Bird](https://github.com/amosbird)). +* Support writing `JSON` columns to `Parquet` and reading `JSON` columns from `Parquet` directly. [#79649](https://github.com/ClickHouse/ClickHouse/pull/79649) ([Nihal Z. Miaji](https://github.com/nihalzp)). +* Add `MultiPolygon` support for `pointInPolygon`. [#79773](https://github.com/ClickHouse/ClickHouse/pull/79773) ([Nihal Z. Miaji](https://github.com/nihalzp)). +* Add support for querying local filesystem-mounted Delta tables via `deltaLakeLocal` table function. [#79781](https://github.com/ClickHouse/ClickHouse/pull/79781) ([roykim98](https://github.com/roykim98)). +* Add new setting `cast_string_to_date_time_mode` that allows to choose DateTime parsing mode during cast from String. [#80210](https://github.com/ClickHouse/ClickHouse/pull/80210) ([Pavel Kruglov](https://github.com/Avogar)). For example, you can set it to the best effort mode. +* Added `bech32Encode` and `bech32Decode` functions for working with Bitcoin's Bech algorithm (issue [#40381](https://github.com/ClickHouse/ClickHouse/issues/40381)). [#80239](https://github.com/ClickHouse/ClickHouse/pull/80239) ([George Larionov](https://github.com/glarik)). +* Add SQL functions to analyse the names of MergeTree parts. [#80573](https://github.com/ClickHouse/ClickHouse/pull/80573) ([Mikhail Artemenko](https://github.com/Michicosun)). +* Allow filtering parts selected for query by the disk they reside on by introducing a new virtual column, `_disk_name`. [#80650](https://github.com/ClickHouse/ClickHouse/pull/80650) ([tanner-bruce](https://github.com/tanner-bruce)). +* Add a landing page with the list of embedded web tools. It will open when requested by a browser-like user agent. [#81129](https://github.com/ClickHouse/ClickHouse/pull/81129) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Function `arrayFirst`, `arrayFirstIndex`, `arrayLast` and `arrayLastIndex` will filter away NULL values returned by the filter expression. In previous versions, Nullable filter results were not supported. Fixes [#81113](https://github.com/ClickHouse/ClickHouse/issues/81113). [#81197](https://github.com/ClickHouse/ClickHouse/pull/81197) ([Lennard Eijsackers](https://github.com/Blokje5)). +* It's now possible to write `USE DATABASE name` instead of `USE name`. [#81307](https://github.com/ClickHouse/ClickHouse/pull/81307) ([Yarik Briukhovetskyi](https://github.com/yariks5s)). +* Added a new system table `system.codecs` to introspect the available codecs. (issue [#81525](https://github.com/ClickHouse/ClickHouse/issues/81525)). [#81600](https://github.com/ClickHouse/ClickHouse/pull/81600) ([Jimmy Aguilar Mena](https://github.com/Ergus)). +* Support `lag` and `lead` window functions. Closes [#9887](https://github.com/ClickHouse/ClickHouse/issues/9887). [#82108](https://github.com/ClickHouse/ClickHouse/pull/82108) ([Dmitry Novik](https://github.com/novikd)). +* Function `tokens` now supports a new tokenizer, named `split`, which is good for logs. [#80195](https://github.com/ClickHouse/ClickHouse/pull/80195) ([Robert Schulze](https://github.com/rschu1ze)). +* Add support for the `--database` argument in `clickhouse-local`. You can switch to a previously created database. This closes [#44115](https://github.com/ClickHouse/ClickHouse/issues/44115). [#81465](https://github.com/ClickHouse/ClickHouse/pull/81465) ([Alexey Milovidov](https://github.com/alexey-milovidov)). + +#### Experimental Feature +* Implement Kafka rebalance like logic for `Kafka2` using ClickHouse Keeper For each replica we support two types of partition locks: permanent locks and temporary locks. The replica tries to hold permanent locks as long as possible, at any given time there are no more than `all_topic_partitions / active_replicas_count` (here `all_topic_partitions` is the number of all partitions, `active_replicas_count` is the number of active replicas) permanent locks on the replica, if there are more, then the replica releases some partitions. Some partitions are temporarily held by the replica. The maximum number of temporary locks on a replica changes dynamically to give other replicas a chance to take some partitions into permanent locks. When updating temporary locks, the replica releases them all and tries to take some others again. [#78726](https://github.com/ClickHouse/ClickHouse/pull/78726) ([Daria Fomina](https://github.com/sinfillo)). +* An improvement for the experimental text index: explicit parameters are supported via key-value pairs. Currently, supported parameters are a mandatory `tokenizer` and two optional `max_rows_per_postings_list` and `ngram_size`. [#80262](https://github.com/ClickHouse/ClickHouse/pull/80262) ([Elmi Ahmadov](https://github.com/ahmadov)). +* Previously, `packed` storage was not supported for the full-text index, because the segment id was updated on-fly by reading and writing (`.gin_sid`) file on disk. In case of packed storage, reading a value from the uncommited file is not supported and this led to an issue. Now it is alright. [#80852](https://github.com/ClickHouse/ClickHouse/pull/80852) ([Elmi Ahmadov](https://github.com/ahmadov)). +* Experimental indexes of type `gin` (which I don't like because it is an inside joke of PostgreSQL hackers) were renamed to `text`. Existing indexes of type `gin` remain loadable but they will throw an exception (suggesting `text` indexes instead) when one tries to use them in searches. [#80855](https://github.com/ClickHouse/ClickHouse/pull/80855) ([Robert Schulze](https://github.com/rschu1ze)). + +#### Performance Improvement +* Enable multiple-projection filtering support, allowing to use more than one projection for part-level filtering. This addresses [#55525](https://github.com/ClickHouse/ClickHouse/issues/55525). This is the second step to implement projection index, following [#78429](https://github.com/ClickHouse/ClickHouse/issues/78429). [#80343](https://github.com/ClickHouse/ClickHouse/pull/80343) ([Amos Bird](https://github.com/amosbird)). +* Use `SLRU` cache policy in filesystem cache by default. [#75072](https://github.com/ClickHouse/ClickHouse/pull/75072) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Remove contention in the Resize step in query pipeline. [#77562](https://github.com/ClickHouse/ClickHouse/pull/77562) ([Zhiguo Zhou](https://github.com/ZhiguoZh)). +* Introduced an option to offload (de)compression and (de)serialization of blocks into pipeline threads instead of a single thread associated with a network connection. Controlled by the setting `enable_parallel_blocks_marshalling`. It should speed up distributed queries that transfer significant amounts of data between the initiator and remote nodes. [#78694](https://github.com/ClickHouse/ClickHouse/pull/78694) ([Nikita Taranov](https://github.com/nickitat)). +* Performance improvements to all bloom filter types. [Video from the OpenHouse conference](https://www.youtube.com/watch?v=yIVz0NKwQvA&pp=ygUQb3BlbmhvdXNlIG9wZW5haQ%3D%3D) [#79800](https://github.com/ClickHouse/ClickHouse/pull/79800) ([Delyan Kratunov](https://github.com/dkratunov)). +* Introduced a happy path in `UniqExactSet::merge` when one of the sets is empty. Also, now if the LHS set is two-level and the RHS is single-level, we won't do the conversion to two-level for the RHS. [#79971](https://github.com/ClickHouse/ClickHouse/pull/79971) ([Nikita Taranov](https://github.com/nickitat)). +* Improve memory reuse efficiency and reduce page faults when using the two-level hash tables. This meant to speed-up GROUP BY. [#80245](https://github.com/ClickHouse/ClickHouse/pull/80245) ([Jiebin Sun](https://github.com/jiebinn)). +* Avoid unnecessary update and reduce lock contention in query condition cache. [#80247](https://github.com/ClickHouse/ClickHouse/pull/80247) ([Jiebin Sun](https://github.com/jiebinn)). +* Trivial optimization for `concatenateBlocks`. Chances are it's good for parallel hash join. [#80328](https://github.com/ClickHouse/ClickHouse/pull/80328) ([李扬](https://github.com/taiyang-li)). +* When selecting mark ranges from the primary key range, binary search cannot be used if the primary key is wrapped with functions. This PR improves this limitation: binary search can still be applied when the primary key is wrapped with an always monotonic function chain, or when the RPN contains an element that is always true. Closes [#45536](https://github.com/ClickHouse/ClickHouse/issues/45536). [#80597](https://github.com/ClickHouse/ClickHouse/pull/80597) ([zoomxi](https://github.com/zoomxi)). +* Improve shutdown speed of `Kafka` engine (remove extra 3 seconds delay in case of multiple `Kafka` tables). [#80796](https://github.com/ClickHouse/ClickHouse/pull/80796) ([Azat Khuzhin](https://github.com/azat)). +* Async inserts: reduce memory usage and improve performance of insert queries. [#80972](https://github.com/ClickHouse/ClickHouse/pull/80972) ([Raúl Marín](https://github.com/Algunenano)). +* Don't profile processors if the log table is disabled. [#81256](https://github.com/ClickHouse/ClickHouse/pull/81256) ([Raúl Marín](https://github.com/Algunenano)). This speeds up very short queries. +* Speed up `toFixedString` when the source is exactly what's requested. [#81257](https://github.com/ClickHouse/ClickHouse/pull/81257) ([Raúl Marín](https://github.com/Algunenano)). +* Don't process quota values if the user is not limited. [#81549](https://github.com/ClickHouse/ClickHouse/pull/81549) ([Raúl Marín](https://github.com/Algunenano)). This speeds up very short queries. +* Fixed performance regression in memory tracking. [#81694](https://github.com/ClickHouse/ClickHouse/pull/81694) ([Michael Kolupaev](https://github.com/al13n321)). +* Improve sharding key optimization on distributed query. [#78452](https://github.com/ClickHouse/ClickHouse/pull/78452) ([fhw12345](https://github.com/fhw12345)). +* Parallel replicas: avoid waiting for slow unused replicas if all read tasks have been assigned to other replicas. [#80199](https://github.com/ClickHouse/ClickHouse/pull/80199) ([Igor Nikonov](https://github.com/devcrafter)). +* Parallel replicas uses separate connection timeout, see `parallel_replicas_connect_timeout_ms` setting. Before `connect_timeout_with_failover_ms`/`connect_timeout_with_failover_secure_ms` settings were used as connection timeout values for parallel replicas queries (1 second by default). [#80421](https://github.com/ClickHouse/ClickHouse/pull/80421) ([Igor Nikonov](https://github.com/devcrafter)). +* In filesystem with journal `mkdir` is written to the journal of filesystem which is persisted to disk. In case of slow disk this can take long time. Move it out from reserve lock scope. [#81371](https://github.com/ClickHouse/ClickHouse/pull/81371) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Postpone reading of Iceberg manifest files until first reading query. [#81619](https://github.com/ClickHouse/ClickHouse/pull/81619) ([Daniil Ivanik](https://github.com/divanik)). +* Allow moving `GLOBAL [NOT] IN` predicate to `PREWHERE` clause if applicable. [#79996](https://github.com/ClickHouse/ClickHouse/pull/79996) ([Eduard Karacharov](https://github.com/korowa)). + +#### Improvement +* `EXPLAIN SYNTAX` now uses a new analyzer. It returns AST built from the query tree. Added option `query_tree_passes` to control the number of passes to executed before converting query tree to the AST. [#74536](https://github.com/ClickHouse/ClickHouse/pull/74536) ([Vladimir Cherkasov](https://github.com/vdimir)). +* Implement flattened serialization for Dynamic and JSON in Native format that allows to serialize/deserialize Dynamic and JSON data without special structures like shared variant for Dynamic and shared data for JSON. This serialization can be enabled by setting `output_format_native_use_flattened_dynamic_and_json_serialization`. This serialization can be used for easier support for Dynamic and JSON in TCP protocol in clients in different languages. [#80499](https://github.com/ClickHouse/ClickHouse/pull/80499) ([Pavel Kruglov](https://github.com/Avogar)). +* Refresh `S3` credentials after error `AuthenticationRequired`. [#77353](https://github.com/ClickHouse/ClickHouse/pull/77353) ([Vitaly Baranov](https://github.com/vitlibar)). +* Added dictionary metrics to `system.asynchronous_metrics` - `DictionaryMaxUpdateDelay` - the maximum delay (in seconds) of dictionary update. - `DictionaryTotalFailedUpdates` - the number of errors since last successful loading in all dictionaries. [#78175](https://github.com/ClickHouse/ClickHouse/pull/78175) ([Vlad](https://github.com/codeworse)). +* Add a warning about databases that were potentially created to save broken tables. [#78841](https://github.com/ClickHouse/ClickHouse/pull/78841) ([János Benjamin Antal](https://github.com/antaljanosbenjamin)). +* Add `_time` virtual column in `S3Queue`, `AzureQueue` engine. [#78926](https://github.com/ClickHouse/ClickHouse/pull/78926) ([Anton Ivashkin](https://github.com/ianton-ru)). +* Make settings controlling connection drop on overloaded CPU hot-reloadable. [#79052](https://github.com/ClickHouse/ClickHouse/pull/79052) ([Alexey Katsman](https://github.com/alexkats)). +* Add container prefix to data paths reported in system.tables for plain disks in Azure blob storage, making reporting consistent with S3 and GCP. [#79241](https://github.com/ClickHouse/ClickHouse/pull/79241) ([Julia Kartseva](https://github.com/jkartseva)). +* Now, clickhouse-client and local also accept query parameters as `param-` (dash) along with `param_` (underscore). This closes [#63093](https://github.com/ClickHouse/ClickHouse/issues/63093). [#79429](https://github.com/ClickHouse/ClickHouse/pull/79429) ([Engel Danila](https://github.com/aaaengel)). +* Detailed warning msg for bandwidth discount when copying data from local to remote S3 with checksum enabled. [#79464](https://github.com/ClickHouse/ClickHouse/pull/79464) ([VicoWu](https://github.com/VicoWu)). +* Previously, when `input_format_parquet_max_block_size = 0` (an invalid value) ClickHouse would stuck. Now this behaviour is fixed. This closes [#79394](https://github.com/ClickHouse/ClickHouse/issues/79394). [#79601](https://github.com/ClickHouse/ClickHouse/pull/79601) ([abashkeev](https://github.com/abashkeev)). +* Add `throw_on_error` setting for `startup_scripts`: when `throw_on_error` is true, the server will not start unless all queries complete successfully. By default, `throw_on_error` is false, preserving the previous behavior. [#79732](https://github.com/ClickHouse/ClickHouse/pull/79732) ([Aleksandr Musorin](https://github.com/AVMusorin)). +* Allow to add `http_response_headers` in `http_handlers` of any kind. [#79975](https://github.com/ClickHouse/ClickHouse/pull/79975) ([Andrey Zvonov](https://github.com/zvonand)). +* Function `reverse` now supports `Tuple` data type. Closes [#80053](https://github.com/ClickHouse/ClickHouse/issues/80053). [#80083](https://github.com/ClickHouse/ClickHouse/pull/80083) ([flynn](https://github.com/ucasfl)). +* Resolve [#75817](https://github.com/ClickHouse/ClickHouse/issues/75817): allow getting `auxiliary_zookeepers` data from `system.zookeeper` table. [#80146](https://github.com/ClickHouse/ClickHouse/pull/80146) ([Nikolay Govorov](https://github.com/mrdimidium)). +* Add asynchronous metrics about the server's TCP sockets. This improves the observability. Closes [#80187](https://github.com/ClickHouse/ClickHouse/issues/80187). [#80188](https://github.com/ClickHouse/ClickHouse/pull/80188) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Support `anyLast_respect_nulls` and `any_respect_nulls` as a `SimpleAggregateFunction`. [#80219](https://github.com/ClickHouse/ClickHouse/pull/80219) ([Diskein](https://github.com/Diskein)). +* Remove unnecessary call `adjustCreateQueryForBackup` for replicated databases. [#80282](https://github.com/ClickHouse/ClickHouse/pull/80282) ([Vitaly Baranov](https://github.com/vitlibar)). +* Allow extra options (that go after `--` like `-- --config.value='abc'`) in `clickhouse-local` without the equality sign. Closes [#80292](https://github.com/ClickHouse/ClickHouse/issues/80292). [#80293](https://github.com/ClickHouse/ClickHouse/pull/80293) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Highlight metacharacters in `SHOW ... LIKE` queries. This closes [#80275](https://github.com/ClickHouse/ClickHouse/issues/80275). [#80297](https://github.com/ClickHouse/ClickHouse/pull/80297) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Make SQL UDF persistent in `clickhouse-local`. The previously created function will be loaded at startup. This closes [#80085](https://github.com/ClickHouse/ClickHouse/issues/80085). [#80300](https://github.com/ClickHouse/ClickHouse/pull/80300) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Fix description in explain plan for preliminary DISTINCT step. [#80330](https://github.com/ClickHouse/ClickHouse/pull/80330) ([UnamedRus](https://github.com/UnamedRus)). +* Allow to use named collections in ODBC/JDBC. [#80334](https://github.com/ClickHouse/ClickHouse/pull/80334) ([Andrey Zvonov](https://github.com/zvonand)). +* Metrics for number of readonly and broken disks. Indicator logs when DiskLocalCheckThread is started. [#80391](https://github.com/ClickHouse/ClickHouse/pull/80391) ([VicoWu](https://github.com/VicoWu)). +* Implement support for `s3_plain_rewritable` storage with projections. In previous versions, metadata objects in S3 referencing projections would not get updated when moved. Closes [#70258](https://github.com/ClickHouse/ClickHouse/issues/70258). [#80393](https://github.com/ClickHouse/ClickHouse/pull/80393) ([Sav](https://github.com/sberss)). +* The `SYSTEM UNFREEZE` command will not try to look up parts in readonly and write-once disks. This closes [#80430](https://github.com/ClickHouse/ClickHouse/issues/80430). [#80432](https://github.com/ClickHouse/ClickHouse/pull/80432) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Lowered the log level of merged parts messages. [#80476](https://github.com/ClickHouse/ClickHouse/pull/80476) ([Hans Krutzer](https://github.com/hkrutzer)). +* Change the default behavior of partition pruning for Iceberg tables. [#80583](https://github.com/ClickHouse/ClickHouse/pull/80583) ([Melvyn Peignon](https://github.com/melvynator)). +* Add two new ProfileEvents for index search algorithm observability: `IndexBinarySearchAlgorithm` and `IndexGenericExclusionSearchAlgorithm`. [#80679](https://github.com/ClickHouse/ClickHouse/pull/80679) ([Pablo Marcos](https://github.com/pamarcos)). +* Do not complain about unsupported `MADV_POPULATE_WRITE` for older kernels in logs (to avoid logs polluting). [#80704](https://github.com/ClickHouse/ClickHouse/pull/80704) ([Robert Schulze](https://github.com/rschu1ze)). +* Added support for `Date32` and `DateTime64` in `TTL` expressions. [#80710](https://github.com/ClickHouse/ClickHouse/pull/80710) ([Andrey Zvonov](https://github.com/zvonand)). +* Adjust compatibility values for `max_merge_delayed_streams_for_parallel_write`. [#80760](https://github.com/ClickHouse/ClickHouse/pull/80760) ([Azat Khuzhin](https://github.com/azat)). +* Fix a crash: if an exception is thrown in an attempt to remove a temporary file (they are used for spilling temporary data on disk) in the destructor, the program can terminate. [#80776](https://github.com/ClickHouse/ClickHouse/pull/80776) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Add `IF EXISTS` modifier to `SYSTEM SYNC REPLICA`. [#80810](https://github.com/ClickHouse/ClickHouse/pull/80810) ([Raúl Marín](https://github.com/Algunenano)). +* Extend exception message about "Having zero bytes, but read range is not finished...", add finished_download_time column to `system.filesystem_cache`. [#80849](https://github.com/ClickHouse/ClickHouse/pull/80849) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Add search algorithm section to `EXPLAIN` output when using it with indexes = 1. If shows either "binary search" or "generic exclusion search". [#80881](https://github.com/ClickHouse/ClickHouse/pull/80881) ([Pablo Marcos](https://github.com/pamarcos)). +* At the beginning of 2024, `prefer_column_name_to_alias` was hardcoded to true for MySQL handler because the new analyzer was not enabled by default. Now, it can be unhardcoded. [#80916](https://github.com/ClickHouse/ClickHouse/pull/80916) ([Yarik Briukhovetskyi](https://github.com/yariks5s)). +* Now `system.iceberg_history` shows history for catalogs databases like glue or iceberg rest. Also renamed `table_name` and `database_name` columns to `table` and `database` in `system.iceberg_history` for consistency. [#80975](https://github.com/ClickHouse/ClickHouse/pull/80975) ([alesapin](https://github.com/alesapin)). +* Allow read-only mode for the `merge` table function, so the `CREATE TEMPORARY TABLE` grant is not required for using it. [#80981](https://github.com/ClickHouse/ClickHouse/pull/80981) ([Miсhael Stetsyuk](https://github.com/mstetsyuk)). +* Better introspection of in-memory caches (expose information about caches in `system.metrics` over incomplete `system.asynchronouse_metrics`). Add in-memory caches size (in bytes) into `dashboard.html`. `VectorSimilarityIndexCacheSize`/`IcebergMetadataFilesCacheSize` has been renamed to `VectorSimilarityIndexCacheBytes`/`IcebergMetadataFilesCacheBytes`. [#81023](https://github.com/ClickHouse/ClickHouse/pull/81023) ([Azat Khuzhin](https://github.com/azat)). +* Ignore databases with engines that can't contain `RocksDB` tables while reading from `system.rocksdb`. [#81083](https://github.com/ClickHouse/ClickHouse/pull/81083) ([Pervakov Grigorii](https://github.com/GrigoryPervakov)). +* Allow `filesystem_caches` and `named_collections` in the `clickhouse-local` configuration file. [#81105](https://github.com/ClickHouse/ClickHouse/pull/81105) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Fix highlighting of `PARTITION BY` in `INSERT` queries. In previous versions, `PARTITION BY` was not highlighted as a keyword. [#81106](https://github.com/ClickHouse/ClickHouse/pull/81106) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Two mini improvements in Web UI: - correctly handle queries without output, such as `CREATE`, `INSERT` (until recently, these queries resulted in an infinite spinner); - when double clicking on a table, scroll to the top. [#81131](https://github.com/ClickHouse/ClickHouse/pull/81131) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* `MemoryResidentWithoutPageCache` metric provides the amount of physical memory used by the server process, excluding userspace page cache, in bytes. This provides a more accurate view of actual memory usage when userspace page cache is utilized. When userspace page cache is disabled, this value equals `MemoryResident`. [#81233](https://github.com/ClickHouse/ClickHouse/pull/81233) ([Jayme Bird](https://github.com/jaymebrd)). +* Mark manually logged exceptions in client, local server, keeper client and disks app as logged, so that they are not logged twice. [#81271](https://github.com/ClickHouse/ClickHouse/pull/81271) ([Miсhael Stetsyuk](https://github.com/mstetsyuk)). +* Setting `use_skip_indexes_if_final` and `use_skip_indexes_if_final_exact_mode` now default to `True`. Queries with `FINAL` clause will now use skip indexes (if applicable) to shortlist granules and also read any additional granules corresponding to matching primary key ranges. Users needing earlier behaviour of approximate/imprecise results can set `use_skip_indexes_if_final_exact_mode` to FALSE after careful evaluation. [#81331](https://github.com/ClickHouse/ClickHouse/pull/81331) ([Shankar Iyer](https://github.com/shankar-iyer)). +* When you have multiple queries in the web UI, it will run the one under the cursor. Continuation of [#80977](https://github.com/ClickHouse/ClickHouse/issues/80977). [#81354](https://github.com/ClickHouse/ClickHouse/pull/81354) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* This PR addresses issues with the implementation of `is_strict` in the monotonicity checks for conversion functions. Currently, some conversion functions, such as `toFloat64(UInt32)` and `toDate(UInt8)`, incorrectly return `is_strict` as false when they should return true. [#81359](https://github.com/ClickHouse/ClickHouse/pull/81359) ([zoomxi](https://github.com/zoomxi)). +* When checking if a `KeyCondition` matches a continuous range, if the key is wrapped with a non-strict function chain, a `Constraint::POINT` may needs to be converted to a`Constraint::RANGE`. For example: `toDate(event_time) = '2025-06-03'` implies a range for `event_time`: ['2025-06-03 00:00:00', '2025-06-04 00:00:00'). This PR fixes this behavior. [#81400](https://github.com/ClickHouse/ClickHouse/pull/81400) ([zoomxi](https://github.com/zoomxi)). +* `clickhouse`/`ch` aliases will invoke `clickhouse-client` instead of `clickhouse-local` if `--host` or `--port` are specified. Continuation of [#79422](https://github.com/ClickHouse/ClickHouse/issues/79422). Closes [#65252](https://github.com/ClickHouse/ClickHouse/issues/65252). [#81509](https://github.com/ClickHouse/ClickHouse/pull/81509) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Now that we have the keeper response time distribution data, we can tune the histogram buckets for metrics. [#81516](https://github.com/ClickHouse/ClickHouse/pull/81516) ([Miсhael Stetsyuk](https://github.com/mstetsyuk)). +* Add profile event `PageCacheReadBytes`. [#81742](https://github.com/ClickHouse/ClickHouse/pull/81742) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Fix logical error in filesystem cache: "Having zero bytes but range is not finished". [#81868](https://github.com/ClickHouse/ClickHouse/pull/81868) ([Kseniia Sumarokova](https://github.com/kssenii)). + +#### Bug Fix (user-visible misbehavior in an official stable release) +* Fix parameterized view with SELECT EXCEPT query. Closes [#49447](https://github.com/ClickHouse/ClickHouse/issues/49447). [#57380](https://github.com/ClickHouse/ClickHouse/pull/57380) ([Nikolay Degterinsky](https://github.com/evillique)). +* Analyzer: Fix column projection name after column type promotion in join. Closes [#63345](https://github.com/ClickHouse/ClickHouse/issues/63345). [#63519](https://github.com/ClickHouse/ClickHouse/pull/63519) ([Dmitry Novik](https://github.com/novikd)). +* Fixed a logical error in cases of column name clashes when analyzer_compatibility_join_using_top_level_identifier is enabled. [#75676](https://github.com/ClickHouse/ClickHouse/pull/75676) ([Vladimir Cherkasov](https://github.com/vdimir)). +* Fix CTE usage in pushed-down predicates when `allow_push_predicate_ast_for_distributed_subqueries` is enabled. Fixes [#75647](https://github.com/ClickHouse/ClickHouse/issues/75647). Fixes [#79672](https://github.com/ClickHouse/ClickHouse/issues/79672). [#77316](https://github.com/ClickHouse/ClickHouse/pull/77316) ([Dmitry Novik](https://github.com/novikd)). +* Fixes an issue where SYSTEM SYNC REPLICA LIGHTWEIGHT 'foo' would report success even when the specified replica didn't exist. The command now properly validates that the replica exists in Keeper before attempting synchronization. [#78405](https://github.com/ClickHouse/ClickHouse/pull/78405) ([Jayme Bird](https://github.com/jaymebrd)). +* Fix crash for a very specific situation when the `currentDatabase` function was used in `CONSTRAINT` sections for `ON CLUSTER` queries Closes [#78100](https://github.com/ClickHouse/ClickHouse/issues/78100). [#79070](https://github.com/ClickHouse/ClickHouse/pull/79070) ([pufit](https://github.com/pufit)). +* Fix passing of external roles in interserver queries. [#79099](https://github.com/ClickHouse/ClickHouse/pull/79099) ([Andrey Zvonov](https://github.com/zvonand)). +* Try to use IColumn instead of Field in SingleValueDataGeneric. It fixes the incorrect return values for some aggregate functions like `argMax` for types `Dynamic/Variant/JSON`. [#79166](https://github.com/ClickHouse/ClickHouse/pull/79166) ([Pavel Kruglov](https://github.com/Avogar)). +* Fix applying use_native_copy and allow_azure_native_copy setting for azure blob storage and updated to use native copy only when credentials match resolves [#78964](https://github.com/ClickHouse/ClickHouse/issues/78964). [#79561](https://github.com/ClickHouse/ClickHouse/pull/79561) ([Smita Kulkarni](https://github.com/SmitaRKulkarni)). +* Fix logical errors about a column's unknown origin scope produced while checking if this column is correlated. Fixes [#78183](https://github.com/ClickHouse/ClickHouse/issues/78183). Fixes [#79451](https://github.com/ClickHouse/ClickHouse/issues/79451). [#79727](https://github.com/ClickHouse/ClickHouse/pull/79727) ([Dmitry Novik](https://github.com/novikd)). +* Fix wrong results for grouping sets with ColumnConst and Analyzer. [#79743](https://github.com/ClickHouse/ClickHouse/pull/79743) ([Andrey Zvonov](https://github.com/zvonand)). +* Fix local shard result duplication when reading from distributed table with local replica being stale. [#79761](https://github.com/ClickHouse/ClickHouse/pull/79761) ([Eduard Karacharov](https://github.com/korowa)). +* Fix the sorting order of the NaNs with a negative sign bit. [#79847](https://github.com/ClickHouse/ClickHouse/pull/79847) ([Pervakov Grigorii](https://github.com/GrigoryPervakov)). +* Now GROUP BY ALL doesn't take into account the GROUPING part. [#79915](https://github.com/ClickHouse/ClickHouse/pull/79915) ([Yarik Briukhovetskyi](https://github.com/yariks5s)). +* Fixed incorrect state merging for `TopK` / `TopKWeighted` functions that would cause excessive error values even when capacity was not exhausted. [#79939](https://github.com/ClickHouse/ClickHouse/pull/79939) ([Joel Höner](https://github.com/athre0z)). +* Respect `readonly` setting in `azure_blob_storage` object storage. [#79954](https://github.com/ClickHouse/ClickHouse/pull/79954) ([Julia Kartseva](https://github.com/jkartseva)). +* Fixed incorrect query results and out-of-memory crashes when using `match(column, '^…')` with backslash-escaped characters. [#79969](https://github.com/ClickHouse/ClickHouse/pull/79969) ([filimonov](https://github.com/filimonov)). +* Disabling hive partitioning for datalakes Partially addresses https://github.com/issues/assigned?issue=ClickHouse%7CClickHouse%7C79937. [#80005](https://github.com/ClickHouse/ClickHouse/pull/80005) ([Daniil Ivanik](https://github.com/divanik)). +* Skip indexes with lambda expressions could not be applied. Fix the case when high-level functions in the index definition exactly match the one in the query. [#80025](https://github.com/ClickHouse/ClickHouse/pull/80025) ([Nikolai Kochetov](https://github.com/KochetovNicolai)). +* Fix metadata version during attach part on the replica executing ATTACH_PART command from replication log. [#80038](https://github.com/ClickHouse/ClickHouse/pull/80038) ([Aleksei Filatov](https://github.com/aalexfvk)). +* Executable User Defined Functions (eUDF) names are not added to the `used_functions` column of the `system.query_log` table, unlike other functions. This PR implements the addition of the eUDF name if the eUDF was used in the request. [#80073](https://github.com/ClickHouse/ClickHouse/pull/80073) ([Kyamran](https://github.com/nibblerenush)). +* Fix logical error in Arrow format with LowCardinality(FixedString). [#80156](https://github.com/ClickHouse/ClickHouse/pull/80156) ([Pavel Kruglov](https://github.com/Avogar)). +* Fix reading subcolumns from Merge engine. [#80158](https://github.com/ClickHouse/ClickHouse/pull/80158) ([Pavel Kruglov](https://github.com/Avogar)). +* Fix a bug about the comparison between numeric types in `KeyCondition`. [#80207](https://github.com/ClickHouse/ClickHouse/pull/80207) ([Yarik Briukhovetskyi](https://github.com/yariks5s)). +* Fix AMBIGUOUS_COLUMN_NAME when lazy materialization applied to table with projections. [#80251](https://github.com/ClickHouse/ClickHouse/pull/80251) ([Igor Nikonov](https://github.com/devcrafter)). +* Fix incorrect count optimization for string prefix filters like LIKE 'ab_c%' when using implicit projections. This fixes [#80250](https://github.com/ClickHouse/ClickHouse/issues/80250). [#80261](https://github.com/ClickHouse/ClickHouse/pull/80261) ([Amos Bird](https://github.com/amosbird)). +* Fix improper serialization of nested numeric fields as strings in MongoDB documents. Remove maximum depth limit for documents from MongoDB. [#80289](https://github.com/ClickHouse/ClickHouse/pull/80289) ([Kirill Nikiforov](https://github.com/allmazz)). +* Perform less strict metadata checks for RMT in the Replicated database. Closes [#80296](https://github.com/ClickHouse/ClickHouse/issues/80296). [#80298](https://github.com/ClickHouse/ClickHouse/pull/80298) ([Nikolay Degterinsky](https://github.com/evillique)). +* Fix text representation of DateTime and DateTime64 for PostgreSQL storage. [#80301](https://github.com/ClickHouse/ClickHouse/pull/80301) ([Yakov Olkhovskiy](https://github.com/yakov-olkhovskiy)). +* Allow `DateTime` with timezone in `StripeLog` tables. This closes [#44120](https://github.com/ClickHouse/ClickHouse/issues/44120). [#80304](https://github.com/ClickHouse/ClickHouse/pull/80304) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Disable filter-push-down for the predicate with a non-deterministic function in case the query plan step changes the number of rows. Fixes [#40273](https://github.com/ClickHouse/ClickHouse/issues/40273). [#80329](https://github.com/ClickHouse/ClickHouse/pull/80329) ([Nikolai Kochetov](https://github.com/KochetovNicolai)). +* Fix possible logical errors and crashes in projections with subcolumns. [#80333](https://github.com/ClickHouse/ClickHouse/pull/80333) ([Pavel Kruglov](https://github.com/Avogar)). +* Fix `NOT_FOUND_COLUMN_IN_BLOCK` error caused by filter-push-down optimization of the logical JOIN sep in case `ON` expression is not a trivial equality. Fixes [#79647](https://github.com/ClickHouse/ClickHouse/issues/79647) Fixes [#77848](https://github.com/ClickHouse/ClickHouse/issues/77848). [#80360](https://github.com/ClickHouse/ClickHouse/pull/80360) ([Nikolai Kochetov](https://github.com/KochetovNicolai)). +* Fix incorrect result when reading reverse-ordered keys in partitioned tables. This fixes [#79987](https://github.com/ClickHouse/ClickHouse/issues/79987). [#80448](https://github.com/ClickHouse/ClickHouse/pull/80448) ([Amos Bird](https://github.com/amosbird)). +* Fixed wrong sorting in tables with a nullable key and enabled optimize_read_in_order. [#80515](https://github.com/ClickHouse/ClickHouse/pull/80515) ([Pervakov Grigorii](https://github.com/GrigoryPervakov)). +* Fixed refreshable materialized view DROP getting stuck if the view was paused using SYSTEM STOP REPLICATED VIEW. [#80543](https://github.com/ClickHouse/ClickHouse/pull/80543) ([Michael Kolupaev](https://github.com/al13n321)). +* Fix 'Cannot find column' with constant tuple in distributed query. [#80596](https://github.com/ClickHouse/ClickHouse/pull/80596) ([Yakov Olkhovskiy](https://github.com/yakov-olkhovskiy)). +* Fix `shardNum` function in Distributed tables with `join_use_nulls`. [#80612](https://github.com/ClickHouse/ClickHouse/pull/80612) ([János Benjamin Antal](https://github.com/antaljanosbenjamin)). +* Fix incorrect result during reading column that exists in subset of tables in Merge engine. [#80643](https://github.com/ClickHouse/ClickHouse/pull/80643) ([Pavel Kruglov](https://github.com/Avogar)). +* Fix possible SSH protocol (due to hang in replxx). [#80688](https://github.com/ClickHouse/ClickHouse/pull/80688) ([Azat Khuzhin](https://github.com/azat)). +* The timestamp in the iceberg_history table should now be correct. [#80711](https://github.com/ClickHouse/ClickHouse/pull/80711) ([Melvyn Peignon](https://github.com/melvynator)). +* Fix possible crash in case of dictionary registration failed (when `CREATE DICTIONARY` failed with `CANNOT_SCHEDULE_TASK` it is possible to leave dangling pointer in the dictionary registry, which later lead to crash). [#80714](https://github.com/ClickHouse/ClickHouse/pull/80714) ([Azat Khuzhin](https://github.com/azat)). +* Fix handling of enum globs of a single element in object storage table functions. [#80716](https://github.com/ClickHouse/ClickHouse/pull/80716) ([Konstantin Bogdanov](https://github.com/thevar1able)). +* Fix wrong result type of comparison functions with Tuple(Dynamic) and String that led to logical error. [#80728](https://github.com/ClickHouse/ClickHouse/pull/80728) ([Pavel Kruglov](https://github.com/Avogar)). +* Add missing support data type `timestamp_ntz` for unity catalog. Fixes [#79535](https://github.com/ClickHouse/ClickHouse/issues/79535), Fixes [#79875](https://github.com/ClickHouse/ClickHouse/issues/79875). [#80740](https://github.com/ClickHouse/ClickHouse/pull/80740) ([alesapin](https://github.com/alesapin)). +* Fix `THERE_IS_NO_COLUMN` error for distributed queries with `IN cte`. Fixes [#75032](https://github.com/ClickHouse/ClickHouse/issues/75032). [#80757](https://github.com/ClickHouse/ClickHouse/pull/80757) ([Nikolai Kochetov](https://github.com/KochetovNicolai)). +* Fix excessive number of files (leads to excessive memory usage) for external ORDER BY. [#80777](https://github.com/ClickHouse/ClickHouse/pull/80777) ([Azat Khuzhin](https://github.com/azat)). +* This PR might close [#80742](https://github.com/ClickHouse/ClickHouse/issues/80742). [#80783](https://github.com/ClickHouse/ClickHouse/pull/80783) ([zoomxi](https://github.com/zoomxi)). +* Fix crash in Kafka due to get_member_id() was creating std::string from NULL (it was likely an issue only in case of connection to broker had been failed). [#80793](https://github.com/ClickHouse/ClickHouse/pull/80793) ([Azat Khuzhin](https://github.com/azat)). +* Properly wait consumers before shutting down Kafka engine (active consumers after shutdown can trigger various debug assertions and also may read data from brokers in background after table has been dropped/detached). [#80795](https://github.com/ClickHouse/ClickHouse/pull/80795) ([Azat Khuzhin](https://github.com/azat)). +* Fix `NOT_FOUND_COLUMN_IN_BLOCK`, which is caused by `predicate-push-down` optimization. Fixes [#80443](https://github.com/ClickHouse/ClickHouse/issues/80443). [#80834](https://github.com/ClickHouse/ClickHouse/pull/80834) ([Nikolai Kochetov](https://github.com/KochetovNicolai)). +* Fix logical error when resolving star (*) matcher in table function in JOIN with USING. [#80894](https://github.com/ClickHouse/ClickHouse/pull/80894) ([Vladimir Cherkasov](https://github.com/vdimir)). +* Fix memory accounting for Iceberg metadata files cache. [#80904](https://github.com/ClickHouse/ClickHouse/pull/80904) ([Azat Khuzhin](https://github.com/azat)). +* Fix wrong partitioning with nullable partition key. [#80913](https://github.com/ClickHouse/ClickHouse/pull/80913) ([Pervakov Grigorii](https://github.com/GrigoryPervakov)). +* Fix `Table does not exist` error for distributed queries with pushed-down predicate (`allow_push_predicate_ast_for_distributed_subqueries=1`) when the source table does not exist on the initialtor. Fixes [#77281](https://github.com/ClickHouse/ClickHouse/issues/77281). [#80915](https://github.com/ClickHouse/ClickHouse/pull/80915) ([Nikolai Kochetov](https://github.com/KochetovNicolai)). +* Fix the logical error in the nested functions with named windows. [#80926](https://github.com/ClickHouse/ClickHouse/pull/80926) ([Pervakov Grigorii](https://github.com/GrigoryPervakov)). +* Fix extremes for nullable and floating-point columns. [#80970](https://github.com/ClickHouse/ClickHouse/pull/80970) ([Pervakov Grigorii](https://github.com/GrigoryPervakov)). +* Fix possible crash while querying from system.tables (likely the case under memory pressure). [#80976](https://github.com/ClickHouse/ClickHouse/pull/80976) ([Azat Khuzhin](https://github.com/azat)). +* Fix atomic rename with truncate for files which compression is inferred from their file extension. [#80979](https://github.com/ClickHouse/ClickHouse/pull/80979) ([Pablo Marcos](https://github.com/pamarcos)). +* Fix ErrorCodes::getName. [#81032](https://github.com/ClickHouse/ClickHouse/pull/81032) ([RinChanNOW](https://github.com/RinChanNOWWW)). +* Fix bug when user cannot list tables in Unity Catalog without permissions for all of them. Now all tables are listed properly, attempt to read from restricted table will throw an exception. [#81044](https://github.com/ClickHouse/ClickHouse/pull/81044) ([alesapin](https://github.com/alesapin)). +* Now ClickHouse will ignore errors and unexpected responses from data lake catalogs in `SHOW TABLES` query. Fixes [#79725](https://github.com/ClickHouse/ClickHouse/issues/79725). [#81046](https://github.com/ClickHouse/ClickHouse/pull/81046) ([alesapin](https://github.com/alesapin)). +* Fix parsing of DateTime64 from integers in JSONExtract and JSON type parsing. [#81050](https://github.com/ClickHouse/ClickHouse/pull/81050) ([Pavel Kruglov](https://github.com/Avogar)). +* Reflect date_time_input_format setting in schema inference cache. [#81052](https://github.com/ClickHouse/ClickHouse/pull/81052) ([Pavel Kruglov](https://github.com/Avogar)). +* Fix crash on INSERT if table was DROPed after query started but before columns sent. [#81053](https://github.com/ClickHouse/ClickHouse/pull/81053) ([Azat Khuzhin](https://github.com/azat)). +* Fix use-of-uninitialized-value in quantileDeterministic. [#81062](https://github.com/ClickHouse/ClickHouse/pull/81062) ([Azat Khuzhin](https://github.com/azat)). +* Fix hardlinks count management for metadatastoragefromdisk disk transactions. add tests. [#81066](https://github.com/ClickHouse/ClickHouse/pull/81066) ([Sema Checherinda](https://github.com/CheSema)). +* User Defined Functions (UDF) names are not added to the `system.query_log` table, unlike other functions. This PR implements the addition of the UDF name to one of the two columns `used_executable_user_defined_functions` or `used_sql_user_defined_functions` if the UDF was used in the request. [#81101](https://github.com/ClickHouse/ClickHouse/pull/81101) ([Kyamran](https://github.com/nibblerenush)). +* Fixed `Too large size ... passed to allocator` errors or possible crashes on inserts via http protocol with text formats (`JSON`, `Values`, ...) and omitted `Enum` fields. [#81145](https://github.com/ClickHouse/ClickHouse/pull/81145) ([Anton Popov](https://github.com/CurtizJ)). +* Fix LOGICAL_ERROR in case of Sparse column in INSERT block pushed to non-MT MV. [#81161](https://github.com/ClickHouse/ClickHouse/pull/81161) ([Azat Khuzhin](https://github.com/azat)). +* Fix `Unknown table expression identifier` for `distributed_product_mode_local=local` with cross-replication. [#81162](https://github.com/ClickHouse/ClickHouse/pull/81162) ([Nikolai Kochetov](https://github.com/KochetovNicolai)). +* Fixed incorrectly caching number of rows in parquet files after filtering. [#81184](https://github.com/ClickHouse/ClickHouse/pull/81184) ([Michael Kolupaev](https://github.com/al13n321)). +* Fix fs cache max_size_to_total_space setting when used with relative cache path. [#81237](https://github.com/ClickHouse/ClickHouse/pull/81237) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Fixed clickhouse-local crashing when outputting const tuples or maps in Parquet format. [#81249](https://github.com/ClickHouse/ClickHouse/pull/81249) ([Michael Kolupaev](https://github.com/al13n321)). +* Verify array offsets received over network. [#81269](https://github.com/ClickHouse/ClickHouse/pull/81269) ([Azat Khuzhin](https://github.com/azat)). +* Fix some corner case in query that joins empty tables and uses window functions. The bug leads to exploding number of parallel streams which leads to OOMs. [#81299](https://github.com/ClickHouse/ClickHouse/pull/81299) ([Alexander Gololobov](https://github.com/davenger)). +* Fixes for datalake Cluster functions (`deltaLakeCluster`, `icebergCluster`, etc): (1) fix potential segfault in `DataLakeConfiguration` when using `Cluster` function with old analyzer; (2) remove duplicating data lake metadata updates (extra object storage requests); (3) fix redundant listing in object storage when format is not explicitly specified (which was already done for non-cluster data lake engines). [#81300](https://github.com/ClickHouse/ClickHouse/pull/81300) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Make force_restore_data flag recover lost keeper metadata. [#81324](https://github.com/ClickHouse/ClickHouse/pull/81324) ([Raúl Marín](https://github.com/Algunenano)). +* Fix region error in delta-kernel. Fixes [#79914](https://github.com/ClickHouse/ClickHouse/issues/79914). [#81353](https://github.com/ClickHouse/ClickHouse/pull/81353) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Disable incorrect JIT for divideOrNull. [#81370](https://github.com/ClickHouse/ClickHouse/pull/81370) ([Raúl Marín](https://github.com/Algunenano)). +* Fix insert error when MergeTree table has a long partition column name. [#81390](https://github.com/ClickHouse/ClickHouse/pull/81390) ([hy123q](https://github.com/haoyangqian)). +* Backported in [#81957](https://github.com/ClickHouse/ClickHouse/issues/81957): Fixed possible crash in `Aggregator` in case of exception during merge. [#81450](https://github.com/ClickHouse/ClickHouse/pull/81450) ([Nikita Taranov](https://github.com/nickitat)). +* Don't store content of several manifest files in memory. [#81470](https://github.com/ClickHouse/ClickHouse/pull/81470) ([Daniil Ivanik](https://github.com/divanik)). +* Fix possible crash during shutting down background pools (`background_.*pool_size`). [#81473](https://github.com/ClickHouse/ClickHouse/pull/81473) ([Azat Khuzhin](https://github.com/azat)). +* Fix out-of-bounds read in the `Npy` format happening when writing to a table with the `URL` engine. This closes [#81356](https://github.com/ClickHouse/ClickHouse/issues/81356). [#81502](https://github.com/ClickHouse/ClickHouse/pull/81502) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* There is a chance that Web UI displays `NaN%` (typical JavaScript problems). [#81507](https://github.com/ClickHouse/ClickHouse/pull/81507) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Fix `DatabaseReplicated` for `database_replicated_enforce_synchronous_settings=1`. [#81564](https://github.com/ClickHouse/ClickHouse/pull/81564) ([Azat Khuzhin](https://github.com/azat)). +* Fix sorting order for LowCardinality(Nullable(...)) types. [#81583](https://github.com/ClickHouse/ClickHouse/pull/81583) ([Pervakov Grigorii](https://github.com/GrigoryPervakov)). +* Server should not preserve a HTTP connection if the request has not been fully read from the socket. [#81595](https://github.com/ClickHouse/ClickHouse/pull/81595) ([Sema Checherinda](https://github.com/CheSema)). +* Make scalar correlated subqueries return a nullable result of the projection expression. Fix the case when a correlated subquery produces an empty result set. [#81632](https://github.com/ClickHouse/ClickHouse/pull/81632) ([Dmitry Novik](https://github.com/novikd)). +* Fix `Unexpected relative path for a deduplicated part` during `ATTACH` to `ReplicatedMergeTree`. [#81647](https://github.com/ClickHouse/ClickHouse/pull/81647) ([Azat Khuzhin](https://github.com/azat)). +* Query settings `use_iceberg_partition_pruning` will not take effect for iceberg storage, because it uses global context rather than query context. it's not critical because its default value is true. this pr can fix it. [#81673](https://github.com/ClickHouse/ClickHouse/pull/81673) ([Han Fei](https://github.com/hanfei1991)). +* Backported in [#82128](https://github.com/ClickHouse/ClickHouse/issues/82128): Fix "Context has expired" during merges when dict used in TTL expression. [#81690](https://github.com/ClickHouse/ClickHouse/pull/81690) ([Azat Khuzhin](https://github.com/azat)). +* Add validation for mergetree setting `merge_max_block_size` to ensure that it's non zero. [#81693](https://github.com/ClickHouse/ClickHouse/pull/81693) ([Bharat Nallan](https://github.com/bharatnc)). +* Fix issues with `clickhouse-local` involving stuck `DROP VIEW ` queries. [#81705](https://github.com/ClickHouse/ClickHouse/pull/81705) ([Bharat Nallan](https://github.com/bharatnc)). +* Fix StorageRedis join in some cases. [#81736](https://github.com/ClickHouse/ClickHouse/pull/81736) ([Pervakov Grigorii](https://github.com/GrigoryPervakov)). +* Fix crash in `ConcurrentHashJoin` with empty `USING ()` and old analyzer enabled. [#81754](https://github.com/ClickHouse/ClickHouse/pull/81754) ([Nikita Taranov](https://github.com/nickitat)). +* Keeper fix: block commits of new logs if there is invalid entry in the logs. Previously, if leader applied some logs incorrectly, it would continue to commit new logs, even though the follower would detect digest mismatch and abort. [#81780](https://github.com/ClickHouse/ClickHouse/pull/81780) ([Antonio Andelic](https://github.com/antonio2368)). +* Fix the issue where required columns are not read during scalar correlated subquery processing. Fixes [#81716](https://github.com/ClickHouse/ClickHouse/issues/81716). [#81805](https://github.com/ClickHouse/ClickHouse/pull/81805) ([Dmitry Novik](https://github.com/novikd)). +* Someone littered our code with Kusto. Cleaned it up. This closes [#81643](https://github.com/ClickHouse/ClickHouse/issues/81643). [#81885](https://github.com/ClickHouse/ClickHouse/pull/81885) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* In previous versions, the server returned excessive content for requests to `/js`. This closes [#61890](https://github.com/ClickHouse/ClickHouse/issues/61890). [#81895](https://github.com/ClickHouse/ClickHouse/pull/81895) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Previously, `MongoDB` table engine definitions could include a path component in the `host:port` argument which was silently ignored. The mongodb integration refuses to load such tables. With this fix *we allow loading such tables and ignore path component* if `MongoDB` engine has five arguments, using the database name from arguments. *Note:* The fix is not applied for newly created tables or queries with `mongo` table function, as well as for dictionary sources and named collections. [#81942](https://github.com/ClickHouse/ClickHouse/pull/81942) ([Vladimir Cherkasov](https://github.com/vdimir)). +* Fixed possible crash in `Aggregator` in case of exception during merge. [#82022](https://github.com/ClickHouse/ClickHouse/pull/82022) ([Nikita Taranov](https://github.com/nickitat)). +* Fixing copy-paste error in `arraySimilarity`, disallowing the use of `UInt32` and `Int32` weights. Update tests and docs. [#82103](https://github.com/ClickHouse/ClickHouse/pull/82103) ([Mikhail f. Shiryaev](https://github.com/Felixoid)). +* Fix possible data-race between suggestion thread and main client thread. [#82233](https://github.com/ClickHouse/ClickHouse/pull/82233) ([Azat Khuzhin](https://github.com/azat)). + +#### Build/Testing/Packaging Improvement +* Use `postgres` 16.9. [#81437](https://github.com/ClickHouse/ClickHouse/pull/81437) ([Konstantin Bogdanov](https://github.com/thevar1able)). +* Use `openssl` 3.2.4. [#81438](https://github.com/ClickHouse/ClickHouse/pull/81438) ([Konstantin Bogdanov](https://github.com/thevar1able)). +* Use `abseil-cpp` 2025-01-27. [#81440](https://github.com/ClickHouse/ClickHouse/pull/81440) ([Konstantin Bogdanov](https://github.com/thevar1able)). +* Use `mongo-c-driver` 1.30.4. [#81449](https://github.com/ClickHouse/ClickHouse/pull/81449) ([Konstantin Bogdanov](https://github.com/thevar1able)). +* Use `krb5` 1.21.3-final. [#81453](https://github.com/ClickHouse/ClickHouse/pull/81453) ([Konstantin Bogdanov](https://github.com/thevar1able)). +* Use `orc` 2.1.2. [#81455](https://github.com/ClickHouse/ClickHouse/pull/81455) ([Konstantin Bogdanov](https://github.com/thevar1able)). +* Use `grpc` 1.73.0. [#81629](https://github.com/ClickHouse/ClickHouse/pull/81629) ([Konstantin Bogdanov](https://github.com/thevar1able)). +* Use `delta-kernel-rs` v0.12.1. [#81707](https://github.com/ClickHouse/ClickHouse/pull/81707) ([Konstantin Bogdanov](https://github.com/thevar1able)). +* Update `c-ares` to `v1.34.5`. [#81159](https://github.com/ClickHouse/ClickHouse/pull/81159) ([Konstantin Bogdanov](https://github.com/thevar1able)). +* Upgrade `curl` to 8.14 to address CVE-2025-5025 and CVE-2025-4947. [#81171](https://github.com/ClickHouse/ClickHouse/pull/81171) ([larryluogit](https://github.com/larryluogit)). +* Upgrade `libarchive` to 3.7.9 to address: CVE-2024-20696 CVE-2025-25724 CVE-2024-48958 CVE-2024-57970 CVE-2025-1632 CVE-2024-48957 CVE-2024-48615. [#81174](https://github.com/ClickHouse/ClickHouse/pull/81174) ([larryluogit](https://github.com/larryluogit)). +* Upgrade `libxml2` to 2.14.3. [#81187](https://github.com/ClickHouse/ClickHouse/pull/81187) ([larryluogit](https://github.com/larryluogit)). +* Avoid copying vendored Rust sources to `CARGO_HOME`. [#79560](https://github.com/ClickHouse/ClickHouse/pull/79560) ([Konstantin Bogdanov](https://github.com/thevar1able)). +* Remove dependency on the Sentry library by replacing it with our own endpoint. [#80236](https://github.com/ClickHouse/ClickHouse/pull/80236) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Update python dependencies in CI images to address Dependabot alerts. [#80658](https://github.com/ClickHouse/ClickHouse/pull/80658) ([Raúl Marín](https://github.com/Algunenano)). +* Retry reading of replicated DDL stop flag from Keeper at startup to make tests more robust when fault injection is enabled for Keeper. [#80964](https://github.com/ClickHouse/ClickHouse/pull/80964) ([Alexander Gololobov](https://github.com/davenger)). +* Use https for ubuntu archive url. [#81016](https://github.com/ClickHouse/ClickHouse/pull/81016) ([Raúl Marín](https://github.com/Algunenano)). +* Update python dependencies in test images. [#81042](https://github.com/ClickHouse/ClickHouse/pull/81042) ([dependabot[bot]](https://github.com/apps/dependabot)). +* Introduce `flake.nix` for Nix builds. [#81463](https://github.com/ClickHouse/ClickHouse/pull/81463) ([Konstantin Bogdanov](https://github.com/thevar1able)). +* Fix `delta-kernel-rs` requiring network access during build. Closes [#80609](https://github.com/ClickHouse/ClickHouse/issues/80609). [#81602](https://github.com/ClickHouse/ClickHouse/pull/81602) ([Konstantin Bogdanov](https://github.com/thevar1able)). Read the article [A Year of Rust in ClickHouse](https://clickhouse.com/blog/rust). + + +### ClickHouse release 25.5, 2025-05-22 {#255} + +#### Backward Incompatible Change +* Function `geoToH3` now accepts the input in the order (lat, lon, res) (which is common for other geometric functions). Users who wish to retain the previous result order (lon, lat, res) can set setting `geotoh3_argument_order = 'lon_lat'`. [#78852](https://github.com/ClickHouse/ClickHouse/pull/78852) ([Pratima Patel](https://github.com/pratimapatel2008)). +* Add a filesystem cache setting `allow_dynamic_cache_resize`, by default `false`, to allow dynamic resize of filesystem cache. Why: in certain environments (ClickHouse Cloud) all the scaling events happen through the restart of the process and we would love this feature to be explicitly disabled to have more control over the behaviour + as a safety measure. This PR is marked as backward incompatible, because in older versions dynamic cache resize worked by default without special setting. [#79148](https://github.com/ClickHouse/ClickHouse/pull/79148) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Removed support for legacy index types `annoy` and `usearch`. Both have been stubs for a long time, i.e. every attempt to use the legacy indexes returned an error anyways. If you still have `annoy` and `usearch` indexes, please drop them. [#79802](https://github.com/ClickHouse/ClickHouse/pull/79802) ([Robert Schulze](https://github.com/rschu1ze)). +* Remove `format_alter_commands_with_parentheses` server setting. The setting was introduced and disabled by default in 24.2. It was enabled by default in 25.2. As there are no LTS versions that don't support the new format, we can remove the setting. [#79970](https://github.com/ClickHouse/ClickHouse/pull/79970) ([János Benjamin Antal](https://github.com/antaljanosbenjamin)). +* Enable `DeltaLake` storage `delta-kernel-rs` implementation by default. [#79541](https://github.com/ClickHouse/ClickHouse/pull/79541) ([Kseniia Sumarokova](https://github.com/kssenii)). +* If reading from an `URL` involves multiple redirects, setting `enable_url_encoding` is correctly applied across all redirects in the chain. [#79563](https://github.com/ClickHouse/ClickHouse/pull/79563) ([Shankar Iyer](https://github.com/shankar-iyer)). Setting `enble_url_encoding` default value is now set to `false`. [#80088](https://github.com/ClickHouse/ClickHouse/pull/80088) ([Shankar Iyer](https://github.com/shankar-iyer)). + +#### New Feature +* Support scalar correlated subqueries in the WHERE clause. Closes [#6697](https://github.com/ClickHouse/ClickHouse/issues/6697). [#79600](https://github.com/ClickHouse/ClickHouse/pull/79600) ([Dmitry Novik](https://github.com/novikd)). Support correlated subqueries in the projection list in simple cases. [#79925](https://github.com/ClickHouse/ClickHouse/pull/79925) ([Dmitry Novik](https://github.com/novikd)). [#76078](https://github.com/ClickHouse/ClickHouse/pull/76078) ([Dmitry Novik](https://github.com/novikd)). Now it covers 100% of TPC-H test suite. +* Vector search using the vector similarity index is now beta (from previously experimental). [#80164](https://github.com/ClickHouse/ClickHouse/pull/80164) ([Robert Schulze](https://github.com/rschu1ze)). +* Support geo types in `Parquet` format. This closes [#75317](https://github.com/ClickHouse/ClickHouse/issues/75317). [#79777](https://github.com/ClickHouse/ClickHouse/pull/79777) ([scanhex12](https://github.com/scanhex12)). +* New functions `sparseGrams`, `sparseGramsHashes`, `sparseGramsHashesUTF8`, `sparseGramsUTF8` for calculating "sparse-ngrams" - a robust algorithm for extracting substrings for indexing and search. [#79517](https://github.com/ClickHouse/ClickHouse/pull/79517) ([scanhex12](https://github.com/scanhex12)). +* `clickhouse-local` (and its shorthand alias, `ch`) now use an implicit `FROM table` when there is input data for processing. This closes [#65023](https://github.com/ClickHouse/ClickHouse/issues/65023). Also enabled format inference in clickhouse-local if `--input-format` is not specified and it processes a regular file. [#79085](https://github.com/ClickHouse/ClickHouse/pull/79085) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Add `stringBytesUniq` and `stringBytesEntropy` functions to search for possibly random or encrypted data. [#79350](https://github.com/ClickHouse/ClickHouse/pull/79350) ([Sachin Kumar Singh](https://github.com/sachinkumarsingh092)). +* Added functions for encoding and decoding base32. [#79809](https://github.com/ClickHouse/ClickHouse/pull/79809) ([Joanna Hulboj](https://github.com/jh0x)). +* Add `getServerSetting` and `getMergeTreeSetting` function. Closes #78318. [#78439](https://github.com/ClickHouse/ClickHouse/pull/78439) ([NamNguyenHoai](https://github.com/NamHoaiNguyen)). +* Add new `iceberg_enable_version_hint` setting to leverage `version-hint.text` file. [#78594](https://github.com/ClickHouse/ClickHouse/pull/78594) ([Arnaud Briche](https://github.com/arnaudbriche)). +* Gives the possibility to truncate specific tables from a database, filtered with the `LIKE` keyword. [#78597](https://github.com/ClickHouse/ClickHouse/pull/78597) ([Yarik Briukhovetskyi](https://github.com/yariks5s)). +* Support `_part_starting_offset` virtual column in `MergeTree`-family tables. This column represents the cumulative row count of all preceding parts, calculated at query time based on the current part list. The cumulative values are retained throughout query execution and remain effective even after part pruning. Related internal logic has been refactored to support this behavior. [#79417](https://github.com/ClickHouse/ClickHouse/pull/79417) ([Amos Bird](https://github.com/amosbird)). +* Add functions `divideOrNull`,`moduloOrNull`, `intDivOrNull`,`positiveModuloOrNull` to return NULL when right argument is zero. [#78276](https://github.com/ClickHouse/ClickHouse/pull/78276) ([kevinyhzou](https://github.com/KevinyhZou)). +* Clickhouse vector search now supports both pre-filtering and post-filtering and provides related settings for finer control. (issue [#78161](https://github.com/ClickHouse/ClickHouse/issues/78161)). [#79854](https://github.com/ClickHouse/ClickHouse/pull/79854) ([Shankar Iyer](https://github.com/shankar-iyer)). +* Add [`icebergHash`](https://iceberg.apache.org/spec/#appendix-b-32-bit-hash-requirements) and [`icebergBucket`](https://iceberg.apache.org/spec/#bucket-transform-details) functions. Support data files pruning in `Iceberg` tables partitioned with [`bucket transfom`](https://iceberg.apache.org/spec/#partitioning). [#79262](https://github.com/ClickHouse/ClickHouse/pull/79262) ([Daniil Ivanik](https://github.com/divanik)). + +#### Experimental Feature +* New `Time`/`Time64` data types: `Time` (HHH:MM:SS) and `Time64` (HHH:MM:SS.``) and some basic cast functions and functions to interact with other data types. Also, changed the existing function's name toTime to toTimeWithFixedDate because the function toTime is required for the cast function. [#75735](https://github.com/ClickHouse/ClickHouse/pull/75735) ([Yarik Briukhovetskyi](https://github.com/yariks5s)). +72459). +* Hive metastore catalog for Iceberg datalake. [#77677](https://github.com/ClickHouse/ClickHouse/pull/77677) ([scanhex12](https://github.com/scanhex12)). +* Indexes of type `full_text` were renamed to `gin`. This follows the more familiar terminology of PostgreSQL and other databases. Existing indexes of type `full_text` remain loadable but they will throw an exception (suggesting `gin` indexes instead) when one tries to use them in searches. [#79024](https://github.com/ClickHouse/ClickHouse/pull/79024) ([Robert Schulze](https://github.com/rschu1ze)). + +#### Performance Improvement +* Change the Compact part format to save marks for each substream to be able to read individual subcolumns. Old Compact format is still supported for reads and can be enabled for writes using MergeTree setting `write_marks_for_substreams_in_compact_parts`. It's disabled by default for safer upgrades as it changes the compact parts storage. It will be enabled by default in one of the next releases. [#77940](https://github.com/ClickHouse/ClickHouse/pull/77940) ([Pavel Kruglov](https://github.com/Avogar)). +* Allow moving conditions with subcolumns to prewhere. [#79489](https://github.com/ClickHouse/ClickHouse/pull/79489) ([Pavel Kruglov](https://github.com/Avogar)). +* Speed up secondary indices by evaluating their expressions on multiple granules at once. [#64109](https://github.com/ClickHouse/ClickHouse/pull/64109) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Enable `compile_expressions` (JIT compiler for fragments of ordinary expressions) by default. This closes [#51264](https://github.com/ClickHouse/ClickHouse/issues/51264) and [#56386](https://github.com/ClickHouse/ClickHouse/issues/56386) and [#66486](https://github.com/ClickHouse/ClickHouse/issues/66486). [#79907](https://github.com/ClickHouse/ClickHouse/pull/79907) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* New setting introduced: `use_skip_indexes_in_final_exact_mode`. If a query on a `ReplacingMergeTree` table has FINAL clause, reading only table ranges based on skip indexes may produce incorrect result. This setting can ensure that correct results are returned by scanning newer parts that have overlap with primary key ranges returned by the skip index. Set to 0 to disable, 1 to enable. [#78350](https://github.com/ClickHouse/ClickHouse/pull/78350) ([Shankar Iyer](https://github.com/shankar-iyer)). +* Object storage cluster table functions (e.g. `s3Cluster`) will now assign files to replicas for reading based on consistent hash to improve cache locality. [#77326](https://github.com/ClickHouse/ClickHouse/pull/77326) ([Andrej Hoos](https://github.com/adikus)). +* Improve performance of `S3Queue`/`AzureQueue` by allowing INSERTs data in parallel (can be enabled with `parallel_inserts=true` queue setting). Previously S3Queue/AzureQueue can only do first part of pipeline in parallel (downloading, parsing), INSERT was single-threaded. And `INSERT`s are almost always the bottleneck. Now it will scale almost linear with `processing_threads_num`. [#77671](https://github.com/ClickHouse/ClickHouse/pull/77671) ([Azat Khuzhin](https://github.com/azat)). More fair max_processed_files_before_commit in S3Queue/AzureQueue. [#79363](https://github.com/ClickHouse/ClickHouse/pull/79363) ([Azat Khuzhin](https://github.com/azat)). +* Introduced threshold (regulated by setting `parallel_hash_join_threshold`) to fall back to the `hash` algorithm when the size of the right table is below the threshold. [#76185](https://github.com/ClickHouse/ClickHouse/pull/76185) ([Nikita Taranov](https://github.com/nickitat)). +* Now we use number of replicas to determine task size for reading with parallel replicas enabled. This provides better work distribution between replicas when the amount of data to read is not really big. [#78695](https://github.com/ClickHouse/ClickHouse/pull/78695) ([Nikita Taranov](https://github.com/nickitat)). +* Allow parallel merging of `uniqExact` states during the final stage of distributed aggregation. [#78703](https://github.com/ClickHouse/ClickHouse/pull/78703) ([Nikita Taranov](https://github.com/nickitat)). +* Fix possible performance degradation of the parallel merging of `uniqExact` states for aggregation with key. [#78724](https://github.com/ClickHouse/ClickHouse/pull/78724) ([Nikita Taranov](https://github.com/nickitat)). +* Reduce the number of List Blobs API calls to Azure storage. [#78860](https://github.com/ClickHouse/ClickHouse/pull/78860) ([Julia Kartseva](https://github.com/jkartseva)). +* Fix performance of the distributed INSERT SELECT with parallel replicas. [#79441](https://github.com/ClickHouse/ClickHouse/pull/79441) ([Azat Khuzhin](https://github.com/azat)). +* Prevent `LogSeriesLimiter` from doing cleanup on every construction, avoiding lock contention and performance regressions in high-concurrency scenarios. [#79864](https://github.com/ClickHouse/ClickHouse/pull/79864) ([filimonov](https://github.com/filimonov)). +* Speedup queries with trivial count optimization. [#79945](https://github.com/ClickHouse/ClickHouse/pull/79945) ([Raúl Marín](https://github.com/Algunenano)). +* Better inlining for some operations with `Decimal`. [#79999](https://github.com/ClickHouse/ClickHouse/pull/79999) ([Konstantin Bogdanov](https://github.com/thevar1able)). +* Set `input_format_parquet_bloom_filter_push_down` to true by default. Also, fix a mistake in the settings changes history. [#80058](https://github.com/ClickHouse/ClickHouse/pull/80058) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Optimized `ALTER ... DELETE` mutations for parts in which all rows should be deleted. Now, in such cases an empty part is created instead of original without executing a mutation. [#79307](https://github.com/ClickHouse/ClickHouse/pull/79307) ([Anton Popov](https://github.com/CurtizJ)). +* Avoid extra copying of the block during insertion into Compact part when possible. [#79536](https://github.com/ClickHouse/ClickHouse/pull/79536) ([Pavel Kruglov](https://github.com/Avogar)). +* Add setting `input_format_max_block_size_bytes` to limit blocks created in input formats in bytes. It can help to avoid high memory usage during data import when rows contains large values. [#79495](https://github.com/ClickHouse/ClickHouse/pull/79495) ([Pavel Kruglov](https://github.com/Avogar)). +* Remove guard pages for threads and async_socket_for_remote/use_hedge_requests. Change the allocation method in `FiberStack` from `mmap` to `aligned_alloc`. Since this splits VMAs and under heavy load vm.max_map_count can be reached. [#79147](https://github.com/ClickHouse/ClickHouse/pull/79147) ([Sema Checherinda](https://github.com/CheSema)). +* Lazy Materialization with parallel replicas. [#79401](https://github.com/ClickHouse/ClickHouse/pull/79401) ([Igor Nikonov](https://github.com/devcrafter)). + +#### Improvement +* Added an ability to apply lightweight deletes on the fly (with settings `lightweight_deletes_sync = 0`, `apply_mutations_on_fly = 1`. [#79281](https://github.com/ClickHouse/ClickHouse/pull/79281) ([Anton Popov](https://github.com/CurtizJ)). +* If data in the pretty format is displayed in the terminal, and a subsequent block has the same column widths, it can continue from the previous block, glue it to the previous block by moving the cursor up. This closes [#79333](https://github.com/ClickHouse/ClickHouse/issues/79333). The feature is controlled by the new setting, `output_format_pretty_glue_chunks`. [#79339](https://github.com/ClickHouse/ClickHouse/pull/79339) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Extend the `isIPAddressInRange` function to `String`, `IPv4`, `IPv6`, `Nullable(String)`, `Nullable(IPv4)`, and `Nullable(IPv6)` data types. [#78364](https://github.com/ClickHouse/ClickHouse/pull/78364) ([YjyJeff](https://github.com/YjyJeff)). +* Allow changing `PostgreSQL` engine connection pooler settings dynamically. [#78414](https://github.com/ClickHouse/ClickHouse/pull/78414) ([Samay Sharma](https://github.com/samay-sharma)). +* Allow to specify `_part_offset` in normal projection. This is the first step to build projection index. It can be used with [#58224](https://github.com/ClickHouse/ClickHouse/issues/58224) and can help improve #63207. [#78429](https://github.com/ClickHouse/ClickHouse/pull/78429) ([Amos Bird](https://github.com/amosbird)). +* Add new columns (`create_query` and `source`) for `system.named_collections`. Closes [#78179](https://github.com/ClickHouse/ClickHouse/issues/78179). [#78582](https://github.com/ClickHouse/ClickHouse/pull/78582) ([MikhailBurdukov](https://github.com/MikhailBurdukov)). +* Added a new field `condition` to system table `system.query_condition_cache`. It stores the plaintext condition whose hash is used as a key in the query condition cache. [#78671](https://github.com/ClickHouse/ClickHouse/pull/78671) ([Robert Schulze](https://github.com/rschu1ze)). +* Vector similarity indexes can now be created on top of `BFloat16` columns. [#78850](https://github.com/ClickHouse/ClickHouse/pull/78850) ([Robert Schulze](https://github.com/rschu1ze)). +* Support unix timestapms with fractional part in best effort `DateTime64` parsing. [#78908](https://github.com/ClickHouse/ClickHouse/pull/78908) ([Pavel Kruglov](https://github.com/Avogar)). +* In the storage `DeltaLake` delta-kernel implementation, fix for column mapping mode, add tests for schema evolution. [#78921](https://github.com/ClickHouse/ClickHouse/pull/78921) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Improve insert into `Variant` column in Values format by better conversion of values. [#78923](https://github.com/ClickHouse/ClickHouse/pull/78923) ([Pavel Kruglov](https://github.com/Avogar)). +* The `tokens` function was extended to accept an additional "tokenizer" argument plus further tokenizer-specific arguments. [#79001](https://github.com/ClickHouse/ClickHouse/pull/79001) ([Elmi Ahmadov](https://github.com/ahmadov)). +* The `SHOW CLUSTER` statement now expands macros (if any) in its argument. [#79006](https://github.com/ClickHouse/ClickHouse/pull/79006) ([arf42](https://github.com/arf42)). +* Hash functions now support `NULL`s inside arrays, tuples, and maps. (issues [#48365](https://github.com/ClickHouse/ClickHouse/issues/48365) and [#48623](https://github.com/ClickHouse/ClickHouse/issues/48623)). [#79008](https://github.com/ClickHouse/ClickHouse/pull/79008) ([Michael Kolupaev](https://github.com/al13n321)). +* Update cctz to 2025a. [#79043](https://github.com/ClickHouse/ClickHouse/pull/79043) ([Raúl Marín](https://github.com/Algunenano)). +* Change the default stderr processing for UDFs to "log_last". It's better for usability. [#79066](https://github.com/ClickHouse/ClickHouse/pull/79066) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Make tabs undo-able in the Web UI. This closes [#71284](https://github.com/ClickHouse/ClickHouse/issues/71284). [#79084](https://github.com/ClickHouse/ClickHouse/pull/79084) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Remove settings during `recoverLostReplica` same as it was done in: https://github.com/ClickHouse/ClickHouse/pull/78637. [#79113](https://github.com/ClickHouse/ClickHouse/pull/79113) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)). +* Add profile events: `ParquetReadRowGroups` and `ParquetPrunedRowGroups` to profile parquet index prune. [#79180](https://github.com/ClickHouse/ClickHouse/pull/79180) ([flynn](https://github.com/ucasfl)). +* Support `ALTER`ing database on cluster. [#79242](https://github.com/ClickHouse/ClickHouse/pull/79242) ([Tuan Pham Anh](https://github.com/tuanpach)). +* Explicitly skip missed runs of statistics collection for QueryMetricLog, otherwise the log will take a long time to catch up with the current time. [#79257](https://github.com/ClickHouse/ClickHouse/pull/79257) ([Mikhail Artemenko](https://github.com/Michicosun)). +* Some small optimizations for reading `Arrow`-based formats. [#79308](https://github.com/ClickHouse/ClickHouse/pull/79308) ([Bharat Nallan](https://github.com/bharatnc)). +* The setting `allow_archive_path_syntax` was marked as experimental by mistake. Add a test to prevent having experimental settings enabled by default. [#79320](https://github.com/ClickHouse/ClickHouse/pull/79320) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Made page cache settings adjustable on a per-query level. This is needed for faster experimentation and for the possibility of fine-tuning for high-throughput and low-latency queries. [#79337](https://github.com/ClickHouse/ClickHouse/pull/79337) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Do not print number tips in pretty formats for numbers that look like most of the 64-bit hashes. This closes [#79334](https://github.com/ClickHouse/ClickHouse/issues/79334). [#79338](https://github.com/ClickHouse/ClickHouse/pull/79338) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Colors of graphs on the advanced dashboards will be calculated from the hash of the corresponding query. This makes it easier to remember and locate a graph while scrolling the dashboard. [#79341](https://github.com/ClickHouse/ClickHouse/pull/79341) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Add asynchronous metric, `FilesystemCacheCapacity` - total capacity in the `cache` virtual filesystem. This is useful for global infrastructure monitoring. [#79348](https://github.com/ClickHouse/ClickHouse/pull/79348) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Optimize access to system.parts (read columns/indexes size only when requested). [#79352](https://github.com/ClickHouse/ClickHouse/pull/79352) ([Azat Khuzhin](https://github.com/azat)). +* Calculate the relevant fields for query `'SHOW CLUSTER '` instead of all fields. [#79368](https://github.com/ClickHouse/ClickHouse/pull/79368) ([Tuan Pham Anh](https://github.com/tuanpach)). +* Allow to specify storage settings for `DatabaseCatalog`. [#79407](https://github.com/ClickHouse/ClickHouse/pull/79407) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Support local storage in `DeltaLake`. [#79416](https://github.com/ClickHouse/ClickHouse/pull/79416) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Add a query level setting to enable delta-kernel-rs: `allow_experimental_delta_kernel_rs`. [#79418](https://github.com/ClickHouse/ClickHouse/pull/79418) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Fix possible endless loop when listing blobs from Azure/S3 blob storage. [#79425](https://github.com/ClickHouse/ClickHouse/pull/79425) ([Alexander Gololobov](https://github.com/davenger)). +* Add filesystem cache setting `max_size_ratio_to_total_space`. [#79460](https://github.com/ClickHouse/ClickHouse/pull/79460) ([Kseniia Sumarokova](https://github.com/kssenii)). +* For `clickhouse-benchmark` reconfigure `reconnect` option to take 0, 1 or N as values for reconnecting accordingly. [#79465](https://github.com/ClickHouse/ClickHouse/pull/79465) ([Sachin Kumar Singh](https://github.com/sachinkumarsingh092)). +* Allow `ALTER TABLE ... MOVE|REPLACE PARTITION` for tables on different `plain_rewritable` disks. [#79566](https://github.com/ClickHouse/ClickHouse/pull/79566) ([Julia Kartseva](https://github.com/jkartseva)). +* The vector similarity index is now also used if the reference vector is of type `Array(BFloat16)`. [#79745](https://github.com/ClickHouse/ClickHouse/pull/79745) ([Shankar Iyer](https://github.com/shankar-iyer)). +* Add last_error_message, last_error_trace and query_id to the system.error_log table. Related ticket [#75816](https://github.com/ClickHouse/ClickHouse/issues/75816). [#79836](https://github.com/ClickHouse/ClickHouse/pull/79836) ([Andrei Tinikov](https://github.com/Dolso)). +* Enable sending crash reports by default. This can be turned off in the server's configuration file. [#79838](https://github.com/ClickHouse/ClickHouse/pull/79838) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* System table `system.functions` now shows in which ClickHouse version functions were first introduced. [#79839](https://github.com/ClickHouse/ClickHouse/pull/79839) ([Robert Schulze](https://github.com/rschu1ze)). +* Added `access_control_improvements.enable_user_name_access_type` setting. This setting allows enabling/disabling of precise grants for users/roles, introduced in https://github.com/ClickHouse/ClickHouse/pull/72246. You may want to turn this setting off in case you have a cluster with the replicas older than 25.1. [#79842](https://github.com/ClickHouse/ClickHouse/pull/79842) ([pufit](https://github.com/pufit)). +* Proper implementation of `ASTSelectWithUnionQuery::clone()` method now takes into account `is_normalized` field as well. This might help with [#77569](https://github.com/ClickHouse/ClickHouse/issues/77569). [#79909](https://github.com/ClickHouse/ClickHouse/pull/79909) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)). +* Fix the inconsistent formatting of certain queries with the EXCEPT operator. If the left-hand side of the EXCEPT operator ends with `*`, the formatted query loses parentheses and is then parsed as a `*` with the `EXCEPT` modifier. These queries are found by the fuzzer and are unlikely to be found in practice. This closes [#79950](https://github.com/ClickHouse/ClickHouse/issues/79950). [#79952](https://github.com/ClickHouse/ClickHouse/pull/79952) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Small improvement in `JSON` type parsing by using cache of variants deserialization order. [#79984](https://github.com/ClickHouse/ClickHouse/pull/79984) ([Pavel Kruglov](https://github.com/Avogar)). +* Add setting `s3_slow_all_threads_after_network_error`. [#80035](https://github.com/ClickHouse/ClickHouse/pull/80035) ([Vitaly Baranov](https://github.com/vitlibar)). +* The logging level about the selected parts to merge was wrong (Information). Closes [#80061](https://github.com/ClickHouse/ClickHouse/issues/80061). [#80062](https://github.com/ClickHouse/ClickHouse/pull/80062) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* trace-visualizer: add runtime/share in tooltips and status messages. [#79040](https://github.com/ClickHouse/ClickHouse/pull/79040) ([Sergei Trifonov](https://github.com/serxa)). +* trace-visualizer: load data from clickhouse server. [#79042](https://github.com/ClickHouse/ClickHouse/pull/79042) ([Sergei Trifonov](https://github.com/serxa)). +* Add metrics on failing merges. [#79228](https://github.com/ClickHouse/ClickHouse/pull/79228) ([Miсhael Stetsyuk](https://github.com/mstetsyuk)). +* `clickhouse-benchmark` will display percentage based on the max iterations if specified. [#79346](https://github.com/ClickHouse/ClickHouse/pull/79346) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Add system.parts table visualizer. [#79437](https://github.com/ClickHouse/ClickHouse/pull/79437) ([Sergei Trifonov](https://github.com/serxa)). +* Add tool for query latency analyzing. [#79978](https://github.com/ClickHouse/ClickHouse/pull/79978) ([Sergei Trifonov](https://github.com/serxa)). + +#### Bug Fix (user-visible misbehavior in an official stable release) +* Fix renames of columns missing in part. [#76346](https://github.com/ClickHouse/ClickHouse/pull/76346) ([Anton Popov](https://github.com/CurtizJ)). +* A materialized view can start too late, e.g. after the Kafka table that streams to it. [#72123](https://github.com/ClickHouse/ClickHouse/pull/72123) ([Ilya Golshtein](https://github.com/ilejn)). +* Fix `SELECT` query rewriting during `VIEW` creation with enabled analyzer. closes [#75956](https://github.com/ClickHouse/ClickHouse/issues/75956). [#76356](https://github.com/ClickHouse/ClickHouse/pull/76356) ([Dmitry Novik](https://github.com/novikd)). +* Fix applying `async_insert` from server (via `apply_settings_from_server`) (previously leads to `Unknown packet 11 from server` errors on the client). [#77578](https://github.com/ClickHouse/ClickHouse/pull/77578) ([Azat Khuzhin](https://github.com/azat)). +* Fixed refreshable materialized view in Replicated database not working on newly added replicas. [#77774](https://github.com/ClickHouse/ClickHouse/pull/77774) ([Michael Kolupaev](https://github.com/al13n321)). +* Fixed refreshable materialized views breaking backups. [#77893](https://github.com/ClickHouse/ClickHouse/pull/77893) ([Michael Kolupaev](https://github.com/al13n321)). +* Fix old firing logical error for `transform`. [#78247](https://github.com/ClickHouse/ClickHouse/pull/78247) ([Yarik Briukhovetskyi](https://github.com/yariks5s)). +* Fix some cases where secondary index was not applied with analyzer. Fixes [#65607](https://github.com/ClickHouse/ClickHouse/issues/65607) , fixes [#69373](https://github.com/ClickHouse/ClickHouse/issues/69373). [#78485](https://github.com/ClickHouse/ClickHouse/pull/78485) ([Nikolai Kochetov](https://github.com/KochetovNicolai)). +* Fix dumping profile events (`NetworkSendElapsedMicroseconds`/`NetworkSendBytes`) for HTTP protocol with compression enabled (the error should not be more then the buffer size, usually around 1MiB). [#78516](https://github.com/ClickHouse/ClickHouse/pull/78516) ([Azat Khuzhin](https://github.com/azat)). +* Fix analyzer producing LOGICAL_ERROR when JOIN ... USING involves ALIAS column - should produce appropriate error. [#78618](https://github.com/ClickHouse/ClickHouse/pull/78618) ([Yakov Olkhovskiy](https://github.com/yakov-olkhovskiy)). +* Fix analyzer: CREATE VIEW ... ON CLUSTER fails if SELECT contains positional arguments. [#78663](https://github.com/ClickHouse/ClickHouse/pull/78663) ([Yakov Olkhovskiy](https://github.com/yakov-olkhovskiy)). +* Fix `Block structure mismatch` error in case of `INSERT SELECT` into table a function with schema inference if `SELECT` has scalar subqueries. [#78677](https://github.com/ClickHouse/ClickHouse/pull/78677) ([Pervakov Grigorii](https://github.com/GrigoryPervakov)). +* Fix analyzer: with prefer_global_in_and_join=1 for Distributed table in SELECT query `in` function should be replaced by `globalIn`. [#78749](https://github.com/ClickHouse/ClickHouse/pull/78749) ([Yakov Olkhovskiy](https://github.com/yakov-olkhovskiy)). +* Fixed several types of `SELECT` queries that read from tables with `MongoDB` engine or `mongodb` table function: queries with implicit conversion of const value in `WHERE` clause (e.g. `WHERE datetime = '2025-03-10 00:00:00'`) ; queries with `LIMIT` and `GROUP BY`. Previously, they could return the wrong result. [#78777](https://github.com/ClickHouse/ClickHouse/pull/78777) ([Anton Popov](https://github.com/CurtizJ)). +* Fix conversion between different JSON types. Not it's performed by simple cast through convertion to/from String. It's less effective but 100% accurate. [#78807](https://github.com/ClickHouse/ClickHouse/pull/78807) ([Pavel Kruglov](https://github.com/Avogar)). +* Fix logical error during convertion of Dynamic type to Interval. [#78813](https://github.com/ClickHouse/ClickHouse/pull/78813) ([Pavel Kruglov](https://github.com/Avogar)). +* Fix column rollback on JSON parsing error. [#78836](https://github.com/ClickHouse/ClickHouse/pull/78836) ([Pavel Kruglov](https://github.com/Avogar)). +* Fix 'bad cast' error when join using constant alias column. [#78848](https://github.com/ClickHouse/ClickHouse/pull/78848) ([Vladimir Cherkasov](https://github.com/vdimir)). +* Don't allow prewhere in materialized view on columns with different types in view and target table. [#78889](https://github.com/ClickHouse/ClickHouse/pull/78889) ([Pavel Kruglov](https://github.com/Avogar)). +* Fix logical error during parsing of bad binary data of Variant column. [#78982](https://github.com/ClickHouse/ClickHouse/pull/78982) ([Pavel Kruglov](https://github.com/Avogar)). +* Throw an exception when the parquet batch size is set to 0. Previously when output_format_parquet_batch_size = 0 ClickHouse would hang. Now this behavior is fixed. [#78991](https://github.com/ClickHouse/ClickHouse/pull/78991) ([daryawessely](https://github.com/daryawessely)). +* Fix deserialization of variant discriminators with basic format in compact parts. It was introduced in https://github.com/ClickHouse/ClickHouse/pull/55518. [#79000](https://github.com/ClickHouse/ClickHouse/pull/79000) ([Pavel Kruglov](https://github.com/Avogar)). +* Dictionaries of type `complex_key_ssd_cache` now reject zero or negative `block_size` and `write_buffer_size` parameters (issue [#78314](https://github.com/ClickHouse/ClickHouse/issues/78314)). [#79028](https://github.com/ClickHouse/ClickHouse/pull/79028) ([Elmi Ahmadov](https://github.com/ahmadov)). +* Avoid using Field for non-aggregated columns in SummingMergeTree. It could lead to unexpected errors with Dynamic/Variant types used in SummingMergeTree. [#79051](https://github.com/ClickHouse/ClickHouse/pull/79051) ([Pavel Kruglov](https://github.com/Avogar)). +* Fix read from Materialized View with Distributed destination table and different header in analyzer. [#79059](https://github.com/ClickHouse/ClickHouse/pull/79059) ([Pavel Kruglov](https://github.com/Avogar)). +* Fixes a bug where `arrayUnion()` returned extra (incorrect) values on tables that had batch inserts. Fixes [#75057](https://github.com/ClickHouse/ClickHouse/issues/75057). [#79079](https://github.com/ClickHouse/ClickHouse/pull/79079) ([Peter Nguyen](https://github.com/petern48)). +* Fix segfault in `OpenSSLInitializer`. Closes [#79092](https://github.com/ClickHouse/ClickHouse/issues/79092). [#79097](https://github.com/ClickHouse/ClickHouse/pull/79097) ([Konstantin Bogdanov](https://github.com/thevar1able)). +* Always set prefix for S3 ListObject. [#79114](https://github.com/ClickHouse/ClickHouse/pull/79114) ([Azat Khuzhin](https://github.com/azat)). +* Fixes a bug where arrayUnion() returned extra (incorrect) values on tables that had batch inserts. Fixes [#79157](https://github.com/ClickHouse/ClickHouse/issues/79157). [#79158](https://github.com/ClickHouse/ClickHouse/pull/79158) ([Peter Nguyen](https://github.com/petern48)). +* Fix logical error after filter pushdown. [#79164](https://github.com/ClickHouse/ClickHouse/pull/79164) ([Pervakov Grigorii](https://github.com/GrigoryPervakov)). +* Fix DeltaLake table engine with delta-kernel implementation being used with http based endpoints, fix NOSIGN. Closes [#78124](https://github.com/ClickHouse/ClickHouse/issues/78124). [#79203](https://github.com/ClickHouse/ClickHouse/pull/79203) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Keeper fix: Avoid triggering watches on failed multi requests. [#79247](https://github.com/ClickHouse/ClickHouse/pull/79247) ([Antonio Andelic](https://github.com/antonio2368)). +* Forbid Dynamic and JSON types in IN. With current implementation of `IN` it can lead to incorrect results. Proper support of this types in `IN` is complicated and can be done in future. [#79282](https://github.com/ClickHouse/ClickHouse/pull/79282) ([Pavel Kruglov](https://github.com/Avogar)). +* Fix check for duplicate paths in JSON type parsing. [#79317](https://github.com/ClickHouse/ClickHouse/pull/79317) ([Pavel Kruglov](https://github.com/Avogar)). +* Fix SecureStreamSocket connection issues. [#79383](https://github.com/ClickHouse/ClickHouse/pull/79383) ([Konstantin Bogdanov](https://github.com/thevar1able)). +* Fix loading of plain_rewritable disks containing data. [#79439](https://github.com/ClickHouse/ClickHouse/pull/79439) ([Julia Kartseva](https://github.com/jkartseva)). +* Fix crash in dynamic subcolumns discovery in Wide parts in MergeTree. [#79466](https://github.com/ClickHouse/ClickHouse/pull/79466) ([Pavel Kruglov](https://github.com/Avogar)). +* Verify the table name's length only for initial create queries. Do not verify this for secondary creates to avoid backward compatibility issues. [#79488](https://github.com/ClickHouse/ClickHouse/pull/79488) ([Miсhael Stetsyuk](https://github.com/mstetsyuk)). +* Fixed error `Block structure mismatch` in several cases with tables with sparse columns. [#79491](https://github.com/ClickHouse/ClickHouse/pull/79491) ([Anton Popov](https://github.com/CurtizJ)). +* Fix two cases of "Logical Error: Can't set alias of * of Asterisk on alias". [#79505](https://github.com/ClickHouse/ClickHouse/pull/79505) ([Raúl Marín](https://github.com/Algunenano)). +* Fix using incorrect paths when renaming an Atomic database. [#79569](https://github.com/ClickHouse/ClickHouse/pull/79569) ([Tuan Pham Anh](https://github.com/tuanpach)). +* Fix order by JSON column with other columns. [#79591](https://github.com/ClickHouse/ClickHouse/pull/79591) ([Pavel Kruglov](https://github.com/Avogar)). +* Fix result duplication when reading from remote with both `use_hedged_requests` and `allow_experimental_parallel_reading_from_replicas` disabled. [#79599](https://github.com/ClickHouse/ClickHouse/pull/79599) ([Eduard Karacharov](https://github.com/korowa)). +* Fix crash in delta-kernel implementation when using unity catalog. [#79677](https://github.com/ClickHouse/ClickHouse/pull/79677) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Resolve macros for autodiscovery clusters. [#79696](https://github.com/ClickHouse/ClickHouse/pull/79696) ([Anton Ivashkin](https://github.com/ianton-ru)). +* Handle incorrectly configured page_cache_limits suitably. [#79805](https://github.com/ClickHouse/ClickHouse/pull/79805) ([Bharat Nallan](https://github.com/bharatnc)). +* Fixes the result of SQL function `formatDateTime` if a variable-size formatter (e.g. `%W` aka. weekday `Monday` `Tuesday`, etc.) is followed by a compound formatter (a formatter that prints multiple components at once, e.g. `%D` aka. the American date `05/04/25`). [#79835](https://github.com/ClickHouse/ClickHouse/pull/79835) ([Robert Schulze](https://github.com/rschu1ze)). +* IcebergS3 supports count optimization, but IcebergS3Cluster does not. As a result, the count() result returned in cluster mode may be a multiple of the number of replicas. [#79844](https://github.com/ClickHouse/ClickHouse/pull/79844) ([wxybear](https://github.com/wxybear)). +* Fixes AMBIGUOUS_COLUMN_NAME error with lazy materialization when no columns are used for query execution until projection. Example, SELECT * FROM t ORDER BY rand() LIMIT 5. [#79926](https://github.com/ClickHouse/ClickHouse/pull/79926) ([Igor Nikonov](https://github.com/devcrafter)). +* Hide password for query `CREATE DATABASE datalake ENGINE = DataLakeCatalog(\'http://catalog:8181\', \'admin\', \'password\')`. [#79941](https://github.com/ClickHouse/ClickHouse/pull/79941) ([Han Fei](https://github.com/hanfei1991)). +* Allow to specify an alias in JOIN USING. Specify this alias in case the column was renamed (e.g., because of ARRAY JOIN). Fixes [#73707](https://github.com/ClickHouse/ClickHouse/issues/73707). [#79942](https://github.com/ClickHouse/ClickHouse/pull/79942) ([Nikolai Kochetov](https://github.com/KochetovNicolai)). +* Allow materialized views with UNIONs to work correctly on new replicas. [#80037](https://github.com/ClickHouse/ClickHouse/pull/80037) ([Samay Sharma](https://github.com/samay-sharma)). +* Format specifier `%e` in SQL function `parseDateTime` now recognizes single-digit days (e.g. `3`), whereas it previously required space padding (e.g. ` 3`). This makes its behavior compatible with MySQL. To retain the previous behaviour, set setting `parsedatetime_e_requires_space_padding = 1`. (issue [#78243](https://github.com/ClickHouse/ClickHouse/issues/78243)). [#80057](https://github.com/ClickHouse/ClickHouse/pull/80057) ([Robert Schulze](https://github.com/rschu1ze)). +* Fix warnings `Cannot find 'kernel' in '[...]/memory.stat'` in ClickHouse's log (issue [#77410](https://github.com/ClickHouse/ClickHouse/issues/77410)). [#80129](https://github.com/ClickHouse/ClickHouse/pull/80129) ([Robert Schulze](https://github.com/rschu1ze)). +* Check stack size in FunctionComparison to avoid stack overflow crash. [#78208](https://github.com/ClickHouse/ClickHouse/pull/78208) ([Julia Kartseva](https://github.com/jkartseva)). +* Fix race during SELECT from `system.workloads`. [#78743](https://github.com/ClickHouse/ClickHouse/pull/78743) ([Sergei Trifonov](https://github.com/serxa)). +* Fix: lazy materialization in distributed queries. [#78815](https://github.com/ClickHouse/ClickHouse/pull/78815) ([Igor Nikonov](https://github.com/devcrafter)). +* Fix `Array(Bool)` to `Array(FixedString)` conversion. [#78863](https://github.com/ClickHouse/ClickHouse/pull/78863) ([Nikita Taranov](https://github.com/nickitat)). +* Make parquet version selection less confusing. [#78818](https://github.com/ClickHouse/ClickHouse/pull/78818) ([Michael Kolupaev](https://github.com/al13n321)). +* Fix `ReservoirSampler` self-merging. [#79031](https://github.com/ClickHouse/ClickHouse/pull/79031) ([Nikita Taranov](https://github.com/nickitat)). +* Fix storage of insertion table in client context. [#79046](https://github.com/ClickHouse/ClickHouse/pull/79046) ([Pervakov Grigorii](https://github.com/GrigoryPervakov)). +* Fix the destruction order of data members of `AggregatingSortedAlgorithm` and `SummingSortedAlgorithm`. [#79056](https://github.com/ClickHouse/ClickHouse/pull/79056) ([Nikita Taranov](https://github.com/nickitat)). +* `enable_user_name_access_type` must not affect `DEFINER` access type. [#80026](https://github.com/ClickHouse/ClickHouse/pull/80026) ([pufit](https://github.com/pufit)). +* Query to system database can hang if system database metadata located in keeper. [#79304](https://github.com/ClickHouse/ClickHouse/pull/79304) ([Mikhail Artemenko](https://github.com/Michicosun)). + +#### Build/Testing/Packaging Improvement +* Make it possible to reuse the built `chcache` binary instead of always rebuilding it. [#78851](https://github.com/ClickHouse/ClickHouse/pull/78851) ([János Benjamin Antal](https://github.com/antaljanosbenjamin)). +* Add NATS pause waiting. [#78987](https://github.com/ClickHouse/ClickHouse/pull/78987) ([Dmitry Novikov](https://github.com/dmitry-sles-novikov)). +* Fix for incorrectly publishing ARM build as amd64compat. [#79122](https://github.com/ClickHouse/ClickHouse/pull/79122) ([Alexander Gololobov](https://github.com/davenger)). +* Use generated ahead of time assembly for OpenSSL. [#79386](https://github.com/ClickHouse/ClickHouse/pull/79386) ([Konstantin Bogdanov](https://github.com/thevar1able)). +* Fixes to allow building with `clang20`. [#79588](https://github.com/ClickHouse/ClickHouse/pull/79588) ([Konstantin Bogdanov](https://github.com/thevar1able)). +* `chcache`: Rust caching support. [#78691](https://github.com/ClickHouse/ClickHouse/pull/78691) ([Konstantin Bogdanov](https://github.com/thevar1able)). +* Add unwind information for `zstd` assembly files. [#79288](https://github.com/ClickHouse/ClickHouse/pull/79288) ([Michael Kolupaev](https://github.com/al13n321)). + + +### ClickHouse release 25.4, 2025-04-22 {#254} + +#### Backward Incompatible Change +* Check if all columns in a materialized view match the target table when `allow_materialized_view_with_bad_select` is `false`. [#74481](https://github.com/ClickHouse/ClickHouse/pull/74481) ([Christoph Wurm](https://github.com/cwurm)). +* Fix cases where `dateTrunc` is used with negative Date/DateTime arguments. [#77622](https://github.com/ClickHouse/ClickHouse/pull/77622) ([Yarik Briukhovetskyi](https://github.com/yariks5s)). +* The legacy `MongoDB` integration has been removed. Server setting `use_legacy_mongodb_integration` became obsolete and now does nothing. [#77895](https://github.com/ClickHouse/ClickHouse/pull/77895) ([Robert Schulze](https://github.com/rschu1ze)). +* Enhance `SummingMergeTree` validation to skip aggregation for columns used in partition or sort keys. [#78022](https://github.com/ClickHouse/ClickHouse/pull/78022) ([Pervakov Grigorii](https://github.com/GrigoryPervakov)). + +#### New Feature +* Added CPU slot scheduling for workloads, see [the docs](https://clickhouse.com/docs/operations/workload-scheduling#cpu_scheduling) for details. [#77595](https://github.com/ClickHouse/ClickHouse/pull/77595) ([Sergei Trifonov](https://github.com/serxa)). +* `clickhouse-local` will retain its databases after restart if you specify the `--path` command line argument. This closes [#50647](https://github.com/ClickHouse/ClickHouse/issues/50647). This closes [#49947](https://github.com/ClickHouse/ClickHouse/issues/49947). [#71722](https://github.com/ClickHouse/ClickHouse/pull/71722) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Reject queries when the server is overloaded. The decision is made based on the ratio of wait time (`OSCPUWaitMicroseconds`) to busy time (`OSCPUVirtualTimeMicroseconds`). The query is dropped with some probability, when this ratio is between `min_os_cpu_wait_time_ratio_to_throw` and `max_os_cpu_wait_time_ratio_to_throw` (those are query level settings). [#63206](https://github.com/ClickHouse/ClickHouse/pull/63206) ([Alexey Katsman](https://github.com/alexkats)). +* Time travel in `Iceberg`: add setting to query `Iceberg` tables as of a specific timestamp. [#71072](https://github.com/ClickHouse/ClickHouse/pull/71072) ([Brett Hoerner](https://github.com/bretthoerner)). [#77439](https://github.com/ClickHouse/ClickHouse/pull/77439) ([Daniil Ivanik](https://github.com/divanik)). +* An in-memory cache for `Iceberg` metadata, which stores manifest files/list and `metadata.json` to speed up queries. [#77156](https://github.com/ClickHouse/ClickHouse/pull/77156) ([Han Fei](https://github.com/hanfei1991)). +* Support `DeltaLake` table engine for Azure Blob Storage. Fixes [#68043](https://github.com/ClickHouse/ClickHouse/issues/68043). [#74541](https://github.com/ClickHouse/ClickHouse/pull/74541) ([Smita Kulkarni](https://github.com/SmitaRKulkarni)). +* Added an in-memory cache for deserialized vector similarity indexes. This should make repeated approximate nearest neighbor (ANN) search queries faster. The size of the new cache is controlled by server settings `vector_similarity_index_cache_size` and `vector_similarity_index_cache_max_entries`. This feature supersedes the skipping index cache feature of earlier releases. [#77905](https://github.com/ClickHouse/ClickHouse/pull/77905) ([Shankar Iyer](https://github.com/shankar-iyer)). +* Support partition pruning in DeltaLake. [#78486](https://github.com/ClickHouse/ClickHouse/pull/78486) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Support for a background refresh in readonly `MergeTree` tables which allows querying updateable tables with an infinite amount of distributed readers (ClickHouse-native data lake). [#76467](https://github.com/ClickHouse/ClickHouse/pull/76467) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Support using custom disks to store databases metadata files. Currently it can be configured only on a global server level. [#77365](https://github.com/ClickHouse/ClickHouse/pull/77365) ([Tuan Pham Anh](https://github.com/tuanpach)). +* Support ALTER TABLE ... ATTACH|DETACH|MOVE|REPLACE PARTITION for the plain_rewritable disk. [#77406](https://github.com/ClickHouse/ClickHouse/pull/77406) ([Julia Kartseva](https://github.com/jkartseva)). +* Add table settings for `SASL` configuration and credentials to the `Kafka` table engine. This allows configuring SASL-based authentication to Kafka and Kafka-compatible systems directly in the CREATE TABLE statement rather than having to use configuration files or named collections. [#78810](https://github.com/ClickHouse/ClickHouse/pull/78810) ([Christoph Wurm](https://github.com/cwurm)). +* Allow setting `default_compression_codec` for MergeTree tables: it is used when the CREATE query does not explicitly define one for the given columns. This closes [#42005](https://github.com/ClickHouse/ClickHouse/issues/42005). [#66394](https://github.com/ClickHouse/ClickHouse/pull/66394) ([gvoelfin](https://github.com/gvoelfin)). +* Add `bind_host` setting in the clusters configuration so that ClickHouse can use a specific network for distributed connections. [#74741](https://github.com/ClickHouse/ClickHouse/pull/74741) ([Todd Yocum](https://github.com/toddyocum)). +* Introduce a new column, `parametrized_view_parameters` in `system.tables`. Closes https://github.com/clickhouse/clickhouse/issues/66756. [#75112](https://github.com/ClickHouse/ClickHouse/pull/75112) ([NamNguyenHoai](https://github.com/NamHoaiNguyen)). +* Allow changing a database comment. Closes [#73351](https://github.com/ClickHouse/ClickHouse/issues/73351) ### Documentation entry for user-facing changes. [#75622](https://github.com/ClickHouse/ClickHouse/pull/75622) ([NamNguyenHoai](https://github.com/NamHoaiNguyen)). +* Support `SCRAM-SHA-256` authentication in the PostgreSQL compatibility protocol. [#76839](https://github.com/ClickHouse/ClickHouse/pull/76839) ([scanhex12](https://github.com/scanhex12)). +* Add functions `arrayLevenshteinDistance`, `arrayLevenshteinDistanceWeighted`, and `arraySimilarity`. [#77187](https://github.com/ClickHouse/ClickHouse/pull/77187) ([Mikhail f. Shiryaev](https://github.com/Felixoid)). +* The setting `parallel_distributed_insert_select` makes effect for `INSERT SELECT` into `ReplicatedMergeTree` (previously it required Distribued tables). [#78041](https://github.com/ClickHouse/ClickHouse/pull/78041) ([Igor Nikonov](https://github.com/devcrafter)). +* Introduce `toInterval` function. This function accepts 2 arguments (value and unit), and converts the value to a specific `Interval` type. [#78723](https://github.com/ClickHouse/ClickHouse/pull/78723) ([Andrew Davis](https://github.com/pulpdrew)). +* Add several convenient ways to resolve root `metadata.json` file in an iceberg table function and engine. Closes [#78455](https://github.com/ClickHouse/ClickHouse/issues/78455). [#78475](https://github.com/ClickHouse/ClickHouse/pull/78475) ([Daniil Ivanik](https://github.com/divanik)). +* Support password based auth in SSH protocol in ClickHouse. [#78586](https://github.com/ClickHouse/ClickHouse/pull/78586) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)). + +#### Experimental Feature +* Support correlated subqueries as an argument of `EXISTS` expression in the `WHERE` clause. Closes [#72459](https://github.com/ClickHouse/ClickHouse/issues/72459). [#76078](https://github.com/ClickHouse/ClickHouse/pull/76078) ([Dmitry Novik](https://github.com/novikd)). +* Functions `sparseGrams` and `sparseGramsHashes` with ASCII and UTF8 versions added. Author: [scanhex12](https://github.com/scanhex12). [#78176](https://github.com/ClickHouse/ClickHouse/pull/78176) ([Pervakov Grigorii](https://github.com/GrigoryPervakov)). Do not use it: the implementation will change in the next versions. + +#### Performance Improvement +* Optimize performance with lazy columns, that read the data after ORDER BY and LIMIT. [#55518](https://github.com/ClickHouse/ClickHouse/pull/55518) ([Xiaozhe Yu](https://github.com/wudidapaopao)). +* Enabled the query condition cache by default. [#79080](https://github.com/ClickHouse/ClickHouse/pull/79080) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Speed-up building JOIN result by de-virtualizing calls to `col->insertFrom()`. [#77350](https://github.com/ClickHouse/ClickHouse/pull/77350) ([Alexander Gololobov](https://github.com/davenger)). +* Merge equality conditions from filter query plan step into JOIN condition if possible to allow using them as hash table keys. [#78877](https://github.com/ClickHouse/ClickHouse/pull/78877) ([Dmitry Novik](https://github.com/novikd)). +* Use dynamic sharding for JOIN if the JOIN key is a prefix of PK for both parts. This optimization is enabled with `query_plan_join_shard_by_pk_ranges` setting (disabled by default). [#74733](https://github.com/ClickHouse/ClickHouse/pull/74733) ([Nikolai Kochetov](https://github.com/KochetovNicolai)). +* Support `Iceberg` data pruning based on lower and upper boundary values for columns. Fixes [#77638](https://github.com/ClickHouse/ClickHouse/issues/77638). [#78242](https://github.com/ClickHouse/ClickHouse/pull/78242) ([alesapin](https://github.com/alesapin)). +* Implement trivial count optimization for `Iceberg`. Now queries with `count()` and without any filters should be faster. Closes [#77639](https://github.com/ClickHouse/ClickHouse/issues/77639). [#78090](https://github.com/ClickHouse/ClickHouse/pull/78090) ([alesapin](https://github.com/alesapin)). +* Add ability to configure the number of columns that merges can flush in parallel using `max_merge_delayed_streams_for_parallel_write` (this should reduce memory usage for vertical merges to S3 about 25x times). [#77922](https://github.com/ClickHouse/ClickHouse/pull/77922) ([Azat Khuzhin](https://github.com/azat)). +* Disable `filesystem_cache_prefer_bigger_buffer_size` when the cache is used passively, such as for merges. This lowers memory consumption on merges. [#77898](https://github.com/ClickHouse/ClickHouse/pull/77898) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Now we use number of replicas to determine task size for reading with parallel replicas enabled. This provides better work distribution between replicas when the amount of data to read is not really big. [#78695](https://github.com/ClickHouse/ClickHouse/pull/78695) ([Nikita Taranov](https://github.com/nickitat)). +* Support asynchronous IO prefetch for the `ORC` format, which improves overall performance by hiding remote IO latency. [#70534](https://github.com/ClickHouse/ClickHouse/pull/70534) ([李扬](https://github.com/taiyang-li)). +* Preallocate memory used by asynchronous inserts to improve performance. [#74945](https://github.com/ClickHouse/ClickHouse/pull/74945) ([Ilya Golshtein](https://github.com/ilejn)). +* Decrease the amount of Keeper requests by eliminating the use of single `get` requests, which could have caused a significant load on Keeper with the increased number of replicas, in places where `multiRead` is available. [#56862](https://github.com/ClickHouse/ClickHouse/pull/56862) ([Nikolay Degterinsky](https://github.com/evillique)). +* A marginal optimization for running functions on Nullable arguments. [#76489](https://github.com/ClickHouse/ClickHouse/pull/76489) ([李扬](https://github.com/taiyang-li)). +* Optimize `arraySort`. [#76850](https://github.com/ClickHouse/ClickHouse/pull/76850) ([李扬](https://github.com/taiyang-li)). +* Merge marks of the same part and write them to the query condition cache at one time to reduce the consumption of locks. [#77377](https://github.com/ClickHouse/ClickHouse/pull/77377) ([zhongyuankai](https://github.com/zhongyuankai)). +* Optimize `s3Cluster` performance for queries with one bracket expansion. [#77686](https://github.com/ClickHouse/ClickHouse/pull/77686) ([Tomáš Hromada](https://github.com/gyfis)). +* Optimize order by single Nullable or LowCardinality columns. [#77789](https://github.com/ClickHouse/ClickHouse/pull/77789) ([李扬](https://github.com/taiyang-li)). +* Optimize memory usage of the `Native` format. [#78442](https://github.com/ClickHouse/ClickHouse/pull/78442) ([Azat Khuzhin](https://github.com/azat)). +* Trivial optimization: do not rewrite `count(if(...))` to `countIf` if a type cast is required. Close [#78564](https://github.com/ClickHouse/ClickHouse/issues/78564). [#78565](https://github.com/ClickHouse/ClickHouse/pull/78565) ([李扬](https://github.com/taiyang-li)). +* The `hasAll` function can now take advantage of the `tokenbf_v1`, `ngrambf_v1` full-text skipping indices. [#77662](https://github.com/ClickHouse/ClickHouse/pull/77662) ([UnamedRus](https://github.com/UnamedRus)). +* Vector similarity index could over-allocate main memory by up to 2x. This fix reworks the memory allocation strategy, reducing the memory consumption and improving the effectiveness of the vector similarity index cache. (issue [#78056](https://github.com/ClickHouse/ClickHouse/issues/78056)). [#78394](https://github.com/ClickHouse/ClickHouse/pull/78394) ([Shankar Iyer](https://github.com/shankar-iyer)). +* Introduce a setting `schema_type` for `system.metric_log` table with schema type. There are three allowed schemas: `wide` -- current schema, each metric/event in a separate column (most effective for reads of separate columns), `transposed` -- similar to `system.asynchronous_metric_log`, metrics/events are stored as rows, and the most interesting `transposed_with_wide_view` -- create underlying table with `transposed` schema, but also introduce a view with `wide` schema which translates queries to underlying table. In `transposed_with_wide_view` subsecond resolution for view is not supported, `event_time_microseconds` is just an alias for backward compatibility. [#78412](https://github.com/ClickHouse/ClickHouse/pull/78412) ([alesapin](https://github.com/alesapin)). + +#### Improvement +* Serialize query plan for `Distributed` queries. A new setting `serialize_query_plan` is added. When enabled, queries from `Distributed` table will use a serialized query plan for remote query execution. This introduces a new packet type to TCP protocol, `true` should be added to the server config to allow processing this packet. [#69652](https://github.com/ClickHouse/ClickHouse/pull/69652) ([Nikolai Kochetov](https://github.com/KochetovNicolai)). +* Support `JSON` type and subcolumns reading from views. [#76903](https://github.com/ClickHouse/ClickHouse/pull/76903) ([Pavel Kruglov](https://github.com/Avogar)). +* Support ALTER DATABASE ... ON CLUSTER. [#79242](https://github.com/ClickHouse/ClickHouse/pull/79242) ([Tuan Pham Anh](https://github.com/tuanpach)). +* Refreshes of refreshable materialized views now appear in `system.query_log`. [#71333](https://github.com/ClickHouse/ClickHouse/pull/71333) ([Michael Kolupaev](https://github.com/al13n321)). +* User-defined functions (UDFs) can now be marked as deterministic via a new setting in their configuration. Also, the query cache now checks if UDFs called within a query are deterministic. If this is the case, it caches the query result. (Issue [#59988](https://github.com/ClickHouse/ClickHouse/issues/59988)). [#77769](https://github.com/ClickHouse/ClickHouse/pull/77769) ([Jimmy Aguilar Mena](https://github.com/Ergus)). +* Enabled a backoff logic for all types of replicated tasks. It will provide the ability to reduce CPU usage, memory usage, and log file sizes. Added new settings `max_postpone_time_for_failed_replicated_fetches_ms`, `max_postpone_time_for_failed_replicated_merges_ms` and `max_postpone_time_for_failed_replicated_tasks_ms` which are similar to `max_postpone_time_for_failed_mutations_ms`. [#74576](https://github.com/ClickHouse/ClickHouse/pull/74576) ([MikhailBurdukov](https://github.com/MikhailBurdukov)). +* Add `query_id` to `system.errors`. Closes [#75815](https://github.com/ClickHouse/ClickHouse/issues/75815). [#76581](https://github.com/ClickHouse/ClickHouse/pull/76581) ([Vladimir Baikov](https://github.com/bkvvldmr)). +* Adding support for converting `UInt128` to `IPv6`. This allows the `bitAnd` operation and arithmatics for `IPv6` and conversion back to `IPv6`. Closes [#76752](https://github.com/ClickHouse/ClickHouse/issues/76752). This allows the result from `bitAnd` operation on `IPv6` to be converted back to `IPv6`, as well. See also [#57707](https://github.com/ClickHouse/ClickHouse/pull/57707). [#76928](https://github.com/ClickHouse/ClickHouse/pull/76928) ([Muzammil Abdul Rehman](https://github.com/muzammilar)). +* Don't parse special `Bool` values in text formats inside `Variant` type by default. It can be enabled using setting `allow_special_bool_values_inside_variant`. [#76974](https://github.com/ClickHouse/ClickHouse/pull/76974) ([Pavel Kruglov](https://github.com/Avogar)). +* Support configurable per task waiting time of low `priority` query in session level and in server level. [#77013](https://github.com/ClickHouse/ClickHouse/pull/77013) ([VicoWu](https://github.com/VicoWu)). +* Implement comparison for values of JSON data type. Now JSON objects can be compared similarly to Maps. [#77397](https://github.com/ClickHouse/ClickHouse/pull/77397) ([Pavel Kruglov](https://github.com/Avogar)). +* Better permission support by `system.kafka_consumers`. Forward internal `librdkafka` errors (worth noting that this library is a crap). [#77700](https://github.com/ClickHouse/ClickHouse/pull/77700) ([Ilya Golshtein](https://github.com/ilejn)). +* Added validation for the settings of the Buffer table engine. [#77840](https://github.com/ClickHouse/ClickHouse/pull/77840) ([Pervakov Grigorii](https://github.com/GrigoryPervakov)). +* Add config `enable_hdfs_pread` to enable or disable pread in `HDFS`. [#77885](https://github.com/ClickHouse/ClickHouse/pull/77885) ([kevinyhzou](https://github.com/KevinyhZou)). +* Add profile events for number of zookeeper `multi` read and write requests. [#77888](https://github.com/ClickHouse/ClickHouse/pull/77888) ([JackyWoo](https://github.com/JackyWoo)). +* Allow creating and inserting into temporary tables when `disable_insertion_and_mutation` is on. [#77901](https://github.com/ClickHouse/ClickHouse/pull/77901) ([Xu Jia](https://github.com/XuJia0210)). +* Decrease `max_insert_delayed_streams_for_parallel_write` (to 100). [#77919](https://github.com/ClickHouse/ClickHouse/pull/77919) ([Azat Khuzhin](https://github.com/azat)). +* Fix year parsing in Joda syntax (this is from the Java world if you're wondering) like `yyy`. [#77973](https://github.com/ClickHouse/ClickHouse/pull/77973) ([李扬](https://github.com/taiyang-li)). +* Attaching parts of `MergeTree` tables will be performed in their block order, which is important for special merging algorithms, such as `ReplacingMergeTree`. This closes [#71009](https://github.com/ClickHouse/ClickHouse/issues/71009). [#77976](https://github.com/ClickHouse/ClickHouse/pull/77976) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Query masking rules are now able to throw a `LOGICAL_ERROR` in case if the match happened. This will help to check if pre-defined password is leaking anywhere in logs. [#78094](https://github.com/ClickHouse/ClickHouse/pull/78094) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)). +* Added column `index_length_column` to `information_schema.tables` for better compatibility with MySQL. [#78119](https://github.com/ClickHouse/ClickHouse/pull/78119) ([Paweł Zakrzewski](https://github.com/KrzaQ)). +* Introduce two new metrics: `TotalMergeFailures` and `NonAbortedMergeFailures`. These metrics are needed to detect the cases where too many merges fail within a short period. [#78150](https://github.com/ClickHouse/ClickHouse/pull/78150) ([Miсhael Stetsyuk](https://github.com/mstetsyuk)). +* Fix incorrect S3 URL parsing when key is not specified on path style. [#78185](https://github.com/ClickHouse/ClickHouse/pull/78185) ([Arthur Passos](https://github.com/arthurpassos)). +* Fix incorrect values of `BlockActiveTime`, `BlockDiscardTime`, `BlockWriteTime`, `BlockQueueTime`, and `BlockReadTime` asynchronous metrics (before the change 1 second was incorrectly reported as 0.001). [#78211](https://github.com/ClickHouse/ClickHouse/pull/78211) ([filimonov](https://github.com/filimonov)). +* Respect `loading_retries` limit for errors during push to materialized view for StorageS3(Azure)Queue. Before that such errors were retried indefinitely. [#78313](https://github.com/ClickHouse/ClickHouse/pull/78313) ([Kseniia Sumarokova](https://github.com/kssenii)). +* In DeltaLake with `delta-kernel-rs` implementation, fix performance and progress bar. [#78368](https://github.com/ClickHouse/ClickHouse/pull/78368) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Support `include`, `from_env`, `from_zk` for runtime disks. Closes [#78177](https://github.com/ClickHouse/ClickHouse/issues/78177). [#78470](https://github.com/ClickHouse/ClickHouse/pull/78470) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Add a dynamic warning to the `system.warnings` table for long running mutations. [#78658](https://github.com/ClickHouse/ClickHouse/pull/78658) ([Bharat Nallan](https://github.com/bharatnc)). +* Added field `condition` to system table `system.query_condition_cache`. It stores the plaintext condition whose hash is used as a key in the query condition cache. [#78671](https://github.com/ClickHouse/ClickHouse/pull/78671) ([Robert Schulze](https://github.com/rschu1ze)). +* Allow an empty value for Hive partitioning. [#78816](https://github.com/ClickHouse/ClickHouse/pull/78816) ([Arthur Passos](https://github.com/arthurpassos)). +* Fix `IN` clause type coercion for `BFloat16` (i.e. `SELECT toBFloat16(1) IN [1, 2, 3];` now returns `1`). Closes [#78754](https://github.com/ClickHouse/ClickHouse/issues/78754). [#78839](https://github.com/ClickHouse/ClickHouse/pull/78839) ([Raufs Dunamalijevs](https://github.com/rienath)). +* Do not check parts on other disks for `MergeTree` if `disk = ...` is set. [#78855](https://github.com/ClickHouse/ClickHouse/pull/78855) ([Azat Khuzhin](https://github.com/azat)). +* Make data types in `used_data_type_families` in `system.query_log` to be recorded with canonical names. [#78972](https://github.com/ClickHouse/ClickHouse/pull/78972) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Cleanup settings during `recoverLostReplica` same as it was done in: [#78637](https://github.com/ClickHouse/ClickHouse/pull/78637). [#79113](https://github.com/ClickHouse/ClickHouse/pull/79113) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)). +* Use insertion columns for INFILE schema inference. [#78490](https://github.com/ClickHouse/ClickHouse/pull/78490) ([Pervakov Grigorii](https://github.com/GrigoryPervakov)). + +#### Bug Fix (user-visible misbehavior in an official stable release) +* Fix incorrect projection analysis when `count(Nullable)` is used in aggregate projections. This fixes [#74495](https://github.com/ClickHouse/ClickHouse/issues/74495) . This PR also adds some logs around projection analysis to clarify why a projection is used or why not. [#74498](https://github.com/ClickHouse/ClickHouse/pull/74498) ([Amos Bird](https://github.com/amosbird)). +* Fix `Part <...> does not contain in snapshot of previous virtual parts. (PART_IS_TEMPORARILY_LOCKED)` during `DETACH PART`. [#76039](https://github.com/ClickHouse/ClickHouse/pull/76039) ([Aleksei Filatov](https://github.com/aalexfvk)). +* Fix not working skip indexes with expression with literals in analyzer and remove trivial casts during indexes analysis. [#77229](https://github.com/ClickHouse/ClickHouse/pull/77229) ([Pavel Kruglov](https://github.com/Avogar)). +* Fix a bug when `close_session` query parameter didn't have any effect leading to named sessions being closed only after `session_timeout`. [#77336](https://github.com/ClickHouse/ClickHouse/pull/77336) ([Alexey Katsman](https://github.com/alexkats)). +* Fixed receiving messages from NATS server without attached Materialized Views. [#77392](https://github.com/ClickHouse/ClickHouse/pull/77392) ([Dmitry Novikov](https://github.com/dmitry-sles-novikov)). +* Fix logical error while reading from empty `FileLog` via `merge` table function, close [#75575](https://github.com/ClickHouse/ClickHouse/issues/75575). [#77441](https://github.com/ClickHouse/ClickHouse/pull/77441) ([Vladimir Cherkasov](https://github.com/vdimir)). +* Use default format settings in `Dynamic` serialization from shared variant. [#77572](https://github.com/ClickHouse/ClickHouse/pull/77572) ([Pavel Kruglov](https://github.com/Avogar)). +* Fix checking if the table data path exists on the local disk. [#77608](https://github.com/ClickHouse/ClickHouse/pull/77608) ([Tuan Pham Anh](https://github.com/tuanpach)). +* Fix sending constant values to remote for some types. [#77634](https://github.com/ClickHouse/ClickHouse/pull/77634) ([Pavel Kruglov](https://github.com/Avogar)). +* Fix a crash because of expired context in S3/AzureQueue. [#77720](https://github.com/ClickHouse/ClickHouse/pull/77720) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Hide credentials in RabbitMQ, Nats, Redis, AzureQueue table engines. [#77755](https://github.com/ClickHouse/ClickHouse/pull/77755) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Fix undefined behaviour on `NaN` comparison in `argMin`/`argMax`. [#77756](https://github.com/ClickHouse/ClickHouse/pull/77756) ([Raúl Marín](https://github.com/Algunenano)). +* Regularly check if merges and mutations were cancelled even in case when the operation doesn't produce any blocks to write. [#77766](https://github.com/ClickHouse/ClickHouse/pull/77766) ([János Benjamin Antal](https://github.com/antaljanosbenjamin)). +* Fixed refreshable materialized view in Replicated database not working on newly added replicas. [#77774](https://github.com/ClickHouse/ClickHouse/pull/77774) ([Michael Kolupaev](https://github.com/al13n321)). +* Fix possible crash when `NOT_FOUND_COLUMN_IN_BLOCK` error occurs. [#77854](https://github.com/ClickHouse/ClickHouse/pull/77854) ([Vladimir Cherkasov](https://github.com/vdimir)). +* Fix crash that happens in the S3/AzureQueue while filling data. [#77878](https://github.com/ClickHouse/ClickHouse/pull/77878) ([Bharat Nallan](https://github.com/bharatnc)). +* Disable fuzzy search for history in SSH server (since it requires the skim library). [#78002](https://github.com/ClickHouse/ClickHouse/pull/78002) ([Azat Khuzhin](https://github.com/azat)). +* Fixes a bug that a vector search query on a non-indexed column was returning incorrect results if there was another vector column in the table with a defined vector similarity index. (Issue [#77978](https://github.com/ClickHouse/ClickHouse/issues/77978)). [#78069](https://github.com/ClickHouse/ClickHouse/pull/78069) ([Shankar Iyer](https://github.com/shankar-iyer)). +* Fix a minuscule error "The requested output format {} is binary... Do you want to output it anyway? [y/N]" prompt. [#78095](https://github.com/ClickHouse/ClickHouse/pull/78095) ([Azat Khuzhin](https://github.com/azat)). +* Fix of a bug in case of `toStartOfInterval` with zero origin argument. [#78096](https://github.com/ClickHouse/ClickHouse/pull/78096) ([Yarik Briukhovetskyi](https://github.com/yariks5s)). +* Disallow specifying an empty `session_id` query parameter for HTTP interface. [#78098](https://github.com/ClickHouse/ClickHouse/pull/78098) ([Alexey Katsman](https://github.com/alexkats)). +* Fix metadata override in `Replicated` database which could have happened due to a `RENAME` query executed right after an `ALTER` query. [#78107](https://github.com/ClickHouse/ClickHouse/pull/78107) ([Nikolay Degterinsky](https://github.com/evillique)). +* Fix crash in `NATS` engine. [#78108](https://github.com/ClickHouse/ClickHouse/pull/78108) ([Dmitry Novikov](https://github.com/dmitry-sles-novikov)). +* Do not try to create history_file in embedded client for SSH (in previous versions the creation was always unsuccessful, but attempted). [#78112](https://github.com/ClickHouse/ClickHouse/pull/78112) ([Azat Khuzhin](https://github.com/azat)). +* Fix `system.detached_tables` displaying incorrect information after `RENAME DATABASE` or `DROP TABLE` queries. [#78126](https://github.com/ClickHouse/ClickHouse/pull/78126) ([Nikolay Degterinsky](https://github.com/evillique)). +* Fix for checks for too many tables with `Replicated` database after [#77274](https://github.com/ClickHouse/ClickHouse/pull/77274). Also, perform the check before creating the storage to avoid creating unaccounted nodes in Keeper in the case of `ReplicatedMergeTree` or `KeeperMap`. [#78127](https://github.com/ClickHouse/ClickHouse/pull/78127) ([Nikolay Degterinsky](https://github.com/evillique)). +* Fix possible crash due to concurrent `S3Queue` metadata initialization. [#78131](https://github.com/ClickHouse/ClickHouse/pull/78131) ([Azat Khuzhin](https://github.com/azat)). +* `groupArray*` functions now produce `BAD_ARGUMENTS` error for Int-typed 0 value of the `max_size` argument, like it's already done for UInt one, instead of trying to execute with it. [#78140](https://github.com/ClickHouse/ClickHouse/pull/78140) ([Eduard Karacharov](https://github.com/korowa)). +* Prevent crash on recovering a lost replica if the local table is removed before it's detached. [#78173](https://github.com/ClickHouse/ClickHouse/pull/78173) ([Raúl Marín](https://github.com/Algunenano)). +* Fix the fact that "alterable" column in `system.s3_queue_settings` returning always `false`. [#78187](https://github.com/ClickHouse/ClickHouse/pull/78187) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Mask Azure access signature to be not visible to user or in logs. [#78189](https://github.com/ClickHouse/ClickHouse/pull/78189) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Fix prefetching of substreams with prefixes in Wide parts. [#78205](https://github.com/ClickHouse/ClickHouse/pull/78205) ([Pavel Kruglov](https://github.com/Avogar)). +* Fixed crashes / incorrect result for `mapFromArrays` in case of `LowCardinality(Nullable)` type of keys array. [#78240](https://github.com/ClickHouse/ClickHouse/pull/78240) ([Eduard Karacharov](https://github.com/korowa)). +* Fix delta-kernel-rs auth options. [#78255](https://github.com/ClickHouse/ClickHouse/pull/78255) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Not schedule Refreshable Materialized Views task if a replica's `disable_insertion_and_mutation` is true. A task is some insertion, it will failed if `disable_insertion_and_mutation` is true. [#78277](https://github.com/ClickHouse/ClickHouse/pull/78277) ([Xu Jia](https://github.com/XuJia0210)). +* Validate access to underlying tables for the `Merge` engine. [#78339](https://github.com/ClickHouse/ClickHouse/pull/78339) ([Pervakov Grigorii](https://github.com/GrigoryPervakov)). +* `FINAL` modifier can be ignored when querying a `Distributed` table. [#78428](https://github.com/ClickHouse/ClickHouse/pull/78428) ([Yakov Olkhovskiy](https://github.com/yakov-olkhovskiy)). +* `bitmapMin` returns the uint32_max when the bitmap is empty (and uint64_max when the input type is larger), which matches the behavior of empty roaring_bitmap's minimum. [#78444](https://github.com/ClickHouse/ClickHouse/pull/78444) ([wxybear](https://github.com/wxybear)). +* Disable parallelization of query processing right after reading FROM when `distributed_aggregation_memory_efficient` enabled, it may lead to logical error. Closes [#76934](https://github.com/ClickHouse/ClickHouse/issues/76934). [#78500](https://github.com/ClickHouse/ClickHouse/pull/78500) ([flynn](https://github.com/ucasfl)). +* Set at least one stream for reading in case there are zero planned streams after applying `max_streams_to_max_threads_ratio` setting. [#78505](https://github.com/ClickHouse/ClickHouse/pull/78505) ([Eduard Karacharov](https://github.com/korowa)). +* In storage `S3Queue` fix logical error "Cannot unregister: table uuid is not registered". Closes [#78285](https://github.com/ClickHouse/ClickHouse/issues/78285). [#78541](https://github.com/ClickHouse/ClickHouse/pull/78541) ([Kseniia Sumarokova](https://github.com/kssenii)). +* ClickHouse is now able to figure out its cgroup v2 on systems with both cgroups v1 and v2 enabled. [#78566](https://github.com/ClickHouse/ClickHouse/pull/78566) ([Grigory Korolev](https://github.com/gkorolev)). +* `-Cluster` table functions were failing when used with table-level settings. [#78587](https://github.com/ClickHouse/ClickHouse/pull/78587) ([Daniil Ivanik](https://github.com/divanik)). +* Better checks when transactions are not supported by ReplicatedMergeTree on INSERT. [#78633](https://github.com/ClickHouse/ClickHouse/pull/78633) ([Azat Khuzhin](https://github.com/azat)). +* Cleanup query settings during attach. [#78637](https://github.com/ClickHouse/ClickHouse/pull/78637) ([Raúl Marín](https://github.com/Algunenano)). +* Fix a crash when an invalid path was specified in `iceberg_metadata_file_path`. [#78688](https://github.com/ClickHouse/ClickHouse/pull/78688) ([alesapin](https://github.com/alesapin)). +* In `DeltaLake` table engine with delta-kernel-s implementation, fix the case when the read schema is different from the table schema and there are partition columns at the same time leading to a "not found column" error. [#78690](https://github.com/ClickHouse/ClickHouse/pull/78690) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Fix a problem when after scheduling to close a named session (but before timeout expiration), creation of a new named session with the same name led to it being closed at a time point when the first session was scheduled to close. [#78698](https://github.com/ClickHouse/ClickHouse/pull/78698) ([Alexey Katsman](https://github.com/alexkats)). +* Fixed several types of `SELECT` queries that read from tables with `MongoDB` engine or `mongodb` table function: queries with implicit conversion of const value in `WHERE` clause (e.g. `WHERE datetime = '2025-03-10 00:00:00'`) ; queries with `LIMIT` and `GROUP BY`. Previously, they could return the wrong result. [#78777](https://github.com/ClickHouse/ClickHouse/pull/78777) ([Anton Popov](https://github.com/CurtizJ)). +* Don't block table shutdown while running `CHECK TABLE`. [#78782](https://github.com/ClickHouse/ClickHouse/pull/78782) ([Raúl Marín](https://github.com/Algunenano)). +* Keeper fix: fix ephemeral count in all cases. [#78799](https://github.com/ClickHouse/ClickHouse/pull/78799) ([Antonio Andelic](https://github.com/antonio2368)). +* Fix bad cast in `StorageDistributed` when using table functions other than `view`. Closes [#78464](https://github.com/ClickHouse/ClickHouse/issues/78464). [#78828](https://github.com/ClickHouse/ClickHouse/pull/78828) ([Konstantin Bogdanov](https://github.com/thevar1able)). +* Fix the consistency of formatting for `tupleElement(*, 1)`. Closes [#78639](https://github.com/ClickHouse/ClickHouse/issues/78639). [#78832](https://github.com/ClickHouse/ClickHouse/pull/78832) ([Konstantin Bogdanov](https://github.com/thevar1able)). +* Dictionaries of type `ssd_cache` now reject zero or negative `block_size` and `write_buffer_size` parameters (issue [#78314](https://github.com/ClickHouse/ClickHouse/issues/78314)). [#78854](https://github.com/ClickHouse/ClickHouse/pull/78854) ([Elmi Ahmadov](https://github.com/ahmadov)). +* Fix crash in Refreshable MATERIALIZED VIEW inthe case of ALTER after an incorrect shutdown. [#78858](https://github.com/ClickHouse/ClickHouse/pull/78858) ([Azat Khuzhin](https://github.com/azat)). +* Fix parsing of bad `DateTime` values in `CSV` format. [#78919](https://github.com/ClickHouse/ClickHouse/pull/78919) ([Pavel Kruglov](https://github.com/Avogar)). +* Keeper fix: Avoid triggering watches on failed multi requests. [#79247](https://github.com/ClickHouse/ClickHouse/pull/79247) ([Antonio Andelic](https://github.com/antonio2368)). +* Fix reading Iceberg table failed when min-max value is specified explicitly but is `NULL`. The Go Iceberg library was noted for generating such an atrocious files. Closes [#78740](https://github.com/ClickHouse/ClickHouse/issues/78740). [#78764](https://github.com/ClickHouse/ClickHouse/pull/78764) ([flynn](https://github.com/ucasfl)). + +#### Build/Testing/Packaging Improvement +* Respect CPU target features in Rust and enable LTO in all crates. [#78590](https://github.com/ClickHouse/ClickHouse/pull/78590) ([Raúl Marín](https://github.com/Algunenano)). + + +### ClickHouse release 25.3 LTS, 2025-03-20 {#253} + +#### Backward Incompatible Change +* Disallow truncating replicated databases. [#76651](https://github.com/ClickHouse/ClickHouse/pull/76651) ([Bharat Nallan](https://github.com/bharatnc)). +* Skipping index cache is reverted. [#77447](https://github.com/ClickHouse/ClickHouse/pull/77447) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)). + +#### New Feature +* `JSON` data type is production-ready. See https://jsonbench.com/. `Dynamic` and `Variant` data types are production-ready. [#77785](https://github.com/ClickHouse/ClickHouse/pull/77785) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Introduce the SSH protocol for clickhouse-server. Now, it is possible to connect to ClickHouse using any SSH client. This closes: [#74340](https://github.com/ClickHouse/ClickHouse/issues/74340). [#74989](https://github.com/ClickHouse/ClickHouse/pull/74989) ([George Gamezardashvili](https://github.com/Infjoker)). +* Replace table functions with their -Cluster alternatives if parallel replicas are enabled. Fixes [#65024](https://github.com/ClickHouse/ClickHouse/issues/65024). [#70659](https://github.com/ClickHouse/ClickHouse/pull/70659) ([Konstantin Bogdanov](https://github.com/thevar1able)). +* A new implementation of the Userspace Page Cache, which allows caching data in the in-process memory instead of relying on the OS page cache, which is useful when the data is stored on a remote virtual filesystem without backing with the local filesystem cache. [#70509](https://github.com/ClickHouse/ClickHouse/pull/70509) ([Michael Kolupaev](https://github.com/al13n321)). +* Added `concurrent_threads_scheduler` server setting that governs how CPU slots are distributed among concurrent queries. Could be set to `round_robin` (previous behavior) or `fair_round_robin` to address the issue of unfair CPU distribution between INSERTs and SELECTs. [#75949](https://github.com/ClickHouse/ClickHouse/pull/75949) ([Sergei Trifonov](https://github.com/serxa)). +* Add `estimateCompressionRatio` aggregate function [#70801](https://github.com/ClickHouse/ClickHouse/issues/70801). [#76661](https://github.com/ClickHouse/ClickHouse/pull/76661) ([Tariq Almawash](https://github.com/talmawash)). +* Added function `arraySymmetricDifference`. It returns all elements from multiple array arguments which do not occur in all arguments. Example: `SELECT arraySymmetricDifference([1, 2], [2, 3])` returns `[1, 3]`. (issue [#61673](https://github.com/ClickHouse/ClickHouse/issues/61673)). [#76231](https://github.com/ClickHouse/ClickHouse/pull/76231) ([Filipp Abapolov](https://github.com/pheepa)). +* Allow to explicitly specify metadata file to read for Iceberg with storage/table function setting `iceberg_metadata_file_path `. Fixes [#47412](https://github.com/ClickHouse/ClickHouse/issues/47412). [#77318](https://github.com/ClickHouse/ClickHouse/pull/77318) ([alesapin](https://github.com/alesapin)). +* Added the `keccak256` hash function, commonly used in blockchain implementations, especially in EVM-based systems. [#76669](https://github.com/ClickHouse/ClickHouse/pull/76669) ([Arnaud Briche](https://github.com/arnaudbriche)). +* Add three new functions. `icebergTruncate` according to specification. https://iceberg.apache.org/spec/#truncate-transform-details, `toYearNumSinceEpoch` and `toMonthNumSinceEpoch`. Support `truncate` transform in partition pruning for `Iceberg` engine. [#77403](https://github.com/ClickHouse/ClickHouse/pull/77403) ([alesapin](https://github.com/alesapin)). +* Support `LowCardinality(Decimal)` data types [#72256](https://github.com/ClickHouse/ClickHouse/issues/72256). [#72833](https://github.com/ClickHouse/ClickHouse/pull/72833) ([zhanglistar](https://github.com/zhanglistar)). +* `FilterTransformPassedRows` and `FilterTransformPassedBytes` profile events will show the number of rows and number of bytes filtered during the query execution. [#76662](https://github.com/ClickHouse/ClickHouse/pull/76662) ([Onkar Deshpande](https://github.com/onkar)). +* Support for the histogram metric type. The interface closely mirrors the Prometheus client, where you simply call `observe(value)` to increment the counter in the bucket corresponding to the value. The histogram metrics are exposed via `system.histogram_metrics`. [#75736](https://github.com/ClickHouse/ClickHouse/pull/75736) ([Miсhael Stetsyuk](https://github.com/mstetsyuk)). +* Non-constant CASE support for switching on explicit values. [#77399](https://github.com/ClickHouse/ClickHouse/pull/77399) ([Yarik Briukhovetskyi](https://github.com/yariks5s)). + +#### Experimental Feature +* Add support [for Unity Catalog](https://www.databricks.com/product/unity-catalog) for DeltaLake tables on top of AWS S3 and local filesystem. [#76988](https://github.com/ClickHouse/ClickHouse/pull/76988) ([alesapin](https://github.com/alesapin)). +* Introduce experimental integration with AWS Glue service catalog for Iceberg tables. [#77257](https://github.com/ClickHouse/ClickHouse/pull/77257) ([alesapin](https://github.com/alesapin)). +* Added support for dynamic cluster autodiscovery. This extends the existing _node_ autodiscovery feature. ClickHouse can now automatically detect and register new _clusters_ under a common ZooKeeper path using ``. [#76001](https://github.com/ClickHouse/ClickHouse/pull/76001) ([Anton Ivashkin](https://github.com/ianton-ru)). +* Allow automatic cleanup merges of entire partitions after a configurable timeout with a new setting `enable_replacing_merge_with_cleanup_for_min_age_to_force_merge`. [#76440](https://github.com/ClickHouse/ClickHouse/pull/76440) ([Christoph Wurm](https://github.com/cwurm)). + +#### Performance Improvement +* Implement query condition cache to improve query performance using repeated conditions. The range of the portion of data that does not meet the condition is remembered as a temporary index in memory. Subsequent queries will use this index. Close [#67768](https://github.com/ClickHouse/ClickHouse/issues/67768) [#69236](https://github.com/ClickHouse/ClickHouse/pull/69236) ([zhongyuankai](https://github.com/zhongyuankai)). +* Actively evict data from the cache on parts removal. Do not let the cache grow to the maximum size if the amount of data is less. [#76641](https://github.com/ClickHouse/ClickHouse/pull/76641) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Replace Int256 and UInt256 with clang builtin i256 in arithmetic calculation, and it gives a performance improvement [#70502](https://github.com/ClickHouse/ClickHouse/issues/70502). [#73658](https://github.com/ClickHouse/ClickHouse/pull/73658) ([李扬](https://github.com/taiyang-li)). +* In some cases (e.g. empty array column) data parts can contain empty files. We can skip writing empty blobs to ObjectStorage and only store metadata for such files when the table resides on disk with separated metadata and object storages. [#75860](https://github.com/ClickHouse/ClickHouse/pull/75860) ([Alexander Gololobov](https://github.com/davenger)). +* Improve min/max performance for Decimal32/Decimal64/DateTime64. [#76570](https://github.com/ClickHouse/ClickHouse/pull/76570) ([李扬](https://github.com/taiyang-li)). +* Query compilation (setting `compile_expressions`) now considers the machine type. This speeds up such queries significantly. [#76753](https://github.com/ClickHouse/ClickHouse/pull/76753) ([ZhangLiStar](https://github.com/zhanglistar)). +* Optimize `arraySort`. [#76850](https://github.com/ClickHouse/ClickHouse/pull/76850) ([李扬](https://github.com/taiyang-li)). +* Disable `filesystem_cache_prefer_bigger_buffer_size` when the cache is used passively, such as for merges. [#77898](https://github.com/ClickHouse/ClickHouse/pull/77898) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Apply `preserve_most` attribute at some places in code, which allows slightly better code generation. [#67778](https://github.com/ClickHouse/ClickHouse/pull/67778) ([Nikita Taranov](https://github.com/nickitat)). +* Faster ClickHouse servers shutdown (get rid of 2.5sec delay). [#76550](https://github.com/ClickHouse/ClickHouse/pull/76550) ([Azat Khuzhin](https://github.com/azat)). +* Avoid excess allocation in ReadBufferFromS3 and other remote reading buffers, reduce their memory consumption in half. [#76692](https://github.com/ClickHouse/ClickHouse/pull/76692) ([Sema Checherinda](https://github.com/CheSema)). +* Update zstd from 1.5.5 to 1.5.7 which could lead to some [performance improvements](https://github.com/facebook/zstd/releases/tag/v1.5.7). [#77137](https://github.com/ClickHouse/ClickHouse/pull/77137) ([Pradeep Chhetri](https://github.com/chhetripradeep)). +* Reduce memory usage during prefetches of JSON column in Wide parts. This is relevant when ClickHouse is used on top of a shared storage, such as in ClickHouse Cloud. [#77640](https://github.com/ClickHouse/ClickHouse/pull/77640) ([Pavel Kruglov](https://github.com/Avogar)). + +#### Improvement +* Support atomic rename when `TRUNCATE` is used with `INTO OUTFILE`. Resolves [#70323](https://github.com/ClickHouse/ClickHouse/issues/70323). [#77181](https://github.com/ClickHouse/ClickHouse/pull/77181) ([Onkar Deshpande](https://github.com/onkar)). +* It's no longer possible to use `NaN` or `inf` for float values as settings. Not like it did make any sense before. [#77546](https://github.com/ClickHouse/ClickHouse/pull/77546) ([Yarik Briukhovetskyi](https://github.com/yariks5s)). +* Disable parallel replicas by default when analyzer is disabled regardless `compatibility` setting. It's still possible to change this behavior by explicitly setting `parallel_replicas_only_with_analyzer` to `false`. [#77115](https://github.com/ClickHouse/ClickHouse/pull/77115) ([Igor Nikonov](https://github.com/devcrafter)). +* Add the ability to define a list of headers that are forwarded from the headers of the client request to the external HTTP authenticator. [#77054](https://github.com/ClickHouse/ClickHouse/pull/77054) ([inv2004](https://github.com/inv2004)). +* Respect column insensitive column matching for fields in tuple columns. Close https://github.com/apache/incubator-gluten/issues/8324. [#73780](https://github.com/ClickHouse/ClickHouse/pull/73780) ([李扬](https://github.com/taiyang-li)). +* Parameters for the codec Gorilla will now always be saved in the table metadata in .sql file. This closes: [#70072](https://github.com/ClickHouse/ClickHouse/issues/70072). [#74814](https://github.com/ClickHouse/ClickHouse/pull/74814) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)). +* Implemented parsing enhancements for certain data lakes (Sequence ID parsing: Added functionality to parse sequence identifiers in manifest files AND Avro metadata parsing: Redesigned the Avro metadata parser to be easily extendable for future enhancements). [#75010](https://github.com/ClickHouse/ClickHouse/pull/75010) ([Daniil Ivanik](https://github.com/divanik)). +* Remove trace_id from default ORDER BY for `system.opentelemetry_span_log`. [#75907](https://github.com/ClickHouse/ClickHouse/pull/75907) ([Azat Khuzhin](https://github.com/azat)). +* Encryption (the attribute `encrypted_by`) can now be applied to any configuration file (config.xml, users.xml, nested configuration files). Previously, it worked only for the top-level config.xml file. [#75911](https://github.com/ClickHouse/ClickHouse/pull/75911) ([Mikhail Gorshkov](https://github.com/mgorshkov)). +* Improve the `system.warnings` table and add some dynamic warning messages that can be added, updated or removed. [#76029](https://github.com/ClickHouse/ClickHouse/pull/76029) ([Bharat Nallan](https://github.com/bharatnc)). +* This PR makes it impossible to run a query `ALTER USER user1 ADD PROFILES a, DROP ALL PROFILES` because all `DROP` operations should come first in the order. [#76242](https://github.com/ClickHouse/ClickHouse/pull/76242) ([pufit](https://github.com/pufit)). +* Various enhancements for SYNC REPLICA (better error messages, better tests, sanity checks). [#76307](https://github.com/ClickHouse/ClickHouse/pull/76307) ([Azat Khuzhin](https://github.com/azat)). +* Use correct fallback when multipart copy to S3 fails during backup with Access Denied. Multi part copy can generate Access Denied error when backup is done between buckets that have different credentials. [#76515](https://github.com/ClickHouse/ClickHouse/pull/76515) ([Antonio Andelic](https://github.com/antonio2368)). +* Upgraded librdkafka (which is a pile of crap) to version 2.8.0 (the pile does not get any better) and improved the shutdown sequence for Kafka tables, reducing delays during table drops and server restarts. The `engine=Kafka` no longer explicitly leaves the consumer group when a table is dropped. Instead, the consumer remains in the group until it is automatically removed after `session_timeout_ms` (default: 45 seconds) of inactivity. [#76621](https://github.com/ClickHouse/ClickHouse/pull/76621) ([filimonov](https://github.com/filimonov)). +* Fix validation of S3 request settings. [#76658](https://github.com/ClickHouse/ClickHouse/pull/76658) ([Vitaly Baranov](https://github.com/vitlibar)). +* System tables like `server_settings` or `settings` have a `default` value column which is convenient. Add them to `merge_tree_settings` and `replicated_merge_tree_settings`. [#76942](https://github.com/ClickHouse/ClickHouse/pull/76942) ([Diego Nieto](https://github.com/lesandie)). +* Added `ProfileEvents::QueryPreempted`, which has a similar logic to `CurrentMetrics::QueryPreempted`. [#77015](https://github.com/ClickHouse/ClickHouse/pull/77015) ([VicoWu](https://github.com/VicoWu)). +* Previously, a Replicated database could print credentials specified in a query to logs. This behaviour is fixed. This closes: [#77123](https://github.com/ClickHouse/ClickHouse/issues/77123). [#77133](https://github.com/ClickHouse/ClickHouse/pull/77133) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)). +* Allow ALTER TABLE DROP PARTITION for `plain_rewritable disk`. [#77138](https://github.com/ClickHouse/ClickHouse/pull/77138) ([Julia Kartseva](https://github.com/jkartseva)). +* Backup/restore setting `allow_s3_native_copy` now supports value three possible values: - `False` - s3 native copy will not be used; - `True` (old default) - ClickHouse will try s3 native copy first, if it fails then fallback to the reading+writing approach; - `'auto'` (new default) - ClickHouse will compare the source and destination credentials first. If they are same, ClickHouse will try s3 native copy and then may fallback to the reading+writing approach. If they are different, ClickHouse will go directly to the reading+writing approach. [#77401](https://github.com/ClickHouse/ClickHouse/pull/77401) ([Vitaly Baranov](https://github.com/vitlibar)). +* Support aws session token and environment credentials usage in delta kernel for DeltaLake table engine. [#77661](https://github.com/ClickHouse/ClickHouse/pull/77661) ([Kseniia Sumarokova](https://github.com/kssenii)). + +#### Bug Fix (user-visible misbehavior in an official stable release) +* Fix stuck while processing pending batch for async distributed INSERT (due to i.e. `No such file or directory`). [#72939](https://github.com/ClickHouse/ClickHouse/pull/72939) ([Azat Khuzhin](https://github.com/azat)). +* Improved datetime conversion during index analysis by enforcing saturating behavior for implicit Date to DateTime conversions. This resolves potential index analysis inaccuracies caused by datetime range limitations. This fixes [#73307](https://github.com/ClickHouse/ClickHouse/issues/73307). It also fixes explicit `toDateTime` conversion when `date_time_overflow_behavior = 'ignore'` which is the default value. [#73326](https://github.com/ClickHouse/ClickHouse/pull/73326) ([Amos Bird](https://github.com/amosbird)). +* Fix all sort of bugs due to race between UUID and table names (for instance it will fix the race between `RENAME` and `RESTART REPLICA`, in case of concurrent `RENAME` with `SYSTEM RESTART REPLICA` you may get end up restarting wrong replica, or/and leaving one of the tables in a `Table X is being restarted` state). [#76308](https://github.com/ClickHouse/ClickHouse/pull/76308) ([Azat Khuzhin](https://github.com/azat)). +* Fix data loss when enable async insert and insert into ... from file ... with unequal block size if the first block size < async_max_size but the second block > async_max_size, the second block will not be inserted. these data is left in `squashing`. [#76343](https://github.com/ClickHouse/ClickHouse/pull/76343) ([Han Fei](https://github.com/hanfei1991)). +* Renamed field 'marks' to 'marks_bytes' in `system.data_skipping_indices`. [#76374](https://github.com/ClickHouse/ClickHouse/pull/76374) ([Robert Schulze](https://github.com/rschu1ze)). +* Fix dynamic filesystem cache resize handling unexpected errors during eviction. [#76466](https://github.com/ClickHouse/ClickHouse/pull/76466) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Fixed `used_flag` initialization in parallel hash. It might cause a server crash. [#76580](https://github.com/ClickHouse/ClickHouse/pull/76580) ([Nikita Taranov](https://github.com/nickitat)). +* Fix a logical error when calling `defaultProfiles` function inside a projection. [#76627](https://github.com/ClickHouse/ClickHouse/pull/76627) ([pufit](https://github.com/pufit)). +* Do not request interactive basic auth in the browser in Web UI. Closes [#76319](https://github.com/ClickHouse/ClickHouse/issues/76319). [#76637](https://github.com/ClickHouse/ClickHouse/pull/76637) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Fix THERE_IS_NO_COLUMN exception when selecting boolean literal from distributed tables. [#76656](https://github.com/ClickHouse/ClickHouse/pull/76656) ([Yakov Olkhovskiy](https://github.com/yakov-olkhovskiy)). +* The subpath inside the table directory is chosen in a more profound way. [#76681](https://github.com/ClickHouse/ClickHouse/pull/76681) ([Daniil Ivanik](https://github.com/divanik)). +* Fix an error `Not found column in block` after altering a table with a subcolumn in PK. After https://github.com/ClickHouse/ClickHouse/pull/72644, requires https://github.com/ClickHouse/ClickHouse/pull/74403. [#76686](https://github.com/ClickHouse/ClickHouse/pull/76686) ([Nikolai Kochetov](https://github.com/KochetovNicolai)). +* Add performance tests for null shortcircuit and fix bugs. [#76708](https://github.com/ClickHouse/ClickHouse/pull/76708) ([李扬](https://github.com/taiyang-li)). +* Flush output write buffers before finalizing them. Fix `LOGICAL_ERROR` generated during the finalization of some output format, e.g. `JSONEachRowWithProgressRowOutputFormat`. [#76726](https://github.com/ClickHouse/ClickHouse/pull/76726) ([Antonio Andelic](https://github.com/antonio2368)). +* Added support for MongoDB's binary UUID ([#74452](https://github.com/ClickHouse/ClickHouse/issues/74452)) - Fixed WHERE pushdown to MongoDB when using the table function ([#72210](https://github.com/ClickHouse/ClickHouse/issues/72210)) - Changed the MongoDB - ClickHouse type mapping such that MongoDB's binary UUID can only be parsed to ClickHouse's UUID. This should avoid ambiguities and surprises in future. - Fixed OID mapping, preserving backward compatibility. [#76762](https://github.com/ClickHouse/ClickHouse/pull/76762) ([Kirill Nikiforov](https://github.com/allmazz)). +* Fix exception handling in parallel prefixes deserialization of JSON subcolumns. [#76809](https://github.com/ClickHouse/ClickHouse/pull/76809) ([Pavel Kruglov](https://github.com/Avogar)). +* Fix lgamma function behavior for negative integers. [#76840](https://github.com/ClickHouse/ClickHouse/pull/76840) ([Ilya Kataev](https://github.com/IlyaKataev)). +* Fix reverse key analysis for explicitly defined primary keys. Similar to [#76654](https://github.com/ClickHouse/ClickHouse/issues/76654). [#76846](https://github.com/ClickHouse/ClickHouse/pull/76846) ([Amos Bird](https://github.com/amosbird)). +* Fix pretty print of Bool values in JSON format. [#76905](https://github.com/ClickHouse/ClickHouse/pull/76905) ([Pavel Kruglov](https://github.com/Avogar)). +* Fix possible crash because of bad JSON column rollback on error during async inserts. [#76908](https://github.com/ClickHouse/ClickHouse/pull/76908) ([Pavel Kruglov](https://github.com/Avogar)). +* Previously, `multiIf` may return different types of columns during planning and main execution. This resulted in code producing undefined behavior from the C++ perspective. [#76914](https://github.com/ClickHouse/ClickHouse/pull/76914) ([Nikita Taranov](https://github.com/nickitat)). +* Fixed incorrect serialization of constant nullable keys in MergeTree. This fixes [#76939](https://github.com/ClickHouse/ClickHouse/issues/76939). [#76985](https://github.com/ClickHouse/ClickHouse/pull/76985) ([Amos Bird](https://github.com/amosbird)). +* Fix sorting of `BFloat16` values. This closes [#75487](https://github.com/ClickHouse/ClickHouse/issues/75487). This closes [#75669](https://github.com/ClickHouse/ClickHouse/issues/75669). [#77000](https://github.com/ClickHouse/ClickHouse/pull/77000) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Bug fix JSON with Variant subcolumn by adding check to skip ephemeral subcolumns in part consistency check. [#72187](https://github.com/ClickHouse/ClickHouse/issues/72187). [#77034](https://github.com/ClickHouse/ClickHouse/pull/77034) ([Smita Kulkarni](https://github.com/SmitaRKulkarni)). +* Fix crash in template parsing in Values format in case of types mismatch. [#77071](https://github.com/ClickHouse/ClickHouse/pull/77071) ([Pavel Kruglov](https://github.com/Avogar)). +* Don't allow creating EmbeddedRocksDB table with subcolumn in primary key. Previosly such table could be created but select queries were failing. [#77074](https://github.com/ClickHouse/ClickHouse/pull/77074) ([Pavel Kruglov](https://github.com/Avogar)). +* Fix illegal comparison in distributed queries because pushing down predicates to remote doesn't respect literal types. [#77093](https://github.com/ClickHouse/ClickHouse/pull/77093) ([Duc Canh Le](https://github.com/canhld94)). +* Fix crash during Kafka table creation with exception. [#77121](https://github.com/ClickHouse/ClickHouse/pull/77121) ([Pavel Kruglov](https://github.com/Avogar)). +* Support JSON and subcolumns in Kafka and RabbitMQ engines. [#77122](https://github.com/ClickHouse/ClickHouse/pull/77122) ([Pavel Kruglov](https://github.com/Avogar)). +* Fix exceptions stack unwinding on MacOS. [#77126](https://github.com/ClickHouse/ClickHouse/pull/77126) ([Eduard Karacharov](https://github.com/korowa)). +* Fix reading 'null' subcolumn in getSubcolumn function. [#77163](https://github.com/ClickHouse/ClickHouse/pull/77163) ([Pavel Kruglov](https://github.com/Avogar)). +* Fix bloom filter index with Array and not supported functions. [#77271](https://github.com/ClickHouse/ClickHouse/pull/77271) ([Pavel Kruglov](https://github.com/Avogar)). +* We should only check the restriction on the amount of tables during the initial CREATE query. [#77274](https://github.com/ClickHouse/ClickHouse/pull/77274) ([Nikolay Degterinsky](https://github.com/evillique)). +* Not a bug: `SELECT toBFloat16(-0.0) == toBFloat16(0.0)` now correctly returns `true` (from previously `false`). This makes the behavior consistent with `Float32` and `Float64`. [#77290](https://github.com/ClickHouse/ClickHouse/pull/77290) ([Shankar Iyer](https://github.com/shankar-iyer)). +* Fix posbile incorrect reference to unintialized key_index variable, which may lead to crash in debug builds (this uninitialized reference won't cause issues in release builds because subsequent code are likely to throw errors.) ### documentation entry for user-facing changes. [#77305](https://github.com/ClickHouse/ClickHouse/pull/77305) ([wxybear](https://github.com/wxybear)). +* Fix name for partition with a Bool value. It was broken in https://github.com/ClickHouse/ClickHouse/pull/74533. [#77319](https://github.com/ClickHouse/ClickHouse/pull/77319) ([Pavel Kruglov](https://github.com/Avogar)). +* Fix comparison between tuples with nullable elements inside and strings. As an example, before the change comparison between a Tuple `(1, null)` and a String `'(1,null)'` would result in an error. Another example would be a comparison between a Tuple `(1, a)`, where `a` is a Nullable column, and a String `'(1, 2)'`. This change addresses these issues. [#77323](https://github.com/ClickHouse/ClickHouse/pull/77323) ([Alexey Katsman](https://github.com/alexkats)). +* Fix crash in ObjectStorageQueueSource. Was intoduced in https://github.com/ClickHouse/ClickHouse/pull/76358. [#77325](https://github.com/ClickHouse/ClickHouse/pull/77325) ([Pavel Kruglov](https://github.com/Avogar)). +* Fix `async_insert` with `input`. [#77340](https://github.com/ClickHouse/ClickHouse/pull/77340) ([Azat Khuzhin](https://github.com/azat)). +* Fix: `WITH FILL` may fail with NOT_FOUND_COLUMN_IN_BLOCK when sorting column is removed by planer. Similar issue related to inconsistent DAG calculated for INTERPOLATE expression. [#77343](https://github.com/ClickHouse/ClickHouse/pull/77343) ([Yakov Olkhovskiy](https://github.com/yakov-olkhovskiy)). +* Fix several LOGICAL_ERRORs around setting alias of invalid AST nodes. [#77445](https://github.com/ClickHouse/ClickHouse/pull/77445) ([Raúl Marín](https://github.com/Algunenano)). +* In filesystem cache impementation fix error processing during file segment write. [#77471](https://github.com/ClickHouse/ClickHouse/pull/77471) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Make DatabaseIceberg use correct metadata file provided by catalog. Closes [#75187](https://github.com/ClickHouse/ClickHouse/issues/75187). [#77486](https://github.com/ClickHouse/ClickHouse/pull/77486) ([Kseniia Sumarokova](https://github.com/kssenii)). +* The query cache now assumes that UDFs are non-deterministic. Accordingly, results of queries with UDFs are no longer cached. Previously, users were able to define non-deterministic UDFs whose result would erronously be cached (issue [#77553](https://github.com/ClickHouse/ClickHouse/issues/77553)). [#77633](https://github.com/ClickHouse/ClickHouse/pull/77633) ([Jimmy Aguilar Mena](https://github.com/Ergus)). +* Fix system.filesystem_cache_log working only under setting `enable_filesystem_cache_log`. [#77650](https://github.com/ClickHouse/ClickHouse/pull/77650) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Fix a logical error when calling `defaultRoles` function inside a projection. Follow-up for [#76627](https://github.com/ClickHouse/ClickHouse/issues/76627). [#77667](https://github.com/ClickHouse/ClickHouse/pull/77667) ([pufit](https://github.com/pufit)). +* Second arguments of type `Nullable` for function `arrayResize` are now disallowed. Previously, anything from errors to wrong results could happen with `Nullable` as second argument. (issue [#48398](https://github.com/ClickHouse/ClickHouse/issues/48398)). [#77724](https://github.com/ClickHouse/ClickHouse/pull/77724) ([Manish Gill](https://github.com/mgill25)). +* Regularly check if merges and mutations were cancelled even in case when the operation doesn't produce any blocks to write. [#77766](https://github.com/ClickHouse/ClickHouse/pull/77766) ([János Benjamin Antal](https://github.com/antaljanosbenjamin)). + +#### Build/Testing/Packaging Improvement +* `clickhouse-odbc-bridge` and `clickhouse-library-bridge` are moved to a separate repository, https://github.com/ClickHouse/odbc-bridge/. [#76225](https://github.com/ClickHouse/ClickHouse/pull/76225) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Fix Rust cross-compilation and allow disabling Rust completely. [#76921](https://github.com/ClickHouse/ClickHouse/pull/76921) ([Raúl Marín](https://github.com/Algunenano)). + + +### ClickHouse release 25.2, 2025-02-27 {#252} + +#### Backward Incompatible Change +* Completely enable `async_load_databases` by default (even for those installations that do not upgrade `config.xml`). [#74772](https://github.com/ClickHouse/ClickHouse/pull/74772) ([Azat Khuzhin](https://github.com/azat)). +* Add `JSONCompactEachRowWithProgress` and `JSONCompactStringsEachRowWithProgress` formats. Continuation of [#69989](https://github.com/ClickHouse/ClickHouse/issues/69989). The `JSONCompactWithNames` and `JSONCompactWithNamesAndTypes` no longer output "totals" - apparently, it was a mistake in the implementation. [#75037](https://github.com/ClickHouse/ClickHouse/pull/75037) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Change the `format_alter_operations_with_parentheses` default to true to disambiguate the ALTER commands list (see https://github.com/ClickHouse/ClickHouse/pull/59532). This breaks replication with clusters prior to 24.3. If you are upgrading a cluster using older releases turn off the setting in the server config or upgrade to 24.3 first. [#75302](https://github.com/ClickHouse/ClickHouse/pull/75302) ([Raúl Marín](https://github.com/Algunenano)). +* Remove the possibility of filtering log messages using regular expressions. The implementation introduced a data race, so it has to be removed. [#75577](https://github.com/ClickHouse/ClickHouse/pull/75577) ([János Benjamin Antal](https://github.com/antaljanosbenjamin)). +* The setting `min_chunk_bytes_for_parallel_parsing` cannot be zero anymore. This fixes: [#71110](https://github.com/ClickHouse/ClickHouse/issues/71110). [#75239](https://github.com/ClickHouse/ClickHouse/pull/75239) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)). +* Validate settings in the cache configuration. Non existing settings were ignored before, now they will throw an error and they should be removed. [#75452](https://github.com/ClickHouse/ClickHouse/pull/75452) ([Kseniia Sumarokova](https://github.com/kssenii)). + +#### New Feature +* Support type `Nullable(JSON)`. [#73556](https://github.com/ClickHouse/ClickHouse/pull/73556) ([Pavel Kruglov](https://github.com/Avogar)). +* Support subcolumns in the DEFAULT and MATERIALIZED expressions. [#74403](https://github.com/ClickHouse/ClickHouse/pull/74403) ([Pavel Kruglov](https://github.com/Avogar)). +* Support writing Parquet bloom filters using the `output_format_parquet_write_bloom_filter` setting (enabled by default). [#71681](https://github.com/ClickHouse/ClickHouse/pull/71681) ([Michael Kolupaev](https://github.com/al13n321)). +* Web UI now has interactive database navigation. [#75777](https://github.com/ClickHouse/ClickHouse/pull/75777) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Allow the combination of read-only and read-write disks in the storage policy (as multiple volumes or multiple disks). This allows data to be read from the entire volume, while inserts will prefer the writable disk (i.e., Copy-on-Write storage policy). [#75862](https://github.com/ClickHouse/ClickHouse/pull/75862) ([Azat Khuzhin](https://github.com/azat)). +* Add a new Database engine, `DatabaseBackup,` that allows to instantly attach table/database from backup. [#75725](https://github.com/ClickHouse/ClickHouse/pull/75725) ([Maksim Kita](https://github.com/kitaisreal)). +* Support prepared statements in the Postgres wire protocol. [#75035](https://github.com/ClickHouse/ClickHouse/pull/75035) ([scanhex12](https://github.com/scanhex12)). +* Add the ability to ATTACH tables without a database layer, which is useful for MergeTree tables located on Web, S3, and similar external virtual filesystems. [#75788](https://github.com/ClickHouse/ClickHouse/pull/75788) ([Azat Khuzhin](https://github.com/azat)). +* Add a new string comparison function, `compareSubstrings` to compare parts of two strings. Example: `SELECT compareSubstrings('Saxony', 'Anglo-Saxon', 0, 6, 5) AS result` means "compare 6 bytes of strings 'Saxon' and 'Anglo-Saxon' lexicographically, starting at offset 0 in the first string, offset 5 in the second string". [#74070](https://github.com/ClickHouse/ClickHouse/pull/74070) ([lgbo](https://github.com/lgbo-ustc)). +* A new function, `initialQueryStartTime` is added. It returns the start time of the current query. The value is the same across all shards during a distributed query. [#75087](https://github.com/ClickHouse/ClickHouse/pull/75087) ([Roman Lomonosov](https://github.com/lomik)). +* Add support for SSL authentication with named collections for MySQL. Closes [#59111](https://github.com/ClickHouse/ClickHouse/issues/59111). [#59452](https://github.com/ClickHouse/ClickHouse/pull/59452) ([Nikolay Degterinsky](https://github.com/evillique)). + +#### Experimental Features +* Added a new setting, `enable_adaptive_memory_spill_scheduler` that allows multiple Grace JOINs in the same query to monitor their combined memory footprint and trigger spilling into external storage adaptively to prevent MEMORY_LIMIT_EXCEEDED. [#72728](https://github.com/ClickHouse/ClickHouse/pull/72728) ([lgbo](https://github.com/lgbo-ustc)). +* Make the new, experimental `Kafka` table engine fully respect Keeper feature flags. [#76004](https://github.com/ClickHouse/ClickHouse/pull/76004) ([János Benjamin Antal](https://github.com/antaljanosbenjamin)). +* Restore the (Intel) QPL codec, which was removed in v24.10 due to licensing issues. [#76021](https://github.com/ClickHouse/ClickHouse/pull/76021) ([Konstantin Bogdanov](https://github.com/thevar1able)). +* For the integration with HDFS added support for the `dfs.client.use.datanode.hostname` configuration option. [#74635](https://github.com/ClickHouse/ClickHouse/pull/74635) ([Mikhail Tiukavkin](https://github.com/freshertm)). + +#### Performance Improvement +* Improve performance of the whole JSON column reading in Wide parts from S3. It's done by adding prefetches for subcolumn prefixes deserialization, cache of deserialized prefixes, and parallel deserialization of subcolumn prefixes. It improves the reading of the JSON column from S3 4 times in queries like `SELECT data FROM table` and about 10 times in queries like `SELECT data FROM table LIMIT 10`. [#74827](https://github.com/ClickHouse/ClickHouse/pull/74827) ([Pavel Kruglov](https://github.com/Avogar)). +* Fixed unnecessary contention in `parallel_hash` when `max_rows_in_join = max_bytes_in_join = 0`. [#75155](https://github.com/ClickHouse/ClickHouse/pull/75155) ([Nikita Taranov](https://github.com/nickitat)). +* Fixed double preallocation in `ConcurrentHashJoin` in case join sides are swapped by the optimizer. [#75149](https://github.com/ClickHouse/ClickHouse/pull/75149) ([Nikita Taranov](https://github.com/nickitat)). +* Slight improvement in some join scenarios: precalculate the number of output rows and reserve memory for them. [#75376](https://github.com/ClickHouse/ClickHouse/pull/75376) ([Alexander Gololobov](https://github.com/davenger)). +* For queries like `WHERE a < b AND b < c AND c < 5`, we can infer new comparing conditions (`a < 5 AND b < 5`) to have better filter ability. [#73164](https://github.com/ClickHouse/ClickHouse/pull/73164) ([Shichao Jin](https://github.com/jsc0218)). +* Keeper improvement: disable digest calculation when committing to in-memory storage for better performance. It can be enabled with `keeper_server.digest_enabled_on_commit` config. Digest is still calculated when preprocessing requests. [#75490](https://github.com/ClickHouse/ClickHouse/pull/75490) ([Antonio Andelic](https://github.com/antonio2368)). +* Push down filter expression from JOIN ON when possible. [#75536](https://github.com/ClickHouse/ClickHouse/pull/75536) ([Vladimir Cherkasov](https://github.com/vdimir)). +* Calculate columns and indices sizes lazily in MergeTree. [#75938](https://github.com/ClickHouse/ClickHouse/pull/75938) ([Pavel Kruglov](https://github.com/Avogar)). +* Reintroduce respect `ttl_only_drop_parts` on `MATERIALIZE TTL`; only read necessary columns to recalculate TTL and drop parts by replacing them with an empty ones. [#72751](https://github.com/ClickHouse/ClickHouse/pull/72751) ([Andrey Zvonov](https://github.com/zvonand)). +* Reduce write buffer size for plain_rewritable metadata files [#75758](https://github.com/ClickHouse/ClickHouse/pull/75758) ([Julia Kartseva](https://github.com/jkartseva)). +* Reduce memory usage for some window functions. [#65647](https://github.com/ClickHouse/ClickHouse/pull/65647) ([lgbo](https://github.com/lgbo-ustc)). +* Evaluate parquet bloom filters and min/max indexes together. Necessary to properly support: `x = 3 or x > 5` where data = [1, 2, 4, 5]. [#71383](https://github.com/ClickHouse/ClickHouse/pull/71383) ([Arthur Passos](https://github.com/arthurpassos)). +* Queries passed to the `Executable` storage are no longer limited to a single-threaded execution. [#70084](https://github.com/ClickHouse/ClickHouse/pull/70084) ([yawnt](https://github.com/yawnt)). +* Fetch parts in parallel in ALTER TABLE FETCH PARTITION (thread pool size is controlled with `max_fetch_partition_thread_pool_size`). [#74978](https://github.com/ClickHouse/ClickHouse/pull/74978) ([Azat Khuzhin](https://github.com/azat)). +* Allow to move predicates with the `indexHint` function to `PREWHERE`. [#74987](https://github.com/ClickHouse/ClickHouse/pull/74987) ([Anton Popov](https://github.com/CurtizJ)). + +#### Improvement +* Fixed calculation of size in memory for `LowCardinality` columns. [#74688](https://github.com/ClickHouse/ClickHouse/pull/74688) ([Nikita Taranov](https://github.com/nickitat)). +* `processors_profile_log` table now has a default configuration with a TTL of 30 days. [#66139](https://github.com/ClickHouse/ClickHouse/pull/66139) ([Ilya Yatsishin](https://github.com/qoega)). +* Allow naming shards in the cluster configuration. [#72276](https://github.com/ClickHouse/ClickHouse/pull/72276) ([MikhailBurdukov](https://github.com/MikhailBurdukov)). +* Change Prometheus remote write response success status from 200/OK to 204/NoContent. [#74170](https://github.com/ClickHouse/ClickHouse/pull/74170) ([Michael Dempsey](https://github.com/bluestealth)). +* Add ability to reload `max_remote_read_network_bandwidth_for_serve` and `max_remote_write_network_bandwidth_for_server` on the fly without restart server. [#74206](https://github.com/ClickHouse/ClickHouse/pull/74206) ([Kai Zhu](https://github.com/nauu)). +* Allow using blob paths to calculate checksums while making a backup. [#74729](https://github.com/ClickHouse/ClickHouse/pull/74729) ([Vitaly Baranov](https://github.com/vitlibar)). +* Added a query ID column to `system.query_cache` (closes [#68205](https://github.com/ClickHouse/ClickHouse/issues/68205)). [#74982](https://github.com/ClickHouse/ClickHouse/pull/74982) ([NamHoaiNguyen](https://github.com/NamHoaiNguyen)). +* It is allowed to cancel `ALTER TABLE ... FREEZE ...` queries with `KILL QUERY` and automatically by a timeout (`max_execution_time`). [#75016](https://github.com/ClickHouse/ClickHouse/pull/75016) ([Kirill](https://github.com/kirillgarbar)). +* Add support for `groupUniqArrayArrayMap` as `SimpleAggregateFunction`. [#75034](https://github.com/ClickHouse/ClickHouse/pull/75034) ([Miel Donkers](https://github.com/mdonkers)). +* Hide catalog credential settings in database engine `Iceberg`. Closes [#74559](https://github.com/ClickHouse/ClickHouse/issues/74559). [#75080](https://github.com/ClickHouse/ClickHouse/pull/75080) ([Kseniia Sumarokova](https://github.com/kssenii)). +* `intExp2` / `intExp10`: Define undefined behaviour: return 0 for too small argument, `18446744073709551615` for too big argument, throw exception if `nan`. [#75312](https://github.com/ClickHouse/ClickHouse/pull/75312) ([Vitaly Baranov](https://github.com/vitlibar)). +* Support `s3.endpoint` natively from catalog config in `DatabaseIceberg`. Closes [#74558](https://github.com/ClickHouse/ClickHouse/issues/74558). [#75375](https://github.com/ClickHouse/ClickHouse/pull/75375) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Don't fail silently if a user executing `SYSTEM DROP REPLICA` doesn't have enough permissions. [#75377](https://github.com/ClickHouse/ClickHouse/pull/75377) ([Bharat Nallan](https://github.com/bharatnc)). +* Add a ProfileEvent about the number of times any of the system logs have failed to flush. [#75466](https://github.com/ClickHouse/ClickHouse/pull/75466) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Add a check and extra logging for decrypting and decompressing. [#75471](https://github.com/ClickHouse/ClickHouse/pull/75471) ([Vitaly Baranov](https://github.com/vitlibar)). +* Added support for the micro sign (U+00B5) in the `parseTimeDelta` function. Now both the micro sign (U+00B5) and the Greek letter mu (U+03BC) are recognized as valid representations for microseconds, aligning ClickHouse's behavior with Go’s implementation ([see time.go](https://github.com/golang/go/blob/ad7b46ee4ac1cee5095d64b01e8cf7fcda8bee5e/src/time/time.go#L983C19-L983C20) and [time/format.go](https://github.com/golang/go/blob/ad7b46ee4ac1cee5095d64b01e8cf7fcda8bee5e/src/time/format.go#L1608-L1609)). [#75472](https://github.com/ClickHouse/ClickHouse/pull/75472) ([Vitaly Orlov](https://github.com/orloffv)). +* Replace server setting (`send_settings_to_client`) with client setting (`apply_settings_from_server`) that controls whether client-side code (e.g., parsing INSERT data and formatting query output) should use settings from server's `users.xml` and user profile. Otherwise, only settings from the client command line, session, and query are used. Note that this only applies to native client (not e.g. HTTP), and doesn't apply to most of query processing (which happens on the server). [#75478](https://github.com/ClickHouse/ClickHouse/pull/75478) ([Michael Kolupaev](https://github.com/al13n321)). +* Better error messages for syntax errors. Previously, if the query was too large, and the token whose length exceeds the limit is a very large string literal, the message about the reason was lost in the middle of two examples of this very long token. Fix the issue when a query with UTF-8 was cut incorrectly in the error message. Fix excessive quoting of query fragments. This closes [#75473](https://github.com/ClickHouse/ClickHouse/issues/75473). [#75561](https://github.com/ClickHouse/ClickHouse/pull/75561) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Add profile events in storage `S3(Azure)Queue`. [#75618](https://github.com/ClickHouse/ClickHouse/pull/75618) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Disable sending settings from server to client (`send_settings_to_client=false`) for compatibility (This feature will be re-implemented as a client setting later for better usability). [#75648](https://github.com/ClickHouse/ClickHouse/pull/75648) ([Michael Kolupaev](https://github.com/al13n321)). +* Add a config `memory_worker_correct_memory_tracker` to enable correction of the internal memory tracker with information from different sources read in the background thread periodically. [#75714](https://github.com/ClickHouse/ClickHouse/pull/75714) ([Antonio Andelic](https://github.com/antonio2368)). +* Add column `normalized_query_hash` into `system.processes`. Note: while it can be easily calculated on the fly with the `normalizedQueryHash` function, this is needed to prepare for subsequent changes. [#75756](https://github.com/ClickHouse/ClickHouse/pull/75756) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Querying `system.tables` will not throw even if there is a `Merge` table created over a database that no longer exists. Remove the `getTotalRows` method from `Hive` tables because we don't allow it to do complex work. [#75772](https://github.com/ClickHouse/ClickHouse/pull/75772) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Store start_time/end_time for Backups with microseconds. [#75929](https://github.com/ClickHouse/ClickHouse/pull/75929) ([Aleksandr Musorin](https://github.com/AVMusorin)). +* Add `MemoryTrackingUncorrected` metric showing the value of the internal global memory tracker which is not corrected by RSS. [#75935](https://github.com/ClickHouse/ClickHouse/pull/75935) ([Antonio Andelic](https://github.com/antonio2368)). +* Allow parsing endpoints like `localhost:1234/handle` in `PostgreSQL` or `MySQL` table functions. This fixes a regression introduced in https://github.com/ClickHouse/ClickHouse/pull/52503. [#75944](https://github.com/ClickHouse/ClickHouse/pull/75944) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)). +* Added a server setting `throw_on_unknown_workload` that allows to choose behavior on query with `workload` setting set to unknown value: either allow unlimited access (default) or throw a `RESOURCE_ACCESS_DENIED` error. It is useful to force all queries to use workload scheduling. [#75999](https://github.com/ClickHouse/ClickHouse/pull/75999) ([Sergei Trifonov](https://github.com/serxa)). +* Don't rewrite subcolumns to `getSubcolumn` in `ARRAY JOIN` if not necessary. [#76018](https://github.com/ClickHouse/ClickHouse/pull/76018) ([Pavel Kruglov](https://github.com/Avogar)). +* Retry coordination errors when loading tables. [#76020](https://github.com/ClickHouse/ClickHouse/pull/76020) ([Alexander Tokmakov](https://github.com/tavplubix)). +* Support flushing individual logs in `SYSTEM FLUSH LOGS`. [#76132](https://github.com/ClickHouse/ClickHouse/pull/76132) ([Raúl Marín](https://github.com/Algunenano)). +* Improved the `/binary` server's page. Using the Hilbert curve instead of the Morton curve. Display 512 MB worth of addresses in the square, which fills the square better (in previous versions, addresses fill only half of the square). Color addresses closer to the library name rather than the function name. Allow scrolling a bit more outside of the area. [#76192](https://github.com/ClickHouse/ClickHouse/pull/76192) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Retry ON CLUSTER queries in case of TOO_MANY_SIMULTANEOUS_QUERIES. [#76352](https://github.com/ClickHouse/ClickHouse/pull/76352) ([Patrick Galbraith](https://github.com/CaptTofu)). +* Add the `CPUOverload` asynchronous metric, which calculates the server's relative CPU deficit. [#76404](https://github.com/ClickHouse/ClickHouse/pull/76404) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Changed the default value of `output_format_pretty_max_rows` from 10000 to 1000. I think it is better for usability. [#76407](https://github.com/ClickHouse/ClickHouse/pull/76407) ([Alexey Milovidov](https://github.com/alexey-milovidov)). + +#### Bug Fix (user-visible misbehavior in an official stable release) +* Fix formatting of exceptions using a custom format if they appear during query interpretation. In previous versions, exceptions were formatted using the default format rather than the format specified in the query. This closes [#55422](https://github.com/ClickHouse/ClickHouse/issues/55422). [#74994](https://github.com/ClickHouse/ClickHouse/pull/74994) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Fix type mapping for SQLite (integer types into `int64`, floating points into `float64`). [#73853](https://github.com/ClickHouse/ClickHouse/pull/73853) ([Joanna Hulboj](https://github.com/jh0x)). +* Fix identifier resolution from parent scopes. Allow the use of aliases to expressions in the WITH clause. Fixes [#58994](https://github.com/ClickHouse/ClickHouse/issues/58994). Fixes [#62946](https://github.com/ClickHouse/ClickHouse/issues/62946). Fixes [#63239](https://github.com/ClickHouse/ClickHouse/issues/63239). Fixes [#65233](https://github.com/ClickHouse/ClickHouse/issues/65233). Fixes [#71659](https://github.com/ClickHouse/ClickHouse/issues/71659). Fixes [#71828](https://github.com/ClickHouse/ClickHouse/issues/71828). Fixes [#68749](https://github.com/ClickHouse/ClickHouse/issues/68749). [#66143](https://github.com/ClickHouse/ClickHouse/pull/66143) ([Dmitry Novik](https://github.com/novikd)). +* Fix negate function monotonicity. In previous versions, the query `select * from a where -x = -42;` where `x` is the primary key, can return a wrong result. [#71440](https://github.com/ClickHouse/ClickHouse/pull/71440) ([Michael Kolupaev](https://github.com/al13n321)). +* Fix empty tuple handling in arrayIntersect. This fixes [#72578](https://github.com/ClickHouse/ClickHouse/issues/72578). [#72581](https://github.com/ClickHouse/ClickHouse/pull/72581) ([Amos Bird](https://github.com/amosbird)). +* Fix reading JSON sub-object subcolumns with incorrect prefix. [#73182](https://github.com/ClickHouse/ClickHouse/pull/73182) ([Pavel Kruglov](https://github.com/Avogar)). +* Propagate Native format settings properly for client-server communication. [#73924](https://github.com/ClickHouse/ClickHouse/pull/73924) ([Pavel Kruglov](https://github.com/Avogar)). +* Check for not supported types for some storages. [#74218](https://github.com/ClickHouse/ClickHouse/pull/74218) ([Pavel Kruglov](https://github.com/Avogar)). +* Fix crash with query `INSERT INTO SELECT` over PostgreSQL interface on macOS (issue [#72938](https://github.com/ClickHouse/ClickHouse/issues/72938)). [#74231](https://github.com/ClickHouse/ClickHouse/pull/74231) ([Artem Yurov](https://github.com/ArtemYurov)). +* Fixed uninitialized max_log_ptr in the replicated database. [#74336](https://github.com/ClickHouse/ClickHouse/pull/74336) ([Konstantin Morozov](https://github.com/k-morozov)). +* Fix crash when inserting interval (issue [#74299](https://github.com/ClickHouse/ClickHouse/issues/74299)). [#74478](https://github.com/ClickHouse/ClickHouse/pull/74478) ([NamHoaiNguyen](https://github.com/NamHoaiNguyen)). +* Fix formatting constant JSON literals. Previously it could lead to syntax errors during sending the query to another server. [#74533](https://github.com/ClickHouse/ClickHouse/pull/74533) ([Pavel Kruglov](https://github.com/Avogar)). +* Fix broken create query when using constant partition expressions with implicit projections enabled. This fixes [#74596](https://github.com/ClickHouse/ClickHouse/issues/74596) . [#74634](https://github.com/ClickHouse/ClickHouse/pull/74634) ([Amos Bird](https://github.com/amosbird)). +* Avoid leaving connection in broken state after INSERT finishes with exception. [#74740](https://github.com/ClickHouse/ClickHouse/pull/74740) ([Azat Khuzhin](https://github.com/azat)). +* Avoid reusing connections that had been left in the intermediate state. [#74749](https://github.com/ClickHouse/ClickHouse/pull/74749) ([Azat Khuzhin](https://github.com/azat)). +* Fix crash during JSON type declaration parsing when type name is not uppercase. [#74784](https://github.com/ClickHouse/ClickHouse/pull/74784) ([Pavel Kruglov](https://github.com/Avogar)). +* Keeper: fix logical_error when the connection had been terminated before establishing. [#74844](https://github.com/ClickHouse/ClickHouse/pull/74844) ([Michael Kolupaev](https://github.com/al13n321)). +* Fix a behavior when the server couldn't startup when there's a table using `AzureBlobStorage`. Tables are loaded without any requests to Azure. [#74880](https://github.com/ClickHouse/ClickHouse/pull/74880) ([Alexey Katsman](https://github.com/alexkats)). +* Fix missing `used_privileges` and `missing_privileges` fields in `query_log` for BACKUP and RESTORE operations. [#74887](https://github.com/ClickHouse/ClickHouse/pull/74887) ([Alexey Katsman](https://github.com/alexkats)). +* HDFS refresh krb ticket if sasl error during hdfs select request. [#74930](https://github.com/ClickHouse/ClickHouse/pull/74930) ([inv2004](https://github.com/inv2004)). +* Fix queries to Replicated database in startup_scripts. [#74942](https://github.com/ClickHouse/ClickHouse/pull/74942) ([Azat Khuzhin](https://github.com/azat)). +* Fix issues with expressions type aliased in the JOIN ON clause when a null-safe comparison is used. [#74970](https://github.com/ClickHouse/ClickHouse/pull/74970) ([Vladimir Cherkasov](https://github.com/vdimir)). +* Revert part's state from deleting back to outdated when remove operation has failed. [#74985](https://github.com/ClickHouse/ClickHouse/pull/74985) ([Sema Checherinda](https://github.com/CheSema)). +* In previous versions, when there was a scalar subquery, we started writing the progress (accumulated from processing the subquery) during the initialization of the data format, which was before HTTP headers were written. This led to the loss of HTTP headers, such as X-ClickHouse-QueryId and X-ClickHouse-Format, as well as Content-Type. [#74991](https://github.com/ClickHouse/ClickHouse/pull/74991) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Fix `CREATE TABLE AS...` queries for `database_replicated_allow_replicated_engine_arguments=0`. [#75000](https://github.com/ClickHouse/ClickHouse/pull/75000) ([Bharat Nallan](https://github.com/bharatnc)). +* Fix leaving connection in a bad state in client after INSERT exceptions. [#75030](https://github.com/ClickHouse/ClickHouse/pull/75030) ([Azat Khuzhin](https://github.com/azat)). +* Fix crash due to uncaught exception in PSQL replication. [#75062](https://github.com/ClickHouse/ClickHouse/pull/75062) ([Azat Khuzhin](https://github.com/azat)). +* Sasl can fail any rpc call, the fix helps to repeat the call in case if krb5 ticker is expired. [#75063](https://github.com/ClickHouse/ClickHouse/pull/75063) ([inv2004](https://github.com/inv2004)). +* Fixed usage of indexes (primary and secondary) for `Array`, `Map` and `Nullable(..)` columns with enabled setting `optimize_function_to_subcolumns`. Previously, indexes for these columns could have been ignored. [#75081](https://github.com/ClickHouse/ClickHouse/pull/75081) ([Anton Popov](https://github.com/CurtizJ)). +* Disable `flatten_nested` when creating materialized views with inner tables since it will not be possible to use such flattened columns. [#75085](https://github.com/ClickHouse/ClickHouse/pull/75085) ([Christoph Wurm](https://github.com/cwurm)). +* Fix for some of IPv6 addresses (such as ::ffff:1.1.1.1) in forwarded_for field is wrongly interpreted resulting in client disconnect with exception. [#75133](https://github.com/ClickHouse/ClickHouse/pull/75133) ([Yakov Olkhovskiy](https://github.com/yakov-olkhovskiy)). +* Fix nullsafe JOIN handling for LowCardinality nullable data type. Previously JOIN ON with nullsafe comparison, such as `IS NOT DISTINCT FROM`, `<=>` , `a IS NULL AND b IS NULL OR a == b` didn't work correctly with LowCardinality columns. [#75143](https://github.com/ClickHouse/ClickHouse/pull/75143) ([Vladimir Cherkasov](https://github.com/vdimir)). +* Checks that we don't specify key_condition when counting total_number_of_rows for NumRowsCache. [#75164](https://github.com/ClickHouse/ClickHouse/pull/75164) ([Daniil Ivanik](https://github.com/divanik)). +* Fix queries with unused interpolation with the new analyzer. [#75173](https://github.com/ClickHouse/ClickHouse/pull/75173) ([János Benjamin Antal](https://github.com/antaljanosbenjamin)). +* Fix the crash bug of CTE with Insert. [#75188](https://github.com/ClickHouse/ClickHouse/pull/75188) ([Shichao Jin](https://github.com/jsc0218)). +* Keeper fix: avoid writing to broken changelogs when rolling back logs. [#75197](https://github.com/ClickHouse/ClickHouse/pull/75197) ([Antonio Andelic](https://github.com/antonio2368)). +* Use `BFloat16` as a supertype where appropriate. This closes: [#74404](https://github.com/ClickHouse/ClickHouse/issues/74404). [#75236](https://github.com/ClickHouse/ClickHouse/pull/75236) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)). +* Fix unexpected defaults in join result with any_join_distinct_right_table_keys and OR in JOIN ON. [#75262](https://github.com/ClickHouse/ClickHouse/pull/75262) ([Vladimir Cherkasov](https://github.com/vdimir)). +* Mask azureblobstorage table engine credentials. [#75319](https://github.com/ClickHouse/ClickHouse/pull/75319) ([Garrett Thomas](https://github.com/garrettthomaskth)). +* Fixed behavior when ClickHouse may erroneously do a filter pushdown to an external database like PostgreSQL, MySQL, or SQLite. This closes: [#71423](https://github.com/ClickHouse/ClickHouse/issues/71423). [#75320](https://github.com/ClickHouse/ClickHouse/pull/75320) ([Nikita Mikhaylov](https://github.com/nikitamikhaylov)). +* Fix crash in protobuf schema cache that can happen during output in Protobuf format and parallel query `SYSTEM DROP FORMAT SCHEMA CACHE`. [#75357](https://github.com/ClickHouse/ClickHouse/pull/75357) ([Pavel Kruglov](https://github.com/Avogar)). +* Fix a possible logical error or uninitialized memory issue when a filter from `HAVING` is pushed down with parallel replicas. [#75363](https://github.com/ClickHouse/ClickHouse/pull/75363) ([Vladimir Cherkasov](https://github.com/vdimir)). +* Hide sensitive info for `icebergS3`, `icebergAzure` table functions and table engines. [#75378](https://github.com/ClickHouse/ClickHouse/pull/75378) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Function `TRIM` with computed empty trim characters are now correctly handled. Example: `SELECT TRIM(LEADING concat('') FROM 'foo')` (Issue [#69922](https://github.com/ClickHouse/ClickHouse/issues/69922)). [#75399](https://github.com/ClickHouse/ClickHouse/pull/75399) ([Manish Gill](https://github.com/mgill25)). +* Fix data race in IOutputFormat. [#75448](https://github.com/ClickHouse/ClickHouse/pull/75448) ([Pavel Kruglov](https://github.com/Avogar)). +* Fix possible error `Elements ... and ... of Nested data structure ... (Array columns) have different array sizes` when JSON subcolumns with Array type are used in JOIN over distributed tables. [#75512](https://github.com/ClickHouse/ClickHouse/pull/75512) ([Pavel Kruglov](https://github.com/Avogar)). +* Fix data corruption with `CODEC(ZSTD, DoubleDelta)`. Closes [#70031](https://github.com/ClickHouse/ClickHouse/issues/70031). [#75548](https://github.com/ClickHouse/ClickHouse/pull/75548) ([Konstantin Bogdanov](https://github.com/thevar1able)). +* Fix interaction between allow_feature_tier and compatibility mergetree setting. [#75635](https://github.com/ClickHouse/ClickHouse/pull/75635) ([Raúl Marín](https://github.com/Algunenano)). +* Fix incorrect processed_rows value in system.s3queue_log in case file was retried. [#75666](https://github.com/ClickHouse/ClickHouse/pull/75666) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Respect `materialized_views_ignore_errors` when a materialized view writes to a URL engine and there is a connectivity issue. [#75679](https://github.com/ClickHouse/ClickHouse/pull/75679) ([Christoph Wurm](https://github.com/cwurm)). +* Fixed rare crashes while reading from `MergeTree` table after multiple asynchronous `RENAME` queries (with `alter_sync = 0`) between columns with different types. [#75693](https://github.com/ClickHouse/ClickHouse/pull/75693) ([Anton Popov](https://github.com/CurtizJ)). +* Fix `Block structure mismatch in QueryPipeline stream` error for some queries with `UNION ALL`. [#75715](https://github.com/ClickHouse/ClickHouse/pull/75715) ([Nikolai Kochetov](https://github.com/KochetovNicolai)). +* Rebuild projection on alter modify of its PK column. Previously it could lead to `CANNOT_READ_ALL_DATA` errors during selects after alter modify of the column used in projection PK. [#75720](https://github.com/ClickHouse/ClickHouse/pull/75720) ([Pavel Kruglov](https://github.com/Avogar)). +* Fix incorrect result of `ARRAY JOIN` for scalar subqueries (with analyzer). [#75732](https://github.com/ClickHouse/ClickHouse/pull/75732) ([Nikolai Kochetov](https://github.com/KochetovNicolai)). +* Fixed null pointer dereference in `DistinctSortedStreamTransform`. [#75734](https://github.com/ClickHouse/ClickHouse/pull/75734) ([Nikita Taranov](https://github.com/nickitat)). +* Fix `allow_suspicious_ttl_expressions` behaviour. [#75771](https://github.com/ClickHouse/ClickHouse/pull/75771) ([Aleksei Filatov](https://github.com/aalexfvk)). +* Fix uninitialized memory read in function `translate`. This closes [#75592](https://github.com/ClickHouse/ClickHouse/issues/75592). [#75794](https://github.com/ClickHouse/ClickHouse/pull/75794) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Propagate format settings to JSON as string formatting in Native format. [#75832](https://github.com/ClickHouse/ClickHouse/pull/75832) ([Pavel Kruglov](https://github.com/Avogar)). +* Recorded the default enablement of parallel hash as join algorithm in v24.12 in the settings change history. This means that ClickHouse will continue to join using non-parallel hash if an older compatibility level than v24.12 is configured. [#75870](https://github.com/ClickHouse/ClickHouse/pull/75870) ([Robert Schulze](https://github.com/rschu1ze)). +* Fixed a bug that tables with implicitly added min-max indices could not be copied into a new table (issue [#75677](https://github.com/ClickHouse/ClickHouse/issues/75677)). [#75877](https://github.com/ClickHouse/ClickHouse/pull/75877) ([Smita Kulkarni](https://github.com/SmitaRKulkarni)). +* `clickhouse-library-bridge` allows opening arbitrary libraries from the filesystem, which makes it safe to run only inside an isolated environment. To prevent a vulnerability when it is run near the clickhouse-server, we will limit the paths of libraries to a location, provided in the configuration. This vulnerability was found with the [ClickHouse Bug Bounty Program](https://github.com/ClickHouse/ClickHouse/issues/38986) by **Arseniy Dugin**. [#75954](https://github.com/ClickHouse/ClickHouse/pull/75954) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* We happened to use JSON serialization for some metadata, which was a mistake, because JSON does not support binary data inside string literals, including zero bytes. SQL queries can contain binary data and invalid UTF-8, so we have to support this in our metadata files as well. At the same time, ClickHouse's `JSONEachRow` and similar formats work around that by deviating from the JSON standard in favor of a perfect roundtrip for the binary data. See the motivation here: https://github.com/ClickHouse/ClickHouse/pull/73668#issuecomment-2560501790. The solution is to make `Poco::JSON` library consistent with the JSON format serialization in ClickHouse. This closes [#73668](https://github.com/ClickHouse/ClickHouse/issues/73668). [#75963](https://github.com/ClickHouse/ClickHouse/pull/75963) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Fix check for commit limits in storage `S3Queue`. [#76104](https://github.com/ClickHouse/ClickHouse/pull/76104) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Fix attaching MergeTree tables with auto indexes (`add_minmax_index_for_numeric_columns`/`add_minmax_index_for_string_columns`). [#76139](https://github.com/ClickHouse/ClickHouse/pull/76139) ([Azat Khuzhin](https://github.com/azat)). +* Fixed issue of stack traces from parent threads of a job (`enable_job_stack_trace` setting) are not printed out. Fixed issue `enable_job_stack_trace` setting is not properly propagated to the threads resulting stack trace content not always respects this setting. [#76191](https://github.com/ClickHouse/ClickHouse/pull/76191) ([Yakov Olkhovskiy](https://github.com/yakov-olkhovskiy)). +* Fix incorrect permission check where `ALTER RENAME` required `CREATE USER` grant. Closes [#74372](https://github.com/ClickHouse/ClickHouse/issues/74372). [#76241](https://github.com/ClickHouse/ClickHouse/pull/76241) ([pufit](https://github.com/pufit)). +* Fix reinterpretAs with FixedString on big-endian architecture. [#76253](https://github.com/ClickHouse/ClickHouse/pull/76253) ([Azat Khuzhin](https://github.com/azat)). +* Fix logical error in S3Queue "Expected current processor {} to be equal to {} for bucket {}". [#76358](https://github.com/ClickHouse/ClickHouse/pull/76358) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Fix deadlock for ALTER with Memory database. [#76359](https://github.com/ClickHouse/ClickHouse/pull/76359) ([Azat Khuzhin](https://github.com/azat)). +* Fix logical error in index analysis if condition in `WHERE` has `pointInPolygon` function. [#76360](https://github.com/ClickHouse/ClickHouse/pull/76360) ([Anton Popov](https://github.com/CurtizJ)). +* Fix potentially unsafe call in signal handler. [#76549](https://github.com/ClickHouse/ClickHouse/pull/76549) ([Yakov Olkhovskiy](https://github.com/yakov-olkhovskiy)). +* Fix reverse key support in PartsSplitter. This fixes [#73400](https://github.com/ClickHouse/ClickHouse/issues/73400). [#73418](https://github.com/ClickHouse/ClickHouse/pull/73418) ([Amos Bird](https://github.com/amosbird)). + +#### Build/Testing/Packaging Improvement +* Support build HDFS on both ARM and Intel Mac. [#74244](https://github.com/ClickHouse/ClickHouse/pull/74244) ([Yan Xin](https://github.com/yxheartipp)). +* Enable ICU and GRPC when cross-compiling for Darwin. [#75922](https://github.com/ClickHouse/ClickHouse/pull/75922) ([Raúl Marín](https://github.com/Algunenano)). +* Update to embedded LLVM 19. [#75148](https://github.com/ClickHouse/ClickHouse/pull/75148) ([Konstantin Bogdanov](https://github.com/thevar1able)). +* Disable network access for user default in the docker image. [#75259](https://github.com/ClickHouse/ClickHouse/pull/75259) ([Mikhail f. Shiryaev](https://github.com/Felixoid)). Make all clickhouse-server related actions a function, and execute them only when launching the default binary in `entrypoint.sh`. A long-postponed improvement was suggested in [#50724](https://github.com/ClickHouse/ClickHouse/issues/50724). Added switch `--users` to `clickhouse-extract-from-config` to get values from the `users.xml`. [#75643](https://github.com/ClickHouse/ClickHouse/pull/75643) ([Mikhail f. Shiryaev](https://github.com/Felixoid)). +* Remove about 20MB of dead code from the binary. [#76226](https://github.com/ClickHouse/ClickHouse/pull/76226) ([Alexey Milovidov](https://github.com/alexey-milovidov)). + +### ClickHouse release 25.1, 2025-01-28 {#251} + +#### Backward Incompatible Change +* `JSONEachRowWithProgress` will write the progress whenever the progress happens. In previous versions, the progress was shown only after each block of the result, which made it useless. Change the way how the progress is displayed: it will not show zero values. This closes [#70800](https://github.com/ClickHouse/ClickHouse/issues/70800). [#73834](https://github.com/ClickHouse/ClickHouse/pull/73834) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* `Merge` tables will unify the structure of underlying tables by using a union of their columns and deriving common types. This closes [#64864](https://github.com/ClickHouse/ClickHouse/issues/64864). In certain cases, this change could be backward incompatible. One example is when there is no common type between tables, but conversion to the type of the first table is still possible, such as in the case of UInt64 and Int64 or any numeric type and String. If you want to return to the old behavior, set `merge_table_max_tables_to_look_for_schema_inference` to `1` or set `compatibility` to `24.12` or earlier. [#73956](https://github.com/ClickHouse/ClickHouse/pull/73956) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Parquet output format converts Date and DateTime columns to date/time types supported by Parquet, instead of writing them as raw numbers. `DateTime` becomes `DateTime64(3)` (was: `UInt32`); setting `output_format_parquet_datetime_as_uint32` brings back the old behavior. `Date` becomes `Date32` (was: `UInt16`). [#70950](https://github.com/ClickHouse/ClickHouse/pull/70950) ([Michael Kolupaev](https://github.com/al13n321)). +* Don't allow not comparable types (like `JSON`/`Object`/`AggregateFunction`) in `ORDER BY` and comparison functions `less/greater/equal/etc` by default. [#73276](https://github.com/ClickHouse/ClickHouse/pull/73276) ([Pavel Kruglov](https://github.com/Avogar)). +* The obsolete `MaterializedMySQL` database engine has been removed and is no longer available. [#73879](https://github.com/ClickHouse/ClickHouse/pull/73879) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* The `mysql` dictionary source no longer does `SHOW TABLE STATUS` query, because it does not provide any value for InnoDB tables, as long as for any recent MySQL versions. This closes [#72636](https://github.com/ClickHouse/ClickHouse/issues/72636). This change is backward compatible, but put in this category so you have a chance to notice it. [#73914](https://github.com/ClickHouse/ClickHouse/pull/73914) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* `CHECK TABLE` queries now require a separate, `CHECK` grant. In previous versions, it was enough to have `SHOW TABLES` grant to run these queries. But a `CHECK TABLE` query can be heavy, and usual query complexity limits for `SELECT` queries don't apply to it. It led to the potential of DoS. [#74471](https://github.com/ClickHouse/ClickHouse/pull/74471) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Function `h3ToGeo()` now returns the results in the order `(lat, lon)` (which is the standard order for geometric functions). Users who wish to retain the legacy result order `(lon, lat)` can set setting `h3togeo_lon_lat_result_order = true`. [#74719](https://github.com/ClickHouse/ClickHouse/pull/74719) ([Manish Gill](https://github.com/mgill25)). +* A new MongoDB driver is now the default. Users who like to continue using the legacy driver can set server setting `use_legacy_mongodb_integration` to true. [#73359](https://github.com/ClickHouse/ClickHouse/pull/73359) ([Robert Schulze](https://github.com/rschu1ze)). + +#### New Feature +* Added an ability to apply non-finished (not materialized by background process) mutations during the execution of `SELECT` queries immediately after submitting. It can be enabled by setting `apply_mutations_on_fly`. [#74877](https://github.com/ClickHouse/ClickHouse/pull/74877) ([Anton Popov](https://github.com/CurtizJ)). +* Implement `Iceberg` tables partition pruning for time-related transform partition operations in Iceberg. [#72044](https://github.com/ClickHouse/ClickHouse/pull/72044) ([Daniil Ivanik](https://github.com/divanik)). +* Support subcolumns in MergeTree sorting key and skip indexes. [#72644](https://github.com/ClickHouse/ClickHouse/pull/72644) ([Pavel Kruglov](https://github.com/Avogar)). +* Support reading `HALF_FLOAT` values from `Apache Arrow`/`Parquet`/`ORC` (they are read into `Float32`). This closes [#72960](https://github.com/ClickHouse/ClickHouse/issues/72960). Keep in mind that IEEE-754 half float is not the same as `BFloat16`. Closes [#73835](https://github.com/ClickHouse/ClickHouse/issues/73835). [#73836](https://github.com/ClickHouse/ClickHouse/pull/73836) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* The `system.trace_log` table will contain two new columns, `symbols` and `lines` containing symbolized stack trace. It allows for easy collection and export of profile information. This is controlled by the server configuration value `symbolize` inside `trace_log` and is enabled by default. [#73896](https://github.com/ClickHouse/ClickHouse/pull/73896) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Add a new function, `generateSerialID`, which can be used to generate auto-incremental numbers in tables. Continuation of [#64310](https://github.com/ClickHouse/ClickHouse/issues/64310) by [kazalika](https://github.com/kazalika). This closes [#62485](https://github.com/ClickHouse/ClickHouse/issues/62485). [#73950](https://github.com/ClickHouse/ClickHouse/pull/73950) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Add syntax `query1 PARALLEL WITH query2 PARALLEL WITH query3 ... PARALLEL WITH queryN` for DDL queries. That means subqueries `{query1, query2, ... queryN}` are allowed to run in parallel with each other (and it's preferable). [#73983](https://github.com/ClickHouse/ClickHouse/pull/73983) ([Vitaly Baranov](https://github.com/vitlibar)). +* Added an in-memory cache for deserialized skipping index granules. This should make repeated queries that use skipping indexes faster. The size of the new cache is controlled by server settings `skipping_index_cache_size` and `skipping_index_cache_max_entries`. The original motivation for the cache were vector similarity indexes which became a lot faster now. [#70102](https://github.com/ClickHouse/ClickHouse/pull/70102) ([Robert Schulze](https://github.com/rschu1ze)). +* Now, the embedded Web UI has a progress bar during query runtime. It allows cancelling queries. It displays the total number of records and the extended information about the speed. The table can be rendered incrementally as soon as data arrives. Enable HTTP compression. Rendering of the table became faster. The table header became sticky. It allows selecting cells and navigating them by arrow keys. Fix the issue when the outline of the selected cell makes it smaller. Cells no longer expand on mouse hover but only on selection. The moment to stop rendering the incoming data is decided on the client rather than on the server side. Highlight digit groups for numbers. The overall design was refreshed and became bolder. It checks if the server is reachable and the correctness of credentials and displays the server version and uptime. The cloud icon is contoured in every font, even in Safari. Big integers inside nested data types will be rendered better. It will display inf/nan correctly. It will display data types when the mouse is over a column header. [#74204](https://github.com/ClickHouse/ClickHouse/pull/74204) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Add the ability to create min-max (skipping) indices by default for columns managed by MergeTree using settings `add_minmax_index_for_numeric_columns` (for numeric columns) and `add_minmax_index_for_string_columns` (for string columns). For now, both settings are disabled, so there is no behavior change yet. [#74266](https://github.com/ClickHouse/ClickHouse/pull/74266) ([Smita Kulkarni](https://github.com/SmitaRKulkarni)). +* Add `script_query_number` and `script_line_number` fields to `system.query_log`, to the ClientInfo in the native protocol, and to server logs. This closes [#67542](https://github.com/ClickHouse/ClickHouse/issues/67542). Credits to [pinsvin00](https://github.com/pinsvin00) for kicking off this feature earlier in [#68133](https://github.com/ClickHouse/ClickHouse/issues/68133). [#74477](https://github.com/ClickHouse/ClickHouse/pull/74477) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Added aggregation function `sequenceMatchEvents` which return timestamps of matched events for longest chain of events in pattern. [#72349](https://github.com/ClickHouse/ClickHouse/pull/72349) ([UnamedRus](https://github.com/UnamedRus)). +* Added function `arrayNormalizedGini`. [#72823](https://github.com/ClickHouse/ClickHouse/pull/72823) ([flynn](https://github.com/ucasfl)). +* Add minus operator support for `DateTime64`, to allow subtraction between `DateTime64` values, as well as `DateTime`. [#74482](https://github.com/ClickHouse/ClickHouse/pull/74482) ([Li Yin](https://github.com/liyinsg)). + +#### Experimental Features +* The `BFloat16` data type is production-ready. [#73840](https://github.com/ClickHouse/ClickHouse/pull/73840) ([Alexey Milovidov](https://github.com/alexey-milovidov)). + +#### Performance Improvement +* Optimized function `indexHint`. Now, columns that are only used as arguments of function `indexHint` are not read from the table. [#74314](https://github.com/ClickHouse/ClickHouse/pull/74314) ([Anton Popov](https://github.com/CurtizJ)). If the `indexHint` function is a central piece of your enterprise data architecture, this optimization will save your life. +* More accurate accounting for `max_joined_block_size_rows` setting for `parallel_hash` JOIN algorithm. Helps to avoid increased memory consumption compared to `hash` algorithm. [#74630](https://github.com/ClickHouse/ClickHouse/pull/74630) ([Nikita Taranov](https://github.com/nickitat)). +* Support predicate push down optimization on the query plan level for the `MergingAggregated` step. It improves performance for some queries with the analyzer. [#74073](https://github.com/ClickHouse/ClickHouse/pull/74073) ([Nikolai Kochetov](https://github.com/KochetovNicolai)). +* Splitting of left table blocks by hash was removed from the probe phase of the `parallel_hash` JOIN algorithm. [#73089](https://github.com/ClickHouse/ClickHouse/pull/73089) ([Nikita Taranov](https://github.com/nickitat)). +* Optimize RowBinary input format. Closes [#63805](https://github.com/ClickHouse/ClickHouse/issues/63805). [#65059](https://github.com/ClickHouse/ClickHouse/pull/65059) ([Pavel Kruglov](https://github.com/Avogar)). +* Write parts with level 1 if `optimize_on_insert` is enabled. It allows to use several optimizations of queries with `FINAL` for freshly written parts. [#73132](https://github.com/ClickHouse/ClickHouse/pull/73132) ([Anton Popov](https://github.com/CurtizJ)). +* Speedup string deserialization by some low-level optimisation. [#65948](https://github.com/ClickHouse/ClickHouse/pull/65948) ([Nikita Taranov](https://github.com/nickitat)). +* When running an equality comparison between records, such as during merges, start to compare rows from most likely unequal columns first. [#63780](https://github.com/ClickHouse/ClickHouse/pull/63780) ([UnamedRus](https://github.com/UnamedRus)). +* Improve grace hash join performance by re-ranking the right join table by keys. [#72237](https://github.com/ClickHouse/ClickHouse/pull/72237) ([kevinyhzou](https://github.com/KevinyhZou)). +* Allow `arrayROCAUC` and `arrayAUCPR` to compute partial area of the whole curve, so that its calculation can be parallelized over huge datasets. [#72904](https://github.com/ClickHouse/ClickHouse/pull/72904) ([Emmanuel](https://github.com/emmanuelsdias)). +* Avoid spawn too many idle threads. [#72920](https://github.com/ClickHouse/ClickHouse/pull/72920) ([Guo Wangyang](https://github.com/guowangy)). +* Don't list blob storage keys if we only have curly brackets expansion in table function. Closes [#73333](https://github.com/ClickHouse/ClickHouse/issues/73333). [#73518](https://github.com/ClickHouse/ClickHouse/pull/73518) ([Konstantin Bogdanov](https://github.com/thevar1able)). +* Short circuit optimization for functions executed over Nullable arguments. [#73820](https://github.com/ClickHouse/ClickHouse/pull/73820) ([李扬](https://github.com/taiyang-li)). +* Do not apply `maskedExecute` on non-function columns, improve the performance of short circuit execution. [#73965](https://github.com/ClickHouse/ClickHouse/pull/73965) ([lgbo](https://github.com/lgbo-ustc)). +* Disable the autodetection of headers in input formats for `Kafka`/`NATS`/`RabbitMQ`/`FileLog` to improve performance. [#74006](https://github.com/ClickHouse/ClickHouse/pull/74006) ([Azat Khuzhin](https://github.com/azat)). +* Execute pipeline with a higher degree of parallelism after aggregation with grouping sets. [#74082](https://github.com/ClickHouse/ClickHouse/pull/74082) ([Nikita Taranov](https://github.com/nickitat)). +* Reduce critical section in `MergeTreeReadPool`. [#74202](https://github.com/ClickHouse/ClickHouse/pull/74202) ([Guo Wangyang](https://github.com/guowangy)). +* Parallel replicas performance improvement. Packets deserialization on query initiator, for packets not related to parallel replicas protocol, now always happens in pipeline thread. Before, it could happen in a thread responsible for pipeline scheduling, which could make initiator less responsive and delay pipeline execution. [#74398](https://github.com/ClickHouse/ClickHouse/pull/74398) ([Igor Nikonov](https://github.com/devcrafter)). +* Improve performance of larger multi requests in Keeper. [#74849](https://github.com/ClickHouse/ClickHouse/pull/74849) ([Antonio Andelic](https://github.com/antonio2368)). +* Use log wrappers by value and don't allocate them in a heap. [#74034](https://github.com/ClickHouse/ClickHouse/pull/74034) ([Mikhail Artemenko](https://github.com/Michicosun)). +* Reestablish connection to MySQL and Postgres dictionary replicas in the background, so it wouldn't delay requests to corresponding dictionaries. [#71101](https://github.com/ClickHouse/ClickHouse/pull/71101) ([Yakov Olkhovskiy](https://github.com/yakov-olkhovskiy)). +* Parallel replicas used historical information about replica availability to improve replica selection but did not update the replica's error count when the connection was unavailable. This PR updates the replica's error count when unavailable. [#72666](https://github.com/ClickHouse/ClickHouse/pull/72666) ([zoomxi](https://github.com/zoomxi)). +* Added a merge tree setting `materialize_skip_indexes_on_merge` which suppresses the creation of skip indexes during merge. This allows users to control explicitly (via `ALTER TABLE [..] MATERIALIZE INDEX [...]`) when skip indexes are created. This can be useful if skip indexes are expensive to build (e.g. vector similarity indexes). [#74401](https://github.com/ClickHouse/ClickHouse/pull/74401) ([Robert Schulze](https://github.com/rschu1ze)). +* Optimize keeper requests in Storage(S3/Azure)Queue. [#74410](https://github.com/ClickHouse/ClickHouse/pull/74410) ([Kseniia Sumarokova](https://github.com/kssenii)). [#74538](https://github.com/ClickHouse/ClickHouse/pull/74538) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Use up to `1000` parallel replicas by default. [#74504](https://github.com/ClickHouse/ClickHouse/pull/74504) ([Konstantin Bogdanov](https://github.com/thevar1able)). +* Improve HTTP session reuse when reading from s3 disk ([#72401](https://github.com/ClickHouse/ClickHouse/issues/72401)). [#74548](https://github.com/ClickHouse/ClickHouse/pull/74548) ([Julian Maicher](https://github.com/jmaicher)). + +#### Improvement +* Support SETTINGS in a CREATE TABLE query with an implicit ENGINE and support mixing engine and query settings. [#73120](https://github.com/ClickHouse/ClickHouse/pull/73120) ([Raúl Marín](https://github.com/Algunenano)). +* Enable `use_hive_partitioning` by default. [#71636](https://github.com/ClickHouse/ClickHouse/pull/71636) ([Yarik Briukhovetskyi](https://github.com/yariks5s)). +* Support CAST and ALTER between JSON types with different parameters. [#72303](https://github.com/ClickHouse/ClickHouse/pull/72303) ([Pavel Kruglov](https://github.com/Avogar)). +* Support equal comparison for values of JSON column. [#72991](https://github.com/ClickHouse/ClickHouse/pull/72991) ([Pavel Kruglov](https://github.com/Avogar)). +* Improve formatting of identifiers with JSON subcolumns to avoid unnecessary back quotes. [#73085](https://github.com/ClickHouse/ClickHouse/pull/73085) ([Pavel Kruglov](https://github.com/Avogar)). +* Interactive metrics improvements. Fix metrics from parallel replicas not being fully displayed. Display the metrics in order of the most recent update, then lexicographically by name. Do not display stale metrics. [#71631](https://github.com/ClickHouse/ClickHouse/pull/71631) ([Julia Kartseva](https://github.com/jkartseva)). +* Make JSON output format pretty by default. Add new setting `output_format_json_pretty_print` to control it and enable it by default. [#72148](https://github.com/ClickHouse/ClickHouse/pull/72148) ([Pavel Kruglov](https://github.com/Avogar)). +* Allow `LowCardinality(UUID)` by default. This has proven practical among ClickHouse Cloud customers. [#73826](https://github.com/ClickHouse/ClickHouse/pull/73826) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Better message during installation. [#73827](https://github.com/ClickHouse/ClickHouse/pull/73827) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Better message about password reset for ClickHouse Cloud. [#73831](https://github.com/ClickHouse/ClickHouse/pull/73831) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Improve the error message with a File table that cannot perform appends into a file. [#73832](https://github.com/ClickHouse/ClickHouse/pull/73832) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Ask when a user accidentally requests to output binary format (such as Native, Parquet, Avro) in the terminal. This closes [#59524](https://github.com/ClickHouse/ClickHouse/issues/59524). [#73833](https://github.com/ClickHouse/ClickHouse/pull/73833) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Highlight trailing spaces in Pretty and Vertical formats in the terminal for better clarity. This is controlled with the `output_format_pretty_highlight_trailing_spaces` setting. Initial implementation by [Braden Burns](https://github.com/bradenburns) from [#72996](https://github.com/ClickHouse/ClickHouse/issues/72996). Closes [#71590](https://github.com/ClickHouse/ClickHouse/issues/71590). [#73847](https://github.com/ClickHouse/ClickHouse/pull/73847) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* `clickhouse-client` and `clickhouse-local` will autodetect compression of stdin when it is redirected from a file. This closes [#70865](https://github.com/ClickHouse/ClickHouse/issues/70865). [#73848](https://github.com/ClickHouse/ClickHouse/pull/73848) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Cut too long column names in pretty formats by default. This is controlled by the `output_format_pretty_max_column_name_width_cut_to` and `output_format_pretty_max_column_name_width_min_chars_to_cut` settings. This is the continuation of the work of [tanmaydatta](https://github.com/tanmaydatta) in [#66502](https://github.com/ClickHouse/ClickHouse/issues/66502). This closes [#65968](https://github.com/ClickHouse/ClickHouse/issues/65968). [#73851](https://github.com/ClickHouse/ClickHouse/pull/73851) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Make `Pretty` formats prettier: squash blocks if not much time passed since the output of the previous block. This is controlled by new settings `output_format_pretty_squash_consecutive_ms` (50 ms by default) and `output_format_pretty_squash_max_wait_ms` (1000 ms by default). Continuation of [#49537](https://github.com/ClickHouse/ClickHouse/issues/49537). This closes [#49153](https://github.com/ClickHouse/ClickHouse/issues/49153). [#73852](https://github.com/ClickHouse/ClickHouse/pull/73852) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Add a metric on the number of currently merging source parts. This closes [#70809](https://github.com/ClickHouse/ClickHouse/issues/70809). [#73868](https://github.com/ClickHouse/ClickHouse/pull/73868) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Highlight columns in the `Vertical` format if the output is to a terminal. This can be disabled with the `output_format_pretty_color` setting. [#73898](https://github.com/ClickHouse/ClickHouse/pull/73898) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Enhanced the MySQL compatibility to a level that now, `mysqlsh` (a rich MySQL CLI from Oracle) can connect to ClickHouse. This is needed to facilitate testing. [#73912](https://github.com/ClickHouse/ClickHouse/pull/73912) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Pretty formats can render multi-line fields inside a table cell, which improves readability. This is enabled by default and can be controlled by the setting `output_format_pretty_multiline_fields`. Continuation of the work by [Volodyachan](https://github.com/Volodyachan) in [#64094](https://github.com/ClickHouse/ClickHouse/issues/64094). This closes [#56912](https://github.com/ClickHouse/ClickHouse/issues/56912). [#74032](https://github.com/ClickHouse/ClickHouse/pull/74032) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Expose X-ClickHouse HTTP headers to JavaScript in the browser. It makes writing applications more convenient. [#74180](https://github.com/ClickHouse/ClickHouse/pull/74180) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* The `JSONEachRowWithProgress` format will include events with metadata, as well as totals and extremes. It also includes `rows_before_limit_at_least` and `rows_before_aggregation`. The format prints the exception properly if it arrives after partial results. The progress now includes elapsed nanoseconds. One final progress event is emitted at the end. The progress during query runtime will be printed no more frequently than the value of the `interactive_delay` setting. [#74181](https://github.com/ClickHouse/ClickHouse/pull/74181) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Hourglass will rotate smoothly in Play UI. [#74182](https://github.com/ClickHouse/ClickHouse/pull/74182) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Even if the HTTP response is compressed, send packets as soon as they arrive. This allows the browser to receive progress packets and compressed data. [#74201](https://github.com/ClickHouse/ClickHouse/pull/74201) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* If the number of output records is larger than N = `output_format_pretty_max_rows`, instead of displaying only the first N rows, we will cut the output table in the middle, displaying N/2 first rows and N/2 last rows. Continuation of [#64200](https://github.com/ClickHouse/ClickHouse/issues/64200). This closes [#59502](https://github.com/ClickHouse/ClickHouse/issues/59502). [#73929](https://github.com/ClickHouse/ClickHouse/pull/73929) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Allow more general join planning algorithm when hash join algorithm is enabled. [#71926](https://github.com/ClickHouse/ClickHouse/pull/71926) ([János Benjamin Antal](https://github.com/antaljanosbenjamin)). +* Allow to create bloom_filter index on columns with data type `DateTime64`. [#66416](https://github.com/ClickHouse/ClickHouse/pull/66416) ([Yutong Xiao](https://github.com/YutSean)). +* When `min_age_to_force_merge_seconds` and `min_age_to_force_merge_on_partition_only` are both enabled, the part merging will ignore the max bytes limit. [#73656](https://github.com/ClickHouse/ClickHouse/pull/73656) ([Kai Zhu](https://github.com/nauu)). +* Added HTTP headers to OpenTelemetry span logs table for enhanced traceability. [#70516](https://github.com/ClickHouse/ClickHouse/pull/70516) ([jonymohajanGmail](https://github.com/jonymohajanGmail)). +* Support writing `orc` file by custom time zone, not always by the `GMT` time zone. [#70615](https://github.com/ClickHouse/ClickHouse/pull/70615) ([kevinyhzou](https://github.com/KevinyhZou)). +* Respect IO scheduling settings when writing backups across clouds. [#71093](https://github.com/ClickHouse/ClickHouse/pull/71093) ([János Benjamin Antal](https://github.com/antaljanosbenjamin)). +* Add `metric` column alias `name` to `system.asynchronous_metrics`. [#71164](https://github.com/ClickHouse/ClickHouse/pull/71164) ([megao](https://github.com/jetgm)). +* Historically for some reason, the query `ALTER TABLE MOVE PARTITION TO TABLE` checked `SELECT` and `ALTER DELETE` rights instead of dedicated `ALTER_MOVE_PARTITION`. This PR makes use of this access type. For compatibility, this permission is also will be granted implicitly if `SELECT` and `ALTER DELETE` are granted, but this behavior will be removed in future releases. Closes [#16403](https://github.com/ClickHouse/ClickHouse/issues/16403). [#71632](https://github.com/ClickHouse/ClickHouse/pull/71632) ([pufit](https://github.com/pufit)). +* Throw an exception when trying to materialize a column in the sort key instead of allowing it to break the sort order. [#71891](https://github.com/ClickHouse/ClickHouse/pull/71891) ([Peter Nguyen](https://github.com/petern48)). +* Hide secrets in `EXPLAIN QUERY TREE`. [#72025](https://github.com/ClickHouse/ClickHouse/pull/72025) ([Yakov Olkhovskiy](https://github.com/yakov-olkhovskiy)). +* Support parquet integer logical types in the "native" reader. [#72105](https://github.com/ClickHouse/ClickHouse/pull/72105) ([Arthur Passos](https://github.com/arthurpassos)). +* Interactively request credentials in the browser if the default user requires a password. In previous versions, the server returned HTTP 403; now, it returns HTTP 401. [#72198](https://github.com/ClickHouse/ClickHouse/pull/72198) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Convert access types `CREATE_USER`, `ALTER_USER`, `DROP_USER`, `CREATE_ROLE`, `ALTER_ROLE`, `DROP_ROLE` from global to parameterized. That means users can now grant access management grants more precise:. [#72246](https://github.com/ClickHouse/ClickHouse/pull/72246) ([pufit](https://github.com/pufit)). +* Add the `latest_fail_error_code_name` column to `system.mutations`. We need this column to introduce a new metric on stuck mutations and use it to build graphs of the errors encountered in the cloud as well as, optionally, adding a new less-noisy alert. [#72398](https://github.com/ClickHouse/ClickHouse/pull/72398) ([Miсhael Stetsyuk](https://github.com/mstetsyuk)). +* Reduce amount of allocation in the `ATTACH PARTITION` query. [#72583](https://github.com/ClickHouse/ClickHouse/pull/72583) ([Konstantin Morozov](https://github.com/k-morozov)). +* Make `max_bytes_before_external_sort` limit depends on total query memory consumption (previously it was number of bytes in the sorting block for one sorting thread, now it has the same meaning as `max_bytes_before_external_group_by` - it is total limit for the whole query memory for all threads). Also one more setting added to control on disk block size - `min_external_sort_block_bytes`. [#72598](https://github.com/ClickHouse/ClickHouse/pull/72598) ([Azat Khuzhin](https://github.com/azat)). +* Ignore memory restrictions by trace collector. [#72606](https://github.com/ClickHouse/ClickHouse/pull/72606) ([Azat Khuzhin](https://github.com/azat)). +* Add server settings `dictionaries_lazy_load` and `wait_dictionaries_load_at_startup` to `system.server_settings`. [#72664](https://github.com/ClickHouse/ClickHouse/pull/72664) ([Christoph Wurm](https://github.com/cwurm)). +* Adds setting `max_backup_bandwidth` to the list of settings that can be specified as part of `BACKUP`/`RESTORE` queries. [#72665](https://github.com/ClickHouse/ClickHouse/pull/72665) ([Christoph Wurm](https://github.com/cwurm)). +* Reducing the log level for appearing replicated parts in the ReplicatedMergeTree engine to help minimize the volume of logs generated in a replicated cluster. [#72876](https://github.com/ClickHouse/ClickHouse/pull/72876) ([mor-akamai](https://github.com/morkalfon)). +* Improve extraction of common expression in disjunctions. Allow simplifying the resulting filter expression even if there's no common subexpression for all the disjuncts. Continuation of [#71537](https://github.com/ClickHouse/ClickHouse/issues/71537). [#73271](https://github.com/ClickHouse/ClickHouse/pull/73271) ([Dmitry Novik](https://github.com/novikd)). +* In Storage `S3Queue`/`AzureQueue` allow to add settings where table was created without settings. [#73283](https://github.com/ClickHouse/ClickHouse/pull/73283) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Introduce a setting `least_greatest_legacy_null_behavior` (default: `false`) which controls if functions `least` and `greatest` handle `NULL` arguments by unconditionally returning `NULL` (if `true`) or by ignoring them (if `false`). [#73344](https://github.com/ClickHouse/ClickHouse/pull/73344) ([Robert Schulze](https://github.com/rschu1ze)). +* Use Keeper multi requests in the cleanup thread of ObjectStorageQueueMetadata. [#73357](https://github.com/ClickHouse/ClickHouse/pull/73357) ([Antonio Andelic](https://github.com/antonio2368)). +* When ClickHouse runs under a cgroup we will still collect system-wide asynchronous metrics related to system load, process scheduling, memory etc. They might provide useful signals when ClickHouse is the only process on the host with high resource consumption. [#73369](https://github.com/ClickHouse/ClickHouse/pull/73369) ([Nikita Taranov](https://github.com/nickitat)). +* In storage `S3Queue` allow to transfer old ordered tables created before 24.6 to new structure with buckets. [#73467](https://github.com/ClickHouse/ClickHouse/pull/73467) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Add `system.azure_queue` similar to existing `system.s3queue`. [#73477](https://github.com/ClickHouse/ClickHouse/pull/73477) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Function `parseDateTime64` (and its variants) now produces correct results for input dates before 1970 / after 2106. Example: `SELECT parseDateTime64InJodaSyntax('2200-01-01 00:00:00.000', 'yyyy-MM-dd HH:mm:ss.SSS')`. [#73594](https://github.com/ClickHouse/ClickHouse/pull/73594) ([zhanglistar](https://github.com/zhanglistar)). +* Address some `clickhouse-disks` usability issues addressed by users. Closes [#67136](https://github.com/ClickHouse/ClickHouse/issues/67136). [#73616](https://github.com/ClickHouse/ClickHouse/pull/73616) ([Daniil Ivanik](https://github.com/divanik)). +* Allow to alter commit settings in storage S3(Azure)Queue. (Commit settings are: `max_processed_files_before_commit`, `max_processed_rows_before_commit`, `max_processed_bytes_before_commit`, `max_processing_time_sec_before_commit`). [#73635](https://github.com/ClickHouse/ClickHouse/pull/73635) ([Kseniia Sumarokova](https://github.com/kssenii)). +* In storage S3(Azure)Queue aggregate progress between sources to compare with commit limit settings. [#73641](https://github.com/ClickHouse/ClickHouse/pull/73641) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Support core settings in `BACKUP`/`RESTORE` query. [#73650](https://github.com/ClickHouse/ClickHouse/pull/73650) ([Vitaly Baranov](https://github.com/vitlibar)). +* Take into account the `output_format_compression_level` on Parquet output. [#73651](https://github.com/ClickHouse/ClickHouse/pull/73651) ([Arthur Passos](https://github.com/arthurpassos)). +* Adds reading Apache Arrow's `fixed_size_list` as an `Array` instead of treating it as an unsupported type. [#73654](https://github.com/ClickHouse/ClickHouse/pull/73654) ([Julian Meyers](https://github.com/J-Meyers)). +* Add two backup engines: `Memory` (keeps backups inside the current user session), and `Null` (don't keep backups anywhere), which is for testing. [#73690](https://github.com/ClickHouse/ClickHouse/pull/73690) ([Vitaly Baranov](https://github.com/vitlibar)). +* `concurrent_threads_soft_limit_num` and `concurrent_threads_soft_limit_num_ratio_to_cores` could be changed w/o restart of a server. [#73713](https://github.com/ClickHouse/ClickHouse/pull/73713) ([Sergei Trifonov](https://github.com/serxa)). +* Add support for extended numeric types (`Decimal`, big integers) in `formatReadable` functions. [#73765](https://github.com/ClickHouse/ClickHouse/pull/73765) ([Raúl Marín](https://github.com/Algunenano)). +* Support TLS for Postgres wire protocol compatibility. [#73812](https://github.com/ClickHouse/ClickHouse/pull/73812) ([scanhex12](https://github.com/scanhex12)). +* The function `isIPv4String` returned true if the correct IPv4 address was followed by a zero byte, while it should return false in this case. Continuation of [#65387](https://github.com/ClickHouse/ClickHouse/issues/65387). [#73946](https://github.com/ClickHouse/ClickHouse/pull/73946) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Make the error code in the MySQL wire protocol compatible with MySQL. Continuation of [#56831](https://github.com/ClickHouse/ClickHouse/issues/56831). Closes [#50957](https://github.com/ClickHouse/ClickHouse/issues/50957). [#73948](https://github.com/ClickHouse/ClickHouse/pull/73948) ([Alexey Milovidov](https://github.com/alexey-milovidov)). +* Add setting `validate_enum_literals_in_opearators` to validate enum literals in operators like `IN`, `NOT IN` against the enum type and throw an exception if the literal is not a valid enum value. [#73985](https://github.com/ClickHouse/ClickHouse/pull/73985) ([Vladimir Cherkasov](https://github.com/vdimir)). +* In Storage `S3(Azure)Queue` commit all files (in a single butch defined by commit settings) in a single keeper transaction. [#73991](https://github.com/ClickHouse/ClickHouse/pull/73991) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Disable header detection for executable UDFs and dictionaries (could lead to Function 'X': wrong result, expected Y row(s), actual Y-1). [#73992](https://github.com/ClickHouse/ClickHouse/pull/73992) ([Azat Khuzhin](https://github.com/azat)). +* Add the `distributed` option for `EXPLAIN PLAN.` Now, `EXPLAIN distributed=1 ... ` appends remote plan to `ReadFromParallelRemote*` steps. [#73994](https://github.com/ClickHouse/ClickHouse/pull/73994) ([Nikolai Kochetov](https://github.com/KochetovNicolai)). +* Use correct return type for not/xor with Dynamic arguments. [#74013](https://github.com/ClickHouse/ClickHouse/pull/74013) ([Pavel Kruglov](https://github.com/Avogar)). +* Allow changing `add_implicit_sign_column_constraint_for_collapsing_engine` after table creation. [#74014](https://github.com/ClickHouse/ClickHouse/pull/74014) ([Christoph Wurm](https://github.com/cwurm)). +* Support subcolumns in materialized view select query. [#74030](https://github.com/ClickHouse/ClickHouse/pull/74030) ([Pavel Kruglov](https://github.com/Avogar)). +* There are now three simple ways to set a custom prompt in `clickhouse-client`: 1. via command-line parameter `--prompt`, 2. in the configuration file, via settings `[...]`, and 3. also in the configuration file, via per-connection settings `[...]`. [#74168](https://github.com/ClickHouse/ClickHouse/pull/74168) ([Christoph Wurm](https://github.com/cwurm)). +* Autodetect secure connection based on connecting to port 9440 in ClickHouse Client. [#74212](https://github.com/ClickHouse/ClickHouse/pull/74212) ([Christoph Wurm](https://github.com/cwurm)). +* Authenticate users with username only for http_handlers (previously it requires user to put the password as well). [#74221](https://github.com/ClickHouse/ClickHouse/pull/74221) ([Azat Khuzhin](https://github.com/azat)). +* Support for the alternative query languages PRQL and KQL was marked experimental. To use them, specify settings `allow_experimental_prql_dialect = 1` and `allow_experimental_kusto_dialect = 1`. [#74224](https://github.com/ClickHouse/ClickHouse/pull/74224) ([Robert Schulze](https://github.com/rschu1ze)). +* Support returning the default Enum type in more aggregate functions. [#74272](https://github.com/ClickHouse/ClickHouse/pull/74272) ([Raúl Marín](https://github.com/Algunenano)). +* In `OPTIMIZE TABLE`, it is now possible to specify keyword `FORCE` as an alternative to existing keyword `FINAL`. [#74342](https://github.com/ClickHouse/ClickHouse/pull/74342) ([Robert Schulze](https://github.com/rschu1ze)). +* Add the `IsServerShuttingDown` metric, which is needed to trigger an alert when the server shutdown takes too much time. [#74429](https://github.com/ClickHouse/ClickHouse/pull/74429) ([Miсhael Stetsyuk](https://github.com/mstetsyuk)). +* Added Iceberg tables names to EXPLAIN. [#74485](https://github.com/ClickHouse/ClickHouse/pull/74485) ([alekseev-maksim](https://github.com/alekseev-maksim)). +* Provide a better error message when using RECURSIVE CTE with the old analyzer. [#74523](https://github.com/ClickHouse/ClickHouse/pull/74523) ([Raúl Marín](https://github.com/Algunenano)). +* Show extended error messages in `system.errors`. [#74574](https://github.com/ClickHouse/ClickHouse/pull/74574) ([Vitaly Baranov](https://github.com/vitlibar)). +* Allow to use password for client communication with clickhouse-keeper. This feature is not very useful if you specify proper SSL configuration for server and client, but still can be useful for some cases. Password cannot be longer than 16 characters. It's not connected with Keeper Auth model. [#74673](https://github.com/ClickHouse/ClickHouse/pull/74673) ([alesapin](https://github.com/alesapin)). +* Add error code for config reloader. [#74746](https://github.com/ClickHouse/ClickHouse/pull/74746) ([Garrett Thomas](https://github.com/garrettthomaskth)). +* Added support for IPv6 addresses in MySQL and PostgreSQL table functions and engines. [#74796](https://github.com/ClickHouse/ClickHouse/pull/74796) ([Mikhail Koviazin](https://github.com/mkmkme)). +* Implement short circuit optimization for `divideDecimal`. Fixes [#74280](https://github.com/ClickHouse/ClickHouse/issues/74280). [#74843](https://github.com/ClickHouse/ClickHouse/pull/74843) ([Kevin Mingtarja](https://github.com/kevinmingtarja)). +* Now users can be specified inside the startup scripts. [#74894](https://github.com/ClickHouse/ClickHouse/pull/74894) ([pufit](https://github.com/pufit)). +* Add support for Azure SAS Tokens. [#72959](https://github.com/ClickHouse/ClickHouse/pull/72959) ([Azat Khuzhin](https://github.com/azat)). + +#### Bug Fix (user-visible misbehavior in an official stable release) +* Set parquet compression level only if compression codec supports it. [#74659](https://github.com/ClickHouse/ClickHouse/pull/74659) ([Arthur Passos](https://github.com/arthurpassos)). +* Fixed a regression that using collation locales with modifiers throws an error. As an example, `SELECT arrayJoin(['kk 50', 'KK 01', ' KK 2', ' KK 3', 'kk 1', 'x9y99', 'x9y100']) item ORDER BY item ASC COLLATE 'tr-u-kn-true-ka-shifted` now works. [#73544](https://github.com/ClickHouse/ClickHouse/pull/73544) ([Robert Schulze](https://github.com/rschu1ze)). +* Fix cannot create SEQUENTIAL node with keeper-client. [#64177](https://github.com/ClickHouse/ClickHouse/pull/64177) ([Duc Canh Le](https://github.com/canhld94)). +* Fix incorrect character counting in the position functions. [#71003](https://github.com/ClickHouse/ClickHouse/pull/71003) ([思维](https://github.com/heymind)). +* `RESTORE` operations for access entities required more permission than necessary because of unhandled partial revokes. This PR fixes the issue. Closes [#71853](https://github.com/ClickHouse/ClickHouse/issues/71853). [#71958](https://github.com/ClickHouse/ClickHouse/pull/71958) ([pufit](https://github.com/pufit)). +* Avoid pause after `ALTER TABLE REPLACE/MOVE PARTITION FROM/TO TABLE`. Retrieve correct settings for background task scheduling. [#72024](https://github.com/ClickHouse/ClickHouse/pull/72024) ([Aleksei Filatov](https://github.com/aalexfvk)). +* Fix handling of empty tuples in some input and output formats (e.g. Parquet, Arrow). [#72616](https://github.com/ClickHouse/ClickHouse/pull/72616) ([Michael Kolupaev](https://github.com/al13n321)). +* Column-level GRANT SELECT/INSERT statements on wildcard databases/tables now throw an error. [#72646](https://github.com/ClickHouse/ClickHouse/pull/72646) ([Johann Gan](https://github.com/johanngan)). +* Fix the situation when a user can't run `REVOKE ALL ON *.*` because of implicit grants in the target access entity. [#72872](https://github.com/ClickHouse/ClickHouse/pull/72872) ([pufit](https://github.com/pufit)). +* Fix positive timezone formatting of formatDateTime scalar function. [#73091](https://github.com/ClickHouse/ClickHouse/pull/73091) ([ollidraese](https://github.com/ollidraese)). +* Fix to correctly reflect source port when connection made through PROXYv1 and `auth_use_forwarded_address` is set - previously proxy port was incorrectly used. Add `currentQueryID()` function. [#73095](https://github.com/ClickHouse/ClickHouse/pull/73095) ([Yakov Olkhovskiy](https://github.com/yakov-olkhovskiy)). +* Propagate format settings to NativeWriter in TCPHandler, so settings like `output_format_native_write_json_as_string` are applied correctly. [#73179](https://github.com/ClickHouse/ClickHouse/pull/73179) ([Pavel Kruglov](https://github.com/Avogar)). +* Fix a crash in StorageObjectStorageQueue. [#73274](https://github.com/ClickHouse/ClickHouse/pull/73274) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Fix rare crash in refreshable materialized view during server shutdown. [#73323](https://github.com/ClickHouse/ClickHouse/pull/73323) ([Michael Kolupaev](https://github.com/al13n321)). +* The `%f` placeholder of function `formatDateTime` now unconditionally generates six (sub-second) digits. This makes the behavior compatible with MySQL `DATE_FORMAT` function. The previous behavior can be restored using setting `formatdatetime_f_prints_scale_number_of_digits = 1`. [#73324](https://github.com/ClickHouse/ClickHouse/pull/73324) ([ollidraese](https://github.com/ollidraese)). +* Fixed filtering by `_etag` column while reading from `s3` storage and table function. [#73353](https://github.com/ClickHouse/ClickHouse/pull/73353) ([Anton Popov](https://github.com/CurtizJ)). +* Fix `Not-ready Set is passed as the second argument for function 'in'` error when `IN (subquery)` is used in `JOIN ON` expression, with the old analyzer. [#73382](https://github.com/ClickHouse/ClickHouse/pull/73382) ([Nikolai Kochetov](https://github.com/KochetovNicolai)). +* Fix preparing for squashin for Dynamic and JSON columns. Previously in some cases new types could be inserted into shared variant/shared data even when the limit on types/paths is not reached. [#73388](https://github.com/ClickHouse/ClickHouse/pull/73388) ([Pavel Kruglov](https://github.com/Avogar)). +* Check for corrupted sizes during types binary decoding to avoid too big allocations. [#73390](https://github.com/ClickHouse/ClickHouse/pull/73390) ([Pavel Kruglov](https://github.com/Avogar)). +* Fixed a logical error when reading from single-replica cluster with parallel replicas enabled. [#73403](https://github.com/ClickHouse/ClickHouse/pull/73403) ([Michael Kolupaev](https://github.com/al13n321)). +* Fix ObjectStorageQueue with ZooKeeper and older Keeper. [#73420](https://github.com/ClickHouse/ClickHouse/pull/73420) ([Antonio Andelic](https://github.com/antonio2368)). +* Implements fix, needed to enable hive partitioning by default. [#73479](https://github.com/ClickHouse/ClickHouse/pull/73479) ([Yarik Briukhovetskyi](https://github.com/yariks5s)). +* Fix data race when creating vector similarity index. [#73517](https://github.com/ClickHouse/ClickHouse/pull/73517) ([Antonio Andelic](https://github.com/antonio2368)). +* Fixes segfault when the source of the dictionary contains a function with wrong data. [#73535](https://github.com/ClickHouse/ClickHouse/pull/73535) ([Yarik Briukhovetskyi](https://github.com/yariks5s)). +* Fix retries on failed insert in storage S3(Azure)Queue. Closes [#70951](https://github.com/ClickHouse/ClickHouse/issues/70951). [#73546](https://github.com/ClickHouse/ClickHouse/pull/73546) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Fixed error in function `tupleElement` which may appear in some cases for tuples with `LowCardinality` elements and enabled setting `optimize_functions_to_subcolumns`. [#73548](https://github.com/ClickHouse/ClickHouse/pull/73548) ([Anton Popov](https://github.com/CurtizJ)). +* Fix parsing enum glob followed by range one. Fixes [#73473](https://github.com/ClickHouse/ClickHouse/issues/73473). [#73569](https://github.com/ClickHouse/ClickHouse/pull/73569) ([Konstantin Bogdanov](https://github.com/thevar1able)). +* Fixed parallel_replicas_for_non_replicated_merge_tree being ignored in subqueries for non-replicated tables. [#73584](https://github.com/ClickHouse/ClickHouse/pull/73584) ([Igor Nikonov](https://github.com/devcrafter)). +* Fix for std::logical_error thrown when task cannot be scheduled. Found in stress tests. [#73629](https://github.com/ClickHouse/ClickHouse/pull/73629) ([Alexander Gololobov](https://github.com/davenger)). +* Do not interpret queries in `EXPLAIN SYNTAX` to avoid logical errors with incorrect processing stage for distributed queries. Fixes [#65205](https://github.com/ClickHouse/ClickHouse/issues/65205). [#73634](https://github.com/ClickHouse/ClickHouse/pull/73634) ([Dmitry Novik](https://github.com/novikd)). +* Fix possible data inconsistency in Dynamic column. Fixes possible logical error `Nested columns sizes are inconsistent with local_discriminators column size`. [#73644](https://github.com/ClickHouse/ClickHouse/pull/73644) ([Pavel Kruglov](https://github.com/Avogar)). +* Fixed `NOT_FOUND_COLUMN_IN_BLOCK` in queries with `FINAL` and `SAMPLE`. Fixed incorrect result in selects with `FINAL` from `CollapsingMergeTree` and enabled optimizations of `FINAL` . [#73682](https://github.com/ClickHouse/ClickHouse/pull/73682) ([Anton Popov](https://github.com/CurtizJ)). +* Fix crash in LIMIT BY COLUMNS. [#73686](https://github.com/ClickHouse/ClickHouse/pull/73686) ([Raúl Marín](https://github.com/Algunenano)). +* Fix the bug when the normal projection is forced to use, and query is exactly the same as the projection defined, but the projection is not selected and thus error is prompted. [#73700](https://github.com/ClickHouse/ClickHouse/pull/73700) ([Shichao Jin](https://github.com/jsc0218)). +* Fix deserialization of Dynamic/Object structure. It could lead to CANNOT_READ_ALL_DATA exceptions. [#73767](https://github.com/ClickHouse/ClickHouse/pull/73767) ([Pavel Kruglov](https://github.com/Avogar)). +* Skip `metadata_version.txt` in while restoring parts from a backup. [#73768](https://github.com/ClickHouse/ClickHouse/pull/73768) ([Vitaly Baranov](https://github.com/vitlibar)). +* Fix segmentation fault when Casting to Enum with LIKE. [#73775](https://github.com/ClickHouse/ClickHouse/pull/73775) ([zhanglistar](https://github.com/zhanglistar)). +* Fix for S3 Express bucket not working as disk. [#73777](https://github.com/ClickHouse/ClickHouse/pull/73777) ([Sameer Tamsekar](https://github.com/stamsekar)). +* Allow merging of rows with invalid sign column values in CollapsingMergeTree tables. [#73864](https://github.com/ClickHouse/ClickHouse/pull/73864) ([Christoph Wurm](https://github.com/cwurm)). +* Fix getting error when querying ddl with offline replica. [#73876](https://github.com/ClickHouse/ClickHouse/pull/73876) ([Tuan Pham Anh](https://github.com/tuanpach)). +* Fixes occasional failure to compare `map()` types due to possibility to create `Map` lacking explicit naming ('keys','values') of its nested tuple. [#73878](https://github.com/ClickHouse/ClickHouse/pull/73878) ([Yakov Olkhovskiy](https://github.com/yakov-olkhovskiy)). +* Ignore window functions during GROUP BY ALL clause resolution. Fix [#73501](https://github.com/ClickHouse/ClickHouse/issues/73501). [#73916](https://github.com/ClickHouse/ClickHouse/pull/73916) ([Dmitry Novik](https://github.com/novikd)). +* Fix implicit privileges (worked as wildcard before). [#73932](https://github.com/ClickHouse/ClickHouse/pull/73932) ([Azat Khuzhin](https://github.com/azat)). +* Fix high memory usage during nested Maps creation. [#73982](https://github.com/ClickHouse/ClickHouse/pull/73982) ([Pavel Kruglov](https://github.com/Avogar)). +* Fix parsing nested JSON with empty keys. [#73993](https://github.com/ClickHouse/ClickHouse/pull/73993) ([Pavel Kruglov](https://github.com/Avogar)). +* Fix: alias can be not added to the projection if it is referenced by another alias and selected in inverse order. [#74033](https://github.com/ClickHouse/ClickHouse/pull/74033) ([Yakov Olkhovskiy](https://github.com/yakov-olkhovskiy)). +* Ignore object not found errors for Azure during plain_rewritable disk initialization. [#74059](https://github.com/ClickHouse/ClickHouse/pull/74059) ([Julia Kartseva](https://github.com/jkartseva)). +* Fix behaviour of `any` and `anyLast` with enum types and empty table. [#74061](https://github.com/ClickHouse/ClickHouse/pull/74061) ([Joanna Hulboj](https://github.com/jh0x)). +* Fixes case when the user specifies keyword arguments in the kafka table engine. [#74064](https://github.com/ClickHouse/ClickHouse/pull/74064) ([Yarik Briukhovetskyi](https://github.com/yariks5s)). +* Fix altering Storage `S3Queue` settings with "s3queue_" prefix to without and vice versa. [#74075](https://github.com/ClickHouse/ClickHouse/pull/74075) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Add a setting `allow_push_predicate_ast_for_distributed_subqueries`. This adds AST-based predicate push-down for distributed queries with the analyzer. This is a temporary solution that we use until distributed queries with query plan serialization are supported. Closes [#66878](https://github.com/ClickHouse/ClickHouse/issues/66878) [#69472](https://github.com/ClickHouse/ClickHouse/issues/69472) [#65638](https://github.com/ClickHouse/ClickHouse/issues/65638) [#68030](https://github.com/ClickHouse/ClickHouse/issues/68030) [#73718](https://github.com/ClickHouse/ClickHouse/issues/73718). [#74085](https://github.com/ClickHouse/ClickHouse/pull/74085) ([Nikolai Kochetov](https://github.com/KochetovNicolai)). +* Fixes issue when after [#73095](https://github.com/ClickHouse/ClickHouse/issues/73095) port can be present in the forwarded_for field, which leads to inability to resolve host name with port included. [#74116](https://github.com/ClickHouse/ClickHouse/pull/74116) ([Yakov Olkhovskiy](https://github.com/yakov-olkhovskiy)). +* Fixed incorrect formatting of `ALTER TABLE (DROP STATISTICS ...) (DROP STATISTICS ...)`. [#74126](https://github.com/ClickHouse/ClickHouse/pull/74126) ([Han Fei](https://github.com/hanfei1991)). +* Fix for issue [#66112](https://github.com/ClickHouse/ClickHouse/issues/66112). [#74128](https://github.com/ClickHouse/ClickHouse/pull/74128) ([Anton Ivashkin](https://github.com/ianton-ru)). +* It is no longer possible to use `Loop` as a table engine in `CREATE TABLE`. This combination was previously causing segfaults. [#74137](https://github.com/ClickHouse/ClickHouse/pull/74137) ([Yarik Briukhovetskyi](https://github.com/yariks5s)). +* Fix security issue to prevent SQL injection in postgresql and sqlite table functions. [#74144](https://github.com/ClickHouse/ClickHouse/pull/74144) ([Pablo Marcos](https://github.com/pamarcos)). +* Fix crash when reading a subcolumn from the compressed Memory engine table. Fixes [#74009](https://github.com/ClickHouse/ClickHouse/issues/74009). [#74161](https://github.com/ClickHouse/ClickHouse/pull/74161) ([Nikita Taranov](https://github.com/nickitat)). +* Fixed an infinite loop occurring with queries to the system.detached_tables. [#74190](https://github.com/ClickHouse/ClickHouse/pull/74190) ([Konstantin Morozov](https://github.com/k-morozov)). +* Fix logical error in s3queue during setting file as failed. [#74216](https://github.com/ClickHouse/ClickHouse/pull/74216) ([Kseniia Sumarokova](https://github.com/kssenii)). +* Fix native copy settings (`allow_s3_native_copy`/`allow_azure_native_copy`) for `RESTORE` from base backup. [#74286](https://github.com/ClickHouse/ClickHouse/pull/74286) ([Azat Khuzhin](https://github.com/azat)). +* Fixed the issue when the number of detached tables in the database is a multiple of max_block_size. [#74289](https://github.com/ClickHouse/ClickHouse/pull/74289) ([Konstantin Morozov](https://github.com/k-morozov)). +* Fix copying via ObjectStorage (i.e. S3) when source and destination credentials differs. [#74331](https://github.com/ClickHouse/ClickHouse/pull/74331) ([Azat Khuzhin](https://github.com/azat)). +* Fix detection of "use the Rewrite method in the JSON API" for native copy on GCS. [#74338](https://github.com/ClickHouse/ClickHouse/pull/74338) ([Azat Khuzhin](https://github.com/azat)). +* Fix incorrect calculation of `BackgroundMergesAndMutationsPoolSize` (it was x2 from real value). [#74509](https://github.com/ClickHouse/ClickHouse/pull/74509) ([alesapin](https://github.com/alesapin)). +* Fix the bug of leaking keeper watches when enable Cluster Discovery. [#74521](https://github.com/ClickHouse/ClickHouse/pull/74521) ([RinChanNOW](https://github.com/RinChanNOWWW)). +* Fix mem alignment issue reported by UBSan [#74512](https://github.com/ClickHouse/ClickHouse/issues/74512). [#74534](https://github.com/ClickHouse/ClickHouse/pull/74534) ([Arthur Passos](https://github.com/arthurpassos)). +* Fix KeeperMap concurrent cleanup during table creation. [#74568](https://github.com/ClickHouse/ClickHouse/pull/74568) ([Antonio Andelic](https://github.com/antonio2368)). +* Do not remove unused projection columns in subqueries in the presence of `EXCEPT` or `INTERSECT` to preserve the correct query result. Fixes [#73930](https://github.com/ClickHouse/ClickHouse/issues/73930). Fixes [#66465](https://github.com/ClickHouse/ClickHouse/issues/66465). [#74577](https://github.com/ClickHouse/ClickHouse/pull/74577) ([Dmitry Novik](https://github.com/novikd)). +* Fixed `INSERT SELECT` queries between tables with `Tuple` columns and enabled sparse serialization. [#74698](https://github.com/ClickHouse/ClickHouse/pull/74698) ([Anton Popov](https://github.com/CurtizJ)). +* Function `right` works incorrectly for const negative offset. [#74701](https://github.com/ClickHouse/ClickHouse/pull/74701) ([Daniil Ivanik](https://github.com/divanik)). +* Fix insertion of gzip-ed data sometimes fails due to flawed decompression on client side. [#74707](https://github.com/ClickHouse/ClickHouse/pull/74707) ([siyuan](https://github.com/linkwk7)). +* Partial revokes with wildcard grants could remove more privileges than expected. Closes [#74263](https://github.com/ClickHouse/ClickHouse/issues/74263). [#74751](https://github.com/ClickHouse/ClickHouse/pull/74751) ([pufit](https://github.com/pufit)). +* Keeper fix: fix reading log entries from disk. [#74785](https://github.com/ClickHouse/ClickHouse/pull/74785) ([Antonio Andelic](https://github.com/antonio2368)). +* Fixed checking grants for SYSTEM REFRESH/START/STOP VIEW, now it's not required to have this grant on `*.*` to execute a query for a specific view, only grant for this view are required. [#74789](https://github.com/ClickHouse/ClickHouse/pull/74789) ([Alexander Tokmakov](https://github.com/tavplubix)). +* The `hasColumnInTable` function doesn't account for alias columns. Fix it to also work for alias columns. [#74841](https://github.com/ClickHouse/ClickHouse/pull/74841) ([Bharat Nallan](https://github.com/bharatnc)). +* Fix FILE_DOESNT_EXIST error occurring during data parts merge for a table with an empty column in Azure Blob Storage. [#74892](https://github.com/ClickHouse/ClickHouse/pull/74892) ([Julia Kartseva](https://github.com/jkartseva)). +* Fix projection column name when joining temporary tables, close [#68872](https://github.com/ClickHouse/ClickHouse/issues/68872). [#74897](https://github.com/ClickHouse/ClickHouse/pull/74897) ([Vladimir Cherkasov](https://github.com/vdimir)). + +#### Build/Testing/Packaging Improvement +* The universal installation script will propose installation even on macOS. [#74339](https://github.com/ClickHouse/ClickHouse/pull/74339) ([Alexey Milovidov](https://github.com/alexey-milovidov)). diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/whats-new/roadmap.md b/i18n/zh/docusaurus-plugin-content-docs/current/whats-new/roadmap.md index d30f4c68a49..bd96443545e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/whats-new/roadmap.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/whats-new/roadmap.md @@ -3,15 +3,16 @@ title: 'Roadmap' slug: /whats-new/roadmap sidebar_position: 50 description: 'Present and past ClickHouse road maps' +doc_type: 'landing-page' --- -## Current Roadmap {#current-roadmap} +## Current roadmap {#current-roadmap} The current roadmap is published for open discussion: - [2025](https://github.com/ClickHouse/ClickHouse/issues/74046) -## Previous Roadmaps {#previous-roadmaps} +## Previous roadmaps {#previous-roadmaps} - [2024](https://github.com/ClickHouse/ClickHouse/issues/58392) - [2023](https://github.com/ClickHouse/ClickHouse/issues/44767) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/whats-new/security-changelog.md b/i18n/zh/docusaurus-plugin-content-docs/current/whats-new/security-changelog.md index 1c79dca658c..20e9e44e0ff 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/whats-new/security-changelog.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/whats-new/security-changelog.md @@ -1,12 +1,13 @@ --- slug: /whats-new/security-changelog sidebar_position: 20 -sidebar_label: 'Security Changelog' -title: 'Security Changelog' +sidebar_label: 'Security changelog' +title: 'Security changelog' description: 'Security changelog detailing security related updates and changes' +doc_type: 'changelog' --- -# Security Changelog +# Security changelog ## Fixed in ClickHouse v25.1.5.5, 2025-01-05 {#fixed-in-clickhouse-release-2025-01-05} From c163bdadf83df5a9eb798f50ac9a7d93c43e6bbc Mon Sep 17 00:00:00 2001 From: Shaun Struwig <41984034+Blargian@users.noreply.github.com> Date: Tue, 7 Oct 2025 11:55:16 +0200 Subject: [PATCH 2/2] Update README with time last retranslated --- i18n/zh/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i18n/zh/README.md b/i18n/zh/README.md index a9f5193e9ae..7a46ce88434 100644 --- a/i18n/zh/README.md +++ b/i18n/zh/README.md @@ -2,4 +2,4 @@ Modify this date to initiate rebuild: -`Wed 11 Jun 2025 11:23 GMT` +Last retranslated: `Tues 7 October 2025 11:54 GMT`